diff --git a/Linux_SGXEclipsePlugin/build.sh b/Linux_SGXEclipsePlugin/build.sh new file mode 100755 index 0000000000..9c36296fd6 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build.sh @@ -0,0 +1,202 @@ +#!/bin/bash +export PATH=/home/jenkins/jdk/bin/:$PATH + + +# Get the Eclipse launcher and build script to use +set -x +set -e + +TRUNK_HOME=$(cd $(pwd)/../../ ; pwd) +#gives you the posibility to overwrite eclipse, if you do not use URL +[ -n "${ECLIPSE_HOME}" ] || { echo "using default ECLIPSE_HOME=${TRUNK_HOME}/eclipse"; ECLIPSE_HOME=${TRUNK_HOME}/eclipse; } + + +BUILD_RELEASE_ID_PREFIX=Linux_SGX_1.5 + +if [ "$RELEASE_ID" != "${RELEASE_ID%$BUILD_RELEASE_ID_PREFIX*}" ]; then + echo "$BUILD_RELEASE_ID_PREFIX IS in $RELEASE_ID, so it is an triggered build. Change the RELEASE_ID to an accepted form." + temp=${RELEASE_ID#$BUILD_RELEASE_ID_PREFIX} + RELEASE_ID=v`echo ${temp} | tr -d _ | tr -d -` +else + echo "$BUILD_RELEASE_ID_PREFIX is NOT in $RELEASE_ID. Keeping the user specified RELEASE_ID." +fi + +function main() { + validate-jenkins-parameters + cleanupPreBuild + checkEnvironment + buildPlugin + archivePlugin +} + +function validate-jenkins-parameters { + validate-parameter "DELETE_CURRENT_ECLIPSE" "$DELETE_CURRENT_ECLIPSE" + [[ "ECLIPSE_DOWNLOAD_URL" != "" ]] && + echo "[WARNING] ECLIPSE_DOWNLOAD_URL is not set; assume eclipse archive is already downloaded" +} + +function validate-parameter { + local NAME="$1" + local VALUE="$2" + [[ ! -z "$VALUE" ]] || { + echo "Mandatory Jenkins parameter '\$$NAME' not set !" + exit 1 + } +} + +function cleanupPreBuild() { + ./clean.sh + + [[ "false" == "${DELETE_CURRENT_ECLIPSE}" ]] || { + forceRemoveEclipse + } +} + +function forceRemoveEclipse() { + pushd ${TRUNK_HOME} + rm -fr eclipse + popd +} + +function checkEnvironment() { + if [ ! -d "${ECLIPSE_HOME}" ]; then + echo "Eclipse does not exist" + echo "Downloading eclipse" + + getEclipse + fi + + if [ -z "$RELEASE_ID" ]; then + echo "Mandatory variable RELEASE_ID not defined; exiting" + exit + fi +} + +function getEclipse() { + local eclipseArchiveURL="${ECLIPSE_DOWNLOAD_URL}" + + pushd $TRUNK_HOME + cleanupEclipseArchive + downloadEclipse "${eclipseArchiveURL}" + unzipEclipse + installPDE + cleanupEclipseArchive + popd +} + +function cleanupEclipseArchive() { + find . -maxdepth 1 -mindepth 1 -name "*eclipse*.zip*" | xargs rm -f +} + +function downloadEclipse() { + local URL="$1" + if [[ "$1" != "" ]] ; then + echo " wget --no-proxy "$1"" + wget --no-proxy "$1" + else + echo "skip downloaded empty url" + fi + +} + +function unzipEclipse() { + pwd + rm -fr eclipse + local eclipseArchiveName="$(find . -maxdepth 1 -mindepth 1 -name "*eclipse*.zip*")" + unzip "${eclipseArchiveName}" + + [[ -d eclipse ]] || { + echo "Eclipse directory does not exist!" + exit + } + +# local eclipseFolderName=${eclipseArchiveName%.zip} +# local eclipseArchiveName="eclipse" +# mv "${eclipseFolderName}" eclipse +} + +function installPDE() { +echo "~~~~>" +pwd +${ECLIPSE_HOME}/eclipse -nosplash \ + -application org.eclipse.equinox.p2.director \ + -repository http://download.eclipse.org/eclipse/updates/4.4 \ + -destination ${ECLIPSE_HOME} \ + -installIU org.eclipse.pde.source.feature.group \ + -installIU org.eclipse.pde.feature.group +} + +function buildPlugin() { + pwd + + echo "PWD=`pwd`" + echo "ECLIPSE_HOME=$ECLIPSE_HOME" + + #BASELOCATION="$PWD/target_platform" + BASELOCATION="$ECLIPSE_HOME" + BUILDVERSION="$RELEASE_ID" + BUILDDIR="$PWD/build_directory" + BUILDCONFIG="$PWD/build_config" + LAUNCHER=`findFirst "$ECLIPSE_HOME"/plugins/org.eclipse.equinox.launcher_*.jar` + BUILDFILE=`findFirst "$ECLIPSE_HOME"/plugins/org.eclipse.pde.build_*/scripts/build.xml` + + # make sure we found valid files + if [ ! -f "$LAUNCHER" ]; then + echo "Installation Error: Eclipse plugin org.eclipse.equinox.launcher...jar not detected. " \ + "Found '$LAUNCHER'. Aborting." + exit 1 + fi + if [ ! -f "$BUILDFILE" ]; then + echo "Installation Error: Eclipse build file org.eclipse.pde.build_.../scripts/build.xml " \ + "not detected. Found '$BUILDFILE'. Aborting." + exit 1 + fi + + # + # -- Print configuration used and actually execute the build -- + # + echo "Eclipse configuration found:" + echo " Eclipse Home: $ECLIPSE_HOME" + echo " Launcher: $LAUNCHER" + echo " Build File: $BUILDFILE" + echo " Build Config: $BUILDCONFIG" + echo " Base Location: $BASELOCATION" + echo " Build Directory: $BUILDDIR" + echo " Build Version: $BUILDVERSION" + echo " Java: " $(which java) + java -version + +# CURRENT_DIR=$(pwd) +# ${ECLIPSE_HOME}/eclipse -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file:/${CURRENT_DIR}/build_directory/updatesite/sgx-eclipse-plugin -artifactRepository file:/${CURRENT_DIR}/build_directory/updatesite/featuresAndBundles -source ${CURRENT_DIR}/build_directory/ -config gtk.linux.x86 -compress -publishArtifacts +# cp ./build_directory/updatesite/featuresAndBundles/artifacts.jar ./build_directory/updatesite/sgx-eclipse-plugin/ + + java \ + -jar $LAUNCHER \ + -application org.eclipse.ant.core.antRunner \ + -buildfile $BUILDFILE \ + -DbuildDirectory=$BUILDDIR \ + -DbaseLocation=$BASELOCATION \ + -Dbuilder=$BUILDCONFIG \ + -DforceContextQualifier=$BUILDVERSION \ + -v -v -v -v + +} + +function findFirst() { + echo "enter Find First, $@" 1>&2 + for i in "$@"; do + if [ -f "$i" ]; then + echo "found $i" 1>&2 + echo "$i" + return + fi + done +} + +function archivePlugin() { + pushd build_directory/updatesite/sgx-eclipse-plugin + zip -r Intel-sgx-eclipse-plugin.zip * + popd +} + +main diff --git a/Linux_SGXEclipsePlugin/build_config/allElements.xml b/Linux_SGXEclipsePlugin/build_config/allElements.xml new file mode 100644 index 0000000000..0bb5016556 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_config/allElements.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_config/build.properties b/Linux_SGXEclipsePlugin/build_config/build.properties new file mode 100644 index 0000000000..beda7eaf99 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_config/build.properties @@ -0,0 +1,307 @@ + +############################################################################### +# Copyright (c) 2003, 2011 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +# Compuware Corporation - Sebastien Angers +# - Enabled additional mirror slicingOptions in Headless PDE Build +# - Enabled 'raw' attribute for mirror step in Headless PDE Build +# - https://bugs.eclipse.org/338878 +############################################################################### +##################### +# Parameters describing how and where to execute the build. +# Typical users need only update the following properties: +# baseLocation - where things you are building against are installed +# bootclasspath - The base jars to compile against (typicaly rt.jar) +# configs - the list of {os, ws, arch} configurations to build. +# +# Of course any of the settings here can be overridden by spec'ing +# them on the command line (e.g., -DbaseLocation=d:/eclipse + +#The type of the top level element we are building, generally "feature" +topLevelElementType = feature +#The id of the top level element we are building +# the following feature will not be include in the final archive +topLevelElementId = com.intel.sgx.build.driver + +############# PRODUCT/PACKAGING CONTROL ############# +#product=/plugin or feature id/path/to/.product +#product=com.intel.sgx.feature +runPackager=false + +#Set the name of the archive that will result from the product build. +#archiveNamePrefix= + +# The prefix that will be used in the generated archive. +archivePrefix=sgx-eclipse-plugin + +# The location underwhich all of the build output will be collected. +collectingFolder=${archivePrefix} + +# The list of {os, ws, arch} configurations to build. This +# value is a '&' separated list of ',' separate triples. For example, +# configs=win32,win32,x86 & linux,motif,x86 +# By default the value is *,*,* +configs = *, *, * +#configs=win32, win32, x86 & \ +# win32,win32,x86_64 & \ +# win32,win32,wpf & \ +# linux, gtk, ppc & \ +# linux, gtk, x86 & \ +# linux, gtk, x86_64 & \ +# linux, motif, x86 & \ +# solaris, motif, sparc & \ +# solaris, gtk, sparc & \ +# aix, motif, ppc & \ +# hpux, motif, ia64_32 & \ +# macosx, carbon, ppc & \ +# macosx, carbon, x86 & \ +# macosx, cocoa, ppc & \ +# macosx, cocoa, x86 & \ +# macosx, cocoa, x86_64 + +# By default PDE creates one archive (result) per entry listed in the configs property. +# Setting this value to true will cause PDE to only create one output containing all +# artifacts for all the platforms listed in the configs property. +# To control the output format for the group, add a "group, group, group - " entry to the +# archivesFormat. +#groupConfigurations=true + +#The format of the archive. By default a zip is created using antZip. +#The list can only contain the configuration for which the desired format is different than zip. +#archivesFormat=win32, win32, x86 - antZip& \ +# linux, gtk, ppc - antZip &\ +# linux, gtk, x86 - antZip& \ +# linux, gtk, x86_64 - antZip& \ +# linux, motif, x86 - antZip& \ +# solaris, motif, sparc - antZip& \ +# solaris, gtk, sparc - antZip& \ +# aix, motif, ppc - antZip& \ +# hpux, motif, PA_RISC - antZip& \ +# macosx, carbon, ppc - antZip + +#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles. +allowBinaryCycles = true + +#Sort bundles depenedencies across all features instead of just within a given feature. +#flattenDependencies = true + +#Parallel compilation, requires flattenedDependencies=true +#parallelCompilation=true +#parallelThreadCount= +#parallelThreadsPerProcessor= + +#Set to true if you want the output to be ready for an update jar (no site.xml generated) +outputUpdateJars = true + +#Set to true for Jnlp generation +#codebase should be a URL that will be used as the root of all relative URLs in the output. +#generateJnlp=false +#jnlp.codebase= +#jnlp.j2se= +#jnlp.locale= +#jnlp.generateOfflineAllowed=true or false generate attribute in the generated features +#jnlp.configs=${configs} #uncomment to filter the content of the generated jnlp files based on the configuration being built + +#Set to true if you want to sign jars +#signJars=false +#sign.alias= +#sign.keystore= +#sign.storepass= +#sign.keypass= + +#Arguments to send to the zip executable +zipargs= + +#Arguments to send to the tar executable +tarargs= + +#individualSourceBundles=true + +#Control the creation of a file containing the version included in each configuration - on by default +#generateVersionsLists=false + +############ REPO MIRROR OPTIONS CONTROL ############ +# Default values for the slicingOptions and raw attribute of the p2.mirror Ant target used to generate the p2 repo (buildRepo) +# Note that the default values used by PDE/Build are different from the default values for p2.mirror's slicingOptions and raw attribute +# See http://help.eclipse.org/topic//org.eclipse.platform.doc.isv/guide/p2_repositorytasks.htm for the details +# of each setting. +#p2.mirror.slicing.filter= +#p2.mirror.slicing.followOnlyFilteredRequirements=false +#p2.mirror.slicing.followStrict=false +#p2.mirror.slicing.includeFeatures=true +#p2.mirror.slicing.includeNonGreedy=false +#p2.mirror.slicing.includeOptional=true +#p2.mirror.slicing.platformFilter= +#p2.mirror.slicing.latestVersionOnly=false + +#p2.mirror.raw=false + +############## SOURCE BUNDLE CONTROL ################ +# Set this property to have source bundles created and output into build repository. +# This does NOT put them in the build output (e.g., product) itself. +# Valid values are: not set, built, all. +# built = only source for bundles that are actually built/compiled in this run are output +# all = all available source is collected and output +#sourceBundleMode=all + +# When outputting autogenerated source bundles a feature is created to contain all the automatic +# source bundles. Typically this feature is not needed and can be ignored. As such, it is given a default +# name and version. These properties can be used to override the defaults. +# sourceBundleTemplateFeature - can specify an existing feature which will be augmented to form the generated source feature +# sourceBundleFeatureId - will be the id of generated source feature which contains all the generated source bundles, default value +# is sourceBundleTemplateFeature + ".source" if sourceBundleTemplateFeature is specified +#sourceBundleTemplateFeature= +#sourceBundleFeatureId= +#sourceBundleFeatureVersion= + +############## BUILD NAMING CONTROL ################ +# The directory into which the build elements are fetched and where +# the build takes place. +#buildDirectory= + +# Type of build. Used in naming the build output. Typically this value is +# one of I, N, M, S, ... +buildType=build + +# ID of the build. Used in naming the build output. +buildId=${forceContextQualifier} + +# Label for the build. Used in naming the build output +buildLabel=${buildId} + +# Timestamp for the build. Used in naming the build output +timestamp=007 + +#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde. +#The value will only be applied to plugin or features indicating build.properties, qualifier = context +#forceContextQualifier= + +#Enable / disable the generation of a suffix for the features that use .qualifier. +#The generated suffix is computed according to the content of the feature +#generateFeatureVersionSuffix=true + +############# BASE CONTROL ############# +# Settings for the base Eclipse components and Java class libraries +# against which you are building. +# Base location for anything the build needs to compile against. For example, +# in most RCP app or a plug-in, the baseLocation should be the location of a previously +# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack. + +base= +#baseLocation= + +#Folder containing repositories whose content is needed to compile against +#repoBaseLocation=${base}/repos +#Folder where the content of the repositories from ${repoBaseLocation} will be made available as a form suitable to be compiled against +#transformedRepoLocation=${base}/transformedRepos + +#Os/Ws/Arch/nl of the eclipse specified by baseLocation +baseos=win32 +basews=win32 +basearch=x86 + +#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built +filteredDependencyCheck=false + +#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons) +resolution.devMode=false + +#pluginPath is a list of locations in which to find plugins and features. This list is separated by the platform file separator (; or :) +#a location is one of: +#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo +#- a directory that contains a /plugins or /features subdirectory +#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml +#pluginPath= + +skipBase=true +eclipseURL= +eclipseBuildId= +eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip + + +############# MAP FILE CONTROL ################ +# This section defines CVS tags to use when fetching the map files from the repository. +# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml + +skipMaps=true +mapsRepo=:pserver:anonymous@example.com/path/to/repo +mapsRoot=path/to/maps +mapsCheckoutTag=HEAD + +#tagMaps=true +mapsTagTag=v${buildId} + + +############ REPOSITORY CONTROL ############### +# This section defines properties parameterizing the repositories where plugins, fragments +# bundles and features are being obtained from. + +# The tags to use when fetching elements to build. +# By default thebuilder will use whatever is in the maps. +# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the +# overriding value +# For example fetchTag=CVS=HEAD, SVN=v20050101 +# fetchTag=HEAD +skipFetch=true + + +############# JAVA COMPILER OPTIONS ############## +# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE +#bootclasspath=${java.home}/lib/rt.jar + +# specific JRE locations to compile against. These values are used to compile bundles specifying a +# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support +#CDC-1.0/Foundation-1.0= /path/to/rt.jar +#CDC-1.1/Foundation-1.1= +#OSGi/Minimum-1.0= +#OSGi/Minimum-1.1= +#JRE-1.1= +#J2SE-1.2= +#J2SE-1.3= +#J2SE-1.4= +#J2SE-1.5= +#JavaSE-1.6= +#PersonalJava-1.1= +#PersonalJava-1.2= +#CDC-1.0/PersonalBasis-1.0= +#CDC-1.0/PersonalJava-1.0= +#CDC-1.1/PersonalBasis-1.1= +#CDC-1.1/PersonalJava-1.1= + +# Specify the output format of the compiler log when eclipse jdt is used +logExtension=.log + +# Whether or not to include debug info in the output jars +javacDebugInfo=false + +# Whether or not to fail the build if there are compiler errors +javacFailOnError=true + +# Enable or disable verbose mode of the compiler +javacVerbose=true + +# Extra arguments for the compiler. These are specific to the java compiler being used. +#compilerArg= + +# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties +javacSource=1.6 + +# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties. +javacTarget=1.6 + +################### CUSTOM PROPERTIES ####################################### +# repository location for update site +# comment out - this is passed in from command line +updateSiteSource=${buildDirectory}/sites +# where to place update site build +#updateSiteRoot=${user.home}/www/no_crawl/ +updateSiteRoot=${buildDirectory}/updatesite +updateSiteFolder=${archivePrefix} +updateSiteDestination=${updateSiteRoot}/${updateSiteFolder} + diff --git a/Linux_SGXEclipsePlugin/build_config/buildUpdateSite.xml b/Linux_SGXEclipsePlugin/build_config/buildUpdateSite.xml new file mode 100644 index 0000000000..a01006f811 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_config/buildUpdateSite.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_config/customAssembly.xml b/Linux_SGXEclipsePlugin/build_config/customAssembly.xml new file mode 100644 index 0000000000..ebe2861da3 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_config/customAssembly.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_config/customTargets.xml b/Linux_SGXEclipsePlugin/build_config/customTargets.xml new file mode 100644 index 0000000000..0a7316b142 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_config/customTargets.xml @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/.project b/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/.project new file mode 100644 index 0000000000..2320c4af2d --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/.project @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + com.intel.sgx.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/build.properties b/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/build.properties new file mode 100644 index 0000000000..6fe048450c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/build.properties @@ -0,0 +1,15 @@ +######################################################################### +# Copyright (c) 2016 Intel Corporation. # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Eclipse Public License v1.0 # +# which accompanies this distribution, and is available at # +# http://www.eclipse.org/legal/epl-v10.html # +# # +# Contributors: # +# Intel Corporation - initial implementation and documentation # +######################################################################### + +bin.includes = feature.xml,\ + build.properties +generate.plugin@com.intel.sgx.source = com.intel.sgx.feature diff --git a/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/feature.xml b/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/feature.xml new file mode 100644 index 0000000000..f9047a713e --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/features/com.intel.sgx.feature/feature.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + The Software Guard Extensions Plug-in enables Independent Service +Vendors in developing Linux applications +with Software Guard Extensions. The Plug-in extends the C/C++ Development +tools Plug-in to allow ISVs develop secure extensions in C or +C++. The Plug-in also allows conversion of an Linux Application +project into an Linux Application project with Software Guard +Extensions. +Using the Plug-in features and SGX Plug-in Menu options, a developer +can modify the Signing keys and Enclave Configuration for an +Enclave project and can add enclaves inside a project with SGX Nature. +Once development is complete, the developer can build the Enclave +and the Linux project using the SGX SDK for Linux with Release/Debug Configurations in Simulation/Hardware +mode and Hardware Prerelease mode. + + + + All rights reserved with Intel Corporation and its Licensors. + + + + Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: +i) changes to the Program, and +ii) additions to the Program; +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and +b) its license agreement: +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and +b) a copy of this Agreement must be included with each copy of the Program. +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.classpath b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.classpath new file mode 100644 index 0000000000..791c66decf --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.classpath @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.project b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.project new file mode 100644 index 0000000000..76c2e17b70 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.project @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + com.intel.sgx.userguide + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/META-INF/MANIFEST.MF b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5db6ad6bff --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +License: Eclipse Public License Version 1.0 ("EPL") +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: SGX Eclipse Plugin Userguide +Bundle-SymbolicName: com.intel.sgx.userguide;singleton:=true +Bundle-Version: 1.0.1.qualifier +Bundle-Activator: com.intel.sgx.userguide.Activator +Bundle-Vendor: INTEL +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime +Bundle-ActivationPolicy: lazy diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/build.properties b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/build.properties new file mode 100644 index 0000000000..b148cda4b4 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/build.properties @@ -0,0 +1,19 @@ +######################################################################### +# Copyright (c) 2016 Intel Corporation. # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Eclipse Public License v1.0 # +# which accompanies this distribution, and is available at # +# http://www.eclipse.org/legal/epl-v10.html # +# # +# Contributors: # +# Intel Corporation - initial implementation and documentation # +######################################################################### + +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + html/,\ + *.xml diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_Project.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_Project.htm new file mode 100644 index 0000000000..ca61b8308c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_Project.htm @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + Adding SGX Nature to a Project + + + +

Adding SGX Nature to a Project

+

The nature of an Eclipse project is a concept defined by an Eclipse Platform which allows a plug-in to tag a project as a specific kind of project. Intel(R) Software Guard Extensions uses an SGX nature to add SGX-specific behavior to projects. Project natures are defined by plug-ins, and are typically added or removed per-project when the user performs some action defined by the plug-in.

+

To use Intel(R) Software Guard Extensions Eclipse Plug-in in your project, you need to add SGX nature to it. You may either add SGX nature to a pre-existing C/C++ project or create a project with SGX nature from start. See Adding SGX Nature to a non-SGX project and Creating a New C/C++ Project with SGX Nature for how to complete these tasks.

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_non_SGX_project.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_non_SGX_project.htm new file mode 100644 index 0000000000..19e6eaa3f4 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_non_SGX_project.htm @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + Adding SGX Nature to a non-SGX project + + + +

Adding SGX Nature to a non-SGX project

+

When you have a C/C++ project created without Intel SGX, you cannot use Intel SGX support. In this case, you need to add SGX nature to this project to use Intel SGX support:

+
    +
  1. Right-click on the project root
  2. +
  3. +

    Select Software Guard Extension Tools → Add SGX Nature

    +

    + +

    +

    Add SGX Nature

    +
  4. +
+

After you add the SGX nature to your project, you should see:

+
    +
  • +

    A subdirectory sgx in the project which contains a Makefile file.

    +

    + +

    +

    Makefile for Intel(R) SGX

    +
  • +
  • +

    The Intel SGX tools as shown in the following graphic:

    +

    + +

    +

    Intel(R) SGX Tools

    +
  • +
  • +

    New configurations specific to SGX technology. You may see the configurations for the project by clicking to the down arrow of button usually found at the top of the Eclipse window:

    +

    + +

    +

    Configurations Specific to Intel(R) SGX Technology

    +
  • +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Enclave.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Enclave.htm new file mode 100644 index 0000000000..fac206c107 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Enclave.htm @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + Adding an SGX Enclave + + + +

Adding an SGX Enclave

+

After you add the SGX nature to a project, you can start creating a minimal but complete skeleton for a new enclave:

+
    +
  1. Right-click on the project root in Project Explorer.
  2. +
  3. +

    Open the dialog Add New SGX Enclave by selecting Software Guard Extensions Tools → Add SGX Enclave from the contextual menu.

    +

    + +

    +

    Add New Intel® SGX Enclave Dialog

    +
  4. +
  5. +

    Choose a name for the enclave in Enclave name field. This name is used in the process of generation of the skeleton to give unicity to the source files and the name of the resulting executable, so you can add more than one enclave to the same project.

    +
      +
    • +

      If you do not select the Generate sample untrusted application checkbox, the plugin generates only a trusted file and a Makefile fragment to build and compile the trusted part. See the following graphic. All the code for the enclave, including build Makefile, is put in a directory <root>/sgx/enclave_<name> . C/C++ code for the enclave proper are in <root>/sgx/enclave_<name>/trusted.

      +

      + +

      +

      Generated Skeleton for an Enclave. The option to Generate Sample was not Used

      +
    • +
    • +

      If you select Generate sample untrusted application checkbox, a simple ready to work sample application is generated, including untrusted stubs and implementation for a sample OCALL and ECALL.

      +

      + +

      +

      Generated Sample Untrusted Application

      +
    • +
    +
  6. +
+
+

NOTE:

+

If you select the Generate sample untrusted application checkbox, ecalls from the untrusted part are not be resolved by Eclipse C/C++ indexer. These functions are marked with a red line. The declaration of these ecalls resides in the unstrusted stub header which is generated during the build proces and is not indexed by Eclipse. To resolve this problem, right-click on project root and select Index → Freshen All Files.

+
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Trusted_Library.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Trusted_Library.htm new file mode 100644 index 0000000000..fb0d63b836 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Trusted_Library.htm @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + Adding an SGX Trusted Library + + + +

Adding an SGX Trusted Library

+

Trusted Static Libraries helps enclave author have libraries of shared code to be reused by enclaves, in exactly the same manner as usual static libxxx.a libraries are used to share code between regular non-SGX applications. The plugin adds a command to generate the skeleton of a trusted shared library.

+

To add a new SGX Trusted Library:

+
    +
  1. +

    Open Add New SGX Static Trusted Library dialog by right-click on the root of the project and select the appropriate command from Software Guard Extensions Tools menu:

    +

    + +

    +

    Add New SGX Static Trusted Library Dialog

    +
  2. +
  3. +

    Choose a name for the library and click OK. A skeleton for a trusted library is generated in directory <root>/sgx/trustedlib_<name>:

    +

    + +

    +

    A Generated Trusted Library

    +
  4. +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Untrusted_Module.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Untrusted_Module.htm new file mode 100644 index 0000000000..c2d90ce205 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Untrusted_Module.htm @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + Adding an SGX Untrusted Module + + + +

Adding an SGX Untrusted Module

+

Add an untrusted module to generate the untrusted stubs so you use an enclave, provided you have access to its .edl file. The enclave might have been built in the current project or in a different project.

+

To use trusted functionality of an enclave for which its *.edl is known, use the command Add SGX Untrusted Module:

+
    +
  1. +

    Open dialog Add Sgx Untrusted Module by right-click-ing the project root in Package Explorer and chose the command from Software Guard Extension Tools.

    +

    + +

    +

    Add SGX Untrusted Module

    +
  2. +
  3. +

    Use the Browse button to navigate the file system using a file dialog, and click OK. The untrusted module is copied to <root>/sgx/untrusted_<edl file name>. The selected *.edl is copied to the project.

    +

    + +

    +

    Copying the Untrusted Module to a Project

    +
  4. +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Building_and_Running_SGX_Code.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Building_and_Running_SGX_Code.htm new file mode 100644 index 0000000000..1f57f2335c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Building_and_Running_SGX_Code.htm @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + Building and Running SGX Code + + + +

Building and Running SGX Code

+

This section describes the following topics about building and running SGX code:

+
    +
  • SGX build configurations
  • +
  • Running samples generated for enclaves
  • +
  + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Command_Reference.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Command_Reference.htm new file mode 100644 index 0000000000..03f9ab1eae --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Command_Reference.htm @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + Command Reference + + + +

Command Reference

+

This topic provides the command reference for the following scenarios of using Intel(R) Software Guard Extensions Eclipse* Plug-in:

+
    +
  • Adding SGX nature to a project
  • +
  • Adding an SGX enclave
  • +
  • Adding an SGX trusted library
  • +
  • Adding an SGX untrusted module
  • +
  • Updating SGX enclave signing key
  • +
  • Updating enclave configuration files
  • +
  • Two steps sign enclave
  • +
+

All commands brought by Intel(R) Software Guard Extensions Eclipse Plug-in are available by right-clicking on the Project root in Project explorer view in menu Software Guard Extension Tools:

 

Project Explorer

  + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in.htm new file mode 100644 index 0000000000..4c8bc41c4a --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in.htm @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in + + + +

Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in

+

If you do not install Intel(R) SGX SDK for Linux* OS in the default location, you need to specify the path for Intel SGX SDK using the following steps:

+
    +
  1. +

    Go to Window menu ->Preferences. Enter SGX in the filter text field to quickly locate the SGX Preferences page.

    +

    + +

    +

    SGX Preference Page

    +
  2. +
  3. Enter the path for Intel SGX SDK for Linux OS in the SGX SDK Directory field.
  4. +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Creating_a_New_C_C_Project_with_SGX_Nature.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Creating_a_New_C_C_Project_with_SGX_Nature.htm new file mode 100644 index 0000000000..f3db754ab1 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Creating_a_New_C_C_Project_with_SGX_Nature.htm @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + Creating a New C/C++ Project with SGX Nature + + + +

Creating a New C/C++ Project with SGX Nature

+

You can create a new project with SGX nature. To create such a project, follow these steps:

+
    +
  1. +

    Open a standard Eclipse new project: File menu → Project... . If you have installed Intel® Software Guard Extensions Eclipse Plug-in, you can see the category C/C++ with SGX Enabled in the New Project dialog.

    +

    + +

    +

    New Project

    +

    This category has 2 sub-categories, SGX C project and SGX C++ project. These sub-categories are similar to the sub-categories C Project and C++ Project of standard C/C++ category.

    +
  2. +
  3. Select one of the 2 sub-categories, SGX C project or SGX C++ project, and click Next.
  4. +
  5. Complete creating the project using the regular process of creating a standard C or C++ project.
  6. +
+
+

NOTE:

+

Projects created following the subcategories under C/C++ with SGX Enabled are identical with their standard counterparts, except that they have SGX Nature added. There is no difference between creating a C or C++ project with SGX enabled, or creating a standard C/C++ project and launch Add SGX nature from it, as described in precedent paragraph.

+
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Hash.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Hash.htm new file mode 100644 index 0000000000..83326534d3 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Hash.htm @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + Generate Hash + + + +

Generate Hash

+

Generating hash is the first step in the 2-Steps signing process.To generate hash, use the following steps:

+
    +
  1. +

    Right-click on project root, go to Software Guard Extensions Tools menu → Two StepSigne Enclave → Generate Hash

    +

    + +

    +

    Two StepSigne Enclave - Generate Hash

    +
  2. +
  3. In the Generate Hash dialog, enter the required inputs to the corresponding fields:
    • Enter the path to the compiled enclave to be signed in the Enclave Path field. Click Select Enclave to open a file dialog to select the enclave.
    • In the Hash File Location field , enter the path of the output file that will contain signing materials. By default this file has the same file name as the unsigned enclave, with .hex extension added. To change the path, click Select File Path to open a file dialog to select the file path.
    • In the Configuration File path field, enter the path of the configuration filefor the generated hash. Click Select Config to open a dialog to select from all enclave configuration files in the project (similar with the one of the command Update Config).
  4. +
  5. +

    Click OK after you fill in all the fields. The Intel(R) SGX SDK is launched under the hood with the provided parameters and the hash file is generated. A dialog box appears to confirm the completion:

    +

    + +

    +

    Generating Hash Completion Dialog

    +
  6. +
+

You complete the first step, generating hash, in the two step signing enclave. The *.hex file may be signed with the external facility, which generates a signature for it and a public verification key.

+

If you click OK, the Generate Signed Enclave dialog appears. The required fileds in this dialog have been pre-configured with the paths of the unsigned enclave, the configuration file and of the *.hex file. To generated the final signed enclave ready for production immediately, click OK.

+

+ +

+

Generate Signed Enclave Dialog with Pre-configurations

+

If you click Cancel in the Generate Signed Enclave dialog, you can continue the signing process later using the Generate Signed Enclave command.

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Signed_Enclaves.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Signed_Enclaves.htm new file mode 100644 index 0000000000..f0427d7d28 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Signed_Enclaves.htm @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + Generate Signed Enclaves + + + +

Generate Signed Enclaves

+

Generating signed enclave is the second step in the 2-Steps signing process. You should have the following files to complete this step:

+
    +
  • The .hex file generated with Generate Hash command
  • +
  • The files produced from the external signing facility
  • +
  • The signature of the .hex file
  • +
  • The public verification key
  • +
+

To generate signed encalves, use the following steps:

+
    +
  1. +

    Right-click on the project root, and go to Software Guard Extensions Tools menu → Two Step Sign Enclave → Generate Signed Enclave.

    +

    + +

    +

    Generate Signed Enclave Dialog

    +
  2. +
  3. Enter the inputs to all the fields and click OK.
  4. +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Getting_Started.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Getting_Started.htm new file mode 100644 index 0000000000..64c4de51c9 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Getting_Started.htm @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + Getting Started with Intel(R) Software Guard Extensions Eclipse* Plugin + + + +

Getting Started with Intel(R) Software Guard Extensions Eclipse* Plugin

+

This section contains steps to set up your Intel(R) Software Guard Extensions Eclipse* Plugin on a Linux* system, including necessary softwares, steps to install the product, and steps to configure your preferred product directory.

+

• Pre-requisites

+

• Installation Intel(R) Software Guard Extensions Eclipse* Plug-in

+

• Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in

  + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin.htm new file mode 100644 index 0000000000..ab27b83cd9 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin.htm @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + Installing Intel(R) Software Guard Extensions Eclipse* Plug-in + + + +

Installing Intel(R) Software Guard Extensions Eclipse* Plug-in

+

Install Intel(R) Software Guard Extensions Eclipse* Plug-in as a regular Eclipse Plugin:

+
    +
  1. Download the zip archive of Intel(R) Software Guard Extensions Eclipse Plug-in from Intel Site
  2. +
  3. +

    Go to Help menu -> Install New Software. Click the Add button for the Work with field to open the Add Repository dialog as shown in the following graphic:

    +

    + +

    +

    Add Repository Dialog

    +
  4. +
  5. +

    Enter SGX Archive in the Name field . Click the Archive... button and select the location of the downloaded archive as shown in the following graphic:

    +

    + +

    +

    The Location of the Plugin zip Archive

    +
  6. +
  7. Press OK to add the archive as a repository.
  8. +
  9. In the Install dialog, select the Software Guard Extensions Plugin check-box and proceed with the usual steps.
  10. +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin.htm new file mode 100644 index 0000000000..8d58e09d73 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin.htm @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + What is Intel(R) Software Guard Extensions? + + + +

Introducing Intel(R) Software Guard Extensions

+

Intel(R) Software Guard Extensions is a new Intel technology, whose objective is to enable a high level of protection of secrets. It operates by allocating hardware-protected memory where code and data reside. The protected memory area within an application process is called an enclave. Data within the enclave memory can only be accessed by code that resides within that enclave. Enclave code can be invoked by special instructions.

+

An enclave can be built and loaded as a shared object.

+

Throughout this document, Intel(R) SGX refers to Intel(R) Software Guard Extensions.

+

An Intel(R) SGX application design is different from the design of non- Intel(R) SGX application as it specifies dividing the application into two logical parts:

+
    +
  • Trusted part. The code that accesses the secret resides here and it is called an enclave. More than one enclave can exist in an application.
  • +
  • Untrusted part. This includes the rest of the modules in the application, that is outside in an enclave.
  • +
+

The trusted components and untrusted components are developed as separate modules.

+

The trusted part or the enclave is implemented in C or C++. It is supplied as a collection of functions and data packaged in the form of a dynamically loaded library, a DLL in Windows* OS and a shared object in Linux* OS. It may be supplied either as a pre-built signed library or as a signed shared library built during compilation of the untrusted component.

+

Enclave functions within an enclave library are wrapped by auto-generated proxy and bridge functions that simplify the mechanism of using the Intel(R) SGX technology by developers.

+

The role of these functions is to handle the following tasks:

+
    +
  • Call an enclave function from untrusted code, also called an ECALL (enclave call).
  • +
  • Call an untrusted function from within an enclave, also called an OCALL (outside call).
  • +
  • Handle interrupts.
  • +
  • Handle exceptions.
  • +
+

The proxy and bridge functions are generated by the sgx_edger8r tool provided by Intel(R) SGX SDK. It reads an edl file (Enclave Descriptor Language) which describes the functions that form the trusted and untrusted component boundaries within the application.

+

After the enclave is built, a signed version of it is created using the tool sgx_sign also provided by Intel(R) SGX SDK. It is this signed version may be loaded and executed in the encrypted memory.

+

Enclaves may have some specific properties which are added as meta-information during the signing process. The meta-information is stored in one configuration xml file per enclave, whose details may be seen in Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS.

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard_Extensions.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard_Extensions.htm new file mode 100644 index 0000000000..e65c2fbaa1 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard_Extensions.htm @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + What can be done with Linux SGX Eclipse Plugin? + + + +

Introducing Intel(R) Software Guard Extensions Eclipse* Plugin

+

The Intel(R) Software Guard Extensions Eclipse* Plug-in helps the enclave developer to maintain enclaves and untrusted related code inside Eclipse* C/C++ projects. To use this support, add SGX nature to the C/C++ project. See Adding SGX Nature to a Project for details.

+

Once the SGX nature is added to a project, you will have access to the SGX commands. SGX nature adds also a folder called sgx to the root of the project, and a Makefile inside it. All resources of the project managed by Intel(R) Software Guard Extensions Eclipse Plug-inare located inside this directory. You can build and run enclaves related code using GNU* Make tool through the Makefile.

+

The plugin is generating minimal but ready-to-work code skeletons, complete with their own Makefile having all the required make targets as to call sgx_edger8r tool to generate the proxies and bridges, compile these source, generate a shared object and finally, to sign the enclave with the sgx_sign tool. This provide a starting point you may build upon.

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introduction.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introduction.htm new file mode 100644 index 0000000000..ae45b4eaf4 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introduction.htm @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + Introduction + + + +

Introduction

+

This Developer Guide is intended for use by Independent Service Vendors who wish to harden their Linux* applications using Intel(R) SGX Technology, code named Intel(R) Software Guard Extensions. The guide describes the procedure for installation of Intel(R) SGX Plugin for Eclipse* IDE and development of Intel(R) SGX components using the plugin. The Intel(R) SGX Plugin for Eclipse leverages on the Intel(R) Software Guard Extensions Evaluation SDK, which is a collection of APIs, libraries and tools that enable you to develop, build and debug Intel(R) SGX applications in C/C++.

+

To learn more about the Intel(R) Software Guard Extensions Evaluation SDK, see the Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS.

  + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Legal_Information.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Legal_Information.htm new file mode 100644 index 0000000000..fd43d5c6e7 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Legal_Information.htm @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + Legal Information + + + + +

Legal Information

+

No license (express or implied, by estoppel or otherwise) to any intellectual + property rights is granted by this document.

+

Intel disclaims all express and implied warranties, including without + limitation, the implied warranties of merchantability, fitness for a particular + purpose, and non-infringement, as well as any warranty arising from course + of performance, course of dealing, or usage in trade.

+

This document contains information on products, services and/or processes + in development.  All information provided here is subject to change + without notice. Contact your Intel representative to obtain the latest + forecast, schedule, specifications and roadmaps.

+

The products and services described may contain defects or errors known + as errata which may cause deviations from published specifications. Current + characterized errata are available on request.

+

Intel technologies features and benefits depend on system configuration + and may require enabled hardware, software or service activation. Learn + more at Intel.com, or from the OEM or retailer.

+

Copies of documents which have an order number and are referenced in + this document may be obtained by calling 1-800-548-4725 or by visiting + www.intel.com/design/literature.htm.

+

Intel, the Intel logo, Xeon, and Xeon Phi are trademarks of Intel Corporation + in the U.S. and/or other countries.

+ + + + + + + + +
+

Optimization Notice

+
+

Intel's compilers may or may not optimize to the same degree + for non-Intel microprocessors for optimizations that are not unique + to Intel microprocessors. These optimizations include SSE2, SSE3, + and SSSE3 instruction sets and other optimizations. Intel does + not guarantee the availability, functionality, or effectiveness + of any optimization on microprocessors not manufactured by Intel. + Microprocessor-dependent optimizations in this product are intended + for use with Intel microprocessors. Certain optimizations not + specific to Intel microarchitecture are reserved for Intel microprocessors. + Please refer to the applicable product User and Reference Guides + for more information regarding the specific instruction sets covered + by this notice.

+

Notice revision #20110804

+
+

* Other names and brands may be claimed as the property of others.

+

© 2016 Intel Corporation.

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Prerequisites.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Prerequisites.htm new file mode 100644 index 0000000000..462873fae3 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Prerequisites.htm @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + Pre-requisites + + + +

Pre-requisites

+

To use Intel(R) Software Guard Extensions Eclipse Plug-in, install the following softwares:

+
    +
  • Eclipse* Mars 1 with CDT IDE for C/C++ Developpers (version 4.5.1). To use this version, install Java* Development Kit (JDK) or Java* Runtime Environment (JRE) version 1.8 or above.
  • +
  • gcc/g++ tools
  • +
  • Openssl*
  • +
  • Intel(R) SGX SDK for Linux* OS
  • +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/A_Generated_Trusted_Library.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/A_Generated_Trusted_Library.png new file mode 100644 index 0000000000..d6cb5308c4 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/A_Generated_Trusted_Library.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_New_Intel_SGX_Enclave_Dialog.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_New_Intel_SGX_Enclave_Dialog.png new file mode 100644 index 0000000000..c857d80377 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_New_Intel_SGX_Enclave_Dialog.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_New_SGX_Static_Trusted_Library_Dialog.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_New_SGX_Static_Trusted_Library_Dialog.png new file mode 100644 index 0000000000..8fd22a4260 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_New_SGX_Static_Trusted_Library_Dialog.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_Repository_Dialog.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_Repository_Dialog.png new file mode 100644 index 0000000000..3d5dd178e5 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_Repository_Dialog.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_SGX_Nature.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_SGX_Nature.png new file mode 100644 index 0000000000..d6dbf14a6d Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_SGX_Nature.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_SGX_Untrusted_Module.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_SGX_Untrusted_Module.png new file mode 100644 index 0000000000..deec5090e3 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Add_SGX_Untrusted_Module.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Configurations_Specific_to_Intel_SGX_Technology.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Configurations_Specific_to_Intel_SGX_Technology.png new file mode 100644 index 0000000000..f36ca69c05 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Configurations_Specific_to_Intel_SGX_Technology.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Configure_SGX_Hardware_Release_Mode.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Configure_SGX_Hardware_Release_Mode.png new file mode 100644 index 0000000000..f7151654d0 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Configure_SGX_Hardware_Release_Mode.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Copying_the_Untrusted_Module_to_a_Project.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Copying_the_Untrusted_Module_to_a_Project.png new file mode 100644 index 0000000000..fb363ea78d Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Copying_the_Untrusted_Module_to_a_Project.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Customization_of_SGX_build_command.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Customization_of_SGX_build_command.png new file mode 100644 index 0000000000..a9c509501b Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Customization_of_SGX_build_command.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Down_Arrow_Button.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Down_Arrow_Button.png new file mode 100644 index 0000000000..fccabba54e Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Down_Arrow_Button.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Enclave_Configuration_Settings.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Enclave_Configuration_Settings.png new file mode 100644 index 0000000000..42217bd097 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Enclave_Configuration_Settings.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generate_Signed_Enclave_Dialog.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generate_Signed_Enclave_Dialog.png new file mode 100644 index 0000000000..9eebe98c66 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generate_Signed_Enclave_Dialog.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generate_Signed_Enclave_Dialog_with_Pre_configurations.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generate_Signed_Enclave_Dialog_with_Pre_configurations.png new file mode 100644 index 0000000000..538d68743a Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generate_Signed_Enclave_Dialog_with_Pre_configurations.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generated_Sample_Untrusted_Application.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generated_Sample_Untrusted_Application.png new file mode 100644 index 0000000000..7e7c609d61 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generated_Sample_Untrusted_Application.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generated_Skeleton_for_an_Enclave.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generated_Skeleton_for_an_Enclave.png new file mode 100644 index 0000000000..55e27af3ab Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generated_Skeleton_for_an_Enclave.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generating_Hash_Completion_Dialog.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generating_Hash_Completion_Dialog.png new file mode 100644 index 0000000000..032c17a2ea Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Generating_Hash_Completion_Dialog.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Import_or_Re_Generate_Enclave_Signing_Key.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Import_or_Re_Generate_Enclave_Signing_Key.png new file mode 100644 index 0000000000..d954544841 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Import_or_Re_Generate_Enclave_Signing_Key.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Intel_SGX_Configurations.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Intel_SGX_Configurations.png new file mode 100644 index 0000000000..f7151654d0 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Intel_SGX_Configurations.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Intel_SGX_Tools.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Intel_SGX_Tools.png new file mode 100644 index 0000000000..fb9ec29775 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Intel_SGX_Tools.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Makefile_for_Intel_SGX.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Makefile_for_Intel_SGX.png new file mode 100644 index 0000000000..466558cb4c Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Makefile_for_Intel_SGX.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/New_Project.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/New_Project.png new file mode 100644 index 0000000000..f7f391f6d6 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/New_Project.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Project_Explorer.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Project_Explorer.png new file mode 100644 index 0000000000..94913f3980 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Project_Explorer.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Project_Menu.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Project_Menu.png new file mode 100644 index 0000000000..659f0d92f3 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Project_Menu.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/SGX_Preference_Page.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/SGX_Preference_Page.png new file mode 100644 index 0000000000..90170646b4 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/SGX_Preference_Page.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Sample_Application.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Sample_Application.png new file mode 100644 index 0000000000..9c25b62823 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Sample_Application.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Select_Configuration_File.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Select_Configuration_File.png new file mode 100644 index 0000000000..a5fb4f811b Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Select_Configuration_File.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/The_Location_of_the_Plugin_zip_Archive.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/The_Location_of_the_Plugin_zip_Archive.png new file mode 100644 index 0000000000..afa17c33eb Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/The_Location_of_the_Plugin_zip_Archive.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/The_Result_of_Running_Samples_Generated_for_Enclaves.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/The_Result_of_Running_Samples_Generated_for_Enclaves.png new file mode 100644 index 0000000000..2f3a03acc5 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/The_Result_of_Running_Samples_Generated_for_Enclaves.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Two_StepSigne_Enclave_Generate_Hash.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Two_StepSigne_Enclave_Generate_Hash.png new file mode 100644 index 0000000000..7b9b49b640 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Two_StepSigne_Enclave_Generate_Hash.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Two_Step_Sign_Enclave_Menu.png b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Two_Step_Sign_Enclave_Menu.png new file mode 100644 index 0000000000..374fd094fd Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Images/Two_Step_Sign_Enclave_Menu.png differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/PageLayouts/Default.flpgl b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/PageLayouts/Default.flpgl new file mode 100644 index 0000000000..5faf8a4961 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/PageLayouts/Default.flpgl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css new file mode 100644 index 0000000000..6c2190cf4c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css @@ -0,0 +1,443 @@ +/*************************************************************************/ +/* Copyright (c) 2016 Intel Corporation. */ +/* */ +/* All rights reserved. This program and the accompanying materials */ +/* are made available under the terms of the Eclipse Public License v1.0 */ +/* which accompanies this distribution, and is available at */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/* */ +/* Contributors: */ +/* Intel Corporation - initial implementation and documentation */ +/*************************************************************************/ +/**/ + +/*begin-old-version{{*/ + +body +{ + color: #333333; + background-color: #ffffff; + font-family: "Intel Clear", Verdana, Arial, sans-serif; + font-size: 12pt; + margin-left: 30px; + margin-right: 30px; + margin-bottom: 7%; + color: #333333; + background-color: #ffffff; + font-family: "Intel Clear", Verdana, Arial, sans-serif; + font-size: 12pt; + margin-left: 30px; + margin-right: 30px; + margin-bottom: 7%; +} + +.RevUpdate +{ + background-color: #FFFF99; + font-weight: normal; + line-height: 100%; + background-color: #FFFF99; + font-weight: normal; + line-height: 100%; +} + +.NonStdFortran +{ + color: #007F00; + color: #007F00; +} + +body.OH_VSIP_body +{ + margin-left: 30px; + margin-left: 30px; +} + +DIV.OH_outerContent +{ + border: 0px none #FFFFFF; + border: 0px none #ffffff; +} + +h1 +{ + color: #0071c5; + font-size: 15pt; + font-weight: normal; + padding-bottom: 1px; + margin-left: 0pt; + margin-bottom: 0px; + color: #0071c5; + font-size: 15pt; + font-weight: normal; + padding-bottom: 1px; + margin-left: 0pt; + margin-bottom: 0px; +} + +h1.firsttitle +{ + font-weight: normal; + border-bottom: 0 none; + margin-left: 0; + font-size: 18pt; + border-bottom: 1px solid #0071c5; + line-height: 100%; + padding-bottom: 10px; + margin-bottom: 20px; + margin-top: 20px; + font-weight: normal; + border-bottom: 0 none; + margin-left: 0; + font-size: 18pt; + border-bottom: 1px solid #0071c5; + line-height: 100%; + padding-bottom: 10px; + margin-bottom: 20px; + margin-top: 20px; +} + +h2 +{ + color: #0071c5; + margin-top: 15pt; + margin-bottom: 5pt; + font-size: 12pt; + color: #0071c5; + margin-top: 15pt; + margin-bottom: 5pt; + font-size: 12pt; +} + +h3 +{ + color: #333333; + font-weight: bold; + margin-top: 15pt; + margin-bottom: 5pt; + font-size: 11pt; + color: #333333; + font-weight: bold; + margin-top: 15pt; + margin-bottom: 5pt; + font-size: 11pt; +} + +h4 +{ + color: #0071c5; + margin-top: 12pt; + margin-bottom: 5pt; + padding-left: 0px; + font-size: 12pt; + color: #0071c5; + margin-top: 12pt; + margin-bottom: 5pt; + padding-left: 0px; + font-size: 12pt; +} + +h5 +{ + color: #0071c5; + margin-top: 12pt; + margin-bottom: 5pt; + padding-left: 0px; + font-size: 12pt; + color: #0071c5; + margin-top: 12pt; + margin-bottom: 5pt; + padding-left: 0px; + font-size: 12pt; +} + +h6 +{ + color: #0071c5; + margin-top: 12pt; + margin-bottom: 5pt; + padding-left: 0px; + font-size: 12pt; + color: #0071c5; + margin-top: 12pt; + margin-bottom: 5pt; + padding-left: 0px; + font-size: 12pt; +} + +.relinfo +{ + padding-left: 30px; + padding-left: 30px; +} + +.tablecap +{ + color: #0071c5; +} + +caption +{ + font-size: 12pt; + font-weight: bold; + text-align: left; + font-size: 12pt; + font-weight: bold; + text-align: left; +} + +.figcap +{ + margin-left: 24px; + font-size: 12pt; + font-weight: bold; + text-align: center; + margin-left: 24px; + font-size: 12pt; + font-weight: bold; + text-align: center; +} + +.sectiontitle +{ + padding-left: 0px; + padding-left: 0px; +} + +.linklist +{ + padding-left: 0px; + padding-left: 0px; +} + +h1.topictitle1 +{ + color: #0071c5; + font-size: 18pt; + margin-left: 0pt; + margin-bottom: 15px; + color: #0071c5; + font-size: 18pt; + margin-left: 0pt; + margin-bottom: 15px; +} + +#header_text +{ + color: #0071C5; + text-align: right; + color: #0071C5; + text-align: right; +} + +.titlepage +{ + margin-right: 15%; + margin-right: 15%; +} + +.familylinks +{ + margin-top: 1em; + margin-top: 1em; +} + +a.start +{ + font-size: 18pt; + text-decoration: underline; + font-size: 18pt; + text-decoration: underline; +} + +a.underlined +{ + text-decoration: underline; + text-decoration: underline; +} + +.shortdesc +{ + font-size: inherit; + padding-left: inherit; + line-height: 16pt; + margin-top: 0px; + margin-bottom: 0.5em; + font-size: inherit; + padding-left: inherit; + line-height: 16pt; + margin-top: 0px; + margin-bottom: 0.5em; +} + +.shortdesc-it +{ + font-style: italic; + font-style: italic; +} + +p +{ + font-size: inherit; + margin-left: 0px; + line-height: 120%; + margin-top: 0; + margin-bottom: 10px; + font-size: inherit; + margin-left: 0px; + line-height: 120%; + margin-top: 0; + margin-bottom: 10px; +} + +.p +{ + font-size: inherit; + margin-left: 0px; + line-height: 170%; + margin-top: 0; + margin-bottom: 5pt; + padding-left: 0pt; + font-size: inherit; + margin-left: 0px; + line-height: 170%; + margin-top: 0; + margin-bottom: 5pt; + padding-left: 0pt; +} + +table +{ + margin-bottom: 5pt; + border-collapse: collapse; + margin-left: 0px; + margin-top: 0.3em; + font-size: 12pt; + margin-bottom: 5pt; + border-collapse: collapse; + margin-left: 0px; + margin-top: 0.3em; + font-size: 12pt; +} + +tr +{ + vertical-align: top; + vertical-align: top; +} + +DIV.Note +{ + margin-top: 20pt; + margin-bottom: 20pt; + margin-right: 0.46cm; + padding-left: 5px; + border-top-style: solid; + border-top-width: 1px; + border-bottom-style: solid; + border-bottom-width: 1px; +} + +p.NoteTipHead +{ + font-weight: bold; + font-style: italic; + margin-top: 9pt; + margin-bottom: 3pt; + line-height: 15pt; + margin-left: 0.202cm; + font-family: "Verdana", "sans-serif"; + font-size: 9pt; + text-transform: uppercase; + text-align: justify; +} + +MadCap|xref +{ + color: #0860a8; + mc-format: '{paratext}'; + text-decoration: none; +} + +div.NoteCont +{ + border-bottom-style: solid; + border-bottom-width: 1px; + border-top-style: solid; + border-top-width: 1px; +} + +p.figcap +{ + text-align: left; +} + +th +{ + text-align: left; +} + +a:link +{ + color: #0071c5; + text-decoration: none; + color: #0071c5; + text-decoration: none; +} + +a:visited +{ + color: #0071c5; + text-decoration: none; + color: #0071c5; + text-decoration: none; +} + +a:hover +{ + color: #00aeef; + text-decoration: underline; + color: #00aeef; + text-decoration: underline; +} + +a:active +{ + color: #0071c5; + text-decoration: underline; + color: #0071c5; + text-decoration: underline; +} + +a.start:visited +{ + color: #0071c5; + text-decoration: underline; + color: #0071c5; + text-decoration: underline; +} + +a.start:active +{ + color: #0071c5; + text-decoration: underline; + color: #0071c5; + text-decoration: underline; +} + +a.underlined:visited +{ + color: #0071c5; + text-decoration: underline; + color: #0071c5; + text-decoration: underline; +} + +a.underlined:active +{ + color: #0071c5; + text-decoration: underline; + color: #0071c5; + text-decoration: underline; +} + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Running_Samples_Generated_for_Enclaves.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Running_Samples_Generated_for_Enclaves.htm new file mode 100644 index 0000000000..1fc481290d --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Running_Samples_Generated_for_Enclaves.htm @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + Running Samples Generated for Enclaves + + + +

Running Samples Generated for Enclaves

+

Intel(R) Software Guard Extensions Eclipse* Plugin provides an option to generate a sample application together with the enclave code when the enclave is created. After the project is build, the sample application is built also and ready to run. You can see the sample application named sample in the enclave directory in Project Explorer. You can run this sample as a local C/C++ application as shown in the following figure:

+

+ +

+

Sample Application

+

See the result of the execution in Eclipse console window as shown below:

+

+ +

+

The Result of Running Samples Generated for Enclaves

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_Build_Configurations.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_Build_Configurations.htm new file mode 100644 index 0000000000..c41301eea7 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_Build_Configurations.htm @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + SGX Build Configurations + + + +

SGX Build Configurations

+

There are usually two types of builds that a regular non-SGX project defines:

+
    +
  • Debug
  • +
  • Release
  • +
+

SGX-enabled projects add to this picture support to build and test SGX-enabled application on non-SGX platforms (or emulator) using simulation libraries. This approach doubles the set of build types, creating four possible combinations. For these combinations, you need to use different sets of compilation and linking flags and link different libraries.

+

The non-debug hardware build is meant to give production code, so it requires the maximum attention when signed. The Two Steps Sign schema is required for production enclaves, which involves an external signing facility, not part of Intel SGX SDK. The other configurations are not meant for production but they have to be signed too. The simplest and more convenient Single Step schema is used for them.

+

Again for testing purpose, you might want to experiment with a non-production enclave built with release compilation and linking flags, on a real hardware SGX-enabled platform. That would be an enclave built exactly as a production enclave, except for the sign process which would be Single Step. To support the construction of such enclave, there is a hardware non-debug build configuration dubbed Prerelease.

+

So there are five SGX related configurations when SGX Nature is added to a project:

+

+ +

+

Intel(R) SGX Configurations

+

The following table resumes the existing SGX configurations and relate them with compilation/linking flags (debug/non-debug) and signing scheme (single vs. two steps):

+

Intel(R) SGX Configurations

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Configuration NameSimulation?Debug?Signing Schema
SGX Hardware DebugHardwareDebugSingle Step
SGX Hardware Pre-releaseHardwareNon-debugSingle Step
SGX Hardware ReleaseHardwareNon-debugTwo Step
SGX SimulationSimulationNon-debugSingle Step
SGX SimulationDebug SimulationDebugSingle step
+

Intel® Software Guard Extensions Eclipse Plug-in uses standard GNU* make tool to build the trusted and the untrusted code, using the generated file sgx/Makefile.

+

This fact does not impose any restriction on the build tool chosen for the hosting project. Intel® Software Guard Extensions Eclipse* Plug-in uses its own build configurations which do not interfere with the configurations that you might have in your project.

+

When SGX configurations are selected, by default only code under <root>/sgx directory get built.

+

You can customize SGX configurations as any other Eclipse build configurations from the project properties dialog. For example:

+
    +
  1. Right-click in Project Explorer Properties → C/C++ Build
  2. +
  3. Uncheck the Use default build command checkbox.
  4. +
+

Then you can customize and integrate SGX build process. You can use Makefile instead of sgx/Makefile in the example shown in the following figure:

+

+ +

+

Customization of SGX Build Command

+

The build process is done using standard Eclipse interface for build, by example from the main Project menu:

+

+ +

+

Project Menu

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_title.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_title.htm new file mode 100644 index 0000000000..bbf44bea76 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_title.htm @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + Intel(R) Software Guard Extensions + + + + +

Intel(R) Software Guard Extensions

+

Developer Reference

+

Intel(R) Software Guard Extensions (Intel(R) SGX) is an Intel technology for a +pplication developers seeking to protect select code and data from disclosure or +modification. Intel(R) SGX makes such protections possible through the use of +enclaves. Enclaves are protected areas of execution. Application code can be put +into an enclave through special instructions and software made available to +developers by the Intel(R) SGX SDK.

+

Legal Information +

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Two_Steps_Sign_Enclave.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Two_Steps_Sign_Enclave.htm new file mode 100644 index 0000000000..6201863d5c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Two_Steps_Sign_Enclave.htm @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + Two Steps Sign Enclave + + + +

Two Steps Sign Enclave

+

To help you develop enclaves, Intel(R) Software Guard Extensions Eclipse Plug-in generates all required structure including:

+
    +
  • c/c++ files and header files
  • +
  • .edl file
  • +
  • *.config.xml file
  • +
  • a sample Makefile
  • +
  • a sample signing key
  • +
+

While these structure might be appropriate for development and debugging, you need a 2-step process to integrate your own signing schema for generating production enclaves.

+
    +
  1. Generate hash: the signer tool generates signing material from the unsigned compiled enclave and from the configuration file for the enclave. The signed material comes as an opaque sequence of bytes which are put in a file with extension .hex. This file is used with the external signing facility. You come back with a signature for the .hex file plus the public key of your signing facility, and proceed to Step 2.
  2. +
  3. Generate signed enclaves : the signer tool generates the final signed enclave.
  4. +
+

To complete this task, provide the following input parameters:

+
    +
  • The unsigned enclave
  • +
  • The configuration file
  • +
  • The output file produced when you generate hash (the .hex file)
  • +
  • The files produced by the external signing facility: the signature of the .hex file and public key for it
  • +
  • The plugin checks if the input parameters are consistent:
  • +
  • The .hex file matches the unsigned enclave and the configuration file,
  • +
  • The signed material is verified with the public key
  • +
+

If the parameters are consistenet, the production signed enclave is produced.

+
+

NOTE:

+

If you generate signed enclave right after generating hash, you can only enter the parameters specific for generating signed enclave.

+
+

To use the two-step signing function, activate the configuration SGX Hardware Release mode. When this configuration is active, the compilation does not produce a signed enclave, as in the other SGX configurations; the process only produces unsigned enclaves.

+

+ +

+

Configure SGX Hardware Release Mode

+

When you configure the plugin in the SGX Hardware Release Mode, you can see the Generate Hash and Generate Signed Enclave options through Software Guard Extension Tools->Two Step Sign Enclave.

+

+ +

+

Two Step Sign Enclave Menu

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_Enclave_Configuration_Files.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_Enclave_Configuration_Files.htm new file mode 100644 index 0000000000..d416791d27 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_Enclave_Configuration_Files.htm @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + Updating Enclave Configuration Files + + + +

Updating Enclave Configuration Files

+

A configuration file is an important part in the definition of an enclave. Intel(R) SGX SDK signer tool requires such *.xml configuration file as necessary input.

+

To update this configuration file, use the Update Config command:

+
    +
  1. +

    Right-click on the root project, Software Extension Guards Tools->Select Config File.

    +

    + +

    +

    Select Configuration File

    +
  2. +
  3. +

    Click OK or double-click the selected configuration file to open the Enclave Configuration Settings dialog.

    +

    + +

    +

    Enclave Configuration Settings

    +

    For details on the meaning of the fields, see Intel(R) Software Guard Extensions Developer Guide.

    +
  4. +
+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_SGX_Enclave_Signing_Key.htm b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_SGX_Enclave_Signing_Key.htm new file mode 100644 index 0000000000..d536de1c6d --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_SGX_Enclave_Signing_Key.htm @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + Updating SGX Enclave Signing Key + + + +

Updating SGX Enclave Signing Key

+

All skeletons enclave samples produced by the plugin contain a sample signing key. You might want to import another sign key that you already have, or generate a new one. Use the command Update SGX Enclave Signing Key to complete this task.

+
    +
  1. Choose Update SGX Enclave Signing Key by right-click on the project in Project Explorer -> Software Guard Extension Tools menu. The Import or (Re)Generate Enclave Signing Key dialog appears.
  2. +
  3. In the Import or (Re)Generate Enclave Signing Key dialog, click Select to open a file dialog to select the output key.
  4. +
  5. +

    Click Improt Key to update a selected signing key by copying another existing key or click Generate Key to update the selected signing key by generating a new key. In both cases, the new signature key is put into the file in text field Enclave Signing Key.

    +

    + +

    +

    Import or (Re)Generate Enclave Signing Key

    +
  6. +
  7. Click OK to update the enclave signing key.
  8. +
+

Under the hood, a new key is generated using openssl*, which needs to be installed on the machine:

+

openssl genrsa -out ../../../encl1_private.pem.key.pem -3 3072 +

+

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/content.html b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/content.html new file mode 100644 index 0000000000..40f03550f3 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/content.html @@ -0,0 +1,557 @@ + + + + + + + + + + + + + + + + + + + +

Intel(R) Software Guard Extensions Plug-in for Eclipse*

+

Developer Guide

+

Intel(R) Software Guard Extensions (Intel(R) SGX) is an Intel technology for a +pplication developers seeking to protect select code and data from disclosure or +modification. Intel(R) SGX makes such protections possible through the use of +enclaves. Enclaves are protected areas of execution. Application code can be put +into an enclave through special instructions and software made available to +developers by the Intel(R) SGX SDK.

+

Legal Information +

+ + +

Legal Information

+

No license (express or implied, by estoppel or otherwise) to any intellectual + property rights is granted by this document.

+

Intel disclaims all express and implied warranties, including without + limitation, the implied warranties of merchantability, fitness for a particular + purpose, and non-infringement, as well as any warranty arising from course + of performance, course of dealing, or usage in trade.

+

This document contains information on products, services and/or processes + in development.  All information provided here is subject to change + without notice. Contact your Intel representative to obtain the latest + forecast, schedule, specifications and roadmaps.

+

The products and services described may contain defects or errors known + as errata which may cause deviations from published specifications. Current + characterized errata are available on request.

+

Intel technologies features and benefits depend on system configuration + and may require enabled hardware, software or service activation. Learn + more at Intel.com, or from the OEM or retailer.

+

Copies of documents which have an order number and are referenced in + this document may be obtained by calling 1-800-548-4725 or by visiting + www.intel.com/design/literature.htm.

+

Intel, the Intel logo, Xeon, and Xeon Phi are trademarks of Intel Corporation + in the U.S. and/or other countries.

+ + + + + + + + +
+

Optimization Notice

+
+

Intel's compilers may or may not optimize to the same degree + for non-Intel microprocessors for optimizations that are not unique + to Intel microprocessors. These optimizations include SSE2, SSE3, + and SSSE3 instruction sets and other optimizations. Intel does + not guarantee the availability, functionality, or effectiveness + of any optimization on microprocessors not manufactured by Intel. + Microprocessor-dependent optimizations in this product are intended + for use with Intel microprocessors. Certain optimizations not + specific to Intel microarchitecture are reserved for Intel microprocessors. + Please refer to the applicable product User and Reference Guides + for more information regarding the specific instruction sets covered + by this notice.

+

Notice revision #20110804

+
+

* Other names and brands may be claimed as the property of others.

+

© 2016 Intel Corporation.

+ + +

Introduction

+

This Developer Guide is intended for use by Independent Service Vendors who wish to harden their Linux* applications using Intel(R) SGX Technology, code named Intel(R) Software Guard Extensions. The guide describes the procedure for installation of Intel(R) SGX Plugin for Eclipse* IDE and development of Intel(R) SGX components using the plugin. The Intel(R) SGX Plugin for Eclipse leverages on the Intel(R) Software Guard Extensions Evaluation SDK, which is a collection of APIs, libraries and tools that enable you to develop, build and debug Intel(R) SGX applications in C/C++.

+

To learn more about the Intel(R) Software Guard Extensions Evaluation SDK, see the Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS.

  + +

Introducing Intel(R) Software Guard Extensions

+

Intel(R) Software Guard Extensions is a new Intel technology, whose objective is to enable a high level of protection of secrets. It operates by allocating hardware-protected memory where code and data reside. The protected memory area within an application process is called an enclave. Data within the enclave memory can only be accessed by code that resides within that enclave. Enclave code can be invoked by special instructions.

+

An enclave can be built and loaded as a shared object.

+

Throughout this document, Intel(R) SGX refers to Intel(R) Software Guard Extensions.

+

An Intel(R) SGX application design is different from the design of non- Intel(R) SGX application as it specifies dividing the application into two logical parts:

+
    +
  • Trusted part. The code that accesses the secret resides here and it is called an enclave. More than one enclave can exist in an application.
  • +
  • Untrusted part. This includes the rest of the modules in the application, that is outside in an enclave.
  • +
+

The trusted components and untrusted components are developed as separate modules.

+

The trusted part or the enclave is implemented in C or C++. It is supplied as a collection of functions and data packaged in the form of a dynamically loaded library, a DLL in Windows* OS and a shared object in Linux* OS. It may be supplied either as a pre-built signed library or as a signed shared library built during compilation of the untrusted component.

+

Enclave functions within an enclave library are wrapped by auto-generated proxy and bridge functions that simplify the mechanism of using the Intel(R) SGX technology by developers.

+

The role of these functions is to handle the following tasks:

+
    +
  • Call an enclave function from untrusted code, also called an ECALL (enclave call).
  • +
  • Call an untrusted function from within an enclave, also called an OCALL (outside call).
  • +
  • Handle interrupts.
  • +
  • Handle exceptions.
  • +
+

The proxy and bridge functions are generated by the sgx_edger8r tool provided by Intel(R) SGX SDK. It reads an edl file (Enclave Descriptor Language) which describes the functions that form the trusted and untrusted component boundaries within the application.

+

After the enclave is built, a signed version of it is created using the tool sgx_sign also provided by Intel(R) SGX SDK. It is this signed version may be loaded and executed in the encrypted memory.

+

Enclaves may have some specific properties which are added as meta-information during the signing process. The meta-information is stored in one configuration xml file per enclave, whose details may be seen in Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS.

+ + +

Introducing Intel(R) Software Guard Extensions Eclipse* Plug-in

+

The Intel(R) Software Guard Extensions Eclipse* Plug-in helps the enclave developer to maintain enclaves and untrusted related code inside Eclipse* C/C++ projects. To use this support, add SGX nature to the C/C++ project. See Adding SGX Nature to a Project for details.

+

Once the SGX nature is added to a project, you will have access to the SGX commands. SGX nature adds also a folder called sgx to the root of the project, and a Makefile inside it. All resources of the project managed by Intel(R) Software Guard Extensions Eclipse Plug-inare located inside this directory. You can build and run enclaves related code using GNU* Make tool through the Makefile.

+

The plugin is generating minimal but ready-to-work code skeletons, complete with their own Makefile having all the required make targets as to call sgx_edger8r tool to generate the proxies and bridges, compile these source, generate a shared object and finally, to sign the enclave with the sgx_sign tool. This provide a starting point you may build upon.

+ + +

Getting Started with Intel(R) Software Guard Extensions Eclipse* Plug-in

+

This section contains steps to set up your Intel(R) Software Guard Extensions Eclipse* Plug-in on a Linux* system, including necessary softwares, steps to install the product, and steps to configure your preferred product directory.

+

• Pre-requisites

+

• Installing Intel(R) Software Guard Extensions Eclipse* Plug-in

+

• Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in

  + +

Pre-requisites

+

To use Intel(R) Software Guard Extensions Eclipse Plug-in, install the following softwares:

+
    +
  • Eclipse* Mars 1 with CDT IDE for C/C++ Developpers (version 4.5.1). To use this version, install Java* Development Kit (JDK) or Java* Runtime Environment (JRE) version 1.8 or above.
  • +
  • gcc/g++ tools
  • +
  • Openssl*
  • +
  • Intel(R) SGX SDK for Linux* OS
  • +
+ + +

Installing Intel(R) Software Guard Extensions Eclipse* Plug-in

+

Install Intel(R) Software Guard Extensions Eclipse* Plug-in as a regular Eclipse Plugin:

+
    +
  1. Download the zip archive of Intel(R) Software Guard Extensions Eclipse Plug-in from Intel Site
  2. +
  3. +

    Go to Help menu -> Install New Software. Click the Add button for the Work with field to open the Add Repository dialog as shown in the following graphic:

    +

    + +

    +

    Add Repository Dialog

    +
  4. +
  5. +

    Enter SGX Archive in the Name field . Click the Archive... button and select the location of the downloaded archive as shown in the following graphic:

    +

    + +

    +

    The Location of the Plugin zip Archive

    +
  6. +
  7. Press OK to add the archive as a repository.
  8. +
  9. In the Install dialog, select the Software Guard Extensions Plugin check-box and proceed with the usual steps.
  10. +
+ + +

Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in

+

If you do not install Intel(R) SGX SDK for Linux* OS in the default location, you need to specify the path for Intel SGX SDK using the following steps:

+
    +
  1. +

    Go to Window menu ->Preferences. Enter SGX in the filter text field to quickly locate the SGX Preferences page.

    +

    + +

    +

    SGX Preference Page

    +
  2. +
  3. Enter the path for Intel SGX SDK for Linux OS in the SGX SDK Directory field.
  4. +
+ + +

Command Reference

+

This topic provides the command reference for the following scenarios of using Intel(R) Software Guard Extensions Eclipse* Plug-in:

+
    +
  • Adding SGX nature to a project
  • +
  • Adding an SGX enclave
  • +
  • Adding an SGX trusted library
  • +
  • Adding an SGX untrusted module
  • +
  • Updating SGX enclave signing key
  • +
  • Updating enclave configuration files
  • +
  • Two steps sign enclave
  • +
+

All commands brought by Intel(R) Software Guard Extensions Eclipse Plug-in are available by right-clicking on the Project root in Project explorer view in menu Software Guard Extension Tools:

 

Project Explorer

  + +

Adding SGX Nature to a Project

+

The nature of an Eclipse project is a concept defined by an Eclipse Platform which allows a plug-in to tag a project as a specific kind of project. Intel(R) Software Guard Extensions uses an SGX nature to add SGX-specific behavior to projects. Project natures are defined by plug-ins, and are typically added or removed per-project when the user performs some action defined by the plug-in.

+

To use Intel(R) Software Guard Extensions Eclipse Plug-in in your project, you need to add SGX nature to it. You may either add SGX nature to a pre-existing C/C++ project or create a project with SGX nature from start. See Adding SGX Nature to a non-SGX project and Creating a New C/C++ Project with SGX Nature for how to complete these tasks.

+ + +

Adding SGX Nature to a non-SGX project

+

When you have a C/C++ project created without Intel SGX, you cannot use Intel SGX support. In this case, you need to add SGX nature to this project to use Intel SGX support:

+
    +
  1. Right-click on the project root
  2. +
  3. +

    Select Software Guard Extension Tools → Add SGX Nature

    +

    + +

    +

    Add SGX Nature

    +
  4. +
+

After you add the SGX nature to your project, you should see:

+
    +
  • +

    A subdirectory sgx in the project which contains a Makefile file.

    +

    + +

    +

    Makefile for Intel(R) SGX

    +
  • +
  • +

    The Intel SGX tools as shown in the following graphic:

    +

    + +

    +

    Intel(R) SGX Tools

    +
  • +
  • +

    New configurations specific to SGX technology. You may see the configurations for the project by clicking to the down arrow of button usually found at the top of the Eclipse window:

    +

    + +

    +

    Configurations Specific to Intel(R) SGX Technology

    +
  • +
+ + +

Creating a New C/C++ Project with SGX Nature

+

You can create a new project with SGX nature. To create such a project, follow these steps:

+
    +
  1. +

    Open a standard Eclipse new project: File menu → Project... . If you have installed Intel® Software Guard Extensions Eclipse Plug-in, you can see the category C/C++ with SGX Enabled in the New Project dialog.

    +

    + +

    +

    New Project

    +

    This category has 2 sub-categories, SGX C project and SGX C++ project. These sub-categories are similar to the sub-categories C Project and C++ Project of standard C/C++ category.

    +
  2. +
  3. Select one of the 2 sub-categories, SGX C project or SGX C++ project, and click Next.
  4. +
  5. Complete creating the project using the regular process of creating a standard C or C++ project.
  6. +
+
+

NOTE:

+

Projects created following the subcategories under C/C++ with SGX Enabled are identical with their standard counterparts, except that they have SGX Nature added. There is no difference between creating a C or C++ project with SGX enabled, or creating a standard C/C++ project and launch Add SGX nature from it, as described in precedent paragraph.

+
+ + +

Adding an SGX Enclave

+

After you add the SGX nature to a project, you can start creating a minimal but complete skeleton for a new enclave:

+
    +
  1. Right-click on the project root in Project Explorer.
  2. +
  3. +

    Open the dialog Add New SGX Enclave by selecting Software Guard Extensions Tools → Add SGX Enclave from the contextual menu.

    +

    + +

    +

    Add New Intel® SGX Enclave Dialog

    +
  4. +
  5. +

    Choose a name for the enclave in Enclave name field. This name is used in the process of generation of the skeleton to give unicity to the source files and the name of the resulting executable, so you can add more than one enclave to the same project.

    +
      +
    • +

      If you do not select the Generate sample untrusted application checkbox, the plugin generates only a trusted file and a Makefile fragment to build and compile the trusted part. See the following graphic. All the code for the enclave, including build Makefile, is put in a directory <root>/sgx/enclave_<name> . C/C++ code for the enclave proper are in <root>/sgx/enclave_<name>/trusted.

      +

      + +

      +

      Generated Skeleton for an Enclave. The option to Generate Sample was not Used

      +
    • +
    • +

      If you select Generate sample untrusted application checkbox, a simple ready to work sample application is generated, including untrusted stubs and implementation for a sample OCALL and ECALL.

      +

      + +

      +

      Generated Sample Untrusted Application

      +
    • +
    +
  6. +
+
+

NOTE:

+

If you select the Generate sample untrusted application checkbox, ecalls from the untrusted part are not be resolved by Eclipse C/C++ indexer. These functions are marked with a red line. The declaration of these ecalls resides in the unstrusted stub header which is generated during the build proces and is not indexed by Eclipse. To resolve this problem, right-click on project root and select Index → Freshen All Files.

+
+ + +

Adding an SGX Trusted Library

+

Trusted Static Libraries helps enclave author have libraries of shared code to be reused by enclaves, in exactly the same manner as usual static libxxx.a libraries are used to share code between regular non-SGX applications. The plugin adds a command to generate the skeleton of a trusted shared library.

+

To add a new SGX Trusted Library:

+
    +
  1. +

    Open Add New SGX Static Trusted Library dialog by right-click on the root of the project and select the appropriate command from Software Guard Extensions Tools menu:

    +

    + +

    +

    Add New SGX Static Trusted Library Dialog

    +
  2. +
  3. +

    Choose a name for the library and click OK. A skeleton for a trusted library is generated in directory <root>/sgx/trustedlib_<name>:

    +

    + +

    +

    A Generated Trusted Library

    +
  4. +
+ + +

Adding an SGX Untrusted Module

+

Add an untrusted module to generate the untrusted stubs so you use an enclave, provided you have access to its .edl file. The enclave might have been built in the current project or in a different project.

+

To use trusted functionality of an enclave for which its *.edl is known, use the command Add SGX Untrusted Module:

+
    +
  1. +

    Open dialog Add Sgx Untrusted Module by right-click-ing the project root in Package Explorer and chose the command from Software Guard Extension Tools.

    +

    + +

    +

    Add SGX Untrusted Module

    +
  2. +
  3. +

    Use the Browse button to navigate the file system using a file dialog, and click OK. The untrusted module is copied to <root>/sgx/untrusted_<edl file name>. The selected *.edl is copied to the project.

    +

    + +

    +

    Copying the Untrusted Module to a Project

    +
  4. +
+ + +

Updating SGX Enclave Signing Key

+

All skeletons enclave samples produced by the plugin contain a sample signing key. You might want to import another sign key that you already have, or generate a new one. Use the command Update SGX Enclave Signing Key to complete this task.

+
    +
  1. Choose Update SGX Enclave Signing Key by right-click on the project in Project Explorer -> Software Guard Extension Tools menu. The Import or (Re)Generate Enclave Signing Key dialog appears.
  2. +
  3. In the Import or (Re)Generate Enclave Signing Key dialog, click Select to open a file dialog to select the output key.
  4. +
  5. +

    Click Improt Key to update a selected signing key by copying another existing key or click Generate Key to update the selected signing key by generating a new key. In both cases, the new signature key is put into the file in text field Enclave Signing Key.

    +

    + +

    +

    Import or (Re)Generate Enclave Signing Key

    +
  6. +
  7. Click OK to update the enclave signing key.
  8. +
+

Under the hood, a new key is generated using openssl*, which needs to be installed on the machine:

+

openssl genrsa -out ../../../encl1_private.pem.key.pem -3 3072 +

+

+ + +

Updating Enclave Configuration Files

+

A configuration file is an important part in the definition of an enclave. Intel(R) SGX SDK signer tool requires such *.xml configuration file as necessary input.

+

To update this configuration file, use the Update Config command:

+
    +
  1. +

    Right-click on the root project, Software Extension Guards Tools->Select Config File.

    +

    + +

    +

    Select Configuration File

    +
  2. +
  3. +

    Click OK or double-click the selected configuration file to open the Enclave Configuration Settings dialog.

    +

    + +

    +

    Enclave Configuration Settings

    +

    For details on the meaning of the fields, see Intel(R) Software Guard Extensions Developer Guide.

    +
  4. +
+ + +

Two Steps Sign Enclave

+

To help you develop enclaves, Intel(R) Software Guard Extensions Eclipse Plug-in generates all required structure including:

+
    +
  • c/c++ files and header files
  • +
  • .edl file
  • +
  • *.config.xml file
  • +
  • a sample Makefile
  • +
  • a sample signing key
  • +
+

While these structure might be appropriate for development and debugging, you need a 2-step process to integrate your own signing schema for generating production enclaves.

+
    +
  1. Generate hash: the signer tool generates signing material from the unsigned compiled enclave and from the configuration file for the enclave. The signed material comes as an opaque sequence of bytes which are put in a file with extension .hex. This file is used with the external signing facility. You come back with a signature for the .hex file plus the public key of your signing facility, and proceed to Step 2.
  2. +
  3. Generate signed enclaves : the signer tool generates the final signed enclave.
  4. +
+

To complete this task, provide the following input parameters:

+
    +
  • The unsigned enclave
  • +
  • The configuration file
  • +
  • The output file produced when you generate hash (the .hex file)
  • +
  • The files produced by the external signing facility: the signature of the .hex file and public key for it
  • +
  • The plugin checks if the input parameters are consistent:
  • +
  • The .hex file matches the unsigned enclave and the configuration file,
  • +
  • The signed material is verified with the public key
  • +
+

If the parameters are consistenet, the production signed enclave is produced.

+
+

NOTE:

+

If you generate signed enclave right after generating hash, you can only enter the parameters specific for generating signed enclave.

+
+

To use the two-step signing function, activate the configuration SGX Hardware Release mode. When this configuration is active, the compilation does not produce a signed enclave, as in the other SGX configurations; the process only produces unsigned enclaves.

+

+ +

+

Configure SGX Hardware Release Mode

+

When you configure the plugin in the SGX Hardware Release Mode, you can see the Generate Hash and Generate Signed Enclave options through Software Guard Extension Tools->Two Step Sign Enclave.

+

+ +

+

Two Step Sign Enclave Menu

+ + +

Generate Hash

+

Generating hash is the first step in the 2-Steps signing process.To generate hash, use the following steps:

+
    +
  1. +

    Right-click on project root, go to Software Guard Extensions Tools menu → Two StepSigne Enclave → Generate Hash

    +

    + +

    +

    Two StepSigne Enclave - Generate Hash

    +
  2. +
  3. In the Generate Hash dialog, enter the required inputs to the corresponding fields:
    • Enter the path to the compiled enclave to be signed in the Enclave Path field. Click Select Enclave to open a file dialog to select the enclave.
    • In the Hash File Location field , enter the path of the output file that will contain signing materials. By default this file has the same file name as the unsigned enclave, with .hex extension added. To change the path, click Select File Path to open a file dialog to select the file path.
    • In the Configuration File path field, enter the path of the configuration filefor the generated hash. Click Select Config to open a dialog to select from all enclave configuration files in the project (similar with the one of the command Update Config).
  4. +
  5. +

    Click OK after you fill in all the fields. The Intel(R) SGX SDK is launched under the hood with the provided parameters and the hash file is generated. A dialog box appears to confirm the completion:

    +

    + +

    +

    Generating Hash Completion Dialog

    +
  6. +
+

You complete the first step, generating hash, in the two step signing enclave. The *.hex file may be signed with the external facility, which generates a signature for it and a public verification key.

+

If you click OK, the Generate Signed Enclave dialog appears. The required fileds in this dialog have been pre-configured with the paths of the unsigned enclave, the configuration file and of the *.hex file. To generated the final signed enclave ready for production immediately, click OK.

+

+ +

+

Generate Signed Enclave Dialog with Pre-configurations

+

If you click Cancel in the Generate Signed Enclave dialog, you can continue the signing process later using the Generate Signed Enclave command.

+ + +

Generate Signed Enclaves

+

Generating signed enclave is the second step in the 2-Steps signing process. You should have the following files to complete this step:

+
    +
  • The .hex file generated with Generate Hash command
  • +
  • The files produced from the external signing facility
  • +
  • The signature of the .hex file
  • +
  • The public verification key
  • +
+

To generate signed encalves, use the following steps:

+
    +
  1. +

    Right-click on the project root, and go to Software Guard Extensions Tools menu → Two Step Sign Enclave → Generate Signed Enclave.

    +

    + +

    +

    Generate Signed Enclave Dialog

    +
  2. +
  3. Enter the inputs to all the fields and click OK.
  4. +
+ + +

Building and Running SGX Code

+

This section describes the following topics about building and running SGX code:

+
    +
  • SGX build configurations
  • +
  • Running samples generated for enclaves
  • +
  + +

SGX Build Configurations

+

There are usually two types of builds that a regular non-SGX project defines:

+
    +
  • Debug
  • +
  • Release
  • +
+

SGX-enabled projects add to this picture support to build and test SGX-enabled application on non-SGX platforms (or emulator) using simulation libraries. This approach doubles the set of build types, creating four possible combinations. For these combinations, you need to use different sets of compilation and linking flags and link different libraries.

+

The non-debug hardware build is meant to give production code, so it requires the maximum attention when signed. The Two Steps Sign schema is required for production enclaves, which involves an external signing facility, not part of Intel SGX SDK. The other configurations are not meant for production but they have to be signed too. The simplest and more convenient Single Step schema is used for them.

+

Again for testing purpose, you might want to experiment with a non-production enclave built with release compilation and linking flags, on a real hardware SGX-enabled platform. That would be an enclave built exactly as a production enclave, except for the sign process which would be Single Step. To support the construction of such enclave, there is a hardware non-debug build configuration dubbed Prerelease.

+

So there are five SGX related configurations when SGX Nature is added to a project:

+

+ +

+

Intel(R) SGX Configurations

+

The following table resumes the existing SGX configurations and relate them with compilation/linking flags (debug/non-debug) and signing scheme (single vs. two steps):

+

Intel(R) SGX Configurations

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Configuration NameSimulation?Debug?Signing Schema
SGX Hardware DebugHardwareDebugSingle Step
SGX Hardware Pre-releaseHardwareNon-debugSingle Step
SGX Hardware ReleaseHardwareNon-debugTwo Step
SGX SimulationSimulationNon-debugSingle Step
SGX SimulationDebug SimulationDebugSingle step
+

Intel® Software Guard Extensions Eclipse Plug-in uses standard GNU* make tool to build the trusted and the untrusted code, using the generated file sgx/Makefile.

+

This fact does not impose any restriction on the build tool chosen for the hosting project. Intel® Software Guard Extensions Eclipse* Plug-in uses its own build configurations which do not interfere with the configurations that you might have in your project.

+

When SGX configurations are selected, by default only code under <root>/sgx directory get built.

+

You can customize SGX configurations as any other Eclipse build configurations from the project properties dialog. For example:

+
    +
  1. Right-click in Project Explorer Properties → C/C++ Build
  2. +
  3. Uncheck the Use default build command checkbox.
  4. +
+

Then you can customize and integrate SGX build process. You can use Makefile instead of sgx/Makefile in the example shown in the following figure:

+

+ +

+

Customization of SGX Build Command

+

The build process is done using standard Eclipse interface for build, by example from the main Project menu:

+

+ +

+

Project Menu

+ + +

Running Samples Generated for Enclaves

+

Intel(R) Software Guard Extensions Eclipse* Plugin provides an option to generate a sample application together with the enclave code when the enclave is created. After the project is build, the sample application is built also and ready to run. You can see the sample application named sample in the enclave directory in Project Explorer. You can run this sample as a local C/C++ application as shown in the following figure:

+

+ +

+

Sample Application

+

See the result of the execution in Eclipse console window as shown below:

+

+ +

+

The Result of Running Samples Generated for Enclaves

+ + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/plugin.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/plugin.xml new file mode 100644 index 0000000000..533d28bf13 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/plugin.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/src/com/intel/sgx/userguide/Activator.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/src/com/intel/sgx/userguide/Activator.java new file mode 100644 index 0000000000..f10dec9896 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/src/com/intel/sgx/userguide/Activator.java @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + +package com.intel.sgx.userguide; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.intel.sgx.userguide"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/toc.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/toc.xml new file mode 100644 index 0000000000..85c36da39e --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/toc.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.classpath b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.classpath new file mode 100644 index 0000000000..6c009435ce --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.classpath @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.project b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.project new file mode 100644 index 0000000000..aec7e39589 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.project @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + com.intel.sgx + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.settings/org.eclipse.jdt.core.prefs b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..a698e59674 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/META-INF/MANIFEST.MF b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..f06f84d713 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/META-INF/MANIFEST.MF @@ -0,0 +1,26 @@ +License: Eclipse Public License Version 1.0 ("EPL") +bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-SymbolicName: com.intel.sgx;singleton:=true +Bundle-Version: 1.0.1.qualifier +Bundle-Activator: com.intel.sgx.Activator +Bundle-Vendor: %Bundle-Vendor +Require-Bundle: org.eclipse.cdt.core;bundle-version="5.11.0", + org.eclipse.core.runtime;bundle-version="3.11.1", + org.eclipse.ui;bundle-version="3.107.0", + org.eclipse.cdt.managedbuilder.ui;bundle-version="8.2.2", + org.eclipse.cdt.managedbuilder.core;bundle-version="8.3.0", + org.eclipse.core.resources;bundle-version="3.10.1", + org.eclipse.cdt.ui;bundle-version="5.11.0", + org.eclipse.core.expressions;bundle-version="3.5.0", + org.eclipse.ui.ide;bundle-version="3.11.0" +Bundle-ActivationPolicy: lazy +Export-Package: com.intel.sgx, + com.intel.sgx.build, + com.intel.sgx.dialogs, + com.intel.sgx.discovery, + com.intel.sgx.handlers, + com.intel.sgx.natures, + com.intel.sgx.preferences, + com.intel.sgx.templates +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/OSGI-INF/l10n/bundle.properties b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000000..171c78c844 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,15 @@ +######################################################################### +# Copyright (c) 2016 Intel Corporation. # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Eclipse Public License v1.0 # +# which accompanies this distribution, and is available at # +# http://www.eclipse.org/legal/epl-v10.html # +# # +# Contributors: # +# Intel Corporation - initial implementation and documentation # +######################################################################### + + +Bundle-Vendor = Intel Corporation +Bundle-Name = SGX(R) Linux Eclipse Plugin \ No newline at end of file diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/build.properties b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/build.properties new file mode 100644 index 0000000000..d055ac2fdc --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/build.properties @@ -0,0 +1,24 @@ +######################################################################### +# Copyright (c) 2016 Intel Corporation. # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Eclipse Public License v1.0 # +# which accompanies this distribution, and is available at # +# http://www.eclipse.org/legal/epl-v10.html # +# # +# Contributors: # +# Intel Corporation - initial implementation and documentation # +######################################################################### + + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + templates/,\ + discovery/,\ + build.properties,\ + OSGI-INF/,\ + OSGI-INF/l10n/bundle.properties +jre.compilation.profile = JavaSE-1.8 diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/discovery/test.c b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/discovery/test.c new file mode 100644 index 0000000000..139597f9cb --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/discovery/test.c @@ -0,0 +1,2 @@ + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/discovery/test.cpp b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/discovery/test.cpp new file mode 100644 index 0000000000..139597f9cb --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/discovery/test.cpp @@ -0,0 +1,2 @@ + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/plugin.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/plugin.xml new file mode 100644 index 0000000000..86a2ba5d05 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/plugin.xml @@ -0,0 +1,786 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An C project, with SGX Commands and Configurations + + + + + + An C++ project, with SGX Commands and Configurations + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Activator.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Activator.java new file mode 100644 index 0000000000..580330b423 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Activator.java @@ -0,0 +1,75 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + +package com.intel.sgx; + +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + public static final String PLUGIN_ID = "com.intel.sgx";//$NON-NLS-1$ + + private static Activator plugin; + + public Activator() { + } + + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public static Activator getDefault() { + return plugin; + } + + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + public static void log(Exception e) { + plugin.getLog().log(newStatus(e)); + } + + public static IStatus newStatus(Exception e) { + return new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e); + } + + public static URL findFile(Path path) { + return FileLocator.find(plugin.getBundle(), path, null); + } + + public static Bundle getBundle(String id){ + for(Bundle bundle : plugin.getBundle().getBundleContext().getBundles()){ + if(bundle.getSymbolicName().equals(id)) + return bundle; + } + return null; + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/CConfigurationDataProvider2.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/CConfigurationDataProvider2.java new file mode 100644 index 0000000000..59cdc66e33 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/CConfigurationDataProvider2.java @@ -0,0 +1,46 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx; + +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; +import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +public class CConfigurationDataProvider2 extends CConfigurationDataProvider { + + public CConfigurationDataProvider2() { + } + + @Override + public CConfigurationData loadConfiguration(ICConfigurationDescription des, + IProgressMonitor monitor) throws CoreException { + return null; + } + + @Override + public CConfigurationData createConfiguration( + ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData baseData, boolean clone, IProgressMonitor monitor) + throws CoreException { + return null; + } + + @Override + public void removeConfiguration(ICConfigurationDescription des, + CConfigurationData data, IProgressMonitor monitor) { + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Messages.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Messages.java new file mode 100644 index 0000000000..d4133b2962 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Messages.java @@ -0,0 +1,37 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "com.intel.sgx.messages";//$NON-NLS-1$ + + /* + * TODO - These Strings can be used all through the package to control what messages are displayed. + * Todo here is to identify any message that needs to be made configurable. + */ + public static String CreateNativeFolders_No_folders; + public static String CreateNativeFolders_Missing_project_name; + public static String CreateNativeFolders_Project_does_not_exist; + + static{ + //Bundle initialization. + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages(){ + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/SdkPathVariableProvider.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/SdkPathVariableProvider.java new file mode 100644 index 0000000000..43f13da5f9 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/SdkPathVariableProvider.java @@ -0,0 +1,70 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx; +import java.io.File; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.variableresolvers.PathVariableResolver; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.preference.IPreferenceStore; + +import com.intel.sgx.preferences.PreferenceConstants; +import com.intel.sgx.preferences.SGXPreferencePage; + +public class SdkPathVariableProvider extends PathVariableResolver { + + public SdkPathVariableProvider() { + super(); + } + + @Override + public String[] getVariableNames(String variable, IResource resource) { + String variableNames[] = {"SGX_SDK_DIR_PATH"}; + return (variableNames); + } + + @Override + public String getValue(String variable, IResource resource) { + if(variable.equals("SGX_SDK_DIR_PATH")) { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + String SDKPath = store.getString(PreferenceConstants.SDK_PATH); + IPath SDKCanonicalPath= new Path(SDKPath); + return(SDKCanonicalPath.append("Include").toOSString()); + } + return null; + } + + public static String getSGXSdkLocation() { + return Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH); + } + + public static boolean isSGXSdkLocationValid() { + String location = getSGXSdkLocation(); + if (location.length() == 0) + return false; + + return isValidSGXSdkLocation(location); + } + + public static boolean isValidSGXSdkLocation(String location) { + File dir = new File(location); + if (!dir.isDirectory()) + return false; + + return new PreferenceConstants.SGXSDK64Descriptor(dir).getSignerPath().canExecute() + || new PreferenceConstants.SGXSDK32Descriptor(dir).getSignerPath().canExecute(); + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/build/SGXSDKCommandLauncher.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/build/SGXSDKCommandLauncher.java new file mode 100644 index 0000000000..c0eb394532 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/build/SGXSDKCommandLauncher.java @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +/** + * This class follows the same solution provided in the NDK_PLUGIN for NDKCommandLauncher. + */ +package com.intel.sgx.build; + +import org.eclipse.cdt.core.CommandLauncher; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; + +import com.intel.sgx.SdkPathVariableProvider; +/** + * This launches the sgx-ndk-build. + */ +public class SGXSDKCommandLauncher extends CommandLauncher { + + @Override + public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, + IProgressMonitor monitor) + throws CoreException { + + return super.execute(commandPath, args, env, changeToDirectory, monitor); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddEnclaveFileDialog.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddEnclaveFileDialog.java new file mode 100644 index 0000000000..e663a1c390 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddEnclaveFileDialog.java @@ -0,0 +1,126 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import javax.swing.JOptionPane; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.intel.sgx.handlers.AddEnclave; + +public class AddEnclaveFileDialog extends SGXDialogBase { + + private Text fileNameField; + private AddEnclave addHandler; + private boolean generateApp = true; + + public AddEnclaveFileDialog(Shell shell, AddEnclave addHandler) { + super(shell); + this.addHandler = addHandler; + this.shell = shell; + // setShellStyle(SWT.RESIZE | SWT.TITLE); + } + + public boolean generateApp() + { + return generateApp; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1,false); + composite.setLayout(gridLayout); + + final Group container = new Group(composite, SWT.NONE); + container.setLayout(new GridLayout(3,false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + container.setLayoutData(innergrid1); + + addLabel(container, "Enter the name of the Enclave. Make sure the name is unique within the hosting application."); + + final Label fileNameLabel = new Label(container, SWT.NONE); + fileNameLabel.setText("Enclave name:"); + fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); + + fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER); + GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL); + textGridData1.minimumWidth = 400; + textGridData1.grabExcessHorizontalSpace = true; + fileNameField.setLayoutData(textGridData1); + + Button generateUntrustedApp = new Button(container, SWT.CHECK); + generateUntrustedApp.setText("Generate sample untrusted application?"); + generateUntrustedApp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false, 3, 1)); + generateUntrustedApp.setSelection(true); + + generateUntrustedApp.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent event) { + Button btn = (Button) event.getSource(); + generateApp = btn.getSelection(); + } + }); + + container.layout(); + composite.layout(); + return composite; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Add New SGX Enclave Dialog"); + newShell.layout(); + } + + @Override + protected + void okPressed() { + addHandler.edlFilename = fileNameField.getText(); + if(!fileNameField.getText().isEmpty() + ){ + if(Character.isDigit(fileNameField.getText().charAt(0))) + { + JOptionPane.showMessageDialog(null, "Enclave names starting with digits are not allowed.", "Error", + JOptionPane.ERROR_MESSAGE); + } + else + super.okPressed(); + } + } + + @Override + protected Point getInitialSize(){ + return new Point(675,200); + } + + public String getFileName() { + return fileNameField.getText(); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddTrustedStaticLibFileDialog.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddTrustedStaticLibFileDialog.java new file mode 100644 index 0000000000..b353c716c8 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddTrustedStaticLibFileDialog.java @@ -0,0 +1,109 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import javax.swing.JOptionPane; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.intel.sgx.handlers.AddTrustedStaticLib; + +public class AddTrustedStaticLibFileDialog extends SGXDialogBase { + + private Text fileNameField; + private AddTrustedStaticLib addHandler; + private boolean generateApp = false; + + public AddTrustedStaticLibFileDialog(Shell shell, AddTrustedStaticLib addHandler) { + super(shell); + this.addHandler = addHandler; + this.shell = shell; + // setShellStyle(SWT.RESIZE | SWT.TITLE); + } + + public boolean generateApp() + { + return generateApp; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1,false); + composite.setLayout(gridLayout); + + final Group container = new Group(composite, SWT.NONE); + container.setLayout(new GridLayout(3,false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + container.setLayoutData(innergrid1); + + addLabel(container, "Enter the name of the Static Trusted Library."); + addLabel(container, "Make sure the name is unique within the hosting application."); + + final Label fileNameLabel = new Label(container, SWT.NONE); + fileNameLabel.setText("Static Trusted Library Name:"); + fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); + + fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER); + GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL); + textGridData1.minimumWidth = 400; + textGridData1.grabExcessHorizontalSpace = true; + fileNameField.setLayoutData(textGridData1); + + composite.layout(); + + return composite; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Add New SGX Static Trusted Library Dialog"); + } + + @Override + protected + void okPressed(){ + addHandler.edlFilename = fileNameField.getText(); + if(!fileNameField.getText().isEmpty() + ){ + if(Character.isDigit(fileNameField.getText().charAt(0))) + { + JOptionPane.showMessageDialog(null, "Enclave names starting with digits are not allowed.", "Error", + JOptionPane.ERROR_MESSAGE); + } + else + super.okPressed(); + } + } + + @Override + protected Point getInitialSize(){ + return new Point(675,200); + } + + public String getFileName() { + return fileNameField.getText(); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddUntrustedModuleDialog.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddUntrustedModuleDialog.java new file mode 100644 index 0000000000..15779d4651 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddUntrustedModuleDialog.java @@ -0,0 +1,138 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import java.io.File; + +import javax.swing.JOptionPane; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.intel.sgx.handlers.AddUntrustedModule; + +public class AddUntrustedModuleDialog extends Dialog { + + private Text fileNameField,makeFilePathField; + private Shell shell; + private AddUntrustedModule addHandler; + private boolean generateApp = false; + + public AddUntrustedModuleDialog(Shell shell, AddUntrustedModule addHandler) { + super(shell); + this.addHandler = addHandler; + this.shell = shell; + //setShellStyle(SWT.RESIZE | SWT.TITLE); + } + + public boolean generateApp() + { + return generateApp; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1,false); + composite.setLayout(gridLayout); + + final Group container = new Group(composite, SWT.NONE); + container.setLayout(new GridLayout(3,false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + container.setLayoutData(innergrid1); + + final Label messageLabel = new Label(container, SWT.NONE); + messageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); + messageLabel.setText("Enter the path to the Enclave Descriptor file (*.edl) of the enclave to host."); + + + final Label fileNameLabel = new Label(container, SWT.NONE); + fileNameLabel.setText("Filename:"); + fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); + + + fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER); + GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL); + textGridData1.minimumWidth = 400; + textGridData1.grabExcessHorizontalSpace = true; + fileNameField.setLayoutData(textGridData1); + + final Button browseButton = new Button(container, SWT.PUSH); + browseButton.setText("Browse"); + GridData buttonGridData1 = new GridData(GridData.END); + buttonGridData1.horizontalAlignment = SWT.RIGHT; + buttonGridData1.horizontalSpan = 1; + buttonGridData1.minimumWidth = 120; + browseButton.setLayoutData(buttonGridData1); + browseButton.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = null; + shell = new Shell(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + dialog.setFilterExtensions(new String [] {"*.edl"}); + dialog.setFilterPath(""); + result = dialog.open(); + fileNameField.setText(result); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + return composite; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Add SGX Untrusted Module."); + } + + @Override + protected + void okPressed(){ + addHandler.edlFilename = fileNameField.getText(); + if(!fileNameField.getText().isEmpty()) + if((new File(fileNameField.getText())).isFile()) + super.okPressed(); + else + JOptionPane.showMessageDialog(null, "EDL file does not exist.", "Error", + JOptionPane.ERROR_MESSAGE); + } + + @Override + protected Point getInitialSize(){ + return new Point(675,200); + } + + public String getFileName() { + return fileNameField.getText(); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/EnclaveConfigDialog.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/EnclaveConfigDialog.java new file mode 100644 index 0000000000..20595f8095 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/EnclaveConfigDialog.java @@ -0,0 +1,257 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import org.eclipse.jface.preference.JFacePreferences; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.intel.sgx.handlers.EnclaveConfigHandler; + +public class EnclaveConfigDialog extends SGXDialogBase { + + @SuppressWarnings("unused") + private Shell shell; + private EnclaveConfigHandler enclaveConfig; + private Label statusLabel; + private Text prodID; + private Text isvSvn; + private Text threadStackSize; + private Text globalHeapSize; + private Text tcsNum; + private Combo tcsPolicy; + private Button disableDebug; + + public EnclaveConfigDialog(Shell parentshell,EnclaveConfigHandler enclaveConfigHandler) { + super(parentshell); + this.shell = parentshell; + this.enclaveConfig = enclaveConfigHandler; + setShellStyle(SWT.RESIZE | SWT.TITLE); + } + + @Override + protected Control createDialogArea(Composite parent) { + + Composite container = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(3,false); + container.setLayout(gridLayout); + + final Group groupLabel1 = new Group(container, SWT.None); + groupLabel1.setLayout(new GridLayout(3,false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + groupLabel1.setLayoutData(innergrid1); + + Label warningLabel = new Label(groupLabel1,SWT.BEGINNING | SWT.WRAP); + warningLabel.setText("Note: Use this Menu to change the Enclave settings."); + + statusLabel = new Label(container,SWT.BEGINNING | SWT.WRAP); + GridData statusGrid = new GridData(GridData.FILL_HORIZONTAL); + statusGrid.horizontalSpan = 3; + statusLabel.setLayoutData(statusGrid); + statusLabel.setText(""); + statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR)); + + final Group groupLabel2 = new Group(container, SWT.None); + groupLabel2.setLayout(new GridLayout(3,false)); + groupLabel2.setText("Modify the Enclave Settings here..."); + GridData innergrid = new GridData(GridData.FILL_HORIZONTAL); + innergrid.horizontalSpan = 3; + groupLabel2.setLayoutData(innergrid); + + final Label messageLabel0 = new Label(groupLabel2, SWT.NONE); + messageLabel0.setText("Product ID:"); + messageLabel0.setLayoutData(new GridData(GridData.BEGINNING)); + + prodID = new Text(groupLabel2, SWT.SINGLE | SWT.BORDER); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 2; + gridData.widthHint = 400; + prodID.setLayoutData(gridData); + prodID.setText(enclaveConfig.prodId); + prodID.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent modifyEvent) { + statusLabel.setText(""); + enclaveConfig.prodId = prodID.getText(); + } + }); + + final Label messageLabel1 = new Label(groupLabel2, SWT.NONE); + messageLabel1.setText("ISV SVN:"); + messageLabel1.setLayoutData(new GridData(GridData.BEGINNING)); + + isvSvn = new Text(groupLabel2, SWT.SINGLE | SWT.BORDER); + isvSvn.setLayoutData(gridData); + isvSvn.setText(enclaveConfig.isvSvn); + isvSvn.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent modifyEvent) { + statusLabel.setText(""); + enclaveConfig.isvSvn = isvSvn.getText(); + } + }); + + final Label messageLabel2 = new Label(groupLabel2, SWT.NONE); + messageLabel2.setText("Thread Stack Size:"); + messageLabel2.setLayoutData(new GridData(GridData.BEGINNING)); + + threadStackSize = new Text(groupLabel2, SWT.SINGLE | SWT.BORDER); + threadStackSize.setLayoutData(gridData); + threadStackSize.setText(enclaveConfig.threadStackSize); + threadStackSize.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent modifyEvent) { + enclaveConfig.threadStackSize = threadStackSize.getText(); + if(!(threadStackSize.getText().matches("0x[0-9a-fA-F]{1,}000"))) + { + statusLabel.setText("Error: The Thread Stack Size value must be Page Aligned."); + } + else + { + if(!(enclaveConfig.globalHeapSize.matches("0x[0-9a-fA-F]{1,}000"))) + statusLabel.setText("Error: The Global Heap Size value must be Page Aligned."); + else + statusLabel.setText(""); + } + } + }); + + final Label messageLabel3 = new Label(groupLabel2, SWT.NONE); + messageLabel3.setText("Global Heap Size:"); + messageLabel3.setLayoutData(new GridData(GridData.BEGINNING)); + + globalHeapSize = new Text(groupLabel2, SWT.SINGLE | SWT.BORDER); + globalHeapSize.setLayoutData(gridData); + globalHeapSize.setText(enclaveConfig.globalHeapSize); + globalHeapSize.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent modifyEvent) { + enclaveConfig.globalHeapSize = globalHeapSize.getText(); + if(!(globalHeapSize.getText().matches("0x[0-9a-fA-F]{1,}000"))) + { + statusLabel.setText("Error: The Global Heap Size value must be Page Aligned."); + } + else + { + if(!(enclaveConfig.threadStackSize.matches("0x[0-9a-fA-F]{1,}000"))) + statusLabel.setText("Error: The Thread Stack Size value must be Page Aligned."); + else + statusLabel.setText(""); + + } + } + }); + + final Label messageLabel4 = new Label(groupLabel2, SWT.NONE); + messageLabel4.setText("TCS Number:"); + messageLabel4.setLayoutData(new GridData(GridData.BEGINNING)); + + tcsNum = new Text(groupLabel2, SWT.SINGLE | SWT.BORDER); + tcsNum.setLayoutData(gridData); + tcsNum.setText(enclaveConfig.tcsNum); + tcsNum.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent modifyEvent) { + statusLabel.setText(""); + enclaveConfig.tcsNum = tcsNum.getText(); + } + }); + + final Label messageLabel5 = new Label(groupLabel2, SWT.NONE); + messageLabel5.setText("TCS Policy:"); + messageLabel5.setLayoutData(new GridData(GridData.BEGINNING)); + + final String[] items = {"Unbound","Bound"}; + tcsPolicy = new Combo(groupLabel2, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); + tcsPolicy.setItems(items); + String item = items[Integer.parseInt(enclaveConfig.tcsPolicy)]; + int index = tcsPolicy.indexOf(item); + tcsPolicy.select(index < 0 ? 0 : index); + tcsPolicy.setLayoutData(gridData); + tcsPolicy.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e){ + statusLabel.setText(""); + enclaveConfig.tcsPolicy = (tcsPolicy.getSelectionIndex() == 0 ? "0" : "1"); + } + }); + + + final Label messageLabel6 = new Label(groupLabel2, SWT.NONE); + messageLabel6.setText("Disable Debug:"); + messageLabel6.setLayoutData(new GridData(GridData.BEGINNING)); + + disableDebug = new Button(groupLabel2,SWT.CHECK); + GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL); + disableDebug.setLayoutData(gridData1); + disableDebug.setSelection(enclaveConfig.disableDebug.equals("1")?true:false); + disableDebug.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e){ + statusLabel.setText(""); + enclaveConfig.disableDebug = disableDebug.getSelection()?"1":"0"; + } + }); + + if(statusLabel.getText() != null){ + statusLabel.setVisible(true); + } + else{ + statusLabel.setVisible(false); + } + + return container; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Enclave Configuration Settings:"); + } + + @Override + protected Point getInitialSize(){ + return new Point(450,400); + } + + @Override + protected + void okPressed(){ + enclaveConfig.prodId = this.prodID.getText(); + enclaveConfig.isvSvn = this.isvSvn.getText(); + enclaveConfig.threadStackSize = this.threadStackSize.getText(); + enclaveConfig.globalHeapSize = this.globalHeapSize.getText(); + enclaveConfig.tcsNum = this.tcsNum.getText(); + enclaveConfig.tcsPolicy = this.tcsPolicy.getSelectionIndex() == 0 ? "0" : "1"; + enclaveConfig.disableDebug = disableDebug.getSelection()?"1":"0"; + + + if((statusLabel.getText() == "") && (enclaveConfig.globalHeapSize.matches("0x[0-9a-fA-F]{1,}000")) && (enclaveConfig.threadStackSize.matches("0x[0-9a-fA-F]{1,}000"))) + super.okPressed(); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/RemoveEnclaveFileDialog.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/RemoveEnclaveFileDialog.java new file mode 100644 index 0000000000..6db3d2e1c4 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/RemoveEnclaveFileDialog.java @@ -0,0 +1,122 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +//import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.intel.sgx.handlers.RemoveEnclave; + +public class RemoveEnclaveFileDialog extends Dialog{ + + private Text fileNameField; + private Shell shell; + private RemoveEnclave removeHandler; + + public RemoveEnclaveFileDialog(Shell shell, RemoveEnclave removeHandler) { + super(shell); + this.removeHandler = removeHandler; + this.shell = shell; + setShellStyle(SWT.RESIZE | SWT.TITLE); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1,false); + composite.setLayout(gridLayout); + + final Group container = new Group(composite, SWT.None); + container.setLayout(new GridLayout(3,false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + container.setLayoutData(innergrid1); + container.setText("Path to Enclave directory:"); + + final Label messageLabel = new Label(container, SWT.NONE); + messageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); + messageLabel.setText("Enter the name of the Enclave Or Navigate to the Enclave folder to be removed from the host."); + + final Label fileNameLabel = new Label(container, SWT.NONE); + fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); + fileNameLabel.setText("Enclave Name:"); + + fileNameField = new Text(container, SWT.SINGLE | SWT.BORDER); + GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL); + textGridData1.minimumWidth = 400; + textGridData1.grabExcessHorizontalSpace = true; + fileNameField.setLayoutData(textGridData1); + + final Button browseButton = new Button(container, SWT.PUSH); + browseButton.setText("Browse"); + GridData buttonGridData1 = new GridData(GridData.END); + buttonGridData1.horizontalAlignment = SWT.RIGHT; + buttonGridData1.horizontalSpan = 1; + buttonGridData1.minimumWidth = 120; + browseButton.setLayoutData(buttonGridData1); + browseButton.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = fileNameField.getText(); + + DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN); + dialog.setMessage("Select the Enclave Directory to remove."); + dialog.setFilterPath(""); + result = dialog.open(); + fileNameField.setText(result); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + return container; + } + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Remove an Imported Enclave"); + } + + @Override + protected void okPressed(){ + removeHandler.edlFilename = fileNameField.getText(); + if(!fileNameField.getText().isEmpty()) + super.okPressed(); + } + + @Override + protected Point getInitialSize(){ + return new Point(675,205); + } + + public String getFileName() { + return fileNameField.getText(); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/SGXDialogBase.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/SGXDialogBase.java new file mode 100644 index 0000000000..4b49a8bb31 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/SGXDialogBase.java @@ -0,0 +1,222 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import java.io.InputStream; +import java.util.Scanner; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.IShellProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; + +import com.intel.sgx.Activator; + +public abstract class SGXDialogBase extends Dialog { + + protected Shell shell; + public Text configFileField; + public static FilteredResourcesSelectionDialog dialogForConfig(Shell shell) { + // final IContainer container = ResourcesPlugin.getWorkspace().getRoot(); + + final IContainer container = SGXDialogBase.getCurrentProject(); + + FilteredResourcesSelectionDialog d = new FilteredResourcesSelectionDialog( + shell, false, container, IResource.FILE) { + { + setInitialPattern("**"); + } + + @Override + protected IStatus validateItem(Object item) { + // return Status.OK_STATUS; + IFile f = (IFile) item; + if (f.getParent() instanceof IProject) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, + "The selected resource has to be part of the source folder"); + } + + + return super.validateItem(item); + } + + protected ItemsFilter createFilter() { + return new ResourceFilter(container, true, IResource.FILE) { + + @Override + public boolean matchItem(Object item) { + return isConfigFile(item); + } + + private boolean isConfigFile(Object item) { + if (!(item.toString().endsWith(".xml") && super + .matchItem(item))) { + return false; + } + try { + IFile iFile = (IFile) item; + return streamContainsString(iFile.getContents(), + ""); + } catch (Throwable e) { + return false; + } + } + + }; + + } + + public boolean streamContainsString(InputStream is, + String searchString) { + Scanner streamScanner = new Scanner(is); + if (streamScanner.findWithinHorizon(searchString, 0) != null) { + return true; + } else { + return false; + } + } + + }; + return d; + } + + + + protected SelectionListener configFileSelectionListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + + FilteredResourcesSelectionDialog d = dialogForConfig(shell); + d.setTitle("Select Config File"); + if (d.open() == Dialog.OK) { + IFile target = (IFile) d.getResult()[0]; + configFileField.setText(target.getLocation().toOSString()); + } + ; + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + // TODO Auto-generated method stub + + } + + }; + + public SGXDialogBase(Shell parentShell) { + super(parentShell); + } + + public SGXDialogBase(IShellProvider parentShell) { + super(parentShell); + } + + protected Text addGroup(Composite composite, String title, String subtitle, + String label, String selectButtonLabel, SelectionListener selectionListener) { + final Group container = new Group(composite, SWT.None); + container.setLayout(new GridLayout(3, false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + container.setLayoutData(innergrid1); + container.setText(title); + + final Label messageLabel = new Label(container, SWT.NONE); + messageLabel.setLayoutData(new GridData(GridData.BEGINNING, + GridData.CENTER, false, false, 3, 1)); + messageLabel.setText(subtitle); + + final Label messageLabel1 = new Label(container, SWT.NONE); + messageLabel1.setText(label); + messageLabel1.setLayoutData(new GridData(GridData.BEGINNING)); + + Text directoryNameField = new Text(container, SWT.SINGLE | SWT.BORDER); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 1; + gridData.widthHint = 400; + directoryNameField.setLayoutData(gridData); + + final Button selectButton = new Button(container, SWT.PUSH); + selectButton.setText(selectButtonLabel); + GridData buttonGridData = new GridData(GridData.END); + buttonGridData.horizontalAlignment = SWT.RIGHT; + buttonGridData.horizontalSpan = 1; + buttonGridData.minimumWidth = 120; + selectButton.setLayoutData(buttonGridData); + selectButton.addSelectionListener(selectionListener); + return directoryNameField; + } + + + public IPath getCurrentProjectPath() { + IProject project = getCurrentProject(); + + IPath path = null; + if (project != null) { + path = project.getLocation(); + } + return path; + } + + static public IProject getCurrentProject() { + IProject project = null; + + + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + if (window != null) { + IStructuredSelection selection = (IStructuredSelection) window + .getSelectionService().getSelection(); + Object firstElement = selection.getFirstElement(); + if (firstElement instanceof IAdaptable) { + project = (IProject) ((IAdaptable) firstElement) + .getAdapter(IProject.class); + } + } + return project; + } + + @Override + protected void configureShell(Shell newShell){ + super.configureShell(newShell); + } + + protected void addLabel(final Group container, String labelText) { + final Label messageLabel = new Label(container, SWT.NONE); + messageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); + messageLabel.setText(labelText); + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignDialogBase.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignDialogBase.java new file mode 100644 index 0000000000..07d25c7321 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignDialogBase.java @@ -0,0 +1,174 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import java.io.File; +import java.util.Scanner; + +import javax.swing.JOptionPane; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public abstract class TwoStepSignDialogBase extends SGXDialogBase { + + public Text enclaveFileField; + public Text hashFileField; + public Text externalSignPublicKeyFileField; + public Text externalSignedHashFileField; + public Text outputSignedEnclaveFileField; + + public TwoStepSignDialogBase(Shell parentShell) { + super(parentShell); + setShellStyle(SWT.RESIZE | SWT.TITLE); + this.shell = TwoStepSignDialogBase.this.getParentShell(); + + } + + // for each field, a corresponding listener + protected SelectionListener enclaveFileSelectionListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = enclaveFileField.getText(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + + + + dialog.setFilterExtensions(new String[]{"*.so"} ); + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + + if (result != null && !result.isEmpty()) { + dialog.setFilterPath(new File(result).getParent()); + } else { + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + } + + result = dialog.open(); + + enclaveFileField.setText(result); + + hashFileField.setText(result + ".hex"); + + if (outputSignedEnclaveFileField != null){ + String outputSignedEnclavePath = result; + if(outputSignedEnclavePath.endsWith(".so")) + { + outputSignedEnclavePath = + outputSignedEnclavePath.substring(0,outputSignedEnclavePath.length() - ".so".length()); + outputSignedEnclaveFileField.setText(outputSignedEnclavePath+".signed.so"); + } + + } + + + + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + } + }; + + protected SelectionListener hashFileSelectionListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = hashFileField.getText(); + + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + + if (result != null && !result.isEmpty()) { + dialog.setFilterPath(new File(result).getParent()); + } else { + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + } + + result = dialog.open(); + + hashFileField.setText(result); + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + } + + }; + + protected SelectionListener publicKeyLocationSelectionListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = externalSignPublicKeyFileField.getText(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + dialog.setFilterExtensions(new String [] {"*.pem", "*"}); + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + result = dialog.open(); + externalSignPublicKeyFileField.setText(result); + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }; + + protected SelectionListener externalSignedHashFileSelectionListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = externalSignedHashFileField.getText(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + result = dialog.open(); + externalSignedHashFileField.setText(result); + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }; + + protected SelectionListener outputSignedEnclaveListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = outputSignedEnclaveFileField.getText(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + + + dialog.setFilterExtensions(new String[]{"*.so", } ); + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + + if (result != null && !result.isEmpty()) { + dialog.setFilterPath(new File(result).getParent()); + } else { + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + } + + result = dialog.open(); + + outputSignedEnclaveFileField.setText(result); + + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + } + }; + + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + } + + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog1.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog1.java new file mode 100644 index 0000000000..fdba448164 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog1.java @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +import com.intel.sgx.handlers.TwoStepSignHandlerBase; + +public class TwoStepSignStep1Dialog1 extends TwoStepSignDialogBase { + + final private TwoStepSignHandlerBase handler; + + public TwoStepSignStep1Dialog1(Shell parentShell, TwoStepSignHandlerBase handler) { + super(parentShell); + this.handler = handler; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1, false); + composite.setLayout(gridLayout); + + enclaveFileField = addGroup(composite, "Unsigned Enclave Path:", + "Select Enclave for which to generate the Hash.", + "Enclave Path:", "Select Enclave", enclaveFileSelectionListener); + + hashFileField = addGroup(composite, "Generate Hash:", + "Select Location to Output Hash File.", "Hash File Location:", + "Select File Path", hashFileSelectionListener); + + configFileField = addGroup(composite, "Configuration File:", + "Select Input Configuration XML File. ", + "Configuration File:", "Select Config", + configFileSelectionListener); + + composite.pack(true); + return composite; + } + + @Override + protected void okPressed() { + handler.enclaveFile = enclaveFileField.getText(); + handler.hashFile = hashFileField.getText(); + handler.configFile = configFileField.getText(); + + super.okPressed(); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Two Step Enclave Sign - Generate Hash"); + } + + + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog2.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog2.java new file mode 100644 index 0000000000..4c2852f9f4 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog2.java @@ -0,0 +1,89 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +public class TwoStepSignStep1Dialog2 extends TwoStepSignDialogBase { + + final private String hashFile; + + public TwoStepSignStep1Dialog2(Shell parentShell, String hashFile) { + super(parentShell); + this.hashFile = hashFile; + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1,false); + composite.setLayout(gridLayout); + + addGroup1(composite); + addGroup3(composite); + + + return composite; + } + + private void addGroup1(Composite composite) { + final Group container = new Group(composite, SWT.None); + container.setLayout(new GridLayout(3,false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + container.setLayoutData(innergrid1); + container.setText("Hash File:"); + + final Label messageLabel = new Label(container, SWT.NONE); + messageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); + messageLabel.setText("Hash File Generated at Location:"); + + final Label messageLabel1 = new Label(container, SWT.NONE); + messageLabel1.setText(hashFile); + + messageLabel1.setLayoutData(new GridData(GridData.BEGINNING)); + } + + private void addGroup3(Composite composite) { + final Group container3 = new Group(composite, SWT.None); + container3.setLayout(new GridLayout(3,false)); + GridData innergrid3 = new GridData(GridData.FILL_HORIZONTAL); + innergrid3.horizontalSpan = 3; + container3.setLayoutData(innergrid3); + container3.setText("Generate Signed Enclave (Step-2):"); + + final Label messageLabel4 = new Label(container3, SWT.NONE); + messageLabel4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); + messageLabel4.setText("To Generate Signed Enclave Now: Click OK"); + + final Label messageLabel5 = new Label(container3, SWT.NONE); + messageLabel5.setLayoutData(new GridData(GridData.CENTER, GridData.END, false, false, 3, 1)); + messageLabel5.setText("To Generate Signed Enclave Later: Click Cancel"); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Two Step Enclave Sign - Generate Hash"); + } + + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog3.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog3.java new file mode 100644 index 0000000000..976f1c21b3 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog3.java @@ -0,0 +1,105 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +import com.intel.sgx.handlers.TwoStepSignHandlerBase; + +public class TwoStepSignStep1Dialog3 extends TwoStepSignDialogBase { + + final private TwoStepSignHandlerBase handler; + + public TwoStepSignStep1Dialog3(Shell parentShell, TwoStepSignHandlerBase handler) { + super(parentShell); + this.handler = handler; + } + + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1, false); + composite.setLayout(gridLayout); + + addInfoGroup(composite); + + externalSignPublicKeyFileField = addGroup(composite, "Public Key:", + "Select the Public Key file obtained from signing facility", + "Public Key:", "Select", publicKeyLocationSelectionListener); + + externalSignedHashFileField = addGroup(composite, "Signature:", + "Select the Signature file obtained from signing facility.", + "Signature:", + "Select", externalSignedHashFileSelectionListener); + + + outputSignedEnclaveFileField = addGroup(composite, "Signed Enclave:", + "Select where to save the output Signed Enclave.", + "Signed Enclave:", + "Select", outputSignedEnclaveListener); + + return composite; + } + + protected void addInfoGroup(Composite composite) { + final Group container = new Group(composite, SWT.None); + container.setLayout(new GridLayout(3,false)); + GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL); + innergrid1.horizontalSpan = 3; + container.setLayoutData(innergrid1); + container.setText("Hash and Enclave:"); + + + addInfoKeyValue(container, "Enclave File:", handler.enclaveFile); + addInfoKeyValue(container, "Config File:", handler.configFile); + addInfoKeyValue(container, "Hash File:", handler.hashFile); + } + + private void addInfoKeyValue(final Group container, String key, + String value) { + final Label messageLabel2 = new Label(container, SWT.NONE); + messageLabel2.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); + messageLabel2.setText(key); + + final Label messageLabel3 = new Label(container, SWT.NONE); + messageLabel3.setText(value); + messageLabel3.setLayoutData(new GridData(GridData.BEGINNING)); + } + + @Override + protected void okPressed() { + handler.externalSignPublicKeyFile = externalSignPublicKeyFileField.getText(); + handler.externallySignedHashFile = externalSignedHashFileField.getText(); + handler.outputSignedEnclaveFile = outputSignedEnclaveFileField.getText(); + super.okPressed(); + } + + + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Two Step Enclave Sign - Generate Signed Enclave"); + } + + + + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep2Dialog.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep2Dialog.java new file mode 100644 index 0000000000..acd9e99627 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep2Dialog.java @@ -0,0 +1,92 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +import com.intel.sgx.handlers.TwoStepSignHandlerBase; +import com.intel.sgx.handlers.TwoStepSignStep2; + +public class TwoStepSignStep2Dialog extends TwoStepSignDialogBase{ + + final private TwoStepSignHandlerBase handler; + + + public TwoStepSignStep2Dialog(Shell parentShell, TwoStepSignHandlerBase handler) { + super(parentShell); + this.handler = handler; + } + + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1,false); + composite.setLayout(gridLayout); + + + + enclaveFileField= addGroup(composite, "Enclave:", + "Select the unsigned enclave file", + "Unsigned Enclave File:", "Select", enclaveFileSelectionListener); + + configFileField = addGroup(composite, "Configuration File:", + "Select Input Configuration XML File. ", + "Configuration File:", "Select Config", + configFileSelectionListener); + + hashFileField= addGroup(composite, "Hash:", + "Select the Hash file obtained from previous step", + "Hash File:", "Select", hashFileSelectionListener); + + externalSignPublicKeyFileField= addGroup(composite, "Public Key:", + "Select the Public Key file obtained from external signing facility", + "Public Key:", "Select", publicKeyLocationSelectionListener); + + externalSignedHashFileField = addGroup(composite, "Signature:", + "Select the Signature file obtained from signing facility.", + "Signature:", + "Select", externalSignedHashFileSelectionListener); + + outputSignedEnclaveFileField = addGroup(composite, "Signed Enclave:", + "Select where to save the output Signed Enclave.", + "Signed Enclave:", + "Select", outputSignedEnclaveListener); + + return composite; + } + + + @Override + protected void okPressed() { + handler.enclaveFile = enclaveFileField.getText(); + handler.hashFile = hashFileField.getText(); + handler.configFile = configFileField.getText(); + handler.externalSignPublicKeyFile = externalSignPublicKeyFileField.getText(); + handler.externallySignedHashFile = externalSignedHashFileField.getText(); + handler.outputSignedEnclaveFile = outputSignedEnclaveFileField.getText(); + + super.okPressed(); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Two Step Enclave Sign - Generate Signed Enclave"); + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/UpdateSignKeyDialog.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/UpdateSignKeyDialog.java new file mode 100644 index 0000000000..502fb2dcfa --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/UpdateSignKeyDialog.java @@ -0,0 +1,191 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.dialogs; + +import java.io.File; + +import javax.swing.JOptionPane; + +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import com.intel.sgx.handlers.UpdateSigningKey; + +public class UpdateSignKeyDialog extends SGXDialogBase { + + private Shell shell; + public Text sourceKeyFileField; + public Text destinationKeyFileField; + public static boolean regenerate = false; + + private final SelectionListener destinationKeyFileSelectionListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = destinationKeyFileField.getText(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + dialog.setFilterExtensions(new String [] {"*.pem", "*"}); + result = dialog.open(); + destinationKeyFileField.setText(result); + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }; + + private final SelectionListener sourceKeyFileSelectionListener = new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + String result = sourceKeyFileField.getText(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + dialog.setFilterExtensions(new String [] {"*.pem", "*"}); + dialog.setFilterPath(getCurrentProjectPath().toOSString()); + result = dialog.open(); + sourceKeyFileField.setText(result); + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }; + final private UpdateSigningKey handler; + + public UpdateSignKeyDialog(Shell parentShell, UpdateSigningKey handler) { + super(parentShell); + this.shell = parentShell; + this.handler = handler; + setShellStyle(SWT.RESIZE | SWT.TITLE); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = new GridLayout(1,false); + composite.setLayout(gridLayout); + + destinationKeyFileField = addGroup(composite, "Enclave Signing Key:", + "Select the Signing Key to be Updated or Generated.", + "Enclave Signing Key:", "Select", destinationKeyFileSelectionListener); + + sourceKeyFileField = addGroup(composite, "Import:", + "To import your own Signing Key use the Import Signing Key option.", + "Import Signing Key:", "Import Key", sourceKeyFileSelectionListener); + + addGroup2(composite); + + return composite; + } + + protected void addGroup2(Composite composite) { + final Group container2 = new Group(composite, SWT.None); + container2.setLayout(new GridLayout(3,false)); + GridData innergrid2 = new GridData(GridData.FILL_HORIZONTAL); + innergrid2.horizontalSpan = 3; + container2.setLayoutData(innergrid2); + container2.setText("Generate:"); + + final Label messageLabel3 = new Label(container2, SWT.NONE); + messageLabel3.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1)); + messageLabel3.setText("To Generate a new Signing Key use the Generate Signing Key option."); + + Label warningLabel2 = new Label(container2,SWT.FILL | SWT.WRAP); + warningLabel2.setText("Generate a new Signing Key:"); + warningLabel2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Label dummy2 = new Label(container2,0); + dummy2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + final Button updateSigningKey = new Button(container2, SWT.PUSH); + updateSigningKey.setText("Generate Key"); + GridData buttonGridData2 = new GridData(GridData.END); + buttonGridData2.horizontalAlignment = SWT.RIGHT; + buttonGridData2.horizontalSpan = 1; + buttonGridData2.minimumWidth = 120; + updateSigningKey.setLayoutData(buttonGridData2); + updateSigningKey.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent event) { + if( !destinationKeyFileField.getText().isEmpty()) + { + regenerate = true; + UpdateSignKeyDialog.this.setReturnCode(InputDialog.OK); + okPressed(); + UpdateSignKeyDialog.this.close(); + } + else + JOptionPane.showMessageDialog(null, "Enclave Signing Key field is not provided.", "Error", + JOptionPane.ERROR_MESSAGE); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Import or (Re)Generate Enclave Signing Key"); + } + + @Override + protected void okPressed() { + + handler.sourceKeyFile = sourceKeyFileField.getText(); + handler.destinationKeyFile = destinationKeyFileField.getText(); + if((!sourceKeyFileField.getText().isEmpty() && !destinationKeyFileField.getText().isEmpty() && + (new File(sourceKeyFileField.getText())).isFile()) + || regenerate == true ) + { + System.out.println("regenerate = " + regenerate); + super.okPressed(); + } + else + { + if(sourceKeyFileField.getText().isEmpty() && destinationKeyFileField.getText().isEmpty()) + JOptionPane.showMessageDialog(null, "Enclave Signing Key and Import Singing Key are not provided.", "Error", + JOptionPane.ERROR_MESSAGE); + else + { + if(sourceKeyFileField.getText().isEmpty()) + JOptionPane.showMessageDialog(null, "Import Singing Key is not provided.", "Error", + JOptionPane.ERROR_MESSAGE); + else + if(!(new File(sourceKeyFileField.getText())).isFile()) + JOptionPane.showMessageDialog(null, "Invalid Import Singing Key.", "Error", + JOptionPane.ERROR_MESSAGE); + + if(destinationKeyFileField.getText().isEmpty()) + JOptionPane.showMessageDialog(null, "Enclave Signing Key is not provided.", "Error", + JOptionPane.ERROR_MESSAGE); + } + } + + } + + + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveredPathInfo.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveredPathInfo.java new file mode 100644 index 0000000000..2c48b2fb39 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveredPathInfo.java @@ -0,0 +1,202 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.discovery; + +import java.util.List; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; +import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; + +import com.intel.sgx.Activator; +/* + * This code has been taken from the NDK plugin for Linux. If there is an update to this code there, then refactor this code. + */ +public class SGXSDKDiscoveredPathInfo implements IDiscoveredPathInfo { + + private final IProject mProject; + private long mLastUpdate = IFile.NULL_STAMP; + private IPath[] mIncludePaths; + private Map mSymbols; + private boolean mNeedReindexing = false; + private static final IPath LINUX_MK = new Path("sgx/Makefile"); + + //Keys for preferences + // public static final String LAST_UPDATE = "lastUpdate"; //$NON-NLS-1$ + + + public SGXSDKDiscoveredPathInfo(IProject project) { + this.mProject = project; + load(); + } + + @Override + public IProject getProject() { + return mProject; + } + + @Override + public IPath[] getIncludePaths() { + if (mNeedReindexing) { + CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(mProject)); + mNeedReindexing = false; + } + return mIncludePaths; + } + + void setIncludePaths(List pathStrings) { + mIncludePaths = new IPath[pathStrings.size()]; + int i = 0; + for (String path : pathStrings) + mIncludePaths[i++] = new Path(path); + mNeedReindexing = true; + } + + @Override + public Map getSymbols() { + if (mSymbols == null) + mSymbols = new HashMap(); + return mSymbols; + } + + void setSymbols(Map symbols) { + this.mSymbols = symbols; + } + + @Override + public IDiscoveredScannerInfoSerializable getSerializable() { + return null; + } + + public void update(IProgressMonitor monitor) throws CoreException { + if (!needUpdating()) + return; + + new SGXSDKDiscoveryUpdater(this).runUpdate(monitor); + + if (mIncludePaths != null && mSymbols != null) { + recordUpdate(); + save(); + } + } + + private boolean needUpdating() { + + + if (mLastUpdate == IFile.NULL_STAMP) { + return true; + } + + return mProject.getFile(LINUX_MK).getLocalTimeStamp() > mLastUpdate; + } + + private void recordUpdate() { + mLastUpdate = mProject.getFile(LINUX_MK).getLocalTimeStamp(); + } + + public void delete() { + mLastUpdate = IFile.NULL_STAMP; + } + + private File getInfoFile() { + File stateLoc = Activator.getDefault().getStateLocation().toFile(); + return new File(stateLoc, mProject.getName() + ".pathInfo"); //$NON-NLS-1$ + } + + private void save() { + try { + File infoFile = getInfoFile(); + infoFile.getParentFile().mkdirs(); + PrintStream out = new PrintStream(infoFile); + + out.print("t,"); //$NON-NLS-1$ + out.print(mLastUpdate); + out.println(); + + for (IPath include : mIncludePaths) { + out.print("i,"); //$NON-NLS-1$ + out.print(include.toPortableString()); + out.println(); + } + + for (Entry symbol : mSymbols.entrySet()) { + out.print("d,"); //$NON-NLS-1$ + out.print(symbol.getKey()); + out.print(","); //$NON-NLS-1$ + out.print(symbol.getValue()); + out.println(); + } + + out.close(); + } catch (IOException e) { + Activator.log(e); + } + + } + + private void load() { + try { + File infoFile = getInfoFile(); + if (!infoFile.exists()) + return; + + long timestamp = IFile.NULL_STAMP; + List includes = new ArrayList(); + Map defines = new HashMap(); + + BufferedReader reader = new BufferedReader(new FileReader(infoFile)); + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + switch (line.charAt(0)) { + case 't': + timestamp = Long.valueOf(line.substring(2)); + break; + case 'i': + includes.add(Path.fromPortableString(line.substring(2))); + break; + case 'd': + int n = line.indexOf(',', 2); + if (n == -1) + defines.put(line.substring(2), ""); //$NON-NLS-1$ + else + defines.put(line.substring(2, n), line.substring(n + 1)); + break; + } + } + reader.close(); + + mLastUpdate = timestamp; + mIncludePaths = includes.toArray(new IPath[includes.size()]); + mSymbols = defines; + } catch (IOException e) { + Activator.log(e); + } + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveryUpdater.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveryUpdater.java new file mode 100644 index 0000000000..4c10fccdcc --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveryUpdater.java @@ -0,0 +1,310 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.discovery; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.managedbuilder.core.IBuilder; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; + +import com.intel.sgx.Activator; +import com.intel.sgx.build.SGXSDKCommandLauncher; + +/* + * This code has been taken from the NDK plugin for Linux. If there is an update to this code there, then refactor this code. + */ +public class SGXSDKDiscoveryUpdater { + private final SGXSDKDiscoveredPathInfo mPathInfo; + private final IProject mProject; + + private boolean mCPlusPlus = false; + private String mCommand; + private List mArguments = new ArrayList(); + + public SGXSDKDiscoveryUpdater(SGXSDKDiscoveredPathInfo pathInfo) { + mPathInfo = pathInfo; + mProject = pathInfo.getProject(); + } + + public void runUpdate(IProgressMonitor monitor) throws CoreException { + try { + // Run make -nB to get the list of commands + IPath commandPath = new Path("make"); //$NON-NLS-1$ + String[] args = {"-f", "sgx/Makefile", "-n", "-B" }; //$NON-NLS-1$ + String[] env = calcEnvironment(); + File projectDir = new File(mProject.getLocationURI()); + IPath changeToDirectory = new Path(projectDir.getAbsolutePath()); + Process proc = new SGXSDKCommandLauncher().execute(commandPath, args, env,changeToDirectory, monitor); + if (proc == null) { + return; + } + + BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); + String line = reader.readLine(); + while (line != null) { + checkBuildLine(line); + line = reader.readLine(); + } + + if (mCommand == null) { + return; + } + + // Run the unique commands with special gcc options to extract the + // symbols and paths + // -E -P -v -dD + mArguments.add("-E"); //$NON-NLS-1$ + mArguments.add("-P"); //$NON-NLS-1$ + mArguments.add("-v"); //$NON-NLS-1$ + mArguments.add("-dD"); //$NON-NLS-1$ + + URL url = Activator.findFile(new Path("discovery/" + (mCPlusPlus ? "test.cpp" : "test.c"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + File testFile = new File(FileLocator.toFileURL(url).toURI()); + String testFileName = testFile.getAbsolutePath().replace('\\', '/'); + mArguments.add(testFileName); + + args = mArguments.toArray(new String[mArguments.size()]); + proc = new SGXSDKCommandLauncher().execute(new Path(mCommand), args, env,changeToDirectory, monitor); + + final InputStream errStream = proc.getErrorStream(); + new Thread() { + @Override + public void run() { + checkIncludes(errStream); + }; + }.start(); + + checkDefines(proc.getInputStream()); + } catch (IOException e) { + throw new CoreException(Activator.newStatus(e)); + } catch (URISyntaxException e) { + throw new CoreException(Activator.newStatus(e)); + } + } + + private String[] calcEnvironment() throws CoreException { + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(mProject); + IBuilder builder = info.getDefaultConfiguration().getBuilder(); + HashMap envMap = new HashMap(); + if (builder.appendEnvironment()) { + ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(builder.getParent().getParent()); + IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); + IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true); + for (IEnvironmentVariable var : vars) { + envMap.put(var.getName(), var.getValue()); + } + } + // Add variables from build info + Map builderEnv = builder.getExpandedEnvironment(); + if (builderEnv != null) + envMap.putAll(builderEnv); + List strings = new ArrayList(envMap.size()); + for (Entry entry : envMap.entrySet()) { + StringBuffer buffer = new StringBuffer(entry.getKey()); + buffer.append('=').append(entry.getValue()); + strings.add(buffer.toString()); + } + return strings.toArray(new String[strings.size()]); + } + + private static class Line { + private final String line; + private int pos; + + public Line(String line) { + this.line = line; + } + + public Line(String line, int pos) { + this(line); + this.pos = pos; + } + + public String getToken() { + skipWhiteSpace(); + if (pos == line.length()) + return null; + + int start = pos; + boolean inQuote = false; + + while (true) { + char c = line.charAt(pos); + if (c == ' ') { + if (!inQuote) + return line.substring(start, pos); + } else if (c == '"') { + inQuote = !inQuote; + } + + if (++pos == line.length()) + return null; + } + + } + + private String getRemaining() { + if (pos == line.length()) + return null; + + skipWhiteSpace(); + String rc = line.substring(pos); + pos = line.length(); + return rc; + } + + private void skipWhiteSpace() { + while (true) { + if (pos == line.length()) + return; + char c = line.charAt(pos); + if (c == ' ') + pos++; + else + return; + } + } + } + + private void checkBuildLine(String text) { + Line line = new Line(text); + String cmd = line.getToken(); + if (cmd == null) { + return; + } else if (cmd.endsWith("g++")) { //$NON-NLS-1$ + if (mCommand == null || !mCPlusPlus) { + mCommand = cmd; + mCPlusPlus = true; + } + gatherOptions(line); + } else if (cmd.endsWith("gcc")) { //$NON-NLS-1$ + if (mCommand == null){ + mCommand = cmd; + } + gatherOptions(line); + } + + } + + private void gatherOptions(Line line) { + for (String option = line.getToken(); option != null; option = line.getToken()) { + if (option.startsWith("-")) { //$NON-NLS-1$ + // only look at options + if (option.equals("-I")) { //$NON-NLS-1$ + String dir = line.getToken(); + if (dir != null) + addArg(option + dir); + } else if (option.startsWith("-I")) { //$NON-NLS-1$ + addArg(option); + } else if (option.equals("-D")) { //$NON-NLS-1$ + String def = line.getToken(); + if (def != null) + addArg(option + def); + } else if (option.startsWith("-D")) { //$NON-NLS-1$ + addArg(option); + } else if (option.startsWith("-f")) { //$NON-NLS-1$ + addArg(option); + } else if (option.startsWith("-m")) { //$NON-NLS-1$ + addArg(option); + } else if (option.startsWith("--sysroot")) { //$NON-NLS-1$ + addArg(option); + } + } + } + } + + private void addArg(String arg) { + if (!mArguments.contains(arg)) + mArguments.add(arg); + } + + private void checkIncludes(InputStream in) { + try { + List includes = new ArrayList(); + boolean inIncludes1 = false; + boolean inIncludes2 = false; + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + String line = reader.readLine(); + while (line != null) { + if (!inIncludes1) { + if (line.equals("#include \"...\" search starts here:")) //$NON-NLS-1$ + inIncludes1 = true; + } else { + if (!inIncludes2) { + if (line.equals("#include <...> search starts here:")) //$NON-NLS-1$ + inIncludes2 = true; + else + includes.add(line.trim()); + } else { + if (line.equals("End of search list.")) { //$NON-NLS-1$ + mPathInfo.setIncludePaths(includes); + } else { + includes.add(line.trim()); + } + } + } + line = reader.readLine(); + } + } catch (IOException e) { + Activator.log(e); + } + } + + private void checkDefines(InputStream in) { + try { + Map defines = new HashMap(); + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + String line = reader.readLine(); + while (line != null) { + if (line.startsWith("#define")) { //$NON-NLS-1$ + Line l = new Line(line, 7); + String var = l.getToken(); + if (var == null) + continue; + String value = l.getRemaining(); + if (value == null) + value = ""; //$NON-NLS-1$ + defines.put(var, value); + } + line = reader.readLine(); + } + mPathInfo.setSymbols(defines); + } catch (IOException e) { + Activator.log(e); + } + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKScannerInfoCollector.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKScannerInfoCollector.java new file mode 100644 index 0000000000..fb21bff5cf --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKScannerInfoCollector.java @@ -0,0 +1,103 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.discovery; + +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3; +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner; +import org.eclipse.cdt.make.core.scannerconfig.InfoContext; +import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; +import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +/* + * This code has been taken from the NDK plugin for Linux. If there is an update to this code there, then refactor this code. + */ +public class SGXSDKScannerInfoCollector implements IScannerInfoCollector3,IScannerInfoCollectorCleaner,IManagedScannerInfoCollector{ + + private SGXSDKDiscoveredPathInfo sgxPathInfo; + + @Override + public void setProject(IProject project) { + throw new Error("Not implemented"); + } + + @Override + public void updateScannerConfiguration(IProgressMonitor monitor) + throws CoreException { + sgxPathInfo.update(monitor); + } + + @Override + public IDiscoveredPathInfo createPathInfoObject() { + return sgxPathInfo; + } + + @Override + public void contributeToScannerConfig(Object resource, @SuppressWarnings("rawtypes") Map scannerInfo) { + throw new Error("Not implemented"); + } + + @SuppressWarnings("rawtypes") + @Override + public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { + throw new Error("Not implemented"); + } + + @Override + public Map getDefinedSymbols() { + throw new Error("Not implemented"); + } + + @Override + public List getIncludePaths() { + throw new Error("Not implemented"); + } + + @Override + public void deleteAllPaths(IResource resource) { + throw new Error("Not implemented"); + } + + @Override + public void deleteAllSymbols(IResource resource) { + throw new Error("Not implemented"); + } + + @Override + public void deletePath(IResource resource, String path) { + throw new Error("Not implemented"); + } + + @Override + public void deleteSymbol(IResource resource, String symbol) { + throw new Error("Not implemented"); + } + + @Override + public void deleteAll(IResource resource) { + sgxPathInfo.delete(); + } + + @Override + public void setInfoContext(InfoContext context) { + sgxPathInfo = new SGXSDKDiscoveredPathInfo(context.getProject()); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddEnclave.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddEnclave.java new file mode 100644 index 0000000000..e998de690b --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddEnclave.java @@ -0,0 +1,213 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Map; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.TemplateEngine; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.intel.sgx.Activator; +import com.intel.sgx.dialogs.AddEnclaveFileDialog; +import com.intel.sgx.preferences.PreferenceConstants; + +public class AddEnclave extends ModuleCreationBaseHandler implements IHandler { + + public String edlFilename = ""; + public String linuxMakePath = ""; + @Override + public void addHandlerListener(IHandlerListener handlerListener) { + } + + @Override + public void dispose() { + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + String edlBasename,linuxPath,enclaveBasename; + IProject project = null; + + // Display display = Display.getCurrent(); + // Shell shell = new Shell(display); + Shell shell = null; + AddEnclaveFileDialog dialog = new AddEnclaveFileDialog(shell, this); + if (dialog.open() != InputDialog.OK) { + return null; + } + + if((edlFilename.isEmpty())){ + System.err.println("No Enclave selected to Import."); + return null; + } + + edlBasename = edlFilename; + ISelection selection = HandlerUtil.getCurrentSelection(event); + Object element = null; + if (selection instanceof IStructuredSelection) { + element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IResource) { + project = ((IResource) element).getProject(); + } + } + if (!project.exists()) { + System.err.println("Error: Project not found"); + return null; + } + + for (IConfigurationElement i : Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.core.resources.projectNature")){ + } + + + + + IPath linuxMkRelPath = (Path.fromOSString(linuxMakePath)).makeRelativeTo(project.getLocation().append("sgx").append("enclave_"+edlBasename)); + + + if(linuxMkRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("sgx")){ + linuxPath = linuxMkRelPath.removeLastSegments(3).toOSString(); + enclaveBasename = linuxMkRelPath.removeLastSegments(2).lastSegment().toString(); + } + + else{ + linuxPath = linuxMkRelPath.removeLastSegments(2).toOSString(); + enclaveBasename = linuxMkRelPath.removeLastSegments(1).lastSegment().toString(); + } + + IProgressMonitor monitor = new NullProgressMonitor(); + TemplateCore template = null; + if(isCPProject(project)) + if(dialog.generateApp()) + { + template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveC++WithSample"); + } + else + { + template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveC++Minimal"); + } + else + if(dialog.generateApp()) + { + template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveCWithSample"); + } + else + { + template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveCMinimal"); + } + + Map valueStore = template.getValueStore(); + valueStore.put("projectName", project.getName()); + valueStore.put("workspacePath", linuxPath); + valueStore.put("baseName", enclaveBasename); + valueStore.put("enclaveName",edlFilename); + valueStore.put("EnclaveName",capitalize(edlFilename)); + valueStore.put("ENCLAVENAME",edlFilename.toUpperCase()); + valueStore.put("SdkPathFromPlugin", Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH)); + + IStatus[] statuses = template.executeTemplateProcesses(monitor, false); + for(IStatus e: statuses) + { + } + + ManagedBuildManager.saveBuildInfo(project, true); + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + Activator.log(e); + e.printStackTrace(); + } + + + return null; + } + + private String capitalize(final String line) { + return Character.toUpperCase(line.charAt(0)) + line.substring(1); + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public boolean isHandled() { + return true; + } + + @Override + public void removeHandlerListener(IHandlerListener handlerListener) { + } + + public void setFilename(String filename) { + edlFilename = filename; + } + + + + + public static void copyFile(File source, File dest) throws IOException { + byte[] bytes = new byte[4092]; + if (source != null && dest != null) { + if (source.isFile()) { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(source); + out = new FileOutputStream(dest); + int len; + while ((len = in.read(bytes)) != -1) { + out.write(bytes, 0, len); + } + } catch (Exception e) { + Activator.log(e); + System.err.println("Error: " + e.toString()); + } finally { + try { + if (in != null) + in.close(); + } finally { + if (out != null) + out.close(); + } + } + } + } + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddSGXNature.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddSGXNature.java new file mode 100644 index 0000000000..569b608adb --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddSGXNature.java @@ -0,0 +1,163 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.TemplateEngine; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +//import org.eclipse.core.resources.IWorkspaceRunnable; +//import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +//import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.intel.sgx.Activator; +import com.intel.sgx.natures.SGXNature; + +public class AddSGXNature implements IHandler { + + private IProject project; + + public AddSGXNature() { + project = null; + } + + @Override + public void addHandlerListener(IHandlerListener arg0) { + } + + @Override + public void dispose() { + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection selection = HandlerUtil.getCurrentSelection(event); + Object element = null; + if (selection instanceof IStructuredSelection) { + element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IResource) { + project = ((IResource) element).getProject(); + } + } + if (!project.exists()) { + System.err.println("Error: Project not found"); + return null; + } else { + try { + TemplateCore template = TemplateEngine.getDefault().getTemplateById("AddSGXNature"); + + Map valueStore = template.getValueStore(); + valueStore.put("projectName",project.getName()); + valueStore.put("baseName",project.getName()); + + IProgressMonitor monitor = new NullProgressMonitor(); + template.executeTemplateProcesses(monitor, false); + + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + try{ + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + + String[] newNatures = new String[natures.length + 1]; + System.arraycopy(natures, 0, newNatures, 0, natures.length); + newNatures[natures.length] = SGXNature.NATURE_ID; + IStatus status = workspace.validateNatureSet(newNatures); + + if (status.getCode() == IStatus.OK) { + description.setNatureIds(newNatures); + project.setDescription(description, null); + } + + project.refreshLocal(IResource.DEPTH_ONE,null); + } catch(CoreException e){ + Activator.log(e); + throw new InvocationTargetException(e); + } + } catch(InvocationTargetException e){ + Activator.log(e); + e.printStackTrace(); + } + + try { + project.refreshLocal(IResource.DEPTH_INFINITE,null); + } catch (CoreException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public boolean isHandled() { + return true; + } + + @Override + public void removeHandlerListener(IHandlerListener arg0) { + } + + public static void copyFile(File source, File dest) throws IOException { + byte[] bytes = new byte[4092]; + if (source != null && dest != null) { + if (source.isFile()) { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(source); + out = new FileOutputStream(dest); + int len; + while ((len = in.read(bytes)) != -1) { + out.write(bytes, 0, len); + } + } catch (Exception e) { + System.err.println("Error: " + e.toString()); + + } finally { + try { + if (in != null) + in.close(); + } finally { + if (out != null) + out.close(); + } + } + } + } + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddTrustedStaticLib.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddTrustedStaticLib.java new file mode 100644 index 0000000000..efeeeedd3a --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddTrustedStaticLib.java @@ -0,0 +1,193 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Map; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.TemplateEngine; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.intel.sgx.Activator; +import com.intel.sgx.dialogs.AddTrustedStaticLibFileDialog; +import com.intel.sgx.preferences.PreferenceConstants; + +public class AddTrustedStaticLib extends ModuleCreationBaseHandler implements IHandler { + + public String edlFilename = ""; + public String linuxMakePath = ""; + + @Override + public void addHandlerListener(IHandlerListener handlerListener) { + } + + @Override + public void dispose() { + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + String edlBasename,linuxPath,enclaveBasename; + IProject project = null; + + // Display display = Display.getCurrent(); + // Shell shell = new Shell(display); + Shell shell = null; + AddTrustedStaticLibFileDialog dialog = new AddTrustedStaticLibFileDialog(shell, this); + if (dialog.open() != InputDialog.OK) { + return null; + } + + if((edlFilename.isEmpty() )){ + System.err.println("No Enclave selected to Import."); + return null; + } + + edlBasename = edlFilename; + ISelection selection = HandlerUtil.getCurrentSelection(event); + Object element = null; + if (selection instanceof IStructuredSelection) { + element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IResource) { + project = ((IResource) element).getProject(); + } + } + if (!project.exists()) { + System.err.println("Error: Project not found"); + return null; + } + + for (IConfigurationElement i : Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.core.resources.projectNature")){ + } + + + + + IPath linuxMkRelPath = (Path.fromOSString(linuxMakePath)).makeRelativeTo(project.getLocation().append("sgx").append("enclave_"+edlBasename)); + + + if(linuxMkRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("sgx")){ + linuxPath = linuxMkRelPath.removeLastSegments(3).toOSString(); + enclaveBasename = linuxMkRelPath.removeLastSegments(2).lastSegment().toString(); + } + + else{ + linuxPath = linuxMkRelPath.removeLastSegments(2).toOSString(); + enclaveBasename = linuxMkRelPath.removeLastSegments(1).lastSegment().toString(); + } + + IProgressMonitor monitor = new NullProgressMonitor(); + TemplateCore template = null; + if(isCPProject(project)) + template = TemplateEngine.getDefault().getTemplateById("SGXTrustedStaticLibraryC++Minimal"); + else + template = TemplateEngine.getDefault().getTemplateById("SGXTrustedStaticLibraryCMinimal"); + + Map valueStore = template.getValueStore(); + valueStore.put("projectName", project.getName()); + valueStore.put("workspacePath", linuxPath); + valueStore.put("baseName", enclaveBasename); + valueStore.put("enclaveName",edlFilename); + valueStore.put("EnclaveName",capitalize(edlFilename)); + valueStore.put("ENCLAVENAME",edlFilename.toUpperCase()); + valueStore.put("SdkPathFromPlugin", Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH)); + + IStatus[] statuses = template.executeTemplateProcesses(monitor, false); + + + ManagedBuildManager.saveBuildInfo(project, true); + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + Activator.log(e); + e.printStackTrace(); + } + return null; + } + + private String capitalize(final String line) { + return Character.toUpperCase(line.charAt(0)) + line.substring(1); + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public boolean isHandled() { + return true; + } + + @Override + public void removeHandlerListener(IHandlerListener handlerListener) { + } + + public void setFilename(String filename) { + edlFilename = filename; + } + + public static void copyFile(File source, File dest) throws IOException { + byte[] bytes = new byte[4092]; + if (source != null && dest != null) { + if (source.isFile()) { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(source); + out = new FileOutputStream(dest); + int len; + while ((len = in.read(bytes)) != -1) { + out.write(bytes, 0, len); + } + } catch (Exception e) { + Activator.log(e); + System.err.println("Error: " + e.toString()); + } finally { + try { + if (in != null) + in.close(); + } finally { + if (out != null) + out.close(); + } + } + } + } + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddUntrustedModule.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddUntrustedModule.java new file mode 100644 index 0000000000..4ebf8da34c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddUntrustedModule.java @@ -0,0 +1,231 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Map; + + + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.TemplateEngine; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; + +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.intel.sgx.Activator; +import com.intel.sgx.dialogs.AddUntrustedModuleDialog; +import com.intel.sgx.preferences.PreferenceConstants; + +public class AddUntrustedModule extends ModuleCreationBaseHandler implements IHandler { + + public String edlFilename = ""; + public String libPath = ""; + private IPath edlCanonicalFilename; + private IPath libCanonicalPathname; + + @Override + public void addHandlerListener(IHandlerListener handlerListener) { + } + + @Override + public void dispose() { + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + String edlBasename,edlPath,linuxLibPath,modulePath,enclaveBasename; + IProject project = null; + + //Display display = Display.getCurrent(); + Shell shell = null; + + AddUntrustedModuleDialog dialog = new AddUntrustedModuleDialog(shell, this); + if (dialog.open() != InputDialog.OK) { + return null; + } + + if((edlFilename.isEmpty() && libPath.isEmpty())){ + System.err.println("No Enclave selected to Import."); + return null; + } + if( edlFilename.isEmpty() ){ + System.err.println("Edl File not selected."); + return null; + } + edlCanonicalFilename = Path.fromOSString(edlFilename); + if (!edlCanonicalFilename.getFileExtension().toLowerCase().equals("edl")) { + System.err.println("Error: EDL file extension = "+ edlCanonicalFilename.getFileExtension()); + return null; + } + edlBasename = edlCanonicalFilename.removeFileExtension().lastSegment(); + + + ISelection selection = HandlerUtil.getCurrentSelection(event); + Object element = null; + if (selection instanceof IStructuredSelection) { + element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IResource) { + project = ((IResource) element).getProject(); + } + } + if (!project.exists()) { + System.err.println("Error: Project not found"); + return null; + } + + IPath targetRelPath = project.getProjectRelativePath().append("sgx").append("untrusted_" + edlBasename); + + try { + for (int i = 1; i <= targetRelPath.segmentCount(); i++) { + IFolder subfolder = project.getFolder(targetRelPath.uptoSegment(i)); + + if (!subfolder.exists()) { + subfolder.create(true, true, null); + } + } + } catch (CoreException e) { + System.err.println("Error: Error creating enclave directory."); + Activator.log(e); + e.printStackTrace(); + } + + IPath edlRelPath = (Path.fromOSString(edlFilename)).makeRelativeTo(project.getLocation().append("sgx")); + edlPath = edlRelPath.toOSString(); + IPath linuxLibRelPath = (Path.fromOSString(libPath)).makeRelativeTo(project.getLocation().append("sgx")); + + if(linuxLibRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("sgx")){ + linuxLibPath = linuxLibRelPath.removeLastSegments(3).toOSString(); + modulePath = linuxLibRelPath.removeFirstSegments(linuxLibRelPath.segmentCount()-3).removeLastSegments(1).toOSString(); + } + else if(linuxLibRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("src")){ + linuxLibPath = linuxLibRelPath.removeLastSegments(3).toOSString(); + modulePath = linuxLibRelPath.removeFirstSegments(linuxLibRelPath.segmentCount()-3).removeLastSegments(1).toOSString(); + } + else{ + linuxLibPath = linuxLibRelPath.removeLastSegments(2).toOSString(); + modulePath = linuxLibRelPath.removeFirstSegments(linuxLibRelPath.segmentCount()-2).removeLastSegments(1).toOSString(); + } + + IProgressMonitor monitor = new NullProgressMonitor(); + TemplateCore template = null; + if(isCPProject(project)) + template = TemplateEngine.getDefault().getTemplateById("SGXUntrustedModuleC++Minimal"); + else + template = TemplateEngine.getDefault().getTemplateById("SGXUntrustedModuleCMinimal"); + + + + Map valueStore = template.getValueStore(); + + + valueStore.put("projectName", project.getName()); + valueStore.put("sourcepath",linuxLibPath); + valueStore.put("edlPath", edlPath); + valueStore.put("baseName", edlBasename); + valueStore.put("workspacePath", linuxLibPath);//deprecate + valueStore.put("modPath", modulePath); + valueStore.put("ENCLAVENAME",edlBasename.toUpperCase()); + valueStore.put("libPath",libPath); + valueStore.put("SdkPathFromPlugin", Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH)); + + IStatus[] statuses = template.executeTemplateProcesses(monitor, false); + + try { + copyFile(new File(edlFilename), project.getLocation().append("sgx").append("untrusted_"+edlBasename).append(edlBasename+".edl").toFile()); + } catch (IOException e1) { + e1.printStackTrace(); + } + + + ManagedBuildManager.saveBuildInfo(project, true); + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + Activator.log(e); + e.printStackTrace(); + } + return null; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public boolean isHandled() { + return true; + } + + @Override + public void removeHandlerListener(IHandlerListener handlerListener) { + } + + public void setFilename(String filename) { + edlFilename = filename; + } + + public static void copyFile(File source, File dest) throws IOException { + byte[] bytes = new byte[4092]; + if (source != null && dest != null) { + if (source.isFile()) { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(source); + out = new FileOutputStream(dest); + int len; + while ((len = in.read(bytes)) != -1) { + out.write(bytes, 0, len); + } + } catch (Exception e) { + Activator.log(e); + System.err.println("Error: " + e.toString()); + } finally { + try { + if (in != null) + in.close(); + } finally { + if (out != null) + out.close(); + } + } + } + } + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/EnclaveConfigHandler.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/EnclaveConfigHandler.java new file mode 100644 index 0000000000..fffa912c4f --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/EnclaveConfigHandler.java @@ -0,0 +1,156 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.TemplateEngine; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import com.intel.sgx.Activator; +import com.intel.sgx.dialogs.EnclaveConfigDialog; +import com.intel.sgx.dialogs.SGXDialogBase; + +public class EnclaveConfigHandler extends SGXHandler { + + public String prodId; + public String isvSvn; + public String threadStackSize; + public String globalHeapSize; + public String tcsNum; + public String tcsPolicy; + public String disableDebug; + private IFile configPath; + + @Override + public void addHandlerListener(IHandlerListener arg0) { + } + + @Override + public void dispose() { + } + + @Override + public Object executeSGXStuff() throws CancelException, ErrorException { + + FilteredResourcesSelectionDialog d = SGXDialogBase + .dialogForConfig(shell); + d.setTitle("Select Config File"); + if (d.open() != Dialog.OK) { + cancel(); + } + + configPath = ((IFile) d.getResult()[0]); + + readConfig(configPath.getLocation()); + EnclaveConfigDialog dialog = new EnclaveConfigDialog(shell, this); + if (dialog.open() != InputDialog.OK) { + return null; + } + writeConfig(); + refreshProject(); + + return null; + } + + protected void writeConfig() { + IProgressMonitor monitor = new NullProgressMonitor(); + TemplateCore template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveConfig"); + + Map valueStore = template.getValueStore(); + valueStore.put("projectName", project.getName()); + valueStore.put("configFile", configPath.getProjectRelativePath().toOSString()); + valueStore.put("ProdID", this.prodId); + valueStore.put("IsvSvn", this.isvSvn); + valueStore.put("ThreadStackSize", this.threadStackSize); + valueStore.put("GlobalHeapSize", this.globalHeapSize); + valueStore.put("TcsNumber", this.tcsNum); + valueStore.put("TcsPolicy", this.tcsPolicy); + valueStore.put("DisableDebug", this.disableDebug); + IStatus[] result = template.executeTemplateProcesses(monitor, true); + + for (IStatus status: result) { + } + } + + + + protected void readConfig(IPath configPath) throws ErrorException { + + try { + String xmlFile = configPath.toString(); + File configFile = new File(xmlFile); + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder; + dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(configFile); + doc.getDocumentElement().normalize(); + + NodeList nList = doc.getElementsByTagName("EnclaveConfiguration"); + Node nNode = nList.item(0); + + if (nNode.getNodeType() == Node.ELEMENT_NODE) { + Element e = (Element) nNode; + this.prodId = e.getElementsByTagName("ProdID").item(0) + .getTextContent(); + this.isvSvn = e.getElementsByTagName("ISVSVN").item(0) + .getTextContent(); + this.threadStackSize = e.getElementsByTagName("StackMaxSize") + .item(0).getTextContent(); + this.globalHeapSize = e.getElementsByTagName("HeapMaxSize") + .item(0).getTextContent(); + this.tcsNum = e.getElementsByTagName("TCSNum").item(0) + .getTextContent(); + this.tcsPolicy = e.getElementsByTagName("TCSPolicy").item(0) + .getTextContent(); + this.disableDebug = e.getElementsByTagName("DisableDebug") + .item(0).getTextContent(); + } + + } catch (ParserConfigurationException e) { + Activator.log(e); + e.printStackTrace(); + quitWithError("Could not parse '"+configPath.toOSString()+"'"); + } catch (SAXException e) { + Activator.log(e); + e.printStackTrace(); + quitWithError("Could not parse '"+configPath.toOSString()+"'"); + } catch (IOException e) { + Activator.log(e); + e.printStackTrace(); + quitWithError("Could not read'"+configPath.toOSString()+"'"); + } + + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/ModuleCreationBaseHandler.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/ModuleCreationBaseHandler.java new file mode 100644 index 0000000000..708208c6cb --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/ModuleCreationBaseHandler.java @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.runtime.CoreException; + +public class ModuleCreationBaseHandler { + public boolean isCPProject(IProject project) + { + boolean isCPProject = false; + IProjectDescription description; + try { + description = project.getDescription(); + String[] natures = description.getNatureIds(); + for(String nature: natures){ + if(nature.equals("org.eclipse.cdt.core.ccnature")) + isCPProject = true; + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return isCPProject; + + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/RemoveEnclave.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/RemoveEnclave.java new file mode 100644 index 0000000000..058e622996 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/RemoveEnclave.java @@ -0,0 +1,169 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.intel.sgx.Activator; +import com.intel.sgx.dialogs.RemoveEnclaveFileDialog; + +public class RemoveEnclave implements IHandler { + + public String edlFilename = ""; + private IPath edlCanonicalFilename; + + @Override + public void addHandlerListener(IHandlerListener handlerListener) { + } + + @Override + public void dispose() { + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + String edlBasename; + IProject project = null; + + // Display display = Display.getCurrent(); + // Shell shell = new Shell(display); + + RemoveEnclaveFileDialog dialog = new RemoveEnclaveFileDialog(null, this); + + if (dialog.open() != InputDialog.OK) { + return null; + } + + edlCanonicalFilename = Path.fromOSString(edlFilename); + edlBasename = edlCanonicalFilename.lastSegment(); + + if(edlBasename.isEmpty()){ + return null; + } + + ISelection selection = HandlerUtil.getCurrentSelection(event); + Object element = null; + if(selection instanceof IStructuredSelection) { + element = ((IStructuredSelection)selection).getFirstElement(); + if (element instanceof IResource) { + project= ((IResource)element).getProject(); + } + } + if (!project.exists()) { + System.err.println("Error: Project not found"); + return null; + } + + IPath targetRelPath = project.getProjectRelativePath().append("sgx").append("enclave_" + edlBasename); + + try { + for (int i=1;i<=targetRelPath.segmentCount();i++) { + IFolder subfolder = project.getFolder(targetRelPath.uptoSegment(i)); + + if (subfolder.exists()){ + if(subfolder.getProjectRelativePath().toOSString().contains("enclave_"+edlBasename)){ + subfolder.delete(true, true, null); + break; + } + } + } + targetRelPath = project.getProjectRelativePath().append("sgx").append(edlBasename); + for (int i=1;i<=targetRelPath.segmentCount();i++) { + IFolder subfolder = project.getFolder(targetRelPath.uptoSegment(i)); + + if (subfolder.exists()){ + if(subfolder.getProjectRelativePath().toOSString().contains(edlBasename)){ + subfolder.delete(true, true, null); + break; + } + } + } + } catch (Exception e) { + Activator.log(e); + } + + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + Activator.log(e); + } catch (IllegalArgumentException e){ + Activator.log(e); + } + + return null; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public boolean isHandled() { + return true; + } + + @Override + public void removeHandlerListener(IHandlerListener handlerListener) { + } + + public static void copyFile(File source, File dest) throws IOException { + byte[] bytes = new byte[4092]; + if (source != null && dest != null) { + if (source.isFile()) { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(source); + out = new FileOutputStream(dest); + int len; + while ((len = in.read(bytes)) != -1) { + out.write(bytes, 0, len); + } + } catch (Exception e) { + System.err.println("Error: " + e.toString()); + Activator.log(e); + } finally { + try { + if (in != null) + in.close(); + } finally { + if (out != null) + out.close(); + } + } + } + } + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXHandler.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXHandler.java new file mode 100644 index 0000000000..bfd5bcb551 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXHandler.java @@ -0,0 +1,206 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.swing.JOptionPane; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * Utility base class for all Handlers The derived classes must implement + * executeSgxStuff() instead of execute(). The user may call methods cancel(), + * quitWithError() & info() + * + * @author mlutescu + * + */ +public abstract class SGXHandler implements IHandler { + + public String projectPath = null; + protected IProject project; + protected Shell shell; + + /** + * Throwing this IS an error. Means that the process can't continue + * + * @author mlutescu + * + */ + static protected class ErrorException extends Exception { + + public ErrorException(String message) { + super(message); + } + + } + + /** + * Throwing this is not an error; just signals stop of execution because the + * user cancels + * + * @author mlutescu + * + */ + static protected class CancelException extends Exception { + + public CancelException() { + super(); + } + + } + + @Override + public final Object execute(ExecutionEvent event) throws ExecutionException { + try { + initializeShell(); + initializeProject(event); + return executeSGXStuff(); + } catch (ErrorException e) { + e.printStackTrace(); + } catch (CancelException e) { + // do nothing by design ; it's Ok to not handle this exception. + } + return null; + } + + protected abstract Object executeSGXStuff() throws ErrorException, + CancelException; + + public SGXHandler() { + super(); + } + + public static void copyFile(File source, File dest) throws ErrorException { + byte[] bytes = new byte[4092]; + if (source != null && dest != null) { + if (source.isFile()) { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(source); + out = new FileOutputStream(dest); + int len; + while ((len = in.read(bytes)) != -1) { + out.write(bytes, 0, len); + } + } catch (IOException e) { + System.err.println("Error: " + e.toString()); + quitWithError("Could not copy from\n" + "'" + + source.getAbsolutePath() + "'\n" + "to\n" + "'" + + dest.getAbsolutePath()); + } finally { + try { + if (in != null) { + in.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } + } + } + + protected static void quitWithError(String message) throws ErrorException { + JOptionPane.showMessageDialog(null, message, "Two Step Enclave Sign", + JOptionPane.ERROR_MESSAGE); + throw new ErrorException(message); + } + + static protected void cancel() throws CancelException { + throw new CancelException(); + } + + protected void initializeProject(ExecutionEvent event) + throws ErrorException { + project = null; + ISelection selection = HandlerUtil.getCurrentSelection(event); + Object element = null; + if (selection instanceof IStructuredSelection) { + element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IResource) { + project = ((IResource) element).getProject(); + } + } + + if (!project.exists()) { + quitWithError("Project not found"); + } + + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public boolean isHandled() { + return true; + } + + @Override + public void removeHandlerListener(IHandlerListener arg0) { + } + + @Override + public void addHandlerListener(IHandlerListener arg0) { + } + + @Override + public void dispose() { + } + + protected void initializeShell() { + shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + } + + protected void refreshProject() throws ErrorException { + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e1) { + quitWithError(e1.getLocalizedMessage()); + } + } + + protected void info(String windowName, String message) { + JOptionPane.showMessageDialog(null, message,windowName, + JOptionPane.INFORMATION_MESSAGE); + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXSDKWizardHandler.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXSDKWizardHandler.java new file mode 100644 index 0000000000..b445c5ea8a --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXSDKWizardHandler.java @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import org.eclipse.cdt.managedbuilder.core.IToolChain; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.ui.wizards.STDWizardHandler; + +public class SGXSDKWizardHandler extends STDWizardHandler { + + public SGXSDKWizardHandler() { + super(null, null); + } + + + @Override + public IToolChain[] getSelectedToolChains() { + IToolChain[] tcs = ManagedBuildManager.getRealToolChains(); + for (IToolChain tc : tcs) { + if (tc.getId().equals("com.intel.sgx.SGXtoolChain")) + return new IToolChain[] { + tc + }; + } + return super.getSelectedToolChains(); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignHandlerBase.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignHandlerBase.java new file mode 100644 index 0000000000..59ae2eb7a4 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignHandlerBase.java @@ -0,0 +1,196 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; + +import com.intel.sgx.preferences.PreferenceConstants; + +public abstract class TwoStepSignHandlerBase extends SGXHandler { + + public String hashFile = null; + public String configFile = null; + public String enclaveFile = null; + public String externalSignPublicKeyFile = null; + public String externallySignedHashFile = null; + public String outputSignedEnclaveFile = null; + + protected File signtool; + + public TwoStepSignHandlerBase() { + super(); + } + + protected void executeGenData() throws ErrorException { + validateConfigFile(); + validateEnclaveFile(); + + refreshProject(); + executeSignTool(new String[] { "gendata", + "-enclave", enclaveFile, + "-config", configFile, + "-out", hashFile }); + refreshProject(); + + validateHashFile(); + + } + + protected void executeCatSig() throws ErrorException { + validateEnclaveFile(); + validateConfigFile(); + validateHashFile(); + + validateExternalSignPublicKeyFile(); + validateExternallySignedHashFile(); + + executeSignTool("catsig", + // enclave data: + "-enclave", enclaveFile, + "-config", configFile, + // previously generated: + "-unsigned", hashFile, + // externally generated + "-key", externalSignPublicKeyFile, + "-sig", externallySignedHashFile, + // output + "-out", outputSignedEnclaveFile + + ); + + refreshProject(); + + validateOutputSignedEnclaveFile(); + + info("Two Step Enclave Sign","Enclave signed successfully !"); + } + + void initializeSigntool() throws ErrorException { + signtool = PreferenceConstants.getSDKDescriptor().getSignerPath(); + if (!signtool.exists() || signtool.isDirectory()) { + quitWithError("Error generating hash! Sign Tool Not Found !\n Please make sure to have written in the box the value for SGX SDK Directory in Window->Preferences->SGX Preferences. \n Usually the path is in /opt/intel/sgxsdk/" ); + } + + } + + protected void validateEnclaveFile() throws ErrorException { + File enclave = new File(enclaveFile); + if (!enclave.exists() || enclave.isDirectory()) { + quitWithError("Error generating hash! Unsigned Enclave File Not Found! Try building the enclave first"); + } + } + + protected void validateConfigFile() throws ErrorException { + if (configFile == null || configFile.isEmpty()) { + quitWithError("Error Enclave Configuration File Not Found !"); + } + File config = new File(configFile); + if (!config.exists() || config.isDirectory()) { + quitWithError("Enclave Config File Not Found !"); + } + } + + protected void validateExternallySignedHashFile() throws ErrorException { + if (externallySignedHashFile == null || externallySignedHashFile.isEmpty()) { + quitWithError("Error signing enclave! Signature File Not Found !"); + } + + File signature = new File(externallySignedHashFile); + if (!signature.exists() || signature.isDirectory()) { + quitWithError("Error signing enclave! Signature File Not Found !"); + } + } + + protected void validateExternalSignPublicKeyFile() throws ErrorException { + if (externalSignPublicKeyFile == null || externalSignPublicKeyFile.isEmpty()) { + quitWithError("Public Key File Not Found !"); + } + + File publickkey = new File(externalSignPublicKeyFile); + if (!publickkey.exists() || publickkey.isDirectory()) { + quitWithError("Error signing enclave! Public Key File Not Found !"); + } + } + + private void validateOutputSignedEnclaveFile() throws ErrorException { + if(outputSignedEnclaveFile == null || outputSignedEnclaveFile.isEmpty()) + { + quitWithError("Output Signed File Not Found !"); + } + File outputSignedEnclave = new File(outputSignedEnclaveFile); + if(!outputSignedEnclave.exists() || outputSignedEnclave.isDirectory()) + { + quitWithError("Output Signed File Not Found !"); + } + + // TODO Auto-generated method stub + + } + + protected void validateHashFile() throws ErrorException { + if(hashFile == null || hashFile.isEmpty()) + { + quitWithError("Hash File Not Found !"); + } + File hash = new File(hashFile); + if(!hash.exists() || hash.isDirectory()) + { + quitWithError("Hash File Not Found !"); + } + } + + + protected void executeSignTool(String... args) throws ErrorException { + + Process q; + try { + + String[] allArgs = new String[args.length+1]; + allArgs[0] = signtool.getAbsolutePath(); + System.arraycopy(args, 0, allArgs, 1, args.length); + + for (String arg : args){ + } + String fullOutput = ""; + q = Runtime.getRuntime().exec(allArgs); + + BufferedReader stdInput = new BufferedReader(new InputStreamReader( + q.getInputStream())); + BufferedReader stdErr = new BufferedReader(new InputStreamReader( + q.getErrorStream())); + String s = null; + while ((s = stdInput.readLine()) != null) { + } + String[] out = new String[20]; + int i = 0; + while ((out[i] = stdErr.readLine()) != null) { + fullOutput += out[i]+"\n"; + i++; + } + String result = out[i - 1]; + + if (!result.equals("Succeed.")) { + // quitWithError("Error generating hash! " + out[i - 2]); + quitWithError("Error generating hash! " + fullOutput); + } + } catch (IOException e) { + quitWithError(e.getLocalizedMessage()); + } + + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep1.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep1.java new file mode 100644 index 0000000000..cb2f3649bd --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep1.java @@ -0,0 +1,74 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import org.eclipse.jface.dialogs.InputDialog; + +import com.intel.sgx.dialogs.SGXDialogBase; +import com.intel.sgx.dialogs.TwoStepSignStep1Dialog1; +import com.intel.sgx.dialogs.TwoStepSignStep1Dialog2; +import com.intel.sgx.dialogs.TwoStepSignStep1Dialog3; + +// Generate Hash +public class TwoStepSignStep1 extends TwoStepSignHandlerBase { + + public TwoStepSignStep1() { + } + + @Override + protected Object executeSGXStuff() throws ErrorException, CancelException { + + initializeSigntool(); + + showDialog1(); + showDialog2(); + showDialog3(); + return null; + } + + private void showDialog1() throws CancelException, ErrorException { + + TwoStepSignStep1Dialog1 dialog1 = new TwoStepSignStep1Dialog1(shell, this); + if (dialog1.open() != InputDialog.OK) { + cancel(); + } + + executeGenData(); + + } + + private void showDialog2() throws CancelException { + TwoStepSignStep1Dialog2 dialog2 = new TwoStepSignStep1Dialog2(shell, + hashFile); + + if (dialog2.open() != InputDialog.OK) { + cancel(); + } + } + + protected void showDialog3() throws CancelException, ErrorException { + SGXDialogBase dialog3 = new TwoStepSignStep1Dialog3(shell, this); + if (dialog3.open() != InputDialog.OK) { + cancel(); + } + + validateExternalSignPublicKeyFile(); + + validateExternallySignedHashFile(); + + executeCatSig(); + + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep2.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep2.java new file mode 100644 index 0000000000..f19738036c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep2.java @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import org.eclipse.jface.dialogs.InputDialog; + +import com.intel.sgx.dialogs.TwoStepSignStep2Dialog; + +// Sign +public class TwoStepSignStep2 extends TwoStepSignHandlerBase { + + public TwoStepSignStep2() { + } + + @Override + protected Object executeSGXStuff() throws ErrorException, CancelException { + initializeSigntool(); + + TwoStepSignStep2Dialog dialog = new TwoStepSignStep2Dialog(shell, this); + if(dialog.open() != InputDialog.OK) { + cancel(); + } + + executeCatSig(); + return null; + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/UpdateSigningKey.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/UpdateSigningKey.java new file mode 100644 index 0000000000..68870ea3cf --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/UpdateSigningKey.java @@ -0,0 +1,101 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.handlers; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +//import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +//import java.security.KeyPair; +//import java.security.KeyPairGenerator; +//import java.security.NoSuchAlgorithmException; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.commands.IHandlerListener; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; + +//import org.bouncycastle.openssl.PEMWriter; +import com.intel.sgx.Activator; +import com.intel.sgx.dialogs.UpdateSignKeyDialog; + +public class UpdateSigningKey extends SGXHandler { + + public String sourceKeyFile = null; + public String destinationKeyFile = null; + public String projectPath = null; + + @Override + protected Object executeSGXStuff() throws ErrorException, CancelException { + + UpdateSignKeyDialog dialog = new UpdateSignKeyDialog(shell, this); + int result = dialog.open(); + if (result != InputDialog.OK) { + cancel(); + } + + if(UpdateSignKeyDialog.regenerate == false) + { + IPath sourceFile = Path.fromOSString(sourceKeyFile); + IPath destFile = Path.fromOSString(destinationKeyFile); + copyFile(sourceFile.toFile(), destFile.toFile()); + refreshProject(); + info("Update SGX Enclave Signing Key","copied \n'" + sourceKeyFile + "' into \n'" + destFile + "'"); + } else { + UpdateSignKeyDialog.regenerate = false; + try { + Process q; + String opensslCmd = "openssl genrsa -out " + destinationKeyFile + + " -3 3072"; + q = Runtime.getRuntime().exec(opensslCmd); + BufferedReader stdInput = new BufferedReader( + new InputStreamReader(q.getInputStream())); + BufferedReader stdErr = new BufferedReader( + new InputStreamReader(q.getErrorStream())); + String s = null; + while ((s = stdInput.readLine()) != null) { + } + while ((s = stdErr.readLine()) != null) { + } + project.refreshLocal(IResource.DEPTH_INFINITE, null); + if (q.exitValue() == 0){ + info("Update SGX Enclave Signing Key","'"+destinationKeyFile+"'"+" was generated!"); + } else { + quitWithError("Could not generate '"+destinationKeyFile+"'!!!"); + } + } catch (IOException e) { + Activator.log(e); + e.printStackTrace(); + } catch (CoreException e) { + Activator.log(e); + e.printStackTrace(); + } + } + return null; + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/about.html b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/about.html new file mode 100644 index 0000000000..a3b9ace448 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/about.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + +About + + +

About This Content

+ +

June 22, 2007

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/messages.properties b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/messages.properties new file mode 100644 index 0000000000..c0011fadda --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/messages.properties @@ -0,0 +1,16 @@ +######################################################################### +# Copyright (c) 2016 Intel Corporation. # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Eclipse Public License v1.0 # +# which accompanies this distribution, and is available at # +# http://www.eclipse.org/legal/epl-v10.html # +# # +# Contributors: # +# Intel Corporation - initial implementation and documentation # +######################################################################### + + +CreateNativeFolders_No_folders=No folders. +CreateNativeFolders_Missing_project_name=Missing project Name. +CreateNativeFolders_Project_does_not_exist=Project does not exist. diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXCCNature.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXCCNature.java new file mode 100644 index 0000000000..fde7f7d29c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXCCNature.java @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.natures; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; + +public class SGXCCNature implements IProjectNature { + + private IProject project; + public static final String NATURE_ID = "com.intel.sgx.sgxccnature"; + + public SGXCCNature() { + } + + @Override + public void configure() throws CoreException { + } + + @Override + public void deconfigure() throws CoreException { + } + + @Override + public IProject getProject() { + return project; + } + + @Override + public void setProject(IProject project) { + this.project = project; + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXNature.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXNature.java new file mode 100644 index 0000000000..8db687e029 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXNature.java @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.natures; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; + +public class SGXNature implements IProjectNature { + + private IProject project; + public static final String NATURE_ID = "com.intel.sgx.sgxnature"; + + public SGXNature() { + } + + @Override + public void configure() throws CoreException { + } + + @Override + public void deconfigure() throws CoreException { + } + + @Override + public IProject getProject() { + return project; + } + + @Override + public void setProject(IProject project) { + this.project = project; + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXStaticCCNature.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXStaticCCNature.java new file mode 100644 index 0000000000..0d642ee5c8 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/natures/SGXStaticCCNature.java @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.natures; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; + +public class SGXStaticCCNature implements IProjectNature { + + private IProject project; + public static final String NATURE_ID = "com.intel.sgx.sgxstaticccnature"; + + public SGXStaticCCNature() { + } + + @Override + public void configure() throws CoreException { + } + + @Override + public void deconfigure() throws CoreException { + } + + @Override + public IProject getProject() { + return project; + } + + @Override + public void setProject(IProject project) { + this.project = project; + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/ISDKDescriptor.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/ISDKDescriptor.java new file mode 100644 index 0000000000..ec8b274912 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/ISDKDescriptor.java @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.preferences; + +import java.io.File; + + +public interface ISDKDescriptor { + + public abstract File getSdkDir(); + + public abstract File getToolsDir(); + + public abstract File getSignerPath(); + + public abstract File getEdger8rPath(); + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/PreferenceConstants.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/PreferenceConstants.java new file mode 100644 index 0000000000..5ce1abc9cc --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/PreferenceConstants.java @@ -0,0 +1,112 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.preferences; + +import java.io.File; + +import org.eclipse.jface.preference.IPreferenceStore; + +import com.intel.sgx.Activator; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String SDK_PATH = "SDKPathPreference"; + + public static ISDKDescriptor getSDKDescriptor() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + File sdkDir = new File(store.getString(PreferenceConstants.SDK_PATH)); + + if (System.getProperty("os.arch").contains("64")) { + return new SGXSDK64Descriptor(sdkDir); + } else { + return new SGXSDK32Descriptor(sdkDir); + } + } + + + static public class SGXSDK32Descriptor implements ISDKDescriptor { + private final File sdkDir; + private final File toolDir; + private final File signerPath; + private final File edger8rPath; + + public SGXSDK32Descriptor(File location){ + this.sdkDir = location; + this.toolDir = new File(location, "bin/x86"); + this.signerPath = new File(toolDir, "sgx_sign"); + this.edger8rPath = new File(toolDir, "sgx_edger8r"); + } + + @Override + public File getSdkDir() { + return sdkDir; + } + + @Override + public File getToolsDir() { + return toolDir; + } + + @Override + public File getSignerPath() { + return signerPath; + } + + @Override + public File getEdger8rPath() { + return edger8rPath; + } + + } + + + static public class SGXSDK64Descriptor implements ISDKDescriptor { + private final File sdkDir; + private final File toolDir; + private final File signerPath; + private final File edger8rPath; + + public SGXSDK64Descriptor(File sdkDir){ + this.sdkDir = sdkDir; + this.toolDir = new File(sdkDir, "bin/x64"); + this.signerPath = new File(toolDir, "sgx_sign"); + this.edger8rPath = new File(toolDir, "sgx_edger8r"); + } + + @Override + public File getSdkDir() { + return sdkDir; + } + + @Override + public File getToolsDir() { + return toolDir; + } + + @Override + public File getSignerPath() { + return signerPath; + } + + @Override + public File getEdger8rPath() { + return edger8rPath; + } + + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/PreferenceInitializer.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/PreferenceInitializer.java new file mode 100644 index 0000000000..b85d5e5299 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/PreferenceInitializer.java @@ -0,0 +1,32 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.preferences; + +import com.intel.sgx.Activator; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.SDK_PATH, ""); + Activator.getDefault().getPreferenceStore().setValue(PreferenceConstants.SDK_PATH, "/opt/intel/sgxsdk"); + Activator.getDefault().getPreferenceStore().setDefault(PreferenceConstants.SDK_PATH, "/opt/intel/sgxsdk"); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/SGXPreferencePage.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/SGXPreferencePage.java new file mode 100644 index 0000000000..bbf6608a71 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/preferences/SGXPreferencePage.java @@ -0,0 +1,110 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.preferences; + +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import com.intel.sgx.Activator; +import com.intel.sgx.SdkPathVariableProvider; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

+ * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class SGXPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + private SGXSdkDirectoryFieldEditor sgxSdkDirectoryEditor; + + public SGXPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("SGX Preferences"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + + @Override + protected void createFieldEditors() { + sgxSdkDirectoryEditor = new SGXSdkDirectoryFieldEditor(PreferenceConstants.SDK_PATH, + "&SGX SDK Directory:", getFieldEditorParent()); + addField(sgxSdkDirectoryEditor); + } + + /* + * Validates whether the path entered in the SGX SDK Preferences points to the SGX SDK or not. + */ + private static class SGXSdkDirectoryFieldEditor extends DirectoryFieldEditor { + public SGXSdkDirectoryFieldEditor(String name, String labelText, Composite parent) { + super(name, labelText, parent); + setEmptyStringAllowed(true); + } + + @Override + protected boolean doCheckState() { + if (!super.doCheckState()) { + setErrorMessage("SGX Preferences: Not a Valid directory"); + return false; + } + + String dirname = getTextControl().getText().trim(); + if (!dirname.isEmpty() && !SdkPathVariableProvider.isValidSGXSdkLocation(dirname)) { + setErrorMessage("SGX SDK: Not a Valid SGX SDK directory"); + return false; + } + return true; + } + + @Override + public Text getTextControl(Composite parent) { + setValidateStrategy(VALIDATE_ON_KEY_STROKE); + return super.getTextControl(parent); + } + } + + @Override + public void init(IWorkbench workbench) { + } + + @Override + public void dispose() { + super.dispose(); + + if (sgxSdkDirectoryEditor != null) { + sgxSdkDirectoryEditor.dispose(); + sgxSdkDirectoryEditor = null; + } + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/CreateNativeFolders.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/CreateNativeFolders.java new file mode 100644 index 0000000000..d493e146fe --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/CreateNativeFolders.java @@ -0,0 +1,230 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.templates; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.core.settings.model.CIncludePathEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICFolderDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSetting; +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.process.ProcessArgument; +import org.eclipse.cdt.core.templateengine.process.ProcessFailureException; +import org.eclipse.cdt.core.templateengine.process.ProcessRunner; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.internal.core.Configuration; +import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; + +import com.intel.sgx.Activator; +import com.intel.sgx.Messages; +import com.intel.sgx.preferences.PreferenceConstants; + +@SuppressWarnings("restriction") +public class CreateNativeFolders extends ProcessRunner { + + @Override + public void process(TemplateCore template, ProcessArgument[] args, + String processId, IProgressMonitor monitor) + throws ProcessFailureException { + String projectName = null; + String[] sourceFolders = null; + String[] outputFolders = null; + + for (ProcessArgument arg : args) { + String argName = arg.getName(); + if (argName.equals("projectName")) { + projectName = arg.getSimpleValue(); + } else if (argName.equals("sourceFolders")) { + sourceFolders = arg.getSimpleArrayValue(); + } else if (argName.equals("outputFolders")) { + outputFolders = arg.getSimpleArrayValue(); + } + } + + if (projectName == null) + throw new ProcessFailureException( + Messages.CreateNativeFolders_Missing_project_name); + + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + if (!project.exists()) + throw new ProcessFailureException( + Messages.CreateNativeFolders_Project_does_not_exist); + + if (sourceFolders == null && outputFolders == null) + throw new ProcessFailureException( + Messages.CreateNativeFolders_No_folders); + + try { + ICProject cproject = CCorePlugin.getDefault().getCoreModel() + .create(project); + IPathEntry[] pathEntries = cproject.getRawPathEntries(); + List newEntries = new ArrayList( + pathEntries.length); + for (IPathEntry pathEntry : pathEntries) { + if (pathEntry.getEntryKind() != IPathEntry.CDT_SOURCE + && pathEntry.getEntryKind() != IPathEntry.CDT_OUTPUT) { + newEntries.add(pathEntry); + } + } + if (sourceFolders != null) + for (String sourceFolder : sourceFolders) { + IFolder folder = project.getFolder(new Path(sourceFolder)); + if (!folder.exists()) + folder.create(true, true, monitor); + newEntries.add(CoreModel.newSourceEntry(folder + .getFullPath())); + } + if (outputFolders != null) + for (String outputFolder : outputFolders) { + IFolder folder = project.getFolder(new Path(outputFolder)); + if (!folder.exists()) + folder.create(true, true, monitor); + newEntries.add(CoreModel.newOutputEntry(folder + .getFullPath())); + } + cproject.setRawPathEntries( + newEntries.toArray(new IPathEntry[newEntries.size()]), + monitor); + + // IConfiguration[] configs = managedProject.getConfigurations(); + // for(IConfiguration conf:configs){ + // managedProject.removeConfiguration(conf.getId()); + + // } + + IConfiguration conSimDebug = ManagedBuildManager + .getExtensionConfiguration("com.intel.sgx.configuration.Sim.Debug"); + IConfiguration conSimRelease = ManagedBuildManager + .getExtensionConfiguration("com.intel.sgx.configuration.Sim.Release"); + IConfiguration conHwDebug = ManagedBuildManager + .getExtensionConfiguration("com.intel.sgx.configuration.HW.Debug"); + IConfiguration conHwPrerelease = ManagedBuildManager + .getExtensionConfiguration("com.intel.sgx.configuration.HW.Prerelease"); + IConfiguration conHwRelease = ManagedBuildManager + .getExtensionConfiguration("com.intel.sgx.configuration.HW.Release"); + + addConfigurationToProject(project, conSimDebug); + addConfigurationToProject(project, conSimRelease); + addConfigurationToProject(project, conHwDebug); + addConfigurationToProject(project, conHwPrerelease); + addConfigurationToProject(project, conHwRelease); + + + changeProjectConfiguration(project, conSimDebug); + + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + throw new ProcessFailureException(e); + } + } + + void addConfigurationToProject(IProject project, IConfiguration config) { + createConfiguration(project, config); + addSGXIncludePathsToConfiguration(project, config); + } + + private void addSGXIncludePathsToConfiguration(IProject project, + IConfiguration config) { + ICProjectDescription projectDescription = CoreModel.getDefault() + .getProjectDescription(project, true); + ICConfigurationDescription configDecriptions[] = projectDescription + .getConfigurations(); + for (ICConfigurationDescription configDescription : configDecriptions) { + ICFolderDescription projectRoot = configDescription + .getRootFolderDescription(); + + ICLanguageSetting[] settings = projectRoot.getLanguageSettings(); + for (ICLanguageSetting setting : settings) { + + if (!"org.eclipse.cdt.core.gcc".equals(setting.getLanguageId()) && !"org.eclipse.cdt.core.g++".equals(setting.getLanguageId()) ) { + continue; + } + List includes = new ArrayList(); + + includes.add(new CIncludePathEntry( Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH) + + "/include/", + ICSettingEntry.LOCAL)); + + setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, includes); + } + } + try { + CoreModel.getDefault().setProjectDescription(project, + projectDescription); + } catch (CoreException e) { + e.printStackTrace(); + } + + } + + private void createConfiguration(IProject project, + IConfiguration config) { + ManagedProject managedProject = (ManagedProject) ManagedBuildManager.getBuildInfo(project) + .getManagedProject();; + + + Configuration cloneConfig1 = (Configuration) config; + Configuration cfg1 = new Configuration(managedProject, cloneConfig1, + cloneConfig1.getId(), false, false); + String target = cfg1.getArtifactName(); + if (target == null || target.length() == 0) + cfg1.setArtifactName(managedProject.getDefaultArtifactName()); + + cfg1.exportArtifactInfo(); + + ManagedBuildManager.saveBuildInfo(project, true); + } + + private void changeProjectConfiguration(IProject project, + IConfiguration conSimDebug) { + ICProjectDescription prjd = CCorePlugin.getDefault() + .getProjectDescriptionManager().getProjectDescription(project); + ICConfigurationDescription[] configs = prjd.getConfigurations(); + if (configs != null && configs.length > 0) { + for (ICConfigurationDescription config : configs) { + if (config.getConfiguration().getId() + .equals(conSimDebug.getId())) { + config.setActive(); + try { + CoreModel.getDefault().setProjectDescription(project, + prjd); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + break; + } + } + } + + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/SetCCNature.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/SetCCNature.java new file mode 100644 index 0000000000..e85476b288 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/SetCCNature.java @@ -0,0 +1,77 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.templates; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.process.ProcessArgument; +import org.eclipse.cdt.core.templateengine.process.ProcessFailureException; +import org.eclipse.cdt.core.templateengine.process.ProcessRunner; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; + +import com.intel.sgx.Activator; +import com.intel.sgx.natures.SGXNature; + +public class SetCCNature extends ProcessRunner { + + public SetCCNature() { + } + + @Override + public void process(TemplateCore template, ProcessArgument[] args, + String processId, IProgressMonitor monitor) + throws ProcessFailureException { + String projectName = null; + IProject project = null; + + for(ProcessArgument arg: args){ + String argName = arg.getName(); + if(argName.equals("projectName")){ + projectName = arg.getSimpleValue(); + } + } + + + project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + IWorkspace workspace = project.getWorkspace(); + IProjectDescription description; + try { + description = project.getDescription(); + + String[] natures = description.getNatureIds(); + String[] newNatures = new String[natures.length+1]; + System.arraycopy(natures,0,newNatures,0,natures.length); + newNatures[natures.length] = SGXNature.NATURE_ID; + IStatus status = workspace.validateNatureSet(newNatures); + + if(status.getCode() == IStatus.OK) + { + + description.setNatureIds(newNatures); + project.setDescription(description, null); + } + else { + System.err.println("Incorrect Project Nature. Please check Project Settings."); + } + } catch (CoreException e) { + Activator.log(e); + e.printStackTrace(); + } + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/SetStaticCCNature.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/SetStaticCCNature.java new file mode 100644 index 0000000000..449a575262 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/templates/SetStaticCCNature.java @@ -0,0 +1,75 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.templates; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.process.ProcessArgument; +import org.eclipse.cdt.core.templateengine.process.ProcessFailureException; +import org.eclipse.cdt.core.templateengine.process.ProcessRunner; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; + +import com.intel.sgx.Activator; +import com.intel.sgx.natures.SGXStaticCCNature; + +public class SetStaticCCNature extends ProcessRunner { + + public SetStaticCCNature() { + } + + @Override + public void process(TemplateCore template, ProcessArgument[] args, + String processId, IProgressMonitor monitor) + throws ProcessFailureException { + + String projectName = null; + IProject project = null; + + for(ProcessArgument arg: args){ + String argName = arg.getName(); + if(argName.equals("projectName")){ + projectName = arg.getSimpleValue(); + } + } + + project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + IWorkspace workspace = project.getWorkspace(); + IProjectDescription description; + try { + description = project.getDescription(); + + String[] natures = description.getNatureIds(); + String[] newNatures = new String[natures.length+1]; + System.arraycopy(natures,0,newNatures,0,natures.length); + newNatures[natures.length] = SGXStaticCCNature.NATURE_ID; + IStatus status = workspace.validateNatureSet(newNatures); + + if(status.getCode() == IStatus.OK) + { + description.setNatureIds(newNatures); + project.setDescription(description, null); + } + else + System.err.println("Incorrect Project Nature. Please check Project Settings."); + } catch (CoreException e) { + Activator.log(e); + e.printStackTrace(); + } + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/testers/SGXPropertyTester.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/testers/SGXPropertyTester.java new file mode 100644 index 0000000000..1b876c79c6 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/testers/SGXPropertyTester.java @@ -0,0 +1,79 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.testers; + +import java.util.regex.Pattern; + +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.viewers.StructuredSelection; + +public class SGXPropertyTester extends PropertyTester { + + private static final Pattern isRelease = Pattern.compile(".*Release.*"); + private static final Pattern isHW = Pattern.compile(".*Hardware.*"); + private static final Pattern isPreRelease = Pattern.compile(".*Prerelease.*");; + + public SGXPropertyTester() { + super(); + + // TODO Auto-generated constructor stub + } + + @Override + public boolean test(Object receiver, String property, Object[] args, + Object expectedValue) { + + + + + + if (property.equals("twoStepsActive")) { + IProject project = getProjectOfSelectedItem(receiver); + IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project); + return isHW(buildInfo) && isRelease(buildInfo) && !isPreRelease(buildInfo); + + } else if (property.equals("sgxNatureAdded")) { + IProject project = getProjectOfSelectedItem(receiver); + return true; + } else { + return false; + } + } + + private IProject getProjectOfSelectedItem(Object receiver) { + StructuredSelection selection = (StructuredSelection) receiver; + IResource resource = (IResource) selection.getFirstElement(); + IProject project = resource.getProject(); + return project; + } + + boolean isHW(IManagedBuildInfo buildInfo){ + return isHW.matcher(buildInfo.getConfigurationName()).matches(); + } + + + + boolean isRelease(IManagedBuildInfo buildInfo){ + return isRelease.matcher(buildInfo.getConfigurationName()).matches(); + } + + boolean isPreRelease(IManagedBuildInfo buildInfo){ + return isPreRelease.matcher(buildInfo.getConfigurationName()).matches(); + } + +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/wizards/SGXCCProjectWizard.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/wizards/SGXCCProjectWizard.java new file mode 100644 index 0000000000..be6ec1e51b --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/wizards/SGXCCProjectWizard.java @@ -0,0 +1,145 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.wizards; + +import java.net.URI; +import java.util.Map; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.TemplateEngine; +import org.eclipse.cdt.ui.wizards.CCProjectWizard; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; + +import com.intel.sgx.natures.SGXNature; + +public class SGXCCProjectWizard extends CCProjectWizard { + + private IProject project; + + @Override + protected boolean setCreated() throws CoreException { + boolean result = super.setCreated(); + doIt(project, new NullProgressMonitor()); + return result; + } + + @Override + public boolean performFinish() { + + return super.performFinish(); + } + + @Override + public void setInitializationData(IConfigurationElement config, + String propertyName, Object data) throws CoreException { + // TODO Auto-generated method stub + super.setInitializationData(config, propertyName, data); + } + + @Override + public IProject createIProject(String name, URI location) + throws CoreException { + // TODO Auto-generated method stub + return super.createIProject(name, location); + + } + + @Override + public IProject createIProject(String name, URI location, + IProgressMonitor monitor) throws CoreException { + project = super.createIProject(name, location, monitor); + return project; + } + + @Override + public String[] getExtensions() { + // TODO Auto-generated method stub + return super.getExtensions(); + } + + public SGXCCProjectWizard() { + // TODO Auto-generated constructor stub + } + + @Override + public String[] getNatures() { + // TODO Auto-generated method stub + return super.getNatures(); + } + + @Override + protected IProject continueCreation(IProject prj) { + // TODO Auto-generated method stub + return super.continueCreation(prj); + } + + @Override + public String[] getContentTypeIDs() { + // TODO Auto-generated method stub + return super.getContentTypeIDs(); + } + + @Override + public IProject getProject(boolean defaults) { + // TODO Auto-generated method stub + return super.getProject(defaults); + } + + @Override + public String[] getLanguageIDs() { + // TODO Auto-generated method stub + return super.getLanguageIDs(); + } + + void doIt(IProject project, IProgressMonitor monitor) throws CoreException { + TemplateCore template = TemplateEngine.getDefault().getTemplateById( + "AddSGXNature"); + Map valueStore = template.getValueStore(); + valueStore.put("projectName", project.getName()); + valueStore.put("baseName", project.getName()); + template.executeTemplateProcesses(monitor, false); + + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + + String[] newNatures = new String[natures.length + 1]; + System.arraycopy(natures, 0, newNatures, 0, natures.length); + newNatures[natures.length] = SGXNature.NATURE_ID; + IStatus status = workspace.validateNatureSet(newNatures); + + if (status.getCode() == IStatus.OK) { + description.setNatureIds(newNatures); + project.setDescription(description, null); + } else { + System.err + .println("Incorrect Project Nature. Please check Project Settings.");// TODO + // throw + // an + // exception + // here. + System.err.println("Status is: " + status.getCode()); + } + + // project.refreshLocal(IResource.DEPTH_ONE,null); + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/wizards/SGXCProjectWizard.java b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/wizards/SGXCProjectWizard.java new file mode 100644 index 0000000000..14ec8f8284 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/wizards/SGXCProjectWizard.java @@ -0,0 +1,146 @@ +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016 Intel Corporation. // +// // +// All rights reserved. This program and the accompanying materials // +// are made available under the terms of the Eclipse Public License v1.0 // +// which accompanies this distribution, and is available at // +// http://www.eclipse.org/legal/epl-v10.html // +// // +// Contributors: // +// Intel Corporation - initial implementation and documentation // +/////////////////////////////////////////////////////////////////////////// + + +package com.intel.sgx.wizards; + +import java.net.URI; +import java.util.Map; + +import org.eclipse.cdt.core.templateengine.TemplateCore; +import org.eclipse.cdt.core.templateengine.TemplateEngine; +import org.eclipse.cdt.ui.wizards.CProjectWizard; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; + +import com.intel.sgx.natures.SGXNature; + +public class SGXCProjectWizard extends CProjectWizard { + + private IProject project; + + @Override + protected boolean setCreated() throws CoreException { + boolean result = super.setCreated(); + doIt(project, new NullProgressMonitor()); + return result; + } + + @Override + public boolean performFinish() { + + return super.performFinish(); + } + + @Override + public void setInitializationData(IConfigurationElement config, + String propertyName, Object data) throws CoreException { + // TODO Auto-generated method stub + super.setInitializationData(config, propertyName, data); + } + + @Override + public IProject createIProject(String name, URI location) + throws CoreException { + // TODO Auto-generated method stub + return super.createIProject(name, location); + + } + + @Override + public IProject createIProject(String name, URI location, + IProgressMonitor monitor) throws CoreException { + project = super.createIProject(name, location, monitor); + return project; + } + + @Override + public String[] getExtensions() { + // TODO Auto-generated method stub + return super.getExtensions(); + } + + public SGXCProjectWizard() { + // TODO Auto-generated constructor stub + } + + @Override + public String[] getNatures() { + // TODO Auto-generated method stub + return super.getNatures(); + } + + @Override + protected IProject continueCreation(IProject prj) { + // TODO Auto-generated method stub + return super.continueCreation(prj); + } + + @Override + public String[] getContentTypeIDs() { + // TODO Auto-generated method stub + return super.getContentTypeIDs(); + } + + @Override + public IProject getProject(boolean defaults) { + // TODO Auto-generated method stub + return super.getProject(defaults); + } + + @Override + public String[] getLanguageIDs() { + // TODO Auto-generated method stub + return super.getLanguageIDs(); + } + + void doIt(IProject project, IProgressMonitor monitor) throws CoreException { + TemplateCore template = TemplateEngine.getDefault().getTemplateById( + "AddSGXNature"); + Map valueStore = template.getValueStore(); + valueStore.put("projectName", project.getName()); + valueStore.put("baseName", project.getName()); + template.executeTemplateProcesses(monitor, false); + + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + for (String nature : natures) { + } + + String[] newNatures = new String[natures.length + 1]; + System.arraycopy(natures, 0, newNatures, 0, natures.length); + newNatures[natures.length] = SGXNature.NATURE_ID; + IStatus status = workspace.validateNatureSet(newNatures); + + if (status.getCode() == IStatus.OK) { + description.setNatureIds(newNatures); + project.setDescription(description, null); + } else { + System.err + .println("Incorrect Project Nature. Please check Project Settings.");// TODO + // throw + // an + // exception + // here. + System.err.println("Status is: " + status.getCode()); + } + + } +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGX.gif b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGX.gif new file mode 100644 index 0000000000..21156bbf96 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGX.gif differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/enclavetemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/enclavetemplate.xml new file mode 100644 index 0000000000..40d4b6b13a --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/enclavetemplate.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/trustedstatictemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/trustedstatictemplate.xml new file mode 100644 index 0000000000..7b8649b17c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/trustedstatictemplate.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/untrusted_module_template.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/untrusted_module_template.xml new file mode 100644 index 0000000000..537100987e --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/minimal/untrusted_module_template.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/with_sample/enclavetemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/with_sample/enclavetemplate.xml new file mode 100644 index 0000000000..7d9527dafb --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c++/with_sample/enclavetemplate.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/enclavetemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/enclavetemplate.xml new file mode 100644 index 0000000000..c32e20347a --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/enclavetemplate.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/trustedstatictemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/trustedstatictemplate.xml new file mode 100644 index 0000000000..6fc320cbba --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/trustedstatictemplate.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/untrusted_module_template.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/untrusted_module_template.xml new file mode 100644 index 0000000000..b8aec6e666 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/minimal/untrusted_module_template.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/with_sample/enclavetemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/with_sample/enclavetemplate.xml new file mode 100644 index 0000000000..66344d6636 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/c/with_sample/enclavetemplate.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/common/addnaturetemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/common/addnaturetemplate.xml new file mode 100644 index 0000000000..9cf5663e3c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/common/addnaturetemplate.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/configtemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/configtemplate.xml new file mode 100644 index 0000000000..7ce22c45e3 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/configtemplate.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/ctemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/ctemplate.xml new file mode 100644 index 0000000000..ed5cbba697 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/ctemplate.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxstaticlibtemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxstaticlibtemplate.xml new file mode 100644 index 0000000000..8ad900de61 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxstaticlibtemplate.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxtemplate.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxtemplate.xml new file mode 100644 index 0000000000..a07ed1479c --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxtemplate.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/template.properties b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/template.properties new file mode 100644 index 0000000000..9ef4fcdf31 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/template.properties @@ -0,0 +1,63 @@ +######################################################################### +# Copyright (c) 2016 Intel Corporation. # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Eclipse Public License v1.0 # +# which accompanies this distribution, and is available at # +# http://www.eclipse.org/legal/epl-v10.html # +# # +# Contributors: # +# Intel Corporation - initial implementation and documentation # +######################################################################### + SGX.author=Intel + + #Add Nature template Values + SGX.naturetemplate.title.description=A Software Guard Extensions Project template. + SGX.naturetemplate.title.label=SGX Project + SGX.naturetemplate.title.id=AddSGXNature + + #Enclave Config template Values + SGX.enclaveconfig.template.title.description=A Software Guard Extensions Configuration template. + SGX.enclaveconfig.template.title.label=SGX Enclave Configuration + SGX.enclaveconfig.template.title.id=SGXEnclaveConfig + + #Untrusted Module template values + SGX.untrustedModule.template.title.description= A Software Guard Extensions Untrusted Module template. + SGX.untrustedModule.template.title.label=SGX Untrusted Module + + #Enclave template values + SGX.enclave.template.title.description= A Software Guard Extensions Project template. + SGX.enclave.template.title.label=SGX Project + SGX.enclave.template.title.id=SGXProject + + #C template Values + SGX.Ctemplate.title.description=A Software Guard Extensions C Enclave Project template. + SGX.Ctemplate.title.label=SGX C Enclave Project + SGX.Ctemplate.title.id=SGXCProject + SGX.Ctemplate.enclaveSettings.label=Enclave Settings + SGX.Ctemplate.enclaveSettings.description=Initial settings required for a new enclave. + + #C Static lib template Values + SGX.CStatictemplate.title.description=A Software Guard Extensions C Enclave Project template. + SGX.CStatictemplate.title.label=SGX C Enclave Library Project + SGX.CStatictemplate.title.id=SGXCEnclaveLibProject + SGX.CStatictemplate.enclaveSettings.label=Enclave Settings + SGX.CStatictemplate.enclaveSettings.description=Initial settings required for a new enclave Library. + SGX.CStatictemplate.requiresEdl.label=Requires EDL + SGX.CStatictemplate.requiresEdl.description=De-select this option to create an Non-SGX trusted static library without an Edl file. By default, the project creates an Enclave library with an Edl file. + + #CXX template Values + SGX.CXXtemplate.title.description=A Software Guard Extensions C++ Enclave Project template. + SGX.CXXtemplate.title.label=C/C++ Project with SGX Nature + SGX.CXXtemplate.title.id=SGXCPPProject + SGX.CXXtemplate.enclaveSettings.label=Enclave Settings + SGX.CXXtemplate.enclaveSettings.description=Initial settings required for a new enclave. + + #CXX Static lib template Values + SGX.CXXStatictemplate.title.description=A Software Guard Extensions C++ Enclave Library Project template. + SGX.CXXStatictemplate.title.label=SGX C++ Enclave Library Project + SGX.CXXStatictemplate.title.id=SGXCPPEnclaveLibProject + SGX.CXXStatictemplate.enclaveSettings.label=Enclave Settings + SGX.CXXStatictemplate.enclaveSettings.description=Initial settings required for a new enclave Library. + SGX.CXXStatictemplate.requiresEdl.label=Requires EDL + SGX.CXXStatictemplate.requiresEdl.description=De-select this option to create an Non-SGX trusted static library without an Edl file. By default, the project creates an Enclave library with an Edl file. diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/newmngc_app.gif b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/newmngc_app.gif new file mode 100644 index 0000000000..23b0284f84 Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/newmngc_app.gif differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/newmngcc_app.gif b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/newmngcc_app.gif new file mode 100644 index 0000000000..4b39411daf Binary files /dev/null and b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/newmngcc_app.gif differ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename.config.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename.config.xml new file mode 100644 index 0000000000..6210afff28 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename.config.xml @@ -0,0 +1,9 @@ + + $(ProdID) + $(IsvSvn) + $(ThreadStackSize) + $(GlobalHeapSize) + $(TcsNumber) + $(TcsPolicy) + $(DisableDebug) + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename_private.pem b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename_private.pem new file mode 100644 index 0000000000..790839d391 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4wIBAAKCAYEA8DLzZJpN7sN5J1PtKZAqWFeW+0/pPJVWRKEB8lfqXGJ0YIjG +1o0g0/+60ktlm0vVdWSqepmpRpTB2ZZjxxc+JHfZGQnvmlGx6qQxSFS9u+S8mSzD +MknsquLVsi7rojq34dTwSckMg0KQ/sGmsV6EgsUnldhdcPOJ8+NaaqtmAmjHYIpK +jLo3pJz0e7NqKvzE2YhmZZjrIZBNFHxX/lrQ36lW6Obp8xj9CqUMZp+2+/ntdFSl +7u9BK5y3ZHh8hUx6PkHfV8f1h9iG1jroINrrQwhftKmcsg/DPG7NOnjK/EvFaBku +6p0pnmeJM6VUihaLWYNAAjylVmMysenAjl4jsSzQeIe5idoPzYonCuAcASj8utgz +4OxxMHFYAXzgc2An6jp700NOgmYdhtoTMCUjohyd+RHJoSNJpE+ocKPVM72xucJB +o8dK55kI2/E19EVm59UyhXs2YGIjswziMK94H9KSl+TRthny7wYKju09lbdQAGid +rZcYTv2LVYP1Q5IDAgEDAoIBgQCgIfeYZt6fLPtvjUjGYBw65Q9SNUYoY47Ya1ah +j/GS7E2VsISPCMCNVSc23O5nh+OjmHGnERuEYyvmZEKEuiltpTtmBp+8NnacbXYw +OH59QyhmHdd22/MclzkhdJ0W0c/r40rb212s1wtUgRnLlFhXLhpj5ZOgolv37Obx +x5lW8ITrBtxd0XptvfhSd5wcqIM7sERDu0drtYi4UuVUPIs/xjnwmfFMu1NcbghE +ann9UUj4OG6fSityaHpC+v2uMvrexpJP3csYY/VbrYdzlp9GLHkm9mM3Y1tSYoU4 +GhsLstDSHIOZ5f2trh+Re6759SktXi+E9B4xQvJwwVAufmfU0aVESHtJDllt+UOK +LfINb3SmXX8uINqAlees+xJDm/ZcA8vvWWioD8Hv6c47qzrYH1JwvTJtk3G3orFs +syZe7KYwUUBxTREmTCdWoeHC9Hou4MxgiyViPl5SbIUz4yqJgcr3gPtoSRhwvY3v +r1GyeyRuB0CsAun5TQCcx31XwssCgcEA/hK8i1nKvEaTJ5GX9bGZo7BtjWftuGfa +qk0b4aZLWBeoJpGgivolaloTYE+aBAhPMFNKo9HT357o9SW48yk0kyReywJj6HBf +b82TSjt9wXmeo+6cE7EO7k1sINoJnlRiDkWqdpZLzty24dWMN27oXjO2ELUmAgnT +M8rzcshlhRsp/OSD+kIyEfVstx3H3hzPDMyHsNnlPv0Jycdp+1YfANLOaog+JHUZ +Kwb90RF2ePXnLbt2ts0N03kuJKgqS6xbAoHBAPIFR1Sheib8A6UlBP3HYrYVPGzQ +GiaS35aN6YSrVxKn5AZcyPjKB6+IRnkcNA8efmUirhb8pCzf3hOiD1V3U17N+ccY +nLPUKjjGrnFfsyuILx1dWQgKGoFDEF0qO2+h1FHvH3Wm5bdxw70l0Z81Yv+57D9A +1/q8S90QqtrOtiA/jnRj3P+RfxwxYSLgm3G54JS3eEPQmQ4HjG2isGeEmVC9E7ob +GnU3NRrit9ZUzJEIsi2iRfTFq4WQ3EWwjvRBeQKBwQCpYdMHkTHS2bdvtmVOdmZt +IEkI7/PQRTxxiL1BGYeQD8VvC8BcpsOcPAzq37wCsDTK4jHCi+KVFJtOGSX3cM23 +bZSHVu1FoD+f3mIxfP6A+78X9GgNILSe3kgV5rEUOEFe2RxPDt00kySWjl16SfA+ +zSQLI26sBozNMfeh2u5YvMaomFf8LCFhTkh6E9qUEzSzMwUgkUN/U1vb2kanjr9V +4d7xsClto2Ycr1Pgtk77TpoefPnPM16M+3QYcBwycucCgcEAoVjaOGumxKgCbhit +/oTseWN9neARbwyVDwlGWHI6DG/tWZMwpdwFH7Au+2gitL7+7hceuf3CyJU+t8Ff +jk+M6d6mhLsTIo1xey8e9j/Mx7AfaOjmBVwRq4IK6MbSSmvi4UoU+RnuekvX026L +v3jsqnvy1NXlUdLdPgsckd8kFX+0TZfoqmD/aCDrbJW89nvrDc+lgosQtAUISRcg +RQMQ4H4NJry8TiTOEex6juMzC1shc8GD+IPHrmCS2SBfTYD7AoHAOYqsSbLvkhWP +JCx3wicFIY4y+eJW2hNK19ho+PEcrmu7+HKZHMU7oslsoSnme5mMomK9pZnY8KSy +px0D13XyUmEmZluxKcdUDC6mRWH4qkPt/9DGbzHwNLfla+KbxoNLi7F6U5XU5J/6 +NzZeO9HrLzHy1ck/0xUDU7Y+WWniMbUdlOpXSd+SsZtKomRhnc+QljYqSJplJL7f +mfnQ4stcY3RcPHGwfDOQT9sVk0hoIGXKCzEl217Iw1P8UwKvBbNe +-----END RSA PRIVATE KEY----- diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_t.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_t.mk new file mode 100644 index 0000000000..41aaf26fa4 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_t.mk @@ -0,0 +1,127 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif + +Crypto_Library_Name := sgx_tcrypto + +$(EnclaveName)_Cpp_Files := trusted/$(enclaveName).cpp +$(EnclaveName)_C_Files := +$(EnclaveName)_Include_Paths := -IInclude -Itrusted -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport + + +Flags_Just_For_C := -Wno-implicit-function-declaration -std=c11 +Common_C_Cpp_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $($(EnclaveName)_Include_Paths) -fno-builtin-printf -I. +$(EnclaveName)_C_Flags := $(Flags_Just_For_C) $(Common_C_Cpp_Flags) +$(EnclaveName)_Cpp_Flags := $(Common_C_Cpp_Flags) -std=c++11 -nostdinc++ -fno-builtin-printf -I. + +$(EnclaveName)_Cpp_Flags := $($(EnclaveName)_Cpp_Flags) -fno-builtin-printf + +$(EnclaveName)_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 \ + -Wl,--version-script=trusted/$(enclaveName).lds + +$(EnclaveName)_Cpp_Objects := $($(EnclaveName)_Cpp_Files:.cpp=.o) +$(EnclaveName)_C_Objects := $($(EnclaveName)_C_Files:.c=.o) + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +ifeq ($(Build_Mode), HW_RELEASE) +all: $(enclaveName).so + @echo "Build enclave $(enclaveName).so [$(Build_Mode)|$(SGX_ARCH)] success!" + @echo + @echo "*********************************************************************************************************************************************************" + @echo "PLEASE NOTE: In this mode, please sign the $(enclaveName).so first using Two Step Sign mechanism before you run the app to launch and access the enclave." + @echo "*********************************************************************************************************************************************************" + @echo + + +else +all: $(enclaveName).signed.so +endif + +run: all +ifneq ($(Build_Mode), HW_RELEASE) + @$(CURDIR)/app + @echo "RUN => app [$(SGX_MODE)|$(SGX_ARCH), OK]" +endif + + +######## $(enclaveName) Objects ######## + +trusted/$(enclaveName)_t.c: $(SGX_EDGER8R) ./trusted/$(enclaveName).edl + @cd ./trusted && $(SGX_EDGER8R) --trusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +trusted/$(enclaveName)_t.o: ./trusted/$(enclaveName)_t.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +trusted/%.o: trusted/%.cpp + @$(CXX) $($(EnclaveName)_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +trusted/%.o: trusted/%.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(enclaveName).so: trusted/$(enclaveName)_t.o $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects) + @$(CXX) $^ -o $@ $($(EnclaveName)_Link_Flags) + @echo "LINK => $@" + +$(enclaveName).signed.so: $(enclaveName).so + @$(SGX_ENCLAVE_SIGNER) sign -key trusted/$(enclaveName)_private.pem -enclave $(enclaveName).so -out $@ -config trusted/$(enclaveName).config.xml + @echo "SIGN => $@" +clean: + @rm -f $(enclaveName).* trusted/$(enclaveName)_t.* $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects) diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_u.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_u.mk new file mode 100644 index 0000000000..201963cb07 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_u.mk @@ -0,0 +1,129 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +ifneq ($(SGX_MODE), HW) + Urts_Library_Name := sgx_urts_sim +else + Urts_Library_Name := sgx_urts +endif + +# App_Cpp_Files := App/App.cpp $(wildcard App/Edger8rSyntax/*.cpp) $(wildcard App/TrustedLibrary/*.cpp) +App_Cpp_Files := $(UNTRUSTED_DIR)/sample.cpp # $(wildcard App/TrustedLibrary/*.cpp) +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Cpp_Flags := $(App_C_Flags) -std=c++11 +App_Link_Flags := $(SGX_COMMON_CFLAGS) -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name) -lpthread + +ifneq ($(SGX_MODE), HW) + App_Link_Flags += -lsgx_uae_service_sim +else + App_Link_Flags += -lsgx_uae_service +endif + +App_Cpp_Objects := $(App_Cpp_Files:.cpp=.o) + + + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +ifeq ($(Build_Mode), HW_RELEASE) +all: sample + @echo "Build sample [$(Build_Mode)|$(SGX_ARCH)] success!" + @echo + @echo "*********************************************************************************************************************************************************" + @echo "PLEASE NOTE: In this mode, please sign the $(enclaveName).so first using Two Step Sign mechanism before you run the app to launch and access the enclave." + @echo "*********************************************************************************************************************************************************" + @echo + + +else +all: sample +endif + +run: all +ifneq ($(Build_Mode), HW_RELEASE) + @$(CURDIR)/sample + @echo "RUN => sample [$(SGX_MODE)|$(SGX_ARCH), OK]" +endif + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) trusted/$(enclaveName).edl + @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(UNTRUSTED_DIR)/%.o: $(UNTRUSTED_DIR)/%.cpp + @$(CXX) $(App_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +sample: $(UNTRUSTED_DIR)/$(enclaveName)_u.o $(App_Cpp_Objects) + @$(CXX) $^ -o $@ $(App_Link_Flags) + @echo "LINK => $@" + + +.PHONY: clean + +clean: + @rm -f sample $(App_Cpp_Objects) $(UNTRUSTED_DIR)/$(enclaveName)_u.* diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_u.without_app.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_u.without_app.mk new file mode 100644 index 0000000000..00aed4b876 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c++/sgx_u.without_app.mk @@ -0,0 +1,71 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Cpp_Flags := $(App_C_Flags) -std=c++11 + +.PHONY: all run + +all: $(UNTRUSTED_DIR)/$(enclaveName)_u.o + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) trusted/$(enclaveName).edl + @mkdir -p $(UNTRUSTED_DIR) + @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +.PHONY: clean + +clean: + @rm -f $(UNTRUSTED_DIR)/$(enclaveName)_u.* diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_t.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_t.mk new file mode 100644 index 0000000000..3851c1de3b --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_t.mk @@ -0,0 +1,115 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif + +Crypto_Library_Name := sgx_tcrypto + +$(EnclaveName)_C_Files := trusted/$(enclaveName).c +$(EnclaveName)_Include_Paths := -IInclude -Itrusted -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport + +Flags_Just_For_C := -Wno-implicit-function-declaration -std=c11 +Common_C_Cpp_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $($(EnclaveName)_Include_Paths) -fno-builtin-printf -I. +$(EnclaveName)_C_Flags := $(Flags_Just_For_C) $(Common_C_Cpp_Flags) + +$(EnclaveName)_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 \ + -Wl,--version-script=trusted/$(enclaveName).lds + +$(EnclaveName)_C_Objects := $($(EnclaveName)_C_Files:.c=.o) + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +ifeq ($(Build_Mode), HW_RELEASE) +all: $(enclaveName).so + @echo "Build enclave $(enclaveName).so [$(Build_Mode)|$(SGX_ARCH)] success!" + @echo + @echo "*********************************************************************************************************************************************************" + @echo "PLEASE NOTE: In this mode, please sign the $(enclaveName).so first using Two Step Sign mechanism before you run the app to launch and access the enclave." + @echo "*********************************************************************************************************************************************************" + @echo +else +all: $(enclaveName).signed.so +endif + +run: all +ifneq ($(Build_Mode), HW_RELEASE) + @$(CURDIR)/app + @echo "RUN => app [$(SGX_MODE)|$(SGX_ARCH), OK]" +endif + + +######## $(enclaveName) Objects ######## + +trusted/$(enclaveName)_t.c: $(SGX_EDGER8R) ./trusted/$(enclaveName).edl + @cd ./trusted && $(SGX_EDGER8R) --trusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +trusted/$(enclaveName)_t.o: ./trusted/$(enclaveName)_t.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +trusted/%.o: trusted/%.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(enclaveName).so: trusted/$(enclaveName)_t.o $($(EnclaveName)_C_Objects) + @$(CXX) $^ -o $@ $($(EnclaveName)_Link_Flags) + @echo "LINK => $@" + +$(enclaveName).signed.so: $(enclaveName).so + @$(SGX_ENCLAVE_SIGNER) sign -key trusted/$(enclaveName)_private.pem -enclave $(enclaveName).so -out $@ -config trusted/$(enclaveName).config.xml + @echo "SIGN => $@" +clean: + @rm -f $(enclaveName).* trusted/$(enclaveName)_t.* $($(EnclaveName)_C_Objects) diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_u.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_u.mk new file mode 100644 index 0000000000..70d293e363 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_u.mk @@ -0,0 +1,126 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +ifneq ($(SGX_MODE), HW) + Urts_Library_Name := sgx_urts_sim +else + Urts_Library_Name := sgx_urts +endif + +App_C_Files := $(UNTRUSTED_DIR)/sample.c +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Link_Flags := $(SGX_COMMON_CFLAGS) -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name) -lpthread + +ifneq ($(SGX_MODE), HW) + App_Link_Flags += -lsgx_uae_service_sim +else + App_Link_Flags += -lsgx_uae_service +endif + +App_C_Objects := $(App_C_Files:.c=.o) + + + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +ifeq ($(Build_Mode), HW_RELEASE) +all: sample + @echo "Build sample [$(Build_Mode)|$(SGX_ARCH)] success!" + @echo + @echo "*********************************************************************************************************************************************************" + @echo "PLEASE NOTE: In this mode, please sign the $(enclaveName).so first using Two Step Sign mechanism before you run the app to launch and access the enclave." + @echo "*********************************************************************************************************************************************************" + @echo + +else +all: sample +endif + +run: all +ifneq ($(Build_Mode), HW_RELEASE) + @$(CURDIR)/sample + @echo "RUN => sample [$(SGX_MODE)|$(SGX_ARCH), OK]" +endif + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) trusted/$(enclaveName).edl + @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(UNTRUSTED_DIR)/%.o: $(UNTRUSTED_DIR)/%.c + @$(CXX) $(App_C_Flags) -c $< -o $@ + @echo "CXX <= $<" + +sample: $(UNTRUSTED_DIR)/$(enclaveName)_u.o $(App_C_Objects) + @$(CXX) $^ -o $@ $(App_Link_Flags) + @echo "LINK => $@" + + +.PHONY: clean + +clean: + @rm -f sample $(App_C_Objects) $(UNTRUSTED_DIR)/$(enclaveName)_u.* diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_u.without_app.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_u.without_app.mk new file mode 100644 index 0000000000..f9eee94c69 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/c/sgx_u.without_app.mk @@ -0,0 +1,70 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + + +.PHONY: all run + +all: $(UNTRUSTED_DIR)/$(enclaveName)_u.o + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) trusted/$(enclaveName).edl + @mkdir -p $(UNTRUSTED_DIR) + @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +.PHONY: clean + +clean: + @rm -f $(UNTRUSTED_DIR)/$(enclaveName)_u.* diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/common/Makefile b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/common/Makefile new file mode 100644 index 0000000000..3defedc4c8 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/makefiles/common/Makefile @@ -0,0 +1,8 @@ +all: + $(MAKE) -f sgx_u.mk all + $(MAKE) -f sgx_t.mk all + +clean: + $(MAKE) -f sgx_u.mk clean + $(MAKE) -f sgx_t.mk clean + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.config.xml b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.config.xml new file mode 100644 index 0000000000..a957526f95 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.config.xml @@ -0,0 +1,10 @@ + + + 0 + 0 + 0x40000 + 0x100000 + 10 + 1 + 0 + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.cpp b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.cpp new file mode 100644 index 0000000000..78f55c1553 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.cpp @@ -0,0 +1,26 @@ +#include +#include /* vsnprintf */ + +#include "$(enclaveName).h" +#include "$(enclaveName)_t.h" /* print_string */ + +/* + * printf: + * Invokes OCALL to display the enclave buffer to the terminal. + */ +void printf(const char *fmt, ...) +{ + char buf[BUFSIZ] = {'\0'}; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, BUFSIZ, fmt, ap); + va_end(ap); + ocall_$(enclaveName)_sample(buf); +} + +int ecall_$(enclaveName)_sample() +{ + printf("IN $(ENCLAVENAME)\n"); + return 0; +} + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.edl b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.edl new file mode 100644 index 0000000000..e97f447eb3 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.edl @@ -0,0 +1,18 @@ +/* $(enclaveName).edl - Top EDL file. */ + +enclave { + + /* + * ocall_$(enclaveName)_sample - invokes OCALL to display string buffer inside the enclave. + * [in]: copy the string buffer to App outside. + * [string]: specifies 'str' is a NULL terminated buffer. + */ + untrusted { + void ocall_$(enclaveName)_sample([in, string] const char *str); + }; + + + trusted { + public int ecall_$(enclaveName)_sample(); + }; +}; diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.h b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.h new file mode 100644 index 0000000000..2d29332f3f --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.h @@ -0,0 +1,17 @@ +#ifndef _$(ENCLAVENAME)_H_ +#define _$(ENCLAVENAME)_H_ + +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +void printf(const char *fmt, ...); + +#if defined(__cplusplus) +} +#endif + +#endif /* !_$(ENCLAVENAME)_H_ */ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.lds b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.lds new file mode 100644 index 0000000000..9019f79f5d --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.lds @@ -0,0 +1,9 @@ +$(enclaveName).so +{ + global: + g_global_data_sim; + g_global_data; + $(enclaveName)_entry; + local: + *; +}; diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_minimal.cpp b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_minimal.cpp new file mode 100644 index 0000000000..79700c42b7 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_minimal.cpp @@ -0,0 +1,7 @@ +#include "$(enclaveName)_t.h" /* print_string */ + +int ecall_$(enclaveName)_sample() +{ + return 0; +} + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_minimal.edl b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_minimal.edl new file mode 100644 index 0000000000..f332f81910 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_minimal.edl @@ -0,0 +1,10 @@ +/* $(enclaveName).edl - Top EDL file. */ + +enclave { + untrusted { + }; + + trusted { + public int ecall_$(enclaveName)_sample(); + }; +}; diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_private.pem b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_private.pem new file mode 100644 index 0000000000..529d07be35 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4gIBAAKCAYEAroOogvsj/fZDZY8XFdkl6dJmky0lRvnWMmpeH41Bla6U1qLZ +AmZuyIF+mQC/cgojIsrBMzBxb1kKqzATF4+XwPwgKz7fmiddmHyYz2WDJfAjIveJ +ZjdMjM4+EytGlkkJ52T8V8ds0/L2qKexJ+NBLxkeQLfV8n1mIk7zX7jguwbCG1Pr +nEMdJ3Sew20vnje+RsngAzdPChoJpVsWi/K7cettX/tbnre1DL02GXc5qJoQYk7b +3zkmhz31TgFrd9VVtmUGyFXAysuSAb3EN+5VnHGr0xKkeg8utErea2FNtNIgua8H +ONfm9Eiyaav1SVKzPHlyqLtcdxH3I8Wg7yqMsaprZ1n5A1v/levxnL8+It02KseD +5HqV4rf/cImSlCt3lpRg8U5E1pyFQ2IVEC/XTDMiI3c+AR+w2jSRB3Bwn9zJtFlW +KHG3m1xGI4ck+Lci1JvWWLXQagQSPtZTsubxTQNx1gsgZhgv1JHVZMdbVlAbbRMC +1nSuJNl7KPAS/VfzAgEDAoIBgHRXxaynbVP5gkO0ug6Qw/E27wzIw4SmjsxG6Wpe +K7kfDeRskKxESdsA/xCrKkwGwhcx1iIgS5+Qscd1Yg+1D9X9asd/P7waPmWoZd+Z +AhlKwhdPsO7PiF3e1AzHhGQwsUTt/Y/aSI1MpHBvy2/s1h9mFCslOUxTmWw0oj/Q +ldIEgWeNR72CE2+jFIJIyml6ftnb6qzPiga8Bm48ubKh0kvySOqnkmnPzgh+JBD6 +JnBmtZbfPT97bwTT+N6rnPqOOApvfHPf15kWI8yDbprG1l4OCUaIUH1AszxLd826 +5IPM+8gINLRDP1MA6azECPjTyHXhtnSIBZCyWSVkc05vYmNXYUNiXWMajcxW9M02 +wKzFELO8NCEAkaTPxwo4SCyIjUxiK1LbQ9h8PSy4c1+gGP4LAMR8xqP4QKg6zdu9 +osUGG/xRe/uufgTBFkcjqBHtK5L5VI0jeNIUAgW/6iNbYXjBMJ0GfauLs+g1VsOm +WfdgXzsb9DYdMa0OXXHypmV4GwKBwQDUwQj8RKJ6c8cT4vcWCoJvJF00+RFL+P3i +Gx2DLERxRrDa8AVGfqaCjsR+3vLgG8V/py+z+dxZYSqeB80Qeo6PDITcRKoeAYh9 +xlT3LJOS+k1cJcEmlbbO2IjLkTmzSwa80fWexKu8/Xv6vv15gpqYl1ngYoqJM3pd +vzmTIOi7MKSZ0WmEQavrZj8zK4endE3v0eAEeQ55j1GImbypSf7Idh7wOXtjZ7WD +Dg6yWDrri+AP/L3gClMj8wsAxMV4ZR8CgcEA0fzDHkFa6raVOxWnObmRoDhAtE0a +cjUj976NM5yyfdf2MrKy4/RhdTiPZ6b08/lBC/+xRfV3xKVGzacm6QjqjZrUpgHC +0LKiZaMtccCJjLtPwQd0jGQEnKfMFaPsnhOc5y8qVkCzVOSthY5qhz0XNotHHFmJ +gffVgB0iqrMTvSL7IA2yqqpOqNRlhaYhNl8TiFP3gIeMtVa9rZy31JPgT2uJ+kfo +gV7sdTPEjPWZd7OshGxWpT6QfVDj/T9T7L6tAoHBAI3WBf2DFvxNL2KXT2QHAZ9t +k3imC4f7U+wSE6zILaDZyzygA4RUbwG0gv8/TJVn2P/Eynf76DuWHGlaiLWnCbSz +Az2DHBQBBaku409zDQym3j1ugMRjzzSQWzJg0SIyBH3hTmnYcn3+Uqcp/lEBvGW6 +O+rsXFt3pukqJmIV8HzLGGaLm62BHUeZf3dyWm+i3p/hQAL7Xvu04QW70xuGqdr5 +afV7p5eaeQIJXyGQJ0eylV/90+qxjMKiB1XYg6WYvwKBwQCL/ddpgOdHJGN8uRom +e7Zq0Csi3hGheMKlKbN3vcxT5U7MdyHtTZZOJbTvxKNNUNYH/8uD+PqDGNneb29G +BfGzvI3EASyLIcGZF3OhKwZd0jUrWk2y7Vhob91jwp2+t73vdMbkKyI4mHOuXvGv +fg95si9oO7EBT+Oqvhccd2J+F1IVXncccYnF4u5ZGWt5lLewN/pVr7MjjykeaHqN +t+rfnQam2psA6fL4zS2zTmZPzR2tnY8Y1GBTi0Ko1OKd1HMCgcAb5cB/7/AQlhP9 +yQa04PLH9ygQkKKptZp7dy5WcWRx0K/hAHRoi2aw1wZqfm7VBNu2SLcs90kCCCxp +6C5sfJi6b8NpNbIPC+sc9wsFr7pGo9SFzQ78UlcWYK2Gu2FxlMjonhka5hvo4zvg +WxlpXKEkaFt3gLd92m/dMqBrHfafH7VwOJY2zT3WIpjwuk0ZzmRg5p0pG/svVQEH +NZmwRwlopysbR69B/n1nefJ84UO50fLh5s5Zr3gBRwbWNZyzhXk= +-----END RSA PRIVATE KEY----- diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp new file mode 100644 index 0000000000..58b28a8509 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp @@ -0,0 +1,247 @@ +#include +#include + +#include +#include +#include +#include + +# define MAX_PATH FILENAME_MAX + + +#include +#include "sample.h" + +#include "$(enclaveName)_u.h" + + + +/* Global EID shared by multiple threads */ +sgx_enclave_id_t global_eid = 0; + +typedef struct _sgx_errlist_t { + sgx_status_t err; + const char *msg; + const char *sug; /* Suggestion */ +} sgx_errlist_t; + +/* Error code returned by sgx_create_enclave */ +static sgx_errlist_t sgx_errlist[] = { + { + SGX_ERROR_UNEXPECTED, + "Unexpected error occurred.", + NULL + }, + { + SGX_ERROR_INVALID_PARAMETER, + "Invalid parameter.", + NULL + }, + { + SGX_ERROR_OUT_OF_MEMORY, + "Out of memory.", + NULL + }, + { + SGX_ERROR_ENCLAVE_LOST, + "Power transition occurred.", + "Please refer to the sample \"PowerTransition\" for details." + }, + { + SGX_ERROR_INVALID_ENCLAVE, + "Invalid enclave image.", + NULL + }, + { + SGX_ERROR_INVALID_ENCLAVE_ID, + "Invalid enclave identification.", + NULL + }, + { + SGX_ERROR_INVALID_SIGNATURE, + "Invalid enclave signature.", + NULL + }, + { + SGX_ERROR_OUT_OF_EPC, + "Out of EPC memory.", + NULL + }, + { + SGX_ERROR_NO_DEVICE, + "Invalid SGX device.", + "Please make sure SGX module is enabled in the BIOS, and install SGX driver afterwards." + }, + { + SGX_ERROR_MEMORY_MAP_CONFLICT, + "Memory map conflicted.", + NULL + }, + { + SGX_ERROR_INVALID_METADATA, + "Invalid enclave metadata.", + NULL + }, + { + SGX_ERROR_DEVICE_BUSY, + "SGX device was busy.", + NULL + }, + { + SGX_ERROR_INVALID_VERSION, + "Enclave version was invalid.", + NULL + }, + { + SGX_ERROR_INVALID_ATTRIBUTE, + "Enclave was not authorized.", + NULL + }, + { + SGX_ERROR_ENCLAVE_FILE_ACCESS, + "Can't open enclave file.", + NULL + }, +}; + +/* Check error conditions for loading enclave */ +void print_error_message(sgx_status_t ret) +{ + size_t idx = 0; + size_t ttl = sizeof sgx_errlist/sizeof sgx_errlist[0]; + + for (idx = 0; idx < ttl; idx++) { + if(ret == sgx_errlist[idx].err) { + if(NULL != sgx_errlist[idx].sug) + printf("Info: %s\n", sgx_errlist[idx].sug); + printf("Error: %s\n", sgx_errlist[idx].msg); + break; + } + } + + if (idx == ttl) + printf("Error: Unexpected error occurred.\n"); +} + +/* Initialize the enclave: + * Step 1: retrive the launch token saved by last transaction + * Step 2: call sgx_create_enclave to initialize an enclave instance + * Step 3: save the launch token if it is updated + */ +int initialize_enclave(void) +{ + char token_path[MAX_PATH] = {'\0'}; + sgx_launch_token_t token = {0}; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + int updated = 0; + /* Step 1: retrive the launch token saved by last transaction */ + + /* try to get the token saved in $HOME */ + const char *home_dir = getpwuid(getuid())->pw_dir; + if (home_dir != NULL && + (strlen(home_dir)+strlen("/")+sizeof(TOKEN_FILENAME)+1) <= MAX_PATH) { + /* compose the token path */ + strncpy(token_path, home_dir, strlen(home_dir)); + strncat(token_path, "/", strlen("/")); + strncat(token_path, TOKEN_FILENAME, sizeof(TOKEN_FILENAME)+1); + } else { + /* if token path is too long or $HOME is NULL */ + strncpy(token_path, TOKEN_FILENAME, sizeof(TOKEN_FILENAME)); + } + + FILE *fp = fopen(token_path, "rb"); + if (fp == NULL && (fp = fopen(token_path, "wb")) == NULL) { + printf("Warning: Failed to create/open the launch token file \"%s\".\n", token_path); + } + printf("token_path: %s\n", token_path); + if (fp != NULL) { + /* read the token from saved file */ + size_t read_num = fread(token, 1, sizeof(sgx_launch_token_t), fp); + if (read_num != 0 && read_num != sizeof(sgx_launch_token_t)) { + /* if token is invalid, clear the buffer */ + memset(&token, 0x0, sizeof(sgx_launch_token_t)); + printf("Warning: Invalid launch token read from \"%s\".\n", token_path); + } + } + + /* Step 2: call sgx_create_enclave to initialize an enclave instance */ + /* Debug Support: set 2nd parameter to 1 */ + + ret = sgx_create_enclave($(ENCLAVENAME)_FILENAME, SGX_DEBUG_FLAG, &token, &updated, &global_eid, NULL); + + if (ret != SGX_SUCCESS) { + print_error_message(ret); + if (fp != NULL) fclose(fp); + + return -1; + } + + /* Step 3: save the launch token if it is updated */ + + if (updated == FALSE || fp == NULL) { + /* if the token is not updated, or file handler is invalid, do not perform saving */ + if (fp != NULL) fclose(fp); + return 0; + } + + /* reopen the file with write capablity */ + fp = freopen(token_path, "wb", fp); + if (fp == NULL) return 0; + size_t write_num = fwrite(token, 1, sizeof(sgx_launch_token_t), fp); + if (write_num != sizeof(sgx_launch_token_t)) + printf("Warning: Failed to save launch token to \"%s\".\n", token_path); + fclose(fp); + + return 0; +} + +/* OCall functions */ +void ocall_$(enclaveName)_sample(const char *str) +{ + /* Proxy/Bridge will check the length and null-terminate + * the input string to prevent buffer overflow. + */ + printf("%s", str); +} + + +/* Application entry */ +int SGX_CDECL main(int argc, char *argv[]) +{ + (void)(argc); + (void)(argv); + + /* Changing dir to where the executable is.*/ + char absolutePath [MAX_PATH]; + char *ptr = NULL; + + ptr = realpath(dirname(argv[0]),absolutePath); + + if( chdir(absolutePath) != 0) + abort(); + + /* Initialize the enclave */ + if(initialize_enclave() < 0){ + + return -1; + } + + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + int ecall_return = 0; + + ret = ecall_$(enclaveName)_sample(global_eid, &ecall_return); + if (ret != SGX_SUCCESS) + abort(); + + if (ecall_return == 0) { + printf("Application ran with success\n"); + } + else + { + printf("Application failed %d \n", ecall_return); + } + + sgx_destroy_enclave(global_eid); + + return ecall_return; +} diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.h b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.h new file mode 100644 index 0000000000..a0fb5e780e --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.h @@ -0,0 +1,34 @@ +#ifndef _APP_H_ +#define _APP_H_ + +#include +#include +#include +#include + +#include "sgx_error.h" /* sgx_status_t */ +#include "sgx_eid.h" /* sgx_enclave_id_t */ + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + + +# define TOKEN_FILENAME "enclave.token" +# define $(ENCLAVENAME)_FILENAME "$(enclaveName).signed.so" + +extern sgx_enclave_id_t global_eid; /* global enclave id */ + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* !_APP_H_ */ diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXNature/Makefile b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXNature/Makefile new file mode 100644 index 0000000000..5a67151653 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXNature/Makefile @@ -0,0 +1,17 @@ +ALL_UNTRUSTED_MK=$(shell find . -name '*sgx_u.mk') +ALL_TRUSTED_MK=$(shell find . -name '*sgx_t.mk') +ALL_STATIC_MK=$(shell find . -name '*sgx_t_static.mk') + + + +.PHONY: all clean run + + +all clean: + $(foreach U_MK, $(ALL_UNTRUSTED_MK), $(MAKE) -C $(shell dirname $(U_MK)) -f $(shell basename $(U_MK)) $@;) + $(foreach T_MK, $(ALL_TRUSTED_MK), $(MAKE) -C $(shell dirname $(T_MK)) -f $(shell basename $(T_MK)) $@;) + $(foreach U_MK, $(ALL_STATIC_MK), $(MAKE) -C $(shell dirname $(U_MK)) -f $(shell basename $(U_MK)) $@;) + +run: + $(foreach U_MK, $(ALL_UNTRUSTED_MK), $(MAKE) -C $(shell dirname $(U_MK)) -f $(shell basename $(U_MK)) $@;) + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c++/sgx_t_static.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c++/sgx_t_static.mk new file mode 100644 index 0000000000..6b9dce7acc --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c++/sgx_t_static.mk @@ -0,0 +1,105 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif + +Crypto_Library_Name := sgx_tcrypto + +$(EnclaveName)_Cpp_Files := static_trusted/$(enclaveName).cpp +$(EnclaveName)_C_Files := +$(EnclaveName)_Include_Paths := -IInclude -I$(EnclaveName) -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport + +Flags_Just_For_C := -Wno-implicit-function-declaration -std=c11 +Common_C_Cpp_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $($(EnclaveName)_Include_Paths) -fno-builtin-printf -I. +$(EnclaveName)_C_Flags := $(Flags_Just_For_C) $(Common_C_Cpp_Flags) +$(EnclaveName)_Cpp_Flags := $(Common_C_Cpp_Flags) -std=c++11 -nostdinc++ -fno-builtin-printf -I. + +$(EnclaveName)_Cpp_Flags := $($(EnclaveName)_Cpp_Flags) -fno-builtin-printf + +$(EnclaveName)_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 \ + -Wl,--version-script=trusted/$(enclaveName).lds + + +$(EnclaveName)_Cpp_Objects := $($(EnclaveName)_Cpp_Files:.cpp=.o) +$(EnclaveName)_C_Objects := $($(EnclaveName)_C_Files:.c=.o) + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +all: $(enclaveName).sgx.static.lib.a + +######## $(enclaveName) Objects ######## + +static_trusted/$(enclaveName)_t.h: $(SGX_EDGER8R) ./static_trusted/$(enclaveName).edl + @cd ./static_trusted && $(SGX_EDGER8R) --header-only --trusted ../static_trusted/$(enclaveName).edl --search-path ../static_trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +static_trusted/$(enclaveName)_t.o: ./trusted/$(enclaveName)_t.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +static_trusted/%.o: static_trusted/%.cpp + @$(CXX) $($(EnclaveName)_Include_Paths) $($(EnclaveName)_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +static_trusted/%.o: static_trusted/%.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(enclaveName).sgx.static.lib.a: static_trusted/$(enclaveName)_t.h $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects) + ar rcs $(enclaveName).sgx.static.lib.a $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects) + @echo "LINK => $@" + +clean: + @rm -f $(enclaveName).* static_trusted/$(enclaveName)_t.* $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects) diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c++/sgx_u.without_app.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c++/sgx_u.without_app.mk new file mode 100644 index 0000000000..c0d0c6778a --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c++/sgx_u.without_app.mk @@ -0,0 +1,71 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Cpp_Flags := $(App_C_Flags) -std=c++11 + +.PHONY: all run + +all: $(UNTRUSTED_DIR)/$(enclaveName)_u.o + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) static_trusted/$(enclaveName).edl + @mkdir -p $(UNTRUSTED_DIR) + @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../static_trusted/$(enclaveName).edl --search-path ../static_trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +.PHONY: clean + +clean: + @rm -f $(UNTRUSTED_DIR)/$(enclaveName)_u.* diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c/sgx_t_static.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c/sgx_t_static.mk new file mode 100644 index 0000000000..e0bd716e18 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c/sgx_t_static.mk @@ -0,0 +1,95 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif + +Crypto_Library_Name := sgx_tcrypto + +$(EnclaveName)_C_Files := static_trusted/$(enclaveName).c +$(EnclaveName)_Include_Paths := -IInclude -I$(EnclaveName) -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport + +Flags_Just_For_C := -Wno-implicit-function-declaration -std=c11 +Common_C_Cpp_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $($(EnclaveName)_Include_Paths) -fno-builtin-printf -I. +$(EnclaveName)_C_Flags := $(Flags_Just_For_C) $(Common_C_Cpp_Flags) + +$(EnclaveName)_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 \ + -Wl,--version-script=trusted/$(enclaveName).lds + +$(EnclaveName)_C_Objects := $($(EnclaveName)_C_Files:.c=.o) + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +all: $(enclaveName).sgx.static.lib.a + +######## $(enclaveName) Objects ######## + +static_trusted/$(enclaveName)_t.h: $(SGX_EDGER8R) ./static_trusted/$(enclaveName).edl + @cd ./static_trusted && $(SGX_EDGER8R) --header-only --trusted ../static_trusted/$(enclaveName).edl --search-path ../static_trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +static_trusted/$(enclaveName)_t.o: ./trusted/$(enclaveName)_t.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +static_trusted/%.o: static_trusted/%.c + @$(CC) $($(EnclaveName)_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(enclaveName).sgx.static.lib.a: static_trusted/$(enclaveName)_t.h $($(EnclaveName)_C_Objects) + ar rcs $(enclaveName).sgx.static.lib.a $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects) + @echo "LINK => $@" + +clean: + @rm -f $(enclaveName).* static_trusted/$(enclaveName)_t.* $($(EnclaveName)_C_Objects) diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c/sgx_u.without_app.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c/sgx_u.without_app.mk new file mode 100644 index 0000000000..e8a5508339 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c/sgx_u.without_app.mk @@ -0,0 +1,70 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + + +.PHONY: all run + +all: $(UNTRUSTED_DIR)/$(enclaveName)_u.o + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) static_trusted/$(enclaveName).edl + @mkdir -p $(UNTRUSTED_DIR) + @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../static_trusted/$(enclaveName).edl --search-path ../static_trusted --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +.PHONY: clean + +clean: + @rm -f $(UNTRUSTED_DIR)/$(enclaveName)_u.* diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/common/Makefile b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/common/Makefile new file mode 100644 index 0000000000..3defedc4c8 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/common/Makefile @@ -0,0 +1,8 @@ +all: + $(MAKE) -f sgx_u.mk all + $(MAKE) -f sgx_t.mk all + +clean: + $(MAKE) -f sgx_u.mk clean + $(MAKE) -f sgx_t.mk clean + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/common/Makefile.without_app b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/common/Makefile.without_app new file mode 100644 index 0000000000..28aa5c8f1e --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/common/Makefile.without_app @@ -0,0 +1,8 @@ +all: + $(MAKE) -f sgx_u.mk all + $(MAKE) -f sgx_t_static.mk all + +clean: + $(MAKE) -f sgx_u.mk clean + $(MAKE) -f sgx_t.mk clean + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/static_trusted/Enclave2_minimal.cpp b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/static_trusted/Enclave2_minimal.cpp new file mode 100644 index 0000000000..79700c42b7 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/static_trusted/Enclave2_minimal.cpp @@ -0,0 +1,7 @@ +#include "$(enclaveName)_t.h" /* print_string */ + +int ecall_$(enclaveName)_sample() +{ + return 0; +} + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/static_trusted/Enclave2_minimal.edl b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/static_trusted/Enclave2_minimal.edl new file mode 100644 index 0000000000..7af749e545 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/static_trusted/Enclave2_minimal.edl @@ -0,0 +1,11 @@ +/* $(enclaveName).edl - Top EDL file. */ + +enclave { + + untrusted { + }; + + trusted { + public int ecall_$(enclaveName)_sample(); + }; +}; diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/c++/sgx_u.without_app.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/c++/sgx_u.without_app.mk new file mode 100644 index 0000000000..0db9ce0ab5 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/c++/sgx_u.without_app.mk @@ -0,0 +1,75 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted +SGX_EDL_FILE := $(baseName).edl + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Cpp_Flags := $(App_C_Flags) -std=c++11 + +.PHONY: all run + +all: $(UNTRUSTED_DIR)/$(baseName)_u.o $(UNTRUSTED_DIR)/$(baseName).o + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(baseName)_u.c: $(SGX_EDGER8R) $(SGX_EDL_FILE) + @mkdir -p $(UNTRUSTED_DIR) && cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted $(SGX_EDL_FILE) --search-path .. --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(baseName)_u.o: $(UNTRUSTED_DIR)/$(baseName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(UNTRUSTED_DIR)/$(baseName).o: $(UNTRUSTED_DIR)/$(baseName).cpp + @$(CC) $(App_Cpp_Flags) -c $< -o $@ + @echo "CC <= $<" + +.PHONY: clean + +clean: + @rm -f $(UNTRUSTED_DIR)/$(baseName)_u.* $(UNTRUSTED_DIR)/$(baseName).o diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/c/sgx_u.without_app.mk b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/c/sgx_u.without_app.mk new file mode 100644 index 0000000000..cce0dfec11 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/c/sgx_u.without_app.mk @@ -0,0 +1,75 @@ +######## SGX SDK Settings ######## +SGX_SDK ?= $(SdkPathFromPlugin) +SGX_MODE ?= SIM +SGX_ARCH ?= x64 +UNTRUSTED_DIR=untrusted +SGX_EDL_FILE := $(baseName).edl + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Cpp_Flags := $(App_C_Flags) -std=c++11 + +.PHONY: all run + +all: $(UNTRUSTED_DIR)/$(baseName)_u.o $(UNTRUSTED_DIR)/$(baseName).o + +######## App Objects ######## + +$(UNTRUSTED_DIR)/$(baseName)_u.c: $(SGX_EDGER8R) $(SGX_EDL_FILE) + @mkdir -p $(UNTRUSTED_DIR) && cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted $(SGX_EDL_FILE) --search-path .. --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(UNTRUSTED_DIR)/$(baseName)_u.o: $(UNTRUSTED_DIR)/$(baseName)_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(UNTRUSTED_DIR)/$(baseName).o: $(UNTRUSTED_DIR)/$(baseName).c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +.PHONY: clean + +clean: + @rm -f $(UNTRUSTED_DIR)/$(baseName)_u.* $(UNTRUSTED_DIR)/$(baseName).o diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/common/Makefile b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/common/Makefile new file mode 100644 index 0000000000..af0747ec6d --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/makefiles/common/Makefile @@ -0,0 +1,6 @@ +all: + $(MAKE) -f sgx_u.mk all + +clean: + $(MAKE) -f sgx_u.mk clean + diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/untrusted/untrusted_module.cpp b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/untrusted/untrusted_module.cpp new file mode 100644 index 0000000000..f4d2acdc38 --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXUntrustedModule/untrusted/untrusted_module.cpp @@ -0,0 +1 @@ +#include "$(baseName)_u.h" diff --git a/Linux_SGXEclipsePlugin/build_directory/sites/site.xml b/Linux_SGXEclipsePlugin/build_directory/sites/site.xml new file mode 100644 index 0000000000..a0a475351b --- /dev/null +++ b/Linux_SGXEclipsePlugin/build_directory/sites/site.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + This website hosts an evaluation version of the Eclipse Plug-in developed for Secure Guard Extensions Application development for Linux platforms. + + + + + + diff --git a/Linux_SGXEclipsePlugin/clean.sh b/Linux_SGXEclipsePlugin/clean.sh new file mode 100755 index 0000000000..0b3edca3d7 --- /dev/null +++ b/Linux_SGXEclipsePlugin/clean.sh @@ -0,0 +1,20 @@ +# clean input directories to make sure there's nothing left from previous run + +rm -rfv ./build_directory/features/com.intel.sgx.build.driver +rm -fv build_directory/*.properties +rm -fv build_directory/*.xml +rm -fv build_directory/plugins/com.intel.sgx/build.xml +rm -fv build_directory/plugins/com.intel.sgx.userguide/build.xml +rm -rfv build_directory/plugins/com.intel.sgx/bin +rm -rfv build_directory/plugins/com.intel.sgx.userguide/bin +rm -rfv build_directory/plugins/com.intel.sgx.source_1.0.0.* +rm -rfv build_directory/features/com.intel.sgx.source +rm -fv build_directory/features/com.intel.sgx.feature/build.xml +rm -fv build_directory/features/com.intel.sgx.feature/*.zip +rm -rfv build_directory/nestedJars +rm -rfv build_directory/updatesite/sgx-eclipse-plugin +find . -name "*.zip" | xargs rm -rfv +find . -name "javaCompiler*" | xargs rm -rfv +find . -name "@*" | xargs rm -rfv +find build_directory -maxdepth 1 -mindepth 1 | grep -v "features" | grep -v "plugins" | grep -v "sites" | grep -v "updatesite" | xargs rm -frv + diff --git a/Linux_SGXEclipsePlugin/readme.txt b/Linux_SGXEclipsePlugin/readme.txt new file mode 100644 index 0000000000..53b7c6241a --- /dev/null +++ b/Linux_SGXEclipsePlugin/readme.txt @@ -0,0 +1,21 @@ +The eclipse plugin build from commandline requires the following variables to be set + +$ECLIPSE_HOME - Path to eclipse home. In order to build the plugin eclipse needs to be installed. +$RELEASE_ID - The release id for the plugin. + +The plugin has been tested with the following Eclipse ADT version + +Build: v22.3.0-887826 + +The following plugins are pre-requisites to be installed in Eclipse before trying to build the plugin. + +1. Eclipse IDE for C/C++ Developers 4.5.1.20150917-1200 (tested_version) +2. Eclipse PDE Plug-in Developer Resources 3.11.1.v20150904-0345 (tested_version) + + +If the sgx eclipse plugin is already installed to eclipse and to build and install a newer version, uninstall the old version and start eclipse with the -clean option. +Then try to build the new version of the plugin and install it in eclipse. + +http://wiki.eclipse.org/FAQ_How_do_I_remove_a_plug-in%3F + +Once the build script is run, the folder build_directory/updatesite/sgx-eclipse-plugin contains the update site. This is the path that needs to be provided to the eclipse while doing installation. diff --git a/Linux_SGXEclipsePlugin/src/main/groovy/preprocessHtml.groovy b/Linux_SGXEclipsePlugin/src/main/groovy/preprocessHtml.groovy new file mode 100644 index 0000000000..99c0aa1168 --- /dev/null +++ b/Linux_SGXEclipsePlugin/src/main/groovy/preprocessHtml.groovy @@ -0,0 +1,34 @@ +import groovy.xml.MarkupBuilder +import groovy.xml.StreamingMarkupBuilder + + +println "Hello, Script!!!" + + + +def fragments = new XmlParser(false, true).parseText("") + +def resultFile = new File('/home/mlutescu/0_WORK/SGXUserGuide/developer_guide_eclipse_plugin/Output/WebHelp/Content/test.html') + +if (resultFile.exists()) { + resultFile.delete() +} + +def fltoc = new File('/home/mlutescu/0_WORK/SGXUserGuide/developer_guide_eclipse_plugin/Project/TOCs/Master.fltoc') +def toc = (new XmlParser()).parse(fltoc) +def contentDir = new File(fltoc, '../../../').canonicalPath + +def PrintWriter pw = new PrintWriter(new FileWriter(resultFile)) + + +toc.TocEntry['**'].each { tocEntry -> + def htmlFile = new File(contentDir, "${tocEntry.'@Link'}") + + + println htmlFile.text +} + + + +println groovy.xml.XmlUtil.serialize( fragments) + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..8e9a40f00d --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include buildenv.mk +.PHONY: all psw sdk clean rebuild sdk_install_pkg psw_install_pkg + +all: sdk psw + +psw: sdk + $(MAKE) -C psw/ + +sdk: + $(MAKE) -C sdk/ + +# Generate SE SDK Install package +sdk_install_pkg: sdk + ./linux/installer/bin/build-installpkg.sh sdk + +psw_install_pkg: psw + ./linux/installer/bin/build-installpkg.sh psw + +clean: + @$(MAKE) -C sdk/ clean + @$(MAKE) -C psw/ clean + @$(RM) -r $(ROOT_DIR)/build + @$(RM) -r linux/installer/bin/sgx_linux*.bin + +rebuild: clean all diff --git a/SampleCode/LocalAttestation/.cproject b/SampleCode/LocalAttestation/.cproject new file mode 100644 index 0000000000..b9fabf3067 --- /dev/null +++ b/SampleCode/LocalAttestation/.cproject @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleCode/LocalAttestation/.project b/SampleCode/LocalAttestation/.project new file mode 100644 index 0000000000..f1af7d8591 --- /dev/null +++ b/SampleCode/LocalAttestation/.project @@ -0,0 +1,28 @@ + + + SimpleEnclave + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.core.ccnature + com.intel.sgx.sgxnature + + diff --git a/SampleCode/LocalAttestation/App/App.cpp b/SampleCode/LocalAttestation/App/App.cpp new file mode 100644 index 0000000000..151d954992 --- /dev/null +++ b/SampleCode/LocalAttestation/App/App.cpp @@ -0,0 +1,446 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// App.cpp : Defines the entry point for the console application. +#include +#include +#include "../Enclave1/Enclave1_u.h" +#include "../Enclave2/Enclave2_u.h" +#include "../Enclave3/Enclave3_u.h" +#include "sgx_eid.h" +#include "sgx_urts.h" + +#define UNUSED(val) (void)(val) +#define TCHAR char +#define _TCHAR char +#define _T(str) str +#define scanf_s scanf +#define _tmain main + +extern std::mapg_enclave_id_map; + + +sgx_enclave_id_t e1_enclave_id = 0; +sgx_enclave_id_t e2_enclave_id = 0; +sgx_enclave_id_t e3_enclave_id = 0; + +#define ENCLAVE1_PATH "libenclave1.so" +#define ENCLAVE2_PATH "libenclave2.so" +#define ENCLAVE3_PATH "libenclave3.so" + +void waitForKeyPress() +{ + uint8_t ch; + printf("\n\nHit a key....\n"); + scanf_s("%c", &ch); +} + +uint32_t load_enclaves() +{ + uint32_t enclave_temp_no; + int ret, launch_token_updated; + sgx_launch_token_t launch_token; + + enclave_temp_no = 0; + + ret = sgx_create_enclave(ENCLAVE1_PATH, SGX_DEBUG_FLAG, &launch_token, &launch_token_updated, &e1_enclave_id, NULL); + if (ret != SGX_SUCCESS) { + return ret; + } + + enclave_temp_no++; + g_enclave_id_map.insert(std::pair(e1_enclave_id, enclave_temp_no)); + + ret = sgx_create_enclave(ENCLAVE2_PATH, SGX_DEBUG_FLAG, &launch_token, &launch_token_updated, &e2_enclave_id, NULL); + if (ret != SGX_SUCCESS) { + return ret; + } + + enclave_temp_no++; + g_enclave_id_map.insert(std::pair(e2_enclave_id, enclave_temp_no)); + + ret = sgx_create_enclave(ENCLAVE3_PATH, SGX_DEBUG_FLAG, &launch_token, &launch_token_updated, &e3_enclave_id, NULL); + if (ret != SGX_SUCCESS) { + return ret; + } + + enclave_temp_no++; + g_enclave_id_map.insert(std::pair(e3_enclave_id, enclave_temp_no)); + + + + return SGX_SUCCESS; +} + +int _tmain(int argc, _TCHAR* argv[]) +{ + uint32_t ret_status; + sgx_status_t status; + + UNUSED(argc); + UNUSED(argv); + + if(load_enclaves() != SGX_SUCCESS) + { + printf("\nLoad Enclave Failure"); + } + + printf("\nAvaliable Enclaves"); + printf("\nEnclave1 - EnclaveID %llx",e1_enclave_id); + printf("\nEnclave2 - EnclaveID %llx",e2_enclave_id); + printf("\nEnclave3 - EnclaveID %llx",e3_enclave_id); + + do + { + //Test Create session between Enclave1(Source) and Enclave2(Destination) + status = Enclave1_test_create_session(e1_enclave_id, &ret_status, e1_enclave_id, e2_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_create_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nSecure Channel Establishment between Source (E1) and Destination (E2) Enclaves successful !!!"); + } + else + { + printf("\nSession establishment and key exchange failure between Source (E1) and Destination (E2): Error code is %x", ret_status); + break; + } + } + + //Test Enclave to Enclave call between Enclave1(Source) and Enclave2(Destination) + status = Enclave1_test_enclave_to_enclave_call(e1_enclave_id, &ret_status, e1_enclave_id, e2_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_enclave_to_enclave_call Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nEnclave to Enclave Call between Source (E1) and Destination (E2) Enclaves successful !!!"); + } + else + { + printf("\n\nEnclave to Enclave Call failure between Source (E1) and Destination (E2): Error code is %x", ret_status); + break; + } + } + //Test message exchange between Enclave1(Source) and Enclave2(Destination) + status = Enclave1_test_message_exchange(e1_enclave_id, &ret_status, e1_enclave_id, e2_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_message_exchange Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nMessage Exchange between Source (E1) and Destination (E2) Enclaves successful !!!"); + } + else + { + printf("\n\nMessage Exchange failure between Source (E1) and Destination (E2): Error code is %x", ret_status); + break; + } + } + //Test Create session between Enclave1(Source) and Enclave3(Destination) + status = Enclave1_test_create_session(e1_enclave_id, &ret_status, e1_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_create_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nSecure Channel Establishment between Source (E1) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nSession establishment and key exchange failure between Source (E1) and Destination (E3): Error code is %x", ret_status); + break; + } + } + //Test Enclave to Enclave call between Enclave1(Source) and Enclave3(Destination) + status = Enclave1_test_enclave_to_enclave_call(e1_enclave_id, &ret_status, e1_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_enclave_to_enclave_call Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nEnclave to Enclave Call between Source (E1) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nEnclave to Enclave Call failure between Source (E1) and Destination (E3): Error code is %x", ret_status); + break; + } + } + //Test message exchange between Enclave1(Source) and Enclave3(Destination) + status = Enclave1_test_message_exchange(e1_enclave_id, &ret_status, e1_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_message_exchange Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nMessage Exchange between Source (E1) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nMessage Exchange failure between Source (E1) and Destination (E3): Error code is %x", ret_status); + break; + } + } + + //Test Create session between Enclave2(Source) and Enclave3(Destination) + status = Enclave2_test_create_session(e2_enclave_id, &ret_status, e2_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave2_test_create_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nSecure Channel Establishment between Source (E2) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nSession establishment and key exchange failure between Source (E2) and Destination (E3): Error code is %x", ret_status); + break; + } + } + //Test Enclave to Enclave call between Enclave2(Source) and Enclave3(Destination) + status = Enclave2_test_enclave_to_enclave_call(e2_enclave_id, &ret_status, e2_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave2_test_enclave_to_enclave_call Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nEnclave to Enclave Call between Source (E2) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nEnclave to Enclave Call failure between Source (E2) and Destination (E3): Error code is %x", ret_status); + break; + } + } + //Test message exchange between Enclave2(Source) and Enclave3(Destination) + status = Enclave2_test_message_exchange(e2_enclave_id, &ret_status, e2_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave2_test_message_exchange Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nMessage Exchange between Source (E2) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nMessage Exchange failure between Source (E2) and Destination (E3): Error code is %x", ret_status); + break; + } + } + + //Test Create session between Enclave3(Source) and Enclave1(Destination) + status = Enclave3_test_create_session(e3_enclave_id, &ret_status, e3_enclave_id, e1_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave3_test_create_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nSecure Channel Establishment between Source (E3) and Destination (E1) Enclaves successful !!!"); + } + else + { + printf("\n\nSession establishment and key exchange failure between Source (E3) and Destination (E1): Error code is %x", ret_status); + break; + } + } + //Test Enclave to Enclave call between Enclave3(Source) and Enclave1(Destination) + status = Enclave3_test_enclave_to_enclave_call(e3_enclave_id, &ret_status, e3_enclave_id, e1_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave3_test_enclave_to_enclave_call Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nEnclave to Enclave Call between Source (E3) and Destination (E1) Enclaves successful !!!"); + } + else + { + printf("\n\nEnclave to Enclave Call failure between Source (E3) and Destination (E1): Error code is %x", ret_status); + break; + } + } + //Test message exchange between Enclave3(Source) and Enclave1(Destination) + status = Enclave3_test_message_exchange(e3_enclave_id, &ret_status, e3_enclave_id, e1_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave3_test_message_exchange Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nMessage Exchange between Source (E3) and Destination (E1) Enclaves successful !!!"); + } + else + { + printf("\n\nMessage Exchange failure between Source (E3) and Destination (E1): Error code is %x", ret_status); + break; + } + } + + + //Test Closing Session between Enclave1(Source) and Enclave2(Destination) + status = Enclave1_test_close_session(e1_enclave_id, &ret_status, e1_enclave_id, e2_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_close_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nClose Session between Source (E1) and Destination (E2) Enclaves successful !!!"); + } + else + { + printf("\n\nClose session failure between Source (E1) and Destination (E2): Error code is %x", ret_status); + break; + } + } + //Test Closing Session between Enclave1(Source) and Enclave3(Destination) + status = Enclave1_test_close_session(e1_enclave_id, &ret_status, e1_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave1_test_close_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nClose Session between Source (E1) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nClose session failure between Source (E1) and Destination (E3): Error code is %x", ret_status); + break; + } + } + //Test Closing Session between Enclave2(Source) and Enclave3(Destination) + status = Enclave2_test_close_session(e2_enclave_id, &ret_status, e2_enclave_id, e3_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave2_test_close_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nClose Session between Source (E2) and Destination (E3) Enclaves successful !!!"); + } + else + { + printf("\n\nClose session failure between Source (E2) and Destination (E3): Error code is %x", ret_status); + break; + } + } + //Test Closing Session between Enclave3(Source) and Enclave1(Destination) + status = Enclave3_test_close_session(e3_enclave_id, &ret_status, e3_enclave_id, e1_enclave_id); + if (status!=SGX_SUCCESS) + { + printf("Enclave3_test_close_session Ecall failed: Error code is %x", status); + break; + } + else + { + if(ret_status==0) + { + printf("\n\nClose Session between Source (E3) and Destination (E1) Enclaves successful !!!"); + } + else + { + printf("\n\nClose session failure between Source (E3) and Destination (E1): Error code is %x", ret_status); + break; + } + } + +#pragma warning (push) +#pragma warning (disable : 4127) + }while(0); +#pragma warning (pop) + + sgx_destroy_enclave(e1_enclave_id); + sgx_destroy_enclave(e2_enclave_id); + sgx_destroy_enclave(e3_enclave_id); + + waitForKeyPress(); + + return 0; +} diff --git a/SampleCode/LocalAttestation/Enclave1/Enclave1.config.xml b/SampleCode/LocalAttestation/Enclave1/Enclave1.config.xml new file mode 100644 index 0000000000..436860dd50 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave1/Enclave1.config.xml @@ -0,0 +1,11 @@ + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/SampleCode/LocalAttestation/Enclave1/Enclave1.cpp b/SampleCode/LocalAttestation/Enclave1/Enclave1.cpp new file mode 100644 index 0000000000..c662516d1d --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave1/Enclave1.cpp @@ -0,0 +1,373 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// Enclave1.cpp : Defines the exported functions for the .so application +#include "sgx_eid.h" +#include "Enclave1_t.h" +#include "EnclaveMessageExchange.h" +#include "error_codes.h" +#include "Utility_E1.h" +#include "sgx_thread.h" +#include "sgx_dh.h" +#include + +#define UNUSED(val) (void)(val) + +std::mapg_src_session_info_map; + +static uint32_t e1_foo1_wrapper(ms_in_msg_exchange_t *ms, size_t param_lenth, char** resp_buffer, size_t* resp_length); + +//Function pointer table containing the list of functions that the enclave exposes +const struct { + size_t num_funcs; + const void* table[1]; +} func_table = { + 1, + { + (const void*)e1_foo1_wrapper, + } +}; + +//Makes use of the sample code function to establish a secure channel with the destination enclave (Test Vector) +uint32_t test_create_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + dh_session_t dest_session_info; + + //Core reference code function for creating a session + ke_status = create_session(src_enclave_id, dest_enclave_id, &dest_session_info); + + //Insert the session information into the map under the corresponding destination enclave id + if(ke_status == SUCCESS) + { + g_src_session_info_map.insert(std::pair(dest_enclave_id, dest_session_info)); + } + memset(&dest_session_info, 0, sizeof(dh_session_t)); + return ke_status; +} + +//Makes use of the sample code function to do an enclave to enclave call (Test Vector) +uint32_t test_enclave_to_enclave_call(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + uint32_t var1,var2; + uint32_t target_fn_id, msg_type; + char* marshalled_inp_buff; + size_t marshalled_inp_buff_len; + char* out_buff; + size_t out_buff_len; + dh_session_t *dest_session_info; + size_t max_out_buff_size; + char* retval; + + var1 = 0x4; + var2 = 0x5; + target_fn_id = 0; + msg_type = ENCLAVE_TO_ENCLAVE_CALL; + max_out_buff_size = 50; + + //Marshals the input parameters for calling function foo1 in Enclave2 into a input buffer + ke_status = marshal_input_parameters_e2_foo1(target_fn_id, msg_type, var1, var2, &marshalled_inp_buff, &marshalled_inp_buff_len); + if(ke_status != SUCCESS) + { + return ke_status; + } + + //Search the map for the session information associated with the destination enclave id of Enclave2 passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = &it->second; + } + else + { + SAFE_FREE(marshalled_inp_buff); + return INVALID_SESSION; + } + + //Core Reference Code function + ke_status = send_request_receive_response(src_enclave_id, dest_enclave_id, dest_session_info, marshalled_inp_buff, + marshalled_inp_buff_len, max_out_buff_size, &out_buff, &out_buff_len); + + + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + //Un-marshal the return value and output parameters from foo1 of Enclave 2 + ke_status = unmarshal_retval_and_output_parameters_e2_foo1(out_buff, &retval); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + SAFE_FREE(retval); + return SUCCESS; +} + +//Makes use of the sample code function to do a generic secret message exchange (Test Vector) +uint32_t test_message_exchange(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + uint32_t target_fn_id, msg_type; + char* marshalled_inp_buff; + size_t marshalled_inp_buff_len; + char* out_buff; + size_t out_buff_len; + dh_session_t *dest_session_info; + size_t max_out_buff_size; + char* secret_response; + uint32_t secret_data; + + target_fn_id = 0; + msg_type = MESSAGE_EXCHANGE; + max_out_buff_size = 50; + secret_data = 0x12345678; //Secret Data here is shown only for purpose of demonstration. + + //Marshals the secret data into a buffer + ke_status = marshal_message_exchange_request(target_fn_id, msg_type, secret_data, &marshalled_inp_buff, &marshalled_inp_buff_len); + if(ke_status != SUCCESS) + { + return ke_status; + } + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = &it->second; + } + else + { + SAFE_FREE(marshalled_inp_buff); + return INVALID_SESSION; + } + + //Core Reference Code function + ke_status = send_request_receive_response(src_enclave_id, dest_enclave_id, dest_session_info, marshalled_inp_buff, + marshalled_inp_buff_len, max_out_buff_size, &out_buff, &out_buff_len); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + //Un-marshal the secret response data + ke_status = umarshal_message_exchange_response(out_buff, &secret_response); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + SAFE_FREE(secret_response); + return SUCCESS; +} + + +//Makes use of the sample code function to close a current session +uint32_t test_close_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + dh_session_t dest_session_info; + ATTESTATION_STATUS ke_status = SUCCESS; + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = it->second; + } + else + { + return NULL; + } + + //Core reference code function for closing a session + ke_status = close_session(src_enclave_id, dest_enclave_id); + + //Erase the session information associated with the destination enclave id + g_src_session_info_map.erase(dest_enclave_id); + return ke_status; +} + +//Function that is used to verify the trust of the other enclave +//Each enclave can have its own way verifying the peer enclave identity +extern "C" uint32_t verify_peer_enclave_trust(sgx_dh_session_enclave_identity_t* peer_enclave_identity) +{ + if(!peer_enclave_identity) + { + return INVALID_PARAMETER_ERROR; + } + if(peer_enclave_identity->isv_prod_id != 0 || !(peer_enclave_identity->attributes.flags & SGX_FLAGS_INITTED)) + // || peer_enclave_identity->attributes.xfrm !=3)// || peer_enclave_identity->mr_signer != xx //TODO: To be hardcoded with values to check + { + return ENCLAVE_TRUST_ERROR; + } + else + { + return SUCCESS; + } +} + + +//Dispatcher function that calls the approriate enclave function based on the function id +//Each enclave can have its own way of dispatching the calls from other enclave +extern "C" uint32_t enclave_to_enclave_call_dispatcher(char* decrypted_data, + size_t decrypted_data_length, + char** resp_buffer, + size_t* resp_length) +{ + ms_in_msg_exchange_t *ms; + uint32_t (*fn1)(ms_in_msg_exchange_t *ms, size_t, char**, size_t*); + if(!decrypted_data || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + ms = (ms_in_msg_exchange_t *)decrypted_data; + if(ms->target_fn_id >= func_table.num_funcs) + { + return INVALID_PARAMETER_ERROR; + } + fn1 = (uint32_t (*)(ms_in_msg_exchange_t*, size_t, char**, size_t*))func_table.table[ms->target_fn_id]; + return fn1(ms, decrypted_data_length, resp_buffer, resp_length); +} + +//Operates on the input secret and generates the output secret +uint32_t get_message_exchange_response(uint32_t inp_secret_data) +{ + uint32_t secret_response; + + //User should use more complex encryption method to protect their secret, below is just a simple example + secret_response = inp_secret_data & 0x11111111; + + return secret_response; + +} + +//Generates the response from the request message +extern "C" uint32_t message_exchange_response_generator(char* decrypted_data, + char** resp_buffer, + size_t* resp_length) +{ + ms_in_msg_exchange_t *ms; + uint32_t inp_secret_data; + uint32_t out_secret_data; + if(!decrypted_data || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + ms = (ms_in_msg_exchange_t *)decrypted_data; + + if(umarshal_message_exchange_request(&inp_secret_data,ms) != SUCCESS) + return ATTESTATION_ERROR; + + out_secret_data = get_message_exchange_response(inp_secret_data); + + if(marshal_message_exchange_response(resp_buffer, resp_length, out_secret_data) != SUCCESS) + return MALLOC_ERROR; + + return SUCCESS; + +} + + +static uint32_t e1_foo1(external_param_struct_t *p_struct_var) +{ + if(!p_struct_var) + { + return INVALID_PARAMETER_ERROR; + } + (p_struct_var->var1)++; + (p_struct_var->var2)++; + (p_struct_var->p_internal_struct->ivar1)++; + (p_struct_var->p_internal_struct->ivar2)++; + + return (p_struct_var->var1 + p_struct_var->var2 + p_struct_var->p_internal_struct->ivar1 + p_struct_var->p_internal_struct->ivar2); +} + +//Function which is executed on request from the source enclave +static uint32_t e1_foo1_wrapper(ms_in_msg_exchange_t *ms, + size_t param_lenth, + char** resp_buffer, + size_t* resp_length) +{ + UNUSED(param_lenth); + + uint32_t ret; + size_t len_data, len_ptr_data; + external_param_struct_t *p_struct_var; + internal_param_struct_t internal_struct_var; + + if(!ms || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + + p_struct_var = (external_param_struct_t*)malloc(sizeof(external_param_struct_t)); + if(!p_struct_var) + return MALLOC_ERROR; + + p_struct_var->p_internal_struct = &internal_struct_var; + + if(unmarshal_input_parameters_e1_foo1(p_struct_var, ms) != SUCCESS)//can use the stack + { + SAFE_FREE(p_struct_var); + return ATTESTATION_ERROR; + } + + ret = e1_foo1(p_struct_var); + + len_data = sizeof(external_param_struct_t) - sizeof(p_struct_var->p_internal_struct); + len_ptr_data = sizeof(internal_struct_var); + + if(marshal_retval_and_output_parameters_e1_foo1(resp_buffer, resp_length, ret, p_struct_var, len_data, len_ptr_data) != SUCCESS) + { + SAFE_FREE(p_struct_var); + return MALLOC_ERROR; + } + SAFE_FREE(p_struct_var); + return SUCCESS; +} + diff --git a/SampleCode/LocalAttestation/Enclave1/Enclave1.edl b/SampleCode/LocalAttestation/Enclave1/Enclave1.edl new file mode 100644 index 0000000000..378965cd11 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave1/Enclave1.edl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave { + include "sgx_eid.h" + from "../LocalAttestationCode/LocalAttestationCode.edl" import *; + from "sgx_tstdc.edl" import *; + trusted{ + public uint32_t test_create_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_enclave_to_enclave_call(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_message_exchange(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_close_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + }; + +}; diff --git a/SampleCode/LocalAttestation/Enclave1/Enclave1_private.pem b/SampleCode/LocalAttestation/Enclave1/Enclave1_private.pem new file mode 100644 index 0000000000..75d7f88cb9 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave1/Enclave1_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4wIBAAKCAYEAuJh4w/KzndQhzEqwH6Ut/3BmOom5CN117KT1/cemEbDLPhn0 +c5yjAfe4NL1qtGqz0RTK9X9BBSi89b6BrsM9S6c2cUJaeYAPrAtJ+IuzN/5BAmmf +RXbPccETd7rHvDdQ9KBRjCipTx+H0D5nOB76S5PZPVrduwrCmSqVFmLNVWWfPYQx +YewbJ2QfEfioICZFYR0Jou38mJqDTl+CH0gLAuQ4n1kdpQ3VGymzt3oUiPzf5ImJ +oZh5HjarRRiWV+cyNyXYJTnx0dOtFQDgd8HhniagbRB0ZOIt6599JjMkWGkVP0Ni +U/NIlXG5musU35GfLB8MbTcxblMNm9sMYz1R8y/eAreoPTXUhtK8NG2TEywRh3UP +RF9/jM9WczjQXxJ3RznKOwNVwg4cRY2AOqD2vb1iGSqyc/WMzVULgfclkcScp75/ +Auz9Y6473CQvaxyrseSWHGwCG7KG1GxYE8Bg8T6OlYD4mzKggoMdwVLAzUepRaPZ +5hqRDZzbTGUxJ+GLAgEDAoIBgHsQUIKhzRPiwTLcdWpuHqpK7tGxJgXo+Uht+VPa +brZ13NQRTaJobKv6es3TnHhHIotjMfj/gK4bKKPUVnSCKN0aJEuBkaZVX8gHhqWy +d3qpgKxGai5PNPaAt6UnL9LPi03ANl1wcN9qWorURNAUpt0NO348k9IHLGYcY2RB +3jjuaikCy5adZ2+YFLalxWrELkC+BmyeqGW8V4mVAWowB1dC0Go7aRiz42dxInpR +YwX96phbsRZlphQkci4QZDqaIFg3ndzTO5bo704zaMcbWtEjmFrYRyb519tRoDkN +Y0rGwOxFANeRV5dSfGGLm7K5JztiuHN0nMu3PhY4LOV0SeZ4+5sYn0LzB2nyKqgy +/c3AA2OG34DEdGxxh94kD66iKFVPyJG38/gnu9CsGmrLl3n4fgutPEVIbPdSSjex +4Y9EQfcnqImPxTrpP9CqD208VPcQHD/uy8s9q3961Ew3RPdHMZ8amIJdXkOmPEme +KZ7SG+VENBaj8r038iq1mPzcWwKBwQDcvJg75LfVuKX+cWMrTO2+MFVcEFiZ/NB/ +gh7mgL6lCleROVa9P6iR2Wn6vHq8nP5BkChehm/rXEG78fgXEMoArimF7FrrICfI +4yB0opDJz/tWrE/62impN7OR8Ce+RQThFj4RTnibQEEVt++JMUXFiMKLdWDSpC2i +tNWnlTOb7d89bk0yk62IoLElCZK/MIMxkCHBKW6YgrmvlPJKQwpA6Z3wQbUpE6Rb +9f8xJfxZGEJPH0s3Ds9A0CVuEt8OOXcCgcEA1hXTHhhgmb2gIUJgIcvrpkDmiLux +EG6ZoyLt6h5QwzScS6KKU1mcoJyVDd0wlt7mEXrPYYHWUWPuvpTQ8/4ZGMw7FCZe +bakhnwRbw36FlLwRG35wCF6nQO1XFBKRGto15ivfTyDvMpJBdtNpET5NwT/ifDF3 +OWS7t6TGhtcfnvBad5S1AgGoAq+q/huFiBGpDbxJ+1xh0lNL5Z8nVypvPWomNpde +rpLuwRPEIb+GBfQ9Hp5AjRXVsPjKnkHsnl2NAoHBAJMoZX1DJTklw/72Qhzd89Qg +OOgK5bv94FUBae8Afxixj7YmOdN/xbaQ8VHS/H29/tZgGumu9UeS1n1L+roLMVXJ +cQPy50dqxTCXavhsYIaKp48diqc8G8YlImFKxSmDWJYO1AuJpbzVgLklSlt2LoOw +gbJOQIxtc8HN48UOImfz6ij0M3cNHlsVy24GYdTLAiEKwStw9GWse8pjTDGCBtXx +E/WBI3C3wuf5VMtuqDtlgYoU3M9fNNXgGPQMlLQmTwKBwQCOuTdpZZW708AWLEAW +h/Ju1e8F0nYK9GZswfPxaYsszb2HwbGM5mhrEw4JPiBklJlg/IpBATmLl/R/DeCi +qWYQiCdixD7zxhZqAufXqa5jKAtnqaAFlG+AnjoNYbYR5s6ZcpTfa0ohttZPN5tg +1DPWKpb9dk97mH0lGIRZ5L+/Sub6YyNWq8VXH8dUElkFYRtefYankuvhjN1Dv2+P +cZ9+RsQkZOnJt0nWDS1r1QQD+Ci/FCsIuTkgpdxpgUhpk7MCgcEAkfkmaBDb7DG2 +Kc39R6ZZuPnV10w+WOpph7ugwcguG/E0wGq+jFWv6HFckCPeHT4BNtOk8Dem/kPp +teF51eAuFWEefj2tScvlSBBPcnla+WzMWXrlxVnajTt73w+oT2Ql//WhgREpsNfx +SvU80YPVu4GJfl+hhxBifLx+0FM20OESW93qFRc3p040bNrDY9JIZuly/y5zaiBa +mRZF9H8P+x3Lu5AJpdXQEOMZ/XJ/xkoWWjbTojkmgOmmZSMLd5Te +-----END RSA PRIVATE KEY----- diff --git a/SampleCode/LocalAttestation/Enclave1/Utility_E1.cpp b/SampleCode/LocalAttestation/Enclave1/Utility_E1.cpp new file mode 100644 index 0000000000..9c2247b716 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave1/Utility_E1.cpp @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sgx_eid.h" +#include "EnclaveMessageExchange.h" +#include "error_codes.h" +#include "Utility_E1.h" +#include "stdlib.h" +#include "string.h" + +uint32_t marshal_input_parameters_e2_foo1(uint32_t target_fn_id, uint32_t msg_type, uint32_t var1, uint32_t var2, char** marshalled_buff, size_t* marshalled_buff_len) +{ + ms_in_msg_exchange_t *ms; + size_t param_len, ms_len; + char *temp_buff; + + param_len = sizeof(var1)+sizeof(var2); + temp_buff = (char*)malloc(param_len); + if(!temp_buff) + return MALLOC_ERROR; + + memcpy(temp_buff,&var1,sizeof(var1)); + memcpy(temp_buff+sizeof(var1),&var2,sizeof(var2)); + ms_len = sizeof(ms_in_msg_exchange_t) + param_len; + ms = (ms_in_msg_exchange_t *)malloc(ms_len); + if(!ms) + { + SAFE_FREE(temp_buff); + return MALLOC_ERROR; + } + ms->msg_type = msg_type; + ms->target_fn_id = target_fn_id; + ms->inparam_buff_len = (uint32_t)param_len; + memcpy(&ms->inparam_buff, temp_buff, param_len); + *marshalled_buff = (char*)ms; + *marshalled_buff_len = ms_len; + SAFE_FREE(temp_buff); + return SUCCESS; +} + +uint32_t unmarshal_retval_and_output_parameters_e2_foo1(char* out_buff, char** retval) +{ + size_t retval_len; + ms_out_msg_exchange_t *ms; + if(!out_buff) + return INVALID_PARAMETER_ERROR; + ms = (ms_out_msg_exchange_t *)out_buff; + retval_len = ms->retval_len; + *retval = (char*)malloc(retval_len); + if(!*retval) + return MALLOC_ERROR; + + memcpy(*retval, ms->ret_outparam_buff, retval_len); + return SUCCESS; +} + +uint32_t unmarshal_input_parameters_e1_foo1(external_param_struct_t *pstruct, ms_in_msg_exchange_t* ms) +{ + char* buff; + size_t len; + if(!pstruct || !ms) + return INVALID_PARAMETER_ERROR; + + buff = ms->inparam_buff; + len = ms->inparam_buff_len; + if(len != (sizeof(pstruct->var1)+sizeof(pstruct->var2)+sizeof(pstruct->p_internal_struct->ivar1)+sizeof(pstruct->p_internal_struct->ivar2))) + return ATTESTATION_ERROR; + + memcpy(&pstruct->var1, buff, sizeof(pstruct->var1)); + memcpy(&pstruct->var2, buff + sizeof(pstruct->var1), sizeof(pstruct->var2)); + memcpy(&pstruct->p_internal_struct->ivar1, buff+(sizeof(pstruct->var1)+sizeof(pstruct->var2)), sizeof(pstruct->p_internal_struct->ivar1)); + memcpy(&pstruct->p_internal_struct->ivar2, buff+(sizeof(pstruct->var1)+sizeof(pstruct->var2)+sizeof(pstruct->p_internal_struct->ivar1)), sizeof(pstruct->p_internal_struct->ivar2)); + + return SUCCESS; +} + +uint32_t marshal_retval_and_output_parameters_e1_foo1(char** resp_buffer, size_t* resp_length, uint32_t retval, external_param_struct_t *p_struct_var, size_t len_data, size_t len_ptr_data) +{ + ms_out_msg_exchange_t *ms; + size_t param_len, ms_len, ret_param_len;; + char *temp_buff; + int* addr; + char* struct_data; + size_t retval_len; + + if(!resp_length || !p_struct_var) + return INVALID_PARAMETER_ERROR; + + retval_len = sizeof(retval); + struct_data = (char*)p_struct_var; + param_len = len_data + len_ptr_data; + ret_param_len = param_len + retval_len; + addr = *(int **)(struct_data + len_data); + temp_buff = (char*)malloc(ret_param_len); + if(!temp_buff) + return MALLOC_ERROR; + + memcpy(temp_buff, &retval, sizeof(retval)); + memcpy(temp_buff + sizeof(retval), struct_data, len_data); + memcpy(temp_buff + sizeof(retval) + len_data, addr, len_ptr_data); + ms_len = sizeof(ms_out_msg_exchange_t) + ret_param_len; + ms = (ms_out_msg_exchange_t *)malloc(ms_len); + if(!ms) + { + SAFE_FREE(temp_buff); + return MALLOC_ERROR; + } + ms->retval_len = (uint32_t)retval_len; + ms->ret_outparam_buff_len = (uint32_t)ret_param_len; + memcpy(&ms->ret_outparam_buff, temp_buff, ret_param_len); + *resp_buffer = (char*)ms; + *resp_length = ms_len; + + SAFE_FREE(temp_buff); + return SUCCESS; +} + +uint32_t marshal_message_exchange_request(uint32_t target_fn_id, uint32_t msg_type, uint32_t secret_data, char** marshalled_buff, size_t* marshalled_buff_len) +{ + ms_in_msg_exchange_t *ms; + size_t secret_data_len, ms_len; + if(!marshalled_buff_len) + return INVALID_PARAMETER_ERROR; + secret_data_len = sizeof(secret_data); + ms_len = sizeof(ms_in_msg_exchange_t) + secret_data_len; + ms = (ms_in_msg_exchange_t *)malloc(ms_len); + if(!ms) + return MALLOC_ERROR; + + ms->msg_type = msg_type; + ms->target_fn_id = target_fn_id; + ms->inparam_buff_len = (uint32_t)secret_data_len; + memcpy(&ms->inparam_buff, &secret_data, secret_data_len); + *marshalled_buff = (char*)ms; + *marshalled_buff_len = ms_len; + return SUCCESS; +} + +uint32_t umarshal_message_exchange_request(uint32_t* inp_secret_data, ms_in_msg_exchange_t* ms) +{ + char* buff; + size_t len; + if(!inp_secret_data || !ms) + return INVALID_PARAMETER_ERROR; + buff = ms->inparam_buff; + len = ms->inparam_buff_len; + if(len != sizeof(uint32_t)) + return ATTESTATION_ERROR; + + memcpy(inp_secret_data, buff, sizeof(uint32_t)); + + return SUCCESS; +} + +uint32_t marshal_message_exchange_response(char** resp_buffer, size_t* resp_length, uint32_t secret_response) +{ + ms_out_msg_exchange_t *ms; + size_t secret_response_len, ms_len; + size_t retval_len, ret_param_len; + if(!resp_length) + return INVALID_PARAMETER_ERROR; + secret_response_len = sizeof(secret_response); + retval_len = secret_response_len; + ret_param_len = secret_response_len; + ms_len = sizeof(ms_out_msg_exchange_t) + ret_param_len; + ms = (ms_out_msg_exchange_t *)malloc(ms_len); + if(!ms) + return MALLOC_ERROR; + + ms->retval_len = (uint32_t)retval_len; + ms->ret_outparam_buff_len = (uint32_t)ret_param_len; + memcpy(&ms->ret_outparam_buff, &secret_response, secret_response_len); + *resp_buffer = (char*)ms; + *resp_length = ms_len; + return SUCCESS; +} + +uint32_t umarshal_message_exchange_response(char* out_buff, char** secret_response) +{ + size_t retval_len; + ms_out_msg_exchange_t *ms; + if(!out_buff) + return INVALID_PARAMETER_ERROR; + ms = (ms_out_msg_exchange_t *)out_buff; + retval_len = ms->retval_len; + *secret_response = (char*)malloc(retval_len); + if(!*secret_response) + { + return MALLOC_ERROR; + } + memcpy(*secret_response, ms->ret_outparam_buff, retval_len); + return SUCCESS; +} + diff --git a/SampleCode/LocalAttestation/Enclave1/Utility_E1.h b/SampleCode/LocalAttestation/Enclave1/Utility_E1.h new file mode 100644 index 0000000000..7af49b6814 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave1/Utility_E1.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef UTILITY_E1_H__ +#define UTILITY_E1_H__ + +#include "stdint.h" + +typedef struct _internal_param_struct_t +{ + uint32_t ivar1; + uint32_t ivar2; +}internal_param_struct_t; + +typedef struct _external_param_struct_t +{ + uint32_t var1; + uint32_t var2; + internal_param_struct_t *p_internal_struct; +}external_param_struct_t; + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t marshal_input_parameters_e2_foo1(uint32_t target_fn_id, uint32_t msg_type, uint32_t var1, uint32_t var2, char** marshalled_buff, size_t* marshalled_buff_len); +uint32_t unmarshal_retval_and_output_parameters_e2_foo1(char* out_buff, char** retval); +uint32_t unmarshal_input_parameters_e1_foo1(external_param_struct_t *pstruct, ms_in_msg_exchange_t* ms); +uint32_t marshal_retval_and_output_parameters_e1_foo1(char** resp_buffer, size_t* resp_length, uint32_t retval, external_param_struct_t *p_struct_var, size_t len_data, size_t len_ptr_data); +uint32_t marshal_message_exchange_request(uint32_t target_fn_id, uint32_t msg_type, uint32_t secret_data, char** marshalled_buff, size_t* marshalled_buff_len); +uint32_t umarshal_message_exchange_request(uint32_t* inp_secret_data, ms_in_msg_exchange_t* ms); +uint32_t marshal_message_exchange_response(char** resp_buffer, size_t* resp_length, uint32_t secret_response); +uint32_t umarshal_message_exchange_response(char* out_buff, char** secret_response); +#ifdef __cplusplus + } +#endif +#endif diff --git a/SampleCode/LocalAttestation/Enclave2/Enclave2.config.xml b/SampleCode/LocalAttestation/Enclave2/Enclave2.config.xml new file mode 100644 index 0000000000..3317e37a37 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave2/Enclave2.config.xml @@ -0,0 +1,11 @@ + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/SampleCode/LocalAttestation/Enclave2/Enclave2.cpp b/SampleCode/LocalAttestation/Enclave2/Enclave2.cpp new file mode 100644 index 0000000000..537957f68c --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave2/Enclave2.cpp @@ -0,0 +1,339 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// Enclave2.cpp : Defines the exported functions for the DLL application +#include "sgx_eid.h" +#include "Enclave2_t.h" +#include "EnclaveMessageExchange.h" +#include "error_codes.h" +#include "Utility_E2.h" +#include "sgx_thread.h" +#include "sgx_dh.h" +#include + +#define UNUSED(val) (void)(val) + +std::mapg_src_session_info_map; + +static uint32_t e2_foo1_wrapper(ms_in_msg_exchange_t *ms, size_t param_lenth, char** resp_buffer, size_t* resp_length); + +//Function pointer table containing the list of functions that the enclave exposes +const struct { + size_t num_funcs; + const void* table[1]; +} func_table = { + 1, + { + (const void*)e2_foo1_wrapper, + } +}; + +//Makes use of the sample code function to establish a secure channel with the destination enclave +uint32_t test_create_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + dh_session_t dest_session_info; + //Core reference code function for creating a session + ke_status = create_session(src_enclave_id, dest_enclave_id,&dest_session_info); + if(ke_status == SUCCESS) + { + //Insert the session information into the map under the corresponding destination enclave id + g_src_session_info_map.insert(std::pair(dest_enclave_id, dest_session_info)); + } + memset(&dest_session_info, 0, sizeof(dh_session_t)); + return ke_status; +} + +//Makes use of the sample code function to do an enclave to enclave call (Test Vector) +uint32_t test_enclave_to_enclave_call(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + param_struct_t *p_struct_var, struct_var; + uint32_t target_fn_id, msg_type; + char* marshalled_inp_buff; + size_t marshalled_inp_buff_len; + char* out_buff; + size_t out_buff_len; + dh_session_t *dest_session_info; + size_t max_out_buff_size; + char* retval; + + max_out_buff_size = 50; + target_fn_id = 0; + msg_type = ENCLAVE_TO_ENCLAVE_CALL; + + struct_var.var1 = 0x3; + struct_var.var2 = 0x4; + p_struct_var = &struct_var; + + //Marshals the input parameters for calling function foo1 in Enclave3 into a input buffer + ke_status = marshal_input_parameters_e3_foo1(target_fn_id, msg_type, p_struct_var, &marshalled_inp_buff, &marshalled_inp_buff_len); + if(ke_status != SUCCESS) + { + return ke_status; + } + + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = &it->second; + } + else + { + SAFE_FREE(marshalled_inp_buff); + return INVALID_SESSION; + } + + //Core Reference Code function + ke_status = send_request_receive_response(src_enclave_id, dest_enclave_id, dest_session_info, marshalled_inp_buff, + marshalled_inp_buff_len, max_out_buff_size, &out_buff, &out_buff_len); + + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + //Un-marshal the return value and output parameters from foo1 of Enclave3 + ke_status = unmarshal_retval_and_output_parameters_e3_foo1(out_buff, p_struct_var, &retval); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + SAFE_FREE(retval); + return SUCCESS; +} + +//Makes use of the sample code function to do a generic secret message exchange (Test Vector) +uint32_t test_message_exchange(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + uint32_t target_fn_id, msg_type; + char* marshalled_inp_buff; + size_t marshalled_inp_buff_len; + char* out_buff; + size_t out_buff_len; + dh_session_t *dest_session_info; + size_t max_out_buff_size; + char* secret_response; + uint32_t secret_data; + + target_fn_id = 0; + msg_type = MESSAGE_EXCHANGE; + max_out_buff_size = 50; + secret_data = 0x12345678; //Secret Data here is shown only for purpose of demonstration. + + //Marshals the secret data into a buffer + ke_status = marshal_message_exchange_request(target_fn_id, msg_type, secret_data, &marshalled_inp_buff, &marshalled_inp_buff_len); + if(ke_status != SUCCESS) + { + return ke_status; + } + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = &it->second; + } + else + { + SAFE_FREE(marshalled_inp_buff); + return INVALID_SESSION; + } + + //Core Reference Code function + ke_status = send_request_receive_response(src_enclave_id, dest_enclave_id, dest_session_info, marshalled_inp_buff, + marshalled_inp_buff_len, max_out_buff_size, &out_buff, &out_buff_len); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + //Un-marshal the secret response data + ke_status = umarshal_message_exchange_response(out_buff, &secret_response); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + SAFE_FREE(secret_response); + return SUCCESS; +} + + +//Makes use of the sample code function to close a current session +uint32_t test_close_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + dh_session_t dest_session_info; + ATTESTATION_STATUS ke_status = SUCCESS; + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = it->second; + } + else + { + return NULL; + } + //Core reference code function for closing a session + ke_status = close_session(src_enclave_id, dest_enclave_id); + + //Erase the session information associated with the destination enclave id + g_src_session_info_map.erase(dest_enclave_id); + return ke_status; +} + +//Function that is used to verify the trust of the other enclave +//Each enclave can have its own way verifying the peer enclave identity +extern "C" uint32_t verify_peer_enclave_trust(sgx_dh_session_enclave_identity_t* peer_enclave_identity) +{ + if(!peer_enclave_identity) + { + return INVALID_PARAMETER_ERROR; + } + if(peer_enclave_identity->isv_prod_id != 0 || !(peer_enclave_identity->attributes.flags & SGX_FLAGS_INITTED)) + // || peer_enclave_identity->attributes.xfrm !=3)// || peer_enclave_identity->mr_signer != xx //TODO: To be hardcoded with values to check + { + return ENCLAVE_TRUST_ERROR; + } + else + { + return SUCCESS; + } +} + +//Dispatch function that calls the approriate enclave function based on the function id +//Each enclave can have its own way of dispatching the calls from other enclave +extern "C" uint32_t enclave_to_enclave_call_dispatcher(char* decrypted_data, + size_t decrypted_data_length, + char** resp_buffer, + size_t* resp_length) +{ + ms_in_msg_exchange_t *ms; + uint32_t (*fn1)(ms_in_msg_exchange_t *ms, size_t, char**, size_t*); + if(!decrypted_data || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + ms = (ms_in_msg_exchange_t *)decrypted_data; + if(ms->target_fn_id >= func_table.num_funcs) + { + return INVALID_PARAMETER_ERROR; + } + fn1 = (uint32_t (*)(ms_in_msg_exchange_t*, size_t, char**, size_t*))func_table.table[ms->target_fn_id]; + return fn1(ms, decrypted_data_length, resp_buffer, resp_length); +} + +//Operates on the input secret and generates the output secret +uint32_t get_message_exchange_response(uint32_t inp_secret_data) +{ + uint32_t secret_response; + + //User should use more complex encryption method to protect their secret, below is just a simple example + secret_response = inp_secret_data & 0x11111111; + + return secret_response; + +} + +//Generates the response from the request message +extern "C" uint32_t message_exchange_response_generator(char* decrypted_data, + char** resp_buffer, + size_t* resp_length) +{ + ms_in_msg_exchange_t *ms; + uint32_t inp_secret_data; + uint32_t out_secret_data; + if(!decrypted_data || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + ms = (ms_in_msg_exchange_t *)decrypted_data; + + if(umarshal_message_exchange_request(&inp_secret_data,ms) != SUCCESS) + return ATTESTATION_ERROR; + + out_secret_data = get_message_exchange_response(inp_secret_data); + + if(marshal_message_exchange_response(resp_buffer, resp_length, out_secret_data) != SUCCESS) + return MALLOC_ERROR; + + return SUCCESS; + +} + +static uint32_t e2_foo1(uint32_t var1, uint32_t var2) +{ + return(var1 + var2); +} + +//Function which is executed on request from the source enclave +static uint32_t e2_foo1_wrapper(ms_in_msg_exchange_t *ms, + size_t param_lenth, + char** resp_buffer, + size_t* resp_length) +{ + UNUSED(param_lenth); + + uint32_t var1,var2,ret; + if(!ms || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + if(unmarshal_input_parameters_e2_foo1(&var1, &var2, ms) != SUCCESS) + return ATTESTATION_ERROR; + + ret = e2_foo1(var1, var2); + + if(marshal_retval_and_output_parameters_e2_foo1(resp_buffer, resp_length, ret) != SUCCESS ) + return MALLOC_ERROR; //can set resp buffer to null here + + return SUCCESS; +} diff --git a/SampleCode/LocalAttestation/Enclave2/Enclave2.edl b/SampleCode/LocalAttestation/Enclave2/Enclave2.edl new file mode 100644 index 0000000000..9ef5c33e4c --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave2/Enclave2.edl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +enclave { + include "sgx_eid.h" + from "../LocalAttestationCode/LocalAttestationCode.edl" import *; + from "sgx_tstdc.edl" import *; + trusted{ + public uint32_t test_create_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_enclave_to_enclave_call(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_message_exchange(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_close_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + }; +}; diff --git a/SampleCode/LocalAttestation/Enclave2/Enclave2_private.pem b/SampleCode/LocalAttestation/Enclave2/Enclave2_private.pem new file mode 100644 index 0000000000..529d07be35 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave2/Enclave2_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4gIBAAKCAYEAroOogvsj/fZDZY8XFdkl6dJmky0lRvnWMmpeH41Bla6U1qLZ +AmZuyIF+mQC/cgojIsrBMzBxb1kKqzATF4+XwPwgKz7fmiddmHyYz2WDJfAjIveJ +ZjdMjM4+EytGlkkJ52T8V8ds0/L2qKexJ+NBLxkeQLfV8n1mIk7zX7jguwbCG1Pr +nEMdJ3Sew20vnje+RsngAzdPChoJpVsWi/K7cettX/tbnre1DL02GXc5qJoQYk7b +3zkmhz31TgFrd9VVtmUGyFXAysuSAb3EN+5VnHGr0xKkeg8utErea2FNtNIgua8H +ONfm9Eiyaav1SVKzPHlyqLtcdxH3I8Wg7yqMsaprZ1n5A1v/levxnL8+It02KseD +5HqV4rf/cImSlCt3lpRg8U5E1pyFQ2IVEC/XTDMiI3c+AR+w2jSRB3Bwn9zJtFlW +KHG3m1xGI4ck+Lci1JvWWLXQagQSPtZTsubxTQNx1gsgZhgv1JHVZMdbVlAbbRMC +1nSuJNl7KPAS/VfzAgEDAoIBgHRXxaynbVP5gkO0ug6Qw/E27wzIw4SmjsxG6Wpe +K7kfDeRskKxESdsA/xCrKkwGwhcx1iIgS5+Qscd1Yg+1D9X9asd/P7waPmWoZd+Z +AhlKwhdPsO7PiF3e1AzHhGQwsUTt/Y/aSI1MpHBvy2/s1h9mFCslOUxTmWw0oj/Q +ldIEgWeNR72CE2+jFIJIyml6ftnb6qzPiga8Bm48ubKh0kvySOqnkmnPzgh+JBD6 +JnBmtZbfPT97bwTT+N6rnPqOOApvfHPf15kWI8yDbprG1l4OCUaIUH1AszxLd826 +5IPM+8gINLRDP1MA6azECPjTyHXhtnSIBZCyWSVkc05vYmNXYUNiXWMajcxW9M02 +wKzFELO8NCEAkaTPxwo4SCyIjUxiK1LbQ9h8PSy4c1+gGP4LAMR8xqP4QKg6zdu9 +osUGG/xRe/uufgTBFkcjqBHtK5L5VI0jeNIUAgW/6iNbYXjBMJ0GfauLs+g1VsOm +WfdgXzsb9DYdMa0OXXHypmV4GwKBwQDUwQj8RKJ6c8cT4vcWCoJvJF00+RFL+P3i +Gx2DLERxRrDa8AVGfqaCjsR+3vLgG8V/py+z+dxZYSqeB80Qeo6PDITcRKoeAYh9 +xlT3LJOS+k1cJcEmlbbO2IjLkTmzSwa80fWexKu8/Xv6vv15gpqYl1ngYoqJM3pd +vzmTIOi7MKSZ0WmEQavrZj8zK4endE3v0eAEeQ55j1GImbypSf7Idh7wOXtjZ7WD +Dg6yWDrri+AP/L3gClMj8wsAxMV4ZR8CgcEA0fzDHkFa6raVOxWnObmRoDhAtE0a +cjUj976NM5yyfdf2MrKy4/RhdTiPZ6b08/lBC/+xRfV3xKVGzacm6QjqjZrUpgHC +0LKiZaMtccCJjLtPwQd0jGQEnKfMFaPsnhOc5y8qVkCzVOSthY5qhz0XNotHHFmJ +gffVgB0iqrMTvSL7IA2yqqpOqNRlhaYhNl8TiFP3gIeMtVa9rZy31JPgT2uJ+kfo +gV7sdTPEjPWZd7OshGxWpT6QfVDj/T9T7L6tAoHBAI3WBf2DFvxNL2KXT2QHAZ9t +k3imC4f7U+wSE6zILaDZyzygA4RUbwG0gv8/TJVn2P/Eynf76DuWHGlaiLWnCbSz +Az2DHBQBBaku409zDQym3j1ugMRjzzSQWzJg0SIyBH3hTmnYcn3+Uqcp/lEBvGW6 +O+rsXFt3pukqJmIV8HzLGGaLm62BHUeZf3dyWm+i3p/hQAL7Xvu04QW70xuGqdr5 +afV7p5eaeQIJXyGQJ0eylV/90+qxjMKiB1XYg6WYvwKBwQCL/ddpgOdHJGN8uRom +e7Zq0Csi3hGheMKlKbN3vcxT5U7MdyHtTZZOJbTvxKNNUNYH/8uD+PqDGNneb29G +BfGzvI3EASyLIcGZF3OhKwZd0jUrWk2y7Vhob91jwp2+t73vdMbkKyI4mHOuXvGv +fg95si9oO7EBT+Oqvhccd2J+F1IVXncccYnF4u5ZGWt5lLewN/pVr7MjjykeaHqN +t+rfnQam2psA6fL4zS2zTmZPzR2tnY8Y1GBTi0Ko1OKd1HMCgcAb5cB/7/AQlhP9 +yQa04PLH9ygQkKKptZp7dy5WcWRx0K/hAHRoi2aw1wZqfm7VBNu2SLcs90kCCCxp +6C5sfJi6b8NpNbIPC+sc9wsFr7pGo9SFzQ78UlcWYK2Gu2FxlMjonhka5hvo4zvg +WxlpXKEkaFt3gLd92m/dMqBrHfafH7VwOJY2zT3WIpjwuk0ZzmRg5p0pG/svVQEH +NZmwRwlopysbR69B/n1nefJ84UO50fLh5s5Zr3gBRwbWNZyzhXk= +-----END RSA PRIVATE KEY----- diff --git a/SampleCode/LocalAttestation/Enclave2/Utility_E2.cpp b/SampleCode/LocalAttestation/Enclave2/Utility_E2.cpp new file mode 100644 index 0000000000..962c68f922 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave2/Utility_E2.cpp @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sgx_eid.h" +#include "EnclaveMessageExchange.h" +#include "error_codes.h" +#include "Utility_E2.h" +#include "stdlib.h" +#include "string.h" + +uint32_t marshal_input_parameters_e3_foo1(uint32_t target_fn_id, uint32_t msg_type, param_struct_t *p_struct_var, char** marshalled_buff, size_t* marshalled_buff_len) +{ + ms_in_msg_exchange_t *ms; + size_t param_len, ms_len; + char *temp_buff; + if(!p_struct_var || !marshalled_buff_len) + return INVALID_PARAMETER_ERROR; + param_len = sizeof(param_struct_t); + temp_buff = (char*)malloc(param_len); + if(!temp_buff) + return MALLOC_ERROR; + memcpy(temp_buff, p_struct_var, sizeof(param_struct_t)); //can be optimized + ms_len = sizeof(ms_in_msg_exchange_t) + param_len; + ms = (ms_in_msg_exchange_t *)malloc(ms_len); + if(!ms) + { + SAFE_FREE(temp_buff); + return MALLOC_ERROR; + } + ms->msg_type = msg_type; + ms->target_fn_id = target_fn_id; + ms->inparam_buff_len = (uint32_t)param_len; + memcpy(&ms->inparam_buff, temp_buff, param_len); + *marshalled_buff = (char*)ms; + *marshalled_buff_len = ms_len; + SAFE_FREE(temp_buff); + return SUCCESS; +} + +uint32_t unmarshal_retval_and_output_parameters_e3_foo1(char* out_buff, param_struct_t *p_struct_var, char** retval) +{ + size_t retval_len; + ms_out_msg_exchange_t *ms; + if(!out_buff) + return INVALID_PARAMETER_ERROR; + ms = (ms_out_msg_exchange_t *)out_buff; + retval_len = ms->retval_len; + *retval = (char*)malloc(retval_len); + if(!*retval) + { + return MALLOC_ERROR; + } + memcpy(*retval, ms->ret_outparam_buff, retval_len); + memcpy(&p_struct_var->var1, (ms->ret_outparam_buff) + retval_len, sizeof(p_struct_var->var1)); + memcpy(&p_struct_var->var2, (ms->ret_outparam_buff) + retval_len + sizeof(p_struct_var->var1), sizeof(p_struct_var->var2)); + return SUCCESS; +} + + +uint32_t unmarshal_input_parameters_e2_foo1(uint32_t* var1, uint32_t* var2, ms_in_msg_exchange_t* ms) +{ + char* buff; + size_t len; + if(!var1 || !var2 || !ms) + return INVALID_PARAMETER_ERROR; + + buff = ms->inparam_buff; + len = ms->inparam_buff_len; + + if(len != (sizeof(*var1) + sizeof(*var2))) + return ATTESTATION_ERROR; + + memcpy(var1, buff, sizeof(*var1)); + memcpy(var2, buff + sizeof(*var1), sizeof(*var2)); + + return SUCCESS; +} + +uint32_t marshal_retval_and_output_parameters_e2_foo1(char** resp_buffer, size_t* resp_length, uint32_t retval) +{ + ms_out_msg_exchange_t *ms; + size_t ret_param_len, ms_len; + char *temp_buff; + size_t retval_len; + if(!resp_length) + return INVALID_PARAMETER_ERROR; + retval_len = sizeof(retval); + ret_param_len = retval_len; //no out parameters + temp_buff = (char*)malloc(ret_param_len); + if(!temp_buff) + return MALLOC_ERROR; + + memcpy(temp_buff, &retval, sizeof(retval)); + ms_len = sizeof(ms_out_msg_exchange_t) + ret_param_len; + ms = (ms_out_msg_exchange_t *)malloc(ms_len); + if(!ms) + { + SAFE_FREE(temp_buff); + return MALLOC_ERROR; + } + ms->retval_len = (uint32_t)retval_len; + ms->ret_outparam_buff_len = (uint32_t)ret_param_len; + memcpy(&ms->ret_outparam_buff, temp_buff, ret_param_len); + *resp_buffer = (char*)ms; + *resp_length = ms_len; + SAFE_FREE(temp_buff); + return SUCCESS; +} + +uint32_t marshal_message_exchange_request(uint32_t target_fn_id, uint32_t msg_type, uint32_t secret_data, char** marshalled_buff, size_t* marshalled_buff_len) +{ + ms_in_msg_exchange_t *ms; + size_t secret_data_len, ms_len; + if(!marshalled_buff_len) + return INVALID_PARAMETER_ERROR; + secret_data_len = sizeof(secret_data); + ms_len = sizeof(ms_in_msg_exchange_t) + secret_data_len; + ms = (ms_in_msg_exchange_t *)malloc(ms_len); + if(!ms) + return MALLOC_ERROR; + + ms->msg_type = msg_type; + ms->target_fn_id = target_fn_id; + ms->inparam_buff_len = (uint32_t)secret_data_len; + memcpy(&ms->inparam_buff, &secret_data, secret_data_len); + *marshalled_buff = (char*)ms; + *marshalled_buff_len = ms_len; + return SUCCESS; +} + +uint32_t umarshal_message_exchange_request(uint32_t* inp_secret_data, ms_in_msg_exchange_t* ms) +{ + char* buff; + size_t len; + if(!inp_secret_data || !ms) + return INVALID_PARAMETER_ERROR; + buff = ms->inparam_buff; + len = ms->inparam_buff_len; + if(len != sizeof(uint32_t)) + return ATTESTATION_ERROR; + + memcpy(inp_secret_data, buff, sizeof(uint32_t)); + + return SUCCESS; +} + + +uint32_t marshal_message_exchange_response(char** resp_buffer, size_t* resp_length, uint32_t secret_response) +{ + ms_out_msg_exchange_t *ms; + size_t secret_response_len, ms_len; + size_t retval_len, ret_param_len; + if(!resp_length) + return INVALID_PARAMETER_ERROR; + secret_response_len = sizeof(secret_response); + retval_len = secret_response_len; + ret_param_len = secret_response_len; + ms_len = sizeof(ms_out_msg_exchange_t) + ret_param_len; + ms = (ms_out_msg_exchange_t *)malloc(ms_len); + if(!ms) + return MALLOC_ERROR; + ms->retval_len = (uint32_t)retval_len; + ms->ret_outparam_buff_len = (uint32_t)ret_param_len; + memcpy(&ms->ret_outparam_buff, &secret_response, secret_response_len); + *resp_buffer = (char*)ms; + *resp_length = ms_len; + return SUCCESS; +} + +uint32_t umarshal_message_exchange_response(char* out_buff, char** secret_response) +{ + size_t retval_len; + ms_out_msg_exchange_t *ms; + if(!out_buff) + return INVALID_PARAMETER_ERROR; + ms = (ms_out_msg_exchange_t *)out_buff; + retval_len = ms->retval_len; + *secret_response = (char*)malloc(retval_len); + if(!*secret_response) + { + return MALLOC_ERROR; + } + memcpy(*secret_response, ms->ret_outparam_buff, retval_len); + return SUCCESS; +} diff --git a/SampleCode/LocalAttestation/Enclave2/Utility_E2.h b/SampleCode/LocalAttestation/Enclave2/Utility_E2.h new file mode 100644 index 0000000000..17b88cdea2 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave2/Utility_E2.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef UTILITY_E2_H__ +#define UTILITY_E2_H__ +#include "stdint.h" + +typedef struct _param_struct_t +{ + uint32_t var1; + uint32_t var2; +}param_struct_t; + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t marshal_input_parameters_e3_foo1(uint32_t target_fn_id, uint32_t msg_type, param_struct_t *p_struct_var, char** marshalled_buff, size_t* marshalled_buff_len); +uint32_t unmarshal_retval_and_output_parameters_e3_foo1(char* out_buff, param_struct_t *p_struct_var, char** retval); +uint32_t unmarshal_input_parameters_e2_foo1(uint32_t* var1, uint32_t* var2, ms_in_msg_exchange_t* ms); +uint32_t marshal_retval_and_output_parameters_e2_foo1(char** resp_buffer, size_t* resp_length, uint32_t retval); +uint32_t marshal_message_exchange_request(uint32_t target_fn_id, uint32_t msg_type, uint32_t secret_data, char** marshalled_buff, size_t* marshalled_buff_len); +uint32_t umarshal_message_exchange_request(uint32_t* inp_secret_data, ms_in_msg_exchange_t* ms); +uint32_t marshal_message_exchange_response(char** resp_buffer, size_t* resp_length, uint32_t secret_response); +uint32_t umarshal_message_exchange_response(char* out_buff, char** secret_response); + +#ifdef __cplusplus + } +#endif +#endif + diff --git a/SampleCode/LocalAttestation/Enclave3/Enclave3.config.xml b/SampleCode/LocalAttestation/Enclave3/Enclave3.config.xml new file mode 100644 index 0000000000..436860dd50 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave3/Enclave3.config.xml @@ -0,0 +1,11 @@ + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/SampleCode/LocalAttestation/Enclave3/Enclave3.cpp b/SampleCode/LocalAttestation/Enclave3/Enclave3.cpp new file mode 100644 index 0000000000..cc15bc4aa7 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave3/Enclave3.cpp @@ -0,0 +1,366 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// Enclave3.cpp : Defines the exported functions for the DLL application +#include "sgx_eid.h" +#include "Enclave3_t.h" +#include "EnclaveMessageExchange.h" +#include "error_codes.h" +#include "Utility_E3.h" +#include "sgx_thread.h" +#include "sgx_dh.h" +#include + +#define UNUSED(val) (void)(val) + +std::mapg_src_session_info_map; + +static uint32_t e3_foo1_wrapper(ms_in_msg_exchange_t *ms, size_t param_lenth, char** resp_buffer, size_t* resp_length); + +//Function pointer table containing the list of functions that the enclave exposes +const struct { + size_t num_funcs; + const void* table[1]; +} func_table = { + 1, + { + (const void*)e3_foo1_wrapper, + } +}; + +//Makes use of the sample code function to establish a secure channel with the destination enclave +uint32_t test_create_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + dh_session_t dest_session_info; + //Core reference code function for creating a session + ke_status = create_session(src_enclave_id, dest_enclave_id,&dest_session_info); + if(ke_status == SUCCESS) + { + //Insert the session information into the map under the corresponding destination enclave id + g_src_session_info_map.insert(std::pair(dest_enclave_id, dest_session_info)); + } + memset(&dest_session_info, 0, sizeof(dh_session_t)); + return ke_status; +} + +//Makes use of the sample code function to do an enclave to enclave call (Test Vector) +uint32_t test_enclave_to_enclave_call(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + external_param_struct_t *p_struct_var, struct_var; + internal_param_struct_t internal_struct_var; + uint32_t target_fn_id, msg_type; + char* marshalled_inp_buff; + size_t marshalled_inp_buff_len; + char* out_buff; + size_t out_buff_len; + dh_session_t *dest_session_info; + size_t max_out_buff_size; + char* retval; + + max_out_buff_size = 50; + msg_type = ENCLAVE_TO_ENCLAVE_CALL; + target_fn_id = 0; + internal_struct_var.ivar1 = 0x5; + internal_struct_var.ivar2 = 0x6; + struct_var.var1 = 0x3; + struct_var.var2 = 0x4; + struct_var.p_internal_struct = &internal_struct_var; + p_struct_var = &struct_var; + + size_t len_data = sizeof(struct_var) - sizeof(struct_var.p_internal_struct); + size_t len_ptr_data = sizeof(internal_struct_var); + + //Marshals the input parameters for calling function foo1 in Enclave1 into a input buffer + ke_status = marshal_input_parameters_e1_foo1(target_fn_id, msg_type, p_struct_var, len_data, + len_ptr_data, &marshalled_inp_buff, &marshalled_inp_buff_len); + + if(ke_status != SUCCESS) + { + return ke_status; + } + + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = &it->second; + } + else + { + SAFE_FREE(marshalled_inp_buff); + return INVALID_SESSION; + } + + //Core Reference Code function + ke_status = send_request_receive_response(src_enclave_id, dest_enclave_id, dest_session_info, + marshalled_inp_buff, marshalled_inp_buff_len, max_out_buff_size, &out_buff, &out_buff_len); + + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + ////Un-marshal the return value and output parameters from foo1 of Enclave1 + ke_status = unmarshal_retval_and_output_parameters_e1_foo1(out_buff, p_struct_var, &retval); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + SAFE_FREE(retval); + return SUCCESS; +} + +//Makes use of the sample code function to do a generic secret message exchange (Test Vector) +uint32_t test_message_exchange(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + ATTESTATION_STATUS ke_status = SUCCESS; + uint32_t target_fn_id, msg_type; + char* marshalled_inp_buff; + size_t marshalled_inp_buff_len; + char* out_buff; + size_t out_buff_len; + dh_session_t *dest_session_info; + size_t max_out_buff_size; + char* secret_response; + uint32_t secret_data; + + target_fn_id = 0; + msg_type = MESSAGE_EXCHANGE; + max_out_buff_size = 50; + secret_data = 0x12345678; //Secret Data here is shown only for purpose of demonstration. + + //Marshals the parameters into a buffer + ke_status = marshal_message_exchange_request(target_fn_id, msg_type, secret_data, &marshalled_inp_buff, &marshalled_inp_buff_len); + if(ke_status != SUCCESS) + { + return ke_status; + } + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = &it->second; + } + else + { + SAFE_FREE(marshalled_inp_buff); + return INVALID_SESSION; + } + + //Core Reference Code function + ke_status = send_request_receive_response(src_enclave_id, dest_enclave_id, dest_session_info, marshalled_inp_buff, + marshalled_inp_buff_len, max_out_buff_size, &out_buff, &out_buff_len); + + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + //Un-marshal the secret response data + ke_status = umarshal_message_exchange_response(out_buff, &secret_response); + if(ke_status != SUCCESS) + { + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + return ke_status; + } + + SAFE_FREE(marshalled_inp_buff); + SAFE_FREE(out_buff); + SAFE_FREE(secret_response); + return SUCCESS; +} + + +//Makes use of the sample code function to close a current session +uint32_t test_close_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + dh_session_t dest_session_info; + ATTESTATION_STATUS ke_status = SUCCESS; + //Search the map for the session information associated with the destination enclave id passed in + std::map::iterator it = g_src_session_info_map.find(dest_enclave_id); + if(it != g_src_session_info_map.end()) + { + dest_session_info = it->second; + } + else + { + return NULL; + } + //Core reference code function for closing a session + ke_status = close_session(src_enclave_id, dest_enclave_id); + + //Erase the session information associated with the destination enclave id + g_src_session_info_map.erase(dest_enclave_id); + return ke_status; +} + +//Function that is used to verify the trust of the other enclave +//Each enclave can have its own way verifying the peer enclave identity +extern "C" uint32_t verify_peer_enclave_trust(sgx_dh_session_enclave_identity_t* peer_enclave_identity) +{ + if(!peer_enclave_identity) + { + return INVALID_PARAMETER_ERROR; + } + if(peer_enclave_identity->isv_prod_id != 0 || !(peer_enclave_identity->attributes.flags & SGX_FLAGS_INITTED)) + // || peer_enclave_identity->attributes.xfrm !=3)// || peer_enclave_identity->mr_signer != xx //TODO: To be hardcoded with values to check + { + return ENCLAVE_TRUST_ERROR; + } + else + { + return SUCCESS; + } +} + + +//Dispatch function that calls the approriate enclave function based on the function id +//Each enclave can have its own way of dispatching the calls from other enclave +extern "C" uint32_t enclave_to_enclave_call_dispatcher(char* decrypted_data, + size_t decrypted_data_length, + char** resp_buffer, + size_t* resp_length) +{ + ms_in_msg_exchange_t *ms; + uint32_t (*fn1)(ms_in_msg_exchange_t *ms, size_t, char**, size_t*); + if(!decrypted_data || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + ms = (ms_in_msg_exchange_t *)decrypted_data; + if(ms->target_fn_id >= func_table.num_funcs) + { + return INVALID_PARAMETER_ERROR; + } + fn1 = (uint32_t (*)(ms_in_msg_exchange_t*, size_t, char**, size_t*))func_table.table[ms->target_fn_id]; + return fn1(ms, decrypted_data_length, resp_buffer, resp_length); +} + +//Operates on the input secret and generates the output secret +uint32_t get_message_exchange_response(uint32_t inp_secret_data) +{ + uint32_t secret_response; + + //User should use more complex encryption method to protect their secret, below is just a simple example + secret_response = inp_secret_data & 0x11111111; + + return secret_response; + +} +//Generates the response from the request message +extern "C" uint32_t message_exchange_response_generator(char* decrypted_data, + char** resp_buffer, + size_t* resp_length) +{ + ms_in_msg_exchange_t *ms; + uint32_t inp_secret_data; + uint32_t out_secret_data; + if(!decrypted_data || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + ms = (ms_in_msg_exchange_t *)decrypted_data; + + if(umarshal_message_exchange_request(&inp_secret_data,ms) != SUCCESS) + return ATTESTATION_ERROR; + + out_secret_data = get_message_exchange_response(inp_secret_data); + + if(marshal_message_exchange_response(resp_buffer, resp_length, out_secret_data) != SUCCESS) + return MALLOC_ERROR; + + return SUCCESS; + +} + + +static uint32_t e3_foo1(param_struct_t *p_struct_var) +{ + if(!p_struct_var) + { + return INVALID_PARAMETER_ERROR; + } + p_struct_var->var1++; + p_struct_var->var2++; + + return(p_struct_var->var1 * p_struct_var->var2); +} + +//Function which is executed on request from the source enclave +static uint32_t e3_foo1_wrapper(ms_in_msg_exchange_t *ms, + size_t param_lenth, + char** resp_buffer, + size_t* resp_length) +{ + UNUSED(param_lenth); + + uint32_t ret; + param_struct_t *p_struct_var; + if(!ms || !resp_length) + { + return INVALID_PARAMETER_ERROR; + } + p_struct_var = (param_struct_t*)malloc(sizeof(param_struct_t)); + if(!p_struct_var) + return MALLOC_ERROR; + + if(unmarshal_input_parameters_e3_foo1(p_struct_var, ms) != SUCCESS) + { + SAFE_FREE(p_struct_var); + return ATTESTATION_ERROR; + } + + ret = e3_foo1(p_struct_var); + + if(marshal_retval_and_output_parameters_e3_foo1(resp_buffer, resp_length, ret, p_struct_var) != SUCCESS) + { + SAFE_FREE(p_struct_var); + return MALLOC_ERROR; + } + SAFE_FREE(p_struct_var); + return SUCCESS; +} diff --git a/SampleCode/LocalAttestation/Enclave3/Enclave3.edl b/SampleCode/LocalAttestation/Enclave3/Enclave3.edl new file mode 100644 index 0000000000..7584ee7945 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave3/Enclave3.edl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave { + include "sgx_eid.h" + from "../LocalAttestationCode/LocalAttestationCode.edl" import *; + from "sgx_tstdc.edl" import *; + trusted{ + public uint32_t test_create_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_enclave_to_enclave_call(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_message_exchange(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + public uint32_t test_close_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + }; +}; diff --git a/SampleCode/LocalAttestation/Enclave3/Enclave3_private.pem b/SampleCode/LocalAttestation/Enclave3/Enclave3_private.pem new file mode 100644 index 0000000000..b8ace89eb3 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave3/Enclave3_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4wIBAAKCAYEA0MvI9NpdP4GEqCvtlJQv00OybzTXzxBhPu/257VYt9cYw/ph +BN1WRyxBBcrZs15xmcvlb3xNmFGWs4w5oUgrFBNgi6g+CUOCsj0cM8xw7P/y3K0H +XaZUf+T3CXCp8NvlkZHzfdWAFA5lGGR9g6kmuk7SojE3h87Zm1KjPU/PvAe+BaMU +trlRr4gPNVnu19Vho60xwuswPxfl/pBFUIk7qWEUR3l2hiqWMeLgf3Ays/WSnkXA +uijwPt5g0hxsgIlyDrI3jKbf0zkFB56jvPwSykfU8aw4Gkbo5qSZxUAKnwH2L8Uf +yM6inBaaYtM79icRwsu45Yt6X0GAt7CSb/1TKBrnm5exmK1sug3YSQ/YuK1FYawU +vIaDD0YfzOndTNVBewA+Hr5xNPvqGJoRKHuGbyu2lI9jrKYpVxQWsmx38wnxF6kE +zX6N4m7KZiLeLpDdBVQtLuOzIdIE4wT3t/ckeqElxO/1Ut9bj765GcTTrYwMKHRw +ukWIH7ZtHtAjj0KzAgEDAoIBgQCLMoX4kZN/q63Fcp5jDXU3gnb0zeU0tZYp9U9F +I5B6j2XX/ECt6OQvctYD3JEiPvZmh+5KUt5li7nNCCZrhXINYkBdGtQGLQHMKL13 +3aCd//c9yK+TxDhVQ09boHFLPUO2YUz+jlVitENlmFOtG28m3zcWy3paieZnjGzT +iop9Wn6ubLh50OEfsAojkUnlOOvCc3aB8iAqD+6ptYOLBifGQLgvpk8EHGQhQer/ +oCHNTmG+2SsmxfV/Pus2vZ2rBkrUbZU0hwrnvKOIPhnt3Qwtmx9xsC67jF+MpWko +UisJXC27FAGz2gpIGMhBp35HEppwG9hhCuMQdK2g62bvweyr1tC4qOVdQrKvhksN +r6CMjS9eSXvmWdF7lU4oxStN0V56/LICSIsLbggUaxTPKhAVEgfTSqwEJoQuFA3Q +4GmgTydPhcRH1L/lhbWJqZQm7V1Gt+5i5J6iATD32uNQQ2iZi5GsUhr+jZC+WlE5 +6lS813cRNiaK52HIk62bG7IXOksCgcEA+6RxZhQ5GaCPYZNsk7TqxqsKopXKoYAr +2R4KWuexJTd+1kcNMk0ETX8OSgpY2cYL2uPFWmdutxPpLfpr8S2u92Da/Wxs70Ti +QSb0426ybTmnS5L7nOnGOHiddXILhW175liAszTeoR7nQ6vpr9YjfcnrXiB8bKIm +akft2DQoxrBPzEe9tA8gfkyDTsSG2j7kncSbvYRtkKcJOmmypotVU6uhRPSrSXCc +J59uBQkg6Bk4CKA1mz8ctG07MluFY0/ZAoHBANRpZlfIFl39gFmuEER7lb80GySO +J190LbqOca3dGOvAMsDgEAi6juJyX7ZNpbHFHj++LvmTtw9+kxhVDBcswS7304kt +7J2EfnGdctEZtXif1wiq30YWAp1tjRpQENKtt9wssmgcwgK39rZNiEHmStHGv3l+ +5TnKPKeuFCDnsLvi5lQYoK2wTYvZtsjf+Rnt7H17q90IV54pMjTS8BkGskCkKf2A +IYuaZkqX0T3cM6ovoYYDAU6rWL5rrYPLEwkbawKBwQCnwvZEDXtmawpBDPMNI0cv +HLHBuTHBAB07aVw8mnYYz6nkL14hiK2I/17cBuXmhAfnQoORmknPYptz/Ef2HnSk +6zyo8vNKLewrb03s9Hbze8TdDKe98S7QUGj49rJY86fu5asiIz8WFJotHUZ1OWz+ +hpzpav2dwW7xhUk6zXCEdYqIL9PNX2r+3azfLa88Ke2+gxJ+WEkLGgYm8SHEXOON +HRYt+HIw9b1vv56uBhXwENAFwCO81L3Nnid2565CNTsCgcEAjZuZj9q5k/5VkR61 +gv0Of3gSGF7E6k1z0bRLyT4QnSrMgJVgBdG0lvbqeYkZIS4UKn7J+7fPX6m3ZY4I +D3MrdKU3sMlIaQL+9mj3NhEjpb/ksHHqLrlXE55eEYq14cklPXMhmr3WrHqkeYkF +gUQx4S8qUP9De9wob8liwJp10pdEOBBrHnWJB+Z52z/7Zp6dqP0dPgWPvsYheIyg +EK8hgG1xU6rBB7xEMbqLfpLNHB/BBAIA3xzl1EfJAodiBhJHAoHAeTS2znDHYayI +TvK86tBAPVORiBVTSdRUONdGF3dipo24hyeyrI5MtiOoMc3sKWXnSTkDQWa3WiPx +qStBmmO/SbGTuz7T6+oOwGeMiYzYBe87Ayn8Y0KYYshFikieJbGusHjUlIGmCVPy +UHrDMYGwFGUGBwW47gBsnZa+YPHtxWCPDe/U80et2Trx0RXJJQPmupAVMSiJWObI +9k5gRU+xDqkHanyD1gkGGwhFTUNX94EJEOdQEWw3hxLnVtePoke/ +-----END RSA PRIVATE KEY----- diff --git a/SampleCode/LocalAttestation/Enclave3/Utility_E3.cpp b/SampleCode/LocalAttestation/Enclave3/Utility_E3.cpp new file mode 100644 index 0000000000..97cf9b0ce6 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave3/Utility_E3.cpp @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sgx_eid.h" +#include "EnclaveMessageExchange.h" +#include "error_codes.h" +#include "Utility_E3.h" +#include "stdlib.h" +#include "string.h" + +uint32_t marshal_input_parameters_e1_foo1(uint32_t target_fn_id, uint32_t msg_type, external_param_struct_t *p_struct_var, size_t len_data, size_t len_ptr_data, char** marshalled_buff, size_t* marshalled_buff_len) +{ + ms_in_msg_exchange_t *ms; + size_t param_len, ms_len; + char *temp_buff; + int* addr; + char* struct_data; + if(!p_struct_var || !marshalled_buff_len) + return INVALID_PARAMETER_ERROR; + struct_data = (char*)p_struct_var; + temp_buff = (char*)malloc(len_data + len_ptr_data); + if(!temp_buff) + return MALLOC_ERROR; + memcpy(temp_buff, struct_data, len_data); + addr = *(int **)(struct_data + len_data); + memcpy(temp_buff + len_data, addr, len_ptr_data); //can be optimized + param_len = len_data + len_ptr_data; + ms_len = sizeof(ms_in_msg_exchange_t) + param_len; + ms = (ms_in_msg_exchange_t *)malloc(ms_len); + if(!ms) + { + SAFE_FREE(temp_buff); + return MALLOC_ERROR; + } + ms->msg_type = msg_type; + ms->target_fn_id = target_fn_id; + ms->inparam_buff_len = (uint32_t)param_len; + memcpy(&ms->inparam_buff, temp_buff, param_len); + *marshalled_buff = (char*)ms; + *marshalled_buff_len = ms_len; + + SAFE_FREE(temp_buff); + return SUCCESS; +} + +uint32_t marshal_retval_and_output_parameters_e3_foo1(char** resp_buffer, size_t* resp_length, uint32_t retval, param_struct_t *p_struct_var) +{ + ms_out_msg_exchange_t *ms; + size_t ret_param_len, ms_len; + char *temp_buff; + size_t retval_len; + if(!resp_length || !p_struct_var) + return INVALID_PARAMETER_ERROR; + retval_len = sizeof(retval); + ret_param_len = sizeof(retval) + sizeof(param_struct_t); + temp_buff = (char*)malloc(ret_param_len); + if(!temp_buff) + return MALLOC_ERROR; + memcpy(temp_buff, &retval, sizeof(retval)); + memcpy(temp_buff + sizeof(retval), p_struct_var, sizeof(param_struct_t)); + ms_len = sizeof(ms_out_msg_exchange_t) + ret_param_len; + ms = (ms_out_msg_exchange_t *)malloc(ms_len); + if(!ms) + { + SAFE_FREE(temp_buff); + return MALLOC_ERROR; + } + ms->retval_len = (uint32_t)retval_len; + ms->ret_outparam_buff_len = (uint32_t)ret_param_len; + memcpy(&ms->ret_outparam_buff, temp_buff, ret_param_len); + *resp_buffer = (char*)ms; + *resp_length = ms_len; + SAFE_FREE(temp_buff); + return SUCCESS; +} + +uint32_t unmarshal_input_parameters_e3_foo1(param_struct_t *pstruct, ms_in_msg_exchange_t* ms) +{ + char* buff; + size_t len; + if(!pstruct || !ms) + return INVALID_PARAMETER_ERROR; + buff = ms->inparam_buff; + len = ms->inparam_buff_len; + + if(len != (sizeof(pstruct->var1) + sizeof(pstruct->var2))) + return ATTESTATION_ERROR; + + memcpy(&pstruct->var1, buff, sizeof(pstruct->var1)); + memcpy(&pstruct->var2, buff + sizeof(pstruct->var1), sizeof(pstruct->var2)); + + return SUCCESS; +} + + +uint32_t unmarshal_retval_and_output_parameters_e1_foo1(char* out_buff, external_param_struct_t *p_struct_var, char** retval) +{ + size_t retval_len; + ms_out_msg_exchange_t *ms; + if(!out_buff || !p_struct_var) + return INVALID_PARAMETER_ERROR; + ms = (ms_out_msg_exchange_t *)out_buff; + retval_len = ms->retval_len; + *retval = (char*)malloc(retval_len); + if(!*retval) + { + return MALLOC_ERROR; + } + memcpy(*retval, ms->ret_outparam_buff, retval_len); + memcpy(&p_struct_var->var1, (ms->ret_outparam_buff) + retval_len, sizeof(p_struct_var->var1)); + memcpy(&p_struct_var->var2, (ms->ret_outparam_buff) + retval_len + sizeof(p_struct_var->var1), sizeof(p_struct_var->var2)); + memcpy(&p_struct_var->p_internal_struct->ivar1, (ms->ret_outparam_buff) + retval_len + sizeof(p_struct_var->var1)+ sizeof(p_struct_var->var2), sizeof(p_struct_var->p_internal_struct->ivar1)); + memcpy(&p_struct_var->p_internal_struct->ivar2, (ms->ret_outparam_buff) + retval_len + sizeof(p_struct_var->var1)+ sizeof(p_struct_var->var2) + sizeof(p_struct_var->p_internal_struct->ivar1), sizeof(p_struct_var->p_internal_struct->ivar2)); + return SUCCESS; +} + + +uint32_t marshal_message_exchange_request(uint32_t target_fn_id, uint32_t msg_type, uint32_t secret_data, char** marshalled_buff, size_t* marshalled_buff_len) +{ + ms_in_msg_exchange_t *ms; + size_t secret_data_len, ms_len; + if(!marshalled_buff_len) + return INVALID_PARAMETER_ERROR; + secret_data_len = sizeof(secret_data); + ms_len = sizeof(ms_in_msg_exchange_t) + secret_data_len; + ms = (ms_in_msg_exchange_t *)malloc(ms_len); + if(!ms) + return MALLOC_ERROR; + + ms->msg_type = msg_type; + ms->target_fn_id = target_fn_id; + ms->inparam_buff_len = (uint32_t)secret_data_len; + memcpy(&ms->inparam_buff, &secret_data, secret_data_len); + + *marshalled_buff = (char*)ms; + *marshalled_buff_len = ms_len; + return SUCCESS; +} + +uint32_t umarshal_message_exchange_request(uint32_t* inp_secret_data, ms_in_msg_exchange_t* ms) +{ + char* buff; + size_t len; + if(!inp_secret_data || !ms) + return INVALID_PARAMETER_ERROR; + buff = ms->inparam_buff; + len = ms->inparam_buff_len; + + if(len != sizeof(uint32_t)) + return ATTESTATION_ERROR; + + memcpy(inp_secret_data, buff, sizeof(uint32_t)); + + return SUCCESS; +} + +uint32_t marshal_message_exchange_response(char** resp_buffer, size_t* resp_length, uint32_t secret_response) +{ + ms_out_msg_exchange_t *ms; + size_t secret_response_len, ms_len; + size_t retval_len, ret_param_len; + if(!resp_length) + return INVALID_PARAMETER_ERROR; + secret_response_len = sizeof(secret_response); + retval_len = secret_response_len; + ret_param_len = secret_response_len; + ms_len = sizeof(ms_out_msg_exchange_t) + ret_param_len; + ms = (ms_out_msg_exchange_t *)malloc(ms_len); + if(!ms) + return MALLOC_ERROR; + ms->retval_len = (uint32_t)retval_len; + ms->ret_outparam_buff_len = (uint32_t)ret_param_len; + memcpy(&ms->ret_outparam_buff, &secret_response, secret_response_len); + *resp_buffer = (char*)ms; + *resp_length = ms_len; + return SUCCESS; +} + +uint32_t umarshal_message_exchange_response(char* out_buff, char** secret_response) +{ + size_t retval_len; + ms_out_msg_exchange_t *ms; + if(!out_buff) + return INVALID_PARAMETER_ERROR; + ms = (ms_out_msg_exchange_t *)out_buff; + retval_len = ms->retval_len; + *secret_response = (char*)malloc(retval_len); + if(!*secret_response) + { + return MALLOC_ERROR; + } + memcpy(*secret_response, ms->ret_outparam_buff, retval_len); + return SUCCESS; +} + diff --git a/SampleCode/LocalAttestation/Enclave3/Utility_E3.h b/SampleCode/LocalAttestation/Enclave3/Utility_E3.h new file mode 100644 index 0000000000..83ba2d6f65 --- /dev/null +++ b/SampleCode/LocalAttestation/Enclave3/Utility_E3.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef UTILITY_E3_H__ +#define UTILITY_E3_H__ + +#include "stdint.h" + + +typedef struct _internal_param_struct_t +{ + uint32_t ivar1; + uint32_t ivar2; +}internal_param_struct_t; + +typedef struct _external_param_struct_t +{ + uint32_t var1; + uint32_t var2; + internal_param_struct_t *p_internal_struct; +}external_param_struct_t; + +typedef struct _param_struct_t +{ + uint32_t var1; + uint32_t var2; +}param_struct_t; + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t marshal_input_parameters_e1_foo1(uint32_t target_fn_id, uint32_t msg_type, external_param_struct_t *p_struct_var, size_t len_data, size_t len_ptr_data, char** marshalled_buff, size_t* marshalled_buff_len); +uint32_t unmarshal_retval_and_output_parameters_e1_foo1(char* out_buff, external_param_struct_t *p_struct_var, char** retval); +uint32_t unmarshal_input_parameters_e3_foo1(param_struct_t *pstruct, ms_in_msg_exchange_t* ms); +uint32_t marshal_retval_and_output_parameters_e3_foo1(char** resp_buffer, size_t* resp_length, uint32_t retval, param_struct_t *p_struct_var); +uint32_t marshal_message_exchange_request(uint32_t target_fn_id, uint32_t msg_type, uint32_t secret_data, char** marshalled_buff, size_t* marshalled_buff_len); +uint32_t umarshal_message_exchange_request(uint32_t* inp_secret_data, ms_in_msg_exchange_t* ms); +uint32_t marshal_message_exchange_response(char** resp_buffer, size_t* resp_length, uint32_t secret_response); +uint32_t umarshal_message_exchange_response(char* out_buff, char** secret_response); + +#ifdef __cplusplus + } +#endif +#endif diff --git a/SampleCode/LocalAttestation/Include/dh_session_protocol.h b/SampleCode/LocalAttestation/Include/dh_session_protocol.h new file mode 100644 index 0000000000..bc92ee4d6c --- /dev/null +++ b/SampleCode/LocalAttestation/Include/dh_session_protocol.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _DH_SESSION_PROROCOL_H +#define _DH_SESSION_PROROCOL_H + +#include "sgx_ecp_types.h" +#include "sgx_key.h" +#include "sgx_report.h" +#include "sgx_attributes.h" + +#define NONCE_SIZE 16 +#define MAC_SIZE 16 + +#define MSG_BUF_LEN sizeof(ec_pub_t)*2 +#define MSG_HASH_SZ 32 + + +//Session information structure +typedef struct _la_dh_session_t +{ + uint32_t session_id; //Identifies the current session + uint32_t status; //Indicates session is in progress, active or closed + union + { + struct + { + sgx_dh_session_t dh_session; + }in_progress; + + struct + { + sgx_key_128bit_t AEK; //Session Key + uint32_t counter; //Used to store Message Sequence Number + }active; + }; +} dh_session_t; + + +#endif diff --git a/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.cpp b/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.cpp new file mode 100644 index 0000000000..a32e3e2197 --- /dev/null +++ b/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.cpp @@ -0,0 +1,721 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_trts.h" +#include "sgx_utils.h" +#include "EnclaveMessageExchange.h" +#include "sgx_eid.h" +#include "error_codes.h" +#include "sgx_ecp_types.h" +#include "sgx_thread.h" +#include +#include "dh_session_protocol.h" +#include "sgx_dh.h" +#include "sgx_tcrypto.h" +#include "LocalAttestationCode_t.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t enclave_to_enclave_call_dispatcher(char* decrypted_data, size_t decrypted_data_length, char** resp_buffer, size_t* resp_length); +uint32_t message_exchange_response_generator(char* decrypted_data, char** resp_buffer, size_t* resp_length); +uint32_t verify_peer_enclave_trust(sgx_dh_session_enclave_identity_t* peer_enclave_identity); + +#ifdef __cplusplus +} +#endif + +#define MAX_SESSION_COUNT 16 + +//number of open sessions +uint32_t g_session_count = 0; + +ATTESTATION_STATUS generate_session_id(uint32_t *session_id); +ATTESTATION_STATUS end_session(sgx_enclave_id_t src_enclave_id); + +//Array of open session ids +session_id_tracker_t *g_session_id_tracker[MAX_SESSION_COUNT]; + +//Map between the source enclave id and the session information associated with that particular session +std::mapg_dest_session_info_map; + +//Create a session with the destination enclave +ATTESTATION_STATUS create_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id, + dh_session_t *session_info) +{ + sgx_dh_msg1_t dh_msg1; //Diffie-Hellman Message 1 + sgx_key_128bit_t dh_aek; // Session Key + sgx_dh_msg2_t dh_msg2; //Diffie-Hellman Message 2 + sgx_dh_msg3_t dh_msg3; //Diffie-Hellman Message 3 + uint32_t session_id; + uint32_t retstatus; + sgx_status_t status = SGX_SUCCESS; + sgx_dh_session_t sgx_dh_session; + sgx_dh_session_enclave_identity_t responder_identity; + + if(!session_info) + { + return INVALID_PARAMETER_ERROR; + } + + memset(&dh_aek,0, sizeof(sgx_key_128bit_t)); + memset(&dh_msg1, 0, sizeof(sgx_dh_msg1_t)); + memset(&dh_msg2, 0, sizeof(sgx_dh_msg2_t)); + memset(&dh_msg3, 0, sizeof(sgx_dh_msg3_t)); + memset(session_info, 0, sizeof(dh_session_t)); + + //Intialize the session as a session initiator + status = sgx_dh_init_session(SGX_DH_SESSION_INITIATOR, &sgx_dh_session); + if(SGX_SUCCESS != status) + { + return status; + } + + //Ocall to request for a session with the destination enclave and obtain session id and Message 1 if successful + status = session_request_ocall(&retstatus, src_enclave_id, dest_enclave_id, &dh_msg1, &session_id); + if (status == SGX_SUCCESS) + { + if ((ATTESTATION_STATUS)retstatus != SUCCESS) + return ((ATTESTATION_STATUS)retstatus); + } + else + { + return ATTESTATION_SE_ERROR; + } + //Process the message 1 obtained from desination enclave and generate message 2 + status = sgx_dh_initiator_proc_msg1(&dh_msg1, &dh_msg2, &sgx_dh_session); + if(SGX_SUCCESS != status) + { + return status; + } + + //Send Message 2 to Destination Enclave and get Message 3 in return + status = exchange_report_ocall(&retstatus, src_enclave_id, dest_enclave_id, &dh_msg2, &dh_msg3, session_id); + if (status == SGX_SUCCESS) + { + if ((ATTESTATION_STATUS)retstatus != SUCCESS) + return ((ATTESTATION_STATUS)retstatus); + } + else + { + return ATTESTATION_SE_ERROR; + } + + //Process Message 3 obtained from the destination enclave + status = sgx_dh_initiator_proc_msg3(&dh_msg3, &sgx_dh_session, &dh_aek, &responder_identity); + if(SGX_SUCCESS != status) + { + return status; + } + + // Verify the identity of the destination enclave + if(verify_peer_enclave_trust(&responder_identity) != SUCCESS) + { + return INVALID_SESSION; + } + + memcpy(session_info->active.AEK, &dh_aek, sizeof(sgx_key_128bit_t)); + session_info->session_id = session_id; + session_info->active.counter = 0; + session_info->status = ACTIVE; + memset(&dh_aek,0, sizeof(sgx_key_128bit_t)); + return status; +} + +//Handle the request from Source Enclave for a session +ATTESTATION_STATUS session_request(sgx_enclave_id_t src_enclave_id, + sgx_dh_msg1_t *dh_msg1, + uint32_t *session_id ) +{ + dh_session_t session_info; + sgx_dh_session_t sgx_dh_session; + sgx_status_t status = SGX_SUCCESS; + + if(!session_id || !dh_msg1) + { + return INVALID_PARAMETER_ERROR; + } + //Intialize the session as a session responder + status = sgx_dh_init_session(SGX_DH_SESSION_RESPONDER, &sgx_dh_session); + if(SGX_SUCCESS != status) + { + return status; + } + + //get a new SessionID + if ((status = (sgx_status_t)generate_session_id(session_id)) != SUCCESS) + return status; //no more sessions available + + //Allocate memory for the session id tracker + g_session_id_tracker[*session_id] = (session_id_tracker_t *)malloc(sizeof(session_id_tracker_t)); + if(!g_session_id_tracker[*session_id]) + { + return MALLOC_ERROR; + } + + memset(g_session_id_tracker[*session_id], 0, sizeof(session_id_tracker_t)); + g_session_id_tracker[*session_id]->session_id = *session_id; + session_info.status = IN_PROGRESS; + + //Generate Message1 that will be returned to Source Enclave + status = sgx_dh_responder_gen_msg1((sgx_dh_msg1_t*)dh_msg1, &sgx_dh_session); + if(SGX_SUCCESS != status) + { + SAFE_FREE(g_session_id_tracker[*session_id]); + return status; + } + memcpy(&session_info.in_progress.dh_session, &sgx_dh_session, sizeof(sgx_dh_session_t)); + //Store the session information under the correspoding source enlave id key + g_dest_session_info_map.insert(std::pair(src_enclave_id, session_info)); + + return status; +} + +//Verify Message 2, generate Message3 and exchange Message 3 with Source Enclave +ATTESTATION_STATUS exchange_report(sgx_enclave_id_t src_enclave_id, + sgx_dh_msg2_t *dh_msg2, + sgx_dh_msg3_t *dh_msg3, + uint32_t session_id) +{ + + sgx_key_128bit_t dh_aek; // Session key + dh_session_t *session_info; + ATTESTATION_STATUS status = SUCCESS; + sgx_dh_session_t sgx_dh_session; + sgx_dh_session_enclave_identity_t initiator_identity; + + if(!dh_msg2 || !dh_msg3) + { + return INVALID_PARAMETER_ERROR; + } + + memset(&dh_aek,0, sizeof(sgx_key_128bit_t)); + do + { + //Retreive the session information for the corresponding source enclave id + std::map::iterator it = g_dest_session_info_map.find(src_enclave_id); + if(it != g_dest_session_info_map.end()) + { + session_info = &it->second; + } + else + { + status = INVALID_SESSION; + break; + } + + if(session_info->status != IN_PROGRESS) + { + status = INVALID_SESSION; + break; + } + + memcpy(&sgx_dh_session, &session_info->in_progress.dh_session, sizeof(sgx_dh_session_t)); + + dh_msg3->msg3_body.additional_prop_length = 0; + //Process message 2 from source enclave and obtain message 3 + sgx_status_t se_ret = sgx_dh_responder_proc_msg2(dh_msg2, + dh_msg3, + &sgx_dh_session, + &dh_aek, + &initiator_identity); + if(SGX_SUCCESS != se_ret) + { + status = se_ret; + break; + } + + //Verify source enclave's trust + if(verify_peer_enclave_trust(&initiator_identity) != SUCCESS) + { + return INVALID_SESSION; + } + + //save the session ID, status and initialize the session nonce + session_info->session_id = session_id; + session_info->status = ACTIVE; + session_info->active.counter = 0; + memcpy(session_info->active.AEK, &dh_aek, sizeof(sgx_key_128bit_t)); + memset(&dh_aek,0, sizeof(sgx_key_128bit_t)); + g_session_count++; + }while(0); + + if(status != SUCCESS) + { + end_session(src_enclave_id); + } + + return status; +} + +//Request for the response size, send the request message to the destination enclave and receive the response message back +ATTESTATION_STATUS send_request_receive_response(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id, + dh_session_t *session_info, + char *inp_buff, + size_t inp_buff_len, + size_t max_out_buff_size, + char **out_buff, + size_t* out_buff_len) +{ + const uint8_t* plaintext; + uint32_t plaintext_length; + sgx_status_t status; + uint32_t retstatus; + secure_message_t* req_message; + secure_message_t* resp_message; + uint8_t *decrypted_data; + uint32_t decrypted_data_length; + uint32_t plain_text_offset; + uint8_t l_tag[TAG_SIZE]; + size_t max_resp_message_length; + plaintext = (const uint8_t*)(" "); + plaintext_length = 0; + + if(!session_info || !inp_buff) + { + return INVALID_PARAMETER_ERROR; + } + //Check if the nonce for the session has not exceeded 2^32-2 if so end session and start a new session + if(session_info->active.counter == ((uint32_t) - 2)) + { + close_session(src_enclave_id, dest_enclave_id); + create_session(src_enclave_id, dest_enclave_id, session_info); + } + + //Allocate memory for the AES-GCM request message + req_message = (secure_message_t*)malloc(sizeof(secure_message_t)+ inp_buff_len); + if(!req_message) + { + return MALLOC_ERROR; + } + + memset(req_message,0,sizeof(secure_message_t)+ inp_buff_len); + const uint32_t data2encrypt_length = (uint32_t)inp_buff_len; + //Set the payload size to data to encrypt length + req_message->message_aes_gcm_data.payload_size = data2encrypt_length; + + //Use the session nonce as the payload IV + memcpy(req_message->message_aes_gcm_data.reserved,&session_info->active.counter,sizeof(session_info->active.counter)); + + //Set the session ID of the message to the current session id + req_message->session_id = session_info->session_id; + + //Prepare the request message with the encrypted payload + status = sgx_rijndael128GCM_encrypt(&session_info->active.AEK, (uint8_t*)inp_buff, data2encrypt_length, + reinterpret_cast(&(req_message->message_aes_gcm_data.payload)), + reinterpret_cast(&(req_message->message_aes_gcm_data.reserved)), + sizeof(req_message->message_aes_gcm_data.reserved), plaintext, plaintext_length, + &(req_message->message_aes_gcm_data.payload_tag)); + + if(SGX_SUCCESS != status) + { + SAFE_FREE(req_message); + return status; + } + + //Allocate memory for the response payload to be copied + *out_buff = (char*)malloc(max_out_buff_size); + if(!*out_buff) + { + SAFE_FREE(req_message); + return MALLOC_ERROR; + } + + memset(*out_buff, 0, max_out_buff_size); + + //Allocate memory for the response message + resp_message = (secure_message_t*)malloc(sizeof(secure_message_t)+ max_out_buff_size); + if(!resp_message) + { + SAFE_FREE(req_message); + return MALLOC_ERROR; + } + + memset(resp_message, 0, sizeof(secure_message_t)+ max_out_buff_size); + + //Ocall to send the request to the Destination Enclave and get the response message back + status = send_request_ocall(&retstatus, src_enclave_id, dest_enclave_id, req_message, + (sizeof(secure_message_t)+ inp_buff_len), max_out_buff_size, + resp_message, (sizeof(secure_message_t)+ max_out_buff_size)); + if (status == SGX_SUCCESS) + { + if ((ATTESTATION_STATUS)retstatus != SUCCESS) + { + SAFE_FREE(req_message); + SAFE_FREE(resp_message); + return ((ATTESTATION_STATUS)retstatus); + } + } + else + { + SAFE_FREE(req_message); + SAFE_FREE(resp_message); + return ATTESTATION_SE_ERROR; + } + + max_resp_message_length = sizeof(secure_message_t)+ max_out_buff_size; + + if(sizeof(resp_message) > max_resp_message_length) + { + SAFE_FREE(req_message); + SAFE_FREE(resp_message); + return INVALID_PARAMETER_ERROR; + } + + //Code to process the response message from the Destination Enclave + + decrypted_data_length = resp_message->message_aes_gcm_data.payload_size; + plain_text_offset = decrypted_data_length; + decrypted_data = (uint8_t*)malloc(decrypted_data_length); + if(!decrypted_data) + { + SAFE_FREE(req_message); + SAFE_FREE(resp_message); + return MALLOC_ERROR; + } + memset(&l_tag, 0, 16); + + memset(decrypted_data, 0, decrypted_data_length); + + //Decrypt the response message payload + status = sgx_rijndael128GCM_decrypt(&session_info->active.AEK, resp_message->message_aes_gcm_data.payload, + decrypted_data_length, decrypted_data, + reinterpret_cast(&(resp_message->message_aes_gcm_data.reserved)), + sizeof(resp_message->message_aes_gcm_data.reserved), &(resp_message->message_aes_gcm_data.payload[plain_text_offset]), plaintext_length, + &resp_message->message_aes_gcm_data.payload_tag); + + if(SGX_SUCCESS != status) + { + SAFE_FREE(req_message); + SAFE_FREE(decrypted_data); + SAFE_FREE(resp_message); + return status; + } + + // Verify if the nonce obtained in the response is equal to the session nonce + 1 (Prevents replay attacks) + if(*(resp_message->message_aes_gcm_data.reserved) != (session_info->active.counter + 1 )) + { + SAFE_FREE(req_message); + SAFE_FREE(resp_message); + SAFE_FREE(decrypted_data); + return INVALID_PARAMETER_ERROR; + } + + //Update the value of the session nonce in the source enclave + session_info->active.counter = session_info->active.counter + 1; + + memcpy(out_buff_len, &decrypted_data_length, sizeof(decrypted_data_length)); + memcpy(*out_buff, decrypted_data, decrypted_data_length); + + SAFE_FREE(decrypted_data); + SAFE_FREE(req_message); + SAFE_FREE(resp_message); + return SUCCESS; + + +} + +//Process the request from the Source enclave and send the response message back to the Source enclave +ATTESTATION_STATUS generate_response(sgx_enclave_id_t src_enclave_id, + secure_message_t* req_message, + size_t req_message_size, + size_t max_payload_size, + secure_message_t* resp_message, + size_t resp_message_size) +{ + const uint8_t* plaintext; + uint32_t plaintext_length; + uint8_t *decrypted_data; + uint32_t decrypted_data_length; + uint32_t plain_text_offset; + ms_in_msg_exchange_t * ms; + size_t resp_data_length; + size_t resp_message_calc_size; + char* resp_data; + uint8_t l_tag[TAG_SIZE]; + size_t header_size, expected_payload_size; + dh_session_t *session_info; + secure_message_t* temp_resp_message; + uint32_t ret; + sgx_status_t status; + + plaintext = (const uint8_t*)(" "); + plaintext_length = 0; + + if(!req_message || !resp_message) + { + return INVALID_PARAMETER_ERROR; + } + + //Get the session information from the map corresponding to the source enclave id + std::map::iterator it = g_dest_session_info_map.find(src_enclave_id); + if(it != g_dest_session_info_map.end()) + { + session_info = &it->second; + } + else + { + return INVALID_SESSION; + } + + if(session_info->status != ACTIVE) + { + return INVALID_SESSION; + } + + //Set the decrypted data length to the payload size obtained from the message + decrypted_data_length = req_message->message_aes_gcm_data.payload_size; + + header_size = sizeof(secure_message_t); + expected_payload_size = req_message_size - header_size; + + //Verify the size of the payload + if(expected_payload_size != decrypted_data_length) + return INVALID_PARAMETER_ERROR; + + memset(&l_tag, 0, 16); + plain_text_offset = decrypted_data_length; + decrypted_data = (uint8_t*)malloc(decrypted_data_length); + if(!decrypted_data) + { + return MALLOC_ERROR; + } + + memset(decrypted_data, 0, decrypted_data_length); + + //Decrypt the request message payload from source enclave + status = sgx_rijndael128GCM_decrypt(&session_info->active.AEK, req_message->message_aes_gcm_data.payload, + decrypted_data_length, decrypted_data, + reinterpret_cast(&(req_message->message_aes_gcm_data.reserved)), + sizeof(req_message->message_aes_gcm_data.reserved), &(req_message->message_aes_gcm_data.payload[plain_text_offset]), plaintext_length, + &req_message->message_aes_gcm_data.payload_tag); + + if(SGX_SUCCESS != status) + { + SAFE_FREE(decrypted_data); + return status; + } + + //Casting the decrypted data to the marshaling structure type to obtain type of request (generic message exchange/enclave to enclave call) + ms = (ms_in_msg_exchange_t *)decrypted_data; + + + // Verify if the nonce obtained in the request is equal to the session nonce + if((uint32_t)*(req_message->message_aes_gcm_data.reserved) != session_info->active.counter || *(req_message->message_aes_gcm_data.reserved) > ((2^32)-2)) + { + SAFE_FREE(decrypted_data); + return INVALID_PARAMETER_ERROR; + } + + if(ms->msg_type == MESSAGE_EXCHANGE) + { + //Call the generic secret response generator for message exchange + ret = message_exchange_response_generator((char*)decrypted_data, &resp_data, &resp_data_length); + if(ret !=0) + { + SAFE_FREE(decrypted_data); + SAFE_FREE(resp_data); + return INVALID_SESSION; + } + } + else if(ms->msg_type == ENCLAVE_TO_ENCLAVE_CALL) + { + //Call the destination enclave's dispatcher to call the appropriate function in the destination enclave + ret = enclave_to_enclave_call_dispatcher((char*)decrypted_data, decrypted_data_length, &resp_data, &resp_data_length); + if(ret !=0) + { + SAFE_FREE(decrypted_data); + SAFE_FREE(resp_data); + return INVALID_SESSION; + } + } + else + { + SAFE_FREE(decrypted_data); + return INVALID_REQUEST_TYPE_ERROR; + } + + + if(resp_data_length > max_payload_size) + { + SAFE_FREE(resp_data); + SAFE_FREE(decrypted_data); + return OUT_BUFFER_LENGTH_ERROR; + } + + resp_message_calc_size = sizeof(secure_message_t)+ resp_data_length; + + if(resp_message_calc_size > resp_message_size) + { + SAFE_FREE(resp_data); + SAFE_FREE(decrypted_data); + return OUT_BUFFER_LENGTH_ERROR; + } + + //Code to build the response back to the Source Enclave + temp_resp_message = (secure_message_t*)malloc(resp_message_calc_size); + if(!temp_resp_message) + { + SAFE_FREE(resp_data); + SAFE_FREE(decrypted_data); + return MALLOC_ERROR; + } + + memset(temp_resp_message,0,sizeof(secure_message_t)+ resp_data_length); + const uint32_t data2encrypt_length = (uint32_t)resp_data_length; + temp_resp_message->session_id = session_info->session_id; + temp_resp_message->message_aes_gcm_data.payload_size = data2encrypt_length; + + //Increment the Session Nonce (Replay Protection) + session_info->active.counter = session_info->active.counter + 1; + + //Set the response nonce as the session nonce + memcpy(&temp_resp_message->message_aes_gcm_data.reserved,&session_info->active.counter,sizeof(session_info->active.counter)); + + //Prepare the response message with the encrypted payload + status = sgx_rijndael128GCM_encrypt(&session_info->active.AEK, (uint8_t*)resp_data, data2encrypt_length, + reinterpret_cast(&(temp_resp_message->message_aes_gcm_data.payload)), + reinterpret_cast(&(temp_resp_message->message_aes_gcm_data.reserved)), + sizeof(temp_resp_message->message_aes_gcm_data.reserved), plaintext, plaintext_length, + &(temp_resp_message->message_aes_gcm_data.payload_tag)); + + if(SGX_SUCCESS != status) + { + SAFE_FREE(resp_data); + SAFE_FREE(decrypted_data); + SAFE_FREE(temp_resp_message); + return status; + } + + memset(resp_message, 0, sizeof(secure_message_t)+ resp_data_length); + memcpy(resp_message, temp_resp_message, sizeof(secure_message_t)+ resp_data_length); + + SAFE_FREE(decrypted_data); + SAFE_FREE(resp_data); + SAFE_FREE(temp_resp_message); + + return SUCCESS; +} + +//Close a current session +ATTESTATION_STATUS close_session(sgx_enclave_id_t src_enclave_id, + sgx_enclave_id_t dest_enclave_id) +{ + sgx_status_t status; + + uint32_t retstatus; + + //Ocall to ask the destination enclave to end the session + status = end_session_ocall(&retstatus, src_enclave_id, dest_enclave_id); + if (status == SGX_SUCCESS) + { + if ((ATTESTATION_STATUS)retstatus != SUCCESS) + return ((ATTESTATION_STATUS)retstatus); + } + else + { + return ATTESTATION_SE_ERROR; + } + return SUCCESS; +} + +//Respond to the request from the Source Enclave to close the session +ATTESTATION_STATUS end_session(sgx_enclave_id_t src_enclave_id) +{ + ATTESTATION_STATUS status = SUCCESS; + int i; + dh_session_t session_info; + uint32_t session_id; + + //Get the session information from the map corresponding to the source enclave id + std::map::iterator it = g_dest_session_info_map.find(src_enclave_id); + if(it != g_dest_session_info_map.end()) + { + session_info = it->second; + } + else + { + return INVALID_SESSION; + } + + session_id = session_info.session_id; + //Erase the session information for the current session + g_dest_session_info_map.erase(src_enclave_id); + + //Update the session id tracker + if (g_session_count > 0) + { + //check if session exists + for (i=1; i <= MAX_SESSION_COUNT; i++) + { + if(g_session_id_tracker[i-1] != NULL && g_session_id_tracker[i-1]->session_id == session_id) + { + memset(g_session_id_tracker[i-1], 0, sizeof(session_id_tracker_t)); + SAFE_FREE(g_session_id_tracker[i-1]); + g_session_count--; + break; + } + } + } + + return status; + +} + + +//Returns a new sessionID for the source destination session +ATTESTATION_STATUS generate_session_id(uint32_t *session_id) +{ + ATTESTATION_STATUS status = SUCCESS; + + if(!session_id) + { + return INVALID_PARAMETER_ERROR; + } + //if the session structure is untintialized, set that as the next session ID + for (int i = 0; i < MAX_SESSION_COUNT; i++) + { + if (g_session_id_tracker[i] == NULL) + { + *session_id = i; + return status; + } + } + + status = NO_AVAILABLE_SESSION_ERROR; + + return status; + +} diff --git a/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.h b/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.h new file mode 100644 index 0000000000..c16a24656e --- /dev/null +++ b/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "datatypes.h" +#include "sgx_eid.h" +#include "sgx_trts.h" +#include +#include "dh_session_protocol.h" + +#ifndef LOCALATTESTATION_H_ +#define LOCALATTESTATION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t SGXAPI create_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, dh_session_t *p_session_info); +uint32_t SGXAPI send_request_receive_response(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, dh_session_t *p_session_info, char *inp_buff, size_t inp_buff_len, size_t max_out_buff_size, char **out_buff, size_t* out_buff_len); +uint32_t SGXAPI close_session(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SampleCode/LocalAttestation/LocalAttestationCode/LocalAttestationCode.edl b/SampleCode/LocalAttestation/LocalAttestationCode/LocalAttestationCode.edl new file mode 100644 index 0000000000..8e401ee843 --- /dev/null +++ b/SampleCode/LocalAttestation/LocalAttestationCode/LocalAttestationCode.edl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave { + include "sgx_eid.h" + include "datatypes.h" + include "../Include/dh_session_protocol.h" + trusted{ + public uint32_t session_request(sgx_enclave_id_t src_enclave_id, [out] sgx_dh_msg1_t *dh_msg1, [out] uint32_t *session_id); + public uint32_t exchange_report(sgx_enclave_id_t src_enclave_id, [in] sgx_dh_msg2_t *dh_msg2, [out] sgx_dh_msg3_t *dh_msg3, uint32_t session_id); + public uint32_t generate_response(sgx_enclave_id_t src_enclave_id, [in, size = req_message_size] secure_message_t* req_message, size_t req_message_size, size_t max_payload_size, [out, size=resp_message_size] secure_message_t* resp_message, size_t resp_message_size ); + public uint32_t end_session(sgx_enclave_id_t src_enclave_id); + }; + + untrusted{ + uint32_t session_request_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, [out] sgx_dh_msg1_t *dh_msg1,[out] uint32_t *session_id); + uint32_t exchange_report_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, [in] sgx_dh_msg2_t *dh_msg2, [out] sgx_dh_msg3_t *dh_msg3, uint32_t session_id); + uint32_t send_request_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, [in, size = req_message_size] secure_message_t* req_message, size_t req_message_size, size_t max_payload_size, [out, size=resp_message_size] secure_message_t* resp_message, size_t resp_message_size); + uint32_t end_session_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + }; +}; diff --git a/SampleCode/LocalAttestation/LocalAttestationCode/datatypes.h b/SampleCode/LocalAttestation/LocalAttestationCode/datatypes.h new file mode 100644 index 0000000000..1c198aa141 --- /dev/null +++ b/SampleCode/LocalAttestation/LocalAttestationCode/datatypes.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sgx_report.h" +#include "sgx_eid.h" +#include "sgx_ecp_types.h" +#include "sgx_dh.h" +#include "sgx_tseal.h" + +#ifndef DATATYPES_H_ +#define DATATYPES_H_ + +#define DH_KEY_SIZE 20 +#define NONCE_SIZE 16 +#define MAC_SIZE 16 +#define MAC_KEY_SIZE 16 +#define PADDING_SIZE 16 + +#define TAG_SIZE 16 +#define IV_SIZE 12 + +#define DERIVE_MAC_KEY 0x0 +#define DERIVE_SESSION_KEY 0x1 +#define DERIVE_VK1_KEY 0x3 +#define DERIVE_VK2_KEY 0x4 + +#define CLOSED 0x0 +#define IN_PROGRESS 0x1 +#define ACTIVE 0x2 + +#define MESSAGE_EXCHANGE 0x0 +#define ENCLAVE_TO_ENCLAVE_CALL 0x1 + +#define INVALID_ARGUMENT -2 ///< Invalid function argument +#define LOGIC_ERROR -3 ///< Functional logic error +#define FILE_NOT_FOUND -4 ///< File not found + +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} + +#define VMC_ATTRIBUTE_MASK 0xFFFFFFFFFFFFFFCB + +typedef uint8_t dh_nonce[NONCE_SIZE]; +typedef uint8_t cmac_128[MAC_SIZE]; + +#pragma pack(push, 1) + +//Format of the AES-GCM message being exchanged between the source and the destination enclaves +typedef struct _secure_message_t +{ + uint32_t session_id; //Session ID identifyting the session to which the message belongs + sgx_aes_gcm_data_t message_aes_gcm_data; +}secure_message_t; + +//Format of the input function parameter structure +typedef struct _ms_in_msg_exchange_t { + uint32_t msg_type; //Type of Call E2E or general message exchange + uint32_t target_fn_id; //Function Id to be called in Destination. Is valid only when msg_type=ENCLAVE_TO_ENCLAVE_CALL + uint32_t inparam_buff_len; //Length of the serialized input parameters + char inparam_buff[]; //Serialized input parameters +} ms_in_msg_exchange_t; + +//Format of the return value and output function parameter structure +typedef struct _ms_out_msg_exchange_t { + uint32_t retval_len; //Length of the return value + uint32_t ret_outparam_buff_len; //Length of the serialized return value and output parameters + char ret_outparam_buff[]; //Serialized return value and output parameters +} ms_out_msg_exchange_t; + +//Session Tracker to generate session ids +typedef struct _session_id_tracker_t +{ + uint32_t session_id; +}session_id_tracker_t; + +#pragma pack(pop) + +#endif diff --git a/SampleCode/LocalAttestation/LocalAttestationCode/error_codes.h b/SampleCode/LocalAttestation/LocalAttestationCode/error_codes.h new file mode 100644 index 0000000000..0bb2a25cf4 --- /dev/null +++ b/SampleCode/LocalAttestation/LocalAttestationCode/error_codes.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef ERROR_CODES_H_ +#define ERROR_CODES_H_ + +typedef uint32_t ATTESTATION_STATUS; + +#define SUCCESS 0x00 +#define INVALID_PARAMETER 0xE1 +#define VALID_SESSION 0xE2 +#define INVALID_SESSION 0xE3 +#define ATTESTATION_ERROR 0xE4 +#define ATTESTATION_SE_ERROR 0xE5 +#define IPP_ERROR 0xE6 +#define NO_AVAILABLE_SESSION_ERROR 0xE7 +#define MALLOC_ERROR 0xE8 +#define ERROR_TAG_MISMATCH 0xE9 +#define OUT_BUFFER_LENGTH_ERROR 0xEA +#define INVALID_REQUEST_TYPE_ERROR 0xEB +#define INVALID_PARAMETER_ERROR 0xEC +#define ENCLAVE_TRUST_ERROR 0xED +#define ENCRYPT_DECRYPT_ERROR 0xEE +#define DUPLICATE_SESSION 0xEF +#endif diff --git a/SampleCode/LocalAttestation/Makefile b/SampleCode/LocalAttestation/Makefile new file mode 100644 index 0000000000..eaacfc8ffe --- /dev/null +++ b/SampleCode/LocalAttestation/Makefile @@ -0,0 +1,297 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +######## SGX SDK Settings ######## + +SGX_SDK ?= /opt/intel/sgxsdk +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## Library Settings ######## + +Trust_Lib_Name := libLocalAttestation_Trusted.a +TrustLib_Cpp_Files := $(wildcard LocalAttestationCode/*.cpp) +TrustLib_Cpp_Objects := $(TrustLib_Cpp_Files:.cpp=.o) +TrustLib_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I$(SGX_SDK)/include/epid -I./Include +TrustLib_Compile_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector -std=c++03 -nostdinc++ $(TrustLib_Include_Paths) + +UnTrustLib_Name := libLocalAttestation_unTrusted.a +UnTrustLib_Cpp_Files := $(wildcard Untrusted_LocalAttestation/*.cpp) +UnTrustLib_Cpp_Objects := $(UnTrustLib_Cpp_Files:.cpp=.o) +UnTrustLib_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/ippcp -I./Include -I./LocalAttestationCode +UnTrustLib_Compile_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes -std=c++11 $(UnTrustLib_Include_Paths) + +######## App Settings ######## + +ifneq ($(SGX_MODE), HW) + Urts_Library_Name := sgx_urts_sim +else + Urts_Library_Name := sgx_urts +endif + +App_Cpp_Files := $(wildcard App/*.cpp) +App_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/ippcp -I./Include -I./LocalAttestationCode + +App_Compile_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_Compile_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_Compile_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_Compile_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Link_Flags := $(SGX_COMMON_CFLAGS) -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name) -L. -lpthread -lLocalAttestation_unTrusted + +ifneq ($(SGX_MODE), HW) + App_Link_Flags += -lsgx_uae_service_sim +else + App_Link_Flags += -lsgx_uae_service +endif + +App_Cpp_Objects := $(App_Cpp_Files:.cpp=.o) +App_Name := app + +######## Enclave Settings ######## + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif +Crypto_Library_Name := sgx_tcrypto + +Enclave_Cpp_Files_1 := $(wildcard Enclave1/*.cpp) +Enclave_Cpp_Files_2 := $(wildcard Enclave2/*.cpp) +Enclave_Cpp_Files_3 := $(wildcard Enclave3/*.cpp) +Enclave_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I./LocalAttestationCode -I./Include + +Enclave_Compile_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) +Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -L. -lLocalAttestation_Trusted -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 + +Enclave_Cpp_Objects_1 := $(Enclave_Cpp_Files_1:.cpp=.o) +Enclave_Cpp_Objects_2 := $(Enclave_Cpp_Files_2:.cpp=.o) +Enclave_Cpp_Objects_3 := $(Enclave_Cpp_Files_3:.cpp=.o) + +Enclave_Name_1 := libenclave1.so +Enclave_Name_2 := libenclave2.so +Enclave_Name_3 := libenclave3.so + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + +ifeq ($(Build_Mode), HW_RELEASE) +all: $(Trust_Lib_Name) $(UnTrustLib_Name) Enclave1.so Enclave2.so Enclave3.so $(App_Name) + @echo "The project has been built in release hardware mode." + @echo "Please sign the enclaves (Enclave1.so, Enclave2.so, Enclave3.so) first with your signing keys before you run the $(App_Name) to launch and access the enclave." + @echo "To sign the enclaves use the following commands:" + @echo " $(SGX_ENCLAVE_SIGNER) sign -key -enclave Enclave1.so -out <$(Enclave_Name_1)> -config Enclave1/Enclave1.config.xml" + @echo " $(SGX_ENCLAVE_SIGNER) sign -key -enclave Enclave2.so -out <$(Enclave_Name_2)> -config Enclave2/Enclave2.config.xml" + @echo " $(SGX_ENCLAVE_SIGNER) sign -key -enclave Enclave3.so -out <$(Enclave_Name_3)> -config Enclave3/Enclave3.config.xml" + @echo "You can also sign the enclaves using an external signing tool. See User's Guide for more details." + @echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW." +else +all: $(Trust_Lib_Name) $(UnTrustLib_Name) $(Enclave_Name_1) $(Enclave_Name_2) $(Enclave_Name_3) $(App_Name) +endif + +######## Library Objects ######## + +LocalAttestationCode/LocalAttestationCode_t.c LocalAttestationCode/LocalAttestationCode_t.h : $(SGX_EDGER8R) LocalAttestationCode/LocalAttestationCode.edl + @cd LocalAttestationCode && $(SGX_EDGER8R) --trusted ../LocalAttestationCode/LocalAttestationCode.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +LocalAttestationCode/LocalAttestationCode_t.o: LocalAttestationCode/LocalAttestationCode_t.c + @$(CC) $(TrustLib_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +LocalAttestationCode/%.o: LocalAttestationCode/%.cpp LocalAttestationCode/LocalAttestationCode_t.h + @$(CXX) $(TrustLib_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(Trust_Lib_Name): LocalAttestationCode/LocalAttestationCode_t.o $(TrustLib_Cpp_Objects) + @$(AR) rcs $@ $^ + @echo "GEN => $@" + +Untrusted_LocalAttestation/%.o: Untrusted_LocalAttestation/%.cpp + @$(CXX) $(UnTrustLib_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +$(UnTrustLib_Name): $(UnTrustLib_Cpp_Objects) + @$(AR) rcs $@ $^ + @echo "GEN => $@" + +######## App Objects ######## +Enclave1/Enclave1_u.c Enclave1/Enclave1_u.h: $(SGX_EDGER8R) Enclave1/Enclave1.edl + @cd Enclave1 && $(SGX_EDGER8R) --use-prefix --untrusted ../Enclave1/Enclave1.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +App/Enclave1_u.o: Enclave1/Enclave1_u.c + @$(CC) $(App_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +Enclave2/Enclave2_u.c Enclave2/Enclave2_u.h: $(SGX_EDGER8R) Enclave2/Enclave2.edl + @cd Enclave2 && $(SGX_EDGER8R) --use-prefix --untrusted ../Enclave2/Enclave2.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +App/Enclave2_u.o: Enclave2/Enclave2_u.c + @$(CC) $(App_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +Enclave3/Enclave3_u.c Enclave3/Enclave3_u.h: $(SGX_EDGER8R) Enclave3/Enclave3.edl + @cd Enclave3 && $(SGX_EDGER8R) --use-prefix --untrusted ../Enclave3/Enclave3.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +App/Enclave3_u.o: Enclave3/Enclave3_u.c + @$(CC) $(App_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +App/%.o: App/%.cpp Enclave1/Enclave1_u.h Enclave2/Enclave2_u.h Enclave3/Enclave3_u.h + @$(CXX) $(App_Compile_Flags) -c $< -o $@ + @echo "CXX <= $<" + +$(App_Name): App/Enclave1_u.o App/Enclave2_u.o App/Enclave3_u.o $(App_Cpp_Objects) $(UnTrustLib_Name) + @$(CXX) $^ -o $@ $(App_Link_Flags) + @echo "LINK => $@" + + +######## Enclave Objects ######## + +Enclave1/Enclave1_t.c Enclave1/Enclave1_t.h: $(SGX_EDGER8R) Enclave1/Enclave1.edl + @cd Enclave1 && $(SGX_EDGER8R) --use-prefix --trusted ../Enclave1/Enclave1.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +Enclave1/Enclave1_t.o: Enclave1/Enclave1_t.c + @$(CC) $(Enclave_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +Enclave1/%.o: Enclave1/%.cpp Enclave1/Enclave1_t.h + @$(CXX) -std=c++03 -nostdinc++ $(Enclave_Compile_Flags) -c $< -o $@ + @echo "CXX <= $<" + +Enclave1.so: Enclave1/Enclave1_t.o $(Enclave_Cpp_Objects_1) $(Trust_Lib_Name) + @$(CXX) Enclave1/Enclave1_t.o $(Enclave_Cpp_Objects_1) -o $@ $(Enclave_Link_Flags) + @echo "LINK => $@" + +$(Enclave_Name_1): Enclave1.so + @$(SGX_ENCLAVE_SIGNER) sign -key Enclave1/Enclave1_private.pem -enclave Enclave1.so -out $@ -config Enclave1/Enclave1.config.xml + @echo "SIGN => $@" + +Enclave2/Enclave2_t.c: $(SGX_EDGER8R) Enclave2/Enclave2.edl + @cd Enclave2 && $(SGX_EDGER8R) --use-prefix --trusted ../Enclave2/Enclave2.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +Enclave2/Enclave2_t.o: Enclave2/Enclave2_t.c + @$(CC) $(Enclave_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +Enclave2/%.o: Enclave2/%.cpp + @$(CXX) -std=c++03 -nostdinc++ $(Enclave_Compile_Flags) -c $< -o $@ + @echo "CXX <= $<" + +Enclave2.so: Enclave2/Enclave2_t.o $(Enclave_Cpp_Objects_2) $(Trust_Lib_Name) + @$(CXX) Enclave2/Enclave2_t.o $(Enclave_Cpp_Objects_2) -o $@ $(Enclave_Link_Flags) + @echo "LINK => $@" + +$(Enclave_Name_2): Enclave2.so + @$(SGX_ENCLAVE_SIGNER) sign -key Enclave2/Enclave2_private.pem -enclave Enclave2.so -out $@ -config Enclave2/Enclave2.config.xml + @echo "SIGN => $@" + +Enclave3/Enclave3_t.c: $(SGX_EDGER8R) Enclave3/Enclave3.edl + @cd Enclave3 && $(SGX_EDGER8R) --use-prefix --trusted ../Enclave3/Enclave3.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +Enclave3/Enclave3_t.o: Enclave3/Enclave3_t.c + @$(CC) $(Enclave_Compile_Flags) -c $< -o $@ + @echo "CC <= $<" + +Enclave3/%.o: Enclave3/%.cpp + @$(CXX) -std=c++03 -nostdinc++ $(Enclave_Compile_Flags) -c $< -o $@ + @echo "CXX <= $<" + +Enclave3.so: Enclave3/Enclave3_t.o $(Enclave_Cpp_Objects_3) $(Trust_Lib_Name) + @$(CXX) Enclave3/Enclave3_t.o $(Enclave_Cpp_Objects_3) -o $@ $(Enclave_Link_Flags) + @echo "LINK => $@" + +$(Enclave_Name_3): Enclave3.so + @$(SGX_ENCLAVE_SIGNER) sign -key Enclave3/Enclave3_private.pem -enclave Enclave3.so -out $@ -config Enclave3/Enclave3.config.xml + @echo "SIGN => $@" + +######## Clean ######## +.PHONY: clean + +clean: + @rm -rf $(App_Name) *.so *.a App/*.o Enclave1/*.o Enclave1/*_t.* Enclave1/*_u.* Enclave2/*.o Enclave2/*_t.* Enclave2/*_u.* Enclave3/*.o Enclave3/*_t.* Enclave3/*_u.* LocalAttestationCode/*.o Untrusted_LocalAttestation/*.o LocalAttestationCode/*_t.* diff --git a/SampleCode/LocalAttestation/README.txt b/SampleCode/LocalAttestation/README.txt new file mode 100644 index 0000000000..067bb498dc --- /dev/null +++ b/SampleCode/LocalAttestation/README.txt @@ -0,0 +1,27 @@ +--------------------------- +Purpose of LocalAttestation +--------------------------- +The project demonstrates: +- How to establish a protected channel +- Secret message exchange using enclave to enclave function calls + +------------------------------------ +How to Build/Execute the Sample Code +------------------------------------ +1. Install Intel(R) SGX SDK for Linux* OS +2. Build the project with the prepared Makefile: + a. Hardware Mode, Debug build: + $ make SGX_MODE=HW SGX_DEBUG=1 + b. Hardware Mode, Pre-release build: + $ make SGX_MODE=HW SGX_PRERELEASE=1 + c. Hardware Mode, Release build: + $ make SGX_MODE=HW + d. Simulation Mode, Debug build: + $ make SGX_DEBUG=1 + e. Simulation Mode, Pre-release build: + $ make SGX_PRERELEASE=1 + f. Simulation Mode, Release build: + $ make +3. Execute the binary directly: + $ ./app + diff --git a/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.cpp b/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.cpp new file mode 100644 index 0000000000..805c14abad --- /dev/null +++ b/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.cpp @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_eid.h" +#include "error_codes.h" +#include "datatypes.h" +#include "sgx_urts.h" +#include "UntrustedEnclaveMessageExchange.h" +#include "sgx_dh.h" +#include + +std::mapg_enclave_id_map; + +//Makes an sgx_ecall to the destination enclave to get session id and message1 +ATTESTATION_STATUS session_request_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, sgx_dh_msg1_t* dh_msg1, uint32_t* session_id) +{ + uint32_t status = 0; + sgx_status_t ret = SGX_SUCCESS; + uint32_t temp_enclave_no; + + std::map::iterator it = g_enclave_id_map.find(dest_enclave_id); + if(it != g_enclave_id_map.end()) + { + temp_enclave_no = it->second; + } + else + { + return INVALID_SESSION; + } + + switch(temp_enclave_no) + { + case 1: + ret = Enclave1_session_request(dest_enclave_id, &status, src_enclave_id, dh_msg1, session_id); + break; + case 2: + ret = Enclave2_session_request(dest_enclave_id, &status, src_enclave_id, dh_msg1, session_id); + break; + case 3: + ret = Enclave3_session_request(dest_enclave_id, &status, src_enclave_id, dh_msg1, session_id); + break; + } + if (ret == SGX_SUCCESS) + return (ATTESTATION_STATUS)status; + else + return INVALID_SESSION; + +} +//Makes an sgx_ecall to the destination enclave sends message2 from the source enclave and gets message 3 from the destination enclave +ATTESTATION_STATUS exchange_report_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, sgx_dh_msg2_t *dh_msg2, sgx_dh_msg3_t *dh_msg3, uint32_t session_id) +{ + uint32_t status = 0; + sgx_status_t ret = SGX_SUCCESS; + uint32_t temp_enclave_no; + + std::map::iterator it = g_enclave_id_map.find(dest_enclave_id); + if(it != g_enclave_id_map.end()) + { + temp_enclave_no = it->second; + } + else + { + return INVALID_SESSION; + } + + switch(temp_enclave_no) + { + case 1: + ret = Enclave1_exchange_report(dest_enclave_id, &status, src_enclave_id, dh_msg2, dh_msg3, session_id); + break; + case 2: + ret = Enclave2_exchange_report(dest_enclave_id, &status, src_enclave_id, dh_msg2, dh_msg3, session_id); + break; + case 3: + ret = Enclave3_exchange_report(dest_enclave_id, &status, src_enclave_id, dh_msg2, dh_msg3, session_id); + break; + } + if (ret == SGX_SUCCESS) + return (ATTESTATION_STATUS)status; + else + return INVALID_SESSION; + +} + +//Make an sgx_ecall to the destination enclave function that generates the actual response +ATTESTATION_STATUS send_request_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id,secure_message_t* req_message, size_t req_message_size, size_t max_payload_size, secure_message_t* resp_message, size_t resp_message_size) +{ + uint32_t status = 0; + sgx_status_t ret = SGX_SUCCESS; + uint32_t temp_enclave_no; + + std::map::iterator it = g_enclave_id_map.find(dest_enclave_id); + if(it != g_enclave_id_map.end()) + { + temp_enclave_no = it->second; + } + else + { + return INVALID_SESSION; + } + + switch(temp_enclave_no) + { + case 1: + ret = Enclave1_generate_response(dest_enclave_id, &status, src_enclave_id, req_message, req_message_size, max_payload_size, resp_message, resp_message_size); + break; + case 2: + ret = Enclave2_generate_response(dest_enclave_id, &status, src_enclave_id, req_message, req_message_size, max_payload_size, resp_message, resp_message_size); + break; + case 3: + ret = Enclave3_generate_response(dest_enclave_id, &status, src_enclave_id, req_message, req_message_size, max_payload_size, resp_message, resp_message_size); + break; + } + if (ret == SGX_SUCCESS) + return (ATTESTATION_STATUS)status; + else + return INVALID_SESSION; + +} + +//Make an sgx_ecall to the destination enclave to close the session +ATTESTATION_STATUS end_session_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id) +{ + uint32_t status = 0; + sgx_status_t ret = SGX_SUCCESS; + uint32_t temp_enclave_no; + + std::map::iterator it = g_enclave_id_map.find(dest_enclave_id); + if(it != g_enclave_id_map.end()) + { + temp_enclave_no = it->second; + } + else + { + return INVALID_SESSION; + } + + switch(temp_enclave_no) + { + case 1: + ret = Enclave1_end_session(dest_enclave_id, &status, src_enclave_id); + break; + case 2: + ret = Enclave2_end_session(dest_enclave_id, &status, src_enclave_id); + break; + case 3: + ret = Enclave3_end_session(dest_enclave_id, &status, src_enclave_id); + break; + } + if (ret == SGX_SUCCESS) + return (ATTESTATION_STATUS)status; + else + return INVALID_SESSION; + +} diff --git a/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.h b/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.h new file mode 100644 index 0000000000..684b33cb3b --- /dev/null +++ b/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_eid.h" +#include "error_codes.h" +#include "datatypes.h" +#include "sgx_urts.h" +#include "dh_session_protocol.h" +#include "sgx_dh.h" +#include + + +#ifndef ULOCALATTESTATION_H_ +#define ULOCALATTESTATION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +sgx_status_t Enclave1_session_request(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, sgx_dh_msg1_t* dh_msg1, uint32_t* session_id); +sgx_status_t Enclave1_exchange_report(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, sgx_dh_msg2_t* dh_msg2, sgx_dh_msg3_t* dh_msg3, uint32_t session_id); +sgx_status_t Enclave1_generate_response(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, secure_message_t* req_message, size_t req_message_size, size_t max_payload_size, secure_message_t* resp_message, size_t resp_message_size); +sgx_status_t Enclave1_end_session(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id); + +sgx_status_t Enclave2_session_request(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, sgx_dh_msg1_t* dh_msg1, uint32_t* session_id); +sgx_status_t Enclave2_exchange_report(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, sgx_dh_msg2_t* dh_msg2, sgx_dh_msg3_t* dh_msg3, uint32_t session_id); +sgx_status_t Enclave2_generate_response(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, secure_message_t* req_message, size_t req_message_size, size_t max_payload_size, secure_message_t* resp_message, size_t resp_message_size); +sgx_status_t Enclave2_end_session(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id); + +sgx_status_t Enclave3_session_request(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, sgx_dh_msg1_t* dh_msg1, uint32_t* session_id); +sgx_status_t Enclave3_exchange_report(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, sgx_dh_msg2_t* dh_msg2, sgx_dh_msg3_t* dh_msg3, uint32_t session_id); +sgx_status_t Enclave3_generate_response(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id, secure_message_t* req_message, size_t req_message_size, size_t max_payload_size, secure_message_t* resp_message, size_t resp_message_size); +sgx_status_t Enclave3_end_session(sgx_enclave_id_t eid, uint32_t* retval, sgx_enclave_id_t src_enclave_id); + +uint32_t session_request_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, sgx_dh_msg1_t* dh_msg1, uint32_t* session_id); +uint32_t exchange_report_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, sgx_dh_msg2_t* dh_msg2, sgx_dh_msg3_t* dh_msg3, uint32_t session_id); +uint32_t send_request_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id, secure_message_t* req_message, size_t req_message_size, size_t max_payload_size, secure_message_t* resp_message, size_t resp_message_size); +uint32_t end_session_ocall(sgx_enclave_id_t src_enclave_id, sgx_enclave_id_t dest_enclave_id); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SampleCode/PowerTransition/.cproject b/SampleCode/PowerTransition/.cproject new file mode 100644 index 0000000000..b9fabf3067 --- /dev/null +++ b/SampleCode/PowerTransition/.cproject @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleCode/PowerTransition/.project b/SampleCode/PowerTransition/.project new file mode 100644 index 0000000000..f1af7d8591 --- /dev/null +++ b/SampleCode/PowerTransition/.project @@ -0,0 +1,28 @@ + + + SimpleEnclave + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.core.ccnature + com.intel.sgx.sgxnature + + diff --git a/SampleCode/PowerTransition/App/App.cpp b/SampleCode/PowerTransition/App/App.cpp new file mode 100644 index 0000000000..6384116722 --- /dev/null +++ b/SampleCode/PowerTransition/App/App.cpp @@ -0,0 +1,319 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +// App.cpp : Define the entry point for the console application. +// + +#include +#include +#include +#include +#include + +#include "Enclave_u.h" +#include "sgx_urts.h" +#include "sgx_tseal.h" + +#include "rwlock.h" +#include "ErrorSupport.h" + +#define ENCLAVE_NAME "libenclave.signed.so" +#define TOKEN_NAME "Enclave.token" + +#define THREAD_NUM 3 + +// Global data +sgx_enclave_id_t global_eid = 0; +sgx_launch_token_t token = {0}; +rwlock_t lock_eid; +struct sealed_buf_t sealed_buf; + +using namespace std; + +// Ocall function +void print(const char *str) +{ + cout<()(std::this_thread::get_id()); + sgx_status_t ret = SGX_SUCCESS; + int retval = 0; + sgx_enclave_id_t current_eid = 0; + + // Enter the enclave to increase and seal the secret data for 100 times. + for(unsigned int i = 0; i< 50000; i++) + { + for( ; ; ) + { + // If power transition occurs, all the data inside the enclave will be lost when the system resumes. + // Therefore, if there are some secret data which need to be backed up for recover, + // users can choose to seal the secret data inside the enclave and back up the sealed data. + + // Enter the enclave to increase the secret data and back up the sealed data + rdlock(&lock_eid); + current_eid = global_eid; + rdunlock(&lock_eid); + ret = increase_and_seal_data(current_eid, &retval, thread_id, &sealed_buf); + + if(ret == SGX_ERROR_ENCLAVE_LOST) + { + // SGX_ERROR_ENCLAVE_LOST indicates the power transition occurs before the system resumes. + // Lock here is to make sure there is only one thread to load and initialize the enclave at the same time + wtlock(&lock_eid); + // The loading and initialization operations happen in current thread only if there is no other thread reloads and initializes the enclave before + if(current_eid == global_eid) + { + cout <<"power transition occured in increase_and_seal_data()." << endl; + // Use the backup sealed data to reload and initialize the enclave. + if((ret = load_and_initialize_enclave(¤t_eid, &sealed_buf)) != SGX_SUCCESS) + { + ret_error_support(ret); + wtunlock(&lock_eid); + return false; + } + else + { + // Update the global_eid after initializing the enclave successfully + global_eid = current_eid; + } + } + else + { + // The enclave has been reloaded by another thread. + // Update the current EID and do increase_and_seal_data() again. + current_eid = global_eid; + } + wtunlock(&lock_eid); + } + else + { + // No power transition occurs + break; + } + } + if(ret != SGX_SUCCESS) + { + ret_error_support(ret); + return false; + } + else if(retval != 0) + { + return false; + } + } + return true; +} + + +void thread_func() +{ + if(increase_and_seal_data_in_enclave() != true) + { + abort(); + } +} + +bool set_global_data() +{ + // Initialize the read/write lock. + init_rwlock(&lock_eid); + + // Get the saved launch token. + // If error occures, zero the token. + ifstream ifs(TOKEN_NAME, std::ios::binary | std::ios::in); + if(!ifs.good()) + { + memset(token, 0, sizeof(sgx_launch_token_t)); + } + else + { + ifs.read(reinterpret_cast(&token), sizeof(sgx_launch_token_t)); + if(ifs.fail()) + { + memset(&token, 0, sizeof(sgx_launch_token_t)); + } + } + + // Allocate memory to save the sealed data. + uint32_t sealed_len = sizeof(sgx_sealed_data_t) + sizeof(uint32_t); + for(int i = 0; i < BUF_NUM; i++) + { + sealed_buf.sealed_buf_ptr[i] = (uint8_t *)malloc(sealed_len); + if(sealed_buf.sealed_buf_ptr[i] == NULL) + { + cout << "Out of memory" << endl; + return false; + } + memset(sealed_buf.sealed_buf_ptr[i], 0, sealed_len); + } + sealed_buf.index = 0; // index indicates which buffer contains current sealed data and which contains the backup sealed data + + return true; +} + +void release_source() +{ + for(int i = 0; i < BUF_NUM; i++) + { + if(sealed_buf.sealed_buf_ptr[i] != NULL) + { + free(sealed_buf.sealed_buf_ptr[i]); + sealed_buf.sealed_buf_ptr[i] = NULL; + } + } + fini_rwlock(&lock_eid); + return; +} + +int main(int argc, char* argv[]) +{ + (void)argc, (void)argv; + + + // Initialize the global data + if(!set_global_data()) + { + release_source(); + cout << "Enter a character before exit ..." << endl; + getchar(); + return -1; + } + + // Load and initialize the signed enclave + // sealed_buf == NULL indicates it is the first time to initialize the enclave. + sgx_status_t ret = load_and_initialize_enclave(&global_eid , NULL); + if(ret != SGX_SUCCESS) + { + ret_error_support(ret); + release_source(); + cout << "Enter a character before exit ..." << endl; + getchar(); + return -1; + } + + cout << "****************************************************************" << endl; + cout << "Demonstrating Power transition needs your cooperation." << endl + << "Please take the following actions:" << endl + << " 1. Enter a character;" << endl + << " 2. Manually put the OS into a sleep or hibernate state;" << endl + << " 3. Resume the OS from that state;" << endl + << "Then you will see the application continues." << endl; + cout << "****************************************************************" << endl; + cout << "Now enter a character ..."; + getchar(); + + // Create multiple threads to calculate the sum + thread trd[THREAD_NUM]; + for (int i = 0; i< THREAD_NUM; i++) + { + trd[i] = thread(thread_func); + } + for (int i = 0; i < THREAD_NUM; i++) + { + trd[i].join(); + } + + // Release resources + release_source(); + + // Destroy the enclave + sgx_destroy_enclave(global_eid); + + cout << "Enter a character before exit ..." << endl; + getchar(); + return 0; +} + diff --git a/SampleCode/PowerTransition/App/ErrorSupport.cpp b/SampleCode/PowerTransition/App/ErrorSupport.cpp new file mode 100644 index 0000000000..9665fb6b31 --- /dev/null +++ b/SampleCode/PowerTransition/App/ErrorSupport.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include +#include "ErrorSupport.h" + + +typedef struct _sgx_errlist_t { + sgx_status_t err; + const char * msg; +} sgx_errlist_t; + +static sgx_errlist_t sgx_errlist[] = { + {SGX_ERROR_UNEXPECTED, "Unexpected error occurred."}, + {SGX_ERROR_INVALID_PARAMETER, "Invalid parameter."}, + {SGX_ERROR_OUT_OF_MEMORY, "Out of memory."}, + {SGX_ERROR_ENCLAVE_LOST, "Power transition occurred."}, + {SGX_ERROR_INVALID_ENCLAVE, "Invalid enclave image."}, + {SGX_ERROR_INVALID_ENCLAVE_ID, "Invalid enclave identification."}, + {SGX_ERROR_INVALID_SIGNATURE, "Invalid enclave signature."}, + {SGX_ERROR_OUT_OF_EPC, "Out of EPC memory."}, + {SGX_ERROR_NO_DEVICE, "Invalid SGX device."}, + {SGX_ERROR_MEMORY_MAP_CONFLICT, "Memory map conflicted."}, + {SGX_ERROR_INVALID_METADATA, "Invalid encalve metadata."}, + {SGX_ERROR_DEVICE_BUSY, "SGX device is busy."}, + {SGX_ERROR_INVALID_VERSION, "Enclave metadata version is invalid."}, + {SGX_ERROR_ENCLAVE_FILE_ACCESS, "Can't open enclave file."}, + + {SGX_ERROR_INVALID_FUNCTION, "Invalid function name."}, + {SGX_ERROR_OUT_OF_TCS, "Out of TCS."}, + {SGX_ERROR_ENCLAVE_CRASHED, "The enclave is crashed."}, + + {SGX_ERROR_MAC_MISMATCH, "Report varification error occurred."}, + {SGX_ERROR_INVALID_ATTRIBUTE, "The enclave is not authorized."}, + {SGX_ERROR_INVALID_CPUSVN, "Invalid CPUSVN."}, + {SGX_ERROR_INVALID_ISVSVN, "Invalid ISVSVN."}, + {SGX_ERROR_INVALID_KEYNAME, "The requested key name is invalid."}, + + {SGX_ERROR_SERVICE_UNAVAILABLE, "AESM service is not responsive."}, + {SGX_ERROR_SERVICE_TIMEOUT, "Request to AESM is time out."}, + {SGX_ERROR_SERVICE_INVALID_PRIVILEGE, "Error occurred while getting launch token."}, +}; + + +void ret_error_support(sgx_status_t ret) +{ + size_t idx = 0; + size_t ttl = sizeof sgx_errlist/sizeof sgx_errlist[0]; + + for (idx = 0; idx < ttl; idx++) { + if(ret == sgx_errlist[idx].err) { + std::cout << "Error: "<< sgx_errlist[idx].msg << std::endl; + break; + } + } + if (idx == ttl) + std::cout << "Error: Unexpected error occurred." < +void wtlock(prwlock_t lock) +{ + int ret = pthread_rwlock_wrlock(lock); + if(0 != ret) + abort(); +} + +void wtunlock(prwlock_t lock) +{ + int ret = pthread_rwlock_unlock(lock); + if(0 != ret) + abort(); +} + + +void rdlock(prwlock_t lock) +{ + int ret = pthread_rwlock_rdlock(lock); + if(0 != ret) + abort(); +} + +void rdunlock(prwlock_t lock) +{ + int ret = pthread_rwlock_unlock(lock); + if(0 != ret) + abort(); +} + +void init_rwlock(prwlock_t lock) +{ + //use the default attribute. + int ret = pthread_rwlock_init(lock, NULL); + if(0 != ret) + abort(); +} + +void fini_rwlock(prwlock_t lock) +{ + int ret = pthread_rwlock_destroy(lock); + if(0 != ret) + abort(); +} + + diff --git a/SampleCode/PowerTransition/App/rwlock.h b/SampleCode/PowerTransition/App/rwlock.h new file mode 100644 index 0000000000..19161f2845 --- /dev/null +++ b/SampleCode/PowerTransition/App/rwlock.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + + +#ifndef _RWLOCK_H +#define _RWLOCK_H + +#include +typedef pthread_rwlock_t rwlock_t; +typedef pthread_rwlock_t* prwlock_t; + +#ifdef __cplusplus +extern "C" { +#endif + + void wtlock(prwlock_t lock); + void rdlock(prwlock_t lock); + void rdunlock(prwlock_t lock); + void wtunlock(prwlock_t lock); + void init_rwlock(prwlock_t lock); + void fini_rwlock(prwlock_t lock); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SampleCode/PowerTransition/Common/types.h b/SampleCode/PowerTransition/Common/types.h new file mode 100644 index 0000000000..a4dc4eaa94 --- /dev/null +++ b/SampleCode/PowerTransition/Common/types.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _TYPES_H_ +#define _TYPES_H_ + +#define BUF_NUM 2 + +#define MOD2(x) ((x) % BUF_NUM) + +struct sealed_buf_t +{ + unsigned int index; + void * sealed_buf_ptr[BUF_NUM]; +}; + + +#endif diff --git a/SampleCode/PowerTransition/Enclave/Enclave.config.xml b/SampleCode/PowerTransition/Enclave/Enclave.config.xml new file mode 100644 index 0000000000..23f5748464 --- /dev/null +++ b/SampleCode/PowerTransition/Enclave/Enclave.config.xml @@ -0,0 +1,11 @@ + + 0 + 0 + 0x40000 + 0x100000 + 3 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/SampleCode/PowerTransition/Enclave/Enclave.cpp b/SampleCode/PowerTransition/Enclave/Enclave.cpp new file mode 100644 index 0000000000..34b9ba0ac7 --- /dev/null +++ b/SampleCode/PowerTransition/Enclave/Enclave.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "string.h" +#include "stdlib.h" +#include "stdio.h" +#include "sgx_trts.h" +#include "sgx_thread.h" +#include "sgx_tseal.h" + +#include "Enclave_t.h" + +uint32_t g_secret; +sgx_thread_mutex_t g_mutex = SGX_THREAD_MUTEX_INITIALIZER; + +static inline void free_allocated_memory(void *pointer) +{ + if(pointer != NULL) + { + free(pointer); + pointer = NULL; + } +} + + +int initialize_enclave(struct sealed_buf_t *sealed_buf) +{ + // sealed_buf == NULL indicates it is the first time to initialize the enclave + if(sealed_buf == NULL) + { + sgx_thread_mutex_lock(&g_mutex); + g_secret = 0; + sgx_thread_mutex_unlock(&g_mutex); + return 0; + } + + // It is not the first time to initialize the enclave + // Reinitialize the enclave to recover the secret data from the input backup sealed data. + + uint32_t len = sizeof(sgx_sealed_data_t) + sizeof(uint32_t); + //Check the sealed_buf length and check the outside pointers deeply + if(sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index)] == NULL || + sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index + 1)] == NULL || + !sgx_is_outside_enclave(sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index)], len) || + !sgx_is_outside_enclave(sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index + 1)], len)) + { + print("Incorrect input parameter(s).\n"); + return -1; + } + + // Retrieve the secret from current backup sealed data + uint32_t unsealed_data = 0; + uint32_t unsealed_data_length = sizeof(g_secret); + uint8_t *plain_text = NULL; + uint32_t plain_text_length = 0; + uint8_t *temp_sealed_buf = (uint8_t *)malloc(len); + if(temp_sealed_buf == NULL) + { + print("Out of memory.\n"); + return -1; + } + + sgx_thread_mutex_lock(&g_mutex); + memcpy(temp_sealed_buf, sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index)], len); + + // Unseal current sealed buf + sgx_status_t ret = sgx_unseal_data((sgx_sealed_data_t *)temp_sealed_buf, plain_text, &plain_text_length, (uint8_t *)&unsealed_data, &unsealed_data_length); + if(ret == SGX_SUCCESS) + { + g_secret = unsealed_data; + sgx_thread_mutex_unlock(&g_mutex); + free_allocated_memory(temp_sealed_buf); + return 0; + } + else + { + sgx_thread_mutex_unlock(&g_mutex); + print("Failed to reinitialize the enclave.\n"); + free_allocated_memory(temp_sealed_buf); + return -1; + } +} + +int increase_and_seal_data(size_t tid, struct sealed_buf_t* sealed_buf) +{ + uint32_t sealed_len = sizeof(sgx_sealed_data_t) + sizeof(g_secret); + // Check the sealed_buf length and check the outside pointers deeply + if(sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index)] == NULL || + sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index + 1)] == NULL || + !sgx_is_outside_enclave(sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index)], sealed_len) || + !sgx_is_outside_enclave(sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index + 1)], sealed_len)) + { + print("Incorrect input parameter(s).\n"); + return -1; + } + + char string_buf[BUFSIZ] = {'\0'}; + uint32_t temp_secret = 0; + uint8_t *plain_text = NULL; + uint32_t plain_text_length = 0; + uint8_t *temp_sealed_buf = (uint8_t *)malloc(sealed_len); + if(temp_sealed_buf == NULL) + { + print("Out of memory.\n"); + return -1; + } + memset(temp_sealed_buf, 0, sealed_len); + + sgx_thread_mutex_lock(&g_mutex); + + // Increase and seal the secret data + temp_secret = ++g_secret; + sgx_status_t ret = sgx_seal_data(plain_text_length, plain_text, sizeof(g_secret), (uint8_t *)&g_secret, sealed_len, (sgx_sealed_data_t *)temp_sealed_buf); + if(ret != SGX_SUCCESS) + { + sgx_thread_mutex_unlock(&g_mutex); + print("Failed to seal data\n"); + free_allocated_memory(temp_sealed_buf); + return -1; + } + // Backup the sealed data to outside buffer + memcpy(sealed_buf->sealed_buf_ptr[MOD2(sealed_buf->index + 1)], temp_sealed_buf, sealed_len); + sealed_buf->index++; + + sgx_thread_mutex_unlock(&g_mutex); + free_allocated_memory(temp_sealed_buf); + + // Ocall to print the unsealed secret data outside. + // In theory, the secret data(s) SHOULD NOT be transferred outside the enclave as clear text(s). + // So please DO NOT print any secret outside. Here printing the secret data to outside is only for demo. + snprintf(string_buf, BUFSIZ, "Thread %#x>: %d\n", (unsigned int)tid, temp_secret); + print(string_buf); + return 0; +} diff --git a/SampleCode/PowerTransition/Enclave/Enclave.edl b/SampleCode/PowerTransition/Enclave/Enclave.edl new file mode 100644 index 0000000000..54aa25a740 --- /dev/null +++ b/SampleCode/PowerTransition/Enclave/Enclave.edl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +enclave { + + // Import the Ocalls for trusted mutex + from "sgx_tstdc.edl" import *; + include "types.h" + + trusted { + public int initialize_enclave([in]struct sealed_buf_t* sealed_buf); + public int increase_and_seal_data(size_t tid, [in, out]struct sealed_buf_t* sealed_buf); + }; + + untrusted { + void print([in, string] const char *string); + }; +}; diff --git a/SampleCode/PowerTransition/Enclave/Enclave.lds b/SampleCode/PowerTransition/Enclave/Enclave.lds new file mode 100644 index 0000000000..b1c6b6fd7e --- /dev/null +++ b/SampleCode/PowerTransition/Enclave/Enclave.lds @@ -0,0 +1,9 @@ +libenclave.so +{ + global: + g_global_data_sim; + g_global_data; + enclave_entry; + local: + *; +}; diff --git a/SampleCode/PowerTransition/Enclave/Enclave_private.pem b/SampleCode/PowerTransition/Enclave/Enclave_private.pem new file mode 100644 index 0000000000..529d07be35 --- /dev/null +++ b/SampleCode/PowerTransition/Enclave/Enclave_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4gIBAAKCAYEAroOogvsj/fZDZY8XFdkl6dJmky0lRvnWMmpeH41Bla6U1qLZ +AmZuyIF+mQC/cgojIsrBMzBxb1kKqzATF4+XwPwgKz7fmiddmHyYz2WDJfAjIveJ +ZjdMjM4+EytGlkkJ52T8V8ds0/L2qKexJ+NBLxkeQLfV8n1mIk7zX7jguwbCG1Pr +nEMdJ3Sew20vnje+RsngAzdPChoJpVsWi/K7cettX/tbnre1DL02GXc5qJoQYk7b +3zkmhz31TgFrd9VVtmUGyFXAysuSAb3EN+5VnHGr0xKkeg8utErea2FNtNIgua8H +ONfm9Eiyaav1SVKzPHlyqLtcdxH3I8Wg7yqMsaprZ1n5A1v/levxnL8+It02KseD +5HqV4rf/cImSlCt3lpRg8U5E1pyFQ2IVEC/XTDMiI3c+AR+w2jSRB3Bwn9zJtFlW +KHG3m1xGI4ck+Lci1JvWWLXQagQSPtZTsubxTQNx1gsgZhgv1JHVZMdbVlAbbRMC +1nSuJNl7KPAS/VfzAgEDAoIBgHRXxaynbVP5gkO0ug6Qw/E27wzIw4SmjsxG6Wpe +K7kfDeRskKxESdsA/xCrKkwGwhcx1iIgS5+Qscd1Yg+1D9X9asd/P7waPmWoZd+Z +AhlKwhdPsO7PiF3e1AzHhGQwsUTt/Y/aSI1MpHBvy2/s1h9mFCslOUxTmWw0oj/Q +ldIEgWeNR72CE2+jFIJIyml6ftnb6qzPiga8Bm48ubKh0kvySOqnkmnPzgh+JBD6 +JnBmtZbfPT97bwTT+N6rnPqOOApvfHPf15kWI8yDbprG1l4OCUaIUH1AszxLd826 +5IPM+8gINLRDP1MA6azECPjTyHXhtnSIBZCyWSVkc05vYmNXYUNiXWMajcxW9M02 +wKzFELO8NCEAkaTPxwo4SCyIjUxiK1LbQ9h8PSy4c1+gGP4LAMR8xqP4QKg6zdu9 +osUGG/xRe/uufgTBFkcjqBHtK5L5VI0jeNIUAgW/6iNbYXjBMJ0GfauLs+g1VsOm +WfdgXzsb9DYdMa0OXXHypmV4GwKBwQDUwQj8RKJ6c8cT4vcWCoJvJF00+RFL+P3i +Gx2DLERxRrDa8AVGfqaCjsR+3vLgG8V/py+z+dxZYSqeB80Qeo6PDITcRKoeAYh9 +xlT3LJOS+k1cJcEmlbbO2IjLkTmzSwa80fWexKu8/Xv6vv15gpqYl1ngYoqJM3pd +vzmTIOi7MKSZ0WmEQavrZj8zK4endE3v0eAEeQ55j1GImbypSf7Idh7wOXtjZ7WD +Dg6yWDrri+AP/L3gClMj8wsAxMV4ZR8CgcEA0fzDHkFa6raVOxWnObmRoDhAtE0a +cjUj976NM5yyfdf2MrKy4/RhdTiPZ6b08/lBC/+xRfV3xKVGzacm6QjqjZrUpgHC +0LKiZaMtccCJjLtPwQd0jGQEnKfMFaPsnhOc5y8qVkCzVOSthY5qhz0XNotHHFmJ +gffVgB0iqrMTvSL7IA2yqqpOqNRlhaYhNl8TiFP3gIeMtVa9rZy31JPgT2uJ+kfo +gV7sdTPEjPWZd7OshGxWpT6QfVDj/T9T7L6tAoHBAI3WBf2DFvxNL2KXT2QHAZ9t +k3imC4f7U+wSE6zILaDZyzygA4RUbwG0gv8/TJVn2P/Eynf76DuWHGlaiLWnCbSz +Az2DHBQBBaku409zDQym3j1ugMRjzzSQWzJg0SIyBH3hTmnYcn3+Uqcp/lEBvGW6 +O+rsXFt3pukqJmIV8HzLGGaLm62BHUeZf3dyWm+i3p/hQAL7Xvu04QW70xuGqdr5 +afV7p5eaeQIJXyGQJ0eylV/90+qxjMKiB1XYg6WYvwKBwQCL/ddpgOdHJGN8uRom +e7Zq0Csi3hGheMKlKbN3vcxT5U7MdyHtTZZOJbTvxKNNUNYH/8uD+PqDGNneb29G +BfGzvI3EASyLIcGZF3OhKwZd0jUrWk2y7Vhob91jwp2+t73vdMbkKyI4mHOuXvGv +fg95si9oO7EBT+Oqvhccd2J+F1IVXncccYnF4u5ZGWt5lLewN/pVr7MjjykeaHqN +t+rfnQam2psA6fL4zS2zTmZPzR2tnY8Y1GBTi0Ko1OKd1HMCgcAb5cB/7/AQlhP9 +yQa04PLH9ygQkKKptZp7dy5WcWRx0K/hAHRoi2aw1wZqfm7VBNu2SLcs90kCCCxp +6C5sfJi6b8NpNbIPC+sc9wsFr7pGo9SFzQ78UlcWYK2Gu2FxlMjonhka5hvo4zvg +WxlpXKEkaFt3gLd92m/dMqBrHfafH7VwOJY2zT3WIpjwuk0ZzmRg5p0pG/svVQEH +NZmwRwlopysbR69B/n1nefJ84UO50fLh5s5Zr3gBRwbWNZyzhXk= +-----END RSA PRIVATE KEY----- diff --git a/SampleCode/PowerTransition/Makefile b/SampleCode/PowerTransition/Makefile new file mode 100644 index 0000000000..5c03d8aaa6 --- /dev/null +++ b/SampleCode/PowerTransition/Makefile @@ -0,0 +1,212 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +####### SGX SDK Settings ######## + +SGX_SDK ?= /opt/intel/sgxsdk +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +ifneq ($(SGX_MODE), HW) + Urts_Library_Name := sgx_urts_sim +else + Urts_Library_Name := sgx_urts +endif + +App_Cpp_Files := $(wildcard App/*.cpp) +App_Include_Paths := -I$(SGX_SDK)/include -I./Common + +App_Compile_CFlags := -fPIC -Wno-attributes $(App_Include_Paths) +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_Compile_CFlags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_Compile_CFlags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_Compile_CFlags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Compile_CXXFlags := -std=c++0x $(App_Compile_CFlags) +App_Link_Flags := -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name) -lpthread + +ifneq ($(SGX_MODE), HW) + App_Link_Flags += -lsgx_uae_service_sim +else + App_Link_Flags += -lsgx_uae_service +endif + +Gen_Untrusted_Source := App/Enclave_u.c +Gen_Untrusted_Object := App/Enclave_u.o + +App_Objects := $(Gen_Untrusted_Object) $(App_Cpp_Files:.cpp=.o) + +App_Name := app + + +######## Enclave Settings ######## + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif +Crypto_Library_Name := sgx_tcrypto + +Enclave_Cpp_Files := $(wildcard Enclave/*.cpp) + +Enclave_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I./Common + +Enclave_Compile_CFlags := -nostdinc -ffreestanding -fvisibility=hidden -fpie \ + $(Enclave_Include_Paths) +Enclave_Compile_CXXFlags := -nostdinc++ -std=c++03 $(Enclave_Compile_CFlags) +Enclave_Link_Flags := -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,--version-script=Enclave/Enclave.lds -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 + +Enclave_Cpp_Objects := $(Enclave_Cpp_Files:.cpp=.o) +Gen_Trusted_Source := Enclave/Enclave_t.c +Gen_Trusted_Object := Enclave/Enclave_t.o + +Enclave_Objects := $(Gen_Trusted_Object) $(Enclave_Cpp_Files:.cpp=.o) + +Enclave_Name := libenclave.so +Signed_Enclave_Name := libenclave.signed.so +Enclave_Config_File := Enclave/Enclave.config.xml + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + +ifeq ($(Build_Mode), HW_RELEASE) +all: $(App_Name) $(Enclave_Name) + @echo "The project has been built in release hardware mode." + @echo "Please sign the $(Enclave_Name) first with your signing key before you run the $(App_Name) to launch and access the enclave." + @echo "To sign the enclave use the command:" + @echo " $(SGX_ENCLAVE_SIGNER) sign -key -enclave $(Enclave_Name) -out <$(Signed_Enclave_Name)> -config $(Enclave_Config_File)" + @echo "You can also sign the enclave using an external signing tool. See User's Guide for more details." + @echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW." +else +all: $(App_Name) $(Signed_Enclave_Name) + @echo "Build $(App_Name) [$(SGX_MODE)|$(SGX_ARCH)] Success!" + @echo "Please RUN the project with command:" + @echo " $(App_Name)" +endif + +######## App Objects ######## + +$(Gen_Untrusted_Source): $(SGX_EDGER8R) Enclave/Enclave.edl + @cd App && $(SGX_EDGER8R) --untrusted ../Enclave/Enclave.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +$(Gen_Untrusted_Object): $(Gen_Untrusted_Source) + @$(CC) $(SGX_COMMON_CFLAGS) $(App_Compile_CFlags) -c $< -o $@ + @echo "CC <= $<" + +App/%.o: App/%.cpp + @$(CXX) $(SGX_COMMON_CFLAGS) $(App_Compile_CXXFlags) -c $< -o $@ + @echo "CXX <= $<" + +$(App_Name): $(App_Objects) + @$(CXX) $(SGX_COMMON_CFLAGS) $^ -o $@ $(App_Link_Flags) + @echo "LINK => $@" + + +######## Enclave Objects ######## + +$(Gen_Trusted_Source): $(SGX_EDGER8R) Enclave/Enclave.edl + @cd Enclave && $(SGX_EDGER8R) --trusted Enclave.edl --search-path $(SGX_SDK)/include + @echo "GEN => $@" +$(Gen_Trusted_Object): $(Gen_Trusted_Source) + @$(CC) $(SGX_COMMON_CFLAGS) $(Enclave_Compile_CFlags) -c $< -o $@ + @echo "CC <= $<" + +Enclave/%.o: Enclave/%.cpp + @$(CXX) $(SGX_COMMON_CFLAGS) $(Enclave_Compile_CXXFlags) -c $< -o $@ + @echo "CXX <= $<" + +$(Enclave_Name): $(Enclave_Objects) + @$(CXX) $(SGX_COMMON_CFLAGS) $(Enclave_Objects) -o $@ $(Enclave_Link_Flags) + @echo "LINK => $@" + +$(Signed_Enclave_Name): $(Enclave_Name) + @$(SGX_ENCLAVE_SIGNER) sign -key Enclave/Enclave_private.pem -enclave $(Enclave_Name) -out $@ -config $(Enclave_Config_File) + @echo "SIGN => $@" + + +######### clean up ######## +.PHONY: clean + + +clean: + @rm -f $(App_Name) $(App_Objects) $(Enclave_Name) $(Enclave_Objects) App/Enclave_u.* Enclave/Enclave_t.* $(Signed_Enclave_Name) diff --git a/SampleCode/PowerTransition/README.txt b/SampleCode/PowerTransition/README.txt new file mode 100644 index 0000000000..a6a23b930e --- /dev/null +++ b/SampleCode/PowerTransition/README.txt @@ -0,0 +1,26 @@ +-------------------------- +Purpose of PowerTransition +-------------------------- +The project demonstrates one method about power transition handling for Intel(R) +Software Guard Extensions projects development. + +------------------------------------ +How to Build/Execute the Sample Code +------------------------------------ +1. Install Intel(R) SGX SDK for Linux* OS +2. Build the project with the prepared Makefile: + a. Hardware Mode, Debug build: + $ make SGX_MODE=HW SGX_DEBUG=1 + b. Hardware Mode, Pre-release build: + $ make SGX_MODE=HW SGX_PRERELEASE=1 + c. Hardware Mode, Release build: + $ make SGX_MODE=HW + d. Simulation Mode, Debug build: + $ make SGX_DEBUG=1 + e. Simulation Mode, Pre-release build: + $ make SGX_PRERELEASE=1 + f. Simulation Mode, Release build: + $ make +3. Execute the binary directly: + $ ./app + diff --git a/SampleCode/RemoteAttestation/.cproject b/SampleCode/RemoteAttestation/.cproject new file mode 100644 index 0000000000..b9fabf3067 --- /dev/null +++ b/SampleCode/RemoteAttestation/.cproject @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleCode/RemoteAttestation/.project b/SampleCode/RemoteAttestation/.project new file mode 100644 index 0000000000..f1af7d8591 --- /dev/null +++ b/SampleCode/RemoteAttestation/.project @@ -0,0 +1,28 @@ + + + SimpleEnclave + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.core.ccnature + com.intel.sgx.sgxnature + + diff --git a/SampleCode/RemoteAttestation/Makefile b/SampleCode/RemoteAttestation/Makefile new file mode 100644 index 0000000000..7335b486c9 --- /dev/null +++ b/SampleCode/RemoteAttestation/Makefile @@ -0,0 +1,230 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +######## SGX SDK Settings ######## + +SGX_SDK ?= /opt/intel/sgxsdk +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +ifneq ($(SGX_MODE), HW) + Urts_Library_Name := sgx_urts_sim +else + Urts_Library_Name := sgx_urts +endif + +App_Cpp_Files := isv_app/isv_app.cpp +App_Include_Paths := -Iservice_provider -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Cpp_Flags := $(App_C_Flags) -std=c++11 +App_Link_Flags := $(SGX_COMMON_CFLAGS) -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name) -L. -lsgx_ukey_exchange -lpthread -lservice_provider -Wl,-rpath=$(CURDIR)/sample_libcrypto -Wl,-rpath=$(CURDIR) + +ifneq ($(SGX_MODE), HW) + App_Link_Flags += -lsgx_uae_service_sim +else + App_Link_Flags += -lsgx_uae_service +endif + +App_Cpp_Objects := $(App_Cpp_Files:.cpp=.o) + +App_Name := app + +######## Service Provider Settings ######## + +ServiceProvider_Cpp_Files := service_provider/ecp.cpp service_provider/network_ra.cpp service_provider/service_provider.cpp service_provider/ias_ra.cpp +ServiceProvider_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -Isample_libcrypto + +ServiceProvider_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes -I$(SGX_SDK)/include -Isample_libcrypto +ServiceProvider_Cpp_Flags := $(ServiceProvider_C_Flags) -std=c++11 +ServiceProvider_Link_Flags := -shared $(SGX_COMMON_CFLAGS) -L$(SGX_LIBRARY_PATH) -lsample_libcrypto -Lsample_libcrypto + +ServiceProvider_Cpp_Objects := $(ServiceProvider_Cpp_Files:.cpp=.o) + +######## Enclave Settings ######## + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif +Crypto_Library_Name := sgx_tcrypto + +Enclave_Cpp_Files := isv_enclave/isv_enclave.cpp +Enclave_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport + +Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) +Enclave_Cpp_Flags := $(Enclave_C_Flags) -std=c++03 -nostdinc++ +Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -lsgx_tkey_exchange -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 \ + -Wl,--version-script=isv_enclave/isv_enclave.lds + +Enclave_Cpp_Objects := $(Enclave_Cpp_Files:.cpp=.o) + +Enclave_Name := isv_enclave.so +Signed_Enclave_Name := isv_enclave.signed.so +Enclave_Config_File := isv_enclave/isv_enclave.config.xml + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +ifeq ($(Build_Mode), HW_RELEASE) +all: libservice_provider.so $(App_Name) $(Enclave_Name) + @echo "The project has been built in release hardware mode." + @echo "Please sign the $(Enclave_Name) first with your signing key before you run the $(App_Name) to launch and access the enclave." + @echo "To sign the enclave use the command:" + @echo " $(SGX_ENCLAVE_SIGNER) sign -key -enclave $(Enclave_Name) -out <$(Signed_Enclave_Name)> -config $(Enclave_Config_File)" + @echo "You can also sign the enclave using an external signing tool. See User's Guide for more details." + @echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW." +else +all: libservice_provider.so $(App_Name) $(Signed_Enclave_Name) +endif + +run: all +ifneq ($(Build_Mode), HW_RELEASE) + @$(CURDIR)/$(App_Name) + @echo "RUN => $(App_Name) [$(SGX_MODE)|$(SGX_ARCH), OK]" +endif + +######## App Objects ######## + +isv_app/isv_enclave_u.c: $(SGX_EDGER8R) isv_enclave/isv_enclave.edl + @cd isv_app && $(SGX_EDGER8R) --untrusted ../isv_enclave/isv_enclave.edl --search-path ../isv_enclave --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +isv_app/isv_enclave_u.o: isv_app/isv_enclave_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +isv_app/%.o: isv_app/%.cpp + @$(CXX) $(App_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +$(App_Name): isv_app/isv_enclave_u.o $(App_Cpp_Objects) + @$(CXX) $^ -o $@ $(App_Link_Flags) + @echo "LINK => $@" + +######## Service Provider Objects ######## + + +service_provider/%.o: service_provider/%.cpp + @$(CXX) $(ServiceProvider_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +libservice_provider.so: $(ServiceProvider_Cpp_Objects) + @$(CXX) $^ -o $@ $(ServiceProvider_Link_Flags) + @echo "LINK => $@" + +######## Enclave Objects ######## + +isv_enclave/isv_enclave_t.c: $(SGX_EDGER8R) isv_enclave/isv_enclave.edl + @cd isv_enclave && $(SGX_EDGER8R) --trusted ../isv_enclave/isv_enclave.edl --search-path ../isv_enclave --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +isv_enclave/isv_enclave_t.o: isv_enclave/isv_enclave_t.c + @$(CC) $(Enclave_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +isv_enclave/%.o: isv_enclave/%.cpp + @$(CXX) $(Enclave_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +$(Enclave_Name): isv_enclave/isv_enclave_t.o $(Enclave_Cpp_Objects) + @$(CXX) $^ -o $@ $(Enclave_Link_Flags) + @echo "LINK => $@" + +$(Signed_Enclave_Name): $(Enclave_Name) + @$(SGX_ENCLAVE_SIGNER) sign -key isv_enclave/isv_enclave_private.pem -enclave $(Enclave_Name) -out $@ -config $(Enclave_Config_File) + @echo "SIGN => $@" + +.PHONY: clean + +clean: + @rm -f $(App_Name) $(Enclave_Name) $(Signed_Enclave_Name) $(App_Cpp_Objects) isv_app/isv_enclave_u.* $(Enclave_Cpp_Objects) isv_enclave/isv_enclave_t.* libservice_provider.* $(ServiceProvider_Cpp_Objects) diff --git a/SampleCode/RemoteAttestation/README.txt b/SampleCode/RemoteAttestation/README.txt new file mode 100644 index 0000000000..a940b9d1b9 --- /dev/null +++ b/SampleCode/RemoteAttestation/README.txt @@ -0,0 +1,27 @@ +---------------------------- +Purpose of RemoteAttestation +---------------------------- +The project demonstrates: +- How an application enclave can attest to a remote party +- How an application enclave and the remote party can establish a secure session + +------------------------------------ +How to Build/Execute the Sample Code +------------------------------------ +1. Install Intel(R) SGX SDK for Linux* OS +2. Build the project with the prepared Makefile: + a. Hardware Mode, Debug build: + $ make SGX_MODE=HW SGX_DEBUG=1 + b. Hardware Mode, Pre-release build: + $ make SGX_MODE=HW SGX_PRERELEASE=1 + c. Hardware Mode, Release build: + $ make SGX_MODE=HW + d. Simulation Mode, Debug build: + $ make SGX_DEBUG=1 + e. Simulation Mode, Pre-release build: + $ make SGX_PRERELEASE=1 + f. Simulation Mode, Release build: + $ make +3. Execute the binary directly: + $ ./app + diff --git a/SampleCode/RemoteAttestation/isv_app/isv_app.cpp b/SampleCode/RemoteAttestation/isv_app/isv_app.cpp new file mode 100644 index 0000000000..472e81902f --- /dev/null +++ b/SampleCode/RemoteAttestation/isv_app/isv_app.cpp @@ -0,0 +1,644 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include +#include +// Needed for definition of remote attestation messages. +#include "remote_attestation_result.h" + +#include "isv_enclave_u.h" + +// Needed to call untrusted key exchange library APIs, i.e. sgx_ra_proc_msg2. +#include "sgx_ukey_exchange.h" + +// Needed to get service provider's information, in your real project, you will +// need to talk to real server. +#include "network_ra.h" + +// Needed to create enclave and do ecall. +#include "sgx_urts.h" + +#include "service_provider.h" + +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr) = NULL;}} +#endif + +// In addition to generating and sending messages, this application +// can use pre-generated messages to verify the generation of +// messages and the information flow. +#include "sample_messages.h" + + +#define ENCLAVE_PATH "isv_enclave.signed.so" + +uint8_t* msg1_samples[] = { msg1_sample1, msg1_sample2 }; +uint8_t* msg2_samples[] = { msg2_sample1, msg2_sample2 }; +uint8_t* msg3_samples[MSG3_BODY_SIZE] = { msg3_sample1, msg3_sample2 }; +uint8_t* attestation_msg_samples[] = + { attestation_msg_sample1, attestation_msg_sample2}; + +// Some utility functions to output some of the data structures passed between +// the ISV app and the remote attestation service provider. +void PRINT_BYTE_ARRAY( + FILE *file, void *mem, uint32_t len) +{ + if(!mem || !len) + { + fprintf(file, "\n( null )\n"); + return; + } + uint8_t *array = (uint8_t *)mem; + fprintf(file, "%u bytes:\n{\n", len); + uint32_t i = 0; + for(i = 0; i < len - 1; i++) + { + fprintf(file, "0x%x, ", array[i]); + if(i % 8 == 7) fprintf(file, "\n"); + } + fprintf(file, "0x%x ", array[i]); + fprintf(file, "\n}\n"); +} + + +void PRINT_ATTESTATION_SERVICE_RESPONSE( + FILE *file, + ra_samp_response_header_t *response) +{ + if(!response) + { + fprintf(file, "\t\n( null )\n"); + return; + } + + fprintf(file, "RESPONSE TYPE: 0x%x\n", response->type); + fprintf(file, "RESPONSE STATUS: 0x%x 0x%x\n", response->status[0], + response->status[1]); + fprintf(file, "RESPONSE BODY SIZE: %u\n", response->size); + + if(response->type == TYPE_RA_MSG2) + { + sgx_ra_msg2_t* p_msg2_body = (sgx_ra_msg2_t*)(response->body); + + fprintf(file, "MSG2 gb - "); + PRINT_BYTE_ARRAY(file, &(p_msg2_body->g_b), sizeof(p_msg2_body->g_b)); + + fprintf(file, "MSG2 spid - "); + PRINT_BYTE_ARRAY(file, &(p_msg2_body->spid), sizeof(p_msg2_body->spid)); + + fprintf(file, "MSG2 sign_gb_ga - "); + PRINT_BYTE_ARRAY(file, &(p_msg2_body->sign_gb_ga), + sizeof(p_msg2_body->sign_gb_ga)); + + fprintf(file, "MSG2 mac - "); + PRINT_BYTE_ARRAY(file, &(p_msg2_body->mac), sizeof(p_msg2_body->mac)); + + fprintf(file, "MSG2 sig_rl - "); + PRINT_BYTE_ARRAY(file, &(p_msg2_body->sig_rl), + p_msg2_body->sig_rl_size); + } + else if(response->type == TYPE_RA_ATT_RESULT) + { + sample_ra_att_result_msg_t *p_att_result = + (sample_ra_att_result_msg_t *)(response->body); + fprintf(file, "ATTESTATION RESULT MSG platform_info_blob - "); + PRINT_BYTE_ARRAY(file, &(p_att_result->platform_info_blob), + sizeof(p_att_result->platform_info_blob)); + + fprintf(file, "ATTESTATION RESULT MSG mac - "); + PRINT_BYTE_ARRAY(file, &(p_att_result->mac), sizeof(p_att_result->mac)); + + fprintf(file, "ATTESTATION RESULT MSG secret.payload_tag - %u bytes\n", + p_att_result->secret.payload_size); + + fprintf(file, "ATTESTATION RESULT MSG secret.payload - "); + PRINT_BYTE_ARRAY(file, p_att_result->secret.payload, + p_att_result->secret.payload_size); + } + else + { + fprintf(file, "\nERROR in printing out the response. " + "Response of type not supported %d\n", response->type); + } +} + +// This sample code doesn't have any recovery/retry mechanisms for the remote +// attestation. Since the enclave can be lost due S3 transitions, apps +// susceptible to S3 transtions should have logic to restart attestation in +// these scenenarios. +#define _T(x) x +int main(int argc, char* argv[]) +{ + int ret = 0; + ra_samp_request_header_t *p_msg1_full = NULL; + ra_samp_response_header_t *p_msg2_full = NULL; + sgx_ra_msg3_t *p_msg3 = NULL; + ra_samp_response_header_t* p_att_result_msg_full = NULL; + sgx_enclave_id_t enclave_id = 0; + int enclave_lost_retry_time = 1; + int busy_retry_time = 2; + sgx_ra_context_t context = INT_MAX; + sgx_status_t status = SGX_SUCCESS; + ra_samp_request_header_t* p_msg3_full = NULL; + + int32_t verify_index = -1; + int32_t verification_samples = sizeof(msg1_samples)/sizeof(msg1_samples[0]); + + FILE* OUTPUT = stdout; + +#define VERIFICATION_INDEX_IS_VALID() (verify_index > 0 && \ + verify_index <= verification_samples) +#define GET_VERIFICATION_ARRAY_INDEX() (verify_index-1) + + if(argc > 1) + { + + verify_index = atoi(argv[1]); + + if( VERIFICATION_INDEX_IS_VALID()) + { + fprintf(OUTPUT, "\nVerifying precomputed attestation messages " + "using precomputed values# %d\n", verify_index); + } + else + { + fprintf(OUTPUT, "\nValid invocations are:\n"); + fprintf(OUTPUT, "\n\tisv_app\n"); + fprintf(OUTPUT, "\n\tisv_app \n"); + fprintf(OUTPUT, "\nValid indices are [1 - %d]\n", + verification_samples); + fprintf(OUTPUT, "\nUsing a verification index uses precomputed " + "messages to assist debugging the remote attestation " + "service provider.\n"); + return -1; + } + } + + // Remote attestaton will be initiated the ISV server challenges the ISV + // app or if the ISV app detects it doesn't have the credentials + // (shared secret) from a previous attestation required for secure + // communication with the server. + { + // ISV application creates the ISV enclave. + int launch_token_update = 0; + sgx_launch_token_t launch_token = {0}; + memset(&launch_token, 0, sizeof(sgx_launch_token_t)); + do + { + ret = sgx_create_enclave(_T(ENCLAVE_PATH), + SGX_DEBUG_FLAG, + &launch_token, + &launch_token_update, + &enclave_id, NULL); + if(SGX_SUCCESS != ret) + { + ret = -1; + fprintf(OUTPUT, "\nError, call sgx_create_enclave fail [%s].", + __FUNCTION__); + return ret; + } + fprintf(OUTPUT, "\nCall sgx_create_enclave success."); + + ret = enclave_init_ra(enclave_id, + &status, + false, + &context); + //Ideally, this check would be around the full attestation flow. + } while (SGX_ERROR_ENCLAVE_LOST == ret && enclave_lost_retry_time--); + + if(SGX_SUCCESS != ret || status) + { + ret = -1; + fprintf(OUTPUT, "\nError, call enclave_init_ra fail [%s].", + __FUNCTION__); + goto CLEANUP; + } + fprintf(OUTPUT, "\nCall enclave_init_ra success."); + + // isv application call uke sgx_ra_get_msg1 + p_msg1_full = (ra_samp_request_header_t*) + malloc(sizeof(ra_samp_request_header_t) + + sizeof(sgx_ra_msg1_t)); + if(NULL == p_msg1_full) + { + ret = -1; + goto CLEANUP; + } + p_msg1_full->type = TYPE_RA_MSG1; + p_msg1_full->size = sizeof(sgx_ra_msg1_t); + do + { + ret = sgx_ra_get_msg1(context, enclave_id, sgx_ra_get_ga, + (sgx_ra_msg1_t*)((uint8_t*)p_msg1_full + + sizeof(ra_samp_request_header_t))); + } while (SGX_ERROR_BUSY == ret && busy_retry_time--); + if(SGX_SUCCESS != ret) + { + ret = -1; + fprintf(OUTPUT, "\nError, call sgx_ra_get_msg1 fail [%s].", + __FUNCTION__); + goto CLEANUP; + } + else + { + fprintf(OUTPUT, "\nCall sgx_ra_get_msg1 success.\n"); + + fprintf(OUTPUT, "\nMSG1 body generated -\n"); + + PRINT_BYTE_ARRAY(OUTPUT, p_msg1_full->body, p_msg1_full->size); + + } + + if(VERIFICATION_INDEX_IS_VALID()) + { + + memcpy_s(p_msg1_full->body, p_msg1_full->size, + msg1_samples[GET_VERIFICATION_ARRAY_INDEX()], + p_msg1_full->size); + + fprintf(OUTPUT, "\nInstead of using the recently generated MSG1, " + "we will use the following precomputed MSG1 -\n"); + + PRINT_BYTE_ARRAY(OUTPUT, p_msg1_full->body, p_msg1_full->size); + } + + + // The ISV application sends msg1 to the SP to get msg2, + // msg2 needs to be freed when no longer needed. + // The ISV decides whether to use linkable or unlinkable signatures. + fprintf(OUTPUT, "\nSending msg1 to remote attestation service provider." + "Expecting msg2 back.\n"); + + + ret = ra_network_send_receive("http://SampleServiceProvider.intel.com/", + p_msg1_full, + &p_msg2_full); + + if(ret != 0 || !p_msg2_full) + { + fprintf(OUTPUT, "\nError, ra_network_send_receive for msg1 failed " + "[%s].", __FUNCTION__); + if(VERIFICATION_INDEX_IS_VALID()) + { + fprintf(OUTPUT, "\nBecause we are in verification mode we will " + "ignore this error.\n"); + fprintf(OUTPUT, "\nInstead, we will pretend we received the " + "following MSG2 - \n"); + + SAFE_FREE(p_msg2_full); + ra_samp_response_header_t* precomputed_msg2 = + (ra_samp_response_header_t*)msg2_samples[ + GET_VERIFICATION_ARRAY_INDEX()]; + const size_t msg2_full_size = sizeof(ra_samp_response_header_t) + + precomputed_msg2->size; + p_msg2_full = + (ra_samp_response_header_t*)malloc(msg2_full_size); + if(NULL == p_msg2_full) + { + ret = -1; + goto CLEANUP; + } + memcpy_s(p_msg2_full, msg2_full_size, precomputed_msg2, + msg2_full_size); + + PRINT_BYTE_ARRAY(OUTPUT, p_msg2_full, + sizeof(ra_samp_response_header_t) + + p_msg2_full->size); + } + else + { + goto CLEANUP; + } + } + else + { + // Successfully sent msg1 and received a msg2 back. + // Time now to check msg2. + if(TYPE_RA_MSG2 != p_msg2_full->type) + { + + fprintf(OUTPUT, "\nError, didn't get MSG2 in response to MSG1. " + "[%s].", __FUNCTION__); + + if(VERIFICATION_INDEX_IS_VALID()) + { + fprintf(OUTPUT, "\nBecause we are in verification mode we " + "will ignore this error."); + } + else + { + goto CLEANUP; + } + } + + fprintf(OUTPUT, "\nSent MSG1 to remote attestation service " + "provider. Received the following MSG2:\n"); + PRINT_BYTE_ARRAY(OUTPUT, p_msg2_full, + sizeof(ra_samp_response_header_t) + + p_msg2_full->size); + + fprintf(OUTPUT, "\nA more descriptive representation of MSG2:\n"); + PRINT_ATTESTATION_SERVICE_RESPONSE(OUTPUT, p_msg2_full); + + if( VERIFICATION_INDEX_IS_VALID() ) + { + // The response should match the precomputed MSG2: + ra_samp_response_header_t* precomputed_msg2 = + (ra_samp_response_header_t *) + msg2_samples[GET_VERIFICATION_ARRAY_INDEX()]; + if(memcmp( precomputed_msg2, p_msg2_full, + sizeof(ra_samp_response_header_t) + p_msg2_full->size)) + { + fprintf(OUTPUT, "\nVerification ERROR. Our precomputed " + "value for MSG2 does NOT match.\n"); + fprintf(OUTPUT, "\nPrecomputed value for MSG2:\n"); + PRINT_BYTE_ARRAY(OUTPUT, precomputed_msg2, + sizeof(ra_samp_response_header_t) + + precomputed_msg2->size); + fprintf(OUTPUT, "\nA more descriptive representation " + "of precomputed value for MSG2:\n"); + PRINT_ATTESTATION_SERVICE_RESPONSE(OUTPUT, + precomputed_msg2); + } + else + { + fprintf(OUTPUT, "\nVerification COMPLETE. Remote " + "attestation service provider generated a " + "matching MSG2.\n"); + } + } + + } + + sgx_ra_msg2_t* p_msg2_body = (sgx_ra_msg2_t*)((uint8_t*)p_msg2_full + + sizeof(ra_samp_response_header_t)); + + + uint32_t msg3_size = 0; + if( VERIFICATION_INDEX_IS_VALID()) + { + // We cannot generate a valid MSG3 using the precomputed messages + // we have been using. We will use the precomputed msg3 instead. + msg3_size = MSG3_BODY_SIZE; + p_msg3 = (sgx_ra_msg3_t*)malloc(msg3_size); + if(NULL == p_msg3) + { + ret = -1; + goto CLEANUP; + } + memcpy_s(p_msg3, msg3_size, + msg3_samples[GET_VERIFICATION_ARRAY_INDEX()], msg3_size); + fprintf(OUTPUT, "\nBecause MSG1 was a precomputed value, the MSG3 " + "we use will also be. PRECOMPUTED MSG3 - \n"); + } + else + { + busy_retry_time = 2; + // The ISV app now calls uKE sgx_ra_proc_msg2, + // The ISV app is responsible for freeing the returned p_msg3!! + do + { + ret = sgx_ra_proc_msg2(context, + enclave_id, + sgx_ra_proc_msg2_trusted, + sgx_ra_get_msg3_trusted, + p_msg2_body, + p_msg2_full->size, + &p_msg3, + &msg3_size); + } while (SGX_ERROR_BUSY == ret && busy_retry_time--); + if(!p_msg3) + { + fprintf(OUTPUT, "\nError, call sgx_ra_proc_msg2 fail. " + "p_msg3 = 0x%p [%s].", p_msg3, __FUNCTION__); + ret = -1; + goto CLEANUP; + } + if(SGX_SUCCESS != (sgx_status_t)ret) + { + fprintf(OUTPUT, "\nError, call sgx_ra_proc_msg2 fail. " + "ret = 0x%08x [%s].", ret, __FUNCTION__); + ret = -1; + goto CLEANUP; + } + else + { + fprintf(OUTPUT, "\nCall sgx_ra_proc_msg2 success.\n"); + fprintf(OUTPUT, "\nMSG3 - \n"); + } + } + + PRINT_BYTE_ARRAY(OUTPUT, p_msg3, msg3_size); + + p_msg3_full = (ra_samp_request_header_t*)malloc( + sizeof(ra_samp_request_header_t) + msg3_size); + if(NULL == p_msg3_full) + { + ret = -1; + goto CLEANUP; + } + p_msg3_full->type = TYPE_RA_MSG3; + p_msg3_full->size = msg3_size; + if(memcpy_s(p_msg3_full->body, msg3_size, p_msg3, msg3_size)) + { + fprintf(OUTPUT,"\nError: INTERNAL ERROR - memcpy failed in [%s].", + __FUNCTION__); + ret = -1; + goto CLEANUP; + } + + // The ISV application sends msg3 to the SP to get the attestation + // result message, attestation result message needs to be freed when + // no longer needed. The ISV service provider decides whether to use + // linkable or unlinkable signatures. The format of the attestation + // result is up to the service provider. This format is used for + // demonstration. Note that the attestation result message makes use + // of both the MK for the MAC and the SK for the secret. These keys are + // established from the SIGMA secure channel binding. + ret = ra_network_send_receive("http://SampleServiceProvider.intel.com/", + p_msg3_full, + &p_att_result_msg_full); + if(ret || !p_att_result_msg_full) + { + ret = -1; + fprintf(OUTPUT, "\nError, sending msg3 failed [%s].", __FUNCTION__); + goto CLEANUP; + } + + + sample_ra_att_result_msg_t * p_att_result_msg_body = + (sample_ra_att_result_msg_t *)((uint8_t*)p_att_result_msg_full + + sizeof(ra_samp_response_header_t)); + if(TYPE_RA_ATT_RESULT != p_att_result_msg_full->type) + { + ret = -1; + fprintf(OUTPUT, "\nError. Sent MSG3 successfully, but the message " + "received was NOT of type att_msg_result. Type = " + "%d. [%s].", p_att_result_msg_full->type, + __FUNCTION__); + goto CLEANUP; + } + else + { + fprintf(OUTPUT, "\nSent MSG3 successfully. Received an attestation " + "result message back\n."); + if( VERIFICATION_INDEX_IS_VALID() ) + { + if(memcmp(p_att_result_msg_full->body, + attestation_msg_samples[GET_VERIFICATION_ARRAY_INDEX()], + p_att_result_msg_full->size) ) + { + fprintf(OUTPUT, "\nSent MSG3 successfully. Received an " + "attestation result message back that did " + "NOT match the expected value.\n"); + fprintf(OUTPUT, "\nEXPECTED ATTESTATION RESULT -"); + PRINT_BYTE_ARRAY(OUTPUT, + attestation_msg_samples[GET_VERIFICATION_ARRAY_INDEX()], + p_att_result_msg_full->size); + } + } + } + + fprintf(OUTPUT, "\nATTESTATION RESULT RECEIVED - "); + PRINT_BYTE_ARRAY(OUTPUT, p_att_result_msg_full->body, + p_att_result_msg_full->size); + + + if( VERIFICATION_INDEX_IS_VALID() ) + { + fprintf(OUTPUT, "\nBecause we used precomputed values for the " + "messages, the attestation result message will " + "not pass further verification tests, so we will " + "skip them.\n"); + goto CLEANUP; + } + + // Check the MAC using MK on the attestation result message. + // The format of the attestation result message is ISV specific. + // This is a simple form for demonstration. In a real product, + // the ISV may want to communicate more information. + ret = verify_att_result_mac(enclave_id, + &status, + context, + (uint8_t*)&p_att_result_msg_body->platform_info_blob, + sizeof(ias_platform_info_blob_t), + (uint8_t*)&p_att_result_msg_body->mac, + sizeof(sgx_mac_t)); + if((SGX_SUCCESS != ret) || + (SGX_SUCCESS != status)) + { + ret = -1; + fprintf(OUTPUT, "\nError: INTEGRITY FAILED - attestation result " + "message MK based cmac failed in [%s].", + __FUNCTION__); + goto CLEANUP; + } + + bool attestation_passed = true; + // Check the attestation result for pass or fail. + // @TODO: Check the status. This is ISV defined. + if(0 != p_att_result_msg_full->status[0] + || 0 != p_att_result_msg_full->status[1]) + { + fprintf(OUTPUT, "\nError, attestation result message MK based cmac " + "failed in [%s].", __FUNCTION__); + attestation_passed = false; + } + + // the SGX blob analysis API. The ISV will take action based on the + // update_info. (upgrade PSW or uCode), the second param should be 1 if + // the attestation failed, otherwise should be 0. + // sgx_update_info_bit_t update_info; + // ret = sgx_report_attestation_status( + // &p_att_result_msg_body->platform_info_blob, + // attestation_passed ? 0 : 1, &update_info); + // Get the shared secret sent by the server using SK (if attestation + // passed) + if(attestation_passed) + { + ret = put_secret_data(enclave_id, + &status, + context, + p_att_result_msg_body->secret.payload, + p_att_result_msg_body->secret.payload_size, + p_att_result_msg_body->secret.payload_tag); + if((SGX_SUCCESS != ret) || (SGX_SUCCESS != status)) + { + fprintf(OUTPUT, "\nError, attestation result message secret " + "using SK based AESGCM failed in [%s]. ret = " + "0x%0x. status = 0x%0x", __FUNCTION__, ret, + status); + goto CLEANUP; + } + } + fprintf(OUTPUT, "\nSecret successfully received from server."); + fprintf(OUTPUT, "\nRemote attestation success!"); + } + +CLEANUP: + // Clean-up + // Need to close the RA key state. + if(INT_MAX != context) + { + int ret_save = ret; + ret = enclave_ra_close(enclave_id, &status, context); + if(SGX_SUCCESS != ret || status) + { + ret = -1; + fprintf(OUTPUT, "\nError, call enclave_ra_close fail [%s].", + __FUNCTION__); + } + else + { + // enclave_ra_close was successful, let's restore the value that + // led us to this point in the code. + ret = ret_save; + } + fprintf(OUTPUT, "\nCall enclave_ra_close success."); + } + + sgx_destroy_enclave(enclave_id); + + + ra_free_network_response_buffer(p_msg2_full); + ra_free_network_response_buffer(p_att_result_msg_full); + + // p_msg3 is malloc'd by the untrused KE library. App needs to free. + SAFE_FREE(p_msg3); + SAFE_FREE(p_msg3_full); + SAFE_FREE(p_msg1_full); + printf("\nEnter a character before exit ...\n"); + getchar(); + return ret; +} + diff --git a/SampleCode/RemoteAttestation/isv_app/sample_messages.h b/SampleCode/RemoteAttestation/isv_app/sample_messages.h new file mode 100644 index 0000000000..92281777fa --- /dev/null +++ b/SampleCode/RemoteAttestation/isv_app/sample_messages.h @@ -0,0 +1,537 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +//This file contains samples of messages sent between the sample ISV application +//and the sample service provider. It is intended to be used so that authors +//of other service providers can verify that the messages generated by their +//remote attestation service matches. + +#include + +uint8_t msg1_sample1[] = +{ + 0xe8, 0xcf, 0xf, 0x97, 0x8a, 0xf4, 0x24, 0x8a, + 0xf5, 0x5b, 0x56, 0xf0, 0xac, 0x7f, 0x78, 0x39, + 0x71, 0x10, 0xb8, 0xdc, 0x88, 0xd, 0x50, 0xf0, + 0x39, 0x85, 0x37, 0xfe, 0xad, 0x1f, 0xc7, 0x59, + 0xc7, 0x23, 0x81, 0xfd, 0x4a, 0x2, 0x48, 0xdf, + 0xd3, 0x74, 0xda, 0x45, 0x48, 0x62, 0xc8, 0xb6, + 0x73, 0x43, 0x26, 0x42, 0x8f, 0x1f, 0x89, 0x17, + 0xe7, 0xa9, 0x2a, 0xf5, 0x27, 0xb3, 0xcc, 0x4d, + 0x3, 0x1, 0x0, 0x0 +}; + +uint8_t msg1_sample2[] = +{ + 0xa8, 0x56, 0x72, 0xc1, 0x14, 0x41, 0xa, 0x2f, + 0xdc, 0xb0, 0xa8, 0xa1, 0x3a, 0x51, 0x40, 0xf9, + 0x12, 0x9f, 0x11, 0x86, 0xe9, 0x1a, 0xf1, 0x16, + 0xbc, 0xd4, 0x6, 0x2f, 0x47, 0x2c, 0xc3, 0x37, + 0x8e, 0x65, 0x7, 0x29, 0x85, 0xb0, 0x8, 0x61, + 0x6b, 0x6d, 0xc7, 0x22, 0x7d, 0x22, 0x61, 0x7f, + 0x40, 0x43, 0x40, 0x5a, 0x7a, 0xf4, 0x94, 0x0, + 0x60, 0x36, 0xf6, 0xa4, 0x22, 0x22, 0x41, 0x82, + 0x3, 0x1, 0x0, 0x0 +}; + +uint8_t msg2_sample1[] = +{ + 0x2, 0x0, 0x0, 0xa8, 0x0, 0x0, 0x0, 0x0, + 0x6a, 0x83, 0xdc, 0x84, 0xd4, 0x4c, 0x8a, 0xbb, + 0x5e, 0x42, 0xaf, 0xee, 0x8d, 0xe9, 0xf4, 0x57, + 0x71, 0xfd, 0x73, 0x66, 0xd7, 0xfa, 0xad, 0xfa, + 0xf2, 0x17, 0x14, 0xdd, 0x5a, 0xb9, 0x9e, 0x97, + 0x79, 0xa7, 0x38, 0x72, 0xf2, 0xb8, 0xd6, 0xbe, + 0x18, 0x91, 0x7f, 0xf7, 0xb5, 0xd3, 0xe5, 0x64, + 0x9b, 0x12, 0x18, 0xaf, 0x39, 0x29, 0x6c, 0x24, + 0x19, 0x38, 0x29, 0xb, 0xc6, 0xac, 0xc, 0x62, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, + 0x58, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x1, 0x0, 0x6a, 0x83, 0xdc, 0x84, + 0xd4, 0x4c, 0x8a, 0xbb, 0x5e, 0x42, 0xaf, 0xee, + 0x8d, 0xe9, 0xf4, 0x57, 0x71, 0xfd, 0x73, 0x66, + 0xd7, 0xfa, 0xad, 0xfa, 0xf2, 0x17, 0x14, 0xdd, + 0x5a, 0xb9, 0x9e, 0x97, 0x6, 0x10, 0x58, 0x61, + 0xa5, 0xbf, 0x7d, 0x2e, 0xab, 0xcc, 0x1a, 0x3e, + 0x4f, 0x44, 0x15, 0xe7, 0x91, 0xca, 0x64, 0x2b, + 0x42, 0xb7, 0x53, 0xd9, 0x71, 0x37, 0xf1, 0x9b, + 0x31, 0xb5, 0xa5, 0x6b, 0xf8, 0xfa, 0x64, 0xfe, + 0x7a, 0x9e, 0xdc, 0xf4, 0xf0, 0x59, 0xbd, 0x78, + 0x27, 0xc2, 0x55, 0xb9, 0x0, 0x0, 0x0, 0x0 +}; + +uint8_t msg2_sample2[] = +{ + 0x2, 0x0, 0x0, 0xa8, 0x0, 0x0, 0x0, 0x0, + 0x6a, 0x83, 0xdc, 0x84, 0xd4, 0x4c, 0x8a, 0xbb, + 0x5e, 0x42, 0xaf, 0xee, 0x8d, 0xe9, 0xf4, 0x57, + 0x71, 0xfd, 0x73, 0x66, 0xd7, 0xfa, 0xad, 0xfa, + 0xf2, 0x17, 0x14, 0xdd, 0x5a, 0xb9, 0x9e, 0x97, + 0x79, 0xa7, 0x38, 0x72, 0xf2, 0xb8, 0xd6, 0xbe, + 0x18, 0x91, 0x7f, 0xf7, 0xb5, 0xd3, 0xe5, 0x64, + 0x9b, 0x12, 0x18, 0xaf, 0x39, 0x29, 0x6c, 0x24, + 0x19, 0x38, 0x29, 0xb, 0xc6, 0xac, 0xc, 0x62, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, + 0x58, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x1, 0x0, 0x6a, 0x83, 0xdc, 0x84, + 0xd4, 0x4c, 0x8a, 0xbb, 0x5e, 0x42, 0xaf, 0xee, + 0x8d, 0xe9, 0xf4, 0x57, 0x71, 0xfd, 0x73, 0x66, + 0xd7, 0xfa, 0xad, 0xfa, 0xf2, 0x17, 0x14, 0xdd, + 0x5a, 0xb9, 0x9e, 0x97, 0x75, 0x39, 0x23, 0x1b, + 0xc2, 0x5a, 0xd4, 0xfa, 0x41, 0xe9, 0xd4, 0x42, + 0x72, 0x8a, 0x75, 0x4b, 0x48, 0x5a, 0xfb, 0xc0, + 0x90, 0x42, 0xef, 0x9c, 0xed, 0xcb, 0xc1, 0x45, + 0x2d, 0xfe, 0x86, 0xbc, 0xee, 0x3, 0xa8, 0x97, + 0x68, 0xf0, 0xb4, 0xf, 0xa, 0x5b, 0x5f, 0xc1, + 0xe4, 0xf9, 0xa9, 0xa6, 0x0, 0x0, 0x0, 0x0 +}; + +#define MSG3_BODY_SIZE 1452 + +uint8_t msg3_sample1[MSG3_BODY_SIZE] = +{ + 0x57, 0x19, 0x8, 0xa1, 0x3b, 0xd0, 0x37, 0xa8, + 0x4a, 0x32, 0xf1, 0x31, 0xc1, 0x14, 0xff, 0xdf, + 0xe8, 0xcf, 0xf, 0x97, 0x8a, 0xf4, 0x24, 0x8a, + 0xf5, 0x5b, 0x56, 0xf0, 0xac, 0x7f, 0x78, 0x39, + 0x71, 0x10, 0xb8, 0xdc, 0x88, 0xd, 0x50, 0xf0, + 0x39, 0x85, 0x37, 0xfe, 0xad, 0x1f, 0xc7, 0x59, + 0xc7, 0x23, 0x81, 0xfd, 0x4a, 0x2, 0x48, 0xdf, + 0xd3, 0x74, 0xda, 0x45, 0x48, 0x62, 0xc8, 0xb6, + 0x73, 0x43, 0x26, 0x42, 0x8f, 0x1f, 0x89, 0x17, + 0xe7, 0xa9, 0x2a, 0xf5, 0x27, 0xb3, 0xcc, 0x4d, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x2, 0x0, 0x1, 0x0, 0x3, 0x1, 0x0, 0x0, + 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, + 0x58, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x2, 0x2, 0xff, 0xff, 0xff, 0x1, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xe2, 0x55, 0x5d, 0xc6, 0xe6, 0x69, 0x53, 0xc0, + 0x8d, 0x52, 0x5b, 0xc0, 0x2a, 0x2c, 0x5c, 0x2f, + 0xc, 0x8c, 0xfe, 0x5b, 0x1, 0xae, 0x89, 0xff, + 0x2, 0x2f, 0x97, 0xea, 0x9b, 0x45, 0xb6, 0x2e, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x60, 0x27, 0x7a, 0xd2, 0xfd, 0xfc, 0x57, 0xe9, + 0x80, 0xe8, 0x76, 0xe7, 0xf8, 0x78, 0xac, 0x19, + 0x9, 0x88, 0xe, 0xa5, 0x38, 0x7, 0x95, 0xa7, + 0xe8, 0xea, 0x98, 0xb1, 0x57, 0x84, 0x1f, 0x85, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x2a, 0xe, 0x9, 0x4c, 0xe2, 0xd9, 0x44, 0x73, + 0x36, 0x42, 0xfa, 0xe0, 0x44, 0x5b, 0x7b, 0x1f, + 0xc2, 0x85, 0x16, 0xca, 0xf1, 0xc5, 0xcd, 0xd2, + 0xf, 0xe4, 0xdf, 0xf, 0x31, 0xca, 0x36, 0x28, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xa8, 0x2, 0x0, 0x0, 0x68, 0xe3, 0x1d, 0x2, + 0xd1, 0x6, 0x2a, 0x16, 0xab, 0x1c, 0xfd, 0x43, + 0x5c, 0x1f, 0x34, 0x5, 0x15, 0xc4, 0x84, 0xdd, + 0xee, 0x73, 0x79, 0xe7, 0x2e, 0xc8, 0x95, 0x77, + 0x6b, 0xca, 0xff, 0xb9, 0xf4, 0xf8, 0x5a, 0x42, + 0x9d, 0x32, 0x73, 0x62, 0xab, 0x49, 0x8, 0xa4, + 0xc3, 0x5c, 0x5a, 0x66, 0x38, 0x76, 0xcd, 0x58, + 0x5b, 0x85, 0xbf, 0xf0, 0x52, 0x12, 0xd2, 0xc8, + 0xd, 0xf8, 0x6d, 0x91, 0xb8, 0xcf, 0x3f, 0x1d, + 0xe0, 0x1d, 0x63, 0xb2, 0x58, 0xa7, 0xbc, 0x8, + 0x97, 0xbb, 0xcc, 0x19, 0x31, 0xdb, 0x47, 0xf3, + 0x8e, 0x54, 0x7d, 0x36, 0x6e, 0x6, 0xd3, 0x20, + 0xca, 0x5e, 0x8a, 0x5, 0x30, 0x50, 0x56, 0xe9, + 0x91, 0x9, 0x35, 0x13, 0x69, 0xd, 0x24, 0x71, + 0x55, 0xca, 0xe8, 0xef, 0x4d, 0x1c, 0xe6, 0x1f, + 0x51, 0xeb, 0x12, 0x32, 0x97, 0xa2, 0xbb, 0x1e, + 0xf2, 0x26, 0xc5, 0xe9, 0x3f, 0xda, 0x79, 0xc3, + 0x89, 0x28, 0x9, 0x6c, 0x59, 0x9e, 0x2d, 0x60, + 0x5f, 0x35, 0x33, 0x76, 0xfe, 0xf5, 0xba, 0x73, + 0xc5, 0xb6, 0x44, 0x9d, 0xb9, 0x3a, 0x90, 0x8, + 0x5e, 0xba, 0x33, 0x3d, 0xe5, 0xff, 0xc0, 0x5b, + 0xbb, 0x7b, 0xbc, 0x39, 0x52, 0x6f, 0x54, 0x8b, + 0xb5, 0x44, 0xf7, 0x75, 0xc5, 0x28, 0xa7, 0x51, + 0xd, 0x69, 0x2b, 0x3a, 0xfd, 0xc0, 0x7c, 0x6f, + 0xf, 0xcf, 0x76, 0x32, 0xea, 0x38, 0xd2, 0x8d, + 0xbe, 0x9c, 0xef, 0x3b, 0x56, 0xdc, 0x8e, 0x29, + 0x40, 0x87, 0x4, 0xe6, 0x15, 0xa1, 0x12, 0x9f, + 0x21, 0x12, 0xe8, 0xd8, 0x5, 0x26, 0x22, 0x23, + 0x12, 0x57, 0xd1, 0xb6, 0x3, 0x59, 0xfa, 0xa6, + 0xfe, 0x24, 0xe1, 0x84, 0xfb, 0x63, 0xf3, 0x3d, + 0xf1, 0xe2, 0x70, 0x2c, 0x94, 0xf1, 0xa4, 0xdc, + 0x70, 0x31, 0xda, 0x9e, 0xb9, 0xf7, 0xc6, 0xba, + 0xd3, 0x4e, 0x5c, 0x63, 0xf1, 0x78, 0xcc, 0x38, + 0xc2, 0x1a, 0xd6, 0x2, 0x34, 0x23, 0x1a, 0x4b, + 0x1, 0x4e, 0xf4, 0xe6, 0xe, 0x6b, 0xfa, 0x27, + 0x8d, 0xe3, 0x67, 0x5d, 0xec, 0x79, 0x13, 0x66, + 0x46, 0xbb, 0xd0, 0x8e, 0xc8, 0x21, 0x6f, 0x37, + 0x5c, 0x5e, 0x5d, 0xed, 0x8e, 0x2d, 0x8d, 0x94, + 0x68, 0x1, 0x0, 0x0, 0x84, 0xd5, 0x35, 0x93, + 0x3a, 0xb1, 0x19, 0x8e, 0xb6, 0xb0, 0x5f, 0x4f, + 0x66, 0x8a, 0xb3, 0xe0, 0x12, 0xbb, 0x7, 0xe0, + 0xa3, 0x6b, 0x54, 0xd5, 0xf6, 0xc8, 0x2, 0xdd, + 0x33, 0x78, 0x3c, 0x4f, 0xdc, 0xa3, 0x3e, 0x5c, + 0x99, 0xb8, 0x2f, 0x3f, 0xdf, 0xf0, 0xf0, 0x63, + 0x24, 0x6f, 0xc2, 0x17, 0xeb, 0x45, 0xd5, 0x79, + 0xaa, 0xb5, 0x46, 0x4b, 0x77, 0x6d, 0x3d, 0xbf, + 0xe8, 0xca, 0xaf, 0x4d, 0xb5, 0x5d, 0xee, 0x9e, + 0xf5, 0x73, 0x8d, 0x1, 0xff, 0x84, 0x1e, 0xc9, + 0x78, 0x2e, 0xde, 0x3, 0x97, 0x36, 0x1c, 0x47, + 0xc, 0x46, 0x5, 0xfc, 0x8b, 0xf5, 0xd5, 0x13, + 0xa3, 0x8, 0xd4, 0x29, 0x83, 0xfb, 0x4b, 0x3e, + 0xf1, 0x3d, 0xe8, 0x54, 0x28, 0x2f, 0x3d, 0x9c, + 0x8b, 0x91, 0xcc, 0xf0, 0x45, 0x40, 0x3, 0xb, + 0xaa, 0x41, 0x38, 0x2f, 0xad, 0xc3, 0x1d, 0x61, + 0x15, 0x20, 0x9, 0xea, 0xfd, 0xdb, 0xf9, 0x17, + 0x84, 0x19, 0xae, 0xf3, 0x4b, 0x4d, 0x8e, 0xa2, + 0x3e, 0x9c, 0xb3, 0x70, 0x4d, 0x38, 0x1, 0x5, + 0xb7, 0xc, 0xb2, 0xf6, 0x84, 0xbe, 0xbc, 0xd5, + 0xd1, 0x8a, 0x22, 0xfc, 0x82, 0xb4, 0x3b, 0x96, + 0x8f, 0xc0, 0x49, 0xaa, 0xf0, 0x52, 0x25, 0xda, + 0x39, 0xc2, 0x4c, 0xbc, 0xe2, 0x47, 0xe3, 0xc, + 0x59, 0xad, 0x40, 0x42, 0x17, 0x30, 0x4d, 0x1c, + 0x34, 0xd3, 0xdb, 0xa7, 0xc5, 0x9c, 0xef, 0x83, + 0xd, 0xb8, 0x9a, 0xa9, 0x29, 0x1b, 0x11, 0x32, + 0x74, 0x53, 0x17, 0x34, 0xd6, 0xa2, 0x14, 0x6, + 0x8b, 0xae, 0x8c, 0xb4, 0xcb, 0x20, 0xec, 0xb3, + 0x2f, 0xe, 0xf3, 0x8f, 0xc3, 0x84, 0xe3, 0xb8, + 0x46, 0x51, 0xea, 0xa6, 0x1c, 0x27, 0x31, 0x1e, + 0x69, 0xb, 0xc7, 0x47, 0xad, 0x7d, 0xde, 0x3f, + 0x13, 0x2b, 0x5e, 0x2a, 0x24, 0x37, 0x85, 0xa4, + 0x8d, 0x45, 0x39, 0xeb, 0x95, 0x47, 0xb8, 0x57, + 0x5d, 0x88, 0xeb, 0x56, 0xb0, 0xa8, 0x58, 0xd, + 0x9e, 0x1b, 0x80, 0x3a, 0x74, 0x86, 0x3a, 0x58, + 0xfc, 0xa6, 0xa, 0xc5, 0x66, 0x5f, 0xc7, 0xa9, + 0xd5, 0xc, 0x37, 0xd1, 0x23, 0xff, 0xfd, 0x1d, + 0x38, 0x1c, 0x98, 0xd1, 0xa9, 0x24, 0x3b, 0x23, + 0xa2, 0x1a, 0xee, 0x8, 0x31, 0x4f, 0xd5, 0xaa, + 0x1d, 0x67, 0xe7, 0x77, 0x5c, 0x46, 0xcc, 0xb, + 0x18, 0xf6, 0xdd, 0x86, 0xf4, 0xcc, 0xb4, 0xd5, + 0xcd, 0xe6, 0xae, 0xb3, 0xf0, 0x24, 0x15, 0x71, + 0xb3, 0x65, 0xff, 0xfa, 0xe5, 0x1a, 0x6d, 0xc3, + 0x6f, 0x43, 0x73, 0xe0, 0xe8, 0xa9, 0x6f, 0x68, + 0xf8, 0x4, 0xf2, 0x73, 0x1, 0x36, 0xeb, 0x83, + 0xa5, 0xf2, 0x6e, 0x4e, 0x36, 0xa5, 0x63, 0xab, + 0x7d, 0xa1, 0xd2, 0x24, 0x17, 0xb7, 0x3b, 0x96, + 0x4b, 0xbe, 0x4c, 0xcb +}; + + +uint8_t msg3_sample2[MSG3_BODY_SIZE] = +{ + 0x4f, 0x85, 0xd3, 0x93, 0xc, 0x44, 0x9c, 0xdd, + 0x3e, 0x81, 0xbd, 0xb6, 0xa2, 0x44, 0x16, 0x5f, + 0xa8, 0x56, 0x72, 0xc1, 0x14, 0x41, 0xa, 0x2f, + 0xdc, 0xb0, 0xa8, 0xa1, 0x3a, 0x51, 0x40, 0xf9, + 0x12, 0x9f, 0x11, 0x86, 0xe9, 0x1a, 0xf1, 0x16, + 0xbc, 0xd4, 0x6, 0x2f, 0x47, 0x2c, 0xc3, 0x37, + 0x8e, 0x65, 0x7, 0x29, 0x85, 0xb0, 0x8, 0x61, + 0x6b, 0x6d, 0xc7, 0x22, 0x7d, 0x22, 0x61, 0x7f, + 0x40, 0x43, 0x40, 0x5a, 0x7a, 0xf4, 0x94, 0x0, + 0x60, 0x36, 0xf6, 0xa4, 0x22, 0x22, 0x41, 0x82, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x2, 0x0, 0x1, 0x0, 0x3, 0x1, 0x0, 0x0, + 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, + 0x58, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x2, 0x2, 0xff, 0xff, 0xff, 0x1, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xe2, 0x55, 0x5d, 0xc6, 0xe6, 0x69, 0x53, 0xc0, + 0x8d, 0x52, 0x5b, 0xc0, 0x2a, 0x2c, 0x5c, 0x2f, + 0xc, 0x8c, 0xfe, 0x5b, 0x1, 0xae, 0x89, 0xff, + 0x2, 0x2f, 0x97, 0xea, 0x9b, 0x45, 0xb6, 0x2e, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x60, 0x27, 0x7a, 0xd2, 0xfd, 0xfc, 0x57, 0xe9, + 0x80, 0xe8, 0x76, 0xe7, 0xf8, 0x78, 0xac, 0x19, + 0x9, 0x88, 0xe, 0xa5, 0x38, 0x7, 0x95, 0xa7, + 0xe8, 0xea, 0x98, 0xb1, 0x57, 0x84, 0x1f, 0x85, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xdd, 0xda, 0x3e, 0x6b, 0x72, 0xa2, 0xd7, 0x31, + 0x31, 0x32, 0xbd, 0xf3, 0xf4, 0xc0, 0xe3, 0xaa, + 0x16, 0x19, 0x72, 0x47, 0x92, 0xe7, 0x8f, 0xf8, + 0x40, 0x2b, 0xa7, 0xc0, 0xb9, 0x77, 0xb1, 0x1c, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xa8, 0x2, 0x0, 0x0, 0x2e, 0x23, 0x7d, 0xe8, + 0x5d, 0xcd, 0x6d, 0x88, 0x6f, 0xad, 0xd3, 0x4c, + 0x7e, 0xed, 0xff, 0xa2, 0xea, 0x1c, 0xd5, 0xc8, + 0x54, 0xbb, 0x93, 0xc8, 0x1b, 0xbe, 0xbe, 0x51, + 0x6b, 0x8d, 0xb7, 0x90, 0x7f, 0x87, 0x9f, 0x9b, + 0x66, 0x4f, 0xeb, 0xf4, 0x34, 0xbb, 0x90, 0x5d, + 0xc5, 0x20, 0x7b, 0xd2, 0x5a, 0x92, 0x42, 0x80, + 0x2f, 0x3f, 0xc2, 0x64, 0x7e, 0x77, 0xa, 0x49, + 0xdb, 0xde, 0x77, 0x88, 0xd7, 0xce, 0xdb, 0x2e, + 0x44, 0x50, 0x26, 0xd8, 0x7a, 0xe, 0x1c, 0x7f, + 0x63, 0x36, 0x62, 0xa8, 0xa7, 0x2e, 0x60, 0x56, + 0xf4, 0xbc, 0xb5, 0xca, 0xc3, 0x81, 0x9e, 0x84, + 0xb8, 0xc, 0xef, 0x7a, 0x18, 0x4a, 0x5b, 0x3, + 0x0, 0xe3, 0x8c, 0x3f, 0x2e, 0xf9, 0x9a, 0xf7, + 0x72, 0xe1, 0xa0, 0x5e, 0x6a, 0x4c, 0x68, 0xea, + 0x67, 0xfc, 0xe8, 0x21, 0x27, 0x90, 0xae, 0xbf, + 0x51, 0xa4, 0xc9, 0xae, 0x3d, 0x3b, 0x5c, 0x53, + 0x7e, 0x25, 0xa4, 0x6f, 0x78, 0x99, 0x35, 0x2e, + 0x48, 0x50, 0xf9, 0xf0, 0x63, 0x90, 0x19, 0x6a, + 0xc, 0x3d, 0x48, 0x2a, 0x5f, 0x6f, 0xb, 0xd7, + 0x26, 0x64, 0xb5, 0xe0, 0x60, 0x36, 0x69, 0x40, + 0x9c, 0x21, 0x29, 0xe0, 0xca, 0xae, 0xd1, 0x7a, + 0x4, 0xb8, 0x8d, 0x96, 0x74, 0xa3, 0x7, 0xa4, + 0x41, 0x9e, 0xf7, 0x9, 0xbe, 0x8f, 0xe8, 0x65, + 0xd9, 0x26, 0x16, 0xa1, 0xef, 0x1b, 0xf4, 0xb7, + 0xd5, 0xfe, 0xd6, 0x7d, 0xa6, 0x6c, 0x50, 0x8c, + 0x90, 0x34, 0x1f, 0x17, 0x8c, 0x14, 0x38, 0x6d, + 0xd7, 0x83, 0x1a, 0x1e, 0xcf, 0xf5, 0xb, 0xdb, + 0x26, 0x8f, 0x23, 0xf9, 0x4f, 0x41, 0x73, 0xac, + 0x9d, 0xfa, 0x77, 0x3, 0x6a, 0x32, 0xbb, 0x37, + 0x93, 0x47, 0x38, 0x93, 0x39, 0xd2, 0x51, 0x46, + 0xaf, 0xfd, 0x71, 0xda, 0x89, 0xc7, 0x44, 0xb0, + 0xf3, 0x95, 0x74, 0x3b, 0xbc, 0x7d, 0x86, 0xc1, + 0x6e, 0x49, 0xd8, 0x52, 0xc, 0xc1, 0x88, 0x72, + 0x5, 0x5c, 0x92, 0x12, 0x22, 0x95, 0xc5, 0x12, + 0xf5, 0xfa, 0x11, 0x8d, 0x50, 0x42, 0x33, 0x4, + 0x41, 0x17, 0x90, 0xc8, 0xb3, 0x1d, 0x2e, 0xe5, + 0x13, 0xf5, 0xd6, 0xb1, 0xc5, 0xd4, 0x6d, 0xe1, + 0x68, 0x1, 0x0, 0x0, 0xc4, 0x15, 0xbf, 0x91, + 0xf1, 0xad, 0xb1, 0x9f, 0x9b, 0x6b, 0x8d, 0xa2, + 0xdf, 0x7d, 0x6, 0xf8, 0xba, 0x73, 0xb7, 0xb, + 0x72, 0xcc, 0x34, 0x4d, 0x52, 0x3b, 0x76, 0xfd, + 0x8e, 0x3a, 0x67, 0xcc, 0x36, 0xb, 0xa9, 0xc2, + 0x90, 0x37, 0x77, 0x75, 0x90, 0xb8, 0x97, 0x44, + 0xed, 0xb4, 0x61, 0xe8, 0x11, 0xe9, 0x2, 0x50, + 0xde, 0x98, 0x99, 0x3e, 0xf6, 0x5c, 0x71, 0x92, + 0x49, 0xcb, 0x0, 0x72, 0xe0, 0x55, 0xa9, 0x6e, + 0xc7, 0x2, 0xf4, 0x2b, 0x3c, 0xe3, 0x42, 0x7e, + 0x8b, 0xf, 0x26, 0xd9, 0x42, 0x21, 0xd5, 0x74, + 0xe3, 0x35, 0xb3, 0xb8, 0xfe, 0x25, 0x1d, 0x47, + 0x5b, 0x35, 0x8d, 0xfd, 0x18, 0x77, 0x29, 0xd9, + 0x69, 0x2b, 0x67, 0x54, 0x8c, 0xf5, 0xd7, 0x84, + 0x36, 0xf3, 0x96, 0xca, 0xb9, 0x42, 0xad, 0xd6, + 0xba, 0x8d, 0x2f, 0xfc, 0x21, 0xfe, 0xa7, 0xea, + 0x59, 0x94, 0xfe, 0x95, 0x1f, 0x1e, 0xb9, 0xca, + 0x5e, 0x4d, 0xf1, 0x2, 0x68, 0x91, 0xf7, 0xa1, + 0xea, 0x11, 0x90, 0x95, 0x1c, 0xf7, 0x85, 0xd4, + 0x70, 0xf9, 0x49, 0xae, 0x5e, 0xa5, 0x62, 0x3d, + 0x35, 0xc5, 0xdf, 0xc1, 0x7f, 0xc7, 0x39, 0x5a, + 0x3b, 0x89, 0x8c, 0x80, 0x71, 0xe7, 0xbc, 0xbf, + 0x4e, 0x72, 0x6d, 0xd7, 0xe0, 0xa2, 0xb0, 0x7d, + 0xca, 0x89, 0x22, 0x6, 0xb2, 0xb4, 0x3c, 0xa2, + 0xed, 0x51, 0xf, 0xa2, 0xf7, 0xc9, 0x89, 0xf0, + 0x27, 0x2f, 0xf6, 0x41, 0x4e, 0xa, 0x2b, 0x67, + 0x49, 0x44, 0x8e, 0x40, 0xc6, 0xb8, 0xad, 0xb8, + 0x40, 0xb, 0xba, 0x73, 0x2e, 0x1d, 0x4, 0xc9, + 0x28, 0x62, 0x6b, 0x3d, 0xe6, 0x5f, 0x1c, 0xdd, + 0xae, 0x27, 0x6d, 0x3c, 0x2d, 0xf6, 0x42, 0x3b, + 0x91, 0x1, 0x37, 0x47, 0x76, 0x5, 0xbc, 0x7, + 0x8c, 0x6, 0x81, 0x77, 0x70, 0x9d, 0x8a, 0x75, + 0x34, 0x1, 0x68, 0x1a, 0x38, 0x13, 0x11, 0x74, + 0xf2, 0x70, 0x4f, 0x9b, 0x86, 0x15, 0xc6, 0xbc, + 0x6b, 0x1a, 0x56, 0x3f, 0x4f, 0xfa, 0xd4, 0x17, + 0x97, 0xbb, 0x4b, 0x91, 0x3b, 0x54, 0xf7, 0x8e, + 0x53, 0xf5, 0x2, 0x21, 0x3b, 0x66, 0xf9, 0xe5, + 0x79, 0xff, 0xeb, 0x5c, 0x66, 0x1b, 0x34, 0xf4, + 0x41, 0xd1, 0x9a, 0xdb, 0x1f, 0x3e, 0xe3, 0x8a, + 0x90, 0x98, 0x9e, 0x73, 0xb9, 0xa8, 0x20, 0xfe, + 0xe7, 0xe3, 0x9f, 0x83, 0xd3, 0x95, 0x5f, 0xa, + 0x40, 0x53, 0x6a, 0xd3, 0x72, 0x32, 0xde, 0xf1, + 0xf, 0x98, 0x2b, 0x7d, 0x6e, 0x76, 0xbd, 0x31, + 0x84, 0x99, 0x1c, 0xdc, 0xac, 0x78, 0x44, 0xbf, + 0x29, 0xdd, 0x2e, 0xe3, 0x39, 0x9d, 0x38, 0x83, + 0xa, 0x3e, 0x83, 0xb6, 0x74, 0x44, 0x4d, 0x78, + 0x55, 0xb2, 0xe0, 0x74, 0x25, 0x61, 0x67, 0xc0, + 0xe8, 0x1e, 0x5e, 0xd8 +}; + +uint8_t attestation_msg_sample1[] = +{ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x97, 0x9e, 0xb9, 0x5a, 0xdd, 0x14, 0x17, + 0xf2, 0xfa, 0xad, 0xfa, 0xd7, 0x66, 0x73, 0xfd, + 0x71, 0x57, 0xf4, 0xe9, 0x8d, 0xee, 0xaf, 0x42, + 0x5e, 0xbb, 0x8a, 0x4c, 0xd4, 0x84, 0xdc, 0x83, + 0x6a, 0x8, 0x70, 0xd, 0xf2, 0x42, 0x8b, 0x2b, + 0xee, 0x42, 0xb0, 0x85, 0xe5, 0xbf, 0x99, 0xc5, + 0x22, 0xf8, 0x37, 0xf7, 0xee, 0xb6, 0x2c, 0xd5, + 0x8c, 0x37, 0xa2, 0xd2, 0x51, 0xed, 0x45, 0xf9, + 0x65, 0xf2, 0x25, 0x8a, 0xf9, 0x9, 0x2d, 0xdb, + 0xdc, 0x4a, 0x73, 0xbd, 0x15, 0x49, 0x2, 0x10, + 0xd, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x54, 0x1c, 0xdd, 0x52, 0x93, 0xd8, 0xd4, + 0x28, 0x9d, 0x24, 0x7d, 0x4b, 0xe5, 0xcc, 0xe8, + 0xc0 +}; + +uint8_t attestation_msg_sample2[] = +{ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x97, 0x9e, 0xb9, 0x5a, 0xdd, 0x14, 0x17, + 0xf2, 0xfa, 0xad, 0xfa, 0xd7, 0x66, 0x73, 0xfd, + 0x71, 0x57, 0xf4, 0xe9, 0x8d, 0xee, 0xaf, 0x42, + 0x5e, 0xbb, 0x8a, 0x4c, 0xd4, 0x84, 0xdc, 0x83, + 0x6a, 0x8, 0x70, 0xd, 0xf2, 0x42, 0x8b, 0x2b, + 0xee, 0x42, 0xb0, 0x85, 0xe5, 0xbf, 0x99, 0xc5, + 0x22, 0xf8, 0x37, 0xf7, 0xee, 0xb6, 0x2c, 0xd5, + 0x8c, 0x37, 0xa2, 0xd2, 0x51, 0xed, 0x45, 0xf9, + 0x65, 0x82, 0x12, 0xa8, 0x53, 0x84, 0x65, 0x62, + 0x33, 0xc0, 0x6, 0x86, 0x9f, 0x82, 0xbb, 0x6d, + 0xd6, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0xb1, 0x60, 0x31, 0x45, 0xd1, 0xa9, 0x23, + 0x7b, 0x85, 0x3f, 0x8, 0x3f, 0x48, 0x6d, 0x2d, + 0xad +}; diff --git a/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.config.xml b/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.config.xml new file mode 100644 index 0000000000..0b95a3edb1 --- /dev/null +++ b/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.config.xml @@ -0,0 +1,11 @@ + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + \ No newline at end of file diff --git a/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.cpp b/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.cpp new file mode 100644 index 0000000000..1d8182e3a0 --- /dev/null +++ b/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "isv_enclave_t.h" +#include "sgx_tkey_exchange.h" +#include "sgx_tcrypto.h" +#include "string.h" + +// This is the public EC key of the SP. The corresponding private EC key is +// used by the SP to sign data used in the remote attestation SIGMA protocol +// to sign channel binding data in MSG2. A successful verification of the +// signature confirms the identity of the SP to the ISV app in remote +// attestation secure channel binding. The public EC key should be hardcoded in +// the enclave or delivered in a trustworthy manner. The use of a spoofed public +// EC key in the remote attestation with secure channel binding session may lead +// to a security compromise. Every different SP the enlcave communicates to +// must have a unique SP public key. Delivery of the SP public key is +// determined by the ISV. The TKE SIGMA protocl expects an Elliptical Curve key +// based on NIST P-256 +static const sgx_ec256_public_t g_sp_pub_key = { + { + 0x72, 0x12, 0x8a, 0x7a, 0x17, 0x52, 0x6e, 0xbf, + 0x85, 0xd0, 0x3a, 0x62, 0x37, 0x30, 0xae, 0xad, + 0x3e, 0x3d, 0xaa, 0xee, 0x9c, 0x60, 0x73, 0x1d, + 0xb0, 0x5b, 0xe8, 0x62, 0x1c, 0x4b, 0xeb, 0x38 + }, + { + 0xd4, 0x81, 0x40, 0xd9, 0x50, 0xe2, 0x57, 0x7b, + 0x26, 0xee, 0xb7, 0x41, 0xe7, 0xc6, 0x14, 0xe2, + 0x24, 0xb7, 0xbd, 0xc9, 0x03, 0xf2, 0x9a, 0x28, + 0xa8, 0x3c, 0xc8, 0x10, 0x11, 0x14, 0x5e, 0x06 + } + +}; + +// Used to store the secret passed by the SP in the sample code. The +// size is forced to be 8 bytes. Expected value is +// 0x01,0x02,0x03,0x04,0x0x5,0x0x6,0x0x7 +uint8_t g_secret[8] = {0}; + + +// This ecall is a wrapper of sgx_ra_init to create the trusted +// KE exchange key context needed for the remote attestation +// SIGMA API's. Input pointers aren't checked since the trusted stubs +// copy them into EPC memory. +// +// @param b_pse Indicates whether the ISV app is using the +// platform services. +// @param p_context Pointer to the location where the returned +// key context is to be copied. +// +// @return Any error return from the create PSE session if b_pse +// is true. +// @return Any error returned from the trusted key exchange API +// for creating a key context. + +sgx_status_t enclave_init_ra( + int b_pse, + sgx_ra_context_t *p_context) +{ + // isv enclave call to trusted key exchange library. + sgx_status_t ret; + if(b_pse) + { + int busy_retry_times = 2; + do{ + ret = sgx_create_pse_session(); + }while (ret == SGX_ERROR_BUSY && busy_retry_times--); + if (ret != SGX_SUCCESS) + return ret; + } + ret = sgx_ra_init(&g_sp_pub_key, b_pse, p_context); + if(b_pse) + { + sgx_close_pse_session(); + return ret; + } + return ret; +} + + +// Closes the tKE key context used during the SIGMA key +// exchange. +// +// @param context The trusted KE library key context. +// +// @return Return value from the key context close API + +sgx_status_t SGXAPI enclave_ra_close( + sgx_ra_context_t context) +{ + sgx_status_t ret; + ret = sgx_ra_close(context); + return ret; +} + + +// Verify the mac sent in att_result_msg from the SP using the +// MK key. Input pointers aren't checked since the trusted stubs +// copy them into EPC memory. +// +// +// @param context The trusted KE library key context. +// @param p_message Pointer to the message used to produce MAC +// @param message_size Size in bytes of the message. +// @param p_mac Pointer to the MAC to compare to. +// @param mac_size Size in bytes of the MAC +// +// @return SGX_ERROR_INVALID_PARAMETER - MAC size is incorrect. +// @return Any error produced by tKE API to get SK key. +// @return Any error produced by the AESCMAC function. +// @return SGX_ERROR_MAC_MISMATCH - MAC compare fails. + +sgx_status_t verify_att_result_mac(sgx_ra_context_t context, + uint8_t* p_message, + size_t message_size, + uint8_t* p_mac, + size_t mac_size) +{ + sgx_status_t ret; + sgx_ec_key_128bit_t mk_key; + + if(mac_size != sizeof(sgx_mac_t)) + { + ret = SGX_ERROR_INVALID_PARAMETER; + return ret; + } + if(message_size > UINT32_MAX) + { + ret = SGX_ERROR_INVALID_PARAMETER; + return ret; + } + + do { + uint8_t mac[SGX_CMAC_MAC_SIZE] = {0}; + + ret = sgx_ra_get_keys(context, SGX_RA_KEY_MK, &mk_key); + if(SGX_SUCCESS != ret) + { + break; + } + ret = sgx_rijndael128_cmac_msg(&mk_key, + p_message, + (uint32_t)message_size, + &mac); + if(SGX_SUCCESS != ret) + { + break; + } + if(0 == consttime_memequal(p_mac, mac, sizeof(mac))) + { + ret = SGX_ERROR_MAC_MISMATCH; + break; + } + + } + while(0); + + return ret; +} + + +// Generate a secret information for the SP encrypted with SK. +// Input pointers aren't checked since the trusted stubs copy +// them into EPC memory. +// +// @param context The trusted KE library key context. +// @param p_secret Message containing the secret. +// @param secret_size Size in bytes of the secret message. +// @param p_gcm_mac The pointer the the AESGCM MAC for the +// message. +// +// @return SGX_ERROR_INVALID_PARAMETER - secret size if +// incorrect. +// @return Any error produced by tKE API to get SK key. +// @return Any error produced by the AESGCM function. +// @return SGX_ERROR_UNEXPECTED - the secret doesn't match the +// expected value. + +sgx_status_t put_secret_data( + sgx_ra_context_t context, + uint8_t *p_secret, + uint32_t secret_size, + uint8_t *p_gcm_mac) +{ + sgx_status_t ret = SGX_SUCCESS; + sgx_ec_key_128bit_t sk_key; + + do { + if(secret_size != 8) + { + ret = SGX_ERROR_INVALID_PARAMETER; + break; + } + + ret = sgx_ra_get_keys(context, SGX_RA_KEY_SK, &sk_key); + if(SGX_SUCCESS != ret) + { + break; + } + + uint8_t aes_gcm_iv[12] = {0}; + ret = sgx_rijndael128GCM_decrypt(&sk_key, + p_secret, + secret_size, + &g_secret[0], + &aes_gcm_iv[0], + 12, + NULL, + 0, + (const sgx_aes_gcm_128bit_tag_t *) + (p_gcm_mac)); + + uint32_t i; + bool secret_match = true; + for(i=0;i +#include +#include "ecp.h" + +#include "sample_libcrypto.h" + + +#define MAC_KEY_SIZE 16 + +errno_t memcpy_s( + void *dest, + size_t numberOfElements, + const void *src, + size_t count) +{ + if(numberOfElements +#include + +#include "remote_attestation_result.h" + +#ifndef SAMPLE_FEBITSIZE +#define SAMPLE_FEBITSIZE 256 +#endif + +#define SAMPLE_ECP_KEY_SIZE (SAMPLE_FEBITSIZE/8) + +typedef struct sample_ec_priv_t +{ + uint8_t r[SAMPLE_ECP_KEY_SIZE]; +} sample_ec_priv_t; + +typedef struct sample_ec_dh_shared_t +{ + uint8_t s[SAMPLE_ECP_KEY_SIZE]; +}sample_ec_dh_shared_t; + +typedef uint8_t sample_ec_key_128bit_t[16]; + +#define SAMPLE_EC_MAC_SIZE 16 + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif +errno_t memcpy_s(void *dest, size_t numberOfElements, const void *src, + size_t count); + + +typedef enum _sample_derive_key_type_t +{ + SAMPLE_DERIVE_KEY_SMK = 0, + SAMPLE_DERIVE_KEY_SK, + SAMPLE_DERIVE_KEY_MK, + SAMPLE_DERIVE_KEY_VK, +} sample_derive_key_type_t; + +bool derive_key( + const sample_ec_dh_shared_t *p_shared_key, + uint8_t key_id, + sample_ec_key_128bit_t *derived_key); + +bool verify_cmac128( + sample_ec_key_128bit_t mac_key, + const uint8_t *p_data_buf, + uint32_t buf_size, + const uint8_t *p_mac_buf); +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/SampleCode/RemoteAttestation/service_provider/ias_ra.cpp b/SampleCode/RemoteAttestation/service_provider/ias_ra.cpp new file mode 100644 index 0000000000..e39d1b1942 --- /dev/null +++ b/SampleCode/RemoteAttestation/service_provider/ias_ra.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "service_provider.h" +#include "sample_libcrypto.h" +#include "ecp.h" +#include +#include +#include +#include +#include +#include "ias_ra.h" + +// @TODO: This whole file is used as simulation of the interfaces to be +// delivered the IAS. Once the interface definitions are made available by the +// IAS, this file should be changed accordingly. + +#define UNUSED(expr) do { (void)(expr); } while (0) + +#if !defined(SWAP_ENDIAN_DW) + #define SWAP_ENDIAN_DW(dw) ((((dw) & 0x000000ff) << 24) \ + | (((dw) & 0x0000ff00) << 8) \ + | (((dw) & 0x00ff0000) >> 8) \ + | (((dw) & 0xff000000) >> 24)) +#endif +#if !defined(SWAP_ENDIAN_32B) + #define SWAP_ENDIAN_32B(ptr) \ +{\ + unsigned int temp = 0; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[0]); \ + ((unsigned int*)(ptr))[0] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[7]); \ + ((unsigned int*)(ptr))[7] = temp; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[1]); \ + ((unsigned int*)(ptr))[1] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[6]); \ + ((unsigned int*)(ptr))[6] = temp; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[2]); \ + ((unsigned int*)(ptr))[2] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[5]); \ + ((unsigned int*)(ptr))[5] = temp; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[3]); \ + ((unsigned int*)(ptr))[3] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[4]); \ + ((unsigned int*)(ptr))[4] = temp; \ +} +#endif + +// This is the ECDSA NIST P-256 private key used to sign platform_info_blob. +// This private +// key and the public key in SDK untrusted KElibrary should be a temporary key +// pair. For production parts the IAS will sign the platform_info_blob with the +// production private key and the SDK untrusted KE library will have the public +// key for verifcation. +// @TODO: This key will will not be available when the production backend +// is avaialbe. The remote attestation sample will need to change to use the +// real backend. This will likely be an RSA2048 type of key. +static const sample_ec256_private_t g_rk_priv_key = +{{ + 0x63,0x2c,0xd4,0x02,0x7a,0xdc,0x56,0xa5, + 0x59,0x6c,0x44,0x3e,0x43,0xca,0x4e,0x0b, + 0x58,0xcd,0x78,0xcb,0x3c,0x7e,0xd5,0xb9, + 0xf2,0x91,0x5b,0x39,0x0d,0xb3,0xb5,0xfb +}}; + +static sample_spid_t g_sim_spid = {"Service X"}; + + +// Simulates the IAS function for verifying the quote produce by +// the ISV enclave. It doesn't decrypt or verify the quote in +// the simulation. Just produces the attestaion verification +// report with the platform info blob. +// +// @param p_isv_quote Pointer to the quote generated by the ISV +// enclave. +// @param pse_manifest Pointer to the PSE manifest if used. +// @param p_attestation_verification_report Pointer the outputed +// verification report. +// +// @return int + +int ias_verify_attestation_evidence( + sample_quote_t *p_isv_quote, + uint8_t* pse_manifest, + ias_att_report_t* p_attestation_verification_report) +{ + int ret = 0; + sample_ecc_state_handle_t ecc_state = NULL; + + //unused parameters + UNUSED(pse_manifest); + + if((NULL == p_isv_quote) || + (NULL == p_attestation_verification_report)) + { + return -1; + } + //Decrypt the Quote signature and verify. + + p_attestation_verification_report->id = 0x12345678; + p_attestation_verification_report->status = IAS_QUOTE_OK; + p_attestation_verification_report->revocation_reason = + IAS_REVOC_REASON_NONE; + p_attestation_verification_report->info_blob.sample_epid_group_status = + 0 << IAS_EPID_GROUP_STATUS_REVOKED_BIT_POS + | 0 << IAS_EPID_GROUP_STATUS_REKEY_AVAILABLE_BIT_POS; + p_attestation_verification_report->info_blob.sample_tcb_evaluation_status = + 0 << IAS_TCB_EVAL_STATUS_CPUSVN_OUT_OF_DATE_BIT_POS + | 0 << IAS_TCB_EVAL_STATUS_ISVSVN_OUT_OF_DATE_BIT_POS; + p_attestation_verification_report->info_blob.pse_evaluation_status = + 0 << IAS_PSE_EVAL_STATUS_ISVSVN_OUT_OF_DATE_BIT_POS + | 0 << IAS_PSE_EVAL_STATUS_EPID_GROUP_REVOKED_BIT_POS + | 0 << IAS_PSE_EVAL_STATUS_PSDASVN_OUT_OF_DATE_BIT_POS + | 0 << IAS_PSE_EVAL_STATUS_SIGRL_OUT_OF_DATE_BIT_POS + | 0 << IAS_PSE_EVAL_STATUS_PRIVRL_OUT_OF_DATE_BIT_POS; + memset(p_attestation_verification_report-> + info_blob.latest_equivalent_tcb_psvn, 0, PSVN_SIZE); + memset(p_attestation_verification_report->info_blob.latest_pse_isvsvn, + 0, ISVSVN_SIZE); + memset(p_attestation_verification_report->info_blob.latest_psda_svn, + 0, PSDA_SVN_SIZE); + memset(p_attestation_verification_report->info_blob.performance_rekey_gid, + 0, GID_SIZE); + + // @TODO: Product signing algorithm still TBD. May be RSA2048 signing. + // Generate the Service providers ECCDH key pair. + do { + ret = sample_ecc256_open_context(&ecc_state); + if (SAMPLE_SUCCESS != ret) { + fprintf(stderr, "\nError, cannot get ECC cotext in [%s].", + __FUNCTION__); + ret = -1; + break; + } + // Sign + ret = sample_ecdsa_sign( + (uint8_t *)&p_attestation_verification_report-> + info_blob.sample_epid_group_status, + sizeof(ias_platform_info_blob_t) - sizeof(sample_ec_sign256_t), + (sample_ec256_private_t *)&g_rk_priv_key, + (sample_ec256_signature_t *)&p_attestation_verification_report-> + info_blob.signature, + ecc_state); + if (SAMPLE_SUCCESS != ret) { + fprintf(stderr, "\nError, sign ga_gb fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + SWAP_ENDIAN_32B(p_attestation_verification_report-> + info_blob.signature.x); + SWAP_ENDIAN_32B(p_attestation_verification_report-> + info_blob.signature.y); + + }while (0); + if (ecc_state) { + sample_ecc256_close_context(ecc_state); + } + p_attestation_verification_report->pse_status = IAS_PSE_OK; + + // For now, don't simulate the policy reports. + p_attestation_verification_report->policy_report_size = 0; + return(ret); +} + + +// Simulates retrieving the SIGRL for upon the SP request. Becaue the IAS +// backend is not ready right now, we will return NULL. +// +// @param gid Group ID for the EPID key. +// @param p_sig_rl_size Pointer to the output value of the full +// SIGRL size in bytes. (including the +// signature). +// @param p_sig_rl Pointer to the output of the SIGRL. +// +// @return int + +int ias_get_sigrl( + const sample_epid_group_id_t gid, + uint32_t *p_sig_rl_size, + uint8_t **p_sig_rl) +{ + int ret = 0; + + UNUSED(gid); + + do { + + if (NULL == p_sig_rl || NULL == p_sig_rl_size) { + ret = -1; + break; + } + *p_sig_rl_size = 0; + *p_sig_rl = NULL; + // we should try to get sig_rl from IAS, but right now we will just + // skip it until the IAS backend is ready. + break; + }while (0); + + return(ret); +} + + +// Used to simulate the enrollment function of the IAS. It only +// gives back the SPID right now. In production, the enrollment +// occurs out of context from an attestation attempt and only +// occurs once. +// +// +// @param sp_credentials +// @param p_spid +// @param p_authentication_token +// +// @return int + +int ias_enroll( + int sp_credentials, + sample_spid_t *p_spid, + int *p_authentication_token) +{ + UNUSED(sp_credentials); + UNUSED(p_authentication_token); + + if (NULL != p_spid) { + memcpy_s(p_spid, sizeof(sample_spid_t), &g_sim_spid, + sizeof(sample_spid_t)); + } else { + return(1); + } + return(0); +} + + diff --git a/SampleCode/RemoteAttestation/service_provider/ias_ra.h b/SampleCode/RemoteAttestation/service_provider/ias_ra.h new file mode 100644 index 0000000000..6230eb4e53 --- /dev/null +++ b/SampleCode/RemoteAttestation/service_provider/ias_ra.h @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _IAS_RA_H +#define _IAS_RA_H + +#include "ecp.h" + +// These status should align with the definition in IAS API spec(rev 0.6) +typedef enum { + IAS_QUOTE_OK, + IAS_QUOTE_SIGNATURE_INVALID, + IAS_QUOTE_GROUP_REVOKED, + IAS_QUOTE_SIGNATURE_REVOKED, + IAS_QUOTE_KEY_REVOKED, + IAS_QUOTE_SIGRL_VERSION_MISMATCH, + IAS_QUOTE_GROUP_OUT_OF_DATE, +} ias_quote_status_t; + +// These status should align with the definition in IAS API spec(rev 0.6) +typedef enum { + IAS_PSE_OK, + IAS_PSE_DESC_TYPE_NOT_SUPPORTED, + IAS_PSE_ISVSVN_OUT_OF_DATE, + IAS_PSE_MISCSELECT_INVALID, + IAS_PSE_ATTRIBUTES_INVALID, + IAS_PSE_MRSIGNER_INVALID, + IAS_PS_HW_GID_REVOKED, + IAS_PS_HW_PRIVKEY_RLVER_MISMATCH, + IAS_PS_HW_SIG_RLVER_MISMATCH, + IAS_PS_HW_CA_ID_INVALID, + IAS_PS_HW_SEC_INFO_INVALID, + IAS_PS_HW_PSDA_SVN_OUT_OF_DATE, +} ias_pse_status_t; + +// Revocation Reasons from RFC5280 +typedef enum { + IAS_REVOC_REASON_NONE, + IAS_REVOC_REASON_KEY_COMPROMISE, + IAS_REVOC_REASON_CA_COMPROMISED, + IAS_REVOC_REASON_SUPERCEDED, + IAS_REVOC_REASON_CESSATION_OF_OPERATION, + IAS_REVOC_REASON_CERTIFICATE_HOLD, + IAS_REVOC_REASON_PRIVILEGE_WITHDRAWN, + IAS_REVOC_REASON_AA_COMPROMISE, +} ias_revoc_reason_t; + +// These status should align with the definition in IAS API spec(rev 0.6) +#define IAS_EPID_GROUP_STATUS_REVOKED_BIT_POS 0x00 +#define IAS_EPID_GROUP_STATUS_REKEY_AVAILABLE_BIT_POS 0x01 + +#define IAS_TCB_EVAL_STATUS_CPUSVN_OUT_OF_DATE_BIT_POS 0x00 +#define IAS_TCB_EVAL_STATUS_ISVSVN_OUT_OF_DATE_BIT_POS 0x01 + +#define IAS_PSE_EVAL_STATUS_ISVSVN_OUT_OF_DATE_BIT_POS 0x00 +#define IAS_PSE_EVAL_STATUS_EPID_GROUP_REVOKED_BIT_POS 0x01 +#define IAS_PSE_EVAL_STATUS_PSDASVN_OUT_OF_DATE_BIT_POS 0x02 +#define IAS_PSE_EVAL_STATUS_SIGRL_OUT_OF_DATE_BIT_POS 0x03 +#define IAS_PSE_EVAL_STATUS_PRIVRL_OUT_OF_DATE_BIT_POS 0x04 + +// These status should align with the definition in IAS API spec(rev 0.6) +#define ISVSVN_SIZE 2 +#define PSDA_SVN_SIZE 4 +#define GID_SIZE 4 +#define PSVN_SIZE 18 + +#define SAMPLE_HASH_SIZE 32 // SHA256 +#define SAMPLE_MAC_SIZE 16 // Message Authentication Code + // - 16 bytes + +#define SAMPLE_REPORT_DATA_SIZE 64 + +typedef uint8_t sample_measurement_t[SAMPLE_HASH_SIZE]; +typedef uint8_t sample_mac_t[SAMPLE_MAC_SIZE]; +typedef uint8_t sample_report_data_t[SAMPLE_REPORT_DATA_SIZE]; +typedef uint16_t sample_prod_id_t; + +#define SAMPLE_CPUSVN_SIZE 16 + +typedef uint8_t sample_cpu_svn_t[SAMPLE_CPUSVN_SIZE]; +typedef uint16_t sample_isv_svn_t; + +typedef struct sample_attributes_t +{ + uint64_t flags; + uint64_t xfrm; +} sample_attributes_t; + +typedef struct sample_report_body_t { + sample_cpu_svn_t cpu_svn; // ( 0) Security Version of the CPU + uint8_t reserved1[32]; // ( 16) + sample_attributes_t attributes; // ( 48) Any special Capabilities + // the Enclave possess + sample_measurement_t mr_enclave; // ( 64) The value of the enclave's + // ENCLAVE measurement + uint8_t reserved2[32]; // ( 96) + sample_measurement_t mr_signer; // (128) The value of the enclave's + // SIGNER measurement + uint8_t reserved3[32]; // (160) + sample_measurement_t mr_reserved1; // (192) + sample_measurement_t mr_reserved2; // (224) + sample_prod_id_t isv_prod_id; // (256) Product ID of the Enclave + sample_isv_svn_t isv_svn; // (258) Security Version of the + // Enclave + uint8_t reserved4[60]; // (260) + sample_report_data_t report_data; // (320) Data provided by the user +} sample_report_body_t; + +#pragma pack(push, 1) + + +// This is a context data structure used in SP side +// @TODO: Modify at production to use the values specified by the Production +// IAS API +typedef struct _ias_att_report_t +{ + uint32_t id; + ias_quote_status_t status; + uint32_t revocation_reason; + ias_platform_info_blob_t info_blob; + ias_pse_status_t pse_status; + uint32_t policy_report_size; + + uint8_t policy_report[];// IAS_Q: Why does it specify a + // list of reports? + + +} ias_att_report_t; + +typedef uint8_t sample_epid_group_id_t[4]; + +typedef struct sample_spid_t +{ + uint8_t id[16]; +} sample_spid_t; + +typedef struct sample_basename_t +{ + uint8_t name[32]; +} sample_basename_t; + + +typedef struct sample_quote_nonce_t +{ + uint8_t rand[16]; +} sample_quote_nonce_t; + +#define SAMPLE_QUOTE_UNLINKABLE_SIGNATURE 0 +#define SAMPLE_QUOTE_LINKABLE_SIGNATURE 1 + +typedef struct sample_quote_t { + uint16_t version; // 0 + uint16_t sign_type; // 2 + sample_epid_group_id_t epid_group_id; // 4 + sample_isv_svn_t qe_svn; // 8 + uint8_t reserved[6]; // 10 + sample_basename_t basename; // 16 + sample_report_body_t report_body; // 48 + uint32_t signature_len; // 432 + uint8_t signature[]; // 436 +} sample_quote_t; + +#pragma pack(pop) + +#ifdef __cplusplus +extern "C" { +#endif + +int ias_enroll(int sp_credentials, sample_spid_t* spid, + int* authentication_token); +int ias_get_sigrl(const sample_epid_group_id_t gid, uint32_t* p_sig_rl_size, + uint8_t** p_sig_rl); +int ias_verify_attestation_evidence(sample_quote_t* p_isv_quote, + uint8_t* pse_manifest, + ias_att_report_t* attestation_verification_report); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SampleCode/RemoteAttestation/service_provider/network_ra.cpp b/SampleCode/RemoteAttestation/service_provider/network_ra.cpp new file mode 100644 index 0000000000..3db2be3973 --- /dev/null +++ b/SampleCode/RemoteAttestation/service_provider/network_ra.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include +#include +#include +#include "network_ra.h" +#include "service_provider.h" + + +// Used to send requests to the service provider sample. It +// simulates network communication between the ISV app and the +// ISV service provider. This would be modified in a real +// product to use the proper IP communication. +// +// @param server_url String name of the server URL +// @param p_req Pointer to the message to be sent. +// @param p_resp Pointer to a pointer of the response message. + +// @return int + +int ra_network_send_receive(const char *server_url, + const ra_samp_request_header_t *p_req, + ra_samp_response_header_t **p_resp) +{ + int ret = 0; + ra_samp_response_header_t* p_resp_msg; + + if((NULL == server_url) || + (NULL == p_req) || + (NULL == p_resp)) + { + return -1; + } + + switch(p_req->type) + { + + case TYPE_RA_MSG1: + ret = sp_ra_proc_msg1_req((const sample_ra_msg1_t*)((uint8_t*)p_req + + sizeof(ra_samp_request_header_t)), + p_req->size, + &p_resp_msg); + if(0 != ret) + { + fprintf(stderr, "\nError, call sp_ra_proc_msg1_req fail [%s].", + __FUNCTION__); + } + else + { + *p_resp = p_resp_msg; + } + break; + + case TYPE_RA_MSG3: + ret =sp_ra_proc_msg3_req((const sample_ra_msg3_t*)((uint8_t*)p_req + + sizeof(ra_samp_request_header_t)), + p_req->size, + &p_resp_msg); + if(0 != ret) + { + fprintf(stderr, "\nError, call sp_ra_proc_msg3_req fail [%s].", + __FUNCTION__); + } + else + { + *p_resp = p_resp_msg; + } + break; + + default: + ret = -1; + fprintf(stderr, "\nError, unknown ra message type. Type = %d [%s].", + p_req->type, __FUNCTION__); + break; + } + + return ret; +} + +// Used to free the response messages. In the sample code, the +// response messages are allocated by the SP code. +// +// +// @param resp Pointer to the response buffer to be freed. + +void ra_free_network_response_buffer(ra_samp_response_header_t *resp) +{ + if(resp!=NULL) + { + free(resp); + } +} diff --git a/SampleCode/RemoteAttestation/service_provider/network_ra.h b/SampleCode/RemoteAttestation/service_provider/network_ra.h new file mode 100644 index 0000000000..bd7fdb7108 --- /dev/null +++ b/SampleCode/RemoteAttestation/service_provider/network_ra.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _NETWORK_RA_H +#define _NETWORK_RA_H + + +// Enum for all possible message types between the ISV app and +// the ISV SP. Requests and responses in hte remote attestation +// sample. +typedef enum _ra_msg_type_t +{ + TYPE_RA_MSG1 = 1, + TYPE_RA_MSG2, + TYPE_RA_MSG3, + TYPE_RA_ATT_RESULT, +}ra_msg_type_t; + +// Enum for all possible message types between the SP and IAS. +// Network communication is not simulated in the remote +// attestation sample. Currently these aren't used. +typedef enum _ias_msg_type_t +{ + TYPE_IAS_ENROLL, + TYPE_IAS_GET_SIGRL, + TYPE_IAS_SIGRL, + TYPE_IAS_ATT_EVIDENCE, + TYPE_IAS_ATT_RESULT, +}ias_msg_type_t; + +#pragma pack(1) +typedef struct _ra_samp_request_header_t{ + uint8_t type; // set to one of ra_msg_type_t + uint32_t size; //size of request body, + uint8_t align[3]; + uint8_t body[]; +}ra_samp_request_header_t; + +typedef struct _ra_samp_response_header_t{ + uint8_t type; // set to one of ra_msg_type_t + uint8_t status[2]; + uint32_t size; //size of the response body + uint8_t align[1]; + uint8_t body[]; +}ra_samp_response_header_t; + +#pragma pack() + +#ifdef __cplusplus +extern "C" { +#endif + +int ra_network_send_receive(const char *server_url, + const ra_samp_request_header_t *req, + ra_samp_response_header_t **p_resp); +void ra_free_network_response_buffer(ra_samp_response_header_t *resp); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SampleCode/RemoteAttestation/service_provider/remote_attestation_result.h b/SampleCode/RemoteAttestation/service_provider/remote_attestation_result.h new file mode 100644 index 0000000000..5e6121cd11 --- /dev/null +++ b/SampleCode/RemoteAttestation/service_provider/remote_attestation_result.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _REMOTE_ATTESTATION_RESULT_H_ +#define _REMOTE_ATTESTATION_RESULT_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SAMPLE_MAC_SIZE 16 // Message Authentication Code + // - 16 bytes +typedef uint8_t sample_mac_t[SAMPLE_MAC_SIZE]; + +#ifndef SAMPLE_FEBITSIZE + #define SAMPLE_FEBITSIZE 256 +#endif + +#define SAMPLE_NISTP256_KEY_SIZE (SAMPLE_FEBITSIZE/ 8 /sizeof(uint32_t)) + +typedef struct sample_ec_sign256_t +{ + uint32_t x[SAMPLE_NISTP256_KEY_SIZE]; + uint32_t y[SAMPLE_NISTP256_KEY_SIZE]; +} sample_ec_sign256_t; + +#pragma pack(push,1) + +#define SAMPLE_SP_TAG_SIZE 16 + +typedef struct sp_aes_gcm_data_t { + uint32_t payload_size; // 0: Size of the payload which is + // encrypted + uint8_t reserved[12]; // 4: Reserved bits + uint8_t payload_tag[SAMPLE_SP_TAG_SIZE]; + // 16: AES-GMAC of the plain text, + // payload, and the sizes + uint8_t payload[]; // 32: Ciphertext of the payload + // followed by the plain text +} sp_aes_gcm_data_t; + + +#define ISVSVN_SIZE 2 +#define PSDA_SVN_SIZE 4 +#define GID_SIZE 4 +#define PSVN_SIZE 18 + +// @TODO: Modify at production to use the values specified by the Production +// IAS API +typedef struct ias_platform_info_blob_t +{ + uint8_t sample_epid_group_status; + uint16_t sample_tcb_evaluation_status; + uint16_t pse_evaluation_status; + uint8_t latest_equivalent_tcb_psvn[PSVN_SIZE]; + uint8_t latest_pse_isvsvn[ISVSVN_SIZE]; + uint8_t latest_psda_svn[PSDA_SVN_SIZE]; + uint8_t performance_rekey_gid[GID_SIZE]; + sample_ec_sign256_t signature; +} ias_platform_info_blob_t; + + +typedef struct sample_ra_att_result_msg_t { + ias_platform_info_blob_t platform_info_blob; + sample_mac_t mac; // mac_smk(attestation_status) + sp_aes_gcm_data_t secret; +} sample_ra_att_result_msg_t; + +#pragma pack(pop) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SampleCode/RemoteAttestation/service_provider/service_provider.cpp b/SampleCode/RemoteAttestation/service_provider/service_provider.cpp new file mode 100644 index 0000000000..3736951d03 --- /dev/null +++ b/SampleCode/RemoteAttestation/service_provider/service_provider.cpp @@ -0,0 +1,660 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "service_provider.h" + +#include "sample_libcrypto.h" + +#include "ecp.h" + +#include +#include +#include +#include +#include +#include "ias_ra.h" + +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr) = NULL;}} +#endif + +// This is the private EC key of SP, the corresponding public EC key is +// hard coded in isv_enclave. It is based on NIST P-256 curve. +static const sample_ec256_private_t g_sp_priv_key = { + { + 0x90, 0xe7, 0x6c, 0xbb, 0x2d, 0x52, 0xa1, 0xce, + 0x3b, 0x66, 0xde, 0x11, 0x43, 0x9c, 0x87, 0xec, + 0x1f, 0x86, 0x6a, 0x3b, 0x65, 0xb6, 0xae, 0xea, + 0xad, 0x57, 0x34, 0x53, 0xd1, 0x03, 0x8c, 0x01 + } +}; + +// This is the public EC key of SP, this key is hard coded in isv_enclave. +// It is based on NIST P-256 curve. Not used in the SP code. +static const sample_ec_pub_t g_sp_pub_key = { + { + 0x72, 0x12, 0x8a, 0x7a, 0x17, 0x52, 0x6e, 0xbf, + 0x85, 0xd0, 0x3a, 0x62, 0x37, 0x30, 0xae, 0xad, + 0x3e, 0x3d, 0xaa, 0xee, 0x9c, 0x60, 0x73, 0x1d, + 0xb0, 0x5b, 0xe8, 0x62, 0x1c, 0x4b, 0xeb, 0x38 + }, + { + 0xd4, 0x81, 0x40, 0xd9, 0x50, 0xe2, 0x57, 0x7b, + 0x26, 0xee, 0xb7, 0x41, 0xe7, 0xc6, 0x14, 0xe2, + 0x24, 0xb7, 0xbd, 0xc9, 0x03, 0xf2, 0x9a, 0x28, + 0xa8, 0x3c, 0xc8, 0x10, 0x11, 0x14, 0x5e, 0x06 + } +}; + +// This is a context data structure used on SP side +typedef struct _sp_db_item_t +{ + sample_ec_pub_t g_a; + sample_ec_pub_t g_b; + sample_ec_key_128bit_t vk_key;// Shared secret key for the REPORT_DATA + sample_ec_key_128bit_t mk_key;// Shared secret key for generating MAC's + sample_ec_key_128bit_t sk_key;// Shared secret key for encryption + sample_ec_key_128bit_t smk_key;// Used only for SIGMA protocol + sample_ec_priv_t b; + sample_ps_sec_prop_desc_t ps_sec_prop; +}sp_db_item_t; +static sp_db_item_t g_sp_db; + +static bool g_is_sp_registered = false; +static int g_sp_credentials = 0; +static int g_authentication_token = 0; + +uint8_t g_secret[8] = {0,1,2,3,4,5,6,7}; + +sample_spid_t g_spid; + +// Verify message 1 then generate and return message 2 to isv. +int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1, + uint32_t msg1_size, + ra_samp_response_header_t **pp_msg2) +{ + int ret = 0; + ra_samp_response_header_t* p_msg2_full = NULL; + sample_ra_msg2_t *p_msg2 = NULL; + sample_ecc_state_handle_t ecc_state = NULL; + sample_status_t sample_ret = SAMPLE_SUCCESS; + bool derive_ret = false; + + if(!p_msg1 || + !pp_msg2 || + (msg1_size != sizeof(sample_ra_msg1_t))) + { + return -1; + } + + do + { + // Check to see if we have registered with the IAS yet? + if(!g_is_sp_registered) + { + do + { + // @IAS_Q: What are the sp credentials? + // @IAS_Q: What is in the authentication token + // In the product, the SP will establish a mutually + // authenticated SSL channel. The authentication token is + // based on this channel. + // @TODO: Convert this call to a 'network' send/receive + // once the IAS server is a vaialable. + ret = ias_enroll(g_sp_credentials, &g_spid, + &g_authentication_token); + if(0 != ret) + { + ret = SP_IAS_FAILED; + break; + } + + // IAS may support registering the Enclave Trust Policy. + // Just leave a place holder here + // @IAS_Q: What needs to be sent to the IAS with the policy + // that identifies the SP? + // ret = ias_register_enclave_policy(g_enclave_policy, + // g_authentication_token); + // if(0 != ret) + // { + // break; + // } + + g_is_sp_registered = true; + break; + } while(0); + } + + // Get the sig_rl from IAS using GID. + // GID is Base-16 encoded of EPID GID in little-endian format. + // @IAS_Q: Does the SP need to supply any authentication info to the + // IAS? SPID? + // In the product, the SP and IAS will use an established channel for + // communication. + uint8_t* sig_rl; + uint32_t sig_rl_size = 0; + + // @TODO: Convert this call to a 'network' send/receive + // once the IAS server is a vaialable. + ret = ias_get_sigrl(p_msg1->gid, &sig_rl_size, &sig_rl); + if(0 != ret) + { + fprintf(stderr, "\nError, ias_get_sigrl [%s].", __FUNCTION__); + ret = SP_IAS_FAILED; + break; + } + + // Need to save the client's public ECCDH key to local storage + if (memcpy_s(&g_sp_db.g_a, sizeof(g_sp_db.g_a), &p_msg1->g_a, + sizeof(p_msg1->g_a))) + { + fprintf(stderr, "\nError, cannot do memcpy in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // Generate the Service providers ECCDH key pair. + sample_ret = sample_ecc256_open_context(&ecc_state); + if(SAMPLE_SUCCESS != sample_ret) + { + fprintf(stderr, "\nError, cannot get ECC cotext in [%s].", + __FUNCTION__); + ret = -1; + break; + } + sample_ec256_public_t pub_key = {{0},{0}}; + sample_ec256_private_t priv_key = {{0}}; + sample_ret = sample_ecc256_create_key_pair(&priv_key, &pub_key, + ecc_state); + if(SAMPLE_SUCCESS != sample_ret) + { + fprintf(stderr, "\nError, cannot generate key pair in [%s].", + __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // Need to save the SP ECCDH key pair to local storage. + if(memcpy_s(&g_sp_db.b, sizeof(g_sp_db.b), &priv_key,sizeof(priv_key)) + || memcpy_s(&g_sp_db.g_b, sizeof(g_sp_db.g_b), + &pub_key,sizeof(pub_key))) + { + fprintf(stderr, "\nError, cannot do memcpy in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // Generate the client/SP shared secret + sample_ec_dh_shared_t dh_key = {{0}}; + sample_ret = sample_ecc256_compute_shared_dhkey(&priv_key, + (sample_ec256_public_t *)&p_msg1->g_a, + (sample_ec256_dh_shared_t *)&dh_key, + ecc_state); + if(SAMPLE_SUCCESS != sample_ret) + { + fprintf(stderr, "\nError, compute share key fail in [%s].", + __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // smk is only needed for msg2 generation. + derive_ret = derive_key(&dh_key, SAMPLE_DERIVE_KEY_SMK, + &g_sp_db.smk_key); + if(derive_ret != true) + { + fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // The rest of the keys are the shared secrets for future communication. + derive_ret = derive_key(&dh_key, SAMPLE_DERIVE_KEY_MK, + &g_sp_db.mk_key); + if(derive_ret != true) + { + fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + derive_ret = derive_key(&dh_key, SAMPLE_DERIVE_KEY_SK, + &g_sp_db.sk_key); + if(derive_ret != true) + { + fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + derive_ret = derive_key(&dh_key, SAMPLE_DERIVE_KEY_VK, + &g_sp_db.vk_key); + if(derive_ret != true) + { + fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + uint32_t msg2_size = sizeof(sample_ra_msg2_t) + sig_rl_size; + p_msg2_full = (ra_samp_response_header_t*)malloc(msg2_size + + sizeof(ra_samp_response_header_t)); + if(!p_msg2_full) + { + fprintf(stderr, "\nError, out of memory in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + memset(p_msg2_full, 0, msg2_size + sizeof(ra_samp_response_header_t)); + p_msg2_full->type = TYPE_RA_MSG2; + p_msg2_full->size = msg2_size; + // @TODO: Set the status properly based on real protocol communication. + p_msg2_full->status[0] = 0; + p_msg2_full->status[1] = 0; + p_msg2 = (sample_ra_msg2_t *)p_msg2_full->body; + + // Assemble MSG2 + if(memcpy_s(&p_msg2->g_b, sizeof(p_msg2->g_b), &g_sp_db.g_b, + sizeof(g_sp_db.g_b)) || + memcpy_s(&p_msg2->spid, sizeof(sample_spid_t), + &g_spid, sizeof(g_spid))) + { + fprintf(stderr,"\nError, memcpy failed in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // The service provider is responsible for selecting the proper EPID + // signature type and to understand the implications of the choice! + p_msg2->quote_type = SAMPLE_QUOTE_LINKABLE_SIGNATURE; + + + p_msg2->kdf_id = SAMPLE_AES_CMAC_KDF_ID; + + // Create gb_ga + sample_ec_pub_t gb_ga[2]; + if(memcpy_s(&gb_ga[0], sizeof(gb_ga[0]), &g_sp_db.g_b, + sizeof(g_sp_db.g_b)) + || memcpy_s(&gb_ga[1], sizeof(gb_ga[1]), &g_sp_db.g_a, + sizeof(g_sp_db.g_a))) + { + fprintf(stderr,"\nError, memcpy failed in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // Sign gb_ga + sample_ret = sample_ecdsa_sign((uint8_t *)&gb_ga, sizeof(gb_ga), + (sample_ec256_private_t *)&g_sp_priv_key, + (sample_ec256_signature_t *)&p_msg2->sign_gb_ga, + ecc_state); + if(SAMPLE_SUCCESS != sample_ret) + { + fprintf(stderr, "\nError, sign ga_gb fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // Generate the CMACsmk for gb||SPID||TYPE||KDF_ID||Sigsp(gb,ga) + uint8_t mac[SAMPLE_EC_MAC_SIZE] = {0}; + uint32_t cmac_size = offsetof(sample_ra_msg2_t, mac); + sample_ret = sample_rijndael128_cmac_msg(&g_sp_db.smk_key, + (uint8_t *)&p_msg2->g_b, cmac_size, &mac); + if(SAMPLE_SUCCESS != sample_ret) + { + fprintf(stderr, "\nError, cmac fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + if(memcpy_s(&p_msg2->mac, sizeof(p_msg2->mac), mac, sizeof(mac))) + { + fprintf(stderr,"\nError, memcpy failed in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + if(memcpy_s(&p_msg2->sig_rl[0], sig_rl_size, sig_rl, sig_rl_size)) + { + fprintf(stderr,"\nError, memcpy failed in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + p_msg2->sig_rl_size = sig_rl_size; + + }while(0); + + if(ret) + { + *pp_msg2 = NULL; + SAFE_FREE(p_msg2_full); + } + else + { + // Freed by the network simulator in ra_free_network_response_buffer + *pp_msg2 = p_msg2_full; + } + + if(ecc_state) + { + sample_ecc256_close_context(ecc_state); + } + + return ret; +} + +// Process remote attestation message 3 +int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3, + uint32_t msg3_size, + ra_samp_response_header_t **pp_att_result_msg) +{ + int ret = 0; + sample_status_t sample_ret = SAMPLE_SUCCESS; + const uint8_t *p_msg3_cmaced = NULL; + sample_quote_t *p_quote = NULL; + sample_sha_state_handle_t sha_handle = NULL; + sample_report_data_t report_data = {0}; + sample_ra_att_result_msg_t *p_att_result_msg = NULL; + ra_samp_response_header_t* p_att_result_msg_full = NULL; + uint32_t i; + + if((!p_msg3) || + (msg3_size < sizeof(sample_ra_msg3_t)) || + (!pp_att_result_msg)) + { + return SP_INTERNAL_ERROR; + } + + do + { + // Compare g_a in message 3 with local g_a. + ret = memcmp(&g_sp_db.g_a, &p_msg3->g_a, sizeof(sample_ec_pub_t)); + if(ret) + { + fprintf(stderr, "\nError, g_a is not same [%s].", __FUNCTION__); + ret = SP_PROTOCOL_ERROR; + break; + } + //Make sure that msg3_size is bigger than sample_mac_t. + uint32_t mac_size = msg3_size - sizeof(sample_mac_t); + p_msg3_cmaced = reinterpret_cast(p_msg3); + p_msg3_cmaced += sizeof(sample_mac_t); + + // Verify the message mac using SMK + sample_cmac_128bit_tag_t mac = {0}; + sample_ret = sample_rijndael128_cmac_msg(&g_sp_db.smk_key, + p_msg3_cmaced, + mac_size, + &mac); + if(SAMPLE_SUCCESS != sample_ret) + { + fprintf(stderr, "\nError, cmac fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + // In real implementation, should use a time safe version of memcmp here, + // in order to avoid side channel attack. + ret = memcmp(&p_msg3->mac, mac, sizeof(mac)); + if(ret) + { + fprintf(stderr, "\nError, verify cmac fail [%s].", __FUNCTION__); + ret = SP_INTEGRITY_FAILED; + break; + } + + if(memcpy_s(&g_sp_db.ps_sec_prop, sizeof(g_sp_db.ps_sec_prop), + &p_msg3->ps_sec_prop, sizeof(p_msg3->ps_sec_prop))) + { + fprintf(stderr,"\nError, memcpy failed in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + p_quote = (sample_quote_t *)p_msg3->quote; + + // Verify the the report_data in the Quote matches the expected value. + // The first 32 bytes of report_data are SHA256 HASH of {ga|gb|vk}. + // The second 32 bytes of report_data are set to zero. + sample_ret = sample_sha256_init(&sha_handle); + if(sample_ret != SAMPLE_SUCCESS) + { + fprintf(stderr,"\nError, init hash failed in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + sample_ret = sample_sha256_update((uint8_t *)&(g_sp_db.g_a), + sizeof(g_sp_db.g_a), sha_handle); + if(sample_ret != SAMPLE_SUCCESS) + { + fprintf(stderr,"\nError, udpate hash failed in [%s].", + __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + sample_ret = sample_sha256_update((uint8_t *)&(g_sp_db.g_b), + sizeof(g_sp_db.g_b), sha_handle); + if(sample_ret != SAMPLE_SUCCESS) + { + fprintf(stderr,"\nError, udpate hash failed in [%s].", + __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + sample_ret = sample_sha256_update((uint8_t *)&(g_sp_db.vk_key), + sizeof(g_sp_db.vk_key), sha_handle); + if(sample_ret != SAMPLE_SUCCESS) + { + fprintf(stderr,"\nError, udpate hash failed in [%s].", + __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + sample_ret = sample_sha256_get_hash(sha_handle, + (sample_sha256_hash_t *)&report_data); + if(sample_ret != SAMPLE_SUCCESS) + { + fprintf(stderr,"\nError, Get hash failed in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + ret = memcmp((uint8_t *)&report_data, + (uint8_t *)&(p_quote->report_body.report_data), + sizeof(report_data)); + if(ret) + { + fprintf(stderr, "\nError, verify hash fail [%s].", __FUNCTION__); + ret = SP_INTEGRITY_FAILED; + break; + } + + // Verify Enclave policy (IAS may provide an API for this if we + // registered an Enclave policy) + + // Verify quote with IAS. + // @IAS_Q: What is the proper JSON format for attestation evidence? + ias_att_report_t attestation_report; + // @TODO: Convert this call to a 'network' send/receive + // once the IAS server is a vaialable. + ret = ias_verify_attestation_evidence(p_quote, NULL, + &attestation_report); + if(0 != ret) + { + ret = SP_IAS_FAILED; + break; + } + FILE* OUTPUT = stdout; + fprintf(OUTPUT, "\n\n\tAtestation Report:"); + fprintf(OUTPUT, "\n\tid: 0x%0x.", attestation_report.id); + fprintf(OUTPUT, "\n\tstatus: %d.", attestation_report.status); + fprintf(OUTPUT, "\n\trevocation_reason: %u.", + attestation_report.revocation_reason); + // attestation_report.info_blob; + fprintf(OUTPUT, "\n\tpse_status: %d.", attestation_report.pse_status); + // Check if Platform_Info_Blob is available. + // @TODO: Currenlty, the IAS spec says this will not be available if + // no info blob status flags are set. For now, assume it is always + // there until we have the full message format definition. + + // Respond the client with the results of the attestation. + uint32_t att_result_msg_size = sizeof(sample_ra_att_result_msg_t) + + attestation_report.policy_report_size; + p_att_result_msg_full = + (ra_samp_response_header_t*)malloc(att_result_msg_size + + sizeof(ra_samp_response_header_t) + sizeof(g_secret)); + if(!p_att_result_msg_full) + { + fprintf(stderr, "\nError, out of memory in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + memset(p_att_result_msg_full, 0, att_result_msg_size + + sizeof(ra_samp_response_header_t) + sizeof(g_secret)); + p_att_result_msg_full->type = TYPE_RA_ATT_RESULT; + p_att_result_msg_full->size = att_result_msg_size; + if(IAS_QUOTE_OK != attestation_report.status) + { + p_att_result_msg_full->status[0] = 0xFF; + } + if(IAS_PSE_OK != attestation_report.pse_status) + { + p_att_result_msg_full->status[1] = 0xFF; + } + + p_att_result_msg = + (sample_ra_att_result_msg_t *)p_att_result_msg_full->body; + + // @TODO: In the product, the HTTP response header itself will have + // an RK based signature that the service provider needs to check here. + + // The platform_info_blob signature will be verified by the client + // if needed. No need to have the Service Provider to check it. + + // @TODO: Verify the enlcave policy report if they are to be supported + // by IAS. Otherwise, the SP will need to check the ISV enclave report + // itself. + fprintf(OUTPUT, "\n\n\tEnclave Report:"); + fprintf(OUTPUT, "\n\tSignature Type: 0x%x", p_quote->sign_type); + fprintf(OUTPUT, "\n\tSignature Basename: "); + for(i=0; ibasename.name) && p_quote->basename.name[i]; + i++) + { + fprintf(OUTPUT, "%c", p_quote->basename.name[i]); + } +#ifdef __x86_64__ + fprintf(OUTPUT, "\n\tattributes.flags: 0x%0lx", + p_quote->report_body.attributes.flags); + fprintf(OUTPUT, "\n\tattributes.xfrm: 0x%0lx", + p_quote->report_body.attributes.xfrm); +#else + fprintf(OUTPUT, "\n\tattributes.flags: 0x%0llx", + p_quote->report_body.attributes.flags); + fprintf(OUTPUT, "\n\tattributes.xfrm: 0x%0llx", + p_quote->report_body.attributes.xfrm); +#endif + fprintf(OUTPUT, "\n\tmr_enclave: "); + for(i=0;ireport_body.mr_enclave[i]); + + //fprintf(stderr, "%02x",p_quote->report_body.mr_enclave.m[i]); + + } + fprintf(OUTPUT, "\n\tmr_signer: "); + for(i=0;ireport_body.mr_signer[i]); + + //fprintf(stderr, "%02x",p_quote->report_body.mr_signer.m[i]); + + } + fprintf(OUTPUT, "\n\tisv_prod_id: 0x%0x", + p_quote->report_body.isv_prod_id); + fprintf(OUTPUT, "\n\tisv_svn: 0x%0x",p_quote->report_body.isv_svn); + fprintf(OUTPUT, "\n"); + // @TODO do a real check here. + bool isv_policy_passed = true; + + // Assemble Attestation Result Message + // Note, this is a structure copy. We don't copy the policy reports + // right now. + p_att_result_msg->platform_info_blob = attestation_report.info_blob; + + // Generate mac based on the mk key. + mac_size = sizeof(ias_platform_info_blob_t); + sample_ret = sample_rijndael128_cmac_msg(&g_sp_db.mk_key, + (const uint8_t*)&p_att_result_msg->platform_info_blob, + mac_size, + &p_att_result_msg->mac); + if(SAMPLE_SUCCESS != sample_ret) + { + fprintf(stderr, "\nError, cmac fail in [%s].", __FUNCTION__); + ret = SP_INTERNAL_ERROR; + break; + } + + // Generate shared secret and encrypt it with SK, if attestation passed. + uint8_t aes_gcm_iv[SAMPLE_SP_IV_SIZE] = {0}; + p_att_result_msg->secret.payload_size = 8; + if((IAS_QUOTE_OK == attestation_report.status) && + (IAS_PSE_OK == attestation_report.pse_status) && + (isv_policy_passed == true)) + { + ret = sample_rijndael128GCM_encrypt(&g_sp_db.sk_key, + &g_secret[0], + p_att_result_msg->secret.payload_size, + p_att_result_msg->secret.payload, + &aes_gcm_iv[0], + SAMPLE_SP_IV_SIZE, + NULL, + 0, + &p_att_result_msg->secret.payload_tag); + } + }while(0); + + if(ret) + { + *pp_att_result_msg = NULL; + SAFE_FREE(p_att_result_msg_full); + } + else + { + // Freed by the network simulator in ra_free_network_response_buffer + *pp_att_result_msg = p_att_result_msg_full; + } + return ret; +} + + + + diff --git a/SampleCode/RemoteAttestation/service_provider/service_provider.h b/SampleCode/RemoteAttestation/service_provider/service_provider.h new file mode 100644 index 0000000000..820e39072a --- /dev/null +++ b/SampleCode/RemoteAttestation/service_provider/service_provider.h @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _SERVICE_PROVIDER_H +#define _SERVICE_PROVIDER_H + +#include "remote_attestation_result.h" +#include "ias_ra.h" +#include "network_ra.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + SP_OK, + SP_INTEGRITY_FAILED, + SP_QUOTE_VERIFICATION_FAILED, + SP_IAS_FAILED, + SP_INTERNAL_ERROR, + SP_PROTOCOL_ERROR, +} sp_ra_msg_status_t; + +#pragma pack(push,1) + +#define SAMPLE_SP_TAG_SIZE 16 +#define SAMPLE_SP_IV_SIZE 12 + +typedef struct sample_ec_pub_t +{ + uint8_t gx[SAMPLE_ECP_KEY_SIZE]; + uint8_t gy[SAMPLE_ECP_KEY_SIZE]; +} sample_ec_pub_t; + +//fixed length to align with internal structure +typedef struct sample_ps_sec_prop_desc_t +{ + uint8_t sample_ps_sec_prop_desc[256]; +} sample_ps_sec_prop_desc_t; + +#pragma pack(pop) + +typedef uint32_t sample_ra_context_t; + +typedef uint8_t sample_key_128bit_t[16]; + +typedef sample_key_128bit_t sample_ra_key_128_t; + +typedef struct sample_ra_msg1_t +{ + sample_ec_pub_t g_a; // the Endian-ness of Ga is + // Little-Endian + sample_epid_group_id_t gid; // the Endian-ness of GID is + // Little-Endian +} sample_ra_msg1_t; + +//Key Derivation Function ID : 0x0001 AES-CMAC Entropy Extraction and Key Expansion +const uint16_t SAMPLE_AES_CMAC_KDF_ID = 0x0001; + +typedef struct sample_ra_msg2_t +{ + sample_ec_pub_t g_b; // the Endian-ness of Gb is + // Little-Endian + sample_spid_t spid; + uint16_t quote_type; /* unlinkable Quote(0) or linkable Quote(0) in little endian*/ + uint16_t kdf_id; /* key derivation function id in little endian. + 0x0001 for AES-CMAC Entropy Extraction and Key Derivation */ + sample_ec_sign256_t sign_gb_ga; // In little endian + sample_mac_t mac; // mac_smk(g_b||spid||quote_type|| + // sign_gb_ga) + uint32_t sig_rl_size; + uint8_t sig_rl[]; +} sample_ra_msg2_t; + +typedef struct sample_ra_msg3_t +{ + sample_mac_t mac; // mac_smk(g_a||ps_sec_prop||quote) + sample_ec_pub_t g_a; // the Endian-ness of Ga is + // Little-Endian + sample_ps_sec_prop_desc_t ps_sec_prop; + uint8_t quote[]; +} sample_ra_msg3_t; + + +int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1, + uint32_t msg1_size, + ra_samp_response_header_t **pp_msg2); + +int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3, + uint32_t msg3_size, + ra_samp_response_header_t **pp_att_result_msg); + +int sp_ra_free_msg2( + sample_ra_msg2_t *p_msg2); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SampleCode/SampleEnclave/.cproject b/SampleCode/SampleEnclave/.cproject new file mode 100644 index 0000000000..b9fabf3067 --- /dev/null +++ b/SampleCode/SampleEnclave/.cproject @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleCode/SampleEnclave/.project b/SampleCode/SampleEnclave/.project new file mode 100644 index 0000000000..f1af7d8591 --- /dev/null +++ b/SampleCode/SampleEnclave/.project @@ -0,0 +1,28 @@ + + + SimpleEnclave + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.core.ccnature + com.intel.sgx.sgxnature + + diff --git a/SampleCode/SampleEnclave/App/App.cpp b/SampleCode/SampleEnclave/App/App.cpp new file mode 100644 index 0000000000..0538d2d8f3 --- /dev/null +++ b/SampleCode/SampleEnclave/App/App.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include + +# include +# include +# define MAX_PATH FILENAME_MAX + +#include "sgx_urts.h" +#include "App.h" +#include "Enclave_u.h" + +/* Global EID shared by multiple threads */ +sgx_enclave_id_t global_eid = 0; + +typedef struct _sgx_errlist_t { + sgx_status_t err; + const char *msg; + const char *sug; /* Suggestion */ +} sgx_errlist_t; + +/* Error code returned by sgx_create_enclave */ +static sgx_errlist_t sgx_errlist[] = { + { + SGX_ERROR_UNEXPECTED, + "Unexpected error occurred.", + NULL + }, + { + SGX_ERROR_INVALID_PARAMETER, + "Invalid parameter.", + NULL + }, + { + SGX_ERROR_OUT_OF_MEMORY, + "Out of memory.", + NULL + }, + { + SGX_ERROR_ENCLAVE_LOST, + "Power transition occurred.", + "Please refer to the sample \"PowerTransition\" for details." + }, + { + SGX_ERROR_INVALID_ENCLAVE, + "Invalid enclave image.", + NULL + }, + { + SGX_ERROR_INVALID_ENCLAVE_ID, + "Invalid enclave identification.", + NULL + }, + { + SGX_ERROR_INVALID_SIGNATURE, + "Invalid enclave signature.", + NULL + }, + { + SGX_ERROR_OUT_OF_EPC, + "Out of EPC memory.", + NULL + }, + { + SGX_ERROR_NO_DEVICE, + "Invalid SGX device.", + "Please make sure SGX module is enabled in the BIOS, and install SGX driver afterwards." + }, + { + SGX_ERROR_MEMORY_MAP_CONFLICT, + "Memory map conflicted.", + NULL + }, + { + SGX_ERROR_INVALID_METADATA, + "Invalid enclave metadata.", + NULL + }, + { + SGX_ERROR_DEVICE_BUSY, + "SGX device was busy.", + NULL + }, + { + SGX_ERROR_INVALID_VERSION, + "Enclave version was invalid.", + NULL + }, + { + SGX_ERROR_INVALID_ATTRIBUTE, + "Enclave was not authorized.", + NULL + }, + { + SGX_ERROR_ENCLAVE_FILE_ACCESS, + "Can't open enclave file.", + NULL + }, +}; + +/* Check error conditions for loading enclave */ +void print_error_message(sgx_status_t ret) +{ + size_t idx = 0; + size_t ttl = sizeof sgx_errlist/sizeof sgx_errlist[0]; + + for (idx = 0; idx < ttl; idx++) { + if(ret == sgx_errlist[idx].err) { + if(NULL != sgx_errlist[idx].sug) + printf("Info: %s\n", sgx_errlist[idx].sug); + printf("Error: %s\n", sgx_errlist[idx].msg); + break; + } + } + + if (idx == ttl) + printf("Error: Unexpected error occurred.\n"); +} + +/* Initialize the enclave: + * Step 1: try to retrieve the launch token saved by last transaction + * Step 2: call sgx_create_enclave to initialize an enclave instance + * Step 3: save the launch token if it is updated + */ +int initialize_enclave(void) +{ + char token_path[MAX_PATH] = {'\0'}; + sgx_launch_token_t token = {0}; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + int updated = 0; + + /* Step 1: try to retrieve the launch token saved by last transaction + * if there is no token, then create a new one. + */ + /* try to get the token saved in $HOME */ + const char *home_dir = getpwuid(getuid())->pw_dir; + + if (home_dir != NULL && + (strlen(home_dir)+strlen("/")+sizeof(TOKEN_FILENAME)+1) <= MAX_PATH) { + /* compose the token path */ + strncpy(token_path, home_dir, strlen(home_dir)); + strncat(token_path, "/", strlen("/")); + strncat(token_path, TOKEN_FILENAME, sizeof(TOKEN_FILENAME)+1); + } else { + /* if token path is too long or $HOME is NULL */ + strncpy(token_path, TOKEN_FILENAME, sizeof(TOKEN_FILENAME)); + } + + FILE *fp = fopen(token_path, "rb"); + if (fp == NULL && (fp = fopen(token_path, "wb")) == NULL) { + printf("Warning: Failed to create/open the launch token file \"%s\".\n", token_path); + } + + if (fp != NULL) { + /* read the token from saved file */ + size_t read_num = fread(token, 1, sizeof(sgx_launch_token_t), fp); + if (read_num != 0 && read_num != sizeof(sgx_launch_token_t)) { + /* if token is invalid, clear the buffer */ + memset(&token, 0x0, sizeof(sgx_launch_token_t)); + printf("Warning: Invalid launch token read from \"%s\".\n", token_path); + } + } + /* Step 2: call sgx_create_enclave to initialize an enclave instance */ + /* Debug Support: set 2nd parameter to 1 */ + ret = sgx_create_enclave(ENCLAVE_FILENAME, SGX_DEBUG_FLAG, &token, &updated, &global_eid, NULL); + if (ret != SGX_SUCCESS) { + print_error_message(ret); + if (fp != NULL) fclose(fp); + return -1; + } + + /* Step 3: save the launch token if it is updated */ + if (updated == FALSE || fp == NULL) { + /* if the token is not updated, or file handler is invalid, do not perform saving */ + if (fp != NULL) fclose(fp); + return 0; + } + + /* reopen the file with write capablity */ + fp = freopen(token_path, "wb", fp); + if (fp == NULL) return 0; + size_t write_num = fwrite(token, 1, sizeof(sgx_launch_token_t), fp); + if (write_num != sizeof(sgx_launch_token_t)) + printf("Warning: Failed to save launch token to \"%s\".\n", token_path); + fclose(fp); + return 0; +} + +/* OCall functions */ +void ocall_print_string(const char *str) +{ + /* Proxy/Bridge will check the length and null-terminate + * the input string to prevent buffer overflow. + */ + printf("%s", str); +} + + +/* Application entry */ +int SGX_CDECL main(int argc, char *argv[]) +{ + (void)(argc); + (void)(argv); + + + /* Initialize the enclave */ + if(initialize_enclave() < 0){ + printf("Enter a character before exit ...\n"); + getchar(); + return -1; + } + + /* Utilize edger8r attributes */ + edger8r_array_attributes(); + edger8r_pointer_attributes(); + edger8r_type_attributes(); + edger8r_function_attributes(); + + /* Utilize trusted libraries */ + ecall_libc_functions(); + ecall_libcxx_functions(); + ecall_thread_functions(); + + /* Destroy the enclave */ + sgx_destroy_enclave(global_eid); + + printf("Info: SampleEnclave successfully returned.\n"); + + printf("Enter a character before exit ...\n"); + getchar(); + return 0; +} + diff --git a/SampleCode/SampleEnclave/App/App.h b/SampleCode/SampleEnclave/App/App.h new file mode 100644 index 0000000000..bc86ff850f --- /dev/null +++ b/SampleCode/SampleEnclave/App/App.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _APP_H_ +#define _APP_H_ + +#include +#include +#include +#include + +#include "sgx_error.h" /* sgx_status_t */ +#include "sgx_eid.h" /* sgx_enclave_id_t */ + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + +# define TOKEN_FILENAME "enclave.token" +# define ENCLAVE_FILENAME "enclave.signed.so" + +extern sgx_enclave_id_t global_eid; /* global enclave id */ + +#if defined(__cplusplus) +extern "C" { +#endif + +void edger8r_array_attributes(void); +void edger8r_type_attributes(void); +void edger8r_pointer_attributes(void); +void edger8r_function_attributes(void); + +void ecall_libc_functions(void); +void ecall_libcxx_functions(void); +void ecall_thread_functions(void); + +#if defined(__cplusplus) +} +#endif + +#endif /* !_APP_H_ */ diff --git a/SampleCode/SampleEnclave/App/Edger8rSyntax/Arrays.cpp b/SampleCode/SampleEnclave/App/Edger8rSyntax/Arrays.cpp new file mode 100644 index 0000000000..01552eeffb --- /dev/null +++ b/SampleCode/SampleEnclave/App/Edger8rSyntax/Arrays.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "../App.h" +#include "Enclave_u.h" + +/* edger8r_array_attributes: + * Invokes ECALLs declared with array attributes. + */ +void edger8r_array_attributes(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + /* user_check */ + int arr1[4] = {0, 1, 2, 3}; + ret = ecall_array_user_check(global_eid, arr1); + if (ret != SGX_SUCCESS) + abort(); + + /* make sure arr1 is changed */ + for (int i = 0; i < 4; i++) + assert(arr1[i] == (3 - i)); + + /* in */ + int arr2[4] = {0, 1, 2, 3}; + ret = ecall_array_in(global_eid, arr2); + if (ret != SGX_SUCCESS) + abort(); + + /* arr2 is not changed */ + for (int i = 0; i < 4; i++) + assert(arr2[i] == i); + + /* out */ + int arr3[4] = {0, 1, 2, 3}; + ret = ecall_array_out(global_eid, arr3); + if (ret != SGX_SUCCESS) + abort(); + + /* arr3 is changed */ + for (int i = 0; i < 4; i++) + assert(arr3[i] == (3 - i)); + + /* in, out */ + int arr4[4] = {0, 1, 2, 3}; + ret = ecall_array_in_out(global_eid, arr4); + if (ret != SGX_SUCCESS) + abort(); + + /* arr4 is changed */ + for (int i = 0; i < 4; i++) + assert(arr4[i] == (3 - i)); + + /* isary */ + array_t arr5 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + ret = ecall_array_isary(global_eid, arr5); + if (ret != SGX_SUCCESS) + abort(); + + /* arr5 is changed */ + for (int i = 0; i < 10; i++) + assert(arr5[i] == (9 - i)); +} diff --git a/SampleCode/SampleEnclave/App/Edger8rSyntax/Functions.cpp b/SampleCode/SampleEnclave/App/Edger8rSyntax/Functions.cpp new file mode 100644 index 0000000000..acc2ad2737 --- /dev/null +++ b/SampleCode/SampleEnclave/App/Edger8rSyntax/Functions.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "../App.h" +#include "Enclave_u.h" + +/* No need to implement memccpy here! */ + +/* edger8r_function_attributes: + * Invokes ECALL declared with calling convention attributes. + * Invokes ECALL declared with [public]. + */ +void edger8r_function_attributes(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + ret = ecall_function_calling_convs(global_eid); + if (ret != SGX_SUCCESS) + abort(); + + ret = ecall_function_public(global_eid); + if (ret != SGX_SUCCESS) + abort(); + + /* user shall not invoke private function here */ + int runned = 0; + ret = ecall_function_private(global_eid, &runned); + if (ret != SGX_ERROR_ECALL_NOT_ALLOWED || runned != 0) + abort(); +} + +/* ocall_function_allow: + * The OCALL invokes the [allow]ed ECALL 'edger8r_private'. + */ +void ocall_function_allow(void) +{ + int runned = 0; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + ret = ecall_function_private(global_eid, &runned); + if (ret != SGX_SUCCESS || runned != 1) + abort(); +} diff --git a/SampleCode/SampleEnclave/App/Edger8rSyntax/Pointers.cpp b/SampleCode/SampleEnclave/App/Edger8rSyntax/Pointers.cpp new file mode 100644 index 0000000000..2187a40dde --- /dev/null +++ b/SampleCode/SampleEnclave/App/Edger8rSyntax/Pointers.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "../App.h" +#include "Enclave_u.h" + +/* edger8r_pointer_attributes: + * Invokes the ECALLs declared with pointer attributes. + */ +void edger8r_pointer_attributes(void) +{ + int val = 0; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + char c[128] = {0}; + size_t len = 0; + memset(c, 0xe, 128); + ret = ecall_pointer_user_check(global_eid, &len, &c, 128); + if (ret != SGX_SUCCESS) + abort(); + assert(strcmp(c, "SGX_SUCCESS") == 0); + + + val = 0; + ret = ecall_pointer_in(global_eid, &val); + if (ret != SGX_SUCCESS) + abort(); + assert(val == 0); + + val = 0; + ret = ecall_pointer_out(global_eid, &val); + if (ret != SGX_SUCCESS) + abort(); + assert(val == 1234); + + val = 0; + ret = ecall_pointer_in_out(global_eid, &val); + if (ret != SGX_SUCCESS) + abort(); + assert(val == 1234); + + ret = ocall_pointer_attr(global_eid); + if (ret != SGX_SUCCESS) + abort(); + + char str1[] = "1234567890"; + ret = ecall_pointer_string(global_eid, str1); + if (ret != SGX_SUCCESS) + abort(); + assert(memcmp(str1, "0987654321", strlen(str1)) == 0); + + const char str2[] = "1234567890"; + ret = ecall_pointer_string_const(global_eid, str2); + if (ret != SGX_SUCCESS) + abort(); + assert(memcmp(str2, "1234567890", strlen(str2)) == 0); + + char str3[] = "1234567890"; + ret = ecall_pointer_size(global_eid, (void*)str3, strlen(str3)); + if (ret != SGX_SUCCESS) + abort(); + assert(memcmp(str3, "0987654321", strlen(str3)) == 0); + + char str4[] = "1234567890"; + ret = ecall_pointer_isptr_readonly(global_eid, (buffer_t)str4, strlen(str4)); + if (ret != SGX_SUCCESS) + abort(); + assert(memcmp(str4, "1234567890", strlen(str4)) == 0); + + int arr[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + ret = ecall_pointer_count(global_eid, arr, 10); + if (ret != SGX_SUCCESS) + abort(); + + for (int i = 0; i < 10; i++) + assert(arr[i] == (9 - i)); + + memset(arr, 0x0, sizeof(arr)); + ret = ecall_pointer_sizefunc(global_eid, (char *)arr); + if (ret != SGX_SUCCESS) + abort(); + + for (int i = 0; i < 10; i++) + assert(arr[i] == i); + + return; +} + +/* ocall_pointer_user_check: + * The OCALL declared with [user_check]. + */ +void ocall_pointer_user_check(int* val) +{ + (void)val; + assert(val != NULL); +} + +/* ocall_pointer_in: + * The OCALL declared with [in]. + */ +void ocall_pointer_in(int* val) +{ + *val = 1234; +} + +/* ocall_pointer_out: + * The OCALL declared with [out]. + */ +void ocall_pointer_out(int* val) +{ + *val = 1234; +} + +/* ocall_pointer_in_out: + * The OCALL declared with [in, out]. + */ +void ocall_pointer_in_out(int* val) +{ + *val = 1234; +} diff --git a/SampleCode/SampleEnclave/App/Edger8rSyntax/Types.cpp b/SampleCode/SampleEnclave/App/Edger8rSyntax/Types.cpp new file mode 100644 index 0000000000..19702263dd --- /dev/null +++ b/SampleCode/SampleEnclave/App/Edger8rSyntax/Types.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "../App.h" +#include "Enclave_u.h" + +/* edger8r_type_attributes: + * Invokes ECALLs declared with basic types. + */ +void edger8r_type_attributes(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + ret = ecall_type_char(global_eid, (char)0x12); + if (ret != SGX_SUCCESS) + abort(); + + ret = ecall_type_int(global_eid, (int)1234); + if (ret != SGX_SUCCESS) + abort(); + + ret = ecall_type_float(global_eid, (float)1234.0); + if (ret != SGX_SUCCESS) + abort(); + + ret = ecall_type_double(global_eid, (double)1234.5678); + if (ret != SGX_SUCCESS) + abort(); + + ret = ecall_type_size_t(global_eid, (size_t)12345678); + if (ret != SGX_SUCCESS) + abort(); + + ret = ecall_type_wchar_t(global_eid, (wchar_t)0x1234); + if (ret != SGX_SUCCESS) + abort(); + + struct struct_foo_t g = {1234, 5678}; + ret = ecall_type_struct(global_eid, g); + if (ret != SGX_SUCCESS) + abort(); + + union union_foo_t val = {0}; + ret = ecall_type_enum_union(global_eid, ENUM_FOO_0, &val); + if (ret != SGX_SUCCESS) + abort(); + assert(val.union_foo_0 == 2); +} diff --git a/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp b/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp new file mode 100644 index 0000000000..29f0074669 --- /dev/null +++ b/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "../App.h" +#include "Enclave_u.h" + +/* ecall_libc_functions: + * Invokes standard C functions. + */ +void ecall_libc_functions(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + ret = ecall_malloc_free(global_eid); + if (ret != SGX_SUCCESS) + abort(); + + int cpuid[4] = {0x1, 0x0, 0x0, 0x0}; + ret = ecall_sgx_cpuid(global_eid, cpuid, 0x0); + if (ret != SGX_SUCCESS) + abort(); +} diff --git a/SampleCode/SampleEnclave/App/TrustedLibrary/Libcxx.cpp b/SampleCode/SampleEnclave/App/TrustedLibrary/Libcxx.cpp new file mode 100644 index 0000000000..f6d567b98f --- /dev/null +++ b/SampleCode/SampleEnclave/App/TrustedLibrary/Libcxx.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include "../App.h" +#include "Enclave_u.h" + +/* ecall_libcxx_functions: + * Invokes standard C++ functions. + */ +void ecall_libcxx_functions(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + ret = ecall_exception(global_eid); + if (ret != SGX_SUCCESS) + abort(); + + ret = ecall_map(global_eid); + if (ret != SGX_SUCCESS) + abort(); +} diff --git a/SampleCode/SampleEnclave/App/TrustedLibrary/Thread.cpp b/SampleCode/SampleEnclave/App/TrustedLibrary/Thread.cpp new file mode 100644 index 0000000000..ca28fe5ed8 --- /dev/null +++ b/SampleCode/SampleEnclave/App/TrustedLibrary/Thread.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +using namespace std; + +#include "../App.h" +#include "Enclave_u.h" + +static size_t counter = 0; + +void increase_counter(void) +{ + size_t cnr = 0; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + ret = ecall_increase_counter(global_eid, &cnr); + if (cnr != 0) counter = cnr; + if (ret != SGX_SUCCESS) + abort(); +} + +void data_producer(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + ret = ecall_producer(global_eid); + if (ret != SGX_SUCCESS) + abort(); +} + +void data_consumer(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + ret = ecall_consumer(global_eid); + if (ret != SGX_SUCCESS) + abort(); +} + +/* ecall_thread_functions: + * Invokes thread functions including mutex, condition variable, etc. + */ +void ecall_thread_functions(void) +{ + thread adder1(increase_counter); + thread adder2(increase_counter); + thread adder3(increase_counter); + thread adder4(increase_counter); + + adder1.join(); + adder2.join(); + adder3.join(); + adder4.join(); + + assert(counter == 4*LOOPS_PER_THREAD); + + printf("Info: executing thread synchronization, please wait... \n"); + /* condition variable */ + thread consumer1(data_consumer); + thread producer0(data_producer); + thread consumer2(data_consumer); + thread consumer3(data_consumer); + thread consumer4(data_consumer); + + consumer1.join(); + consumer2.join(); + consumer3.join(); + consumer4.join(); + producer0.join(); +} diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.cpp b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.cpp new file mode 100644 index 0000000000..cd0718b5c0 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* Test Array Attributes */ + +#include "sgx_trts.h" +#include "../Enclave.h" +#include "Enclave_t.h" + +/* ecall_array_user_check: + * [user_check] parameter does not perfrom copy operations. + */ +void ecall_array_user_check(int arr[4]) +{ + if (sgx_is_outside_enclave(arr, 4 * sizeof(int)) != 1) + abort(); + + for (int i = 0; i < 4; i++) { + assert(arr[i] == i); + arr[i] = 3 - i; + } +} + +/* ecall_array_in: + * arr[] is copied to trusted domain, but modified + * results will not be reflected to the untrusted side. + */ +void ecall_array_in(int arr[4]) +{ + for (int i = 0; i < 4; i++) { + assert(arr[i] == i); + arr[i] = (3 - i); + } +} + +/* ecall_array_out: + * arr[] is allocated inside the enclave, and it will be copied + * to the untrusted side + */ +void ecall_array_out(int arr[4]) +{ + for (int i = 0; i < 4; i++) { + /* arr is not copied from App */ + assert(arr[i] == 0); + arr[i] = (3 - i); + } +} + +/* ecall_array_in_out: + * arr[] will be allocated inside the enclave, content of arr[] will be copied either. + * After ECALL returns, the results will be copied to the outside. + */ +void ecall_array_in_out(int arr[4]) +{ + for (int i = 0; i < 4; i++) { + assert(arr[i] == i); + arr[i] = (3 - i); + } +} + +/* ecall_array_isary: + * [isary] tells Edger8r that user defined 'array_t' is an array type. + */ +void ecall_array_isary(array_t arr) +{ + if (sgx_is_outside_enclave(arr, sizeof(array_t)) != 1) + abort(); + + int n = sizeof(array_t)/sizeof(arr[0]); + for (int i = 0; i < n; i++) { + assert(arr[i] == i); + arr[i] = (n - 1 - i); + } +} diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.edl b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.edl new file mode 100644 index 0000000000..4d481fa197 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.edl @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Arrays.edl - Samples for array attributes. */ + +enclave { + + /* + * Only for fixed-size array (size is explicitly specified). + */ + + trusted { + + /* + * []: can be used to declare an array. + * [user_check]: + * pointer of the array won't be valified, and the buffer pointed by 'arr' + * is not copied into the enclave either. But enclave can modify the memory outside. + */ + + public void ecall_array_user_check([user_check] int arr[4]); + + /* + * [in]: + * buffer for the array will be allocated inside the enclave, + * content of the array will be copied into the new allocated memory inside. + * Any changes performed inside the enclave will not affect the array outside. + */ + + public void ecall_array_in([in] int arr[4]); + + /* + * [out]: + * buffer for the array will be allocated inside the enclave, + * but the content of the array won't be copied. After ECALL returns, + * the buffer inside the enclave will copied into outside array. + */ + + public void ecall_array_out([out] int arr[4]); + + /* + * [in, out]: + * buffer for the array will be allocated inside the enclave, + * the content of the array will be copied either. After ECALL returns, + * the buffer inside the enclave will by copied into outside array again. + */ + + public void ecall_array_in_out([in, out] int arr[4]); + + /* + * [isary]: + * tells Edger8r the user defined 'array_t' is an array type, 'arr' will be + * treated as a pointer, no memory copied either due to [user_check]. + * For OCALLs, 'arr' shall point to the memory outside the enclave. + */ + + public void ecall_array_isary([user_check, isary] array_t arr); + + }; + + untrusted { + + /* + * [user_check|in|out|in,out|isary] can also be used in OCALLs, refer to the "User Guide" for details. + */ + + }; + +}; diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.cpp b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.cpp new file mode 100644 index 0000000000..e29739a21e --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Test Calling Conventions */ + +#include +#include + +#include "../Enclave.h" +#include "Enclave_t.h" + +/* ecall_function_calling_convs: + * memccpy is defined in system C library. + */ +void ecall_function_calling_convs(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + char s1[] = "1234567890"; + char s2[] = "0987654321"; + + char buf[BUFSIZ] = {'\0'}; + memcpy(buf, s1, strlen(s1)); + + ret = memccpy(NULL, s1, s2, '\0', strlen(s1)); + + if (ret != SGX_SUCCESS) + abort(); + assert(memcmp(s1, s2, strlen(s1)) == 0); + + return; +} + +/* ecall_function_public: + * The public ECALL that invokes the OCALL 'ocall_function_allow'. + */ +void ecall_function_public(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + ret = ocall_function_allow(); + if (ret != SGX_SUCCESS) + abort(); + + return; +} + +/* ecall_function_private: + * The private ECALL that only can be invoked in the OCALL 'ocall_function_allow'. + */ +int ecall_function_private(void) +{ + return 1; +} + diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.edl b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.edl new file mode 100644 index 0000000000..ad9e1d995f --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.edl @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Functions.edl - Samples for function attributes. */ + +enclave { + + /* + * Following keywords/attributes are supported for untrusted functions: + * cdecl, stdcall, fastcall, dllimport (only for Windows). + * [public] is only supported for the trusted functions. + * Trusted function will be treated as [private] w/o the [public]. + */ + + trusted { + + public void ecall_function_calling_convs(void); + + /* + * [public]: + * public ECALL can be called directly in App. + */ + + public void ecall_function_public(void); + + /* + * [private]: + * private ECALL cannot be called directly in App. + */ + + int ecall_function_private(void); + + }; + + untrusted { + + /* + * [cdecl]: + * tells edger8r the calling convention of the OCALLs is 'cdecl'. + * [dllimport]: + * indicats the OCALL is provided in DLLs. + * + * Note: memccpy() is provided by MS system DLL, we don't need to implement it in App side. + */ + + [cdecl, dllimport] void *memccpy([in, out, size=len] void *dest, [in, size=len] const void *src, int val, size_t len); + + /* + * [allow]: + * OCALL 'ocall_function_allow' can invoke ECALL 'ecall_function_private' in App side. + * + * Note: No ECALL can be called in OCALL w/o [allow]. + */ + + void ocall_function_allow(void) allow(ecall_function_private); + + }; + +}; diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.cpp b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.cpp new file mode 100644 index 0000000000..3ee37ab8f4 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.cpp @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Test Pointer Auttributes */ + +#include +#include + +#include "sgx_trts.h" +#include "../Enclave.h" +#include "Enclave_t.h" + +/* checksum_internal: + * get simple checksum of input buffer and length + */ +int32_t checksum_internal(char *buf, size_t count) +{ + register int32_t sum = 0; + int16_t *ptr = (int16_t *)buf; + + /* Main summing loop */ + while(count > 1) { + sum = sum + *ptr++; + count = count - 2; + } + + /* Add left-over byte, if any */ + if (count > 0) + sum = sum + *((char *)ptr); + + return ~sum; +} + +/* ecall_pointer_user_check, ecall_pointer_in, ecall_pointer_out, ecall_pointer_in_out: + * The root ECALLs to test [in], [out], [user_check] attributes. + */ +size_t ecall_pointer_user_check(void *val, size_t sz) +{ + /* check if the buffer is allocated outside */ + if (sgx_is_outside_enclave(val, sz) != 1) + abort(); + + char tmp[100] = {0}; + size_t len = sz>100?100:sz; + + /* copy the memory into the enclave to make sure 'val' + * is not being changed in checksum_internal() */ + memcpy(tmp, val, len); + + int32_t sum = checksum_internal((char *)tmp, len); + printf("Checksum(0x%p, %zu) = 0x%x\n", + val, len, sum); + + /* modify outside memory directly */ + memcpy(val, "SGX_SUCCESS", len>12?12:len); + + return len; +} + +/* ecall_pointer_in: + * the buffer of val is copied to the enclave. + */ + +void ecall_pointer_in(int *val) +{ + if (sgx_is_within_enclave(val, sizeof(int)) != 1) + abort(); + *val = 1234; +} + +/* ecall_pointer_out: + * the buffer of val is copied to the untrusted side. + */ +void ecall_pointer_out(int *val) +{ + if (sgx_is_within_enclave(val, sizeof(int)) != 1) + abort(); + assert(*val == 0); + *val = 1234; +} + +/* ecall_pointer_in_out: + * the buffer of val is double-copied. + */ +void ecall_pointer_in_out(int *val) +{ + if (sgx_is_within_enclave(val, sizeof(int)) != 1) + abort(); + *val = 1234; +} + +/* ocall_pointer_attr: + * The root ECALL that test OCALL [in], [out], [user_check]. + */ +void ocall_pointer_attr(void) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + int val = 0; + ret = ocall_pointer_user_check(&val); + if (ret != SGX_SUCCESS) + abort(); + + val = 0; + ret = ocall_pointer_in(&val); + if (ret != SGX_SUCCESS) + abort(); + assert(val == 0); + + val = 0; + ret = ocall_pointer_out(&val); + if (ret != SGX_SUCCESS) + abort(); + assert(val == 1234); + + val = 0; + ret = ocall_pointer_in_out(&val); + if (ret != SGX_SUCCESS) + abort(); + assert(val == 1234); + + return; +} + +/* ecall_pointer_string: + * [string] defines a string. + */ +void ecall_pointer_string(char *str) +{ + strncpy(str, "0987654321", strlen(str)); +} + +/* ecall_pointer_string_const: + * const [string] defines a string that cannot be modified. + */ +void ecall_pointer_string_const(const char *str) +{ + char* temp = new char[strlen(str)]; + strncpy(temp, str, strlen(str)); + delete []temp; +} + +/* ecall_pointer_size: + * 'len' needs to be specified to tell Edger8r the length of 'str'. + */ +void ecall_pointer_size(void *ptr, size_t len) +{ + strncpy((char*)ptr, "0987654321", len); +} + +/* ecall_pointer_count: + * 'cnt' needs to be specified to tell Edger8r the number of elements in 'arr'. + */ +void ecall_pointer_count(int *arr, int cnt) +{ + for (int i = (cnt - 1); i >= 0; i--) + arr[i] = (cnt - 1 - i); +} + +/* ecall_pointer_isptr_readonly: + * 'buf' is user defined type, shall be tagged with [isptr]. + * if it's not writable, [readonly] shall be specified. + */ +void ecall_pointer_isptr_readonly(buffer_t buf, size_t len) +{ + strncpy((char*)buf, "0987654321", len); +} + +/* get_buffer_len: + * get the length of input buffer 'buf'. + */ +size_t get_buffer_len(const char* buf) +{ + (void)buf; + return 10*sizeof(int); +} + +/* ecall_pointer_sizefunc: + * call get_buffer_len to determin the length of 'buf'. + */ +void ecall_pointer_sizefunc(char *buf) +{ + int *tmp = (int*)buf; + for (int i = 0; i < 10; i++) { + assert(tmp[i] == 0); + tmp[i] = i; + } +} diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.edl b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.edl new file mode 100644 index 0000000000..cbbc960f38 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.edl @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Pointers.edl - Samples for pointer attributes. */ + +enclave { + + /* + * Following keywords/attributes are supported for pointers in Edger8r: + * in, out, user_check, + * string, wstring, + * const, size, count, sizefunc, isptr, readonly + */ + + trusted { + + /* + * [user_check]: + * the pointer won't be validated, and the buffer pointed by + * 'val' is not copied into the enclave either. But Enclave + * can modify the memory pointed by 'val'. + */ + + public size_t ecall_pointer_user_check([user_check] void *val, size_t sz); + + /* + * [in]: + * buffer with the same size will be allocated inside the enclave, + * content pointed by 'val' will be copied into the new allocated + * memory inside. Any changes performed inside the enclave will not + * affect the buffer outside. + */ + + public void ecall_pointer_in([in] int *val); + + /* + * [out]: + * buffer with the same size will be allocated inside the enclave, + * but the content pointed by 'val' won't be copied. But after return, + * the buffer inside the enclave will copied into outside 'val'. + */ + + public void ecall_pointer_out([out] int *val); + + /* + * [in, out]: + * buffer with the same size will be allocated inside the enclave, + * the content pointed by 'val' will be copied either. After return, + * the buffer inside the enclave will by copied into outside 'val' again. + */ + + public void ecall_pointer_in_out([in, out] int *val); + + /* + * [string]: + * the attribute tells Edger8r 'str' is NULL terminated string, so strlen + * will be used to count the length of buffer pointed by 'str'. + */ + + public void ecall_pointer_string([in, out, string] char *str); + + /* + * [const]: + * the attribute tells Edger8r the buffer pointed by 'str' cannot be modified, + * so users cannot decorate 'str' with [out] attribute anymore. + */ + + public void ecall_pointer_string_const([in, string] const char *str); + + /* + * [size]: + * the attribute tells Edger8r the length of buffer in byte pointed by 'ptr' + * (shall be copied or not). + * Note: Users shall not specify [size] on [string] parameters. + */ + + public void ecall_pointer_size([in, out, size=len] void *ptr, size_t len); + + /* + * [count]: + * the attribute tells Edger8r the number of integers to be copied from 'arr'. + */ + + public void ecall_pointer_count([in, out, count=cnt] int *arr, int cnt); + + /* + * [isptr]: + * tells Edger8r the user defined type is a pointer; + * [readonly]: + * forbids the buffer allocated inside the enclave to be copied back to App + * (cannot use with [out]). + */ + + public void ecall_pointer_isptr_readonly([in, isptr, readonly, size=len] buffer_t buf, size_t len); + + /* + * [sizefunc]: + * call a function to decide the size/length of the parameter; + * Note: + * User need to define and implement `get_buf_len' as: + * size_t get_buf_len(const char* buf); + */ + + public void ecall_pointer_sizefunc([sizefunc = get_buffer_len, in, out] char *buf); + + }; + + /* + * Users can define multiple trusted/untrusted blocks, + * edger8r will merged them into one trusted/untrusted block. + */ + trusted { + /* + * Test pointer attributes in OCALLs + */ + + public void ocall_pointer_attr(void); + + }; + + untrusted { + + /* + * [user_check]: + * the pointer won't be valified, and the buffer pointed by 'val' is not + * copied to outside buffer either. Besides 'App' cannot modify the memory + * pointer by 'val'. + */ + + void ocall_pointer_user_check([user_check] int *val); + + /* + * [in]: + * buffer with the same size will be allocated in 'App' side, the content + * pointed by 'val' will be copied into the new allocated memory outside. + * Any changes performed by 'App' will not affect the buffer pointed by 'val'. + */ + + void ocall_pointer_in([in] int *val); + + /* + * [out]: + * buffer with the same size will be allocated in 'App' side, the content + * pointed by 'val' won't be copied. But after return, the buffer outside + * will be copied into the enclave. + */ + + void ocall_pointer_out([out] int *val); + + /* + * [in, out]: + * buffer with the same size will be allocated in 'App' side, the content + * pointed by 'val' will be copied either. After return, the buffer outside + * will copied into the enclave. + */ + + void ocall_pointer_in_out([in, out] int *val); + + }; + +}; diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.cpp b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.cpp new file mode 100644 index 0000000000..aba016a6d8 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Test Basic Types */ + +#include "sgx_trts.h" +#include "../Enclave.h" +#include "Enclave_t.h" +#include +#include + +/* used to eliminate `unused variable' warning */ +#define UNUSED(val) (void)(val) + +#define ULP 2 + +/* used to compare double variables in order to avoid compile warnings */ +bool almost_equal(double x, double y) +{ + /* the machine epsilon has to be scaled to the magnitude of the larger value + and multiplied by the desired precision in ULPs (units in the last place) */ + return std::abs(x-y) <= std::numeric_limits::epsilon() * std::abs(x+y) * ULP; +} + +/* used to compare double variables in order to avoid compile warnings */ +bool almost_equal(float x, float y) +{ + /* the machine epsilon has to be scaled to the magnitude of the larger value + and multiplied by the desired precision in ULPs (units in the last place) */ + return std::abs(x-y) <= std::numeric_limits::epsilon() * std::abs(x+y) * ULP; +} + +/* ecall_type_char: + * [char] value passed by App. + */ +void ecall_type_char(char val) +{ + assert(val == 0x12); +#ifndef DEBUG + UNUSED(val); +#endif +} + +/* ecall_type_int: + * [int] value passed by App. + */ +void ecall_type_int(int val) +{ + assert(val == 1234); +#ifndef DEBUG + UNUSED(val); +#endif +} + +/* ecall_type_float: + * [float] value passed by App. + */ +void ecall_type_float(float val) +{ + assert(almost_equal(val, (float)1234.0)); +#ifndef DEBUG + UNUSED(val); +#endif +} + +/* ecall_type_double: + * [double] value passed by App. + */ +void ecall_type_double(double val) +{ + assert(almost_equal(val, (double)1234.5678)); +#ifndef DEBUG + UNUSED(val); +#endif +} + +/* ecall_type_size_t: + * [size_t] value passed by App. + */ +void ecall_type_size_t(size_t val) +{ + assert(val == (size_t)12345678); +#ifndef DEBUG + UNUSED(val); +#endif +} + +/* ecall_type_wchar_t: + * [wchar_t] value passed by App. + */ +void ecall_type_wchar_t(wchar_t val) +{ + assert(val == (wchar_t)0x1234); +#ifndef DEBUG + UNUSED(val); +#endif +} + +/* ecall_type_struct: + * struct_foo_t is defined in EDL and can be used in ECALL. + */ +void ecall_type_struct(struct struct_foo_t val) +{ + assert(val.struct_foo_0 == 1234); + assert(val.struct_foo_1 == 5678); +#ifndef DEBUG + UNUSED(val); +#endif +} + +/* + * ecall_type_enum_union: + * enum_foo_t/union_foo_t is defined in EDL + * and can be used in ECALL. + */ +void ecall_type_enum_union(enum enum_foo_t val1, union union_foo_t *val2) +{ + if (sgx_is_outside_enclave(val2, sizeof(union union_foo_t)) != 1) + abort(); + val2->union_foo_0 = 1; + val2->union_foo_1 = 2; /* overwrite union_foo_0 */ + assert(val1 == ENUM_FOO_0); +#ifndef DEBUG + UNUSED(val1); +#endif +} diff --git a/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.edl b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.edl new file mode 100644 index 0000000000..a23aed85ca --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.edl @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* Types.edl - Samples for basic types. */ + +enclave { + + /* + * Following types can be supported in Edger8r: + * char, short, int, float, double, void, + * int8_t, int16_t, int32_t, int64_t, + * size_t, wchar_t, + * uint8_t, uint16_t, uint32_t, uint64_t, + * unsigned, struct, enum, union. + */ + + /* + * We will demo few types in ECALL functions, data + * types in OCALL functions can be handled either. + */ + + /* structure definition */ + struct struct_foo_t { + /* Basic types can be used in structure. */ + uint32_t struct_foo_0; + uint64_t struct_foo_1; + }; + + /* enum definition */ + enum enum_foo_t { + ENUM_FOO_0 = 0, + ENUM_FOO_1 = 1 + }; + + /* union definition */ + union union_foo_t { + uint32_t union_foo_0; + uint32_t union_foo_1; + uint64_t union_foo_3; + }; + + trusted { + + public void ecall_type_char(char val); + public void ecall_type_int(int val); + + public void ecall_type_float(float val); + public void ecall_type_double(double val); + + public void ecall_type_size_t(size_t val); + public void ecall_type_wchar_t(wchar_t val); + + public void ecall_type_struct(struct struct_foo_t val); + public void ecall_type_enum_union(enum enum_foo_t val1, [user_check] union union_foo_t *val2); + + /* for using user defined types, please refer to Pointers.edl, Arrays.edl. */ + }; + +}; diff --git a/SampleCode/SampleEnclave/Enclave/Enclave.config.xml b/SampleCode/SampleEnclave/Enclave/Enclave.config.xml new file mode 100644 index 0000000000..a94d12f001 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Enclave.config.xml @@ -0,0 +1,12 @@ + + + 0 + 0 + 0x40000 + 0x100000 + 10 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/SampleCode/SampleEnclave/Enclave/Enclave.cpp b/SampleCode/SampleEnclave/Enclave/Enclave.cpp new file mode 100644 index 0000000000..94a3108c46 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Enclave.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include /* vsnprintf */ + +#include "Enclave.h" +#include "Enclave_t.h" /* print_string */ + +/* + * printf: + * Invokes OCALL to display the enclave buffer to the terminal. + */ +void printf(const char *fmt, ...) +{ + char buf[BUFSIZ] = {'\0'}; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, BUFSIZ, fmt, ap); + va_end(ap); + ocall_print_string(buf); +} diff --git a/SampleCode/SampleEnclave/Enclave/Enclave.edl b/SampleCode/SampleEnclave/Enclave/Enclave.edl new file mode 100644 index 0000000000..9e31bd2ce8 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Enclave.edl @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* Enclave.edl - Top EDL file. */ + +enclave { + + include "user_types.h" /* buffer_t */ + + /* Import ECALL/OCALL from sub-directory EDLs. + * [from]: specifies the location of EDL file. + * [import]: specifies the functions to import, + * [*]: implies to import all functions. + */ + + from "Edger8rSyntax/Types.edl" import *; + from "Edger8rSyntax/Pointers.edl" import *; + from "Edger8rSyntax/Arrays.edl" import *; + from "Edger8rSyntax/Functions.edl" import *; + + from "TrustedLibrary/Libc.edl" import *; + from "TrustedLibrary/Libcxx.edl" import ecall_exception, ecall_map; + from "TrustedLibrary/Thread.edl" import *; + + /* + * ocall_print_string - invokes OCALL to display string buffer inside the enclave. + * [in]: copy the string buffer to App outside. + * [string]: specifies 'str' is a NULL terminated buffer. + */ + untrusted { + void ocall_print_string([in, string] const char *str); + }; + +}; diff --git a/SampleCode/SampleEnclave/Enclave/Enclave.h b/SampleCode/SampleEnclave/Enclave/Enclave.h new file mode 100644 index 0000000000..6e4c09ee2c --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Enclave.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ENCLAVE_H_ +#define _ENCLAVE_H_ + +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +void printf(const char *fmt, ...); + +#if defined(__cplusplus) +} +#endif + +#endif /* !_ENCLAVE_H_ */ diff --git a/SampleCode/SampleEnclave/Enclave/Enclave.lds b/SampleCode/SampleEnclave/Enclave/Enclave.lds new file mode 100644 index 0000000000..e3d9d0ee0d --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Enclave.lds @@ -0,0 +1,9 @@ +enclave.so +{ + global: + g_global_data_sim; + g_global_data; + enclave_entry; + local: + *; +}; diff --git a/SampleCode/SampleEnclave/Enclave/Enclave_private.pem b/SampleCode/SampleEnclave/Enclave/Enclave_private.pem new file mode 100644 index 0000000000..529d07be35 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/Enclave_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4gIBAAKCAYEAroOogvsj/fZDZY8XFdkl6dJmky0lRvnWMmpeH41Bla6U1qLZ +AmZuyIF+mQC/cgojIsrBMzBxb1kKqzATF4+XwPwgKz7fmiddmHyYz2WDJfAjIveJ +ZjdMjM4+EytGlkkJ52T8V8ds0/L2qKexJ+NBLxkeQLfV8n1mIk7zX7jguwbCG1Pr +nEMdJ3Sew20vnje+RsngAzdPChoJpVsWi/K7cettX/tbnre1DL02GXc5qJoQYk7b +3zkmhz31TgFrd9VVtmUGyFXAysuSAb3EN+5VnHGr0xKkeg8utErea2FNtNIgua8H +ONfm9Eiyaav1SVKzPHlyqLtcdxH3I8Wg7yqMsaprZ1n5A1v/levxnL8+It02KseD +5HqV4rf/cImSlCt3lpRg8U5E1pyFQ2IVEC/XTDMiI3c+AR+w2jSRB3Bwn9zJtFlW +KHG3m1xGI4ck+Lci1JvWWLXQagQSPtZTsubxTQNx1gsgZhgv1JHVZMdbVlAbbRMC +1nSuJNl7KPAS/VfzAgEDAoIBgHRXxaynbVP5gkO0ug6Qw/E27wzIw4SmjsxG6Wpe +K7kfDeRskKxESdsA/xCrKkwGwhcx1iIgS5+Qscd1Yg+1D9X9asd/P7waPmWoZd+Z +AhlKwhdPsO7PiF3e1AzHhGQwsUTt/Y/aSI1MpHBvy2/s1h9mFCslOUxTmWw0oj/Q +ldIEgWeNR72CE2+jFIJIyml6ftnb6qzPiga8Bm48ubKh0kvySOqnkmnPzgh+JBD6 +JnBmtZbfPT97bwTT+N6rnPqOOApvfHPf15kWI8yDbprG1l4OCUaIUH1AszxLd826 +5IPM+8gINLRDP1MA6azECPjTyHXhtnSIBZCyWSVkc05vYmNXYUNiXWMajcxW9M02 +wKzFELO8NCEAkaTPxwo4SCyIjUxiK1LbQ9h8PSy4c1+gGP4LAMR8xqP4QKg6zdu9 +osUGG/xRe/uufgTBFkcjqBHtK5L5VI0jeNIUAgW/6iNbYXjBMJ0GfauLs+g1VsOm +WfdgXzsb9DYdMa0OXXHypmV4GwKBwQDUwQj8RKJ6c8cT4vcWCoJvJF00+RFL+P3i +Gx2DLERxRrDa8AVGfqaCjsR+3vLgG8V/py+z+dxZYSqeB80Qeo6PDITcRKoeAYh9 +xlT3LJOS+k1cJcEmlbbO2IjLkTmzSwa80fWexKu8/Xv6vv15gpqYl1ngYoqJM3pd +vzmTIOi7MKSZ0WmEQavrZj8zK4endE3v0eAEeQ55j1GImbypSf7Idh7wOXtjZ7WD +Dg6yWDrri+AP/L3gClMj8wsAxMV4ZR8CgcEA0fzDHkFa6raVOxWnObmRoDhAtE0a +cjUj976NM5yyfdf2MrKy4/RhdTiPZ6b08/lBC/+xRfV3xKVGzacm6QjqjZrUpgHC +0LKiZaMtccCJjLtPwQd0jGQEnKfMFaPsnhOc5y8qVkCzVOSthY5qhz0XNotHHFmJ +gffVgB0iqrMTvSL7IA2yqqpOqNRlhaYhNl8TiFP3gIeMtVa9rZy31JPgT2uJ+kfo +gV7sdTPEjPWZd7OshGxWpT6QfVDj/T9T7L6tAoHBAI3WBf2DFvxNL2KXT2QHAZ9t +k3imC4f7U+wSE6zILaDZyzygA4RUbwG0gv8/TJVn2P/Eynf76DuWHGlaiLWnCbSz +Az2DHBQBBaku409zDQym3j1ugMRjzzSQWzJg0SIyBH3hTmnYcn3+Uqcp/lEBvGW6 +O+rsXFt3pukqJmIV8HzLGGaLm62BHUeZf3dyWm+i3p/hQAL7Xvu04QW70xuGqdr5 +afV7p5eaeQIJXyGQJ0eylV/90+qxjMKiB1XYg6WYvwKBwQCL/ddpgOdHJGN8uRom +e7Zq0Csi3hGheMKlKbN3vcxT5U7MdyHtTZZOJbTvxKNNUNYH/8uD+PqDGNneb29G +BfGzvI3EASyLIcGZF3OhKwZd0jUrWk2y7Vhob91jwp2+t73vdMbkKyI4mHOuXvGv +fg95si9oO7EBT+Oqvhccd2J+F1IVXncccYnF4u5ZGWt5lLewN/pVr7MjjykeaHqN +t+rfnQam2psA6fL4zS2zTmZPzR2tnY8Y1GBTi0Ko1OKd1HMCgcAb5cB/7/AQlhP9 +yQa04PLH9ygQkKKptZp7dy5WcWRx0K/hAHRoi2aw1wZqfm7VBNu2SLcs90kCCCxp +6C5sfJi6b8NpNbIPC+sc9wsFr7pGo9SFzQ78UlcWYK2Gu2FxlMjonhka5hvo4zvg +WxlpXKEkaFt3gLd92m/dMqBrHfafH7VwOJY2zT3WIpjwuk0ZzmRg5p0pG/svVQEH +NZmwRwlopysbR69B/n1nefJ84UO50fLh5s5Zr3gBRwbWNZyzhXk= +-----END RSA PRIVATE KEY----- diff --git a/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.cpp b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.cpp new file mode 100644 index 0000000000..b0e566ced1 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include + +#include "sgx_trts.h" +#include "../Enclave.h" +#include "Enclave_t.h" + +/* ecall_malloc_free: + * Uses malloc/free to allocate/free trusted memory. + */ +void ecall_malloc_free(void) +{ + void *ptr = malloc(100); + assert(ptr != NULL); + memset(ptr, 0x0, 100); + free(ptr); +} + +/* ecall_sgx_cpuid: + * Uses sgx_cpuid to get CPU features and types. + */ +void ecall_sgx_cpuid(int cpuinfo[4], int leaf) +{ + sgx_status_t ret = sgx_cpuid(cpuinfo, leaf); + if (ret != SGX_SUCCESS) + abort(); +} diff --git a/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl new file mode 100644 index 0000000000..9efe3219d4 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Libc.edl - EDL sample for trusted C library. */ + +enclave { + + from "sgx_tstdc.edl" import sgx_oc_cpuidex; + + /* + * A subset of the C99 standard is supported as well as SGX customized functions: + * sgx_cpuid, etc. + */ + + trusted { + /* + * Utilize malloc/free in enclave. + */ + public void ecall_malloc_free(void); + + /* + * Utilize SGX version __cpuid() in enclave. + */ + public void ecall_sgx_cpuid([in, out] int cpuinfo[4], int leaf); + }; +}; diff --git a/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.cpp b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.cpp new file mode 100644 index 0000000000..6f76646466 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include + +#include "../Enclave.h" +#include "Enclave_t.h" + +/* + * ecall_exception: + * throw/catch C++ exception inside the enclave. + */ + +void ecall_exception(void) +{ + std::string foo = "foo"; + try { + throw std::runtime_error(foo); + } + catch (std::runtime_error const& e) { + assert( foo == e.what() ); + std::runtime_error clone(""); + clone = e; + assert(foo == clone.what() ); + } + catch (...) { + assert( false ); + } +} + +#include +#include + +using namespace std; + +/* + * ecall_map: + * Utilize STL in the enclave. + */ +void ecall_map(void) +{ + typedef map > map_t; + typedef map_t::value_type map_value; + map_t m; + + m.insert(map_value('a', 1)); + m.insert(map_value('b', 2)); + m.insert(map_value('c', 3)); + m.insert(map_value('d', 4)); + + assert(m['a'] == 1); + assert(m['b'] == 2); + assert(m['c'] == 3); + assert(m['d'] == 4); + + assert(m.find('e') == m.end()); + + return; +} diff --git a/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.edl b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.edl new file mode 100644 index 0000000000..49a8b8d9d9 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.edl @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Libcxx.edl - EDL sample for trusted C++ library. */ + +enclave { + + /* + * A subset of the C++03 standard is supported. + */ + + trusted { + /* + * Throw/catch exception inside the enclave. + */ + public void ecall_exception(void); + + /* + * Utilize inside the enclave. + */ + public void ecall_map(void); + }; +}; diff --git a/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.cpp b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.cpp new file mode 100644 index 0000000000..d360d716a6 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "../Enclave.h" +#include "Enclave_t.h" + +#include + +static size_t global_counter = 0; +static sgx_thread_mutex_t global_mutex = SGX_THREAD_MUTEX_INITIALIZER; + +#define BUFFER_SIZE 50 + +typedef struct { + int buf[BUFFER_SIZE]; + int occupied; + int nextin; + int nextout; + sgx_thread_mutex_t mutex; + sgx_thread_cond_t more; + sgx_thread_cond_t less; +} cond_buffer_t; + +static cond_buffer_t buffer = {{0, 0, 0, 0, 0, 0}, 0, 0, 0, + SGX_THREAD_MUTEX_INITIALIZER, SGX_THREAD_COND_INITIALIZER, SGX_THREAD_COND_INITIALIZER}; + +/* + * ecall_increase_counter: + * Utilize thread APIs inside the enclave. + */ +size_t ecall_increase_counter(void) +{ + size_t ret = 0; + for (int i = 0; i < LOOPS_PER_THREAD; i++) { + sgx_thread_mutex_lock(&global_mutex); + /* mutually exclusive adding */ + size_t tmp = global_counter; + global_counter = ++tmp; + if (4*LOOPS_PER_THREAD == global_counter) + ret = global_counter; + sgx_thread_mutex_unlock(&global_mutex); + } + return ret; +} + +void ecall_producer(void) +{ + for (int i = 0; i < 4*LOOPS_PER_THREAD; i++) { + cond_buffer_t *b = &buffer; + sgx_thread_mutex_lock(&b->mutex); + while (b->occupied >= BUFFER_SIZE) + sgx_thread_cond_wait(&b->less, &b->mutex); + b->buf[b->nextin] = b->nextin; + b->nextin++; + b->nextin %= BUFFER_SIZE; + b->occupied++; + sgx_thread_cond_signal(&b->more); + sgx_thread_mutex_unlock(&b->mutex); + } +} + +void ecall_consumer(void) +{ + for (int i = 0; i < LOOPS_PER_THREAD; i++) { + cond_buffer_t *b = &buffer; + sgx_thread_mutex_lock(&b->mutex); + while(b->occupied <= 0) + sgx_thread_cond_wait(&b->more, &b->mutex); + b->buf[b->nextout++] = 0; + b->nextout %= BUFFER_SIZE; + b->occupied--; + sgx_thread_cond_signal(&b->less); + sgx_thread_mutex_unlock(&b->mutex); + } +} diff --git a/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.edl b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.edl new file mode 100644 index 0000000000..77ce461de4 --- /dev/null +++ b/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.edl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* Thread.edl - EDL sample for trusted thread library. */ + +enclave { + + from "sgx_tstdc.edl" import sgx_thread_wait_untrusted_event_ocall, sgx_thread_set_untrusted_event_ocall, sgx_thread_setwait_untrusted_events_ocall, sgx_thread_set_multiple_untrusted_events_ocall; + + trusted { + /* + * Use SGX mutex. + */ + public size_t ecall_increase_counter(); + + /* + * Use SGX condition variables. + */ + public void ecall_producer(); + public void ecall_consumer(); + + }; +}; diff --git a/SampleCode/SampleEnclave/Include/user_types.h b/SampleCode/SampleEnclave/Include/user_types.h new file mode 100644 index 0000000000..00a9bed83f --- /dev/null +++ b/SampleCode/SampleEnclave/Include/user_types.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* User defined types */ + + +#define LOOPS_PER_THREAD 500 + +typedef void *buffer_t; +typedef int array_t[10]; + diff --git a/SampleCode/SampleEnclave/Makefile b/SampleCode/SampleEnclave/Makefile new file mode 100644 index 0000000000..3885ed8b58 --- /dev/null +++ b/SampleCode/SampleEnclave/Makefile @@ -0,0 +1,209 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +######## SGX SDK Settings ######## + +SGX_SDK ?= /opt/intel/sgxsdk +SGX_MODE ?= SIM +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## App Settings ######## + +ifneq ($(SGX_MODE), HW) + Urts_Library_Name := sgx_urts_sim +else + Urts_Library_Name := sgx_urts +endif + +App_Cpp_Files := App/App.cpp $(wildcard App/Edger8rSyntax/*.cpp) $(wildcard App/TrustedLibrary/*.cpp) +App_Include_Paths := -IInclude -IApp -I$(SGX_SDK)/include + +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +# Three configuration modes - Debug, prerelease, release +# Debug - Macro DEBUG enabled. +# Prerelease - Macro NDEBUG and EDEBUG enabled. +# Release - Macro NDEBUG enabled. +ifeq ($(SGX_DEBUG), 1) + App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG +else ifeq ($(SGX_PRERELEASE), 1) + App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG +else + App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG +endif + +App_Cpp_Flags := $(App_C_Flags) -std=c++11 +App_Link_Flags := $(SGX_COMMON_CFLAGS) -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name) -lpthread + +ifneq ($(SGX_MODE), HW) + App_Link_Flags += -lsgx_uae_service_sim +else + App_Link_Flags += -lsgx_uae_service +endif + +App_Cpp_Objects := $(App_Cpp_Files:.cpp=.o) + +App_Name := app + +######## Enclave Settings ######## + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif +Crypto_Library_Name := sgx_tcrypto + +Enclave_Cpp_Files := Enclave/Enclave.cpp $(wildcard Enclave/Edger8rSyntax/*.cpp) $(wildcard Enclave/TrustedLibrary/*.cpp) +Enclave_Include_Paths := -IInclude -IEnclave -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport + +Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) +Enclave_Cpp_Flags := $(Enclave_C_Flags) -std=c++03 -nostdinc++ +Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 \ + -Wl,--version-script=Enclave/Enclave.lds + +Enclave_Cpp_Objects := $(Enclave_Cpp_Files:.cpp=.o) + +Enclave_Name := enclave.so +Signed_Enclave_Name := enclave.signed.so +Enclave_Config_File := Enclave/Enclave.config.xml + +ifeq ($(SGX_MODE), HW) +ifneq ($(SGX_DEBUG), 1) +ifneq ($(SGX_PRERELEASE), 1) +Build_Mode = HW_RELEASE +endif +endif +endif + + +.PHONY: all run + +ifeq ($(Build_Mode), HW_RELEASE) +all: $(App_Name) $(Enclave_Name) + @echo "The project has been built in release hardware mode." + @echo "Please sign the $(Enclave_Name) first with your signing key before you run the $(App_Name) to launch and access the enclave." + @echo "To sign the enclave use the command:" + @echo " $(SGX_ENCLAVE_SIGNER) sign -key -enclave $(Enclave_Name) -out <$(Signed_Enclave_Name)> -config $(Enclave_Config_File)" + @echo "You can also sign the enclave using an external signing tool. See User's Guide for more details." + @echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW." +else +all: $(App_Name) $(Signed_Enclave_Name) +endif + +run: all +ifneq ($(Build_Mode), HW_RELEASE) + @$(CURDIR)/$(App_Name) + @echo "RUN => $(App_Name) [$(SGX_MODE)|$(SGX_ARCH), OK]" +endif + +######## App Objects ######## + +App/Enclave_u.c: $(SGX_EDGER8R) Enclave/Enclave.edl + @cd App && $(SGX_EDGER8R) --untrusted ../Enclave/Enclave.edl --search-path ../Enclave --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +App/Enclave_u.o: App/Enclave_u.c + @$(CC) $(App_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +App/%.o: App/%.cpp + @$(CXX) $(App_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +$(App_Name): App/Enclave_u.o $(App_Cpp_Objects) + @$(CXX) $^ -o $@ $(App_Link_Flags) + @echo "LINK => $@" + + +######## Enclave Objects ######## + +Enclave/Enclave_t.c: $(SGX_EDGER8R) Enclave/Enclave.edl + @cd Enclave && $(SGX_EDGER8R) --trusted ../Enclave/Enclave.edl --search-path ../Enclave --search-path $(SGX_SDK)/include + @echo "GEN => $@" + +Enclave/Enclave_t.o: Enclave/Enclave_t.c + @$(CC) $(Enclave_C_Flags) -c $< -o $@ + @echo "CC <= $<" + +Enclave/%.o: Enclave/%.cpp + @$(CXX) $(Enclave_Cpp_Flags) -c $< -o $@ + @echo "CXX <= $<" + +$(Enclave_Name): Enclave/Enclave_t.o $(Enclave_Cpp_Objects) + @$(CXX) $^ -o $@ $(Enclave_Link_Flags) + @echo "LINK => $@" + +$(Signed_Enclave_Name): $(Enclave_Name) + @$(SGX_ENCLAVE_SIGNER) sign -key Enclave/Enclave_private.pem -enclave $(Enclave_Name) -out $@ -config $(Enclave_Config_File) + @echo "SIGN => $@" + +.PHONY: clean + +clean: + @rm -f $(App_Name) $(Enclave_Name) $(Signed_Enclave_Name) $(App_Cpp_Objects) App/Enclave_u.* $(Enclave_Cpp_Objects) Enclave/Enclave_t.* diff --git a/SampleCode/SampleEnclave/README.txt b/SampleCode/SampleEnclave/README.txt new file mode 100644 index 0000000000..b07ef7fcfb --- /dev/null +++ b/SampleCode/SampleEnclave/README.txt @@ -0,0 +1,29 @@ +------------------------ +Purpose of SampleEnclave +------------------------ +The project demonstrates several fundamental usages of Intel(R) Software Guard +Extensions (SGX) SDK: +- Initializing and destroying an enclave +- Creating ECALLs or OCALLs +- Calling trusted libraries inside the enclave + +------------------------------------ +How to Build/Execute the Sample Code +------------------------------------ +1. Install Intel(R) SGX SDK for Linux* OS +2. Build the project with the prepared Makefile: + a. Hardware Mode, Debug build: + $ make SGX_MODE=HW SGX_DEBUG=1 + b. Hardware Mode, Pre-release build: + $ make SGX_MODE=HW SGX_PRERELEASE=1 + c. Hardware Mode, Release build: + $ make SGX_MODE=HW + d. Simulation Mode, Debug build: + $ make SGX_DEBUG=1 + e. Simulation Mode, Pre-release build: + $ make SGX_PRERELEASE=1 + f. Simulation Mode, Release build: + $ make +3. Execute the binary directly: + $ ./app + diff --git a/build-scripts/enclave.lds b/build-scripts/enclave.lds new file mode 100644 index 0000000000..975b185f3c --- /dev/null +++ b/build-scripts/enclave.lds @@ -0,0 +1,9 @@ +{ +global: + enclave_entry; + g_global_data_sim; + g_peak_heap_used; + g_global_data; +local: + *; +}; diff --git a/buildenv.mk b/buildenv.mk new file mode 100644 index 0000000000..6fdda27e47 --- /dev/null +++ b/buildenv.mk @@ -0,0 +1,153 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +# ----------------------------------------------------------------------------- +# Function : parent-dir +# Arguments: 1: path +# Returns : Parent dir or path of $1, with final separator removed. +# ----------------------------------------------------------------------------- +parent-dir = $(patsubst %/,%,$(dir $(1:%/=%))) + +# ----------------------------------------------------------------------------- +# Macro : my-dir +# Returns : the directory of the current Makefile +# Usage : $(my-dir) +# ----------------------------------------------------------------------------- +my-dir = $(realpath $(call parent-dir,$(lastword $(MAKEFILE_LIST)))) + + +ROOT_DIR := $(call my-dir) +COMMON_DIR := $(ROOT_DIR)/common +LINUX_EXTERNAL_DIR := $(ROOT_DIR)/external +LINUX_PSW_DIR := $(ROOT_DIR)/psw +LINUX_SDK_DIR := $(ROOT_DIR)/sdk +LINUX_UNITTESTS := $(ROOT_DIR)/unittests + + +CP := /bin/cp -f +MKDIR := mkdir -p + +# clean the content of 'INCLUDE' - this variable will be set by vcvars32.bat +# thus it will cause build error when this variable is used by our Makefile, +# when compiling the code under Cygwin tainted by MSVC environment settings. +INCLUDE := + +# this will return the path to the file that included the buildenv.mk file +CUR_DIR := $(realpath $(call parent-dir,$(lastword $(wordlist 2,$(words $(MAKEFILE_LIST)),x $(MAKEFILE_LIST))))) + +# turn on stack protector for SDK +COMMON_FLAGS += -fstack-protector + +ifdef DEBUG + COMMON_FLAGS += -ggdb -DDEBUG -UNDEBUG + COMMON_FLAGS += -DSE_DEBUG_LEVEL=SE_TRACE_DEBUG +else + COMMON_FLAGS += -O2 -UDEBUG -DNDEBUG +endif + +ifdef SE_SIM + COMMON_FLAGS += -DSE_SIM +endif + +# turn on compiler warnings as much as possible +COMMON_FLAGS += -Wall -Wextra -Winit-self -Wpointer-arith -Wreturn-type \ + -Waddress -Wsequence-point -Wformat-security \ + -Wmissing-include-dirs -Wfloat-equal -Wundef -Wshadow \ + -Wcast-align -Wconversion -Wredundant-decls + +# additional warnings flags for C +CFLAGS += -Wjump-misses-init -Wstrict-prototypes -Wunsuffixed-float-constants + +# additional warnings flags for C++ +CXXFLAGS += -Wnon-virtual-dtor + +# for static_assert() +CXXFLAGS += -std=c++0x + +.DEFAULT_GOAL := all +# this turns off the RCS / SCCS implicit rules of GNU Make +% : RCS/%,v +% : RCS/% +% : %,v +% : s.% +% : SCCS/s.% + +# If a rule fails, delete $@. +.DELETE_ON_ERROR: + +HOST_FILE_PROGRAM := file + +UNAME := $(shell uname -m) +ifneq (,$(findstring 86,$(UNAME))) + HOST_ARCH := x86 + ifneq (,$(shell $(HOST_FILE_PROGRAM) -L $(SHELL) | grep 'x86[_-]64')) + HOST_ARCH := x86_64 + endif +else + $(info Unknown host CPU arhitecture $(UNAME)) + $(error Aborting) +endif + +BUILD_DIR := $(ROOT_DIR)/build/linux + +ifeq "$(findstring __INTEL_COMPILER, $(shell $(CC) -E -dM -xc /dev/null))" "__INTEL_COMPILER" + ifeq ($(shell test -f /usr/bin/dpkg; echo $$?), 0) + ADDED_INC := -I /usr/include/$(shell dpkg-architecture -qDEB_BUILD_MULTIARCH) + endif +endif + +ARCH := $(HOST_ARCH) +ifeq "$(findstring -m32, $(CXXFLAGS))" "-m32" + ARCH := x86 +endif + +ifeq ($(ARCH), x86) +COMMON_FLAGS += -DITT_ARCH_IA32 +else +COMMON_FLAGS += -DITT_ARCH_IA64 +endif + +CFLAGS += $(COMMON_FLAGS) +CXXFLAGS += $(COMMON_FLAGS) + +# Compiler and linker options for an Enclave +# +# We are using '--export-dynamic' so that `g_global_data_sim' etc. +# will be exported to dynamic symbol table. +# +# When `pie' is enabled, the linker (both BFD and Gold) under Ubuntu 14.04 +# will hide all symbols from dynamic symbol table even if they are marked +# as `global' in the LD version script. +ENCLAVE_CFLAGS = -ffreestanding -nostdinc -fvisibility=hidden -fpie +ENCLAVE_CXXFLAGS = $(ENCLAVE_CFLAGS) -nostdinc++ +ENCLAVE_LDFLAGS = -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 diff --git a/common/inc/internal/ae_ipp.h b/common/inc/internal/ae_ipp.h new file mode 100644 index 0000000000..3fad09cdff --- /dev/null +++ b/common/inc/internal/ae_ipp.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _AE_IPP_H +#define _AE_IPP_H + +#include "ippcore.h" +#include "ippcp.h" + +#endif diff --git a/common/inc/internal/arch.h b/common/inc/internal/arch.h new file mode 100644 index 0000000000..876e2aad50 --- /dev/null +++ b/common/inc/internal/arch.h @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_ARCH_H_ +#define _SE_ARCH_H_ + +#include "inst.h" +#include "se_types.h" +#include "sgx_attributes.h" +#include "sgx_key.h" +#include "sgx_report.h" +#include "sgx_tcrypto.h" + +#define SE_PAGE_SIZE 0x1000 +#define TCS_SIZE SE_PAGE_SIZE + +#pragma pack(push, 1) + +#if !defined(__cplusplus) || defined(__INTEL_COMPILER) || (defined(SE_GNU) && !defined(__GXX_EXPERIMENTAL_CXX0X__)) +#define _ASSERT_CONCAT(a, b) a##b +#define ASSERT_CONCAT(a, b) _ASSERT_CONCAT(a, b) +#define se_static_assert(e) typedef char ASSERT_CONCAT(assert_line, __LINE__)[(e)?1:-1] +#else +#define se_static_assert(e) static_assert(e,#e) +#endif + +se_static_assert(sizeof(sgx_key_request_t) == 512); +se_static_assert(sizeof(sgx_target_info_t) == 512); + +/*SECS data structure*/ +typedef struct _secs_t +{ + uint64_t size; /* ( 0) Size of the enclave in bytes */ + PADDED_POINTER(void, base); /* ( 8) Base address of enclave */ + uint32_t ssa_frame_size; /* ( 16) size of 1 SSA frame in pages */ + sgx_misc_select_t misc_select; /* ( 20) Which fields defined in SSA.MISC */ +#define SECS_RESERVED1_LENGTH 24 + uint8_t reserved1[SECS_RESERVED1_LENGTH]; /* ( 24) reserved */ + sgx_attributes_t attributes; /* ( 48) ATTRIBUTES Flags Field */ + sgx_measurement_t mr_enclave; /* ( 64) Integrity Reg 0 - Enclave measurement */ +#define SECS_RESERVED2_LENGTH 32 + uint8_t reserved2[SECS_RESERVED2_LENGTH]; /* ( 96) reserved */ + sgx_measurement_t mr_signer; /* (128) Integrity Reg 1 - Enclave signing key */ +#define SECS_RESERVED3_LENGTH 96 + uint8_t reserved3[SECS_RESERVED3_LENGTH]; /* (160) reserved */ + sgx_prod_id_t isv_prod_id; /* (256) product ID of enclave */ + sgx_isv_svn_t isv_svn; /* (258) Security Version of the Enclave */ +#define SECS_RESERVED4_LENGTH 3836 + uint8_t reserved4[SECS_RESERVED4_LENGTH];/* (260) reserved */ +} secs_t; + +/* +TCS +flags definitions +*/ +#define DBGOPTIN 1 /* used by debugger */ + +typedef struct _tcs_t +{ + uint64_t reserved0; /* (0) */ + uint64_t flags; /* (8)bit 0: DBGOPTION */ + uint64_t ossa; /* (16)State Save Area */ + uint32_t cssa; /* (24)Current SSA slot */ + uint32_t nssa; /* (28)Number of SSA slots */ + uint64_t oentry; /* (32)Offset in enclave to which control is transferred on EENTER if enclave INACTIVE state */ + uint64_t reserved1; /* (40) */ + uint64_t ofs_base; /* (48)When added to the base address of the enclave, produces the base address FS segment inside the enclave */ + uint64_t ogs_base; /* (56)When added to the base address of the enclave, produces the base address GS segment inside the enclave */ + uint32_t ofs_limit; /* (64)Size to become the new FS limit in 32-bit mode */ + uint32_t ogs_limit; /* (68)Size to become the new GS limit in 32-bit mode */ +#define TCS_RESERVED_LENGTH 4024 + uint8_t reserved[TCS_RESERVED_LENGTH]; /* (72) */ +}tcs_t; + +se_static_assert(sizeof(tcs_t) == SE_PAGE_SIZE); + +/**************************************************************************** + * Definitions for SSA + ****************************************************************************/ +typedef struct _exit_info_t +{ + uint32_t vector:8; /* Exception number of exceptions reported inside enclave */ + uint32_t exit_type:3; /* 3: Hardware exceptions, 6: Software exceptions */ + uint32_t reserved:20; + uint32_t valid:1; /* 0: unsupported exceptions, 1: Supported exceptions */ +} exit_info_t; + +#define SE_VECTOR_DE 0 +#define SE_VECTOR_DB 1 +#define SE_VECTOR_BP 3 +#define SE_VECTOR_BR 5 +#define SE_VECTOR_UD 6 +#define SE_VECTOR_MF 16 +#define SE_VECTOR_AC 17 +#define SE_VECTOR_XM 19 + +typedef struct _ssa_gpr_t +{ + REGISTER( ax); /* (0) */ + REGISTER( cx); /* (8) */ + REGISTER( dx); /* (16) */ + REGISTER( bx); /* (24) */ + REGISTER( sp); /* (32) */ + REGISTER( bp); /* (40) */ + REGISTER( si); /* (48) */ + REGISTER( di); /* (56) */ + uint64_t r8; /* (64) */ + uint64_t r9; /* (72) */ + uint64_t r10; /* (80) */ + uint64_t r11; /* (88) */ + uint64_t r12; /* (96) */ + uint64_t r13; /* (104) */ + uint64_t r14; /* (112) */ + uint64_t r15; /* (120) */ + REGISTER(flags); /* (128) */ + REGISTER( ip); /* (136) */ + REGISTER( sp_u); /* (144) untrusted stack pointer. saved by EENTER */ + REGISTER( bp_u); /* (152) untrusted frame pointer. saved by EENTER */ + exit_info_t exit_info; /* (160) contain information for exits */ + uint32_t reserved; /* (164) padding to multiple of 8 bytes */ + uint64_t fs; /* (168) FS register */ + uint64_t gs; /* (176) GS register */ +} ssa_gpr_t; + +typedef uint64_t si_flags_t; + +#define SI_FLAG_NONE 0x0 +#define SI_FLAG_R 0x1 /* Read Access */ +#define SI_FLAG_W 0x2 /* Write Access */ +#define SI_FLAG_X 0x4 /* Execute Access */ +#define SI_FLAG_PT_LOW_BIT 0x8 /* PT low bit */ +#define SI_FLAG_PT_MASK (0xFF< +#include + +namespace { + template + void delete_ptrs_from_container(T& vec) + { + typename T::iterator iter = vec.begin(); + typename T::iterator end = vec.end(); + typename T::iterator this_iter; + + while (iter != end) + { + this_iter = iter; + ++iter; + delete *this_iter; + } + } + + /* Each pair is well-formed (p.first <= p.second) */ + template + bool is_overlap(const std::pair& p1, + const std::pair& p2) + { + assert(p1.first <= p1.second); + assert(p2.first <= p2.second); + + return ((p1.first <= p2.second) && (p2.first <= p1.second)); + } +} + +#endif diff --git a/common/inc/internal/cpuid.h b/common/inc/internal/cpuid.h new file mode 100644 index 0000000000..b3ee8f5db9 --- /dev/null +++ b/common/inc/internal/cpuid.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _CPUID_H_ +#define _CPUID_H_ + +#include "linux/cpuid_gnu.h" + + +#endif /* _CPUID_H_ */ diff --git a/common/inc/internal/dh.h b/common/inc/internal/dh.h new file mode 100644 index 0000000000..76c347f588 --- /dev/null +++ b/common/inc/internal/dh.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _DH_H +#define _DH_H + +#include "utility.h" + +/*return true if encrypt message successfully */ +bool encrypt_msg(pse_message_t* pse_msg, uint8_t* data, sgx_key_128bit_t* authenticated_encryption_key); + +/*return true if decrypt message successfully */ +bool decrypt_msg(pse_message_t* pse_msg, uint8_t* data, sgx_key_128bit_t* authenticated_encryption_key); +#endif diff --git a/common/inc/internal/driver_api.h b/common/inc/internal/driver_api.h new file mode 100644 index 0000000000..c0e20232e7 --- /dev/null +++ b/common/inc/internal/driver_api.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _DRIVER_API_H_ +#define _DRIVER_API_H_ + +#include "arch.h" +#include "sgx_eid.h" + +/* +@enclave_id identify the unique enclave; +@start_addr is the linear address that driver allocate for app; +*/ +int create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr); +/* +*@attr can be REMOVABLE +*/ +int add_enclave_page(sgx_enclave_id_t enclave_id, void *source, size_t offset, const sec_info_t &secinfo, uint32_t attr); +int init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, token_t *launch); +int destroy_enclave(sgx_enclave_id_t enclave_id); + +#endif diff --git a/common/inc/internal/ecp_interface.h b/common/inc/internal/ecp_interface.h new file mode 100644 index 0000000000..d3b7515cd5 --- /dev/null +++ b/common/inc/internal/ecp_interface.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ECP_INTERFACE_H +#define _ECP_INTERFACE_H + +#include "sgx_ecp_types.h" +#include "sgx_tcrypto.h" + +//Key Derivation Function ID : 0x0001 AES-CMAC Entropy Extraction and Key Expansion +const uint16_t AES_CMAC_KDF_ID = 0x0001; + +sgx_status_t derive_key( + const sgx_ec256_dh_shared_t* shared_key, + const char* label, + uint32_t label_length, + sgx_ec_key_128bit_t* derived_key); + +#ifndef INTERNAL_SGX_ERROR_CODE_CONVERTOR +#define INTERNAL_SGX_ERROR_CODE_CONVERTOR(x) if(x != SGX_ERROR_OUT_OF_MEMORY){x = SGX_ERROR_UNEXPECTED;} +#endif + +#endif + diff --git a/common/inc/internal/elf_util.h b/common/inc/internal/elf_util.h new file mode 100644 index 0000000000..408c42f642 --- /dev/null +++ b/common/inc/internal/elf_util.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _ELF_UTIL_H_ +#define _ELF_UTIL_H_ + +#include "elfheader/elf_common.h" +#include "elfheader/elfstructs.h" + +#ifndef __ELF_NATIVE_CLASS +# if defined(_M_X64) || defined(__x86_64) || defined(__amd64) +# include /* for UINT_MAX */ +# define __ELF_NATIVE_CLASS 64 +# else +# define __ELF_NATIVE_CLASS 32 +# endif +#endif + +#if __ELF_NATIVE_CLASS == 64 +# define Rel Rela + +# define RTS_DT_REL DT_RELA +# define RTS_DT_RELSZ DT_RELASZ +# define RTS_DT_RELENT DT_RELAENT +# else +# define RTS_DT_REL DT_REL +# define RTS_DT_RELSZ DT_RELSZ +# define RTS_DT_RELENT DT_RELENT +#endif + +/* We use this macro to refer to ELF types independent of the native wordsize. + `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */ +#define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type) + +/* We use this macro to refer to ELF macro constants. For example, + `ELFW(R_SYM)' is used in place of `ELF32_R_SYM' or `ELF64_R_SYM'. */ +#define ELFW(type) _ElfW (ELF, __ELF_NATIVE_CLASS, type) + +#define _ElfW(e,w,t) _ElfW_1 (e, w, _##t) +#define _ElfW_1(e,w,t) e##w##t + +/* GNU header uses `JUMP_SLOT' while `JMP_SLOT' in FreeBSD. */ +#define R_X86_64_JUMP_SLOT R_X86_64_JMP_SLOT + +#endif diff --git a/common/inc/internal/elfheader/README.txt b/common/inc/internal/elfheader/README.txt new file mode 100644 index 0000000000..654a5ecadd --- /dev/null +++ b/common/inc/internal/elfheader/README.txt @@ -0,0 +1,59 @@ +Note, the files `elf_common.h' and `elfstructs.h' are from FreeBSD. + git://github.com/freebsd/freebsd.git + +But with slight modifications shown below: + +diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h +index 8f02ef1..7601abb 100644 +--- a/sys/sys/elf_common.h ++++ b/sys/sys/elf_common.h +@@ -30,6 +30,9 @@ + #ifndef _SYS_ELF_COMMON_H_ + #define _SYS_ELF_COMMON_H_ 1 + ++typedef uint32_t u_int32_t; ++typedef uint32_t Elf_Symndx; ++ + /* + * ELF definitions that are independent of architecture or word size. + */ +@@ -117,9 +120,6 @@ typedef struct { + #define ELFOSABI_ARM 97 /* ARM */ + #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +-#define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */ +-#define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */ +- + /* e_ident */ + #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ + (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ +@@ -242,7 +242,6 @@ typedef struct { + #define EM_486 6 /* Intel i486. */ + #define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ + #define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ +-#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */ + + /* Special section indexes. */ + #define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ +@@ -441,6 +440,8 @@ typedef struct { + #define DT_MOVETAB 0x6ffffefe /* move table */ + #define DT_SYMINFO 0x6ffffeff /* syminfo table */ + #define DT_ADDRRNGHI 0x6ffffeff ++#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ ++#define DT_ADDRNUM 11 + + #define DT_VERSYM 0x6ffffff0 /* Address of versym section. */ + #define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ +@@ -505,12 +506,9 @@ typedef struct { + #define STT_FILE 4 /* Source file. */ + #define STT_COMMON 5 /* Uninitialized common block. */ + #define STT_TLS 6 /* TLS object. */ +-#define STT_NUM 7 + #define STT_LOOS 10 /* Reserved range for operating system */ + #define STT_GNU_IFUNC 10 + #define STT_HIOS 12 /* specific semantics. */ +-#define STT_LOPROC 13 /* reserved range for processor */ +-#define STT_HIPROC 15 /* specific semantics. */ + + /* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ + #define STV_DEFAULT 0x0 /* Default visibility (see binding). */ diff --git a/common/inc/internal/elfheader/elf_common.h b/common/inc/internal/elfheader/elf_common.h new file mode 100644 index 0000000000..7601abb189 --- /dev/null +++ b/common/inc/internal/elfheader/elf_common.h @@ -0,0 +1,975 @@ +/*- + * Copyright (c) 2000, 2001, 2008, 2011, David E. O'Brien + * Copyright (c) 1998 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_ELF_COMMON_H_ +#define _SYS_ELF_COMMON_H_ 1 + +typedef uint32_t u_int32_t; +typedef uint32_t Elf_Symndx; + +/* + * ELF definitions that are independent of architecture or word size. + */ + +/* + * Note header. The ".note" section contains an array of notes. Each + * begins with this header, aligned to a word boundary. Immediately + * following the note header is n_namesz bytes of name, padded to the + * next word boundary. Then comes n_descsz bytes of descriptor, again + * padded to a word boundary. The values of n_namesz and n_descsz do + * not include the padding. + */ + +typedef struct { + u_int32_t n_namesz; /* Length of name. */ + u_int32_t n_descsz; /* Length of descriptor. */ + u_int32_t n_type; /* Type of this note. */ +} Elf_Note; + +/* + * The header for GNU-style hash sections. + */ + +typedef struct { + u_int32_t gh_nbuckets; /* Number of hash buckets. */ + u_int32_t gh_symndx; /* First visible symbol in .dynsym. */ + u_int32_t gh_maskwords; /* #maskwords used in bloom filter. */ + u_int32_t gh_shift2; /* Bloom filter shift count. */ +} Elf_GNU_Hash_Header; + +/* Indexes into the e_ident array. Keep synced with + http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ +#define EI_MAG0 0 /* Magic number, byte 0. */ +#define EI_MAG1 1 /* Magic number, byte 1. */ +#define EI_MAG2 2 /* Magic number, byte 2. */ +#define EI_MAG3 3 /* Magic number, byte 3. */ +#define EI_CLASS 4 /* Class of machine. */ +#define EI_DATA 5 /* Data format. */ +#define EI_VERSION 6 /* ELF format version. */ +#define EI_OSABI 7 /* Operating system / ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define OLD_EI_BRAND 8 /* Start of architecture identification. */ +#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ +#define EI_NIDENT 16 /* Size of e_ident array. */ + +/* Values for the magic number bytes. */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" /* magic string */ +#define SELFMAG 4 /* magic string size */ + +/* Values for e_ident[EI_VERSION] and e_version. */ +#define EV_NONE 0 +#define EV_CURRENT 1 + +/* Values for e_ident[EI_CLASS]. */ +#define ELFCLASSNONE 0 /* Unknown class. */ +#define ELFCLASS32 1 /* 32-bit architecture. */ +#define ELFCLASS64 2 /* 64-bit architecture. */ + +/* Values for e_ident[EI_DATA]. */ +#define ELFDATANONE 0 /* Unknown data format. */ +#define ELFDATA2LSB 1 /* 2's complement little-endian. */ +#define ELFDATA2MSB 2 /* 2's complement big-endian. */ + +/* Values for e_ident[EI_OSABI]. */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_LINUX 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_AIX 7 /* AIX */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* Open VMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +/* e_ident */ +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ + (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ + (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ + (ehdr).e_ident[EI_MAG3] == ELFMAG3) + +/* Values for e_type. */ +#define ET_NONE 0 /* Unknown type. */ +#define ET_REL 1 /* Relocatable. */ +#define ET_EXEC 2 /* Executable. */ +#define ET_DYN 3 /* Shared object. */ +#define ET_CORE 4 /* Core file. */ +#define ET_LOOS 0xfe00 /* First operating system specific. */ +#define ET_HIOS 0xfeff /* Last operating system-specific. */ +#define ET_LOPROC 0xff00 /* First processor-specific. */ +#define ET_HIPROC 0xffff /* Last processor-specific. */ + +/* Values for e_machine. */ +#define EM_NONE 0 /* Unknown machine. */ +#define EM_M32 1 /* AT&T WE32100. */ +#define EM_SPARC 2 /* Sun SPARC. */ +#define EM_386 3 /* Intel i386. */ +#define EM_68K 4 /* Motorola 68000. */ +#define EM_88K 5 /* Motorola 88000. */ +#define EM_860 7 /* Intel i860. */ +#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ +#define EM_S370 9 /* IBM System/370. */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ +#define EM_PARISC 15 /* HP PA-RISC. */ +#define EM_VPP500 17 /* Fujitsu VPP500. */ +#define EM_SPARC32PLUS 18 /* SPARC v8plus. */ +#define EM_960 19 /* Intel 80960. */ +#define EM_PPC 20 /* PowerPC 32-bit. */ +#define EM_PPC64 21 /* PowerPC 64-bit. */ +#define EM_S390 22 /* IBM System/390. */ +#define EM_V800 36 /* NEC V800. */ +#define EM_FR20 37 /* Fujitsu FR20. */ +#define EM_RH32 38 /* TRW RH-32. */ +#define EM_RCE 39 /* Motorola RCE. */ +#define EM_ARM 40 /* ARM. */ +#define EM_SH 42 /* Hitachi SH. */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit. */ +#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ +#define EM_ARC 45 /* Argonaut RISC Core. */ +#define EM_H8_300 46 /* Hitachi H8/300. */ +#define EM_H8_300H 47 /* Hitachi H8/300H. */ +#define EM_H8S 48 /* Hitachi H8S. */ +#define EM_H8_500 49 /* Hitachi H8/500. */ +#define EM_IA_64 50 /* Intel IA-64 Processor. */ +#define EM_MIPS_X 51 /* Stanford MIPS-X. */ +#define EM_COLDFIRE 52 /* Motorola ColdFire. */ +#define EM_68HC12 53 /* Motorola M68HC12. */ +#define EM_MMA 54 /* Fujitsu MMA. */ +#define EM_PCP 55 /* Siemens PCP. */ +#define EM_NCPU 56 /* Sony nCPU. */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor. */ +#define EM_STARCORE 58 /* Motorola Star*Core processor. */ +#define EM_ME16 59 /* Toyota ME16 processor. */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor. */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ +#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ +#define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */ +#define EM_PDSP 63 /* Sony DSP Processor. */ +#define EM_FX66 66 /* Siemens FX66 microcontroller. */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 + microcontroller. */ +#define EM_ST7 68 /* STmicroelectronics ST7 8-bit + microcontroller. */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller. */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller. */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller. */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller. */ +#define EM_SVX 73 /* Silicon Graphics SVx. */ +#define EM_ST19 74 /* STMicroelectronics ST19 8-bit mc. */ +#define EM_VAX 75 /* Digital VAX. */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded + processor. */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded + processor. */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor. */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor. */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc. */ +#define EM_HUANY 81 /* Harvard University machine-independent + object files. */ +#define EM_PRISM 82 /* SiTera Prism. */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller. */ +#define EM_FR30 84 /* Fujitsu FR30. */ +#define EM_D10V 85 /* Mitsubishi D10V. */ +#define EM_D30V 86 /* Mitsubishi D30V. */ +#define EM_V850 87 /* NEC v850. */ +#define EM_M32R 88 /* Mitsubishi M32R. */ +#define EM_MN10300 89 /* Matsushita MN10300. */ +#define EM_MN10200 90 /* Matsushita MN10200. */ +#define EM_PJ 91 /* picoJava. */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor. */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5. */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture. */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor. */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose + Processor. */ +#define EM_NS32K 97 /* National Semiconductor 32000 series. */ +#define EM_TPC 98 /* Tenor Network TPC processor. */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor. */ +#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller. */ +#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family. */ +#define EM_MAX 102 /* MAX Processor. */ +#define EM_CR 103 /* National Semiconductor CompactRISC + microprocessor. */ +#define EM_F2MC16 104 /* Fujitsu F2MC16. */ +#define EM_MSP430 105 /* Texas Instruments embedded microcontroller + msp430. */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor. */ +#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors. */ +#define EM_SEP 108 /* Sharp embedded microprocessor. */ +#define EM_ARCA 109 /* Arca RISC Microprocessor. */ +#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. + and MPRC of Peking University */ + +/* Non-standard or deprecated. */ +#define EM_486 6 /* Intel i486. */ +#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ +#define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ + +/* Special section indexes. */ +#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ +#define SHN_LORESERVE 0xff00 /* First of reserved range. */ +#define SHN_LOPROC 0xff00 /* First processor-specific. */ +#define SHN_HIPROC 0xff1f /* Last processor-specific. */ +#define SHN_LOOS 0xff20 /* First operating system-specific. */ +#define SHN_HIOS 0xff3f /* Last operating system-specific. */ +#define SHN_ABS 0xfff1 /* Absolute values. */ +#define SHN_COMMON 0xfff2 /* Common data. */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ +#define SHN_HIRESERVE 0xffff /* Last of reserved range. */ + +/* sh_type */ +#define SHT_NULL 0 /* inactive */ +#define SHT_PROGBITS 1 /* program defined information */ +#define SHT_SYMTAB 2 /* symbol table section */ +#define SHT_STRTAB 3 /* string table section */ +#define SHT_RELA 4 /* relocation section with addends */ +#define SHT_HASH 5 /* symbol hash table section */ +#define SHT_DYNAMIC 6 /* dynamic section */ +#define SHT_NOTE 7 /* note section */ +#define SHT_NOBITS 8 /* no space section */ +#define SHT_REL 9 /* relocation section - no addends */ +#define SHT_SHLIB 10 /* reserved - purpose unknown */ +#define SHT_DYNSYM 11 /* dynamic symbol table section */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers. */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers. */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */ +#define SHT_GROUP 17 /* Section group. */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ +#define SHT_LOOS 0x60000000 /* First of OS specific semantics */ +#define SHT_LOSUNW 0x6ffffff4 +#define SHT_SUNW_dof 0x6ffffff4 +#define SHT_SUNW_cap 0x6ffffff5 +#define SHT_SUNW_SIGNATURE 0x6ffffff6 +#define SHT_GNU_HASH 0x6ffffff6 +#define SHT_SUNW_ANNOTATE 0x6ffffff7 +#define SHT_SUNW_DEBUGSTR 0x6ffffff8 +#define SHT_SUNW_DEBUG 0x6ffffff9 +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd +#define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */ +#define SHT_SUNW_verneed 0x6ffffffe +#define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */ +#define SHT_SUNW_versym 0x6fffffff +#define SHT_GNU_versym 0x6fffffff /* Symbol version table */ +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ +#define SHT_LOPROC 0x70000000 /* reserved range for processor */ +#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_MIPS_REGINFO 0x70000006 +#define SHT_MIPS_OPTIONS 0x7000000d +#define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ +#define SHT_HIPROC 0x7fffffff /* specific section header types */ +#define SHT_LOUSER 0x80000000 /* reserved range for application */ +#define SHT_HIUSER 0xffffffff /* specific indexes */ + +/* Flags for sh_flags. */ +#define SHF_WRITE 0x1 /* Section contains writable data. */ +#define SHF_ALLOC 0x2 /* Section occupies memory. */ +#define SHF_EXECINSTR 0x4 /* Section contains instructions. */ +#define SHF_MERGE 0x10 /* Section may be merged. */ +#define SHF_STRINGS 0x20 /* Section contains strings. */ +#define SHF_INFO_LINK 0x40 /* sh_info holds section index. */ +#define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */ +#define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ +#define SHF_GROUP 0x200 /* Member of section group. */ +#define SHF_TLS 0x400 /* Section contains TLS data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ + +/* Values for p_type. */ +#define PT_NULL 0 /* Unused entry. */ +#define PT_LOAD 1 /* Loadable segment. */ +#define PT_DYNAMIC 2 /* Dynamic linking information segment. */ +#define PT_INTERP 3 /* Pathname of interpreter. */ +#define PT_NOTE 4 /* Auxiliary information. */ +#define PT_SHLIB 5 /* Reserved (not used). */ +#define PT_PHDR 6 /* Location of program header itself. */ +#define PT_TLS 7 /* Thread local storage segment */ +#define PT_LOOS 0x60000000 /* First OS-specific. */ +#define PT_SUNW_UNWIND 0x6464e550 /* amd64 UNWIND program header */ +#define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_STACK 0x6474e551 +#define PT_GNU_RELRO 0x6474e552 +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ +#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ +#define PT_SUNWDTRACE 0x6ffffffc /* private */ +#define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff /* Last OS-specific. */ +#define PT_LOPROC 0x70000000 /* First processor-specific type. */ +#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for p_flags. */ +#define PF_X 0x1 /* Executable. */ +#define PF_W 0x2 /* Writable. */ +#define PF_R 0x4 /* Readable. */ +#define PF_MASKOS 0x0ff00000 /* Operating system-specific. */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific. */ + +/* Extended program header index. */ +#define PN_XNUM 0xffff + +/* Values for d_tag. */ +#define DT_NULL 0 /* Terminating entry. */ +#define DT_NEEDED 1 /* String table offset of a needed shared + library. */ +#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ +#define DT_PLTGOT 3 /* Processor-dependent address. */ +#define DT_HASH 4 /* Address of symbol hash table. */ +#define DT_STRTAB 5 /* Address of string table. */ +#define DT_SYMTAB 6 /* Address of symbol table. */ +#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ +#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ +#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ +#define DT_STRSZ 10 /* Size of string table. */ +#define DT_SYMENT 11 /* Size of each symbol table entry. */ +#define DT_INIT 12 /* Address of initialization function. */ +#define DT_FINI 13 /* Address of finalization function. */ +#define DT_SONAME 14 /* String table offset of shared object + name. */ +#define DT_RPATH 15 /* String table offset of library path. [sup] */ +#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ +#define DT_REL 17 /* Address of ElfNN_Rel relocations. */ +#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ +#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ +#define DT_PLTREL 20 /* Type of relocation used for PLT. */ +#define DT_DEBUG 21 /* Reserved (not used). */ +#define DT_TEXTREL 22 /* Indicates there may be relocations in + non-writable segments. [sup] */ +#define DT_JMPREL 23 /* Address of PLT relocations. */ +#define DT_BIND_NOW 24 /* [sup] */ +#define DT_INIT_ARRAY 25 /* Address of the array of pointers to + initialization functions */ +#define DT_FINI_ARRAY 26 /* Address of the array of pointers to + termination functions */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of + initialization functions. */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of + termination functions. */ +#define DT_RUNPATH 29 /* String table offset of a null-terminated + library search path string. */ +#define DT_FLAGS 30 /* Object specific flag values. */ +#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING + and less than DT_LOOS follow the rules for + the interpretation of the d_un union + as follows: even == 'd_ptr', odd == 'd_val' + or none */ +#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to + pre-initialization functions. */ +#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of + pre-initialization functions. */ +#define DT_MAXPOSTAGS 34 /* number of positive tags */ +#define DT_LOOS 0x6000000d /* First OS-specific */ +#define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ +#define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ +#define DT_SUNW_FILTER 0x6000000f /* symbol filter name */ +#define DT_SUNW_CAP 0x60000010 /* hardware/software */ +#define DT_HIOS 0x6ffff000 /* Last OS-specific */ + +/* + * DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + * Dyn.d_un.d_val field of the Elf*_Dyn structure. + */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */ +#define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */ +#define DT_MOVEENT 0x6ffffdfa /* move table entry size */ +#define DT_MOVESZ 0x6ffffdfb /* move table size */ +#define DT_FEATURE_1 0x6ffffdfc /* feature holder */ +#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */ + /* the following DT_* entry. */ + /* See DF_P1_* definitions */ +#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */ +#define DT_VALRNGHI 0x6ffffdff + +/* + * DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + * + * If any adjustment is made to the ELF object after it has been + * built, these entries will need to be adjusted. + */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ +#define DT_CONFIG 0x6ffffefa /* configuration information */ +#define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */ +#define DT_AUDIT 0x6ffffefc /* object auditing */ +#define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */ +#define DT_MOVETAB 0x6ffffefe /* move table */ +#define DT_SYMINFO 0x6ffffeff /* syminfo table */ +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ +#define DT_ADDRNUM 11 + +#define DT_VERSYM 0x6ffffff0 /* Address of versym section. */ +#define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ +#define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */ +#define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */ +#define DT_VERDEF 0x6ffffffc /* Address of verdef section. */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of elems in verdef section */ +#define DT_VERNEED 0x6ffffffe /* Address of verneed section. */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */ + +#define DT_LOPROC 0x70000000 /* First processor-specific type. */ +#define DT_DEPRECATED_SPARC_REGISTER 0x7000001 +#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */ +#define DT_USED 0x7ffffffe /* ignored - same as needed */ +#define DT_FILTER 0x7fffffff /* shared library filter name */ +#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for DT_FLAGS */ +#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may + make reference to the $ORIGIN substitution + string */ +#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ +#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in + non-writable segments. */ +#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should + process all relocations for the object + containing this entry before transferring + control to the program. */ +#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or + executable contains code using a static + thread-local storage scheme. */ + +/* Values for DT_FLAGS_1 */ +#define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ +#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */ +#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ +#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */ +#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ +#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */ +#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */ + +/* Values for n_type. Used in core files. */ +#define NT_PRSTATUS 1 /* Process status. */ +#define NT_FPREGSET 2 /* Floating point registers. */ +#define NT_PRPSINFO 3 /* Process state info. */ +#define NT_THRMISC 7 /* Thread miscellaneous info. */ + +/* Symbol Binding - ELFNN_ST_BIND - st_info */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* like global - lower precedence */ +#define STB_LOOS 10 /* Reserved range for operating system */ +#define STB_HIOS 12 /* specific semantics. */ +#define STB_LOPROC 13 /* reserved range for processor */ +#define STB_HIPROC 15 /* specific semantics. */ + +/* Symbol type - ELFNN_ST_TYPE - st_info */ +#define STT_NOTYPE 0 /* Unspecified type. */ +#define STT_OBJECT 1 /* Data object. */ +#define STT_FUNC 2 /* Function. */ +#define STT_SECTION 3 /* Section. */ +#define STT_FILE 4 /* Source file. */ +#define STT_COMMON 5 /* Uninitialized common block. */ +#define STT_TLS 6 /* TLS object. */ +#define STT_LOOS 10 /* Reserved range for operating system */ +#define STT_GNU_IFUNC 10 +#define STT_HIOS 12 /* specific semantics. */ + +/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ +#define STV_DEFAULT 0x0 /* Default visibility (see binding). */ +#define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */ +#define STV_HIDDEN 0x2 /* Not visible. */ +#define STV_PROTECTED 0x3 /* Visible but not preemptible. */ +#define STV_EXPORTED 0x4 +#define STV_SINGLETON 0x5 +#define STV_ELIMINATE 0x6 + +/* Special symbol table indexes. */ +#define STN_UNDEF 0 /* Undefined symbol index. */ + +/* Symbol versioning flags. */ +#define VER_DEF_CURRENT 1 +#define VER_DEF_IDX(x) VER_NDX(x) + +#define VER_FLG_BASE 0x01 +#define VER_FLG_WEAK 0x02 + +#define VER_NEED_CURRENT 1 +#define VER_NEED_WEAK (1u << 15) +#define VER_NEED_HIDDEN VER_NDX_HIDDEN +#define VER_NEED_IDX(x) VER_NDX(x) + +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_GIVEN 2 + +#define VER_NDX_HIDDEN (1u << 15) +#define VER_NDX(x) ((x) & ~(1u << 15)) + +#define CA_SUNW_NULL 0 +#define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ +#define CA_SUNW_SF_1 2 /* first software capabilities entry */ + +/* + * Syminfo flag values + */ +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */ + /* to object containing defn. */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */ + /* lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */ + /* object containing defn. */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */ + /* directly bind to this symbol */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ + +/* + * Syminfo.si_boundto values. + */ +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +/* + * Syminfo version values. + */ +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +/* + * Relocation types. + * + * All machine architectures are defined here to allow tools on one to + * handle others. + */ + +#define R_386_NONE 0 /* No relocation. */ +#define R_386_32 1 /* Add symbol value. */ +#define R_386_PC32 2 /* Add PC-relative symbol value. */ +#define R_386_GOT32 3 /* Add PC-relative GOT offset. */ +#define R_386_PLT32 4 /* Add PC-relative PLT offset. */ +#define R_386_COPY 5 /* Copy data from shared object. */ +#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ +#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ +#define R_386_RELATIVE 8 /* Add load address of shared object. */ +#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ +#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ +#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */ +#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */ +#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */ +#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */ +#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */ +#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */ +#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */ +#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */ +#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */ +#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */ +#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */ +#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */ +#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */ +#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */ +#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */ +#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */ +#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */ +#define R_386_IRELATIVE 42 /* PLT entry resolved indirectly at runtime */ + +#define R_ARM_NONE 0 /* No relocation. */ +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +/* TLS relocations */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ +#define R_ARM_COPY 20 /* Copy data from shared object. */ +#define R_ARM_GLOB_DAT 21 /* Set GOT entry to data address. */ +#define R_ARM_JUMP_SLOT 22 /* Set GOT entry to code address. */ +#define R_ARM_RELATIVE 23 /* Add load address of shared object. */ +#define R_ARM_GOTOFF 24 /* Add GOT-relative symbol address. */ +#define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */ +#define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */ +#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +/* Name Value Field Calculation */ +#define R_IA_64_NONE 0 /* None */ +#define R_IA_64_IMM14 0x21 /* immediate14 S + A */ +#define R_IA_64_IMM22 0x22 /* immediate22 S + A */ +#define R_IA_64_IMM64 0x23 /* immediate64 S + A */ +#define R_IA_64_DIR32MSB 0x24 /* word32 MSB S + A */ +#define R_IA_64_DIR32LSB 0x25 /* word32 LSB S + A */ +#define R_IA_64_DIR64MSB 0x26 /* word64 MSB S + A */ +#define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */ +#define R_IA_64_GPREL22 0x2a /* immediate22 @gprel(S + A) */ +#define R_IA_64_GPREL64I 0x2b /* immediate64 @gprel(S + A) */ +#define R_IA_64_GPREL32MSB 0x2c /* word32 MSB @gprel(S + A) */ +#define R_IA_64_GPREL32LSB 0x2d /* word32 LSB @gprel(S + A) */ +#define R_IA_64_GPREL64MSB 0x2e /* word64 MSB @gprel(S + A) */ +#define R_IA_64_GPREL64LSB 0x2f /* word64 LSB @gprel(S + A) */ +#define R_IA_64_LTOFF22 0x32 /* immediate22 @ltoff(S + A) */ +#define R_IA_64_LTOFF64I 0x33 /* immediate64 @ltoff(S + A) */ +#define R_IA_64_PLTOFF22 0x3a /* immediate22 @pltoff(S + A) */ +#define R_IA_64_PLTOFF64I 0x3b /* immediate64 @pltoff(S + A) */ +#define R_IA_64_PLTOFF64MSB 0x3e /* word64 MSB @pltoff(S + A) */ +#define R_IA_64_PLTOFF64LSB 0x3f /* word64 LSB @pltoff(S + A) */ +#define R_IA_64_FPTR64I 0x43 /* immediate64 @fptr(S + A) */ +#define R_IA_64_FPTR32MSB 0x44 /* word32 MSB @fptr(S + A) */ +#define R_IA_64_FPTR32LSB 0x45 /* word32 LSB @fptr(S + A) */ +#define R_IA_64_FPTR64MSB 0x46 /* word64 MSB @fptr(S + A) */ +#define R_IA_64_FPTR64LSB 0x47 /* word64 LSB @fptr(S + A) */ +#define R_IA_64_PCREL60B 0x48 /* immediate60 form1 S + A - P */ +#define R_IA_64_PCREL21B 0x49 /* immediate21 form1 S + A - P */ +#define R_IA_64_PCREL21M 0x4a /* immediate21 form2 S + A - P */ +#define R_IA_64_PCREL21F 0x4b /* immediate21 form3 S + A - P */ +#define R_IA_64_PCREL32MSB 0x4c /* word32 MSB S + A - P */ +#define R_IA_64_PCREL32LSB 0x4d /* word32 LSB S + A - P */ +#define R_IA_64_PCREL64MSB 0x4e /* word64 MSB S + A - P */ +#define R_IA_64_PCREL64LSB 0x4f /* word64 LSB S + A - P */ +#define R_IA_64_LTOFF_FPTR22 0x52 /* immediate22 @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64I 0x53 /* immediate64 @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR32MSB 0x54 /* word32 MSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR32LSB 0x55 /* word32 LSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64MSB 0x56 /* word64 MSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64LSB 0x57 /* word64 LSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_SEGREL32MSB 0x5c /* word32 MSB @segrel(S + A) */ +#define R_IA_64_SEGREL32LSB 0x5d /* word32 LSB @segrel(S + A) */ +#define R_IA_64_SEGREL64MSB 0x5e /* word64 MSB @segrel(S + A) */ +#define R_IA_64_SEGREL64LSB 0x5f /* word64 LSB @segrel(S + A) */ +#define R_IA_64_SECREL32MSB 0x64 /* word32 MSB @secrel(S + A) */ +#define R_IA_64_SECREL32LSB 0x65 /* word32 LSB @secrel(S + A) */ +#define R_IA_64_SECREL64MSB 0x66 /* word64 MSB @secrel(S + A) */ +#define R_IA_64_SECREL64LSB 0x67 /* word64 LSB @secrel(S + A) */ +#define R_IA_64_REL32MSB 0x6c /* word32 MSB BD + A */ +#define R_IA_64_REL32LSB 0x6d /* word32 LSB BD + A */ +#define R_IA_64_REL64MSB 0x6e /* word64 MSB BD + A */ +#define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */ +#define R_IA_64_LTV32MSB 0x74 /* word32 MSB S + A */ +#define R_IA_64_LTV32LSB 0x75 /* word32 LSB S + A */ +#define R_IA_64_LTV64MSB 0x76 /* word64 MSB S + A */ +#define R_IA_64_LTV64LSB 0x77 /* word64 LSB S + A */ +#define R_IA_64_PCREL21BI 0x79 /* immediate21 form1 S + A - P */ +#define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */ +#define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */ +#define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */ +#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */ +#define R_IA_64_SUB 0x85 /* immediate64 A - S */ +#define R_IA_64_LTOFF22X 0x86 /* immediate22 special */ +#define R_IA_64_LDXMOV 0x87 /* immediate22 special */ +#define R_IA_64_TPREL14 0x91 /* imm14 @tprel(S + A) */ +#define R_IA_64_TPREL22 0x92 /* imm22 @tprel(S + A) */ +#define R_IA_64_TPREL64I 0x93 /* imm64 @tprel(S + A) */ +#define R_IA_64_TPREL64MSB 0x96 /* word64 MSB @tprel(S + A) */ +#define R_IA_64_TPREL64LSB 0x97 /* word64 LSB @tprel(S + A) */ +#define R_IA_64_LTOFF_TPREL22 0x9a /* imm22 @ltoff(@tprel(S+A)) */ +#define R_IA_64_DTPMOD64MSB 0xa6 /* word64 MSB @dtpmod(S + A) */ +#define R_IA_64_DTPMOD64LSB 0xa7 /* word64 LSB @dtpmod(S + A) */ +#define R_IA_64_LTOFF_DTPMOD22 0xaa /* imm22 @ltoff(@dtpmod(S+A)) */ +#define R_IA_64_DTPREL14 0xb1 /* imm14 @dtprel(S + A) */ +#define R_IA_64_DTPREL22 0xb2 /* imm22 @dtprel(S + A) */ +#define R_IA_64_DTPREL64I 0xb3 /* imm64 @dtprel(S + A) */ +#define R_IA_64_DTPREL32MSB 0xb4 /* word32 MSB @dtprel(S + A) */ +#define R_IA_64_DTPREL32LSB 0xb5 /* word32 LSB @dtprel(S + A) */ +#define R_IA_64_DTPREL64MSB 0xb6 /* word64 MSB @dtprel(S + A) */ +#define R_IA_64_DTPREL64LSB 0xb7 /* word64 LSB @dtprel(S + A) */ +#define R_IA_64_LTOFF_DTPREL22 0xba /* imm22 @ltoff(@dtprel(S+A)) */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ +#define R_MIPS_GOTHI16 21 /* GOT HI 16 bit */ +#define R_MIPS_GOTLO16 22 /* GOT LO 16 bit */ +#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ +#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ + +#define R_PPC_NONE 0 /* No relocation. */ +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + +/* + * 64-bit relocations + */ +#define R_PPC64_ADDR64 38 +#define R_PPC64_ADDR16_HIGHER 39 +#define R_PPC64_ADDR16_HIGHERA 40 +#define R_PPC64_ADDR16_HIGHEST 41 +#define R_PPC64_ADDR16_HIGHESTA 42 +#define R_PPC64_UADDR64 43 +#define R_PPC64_REL64 44 +#define R_PPC64_PLT64 45 +#define R_PPC64_PLTREL64 46 +#define R_PPC64_TOC16 47 +#define R_PPC64_TOC16_LO 48 +#define R_PPC64_TOC16_HI 49 +#define R_PPC64_TOC16_HA 50 +#define R_PPC64_TOC 51 +#define R_PPC64_DTPMOD64 68 +#define R_PPC64_TPREL64 73 +#define R_PPC64_DTPREL64 78 + +/* + * TLS relocations + */ +#define R_PPC_TLS 67 +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 + +/* + * The remaining relocs are from the Embedded ELF ABI, and are not in the + * SVR4 ELF ABI. + */ + +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_X86_64_NONE 0 /* No relocation. */ +#define R_X86_64_64 1 /* Add 64 bit symbol value. */ +#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */ +#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */ +#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */ +#define R_X86_64_COPY 5 /* Copy data from shared object. */ +#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */ +#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */ +#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */ +#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */ +#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */ +#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */ +#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */ +#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */ +#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */ +#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */ +#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ +#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */ +#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */ +#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */ +#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */ +#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ +#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */ +#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */ +#define R_X86_64_IRELATIVE 37 + + +#endif /* !_SYS_ELF_COMMON_H_ */ diff --git a/common/inc/internal/elfheader/elfstructs.h b/common/inc/internal/elfheader/elfstructs.h new file mode 100644 index 0000000000..77362f3b9e --- /dev/null +++ b/common/inc/internal/elfheader/elfstructs.h @@ -0,0 +1,527 @@ +#ifndef __XEN_PUBLIC_ELFSTRUCTS_H__ +#define __XEN_PUBLIC_ELFSTRUCTS_H__ 1 +/* + * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +typedef uint8_t Elf_Byte; + +typedef uint32_t Elf32_Addr; /* Unsigned program address */ +typedef uint32_t Elf32_Off; /* Unsigned file offset */ +typedef int32_t Elf32_Sword; /* Signed large integer */ +typedef uint32_t Elf32_Word; /* Unsigned large integer */ +typedef uint16_t Elf32_Half; /* Unsigned medium integer */ + +typedef uint64_t Elf64_Addr; +typedef uint64_t Elf64_Off; +typedef int32_t Elf64_Shalf; + +typedef int32_t Elf64_Sword; +typedef uint32_t Elf64_Word; + +typedef int64_t Elf64_Sxword; +typedef uint64_t Elf64_Xword; + +typedef uint32_t Elf64_Half; +typedef uint16_t Elf64_Quarter; + +/* + * e_ident[] identification indexes + * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html + */ +#define EI_MAG0 0 /* file ID */ +#define EI_MAG1 1 /* file ID */ +#define EI_MAG2 2 /* file ID */ +#define EI_MAG3 3 /* file ID */ +#define EI_CLASS 4 /* file class */ +#define EI_DATA 5 /* data encoding */ +#define EI_VERSION 6 /* ELF header version */ +#define EI_OSABI 7 /* OS/ABI ID */ +#define EI_ABIVERSION 8 /* ABI version */ +#define EI_PAD 9 /* start of pad bytes */ +#define EI_NIDENT 16 /* Size of e_ident[] */ + +/* e_ident[] magic number */ +#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */ +#define ELFMAG1 'E' /* e_ident[EI_MAG1] */ +#define ELFMAG2 'L' /* e_ident[EI_MAG2] */ +#define ELFMAG3 'F' /* e_ident[EI_MAG3] */ +#define ELFMAG "\177ELF" /* magic */ +#define SELFMAG 4 /* size of magic */ + +/* e_ident[] file class */ +#define ELFCLASSNONE 0 /* invalid */ +#define ELFCLASS32 1 /* 32-bit objs */ +#define ELFCLASS64 2 /* 64-bit objs */ +#define ELFCLASSNUM 3 /* number of classes */ + +/* e_ident[] data encoding */ +#define ELFDATANONE 0 /* invalid */ +#define ELFDATA2LSB 1 /* Little-Endian */ +#define ELFDATA2MSB 2 /* Big-Endian */ +#define ELFDATANUM 3 /* number of data encode defines */ + +/* e_ident[] Operating System/ABI */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_LINUX 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_MONTEREY 7 /* Monterey */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +/* e_ident */ +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ + (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ + (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ + (ehdr).e_ident[EI_MAG3] == ELFMAG3) + +/* ELF Header */ +typedef struct elfhdr { + unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ + Elf32_Half e_type; /* object file type */ + Elf32_Half e_machine; /* machine */ + Elf32_Word e_version; /* object file version */ + Elf32_Addr e_entry; /* virtual entry point */ + Elf32_Off e_phoff; /* program header table offset */ + Elf32_Off e_shoff; /* section header table offset */ + Elf32_Word e_flags; /* processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size */ + Elf32_Half e_phentsize; /* program header entry size */ + Elf32_Half e_phnum; /* number of program header entries */ + Elf32_Half e_shentsize; /* section header entry size */ + Elf32_Half e_shnum; /* number of section header entries */ + Elf32_Half e_shstrndx; /* section header table's "section + header string table" entry offset */ +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* Id bytes */ + Elf64_Quarter e_type; /* file type */ + Elf64_Quarter e_machine; /* machine type */ + Elf64_Half e_version; /* version number */ + Elf64_Addr e_entry; /* entry point */ + Elf64_Off e_phoff; /* Program hdr offset */ + Elf64_Off e_shoff; /* Section hdr offset */ + Elf64_Half e_flags; /* Processor flags */ + Elf64_Quarter e_ehsize; /* sizeof ehdr */ + Elf64_Quarter e_phentsize; /* Program header entry size */ + Elf64_Quarter e_phnum; /* Number of program headers */ + Elf64_Quarter e_shentsize; /* Section header entry size */ + Elf64_Quarter e_shnum; /* Number of section headers */ + Elf64_Quarter e_shstrndx; /* String table index */ +} Elf64_Ehdr; + +/* e_type */ +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* relocatable file */ +#define ET_EXEC 2 /* executable file */ +#define ET_DYN 3 /* shared object file */ +#define ET_CORE 4 /* core file */ +#define ET_NUM 5 /* number of types */ +#define ET_LOPROC 0xff00 /* reserved range for processor */ +#define ET_HIPROC 0xffff /* specific e_type */ + +/* e_machine */ +#define EM_NONE 0 /* No Machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 - unused? */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */ +/* + * Don't know if EM_MIPS_RS4_BE, + * EM_SPARC64, EM_PARISC, + * or EM_PPC are ABI compliant + */ +#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ +#define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */ +#define EM_PARISC 15 /* HPPA */ +#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* PowerPC 64-bit */ +#define EM_ARM 40 /* Advanced RISC Machines ARM */ +#define EM_ALPHA 41 /* DEC ALPHA */ +#define EM_SPARCV9 43 /* SPARC version 9 */ +#define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */ +#define EM_IA_64 50 /* Intel Merced */ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_VAX 75 /* DEC VAX */ + +/* Version */ +#define EV_NONE 0 /* Invalid */ +#define EV_CURRENT 1 /* Current */ +#define EV_NUM 2 /* number of versions */ + +/* Section Header */ +typedef struct { + Elf32_Word sh_name; /* name - index into section header + string table section */ + Elf32_Word sh_type; /* type */ + Elf32_Word sh_flags; /* flags */ + Elf32_Addr sh_addr; /* address */ + Elf32_Off sh_offset; /* file offset */ + Elf32_Word sh_size; /* section size */ + Elf32_Word sh_link; /* section header table index link */ + Elf32_Word sh_info; /* extra information */ + Elf32_Word sh_addralign; /* address alignment */ + Elf32_Word sh_entsize; /* section entry size */ +} Elf32_Shdr; + +typedef struct { + Elf64_Half sh_name; /* section name */ + Elf64_Half sh_type; /* section type */ + Elf64_Xword sh_flags; /* section flags */ + Elf64_Addr sh_addr; /* virtual address */ + Elf64_Off sh_offset; /* file offset */ + Elf64_Xword sh_size; /* section size */ + Elf64_Half sh_link; /* link to another */ + Elf64_Half sh_info; /* misc info */ + Elf64_Xword sh_addralign; /* memory alignment */ + Elf64_Xword sh_entsize; /* table entry size */ +} Elf64_Shdr; + +/* Special Section Indexes */ +#define SHN_UNDEF 0 /* undefined */ +#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ +#define SHN_LOPROC 0xff00 /* reserved range for processor */ +#define SHN_HIPROC 0xff1f /* specific section indexes */ +#define SHN_ABS 0xfff1 /* absolute value */ +#define SHN_COMMON 0xfff2 /* common symbol */ +#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ + +/* sh_type */ +#define SHT_NULL 0 /* inactive */ +#define SHT_PROGBITS 1 /* program defined information */ +#define SHT_SYMTAB 2 /* symbol table section */ +#define SHT_STRTAB 3 /* string table section */ +#define SHT_RELA 4 /* relocation section with addends*/ +#define SHT_HASH 5 /* symbol hash table section */ +#define SHT_DYNAMIC 6 /* dynamic section */ +#define SHT_NOTE 7 /* note section */ +#define SHT_NOBITS 8 /* no space section */ +#define SHT_REL 9 /* relation section without addends */ +#define SHT_SHLIB 10 /* reserved - purpose unknown */ +#define SHT_DYNSYM 11 /* dynamic symbol table section */ +#define SHT_NUM 12 /* number of section types */ +#define SHT_LOPROC 0x70000000 /* reserved range for processor */ +#define SHT_HIPROC 0x7fffffff /* specific section header types */ +#define SHT_LOUSER 0x80000000 /* reserved range for application */ +#define SHT_HIUSER 0xffffffff /* specific indexes */ + +/* Section names */ +#define ELF_BSS ".bss" /* uninitialized data */ +#define ELF_DATA ".data" /* initialized data */ +#define ELF_DEBUG ".debug" /* debug */ +#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ +#define ELF_DYNSTR ".dynstr" /* dynamic string table */ +#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ +#define ELF_FINI ".fini" /* termination code */ +#define ELF_GOT ".got" /* global offset table */ +#define ELF_HASH ".hash" /* symbol hash table */ +#define ELF_INIT ".init" /* initialization code */ +#define ELF_REL_DATA ".rel.data" /* relocation data */ +#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ +#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ +#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ +#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ +#define ELF_REL_TEXT ".rel.text" /* relocation code */ +#define ELF_RODATA ".rodata" /* read-only data */ +#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ +#define ELF_STRTAB ".strtab" /* string table */ +#define ELF_SYMTAB ".symtab" /* symbol table */ +#define ELF_TEXT ".text" /* code */ + + +/* Section Attribute Flags - sh_flags */ +#define SHF_WRITE 0x1 /* Writable */ +#define SHF_ALLOC 0x2 /* occupies memory */ +#define SHF_EXECINSTR 0x4 /* executable */ +#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ + /* specific section attributes */ + +/* Symbol Table Entry */ +typedef struct elf32_sym { + Elf32_Word st_name; /* name - index into string table */ + Elf32_Addr st_value; /* symbol value */ + Elf32_Word st_size; /* symbol size */ + unsigned char st_info; /* type and binding */ + unsigned char st_other; /* 0 - no defined meaning */ + Elf32_Half st_shndx; /* section header index */ +} Elf32_Sym; + +typedef struct { + Elf64_Half st_name; /* Symbol name index in str table */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf64_Quarter st_shndx; /* section index of symbol */ + Elf64_Xword st_value; /* value of symbol */ + Elf64_Xword st_size; /* size of symbol */ +} Elf64_Sym; + +/* Symbol table index */ +#define STN_UNDEF 0 /* undefined */ + +/* Extract symbol info - st_info */ +#define ELF32_ST_BIND(x) ((x) >> 4) +#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) +#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) + +#define ELF64_ST_BIND(x) ((x) >> 4) +#define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf) +#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) + +/* Symbol Binding - ELF32_ST_BIND - st_info */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* like global - lower precedence */ +#define STB_NUM 3 /* number of symbol bindings */ +#define STB_LOPROC 13 /* reserved range for processor */ +#define STB_HIPROC 15 /* specific symbol bindings */ + +/* Symbol type - ELF32_ST_TYPE - st_info */ +#define STT_NOTYPE 0 /* not specified */ +#define STT_OBJECT 1 /* data object */ +#define STT_FUNC 2 /* function */ +#define STT_SECTION 3 /* section */ +#define STT_FILE 4 /* file */ +#define STT_NUM 5 /* number of symbol types */ +#define STT_LOPROC 13 /* reserved range for processor */ +#define STT_HIPROC 15 /* specific symbol types */ + +/* Relocation entry with implicit addend */ +typedef struct { + Elf32_Addr r_offset; /* offset of relocation */ + Elf32_Word r_info; /* symbol table index and type */ +} Elf32_Rel; + +/* Relocation entry with explicit addend */ +typedef struct { + Elf32_Addr r_offset; /* offset of relocation */ + Elf32_Word r_info; /* symbol table index and type */ + Elf32_Sword r_addend; +} Elf32_Rela; + +/* Extract relocation info - r_info */ +#define ELF32_R_SYM(i) ((i) >> 8) +#define ELF32_R_TYPE(i) ((unsigned char) (i)) +#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t)) + +typedef struct { + Elf64_Xword r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ +} Elf64_Rel; + +typedef struct { + Elf64_Xword r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ + Elf64_Sxword r_addend; /* adjustment value */ +} Elf64_Rela; + +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF) +#define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t)) + +/* Program Header */ +typedef struct { + Elf32_Word p_type; /* segment type */ + Elf32_Off p_offset; /* segment offset */ + Elf32_Addr p_vaddr; /* virtual address of segment */ + Elf32_Addr p_paddr; /* physical address - ignored? */ + Elf32_Word p_filesz; /* number of bytes in file for seg. */ + Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ + Elf32_Word p_flags; /* flags */ + Elf32_Word p_align; /* memory alignment */ +} Elf32_Phdr; + +typedef struct { + Elf64_Half p_type; /* entry type */ + Elf64_Half p_flags; /* flags */ + Elf64_Off p_offset; /* offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory & file alignment */ +} Elf64_Phdr; + +/* Segment types - p_type */ +#define PT_NULL 0 /* unused */ +#define PT_LOAD 1 /* loadable segment */ +#define PT_DYNAMIC 2 /* dynamic linking section */ +#define PT_INTERP 3 /* the RTLD */ +#define PT_NOTE 4 /* auxiliary information */ +#define PT_SHLIB 5 /* reserved - purpose undefined */ +#define PT_PHDR 6 /* program header */ +#define PT_NUM 7 /* Number of segment types */ +#define PT_LOPROC 0x70000000 /* reserved range for processor */ +#define PT_HIPROC 0x7fffffff /* specific segment types */ + +/* Segment flags - p_flags */ +#define PF_X 0x1 /* Executable */ +#define PF_W 0x2 /* Writable */ +#define PF_R 0x4 /* Readable */ +#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ + /* specific segment flags */ + +/* Dynamic structure */ +typedef struct { + Elf32_Sword d_tag; /* controls meaning of d_val */ + union { + Elf32_Word d_val; /* Multiple meanings - see d_tag */ + Elf32_Addr d_ptr; /* program virtual address */ + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Xword d_tag; /* controls meaning of d_val */ + union { + Elf64_Addr d_ptr; + Elf64_Xword d_val; + } d_un; +} Elf64_Dyn; + +/* Dynamic Array Tags - d_tag */ +#define DT_NULL 0 /* marks end of _DYNAMIC array */ +#define DT_NEEDED 1 /* string table offset of needed lib */ +#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */ +#define DT_PLTGOT 3 /* address PLT/GOT */ +#define DT_HASH 4 /* address of symbol hash table */ +#define DT_STRTAB 5 /* address of string table */ +#define DT_SYMTAB 6 /* address of symbol table */ +#define DT_RELA 7 /* address of relocation table */ +#define DT_RELASZ 8 /* size of relocation table */ +#define DT_RELAENT 9 /* size of relocation entry */ +#define DT_STRSZ 10 /* size of string table */ +#define DT_SYMENT 11 /* size of symbol table entry */ +#define DT_INIT 12 /* address of initialization func. */ +#define DT_FINI 13 /* address of termination function */ +#define DT_SONAME 14 /* string table offset of shared obj */ +#define DT_RPATH 15 /* string table offset of library + search path */ +#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ +#define DT_REL 17 /* address of rel. tbl. w addends */ +#define DT_RELSZ 18 /* size of DT_REL relocation table */ +#define DT_RELENT 19 /* size of DT_REL relocation entry */ +#define DT_PLTREL 20 /* PLT referenced relocation entry */ +#define DT_DEBUG 21 /* bugger */ +#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */ +#define DT_JMPREL 23 /* add. of PLT's relocation entries */ +#define DT_BIND_NOW 24 /* Bind now regardless of env setting */ +#define DT_NUM 25 /* Number used. */ +#define DT_LOPROC 0x70000000 /* reserved range for processor */ +#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ + +/* Standard ELF hashing function */ +unsigned int elf_hash(const unsigned char *name); + +/* + * Note Definitions + */ +typedef struct { + Elf32_Word namesz; + Elf32_Word descsz; + Elf32_Word type; +} Elf32_Note; + +typedef struct { + Elf64_Half namesz; + Elf64_Half descsz; + Elf64_Half type; +} Elf64_Note; + + +#if defined(ELFSIZE) +#define CONCAT(x,y) __CONCAT(x,y) +#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) +#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) +#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) +#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 32) +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Phdr Elf32_Phdr +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Rel Elf32_Rel +#define Elf_RelA Elf32_Rela +#define Elf_Dyn Elf32_Dyn +#define Elf_Word Elf32_Word +#define Elf_Sword Elf32_Sword +#define Elf_Addr Elf32_Addr +#define Elf_Off Elf32_Off +#define Elf_Nhdr Elf32_Nhdr +#define Elf_Note Elf32_Note + +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE ELF32_R_TYPE +#define ELF_R_INFO ELF32_R_INFO +#define ELFCLASS ELFCLASS32 + +#define ELF_ST_BIND ELF32_ST_BIND +#define ELF_ST_TYPE ELF32_ST_TYPE +#define ELF_ST_INFO ELF32_ST_INFO + +#define AuxInfo Aux32Info +#elif defined(ELFSIZE) && (ELFSIZE == 64) +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Phdr Elf64_Phdr +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Rel Elf64_Rel +#define Elf_RelA Elf64_Rela +#define Elf_Dyn Elf64_Dyn +#define Elf_Word Elf64_Word +#define Elf_Sword Elf64_Sword +#define Elf_Addr Elf64_Addr +#define Elf_Off Elf64_Off +#define Elf_Nhdr Elf64_Nhdr +#define Elf_Note Elf64_Note + +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE ELF64_R_TYPE +#define ELF_R_INFO ELF64_R_INFO +#define ELFCLASS ELFCLASS64 + +#define ELF_ST_BIND ELF64_ST_BIND +#define ELF_ST_TYPE ELF64_ST_TYPE +#define ELF_ST_INFO ELF64_ST_INFO + +#define AuxInfo Aux64Info +#endif + +#endif /* __XEN_PUBLIC_ELFSTRUCTS_H__ */ diff --git a/common/inc/internal/enclave_creator.h b/common/inc/internal/enclave_creator.h new file mode 100644 index 0000000000..67d41a7ae2 --- /dev/null +++ b/common/inc/internal/enclave_creator.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * File: enclave_creator.h + * Description: this header file defines the interface used by Enclave loader to create the Enclave + * + * The hardware, simulation and signing mode shall inherit from this class and + * implement all the virtual functions + */ + +#ifndef _ENCLAVE_CREATOR_H +#define _ENCLAVE_CREATOR_H + +#include "arch.h" +#include "sgx_eid.h" +#include "metadata.h" +#include "sgx_error.h" +#include "util.h" +#include "launch_checker.h" +#include "uncopyable.h" +#include +#include "file.h" + +// this is the interface to both hardware, simulation and signing mode +class EnclaveCreator : private Uncopyable +{ +public: + /* + @quote the EPC reserved; + @enclave_id identify the unique enclave; + @start_addr is the linear address allocated for Enclave; + */ + virtual int create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae = false) = 0; + /* + *@attr can be REMOVABLE + */ + virtual int add_enclave_page(sgx_enclave_id_t enclave_id, void *source, uint64_t offset, const sec_info_t &sinfo, uint32_t attr) = 0; + virtual int init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, SGXLaunchToken *lc, le_prd_css_file_t *prd_css_file = NULL) = 0; + virtual int destroy_enclave(sgx_enclave_id_t enclave_id) = 0; + virtual int initialize(sgx_enclave_id_t enclave_id) = 0; + virtual bool use_se_hw() const = 0; + + virtual int get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t flag) = 0; + virtual bool get_plat_cap(sgx_misc_attribute_t *se_attr) = 0; +#ifdef SE_1P5_VERTICAL + virtual uint32_t handle_page_fault(uint64_t pf_address) { UNUSED(pf_address); return (uint32_t)SGX_ERROR_UNEXPECTED; } +#endif + // destructor + virtual ~EnclaveCreator() {}; +}; + +EnclaveCreator* get_enclave_creator(void); + +extern EnclaveCreator* g_enclave_creator; + +#endif diff --git a/common/inc/internal/global_data.h b/common/inc/internal/global_data.h new file mode 100644 index 0000000000..be1e97eec8 --- /dev/null +++ b/common/inc/internal/global_data.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: global_data.h + * Description: + * The file defines the structure global_data_t. + */ + +#ifndef _TRTS_GLOBAL_DATA_H_ +#define _TRTS_GLOBAL_DATA_H_ + +#include "se_types.h" +#include "thread_data.h" + +typedef struct _global_data_t +{ + sys_word_t enclave_size; + sys_word_t heap_offset; + sys_word_t heap_size; + uint32_t thread_policy; + uint32_t reserved; + thread_data_t td_template; +} global_data_t; + +#define ENCLAVE_INIT_NOT_STARTED 0 +#define ENCLAVE_INIT_IN_PROGRESS 1 +#define ENCLAVE_INIT_DONE 2 +#define ENCLAVE_CRASHED 3 + +#ifdef __cplusplus +extern "C" { +#endif +extern SE_DECLSPEC_EXPORT global_data_t const volatile g_global_data; +extern uint32_t g_enclave_state; +extern uint8_t __ImageBase; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/common/inc/internal/global_init.h b/common/inc/internal/global_init.h new file mode 100644 index 0000000000..d7a36530cb --- /dev/null +++ b/common/inc/internal/global_init.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GLOBAL_INIT_H +#define GLOBAL_INIT_H + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +void init_global_object(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/inst.h b/common/inc/internal/inst.h new file mode 100644 index 0000000000..cd09c5a939 --- /dev/null +++ b/common/inc/internal/inst.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_ARCH_H_ +# error "never include inst.h directly; use arch.h instead." +#endif + + +#ifndef _SE_INST_H_ +#define _SE_INST_H_ + +#define ENCLU 0xd7010f + +typedef enum { + SE_EREPORT = 0x0, + SE_EGETKEY, + SE_EENTER, + SE_ERESUME, + SE_EEXIT, + SE_LAST_RING3, + + SE_ECREATE = 0x0, + SE_EADD, + SE_EINIT, + SE_EREMOVE, + SE_EDBGRD, + SE_EDBGWR, + SE_EEXTEND, + SE_LAST_RING0 +} se_opcode_t; + +#endif diff --git a/common/inc/internal/ipp_wrapper.h b/common/inc/internal/ipp_wrapper.h new file mode 100644 index 0000000000..242a041c3b --- /dev/null +++ b/common/inc/internal/ipp_wrapper.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _IPP_WRAPPER_H +#define _IPP_WRAPPER_H + +#include "ippcp.h" + +#ifndef SAFE_FREE_MM +#define SAFE_FREE_MM(ptr) {\ + if(ptr != NULL) \ + { \ + free(ptr); \ + ptr = NULL; \ + }} +#endif + +#ifndef ERROR_BREAK +#define ERROR_BREAK(x) if(x != ippStsNoErr){break;} +#endif +#ifndef NULL_BREAK +#define NULL_BREAK(x) if(!x){break;} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +IppStatus newBN(const Ipp32u *data, int size_in_bytes, IppsBigNumState **p_new_BN); + +IppStatus create_rsa_priv1_key(int n_byte_size, int d_byte_size, const Ipp32u *n, const Ipp32u *d, IppsRSAPrivateKeyState **new_pri_key1); + +IppStatus create_rsa_priv2_key(int p_byte_size, const Ipp32u *p, const Ipp32u *q, + const Ipp32u *dmp1, const Ipp32u *dmq1, const Ipp32u *iqmp, + IppsRSAPrivateKeyState **new_pri_key2); + +IppStatus create_rsa_pub_key(int n_byte_size, int e_byte_size, const Ipp32u *n, const Ipp32u *e, IppsRSAPublicKeyState **new_pub_key); + +IppStatus create_validate_rsa_key_pair(int n_byte_size, int e_byte_size, const Ipp32u *n, const Ipp32u *d, const Ipp32u *e, const Ipp32u *p, const Ipp32u *q, + const Ipp32u *dmp1, const Ipp32u *dmq1, const Ipp32u *iqmp, + IppsRSAPrivateKeyState **new_pri_key, IppsRSAPublicKeyState **new_pub_key, int *validate_result); + +IppStatus get_pub_key(const IppsRSAPublicKeyState *pub_key, int *e_byte_size, Ipp32u *e, int *n_byte_size, Ipp32u *n); + +void secure_free_BN(IppsBigNumState *pBN, int size_in_bytes); + +void secure_free_rsa_pri1_key(int n_byte_size, int d_byte_size, IppsRSAPrivateKeyState *pri_key1); + +void secure_free_rsa_pri2_key(int p_byte_size, IppsRSAPrivateKeyState *pri_key2); + +void secure_free_rsa_pub_key(int n_byte_size, int e_byte_size, IppsRSAPublicKeyState *pub_key); + + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/common/inc/internal/linux/cpuid_gnu.h b/common/inc/internal/linux/cpuid_gnu.h new file mode 100644 index 0000000000..5fd907162f --- /dev/null +++ b/common/inc/internal/linux/cpuid_gnu.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _CPUID_GNU_H_ +#define _CPUID_GNU_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* This is a PIC-compliant version of CPUID */ +static inline void cpuid(int *eax, int *ebx, int *ecx, int *edx) +{ +#if defined(__x86_64__) + asm("cpuid" + : "=a" (*eax), + "=b" (*ebx), + "=c" (*ecx), + "=d" (*edx) + : "0" (*eax), "2" (*ecx)); + +#else + /*on 32bit, ebx can NOT be used as PIC code*/ + asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" + : "=a" (*eax), "=r" (*ebx), "=c" (*ecx), "=d" (*edx) + : "0" (*eax), "2" (*ecx)); +#endif +} + +static inline void __cpuid(int a[4], int b) +{ + a[0] = b; + a[2] = 0; + cpuid(&a[0], &a[1], &a[2], &a[3]); +} + +static inline void __cpuidex(int a[4], int b, int c) +{ + a[0] = b; + a[2] = c; + cpuid(&a[0], &a[1], &a[2], &a[3]); +} + +#ifdef __cplusplus +} +#endif + +#endif /*_CPUID_GNU_H_*/ diff --git a/common/inc/internal/linux/linux-regs.h b/common/inc/internal/linux/linux-regs.h new file mode 100644 index 0000000000..1ebed38720 --- /dev/null +++ b/common/inc/internal/linux/linux-regs.h @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * This header wraps the register names for x86/x64. + */ + +#ifndef LINUX_REGS_H__ +#define LINUX_REGS_H__ + +#if defined(__i386) || defined(__i386__) +# define LINUX32 1 +# define SE_WORDSIZE 4 + +/* Generic argument picker for `naked' functions */ +# define naked_arg0 4(%esp) +# define naked_arg1 8(%esp) +# define naked_arg2 12(%esp) +# define naked_arg3 16(%esp) + +# define xax eax +# define xbx ebx +# define xcx ecx +# define xdx edx + +# define xsi esi +# define xdi edi +# define xbp ebp +# define xsp esp +#elif defined(__x86_64) || defined(__x86_64__) +# define LINUX64 1 +# define SE_WORDSIZE 8 + +/* For x86_64, the first six parameters are passed by + * rdi, rsi, rdx, rcx, r8, r9. + */ +# define naked_arg0 %rdi +# define naked_arg1 %rsi +# define naked_arg2 %rdx +# define naked_arg3 %rcx + +# define xax rax +# define xbx rbx +# define xcx rcx +# define xdx rdx + +# define xsi rsi +# define xdi rdi +# define xbp rbp +# define xsp rsp +#else +# error unknown platform! +#endif + +/* SE instructions - needs to be sync-up with inst70.h */ +#define SE_EREPORT 0 +#define SE_EGETKEY 1 +#define SE_EENTER 2 +#define SE_EEXIT 4 + +#define SE_ECREATE 0 +#define SE_EADD 1 +#define SE_EINIT 2 +#define SE_EREMOVE 3 + +/* + * Macros for GNU assembly + */ +.macro ENCLU +#ifdef SE_SIM + cmp $SE_EEXIT, %xax + jne 1f + + /* if leaf is EEXIT, xbp and xsp need to be passed by xdx and xcx */ + mov %xbp, %xdx + mov %xsp, %xcx +1: + push %xdi + push %xsi + push %xdx + push %xcx + push %xbx + push %xax + +# ifdef LINUX64 + pop %rdi + pop %rsi + pop %rdx + pop %rcx + pop %r8 + pop %r9 +# endif + +.type _SE3,@function +.protected _SE3 + call _SE3 + +# ifdef LINUX32 + add $(SE_WORDSIZE * 6), %esp +# endif + +#else /* SE_SIM */ +.byte 0x0f, 0x01, 0xd7 /* 0xf3 */ +#endif /* !SE_SIM */ +.endm + +/* declare a function with default visibility */ +.macro DECLARE_GLOBAL_FUNC name + .globl \name + .type \name, @function +\name: +.endm + +/* declare a function with visibility='hidden' */ +.macro DECLARE_LOCAL_FUNC name + .globl \name + .hidden \name + .type \name, @function +\name: +.endm + +.macro NAKED_PROLOG + push %xbp + mov %xsp, %xbp + sub $(7 * SE_WORDSIZE), %xsp +.endm + +.macro NAKED_EPILOG + mov %xbp, %xsp + pop %xbp +.endm + +/* `paramN' (N = 1,2,3,4) should be registers. */ +.macro SET_PARAMS param1:req, param2, param3, param4 +#if defined(LINUX32) + +.ifnb \param4 + mov \param4, 3*SE_WORDSIZE(%esp) +.endif + +.ifnb \param3 + mov \param3, 2*SE_WORDSIZE(%esp) +.endif + +.ifnb \param2 + mov \param2, 1*SE_WORDSIZE(%esp) +.endif + + mov \param1, 0*SE_WORDSIZE(%esp) + +#else /* LINUX32 */ + +.ifnb \param4 +.ifnc \param4, %rcx + mov \param4, %rcx +.endif +.endif + +.ifnb \param3 +.ifnc \param3, %rdx + mov \param3, %rdx +.endif +.endif + +.ifnb \param2 +.ifnc \param2, %rsi + mov \param2, %rsi +.endif +.endif + +.ifnc \param1, %rdi + mov \param1, %rdi +.endif + +#endif /* LINUX64 */ +.endm + +/*******************************************************************/ + +.macro SE_PROLOG + .cfi_startproc + +#ifdef LINUX32 + pushl %ebp + movl %esp, %ebp +#endif + + push %xbx + push %xcx + push %xdx + +#if defined LINUX64 + movq %rdi, %rbx + movq %rsi, %rcx + /* rdx remains the same, rdi/rsi is not used by _SE0 + */ +#elif defined LINUX32 + movl 2*SE_WORDSIZE(%ebp), %ebx + movl 3*SE_WORDSIZE(%ebp), %ecx + movl 4*SE_WORDSIZE(%ebp), %edx +#endif + +.endm + +/*******************************************************************/ + +.macro SE_EPILOG + pop %xdx + pop %xcx + pop %xbx + +#ifdef LINUX32 + movl %ebp, %esp + popl %ebp +#endif + + ret + .cfi_endproc +.endm + +/*******************************************************************/ + +/* load the address of `symbol' to the register `reg' in PIC way. */ +.macro lea_pic symbol, reg +#ifdef LINUX64 + lea \symbol(%rip), \reg +#else +/* The real code on x86 would look like this (get `bar' from `foo'): + * + * 00000198 : + * 198: c3 ret + * + * 00000199 : + * 199: e8 00 00 00 00 call 19e + * 19e: 58 pop %eax + * 19f: 8d 40 fa lea -0x6(%eax),%eax + */ + call . + 0x5 /* No label here to avoid interfering w/ calling code */ + pop \reg + lea (\symbol - . + 1)(\reg), \reg +#endif +.endm + +#endif /* LINUX_REGS_H__ */ diff --git a/common/inc/internal/linux/xsave_gnu.h b/common/inc/internal/linux/xsave_gnu.h new file mode 100644 index 0000000000..960398faaf --- /dev/null +++ b/common/inc/internal/linux/xsave_gnu.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _XSAVE_GNU_H_ +#define _XSAVE_GNU_H_ + +#include "se_types.h" + +#ifdef __x86_64__ +# define ASM_FXSAVE "rex64/fxsave" +# define ASM_FXRSTR "rex64/fxrstor" +# define ASM_XSAVE "rex64/xsave" +# define ASM_XRSTR ".byte 0x48,0x0f,0xae,0x2f" +#else +# define ASM_FXSAVE "fxsave" +# define ASM_FXRSTR "fxrstor" +# define ASM_XSAVE "xsave" +# define ASM_XRSTR ".byte 0x0f,0xae,0x2f" +#endif + +static inline void do_fwait(void) +{ + asm volatile("fwait"); +} + +static inline void do_fxsave(void *buffer) +{ + asm volatile(ASM_FXSAVE" (%0)" : : "r"(buffer) : "memory"); +} + +static inline void do_fxrstor(const void *buffer) +{ + asm volatile(ASM_FXRSTR" (%0)" : : "r"(buffer)); +} + +static inline void do_xsave(void *buffer) +{ + asm volatile(ASM_XSAVE + : + : "D" (buffer), "a" (-1), "d" (-1) + : "memory"); +} + +static inline void _do_xrstor(const void *buffer, uint64_t mask) +{ + uint32_t lmask = (uint32_t)mask; + uint32_t hmask = (uint32_t)(mask >> 32); + + asm volatile(ASM_XRSTR + : + : "D" (buffer), "a" (lmask), "d" (hmask)); +} + +static inline void do_xrstor(const void *buffer) +{ + _do_xrstor(buffer, 0xffffffffffffffffULL); +} + +static inline void do_vzeroupper() +{ + asm volatile("vzeroupper"); +} + +#endif diff --git a/common/inc/internal/metadata.h b/common/inc/internal/metadata.h new file mode 100644 index 0000000000..031af632e2 --- /dev/null +++ b/common/inc/internal/metadata.h @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _METADATA_H_ +#define _METADATA_H_ +#include "arch.h" +#include "se_macro.h" + +#pragma pack(1) + + /* version of metadata */ +#define MAJOR_VERSION 1 /* MAJOR_VERSION should not larger than 0ffffffff */ +#define MINOR_VERSION 3 /* MINOR_VERSION should not larger than 0ffffffff */ + +#define META_DATA_MAKE_VERSION(major, minor) (((uint64_t)major)<<32 | minor) + +#define METADATA_MAGIC 0x86A80294635D0E4CULL +#define METADATA_SIZE 0x1000 +/* TCS Policy bit masks */ +#define TCS_POLICY_BIND 0x00000000 /* If set, the TCS is bound to the application thread */ +#define TCS_POLICY_UNBIND 0x00000001 + +#define MAX_SAVE_BUF_SIZE 2632 + +#define TCS_NUM_MIN 1 +#define SSA_NUM_MIN 2 +#define SSA_FRAME_SIZE_MIN 1 +#define SSA_FRAME_SIZE_MAX 2 +#define STACK_SIZE_MIN 0x1000 +#define HEAP_SIZE_MIN 0 +#define DEFAULT_MISC_SELECT 0 +#define DEFAULT_MISC_MASK 0xFFFFFFFF + +typedef struct _data_directory_t +{ + uint32_t offset; + uint32_t size; +} data_directory_t; + +typedef enum +{ + DIR_PATCH, + DIR_LAYOUT, + DIR_NUM, +} dir_index_t; + +#define GROUP_FLAG (1<<12) +#define GROUP_ID(x) (GROUP_FLAG | x) +#define IS_GROUP_ID(x) !!((x) & GROUP_FLAG) +#define LAYOUT_ID_HEAP 1 +#define LAYOUT_ID_TCS 2 +#define LAYOUT_ID_TD 3 +#define LAYOUT_ID_SSA 4 +#define LAYOUT_ID_STACK 5 +#define LAYOUT_ID_THREAD_GROUP GROUP_ID(6) +#define LAYOUT_ID_GUARD 7 + +/* +** layout table example +** entry0 - entry1 - entry2 - group3 (entry_count=2, load_times=3) ... +** the load sequence should be: +** entry0 - entry1 - entry2 - entry1 - entry2 - entry1 - entry2 - entry1 - entry2 ... +** -------------- -------------- -------------- +** group3 1st time group3 2nd time group3 3rd time +*/ +typedef struct _layout_entry_t +{ + uint16_t id; /* unique ID to identify the purpose for this entry */ + uint16_t attributes; /* EADD/EEXTEND/EREMOVE... */ + uint32_t page_count; /* map size in page. Biggest chunk = 2^32 pages = 2^44 bytes. */ + uint64_t rva; /* map offset, relative to encalve base */ + uint32_t content_size; /* if content_offset = 0, content_size is the initial data to fill the whole page. */ + uint32_t content_offset; /* offset to the initial content, relative to metadata */ + si_flags_t si_flags; /* security info, R/W/X, SECS/TCS/REG/VA */ +} layout_entry_t; + +typedef struct _layout_group_t +{ + uint16_t id; /* unique ID to identify the purpose for this entry */ + uint16_t entry_count; /* reversely count entry_count entries for the group loading. */ + uint32_t load_times; /* the repeated times of loading */ + uint64_t load_step; /* the group size. the entry load rva should be adjusted with the load_step */ + /* rva = entry.rva + group.load_step * load_times */ + uint32_t reserved[4]; +} layout_group_t; + +typedef union _layout_t +{ + layout_entry_t entry; + layout_group_t group; +} layout_t; + +typedef struct _patch_entry_t +{ + uint64_t dst; /* relative to enclave file base */ + uint32_t src; /* relative to metadata base */ + uint32_t size; /* patched size */ + uint32_t reserved[4]; +} patch_entry_t; + +typedef struct _metadata_t +{ + uint64_t magic_num; /* The magic number identifying the file as a signed enclave image */ + uint64_t version; /* The metadata version */ + uint32_t size; /* The size of this structure */ + uint32_t tcs_policy; /* TCS management policy */ + uint32_t ssa_frame_size; /* The size of SSA frame in page */ + uint32_t max_save_buffer_size; /* Max buffer size is 2632 */ + uint32_t desired_misc_select; + uint32_t reserved; + uint64_t enclave_size; /* enclave virtual size */ + sgx_attributes_t attributes; /* XFeatureMask to be set in SECS. */ + enclave_css_t enclave_css; /* The enclave signature */ + data_directory_t dirs[DIR_NUM]; + uint8_t data[2208]; +}metadata_t; + +se_static_assert(sizeof(metadata_t) == METADATA_SIZE); + +#pragma pack() + +#endif diff --git a/common/inc/internal/oal/uae_oal_api.h b/common/inc/internal/oal/uae_oal_api.h new file mode 100644 index 0000000000..2666fd662b --- /dev/null +++ b/common/inc/internal/oal/uae_oal_api.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _UAE_OAL_H +#define _UAE_OAL_H + +#include "sgx_quote.h" +#include "sgx_error.h" +#include "sgx_urts.h" +#include +#include + +typedef enum{ + UAE_OAL_SUCCESS = 0, + UAE_OAL_ERROR_UNEXPECTED , + UAE_OAL_ERROR_AESM_UNAVAILABLE , + UAE_OAL_ERROR_TIMEOUT , +} uae_oal_status_t; + +/*OAL methods from here forward */ + +extern "C" +{ + +uae_oal_status_t SGXAPI oal_get_launch_token( + const enclave_css_t* signature, + const sgx_attributes_t* attribute, + sgx_launch_token_t* launch_token, + uint32_t timeout_usec, + aesm_error_t *result); + + +uae_oal_status_t SGXAPI oal_init_quote( + sgx_target_info_t *p_target_info, + sgx_epid_group_id_t *p_gid, + uint32_t timeout_usec, + aesm_error_t *result); + + +uae_oal_status_t SGXAPI oal_get_quote( + const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + const sgx_spid_t *p_spid, + const sgx_quote_nonce_t *p_nonce, + const uint8_t *p_sig_rl, + uint32_t sig_rl_size, + sgx_report_t *p_qe_report, + sgx_quote_t *p_quote, + uint32_t quote_size, + uint32_t timeout_usec, + aesm_error_t *result); + +uae_oal_status_t SGXAPI oal_get_ps_cap( + uint64_t* p_ps_cap, + uint32_t timeout_usec, + aesm_error_t *result); + +uae_oal_status_t SGXAPI oal_report_attestation_status( + const sgx_platform_info_t* p_platform_info, + int attestation_status, + sgx_update_info_bit_t* p_update_info, + uint32_t timeout_usec, + aesm_error_t *result); + +uae_oal_status_t oal_create_session( + uint32_t *session_id, + uint8_t *se_dh_msg1, + uint32_t dh_msg1_size, + uint32_t timeout_usec, + aesm_error_t *result); + +uae_oal_status_t oal_exchange_report( + uint32_t session_id, + const uint8_t *se_dh_msg2, + uint32_t dh_msg2_size, + uint8_t *se_dh_msg3, + uint32_t dh_msg3_size, + uint32_t timeout_usec, + aesm_error_t *result); + +uae_oal_status_t oal_close_session( + uint32_t session_id, + uint32_t timeout_usec, + aesm_error_t *result); + +uae_oal_status_t oal_invoke_service( + const uint8_t *pse_message_req, + uint32_t pse_message_req_size, + uint8_t *pse_message_resp, + uint32_t pse_message_resp_size, + uint32_t timeout_usec, + aesm_error_t *response); + +sgx_status_t oal_map_status(uae_oal_status_t status); +sgx_status_t oal_map_result(aesm_error_t result); + +} /* end of extern "C" */ +#endif diff --git a/common/inc/internal/routine.h b/common/inc/internal/routine.h new file mode 100644 index 0000000000..c753b2e2bf --- /dev/null +++ b/common/inc/internal/routine.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ROUTINE_H_ +#define _ROUTINE_H_ +#include "sgx_eid.h" +#include "sgx_error.h" +#include "sgx_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _ocall_table_t +{ + uint32_t count; + void *ocall[]; +} sgx_ocall_table_t; + +sgx_status_t SGXAPI sgx_ecall(const sgx_enclave_id_t enclave_id, const int proc, const void *ocall_table, void *ms); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/common/inc/internal/rts.h b/common/inc/internal/rts.h new file mode 100644 index 0000000000..61a7711501 --- /dev/null +++ b/common/inc/internal/rts.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _RTS_H_ +#define _RTS_H_ + +#include "se_types.h" +#include "rts_cmd.h" + +typedef struct _ocall_context_t +{ + uintptr_t shadow0; + uintptr_t shadow1; + uintptr_t shadow2; + uintptr_t shadow3; + uintptr_t ocall_flag; + uintptr_t ocall_index; + uintptr_t pre_last_sp; + uintptr_t r15; + uintptr_t r14; + uintptr_t r13; + uintptr_t r12; + uintptr_t xbp; + uintptr_t xdi; + uintptr_t xsi; + uintptr_t xbx; + uintptr_t reserved[3]; + uintptr_t ocall_depth; + uintptr_t ocall_ret; +} ocall_context_t; + +typedef enum +{ + SDK_VERSION_1_5, + SDK_VERSION_2_0 +} sdk_version_t; + +typedef struct _cpu_feature_sdk_version +{ + uint64_t cpu_features; + sdk_version_t version; +}cpu_sdk_info_t; + +#define OCALL_FLAG 0x4F434944 + +#endif diff --git a/common/inc/internal/rts_cmd.h b/common/inc/internal/rts_cmd.h new file mode 100644 index 0000000000..671c2c90d1 --- /dev/null +++ b/common/inc/internal/rts_cmd.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ECALL command */ +#define ECMD_ECALL 0 +#define ECMD_INIT_ENCLAVE -1 +#define ECMD_ORET -2 +#define ECMD_EXCEPT -3 + +/* OCALL command */ +#define OCMD_ERET -1 + diff --git a/common/inc/internal/se_atomic.h b/common/inc/internal/se_atomic.h new file mode 100644 index 0000000000..f4de235e8d --- /dev/null +++ b/common/inc/internal/se_atomic.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_ATOMIC_H_ +#define _SE_ATOMIC_H_ + + +inline uint32_t se_atomic_inc(volatile uint32_t *mem) +{ + int ret; + + __asm__ __volatile__ ("lock; xaddl %0, %1" + : "=r" (ret), "=m" (*mem) + : "0" (1), "m" (*mem) + ); + + return ret + 1; +} + +inline uint32_t se_atomic_dec(uint32_t volatile *mem) +{ + int ret; + + __asm__ __volatile__ ("lock; xaddl %0, %1" + : "=r" (ret), "=m" (*mem) + : "0" (-1), "m" (*mem) + ); + + return ret - 1; +} + +#endif diff --git a/common/inc/internal/se_cdefs.h b/common/inc/internal/se_cdefs.h new file mode 100644 index 0000000000..12be808120 --- /dev/null +++ b/common/inc/internal/se_cdefs.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SE_CDEFS_H_ +#define _SE_CDEFS_H_ + + +#define SGX_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 + +#ifndef SE_DECLSPEC_EXPORT +#define SE_DECLSPEC_EXPORT __attribute__((visibility("default"))) +#endif + +#ifndef SE_DECLSPEC_IMPORT +#define SE_DECLSPEC_IMPORT +#endif + +#ifndef SE_DECLSPEC_ALIGN +#define SE_DECLSPEC_ALIGN(x) __attribute__((aligned(x))) +#endif + +#ifndef SE_DECLSPEC_THREAD +#define SE_DECLSPEC_THREAD /*__thread*/ +#endif + +/* disable __try, __except on linux */ +#ifndef __try +#define __try try +#endif + +#ifndef __except +#define __except(x) catch(...) +#endif + + +#ifndef SE_DRIVER + +# define SE_GNU +# if defined(__x86_64__) +# define SE_64 +# define SE_GNU64 +# else +# define SE_32 +# define SE_GNU32 +# endif + +#endif + + #define INITIALIZER(f) \ + static void f(void) __attribute__((constructor)); + +#ifdef __cplusplus +#define MY_EXTERN extern "C" +#else +#define MY_EXTERN extern +#endif + +#define SGX_ACCESS_VERSION(libname, num) \ + MY_EXTERN const char *sgx_##libname##_version; \ + const char * __attribute__((destructor)) libname##_access_version_dummy##num() \ + { \ + return sgx_##libname##_version; \ + } + + +#endif diff --git a/common/inc/internal/se_cpu_feature.h b/common/inc/internal/se_cpu_feature.h new file mode 100644 index 0000000000..8b3edbfa66 --- /dev/null +++ b/common/inc/internal/se_cpu_feature.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SE_CPU_FEATURE_H_ +#define _SE_CPU_FEATURE_H_ + +#include +#include "se_cpu_feature_defs.h" + + +#ifdef __cplusplus +extern "C" uint64_t g_cpu_feature_indicator; +#else +extern uint64_t g_cpu_feature_indicator; +#endif + +#define TEST_CPU_HAS_RDRAND (g_cpu_feature_indicator & CPU_FEATURE_RDRND) + + +#endif diff --git a/common/inc/internal/se_cpu_feature_defs.h b/common/inc/internal/se_cpu_feature_defs.h new file mode 100644 index 0000000000..20983b96d7 --- /dev/null +++ b/common/inc/internal/se_cpu_feature_defs.h @@ -0,0 +1,294 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_CPU_FEATURE_DEFS_H_ +#define _SE_CPU_FEATURE_DEFS_H_ + +/* + * Different extended model + model values for Silverthorn. + */ +#define CPU_ATOM1 0x1c +#define CPU_ATOM2 0x26 +#define CPU_ATOM3 0x27 + +/* + * The processor family is an 8-bit value obtained by adding the + * Extended Family field of the processor signature returned by + * CPUID Function 1 with the Family field. + * F = (CPUID(1).EAX[27:20] >> 20) + (CPUID(1).EAX[11:8] >> 8) + */ +#define CPU_FAMILY(x) (((((x) >> 20) & 0xffU) | (((x) >> 8) & 0xfU)) & 0xffU) + +/* The processor model is an 8-bit value obtained by shifting left 4 + * the Extended Model field of the processor signature returned by + * CPUID Function 1 then adding the Model field. + * M = (CPUID(1).EAX[19:16] >> 12) + (CPUID(1).EAX[7:4] >> 4) + */ +#define CPU_MODEL(x) ((((x) >> 12) & 0xf0U) | (((x) >> 4) & 0xfU)) +#define CPU_STEPPING(x) (((x) >> 0) & 0xf) + +#define CPU_HAS_MMX(x) (((x) & (1 << 23)) != 0) +#define CPU_HAS_FXSAVE(x) (((x) & (1 << 24)) != 0) +#define CPU_HAS_SSE(x) (((x) & (1 << 25)) != 0) +#define CPU_HAS_SSE2(x) (((x) & (1 << 26)) != 0) +#define CPU_HAS_PNI(x) (((x) & (1 << 0)) != 0) +#define CPU_HAS_MNI(x) (((x) & (1 << 9)) != 0) +#define CPU_HAS_SNI(x) (((x) & (1 << 19)) != 0) +#define CPU_HAS_MOVBE(x) (((x) & (1 << 22)) != 0) +#define CPU_HAS_SSE4_2(x) (((x) & (1 << 20)) != 0) +#define CPU_HAS_POPCNT(x) (((x) & (1 << 23)) != 0) +#define CPU_HAS_PCLMULQDQ(x) (((x) & (1 << 1)) != 0) +#define CPU_HAS_AES(x) (((x) & (1 << 25)) != 0) +#define CPU_HAS_XSAVE(x) (((x) & (1 << 27)) != 0) +#define CPU_HAS_AVX(x) (((x) & (1 << 28)) != 0) +#define XFEATURE_ENABLED_AVX(x) \ + (((x) & 0x06) == 0x06) +#define CPU_HAS_F16C(x) (((x) & (1 << 29)) != 0) +#define CPU_HAS_RDRAND(x) (((x) & (1 << 30)) != 0) +#define CPU_HAS_IVB(x) (CPU_HAS_F16C(x) && CPU_HAS_RDRAND(x)) +#define CPU_HAS_IVB_NORDRAND(x) (CPU_HAS_F16C(x)) +#define CPU_HAS_AVX2(x) (((x) & (1 << 5)) != 0) +#define CPU_HAS_HLE(x) (((x) & (1 << 4)) != 0) +#define CPU_HAS_RTM(x) (((x) & (1 << 11)) != 0) +#define CPU_HAS_ADCOX(x) (((x) & (1 << 19)) != 0) +#define CPU_HAS_RDSEED(x) (((x) & (1 << 18)) != 0) +#define CPU_HAS_BMI(x) (((x) & (1 << 3)) != 0 && \ + ((x) & (1 << 8)) != 0) +#define CPU_HAS_LZCNT(x) (((x) & (1 << 5)) != 0) +#define CPU_HAS_PREFETCHW(x) (((x) & (1 << 8)) != 0) +#define CPU_HAS_FMA(x) (((x) & (1 << 12)) != 0) +#define CPU_HAS_HSW(cpuid7_ebx, ecpuid1_ecx, cpuid1_ecx) \ + (CPU_HAS_AVX2(cpuid7_ebx) && CPU_HAS_BMI(cpuid7_ebx) && \ + CPU_HAS_LZCNT(ecpuid1_ecx) && CPU_HAS_FMA(cpuid1_ecx) && \ + CPU_HAS_HLE(cpuid7_ebx) && CPU_HAS_RTM(cpuid7_ebx)) + +#define CPU_HAS_FPU(x) (((x) & (1 << 0)) != 0) +#define CPU_HAS_CMOV(x) (((x) & (1 << 15)) != 0) + +#define CPU_HAS_SSE3(x) (((x) & (1 << 0)) != 0) +#define CPU_HAS_SSSE3(x) (((x) & (1 << 9)) != 0) + +#define CPU_HAS_SSE4_1(x) (((x) & (1 << 19)) != 0) + +#define CPU_HAS_LRBNI(x) (((x) & (1 << 1)) != 0) +#define CPU_HAS_LRB2(x) (((x) & (1 << 4)) != 0) + + +#define CPU_GENU_VAL ('G' << 0 | 'e' << 8 | 'n' << 16 | 'u' << 24) +#define CPU_INEI_VAL ('i' << 0 | 'n' << 8 | 'e' << 16 | 'I' << 24) +#define CPU_NTEL_VAL ('n' << 0 | 't' << 8 | 'e' << 16 | 'l' << 24) + +/* + * These values must be in sync with dev/proton/globals/glob_cpu_info.c + * c_legacy_cpu_set_xxx constants. + */ +#define CPU_GENERIC 0x1 +#define CPU_PENTIUM 0x2 +#define CPU_PENTIUM_PRO 0x4 +#define CPU_PENTIUM_MMX 0x8 +#define CPU_PENTIUM_II 0x10 +#define CPU_PENTIUM_II_FXSV 0x20 +#define CPU_PENTIUM_III 0x40 +#define CPU_PENTIUM_III_SSE 0x80 +#define CPU_PENTIUM_4 0x100 +#define CPU_PENTIUM_4_SSE2 0x200 +#define CPU_BNI 0x400 +#define CPU_PENTIUM_4_PNI 0x800 +#define CPU_MNI 0x1000 +#define CPU_SNI 0x2000 +#define CPU_BNL 0x4000 +#define CPU_NHM 0x8000 +#define CPU_WSM 0x10000 +#define CPU_SNB 0x20000 +#define CPU_IVB 0x40000 +#define CPU_HSW 0x400000 + +#define CPU_PENTIUM_FAMILY 5 +#define CPU_PPRO_FAMILY 6 +#define CPU_WMT_FAMILY 15 + +/* + * The processor is a generic IA32 CPU + */ +#define CPU_FEATURE_GENERIC_IA32 0x00000001ULL + +/* + * Floating point unit is on-chip. + */ +#define CPU_FEATURE_FPU 0x00000002ULL + +/* + * Conditional mov instructions are supported. + */ +#define CPU_FEATURE_CMOV 0x00000004ULL + +/* + * The processor supports the MMX technology instruction set extensions + * to Intel Architecture. + */ +#define CPU_FEATURE_MMX 0x00000008ULL + +/* + * The FXSAVE and FXRSTOR instructions are supported for fast + * save and restore of the floating point context. + */ +#define CPU_FEATURE_FXSAVE 0x00000010ULL + +/* + * Indicates the processor supports the Streaming SIMD Extensions Instructions. + */ +#define CPU_FEATURE_SSE 0x00000020ULL + +/* + * Indicates the processor supports the Streaming SIMD + * Extensions 2 Instructions. + */ +#define CPU_FEATURE_SSE2 0x00000040ULL + +/* + * Indicates the processor supports the Streaming SIMD + * Extensions 3 Instructions. (PNI) + */ +#define CPU_FEATURE_SSE3 0x00000080ULL + +/* + * The processor supports the Supplemental Streaming SIMD Extensions 3 + * instructions. (MNI) + */ +#define CPU_FEATURE_SSSE3 0x00000100ULL + +/* + * The processor supports the Streaming SIMD Extensions 4.1 instructions.(SNI) + */ +#define CPU_FEATURE_SSE4_1 0x00000200ULL + +/* + * The processor supports the Streaming SIMD Extensions 4.1 instructions. + * (NNI + STTNI) + */ +#define CPU_FEATURE_SSE4_2 0x00000400ULL + + +/* + * The processor supports POPCNT instruction. + */ +#define CPU_FEATURE_POPCNT 0x00000800ULL + +/* + * The processor supports MOVBE instruction. + */ +#define CPU_FEATURE_MOVBE 0x00001000ULL + +/* + * The processor supports PCLMULQDQ instruction. + */ +#define CPU_FEATURE_PCLMULQDQ 0x00002000ULL + +/* + * The processor supports instruction extension for encryption. + */ +#define CPU_FEATURE_AES 0x00004000ULL + +/* + * The processor supports 16-bit floating-point conversions instructions. + */ +#define CPU_FEATURE_F16C 0x00008000ULL + +/* + * The processor supports AVX instruction extension. + */ +#define CPU_FEATURE_AVX 0x00010000ULL + +/* + * The processor supports RDRND (read random value) instruction. + */ +#define CPU_FEATURE_RDRND 0x00020000ULL + +/* + * The processor supports FMA instructions. + */ +#define CPU_FEATURE_FMA 0x00040000ULL + +/* + * The processor supports two groups of advanced bit manipulation extensions. - Haswell introduced, AVX2 related + */ +#define CPU_FEATURE_BMI 0x00080000ULL + +/* + * The processor supports LZCNT instruction (counts the number of leading zero + * bits). - Haswell introduced + */ +#define CPU_FEATURE_LZCNT 0x00100000ULL + +/* + * The processor supports HLE extension (hardware lock elision). - Haswell introduced + */ +#define CPU_FEATURE_HLE 0x00200000ULL + +/* + * The processor supports RTM extension (restricted transactional memory) - Haswell AVX2 related. + */ +#define CPU_FEATURE_RTM 0x00400000ULL + +/* + * The processor supports AVX2 instruction extension. + */ +#define CPU_FEATURE_AVX2 0x00800000ULL + +/* + * The processor supports AVX512 instruction extension. + */ +#define CPU_FEATURE_AVX512 0x01000000ULL + +/* + * The processor supports the PREFETCHW instruction. + */ +#define CPU_FEATURE_PREFETCHW 0x02000000ULL + +/* + * The processor supports RDSEED instruction. + */ +#define CPU_FEATURE_RDSEED 0x04000000ULL + +/* + * The processor supports ADCX and ADOX instructions. + */ +#define CPU_FEATURE_ADCOX 0x08000000ULL + +/* + * The processor is a full inorder (Silverthorne) processor + */ +#define CPU_FEATURE_FULL_INORDER 0x10000000ULL + +/* Reserved feature bits which includes the unset bit CPU_FEATURE_AVX512 */ +#define RESERVED_CPU_FEATURE_BIT ((~(0x20000000ULL - 1)) | 0x01000000ULL) + +#endif diff --git a/common/inc/internal/se_debugger_lib.h b/common/inc/internal/se_debugger_lib.h new file mode 100644 index 0000000000..97e4e36546 --- /dev/null +++ b/common/inc/internal/se_debugger_lib.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SEDEBUGGERLIB_H_ +#define _SEDEBUGGERLIB_H_ + +#include "arch.h" +#include "se_types.h" +#include "se_macro.h" +#include + +#define URTS_EXCEPTION_PRECREATEENCLAVE 0xa1a01ec0 +#define URTS_EXCEPTION_POSTINITENCLAVE 0xa1a01ec1 +#define URTS_EXCEPTION_PREREMOVEENCLAVE 0xa1a01ec3 +#define URTS_EXCEPTION_PREEENTER 0xa1a01ec7 + +#define FIRST_CHANCE_EXCEPTION 1 +#define SECOND_CHANCE_EXCEPTION 0 + +#define DBWIN_BUFFER 0xa1a01ec5 +#define CXX_EXCEPTION 0xe06d7363 + +#define SE_UNICODE 1 +#define SE_ANSI 0 +#define DEBUGGER_ENABLED 1 + +#define DEBUG_INFO_STRUCT_VERSION 0x83d0ce23 + +const size_t BUF_SIZE = sizeof(void*); + +typedef struct _debug_tcs_info_t +{ + struct _debug_tcs_info_t* next_tcs_info; + void* TCS_address; + uintptr_t ocall_frame; /* ocall_frame_t** */ + unsigned long thread_id; +}debug_tcs_info_t; + + +#define DEBUG_INFO_MAX_PARAMETERS 10 +typedef struct _debug_info_t +{ + uintptr_t param_array[DEBUG_INFO_MAX_PARAMETERS]; +}debug_info_t; + +//enclave_type bit map +#define ET_SIM_SHIFT 0 /*bits[0]=0 hw, bits[0]=1 sim*/ +#define ET_DEBUG_SHIFT 1 /*bits[1]=0 product enclave, bits[1]=1 debug enclave*/ +#define ET_SIM (1 << ET_SIM_SHIFT) +#define ET_DEBUG (1 << ET_DEBUG_SHIFT) + +typedef struct _debug_enclave_info_t +{ + PADDED_POINTER(struct _debug_enclave_info_t, next_enclave_info); + PADDED_POINTER(void, start_addr); + PADDED_POINTER(debug_tcs_info_t, tcs_list); + uint32_t enclave_type; + uint32_t file_name_size; + PADDED_POINTER(void, lpFileName); + PADDED_POINTER(void, g_peak_heap_used_addr); + PADDED_POINTER(void, dyn_sec); + sgx_misc_select_t misc_select; + /* The following members are optional or unused */ + uint32_t struct_version; + uint32_t unicode; +}debug_enclave_info_t; +typedef struct _ocall_frame_t +{ + uintptr_t pre_last_frame; + uintptr_t index; + uintptr_t xbp; + uintptr_t ret; +}ocall_frame_t; + +static inline void destory_debug_info(debug_enclave_info_t *debug_info) +{ + if(debug_info->lpFileName) + { + free(debug_info->lpFileName); + debug_info->lpFileName = NULL; + } + + /*tcs_list is just a pointer, the instance is maintained in CTrustThread, so don't free it.*/ + debug_info->tcs_list = NULL; +} +#endif /*_SEDEBUGGERLIB_H_*/ + diff --git a/common/inc/internal/se_enclave_type.h b/common/inc/internal/se_enclave_type.h new file mode 100644 index 0000000000..bd450e3918 --- /dev/null +++ b/common/inc/internal/se_enclave_type.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_ENCLAVE_TYPE_H_ +#define _SE_ENCLAVE_TYPE_H_ + +typedef enum +{ + enclave_type_general = 0, + enclave_type_architecture, +} enclave_type_t; + +#endif diff --git a/common/inc/internal/se_error_internal.h b/common/inc/internal/se_error_internal.h new file mode 100644 index 0000000000..b98aed81d7 --- /dev/null +++ b/common/inc/internal/se_error_internal.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_ERROR_INTERNAL_H_ +#define _SE_ERROR_INTERNAL_H_ + +#include "sgx_error.h" + +/* +bit[31:30] - main module id + 00 - external error + 11---internal error +bit[29:16] - reserved +bit[15:12] - sub-module id +bit[11:0] - specific error +*/ + +#define MAIN_MOD_SHIFT 30 +#define SUB_MOD_SHIFT 12 + +#define INTERNAL_ERROR 3 +#define EXTERNAL_ERROR 0 + +#define SE_INTERNAL_ERROR(x) (0xC0000000|(x)) + +typedef enum _se_status_internal_t +{ + SE_ERROR_SUCCESS = 0, /*same value as SGX_SUCCESS*/ + /*error code for driver return to uRTS*/ + SE_ERROR_DRIVER_UNEXPECTED = SE_INTERNAL_ERROR(0X2001), + SE_ERROR_DRIVER_INVALID_ID = SE_INTERNAL_ERROR(0X2002), + SE_ERROR_DRIVER_INVALID_PARAMETER = SE_INTERNAL_ERROR(0X2003), + SE_ERROR_DRIVER_INVALID_REQUEST = SE_INTERNAL_ERROR(0X2004), + SE_ERROR_DRIVER_OUTOF_MEMORY_R0 = SE_INTERNAL_ERROR(0X2005), + SE_ERROR_DRIVER_OUTOF_MEMORY_R3 = SE_INTERNAL_ERROR(0X2006), + SE_ERROR_DRIVER_OUTOF_EPC = SE_INTERNAL_ERROR(0X2007), + SE_ERROR_DRIVER_HW_CAPABILITY = SE_INTERNAL_ERROR(0X2008), + SE_ERROR_DRIVER_MEMORY_MAP_CONFLICT = SE_INTERNAL_ERROR(0X2009), + SE_ERROR_DRIVER_POWER = SE_INTERNAL_ERROR(0X200a), + SE_ERROR_DRIVER_INVALID_PRIVILEGE = SE_INTERNAL_ERROR(0X200b), + SE_ERROR_DRIVER_INVALID_ISVSVNLE = SE_INTERNAL_ERROR(0X200c), + + SE_ERROR_DRIVER_INVALID_SIG_STRUCT = SE_INTERNAL_ERROR(0X2100), + SE_ERROR_DRIVER_INVALID_ATTRIBUTE = SE_INTERNAL_ERROR(0X2101), + SE_ERROR_DRIVER_INVALID_MEASUREMENT = SE_INTERNAL_ERROR(0X2102), + SE_ERROR_DRIVER_INVALID_SIGNATURE = SE_INTERNAL_ERROR(0X2103), + SE_ERROR_DRIVER_INVALID_LAUNCH_TOKEN= SE_INTERNAL_ERROR(0X2104), + SE_ERROR_DRIVER_INVALID_CPUSVN = SE_INTERNAL_ERROR(0X2105), + SE_ERROR_DRIVER_UNMASKED_EVENT = SE_INTERNAL_ERROR(0X2106), + + SE_ERROR_INVALID_LAUNCH_TOKEN = SE_INTERNAL_ERROR(0x2200), /* the license is invalid*/ + SE_ERROR_INVALID_MEASUREMENT = SE_INTERNAL_ERROR(0x2201), /* The measurement of the enclave is invalid. May caused by signature or launch token*/ + SE_ERROR_READ_LOCK_FAIL = SE_INTERNAL_ERROR(0x2202), + SE_ERROR_INVALID_ISVSVNLE = SE_INTERNAL_ERROR(0X2203), + + /*error code for untrusted event of SE mutex*/ + SE_ERROR_MUTEX_GET_EVENT = SE_INTERNAL_ERROR(0x3001), + SE_ERROR_MUTEX_WAIT_EVENT = SE_INTERNAL_ERROR(0x3002), + SE_ERROR_MUTEX_WAKE_EVENT = SE_INTERNAL_ERROR(0x3003), +} se_status_internal_t; + +#endif diff --git a/common/inc/internal/se_event.h b/common/inc/internal/se_event.h new file mode 100644 index 0000000000..3672fd3246 --- /dev/null +++ b/common/inc/internal/se_event.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_EVENT_H_ +#define _SE_EVENT_H_ + +# include +# include +# include +typedef void * se_handle_t; + +#include "sgx_defs.h" + +#define SE_MUTEX_SUCCESS 0x0 +#define SE_MUTEX_INVALID 0x1 +#define SE_MUTEX_ERROR_WAKE 0x2 +#define SE_MUTEX_ERROR_WAIT 0x3 + +#ifdef __cplusplus +extern "C" { +#endif + +se_handle_t SGXAPI se_event_init(void); +void SGXAPI se_event_destroy(se_handle_t); + +int SGXAPI se_event_wait(se_handle_t); +int SGXAPI se_event_wake(se_handle_t); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/se_lock.hpp b/common/inc/internal/se_lock.hpp new file mode 100644 index 0000000000..68aedf2cf5 --- /dev/null +++ b/common/inc/internal/se_lock.hpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* This file implement lock guard */ + +#ifndef SE_LOCK_HPP +#define SE_LOCK_HPP + +#include "util.h" +#include "se_thread.h" +#include "uncopyable.h" + +class Mutex: private Uncopyable +{ +public: + Mutex(){se_mutex_init(&m_mutex);} + ~Mutex(){se_mutex_destroy(&m_mutex);} + void lock(){se_mutex_lock(&m_mutex);} + void unlock(){se_mutex_unlock(&m_mutex);} +private: + se_mutex_t m_mutex; +}; + +class LockGuard: private Uncopyable +{ +public: + LockGuard(Mutex* mutex):m_mutex(mutex){m_mutex->lock();} + ~LockGuard(){m_mutex->unlock();} +private: + Mutex* m_mutex; +}; + +#endif diff --git a/common/inc/internal/se_macro.h b/common/inc/internal/se_macro.h new file mode 100644 index 0000000000..4b465ac71b --- /dev/null +++ b/common/inc/internal/se_macro.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + #ifndef SE_MACRO_H_ + #define SE_MACRO_H_ + +#ifndef SGX_HYPERV_ECO +#define SGX_HYPERV_ECO +#endif + + #endif \ No newline at end of file diff --git a/common/inc/internal/se_map.h b/common/inc/internal/se_map.h new file mode 100644 index 0000000000..2b1889a838 --- /dev/null +++ b/common/inc/internal/se_map.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_MAP_H_ +#define _SE_MAP_H_ + +#include +#include +#include +#include + +#include "se_types.h" + +#include +#include +#include +#include +typedef int se_file_handle_t; + +typedef struct { + uint8_t* base_addr; /* pointer to the mapped area */ + size_t length; /* the length of the mapping */ +} map_handle_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Map a file to memory and get its size. */ +map_handle_t* map_file(se_file_handle_t fd, uint32_t *size); + +/* Unmap a mapped file. */ +void unmap_file(map_handle_t* mh); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/se_memcpy.h b/common/inc/internal/se_memcpy.h new file mode 100644 index 0000000000..f7cd259993 --- /dev/null +++ b/common/inc/internal/se_memcpy.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_MEMCPY_H_ +#define _SE_MEMCPY_H_ + +#include + + +/* memcpy_s always return 0 under Linux */ + +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif + +static inline errno_t memcpy_s(void *dest, size_t numberOfElements, const void *src, size_t count) +{ + if(numberOfElements +#include +#include +#include + +#ifndef MEM_COMMIT +#define MEM_COMMIT 0x1000 +#endif + +#ifndef MEM_RESERVE +#define MEM_RESERVE 0x2000 +#endif + +#ifdef MEM_RELEASE +#warning "MEM_RELEASE define conflict" +#else +#define MEM_RELEASE 0x8000 +#endif + +#ifdef MEM_DECOMMIT +#warning "MEM_DECOMMIT define conflict" +#else +#define MEM_DECOMMIT 0x4000 +#endif + +#include "se_types.h" +#include "arch.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +Reserves or commits a region of pages in the virtual address space of the calling process. +Memory allocated by this function is automatically initialized to zero, unless MEM_RESET is specified. +@address: the starting address of the region to allocate. +@size: size of region in bytes. +@type: Only MEM_COMMIT accepted. + MEM_COMMIT - Allocates memory charges for the specified reserved memory pages. + Actual physical pages are not allocated until the virtual addresses are actually accessed. + The function initializes the memory to zero. +@return value: If the function succeeds, the return value is the base address of the allocated region of pages. + If the function fails, the return value is NULL. +*/ +void* se_virtual_alloc(void* address, size_t size, uint32_t type); +/* +Releases, decommits, or releases and decommits a region of pages within the virtual address space of the calling process. +@address:A pointer to the base address of the region of pages to be freed. If the dwFreeType parameter is MEM_RELEASE, + this parameter must be the base address returned by the se_virtual_alloc function when the region of pages is reserved. +@size: The size of the region of memory to be freed, in bytes. +@type: Only MEM_RELEASE accepted + MEM_RELEASE - releases the specified region of pages. After this operation, the pages are in the free state. +@return value:If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. +*/ +int se_virtual_free(void* address, size_t size, uint32_t type); +/* +Locks the specified region of the process's virtual address space into physical memory, ensuring that subsequent access to the region will not incur a page fault. +@address: A pointer to the base address of the region of pages to be locked. + The region of affected pages includes all pages that contain one or more bytes in the range from the address parameter to (address+size). +@size: The size of the region to be locked, in bytes. +@return value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. +*/ +int se_virtual_lock(void* address, size_t size); +/* +Changes the protection on a region of committed pages in the virtual address space of the calling process. +@address: A pointer an address that describes the starting page of the region of pages whose access protection attributes are to be changed. +@size: The size of the region whose access protection attributes are to be changed, in bytes. +@prot: The memory protection option. The option can be SI_FLAG_R, SI_FLAG_W, SI_FLAG_X. +@return value: If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. +*/ + +#define SGX_PROT_NONE PROT_NONE + +int se_virtual_protect(void* address, size_t size, uint32_t prot); + + +#include +#include +#include +#include +typedef pid_t se_proc_t; + +/* +@return value: on success, return TRUE else return FALSE +*/ +se_proc_t get_self_proc(void); +/* +** If the function succeeds, the return value is nonzero. +** If the function fails, the return value is zero. +*/ +int put_self_proc(se_proc_t proc); +int se_read_process_mem(se_proc_t proc, void* base_addr, void* buffer, size_t size, size_t* read_nr); +int se_write_process_mem(se_proc_t proc, void* base_addr, void* buffer, size_t size, size_t* write_ndr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/se_page_attr.h b/common/inc/internal/se_page_attr.h new file mode 100644 index 0000000000..9bafac8af5 --- /dev/null +++ b/common/inc/internal/se_page_attr.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_PAGE_ATTR_H_ +#define _SE_PAGE_ATTR_H_ + +typedef enum +{ + DoEADD = 0, + DoEEXTEND, +} ATTRIBUTE_BITS_t; + +typedef enum +{ + ADD_PAGE_ONLY = 1< + +typedef pthread_rwlock_t se_rwlock_t; +typedef pthread_rwlock_t* se_prwlock_t; + +#ifdef __cplusplus +extern "C" { +#endif + +void se_wtlock(se_prwlock_t); +void se_wtunlock(se_prwlock_t); +int se_try_rdlock(se_prwlock_t); +void se_rdlock(se_prwlock_t lock); +void se_rdunlock(se_prwlock_t); +void se_init_rwlock(se_prwlock_t lock); +void se_fini_rwlock(se_prwlock_t lock); + +#ifdef __cplusplus +} +#endif + +#endif /* _RWLOCK_H_ */ diff --git a/common/inc/internal/se_stdio.h b/common/inc/internal/se_stdio.h new file mode 100644 index 0000000000..9f5dc3adab --- /dev/null +++ b/common/inc/internal/se_stdio.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef SE_STDIO_H +#define SE_STDIO_H + +#include +#include +#include "se_memcpy.h" +#include +#include +#include +#include +#include + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif + +static inline int se_delete_file(const char *path_name) +{ + return unlink(path_name); +} + +#define se_delete_tfile se_delete_file + +static inline int sprintf_s(char *dst_buf, size_t size_in_bytes, const char *format, ...) +{ + va_list argptr; + int cnt; + va_start(argptr, format); + cnt = vsnprintf(dst_buf, size_in_bytes, format, argptr); + va_end(argptr); + return cnt; +} + +static inline int _snprintf_s(char *dst_buf, size_t size_in_bytes, size_t max_count, const char *format, ...) +{ + (void) size_in_bytes; + va_list argptr; + int cnt; + va_start(argptr, format); + cnt = vsnprintf(dst_buf, max_count, format, argptr); + va_end(argptr); + return cnt; +} + +static inline errno_t fopen_s(FILE **f, const char *filename, const char *mode) +{ + errno_t err = 0; + *f = fopen(filename, mode); + if(*f==NULL){ + err = -1; + } + return err; +} + +static inline int se_copy_file(const char *dst_name, const char *src_name) +{ + int dest = -1; + int source = -1; + ssize_t nr_read; + struct stat stat_buf; + +#ifndef BUF_SIZE +#define BUF_SIZE 4096 +#endif + char buf[BUF_SIZE]; + + /* open the input file */ + source = open(src_name, O_RDONLY); + if(source < 0) + goto error; + + /* get size and permissions of the prebuild DB file */ + if (fstat(source, &stat_buf) != 0) + goto error; + + dest = open(dst_name, O_WRONLY|O_CREAT|O_TRUNC, stat_buf.st_mode); + if(dest < 0) + goto error; + + while ((nr_read = read(source, buf, BUF_SIZE)) > 0) + { + if (write(dest, buf, nr_read) != nr_read) + goto error; + } +#undef BUF_SIZE + + close(dest); + close(source); + return 0; + +error: + if(dest>=0)close(dest); + if(source>=0)close(source); + return -1; +} + +#ifdef __cplusplus +template +int sprintf_s(char (&dst)[_Size], const char *format, ...) +{ + va_list argptr; + int cnt; + va_start(argptr, format); + cnt = vsprintf(dst, format, argptr); + va_end(argptr); + return cnt; +} + +template +int _snprintf_s(char (&dst)[_Size], size_t max_count, const char *format, ...) +{ + va_list argptr; + int cnt; + va_start(argptr, format); + cnt = vsnprintf(dst, max_count, format, argptr); + va_end(argptr); + return cnt; +} + +#endif + +#endif diff --git a/common/inc/internal/se_string.h b/common/inc/internal/se_string.h new file mode 100644 index 0000000000..e5185617df --- /dev/null +++ b/common/inc/internal/se_string.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_STRING_H_ +#define _SE_STRING_H_ + +#include "se_memcpy.h" +#include + + +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif + +static inline errno_t strcat_s(char *dst, size_t max_size, const char *src) +{ + if(strlen(dst)+strlen(src)+1>max_size)return -1; + strcat(dst, src); + return 0; +} + +static inline errno_t strcpy_s(char *dst, size_t max_size, const char *src) +{ + if(strnlen(src, max_size)+1>max_size)return -1; + strcpy(dst, src); + return 0; +} + +#define _strnicmp strncasecmp +static inline errno_t strncat_s(char *dst, size_t max_size, const char *src, size_t max_count) +{ + size_t len = strnlen(src,max_count); + len+=strnlen(dst, max_size)+1; + if(len>max_size)return -1; + strncat(dst, src, max_count); + return 0; +} + +#define _strdup strdup +#define strnlen_s strnlen + + + +#endif diff --git a/common/inc/internal/se_thread.h b/common/inc/internal/se_thread.h new file mode 100644 index 0000000000..d6432b80b1 --- /dev/null +++ b/common/inc/internal/se_thread.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _SE_THREAD_H_ +#define _SE_THREAD_H_ + + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE /* for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */ +#endif +#include +#include +#include +#include +typedef pthread_mutex_t se_mutex_t; +typedef pid_t se_thread_id_t; +typedef pthread_key_t se_tls_index_t; + +#ifdef __cplusplus +extern "C" { +#endif +/* +@mutex: A pointer to the critical section object. +@return value: If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. +*/ +void se_mutex_init(se_mutex_t* mutex); +int se_mutex_lock(se_mutex_t* mutex); +int se_mutex_unlock(se_mutex_t* mutex); +int se_mutex_destroy(se_mutex_t* mutex); + +unsigned int se_get_threadid(void); + +/* tls functions */ +int se_tls_alloc(se_tls_index_t *tls_index); +int se_tls_free(se_tls_index_t tls_index); +void * se_tls_get_value(se_tls_index_t tls_index); +int se_tls_set_value(se_tls_index_t tls_index, void *tls_value); + +/* se_thread_handle_t se_create_thread(size_t stack_size, thread_start_routine_t start_routine, void *param, se_thread_t* thread); */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/se_time.h b/common/inc/internal/se_time.h new file mode 100644 index 0000000000..d1492021ea --- /dev/null +++ b/common/inc/internal/se_time.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_TIME_H_ +#define _SE_TIME_H_ + +#include "se_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +*@milli_seconds: the time range for sleep. It is milliseconds. +*/ +void se_sleep(uint32_t milli_seconds); +uint64_t se_get_tick_count_freq(void); +uint64_t se_get_tick_count(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/se_trace.h b/common/inc/internal/se_trace.h new file mode 100644 index 0000000000..68967939d7 --- /dev/null +++ b/common/inc/internal/se_trace.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + *This file wrapper some trace output. +*/ + +#ifndef _SE_DEBUG_H_ +#define _SE_DEBUG_H_ + +#include +#include + +typedef enum +{ + SE_TRACE_ERROR, + SE_TRACE_WARNING, + SE_TRACE_NOTICE, + SE_TRACE_DEBUG +} se_trace_t; + +#ifndef SE_DEBUG_LEVEL +/* Each module need define their own SE_DEBUG_LEVEL */ +#define SE_DEBUG_LEVEL SE_TRACE_ERROR +#endif + +#ifdef __cplusplus +extern "C" { +#endif +int se_trace_internal(int debug_level, const char *fmt, ...); + +#ifdef __cplusplus +} +#endif + +/* For libraries, we usually define DISABLE_TRACE to disable any trace. */ +/* For apps, we usually enable trace. */ +#ifdef DISABLE_TRACE +#define SE_TRACE(...) +#define se_trace(...) +#else /* DISABLE_TRACE */ +#define se_trace(debug_level, fmt, ...) \ + do { \ + if(debug_level <= SE_DEBUG_LEVEL) \ + se_trace_internal(debug_level, fmt, ##__VA_ARGS__); \ + }while(0) + +/* For compatibility, SE_TRACE/se_trace is used in old code. */ +/* New code should use SE_TRACE_DEBUG, SE_TRACE_NOTICE, SE_TRACE_WARNING, SE_TRACE_ERROR */ +#define SE_TRACE(debug_level, fmt, ...) \ + se_trace(debug_level, "[%s %s:%d] " fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) +#endif/* DISABLE_TRACE */ + +/* SE_TRACE_DEBUG and SE_TRACE_NOTICE print the debug information plus message. */ +#define SE_TRACE_DEBUG(fmt, ...) se_trace(SE_TRACE_DEBUG, "[%s %s:%d] " fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) +#define SE_TRACE_NOTICE(fmt, ...) se_trace(SE_TRACE_NOTICE, "[%s %s:%d] " fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) +/* SE_TRACE_WARNING and SE_TRACE_ERROR only print message. */ +#define SE_TRACE_WARNING(fmt, ...) se_trace(SE_TRACE_WARNING, fmt, ##__VA_ARGS__) +#define SE_TRACE_ERROR(fmt, ...) se_trace(SE_TRACE_ERROR, fmt, ##__VA_ARGS__) + +#endif diff --git a/common/inc/internal/se_types.h b/common/inc/internal/se_types.h new file mode 100644 index 0000000000..c3b29e047a --- /dev/null +++ b/common/inc/internal/se_types.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * This file is to define some types that is platform independent. +*/ + +#ifndef _SE_TYPE_H_ +#define _SE_TYPE_H_ +#include "se_cdefs.h" + +#ifdef SE_DRIVER + +typedef INT8 int8_t; +typedef UINT8 uint8_t; +typedef INT16 int16_t; +typedef UINT16 uint16_t; +typedef INT32 int32_t; +typedef UINT32 uint32_t; +typedef INT64 int64_t; +typedef UINT64 uint64_t; + +#else + +#include +#include + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#endif + +#if defined(SE_64) + +#define PADDED_POINTER(t, p) t* p +#define PADDED_DWORD(d) uint64_t d +#define PADDED_LONG(l) int64_t l +#define REG(name) r##name +#ifdef SE_SIM_EXCEPTION +#define REG_ALIAS(name) R##name +#endif +#define REGISTER(name) uint64_t REG(name) + +#else /* !defined(SE_64) */ + +#define PADDED_POINTER(t, p) t* p; void* ___##p##_pad_to64_bit +#define PADDED_DWORD(d) uint32_t d; uint32_t ___##d##_pad_to64_bit +#define PADDED_LONG(l) int32_t l; int32_t ___##l##_pad_to64_bit + +#define REG(name) e##name + +#ifdef SE_SIM_EXCEPTION +#define REG_ALIAS(name) E##name +#endif + +#define REGISTER(name) uint32_t REG(name); uint32_t ___##e##name##_pad_to64_bit + +#endif /* !defined(SE_64) */ + +#endif diff --git a/common/inc/internal/se_vendor.h b/common/inc/internal/se_vendor.h new file mode 100644 index 0000000000..ce2f1674bc --- /dev/null +++ b/common/inc/internal/se_vendor.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_VENDOR_H_ +#define _SE_VENDOR_H_ + +#define INTEL_VENDOR_ID 0x8086 +#define AE_PRODUCT_ID 0x1 + +#endif diff --git a/common/inc/internal/se_version.h b/common/inc/internal/se_version.h new file mode 100644 index 0000000000..b7bf1bb4a0 --- /dev/null +++ b/common/inc/internal/se_version.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define STRFILEVER "1.5.80.33399" + diff --git a/common/inc/internal/se_wrapper.h b/common/inc/internal/se_wrapper.h new file mode 100644 index 0000000000..0edf25d8be --- /dev/null +++ b/common/inc/internal/se_wrapper.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + *This file wrapper all the head file that is platform dependent. +*/ +#ifndef _SE_WRAPPER_H_ +#define _SE_WRAPPER_H_ + +#include "se_cdefs.h" +#include "se_types.h" +#include "se_thread.h" +#include "se_trace.h" +#include "se_time.h" +#include "se_event.h" +#include "se_rwlock.h" +#include "se_atomic.h" +#include "se_memcpy.h" +#include "se_string.h" +#include "se_stdio.h" + +#endif diff --git a/common/inc/internal/sgx_memset_s.h b/common/inc/internal/sgx_memset_s.h new file mode 100644 index 0000000000..64956b384a --- /dev/null +++ b/common/inc/internal/sgx_memset_s.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SE_MEMSET_S_H +#define _SE_MEMSET_S_H +#include +#ifdef __cplusplus +extern "C" +#endif +int memset_s(void *s, size_t smax, int c, size_t n); + +#endif diff --git a/common/inc/internal/sgx_profile.h b/common/inc/internal/sgx_profile.h new file mode 100644 index 0000000000..3c83d1a396 --- /dev/null +++ b/common/inc/internal/sgx_profile.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* +Some notes for using the profiling macros + +1. Define _PROFILE_ before including "sgx_profile.h" will enable the profiling, + also need to include sgx_profile.cpp in the compiling process +2. When use it in multi-threaded application, please don't trigger profiling in multiple threads at the same time. + The implementation is not thread-safe now, to avoid additional latency introduced by locks +3. PROFILE_OUTPUT macro should only be used once before application exits +4. PROFILE_START and PROFILE_END should be paired, otherwise PROFILE_OUTPUT will abort the program when detects the mismatch + +A simple example to use PROFILE macro + +#define _PROFILE_ +#include "sgx_profile.h" + +... +PROFILE_INIT(); +... + +PROFILE_START("func1"); +func1(); +PROFILE_END("func1"); + +... + +PROFILE_START("func2"); +func2(); +PROFILE_END("func2"); + +... + +PROFILE_OUTPUT("C:\\work\\output.csv"); +... +*/ + + +#ifndef _SGX_PROFILE_H_ +#define _SGX_PROFILE_H_ + + +#if defined(_PROFILE_) +#define PRO_START 0 +#define PRO_END 1 + +#if defined(__cplusplus) +extern "C" +{ +#endif + +void profile_init(); +void profile_start(const char* str); /* 'str' must be global string. Do not use string in stack. */ +void profile_end(const char * str); +void profile_output(const char* filename); + +#if defined(__cplusplus) +} +#endif + +#define PROFILE_INIT() profile_init() +#define PROFILE_START(x) profile_start(x) +#define PROFILE_END(x) profile_end(x) +#define PROFILE_OUTPUT(x) profile_output(x) + +#else +#define PROFILE_INIT() +#define PROFILE_START(x) +#define PROFILE_END(x) +#define PROFILE_OUTPUT(x) +#endif + + +#endif diff --git a/common/inc/internal/sgx_read_rand.h b/common/inc/internal/sgx_read_rand.h new file mode 100644 index 0000000000..05d79861f3 --- /dev/null +++ b/common/inc/internal/sgx_read_rand.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __SGX_READ_RAND_H__ +#define __SGX_READ_RAND_H__ +#include "sgx.h" +#include "sgx_defs.h" +#ifdef __cplusplus +extern "C" +#endif +sgx_status_t SGXAPI sgx_read_rand(unsigned char *buf, size_t size); +#endif diff --git a/common/inc/internal/sgx_tcrypto_internal.h b/common/inc/internal/sgx_tcrypto_internal.h new file mode 100644 index 0000000000..666b36125a --- /dev/null +++ b/common/inc/internal/sgx_tcrypto_internal.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_TCRYPTO_INTERNAL_H_ +#define _SGX_TCRYPTO_INTERNAL_H_ + +#include "sgx_tcrypto.h" + +typedef struct _sgx_ec256_dh_shared512_t +{ + uint8_t x[SGX_ECP256_KEY_SIZE]; + uint8_t y[SGX_ECP256_KEY_SIZE]; +} sgx_ec256_dh_shared512_t; + +#ifdef __cplusplus +extern "C" { +#endif + + /* Computes 512-bit DH shared key based on private B key (local) and remote public Ga Key + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system + * sgx_ec256_private_t *p_private_b - Pointer to the local private key + * sgx_ec256_public_t *p_public_ga - Pointer to the remote public key + * Output: sgx_ec256_dh_shared512_t *p_shared_key - Pointer to the 512-bit shared DH key + */ + sgx_status_t SGXAPI sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b, + sgx_ec256_public_t *p_public_ga, + sgx_ec256_dh_shared512_t *p_shared_key, + sgx_ecc_state_handle_t ecc_handle); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/tae_service_internal.h b/common/inc/internal/tae_service_internal.h new file mode 100644 index 0000000000..948402c2bd --- /dev/null +++ b/common/inc/internal/tae_service_internal.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _TAE_SERVICE_INTERNAL_H_ +#define _TAE_SERVICE_INTERNAL_H_ + +#include +#include "sgx.h" +#include "arch.h" +#include "sgx_tae_service.h" +#include "pse_types.h" + +#pragma pack(push, 1) + +typedef struct _se_ps_sec_prop_desc_internal +{ + uint32_t desc_type; /* Type of this descriptor. Must be 0 */ + sgx_prod_id_t pse_prod_id; /* REPORT(PSE).ProdID */ + sgx_isv_svn_t pse_isvsvn; /* REPORT(PSE).ISVSVN */ + uint32_t pse_miscselect; /* REPORT(PSE).MISC_SELECT */ + uint32_t reserved1; /* For DESC_TYPE=0, MBZ */ + sgx_attributes_t pse_attributes; /* REPORT(PSE).ATTRIBUTES */ + sgx_measurement_t pse_mr_signer; /* REPORT(PSE).MRSIGNER */ + uint32_t reserved2[16]; + /*the following will be provided by PSE from CSE_SEC_PROP */ + cse_sec_prop_t cse_sec_prop; +} se_ps_sec_prop_desc_internal_t; + +se_static_assert(sizeof(se_ps_sec_prop_desc_internal_t) == sizeof(sgx_ps_sec_prop_desc_t)); + +#pragma pack(pop) + +#endif diff --git a/common/inc/internal/thread_data.h b/common/inc/internal/thread_data.h new file mode 100644 index 0000000000..da2bfe7abc --- /dev/null +++ b/common/inc/internal/thread_data.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _THREAD_DATA_H_ +#define _THREAD_DATA_H_ + +#include "se_types.h" +#include "se_cdefs.h" + +#ifdef TD_SUPPORT_MULTI_PLATFORM +/* To enable the SignTool to sign both 32/64-bit Enclave for ELF, + * we need to make the struct `thread_data_t' have a consistent + * definition for 32/64-bit compiler. + * + * We achieve it by forcing the compiler to check pre-defined macros + * `RTS_SYSTEM_WORDSIZE' + * + * |--------------------------+-------| + * | RTS_SYSTEM_WORDSIZE = 32 | ELF32 | + * |--------------------------+-------| + * | RTS_SYSTEM_WORDSIZE = 64 | ELF64 | + * + */ +# ifndef RTS_SYSTEM_WORDSIZE +# error RTS_SYSTEM_WORDSIZE should be pre-defined. +# endif + +/* Avoid to use `uintptr_t' in the struct `thread_data_t' and its members. */ +# if RTS_SYSTEM_WORDSIZE == 32 +typedef uint32_t sys_word_t; +# elif RTS_SYSTEM_WORDSIZE == 64 +typedef uint64_t sys_word_t; +# else +# error Invalid value for 'RTS_SYSTEM_WORDSIZE'. +# endif + +#else + +/* For uRTS, there is no need to define the macro 'TD_SUPPORT_MULTI_PLATFORM' */ +typedef size_t sys_word_t; + +/* SE_32 and SE_64 are defined in "se_cdefs.h" */ +# ifdef SE_32 +# define RTS_SYSTEM_WORDSIZE 32 +# elif defined(SE_64) +# define RTS_SYSTEM_WORDSIZE 64 +# else +# error Unknown system word size. +# endif + +#endif /* ! TD_SUPPORT_MULTI_PLATFORM */ + +/* The data structure currently is naturally aligned regardless of the value of + * RTS_SYSTEM_WORDSIZE. + * + * However, we need to take care when modifying the data structure in future. + */ + +typedef struct _thread_data_t +{ + sys_word_t self_addr; + sys_word_t last_sp; /* set by urts, relative to TCS */ + sys_word_t stack_base_addr; /* set by urts, relative to TCS */ + sys_word_t stack_limit_addr; /* set by urts, relative to TCS */ + sys_word_t first_ssa_gpr; /* set by urts, relative to TCS */ + sys_word_t stack_guard; /* GCC expects start_guard at 0x14 on x86 and 0x28 on x64 */ + + sys_word_t reserved; + sys_word_t ssa_frame_size; /* set by urts, in pages (se_ptrace.c needs to know its offset). */ + sys_word_t last_error; /* init to be 0. Used by trts. */ + +#ifdef TD_SUPPORT_MULTI_PLATFORM + sys_word_t m_next; /* next TD used by trusted thread library (of type "struct _thread_data *") */ +#else + struct _thread_data_t *m_next; +#endif + sys_word_t tls_addr; /* points to TLS pages */ + sys_word_t tls_array; /* points to TD.tls_addr relative to TCS */ +#ifdef TD_SUPPORT_MULTI_PLATFORM + sys_word_t exception_flag; /* mark how many exceptions are being handled */ +#else + intptr_t exception_flag; +#endif + sys_word_t cxx_thread_info[6]; +} thread_data_t; + +#ifdef __cplusplus +extern "C" { +#endif + +thread_data_t *get_thread_data(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/trts_inst.h b/common/inc/internal/trts_inst.h new file mode 100644 index 0000000000..09ed8ae9f5 --- /dev/null +++ b/common/inc/internal/trts_inst.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _TRTS_INST_H_ +#define _TRTS_INST_H_ + +#include "sgx.h" + +/* Attention: + * if the following alignment requirement changes, go to selib to + * review the memory allocation of sgx_create_report and sgx_get_key. + */ +#define TARGET_INFO_ALIGN_SIZE 512 +#define REPORT_DATA_ALIGN_SIZE 128 +#define REPORT_ALIGN_SIZE 512 +#define KEY_REQUEST_ALIGN_SIZE 512 +#define KEY_ALIGN_SIZE 16 + +#define BIT_ERROR(x) (1 << (x)) + +typedef enum _egetkey_status_t +{ + EGETKEY_SUCCESS = 0, + EGETKEY_INVALID_ATTRIBUTE = BIT_ERROR(1), + EGETKEY_INVALID_CPUSVN = BIT_ERROR(5), + EGETKEY_INVALID_ISVSVN = BIT_ERROR(6), + EGETKEY_INVALID_KEYNAME = BIT_ERROR(8), +} egetkey_status_t; + +#ifdef __cplusplus +extern "C" { +#endif + +void do_ereport(const sgx_target_info_t *target_info, const sgx_report_data_t *report_data, sgx_report_t *report); +int do_egetkey(const sgx_key_request_t *key_request, sgx_key_128bit_t *key); +uint32_t do_rdrand(uint32_t *rand); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/uae_service_internal.h b/common/inc/internal/uae_service_internal.h new file mode 100644 index 0000000000..75428cadef --- /dev/null +++ b/common/inc/internal/uae_service_internal.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _UAE_SERVICE_INTERNAL_H_ +#define _UAE_SERVICE_INTERNAL_H_ + +#include +#include "arch.h" +#include "sgx_urts.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * Function to get launch token of a enclave + * + * @param signature[in] Signature of enclave to be launched. + * @param attribute[in] Attribute of enclave to be launched. + * @param launch_token[out] Vontains launch token. + * @return if a launch token is generated,return SGX_SCCUESS, otherwise return general error code SGX_ERROR_SERVICE_UNAVAILABLE + * SGX_ERROR_SERVICE_TIMEOUT, or SGX_ERROR_SERVICE_INVALID_PRIVILEGE, SGX_ERROR_INVALID_PARAMETER + * to indicate special error condition. + */ +sgx_status_t SGXAPI get_launch_token(const enclave_css_t* signature, const sgx_attributes_t* attribute, sgx_launch_token_t* launch_token); + +/* Return SGX_SUCCESS on success */ +sgx_status_t create_session_ocall(uint32_t* sid, uint8_t* dh_msg1, uint32_t dh_msg1_size, uint32_t timeout); + +/* Return SGX_SUCCESS on success */ +sgx_status_t exchange_report_ocall(uint32_t sid, const uint8_t* dh_msg2, uint32_t dh_msg2_size, uint8_t* dh_msg3, uint32_t dh_msg3_size, uint32_t timeout); + +/* Return SGX_SUCCESS on success */ +sgx_status_t close_session_ocall(uint32_t sid, uint32_t timeout); + +/* Return SGX_SUCCESS on success */ +sgx_status_t invoke_service_ocall( + const uint8_t* pse_message_req, uint32_t pse_message_req_size, + uint8_t* pse_message_resp, uint32_t pse_message_resp_size, + uint32_t timeout + ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/internal/uncopyable.h b/common/inc/internal/uncopyable.h new file mode 100644 index 0000000000..b271953f79 --- /dev/null +++ b/common/inc/internal/uncopyable.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _UNCOPYABLE_H_ +#define _UNCOPYABLE_H_ + +/* Similiar to boost::noncopyable */ +class Uncopyable { +protected: + Uncopyable() {} + ~Uncopyable() {} + +private: + /* Disable copying */ + Uncopyable(const Uncopyable&); + Uncopyable& operator=(const Uncopyable&); +}; + +#endif diff --git a/common/inc/internal/util.h b/common/inc/internal/util.h new file mode 100644 index 0000000000..d26b2d9d10 --- /dev/null +++ b/common/inc/internal/util.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include "arch.h" +#include + +#ifdef __cplusplus +#define GET_PTR(t, p, offset) reinterpret_cast( reinterpret_cast(p) + static_cast(offset) ) +#define PTR_DIFF(p1, p2) ((reinterpret_cast(p1) - reinterpret_cast(p2))) +#else +#define GET_PTR(t, p, offset) (t*)( (size_t)(p) + (size_t)(offset) ) +#define PTR_DIFF(p1, p2) ((size_t)(p1) - (size_t)(p2)) +#endif + +#define DIFF(p1, p2) (assert((size_t)(p1) >= (size_t)(p2)), ((size_t)(p1) - (size_t)(p2))) +#define DIFF64(p1, p2) (assert((uint64_t)(p1) >= (uint64_t)(p2)), ((uint64_t)(p1) - (uint64_t)(p2))) + +#define SE_PAGE_SHIFT 12 +#define SE_BULK_PAGE_FRAME_SHIFT 4 +#define SE_BULK_PAGE_FRAME_SIZE (1 << SE_BULK_PAGE_FRAME_SHIFT) +#define SE_BULK_PAGE_FRAME_MASK (SE_BULK_PAGE_FRAME_SIZE-1) +#define SE_BULK_PAGE_SHIFT (SE_PAGE_SHIFT + SE_BULK_PAGE_FRAME_SHIFT) +#define SE_BULK_PAGE_SIZE (1 << SE_BULK_PAGE_SHIFT) +#define SE_GUARD_PAGE_SHIFT SE_PAGE_SHIFT +#define SE_GUARD_PAGE_SIZE SE_PAGE_SIZE + +#define ROUND_TO(x, align) (((x) + ((align)-1)) & ~((align)-1)) +#define ROUND_TO_PAGE(x) ROUND_TO(x, SE_PAGE_SIZE) +#define TRIM_TO_PAGE(x) ((x) & ~(SE_PAGE_SIZE-1)) +#ifdef __cplusplus +#define PAGE_ALIGN(t, x) reinterpret_cast((reinterpret_cast(x)+(SE_PAGE_SIZE-1)) & (~(SE_PAGE_SIZE-1))) +#else +#define PAGE_ALIGN(t, x) (t*)( ((size_t)(x)+(SE_PAGE_SIZE-1)) & (~(SE_PAGE_SIZE-1)) ) +#endif + +#define IS_PAGE_ALIGNED(x) (!((size_t)(x)&(SE_PAGE_SIZE-1))) + +#define MIN(x, y) (((x)>(y))?(y):(x)) +#define MAX(x, y) (((x)>(y))?(x):(y)) +#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0])) + +/* used to eliminate `unused variable' warning */ +#define UNUSED(val) (void)(val) + +#include +#define container_of(ptr, type, member) (type *)( (char *)(ptr) - offsetof(type,member) ) + +#endif diff --git a/common/inc/internal/xsave.h b/common/inc/internal/xsave.h new file mode 100644 index 0000000000..431d453542 --- /dev/null +++ b/common/inc/internal/xsave.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _XSAVE_H_ +#define _XSAVE_H_ + +#include "se_types.h" + + +#define XSAVE_ALIGN_SIZE 64 +#define FXSAVE_ALIGN_SIZE 16 +#define FXSAVE_SIZE 528 +/* 512 + 16, the alignment is handled in internal functions */ + +#define CLEAN_XFEATURE_REGS save_and_clean_xfeature_regs(NULL); + +#ifdef __cplusplus +extern "C" { +#endif + +#include "linux/xsave_gnu.h" + +/* implemented in urts_xsave.cpp/trts_xsave.cpp */ +void save_and_clean_xfeature_regs(uint8_t *buffer); +void restore_xfeature_regs(const uint8_t *buffer); + +/* trts_xsave.cpp */ +uint64_t get_xfeature_state(); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx.h b/common/inc/sgx.h new file mode 100644 index 0000000000..7695c65d04 --- /dev/null +++ b/common/inc/sgx.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_H_ +#define _SGX_H_ + +#include "sgx_error.h" +#include "sgx_attributes.h" +#include "sgx_key.h" +#include "sgx_report.h" + +#endif diff --git a/common/inc/sgx_attributes.h b/common/inc/sgx_attributes.h new file mode 100644 index 0000000000..398621e5b0 --- /dev/null +++ b/common/inc/sgx_attributes.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_ATTRIBUTES_H_ +#define _SGX_ATTRIBUTES_H_ + +#include + +/* Enclave Flags Bit Masks */ +#define SGX_FLAGS_INITTED 0x0000000000000001ULL /* If set, then the enclave is initialized */ +#define SGX_FLAGS_DEBUG 0x0000000000000002ULL /* If set, then the enclave is debug */ +#define SGX_FLAGS_MODE64BIT 0x0000000000000004ULL /* If set, then the enclave is 64 bit */ +#define SGX_FLAGS_PROVISION_KEY 0x0000000000000010ULL /* If set, then the enclave has access to provision key */ +#define SGX_FLAGS_LICENSE_KEY 0x0000000000000020ULL /* If set, then the enclave has access to License key */ +#define SGX_FLAGS_RESERVED (~(SGX_FLAGS_INITTED | SGX_FLAGS_DEBUG | SGX_FLAGS_MODE64BIT | SGX_FLAGS_PROVISION_KEY | SGX_FLAGS_LICENSE_KEY)) + +/* XSAVE Feature Request Mask */ +#define SGX_XFRM_LEGACY 0x0000000000000003ULL /* Legacy XFRM */ +#define SGX_XFRM_AVX 0x0000000000000006ULL /* AVX */ +#define SGX_XFRM_AVX512 0x00000000000000E6ULL /* AVX-512 - not supported */ +#define SGX_XFRM_MPX 0x0000000000000018ULL /* MPX - not supported */ + +#define SGX_XFRM_RESERVED (~(SGX_XFRM_LEGACY | SGX_XFRM_AVX)) + +typedef struct _attributes_t +{ + uint64_t flags; + uint64_t xfrm; +} sgx_attributes_t; + +/* define MISCSELECT - all bits are currently reserved */ +typedef uint32_t sgx_misc_select_t; + +typedef struct _sgx_misc_attribute_t { + sgx_attributes_t secs_attr; + sgx_misc_select_t misc_select; +} sgx_misc_attribute_t; + +#endif/* _SGX_ATTRIBUTES_H_ */ diff --git a/common/inc/sgx_cpuid.h b/common/inc/sgx_cpuid.h new file mode 100644 index 0000000000..2d4221280b --- /dev/null +++ b/common/inc/sgx_cpuid.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +/** + * File: sgx_cpuid.h + * Description: + * Enquire CPU capabilities via OCALLs. + */ + +#ifndef _SGX_CPUID_H_ +#define _SGX_CPUID_H_ + +#include "sgx_defs.h" +#include "sgx_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +sgx_status_t SGXAPI sgx_cpuid(int cpuinfo[4], int leaf); +sgx_status_t SGXAPI sgx_cpuidex(int cpuinfo[4], int leaf, int subleaf); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_defs.h b/common/inc/sgx_defs.h new file mode 100644 index 0000000000..4b0a658283 --- /dev/null +++ b/common/inc/sgx_defs.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_DEFS_H_ +#define _SGX_DEFS_H_ + +/* The following macros are for GCC only */ + +# define SGXAPI + +# ifdef linux +# undef linux +# endif +# define SGX_CXX_NATIVE_HEADER(header) + +# define SGX_CDECL +# define SGX_STDCALL +# define SGX_FASTCALL + +# define SGX_DLLIMPORT +# define SGX_UBRIDGE(attr, fname, args...) attr fname args + + +#define SGX_NOCONVENTION /* Empty. No calling convention specified. */ + +#endif /* !_SGX_DEFS_H_ */ diff --git a/common/inc/sgx_dh.h b/common/inc/sgx_dh.h new file mode 100644 index 0000000000..9860271a0b --- /dev/null +++ b/common/inc/sgx_dh.h @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _SGX_DH_H_ +#define _SGX_DH_H_ + +#include "sgx.h" +#include "sgx_defs.h" +#include "sgx_ecp_types.h" + +#pragma pack(push, 1) + +#define SGX_DH_MAC_SIZE 16 + +#define SGX_DH_SESSION_DATA_SIZE 200 + +typedef struct _sgx_dh_msg1_t +{ + sgx_ec256_public_t g_a; /* the Endian-ness of Ga is Little-Endian */ + sgx_target_info_t target; +} sgx_dh_msg1_t; + +typedef struct _sgx_dh_msg2_t +{ + sgx_ec256_public_t g_b; /* the Endian-ness of Gb is Little-Endian */ + sgx_report_t report; + uint8_t cmac[SGX_DH_MAC_SIZE]; +} sgx_dh_msg2_t; + +typedef struct _sgx_dh_msg3_body_t +{ + sgx_report_t report; + uint32_t additional_prop_length; + uint8_t additional_prop[0]; +} sgx_dh_msg3_body_t; + + +typedef struct _sgx_dh_msg3_t +{ + uint8_t cmac[SGX_DH_MAC_SIZE]; + sgx_dh_msg3_body_t msg3_body; +} sgx_dh_msg3_t; + +typedef struct _sgx_dh_session_enclave_identity_t +{ + sgx_cpu_svn_t cpu_svn; + sgx_misc_select_t misc_select; + uint8_t reserved_1[28]; + sgx_attributes_t attributes; + sgx_measurement_t mr_enclave; + uint8_t reserved_2[32]; + sgx_measurement_t mr_signer; + uint8_t reserved_3[96]; + sgx_prod_id_t isv_prod_id; + sgx_isv_svn_t isv_svn; +} sgx_dh_session_enclave_identity_t; + +typedef enum _sgx_dh_session_role_t +{ + SGX_DH_SESSION_INITIATOR, + SGX_DH_SESSION_RESPONDER +} sgx_dh_session_role_t; + +typedef struct _sgx_dh_session_t +{ + uint8_t sgx_dh_session[SGX_DH_SESSION_DATA_SIZE]; +} sgx_dh_session_t; +#pragma pack(pop) +#ifdef __cplusplus +extern "C" { +#endif + +/* The order of calling SGX DH Library APIs is restricted as below */ +/* As session initiator : Step.1 sgx_dh_init_session --> Step.2 sgx_dh_initiator_proc_msg1 --> Step.3 sgx_dh_initiator_proc_msg3 */ +/* As session responder : Step.1 sgx_dh_init_session --> Step.2 sgx_dh_responder_gen_msg1 --> Step.3 sgx_dh_responder_proc_msg2*/ +/* Any out of order calling will cause session establishment failure. */ + +/*Function name: sgx_dh_init_session +** parameter description +**@ [input] role: caller's role in dh session establishment +**@ [output] session: point to dh session structure that is used during establishment, the buffer must be in enclave address space +*/ +sgx_status_t SGXAPI sgx_dh_init_session(sgx_dh_session_role_t role, + sgx_dh_session_t* session); +/*Function name: sgx_dh_responder_gen_msg1 +** parameter description +**@ [output] msg1: point to dh message 1 buffer, and the buffer must be in enclave address space +**@ [input/output] dh_session: point to dh session structure that is used during establishment, and the buffer must be in enclave address space +*/ +sgx_status_t SGXAPI sgx_dh_responder_gen_msg1(sgx_dh_msg1_t* msg1, + sgx_dh_session_t* dh_session); +/*Function name: sgx_dh_initiator_proc_msg1 +** parameter description +**@ [input] msg1: point to dh message 1 buffer generated by session responder, and the buffer must be in enclave address space +**@ [output] msg2: point to dh message 2 buffer, and the buffer must be in enclave address space +**@ [input/output] dh_session: point to dh session structure that is used during establishment, and the buffer must be in enclave address space +*/ +sgx_status_t SGXAPI sgx_dh_initiator_proc_msg1(const sgx_dh_msg1_t* msg1, + sgx_dh_msg2_t* msg2, + sgx_dh_session_t* dh_session); +/*Function name: sgx_dh_responder_proc_msg2 +** parameter description +**@ [input] msg2: point to dh message 2 buffer generated by session initiator, and the buffer must be in enclave address space +**@ [output] msg3: point to dh message 3 buffer generated by session responder in this function, and the buffer must be in enclave address space +**@ [input/output] dh_session: point to dh session structure that is used during establishment, and the buffer must be in enclave address space +**@ [output] aek: AEK derived from shared key. the buffer must be in enclave address space. +**@ [output] initiator_identity: identity information of initiator including isv svn, isv product id, sgx attributes, mr signer, and mr enclave. the buffer must be in enclave address space. +*/ +sgx_status_t SGXAPI sgx_dh_responder_proc_msg2(const sgx_dh_msg2_t* msg2, + sgx_dh_msg3_t* msg3, + sgx_dh_session_t* dh_session, + sgx_key_128bit_t* aek, + sgx_dh_session_enclave_identity_t* initiator_identity); +/*Function name: sgx_dh_initiator_proc_msg3 +** parameter description +**@ [input] msg3: point to dh message 3 buffer generated by session responder, and the buffer must be in enclave address space +**@ [input/output] dh_session: point to dh session structure that is used during establishment, and the buffer must be in enclave address space +**@ [output] aek: AEK derived from shared key. the buffer must be in enclave address space. +**@ [output] responder_identity: identity information of responder including isv svn, isv product id, sgx attributes, mr signer, and mr enclave. the buffer must be in enclave address space. +*/ +sgx_status_t SGXAPI sgx_dh_initiator_proc_msg3(const sgx_dh_msg3_t* msg3, + sgx_dh_session_t* dh_session, + sgx_key_128bit_t* aek, + sgx_dh_session_enclave_identity_t* responder_identity); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/common/inc/sgx_ecp_types.h b/common/inc/sgx_ecp_types.h new file mode 100644 index 0000000000..ef935d103b --- /dev/null +++ b/common/inc/sgx_ecp_types.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _SGX_ECP_TYPES_H_ +#define _SGX_ECP_TYPES_H_ + +#include + +#pragma pack(push, 1) + +#include "sgx_tcrypto.h" + +#ifndef SGX_FEBITSIZE +#define SGX_FEBITSIZE 256 +#endif + +typedef struct _ecc_param_t +{ + uint32_t eccP[SGX_NISTP_ECP256_KEY_SIZE]; /* EC prime field */ + uint32_t eccA[SGX_NISTP_ECP256_KEY_SIZE]; /* EC curve coefficient A */ + uint32_t eccB[SGX_NISTP_ECP256_KEY_SIZE]; /* EC curve coefficient B */ + uint32_t eccG[2][SGX_NISTP_ECP256_KEY_SIZE]; /* ECC base point */ + uint32_t eccR[SGX_NISTP_ECP256_KEY_SIZE]; /* ECC base point order */ +} sgx_ecc_param_t; + +typedef uint8_t sgx_ec_key_128bit_t[SGX_CMAC_KEY_SIZE]; + +#pragma pack(pop) + +#endif diff --git a/common/inc/sgx_edger8r.h b/common/inc/sgx_edger8r.h new file mode 100644 index 0000000000..f3da7873df --- /dev/null +++ b/common/inc/sgx_edger8r.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +/* + * Here contains functions intended to be used by `sgx_edger8r' only. + * + * ------------------------------------- + * Be warned: use them at your own risk. + * ------------------------------------- + * + */ + +#ifndef _SGX_EDGER8R_H_ +#define _SGX_EDGER8R_H_ + +#include "sgx_defs.h" +#include "sgx_error.h" +#include "sgx_eid.h" +#include /* for size_t */ + +/* The `sgx_edger8r' tool will generate C interfaces. */ +#ifdef __cplusplus +# define SGX_EXTERNC extern "C" +#else +# define SGX_EXTERNC +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* sgx_ocalloc() + * Parameters: + * size - bytes to allocate on the outside stack + * Return Value: + * the pointer to the allocated space on the outside stack + * NULL - fail to allocate +*/ +void* SGXAPI sgx_ocalloc(size_t size); + +/* sgx_ocfree() + * Parameters: + * N/A + * Return Value: + * N/A +*/ +void SGXAPI sgx_ocfree(void); + +/* sgx_ecall() + * Parameters: + * eid - the enclave id + * index - the index of the trusted function + * ocall_table - the address of the OCALL table + * ms - the pointer to the marshaling struct + * Return Value: + * SGX_SUCCESS on success +*/ +sgx_status_t SGXAPI sgx_ecall(const sgx_enclave_id_t eid, + const int index, + const void* ocall_table, + void* ms); + +/* sgx_ocall() + * Parameters: + * index - the index of the untrusted function + * ms - the pointer to the marshaling struct + * Return Value: + * SGX_SUCCESS on success +*/ +sgx_status_t SGXAPI sgx_ocall(const unsigned int index, + void* ms); + +#ifdef __cplusplus +} +#endif + +#endif /* !_SGX_EDGER8R_H_ */ diff --git a/common/inc/sgx_eid.h b/common/inc/sgx_eid.h new file mode 100644 index 0000000000..ea2dfc6e28 --- /dev/null +++ b/common/inc/sgx_eid.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_EID_H_ +#define _SGX_EID_H_ + +#include + +typedef uint64_t sgx_enclave_id_t; + +#endif diff --git a/common/inc/sgx_error.h b/common/inc/sgx_error.h new file mode 100644 index 0000000000..d093fd8a1e --- /dev/null +++ b/common/inc/sgx_error.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_ERROR_H_ +#define _SGX_ERROR_H_ + +#define SGX_MK_ERROR(x) (0x00000000|(x)) + +typedef enum _status_t +{ + SGX_SUCCESS = SGX_MK_ERROR(0x0000), + + SGX_ERROR_UNEXPECTED = SGX_MK_ERROR(0x0001), /* Unexpected error */ + SGX_ERROR_INVALID_PARAMETER = SGX_MK_ERROR(0x0002), /* The parameter is incorrect */ + SGX_ERROR_OUT_OF_MEMORY = SGX_MK_ERROR(0x0003), /* Not enough memory is available to complete this operation */ + SGX_ERROR_ENCLAVE_LOST = SGX_MK_ERROR(0x0004), /* Enclave lost after power transition or used in child process created by linux:fork() */ + SGX_ERROR_INVALID_STATE = SGX_MK_ERROR(0x0005), /* SGX API is invoked in incorrect order or state */ + + SGX_ERROR_INVALID_FUNCTION = SGX_MK_ERROR(0x1001), /* The ecall/ocall index is invalid */ + SGX_ERROR_OUT_OF_TCS = SGX_MK_ERROR(0x1003), /* The enclave is out of TCS */ + SGX_ERROR_ENCLAVE_CRASHED = SGX_MK_ERROR(0x1006), /* The enclave is crashed */ + SGX_ERROR_ECALL_NOT_ALLOWED = SGX_MK_ERROR(0x1007), /* The ECALL is not allowed at this time, e.g. ecall is blocked by the dynamic entry table, or nested ecall is not allowed during initialization */ + SGX_ERROR_OCALL_NOT_ALLOWED = SGX_MK_ERROR(0x1008), /* The OCALL is not allowed at this time, e.g. ocall is not allowed during exception handling */ + SGX_ERROR_STACK_OVERRUN = SGX_MK_ERROR(0x1009), /* The enclave is running out of stack */ + + SGX_ERROR_UNDEFINED_SYMBOL = SGX_MK_ERROR(0x2000), /* The enclave image has undefined symbol. */ + SGX_ERROR_INVALID_ENCLAVE = SGX_MK_ERROR(0x2001), /* The enclave image is not correct. */ + SGX_ERROR_INVALID_ENCLAVE_ID = SGX_MK_ERROR(0x2002), /* The enclave id is invalid */ + SGX_ERROR_INVALID_SIGNATURE = SGX_MK_ERROR(0x2003), /* The signature is invalid */ + SGX_ERROR_NDEBUG_ENCLAVE = SGX_MK_ERROR(0x2004), /* The enclave is signed as product enclave, and can not be created as debuggable enclave. */ + SGX_ERROR_OUT_OF_EPC = SGX_MK_ERROR(0x2005), /* Not enough EPC is available to load the enclave */ + SGX_ERROR_NO_DEVICE = SGX_MK_ERROR(0x2006), /* Can't open SGX device */ + SGX_ERROR_MEMORY_MAP_CONFLICT= SGX_MK_ERROR(0x2007), /* Page mapping failed in driver */ + SGX_ERROR_INVALID_METADATA = SGX_MK_ERROR(0x2009), /* The metadata is incorrect. */ + SGX_ERROR_DEVICE_BUSY = SGX_MK_ERROR(0x200c), /* Device is busy, mostly EINIT failed. */ + SGX_ERROR_INVALID_VERSION = SGX_MK_ERROR(0x200d), /* Metadata version is inconsistent between uRTS and sgx_sign or uRTS is incompatible with current platform. */ + SGX_ERROR_MODE_INCOMPATIBLE = SGX_MK_ERROR(0x200e), /* The target enclave 32/64 bit mode or sim/hw mode is incompatible with the mode of current uRTS. */ + SGX_ERROR_ENCLAVE_FILE_ACCESS = SGX_MK_ERROR(0x200f), /* Can't open enclave file. */ + SGX_ERROR_INVALID_MISC = SGX_MK_ERROR(0x2010), /* The MiscSelct/MiscMask settings are not correct.*/ + + SGX_ERROR_MAC_MISMATCH = SGX_MK_ERROR(0x3001), /* Indicates verification error for reports, sealed datas, etc */ + SGX_ERROR_INVALID_ATTRIBUTE = SGX_MK_ERROR(0x3002), /* The enclave is not authorized */ + SGX_ERROR_INVALID_CPUSVN = SGX_MK_ERROR(0x3003), /* The cpu svn is beyond platform's cpu svn value */ + SGX_ERROR_INVALID_ISVSVN = SGX_MK_ERROR(0x3004), /* The isv svn is greater than the enclave's isv svn */ + SGX_ERROR_INVALID_KEYNAME = SGX_MK_ERROR(0x3005), /* The key name is an unsupported value */ + + SGX_ERROR_SERVICE_UNAVAILABLE = SGX_MK_ERROR(0x4001), /* Indicates aesm didn't response or the requested service is not supported */ + SGX_ERROR_SERVICE_TIMEOUT = SGX_MK_ERROR(0x4002), /* The request to aesm time out */ + SGX_ERROR_AE_INVALID_EPIDBLOB = SGX_MK_ERROR(0x4003), /* Indicates epid blob verification error */ + SGX_ERROR_SERVICE_INVALID_PRIVILEGE = SGX_MK_ERROR(0x4004), /* Enclave has no privilege to get launch token */ + SGX_ERROR_EPID_MEMBER_REVOKED = SGX_MK_ERROR(0x4005), /* The EPID group membership is revoked. */ + SGX_ERROR_UPDATE_NEEDED = SGX_MK_ERROR(0x4006), /* SGX needs to be updated */ + SGX_ERROR_NETWORK_FAILURE = SGX_MK_ERROR(0x4007), /* Network connecting or proxy setting issue is encountered */ + SGX_ERROR_AE_SESSION_INVALID = SGX_MK_ERROR(0x4008), /* Session is invalid or ended by server */ + SGX_ERROR_BUSY = SGX_MK_ERROR(0x400a), /* The requested service is temporarily not availabe */ + SGX_ERROR_MC_NOT_FOUND = SGX_MK_ERROR(0x400c), /* The Monotonic Counter doesn't exist or has been invalided */ + SGX_ERROR_MC_NO_ACCESS_RIGHT = SGX_MK_ERROR(0x400d), /* Caller doesn't have the access right to specified VMC */ + SGX_ERROR_MC_USED_UP = SGX_MK_ERROR(0x400e), /* Monotonic counters are used out */ + SGX_ERROR_MC_OVER_QUOTA = SGX_MK_ERROR(0x400f), /* Monotonic counters exceeds quota limitation */ + SGX_ERROR_KDF_MISMATCH = SGX_MK_ERROR(0x4011), /* Key derivation function doesn't match during key exchange */ + +} sgx_status_t; + +#endif diff --git a/common/inc/sgx_intrin.h b/common/inc/sgx_intrin.h new file mode 100644 index 0000000000..237a1cd6f1 --- /dev/null +++ b/common/inc/sgx_intrin.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _SGX_INTRIN_H_ +#define _SGX_INTRIN_H_ + +#if defined(__STDC__) || defined(__cplusplus) +# define __STRING(x) #x +#else +# define __STRING(x) "x" +#endif + +#define _DEPR_MESSAGE(func) __STRING(func)" is deprecated in enclave." + +/* Deprecated GCC Built-ins */ + +# include + +/*#pragma GCC diagnostic error "-Wdeprecated-declarations" */ +#define _SGX_DEPRECATED(__ret_type, __func_name, ...) \ + __attribute__((deprecated(_DEPR_MESSAGE(__func_name)))) \ + __ret_type __func_name(__VA_ARGS__) + +_SGX_DEPRECATED(void, _writefsbase_u32, unsigned int); +_SGX_DEPRECATED(void, _writefsbase_u64, unsigned long long); +_SGX_DEPRECATED(void, _writegsbase_u32, unsigned int); +_SGX_DEPRECATED(void, _writegsbase_u64, unsigned long long); + +_SGX_DEPRECATED(unsigned long long, __rdpmc, int); +_SGX_DEPRECATED(unsigned long long, __rdtsc, void); +_SGX_DEPRECATED(unsigned long long, __rdtscp, unsigned int *); + + +#endif /* _SGX_INTRIN_H_ */ diff --git a/common/inc/sgx_key.h b/common/inc/sgx_key.h new file mode 100644 index 0000000000..7e040fb64c --- /dev/null +++ b/common/inc/sgx_key.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + + +/* + * This file is to define Enclave's keys +*/ + +#ifndef _SGX_KEY_H_ +#define _SGX_KEY_H_ + +#include +#include "sgx_attributes.h" + +/* Key Name */ +#define SGX_KEYSELECT_LICENSE 0x0000 +#define SGX_KEYSELECT_PROVISION 0x0001 +#define SGX_KEYSELECT_PROVISION_SEAL 0x0002 +#define SGX_KEYSELECT_REPORT 0x0003 +#define SGX_KEYSELECT_SEAL 0x0004 + +/* Key Policy */ +#define SGX_KEYPOLICY_MRENCLAVE 0x0001 /* Derive key using the enclave's ENCLAVE measurement register */ +#define SGX_KEYPOLICY_MRSIGNER 0x0002 /* Derive key using the enclave's SINGER measurement register */ + +#define SGX_KEYID_SIZE 32 +#define SGX_CPUSVN_SIZE 16 + +typedef uint8_t sgx_key_128bit_t[16]; +typedef uint16_t sgx_isv_svn_t; + +typedef struct _sgx_cpu_svn_t +{ + uint8_t svn[SGX_CPUSVN_SIZE]; +} sgx_cpu_svn_t; + +typedef struct _sgx_key_id_t +{ + uint8_t id[SGX_KEYID_SIZE]; +} sgx_key_id_t; + +#define SGX_KEY_REQUEST_RESERVED2_BYTES 436 + +typedef struct _key_request_t +{ + uint16_t key_name; /* Identifies the key required */ + uint16_t key_policy; /* Identifies which inputs should be used in the key derivation */ + sgx_isv_svn_t isv_svn; /* Security Version of the Enclave */ + uint16_t reserved1; /* Must be 0 */ + sgx_cpu_svn_t cpu_svn; /* Security Version of the CPU */ + sgx_attributes_t attribute_mask; /* Mask which ATTRIBUTES Seal keys should be bound to */ + sgx_key_id_t key_id; /* Value for key wear-out protection */ + sgx_misc_select_t misc_mask; /* Mask what MISCSELECT Seal keys bound to */ + uint8_t reserved2[SGX_KEY_REQUEST_RESERVED2_BYTES]; /* Struct size is 512 bytes */ +} sgx_key_request_t; + + +#endif diff --git a/common/inc/sgx_key_exchange.h b/common/inc/sgx_key_exchange.h new file mode 100644 index 0000000000..570945f013 --- /dev/null +++ b/common/inc/sgx_key_exchange.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_KEY_EXCHANGE_H_ +#define _SGX_KEY_EXCHANGE_H_ + +#include +#include "sgx_quote.h" +#include "sgx_ecp_types.h" +#include "sgx_tae_service.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint32_t sgx_ra_context_t; + +typedef sgx_key_128bit_t sgx_ra_key_128_t; + +typedef enum _ra_key_type_t +{ + SGX_RA_KEY_SK = 1, + SGX_RA_KEY_MK, + SGX_RA_KEY_VK, +} sgx_ra_key_type_t; + +typedef struct _ra_msg1_t +{ + sgx_ec256_public_t g_a; /* the Endian-ness of Ga is Little-Endian */ + sgx_epid_group_id_t gid; /* the Endian-ness of GID is Little-Endian */ +} sgx_ra_msg1_t; + + +typedef struct _ra_msg2_t +{ + sgx_ec256_public_t g_b; /* the Endian-ness of Gb is Little-Endian */ + sgx_spid_t spid; + uint16_t quote_type; /* unlinkable Quote(0) or linkable Quote(1) in little endian*/ + uint16_t kdf_id; /* key derivation function id in little endian. */ + sgx_ec256_signature_t sign_gb_ga; /* In little endian */ + sgx_mac_t mac; /* mac_smk(g_b||spid||quote_type||kdf_id||sign_gb_ga) */ + uint32_t sig_rl_size; + uint8_t sig_rl[]; +} sgx_ra_msg2_t; + +typedef struct _ra_msg3_t +{ + sgx_mac_t mac; /* mac_smk(g_a||ps_sec_prop||quote) */ + sgx_ec256_public_t g_a; /* the Endian-ness of Ga is Little-Endian */ + sgx_ps_sec_prop_desc_t ps_sec_prop; + uint8_t quote[]; +} sgx_ra_msg3_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_quote.h b/common/inc/sgx_quote.h new file mode 100644 index 0000000000..06a6ae6c60 --- /dev/null +++ b/common/inc/sgx_quote.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + + /** + * File: sgx_quote.h + * Description: Definition for quote structure. + * + * Quote structure and all relative structure will be defined in this file. + */ + +#ifndef _SGX_QUOTE_H_ +#define _SGX_QUOTE_H_ + +#include "sgx_report.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma pack(push, 1) +typedef uint8_t sgx_epid_group_id_t[4]; + +typedef struct _spid_t +{ + uint8_t id[16]; +} sgx_spid_t; + +typedef struct _basename_t +{ + uint8_t name[32]; +} sgx_basename_t; + + +typedef struct _quote_nonce +{ + uint8_t rand[16]; +} sgx_quote_nonce_t; + +typedef enum +{ + SGX_UNLINKABLE_SIGNATURE, + SGX_LINKABLE_SIGNATURE +} sgx_quote_sign_type_t; + +typedef struct _quote_t +{ + uint16_t version; /* 0 */ + uint16_t sign_type; /* 2 */ + sgx_epid_group_id_t epid_group_id; /* 4 */ + sgx_isv_svn_t qe_svn; /* 8 */ + uint8_t reserved[6]; /* 10 */ + sgx_basename_t basename; /* 16 */ + sgx_report_body_t report_body; /* 48 */ + uint32_t signature_len; /* 432 */ + uint8_t signature[]; /* 436 */ +} sgx_quote_t; + +#define SGX_PLATFORM_INFO_SIZE 101 +typedef struct _platform_info +{ + uint8_t platform_info[SGX_PLATFORM_INFO_SIZE]; +} sgx_platform_info_t; + +typedef struct _update_info_bit +{ + int ucodeUpdate; + int csmeFwUpdate; + int pswUpdate; +} sgx_update_info_bit_t; + +#pragma pack(pop) + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/common/inc/sgx_report.h b/common/inc/sgx_report.h new file mode 100644 index 0000000000..8d26087397 --- /dev/null +++ b/common/inc/sgx_report.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +/* + * This file is to define Enclave's Report +*/ + +#ifndef _SGX_REPORT_H_ +#define _SGX_REPORT_H_ + +#include "sgx_attributes.h" +#include "sgx_key.h" + +#define SGX_HASH_SIZE 32 /* SHA256 */ +#define SGX_MAC_SIZE 16 /* Message Authentication Code - 16 bytes */ + +#define SGX_REPORT_DATA_SIZE 64 + +typedef struct _sgx_measurement_t +{ + uint8_t m[SGX_HASH_SIZE]; +} sgx_measurement_t; + +typedef uint8_t sgx_mac_t[SGX_MAC_SIZE]; + +typedef struct _sgx_report_data_t +{ + uint8_t d[SGX_REPORT_DATA_SIZE]; +} sgx_report_data_t; + +typedef uint16_t sgx_prod_id_t; + +#define SGX_TARGET_INFO_RESERVED1_BYTES 4 +#define SGX_TARGET_INFO_RESERVED2_BYTES 456 + +typedef struct _targe_info_t +{ + sgx_measurement_t mr_enclave; /* ( 0) The MRENCLAVE of the target enclave */ + sgx_attributes_t attributes; /* ( 32) The ATTRIBUTES field of the target enclave */ + uint8_t reserved1[SGX_TARGET_INFO_RESERVED1_BYTES]; /* ( 48) Reserved */ + sgx_misc_select_t misc_select; /* ( 52) The MISCSELECT of the target enclave */ + uint8_t reserved2[SGX_TARGET_INFO_RESERVED2_BYTES]; /* ( 56) Struct size is 512 bytes */ +} sgx_target_info_t; + +typedef struct _report_body_t +{ + sgx_cpu_svn_t cpu_svn; /* ( 0) Security Version of the CPU */ + sgx_misc_select_t misc_select; /* ( 16) Which fields defined in SSA.MISC */ + uint8_t reserved1[28]; /* ( 20) */ + sgx_attributes_t attributes; /* ( 48) Any special Capabilities the Enclave possess */ + sgx_measurement_t mr_enclave; /* ( 64) The value of the enclave's ENCLAVE measurement */ + uint8_t reserved2[32]; /* ( 96) */ + sgx_measurement_t mr_signer; /* (128) The value of the enclave's SIGNER measurement */ + uint8_t reserved3[96]; /* (160) */ + sgx_prod_id_t isv_prod_id; /* (256) Product ID of the Enclave */ + sgx_isv_svn_t isv_svn; /* (258) Security Version of the Enclave */ + uint8_t reserved4[60]; /* (260) */ + sgx_report_data_t report_data; /* (320) Data provided by the user */ +} sgx_report_body_t; + +typedef struct _report_t /* 432 bytes */ +{ + sgx_report_body_t body; + sgx_key_id_t key_id; /* (384) KeyID used for diversifying the key tree */ + sgx_mac_t mac; /* (416) The Message Authentication Code over this structure. */ +} sgx_report_t; + +#endif diff --git a/common/inc/sgx_sha256_128.h b/common/inc/sgx_sha256_128.h new file mode 100644 index 0000000000..52602d0ec2 --- /dev/null +++ b/common/inc/sgx_sha256_128.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SHA256_128_H +#define _SHA256_128_H + +#include "stdlib.h" +#include "sgx_utils.h" +#include "sgx_tcrypto.h" +#include "math.h" +#include "string.h" + +#define SGX_SHA256_128_HASH_SIZE 16 +typedef uint8_t sgx_sha256_128_hash_t[SGX_SHA256_128_HASH_SIZE]; + +sgx_status_t SGXAPI sgx_sha256_128_msg(const uint8_t *p_src, uint32_t src_len, sgx_sha256_128_hash_t *p_hash); + +#endif diff --git a/common/inc/sgx_spinlock.h b/common/inc/sgx_spinlock.h new file mode 100644 index 0000000000..77d8084856 --- /dev/null +++ b/common/inc/sgx_spinlock.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + + + +#ifndef _SGX_SPINLOCK_H_ +#define _SGX_SPINLOCK_H_ + +#include "sgx_defs.h" +#include + +typedef volatile uint32_t sgx_spinlock_t; + +#define SGX_SPINLOCK_INITIALIZER 0 + +#if defined(__cplusplus) +extern "C" { +#endif + +uint32_t SGXAPI sgx_spin_lock(sgx_spinlock_t *lock); +uint32_t SGXAPI sgx_spin_unlock(sgx_spinlock_t *lock); + +#if defined(__cplusplus) +} +#endif + +#endif /* !_SGX_SPINLOCK_H_ */ diff --git a/common/inc/sgx_tae_service.edl b/common/inc/sgx_tae_service.edl new file mode 100644 index 0000000000..9b19a8026b --- /dev/null +++ b/common/inc/sgx_tae_service.edl @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave{ + from "sgx_tstdc.edl" import *; + untrusted { + sgx_status_t create_session_ocall([out] uint32_t* sid, + [size = dh_msg1_size, out] uint8_t* dh_msg1, + uint32_t dh_msg1_size, + uint32_t timeout); + + sgx_status_t exchange_report_ocall(uint32_t sid, + [size = dh_msg2_size, in] uint8_t* dh_msg2, uint32_t dh_msg2_size, + [size = dh_msg3_size, out] uint8_t* dh_msg3, uint32_t dh_msg3_size, + uint32_t timeout); + + sgx_status_t close_session_ocall(uint32_t sid, uint32_t timeout); + + sgx_status_t invoke_service_ocall([size = pse_message_req_size, in] uint8_t* pse_message_req, + uint32_t pse_message_req_size, + [size = pse_message_resp_size, out] uint8_t* pse_message_resp, uint32_t pse_message_resp_size, + uint32_t timeout); + }; +}; diff --git a/common/inc/sgx_tae_service.h b/common/inc/sgx_tae_service.h new file mode 100644 index 0000000000..687f230607 --- /dev/null +++ b/common/inc/sgx_tae_service.h @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_TAE_SERVICE_H_ +#define _SGX_TAE_SERVICE_H_ + +/** +* File: +* sgx_tae_service.h +*Description: +* header for trusted AE support library. +* ADD from path/sgx_tae_service.edl import *; to your edl file +* to use sgx_tae_service.lib +*/ + +#include "sgx.h" +#include "sgx_defs.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma pack(push, 1) + +typedef uint64_t sgx_time_t; + +typedef uint8_t sgx_time_source_nonce_t[32]; + +#define SGX_MC_UUID_COUNTER_ID_SIZE 3 +#define SGX_MC_UUID_NONCE_SIZE 13 +typedef struct _mc_uuid { + uint8_t counter_id[SGX_MC_UUID_COUNTER_ID_SIZE]; + uint8_t nonce[SGX_MC_UUID_NONCE_SIZE]; +} sgx_mc_uuid_t; + +/* fixed length to align with internal structure */ +typedef struct _ps_sec_prop_desc +{ + uint8_t sgx_ps_sec_prop_desc[256]; +} sgx_ps_sec_prop_desc_t; + +#pragma pack(pop) + +/* create a session, call it before using Platform Service */ +sgx_status_t SGXAPI sgx_create_pse_session(void); + +/* close a created session, call it after finishing using Platform Service */ +sgx_status_t SGXAPI sgx_close_pse_session(void); + +/* get a data structure describing the Security Property of the Platform Service */ +sgx_status_t SGXAPI sgx_get_ps_sec_prop(sgx_ps_sec_prop_desc_t* security_property); + +/* provides the trusted platform current time */ +sgx_status_t SGXAPI sgx_get_trusted_time( + sgx_time_t* current_time, + sgx_time_source_nonce_t* time_source_nonce + ); + +/* monotonic counter policy */ +#define SGX_MC_POLICY_SIGNER 0x1 +#define SGX_MC_POLICY_ENCLAVE 0x2 +/* create a monotonic counter using given policy(SIGNER 0x1 or ENCLAVE 0x2) and attribute_mask */ +sgx_status_t SGXAPI sgx_create_monotonic_counter_ex( + uint16_t owner_policy, + const sgx_attributes_t* owner_attribute_mask, + sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ); + +/* create a monotonic counter using default policy SIGNER and default attribute_mask */ +sgx_status_t SGXAPI sgx_create_monotonic_counter( + sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ); + +/* destroy a specified monotonic counter */ +sgx_status_t SGXAPI sgx_destroy_monotonic_counter(const sgx_mc_uuid_t* counter_uuid); + +/* increment a specified monotonic counter by 1 */ +sgx_status_t SGXAPI sgx_increment_monotonic_counter( + const sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ); + +/* read a specified monotonic counter */ +sgx_status_t SGXAPI sgx_read_monotonic_counter( + const sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_tcrypto.h b/common/inc/sgx_tcrypto.h new file mode 100644 index 0000000000..8ecf0b32d0 --- /dev/null +++ b/common/inc/sgx_tcrypto.h @@ -0,0 +1,588 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +/** +* File: sgx_tcrypto.h +* Description: +* Interface for generic crypto library APIs required in SDK implementation. +*/ + +#ifndef _SGX_TCRYPTO_H_ +#define _SGX_TCRYPTO_H_ + +#include "sgx.h" +#include "sgx_defs.h" + +#define SGX_SHA256_HASH_SIZE 32 +#define SGX_ECP256_KEY_SIZE 32 +#define SGX_NISTP_ECP256_KEY_SIZE (SGX_ECP256_KEY_SIZE/sizeof(uint32_t)) +#define SGX_AESGCM_IV_SIZE 12 +#define SGX_AESGCM_KEY_SIZE 16 +#define SGX_AESGCM_MAC_SIZE 16 +#define SGX_CMAC_KEY_SIZE 16 +#define SGX_CMAC_MAC_SIZE 16 +#define SGX_AESCTR_KEY_SIZE 16 + +typedef struct _sgx_ec256_dh_shared_t +{ + uint8_t s[SGX_ECP256_KEY_SIZE]; +} sgx_ec256_dh_shared_t; + +typedef struct _sgx_ec256_private_t +{ + uint8_t r[SGX_ECP256_KEY_SIZE]; +} sgx_ec256_private_t; + +typedef struct _sgx_ec256_public_t +{ + uint8_t gx[SGX_ECP256_KEY_SIZE]; + uint8_t gy[SGX_ECP256_KEY_SIZE]; +} sgx_ec256_public_t; + +typedef struct _sgx_ec256_signature_t +{ + uint32_t x[SGX_NISTP_ECP256_KEY_SIZE]; + uint32_t y[SGX_NISTP_ECP256_KEY_SIZE]; +} sgx_ec256_signature_t; + +typedef void* sgx_sha_state_handle_t; +typedef void* sgx_cmac_state_handle_t; +typedef void* sgx_ecc_state_handle_t; + +typedef uint8_t sgx_sha256_hash_t[SGX_SHA256_HASH_SIZE]; + +typedef uint8_t sgx_aes_gcm_128bit_key_t[SGX_AESGCM_KEY_SIZE]; +typedef uint8_t sgx_aes_gcm_128bit_tag_t[SGX_AESGCM_MAC_SIZE]; +typedef uint8_t sgx_cmac_128bit_key_t[SGX_CMAC_KEY_SIZE]; +typedef uint8_t sgx_cmac_128bit_tag_t[SGX_CMAC_MAC_SIZE]; +typedef uint8_t sgx_aes_ctr_128bit_key_t[SGX_AESCTR_KEY_SIZE]; + +typedef enum { + SGX_EC_VALID, /* validation pass successfully */ + + SGX_EC_COMPOSITE_BASE, /* field based on composite */ + SGX_EC_COMPLICATED_BASE, /* number of non-zero terms in the polynomial (> PRIME_ARR_MAX) */ + SGX_EC_IS_ZERO_DISCRIMINANT,/* zero discriminant */ + SGX_EC_COMPOSITE_ORDER, /* composite order of base point */ + SGX_EC_INVALID_ORDER, /* invalid base point order */ + SGX_EC_IS_WEAK_MOV, /* weak Meneze-Okamoto-Vanstone reduction attack */ + SGX_EC_IS_WEAK_SSA, /* weak Semaev-Smart,Satoh-Araki reduction attack */ + SGX_EC_IS_SUPER_SINGULAR, /* supersingular curve */ + + SGX_EC_INVALID_PRIVATE_KEY, /* !(0 < Private < order) */ + SGX_EC_INVALID_PUBLIC_KEY, /* (order*PublicKey != Infinity) */ + SGX_EC_INVALID_KEY_PAIR, /* (Private*BasePoint != PublicKey) */ + + SGX_EC_POINT_OUT_OF_GROUP, /* out of group (order*P != Infinity) */ + SGX_EC_POINT_IS_AT_INFINITY,/* point (P=(Px,Py)) at Infinity */ + SGX_EC_POINT_IS_NOT_VALID, /* point (P=(Px,Py)) out-of EC */ + + SGX_EC_POINT_IS_EQUAL, /* compared points are equal */ + SGX_EC_POINT_IS_NOT_EQUAL, /* compared points are different */ + + SGX_EC_INVALID_SIGNATURE /* invalid signature */ +} sgx_generic_ecresult_t; + + +#ifdef __cplusplus +extern "C" { +#endif + + /** SHA Hashing functions - NOTE: ONLY 256-bit is supported. + * + * NOTE: Use sgx_sha256_msg if the src pointer contains the complete msg to perform hash (Option 1) + * Else use the Init, Update, Update, ..., Final procedure (Option 2) + * Option 1: If the complete dataset is available for hashing, sgx_sha256_msg + * is a single API call for generating the 256bit hash for the given dataset. + * Return: If source pointer or hash pointer are NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If hash function fails then SGX_ERROR_UNEXPECTED is returned. + * Option 2: If the hash is to be performed over multiple data sets, then use: + * A. sgx_sha256_init - to create the context - context memory is allocated by this function. + * Return: If out of enclave memory, SGX_ERROR_OUT_OF_MEMORY is returned. + * If context creation fails then SGX_ERROR_UNEXPECTED is returned. + * B. sgx_sha256_update - updates hash based on input source data + * This function should be called for each chunk of data to be + * included in the hash including the 1st and final chunks. + * Return: If source pointer or context pointer are NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If hash function fails then SGX_ERROR_UNEXPECTED is returned. + * C. sgx_sha256_get_hash - function obtains the hash value + * Return: If hash pointer or context pointer are NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If the function fails then SGX_ERROR_UNEXPECTED is returned. + * D. sgx_sha256_close - SHOULD BE CALLED to FREE context memory + * Upon completing the process of computing a hash over a set of data + * or sets of data, this function is used to free the context. + * Return: If context pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: uint8_t *p_src - Pointer to the input stream to be hashed + * uint32_t src_len - Length of the input stream to be hashed + * Output: sgx_sha256_hash_t *p_hash - Resultant hash from operation + */ + sgx_status_t SGXAPI sgx_sha256_msg(const uint8_t *p_src, uint32_t src_len, sgx_sha256_hash_t *p_hash); + + /** Allocates and initializes sha256 state + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Output: sgx_sha_state_handle_t *p_sha_handle - Pointer to the handle of the SHA256 state + */ + sgx_status_t SGXAPI sgx_sha256_init(sgx_sha_state_handle_t* p_sha_handle); + + /** Updates sha256 has calculation based on the input message + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state + * uint8_t *p_src - Pointer to the input stream to be hashed + * uint32_t src_len - Length of the input stream to be hashed + */ + sgx_status_t SGXAPI sgx_sha256_update(const uint8_t *p_src, uint32_t src_len, sgx_sha_state_handle_t sha_handle); + + /** Returns Hash calculation + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state + * Output: sgx_sha256_hash_t *p_hash - Resultant hash from operation + */ + sgx_status_t SGXAPI sgx_sha256_get_hash(sgx_sha_state_handle_t sha_handle, sgx_sha256_hash_t *p_hash); + + /** Cleans up SHA state + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state + */ + sgx_status_t SGXAPI sgx_sha256_close(sgx_sha_state_handle_t sha_handle); + + /**Rijndael AES-GCM - Only 128-bit key AES-GCM Encryption/Decryption is supported + * + * The Galois/Counter Mode (GCM) is a mode of operation of the AES algorithm. + * GCM [NIST SP 800-38D] uses a variation of the Counter mode of operation for encryption. + * GCM assures authenticity of the confidential data (of up to about 64 GB per invocation) + * using a universal hash function defined over a binary finite field (the Galois field). + * + * GCM can also provide authentication assurance for additional data + * (of practically unlimited length per invocation) that is not encrypted. + * GCM provides stronger authentication assurance than a (non-cryptographic) checksum or + * error detecting code. In particular, GCM can detect both accidental modifications of + * the data and intentional, unauthorized modifications. + * + * sgx_rijndael128GCM_encrypt: + * Return: If key, source, destination, MAC, or IV pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If AAD size is > 0 and the AAD pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If the Source Length is < 1, SGX_ERROR_INVALID_PARAMETER is returned. + * IV Length must = 12 (bytes) or SGX_ERROR_INVALID_PARAMETER is returned. + * If out of enclave memory then SGX_ERROR_OUT_OF_MEMORY is returned. + * If the encryption process fails then SGX_ERROR_UNEXPECTED is returned. + * + * sgx_rijndael128GCM_decrypt: + * Return: If key, source, destination, MAC, or IV pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If AAD size is > 0 and the AAD pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If the Source Length is < 1, SGX_ERROR_INVALID_PARAMETER is returned. + * IV Length must = 12 (bytes) or SGX_ERROR_INVALID_PARAMETER is returned. + * If the decryption process fails then SGX_ERROR_UNEXPECTED is returned. + * If the input MAC does not match the calculated MAC, SGX_ERROR_MAC_MISMATCH is returned. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_aes_gcm_128bit_key_t *p_key - Pointer to the key used in encryption/decryption operation + * Size MUST BE 128-bits + * uint8_t *p_src - Pointer to the input stream to be encrypted/decrypted + * uint32_t src_len - Length of the input stream to be encrypted/decrypted + * uint8_t *p_iv - Pointer to the initialization vector + * uint32_t iv_len - Length of the initialization vector - MUST BE 12 (bytes) + * NIST AES-GCM recommended IV size = 96 bits + * uint8_t *p_aad - Pointer to the input stream of additional authentication data + * uint32_t aad_len - Length of the additional authentication data stream + * sgx_aes_gcm_128bit_tag_t *p_in_mac - Pointer to the expected MAC in decryption process + * Output: uint8_t *p_dst - Pointer to the cipher text for encryption or clear text for decryption. Size of buffer should be >= src_len. + * sgx_aes_gcm_128bit_tag_t *p_out_mac - Pointer to the MAC generated from encryption process + * NOTE: Wrapper is responsible for confirming decryption tag matches encryption tag + */ + sgx_status_t SGXAPI sgx_rijndael128GCM_encrypt(const sgx_aes_gcm_128bit_key_t *p_key, + const uint8_t *p_src, + uint32_t src_len, + uint8_t *p_dst, + const uint8_t *p_iv, + uint32_t iv_len, + const uint8_t *p_aad, + uint32_t aad_len, + sgx_aes_gcm_128bit_tag_t *p_out_mac); + sgx_status_t SGXAPI sgx_rijndael128GCM_decrypt(const sgx_aes_gcm_128bit_key_t *p_key, + const uint8_t *p_src, + uint32_t src_len, + uint8_t *p_dst, + const uint8_t *p_iv, + uint32_t iv_len, + const uint8_t *p_aad, + uint32_t aad_len, + const sgx_aes_gcm_128bit_tag_t *p_in_mac); + + /** Message Authentication Rijndael 128 CMAC - Only 128-bit key size is supported. + * NOTE: Use sgx_rijndael128_cmac_msg if the src ptr contains the complete msg to perform hash (Option 1) + * Else use the Init, Update, Update, ..., Final, Close procedure (Option 2) + * Option 1: If the complete dataset is available for hashing, sgx_rijndael128_cmac_msg + * is a single API call for generating the 128-bit hash for the given dataset. + * Return: If source, key, or MAC pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If out of enclave memory, SGX_ERROR_OUT_OF_MEMORY is returned. + * If hash function fails then SGX_ERROR_UNEXPECTED is returned. + * Option 2: If the hash is to be performed over multiple data sets, then use: + * A. sgx_cmac128_init - to create the context - context memory is allocated by this function. + * Return: If key pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If out of enclave memory, SGX_ERROR_OUT_OF_MEMORY is returned. + * If context creation fails then SGX_ERROR_UNEXPECTED is returned. + * B. sgx_cmac128_update - updates hash based on input source data + * This function should be called for each chunk of data to be + * included in the hash including the 1st and final chunks. + * Return: If source pointer or context pointer are NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If hash function fails then SGX_ERROR_UNEXPECTED is returned. + * C. sgx_cmac128_final - function obtains the hash value + * Upon completing the process of computing a hash over a set of data or sets of data, + * this function populates the hash value. + * Return: If hash pointer or context pointer are NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * If the function fails then SGX_ERROR_UNEXPECTED is returned. + * D. sgx_cmac128_close - SHOULD BE CALLED to clean up the CMAC state + * Upon populating the hash value over a set of data or sets of data, + * this function is used to free the CMAC state. + * Return: If CMAC state pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_cmac_128bit_key_t *p_key - Pointer to the key used in encryption/decryption operation + * uint8_t *p_src - Pointer to the input stream to be MAC’d + * uint32_t src_len - Length of the input stream to be MAC’d + * Output: sgx_cmac_gcm_128bit_tag_t *p_mac - Pointer to the resultant MAC + */ + sgx_status_t SGXAPI sgx_rijndael128_cmac_msg(const sgx_cmac_128bit_key_t *p_key, + const uint8_t *p_src, + uint32_t src_len, + sgx_cmac_128bit_tag_t *p_mac); + /** Allocates and initializes CMAC state. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_cmac_128bit_key_t *p_key - Pointer to the key used in encryption/decryption operation + * Output: sgx_cmac_state_handle_t *p_cmac_handle - Pointer to the handle of the CMAC state + */ + sgx_status_t SGXAPI sgx_cmac128_init(const sgx_cmac_128bit_key_t *p_key, sgx_cmac_state_handle_t* p_cmac_handle); + + /** Updates CMAC has calculation based on the input message. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state + * uint8_t *p_src - Pointer to the input stream to be hashed + * uint32_t src_len - Length of the input stream to be hashed + */ + sgx_status_t SGXAPI sgx_cmac128_update(const uint8_t *p_src, uint32_t src_len, sgx_cmac_state_handle_t cmac_handle); + + /** Returns Hash calculation and clean up CMAC state. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state + * Output: sgx_cmac_128bit_tag_t *p_hash - Resultant hash from operation + */ + sgx_status_t SGXAPI sgx_cmac128_final(sgx_cmac_state_handle_t cmac_handle, sgx_cmac_128bit_tag_t *p_hash); + + /** Clean up the CMAC state + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state + */ + sgx_status_t SGXAPI sgx_cmac128_close(sgx_cmac_state_handle_t cmac_handle); + + + /** AES-CTR 128-bit - Only 128-bit key size is supported. + * + * These functions encrypt/decrypt the input data stream of a variable length according + * to the CTR mode as specified in [NIST SP 800-38A]. The counter can be thought of as + * an IV which increments on successive encryption or decrytion calls. For a given + * dataset or data stream the incremented counter block should be used on successive + * calls of the encryption/decryption process for that given stream. However for + * new or different datasets/streams, the same counter should not be reused, instead + * intialize the counter for the new data set. + * + * sgx_aes_ctr_encrypt + * Return: If source, key, counter, or destination pointer is NULL, + * SGX_ERROR_INVALID_PARAMETER is returned. + * If out of enclave memory, SGX_ERROR_OUT_OF_MEMORY is returned. + * If the encryption process fails then SGX_ERROR_UNEXPECTED is returned. + * sgx_aes_ctr_decrypt + * Return: If source, key, counter, or destination pointer is NULL, + * SGX_ERROR_INVALID_PARAMETER is returned. + * If out of enclave memory, SGX_ERROR_OUT_OF_MEMORY is returned. + * If the decryption process fails then SGX_ERROR_UNEXPECTED is returned. + * + * Parameters: + * Return: + * sgx_status_t - SGX_SUCCESS or failure as defined + * in sgx_error.h + * Inputs: + * sgx_aes_128bit_key_t *p_key - Pointer to the key used in + * encryption/decryption operation + * uint8_t *p_src - Pointer to the input stream to be + * encrypted/decrypted + * uint32_t src_len - Length of the input stream to be + * encrypted/decrypted + * uint8_t *p_ctr - Pointer to the counter block + * uint32_t ctr_inc_bits - Number of bits in counter to be + * incremented + * Output: + * uint8_t *p_dst - Pointer to the cipher text. + * Size of buffer should be >= src_len. + */ + sgx_status_t SGXAPI sgx_aes_ctr_encrypt( + const sgx_aes_ctr_128bit_key_t *p_key, + const uint8_t *p_src, + const uint32_t src_len, + uint8_t *p_ctr, + const uint32_t ctr_inc_bits, + uint8_t *p_dst); + sgx_status_t SGXAPI sgx_aes_ctr_decrypt( + const sgx_aes_ctr_128bit_key_t *p_key, + const uint8_t *p_src, + const uint32_t src_len, + uint8_t *p_ctr, + const uint32_t ctr_inc_bits, + uint8_t *p_dst); + + + /** + * Elliptic Curve Cryptography based on GF(p), 256 bit. + * + * Elliptic curve cryptosystems (ECCs) implement a different way of creating public keys. + * Because elliptic curve calculation is based on the addition of the rational points in + * the (x,y) plane and it is difficult to solve a discrete logarithm from these points, + * a higher level of security is achieved through the cryptographic schemes that use the + * elliptic curves. The cryptographic systems that encrypt messages by using the properties + * of elliptic curves are hard to attack due to the extreme complexity of deciphering the + * private key. + * + * Use of elliptic curves allows for shorter public key length and encourage cryptographers + * to create cryptosystems with the same or higher encryption strength as the RSA or DSA + * cryptosystems. Because of the relatively short key length, ECCs do encryption and decryption + * faster on the hardware that requires less computation processing volumes. For example, with + * a key length of 150-350 bits, ECCs provide the same encryption strength as the cryptosystems + * who have to use 600 -1400 bits. + * + * ECCP stands for Elliptic Curve Cryptography Prime and these functions include operations + * over a prime finite field GF(p). + * + */ + /** Allocates and initializes ecc context. + * The function initializes the context of the elliptic curve cryptosystem over the + * prime finite field GF(p). This function allocates and initializes the ecc context. + * Return: If out of enclave memory, SGX_ERROR_OUT_OF_MEMORY is returned. + * If context creation fails then SGX_ERROR_UNEXPECTED is returned. + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Output: sgx_ecc_state_handle_t *p_ecc_handle - Pointer to the handle of the ECC crypto system + */ + sgx_status_t SGXAPI sgx_ecc256_open_context(sgx_ecc_state_handle_t* p_ecc_handle); + + /** Cleans up ecc context. + * Return: If context pointer is NULL, SGX_ERROR_INVALID_PARAMETER is returned. + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Output: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system + */ + sgx_status_t SGXAPI sgx_ecc256_close_context(sgx_ecc_state_handle_t ecc_handle); + + /** Populates private/public key pair. + * NOTE: Caller code allocates memory for Private & Public key pointers to be populated + * + * The function generates a private key p_private and computes a public key p_public of the + * elliptic cryptosystem over a finite field GF(p). + * + * The private key p_private is a number that lies in the range of [1, n-1] where n is + * the order of the elliptic curve base point. + * + * The public key p_public is an elliptic curve point such that p_public = p_private ?G, + * where G is the base point of the elliptic curve. + * + * The context of the point p_public as an elliptic curve point must be created by using + * the function sgx_ecc256_open_context. + * + * Return: If context, public key, or private key pointer is NULL, + * SGX_ERROR_INVALID_PARAMETER is returned. + * If the key creation process fails then SGX_ERROR_UNEXPECTED is returned. + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system + * Outputs: sgx_ec256_private_t *p_private - Pointer to the private key - LITTLE ENDIAN + * sgx_ec256_public_t *p_public - Pointer to the public key - LITTLE ENDIAN + */ + sgx_status_t SGXAPI sgx_ecc256_create_key_pair(sgx_ec256_private_t *p_private, + sgx_ec256_public_t *p_public, + sgx_ecc_state_handle_t ecc_handle); + + /** Checks whether the input point is a valid point on the given elliptic curve. + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system + * sgx_ec256_public_t *p_point - Pointer to perform validity check on - LITTLE ENDIAN + * Output: int *p_valid - Return 0 if the point is an invalid point on ECC curve + */ + sgx_status_t SGXAPI sgx_ecc256_check_point(const sgx_ec256_public_t *p_point, + const sgx_ecc_state_handle_t ecc_handle, + int *p_valid); + + /** Computes DH shared key based on own (local) private key and remote public Ga Key. + * NOTE: Caller code allocates memory for Shared key pointer to be populated + * + * The function computes a secret number bnShare, which is a secret key shared between + * two participants of the cryptosystem. + * + * In cryptography, metasyntactic names such as Alice as Bob are normally used as examples + * and in discussions and stand for participant A and participant B. + * + * Both participants (Alice and Bob) use the cryptosystem for receiving a common secret point + * on the elliptic curve called a secret key. To receive a secret key, participants apply the + * Diffie-Hellman key-agreement scheme involving public key exchange. The value of the secret + * key entirely depends on participants. + * + * According to the scheme, Alice and Bob perform the following operations: + * 1. Alice calculates her own public key pubKeyA by using her private key + * privKeyA: pubKeyA = privKeyA ?G, where G is the base point of the elliptic curve. + * 2. Alice passes the public key to Bob. + * 3. Bob calculates his own public key pubKeyB by using his private key + * privKeyB: pubKeyB = privKeyB ?G, where G is a base point of the elliptic curve. + * 4. Bob passes the public key to Alice. + * 5. Alice gets Bob's public key and calculates the secret point shareA. When calculating, + * she uses her own private key and Bob's public key and applies the following formula: + * shareA = privKeyA ?pubKeyB = privKeyA ?privKeyB ?G. + * 6. Bob gets Alice's public key and calculates the secret point shareB. When calculating, + * he uses his own private key and Alice's public key and applies the following formula: + * shareB = privKeyB ?pubKeyA = privKeyB ?privKeyA ?G. + * + * Because the following equation is true privKeyA ?privKeyB ?G = privKeyB ?privKeyA ?G, + * the result of both calculations is the same, that is, the equation shareA = shareB is true. + * The secret point serves as a secret key. + * + * Shared secret bnShare is an x-coordinate of the secret point on the elliptic curve. The elliptic + * curve domain parameters must be hitherto defined by the function: sgx_ecc256_open_context. + * + * Return: If context, public key, private key, or shared key pointer is NULL, + * SGX_ERROR_INVALID_PARAMETER is returned. + * If the remote public key is not a valid point on the elliptic curve, + * SGX_ERROR_INVALID_PARAMETER is returned. + * If the key creation process fails then SGX_ERROR_UNEXPECTED is returned. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system + * sgx_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN + * sgx_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN + * Output: sgx_ec256_dh_shared_t *p_shared_key - Pointer to the shared DH key - LITTLE ENDIAN + */ + sgx_status_t SGXAPI sgx_ecc256_compute_shared_dhkey(sgx_ec256_private_t *p_private_b, + sgx_ec256_public_t *p_public_ga, + sgx_ec256_dh_shared_t *p_shared_key, + sgx_ecc_state_handle_t ecc_handle); + + /** Computes signature for data based on private key. + * + * A message digest is a fixed size number derived from the original message with + * an applied hash function over the binary code of the message. (SHA256 in this case) + * The signer's private key and the message digest are used to create a signature. + * + * A digital signature over a message consists of a pair of large numbers, 256-bits each, + * which the given function computes. + * + * The scheme used for computing a digital signature is of the ECDSA scheme, + * an elliptic curve of the DSA scheme. + * + * The keys can be generated and set up by the function: sgx_ecc256_create_key_pair. + * + * The elliptic curve domain parameters must be created by function: + * sgx_ecc256_open_context + * + * Return: If context, private key, signature or data pointer is NULL, + * SGX_ERROR_INVALID_PARAMETER is returned. + * If the signature creation process fails then SGX_ERROR_UNEXPECTED is returned. + * + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system + * sgx_ec256_private_t *p_private - Pointer to the private key - LITTLE ENDIAN + * uint8_t *p_data - Pointer to the data to be signed + * uint32_t data_size - Size of the data to be signed + * Output: ec256_signature_t *p_signature - Pointer to the signature - LITTLE ENDIAN + */ + sgx_status_t SGXAPI sgx_ecdsa_sign(const uint8_t *p_data, + uint32_t data_size, + sgx_ec256_private_t *p_private, + sgx_ec256_signature_t *p_signature, + sgx_ecc_state_handle_t ecc_handle); + + /** Verifies the signature for the given data based on the public key. + * + * A digital signature over a message consists of a pair of large numbers, 256-bits each, + * which could be created by function: sgx_ecdsa_sign. The scheme used for computing a + * digital signature is of the ECDSA scheme, an elliptic curve of the DSA scheme. + * + * The typical result of the digital signature verification is one of the two values: + * SGX_Generic_ECValid - Digital signature is valid + * SGX_Generic_ECInvalidSignature - Digital signature is not valid + * + * The elliptic curve domain parameters must be created by function: + * sgx_ecc256_open_context + * + * Return: If context, public key, signature, result or data pointer is NULL, + * SGX_ERROR_INVALID_PARAMETER is returned. + * If the verification process fails then SGX_ERROR_UNEXPECTED is returned. + * Parameters: + * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system + * sgx_ec256_public_t *p_public - Pointer to the public key + * uint8_t *p_data - Pointer to the data to be signed + * uint32_t data_size - Size of the data to be signed + * sgx_ec256_signature_t *p_signature - Pointer to the signature + * Output: uint8_t *p_result - Pointer to the result of verification check + */ + sgx_status_t SGXAPI sgx_ecdsa_verify(const uint8_t *p_data, + uint32_t data_size, + const sgx_ec256_public_t *p_public, + sgx_ec256_signature_t *p_signature, + uint8_t *p_result, + sgx_ecc_state_handle_t ecc_handle); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_thread.h b/common/inc/sgx_thread.h new file mode 100644 index 0000000000..88af98372e --- /dev/null +++ b/common/inc/sgx_thread.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_THREAD_H_ +#define _SGX_THREAD_H_ + +#include +#include +#include "sgx_defs.h" + +typedef uintptr_t sgx_thread_t; + +typedef struct sgx_thread_queue +{ + sgx_thread_t m_first; /* first element */ + sgx_thread_t m_last; /* last element */ +} sgx_thread_queue_t; + +/* Mutex */ +typedef struct sgx_thread_mutex +{ + size_t m_refcount; + uint32_t m_control; + volatile uint32_t m_lock; /* use sgx_spinlock_t */ + sgx_thread_t m_owner; + sgx_thread_queue_t m_queue; +} sgx_thread_mutex_t; + +#define SGX_THREAD_T_NULL ((sgx_thread_t)(NULL)) + +#define SGX_THREAD_MUTEX_NONRECURSIVE 0x01 +#define SGX_THREAD_MUTEX_RECURSIVE 0x02 +#define SGX_THREAD_NONRECURSIVE_MUTEX_INITIALIZER \ + {0, SGX_THREAD_MUTEX_NONRECURSIVE, 0, SGX_THREAD_T_NULL, {SGX_THREAD_T_NULL, SGX_THREAD_T_NULL}} +#define SGX_THREAD_RECURSIVE_MUTEX_INITIALIZER \ + {0, SGX_THREAD_MUTEX_RECURSIVE, 0, SGX_THREAD_T_NULL, {SGX_THREAD_T_NULL, SGX_THREAD_T_NULL}} +#define SGX_THREAD_MUTEX_INITIALIZER \ + SGX_THREAD_NONRECURSIVE_MUTEX_INITIALIZER + +typedef struct sgx_thread_mutex_attr +{ + unsigned char m_dummy; /* for C syntax check */ +} sgx_thread_mutexattr_t; + +/* Condition Variable */ +typedef struct sgx_thread_cond +{ + volatile uint32_t m_lock; /* use sgx_spinlock_t */ + sgx_thread_queue_t m_queue; +} sgx_thread_cond_t; + +#define SGX_THREAD_COND_INITIALIZER {0, {SGX_THREAD_T_NULL, SGX_THREAD_T_NULL}} + +typedef struct sgx_thread_cond_attr +{ + unsigned char m_dummy; /* for C syntax check */ +} sgx_thread_condattr_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Mutex */ +int SGXAPI sgx_thread_mutex_init(sgx_thread_mutex_t *mutex, const sgx_thread_mutexattr_t *unused); +int SGXAPI sgx_thread_mutex_destroy(sgx_thread_mutex_t *mutex); + +int SGXAPI sgx_thread_mutex_lock(sgx_thread_mutex_t *mutex); +int SGXAPI sgx_thread_mutex_trylock(sgx_thread_mutex_t *mutex); +int SGXAPI sgx_thread_mutex_unlock(sgx_thread_mutex_t *mutex); + +/* Condition Variable */ +int SGXAPI sgx_thread_cond_init(sgx_thread_cond_t *cond, const sgx_thread_condattr_t *unused); +int SGXAPI sgx_thread_cond_destroy(sgx_thread_cond_t *cond); + +int SGXAPI sgx_thread_cond_wait(sgx_thread_cond_t *cond, sgx_thread_mutex_t *mutex); +int SGXAPI sgx_thread_cond_signal(sgx_thread_cond_t *cond); +int SGXAPI sgx_thread_cond_broadcast(sgx_thread_cond_t *cond); + +sgx_thread_t SGXAPI sgx_thread_self(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SGX_THREAD_H_ */ diff --git a/common/inc/sgx_tkey_exchange.edl b/common/inc/sgx_tkey_exchange.edl new file mode 100644 index 0000000000..179418d0ce --- /dev/null +++ b/common/inc/sgx_tkey_exchange.edl @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave { + from "sgx_tae_service.edl" import *; + trusted { + public sgx_status_t sgx_ra_get_ga(sgx_ra_context_t context, + [out] sgx_ec256_public_t *g_a); + + public sgx_status_t sgx_ra_proc_msg2_trusted(sgx_ra_context_t context, + [in]const sgx_ra_msg2_t *p_msg2, /*copy msg2 except quote into enclave */ + [in] const sgx_target_info_t *p_qe_target, + [out] sgx_report_t *p_report, + [out] sgx_quote_nonce_t *p_nonce); + + public sgx_status_t sgx_ra_get_msg3_trusted(sgx_ra_context_t context, + uint32_t quote_size, + [in]sgx_report_t* qe_report, + [user_check]sgx_ra_msg3_t *p_msg3, + uint32_t msg3_size); + }; +}; diff --git a/common/inc/sgx_tkey_exchange.h b/common/inc/sgx_tkey_exchange.h new file mode 100644 index 0000000000..f2fb9d0f75 --- /dev/null +++ b/common/inc/sgx_tkey_exchange.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_TKEY_EXCHANGE_H_ +#define _SGX_TKEY_EXCHANGE_H_ + +#include "sgx.h" +#include "sgx_defs.h" +#include "sgx_key_exchange.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The sgx_ra_init function creates a context for the remote attestation and + * key exchange process. + * + * @param p_pub_key The EC public key of the service provider based on the NIST + * P-256 elliptic curve. + * @param b_pse If true, platform service information is needed in message + * 3. The caller should make sure a PSE session has been + * established using sgx_create_pse_session before attempting + * to establish a remote attestation and key exchange session + * involving platform service information. + * @param p_context The output context for the subsequent remote attestation + * and key exchange process, to be used in sgx_ra_get_msg1 and + * sgx_ra_proc_msg2. + * @return sgx_status_t SGX_SUCCESS Indicates success. + * SGX_ERROR_INVALID_PARAMETER Indicates an error that + * the input parameters are + * invalid. + * SGX_ERROR_KDF_MISMATCH Indicates key derivation + * function doesn't match. + * SGX_ERROR_OUT_OF_MEMORY There is not enough + * memory available to + * complete this operation. + * SGX_ERROR_AE_SESSION_INVALID Session is invalid or + * ended by server. + * SGX_ERROR_UNEXPECTED Indicates an unexpected + * error occurs. + */ +sgx_status_t SGXAPI sgx_ra_init( + const sgx_ec256_public_t *p_pub_key, + int b_pse, + sgx_ra_context_t *p_context); + +/* + * The sgx_ra_get_keys function is used to get the negotiated keys of a remote + * attestation and key exchange session. This function should only be called + * after the service provider accepts the remote attestation and key exchange + * protocol message 3 produced by sgx_ra_proc_msg2. + * + * @param context Context returned by sgx_ra_init. + * @param type The specifier of keys, can be SGX_RA_KEY_MK, SGX_RA_KEY_SK + * and SGX_RA_VK. + * @param p_key The key returned. + * @return sgx_status_t SGX_SUCCESS Indicates success. + * SGX_ERROR_INVALID_PARAMETER Indicates an error that + * the input parameters are + * invalid. + * SGX_ERROR_INVALID_STATE Indicates this function + * is called out of order. + */ +sgx_status_t SGXAPI sgx_ra_get_keys( + sgx_ra_context_t context, + sgx_ra_key_type_t type, + sgx_ra_key_128_t *p_key); + +/* + * Call the sgx_ra_close function to release the remote attestation and key + * exchange context after the process is done and the context isn't needed + * anymore. + * + * @param context Context returned by sgx_ra_init. + * @return sgx_status_t SGX_SUCCESS Indicates success. + * SGX_ERROR_INVALID_PARAMETER Indicates an error that + * the input parameters are + * invalid. + */ +sgx_status_t SGXAPI sgx_ra_close( + sgx_ra_context_t context); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_trts.h b/common/inc/sgx_trts.h new file mode 100644 index 0000000000..1a669f78d2 --- /dev/null +++ b/common/inc/sgx_trts.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_TRTS_H_ +#define _SGX_TRTS_H_ + +#include "sgx_error.h" +#include "stddef.h" +#include "sgx_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* sgx_is_within_enclave() + * Parameters: + * addr - the start address of the buffer + * size - the size of the buffer + * Return Value: + * 1 - the buffer is strictly within the enclave + * 0 - the whole buffer or part of the buffer is not within the enclave, + * or the buffer is wrap around +*/ +int SGXAPI sgx_is_within_enclave(const void *addr, size_t size); + +/* sgx_is_outside_enclave() + * Parameters: + * addr - the start address of the buffer + * size - the size of the buffer + * Return Value: + * 1 - the buffer is strictly outside the enclave + * 0 - the whole buffer or part of the buffer is not outside the enclave, + * or the buffer is wrap around +*/ +int SGXAPI sgx_is_outside_enclave(const void *addr, size_t size); + + +/* sgx_read_rand() + * Parameters: + * rand - the buffer to receive the random number + * length_in_bytes - the number of bytes to read the random number + * Return Value: + * SGX_SUCCESS - success + * SGX_ERROR_INVALID_PARAMETER - the parameter is invalid + * SGX_ERROR_UNEXPECTED - HW failure of RDRAND instruction +*/ +sgx_status_t SGXAPI sgx_read_rand(unsigned char *rand, size_t length_in_bytes); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_trts_exception.h b/common/inc/sgx_trts_exception.h new file mode 100644 index 0000000000..41280aff4d --- /dev/null +++ b/common/inc/sgx_trts_exception.h @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +/** + * File: sgx_trts_exception.h + * Description: + * Header file for custom exception handling support. + */ + +#ifndef _SGX_TRTS_EXCEPTION_H_ +#define _SGX_TRTS_EXCEPTION_H_ + +#include +#include +#include "sgx_defs.h" + +#define EXCEPTION_CONTINUE_SEARCH 0 +#define EXCEPTION_CONTINUE_EXECUTION -1 + +typedef enum _sgx_exception_vector_t +{ + SGX_EXCEPTION_VECTOR_DE = 0, /* DIV and DIV instructions */ + SGX_EXCEPTION_VECTOR_DB = 1, /* For Intel use only */ + SGX_EXCEPTION_VECTOR_BP = 3, /* INT 3 instruction */ + SGX_EXCEPTION_VECTOR_BR = 5, /* BOUND instruction */ + SGX_EXCEPTION_VECTOR_UD = 6, /* UD2 instruction or reserved opcode */ + SGX_EXCEPTION_VECTOR_MF = 16, /* x87 FPU floating-point or WAIT/FWAIT instruction */ + SGX_EXCEPTION_VECTOR_AC = 17, /* Any data reference in memory */ + SGX_EXCEPTION_VECTOR_XM = 19, /* SSE/SSE2/SSE3 floating-point instruction */ +} sgx_exception_vector_t; + +typedef enum _sgx_exception_type_t +{ + SGX_EXCEPTION_HARDWARE = 3, + SGX_EXCEPTION_SOFTWARE = 6, +} sgx_exception_type_t; + +#if defined (_M_X64) || defined (__x86_64__) +typedef struct _cpu_context_t +{ + uint64_t rax; + uint64_t rcx; + uint64_t rdx; + uint64_t rbx; + uint64_t rsp; + uint64_t rbp; + uint64_t rsi; + uint64_t rdi; + uint64_t r8; + uint64_t r9; + uint64_t r10; + uint64_t r11; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + uint64_t rflags; + uint64_t rip; +} sgx_cpu_context_t; +#else +typedef struct _cpu_context_t +{ + uint32_t eax; + uint32_t ecx; + uint32_t edx; + uint32_t ebx; + uint32_t esp; + uint32_t ebp; + uint32_t esi; + uint32_t edi; + uint32_t eflags; + uint32_t eip; +} sgx_cpu_context_t; +#endif + +typedef struct _exception_info_t +{ + sgx_cpu_context_t cpu_context; + sgx_exception_vector_t exception_vector; + sgx_exception_type_t exception_type; +} sgx_exception_info_t; + +typedef int (*sgx_exception_handler_t)(sgx_exception_info_t *info); + +#ifdef __cplusplus +extern "C" { +#endif + +/* sgx_register_exception_handler() + * register a custom exception handler + * Parameter + * is_first_handler - the order in which the handler should be called. + * If the parameter is nonzero, the handler is the first handler to be called. + * If the parameter is zero, the handler is the last handler to be called. + * exception_handler - a pointer to the handler to be called. + * Return Value + * handler - success + * NULL - fail +*/ +void * SGXAPI sgx_register_exception_handler(int is_first_handler, sgx_exception_handler_t exception_handler); + +/* sgx_unregister_exception_handler() + * unregister a custom exception handler. + * Parameter + * handler - a handler to the custom excepetion handler previously + * registered using the sgx_register_exception_handler function. + * Return Value + * none zero - success + * 0 - fail +*/ +int SGXAPI sgx_unregister_exception_handler(void *handler); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_tseal.h b/common/inc/sgx_tseal.h new file mode 100644 index 0000000000..fa93227800 --- /dev/null +++ b/common/inc/sgx_tseal.h @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _SGX_TSEAL_H_ +#define _SGX_TSEAL_H_ + +#include +#include +#include "sgx_key.h" +#include "sgx_error.h" +#include "sgx_defs.h" +#include "sgx_attributes.h" +#include "sgx_tcrypto.h" + +#define SGX_SEAL_TAG_SIZE SGX_AESGCM_MAC_SIZE +#define SGX_SEAL_IV_SIZE 12 + +typedef struct _aes_gcm_data_t +{ + uint32_t payload_size; /* 0: Size of the payload which includes both the encrypted data and the optional additional MAC text */ + uint8_t reserved[12]; /* 4: Reserved bits */ + uint8_t payload_tag[SGX_SEAL_TAG_SIZE]; /* 16: AES-GMAC of the plain text, payload, and the sizes */ + uint8_t payload[]; /* 32: The payload data which includes the encrypted data followed by the optional additional MAC text */ +} sgx_aes_gcm_data_t; + +typedef struct _sealed_data_t +{ + sgx_key_request_t key_request; /* 00: The key request used to obtain the sealing key */ + uint32_t plain_text_offset; /* 64: Offset within aes_data.playload to the start of the optional additional MAC text */ + uint8_t reserved[12]; /* 68: Reserved bits */ + sgx_aes_gcm_data_t aes_data; /* 80: Data structure holding the AES/GCM related data */ +} sgx_sealed_data_t; + +#ifdef __cplusplus +extern "C" { +#endif + /* sgx_calc_sealed_data_size + * Purpose: This function is used to determine how much memory to allocate for sgx_sealed_data_t structure. + * + * Paramters: + * add_mac_txt_size - [IN] Length of the optional additional data stream in bytes + * txt_encrypt_size - [IN] Length of the data stream to be encrypted in bytes + * + * Return Value: + * uint32_t - The minimum number of bytes that need to be allocated for the sgx_sealed_data_t structure + * If the function fails, the return value is UINT32_MAX + */ + uint32_t sgx_calc_sealed_data_size(const uint32_t add_mac_txt_size, const uint32_t txt_encrypt_size); + + /* sgx_get_add_mac_txt_len + * Purpose: This function is used to determine how much memory to allocate for the additional_MAC_text buffer + * + * Parameter: + * p_sealed_data - [IN] Pointer to the sgx_sealed_data_t structure which was populated by the sgx_seal_data function + * + * Return Value: + * uint32_t - The number of bytes in the optional additional MAC buffer + */ + uint32_t sgx_get_add_mac_txt_len(const sgx_sealed_data_t* p_sealed_data); + + /* sgx_get_encrypt_txt_len + * + * Parameter: + * p_sealed_data - [IN] Pointer to the sgx_sealed_data_t structure which was populated by the sgx_seal_data function + * + * Return Value: + * uint32_t - The number of bytes in the encrypted data buffer + * If the function fails, the return value is UINT32_MAX + */ + uint32_t sgx_get_encrypt_txt_len(const sgx_sealed_data_t* p_sealed_data); + + + /* sgx_seal_data + * Purpose: This algorithm is used to AES-GCM encrypt the input data. Specifically, + * two input data sets can be provided, one is the text to encrypt (p_text2encrypt) + * the second being optional additional text that should not be encrypted but will + * be part of the GCM MAC calculation. + * The sgx_sealed_data_t structure should be allocated prior to the API call and + * should include buffer storage for the MAC text and encrypted text. + * The sgx_sealed_data_t structure contains the data required to unseal the data on + * the same system it was sealed. + * + * Parameters: + * additional_MACtext_length - [IN] length of the plaintext data stream in bytes + * The additional data is optional and thus the length + * can be zero if no data is provided + * p_additional_MACtext - [IN] pointer to the plaintext data stream to be GCM protected + * The additional data is optional. You may pass a NULL pointer + * but additional_MACtext_length must be zero in that case + * text2encrypt_length - [IN] length of the data stream to encrypt in bytes + * p_text2encrypt - [IN] pointer to data stream to encrypt + * sealed_data_size - [IN] Size of the sealed data buffer passed in + * p_sealed_data - [OUT] pointer to the sealed data structure containing protected data + * + * Return Value: + * sgx_status_t - SGX Error code + */ + sgx_status_t SGXAPI sgx_seal_data(const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, + const uint32_t text2encrypt_length, + const uint8_t *p_text2encrypt, + const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data); + + /* sgx_seal_data_ex + * Purpose: Expert version of sgx_seal_data which is used if the key_policy/attribute_mask/misc_mask + * need to be modified from the default values. + * + * Parameters: + * key_policy - [IN] Specifies the measurement to use in key derivation + * attribute_mask - [IN] Identifies which platform/enclave attributes to use in key derivation + * misc_mask - [IN] The mask for MISC_SELECT + * additional_MACtext_length - [IN] length of the plaintext data stream in bytes + * The additional data is optional and thus the length + * can be zero if no data is provided + * p_additional_MACtext - [IN] pointer to the plaintext data stream to be GCM protected + * The additional data is optional. You may pass a NULL pointer + * but additional_MACtext_length must be zero in that case + * text2encrypt_length - [IN] length of the data stream to encrypt in bytes + * p_text2encrypt - [IN] pointer to data stream to encrypt + * sealed_data_size - [IN] Size of the sealed data buffer passed in + * p_sealed_data - [OUT] pointer to the sealed data structure containing protected data + * + * Return Value: + * sgx_status_t - SGX Error code + */ + sgx_status_t SGXAPI sgx_seal_data_ex(const uint16_t key_policy, + const sgx_attributes_t attribute_mask, + const sgx_misc_select_t misc_mask, + const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, + const uint32_t text2encrypt_length, + const uint8_t *p_text2encrypt, + const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data); + + /* sgx_unseal_data + * Purpose: Unseal the sealed data structure passed in and populate the MAC text and decrypted text + * buffers with the appropriate data from the sealed data structure. + * + * Parameters: + * p_sealed_data - [IN] pointer to the sealed data structure containing protected data + * p_additional_MACtext - [OUT] pointer to the plaintext data stream which was GCM protected + * The additiona data is optional. You may pass a NULL pointer but + * p_additional_MACtext_length must be zero in that case + * p_additional_MACtext_length - [IN/OUT] pointer to length of the plaintext data stream in bytes + * If there is not additional data, this parameter should be zero. + * p_decrypted_text - [OUT] pointer to decrypted data stream + * p_decrypted_text_length - [IN/OUT] pointer to length of the decrypted data stream to encrypt in bytes + * + * Return Value: + * sgx_status_t - SGX Error code + */ + sgx_status_t SGXAPI sgx_unseal_data(const sgx_sealed_data_t *p_sealed_data, + uint8_t *p_additional_MACtext, + uint32_t *p_additional_MACtext_length, + uint8_t *p_decrypted_text, + uint32_t *p_decrypted_text_length); + + /* sgx_mac_aadata + * Purpose: Use AES-GCM algorithm to generate a sealed data structure with integrity protection. + * Specifically, the input data set is ONLY the plaintext data stream, or + * additional authenticated data(AAD), no encrypt data. + * The sgx_sealed_data_t structure should be allocated prior to the API call and + * should include buffer storage for the plaintext data. + * The sgx_sealed_data_t structure contains the data required to unseal the data on + * the same system it was sealed. + * + * Parameters: + * additional_MACtext_length - [IN] length of the plaintext data stream in bytes + * p_additional_MACtext - [IN] pointer to the plaintext data stream to be GCM protected + * sealed_data_size - [IN] Size of the sealed data buffer passed in + * p_sealed_data - [OUT] pointer to the sealed data structure containing protected data + * + * Return Value: + * sgx_status_t - SGX Error code + */ + sgx_status_t sgx_mac_aadata(const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, + const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data); + + /* sgx_mac_aadata_ex + * Purpose: Expert version of sgx_mac_aadata which is used if the key_policy/attribute_mask/misc_mask + * need to be modified from the default values. + * + * Parameters: + * key_policy - [IN] Specifies the measurement to use in key derivation + * attribute_mask - [IN] Identifies which platform/enclave attributes to use in key derivation + * misc_mask - [IN] The mask for MISC_SELECT + * additional_MACtext_length - [IN] length of the plaintext data stream in bytes + * p_additional_MACtext - [IN] pointer to the plaintext data stream to be GCM protected + * sealed_data_size - [IN] Size of the sealed data buffer passed in + * p_sealed_data - [OUT] pointer to the sealed data structure containing protected data + * + * Return Value: + * sgx_status_t - SGX Error code + */ + sgx_status_t sgx_mac_aadata_ex(const uint16_t key_policy, + const sgx_attributes_t attribute_mask, + const sgx_misc_select_t misc_mask, + const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, + const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data); + + /* sgx_unmac_aadata + * Purpose: Unseal the sealed data structure passed in and populate the plaintext data stream + * with the appropriate data from the sealed data structure. + * + * Parameters: + * p_sealed_data - [IN] pointer to the sealed data structure containing protected data + * p_additional_MACtext - [OUT] pointer to the plaintext data stream which was GCM protected + * p_additional_MACtext_length - [IN/OUT] pointer to length of the plaintext data stream in bytes + * + * Return Value: + * sgx_status_t - SGX Error code + */ + sgx_status_t sgx_unmac_aadata(const sgx_sealed_data_t *p_sealed_data, + uint8_t *p_additional_MACtext, + uint32_t *p_additional_MACtext_length); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_tstdc.edl b/common/inc/sgx_tstdc.edl new file mode 100644 index 0000000000..e92e2218c3 --- /dev/null +++ b/common/inc/sgx_tstdc.edl @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave { + untrusted { + [cdecl] void sgx_oc_cpuidex([in, out] int cpuinfo[4], int leaf, int subleaf); + + /* Go outside and wait on my untrusted event */ + [cdecl] int sgx_thread_wait_untrusted_event_ocall([user_check] const void *self); + + /* Wake a thread waiting on its untrusted event */ + [cdecl] int sgx_thread_set_untrusted_event_ocall([user_check] const void *waiter); + + /* Wake a thread waiting on its untrusted event, and wait on my untrusted event */ + [cdecl] int sgx_thread_setwait_untrusted_events_ocall([user_check] const void *waiter, [user_check] const void *self); + + /* Wake multiple threads waiting on their untrusted events */ + [cdecl] int sgx_thread_set_multiple_untrusted_events_ocall([in, count = total] const void **waiters, size_t total); + }; +}; diff --git a/common/inc/sgx_uae_service.h b/common/inc/sgx_uae_service.h new file mode 100644 index 0000000000..5380c59a57 --- /dev/null +++ b/common/inc/sgx_uae_service.h @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_UAE_SERVICE_H_ +#define _SGX_UAE_SERVICE_H_ + +#include + +#include "sgx_quote.h" +#include "sgx_error.h" +#include "sgx_urts.h" + +#define PS_CAP_TRUSTED_TIME 0x1 +#define PS_CAP_MONOTONIC_COUNTER 0x2 + +/** + * Platform service capabilities + * ps_cap0 + * Bit 0 : Trusted Time + * Bit 1 : Monotonic Counter + * Bit 2-31 : Reserved + * ps_cap1 + * Bit 0-31 : Reserved + */ +typedef struct _sgx_ps_cap_t +{ + uint32_t ps_cap0; + uint32_t ps_cap1; +} sgx_ps_cap_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Function used to initialize the process of quoting. + * + * @param p_target_info[out] Target info of quoting enclave. + * @param p_gid[out] ID of platform's current EPID group. + * @return If outputs are generated, return SGX_SCCUESS, otherwise return general error code + * or SGX_ERROR_AE_INVALID_EPIDBLOB to indicate special error condition. + */ +sgx_status_t SGXAPI sgx_init_quote( + sgx_target_info_t *p_target_info, + sgx_epid_group_id_t *p_gid); + + +/* + * Function used to get quote size. + * + * @param p_sig_rl[in] OPTIONAL Signature Revocation List. + * @param p_quote_size[out] Quote size, in bytes. + * @return If quote size is calculated,return SGX_SCCUESS, otherwise return + * SGX_ERROR_INVALID_PARAMETER to indicate special error condition. + */ +sgx_status_t SGXAPI sgx_get_quote_size( + const uint8_t *p_sig_rl, + uint32_t* p_quote_size); + +/* + * Function used to get quote. + * + * @param p_report[in] Report of enclave for which quote is being calculated. + * @param quote_type[in] Linkable or unlinkable quote. + * @param p_spid[in] Pointer of SPID. + * @param p_nonce[in] OPTIONAL nonce. + * @param p_sig_rl[in] OPTIONAL list of signature made fore EPID. + * @param sig_rl_size[in] The size of p_sig_rl, in bytes. + * @param p_qe_report[out] OPTIONAL The QE report. + * @param p_quote[out] The quote buffer, can not be NULL. + * @param quote_size[in] Quote buffer size, in bytes. + * @return If quote is generated,return SGX_SCCUESS, + * error code or SGX_ERROR_AE_INVALID_EPIDBLOB, + * SGX_ERROR_INVALID_PARAMETER to indicate special error condition. + * SGX_ERROR_EPID_MEMBER_REVOKED to indicate the EPID group membership has been revoked. + */ +sgx_status_t SGXAPI sgx_get_quote( + const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + const sgx_spid_t *p_spid, + const sgx_quote_nonce_t *p_nonce, + const uint8_t *p_sig_rl, + uint32_t sig_rl_size, + sgx_report_t *p_qe_report, + sgx_quote_t *p_quote, + uint32_t quote_size); + +/** + * Get the platform service capabilities + * + * @param sgx_ps_cap Platform capabilities reported by AESM. + * @return if OK, return SGX_SUCCESS + */ +sgx_status_t SGXAPI sgx_get_ps_cap(sgx_ps_cap_t* p_sgx_ps_cap); + +#define SGX_IS_TRUSTED_TIME_AVAILABLE(cap) ((((uint32_t)PS_CAP_TRUSTED_TIME)&((cap).ps_cap0))!=0) +#define SGX_IS_MONOTONIC_COUNTER_AVAILABLE(cap) ((((uint32_t)PS_CAP_MONOTONIC_COUNTER)&((cap).ps_cap0))!=0) + +/* + * Function used to report the status of the attestation. + * + * @param p_platform_info[in] platform information received from Intel Attestation Server. + * @param attestation_status[in] Value representing status during attestation. 0 if attestation succeeds. + * @param p_update_info[out] update information of the SGX platform. + * @return If OK, return SGX_SUCCESS. If update is needed, return SGX_ERROR_UPDATE_NEEDED and update_info contains update information. + */ + +sgx_status_t SGXAPI sgx_report_attestation_status( + const sgx_platform_info_t* p_platform_info, + int attestation_status, + sgx_update_info_bit_t* p_update_info); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_ukey_exchange.h b/common/inc/sgx_ukey_exchange.h new file mode 100644 index 0000000000..0f1e79f506 --- /dev/null +++ b/common/inc/sgx_ukey_exchange.h @@ -0,0 +1,199 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SGX_UKEY_EXCHANGE_H_ +#define _SGX_UKEY_EXCHANGE_H_ + +#include "sgx_eid.h" +#include "sgx_defs.h" +#include "sgx_key_exchange.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef sgx_status_t (* sgx_ecall_get_ga_trusted_t)( + sgx_enclave_id_t eid, + sgx_status_t* retval, + sgx_ra_context_t context, + sgx_ec256_public_t *g_a); + +typedef sgx_status_t (* sgx_ecall_proc_msg2_trusted_t)( + sgx_enclave_id_t eid, + sgx_status_t* retval, + sgx_ra_context_t context, + const sgx_ra_msg2_t *p_msg2, + const sgx_target_info_t *p_qe_target, + sgx_report_t *p_report, + sgx_quote_nonce_t* nonce); + +typedef sgx_status_t (* sgx_ecall_get_msg3_trusted_t)( + sgx_enclave_id_t eid, + sgx_status_t* retval, + sgx_ra_context_t context, + uint32_t quote_size, + sgx_report_t* qe_report, + sgx_ra_msg3_t *p_msg3, + uint32_t msg3_size); + +/* + * sgx_ra_get_msg1 is used to get the remote attestation and key exchange + * protocol message 1 to send to a service provider. The application enclave + * should use sgx_ra_init function to create the remote attestation and key + * exchange process context and return to the untrusted code, before the + * untrusted code can invoke this function. + * + * @param context Context returned by the sgx_ra_init function inside the + * application enclave. + * @param eid ID of the application enclave which is going to be + * attested. + * @param p_get_ga Function pointer of the ECALL proxy sgx_ra_get_ga + * generated by sgx_edger8r. The application enclave should + * link with sgx_tkey_exchange library and import + * sgx_tkey_exchange.edl in the enclave's EDL file to + * expose the ECALL proxy for sgx_ra_get_ga. + * @param p_msg1 Message 1 used by the remote attestation and key + * exchange protocol. + * @return sgx_status_t SGX_SUCCESS Indicates success. + * SGX_ERROR_INVALID_PARAMETER Invalid input parameters + * detected. + * SGX_ERROR_AE_INVALID_EPIDBLOB The EPID blob is + * corrupted. + * SGX_ERROR_INVALID_STATE SGX API is invoked in + * incorrect order or + * state. + * SGX_ERROR_EPID_MEMBER_REVOKED The EPID group + * membership revoked. + * SGX_ERROR_BUSY The requested service is + * temporarily not + * available. + * SGX_ERROR_UPDATE_NEEDED SGX needs to be updated. + * SGX_ERROR_SERVICE_UNAVAILABLE The AE service did not + * respond. + * SGX_ERROR_SERVICE_TIMEOUT A request to the AE + * service timed out. + * SGX_ERROR_NETWORK_FAILURE Network connecting or + * proxy setting issue was + * encountered. + * SGX_ERROR_OUT_OF_MEMORY There is not enough + * memory available to + * complete this operation. + * SGX_ERROR_UNEXPECTED Indicates an unexpected + * error occurs. + * And other possible return code from sgx_ecall. + */ +sgx_status_t SGXAPI sgx_ra_get_msg1( + sgx_ra_context_t context, + sgx_enclave_id_t eid, + sgx_ecall_get_ga_trusted_t p_get_ga, + sgx_ra_msg1_t *p_msg1); + +/* + * sgx_ra_get_msg2 is used to process the remote attestation and key exchange + * protocol message 2 from the service provider and generate message 3 to send + * to the service provider. If the service provider accepts message 3, + * negotiated session keys between the application enclave and the service + * provider are ready for use. The application enclave can use sgx_ra_get_keys + * function to retrieve the negotiated keys and use sgx_ra_close function to + * release the context of the remote attestation and key exchange process. + * + * @param context Context returned by the sgx_ra_init function inside the + * application enclave. + * @param eid ID of the application enclave which is going to be + * attested. + * @param p_proc_msg2 Function pointer of the ECALL proxy sgx_ra_proc_msg2_trusted + * generated by sgx_edger8r. The application enclave should + * link with sgx_tkey_exchange library and import the + * sgx_tkey_exchange.edl in the application enclave's EDL + * file to expose the ECALL proxy for sgx_ra_get_msg2. + * @param p_get_msg3 Function pointer of the ECALL proxy sgx_ra_get_msg3_trusted + * generated by sgx_edger8r. The application enclave should + * link with sgx_tkey_exchange library and import the + * sgx_tkey_exchange.edl in the application enclave's EDL + * file to expose the ECALL proxy for sgx_ra_get_msg3. + * @param p_msg2 sgx_ra_msg2_t message 2 from the service provider + * received by application. + * @param msg2_size The length of msg2 (in bytes). + * @param pp_msg3 sgx_ra_msg3_t message 3 to be sent to the service + * provider. The message buffer is allocated by the + * sgx_ukey_exchange library. The caller should free the + * buffer after use. + * @param p_msg3_size The length of msg3 (in bytes). + * @return sgx_status_t SGX_SUCCESS Indicates success. + * SGX_ERROR_INVALID_PARAMETER Invalid input parameters + * detected. + * SGX_ERROR_AE_INVALID_EPIDBLOB The EPID blob is + * corrupted. + * SGX_ERROR_INVALID_STATE SGX API is invoked in + * incorrect order or + * state. + * SGX_ERROR_EPID_MEMBER_REVOKED The EPID group + * membership revoked. + * SGX_ERROR_INVALID_SIGNATURE The signature is invalid. + * SGX_ERROR_MAC_MISMATCH Indicates verification + * error for reports, sealed + * data, etc. + * SGX_ERROR_KDF_MISMATCH Indicates key derivation + * function doesn't match. + * SGX_ERROR_BUSY The requested service is + * temporarily not + * available. + * SGX_ERROR_UPDATE_NEEDED SGX needs to be updated. + * SGX_ERROR_SERVICE_UNAVAILABLE The AE service did not + * respond. + * SGX_ERROR_SERVICE_TIMEOUT A request to the AE + * service timed out. + * SGX_ERROR_NETWORK_FAILURE Network connecting or + * proxy setting issue was + * encountered. + * SGX_ERROR_OUT_OF_MEMORY There is not enough + * memory available to + * complete this operation. + * SGX_ERROR_UNEXPECTED Indicates an unexpected + * error occurs. + * And other possible return code from sgx_ecall. + */ +sgx_status_t SGXAPI sgx_ra_proc_msg2( + sgx_ra_context_t context, + sgx_enclave_id_t eid, + sgx_ecall_proc_msg2_trusted_t p_proc_msg2, + sgx_ecall_get_msg3_trusted_t p_get_msg3, + const sgx_ra_msg2_t *p_msg2, + uint32_t msg2_size, + sgx_ra_msg3_t **pp_msg3, + uint32_t *p_msg3_size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/sgx_urts.h b/common/inc/sgx_urts.h new file mode 100644 index 0000000000..c1bfa65183 --- /dev/null +++ b/common/inc/sgx_urts.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _SGX_URTS_H_ +#define _SGX_URTS_H_ + +#include "sgx_attributes.h" +#include "sgx_error.h" +#include "sgx_eid.h" +#include "sgx_defs.h" +#include "sgx_key.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint8_t sgx_launch_token_t[1024]; + +/* Convenient macro to be passed to sgx_create_enclave(). */ +#if !defined(NDEBUG) || defined(EDEBUG) +#define SGX_DEBUG_FLAG ((int)1) +#else +#define SGX_DEBUG_FLAG ((int)0) +#endif + +sgx_status_t SGXAPI sgx_create_enclave(const char *file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr); + +sgx_status_t SGXAPI sgx_destroy_enclave(const sgx_enclave_id_t enclave_id); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/common/inc/sgx_utils.h b/common/inc/sgx_utils.h new file mode 100644 index 0000000000..0d8420b753 --- /dev/null +++ b/common/inc/sgx_utils.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +/** + * File: sgx_utils.h + * Description: + * Trusted library for SGX instructions + */ + +#ifndef _SGX_UTILS_H_ +#define _SGX_UTILS_H_ + +#include "sgx.h" +#include "sgx_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*sgx_create_report + * Purpose: Create a cryptographic report of the enclave using the input information if any. + * + * Parameters: + * target_info - [IN] pointer to the information of the target enclave. + * report_data - [IN] pointer to a set of data used for communication between the enclaves. + * report - [OUT] pointer to the cryptographic report of the enclave + * + * Return value: + * sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h. +*/ +sgx_status_t SGXAPI sgx_create_report(const sgx_target_info_t *target_info, const sgx_report_data_t *report_data, sgx_report_t *report); + +/* sgx_verify_report + * Purpose: Software verification for the input report + * + * Paramters: + * report - [IN] ponter to the cryptographic report to be verified. + * + * Return value: + * sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h. +*/ +sgx_status_t SGXAPI sgx_verify_report(const sgx_report_t *report); + +/*sgx_get_key + * Purpose: Generate a 128-bit secret key with the input information. + * + * Parameters: + * key_request - [IN] pointer to the sgx_key_request_t object used for selecting the appropriate key. + * key - [OUT] Pointer to the buffer that receives the cryptographic key output. + * + * Return value: + * sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h. +*/ +sgx_status_t SGXAPI sgx_get_key(const sgx_key_request_t *key_request, sgx_key_128bit_t *key); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/inc/stdc++/exception b/common/inc/stdc++/exception new file mode 100644 index 0000000000..0389bfd199 --- /dev/null +++ b/common/inc/stdc++/exception @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _EXCEPTION_ +#define _EXCEPTION_ + +#include +#include SGX_CXX_NATIVE_HEADER(exception) + +#endif /* _EXCEPTION_ */ diff --git a/common/inc/stdc++/linux/exception b/common/inc/stdc++/linux/exception new file mode 100644 index 0000000000..afcb0feac1 --- /dev/null +++ b/common/inc/stdc++/linux/exception @@ -0,0 +1,77 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUX_EXCEPTION_ +#define _LINUX_EXCEPTION_ + + +namespace std +{ + class exception + { + public: + exception() throw(); + exception(const exception&) throw(); + exception& operator=(const exception&) throw(); + virtual ~exception(); + virtual const char* what() const throw(); + }; + + /** + * Bad allocation exception. Thrown by ::operator new() if it fails. + */ + class bad_alloc: public exception + { + public: + bad_alloc() throw(); + bad_alloc(const bad_alloc&) throw(); + bad_alloc& operator=(const bad_alloc&) throw(); + ~bad_alloc(); + virtual const char* what() const throw(); + }; + + class bad_exception : public exception + { + public: + bad_exception() throw(); + virtual ~bad_exception() throw(); + virtual const char* what() const throw(); + }; + + bool uncaught_exception() throw(); + + typedef void (*unexpected_handler)(); + unexpected_handler set_unexpected(unexpected_handler) throw(); + void unexpected(); + + typedef void (*terminate_handler)(); + terminate_handler set_terminate(terminate_handler) throw(); + void terminate(); + +} // namespace std + + +#endif /* _LINUX_EXCEPTION_ */ diff --git a/common/inc/stdc++/linux/typeinfo b/common/inc/stdc++/linux/typeinfo new file mode 100644 index 0000000000..a32df180f6 --- /dev/null +++ b/common/inc/stdc++/linux/typeinfo @@ -0,0 +1,138 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUX_TYPEINFO_ +#define _LINUX_TYPEINFO_ + +#include +#include "exception" + +namespace __cxxabiv1 +{ + struct __class_type_info; +} +namespace std +{ + /** + * Standard type info class. The layout of this class is specified by the + * ABI. The layout of the vtable is not, but is intended to be + * compatible with the GNU ABI. + * + * Unlike the GNU version, the vtable layout is considered semi-private. + */ + class type_info + { + public: + /** + * Virtual destructor. This class must have one virtual function to + * ensure that it has a vtable. + */ + virtual ~type_info(); + bool operator==(const type_info &) const; + bool operator!=(const type_info &) const; + bool before(const type_info &) const; + const char* name() const; + type_info(); + private: + type_info(const type_info& rhs); + type_info& operator= (const type_info& rhs); + const char *__type_name; + /* + * The following functions are in this order to match the + * vtable layout of libsupc++. This allows libcxxrt to be used + * with libraries that depend on this. + * + * These functions are in the public headers for libstdc++, so + * we have to assume that someone will probably call them and + * expect them to work. Their names must also match the names used in + * libsupc++, so that code linking against this library can subclass + * type_info and correctly fill in the values in the vtables. + */ + public: + /** + * Returns true if this is some pointer type, false otherwise. + */ + virtual bool __is_pointer_p() const { return false; } + /** + * Returns true if this is some function type, false otherwise. + */ + virtual bool __is_function_p() const { return false; } + /** + * Catch function. Allows external libraries to implement + * their own basic types. This is used, for example, in the + * GNUstep Objective-C runtime to allow Objective-C types to be + * caught in G++ catch blocks. + * + * The outer parameter indicates the number of outer pointers + * in the high bits. The low bit indicates whether the + * pointers are const qualified. + */ + virtual bool __do_catch(const type_info *thrown_type, + void **thrown_object, + unsigned outer) const; + /** + * Performs an upcast. This is used in exception handling to + * cast from subclasses to superclasses. If the upcast is + * possible, it returns true and adjusts the pointer. If the + * upcast is not possible, it returns false and does not adjust + * the pointer. + */ + virtual bool __do_upcast( + const __cxxabiv1::__class_type_info *target, + void **thrown_object) const + { + (void)target, (void)thrown_object; + return false; + } + }; + + /** + * Bad cast exception. Thrown by the __cxa_bad_cast() helper function. + */ + class bad_cast: public exception { + public: + bad_cast() throw(); + bad_cast(const bad_cast&) throw(); + bad_cast& operator=(const bad_cast&) throw(); + virtual ~bad_cast(); + virtual const char* what() const throw(); + }; + + /** + * Bad typeidexception. Thrown by the __cxa_bad_typeid() helper function. + */ + class bad_typeid: public exception + { + public: + bad_typeid() throw(); + bad_typeid(const bad_typeid &__rhs) throw(); + virtual ~bad_typeid(); + bad_typeid& operator=(const bad_typeid &__rhs) throw(); + virtual const char* what() const throw(); + }; +} + +#endif /* _LINUX_TYPEINFO_ */ diff --git a/common/inc/stdc++/new b/common/inc/stdc++/new new file mode 100644 index 0000000000..fbf11fb67d --- /dev/null +++ b/common/inc/stdc++/new @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _NEW_ +#define _NEW_ + +#include +#include +#include + + +namespace std +{ + typedef void (*new_handler)(); // The type of the function called when allocation fails. + + struct nothrow_t {}; // placement new tag type to suppress exceptions + const nothrow_t nothrow = {}; // constant for placement new tag + + /* + * The function to call when allocation fails. By default, there is no + * handler and a bad allocation exception is thrown if an allocation fails. + */ + new_handler set_new_handler(new_handler handler) throw(); +}; + +void* SGXAPI operator new (size_t) throw (std::bad_alloc); +void* SGXAPI operator new[] (size_t) throw (std::bad_alloc); + +void* SGXAPI operator new (size_t, const std::nothrow_t&) throw(); +void* SGXAPI operator new (size_t, void*) throw(); +void* SGXAPI operator new[] (size_t, const std::nothrow_t&) throw(); +void* SGXAPI operator new[] (size_t, void*) throw(); + +void SGXAPI operator delete (void*) throw (); +void SGXAPI operator delete (void*, const std::nothrow_t&) throw(); +void SGXAPI operator delete (void*, void*) throw(); +void SGXAPI operator delete[] (void*) throw (); +void SGXAPI operator delete[] (void*, const std::nothrow_t&) throw(); +void SGXAPI operator delete[] (void*, void*) throw(); + +#endif /* _NEW_ */ diff --git a/common/inc/stdc++/typeinfo b/common/inc/stdc++/typeinfo new file mode 100644 index 0000000000..fa9c05e737 --- /dev/null +++ b/common/inc/stdc++/typeinfo @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _TYPEINFO_ +#define _TYPEINFO_ + +#include +#include SGX_CXX_NATIVE_HEADER(typeinfo) + +#endif /* _TYPEINFO_ */ diff --git a/common/inc/tlibc/assert.h b/common/inc/tlibc/assert.h new file mode 100644 index 0000000000..82489e80c0 --- /dev/null +++ b/common/inc/tlibc/assert.h @@ -0,0 +1,63 @@ +/* $OpenBSD: assert.h,v 1.12 2006/01/31 10:53:51 hshoexer Exp $ */ +/* $NetBSD: assert.h,v 1.6 1994/10/26 00:55:44 cgd Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)assert.h 8.2 (Berkeley) 1/21/94 + */ + +/* + * Unlike other ANSI header files, may usefully be included + * multiple times, with and without NDEBUG defined. + */ + +#include + +#undef assert + +#ifdef NDEBUG +# define assert(e) ((void)0) +#else +# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, __func__, #e)) +#endif + +#ifndef _ASSERT_H_DECLS +#define _ASSERT_H_DECLS +__BEGIN_DECLS + +void _TLIBC_CDECL_ __assert(const char *, int, const char *, const char *); + +__END_DECLS +#endif /* Not _ASSERT_H_DECLS */ + diff --git a/common/inc/tlibc/complex.h b/common/inc/tlibc/complex.h new file mode 100644 index 0000000000..7d92d63e87 --- /dev/null +++ b/common/inc/tlibc/complex.h @@ -0,0 +1,134 @@ +/* $OpenBSD: complex.h,v 1.3 2010/07/24 22:17:03 guenther Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _COMPLEX_H_ +#define _COMPLEX_H_ + +#include + +/* + * C99 + */ +#ifdef __GNUC__ +#if __STDC_VERSION__ < 199901 +#define _Complex __complex__ +#endif +#define _Complex_I 1.0fi +#elif defined(lint) +#define _Complex_I 1.0fi +#endif + +#define complex _Complex + +/* XXX switch to _Imaginary_I */ +#undef I +#define I _Complex_I + +__BEGIN_DECLS +/* + * Double versions of C99 functions + */ +double complex cacos(double complex); +double complex casin(double complex); +double complex catan(double complex); +double complex ccos(double complex); +double complex csin(double complex); +double complex ctan(double complex); +double complex cacosh(double complex); +double complex casinh(double complex); +double complex catanh(double complex); +double complex ccosh(double complex); +double complex csinh(double complex); +double complex ctanh(double complex); +double complex cexp(double complex); +double complex clog(double complex); +double cabs(double complex); +double complex cpow(double complex, double complex); +double complex csqrt(double complex); +double carg(double complex); +double cimag(double complex); +double complex conj(double complex); +double complex cproj(double complex); +double creal(double complex); +/* + * C99 reserved + */ +double complex clog10(double complex); + +/* + * Float versions of C99 functions + */ +float complex cacosf(float complex); +float complex casinf(float complex); +float complex catanf(float complex); +float complex ccosf(float complex); +float complex csinf(float complex); +float complex ctanf(float complex); +float complex cacoshf(float complex); +float complex casinhf(float complex); +float complex catanhf(float complex); +float complex ccoshf(float complex); +float complex csinhf(float complex); +float complex ctanhf(float complex); +float complex cexpf(float complex); +float complex clogf(float complex); +float cabsf(float complex); +float complex cpowf(float complex, float complex); +float complex csqrtf(float complex); +float cargf(float complex); +float cimagf(float complex); +float complex conjf(float complex); +float complex cprojf(float complex); +float crealf(float complex); +/* + * C99 reserved + */ +float complex clog10f(float complex); + +/* + * Long double versions of C99 functions + */ +long double complex cacosl(long double complex); +long double complex casinl(long double complex); +long double complex catanl(long double complex); +long double complex ccosl(long double complex); +long double complex csinl(long double complex); +long double complex ctanl(long double complex); +long double complex cacoshl(long double complex); +long double complex casinhl(long double complex); +long double complex catanhl(long double complex); +long double complex ccoshl(long double complex); +long double complex csinhl(long double complex); +long double complex ctanhl(long double complex); +long double complex cexpl(long double complex); +long double complex clogl(long double complex); +long double cabsl(long double complex); +long double complex cpowl(long double complex, long double complex); +long double complex csqrtl(long double complex); +long double cargl(long double complex); +long double cimagl(long double complex); +long double complex conjl(long double complex); +long double complex cprojl(long double complex); +long double creall(long double complex); +/* + * C99 reserved + */ +long double complex clog10l(long double complex); + +__END_DECLS + +#endif /* !_COMPLEX_H_ */ diff --git a/common/inc/tlibc/ctype.h b/common/inc/tlibc/ctype.h new file mode 100644 index 0000000000..1408447059 --- /dev/null +++ b/common/inc/tlibc/ctype.h @@ -0,0 +1,64 @@ +/* $OpenBSD: ctype.h,v 1.22 2010/10/01 20:10:24 guenther Exp $ */ +/* $NetBSD: ctype.h,v 1.14 1994/10/26 00:55:47 cgd Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ctype.h 5.3 (Berkeley) 4/3/91 + */ + +#ifndef _CTYPE_H_ +#define _CTYPE_H_ + +#include + +__BEGIN_DECLS + +int _TLIBC_CDECL_ isalnum(int); +int _TLIBC_CDECL_ isalpha(int); +int _TLIBC_CDECL_ iscntrl(int); +int _TLIBC_CDECL_ isdigit(int); +int _TLIBC_CDECL_ isgraph(int); +int _TLIBC_CDECL_ islower(int); +int _TLIBC_CDECL_ isprint(int); +int _TLIBC_CDECL_ ispunct(int); +int _TLIBC_CDECL_ isspace(int); +int _TLIBC_CDECL_ isupper(int); +int _TLIBC_CDECL_ isxdigit(int); +int _TLIBC_CDECL_ tolower(int); +int _TLIBC_CDECL_ toupper(int); +int _TLIBC_CDECL_ isblank(int); + +__END_DECLS + +#endif /* _CTYPE_H_ */ diff --git a/common/inc/tlibc/endian.h b/common/inc/tlibc/endian.h new file mode 100644 index 0000000000..fcd74c9a14 --- /dev/null +++ b/common/inc/tlibc/endian.h @@ -0,0 +1,33 @@ +/* $OpenBSD: endian.h,v 1.18 2006/03/27 07:09:24 otto Exp $ */ + +/*- + * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ENDIAN_H_ +#define _ENDIAN_H_ + +#include + +#endif /* _ENDIAN_H_ */ + diff --git a/common/inc/tlibc/errno.h b/common/inc/tlibc/errno.h new file mode 100644 index 0000000000..0924d5ac4b --- /dev/null +++ b/common/inc/tlibc/errno.h @@ -0,0 +1,187 @@ +/* $OpenBSD: errno.h,v 1.1 2005/12/28 16:33:56 millert Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)errno.h 8.5 (Berkeley) 1/21/94 + */ + +#ifndef _ERRNO_H_ +#define _ERRNO_H_ + +#include + +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 +#define ELOOP 40 +#define EWOULDBLOCK EAGAIN +#define ENOMSG 42 +#define EIDRM 43 +#define ECHRNG 44 +#define EL2NSYNC 45 +#define EL3HLT 46 +#define EL3RST 47 +#define ELNRNG 48 +#define EUNATCH 49 +#define ENOCSI 50 +#define EL2HLT 51 +#define EBADE 52 +#define EBADR 53 +#define EXFULL 54 +#define ENOANO 55 +#define EBADRQC 56 +#define EBADSLT 57 +#define EDEADLOCK EDEADLK +#define EBFONT 59 +#define ENOSTR 60 +#define ENODATA 61 +#define ETIME 62 +#define ENOSR 63 +#define ENONET 64 +#define ENOPKG 65 +#define EREMOTE 66 +#define ENOLINK 67 +#define EADV 68 +#define ESRMNT 69 +#define ECOMM 70 +#define EPROTO 71 +#define EMULTIHOP 72 +#define EDOTDOT 73 +#define EBADMSG 74 +#define EOVERFLOW 75 +#define ENOTUNIQ 76 +#define EBADFD 77 +#define EREMCHG 78 +#define ELIBACC 79 +#define ELIBBAD 80 +#define ELIBSCN 81 +#define ELIBMAX 82 +#define ELIBEXEC 83 +#define EILSEQ 84 +#define ERESTART 85 +#define ESTRPIPE 86 +#define EUSERS 87 +#define ENOTSOCK 88 +#define EDESTADDRREQ 89 +#define EMSGSIZE 90 +#define EPROTOTYPE 91 +#define ENOPROTOOPT 92 +#define EPROTONOSUPPORT 93 +#define ESOCKTNOSUPPORT 94 +#define EOPNOTSUPP 95 +#define EPFNOSUPPORT 96 +#define EAFNOSUPPORT 97 +#define EADDRINUSE 98 +#define EADDRNOTAVAIL 99 +#define ENETDOWN 100 +#define ENETUNREACH 101 +#define ENETRESET 102 +#define ECONNABORTED 103 +#define ECONNRESET 104 +#define ENOBUFS 105 +#define EISCONN 106 +#define ENOTCONN 107 +#define ESHUTDOWN 108 +#define ETOOMANYREFS 109 +#define ETIMEDOUT 110 +#define ECONNREFUSED 111 +#define EHOSTDOWN 112 +#define EHOSTUNREACH 113 +#define EALREADY 114 +#define EINPROGRESS 115 +#define ESTALE 116 +#define EUCLEAN 117 +#define ENOTNAM 118 +#define ENAVAIL 119 +#define EISNAM 120 +#define EREMOTEIO 121 +#define EDQUOT 122 +#define ENOMEDIUM 123 +#define EMEDIUMTYPE 124 +#define ECANCELED 125 +#define ENOKEY 126 +#define EKEYEXPIRED 127 +#define EKEYREVOKED 128 +#define EKEYREJECTED 129 +#define EOWNERDEAD 130 +#define ENOTRECOVERABLE 131 +#define ERFKILL 132 +#define EHWPOISON 133 +#define ENOTSUP EOPNOTSUPP + +__BEGIN_DECLS + +#ifndef errno +int * _TLIBC_CDECL_ __errno(void); +#define errno (*__errno()) +#endif /* errno */ +__END_DECLS + +#endif /* _ERRNO_H_ */ diff --git a/common/inc/tlibc/float.h b/common/inc/tlibc/float.h new file mode 100644 index 0000000000..99ae58de83 --- /dev/null +++ b/common/inc/tlibc/float.h @@ -0,0 +1,84 @@ +/* $OpenBSD: float.h,v 1.3 2008/07/21 20:50:54 martynas Exp $ */ +/* $NetBSD: float.h,v 1.8 1995/06/20 20:45:37 jtc Exp $ */ + +/* + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)float.h 7.1 (Berkeley) 5/8/90 + */ + +#ifndef _FLOAT_H_ +#define _FLOAT_H_ + +#include + +#define FLT_RADIX 2 /* b */ + +// The rounding direction can be specified by fesetround() in +#define FLT_ROUNDS 1 /* addition rounding: near */ +#define DECIMAL_DIG 21 /* max precision in decimal digits */ + +// NOTE: FLT_EVAL_METHOD is -1 under FREEBSD x86. +#ifdef __i386__ +#define FLT_EVAL_METHOD 2 /* long double */ +#else +#define FLT_EVAL_METHOD 0 /* no promotions */ +#endif + +#define DBL_MANT_DIG 53 +#define DBL_EPSILON 2.2204460492503131E-16 +#define DBL_DIG 15 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN 2.2250738585072014E-308 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP 1024 +#define DBL_MAX_10_EXP 308 + +#define FLT_MANT_DIG 24 /* p */ +#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ +#define FLT_MIN_EXP (-125) /* emin */ +#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ +#define FLT_MAX_EXP 128 /* emax */ +#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ + +#define DBL_MAX 1.7976931348623157E+308 +#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ +#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ +#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ + +#define LDBL_MANT_DIG 64 +#define LDBL_EPSILON 1.08420217248550443401e-19L +#define LDBL_DIG 18 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 3.36210314311209350626e-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX 1.18973149535723176502e+4932L +#define LDBL_MAX_10_EXP 4932 + +#endif /* _FLOAT_H_ */ diff --git a/common/inc/tlibc/inttypes.h b/common/inc/tlibc/inttypes.h new file mode 100644 index 0000000000..c4fbcafc32 --- /dev/null +++ b/common/inc/tlibc/inttypes.h @@ -0,0 +1,330 @@ +/* $OpenBSD: inttypes.h,v 1.10 2009/01/13 18:13:51 kettenis Exp $ */ + +/* + * Copyright (c) 1997, 2005 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _INTTYPES_H_ +#define _INTTYPES_H_ + +#include + +/* + * 7.8.1 Macros for format specifiers + * + * Each of the following object-like macros expands to a string + * literal containing a conversion specifier, possibly modified by + * a prefix such as hh, h, l, or ll, suitable for use within the + * format argument of a formatted input/output function when + * converting the corresponding integer type. These macro names + * have the general form of PRI (character string literals for the + * fprintf family) or SCN (character string literals for the fscanf + * family), followed by the conversion specifier, followed by a + * name corresponding to a similar typedef name. For example, + * PRIdFAST32 can be used in a format string to print the value of + * an integer of type int_fast32_t. + */ + +/* fprintf macros for signed integers */ +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#ifdef __x86_64__ +#define PRId64 "ld" /* int64_t */ +#else +#define PRId64 "lld" /* int64_t */ +#endif + +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#ifdef __x86_64__ +#define PRIdLEAST64 "ld" /* int_least64_t */ +#else +#define PRIdLEAST64 "lld" /* int_least64_t */ +#endif + +#define PRIdFAST8 "d" /* int_fast8_t */ +#ifdef __x86_64__ +#define PRIdFAST16 "ld" /* int_fast16_t */ +#define PRIdFAST32 "ld" /* int_fast32_t */ +#define PRIdFAST64 "ld" /* int_fast64_t */ +#else +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "lld" /* int_fast64_t */ +#endif + +#ifdef __x86_64__ +#define PRIdMAX "ld" /* intmax_t */ +#else +#if defined(__i386__) +#define PRIdMAX "lld" /* intmax_t */ +#else +#define PRIdMAX "jd" /* intmax_t */ +#endif +#endif + +#ifdef __i386__ +#define PRIdPTR "d" /* intptr_t */ +#else +#define PRIdPTR "ld" /* intptr_t */ +#endif + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#ifdef __x86_64__ +#define PRIi64 "li" /* int64_t */ +#else +#define PRIi64 "lli" /* int64_t */ +#endif + +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#ifdef __x86_64__ +#define PRIiLEAST64 "li" /* int_least64_t */ +#else +#define PRIiLEAST64 "lli" /* int_least64_t */ +#endif + +#define PRIiFAST8 "i" /* int_fast8_t */ +#ifdef __x86_64__ +#define PRIiFAST16 "li" /* int_fast16_t */ +#define PRIiFAST32 "li" /* int_fast32_t */ +#define PRIiFAST64 "li" /* int_fast64_t */ +#else +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "lli" /* int_fast64_t */ +#endif + +#ifdef __x86_64__ +#define PRIiMAX "li" /* intmax_t */ +#else +#if defined(__i386__) +#define PRIiMAX "lli" /* intmax_t */ +#else +#define PRIiMAX "ji" /* intmax_t */ +#endif +#endif + +#ifdef __i386__ +#define PRIiPTR "i" /* intptr_t */ +#else +#define PRIiPTR "li" /* intptr_t */ +#endif + +/* fprintf macros for unsigned integers */ +#define PRIo8 "o" /* int8_t */ +#define PRIo16 "o" /* int16_t */ +#define PRIo32 "o" /* int32_t */ +#ifdef __x86_64__ +#define PRIo64 "lo" /* int64_t */ +#else +#define PRIo64 "llo" /* int64_t */ +#endif + +#define PRIoLEAST8 "o" /* int_least8_t */ +#define PRIoLEAST16 "o" /* int_least16_t */ +#define PRIoLEAST32 "o" /* int_least32_t */ +#ifdef __x86_64__ +#define PRIoLEAST64 "lo" /* int_least64_t */ +#else +#define PRIoLEAST64 "llo" /* int_least64_t */ +#endif + +#define PRIoFAST8 "o" /* int_fast8_t */ +#ifdef __x86_64__ +#define PRIoFAST16 "lo" /* int_fast16_t */ +#define PRIoFAST32 "lo" /* int_fast32_t */ +#define PRIoFAST64 "lo" /* int_fast64_t */ +#else +#define PRIoFAST16 "o" /* int_fast16_t */ +#define PRIoFAST32 "o" /* int_fast32_t */ +#define PRIoFAST64 "llo" /* int_fast64_t */ +#endif + +#ifdef __x86_64__ +#define PRIoMAX "lo" /* intmax_t */ +#else +#if defined(__i386__) +#define PRIoMAX "llo" /* intmax_t */ +#else +#define PRIoMAX "jo" /* intmax_t */ +#endif +#endif + +#ifdef __i386__ +#define PRIoPTR "o" /* intptr_t */ +#else +#define PRIoPTR "lo" /* intptr_t */ +#endif + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ + +#ifdef __x86_64__ +#define PRIu64 "lu" /* uint64_t */ +#else +#define PRIu64 "llu" /* uint64_t */ +#endif + +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ + +#ifdef __x86_64__ +#define PRIuLEAST64 "lu" /* uint_least64_t */ +#else +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#endif + +#define PRIuFAST8 "u" /* uint_fast8_t */ + +#ifdef __x86_64__ +#define PRIuFAST16 "lu" /* uint_fast16_t */ +#define PRIuFAST32 "lu" /* uint_fast32_t */ +#define PRIuFAST64 "lu" /* uint_fast64_t */ +#else +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#endif + +#ifdef __x86_64__ +#define PRIuMAX "lu" /* uintmax_t */ +#else +#if defined(__i386__) +#define PRIuMAX "llu" /* uintmax_t */ +#else +#define PRIuMAX "ju" /* uintmax_t */ +#endif +#endif + +#ifdef __i386__ +#define PRIuPTR "u" /* uintptr_t */ +#else +#define PRIuPTR "lu" /* uintptr_t */ +#endif + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#ifdef __x86_64__ +#define PRIx64 "lx" /* uint64_t */ +#else +#define PRIx64 "llx" /* uint64_t */ +#endif + +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#ifdef __x86_64__ +#define PRIxLEAST64 "lx" /* uint_least64_t */ +#else +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#endif + +#define PRIxFAST8 "x" /* uint_fast8_t */ +#ifdef __x86_64__ +#define PRIxFAST16 "lx" /* uint_fast16_t */ +#define PRIxFAST32 "lx" /* uint_fast32_t */ +#define PRIxFAST64 "lx" /* uint_fast64_t */ +#else +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#endif + +#ifdef __x86_64__ +#define PRIxMAX "lx" /* uintmax_t */ +#else +#if defined(__i386__) +#define PRIxMAX "llx" /* uintmax_t */ +#else +#define PRIxMAX "jx" /* uintmax_t */ +#endif +#endif + +#ifdef __i386__ +#define PRIxPTR "x" /* uintptr_t */ +#else +#define PRIxPTR "lx" /* uintptr_t */ +#endif + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ + +#ifdef __x86_64__ +#define PRIX64 "lX" /* uint64_t */ +#else +#define PRIX64 "llX" /* uint64_t */ +#endif + +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#ifdef __x86_64__ +#define PRIXLEAST64 "lX" /* uint_least64_t */ +#else +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#endif + +#define PRIXFAST8 "X" /* uint_fast8_t */ +#ifdef __x86_64__ +#define PRIXFAST16 "lX" /* uint_fast16_t */ +#define PRIXFAST32 "lX" /* uint_fast32_t */ +#define PRIXFAST64 "lX" /* uint_fast64_t */ +#else +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#endif + +#ifdef __x86_64__ +#define PRIXMAX "lX" /* uintmax_t */ +#else +#if defined(__i386__) +#define PRIXMAX "llX" /* uintmax_t */ +#else +#define PRIXMAX "jX" /* uintmax_t */ +#endif +#endif + +#ifdef __i386__ +#define PRIXPTR "X" /* uintptr_t */ +#else +#define PRIXPTR "lX" /* uintptr_t */ +#endif + +typedef struct { + intmax_t quot; /* quotient */ + intmax_t rem; /* remainder */ +} imaxdiv_t; + +__BEGIN_DECLS + +intmax_t _TLIBC_CDECL_ imaxabs(intmax_t); +imaxdiv_t _TLIBC_CDECL_ imaxdiv(intmax_t, intmax_t); +intmax_t _TLIBC_CDECL_ strtoimax(const char *, char **, int); +uintmax_t _TLIBC_CDECL_ strtoumax(const char *, char **, int); + +__END_DECLS + +#endif /* _INTTYPES_H_ */ diff --git a/common/inc/tlibc/iso646.h b/common/inc/tlibc/iso646.h new file mode 100644 index 0000000000..d711cace6d --- /dev/null +++ b/common/inc/tlibc/iso646.h @@ -0,0 +1,26 @@ +/* $OpenBSD: iso646.h,v 1.3 2001/10/11 00:05:21 espie Exp $ */ +/* $NetBSD: iso646.h,v 1.1 1995/02/17 09:08:10 jtc Exp $ */ + +/* + * Written by J.T. Conklin 02/16/95. + * Public domain. + */ + +#ifndef _ISO646_H_ +#define _ISO646_H_ + +#ifndef __cplusplus +#define and && +#define and_eq &= +#define bitand & +#define bitor | +#define compl ~ +#define not ! +#define not_eq != +#define or || +#define or_eq |= +#define xor ^ +#define xor_eq ^= +#endif + +#endif /* !_ISO646_H_ */ diff --git a/common/inc/tlibc/limits.h b/common/inc/tlibc/limits.h new file mode 100644 index 0000000000..fab59c9b8e --- /dev/null +++ b/common/inc/tlibc/limits.h @@ -0,0 +1,41 @@ +/* $OpenBSD: limits.h,v 1.15 2008/02/10 09:59:54 kettenis Exp $ */ +/* $NetBSD: limits.h,v 1.7 1994/10/26 00:56:00 cgd Exp $ */ + +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)limits.h 5.9 (Berkeley) 4/3/91 + */ + + +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +#include + +#endif /* !_LIMITS_H_ */ diff --git a/common/inc/tlibc/math.h b/common/inc/tlibc/math.h new file mode 100644 index 0000000000..104ac7f156 --- /dev/null +++ b/common/inc/tlibc/math.h @@ -0,0 +1,430 @@ +/* $OpenBSD: math.h,v 1.27 2010/12/14 11:16:15 martynas Exp $ */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * from: @(#)fdlibm.h 5.1 93/09/24 + */ + +#ifndef _MATH_H_ +#define _MATH_H_ + +#include +#include +#include + +#include + +typedef __float_t float_t; +typedef __double_t double_t; + +#define FP_NAN 0x00 +#define FP_INFINITE 0x01 +#define FP_ZERO 0x02 +#define FP_SUBNORMAL 0x03 +#define FP_NORMAL 0x04 + +#define FP_ILOGB0 (-INT_MAX - 1) +#define FP_ILOGBNAN (-INT_MAX - 1) + +#define fpclassify(x) \ + ((sizeof (x) == sizeof (float)) ? \ + __fpclassifyf(x) \ + : (sizeof (x) == sizeof (double)) ? \ + __fpclassify(x) \ + : __fpclassifyl(x)) +#define isfinite(x) \ + ((sizeof (x) == sizeof (float)) ? \ + __isfinitef(x) \ + : (sizeof (x) == sizeof (double)) ? \ + __isfinite(x) \ + : __isfinitel(x)) +#define isnormal(x) \ + ((sizeof (x) == sizeof (float)) ? \ + __isnormalf(x) \ + : (sizeof (x) == sizeof (double)) ? \ + __isnormal(x) \ + : __isnormall(x)) +#define signbit(x) \ + ((sizeof (x) == sizeof (float)) ? \ + __signbitf(x) \ + : (sizeof (x) == sizeof (double)) ? \ + __signbit(x) \ + : __signbitl(x)) +#define isinf(x) \ + ((sizeof (x) == sizeof (float)) ? \ + __isinff(x) \ + : (sizeof (x) == sizeof (double)) ? \ + __isinf(x) \ + : __isinfl(x)) +#define isnan(x) \ + ((sizeof (x) == sizeof (float)) ? \ + __isnanf(x) \ + : (sizeof (x) == sizeof (double)) ? \ + __isnan(x) \ + : __isnanl(x)) + +#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y)) +#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y)) +#define isless(x, y) (!isunordered((x), (y)) && (x) < (y)) +#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y)) +#define islessgreater(x, y) (!isunordered((x), (y)) && ((x) > (y) || (y) > (x))) +#define isunordered(x, y) (isnan(x) || isnan(y)) + +__BEGIN_DECLS + +extern char __infinity[]; +#define HUGE_VAL (*(double *)(void *)__infinity) +#define HUGE_VALF ((float)HUGE_VAL) +#define HUGE_VALL ((long double)HUGE_VAL) +#define INFINITY HUGE_VALF +extern char __nan[]; +#define NAN (*(float *)(void *)__nan) + +/* + * ANSI/POSIX + */ +double _TLIBC_CDECL_ acos(double); +double _TLIBC_CDECL_ asin(double); +double _TLIBC_CDECL_ atan(double); +double _TLIBC_CDECL_ atan2(double, double); +double _TLIBC_CDECL_ cos(double); +double _TLIBC_CDECL_ sin(double); +double _TLIBC_CDECL_ tan(double); + +double _TLIBC_CDECL_ cosh(double); +double _TLIBC_CDECL_ sinh(double); +double _TLIBC_CDECL_ tanh(double); + +double _TLIBC_CDECL_ exp(double); +double _TLIBC_CDECL_ frexp(double, int *); +double _TLIBC_CDECL_ ldexp(double, int); +double _TLIBC_CDECL_ log(double); +double _TLIBC_CDECL_ log10(double); +double _TLIBC_CDECL_ modf(double, double *); + +double _TLIBC_CDECL_ pow(double, double); +double _TLIBC_CDECL_ sqrt(double); + +double _TLIBC_CDECL_ ceil(double); +double _TLIBC_CDECL_ fabs(double); +double _TLIBC_CDECL_ floor(double); +double _TLIBC_CDECL_ fmod(double, double); + +/* + * C99 + */ +double _TLIBC_CDECL_ acosh(double); +double _TLIBC_CDECL_ asinh(double); +double _TLIBC_CDECL_ atanh(double); + +double _TLIBC_CDECL_ exp2(double); +double _TLIBC_CDECL_ expm1(double); +int _TLIBC_CDECL_ ilogb(double); +double _TLIBC_CDECL_ log1p(double); +double _TLIBC_CDECL_ log2(double); +double _TLIBC_CDECL_ logb(double); +double _TLIBC_CDECL_ scalbn(double, int); +double _TLIBC_CDECL_ scalbln(double, long int); + +double _TLIBC_CDECL_ cbrt(double); +double _TLIBC_CDECL_ hypot(double, double); + +double _TLIBC_CDECL_ erf(double); +double _TLIBC_CDECL_ erfc(double); +double _TLIBC_CDECL_ lgamma(double); +double _TLIBC_CDECL_ tgamma(double); + +double _TLIBC_CDECL_ nearbyint(double); +double _TLIBC_CDECL_ rint(double); +long int _TLIBC_CDECL_ lrint(double); +long long int _TLIBC_CDECL_ llrint(double); +double _TLIBC_CDECL_ round(double); +long int _TLIBC_CDECL_ lround(double); +long long int _TLIBC_CDECL_ llround(double); +double _TLIBC_CDECL_ trunc(double); + +double _TLIBC_CDECL_ remainder(double, double); +double _TLIBC_CDECL_ remquo(double, double, int *); + +double _TLIBC_CDECL_ copysign(double, double); +double _TLIBC_CDECL_ nan(const char *); +double _TLIBC_CDECL_ nextafter(double, double); + +double _TLIBC_CDECL_ fdim(double, double); +double _TLIBC_CDECL_ fmax(double, double); +double _TLIBC_CDECL_ fmin(double, double); + +double _TLIBC_CDECL_ fma(double, double, double); + +/* + * Float versions of C99 functions + */ + +float _TLIBC_CDECL_ acosf(float); +float _TLIBC_CDECL_ asinf(float); +float _TLIBC_CDECL_ atanf(float); +float _TLIBC_CDECL_ atan2f(float, float); +float _TLIBC_CDECL_ cosf(float); +float _TLIBC_CDECL_ sinf(float); +float _TLIBC_CDECL_ tanf(float); + +float _TLIBC_CDECL_ acoshf(float); +float _TLIBC_CDECL_ asinhf(float); +float _TLIBC_CDECL_ atanhf(float); +float _TLIBC_CDECL_ coshf(float); +float _TLIBC_CDECL_ sinhf(float); +float _TLIBC_CDECL_ tanhf(float); + +float _TLIBC_CDECL_ expf(float); +float _TLIBC_CDECL_ exp2f(float); +float _TLIBC_CDECL_ expm1f(float); +float _TLIBC_CDECL_ frexpf(float, int *); +int _TLIBC_CDECL_ ilogbf(float); +float _TLIBC_CDECL_ ldexpf(float, int); +float _TLIBC_CDECL_ logf(float); +float _TLIBC_CDECL_ log10f(float); +float _TLIBC_CDECL_ log1pf(float); +float _TLIBC_CDECL_ log2f(float); +float _TLIBC_CDECL_ logbf(float); +float _TLIBC_CDECL_ modff(float, float *); +float _TLIBC_CDECL_ scalbnf(float, int); +float _TLIBC_CDECL_ scalblnf(float, long int); + +float _TLIBC_CDECL_ cbrtf(float); +float _TLIBC_CDECL_ fabsf(float); +float _TLIBC_CDECL_ hypotf(float, float); +float _TLIBC_CDECL_ powf(float, float); +float _TLIBC_CDECL_ sqrtf(float); + +float _TLIBC_CDECL_ erff(float); +float _TLIBC_CDECL_ erfcf(float); +float _TLIBC_CDECL_ lgammaf(float); +float _TLIBC_CDECL_ tgammaf(float); + +float _TLIBC_CDECL_ ceilf(float); +float _TLIBC_CDECL_ floorf(float); +float _TLIBC_CDECL_ nearbyintf(float); + +float _TLIBC_CDECL_ rintf(float); +long int _TLIBC_CDECL_ lrintf(float); +long long int _TLIBC_CDECL_ llrintf(float); +float _TLIBC_CDECL_ roundf(float); +long int _TLIBC_CDECL_ lroundf(float); +long long int _TLIBC_CDECL_ llroundf(float); +float _TLIBC_CDECL_ truncf(float); + +float _TLIBC_CDECL_ fmodf(float, float); +float _TLIBC_CDECL_ remainderf(float, float); +float _TLIBC_CDECL_ remquof(float, float, int *); + +float _TLIBC_CDECL_ copysignf(float, float); +float _TLIBC_CDECL_ nanf(const char *); +float _TLIBC_CDECL_ nextafterf(float, float); + +float _TLIBC_CDECL_ fdimf(float, float); +float _TLIBC_CDECL_ fmaxf(float, float); +float _TLIBC_CDECL_ fminf(float, float); + +float _TLIBC_CDECL_ fmaf(float, float, float); + +/* + * Long double versions of C99 functions + */ + +/* Macros defining long double functions to be their double counterparts + * (long double is synonymous with double in this implementation). + */ + +long double _TLIBC_CDECL_ acosl(long double); +long double _TLIBC_CDECL_ asinl(long double); +long double _TLIBC_CDECL_ atanl(long double); +long double _TLIBC_CDECL_ atan2l(long double, long double); +long double _TLIBC_CDECL_ cosl(long double); +long double _TLIBC_CDECL_ sinl(long double); +long double _TLIBC_CDECL_ tanl(long double); + +long double _TLIBC_CDECL_ acoshl(long double); +long double _TLIBC_CDECL_ asinhl(long double); +long double _TLIBC_CDECL_ atanhl(long double); +long double _TLIBC_CDECL_ coshl(long double); +long double _TLIBC_CDECL_ sinhl(long double); +long double _TLIBC_CDECL_ tanhl(long double); + +long double _TLIBC_CDECL_ expl(long double); +long double _TLIBC_CDECL_ exp2l(long double); +long double _TLIBC_CDECL_ expm1l(long double); +long double _TLIBC_CDECL_ frexpl(long double, int *); +int _TLIBC_CDECL_ ilogbl(long double); +long double _TLIBC_CDECL_ ldexpl(long double, int); +long double _TLIBC_CDECL_ logl(long double); +long double _TLIBC_CDECL_ log10l(long double); +long double _TLIBC_CDECL_ log1pl(long double); +long double _TLIBC_CDECL_ log2l(long double); +long double _TLIBC_CDECL_ logbl(long double); +long double _TLIBC_CDECL_ modfl(long double, long double *); +long double _TLIBC_CDECL_ scalbnl(long double, int); +long double _TLIBC_CDECL_ scalblnl(long double, long int); + +long double _TLIBC_CDECL_ cbrtl(long double); +long double _TLIBC_CDECL_ fabsl(long double); +long double _TLIBC_CDECL_ hypotl(long double, long double); +long double _TLIBC_CDECL_ powl(long double, long double); +long double _TLIBC_CDECL_ sqrtl(long double); + +long double _TLIBC_CDECL_ erfl(long double); +long double _TLIBC_CDECL_ erfcl(long double); +long double _TLIBC_CDECL_ lgammal(long double); +long double _TLIBC_CDECL_ tgammal(long double); + +long double _TLIBC_CDECL_ ceill(long double); +long double _TLIBC_CDECL_ floorl(long double); +long double _TLIBC_CDECL_ nearbyintl(long double); +long double _TLIBC_CDECL_ rintl(long double); +long int _TLIBC_CDECL_ lrintl(long double); +long long int _TLIBC_CDECL_ llrintl(long double); +long double _TLIBC_CDECL_ roundl(long double); +long int _TLIBC_CDECL_ lroundl(long double); +long long int _TLIBC_CDECL_ llroundl(long double); +long double _TLIBC_CDECL_ truncl(long double); + +long double _TLIBC_CDECL_ fmodl(long double, long double); +long double _TLIBC_CDECL_ remainderl(long double, long double); +long double _TLIBC_CDECL_ remquol(long double, long double, int *); + +long double _TLIBC_CDECL_ copysignl(long double, long double); +long double _TLIBC_CDECL_ nanl(const char *); +long double _TLIBC_CDECL_ nextafterl(long double, long double); + +long double _TLIBC_CDECL_ fdiml(long double, long double); +long double _TLIBC_CDECL_ fmaxl(long double, long double); +long double _TLIBC_CDECL_ fminl(long double, long double); +long double _TLIBC_CDECL_ fmal(long double, long double, long double); + +/* nexttoward(): +* The implementation in Intel math library is incompatible with MSVC. +* Because sizeof(long double) is 8bytes with MSVC, +* but the expected long double size is 10bytes. +* And by default, MSVC doesn't provide nexttoward(). +* So we only provide Linux version here. +*/ +double _TLIBC_CDECL_ nexttoward(double, long double); +float _TLIBC_CDECL_ nexttowardf(float, long double); + +long double _TLIBC_CDECL_ nexttowardl(long double, long double); + +/* + * Library implementation + */ +int _TLIBC_CDECL_ __fpclassify(double); +int _TLIBC_CDECL_ __fpclassifyf(float); +int _TLIBC_CDECL_ __isfinite(double); +int _TLIBC_CDECL_ __isfinitef(float); +int _TLIBC_CDECL_ __isinf(double); +int _TLIBC_CDECL_ __isinff(float); +int _TLIBC_CDECL_ __isnan(double); +int _TLIBC_CDECL_ __isnanf(float); +int _TLIBC_CDECL_ __isnormal(double); +int _TLIBC_CDECL_ __isnormalf(float); +int _TLIBC_CDECL_ __signbit(double); +int _TLIBC_CDECL_ __signbitf(float); + +int _TLIBC_CDECL_ __fpclassifyl(long double); +int _TLIBC_CDECL_ __isfinitel(long double); +int _TLIBC_CDECL_ __isinfl(long double); +int _TLIBC_CDECL_ __isnanl(long double); +int _TLIBC_CDECL_ __isnormall(long double); +int _TLIBC_CDECL_ __signbitl(long double); + +/* + * Non-C99 functions. + */ +double _TLIBC_CDECL_ drem(double, double); +double _TLIBC_CDECL_ exp10(double); +double _TLIBC_CDECL_ gamma(double); +double _TLIBC_CDECL_ gamma_r(double, int *); +double _TLIBC_CDECL_ j0(double); +double _TLIBC_CDECL_ j1(double); +double _TLIBC_CDECL_ jn(int, double); +double _TLIBC_CDECL_ lgamma_r(double, int *); +double _TLIBC_CDECL_ pow10(double); +double _TLIBC_CDECL_ scalb(double, double); +/* C99 Macro signbit.*/ +double _TLIBC_CDECL_ significand(double); +void _TLIBC_CDECL_ sincos(double, double *, double *); +double _TLIBC_CDECL_ y0(double); +double _TLIBC_CDECL_ y1(double); +double _TLIBC_CDECL_ yn(int, double); +/* C99 Macro isinf.*/ +/* C99 Macro isnan.*/ +int _TLIBC_CDECL_ finite(double); + +float _TLIBC_CDECL_ dremf(float, float); +float _TLIBC_CDECL_ exp10f(float); +float _TLIBC_CDECL_ gammaf(float); +float _TLIBC_CDECL_ gammaf_r(float, int *); +float _TLIBC_CDECL_ j0f(float); +float _TLIBC_CDECL_ j1f(float); +float _TLIBC_CDECL_ jnf(int, float); +float _TLIBC_CDECL_ lgammaf_r(float, int *); +float _TLIBC_CDECL_ pow10f(float); +float _TLIBC_CDECL_ scalbf(float, float); +int _TLIBC_CDECL_ signbitf(float); +float _TLIBC_CDECL_ significandf(float); +void _TLIBC_CDECL_ sincosf(float, float *, float *); +float _TLIBC_CDECL_ y0f(float); +float _TLIBC_CDECL_ y1f(float); +float _TLIBC_CDECL_ ynf(int, float); +int _TLIBC_CDECL_ finitef(float); +int _TLIBC_CDECL_ isinff(float); +int _TLIBC_CDECL_ isnanf(float); + +long double _TLIBC_CDECL_ dreml(long double, long double); +long double _TLIBC_CDECL_ exp10l(long double); +long double _TLIBC_CDECL_ gammal(long double); +long double _TLIBC_CDECL_ gammal_r(long double, int *); +long double _TLIBC_CDECL_ j0l(long double); +long double _TLIBC_CDECL_ j1l(long double); +long double _TLIBC_CDECL_ jnl(int, long double); +long double _TLIBC_CDECL_ lgammal_r(long double, int *); +long double _TLIBC_CDECL_ pow10l(long double); +long double _TLIBC_CDECL_ scalbl(long double, long double); +int _TLIBC_CDECL_ signbitl(long double); +long double _TLIBC_CDECL_ significandl(long double); +void _TLIBC_CDECL_ sincosl(long double, long double *, long double *); +long double _TLIBC_CDECL_ y1l(long double); +long double _TLIBC_CDECL_ y0l(long double); +long double _TLIBC_CDECL_ ynl(int, long double); +int _TLIBC_CDECL_ finitel(long double); +int _TLIBC_CDECL_ isinfl(long double); +int _TLIBC_CDECL_ isnanl(long double); + +/* + * TODO: From Intel Decimal Floating-Point Math Library + * signbitd32/signbitd64/signbitd128, finited32/finited64/finited128 + * isinfd32/isinfd64/isinfd128, isnand32/isnand64/isnand128 + */ +#if defined(__cplusplus) +/* Clang does not support decimal floating point types. + * + * c.f.: + * http://clang.llvm.org/docs/UsersManual.html#gcc-extensions-not-implemented-yet + */ +#if !defined(__clang__) +typedef float _Decimal32 __attribute__((mode(SD))); +typedef float _Decimal64 __attribute__((mode(DD))); +typedef float _Decimal128 __attribute__((mode(TD))); +#endif +#endif + +__END_DECLS + +#endif /* !_MATH_H_ */ diff --git a/common/inc/tlibc/stdarg.h b/common/inc/tlibc/stdarg.h new file mode 100644 index 0000000000..ed73e246a6 --- /dev/null +++ b/common/inc/tlibc/stdarg.h @@ -0,0 +1,48 @@ +/* $OpenBSD: stdarg.h,v 1.14 2010/12/30 05:01:36 tedu Exp $ */ +/* $NetBSD: stdarg.h,v 1.12 1995/12/25 23:15:31 mycroft Exp $ */ + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdarg.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _STDARG_H_ +#define _STDARG_H_ + +#include +#include + +typedef __va_list va_list; + +#define va_start(ap, last) __builtin_va_start((ap), last) +#define va_end __builtin_va_end +#define va_arg __builtin_va_arg +#define va_copy(dst, src) __builtin_va_copy((dst),(src)) + +#endif /* !_STDARG_H_ */ diff --git a/common/inc/tlibc/stdbool.h b/common/inc/tlibc/stdbool.h new file mode 100644 index 0000000000..bd1837ec46 --- /dev/null +++ b/common/inc/tlibc/stdbool.h @@ -0,0 +1,44 @@ +/* $OpenBSD: stdbool.h,v 1.5 2010/07/24 22:17:03 guenther Exp $ */ + +/* + * Written by Marc Espie, September 25, 1999 + * Public domain. + */ + +#ifndef _STDBOOL_H_ +#define _STDBOOL_H_ + +#ifndef __cplusplus + +#ifndef __GNUC__ +/* Support for _C99: type _Bool is already built-in. */ +/* `_Bool' type must promote to `int' or `unsigned int'. */ +typedef enum { + false = 0, + true = 1 +} _Bool; + +/* And those constants must also be available as macros. */ +# define false false +# define true true +#else /* __GNUC__ */ +# define false 0 +# define true 1 +#endif + +/* User visible type `bool' is provided as a macro which may be redefined */ +#define bool _Bool + +#else /* __cplusplus */ + +# define _Bool bool +# define bool bool +# define false false +# define true true + +#endif + +/* Inform that everything is fine */ +#define __bool_true_false_are_defined 1 + +#endif /* _STDBOOL_H_ */ diff --git a/common/inc/tlibc/stddef.h b/common/inc/tlibc/stddef.h new file mode 100644 index 0000000000..84509c5025 --- /dev/null +++ b/common/inc/tlibc/stddef.h @@ -0,0 +1,70 @@ +/* $OpenBSD: stddef.h,v 1.10 2009/09/22 21:40:02 jsg Exp $ */ +/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stddef.h 5.5 (Berkeley) 4/3/91 + */ + +#ifndef _STDDEF_H_ +#define _STDDEF_H_ + +#include +#include + +#ifndef _PTRDIFF_T_DEFINED_ +#define _PTRDIFF_T_DEFINED_ +typedef __ptrdiff_t ptrdiff_t; +#endif + +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef __size_t size_t; +#endif + +#if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus) +#define _WCHAR_T_DEFINED_ +#ifndef __WCHAR_TYPE__ +#define __WCHAR_TYPE__ int +#endif +typedef __WCHAR_TYPE__ wchar_t; +#endif + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#define offsetof(type, member) ((size_t)(&((type *)0)->member)) + +#endif /* _STDDEF_H_ */ + diff --git a/common/inc/tlibc/stdint.h b/common/inc/tlibc/stdint.h new file mode 100644 index 0000000000..d283ae9214 --- /dev/null +++ b/common/inc/tlibc/stdint.h @@ -0,0 +1,24 @@ +/* $OpenBSD: stdint.h,v 1.4 2006/12/10 22:17:55 deraadt Exp $ */ + +/* + * Copyright (c) 1997, 2005 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _STDINT_H_ +#define _STDINT_H_ + +#include + +#endif /* _STDINT_H_ */ diff --git a/common/inc/tlibc/stdio.h b/common/inc/tlibc/stdio.h new file mode 100644 index 0000000000..0175a3ace3 --- /dev/null +++ b/common/inc/tlibc/stdio.h @@ -0,0 +1,95 @@ +/* $OpenBSD: stdio.h,v 1.38 2009/11/09 00:18:27 kurt Exp $ */ +/* $NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdio.h 5.17 (Berkeley) 6/3/91 + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#include +#include + +#include + +#ifndef _SIZE_T_DEFINED_ +typedef __size_t size_t; +#define _SIZE_T_DEFINED_ +#endif + +#ifndef NULL +# ifdef __cplusplus +# define NULL 0 +# else +# define NULL ((void *)0) +# endif +#endif + +# define BUFSIZ 8192 + +#define EOF (-1) + +__BEGIN_DECLS + +int _TLIBC_CDECL_ snprintf(char *, size_t, const char *, ...) _GCC_PRINTF_FORMAT_(3, 4); +int _TLIBC_CDECL_ vsnprintf(char *, size_t, const char *, __va_list) _GCC_PRINTF_FORMAT_(3, 0); + +/* + * Deprecated definitions. + */ +#if 0 /* No FILE */ +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, fprintf, FILE *, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, putc, int, FILE *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, fputc, int, FILE *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, fputs, const char *, FILE *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, fscanf, FILE *, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(size_t _TLIBC_CDECL_, fwrite, const void *, size_t, size_t, FILE *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, printf, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, putchar, int); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, puts, const char *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, scanf, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, sprintf, char *, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, sscanf, const char *, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, vfprintf, FILE *, const char *, __va_list); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, vfscanf, FILE *, const char *, __va_list); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, vprintf, const char *, __va_list); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, vscanf, const char *, __va_list); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, vsprintf, char *, const char *, __va_list); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, vsscanf, const char *, const char *, __va_list); +#endif + +__END_DECLS + + +#endif /* !_STDIO_H_ */ diff --git a/common/inc/tlibc/stdlib.h b/common/inc/tlibc/stdlib.h new file mode 100644 index 0000000000..8a851db09b --- /dev/null +++ b/common/inc/tlibc/stdlib.h @@ -0,0 +1,159 @@ +/* $OpenBSD: stdlib.h,v 1.47 2010/05/18 22:24:55 tedu Exp $ */ +/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ + +/*- +* Copyright (c) 1990 The Regents of the University of California. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. Neither the name of the University nor the names of its contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* +* @(#)stdlib.h 5.13 (Berkeley) 6/4/91 +*/ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#include +#include + +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef __size_t size_t; +#endif + +#ifdef _TLIBC_WIN_ +#if !defined(_WCHAR_T_DEFINED) && !defined (_NATIVE_WCHAR_T_DEFINED) +#define _WCHAR_T_DEFINED +typedef unsigned short wchar_t; +#endif +#else +#if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus) +#define _WCHAR_T_DEFINED_ +#ifndef __WCHAR_TYPE__ +#define __WCHAR_TYPE__ int +#endif +typedef __WCHAR_TYPE__ wchar_t; +#endif +#endif + +#ifndef _DIV_T_DEFINED +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +typedef struct { + long long quot; /* quotient */ + long long rem; /* remainder */ +} lldiv_t; +#define _DIV_T_DEFINED +#endif + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX 0x7fffffff +#define MB_CUR_MAX 1 + +__BEGIN_DECLS + +_TLIBC_NORETURN_ void _TLIBC_CDECL_ abort(void); +int _TLIBC_CDECL_ abs(int); +double _TLIBC_CDECL_ atof(const char *); +int _TLIBC_CDECL_ atoi(const char *); +long _TLIBC_CDECL_ atol(const char *); +void * _TLIBC_CDECL_ bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); +void * _TLIBC_CDECL_ calloc(size_t, size_t); +div_t _TLIBC_CDECL_ div(int, int); +void _TLIBC_CDECL_ free(void *); +long _TLIBC_CDECL_ labs(long); +ldiv_t _TLIBC_CDECL_ ldiv(long, long); +void * _TLIBC_CDECL_ malloc(size_t); +void * _TLIBC_CDECL_ memalign(size_t, size_t); +void _TLIBC_CDECL_ qsort(void *, size_t, size_t, int (*)(const void *, const void *)); +void * _TLIBC_CDECL_ realloc(void *, size_t); +double _TLIBC_CDECL_ strtod(const char *, char **); +long _TLIBC_CDECL_ strtol(const char *, char **, int); +float _TLIBC_CDECL_ strtof(const char *, char **); + +long long + _TLIBC_CDECL_ atoll(const char *); +long long + _TLIBC_CDECL_ llabs(long long); +lldiv_t + _TLIBC_CDECL_ lldiv(long long, long long); +long long + _TLIBC_CDECL_ strtoll(const char *, char **, int); +unsigned long + _TLIBC_CDECL_ strtoul(const char *, char **, int); +long double + _TLIBC_CDECL_ strtold(const char *, char **); +unsigned long long + _TLIBC_CDECL_ strtoull(const char *, char **, int); + +int _TLIBC_CDECL_ mblen(const char *, size_t); +size_t _TLIBC_CDECL_ mbstowcs(wchar_t *, const char *, size_t); +int _TLIBC_CDECL_ wctomb(char *, wchar_t); +int _TLIBC_CDECL_ mbtowc(wchar_t *, const char *, size_t); +size_t _TLIBC_CDECL_ wcstombs(char *, const wchar_t *, size_t); + + +/* + * Deprecated C99. + */ +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, atexit, void (_TLIBC_CDECL_ *)(void)); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, rand, void); +_TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, srand, unsigned); +_TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, exit, int); +_TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, _Exit, int); +_TLIBC_DEPRECATED_FUNCTION_(char * _TLIBC_CDECL_, getenv, const char *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, system, const char *); + +/* + * Non-C99 Functions. + */ +void * _TLIBC_CDECL_ alloca(size_t); + +/* + * Deprecated Non-C99. + */ +//_TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, _exit, int); + +__END_DECLS + +#endif /* !_STDLIB_H_ */ diff --git a/common/inc/tlibc/string.h b/common/inc/tlibc/string.h new file mode 100644 index 0000000000..c8e458f477 --- /dev/null +++ b/common/inc/tlibc/string.h @@ -0,0 +1,125 @@ +/* $OpenBSD: string.h,v 1.20 2010/09/24 13:33:00 matthew Exp $ */ +/* $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)string.h 5.10 (Berkeley) 3/9/91 + */ + +#ifndef _STRING_H_ +#define _STRING_H_ + +#include +#include + +#ifndef _SIZE_T_DEFINED_ +typedef __size_t size_t; +#define _SIZE_T_DEFINED_ +#endif + +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +__BEGIN_DECLS + +void * _TLIBC_CDECL_ memchr(const void *, int, size_t); +int _TLIBC_CDECL_ memcmp(const void *, const void *, size_t); +void * _TLIBC_CDECL_ memcpy(void *, const void *, size_t); +void * _TLIBC_CDECL_ memmove(void *, const void *, size_t); +void * _TLIBC_CDECL_ memset(void *, int, size_t); +char * _TLIBC_CDECL_ strchr(const char *, int); +int _TLIBC_CDECL_ strcmp(const char *, const char *); +int _TLIBC_CDECL_ strcoll(const char *, const char *); +size_t _TLIBC_CDECL_ strcspn(const char *, const char *); +char * _TLIBC_CDECL_ strerror(int); +size_t _TLIBC_CDECL_ strlen(const char *); +char * _TLIBC_CDECL_ strncat(char *, const char *, size_t); +int _TLIBC_CDECL_ strncmp(const char *, const char *, size_t); +char * _TLIBC_CDECL_ strncpy(char *, const char *, size_t); +char * _TLIBC_CDECL_ strpbrk(const char *, const char *); +char * _TLIBC_CDECL_ strrchr(const char *, int); +size_t _TLIBC_CDECL_ strspn(const char *, const char *); +char * _TLIBC_CDECL_ strstr(const char *, const char *); +char * _TLIBC_CDECL_ strtok(char *, const char *); +size_t _TLIBC_CDECL_ strxfrm(char *, const char *, size_t); +size_t _TLIBC_CDECL_ strlcpy(char *, const char *, size_t); +errno_t _TLIBC_CDECL_ memset_s(void *s, size_t smax, int c, size_t n); + +/* + * Deprecated C99. + */ +_TLIBC_DEPRECATED_FUNCTION_(char * _TLIBC_CDECL_, strcat, char *, const char *); +_TLIBC_DEPRECATED_FUNCTION_(char * _TLIBC_CDECL_, strcpy, char *, const char *); + +/* + * Common used non-C99 functions. + */ +char * _TLIBC_CDECL_ strndup(const char *, size_t); +size_t _TLIBC_CDECL_ strnlen(const char *, size_t); +int _TLIBC_CDECL_ consttime_memequal(const void *b1, const void *b2, size_t len); + +/* + * Non-C99 + */ +int _TLIBC_CDECL_ bcmp(const void *, const void *, size_t); +void _TLIBC_CDECL_ bcopy(const void *, void *, size_t); +void _TLIBC_CDECL_ bzero(void *, size_t); +char * _TLIBC_CDECL_ index(const char *, int); +void * _TLIBC_CDECL_ mempcpy(void *, const void *, size_t); +char * _TLIBC_CDECL_ rindex(const char *, int); +char * _TLIBC_CDECL_ stpncpy(char *dest, const char *src, size_t n); +int _TLIBC_CDECL_ strcasecmp(const char *, const char *); +int _TLIBC_CDECL_ strncasecmp(const char *, const char *, size_t); + +int _TLIBC_CDECL_ ffs(int); +int _TLIBC_CDECL_ ffsl(long int); +int _TLIBC_CDECL_ ffsll(long long int); + +char * _TLIBC_CDECL_ strtok_r(char *, const char *, char **); +int _TLIBC_CDECL_ strerror_r(int, char *, size_t); + +/* + * Deprecated Non-C99. + */ +_TLIBC_DEPRECATED_FUNCTION_(char * _TLIBC_CDECL_, strdup, const char *); +_TLIBC_DEPRECATED_FUNCTION_(char * _TLIBC_CDECL_, stpcpy, char *dest, const char *src); + +__END_DECLS + +#endif /* _STRING_H_ */ diff --git a/common/inc/tlibc/sys/_types.h b/common/inc/tlibc/sys/_types.h new file mode 100644 index 0000000000..b1b315c7ed --- /dev/null +++ b/common/inc/tlibc/sys/_types.h @@ -0,0 +1,133 @@ +/* $OpenBSD: _types.h,v 1.2 2008/03/16 19:42:57 otto Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.3 (Berkeley) 1/5/94 + */ + +#ifndef _SYS__TYPES_H_ +#define _SYS__TYPES_H_ + +#include +/* 7.18.1.1 Exact-width integer types */ +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short __int16_t; +typedef unsigned short __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +typedef long long __int64_t; +typedef unsigned long long __uint64_t; + +/* 7.18.1.2 Minimum-width integer types */ +typedef __int8_t __int_least8_t; +typedef __uint8_t __uint_least8_t; +typedef __int16_t __int_least16_t; +typedef __uint16_t __uint_least16_t; +typedef __int32_t __int_least32_t; +typedef __uint32_t __uint_least32_t; +typedef __int64_t __int_least64_t; +typedef __uint64_t __uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef __int8_t __int_fast8_t; +typedef __uint8_t __uint_fast8_t; +#ifdef __x86_64__ +/* Linux x86_64, from stdint.h */ +typedef long int __int_fast16_t; +typedef unsigned long int __uint_fast16_t; +typedef long int __int_fast32_t; +typedef unsigned long int __uint_fast32_t; +typedef long int __int_fast64_t; +typedef unsigned long int __uint_fast64_t; +#else +/* Android x86, and Linux x86 */ +typedef __int32_t __int_fast16_t; +typedef __uint32_t __uint_fast16_t; +typedef __int32_t __int_fast32_t; +typedef __uint32_t __uint_fast32_t; +typedef __int64_t __int_fast64_t; +typedef __uint64_t __uint_fast64_t; +#endif + +typedef long __off_t; + +/* 7.18.1.4 Integer types capable of holding object pointers */ +#ifdef __i386__ +typedef __int32_t __intptr_t; +typedef __uint32_t __uintptr_t; +typedef __int32_t __ptrdiff_t; +/* Standard system types */ +typedef __uint32_t __size_t; +typedef __int32_t __ssize_t; +typedef long double __double_t; +typedef long double __float_t; +#else +typedef __int64_t __intptr_t; +typedef __uint64_t __uintptr_t; +typedef __int64_t __ptrdiff_t; + +/* Standard system types */ +typedef unsigned long __size_t; +typedef long __ssize_t; +typedef double __double_t; +typedef float __float_t; + +#endif /* !__i386__ */ + +typedef long __clock_t; + +typedef long __time_t; +typedef __builtin_va_list __va_list; +typedef int __wint_t; +/* wctype_t and wctrans_t are defined in wchar.h */ +typedef unsigned long int __wctype_t; +typedef int * __wctrans_t; + +/* + * mbstate_t is an opaque object to keep conversion state, during multibyte + * stream conversions. The content must not be referenced by user programs. + */ +/* For Linux, __mbstate_t is defined in wchar.h */ +typedef struct { + int __c; + union { + __wint_t __wc; + char __wcb[4]; + } __v; +} __mbstate_t; + +/* 7.18.1.5 Greatest-width integer types */ +typedef __int64_t __intmax_t; +typedef __uint64_t __uintmax_t; + +#endif /* !_SYS__TYPES_H_ */ + + + diff --git a/common/inc/tlibc/sys/cdefs.h b/common/inc/tlibc/sys/cdefs.h new file mode 100644 index 0000000000..398a12bbc7 --- /dev/null +++ b/common/inc/tlibc/sys/cdefs.h @@ -0,0 +1,132 @@ +/* $OpenBSD: cdefs.h,v 1.34 2012/08/14 20:11:37 matthew Exp $ */ +/* $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cdefs.h 8.7 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_CDEFS_H_ +#define _SYS_CDEFS_H_ + +/* Declaration field in C/C++ headers */ +#if defined(__cplusplus) +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS +# define __END_DECLS +#endif + +#if defined(__STDC__) || defined(__cplusplus) +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif +/* + * Macro to test if we're using a specific version of gcc or later. + */ +#if defined __GNUC__ && defined __GNUC_MINOR_ +# define __GNUC_PREREQ__(ma, mi) \ + ((__GNUC__ > (ma)) || (__GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))) +#else +# define __GNUC_PREREQ__(ma, mi) 0 +#endif + +/* Calling Convention: cdecl */ +#define _TLIBC_CDECL_ + +/* Thread Directive */ +#define _TLIBC_THREAD_ /* __thread */ + +/* Deprecated Warnings */ +#define _TLIBC_DEPRECATED_MSG(x) __STRING(x)" is deprecated in tlibc." +#define _TLIBC_DEPRECATED_(x) __attribute__((deprecated(_TLIBC_DEPRECATED_MSG(x)))) + +#ifndef _TLIBC_WARN_DEPRECATED_FUNCTIONS_ +# define _TLIBC_DEPRECATED_FUNCTION_(__ret, __func, ...) +#else +# define _TLIBC_DEPRECATED_FUNCTION_(__ret, __func, ...) \ + _TLIBC_DEPRECATED_(__func) \ + __ret __func(__VA_ARGS__) +#endif + +/* Static analysis for printf format strings. + * _MSC_PRINTF_FORMAT_: MSVC SAL annotation for specifying format strings. + * _GCC_PRINTF_FORMAT_(x, y): GCC declaring attribute for checking format strings. + * x - index of the format string. In C++ non-static method, index 1 is reseved for 'this'. + * y - index of first variadic agrument in '...'. + */ +#define _GCC_PRINTF_FORMAT_(x, y) __attribute__((__format__ (printf, x, y))) + +/* Attribute - noreturn */ +#define _TLIBC_NORETURN_ __attribute__ ((__noreturn__)) + +/* + * GNU C version 2.96 adds explicit branch prediction so that + * the CPU back-end can hint the processor and also so that + * code blocks can be reordered such that the predicted path + * sees a more linear flow, thus improving cache behavior, etc. + * + * The following two macros provide us with a way to utilize this + * compiler feature. Use __predict_true() if you expect the expression + * to evaluate to true, and __predict_false() if you expect the + * expression to evaluate to false. + * + * A few notes about usage: + * + * * Generally, __predict_false() error condition checks (unless + * you have some _strong_ reason to do otherwise, in which case + * document it), and/or __predict_true() `no-error' condition + * checks, assuming you want to optimize for the no-error case. + * + * * Other than that, if you don't know the likelihood of a test + * succeeding from empirical or other `hard' evidence, don't + * make predictions. + * + * * These are meant to be used in places that are run `a lot'. + * It is wasteful to make predictions in code that is run + * seldomly (e.g. at subsystem initialization time) as the + * basic block reordering that this affects can often generate + * larger code. + */ +#if defined(__GNUC__) && __GNUC_PREREQ__(2, 96) +#define __predict_true(exp) __builtin_expect(((exp) != 0), 1) +#define __predict_false(exp) __builtin_expect(((exp) != 0), 0) +#else +#define __predict_true(exp) ((exp) != 0) +#define __predict_false(exp) ((exp) != 0) +#endif + +#endif /* !_SYS_CDEFS_H_ */ diff --git a/common/inc/tlibc/sys/endian.h b/common/inc/tlibc/sys/endian.h new file mode 100644 index 0000000000..29edd81c5c --- /dev/null +++ b/common/inc/tlibc/sys/endian.h @@ -0,0 +1,54 @@ +/* $OpenBSD: endian.h,v 1.18 2006/03/27 07:09:24 otto Exp $ */ + +/*- + * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Generic definitions for little- and big-endian systems. Other endianesses + * has to be dealt with in the specific machine/endian.h file for that port. + * + * This file is meant to be included from a little- or big-endian port's + * machine/endian.h after setting _BYTE_ORDER to either 1234 for little endian + * or 4321 for big.. + */ + +#ifndef _SYS_ENDIAN_H_ +#define _SYS_ENDIAN_H_ + +#define _LITTLE_ENDIAN 1234 +#define _BIG_ENDIAN 4321 +#define _PDP_ENDIAN 3412 +#define _BYTE_ORDER _LITTLE_ENDIAN + +#define LITTLE_ENDIAN _LITTLE_ENDIAN +#define BIG_ENDIAN _BIG_ENDIAN +#define PDP_ENDIAN _PDP_ENDIAN +#define BYTE_ORDER _BYTE_ORDER + +#define __BYTE_ORDER _BYTE_ORDER +#define __BIG_ENDIAN _BIG_ENDIAN +#define __LITTLE_ENDIAN _LITTLE_ENDIAN + +#endif /* _SYS_ENDIAN_H_ */ + diff --git a/common/inc/tlibc/sys/ieee.h b/common/inc/tlibc/sys/ieee.h new file mode 100644 index 0000000000..8370cd8295 --- /dev/null +++ b/common/inc/tlibc/sys/ieee.h @@ -0,0 +1,145 @@ +/* $OpenBSD: ieee.h,v 1.2 2008/09/07 20:36:06 martynas Exp $ */ +/* $NetBSD: ieee.h,v 1.1 1996/09/30 16:34:25 ws Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ieee.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * ieee.h defines the machine-dependent layout of the machine's IEEE + * floating point. It does *not* define (yet?) any of the rounding + * mode bits, exceptions, and so forth. + */ + +/* + * Define the number of bits in each fraction and exponent. + * + * k k+1 + * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented + * + * (-exp_bias+1) + * as fractions that look like 0.fffff x 2 . This means that + * + * -126 + * the number 0.10000 x 2 , for instance, is the same as the normalized + * + * -127 -128 + * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero + * + * -129 + * in the fraction; to represent 2 , we need two, and so on. This + * + * (-exp_bias-fracbits+1) + * implies that the smallest denormalized number is 2 + * + * for whichever format we are talking about: for single precision, for + * + * -126 -149 + * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and + * + * -149 == -127 - 23 + 1. + */ + +#include + +#define SNG_EXPBITS 8 +#define SNG_FRACBITS 23 + +#define DBL_EXPBITS 11 +#define DBL_FRACHBITS 20 +#define DBL_FRACLBITS 32 +#define DBL_FRACBITS 52 + +#define EXT_EXPBITS 15 +#define EXT_FRACHBITS 32 +#define EXT_FRACLBITS 32 +#define EXT_FRACBITS 64 + +#define EXT_TO_ARRAY32(p, a) do { \ + (a)[0] = (uint32_t)(p)->ext_fracl; \ + (a)[1] = (uint32_t)(p)->ext_frach; \ +} while(0) + +struct ieee_single { + u_int sng_frac:23; + u_int sng_exp:8; + u_int sng_sign:1; +}; + +struct ieee_double { + u_int dbl_fracl; + u_int dbl_frach:20; + u_int dbl_exp:11; + u_int dbl_sign:1; +}; + +struct ieee_ext { + u_int ext_fracl; + u_int ext_frach; + u_int ext_exp:15; + u_int ext_sign:1; + u_int ext_padl:16; + u_int ext_padh; +}; + +/* + * Floats whose exponent is in [1..INFNAN) (of whatever type) are + * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. + * Floats whose exponent is zero are either zero (iff all fraction + * bits are zero) or subnormal values. + * + * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its + * high fraction; if the bit is set, it is a `quiet NaN'. + */ +#define SNG_EXP_INFNAN 255 +#define DBL_EXP_INFNAN 2047 +#define EXT_EXP_INFNAN 32767 + +#if 0 +#define SNG_QUIETNAN (1 << 22) +#define DBL_QUIETNAN (1 << 19) +#define EXT_QUIETNAN (1 << 15) +#endif + +/* + * Exponent biases. + */ +#define SNG_EXP_BIAS 127 +#define DBL_EXP_BIAS 1023 +#define EXT_EXP_BIAS 16383 diff --git a/common/inc/tlibc/sys/limits.h b/common/inc/tlibc/sys/limits.h new file mode 100644 index 0000000000..3d1f9673ad --- /dev/null +++ b/common/inc/tlibc/sys/limits.h @@ -0,0 +1,77 @@ +/* $OpenBSD: limits.h,v 1.8 2009/11/27 19:54:35 guenther Exp $ */ +/* + * Copyright (c) 2002 Marc Espie. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD + * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SYS_LIMITS_H_ +#define _SYS_LIMITS_H_ + +#include + +/* Common definitions for limits.h. */ + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define SCHAR_MAX 0x7f /* max value for a signed char */ +#define SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#ifdef __CHAR_UNSIGNED__ +# define CHAR_MIN 0 /* min value for a char */ +# define CHAR_MAX 0xff /* max value for a char */ +#else +# define CHAR_MAX 0x7f +# define CHAR_MIN (-0x7f-1) +#endif + +#define MB_LEN_MAX 1 /* Allow UTF-8 (RFC 3629) */ + +#define USHRT_MAX 0xffff /* max value for an unsigned short */ +#define SHRT_MAX 0x7fff /* max value for a short */ +#define SHRT_MIN (-0x7fff-1) /* min value for a short */ + +#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ +#define INT_MAX 0x7fffffff /* max value for an int */ +#define INT_MIN (-0x7fffffff-1) /* min value for an int */ + +#ifdef __x86_64__ +# define ULONG_MAX 0xffffffffffffffffUL /* max value for unsigned long */ +# define LONG_MAX 0x7fffffffffffffffL /* max value for a signed long */ +# define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a signed long */ +#else +# define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ +# define LONG_MAX 0x7fffffffL /* max value for a long */ +# define LONG_MIN (-0x7fffffffL-1) /* min value for a long */ +#endif + +#define ULLONG_MAX 0xffffffffffffffffULL /* max value for unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max value for a signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min value for a signed long long */ + +#ifdef __x86_64__ +# define LONG_BIT 64 +#else +# define LONG_BIT 32 +#endif + +#endif /* !_SYS_LIMITS_H_ */ diff --git a/common/inc/tlibc/sys/stdint.h b/common/inc/tlibc/sys/stdint.h new file mode 100644 index 0000000000..b76cc52ed8 --- /dev/null +++ b/common/inc/tlibc/sys/stdint.h @@ -0,0 +1,253 @@ +/* $OpenBSD: stdint.h,v 1.4 2006/12/10 22:17:55 deraadt Exp $ */ + +/* + * Copyright (c) 1997, 2005 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_STDINT_H_ +#define _SYS_STDINT_H_ + +#include +#include + +/* 7.18.1.1 Exact-width integer types (also in sys/types.h) */ +#ifndef _INT8_T_DEFINED_ +#define _INT8_T_DEFINED_ +typedef __int8_t int8_t; +#endif + +#ifndef _UINT8_T_DEFINED_ +#define _UINT8_T_DEFINED_ +typedef __uint8_t uint8_t; +#endif + +#ifndef _INT16_T_DEFINED_ +#define _INT16_T_DEFINED_ +typedef __int16_t int16_t; +#endif + +#ifndef _UINT16_T_DEFINED_ +#define _UINT16_T_DEFINED_ +typedef __uint16_t uint16_t; +#endif + +#ifndef _INT32_T_DEFINED_ +#define _INT32_T_DEFINED_ +typedef __int32_t int32_t; +#endif + +#ifndef _UINT32_T_DEFINED_ +#define _UINT32_T_DEFINED_ +typedef __uint32_t uint32_t; +#endif + +#ifndef _INT64_T_DEFINED_ +#define _INT64_T_DEFINED_ +typedef __int64_t int64_t; +#endif + +#ifndef _UINT64_T_DEFINED_ +#define _UINT64_T_DEFINED_ +typedef __uint64_t uint64_t; +#endif + +/* 7.18.1.2 Minimum-width integer types */ +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef __int_fast8_t int_fast8_t; +typedef __uint_fast8_t uint_fast8_t; +typedef __int_fast16_t int_fast16_t; +typedef __uint_fast16_t uint_fast16_t; +typedef __int_fast32_t int_fast32_t; +typedef __uint_fast32_t uint_fast32_t; +typedef __int_fast64_t int_fast64_t; +typedef __uint_fast64_t uint_fast64_t; + +/* 7.18.1.4 Integer types capable of holding object pointers */ +#ifndef _INTPTR_T_DEFINED_ +#define _INTPTR_T_DEFINED_ +typedef __intptr_t intptr_t; +#endif + +#ifndef _UINTPTR_T_DEFINED_ +#define _UINTPTR_T_DEFINED_ +typedef __uintptr_t uintptr_t; +#endif + +/* 7.18.1.5 Greatest-width integer types */ +typedef __intmax_t intmax_t; +typedef __uintmax_t uintmax_t; + +//#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) +/* + * 7.18.2 Limits of specified-width integer types. + * + * The following object-like macros specify the minimum and maximum limits + * of integer types corresponding to the typedef names defined above. + */ + +/* 7.18.2.1 Limits of exact-width integer types */ +#define INT8_MIN (-0x7f - 1) +#define INT16_MIN (-0x7fff - 1) +#define INT32_MIN (-0x7fffffff - 1) +#define INT64_MIN (-0x7fffffffffffffffLL - 1) + +#define INT8_MAX 0x7f +#define INT16_MAX 0x7fff +#define INT32_MAX 0x7fffffff +#define INT64_MAX 0x7fffffffffffffffLL + +#define UINT8_MAX 0xff +#define UINT16_MAX 0xffff +#define UINT32_MAX 0xffffffffU +#define UINT64_MAX 0xffffffffffffffffULL + +/* 7.18.2.2 Limits of minimum-width integer types */ +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#ifdef __x86_64__ +#define INT_FAST16_MAX INT64_MAX +#define INT_FAST32_MAX INT64_MAX +#else +#define INT_FAST16_MAX INT32_MAX +#define INT_FAST32_MAX INT32_MAX +#endif +#define INT_FAST64_MAX INT64_MAX + +#define UINT_FAST8_MAX UINT8_MAX +#ifdef __x86_64__ +#define UINT_FAST16_MAX UINT64_MAX +#define UINT_FAST32_MAX UINT64_MAX +#else +#define UINT_FAST16_MAX UINT32_MAX +#define UINT_FAST32_MAX UINT32_MAX +#endif +#define UINT_FAST64_MAX UINT64_MAX + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ +#ifdef __x86_64__ +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX +#else +#define INTPTR_MIN INT32_MIN +#define INTPTR_MAX INT32_MAX +#define UINTPTR_MAX UINT32_MAX +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +/* + * 7.18.3 Limits of other integer types. + * + * The following object-like macros specify the minimum and maximum limits + * of integer types corresponding to types specified in other standard + * header files. + */ + +/* Limits of ptrdiff_t */ +#define PTRDIFF_MIN INTPTR_MIN +#define PTRDIFF_MAX INTPTR_MAX + +/* Limits of size_t (also in limits.h) */ +#ifndef SIZE_MAX +#define SIZE_MAX UINTPTR_MAX +#endif + +/* Limits of wchar_t */ +#ifdef _TLIBC_WIN_ +# define WCHAR_MIN 0x0000 +# define WCHAR_MAX 0xffff +#else +# ifdef __WCHAR_MAX__ +# define WCHAR_MAX __WCHAR_MAX__ +# else +# define WCHAR_MAX (2147483647) +# endif +# ifdef __WCHAR_MIN__ +# define WCHAR_MIN __WCHAR_MIN__ +# elif L'\0' - 1 > 0 +# define WCHAR_MIN L'\0' +# else +# define WCHAR_MIN (-WCHAR_MAX - 1) +# endif +#endif + +/* Limits of wint_t */ +# define WINT_MIN (0u) +# define WINT_MAX (4294967295u) + +//#endif /* __cplusplus || __STDC_LIMIT_MACROS */ + +//#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) +/* + * 7.18.4 Macros for integer constants. + * + * The following function-like macros expand to integer constants + * suitable for initializing objects that have integer types corresponding + * to types defined in . The argument in any instance of + * these macros shall be a decimal, octal, or hexadecimal constant with + * a value that does not exceed the limits for the corresponding type. + */ + +/* 7.18.4.1 Macros for minimum-width integer constants. */ +#define INT8_C(_c) (_c) +#define INT16_C(_c) (_c) +#define INT32_C(_c) (_c) +#define INT64_C(_c) __CONCAT(_c, LL) + +#define UINT8_C(_c) (_c) +#define UINT16_C(_c) (_c) +#define UINT32_C(_c) __CONCAT(_c, U) +#define UINT64_C(_c) __CONCAT(_c, ULL) + +/* 7.18.4.2 Macros for greatest-width integer constants. */ +#define INTMAX_C(_c) __CONCAT(_c, LL) +#define UINTMAX_C(_c) __CONCAT(_c, ULL) + +//#endif /* __cplusplus || __STDC_CONSTANT_MACROS */ + +#endif /* _SYS_STDINT_H_ */ diff --git a/common/inc/tlibc/sys/types.h b/common/inc/tlibc/sys/types.h new file mode 100644 index 0000000000..474f3e93d9 --- /dev/null +++ b/common/inc/tlibc/sys/types.h @@ -0,0 +1,128 @@ +/* $OpenBSD: types.h,v 1.31 2008/03/16 19:42:57 otto Exp $ */ +/* $NetBSD: types.h,v 1.29 1996/11/15 22:48:25 jtc Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_TYPES_H_ +#define _SYS_TYPES_H_ + +#include +#include + +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +typedef unsigned char unchar; /* Sys V compatibility */ +typedef unsigned short ushort; /* Sys V compatibility */ +typedef unsigned int uint; /* Sys V compatibility */ +typedef unsigned long ulong; /* Sys V compatibility */ + +#ifndef _INT8_T_DEFINED_ +#define _INT8_T_DEFINED_ +typedef __int8_t int8_t; +#endif + +#ifndef _UINT8_T_DEFINED_ +#define _UINT8_T_DEFINED_ +typedef __uint8_t uint8_t; +#endif + +#ifndef _INT16_T_DEFINED_ +#define _INT16_T_DEFINED_ +typedef __int16_t int16_t; +#endif + +#ifndef _UINT16_T_DEFINED_ +#define _UINT16_T_DEFINED_ +typedef __uint16_t uint16_t; +#endif + +#ifndef _INT32_T_DEFINED_ +#define _INT32_T_DEFINED_ +typedef __int32_t int32_t; +#endif + +#ifndef _UINT32_T_DEFINED_ +#define _UINT32_T_DEFINED_ +typedef __uint32_t uint32_t; +#endif + +#ifndef _INT64_T_DEFINED_ +#define _INT64_T_DEFINED_ +typedef __int64_t int64_t; +#endif + +#ifndef _UINT64_T_DEFINED_ +#define _UINT64_T_DEFINED_ +typedef __uint64_t uint64_t; +#endif + +#ifndef _INTPTR_T_DEFINED_ +#define _INTPTR_T_DEFINED_ +typedef __intptr_t intptr_t; +#endif + +#ifndef _UINTPTR_T_DEFINED_ +#define _UINTPTR_T_DEFINED_ +typedef __uintptr_t uintptr_t; +#endif + +/* BSD-style unsigned bits types */ +typedef __uint8_t u_int8_t; +typedef __uint16_t u_int16_t; +typedef __uint32_t u_int32_t; +typedef __uint64_t u_int64_t; + + +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef __size_t size_t; +#endif + +#ifndef _SSIZE_T_DEFINED_ +#define _SSIZE_T_DEFINED_ +typedef __ssize_t ssize_t; +#endif + +#ifndef _OFF_T_DEFINED_ +#define _OFF_T_DEFINED_ +typedef __off_t off_t; +#endif + +#endif /* !_SYS_TYPES_H_ */ diff --git a/common/inc/tlibc/time.h b/common/inc/tlibc/time.h new file mode 100644 index 0000000000..3880d3e9ac --- /dev/null +++ b/common/inc/tlibc/time.h @@ -0,0 +1,104 @@ +/* $OpenBSD: time.h,v 1.18 2006/01/06 18:53:04 millert Exp $ */ +/* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)time.h 5.12 (Berkeley) 3/9/91 + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + +#include +#include + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#if !defined (_CLOCK_T_DEFINED_) && !defined (_CLOCK_T_DEFINED) +#define _CLOCK_T_DEFINED_ +#define _CLOCK_T_DEFINED +typedef __clock_t clock_t; +#endif + +#if !defined (_TIME_T_DEFINED_) && !defined (_TIME_T_DEFINED) +#define _TIME_T_DEFINED_ +#define _TIME_T_DEFINED +typedef __time_t time_t; +#endif + +#if !defined (_SIZE_T_DEFINED_) && !defined (_SIZE_T_DEFINED) +#define _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED +typedef __size_t size_t; +#endif + +#if !defined (_TM_DEFINED) +#define _TM_DEFINED +struct tm { + int tm_sec; /* seconds after the minute [0-60] */ + int tm_min; /* minutes after the hour [0-59] */ + int tm_hour; /* hours since midnight [0-23] */ + int tm_mday; /* day of the month [1-31] */ + int tm_mon; /* months since January [0-11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday [0-6] */ + int tm_yday; /* days since January 1 [0-365] */ + int tm_isdst; /* Daylight Saving Time flag */ + /* FIXME: naming issue exists on Fedora/Ubuntu */ + long tm_gmtoff; /* offset from UTC in seconds */ + char *tm_zone; /* timezone abbreviation */ +}; +#endif + +__BEGIN_DECLS + +double _TLIBC_CDECL_ difftime(time_t, time_t); +char * _TLIBC_CDECL_ asctime(const struct tm *); +size_t _TLIBC_CDECL_ strftime(char *, size_t, const char *, const struct tm *); + +/* + * Non-C99 + */ +char * _TLIBC_CDECL_ asctime_r(const struct tm *, char *); + +__END_DECLS + +#endif /* !_TIME_H_ */ diff --git a/common/inc/tlibc/unistd.h b/common/inc/tlibc/unistd.h new file mode 100644 index 0000000000..2958a6ccc6 --- /dev/null +++ b/common/inc/tlibc/unistd.h @@ -0,0 +1,59 @@ +/* $OpenBSD: unistd.h,v 1.62 2008/06/25 14:58:54 millert Exp $ */ +/* $NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $ */ + +/*- + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)unistd.h 5.13 (Berkeley) 6/17/91 + */ + +#ifndef _UNISTD_H_ +#define _UNISTD_H_ + +#include +#include + +__BEGIN_DECLS + +void * _TLIBC_CDECL_ sbrk(intptr_t); + +/* + * Deprecated Non-C99. + */ +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, execl, const char *, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, execlp, const char *, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, execle, const char *, const char *, ...); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, execv, const char *, char * const *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, execve, const char *, char * const *, char * const *); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, execvp, const char *, char * const *); + +//_TLIBC_DEPRECATED_FUNCTION_(pid_t _TLIBC_CDECL_, fork, void); /* no pid_t */ + +__END_DECLS + +#endif /* !_UNISTD_H_ */ diff --git a/common/inc/tlibc/wchar.h b/common/inc/tlibc/wchar.h new file mode 100644 index 0000000000..4ca0b39f40 --- /dev/null +++ b/common/inc/tlibc/wchar.h @@ -0,0 +1,139 @@ +/* $OpenBSD: wchar.h,v 1.11 2010/07/24 09:58:39 guenther Exp $ */ +/* $NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julian Coleman. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _WCHAR_H_ +#define _WCHAR_H_ + +#include +#include +#include /* WCHAR_MAX/WCHAR_MIN */ + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus) +#define _WCHAR_T_DEFINED_ +#ifndef __WCHAR_TYPE__ +#define __WCHAR_TYPE__ int +#endif +typedef __WCHAR_TYPE__ wchar_t; +#endif + +#ifndef _MBSTATE_T_DEFINED_ +#define _MBSTATE_T_DEFINED_ +typedef __mbstate_t mbstate_t; +#endif + +#ifndef _WINT_T_DEFINED_ +#define _WINT_T_DEFINED_ +typedef __wint_t wint_t; +#endif + +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef __size_t size_t; +#endif + +#ifndef WEOF +#define WEOF ((wint_t)-1) +#endif + +__BEGIN_DECLS + +wint_t _TLIBC_CDECL_ btowc(int); +int _TLIBC_CDECL_ wctob(wint_t); +size_t _TLIBC_CDECL_ mbrlen(const char *, size_t, mbstate_t *); +size_t _TLIBC_CDECL_ mbrtowc(wchar_t *, const char *, size_t, mbstate_t *); +int _TLIBC_CDECL_ mbsinit(const mbstate_t *); +size_t _TLIBC_CDECL_ mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *); +size_t _TLIBC_CDECL_ wcrtomb(char *, wchar_t, mbstate_t *); +wchar_t * _TLIBC_CDECL_ wcschr(const wchar_t *, wchar_t); +int _TLIBC_CDECL_ wcscmp(const wchar_t *, const wchar_t *); +int _TLIBC_CDECL_ wcscoll(const wchar_t *, const wchar_t *); +size_t _TLIBC_CDECL_ wcscspn(const wchar_t *, const wchar_t *); +size_t _TLIBC_CDECL_ wcslen(const wchar_t *); +wchar_t * _TLIBC_CDECL_ wcsncat(wchar_t *, const wchar_t *, size_t); +int _TLIBC_CDECL_ wcsncmp(const wchar_t *, const wchar_t *, size_t); +wchar_t * _TLIBC_CDECL_ wcsncpy(wchar_t *, const wchar_t *, size_t); +wchar_t * _TLIBC_CDECL_ wcspbrk(const wchar_t *, const wchar_t *); +wchar_t * _TLIBC_CDECL_ wcsrchr(const wchar_t *, wchar_t); +size_t _TLIBC_CDECL_ wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *); +size_t _TLIBC_CDECL_ wcsspn(const wchar_t *, const wchar_t *); +wchar_t * _TLIBC_CDECL_ wcsstr(const wchar_t *, const wchar_t *); +wchar_t * _TLIBC_CDECL_ wcstok(wchar_t *, const wchar_t *, wchar_t **); +size_t _TLIBC_CDECL_ wcsxfrm(wchar_t *, const wchar_t *, size_t); +wchar_t * _TLIBC_CDECL_ wmemchr(const wchar_t *, wchar_t, size_t); +int _TLIBC_CDECL_ wmemcmp(const wchar_t *, const wchar_t *, size_t); +wchar_t * _TLIBC_CDECL_ wmemcpy(wchar_t *, const wchar_t *, size_t); +wchar_t * _TLIBC_CDECL_ wmemmove(wchar_t *, const wchar_t *, size_t); +wchar_t * _TLIBC_CDECL_ wmemset(wchar_t *, wchar_t, size_t); + +int _TLIBC_CDECL_ swprintf(wchar_t *, size_t, const wchar_t *, ...); +int _TLIBC_CDECL_ vswprintf(wchar_t *, size_t, const wchar_t *, __va_list); + +/* leagcy version of wcsstr */ +wchar_t * _TLIBC_CDECL_ wcswcs(const wchar_t *, const wchar_t *); + +__END_DECLS + +#endif /* !_WCHAR_H_ */ diff --git a/common/inc/tlibc/wctype.h b/common/inc/tlibc/wctype.h new file mode 100644 index 0000000000..25466f15d1 --- /dev/null +++ b/common/inc/tlibc/wctype.h @@ -0,0 +1,83 @@ +/* $OpenBSD: wctype.h,v 1.5 2006/01/06 18:53:04 millert Exp $ */ +/* $NetBSD: wctype.h,v 1.5 2003/03/02 22:18:11 tshiozak Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp + */ + +#ifndef _WCTYPE_H_ +#define _WCTYPE_H_ + +#include +#include + +#ifndef _WINT_T_DEFINED_ +#define _WINT_T_DEFINED_ +typedef __wint_t wint_t; +#endif + +#ifndef _WCTRANS_T_DEFINED_ +#define _WCTRANS_T_DEFINED_ +typedef __wctrans_t wctrans_t; +#endif + +#ifndef _WCTYPE_T_DEFINED_ +#define _WCTYPE_T_DEFINED_ +typedef __wctype_t wctype_t; +#endif + +#ifndef WEOF +#define WEOF ((wint_t)-1) +#endif + +__BEGIN_DECLS + +/* + * Deprecated definitions. + */ +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswalnum, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswalpha, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswblank, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswcntrl, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswdigit, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswgraph, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswlower, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswprint, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswpunct, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswspace, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswupper, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswxdigit, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, iswctype, wint_t, wctype_t); +_TLIBC_DEPRECATED_FUNCTION_(wint_t _TLIBC_CDECL_, towctrans, wint_t, wctrans_t); +_TLIBC_DEPRECATED_FUNCTION_(wint_t _TLIBC_CDECL_, towlower, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(wint_t _TLIBC_CDECL_, towupper, wint_t); +_TLIBC_DEPRECATED_FUNCTION_(wctrans_t _TLIBC_CDECL_, wctrans, const char *); +_TLIBC_DEPRECATED_FUNCTION_(wctype_t _TLIBC_CDECL_, wctype, const char *); + +__END_DECLS + +#endif /* _WCTYPE_H_ */ diff --git a/common/se_wrapper/Makefile b/common/se_wrapper/Makefile new file mode 100644 index 0000000000..0cf6f20ebd --- /dev/null +++ b/common/se_wrapper/Makefile @@ -0,0 +1,61 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +CFLAGS += -Werror -D_GNU_SOURCE -fPIC +CFLAGS += $(ADDED_INC) + +CPPFLAGS := -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal + +OBJS := se_memory.o \ + se_thread.o \ + se_trace.o \ + se_event.o \ + se_rwlock.o \ + se_time.o \ + se_map.o + +LIBWRAPPER := libwrapper.a + +.PHONY: clean all +all: $(LIBWRAPPER) + +$(LIBWRAPPER): $(OBJS) + $(AR) rcs $@ $^ + +$(OBJS): %.o: $(COMMON_DIR)/src/%.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +.PHONY: clean +clean: + @$(RM) $(LIBWRAPPER) $(OBJS) diff --git a/common/src/dh.cpp b/common/src/dh.cpp new file mode 100644 index 0000000000..6b01601b9f --- /dev/null +++ b/common/src/dh.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** +* File: +* dh.cpp +*Description: +* Encrypt and decrypt messages over DH session +*/ +#include "dh.h" +#include "sgx_tcrypto.h" + +bool encrypt_msg(pse_message_t* pse_msg, uint8_t* data, sgx_key_128bit_t* authenticated_encryption_key) +{ + /* get random IV */ + if(sgx_read_rand(pse_msg->payload_iv, PAYLOAD_IV_SIZE) != SGX_SUCCESS) + { + return false; + } + + return (SGX_SUCCESS == sgx_rijndael128GCM_encrypt( + authenticated_encryption_key, + data, + pse_msg->payload_size, + reinterpret_cast(&(pse_msg->payload)), + reinterpret_cast(&(pse_msg->payload_iv)), + 12, + NULL, + 0, + &pse_msg->payload_tag + )); +} + +bool decrypt_msg(pse_message_t* pse_msg, uint8_t* data, sgx_key_128bit_t* authenticated_encryption_key) +{ + return(SGX_SUCCESS == sgx_rijndael128GCM_decrypt( + authenticated_encryption_key, + pse_msg->payload, + pse_msg->payload_size, + data, + reinterpret_cast(&(pse_msg->payload_iv)), + 12, + NULL, + 0, + &pse_msg->payload_tag + )); +} + diff --git a/common/src/ecp.cpp b/common/src/ecp.cpp new file mode 100644 index 0000000000..ea632f9443 --- /dev/null +++ b/common/src/ecp.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_ecp_types.h" +#include "ecp_interface.h" +#include "stdlib.h" +#include "string.h" + +#ifndef ERROR_BREAK +#define ERROR_BREAK(x) if(x != ippStsNoErr){break;} +#endif +#ifndef NULL_BREAK +#define NULL_BREAK(x) if(!x){break;} +#endif +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} +#endif + +#define MAC_KEY_SIZE 16 + +#define EC_DERIVATION_BUFFER_SIZE(label_length) ((label_length) +4) + +sgx_status_t derive_key( + const sgx_ec256_dh_shared_t* shared_key, + const char* label, + uint32_t label_length, + sgx_ec_key_128bit_t* derived_key) +{ + sgx_status_t se_ret = SGX_SUCCESS; + uint8_t cmac_key[MAC_KEY_SIZE]; + sgx_ec_key_128bit_t key_derive_key; + if (!shared_key || !derived_key || !label) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + /*check integer overflow */ + if (label_length > EC_DERIVATION_BUFFER_SIZE(label_length)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + memset(cmac_key, 0, MAC_KEY_SIZE); + se_ret = sgx_rijndael128_cmac_msg((sgx_cmac_128bit_key_t *)cmac_key, + (uint8_t*)shared_key, + sizeof(sgx_ec256_dh_shared_t), + (sgx_cmac_128bit_tag_t *)&key_derive_key); + if (SGX_SUCCESS != se_ret) + { + memset_s(&key_derive_key, sizeof(key_derive_key), 0, sizeof(key_derive_key)); + INTERNAL_SGX_ERROR_CODE_CONVERTOR(se_ret); + return se_ret; + } + /* derivation_buffer = counter(0x01) || label || 0x00 || output_key_len(0x0080) */ + uint32_t derivation_buffer_length = EC_DERIVATION_BUFFER_SIZE(label_length); + uint8_t *p_derivation_buffer = (uint8_t *)malloc(derivation_buffer_length); + if (p_derivation_buffer == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(p_derivation_buffer, 0, derivation_buffer_length); + + /*counter = 0x01 */ + p_derivation_buffer[0] = 0x01; + /*label*/ + memcpy(&p_derivation_buffer[1], label, label_length); + /*output_key_len=0x0080*/ + uint16_t *key_len = (uint16_t *)&p_derivation_buffer[derivation_buffer_length - 2]; + *key_len = 0x0080; + + se_ret = sgx_rijndael128_cmac_msg((sgx_cmac_128bit_key_t *)&key_derive_key, + p_derivation_buffer, + derivation_buffer_length, + (sgx_cmac_128bit_tag_t *)derived_key); + memset_s(&key_derive_key, sizeof(key_derive_key), 0, sizeof(key_derive_key)); + free(p_derivation_buffer); + if(SGX_SUCCESS != se_ret) + { + INTERNAL_SGX_ERROR_CODE_CONVERTOR(se_ret); + } + return se_ret; +} diff --git a/common/src/ipp_bn.cpp b/common/src/ipp_bn.cpp new file mode 100644 index 0000000000..03b7cb6826 --- /dev/null +++ b/common/src/ipp_bn.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** +* File: +* ipp_bn.cpp +*Description: +* Wrappers for Big number generation and free functions +* +*/ + + + +#include "ipp_wrapper.h" + +#include +#include + +#ifndef _TLIBC_CDECL_ +extern "C" int memset_s(void *s, size_t smax, int c, size_t n); +#endif + +extern "C" IppStatus + newBN(const Ipp32u *data, int size_in_bytes, IppsBigNumState **p_new_BN) +{ + IppsBigNumState *pBN=0; + int bn_size = 0; + + if(p_new_BN == NULL || size_in_bytes <= 0 || size_in_bytes % sizeof(Ipp32u)) + return ippStsBadArgErr; + + /* Get the size of the IppsBigNumState context in bytes */ + IppStatus error_code = ippsBigNumGetSize(size_in_bytes/(int)sizeof(Ipp32u), &bn_size); + if(error_code != ippStsNoErr) + { + *p_new_BN = 0; + return error_code; + } + pBN = (IppsBigNumState *) malloc(bn_size); + if(!pBN) + { + error_code = ippStsMemAllocErr; + *p_new_BN = 0; + return error_code; + } + /* Initializes context and partitions allocated buffer */ + error_code = ippsBigNumInit(size_in_bytes/(int)sizeof(Ipp32u), pBN); + if(error_code != ippStsNoErr) + { + SAFE_FREE_MM(pBN); + *p_new_BN = 0; + return error_code; + } + if(data) + { + error_code = ippsSet_BN(IppsBigNumPOS, size_in_bytes/(int)sizeof(Ipp32u), data, pBN); + if(error_code != ippStsNoErr) + { + SAFE_FREE_MM(pBN); + *p_new_BN = 0; + return error_code; + } + } + *p_new_BN = pBN; + return error_code; + +} + + +extern "C" void secure_free_BN(IppsBigNumState *pBN, int size_in_bytes) +{ + if(pBN == NULL || size_in_bytes <= 0 || size_in_bytes % sizeof(Ipp32u)) + { + if(pBN) + { + free(pBN); + } + return; + } + + int bn_size = 0; + + /* Get the size of the IppsBigNumState context in bytes + * Since we have checked the size_in_bytes before and the &bn_size is not NULL, + * ippsBigNumGetSize never returns failure + */ + if(ippsBigNumGetSize(size_in_bytes/(int)sizeof(Ipp32u), &bn_size) != ippStsNoErr) + { + free(pBN); + return; + } + /* Clear the buffer before free. */ + memset_s(pBN, bn_size, 0, bn_size); + free(pBN); + return; +} diff --git a/common/src/ipp_rsa_key.cpp b/common/src/ipp_rsa_key.cpp new file mode 100644 index 0000000000..e1ccd5513e --- /dev/null +++ b/common/src/ipp_rsa_key.cpp @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** +* File: +* ipp_rsa_key.cpp +*Description: +* Wrapper for rsa key operation functions (public key generation and free excluded) +* +*/ + +#include "ipp_wrapper.h" +#include "util.h" + +#include +#include +#include +#include + +extern "C" int memset_s(void *s, size_t smax, int c, size_t n); + +static IppStatus newPRNG(IppsPRNGState **pRandGen) +{ + if(pRandGen == NULL) + return ippStsBadArgErr; + int ctxSize = 0; + IppStatus error_code = ippsPRNGGetSize(&ctxSize); + if(error_code != ippStsNoErr) + return error_code; + IppsPRNGState* pCtx = (IppsPRNGState *) malloc(ctxSize); + if(pCtx == NULL) + return ippStsMemAllocErr; + + error_code = ippsPRNGInit(160, pCtx); + if(error_code != ippStsNoErr) + { + free(pCtx); + return error_code; + } + + *pRandGen = pCtx; + return error_code; +} + +static IppStatus newPrimeGen(int nMaxBits, IppsPrimeState ** pPrimeG) +{ + if(pPrimeG == NULL || nMaxBits <= 0 ) + return ippStsBadArgErr; + int ctxSize = 0; + IppStatus error_code = ippsPrimeGetSize(nMaxBits, &ctxSize); + if(error_code != ippStsNoErr) + return error_code; + IppsPrimeState* pCtx = (IppsPrimeState *) malloc(ctxSize); + if(pCtx == NULL) + return ippStsMemAllocErr; + + error_code = ippsPrimeInit(nMaxBits, pCtx); + if(error_code != ippStsNoErr) + { + free(pCtx); + return error_code; + } + + *pPrimeG = pCtx; + return error_code; +} + + +extern "C" IppStatus create_rsa_priv2_key(int p_byte_size, const Ipp32u *p, const Ipp32u *q, + const Ipp32u *dmp1, const Ipp32u *dmq1, const Ipp32u *iqmp, + IppsRSAPrivateKeyState **new_pri_key2) +{ + IppsRSAPrivateKeyState *p_rsa2 = NULL; + IppsBigNumState *p_p = NULL, *p_q = NULL, *p_dmp1 = NULL, *p_dmq1 = NULL, *p_iqmp = NULL; + int rsa2_size = 0; + + if(p_byte_size <= 0 || p == NULL || q == NULL || dmp1 == NULL || dmq1 == NULL || iqmp == NULL || new_pri_key2 == NULL) + { + return ippStsBadArgErr; + } + + IppStatus error_code = ippStsNoErr; + do{ + error_code = newBN(p, p_byte_size, &p_p); + ERROR_BREAK(error_code); + error_code = newBN(q, p_byte_size, &p_q); + ERROR_BREAK(error_code); + error_code = newBN(dmp1, p_byte_size, &p_dmp1); + ERROR_BREAK(error_code); + error_code = newBN(dmq1, p_byte_size, &p_dmq1); + ERROR_BREAK(error_code); + error_code = newBN(iqmp, p_byte_size, &p_iqmp); + ERROR_BREAK(error_code); + error_code = ippsRSA_GetSizePrivateKeyType2(p_byte_size * 8, p_byte_size * 8, &rsa2_size); + ERROR_BREAK(error_code); + p_rsa2 = (IppsRSAPrivateKeyState *)malloc(rsa2_size); + NULL_BREAK(p_rsa2); + + error_code = ippsRSA_InitPrivateKeyType2(p_byte_size * 8, p_byte_size * 8, p_rsa2, rsa2_size); + ERROR_BREAK(error_code); + error_code = ippsRSA_SetPrivateKeyType2(p_p, p_q, p_dmp1, p_dmq1, p_iqmp, p_rsa2); + ERROR_BREAK(error_code); + }while(0); + + secure_free_BN(p_p, p_byte_size); + secure_free_BN(p_q, p_byte_size); + secure_free_BN(p_dmp1, p_byte_size); + secure_free_BN(p_dmq1, p_byte_size); + secure_free_BN(p_iqmp, p_byte_size); + + if(error_code != ippStsNoErr || p_rsa2 == NULL) + { + if(error_code == ippStsNoErr ) + error_code = ippStsMemAllocErr; + + /* Clear sensitive data before free */ + secure_free_rsa_pri2_key(p_byte_size, p_rsa2); + return error_code; + } + + *new_pri_key2 = p_rsa2; + return error_code; +} + +extern "C" IppStatus create_rsa_priv1_key(int n_byte_size, int d_byte_size, const Ipp32u *n, const Ipp32u *d, IppsRSAPrivateKeyState **new_pri_key1) +{ + IppsRSAPrivateKeyState *p_rsa1 = NULL; + IppsBigNumState *p_n = NULL, *p_d = NULL; + int rsa1_size = 0; + if(n_byte_size <= 0 || d_byte_size <= 0 || n == NULL || d == NULL || new_pri_key1 == NULL) + { + return ippStsBadArgErr; + } + IppStatus error_code = ippStsNoErr; + do{ + error_code = newBN(n, n_byte_size, &p_n); + ERROR_BREAK(error_code); + error_code = newBN(d, d_byte_size, &p_d); + ERROR_BREAK(error_code); + + error_code = ippsRSA_GetSizePrivateKeyType1(n_byte_size * 8, d_byte_size * 8, &rsa1_size); + ERROR_BREAK(error_code); + p_rsa1 = (IppsRSAPrivateKeyState *)malloc(rsa1_size); + NULL_BREAK(p_rsa1); + error_code = ippsRSA_InitPrivateKeyType1(n_byte_size * 8, d_byte_size * 8, p_rsa1, rsa1_size); + ERROR_BREAK(error_code); + error_code = ippsRSA_SetPrivateKeyType1(p_n, p_d, p_rsa1); + ERROR_BREAK(error_code); + }while(0); + secure_free_BN(p_n, n_byte_size); + secure_free_BN(p_d, d_byte_size); + if(error_code != ippStsNoErr || p_rsa1 == NULL) + { + if(error_code == ippStsNoErr ) + error_code = ippStsMemAllocErr; + + /* Clear sensitive data before free */ + secure_free_rsa_pri1_key(n_byte_size, d_byte_size, p_rsa1); + return error_code; + } + + *new_pri_key1 = p_rsa1; + return error_code; +} + + +extern "C" IppStatus create_validate_rsa_key_pair(int n_byte_size, int e_byte_size, const Ipp32u *n, const Ipp32u *d, const Ipp32u *e, const Ipp32u *p, const Ipp32u *q, + const Ipp32u *dmp1, const Ipp32u *dmq1, const Ipp32u *iqmp, + IppsRSAPrivateKeyState **new_pri_key, IppsRSAPublicKeyState **new_pub_key, int *validate_result) +{ + if(n_byte_size <= 0 || e_byte_size <= 0 || n == NULL || d == NULL || e == NULL || + p == NULL || q == NULL || dmp1 == NULL || dmq1 == NULL || iqmp == NULL || new_pri_key == NULL || + new_pub_key == NULL || validate_result == NULL) + { + return ippStsBadArgErr; + } + IppsRSAPrivateKeyState *p_pri_key1 = NULL, *p_pri_key2 = NULL; + IppsRSAPublicKeyState *p_pub_key = NULL; + IppStatus error_code = ippStsNoErr; + IppsPRNGState *p_rand = NULL; + IppsPrimeState *p_prime = NULL; + Ipp8u * scratch_buffer = NULL; + int result = IPP_IS_VALID; + int max_size = 0, pri1_size = 0, pri2_size = 0, pub_size = 0; + + do + { + /* Generate the pri_key1, pri_key2 and pub_key */ + error_code = create_rsa_priv1_key(n_byte_size, n_byte_size, n, d, &p_pri_key1); + ERROR_BREAK(error_code); + error_code = create_rsa_priv2_key(n_byte_size/2, p, q, dmp1, dmq1, iqmp, &p_pri_key2); + ERROR_BREAK(error_code); + error_code = create_rsa_pub_key(n_byte_size, e_byte_size, n, e, &p_pub_key); + ERROR_BREAK(error_code); + + /* Generate random state and prime state */ + error_code = newPRNG(&p_rand); + ERROR_BREAK(error_code); + error_code = newPrimeGen(n_byte_size * 8 / 2, &p_prime); + ERROR_BREAK(error_code); + + /* Allocate scratch buffer */ + error_code = ippsRSA_GetBufferSizePrivateKey(&pri1_size, p_pri_key1); + ERROR_BREAK(error_code); + error_code = ippsRSA_GetBufferSizePrivateKey(&pri2_size, p_pri_key2); + ERROR_BREAK(error_code); + max_size = MAX(pri1_size, pri2_size); + error_code = ippsRSA_GetBufferSizePublicKey(&pub_size, p_pub_key); + ERROR_BREAK(error_code); + max_size = MAX(max_size, pub_size); + scratch_buffer = (Ipp8u *)malloc(max_size); + NULL_BREAK(scratch_buffer); + memset(scratch_buffer, 0, max_size); + + /* Validate keys */ + error_code = ippsRSA_ValidateKeys(&result, p_pub_key, p_pri_key2, p_pri_key1, scratch_buffer, 10, p_prime, ippsPRNGen, p_rand); + ERROR_BREAK(error_code); + }while(0); + SAFE_FREE_MM(p_rand); + SAFE_FREE_MM(p_prime); + secure_free_rsa_pri2_key(n_byte_size/2, p_pri_key2); + + if(error_code != ippStsNoErr || scratch_buffer == NULL) + { + if(error_code == ippStsNoErr) + error_code = ippStsMemAllocErr; + + SAFE_FREE_MM(scratch_buffer); + secure_free_rsa_pri1_key(n_byte_size, n_byte_size, p_pri_key1); + secure_free_rsa_pub_key(n_byte_size, e_byte_size, p_pub_key); + return error_code; + } + SAFE_FREE_MM(scratch_buffer); + *new_pri_key = p_pri_key1; + *new_pub_key = p_pub_key; + *validate_result = result; + return error_code; +} + +extern "C" IppStatus get_pub_key(const IppsRSAPublicKeyState *pub_key, int *e_byte_size, Ipp32u *e, int *n_byte_size, Ipp32u *n) +{ + IppStatus error_code = ippStsNoErr; + IppsBigNumState *p_n=NULL, *p_e=NULL; + + if(!pub_key || !e_byte_size || !e || !n_byte_size || !n) + { + return ippStsBadArgErr; + } + do + { + error_code = newBN(NULL, SE_KEY_SIZE, &p_n); + ERROR_BREAK(error_code); + error_code = newBN(NULL, sizeof(Ipp32u), &p_e); + ERROR_BREAK(error_code); + + error_code = ippsRSA_GetPublicKey(p_n, p_e, pub_key); + ERROR_BREAK(error_code); + + IppsBigNumSGN sgn = IppsBigNumPOS; + Ipp32u *pdata = NULL; + int length_in_bit = 0; + + + error_code = ippsRef_BN(&sgn, &length_in_bit, &pdata, p_n); + ERROR_BREAK(error_code); + *n_byte_size = ROUND_TO(length_in_bit, 8)/8; + memset(n, 0, *n_byte_size); + memcpy(n, pdata, ROUND_TO(length_in_bit, 8)/8); + + error_code = ippsRef_BN(&sgn, &length_in_bit, &pdata, p_e); + ERROR_BREAK(error_code); + *e_byte_size = ROUND_TO(length_in_bit, 8)/8; + memset(e, 0, *e_byte_size); + memcpy(e, pdata, ROUND_TO(length_in_bit, 8)/8); + } while(0); + + secure_free_BN(p_n, SE_KEY_SIZE); + secure_free_BN(p_e, sizeof(Ipp32u)); + return error_code; +} + +extern "C" void secure_free_rsa_pri1_key(int n_byte_size, int d_byte_size, IppsRSAPrivateKeyState *pri_key1) +{ + if(n_byte_size <= 0 || d_byte_size <= 0 || pri_key1 == NULL) + { + if(pri_key1) + free(pri_key1); + return; + } + + int rsa1_size = 0; + if(ippsRSA_GetSizePrivateKeyType1(n_byte_size * 8, d_byte_size * 8, &rsa1_size) != ippStsNoErr) + { + free(pri_key1); + return; + } + /* Clear the buffer before free. */ + memset_s(pri_key1, rsa1_size, 0, rsa1_size); + free(pri_key1); + return; +} + +extern "C" void secure_free_rsa_pri2_key(int p_byte_size, IppsRSAPrivateKeyState *pri_key2) +{ + if(p_byte_size <= 0 || pri_key2 == NULL) + { + if(pri_key2) + free(pri_key2); + return; + } + + int rsa2_size = 0; + if(ippsRSA_GetSizePrivateKeyType2(p_byte_size * 8, p_byte_size * 8, &rsa2_size) != ippStsNoErr) + { + free(pri_key2); + return; + } + /* Clear the buffer before free. */ + memset_s(pri_key2, rsa2_size, 0, rsa2_size); + free(pri_key2); + return; +} diff --git a/common/src/ipp_rsa_pub_key.cpp b/common/src/ipp_rsa_pub_key.cpp new file mode 100644 index 0000000000..dfc3fc3488 --- /dev/null +++ b/common/src/ipp_rsa_pub_key.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** +* File: +* ipp_rsa_pub_key.cpp +*Description: +* Wrapper for rsa public key generation and free +* +*/ + +#include "ipp_wrapper.h" + +#include +#include + +#ifndef _TLIBC_CDECL_ +extern "C" int memset_s(void *s, size_t smax, int c, size_t n); +#endif + +extern "C" IppStatus create_rsa_pub_key(int n_byte_size, int e_byte_size, const Ipp32u *n, const Ipp32u *e, IppsRSAPublicKeyState **new_pub_key) +{ + IppsRSAPublicKeyState *p_pub_key = NULL; + IppsBigNumState *p_n = NULL, *p_e = NULL; + int rsa_size = 0; + if(n_byte_size <= 0 || e_byte_size <= 0 || n == NULL || e == NULL || new_pub_key == NULL) + { + return ippStsBadArgErr; + } + + IppStatus error_code = ippStsNoErr; + do{ + error_code = newBN(n, n_byte_size, &p_n); + ERROR_BREAK(error_code); + error_code = newBN(e, e_byte_size, &p_e); + ERROR_BREAK(error_code); + + error_code = ippsRSA_GetSizePublicKey(n_byte_size * 8, e_byte_size * 8, &rsa_size); + ERROR_BREAK(error_code); + p_pub_key = (IppsRSAPublicKeyState *)malloc(rsa_size); + NULL_BREAK(p_pub_key); + error_code = ippsRSA_InitPublicKey(n_byte_size * 8, e_byte_size * 8, p_pub_key, rsa_size); + ERROR_BREAK(error_code); + error_code = ippsRSA_SetPublicKey(p_n, p_e, p_pub_key); + ERROR_BREAK(error_code); + }while(0); + secure_free_BN(p_n, n_byte_size); + secure_free_BN(p_e, e_byte_size); + if(error_code != ippStsNoErr || p_pub_key == NULL) + { + if(error_code == ippStsNoErr ) + error_code = ippStsMemAllocErr; + + secure_free_rsa_pub_key(n_byte_size, e_byte_size, p_pub_key); + return error_code; + } + + *new_pub_key = p_pub_key; + return error_code; + +} + +extern "C" void secure_free_rsa_pub_key(int n_byte_size, int e_byte_size, IppsRSAPublicKeyState *pub_key) +{ + if(n_byte_size <= 0 || e_byte_size <= 0 || pub_key == NULL) + { + if(pub_key) + free(pub_key); + return; + } + int rsa_size = 0; + if(ippsRSA_GetSizePublicKey(n_byte_size * 8, e_byte_size * 8, &rsa_size) != ippStsNoErr) + { + free(pub_key); + return; + } + /* Clear the buffer before free. */ + memset_s(pub_key, rsa_size, 0, rsa_size); + free(pub_key); + return; +} diff --git a/common/src/se_event.c b/common/src/se_event.c new file mode 100644 index 0000000000..132e48b204 --- /dev/null +++ b/common/src/se_event.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_event.h" + +#include + +se_handle_t se_event_init(void) +{ + return calloc(1, sizeof(int)); +} + +void se_event_destroy(se_handle_t se_event) +{ + if (se_event != NULL) + free(se_event); +} + +int se_event_wait(se_handle_t se_event) +{ + if (se_event == NULL) + return SE_MUTEX_INVALID; + + if (__sync_fetch_and_add((int*)se_event, -1) == 0) + syscall(__NR_futex, se_event, FUTEX_WAIT, -1, NULL, NULL, 0); + + return SE_MUTEX_SUCCESS; +} + +int se_event_wake(se_handle_t se_event) +{ + if (se_event == NULL) + return SE_MUTEX_INVALID; + + if (__sync_fetch_and_add((int*)se_event, 1) != 0) + syscall(__NR_futex, se_event, FUTEX_WAKE, 1, NULL, NULL, 0); + + return SE_MUTEX_SUCCESS; +} diff --git a/common/src/se_map.c b/common/src/se_map.c new file mode 100644 index 0000000000..687d035012 --- /dev/null +++ b/common/src/se_map.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "se_map.h" +#include "se_trace.h" +#include + +map_handle_t* map_file(se_file_handle_t fd, uint32_t *size) +{ + struct stat st; + memset(&st, 0, sizeof(st)); + if (-1 == fstat(fd, &st)) + return NULL; + + map_handle_t* mh = (map_handle_t *)calloc(1, sizeof(map_handle_t)); + if (mh == NULL) + return NULL; + + mh->base_addr = (uint8_t *)mmap(NULL, (size_t)st.st_size, + PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + if(MAP_FAILED == mh->base_addr) + { + free(mh); + SE_TRACE(SE_TRACE_WARNING, "Couldn't map view of file, error code %x\n", errno); + return NULL; + } + + mh->length = (size_t)st.st_size; + if (size) *size = (uint32_t)st.st_size; + return mh; +} + +void unmap_file(map_handle_t* mh) +{ + munmap(mh->base_addr, mh->length); + free(mh); +} + + diff --git a/common/src/se_memory.c b/common/src/se_memory.c new file mode 100644 index 0000000000..d860b6bc34 --- /dev/null +++ b/common/src/se_memory.c @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "se_memory.h" +#include "se_trace.h" +#include "util.h" + +void* se_virtual_alloc(void* address, size_t size, uint32_t type) +{ + UNUSED(type); + void* pRet = mmap(address, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if(MAP_FAILED == pRet) + return NULL; + return pRet; +} + +int se_virtual_free(void* address, size_t size, uint32_t type) +{ + UNUSED(type); + + return !(munmap(address, size)); + +} + +int se_virtual_lock(void* address, size_t size) +{ + return !mlock(address, size); +} + +static unsigned int get_prot(uint64_t flags) +{ + if ((flags & SI_FLAG_PT_MASK) == SI_FLAG_TCS) + return PROT_READ|PROT_WRITE|PROT_EXEC; + + switch (flags & (SI_FLAG_R | SI_FLAG_W | SI_FLAG_X)) + { + case SI_FLAG_X: return PROT_EXEC; break; + case SI_FLAG_R | SI_FLAG_X: return PROT_READ|PROT_EXEC; break; + case SI_FLAG_R | SI_FLAG_W | SI_FLAG_X: return PROT_READ|PROT_WRITE|PROT_EXEC; break; + case SI_FLAG_R: return PROT_READ; break; + case SI_FLAG_R | SI_FLAG_W: return PROT_READ|PROT_WRITE; break; + /* This covers no access, W and WX */ + default: return PROT_NONE; break; + } + +} +int se_virtual_protect(void* address, size_t size, uint32_t prot) +{ + return !mprotect(address, size, (int)get_prot(prot)); +} + +se_proc_t get_self_proc() +{ + return getpid(); +} + +int put_self_proc(se_proc_t proc) +{ + UNUSED(proc); + return 1; +} + +int se_read_process_mem(se_proc_t proc, void* base_addr, void* buffer, size_t size, size_t* read_nr) +{ + char filename[64]; + int fd = -1; + int ret = FALSE; + ssize_t len = 0; + off64_t offset = (off64_t)(size_t) base_addr; + + snprintf (filename, 64, "/proc/%d/mem", (int)proc); + fd = open(filename, O_RDONLY | O_LARGEFILE); + if(fd == -1) + return FALSE; + + if(lseek64(fd, offset, SEEK_SET) == -1) + { + goto out; + } + if((len = read(fd, buffer, size)) < 0) + { + goto out; + } + else if(read_nr) + *read_nr = (size_t)len; /* len is a non-negative number */ + + ret = TRUE; + +out: + close (fd); + return ret; +} + +int se_write_process_mem(se_proc_t proc, void* base_addr, void* buffer, size_t size, size_t* write_nr) +{ + char filename[64]; + int fd = -1; + int ret = FALSE; + ssize_t len = 0; + off64_t offset = (off64_t)(size_t)base_addr; + + snprintf (filename, 64, "/proc/%d/mem", (int)proc); + fd = open(filename, O_RDWR | O_LARGEFILE); + if(fd == -1) + return FALSE; + + if(lseek64(fd, offset, SEEK_SET) == -1) + { + goto out; + } + if((len = write(fd, buffer, size)) < 0) + { + goto out; + } + else if(write_nr) + *write_nr = (size_t)len; /* len is a non-negative number */ + + ret = TRUE; +out: + close (fd); + return ret; +} + diff --git a/common/src/se_rwlock.c b/common/src/se_rwlock.c new file mode 100644 index 0000000000..9164a123f7 --- /dev/null +++ b/common/src/se_rwlock.c @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_rwlock.h" +#include "internal/util.h" + + +#include +void se_wtlock(se_prwlock_t lock) +{ + int ret = pthread_rwlock_wrlock(lock); + if(0 != ret) + abort(); +} + +void se_wtunlock(se_prwlock_t lock) +{ + int ret = pthread_rwlock_unlock(lock); + if(0 != ret) + abort(); +} + +int se_try_rdlock(se_prwlock_t lock) +{ + return (0 == pthread_rwlock_tryrdlock(lock)); +} + +void se_rdlock(se_prwlock_t lock) +{ + int ret = pthread_rwlock_rdlock(lock); + if(0 != ret) + abort(); +} + +void se_rdunlock(se_prwlock_t lock) +{ + int ret = pthread_rwlock_unlock(lock); + if(0 != ret) + abort(); +} + +void se_init_rwlock(se_prwlock_t lock) +{ + /* use the default attribute. */ + int ret = pthread_rwlock_init(lock, NULL); + if(0 != ret) + abort(); +} + +void se_fini_rwlock(se_prwlock_t lock) +{ + int ret = pthread_rwlock_destroy(lock); + if(0 != ret) + abort(); +} + diff --git a/common/src/se_thread.c b/common/src/se_thread.c new file mode 100644 index 0000000000..b188a049d1 --- /dev/null +++ b/common/src/se_thread.c @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "se_thread.h" +#include "se_types.h" + +void se_mutex_init(se_mutex_t* mutex) +{ +#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + se_mutex_t tmp = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) + se_mutex_t tmp = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; +#else +#error no pre-defined RECURSIVE_MUTEX found. +#endif + + /* C doesn't allow `*mutex = PTHREAD_..._INITIALIZER'.*/ + memcpy(mutex, &tmp, sizeof(tmp)); +} + +int se_mutex_lock(se_mutex_t* mutex) { return (0 == pthread_mutex_lock(mutex)); } +int se_mutex_unlock(se_mutex_t* mutex) { return (0 == pthread_mutex_unlock(mutex)); } +int se_mutex_destroy(se_mutex_t* mutex) { return (0 == pthread_mutex_destroy(mutex));} + +unsigned int se_get_threadid(void) { return (unsigned)syscall(__NR_gettid);} +/* tls functions */ +int se_tls_alloc(se_tls_index_t *tls_index) { return !pthread_key_create(tls_index, NULL); } +int se_tls_free(se_tls_index_t tls_index) { return !pthread_key_delete(tls_index); } +void * se_tls_get_value(se_tls_index_t tls_index) { return pthread_getspecific(tls_index); } +int se_tls_set_value(se_tls_index_t tls_index, void *tls_value) { return !pthread_setspecific(tls_index, tls_value); } +/* +se_thread_handle_t se_create_thread(size_t stack_size, thread_start_routine_t start_routine, void *param, se_thread_t *thread) +{ + pthread_attr_t attr, *attr_ptr = NULL; + int ret; + + if(stack_size > 0) + { + ret = pthread_attr_init(&attr); + if(ret) + return NULL; + ret = pthread_attr_setstacksize(&attr, stack_size); + if(ret) + return NULL; + attr_ptr = &attr; + } + else + { + attr_ptr = NULL; + } + ret = pthread_create(thread, attr_ptr, start_routine, param); + if(ret) + return NULL; + if(attr_ptr) + pthread_attr_destroy(&attr); + + return thread; + +} +*/ diff --git a/common/src/se_time.c b/common/src/se_time.c new file mode 100644 index 0000000000..20bc84fc38 --- /dev/null +++ b/common/src/se_time.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_time.h" + + +#include +#include +void se_sleep(uint32_t milli_seconds) +{ + usleep(milli_seconds * 1000); +} + +uint64_t se_get_tick_count_freq(void) +{ + return 1000000000ULL; +} + +uint64_t se_get_tick_count(void) +{ + struct timespec tm; + if (clock_gettime(CLOCK_MONOTONIC, &tm) != 0) + return 0; + return ((uint64_t)tm.tv_sec * 1000000000ULL) + ((uint64_t)tm.tv_nsec ); +} diff --git a/common/src/se_trace.c b/common/src/se_trace.c new file mode 100644 index 0000000000..ff81de827d --- /dev/null +++ b/common/src/se_trace.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_trace.h" +#include +int se_trace_internal(int debug_level, const char *fmt, ...) +{ + va_list args; + int ret = 0; + + va_start(args, fmt); + if(SE_TRACE_NOTICE == debug_level) + ret = vfprintf(stdout, fmt, args); + else + ret = vfprintf(stderr, fmt, args); + va_end(args); + + return ret; +} diff --git a/common/src/sgx_memset_s.cpp b/common/src/sgx_memset_s.cpp new file mode 100644 index 0000000000..816c1504e5 --- /dev/null +++ b/common/src/sgx_memset_s.cpp @@ -0,0 +1,78 @@ +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Alan Barrett + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ISO/IEC 9899:2011 section K.3.7.4.1 The memset_s function + */ + +#include "sgx_memset_s.h" +#include +#include +#include +/* + * __memset_vp is a volatile pointer to a function. + * It is initialised to point to memset, and should never be changed. + */ +static void * (* const volatile __memset_vp)(void *, int, size_t) + = (memset); + +#ifdef memset_s +#undef memset_s /* in case it was defined as a macro */ +#endif + +#ifdef __cplusplus +extern "C" +#endif +int memset_s(void *s, size_t smax, int c, size_t n) +{ + int err = 0; + + if (s == NULL) { + err = EINVAL; + goto out; + } + + if (n > smax) { + err = EOVERFLOW; + n = smax; + } + + /* Calling through a volatile pointer should never be optimised away. */ + (*__memset_vp)(s, c, n); + + out: + if (err == 0) + return 0; + else { + errno = err; + /* XXX call runtime-constraint handler */ + return err; + } +} + diff --git a/common/src/sgx_profile.cpp b/common/src/sgx_profile.cpp new file mode 100644 index 0000000000..17244cd008 --- /dev/null +++ b/common/src/sgx_profile.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifdef _PROFILE_ + +#include +#include +#include +#include "sgx_profile.h" +#include "se_time.h" +#include +using namespace std; + +typedef struct _profile_item_t{ + const char *str; /* tag */ + int flag; /* 0: start, 1: end */ + long long time; /* current time */ +} profile_item_t; + +static vector profile_items; +static int alloc_size; +static int used_size; +const int MALLOC_SIZE = 1000; +static long long freq = {0}; + +#define MALLOC_TAG "PROFILE_MALLOC_CONSUMED_TIME" + +extern "C" void profile_init() +{ + freq = se_get_tick_count_freq(); + profile_items.resize(MALLOC_SIZE); + alloc_size = MALLOC_SIZE; + used_size = 0; +} + +static void profile_add_info(const char *str, int flag) +{ + long long cur_time = se_get_tick_count(); + if(used_size==alloc_size){ + alloc_size+=MALLOC_SIZE; + profile_items.resize(alloc_size); + profile_items[used_size].flag = PRO_START; + profile_items[used_size].str = MALLOC_TAG; + profile_items[used_size].time = cur_time; + cur_time = se_get_tick_count(); + used_size++; + profile_items[used_size].flag = PRO_END; + profile_items[used_size].str = MALLOC_TAG; + profile_items[used_size].time = cur_time; + used_size++; + } + profile_items[used_size].flag = flag; + profile_items[used_size].str = str; + profile_items[used_size].time = cur_time; + used_size++; +} + +extern "C" void profile_start(const char* str) +{ + profile_add_info(str, PRO_START); +} + +extern "C" void profile_end(const char * str) +{ + profile_add_info(str, PRO_END); +} + +#include +std::string get_prof_fun_name(const char *s) +{ + std::string input(s); + size_t end = input.find("("); + size_t begin = input.substr(0,end).rfind(" ")+1; + end = end - begin; + return input.substr(begin,end); +} + +extern "C" void profile_output(const char* filename) +{ + int i,j; + + ofstream fs; + fs.open(filename); /* do not overwritten previous value */ + + fs << "freq: " << freq <str << endl; */ + return; + } + } + } + + if(j == used_size) + { + /* cout << "Error: not find end for " << it->str << endl; */ + return; + } + + fs << get_prof_fun_name(profile_items[i].str) << "," << profile_items[i].time << "," << profile_items[j].time << endl; + } + profile_items.clear(); + used_size=0; + alloc_size=0; + fs.close(); + +} +#endif diff --git a/common/src/sgx_read_rand.cpp b/common/src/sgx_read_rand.cpp new file mode 100644 index 0000000000..410ea6979c --- /dev/null +++ b/common/src/sgx_read_rand.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* Please add external/rdrand into INCLUDE path and correpondent library to project */ + +#include +#include +#include +#include "sgx.h" +#include "sgx_defs.h" +#include "se_wrapper.h" +#include "rdrand.h" +#include "cpuid.h" +#include +#ifndef UINT32_MAX +#define UINT32_MAX 0xFFFFFFFFU +#endif + +static int g_is_rdrand_supported=-1; + +#define RDRAND_MASK 0x40000000 + +static int rdrand_cpuid() +{ + int info[4] = {-1, -1, -1, -1}; + + /* Are we on an Intel processor? */ + + __cpuid(info, 0); + + if (memcmp(&info[1], "Genu", 4) != 0 || + memcmp(&info[3], "ineI", 4) != 0 || + memcmp(&info[2], "ntel", 4) != 0 ) { + return 0; + } + + /* Do we have RDRAND? */ + + __cpuid(info, /*feature bits*/1); + + int ecx = info[2]; + if ((ecx & RDRAND_MASK) == RDRAND_MASK) + return 1; + else + return 0; +} + + +extern "C" sgx_status_t SGXAPI sgx_read_rand(uint8_t *buf, size_t size) +{ + if(buf == NULL || size == 0 || size> UINT32_MAX ){ + return SGX_ERROR_INVALID_PARAMETER; + } + if(g_is_rdrand_supported==-1){ + g_is_rdrand_supported = rdrand_cpuid(); + } + if(!g_is_rdrand_supported){ + uint32_t i; + for(i=0;i<(uint32_t)size;++i){ + buf[i]=(uint8_t)rand(); + } + }else{ + int rd_ret =rdrand_get_bytes((uint32_t)size, buf); + if(rd_ret != RDRAND_SUCCESS){ + rd_ret = rdrand_get_bytes((uint32_t)size, buf); + if(rd_ret != RDRAND_SUCCESS){ + return SGX_ERROR_UNEXPECTED; + } + } + } + return SGX_SUCCESS; +} diff --git a/common/src/sgx_sha256_128.cpp b/common/src/sgx_sha256_128.cpp new file mode 100644 index 0000000000..a12618b7d1 --- /dev/null +++ b/common/src/sgx_sha256_128.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_sha256_128.h" + +/* +** SHA256-128 implementation: +** out-length := x ¨C number of bits to output +** prefix := SHA-256(out-length) +** digest := SHA-256(prefix || m) +** output := truncate(digest, out-length) ? always return first out-length bits +*/ +sgx_status_t SGXAPI sgx_sha256_128_msg(const uint8_t *p_src, uint32_t src_len, sgx_sha256_128_hash_t *p_hash) +{ + uint32_t outlength = 128; /*number of bits to output */ + uint32_t sha256_128_digest_length; + sgx_status_t ret; + sgx_sha256_hash_t digest = {0}; + uint8_t* digest_buffer = NULL; + + /* check potential overflow and NULL pointer */ + if( (UINT32_MAX-src_len) < sizeof(sgx_sha256_hash_t) || !p_hash || !p_src) + return SGX_ERROR_INVALID_PARAMETER; + + sha256_128_digest_length = (uint32_t)sizeof(sgx_sha256_hash_t)+ src_len; + + digest_buffer = (uint8_t*)malloc(sha256_128_digest_length); + if(!digest_buffer) + return SGX_ERROR_OUT_OF_MEMORY; + memset(digest_buffer, 0, sha256_128_digest_length); + + /* get prefix := SHA-256(out-length) */ + ret = sgx_sha256_msg((const uint8_t*)&outlength, sizeof(uint32_t), (sgx_sha256_hash_t*)digest_buffer); + if(SGX_SUCCESS != ret) + goto clean_up; + + /* get digest := SHA-256(prefix || m) */ + memcpy(digest_buffer+sizeof(sgx_sha256_hash_t), p_src, src_len); /* copy m to digest_buffer */ + ret = sgx_sha256_msg((const uint8_t*)digest_buffer, sha256_128_digest_length, &digest); + if(SGX_SUCCESS != ret) + goto clean_up; + + /* output truncated hash + return the first 128 bits */ + memcpy(p_hash, &digest, sizeof(sgx_sha256_128_hash_t)); + +clean_up: + if(digest_buffer) + free(digest_buffer); + + return ret; +} diff --git a/download_prebuilt.sh b/download_prebuilt.sh new file mode 100755 index 0000000000..84533dd102 --- /dev/null +++ b/download_prebuilt.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +top_dir=`dirname $0` +out_dir=$top_dir/psw/ae/data/prebuilt +server_url=https://01.org/sites/default/files/downloads/intelr-software-guard-extensions-linux-os/sgxprebuilt-1.5.80.27216.tar +wget $server_url -P $out_dir +if [ $? -ne 0 ]; then + echo "Fail to download file $server_url" + exit -1 +fi +pushd $out_dir;tar -xf sgxprebuilt-1.5.80.27216.tar;rm -rf sgxprebuilt-1.5.80.27216.tar;popd diff --git a/external/crypto_px/Makefile b/external/crypto_px/Makefile new file mode 100644 index 0000000000..5c70a24ef6 --- /dev/null +++ b/external/crypto_px/Makefile @@ -0,0 +1,62 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +CFLAGS += $(ENCLAVE_CFLAGS) -D_PX +ifeq ($(ARCH), x86_64) + CFLAGS += -D_ARCH_EM64T +else + CFLAGS += -D_ARCH_IA32 +endif + +INC := -I./include \ + -I./sources/include \ + -I./sources/ippcp/src + +SRCS := $(wildcard ./sources/ippcp/src/*.c) +OBJS := $(SRCS:.c=.o) + +libcrypto_px.a: $(OBJS) + ar crv $@ $^ + +%.o :%.c + $(CC) -c $(INC) $(CFLAGS) $< -o $@ + +.PHONY: all +all: libcrypto_px.a + +.PHONY: clean +clean: + @$(RM) $(OBJS) libcrypto_px.a + +.PHONY: rebuild +rebuild: clean all diff --git a/external/crypto_px/include/ippbase.h b/external/crypto_px/include/ippbase.h new file mode 100755 index 0000000000..fdcd79e2c6 --- /dev/null +++ b/external/crypto_px/include/ippbase.h @@ -0,0 +1,195 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifndef __IPPBASE_H__ +#define __IPPBASE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined( _WIN32 ) || defined ( _WIN64 ) + #define __STDCALL __stdcall + #define __CDECL __cdecl + #define __INT64 __int64 + #define __UINT64 unsigned __int64 +#else + #define __STDCALL + #define __CDECL + #define __INT64 long long + #define __UINT64 unsigned long long +#endif + +#define IPP_PI ( 3.14159265358979323846 ) /* ANSI C does not support M_PI */ +#define IPP_2PI ( 6.28318530717958647692 ) /* 2*pi */ +#define IPP_PI2 ( 1.57079632679489661923 ) /* pi/2 */ +#define IPP_PI4 ( 0.78539816339744830961 ) /* pi/4 */ +#define IPP_PI180 ( 0.01745329251994329577 ) /* pi/180 */ +#define IPP_RPI ( 0.31830988618379067154 ) /* 1/pi */ +#define IPP_SQRT2 ( 1.41421356237309504880 ) /* sqrt(2) */ +#define IPP_SQRT3 ( 1.73205080756887729353 ) /* sqrt(3) */ +#define IPP_LN2 ( 0.69314718055994530942 ) /* ln(2) */ +#define IPP_LN3 ( 1.09861228866810969139 ) /* ln(3) */ +#define IPP_E ( 2.71828182845904523536 ) /* e */ +#define IPP_RE ( 0.36787944117144232159 ) /* 1/e */ +#define IPP_EPS23 ( 1.19209289e-07f ) +#define IPP_EPS52 ( 2.2204460492503131e-016 ) + +#define IPP_MAX_8U ( 0xFF ) +#define IPP_MAX_16U ( 0xFFFF ) +#define IPP_MAX_32U ( 0xFFFFFFFF ) +#define IPP_MIN_8U ( 0 ) +#define IPP_MIN_16U ( 0 ) +#define IPP_MIN_32U ( 0 ) +#define IPP_MIN_8S (-128 ) +#define IPP_MAX_8S ( 127 ) +#define IPP_MIN_16S (-32768 ) +#define IPP_MAX_16S ( 32767 ) +#define IPP_MIN_32S (-2147483647 - 1 ) +#define IPP_MAX_32S ( 2147483647 ) +#define IPP_MIN_64U ( 0 ) + +#if defined( _WIN32 ) || defined ( _WIN64 ) + #define IPP_MAX_64S ( 9223372036854775807i64 ) + #define IPP_MIN_64S (-9223372036854775807i64 - 1 ) + #define IPP_MAX_64U ( 0xffffffffffffffffL ) /* 18446744073709551615 */ +#else + #define IPP_MAX_64S ( 9223372036854775807LL ) + #define IPP_MIN_64S (-9223372036854775807LL - 1 ) + #define IPP_MAX_64U ( 0xffffffffffffffffLL ) /* 18446744073709551615 */ +#endif + +#define IPP_MINABS_32F ( 1.175494351e-38f ) +#define IPP_MAXABS_32F ( 3.402823466e+38f ) +#define IPP_EPS_32F ( 1.192092890e-07f ) +#define IPP_MINABS_64F ( 2.2250738585072014e-308 ) +#define IPP_MAXABS_64F ( 1.7976931348623158e+308 ) +#define IPP_EPS_64F ( 2.2204460492503131e-016 ) + +#define IPP_MAX( a, b ) ( ((a) > (b)) ? (a) : (b) ) +#define IPP_MIN( a, b ) ( ((a) < (b)) ? (a) : (b) ) + +#define IPP_ABS( a ) ( ((a) < 0) ? (-(a)) : (a) ) + +typedef struct { + int major; /* e.g. 1 */ + int minor; /* e.g. 2 */ + int majorBuild; /* e.g. 3 */ + int build; /* e.g. 10, always >= majorBuild */ + char targetCpu[4]; /* corresponding to Intel(R) processor */ + const char* Name; /* e.g. "ippsw7" */ + const char* Version; /* e.g. "v1.2 Beta" */ + const char* BuildDate; /* e.g. "Jul 20 99" */ +} IppLibraryVersion; + +typedef unsigned char Ipp8u; +typedef unsigned short Ipp16u; +typedef unsigned int Ipp32u; +typedef signed char Ipp8s; +typedef signed short Ipp16s; +typedef signed int Ipp32s; +typedef float Ipp32f; +typedef __INT64 Ipp64s; +typedef __UINT64 Ipp64u; +typedef double Ipp64f; +typedef Ipp16s Ipp16f; + +typedef struct { + Ipp8s re; + Ipp8s im; +} Ipp8sc; + +typedef struct { + Ipp16s re; + Ipp16s im; +} Ipp16sc; + +typedef struct { + Ipp16u re; + Ipp16u im; +} Ipp16uc; + +typedef struct { + Ipp32s re; + Ipp32s im; +} Ipp32sc; + +typedef struct { + Ipp32f re; + Ipp32f im; +} Ipp32fc; + +typedef struct { + Ipp64s re; + Ipp64s im; +} Ipp64sc; + +typedef struct { + Ipp64f re; + Ipp64f im; +} Ipp64fc; + +typedef enum { + ippUndef = -1, + ipp1u = 0, + ipp8u = 1, + ipp8uc = 2, + ipp8s = 3, + ipp8sc = 4, + ipp16u = 5, + ipp16uc = 6, + ipp16s = 7, + ipp16sc = 8, + ipp32u = 9, + ipp32uc = 10, + ipp32s = 11, + ipp32sc = 12, + ipp32f = 13, + ipp32fc = 14, + ipp64u = 15, + ipp64uc = 16, + ipp64s = 17, + ipp64sc = 18, + ipp64f = 19, + ipp64fc = 20 +} IppDataType; + +typedef enum { + ippFalse = 0, + ippTrue = 1 +} IppBool; + +#ifdef __cplusplus +} +#endif + +#endif /* __IPPBASE_H__ */ + diff --git a/external/crypto_px/include/ippcore.h b/external/crypto_px/include/ippcore.h new file mode 100755 index 0000000000..e4bc012bc6 --- /dev/null +++ b/external/crypto_px/include/ippcore.h @@ -0,0 +1,395 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined( __IPPCORE_H__ ) || defined( _OWN_BLDPCS ) +#define __IPPCORE_H__ + +#if defined (_WIN32_WCE) && defined (_M_IX86) && defined (__stdcall) + #define _IPP_STDCALL_CDECL + #undef __stdcall +#endif + +#ifndef __IPPDEFS_H__ + #include "ippdefs.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +#if !defined( _IPP_NO_DEFAULT_LIB ) + #if defined( _IPP_SEQUENTIAL_DYNAMIC ) + #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcore" ) + #elif defined( _IPP_SEQUENTIAL_STATIC ) + #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcoremt" ) + #elif defined( _IPP_PARALLEL_DYNAMIC ) + #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcore" ) + #elif defined( _IPP_PARALLEL_STATIC ) + #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcoremt" ) + #endif +#endif + +/* ///////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// Functions declarations +//////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippGetLibVersion +// Purpose: getting of the library version +// Returns: the structure of information about version +// of ippcore library +// Parameters: +// +// Notes: not necessary to release the returned structure +*/ +IPPAPI( const IppLibraryVersion*, ippGetLibVersion, (void) ) + + +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippGetStatusString +// Purpose: convert the library status code to a readable string +// Parameters: +// StsCode IPP status code +// Returns: pointer to string describing the library status code +// +// Notes: don't free the pointer +*/ +IPPAPI( const char*, ippGetStatusString, ( IppStatus StsCode ) ) + + + +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippGetCpuClocks +// Purpose: reading of time stamp counter (TSC) register value +// Returns: TSC value +// +// Note: An hardware exception is possible if TSC reading is not supported by +/ the current chipset +*/ + +IPPAPI( Ipp64u, ippGetCpuClocks, (void) ) + + +/* /////////////////////////////////////////////////////////////////////////// +// Names: ippSetFlushToZero, +// ippSetDenormAreZero. +// +// Purpose: ippSetFlushToZero enables or disables the flush-to-zero mode, +// ippSetDenormAreZero enables or disables the denormals-are-zeros +// mode. +// +// Arguments: +// value - !0 or 0 - set or clear the corresponding bit of MXCSR +// pUMask - pointer to user store current underflow exception mask +// ( may be NULL if don't want to store ) +// +// Return: +// ippStsNoErr - Ok +// ippStsCpuNotSupportedErr - the mode is not supported +*/ + +IPPAPI( IppStatus, ippSetFlushToZero, ( int value, unsigned int* pUMask )) +IPPAPI( IppStatus, ippSetDenormAreZeros, ( int value )) + + + +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippAlignPtr +// Purpose: pointer aligning +// Returns: aligned pointer +// +// Parameter: +// ptr - pointer +// alignBytes - number of bytes to align +// +*/ +IPPAPI( void*, ippAlignPtr, ( void * ptr, int alignBytes ) ) + +/* ///////////////////////////////////////////////////////////////////////////// +// Functions to allocate and free memory +///////////////////////////////////////////////////////////////////////////// */ +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippMalloc +// Purpose: 64-byte aligned memory allocation +// Parameter: +// len number of bytes +// Returns: pointer to allocated memory +// +// Notes: the memory allocated by ippMalloc has to be free by ippFree +// function only. +*/ + +IPPAPI( void*, ippMalloc, (int length) ) + + +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippFree +// Purpose: free memory allocated by the ippMalloc function +// Parameter: +// ptr pointer to the memory allocated by the ippMalloc function +// +// Notes: use the function to free memory allocated by ippMalloc +*/ +IPPAPI( void, ippFree, (void* ptr) ) + + + +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippInit +// Purpose: Automatic switching to best for current cpu library code using. +// Returns: +// ippStsNoErr +// +// Parameter: nothing +// +// Notes: At the moment of this function execution no any other IPP function +// has to be working +*/ +IPPAPI( IppStatus, ippInit, ( void )) + + +/* //////////////////////////////////////////////////////////////////////////// +// Name: ippGetCpuFreqMhz +// +// Purpose: the function estimates cpu frequency and returns +// its value in MHz as a integer +// +// Return: +// ippStsNoErr Ok +// ippStsNullPtrErr null pointer to the freq value +// ippStsSizeErr wrong num of tries, internal var +// Arguments: +// pMhz pointer to the integer to write +// cpu freq value estimated +// +// Notes: no exact value is guaranteed, the value could +// vary with cpu workloading +*/ + +IPPAPI(IppStatus, ippGetCpuFreqMhz, ( int* pMhz ) ) + +/* //////////////////////////////////////////////////////////////////////////// +// Name: ippSetNumThreads +// +// Purpose: +// +// Return: +// ippStsNoErr Ok +// ippStsNoOperation For static library internal threading is not supported +// ippStsSizeErr Desired number of threads less or equal zero +// +// Arguments: +// numThr Desired number of threads +*/ +IPPAPI( IppStatus, ippSetNumThreads, ( int numThr ) ) + +/* //////////////////////////////////////////////////////////////////////////// +// Name: ippGetNumThreads +// +// Purpose: +// +// Return: +// ippStsNoErr Ok +// ippStsNullPtrErr Pointer to numThr is Null +// ippStsNoOperation For static library internal threading is not supported +// and return value is always == 1 +// +// Arguments: +// pNumThr Pointer to memory location where to store current numThr +*/ +IPPAPI( IppStatus, ippGetNumThreads, (int* pNumThr) ) + +/* //////////////////////////////////////////////////////////////////////////// +// Name: ippGetMaxCacheSizeB +// +// Purpose: Detects maximal from the sizes of L2 or L3 in bytes +// +// Return: +// ippStsNullPtrErr The result's pointer is NULL. +// ippStsNotSupportedCpu The cpu is not supported. +// ippStsUnknownCacheSize The cpu is supported, but the size of the cache is unknown. +// ippStsNoErr Ok +// +// Arguments: +// pSizeByte Pointer to the result +// +// Note: +// 1). Intel(R) processors are supported only. +// 2). Intel(R) Itanium(R) processors and platforms with Intel XScale(R) technology are unsupported +// 3). For unsupported processors the result is "0", +// and the return status is "ippStsNotSupportedCpu". +// 4). For supported processors the result is "0", +// and the return status is "ippStsUnknownCacheSize". +// if sizes of the cache is unknown. +// +*/ +IPPAPI( IppStatus, ippGetMaxCacheSizeB, ( int* pSizeByte ) ) + +/* +// Name: ippGetCpuFeatures +// Purpose: Detects CPU features. +// Parameters: +// pFeaturesMask Pointer to the features mask. +// Nonzero value of bit means the corresponding feature is supported. +// Features mask values are defined in the ippdefs.h +// [ 0] - MMX ( ippCPUID_MMX ) +// [ 1] - SSE ( ippCPUID_SSE ) +// [ 2] - SSE2 ( ippCPUID_SSE2 ) +// [ 3] - SSE3 ( ippCPUID_SSE3 ) +// [ 4] - SSSE3 ( ippCPUID_SSSE3 ) +// [ 5] - MOVBE ( ippCPUID_MOVBE ) +// [ 6] - SSE41 ( ippCPUID_SSE41 ) +// [ 7] - SSE42 ( ippCPUID_SSE42 ) +// [ 8] - AVX ( ippCPUID_AVX ) +// [ 9] - ENABLEDBYOS( ippAVX_ENABLEDBYOS ) +// [10] - AES ( ippCPUID_AES ) +// [11] - PCLMULQDQ ( ippCPUID_CLMUL ) +// [12] - ABR ( ippCPUID_ABR ) +// [13] - RDRAND ( ippCPUID_RDRAND ) +// [14] - F16C ( ippCPUID_F16C ) +// [15] - AVX2 ( ippCPUID_AVX2 ) +// [16] - ADOX/ADCX ( ippCPUID_ADCOX ) ADCX and ADOX instructions +// [17] - RDSEED ( ippCPUID_RDSEED ) The RDSEED instruction +// [18] - PREFETCHW ( ippCPUID_PREFETCHW ) The PREFETCHW instruction +// [19] - SHA ( ippCPUID_SHA ) Intel (R) SHA Extensions +// [20:63] - Reserved +// +// pCpuidInfoRegs Pointer to the 4-element vector. +// Result of CPUID.1 are stored in this vector. +// [0] - register EAX +// [1] - register EBX +// [2] - register ECX +// [3] - register EDX +// If pointer pCpuidInfoRegs is set to NULL, registers are not stored. +// +// Returns: +// ippStsNullPtrErr The pointer to the features mask (pFeaturesMask) is NULL. +// ippStsNotSupportedCpu CPU is not supported. +// ippStsNoErr Ok +// +// Note: Only IA-32 and Intel(R) 64 are supported +*/ +IPPAPI( IppStatus, ippGetCpuFeatures, ( Ipp64u* pFeaturesMask, + Ipp32u pCpuidInfoRegs[4] ) ) + +/* +// Name: ippGetEnabledCpuFeatures +// Purpose: Detects enabled features for loaded libraries +// Returns: Features mask +// Features mask values are defined in the ippdefs.h +// [ 0] - ippCPUID_MMX +// [ 1] - ippCPUID_SSE +// [ 2] - ippCPUID_SSE2 +// [ 3] - ippCPUID_SSE3 +// [ 4] - ippCPUID_SSSE3 +// [ 5] - ippCPUID_MOVBE +// [ 6] - ippCPUID_SSE41 +// [ 7] - ippCPUID_SSE42 +// [ 8] - ippCPUID_AVX +// [ 9] - ippAVX_ENABLEDBYOS +// [10] - ippCPUID_AES +// [11] - ippCPUID_CLMUL +// [12] - ippCPUID_ABR +// [13] - ippCPUID_RDRAND +// [14] - ippCPUID_F16C +// [15] - ippCPUID_AVX2 +// [16] - ippCPUID_ADCOX +// [17] - ippCPUID_RDSEED +// [18] - ippCPUID_PREFETCHW +// [19] - ippCPUID_SHA +// [20:63] - Reserved +// +*/ +IPPAPI( Ipp64u, ippGetEnabledCpuFeatures, ( void ) ) + +/* //////////////////////////////////////////////////////////////////////////// +// Name: ippSetCpuFeatures +// +// Purpose: Changes the set of enabled/disabled CPU features. +// This function sets the processor-specific code of the Intel IPP +// library according to the processor features specified in cpuFeatures. +// +// Return: +// ippStsNoErr No errors. +// Warnings: +// ippStsFeatureNotSupported Current CPU doesn't support at least 1 of the +// desired features; +// ippStsUnknownFeature At least one of the desired features is unknown; +// ippStsFeaturesCombination Wrong combination of features; +// ippStsCpuMismatch Indicates that the specified processor features +// are not valid. Previously set code is used. +// +// Arguments: +// cpuFeatures Desired features to support by the library +// (see ippdefs.h for ippCPUID_XX definition) +// +// NOTE: this function can re-initializes dispatcher and after the +// call another library (letter) may work +// CAUTION: At the moment of this function excecution no any other IPP +// function has to be working +// +// The next pre-defined sets of features can be used: +// 32-bit code: +// #define PX_FM ( ippCPUID_MMX | ippCPUID_SSE ) +// #define W7_FM ( PX_FM | ippCPUID_SSE2 ) +// #define V8_FM ( W7_FM | ippCPUID_SSE3 | ippCPUID_SSSE3 ) +// #define S8_FM ( V8_FM | ippCPUID_MOVBE ) +// #define P8_FM ( V8_FM | ippCPUID_SSE41 | ippCPUID_SSE42 | ippCPUID_AES | ippCPUID_CLMUL | ippCPUID_SHA ) +// #define G9_FM ( P8_FM | ippCPUID_AVX | ippAVX_ENABLEDBYOS | ippCPUID_RDRAND | ippCPUID_F16C ) +// #define H9_FM ( G9_FM | ippCPUID_AVX2 | ippCPUID_MOVBE | ippCPUID_ADCOX | ippCPUID_RDSEED | ippCPUID_PREFETCHW ) +// +// 64-bit code: +// #define PX_FM ( ippCPUID_MMX | ippCPUID_SSE | ippCPUID_SSE2 ) +// #define M7_FM ( PX_FM | ippCPUID_SSE3 ) +// #define N8_FM ( S8_FM ) +// #define U8_FM ( V8_FM ) +// #define Y8_FM ( P8_FM ) +// #define E9_FM ( G9_FM ) +// #define L9_FM ( H9_FM ) +// +*/ + +IPPAPI( IppStatus, ippSetCpuFeatures,( Ipp64u cpuFeatures )) + +#if defined (_IPP_STDCALL_CDECL) + #undef _IPP_STDCALL_CDECL + #define __stdcall __cdecl +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __IPPCORE_H__ */ diff --git a/external/crypto_px/include/ippcp.h b/external/crypto_px/include/ippcp.h new file mode 100755 index 0000000000..07d92d52b5 --- /dev/null +++ b/external/crypto_px/include/ippcp.h @@ -0,0 +1,327 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined( __IPPCP_H__ ) || defined( _OWN_BLDPCS ) +#define __IPPCP_H__ + + +#if defined (_WIN32_WCE) && defined (_M_IX86) && defined (__stdcall) + #define _IPP_STDCALL_CDECL + #undef __stdcall +#endif + + +#ifndef __IPPDEFS_H__ + #include "ippdefs.h" +#endif + +#ifndef __IPPCPDEFS_H__ + #include "ippcpdefs.h" +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ///////////////////////////////////////////////////////////////////////////// +// Name: ippcpGetLibVersion +// Purpose: getting of the library version +// Returns: the structure of information about version of ippCP library +// Parameters: +// +// Notes: not necessary to release the returned structure +*/ +IPPAPI( const IppLibraryVersion*, ippcpGetLibVersion, (void) ) + + +/* +// AES +*/ +IPPAPI(IppStatus, ippsAESGetSize,(int *pSize)) +IPPAPI(IppStatus, ippsAESInit,(const Ipp8u* pKey, int keyLen, IppsAESSpec* pCtx, int ctxSize)) + +/* AES-CTR */ +IPPAPI(IppStatus, ippsAESEncryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len, + const IppsAESSpec* pCtx, + Ipp8u* pCtrValue, int ctrNumBitSize)) +IPPAPI(IppStatus, ippsAESDecryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len, + const IppsAESSpec* pCtx, + Ipp8u* pCtrValue, int ctrNumBitSize)) + +/* AES-GCM */ +IPPAPI(IppStatus, ippsAES_GCMGetSize,(int * pSize)) +IPPAPI(IppStatus, ippsAES_GCMInit,(const Ipp8u* pKey, int keyLen, IppsAES_GCMState* pState, int ctxSize)) + +IPPAPI(IppStatus, ippsAES_GCMReset,(IppsAES_GCMState* pState)) +IPPAPI(IppStatus, ippsAES_GCMProcessIV,(const Ipp8u* pIV, int ivLen, + IppsAES_GCMState* pState)) +IPPAPI(IppStatus, ippsAES_GCMProcessAAD,(const Ipp8u* pAAD, int ivAAD, + IppsAES_GCMState* pState)) +IPPAPI(IppStatus, ippsAES_GCMStart,(const Ipp8u* pIV, int ivLen, + const Ipp8u* pAAD, int aadLen, + IppsAES_GCMState* pState)) +IPPAPI(IppStatus, ippsAES_GCMEncrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_GCMState* pState)) +IPPAPI(IppStatus, ippsAES_GCMDecrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_GCMState* pState)) +IPPAPI(IppStatus, ippsAES_GCMGetTag,(Ipp8u* pDstTag, int tagLen, const IppsAES_GCMState* pState)) + +/* AES-CMAC */ +IPPAPI(IppStatus, ippsAES_CMACGetSize,(int* pSize)) +IPPAPI(IppStatus, ippsAES_CMACInit,(const Ipp8u* pKey, int keyLen, IppsAES_CMACState* pState, int ctxSize)) + +IPPAPI(IppStatus, ippsAES_CMACUpdate,(const Ipp8u* pSrc, int len, IppsAES_CMACState* pState)) +IPPAPI(IppStatus, ippsAES_CMACFinal,(Ipp8u* pMD, int mdLen, IppsAES_CMACState* pState)) +IPPAPI(IppStatus, ippsAES_CMACGetTag,(Ipp8u* pMD, int mdLen, const IppsAES_CMACState* pState)) + +/* +// hash +*/ +IPPAPI(IppStatus, ippsHashGetSize,(int* pSize)) +IPPAPI(IppStatus, ippsHashInit,(IppsHashState* pCtx, IppHashAlgId hashAlg)) + +IPPAPI(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pCtx)) +IPPAPI(IppStatus, ippsHashGetTag,(Ipp8u* pMD, int tagLen, const IppsHashState* pCtx)) +IPPAPI(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pCtx)) +IPPAPI(IppStatus, ippsHashMessage,(const Ipp8u* pMsg, int len, Ipp8u* pMD, IppHashAlgId hashAlg)) + +IPPAPI(IppStatus, ippsMGF,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, IppHashAlgId hashAlg)) + +IPPAPI(IppStatus, ippsHMAC_GetSize,(int* pSize)) +IPPAPI(IppStatus, ippsHMAC_Init,(const Ipp8u* pKey, int keyLen, IppsHMACState* pCtx, IppHashAlgId hashAlg)) + +IPPAPI(IppStatus, ippsHMAC_Update,(const Ipp8u* pSrc, int len, IppsHMACState* pCtx)) +IPPAPI(IppStatus, ippsHMAC_Final,(Ipp8u* pMD, int mdLen, IppsHMACState* pCtx)) +IPPAPI(IppStatus, ippsHMAC_GetTag,(Ipp8u* pMD, int mdLen, const IppsHMACState* pCtx)) +IPPAPI(IppStatus, ippsHMAC_Message,(const Ipp8u* pMsg, int msgLen, + const Ipp8u* pKey, int keyLen, + Ipp8u* pMD, int mdLen, + IppHashAlgId hashAlg)) + +/* +// Big Number Integer Arithmetic +*/ +IPPAPI(IppStatus, ippsBigNumGetSize,(int length, int* pSize)) +IPPAPI(IppStatus, ippsBigNumInit,(int length, IppsBigNumState* pBN)) + +IPPAPI(IppStatus, ippsSet_BN,(IppsBigNumSGN sgn, + int length, const Ipp32u* pData, + IppsBigNumState* pBN)) +IPPAPI(IppStatus, ippsRef_BN,(IppsBigNumSGN* pSgn, int* bitSize, Ipp32u** const ppData, + const IppsBigNumState* pBN)) + +IPPAPI(IppStatus, ippsAdd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) +IPPAPI(IppStatus, ippsSub_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) +IPPAPI(IppStatus, ippsMod_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR)) +IPPAPI(IppStatus, ippsModInv_BN,(IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pInv)) +IPPAPI(IppStatus, ippsDiv_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pQ, IppsBigNumState* pR)) +IPPAPI(IppStatus, ippsCmpZero_BN,(const IppsBigNumState* pBN, Ipp32u* pResult)) +IPPAPI(IppStatus, ippsCmp_BN,(const IppsBigNumState* pA, const IppsBigNumState* pB, Ipp32u* pResult)) +IPPAPI(IppStatus, ippsMul_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) +IPPAPI(IppStatus, ippsGcd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pGCD)) + +IPPAPI(IppStatus, ippsSetOctString_BN,(const Ipp8u* pStr, int strLen, IppsBigNumState* pBN)) +IPPAPI(IppStatus, ippsGetOctString_BN,(Ipp8u* pStr, int strLen, const IppsBigNumState* pBN)) + +/* +// Montgomery Operations +*/ +IPPAPI(IppStatus, ippsMontGetSize,(IppsExpMethod method, int length, int* pSize)) +IPPAPI(IppStatus, ippsMontInit,(IppsExpMethod method, int length, IppsMontState* pCtx)) +IPPAPI(IppStatus, ippsMontSet,(const Ipp32u* pModulo, int size, IppsMontState* pCtx)) +IPPAPI(IppStatus, ippsMontMul, (const IppsBigNumState* pA, const IppsBigNumState* pB, IppsMontState* m, IppsBigNumState* pR)) + +/* +// PRNG +*/ +IPPAPI(IppStatus, ippsPRNGGetSize,(int* pSize)) +IPPAPI(IppStatus, ippsPRNGInit, (int seedBits, IppsPRNGState* pCtx)) +IPPAPI(IppStatus, ippsPRNGen, (Ipp32u* pRand, int nBits, void* pCtx)) + +/* +// Prime Number Generation +*/ +IPPAPI(IppStatus, ippsPrimeGetSize,(int nMaxBits, int* pSize)) +IPPAPI(IppStatus, ippsPrimeInit, (int nMaxBits, IppsPrimeState* pCtx)) + + +/* +// RSA +*/ +IPPAPI(IppStatus, ippsRSA_GetSizePublicKey,(int rsaModulusBitSize, int pubicExpBitSize, int* pKeySize)) +IPPAPI(IppStatus, ippsRSA_InitPublicKey,(int rsaModulusBitSize, int publicExpBitSize, + IppsRSAPublicKeyState* pKey, int keyCtxSize)) +IPPAPI(IppStatus, ippsRSA_SetPublicKey,(const IppsBigNumState* pModulus, + const IppsBigNumState* pPublicExp, + IppsRSAPublicKeyState* pKey)) +IPPAPI(IppStatus, ippsRSA_GetPublicKey,(IppsBigNumState* pModulus, + IppsBigNumState* pPublicExp, + const IppsRSAPublicKeyState* pKey)) + +IPPAPI(IppStatus, ippsRSA_GetSizePrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize, int* pKeySize)) +IPPAPI(IppStatus, ippsRSA_InitPrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize, + IppsRSAPrivateKeyState* pKey, int keyCtxSize)) +IPPAPI(IppStatus, ippsRSA_SetPrivateKeyType1,(const IppsBigNumState* pModulus, + const IppsBigNumState* pPrivateExp, + IppsRSAPrivateKeyState* pKey)) + +IPPAPI(IppStatus, ippsRSA_GetSizePrivateKeyType2,(int factorPbitSize, int factorQbitSize, int* pKeySize)) +IPPAPI(IppStatus, ippsRSA_InitPrivateKeyType2,(int factorPbitSize, int factorQbitSize, + IppsRSAPrivateKeyState* pKey, int keyCtxSize)) +IPPAPI(IppStatus, ippsRSA_SetPrivateKeyType2,(const IppsBigNumState* pFactorP, + const IppsBigNumState* pFactorQ, + const IppsBigNumState* pCrtExpP, + const IppsBigNumState* pCrtExpQ, + const IppsBigNumState* pInverseQ, + IppsRSAPrivateKeyState* pKey)) + +IPPAPI(IppStatus, ippsRSA_GetBufferSizePublicKey,(int* pBufferSize, const IppsRSAPublicKeyState* pKey)) +IPPAPI(IppStatus, ippsRSA_GetBufferSizePrivateKey,(int* pBufferSize, const IppsRSAPrivateKeyState* pKey)) + +IPPAPI(IppStatus, ippsRSA_Encrypt,(const IppsBigNumState* pPtxt, + IppsBigNumState* pCtxt, + const IppsRSAPublicKeyState* pKey, + Ipp8u* pScratchBuffer)) +IPPAPI(IppStatus, ippsRSA_Decrypt,(const IppsBigNumState* pCtxt, + IppsBigNumState* pPtxt, + const IppsRSAPrivateKeyState* pKey, + Ipp8u* pScratchBuffer)) + +IPPAPI(IppStatus, ippsRSA_ValidateKeys,(int* pResult, + const IppsRSAPublicKeyState* pPublicKey, + const IppsRSAPrivateKeyState* pPrivateKeyType2, + const IppsRSAPrivateKeyState* pPrivateKeyType1, + Ipp8u* pScratchBuffer, + int nTrials, + IppsPrimeState* pPrimeGen, + IppBitSupplier rndFunc, void* pRndParam)) + +/* encryption scheme: RSAES-OAEP */ +IPPAPI(IppStatus, ippsRSAEncrypt_OAEP,(const Ipp8u* pSrc, int srcLen, + const Ipp8u* pLabel, int labLen, + const Ipp8u* pSeed, + Ipp8u* pDst, + const IppsRSAPublicKeyState* pKey, + IppHashAlgId hashAlg, + Ipp8u* pBuffer)) +IPPAPI(IppStatus, ippsRSA_OAEPEncrypt_SHA256,(const Ipp8u* pSrc, int srcLen, + const Ipp8u* pLabel, int labLen, + const Ipp8u* pSeed, + Ipp8u* pDst, + const IppsRSAPublicKeyState* pKey, + Ipp8u* pBuffer)) + +/* signature scheme : RSA-SSA-PKCS1-v1_5 */ +IPPAPI(IppStatus, ippsRSASign_PKCS1v15,(const Ipp8u* pMsg, int msgLen, + Ipp8u* pSign, + const IppsRSAPrivateKeyState* pPrvKey, + const IppsRSAPublicKeyState* pPubKey, + IppHashAlgId hashAlg, + Ipp8u* pBuffer)) + + +IPPAPI(IppStatus, ippsRSAVerify_PKCS1v15,(const Ipp8u* pMsg, int msgLen, + const Ipp8u* pSign, int* pIsValid, + const IppsRSAPublicKeyState* pKey, + IppHashAlgId hashAlg, + Ipp8u* pBuffer)) + + +/* +// EC Cryptography +*/ +IPPAPI(IppStatus, ippsECCPGetSize,(int feBitSize, int* pSize)) +IPPAPI(IppStatus, ippsECCPInit,(int feBitSize, IppsECCPState* pECC)) + +IPPAPI(IppStatus, ippsECCPSet,(const IppsBigNumState* pPrime, + const IppsBigNumState* pA, const IppsBigNumState* pB, + const IppsBigNumState* pGX,const IppsBigNumState* pGY,const IppsBigNumState* pOrder, + int cofactor, + IppsECCPState* pECC)) + +IPPAPI(IppStatus, ippsECCPSetStd,(IppECCType flag, IppsECCPState* pECC)) + + +IPPAPI(IppStatus, ippsECCPPointGetSize,(int feBitSize, int* pSize)) +IPPAPI(IppStatus, ippsECCPPointInit,(int feBitSize, IppsECCPPointState* pPoint)) + +IPPAPI(IppStatus, ippsECCPSetPoint,(const IppsBigNumState* pX, const IppsBigNumState* pY, + IppsECCPPointState* pPoint, IppsECCPState* pECC)) +IPPAPI(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint, IppsECCPState* pECC)) + +IPPAPI(IppStatus, ippsECCPGetPoint,(IppsBigNumState* pX, IppsBigNumState* pY, + const IppsECCPPointState* pPoint, IppsECCPState* pECC)) + +IPPAPI(IppStatus, ippsECCPCheckPoint,(const IppsECCPPointState* pP, + IppECResult* pResult, IppsECCPState* pECC)) +IPPAPI(IppStatus, ippsECCPComparePoint,(const IppsECCPPointState* pP, const IppsECCPPointState* pQ, + IppECResult* pResult, IppsECCPState* pECC)) +IPPAPI(IppStatus, ippsECCPNegativePoint,(const IppsECCPPointState* pP, + IppsECCPPointState* pR, IppsECCPState* pECC)) +IPPAPI(IppStatus, ippsECCPAddPoint,(const IppsECCPPointState* pP, const IppsECCPPointState* pQ, + IppsECCPPointState* pR, IppsECCPState* pECC)) +IPPAPI(IppStatus, ippsECCPMulPointScalar,(const IppsECCPPointState* pP, const IppsBigNumState* pK, + IppsECCPPointState* pR, IppsECCPState* pECC)) + +IPPAPI(IppStatus, ippsECCPGenKeyPair,(IppsBigNumState* pPrivate, IppsECCPPointState* pPublic, + IppsECCPState* pECC, + IppBitSupplier rndFunc, void* pRndParam)) +IPPAPI(IppStatus, ippsECCPPublicKey,(const IppsBigNumState* pPrivate, + IppsECCPPointState* pPublic, + IppsECCPState* pECC)) +IPPAPI(IppStatus, ippsECCPSetKeyPair,(const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic, + IppBool regular, + IppsECCPState* pECC)) + +IPPAPI(IppStatus, ippsECCPSharedSecretDH,(const IppsBigNumState* pPrivateA, + const IppsECCPPointState* pPublicB, + IppsBigNumState* pShare, + IppsECCPState* pECC)) + +IPPAPI(IppStatus, ippsECCPSignDSA,(const IppsBigNumState* pMsgDigest, + const IppsBigNumState* pPrivate, + IppsBigNumState* pSignX, IppsBigNumState* pSignY, + IppsECCPState* pECC)) +IPPAPI(IppStatus, ippsECCPVerifyDSA,(const IppsBigNumState* pMsgDigest, + const IppsBigNumState* pSignX, const IppsBigNumState* pSignY, + IppECResult* pResult, + IppsECCPState* pECC)) + +#ifdef __cplusplus +} +#endif + +#if defined (_IPP_STDCALL_CDECL) + #undef _IPP_STDCALL_CDECL + #define __stdcall __cdecl +#endif + +#endif /* __IPPCP_H__ */ diff --git a/external/crypto_px/include/ippcpdefs.h b/external/crypto_px/include/ippcpdefs.h new file mode 100755 index 0000000000..c86ee0f3ed --- /dev/null +++ b/external/crypto_px/include/ippcpdefs.h @@ -0,0 +1,211 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifndef __IPPCPDEFS_H__ +#define __IPPCPDEFS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +// AES +*/ +#define IPP_AES_BLOCK_BITSIZE (128) /* cipher blocksizes (bits) */ + +typedef enum { /* cipher keysizes (bits) */ + ippRijndaelKey128 = 128, IppsRijndaelKey128 = 128, /* 128-bit key */ + ippRijndaelKey192 = 192, IppsRijndaelKey192 = 192, /* 192-bit key */ + ippRijndaelKey256 = 256, IppsRijndaelKey256 = 256 /* 256-bit key */ +} IppsRijndaelKeyLength; + +typedef struct _cpRijndael128 IppsAESSpec; +typedef struct _cpAES_GCM IppsAES_GCMState; +typedef struct _cpAES_CMAC IppsAES_CMACState; + + +/* +// hash +*/ +typedef enum { + ippHashAlg_Unknown, + ippHashAlg_SHA1, + ippHashAlg_SHA256, + ippHashAlg_SHA224, + ippHashAlg_SHA512, + ippHashAlg_SHA384, + ippHashAlg_MD5, + ippHashAlg_SHA512_224, + ippHashAlg_SHA512_256, + ippHashAlg_MaxNo +} IppHashAlgId; + +#define IPP_ALG_HASH_UNKNOWN (ippHashAlg_Unknown) /* unknown */ +#define IPP_ALG_HASH_SHA1 (ippHashAlg_SHA1) /* SHA1 */ +#define IPP_ALG_HASH_SHA256 (ippHashAlg_SHA256) /* SHA256 */ +#define IPP_ALG_HASH_SHA224 (ippHashAlg_SHA224) /* SHA224 or SHA256/224 */ +#define IPP_ALG_HASH_SHA512 (ippHashAlg_SHA512) /* SHA512 */ +#define IPP_ALG_HASH_SHA384 (ippHashAlg_SHA384) /* SHA384 or SHA512/384 */ +#define IPP_ALG_HASH_MD5 (ippHashAlg_MD5) /* MD5 */ +#define IPP_ALG_HASH_SHA512_224 (ippHashAlg_SHA512_224) /* SHA512/224 */ +#define IPP_ALG_HASH_SHA512_256 (ippHashAlg_SHA512_256) /* SHA512/256 */ +#define IPP_ALG_HASH_LIMIT (ippHashAlg_MaxNo) /* hash alg limiter*/ + +#define IPP_SHA1_DIGEST_BITSIZE 160 /* digest size (bits) */ +#define IPP_SHA256_DIGEST_BITSIZE 256 +#define IPP_SHA224_DIGEST_BITSIZE 224 +#define IPP_SHA384_DIGEST_BITSIZE 384 +#define IPP_SHA512_DIGEST_BITSIZE 512 +#define IPP_MD5_DIGEST_BITSIZE 128 +#define IPP_SHA512_224_DIGEST_BITSIZE 224 +#define IPP_SHA512_256_DIGEST_BITSIZE 256 + +typedef struct _cpHashCtx IppsHashState; +typedef struct _cpHMAC IppsHMACState; + + +/* +// Big Number Integer Arithmetic +*/ +#define BN_MAXBITSIZE (16*1024) /* bn max size (bits) */ + +/* operation results */ +#define IPP_IS_EQ (0) +#define IPP_IS_GT (1) +#define IPP_IS_LT (2) +#define IPP_IS_NE (3) +#define IPP_IS_NA (4) + +#define IPP_IS_PRIME (5) +#define IPP_IS_COMPOSITE (6) + +#define IPP_IS_VALID (7) +#define IPP_IS_INVALID (8) +#define IPP_IS_INCOMPLETE (9) +#define IPP_IS_ATINFINITY (10) + +#define IS_ZERO IPP_IS_EQ +#define GREATER_THAN_ZERO IPP_IS_GT +#define LESS_THAN_ZERO IPP_IS_LT +#define IS_PRIME IPP_IS_PRIME +#define IS_COMPOSITE IPP_IS_COMPOSITE +#define IS_VALID_KEY IPP_IS_VALID +#define IS_INVALID_KEY IPP_IS_INVALID +#define IS_INCOMPLETED_KEY IPP_IS_INCOMPLETE + +typedef enum { + ippBigNumNEG = 0, IppsBigNumNEG = 0, + ippBigNumPOS = 1, IppsBigNumPOS = 1 +} IppsBigNumSGN; + +typedef enum { + ippBinaryMethod = 0, IppsBinaryMethod = 0, + ippSlidingWindows = 1, IppsSlidingWindows = 1 +} IppsExpMethod; + +typedef struct _cpBigNum IppsBigNumState; +typedef struct _cpMontgomery IppsMontState; +typedef struct _cpPRNG IppsPRNGState; +typedef struct _cpPrime IppsPrimeState; + +/* External Bit Supplier */ +typedef IppStatus (__STDCALL *IppBitSupplier)(Ipp32u* pRand, int nBits, void* pEbsParams); + + +/* +// RSA +*/ +#define MIN_RSA_SIZE (8) +#define MAX_RSA_SIZE (4096) + +typedef struct _cpRSA IppsRSAState; +typedef struct _cpRSA_public_key IppsRSAPublicKeyState; +typedef struct _cpRSA_private_key IppsRSAPrivateKeyState; + + +/* +// EC Cryptography +*/ +#define EC_GFP_MAXBITSIZE (1024) + +typedef struct _cpECCP IppsECCPState; +typedef struct _cpECCPPoint IppsECCPPointState; + +/* operation result */ +typedef enum { + ippECValid, /* validation pass successfully */ + + ippECCompositeBase, /* field based on composite */ + ippECComplicatedBase, /* number of non-zero terms in the polynomial (> PRIME_ARR_MAX) */ + ippECIsZeroDiscriminant,/* zero discriminant */ + ippECCompositeOrder, /* composite order of base point */ + ippECInvalidOrder, /* invalid base point order */ + ippECIsWeakMOV, /* weak Meneze-Okamoto-Vanstone reduction attack */ + ippECIsWeakSSSA, /* weak Semaev-Smart,Satoh-Araki reduction attack */ + ippECIsSupersingular, /* supersingular curve */ + + ippECInvalidPrivateKey, /* !(0 < Private < order) */ + ippECInvalidPublicKey, /* (order*PublicKey != Infinity) */ + ippECInvalidKeyPair, /* (Private*BasePoint != PublicKey) */ + + ippECPointOutOfGroup, /* out of group (order*P != Infinity) */ + ippECPointIsAtInfinite, /* point (P=(Px,Py)) at Infinity */ + ippECPointIsNotValid, /* point (P=(Px,Py)) out-of EC */ + + ippECPointIsEqual, /* compared points are equal */ + ippECPointIsNotEqual, /* compared points are different */ + + ippECInvalidSignature /* invalid signature */ +} IppECResult; + +typedef enum { + ippECarbitrary =0x00000, IppECCArbitrary = 0x00000, /* arbitrary ECC */ + + ippECPstd = 0x10000, IppECCPStd = 0x10000, /* random (recommended) EC over FG(p): */ + ippECPstd112r1 = ippECPstd, IppECCPStd112r1 = IppECCPStd, /* secp112r1 curve */ + ippECPstd112r2 = ippECPstd+1, IppECCPStd112r2 = IppECCPStd+1, /* secp112r2 curve */ + ippECPstd128r1 = ippECPstd+2, IppECCPStd128r1 = IppECCPStd+2, /* secp128r1 curve */ + ippECPstd128r2 = ippECPstd+3, IppECCPStd128r2 = IppECCPStd+3, /* secp128r2 curve */ + ippECPstd160r1 = ippECPstd+4, IppECCPStd160r1 = IppECCPStd+4, /* secp160r1 curve */ + ippECPstd160r2 = ippECPstd+5, IppECCPStd160r2 = IppECCPStd+5, /* secp160r2 curve */ + ippECPstd192r1 = ippECPstd+6, IppECCPStd192r1 = IppECCPStd+6, /* secp192r1 curve */ + ippECPstd224r1 = ippECPstd+7, IppECCPStd224r1 = IppECCPStd+7, /* secp224r1 curve */ + ippECPstd256r1 = ippECPstd+8, IppECCPStd256r1 = IppECCPStd+8, /* secp256r1 curve */ + ippECPstd384r1 = ippECPstd+9, IppECCPStd384r1 = IppECCPStd+9, /* secp384r1 curve */ + ippECPstd521r1 = ippECPstd+10, IppECCPStd521r1 = IppECCPStd+10, /* secp521r1 curve */ +} IppsECType, IppECCType; + + +#ifdef __cplusplus +} +#endif + +#endif /* __IPPCPDEFS_H__ */ diff --git a/external/crypto_px/include/ippdefs.h b/external/crypto_px/include/ippdefs.h new file mode 100755 index 0000000000..4250bf24d4 --- /dev/null +++ b/external/crypto_px/include/ippdefs.h @@ -0,0 +1,129 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifndef __IPPDEFS_H__ +#define __IPPDEFS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#if defined (_WIN64) +#define _INTEL_PLATFORM "intel64/" +#elif defined (_WIN32) +#define _INTEL_PLATFORM "ia32/" +#endif + +#if !defined( IPPAPI ) + + #if defined( IPP_W32DLL ) && (defined( _WIN32 ) || defined( _WIN64 )) + #if defined( _MSC_VER ) || defined( __ICL ) + #define IPPAPI( type,name,arg ) \ + __declspec(dllimport) type __STDCALL name arg; + #else + #define IPPAPI( type,name,arg ) type __STDCALL name arg; + #endif + #else + #define IPPAPI( type,name,arg ) type __STDCALL name arg; + #endif + +#endif + +#if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER)) && !defined( _PCS ) && !defined( _PCS_GENSTUBS ) + #if( __INTEL_COMPILER >= 1100 ) /* icl 11.0 supports additional comment */ + #if( _MSC_VER >= 1400 ) + #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment )) + #else + #pragma message ("your icl version supports additional comment for deprecated functions but it can't be displayed") + #pragma message ("because internal _MSC_VER macro variable setting requires compatibility with MSVC7.1") + #pragma message ("use -Qvc8 switch for icl command line to see these additional comments") + #define IPP_DEPRECATED( comment ) __declspec( deprecated ) + #endif + #elif( _MSC_FULL_VER >= 140050727 )&&( !defined( __INTEL_COMPILER )) /* VS2005 supports additional comment */ + #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment )) + #elif( _MSC_VER <= 1200 )&&( !defined( __INTEL_COMPILER )) /* VS 6 doesn't support deprecation */ + #define IPP_DEPRECATED( comment ) + #else + #define IPP_DEPRECATED( comment ) __declspec( deprecated ) + #endif +#elif (defined(__ICC) || defined(__ECC) || defined( __GNUC__ )) && !defined( _PCS ) && !defined( _PCS_GENSTUBS ) + #if defined( __GNUC__ ) + #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5 + #define IPP_DEPRECATED( message ) __attribute__(( deprecated( message ))) + #else + #define IPP_DEPRECATED( message ) __attribute__(( deprecated )) + #endif + #else + #define IPP_DEPRECATED( comment ) __attribute__(( deprecated )) + #endif +#else + #define IPP_DEPRECATED( comment ) +#endif + +#if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER)) + #if !defined( _IPP_NO_DEFAULT_LIB ) + #if (( defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \ + (!defined( _IPP_PARALLEL_DYNAMIC ) && defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \ + (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \ + (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && defined( _IPP_SEQUENTIAL_STATIC ))) + #elif (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) + #define _IPP_NO_DEFAULT_LIB + #else + #error Illegal combination of _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC, only one definition can be defined + #endif + #endif +#else + #define _IPP_NO_DEFAULT_LIB + #if (defined( _IPP_PARALLEL_DYNAMIC ) || defined( _IPP_PARALLEL_STATIC ) || defined(_IPP_SEQUENTIAL_DYNAMIC) || defined(_IPP_SEQUENTIAL_STATIC)) + #pragma message ("defines _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC do not have any effect in current configuration") + #endif +#endif + +#if !defined( _IPP_NO_DEFAULT_LIB ) + #if defined( _IPP_PARALLEL_STATIC ) + #pragma comment( lib, "libircmt" ) + #pragma comment( lib, "libmmt" ) + #pragma comment( lib, "svml_dispmt" ) + #pragma comment( lib, "libiomp5md" ) + #endif +#endif + +#include "ippbase.h" +#include "ipptypes.h" + +extern const IppiRect ippRectInfinite; + +#ifdef __cplusplus +} +#endif + +#endif /* __IPPDEFS_H__ */ diff --git a/external/crypto_px/include/ipptypes.h b/external/crypto_px/include/ipptypes.h new file mode 100755 index 0000000000..684a8e9dbe --- /dev/null +++ b/external/crypto_px/include/ipptypes.h @@ -0,0 +1,1104 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifndef __IPPTYPES_H__ +#define __IPPTYPES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*****************************************************************************/ +/* Below are ippCore domain specific definitions */ +/*****************************************************************************/ +#if !defined( _OWN_BLDPCS ) + +#define ippCPUID_MMX 0x00000001 /* Intel Architecture MMX technology supported */ +#define ippCPUID_SSE 0x00000002 /* Streaming SIMD Extensions */ +#define ippCPUID_SSE2 0x00000004 /* Streaming SIMD Extensions 2 */ +#define ippCPUID_SSE3 0x00000008 /* Streaming SIMD Extensions 3 */ +#define ippCPUID_SSSE3 0x00000010 /* Supplemental Streaming SIMD Extensions 3 */ +#define ippCPUID_MOVBE 0x00000020 /* The processor supports MOVBE instruction */ +#define ippCPUID_SSE41 0x00000040 /* Streaming SIMD Extensions 4.1 */ +#define ippCPUID_SSE42 0x00000080 /* Streaming SIMD Extensions 4.2 */ +#define ippCPUID_AVX 0x00000100 /* Advanced Vector Extensions instruction set */ +#define ippAVX_ENABLEDBYOS 0x00000200 /* The operating system supports AVX */ +#define ippCPUID_AES 0x00000400 /* AES instruction */ +#define ippCPUID_CLMUL 0x00000800 /* PCLMULQDQ instruction */ +#define ippCPUID_ABR 0x00001000 /* Reserved */ +#define ippCPUID_RDRAND 0x00002000 /* Read Random Number instructions */ +#define ippCPUID_F16C 0x00004000 /* Float16 instructions */ +#define ippCPUID_AVX2 0x00008000 /* Advanced Vector Extensions 2 instruction set */ +#define ippCPUID_ADCOX 0x00010000 /* ADCX and ADOX instructions */ +#define ippCPUID_RDSEED 0x00020000 /* The RDSEED instruction */ +#define ippCPUID_PREFETCHW 0x00040000 /* The PREFETCHW instruction */ +#define ippCPUID_SHA 0x00080000 /* Intel (R) SHA Extensions */ +#define ippCPUID_AVX512F 0x00100000 /* AVX-512 Foundation instructions */ +#define ippCPUID_AVX512CD 0x00200000 /* AVX-512 Conflict Detection instructions */ +#define ippCPUID_AVX512ER 0x00400000 /* AVX-512 Exponential & Reciprocal instructions*/ +#define ippCPUID_AVX512PF 0x00800000 /* AVX-512 Prefetch instructions */ +#define ippCPUID_AVX512BW 0x01000000 /* AVX-512 Byte & Word instructions */ +#define ippCPUID_AVX512DQ 0x02000000 /* AVX-512 DWord & QWord instructions */ +#define ippCPUID_AVX512VL 0x04000000 /* AVX-512 Vector Length extensions */ +#define ippCPUID_KNC 0x80000000 /* Intel(R) Xeon Phi(TM) Coprocessor */ +#if defined( _WIN32 ) || defined ( _WIN64 ) + #define ippCPUID_NOCHECK 0x8000000000000000L /* Force ippSetCpuFeatures to set CPU features without check */ +#else + #define ippCPUID_NOCHECK 0x8000000000000000LL +#endif + +#if defined( _WIN32 ) || defined ( _WIN64 ) + #define ippCPUID_GETINFO_A 0x616f666e69746567L /* Force ipp_GetCpuFeatures to work as cpuid instruction */ +#else + #define ippCPUID_GETINFO_A 0x616f666e69746567LL +#endif + +#define IPP_COUNT_OF( obj ) (sizeof(obj)/sizeof(obj[0])) + +/*****************************************************************************/ +/* Below are ippSP domain specific definitions */ +/*****************************************************************************/ +typedef enum { + ippRndZero, + ippRndNear, + ippRndFinancial, + ippRndHintAccurate=0x10 +} IppRoundMode; + + +typedef enum { + ippAlgHintNone, + ippAlgHintFast, + ippAlgHintAccurate +} IppHintAlgorithm; + +typedef enum { + ippCmpLess, + ippCmpLessEq, + ippCmpEq, + ippCmpGreaterEq, + ippCmpGreater +} IppCmpOp; + +typedef enum { + ippAlgAuto = 0x00000000, + ippAlgDirect = 0x00000001, + ippAlgFFT = 0x00000002, + ippAlgMask = 0x000000FF +} IppAlgType; + +typedef enum { + ippsNormNone = 0x00000000, /* default */ + ippsNormA = 0x00000100, /* biased normalization */ + ippsNormB = 0x00000200, /* unbiased normalization */ + ippsNormMask = 0x0000FF00 +} IppsNormOp; + +typedef enum { + ippNormInf = 0x00000001, + ippNormL1 = 0x00000002, + ippNormL2 = 0x00000004 +} IppNormType; + +enum { + IPP_FFT_DIV_FWD_BY_N = 1, + IPP_FFT_DIV_INV_BY_N = 2, + IPP_FFT_DIV_BY_SQRTN = 4, + IPP_FFT_NODIV_BY_ANY = 8 +}; + +enum { + IPP_DIV_FWD_BY_N = 1, + IPP_DIV_INV_BY_N = 2, + IPP_DIV_BY_SQRTN = 4, + IPP_NODIV_BY_ANY = 8 +}; + +typedef struct { + Ipp32f rho; + Ipp32f theta; +} IppPointPolar; + +typedef enum {ippWinBartlett,ippWinBlackman,ippWinHamming,ippWinHann,ippWinRect} IppWinType; + +typedef enum { ippButterworth, ippChebyshev1 } IppsIIRFilterType; + +typedef enum { ippZCR=0, ippZCXor, ippZCC } IppsZCType; + +#if !defined( _OWN_BLDPCS ) + +typedef struct { + int left; + int right; +} IppsROI; + +typedef struct RandUniState_8u IppsRandUniState_8u; +typedef struct RandUniState_16s IppsRandUniState_16s; +typedef struct RandUniState_32f IppsRandUniState_32f; +typedef struct RandUniState_64f IppsRandUniState_64f; + +typedef struct RandGaussState_8u IppsRandGaussState_8u; +typedef struct RandGaussState_16s IppsRandGaussState_16s; +typedef struct RandGaussState_32f IppsRandGaussState_32f; +typedef struct RandGaussState_64f IppsRandGaussState_64f; + +typedef struct FFTSpec_C_32fc IppsFFTSpec_C_32fc; +typedef struct FFTSpec_C_32f IppsFFTSpec_C_32f; +typedef struct FFTSpec_R_32f IppsFFTSpec_R_32f; + +typedef struct FFTSpec_C_64fc IppsFFTSpec_C_64fc; +typedef struct FFTSpec_C_64f IppsFFTSpec_C_64f; +typedef struct FFTSpec_R_64f IppsFFTSpec_R_64f; + +typedef struct DFTSpec_C_32fc IppsDFTSpec_C_32fc; +typedef struct DFTSpec_C_32f IppsDFTSpec_C_32f; +typedef struct DFTSpec_R_32f IppsDFTSpec_R_32f; + +typedef struct DFTSpec_C_64fc IppsDFTSpec_C_64fc; +typedef struct DFTSpec_C_64f IppsDFTSpec_C_64f; +typedef struct DFTSpec_R_64f IppsDFTSpec_R_64f; + +typedef struct DCTFwdSpec_32f IppsDCTFwdSpec_32f; +typedef struct DCTInvSpec_32f IppsDCTInvSpec_32f; + +typedef struct DCTFwdSpec_64f IppsDCTFwdSpec_64f; +typedef struct DCTInvSpec_64f IppsDCTInvSpec_64f; + +typedef struct sWTFwdState_32f IppsWTFwdState_32f; +typedef struct sWTFwdState_8u32f IppsWTFwdState_8u32f; +typedef struct sWTFwdState_16s32f IppsWTFwdState_16s32f; +typedef struct sWTFwdState_16u32f IppsWTFwdState_16u32f; +typedef struct sWTInvState_32f IppsWTInvState_32f; +typedef struct sWTInvState_32f8u IppsWTInvState_32f8u; +typedef struct sWTInvState_32f16s IppsWTInvState_32f16s; +typedef struct sWTInvState_32f16u IppsWTInvState_32f16u; + +typedef struct IIRState_32f IppsIIRState_32f; +typedef struct IIRState_32fc IppsIIRState_32fc; +typedef struct IIRState32f_16s IppsIIRState32f_16s; +typedef struct IIRState32fc_16sc IppsIIRState32fc_16sc; +typedef struct IIRState_64f IppsIIRState_64f; +typedef struct IIRState_64fc IppsIIRState_64fc; +typedef struct IIRState64f_32f IppsIIRState64f_32f; +typedef struct IIRState64fc_32fc IppsIIRState64fc_32fc; +typedef struct IIRState64f_32s IppsIIRState64f_32s; +typedef struct IIRState64fc_32sc IppsIIRState64fc_32sc; +typedef struct IIRState64f_16s IppsIIRState64f_16s; +typedef struct IIRState64fc_16sc IppsIIRState64fc_16sc; + +typedef struct FIRSpec_32f IppsFIRSpec_32f; +typedef struct FIRSpec_64f IppsFIRSpec_64f; +typedef struct FIRSpec_32fc IppsFIRSpec_32fc; +typedef struct FIRSpec_64fc IppsFIRSpec_64fc; + +typedef struct FIRLMSState_32f IppsFIRLMSState_32f; +typedef struct FIRLMSState32f_16s IppsFIRLMSState32f_16s; + +typedef struct HilbertSpec IppsHilbertSpec; + +typedef struct FIRSparseState_32f IppsFIRSparseState_32f; +typedef struct IIRSparseState_32f IppsIIRSparseState_32f; + +typedef struct ResamplingPolyphase_16s IppsResamplingPolyphase_16s; +typedef struct ResamplingPolyphaseFixed_16s IppsResamplingPolyphaseFixed_16s; +typedef struct ResamplingPolyphase_32f IppsResamplingPolyphase_32f; +typedef struct ResamplingPolyphaseFixed_32f IppsResamplingPolyphaseFixed_32f; + +#endif /* _OWN_BLDPCS */ + +/*****************************************************************************/ +/* Below are ippIP domain specific definitions */ +/*****************************************************************************/ +#define IPP_TEMPORAL_COPY 0x0 +#define IPP_NONTEMPORAL_STORE 0x01 +#define IPP_NONTEMPORAL_LOAD 0x02 + +typedef int IppEnum; + +#define IPP_DEG_TO_RAD( deg ) ( (deg)/180.0 * IPP_PI ) + +typedef enum { + ippiNormNone = 0x00000000, /* default */ + ippiNorm = 0x00000100, /* normalized form */ + ippiNormCoefficient = 0x00000200, /* correlation coefficient in the range [-1.0 ... 1.0] */ + ippiNormMask = 0x0000FF00 +} IppiNormOp; + +typedef enum { + ippiROIFull = 0x00000000, + ippiROIValid = 0x00010000, + ippiROISame = 0x00020000, + ippiROIMask = 0x00FF0000 +} IppiROIShape; + +typedef enum { + ippC0 = 0, + ippC1 = 1, + ippC2 = 2, + ippC3 = 3, + ippC4 = 4, + ippP2 = 5, + ippP3 = 6, + ippP4 = 7, + ippAC1 = 8, + ippAC4 = 9, + ippA0C4 = 10, + ippAP4 = 11 +} IppChannels; + +typedef enum _IppiBorderType { + ippBorderConst = 0, + ippBorderRepl = 1, + ippBorderWrap = 2, + ippBorderMirror = 3, /* left border: 012... -> 21012... */ + ippBorderMirrorR = 4, /* left border: 012... -> 210012... */ + ippBorderInMem = 6, + ippBorderTransp = 7, + ippBorderInMemTop = 0x0010, + ippBorderInMemBottom = 0x0020, + ippBorderInMemLeft = 0x0040, + ippBorderInMemRight = 0x0080 +} IppiBorderType; + +typedef enum { + ippAxsHorizontal, + ippAxsVertical, + ippAxsBoth, + ippAxs45, + ippAxs135 +} IppiAxis; + +typedef struct { + int x; + int y; + int width; + int height; +} IppiRect; + +typedef struct { + int x; + int y; +} IppiPoint; + +typedef struct { + int width; + int height; +} IppiSize; + +typedef struct { + Ipp32f x; + Ipp32f y; +} IppiPoint_32f; + +typedef enum _IppiMaskSize { + ippMskSize1x3 = 13, + ippMskSize1x5 = 15, + ippMskSize3x1 = 31, + ippMskSize3x3 = 33, + ippMskSize5x1 = 51, + ippMskSize5x5 = 55 +} IppiMaskSize; + +enum { + IPPI_INTER_NN = 1, + IPPI_INTER_LINEAR = 2, + IPPI_INTER_CUBIC = 4, + IPPI_INTER_CUBIC2P_BSPLINE, /* two-parameter cubic filter (B=1, C=0) */ + IPPI_INTER_CUBIC2P_CATMULLROM, /* two-parameter cubic filter (B=0, C=1/2) */ + IPPI_INTER_CUBIC2P_B05C03, /* two-parameter cubic filter (B=1/2, C=3/10) */ + IPPI_INTER_SUPER = 8, + IPPI_INTER_LANCZOS = 16, + IPPI_ANTIALIASING = (1 << 29), + IPPI_SUBPIXEL_EDGE = (1 << 30), + IPPI_SMOOTH_EDGE = (1 << 31) +}; + +typedef enum { + ippNearest = IPPI_INTER_NN, + ippLinear = IPPI_INTER_LINEAR, + ippCubic = IPPI_INTER_CUBIC2P_CATMULLROM, + ippLanczos = IPPI_INTER_LANCZOS, + ippHahn = 0, + ippSuper = IPPI_INTER_SUPER +} IppiInterpolationType; + +typedef enum { + ippPolyphase_1_2, + ippPolyphase_3_5, + ippPolyphase_2_3, + ippPolyphase_7_10, + ippPolyphase_3_4 +} IppiFraction; + +enum { + IPP_FASTN_ORIENTATION = 0x0001, + IPP_FASTN_NMS = 0x0002, + IPP_FASTN_CIRCLE = 0X0004, + IPP_FASTN_SCORE_MODE0 = 0X0020 +}; + +#if !defined( _OWN_BLDPCS ) + +typedef enum { + ippAlphaOver, + ippAlphaIn, + ippAlphaOut, + ippAlphaATop, + ippAlphaXor, + ippAlphaPlus, + ippAlphaOverPremul, + ippAlphaInPremul, + ippAlphaOutPremul, + ippAlphaATopPremul, + ippAlphaXorPremul, + ippAlphaPlusPremul +} IppiAlphaType; + +typedef struct DeconvFFTState_32f_C1R IppiDeconvFFTState_32f_C1R; +typedef struct DeconvFFTState_32f_C3R IppiDeconvFFTState_32f_C3R; +typedef struct DeconvLR_32f_C1R IppiDeconvLR_32f_C1R; +typedef struct DeconvLR_32f_C3R IppiDeconvLR_32f_C3R; + +typedef enum { + ippiFilterBilateralGauss = 100, + ippiFilterBilateralGaussFast = 101 +} IppiFilterBilateralType; + +typedef struct FilterBilateralSpec IppiFilterBilateralSpec; + +typedef enum { + ippDistNormL1 = 0x00000002 +} IppiDistanceMethodType; + +typedef enum { + ippResizeFilterHann, + ippResizeFilterLanczos +} IppiResizeFilterType; + +typedef struct ResizeFilterState IppiResizeFilterState; + +typedef struct { + Ipp32u borderLeft; + Ipp32u borderTop; + Ipp32u borderRight; + Ipp32u borderBottom; +} IppiBorderSize; + +typedef enum { + ippWarpForward, + ippWarpBackward, +} IppiWarpDirection; + +typedef enum { + ippWarpAffine, + ippWarpPerspective, + ippWarpBilinear, +} IppiWarpTransformType; + + +typedef struct ResizeSpec_32f IppiResizeSpec_32f; +typedef struct ResizeYUV422Spec IppiResizeYUV422Spec; +typedef struct ResizeYUV420Spec IppiResizeYUV420Spec; + +typedef struct ResizeSpec_64f IppiResizeSpec_64f; + +typedef struct IppiWarpSpec IppiWarpSpec; + +typedef struct FilterBorderSpec IppiFilterBorderSpec; + +typedef struct ThresholdAdaptiveSpec IppiThresholdAdaptiveSpec; + +typedef struct HistogramSpec IppiHistogramSpec; + +typedef struct { + int cvCompatible; /* openCV compatible output format */ + int cellSize; /* squre cell size (pixels) */ + int blockSize; /* square block size (pixels) */ + int blockStride; /* block displacement (the same for x- and y- directions) */ + int nbins; /* required number of bins */ + Ipp32f sigma; /* gaussian factor of HOG block weights */ + Ipp32f l2thresh; /* normalization factor */ + IppiSize winSize; /* detection window size (pixels) */ +} IppiHOGConfig; + +typedef struct FFT2DSpec_C_32fc IppiFFTSpec_C_32fc; +typedef struct FFT2DSpec_R_32f IppiFFTSpec_R_32f; + +typedef struct DFT2DSpec_C_32fc IppiDFTSpec_C_32fc; +typedef struct DFT2DSpec_R_32f IppiDFTSpec_R_32f; + +typedef struct DCT2DFwdSpec_32f IppiDCTFwdSpec_32f; +typedef struct DCT2DInvSpec_32f IppiDCTInvSpec_32f; + +typedef struct iWTFwdSpec_32f_C1R IppiWTFwdSpec_32f_C1R; +typedef struct iWTInvSpec_32f_C1R IppiWTInvSpec_32f_C1R; +typedef struct iWTFwdSpec_32f_C3R IppiWTFwdSpec_32f_C3R; +typedef struct iWTInvSpec_32f_C3R IppiWTInvSpec_32f_C3R; + +typedef struct MomentState64f IppiMomentState_64f; +typedef Ipp64f IppiHuMoment_64f[7]; + +typedef struct LUT_Spec IppiLUT_Spec; + +#define IPP_HOG_MAX_CELL (16) /* max size of CELL */ +#define IPP_HOG_MAX_BLOCK (64) /* max size of BLOCK */ +#define IPP_HOG_MAX_BINS (16) /* max number of BINS */ + +typedef struct _ipHOG IppiHOGSpec; + +#endif /* _OWN_BLDPCS */ + + + /**** Below are 3D Image (Volume) Processing specific definitions ****/ + +typedef struct { + int width; + int height; + int depth; +} IpprVolume; + +typedef struct { + int x; + int y; + int z; + int width; + int height; + int depth; +} IpprCuboid; + +typedef struct { + int x; + int y; + int z; +} IpprPoint; + +/*****************************************************************************/ +/* Below are ippCV domain specific definitions */ +/*****************************************************************************/ + +typedef enum _IppiDifferentialKernel +{ + ippFilterSobelVert, + ippFilterSobelHoriz, + ippFilterSobel, + ippFilterScharrVert, + ippFilterScharrHoriz, + ippFilterScharr, + ippFilterCentralDiffVert, + ippFilterCentralDiffHoriz, + ippFilterCentralDiff, +}IppiDifferentialKernel; + +#if !defined( _OWN_BLDPCS ) + +typedef enum _IppiKernelType { + ippKernelSobel = 0, + ippKernelScharr = 1, + ippKernelSobelNeg = 2 +} IppiKernelType; + +typedef enum _IppiNorm { + ippiNormInf = 0, + ippiNormL1 = 1, + ippiNormL2 = 2, + ippiNormFM = 3 +} IppiNorm; + +typedef struct ipcvMorphState IppiMorphState; +typedef struct ipcvMorphAdvState IppiMorphAdvState; +typedef struct ipcvMorphGrayState_8u IppiMorphGrayState_8u; +typedef struct ipcvMorphGrayState_32f IppiMorphGrayState_32f; + +typedef struct ipcvConvState IppiConvState; + +typedef struct _IppiConnectedComp { + Ipp64f area; /* area of the segmented component */ + Ipp64f value[3];/* gray scale value of the segmented component */ + IppiRect rect; /* bounding rectangle of the segmented component */ +} IppiConnectedComp; + +typedef struct PyramidState IppiPyramidState; + +typedef IppiPyramidState IppiPyramidDownState_8u_C1R; +typedef IppiPyramidState IppiPyramidDownState_16u_C1R; +typedef IppiPyramidState IppiPyramidDownState_32f_C1R; +typedef IppiPyramidState IppiPyramidDownState_8u_C3R; +typedef IppiPyramidState IppiPyramidDownState_16u_C3R; +typedef IppiPyramidState IppiPyramidDownState_32f_C3R; +typedef IppiPyramidState IppiPyramidUpState_8u_C1R; +typedef IppiPyramidState IppiPyramidUpState_16u_C1R; +typedef IppiPyramidState IppiPyramidUpState_32f_C1R; +typedef IppiPyramidState IppiPyramidUpState_8u_C3R; +typedef IppiPyramidState IppiPyramidUpState_16u_C3R; +typedef IppiPyramidState IppiPyramidUpState_32f_C3R; + + +typedef struct _IppiPyramid { + Ipp8u **pImage; + IppiSize *pRoi; + Ipp64f *pRate; + int *pStep; + Ipp8u *pState; + int level; +} IppiPyramid; + +typedef struct OptFlowPyrLK IppiOptFlowPyrLK; + +typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_8u_C1R; +typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_16u_C1R; +typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_32f_C1R; + +typedef struct ipcvHaarClassifier_32f IppiHaarClassifier_32f; +typedef struct ipcvHaarClassifier_32s IppiHaarClassifier_32s; + +typedef struct ipcvFGHistogramState_8u_C1R IppFGHistogramState_8u_C1R; +typedef struct ipcvFGHistogramState_8u_C3R IppFGHistogramState_8u_C3R; + +typedef struct ipcvFGGaussianState_8u_C1R IppFGGaussianState_8u_C1R; +typedef struct ipcvFGGaussianState_8u_C3R IppFGGaussianState_8u_C3R; + +typedef enum _IppiInpaintFlag { + IPP_INPAINT_TELEA = 0, + IPP_INPAINT_NS = 1 +} IppiInpaintFlag; + +typedef struct ippcvFilterGaussianSpec IppFilterGaussianSpec; + +typedef struct ipcvInpaintState_8u IppiInpaintState_8u_C1R; +typedef struct ipcvInpaintState_8u IppiInpaintState_8u_C3R; + +typedef struct HoughProbSpec IppiHoughProbSpec; + +typedef struct FastNSpec IppiFastNSpec; + +typedef struct _IppiCornerFastN { + int x; + int y; + int cornerType; + int orientation; + float angle; + float score; +} IppiCornerFastN; + +typedef struct FGMMState_8u_C3R IppFGMMState_8u_C3R; + +typedef struct +{ + unsigned int numFrames; + unsigned int maxNGauss; + Ipp32f varInit; + Ipp32f varMin; + Ipp32f varMax; + Ipp32f varWBRatio; + Ipp32f bckgThr; + Ipp32f varNGRatio; + Ipp32f reduction; + Ipp8u shadowValue; + char shadowFlag; + Ipp32f shadowRatio; +} IppFGMModel; + +#endif /* _OWN_BLDPCS */ + +#define IPP_SEGMENT_QUEUE 0x01 +#define IPP_SEGMENT_DISTANCE 0x02 +#define IPP_SEGMENT_BORDER_4 0x40 +#define IPP_SEGMENT_BORDER_8 0x80 + +#define IPP_TRUNC(a,b) ((a)&~((b)-1)) +#define IPP_APPEND(a,b) (((a)+(b)-1)&~((b)-1)) + +/*****************************************************************************/ +/* Below are ippCC domain specific definitions */ +/*****************************************************************************/ +enum { + IPP_UPPER = 1, + IPP_LEFT = 2, + IPP_CENTER = 4, + IPP_RIGHT = 8, + IPP_LOWER = 16, + IPP_UPPER_LEFT = 32, + IPP_UPPER_RIGHT = 64, + IPP_LOWER_LEFT = 128, + IPP_LOWER_RIGHT = 256 +}; + +#if !defined( _OWN_BLDPCS ) + +typedef enum { + ippDitherNone, + ippDitherFS, + ippDitherJJN, + ippDitherStucki, + ippDitherBayer +} IppiDitherType; + +#endif /* _OWN_BLDPCS */ + +/*****************************************************************************/ +/* Below are ippCH domain specific definitions */ +/*****************************************************************************/ + +#if !defined( _OWN_BLDPCS ) + +typedef struct { + void *pFind; + int lenFind; +} IppRegExpFind; + +typedef struct RegExpState IppRegExpState; + +typedef enum { + ippFmtASCII = 0, + ippFmtUTF8 +} IppRegExpFormat; + +typedef struct RegExpReplaceState IppRegExpReplaceState; + +#endif /* _OWN_BLDPCS */ + +/*****************************************************************************/ +/* Below are ippDC domain specific definitions */ +/*****************************************************************************/ + +#if !defined ( _OWN_BLDPCS ) + +typedef struct MTFState_8u IppMTFState_8u; + +typedef enum { + ippBWTItohTanakaLimSort, + ippBWTItohTanakaUnlimSort, + ippBWTSuffixSort, + ippBWTAutoSort +} IppBWTSortAlgorithmHint; + +typedef struct LZSSState_8u IppLZSSState_8u; + +typedef struct LZ77State_8u IppLZ77State_8u; +typedef enum{ + IppLZ77FastCompr, + IppLZ77AverageCompr, + IppLZ77BestCompr +} IppLZ77ComprLevel; +typedef enum{ + IppLZ77NoChcksm, + IppLZ77Adler32, + IppLZ77CRC32 +} IppLZ77Chcksm; +typedef enum { + IppLZ77NoFlush, + IppLZ77SyncFlush, + IppLZ77FullFlush, + IppLZ77FinishFlush +} IppLZ77Flush; +typedef struct IppLZ77Pairs_16u { + Ipp16u length; + Ipp16u offset; +} IppLZ77Pair; +typedef enum { + IppLZ77StatusInit, + IppLZ77StatusLZ77Process, + IppLZ77StatusHuffProcess, + IppLZ77StatusFinal +} IppLZ77DeflateStatus; +typedef enum { + IppLZ77UseFixed, + IppLZ77UseDynamic, + IppLZ77UseStored +} IppLZ77HuffMode; +typedef enum { + IppLZ77InflateStatusInit, + IppLZ77InflateStatusHuffProcess, + IppLZ77InflateStatusLZ77Process, + IppLZ77InflateStatusFinal +} IppLZ77InflateStatus; + +typedef struct IppInflateState { + const Ipp8u* pWindow; /* pointer to the sliding window + (the dictionary for the LZ77 algorithm) */ + unsigned int winSize; /* size of the sliding window */ + unsigned int tableType; /* type of Huffman code tables + (for example, 0 - tables for Fixed Huffman codes) */ + unsigned int tableBufferSize; /* (ENOUGH = 2048) * (sizeof(code) = 4) - + sizeof(IppInflateState) */ +} IppInflateState; + +typedef enum { /* this type is used as a translator of the inflate_mode type from zlib */ + ippTYPE, + ippLEN, + ippLENEXT +} IppInflateMode; + +typedef struct { + Ipp16u freq; + Ipp16u code; +} IppDeflateFreqTable; + +typedef struct { + Ipp16u code; + Ipp16u len; +} IppDeflateHuffCode; + +typedef struct RLEState_BZ2 IppRLEState_BZ2; + +typedef struct EncodeHuffState_BZ2 IppEncodeHuffState_BZ2; + +typedef struct DecodeHuffState_BZ2 IppDecodeHuffState_BZ2; + +typedef enum { + IppLZO1XST, /* Single-threaded, generic LZO-compatible*/ + IppLZO1XMT /* Multi-threaded */ +} IppLZOMethod ; + +typedef struct LZOState_8u IppLZOState_8u; + +#endif /* _OWN_BLDPCS */ + +/* ///////////////////////////////////////////////////////////////////////////// +// The following enumerator defines a status of IPP operations +// negative value means error +*/ +typedef enum { + /* errors */ + ippStsNotSupportedModeErr = -9999,/* The requested mode is currently not supported. */ + ippStsCpuNotSupportedErr = -9998,/* The target CPU is not supported. */ + ippStsInplaceModeNotSupportedErr = -9997,/* The inplace operation is currently not supported. */ + + ippStsIIRIIRLengthErr = -234, /* Vector length for IIRIIR function is less than 3*(IIR order) */ + ippStsWarpTransformTypeErr = -233, /* The warp transform type is illegal */ + ippStsExceededSizeErr = -232, /* Requested size exceeded the maximum supported ROI size */ + ippStsWarpDirectionErr = -231, /* The warp transform direction is illegal */ + + ippStsFilterTypeErr = -230, /* The filter type is incorrect or not supported */ + + ippStsNormErr = -229, /* The norm is incorrect or not supported */ + + ippStsAlgTypeErr = -228, /* Algorithm type is not supported. */ + ippStsMisalignedOffsetErr = -227, /* The offset is not aligned with an element. */ + + ippStsQuadraticNonResidueErr = -226, /* SQRT operation on quadratic non-residue value. */ + + ippStsBorderErr = -225, /* Illegal value for border type.*/ + + ippStsDitherTypeErr = -224, /* Dithering type is not supported. */ + ippStsH264BufferFullErr = -223, /* Buffer for the output bitstream is full. */ + ippStsWrongAffinitySettingErr= -222, /* An affinity setting does not correspond to the affinity setting that was set by f.ippSetAffinity(). */ + ippStsLoadDynErr = -221, /* Error when loading the dynamic library. */ + + ippStsPointAtInfinity = -220, /* Point at infinity is detected. */ + + ippStsUnknownStatusCodeErr = -216, /* Unknown status code. */ + + ippStsOFBSizeErr = -215, /* Incorrect value for crypto OFB block size. */ + ippStsLzoBrokenStreamErr = -214, /* LZO safe decompression function cannot decode LZO stream. */ + + ippStsRoundModeNotSupportedErr = -213, /* Rounding mode is not supported. */ + ippStsDecimateFractionErr = -212, /* Fraction in Decimate is not supported. */ + ippStsWeightErr = -211, /* Incorrect value for weight. */ + + ippStsQualityIndexErr = -210, /* Cannot calculate the quality index for an image filled with a constant. */ + ippStsIIRPassbandRippleErr = -209, /* Ripple in passband for Chebyshev1 design is less than zero, equal to zero, or greater than 29. */ + ippStsFilterFrequencyErr = -208, /* Cutoff frequency of filter is less than zero, equal to zero, or greater than 0.5. */ + ippStsFIRGenOrderErr = -207, /* Order of the FIR filter for design is less than 1. */ + ippStsIIRGenOrderErr = -206, /* Order of the IIR filter for design is less than 1, or greater than 12. */ + + ippStsConvergeErr = -205, /* The algorithm does not converge. */ + ippStsSizeMatchMatrixErr = -204, /* The sizes of the source matrices are unsuitable. */ + ippStsCountMatrixErr = -203, /* Count value is less than, or equal to zero. */ + ippStsRoiShiftMatrixErr = -202, /* RoiShift value is negative or not divisible by the size of the data type. */ + + ippStsResizeNoOperationErr = -201, /* One of the output image dimensions is less than 1 pixel. */ + ippStsSrcDataErr = -200, /* The source buffer contains unsupported data. */ + ippStsMaxLenHuffCodeErr = -199, /* Huff: Max length of Huffman code is more than the expected one. */ + ippStsCodeLenTableErr = -198, /* Huff: Invalid codeLenTable. */ + ippStsFreqTableErr = -197, /* Huff: Invalid freqTable. */ + + ippStsIncompleteContextErr = -196, /* Crypto: set up of context is not complete. */ + + ippStsSingularErr = -195, /* Matrix is singular. */ + ippStsSparseErr = -194, /* Positions of taps are not in ascending order, or are negative, or repetitive. */ + ippStsBitOffsetErr = -193, /* Incorrect bit offset value. */ + ippStsQPErr = -192, /* Incorrect quantization parameter value. */ + ippStsVLCErr = -191, /* Illegal VLC or FLC is detected during stream decoding. */ + ippStsRegExpOptionsErr = -190, /* RegExp: Options for the pattern are incorrect. */ + ippStsRegExpErr = -189, /* RegExp: The structure pRegExpState contains incorrect data. */ + ippStsRegExpMatchLimitErr = -188, /* RegExp: The match limit is exhausted. */ + ippStsRegExpQuantifierErr = -187, /* RegExp: Incorrect quantifier. */ + ippStsRegExpGroupingErr = -186, /* RegExp: Incorrect grouping. */ + ippStsRegExpBackRefErr = -185, /* RegExp: Incorrect back reference. */ + ippStsRegExpChClassErr = -184, /* RegExp: Incorrect character class. */ + ippStsRegExpMetaChErr = -183, /* RegExp: Incorrect metacharacter. */ + ippStsStrideMatrixErr = -182, /* Stride value is not positive or not divisible by the size of the data type. */ + ippStsCTRSizeErr = -181, /* Incorrect value for crypto CTR block size. */ + ippStsJPEG2KCodeBlockIsNotAttached =-180, /* Codeblock parameters are not attached to the state structure. */ + ippStsNotPosDefErr = -179, /* Matrix is not positive definite. */ + + ippStsEphemeralKeyErr = -178, /* ECC: Invalid ephemeral key. */ + ippStsMessageErr = -177, /* ECC: Invalid message digest. */ + ippStsShareKeyErr = -176, /* ECC: Invalid share key. */ + ippStsIvalidPublicKey = -175, /* ECC: Invalid public key. */ + ippStsIvalidPrivateKey = -174, /* ECC: Invalid private key. */ + ippStsOutOfECErr = -173, /* ECC: Point out of EC. */ + ippStsECCInvalidFlagErr = -172, /* ECC: Invalid Flag. */ + + ippStsMP3FrameHeaderErr = -171, /* Error in fields of the IppMP3FrameHeader structure. */ + ippStsMP3SideInfoErr = -170, /* Error in fields of the IppMP3SideInfo structure. */ + + ippStsBlockStepErr = -169, /* Step for Block is less than 8. */ + ippStsMBStepErr = -168, /* Step for MB is less than 16. */ + + ippStsAacPrgNumErr = -167, /* AAC: Invalid number of elements for one program. */ + ippStsAacSectCbErr = -166, /* AAC: Invalid section codebook. */ + ippStsAacSfValErr = -164, /* AAC: Invalid scalefactor value. */ + ippStsAacCoefValErr = -163, /* AAC: Invalid quantized coefficient value. */ + ippStsAacMaxSfbErr = -162, /* AAC: Invalid coefficient index. */ + ippStsAacPredSfbErr = -161, /* AAC: Invalid predicted coefficient index. */ + ippStsAacPlsDataErr = -160, /* AAC: Invalid pulse data attributes. */ + ippStsAacGainCtrErr = -159, /* AAC: Gain control is not supported. */ + ippStsAacSectErr = -158, /* AAC: Invalid number of sections. */ + ippStsAacTnsNumFiltErr = -157, /* AAC: Invalid number of TNS filters. */ + ippStsAacTnsLenErr = -156, /* AAC: Invalid length of TNS region. */ + ippStsAacTnsOrderErr = -155, /* AAC: Invalid order of TNS filter. */ + ippStsAacTnsCoefResErr = -154, /* AAC: Invalid bit-resolution for TNS filter coefficients. */ + ippStsAacTnsCoefErr = -153, /* AAC: Invalid coefficients of TNS filter. */ + ippStsAacTnsDirectErr = -152, /* AAC: Invalid direction TNS filter. */ + ippStsAacTnsProfileErr = -151, /* AAC: Invalid TNS profile. */ + ippStsAacErr = -150, /* AAC: Internal error. */ + ippStsAacBitOffsetErr = -149, /* AAC: Invalid current bit offset in bitstream. */ + ippStsAacAdtsSyncWordErr = -148, /* AAC: Invalid ADTS syncword. */ + ippStsAacSmplRateIdxErr = -147, /* AAC: Invalid sample rate index. */ + ippStsAacWinLenErr = -146, /* AAC: Invalid window length (not short or long). */ + ippStsAacWinGrpErr = -145, /* AAC: Invalid number of groups for current window length. */ + ippStsAacWinSeqErr = -144, /* AAC: Invalid window sequence range. */ + ippStsAacComWinErr = -143, /* AAC: Invalid common window flag. */ + ippStsAacStereoMaskErr = -142, /* AAC: Invalid stereo mask. */ + ippStsAacChanErr = -141, /* AAC: Invalid channel number. */ + ippStsAacMonoStereoErr = -140, /* AAC: Invalid mono-stereo flag. */ + ippStsAacStereoLayerErr = -139, /* AAC: Invalid this Stereo Layer flag. */ + ippStsAacMonoLayerErr = -138, /* AAC: Invalid this Mono Layer flag. */ + ippStsAacScalableErr = -137, /* AAC: Invalid scalable object flag. */ + ippStsAacObjTypeErr = -136, /* AAC: Invalid audio object type. */ + ippStsAacWinShapeErr = -135, /* AAC: Invalid window shape. */ + ippStsAacPcmModeErr = -134, /* AAC: Invalid PCM output interleaving indicator. */ + ippStsVLCUsrTblHeaderErr = -133, /* VLC: Invalid header inside table. */ + ippStsVLCUsrTblUnsupportedFmtErr = -132, /* VLC: Table format is not supported. */ + ippStsVLCUsrTblEscAlgTypeErr = -131, /* VLC: Ecs-algorithm is not supported. */ + ippStsVLCUsrTblEscCodeLengthErr = -130, /* VLC: Esc-code length inside table header is incorrect. */ + ippStsVLCUsrTblCodeLengthErr = -129, /* VLC: Code length inside table is incorrect. */ + ippStsVLCInternalTblErr = -128, /* VLC: Invalid internal table. */ + ippStsVLCInputDataErr = -127, /* VLC: Invalid input data. */ + ippStsVLCAACEscCodeLengthErr = -126, /* VLC: Invalid AAC-Esc code length. */ + ippStsNoiseRangeErr = -125, /* Noise value for Wiener Filter is out of range. */ + ippStsUnderRunErr = -124, /* Error in data under run. */ + ippStsPaddingErr = -123, /* Detected padding error indicates the possible data corruption. */ + ippStsCFBSizeErr = -122, /* Incorrect value for crypto CFB block size. */ + ippStsPaddingSchemeErr = -121, /* Invalid padding scheme. */ + ippStsInvalidCryptoKeyErr = -120, /* A compromised key causes suspansion of the requested cryptographic operation. */ + ippStsLengthErr = -119, /* Incorrect value for string length. */ + ippStsBadModulusErr = -118, /* Bad modulus caused a failure in module inversion. */ + ippStsLPCCalcErr = -117, /* Cannot evaluate linear prediction. */ + ippStsRCCalcErr = -116, /* Cannot compute reflection coefficients. */ + ippStsIncorrectLSPErr = -115, /* Incorrect values for Linear Spectral Pair. */ + ippStsNoRootFoundErr = -114, /* No roots are found for equation. */ + ippStsJPEG2KBadPassNumber = -113, /* Pass number exceeds allowed boundaries [0,nOfPasses-1]. */ + ippStsJPEG2KDamagedCodeBlock= -112, /* Codeblock for decoding contains damaged data. */ + ippStsH263CBPYCodeErr = -111, /* Illegal Huffman code is detected through CBPY stream processing. */ + ippStsH263MCBPCInterCodeErr = -110, /* Illegal Huffman code is detected through MCBPC Inter stream processing. */ + ippStsH263MCBPCIntraCodeErr = -109, /* Illegal Huffman code is detected through MCBPC Intra stream processing. */ + ippStsNotEvenStepErr = -108, /* Step value is not pixel multiple. */ + ippStsHistoNofLevelsErr = -107, /* Number of levels for histogram is less than 2. */ + ippStsLUTNofLevelsErr = -106, /* Number of levels for LUT is less than 2. */ + ippStsMP4BitOffsetErr = -105, /* Incorrect bit offset value. */ + ippStsMP4QPErr = -104, /* Incorrect quantization parameter. */ + ippStsMP4BlockIdxErr = -103, /* Incorrect block index. */ + ippStsMP4BlockTypeErr = -102, /* Incorrect block type. */ + ippStsMP4MVCodeErr = -101, /* Illegal Huffman code is detected during MV stream processing. */ + ippStsMP4VLCCodeErr = -100, /* Illegal Huffman code is detected during VLC stream processing. */ + ippStsMP4DCCodeErr = -99, /* Illegal code is detected during DC stream processing. */ + ippStsMP4FcodeErr = -98, /* Incorrect fcode value. */ + ippStsMP4AlignErr = -97, /* Incorrect buffer alignment . */ + ippStsMP4TempDiffErr = -96, /* Incorrect temporal difference. */ + ippStsMP4BlockSizeErr = -95, /* Incorrect size of a block or macroblock. */ + ippStsMP4ZeroBABErr = -94, /* All BAB values are equal to zero. */ + ippStsMP4PredDirErr = -93, /* Incorrect prediction direction. */ + ippStsMP4BitsPerPixelErr = -92, /* Incorrect number of bits per pixel. */ + ippStsMP4VideoCompModeErr = -91, /* Incorrect video component mode. */ + ippStsMP4LinearModeErr = -90, /* Incorrect DC linear mode. */ + ippStsH263PredModeErr = -83, /* Incorrect Prediction Mode value. */ + ippStsH263BlockStepErr = -82, /* The step value is less than 8. */ + ippStsH263MBStepErr = -81, /* The step value is less than 16. */ + ippStsH263FrameWidthErr = -80, /* The frame width is less than 8. */ + ippStsH263FrameHeightErr = -79, /* The frame height is less than, or equal to zero. */ + ippStsH263ExpandPelsErr = -78, /* Expand pixels number is less than 8. */ + ippStsH263PlaneStepErr = -77, /* Step value is less than the plane width. */ + ippStsH263QuantErr = -76, /* Quantizer value is less than, or equal to zero, or greater than 31. */ + ippStsH263MVCodeErr = -75, /* Illegal Huffman code is detected during MV stream processing. */ + ippStsH263VLCCodeErr = -74, /* Illegal Huffman code is detected during VLC stream processing. */ + ippStsH263DCCodeErr = -73, /* Illegal code is detected during DC stream processing. */ + ippStsH263ZigzagLenErr = -72, /* Zigzag compact length is more than 64. */ + ippStsFBankFreqErr = -71, /* Incorrect value for the filter bank frequency parameter. */ + ippStsFBankFlagErr = -70, /* Incorrect value for the filter bank parameter. */ + ippStsFBankErr = -69, /* Filter bank is not correctly initialized. */ + ippStsNegOccErr = -67, /* Occupation count is negative. */ + ippStsCdbkFlagErr = -66, /* Incorrect value for the codebook flag parameter. */ + ippStsSVDCnvgErr = -65, /* SVD algorithm does not converge. */ + ippStsJPEGHuffTableErr = -64, /* JPEG Huffman table is destroyed. */ + ippStsJPEGDCTRangeErr = -63, /* JPEG DCT coefficient is out of range. */ + ippStsJPEGOutOfBufErr = -62, /* Attempt to access out of the buffer limits. */ + ippStsDrawTextErr = -61, /* System error in the draw text operation. */ + ippStsChannelOrderErr = -60, /* Incorrect order of the destination channels. */ + ippStsZeroMaskValuesErr = -59, /* All values of the mask are equal to zero. */ + ippStsQuadErr = -58, /* The quadrangle is nonconvex or degenerates into triangle, line, or point */ + ippStsRectErr = -57, /* Size of the rectangle region is less than, or equal to 1. */ + ippStsCoeffErr = -56, /* Incorrect values for transformation coefficients. */ + ippStsNoiseValErr = -55, /* Incorrect value for noise amplitude for dithering. */ + ippStsDitherLevelsErr = -54, /* Number of dithering levels is out of range. */ + ippStsNumChannelsErr = -53, /* Number of channels is incorrect, or not supported. */ + ippStsCOIErr = -52, /* COI is out of range. */ + ippStsDivisorErr = -51, /* Divisor is equal to zero, function is aborted. */ + ippStsAlphaTypeErr = -50, /* Illegal type of image compositing operation. */ + ippStsGammaRangeErr = -49, /* Gamma range bounds is less than, or equal to zero. */ + ippStsGrayCoefSumErr = -48, /* Sum of the conversion coefficients must be less than, or equal to 1. */ + ippStsChannelErr = -47, /* Illegal channel number. */ + ippStsToneMagnErr = -46, /* Tone magnitude is less than, or equal to zero. */ + ippStsToneFreqErr = -45, /* Tone frequency is negative, or greater than, or equal to 0.5. */ + ippStsTonePhaseErr = -44, /* Tone phase is negative, or greater than, or equal to 2*PI. */ + ippStsTrnglMagnErr = -43, /* Triangle magnitude is less than, or equal to zero. */ + ippStsTrnglFreqErr = -42, /* Triangle frequency is negative, or greater than, or equal to 0.5. */ + ippStsTrnglPhaseErr = -41, /* Triangle phase is negative, or greater than, or equal to 2*PI. */ + ippStsTrnglAsymErr = -40, /* Triangle asymmetry is less than -PI, or greater than, or equal to PI. */ + ippStsHugeWinErr = -39, /* Kaiser window is too big. */ + ippStsJaehneErr = -38, /* Magnitude value is negative. */ + ippStsStrideErr = -37, /* Stride value is less than the length of the row. */ + ippStsEpsValErr = -36, /* Negative epsilon value. */ + ippStsWtOffsetErr = -35, /* Invalid offset value for wavelet filter. */ + ippStsAnchorErr = -34, /* Anchor point is outside the mask. */ + ippStsMaskSizeErr = -33, /* Invalid mask size. */ + ippStsShiftErr = -32, /* Shift value is less than zero. */ + ippStsSampleFactorErr = -31, /* Sampling factor is less than, or equal to zero. */ + ippStsSamplePhaseErr = -30, /* Phase value is out of range: 0 <= phase < factor. */ + ippStsFIRMRFactorErr = -29, /* MR FIR sampling factor is less than, or equal to zero. */ + ippStsFIRMRPhaseErr = -28, /* MR FIR sampling phase is negative, or greater than, or equal to the sampling factor. */ + ippStsRelFreqErr = -27, /* Relative frequency value is out of range. */ + ippStsFIRLenErr = -26, /* Length of a FIR filter is less than, or equal to zero. */ + ippStsIIROrderErr = -25, /* Order of an IIR filter is not valid. */ + ippStsDlyLineIndexErr = -24, /* Invalid value for the delay line sample index. */ + ippStsResizeFactorErr = -23, /* Resize factor(s) is less than, or equal to zero. */ + ippStsInterpolationErr = -22, /* Invalid interpolation mode. */ + ippStsMirrorFlipErr = -21, /* Invalid flip mode. */ + ippStsMoment00ZeroErr = -20, /* Moment value M(0,0) is too small to continue calculations. */ + ippStsThreshNegLevelErr = -19, /* Negative value of the level in the threshold operation. */ + ippStsThresholdErr = -18, /* Invalid threshold bounds. */ + ippStsContextMatchErr = -17, /* Context parameter does not match the operation. */ + ippStsFftFlagErr = -16, /* Invalid value for the FFT flag parameter. */ + ippStsFftOrderErr = -15, /* Invalid value for the FFT order parameter. */ + ippStsStepErr = -14, /* Step value is not valid. */ + ippStsScaleRangeErr = -13, /* Scale bounds are out of range. */ + ippStsDataTypeErr = -12, /* Data type is incorrect or not supported. */ + ippStsOutOfRangeErr = -11, /* Argument is out of range, or point is outside the image. */ + ippStsDivByZeroErr = -10, /* An attempt to divide by zero. */ + ippStsMemAllocErr = -9, /* Memory allocated for the operation is not enough.*/ + ippStsNullPtrErr = -8, /* Null pointer error. */ + ippStsRangeErr = -7, /* Incorrect values for bounds: the lower bound is greater than the upper bound. */ + ippStsSizeErr = -6, /* Incorrect value for data size. */ + ippStsBadArgErr = -5, /* Incorrect arg/param of the function. */ + ippStsNoMemErr = -4, /* Not enough memory for the operation. */ + ippStsSAReservedErr3 = -3, /* Unknown/unspecified error, -3. */ + ippStsErr = -2, /* Unknown/unspecified error, -2. */ + ippStsSAReservedErr1 = -1, /* Unknown/unspecified error, -1. */ + + /* no errors */ + ippStsNoErr = 0, /* No errors. */ + + /* warnings */ + ippStsNoOperation = 1, /* No operation has been executed. */ + ippStsMisalignedBuf = 2, /* Misaligned pointer in operation in which it must be aligned. */ + ippStsSqrtNegArg = 3, /* Negative value(s) for the argument in the Sqrt function. */ + ippStsInvZero = 4, /* INF result. Zero value was met by InvThresh with zero level. */ + ippStsEvenMedianMaskSize= 5, /* Even size of the Median Filter mask was replaced with the odd one. */ + ippStsDivByZero = 6, /* Zero value(s) for the divisor in the Div function. */ + ippStsLnZeroArg = 7, /* Zero value(s) for the argument in the Ln function. */ + ippStsLnNegArg = 8, /* Negative value(s) for the argument in the Ln function. */ + ippStsNanArg = 9, /* Argument value is not a number. */ + ippStsJPEGMarker = 10, /* JPEG marker in the bitstream. */ + ippStsResFloor = 11, /* All result values are floored. */ + ippStsOverflow = 12, /* Overflow in the operation. */ + ippStsLSFLow = 13, /* Quantized LP synthesis filter stability check is applied at the low boundary of [0,pi]. */ + ippStsLSFHigh = 14, /* Quantized LP synthesis filter stability check is applied at the high boundary of [0,pi]. */ + ippStsLSFLowAndHigh = 15, /* Quantized LP synthesis filter stability check is applied at both boundaries of [0,pi]. */ + ippStsZeroOcc = 16, /* Zero occupation count. */ + ippStsUnderflow = 17, /* Underflow in the operation. */ + ippStsSingularity = 18, /* Singularity in the operation. */ + ippStsDomain = 19, /* Argument is out of the function domain. */ + ippStsNonIntelCpu = 20, /* The target CPU is not Genuine Intel. */ + ippStsCpuMismatch = 21, /* Cannot set the library for the given CPU. */ + ippStsNoIppFunctionFound = 22, /* Application does not contain Intel IPP function calls. */ + ippStsDllNotFoundBestUsed = 23, /* Dispatcher cannot find the newest version of the Intel IPP dll. */ + ippStsNoOperationInDll = 24, /* The function does nothing in the dynamic version of the library. */ + ippStsInsufficientEntropy= 25, /* Generation of the prime/key failed due to insufficient entropy in the random seed and stimulus bit string. */ + ippStsOvermuchStrings = 26, /* Number of destination strings is more than expected. */ + ippStsOverlongString = 27, /* Length of one of the destination strings is more than expected. */ + ippStsAffineQuadChanged = 28, /* 4th vertex of destination quad is not equal to customer's one. */ + ippStsWrongIntersectROI = 29, /* ROI has no intersection with the source or destination ROI. No operation. */ + ippStsWrongIntersectQuad = 30, /* Quadrangle has no intersection with the source or destination ROI. No operation. */ + ippStsSmallerCodebook = 31, /* Size of created codebook is less than the cdbkSize argument. */ + ippStsSrcSizeLessExpected = 32, /* DC: Size of the source buffer is less than the expected one. */ + ippStsDstSizeLessExpected = 33, /* DC: Size of the destination buffer is less than the expected one. */ + ippStsStreamEnd = 34, /* DC: The end of stream processed. */ + ippStsDoubleSize = 35, /* Width or height of image is odd. */ + ippStsNotSupportedCpu = 36, /* The CPU is not supported. */ + ippStsUnknownCacheSize = 37, /* The CPU is supported, but the size of the cache is unknown. */ + ippStsSymKernelExpected = 38, /* The Kernel is not symmetric. */ + ippStsEvenMedianWeight = 39, /* Even weight of the Weighted Median Filter is replaced with the odd one. */ + ippStsWrongIntersectVOI = 40, /* VOI has no intersection with the source or destination volume. No operation. */ + ippStsI18nMsgCatalogInvalid=41, /* Message Catalog is invalid, English message returned. */ + ippStsI18nGetMessageFail = 42, /* Failed to fetch a localized message, English message returned. For more information use errno on Linux* OS and GetLastError on Windows* OS. */ + ippStsWaterfall = 43, /* Cannot load required library, waterfall is used. */ + ippStsPrevLibraryUsed = 44, /* Cannot load required library, previous dynamic library is used. */ + ippStsLLADisabled = 45, /* OpenMP* Low Level Affinity is disabled. */ + ippStsNoAntialiasing = 46, /* The mode does not support antialiasing. */ + ippStsRepetitiveSrcData = 47, /* DC: The source data is too repetitive. */ + ippStsSizeWrn = 48, /* The size does not allow to perform full operation. */ + ippStsFeatureNotSupported = 49, /* Current CPU doesn't support at least 1 of the desired features. */ + ippStsUnknownFeature = 50, /* At least one of the desired features is unknown. */ + ippStsFeaturesCombination = 51, /* Wrong combination of features. */ + ippStsAccurateModeNotSupported = 52 /* Accurate mode is not supported. */ +} IppStatus; + +#define ippStsOk ippStsNoErr + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __IPPTYPES_H__ */ diff --git a/external/crypto_px/include/ippversion.h b/external/crypto_px/include/ippversion.h new file mode 100755 index 0000000000..66dcd6b216 --- /dev/null +++ b/external/crypto_px/include/ippversion.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined( __IPPVERSION_H__ ) +#define __IPPVERSION_H__ + +#define IPP_VERSION_MAJOR 9 +#define IPP_VERSION_MINOR 0 +#define IPP_VERSION_UPDATE 2 + +#define IPP_VERSION_STR "9.0.2" + +#endif /* __IPPVERSION_H__ */ diff --git a/external/crypto_px/sources/include/cpudef.h b/external/crypto_px/sources/include/cpudef.h new file mode 100644 index 0000000000..2bdd6eff07 --- /dev/null +++ b/external/crypto_px/sources/include/cpudef.h @@ -0,0 +1,264 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifndef __CPUDEF_H__ +#define __CPUDEF_H__ + +#include "ippcore.h" + +#if defined( __cplusplus ) +extern "C" { +#endif + +#undef __CDECL +#if defined( _WIN32 ) || defined ( _WIN64 ) + #define __CDECL __cdecl +#else + #define __CDECL +#endif + + +/* Intel CPU informator */ + +typedef struct { + int family; + int stepping; + int model; + int type; + int feature; + int tlb; + int cache; + int mmx; + int freq; + int ssx; + int wni; + int htt; + int pni; + int em64t; + int mni; + int phcores; + int sse41; + int sse42; + int ext_family; + int ext_model; + int movbe_instr; + int avx; + int xsavexgetbv; +} ippIntelCpuId; + +int __CDECL ownGetMaskFeatures( Ipp64u* pFeaturesMask ); +int __CDECL ownGetFeature( Ipp64u MaskOfFeature ); +int __CDECL ipp_is_avx_extension( void ); + +__INT64 __CDECL ipp_get_pentium_counter (void); +int __CDECL ipp_is_mmx_extension (void); +int __CDECL ipp_is_ssx_extension (void); +int __CDECL ipp_is_wni_extension (void); +int __CDECL ipp_is_htt_extension( void ); +int __CDECL ipp_is_pni_extension( void ); +int __CDECL ipp_is_mni_extension( void ); +int __CDECL ipp_is_sse41_extension( void ); +int __CDECL ipp_is_sse42_extension( void ); +int __CDECL ipp_is_movbe( void ); +int __CDECL ipp_get_cores_on_die( void ); +int __CDECL ipp_is_em64t_extension( void ); +int __CDECL ipp_has_cpuid ( void ); +int __CDECL ipp_has_rdtsc( void ); + +void __CDECL ipp_get_pentium_ident ( ippIntelCpuId* cpuid ); +int __CDECL ipp_is_GenuineIntel ( void ); +int __CDECL ipp_max_cpuid_input( void ); +int __CDECL ipp_get_cpuid( int regs[4], int valEAX, int valECX ); +void __CDECL ipp_get_cache_line_size( int* szCacheLine ); + +int __CDECL ipp_isnan( double x ); +int __CDECL ipp_finite( double x ); +int __CDECL ipp_isnan_32f( float x ); +int __CDECL ipp_finite_32f( float x ); +#define ipp_isfinite ipp_finite + +unsigned int __CDECL ipp_control87 ( unsigned int newcw, unsigned int mask ); +unsigned int __CDECL ipp_status87 ( void ); +unsigned int __CDECL ipp_clear87 ( void ); + +unsigned int __CDECL ipp_clear_ssx (void); +/* topology/affinity */ + +/* here are definitions of the CW bits exactly as x87 and ssx have */ + +#define IPP_FPU_MASK_RC 0x0c00 +#define IPP_FPU_MASK_PC 0x0300 +#define IPP_FPU_MASK_RCPC 0x0f00 + +#define IPP_FPU_RC_NEAR 0x0000 +#define IPP_FPU_RC_DOWN 0x0400 +#define IPP_FPU_RC_UP 0x0800 +#define IPP_FPU_RC_ZERO 0x0c00 + +#define IPP_FPU_PC_24 0x0000 +#define IPP_FPU_PC_53 0x0200 +#define IPP_FPU_PC_64 0x0300 + + +unsigned int __CDECL ipp_set_rcpc_fpu( unsigned int newrcpc, unsigned int mask); +void __CDECL ipp_set_cw_fpu( unsigned int cw ); + +#define IPP_SSX_RC_NEAR 0x0000 +#define IPP_SSX_RC_DOWN 0x2000 +#define IPP_SSX_RC_UP 0x4000 +#define IPP_SSX_RC_ZERO 0x6000 +#define IPP_SSX_MASK_RC 0x6000 + + +unsigned int __CDECL ipp_set_rc_ssx( unsigned int newrc ); +void __CDECL ipp_set_cw_ssx( unsigned int cw ); + +/* ================= FPU section ===================== */ + +/* Control bits - disable exceptions */ +#define FPU_EXC_MSK 0x003f /* Exception Masks Mask */ +#define FPU_MSK_INVALID 0x0001 /* invalid operation */ +#define FPU_MSK_DENORMAL 0x0002 /* denormalized operand */ +#define FPU_MSK_ZERODIV 0x0004 /* zero divide */ +#define FPU_MSK_OVERFLOW 0x0008 /* overflow */ +#define FPU_MSK_UNDERFLOW 0x0010 /* underflow */ +#define FPU_MSK_INEXACT 0x0020 /* inexact (precision) */ + +/* Status bits - exceptions */ +#define FPU_EXC_FLG 0x003f /* Exception Flags Mask */ +#define FPU_FLG_INVALID 0x0001 /* invalid operation */ +#define FPU_FLG_DENORMAL 0x0002 /* denormalized operand */ +#define FPU_FLG_ZERODIV 0x0004 /* zero divide */ +#define FPU_FLG_OVERFLOW 0x0008 /* overflow */ +#define FPU_FLG_UNDERFLOW 0x0010 /* underflow */ +#define FPU_FLG_INEXACT 0x0020 /* inexact (precision) */ + +/* Control bits - rounding control */ +#define FPU_RND 0x0c00 /* Rounding Control Mask */ +#define FPU_RND_NEAR 0x0000 /* near */ +#define FPU_RND_DOWN 0x0400 /* down */ +#define FPU_RND_UP 0x0800 /* up */ +#define FPU_RND_CHOP 0x0c00 /* chop */ + +/* Control bits - precision control */ +#define FPU_PRC 0x0300 /* Precision Control Mask */ +#define FPU_PRC_64 0x0300 /* 64 bits */ +#define FPU_PRC_53 0x0200 /* 53 bits */ +#define FPU_PRC_24 0x0000 /* 24 bits */ + +/* Control bits - all masks */ +#define FPU_ALL 0x0f3f /* all masks */ + +/* ============= definition for control/status world ============== */ + +#define FPU_SET_EXC_MASK(mask) ps_set_cw_fpu(mask,FPU_EXC_MSK) +#define FPU_GET_EXC_MASK() (ps_set_cw_fpu(0,0) & FPU_EXC_MSK) + +#define FPU_GET_EXC_FLAG() (ps_get_sw_fpu() & FPU_EXC_FLG) + +#define FPU_SET_RND_MODE(mode) ps_set_cw_fpu(mode,FPU_RND) +#define FPU_GET_RND_MODE() (ps_set_cw_fpu(0,0) & FPU_RND) + +#define FPU_SET_PRC_MODE(mode) ps_set_cw_fpu(mode,FPU_PRC) +#define FPU_GET_PRC_MODE() (ps_set_cw_fpu(0,0) & FPU_PRC) + +unsigned int __CDECL ps_set_cw_fpu( unsigned int newcw, unsigned int msk); +unsigned int __CDECL ps_get_cw_fpu(void); +unsigned int __CDECL ps_get_sw_fpu(void); +unsigned int __CDECL ps_clear_fpu(void); + +/* ======================= SSX section ============================ */ + +/* Control bits - disable exceptions */ +#define SSX_EXC_MSK 0x1f80 /* Disabling exception mask */ +#define SSX_MSK_INEXACT 0x1000 /* precision (inexact) */ +#define SSX_MSK_UNDERFLOW 0x0800 /* underflow */ +#define SSX_MSK_OVERFLOW 0x0400 /* overflow */ +#define SSX_MSK_ZERODIV 0x0200 /* divide by zero */ +#define SSX_MSK_DENORMAL 0x0100 /* denormalized */ +#define SSX_MSK_INVALID 0x0080 /* invalid operation */ + +/* Status bits - exceptions */ +#define SSX_EXC_FLG 0x003f /* Exception flags mask */ +#define SSX_FLG_INEXACT 0x0020 /* precision (inexact) */ +#define SSX_FLG_UNDERFLOW 0x0010 /* underflow */ +#define SSX_FLG_OVERFLOW 0x0008 /* overflow */ +#define SSX_FLG_ZERODIV 0x0004 /* divide by zero */ +#define SSX_FLG_DENORMAL 0x0002 /* denormalized */ +#define SSX_FLG_INVALID 0x0001 /* invalid operation */ + +/* Control bits - rounding control */ +#define SSX_RND 0x6000 /* Rounding control mask */ +#define SSX_RND_NEAR 0x0000 /* near */ +#define SSX_RND_DOWN 0x2000 /* down */ +#define SSX_RND_UP 0x4000 /* up */ +#define SSX_RND_CHOP 0x6000 /* chop */ + +/* Control bits - flush to zero mode */ +#define SSX_FZ 0x8000 /* Flush to zero mask */ +#define SSX_FZ_ENABLE 0x8000 /* flush to zero */ +#define SSX_FZ_DISABLE 0x0000 /* not flush to zero */ + +/* Control bits - denormals are zero mode */ +#define SSX_DAZ 0x0040 /* denorm. are zero mask */ +#define SSX_DAZ_ENABLE 0x0040 /* denorm. are zero */ +#define SSX_DAZ_DISABLE 0x0000 /* denorm. are not zero */ + +#define SSX_ALL 0xffbf /* All masks */ + +/* ==================== definition for SSX register =============== */ + +#define SSX_SET_EXC_MASK(mask) ps_set_ssx(mask,SSX_EXC_MSK) +#define SSX_GET_EXC_MASK() (ps_get_ssx() & SSX_EXC_MSK) + +#define SSX_SET_EXC_FLAG(flag) ps_set_ssx(flag,SSX_EXC_FLG) +#define SSX_GET_EXC_FLAG() (ps_get_ssx() & SSX_EXC_FLG) + +#define SSX_SET_RND_MODE(mode) ps_set_ssx(mode,SSX_RND) +#define SSX_GET_RND_MODE() (ps_get_ssx() & SSX_RND) + +#define SSX_SET_FZ_MODE(mode) ps_set_ssx(mode,SSX_FZ) +#define SSX_GET_FZ_MODE() (ps_get_ssx() & SSX_FZ) + +#define SSX_SET_DAZ_MODE(mode) ps_set_ssx(mode,SSX_DAZ) +#define SSX_GET_DAZ_MODE() (ps_get_ssx() & SSX_DAZ) + +unsigned int __CDECL ps_set_ssx(unsigned int newssx, unsigned int msk); +unsigned int __CDECL ps_get_ssx(void); +unsigned int __CDECL ipp_tst_daz_ssx(void); + +#if defined( __cplusplus ) +} +#endif + +#endif /* __CPUDEF_H__ */ + +/* ////////////////////////// End of file "cpudef.h" //////////////////////// */ diff --git a/external/crypto_px/sources/include/ippver.gen b/external/crypto_px/sources/include/ippver.gen new file mode 100644 index 0000000000..51c4a2d51d --- /dev/null +++ b/external/crypto_px/sources/include/ippver.gen @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_IPP_DYNAMIC) || defined(_CORE) +#include "owndefs.h" + +#ifndef _IPP_VERSION +#define _IPP_VERSION "" +#endif + +#define GET_LIB_NAME01(pref) pref ## GetLibVersion + +#define GET_LIB_NAME(pref) GET_LIB_NAME01(pref) + +#define LIBVERNAME s_libVer + +#define SLIBVERNAME LIBVERNAME +#include "ippverstr.gen" + +#include "cpudef.h" + +extern int ippJumpIndexForMergedDLL; + +IPPFUN( const IppLibraryVersion*, GET_LIB_NAME(LIB_PREFIX), (void) ) +{ + return &LIBVERNAME; +} +#endif diff --git a/external/crypto_px/sources/include/ippver.h b/external/crypto_px/sources/include/ippver.h new file mode 100644 index 0000000000..f72232a335 --- /dev/null +++ b/external/crypto_px/sources/include/ippver.h @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "ippversion.h" +#ifndef BASE_VERSION +#define BASE_VERSION() IPP_VERSION_MAJOR,IPP_VERSION_MINOR,IPP_VERSION_UPDATE +#endif + +#ifndef STR_VERSION + #ifdef IPP_REVISION + #define STR_VERSION() IPP_VERSION_STR " (r" STR( IPP_REVISION ) ")" + #else + #define STR_VERSION() IPP_VERSION_STR " (-)" + #endif +#endif + + +/* ////////////////////////////// End of file /////////////////////////////// */ diff --git a/external/crypto_px/sources/include/ippverstr.gen b/external/crypto_px/sources/include/ippverstr.gen new file mode 100644 index 0000000000..edbcad3309 --- /dev/null +++ b/external/crypto_px/sources/include/ippverstr.gen @@ -0,0 +1,120 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifdef _IPP_OMP_STATIC +#define LIB_THREADS " threaded" +#define CORE_THREADS " (threaded)" +#else +#define LIB_THREADS "" +#define CORE_THREADS "" +#endif + +#define GET_LIBRARY_NAME( cpu, is ) #cpu, IPP_LIB_SHORTNAME() " " is " (" #cpu LIB_THREADS ")" + +static const IppLibraryVersion SLIBVERNAME = { + +/* major, minor, update (ex-majorBuild) */ + BASE_VERSION(), + +#if defined IPP_REVISION + IPP_REVISION, +#else + -1, +#endif /* IPP_REVISION */ + +#if defined( _CORE ) + /*GET_LIBRARY_NAME( core )*/ + "core", + "ippCore" CORE_THREADS + +#elif ( _IPP_ARCH == _IPP_ARCH_IA32 ) || ( _IPP_ARCH == _IPP_ARCH_LP32 ) + #if ( _IPP == _IPP_M5 ) + GET_LIBRARY_NAME( m5, "586" ) + #elif ( _IPP == _IPP_H9 ) + GET_LIBRARY_NAME( h9, "AVX2" ) + #elif ( _IPP == _IPP_G9 ) + GET_LIBRARY_NAME( g9, "AVX" ) + #elif ( _IPP == _IPP_P8 ) + GET_LIBRARY_NAME( p8, "SSE4.2" ) + #elif ( _IPPLP32 == _IPPLP32_S8 ) + GET_LIBRARY_NAME( s8, "Atom" ) + #elif ( _IPP == _IPP_V8 ) + GET_LIBRARY_NAME( v8, "SSSE3" ) + #elif ( _IPP == _IPP_W7 ) + GET_LIBRARY_NAME( w7, "SSE2" ) + #else + GET_LIBRARY_NAME( px, "PX" ) + #endif + +#elif ( _IPP_ARCH == _IPP_ARCH_EM64T ) || ( _IPP_ARCH == _IPP_ARCH_LP64 ) + #if ( _IPP32E == _IPP32E_K0 ) + GET_LIBRARY_NAME( k0, "AVX-512F/CD/BW/DQ/VL" ) + #elif ( _IPP32E == _IPP32E_N0 ) + GET_LIBRARY_NAME( n0, "AVX-512F/CD/ER/PF" ) + #elif ( _IPP32E == _IPP32E_E9 ) + GET_LIBRARY_NAME( e9, "AVX" ) + #elif ( _IPP32E == _IPP32E_L9 ) + GET_LIBRARY_NAME( l9, "AVX2" ) + #elif ( _IPP32E == _IPP32E_Y8 ) + GET_LIBRARY_NAME( y8, "SSE4.2" ) + #elif ( _IPPLP64 == _IPPLP64_N8 ) + GET_LIBRARY_NAME( n8, "Atom" ) + #elif ( _IPP32E == _IPP32E_U8 ) + GET_LIBRARY_NAME( u8, "SSSE3" ) + #elif ( _IPP32E == _IPP32E_M7 ) + GET_LIBRARY_NAME( m7, "SSE3" ) + #else + GET_LIBRARY_NAME( mx, "PX" ) + #endif + +#elif ( _IPP_ARCH == _IPP_ARCH_LRB2 ) + #if ( _IPPLRB == _IPPLRB_BX ) + GET_LIBRARY_NAME( bx, "PX" ) + #elif ( _IPPLRB == _IPPLRB_B2 ) + GET_LIBRARY_NAME( b2, "KNC" ) + #endif + +#else + #error ARCH not supported + +#endif + +#if defined( TICKTOCK ) + "+" +#endif + +/* release Version (by Manager) */ + ,STR_VERSION() + +/* BuildDate (by QA person) */ + ,__DATE__ + +}; diff --git a/external/crypto_px/sources/include/owndefs.h b/external/crypto_px/sources/include/owndefs.h new file mode 100644 index 0000000000..9757893d4e --- /dev/null +++ b/external/crypto_px/sources/include/owndefs.h @@ -0,0 +1,944 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifndef __OWNDEFS_H__ +#define __OWNDEFS_H__ + +#if defined( _VXWORKS ) + #include + #undef NONE +#endif + +#include "ippdefs.h" + +#if defined(__INTEL_COMPILER) || defined(_MSC_VER) + #define __INLINE static __inline +#elif defined( __GNUC__ ) + #define __INLINE static __inline__ +#else + #define __INLINE static +#endif + +#if defined(__INTEL_COMPILER) + #define __RESTRICT restrict +#elif !defined( __RESTRICT ) + #define __RESTRICT +#endif + +#if defined( IPP_W32DLL ) + #if defined( _MSC_VER ) || defined( __INTEL_COMPILER ) + #define IPPFUN(type,name,arg) __declspec(dllexport) type __STDCALL name arg + #else + #define IPPFUN(type,name,arg) extern type __STDCALL name arg + #endif +#else + #define IPPFUN(type,name,arg) extern type __STDCALL name arg +#endif + + +/* structure represeting 128 bit unsigned integer type */ + +typedef struct{ + Ipp64u low; + Ipp64u high; +}Ipp128u; + +#define _IPP_PX 0 /* pure C-code ia32 */ +#define _IPP_M5 1 /* Quark (Pentium) - x86+x87 ia32 */ +#define _IPP_M6 2 /* Pentium MMX - MMX ia32 */ +#define _IPP_A6 4 /* Pentium III - SSE ia32 */ +#define _IPP_W7 8 /* Pentium 4 - SSE2 ia32 */ +#define _IPP_T7 16 /* Pentium with x64 support (Nocona) - SSE3 ia32 */ +#define _IPP_V8 32 /* Merom - SSSE3 ia32 */ +#define _IPP_P8 64 /* Penryn - SSE4.1 + tick for SSE4.2 ia32 */ +#define _IPP_G9 128 /* SandyBridge (GSSE) - AVX ia32 */ +#define _IPP_H9 256 /* Haswell (AVX2) ia32 */ +#define _IPP_I0 512 /* KNL (AVX-512) ia32 */ +#define _IPP_S0 1024 /* SkyLake Xeon (AVX-512) ia32 */ + +#define _IPPXSC_PX 0 +#define _IPPXSC_S1 1 +#define _IPPXSC_S2 2 +#define _IPPXSC_C2 4 + +#define _IPPLRB_PX 0 +#define _IPPLRB_B1 1 +#define _IPPLRB_B2 2 + +#define _IPP64_PX _IPP_PX +#define _IPP64_I7 64 + +#define _IPP32E_PX _IPP_PX /* pure C-code x64 */ +#define _IPP32E_M7 32 /* Pentium with x64 support (Nocona) - SSE3 x64 */ +#define _IPP32E_U8 64 /* Merom - SSSE3 x64 */ +#define _IPP32E_Y8 128 /* Penryn - SSE4.1 + tick for SSE4.2 x64 */ +#define _IPP32E_E9 256 /* SandyBridge (GSSE) - AVX x64 */ +#define _IPP32E_L9 512 /* Haswell (AVX2) x64 */ +#define _IPP32E_N0 1024 /* KNL (AVX-512) x64 */ +#define _IPP32E_K0 2048 /* SkyLake Xeon (AVX-512) x64 */ + +#define _IPPLP32_PX _IPP_PX +#define _IPPLP32_S8 1 /* old Atom (SSSE3+movbe) (Silverthorne) ia32 */ + +#define _IPPLP64_PX _IPP_PX +#define _IPPLP64_N8 1 /* old Atom (SSSE3+movbe) (Silverthorne) x64 */ + +#if defined(__INTEL_COMPILER) || (_MSC_VER >= 1300) + #define __ALIGN8 __declspec (align(8)) + #define __ALIGN16 __declspec (align(16)) +#if !defined( OSX32 ) + #define __ALIGN32 __declspec (align(32)) +#else + #define __ALIGN32 __declspec (align(16)) +#endif + #define __ALIGN64 __declspec (align(64)) +#elif defined (__GNUC__) + #define __ALIGN8 __attribute((aligned(8))) + #define __ALIGN16 __attribute((aligned(16))) + #define __ALIGN32 __attribute((aligned(32))) + #define __ALIGN64 __attribute((aligned(64))) +#else + #define __ALIGN8 + #define __ALIGN16 + #define __ALIGN32 + #define __ALIGN64 +#endif + +#if defined ( _M5 ) /* Quark (Pentium) - x86+x87 ia32 */ + #define _IPP _IPP_M5 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined ( _M6 ) /* Pentium MMX - MMX ia32 */ + #define _IPP _IPP_M6 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _A6 ) /* Pentium III - SSE ia32 */ + #define _IPP _IPP_A6 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _W7 ) /* Pentium 4 - SSE2 ia32 */ + #define _IPP _IPP_W7 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _T7 ) /* Pentium with x64 support (Nocona) - SSE3 ia32 */ + #define _IPP _IPP_T7 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _V8 ) /* Merom - SSSE3 ia32 */ + #define _IPP _IPP_V8 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _P8 ) /* Penryn - SSE4.1 + tick for SSE4.2 ia32 */ + #define _IPP _IPP_P8 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _G9 ) /* SandyBridge (GSSE) - AVX ia32 */ + #define _IPP _IPP_G9 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _H9 ) /* Haswell (AVX2) ia32 */ + #define _IPP _IPP_H9 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _M7 ) /* Pentium with x64 support (Nocona) - SSE3 x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_M7 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _U8 ) /* Merom - SSSE3 x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_U8 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _Y8 ) /* Penryn - SSE4.1 + tick for SSE4.2 x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_Y8 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _E9 ) /* SandyBridge (GSSE) - AVX x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_E9 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _L9 ) /* Haswell (AVX2) x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_L9 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _N0 ) /* KNL (AVX-512) x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_N0 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _K0 ) /* SkyLake Xeon (AVX-512) x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_K0 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _B2 ) /* KNC (MIC) */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_B2 + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _S8 ) /* old Atom (SSSE3+movbe) (Silverthorne) ia32 */ + #define _IPP _IPP_V8 + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_S8 + #define _IPPLP64 _IPPLP64_PX + +#elif defined( _N8 ) /* old Atom (SSSE3+movbe) (Silverthorne) x64 */ + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_U8 + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_N8 + +#else + #define _IPP _IPP_PX + #define _IPP32E _IPP32E_PX + #define _IPPLRB _IPPLRB_PX + #define _IPPLP32 _IPPLP32_PX + #define _IPPLP64 _IPPLP64_PX + +#endif + + +#define _IPP_ARCH_IA32 1 +#define _IPP_ARCH_IA64 2 +#define _IPP_ARCH_EM64T 4 +#define _IPP_ARCH_XSC 8 +#define _IPP_ARCH_LRB 16 +#define _IPP_ARCH_LP32 32 +#define _IPP_ARCH_LP64 64 +#define _IPP_ARCH_LRB2 128 + +#if defined ( _ARCH_IA32 ) + #define _IPP_ARCH _IPP_ARCH_IA32 + +#elif defined( _ARCH_EM64T ) + #define _IPP_ARCH _IPP_ARCH_EM64T + +#elif defined( _ARCH_LRB2 ) + #define _IPP_ARCH _IPP_ARCH_LRB2 + +#elif defined( _ARCH_LP32 ) + #define _IPP_ARCH _IPP_ARCH_LP32 + +#elif defined( _ARCH_LP64 ) + #define _IPP_ARCH _IPP_ARCH_LP64 + +#else + #if defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) + #define _IPP_ARCH _IPP_ARCH_EM64T + + #else + #define _IPP_ARCH _IPP_ARCH_IA32 + + #endif +#endif + +#if ((_IPP_ARCH == _IPP_ARCH_IA32) || (_IPP_ARCH == _IPP_ARCH_LP32)) +__INLINE +Ipp32s IPP_INT_PTR( const void* ptr ) { + union { + void* Ptr; + Ipp32s Int; + } dd; + dd.Ptr = (void*)ptr; + return dd.Int; +} + +__INLINE +Ipp32u IPP_UINT_PTR( const void* ptr ) { + union { + void* Ptr; + Ipp32u Int; + } dd; + dd.Ptr = (void*)ptr; + return dd.Int; +} +#elif ((_IPP_ARCH == _IPP_ARCH_EM64T) || (_IPP_ARCH == _IPP_ARCH_LRB2) || (_IPP_ARCH == _IPP_ARCH_LP64)) +__INLINE +Ipp64s IPP_INT_PTR( const void* ptr ) { + union { + void* Ptr; + Ipp64s Int; + } dd; + dd.Ptr = (void*)ptr; + return dd.Int; +} + +__INLINE +Ipp64u IPP_UINT_PTR( const void* ptr ) { + union { + void* Ptr; + Ipp64u Int; + } dd; + dd.Ptr = (void*)ptr; + return dd.Int; +} +#else + #define IPP_INT_PTR( ptr ) ( (long)(ptr) ) + #define IPP_UINT_PTR( ptr ) ( (unsigned long)(ptr) ) +#endif + +#define IPP_ALIGN_TYPE(type, align) ((align)/sizeof(type)-1) +#define IPP_BYTES_TO_ALIGN(ptr, align) ((-(IPP_INT_PTR(ptr)&((align)-1)))&((align)-1)) +#define IPP_ALIGNED_PTR(ptr, align) (void*)( (unsigned char*)(ptr) + (IPP_BYTES_TO_ALIGN( ptr, align )) ) + +#define IPP_ALIGNED_SIZE(size, align) (((size)+(align)-1)&~((align)-1)) + +#define IPP_MALLOC_ALIGNED_BYTES 64 +#define IPP_MALLOC_ALIGNED_8BYTES 8 +#define IPP_MALLOC_ALIGNED_16BYTES 16 +#define IPP_MALLOC_ALIGNED_32BYTES 32 + +#define IPP_ALIGNED_ARRAY(align,arrtype,arrname,arrlength)\ + char arrname##AlignedArrBuff[sizeof(arrtype)*(arrlength)+IPP_ALIGN_TYPE(char, align)];\ + arrtype *arrname = (arrtype*)IPP_ALIGNED_PTR(arrname##AlignedArrBuff,align) + +#if defined( __cplusplus ) +extern "C" { +#endif + +/* ///////////////////////////////////////////////////////////////////////////// + + IPP Context Identification + + /////////////////////////////////////////////////////////////////////////// */ + +#define IPP_CONTEXT( a, b, c, d) \ + (int)(((unsigned)(a) << 24) | ((unsigned)(b) << 16) | \ + ((unsigned)(c) << 8) | (unsigned)(d)) + +typedef enum { + idCtxUnknown = 0, + idCtxFFT_C_16sc, + idCtxFFT_C_16s, + idCtxFFT_R_16s, + idCtxFFT_C_32fc, + idCtxFFT_C_32f, + idCtxFFT_R_32f, + idCtxFFT_C_64fc, + idCtxFFT_C_64f, + idCtxFFT_R_64f, + idCtxDFT_C_16sc, + idCtxDFT_C_16s, + idCtxDFT_R_16s, + idCtxDFT_C_32fc, + idCtxDFT_C_32f, + idCtxDFT_R_32f, + idCtxDFT_C_64fc, + idCtxDFT_C_64f, + idCtxDFT_R_64f, + idCtxDCTFwd_16s, + idCtxDCTInv_16s, + idCtxDCTFwd_32f, + idCtxDCTInv_32f, + idCtxDCTFwd_64f, + idCtxDCTInv_64f, + idCtxFFT2D_C_32fc, + idCtxFFT2D_R_32f, + idCtxDFT2D_C_32fc, + idCtxDFT2D_R_32f, + idCtxFFT2D_R_32s, + idCtxDFT2D_R_32s, + idCtxDCT2DFwd_32f, + idCtxDCT2DInv_32f, + idCtxMoment64f, + idCtxMoment64s, + idCtxRandUni_8u, + idCtxRandUni_16s, + idCtxRandUni_32f, + idCtxRandUni_64f, + idCtxRandGauss_8u, + idCtxRandGauss_16s, + idCtxRandGauss_32f, + idCtxRandGauss_64f, + idCtxWTFwd_32f, + idCtxWTFwd_8u32f, + idCtxWTFwd_8s32f, + idCtxWTFwd_16u32f, + idCtxWTFwd_16s32f, + idCtxWTFwd2D_32f_C1R, + idCtxWTInv2D_32f_C1R, + idCtxWTFwd2D_32f_C3R, + idCtxWTInv2D_32f_C3R, + idCtxWTInv_32f, + idCtxWTInv_32f8u, + idCtxWTInv_32f8s, + idCtxWTInv_32f16u, + idCtxWTInv_32f16s, + idCtxMDCTFwd_32f, + idCtxMDCTInv_32f, + idCtxMDCTFwd_16s, + idCtxFIRBlock_32f, + idCtxFDP_32f, + idCtxRLMS_32f = IPP_CONTEXT( 'L', 'M', 'S', '1'), + idCtxRLMS32f_16s = IPP_CONTEXT( 'L', 'M', 'S', 0 ), + idCtxIIRAR_32f = IPP_CONTEXT( 'I', 'I', '0', '1'), + idCtxIIRBQ_32f = IPP_CONTEXT( 'I', 'I', '0', '2'), + idCtxIIRAR_32fc = IPP_CONTEXT( 'I', 'I', '0', '3'), + idCtxIIRBQ_32fc = IPP_CONTEXT( 'I', 'I', '0', '4'), + idCtxIIRAR32f_16s = IPP_CONTEXT( 'I', 'I', '0', '5'), + idCtxIIRBQ32f_16s = IPP_CONTEXT( 'I', 'I', '0', '6'), + idCtxIIRAR32fc_16sc = IPP_CONTEXT( 'I', 'I', '0', '7'), + idCtxIIRBQ32fc_16sc = IPP_CONTEXT( 'I', 'I', '0', '8'), + idCtxIIRAR32s_16s = IPP_CONTEXT( 'I', 'I', '0', '9'), + idCtxIIRBQ32s_16s = IPP_CONTEXT( 'I', 'I', '1', '0'), + idCtxIIRAR32sc_16sc = IPP_CONTEXT( 'I', 'I', '1', '1'), + idCtxIIRBQ32sc_16sc = IPP_CONTEXT( 'I', 'I', '1', '2'), + idCtxIIRAR_64f = IPP_CONTEXT( 'I', 'I', '1', '3'), + idCtxIIRBQ_64f = IPP_CONTEXT( 'I', 'I', '1', '4'), + idCtxIIRAR_64fc = IPP_CONTEXT( 'I', 'I', '1', '5'), + idCtxIIRBQ_64fc = IPP_CONTEXT( 'I', 'I', '1', '6'), + idCtxIIRAR64f_32f = IPP_CONTEXT( 'I', 'I', '1', '7'), + idCtxIIRBQ64f_32f = IPP_CONTEXT( 'I', 'I', '1', '8'), + idCtxIIRAR64fc_32fc = IPP_CONTEXT( 'I', 'I', '1', '9'), + idCtxIIRBQ64fc_32fc = IPP_CONTEXT( 'I', 'I', '2', '0'), + idCtxIIRAR64f_32s = IPP_CONTEXT( 'I', 'I', '2', '1'), + idCtxIIRBQ64f_32s = IPP_CONTEXT( 'I', 'I', '2', '2'), + idCtxIIRAR64fc_32sc = IPP_CONTEXT( 'I', 'I', '2', '3'), + idCtxIIRBQ64fc_32sc = IPP_CONTEXT( 'I', 'I', '2', '4'), + idCtxIIRAR64f_16s = IPP_CONTEXT( 'I', 'I', '2', '5'), + idCtxIIRBQ64f_16s = IPP_CONTEXT( 'I', 'I', '2', '6'), + idCtxIIRAR64fc_16sc = IPP_CONTEXT( 'I', 'I', '2', '7'), + idCtxIIRBQ64fc_16sc = IPP_CONTEXT( 'I', 'I', '2', '8'), + idCtxIIRBQDF1_32f = IPP_CONTEXT( 'I', 'I', '2', '9'), + idCtxIIRBQDF164f_32s= IPP_CONTEXT( 'I', 'I', '3', '0'), + idCtxFIRSR_32f = IPP_CONTEXT( 'F', 'I', '0', '1'), + idCtxFIRSR_32fc = IPP_CONTEXT( 'F', 'I', '0', '2'), + idCtxFIRMR_32f = IPP_CONTEXT( 'F', 'I', '0', '3'), + idCtxFIRMR_32fc = IPP_CONTEXT( 'F', 'I', '0', '4'), + idCtxFIRSR32f_16s = IPP_CONTEXT( 'F', 'I', '0', '5'), + idCtxFIRSR32fc_16sc = IPP_CONTEXT( 'F', 'I', '0', '6'), + idCtxFIRMR32f_16s = IPP_CONTEXT( 'F', 'I', '0', '7'), + idCtxFIRMR32fc_16sc = IPP_CONTEXT( 'F', 'I', '0', '8'), + idCtxFIRSR32s_16s = IPP_CONTEXT( 'F', 'I', '0', '9'), + idCtxFIRSR32sc_16sc = IPP_CONTEXT( 'F', 'I', '1', '0'), + idCtxFIRMR32s_16s = IPP_CONTEXT( 'F', 'I', '1', '1'), + idCtxFIRMR32sc_16sc = IPP_CONTEXT( 'F', 'I', '1', '2'), + idCtxFIRSR_64f = IPP_CONTEXT( 'F', 'I', '1', '3'), + idCtxFIRSR_64fc = IPP_CONTEXT( 'F', 'I', '1', '4'), + idCtxFIRMR_64f = IPP_CONTEXT( 'F', 'I', '1', '5'), + idCtxFIRMR_64fc = IPP_CONTEXT( 'F', 'I', '1', '6'), + idCtxFIRSR64f_32f = IPP_CONTEXT( 'F', 'I', '1', '7'), + idCtxFIRSR64fc_32fc = IPP_CONTEXT( 'F', 'I', '1', '8'), + idCtxFIRMR64f_32f = IPP_CONTEXT( 'F', 'I', '1', '9'), + idCtxFIRMR64fc_32fc = IPP_CONTEXT( 'F', 'I', '2', '0'), + idCtxFIRSR64f_32s = IPP_CONTEXT( 'F', 'I', '2', '1'), + idCtxFIRSR64fc_32sc = IPP_CONTEXT( 'F', 'I', '2', '2'), + idCtxFIRMR64f_32s = IPP_CONTEXT( 'F', 'I', '2', '3'), + idCtxFIRMR64fc_32sc = IPP_CONTEXT( 'F', 'I', '2', '4'), + idCtxFIRSR64f_16s = IPP_CONTEXT( 'F', 'I', '2', '5'), + idCtxFIRSR64fc_16sc = IPP_CONTEXT( 'F', 'I', '2', '6'), + idCtxFIRMR64f_16s = IPP_CONTEXT( 'F', 'I', '2', '7'), + idCtxFIRMR64fc_16sc = IPP_CONTEXT( 'F', 'I', '2', '8'), + idCtxFIRSR_16s = IPP_CONTEXT( 'F', 'I', '2', '9'), + idCtxFIRMR_16s = IPP_CONTEXT( 'F', 'I', '3', '0'), + idCtxFIRSRStream_16s= IPP_CONTEXT( 'F', 'I', '3', '1'), + idCtxFIRMRStream_16s= IPP_CONTEXT( 'F', 'I', '3', '2'), + idCtxFIRSRStream_32f= IPP_CONTEXT( 'F', 'I', '3', '3'), + idCtxFIRMRStream_32f= IPP_CONTEXT( 'F', 'I', '3', '4'), + idCtxRLMS32s_16s = IPP_CONTEXT( 'L', 'M', 'S', 'R'), + idCtxCLMS32s_16s = IPP_CONTEXT( 'L', 'M', 'S', 'C'), + idCtxEncode_JPEG2K, + idCtxDES = IPP_CONTEXT( ' ', 'D', 'E', 'S'), + idCtxBlowfish = IPP_CONTEXT( ' ', ' ', 'B', 'F'), + idCtxRijndael = IPP_CONTEXT( ' ', 'R', 'I', 'J'), + idCtxSMS4 = IPP_CONTEXT( 'S', 'M', 'S', '4'), + idCtxTwofish = IPP_CONTEXT( ' ', ' ', 'T', 'F'), + idCtxARCFOUR = IPP_CONTEXT( ' ', 'R', 'C', '4'), + idCtxRC564 = IPP_CONTEXT( 'R', 'C', '5', '1'), + idCtxRC5128 = IPP_CONTEXT( 'R', 'C', '5', '2'), + idCtxSHA1 = IPP_CONTEXT( 'S', 'H', 'S', '1'), + idCtxSHA224 = IPP_CONTEXT( 'S', 'H', 'S', '3'), + idCtxSHA256 = IPP_CONTEXT( 'S', 'H', 'S', '2'), + idCtxSHA384 = IPP_CONTEXT( 'S', 'H', 'S', '4'), + idCtxSHA512 = IPP_CONTEXT( 'S', 'H', 'S', '5'), + idCtxMD5 = IPP_CONTEXT( ' ', 'M', 'D', '5'), + idCtxHMAC = IPP_CONTEXT( 'H', 'M', 'A', 'C'), + idCtxDAA = IPP_CONTEXT( ' ', 'D', 'A', 'A'), + idCtxBigNum = IPP_CONTEXT( 'B', 'I', 'G', 'N'), + idCtxMontgomery = IPP_CONTEXT( 'M', 'O', 'N', 'T'), + idCtxPrimeNumber = IPP_CONTEXT( 'P', 'R', 'I', 'M'), + idCtxPRNG = IPP_CONTEXT( 'P', 'R', 'N', 'G'), + idCtxRSA = IPP_CONTEXT( ' ', 'R', 'S', 'A'), + idCtxRSA_PubKey = IPP_CONTEXT( 'R', 'S', 'A', '0'), + idCtxRSA_PrvKey1 = IPP_CONTEXT( 'R', 'S', 'A', '1'), + idCtxRSA_PrvKey2 = IPP_CONTEXT( 'R', 'S', 'A', '2'), + idCtxDSA = IPP_CONTEXT( ' ', 'D', 'S', 'A'), + idCtxECCP = IPP_CONTEXT( ' ', 'E', 'C', 'P'), + idCtxECCB = IPP_CONTEXT( ' ', 'E', 'C', 'B'), + idCtxECCPPoint = IPP_CONTEXT( 'P', 'E', 'C', 'P'), + idCtxECCBPoint = IPP_CONTEXT( 'P', 'E', 'C', 'B'), + idCtxDH = IPP_CONTEXT( ' ', ' ', 'D', 'H'), + idCtxDLP = IPP_CONTEXT( ' ', 'D', 'L', 'P'), + idCtxCMAC = IPP_CONTEXT( 'C', 'M', 'A', 'C'), + idCtxRFFT2_8u, + idCtxHilbert_32f32fc, + idCtxHilbert_16s32fc, + idCtxHilbert_16s16sc, + idCtxTone_16s, + idCtxTriangle_16s, + idCtxDFTOutOrd_C_32fc, + idCtxDFTOutOrd_C_64fc, + idCtxFFT_C_32sc, + idCtxFFT_C_32s, + idCtxFFT_R_32s, + idCtxFFT_R_16s32s, + idCtxDecodeProgr_JPEG2K, + idCtxWarp_MPEG4, + idCtxQuantInvIntra_MPEG4, + idCtxQuantInvInter_MPEG4, + idCtxQuantIntra_MPEG4, + idCtxQuantInter_MPEG4, + idCtxAnalysisFilter_SBR_C_32f32fc, + idCtxAnalysisFilter_SBR_C_32f, + idCtxAnalysisFilter_SBR_R_32f, + idCtxSynthesisFilter_SBR_C_32fc32f, + idCtxSynthesisFilter_SBR_C_32f, + idCtxSynthesisFilter_SBR_R_32f, + idCtxSynthesisDownFilter_SBR_C_32fc32f, + idCtxSynthesisDownFilter_SBR_C_32f, + idCtxSynthesisDownFilter_SBR_R_32f, + idCtxVLCEncode, + idCtxVLCDecode, + idCtxAnalysisFilter_SBR_C_32s32sc, + idCtxAnalysisFilter_SBR_R_32s, + idCtxSynthesisFilter_SBR_C_32sc32s, + idCtxSynthesisFilter_SBR_R_32s, + idCtxSynthesisDownFilter_SBR_C_32sc32s, + idCtxSynthesisDownFilter_SBR_R_32s, + idCtxSynthesisFilter_PQMF_MP3_32f, + idCtxAnalysisFilter_PQMF_MP3_32f, + idCtxResampleRow, + idCtxAnalysisFilter_SBR_Enc_C_32f32fc, + idCtxSynthesisFilter_DTS_32f, + idCtxFilterBilateralGauss_8u, + idCtxFilterBilateralGaussFast_8u, + idCtxBGF, + idCtxPolyGF, + idCtxRSenc, + idCtxRSdec, + idCtxSnow3g = IPP_CONTEXT( 'S', 'n', 'o', 'w'), + idCtxSnow3gF8, + idCtxSnow3gF9, + idCtxKasumi = IPP_CONTEXT( 'K', 'a', 's', 'u'), + idCtxKasumiF8, + idCtxKasumiF9, + idCtxResizeHannFilter_8u, + idCtxResizeLanczosFilter_8u, + idCtxAESXCBC, + idCtxAESCCM, + idCtxAESGCM, + idCtxMsgCatalog, + idCtxGFP, + idCtxGFPE, + idCtxGFPX, + idCtxGFPXE, + idCtxGFPXQX, + idCtxGFPXQXE, + idCtxGFPEC, + idCtxGFPPoint, + idCtxGFPXEC, + idCtxGFPXECPoint, + idCtxPairing, + idCtxResize_32f, + idCtxResizeYUV420, + idCtxResizeYUV422, + idCtxResize_64f, + idCtxFilterBilateralBorder, + idCtxThresholdAdaptiveGauss, + idCtxHOG, + idCtxFastN, + idCtxHash, + idCtxSM3 +} IppCtxId; + + + + +/* ///////////////////////////////////////////////////////////////////////////// + Helpers + /////////////////////////////////////////////////////////////////////////// */ + +#define IPP_NOERROR_RET() return ippStsNoErr +#define IPP_ERROR_RET( ErrCode ) return (ErrCode) + +#ifdef _IPP_DEBUG + + #define IPP_BADARG_RET( expr, ErrCode )\ + {if (expr) { IPP_ERROR_RET( ErrCode ); }} + +#else + + #define IPP_BADARG_RET( expr, ErrCode ) + +#endif + + + #define IPP_BAD_SIZE_RET( n )\ + IPP_BADARG_RET( (n)<=0, ippStsSizeErr ) + + #define IPP_BAD_STEP_RET( n )\ + IPP_BADARG_RET( (n)<=0, ippStsStepErr ) + + #define IPP_BAD_PTR1_RET( ptr )\ + IPP_BADARG_RET( NULL==(ptr), ippStsNullPtrErr ) + + #define IPP_BAD_PTR2_RET( ptr1, ptr2 )\ + {IPP_BAD_PTR1_RET( ptr1 ); IPP_BAD_PTR1_RET( ptr2 )} + + #define IPP_BAD_PTR3_RET( ptr1, ptr2, ptr3 )\ + {IPP_BAD_PTR2_RET( ptr1, ptr2 ); IPP_BAD_PTR1_RET( ptr3 )} + + #define IPP_BAD_PTR4_RET( ptr1, ptr2, ptr3, ptr4 )\ + {IPP_BAD_PTR2_RET( ptr1, ptr2 ); IPP_BAD_PTR2_RET( ptr3, ptr4 )} + + #define IPP_BAD_ISIZE_RET(roi) \ + IPP_BADARG_RET( ((roi).width<=0 || (roi).height<=0), ippStsSizeErr) + +/* ////////////////////////////////////////////////////////////////////////// */ +/* internal messages */ + +#define MSG_LOAD_DLL_ERR (-9700) /* Error at loading of %s library */ +#define MSG_NO_DLL (-9701) /* No DLLs were found in the Waterfall procedure */ +#define MSG_NO_SHARED (-9702) /* No shared libraries were found in the Waterfall procedure */ + +/* ////////////////////////////////////////////////////////////////////////// */ + + +typedef union { /* double precision */ + Ipp64s hex; + Ipp64f fp; +} IppFP_64f; + +typedef union { /* single precision */ + Ipp32s hex; + Ipp32f fp; +} IppFP_32f; + + +extern const IppFP_32f ippConstantOfNAN_32f; +extern const IppFP_64f ippConstantOfNAN_64f; + +extern const IppFP_32f ippConstantOfINF_32f; +extern const IppFP_64f ippConstantOfINF_64f; +extern const IppFP_32f ippConstantOfINF_NEG_32f; +extern const IppFP_64f ippConstantOfINF_NEG_64f; + +#define NAN_32F (ippConstantOfNAN_32f.fp) +#define NAN_64F (ippConstantOfNAN_64f.fp) +#define INF_32F (ippConstantOfINF_32f.fp) +#define INF_64F (ippConstantOfINF_64f.fp) +#define INF_NEG_32F (ippConstantOfINF_NEG_32f.fp) +#define INF_NEG_64F (ippConstantOfINF_NEG_64f.fp) + +/* ////////////////////////////////////////////////////////////////////////// */ + +typedef enum { + ippunreg=-1, + ippac = 0, + ippcc = 1, + ippch = 2, + ippcp = 3, + ippcv = 4, + ippdc = 5, + ippdi = 6, + ippgen = 7, + ippi = 8, + ippj = 9, + ippm = 10, + ippr = 11, + ipps = 12, + ippsc = 13, + ippsr = 14, + ippvc = 15, + ippvm = 16, + ippmsdk = 17, + ippcpepid = 18, + ippe = 19, + ipprs = 20, + ippsq = 21, + ippnomore +} IppDomain; + +int __CDECL ownGetNumThreads( void ); +int __CDECL ownGetFeature( Ipp64u MaskOfFeature ); /* the main function of tick-tock dispatcher */ + +#ifdef _IPP_DYNAMIC +typedef IppStatus (__STDCALL *DYN_RELOAD)( int ); +void __CDECL ownRegisterLib( IppDomain, DYN_RELOAD ); +void __CDECL ownUnregisterLib( IppDomain ); +#endif + +/* the number of threads available for any ipp function that uses OMP; */ +/* at the ippxx.dll loading time is equal to the number of logical processors, */ +/* and can be changed ONLY externally by library user to any desired number */ +/* by means of ippSetNumThreads() function */ +#define IPP_GET_NUM_THREADS() ( ownGetNumThreads() ) +#define IPP_OMP_NUM_THREADS() num_threads( IPP_GET_NUM_THREADS() ) +#define IPP_OMP_LIMIT_MAX_NUM_THREADS(n) num_threads( IPP_MIN(IPP_GET_NUM_THREADS(),(n))) + + +/* ////////////////////////////////////////////////////////////////////////// */ + +/* Define NULL pointer value */ +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#define UNREFERENCED_PARAMETER(p) (p)=(p) + +#if defined( _IPP_MARK_LIBRARY ) +static char G[] = {73, 80, 80, 71, 101, 110, 117, 105, 110, 101, 243, 193, 210, 207, 215}; +#endif + + +#define STR2(x) #x +#define STR(x) STR2(x) +#define MESSAGE( desc )\ + message(__FILE__ "(" STR(__LINE__) "):" #desc) + +/* +// endian definition +*/ +#define IPP_LITTLE_ENDIAN (0) +#define IPP_BIG_ENDIAN (1) + +#if defined( _IPP_LE ) + #define IPP_ENDIAN IPP_LITTLE_ENDIAN + +#elif defined( _IPP_BE ) + #define IPP_ENDIAN IPP_BIG_ENDIAN + +#else + #if defined( __ARMEB__ ) + #define IPP_ENDIAN IPP_BIG_ENDIAN + + #else + #define IPP_ENDIAN IPP_LITTLE_ENDIAN + + #endif +#endif + + +/* ////////////////////////////////////////////////////////////////////////// */ + +/* intrinsics */ +#if (_IPP >= _IPP_A6) || (_IPP32E >= _IPP32E_M7) + #if defined(__INTEL_COMPILER) || (_MSC_VER >= 1300) + #if (_IPP == _IPP_A6) + #include "xmmintrin.h" + #elif (_IPP == _IPP_W7) + #if defined(__INTEL_COMPILER) + #include "emmintrin.h" + #else + #undef _W7 + #include "emmintrin.h" + #define _W7 + #endif + #define _mm_loadu _mm_loadu_si128 + #elif (_IPP == _IPP_T7) || (_IPP32E == _IPP32E_M7) + #if defined(__INTEL_COMPILER) + #include "pmmintrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER >= 140050110) + #include "intrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER < 140050110) + #include "emmintrin.h" + #define _mm_loadu _mm_loadu_si128 + #endif + #elif (_IPP == _IPP_V8) || (_IPP32E == _IPP32E_U8) + #if defined(__INTEL_COMPILER) + #include "tmmintrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER >= 140050110) + #include "intrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER < 140050110) + #include "emmintrin.h" + #define _mm_loadu _mm_loadu_si128 + #endif + #elif (_IPP == _IPP_P8) || (_IPP32E == _IPP32E_Y8) + #if defined(__INTEL_COMPILER) + #include "smmintrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER >= 140050110) + #include "intrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER < 140050110) + #include "emmintrin.h" + #define _mm_loadu _mm_loadu_si128 + #endif + #elif (_IPP >= _IPP_G9) || (_IPP32E >= _IPP32E_E9) + #if defined(__INTEL_COMPILER) + #include "immintrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER >= 160021003) + #include "immintrin.h" + #define _mm_loadu _mm_lddqu_si128 + #endif + #endif + #endif +#elif (_IPPLP32 >= _IPPLP32_S8) || (_IPPLP64 >= _IPPLP64_N8) + #if defined(__INTEL_COMPILER) + #include "tmmintrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER >= 140050110) + #include "intrin.h" + #define _mm_loadu _mm_lddqu_si128 + #elif (_MSC_FULL_VER < 140050110) + #include "emmintrin.h" + #define _mm_loadu _mm_loadu_si128 + #endif +#elif (_IPPLRB >= _IPPLRB_B2) + #if defined(__INTEL_COMPILER) || defined(_REF_LIB) + #include "immintrin.h" + #endif +#endif + +// **** intrinsics for bit casting **** +#if defined(__INTEL_COMPILER) +extern unsigned int __intel_castf32_u32(float val); +extern float __intel_castu32_f32(unsigned int val); +extern unsigned __int64 __intel_castf64_u64(double val); +extern double __intel_castu64_f64(unsigned __int64 val); + #define __CAST_32f32u(val) __intel_castf32_u32((Ipp32f)val) + #define __CAST_32u32f(val) __intel_castu32_f32((Ipp32u)val) + #define __CAST_64f64u(val) __intel_castf64_u64((Ipp64f)val) + #define __CAST_64u64f(val) __intel_castu64_f64((Ipp64u)val) +#else + #define __CAST_32f32u(val) ( *((Ipp32u*)&val) ) + #define __CAST_32u32f(val) ( *((Ipp32f*)&val) ) + #define __CAST_64f64u(val) ( *((Ipp64u*)&val) ) + #define __CAST_64u64f(val) ( *((Ipp64f*)&val) ) +#endif + + +// short names for vector registers casting +#define _pd2ps _mm_castpd_ps +#define _ps2pd _mm_castps_pd +#define _pd2pi _mm_castpd_si128 +#define _pi2pd _mm_castsi128_pd +#define _ps2pi _mm_castps_si128 +#define _pi2ps _mm_castsi128_ps + +#define _ypd2ypi _mm256_castpd_si256 +#define _ypi2ypd _mm256_castsi256_pd +#define _yps2ypi _mm256_castps_si256 +#define _ypi2yps _mm256_castsi256_ps +#define _ypd2yps _mm256_castpd_ps +#define _yps2ypd _mm256_castps_pd + +#define _yps2ps _mm256_castps256_ps128 +#define _ypi2pi _mm256_castsi256_si128 +#define _ypd2pd _mm256_castpd256_pd128 +#define _ps2yps _mm256_castps128_ps256 +#define _pi2ypi _mm256_castsi128_si256 +#define _pd2ypd _mm256_castpd128_pd256 + + +#if defined(__INTEL_COMPILER) +#define __IVDEP ivdep +#else +#define __IVDEP message("message :: 'ivdep' is not defined") +#endif +//usage: #pragma __IVDEP + +/* ////////////////////////////////////////////////////////////////////////// + _IPP_DATA shoul be defined only: + - if compile not merged library + - only for 1 CPU for merged library to avoid data duplication +*/ +#if defined( _MERGED_BLD ) && ( defined(_G9) || defined(_E9) ) /* compile data only for g9 and e9 CPU */ + #define _IPP_DATA 1 +#elif !defined( _MERGED_BLD ) /* compile data if it isn't merged library */ + #define _IPP_DATA 1 +#endif + + +#if defined( __cplusplus ) +} +#endif + +#endif /* __OWNDEFS_H__ */ + diff --git a/external/crypto_px/sources/ippcp/src/owncp.h b/external/crypto_px/sources/ippcp/src/owncp.h new file mode 100644 index 0000000000..ec0e3b7d83 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/owncp.h @@ -0,0 +1,149 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#ifndef __OWNCP_H__ +#define __OWNCP_H__ + +#ifndef __OWNDEFS_H__ + #include "owndefs.h" +#endif + +#ifndef __IPPCP_H__ + #include "ippcp.h" +#endif + +#pragma warning( disable : 4324) + +/* ippCP length */ +typedef int cpSize; + +/* +// common macros & definitions +*/ + +/* size of cache line (bytes) */ +#define CACHE_LINE_SIZE (64) +#define LOG_CACHE_LINE_SIZE (6) + +/* swap data & pointers */ +#define SWAP_PTR(ATYPE, pX,pY) { ATYPE* aPtr=(pX); (pX)=(pY); (pY)=aPtr; } +#define SWAP(x,y) {(x)^=(y); (y)^=(x); (x)^=(y);} + +/* alignment value */ +#define ALIGN_VAL ((int)sizeof(void*)) + +/* bitsize */ +#define BYTESIZE (8) +#define BITSIZE(x) ((int)(sizeof(x)*BYTESIZE)) + +/* bit length -> byte/word length conversion */ +#define BITS2WORD8_SIZE(x) (((x)+ 7)>>3) +#define BITS2WORD16_SIZE(x) (((x)+15)>>4) +#define BITS2WORD32_SIZE(x) (((x)+31)>>5) +#define BITS2WORD64_SIZE(x) (((x)+63)>>6) + +/* WORD and DWORD manipulators */ +#define LODWORD(x) ((Ipp32u)(x)) +#define HIDWORD(x) ((Ipp32u)(((Ipp64u)(x) >>32) & 0xFFFFFFFF)) + +#define MAKEHWORD(bLo,bHi) ((Ipp16u)(((Ipp8u)(bLo)) | ((Ipp16u)((Ipp8u)(bHi))) << 8)) +#define MAKEWORD(hLo,hHi) ((Ipp32u)(((Ipp16u)(hLo)) | ((Ipp32u)((Ipp16u)(hHi))) << 16)) +#define MAKEDWORD(wLo,wHi) ((Ipp64u)(((Ipp32u)(wLo)) | ((Ipp64u)((Ipp32u)(wHi))) << 32)) + +/* extract byte */ +#define EBYTE(w,n) ((Ipp8u)((w) >> (8 * (n)))) + +/* hexString <-> Ipp32u conversion */ +#define HSTRING_TO_U32(ptrByte) \ + (((ptrByte)[0]) <<24) \ + +(((ptrByte)[1]) <<16) \ + +(((ptrByte)[2]) <<8) \ + +((ptrByte)[3]) +#define U32_TO_HSTRING(ptrByte, x) \ + (ptrByte)[0] = (Ipp8u)((x)>>24); \ + (ptrByte)[1] = (Ipp8u)((x)>>16); \ + (ptrByte)[2] = (Ipp8u)((x)>>8); \ + (ptrByte)[3] = (Ipp8u)(x) + +/* 32- and 64-bit masks for MSB of nbits-sequence */ +#define MAKEMASK32(nbits) (0xFFFFFFFF >>((32 - ((nbits)&0x1F)) &0x1F)) +#define MAKEMASK64(nbits) (0xFFFFFFFFFFFFFFFF >>((64 - ((nbits)&0x3F)) &0x3F)) + +/* Logical Shifts (right and left) of WORD */ +#define LSR32(x,nBits) ((x)>>(nBits)) +#define LSL32(x,nBits) ((x)<<(nBits)) + +/* Rorate (right and left) of WORD */ +#if defined(_MSC_VER) +# include +# define ROR32(x, nBits) _lrotr((x),(nBits)) +# define ROL32(x, nBits) _lrotl((x),(nBits)) +#else +# define ROR32(x, nBits) (LSR32((x),(nBits)) | LSL32((x),32-(nBits))) +# define ROL32(x, nBits) ROR32((x),(32-(nBits))) +#endif + +/* Logical Shifts (right and left) of DWORD */ +#define LSR64(x,nBits) ((x)>>(nBits)) +#define LSL64(x,nBits) ((x)<<(nBits)) + +/* Rorate (right and left) of DWORD */ +#define ROR64(x, nBits) (LSR64((x),(nBits)) | LSL64((x),64-(nBits))) +#define ROL64(x, nBits) ROR64((x),(64-(nBits))) + +/* change endian */ +#if defined(_MSC_VER) +# define ENDIANNESS(x) _byteswap_ulong((x)) +# define ENDIANNESS32(x) ENDIANNESS((x)) +# define ENDIANNESS64(x) _byteswap_uint64((x)) +#else +# define ENDIANNESS(x) ((ROR32((x), 24) & 0x00ff00ff) | (ROR32((x), 8) & 0xff00ff00)) +# define ENDIANNESS32(x) ENDIANNESS((x)) +# define ENDIANNESS64(x) MAKEDWORD(ENDIANNESS(HIDWORD((x))), ENDIANNESS(LODWORD((x)))) +#endif + +#define IPP_MAKE_MULTIPLE_OF_8(x) ((x) = ((x)+7)&(~7)) +#define IPP_MAKE_MULTIPLE_OF_16(x) ((x) = ((x)+15)&(~15)) + +/* 64-bit constant */ +#if !defined(__GNUC__) + #define CONST_64(x) (x) /*(x##i64)*/ +#else + #define CONST_64(x) (x##LL) +#endif + +/* copy under mask */ +#define MASKED_COPY_BNU(dst, mask, src1, src2, len) { \ + cpSize i; \ + for(i=0; i<(len); i++) (dst)[i] = ((mask) & (src1)[i]) | (~(mask) & (src2)[i]); \ +} + +#endif /* __OWNCP_H__ */ diff --git a/external/crypto_px/sources/ippcp/src/pcpaesauthcmacca.c b/external/crypto_px/sources/ippcp/src/pcpaesauthcmacca.c new file mode 100644 index 0000000000..8c4d24bc5e --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpaesauthcmacca.c @@ -0,0 +1,396 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpcmac.h" +#include "pcpaesm.h" +#include "pcptool.h" + +#include "pcprijtables.h" + +/*F* +// Name: ippsAES_CMACGetSize +// +// Purpose: Returns size of AES-CMAC context (in bytes). +// +// Returns: Reason: +// ippStsNullPtrErr pSzie == NULL +// ippStsNoErr no errors +// +// Parameters: +// pSize pointer to the AES-CMAC size of context +// +*F*/ +static int cpSizeofCtx_AESCMAC(void) +{ + return sizeof(IppsAES_CMACState) + AESCMAC_ALIGNMENT-1; +} + +IPPFUN(IppStatus, ippsAES_CMACGetSize,(int* pSize)) +{ + /* test size's pointer */ + IPP_BAD_PTR1_RET(pSize); + + *pSize = cpSizeofCtx_AESCMAC(); + + return ippStsNoErr; +} + + +/*F* +// Name: ippsAES_CMACInit +// +// Purpose: Init AES-CMAC context. +// +// Returns: Reason: +// ippStsNullPtrErr pCtx == NULL +// ippStsMemAllocErr size of buffer is not match fro operation +// ippStsLengthErr keyLen != 16 +// keyLen != 24 +// keyLen != 32 +// ippStsNoErr no errors +// +// Parameters: +// pKey pointer to the secret key +// keyLen length of secret key +// pCtx pointer to the CMAC context +// ctxSize available size (in bytes) of buffer above +// +*F*/ +static +void init(IppsAES_CMACState* pCtx) +{ + /* buffer is empty */ + CMAC_INDX(pCtx) = 0; + /* zeros MAC */ + PaddBlock(0, CMAC_MAC(pCtx), MBS_RIJ128); +} + +static +void LogicalLeftSift16(const Ipp8u* pSrc, Ipp8u* pDst) +{ + Ipp32u carry = 0; + int n; + for(n=0; n<16; n++) { + Ipp32u x = pSrc[16-1-n] + pSrc[16-1-n] + carry; + pDst[16-1-n] = (Ipp8u)x; + carry = (x>>8) & 0xFF; + } +} + +IPPFUN(IppStatus, ippsAES_CMACInit,(const Ipp8u* pKey, int keyLen, IppsAES_CMACState* pCtx, int ctxSize)) +{ + /* test pCtx pointer */ + IPP_BAD_PTR1_RET(pCtx); + + /* test available size of context buffer */ + IPP_BADARG_RET(ctxSize>7)) & 0x87); /* ^ Rb changed for constant time execution */ + + /* precompute k2 subkey */ + msb = (CMAC_K1(pCtx))[0]; + LogicalLeftSift16(CMAC_K1(pCtx),CMAC_K2(pCtx)); + (CMAC_K2(pCtx))[MBS_RIJ128-1] ^= (Ipp8u)((0-(msb>>7)) & 0x87); /* ^ Rb changed for constant time execution */ + } + + return sts; + } +} + + +/*F* +// Name: ippsAES_CMACUpdate +// +// Purpose: Updates intermadiate digest based on input stream. +// +// Returns: Reason: +// ippStsNullPtrErr pSrc == NULL +// pCtx == NULL +// ippStsContextMatchErr !VALID_AESCMAC_ID() +// ippStsLengthErr len <0 +// ippStsNoErr no errors +// +// Parameters: +// pSrc pointer to the input stream +// len input stream length +// pCtx pointer to the CMAC context +// +*F*/ +static +void AES_CMAC_processing(Ipp8u* pDigest, const Ipp8u* pSrc, int processedLen, const IppsAESSpec* pAES) +{ + /* setup encoder method */ + RijnCipher encoder = RIJ_ENCODER(pAES); + + while(processedLen) { + ((Ipp32u*)pDigest)[0] ^= ((Ipp32u*)pSrc)[0]; + ((Ipp32u*)pDigest)[1] ^= ((Ipp32u*)pSrc)[1]; + ((Ipp32u*)pDigest)[2] ^= ((Ipp32u*)pSrc)[2]; + ((Ipp32u*)pDigest)[3] ^= ((Ipp32u*)pSrc)[3]; + + encoder(pDigest, pDigest, RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + + pSrc += MBS_RIJ128; + processedLen -= MBS_RIJ128; + } +} + +IPPFUN(IppStatus, ippsAES_CMACUpdate,(const Ipp8u* pSrc, int len, IppsAES_CMACState* pCtx)) +{ + int processedLen; + + /* test context pointer */ + IPP_BAD_PTR1_RET(pCtx); + /* use aligned context */ + pCtx = (IppsAES_CMACState*)( IPP_ALIGNED_PTR(pCtx, AESCMAC_ALIGNMENT) ); + + /* test ID */ + IPP_BADARG_RET(!VALID_AESCMAC_ID(pCtx), ippStsContextMatchErr); + /* test input message and it's length */ + IPP_BADARG_RET((len<0 && pSrc), ippStsLengthErr); + /* test source pointer */ + IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr); + + if(!len) + return ippStsNoErr; + + { + /* + // test internal buffer filling + */ + if(CMAC_INDX(pCtx)) { + /* copy from input stream to the internal buffer as match as possible */ + processedLen = IPP_MIN(len, (MBS_RIJ128 - CMAC_INDX(pCtx))); + CopyBlock(pSrc, CMAC_BUFF(pCtx)+CMAC_INDX(pCtx), processedLen); + + /* internal buffer filling */ + CMAC_INDX(pCtx) += processedLen; + + /* update message pointer and length */ + pSrc += processedLen; + len -= processedLen; + + if(!len) + return ippStsNoErr; + + /* update CMAC if buffer full but not the last */ + if(MBS_RIJ128==CMAC_INDX(pCtx) ) { + const IppsAESSpec* pAES = &CMAC_CIPHER(pCtx); + /* setup encoder method */ + RijnCipher encoder = RIJ_ENCODER(pAES); + XorBlock16(CMAC_BUFF(pCtx), CMAC_MAC(pCtx), CMAC_MAC(pCtx)); + + encoder(CMAC_MAC(pCtx), CMAC_MAC(pCtx), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + + CMAC_INDX(pCtx) = 0; + } + } + + /* + // main part + */ + processedLen = len & ~(MBS_RIJ128-1); + if(!(len & (MBS_RIJ128-1))) + processedLen -= MBS_RIJ128; + if(processedLen) { + const IppsAESSpec* pAES = &CMAC_CIPHER(pCtx); + + AES_CMAC_processing(CMAC_MAC(pCtx), pSrc, processedLen, pAES); + + /* update message pointer and length */ + pSrc += processedLen; + len -= processedLen; + } + + /* + // remaind + */ + if(len) { + CopyBlock(pSrc, (Ipp8u*)(&CMAC_BUFF(pCtx)), len); + /* update internal buffer filling */ + CMAC_INDX(pCtx) += len; + } + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsAES_CMACFinal +// +// Purpose: Stop message digesting and return MD. +// +// Returns: Reason: +// ippStsNullPtrErr pMD == NULL +// pCtx == NULL +// ippStsContextMatchErr !VALID_AESCMAC_ID() +// ippStsLengthErr MBS_RIJ128 < mdLen <1 +// ippStsNoErr no errors +// +// Parameters: +// pMD pointer to the output message digest +// mdLen requested length of the message digest +// pCtx pointer to the CMAC context +// +*F*/ +IPPFUN(IppStatus, ippsAES_CMACFinal,(Ipp8u* pMD, int mdLen, IppsAES_CMACState* pCtx)) +{ + /* test context pointer and ID */ + IPP_BAD_PTR1_RET(pCtx); + /* use aligned context */ + pCtx = (IppsAES_CMACState*)( IPP_ALIGNED_PTR(pCtx, AESCMAC_ALIGNMENT) ); + + IPP_BADARG_RET(!VALID_AESCMAC_ID(pCtx), ippStsContextMatchErr); + /* test DAC pointer */ + IPP_BAD_PTR1_RET(pMD); + IPP_BADARG_RET((mdLen<1)||(MBS_RIJ128idCtx) +#define AESGCM_STATE(stt) ((stt)->state) + +#define AESGCM_IV_LEN(stt) ((stt)->ivLen) +#define AESGCM_AAD_LEN(stt) ((stt)->aadLen) +#define AESGCM_TXT_LEN(stt) ((stt)->txtLen) + +#define AESGCM_BUFLEN(stt) ((stt)->bufLen) +#define AESGCM_COUNTER(stt) ((stt)->counter) +#define AESGCM_ECOUNTER0(stt) ((stt)->ecounter0) +#define AESGCM_ECOUNTER(stt) ((stt)->ecounter) +#define AESGCM_GHASH(stt) ((stt)->ghash) + +#define AESGCM_HASH(stt) ((stt)->hashFun) +#define AESGCM_AUTH(stt) ((stt)->authFun) +#define AESGCM_ENC(stt) ((stt)->encFun) +#define AESGCM_DEC(stt) ((stt)->decFun) + +#define AESGCM_CIPHER(stt) (IppsAESSpec*)(&((stt)->cipher)) + +#define AESGCM_HKEY(stt) ((stt)->multiplier) +#define AESGCM_CPWR(stt) ((stt)->multiplier) +#define AES_GCM_MTBL(stt) ((stt)->multiplier) + +#define AESGCM_VALID_ID(stt) (AESGCM_ID((stt))==idCtxAESGCM) + + +__INLINE void IncrementCounter32(Ipp8u* pCtr) +{ + int i; + for(i=BLOCK_SIZE-1; i>=CTR_POS && 0==(Ipp8u)(++pCtr[i]); i--) ; +} + + +void AesGcmPrecompute_table2K(Ipp8u* pPrecomputeData, const Ipp8u* pHKey); +void AesGcmMulGcm_table2K(Ipp8u* pGhash, const Ipp8u* pHkey, const void* pParam); +void AesGcmAuth_table2K(Ipp8u* pGhash, const Ipp8u* pSrc, int len, const Ipp8u* pHkey, const void* pParam); +void wrpAesGcmEnc_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx); +void wrpAesGcmDec_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx); + +extern const Ipp16u AesGcmConst_table[256]; /* precomputed reduction table */ + +#endif /* _CP_AESAUTH_GCM_H*/ diff --git a/external/crypto_px/sources/ippcp/src/pcpaesauthgcmca.c b/external/crypto_px/sources/ippcp/src/pcpaesauthgcmca.c new file mode 100644 index 0000000000..c48b66f302 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpaesauthgcmca.c @@ -0,0 +1,731 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" + +#include "pcpaesauthgcm.h" +#include "pcptool.h" + +#include "pcprijtables.h" + +/*F* +// Name: ippsAES_GCMGetSize +// +// Purpose: Returns size of AES_GCM state (in bytes). +// +// Returns: Reason: +// ippStsNullPtrErr pSize == NULL +// ippStsNoErr no errors +// +// Parameters: +// pSize pointer to size of context +// +*F*/ +static int cpSizeofCtx_AESGCM(void) +{ + int precomp_size; + + precomp_size = PRECOMP_DATA_SIZE_FAST2K; + + /* decrease precomp_size as soon as BLOCK_SIZE bytes already reserved in context */ + precomp_size -= BLOCK_SIZE; + + return sizeof(IppsAES_GCMState) + +precomp_size + +AESGCM_ALIGNMENT-1; +} + +IPPFUN(IppStatus, ippsAES_GCMGetSize,(int* pSize)) +{ + /* test size's pointer */ + IPP_BAD_PTR1_RET(pSize); + + *pSize = cpSizeofCtx_AESGCM(); + + return ippStsNoErr; +} + + +/*F* +// Name: ippsAES_GCMReset +// +// Purpose: Resets AES_GCM context. +// +// Returns: Reason: +// ippStsNullPtrErr pState== NULL +// ippStsContextMatchErr pState points on invalid context +// ippStsNoErr no errors +// +// Parameters: +// pState pointer to the context +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMReset,(IppsAES_GCMState* pState)) +{ + /* test pState pointer */ + IPP_BAD_PTR1_RET(pState); + + /* use aligned context */ + pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) ); + /* test context validity */ + IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr); + + /* reset GCM */ + AESGCM_STATE(pState) = GcmInit; + AESGCM_IV_LEN(pState) = CONST_64(0); + AESGCM_AAD_LEN(pState) = CONST_64(0); + AESGCM_TXT_LEN(pState) = CONST_64(0); + + AESGCM_BUFLEN(pState) = 0; + PaddBlock(0, AESGCM_COUNTER(pState), BLOCK_SIZE); + PaddBlock(0, AESGCM_ECOUNTER(pState), BLOCK_SIZE); + PaddBlock(0, AESGCM_ECOUNTER0(pState), BLOCK_SIZE); + PaddBlock(0, AESGCM_GHASH(pState), BLOCK_SIZE); + + return ippStsNoErr; +} + + +/*F* +// Name: ippsAES_GCMInit +// +// Purpose: Init AES_GCM context for future usage. +// +// Returns: Reason: +// ippStsNullPtrErr pState == NULL +// ippStsMemAllocErr size of buffer is not match fro operation +// ippStsLengthErr keyLen != 16 && +// != 24 && +// != 32 +// ippStsNoErr no errors +// +// Parameters: +// pKey pointer to the secret key +// keyLen length of secret key +// pState pointer to the AES-GCM context +// ctxSize available size (in bytes) of buffer above +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMInit,(const Ipp8u* pKey, int keyLen, IppsAES_GCMState* pState, int ctxSize)) +{ + /* test pCtx pointer */ + IPP_BAD_PTR1_RET(pState); + + /* test available size of context buffer */ + IPP_BADARG_RET(ctxSize0 +// ippStsContextMatchErr !AESGCM_VALID_ID() +// ippStsLengthErr ivLen <0 +// ippStsBadArgErr illegal sequence call +// ippStsNoErr no errors +// +// Parameters: +// pIV pointer to the IV +// ivLen length of IV (it could be 0) +// pState pointer to the context +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMProcessIV,(const Ipp8u* pIV, int ivLen, IppsAES_GCMState* pState)) +{ + /* test pState pointer */ + IPP_BAD_PTR1_RET(pState); + + /* test IV pointer and length */ + IPP_BADARG_RET(ivLen && !pIV, ippStsNullPtrErr); + IPP_BADARG_RET(ivLen<0, ippStsLengthErr); + + /* use aligned context */ + pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) ); + /* test context validity */ + IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr); + + IPP_BADARG_RET(!(GcmInit==AESGCM_STATE(pState) || GcmIVprocessing==AESGCM_STATE(pState)), ippStsBadArgErr); + + /* switch IVprocessing on */ + AESGCM_STATE(pState) = GcmIVprocessing; + + /* test if buffer is not empty */ + if(AESGCM_BUFLEN(pState)) { + int locLen = IPP_MIN(ivLen, BLOCK_SIZE-AESGCM_BUFLEN(pState)); + XorBlock(pIV, AESGCM_COUNTER(pState)+AESGCM_BUFLEN(pState), AESGCM_COUNTER(pState)+AESGCM_BUFLEN(pState), locLen); + AESGCM_BUFLEN(pState) += locLen; + + /* if buffer full */ + if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) { + MulGcm_ ghashFunc = AESGCM_HASH(pState); + ghashFunc(AESGCM_COUNTER(pState), AESGCM_HKEY(pState), AesGcmConst_table); + AESGCM_BUFLEN(pState) = 0; + } + + AESGCM_IV_LEN(pState) += locLen; + pIV += locLen; + ivLen -= locLen; + } + + /* process main part of IV */ + { + int lenBlks = ivLen & (-BLOCK_SIZE); + if(lenBlks) { + Auth_ authFunc = AESGCM_AUTH(pState); + + authFunc(AESGCM_COUNTER(pState), pIV, lenBlks, AESGCM_HKEY(pState), AesGcmConst_table); + + AESGCM_IV_LEN(pState) += lenBlks; + pIV += lenBlks; + ivLen -= lenBlks; + } + } + + /* copy the rest of IV into the buffer */ + if(ivLen) { + XorBlock(pIV, AESGCM_COUNTER(pState), AESGCM_COUNTER(pState), ivLen); + AESGCM_IV_LEN(pState) += ivLen; + AESGCM_BUFLEN(pState) += ivLen; + } + + return ippStsNoErr; +} + + +/*F* +// Name: ippsAES_GCMProcessAAD +// +// Purpose: AAD processing. +// +// Returns: Reason: +// ippStsNullPtrErr pState == NULL +// pAAD == NULL, aadLen>0 +// ippStsContextMatchErr !AESGCM_VALID_ID() +// ippStsLengthErr aadLen <0 +// ippStsBadArgErr illegal sequence call +// ippStsNoErr no errors +// +// Parameters: +// pAAD pointer to the AAD +// aadlen length of AAD (it could be 0) +// pState pointer to the context +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMProcessAAD,(const Ipp8u* pAAD, int aadLen, IppsAES_GCMState* pState)) +{ + /* test pState pointer */ + IPP_BAD_PTR1_RET(pState); + /* use aligned context */ + pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) ); + /* test if context is valid */ + IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr); + + /* test AAD pointer and length */ + IPP_BADARG_RET(aadLen && !pAAD, ippStsNullPtrErr); + IPP_BADARG_RET(aadLen<0, ippStsLengthErr); + + IPP_BADARG_RET(!(GcmIVprocessing==AESGCM_STATE(pState) || GcmAADprocessing==AESGCM_STATE(pState)), ippStsBadArgErr); + + { + /* get method */ + MulGcm_ hashFunc = AESGCM_HASH(pState); + + if( GcmIVprocessing==AESGCM_STATE(pState) ) { + IPP_BADARG_RET(0==AESGCM_IV_LEN(pState), ippStsBadArgErr); + + /* complete IV processing */ + if(CTR_POS==AESGCM_IV_LEN(pState)) { + /* apply special format if IV length is 12 bytes */ + AESGCM_COUNTER(pState)[12] = 0; + AESGCM_COUNTER(pState)[13] = 0; + AESGCM_COUNTER(pState)[14] = 0; + AESGCM_COUNTER(pState)[15] = 1; + } + else { + /* process the rest of IV */ + if(AESGCM_BUFLEN(pState)) + hashFunc(AESGCM_COUNTER(pState), AESGCM_HKEY(pState), AesGcmConst_table); + + /* add IV bit length */ + { + Ipp64u ivBitLen = AESGCM_IV_LEN(pState)*BYTESIZE; + Ipp8u tmp[BLOCK_SIZE]; + PaddBlock(0, tmp, BLOCK_SIZE-8); + U32_TO_HSTRING(tmp+8, HIDWORD(ivBitLen)); + U32_TO_HSTRING(tmp+12, LODWORD(ivBitLen)); + XorBlock16(tmp, AESGCM_COUNTER(pState), AESGCM_COUNTER(pState)); + hashFunc(AESGCM_COUNTER(pState), AESGCM_HKEY(pState), AesGcmConst_table); + } + } + + /* prepare initial counter */ + { + IppsAESSpec* pAES = AESGCM_CIPHER(pState); + RijnCipher encoder = RIJ_ENCODER(pAES); + encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER0(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + } + + /* switch mode and init counters */ + AESGCM_STATE(pState) = GcmAADprocessing; + AESGCM_AAD_LEN(pState) = CONST_64(0); + AESGCM_BUFLEN(pState) = 0; + } + + /* + // AAD processing + */ + + /* test if buffer is not empty */ + if(AESGCM_BUFLEN(pState)) { + int locLen = IPP_MIN(aadLen, BLOCK_SIZE-AESGCM_BUFLEN(pState)); + XorBlock(pAAD, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), locLen); + AESGCM_BUFLEN(pState) += locLen; + + /* if buffer full */ + if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) { + hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table); + AESGCM_BUFLEN(pState) = 0; + } + + AESGCM_AAD_LEN(pState) += locLen; + pAAD += locLen; + aadLen -= locLen; + } + + /* process main part of AAD */ + { + int lenBlks = aadLen & (-BLOCK_SIZE); + if(lenBlks) { + Auth_ authFunc = AESGCM_AUTH(pState); + + authFunc(AESGCM_GHASH(pState), pAAD, lenBlks, AESGCM_HKEY(pState), AesGcmConst_table); + + AESGCM_AAD_LEN(pState) += lenBlks; + pAAD += lenBlks; + aadLen -= lenBlks; + } + } + + /* copy the rest of AAD into the buffer */ + if(aadLen) { + XorBlock(pAAD, AESGCM_GHASH(pState), AESGCM_GHASH(pState), aadLen); + AESGCM_AAD_LEN(pState) += aadLen; + AESGCM_BUFLEN(pState) = aadLen; + } + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsAES_GCMStart +// +// Purpose: Start the process of encryption or decryption and authentication tag generation. +// +// Returns: Reason: +// ippStsNullPtrErr pState == NULL +// pIV == NULL, ivLen>0 +// pAAD == NULL, aadLen>0 +// ippStsContextMatchErr !AESGCM_VALID_ID() +// ippStsLengthErr ivLen < 0 +// aadLen < 0 +// ippStsNoErr no errors +// +// Parameters: +// pIV pointer to the IV (nonce) +// ivLen length of the IV in bytes +// pAAD pointer to the Addition Authenticated Data (header) +// aadLen length of the AAD in bytes +// pState pointer to the AES-GCM state +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMStart,(const Ipp8u* pIV, int ivLen, + const Ipp8u* pAAD, int aadLen, + IppsAES_GCMState* pState)) +{ + IppStatus sts = ippsAES_GCMReset(pState); + if(ippStsNoErr==sts) + sts = ippsAES_GCMProcessIV(pIV, ivLen, pState); + if(ippStsNoErr==sts) + sts = ippsAES_GCMProcessAAD(pAAD, aadLen, pState); + return sts; +} + + +/*F* +// Name: ippsAES_GCMEncrypt +// +// Purpose: Encrypts a data buffer in the GCM mode. +// +// Returns: Reason: +// ippStsNullPtrErr pSrc == NULL +// pDst == NULL +// pState == NULL +// ippStsContextMatchErr !AESGCM_VALID_ID() +// ippStsLengthErr txtLen<0 +// ippStsNoErr no errors +// +// Parameters: +// pSrc Pointer to plaintext. +// pDst Pointer to ciphertext. +// len Length of the plaintext and ciphertext in bytes +// pState pointer to the context +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMEncrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int txtLen, + IppsAES_GCMState* pState)) +{ + /* test pState pointer */ + IPP_BAD_PTR1_RET(pState); + /* use aligned context */ + pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) ); + /* test state ID */ + IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr); + /* test context validity */ + IPP_BADARG_RET(!(GcmAADprocessing==AESGCM_STATE(pState) || GcmTXTprocessing==AESGCM_STATE(pState)), ippStsBadArgErr); + + /* test text pointers and length */ + IPP_BAD_PTR2_RET(pSrc, pDst); + IPP_BADARG_RET(txtLen<0, ippStsLengthErr); + + + { + /* get method */ + IppsAESSpec* pAES = AESGCM_CIPHER(pState); + RijnCipher encoder = RIJ_ENCODER(pAES); + MulGcm_ hashFunc = AESGCM_HASH(pState); + + if( GcmAADprocessing==AESGCM_STATE(pState) ) { + /* complete AAD processing */ + if(AESGCM_BUFLEN(pState)) + hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table); + + /* increment counter block */ + IncrementCounter32(AESGCM_COUNTER(pState)); + /* and encrypt counter */ + encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + + /* switch mode and init counters */ + AESGCM_STATE(pState) = GcmTXTprocessing; + AESGCM_TXT_LEN(pState) = CONST_64(0); + AESGCM_BUFLEN(pState) = 0; + } + + /* + // process text (encrypt and authenticate) + */ + /* process partial block */ + if(AESGCM_BUFLEN(pState)) { + int locLen = IPP_MIN(txtLen, BLOCK_SIZE-AESGCM_BUFLEN(pState)); + /* ctr encryption */ + XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, locLen); + /* authentication */ + XorBlock(pDst, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), locLen); + + AESGCM_BUFLEN(pState) += locLen; + AESGCM_TXT_LEN(pState) += locLen; + pSrc += locLen; + pDst += locLen; + txtLen -= locLen; + + /* if buffer full */ + if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) { + /* hash buffer */ + hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table); + AESGCM_BUFLEN(pState) = 0; + + /* increment counter block */ + IncrementCounter32(AESGCM_COUNTER(pState)); + /* and encrypt counter */ + encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + } + } + + /* process the main part of text */ + { + int lenBlks = txtLen & (-BLOCK_SIZE); + if(lenBlks) { + Encrypt_ encFunc = AESGCM_ENC(pState); + + encFunc(pDst, pSrc, lenBlks, pState); + + AESGCM_TXT_LEN(pState) += lenBlks; + pSrc += lenBlks; + pDst += lenBlks; + txtLen -= lenBlks; + } + } + + /* process the rest of text */ + if(txtLen) { + XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, txtLen); + XorBlock(pDst, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), txtLen); + + AESGCM_BUFLEN(pState) += txtLen; + AESGCM_TXT_LEN(pState) += txtLen; + } + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsAES_GCMDecrypt +// +// Purpose: Decrypts a data buffer in the GCM mode. +// +// Returns: Reason: +// ippStsNullPtrErr pSrc == NULL +// pDst == NULL +// pState == NULL +// ippStsContextMatchErr !AESGCM_VALID_ID() +// ippStsLengthErr txtLen<0 +// ippStsNoErr no errors +// +// Parameters: +// pSrc Pointer to ciphertext. +// pDst Pointer to plaintext. +// len Length of the plaintext and ciphertext in bytes +// pState pointer to the context +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMDecrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int txtLen, IppsAES_GCMState* pState)) +{ + /* test pState pointer */ + IPP_BAD_PTR1_RET(pState); + /* use aligned context */ + pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) ); + /* test state ID */ + IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr); + /* test context validity */ + IPP_BADARG_RET(!(GcmAADprocessing==AESGCM_STATE(pState) || GcmTXTprocessing==AESGCM_STATE(pState)), ippStsBadArgErr); + + /* test text pointers and length */ + IPP_BAD_PTR2_RET(pSrc, pDst); + IPP_BADARG_RET(txtLen<0, ippStsLengthErr); + + + { + /* get method */ + IppsAESSpec* pAES = AESGCM_CIPHER(pState); + RijnCipher encoder = RIJ_ENCODER(pAES); + MulGcm_ hashFunc = AESGCM_HASH(pState); + + if( GcmAADprocessing==AESGCM_STATE(pState) ) { + /* complete AAD processing */ + if(AESGCM_BUFLEN(pState)) + hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table); + + /* increment counter block */ + IncrementCounter32(AESGCM_COUNTER(pState)); + /* and encrypt counter */ + encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + + /* switch mode and init counters */ + AESGCM_BUFLEN(pState) = 0; + AESGCM_TXT_LEN(pState) = CONST_64(0); + AESGCM_STATE(pState) = GcmTXTprocessing; + } + + /* + // process text (authenticate and decrypt ) + */ + /* process partial block */ + if(AESGCM_BUFLEN(pState)) { + int locLen = IPP_MIN(txtLen, BLOCK_SIZE-AESGCM_BUFLEN(pState)); + /* authentication */ + XorBlock(pSrc, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), locLen); + /* ctr decryption */ + XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, locLen); + + AESGCM_BUFLEN(pState) += locLen; + AESGCM_TXT_LEN(pState) += locLen; + pSrc += locLen; + pDst += locLen; + txtLen -= locLen; + + /* if buffer full */ + if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) { + /* hash buffer */ + hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table); + AESGCM_BUFLEN(pState) = 0; + + /* increment counter block */ + IncrementCounter32(AESGCM_COUNTER(pState)); + /* and encrypt counter */ + encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + } + } + + /* process the main part of text */ + { + int lenBlks = txtLen & (-BLOCK_SIZE); + if(lenBlks) { + Decrypt_ decFunc = AESGCM_DEC(pState); + + decFunc(pDst, pSrc, lenBlks, pState); + + AESGCM_TXT_LEN(pState) += lenBlks; + pSrc += lenBlks; + pDst += lenBlks; + txtLen -= lenBlks; + } + } + + /* process the rest of text */ + if(txtLen) { + /* ctr encryption */ + XorBlock(pSrc, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), txtLen); + XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, txtLen); + + AESGCM_BUFLEN(pState) += txtLen; + AESGCM_TXT_LEN(pState) += txtLen; + } + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsAES_GCMGetTag +// +// Purpose: Generates authentication tag in the GCM mode. +// +// Returns: Reason: +// ippStsNullPtrErr pDstTag == NULL +// pState == NULL +// ippStsLengthErr tagLen<=0 || tagLen>16 +// ippStsContextMatchErr !AESGCM_VALID_ID() +// ippStsNoErr no errors +// +// Parameters: +// pDstTag pointer to the authentication tag. +// tagLen length of the authentication tag *pDstTag in bytes +// pState pointer to the context +// +*F*/ +IPPFUN(IppStatus, ippsAES_GCMGetTag,(Ipp8u* pTag, int tagLen, const IppsAES_GCMState* pState)) +{ + /* test State pointer */ + IPP_BAD_PTR1_RET(pState); + /* use aligned context */ + pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) ); + /* test state ID */ + IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr); + + /* test tag pointer and length */ + IPP_BAD_PTR1_RET(pTag); + IPP_BADARG_RET(tagLen<=0 || tagLen>BLOCK_SIZE, ippStsLengthErr); + + + { + /* get method */ + MulGcm_ hashFunc = AESGCM_HASH(pState); + + __ALIGN16 Ipp8u tmpHash[BLOCK_SIZE]; + Ipp8u tmpCntr[BLOCK_SIZE]; + + /* local copy of AAD and text counters (in bits) */ + Ipp64u aadBitLen = AESGCM_AAD_LEN(pState)*BYTESIZE; + Ipp64u txtBitLen = AESGCM_TXT_LEN(pState)*BYTESIZE; + + /* do local copy of ghash */ + CopyBlock16(AESGCM_GHASH(pState), tmpHash); + + /* complete text processing */ + if(AESGCM_BUFLEN(pState)) { + hashFunc(tmpHash, AESGCM_HKEY(pState), AesGcmConst_table); + } + + /* process lengths of AAD and text */ + U32_TO_HSTRING(tmpCntr, HIDWORD(aadBitLen)); + U32_TO_HSTRING(tmpCntr+4, LODWORD(aadBitLen)); + U32_TO_HSTRING(tmpCntr+8, HIDWORD(txtBitLen)); + U32_TO_HSTRING(tmpCntr+12,LODWORD(txtBitLen)); + + XorBlock16(tmpHash, tmpCntr, tmpHash); + hashFunc(tmpHash, AESGCM_HKEY(pState), AesGcmConst_table); + + /* add encrypted initial counter */ + XorBlock16(tmpHash, AESGCM_ECOUNTER0(pState), tmpHash); + + /* return tag of required lenth */ + CopyBlock(tmpHash, pTag, tagLen); + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpaesgcmtableca.c b/external/crypto_px/sources/ippcp/src/pcpaesgcmtableca.c new file mode 100644 index 0000000000..7675de46ea --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpaesgcmtableca.c @@ -0,0 +1,52 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" + +const Ipp16u AesGcmConst_table[256] = { +0x0000, 0xc201, 0x8403, 0x4602, 0x0807, 0xca06, 0x8c04, 0x4e05, 0x100e, 0xd20f, 0x940d, 0x560c, 0x1809, 0xda08, 0x9c0a, 0x5e0b, +0x201c, 0xe21d, 0xa41f, 0x661e, 0x281b, 0xea1a, 0xac18, 0x6e19, 0x3012, 0xf213, 0xb411, 0x7610, 0x3815, 0xfa14, 0xbc16, 0x7e17, +0x4038, 0x8239, 0xc43b, 0x063a, 0x483f, 0x8a3e, 0xcc3c, 0x0e3d, 0x5036, 0x9237, 0xd435, 0x1634, 0x5831, 0x9a30, 0xdc32, 0x1e33, +0x6024, 0xa225, 0xe427, 0x2626, 0x6823, 0xaa22, 0xec20, 0x2e21, 0x702a, 0xb22b, 0xf429, 0x3628, 0x782d, 0xba2c, 0xfc2e, 0x3e2f, +0x8070, 0x4271, 0x0473, 0xc672, 0x8877, 0x4a76, 0x0c74, 0xce75, 0x907e, 0x527f, 0x147d, 0xd67c, 0x9879, 0x5a78, 0x1c7a, 0xde7b, +0xa06c, 0x626d, 0x246f, 0xe66e, 0xa86b, 0x6a6a, 0x2c68, 0xee69, 0xb062, 0x7263, 0x3461, 0xf660, 0xb865, 0x7a64, 0x3c66, 0xfe67, +0xc048, 0x0249, 0x444b, 0x864a, 0xc84f, 0x0a4e, 0x4c4c, 0x8e4d, 0xd046, 0x1247, 0x5445, 0x9644, 0xd841, 0x1a40, 0x5c42, 0x9e43, +0xe054, 0x2255, 0x6457, 0xa656, 0xe853, 0x2a52, 0x6c50, 0xae51, 0xf05a, 0x325b, 0x7459, 0xb658, 0xf85d, 0x3a5c, 0x7c5e, 0xbe5f, +0x00e1, 0xc2e0, 0x84e2, 0x46e3, 0x08e6, 0xcae7, 0x8ce5, 0x4ee4, 0x10ef, 0xd2ee, 0x94ec, 0x56ed, 0x18e8, 0xdae9, 0x9ceb, 0x5eea, +0x20fd, 0xe2fc, 0xa4fe, 0x66ff, 0x28fa, 0xeafb, 0xacf9, 0x6ef8, 0x30f3, 0xf2f2, 0xb4f0, 0x76f1, 0x38f4, 0xfaf5, 0xbcf7, 0x7ef6, +0x40d9, 0x82d8, 0xc4da, 0x06db, 0x48de, 0x8adf, 0xccdd, 0x0edc, 0x50d7, 0x92d6, 0xd4d4, 0x16d5, 0x58d0, 0x9ad1, 0xdcd3, 0x1ed2, +0x60c5, 0xa2c4, 0xe4c6, 0x26c7, 0x68c2, 0xaac3, 0xecc1, 0x2ec0, 0x70cb, 0xb2ca, 0xf4c8, 0x36c9, 0x78cc, 0xbacd, 0xfccf, 0x3ece, +0x8091, 0x4290, 0x0492, 0xc693, 0x8896, 0x4a97, 0x0c95, 0xce94, 0x909f, 0x529e, 0x149c, 0xd69d, 0x9898, 0x5a99, 0x1c9b, 0xde9a, +0xa08d, 0x628c, 0x248e, 0xe68f, 0xa88a, 0x6a8b, 0x2c89, 0xee88, 0xb083, 0x7282, 0x3480, 0xf681, 0xb884, 0x7a85, 0x3c87, 0xfe86, +0xc0a9, 0x02a8, 0x44aa, 0x86ab, 0xc8ae, 0x0aaf, 0x4cad, 0x8eac, 0xd0a7, 0x12a6, 0x54a4, 0x96a5, 0xd8a0, 0x1aa1, 0x5ca3, 0x9ea2, +0xe0b5, 0x22b4, 0x64b6, 0xa6b7, 0xe8b2, 0x2ab3, 0x6cb1, 0xaeb0, 0xf0bb, 0x32ba, 0x74b8, 0xb6b9, 0xf8bc, 0x3abd, 0x7cbf, 0xbebe +}; diff --git a/external/crypto_px/sources/ippcp/src/pcpaesgcmtbl2kca.c b/external/crypto_px/sources/ippcp/src/pcpaesgcmtbl2kca.c new file mode 100644 index 0000000000..b2d9d32322 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpaesgcmtbl2kca.c @@ -0,0 +1,229 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" + +#include "pcpaesauthgcm.h" +#include "pcptool.h" + +#include "pcprijtables.h" + + +/* +// AES-GCM precomputations. +*/ +static void RightShiftBlock16(Ipp8u* pBlock) +{ + Ipp8u v0 = 0; + int i; + for(i=0; i<16; i++) { + Ipp8u v1 = pBlock[i]; + Ipp8u tmp = (Ipp8u)( (v1>>1) | (v0<<7) ); + pBlock[i] = tmp; + v0 = v1; + } +} +void AesGcmPrecompute_table2K(Ipp8u* pPrecomputeData, const Ipp8u* pHKey) +{ + Ipp8u t[BLOCK_SIZE]; + int n; + + CopyBlock16(pHKey, t); + + for(n=0; n<128-24; n++) { + /* get msb */ + int hBit = t[15]&1; + + int k = n%32; + if(k<4) { + CopyBlock16(t, pPrecomputeData +1024 +(n/32)*256 +(Ipp32u)(1<<(7-k))); + } + else if(k<8) { + CopyBlock16(t, pPrecomputeData +(n/32)*256 +(Ipp32u)(1<<(11-k))); + } + + /* shift */ + RightShiftBlock16(t); + /* xor if msb=1 */ + if(hBit) + t[0] ^= 0xe1; + } + + for(n=0; n<4; n++) { + int m, k; + XorBlock16(pPrecomputeData +n*256, pPrecomputeData +n*256, pPrecomputeData +n*256); + XorBlock16(pPrecomputeData +1024 +n*256, pPrecomputeData +1024 +n*256, pPrecomputeData +1024 +n*256); + for(m=2; m<=8; m*=2) + for(k=1; k=BLOCK_SIZE) { + /* add src */ + XorBlock16(pSrc, pHash, pHash); + /* hash it */ + AesGcmMulGcm_table2K(pHash, pHKey, AesGcmConst_table); + + pSrc += BLOCK_SIZE; + len -= BLOCK_SIZE; + } +} + + +/* +// encrypts and authenticates n*BLOCK_SIZE bytes +*/ +void wrpAesGcmEnc_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pState) +{ + Ipp8u* pHashedData = pDst; + int hashedDataLen = len; + + Ipp8u* pCounter = AESGCM_COUNTER(pState); + Ipp8u* pECounter = AESGCM_ECOUNTER(pState); + + IppsAESSpec* pAES = AESGCM_CIPHER(pState); + RijnCipher encoder = RIJ_ENCODER(pAES); + + while(len>=BLOCK_SIZE) { + /* encrypt whole AES block */ + XorBlock16(pSrc, pECounter, pDst); + + pSrc += BLOCK_SIZE; + pDst += BLOCK_SIZE; + len -= BLOCK_SIZE; + + /* increment counter block */ + IncrementCounter32(pCounter); + /* and encrypt counter */ + encoder(pCounter, pECounter, RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + } + + AesGcmAuth_table2K(AESGCM_GHASH(pState), pHashedData, hashedDataLen, AESGCM_HKEY(pState), AesGcmConst_table); +} + + +/* +// authenticates and decrypts n*BLOCK_SIZE bytes +*/ +void wrpAesGcmDec_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pState) +{ + AesGcmAuth_table2K(AESGCM_GHASH(pState), pSrc, len, AESGCM_HKEY(pState), AesGcmConst_table); + + { + Ipp8u* pCounter = AESGCM_COUNTER(pState); + Ipp8u* pECounter = AESGCM_ECOUNTER(pState); + + IppsAESSpec* pAES = AESGCM_CIPHER(pState); + RijnCipher encoder = RIJ_ENCODER(pAES); + + while(len>=BLOCK_SIZE) { + /* encrypt whole AES block */ + XorBlock16(pSrc, pECounter, pDst); + + pSrc += BLOCK_SIZE; + pDst += BLOCK_SIZE; + len -= BLOCK_SIZE; + + /* increment counter block */ + IncrementCounter32(pCounter); + /* and encrypt counter */ + encoder(pCounter, pECounter, RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox); + } + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpaesm.h b/external/crypto_px/sources/ippcp/src/pcpaesm.h new file mode 100644 index 0000000000..dacfe258ea --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpaesm.h @@ -0,0 +1,50 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_AES_H) +#define _PCP_AES_H + +#include "pcprij.h" + +/* alignment of AES context */ +#define AES_ALIGNMENT (RIJ_ALIGNMENT) + +/* valid AES context ID */ +#define VALID_AES_ID(ctx) (RIJ_ID((ctx))==idCtxRijndael) + +/* size of AES context */ +__INLINE int cpSizeofCtx_AES(void) +{ + return sizeof(IppsAESSpec) + +(AES_ALIGNMENT-1); +} + +#endif /* _PCP_AES_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpaesmctrca.c b/external/crypto_px/sources/ippcp/src/pcpaesmctrca.c new file mode 100644 index 0000000000..1a7f65487d --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpaesmctrca.c @@ -0,0 +1,150 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" + +#include "owncp.h" +#include "pcpaesm.h" +#include "pcptool.h" + +#include "pcprijtables.h" + +/* +// AES-CRT processing. +// +// Returns: Reason: +// ippStsNullPtrErr pCtx == NULL +// pSrc == NULL +// pDst == NULL +// pCtrValue ==NULL +// ippStsContextMatchErr !VALID_AES_ID() +// ippStsLengthErr len <1 +// ippStsCTRSizeErr 128 < ctrNumBitSize < 1 +// ippStsNoErr no errors +// +// Parameters: +// pSrc pointer to the source data buffer +// pDst pointer to the target data buffer +// dataLen input/output buffer length (in bytes) +// pCtx pointer to rge AES context +// pCtrValue pointer to the counter block +// ctrNumBitSize counter block size (bits) +// +// Note: +// counter will updated on return +// +*/ +static +IppStatus cpProcessAES_ctr(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen, + const IppsAESSpec* pCtx, + Ipp8u* pCtrValue, int ctrNumBitSize) +{ + /* test context */ + IPP_BAD_PTR1_RET(pCtx); + /* use aligned AES context */ + pCtx = (IppsAESSpec*)( IPP_ALIGNED_PTR(pCtx, AES_ALIGNMENT) ); + /* test the context ID */ + IPP_BADARG_RET(!VALID_AES_ID(pCtx), ippStsContextMatchErr); + + /* test source, target and counter block pointers */ + IPP_BAD_PTR3_RET(pSrc, pDst, pCtrValue); + /* test stream length */ + IPP_BADARG_RET((dataLen<1), ippStsLengthErr); + + /* test counter block size */ + IPP_BADARG_RET(((MBS_RIJ128*8)= MBS_RIJ128) { + /* encrypt counter block */ + encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijEncSbox); + + /* compute ciphertext block */ + if( !(IPP_UINT_PTR(pSrc) & 0x3) && !(IPP_UINT_PTR(pDst) & 0x3)) { + ((Ipp32u*)pDst)[0] = output[0]^((Ipp32u*)pSrc)[0]; + ((Ipp32u*)pDst)[1] = output[1]^((Ipp32u*)pSrc)[1]; + ((Ipp32u*)pDst)[2] = output[2]^((Ipp32u*)pSrc)[2]; + ((Ipp32u*)pDst)[3] = output[3]^((Ipp32u*)pSrc)[3]; + } + else + XorBlock16(pSrc, output, pDst); + /* encrement counter block */ + StdIncrement((Ipp8u*)counter,MBS_RIJ128*8, ctrNumBitSize); + + pSrc += MBS_RIJ128; + pDst += MBS_RIJ128; + dataLen -= MBS_RIJ128; + } + /* + // encrypt last data block + */ + if(dataLen) { + /* encrypt counter block */ + encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijEncSbox); + + /* compute ciphertext block */ + XorBlock(pSrc, output, pDst,dataLen); + /* encrement counter block */ + StdIncrement((Ipp8u*)counter,MBS_RIJ128*8, ctrNumBitSize); + } + + /* update counter */ + CopyBlock16(counter, pCtrValue); + + return ippStsNoErr; + } +} + +IPPFUN(IppStatus, ippsAESEncryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen, + const IppsAESSpec* pCtx, + Ipp8u* pCtrValue, int ctrNumBitSize)) +{ + return cpProcessAES_ctr(pSrc, pDst, dataLen, pCtx, pCtrValue, ctrNumBitSize); +} + +IPPFUN(IppStatus, ippsAESDecryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen, + const IppsAESSpec* pCtx, + Ipp8u* pCtrValue, int ctrNumBitSize)) +{ + return cpProcessAES_ctr(pSrc, pDst, dataLen, pCtx, pCtrValue, ctrNumBitSize); +} diff --git a/external/crypto_px/sources/ippcp/src/pcpaesminitca.c b/external/crypto_px/sources/ippcp/src/pcpaesminitca.c new file mode 100644 index 0000000000..ce273cdeec --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpaesminitca.c @@ -0,0 +1,173 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpaesm.h" +#include "pcptool.h" + +#include "pcprijtables.h" + +/*F* +// Name: ippsAESGetSize +// +// Purpose: Returns size of AES context (in bytes). +// +// Returns: Reason: +// ippStsNullPtrErr pSzie == NULL +// ippStsNoErr no errors +// +// Parameters: +// pSize pointer to AES size of context(in bytes) +// +*F*/ +IPPFUN(IppStatus, ippsAESGetSize,(int* pSize)) +{ + /* test size's pointer */ + IPP_BAD_PTR1_RET(pSize); + + *pSize = cpSizeofCtx_AES(); + + return ippStsNoErr; +} + +/* number of rounds (use [NK] for access) */ +static int rij128nRounds[3] = {NR128_128, NR128_192, NR128_256}; + +/* +// number of keys (estimation only!) (use [NK] for access) +// +// accurate number of keys necassary for encrypt/decrypt are: +// nKeys = NB * (NR+1) +// where NB - data block size (32-bit words) +// NR - number of rounds (depend on NB and keyLen) +// +// but the estimation +// estnKeys = (NK*n) >= nKeys +// or +// estnKeys = ( (NB*(NR+1) + (NK-1)) / NK) * NK +// where NK - key length (words) +// NB - data block size (word) +// NR - number of rounds (depend on NB and keyLen) +// nKeys - accurate numner of keys +// is more convinient when calculates key extension +*/ +static int rij128nKeys[3] = {44, 54, 64 }; + +/* +// helper for nRounds[] and estnKeys[] access +// note: x is length in 32-bits words +*/ +__INLINE int rij_index(int x) +{ return (x-NB(128))>>1; } + +/*F* +// Name: ippsAESInit +// +// Purpose: Init AES context for future usage +// and setup secret key. +// +// Returns: Reason: +// ippStsNullPtrErr pCtx == NULL +// ippStsMemAllocErr size of buffer is not match fro operation +// ippStsLengthErr keyLen != 16 +// keyLen != 24 +// keyLen != 32 +// +// Parameters: +// pKey secret key +// keyLen length of the secret key (in bytes) +// pCtx pointer to buffer initialized as AES context +// ctxSize available size (in bytes) of buffer above +// +// Note: +// if pKey==NULL, then AES initialized by zero value key +// +*F*/ +IPPFUN(IppStatus, ippsAESInit,(const Ipp8u* pKey, int keyLen, + IppsAESSpec* pCtxRaw, int rawCtxSize)) +{ + /* test context pointer */ + IPP_BAD_PTR1_RET(pCtxRaw); + + /* make sure in legal keyLen */ + IPP_BADARG_RET(keyLen!=16 && keyLen!=24 && keyLen!=32, ippStsLengthErr); + + { + /* use aligned Rijndael context */ + IppsAESSpec* pCtx = (IppsAESSpec*)( IPP_ALIGNED_PTR(pCtxRaw, AES_ALIGNMENT) ); + + /* test available size of context buffer */ + if(((Ipp8u*)pCtx+sizeof(IppsAESSpec)) > ((Ipp8u*)pCtxRaw+rawCtxSize)) + IPP_ERROR_RET(ippStsMemAllocErr); + + else { + int keyWords = NK(keyLen*BITSIZE(Ipp8u)); + int nExpKeys = rij128nKeys [ rij_index(keyWords) ]; + int nRounds = rij128nRounds[ rij_index(keyWords) ]; + + Ipp8u zeroKey[32] = {0}; + const Ipp8u* pActualKey = pKey? pKey : zeroKey; + + /* clear context */ + PaddBlock(0, pCtx, sizeof(IppsAESSpec)); + + /* init spec */ + RIJ_ID(pCtx) = idCtxRijndael; + RIJ_NB(pCtx) = NB(128); + RIJ_NK(pCtx) = keyWords; + RIJ_NR(pCtx) = nRounds; + RIJ_SAFE_INIT(pCtx) = 1; + + /* set key expansion */ + ExpandRijndaelKey(pActualKey, keyWords, NB(128), nRounds, nExpKeys, + RIJ_EKEYS(pCtx), + RIJ_DKEYS(pCtx)); + { + int nr; + Ipp8u* pEnc_key = (Ipp8u*)(RIJ_EKEYS(pCtx)); + /* update key material: transpose inplace */ + for(nr=0; nr<(1+nRounds); nr++, pEnc_key+=16) { + SWAP(pEnc_key[ 1], pEnc_key[ 4]); + SWAP(pEnc_key[ 2], pEnc_key[ 8]); + SWAP(pEnc_key[ 3], pEnc_key[12]); + SWAP(pEnc_key[ 6], pEnc_key[ 9]); + SWAP(pEnc_key[ 7], pEnc_key[13]); + SWAP(pEnc_key[11], pEnc_key[14]); + } + } + RIJ_ENCODER(pCtx) = Safe2Encrypt_RIJ128; /* safe encoder (compact Sbox)) */ + RIJ_DECODER(pCtx) = Safe2Decrypt_RIJ128; /* safe decoder (compact Sbox)) */ + + return ippStsNoErr; + } + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpbn.h b/external/crypto_px/sources/ippcp/src/pcpbn.h new file mode 100644 index 0000000000..a6fd9a0b14 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbn.h @@ -0,0 +1,210 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_CP_BN_H) +#define _CP_BN_H + +#include "pcpbnuimpl.h" +#include "pcpbnuarith.h" +#include "pcpbnumisc.h" +#include "pcpbnu32arith.h" +#include "pcpbnu32misc.h" + +/* +// Big Number context +*/ +struct _cpBigNum +{ + IppCtxId idCtx; /* BigNum ctx id */ + IppsBigNumSGN sgn; /* sign */ + cpSize size; /* BigNum size (BNU_CHUNK_T) */ + cpSize room; /* BigNum max size (BNU_CHUNK_T) */ + BNU_CHUNK_T* number; /* BigNum value */ + BNU_CHUNK_T* buffer; /* temporary buffer */ +}; + +/* BN accessory macros */ +#define BN_ID(pBN) ((pBN)->idCtx) +#define BN_SIGN(pBN) ((pBN)->sgn) +#define BN_POSITIVE(pBN) (BN_SIGN(pBN)==ippBigNumPOS) +#define BN_NEGATIVE(pBN) (BN_SIGN(pBN)==ippBigNumNEG) +#define BN_NUMBER(pBN) ((pBN)->number) +#define BN_BUFFER(pBN) ((pBN)->buffer) +#define BN_ROOM(pBN) ((pBN)->room) +#define BN_SIZE(pBN) ((pBN)->size) +#define BN_SIZE32(pBN) ((pBN)->size*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) +//#define BN_SIZE32(pBN) (BITS2WORD32_SIZE( BITSIZE_BNU(BN_NUMBER((pBN)),BN_SIZE((pBN))))) + +#define BN_VALID_ID(pBN) (BN_ID((pBN))==idCtxBigNum) + +#define INVERSE_SIGN(s) (((s)==ippBigNumPOS)? ippBigNumNEG : ippBigNumPOS) + +#define BN_ALIGNMENT ((int)sizeof(void*)) + + +/* pack-unpack context */ +void cpPackBigNumCtx(const IppsBigNumState* pBN, Ipp8u* pBuffer); +void cpUnpackBigNumCtx(const Ipp8u* pBuffer, IppsBigNumState* pBN); + +/* copy BN */ +__INLINE IppsBigNumState* cpBN_copy(IppsBigNumState* pDst, const IppsBigNumState* pSrc) +{ + BN_SIGN(pDst) = BN_SIGN(pSrc); + BN_SIZE(pDst) = BN_SIZE(pSrc); + ZEXPAND_COPY_BNU(BN_NUMBER(pDst), BN_ROOM(pDst), BN_NUMBER(pSrc), BN_SIZE(pSrc)); + return pDst; +} +/* set BN to zero */ +__INLINE IppsBigNumState* cpBN_zero(IppsBigNumState* pBN) +{ + BN_SIGN(pBN) = ippBigNumPOS; + BN_SIZE(pBN) = 1; + ZEXPAND_BNU(BN_NUMBER(pBN),0, (int)BN_ROOM(pBN)); + return pBN; +} +/* fixup BN */ +__INLINE IppsBigNumState* cpBN_fix(IppsBigNumState* pBN) +{ + cpSize len = BN_SIZE(pBN); + FIX_BNU(BN_NUMBER(pBN), len); + BN_SIZE(pBN) = len; + return pBN; +} +/* set BN to chunk */ +__INLINE IppsBigNumState* cpBN_chunk(IppsBigNumState* pBN, BNU_CHUNK_T a) +{ + BN_SIGN(pBN) = ippBigNumPOS; + BN_SIZE(pBN) = 1; + ZEXPAND_BNU(BN_NUMBER(pBN),0, (int)BN_ROOM(pBN)); + BN_NUMBER(pBN)[0] = a; + return pBN; +} +/* set BN to 2^m */ +__INLINE IppsBigNumState* cpBN_power2(IppsBigNumState* pBN, int power) +{ + cpSize size = BITS_BNU_CHUNK(power+1); + if(BN_ROOM(pBN) >= size) { + BN_SIGN(pBN) = ippBigNumPOS; + BN_SIZE(pBN) = size; + ZEXPAND_BNU(BN_NUMBER(pBN),0, BN_ROOM(pBN)); + SET_BIT(BN_NUMBER(pBN), power); + return pBN; + } + else return NULL; +} + +/* bitsize of BN */ +__INLINE int cpBN_bitsize(const IppsBigNumState* pA) +{ + int bitsize = BITSIZE_BNU(BN_NUMBER(pA), BN_SIZE(pA)); + return bitsize; +} + +/* returns -1/0/+1 depemding on A~B comparison */ +__INLINE int cpBN_cmp(const IppsBigNumState* pA, const IppsBigNumState* pB) +{ + IppsBigNumSGN signA = BN_SIGN(pA); + IppsBigNumSGN signB = BN_SIGN(pB); + + if(signA==signB) { + int result = cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pB), BN_SIZE(pB)); + return (ippBigNumPOS==signA)? result : -result; + } + return (ippBigNumPOS==signA)? 1 : -1; +} + +/* returns -1/0/+1 depemding on A comparison 00 */ +__INLINE int cpBN_tst(const IppsBigNumState* pA) +{ + if(1==BN_SIZE(pA) && 0==BN_NUMBER(pA)[0]) + return 0; + else + return BN_POSITIVE(pA)? 1 : -1; +} + + +// some addtition functions +__INLINE int IsZero_BN(const IppsBigNumState* pA) +{ + return ( BN_SIZE(pA)==1 ) && ( BN_NUMBER(pA)[0]==0 ); +} +__INLINE int IsOdd_BN(const IppsBigNumState* pA) +{ + return BN_NUMBER(pA)[0] & 1; +} + +__INLINE IppsBigNumState* BN_Word(IppsBigNumState* pBN, BNU_CHUNK_T w) +{ + BN_SIGN(pBN) = ippBigNumPOS; + BN_SIZE(pBN) = 1; + ZEXPAND_BNU(BN_NUMBER(pBN),0, BN_ROOM(pBN)); + BN_NUMBER(pBN)[0] = w; + return pBN; +} +__INLINE IppsBigNumState* BN_Set(const BNU_CHUNK_T* pData, cpSize len, IppsBigNumState* pBN) +{ + BN_SIGN(pBN) = ippBigNumPOS; + BN_SIZE(pBN) = len; + ZEXPAND_COPY_BNU(BN_NUMBER(pBN), BN_ROOM(pBN), pData, len); + return pBN; +} +__INLINE IppsBigNumState* BN_Make(BNU_CHUNK_T* pData, BNU_CHUNK_T* pBuffer, cpSize len, IppsBigNumState* pBN) +{ + BN_ID(pBN) = idCtxBigNum; + BN_SIGN(pBN) = ippBigNumPOS; + BN_SIZE(pBN) = 1; + BN_ROOM(pBN) = len; + BN_NUMBER(pBN) = pData; + BN_BUFFER(pBN) = pBuffer; + return pBN; +} + + + +/* +// fixed single chunk BN +*/ +typedef struct _ippcpBigNumChunk { + IppsBigNumState bn; + BNU_CHUNK_T value; + BNU_CHUNK_T temporary; +} IppsBigNumStateChunk; + +/* reference to BN(1) and BN(2) */ +IppsBigNumState* cpBN_OneRef(void); +IppsBigNumState* cpBN_TwoRef(void); +IppsBigNumState* cpBN_ThreeRef(void); + +#define BN_ONE_REF() cpBN_OneRef() +#define BN_TWO_REF() cpBN_TwoRef() +#define BN_THREE_REF() cpBN_ThreeRef() + +#endif /* _CP_BN_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpbnca.c b/external/crypto_px/sources/ippcp/src/pcpbnca.c new file mode 100644 index 0000000000..c2a276796b --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnca.c @@ -0,0 +1,1058 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcptool.h" + +/* BN(1) and reference */ +static IppsBigNumStateChunk cpChunk_BN1 = { + { + idCtxBigNum, + ippBigNumPOS, + 1,1, + &cpChunk_BN1.value,&cpChunk_BN1.temporary + }, + 1,0 +}; +IppsBigNumState* cpBN_OneRef(void) +{ return &cpChunk_BN1.bn; }; + +/* BN(2) and reference */ +static IppsBigNumStateChunk cpChunk_BN2 = { + { + idCtxBigNum, + ippBigNumPOS, + 1,1, + &cpChunk_BN2.value,&cpChunk_BN2.temporary + }, + 2,0 +}; +IppsBigNumState* cpBN_TwoRef(void) +{ return &cpChunk_BN2.bn; }; + +/* BN(3) and reference */ +static IppsBigNumStateChunk cpChunk_BN3 = { + { + idCtxBigNum, + ippBigNumPOS, + 1,1, + &cpChunk_BN3.value,&cpChunk_BN3.temporary + }, + 3,0 +}; +IppsBigNumState* cpBN_ThreeRef(void) +{ return &cpChunk_BN3.bn; }; + + + +/*F* +// Name: ippsBigNumGetSize +// +// Purpose: Returns size of BigNum ctx (bytes). +// +// Returns: Reason: +// ippStsNullPtrErr pCtxSize == NULL +// ippStsLengthErr len32 < 1 +// len32 > BITS2WORD32_SIZE(BN_MAXBITSIZE) +// ippStsNoErr no errors +// +// Parameters: +// pCtxSize pointer BigNum ctx size +// +*F*/ +IPPFUN(IppStatus, ippsBigNumGetSize, (cpSize len32, cpSize *pCtxSize)) +{ + IPP_BAD_PTR1_RET(pCtxSize); + IPP_BADARG_RET(len32<1 || len32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr); + + { + /* convert length to the number of BNU_CHUNK_T */ + cpSize len = INTERNAL_BNU_LENGTH(len32); + + /* reserve one BNU_CHUNK_T more for cpDiv_BNU, + mul, mont exp operations */ + len++; + + *pCtxSize = sizeof(IppsBigNumState) + + len*sizeof(BNU_CHUNK_T) + + len*sizeof(BNU_CHUNK_T) + + BN_ALIGNMENT-1; + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsBigNumInit +// +// Purpose: Init BigNum spec for future usage. +// +// Returns: Reason: +// ippStsNullPtrErr pBN == NULL +// ippStsLengthErr len32<1 +// len32 > BITS2WORD32_SIZE(BN_MAXBITSIZE) +// ippStsNoErr no errors +// +// Parameters: +// len32 max BN length (32-bits segments) +// pBN BigNum ctx +// +*F*/ +IPPFUN(IppStatus, ippsBigNumInit, (cpSize len32, IppsBigNumState* pBN)) +{ + IPP_BADARG_RET(len32<1 || len32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr); + IPP_BAD_PTR1_RET(pBN); + pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); + + { + Ipp8u* ptr = (Ipp8u*)pBN; + + /* convert length to the number of BNU_CHUNK_T */ + cpSize len = INTERNAL_BNU_LENGTH(len32); + + BN_ID(pBN) = idCtxUnknown; + BN_SIGN(pBN) = ippBigNumPOS; + BN_SIZE(pBN) = 1; /* initial valie is zero */ + BN_ROOM(pBN) = len; /* close to what has been passed by user */ + + /* reserve one BNU_CHUNK_T more for cpDiv_BNU, + mul, mont exp operations */ + len++; + + /* allocate buffers */ + BN_NUMBER(pBN) = (BNU_CHUNK_T*)(ptr += sizeof(IppsBigNumState)); + BN_BUFFER(pBN) = (BNU_CHUNK_T*)(ptr += len*sizeof(BNU_CHUNK_T)); /* use expanded length here */ + + /* set BN value and buffer to zero */ + ZEXPAND_BNU(BN_NUMBER(pBN), 0, len); + ZEXPAND_BNU(BN_BUFFER(pBN), 0, len); + + BN_ID(pBN) = idCtxBigNum; + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsCmpZero_BN +// +// Purpose: Test BigNum value. +// +// Returns: Reason: +// ippStsNullPtrErr pBN == NULL +// pResult == NULL +// ippStsContextMatchErr BN_VALID_ID() +// ippStsNoErr no errors +// +// Parameters: +// pBN BigNum ctx +// pResult result of comparison +// +*F*/ +IPPFUN(IppStatus, ippsCmpZero_BN, (const IppsBigNumState* pBN, Ipp32u* pResult)) +{ + IPP_BAD_PTR2_RET(pBN, pResult); + + pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr); + + if(BN_SIZE(pBN)==1 && BN_NUMBER(pBN)[0]==0) + *pResult = IS_ZERO; + else if (BN_SIGN(pBN)==ippBigNumPOS) + *pResult = GREATER_THAN_ZERO; + else if (BN_SIGN(pBN)==ippBigNumNEG) + *pResult = LESS_THAN_ZERO; + + return ippStsNoErr; +} + + +/*F* +// Name: ippsCmp_BN +// +// Purpose: Compare two BigNums. +// +// Returns: Reason: +// ippStsNullPtrErr pA == NULL +// pB == NULL +// pResult == NULL +// ippStsContextMatchErr BN_VALID_ID(pA) +// BN_VALID_ID(pB) +// ippStsNoErr no errors +// +// Parameters: +// pA BigNum ctx +// pB BigNum ctx +// pResult result of comparison +// +*F*/ +IPPFUN(IppStatus, ippsCmp_BN,(const IppsBigNumState* pA, const IppsBigNumState* pB, Ipp32u *pResult)) +{ + IPP_BAD_PTR3_RET(pA, pB, pResult); + + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr); + + { + int res; + if(BN_SIGN(pA)==BN_SIGN(pB)) { + res = cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pB), BN_SIZE(pB)); + if(ippBigNumNEG==BN_SIGN(pA)) + res = -res; + } + else + res = (ippBigNumPOS==BN_SIGN(pA))? 1 :-1; + + *pResult = (1==res)? IPP_IS_GT : (-1==res)? IPP_IS_LT : IPP_IS_EQ; + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsSet_BN +// +// Purpose: Set BigNum. +// +// Returns: Reason: +// ippStsNullPtrErr pBN == NULL +// pData == NULL +// ippStsContextMatchErr BN_VALID_ID(pBN) +// ippStsLengthErr len32 < 1 +// ippStsOutOfRangeErr len32 > BN_ROOM() +// ippStsNoErr no errors +// +// Parameters: +// sgn sign +// len32 data size (in Ipp32u chunks) +// pData source data pointer +// pBn BigNum ctx +// +*F*/ +IPPFUN(IppStatus, ippsSet_BN, (IppsBigNumSGN sgn, cpSize len32, const Ipp32u* pData, + IppsBigNumState* pBN)) +{ + IPP_BAD_PTR2_RET(pData, pBN); + + pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr); + + IPP_BADARG_RET(len32<1, ippStsLengthErr); + + /* compute real size */ + FIX_BNU(pData, len32); + + { + cpSize len = INTERNAL_BNU_LENGTH(len32); + IPP_BADARG_RET(len > BN_ROOM(pBN), ippStsOutOfRangeErr); + + ZEXPAND_COPY_BNU((Ipp32u*)BN_NUMBER(pBN), BN_ROOM(pBN)*(int)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)), pData, len32); + + BN_SIZE(pBN) = len; + + if(len32==1 && pData[0] == 0) + sgn = ippBigNumPOS; /* consider zero value as positive */ + BN_SIGN(pBN) = sgn; + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsRef_BN +// +// Purpose: Get BigNum info. +// +// Returns: Reason: +// ippStsNullPtrErr pBN == NULL +// ippStsContextMatchErr BN_VALID_ID(pBN) +// ippStsNoErr no errors +// +// Parameters: +// pSgn pointer to the sign +// pBitSize pointer to the data size (in bits) +// ppData pointer to the data buffer +// pBN BigNum ctx +// +*F*/ +IPPFUN(IppStatus, ippsRef_BN, (IppsBigNumSGN* pSgn, cpSize* pBitSize, Ipp32u** const ppData, + const IppsBigNumState *pBN)) +{ + IPP_BAD_PTR1_RET(pBN); + + pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr); + + if(pSgn) + *pSgn = BN_SIGN(pBN); + if(pBitSize) { + cpSize bitLen = BITSIZE_BNU(BN_NUMBER(pBN), BN_SIZE(pBN)); + *pBitSize = bitLen? bitLen : 1; + } + + if(ppData) + *ppData = (Ipp32u*)BN_NUMBER(pBN); + + return ippStsNoErr; +} + + +/*F* +// Name: ippsAdd_BN +// +// Purpose: Add BigNum. +// +// Returns: Reason: +// ippStsNullPtrErr pA == NULL +// pB == NULL +// pR == NULL +// ippStsContextMatchErr BN_VALID_ID(pA) +// BN_VALID_ID(pB) +// BN_VALID_ID(pR) +// ippStsOutOfRangeErr pR can not hold result +// ippStsNoErr no errors +// +// Parameters: +// pA source BigNum +// pB source BigNum +// pR resultant BigNum +// +*F*/ +IPPFUN(IppStatus, ippsAdd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) +{ + IPP_BAD_PTR3_RET(pA, pB, pR); + + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr); + pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr); + + { + cpSize nsA = BN_SIZE(pA); + cpSize nsB = BN_SIZE(pB); + cpSize nsR = BN_ROOM(pR); + IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr); + + { + BNU_CHUNK_T* pDataR = BN_NUMBER(pR); + + IppsBigNumSGN sgnA = BN_SIGN(pA); + IppsBigNumSGN sgnB = BN_SIGN(pB); + BNU_CHUNK_T* pDataA = BN_NUMBER(pA); + BNU_CHUNK_T* pDataB = BN_NUMBER(pB); + + BNU_CHUNK_T carry; + + if(sgnA==sgnB) { + if(nsA < nsB) { + SWAP(nsA, nsB); + SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB); + } + + carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB); + if(nsA>nsB) + carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry); + if(carry) { + if(nsR>nsA) + pDataR[nsA++] = carry; + else + IPP_ERROR_RET(ippStsOutOfRangeErr); + } + BN_SIGN(pR) = sgnA; + } + + else { + int cmpRes = cpCmp_BNU(pDataA, nsA, pDataB, nsB); + + if(0==cmpRes) { + pDataR[0] = 0; + BN_SIZE(pR) = 1; + BN_SIGN(pR) = ippBigNumPOS; + return ippStsNoErr; + } + + if(0>cmpRes) { + SWAP(nsA, nsB); + SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB); + } + + carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB); + if(nsA>nsB) + cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry); + + BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA); + } + + FIX_BNU(pDataR, nsA); + BN_SIZE(pR) = nsA; + + return ippStsNoErr; + } + } +} + + +/*F* +// Name: ippsSub_BN +// +// Purpose: Subtcrac BigNum. +// +// Returns: Reason: +// ippStsNullPtrErr pA == NULL +// pB == NULL +// pR == NULL +// ippStsContextMatchErr BN_VALID_ID(pA) +// BN_VALID_ID(pB) +// BN_VALID_ID(pR) +// ippStsOutOfRangeErr pR can not hold result +// ippStsNoErr no errors +// +// Parameters: +// pA source BigNum +// pB source BigNum +// pR resultant BigNum +// +*F*/ +IPPFUN(IppStatus, ippsSub_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) +{ + IPP_BAD_PTR3_RET(pA, pB, pR); + + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr); + pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr); + + { + cpSize nsA = BN_SIZE(pA); + cpSize nsB = BN_SIZE(pB); + cpSize nsR = BN_ROOM(pR); + IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr); + + { + BNU_CHUNK_T* pDataR = BN_NUMBER(pR); + + IppsBigNumSGN sgnA = BN_SIGN(pA); + IppsBigNumSGN sgnB = BN_SIGN(pB); + BNU_CHUNK_T* pDataA = BN_NUMBER(pA); + BNU_CHUNK_T* pDataB = BN_NUMBER(pB); + + BNU_CHUNK_T carry; + + if(sgnA!=sgnB) { + if(nsA < nsB) { + SWAP(nsA, nsB); + SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB); + } + + carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB); + if(nsA>nsB) + carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry); + if(carry) { + if(nsR > nsA) + pDataR[nsA++] = carry; + else + IPP_ERROR_RET(ippStsOutOfRangeErr); + } + BN_SIGN(pR) = sgnA; + } + + else { + int cmpRes= cpCmp_BNU(pDataA, nsA, pDataB, nsB); + + if(0==cmpRes) { + ZEXPAND_BNU(pDataR,0, nsR); + BN_SIZE(pR) = 1; + BN_SIGN(pR) = ippBigNumPOS; + return ippStsNoErr; + } + + if(0>cmpRes) { + SWAP(nsA, nsB); + SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB); + } + + carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB); + if(nsA>nsB) + cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry); + + BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA); + } + + FIX_BNU(pDataR, nsA); + BN_SIZE(pR) = nsA; + + return ippStsNoErr; + } + } +} + + +/*F* +// Name: ippsMul_BN +// +// Purpose: Multiply BigNum. +// +// Returns: Reason: +// ippStsNullPtrErr pA == NULL +// pB == NULL +// pR == NULL +// ippStsContextMatchErr BN_VALID_ID(pA) +// BN_VALID_ID(pB) +// BN_VALID_ID(pR) +// ippStsOutOfRangeErr pR can not hold result +// ippStsNoErr no errors +// +// Parameters: +// pA source BigNum +// pB source BigNum +// pR resultant BigNum +// +*F*/ +IPPFUN(IppStatus, ippsMul_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) +{ + IPP_BAD_PTR3_RET(pA, pB, pR); + + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr); + pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr); + + { + BNU_CHUNK_T* pDataA = BN_NUMBER(pA); + BNU_CHUNK_T* pDataB = BN_NUMBER(pB); + BNU_CHUNK_T* pDataR = BN_NUMBER(pR); + + cpSize nsA = BN_SIZE(pA); + cpSize nsB = BN_SIZE(pB); + cpSize nsR = BN_ROOM(pR); + + cpSize bitSizeA = BITSIZE_BNU(pDataA, nsA); + cpSize bitSizeB = BITSIZE_BNU(pDataB, nsB); + + /* test if multiplicant/multiplier is zero */ + if(!bitSizeA || !bitSizeB) { + BN_SIZE(pR) = 1; + BN_SIGN(pR) = IppsBigNumPOS; + pDataR[0] = 0; + return ippStsNoErr; + } + + /* test if even low estimation of product A*B exceeded */ + IPP_BADARG_RET(nsR*BNU_CHUNK_BITS < (bitSizeA+bitSizeB-1), ippStsOutOfRangeErr); + + { + BNU_CHUNK_T* aData = pDataA; + BNU_CHUNK_T* bData = pDataB; + + if(pA == pR) { + aData = BN_BUFFER(pR); + COPY_BNU(aData, pDataA, nsA); + } + if((pB == pR) && (pA != pB)) { + bData = BN_BUFFER(pR); + COPY_BNU(bData, pDataB, nsB); + } + + /* clear result */ + ZEXPAND_BNU(pDataR, 0, nsR+1); + + cpMul_BNU_school(pDataR, aData, nsA, bData, nsB); + + nsR = (bitSizeA + bitSizeB + BNU_CHUNK_BITS - 1) /BNU_CHUNK_BITS; + FIX_BNU(pDataR, nsR); + IPP_BADARG_RET(nsR>BN_ROOM(pR), ippStsOutOfRangeErr); + + BN_SIZE(pR) = nsR; + BN_SIGN(pR) = (BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG); + return ippStsNoErr; + } + } +} + + +/*F* +// Name: ippsDiv_BN +// +// Purpose: Divide BigNum. +// +// Returns: Reason: +// ippStsNullPtrErr pA == NULL +// pB == NULL +// pQ == NULL +// pR == NULL +// ippStsContextMatchErr BN_VALID_ID(pA) +// BN_VALID_ID(pB) +// BN_VALID_ID(pQ) +// BN_VALID_ID(pR) +// ippStsOutOfRangeErr pQ and/or pR can not hold result +// ippStsNoErr no errors +// +// Parameters: +// pA source BigNum +// pB source BigNum +// pQ quotient BigNum +// pR reminder BigNum +// +// A = Q*B + R, 0 <= val(R) < val(B), sgn(A)==sgn(R) +// +*F*/ +IPPFUN(IppStatus, ippsDiv_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pQ, IppsBigNumState* pR)) +{ + IPP_BAD_PTR4_RET(pA, pB, pQ, pR); + + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr); + pQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pQ, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pQ), ippStsContextMatchErr); + pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr); + + IPP_BADARG_RET(BN_SIZE(pB)== 1 && BN_NUMBER(pB)[0]==0, ippStsDivByZeroErr); + + IPP_BADARG_RET(BN_ROOM(pR)cmpRes) + SWAP_PTR(IppsBigNumState, x, y); + if(0==cmpRes) { + COPY_BNU(BN_NUMBER(g), BN_NUMBER(x), BN_SIZE(x)); + BN_SIGN(g) = ippBigNumPOS; + BN_SIZE(g) = BN_SIZE(x); + return ippStsNoErr; + } + if(BN_SIZE(x)==1) { + BNU_CHUNK_T gcd = cpGcd_BNU(BN_NUMBER(x)[0], BN_NUMBER(y)[0]); + BN_NUMBER(g)[0] = gcd; + BN_SIZE(g) = 1; + return ippStsNoErr; + } + } + + { + Ipp32u* xBuffer = (Ipp32u*)BN_BUFFER(x); + Ipp32u* yBuffer = (Ipp32u*)BN_BUFFER(y); + Ipp32u* gBuffer = (Ipp32u*)BN_BUFFER(g); + Ipp32u* xData = (Ipp32u*)BN_NUMBER(x); + Ipp32u* yData = (Ipp32u*)BN_NUMBER(y); + Ipp32u* gData = (Ipp32u*)BN_NUMBER(g); + cpSize nsXmax = BN_ROOM(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)); + cpSize nsYmax = BN_ROOM(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)); + cpSize nsGmax = BN_ROOM(g)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)); + cpSize nsX = BN_SIZE(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)); + cpSize nsY = BN_SIZE(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)); + + Ipp32u* T; + Ipp32u* u; + + FIX_BNU(xData, nsX); + FIX_BNU(yData, nsY); + + /* init buffers */ + ZEXPAND_COPY_BNU(xBuffer, nsX, xData, nsXmax); + ZEXPAND_COPY_BNU(yBuffer, nsY, yData, nsYmax); + + T = gBuffer; + u = gData; + ZEXPAND_BNU(T, 0, nsGmax); + ZEXPAND_BNU(u, 0, nsGmax); + + while(nsX > (cpSize)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) { + /* xx and yy is the high-order digits of x and y (yy could be 0) */ + + Ipp64u xx = (Ipp64u)(xBuffer[nsX-1]); + Ipp64u yy = (nsY < nsX)? 0 : (Ipp64u)(yBuffer[nsY-1]); + + Ipp64s AA = 1; + Ipp64s BB = 0; + Ipp64s CC = 0; + Ipp64s DD = 1; + Ipp64s t; + + while((yy+CC)!=0 && (yy+DD)!=0) { + Ipp64u q = ( xx + AA ) / ( yy + CC ); + Ipp64u q1 = ( xx + BB ) / ( yy + DD ); + if(q!=q1) + break; + t = AA - q*CC; + AA = CC; + CC = t; + t = BB - q*DD; + BB = DD; + DD = t; + t = xx - q*yy; + xx = yy; + yy = t; + } + + if(BB == 0) { + /* T = x mod y */ + cpSize nsT = cpMod_BNU32(xBuffer, nsX, yBuffer, nsY); + ZEXPAND_BNU(T, 0, nsGmax); + COPY_BNU(T, xBuffer, nsT); + /* a = b; b = T; */ + ZEXPAND_BNU(xBuffer, 0, nsXmax); + COPY_BNU(xBuffer, yBuffer, nsY); + ZEXPAND_BNU(yBuffer, 0, nsYmax); + COPY_BNU(yBuffer, T, nsY); + } + + else { + Ipp32u carry; + /* + // T = AA*x + BB*y; + // u = CC*x + DD*y; + // b = u; a = T; + */ + if((AA <= 0)&&(BB>=0)) { + Ipp32u a1 = (Ipp32u)(-AA); + carry = cpMulDgt_BNU32(T, yBuffer, nsY, (Ipp32u)BB); + carry = cpMulDgt_BNU32(u, xBuffer, nsY, a1); + /* T = BB*y - AA*x; */ + carry = cpSub_BNU32(T, T, u, nsY); + } + else { + if((AA >= 0)&&(BB<=0)) { + Ipp32u b1 = (Ipp32u)(-BB); + carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA); + carry = cpMulDgt_BNU32(u, yBuffer, nsY, b1); + /* T = AA*x - BB*y; */ + carry = cpSub_BNU32(T, T, u, nsY); + } + else { + /*AA*BB>=0 */ + carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA); + carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)BB); + /* T = AA*x + BB*y; */ + carry = cpAdd_BNU32(T, T, u, nsY); + } + } + + /* Now T is reserved. We use only u for intermediate results. */ + if((CC <= 0)&&(DD>=0)){ + Ipp32u c1 = (Ipp32u)(-CC); + /* u = x*CC; x = u; */ + carry = cpMulDgt_BNU32(u, xBuffer, nsY, c1); + COPY_BNU(xBuffer, u, nsY); + /* u = y*DD; */ + carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD); + /* u = DD*y - CC*x; */ + carry = cpSub_BNU32(u, u, xBuffer, nsY); + } + else { + if((CC >= 0)&&(DD<=0)){ + Ipp32u d1 = (Ipp32u)(-DD); + /* u = y*DD; y = u */ + carry = cpMulDgt_BNU32(u, yBuffer, nsY, d1); + COPY_BNU(yBuffer, u, nsY); + /* u = CC*x; */ + carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC); + /* u = CC*x - DD*y; */ + carry = cpSub_BNU32(u, u, yBuffer, nsY); + } + else { + /*CC*DD>=0 */ + /* y = y*DD */ + carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD); + COPY_BNU(yBuffer, u, nsY); + /* u = x*CC */ + carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC); + /* u = x*CC + y*DD */ + carry = cpAdd_BNU32(u, u, yBuffer, nsY); + } + } + + /* y = u; x = T; */ + COPY_BNU(yBuffer, u, nsY); + COPY_BNU(xBuffer, T, nsY); + } + + FIX_BNU(xBuffer, nsX); + FIX_BNU(yBuffer, nsY); + + if (nsY > nsX) { + SWAP_PTR(IppsBigNumState, x, y); + SWAP(nsX, nsY); + } + + if (nsY==1 && yBuffer[nsY-1]==0) { + /* End evaluation */ + ZEXPAND_BNU(gData, 0, nsGmax); + COPY_BNU(gData, xBuffer, nsX); + BN_SIZE(g) = INTERNAL_BNU_LENGTH(nsX); + BN_SIGN(g) = ippBigNumPOS; + return ippStsNoErr; + } + } + + BN_NUMBER(g)[0] = cpGcd_BNU(((BNU_CHUNK_T*)xBuffer)[0], ((BNU_CHUNK_T*)yBuffer)[0]); + BN_SIZE(g) = 1; + BN_SIGN(g) = ippBigNumPOS; + return ippStsNoErr; + } + } +} + + +/*F* +// Name: ippsModInv_BN +// +// Purpose: Multiplicative Inversion BigNum. +// +// Returns: Reason: +// ippStsNullPtrErr pA == NULL +// pM == NULL +// pR == NULL +// ippStsContextMatchErr BN_VALID_ID(pA) +// BN_VALID_ID(pM) +// BN_VALID_ID(pR) +// ippStsBadArgErr A<=0 +// ippStsBadModulusErr M<=0 +// ippStsScaleRangeErr A>=M +// ippStsOutOfRangeErr pR can not hold result +// ippStsNoErr no errors +// ippStsBadModulusErr inversion not found +// +// Parameters: +// pA source (value) BigNum +// pM source (modulus) BigNum +// pR reminder BigNum +// +*F*/ +IPPFUN(IppStatus, ippsModInv_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR) ) +{ + IPP_BAD_PTR3_RET(pA, pM, pR); + + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + pM = (IppsBigNumState*)( IPP_ALIGNED_PTR(pM, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pM), ippStsContextMatchErr); + pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr); + + IPP_BADARG_RET(BN_ROOM(pR) < BN_SIZE(pM), ippStsOutOfRangeErr); + IPP_BADARG_RET(BN_NEGATIVE(pA) || (BN_SIZE(pA)==1 && BN_NUMBER(pA)[0]==0), ippStsBadArgErr); + IPP_BADARG_RET(BN_NEGATIVE(pM) || (BN_SIZE(pM)==1 && BN_NUMBER(pM)[0]==0), ippStsBadModulusErr); + IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pM), BN_SIZE(pM)) >= 0, ippStsScaleRangeErr); + + { + cpSize nsR = cpModInv_BNU(BN_NUMBER(pR), + BN_NUMBER(pA), BN_SIZE(pA), + BN_NUMBER(pM), BN_SIZE(pM), + BN_BUFFER(pR), BN_BUFFER(pA), BN_BUFFER(pM)); + if(nsR) { + BN_SIGN(pR) = ippBigNumPOS; + BN_SIZE(pR) = nsR; + return ippStsNoErr; + } + else + return ippStsBadModulusErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpbnresource.h b/external/crypto_px/sources/ippcp/src/pcpbnresource.h new file mode 100644 index 0000000000..a77f6880c5 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnresource.h @@ -0,0 +1,51 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_BNRESOURCE_H) +#define _PCP_BNRESOURCE_H + + +typedef struct { + void* pNext; + IppsBigNumState* pBN; +} BigNumNode; + + +/* size (byte) of BN resource */ +int cpBigNumListGetSize(int feBitSize, int nodes); + +/* init BN resource */ +void cpBigNumListInit(int feBitSize, int nodes, BigNumNode* pList); + +/* get BN from resource */ +IppsBigNumState* cpBigNumListGet(BigNumNode** pList); + +#endif /* _PCP_BNRESOURCE_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpbnresourceca.c b/external/crypto_px/sources/ippcp/src/pcpbnresourceca.c new file mode 100644 index 0000000000..1c89c67a5f --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnresourceca.c @@ -0,0 +1,93 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbnresource.h" +#include "pcpbn.h" + +/* +// Size of BigNum List Buffer +*/ +int cpBigNumListGetSize(int feBitSize, int nodes) +{ + /* size of buffer per single big number */ + int bnSize; + ippsBigNumGetSize(BITS2WORD32_SIZE(feBitSize), &bnSize); + + /* size of buffer for whole list */ + return (ALIGN_VAL-1) + (sizeof(BigNumNode) + bnSize) * nodes; +} + +/* +// Init list +// +// Note: buffer for BN list must have appropriate alignment +*/ +void cpBigNumListInit(int feBitSize, int nodes, BigNumNode* pList) +{ + int itemSize; + /* length of Big Num */ + int bnLen = BITS2WORD32_SIZE(feBitSize); + /* size of buffer per single big number */ + ippsBigNumGetSize(bnLen, &itemSize); + /* size of list item */ + itemSize += sizeof(BigNumNode); + + { + int n; + /* init all nodes */ + BigNumNode* pNode = (BigNumNode*)( (Ipp8u*)pList + (nodes-1)*itemSize ); + BigNumNode* pNext = NULL; + for(n=0; npNext = pNext; + pNode->pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(tbnPtr, ALIGN_VAL) ); + ippsBigNumInit(bnLen, pNode->pBN); + pNext = pNode; + pNode = (BigNumNode*)( (Ipp8u*)pNode - itemSize); + } + } +} + +/* +// Get BigNum reference +*/ +IppsBigNumState* cpBigNumListGet(BigNumNode** ppList) +{ + if(*ppList) { + IppsBigNumState* ret = (*ppList)->pBN; + *ppList = (BigNumNode*)((*ppList)->pNext); + return ret; + } + else + return NULL; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpbnsetca.c b/external/crypto_px/sources/ippcp/src/pcpbnsetca.c new file mode 100644 index 0000000000..4d92c39032 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnsetca.c @@ -0,0 +1,119 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" + + +/*F* +// Name: ippsSetOctString_BN +// +// Purpose: Convert octet string into the BN value. +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pOctStr +// NULL == pBN +// +// ippStsLengthErr 0>strLen +// +// ippStsSizeErr BN_ROOM() is enough for keep actual strLen +// +// ippStsNoErr no errors +// +// Parameters: +// pOctStr pointer to the source octet string +// strLen octet string length +// pBN pointer to the target BN +// +*F*/ +IPPFUN(IppStatus, ippsSetOctString_BN,(const Ipp8u* pOctStr, cpSize strLen, + IppsBigNumState* pBN)) +{ + IPP_BAD_PTR2_RET(pOctStr, pBN); + + pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr); + + IPP_BADARG_RET((0>strLen), ippStsLengthErr); + + /* remove leading zeros */ + while(strLen && (0==pOctStr[0])) { + strLen--; + pOctStr++; + } + + /* test BN size */ + IPP_BADARG_RET((int)(sizeof(BNU_CHUNK_T)*BN_ROOM(pBN))strLen), ippStsLengthErr); + + return cpToOctStr_BNU(pOctStr,strLen, BN_NUMBER(pBN),BN_SIZE(pBN))? ippStsNoErr : ippStsLengthErr; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpbnu32arith.c b/external/crypto_px/sources/ippcp/src/pcpbnu32arith.c new file mode 100644 index 0000000000..cf04011d47 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnu32arith.c @@ -0,0 +1,234 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owncp.h" +#include "pcpbnumisc.h" +#include "pcpbnu32misc.h" +#include "pcpbnu32arith.h" + + +/* +// BNU32 addition +*/ +Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, cpSize ns) +{ + Ipp32u carry = 0; + cpSize i; + for(i=0; i>(32-1); + } + return borrow; +} + +/* +// BNU32 mul_by_digit +*/ +Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, Ipp32u val) +{ + Ipp32u carry = 0; + cpSize i; + for(i=0; i0; nsA--) { + Ipp64u r = (Ipp64u)*pR - (Ipp64u)(*pA++) * val - carry; + *pR++ = LODWORD(r); + carry = 0-HIDWORD(r); + } + return carry; +} + +/* +// BNU32 division +*/ +int cpDiv_BNU32(Ipp32u* pQ, cpSize* sizeQ, + Ipp32u* pX, cpSize sizeX, + Ipp32u* pY, cpSize sizeY) +{ + FIX_BNU(pY,sizeY); + FIX_BNU(pX,sizeX); + + /* special case */ + if(sizeX < sizeY) { + + if(pQ) { + pQ[0] = 0; + *sizeQ = 1; + } + + return sizeX; + } + + /* special case */ + if(1 == sizeY) { + int i; + Ipp32u r = 0; + for(i=(int)sizeX-1; i>=0; i--) { + Ipp64u tmp = MAKEDWORD(pX[i],r); + Ipp32u q = LODWORD(tmp / pY[0]); + r = LODWORD(tmp - q*pY[0]); + if(pQ) pQ[i] = q; + } + + pX[0] = r; + + if(pQ) { + FIX_BNU(pQ,sizeX); + *sizeQ = sizeX; + } + + return 1; + } + + + /* common case */ + { + cpSize qs = sizeX-sizeY+1; + + cpSize nlz = cpNLZ_BNU32(pY[sizeY-1]); + + /* normalization */ + pX[sizeX] = 0; + if(nlz) { + cpSize ni; + + pX[sizeX] = pX[sizeX-1] >> (32-nlz); + for(ni=sizeX-1; ni>0; ni--) + pX[ni] = (pX[ni]<>(32-nlz)); + pX[0] <<= nlz; + + for(ni=sizeY-1; ni>0; ni--) + pY[ni] = (pY[ni]<>(32-nlz)); + pY[0] <<= nlz; + } + + /* + // division + */ + { + Ipp32u yHi = pY[sizeY-1]; + + int i; + for(i=(int)qs-1; i>=0; i--) { + Ipp32u extend; + + /* estimate digit of quotient */ + Ipp64u tmp = MAKEDWORD(pX[i+sizeY-1], pX[i+sizeY]); + Ipp64u q = tmp / yHi; + Ipp64u r = tmp - q*yHi; + + /* tune estimation above */ + for(; HIDWORD(q) || (Ipp64u)q*pY[sizeY-2] > MAKEDWORD(pX[i+sizeY-2],r); ) { + q -= 1; + r += yHi; + if( HIDWORD(r) ) + break; + } + + /* multiply and subtract */ + extend = cpSubMulDgt_BNU32(pX+i, pY, sizeY, (Ipp32u)q); + extend = (pX[i+sizeY] -= extend); + + if(extend) { /* subtracted too much */ + q -= 1; + extend = cpAdd_BNU32(pX+i, pY, pX+i, sizeY); + pX[i+sizeY] += extend; + } + + /* store quotation digit */ + if(pQ) pQ[i] = LODWORD(q); + } + } + + /* de-normalization */ + if(nlz) { + cpSize ni; + for(ni=0; ni>nlz) | (pX[ni+1]<<(32-nlz)); + for(ni=0; ni>nlz) | (pY[ni+1]<<(32-nlz)); + pY[sizeY-1] >>= nlz; + } + + FIX_BNU(pX,sizeX); + + if(pQ) { + FIX_BNU(pQ,qs); + *sizeQ = qs; + } + + return sizeX; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpbnu32arith.h b/external/crypto_px/sources/ippcp/src/pcpbnu32arith.h new file mode 100644 index 0000000000..c72b77e18c --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnu32arith.h @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_CP_BNU32_ARITH_H) +#define _CP_BNU32_ARITH_H + +Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns); +Ipp32u cpSub_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns); +Ipp32u cpInc_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val); +Ipp32u cpDec_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val); + +Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int ns, Ipp32u val); +Ipp32u cpSubMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int nsA, Ipp32u val); + +int cpDiv_BNU32(Ipp32u* pQ, int* nsQ, Ipp32u* pX, int nsX, Ipp32u* pY, int nsY); +#define cpMod_BNU32(pX,sizeX, pM,sizeM) cpDiv_BNU32(NULL,NULL, (pX),(sizeX), (pM),(sizeM)) + +#endif /* _CP_BNU32_ARITH_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpbnu32misc.c b/external/crypto_px/sources/ippcp/src/pcpbnu32misc.c new file mode 100644 index 0000000000..e9a2dd7313 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnu32misc.c @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owncp.h" +#include "pcpbnuimpl.h" +#include "pcpbnumisc.h" +#include "pcpbnu32misc.h" + + +/* +// number of leading zeros +*/ +cpSize cpNLZ_BNU32(Ipp32u x) +{ + cpSize nlz = BITSIZE(Ipp32u); + if(x) { + nlz = 0; + if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; } + if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; } + if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; } + if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; } + if( 0==(x & 0x80000000) ) { nlz++; } + } + return nlz; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpbnu32misc.h b/external/crypto_px/sources/ippcp/src/pcpbnu32misc.h new file mode 100644 index 0000000000..a25c9f0d5a --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnu32misc.h @@ -0,0 +1,49 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_CP_BNU32_MISC_H) +#define _CP_BNU32_MISC_H + + +/* bit operations */ +#define BITSIZE_BNU32(p,ns) ((ns)*BNU_CHUNK_32BIT-cpNLZ_BNU32((p)[(ns)-1])) + +/* number of leading/trailing zeros */ +cpSize cpNLZ_BNU32(Ipp32u x); + +/* most significant BNU bit */ +__INLINE int cpMSBit_BNU32(const Ipp32u* pA, cpSize nsA) +{ + FIX_BNU(pA, nsA); + return nsA*BITSIZE(Ipp32u) - cpNLZ_BNU32(pA[nsA-1]) -1; +} + +#endif /* _CP_BNU32_MISC_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpbnuarith.c b/external/crypto_px/sources/ippcp/src/pcpbnuarith.c new file mode 100644 index 0000000000..c1a21e9065 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnuarith.c @@ -0,0 +1,301 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owncp.h" +#include "pcpbnuarith.h" +#include "pcpbnumisc.h" + + +/* Function cpAdd_BNU - addition of 2 BigNumbers */ +BNU_CHUNK_T cpAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns) +{ + BNU_CHUNK_T carry = 0; + cpSize i; + for(i=0; i b){ + gcd = a; + t = b; + } else { + t = a; + gcd = b; + } + + while (t != 0) { + r = gcd % t; + gcd = t; + t = r; + } + return gcd; +} + + +/* +// cpMAC_BNU +// +// Multiply with ACcumulation +// Computes r <- r + a * b, returns real size of the r in the size_r variable +// Returns 0 if there are no enought buffer size to write to r[MAX(size_r + 1, size_a + size_b) - 1] +// Returns 1 if no error +// +// Note: +// DO NOT run in inplace mode +// The minimum buffer size for the r must be (size_a + size_b - 1) +// the maximum buffer size for the r is MAX(size_r + 1, size_a + size_b) +*/ +static int cpMac_BNU(BNU_CHUNK_T* pR, cpSize nsR, + const BNU_CHUNK_T* pA, cpSize nsA, + const BNU_CHUNK_T* pB, cpSize nsB) +{ + /* cleanup the rest of destination buffer */ + ZEXPAND_BNU(pR, nsR, nsA+nsB-1); + + { + BNU_CHUNK_T expansion = 0; + cpSize i; + for(i=0; i> (BNU_CHUNK_BITS/2)) + +/* (carry,R) = A+B */ +#define ADD_AB(CARRY,R, A,B) \ +do { \ + BNU_CHUNK_T __s = (A) + (B); \ + (CARRY) = __s < (A); \ + (R) = __s; \ +} while(0) + +/* (carry,R) = A+B+C */ +#define ADD_ABC(CARRY,R, A,B,C) \ +do { \ + BNU_CHUNK_T __s = (A) + (B); \ + BNU_CHUNK_T __t1= __s < (A); \ + BNU_CHUNK_T __r = __s + (C); \ + BNU_CHUNK_T __t2 = __r < __s; \ + (CARRY) = __t1 + __t2; \ + (R) = __r; \ +} while(0) + +/* (borrow,R) = A-B */ +#define SUB_AB(BORROW,R, A,B) \ +do { \ + (BORROW) = (A)<(B); \ + (R) = (A)-(B); \ +} while(0) + +/* (borrow,R) = A-B-C */ +#define SUB_ABC(BORROW,R, A,B,C) \ +do { \ + BNU_CHUNK_T __s = (A) -( B); \ + BNU_CHUNK_T __t1= __s > (A); \ + BNU_CHUNK_T __r = __s - (C); \ + BNU_CHUNK_T __t2 = __r > __s; \ + (BORROW) = __t1 + __t2; \ + (R) = __r; \ +} while(0) + +/* (RH,RL) = A*B */ +#define MUL_AB(RH, RL, A, B) \ + do { \ + BNU_CHUNK_T __aL = LO_CHUNK((A)); \ + BNU_CHUNK_T __aH = HI_CHUNK((A)); \ + BNU_CHUNK_T __bL = LO_CHUNK((B)); \ + BNU_CHUNK_T __bH = HI_CHUNK((B)); \ + \ + BNU_CHUNK_T __x0 = (BNU_CHUNK_T) __aL * __bL; \ + BNU_CHUNK_T __x1 = (BNU_CHUNK_T) __aL * __bH; \ + BNU_CHUNK_T __x2 = (BNU_CHUNK_T) __aH * __bL; \ + BNU_CHUNK_T __x3 = (BNU_CHUNK_T) __aH * __bH; \ + \ + __x1 += HI_CHUNK(__x0); \ + __x1 += __x2; \ + if(__x1 < __x2) \ + __x3 += BNU_CHUNK_2H; \ + \ + (RH) = __x3 + HI_CHUNK(__x1); \ + (RL) = (__x1 << BNU_CHUNK_BITS/2) + LO_CHUNK(__x0); \ + } while (0) + +#endif /* _CP_BNU_IMPL_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpbnumisc.c b/external/crypto_px/sources/ippcp/src/pcpbnumisc.c new file mode 100644 index 0000000000..3e7eec89ff --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnumisc.c @@ -0,0 +1,208 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owncp.h" +#include "pcpbnumisc.h" + + +/* +// number of leading zeros +*/ +cpSize cpNLZ_BNU(BNU_CHUNK_T x) +{ + cpSize nlz = BNU_CHUNK_BITS; + if(x) { + nlz = 0; + #if (BNU_CHUNK_BITS == BNU_CHUNK_64BIT) + if( 0==(x & 0xFFFFFFFF00000000) ) { nlz +=32; x<<=32; } + if( 0==(x & 0xFFFF000000000000) ) { nlz +=16; x<<=16; } + if( 0==(x & 0xFF00000000000000) ) { nlz += 8; x<<= 8; } + if( 0==(x & 0xF000000000000000) ) { nlz += 4; x<<= 4; } + if( 0==(x & 0xC000000000000000) ) { nlz += 2; x<<= 2; } + if( 0==(x & 0x8000000000000000) ) { nlz++; } + #else + if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; } + if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; } + if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; } + if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; } + if( 0==(x & 0x80000000) ) { nlz++; } + #endif + } + return nlz; +} + +/* +// number of trailing zeros +*/ +cpSize cpNTZ_BNU(BNU_CHUNK_T x) +{ + cpSize ntz = BNU_CHUNK_BITS; + if(x) { + ntz = 0; + #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT) + if( 0==(x & 0x00000000FFFFFFFF) ) { ntz+=32; x>>=32; } + if( 0==(x & 0x000000000000FFFF) ) { ntz+=16; x>>=16; } + if( 0==(x & 0x00000000000000FF) ) { ntz+= 8; x>>= 8; } + if( 0==(x & 0x000000000000000F) ) { ntz+= 4; x>>= 4; } + if( 0==(x & 0x0000000000000003) ) { ntz+= 2; x>>= 2; } + if( 0==(x & 0x0000000000000001) ) { ntz++; } + #else + if( 0==(x & 0x0000FFFF) ) { ntz+=16; x>>=16; } + if( 0==(x & 0x000000FF) ) { ntz+= 8; x>>= 8; } + if( 0==(x & 0x0000000F) ) { ntz+= 4; x>>= 4; } + if( 0==(x & 0x00000003) ) { ntz+= 2; x>>= 2; } + if( 0==(x & 0x00000001) ) { ntz++; } + #endif + } + return ntz; +} + + +/* +// Logical shift right (including inplace) +// +// Returns new length +// +*/ +cpSize cpLSR_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits) +{ + cpSize nw = nBits/BNU_CHUNK_BITS; + cpSize n; + + pA += nw; + nsA -= nw; + + nBits %= BNU_CHUNK_BITS; + if(nBits) { + BNU_CHUNK_T hi; + BNU_CHUNK_T lo = pA[0]; + + for(n=0; n<(nsA-1); n++) { + hi = pA[n+1]; + pR[n] = (lo>>nBits) | (hi<<(BNU_CHUNK_BITS-nBits)); + lo = hi; + } + pR[nsA-1] = (lo>>nBits); + } + else { + for(n=0; n=(int)sizeof(BNU_CHUNK_T); nsA++,strLen-=(int)(sizeof(BNU_CHUNK_T))) { + /* pack sizeof(BNU_CHUNK_T) bytes into single BNU_CHUNK_T value*/ + *pA++ = + #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT) + +( (BNU_CHUNK_T)pStr[strLen-8]<<(8*7) ) + +( (BNU_CHUNK_T)pStr[strLen-7]<<(8*6) ) + +( (BNU_CHUNK_T)pStr[strLen-6]<<(8*5) ) + +( (BNU_CHUNK_T)pStr[strLen-5]<<(8*4) ) + #endif + +( (BNU_CHUNK_T)pStr[strLen-4]<<(8*3) ) + +( (BNU_CHUNK_T)pStr[strLen-3]<<(8*2) ) + +( (BNU_CHUNK_T)pStr[strLen-2]<<(8*1) ) + + (BNU_CHUNK_T)pStr[strLen-1]; + } + + /* convert the beginning of the string */ + if(strLen) { + BNU_CHUNK_T x = 0; + for(x=0; strLen>0; strLen--) { + BNU_CHUNK_T d = *pStr++; + x = (x<<8) + d; + } + *pA++ = x; + nsA++; + } + + return nsA; +} + +/* +// Convert BNU into HexString representation +// +// Returns length of the string or 0 if no success +*/ +cpSize cpToOctStr_BNU(Ipp8u* pStr, cpSize strLen, const BNU_CHUNK_T* pA, cpSize nsA) +{ + FIX_BNU(pA, nsA); + { + cpSize bnuBitSize = BITSIZE_BNU(pA, nsA); + if(bnuBitSize <= strLen*BYTESIZE) { + int cnvLen = 0; + BNU_CHUNK_T x = pA[nsA-1]; + + ZEXPAND_BNU(pStr, 0, strLen); + pStr += strLen - BITS2WORD8_SIZE(bnuBitSize); + + if(x) { + //int nb; + cpSize nb; + for(nb=cpNLZ_BNU(x)/BYTESIZE; nb<(cpSize)(sizeof(BNU_CHUNK_T)); cnvLen++, nb++) + *pStr++ = EBYTE(x, sizeof(BNU_CHUNK_T)-1-nb); + + for(--nsA; nsA>0; cnvLen+=sizeof(BNU_CHUNK_T), nsA--) { + x = pA[nsA-1]; + #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT) + *pStr++ = EBYTE(x,7); + *pStr++ = EBYTE(x,6); + *pStr++ = EBYTE(x,5); + *pStr++ = EBYTE(x,4); + #endif + *pStr++ = EBYTE(x,3); + *pStr++ = EBYTE(x,2); + *pStr++ = EBYTE(x,1); + *pStr++ = EBYTE(x,0); + } + } + return strLen; + } + else + return 0; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpbnumisc.h b/external/crypto_px/sources/ippcp/src/pcpbnumisc.h new file mode 100644 index 0000000000..8a27bea7a8 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpbnumisc.h @@ -0,0 +1,149 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_BNUMISC_H) +#define _PCP_BNUMISC_H + +#include "pcpbnuimpl.h" + + +/* bit operations */ +#define BITSIZE_BNU(p,ns) ((ns)*BNU_CHUNK_BITS-cpNLZ_BNU((p)[(ns)-1])) +#define BIT_BNU(bnu, ns,nbit) ((((nbit)>>BNU_CHUNK_LOG2) < (ns))? ((((bnu))[(nbit)>>BNU_CHUNK_LOG2] >>((nbit)&(BNU_CHUNK_BITS))) &1) : 0) +#define TST_BIT(bnu, nbit) ((((bnu))[(nbit)>>BNU_CHUNK_LOG2]) & ((BNU_CHUNK_T)1<<((nbit)&(BNU_CHUNK_BITS-1)))) +#define SET_BIT(bnu, nbit) ((((bnu))[(nbit)>>BNU_CHUNK_LOG2]) |= ((BNU_CHUNK_T)1<<((nbit)&(BNU_CHUNK_BITS-1)))) +#define CLR_BIT(bnu, nbit) ((((bnu))[(nbit)>>BNU_CHUNK_LOG2]) &=~((BNU_CHUNK_T)1<<((nbit)&(BNU_CHUNK_BITS-1)))) + +/* convert bitsize nbits into the number of BNU_CHUNK_T */ +#define BITS_BNU_CHUNK(nbits) (((nbits)+BNU_CHUNK_BITS-1)/BNU_CHUNK_BITS) + +/* mask for top BNU_CHUNK_T */ +#define MASK_BNU_CHUNK(nbits) ((BNU_CHUNK_T)(-1) >>((BNU_CHUNK_BITS- ((nbits)&(BNU_CHUNK_BITS-1))) &(BNU_CHUNK_BITS-1))) + +/* copy BNU content */ +#define COPY_BNU(dst, src, len) \ +{ \ + cpSize __idx; \ + for(__idx=0; __idx<(len); __idx++) (dst)[__idx] = (src)[__idx]; \ +} + +/* expand by zeros */ +#define ZEXPAND_BNU(srcdst,srcLen, dstLen) \ +{ \ + cpSize __idx; \ + for(__idx=(srcLen); __idx<(dstLen); __idx++) (srcdst)[__idx] = 0; \ +} + +/* copy and expand by zeros */ +#define ZEXPAND_COPY_BNU(dst,dstLen, src,srcLen) \ +{ \ + cpSize __idx; \ + for(__idx=0; __idx<(srcLen); __idx++) (dst)[__idx] = (src)[__idx]; \ + for(; __idx<(dstLen); __idx++) (dst)[__idx] = 0; \ +} + +/* fix actual length */ +#define FIX_BNU(src,srcLen) \ + for(; ((srcLen)>1) && (0==(src)[(srcLen)-1]); (srcLen)--) + + +/* copy and set */ +__INLINE void cpCpy_BNU(BNU_CHUNK_T* pDst, const BNU_CHUNK_T* pSrc, cpSize ns) +{ COPY_BNU(pDst, pSrc, ns); } + +__INLINE void cpSet_BNU(BNU_CHUNK_T* pDst, cpSize ns, BNU_CHUNK_T val) +{ + ZEXPAND_BNU(pDst, 0, ns); + pDst[0] = val; +} + +/* fix up */ +__INLINE int cpFix_BNU(const BNU_CHUNK_T* pA, int nsA) +{ + FIX_BNU(pA, nsA); + return nsA; +} + +/* comparison +// +// returns +// negative, if A < B +// 0, if A = B +// positive, if A > B +*/ +__INLINE int cpCmp_BNU(const BNU_CHUNK_T* pA, cpSize nsA, const BNU_CHUNK_T* pB, cpSize nsB) +{ + if(nsA!=nsB) + return nsA>nsB? 1 : -1; + else { + for(; nsA>0; nsA--) { + if(pA[nsA-1] > pB[nsA-1]) + return 1; + else if(pA[nsA-1] < pB[nsA-1]) + return -1; + } + return 0; + } +} +__INLINE int cpEqu_BNU_CHUNK(const BNU_CHUNK_T* pA, cpSize nsA, BNU_CHUNK_T b) +{ + return (pA[0]==b && 1==cpFix_BNU(pA, nsA)); +} + +/* +// test +// +// returns +// 0, if A = 0 +// >0, if A > 0 +// <0, looks like impossible (or error) case +*/ +__INLINE int cpTst_BNU(const BNU_CHUNK_T* pA, int nsA) +{ + for(; (nsA>0) && (0==pA[nsA-1]); nsA--) ; + return nsA; +} + +/* number of leading/trailing zeros */ +cpSize cpNLZ_BNU(BNU_CHUNK_T x); +cpSize cpNTZ_BNU(BNU_CHUNK_T x); + +/* logical shift left/right */ +int cpLSR_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits); + +/* least and most significant BNU bit */ +int cpMSBit_BNU(const BNU_CHUNK_T* pA, cpSize nsA); + +/* BNU <-> hex-string conversion */ +int cpToOctStr_BNU(Ipp8u* pStr, cpSize strLen, const BNU_CHUNK_T* pA, cpSize nsA); +int cpFromOctStr_BNU(BNU_CHUNK_T* pA, const Ipp8u* pStr, cpSize strLen); + +#endif /* _PCP_BNUMISC_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpcmac.h b/external/crypto_px/sources/ippcp/src/pcpcmac.h new file mode 100644 index 0000000000..cfeb9bf107 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpcmac.h @@ -0,0 +1,70 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_CMAC_H) +#define _PCP_CMAC_H + +#include "pcprij.h" + + +/* +// Rijndael128 based CMAC context +*/ +struct _cpAES_CMAC { + IppCtxId idCtx; /* CMAC identifier */ + int index; /* internal buffer entry (free) */ + int dummy[2]; /* align-16 */ + Ipp8u k1[MBS_RIJ128]; /* k1 subkey */ + Ipp8u k2[MBS_RIJ128]; /* k2 subkey */ + Ipp8u mBuffer[MBS_RIJ128];/* buffer */ + Ipp8u mMAC[MBS_RIJ128]; /* intermediate digest */ + __ALIGN16 /* aligned AES context */ + IppsAESSpec mCipherCtx; +}; + +/* alignment */ +#define AESCMAC_ALIGNMENT (RIJ_ALIGNMENT) + +/* +// Useful macros +*/ +#define CMAC_ID(stt) ((stt)->idCtx) +#define CMAC_INDX(stt) ((stt)->index) +#define CMAC_K1(stt) ((stt)->k1) +#define CMAC_K2(stt) ((stt)->k2) +#define CMAC_BUFF(stt) ((stt)->mBuffer) +#define CMAC_MAC(stt) ((stt)->mMAC) +#define CMAC_CIPHER(stt) ((stt)->mCipherCtx) + +/* valid context ID */ +#define VALID_AESCMAC_ID(ctx) (CMAC_ID((ctx))==idCtxCMAC) + +#endif /* _PCP_CMAC_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpeccp.h b/external/crypto_px/sources/ippcp/src/pcpeccp.h new file mode 100644 index 0000000000..c5bf622be5 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccp.h @@ -0,0 +1,230 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_ECCP_H) +#define _PCP_ECCP_H + +#include "pcpbnresource.h" +#include "pcppma.h" +#include "pcpeccppoint.h" +#include "pcpeccpsscm.h" + + +typedef struct eccp_method_st ECCP_METHOD; + +/* +// ECC over prime GF(p) Context +*/ +struct _cpECCP { + IppCtxId idCtx; /* prime EC identifier */ + + IppsBigNumState* pPrime; /* specify finite field GF(p) */ + IppsBigNumState* pA; /* scecify A & B of EC equation: */ + IppsBigNumState* pB; /* y^2 = x^3 + A*x + B (mod)p */ + + IppsBigNumState* pGX; /* Base Point (X coordinate) */ + IppsBigNumState* pGY; /* Base Point (Y coordinate) */ + IppsBigNumState* pR; /* order (r) of Base Point */ + /* fields above mainly for ippsECCPSet()/ippsECCPGet() */ + + Ipp32u eccStandard;/* generic/standard ecc */ + + ECCP_METHOD* pMethod; + + int gfeBitSize; /* size (bits) of field element */ + int ordBitSize; /* size (bits) of BP order */ + + int a_3; /* ==1 if A==-3 or A==P-3 */ + IppsBigNumState* pAenc; /* internal formatted pA value */ + IppsBigNumState* pBenc; /* internal formatted pB value */ + IppsMontState* pMontP; /* montromery engine (modulo p) */ + + IppsECCPPointState* pGenc; /* internal formatted Base Point */ + IppsBigNumState* pCofactor; /* cofactor = #E/base_point_order*/ + IppsMontState* pMontR; /* montromery engine (modulo r) */ + + IppsBigNumState* pPrivate; /* private key */ + IppsECCPPointState* pPublic; /* public key (affine) */ + IppsBigNumState* pPrivateE; /* ephemeral private key */ + IppsECCPPointState* pPublicE; /* ephemeral public key (affine) */ + + IppsPrimeState* pPrimary; /* prime engine */ + + Ipp8u* pSscmBuffer;/* pointer to sscm buffer */ + + BigNumNode* pBnList; /* list of big numbers */ +}; + +/* some useful constants */ +#define BNLISTSIZE (32) /* list size (probably less) */ + +/* +// Contetx Access Macros +*/ +#define ECP_ID(ctx) ((ctx)->idCtx) + +#define ECP_PRIME(ctx) ((ctx)->pPrime) +#define ECP_A(ctx) ((ctx)->pA) +#define ECP_B(ctx) ((ctx)->pB) + +#define ECP_GX(ctx) ((ctx)->pGX) +#define ECP_GY(ctx) ((ctx)->pGY) +#define ECP_ORDER(ctx) ((ctx)->pR) + +#define ECP_TYPE(ctx) ((ctx)->eccStandard) + +#define ECP_METHOD(ctx) ((ctx)->pMethod) + +#define ECP_GFEBITS(ctx) ((ctx)->gfeBitSize) +#define ECP_ORDBITS(ctx) ((ctx)->ordBitSize) + +#define ECP_AMI3(ctx) ((ctx)->a_3) +#define ECP_AENC(ctx) ((ctx)->pAenc) +#define ECP_BENC(ctx) ((ctx)->pBenc) +#define ECP_PMONT(ctx) ((ctx)->pMontP) + +#define ECP_GENC(ctx) ((ctx)->pGenc) +#define ECP_COFACTOR(ctx) ((ctx)->pCofactor) +#define ECP_RMONT(ctx) ((ctx)->pMontR) + +#define ECP_PRIVATE(ctx) ((ctx)->pPrivate) +#define ECP_PUBLIC(ctx) ((ctx)->pPublic) +#define ECP_PRIVATE_E(ctx) ((ctx)->pPrivateE) +#define ECP_PUBLIC_E(ctx) ((ctx)->pPublicE) + +#define ECP_PRIMARY(ctx) ((ctx)->pPrimary) +#define ECP_SCCMBUFF(ctx) ((ctx)->pSscmBuffer) +#define ECP_BNCTX(ctx) ((ctx)->pBnList) + +#define ECP_VALID_ID(ctx) (ECP_ID((ctx))==idCtxECCP) + +/* +// Recommended (Standard) Domain Parameters +*/ +extern const Ipp32u secp112r1_p[]; // (2^128 -3)/76439 +extern const Ipp32u secp112r1_a[]; +extern const Ipp32u secp112r1_b[]; +extern const Ipp32u secp112r1_gx[]; +extern const Ipp32u secp112r1_gy[]; +extern const Ipp32u secp112r1_r[]; +extern Ipp32u secp112r1_h; + +extern const Ipp32u secp112r2_p[]; // (2^128 -3)/76439 +extern const Ipp32u secp112r2_a[]; +extern const Ipp32u secp112r2_b[]; +extern const Ipp32u secp112r2_gx[]; +extern const Ipp32u secp112r2_gy[]; +extern const Ipp32u secp112r2_r[]; +extern Ipp32u secp112r2_h; + +extern const Ipp32u secp128r1_p[]; // 2^128 -2^97 -1 +extern const Ipp32u secp128r1_a[]; +extern const Ipp32u secp128r1_b[]; +extern const Ipp32u secp128r1_gx[]; +extern const Ipp32u secp128r1_gy[]; +extern const Ipp32u secp128r1_r[]; +extern Ipp32u secp128r1_h; + +extern const Ipp32u* secp128_mx[]; + +extern const Ipp32u secp128r2_p[]; // 2^128 -2^97 -1 +extern const Ipp32u secp128r2_a[]; +extern const Ipp32u secp128r2_b[]; +extern const Ipp32u secp128r2_gx[]; +extern const Ipp32u secp128r2_gy[]; +extern const Ipp32u secp128r2_r[]; +extern Ipp32u secp128r2_h; + +extern const Ipp32u secp160r1_p[]; // 2^160 -2^31 -1 +extern const Ipp32u secp160r1_a[]; +extern const Ipp32u secp160r1_b[]; +extern const Ipp32u secp160r1_gx[]; +extern const Ipp32u secp160r1_gy[]; +extern const Ipp32u secp160r1_r[]; +extern Ipp32u secp160r1_h; + +extern const Ipp32u secp160r2_p[]; // 2^160 -2^32 -2^14 -2^12 -2^9 -2^8 -2^7 -2^2 -1 +extern const Ipp32u secp160r2_a[]; +extern const Ipp32u secp160r2_b[]; +extern const Ipp32u secp160r2_gx[]; +extern const Ipp32u secp160r2_gy[]; +extern const Ipp32u secp160r2_r[]; +extern Ipp32u secp160r2_h; + +extern const Ipp32u secp192r1_p[]; // 2^192 -2^64 -1 +extern const Ipp32u secp192r1_a[]; +extern const Ipp32u secp192r1_b[]; +extern const Ipp32u secp192r1_gx[]; +extern const Ipp32u secp192r1_gy[]; +extern const Ipp32u secp192r1_r[]; +extern Ipp32u secp192r1_h; + +extern const Ipp32u secp224r1_p[]; // 2^224 -2^96 +1 +extern const Ipp32u secp224r1_a[]; +extern const Ipp32u secp224r1_b[]; +extern const Ipp32u secp224r1_gx[]; +extern const Ipp32u secp224r1_gy[]; +extern const Ipp32u secp224r1_r[]; +extern Ipp32u secp224r1_h; + +extern const Ipp32u secp256r1_p[]; // 2^256 -2^224 +2^192 +2^96 -1 +extern const Ipp32u secp256r1_a[]; +extern const Ipp32u secp256r1_b[]; +extern const Ipp32u secp256r1_gx[]; +extern const Ipp32u secp256r1_gy[]; +extern const Ipp32u secp256r1_r[]; +extern Ipp32u secp256r1_h; + +extern const Ipp32u secp384r1_p[]; // 2^384 -2^128 -2^96 +2^32 -1 +extern const Ipp32u secp384r1_a[]; +extern const Ipp32u secp384r1_b[]; +extern const Ipp32u secp384r1_gx[]; +extern const Ipp32u secp384r1_gy[]; +extern const Ipp32u secp384r1_r[]; +extern Ipp32u secp384r1_h; + +extern const Ipp32u secp521r1_p[]; // 2^521 -1 +extern const Ipp32u secp521r1_a[]; +extern const Ipp32u secp521r1_b[]; +extern const Ipp32u secp521r1_gx[]; +extern const Ipp32u secp521r1_gy[]; +extern const Ipp32u secp521r1_r[]; +extern Ipp32u secp521r1_h; + +/* half of some std modulus */ +extern const Ipp32u h_secp128r1_p[]; +extern const Ipp32u h_secp192r1_p[]; +extern const Ipp32u h_secp224r1_p[]; +extern const Ipp32u h_secp256r1_p[]; +extern const Ipp32u h_secp384r1_p[]; +extern const Ipp32u h_secp521r1_p[]; + +#endif /* _PCP_ECCP_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpeccpdpca.c b/external/crypto_px/sources/ippcp/src/pcpeccpdpca.c new file mode 100644 index 0000000000..f5b9f5b060 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccpdpca.c @@ -0,0 +1,370 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccp.h" +#include "pcpeccppoint.h" +#include "pcpbnresource.h" +#include "pcpeccpmethod.h" +#include "pcpeccpmethodcom.h" +#include "pcppma.h" + + +/*F* +// Name: ippsECCPSet +// +// Purpose: Set EC Domain Parameters. +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pPrime +// NULL == pA +// NULL == pB +// NULL == pGX +// NULL == pGY +// NULL == pOrder +// NULL == pECC +// +// ippStsContextMatchErr illegal pPrime->idCtx +// illegal pA->idCtx +// illegal pB->idCtx +// illegal pGX->idCtx +// illegal pGY->idCtx +// illegal pOrder->idCtx +// illegal pECC->idCtx +// +// ippStsRangeErr not enough room for: +// pPrime +// pA, pB, +// pGX,pGY +// pOrder +// +// ippStsRangeErr 0>= cofactor +// +// ippStsNoErr no errors +// +// Parameters: +// pPrime pointer to the prime (specify FG(p)) +// pA pointer to the A coefficient of EC equation +// pB pointer to the B coefficient of EC equation +// pGX,pGY pointer to the Base Point (x and y coordinates) of EC +// pOrder pointer to the Base Point order +// cofactor cofactor value +// pECC pointer to the ECC context +// +*F*/ +static +void ECCPSetDP(IppECCType flag, + int primeSize, const Ipp32u* pPrime, + int aSize, const Ipp32u* pA, + int bSize, const Ipp32u* pB, + int gxSize, const Ipp32u* pGx, + int gySize, const Ipp32u* pGy, + int orderSize, const Ipp32u* pOrder, + Ipp32u cofactor, + IppsECCPState* pECC) +{ + ECP_TYPE(pECC) = flag; + + /* reset size (bits) of field element */ + ECP_GFEBITS(pECC) = cpMSBit_BNU32(pPrime, primeSize) +1; + /* reset size (bits) of Base Point order */ + ECP_ORDBITS(pECC) = cpMSBit_BNU32(pOrder, orderSize) +1; + + /* set up prime */ + ippsSet_BN(ippBigNumPOS, primeSize, pPrime, ECP_PRIME(pECC)); + /* set up A */ + ippsSet_BN(ippBigNumPOS, aSize, pA, ECP_A(pECC)); + /* test A */ + BN_Word(ECP_B(pECC), 3); + PMA_add(ECP_B(pECC), ECP_A(pECC), ECP_B(pECC), ECP_PRIME(pECC)); + ECP_AMI3(pECC) = IsZero_BN(ECP_B(pECC)); + /* set up B */ + ippsSet_BN(ippBigNumPOS, bSize, pB, ECP_B(pECC)); + + /* set up affine coordinates of Base Point and order */ + ippsSet_BN(ippBigNumPOS, gxSize, pGx, ECP_GX(pECC)); + ippsSet_BN(ippBigNumPOS, gySize, pGy, ECP_GY(pECC)); + ippsSet_BN(ippBigNumPOS, orderSize, pOrder, ECP_ORDER(pECC)); + + /* set up cofactor */ + //ippsSet_BN(ippBigNumPOS, 1, &((Ipp32u)cofactor), ECP_COFACTOR(pECC)); + ippsSet_BN(ippBigNumPOS, 1, &cofactor, ECP_COFACTOR(pECC)); + + /* montgomery engine (prime) */ + if( ippStsNoErr == ippsMontSet((Ipp32u*)BN_NUMBER(ECP_PRIME(pECC)), BN_SIZE32(ECP_PRIME(pECC)), ECP_PMONT(pECC)) ) { + /* modulo reduction and montgomery form of A and B */ + PMA_mod(ECP_AENC(pECC), ECP_A(pECC), ECP_PRIME(pECC)); + PMA_enc(ECP_AENC(pECC), ECP_AENC(pECC), ECP_PMONT(pECC)); + PMA_mod(ECP_BENC(pECC), ECP_B(pECC), ECP_PRIME(pECC)); + PMA_enc(ECP_BENC(pECC), ECP_BENC(pECC), ECP_PMONT(pECC)); + /* projective coordinates and montgomery form of of Base Point */ + if( ( IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity1(ECP_GX(pECC), ECP_GY(pECC))) || + (!IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity0(ECP_GX(pECC), ECP_GY(pECC))) ) + ECCP_SetPointToInfinity(ECP_GENC(pECC)); + else { + ECP_METHOD(pECC)->SetPointProjective(ECP_GX(pECC), ECP_GY(pECC), BN_ONE_REF(), ECP_GENC(pECC), pECC); + } + } + + /* montgomery engine (order) */ + if( ippStsNoErr == ippsMontSet((Ipp32u*)BN_NUMBER(ECP_ORDER(pECC)), BN_SIZE32(ECP_ORDER(pECC)), ECP_RMONT(pECC)) ) + PMA_enc(ECP_COFACTOR(pECC), ECP_COFACTOR(pECC), ECP_RMONT(pECC)); + + /* set zero private keys */ + BN_Word(ECP_PRIVATE(pECC), 0); + BN_Word(ECP_PRIVATE_E(pECC), 0); + + /* set infinity public keys */ + ECCP_SetPointToInfinity(ECP_PUBLIC(pECC)); + ECCP_SetPointToInfinity(ECP_PUBLIC_E(pECC)); +} + + +IPPFUN(IppStatus, ippsECCPSet, (const IppsBigNumState* pPrime, + const IppsBigNumState* pA, const IppsBigNumState* pB, + const IppsBigNumState* pGX,const IppsBigNumState* pGY,const IppsBigNumState* pOrder, + int cofactor, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test pPrime */ + IPP_BAD_PTR1_RET(pPrime); + pPrime = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrime, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pPrime), ippStsContextMatchErr); + IPP_BADARG_RET((cpBN_bitsize(pPrime)>ECP_GFEBITS(pECC)), ippStsRangeErr); + + /* test pA and pB */ + IPP_BAD_PTR2_RET(pA,pB); + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, ALIGN_VAL) ); + pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr); + IPP_BADARG_RET((cpBN_bitsize(pA)>ECP_GFEBITS(pECC)), ippStsRangeErr); + IPP_BADARG_RET((cpBN_bitsize(pB)>ECP_GFEBITS(pECC)), ippStsRangeErr); + + /* test pG and pGorder pointers */ + IPP_BAD_PTR3_RET(pGX,pGY, pOrder); + pGX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGX, ALIGN_VAL) ); + pGY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGY, ALIGN_VAL) ); + pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pGX), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pGY), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr); + IPP_BADARG_RET((cpBN_bitsize(pGX)>ECP_GFEBITS(pECC)), ippStsRangeErr); + IPP_BADARG_RET((cpBN_bitsize(pGY)>ECP_GFEBITS(pECC)), ippStsRangeErr); + IPP_BADARG_RET((cpBN_bitsize(pOrder)>ECP_ORDBITS(pECC)), ippStsRangeErr); + + /* test cofactor */ + IPP_BADARG_RET(!(0idCtx +// +// ippStsECCInvalidFlagErr invalid flag +// +// ippStsNoErr no errors +// +// Parameters: +// flag specify standard ECC parameter(s) to be setup +// pECC pointer to the ECC context +// +*F*/ +IPPFUN(IppStatus, ippsECCPSetStd, (IppECCType flag, IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); + + switch(flag) { + case IppECCPStd112r1: + ECCPSetDP(IppECCPStd112r1, + BITS2WORD32_SIZE(112), secp112r1_p, + BITS2WORD32_SIZE(112), secp112r1_a, + BITS2WORD32_SIZE(112), secp112r1_b, + BITS2WORD32_SIZE(112), secp112r1_gx, + BITS2WORD32_SIZE(112), secp112r1_gy, + BITS2WORD32_SIZE(112), secp112r1_r, + secp112r1_h, pECC); + break; + + case IppECCPStd112r2: + ECCPSetDP(IppECCPStd112r2, + BITS2WORD32_SIZE(112), secp112r2_p, + BITS2WORD32_SIZE(112), secp112r2_a, + BITS2WORD32_SIZE(112), secp112r2_b, + BITS2WORD32_SIZE(112), secp112r2_gx, + BITS2WORD32_SIZE(112), secp112r2_gy, + BITS2WORD32_SIZE(112), secp112r2_r, + secp112r2_h, pECC); + break; + + case IppECCPStd128r1: + ECCPSetDP(IppECCPStd128r1, + BITS2WORD32_SIZE(128), secp128r1_p, + BITS2WORD32_SIZE(128), secp128r1_a, + BITS2WORD32_SIZE(128), secp128r1_b, + BITS2WORD32_SIZE(128), secp128r1_gx, + BITS2WORD32_SIZE(128), secp128r1_gy, + BITS2WORD32_SIZE(128), secp128r1_r, + secp128r1_h, pECC); + break; + + case IppECCPStd128r2: + ECCPSetDP(IppECCPStd128r2, + BITS2WORD32_SIZE(128), secp128r2_p, + BITS2WORD32_SIZE(128), secp128r2_a, + BITS2WORD32_SIZE(128), secp128r2_b, + BITS2WORD32_SIZE(128), secp128r2_gx, + BITS2WORD32_SIZE(128), secp128r2_gy, + BITS2WORD32_SIZE(128), secp128r2_r, + secp128r2_h, pECC); + break; + + case IppECCPStd160r1: + ECCPSetDP(IppECCPStd160r1, + BITS2WORD32_SIZE(160), secp160r1_p, + BITS2WORD32_SIZE(160), secp160r1_a, + BITS2WORD32_SIZE(160), secp160r1_b, + BITS2WORD32_SIZE(160), secp160r1_gx, + BITS2WORD32_SIZE(160), secp160r1_gy, + BITS2WORD32_SIZE(161), secp160r1_r, + secp160r1_h, pECC); + break; + + case IppECCPStd160r2: + ECCPSetDP(IppECCPStd160r2, + BITS2WORD32_SIZE(160), secp160r2_p, + BITS2WORD32_SIZE(160), secp160r2_a, + BITS2WORD32_SIZE(160), secp160r2_b, + BITS2WORD32_SIZE(160), secp160r2_gx, + BITS2WORD32_SIZE(160), secp160r2_gy, + BITS2WORD32_SIZE(161), secp160r2_r, + secp160r2_h, pECC); + break; + + case IppECCPStd192r1: + ECCPSetDP(IppECCPStd192r1, + BITS2WORD32_SIZE(192), secp192r1_p, + BITS2WORD32_SIZE(192), secp192r1_a, + BITS2WORD32_SIZE(192), secp192r1_b, + BITS2WORD32_SIZE(192), secp192r1_gx, + BITS2WORD32_SIZE(192), secp192r1_gy, + BITS2WORD32_SIZE(192), secp192r1_r, + secp192r1_h, pECC); + break; + + case IppECCPStd224r1: + ECCPSetDP(IppECCPStd224r1, + BITS2WORD32_SIZE(224), secp224r1_p, + BITS2WORD32_SIZE(224), secp224r1_a, + BITS2WORD32_SIZE(224), secp224r1_b, + BITS2WORD32_SIZE(224), secp224r1_gx, + BITS2WORD32_SIZE(224), secp224r1_gy, + BITS2WORD32_SIZE(224), secp224r1_r, + secp224r1_h, pECC); + break; + + case IppECCPStd256r1: + ECCPSetDP(IppECCPStd256r1, + BITS2WORD32_SIZE(256), secp256r1_p, + BITS2WORD32_SIZE(256), secp256r1_a, + BITS2WORD32_SIZE(256), secp256r1_b, + BITS2WORD32_SIZE(256), secp256r1_gx, + BITS2WORD32_SIZE(256), secp256r1_gy, + BITS2WORD32_SIZE(256), secp256r1_r, + secp256r1_h, pECC); + break; + + case IppECCPStd384r1: + ECCPSetDP(IppECCPStd384r1, + BITS2WORD32_SIZE(384), secp384r1_p, + BITS2WORD32_SIZE(384), secp384r1_a, + BITS2WORD32_SIZE(384), secp384r1_b, + BITS2WORD32_SIZE(384), secp384r1_gx, + BITS2WORD32_SIZE(384), secp384r1_gy, + BITS2WORD32_SIZE(384), secp384r1_r, + secp384r1_h, pECC); + break; + + case IppECCPStd521r1: + ECCPSetDP(IppECCPStd521r1, + BITS2WORD32_SIZE(521), secp521r1_p, + BITS2WORD32_SIZE(521), secp521r1_a, + BITS2WORD32_SIZE(521), secp521r1_b, + BITS2WORD32_SIZE(521), secp521r1_gx, + BITS2WORD32_SIZE(521), secp521r1_gy, + BITS2WORD32_SIZE(521), secp521r1_r, + secp521r1_h, pECC); + break; + + default: + return ippStsECCInvalidFlagErr; + } + + return ippStsNoErr; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccpgenkeyca.c b/external/crypto_px/sources/ippcp/src/pcpeccpgenkeyca.c new file mode 100644 index 0000000000..aab1fd4f29 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccpgenkeyca.c @@ -0,0 +1,107 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccppoint.h" +#include "pcpeccpmethod.h" +#include "pcpeccpmethodcom.h" + + +/*F* +// Name: ippsECCPGenKeyPair +// +// Purpose: Generate (private,public) Key Pair +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pPrivate +// NULL == pPublic +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pPrivate->idCtx +// illegal pPublic->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pPrivate pointer to the resultant private key +// pPublic pointer to the resultant public key +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPGenKeyPair, (IppsBigNumState* pPrivate, IppsECCPPointState* pPublic, + IppsECCPState* pECC, + IppBitSupplier rndFunc, void* pRndParam)) +{ + IPP_BAD_PTR2_RET(pECC, rndFunc); + + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test private/public keys */ + IPP_BAD_PTR2_RET(pPrivate,pPublic); + pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) ); + pPublic = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublic, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr); + IPP_BADARG_RET((BN_ROOM(pPrivate)*BITSIZE(BNU_CHUNK_T)MulBasePoint(pPrivate, pPublic, pECC, ECP_BNCTX(pECC)); + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccpinitca.c b/external/crypto_px/sources/ippcp/src/pcpeccpinitca.c new file mode 100644 index 0000000000..ef7be299ea --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccpinitca.c @@ -0,0 +1,305 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccp.h" +#include "pcpeccppoint.h" +#include "pcpbnresource.h" +#include "pcpeccpmethod.h" +#include "pcpeccpsscm.h" +#include "pcptool.h" + + +/*F* +// Name: ippsECCPGetSize +// +// Purpose: Returns size of ECC context (bytes). +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pSize +// +// ippStsSizeErr 2>feBitSize +// +// ippStsNoErr no errors +// +// Parameters: +// feBitSize size of field element (bits) +// pSize pointer to the size of internal ECC context +// +*F*/ +IPPFUN(IppStatus, ippsECCPGetSize, (int feBitSize, int *pSize)) +{ + /* test size's pointer */ + IPP_BAD_PTR1_RET(pSize); + + /* test size of field element */ + IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr); + + { + int bn1Size; + int bn2Size; + int pointSize; + int mont1Size; + int mont2Size; + int primeSize; + int listSize; + + /* size of field element */ + int gfeSize = BITS2WORD32_SIZE(feBitSize); + /* size of order */ + int ordSize = BITS2WORD32_SIZE(feBitSize+1); + + /* size of sscm buffer */ + int w = cpECCP_OptimalWinSize(feBitSize+1); + int nPrecomputed = 1<feBitSize +// +// ippStsNoErr no errors +// +// Parameters: +// feBitSize size of field element (bits) +// pECC pointer to the ECC context +// +*F*/ +IPPFUN(IppStatus, ippsECCPInit, (int feBitSize, IppsECCPState* pECC)) +{ + /* test pECC pointer */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + + /* test size of field element */ + IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr); + + /* clear context */ + PaddBlock(0, pECC, sizeof(IppsECCPState)); + + /* context ID */ + ECP_ID(pECC) = idCtxECCP; + + /* generic EC */ + ECP_TYPE(pECC) = IppECCArbitrary; + + /* size of field element & BP order */ + ECP_GFEBITS(pECC) = feBitSize; + ECP_ORDBITS(pECC) = feBitSize+1; + + /* + // init other context fields + */ + { + int bn1Size; + int bn2Size; + int pointSize; + int mont1Size; + int mont2Size; + int primeSize; + + /* size of field element */ + int gfeSize = BITS2WORD32_SIZE(feBitSize); + /* size of order */ + int ordSize = BITS2WORD32_SIZE(feBitSize+1); + + /* size of sscm buffer */ + int w = cpECCP_OptimalWinSize(feBitSize+1); + int nPrecomputed = 1< pP==pQ (maybe both pP and pQ are at Infinity) +// returns 1 => pP!=pQ +// +// Note +// In general we check: +// P_X*Q_Z^2 ~ Q_X*P_Z^2 +// P_Y*Q_Z^3 ~ Q_Y*P_Z^3 +*/ +int ECCP_ComparePoint(const IppsECCPPointState* pP, + const IppsECCPPointState* pQ, + const IppsECCPState* pECC, + BigNumNode* pList) +{ + /* P or/and Q at Infinity */ + if( ECCP_IsPointAtInfinity(pP) ) + return ECCP_IsPointAtInfinity(pQ)? 0:1; + if( ECCP_IsPointAtInfinity(pQ) ) + return ECCP_IsPointAtInfinity(pP)? 0:1; + + /* (P_Z==1) && (Q_Z==1) */ + if( ECP_POINT_AFFINE(pP) && ECP_POINT_AFFINE(pQ) ) + return ((0==cpBN_cmp(ECP_POINT_X(pP),ECP_POINT_X(pQ))) && (0==cpBN_cmp(ECP_POINT_Y(pP),ECP_POINT_Y(pQ))))? 0:1; + + { + IppsMontState* pMont = ECP_PMONT(pECC); + + IppsBigNumState* pPtmp = cpBigNumListGet(&pList); + IppsBigNumState* pQtmp = cpBigNumListGet(&pList); + IppsBigNumState* pPZ = cpBigNumListGet(&pList); + IppsBigNumState* pQZ = cpBigNumListGet(&pList); + + /* P_X*Q_Z^2 ~ Q_X*P_Z^2 */ + if( !ECP_POINT_AFFINE(pQ) ) { + PMA_sqre(pQZ, ECP_POINT_Z(pQ), pMont); /* Ptmp = P_X*Q_Z^2 */ + PMA_mule(pPtmp, ECP_POINT_X(pP), pQZ, pMont); + } + else { + PMA_set(pPtmp, ECP_POINT_X(pP)); + } + if( !ECP_POINT_AFFINE(pP) ) { + PMA_sqre(pPZ, ECP_POINT_Z(pP), pMont); /* Qtmp = Q_X*P_Z^2 */ + PMA_mule(pQtmp, ECP_POINT_X(pQ), pPZ, pMont); + } + else { + PMA_set(pQtmp, ECP_POINT_X(pQ)); + } + if ( cpBN_cmp(pPtmp, pQtmp) ) + return 1; /* points are different: (P_X*Q_Z^2) != (Q_X*P_Z^2) */ + + /* P_Y*Q_Z^3 ~ Q_Y*P_Z^3 */ + if( !ECP_POINT_AFFINE(pQ) ) { + PMA_mule(pQZ, pQZ, ECP_POINT_Z(pQ), pMont); /* Ptmp = P_Y*Q_Z^3 */ + PMA_mule(pPtmp, ECP_POINT_Y(pP), pQZ, pMont); + } + else { + PMA_set(pPtmp, ECP_POINT_Y(pP)); + } + if( !ECP_POINT_AFFINE(pP) ) { + PMA_mule(pPZ, pPZ, ECP_POINT_Z(pP), pMont); /* Qtmp = Q_Y*P_Z^3 */ + PMA_mule(pQtmp, ECP_POINT_Y(pQ), pPZ, pMont); + } + else { + PMA_set(pQtmp, ECP_POINT_Y(pQ)); + } + return cpBN_cmp(pPtmp, pQtmp)? 1:0; + } +} + +/* +// ECCP_NegPoint +// +// Negative point +*/ +void ECCP_NegPoint(const IppsECCPPointState* pP, + IppsECCPPointState* pR, + const IppsECCPState* pECC) +{ + /* test point at Infinity */ + if( ECCP_IsPointAtInfinity(pP) ) + ECCP_SetPointToInfinity(pR); + + else { + IppsBigNumState* pModulo = ECP_PRIME(pECC); + + if( pP!=pR ) { + PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); + PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); + } + PMA_sub(ECP_POINT_Y(pR), pModulo, ECP_POINT_Y(pP), pModulo); + ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); + } +} + +/* +// ECCP_DblPoint +// +// Double point +*/ +void ECCP_DblPoint(const IppsECCPPointState* pP, + IppsECCPPointState* pR, + const IppsECCPState* pECC, + BigNumNode* pList) +{ + /* P at infinity */ + if( ECCP_IsPointAtInfinity(pP) ) + ECCP_SetPointToInfinity(pR); + + else { + IppsMontState* pMont = ECP_PMONT(pECC); + + IppsBigNumState* bnV = cpBigNumListGet(&pList); + IppsBigNumState* bnU = cpBigNumListGet(&pList); + IppsBigNumState* bnM = cpBigNumListGet(&pList); + IppsBigNumState* bnS = cpBigNumListGet(&pList); + IppsBigNumState* bnT = cpBigNumListGet(&pList); + IppsBigNumState* pModulo = ECP_PRIME(pECC); + + /* M = 3*X^2 + A*Z^4 */ + if( ECP_POINT_AFFINE(pP) ) { + PMA_sqre(bnU, ECP_POINT_X(pP), pMont); + PMA_add(bnM, bnU, bnU, pModulo); + PMA_add(bnM, bnM, bnU, pModulo); + PMA_add(bnM, bnM, ECP_AENC(pECC), pModulo); + } + else if( ECP_AMI3(pECC) ) { + PMA_sqre(bnU, ECP_POINT_Z(pP), pMont); + PMA_add(bnS, ECP_POINT_X(pP), bnU, pModulo); + PMA_sub(bnT, ECP_POINT_X(pP), bnU, pModulo); + PMA_mule(bnM, bnS, bnT, pMont); + PMA_add(bnU, bnM, bnM, pModulo); + PMA_add(bnM, bnU, bnM, pModulo); + } + else { + PMA_sqre(bnU, ECP_POINT_X(pP), pMont); + PMA_add(bnM, bnU, bnU, pModulo); + PMA_add(bnM, bnM, bnU, pModulo); + PMA_sqre(bnU, ECP_POINT_Z(pP), pMont); + PMA_sqre(bnU, bnU, pMont); + PMA_mule(bnU, bnU, ECP_AENC(pECC), pMont); + PMA_add(bnM, bnM, bnU, pModulo); + } + + PMA_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP), pModulo); + + /* R_Z = 2*Y*Z */ + if( ECP_POINT_AFFINE(pP) ) { + PMA_set(ECP_POINT_Z(pR), bnV); + } + else { + PMA_mule(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP), pMont); + } + + /* S = 4*X*Y^2 */ + PMA_sqre(bnT, bnV, pMont); + PMA_mule(bnS, bnT, ECP_POINT_X(pP), pMont); + + /* R_X = M^2 - 2*S */ + PMA_sqre(bnU, bnM, pMont); + PMA_sub(bnU, bnU, bnS, pModulo); + PMA_sub(ECP_POINT_X(pR), bnU, bnS, pModulo); + + /* T = 8*Y^4 */ + PMA_mule(bnV, bnV, ECP_POINT_Y(pP), pMont); + PMA_mule(bnT, bnT, bnV, pMont); + + /* R_Y = M*(S - R_X) - T */ + PMA_sub(bnS, bnS, ECP_POINT_X(pR), pModulo); + PMA_mule(bnS, bnS, bnM, pMont); + PMA_sub(ECP_POINT_Y(pR), bnS, bnT, pModulo); + + ECP_POINT_AFFINE(pR) = 0; + } +} + +/* +// ECCP_AddPoint +// +// Add points +*/ +void ECCP_AddPoint(const IppsECCPPointState* pP, + const IppsECCPPointState* pQ, + IppsECCPPointState* pR, + const IppsECCPState* pECC, + BigNumNode* pList) +{ + /* prevent operation with point at Infinity */ + if( ECCP_IsPointAtInfinity(pP) ) { + ECCP_CopyPoint(pQ, pR); + return; + } + if( ECCP_IsPointAtInfinity(pQ) ) { + ECCP_CopyPoint(pP, pR); + return; + } + + /* + // addition + */ + { + IppsMontState* pMont = ECP_PMONT(pECC); + + IppsBigNumState* bnU0 = cpBigNumListGet(&pList); + IppsBigNumState* bnS0 = cpBigNumListGet(&pList); + IppsBigNumState* bnU1 = cpBigNumListGet(&pList); + IppsBigNumState* bnS1 = cpBigNumListGet(&pList); + IppsBigNumState* bnW = cpBigNumListGet(&pList); + IppsBigNumState* bnR = cpBigNumListGet(&pList); + IppsBigNumState *bnT = bnU0; + IppsBigNumState *bnM = bnS0; + IppsBigNumState* pModulo = ECP_PRIME(pECC); + + /* U0 = P_X * Q_Z^2 */ + /* S0 = P_Y * Q_Z^3 */ + if( ECP_POINT_AFFINE(pQ) ) { + PMA_set(bnU0, ECP_POINT_X(pP)); + PMA_set(bnS0, ECP_POINT_Y(pP)); + } + else { + PMA_sqre(bnW, ECP_POINT_Z(pQ), pMont); + PMA_mule(bnU0,ECP_POINT_X(pP), bnW, pMont); + PMA_mule(bnW, ECP_POINT_Z(pQ), bnW, pMont); + PMA_mule(bnS0,ECP_POINT_Y(pP), bnW, pMont); + } + + /* U1 = Q_X * P_Z^2 */ + /* S1 = Q_Y * P_Z^3 */ + if( ECP_POINT_AFFINE(pP) ) { + PMA_set(bnU1, ECP_POINT_X(pQ)); + PMA_set(bnS1, ECP_POINT_Y(pQ)); + } + else { + PMA_sqre(bnW, ECP_POINT_Z(pP), pMont); + PMA_mule(bnU1,ECP_POINT_X(pQ), bnW, pMont); + PMA_mule(bnW, ECP_POINT_Z(pP), bnW, pMont); + PMA_mule(bnS1,ECP_POINT_Y(pQ), bnW, pMont); + } + + /* W = U0-U1 */ + /* R = S0-S1 */ + PMA_sub(bnW, bnU0, bnU1, pModulo); + PMA_sub(bnR, bnS0, bnS1, pModulo); + + if( IsZero_BN(bnW) ) { + if( IsZero_BN(bnR) ) { + ECCP_DblPoint(pP, pR, pECC, pList); + return; + } + else { + ECCP_SetPointToInfinity(pR); + return; + } + } + + /* T = U0+U1 */ + /* M = S0+S1 */ + PMA_add(bnT, bnU0, bnU1, pModulo); + PMA_add(bnM, bnS0, bnS1, pModulo); + + /* R_Z = P_Z * Q_Z * W */ + if( ECP_POINT_AFFINE(pQ) && ECP_POINT_AFFINE(pP) ) { + PMA_set(ECP_POINT_Z(pR), bnW); + } + else { + if( ECP_POINT_AFFINE(pQ) ) { + PMA_set(bnU1, ECP_POINT_Z(pP)); + } + else if( ECP_POINT_AFFINE(pP) ) { + PMA_set(bnU1, ECP_POINT_Z(pQ)); + } + else { + PMA_mule(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ), pMont); + } + PMA_mule(ECP_POINT_Z(pR), bnU1, bnW, pMont); + } + + PMA_sqre(bnU1, bnW, pMont); /* U1 = W^2 */ + PMA_mule(bnS1, bnT, bnU1, pMont); /* S1 = T * W^2 */ + + /* R_X = R^2 - T * W^2 */ + PMA_sqre(ECP_POINT_X(pR), bnR, pMont); + PMA_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1, pModulo); + + /* V = T * W^2 - 2 * R_X (S1) */ + PMA_sub(bnS1, bnS1, ECP_POINT_X(pR), pModulo); + PMA_sub(bnS1, bnS1, ECP_POINT_X(pR), pModulo); + + /* R_Y = (V * R - M * W^3) /2 */ + PMA_mule(ECP_POINT_Y(pR), bnS1, bnR, pMont); + PMA_mule(bnU1, bnU1, bnW, pMont); + PMA_mule(bnU1, bnU1, bnM, pMont); + PMA_sub(bnU1, ECP_POINT_Y(pR), bnU1, pModulo); + PMA_div2(ECP_POINT_Y(pR), bnU1, pModulo); + + ECP_POINT_AFFINE(pR) = 0; + } +} + +/* +// ECCP_MulPoint +// +// Multiply point by scalar +*/ +void ECCP_MulPoint(const IppsECCPPointState* pP, + const IppsBigNumState* bnN, + IppsECCPPointState* pR, + const IppsECCPState* pECC, + BigNumNode* pList) +{ + /* test zero scalar or input point at Infinity */ + if( IsZero_BN(bnN) || ECCP_IsPointAtInfinity(pP) ) { + ECCP_SetPointToInfinity(pR); + return; + } + + /* + // scalar multiplication + */ + else { + Ipp8u* pScratchAligned = ECP_SCCMBUFF(pECC); + + BNU_CHUNK_T* pN = BN_NUMBER(bnN); + cpSize nsN = BN_SIZE(bnN); + /* scalar bitsize */ + int scalarBitSize = BITSIZE_BNU(pN, nsN); + /* optimal size of window */ + int w = cpECCP_OptimalWinSize(scalarBitSize); + /* number of table entries */ + int nPrecomputed = 1<>shift) & dmask; + + /* initialize result (ECP_FINITE_POINT|ECP_PROJECTIVE) */ + cpECCP_ScrambleGet(pR, coordSize, pScratchAligned+windowVal, nPrecomputed); + ECP_POINT_AFFINE(pR) = 0; + + /* initialize temporary T (ECP_PROJECTIVE) */ + ECP_POINT_AFFINE(&T) = 0; + + for(wPosition-=w; wPosition>=0; wPosition-=w) { + /* w times doubling */ + int k; + for(k=0; k>shift) & dmask; + + /* extract value from the pre-computed table */ + cpECCP_ScrambleGet(&T, coordSize, pScratchAligned+windowVal, nPrecomputed); + + /* and add it */ + ECCP_AddPoint(pR, &T, pR, pECC, pList); + } + } + } +} + + +void ECCP_MulBasePoint(const IppsBigNumState* pK, + IppsECCPPointState* pR, + const IppsECCPState* pECC, + BigNumNode* pList) +{ + ECCP_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); +} + +/* +// ECCP_ProdPoint +// +// Point product +*/ +void ECCP_ProdPoint(const IppsECCPPointState* pP, + const IppsBigNumState* bnPscalar, + const IppsECCPPointState* pQ, + const IppsBigNumState* bnQscalar, + IppsECCPPointState* pR, + const IppsECCPState* pECC, + BigNumNode* pList) +{ + IppsECCPPointState T; + IppsECCPPointState U; + + ECP_POINT_X(&T) = cpBigNumListGet(&pList); + ECP_POINT_Y(&T) = cpBigNumListGet(&pList); + ECP_POINT_Z(&T) = cpBigNumListGet(&pList); + + ECP_POINT_X(&U) = cpBigNumListGet(&pList); + ECP_POINT_Y(&U) = cpBigNumListGet(&pList); + ECP_POINT_Z(&U) = cpBigNumListGet(&pList); + + ECCP_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); + ECCP_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); + ECCP_AddPoint(&T, &U, pR, pECC, pList); +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccppoint.h b/external/crypto_px/sources/ippcp/src/pcpeccppoint.h new file mode 100644 index 0000000000..62c2cadc84 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccppoint.h @@ -0,0 +1,60 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_ECCPPOINT_H) +#define _PCP_ECCPPOINT_H + +#include "pcpeccp.h" + + +/* +// EC Point context +*/ +struct _cpECCPPoint { + IppCtxId idCtx; /* EC Point identifier */ + + IppsBigNumState* pX; /* projective X */ + IppsBigNumState* pY; /* Y */ + IppsBigNumState* pZ; /* Z coordinates */ + int affine; /* impotrant case Z=1 */ +}; + +/* +// Contetx Access Macros +*/ +#define ECP_POINT_ID(ctx) ((ctx)->idCtx) +#define ECP_POINT_X(ctx) ((ctx)->pX) +#define ECP_POINT_Y(ctx) ((ctx)->pY) +#define ECP_POINT_Z(ctx) ((ctx)->pZ) +#define ECP_POINT_AFFINE(ctx) ((ctx)->affine) +#define ECP_POINT_VALID_ID(ctx) (ECP_POINT_ID((ctx))==idCtxECCPPoint) + +#endif /* _PCP_ECCPPOINT_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpeccppointca.c b/external/crypto_px/sources/ippcp/src/pcpeccppointca.c new file mode 100644 index 0000000000..edd94e5452 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccppointca.c @@ -0,0 +1,128 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccppoint.h" + + +/*F* +// Name: ippsECCPPointGetSize +// +// Purpose: Returns size of EC Point context (bytes). +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pSzie +// ippStsSizeErr 2>feBitSize +// ippStsNoErr no errors +// +// Parameters: +// feBitSize size of field element (bits) +// pSize pointer to the size of EC Point context +// +*F*/ +IPPFUN(IppStatus, ippsECCPPointGetSize, (int feBitSize, int* pSize)) +{ + /* test size's pointer */ + IPP_BAD_PTR1_RET(pSize); + + /* test size of field element */ + IPP_BADARG_RET((2>feBitSize), ippStsSizeErr); + + { + int bnSize; + ippsBigNumGetSize(BITS2WORD32_SIZE(feBitSize), &bnSize); + *pSize = sizeof(IppsECCPPointState) + + bnSize /* X coodinate */ + + bnSize /* Y coodinate */ + + bnSize /* Z coodinate */ + +(ALIGN_VAL-1); + } + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPPointInit +// +// Purpose: Init EC Point context. +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pPoint +// ippStsSizeErr 2>feBitSize +// ippStsNoErr no errors +// +// Parameters: +// feBitSize size of field element (bits) +// pECC pointer to ECC context +// +*F*/ +IPPFUN(IppStatus, ippsECCPPointInit, (int feBitSize, IppsECCPPointState* pPoint)) +{ + /* test pEC pointer */ + IPP_BAD_PTR1_RET(pPoint); + + /* use aligned context */ + pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) ); + + /* test size of field element */ + IPP_BADARG_RET((2>feBitSize), ippStsSizeErr); + + /* context ID */ + ECP_POINT_ID(pPoint) = idCtxECCPPoint; + + /* meaning: point was not set */ + ECP_POINT_AFFINE(pPoint) =-1; + + /* + // init other context fields + */ + { + Ipp8u* ptr = (Ipp8u*)pPoint; + int bnLen = BITS2WORD32_SIZE(feBitSize); + int bnSize; + ippsBigNumGetSize(bnLen, &bnSize); + + /* allocate coordinate buffers */ + ptr += sizeof(IppsECCPPointState); + ECP_POINT_X(pPoint) = (IppsBigNumState*)( IPP_ALIGNED_PTR(ptr,ALIGN_VAL) ); + ptr += bnSize; + ECP_POINT_Y(pPoint) = (IppsBigNumState*)( IPP_ALIGNED_PTR(ptr,ALIGN_VAL) ); + ptr += bnSize; + ECP_POINT_Z(pPoint) = (IppsBigNumState*)( IPP_ALIGNED_PTR(ptr,ALIGN_VAL) ); + + /* init coordinate buffers */ + ippsBigNumInit(bnLen, ECP_POINT_X(pPoint)); + ippsBigNumInit(bnLen, ECP_POINT_Y(pPoint)); + ippsBigNumInit(bnLen, ECP_POINT_Z(pPoint)); + } + return ippStsNoErr; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccppointopca.c b/external/crypto_px/sources/ippcp/src/pcpeccppointopca.c new file mode 100644 index 0000000000..26c0fc71bf --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccppointopca.c @@ -0,0 +1,476 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccppoint.h" +#include "pcpeccpmethod.h" +#include "pcpeccpmethodcom.h" + + +/*F* +// Name: ippsECCPSetPoint +// +// Purpose: Converts regular affine coordinates EC point (pX,pY) +// into internal presentation - montgomery projective. +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pPoint +// NULL == pX +// NULL == pY +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pX->idCtx +// illegal pY->idCtx +// illegal pPoint->idCtx +// +// ippStsOutOfECErr point out-of EC +// +// ippStsNoErr no errors +// +// Parameters: +// pX pointer to the regular affine coordinate X +// pY pointer to the regular affine coordinate Y +// pPoint pointer to the EC Point context +// pECC pointer to the ECCP context +// +// Note: +// if B==0 and (x,y)=(0,y) then point at Infinity will be set up +// if B!=0 and (x,y)=(0,0) then point at Infinity will be set up +// else point with requested coordinates (x,y) wil be set up +// There are no check validation inside! +// +*F*/ +IPPFUN(IppStatus, ippsECCPSetPoint,(const IppsBigNumState* pX, + const IppsBigNumState* pY, + IppsECCPPointState* pPoint, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test pX and pY */ + IPP_BAD_PTR2_RET(pX,pY); + pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) ); + pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr); + + /* test pPoint */ + IPP_BAD_PTR1_RET(pPoint); + pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPoint), ippStsContextMatchErr); + + /* set affine coordinates at Infinity */ + if( ( IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity1(pX,pY)) || + (!IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity0(pX,pY)) ) + ECCP_SetPointToInfinity(pPoint); + /* set point */ + else { + ECP_METHOD(pECC)->SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC); + } + + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPSetPointAtInfinity +// +// Purpose: Set point at Infinity +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pPoint +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pPoint->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pPoint pointer to the EC Point context +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test pPoint */ + IPP_BAD_PTR1_RET(pPoint); + pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPoint), ippStsContextMatchErr); + + ECCP_SetPointToInfinity(pPoint); + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPGetPoint +// +// Purpose: Converts internal presentation EC point - montgomery projective +// into regular affine coordinates EC point (pX,pY) +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pPoint +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pPoint->idCtx +// NULL != pX, illegal pX->idCtx +// NULL != pY, illegal pY->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pX pointer to the regular affine coordinate X +// pY pointer to the regular affine coordinate Y +// pLength pointer to the length of coordinates +// pPoint pointer to the EC Point context +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPGetPoint,(IppsBigNumState* pX, + IppsBigNumState* pY, + const IppsECCPPointState* pPoint, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test source point */ + IPP_BAD_PTR1_RET(pPoint); + pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPoint), ippStsContextMatchErr); + + /* test pX and pY */ + if(pX) { + pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr); + } + if(pY) { + pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr); + } + + if( ECCP_IsPointAtInfinity(pPoint) ) { + if( IsZero_BN(ECP_BENC(pECC)) ) + ECCP_SetPointToAffineInfinity1(pX, pY); + else + ECCP_SetPointToAffineInfinity0(pX, pY); + } + else + ECP_METHOD(pECC)->GetPointAffine(pX, pY, pPoint, pECC, ECP_BNCTX(pECC)); + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPCheckPoint +// +// Purpose: Check EC point: +// - is point lie on EC +// - is point at infinity +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pP +// NULL == pResult +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pP->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pPoint pointer to the EC Point context +// pECC pointer to the ECCP context +// pResult pointer to the result: +// ippECValid +// ippECPointIsNotValid +// ippECPointIsAtInfinite +// +*F*/ +IPPFUN(IppStatus, ippsECCPCheckPoint,(const IppsECCPPointState* pP, + IppECResult* pResult, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test point */ + IPP_BAD_PTR1_RET(pP); + pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr); + + /* test pResult */ + IPP_BAD_PTR1_RET(pResult); + + if( ECCP_IsPointAtInfinity(pP) ) + *pResult = ippECPointIsAtInfinite; + else if( ECP_METHOD(pECC)->IsPointOnCurve(pP, pECC, ECP_BNCTX(pECC)) ) + *pResult = ippECValid; + else + *pResult = ippECPointIsNotValid; + + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPComparePoint +// +// Purpose: Compare two EC points +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pP +// NULL == pQ +// NULL == pResult +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pP->idCtx +// illegal pQ->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pP pointer to the EC Point context +// pQ pointer to the EC Point context +// pECC pointer to the ECCP context +// pResult pointer to the result: +// ippECPointIsEqual +// ippECPointIsNotEqual +// +*F*/ +IPPFUN(IppStatus, ippsECCPComparePoint,(const IppsECCPPointState* pP, + const IppsECCPPointState* pQ, + IppECResult* pResult, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test points */ + IPP_BAD_PTR2_RET(pP,pQ); + pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) ); + pQ = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pQ, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pQ), ippStsContextMatchErr); + + /* test pResult */ + IPP_BAD_PTR1_RET(pResult); + + *pResult = ECP_METHOD(pECC)->ComparePoint(pP, pQ, pECC, ECP_BNCTX(pECC))? ippECPointIsNotEqual : ippECPointIsEqual; + + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPNegativePoint +// +// Purpose: Perforn EC point operation: R = -P +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pP +// NULL == pR +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pP->idCtx +// illegal pR->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pP pointer to the source EC Point context +// pR pointer to the resultant EC Point context +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPNegativePoint, (const IppsECCPPointState* pP, + IppsECCPPointState* pR, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test points */ + IPP_BAD_PTR2_RET(pP,pR); + pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) ); + pR = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pR, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pR), ippStsContextMatchErr); + + ECP_METHOD(pECC)->NegPoint(pP, pR, pECC); + + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPAddPoint +// +// Purpose: Perforn EC point operation: R = P+Q +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pP +// NULL == pQ +// NULL == pR +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pP->idCtx +// illegal pQ->idCtx +// illegal pR->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pP pointer to the source EC Point context +// pQ pointer to the source EC Point context +// pR pointer to the resultant EC Point context +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPAddPoint,(const IppsECCPPointState* pP, + const IppsECCPPointState* pQ, + IppsECCPPointState* pR, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test points */ + IPP_BAD_PTR3_RET(pP,pQ,pR); + pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) ); + pQ = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pQ, ALIGN_VAL) ); + pR = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pR, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pQ), ippStsContextMatchErr); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pR), ippStsContextMatchErr); + + if(pP==pQ) + ECP_METHOD(pECC)->DblPoint(pP, pR, pECC, ECP_BNCTX(pECC)); + else + ECP_METHOD(pECC)->AddPoint(pP, pQ, pR, pECC, ECP_BNCTX(pECC)); + + return ippStsNoErr; +} + + +/*F* +// Name: ippsECCPMulPointScalar +// +// Purpose: Perforn EC point operation: R = k*P +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pP +// NULL == pK +// NULL == pR +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pP->idCtx +// illegal pK->idCtx +// illegal pR->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pP pointer to the source EC Point context +// pK pointer to the source BigNum multiplier context +// pR pointer to the resultant EC Point context +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPMulPointScalar,(const IppsECCPPointState* pP, + const IppsBigNumState* pK, + IppsECCPPointState* pR, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test points */ + IPP_BAD_PTR2_RET(pP,pR); + pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) ); + pR = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pR, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pR), ippStsContextMatchErr); + + /* test scalar */ + IPP_BAD_PTR1_RET(pK); + pK = (IppsBigNumState*)( IPP_ALIGNED_PTR(pK, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pK), ippStsContextMatchErr); + + ECP_METHOD(pECC)->MulPoint(pP, pK, pR, pECC, ECP_BNCTX(pECC)); + + return ippStsNoErr; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccppublickeyca.c b/external/crypto_px/sources/ippcp/src/pcpeccppublickeyca.c new file mode 100644 index 0000000000..d4a4408c98 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccppublickeyca.c @@ -0,0 +1,89 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccppoint.h" +#include "pcpeccpmethod.h" +#include "pcpeccpmethodcom.h" + + +/*F* +// Name: ippsECCPPublicKey +// +// Purpose: Calculate Public Key +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pPrivate +// NULL == pPublic +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pPrivate->idCtx +// illegal pPublic->idCtx +// +// ippStsIvalidPrivateKey !(0 < pPrivate < order) +// +// ippStsNoErr no errors +// +// Parameters: +// pPrivate pointer to the private key +// pPublic pointer to the resultant public key +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPPublicKey, (const IppsBigNumState* pPrivate, + IppsECCPPointState* pPublic, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test public key */ + IPP_BAD_PTR1_RET(pPublic); + pPublic = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublic, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPublic), ippStsContextMatchErr); + + /* test private keys */ + IPP_BAD_PTR1_RET(pPrivate); + pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr); + IPP_BADARG_RET(!((0cpBN_cmp(pPrivate, ECP_ORDER(pECC))) ), ippStsIvalidPrivateKey); + + /* calculates public key */ + ECP_METHOD(pECC)->MulBasePoint(pPrivate, pPublic, pECC, ECP_BNCTX(pECC)); + + return ippStsNoErr; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccpsecretdhca.c b/external/crypto_px/sources/ippcp/src/pcpeccpsecretdhca.c new file mode 100644 index 0000000000..05d3c10233 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccpsecretdhca.c @@ -0,0 +1,116 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccp.h" +#include "pcpeccppoint.h" +#include "pcpeccpmethod.h" +#include "pcpeccpmethodcom.h" + + +/*F* +// Name: ippsECCPSharedSecretDH +// +// Purpose: Shared Secret Value Derivation +// (Diffie-Hellman version). +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pPrivateA +// NULL == pPublicB +// NULL == pShare +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pPrivateA->idCtx +// illegal pPublicB->idCtx +// illegal pShare->idCtx +// +// ippStsRangeErr not enough room for share key +// +// ippStsShareKeyErr (infinity) => z +// +// ippStsNoErr no errors +// +// Parameters: +// pPrivateA pointer to own private key +// pPublicB pointer to alien public key +// pShare pointer to the shareds secret value +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPSharedSecretDH,(const IppsBigNumState* pPrivateA, + const IppsECCPPointState* pPublicB, + IppsBigNumState* pShare, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test private (own) key */ + IPP_BAD_PTR1_RET(pPrivateA); + pPrivateA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateA, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pPrivateA), ippStsContextMatchErr); + + /* test public (other party) key */ + IPP_BAD_PTR1_RET(pPublicB); + pPublicB = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublicB, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPublicB), ippStsContextMatchErr); + + /* test share secret value */ + IPP_BAD_PTR1_RET(pShare); + pShare = (IppsBigNumState*)( IPP_ALIGNED_PTR(pShare, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pShare), ippStsContextMatchErr); + IPP_BADARG_RET((BN_ROOM(pShare)*BITSIZE(BNU_CHUNK_T)MulPoint(pPublicB, pPrivateA, &Tmp, pECC, pList); + + /* test: Tmp ~ point at Infinity */ + if( ECCP_IsPointAtInfinity(&Tmp) ) + return ippStsShareKeyErr; + else { + ECP_METHOD(pECC)->GetPointAffine(pShare, NULL, &Tmp, pECC, pList); + return ippStsNoErr; + } + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccpsetkeyca.c b/external/crypto_px/sources/ippcp/src/pcpeccpsetkeyca.c new file mode 100644 index 0000000000..bb3463cfc1 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccpsetkeyca.c @@ -0,0 +1,105 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccp.h" +#include "pcpeccppoint.h" +#include "pcpeccpmethod.h" +#include "pcpeccpmethodcom.h" + + +/*F* +// Name: ippsECCPSetKeyPair +// +// Purpose: Generate (private,public) Key Pair +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pPrivate +// NULL == pPublic +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pPrivate->idCtx +// illegal pPublic->idCtx +// +// ippStsNoErr no errors +// +// Parameters: +// pPrivate pointer to the private key +// pPublic pointer to the public key +// regular flag regular/ephemeral keys +// pECC pointer to the ECCP context +// +*F*/ +IPPFUN(IppStatus, ippsECCPSetKeyPair, (const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic, + IppBool regular, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + /* test ID */ + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + { + IppsBigNumState* targetPrivate; + IppsECCPPointState* targetPublic; + + if( regular ) { + targetPrivate = ECP_PRIVATE(pECC); + targetPublic = ECP_PUBLIC(pECC); + } + else { + targetPrivate = ECP_PRIVATE_E(pECC); + targetPublic = ECP_PUBLIC_E(pECC); + } + + /* set up private key request */ + if( pPrivate ) { + pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr); + ippsSet_BN(ippBigNumPOS, BN_SIZE32(pPrivate), (Ipp32u*)BN_NUMBER(pPrivate), targetPrivate); + } + + /* set up public key request */ + if( pPublic ) { + pPublic = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublic, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPublic), ippStsContextMatchErr); + + ECP_METHOD(pECC)->GetPointAffine(ECP_POINT_X(targetPublic), ECP_POINT_Y(targetPublic), pPublic, pECC, ECP_BNCTX(pECC)); + ECP_METHOD(pECC)->SetPointAffine(ECP_POINT_X(targetPublic), ECP_POINT_Y(targetPublic), targetPublic, pECC); + } + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccpsigndsaca.c b/external/crypto_px/sources/ippcp/src/pcpeccpsigndsaca.c new file mode 100644 index 0000000000..ca9a9dbe9d --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccpsigndsaca.c @@ -0,0 +1,149 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpeccp.h" +#include "pcpeccppoint.h" +#include "pcpeccpmethod.h" +#include "pcpeccpmethodcom.h" + + +/*F* +// Name: ippsECCPSignDSA +// +// Purpose: Signing of message representative. +// (DSA version). +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pECC +// NULL == pMsgDigest +// NULL == pPrivate +// NULL == pSignX +// NULL == pSignY +// +// ippStsContextMatchErr illegal pECC->idCtx +// illegal pMsgDigest->idCtx +// illegal pPrivate->idCtx +// illegal pSignX->idCtx +// illegal pSignY->idCtx +// +// ippStsMessageErr MsgDigest >= order +// +// ippStsRangeErr not enough room for: +// signX +// signY +// +// ippStsEphemeralKeyErr (0==signX) || (0==signY) +// +// ippStsNoErr no errors +// +// Parameters: +// pMsgDigest pointer to the message representative to be signed +// pPrivate pointer to the regular private key +// pSignX,pSignY pointer to the signature +// pECC pointer to the ECCP context +// +// Note: +// - ephemeral key pair extracted from pECC and +// must be generated and before ippsECCPDSASign() usage +// - ephemeral key pair destroy before exit +// +*F*/ +IPPFUN(IppStatus, ippsECCPSignDSA,(const IppsBigNumState* pMsgDigest, + const IppsBigNumState* pPrivate, + IppsBigNumState* pSignX, IppsBigNumState* pSignY, + IppsECCPState* pECC)) +{ + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test private key*/ + IPP_BAD_PTR1_RET(pPrivate); + pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr); + + /* test message representative */ + IPP_BAD_PTR1_RET(pMsgDigest); + pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr); + IPP_BADARG_RET((0<=cpBN_cmp(pMsgDigest, ECP_ORDER(pECC))), ippStsMessageErr); + + /* test signature */ + IPP_BAD_PTR2_RET(pSignX,pSignY); + pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, ALIGN_VAL) ); + pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr); + IPP_BADARG_RET((BN_ROOM(pSignX)*BITSIZE(BNU_CHUNK_T)GetPointAffine(pTmp, NULL, ECP_PUBLIC_E(pECC), pECC, pList); + + /* + // compute + // signX = eph_pub_x (mod order) + */ + PMA_mod(pSignX, pTmp, pOrder); + if( !IsZero_BN(pSignX) ) { + + IppsBigNumState* pEncMsg = cpBigNumListGet(&pList); + IppsBigNumState* pEncSignX = cpBigNumListGet(&pList); + PMA_enc(pEncMsg, (IppsBigNumState*)pMsgDigest, rMont); + PMA_enc(pEncSignX, pSignX, rMont); + + /* + // compute + // signY = (1/eph_private)*(pMsgDigest + private*signX) (mod order) + */ + PMA_inv(pSignY, ECP_PRIVATE_E(pECC), pOrder); + PMA_enc(ECP_PRIVATE_E(pECC), pPrivate, rMont); + PMA_mule(pTmp, ECP_PRIVATE_E(pECC), pEncSignX, rMont); + PMA_add(pTmp, pTmp, pEncMsg, pOrder); + PMA_mule(pSignY, pSignY, pTmp, rMont); + if( !IsZero_BN(pSignY) ) + return ippStsNoErr; + } + + return ippStsEphemeralKeyErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpeccpsscm.c b/external/crypto_px/sources/ippcp/src/pcpeccpsscm.c new file mode 100644 index 0000000000..c2b08f3fd7 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpeccpsscm.c @@ -0,0 +1,161 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcpeccppoint.h" + + +#define LOG2_CACHE_LINE_SIZE (LOG_CACHE_LINE_SIZE) + +static int div_upper(int a, int d) +{ return (a+d-1)/d; } + +static int getNumOperations(int bitsize, int w) +{ + int n_overhead = (1<=n_opt) break; + w_opt = w_trial; + n_opt = n_trial; + } + return w_opt; +#undef LIMIT +} + +int cpECCP_ConvertRepresentation(BNU_CHUNK_T* pInput, int inpBits, int w) +{ + Ipp32u* pR = (Ipp32u*)pInput; + Ipp16u* pR16 = (Ipp16u*)pInput; + + int outBits = 0; + Ipp32u base = (BNU_CHUNK_T)1<>digitShift) &digitMask; + + Ipp32u delta = (base-digit) & ~digitMask; + delta <<= digitShift; + cpDec_BNU32((Ipp32u*)(pR16+chunkIdx), (Ipp32u*)(pR16+chunkIdx), (2*nsR-chunkIdx+1)/2, delta); + + inpBits = BITSIZE_BNU32(pR, nsR); + outBits += w; + } + + return outBits; +} + +/* +// cpsScramblePut/cpsScrambleGet +// stores to/retrieves from pScrambleEntry position +// pre-computed data if fixed window method is used +*/ +void cpECCP_ScramblePut(Ipp8u* pScrambleEntry, int proposity, + const IppsECCPPointState* pPoint, cpSize coordLen) +{ + int i; + Ipp8u* pCoord; + + BNU_CHUNK_T* pX = BN_NUMBER(ECP_POINT_X(pPoint)); + BNU_CHUNK_T* pY = BN_NUMBER(ECP_POINT_Y(pPoint)); + BNU_CHUNK_T* pZ = BN_NUMBER(ECP_POINT_Z(pPoint)); + int coordSize = coordLen*sizeof(BNU_CHUNK_T); + + ZEXPAND_BNU(pX, BN_SIZE(ECP_POINT_X(pPoint)), coordLen); + ZEXPAND_BNU(pY, BN_SIZE(ECP_POINT_Y(pPoint)), coordLen); + ZEXPAND_BNU(pZ, BN_SIZE(ECP_POINT_Z(pPoint)), coordLen); + + pCoord = (Ipp8u*)pX; + for(i=0; iidCtx +// illegal pMsgDigest->idCtx +// illegal pSignX->idCtx +// illegal pSignY->idCtx +// +// ippStsMessageErr MsgDigest >= order +// +// ippStsNoErr no errors +// +// Parameters: +// pMsgDigest pointer to the message representative to be signed +// pSignX,pSignY pointer to the signature +// pResult pointer to the result: ippECValid/ippECInvalidSignature +// pECC pointer to the ECCP context +// +// Note: +// - signer's key must be set up in ECCP context +// before ippsECCPVerifyDSA() usage +// +*F*/ +IPPFUN(IppStatus, ippsECCPVerifyDSA,(const IppsBigNumState* pMsgDigest, + const IppsBigNumState* pSignX, const IppsBigNumState* pSignY, + IppECResult* pResult, + IppsECCPState* pECC)) +{ + IppsMontState* rMont; + + /* test pECC */ + IPP_BAD_PTR1_RET(pECC); + /* use aligned EC context */ + pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) ); + IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); + + /* test message representative */ + IPP_BAD_PTR1_RET(pMsgDigest); + pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr); + rMont = ECP_RMONT(pECC); + IPP_BADARG_RET((0<=cpBN_cmp(pMsgDigest, ECP_ORDER(pECC))), ippStsMessageErr); + + /* test result */ + IPP_BAD_PTR1_RET(pResult); + + /* test signature */ + IPP_BAD_PTR2_RET(pSignX,pSignY); + pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, ALIGN_VAL) ); + pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, ALIGN_VAL) ); + IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr); + + /* test signature value */ + if( (0>cpBN_tst(pSignX)) || (0>cpBN_tst(pSignY)) || + (0<=cpBN_cmp(pSignX, ECP_ORDER(pECC))) || + (0<=cpBN_cmp(pSignY, ECP_ORDER(pECC))) ) { + *pResult = ippECInvalidSignature; + return ippStsNoErr; + } + + /* validate signature */ + else { + IppsECCPPointState P1; + + BigNumNode* pList = ECP_BNCTX(pECC); + IppsBigNumState* pH1 = cpBigNumListGet(&pList); + IppsBigNumState* pH2 = cpBigNumListGet(&pList); + IppsBigNumState* pOrder = cpBigNumListGet(&pList); + BN_Set(MNT_MODULUS(rMont), MNT_SIZE(rMont), pOrder); + + ECP_POINT_X(&P1) = cpBigNumListGet(&pList); + ECP_POINT_Y(&P1) = cpBigNumListGet(&pList); + ECP_POINT_Z(&P1) = cpBigNumListGet(&pList); + + PMA_inv(pH1, (IppsBigNumState*)pSignY, pOrder);/* h = 1/signY (mod order) */ + PMA_enc(pH1, pH1, rMont); + PMA_mule(pH2, (IppsBigNumState*)pSignX, pH1, rMont); /* h2 = pSignX * h (mod order) */ + PMA_mule(pH1, (IppsBigNumState*)pMsgDigest, pH1, rMont); /* h1 = pMsgDigest * h (mod order) */ + + /* compute h1*BasePoint + h2*publicKey */ + ECP_METHOD(pECC)->ProdPoint(ECP_GENC(pECC), pH1, + ECP_PUBLIC(pECC), pH2, + &P1, pECC, pList); + + if( ECCP_IsPointAtInfinity(&P1) ) { + *pResult = ippECInvalidSignature; + return ippStsNoErr; + } + /* extract X component */ + ECP_METHOD(pECC)->GetPointAffine(pH1, NULL, &P1, pECC, pList); + /* compare with signX */ + PMA_mod(pH1, pH1, pOrder); + *pResult = (0==cpBN_cmp(pH1, pSignX))? ippECValid : ippECInvalidSignature; + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcphash.h b/external/crypto_px/sources/ippcp/src/pcphash.h new file mode 100644 index 0000000000..1dccb86b36 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphash.h @@ -0,0 +1,159 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_HASH_H) +#define _PCP_HASH_H + + +/* messge block size */ +#define MBS_SHA1 (64) /* SHA1 message block size (bytes) */ +#define MBS_SHA256 (64) /* SHA256 and SHA224 */ +#define MBS_SHA224 (64) /* SHA224 */ +#define MBS_SHA512 (128) /* SHA512 and SHA384 */ +#define MBS_SHA384 (128) /* SHA384 */ +#define MBS_MD5 (64) /* MD5 */ +#define MBS_HASH_MAX (MBS_SHA512) /* max message block size (bytes) */ +#define MAX_HASH_SIZE (IPP_SHA512_DIGEST_BITSIZE/8) /* hash of the max len (bytes) */ + +/* +// Useful macros +*/ +#define SHS_ID(stt) ((stt)->idCtx) +#define SHS_INDX(stt) ((stt)->index) +#define SHS_LENL(stt) ((stt)->msgLenLo) +#define SHS_LENH(stt) ((stt)->msgLenHi) +#define SHS_BUFF(stt) ((stt)->msgBuffer) +#define SHS_HASH(stt) ((stt)->msgHash) + +/* initial hash values */ +extern const Ipp32u SHA1_IV[]; +extern const Ipp32u SHA256_IV[]; +extern const Ipp32u SHA224_IV[]; +extern const Ipp64u SHA512_IV[]; +extern const Ipp64u SHA384_IV[]; +extern const Ipp32u MD5_IV[]; +extern const Ipp64u SHA512_224_IV[]; +extern const Ipp64u SHA512_256_IV[]; + +/* hash alg additive constants */ +extern __ALIGN16 const Ipp32u SHA1_cnt[]; +extern __ALIGN16 const Ipp32u SHA256_cnt[]; +extern __ALIGN16 const Ipp64u SHA512_cnt[]; +extern __ALIGN16 const Ipp32u MD5_cnt[]; + + +/* hash alg attributes */ +typedef struct _cpHashAttr { + int ivSize; /* attr: length (bytes) of initial value cpHashIV */ + int hashSize; /* attr: length (bytes) of hash */ + int msgBlkSize; /* attr: length (bytes) of message block */ + int msgLenRepSize; /* attr: length (bytes) in representation of processed message length */ + Ipp64u msgLenMax[2]; /* attr: max message length (bytes) (low high) */ +} cpHashAttr; + + +/* hash value */ +typedef Ipp64u cpHash[IPP_SHA512_DIGEST_BITSIZE/BITSIZE(Ipp64u)]; /* hash value */ + +/* hash update function */ +typedef void (*cpHashProc)(void* pHash, const Ipp8u* pMsg, int msgLen, const void* pParam); + + + +/* hash context */ +struct _cpHashCtx { + IppCtxId idCtx; /* hash identifier */ + IppHashAlgId algID; /* hash algorithm ID */ + Ipp64u msgLenLo; /* length (bytes) of processed message: */ + Ipp64u msgLenHi; /* low and high parts */ + cpHashProc hashProc; /* hash update function */ + const void* pParam; /* optional hashProc's parameter */ + cpHash hashVal; /* intermadiate has value */ + int buffOffset; /* current buffer position */ + Ipp8u msgBuffer[MBS_HASH_MAX]; /* buffer */ +}; + +/* accessors */ +#define HASH_CTX_ID(stt) ((stt)->idCtx) +#define HASH_ALG_ID(stt) ((stt)->algID) +#define HASH_LENLO(stt) ((stt)->msgLenLo) +#define HASH_LENHI(stt) ((stt)->msgLenHi) +#define HASH_FUNC(stt) ((stt)->hashProc) +#define HASH_FUNC_PAR(stt) ((stt)->pParam) +#define HASH_VALUE(stt) ((stt)->hashVal) +#define HAHS_BUFFIDX(stt) ((stt)->buffOffset) +#define HASH_BUFF(stt) ((stt)->msgBuffer) +#define HASH_VALID_ID(pCtx) (HASH_CTX_ID((pCtx))==idCtxHash) + + +/* hash alg opt argument */ +extern const void* cpHashProcFuncOpt[]; + +/* enabled hash alg */ +extern const IppHashAlgId cpEnabledHashAlgID[]; + +/* hash alg IV (init value) */ +extern const Ipp8u* cpHashIV[]; + +/* hash alg attribute DB */ +extern const cpHashAttr cpHashAlgAttr[]; + +/* IV size helper */ +__INLINE int cpHashIvSize(IppHashAlgId algID) +{ return cpHashAlgAttr[algID].ivSize; } + +/* hash size helper */ +__INLINE int cpHashSize(IppHashAlgId algID) +{ return cpHashAlgAttr[algID].hashSize; } + +/* message block size helper */ +__INLINE int cpHashMBS(IppHashAlgId algID) +{ return cpHashAlgAttr[algID].msgBlkSize; } + +/* maps algID into enabled IppHashAlgId value */ +__INLINE IppHashAlgId cpValidHashAlg(IppHashAlgId algID) +{ + /* maps algID into the valid range */ + algID = (((int)ippHashAlg_Unknown < (int)algID) && ((int)algID < (int)ippHashAlg_MaxNo))? algID : ippHashAlg_Unknown; + return cpEnabledHashAlgID[algID]; +} + + +/* processing functions */ +void UpdateSHA1 (void* pHash, const Ipp8u* mblk, int mlen, const void* pParam); +void UpdateSHA256(void* pHash, const Ipp8u* mblk, int mlen, const void* pParam); +void UpdateSHA512(void* pHash, const Ipp8u* mblk, int mlen, const void* pParam); +void UpdateMD5 (void* pHash, const Ipp8u* mblk, int mlen, const void* pParam); + +/* general methods */ +int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID); + +#endif /* _PCP_HASH_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcphashca.c b/external/crypto_px/sources/ippcp/src/pcphashca.c new file mode 100644 index 0000000000..f80272c04b --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphashca.c @@ -0,0 +1,513 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphash.h" +#include "pcptool.h" + + +/*F* +// Name: ippsHashGetSize +// +// Purpose: Returns size (bytes) of IppsHashState state. +// +// Returns: Reason: +// ippStsNullPtrErr pSize == NULL +// ippStsNoErr no errors +// +// Parameters: +// pSize pointer to state size +// +*F*/ +IPPFUN(IppStatus, ippsHashGetSize,(int* pSize)) +{ + /* test pointers */ + IPP_BAD_PTR1_RET(pSize); + + *pSize = sizeof(IppsHashState); + return ippStsNoErr; +} + + +/*F* +// Name: ippsHashInit +// +// Purpose: Init Hash state. +// +// Returns: Reason: +// ippStsNullPtrErr pState == NULL +// ippStsNotSupportedModeErr if algID is not match to supported hash alg +// ippStsNoErr no errors +// +// Parameters: +// pCtx pointer to the Hash state +// algID hash alg ID +// +*F*/ +int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID) +{ + int hashIvSize = cpHashIvSize(algID); + const Ipp8u* iv = cpHashIV[algID]; + + HASH_LENLO(pCtx) = CONST_64(0); + HASH_LENHI(pCtx) = CONST_64(0); + HAHS_BUFFIDX(pCtx) = 0; + CopyBlock(iv, HASH_VALUE(pCtx), hashIvSize); + + return hashIvSize; +} + +/* +// hash alg default processing functions and opt argument +*/ +static cpHashProc cpHashProcFunc[] = { + (cpHashProc)NULL, + UpdateSHA1, + UpdateSHA256, + UpdateSHA256, + UpdateSHA512, + UpdateSHA512, + UpdateMD5, + UpdateSHA512, + UpdateSHA512, +}; + +int cpInitHash(IppsHashState* pCtx, IppHashAlgId algID) +{ + /* setup default processing function */ + HASH_FUNC(pCtx) = cpHashProcFunc[algID]; + + /* setup optional agr of processing function */ + HASH_FUNC_PAR(pCtx) = cpHashProcFuncOpt[algID]; + + return cpReInitHash(pCtx, algID); +} + +IPPFUN(IppStatus, ippsHashInit,(IppsHashState* pCtx, IppHashAlgId algID)) +{ + /* get algorithm id */ + algID = cpValidHashAlg(algID); + /* test hash alg */ + IPP_BADARG_RET(ippHashAlg_Unknown==algID, ippStsNotSupportedModeErr); + + /* test ctx pointer */ + IPP_BAD_PTR1_RET(pCtx); + /* test hash alg */ + + /* set ctx ID */ + HASH_CTX_ID(pCtx) = idCtxHash; + HASH_ALG_ID(pCtx) = algID; + + /* init context */ + cpInitHash(pCtx, algID); + return ippStsNoErr; +} + + +/*F* +// Name: ippsHashUpdate +// +// Purpose: Updates intermediate hash value based on input stream. +// +// Returns: Reason: +// ippStsNullPtrErr pCtx == NULL +// ippStsNullPtrErr pSrc==0 but len!=0 +// ippStsContextMatchErr pCtx->idCtx != idCtxHash +// ippStsLengthErr len <0 +// ippStsNoErr no errors +// +// Parameters: +// pSrc pointer to the input stream +// len input stream length +// pCtx pointer to the Hash context +// +*F*/ +__INLINE int IsExceedMsgLen(Ipp64u maxLo, Ipp64u maxHi, Ipp64u lenLo, Ipp64u lenHi) +{ + int isExceed = lenLo > maxLo; + isExceed = (lenHi+isExceed) > maxHi; + return isExceed; +} + +IPPFUN(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pCtx)) +{ + /* test state pointer and ID */ + IPP_BAD_PTR1_RET(pCtx); + /* test the context */ + IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr); + /* test input length */ + IPP_BADARG_RET((len<0 && pSrc), ippStsLengthErr); + /* test source pointer */ + IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr); + + /* handle non empty input */ + if(len) { + const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pCtx)]; + + /* test if size of message is being processed not exceeded yet */ + Ipp64u lenLo = HASH_LENLO(pCtx); + Ipp64u lenHi = HASH_LENHI(pCtx); + lenLo += len; + if(lenLo < HASH_LENLO(pCtx)) lenHi++; + if(IsExceedMsgLen(pAttr->msgLenMax[0],pAttr->msgLenMax[1], lenLo,lenHi)) + IPP_ERROR_RET(ippStsLengthErr); + + else { + cpHashProc hashFunc = HASH_FUNC(pCtx); /* processing function */ + const void* pParam = HASH_FUNC_PAR(pCtx); /* and it's addition params */ + int mbs = pAttr->msgBlkSize; /* data block size */ + + /* + // processing + */ + { + int procLen; + + /* test if internal buffer is not empty */ + int n = HAHS_BUFFIDX(pCtx); + if(n) { + procLen = IPP_MIN(len, (mbs-n)); + CopyBlock(pSrc, HASH_BUFF(pCtx)+n, procLen); + HAHS_BUFFIDX(pCtx) = n += procLen; + + /* block processing */ + if(mbs==n) { + hashFunc(HASH_VALUE(pCtx), HASH_BUFF(pCtx), mbs, pParam); + HAHS_BUFFIDX(pCtx) = 0; + } + + /* update message pointer and length */ + pSrc += procLen; + len -= procLen; + } + + /* main processing part */ + procLen = len & ~(mbs-1); + if(procLen) { + hashFunc(HASH_VALUE(pCtx), pSrc, procLen, pParam); + pSrc += procLen; + len -= procLen; + } + + /* rest of input message */ + if(len) { + CopyBlock(pSrc, HASH_BUFF(pCtx), len); + HAHS_BUFFIDX(pCtx) += len; + } + } + + /* update length of processed message */ + HASH_LENLO(pCtx) = lenLo; + HASH_LENHI(pCtx) = lenHi; + + return ippStsNoErr; + } + } + + return ippStsNoErr; +} + + +static void cpComputeDigest(Ipp8u* pHashTag, int hashTagLen, const IppsHashState* pCtx) +{ + /* hash alg and parameters */ + cpHashProc hashFunc = HASH_FUNC(pCtx); /* processing function */ + const void* pParam = HASH_FUNC_PAR(pCtx); /* and it's addition params */ + + /* attributes */ + const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pCtx)]; + int mbs = pAttr->msgBlkSize; /* data block size */ + int ivSize = pAttr->ivSize; /* size of hash's IV */ + int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */ + + /* number of bytes in context buffer */ + int n = HAHS_BUFFIDX(pCtx); + /* buffer and it actual length */ + Ipp8u buffer[MBS_HASH_MAX*2]; + int bufferLen = n < (mbs-msgLenRepSize)? mbs : mbs*2; + + /* copy current hash value */ + cpHash hash; + CopyBlock(HASH_VALUE(pCtx), hash, ivSize); + + /* copy of state's buffer */ + CopyBlock(HASH_BUFF(pCtx), buffer, bufferLen); + /* end of message bit */ + buffer[n++] = 0x80; + /* padd buffer */ + PaddBlock(0, buffer+n, bufferLen-n-msgLenRepSize); + + /* message length representation in bits (remember about big endian) */ + { + /* convert processed message length bytes ->bits */ + Ipp64u lo = HASH_LENLO(pCtx); + Ipp64u hi = HASH_LENHI(pCtx); + hi = LSL64(hi,3) | LSR64(lo,63-3); + lo = LSL64(lo,3); + + if(msgLenRepSize>(int)(sizeof(Ipp64u))) { + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + ((Ipp64u*)(buffer+bufferLen))[-2] = hi; + #else + ((Ipp64u*)(buffer+bufferLen))[-2] = ENDIANNESS64(hi); + #endif + } + + /* recall about MD5 specific */ + if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) { + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + ((Ipp64u*)(buffer+bufferLen))[-1] = lo; + #else + ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo); + #endif + } + else { + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo); + #else + ((Ipp64u*)(buffer+bufferLen))[-1] = lo; + #endif + } + } + + /* copmplete hash computation */ + hashFunc(hash, buffer, bufferLen, pParam); + + /* store digest into the user buffer (remember digest in big endian) */ + if(msgLenRepSize>(int)(sizeof(Ipp64u))) { + /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */ + hash[0] = ENDIANNESS64(hash[0]); + hash[1] = ENDIANNESS64(hash[1]); + hash[2] = ENDIANNESS64(hash[2]); + hash[3] = ENDIANNESS64(hash[3]); + hash[4] = ENDIANNESS64(hash[4]); + hash[5] = ENDIANNESS64(hash[5]); + hash[6] = ENDIANNESS64(hash[6]); + hash[7] = ENDIANNESS64(hash[7]); + } + else if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) { + ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]); + ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]); + ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]); + ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]); + ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]); + if(ippHashAlg_SHA1!=HASH_ALG_ID(pCtx)) { + ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]); + ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]); + ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]); + } + } + CopyBlock(hash, pHashTag, hashTagLen); +} + + +/*F* +// Name: ippsHashGetTag +// +// Purpose: Compute digest based on current state. +// Note, that futher digest update is possible +// +// Returns: Reason: +// ippStsNullPtrErr pTag == NULL +// pCtx == NULL +// ippStsContextMatchErr pCtx->idCtx != idCtxHash +// ippStsLengthErr hashSize < tagLen <1 +// ippStsNoErr no errors +// +// Parameters: +// pTag address of the output digest +// tagLen length of digest +// pCtx pointer to the SHS state +// +*F*/ +IPPFUN(IppStatus, ippsHashGetTag,(Ipp8u* pTag, int tagLen, const IppsHashState* pCtx)) +{ + /* test state pointer and ID */ + IPP_BAD_PTR2_RET(pTag, pCtx); + /* test the context */ + IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr); + + { + /* size of hash */ + int hashSize = cpHashAlgAttr[HASH_ALG_ID(pCtx)].hashSize; + if(tagLen<1||hashSizeidCtx != idCtxHash +// ippStsNoErr no errors +// +// Parameters: +// pMD address of the output digest +// pCtx pointer to the SHS state +// +*F*/ +IPPFUN(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pCtx)) +{ + /* test state pointer and ID */ + IPP_BAD_PTR2_RET(pMD, pCtx); + /* test the context */ + IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr); + + { + IppHashAlgId algID = HASH_ALG_ID(pCtx); + int hashSize = cpHashAlgAttr[algID].hashSize; + + cpComputeDigest(pMD, hashSize, pCtx); + cpReInitHash(pCtx, algID); + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsHashMessage +// +// Purpose: Hash of the whole message. +// +// Returns: Reason: +// ippStsNullPtrErr pMD == NULL +// pMsg == NULL but msgLen!=0 +// ippStsLengthErr msgLen <0 +// ippStsNotSupportedModeErr if algID is not match to supported hash alg +// ippStsNoErr no errors +// +// Parameters: +// pMsg pointer to the input message +// msgLen input message length +// pMD address of the output digest +// algID hash alg ID +// +*F*/ +IPPFUN(IppStatus, ippsHashMessage,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD, IppHashAlgId algID)) +{ + /* get algorithm id */ + algID = cpValidHashAlg(algID); + /* test hash alg */ + IPP_BADARG_RET(ippHashAlg_Unknown==algID, ippStsNotSupportedModeErr); + + /* test digest pointer */ + IPP_BAD_PTR1_RET(pMD); + /* test message length */ + IPP_BADARG_RET((msgLen<0), ippStsLengthErr); + /* test message pointer */ + IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr); + + { + /* processing function and parameter */ + cpHashProc hashFunc = cpHashProcFunc[algID]; + const void* pParam = cpHashProcFuncOpt[algID]; + + /* attributes */ + const cpHashAttr* pAttr = &cpHashAlgAttr[algID]; + int mbs = pAttr->msgBlkSize; /* data block size */ + int ivSize = pAttr->ivSize; /* size of hash's IV */ + int hashSize = pAttr->hashSize; /* hash size */ + int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */ + + /* message bitlength representation */ + Ipp64u msgLenBits = (Ipp64u)msgLen*8; + /* length of main message part */ + int msgLenBlks = msgLen & (-mbs); + /* rest of message length */ + int msgLenRest = msgLen - msgLenBlks; + + /* end of message buffer */ + Ipp8u buffer[MBS_HASH_MAX*2]; + int bufferLen = (msgLenRest < (mbs-msgLenRepSize))? mbs : mbs*2; + + /* init hash */ + cpHash hash; + const Ipp8u* iv = cpHashIV[algID]; + CopyBlock(iv, hash, ivSize); + + /*construct last messge block(s) */ + #define MSG_LEN_REP (sizeof(Ipp64u)) + + /* copy end of message */ + CopyBlock(pMsg+msgLen-msgLenRest, buffer, msgLenRest); + /* end of message bit */ + buffer[msgLenRest++] = 0x80; + /* padd buffer */ + PaddBlock(0, buffer+msgLenRest, bufferLen-msgLenRest-MSG_LEN_REP); + /* copy message bitlength representation */ + if(ippHashAlg_MD5!=algID) + msgLenBits = ENDIANNESS64(msgLenBits); + ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits; + + #undef MSG_LEN_REP + + /* message processing */ + if(msgLenBlks) + hashFunc(hash, pMsg, msgLenBlks, pParam); + hashFunc(hash, buffer, bufferLen, pParam); + + /* store digest into the user buffer (remember digest in big endian) */ + if(msgLenRepSize > (int)(sizeof(Ipp64u))) { + /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */ + hash[0] = ENDIANNESS64(hash[0]); + hash[1] = ENDIANNESS64(hash[1]); + hash[2] = ENDIANNESS64(hash[2]); + hash[3] = ENDIANNESS64(hash[3]); + hash[4] = ENDIANNESS64(hash[4]); + hash[5] = ENDIANNESS64(hash[5]); + hash[6] = ENDIANNESS64(hash[6]); + hash[7] = ENDIANNESS64(hash[7]); + } + else if(ippHashAlg_MD5!=algID) { + /* ippHashAlg_SHA1, ippHashAlg_SHA224, ippHashAlg_SHA256 and ippHashAlg_SM3 */ + ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]); + ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]); + ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]); + ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]); + ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]); + ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]); + ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]); + ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]); + } + CopyBlock(hash, pMD, hashSize); + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcphashcnt.c b/external/crypto_px/sources/ippcp/src/pcphashcnt.c new file mode 100644 index 0000000000..9a54892bbf --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphashcnt.c @@ -0,0 +1,216 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphash.h" + +/* +// enabled hash alg IDs +*/ +const IppHashAlgId cpEnabledHashAlgID[] = { + IPP_ALG_HASH_UNKNOWN, + IPP_ALG_HASH_SHA1, + IPP_ALG_HASH_SHA256, + IPP_ALG_HASH_SHA224, + IPP_ALG_HASH_SHA512, + IPP_ALG_HASH_SHA384, + IPP_ALG_HASH_MD5, + IPP_ALG_HASH_SHA512_224, + IPP_ALG_HASH_SHA512_256 +}; +//////////////////////////////////////////////////////////// + +/* +// hash init values +*/ +const Ipp32u UnknownHash_IV[] = { + 0}; + +const Ipp32u SHA1_IV[] = { + 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0}; + +const Ipp32u SHA256_IV[] = { + 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, + 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19}; + +const Ipp32u SHA224_IV[] = { + 0xC1059ED8, 0x367CD507, 0x3070DD17, 0xF70E5939, + 0xFFC00B31, 0x68581511, 0x64F98FA7, 0xBEFA4FA4}; + +const Ipp64u SHA512_IV[] = { + CONST_64(0x6A09E667F3BCC908), CONST_64(0xBB67AE8584CAA73B), + CONST_64(0x3C6EF372FE94F82B), CONST_64(0xA54FF53A5F1D36F1), + CONST_64(0x510E527FADE682D1), CONST_64(0x9B05688C2B3E6C1F), + CONST_64(0x1F83D9ABFB41BD6B), CONST_64(0x5BE0CD19137E2179)}; + +const Ipp64u SHA384_IV[] = { + CONST_64(0xCBBB9D5DC1059ED8), CONST_64(0x629A292A367CD507), + CONST_64(0x9159015A3070DD17), CONST_64(0x152FECD8F70E5939), + CONST_64(0x67332667FFC00B31), CONST_64(0x8EB44A8768581511), + CONST_64(0xDB0C2E0D64F98FA7), CONST_64(0x47B5481DBEFA4FA4)}; + +const Ipp32u MD5_IV[] = { + 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476}; + +const Ipp64u SHA512_224_IV[] = { + CONST_64(0x8C3D37C819544DA2), CONST_64(0x73E1996689DCD4D6), + CONST_64(0x1DFAB7AE32FF9C82), CONST_64(0x679DD514582F9FCF), + CONST_64(0x0F6D2B697BD44DA8), CONST_64(0x77E36F7304C48942), + CONST_64(0x3F9D85A86A1D36C8), CONST_64(0x1112E6AD91D692A1)}; + +const Ipp64u SHA512_256_IV[] = { + CONST_64(0x22312194FC2BF72C), CONST_64(0x9F555FA3C84C64C2), + CONST_64(0x2393B86B6F53B151), CONST_64(0x963877195940EABD), + CONST_64(0x96283EE2A88EFFE3), CONST_64(0xBE5E1E2553863992), + CONST_64(0x2B0199FC2C85B8AA), CONST_64(0x0EB72DDC81C52CA2)}; + +const Ipp8u* cpHashIV[] = { + (Ipp8u*)UnknownHash_IV, + (Ipp8u*)SHA1_IV, + (Ipp8u*)SHA256_IV, + (Ipp8u*)SHA224_IV, + (Ipp8u*)SHA512_IV, + (Ipp8u*)SHA384_IV, + (Ipp8u*)MD5_IV, + (Ipp8u*)SHA512_224_IV, + (Ipp8u*)SHA512_256_IV, +}; + +//////////////////////////////////////////////////////////// + +/* +// additive constatns +*/ +__ALIGN16 const Ipp32u SHA1_cnt[] = { + 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 +}; + +__ALIGN16 const Ipp32u SHA256_cnt[] = { + 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, + 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, + 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, + 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, + 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, + 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, + 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, + 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, + 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, + 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, + 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, + 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, + 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, + 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, + 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, + 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 +}; + +__ALIGN16 const Ipp64u SHA512_cnt[] = { + CONST_64(0x428A2F98D728AE22), CONST_64(0x7137449123EF65CD), CONST_64(0xB5C0FBCFEC4D3B2F), CONST_64(0xE9B5DBA58189DBBC), + CONST_64(0x3956C25BF348B538), CONST_64(0x59F111F1B605D019), CONST_64(0x923F82A4AF194F9B), CONST_64(0xAB1C5ED5DA6D8118), + CONST_64(0xD807AA98A3030242), CONST_64(0x12835B0145706FBE), CONST_64(0x243185BE4EE4B28C), CONST_64(0x550C7DC3D5FFB4E2), + CONST_64(0x72BE5D74F27B896F), CONST_64(0x80DEB1FE3B1696B1), CONST_64(0x9BDC06A725C71235), CONST_64(0xC19BF174CF692694), + CONST_64(0xE49B69C19EF14AD2), CONST_64(0xEFBE4786384F25E3), CONST_64(0x0FC19DC68B8CD5B5), CONST_64(0x240CA1CC77AC9C65), + CONST_64(0x2DE92C6F592B0275), CONST_64(0x4A7484AA6EA6E483), CONST_64(0x5CB0A9DCBD41FBD4), CONST_64(0x76F988DA831153B5), + CONST_64(0x983E5152EE66DFAB), CONST_64(0xA831C66D2DB43210), CONST_64(0xB00327C898FB213F), CONST_64(0xBF597FC7BEEF0EE4), + CONST_64(0xC6E00BF33DA88FC2), CONST_64(0xD5A79147930AA725), CONST_64(0x06CA6351E003826F), CONST_64(0x142929670A0E6E70), + CONST_64(0x27B70A8546D22FFC), CONST_64(0x2E1B21385C26C926), CONST_64(0x4D2C6DFC5AC42AED), CONST_64(0x53380D139D95B3DF), + CONST_64(0x650A73548BAF63DE), CONST_64(0x766A0ABB3C77B2A8), CONST_64(0x81C2C92E47EDAEE6), CONST_64(0x92722C851482353B), + CONST_64(0xA2BFE8A14CF10364), CONST_64(0xA81A664BBC423001), CONST_64(0xC24B8B70D0F89791), CONST_64(0xC76C51A30654BE30), + CONST_64(0xD192E819D6EF5218), CONST_64(0xD69906245565A910), CONST_64(0xF40E35855771202A), CONST_64(0x106AA07032BBD1B8), + CONST_64(0x19A4C116B8D2D0C8), CONST_64(0x1E376C085141AB53), CONST_64(0x2748774CDF8EEB99), CONST_64(0x34B0BCB5E19B48A8), + CONST_64(0x391C0CB3C5C95A63), CONST_64(0x4ED8AA4AE3418ACB), CONST_64(0x5B9CCA4F7763E373), CONST_64(0x682E6FF3D6B2B8A3), + CONST_64(0x748F82EE5DEFB2FC), CONST_64(0x78A5636F43172F60), CONST_64(0x84C87814A1F0AB72), CONST_64(0x8CC702081A6439EC), + CONST_64(0x90BEFFFA23631E28), CONST_64(0xA4506CEBDE82BDE9), CONST_64(0xBEF9A3F7B2C67915), CONST_64(0xC67178F2E372532B), + CONST_64(0xCA273ECEEA26619C), CONST_64(0xD186B8C721C0C207), CONST_64(0xEADA7DD6CDE0EB1E), CONST_64(0xF57D4F7FEE6ED178), + CONST_64(0x06F067AA72176FBA), CONST_64(0x0A637DC5A2C898A6), CONST_64(0x113F9804BEF90DAE), CONST_64(0x1B710B35131C471B), + CONST_64(0x28DB77F523047D84), CONST_64(0x32CAAB7B40C72493), CONST_64(0x3C9EBE0A15C9BEBC), CONST_64(0x431D67C49C100D4C), + CONST_64(0x4CC5D4BECB3E42B6), CONST_64(0x597F299CFC657E2A), CONST_64(0x5FCB6FAB3AD6FAEC), CONST_64(0x6C44198C4A475817) +}; + +__ALIGN16 const Ipp32u MD5_cnt[] = { + 0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, + 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501, + 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, + 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821, + + 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, + 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8, + 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED, + 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A, + + 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C, + 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70, + 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05, + 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665, + + 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039, + 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1, + 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1, + 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391 +}; + +/* +// hash alg default processing opt argument +*/ +const void* cpHashProcFuncOpt[] = { + NULL, + SHA1_cnt, + SHA256_cnt, + SHA256_cnt, + SHA512_cnt, + SHA512_cnt, + MD5_cnt, + SHA512_cnt, + SHA512_cnt, +}; +//////////////////////////////////////////////////////////// + +/* hash alg attributes */ +const cpHashAttr cpHashAlgAttr[] = { + {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, /* unknown */ + + {IPP_SHA1_DIGEST_BITSIZE/8, IPP_SHA1_DIGEST_BITSIZE/8, MBS_SHA1, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, + + {IPP_SHA256_DIGEST_BITSIZE/8,IPP_SHA256_DIGEST_BITSIZE/8, MBS_SHA256, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, + + {IPP_SHA256_DIGEST_BITSIZE/8,IPP_SHA224_DIGEST_BITSIZE/8, MBS_SHA224, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, + + {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}}, + + {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA384_DIGEST_BITSIZE/8, MBS_SHA384, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}}, + + {IPP_MD5_DIGEST_BITSIZE/8,IPP_MD5_DIGEST_BITSIZE/8, MBS_MD5, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, + + {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_224_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}}, + + {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_256_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}} +}; diff --git a/external/crypto_px/sources/ippcp/src/pcphashmd5px.c b/external/crypto_px/sources/ippcp/src/pcphashmd5px.c new file mode 100644 index 0000000000..f42f95bde6 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphashmd5px.c @@ -0,0 +1,197 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphash.h" +#include "pcptool.h" + +#pragma message("IPP_ALG_HASH_MD5 enabled") + + +/* +// Magic functions defined in RFC 1321 +// +*/ +#define F(X,Y,Z) ((Z) ^ ((X) & ((Y) ^ (Z)))) /* sightly optimized form of (((X) & (Y)) | ((~(X) & (Z)))*/ +#define G(X,Y,Z) F((Z),(X),(Y)) /* replace the original (((X) & (Z)) | ((Y) & ~(Z))) */ +#define H(X,Y,Z) ((X) ^ (Y) ^ (Z)) +#define I(X,Y,Z) ((Y) ^ ((X) | ~(Z))) + +/* +// MD5 step +*/ +#define MD5_STEP(MAGIC, A,B,C,D, data, constant, nrot) \ + (A = B +ROL32((A +MAGIC(B,C,D) +data +constant), nrot)) + +/* +// MD5 left rotations (number of bits) +// depends on round type +*/ +#define F1 7 +#define F2 12 +#define F3 17 +#define F4 22 + +#define G1 5 +#define G2 9 +#define G3 14 +#define G4 20 + +#define H1 4 +#define H2 11 +#define H3 16 +#define H4 23 + +#define I1 6 +#define I2 10 +#define I3 15 +#define I4 21 + +/*F* +// Name: UpdateMD5 +// +// Purpose: Update internal hash according to input message stream. +// +// Parameters: +// uniHash pointer to in/out hash +// mblk pointer to message stream +// mlen message stream length (multiple by message block size) +// uniParam pointer to the optional parameter +// +*F*/ +void UpdateMD5(void* uinHash, const Ipp8u* mblk, int mlen, const void* uniParam) +{ + Ipp32u* digest = (Ipp32u*)uinHash; + Ipp32u* MD5_cnt_loc = (Ipp32u*)uniParam; + + for(; mlen>=MBS_MD5; mblk += MBS_MD5, mlen -= MBS_MD5) { + + /* allocate data */ + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + Ipp32u data[MBS_MD5/sizeof(Ipp32u)]; + #else + /* or just word alias */ + Ipp32u* data = (Ipp32u*)mblk; + #endif + + /* init variables */ + Ipp32u a = digest[0]; + Ipp32u b = digest[1]; + Ipp32u c = digest[2]; + Ipp32u d = digest[3]; + + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + int t; + for(t=0; t<16; t++) { + data[t] = ENDIANNESS(((Ipp32u*)mblk)[t]); + } + #endif + + /* rounds type F */ + MD5_STEP(F, a,b,c,d, data[ 0], MD5_cnt_loc[ 0], F1); + MD5_STEP(F, d,a,b,c, data[ 1], MD5_cnt_loc[ 1], F2); + MD5_STEP(F, c,d,a,b, data[ 2], MD5_cnt_loc[ 2], F3); + MD5_STEP(F, b,c,d,a, data[ 3], MD5_cnt_loc[ 3], F4); + MD5_STEP(F, a,b,c,d, data[ 4], MD5_cnt_loc[ 4], F1); + MD5_STEP(F, d,a,b,c, data[ 5], MD5_cnt_loc[ 5], F2); + MD5_STEP(F, c,d,a,b, data[ 6], MD5_cnt_loc[ 6], F3); + MD5_STEP(F, b,c,d,a, data[ 7], MD5_cnt_loc[ 7], F4); + MD5_STEP(F, a,b,c,d, data[ 8], MD5_cnt_loc[ 8], F1); + MD5_STEP(F, d,a,b,c, data[ 9], MD5_cnt_loc[ 9], F2); + MD5_STEP(F, c,d,a,b, data[10], MD5_cnt_loc[10], F3); + MD5_STEP(F, b,c,d,a, data[11], MD5_cnt_loc[11], F4); + MD5_STEP(F, a,b,c,d, data[12], MD5_cnt_loc[12], F1); + MD5_STEP(F, d,a,b,c, data[13], MD5_cnt_loc[13], F2); + MD5_STEP(F, c,d,a,b, data[14], MD5_cnt_loc[14], F3); + MD5_STEP(F, b,c,d,a, data[15], MD5_cnt_loc[15], F4); + + /* rounds type G */ + MD5_STEP(G, a,b,c,d, data[ 1], MD5_cnt_loc[16], G1); + MD5_STEP(G, d,a,b,c, data[ 6], MD5_cnt_loc[17], G2); + MD5_STEP(G, c,d,a,b, data[11], MD5_cnt_loc[18], G3); + MD5_STEP(G, b,c,d,a, data[ 0], MD5_cnt_loc[19], G4); + MD5_STEP(G, a,b,c,d, data[ 5], MD5_cnt_loc[20], G1); + MD5_STEP(G, d,a,b,c, data[10], MD5_cnt_loc[21], G2); + MD5_STEP(G, c,d,a,b, data[15], MD5_cnt_loc[22], G3); + MD5_STEP(G, b,c,d,a, data[ 4], MD5_cnt_loc[23], G4); + MD5_STEP(G, a,b,c,d, data[ 9], MD5_cnt_loc[24], G1); + MD5_STEP(G, d,a,b,c, data[14], MD5_cnt_loc[25], G2); + MD5_STEP(G, c,d,a,b, data[ 3], MD5_cnt_loc[26], G3); + MD5_STEP(G, b,c,d,a, data[ 8], MD5_cnt_loc[27], G4); + MD5_STEP(G, a,b,c,d, data[13], MD5_cnt_loc[28], G1); + MD5_STEP(G, d,a,b,c, data[ 2], MD5_cnt_loc[29], G2); + MD5_STEP(G, c,d,a,b, data[ 7], MD5_cnt_loc[30], G3); + MD5_STEP(G, b,c,d,a, data[12], MD5_cnt_loc[31], G4); + + /* rounds type H */ + MD5_STEP(H, a,b,c,d, data[ 5], MD5_cnt_loc[32], H1); + MD5_STEP(H, d,a,b,c, data[ 8], MD5_cnt_loc[33], H2); + MD5_STEP(H, c,d,a,b, data[11], MD5_cnt_loc[34], H3); + MD5_STEP(H, b,c,d,a, data[14], MD5_cnt_loc[35], H4); + MD5_STEP(H, a,b,c,d, data[ 1], MD5_cnt_loc[36], H1); + MD5_STEP(H, d,a,b,c, data[ 4], MD5_cnt_loc[37], H2); + MD5_STEP(H, c,d,a,b, data[ 7], MD5_cnt_loc[38], H3); + MD5_STEP(H, b,c,d,a, data[10], MD5_cnt_loc[39], H4); + MD5_STEP(H, a,b,c,d, data[13], MD5_cnt_loc[40], H1); + MD5_STEP(H, d,a,b,c, data[ 0], MD5_cnt_loc[41], H2); + MD5_STEP(H, c,d,a,b, data[ 3], MD5_cnt_loc[42], H3); + MD5_STEP(H, b,c,d,a, data[ 6], MD5_cnt_loc[43], H4); + MD5_STEP(H, a,b,c,d, data[ 9], MD5_cnt_loc[44], H1); + MD5_STEP(H, d,a,b,c, data[12], MD5_cnt_loc[45], H2); + MD5_STEP(H, c,d,a,b, data[15], MD5_cnt_loc[46], H3); + MD5_STEP(H, b,c,d,a, data[ 2], MD5_cnt_loc[47], H4); + + /* rounds type I */ + MD5_STEP(I, a,b,c,d, data[ 0], MD5_cnt_loc[48], I1); + MD5_STEP(I, d,a,b,c, data[ 7], MD5_cnt_loc[49], I2); + MD5_STEP(I, c,d,a,b, data[14], MD5_cnt_loc[50], I3); + MD5_STEP(I, b,c,d,a, data[ 5], MD5_cnt_loc[51], I4); + MD5_STEP(I, a,b,c,d, data[12], MD5_cnt_loc[52], I1); + MD5_STEP(I, d,a,b,c, data[ 3], MD5_cnt_loc[53], I2); + MD5_STEP(I, c,d,a,b, data[10], MD5_cnt_loc[54], I3); + MD5_STEP(I, b,c,d,a, data[ 1], MD5_cnt_loc[55], I4); + MD5_STEP(I, a,b,c,d, data[ 8], MD5_cnt_loc[56], I1); + MD5_STEP(I, d,a,b,c, data[15], MD5_cnt_loc[57], I2); + MD5_STEP(I, c,d,a,b, data[ 6], MD5_cnt_loc[58], I3); + MD5_STEP(I, b,c,d,a, data[13], MD5_cnt_loc[59], I4); + MD5_STEP(I, a,b,c,d, data[ 4], MD5_cnt_loc[60], I1); + MD5_STEP(I, d,a,b,c, data[11], MD5_cnt_loc[61], I2); + MD5_STEP(I, c,d,a,b, data[ 2], MD5_cnt_loc[62], I3); + MD5_STEP(I, b,c,d,a, data[ 9], MD5_cnt_loc[63], I4); + + /* update digest */ + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcphashsha1px.c b/external/crypto_px/sources/ippcp/src/pcphashsha1px.c new file mode 100644 index 0000000000..cb3b7a155f --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphashsha1px.c @@ -0,0 +1,174 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphash.h" +#include "pcptool.h" + + +/* +// Magic functions defined in FIPS 180-1 +// +*/ +#define MAGIC_F0(B,C,D) (((B) & (C)) | ((~(B)) & (D))) +#define MAGIC_F1(B,C,D) ((B) ^ (C) ^ (D)) +#define MAGIC_F2(B,C,D) (((B) & (C)) | ((B) & (D)) | ((C) & (D))) +#define MAGIC_F3(B,C,D) ((B) ^ (C) ^ (D)) + +#define SHA1_STEP(A,B,C,D,E, MAGIC_FUN, W,K) \ + (E)+= ROL32((A),5) + MAGIC_FUN((B),(C),(D)) + (W) + (K); \ + (B) = ROL32((B),30) + +#define COMPACT_SHA1_STEP(A,B,C,D,E, MAGIC_FUN, W,K, t) { \ + Ipp32u _T = ROL32((A),5) + MAGIC_FUN((t)/20, (B),(C),(D)) + (E) + (W)[(t)] + (K)[(t)/20]; \ + (E) = (D); \ + (D) = (C); \ + (C) = ROL32((B),30); \ + (B) = (A); \ + (A) = _T; \ +} + +#if defined(_ALG_SHA1_COMPACT_) +__INLINE Ipp32u MagicFun(int s, Ipp32u b, Ipp32u c, Ipp32u d) +{ + switch(s) { + case 0: return MAGIC_F0(b,c,d); + case 2: return MAGIC_F2(b,c,d); + default:return MAGIC_F1(b,c,d); + } +} +#endif + + +/*F* +// Name: UpdateSHA1 +// +// Purpose: Update internal hash according to input message stream. +// +// Parameters: +// uniHash pointer to in/out hash +// mblk pointer to message stream +// mlen message stream length (multiple by message block size) +// uniParam pointer to the optional parameter +// +*F*/ +#if defined(_ALG_SHA1_COMPACT_) +#pragma message("SHA1 compact") +#endif + +void UpdateSHA1(void* uinHash, const Ipp8u* mblk, int mlen, const void *uniParam) +{ + Ipp32u* data = (Ipp32u*)mblk; + + Ipp32u* digest = (Ipp32u*)uinHash; + Ipp32u* SHA1_cnt_loc = (Ipp32u*)uniParam; + + for(; mlen>=MBS_SHA1; data += MBS_SHA1/sizeof(Ipp32u), mlen -= MBS_SHA1) { + int t; + + /* + // expand message block + */ + Ipp32u W[80]; + /* initialize the first 16 words in the array W (remember about endian) */ + for(t=0; t<16; t++) { + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + W[t] = data[t]; + #else + W[t] = ENDIANNESS(data[t]); + #endif + } + /* schedule another 80-16 words in the array W */ + for(; t<80; t++) { + W[t] = ROL32(W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1); + } + + /* + // update hash + */ + { + /* init A, B, C, D, E by the the input hash */ + Ipp32u A = digest[0]; + Ipp32u B = digest[1]; + Ipp32u C = digest[2]; + Ipp32u D = digest[3]; + Ipp32u E = digest[4]; + + #if defined(_ALG_SHA1_COMPACT_) + /* steps 0-79 */ + for(t=0; t<80; t++) + COMPACT_SHA1_STEP(A,B,C,D,E, MagicFun, W, SHA1_cnt_loc, t); + + #else + /* perform 0-19 steps */ + for(t=0; t<20; t+=5) { + SHA1_STEP(A,B,C,D,E, MAGIC_F0, W[t ],SHA1_cnt_loc[0]); + SHA1_STEP(E,A,B,C,D, MAGIC_F0, W[t+1],SHA1_cnt_loc[0]); + SHA1_STEP(D,E,A,B,C, MAGIC_F0, W[t+2],SHA1_cnt_loc[0]); + SHA1_STEP(C,D,E,A,B, MAGIC_F0, W[t+3],SHA1_cnt_loc[0]); + SHA1_STEP(B,C,D,E,A, MAGIC_F0, W[t+4],SHA1_cnt_loc[0]); + } + /* perform 20-39 steps */ + for(; t<40; t+=5) { + SHA1_STEP(A,B,C,D,E, MAGIC_F1, W[t ],SHA1_cnt_loc[1]); + SHA1_STEP(E,A,B,C,D, MAGIC_F1, W[t+1],SHA1_cnt_loc[1]); + SHA1_STEP(D,E,A,B,C, MAGIC_F1, W[t+2],SHA1_cnt_loc[1]); + SHA1_STEP(C,D,E,A,B, MAGIC_F1, W[t+3],SHA1_cnt_loc[1]); + SHA1_STEP(B,C,D,E,A, MAGIC_F1, W[t+4],SHA1_cnt_loc[1]); + } + /* perform 40-59 steps */ + for(; t<60; t+=5) { + SHA1_STEP(A,B,C,D,E, MAGIC_F2, W[t ],SHA1_cnt_loc[2]); + SHA1_STEP(E,A,B,C,D, MAGIC_F2, W[t+1],SHA1_cnt_loc[2]); + SHA1_STEP(D,E,A,B,C, MAGIC_F2, W[t+2],SHA1_cnt_loc[2]); + SHA1_STEP(C,D,E,A,B, MAGIC_F2, W[t+3],SHA1_cnt_loc[2]); + SHA1_STEP(B,C,D,E,A, MAGIC_F2, W[t+4],SHA1_cnt_loc[2]); + } + /* perform 60-79 steps */ + for(; t<80; t+=5) { + SHA1_STEP(A,B,C,D,E, MAGIC_F3, W[t ],SHA1_cnt_loc[3]); + SHA1_STEP(E,A,B,C,D, MAGIC_F3, W[t+1],SHA1_cnt_loc[3]); + SHA1_STEP(D,E,A,B,C, MAGIC_F3, W[t+2],SHA1_cnt_loc[3]); + SHA1_STEP(C,D,E,A,B, MAGIC_F3, W[t+3],SHA1_cnt_loc[3]); + SHA1_STEP(B,C,D,E,A, MAGIC_F3, W[t+4],SHA1_cnt_loc[3]); + } + #endif + + /* update digest */ + digest[0] += A; + digest[1] += B; + digest[2] += C; + digest[3] += D; + digest[4] += E; + } + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcphashsha256px.c b/external/crypto_px/sources/ippcp/src/pcphashsha256px.c new file mode 100644 index 0000000000..0eb0628518 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphashsha256px.c @@ -0,0 +1,199 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphash.h" +#include "pcptool.h" + + +/* +// SHA256 Specific Macros (reference proposal 256-384-512) +*/ +#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z))) +#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) + +#define SUM0(x) (ROR32((x), 2) ^ ROR32((x),13) ^ ROR32((x),22)) +#define SUM1(x) (ROR32((x), 6) ^ ROR32((x),11) ^ ROR32((x),25)) + +#define SIG0(x) (ROR32((x), 7) ^ ROR32((x),18) ^ LSR32((x), 3)) +#define SIG1(x) (ROR32((x),17) ^ ROR32((x),19) ^ LSR32((x),10)) + +#define SHA256_UPDATE(i) \ + wdat[i & 15] += SIG1(wdat[(i+14)&15]) + wdat[(i+9)&15] + SIG0(wdat[(i+1)&15]) + +#define SHA256_STEP(i,j) \ + v[(7 - i) & 7] += (j ? SHA256_UPDATE(i) : wdat[i&15]) \ + + SHA256_cnt_loc[i + j] \ + + SUM1(v[(4-i)&7]) \ + + CH(v[(4-i)&7], v[(5-i)&7], v[(6-i)&7]); \ + v[(3-i)&7] += v[(7-i)&7]; \ + v[(7-i)&7] += SUM0(v[(0-i)&7]) + MAJ(v[(0-i)&7], v[(1-i)&7], v[(2-i)&7]) + +#define COMPACT_SHA256_STEP(A,B,C,D,E,F,G,H, W,K, r) { \ + Ipp32u _T1 = (H) + SUM1((E)) + CH((E),(F),(G)) + (W)[(r)] + (K)[(r)]; \ + Ipp32u _T2 = SUM0((A)) + MAJ((A),(B),(C)); \ + (H) = (G); \ + (G) = (F); \ + (F) = (E); \ + (E) = (D)+_T1; \ + (D) = (C); \ + (C) = (B); \ + (B) = (A); \ + (A) = _T1+_T2; \ +} + +/*F* +// Name: UpdateSHA256 +// +// Purpose: Update internal hash according to input message stream. +// +// Parameters: +// uniHash pointer to in/out hash +// mblk pointer to message stream +// mlen message stream length (multiple by message block size) +// uniParam pointer to the optional parameter +// +*F*/ +#if defined(_ALG_SHA256_COMPACT_) +#pragma message("SHA256 compact") + +void UpdateSHA256(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniParam) +{ + Ipp32u* data = (Ipp32u*)mblk; + + Ipp32u* digest = (Ipp32u*)uniHash; + Ipp32u* SHA256_cnt_loc = (Ipp32u*)uniParam; + + for(; mlen>=MBS_SHA256; data += MBS_SHA256/sizeof(Ipp32u), mlen -= MBS_SHA256) { + int t; + + /* + // expand message block + */ + Ipp32u W[64]; + /* initialize the first 16 words in the array W (remember about endian) */ + for(t=0; t<16; t++) { + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + W[t] = data[t]; + #else + W[t] = ENDIANNESS( data[t] ); + #endif + } + for(; t<64; t++) + W[t] = SIG1(W[t-2]) + W[t-7] + SIG0(W[t-15]) + W[t-16]; + + /* + // update hash + */ + { + /* init A, B, C, D, E, F, G, H by the input hash */ + Ipp32u A = digest[0]; + Ipp32u B = digest[1]; + Ipp32u C = digest[2]; + Ipp32u D = digest[3]; + Ipp32u E = digest[4]; + Ipp32u F = digest[5]; + Ipp32u G = digest[6]; + Ipp32u H = digest[7]; + + for(t=0; t<64; t++) + COMPACT_SHA256_STEP(A,B,C,D,E,F,G,H, W,SHA256_cnt_loc, t); + + /* update hash*/ + digest[0] += A; + digest[1] += B; + digest[2] += C; + digest[3] += D; + digest[4] += E; + digest[5] += F; + digest[6] += G; + digest[7] += H; + } + } +} + +#else +void UpdateSHA256(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniParam) +{ + Ipp32u* data = (Ipp32u*)mblk; + + Ipp32u* digest = (Ipp32u*)uniHash; + Ipp32u* SHA256_cnt_loc = (Ipp32u*)uniParam; + + for(; mlen>=MBS_SHA256; data += MBS_SHA256/sizeof(Ipp32u), mlen -= MBS_SHA256) { + Ipp32u wdat[16]; + int j; + + /* copy digest */ + Ipp32u v[8]; + CopyBlock(digest, v, IPP_SHA256_DIGEST_BITSIZE/BYTESIZE); + + /* initialize the first 16 words in the array W (remember about endian) */ + for(j=0; j<16; j++) { + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + wdat[j] = data[j]; + #else + wdat[j] = ENDIANNESS( data[j] ); + #endif + } + + for(j=0; j<64; j+=16) { + SHA256_STEP( 0, j); + SHA256_STEP( 1, j); + SHA256_STEP( 2, j); + SHA256_STEP( 3, j); + SHA256_STEP( 4, j); + SHA256_STEP( 5, j); + SHA256_STEP( 6, j); + SHA256_STEP( 7, j); + SHA256_STEP( 8, j); + SHA256_STEP( 9, j); + SHA256_STEP(10, j); + SHA256_STEP(11, j); + SHA256_STEP(12, j); + SHA256_STEP(13, j); + SHA256_STEP(14, j); + SHA256_STEP(15, j); + } + + /* update digest */ + digest[0] += v[0]; + digest[1] += v[1]; + digest[2] += v[2]; + digest[3] += v[3]; + digest[4] += v[4]; + digest[5] += v[5]; + digest[6] += v[6]; + digest[7] += v[7]; + } +} +#endif diff --git a/external/crypto_px/sources/ippcp/src/pcphashsha512px.c b/external/crypto_px/sources/ippcp/src/pcphashsha512px.c new file mode 100644 index 0000000000..5dd09b8fca --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphashsha512px.c @@ -0,0 +1,207 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphash.h" +#include "pcptool.h" + + +/* +// SHA512 Specific Macros (reference proposal 256-384-512) +// +// Note: All operations act on DWORDs (64-bits) +*/ +#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z))) +#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) + +#define SUM0(x) (ROR64((x),28) ^ ROR64((x),34) ^ ROR64((x),39)) +#define SUM1(x) (ROR64((x),14) ^ ROR64((x),18) ^ ROR64((x),41)) + +#define SIG0(x) (ROR64((x), 1) ^ ROR64((x), 8) ^ LSR64((x), 7)) +#define SIG1(x) (ROR64((x),19) ^ ROR64((x),61) ^ LSR64((x), 6)) + +#define SHA512_UPDATE(i) \ + wdat[i&15] += SIG1(wdat[(i+14)&15]) + wdat[(i+9)&15] + SIG0(wdat[(i+1)&15]) + +#define SHA512_STEP(i,j) \ + v[(7-i)&7] += (j ? SHA512_UPDATE(i) : wdat[i&15]) \ + + SHA512_cnt_loc[i+j] \ + + SUM1(v[(4-i)&7]) \ + + CH(v[(4-i)&7], v[(5-i)&7], v[(6-i)&7]); \ + v[(3-i)&7] += v[(7-i)&7]; \ + v[(7-i)&7] += SUM0(v[(0-i)&7]) + MAJ(v[(0-i)&7], v[(1-i)&7], v[(2-i)&7]) + +#define COMPACT_SHA512_STEP(A,B,C,D,E,F,G,H, W,K, r) { \ + Ipp64u _T1 = (H) + SUM1((E)) + CH((E),(F),(G)) + (W)[(r)] + (K)[(r)]; \ + Ipp64u _T2 = SUM0((A)) + MAJ((A),(B),(C)); \ + (H) = (G); \ + (G) = (F); \ + (F) = (E); \ + (E) = (D)+_T1; \ + (D) = (C); \ + (C) = (B); \ + (B) = (A); \ + (A) = _T1+_T2; \ +} + +/*F* +// Name: UpdateSHA512 +// +// Purpose: Update internal hash according to input message stream. +// +// Parameters: +// uniHash pointer to in/out hash +// mblk pointer to message stream +// mlen message stream length (multiple by message block size) +// uniParam pointer to the optional parameter +// +*F*/ +#if defined(_ALG_SHA512_COMPACT_) +#pragma message("SHA512 compact") + +void UpdateSHA512(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniPraram) +{ + Ipp32u* data = (Ipp32u*)mblk; + + Ipp64u* digest = (Ipp64u*)uniHash; + Ipp64u* SHA512_cnt_loc = (Ipp64u*)uniPraram; + + + for(; mlen>=MBS_SHA512; data += MBS_SHA512/sizeof(Ipp32u), mlen -= MBS_SHA512) { + int t; + Ipp64u W[80]; + + /* + // expand message block + */ + /* initialize the first 16 words in the array W (remember about endian) */ + for(t=0; t<16; t++) { + Ipp32u hiX = data[2*t]; + Ipp32u loX = data[2*t+1]; + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + W[t] = MAKEDWORD(loX, hiX); + #else + W[t] = MAKEDWORD( ENDIANNESS(loX), ENDIANNESS(hiX) ); + #endif + } + for(; t<80; t++) + W[t] = SIG1(W[t-2]) + W[t-7] + SIG0(W[t-15]) + W[t-16]; + + /* + // update hash + */ + { + /* init A, B, C, D, E, F, G, H by the input hash */ + Ipp64u A = digest[0]; + Ipp64u B = digest[1]; + Ipp64u C = digest[2]; + Ipp64u D = digest[3]; + Ipp64u E = digest[4]; + Ipp64u F = digest[5]; + Ipp64u G = digest[6]; + Ipp64u H = digest[7]; + + for(t=0; t<80; t++) + COMPACT_SHA512_STEP(A,B,C,D,E,F,G,H, W,SHA512_cnt_loc, t); + + /* update hash*/ + digest[0] += A; + digest[1] += B; + digest[2] += C; + digest[3] += D; + digest[4] += E; + digest[5] += F; + digest[6] += G; + digest[7] += H; + } + } +} + +#else +void UpdateSHA512(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniPraram) +{ + Ipp32u* data = (Ipp32u*)mblk; + + Ipp64u* digest = (Ipp64u*)uniHash; + Ipp64u* SHA512_cnt_loc = (Ipp64u*)uniPraram; + + for(; mlen>=MBS_SHA512; data += MBS_SHA512/sizeof(Ipp32u), mlen -= MBS_SHA512) { + Ipp64u wdat[16]; + int j; + + Ipp64u v[8]; + + /* initialize the first 16 words in the array W (remember about endian) */ + for(j=0; j<16; j++) { + Ipp32u hiX = data[2*j]; + Ipp32u loX = data[2*j+1]; + #if (IPP_ENDIAN == IPP_BIG_ENDIAN) + wdat[j] = MAKEDWORD(loX, hiX); + #else + wdat[j] = MAKEDWORD( ENDIANNESS(loX), ENDIANNESS(hiX) ); + #endif + } + + /* copy digest */ + CopyBlock(digest, v, IPP_SHA512_DIGEST_BITSIZE/BYTESIZE); + + for(j=0; j<80; j+=16) { + SHA512_STEP( 0, j); + SHA512_STEP( 1, j); + SHA512_STEP( 2, j); + SHA512_STEP( 3, j); + SHA512_STEP( 4, j); + SHA512_STEP( 5, j); + SHA512_STEP( 6, j); + SHA512_STEP( 7, j); + SHA512_STEP( 8, j); + SHA512_STEP( 9, j); + SHA512_STEP(10, j); + SHA512_STEP(11, j); + SHA512_STEP(12, j); + SHA512_STEP(13, j); + SHA512_STEP(14, j); + SHA512_STEP(15, j); + } + + /* update digest */ + digest[0] += v[0]; + digest[1] += v[1]; + digest[2] += v[2]; + digest[3] += v[3]; + digest[4] += v[4]; + digest[5] += v[5]; + digest[6] += v[6]; + digest[7] += v[7]; + } +} +#endif diff --git a/external/crypto_px/sources/ippcp/src/pcphmac.h b/external/crypto_px/sources/ippcp/src/pcphmac.h new file mode 100644 index 0000000000..5e55334339 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphmac.h @@ -0,0 +1,55 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_HMAC_H) +#define _PCP_HMAC_H + +#include "pcphash.h" + +/* +// HMAC context +*/ +struct _cpHMAC { + IppCtxId idCtx; /* HMAC identifier */ + Ipp8u ipadKey[MBS_HASH_MAX]; /* inner padding key */ + Ipp8u opadKey[MBS_HASH_MAX]; /* outer padding key */ + IppsHashState hashCtx; /* hash context */ +}; + +/* accessors */ +#define HMAC_CTX_ID(stt) ((stt)->idCtx) +#define HASH_CTX(stt) ((stt)->hashCtx) +#define HMAC_VALID_ID(stt) (HMAC_CTX_ID((stt))==idCtxHMAC) + +#define IPAD (0x36) /* inner padding value */ +#define OPAD (0x5C) /* outer padding value */ + +#endif /* _PCP_HMAC_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcphmacca.c b/external/crypto_px/sources/ippcp/src/pcphmacca.c new file mode 100644 index 0000000000..2c45b38291 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcphmacca.c @@ -0,0 +1,332 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphmac.h" +#include "pcptool.h" + +/*F* +// Name: ippsHMAC_GetSize +// +// Purpose: Returns size of HMAC state (bytes). +// +// Returns: Reason: +// ippStsNullPtrErr pSzie == NULL +// ippStsNoErr no errors +// +// Parameters: +// pSize pointer to the HMAC state size +// +*F*/ +IPPFUN(IppStatus, ippsHMAC_GetSize,(int* pSize)) +{ + /* test size's pointer */ + IPP_BAD_PTR1_RET(pSize); + + *pSize = sizeof(IppsHMACState); + return ippStsNoErr; +} + +/*F* +// Name: ippsHMAC_Init +// +// Purpose: Init HMAC state. +// +// Returns: Reason: +// ippStsNullPtrErr pKey == NULL +// pState == NULL +// ippStsLengthErr keyLen <0 +// ippStsNotSupportedModeErr if algID is not match to supported hash alg +// ippStsNoErr no errors +// +// Parameters: +// pKey pointer to the secret key +// keyLen length (bytes) of the secret key +// pState pointer to the HMAC state +// hashAlg hash alg ID +// +*F*/ +IPPFUN(IppStatus, ippsHMAC_Init,(const Ipp8u* pKey, int keyLen, IppsHMACState* pCtx, IppHashAlgId hashAlg)) +{ + //int mbs; + + /* get algorithm id */ + hashAlg = cpValidHashAlg(hashAlg); + /* test hash alg */ + IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr); + //mbs = cpHashMBS(hashAlg); + + /* test pState pointer */ + IPP_BAD_PTR1_RET(pCtx); + + /* test key pointer and key length */ + IPP_BAD_PTR1_RET(pKey); + IPP_BADARG_RET(0>keyLen, ippStsLengthErr); + + /* set state ID */ + HMAC_CTX_ID(pCtx) = idCtxHMAC; + + /* init hash context */ + ippsHashInit(&HASH_CTX(pCtx), hashAlg); + + { + int n; + + /* hash specific */ + IppsHashState* pHashCtx = &HASH_CTX(pCtx); + int mbs = cpHashMBS(hashAlg); + int hashSize = cpHashSize(hashAlg); + + /* copyMask = keyLen>mbs? 0xFF : 0x00 */ + int copyMask = (mbs-keyLen) >>(BITSIZE(int)-1); + + /* actualKeyLen = keyLen>mbs? hashSize:keyLen */ + int actualKeyLen = (hashSize & copyMask) | (keyLen & ~copyMask); + + /* compute hash(key, keyLen) just in case */ + ippsHashUpdate(pKey, keyLen, pHashCtx); + ippsHashFinal(HASH_BUFF(pHashCtx), pHashCtx); + + /* copy either key or hash(key) into ipad- and opad- buffers */ + MASKED_COPY_BNU(pCtx->ipadKey, (Ipp8u)copyMask, HASH_BUFF(pHashCtx), pKey, actualKeyLen); + MASKED_COPY_BNU(pCtx->opadKey, (Ipp8u)copyMask, HASH_BUFF(pHashCtx), pKey, actualKeyLen); + + /* XOR-ing key */ + for(n=0; nipadKey[n] ^= (Ipp8u)IPAD; + pCtx->opadKey[n] ^= (Ipp8u)OPAD; + } + for(; nipadKey[n] = (Ipp8u)IPAD; + pCtx->opadKey[n] = (Ipp8u)OPAD; + } + + /* ipad key processing */ + ippsHashUpdate(pCtx->ipadKey, mbs, pHashCtx); + + return ippStsNoErr; + } +} + +/*F* +// Name: ippsHMAC_Update +// +// Purpose: Updates intermadiate MAC based on input stream. +// +// Returns: Reason: +// ippStsNullPtrErr pSrc == NULL +// pState == NULL +// ippStsContextMatchErr pState->idCtx != idCtxHMAC +// ippStsLengthErr len <0 +// ippStsNoErr no errors +// +// Parameters: +// pSrc pointer to the input stream +// len input stream length +// pState pointer to the HMAC state +// +*F*/ +IPPFUN(IppStatus, ippsHMAC_Update,(const Ipp8u* pSrc, int len, IppsHMACState* pCtx)) +{ + /* test state pointers */ + IPP_BAD_PTR1_RET(pCtx); + + /* test state ID */ + IPP_BADARG_RET(!HMAC_VALID_ID(pCtx), ippStsContextMatchErr); + /* test input length */ + IPP_BADARG_RET((len<0), ippStsLengthErr); + /* test source pointer */ + IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr); + + if(len) + return ippsHashUpdate(pSrc, len, &HASH_CTX(pCtx)); + else + return ippStsNoErr; +} + +/*F* +// Name: ippsHMAC_Final +// +// Purpose: Stop message digesting and return digest. +// +// Returns: Reason: +// ippStsNullPtrErr pMD == NULL +// pState == NULL +// ippStsContextMatchErr pState->idCtx != idCtxHMAC +// ippStsLengthErr sizeof(DigestMD5) < mdLen <1 +// ippStsNoErr no errors +// +// Parameters: +// pMD address of the output digest +// pState pointer to the HMAC state +// +*F*/ +IPPFUN(IppStatus, ippsHMAC_Final,(Ipp8u* pMD, int mdLen, IppsHMACState* pCtx)) +{ + /* test state pointer and ID */ + IPP_BAD_PTR1_RET(pCtx); + IPP_BADARG_RET(!HMAC_VALID_ID(pCtx), ippStsContextMatchErr); + + /* test MD pointer and length */ + IPP_BAD_PTR1_RET(pMD); + IPP_BADARG_RET(mdLen<=0, ippStsLengthErr); + + { + /* hash specific */ + IppsHashState* pHashCtx = &HASH_CTX(pCtx); + int mbs = cpHashMBS(HASH_ALG_ID(pHashCtx)); + int hashSize = cpHashSize(HASH_ALG_ID(pHashCtx)); + if(mdLen>hashSize) + IPP_ERROR_RET(ippStsLengthErr); + + /* + // finalize hmac + */ + { + /* finalize 1-st step */ + Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/8]; + IppStatus sts = ippsHashFinal(md, pHashCtx); + + if(ippStsNoErr==sts) { + /* perform outer hash */ + ippsHashUpdate(pCtx->opadKey, mbs, pHashCtx); + ippsHashUpdate(md, hashSize, pHashCtx); + + /* complete HMAC */ + ippsHashFinal(md, pHashCtx); + CopyBlock(md, pMD, IPP_MIN(hashSize, mdLen)); + + /* ready to the next HMAC computation */ + ippsHashUpdate(pCtx->ipadKey, mbs, pHashCtx); + } + + return sts; + } + } +} + +/*F* +// Name: ippsHMAC_GetTag +// +// Purpose: Compute digest with further digesting ability. +// +// Returns: Reason: +// ippStsNullPtrErr pMD == NULL +// pState == NULL +// ippStsContextMatchErr pState->idCtx != idCtxHMAC +// ippStsLengthErr size_of_digest < mdLen <1 +// ippStsNoErr no errors +// +// Parameters: +// pMD address of the output digest +// mdLen length of the digest +// pState pointer to the HMAC state +// +*F*/ +IPPFUN(IppStatus, ippsHMAC_GetTag,(Ipp8u* pMD, int mdLen, const IppsHMACState* pCtx)) +{ + /* test state pointer and ID */ + IPP_BAD_PTR1_RET(pCtx); + IPP_BADARG_RET(!HMAC_VALID_ID(pCtx), ippStsContextMatchErr); + + /* test MD pointer */ + IPP_BAD_PTR1_RET(pMD); + + { + IppsHMACState tmpCtx; + CopyBlock(pCtx, &tmpCtx, sizeof(IppsHMACState)); + return ippsHMAC_Final(pMD, mdLen, &tmpCtx); + } +} + +/*F* +// Name: ippsHMAC_Message +// +// Purpose: MAC of the whole message. +// +// Returns: Reason: +// ippStsNullPtrErr pMsg == NULL +// pKey == NULL +// pMD == NULL +// ippStsLengthErr msgLen <0 +// keyLen <0 +// size_of_digest < mdLen <1 +// ippStsNotSupportedModeErr if algID is not match to supported hash alg +// ippStsNoErr no errors +// +// Parameters: +// pMsg pointer to the input message +// msgLen input message length +// pKey pointer to the secret key +// keyLen secret key length +// pMD pointer to message digest +// mdLen MD length +// hashAlg hash alg ID +// +*F*/ +IPPFUN(IppStatus, ippsHMAC_Message,(const Ipp8u* pMsg, int msgLen, + const Ipp8u* pKey, int keyLen, + Ipp8u* pMD, int mdLen, + IppHashAlgId hashAlg)) +{ + /* get algorithm id */ + hashAlg = cpValidHashAlg(hashAlg); + /* test hash alg */ + IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr); + + /* test secret key pointer and length */ + IPP_BAD_PTR1_RET(pKey); + IPP_BADARG_RET((keyLen<0), ippStsLengthErr); + + /* test input message pointer and length */ + IPP_BADARG_RET((msgLen<0), ippStsLengthErr); + IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr); + + /* test MD pointer and length */ + IPP_BAD_PTR1_RET(pMD); + IPP_BADARG_RET(0>=mdLen || mdLen>cpHashSize(hashAlg), ippStsLengthErr); + + { + IppsHMACState ctx; + IppStatus sts = ippsHMAC_Init(pKey, keyLen, &ctx, hashAlg); + if(ippStsNoErr!=sts) goto exit; + + sts = ippsHashUpdate(pMsg,msgLen, &HASH_CTX(&ctx)); + if(ippStsNoErr!=sts) goto exit; + + sts = ippsHMAC_Final(pMD, mdLen, &ctx); + + exit: + PurgeBlock(&ctx, sizeof(IppsHMACState)); + return sts; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpmontexpbinca.c b/external/crypto_px/sources/ippcp/src/pcpmontexpbinca.c new file mode 100644 index 0000000000..f7708ed648 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpmontexpbinca.c @@ -0,0 +1,116 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcpmontgomery.h" + + +/* +// Binary method of Exponentiation +*/ +cpSize cpMontExpBin_BNU(BNU_CHUNK_T* dataY, + const BNU_CHUNK_T* dataX, cpSize nsX, + const BNU_CHUNK_T* dataE, cpSize nsE, + IppsMontState* pMont) +{ + cpSize nsM = MNT_SIZE(pMont); + + /* + // test for special cases: + // x^0 = 1 + // 0^e = 0 + */ + if( cpEqu_BNU_CHUNK(dataE, nsE, 0) ) { + COPY_BNU(dataY, MNT_1(pMont), nsM); + } + else if( cpEqu_BNU_CHUNK(dataX, nsX, 0) ) { + ZEXPAND_BNU(dataY, 0, nsM); + } + + /* general case */ + else { + BNU_CHUNK_T* dataM = MNT_MODULUS(pMont); + BNU_CHUNK_T m0 = MNT_HELPER(pMont); + + /* Montgomery engine buffers */ + BNU_CHUNK_T* pKBuffer = MNT_KBUFFER(pMont); + BNU_CHUNK_T* pProduct = MNT_PRODUCT(pMont); + + BNU_CHUNK_T* dataT = MNT_TBUFFER(pMont); + + /* execute most significant part pE */ + BNU_CHUNK_T eValue = dataE[nsE-1]; + int n = cpNLZ_BNU(eValue)+1; + + /* expand base and init result */ + ZEXPAND_COPY_BNU(dataT, nsM, dataX, nsX); + COPY_BNU(dataY, dataT, nsM); + + eValue <<= n; + for(; n0; nsE--) { + eValue = dataE[nsE-1]; + + for(n=0; nidCtx) +#define MNT_ROOM(eng) ((eng)->maxLen) +#define MNT_SIZE(eng) ((eng)->modLen) +#define MNT_HELPER(eng) ((eng)->m0) +#define MNT_MODULUS(eng) ((eng)->pModulus) +#define MNT_1(eng) ((eng)->pIdentity) +#define MNT_IDENT_R(eng) (MNT_1((eng))) +#define MNT_SQUARE_R(eng) ((eng)->pSquare) +#define MNT_CUBE_R(eng) ((eng)->pCube) +#define MNT_TBUFFER(eng) ((eng)->pTBuffer) +#define MNT_SBUFFER(eng) ((eng)->pSBuffer) +#define MNT_PRODUCT(eng) ((eng)->pProduct) +#define MNT_KBUFFER(eng) ((eng)->pKBuffer) + +#define MNT_VALID_ID(eng) (MNT_ID((eng))==idCtxMontgomery) + +/* default methos */ +#define EXPONENT_METHOD (ippBinaryMethod) + +/* alignment */ +#define MONT_ALIGNMENT ((int)(sizeof(void*))) + + +/* +// Pacp/unpack Montgomery context +*/ +void cpPackMontCtx(const IppsMontState* pCtx, Ipp8u* pBuffer); +void cpUnpackMontCtx(const Ipp8u* pBuffer, IppsMontState* pCtx); + + +/* +// Montgomery reduction, multiplication and squaring +*/ +void cpMontRedAdc_BNU(BNU_CHUNK_T* pR, + BNU_CHUNK_T* pProduct, + const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0); + +__INLINE void cpMontRed_BNU(BNU_CHUNK_T* pR, + BNU_CHUNK_T* pProduct, + const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0) +{ + cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0); +} + +__INLINE void cpMontMul_BNU(BNU_CHUNK_T* pR, + const BNU_CHUNK_T* pX, cpSize nsX, + const BNU_CHUNK_T* pY, cpSize nsY, + const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0, + BNU_CHUNK_T* pProduct, BNU_CHUNK_T* pKBuffer) +{ + cpMul_BNU(pProduct, pX,nsX, pY,nsY, pKBuffer); + ZEXPAND_BNU(pProduct,nsX+nsY, 2*nsM); + cpMontRed_BNU(pR, pProduct, pModulus, nsM, m0); +} + +__INLINE void cpMontSqr_BNU(BNU_CHUNK_T* pR, + const BNU_CHUNK_T* pX, cpSize nsX, + const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0, + BNU_CHUNK_T* pProduct, BNU_CHUNK_T* pKBuffer) +{ + cpSqr_BNU(pProduct, pX,nsX, pKBuffer); + ZEXPAND_BNU(pProduct, 2*nsX, 2*nsM); + cpMontRed_BNU(pR, pProduct, pModulus, nsM, m0); +} + +/* +// Montgomery encoding/decoding +*/ +__INLINE cpSize cpMontEnc_BNU(BNU_CHUNK_T* pR, + const BNU_CHUNK_T* pXreg, cpSize nsX, + IppsMontState* pMont) +{ + cpSize nsM = MNT_SIZE(pMont); + cpMontMul_BNU(pR, + pXreg, nsX, MNT_SQUARE_R(pMont), nsM, + MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont), + MNT_PRODUCT(pMont), MNT_KBUFFER(pMont)); + + FIX_BNU(pR, nsM); + return nsM; +} + +__INLINE cpSize cpMontDec_BNU(BNU_CHUNK_T* pR, + const BNU_CHUNK_T* pXmont, cpSize nsX, + IppsMontState* pMont) +{ + cpSize nsM = MNT_SIZE(pMont); + ZEXPAND_COPY_BNU(MNT_PRODUCT(pMont), 2*nsM, pXmont, nsX); + + cpMontRed_BNU(pR, MNT_PRODUCT(pMont), MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont)); + + FIX_BNU(pR, nsM); + return nsM; +} + +__INLINE void cpMontEnc_BN(IppsBigNumState* pRbn, + const IppsBigNumState* pXbn, + IppsMontState* pMont) +{ + BNU_CHUNK_T* pR = BN_NUMBER(pRbn); + cpSize nsM = MNT_SIZE(pMont); + cpMontMul_BNU(pR, + BN_NUMBER(pXbn), BN_SIZE(pXbn), + MNT_SQUARE_R(pMont), nsM, + MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont), + MNT_PRODUCT(pMont), MNT_KBUFFER(pMont)); + + FIX_BNU(pR, nsM); + BN_SIZE(pRbn) = nsM; + BN_SIGN(pRbn) = ippBigNumPOS; +} + +__INLINE void cpMontDec_BN(IppsBigNumState* pRbn, + const IppsBigNumState* pXbn, + IppsMontState* pMont) +{ + BNU_CHUNK_T* pR = BN_NUMBER(pRbn); + cpSize nsM = MNT_SIZE(pMont); + ZEXPAND_COPY_BNU(MNT_PRODUCT(pMont), 2*nsM, BN_NUMBER(pXbn), BN_SIZE(pXbn)); + + cpMontRed_BNU(pR, MNT_PRODUCT(pMont), MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont)); + + FIX_BNU(pR, nsM); + BN_SIZE(pRbn) = nsM; + BN_SIGN(pRbn) = ippBigNumPOS; +} + +/* +// Montgomery exponentiation (binary) +*/ +cpSize cpMontExpBin_BNU(BNU_CHUNK_T* pY, + const BNU_CHUNK_T* pX, cpSize nsX, + const BNU_CHUNK_T* pE, cpSize nsE, + IppsMontState* pMont); + +#endif /* _CP_MONTGOMETRY_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpmontgomeryca.c b/external/crypto_px/sources/ippcp/src/pcpmontgomeryca.c new file mode 100644 index 0000000000..f82147cfb2 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpmontgomeryca.c @@ -0,0 +1,296 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcpmontgomery.h" +#include "pcptool.h" + +/*F* +// Name: ippsMontGetSize +// +// Purpose: Specifies size of buffer in bytes. +// +// Returns: Reason: +// ippStsNullPtrErr pCtxSize==NULL +// ippStsLengthErr maxLen32 < 1 +// maxLen32 > BITS2WORD32_SIZE(BN_MAXBITSIZE) +// ippStsNoErr no errors +// +// Parameters: +// method selected exponential method (unused parameter) +// maxLen32 max modulus length (in Ipp32u chunks) +// pCtxSize size of context +// +// Notes: Function always use method=ippBinaryMethod, +// so this parameter is ignored +*F*/ +IPPFUN(IppStatus, ippsMontGetSize, (IppsExpMethod method, cpSize maxLen32, cpSize* pCtxSize)) +{ + IPP_BAD_PTR1_RET(pCtxSize); + IPP_BADARG_RET(maxLen32<1 || maxLen32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr); + + UNREFERENCED_PARAMETER(method); + + { + /* convert modulus length to the number of BNU_CHUNK_T */ + cpSize modSize = INTERNAL_BNU_LENGTH(maxLen32); + + *pCtxSize= sizeof(IppsMontState) + + modSize*sizeof(BNU_CHUNK_T) /* modulus */ + + modSize*sizeof(BNU_CHUNK_T) /* identity */ + + modSize*sizeof(BNU_CHUNK_T) /* square R */ + + modSize*sizeof(BNU_CHUNK_T) /* cube R */ + + modSize*sizeof(BNU_CHUNK_T) /* internal buffer */ + + modSize*sizeof(BNU_CHUNK_T) /* internal sscm buffer */ + + modSize*sizeof(BNU_CHUNK_T)*2 /* internal product */ + + MONT_ALIGNMENT-1; + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsMontInit +// +// Purpose: Initializes the symbolic data structure and partitions the +// specified buffer space. +// +// Returns: Reason: +// ippStsNullPtrErr pMont==NULL +// ippStsLengthErr maxLen32 < 1 +// maxLen32 > BITS2WORD32_SIZE(BN_MAXBITSIZE) +// ippStsNoErr no errors +// +// Parameters: +// method selected exponential method (unused parameter) +// maxLen32 max modulus length (in Ipp32u chunks) +// pMont pointer to Montgomery context +*F*/ +IPPFUN(IppStatus, ippsMontInit,(IppsExpMethod method, int maxLen32, IppsMontState* pMont)) +{ + IPP_BADARG_RET(maxLen32<1 || maxLen32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr); + + IPP_BAD_PTR1_RET(pMont); + pMont = (IppsMontState*)( IPP_ALIGNED_PTR(pMont, MONT_ALIGNMENT) ); + + UNREFERENCED_PARAMETER(method); + + MNT_ID(pMont) = idCtxUnknown; + MNT_ROOM(pMont) = INTERNAL_BNU_LENGTH(maxLen32); + MNT_SIZE(pMont) = 0; + MNT_HELPER(pMont) = 0; + + { + Ipp8u* ptr = (Ipp8u*)pMont; + + /* convert modulus length to the number of BNU_CHUNK_T */ + cpSize modSize = MNT_ROOM(pMont); + + /* assign internal buffers */ + MNT_MODULUS(pMont) = (BNU_CHUNK_T*)( ptr += sizeof(IppsMontState) ); + + MNT_1(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) ); + MNT_SQUARE_R(pMont)= (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) ); + MNT_CUBE_R(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) ); + + MNT_TBUFFER(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) ); + MNT_SBUFFER(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) ); + MNT_PRODUCT(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) ); + MNT_KBUFFER(pMont) = (BNU_CHUNK_T*)NULL; + + /* init internal buffers */ + ZEXPAND_BNU(MNT_MODULUS(pMont), 0, modSize); + ZEXPAND_BNU(MNT_1(pMont), 0, modSize); + ZEXPAND_BNU(MNT_SQUARE_R(pMont), 0, modSize); + ZEXPAND_BNU(MNT_CUBE_R(pMont), 0, modSize); + + MNT_ID(pMont) = idCtxMontgomery; + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsMontSet +// +// Purpose: Setup modulus value +// +// Returns: Reason: +// ippStsNullPtrErr pMont==NULL +// pModulus==NULL +// ippStsContextMatchErr !MNT_VALID_ID() +// ippStsLengthErr len32<1 +// ippStsNoErr no errors +// +// Parameters: +// pModulus pointer to the modulus buffer +// len32 length of the modulus (in Ipp32u chunks). +// pMont pointer to the context +*F*/ +static BNU_CHUNK_T cpMontHelper(BNU_CHUNK_T m0) +{ + BNU_CHUNK_T y = 1; + BNU_CHUNK_T x = 2; + BNU_CHUNK_T mask = 2*x-1; + + int i; + for(i=2; i<=BNU_CHUNK_BITS; i++, x<<=1) { + BNU_CHUNK_T rH, rL; + MUL_AB(rH, rL, m0, y); + if( x < (rL & mask) ) /* x < ((m0*y) mod (2*x)) */ + y+=x; + mask += mask + 1; + } + return 0-y; +} + +IPPFUN(IppStatus, ippsMontSet,(const Ipp32u* pModulus, cpSize len32, IppsMontState* pMont)) +{ + IPP_BAD_PTR2_RET(pModulus, pMont); + pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT)); + IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr); + + IPP_BADARG_RET(len32<1, ippStsLengthErr); + + /* modulus is not an odd number */ + IPP_BADARG_RET((pModulus[0] & 1) == 0, ippStsBadModulusErr); + IPP_BADARG_RET(MNT_ROOM(pMont)<(int)(INTERNAL_BNU_LENGTH(len32)), ippStsOutOfRangeErr); + + { + BNU_CHUNK_T m0; + cpSize len; + + /* fix input modulus */ + FIX_BNU(pModulus, len32); + + /* store modulus */ + ZEXPAND_BNU(MNT_MODULUS(pMont), 0, MNT_ROOM(pMont)); + COPY_BNU((Ipp32u*)(MNT_MODULUS(pMont)), pModulus, len32); + /* store modulus length */ + len = INTERNAL_BNU_LENGTH(len32); + MNT_SIZE(pMont) = len; + + /* pre-compute helper m0, m0*m = -1 mod R */ + m0 = cpMontHelper(MNT_MODULUS(pMont)[0]); + MNT_HELPER(pMont) = m0; + + /* setup identity */ + ZEXPAND_BNU(MNT_1(pMont), 0, len); + MNT_1(pMont)[len] = 1; + cpMod_BNU(MNT_1(pMont), len+1, MNT_MODULUS(pMont), len); + + /* setup square */ + ZEXPAND_BNU(MNT_SQUARE_R(pMont), 0, len); + COPY_BNU(MNT_SQUARE_R(pMont)+len, MNT_1(pMont), len); + cpMod_BNU(MNT_SQUARE_R(pMont), 2*len, MNT_MODULUS(pMont), len); + + /* setup cube */ + ZEXPAND_BNU(MNT_CUBE_R(pMont), 0, len); + COPY_BNU(MNT_CUBE_R(pMont)+len, MNT_SQUARE_R(pMont), len); + cpMod_BNU(MNT_CUBE_R(pMont), 2*len, MNT_MODULUS(pMont), len); + + /* clear buffers */ + ZEXPAND_BNU(MNT_TBUFFER(pMont), 0, len); + ZEXPAND_BNU(MNT_SBUFFER(pMont), 0, len); + ZEXPAND_BNU(MNT_PRODUCT(pMont), 0, 2*len); + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsMontMul +// +// Purpose: Computes Montgomery modular multiplication for positive big +// number integers of Montgomery form. The following pseudocode +// represents this function: +// r <- ( a * b * R^(-1) ) mod m +// +// Returns: Reason: +// ippStsNoErr Returns no error. +// ippStsNullPtrErr Returns an error when pointers are null. +// ippStsBadArgErr Returns an error when a or b is a negative integer. +// ippStsScaleRangeErr Returns an error when a or b is more than m. +// ippStsOutOfRangeErr Returns an error when IppsBigNumState *r is larger than +// IppsMontState *m. +// ippStsContextMatchErr Returns an error when the context parameter does +// not match the operation. +// +// Parameters: +// a Multiplicand within the range [0, m - 1]. +// b Multiplier within the range [0, m - 1]. +// m Modulus. +// r Montgomery multiplication result. +// +// Notes: The size of IppsBigNumState *r should not be less than the data +// length of the modulus m. +*F*/ +IPPFUN(IppStatus, ippsMontMul, (const IppsBigNumState* pA, const IppsBigNumState* pB, IppsMontState* pMont, IppsBigNumState* pR)) +{ + IPP_BAD_PTR4_RET(pA, pB, pMont, pR); + + pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT)); + pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); + pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) ); + pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) ); + + IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr); + IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr); + + IPP_BADARG_RET(BN_NEGATIVE(pA) || BN_NEGATIVE(pB), ippStsBadArgErr); + IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MNT_MODULUS(pMont), MNT_SIZE(pMont)) >= 0, ippStsScaleRangeErr); + IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pB), BN_SIZE(pB), MNT_MODULUS(pMont), MNT_SIZE(pMont)) >= 0, ippStsScaleRangeErr); + IPP_BADARG_RET(BN_ROOM(pR) < MNT_SIZE(pMont), ippStsOutOfRangeErr); + + { + BNU_CHUNK_T* pDataR = BN_NUMBER(pR); + cpSize nsM = MNT_SIZE(pMont); + + cpMontMul_BNU(pDataR, + BN_NUMBER(pA), BN_SIZE(pA), + BN_NUMBER(pB), BN_SIZE(pB), + MNT_MODULUS(pMont), nsM, + MNT_HELPER(pMont), + MNT_PRODUCT(pMont), MNT_KBUFFER(pMont)); + + FIX_BNU(pDataR, nsM); + BN_SIZE(pR) = nsM; + BN_SIGN(pR) = ippBigNumPOS; + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpmontred.c b/external/crypto_px/sources/ippcp/src/pcpmontred.c new file mode 100644 index 0000000000..b43dce71f9 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpmontred.c @@ -0,0 +1,64 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owncp.h" +#include "pcpbnuarith.h" + + +void cpMontRedAdc_BNU(BNU_CHUNK_T* pR, + BNU_CHUNK_T* pProduct, + const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0) +{ + BNU_CHUNK_T carry; + BNU_CHUNK_T extension; + + cpSize n; + for(n=0, carry = 0; n<(nsM-1); n++) { + BNU_CHUNK_T u = pProduct[n]*m0; + BNU_CHUNK_T t = pProduct[nsM +n +1] + carry; + + extension = cpAddMulDgt_BNU(pProduct+n, pModulus, nsM, u); + ADD_AB(carry, pProduct[nsM+n], pProduct[nsM+n], extension); + t += carry; + + carry = tmaxbitSizeN) +#define RSA_PUB_KEY_MAXSIZE_E(x) ((x)->maxbitSizeE) +#define RSA_PUB_KEY_ID(x) ((x)->id) +#define RSA_PUB_KEY_BITSIZE_N(x) ((x)->bitSizeN) +#define RSA_PUB_KEY_BITSIZE_E(x) ((x)->bitSizeE) +#define RSA_PUB_KEY_E(x) ((x)->pDataE) +#define RSA_PUB_KEY_NMONT(x) ((x)->pMontN) +#define RSA_PUB_KEY_VALID_ID(x) (RSA_PUB_KEY_ID((x))==idCtxRSA_PubKey) +#define RSA_PUB_KEY_IS_SET(x) (RSA_PUB_KEY_BITSIZE_N((x))>0) + +/* alignment */ +#define RSA_PUBLIC_KEY_ALIGNMENT ((int)(sizeof(void*))) + +struct _cpRSA_private_key { + IppCtxId id; /* key ID */ + int maxbitSizeN; + int maxbitSizeD; + int bitSizeN; /* RSA modulus bitsize */ + int bitSizeD; /* RSA private exp bitsize */ + int bitSizeP; /* RSA p-factor bitsize */ + int bitSizeQ; /* RSA q-factor bitsize */ + + BNU_CHUNK_T* pDataD; /* private exp */ + BNU_CHUNK_T* pDataDp; /* dp private exp */ + BNU_CHUNK_T* pDataDq; /* dq private exp */ + BNU_CHUNK_T* pDataQinv; /* qinv coeff */ + + IppsMontState* pMontP; /* montgomery engine (P) */ + IppsMontState* pMontQ; /* montgomery engine (Q) */ + IppsMontState* pMontN; /* montgomery engine (N) */ +}; + +/* access */ +#define RSA_PRV_KEY_MAXSIZE_N(x) ((x)->maxbitSizeN) +#define RSA_PRV_KEY_MAXSIZE_D(x) ((x)->maxbitSizeD) +#define RSA_PRV_KEY_ID(x) ((x)->id) +#define RSA_PRV_KEY_BITSIZE_N(x) ((x)->bitSizeN) +#define RSA_PRV_KEY_BITSIZE_D(x) ((x)->bitSizeD) +#define RSA_PRV_KEY_BITSIZE_P(x) ((x)->bitSizeP) +#define RSA_PRV_KEY_BITSIZE_Q(x) ((x)->bitSizeQ) +#define RSA_PRV_KEY_D(x) ((x)->pDataD) +#define RSA_PRV_KEY_DP(x) ((x)->pDataDp) +#define RSA_PRV_KEY_DQ(x) ((x)->pDataDq) +#define RSA_PRV_KEY_INVQ(x) ((x)->pDataQinv) +#define RSA_PRV_KEY_PMONT(x) ((x)->pMontP) +#define RSA_PRV_KEY_QMONT(x) ((x)->pMontQ) +#define RSA_PRV_KEY_NMONT(x) ((x)->pMontN) +#define RSA_PRV_KEY1_VALID_ID(x) (RSA_PRV_KEY_ID((x))==idCtxRSA_PrvKey1) +#define RSA_PRV_KEY2_VALID_ID(x) (RSA_PRV_KEY_ID((x))==idCtxRSA_PrvKey2) +#define RSA_PRV_KEY_VALID_ID(x) (RSA_PRV_KEY1_VALID_ID((x)) || RSA_PRV_KEY2_VALID_ID((x))) +#define RSA_PRV_KEY_IS_SET(x) (RSA_PRV_KEY_BITSIZE_N((x))>0) + +/* alignment */ +#define RSA_PRIVATE_KEY_ALIGNMENT ((int)(sizeof(void*))) + +/* pubic and private key operations */ +void gsRSApub_cipher(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPublicKeyState* pKey, BNU_CHUNK_T* pScratchBuffer); +void gsRSAprv_cipher(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPrivateKeyState* pKey, BNU_CHUNK_T* pScratchBuffer); +void gsRSAprv_cipher_crt(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPrivateKeyState* pKey, BNU_CHUNK_T* pScratchBuffer); + +#endif /* _CP_NG_RSA_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpngrsaencodec.c b/external/crypto_px/sources/ippcp/src/pcpngrsaencodec.c new file mode 100644 index 0000000000..ccf2a855a6 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpngrsaencodec.c @@ -0,0 +1,437 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcpngrsa.h" +#include "pcpngrsamontstuff.h" + + +/*F* +// Name: ippsRSA_GetBufferSizePublicKey +// +// Purpose: Returns size of temporary buffer (in bytes) for public key operation +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pKey +// NULL == pBufferSize +// +// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID() +// +// ippStsIncompleteContextErr no ippsRSA_SetPublicKey() call +// +// ippStsNoErr no error +// +// Parameters: +// pBufferSize pointer to size of temporary buffer +// pKey pointer to the key context +*F*/ +IPPFUN(IppStatus, ippsRSA_GetBufferSizePublicKey,(int* pBufferSize, const IppsRSAPublicKeyState* pKey)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr); + + IPP_BAD_PTR1_RET(pBufferSize); + + { + cpSize expBitSize = RSA_PUB_KEY_BITSIZE_E(pKey); + cpSize w = gsMontExp_WinSize(expBitSize); + cpSize precompLen = (1==w)? 0 : (1<1) + // temporary product (2) + */ + cpSize bufferLen = ((nsM+1)*2)*2 + +precompLen*nsM + +nsM + +nsM*2; + + *pBufferSize = bufferLen*sizeof(BNU_CHUNK_T) + + sizeof(BNU_CHUNK_T)-1 + + (CACHE_LINE_SIZE-1); + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsRSA_GetBufferSizePublicKey +// +// Purpose: Returns size of temporary buffer (in bytes) for public key operation +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pKey +// NULL == pBufferSize +// +// ippStsContextMatchErr !RSA_PRV_KEY_VALID_ID() +// +// ippStsIncompleteContextErr (type1) private key is not set up +// +// ippStsNoErr no error +// +// Parameters: +// pBufferSize pointer to size of temporary buffer +// pKey pointer to the key context +*F*/ +IPPFUN(IppStatus, ippsRSA_GetBufferSizePrivateKey,(int* pBufferSize, const IppsRSAPrivateKeyState* pKey)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PRV_KEY_VALID_ID(pKey), ippStsContextMatchErr); + IPP_BADARG_RET(RSA_PRV_KEY1_VALID_ID(pKey) && !RSA_PRV_KEY_IS_SET(pKey), ippStsIncompleteContextErr); + + IPP_BAD_PTR1_RET(pBufferSize); + + { + cpSize bufferLen; + if(RSA_PRV_KEY1_VALID_ID(pKey)) { + cpSize expBitSize = RSA_PRV_KEY_BITSIZE_D(pKey); + cpSize w = gsMontExp_WinSize(expBitSize); + cpSize precompLen = (1==w)? 0 : (1<1) + // temporary product (2) + */ + bufferLen = ((nsN+1)*2)*2 + +gsPrecompResourcelen(precompLen,nsN) //+precompLen*nsN + +nsN + +nsN + +nsN*2; + } + else { + cpSize expBitSize = IPP_MAX(RSA_PRV_KEY_BITSIZE_P(pKey), RSA_PRV_KEY_BITSIZE_Q(pKey)); + cpSize w = gsMontExp_WinSize(expBitSize); + cpSize precompLen = (1==w)? 0 : (1<1) + // recoure to keep "masked" multipler (x|1) (1), (w=1) + // or resource to keep zero-extended power e (1), (w>1) + // temporary product (2) + */ + bufferLen = ((nsP*2+1)*2)*2 + +gsPrecompResourcelen(precompLen, nsP) //+precompLen*nsP + +nsP + +nsP + +nsP*2; + bufferLen = IPP_MAX( IPP_MAX(validationBufferLen,generationBufferLen), bufferLen ); + } + *pBufferSize = bufferLen*sizeof(BNU_CHUNK_T) + + sizeof(BNU_CHUNK_T)-1 + + (CACHE_LINE_SIZE-1); + return ippStsNoErr; + } +} + + + +void gsRSApub_cipher(IppsBigNumState* pY, + const IppsBigNumState* pX, + const IppsRSAPublicKeyState* pKey, + BNU_CHUNK_T* pScratchBuffer) +{ + IppsMontState* pMontN = RSA_PUB_KEY_NMONT(pKey); + gsMontEnc_BN(pY, pX, pMontN, pScratchBuffer); + + { + /* optimal size of window */ + BNU_CHUNK_T* pExp = RSA_PUB_KEY_E(pKey); + cpSize nsExp = BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_E(pKey)); + cpSize w = gsMontExp_WinSize(RSA_PUB_KEY_BITSIZE_E(pKey)); + + if(1==w) + gsMontExpBin_BN(pY, pY, pExp, nsExp, pMontN, pScratchBuffer); + else + gsMontExpWin_BN(pY, pY, pExp, nsExp, w, pMontN, pScratchBuffer); + } + + gsMontDec_BN(pY, pY, pMontN, pScratchBuffer); +} + + +/*F* +// Name: ippsRSA_Encrypt +// +// Purpose: Performs RSA Encryprion +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pKey +// NULL == pPtxt +// NULL == pCtxt +// NULL == pBuffer +// +// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID() +// !BN_VALID_ID(pPtxt) +// !BN_VALID_ID(pCtxt) +// +// ippStsIncompleteContextErr public key is not setup +// +// ippStsOutOfRangeErr pPtxt >= modulus +// pPtxt <0 +// +// ippStsSizeErr BN_ROOM(pCtxt) is not enough +// +// ippStsNoErr no error +// +// Parameters: +// pPtxt pointer to the plaintext +// pCtxt pointer to the ciphertext +// pKey pointer to the key context +// pScratchBuffer pointer to the temporary buffer +*F*/ +IPPFUN(IppStatus, ippsRSA_Encrypt,(const IppsBigNumState* pPtxt, + IppsBigNumState* pCtxt, + const IppsRSAPublicKeyState* pKey, + Ipp8u* pScratchBuffer)) +{ + IPP_BAD_PTR2_RET(pKey, pScratchBuffer); + pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr); + + IPP_BAD_PTR1_RET(pPtxt); + pPtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPtxt, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pPtxt), ippStsContextMatchErr); + IPP_BADARG_RET(BN_NEGATIVE(pPtxt), ippStsOutOfRangeErr); + IPP_BADARG_RET(0 <= cpCmp_BNU(BN_NUMBER(pPtxt), BN_SIZE(pPtxt), + MNT_MODULUS(RSA_PUB_KEY_NMONT(pKey)), MNT_SIZE(RSA_PUB_KEY_NMONT(pKey))), ippStsOutOfRangeErr); + + IPP_BAD_PTR1_RET(pCtxt); + pCtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCtxt, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pCtxt), ippStsContextMatchErr); + IPP_BADARG_RET(BN_ROOM(pCtxt) < BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_N(pKey)), ippStsSizeErr); + + gsRSApub_cipher(pCtxt, + pPtxt, + pKey, + (BNU_CHUNK_T*)(IPP_ALIGNED_PTR((pScratchBuffer), (int)sizeof(BNU_CHUNK_T))) ); + return ippStsNoErr; +} + + + +void gsRSAprv_cipher(IppsBigNumState* pY, + const IppsBigNumState* pX, + const IppsRSAPrivateKeyState* pKey, + BNU_CHUNK_T* pScratchBuffer) +{ + IppsMontState* pMontN = RSA_PRV_KEY_NMONT(pKey); + gsMontEnc_BN(pY, pX, pMontN, pScratchBuffer); + + { + /* optimal size of window */ + BNU_CHUNK_T* pExp = RSA_PRV_KEY_D(pKey); + cpSize nsExp = BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_D(pKey)); + cpSize w = gsMontExp_WinSize(RSA_PRV_KEY_BITSIZE_D(pKey)); + + if(1==w) + gsMontExpBin_BN_sscm(pY, pY, pExp, nsExp, pMontN, pScratchBuffer); + else + gsMontExpWin_BN_sscm(pY, pY, pExp, nsExp, w, pMontN, pScratchBuffer); + } + + gsMontDec_BN(pY, pY, pMontN, pScratchBuffer); +} + +void gsRSAprv_cipher_crt(IppsBigNumState* pY, + const IppsBigNumState* pX, + const IppsRSAPrivateKeyState* pKey, + BNU_CHUNK_T* pScratchBuffer) +{ + /* P- and Q- montgometry engines */ + IppsMontState* pMontP = RSA_PRV_KEY_PMONT(pKey); + IppsMontState* pMontQ = RSA_PRV_KEY_QMONT(pKey); + cpSize nsP = MNT_SIZE(pMontP); + cpSize nsQ = MNT_SIZE(pMontQ); + + const BNU_CHUNK_T* dataX = BN_NUMBER(pX); + cpSize nsX = BN_SIZE(pX); + BNU_CHUNK_T* dataXp = BN_NUMBER(pY); + BNU_CHUNK_T* dataXq = BN_BUFFER(pY); + + cpSize bitSizeDP = BITSIZE_BNU(RSA_PRV_KEY_DP(pKey), nsP); + cpSize bitSizeDQ = BITSIZE_BNU(RSA_PRV_KEY_DQ(pKey), nsQ); + cpSize w; + BNU_CHUNK_T cf; + + /* compute xq = x^dQ mod Q */ + COPY_BNU(dataXq, dataX, nsX); + cpMod_BNU(dataXq, nsX, MNT_MODULUS(pMontQ), nsQ); + gsMontEnc_BNU(dataXq, dataXq, nsQ, pMontQ, pScratchBuffer); + w = gsMontExp_WinSize(bitSizeDQ); + + if(1==w) + gsMontExpBin_BNU_sscm(dataXq, + dataXq, nsQ, + RSA_PRV_KEY_DQ(pKey), BITS_BNU_CHUNK(bitSizeDQ), + pMontQ, pScratchBuffer); + else + gsMontExpWin_BNU_sscm(dataXq, + dataXq, nsQ, + RSA_PRV_KEY_DQ(pKey), BITS_BNU_CHUNK(bitSizeDQ), w, + pMontQ, pScratchBuffer); + + gsMontDec_BNU(dataXq, dataXq, nsQ, pMontQ, pScratchBuffer); + + /* compute xp = x^dP mod P */ + COPY_BNU(dataXp, dataX, nsX); + cpMod_BNU(dataXp, nsX, MNT_MODULUS(pMontP), nsP); + gsMontEnc_BNU(dataXp, dataXp, nsP, pMontP, pScratchBuffer); + w = gsMontExp_WinSize(bitSizeDP); + + if(1==w) + gsMontExpBin_BNU_sscm(dataXp, + dataXp, nsP, + RSA_PRV_KEY_DP(pKey), BITS_BNU_CHUNK(bitSizeDP), + pMontP, pScratchBuffer); + else + gsMontExpWin_BNU_sscm(dataXp, + dataXp, nsP, + RSA_PRV_KEY_DP(pKey), BITS_BNU_CHUNK(bitSizeDP), w, + pMontP, pScratchBuffer); + + gsMontDec_BNU(dataXp, dataXp, nsP, pMontP, pScratchBuffer); + + /* xp -= xq */ + cf = cpSub_BNU(dataXp, dataXp, dataXq, nsQ); + if(nsP-nsQ) + cf = cpDec_BNU(dataXp+nsQ, dataXp+nsQ, (nsP-nsQ), cf); + if(cf) + cpAdd_BNU(dataXp, dataXp, MNT_MODULUS(pMontP), nsP); + + /* xp = xp*qInv mod P */ + cpMontMul_BNU(dataXp, + dataXp, nsP, + RSA_PRV_KEY_INVQ(pKey), nsP, + MNT_MODULUS(pMontP), nsP, MNT_HELPER(pMontP), + pScratchBuffer, NULL); + + /* Y = xq + xp*Q */ + cpMul_BNU_school(pScratchBuffer, + dataXp, nsP, + MNT_MODULUS(pMontQ), nsQ); + cf = cpAdd_BNU(BN_NUMBER(pY), pScratchBuffer, dataXq, nsQ); + cpInc_BNU(BN_NUMBER(pY)+nsQ, pScratchBuffer+nsQ, nsP, cf); + + nsX = nsP+nsQ; + FIX_BNU(BN_NUMBER(pY), nsX); + BN_SIZE(pY) = nsX; + BN_SIGN(pY) = ippBigNumPOS; +} + +/*F* +// Name: ippsRSA_Decrypt +// +// Purpose: Performs RSA Decryprion +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pKey +// NULL == pCtxt +// NULL == pPtxt +// NULL == pBuffer +// +// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID() +// !BN_VALID_ID(pCtxt) +// !BN_VALID_ID(pPtxt) +// +// ippStsIncompleteContextErr private key is not set up +// +// ippStsOutOfRangeErr pCtxt >= modulus +// pCtxt <0 +// +// ippStsSizeErr BN_ROOM(pPtxt) is not enough +// +// ippStsNoErr no error +// +// Parameters: +// pCtxt pointer to the ciphertext +// pPtxt pointer to the plaintext +// pKey pointer to the key context +// pScratchBuffer pointer to the temporary buffer +*F*/ +IPPFUN(IppStatus, ippsRSA_Decrypt,(const IppsBigNumState* pCtxt, + IppsBigNumState* pPtxt, + const IppsRSAPrivateKeyState* pKey, + Ipp8u* pScratchBuffer)) +{ + IPP_BAD_PTR2_RET(pKey, pScratchBuffer); + pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PRV_KEY_VALID_ID(pKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pKey), ippStsIncompleteContextErr); + + IPP_BAD_PTR1_RET(pCtxt); + pCtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCtxt, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pCtxt), ippStsContextMatchErr); + IPP_BADARG_RET(BN_NEGATIVE(pCtxt), ippStsOutOfRangeErr); + IPP_BADARG_RET(0 <= cpCmp_BNU(BN_NUMBER(pCtxt), BN_SIZE(pCtxt), + MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey)), MNT_SIZE(RSA_PRV_KEY_NMONT(pKey))), ippStsOutOfRangeErr); + + IPP_BAD_PTR1_RET(pPtxt); + pPtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPtxt, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pPtxt), ippStsContextMatchErr); + IPP_BADARG_RET(BN_ROOM(pPtxt) < BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_N(pKey)), ippStsSizeErr); + + if(RSA_PRV_KEY1_VALID_ID(pKey)) + gsRSAprv_cipher(pPtxt, + pCtxt, + pKey, + (BNU_CHUNK_T*)(IPP_ALIGNED_PTR((pScratchBuffer), (int)sizeof(BNU_CHUNK_T))) ); + else + gsRSAprv_cipher_crt(pPtxt, + pCtxt, + pKey, + (BNU_CHUNK_T*)(IPP_ALIGNED_PTR((pScratchBuffer), (int)sizeof(BNU_CHUNK_T))) ); + return ippStsNoErr; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpngrsaesoaepca.c b/external/crypto_px/sources/ippcp/src/pcpngrsaesoaepca.c new file mode 100644 index 0000000000..22b8917f67 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpngrsaesoaepca.c @@ -0,0 +1,176 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcptool.h" +#include "pcpngrsa.h" +#include "pcphash.h" + + +/*F* +// Name: ippsRSAEncrypt_OAEP +// +// Purpose: Performs RSAES-OAEP encryprion scheme +// +// Returns: Reason: +// ippStsNotSupportedModeErr unknown hashAlg +// +// ippStsNullPtrErr NULL == pKey +// NULL == pSrc +// NULL == pDst +// NULL == pLabel +// NULL == pSeed +// NULL == pBuffer +// +// ippStsLengthErr srcLen <0 +// labLen <0 +// srcLen > RSAsize -2*hashLen -2 +// RSAsize < 2*hashLen +2 +// +// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID() +// +// ippStsIncompleteContextErr public key is not set up +// +// ippStsNoErr no error +// +// Parameters: +// pSrc pointer to the plaintext +// srcLen plaintext length (bytes) +// pLabel (optional) pointer to the label associated with plaintext +// labLen label length (bytes) +// pSeed seed string of hashLen size +// pDst pointer to the ciphertext (length of pdst is not less then size of RSA modulus) +// pKey pointer to the RSA public key context +// hashAlg hash alg ID +// pBuffer pointer to scratch buffer +*F*/ +IPPFUN(IppStatus, ippsRSAEncrypt_OAEP,(const Ipp8u* pSrc, int srcLen, + const Ipp8u* pLabel, int labLen, + const Ipp8u* pSeed, + Ipp8u* pDst, + const IppsRSAPublicKeyState* pKey, + IppHashAlgId hashAlg, + Ipp8u* pBuffer)) +{ + int hashLen; + + /* test hash algorith ID */ + hashAlg = cpValidHashAlg(hashAlg); + IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr); + + /* test data pointer */ + IPP_BAD_PTR3_RET(pSrc,pDst, pSeed); + + IPP_BADARG_RET(!pLabel && labLen, ippStsNullPtrErr); + + /* test public key context */ + IPP_BAD_PTR2_RET(pKey, pBuffer); + pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr); + + /* test length */ + IPP_BADARG_RET(srcLen<0||labLen<0, ippStsLengthErr); + + hashLen = cpHashSize(hashAlg); + /* test compatibility of RSA and hash length */ + IPP_BADARG_RET(BITS2WORD8_SIZE(RSA_PRV_KEY_BITSIZE_N(pKey)) < (2*hashLen +2), ippStsLengthErr); + /* test compatibility of msg length and other (RSA and hash) lengths */ + IPP_BADARG_RET(BITS2WORD8_SIZE(RSA_PRV_KEY_BITSIZE_N(pKey))-(2*hashLen +2) < srcLen, ippStsLengthErr); + + { + /* size of RSA modulus in bytes and chunks */ + int k = BITS2WORD8_SIZE(RSA_PUB_KEY_BITSIZE_N(pKey)); + cpSize nsN = BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_N(pKey)); + + /* + // EME-OAEP encoding + */ + { + Ipp8u seedMask[BITS2WORD8_SIZE(IPP_SHA512_DIGEST_BITSIZE)]; + + Ipp8u* pMaskedSeed = pDst+1; + Ipp8u* pMaskedDB = pDst +hashLen +1; + + pDst[0] = 0; + + /* maskedDB = MGF(seed, k-1-hashLen)*/ + ippsMGF(pSeed, hashLen, pMaskedDB, k-1-hashLen, hashAlg); + + /* seedMask = HASH(pLab) */ + ippsHashMessage(pLabel, labLen, seedMask, hashAlg); + + /* maskedDB ^= concat(HASH(pLab),PS,0x01,pSc) */ + XorBlock(pMaskedDB, seedMask, pMaskedDB, hashLen); + pMaskedDB[k-srcLen-hashLen-2] ^= 0x01; + XorBlock(pMaskedDB+k-srcLen-hashLen-2+1, pSrc, pMaskedDB+k-srcLen-hashLen-2+1, srcLen); + + /* seedMask = MGF(maskedDB, hashLen) */ + ippsMGF(pMaskedDB, k-1-hashLen, seedMask, hashLen, hashAlg); + /* maskedSeed = seed ^ seedMask */ + XorBlock(pSeed, seedMask, pMaskedSeed, hashLen); + } + + /* RSA encryption */ + { + /* align buffer */ + BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T)) ); + + /* temporary BN */ + __ALIGN8 IppsBigNumState tmpBN; + BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &tmpBN); + + /* updtae buffer pointer */ + pScratchBuffer += (nsN+1)*2; + + ippsSetOctString_BN(pDst, k, &tmpBN); + + gsRSApub_cipher(&tmpBN, &tmpBN, pKey, pScratchBuffer); + + ippsGetOctString_BN(pDst, k, &tmpBN); + } + + return ippStsNoErr; + } +} + + +IPPFUN(IppStatus, ippsRSA_OAEPEncrypt_SHA256,(const Ipp8u* pSrc, int srcLen, + const Ipp8u* pLabel, int labLen, + const Ipp8u* pSeed, + Ipp8u* pDst, + const IppsRSAPublicKeyState* pKey, + Ipp8u* pBuffer)) +{ return ippsRSAEncrypt_OAEP(pSrc,srcLen, pLabel,labLen, pSeed, + pDst, pKey, + IPP_ALG_HASH_SHA256, + pBuffer); } diff --git a/external/crypto_px/sources/ippcp/src/pcpngrsagenerate.c b/external/crypto_px/sources/ippcp/src/pcpngrsagenerate.c new file mode 100644 index 0000000000..e942bed1a5 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpngrsagenerate.c @@ -0,0 +1,323 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcpprimeg.h" +#include "pcpngrsa.h" +#include "pcpngrsamontstuff.h" + +/*F* +// Name: ippsRSA_ValidateKeys +// +// Purpose: Validate RSA keys +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pPublicKey +// NULL == pPrivateKeyType2 +// NULL == pPrivateKeyType1 +// NULL == pBuffer +// NULL == pPrimeGen +// NULL == rndFunc +// NULL == pResult +// +// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID(pPublicKey) +// !RSA_PRV_KEY2_VALID_ID(pPrivateKeyType2) +// !RSA_PRV_KEY1_VALID_ID(pPrivateKeyType1) +// !PRIME_VALID_ID(pPrimeGen) +// +// ippStsIncompleteContextErr public and.or private key is not set up +// +// ippStsSizeErr PRIME_MAXBITSIZE(pPrimeGen) < factorPbitSize +// +// ippStsBadArgErr nTrials < 1 +// +// ippStsNoErr no error +// +// Parameters: +// pResult pointer to the validation result +// pPublicKey pointer to the public key context +// pPrivateKeyType2 pointer to the private key type2 context +// pPrivateKeyType1 (optional) pointer to the private key type1 context +// pBuffer pointer to the temporary buffer +// nTrials parameter of Miller-Rabin Test +// pPrimeGen pointer to the Prime generator context +// rndFunc external PRNG +// pRndParam pointer to the external PRNG parameters +*F*/ +/* +// make sure D*E = 1 mod(phi(P,Q)) +// where phi(P,Q) = (P-1)*(Q-1) +*/ +static +int isValidPriv1_classic(const BNU_CHUNK_T* pN, int nsN, + const BNU_CHUNK_T* pE, int nsE, + const BNU_CHUNK_T* pD, int nsD, + const BNU_CHUNK_T* pFactorP, int nsP, + const BNU_CHUNK_T* pFactorQ, int nsQ, + BNU_CHUNK_T* pBuffer) +{ + BNU_CHUNK_T* pPhi = pBuffer; + BNU_CHUNK_T* pProduct = pPhi + nsN; + BNU_CHUNK_T c = cpSub_BNU(pPhi, pN, pFactorP, nsP); + int prodLen; + if(nsN>1) cpDec_BNU(pPhi+nsP, pN+nsP, nsQ, c); + c = cpSub_BNU(pPhi,pPhi, pFactorQ, nsQ); + if(nsN>1) cpDec_BNU(pPhi+nsQ, pPhi+nsQ, nsP, c); + cpInc_BNU(pPhi, pPhi, nsP+nsQ, 1); + + cpMul_BNU_school(pProduct, pE, nsE, pD, nsD); + prodLen = cpMod_BNU(pProduct, nsE+nsD, pPhi, nsN); + + return 1==cpEqu_BNU_CHUNK(pProduct, prodLen, 1)? IPP_IS_VALID : IPP_IS_INVALID; +} + +/* +// make sure D*E = 1 mod(lcm(P-1,Q-1)) +// where lcm(P-1,Q-1) = (P-1)*(Q-1)/gcd(P-1,Q-1) +*/ +static +int isValidPriv1_rsa(const BNU_CHUNK_T* pN, int nsN, + const BNU_CHUNK_T* pE, int nsE, + const BNU_CHUNK_T* pD, int nsD, + BNU_CHUNK_T* pFactorP, int nsP, + BNU_CHUNK_T* pFactorQ, int nsQ, + BNU_CHUNK_T* pBuffer) +{ + __ALIGN8 IppsBigNumState tmpBN1; + __ALIGN8 IppsBigNumState tmpBN2; + __ALIGN8 IppsBigNumState tmpBN3; + + BNU_CHUNK_T* pProduct = pBuffer; + BNU_CHUNK_T* pGcd = pProduct+(nsN+1); + BNU_CHUNK_T* pLcm; + int nsLcm; + int prodLen; + pBuffer = pGcd + (nsP+1)*2; + + /* P = P-1 and Q = Q-1 */ + pFactorP[0]--; + pFactorQ[0]--; + + /* compute product (P-1)*(Q-1) = P*Q -P -Q +1 = N -(P-1) -(Q-1) -1 */ + { + BNU_CHUNK_T c = cpSub_BNU(pProduct, pN, pFactorP, nsP); + if(nsN>1) cpDec_BNU(pProduct+nsP, pN+nsP, nsQ, c); + c = cpSub_BNU(pProduct, pProduct, pFactorQ, nsQ); + if(nsN>1) cpDec_BNU(pProduct+nsQ, pProduct+nsQ, nsP, c); + cpDec_BNU(pProduct, pProduct, nsN, 1); + } + + /* compute gcd(p-1, q-1) */ + BN_Make(pGcd, pGcd+nsP+1, nsP, &tmpBN1); /* BN(gcd) */ + BN_SIZE(&tmpBN1) = nsP; + BN_Make(pFactorP, pBuffer, nsP, &tmpBN2); /* BN(P-1) */ + BN_SIZE(&tmpBN2) = nsP; + BN_Make(pFactorQ, pBuffer+nsP+1, nsQ, &tmpBN3); /* BN(Q-1) */ + BN_SIZE(&tmpBN3) = nsQ; + ippsGcd_BN(&tmpBN2, &tmpBN3, &tmpBN1); + + /* compute lcm(p-1, q-1) = (p-1)(q-1)/gcd(p-1, q-1) */ + pLcm = pBuffer; + cpDiv_BNU(pLcm, &nsLcm, pProduct, nsN, pGcd, BN_SIZE(&tmpBN1)); + + /* test E*D = 1 mod lcm */ + cpMul_BNU_school(pProduct, pE, nsE, pD, nsD); + prodLen = cpMod_BNU(pProduct, nsE+nsD, pLcm, nsLcm); + + /* restore P and Q */ + pFactorP[0]++; + pFactorQ[0]++; + + return 1==cpEqu_BNU_CHUNK(pProduct, prodLen, 1)? IPP_IS_VALID : IPP_IS_INVALID; +} + +IPPFUN(IppStatus, ippsRSA_ValidateKeys,(int* pResult, + const IppsRSAPublicKeyState* pPublicKey, + const IppsRSAPrivateKeyState* pPrivateKeyType2, + const IppsRSAPrivateKeyState* pPrivateKeyType1, /*optional */ + Ipp8u* pBuffer, + int nTrials, + IppsPrimeState* pPrimeGen, + IppBitSupplier rndFunc, void* pRndParam)) +{ + IPP_BAD_PTR1_RET(pPublicKey); + pPublicKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pPublicKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pPublicKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pPublicKey), ippStsIncompleteContextErr); + + IPP_BAD_PTR1_RET(pPrivateKeyType2); + pPrivateKeyType2 = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pPrivateKeyType2, RSA_PRIVATE_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PRV_KEY2_VALID_ID(pPrivateKeyType2), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pPrivateKeyType2), ippStsIncompleteContextErr); + + if(pPrivateKeyType1) { /* pPrivateKeyType1 is optional */ + pPrivateKeyType1 = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pPrivateKeyType1, RSA_PRIVATE_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PRV_KEY1_VALID_ID(pPrivateKeyType1), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pPrivateKeyType1), ippStsIncompleteContextErr); + } + + IPP_BAD_PTR1_RET(pPrimeGen); + pPrimeGen = (IppsPrimeState*)( IPP_ALIGNED_PTR(pPrimeGen, PRIME_ALIGNMENT) ); + IPP_BADARG_RET(!PRIME_VALID_ID(pPrimeGen), ippStsContextMatchErr); + IPP_BADARG_RET(PRIME_MAXBITSIZE(pPrimeGen) < RSA_PRV_KEY_BITSIZE_P(pPrivateKeyType2), ippStsSizeErr); + + IPP_BAD_PTR3_RET(pResult, pBuffer, rndFunc); + + /* test security parameter parameter */ + IPP_BADARG_RET((1>nTrials), ippStsBadArgErr); + + { + BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T))); + + /* E key component */ + BNU_CHUNK_T* pExpE = RSA_PUB_KEY_E(pPublicKey); + cpSize nsE = BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_E(pPublicKey)); + /* P, dP, invQ key components */ + BNU_CHUNK_T* pFactorP= MNT_MODULUS(RSA_PRV_KEY_PMONT(pPrivateKeyType2)); + BNU_CHUNK_T* pExpDp = RSA_PRV_KEY_DP(pPrivateKeyType2); + BNU_CHUNK_T* pInvQ = RSA_PRV_KEY_INVQ(pPrivateKeyType2); + cpSize nsP = MNT_SIZE(RSA_PRV_KEY_PMONT(pPrivateKeyType2)); + /* Q, dQ key components */ + BNU_CHUNK_T* pFactorQ= MNT_MODULUS(RSA_PRV_KEY_QMONT(pPrivateKeyType2)); + BNU_CHUNK_T* pExpDq = RSA_PRV_KEY_DQ(pPrivateKeyType2); + cpSize nsQ = MNT_SIZE(RSA_PRV_KEY_QMONT(pPrivateKeyType2)); + + /*const*/ BNU_CHUNK_T* pN0 = MNT_MODULUS(RSA_PUB_KEY_NMONT(pPublicKey)); + cpSize nsN = MNT_SIZE(RSA_PUB_KEY_NMONT(pPublicKey)); + + *pResult = IPP_IS_VALID; + + /* make sure P is prime */ + if(!cpPrimeTest(pFactorP, nsP, nTrials, pPrimeGen, rndFunc, pRndParam)) { + *pResult = IPP_IS_COMPOSITE; + return ippStsNoErr; + } + + /* make sure Q is prime */ + if(!cpPrimeTest(pFactorQ, nsQ, nTrials, pPrimeGen, rndFunc, pRndParam)) { + *pResult = IPP_IS_COMPOSITE; + return ippStsNoErr; + } + + /* make sure PubKey(N)==PrivKeytype2(N) and PubKey(N)==PrivKeytype1(N) */ + if(cpCmp_BNU(pN0, nsN, + MNT_MODULUS(RSA_PRV_KEY_NMONT(pPrivateKeyType2)), MNT_SIZE(RSA_PRV_KEY_NMONT(pPrivateKeyType2)))) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + if(pPrivateKeyType1) { + if(cpCmp_BNU(pN0, nsN, + MNT_MODULUS(RSA_PRV_KEY_NMONT(pPrivateKeyType1)), MNT_SIZE(RSA_PRV_KEY_NMONT(pPrivateKeyType1)))) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + } + + /* make sure 3 <= E < N */ + if(1==nsE && pExpE[0]<3) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + if(0 <= cpCmp_BNU(pExpE, nsE, pN0, nsN)) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + + { + BNU_CHUNK_T* pFactor1 = pScratchBuffer; + BNU_CHUNK_T* pInv = pFactor1 +nsP+1; + BNU_CHUNK_T* pBufInv = pInv +nsP+1; + BNU_CHUNK_T* pBufE = pBufInv +nsP+1; + BNU_CHUNK_T* pBufFact = pBufE +nsP+1; + BNU_CHUNK_T* pProduct = pBufInv; + + /* make sure E*dP = 1 mod (P-1) */ + cpDec_BNU(pFactor1, pFactorP, nsP, 1); + cpMul_BNU_school(pProduct, pExpDp, nsP, pExpE, nsE); + cpMod_BNU(pProduct, nsP+nsE, pFactor1, nsP); + if(!cpEqu_BNU_CHUNK(pProduct, nsP, 1)) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + /* make sure 1==GCD(E,P-1) => exist Inv(E,P-1) */ + if(!cpModInv_BNU(pInv, pExpE, nsE, pFactor1, nsP, pBufInv, pBufE, pBufFact)) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + + /* make sure E*dQ = 1 mod (Q-1) */ + cpDec_BNU(pFactor1, pFactorQ, nsQ, 1); + cpMul_BNU_school(pProduct, pExpDq, nsQ, pExpE, nsE); + cpMod_BNU(pProduct, nsQ+nsE, pFactor1, nsQ); + if(!cpEqu_BNU_CHUNK(pProduct, nsQ, 1)) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + /* make sure 1==GCD(E,Q-1) => exist Inv(E,Q-1) */ + if(!cpModInv_BNU(pInv, pExpE, nsE, pFactor1, nsQ, pBufInv, pBufE, pBufFact)) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + } + + /* make sure Q*Qinv = 1 mod P */ + cpMontMul_BNU(pScratchBuffer, + pFactorQ, nsQ, + pInvQ, nsP, + pFactorP, nsP, MNT_HELPER(RSA_PRV_KEY_PMONT(pPrivateKeyType2)), + pScratchBuffer+nsP, NULL); + if(!cpEqu_BNU_CHUNK(pScratchBuffer, nsP, 1)) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + + /* test priva exponent (optiobal) */ + if(pPrivateKeyType1) { + const BNU_CHUNK_T* pExpD = RSA_PRV_KEY_D(pPrivateKeyType1); + cpSize nsD = nsN; + + int resilt1 = isValidPriv1_classic(pN0,nsN, pExpE,nsE, pExpD,nsD, + pFactorP,nsP, pFactorQ,nsQ, + (BNU_CHUNK_T*)pScratchBuffer); + int resilt2 = isValidPriv1_rsa(pN0,nsN, pExpE,nsE, pExpD,nsD, + pFactorP,nsP, pFactorQ,nsQ, + (BNU_CHUNK_T*)pScratchBuffer); + if(IPP_IS_VALID!=resilt1 && IPP_IS_VALID!=resilt2) { + *pResult = IPP_IS_INVALID; + return ippStsNoErr; + } + } + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpngrsakeyprivate.c b/external/crypto_px/sources/ippcp/src/pcpngrsakeyprivate.c new file mode 100644 index 0000000000..f038522c4d --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpngrsakeyprivate.c @@ -0,0 +1,496 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcpngrsa.h" +#include "pcpngrsamontstuff.h" + +/*F* +// Name: ippsRSA_GetSizePrivateKeyType1 +// +// Purpose: Returns context size (bytes) of RSA private key (type1) context +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pSize +// +// ippStsNotSupportedModeErr MIN_RSA_SIZE > rsaModulusBitSize +// MAX_RSA_SIZE < rsaModulusBitSize +// +// ippStsBadArgErr 0 >= privateExpBitSize +// privateExpBitSize > rsaModulusBitSize +// +// ippStsNoErr no error +// +// Parameters: +// rsaModulusBitSize bitsize of RSA modulus (bitsize of N) +// privateExpBitSize bitsize of private exponent (bitsize of D) +// pSize pointer to the size of RSA key context (bytes) +*F*/ +static int cpSizeof_RSA_privateKey1(int rsaModulusBitSize, int privateExpBitSize) +{ + int prvExpLen = BITS_BNU_CHUNK(privateExpBitSize); + int modulusLen32 = BITS2WORD32_SIZE(rsaModulusBitSize); + int montNsize; + gsMontGetSize(ippBinaryMethod, modulusLen32, &montNsize); + + return sizeof(IppsRSAPrivateKeyState) + + prvExpLen*sizeof(BNU_CHUNK_T) + + sizeof(BNU_CHUNK_T)-1 + + montNsize + + (RSA_PRIVATE_KEY_ALIGNMENT-1); +} + +IPPFUN(IppStatus, ippsRSA_GetSizePrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize, int* pKeySize)) +{ + IPP_BAD_PTR1_RET(pKeySize); + IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr); + IPP_BADARG_RET(!((0 rsaModulusBitSize +// MAX_RSA_SIZE < rsaModulusBitSize +// +// ippStsBadArgErr 0 >= privateExpBitSize +// privateExpBitSize > rsaModulusBitSize +// +// ippStsMemAllocErr keyCtxSize is not enough for operation +// +// ippStsNoErr no error +// +// Parameters: +// rsaModulusBitSize bitsize of RSA modulus (bitsize of N) +// privateExpBitSize bitsize of private exponent (bitsize of D) +// pKey pointer to the key context +// keyCtxSize size of memmory accosizted with key comtext +*F*/ +IPPFUN(IppStatus, ippsRSA_InitPrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize, + IppsRSAPrivateKeyState* pKey, int keyCtxSize)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) ); + + IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr); + IPP_BADARG_RET(!((0= pModulus +// 0 >= pPrivateExp +// +// ippStsSizeErr bitsize(pModulus) exceeds requested value +// bitsize(pPrivateExp) exceeds requested value +// +// ippStsNoErr no error +// +// Parameters: +// pModulus pointer to modulus (N) +// pPrivateExp pointer to public exponent (D) +// pKey pointer to the key context +*F*/ +IPPFUN(IppStatus, ippsRSA_SetPrivateKeyType1,(const IppsBigNumState* pModulus, + const IppsBigNumState* pPrivateExp, + IppsRSAPrivateKeyState* pKey)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PRV_KEY1_VALID_ID(pKey), ippStsContextMatchErr); + + IPP_BAD_PTR1_RET(pModulus); + pModulus = (IppsBigNumState*)( IPP_ALIGNED_PTR(pModulus, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pModulus), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pModulus)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pModulus), BN_SIZE(pModulus)) > RSA_PRV_KEY_MAXSIZE_N(pKey), ippStsSizeErr); + + IPP_BAD_PTR1_RET(pPrivateExp); + pPrivateExp = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateExp, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pPrivateExp), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pPrivateExp)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPrivateExp), BN_SIZE(pPrivateExp)) > RSA_PRV_KEY_MAXSIZE_D(pKey), ippStsSizeErr); + + { + /* store D */ + ZEXPAND_COPY_BNU(RSA_PRV_KEY_D(pKey), BITS_BNU_CHUNK(RSA_PRV_KEY_MAXSIZE_D(pKey)), BN_NUMBER(pPrivateExp), BN_SIZE(pPrivateExp)); + + /* setup montgomery engine */ + gsMontSet((Ipp32u*)BN_NUMBER(pModulus), BN_SIZE32(pModulus), RSA_PRV_KEY_NMONT(pKey)); + + RSA_PRV_KEY_BITSIZE_N(pKey) = cpBN_bitsize(pModulus); + RSA_PRV_KEY_BITSIZE_D(pKey) = cpBN_bitsize(pPrivateExp); + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsRSA_GetSizePrivateKeyType2 +// +// Purpose: Returns context size (bytes) of RSA private key (type2) context +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pSize +// +// ippStsNotSupportedModeErr MIN_RSA_SIZE > (factorPbitSize+factorQbitSize) +// MAX_RSA_SIZE < (factorPbitSize+factorQbitSize) +// +// ippStsBadArgErr 0 >= factorPbitSize +// 0 >= factorQbitSize +// factorQbitSize > factorPbitSize +// +// ippStsNoErr no error +// +// Parameters: +// factorPbitSize bitsize of RSA modulus (bitsize of P) +// factorPbitSize bitsize of private exponent (bitsize of Q) +// pSize pointer to the size of RSA key context (bytes) +*F*/ +static int cpSizeof_RSA_privateKey2(int factorPbitSize, int factorQbitSize) +{ + int factorPlen = BITS_BNU_CHUNK(factorPbitSize); + int factorQlen = BITS_BNU_CHUNK(factorQbitSize); + int factorPlen32 = BITS2WORD32_SIZE(factorPbitSize); + int factorQlen32 = BITS2WORD32_SIZE(factorQbitSize); + int rsaModulusLen32 = BITS2WORD32_SIZE(factorPbitSize+factorQbitSize); + int montPsize; + int montQsize; + int montNsize; + gsMontGetSize(ippBinaryMethod, factorPlen32, &montPsize); + gsMontGetSize(ippBinaryMethod, factorQlen32, &montQsize); + gsMontGetSize(ippBinaryMethod, rsaModulusLen32, &montNsize); + + return sizeof(IppsRSAPrivateKeyState) + + factorPlen*sizeof(BNU_CHUNK_T) /* dp slot */ + + factorQlen*sizeof(BNU_CHUNK_T) /* dq slot */ + + factorPlen*sizeof(BNU_CHUNK_T) /* qinv slot */ + + sizeof(BNU_CHUNK_T)-1 + + montPsize + + montQsize + + montNsize + + (RSA_PRIVATE_KEY_ALIGNMENT-1); +} + +IPPFUN(IppStatus, ippsRSA_GetSizePrivateKeyType2,(int factorPbitSize, int factorQbitSize, int* pKeySize)) +{ + IPP_BAD_PTR1_RET(pKeySize); + IPP_BADARG_RET((factorPbitSize<=0) || (factorQbitSize<=0), ippStsBadArgErr); + IPP_BADARG_RET((factorPbitSize < factorQbitSize), ippStsBadArgErr); + IPP_BADARG_RET((MIN_RSA_SIZE>(factorPbitSize+factorQbitSize) || (factorPbitSize+factorQbitSize)>MAX_RSA_SIZE), ippStsNotSupportedModeErr); + + *pKeySize = cpSizeof_RSA_privateKey2(factorPbitSize, factorQbitSize); + return ippStsNoErr; +} + + +/*F* +// Name: ippsRSA_InitPrivateKeyType2 +// +// Purpose: Init RSA private key context +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pKey +// +// ippStsNotSupportedModeErr MIN_RSA_SIZE > (factorPbitSize+factorQbitSize) +// MAX_RSA_SIZE < (factorPbitSize+factorQbitSize) +// +// ippStsBadArgErr 0 >= factorPbitSize +// 0 >= factorQbitSize +// factorQbitSize > factorPbitSize +// +// ippStsMemAllocErr keyCtxSize is not enough for operation +// +// ippStsNoErr no error +// +// Parameters: +// factorPbitSize bitsize of RSA modulus (bitsize of P) +// factorQbitSize bitsize of private exponent (bitsize of Q) +// pKey pointer to the key context +// keyCtxSize size of memmory accosizted with key comtext +*F*/ +IPPFUN(IppStatus, ippsRSA_InitPrivateKeyType2,(int factorPbitSize, int factorQbitSize, + IppsRSAPrivateKeyState* pKey, int keyCtxSize)) +{ + IPP_BAD_PTR1_RET(pKey); + IPP_BADARG_RET((factorPbitSize<=0) || (factorQbitSize<=0), ippStsBadArgErr); + IPP_BADARG_RET((factorPbitSize < factorQbitSize), ippStsBadArgErr); + IPP_BADARG_RET((MIN_RSA_SIZE>(factorPbitSize+factorQbitSize) || (factorPbitSize+factorQbitSize)>MAX_RSA_SIZE), ippStsNotSupportedModeErr); + + /* test available size of context buffer */ + IPP_BADARG_RET(keyCtxSize= pFactorP, 0 >= pFactorQ +// 0 >= pCrtExpP, 0 >= pCrtExpQ +// 0 >= pInverseQ +// +// ippStsSizeErr bitsize(pFactorP) exceeds requested value +// bitsize(pFactorQ) exceeds requested value +// bitsize(pCrtExpP) > bitsize(pFactorP) +// bitsize(pCrtExpQ) > bitsize(pFactorQ) +// bitsize(pInverseQ) > bitsize(pFactorP) +// +// ippStsNoErr no error +// +// Parameters: +// pFactorP, pFactorQ pointer to the RSA modulus (N) prime factors +// pCrtExpP, pCrtExpQ pointer to CTR's exponent +// pInverseQ 1/Q mod P +// pKey pointer to the key context +*F*/ +IPPFUN(IppStatus, ippsRSA_SetPrivateKeyType2,(const IppsBigNumState* pFactorP, + const IppsBigNumState* pFactorQ, + const IppsBigNumState* pCrtExpP, + const IppsBigNumState* pCrtExpQ, + const IppsBigNumState* pInverseQ, + IppsRSAPrivateKeyState* pKey)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PRV_KEY2_VALID_ID(pKey), ippStsContextMatchErr); + + IPP_BAD_PTR1_RET(pFactorP); + pFactorP = (IppsBigNumState*)( IPP_ALIGNED_PTR(pFactorP, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pFactorP), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pFactorP)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pFactorP), BN_SIZE(pFactorP)) > RSA_PRV_KEY_BITSIZE_P(pKey), ippStsSizeErr); + + IPP_BAD_PTR1_RET(pFactorQ); + pFactorQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pFactorQ, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pFactorQ), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pFactorQ)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pFactorQ), BN_SIZE(pFactorQ)) > RSA_PRV_KEY_BITSIZE_Q(pKey), ippStsSizeErr); + + /* let P>Q */ + IPP_BADARG_RET(0>=cpBN_cmp(pFactorP,pFactorQ), ippStsBadArgErr); + + IPP_BAD_PTR1_RET(pCrtExpP); + pCrtExpP = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCrtExpP, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pCrtExpP), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pCrtExpP)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pCrtExpP), BN_SIZE(pCrtExpP)) > RSA_PRV_KEY_BITSIZE_P(pKey), ippStsSizeErr); + + IPP_BAD_PTR1_RET(pCrtExpQ); + pCrtExpQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCrtExpQ, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pCrtExpQ), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pCrtExpQ)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pCrtExpQ), BN_SIZE(pCrtExpQ)) > RSA_PRV_KEY_BITSIZE_Q(pKey), ippStsSizeErr); + + IPP_BAD_PTR1_RET(pInverseQ); + pInverseQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pInverseQ, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pInverseQ), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pInverseQ)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pInverseQ), BN_SIZE(pInverseQ)) > RSA_PRV_KEY_BITSIZE_P(pKey), ippStsSizeErr); + + /* set bitsize(N) = 0, so the key contex is not ready */ + RSA_PRV_KEY_BITSIZE_N(pKey) = 0; + RSA_PRV_KEY_BITSIZE_D(pKey) = 0; + + /* setup montgomery engine P */ + gsMontSet((Ipp32u*)BN_NUMBER(pFactorP), BN_SIZE32(pFactorP), RSA_PRV_KEY_PMONT(pKey)); + /* setup montgomery engine Q */ + gsMontSet((Ipp32u*)BN_NUMBER(pFactorQ), BN_SIZE32(pFactorQ), RSA_PRV_KEY_QMONT(pKey)); + + /* actual size of key components */ + RSA_PRV_KEY_BITSIZE_P(pKey) = cpBN_bitsize(pFactorP); + RSA_PRV_KEY_BITSIZE_Q(pKey) = cpBN_bitsize(pFactorQ); + + /* store CTR's exp dp */ + ZEXPAND_COPY_BNU(RSA_PRV_KEY_DP(pKey), BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_P(pKey)), BN_NUMBER(pCrtExpP), BN_SIZE(pCrtExpP)); + /* store CTR's exp dq */ + ZEXPAND_COPY_BNU(RSA_PRV_KEY_DQ(pKey), BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_Q(pKey)), BN_NUMBER(pCrtExpQ), BN_SIZE(pCrtExpQ)); + /* store mont encoded CTR's coeff qinv */ + { + IppsMontState* pMontP = RSA_PRV_KEY_PMONT(pKey); + BNU_CHUNK_T* pTmpProduct = MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey)); + cpMontMul_BNU(RSA_PRV_KEY_INVQ(pKey), + BN_NUMBER(pInverseQ), BN_SIZE(pInverseQ), + MNT_SQUARE_R(pMontP), MNT_SIZE(pMontP), + MNT_MODULUS(pMontP), MNT_SIZE(pMontP), MNT_HELPER(pMontP), + pTmpProduct, NULL); + } + + /* setup montgomery engine N = P*Q */ + { + BNU_CHUNK_T* pN = MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey)); + cpSize nsN = BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_P(pKey) + RSA_PRV_KEY_BITSIZE_Q(pKey)); + + cpMul_BNU_school(pN, + BN_NUMBER(pFactorP), BN_SIZE(pFactorP), + BN_NUMBER(pFactorQ), BN_SIZE(pFactorQ)); + + gsMontSet((Ipp32u*)MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey)), BITS2WORD32_SIZE(RSA_PRV_KEY_BITSIZE_P(pKey)+RSA_PRV_KEY_BITSIZE_Q(pKey)), RSA_PRV_KEY_NMONT(pKey)); + + FIX_BNU(pN, nsN); + RSA_PRV_KEY_BITSIZE_N(pKey) = BITSIZE_BNU(pN, nsN); + } + + return ippStsNoErr; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpngrsakeypublic.c b/external/crypto_px/sources/ippcp/src/pcpngrsakeypublic.c new file mode 100644 index 0000000000..48ca2be853 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpngrsakeypublic.c @@ -0,0 +1,272 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcpbn.h" +#include "pcpngrsa.h" +#include "pcpngrsamontstuff.h" + + +/*F* +// Name: ippsRSA_GetSizePublicKey +// +// Purpose: Returns context size (bytes) of RSA public key context +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pSize +// +// ippStsNotSupportedModeErr MIN_RSA_SIZE > rsaModulusBitSize +// MAX_RSA_SIZE < rsaModulusBitSize +// +// ippStsBadArgErr 0 >= publicExpBitSize +// publicExpBitSize > rsaModulusBitSize +// +// ippStsNoErr no error +// +// Parameters: +// rsaModulusBitSize bitsize of RSA modulus (bitsize of N) +// publicExpBitSize bitsize of public exponent (bitsize of E) +// pSize pointer to the size of RSA key context (bytes) +*F*/ +static int cpSizeof_RSA_publicKey(int rsaModulusBitSize, int publicExpBitSize) +{ + int pubExpLen = BITS_BNU_CHUNK(publicExpBitSize); + int modulusLen32 = BITS2WORD32_SIZE(rsaModulusBitSize); + int montNsize; + gsMontGetSize(ippBinaryMethod, modulusLen32, &montNsize); + + return sizeof(IppsRSAPublicKeyState) + + pubExpLen*sizeof(BNU_CHUNK_T) + + sizeof(BNU_CHUNK_T)-1 + + montNsize + + (RSA_PUBLIC_KEY_ALIGNMENT-1); +} + +IPPFUN(IppStatus, ippsRSA_GetSizePublicKey,(int rsaModulusBitSize, int publicExpBitSize, int* pKeySize)) +{ + IPP_BAD_PTR1_RET(pKeySize); + IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr); + IPP_BADARG_RET(!((0 rsaModulusBitSize +// MAX_RSA_SIZE < rsaModulusBitSize +// +// ippStsBadArgErr 0 >= publicExpBitSize +// publicExpBitSize > rsaModulusBitSize +// +// ippStsMemAllocErr keyCtxSize is not enough for operation +// +// ippStsNoErr no error +// +// Parameters: +// rsaModulusBitSize bitsize of RSA modulus (bitsize of N) +// publicExpBitSize bitsize of public exponent (bitsize of E) +// pKey pointer to the key context +// keyCtxSize size of memmory accosizted with key comtext +*F*/ +IPPFUN(IppStatus, ippsRSA_InitPublicKey,(int rsaModulusBitSize, int publicExpBitSize, + IppsRSAPublicKeyState* pKey, int keyCtxSize)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + + IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr); + IPP_BADARG_RET(!((0= pModulus +// 0 >= pPublicExp +// +// ippStsSizeErr bitsize(pModulus) exceeds requested value +// bitsize(pPublicExp) exceeds requested value +// +// ippStsNoErr no error +// +// Parameters: +// pModulus pointer to modulus (N) +// pPublicExp pointer to public exponent (E) +// pKey pointer to the key context +*F*/ +IPPFUN(IppStatus, ippsRSA_SetPublicKey,(const IppsBigNumState* pModulus, + const IppsBigNumState* pPublicExp, + IppsRSAPublicKeyState* pKey)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr); + + IPP_BAD_PTR1_RET(pModulus); + pModulus = (IppsBigNumState*)( IPP_ALIGNED_PTR(pModulus, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pModulus), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pModulus)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pModulus), BN_SIZE(pModulus)) > RSA_PUB_KEY_MAXSIZE_N(pKey), ippStsSizeErr); + + IPP_BAD_PTR1_RET(pPublicExp); + pPublicExp = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPublicExp, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pPublicExp), ippStsContextMatchErr); + IPP_BADARG_RET(!(0 < cpBN_tst(pPublicExp)), ippStsOutOfRangeErr); + IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPublicExp), BN_SIZE(pPublicExp)) > RSA_PUB_KEY_MAXSIZE_E(pKey), ippStsSizeErr); + + { + RSA_PUB_KEY_BITSIZE_N(pKey) = 0; + RSA_PUB_KEY_BITSIZE_E(pKey) = 0; + + /* store E */ + ZEXPAND_COPY_BNU(RSA_PUB_KEY_E(pKey), BITS_BNU_CHUNK(RSA_PUB_KEY_MAXSIZE_E(pKey)), BN_NUMBER(pPublicExp), BN_SIZE(pPublicExp)); + + /* setup montgomery engine */ + gsMontSet((Ipp32u*)BN_NUMBER(pModulus), BN_SIZE32(pModulus), RSA_PUB_KEY_NMONT(pKey)); + + RSA_PUB_KEY_BITSIZE_N(pKey) = cpBN_bitsize(pModulus); + RSA_PUB_KEY_BITSIZE_E(pKey) = cpBN_bitsize(pPublicExp); + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsRSA_GetPublicKey +// +// Purpose: Extract key component from the key context +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pKey +// +// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID() +// !BN_VALID_ID(pModulus) +// !BN_VALID_ID(pExp) +// +// ippStsIncompleteContextErr public key is not set up +// +// ippStsSizeErr BN_ROOM(pModulus), BN_ROOM(pExp) is not enough +// +// ippStsNoErr no error +// +// Parameters: +// pModulus (optional) pointer to the modulus (N) +// pExp (optional) pointer to the public exponent (E) +// pKey pointer to the key context +*F*/ +IPPFUN(IppStatus, ippsRSA_GetPublicKey,(IppsBigNumState* pModulus, + IppsBigNumState* pExp, + const IppsRSAPublicKeyState* pKey)) +{ + IPP_BAD_PTR1_RET(pKey); + pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr); + + if(pModulus) { + pModulus = (IppsBigNumState*)( IPP_ALIGNED_PTR(pModulus, BN_ALIGNMENT) ); + IPP_BADARG_RET(!BN_VALID_ID(pModulus), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr); + IPP_BADARG_RET(BN_ROOM(pModulus)0; nsE--) { + eValue = dataE[nsE-1]; + + for(n=0; n=0; j--) { + mask_pattern = (BNU_CHUNK_T)(back_step-1); + + /* safeBuffer = (Y[] and mask_pattern) or (X[] and ~mask_pattern) */ + for(i=0; i>j) & 0x1) & (back_step^1); + j += back_step; + } + + /* execute rest bits of E */ + for(--nsE; nsE>0; nsE--) { + eValue = dataE[nsE-1]; + + for(j=BNU_CHUNK_BITS-1; j>=0; j--) { + mask_pattern = (BNU_CHUNK_T)(back_step-1); + + /* safeBuffer = (Y[] and mask_pattern) or (X[] and ~mask_pattern) */ + for(i=0; i>j) & 0x1) & (back_step^1); + j += back_step; + } + } + } + + return nsM; +} + + +/* +// "fast" fixed-size window montgomery exponentiation +// +// scratch buffer structure: +// precomutation resource[(1<>shift) &mask; + + /* initialize result */ + COPY_BNU(dataY, pResource+windowVal*nsM, nsM); + + for(eBit-=wBitSize; eBit>=0; eBit-=wBitSize) { + /* do square window times */ + for(n=0,windowVal=0; n>shift) &mask; + + if(windowVal) { + /* extract precomputed value and muptiply */ + cpMul_BNU(pProduct, dataY, nsM, pResource+windowVal*nsM, nsM, pBufferMulK); + cpMontRed_BNU(dataY, pProduct, dataM, nsM, m0); + } + } + } + } + + return nsM; +} + + +/* +// "safe" fixed-size window montgomery exponentiation +// +// scratch buffer structure: +// precomutation resource[(1<>shift) &mask; + + /* initialize result */ + cpScrambleGet((Ipp32u*)dataY, nsM*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u), ((Ipp8u*)pResource)+windowVal*chunkSize, chunkSize); + + for(eBit-=bitsizeEwin; eBit>=0; eBit-=bitsizeEwin) { + /* do square window times */ + for(n=0,windowVal=0; n>shift) &mask; + + /* exptact precomputed value and muptiply */ + cpScrambleGet((Ipp32u*)dataT, nsM*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u), ((Ipp8u*)pResource)+windowVal*chunkSize, chunkSize); + + cpMul_BNU(pProduct, dataY, nsM, dataT, nsM, pBufferMulK); + cpMontRed_BNU(dataY, pProduct, dataM, nsM, m0); + } + } + } + + return nsM; +} diff --git a/external/crypto_px/sources/ippcp/src/pcpngrsamontstuff.h b/external/crypto_px/sources/ippcp/src/pcpngrsamontstuff.h new file mode 100644 index 0000000000..beb996aed4 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpngrsamontstuff.h @@ -0,0 +1,229 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_CP_NG_RSA_MONT_STUFF_H) +#define _CP_NG_RSA_MONT_STUFF_H + +#include "pcpbn.h" +#include "pcpmontgomery.h" + +/* +// Montgomery engine preparation (GetSize/init/Set) +*/ +void gsMontGetSize(IppsExpMethod method, int length, int* pSize); +void gsMontInit(IppsExpMethod method, int length, IppsMontState* pCtx); +void gsMontSet(const Ipp32u* pModulo, int size, IppsMontState* pCtx); + + +/* +// optimal size of fixed window exponentiation +*/ +__INLINE cpSize gsMontExp_WinSize(cpSize bitsize) +{ + return + bitsize> 4096? 6 : /* 4096- .. . */ + bitsize> 2666? 5 : /* 2666 - 4095 */ + bitsize> 717? 4 : /* 717 - 2665 */ + bitsize> 178? 3 : /* 178 - 716 */ + bitsize> 41? 2 : 1; /* 41 - 177 */ +} + +/* +// Montgomery encoding/decoding +*/ +__INLINE cpSize gsMontEnc_BNU(BNU_CHUNK_T* pR, + const BNU_CHUNK_T* pXreg, cpSize nsX, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + cpSize nsM = MNT_SIZE(pMont); + BNU_CHUNK_T* pProduct = pBuffer; + BNU_CHUNK_T* pBufferKmul = NULL; + + cpMontMul_BNU(pR, + pXreg, nsX, MNT_SQUARE_R(pMont), nsM, + MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont), + pProduct, pBufferKmul); + return nsM; +} + +__INLINE cpSize gsMontDec_BNU(BNU_CHUNK_T* pR, + const BNU_CHUNK_T* pXmont, cpSize nsX, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + cpSize nsM = MNT_SIZE(pMont); + ZEXPAND_COPY_BNU(pBuffer, 2*nsM, pXmont, nsX); + + cpMontRed_BNU(pR, pBuffer, MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont)); + return nsM; +} + +__INLINE void gsMontEnc_BN(IppsBigNumState* pRbn, + const IppsBigNumState* pXbn, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + BNU_CHUNK_T* pR = BN_NUMBER(pRbn); + cpSize nsM = MNT_SIZE(pMont); + + gsMontEnc_BNU(pR, BN_NUMBER(pXbn), BN_SIZE(pXbn), pMont, pBuffer); + + FIX_BNU(pR, nsM); + BN_SIZE(pRbn) = nsM; + BN_SIGN(pRbn) = ippBigNumPOS; +} + +__INLINE void gsMontDec_BN(IppsBigNumState* pRbn, + const IppsBigNumState* pXbn, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + BNU_CHUNK_T* pR = BN_NUMBER(pRbn); + cpSize nsM = MNT_SIZE(pMont); + + gsMontDec_BNU(pR, BN_NUMBER(pXbn), BN_SIZE(pXbn), pMont, pBuffer); + + FIX_BNU(pR, nsM); + BN_SIZE(pRbn) = nsM; + BN_SIGN(pRbn) = ippBigNumPOS; +} + + +/* +// binary montgomery exponentiation ("fast" version) +*/ +cpSize gsMontExpBin_BNU(BNU_CHUNK_T* dataY, + const BNU_CHUNK_T* dataX, cpSize nsX, + const BNU_CHUNK_T* dataE, cpSize nsE, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer); + +__INLINE void gsMontExpBin_BN(IppsBigNumState* pY, + const IppsBigNumState* pX, + const BNU_CHUNK_T* dataE, cpSize nsE, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + BNU_CHUNK_T* dataY = BN_NUMBER(pY); + cpSize nsY = gsMontExpBin_BNU(dataY, + BN_NUMBER(pX), BN_SIZE(pX), + dataE, nsE, + pMont, pBuffer); + FIX_BNU(dataY, nsY); + BN_SIZE(pY) = nsY; + BN_SIGN(pY) = ippBigNumPOS; +} + +/* +// fixed-size window montgomery exponentiation ("fast" version) +*/ +cpSize gsMontExpWin_BNU(BNU_CHUNK_T* pY, + const BNU_CHUNK_T* pX, cpSize nsX, + const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieW, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer); + +__INLINE void gsMontExpWin_BN(IppsBigNumState* pY, + const IppsBigNumState* pX, + const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieW, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + BNU_CHUNK_T* dataY = BN_NUMBER(pY); + cpSize nsY = gsMontExpWin_BNU(dataY, + BN_NUMBER(pX), BN_SIZE(pX), + dataE, nsE, bitsieW, + pMont, pBuffer); + FIX_BNU(dataY, nsY); + BN_SIZE(pY) = nsY; + BN_SIGN(pY) = ippBigNumPOS; +} + +/* +// binary montgomery exponentiation ("safe" version) +*/ +__INLINE cpSize gsPrecompResourcelen(int n, cpSize nsM) +{ + cpSize nsR = sizeof(BNU_CHUNK_T)*nsM*n + (CACHE_LINE_SIZE-1); + nsR /=CACHE_LINE_SIZE; /* num of cashe lines */ + nsR *= (CACHE_LINE_SIZE/sizeof(BNU_CHUNK_T)); + return nsR; +} + +cpSize gsMontExpBin_BNU_sscm(BNU_CHUNK_T* pY, + const BNU_CHUNK_T* pX, cpSize nsX, + const BNU_CHUNK_T* pE, cpSize nsE, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer); + +__INLINE void gsMontExpBin_BN_sscm(IppsBigNumState* pY, + const IppsBigNumState* pX, + const BNU_CHUNK_T* dataE, cpSize nsE, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + BNU_CHUNK_T* dataY = BN_NUMBER(pY); + cpSize nsY = gsMontExpBin_BNU_sscm(dataY, + BN_NUMBER(pX), BN_SIZE(pX), + dataE, nsE, + pMont, pBuffer); + FIX_BNU(dataY, nsY); + BN_SIZE(pY) = nsY; + BN_SIGN(pY) = ippBigNumPOS; +} + +/* +// fixed-size window montgomery exponentiation ("safe" version) +*/ +cpSize gsMontExpWin_BNU_sscm(BNU_CHUNK_T* dataY, + const BNU_CHUNK_T* dataX, cpSize nsX, + const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieEwin, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer); + +__INLINE void gsMontExpWin_BN_sscm(IppsBigNumState* pY, + const IppsBigNumState* pX, + const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieEwin, + const IppsMontState* pMont, + BNU_CHUNK_T* pBuffer) +{ + BNU_CHUNK_T* dataY = BN_NUMBER(pY); + cpSize nsY = gsMontExpWin_BNU_sscm(dataY, + BN_NUMBER(pX), BN_SIZE(pX), + dataE, nsE, bitsieEwin, + pMont, pBuffer); + FIX_BNU(dataY, nsY); + BN_SIZE(pY) = nsY; + BN_SIGN(pY) = ippBigNumPOS; +} + +#endif /* _CP_NG_RSA_MONT_STUFF_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpngrsassapkcsv15ca.c b/external/crypto_px/sources/ippcp/src/pcpngrsassapkcsv15ca.c new file mode 100644 index 0000000000..86df1f3a12 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpngrsassapkcsv15ca.c @@ -0,0 +1,278 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" + +#include "pcpngrsa.h" +#include "pcphash.h" +#include "pcptool.h" + +static int EMSA_PKCSv15(const Ipp8u* msgDg, int lenMsgDg, + const Ipp8u* fixPS, int lenFixPS, + Ipp8u* pEM, int lenEM) +{ + /* + // encoded message format: + // EM = 00 || 01 || PS=(FF..FF) || 00 || T + // T = fixPS || msgDg + // len(PS) >= 8 + */ + int tLen = lenFixPS + lenMsgDg; + + if(lenEM >= tLen+11) { + int psLen = lenEM - 3 - tLen; + + PaddBlock(0xFF, pEM, lenEM); + pEM[0] = 0x00; + pEM[1] = 0x01; + pEM[2+psLen] = 0x00; + CopyBlock(fixPS, pEM+3+psLen, lenFixPS); + CopyBlock(msgDg, pEM+3+psLen+lenFixPS, lenMsgDg); + return 1; + } + else + return 0; /* encoded message length too long */ +} + +/* +// The DER encoding T of the DigestInfo value is equal to the following (see PKCS-1v2-2): +*/ +static const Ipp8u SHA1_fixPS[] = "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14"; +static const Ipp8u SHA224_fixPS[] = "\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04\x05\x00\x04\x1c"; +static const Ipp8u SHA256_fixPS[] = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20"; +static const Ipp8u SHA384_fixPS[] = "\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30"; +static const Ipp8u SHA512_fixPS[] = "\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40"; +static const Ipp8u MD5_fixPS[] = "\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10"; +static const Ipp8u SHA512_224_fixPS[] = "\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x05\x05\x00\x04\x1c"; +static const Ipp8u SHA512_256_fixPS[] = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06\x05\x00\x04\x20"; + +typedef struct { + const Ipp8u* pSalt; + int saltLen; +} SaltInfo; + +static SaltInfo pksc15_salt[] = { + {NULL, 0}, + {SHA1_fixPS, sizeof(SHA1_fixPS)-1}, + {SHA256_fixPS, sizeof(SHA256_fixPS)-1}, + {SHA224_fixPS, sizeof(SHA224_fixPS)-1}, + {SHA512_fixPS, sizeof(SHA512_fixPS)-1}, + {SHA384_fixPS, sizeof(SHA384_fixPS)-1}, + { MD5_fixPS, sizeof(MD5_fixPS)-1}, + {NULL, 0}, + {SHA512_224_fixPS, sizeof(SHA512_224_fixPS)-1}, + {SHA512_256_fixPS, sizeof(SHA512_256_fixPS)-1}, +}; +/* //////////////////////////////////////////////////////////////////////////////////////////////// */ + +static int GenerateSing(const Ipp8u* pMsg, int msgLen, /* message representation */ + const Ipp8u* pSalt, int saltLen, /* fied string */ + Ipp8u* pSign, + const IppsRSAPrivateKeyState* pPrvKey, + const IppsRSAPublicKeyState* pPubKey, + Ipp8u* pBuffer) +{ + /* size of RSA modulus in bytes and chunks */ + cpSize rsaBits = RSA_PRV_KEY_BITSIZE_N(pPrvKey); + cpSize k = BITS2WORD8_SIZE(rsaBits); + cpSize nsN = BITS_BNU_CHUNK(rsaBits); + + /* EMSA-PKCS-v1_5 encoding */ + int result = EMSA_PKCSv15(pMsg,msgLen, pSalt,saltLen, pSign, k); + + if(result) { + /* align buffer */ + BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T)) ); + + /* temporary BNs */ + __ALIGN8 IppsBigNumState bnC; + __ALIGN8 IppsBigNumState bnP; + + /* make BNs */ + BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnC); + pScratchBuffer += (nsN+1)*2; + BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnP); + pScratchBuffer += (nsN+1)*2; + + /* + // private-key operation + */ + ippsSetOctString_BN(pSign, k, &bnC); + + if(RSA_PRV_KEY1_VALID_ID(pPrvKey)) + gsRSAprv_cipher(&bnP, &bnC, pPrvKey, pScratchBuffer); + else + gsRSAprv_cipher_crt(&bnP, &bnC, pPrvKey, pScratchBuffer); + + ippsGetOctString_BN(pSign, k, &bnP); + + /* check the result before send it out (fault attack mitigatioin) */ + if(pPubKey) { + gsRSApub_cipher(&bnP, &bnP, pPubKey, pScratchBuffer); + + /* check signature before send it out (fault attack mitigatioin) */ + if(0!=cpBN_cmp(&bnP, &bnC)) { + PaddBlock(0, pSign, k); + result = 0; + } + } + } + + return result; +} + +IPPFUN(IppStatus, ippsRSASign_PKCS1v15,(const Ipp8u* pMsg, int msgLen, + Ipp8u* pSign, + const IppsRSAPrivateKeyState* pPrvKey, + const IppsRSAPublicKeyState* pPubKey, + IppHashAlgId hashAlg, + Ipp8u* pBuffer)) +{ + /* test private key context */ + IPP_BAD_PTR2_RET(pPrvKey, pBuffer); + pPrvKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pPrvKey, RSA_PRIVATE_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PRV_KEY_VALID_ID(pPrvKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pPrvKey), ippStsIncompleteContextErr); + + /* test hash algorith ID */ + hashAlg = cpValidHashAlg(hashAlg); + IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr); + + /* use aligned public key context if defined */ + if(pPubKey) { + pPubKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pPubKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pPubKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pPubKey), ippStsIncompleteContextErr); + } + + /* test data pointer */ + IPP_BAD_PTR2_RET(pMsg, pSign); + /* test length */ + IPP_BADARG_RET(msgLen<0, ippStsLengthErr); + + { + Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE]; + int mdLen = cpHashSize(hashAlg); + ippsHashMessage(pMsg, msgLen, md, hashAlg); + + { + const Ipp8u* pSalt = pksc15_salt[hashAlg].pSalt; + int saltLen = pksc15_salt[hashAlg].saltLen; + + int sts = GenerateSing(md, mdLen, + pSalt, saltLen, + pSign, + pPrvKey, pPubKey, pBuffer); + + return (1==sts)? ippStsNoErr : ippStsSizeErr; + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +static int VerifySing(const Ipp8u* pMsg, int msgLen, /* message representation */ + const Ipp8u* pSalt, int saltLen, /* fied string */ + const Ipp8u* pSign, + int* pIsValid, + const IppsRSAPublicKeyState* pKey, + Ipp8u* pBuffer) +{ + /* size of RSA modulus in bytes and chunks */ + cpSize rsaBits = RSA_PUB_KEY_BITSIZE_N(pKey); + cpSize k = BITS2WORD8_SIZE(rsaBits); + cpSize nsN = BITS_BNU_CHUNK(rsaBits); + + /* align buffer */ + BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T)) ); + + /* temporary BNs */ + __ALIGN8 IppsBigNumState bnC; + __ALIGN8 IppsBigNumState bnP; + + /* make BNs */ + BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnC); + pScratchBuffer += (nsN+1)*2; + BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnP); + pScratchBuffer += (nsN+1)*2; + + /* + // public-key operation + */ + ippsSetOctString_BN(pSign, k, &bnP); + gsRSApub_cipher(&bnC, &bnP, pKey, pScratchBuffer); + + /* convert EM into the string */ + ippsGetOctString_BN((Ipp8u*)(BN_BUFFER(&bnC)), k, &bnC); + + /* EMSA-PKCS-v1_5 encoding */ + if( EMSA_PKCSv15(pMsg,msgLen, pSalt,saltLen, (Ipp8u*)(BN_NUMBER(&bnC)), k) ) { + *pIsValid = 1==EquBlock((Ipp8u*)(BN_BUFFER(&bnC)), (Ipp8u*)(BN_NUMBER(&bnC)), k); + return 1; + } + else + return 0; +} + +IPPFUN(IppStatus, ippsRSAVerify_PKCS1v15,(const Ipp8u* pMsg, int msgLen, + const Ipp8u* pSign, int* pIsValid, + const IppsRSAPublicKeyState* pKey, + IppHashAlgId hashAlg, + Ipp8u* pBuffer)) +{ + /* test public key context */ + IPP_BAD_PTR2_RET(pKey, pBuffer); + pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) ); + IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr); + IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr); + + /* test hash algorith ID */ + hashAlg = cpValidHashAlg(hashAlg); + IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr); + + /* test data pointer */ + IPP_BAD_PTR3_RET(pMsg, pSign, pIsValid); + /* test length */ + IPP_BADARG_RET(msgLen<0, ippStsLengthErr); + + *pIsValid = 0; + { + Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE]; + int mdLen = cpHashSize(hashAlg); + ippsHashMessage(pMsg, msgLen, md, hashAlg); + + return VerifySing(md, mdLen, + pksc15_salt[hashAlg].pSalt, pksc15_salt[hashAlg].saltLen, + pSign, pIsValid, + pKey, pBuffer)? ippStsNoErr : ippStsSizeErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcppma.h b/external/crypto_px/sources/ippcp/src/pcppma.h new file mode 100644 index 0000000000..b9d1e1ca82 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcppma.h @@ -0,0 +1,83 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_PMA_H) +#define _PCP_PMA_H + +#include "pcpbn.h" +#include "pcpmontgomery.h" + + +/* +// Prime Modulo Arithmetic +*/ +#define PMA_set(r,a) \ + BN_SIGN((r)) = BN_SIGN((a)); \ + BN_SIZE((r)) = BN_SIZE((a)); \ + ZEXPAND_COPY_BNU(BN_NUMBER((r)),BN_ROOM((r)), BN_NUMBER((a)),BN_SIZE((a))) \ + +#define PMA_mod(r,a,modulo) \ + ippsMod_BN((a),(modulo),(r)) + +#define PMA_inv(r,a,modulo) \ + ippsModInv_BN((a),(modulo),(r)) + +#define PMA_div2(r,a,modulo) { \ + if( IsOdd_BN((a)) ) { \ + ippsAdd_BN((a), (modulo), (a)); \ + } \ + BN_SIZE((r)) = cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), (int)BN_SIZE((a)), 1); \ + cpBN_fix((r)); \ +} + +#define PMA_add(r,a,b,modulo) \ + ippsAdd_BN((a),(b),(r)); \ + if( cpCmp_BNU(BN_NUMBER((r)),BN_SIZE((r)),BN_NUMBER((modulo)),BN_SIZE(modulo)) >= 0 ) \ + ippsSub_BN((r),(modulo),(r)) + +#define PMA_sub(r,a,b,modulo) \ + ippsSub_BN((a),(b),(r)); \ + if( BN_NEGATIVE((r)) ) \ + ippsAdd_BN((r),(modulo),(r)) + +#define PMA_enc(r,a,mont) \ + cpMontEnc_BN((r), (a), (mont)) + +#define PMA_dec(r,a,mont) \ + cpMontDec_BN((r), (a), (mont)) + +#define PMA_sqre(r,a,mont) \ + ippsMontMul((a),(a), (mont),(r)) + +#define PMA_mule(r,a,b,mont) \ + ippsMontMul((a),(b), (mont),(r)) + +#endif /* _PCP_PMA_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpprimeg.h b/external/crypto_px/sources/ippcp/src/pcpprimeg.h new file mode 100644 index 0000000000..e61d4dee44 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpprimeg.h @@ -0,0 +1,78 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_CP_PRIME_H) +#define _CP_PRIME_H + +#include "pcpbn.h" +#include "pcpmontgomery.h" + + +/* +// Prime context +*/ +struct _cpPrime { + IppCtxId idCtx; /* Prime context identifier */ + cpSize maxBitSize; /* max bit length */ + BNU_CHUNK_T* pPrime; /* prime value */ + BNU_CHUNK_T* pT1; /* temporary BNU */ + BNU_CHUNK_T* pT2; /* temporary BNU */ + BNU_CHUNK_T* pT3; /* temporary BNU */ + IppsMontState* pMont; /* montgomery engine */ +}; + +/* alignment */ +#define PRIME_ALIGNMENT ((int)sizeof(void*)) + +/* Prime accessory macros */ +#define PRIME_ID(ctx) ((ctx)->idCtx) +#define PRIME_MAXBITSIZE(ctx) ((ctx)->maxBitSize) +#define PRIME_NUMBER(ctx) ((ctx)->pPrime) +#define PRIME_TEMP1(ctx) ((ctx)->pT1) +#define PRIME_TEMP2(ctx) ((ctx)->pT2) +#define PRIME_TEMP3(ctx) ((ctx)->pT3) +#define PRIME_MONT(ctx) ((ctx)->pMont) + +#define PRIME_VALID_ID(ctx) (PRIME_ID((ctx))==idCtxPrimeNumber) + +/* easy prime test */ +int cpMimimalPrimeTest(const Ipp32u* pPrime, cpSize ns); + +/* prime test */ +int cpPrimeTest(const BNU_CHUNK_T* pPrime, cpSize primeLen, + cpSize nTrials, + IppsPrimeState* pCtx, + IppBitSupplier rndFunc, void* pRndParam); + +void cpPackPrimeCtx(const IppsPrimeState* pCtx, Ipp8u* pBuffer); +void cpUnpackPrimeCtx(const Ipp8u* pBuffer, IppsPrimeState* pCtx); + +#endif /* _CP_PRIME_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpprimegenca.c b/external/crypto_px/sources/ippcp/src/pcpprimegenca.c new file mode 100644 index 0000000000..bfa6ea5518 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpprimegenca.c @@ -0,0 +1,472 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owncp.h" +#include "pcpprimeg.h" +#include "pcptool.h" + + +/*F* +// Name: ippsPrimeTest +// +// Purpose: Tests the set BN for being a probable prime. +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pCtx +// NULL == pResult +// NULL == rndFunc +// ippStsContextMatchErr illegal pCtx->idCtx +// ippStsOutOfRangeErr zero value under the test +// ippStsBadArgErr 1 > nTrials +// ippStsNoErr no error +// +// Parameters: +// nTrials parameter for the Miller-Rabin probable primality test +// pResult pointer to the test result (IS_COMPOSITE / IS_PRIME) +// pCtx pointer to the context +// rndFunc external PRNG +// pRndParam pointer to the external PRNG parameters +*F*/ + +/* minimal prime test */ +static Ipp32u PrimeList[] = { + 2, 3, 5, 7, 11, 13, 17, 19, + 23, 29, 31, 37, 41, 43, 47, 53, + 59, 61, 67, 71, 73, 79, 83, 89, + 97, 101, 103, 107, 109, 113, 127, 131, + 137, 139, 149, 151, 157, 163, 167, 173, + 179, 181, 191, 193, 197, 199, 211, 223, + 227, 229, 233, 239, 241, 251, 257, 263, + 269, 271, 277, 281, 283, 293, 307, 311, + 313, 317, 331, 337, 347, 349, 353, 359, + 367, 373, 379, 383, 389, 397, 401, 409, + 419, 421, 431, 433, 439, 443, 449, 457, + 461, 463, 467, 479, 487, 491, 499, 503, + 509, 521, 523, 541, 547, 557, 563, 569, + 571, 577, 587, 593, 599, 601, 607, 613, + 617, 619, 631, 641, 643, 647, 653, 659, + 661, 673, 677, 683, 691, 701, 709, 719, + 727, 733, 739, 743, 751, 757, 761, 769, + 773, 787, 797, 809, 811, 821, 823, 827, + 829, 839, 853, 857, 859, 863, 877, 881, + 883, 887, 907, 911, 919, 929, 937, 941, + 947, 953, 967, 971, 977, 983, 991, 997, + 1009,1013,1019,1021,1031,1033,1039,1049, + 1051,1061,1063,1069,1087,1091,1093,1097, + 1103,1109,1117,1123,1129,1151,1153,1163, + 1171,1181,1187,1193,1201,1213,1217,1223, + 1229,1231,1237,1249,1259,1277,1279,1283, + 1289,1291,1297,1301,1303,1307,1319,1321, + 1327,1361,1367,1373,1381,1399,1409,1423, + 1427,1429,1433,1439,1447,1451,1453,1459, + 1471,1481,1483,1487,1489,1493,1499,1511, + 1523,1531,1543,1549,1553,1559,1567,1571, + 1579,1583,1597,1601,1607,1609,1613,1619, + 1621,1627,1637,1657,1663,1667,1669,1693, + 1697,1699,1709,1721,1723,1733,1741,1747, + 1753,1759,1777,1783,1787,1789,1801,1811, + 1823,1831,1847,1861,1867,1871,1873,1877, + 1879,1889,1901,1907,1913,1931,1933,1949, + 1951,1973,1979,1987,1993,1997,1999,2003, + 2011,2017,2027,2029,2039,2053,2063,2069, + 2081,2083,2087,2089,2099,2111,2113,2129, + 2131,2137,2141,2143,2153,2161,2179,2203, + 2207,2213,2221,2237,2239,2243,2251,2267, + 2269,2273,2281,2287,2293,2297,2309,2311, + 2333,2339,2341,2347,2351,2357,2371,2377, + 2381,2383,2389,2393,2399,2411,2417,2423, + 2437,2441,2447,2459,2467,2473,2477,2503, + 2521,2531,2539,2543,2549,2551,2557,2579, + 2591,2593,2609,2617,2621,2633,2647,2657, + 2659,2663,2671,2677,2683,2687,2689,2693, + 2699,2707,2711,2713,2719,2729,2731,2741, + 2749,2753,2767,2777,2789,2791,2797,2801, + 2803,2819,2833,2837,2843,2851,2857,2861, + 2879,2887,2897,2903,2909,2917,2927,2939, + 2953,2957,2963,2969,2971,2999,3001,3011, + 3019,3023,3037,3041,3049,3061,3067,3079, + 3083,3089,3109,3119,3121,3137,3163,3167, + 3169,3181,3187,3191,3203,3209,3217,3221, + 3229,3251,3253,3257,3259,3271,3299,3301, + 3307,3313,3319,3323,3329,3331,3343,3347, + 3359,3361,3371,3373,3389,3391,3407,3413, + 3433,3449,3457,3461,3463,3467,3469,3491, + 3499,3511,3517,3527,3529,3533,3539,3541, + 3547,3557,3559,3571,3581,3583,3593,3607, + 3613,3617,3623,3631,3637,3643,3659,3671, + 3673,3677,3691,3697,3701,3709,3719,3727, + 3733,3739,3761,3767,3769,3779,3793,3797, + 3803,3821,3823,3833,3847,3851,3853,3863, + 3877,3881,3889,3907,3911,3917,3919,3923, + 3929,3931,3943,3947,3967,3989,4001,4003, + 4007,4013,4019,4021,4027,4049,4051,4057, + 4073,4079,4091,4093,4099,4111,4127,4129, + 4133,4139,4153,4157,4159,4177,4201,4211, + 4217,4219,4229,4231,4241,4243,4253,4259, + 4261,4271,4273,4283,4289,4297,4327,4337, + 4339,4349,4357,4363,4373,4391,4397,4409, + 4421,4423,4441,4447,4451,4457,4463,4481, + 4483,4493,4507,4513,4517,4519,4523,4547, + 4549,4561,4567,4583,4591,4597,4603,4621, + 4637,4639,4643,4649,4651,4657,4663,4673, + 4679,4691,4703,4721,4723,4729,4733,4751, + 4759,4783,4787,4789,4793,4799,4801,4813, + 4817,4831,4861,4871,4877,4889,4903,4909, + 4919,4931,4933,4937,4943,4951,4957,4967, + 4969,4973,4987,4993,4999,5003,5009,5011, + 5021,5023,5039,5051,5059,5077,5081,5087, + 5099,5101,5107,5113,5119,5147,5153,5167, + 5171,5179,5189,5197,5209,5227,5231,5233, + 5237,5261,5273,5279,5281,5297,5303,5309, + 5323,5333,5347,5351,5381,5387,5393,5399, + 5407,5413,5417,5419,5431,5437,5441,5443, + 5449,5471,5477,5479,5483,5501,5503,5507, + 5519,5521,5527,5531,5557,5563,5569,5573, + 5581,5591,5623,5639,5641,5647,5651,5653, + 5657,5659,5669,5683,5689,5693,5701,5711, + 5717,5737,5741,5743,5749,5779,5783,5791, + 5801,5807,5813,5821,5827,5839,5843,5849, + 5851,5857,5861,5867,5869,5879,5881,5897, + 5903,5923,5927,5939,5953,5981,5987,6007, + 6011,6029,6037,6043,6047,6053,6067,6073, + 6079,6089,6091,6101,6113,6121,6131,6133, + 6143,6151,6163,6173,6197,6199,6203,6211, + 6217,6221,6229,6247,6257,6263,6269,6271, + 6277,6287,6299,6301,6311,6317,6323,6329, + 6337,6343,6353,6359,6361,6367,6373,6379, + 6389,6397,6421,6427,6449,6451,6469,6473, + 6481,6491,6521,6529,6547,6551,6553,6563, + 6569,6571,6577,6581,6599,6607,6619,6637, + 6653,6659,6661,6673,6679,6689,6691,6701, + 6703,6709,6719,6733,6737,6761,6763,6779, + 6781,6791,6793,6803,6823,6827,6829,6833, + 6841,6857,6863,6869,6871,6883,6899,6907, + 6911,6917,6947,6949,6959,6961,6967,6971, + 6977,6983,6991,6997,7001,7013,7019,7027, + 7039,7043,7057,7069,7079,7103,7109,7121, + 7127,7129,7151,7159,7177,7187,7193,7207, + 7211,7213,7219,7229,7237,7243,7247,7253, + 7283,7297,7307,7309,7321,7331,7333,7349, + 7351,7369,7393,7411,7417,7433,7451,7457, + 7459,7477,7481,7487,7489,7499,7507,7517, + 7523,7529,7537,7541,7547,7549,7559,7561, + 7573,7577,7583,7589,7591,7603,7607,7621, + 7639,7643,7649,7669,7673,7681,7687,7691, + 7699,7703,7717,7723,7727,7741,7753,7757, + 7759,7789,7793,7817,7823,7829,7841,7853, + 7867,7873,7877,7879,7883,7901,7907,7919, + 7927,7933,7937,7949,7951,7963,7993,8009, + 8011,8017,8039,8053,8059,8069,8081,8087, + 8089,8093,8101,8111,8117,8123,8147,8161, + 8167,8171,8179,8191,8209,8219,8221,8231, + 8233,8237,8243,8263,8269,8273,8287,8291, + 8293,8297,8311,8317,8329,8353,8363,8369, + 8377,8387,8389,8419,8423,8429,8431,8443, + 8447,8461,8467,8501,8513,8521,8527,8537, + 8539,8543,8563,8573,8581,8597,8599,8609, + 8623,8627,8629,8641,8647,8663,8669,8677, + 8681,8689,8693,8699,8707,8713,8719,8731, + 8737,8741,8747,8753,8761,8779,8783,8803, + 8807,8819,8821,8831,8837,8839,8849,8861, + 8863,8867,8887,8893,8923,8929,8933,8941, + 8951,8963,8969,8971,8999,9001,9007,9011, + 9013,9029,9041,9043,9049,9059,9067,9091, + 9103,9109,9127,9133,9137,9151,9157,9161, + 9173,9181,9187,9199,9203,9209,9221,9227, + 9239,9241,9257,9277,9281,9283,9293,9311, + 9319,9323,9337,9341,9343,9349,9371,9377, + 9391,9397,9403,9413,9419,9421,9431,9433, + 9437,9439,9461,9463,9467,9473,9479,9491, + 9497,9511,9521,9533,9539,9547,9551,9587, + 9601,9613,9619,9623,9629,9631,9643,9649, + 9661,9677,9679,9689,9697,9719,9721,9733, + 9739,9743,9749,9767,9769,9781,9787,9791, + 9803,9811,9817,9829,9833,9839,9851,9857, + 9859,9871,9883,9887,9901,9907,9923,9929, + 9931,9941,9949,9967,9973,10007,10009,10037, + 10039,10061,10067,10069,10079,10091,10093,10099, + 10103,10111,10133,10139,10141,10151,10159,10163, + 10169,10177,10181,10193,10211,10223,10243,10247, + 10253,10259,10267,10271,10273,10289,10301,10303, + 10313,10321,10331,10333,10337,10343,10357,10369, + 10391,10399,10427,10429,10433,10453,10457,10459, + 10463,10477,10487,10499,10501,10513,10529,10531, + 10559,10567,10589,10597,10601,10607,10613,10627, + 10631,10639,10651,10657,10663,10667,10687,10691, + 10709,10711,10723,10729,10733,10739,10753,10771, + 10781,10789,10799,10831,10837,10847,10853,10859, + 10861,10867,10883,10889,10891,10903,10909,10937, + 10939,10949,10957,10973,10979,10987,10993,11003, + 11027,11047,11057,11059,11069,11071,11083,11087, + 11093,11113,11117,11119,11131,11149,11159,11161, + 11171,11173,11177,11197,11213,11239,11243,11251, + 11257,11261,11273,11279,11287,11299,11311,11317, + 11321,11329,11351,11353,11369,11383,11393,11399, + 11411,11423,11437,11443,11447,11467,11471,11483, + 11489,11491,11497,11503,11519,11527,11549,11551, + 11579,11587,11593,11597,11617,11621,11633,11657, + 11677,11681,11689,11699,11701,11717,11719,11731, + 11743,11777,11779,11783,11789,11801,11807,11813, + 11821,11827,11831,11833,11839,11863,11867,11887, + 11897,11903,11909,11923,11927,11933,11939,11941, + 11953,11959,11969,11971,11981,11987,12007,12011, + 12037,12041,12043,12049,12071,12073,12097,12101, + 12107,12109,12113,12119,12143,12149,12157,12161, + 12163,12197,12203,12211,12227,12239,12241,12251, + 12253,12263,12269,12277,12281,12289,12301,12323, + 12329,12343,12347,12373,12377,12379,12391,12401, + 12409,12413,12421,12433,12437,12451,12457,12473, + 12479,12487,12491,12497,12503,12511,12517,12527, + 12539,12541,12547,12553,12569,12577,12583,12589, + 12601,12611,12613,12619,12637,12641,12647,12653, + 12659,12671,12689,12697,12703,12713,12721,12739, + 12743,12757,12763,12781,12791,12799,12809,12821, + 12823,12829,12841,12853,12889,12893,12899,12907, + 12911,12917,12919,12923,12941,12953,12959,12967, + 12973,12979,12983,13001,13003,13007,13009,13033, + 13037,13043,13049,13063,13093,13099,13103,13109, + 13121,13127,13147,13151,13159,13163,13171,13177, + 13183,13187,13217,13219,13229,13241,13249,13259, + 13267,13291,13297,13309,13313,13327,13331,13337, + 13339,13367,13381,13397,13399,13411,13417,13421, + 13441,13451,13457,13463,13469,13477,13487,13499, + 13513,13523,13537,13553,13567,13577,13591,13597, + 13613,13619,13627,13633,13649,13669,13679,13681, + 13687,13691,13693,13697,13709,13711,13721,13723, + 13729,13751,13757,13759,13763,13781,13789,13799, + 13807,13829,13831,13841,13859,13873,13877,13879, + 13883,13901,13903,13907,13913,13921,13931,13933, + 13963,13967,13997,13999,14009,14011,14029,14033, + 14051,14057,14071,14081,14083,14087,14107,14143, + 14149,14153,14159,14173,14177,14197,14207,14221, + 14243,14249,14251,14281,14293,14303,14321,14323, + 14327,14341,14347,14369,14387,14389,14401,14407, + 14411,14419,14423,14431,14437,14447,14449,14461, + 14479,14489,14503,14519,14533,14537,14543,14549, + 14551,14557,14561,14563,14591,14593,14621,14627, + 14629,14633,14639,14653,14657,14669,14683,14699, + 14713,14717,14723,14731,14737,14741,14747,14753, + 14759,14767,14771,14779,14783,14797,14813,14821, + 14827,14831,14843,14851,14867,14869,14879,14887, + 14891,14897,14923,14929,14939,14947,14951,14957, + 14969,14983,15013,15017,15031,15053,15061,15073, + 15077,15083,15091,15101,15107,15121,15131,15137, + 15139,15149,15161,15173,15187,15193,15199,15217, + 15227,15233,15241,15259,15263,15269,15271,15277, + 15287,15289,15299,15307,15313,15319,15329,15331, + 15349,15359,15361,15373,15377,15383,15391,15401, + 15413,15427,15439,15443,15451,15461,15467,15473, + 15493,15497,15511,15527,15541,15551,15559,15569, + 15581,15583,15601,15607,15619,15629,15641,15643, + 15647,15649,15661,15667,15671,15679,15683,15727, + 15731,15733,15737,15739,15749,15761,15767,15773, + 15787,15791,15797,15803,15809,15817,15823,15859, + 15877,15881,15887,15889,15901,15907,15913,15919, + 15923,15937,15959,15971,15973,15991,16001,16007, + 16033,16057,16061,16063,16067,16069,16073,16087, + 16091,16097,16103,16111,16127,16139,16141,16183, + 16187,16189,16193,16217,16223,16229,16231,16249, + 16253,16267,16273,16301,16319,16333,16339,16349, + 16361,16363,16369,16381,16411,16417,16421,16427, + 16433,16447,16451,16453,16477,16481,16487,16493, + 16519,16529,16547,16553,16561,16567,16573,16603, + 16607,16619,16631,16633,16649,16651,16657,16661, + 16673,16691,16693,16699,16703,16729,16741,16747, + 16759,16763,16787,16811,16823,16829,16831,16843, + 16871,16879,16883,16889,16901,16903,16921,16927, + 16931,16937,16943,16963,16979,16981,16987,16993, + 17011,17021,17027,17029,17033,17041,17047,17053, + 17077,17093,17099,17107,17117,17123,17137,17159, + 17167,17183,17189,17191,17203,17207,17209,17231, + 17239,17257,17291,17293,17299,17317,17321,17327, + 17333,17341,17351,17359,17377,17383,17387,17389, + 17393,17401,17417,17419,17431,17443,17449,17467, + 17471,17477,17483,17489,17491,17497,17509,17519, + 17539,17551,17569,17573,17579,17581,17597,17599, + 17609,17623,17627,17657,17659,17669,17681,17683, + 17707,17713,17729,17737,17747,17749,17761,17783, + 17789,17791,17807,17827,17837,17839,17851,17863 +}; + +static +Ipp32u cpMod32(const Ipp32u* pX, cpSize sizeX, Ipp32u divider) +{ + cpSize n; + Ipp32u r; + for(n=sizeX, r=0; n>0; n--) { + Ipp64u tmp = MAKEDWORD(pX[n-1],r); + r = (Ipp32u)(tmp%divider); + } + return r; +} + +int cpMimimalPrimeTest(const Ipp32u* pPrime, cpSize len32) +{ + cpSize i; + + FIX_BNU(pPrime, len32); + + /* take a look in the list */ + if(1==len32) { + for(i=0; i<(cpSize)(sizeof(PrimeList)/sizeof(Ipp32u)); i++) { + if(pPrime[0]==PrimeList[i]) + return 1; + } + } + + /* test if value under the test is divisible by first prime numbers 2,3,5, ... */ + for(i=0; i<(cpSize)(sizeof(PrimeList)/sizeof(Ipp32u)); i++) { + if(0 == cpMod32(pPrime, len32, PrimeList[i])) + return 0; + } + + return 1; +} + +/* Rabin-Miller test */ +static +int RabinMiller(int a, + BNU_CHUNK_T* pZ, + BNU_CHUNK_T* pR, cpSize nsR, + BNU_CHUNK_T* pM, cpSize nsM, + IppsMontState* pMont) +{ + /* modulus and it length and other parameters */ + const BNU_CHUNK_T* pModulus = MNT_MODULUS(pMont); + cpSize modLen = MNT_SIZE(pMont); + BNU_CHUNK_T m0 = MNT_HELPER(pMont); + BNU_CHUNK_T* pProduct = MNT_PRODUCT(pMont); + BNU_CHUNK_T* pKBuffer = MNT_KBUFFER(pMont); + + /* compute z = r^m mod prime */ + nsR = cpMontEnc_BNU(pR, pR, nsR, pMont); + cpMontExpBin_BNU(pZ, pR, nsR, pM, nsM, pMont); + + /* if z==1 => probably prime */ + if(0==cpCmp_BNU(pZ, modLen, MNT_1(pMont), modLen)) + return 1; + + /* if z==prime-1 => probably prime */ + cpSub_BNU(MNT_PRODUCT(pMont), pModulus, MNT_1(pMont), modLen); + if(0==cpCmp_BNU(pZ, modLen, MNT_PRODUCT(pMont), modLen)) + return 1; + + while(--a) { + + /* z = z^2 mod w */ + cpMontSqr_BNU(pZ, pZ, modLen, pModulus, modLen, m0, pProduct, pKBuffer); + + /* if z==1 => definitely composite */ + if(0==cpCmp_BNU(pZ, modLen, MNT_1(pMont), modLen)) + return 1; + + /* if z==w-1 => probably prime */ + cpSub_BNU(MNT_PRODUCT(pMont), pModulus, MNT_1(pMont), modLen); + if(0==cpCmp_BNU(pZ, modLen, MNT_PRODUCT(pMont), modLen)) + return 1; + } + + /* if we are here, then we deal with composize */ + return 0; +} + +int cpPrimeTest(const BNU_CHUNK_T* pPrime, cpSize primeLen, + cpSize nTrials, + IppsPrimeState* pCtx, + IppBitSupplier rndFunc, void* pRndParam) +{ + FIX_BNU(pPrime, primeLen); + + /* 0 is composite number */ + if( primeLen==1 && pPrime[0]==0) + return 0; + + /* 2 is prime number */ + else if( primeLen==1 && pPrime[0]==2) + return 1; + + /* + // test number + */ + else { + cpSize primeBitsize = BITSIZE_BNU(pPrime, primeLen); + cpSize primeLen32 = BITS2WORD32_SIZE(primeBitsize); + + /* apply easy prime test */ + if( 0==cpMimimalPrimeTest((Ipp32u*)pPrime, primeLen32) ) + return 0; + + /* continue test */ + else { + cpSize n, a; + + IppsMontState* pMont = PRIME_MONT(pCtx); + BNU_CHUNK_T* pMdata = PRIME_TEMP1(pCtx); + BNU_CHUNK_T* pRdata = PRIME_TEMP2(pCtx); + BNU_CHUNK_T* pZdata = PRIME_TEMP3(pCtx); + cpSize lenM, lenR; + + /* set up Montgomery engine (and save value being under the test) */ + ippsMontSet((Ipp32u*)pPrime, primeLen32, pMont); + + /* express w = m*2^a + 1 */ + cpDec_BNU(pMdata, pPrime, primeLen, 1); + for(n=0,a=0; n=1 */ + if(!cpTst_BNU(pRdata, lenR)) + pRdata[0] |= 1; + FIX_BNU(pRdata, lenR); + + /* Rabin-Miller test */ + if(0==RabinMiller(a, pZdata, pRdata,lenR, pMdata,lenM, pMont)) + return 0; + } + + return 1; + } + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpprimeginitca.c b/external/crypto_px/sources/ippcp/src/pcpprimeginitca.c new file mode 100644 index 0000000000..e3eeefe141 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpprimeginitca.c @@ -0,0 +1,124 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owncp.h" +#include "pcpprimeg.h" +#include "pcptool.h" + + +/*F* +// Name: ippsPrimeGetSize +// +// Purpose: Returns size of Prime Number Generator context (bytes). +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pSize +// ippStsLengthErr 1 > maxBits +// ippStsNoErr no error +// +// Parameters: +// maxBits max length of a prime number +// pSize pointer to the size of internal context +*F*/ +IPPFUN(IppStatus, ippsPrimeGetSize, (cpSize maxBits, cpSize* pSize)) +{ + IPP_BAD_PTR1_RET(pSize); + IPP_BADARG_RET(maxBits<1, ippStsLengthErr); + + { + cpSize len = BITS_BNU_CHUNK(maxBits); + cpSize len32 = BITS2WORD32_SIZE(maxBits); + cpSize montSize; + ippsMontGetSize(ippBinaryMethod, len32, &montSize); + + *pSize = sizeof(IppsPrimeState) + +len*sizeof(BNU_CHUNK_T) + +len*sizeof(BNU_CHUNK_T) + +len*sizeof(BNU_CHUNK_T) + +len*sizeof(BNU_CHUNK_T) + +montSize + +PRIME_ALIGNMENT-1; + + return ippStsNoErr; + } +} + + +/*F* +// Name: ippsPrimeInit +// +// Purpose: Initializes Prime Number Generator context +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pCtx +// ippStsLengthErr 1 > maxBits +// ippStsNoErr no error +// +// Parameters: +// maxBits max length of a prime number +// pCtx pointer to the context to be initialized +*F*/ +IPPFUN(IppStatus, ippsPrimeInit, (cpSize maxBits, IppsPrimeState* pCtx)) +{ + IPP_BAD_PTR1_RET(pCtx); + IPP_BADARG_RET(maxBits<1, ippStsLengthErr); + + /* use aligned PRNG context */ + pCtx = (IppsPrimeState*)( IPP_ALIGNED_PTR(pCtx, PRIME_ALIGNMENT) ); + + { + Ipp8u* ptr = (Ipp8u*)pCtx; + + cpSize len = BITS_BNU_CHUNK(maxBits); + cpSize len32 = BITS2WORD32_SIZE(maxBits); + + PRIME_ID(pCtx) = idCtxPrimeNumber; + PRIME_MAXBITSIZE(pCtx) = maxBits; + + ptr += sizeof(IppsPrimeState); + PRIME_NUMBER(pCtx) = (BNU_CHUNK_T*)ptr; + + ptr += len*sizeof(BNU_CHUNK_T); + PRIME_TEMP1(pCtx) = (BNU_CHUNK_T*)ptr; + + ptr += len*sizeof(BNU_CHUNK_T); + PRIME_TEMP2(pCtx) = (BNU_CHUNK_T*)ptr; + + ptr += len*sizeof(BNU_CHUNK_T); + PRIME_TEMP3(pCtx) = (BNU_CHUNK_T*)ptr; + + ptr += len*sizeof(BNU_CHUNK_T); + PRIME_MONT(pCtx) = (IppsMontState*)( IPP_ALIGNED_PTR((ptr), MONT_ALIGNMENT) ); + ippsMontInit(ippBinaryMethod, len32, PRIME_MONT(pCtx)); + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpprng.h b/external/crypto_px/sources/ippcp/src/pcpprng.h new file mode 100644 index 0000000000..3c4829fe5e --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpprng.h @@ -0,0 +1,65 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_CP_PRNG_H) +#define _CP_PRNG_H + +/* +// Pseudo-random generation context +*/ + +#define MAX_XKEY_SIZE 512 +#define DEFAULT_XKEY_SIZE 512 /* must be >=160 || <=512 */ + +struct _cpPRNG { + IppCtxId idCtx; /* PRNG identifier */ + cpSize seedBits; /* secret seed-key bitsize */ + BNU_CHUNK_T Q[BITS_BNU_CHUNK(160)]; /* modulus */ + BNU_CHUNK_T T[BITS_BNU_CHUNK(160)]; /* parameter of SHA_G() funct */ + BNU_CHUNK_T xAug[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* optional entropy augment */ + BNU_CHUNK_T xKey[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* secret seed-key */ +}; + +/* alignment */ +#define PRNG_ALIGNMENT ((int)(sizeof(void*))) + +#define RAND_ID(ctx) ((ctx)->idCtx) +#define RAND_SEEDBITS(ctx) ((ctx)->seedBits) +#define RAND_Q(ctx) ((ctx)->Q) +#define RAND_T(ctx) ((ctx)->T) +#define RAND_XAUGMENT(ctx) ((ctx)->xAug) +#define RAND_XKEY(ctx) ((ctx)->xKey) + +#define RAND_VALID_ID(ctx) (RAND_ID((ctx))==idCtxPRNG) + +int cpPRNGen(Ipp32u* pBuffer, cpSize bitLen, IppsPRNGState* pCtx); + +#endif /* _CP_PRNG_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpprngenca.c b/external/crypto_px/sources/ippcp/src/pcpprngenca.c new file mode 100644 index 0000000000..f25b6e6b31 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpprngenca.c @@ -0,0 +1,178 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" + +#include "owncp.h" +#include "pcpbn.h" +#include "pcphash.h" +#include "pcpprng.h" +#include "pcptool.h" + +/* +// G() function based on SHA1 +// +// Parameters: +// T 160 bit parameter +// pHexStr input hex string +// hexStrLen size of hex string (Ipp8u segnments) +// xBNU 160 bit BNU result +// +// Note 1: +// must to be hexStrLen <= 64 (512 bits) +*/ +static +void SHA1_G(Ipp32u* xBNU, const Ipp32u* T, Ipp8u* pHexStr, int hexStrLen) +{ + /* select processing function */ + cpHashProc updateFunc = UpdateSHA1; + + /* pad HexString zeros */ + PaddBlock(0, pHexStr+hexStrLen, BITS2WORD8_SIZE(MAX_XKEY_SIZE)-hexStrLen); + + /* reset initial HASH value */ + xBNU[0] = T[0]; + xBNU[1] = T[1]; + xBNU[2] = T[2]; + xBNU[3] = T[3]; + xBNU[4] = T[4]; + + /* SHA1 */ + //UpdateSHA1(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt); + updateFunc(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt); + + /* swap back */ + SWAP(xBNU[0],xBNU[4]); + SWAP(xBNU[1],xBNU[3]); +} + +/* +// Returns bitsize of the bitstring has beed added +*/ +int cpPRNGen(Ipp32u* pRand, cpSize nBits, IppsPRNGState* pRnd) +{ + BNU_CHUNK_T Xj [BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; + BNU_CHUNK_T XVAL[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; + + Ipp8u TXVAL[BITS2WORD8_SIZE(MAX_XKEY_SIZE)]; + + /* XKEY length in BNU_CHUNK_T */ + cpSize xKeyLen = BITS_BNU_CHUNK(RAND_SEEDBITS(pRnd)); + /* XKEY length in bytes */ + cpSize xKeySize= BITS2WORD8_SIZE(RAND_SEEDBITS(pRnd)); + /* XKEY word's mask */ + BNU_CHUNK_T xKeyMsk = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd)); + + /* number of Ipp32u chunks to be generated */ + cpSize genlen = BITS2WORD32_SIZE(nBits); + + ZEXPAND_BNU(Xj, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE)); + ZEXPAND_BNU(XVAL, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE)); + + while(genlen) { + cpSize len; + + /* Step 1: XVAL=(Xkey+Xseed) mod 2^b */ + BNU_CHUNK_T carry = cpAdd_BNU(XVAL, RAND_XKEY(pRnd), RAND_XAUGMENT(pRnd), xKeyLen); + XVAL[xKeyLen-1] &= xKeyMsk; + + /* Step 2: xj=G(t, XVAL) mod Q */ + cpToOctStr_BNU(TXVAL, xKeySize, XVAL, xKeyLen); + SHA1_G((Ipp32u*)Xj, (Ipp32u*)RAND_T(pRnd), TXVAL, xKeySize); + + { + cpSize sizeXj = BITS_BNU_CHUNK(160); + if(0 <= cpCmp_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd),BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE)) ) + sizeXj = cpMod_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd), BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE)); + FIX_BNU(Xj, sizeXj); + ZEXPAND_BNU(Xj, sizeXj, BITS_BNU_CHUNK(MAX_XKEY_SIZE)); + } + + /* Step 3: Xkey=(1+Xkey+Xj) mod 2^b */ + cpInc_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), xKeyLen, 1); + carry = cpAdd_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), Xj, xKeyLen); + RAND_XKEY(pRnd)[xKeyLen-1] &= xKeyMsk; + + /* fill out result */ + len = genlenidCtx +// +// ippStsLengthErr 1 > nBits +// +// ippStsNoErr no error +// +// Parameters: +// pBuffer pointer to the buffer +// nBits number of bits be requested +// pRndCtx pointer to the context +*F*/ +IPPFUN(IppStatus, ippsPRNGen,(Ipp32u* pBuffer, cpSize nBits, void* pRnd)) +{ + IppsPRNGState* pRndCtx = (IppsPRNGState*)pRnd; + + /* test PRNG context */ + IPP_BAD_PTR2_RET(pBuffer, pRnd); + + pRndCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRndCtx, PRNG_ALIGNMENT) ); + IPP_BADARG_RET(!RAND_VALID_ID(pRndCtx), ippStsContextMatchErr); + + /* test sizes */ + IPP_BADARG_RET(nBits< 1, ippStsLengthErr); + + { + cpSize rndSize = BITS2WORD32_SIZE(nBits); + Ipp32u rndMask = MAKEMASK32(nBits); + + cpPRNGen(pBuffer, nBits, pRndCtx); + pBuffer[rndSize-1] &= rndMask; + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcpprnginitca.c b/external/crypto_px/sources/ippcp/src/pcpprnginitca.c new file mode 100644 index 0000000000..06c8f2b283 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpprnginitca.c @@ -0,0 +1,113 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" + +#include "owncp.h" +#include "pcpbn.h" +#include "pcpprng.h" +#include "pcphash.h" +#include "pcptool.h" + + +/*F* +// Name: ippsPRNGGetSize +// +// Purpose: Returns size of PRNG context (bytes). +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pSize +// +// ippStsNoErr no error +// +// Parameters: +// pSize pointer to the size of internal context +*F*/ +IPPFUN(IppStatus, ippsPRNGGetSize, (int* pSize)) +{ + IPP_BAD_PTR1_RET(pSize); + + *pSize = sizeof(IppsPRNGState) + +PRNG_ALIGNMENT-1; + return ippStsNoErr; +} + + +/*F* +// Name: ippsPRNGInit +// +// Purpose: Initializes PRNG context +// +// Returns: Reason: +// ippStsNullPtrErr NULL == pRnd +// +// ippStsLengthErr seedBits < 1 +// seedBits < MAX_XKEY_SIZE +// seedBits%8 !=0 +// +// ippStsNoErr no error +// +// Parameters: +// seedBits seed bitsize +// pRnd pointer to the context to be initialized +*F*/ +IPPFUN(IppStatus, ippsPRNGInit, (int seedBits, IppsPRNGState* pRnd)) +{ + /* test PRNG context */ + IPP_BAD_PTR1_RET(pRnd); + pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) ); + + /* test sizes */ + IPP_BADARG_RET((1>seedBits) || (seedBits>MAX_XKEY_SIZE) ||(seedBits&7), ippStsLengthErr); + + { + int hashIvSize = cpHashIvSize(ippHashAlg_SHA1); + const Ipp8u* iv = cpHashIV[ippHashAlg_SHA1]; + + /* cleanup context */ + ZEXPAND_BNU((Ipp8u*)pRnd, 0, (cpSize)(sizeof(IppsPRNGState))); + + RAND_ID(pRnd) = idCtxPRNG; + RAND_SEEDBITS(pRnd) = seedBits; + + /* default Q parameter */ + ((Ipp32u*)RAND_Q(pRnd))[0] = 0xFFFFFFFF; + ((Ipp32u*)RAND_Q(pRnd))[1] = 0xFFFFFFFF; + ((Ipp32u*)RAND_Q(pRnd))[2] = 0xFFFFFFFF; + ((Ipp32u*)RAND_Q(pRnd))[3] = 0xFFFFFFFF; + ((Ipp32u*)RAND_Q(pRnd))[4] = 0xFFFFFFFF; + + /* default T parameter */ + CopyBlock(iv, RAND_T(pRnd), hashIvSize); + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcprij.h b/external/crypto_px/sources/ippcp/src/pcprij.h new file mode 100644 index 0000000000..6b55123a77 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcprij.h @@ -0,0 +1,141 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_RIJ_H) +#define _PCP_RIJ_H + + +/* +// The GF(256) modular polynomial and elements +*/ +#define WPOLY 0x011B +#define BPOLY 0x1B + +/* +// Make WORD using 4 arbitrary bytes +*/ +#define BYTES_TO_WORD(b0,b1,b2,b3) ( ( ((Ipp32u)((Ipp8u)(b3))) <<24 ) \ + |( ((Ipp32u)((Ipp8u)(b2))) <<16 ) \ + |( ((Ipp32u)((Ipp8u)(b1))) << 8 ) \ + |( ((Ipp32u)((Ipp8u)(b0))) ) ) +/* +// Make WORD setting byte in specified position +*/ +#define BYTE0_TO_WORD(b) BYTES_TO_WORD((b), 0, 0, 0) +#define BYTE1_TO_WORD(b) BYTES_TO_WORD( 0, (b), 0, 0) +#define BYTE2_TO_WORD(b) BYTES_TO_WORD( 0, 0, (b), 0) +#define BYTE3_TO_WORD(b) BYTES_TO_WORD( 0, 0, 0, (b)) + +/* +// Extract byte from specified position n. +// Sure, n=0,1,2 or 3 only +*/ +#define EBYTE(w,n) ((Ipp8u)((w) >> (8 * (n)))) + + +/* +// Rijndael's spec +*/ +typedef void (*RijnCipher)(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl); + +struct _cpRijndael128 { + IppCtxId idCtx; /* Rijndael spec identifier */ + int nk; /* security key length (words) */ + int nb; /* data block size (words) */ + int nr; /* number of rounds */ + RijnCipher encoder; /* encoder/decoder */ + RijnCipher decoder; /* entry point */ + Ipp32u* pEncTbl; /* expanded S-boxes for */ + Ipp32u* pDecTbl; /* encryption and decryption */ + Ipp32u enc_keys[64]; /* array of keys for encryprion */ + Ipp32u dec_keys[64]; /* array of keys for decryprion */ + Ipp32u aesNI; /* AES instruction available */ + Ipp32u safeInit; /* SafeInit performed */ +}; + +/* alignment */ +#define RIJ_ALIGNMENT (16) + +#define MBS_RIJ128 (128/8) /* message block size (bytes) */ +#define MBS_RIJ192 (192/8) +#define MBS_RIJ256 (256/8) + +#define SR (4) /* number of rows in STATE data */ + +#define NB(msgBlks) ((msgBlks)/32) /* message block size (words) */ + /* 4-word for 128-bits data block */ + /* 6-word for 192-bits data block */ + /* 8-word for 256-bits data block */ + +#define NK(keybits) ((keybits)/32) /* key length (words): */ +#define NK128 NK(ippRijndaelKey128)/* 4-word for 128-bits security key */ +#define NK192 NK(ippRijndaelKey192)/* 6-word for 192-bits security key */ +#define NK256 NK(ippRijndaelKey256)/* 8-word for 256-bits security key */ + +#define NR128_128 (10) /* number of rounds data: 128 bits key: 128 bits are used */ +#define NR128_192 (12) /* number of rounds data: 128 bits key: 192 bits are used */ +#define NR128_256 (14) /* number of rounds data: 128 bits key: 256 bits are used */ +#define NR192_128 (12) /* number of rounds data: 192 bits key: 128 bits are used */ +#define NR192_192 (12) /* number of rounds data: 192 bits key: 192 bits are used */ +#define NR192_256 (14) /* number of rounds data: 192 bits key: 256 bits are used */ +#define NR256_128 (14) /* number of rounds data: 256 bits key: 128 bits are used */ +#define NR256_192 (14) /* number of rounds data: 256 bits key: 192 bits are used */ +#define NR256_256 (14) /* number of rounds data: 256 bits key: 256 bits are used */ + +/* +// Useful macros +*/ +#define RIJ_ID(ctx) ((ctx)->idCtx) +#define RIJ_NB(ctx) ((ctx)->nb) +#define RIJ_NK(ctx) ((ctx)->nk) +#define RIJ_NR(ctx) ((ctx)->nr) +#define RIJ_ENCODER(ctx) ((ctx)->encoder) +#define RIJ_DECODER(ctx) ((ctx)->decoder) +#define RIJ_ENC_SBOX(ctx) ((ctx)->pEncTbl) +#define RIJ_DEC_SBOX(ctx) ((ctx)->pDecTbl) +#define RIJ_EKEYS(ctx) (Ipp8u*)((ctx)->enc_keys) +#define RIJ_DKEYS(ctx) (Ipp8u*)((ctx)->dec_keys) +#define RIJ_AESNI(ctx) ((ctx)->aesNI) +#define RIJ_SAFE_INIT(ctx) ((ctx)->safeInit) + +#define RIJ_ID_TEST(ctx) (RIJ_ID((ctx))==idCtxRijndael) + +/* +// Internal functions +*/ + +void Safe2Encrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl); +void Safe2Decrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl); + +void ExpandRijndaelKey(const Ipp8u* pKey, int NK, int NB, int NR, int nKeys, + Ipp8u* pEncKeys, Ipp8u* pDecKeys); + +#endif /* _PCP_RIJ_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcprij128safe2.h b/external/crypto_px/sources/ippcp/src/pcprij128safe2.h new file mode 100644 index 0000000000..94a79f13d7 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcprij128safe2.h @@ -0,0 +1,79 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PCP_RIJ_SAFE2_H) +#define _PCP_RIJ_SAFE2_H + +// transpose 4x4 Ipp8u matrix +#define TRANSPOSE(out, inp) \ + (out)[ 0] = (inp)[ 0]; \ + (out)[ 4] = (inp)[ 1]; \ + (out)[ 8] = (inp)[ 2]; \ + (out)[12] = (inp)[ 3]; \ + \ + (out)[ 1] = (inp)[ 4]; \ + (out)[ 5] = (inp)[ 5]; \ + (out)[ 9] = (inp)[ 6]; \ + (out)[13] = (inp)[ 7]; \ + \ + (out)[ 2] = (inp)[ 8]; \ + (out)[ 6] = (inp)[ 9]; \ + (out)[10] = (inp)[10]; \ + (out)[14] = (inp)[11]; \ + \ + (out)[ 3] = (inp)[12]; \ + (out)[ 7] = (inp)[13]; \ + (out)[11] = (inp)[14]; \ + (out)[15] = (inp)[15] + +__INLINE void XorRoundKey(Ipp32u* state, const Ipp32u* RoundKey) +{ + state[0] ^= RoundKey[0]; + state[1] ^= RoundKey[1]; + state[2] ^= RoundKey[2]; + state[3] ^= RoundKey[3]; +} + +// xtime is a macro that finds the product of {02} and the argument to xtime modulo {1b} +__INLINE Ipp32u mask4(Ipp32u x) +{ + x &= 0x80808080; + return (Ipp32u)((x<<1) - (x>>7)); +} + +__INLINE Ipp32u xtime4(Ipp32u x) +{ + Ipp32u t = (x+x) &0xFEFEFEFE; + t ^= mask4(x) & 0x1B1B1B1B; + return t; +} + +#endif /* _PCP_RIJ_SAFE2_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcprij128safedec2pxca.c b/external/crypto_px/sources/ippcp/src/pcprij128safedec2pxca.c new file mode 100644 index 0000000000..16b1f54133 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcprij128safedec2pxca.c @@ -0,0 +1,133 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" + +#include "pcprij128safe2.h" +#include "pcprijtables.h" + + +__INLINE Ipp8u getInvSboxValue(Ipp32u x) +{ + Ipp32u t[sizeof(RijDecSbox)/CACHE_LINE_SIZE]; + const Ipp8u* SboxEntry = RijDecSbox +x%CACHE_LINE_SIZE; + Ipp32u i; + for(i=0; i0;round--) { + invShiftRows(state); + invSubBytes((Ipp8u*)state); + XorRoundKey(state,(Ipp32u*)(RoundKey+round*16)); + invMixColumns(state); + } + + // last round + invShiftRows(state); + invSubBytes((Ipp8u*)state); + XorRoundKey(state,(Ipp32u*)(RoundKey+0*16)); + + // copy from the state to output + TRANSPOSE(out, (Ipp8u*)state); +} diff --git a/external/crypto_px/sources/ippcp/src/pcprij128safeenc2pxca.c b/external/crypto_px/sources/ippcp/src/pcprij128safeenc2pxca.c new file mode 100644 index 0000000000..8295b1b001 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcprij128safeenc2pxca.c @@ -0,0 +1,125 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" + +#include "pcprij128safe2.h" +#include "pcprijtables.h" + + +__INLINE Ipp8u getSboxValue(Ipp32u x) +{ + Ipp32u t[sizeof(RijEncSbox)/CACHE_LINE_SIZE]; + const Ipp8u* SboxEntry = RijEncSbox +x%CACHE_LINE_SIZE; + Ipp32u i; + for(i=0; i>7) & 1) * WPOLY)) +#define gf_m4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY)) +#define gf_m8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \ + ^ (((x>>5) & 4) * WPOLY)) +#define gf_m1(x) ((x)) +#define gf_m3(x) (gf_m2(x) ^ x) +#define gf_m9(x) (gf_m8(x) ^ x) +#define gf_mB(x) (gf_m8(x) ^ gf_m2(x) ^ x) +#define gf_mD(x) (gf_m8(x) ^ gf_m4(x) ^ x) +#define gf_mE(x) (gf_m8(x) ^ gf_m4(x) ^ gf_m2(x)) + +/* +// The following particular transformations +// are used for create Encryption Tables +*/ +#define fwd_t0(x) BYTES_TO_WORD(gf_m2(x), gf_m1(x), gf_m1(x), gf_m3(x)) +#define fwd_t1(x) BYTES_TO_WORD(gf_m3(x), gf_m2(x), gf_m1(x), gf_m1(x)) +#define fwd_t2(x) BYTES_TO_WORD(gf_m1(x), gf_m3(x), gf_m2(x), gf_m1(x)) +#define fwd_t3(x) BYTES_TO_WORD(gf_m1(x), gf_m1(x), gf_m3(x), gf_m2(x)) + +/* +// The following particular transformations +// are used for create Decryption Tables +*/ +#define inv_t0(x) BYTES_TO_WORD(gf_mE(x), gf_m9(x), gf_mD(x), gf_mB(x)) +#define inv_t1(x) BYTES_TO_WORD(gf_mB(x), gf_mE(x), gf_m9(x), gf_mD(x)) +#define inv_t2(x) BYTES_TO_WORD(gf_mD(x), gf_mB(x), gf_mE(x), gf_m9(x)) +#define inv_t3(x) BYTES_TO_WORD(gf_m9(x), gf_mD(x), gf_mB(x), gf_mE(x)) + +#define exp_b3(x) BYTES_TO_WORD(0, 0, 0, (x)) +#define exp_b2(x) BYTES_TO_WORD(0, 0, (x),0) +#define exp_b1(x) BYTES_TO_WORD(0, (x),0, 0) +#define exp_b0(x) BYTES_TO_WORD((x),0, 0, 0) + +/* +// The following particular transformations +// are used for create pure Encryption/Decryption Sboxes +*/ +#define none_t(x) (x) + + +/* +// Just sequence of byte, beginning 0x00 upto 0xff +// (be parametrized by any transformation 't') +*/ +#define LINE(t) \ + t(0x00), t(0x01), t(0x02), t(0x03), t(0x04), t(0x05), t(0x06), t(0x07),\ + t(0x08), t(0x09), t(0x0a), t(0x0b), t(0x0c), t(0x0d), t(0x0e), t(0x0f),\ + t(0x10), t(0x11), t(0x12), t(0x13), t(0x14), t(0x15), t(0x16), t(0x17),\ + t(0x18), t(0x19), t(0x1a), t(0x1b), t(0x1c), t(0x1d), t(0x1e), t(0x1f),\ + t(0x20), t(0x21), t(0x22), t(0x23), t(0x24), t(0x25), t(0x26), t(0x27),\ + t(0x28), t(0x29), t(0x2a), t(0x2b), t(0x2c), t(0x2d), t(0x2e), t(0x2f),\ + t(0x30), t(0x31), t(0x32), t(0x33), t(0x34), t(0x35), t(0x36), t(0x37),\ + t(0x38), t(0x39), t(0x3a), t(0x3b), t(0x3c), t(0x3d), t(0x3e), t(0x3f),\ + t(0x40), t(0x41), t(0x42), t(0x43), t(0x44), t(0x45), t(0x46), t(0x47),\ + t(0x48), t(0x49), t(0x4a), t(0x4b), t(0x4c), t(0x4d), t(0x4e), t(0x4f),\ + t(0x50), t(0x51), t(0x52), t(0x53), t(0x54), t(0x55), t(0x56), t(0x57),\ + t(0x58), t(0x59), t(0x5a), t(0x5b), t(0x5c), t(0x5d), t(0x5e), t(0x5f),\ + t(0x60), t(0x61), t(0x62), t(0x63), t(0x64), t(0x65), t(0x66), t(0x67),\ + t(0x68), t(0x69), t(0x6a), t(0x6b), t(0x6c), t(0x6d), t(0x6e), t(0x6f),\ + t(0x70), t(0x71), t(0x72), t(0x73), t(0x74), t(0x75), t(0x76), t(0x77),\ + t(0x78), t(0x79), t(0x7a), t(0x7b), t(0x7c), t(0x7d), t(0x7e), t(0x7f),\ + t(0x80), t(0x81), t(0x82), t(0x83), t(0x84), t(0x85), t(0x86), t(0x87),\ + t(0x88), t(0x89), t(0x8a), t(0x8b), t(0x8c), t(0x8d), t(0x8e), t(0x8f),\ + t(0x90), t(0x91), t(0x92), t(0x93), t(0x94), t(0x95), t(0x96), t(0x97),\ + t(0x98), t(0x99), t(0x9a), t(0x9b), t(0x9c), t(0x9d), t(0x9e), t(0x9f),\ + t(0xa0), t(0xa1), t(0xa2), t(0xa3), t(0xa4), t(0xa5), t(0xa6), t(0xa7),\ + t(0xa8), t(0xa9), t(0xaa), t(0xab), t(0xac), t(0xad), t(0xae), t(0xaf),\ + t(0xb0), t(0xb1), t(0xb2), t(0xb3), t(0xb4), t(0xb5), t(0xb6), t(0xb7),\ + t(0xb8), t(0xb9), t(0xba), t(0xbb), t(0xbc), t(0xbd), t(0xbe), t(0xbf),\ + t(0xc0), t(0xc1), t(0xc2), t(0xc3), t(0xc4), t(0xc5), t(0xc6), t(0xc7),\ + t(0xc8), t(0xc9), t(0xca), t(0xcb), t(0xcc), t(0xcd), t(0xce), t(0xcf),\ + t(0xd0), t(0xd1), t(0xd2), t(0xd3), t(0xd4), t(0xd5), t(0xd6), t(0xd7),\ + t(0xd8), t(0xd9), t(0xda), t(0xdb), t(0xdc), t(0xdd), t(0xde), t(0xdf),\ + t(0xe0), t(0xe1), t(0xe2), t(0xe3), t(0xe4), t(0xe5), t(0xe6), t(0xe7),\ + t(0xe8), t(0xe9), t(0xea), t(0xeb), t(0xec), t(0xed), t(0xee), t(0xef),\ + t(0xf0), t(0xf1), t(0xf2), t(0xf3), t(0xf4), t(0xf5), t(0xf6), t(0xf7),\ + t(0xf8), t(0xf9), t(0xfa), t(0xfb), t(0xfc), t(0xfd), t(0xfe), t(0xff) + +/* +// Encrypt/Decrypt S-box data +// (be parametrized by any transformation 't') +*/ +#define ENC_SBOX(t) \ + t(0x63), t(0x7c), t(0x77), t(0x7b), t(0xf2), t(0x6b), t(0x6f), t(0xc5),\ + t(0x30), t(0x01), t(0x67), t(0x2b), t(0xfe), t(0xd7), t(0xab), t(0x76),\ + t(0xca), t(0x82), t(0xc9), t(0x7d), t(0xfa), t(0x59), t(0x47), t(0xf0),\ + t(0xad), t(0xd4), t(0xa2), t(0xaf), t(0x9c), t(0xa4), t(0x72), t(0xc0),\ + t(0xb7), t(0xfd), t(0x93), t(0x26), t(0x36), t(0x3f), t(0xf7), t(0xcc),\ + t(0x34), t(0xa5), t(0xe5), t(0xf1), t(0x71), t(0xd8), t(0x31), t(0x15),\ + t(0x04), t(0xc7), t(0x23), t(0xc3), t(0x18), t(0x96), t(0x05), t(0x9a),\ + t(0x07), t(0x12), t(0x80), t(0xe2), t(0xeb), t(0x27), t(0xb2), t(0x75),\ + t(0x09), t(0x83), t(0x2c), t(0x1a), t(0x1b), t(0x6e), t(0x5a), t(0xa0),\ + t(0x52), t(0x3b), t(0xd6), t(0xb3), t(0x29), t(0xe3), t(0x2f), t(0x84),\ + t(0x53), t(0xd1), t(0x00), t(0xed), t(0x20), t(0xfc), t(0xb1), t(0x5b),\ + t(0x6a), t(0xcb), t(0xbe), t(0x39), t(0x4a), t(0x4c), t(0x58), t(0xcf),\ + t(0xd0), t(0xef), t(0xaa), t(0xfb), t(0x43), t(0x4d), t(0x33), t(0x85),\ + t(0x45), t(0xf9), t(0x02), t(0x7f), t(0x50), t(0x3c), t(0x9f), t(0xa8),\ + t(0x51), t(0xa3), t(0x40), t(0x8f), t(0x92), t(0x9d), t(0x38), t(0xf5),\ + t(0xbc), t(0xb6), t(0xda), t(0x21), t(0x10), t(0xff), t(0xf3), t(0xd2),\ + t(0xcd), t(0x0c), t(0x13), t(0xec), t(0x5f), t(0x97), t(0x44), t(0x17),\ + t(0xc4), t(0xa7), t(0x7e), t(0x3d), t(0x64), t(0x5d), t(0x19), t(0x73),\ + t(0x60), t(0x81), t(0x4f), t(0xdc), t(0x22), t(0x2a), t(0x90), t(0x88),\ + t(0x46), t(0xee), t(0xb8), t(0x14), t(0xde), t(0x5e), t(0x0b), t(0xdb),\ + t(0xe0), t(0x32), t(0x3a), t(0x0a), t(0x49), t(0x06), t(0x24), t(0x5c),\ + t(0xc2), t(0xd3), t(0xac), t(0x62), t(0x91), t(0x95), t(0xe4), t(0x79),\ + t(0xe7), t(0xc8), t(0x37), t(0x6d), t(0x8d), t(0xd5), t(0x4e), t(0xa9),\ + t(0x6c), t(0x56), t(0xf4), t(0xea), t(0x65), t(0x7a), t(0xae), t(0x08),\ + t(0xba), t(0x78), t(0x25), t(0x2e), t(0x1c), t(0xa6), t(0xb4), t(0xc6),\ + t(0xe8), t(0xdd), t(0x74), t(0x1f), t(0x4b), t(0xbd), t(0x8b), t(0x8a),\ + t(0x70), t(0x3e), t(0xb5), t(0x66), t(0x48), t(0x03), t(0xf6), t(0x0e),\ + t(0x61), t(0x35), t(0x57), t(0xb9), t(0x86), t(0xc1), t(0x1d), t(0x9e),\ + t(0xe1), t(0xf8), t(0x98), t(0x11), t(0x69), t(0xd9), t(0x8e), t(0x94),\ + t(0x9b), t(0x1e), t(0x87), t(0xe9), t(0xce), t(0x55), t(0x28), t(0xdf),\ + t(0x8c), t(0xa1), t(0x89), t(0x0d), t(0xbf), t(0xe6), t(0x42), t(0x68),\ + t(0x41), t(0x99), t(0x2d), t(0x0f), t(0xb0), t(0x54), t(0xbb), t(0x16) + +#define DEC_SBOX(t) \ + t(0x52), t(0x09), t(0x6a), t(0xd5), t(0x30), t(0x36), t(0xa5), t(0x38),\ + t(0xbf), t(0x40), t(0xa3), t(0x9e), t(0x81), t(0xf3), t(0xd7), t(0xfb),\ + t(0x7c), t(0xe3), t(0x39), t(0x82), t(0x9b), t(0x2f), t(0xff), t(0x87),\ + t(0x34), t(0x8e), t(0x43), t(0x44), t(0xc4), t(0xde), t(0xe9), t(0xcb),\ + t(0x54), t(0x7b), t(0x94), t(0x32), t(0xa6), t(0xc2), t(0x23), t(0x3d),\ + t(0xee), t(0x4c), t(0x95), t(0x0b), t(0x42), t(0xfa), t(0xc3), t(0x4e),\ + t(0x08), t(0x2e), t(0xa1), t(0x66), t(0x28), t(0xd9), t(0x24), t(0xb2),\ + t(0x76), t(0x5b), t(0xa2), t(0x49), t(0x6d), t(0x8b), t(0xd1), t(0x25),\ + t(0x72), t(0xf8), t(0xf6), t(0x64), t(0x86), t(0x68), t(0x98), t(0x16),\ + t(0xd4), t(0xa4), t(0x5c), t(0xcc), t(0x5d), t(0x65), t(0xb6), t(0x92),\ + t(0x6c), t(0x70), t(0x48), t(0x50), t(0xfd), t(0xed), t(0xb9), t(0xda),\ + t(0x5e), t(0x15), t(0x46), t(0x57), t(0xa7), t(0x8d), t(0x9d), t(0x84),\ + t(0x90), t(0xd8), t(0xab), t(0x00), t(0x8c), t(0xbc), t(0xd3), t(0x0a),\ + t(0xf7), t(0xe4), t(0x58), t(0x05), t(0xb8), t(0xb3), t(0x45), t(0x06),\ + t(0xd0), t(0x2c), t(0x1e), t(0x8f), t(0xca), t(0x3f), t(0x0f), t(0x02),\ + t(0xc1), t(0xaf), t(0xbd), t(0x03), t(0x01), t(0x13), t(0x8a), t(0x6b),\ + t(0x3a), t(0x91), t(0x11), t(0x41), t(0x4f), t(0x67), t(0xdc), t(0xea),\ + t(0x97), t(0xf2), t(0xcf), t(0xce), t(0xf0), t(0xb4), t(0xe6), t(0x73),\ + t(0x96), t(0xac), t(0x74), t(0x22), t(0xe7), t(0xad), t(0x35), t(0x85),\ + t(0xe2), t(0xf9), t(0x37), t(0xe8), t(0x1c), t(0x75), t(0xdf), t(0x6e),\ + t(0x47), t(0xf1), t(0x1a), t(0x71), t(0x1d), t(0x29), t(0xc5), t(0x89),\ + t(0x6f), t(0xb7), t(0x62), t(0x0e), t(0xaa), t(0x18), t(0xbe), t(0x1b),\ + t(0xfc), t(0x56), t(0x3e), t(0x4b), t(0xc6), t(0xd2), t(0x79), t(0x20),\ + t(0x9a), t(0xdb), t(0xc0), t(0xfe), t(0x78), t(0xcd), t(0x5a), t(0xf4),\ + t(0x1f), t(0xdd), t(0xa8), t(0x33), t(0x88), t(0x07), t(0xc7), t(0x31),\ + t(0xb1), t(0x12), t(0x10), t(0x59), t(0x27), t(0x80), t(0xec), t(0x5f),\ + t(0x60), t(0x51), t(0x7f), t(0xa9), t(0x19), t(0xb5), t(0x4a), t(0x0d),\ + t(0x2d), t(0xe5), t(0x7a), t(0x9f), t(0x93), t(0xc9), t(0x9c), t(0xef),\ + t(0xa0), t(0xe0), t(0x3b), t(0x4d), t(0xae), t(0x2a), t(0xf5), t(0xb0),\ + t(0xc8), t(0xeb), t(0xbb), t(0x3c), t(0x83), t(0x53), t(0x99), t(0x61),\ + t(0x17), t(0x2b), t(0x04), t(0x7e), t(0xba), t(0x77), t(0xd6), t(0x26),\ + t(0xe1), t(0x69), t(0x14), t(0x63), t(0x55), t(0x21), t(0x0c), t(0x7d), + +/* +// Internal cipher tables +*/ +extern const __ALIGN64 Ipp8u RijEncSbox[256]; /* pure encryption S-box */ +extern const __ALIGN64 Ipp8u RijDecSbox[256]; /* pure decryption S-box */ + +#endif /* _PCP_RIJTBLES_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpscramble.h b/external/crypto_px/sources/ippcp/src/pcpscramble.h new file mode 100644 index 0000000000..c26f96bd10 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpscramble.h @@ -0,0 +1,170 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PC_SCRAMBLE_H) +#define _PC_SCRAMBLE_H + +/* +// cpsScramblePut/cpsScrambleGet +// stores to/retrieves from pScrambleEntry position +// pre-computed data if fixed window method is used +*/ +__INLINE void cpScramblePut(Ipp8u* pArray, cpSize colummSize, + const Ipp32u* pData, cpSize dataSize) +{ + int i; + switch(colummSize) { + case 1: + dataSize *= sizeof(Ipp32u); + for(i=0; i=2; dataSize-=2, pArray+=CACHE_LINE_SIZE, pData+=2) { + ((Ipp32u*)pArray)[0] = pData[0]; + ((Ipp32u*)pArray)[1] = pData[1]; + } + if(dataSize) + ((Ipp32u*)pArray)[0] = pData[0]; + break; + case 16: + for(; dataSize>=4; dataSize-=4, pArray+=CACHE_LINE_SIZE, pData+=4) { + ((Ipp32u*)pArray)[0] = pData[0]; + ((Ipp32u*)pArray)[1] = pData[1]; + ((Ipp32u*)pArray)[2] = pData[2]; + ((Ipp32u*)pArray)[3] = pData[3]; + } + for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++) + ((Ipp32u*)pArray)[0] = pData[0]; + break; + case 32: + for(; dataSize>=8; dataSize-=8, pArray+=CACHE_LINE_SIZE, pData+=8) { + ((Ipp32u*)pArray)[0] = pData[0]; + ((Ipp32u*)pArray)[1] = pData[1]; + ((Ipp32u*)pArray)[2] = pData[2]; + ((Ipp32u*)pArray)[3] = pData[3]; + ((Ipp32u*)pArray)[4] = pData[4]; + ((Ipp32u*)pArray)[5] = pData[5]; + ((Ipp32u*)pArray)[6] = pData[6]; + ((Ipp32u*)pArray)[7] = pData[7]; + } + for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++) + ((Ipp32u*)pArray)[0] = pData[0]; + break; + default: + break; + } +} + + +/* +// Retrieve data from pArray +*/ +#define u8_to_u32(b0,b1,b2,b3, x) \ + ((x) = (b0), \ + (x)|=((b1)<<8), \ + (x)|=((b2)<<16), \ + (x)|=((b3)<<24)) +#define u16_to_u32(w0,w1, x) \ + ((x) = (w0), \ + (x)|=((w1)<<16)) +#define u32_to_u64(dw0,dw1, x) \ + ((x) = (Ipp64u)(dw0), \ + (x)|= (((Ipp64u)(dw1))<<32)) + +__INLINE void cpScrambleGet(Ipp32u* pData, cpSize dataSize, + const Ipp8u* pArray, cpSize colummSize) +{ + int i; + switch(colummSize) { + case 1: + for(i=0; i=2; dataSize-=2, pArray+=CACHE_LINE_SIZE, pData+=2) { + pData[0] = ((Ipp32u*)pArray)[0]; + pData[1] = ((Ipp32u*)pArray)[1]; + } + if(dataSize) + pData[0] = ((Ipp32u*)pArray)[0]; + break; + case 16: + for(; dataSize>=4; dataSize-=4, pArray+=CACHE_LINE_SIZE, pData+=4) { + pData[0] = ((Ipp32u*)pArray)[0]; + pData[1] = ((Ipp32u*)pArray)[1]; + pData[2] = ((Ipp32u*)pArray)[2]; + pData[3] = ((Ipp32u*)pArray)[3]; + + } + for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++) + pData[0] = ((Ipp32u*)pArray)[0]; + break; + case 32: + for(; dataSize>=8; dataSize-=8, pArray+=CACHE_LINE_SIZE, pData+=8) { + pData[0] = ((Ipp32u*)pArray)[0]; + pData[1] = ((Ipp32u*)pArray)[1]; + pData[2] = ((Ipp32u*)pArray)[2]; + pData[3] = ((Ipp32u*)pArray)[3]; + pData[4] = ((Ipp32u*)pArray)[4]; + pData[5] = ((Ipp32u*)pArray)[5]; + pData[6] = ((Ipp32u*)pArray)[6]; + pData[7] = ((Ipp32u*)pArray)[7]; + } + for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++) + pData[0] = ((Ipp32u*)pArray)[0]; + break; + default: + break; + } +} + +#endif /* _PC_SCRAMBLE_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpshsmgfca.c b/external/crypto_px/sources/ippcp/src/pcpshsmgfca.c new file mode 100644 index 0000000000..1fef36aef0 --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpshsmgfca.c @@ -0,0 +1,109 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" +#include "owncp.h" +#include "pcphash.h" +#include "pcptool.h" + + +/*F* +// Name: ippsMGF_SHA1 +// ippsMGF_SHA224 +// ippsMGF_SHA256 +// ippsMGF_SHA384 +// ippsMGF_SHA512 +// ippsMGF_MD5 +// +// Purpose: Mask Generation Functios. +// +// Returns: Reason: +// ippStsNullPtrErr pMask == NULL +// ippStsLengthErr seedLen <0 +// maskLen <0 +// ippStsNotSupportedModeErr if algID is not match to supported hash alg +// ippStsNoErr no errors +// +// Parameters: +// pSeed pointer to the input stream +// seedLen input stream length (bytes) +// pMaske pointer to the ouput mask +// maskLen desired length of mask (bytes) +// +*F*/ +IPPFUN(IppStatus, ippsMGF,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, IppHashAlgId hashAlg)) +{ + /* get algorithm id */ + hashAlg = cpValidHashAlg(hashAlg); + /* test hash alg */ + IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr); + + IPP_BAD_PTR1_RET(pMask); + IPP_BADARG_RET((seedLen<0)||(maskLen<0), ippStsLengthErr); + + { + /* hash specific */ + int hashSize = cpHashSize(hashAlg); + + int i, outLen; + + IppsHashState hashCtx; + ippsHashInit(&hashCtx, hashAlg); + + if(!pSeed) + seedLen = 0; + + for(i=0,outLen=0; outLen>24) & 0xFF); + cnt[1] = (Ipp8u)((i>>16) & 0xFF); + cnt[2] = (Ipp8u)((i>>8) & 0xFF); + cnt[3] = (Ipp8u)(i & 0xFF); + + cpReInitHash(&hashCtx, hashAlg); + ippsHashUpdate(pSeed, seedLen, &hashCtx); + ippsHashUpdate(cnt, 4, &hashCtx); + + if((outLen + hashSize) <= maskLen) { + ippsHashFinal(pMask+outLen, &hashCtx); + outLen += hashSize; + } + else { + Ipp8u md[BITS2WORD8_SIZE(IPP_SHA512_DIGEST_BITSIZE)]; + ippsHashFinal(md, &hashCtx); + CopyBlock(md, pMask+outLen, maskLen-outLen); + outLen = maskLen; + } + } + + return ippStsNoErr; + } +} diff --git a/external/crypto_px/sources/ippcp/src/pcptool.h b/external/crypto_px/sources/ippcp/src/pcptool.h new file mode 100644 index 0000000000..f4549263cd --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcptool.h @@ -0,0 +1,177 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#if !defined(_PC_TOOL_H) +#define _CP_TOOL_H + +/* copy data block */ +__INLINE void CopyBlock(const void* pSrc, void* pDst, cpSize numBytes) +{ + const Ipp8u* s = (Ipp8u*)pSrc; + Ipp8u* d = (Ipp8u*)pDst; + cpSize k; + for(k=0; k> (blkSize-numSize)%8 ); + + /* save crytical byte */ + Ipp8u save = (Ipp8u)( pCounter[maskPosition] & ~mask ); + + int len = BITS2WORD8_SIZE(blkSize); + Ipp32u carry = 1; + for(; (len>maskPosition) && carry; len--) { + Ipp32u x = pCounter[len-1] + carry; + pCounter[len-1] = (Ipp8u)x; + carry = (x>>8) & 0xFF; + } + + /* update crytical byte */ + pCounter[maskPosition] &= mask; + pCounter[maskPosition] |= save; +} + +#endif /* _CP_TOOL_H */ diff --git a/external/crypto_px/sources/ippcp/src/pcpver.c b/external/crypto_px/sources/ippcp/src/pcpver.c new file mode 100644 index 0000000000..694c6292ad --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpver.c @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "owndefs.h" + +#ifndef __OWNCP_H__ + #include "owncp.h" +#endif + +#include "pcpname.h" +#include "pcpver.h" + +#include "ippver.gen" diff --git a/external/crypto_px/sources/ippcp/src/pcpver.h b/external/crypto_px/sources/ippcp/src/pcpver.h new file mode 100644 index 0000000000..6e6e90fc7e --- /dev/null +++ b/external/crypto_px/sources/ippcp/src/pcpver.h @@ -0,0 +1,36 @@ +/* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include "ippver.h" +#define BUILD() 1043 +#define VERSION() BASE_VERSION(),BUILD() + +/* ////////////////////////// End of file "pcpver.h" ///////////////////////// */ diff --git a/external/epid/inc/epid_types.h b/external/epid/inc/epid_types.h new file mode 100644 index 0000000000..eb4b9d873f --- /dev/null +++ b/external/epid/inc/epid_types.h @@ -0,0 +1,305 @@ +/*############################################################################ + # Copyright 2016 Intel Corporation + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + ############################################################################*/ +#ifndef EPID_COMMON_TYPES_H_ +#define EPID_COMMON_TYPES_H_ + +#include // for CHAR_BIT + +/*! + * \file + * \brief SDK data types. + * \defgroup EpidTypes types + * \ingroup EpidCommon + * @{ + */ + +/// Recognized hash algorithms +typedef enum { + /// SHA-256 + kSha256 = 0, + /// SHA-384 + kSha384 = 1, + /// SHA-512 + kSha512 = 2, + /// SHA-512/256 + kSha512_256 = 3, + /// Reserved for SHA3/256 + kSha3_256 = 4, + /// Reserved for SHA3/384 + kSha3_384 = 5, + /// Reserved for SHA3/512 + kSha3_512 = 6, +} HashAlg; + +#pragma pack(1) +/// 8 bit octet string +typedef struct OctStr8 { + unsigned char data[8 / CHAR_BIT]; ///< 8 bit data +} OctStr8; +/// 32 bit octet string +typedef struct OctStr32 { + unsigned char data[32 / CHAR_BIT]; ///< 32 bit data +} OctStr32; +/// 64 bit octet string +typedef struct OctStr64 { + unsigned char data[64 / CHAR_BIT]; ///< 64 bit data +} OctStr64; +/// 128 bit octet string +typedef struct OctStr128 { + unsigned char data[128 / CHAR_BIT]; ///< 128 bit data +} OctStr128; +/// 256 bit octet string +typedef struct OctStr256 { + unsigned char data[256 / CHAR_BIT]; ///< 256 bit data +} OctStr256; + +/// Serialized BigNum +typedef struct BigNumStr { + OctStr256 data; ///< 256 bit octet string +} BigNumStr; +/// a number in [0, p-1] +typedef struct FpElemStr { + OctStr256 data; ///< 256 bit octet string +} FpElemStr; +/// a number in [0, q-1] +typedef struct FqElemStr { + OctStr256 data; ///< 256 bit octet string +} FqElemStr; + +/// Serialized G1 element +typedef struct G1ElemStr { + FqElemStr x; ///< an integer between [0, q-1] + FqElemStr y; ///< an integer between [0, q-1] +} G1ElemStr; + +/// Serialized G2 element +typedef struct G2ElemStr { + FqElemStr x[2]; ///< an integer between [0, q-1] + FqElemStr y[2]; ///< an integer between [0, q-1] +} G2ElemStr; + +/// Serialized GT element +typedef struct GtElemStr { + FqElemStr x[12]; ///< an integer between [0, q-1] +} GtElemStr; + +typedef FpElemStr PElemStr; +typedef OctStr32 RLver_t; +typedef OctStr32 RLCount; + +/// Intel(R) EPID 2.0 Parameters. +/*! + * INTEL(R) EPID 2.0 parameters: (p, q, b, t, neg, beta, xi0, xi1, + * g1, g2) + */ +typedef struct Epid2Params { + BigNumStr p; ///< a prime + BigNumStr q; ///< a prime + FqElemStr b; ///< an integer between [0, q-1] + OctStr64 t; ///< an integer + OctStr8 neg; ///< a boolean + FqElemStr beta; ///< an integer between [0, q-1] + FqElemStr xi[2]; ///< array of integers between [0, q-1] + G1ElemStr g1; ///< a generator (an element) of G1 + G2ElemStr g2; ///< a generator (an element) of G2 +} EPID2Params; + +/// group ID +typedef OctStr32 GroupID; + +/// Intel(R) EPID 2.0 group public key +/*! + * Group public key: (gid, h1, h2, w) + */ +typedef struct GroupPubKey { + GroupID gid; ///< group ID + G1ElemStr h1; ///< an element in G1 + G1ElemStr h2; ///< an element in G1 + G2ElemStr w; ///< an element in G2 +} GroupPubKey; + +/// Intel(R) EPID 2.0 issuing private key +/*! + * Issuing private key: (gid, gamma) + */ +typedef struct IPrivKey { + GroupID gid; ///< group ID + FpElemStr gamma; ///< an integer between [0, p-1] +} IPrivKey; + +/// Intel(R) EPID 2.0 private key +/*! + * Private key: (gid, A, x, f) + */ +typedef struct PrivKey { + GroupID gid; ///< group ID + G1ElemStr A; ///< an element in G1 + FpElemStr x; ///< an integer between [0, p-1] + FpElemStr f; ///< an integer between [0, p-1] +} PrivKey; + +/// 256 bit seed derived from fuse key +typedef OctStr256 Seed; + +/// Compressed private key +/*! + * Compressed Private key: (gid, A.x, seed) + */ +typedef struct CompressedPrivKey { + GroupID gid; ///< group ID + FqElemStr ax; ///< an integer between [0, p-1] + Seed seed; ///< 256 bit rekey seed +} CompressedPrivKey; + +/// Membership credential +/*! + * Membership credential: (gid, A, x) + */ +typedef struct MembershipCredential { + GroupID gid; ///< group ID + G1ElemStr A; ///< an element in G1 + FpElemStr x; ///< an integer between [0, p-1] +} MembershipCredential; + +/// 256 bit nonce chosen by issuer +typedef OctStr256 IssuerNonce; + +/// Join request +/*! + * Join request: (F, c, s) + */ +typedef struct JoinRequest { + G1ElemStr F; ///< an element in G1 + FpElemStr c; ///< an integer between [0, p-1] + FpElemStr s; ///< an integer between [0, p-1] +} JoinRequest; + +//////////////////////// + +/// Intel(R) EPID 2.0 basic signature. +/*! + * Basic signature: (B, K, T, c, sx, sf, sa, sb) + */ +typedef struct BasicSignature { + G1ElemStr B; ///< an element in G1 + G1ElemStr K; ///< an element in G1 + G1ElemStr T; ///< an element in G1 + FpElemStr c; ///< an integer between [0, p-1] + FpElemStr sx; ///< an integer between [0, p-1] + FpElemStr sf; ///< an integer between [0, p-1] + FpElemStr sa; ///< an integer between [0, p-1] + FpElemStr sb; ///< an integer between [0, p-1] +} BasicSignature; + +/// +/*! + * \brief + * non-revoked Proof. + * + * Non-revoked Proof: (T, c, smu, snu) + */ +typedef struct NrProof { + G1ElemStr T; ///< an element in G1 + FpElemStr c; ///< an integer between [0, p-1] + FpElemStr smu; ///< an integer between [0, p-1] + FpElemStr snu; ///< an integer between [0, p-1] +} NRProof; + +/// Intel(R) EPID 2.0 Signature +/*! + * Signature: (sigma0, RLver, n2, sigma[0], ..., sigma[n2-1]) + */ +typedef struct EpidSignature { + BasicSignature sigma0; ///< basic signature + OctStr32 rl_ver; ///< revocation list version number + OctStr32 n2; ///< number of entries in SigRL + NRProof sigma[1]; ///< array of non-revoked proofs (flexible array) +} EPIDSignature; + +/// private-key based revocation list. +/*! + * Private-key based revocation list PrivRL: (gid, RLver, n1, f[0], + * ..., f[n1-1]) + */ +typedef struct PrivRl { + GroupID gid; ///< group ID + OctStr32 version; ///< revocation list version number + OctStr32 n1; ///< number of entries in PrivRL + FpElemStr f[1]; ///< integers between [1, p-1] (flexible array) +} PrivRl; + +/// entry in SigRL (B,K) +typedef struct SigRlEntry { + G1ElemStr b; ///< an element of G1 + G1ElemStr k; ///< an element of G1 +} SigRLEntry; + +/// signature based revocation list +/*! + * Signature based revocation list SigRL: (gid, RLver, n2, B[0], + * K[0], ..., B[n2-1], K[n2-1]) + */ +typedef struct SigRl { + GroupID gid; ///< group ID + OctStr32 RLver; ///< revocation list version number + OctStr32 n2; ///< number of entries in SigRL + SigRLEntry BK[1]; ///< revoked Bs and Ks (flexible array) +} SigRL; + +/// group revocation list +/*! + * Group revocation list GroupRL: (RLver, n3, gid[0], ..., + * gid[n3-1]) + */ +typedef struct GroupRl { + OctStr32 version; ///< revocation list version number + OctStr32 n3; ///< number of entries in GroupRL + GroupID gid[1]; ///< revoked group IDs (flexible array) +} GroupRl; + +/*! verifier revocation list + * Verifier revocation list VerifierRL: (gid, B, RLver, n4, K[0], + * ..., K[n4-1]) + */ +typedef struct VerifierRl { + GroupID gid; ///< group ID + G1ElemStr B; ///< an element in G1 + OctStr32 version; ///< revocation list version number + OctStr32 n4; ///< number of entries in VerifierRL + G1ElemStr K[1]; ///< elements in G1 (flexible array) +} VerifierRl; + +/// element to store seed values for later rekey +typedef G1ElemStr ReKeySeed; + +/// Serialized Fq2 element +typedef struct Fq2ElemStr { + FqElemStr a[2]; ///< polynomial coefficient +} Fq2ElemStr; + +/// Serialized Fq2^3 element +typedef struct Fq6ElemStr { + Fq2ElemStr a[3]; ///< polynomial coefficient +} Fq6ElemStr; + +/// Serialized Fq2^3^2 element +typedef struct Fq12ElemStr { + Fq6ElemStr a[2]; ///< polynomial coefficient +} Fq12ElemStr; +#pragma pack() + +/*! @} */ +#endif // EPID_COMMON_TYPES_H_ diff --git a/external/rdrand/rdrand.h b/external/rdrand/rdrand.h new file mode 100644 index 0000000000..ee25cf5986 --- /dev/null +++ b/external/rdrand/rdrand.h @@ -0,0 +1,156 @@ +/* Copyright © 2012, Intel Corporation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +- Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +/*! \file rdrand.h + * \brief Public header for rdrand API. + * + * This is the public header for the rdrand API. It exposes the three public + * APIs, which access the rdrand instruction for various data sizes. + */ + +#ifndef RDRAND_H +#define RDRAND_H + +#include + +/*! \def RDRAND_SUCCESS + * The rdrand call was successful, the hardware was ready, and a random + * number was returned. + */ +#define RDRAND_SUCCESS 1 + +/*! \def RDRAND_NOT_READY + * The rdrand call was unsuccessful, the hardware was not ready, and a + * random number was not returned. + */ +#define RDRAND_NOT_READY -1 + +/*! \def RDRAND_SUPPORTED + * The rdrand instruction is supported by the host hardware. + */ +#define RDRAND_SUPPORTED -2 + +/*! \def RDRAND_UNSUPPORTED + * The rdrand instruction is unsupported by the host hardware. + */ +#define RDRAND_UNSUPPORTED -3 + +/*! \def RDRAND_SUPPORT_UNKNOWN + * Whether or not the hardware supports the rdrand instruction is unknown + */ +#define RDRAND_SUPPORT_UNKNOWN -4 + +#ifdef __cplusplus +extern "C" { +#endif +/*! \brief Calls rdrand for a 16-bit result. + * + * This function calls rdrand requesting a 16-bit result. By default, it will + * perform only a single call to rdrand, returning success or failure. On + * success, the data is written to memory pointed to by x. If the int retry is + * true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at + * which point it write the random data and return success, or fails This + * function also ensures that rdrand is supported by the cpu or fails + * gracefully. + * + * \param x pointer to memory to store the random result + * \param retry int to determine whether or not to loop until rdrand succeeds + * or until 10 failed attempts + * + * \return whether or not the call was successful, or supported at all + */ +int rdrand_16(uint16_t* x, int retry); + +/*! \brief Calls rdrand for a 32-byte result. + * + * This function calls rdrand requesting a 32-bit result. By default, it will + * perform only a single call to rdrand, returning success or failure. On + * success, the data is written to memory pointed to by x. If the int retry is + * true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at + * which point it write the random data and return success, or fails This + * function also ensures that rdrand is supported by the cpu or fails + * gracefully. + * + * \param x pointer to memory to store the random result + * \param retry int to determine whether or not to loop until rdrand succeeds + * or until 10 failed attempts + * + * \return whether or not the call was successful, or supported at all + */ +int rdrand_32(uint32_t* x, int retry); + +/*! \brief Calls rdrand for a 64-byte result. + * + * This function calls rdrand requesting a 64-byte result. By default, it will + * perform only a single call to rdrand, returning success or failure. On + * success, the data is written to memory pointed to by x. If the int retry is + * true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at + * which point it write the random data and return success, or fails This + * function also ensures that rdrand is supported by the cpu or fails + * gracefully. + * + * \param x pointer to memory to store the random result + * \param retry int to determine whether or not to loop until rdrand succeeds + * or until 10 failed attempts + * + * \return whether or not the call was successful, or supported at all + */ +int rdrand_64(uint64_t* x, int retry); + +/*! \brief Calls rdrand to obtain multiple 64-byte results. + * + * This function calls rdrand requesting multiple 64-byte results. On + * success, the data is written to memory pointed to by x. This function + * calls rdrand_64 and if any of those invocations fail, this function + * fails. It returns the same values as rdrand_64. + */ +int rdrand_get_n_64(unsigned int n, uint64_t* x); + +/*! \brief Calls rdrand to obtain multiple 32-byte results. + * + * This function calls rdrand requesting multiple 32-byte results. On + * success, the data is written to memory pointed to by x. This function + * calls rdrand_32 and if any of those invocations fail, this function + * fails. It returns the same values as rdrand_32. + */ +int rdrand_get_n_32(unsigned int n, uint32_t* x); + +/*! \brief Calls rdrand to fill a buffer of arbitrary size with random bytes. + * + * This function calls rdrand requesting multiple 64- or 32-bit results to + * fill a buffer of arbitrary size. + * + * \param n size of the buffer to fill with random bytes + * \param buffer pointer to memory to store the random result + * + * \return whether or not the call was successful, or supported at all + */ + +int rdrand_get_bytes(unsigned int n, unsigned char *buffer); +#ifdef __cplusplus +}; +#endif + +#endif // RDRAND_H diff --git a/external/rdrand/src/Makefile.in b/external/rdrand/src/Makefile.in new file mode 100644 index 0000000000..5a4ec8c421 --- /dev/null +++ b/external/rdrand/src/Makefile.in @@ -0,0 +1,29 @@ +PACKAGE_NAME=@PACKAGE_NAME@ +PACKAGE_VERSION=@PACKAGE_VERSION@ +CC=@CC@ +CFLAGS=@CFLAGS@ -O2 +AR=ar + +TEST_OBJ=main.o + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +all: bin lib + +bin: test + +lib: librdrand.a + +librdrand.a: rdrand.o + $(AR) rcs $@ $? + +test: $(TEST_OBJ) librdrand.a + $(CC) $(CFLAGS) -o $@ $(TEST_OBJ) -L. -lrdrand + +clean: + rm -f *.o librdrand.a test + +distclean: clean + rm -f Makefile config.guess config.status config.log config.h + diff --git a/external/rdrand/src/README b/external/rdrand/src/README new file mode 100644 index 0000000000..2535036019 --- /dev/null +++ b/external/rdrand/src/README @@ -0,0 +1,26 @@ +Rdrand Library +---------------------------- +Welcome to the Rdrand Library. This is a simple library aimed at +bringing suport for the rdrdand instruction feature of Intel processors +starting with the Intel(r) microarchitecture code name Ivy Bridge, (also known +as 3rd Generation Intel Core(tm) processor) to users with toolchains that do +not support this new feature. For more information on the rdrand instruction, +please visit http://software.intel.com/en-us/articles/download-the-latest-bull-mountain-software-implementation-guide/ +The new rdrand instruction is innovative hardware approach to high-quality, +high-performance entropy and random number generation. Because the many of +compiler toolchains do not support this new instruction, this library was +created to facilitate easy access to it. The idea is simple: link to a +built static library and enjoy the new feature! Or, if you wish the full +source code is provided. + +Documentation is stored in doc/--Point your browser to doc/html/index.html to get +started. Included in the documentation is more information about the +rdrand instruction, build instructions, and information on supported +toolchains. + +There is also a demonstration project using Microsoft* Visual Studio* project +file named "Test" that demonstrate linking to the generated library. + +Copyright(C) 2012 Intel Corporation. All rights reserved. + +*Other names and brands may be claimed as the property of others \ No newline at end of file diff --git a/external/rdrand/src/config.h.in b/external/rdrand/src/config.h.in new file mode 100644 index 0000000000..1908799d2f --- /dev/null +++ b/external/rdrand/src/config.h.in @@ -0,0 +1,53 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if using gcc and it supports RDRAND */ +#undef HAVE_RDRAND_IN_GCC + diff --git a/external/rdrand/src/configure b/external/rdrand/src/configure new file mode 100755 index 0000000000..241321dfd5 --- /dev/null +++ b/external/rdrand/src/configure @@ -0,0 +1,4284 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.68 for librdrand 1.1. +# +# Report bugs to . +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and Intel Software +$0: Network about your system, including any error possibly +$0: output before this message. Then install a modern +$0: shell, or manually run the script under such a shell if +$0: you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='librdrand' +PACKAGE_TARNAME='librdrand' +PACKAGE_VERSION='1.1' +PACKAGE_STRING='librdrand 1.1' +PACKAGE_BUGREPORT='Intel Software Network' +PACKAGE_URL='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures librdrand 1.1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/librdrand] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of librdrand 1.1:";; + esac + cat <<\_ACEOF + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +librdrand configure 1.1 +generated by GNU Autoconf 2.68 + +Copyright (C) 2010 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------------- ## +## Report this to Intel Software Network ## +## ------------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by librdrand $as_me 1.1, which was +generated by GNU Autoconf 2.68. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +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 || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in icc gcc + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in icc gcc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +if test "x$CC" = "xgcc" +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gcc knows the rdrand instruction" >&5 +$as_echo_n "checking if gcc knows the rdrand instruction... " >&6; } + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + asm("rdrand %eax;"); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + $as_echo "#define HAVE_RDRAND_IN_GCC 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in inttypes.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" +if test "x$ac_cv_header_inttypes_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_INTTYPES_H 1 +_ACEOF + +fi + +done + + +ac_config_files="$ac_config_files Makefile" + + +ac_config_headers="$ac_config_headers config.h" + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by librdrand $as_me 1.1, which was +generated by GNU Autoconf 2.68. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +librdrand config.status 1.1 +configured by $0, generated by GNU Autoconf 2.68, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2010 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + + diff --git a/external/rdrand/src/configure.ac b/external/rdrand/src/configure.ac new file mode 100644 index 0000000000..162c4ddf4b --- /dev/null +++ b/external/rdrand/src/configure.ac @@ -0,0 +1,21 @@ +AC_INIT([librdrand], [1.1], [Intel Software Network]) + +AC_PROG_CC([icc gcc]) + +if test "x$CC" = "xgcc" +then + AC_MSG_CHECKING([if gcc knows the rdrand instruction]) + AC_TRY_COMPILE([], [ + asm("rdrand %eax;"); + ], AC_DEFINE([HAVE_RDRAND_IN_GCC]) AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) +fi + +AC_CHECK_HEADERS([inttypes.h]) + +AC_CONFIG_FILES([Makefile]) + +AC_CONFIG_HEADERS([config.h]) + +AC_OUTPUT + + diff --git a/external/rdrand/src/main.c b/external/rdrand/src/main.c new file mode 100644 index 0000000000..02bd704f41 --- /dev/null +++ b/external/rdrand/src/main.c @@ -0,0 +1,95 @@ +/* Copyright © 2012, Intel Corporation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +- Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include +#include + +#include "rdrand.h" + +#define BUFFSIZE 1275 + +int main() +{ + int r; + uint16_t u16; + uint32_t u32; + uint64_t u64; + uint32_t array32[10]; + uint64_t array64[10]; + unsigned char buffer[BUFFSIZE]; + + r = rdrand_16(&u16, 10); + if (r != RDRAND_SUCCESS ) printf("rdrand instruction failed with code %d\n", r); + + r = rdrand_32(&u32, 10); + if (r != RDRAND_SUCCESS ) printf("rdrand instruction failed with code %d\n", r); + + r = rdrand_64(&u64, 10); + if (r != RDRAND_SUCCESS ) printf("rdrand instruction failed with code %d\n", r); + + printf("uint16: %u\n", u16); + printf("uint32: %u\n", u32); + printf("uint64: %llu\n", (unsigned long long) u64); + + r = rdrand_get_n_32(10, array32); + if ( r == RDRAND_SUCCESS ) { + int i; + printf("\n10 uint32's:\n"); + for (i= 0; i< 10; ++i) { + printf("%u\n", array32[i]); + } + } else printf("rdrand instruction failed with code %d\n", r); + + r = rdrand_get_n_64(10, array64); + if ( r == RDRAND_SUCCESS ) { + int i; + printf("\n10 uint64's:\n"); + for (i= 0; i< 10; ++i) { + printf("%llu\n", (unsigned long long) array64[i]); + } + } else printf("rdrand instruction failed with code %d\n", r); + + memset(buffer, 0, BUFFSIZE); + r = rdrand_get_bytes(BUFFSIZE, buffer); + if ( r == RDRAND_SUCCESS ) { + int i, j; + printf("\nBuffer of %ld bytes:\n", (long) BUFFSIZE); + + j= 0; + for (i= 0; i< BUFFSIZE; ++i) + { + printf("%02x ", buffer[i]); + + ++j; + + if ( j == 16 ) { + j= 0; + printf("\n"); + } else if ( j == 8 ) printf(" "); + + } + printf("\n"); + } else printf("rdrand instruction failed with code %d\n", r); +} diff --git a/external/rdrand/src/rdrand.c b/external/rdrand/src/rdrand.c new file mode 100644 index 0000000000..789b4f06cb --- /dev/null +++ b/external/rdrand/src/rdrand.c @@ -0,0 +1,385 @@ +/* Copyright © 2012, Intel Corporation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +- Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +#include "rdrand.h" + +#ifdef __INTEL_COMPILER +# include +#endif + +#include +#include + +/*! \def RDRAND_MASK +* The bit mask used to examine the ecx register returned by cpuid. The + * 30th bit is set. + */ +#define RDRAND_MASK 0x40000000 + +#define RETRY_LIMIT 10 + +#if defined(_WIN64)||defined(_LP64) +# define _IS64BIT +#endif + +#ifdef _IS64BIT +typedef uint64_t _wordlen_t; +#else +typedef uint32_t _wordlen_t; +#endif + +/* Mimic the Intel compiler's intrinsics as best we can if we are using gcc */ + +#ifdef __GNUC__ + +# define __cpuid(x,y) asm volatile("cpuid":"=a"(x[0]),"=b"(x[1]),"=c"(x[2]),"=d"(x[3]):"a"(y)) + +/* RDRAND isn't a supported instruction until gcc 4.6 */ + +# ifdef HAVE_RDRAND_IN_GCC + +# define _rdrand_step(x) ({ unsigned char err; asm volatile("rdrand %0; setc %1":"=r"(*x), "=qm"(err)); err; }) + +# define _rdrand16_step(x) _rdrand_step(x) +# define _rdrand32_step(x) _rdrand_step(x) + +# else + + /* Our version of gcc is too old, so we need to use byte code */ + +# define _rdrand16_step(x) ({ unsigned char err; asm volatile(".byte 0x66; .byte 0x0f; .byte 0xc7; .byte 0xf0; setc %1":"=a"(*x), "=qm"(err)); err; }) +# define _rdrand32_step(x) ({ unsigned char err; asm volatile(".byte 0x0f; .byte 0xc7; .byte 0xf0; setc %1":"=a"(*x), "=qm"(err)); err; }) + +# endif + +#ifdef _IS64BIT + +# ifdef HAVE_RDRAND_IN_GCC +# define _rdrand64_step(x) _rdrand_step(x) +# else + + /* Our version of gcc is too old, so we need to use byte code */ + +# define _rdrand64_step(x) ({ unsigned char err; asm volatile(".byte 0x48; .byte 0x0f; .byte 0xc7; .byte 0xf0; setc %1":"=a"(*x), "=qm"(err)); err; }) + +# endif + +#else + +/* + * The Intel compiler intrinsic for generating a 64-bit rand on a 32-bit + * system maps to two 32-bit RDRAND instructions. Because of the way + * the way the DRNG is implemented you can do this up to a 128-bit value + * (for crypto purposes) before you no longer have multiplicative + * prediction resistance. + * + * Note that this isn't very efficient. If you need 64-bit values + * you should really be on a 64-bit system. + */ + +int _rdrand64_step (uint64_t *x); + +int _rdrand64_step (uint64_t *x) +{ + uint32_t xlow, xhigh; + int rv; + + if ( (rv= _rdrand32_step(&xlow)) != RDRAND_SUCCESS ) return rv; + if ( (rv= _rdrand32_step(&xhigh)) != RDRAND_SUCCESS ) return rv; + + *x= (uint64_t) xlow | ((uint64_t)xhigh<<32); + + return RDRAND_SUCCESS; +} + +# endif + +#endif + +/*! \brief Queries cpuid to see if rdrand is supported + * + * rdrand support in a CPU is determined by examining the 30th bit of the ecx + * register after calling cpuid. + * + * \return bool of whether or not rdrand is supported + */ + +int RdRand_cpuid() +{ + int info[4] = {-1, -1, -1, -1}; + + /* Are we on an Intel processor? */ + + __cpuid(info, 0); + + if ( memcmp((void *) &info[1], (void *) "Genu", 4) != 0 || + memcmp((void *) &info[3], (void *) "ineI", 4) != 0 || + memcmp((void *) &info[2], (void *) "ntel", 4) != 0 ) { + + return 0; + } + + /* Do we have RDRAND? */ + + __cpuid(info, /*feature bits*/1); + + int ecx = info[2]; + if ((ecx & RDRAND_MASK) == RDRAND_MASK) + return 1; + else + return 0; +} + +/*! \brief Determines whether or not rdrand is supported by the CPU + * + * This function simply serves as a cache of the result provided by cpuid, + * since calling cpuid is so expensive. The result is stored in a static + * variable to save from calling cpuid on each invocation of rdrand. + * + * \return bool/int of whether or not rdrand is supported + */ + +int RdRand_isSupported() +{ + static int supported = RDRAND_SUPPORT_UNKNOWN; + + if (supported == RDRAND_SUPPORT_UNKNOWN) + { + if (RdRand_cpuid()) + supported = RDRAND_SUPPORTED; + else + supported = RDRAND_UNSUPPORTED; + } + + return (supported == RDRAND_SUPPORTED) ? 1 : 0; +} + +int rdrand_16(uint16_t* x, int retry) +{ + if (RdRand_isSupported()) + { + if (retry) + { + int i; + + for (i = 0; i < RETRY_LIMIT; i++) + { + if (_rdrand16_step(x)) + return RDRAND_SUCCESS; + } + + return RDRAND_NOT_READY; + } + else + { + if (_rdrand16_step(x)) + return RDRAND_SUCCESS; + else + return RDRAND_NOT_READY; + } + } + else + { + return RDRAND_UNSUPPORTED; + } +} + +int rdrand_32(uint32_t* x, int retry) +{ + if (RdRand_isSupported()) + { + if (retry) + { + int i; + + for (i= 0; i < RETRY_LIMIT; i++) + { + if (_rdrand32_step(x)) + return RDRAND_SUCCESS; + } + + return RDRAND_NOT_READY; + } + else + { + if (_rdrand32_step(x)) + return RDRAND_SUCCESS; + else + return RDRAND_NOT_READY; + } + } + else + { + return RDRAND_UNSUPPORTED; + } +} + +int rdrand_64(uint64_t* x, int retry) +{ + if (RdRand_isSupported()) + { + if (retry) + { + int i; + + for (i= 0; i < RETRY_LIMIT; i++) + { + if (_rdrand64_step(x)) + return RDRAND_SUCCESS; + } + + return RDRAND_NOT_READY; + } + else + { + if (_rdrand64_step(x)) + return RDRAND_SUCCESS; + else + return RDRAND_NOT_READY; + } + } + else + { + return RDRAND_UNSUPPORTED; + } +} + +int rdrand_get_n_64(unsigned int n, uint64_t *dest) +{ + int success; + int count; + unsigned int i; + + for (i=0; i 0) + { +#ifdef _IS64BIT + if ( (success= rdrand_64((uint64_t *) &temprand, 1)) != RDRAND_SUCCESS) return success; +#else + if ( (success= rdrand_32((uint32_t *) &temprand, 1)) != RDRAND_SUCCESS) return success; +#endif + } + + /* populate the starting misaligned block */ + for (i = 0; i> 8; + } + + /* populate the central aligned block. Fail out if retry fails */ + +#ifdef _IS64BIT + if ( (success= rdrand_get_n_64(length, (uint64_t *)(blockstart))) != RDRAND_SUCCESS) return success; +#else + if ( (success= rdrand_get_n_32(length, (uint32_t *)(blockstart))) != RDRAND_SUCCESS) return success; +#endif + /* populate the final misaligned block */ + if (residual > 0) + { +#ifdef _IS64BIT + if ((success= rdrand_64((uint64_t *)&temprand, 1)) != RDRAND_SUCCESS) return success; +#else + if ((success= rdrand_32((uint32_t *)&temprand, 1)) != RDRAND_SUCCESS) return success; +#endif + + for (i = 0; i> 8; + } + } + + return RDRAND_SUCCESS; +} + + diff --git a/external/rdrand/src/rdrand.h b/external/rdrand/src/rdrand.h new file mode 100644 index 0000000000..2c6f9be8cd --- /dev/null +++ b/external/rdrand/src/rdrand.h @@ -0,0 +1,169 @@ +/* Copyright © 2012, Intel Corporation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +- Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + +/*! \file rdrand.h + * \brief Public header for rdrand API. + * + * This is the public header for the rdrand API. It exposes the three public + * APIs, which access the rdrand instruction for various data sizes. + */ + +#ifndef RDRAND_H +#define RDRAND_H + +#include "config.h" + +#if HAVE_INTTYPES_H +#include +#endif + +#ifdef _MSC_VER + /* MSVC specific */ + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int64 uint64_t; +#endif + +/*! \def RDRAND_SUCCESS + * The rdrand call was successful, the hardware was ready, and a random + * number was returned. + */ +#define RDRAND_SUCCESS 1 + +/*! \def RDRAND_NOT_READY + * The rdrand call was unsuccessful, the hardware was not ready, and a + * random number was not returned. + */ +#define RDRAND_NOT_READY -1 + +/*! \def RDRAND_SUPPORTED + * The rdrand instruction is supported by the host hardware. + */ +#define RDRAND_SUPPORTED -2 + +/*! \def RDRAND_UNSUPPORTED + * The rdrand instruction is unsupported by the host hardware. + */ +#define RDRAND_UNSUPPORTED -3 + +/*! \def RDRAND_SUPPORT_UNKNOWN + * Whether or not the hardware supports the rdrand instruction is unknown + */ +#define RDRAND_SUPPORT_UNKNOWN -4 + +/*! \brief Calls rdrand for a 16-bit result. + * + * This function calls rdrand requesting a 16-bit result. By default, it will + * perform only a single call to rdrand, returning success or failure. On + * success, the data is written to memory pointed to by x. If the int retry is + * true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at + * which point it write the random data and return success, or fails This + * function also ensures that rdrand is supported by the cpu or fails + * gracefully. + * + * \param x pointer to memory to store the random result + * \param retry int to determine whether or not to loop until rdrand succeeds + * or until 10 failed attempts + * + * \return whether or not the call was successful, or supported at all + */ +int rdrand_16(uint16_t* x, int retry); + +/*! \brief Calls rdrand for a 32-byte result. + * + * This function calls rdrand requesting a 32-bit result. By default, it will + * perform only a single call to rdrand, returning success or failure. On + * success, the data is written to memory pointed to by x. If the int retry is + * true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at + * which point it write the random data and return success, or fails This + * function also ensures that rdrand is supported by the cpu or fails + * gracefully. + * + * \param x pointer to memory to store the random result + * \param retry int to determine whether or not to loop until rdrand succeeds + * or until 10 failed attempts + * + * \return whether or not the call was successful, or supported at all + */ +int rdrand_32(uint32_t* x, int retry); + +/*! \brief Calls rdrand for a 64-byte result. + * + * This function calls rdrand requesting a 64-byte result. By default, it will + * perform only a single call to rdrand, returning success or failure. On + * success, the data is written to memory pointed to by x. If the int retry is + * true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at + * which point it write the random data and return success, or fails This + * function also ensures that rdrand is supported by the cpu or fails + * gracefully. + * + * Calling rdrand_64 on a 32-bit system is inefficient as it makes two calls + * to rdrand_32 to produce a single 64-bit value, using a shift to populate + * the high bits. The physical construction of the DRNG allows you to do this + * up to a 128-bit value while retaining multiplicative prediction resistance + * (i.e., don't do this to generate numbers larger than 128 bits). + * + * \param x pointer to memory to store the random result + * \param retry int to determine whether or not to loop until rdrand succeeds + * or until 10 failed attempts + * + * \return whether or not the call was successful, or supported at all + */ +int rdrand_64(uint64_t* x, int retry); + +/*! \brief Calls rdrand to obtain multiple 64-byte results. + * + * This function calls rdrand requesting multiple 64-byte results. On + * success, the data is written to memory pointed to by x. This function + * calls rdrand_64 and if any of those invocations fail, this function + * fails. It returns the same values as rdrand_64. + * + * This function is inefficient on 32-bit systems. + */ +int rdrand_get_n_64(unsigned int n, uint64_t* x); + +/*! \brief Calls rdrand to obtain multiple 32-byte results. + * + * This function calls rdrand requesting multiple 32-byte results. On + * success, the data is written to memory pointed to by x. This function + * calls rdrand_32 and if any of those invocations fail, this function + * fails. It returns the same values as rdrand_32. + */ +int rdrand_get_n_32(unsigned int n, uint32_t* x); + +/*! \brief Calls rdrand to fill a buffer of arbitrary size with random bytes. + * + * This function calls rdrand requesting multiple 64- or 32-bit results to + * fill a buffer of arbitrary size. + * + * \param n size of the buffer to fill with random bytes + * \param buffer pointer to memory to store the random result + * + * \return whether or not the call was successful, or supported at all + */ + +int rdrand_get_bytes(unsigned int n, unsigned char *buffer); + +#endif // RDRAND_H diff --git a/external/sgx_libm/ia32/acos_wmt.S b/external/sgx_libm/ia32/acos_wmt.S new file mode 100644 index 0000000000..d3163b7aca --- /dev/null +++ b/external/sgx_libm/ia32/acos_wmt.S @@ -0,0 +1,1927 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acos_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin acos + .text + .align 16,0x90 + .globl acos +acos: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd 6048(%ebx), %xmm4 + movsd 6080(%ebx), %xmm3 + xorpd %xmm5, %xmm5 + movsd 6064(%ebx), %xmm2 + movapd %xmm0, %xmm1 + movsd %xmm0, 8(%esp) + psrlq $44, %xmm0 + movd %xmm0, %edx + movapd %xmm1, %xmm7 + movl $8192, %ecx + pinsrw $2, %ecx, %xmm5 + movapd %xmm1, %xmm0 + movl $524287, %eax + andl %edx, %eax + subl $260864, %eax + cmpl $955, %eax + jae .L_2TAG_PACKET_0.0.3 + mulsd %xmm1, %xmm1 + andl $65535, %edx + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + andpd %xmm7, %xmm2 + andl $-4, %edx + subl $64256, %edx + movsd 3840(%ebx,%edx,2), %xmm1 + orpd %xmm5, %xmm2 + movapd (%ebx,%edx,4), %xmm4 + movapd %xmm7, %xmm6 + addsd %xmm2, %xmm7 + subsd %xmm2, %xmm0 + mulsd %xmm0, %xmm7 + mulsd %xmm1, %xmm6 + mulsd %xmm2, %xmm3 + movapd %xmm6, %xmm1 + addsd %xmm3, %xmm6 + divsd %xmm6, %xmm7 + movsd 5976(%ebx), %xmm0 + movsd 5960(%ebx), %xmm5 + subsd %xmm3, %xmm1 + psrlq $63, %xmm2 + movapd %xmm1, %xmm3 + psllq $63, %xmm2 + mulsd %xmm1, %xmm1 + pshufd $68, %xmm2, %xmm2 + movsd 5968(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm0 + xorpd %xmm2, %xmm4 + mulsd %xmm3, %xmm5 + subpd 5888(%ebx), %xmm4 + mulsd %xmm1, %xmm3 + addsd %xmm6, %xmm0 + mulsd %xmm3, %xmm0 + subsd %xmm4, %xmm5 + pshufd $238, %xmm4, %xmm4 + addsd %xmm5, %xmm0 + subsd %xmm7, %xmm0 + subsd %xmm4, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + subl $955, %eax + cmpl $65, %eax + jae .L_2TAG_PACKET_2.0.3 + psrlq $38, %xmm7 + psllq $38, %xmm7 + pmovmskb %xmm0, %eax + andnpd %xmm0, %xmm4 + subsd %xmm7, %xmm1 + movapd %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + addsd %xmm6, %xmm0 + orpd %xmm4, %xmm5 + subsd %xmm7, %xmm3 + mulsd %xmm1, %xmm0 + movapd %xmm3, %xmm4 + subsd %xmm0, %xmm3 + sqrtsd %xmm3, %xmm3 + andl $128, %eax + shrl $7, %eax + negl %eax + movapd %xmm3, %xmm7 + andpd %xmm3, %xmm2 + psllq $2, %xmm3 + pextrw $3, %xmm3, %edx + orpd %xmm5, %xmm2 + movd %eax, %xmm3 + pshufd $0, %xmm3, %xmm3 + subl $65216, %edx + addl %edx, %edx + mulsd 3840(%ebx,%edx,4), %xmm7 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + subsd %xmm7, %xmm6 + andpd 5904(%ebx), %xmm3 + addsd %xmm1, %xmm6 + subsd %xmm2, %xmm4 + addsd %xmm7, %xmm7 + movsd 5960(%ebx), %xmm5 + subsd %xmm0, %xmm4 + addsd %xmm6, %xmm7 + movsd 5976(%ebx), %xmm0 + divsd %xmm7, %xmm4 + movsd 5968(%ebx), %xmm2 + addpd (%ebx,%edx,8), %xmm3 + movapd %xmm6, %xmm1 + mulsd %xmm6, %xmm6 + mulsd %xmm6, %xmm0 + mulsd %xmm6, %xmm1 + mulsd %xmm1, %xmm5 + mulsd %xmm6, %xmm1 + addsd %xmm2, %xmm0 + pxor %xmm6, %xmm6 + mulsd %xmm1, %xmm0 + addsd %xmm3, %xmm5 + addsd %xmm5, %xmm0 + andl $32768, %eax + pinsrw $3, %eax, %xmm6 + movapd %xmm4, %xmm5 + pshufd $238, %xmm3, %xmm3 + addsd %xmm3, %xmm4 + subsd %xmm4, %xmm3 + addsd %xmm3, %xmm5 + addsd %xmm5, %xmm0 + addsd %xmm4, %xmm0 + xorpd %xmm6, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + addl $15291, %eax + cmpl $14336, %eax + jae .L_2TAG_PACKET_3.0.3 + unpcklpd %xmm0, %xmm0 + movapd 5984(%ebx), %xmm6 + unpcklpd %xmm0, %xmm1 + movapd 6000(%ebx), %xmm2 + movapd 6016(%ebx), %xmm4 + mulpd %xmm0, %xmm0 + movapd 5888(%ebx), %xmm5 + mulpd %xmm0, %xmm1 + mulpd %xmm0, %xmm6 + mulpd %xmm0, %xmm0 + movapd %xmm1, %xmm3 + mulsd %xmm1, %xmm1 + addpd %xmm2, %xmm6 + mulpd %xmm0, %xmm4 + mulsd %xmm3, %xmm1 + addpd %xmm4, %xmm6 + pshufd $238, %xmm5, %xmm0 + mulpd %xmm6, %xmm1 + pshufd $238, %xmm5, %xmm6 + subsd %xmm7, %xmm0 + pshufd $238, %xmm1, %xmm2 + subsd %xmm1, %xmm5 + subsd %xmm0, %xmm6 + subsd %xmm2, %xmm5 + subsd %xmm6, %xmm7 + subsd %xmm7, %xmm5 + addsd %xmm5, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + subl $15356, %eax + cmpl $4, %eax + jae .L_2TAG_PACKET_4.0.3 + xorpd %xmm6, %xmm6 + andpd 6048(%ebx), %xmm7 + movsd 6096(%ebx), %xmm4 + movapd 5984(%ebx), %xmm1 + mulsd %xmm4, %xmm7 + movapd 6000(%ebx), %xmm2 + subsd %xmm7, %xmm4 + movapd 6016(%ebx), %xmm3 + pshufd $68, %xmm4, %xmm7 + sqrtsd %xmm4, %xmm4 + mulpd %xmm7, %xmm1 + pshufd $68, %xmm7, %xmm5 + pextrw $3, %xmm0, %eax + mulpd %xmm7, %xmm7 + addpd %xmm1, %xmm2 + movsd 5936(%ebx), %xmm1 + mulpd %xmm7, %xmm3 + cmpsd $1, %xmm6, %xmm0 + mulsd %xmm5, %xmm7 + addpd %xmm3, %xmm2 + pshufd $68, %xmm0, %xmm0 + mulsd %xmm7, %xmm2 + andpd 5904(%ebx), %xmm0 + mulpd %xmm5, %xmm2 + andpd %xmm4, %xmm1 + pshufd $68, %xmm4, %xmm3 + subsd %xmm1, %xmm4 + addsd %xmm3, %xmm3 + mulsd %xmm1, %xmm1 + subsd %xmm4, %xmm3 + subsd %xmm1, %xmm5 + mulsd %xmm3, %xmm4 + pshufd $238, %xmm3, %xmm3 + subsd %xmm4, %xmm5 + divsd %xmm3, %xmm5 + addpd %xmm3, %xmm3 + mulpd %xmm3, %xmm2 + pshufd $238, %xmm2, %xmm4 + addsd %xmm0, %xmm2 + andl $32768, %eax + pinsrw $3, %eax, %xmm6 + pshufd $238, %xmm0, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm5, %xmm2 + addsd %xmm3, %xmm2 + addsd %xmm2, %xmm0 + xorpd %xmm6, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_4.0.3: + addl $261884, %eax + cmpl $261888, %eax + jb .L_2TAG_PACKET_5.0.3 + movd %xmm7, %ecx + psrlq $32, %xmm7 + movd %xmm7, %edx + andl $2147483647, %edx + movl $1072693248, %eax + subl %edx, %eax + orl %ecx, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_6.0.3 + movq 8(%esp), %xmm2 + movd %xmm2, %edx + psrlq $32, %xmm2 + movd %xmm2, %ecx + andl $2147483647, %ecx + subl $1, %edx + sbbl $2146435072, %ecx + cmpl $0, %ecx + jge .L_2TAG_PACKET_7.0.3 + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %edx + pinsrw $3, %edx, %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $58, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_6.0.3: + pextrw $1, %xmm7, %edx + shrl $15, %edx + negl %edx + movd %edx, %xmm7 + pshufd $0, %xmm7, %xmm7 + movsd 5920(%ebx), %xmm2 + movsd 5928(%ebx), %xmm0 + andpd %xmm7, %xmm2 + andpd %xmm7, %xmm0 + addsd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_5.0.3: + movsd 5888(%ebx), %xmm2 + movsd 5896(%ebx), %xmm0 + addsd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_7.0.3: + xorpd %xmm6, %xmm6 + addsd %xmm6, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) +.L_2TAG_PACKET_1.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type acos,@function + .size acos,.-acos + .data +# -- End acos + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 3822952792 + .long 1021639372 + .long 182792448 + .long 1068507836 + .long 2264213271 + .long 1019558908 + .long 649052928 + .long 1068524253 + .long 1797139609 + .long 1022295143 + .long 1243095296 + .long 1068540671 + .long 1415938756 + .long 1021439537 + .long 2033294592 + .long 1068557090 + .long 2356809978 + .long 1021777916 + .long 3088063744 + .long 1068573510 + .long 2669055318 + .long 1022124482 + .long 180888576 + .long 1068589932 + .long 3566445325 + .long 1021358712 + .long 1970196992 + .long 1068606354 + .long 896980323 + .long 1021319659 + .long 4229555456 + .long 1068622777 + .long 436049712 + .long 1021319758 + .long 2732572160 + .long 1068639202 + .long 583123209 + .long 1020797960 + .long 1842831872 + .long 1068655628 + .long 1370449804 + .long 1021429270 + .long 1628994560 + .long 1068672055 + .long 2411391464 + .long 1021057980 + .long 2159763712 + .long 1068688483 + .long 1208692749 + .long 1021943903 + .long 3503886336 + .long 1068704912 + .long 538793309 + .long 1019744063 + .long 1435187200 + .long 1068721343 + .long 4085087612 + .long 1020608419 + .long 317469952 + .long 1068737775 + .long 144386942 + .long 1021440732 + .long 219617280 + .long 1068754208 + .long 2940088361 + .long 1019981122 + .long 1210558208 + .long 1068770642 + .long 2176850347 + .long 1018373705 + .long 3359268352 + .long 1068787077 + .long 2395611454 + .long 1021889042 + .long 2439803648 + .long 1068803514 + .long 1650705253 + .long 1020227966 + .long 2816203520 + .long 1068819952 + .long 3702166386 + .long 1019379914 + .long 262620672 + .long 1068836392 + .long 1855649370 + .long 1020453124 + .long 3438159616 + .long 1068852832 + .long 923063860 + .long 1019273834 + .long 3822105856 + .long 1068869274 + .long 4289947947 + .long 1019434249 + .long 1483729920 + .long 1068885718 + .long 787455814 + .long 1020738379 + .long 787321088 + .long 1068902163 + .long 3321653337 + .long 1021842569 + .long 1802253312 + .long 1068918609 + .long 2653633526 + .long 1021821525 + .long 302985984 + .long 1068935057 + .long 161272028 + .long 1021655149 + .long 653966080 + .long 1068951506 + .long 2566098667 + .long 1020066219 + .long 2924727296 + .long 1068967956 + .long 3646493722 + .long 1014292285 + .long 2889890304 + .long 1068984408 + .long 1081009196 + .long 1022189620 + .long 619098112 + .long 1069000862 + .long 4011643355 + .long 1021773297 + .long 477017600 + .long 1069017317 + .long 4030305534 + .long 1021292252 + .long 2533403904 + .long 1069033773 + .long 2645187591 + .long 1019527099 + .long 2563102208 + .long 1069050231 + .long 3857293792 + .long 1022311697 + .long 635982336 + .long 1069066691 + .long 3625936637 + .long 1017511744 + .long 1116940800 + .long 1069083152 + .long 3653872993 + .long 1022016631 + .long 4075964160 + .long 1069099614 + .long 2468900271 + .long 1021769532 + .long 993165568 + .long 1069116079 + .long 1358104224 + .long 1021199776 + .long 528586752 + .long 1069132545 + .long 2200950332 + .long 1022024872 + .long 2752395776 + .long 1069149012 + .long 3197072454 + .long 1017751319 + .long 3439855616 + .long 1069165481 + .long 1651081806 + .long 1020809338 + .long 2661257728 + .long 1069181952 + .long 539032752 + .long 1021728805 + .long 486957312 + .long 1069198425 + .long 3136045149 + .long 1016888671 + .long 1282340352 + .long 1069214899 + .long 2593963259 + .long 1018956103 + .long 822921728 + .long 1069231375 + .long 2146032737 + .long 1022306465 + .long 3474216192 + .long 1069247852 + .long 3976811625 + .long 1021350207 + .long 716902656 + .long 1069264332 + .long 718267222 + .long 1018624727 + .long 1211594496 + .long 1069280813 + .long 1485641389 + .long 1018447451 + .long 734070272 + .long 1069297296 + .long 354455128 + .long 1021341291 + .long 3650110720 + .long 1069313780 + .long 682185947 + .long 1021651853 + .long 1440663040 + .long 1069330267 + .long 3558574550 + .long 1021615110 + .long 2766612224 + .long 1069346755 + .long 874607978 + .long 1017746872 + .long 3404011008 + .long 1069363245 + .long 4154988502 + .long 1021439906 + .long 3423949056 + .long 1069379737 + .long 2263202309 + .long 1021479615 + .long 2897587712 + .long 1069396231 + .long 2562065031 + .long 1022090363 + .long 1896159232 + .long 1069412727 + .long 3836237663 + .long 1019867288 + .long 490968576 + .long 1069429225 + .long 3322056743 + .long 1006752762 + .long 3048360192 + .long 1069445724 + .long 1152314833 + .long 1013122252 + .long 1049850624 + .long 1069462226 + .long 3601590727 + .long 1022214610 + .long 3156899584 + .long 1069478729 + .long 1855169970 + .long 1019487271 + .long 851173376 + .long 1069495235 + .long 312649594 + .long 1020868604 + .long 2794281728 + .long 1069511742 + .long 1093490181 + .long 1020777577 + .long 468042496 + .long 1069528252 + .long 1152540679 + .long 1021403732 + .long 2534219264 + .long 1069544763 + .long 2292126035 + .long 1021872430 + .long 1376146432 + .long 1069558527 + .long 3293753641 + .long 1020500454 + .long 4175442432 + .long 1069575044 + .long 3626347564 + .long 1021610969 + .long 3523113472 + .long 1069591566 + .long 339956500 + .long 1021119039 + .long 4003350528 + .long 1069608092 + .long 3429333082 + .long 1022813542 + .long 1611067392 + .long 1069624623 + .long 2298017544 + .long 1021977587 + .long 931782144 + .long 1069641158 + .long 2164684743 + .long 1021250988 + .long 2256725504 + .long 1069657697 + .long 1138762335 + .long 1021443776 + .long 1582853120 + .long 1069674241 + .long 1084010382 + .long 1022994693 + .long 3497758720 + .long 1069690789 + .long 406366244 + .long 1022713586 + .long 3999816960 + .long 1069707342 + .long 1488723042 + .long 1023381290 + .long 3383096064 + .long 1069723900 + .long 2541558953 + .long 1019137887 + .long 1942403584 + .long 1069740463 + .long 1879620343 + .long 1022653642 + .long 4268263680 + .long 1069757030 + .long 3039077047 + .long 1022252545 + .long 2067062272 + .long 1069773603 + .long 4190670677 + .long 1020725863 + .long 4225828096 + .long 1069790180 + .long 1998567321 + .long 1022014385 + .long 2452507136 + .long 1069806763 + .long 1511628873 + .long 1021900300 + .long 1340746240 + .long 1069823351 + .long 788367341 + .long 1022726208 + .long 1190035456 + .long 1069839944 + .long 3856337230 + .long 1021834118 + .long 2300688384 + .long 1069856542 + .long 3211396579 + .long 1022621365 + .long 678886400 + .long 1069873146 + .long 4001011887 + .long 1022042646 + .long 921594112 + .long 1069889755 + .long 557811968 + .long 1023065533 + .long 3331668992 + .long 1069906369 + .long 1877060679 + .long 1022419742 + .long 3917875200 + .long 1069922989 + .long 1181055171 + .long 1022752712 + .long 2984829696 + .long 1069939615 + .long 4294526932 + .long 1021499988 + .long 838049024 + .long 1069956247 + .long 3658081878 + .long 1022957952 + .long 2078928384 + .long 1069972884 + .long 820353701 + .long 1019391107 + .long 2719854336 + .long 1069989527 + .long 1644022489 + .long 1023378240 + .long 3069117696 + .long 1070006176 + .long 2771393702 + .long 1019319954 + .long 3435962368 + .long 1070022831 + .long 3876394145 + .long 1023024433 + .long 4130595328 + .long 1070039492 + .long 1630447748 + .long 1021465882 + .long 1169236224 + .long 1070056160 + .long 2828355997 + .long 1020458120 + .long 3453997312 + .long 1070072833 + .long 164091641 + .long 1020388279 + .long 2708127744 + .long 1070089513 + .long 3036550223 + .long 1023328684 + .long 3540797696 + .long 1070106199 + .long 3710949463 + .long 1022568805 + .long 1972276736 + .long 1070122892 + .long 3885277950 + .long 1019761674 + .long 2613815552 + .long 1070139591 + .long 2764165077 + .long 1022921023 + .long 1487791616 + .long 1070156297 + .long 1330644769 + .long 1023162679 + .long 3207593472 + .long 1070173009 + .long 3911007221 + .long 1022993496 + .long 3797764608 + .long 1070189728 + .long 979712598 + .long 1022554580 + .long 3578920448 + .long 1070206454 + .long 2825738223 + .long 1020223708 + .long 2872795648 + .long 1070223187 + .long 392451124 + .long 1022666279 + .long 2002258432 + .long 1070239927 + .long 3730407632 + .long 1023148291 + .long 1291326464 + .long 1070256674 + .long 3723802980 + .long 1022514089 + .long 1065180928 + .long 1070273428 + .long 2635617463 + .long 1022654470 + .long 1650181632 + .long 1070290189 + .long 2061982883 + .long 1022853411 + .long 3373882880 + .long 1070306957 + .long 319732785 + .long 1022017175 + .long 2270081280 + .long 1070323733 + .long 2237757411 + .long 1023064087 + .long 2963732736 + .long 1070340516 + .long 468839165 + .long 1023293774 + .long 1491099904 + .long 1070357307 + .long 1502657946 + .long 1021533479 + .long 2479636480 + .long 1070374105 + .long 482913562 + .long 1021986286 + .long 1968133632 + .long 1070390911 + .long 3281474337 + .long 1022646400 + .long 291639040 + .long 1070407725 + .long 2453320259 + .long 1022812423 + .long 2081472512 + .long 1070424546 + .long 2939989570 + .long 1023091888 + .long 3380340480 + .long 1070441375 + .long 2850707499 + .long 1021921109 + .long 232287488 + .long 1070458213 + .long 3674625342 + .long 1020725130 + .long 1567614208 + .long 1070475058 + .long 9347334 + .long 1022024009 + .long 3433091072 + .long 1070491911 + .long 282524999 + .long 1021433523 + .long 1876877312 + .long 1070508773 + .long 3470449440 + .long 1019309721 + .long 1538472192 + .long 1070525643 + .long 2089486825 + .long 1019698916 + .long 2763830784 + .long 1070542521 + .long 443498115 + .long 1020505194 + .long 1605381632 + .long 1070559408 + .long 3018871601 + .long 1022869913 + .long 2706946048 + .long 1070576303 + .long 3936260892 + .long 1023175875 + .long 2123887360 + .long 1070593207 + .long 2994220655 + .long 1022825948 + .long 104015104 + .long 1070603108 + .long 335054493 + .long 1023441853 + .long 2904568832 + .long 1070615800 + .long 1451215633 + .long 1023853857 + .long 3456197120 + .long 1070632739 + .long 436334733 + .long 1024026432 + .long 252452352 + .long 1070649697 + .long 34596167 + .long 1024031396 + .long 3328018432 + .long 1070666672 + .long 2644547073 + .long 1024296758 + .long 1255829248 + .long 1070683667 + .long 552832586 + .long 1023763122 + .long 4097058560 + .long 1070700680 + .long 1955640623 + .long 1021394654 + .long 451770112 + .long 1070717714 + .long 3428903777 + .long 1022941142 + .long 408920832 + .long 1070734767 + .long 165503263 + .long 1023894958 + .long 1186960640 + .long 1070751840 + .long 435826450 + .long 1024026134 + .long 19078656 + .long 1070768934 + .long 1834169749 + .long 1022899284 + .long 2743490304 + .long 1070786048 + .long 494581074 + .long 1018818479 + .long 2328961024 + .long 1070803184 + .long 2987908834 + .long 1022581110 + .long 350011392 + .long 1070820342 + .long 240771184 + .long 1024143083 + .long 2692326912 + .long 1070837521 + .long 666056837 + .long 1022394776 + .long 2373274368 + .long 1070854723 + .long 2484337770 + .long 1024228156 + .long 1017131520 + .long 1070871948 + .long 3285648279 + .long 1024025789 + .long 265558272 + .long 1070889196 + .long 392241896 + .long 1024252809 + .long 1778008064 + .long 1070906467 + .long 1536107943 + .long 1023949300 + .long 2937184768 + .long 1070923762 + .long 3541062251 + .long 1019448646 + .long 1144442880 + .long 1070941082 + .long 3691683781 + .long 1022123948 + .long 2410165504 + .long 1070958426 + .long 1804181960 + .long 1023945221 + .long 4174350848 + .long 1070975795 + .long 2016094861 + .long 1021716585 + .long 3897012480 + .long 1070993190 + .long 175294410 + .long 1023703404 + .long 3353623040 + .long 1071010611 + .long 167973242 + .long 1023240839 + .long 45671168 + .long 1071028059 + .long 2166856113 + .long 1021565413 + .long 86063872 + .long 1071045533 + .long 2676254727 + .long 1023985299 + .long 1019772672 + .long 1071063034 + .long 989043593 + .long 1021549587 + .long 414297344 + .long 1071080563 + .long 3960972046 + .long 1024307251 + .long 155173120 + .long 1071098120 + .long 1830919291 + .long 1021592251 + .long 2151562240 + .long 1071115705 + .long 405408666 + .long 1023423128 + .long 4041854720 + .long 1071133319 + .long 2043497827 + .long 1024411503 + .long 3489224192 + .long 1071150963 + .long 3072215864 + .long 1022698635 + .long 2477196288 + .long 1071168637 + .long 1812195139 + .long 1022689192 + .long 3015298816 + .long 1071186341 + .long 764841969 + .long 1021027331 + .long 2844731136 + .long 1071204076 + .long 2878117321 + .long 1019116513 + .long 4028950528 + .long 1071221842 + .long 698911452 + .long 1023265602 + .long 69441536 + .long 1071239641 + .long 3253467847 + .long 1020795075 + .long 1676209920 + .long 1071257471 + .long 4272431167 + .long 1022873982 + .long 2408752384 + .long 1071275334 + .long 648519100 + .long 1024385717 + .long 151623680 + .long 1071293231 + .long 345257017 + .long 1019561408 + .long 1410154240 + .long 1071311161 + .long 197863993 + .long 1023224207 + .long 4131351552 + .long 1071329125 + .long 2620801789 + .long 1024411169 + .long 1999664384 + .long 1071347125 + .long 3952692616 + .long 1024168086 + .long 1617668864 + .long 1071365160 + .long 3019889809 + .long 1021907692 + .long 1032074240 + .long 1071383231 + .long 59469899 + .long 1023656194 + .long 2619492096 + .long 1071401338 + .long 1417526820 + .long 1021457783 + .long 202429440 + .long 1071419483 + .long 2927667935 + .long 1019175447 + .long 525044224 + .long 1071437665 + .long 38166811 + .long 1023981879 + .long 1779258880 + .long 1071455885 + .long 481252500 + .long 1023310234 + .long 2195673600 + .long 1071474144 + .long 3962395981 + .long 1021339088 + .long 44573696 + .long 1071492443 + .long 3936281395 + .long 1023014829 + .long 2226905344 + .long 1071510781 + .long 1515320476 + .long 1024320623 + .long 2800512512 + .long 1071529160 + .long 1225403697 + .long 1021081846 + .long 161113600 + .long 1071547581 + .long 3064809733 + .long 1024173917 + .long 1338410240 + .long 1071566043 + .long 2027604973 + .long 1024362526 + .long 522433280 + .long 1071584548 + .long 2055171723 + .long 1023858825 + .long 539595776 + .long 1071603096 + .long 3868820135 + .long 1022936424 + .long 4264017664 + .long 1071621687 + .long 3228065145 + .long 1023479578 + .long 1733924096 + .long 1071640324 + .long 3511934475 + .long 1022496355 + .long 108880384 + .long 1071651839 + .long 615880967 + .long 1023519706 + .long 3517856512 + .long 1071661202 + .long 3113108559 + .long 1025190289 + .long 4043153152 + .long 1071670589 + .long 1571836218 + .long 1023106116 + .long 3251299072 + .long 1071680000 + .long 3444076102 + .long 1022187841 + .long 2736921600 + .long 1071689435 + .long 272771483 + .long 1025095280 + .long 3897698560 + .long 1071703633 + .long 2075390188 + .long 1022489022 + .long 3209485056 + .long 1071722652 + .long 1438094065 + .long 1021844944 + .long 3781432064 + .long 1071741774 + .long 1675017145 + .long 1024143828 + .long 2684184064 + .long 1071761003 + .long 2259963753 + .long 1024731393 + .long 1840489728 + .long 1071780342 + .long 3372883597 + .long 1023431408 + .long 3764087808 + .long 1071799794 + .long 3307523102 + .long 1024485788 + .long 3006232320 + .long 1071819364 + .long 3088971966 + .long 1025213251 + .long 3374881280 + .long 1071839055 + .long 834437749 + .long 1025236452 + .long 797284864 + .long 1071858872 + .long 3122663941 + .long 1025320473 + .long 545765120 + .long 1071878818 + .long 826539625 + .long 1022450955 + .long 107562240 + .long 1071898898 + .long 339584600 + .long 1022481255 + .long 2123649024 + .long 1071919116 + .long 3912959833 + .long 1024321009 + .long 1562385664 + .long 1071939478 + .long 2846067230 + .long 1023343981 + .long 2963085824 + .long 1071959988 + .long 954548627 + .long 1021475211 + .long 3325550592 + .long 1071980652 + .long 3459651155 + .long 1025305573 + .long 775752448 + .long 1072001476 + .long 3582746667 + .long 1023859460 + .long 3238590720 + .long 1072022464 + .long 634636162 + .long 1024472353 + .long 2758801920 + .long 1072043624 + .long 3078216319 + .long 1025304516 + .long 1370319104 + .long 1072064962 + .long 2570569078 + .long 1025099442 + .long 2615805184 + .long 1072086484 + .long 3729933412 + .long 1024605112 + .long 3077336576 + .long 1072108198 + .long 1948916066 + .long 1024781603 + .long 1099528192 + .long 1072130112 + .long 3139143157 + .long 1023729360 + .long 1231903232 + .long 1072152233 + .long 1349513477 + .long 1024737515 + .long 1507504128 + .long 1072174570 + .long 3484516322 + .long 1024000959 + .long 2214659840 + .long 1072197132 + .long 2563820917 + .long 1025225535 + .long 1804739840 + .long 1072219929 + .long 760038746 + .long 1024482855 + .long 1413746688 + .long 1072242971 + .long 3401734714 + .long 1025129838 + .long 821409536 + .long 1072266269 + .long 3729772551 + .long 1025484796 + .long 3031825664 + .long 1072289834 + .long 122256749 + .long 1024752594 + .long 1710784256 + .long 1072313680 + .long 1518205483 + .long 1024724809 + .long 3025265152 + .long 1072337819 + .long 409951989 + .long 1022835555 + .long 287769088 + .long 1072362267 + .long 800355594 + .long 1022484850 + .long 198179840 + .long 1072387038 + .long 3502926213 + .long 1024209373 + .long 1909130496 + .long 1072412149 + .long 3064694319 + .long 1025380823 + .long 1941732096 + .long 1072437619 + .long 4112930390 + .long 1024294679 + .long 3492010496 + .long 1072463467 + .long 2684918107 + .long 1023220233 + .long 81959680 + .long 1072489716 + .long 220021366 + .long 1020635131 + .long 2297837056 + .long 1072516387 + .long 4027683826 + .long 1021041185 + .long 270404096 + .long 1072543508 + .long 2012766065 + .long 1021780753 + .long 3667376896 + .long 1072571105 + .long 2727981522 + .long 1023009874 + .long 330400256 + .long 1072599212 + .long 2940017003 + .long 1025393439 + .long 1119293952 + .long 1072627861 + .long 1608550416 + .long 1022675612 + .long 3536155904 + .long 1072657091 + .long 349665778 + .long 1025156751 + .long 3078046720 + .long 1072686946 + .long 2016159996 + .long 1022193169 + .long 455228416 + .long 1072705361 + .long 1908539328 + .long 1026126332 + .long 1871505664 + .long 1072720988 + .long 2784700894 + .long 1025922277 + .long 1630994432 + .long 1072737010 + .long 361107678 + .long 1022887244 + .long 2084558336 + .long 1072753462 + .long 2642784509 + .long 1072689083 + .long 1514442531 + .long 1072688953 + .long 333108933 + .long 1072688821 + .long 3392112024 + .long 1072688686 + .long 2099852862 + .long 1072688550 + .long 749609004 + .long 1072688412 + .long 3634632596 + .long 1072688271 + .long 2163248461 + .long 1072688129 + .long 628657846 + .long 1072687985 + .long 3324036511 + .long 1072687838 + .long 1657632815 + .long 1072687690 + .long 4217538760 + .long 1072687539 + .long 2411951597 + .long 1072687387 + .long 533944872 + .long 1072687233 + .long 2876566508 + .long 1072687076 + .long 847936891 + .long 1072686918 + .long 3036019913 + .long 1072686757 + .long 848884575 + .long 1072686595 + .long 2874443326 + .long 1072686430 + .long 520713666 + .long 1072686264 + .long 2375556481 + .long 1072686095 + .long 4141904948 + .long 1072685924 + .long 1522666382 + .long 1072685752 + .long 3105624104 + .long 1072685577 + .long 298666327 + .long 1072685401 + .long 1689524500 + .long 1072685222 + .long 2981002200 + .long 1072685041 + .long 4170844284 + .long 1072684858 + .long 961802263 + .long 1072684674 + .long 1941503454 + .long 1072684487 + .long 2812647170 + .long 1072684298 + .long 3572873869 + .long 1072684107 + .long 4219797823 + .long 1072683914 + .long 456039788 + .long 1072683720 + .long 869096151 + .long 1072683523 + .long 1161535119 + .long 1072683324 + .long 1330865866 + .long 1072683123 + .long 1374571204 + .long 1072682920 + .long 1290107538 + .long 1072682715 + .long 1074904836 + .long 1072682508 + .long 726366587 + .long 1072682299 + .long 241869763 + .long 1072682088 + .long 3913732079 + .long 1072681874 + .long 3149342765 + .long 1072681659 + .long 2240966306 + .long 1072681442 + .long 1185873216 + .long 1072681223 + .long 4276274591 + .long 1072681001 + .long 2919452883 + .long 1072680778 + .long 1407565635 + .long 1072680553 + .long 4032743551 + .long 1072680325 + .long 2202188565 + .long 1072680096 + .long 207977577 + .long 1072679865 + .long 2342160518 + .long 1072679631 + .long 11858423 + .long 1072679396 + .long 1804034453 + .long 1072679158 + .long 3420722787 + .long 1072678918 + .long 563930456 + .long 1072678677 + .long 1820539192 + .long 1072678433 + .long 2892501606 + .long 1072678187 + .long 3776710320 + .long 1072677939 + .long 175063337 + .long 1072677690 + .long 674333171 + .long 1072677438 + .long 976363026 + .long 1072677184 + .long 1077935934 + .long 1072676928 + .long 1921075490 + .long 1072676540 + .long 881493302 + .long 1072676016 + .long 3275752439 + .long 1072675483 + .long 486855588 + .long 1072674943 + .long 1077229111 + .long 1072674394 + .long 723950308 + .long 1072673837 + .long 3693582199 + .long 1072673271 + .long 1367335316 + .long 1072672698 + .long 2305837020 + .long 1072672116 + .long 2184358641 + .long 1072671526 + .long 972682840 + .long 1072670928 + .long 2935101762 + .long 1072670321 + .long 3745513263 + .long 1072669706 + .long 3372320886 + .long 1072669083 + .long 1783464620 + .long 1072668452 + .long 3241386215 + .long 1072667812 + .long 3418125284 + .long 1072667164 + .long 2280219148 + .long 1072666508 + .long 4088700758 + .long 1072665843 + .long 219227400 + .long 1072665171 + .long 3521816918 + .long 1072664489 + .long 1076205279 + .long 1072663800 + .long 1436484616 + .long 1072663102 + .long 271362610 + .long 1072662396 + .long 1838996688 + .long 1072661681 + .long 1807122518 + .long 1072660958 + .long 137953542 + .long 1072660227 + .long 1088178584 + .long 1072659487 + .long 324057537 + .long 1072658739 + .long 2101288076 + .long 1072657982 + .long 2085133974 + .long 1072657217 + .long 235324451 + .long 1072656444 + .long 806051592 + .long 1072655662 + .long 3756033140 + .long 1072654871 + .long 453542543 + .long 1072654073 + .long 3741177327 + .long 1072653265 + .long 691216109 + .long 1072652450 + .long 4145223372 + .long 1072651625 + .long 1174439091 + .long 1072650793 + .long 324416139 + .long 1072649952 + .long 1550246310 + .long 1072649102 + .long 511524674 + .long 1072648244 + .long 1457248482 + .long 1072647377 + .long 45944955 + .long 1072646502 + .long 525537397 + .long 1072645618 + .long 2848440188 + .long 1072644725 + .long 2671555633 + .long 1072643824 + .long 4241172637 + .long 1072642914 + .long 3213094278 + .long 1072641996 + .long 3832503688 + .long 1072641069 + .long 1754091534 + .long 1072640134 + .long 1221921804 + .long 1072639190 + .long 2184526489 + .long 1072638237 + .long 294902089 + .long 1072637276 + .long 4090375270 + .long 1072636305 + .long 632860906 + .long 1072635327 + .long 2753498702 + .long 1072634339 + .long 1808009252 + .long 1072633343 + .long 2036428672 + .long 1072632338 + .long 3383235626 + .long 1072631324 + .long 1497347484 + .long 1072630302 + .long 617018317 + .long 1072629271 + .long 684933058 + .long 1072628231 + .long 1643170798 + .long 1072627182 + .long 3011066360 + .long 1072625592 + .long 957158713 + .long 1072623442 + .long 1390907941 + .long 1072621256 + .long 3819155270 + .long 1072619034 + .long 3443571196 + .long 1072616777 + .long 4045412458 + .long 1072614484 + .long 805503923 + .long 1072612156 + .long 1778922015 + .long 1072609791 + .long 2125033665 + .long 1072607390 + .long 1287203863 + .long 1072604953 + .long 2992629568 + .long 1072602479 + .long 2367267127 + .long 1072599969 + .long 3115526047 + .long 1072597422 + .long 340219539 + .long 1072594839 + .long 2017215719 + .long 1072592218 + .long 3225443424 + .long 1072589560 + .long 3326565673 + .long 1072586865 + .long 1669811211 + .long 1072584133 + .long 1886735022 + .long 1072581363 + .long 3301071171 + .long 1072578555 + .long 928514283 + .long 1072575710 + .long 2656364059 + .long 1072572826 + .long 3473490507 + .long 1072569904 + .long 2649965606 + .long 1072566944 + .long 3736819052 + .long 1072563945 + .long 1680885175 + .long 1072560908 + .long 4413771 + .long 1072557832 + .long 2214869753 + .long 1072554716 + .long 3214725184 + .long 1072551561 + .long 2186079903 + .long 1072548367 + .long 2590372131 + .long 1072545133 + .long 3578146079 + .long 1072541859 + .long 4283712755 + .long 1072538545 + .long 3824834510 + .long 1072535191 + .long 1302400298 + .long 1072531797 + .long 95058636 + .long 1072528362 + .long 3563906063 + .long 1072524885 + .long 2167230730 + .long 1072521368 + .long 3524918334 + .long 1072517809 + .long 2353304918 + .long 1072514209 + .long 1939625839 + .long 1072510567 + .long 1256714581 + .long 1072506883 + .long 3552525848 + .long 1072503156 + .long 3464809522 + .long 1072499387 + .long 4200542593 + .long 1072495575 + .long 355609124 + .long 1072491721 + .long 3684139099 + .long 1072487822 + .long 148355918 + .long 1072483881 + .long 1457689242 + .long 1072479895 + .long 2118591596 + .long 1072475865 + .long 908848089 + .long 1072471791 + .long 877032689 + .long 1072467672 + .long 752012304 + .long 1072463508 + .long 3532301749 + .long 1072459298 + .long 3600563221 + .long 1072455043 + .long 3902857084 + .long 1072450742 + .long 3063101036 + .long 1072446395 + .long 3972344374 + .long 1072442001 + .long 903183549 + .long 1072437561 + .long 983892938 + .long 1072433073 + .long 2722858568 + .long 1072428537 + .long 302790515 + .long 1072423954 + .long 759811057 + .long 1072419322 + .long 2507809922 + .long 1072414641 + .long 2388408813 + .long 1072407528 + .long 2084492942 + .long 1072397870 + .long 2435703301 + .long 1072388010 + .long 1935433360 + .long 1072377945 + .long 2742047290 + .long 1072367671 + .long 2053284205 + .long 1072357185 + .long 657783367 + .long 1072346483 + .long 2893664841 + .long 1072335560 + .long 3718906405 + .long 1072324413 + .long 1547896303 + .long 1072313038 + .long 2494058440 + .long 1072301429 + .long 3133238742 + .long 1072289582 + .long 3327000086 + .long 1072277492 + .long 1860667274 + .long 1072265154 + .long 665340747 + .long 1072252562 + .long 443347841 + .long 1072239710 + .long 581282618 + .long 1072226592 + .long 3349780465 + .long 1072213201 + .long 914217606 + .long 1072199532 + .long 989797661 + .long 1072185576 + .long 945436416 + .long 1072171326 + .long 549291300 + .long 1072156774 + .long 1814636389 + .long 1072141911 + .long 239092858 + .long 1072126729 + .long 1794680724 + .long 1072111217 + .long 1241534678 + .long 1072095366 + .long 3366566214 + .long 1072079164 + .long 1244090828 + .long 1072062601 + .long 1708448120 + .long 1072045663 + .long 3544260650 + .long 1072028337 + .long 1402741403 + .long 1072010610 + .long 2551936888 + .long 1071992465 + .long 617669739 + .long 1071973887 + .long 794002186 + .long 1071954857 + .long 2021237693 + .long 1071935356 + .long 540450384 + .long 1071915364 + .long 1920555537 + .long 1071894857 + .long 2879585206 + .long 1071873811 + .long 3000237455 + .long 1071852199 + .long 3352974346 + .long 1071829991 + .long 569629937 + .long 1071807155 + .long 2077237208 + .long 1071783653 + .long 2284891805 + .long 1071759446 + .long 1226651784 + .long 1071734489 + .long 1102047405 + .long 1071708731 + .long 2009896384 + .long 1071682115 + .long 927419082 + .long 1071654577 + .long 85010366 + .long 1071607413 + .long 696431025 + .long 1071548180 + .long 2611410541 + .long 1071486585 + .long 2612593658 + .long 1071422396 + .long 3548155306 + .long 1071355336 + .long 3887997484 + .long 1071285073 + .long 244854763 + .long 1071211202 + .long 4214445648 + .long 1071133216 + .long 2303966727 + .long 1071050478 + .long 3991040013 + .long 1070962152 + .long 3126952278 + .long 1070867118 + .long 1817448378 + .long 1070763804 + .long 1793814864 + .long 1070649884 + .long 3507224072 + .long 1070447193 + .long 4027609105 + .long 1070148772 + .long 577507993 + .long 1069779414 + .long 2310232419 + .long 1068931829 + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 3164710438 + .long 1413754136 + .long 3221823995 + .long 856972295 + .long 1017226790 + .long 1413754136 + .long 1074340347 + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .long 0 + .long 0 + .long 1431655765 + .long 3217380693 + .long 858993459 + .long 3216192307 + .long 3067833783 + .long 3215383405 + .long 780903145 + .long 1066854586 + .long 858993459 + .long 1068708659 + .long 3340530119 + .long 1067392113 + .long 1431655765 + .long 1069897045 + .long 1321528399 + .long 1066517740 + .long 3067833783 + .long 1067899757 + .long 2021159460 + .long 1065855096 + .long 2576980378 + .long 1066178969 + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 4294950912 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,6112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/acosf_wmt.S b/external/sgx_libm/ia32/acosf_wmt.S new file mode 100644 index 0000000000..b2e8659e00 --- /dev/null +++ b/external/sgx_libm/ia32/acosf_wmt.S @@ -0,0 +1,551 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acosf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin acosf + .text + .align 16,0x90 + .globl acosf +acosf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %eax + cvtps2pd %xmm0, %xmm1 + movsd 1040(%ebx), %xmm3 + movl $2147483647, %ecx + andl %eax, %ecx + subl $1015021568, %ecx + cmpl $49283072, %ecx + jae .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + movl $8388608, %edx + mulsd %xmm1, %xmm1 + cvtps2pd %xmm0, %xmm2 + shrl $23, %ecx + addl $1, %ecx + shrl %cl, %edx + subsd %xmm1, %xmm3 + orl %edx, %eax + negl %edx + andl %edx, %eax + movd %eax, %xmm4 + sqrtsd %xmm3, %xmm3 + addl %edx, %edx + andl $16777215, %edx + andl %edx, %eax + negl %ecx + addl $24, %ecx + orl $8388608, %eax + shrl %cl, %eax + addl %eax, %eax + movsd (%ebx,%eax,8), %xmm5 + psrlq $31, %xmm0 + movsd 8(%ebx,%eax,8), %xmm1 + psllq $63, %xmm0 + cvtps2pd %xmm4, %xmm4 + mulsd %xmm5, %xmm2 + orpd %xmm1, %xmm0 + movsd 1056(%ebx), %xmm5 + movsd 1072(%ebx), %xmm1 + mulsd %xmm3, %xmm4 + movsd 1088(%ebx), %xmm3 + subsd %xmm4, %xmm2 + pshufd $68, %xmm2, %xmm4 + mulsd %xmm2, %xmm2 + subsd 1024(%ebx), %xmm0 + mulsd %xmm4, %xmm5 + mulsd %xmm4, %xmm1 + mulsd %xmm4, %xmm3 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + subsd %xmm3, %xmm5 + addsd %xmm1, %xmm4 + mulsd %xmm5, %xmm2 + addsd %xmm4, %xmm0 + subsd %xmm0, %xmm2 + movsd %xmm2, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + jge .L_2TAG_PACKET_3.0.3 + addl $1015021568, %ecx + cmpl $964689920, %ecx + jb .L_2TAG_PACKET_4.0.3 + movsd 1072(%ebx), %xmm2 + movapd %xmm1, %xmm0 + movsd 1024(%ebx), %xmm3 + mulsd %xmm1, %xmm1 + mulsd %xmm1, %xmm2 + mulsd %xmm0, %xmm2 + subsd %xmm0, %xmm3 + subsd %xmm2, %xmm3 + cvtsd2ss %xmm3, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + movsd 1024(%ebx), %xmm2 + subsd %xmm1, %xmm2 + cvtsd2ss %xmm2, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + movl %eax, %edx + addl %edx, %edx + cmpl $2130706432, %edx + jb .L_2TAG_PACKET_5.0.3 + jne .L_2TAG_PACKET_6.0.3 + shrl $31, %eax + movsd 1136(%ebx,%eax,8), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_5.0.3: + cmpl $0, %eax + jl .L_2TAG_PACKET_1.0.3 + xorpd %xmm2, %xmm2 + movl $16352, %eax + pinsrw $3, %eax, %xmm2 + subsd %xmm1, %xmm3 + mulsd %xmm2, %xmm3 + sqrtsd %xmm3, %xmm3 + movsd 1120(%ebx), %xmm4 + movsd 1056(%ebx), %xmm5 + movsd 1072(%ebx), %xmm0 + movsd 1088(%ebx), %xmm1 + pshufd $68, %xmm3, %xmm2 + mulsd %xmm3, %xmm3 + addpd %xmm2, %xmm2 + mulsd %xmm3, %xmm4 + mulsd %xmm3, %xmm1 + mulsd %xmm3, %xmm2 + mulsd %xmm3, %xmm3 + subsd %xmm5, %xmm4 + addsd %xmm0, %xmm1 + mulsd %xmm3, %xmm4 + addsd %xmm1, %xmm4 + mulsd %xmm2, %xmm4 + pshufd $238, %xmm2, %xmm2 + addsd %xmm4, %xmm2 + cvtpd2ps %xmm2, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + cmpl $-16777216, %edx + ja .L_2TAG_PACKET_7.0.3 + xorps %xmm0, %xmm0 + movl $2139095040, %edx + movd %edx, %xmm1 + mulss %xmm1, %xmm0 + movss %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $62, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_7.0.3: + addss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_2.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type acosf,@function + .size acosf,.-acosf + .data +# -- End acosf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4290772864 + .long 1072693183 + .long 2864569868 + .long 1065353226 + .long 3955135328 + .long 1072692671 + .long 152932388 + .long 1066926224 + .long 1671525387 + .long 1072691647 + .long 2415589551 + .long 1067712845 + .long 2799290704 + .long 1072690109 + .long 3864800403 + .long 1068237715 + .long 2477707161 + .long 1072688057 + .long 725093587 + .long 1068630990 + .long 2787892653 + .long 1072685489 + .long 2536557765 + .long 1068893940 + .long 4138691444 + .long 1072682403 + .long 62552236 + .long 1069157247 + .long 941089134 + .long 1072678798 + .long 165833141 + .long 1069420976 + .long 3045724825 + .long 1072674669 + .long 2611259588 + .long 1069616357 + .long 1338788729 + .long 1072670015 + .long 2616012614 + .long 1069748746 + .long 2049955026 + .long 1072664831 + .long 11397492 + .long 1069881450 + .long 922854000 + .long 1072659114 + .long 2157235516 + .long 1070014503 + .long 326738075 + .long 1072652859 + .long 2788743992 + .long 1070147943 + .long 589211462 + .long 1072646061 + .long 3920198733 + .long 1070281807 + .long 4203970809 + .long 1072638714 + .long 3416546056 + .long 1070416134 + .long 2847908959 + .long 1072630814 + .long 4071425947 + .long 1070550963 + .long 3041144817 + .long 1072622353 + .long 623140044 + .long 1070641216 + .long 254499552 + .long 1072613325 + .long 307519074 + .long 1070709195 + .long 247322296 + .long 1072603721 + .long 2945179265 + .long 1070777488 + .long 1734768715 + .long 1072593533 + .long 3301227932 + .long 1070846119 + .long 512284341 + .long 1072582753 + .long 148694291 + .long 1070915112 + .long 2150320922 + .long 1072571370 + .long 959165711 + .long 1070984490 + .long 307214965 + .long 1072559375 + .long 862254873 + .long 1071054280 + .long 2261822985 + .long 1072546755 + .long 303820077 + .long 1071124509 + .long 2878424532 + .long 1072533499 + .long 1279667396 + .long 1071195205 + .long 1489389340 + .long 1072519594 + .long 3626865975 + .long 1071266398 + .long 1561634021 + .long 1072505025 + .long 1381197995 + .long 1071338121 + .long 1731593006 + .long 1072489777 + .long 685577004 + .long 1071410406 + .long 3972360633 + .long 1072473833 + .long 3426639945 + .long 1071483288 + .long 231016948 + .long 1072457177 + .long 3858097791 + .long 1071556806 + .long 1951983052 + .long 1072439787 + .long 2522397359 + .long 1071631000 + .long 806900869 + .long 1072421644 + .long 1565390008 + .long 1071675292 + .long 2352519275 + .long 1072402724 + .long 2655228975 + .long 1071713130 + .long 3752547712 + .long 1072383003 + .long 3066292715 + .long 1071751375 + .long 1444584515 + .long 1072362455 + .long 933027783 + .long 1071790054 + .long 2960036461 + .long 1072341049 + .long 3589869088 + .long 1071829194 + .long 4214933698 + .long 1072318754 + .long 2973206241 + .long 1071868828 + .long 957213757 + .long 1072295536 + .long 2756129430 + .long 1071908989 + .long 4263431727 + .long 1072271354 + .long 2767348050 + .long 1071949714 + .long 4197201246 + .long 1072246168 + .long 874994578 + .long 1071991044 + .long 1821133236 + .long 1072219931 + .long 3810301671 + .long 1072033022 + .long 2102004657 + .long 1072192590 + .long 4064603671 + .long 1072075699 + .long 1957725919 + .long 1072164088 + .long 276553332 + .long 1072119130 + .long 3365782140 + .long 1072134360 + .long 1120469626 + .long 1072163374 + .long 4096932877 + .long 1072103334 + .long 4291572900 + .long 1072208500 + .long 177757517 + .long 1072070929 + .long 2376322938 + .long 1072254587 + .long 4029755771 + .long 1072037049 + .long 3060434712 + .long 1072301721 + .long 497611374 + .long 1072001591 + .long 4010165530 + .long 1072350003 + .long 3306304935 + .long 1071964429 + .long 388249839 + .long 1072399550 + .long 539435036 + .long 1071925423 + .long 165779504 + .long 1072450495 + .long 2497352827 + .long 1071884403 + .long 1343287957 + .long 1072502997 + .long 884164153 + .long 1071841172 + .long 1828157318 + .long 1072557245 + .long 3653025069 + .long 1071795489 + .long 2128712154 + .long 1072613466 + .long 3056817116 + .long 1071747064 + .long 1489283833 + .long 1072671938 + .long 1840990109 + .long 1071695534 + .long 2059782629 + .long 1072713127 + .long 3931971716 + .long 1071636206 + .long 1027831985 + .long 1072745180 + .long 3187721039 + .long 1071517691 + .long 3329524973 + .long 1072779038 + .long 3649449467 + .long 1071389244 + .long 2110923290 + .long 1072815090 + .long 4055205277 + .long 1071248617 + .long 2992048670 + .long 1072853879 + .long 2715653706 + .long 1071092488 + .long 419466969 + .long 1072896214 + .long 2030806678 + .long 1070915559 + .long 1069790871 + .long 1072943387 + .long 2084655462 + .long 1070708358 + .long 3811755941 + .long 1072997722 + .long 3549768261 + .long 1070304457 + .long 884757291 + .long 1073064302 + .long 4261330719 + .long 1069543419 + .long 3631318613 + .long 1073160613 + .long 1413754136 + .long 1073291771 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 3067833783 + .long 3215383405 + .long 0 + .long 0 + .long 1431655765 + .long 1069897045 + .long 0 + .long 0 + .long 858993459 + .long 1068708659 + .long 0 + .long 0 + .long 1 + .long 1072693248 + .long 0 + .long 0 + .long 3340530119 + .long 1067392113 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1413754136 + .long 1074340347 + .type static_const_table,@object + .size static_const_table,1152 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/acosh_wmt.S b/external/sgx_libm/ia32/acosh_wmt.S new file mode 100644 index 0000000000..36112ecb6e --- /dev/null +++ b/external/sgx_libm/ia32/acosh_wmt.S @@ -0,0 +1,1922 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acosh_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin acosh + .text + .align 16,0x90 + .globl acosh +acosh: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movl 116(%esp), %eax + subl $1072693248, %eax + je .L_2TAG_PACKET_0.0.3 + cmpl $1073741824, %eax + jae .L_2TAG_PACKET_1.0.3 + cmpl $6144, %eax + jl .L_2TAG_PACKET_2.0.3 + cmpl $29360128, %eax + jge .L_2TAG_PACKET_3.0.3 + cmpl $2293760, %eax + jl .L_2TAG_PACKET_4.0.3 + movq 112(%ebx), %xmm1 + movapd %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + addsd 112(%ebx), %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm2, %xmm0 + paddw 288(%ebx), %xmm2 + divsd %xmm0, %xmm1 + movapd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_4.0.3: + movapd %xmm0, %xmm1 + movapd %xmm0, %xmm3 + pand 208(%ebx), %xmm0 + movapd %xmm0, %xmm2 + subsd %xmm0, %xmm1 + addsd %xmm0, %xmm3 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm3 + subsd 128(%ebx), %xmm0 + movapd %xmm3, %xmm4 + addsd %xmm0, %xmm3 + sqrtsd %xmm3, %xmm3 + movapd %xmm3, %xmm5 + pand 208(%ebx), %xmm3 + subsd %xmm3, %xmm5 + movapd %xmm3, %xmm6 + movapd %xmm3, %xmm7 + addsd %xmm3, %xmm2 + mulsd %xmm3, %xmm3 + mulsd %xmm5, %xmm6 + addsd %xmm5, %xmm7 + subsd %xmm3, %xmm0 + subsd %xmm6, %xmm0 + addsd %xmm0, %xmm4 + movapd %xmm2, %xmm0 + divsd %xmm7, %xmm4 + addsd %xmm5, %xmm4 + mulsd 96(%ebx), %xmm4 + addsd %xmm4, %xmm1 +.L_2TAG_PACKET_5.0.3: + movq 240(%ebx), %xmm3 + addsd %xmm1, %xmm0 + movapd %xmm0, %xmm5 + psrlq $41, %xmm5 + pextrw $0, %xmm5, %ecx + pand 208(%ebx), %xmm0 + subsd %xmm0, %xmm2 + addsd %xmm2, %xmm1 + pshufd $68, %xmm0, %xmm4 + pand 192(%ebx), %xmm0 + pand 224(%ebx), %xmm4 + psubd %xmm4, %xmm3 + psubw 128(%ebx), %xmm4 + psrlq $52, %xmm4 + por 128(%ebx), %xmm0 + por 160(%ebx), %xmm4 + mulsd %xmm3, %xmm1 + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_3.0.3: + shrl $20, %eax + addl $1, %eax + movd %eax, %xmm4 + unpcklpd %xmm4, %xmm4 + movl 116(%esp), %ecx + por 160(%ebx), %xmm4 + pand 192(%ebx), %xmm0 + por 128(%ebx), %xmm0 + movapd %xmm0, %xmm1 + pand 208(%ebx), %xmm0 + subsd %xmm0, %xmm1 + shrl $9, %ecx +.L_2TAG_PACKET_6.0.3: + subpd 160(%ebx), %xmm4 + movq 80(%ebx), %xmm2 + andl $2040, %ecx + mulpd 256(%ebx), %xmm4 + mulsd 4400(%ebx,%ecx), %xmm0 + mulsd 4400(%ebx,%ecx), %xmm1 + subsd 128(%ebx), %xmm0 + movapd %xmm0, %xmm5 + addsd %xmm1, %xmm0 + movapd %xmm0, %xmm3 + unpcklpd %xmm0, %xmm0 + addpd 304(%ebx,%ecx,2), %xmm4 + movhlps %xmm4, %xmm6 + mulpd %xmm0, %xmm0 + mulsd %xmm0, %xmm2 + addpd 64(%ebx), %xmm2 + mulpd %xmm0, %xmm2 + addpd 48(%ebx), %xmm2 + mulpd %xmm0, %xmm2 + movhlps %xmm2, %xmm0 + mulsd %xmm3, %xmm0 + addsd %xmm2, %xmm0 + addsd %xmm1, %xmm0 + addsd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + addsd %xmm5, %xmm0 + movsd %xmm0, 24(%esp) + fldl 24(%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_2.0.3: + subsd 128(%ebx), %xmm0 + movapd %xmm0, %xmm1 + mulsd 144(%ebx), %xmm0 + movapd %xmm0, %xmm2 + movq 32(%ebx), %xmm7 + mulsd %xmm1, %xmm7 + addsd 24(%ebx), %xmm7 + mulsd %xmm1, %xmm7 + addsd 16(%ebx), %xmm7 + mulsd %xmm1, %xmm7 + addsd 8(%ebx), %xmm7 + mulsd %xmm1, %xmm7 + addsd (%ebx), %xmm7 + mulsd %xmm1, %xmm7 + movapd %xmm7, %xmm1 + sqrtsd %xmm0, %xmm0 + movapd %xmm0, %xmm3 + movapd %xmm0, %xmm4 + pand 208(%ebx), %xmm0 + subsd %xmm0, %xmm3 + movapd %xmm0, %xmm5 + movapd %xmm0, %xmm6 + mulsd %xmm0, %xmm0 + subsd %xmm0, %xmm2 + movapd %xmm7, %xmm0 + mulsd %xmm3, %xmm5 + subsd %xmm5, %xmm2 + divsd %xmm4, %xmm2 + addsd %xmm3, %xmm2 + mulsd 96(%ebx), %xmm2 + pand 208(%ebx), %xmm7 + subsd %xmm7, %xmm1 + mulsd %xmm6, %xmm7 + mulsd %xmm6, %xmm1 + mulsd %xmm2, %xmm0 + addsd %xmm1, %xmm0 + addsd %xmm2, %xmm0 + addsd %xmm7, %xmm0 + addsd %xmm6, %xmm0 + movsd %xmm0, 24(%esp) + fldl 24(%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_0.0.3: + movl 112(%esp), %ecx + testl %ecx, %ecx + jne .L_2TAG_PACKET_2.0.3 + fldz + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_1.0.3: + addl $1072693248, %eax + movl $2147483647, %ecx + andl %eax, %ecx + cmpl $2146435072, %ecx + jge .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_9.0.3: + xorpd %xmm1, %xmm1 + mulsd 224(%ebx), %xmm1 + movsd %xmm1, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $136, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_8.0.3: + cmpl $-1048576, %eax + je .L_2TAG_PACKET_10.0.3 + jmp .L_2TAG_PACKET_11.0.3 +.L_2TAG_PACKET_10.0.3: + movl 112(%esp), %eax + testl %eax, %eax + je .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_11.0.3: + addsd %xmm0, %xmm0 + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_7.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type acosh,@function + .size acosh,.-acosh + .data +# -- End acosh + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1431655760 + .long 3216332117 + .long 858954823 + .long 1066611507 + .long 2956777430 + .long 3212237677 + .long 4158004615 + .long 1063197775 + .long 2173429939 + .long 3209085130 + .long 0 + .long 0 + .long 0 + .long 3219128320 + .long 1431621855 + .long 1070945621 + .long 4294842013 + .long 3218079743 + .long 1289448124 + .long 1070176674 + .long 2077359316 + .long 3217380703 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 0 + .long 3220176896 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 1073741824 + .long 0 + .long 1073741824 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 0 + .long 4294967295 + .long 0 + .long 4294967295 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 0 + .long 2145386496 + .long 0 + .long 2145386496 + .long 897137782 + .long 1038760431 + .long 4276092928 + .long 1072049730 + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 1048576 + .long 0 + .long 0 + .long 662290844 + .long 1040545122 + .long 0 + .long 1063257089 + .long 1410206301 + .long 1039423595 + .long 0 + .long 1064833554 + .long 1576129908 + .long 1044327686 + .long 0 + .long 1065621801 + .long 3771466512 + .long 1043372267 + .long 0 + .long 1066152307 + .long 2250061482 + .long 1041942323 + .long 0 + .long 1066510009 + .long 241025648 + .long 1043818160 + .long 0 + .long 1066777242 + .long 3481293707 + .long 1039994007 + .long 0 + .long 1067045544 + .long 17391197 + .long 1042467788 + .long 0 + .long 1067281191 + .long 1429304634 + .long 1045705663 + .long 0 + .long 1067500943 + .long 2258946786 + .long 1045312243 + .long 0 + .long 1067619660 + .long 725099158 + .long 1043780790 + .long 0 + .long 1067755853 + .long 1795694751 + .long 1046370967 + .long 0 + .long 1067875476 + .long 218276363 + .long 1045874206 + .long 0 + .long 1067995528 + .long 3918058606 + .long 1045941877 + .long 0 + .long 1068133258 + .long 2029669416 + .long 1040964778 + .long 0 + .long 1068254238 + .long 111041497 + .long 1042505837 + .long 0 + .long 1068375655 + .long 9214008 + .long 1042394003 + .long 0 + .long 1068497513 + .long 3222421290 + .long 1046711220 + .long 0 + .long 1068559379 + .long 1120482910 + .long 1046024006 + .long 0 + .long 1068620754 + .long 3817590987 + .long 1046519755 + .long 0 + .long 1068682354 + .long 3431328350 + .long 1046805053 + .long 0 + .long 1068744181 + .long 3088376696 + .long 1046390788 + .long 0 + .long 1068806237 + .long 3229576382 + .long 1046428373 + .long 0 + .long 1068859611 + .long 1328753044 + .long 1046554315 + .long 0 + .long 1068922096 + .long 1186666727 + .long 1044788651 + .long 0 + .long 1068984815 + .long 603190068 + .long 1044621365 + .long 0 + .long 1069047769 + .long 1647019864 + .long 1045911122 + .long 0 + .long 1069101918 + .long 4200935885 + .long 1044407410 + .long 0 + .long 1069165314 + .long 3581720604 + .long 1046840144 + .long 0 + .long 1069219844 + .long 2217841072 + .long 1046325234 + .long 0 + .long 1069283688 + .long 1963222525 + .long 1047002562 + .long 0 + .long 1069338605 + .long 2828272122 + .long 1046012177 + .long 0 + .long 1069393703 + .long 3730942205 + .long 1046476867 + .long 0 + .long 1069458213 + .long 3166604115 + .long 1047518079 + .long 0 + .long 1069513705 + .long 2095461845 + .long 1046790089 + .long 0 + .long 1069558451 + .long 322388698 + .long 1046865736 + .long 0 + .long 1069586382 + .long 2407253617 + .long 1047545084 + .long 0 + .long 1069619086 + .long 3437791416 + .long 1047490483 + .long 0 + .long 1069647220 + .long 2693469775 + .long 1045625134 + .long 0 + .long 1069675449 + .long 1454696571 + .long 1045327327 + .long 0 + .long 1069703773 + .long 1940756848 + .long 1043926274 + .long 0 + .long 1069732193 + .long 2244096130 + .long 1047717922 + .long 0 + .long 1069760709 + .long 2856509870 + .long 1047123452 + .long 0 + .long 1069789323 + .long 116200689 + .long 1043361536 + .long 0 + .long 1069813243 + .long 4018367049 + .long 1048385867 + .long 0 + .long 1069842036 + .long 3162755613 + .long 1048496333 + .long 0 + .long 1069870929 + .long 2730655796 + .long 1048315252 + .long 0 + .long 1069899922 + .long 892380602 + .long 1046868829 + .long 0 + .long 1069929016 + .long 3139480334 + .long 1046190510 + .long 0 + .long 1069953338 + .long 1886171545 + .long 1048270714 + .long 0 + .long 1069982617 + .long 2203106387 + .long 1048291228 + .long 0 + .long 1070007095 + .long 659271154 + .long 1044549473 + .long 0 + .long 1070036564 + .long 377790372 + .long 1045759361 + .long 0 + .long 1070066136 + .long 1269824164 + .long 1047357396 + .long 0 + .long 1070090859 + .long 1643831617 + .long 1048231604 + .long 0 + .long 1070115655 + .long 57265969 + .long 1047663307 + .long 0 + .long 1070145508 + .long 2640032722 + .long 1046479978 + .long 0 + .long 1070170467 + .long 2420992102 + .long 1043079769 + .long 0 + .long 1070200516 + .long 2711573521 + .long 1045731911 + .long 0 + .long 1070225639 + .long 1973048145 + .long 1048077010 + .long 0 + .long 1070250837 + .long 4093691059 + .long 1046627963 + .long 0 + .long 1070276112 + .long 4182783767 + .long 1047690348 + .long 0 + .long 1070306542 + .long 2883525439 + .long 1048055018 + .long 0 + .long 1070331985 + .long 3917130655 + .long 1046818760 + .long 0 + .long 1070357506 + .long 2320146059 + .long 1048132455 + .long 0 + .long 1070383104 + .long 3464331364 + .long 1047738634 + .long 0 + .long 1070408781 + .long 674627443 + .long 1046468986 + .long 0 + .long 1070434537 + .long 2152289494 + .long 1046214007 + .long 0 + .long 1070460372 + .long 37897452 + .long 1048575202 + .long 0 + .long 1070486286 + .long 1899477568 + .long 1044793529 + .long 0 + .long 1070512282 + .long 2077140689 + .long 1048534003 + .long 0 + .long 1070538357 + .long 448558287 + .long 1045911230 + .long 0 + .long 1070564515 + .long 3867352000 + .long 1046082819 + .long 0 + .long 1070590754 + .long 2206537816 + .long 1049157739 + .long 0 + .long 1070606585 + .long 1799603998 + .long 1049369388 + .long 0 + .long 1070619787 + .long 4075457018 + .long 1048703324 + .long 0 + .long 1070630379 + .long 572844178 + .long 1049388451 + .long 0 + .long 1070643656 + .long 540240475 + .long 1048063456 + .long 0 + .long 1070656976 + .long 2413664112 + .long 1047739393 + .long 0 + .long 1070670338 + .long 2592177285 + .long 1048727389 + .long 0 + .long 1070681058 + .long 1541931453 + .long 1048698417 + .long 0 + .long 1070694497 + .long 3345398163 + .long 1049085432 + .long 0 + .long 1070707979 + .long 2241984547 + .long 1049164260 + .long 0 + .long 1070718796 + .long 890223989 + .long 1048265646 + .long 0 + .long 1070732357 + .long 1226890683 + .long 1048781783 + .long 0 + .long 1070743237 + .long 1600520378 + .long 1048834273 + .long 0 + .long 1070756877 + .long 1081324478 + .long 1048934847 + .long 0 + .long 1070767821 + .long 1928471339 + .long 1042640487 + .long 0 + .long 1070781542 + .long 982084959 + .long 1048971733 + .long 0 + .long 1070792550 + .long 2380239162 + .long 1047711062 + .long 0 + .long 1070806352 + .long 3609542249 + .long 1048031507 + .long 0 + .long 1070817426 + .long 3466499103 + .long 1049126511 + .long 0 + .long 1070828529 + .long 1626165976 + .long 1048431820 + .long 0 + .long 1070842450 + .long 261635432 + .long 1048113242 + .long 0 + .long 1070853620 + .long 1670437810 + .long 1046604532 + .long 0 + .long 1070864820 + .long 3910575981 + .long 1049365107 + .long 0 + .long 1070876049 + .long 727294688 + .long 1048407484 + .long 0 + .long 1070890129 + .long 3260008354 + .long 1047549258 + .long 0 + .long 1070901427 + .long 872084085 + .long 1048711456 + .long 0 + .long 1070912755 + .long 754632403 + .long 1048687679 + .long 0 + .long 1070924114 + .long 1033413261 + .long 1048105461 + .long 0 + .long 1070935504 + .long 1155773876 + .long 1047412165 + .long 0 + .long 1070946925 + .long 746670859 + .long 1046841493 + .long 0 + .long 1070961245 + .long 1820254373 + .long 1048237327 + .long 0 + .long 1070972736 + .long 3605217861 + .long 1047440922 + .long 0 + .long 1070984259 + .long 2212317823 + .long 1049212421 + .long 0 + .long 1070995813 + .long 2826670683 + .long 1047678316 + .long 0 + .long 1071007400 + .long 3532575187 + .long 1049339451 + .long 0 + .long 1071019018 + .long 413443603 + .long 1049028939 + .long 0 + .long 1071030669 + .long 2964472999 + .long 1043732931 + .long 0 + .long 1071042353 + .long 389771102 + .long 1049430622 + .long 0 + .long 1071051136 + .long 1005132876 + .long 1048342053 + .long 0 + .long 1071062877 + .long 2877512173 + .long 1049492173 + .long 0 + .long 1071074650 + .long 1874411204 + .long 1048724858 + .long 0 + .long 1071086457 + .long 1011596427 + .long 1048646627 + .long 0 + .long 1071098297 + .long 838498113 + .long 1043068341 + .long 0 + .long 1071110171 + .long 409945993 + .long 1047118137 + .long 0 + .long 1071122078 + .long 2035722984 + .long 1049263601 + .long 0 + .long 1071131030 + .long 4272650650 + .long 1048435570 + .long 0 + .long 1071142997 + .long 867757828 + .long 1047923871 + .long 0 + .long 1071154998 + .long 433900304 + .long 1048766295 + .long 0 + .long 1071164021 + .long 2626749065 + .long 1049334020 + .long 0 + .long 1071176082 + .long 2721103389 + .long 1049448370 + .long 0 + .long 1071188178 + .long 3401674810 + .long 1049424769 + .long 0 + .long 1071197273 + .long 3030733799 + .long 1047804815 + .long 0 + .long 1071209431 + .long 1532130487 + .long 1045537774 + .long 0 + .long 1071221624 + .long 225486125 + .long 1049520040 + .long 0 + .long 1071230791 + .long 1326263423 + .long 1044918825 + .long 0 + .long 1071243047 + .long 3029302589 + .long 1049469599 + .long 0 + .long 1071252261 + .long 3326443421 + .long 1042360275 + .long 0 + .long 1071264580 + .long 3770244744 + .long 1048027184 + .long 0 + .long 1071273842 + .long 2568976454 + .long 1045847505 + .long 0 + .long 1071286224 + .long 628040571 + .long 1048248574 + .long 0 + .long 1071295534 + .long 2688775955 + .long 1048311770 + .long 0 + .long 1071307980 + .long 3357093336 + .long 1047484659 + .long 0 + .long 1071317339 + .long 2753529189 + .long 1047343532 + .long 0 + .long 1071329850 + .long 625560417 + .long 1043404964 + .long 0 + .long 1071339258 + .long 2456374941 + .long 1048890167 + .long 0 + .long 1071351834 + .long 748255530 + .long 1049487286 + .long 0 + .long 1071361291 + .long 2246865993 + .long 1048768259 + .long 0 + .long 1071370770 + .long 205672663 + .long 1047230532 + .long 0 + .long 1071383442 + .long 4242870741 + .long 1046367538 + .long 0 + .long 1071392971 + .long 2016709797 + .long 1049037028 + .long 0 + .long 1071402521 + .long 2569308411 + .long 1049159850 + .long 0 + .long 1071415289 + .long 3242472523 + .long 1048132214 + .long 0 + .long 1071424891 + .long 1602055934 + .long 1044691415 + .long 0 + .long 1071434515 + .long 1307177952 + .long 1049244134 + .long 0 + .long 1071444160 + .long 2152237414 + .long 1048407400 + .long 0 + .long 1071457056 + .long 2598207309 + .long 1047639998 + .long 0 + .long 1071466754 + .long 3115077937 + .long 1048719780 + .long 0 + .long 1071476474 + .long 1272724396 + .long 1048321721 + .long 0 + .long 1071486217 + .long 2860867658 + .long 1049612888 + .long 0 + .long 1071495982 + .long 1467300368 + .long 1047143154 + .long 0 + .long 1071509039 + .long 3449085837 + .long 1046095654 + .long 0 + .long 1071518858 + .long 2146871948 + .long 1044681726 + .long 0 + .long 1071528700 + .long 3066750144 + .long 1046492840 + .long 0 + .long 1071538565 + .long 1416401583 + .long 1048453263 + .long 0 + .long 1071548453 + .long 2249840317 + .long 1046959692 + .long 0 + .long 1071558365 + .long 4172904720 + .long 1048039642 + .long 0 + .long 1071568300 + .long 1549017192 + .long 1046702261 + .long 0 + .long 1071578259 + .long 3220736011 + .long 1048855214 + .long 0 + .long 1071588241 + .long 630967006 + .long 1049477219 + .long 0 + .long 1071598247 + .long 3624057028 + .long 1046733189 + .long 0 + .long 1071608278 + .long 3730794064 + .long 1048259820 + .long 0 + .long 1071618332 + .long 570378657 + .long 1049316661 + .long 0 + .long 1071628410 + .long 2814556357 + .long 1048696327 + .long 0 + .long 1071638513 + .long 194866917 + .long 1048899904 + .long 0 + .long 1071646656 + .long 3497355923 + .long 1047579730 + .long 0 + .long 1071651732 + .long 984418162 + .long 1048576793 + .long 0 + .long 1071656820 + .long 1973276684 + .long 1050136256 + .long 0 + .long 1071661920 + .long 3329497336 + .long 1049987327 + .long 0 + .long 1071667033 + .long 1374214759 + .long 1047073231 + .long 0 + .long 1071672159 + .long 2689110139 + .long 1044696853 + .long 0 + .long 1071675583 + .long 3281519615 + .long 1049239454 + .long 0 + .long 1071680729 + .long 106060705 + .long 1049441252 + .long 0 + .long 1071685888 + .long 994445709 + .long 1048383906 + .long 0 + .long 1071691060 + .long 968365306 + .long 1050219142 + .long 0 + .long 1071696244 + .long 1127183666 + .long 1048063436 + .long 0 + .long 1071701442 + .long 1176023037 + .long 1048767474 + .long 0 + .long 1071704914 + .long 494386159 + .long 1048610025 + .long 0 + .long 1071710133 + .long 3484359724 + .long 1048499390 + .long 0 + .long 1071715365 + .long 3217980016 + .long 1048823654 + .long 0 + .long 1071720610 + .long 422622404 + .long 1048883138 + .long 0 + .long 1071724114 + .long 1262752531 + .long 1048980778 + .long 0 + .long 1071729381 + .long 3412819100 + .long 1049899918 + .long 0 + .long 1071734661 + .long 4248496658 + .long 1048338572 + .long 0 + .long 1071738189 + .long 644483909 + .long 1050165690 + .long 0 + .long 1071743491 + .long 3881343467 + .long 1050118499 + .long 0 + .long 1071748807 + .long 2653622880 + .long 1048337361 + .long 0 + .long 1071752359 + .long 2812002981 + .long 1050155308 + .long 0 + .long 1071757697 + .long 224311686 + .long 1050482530 + .long 0 + .long 1071763049 + .long 679701015 + .long 1049869325 + .long 0 + .long 1071766625 + .long 3027506890 + .long 1049908641 + .long 0 + .long 1071772000 + .long 3751375892 + .long 1049481244 + .long 0 + .long 1071777389 + .long 1920294497 + .long 1050102004 + .long 0 + .long 1071780989 + .long 1483524208 + .long 1050119127 + .long 0 + .long 1071786401 + .long 97441208 + .long 1049658186 + .long 0 + .long 1071790017 + .long 3008178484 + .long 1050468097 + .long 0 + .long 1071795452 + .long 3633428993 + .long 1048933205 + .long 0 + .long 1071799084 + .long 272261604 + .long 1048795103 + .long 0 + .long 1071804543 + .long 1886467610 + .long 1049658772 + .long 0 + .long 1071810016 + .long 3703763111 + .long 1048691245 + .long 0 + .long 1071813673 + .long 3272554440 + .long 1049215679 + .long 0 + .long 1071819170 + .long 1615609844 + .long 1047938702 + .long 0 + .long 1071822843 + .long 2101526408 + .long 1049159037 + .long 0 + .long 1071826522 + .long 3501340145 + .long 1048964151 + .long 0 + .long 1071832053 + .long 3398848880 + .long 1050181422 + .long 0 + .long 1071835748 + .long 3113670222 + .long 1047639078 + .long 0 + .long 1071841304 + .long 3113807767 + .long 1050490134 + .long 0 + .long 1071845015 + .long 2638078905 + .long 1050508198 + .long 0 + .long 1071850595 + .long 3402790998 + .long 1048094059 + .long 0 + .long 1071854324 + .long 2677940860 + .long 1046276297 + .long 0 + .long 1071859929 + .long 2914178933 + .long 1050613895 + .long 0 + .long 1071863673 + .long 1395015268 + .long 1049805645 + .long 0 + .long 1071867425 + .long 3443880395 + .long 1049880454 + .long 0 + .long 1071873065 + .long 3880277067 + .long 1046944118 + .long 0 + .long 1071876834 + .long 4190954257 + .long 1048963456 + .long 0 + .long 1071880609 + .long 975315090 + .long 1050660599 + .long 0 + .long 1071886284 + .long 3981445309 + .long 1048841548 + .long 0 + .long 1071890077 + .long 340978156 + .long 1049630357 + .long 0 + .long 1071893876 + .long 3056282856 + .long 1048349819 + .long 0 + .long 1071899588 + .long 3637866925 + .long 1050038234 + .long 0 + .long 1071903404 + .long 1233925752 + .long 1047565029 + .long 0 + .long 1071907228 + .long 3365276628 + .long 1049120293 + .long 0 + .long 1071912976 + .long 1364708917 + .long 1048863613 + .long 0 + .long 1071916817 + .long 2949393003 + .long 1048806573 + .long 0 + .long 1071920665 + .long 2588933741 + .long 1049057850 + .long 0 + .long 1071924520 + .long 1317344960 + .long 1048679202 + .long 0 + .long 1071930316 + .long 4264843208 + .long 1047591051 + .long 0 + .long 1071934189 + .long 1772398646 + .long 1047786577 + .long 0 + .long 1071938069 + .long 855212881 + .long 1049083903 + .long 0 + .long 1071941956 + .long 111728933 + .long 1050121939 + .long 0 + .long 1071947800 + .long 2934994658 + .long 1046035147 + .long 0 + .long 1071951706 + .long 3504420384 + .long 1049933751 + .long 0 + .long 1071955618 + .long 2295312686 + .long 1049747989 + .long 0 + .long 1071959538 + .long 185383186 + .long 1050276648 + .long 0 + .long 1071963465 + .long 2699459344 + .long 1049336105 + .long 0 + .long 1071967400 + .long 3020028019 + .long 1048472693 + .long 0 + .long 1071973316 + .long 365843238 + .long 1049205247 + .long 0 + .long 1071977269 + .long 1597522098 + .long 1045226127 + .long 0 + .long 1071981230 + .long 731482298 + .long 1047741244 + .long 0 + .long 1071985198 + .long 19057756 + .long 1050243827 + .long 0 + .long 1071989173 + .long 2890838867 + .long 1050654615 + .long 0 + .long 1071993156 + .long 2027053605 + .long 1050184234 + .long 0 + .long 1071997147 + .long 858789886 + .long 1047748038 + .long 0 + .long 1072001146 + .long 4288580762 + .long 1046326129 + .long 0 + .long 1072007158 + .long 3861103191 + .long 1049816977 + .long 0 + .long 1072011175 + .long 1902054808 + .long 1050330775 + .long 0 + .long 1072015200 + .long 568089353 + .long 1050301118 + .long 0 + .long 1072019233 + .long 3743438430 + .long 1049790563 + .long 0 + .long 1072023274 + .long 2063211846 + .long 1047622979 + .long 0 + .long 1072027323 + .long 1911797542 + .long 1049675962 + .long 0 + .long 1072031379 + .long 3660869822 + .long 1050198853 + .long 0 + .long 1072035443 + .long 616847508 + .long 1050494731 + .long 0 + .long 1072039515 + .long 225141268 + .long 1050627992 + .long 0 + .long 1072043595 + .long 3898487111 + .long 1050663410 + .long 0 + .long 1072047683 + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .type static_const_table,@object + .size static_const_table,6448 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/acoshf_wmt.S b/external/sgx_libm/ia32/acoshf_wmt.S new file mode 100644 index 0000000000..b2bf2ceab0 --- /dev/null +++ b/external/sgx_libm/ia32/acoshf_wmt.S @@ -0,0 +1,1292 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acoshf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin acoshf + .text + .align 16,0x90 + .globl acoshf +acoshf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movl 112(%esp), %eax + subl $1065353217, %eax + cmpl $1073741823, %eax + jae .L_2TAG_PACKET_0.0.3 + subl $4194303, %eax + js .L_2TAG_PACKET_1.0.3 + cmpl $130023424, %eax + ja .L_2TAG_PACKET_2.0.3 + movss 112(%esp), %xmm0 + cvtps2pd %xmm0, %xmm0 + movapd %xmm0, %xmm1 + mulsd %xmm0, %xmm0 + subsd 96(%ebx), %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + pshufd $85, %xmm0, %xmm1 + movd %xmm1, %eax + movl %eax, %ecx + shrl $20, %eax + shrl $9, %ecx + subl $1023, %eax + cvtsi2sdl %eax, %xmm2 + andpd 112(%ebx), %xmm0 + orpd 96(%ebx), %xmm0 + andl $2040, %ecx + movq 72(%ebx), %xmm1 + mulsd 2176(%ebx,%ecx), %xmm0 + subsd 96(%ebx), %xmm0 + mulsd 80(%ebx), %xmm2 + mulsd %xmm0, %xmm1 + addsd 64(%ebx), %xmm1 + mulsd %xmm0, %xmm1 + addsd 128(%ebx,%ecx), %xmm2 + mulsd %xmm0, %xmm1 + addsd %xmm1, %xmm0 + addsd %xmm2, %xmm0 + movsd %xmm0, 24(%esp) + fldl 24(%esp) + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_2.0.3: + movss 112(%esp), %xmm0 + cvtss2sd %xmm0, %xmm0 + addl $1069547520, %eax + movl %eax, %ecx + shrl $23, %eax + subl $126, %eax + shrl $12, %ecx + cvtsi2sdl %eax, %xmm2 + andpd 112(%ebx), %xmm0 + orpd 96(%ebx), %xmm0 + andl $2040, %ecx + movq 72(%ebx), %xmm1 + mulsd 2176(%ebx,%ecx), %xmm0 + subsd 96(%ebx), %xmm0 + mulsd 80(%ebx), %xmm2 + mulsd %xmm0, %xmm1 + addsd 64(%ebx), %xmm1 + mulsd %xmm0, %xmm1 + addsd 128(%ebx,%ecx), %xmm2 + mulsd %xmm0, %xmm1 + addsd %xmm1, %xmm0 + addsd %xmm2, %xmm0 + movsd %xmm0, 24(%esp) + fldl 24(%esp) + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_1.0.3: + movss 112(%esp), %xmm0 + cvtps2pd %xmm0, %xmm0 + movdqa 48(%ebx), %xmm3 + subsd 96(%ebx), %xmm0 + movdqa %xmm0, %xmm2 + movdqa %xmm0, %xmm1 + addsd %xmm0, %xmm0 + sqrtsd %xmm0, %xmm0 + mulsd %xmm2, %xmm2 + pshufd $68, %xmm1, %xmm1 + pshufd $68, %xmm2, %xmm2 + mulpd %xmm2, %xmm3 + addpd 32(%ebx), %xmm3 + mulpd %xmm2, %xmm3 + addpd 16(%ebx), %xmm3 + mulpd %xmm2, %xmm3 + addpd (%ebx), %xmm3 + mulpd %xmm1, %xmm3 + pshufd $238, %xmm3, %xmm2 + mulsd %xmm3, %xmm1 + addsd %xmm2, %xmm1 + mulsd %xmm0, %xmm1 + addsd %xmm1, %xmm0 + movsd %xmm0, 24(%esp) + fldl 24(%esp) + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_0.0.3: + incl %eax + movl 112(%esp), %edx + je .L_2TAG_PACKET_4.0.3 + andl $2147483647, %edx + cmpl $2139095040, %edx + ja .L_2TAG_PACKET_5.0.3 + cmpl $1073741824, %eax + je .L_2TAG_PACKET_5.0.3 + pcmpeqd %xmm1, %xmm1 + pslld $23, %xmm1 + subss %xmm1, %xmm1 + movss %xmm1, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $137, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_4.0.3: + fldz + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_5.0.3: + flds 112(%esp) + fadd %st(0), %st +.L_2TAG_PACKET_3.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type acoshf,@function + .size acoshf,.-acoshf + .data +# -- End acoshf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 305580873 + .long 1066611507 + .long 1429119421 + .long 3216332117 + .long 2886529429 + .long 1063197348 + .long 3670928078 + .long 3212237666 + .long 2610913564 + .long 1060186234 + .long 1100460448 + .long 3209089799 + .long 3532580246 + .long 1056164631 + .long 3531562621 + .long 3205972992 + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .long 4277811695 + .long 1072049730 + .long 4277811695 + .long 1072049730 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 1440057502 + .long 1063257089 + .long 341338964 + .long 1064833554 + .long 4184355568 + .long 1065621801 + .long 2227658503 + .long 1066152307 + .long 449262470 + .long 1066510009 + .long 1570422842 + .long 1066777242 + .long 121841140 + .long 1067045544 + .long 630691842 + .long 1067281191 + .long 2711485097 + .long 1067500943 + .long 2026622491 + .long 1067619660 + .long 766078039 + .long 1067755853 + .long 4074027864 + .long 1067875476 + .long 3056660584 + .long 1067995528 + .long 3195252556 + .long 1068133258 + .long 116861598 + .long 1068254238 + .long 325086471 + .long 1068375655 + .long 296456961 + .long 1068497513 + .long 2623383041 + .long 1068559379 + .long 1681725707 + .long 1068620754 + .long 2231263004 + .long 1068682354 + .long 2815553124 + .long 1068744181 + .long 2057310944 + .long 1068806237 + .long 2095798018 + .long 1068859611 + .long 2302040698 + .long 1068922096 + .long 745232013 + .long 1068984815 + .long 659581512 + .long 1069047769 + .long 1566132617 + .long 1069101918 + .long 550036981 + .long 1069165314 + .long 2887419564 + .long 1069219844 + .long 1990183441 + .long 1069283688 + .long 3220050856 + .long 1069338605 + .long 1669613218 + .long 1069393703 + .long 2145455994 + .long 1069458213 + .long 4275830246 + .long 1069513705 + .long 1392453108 + .long 1069558451 + .long 1469915213 + .long 1069586382 + .long 2183652476 + .long 1069619086 + .long 2109656884 + .long 1069647220 + .long 636640577 + .long 1069675449 + .long 510517079 + .long 1069703773 + .long 210141498 + .long 1069732193 + .long 2537624622 + .long 1069760709 + .long 1733817001 + .long 1069789323 + .long 137854980 + .long 1069813243 + .long 3905576828 + .long 1069842036 + .long 4131810788 + .long 1069870929 + .long 3760956694 + .long 1069899922 + .long 1473082581 + .long 1069929016 + .long 926113142 + .long 1069953338 + .long 3669742467 + .long 1069982617 + .long 3711755290 + .long 1070007095 + .long 311386407 + .long 1070036564 + .long 705364525 + .long 1070066136 + .long 1973375279 + .long 1070090859 + .long 3589645072 + .long 1070115655 + .long 2425772059 + .long 1070145508 + .long 1074899574 + .long 1070170467 + .long 118003300 + .long 1070200516 + .long 691310403 + .long 1070225639 + .long 3273036717 + .long 1070250837 + .long 1226436560 + .long 1070276112 + .long 2481153995 + .long 1070306542 + .long 3227997535 + .long 1070331985 + .long 1421812646 + .long 1070357506 + .long 3386588242 + .long 1070383104 + .long 2580043380 + .long 1070408781 + .long 1068692560 + .long 1070434537 + .long 938143489 + .long 1070460372 + .long 4293333010 + .long 1070486286 + .long 373864817 + .long 1070512282 + .long 4208958430 + .long 1070538357 + .long 783121462 + .long 1070564515 + .long 870975437 + .long 1070590754 + .long 3338886172 + .long 1070606585 + .long 3772343130 + .long 1070619787 + .long 2408245143 + .long 1070630379 + .long 3811383569 + .long 1070643656 + .long 1622638721 + .long 1070656976 + .long 1290798655 + .long 1070670338 + .long 2457529556 + .long 1070681058 + .long 2398194399 + .long 1070694497 + .long 3190801979 + .long 1070707979 + .long 3352241197 + .long 1070718796 + .long 1829681364 + .long 1070732357 + .long 2568927817 + .long 1070743237 + .long 2676427515 + .long 1070756877 + .long 2882402820 + .long 1070767821 + .long 44944622 + .long 1070781542 + .long 2957945300 + .long 1070792550 + .long 1261787704 + .long 1070806352 + .long 1589923677 + .long 1070817426 + .long 3274931829 + .long 1070828529 + .long 1999843716 + .long 1070842450 + .long 1673619518 + .long 1070853620 + .long 601221319 + .long 1070864820 + .long 3763576649 + .long 1070876049 + .long 1974923437 + .long 1070890129 + .long 1096100617 + .long 1070901427 + .long 2424897952 + .long 1070912755 + .long 2376202600 + .long 1070924114 + .long 1665651958 + .long 1070935504 + .long 1014729354 + .long 1070946925 + .long 722545241 + .long 1070961245 + .long 1800682930 + .long 1070972736 + .long 1029453230 + .long 1070984259 + .long 3450874911 + .long 1070995813 + .long 1228255906 + .long 1071007400 + .long 3711032981 + .long 1071019018 + .long 3075102917 + .long 1071030669 + .long 92696812 + .long 1071042353 + .long 3897749690 + .long 1071051136 + .long 1907922160 + .long 1071062877 + .long 4023807324 + .long 1071074650 + .long 2452345726 + .long 1071086457 + .long 2292128226 + .long 1071098297 + .long 58635942 + .long 1071110171 + .long 864186929 + .long 1071122078 + .long 3555691467 + .long 1071131030 + .long 2003684347 + .long 1071142997 + .long 1479703759 + .long 1071154998 + .long 2537208015 + .long 1071164021 + .long 3699909861 + .long 1071176082 + .long 3934098706 + .long 1071188178 + .long 3885764182 + .long 1071197273 + .long 1357790931 + .long 1071209431 + .long 295956059 + .long 1071221624 + .long 4080877676 + .long 1071230791 + .long 202970280 + .long 1071243047 + .long 3977575845 + .long 1071252261 + .long 35977849 + .long 1071264580 + .long 1585496963 + .long 1071273842 + .long 375247257 + .long 1071286224 + .long 1812199574 + .long 1071295534 + .long 1876912769 + .long 1071307980 + .long 1051846544 + .long 1071317339 + .long 979589448 + .long 1071329850 + .long 71706889 + .long 1071339258 + .long 2790898835 + .long 1071351834 + .long 4013797733 + .long 1071361291 + .long 2541231151 + .long 1071370770 + .long 921733145 + .long 1071383442 + .long 508375805 + .long 1071392971 + .long 3091669954 + .long 1071402521 + .long 3343209673 + .long 1071415289 + .long 1693047557 + .long 1071424891 + .long 173861808 + .long 1071434515 + .long 3515822703 + .long 1071444160 + .long 1974837761 + .long 1071457056 + .long 1189018219 + .long 1071466754 + .long 2441946573 + .long 1071476474 + .long 1887102255 + .long 1071486217 + .long 4271031636 + .long 1071495982 + .long 876995759 + .long 1071509039 + .long 438773454 + .long 1071518858 + .long 172621632 + .long 1071528700 + .long 544035182 + .long 1071538565 + .long 2021801298 + .long 1071548453 + .long 783063308 + .long 1071558365 + .long 1598254051 + .long 1071568300 + .long 651258553 + .long 1071578259 + .long 2719315456 + .long 1071588241 + .long 3993180461 + .long 1071598247 + .long 667093936 + .long 1071608278 + .long 1823716217 + .long 1071618332 + .long 3664357648 + .long 1071628410 + .long 2393914686 + .long 1071638513 + .long 1405419566 + .long 1071646656 + .long 563652001 + .long 1071651732 + .long 1074554091 + .long 1071656820 + .long 3195405229 + .long 1071661920 + .long 2890399284 + .long 1071667033 + .long 420597586 + .long 1071672159 + .long 87278952 + .long 1071675583 + .long 1753119502 + .long 1071680729 + .long 1959759897 + .long 1071685888 + .long 975389815 + .long 1071691060 + .long 3365155278 + .long 1071696244 + .long 811309190 + .long 1071701442 + .long 1269811480 + .long 1071704914 + .long 1108583542 + .long 1071710133 + .long 1034517919 + .long 1071715365 + .long 1327340287 + .long 1071720610 + .long 1388251237 + .long 1071724114 + .long 1488234797 + .long 1071729381 + .long 2711385691 + .long 1071734661 + .long 952179194 + .long 1071738189 + .long 3255685427 + .long 1071743491 + .long 3159039803 + .long 1071748807 + .long 951558972 + .long 1071752359 + .long 3234424125 + .long 1071757697 + .long 3904573547 + .long 1071763049 + .long 2648729924 + .long 1071766625 + .long 2729250212 + .long 1071772000 + .long 2000712574 + .long 1071777389 + .long 3125257108 + .long 1071780989 + .long 3160324803 + .long 1071786401 + .long 2216316974 + .long 1071790017 + .long 3875016090 + .long 1071795452 + .long 1439520610 + .long 1071799084 + .long 1298103361 + .long 1071804543 + .long 2217517956 + .long 1071810016 + .long 1191753587 + .long 1071813673 + .long 1728773900 + .long 1071819170 + .long 747445441 + .long 1071822843 + .long 1670772213 + .long 1071826522 + .long 1471209283 + .long 1071832053 + .long 3287905877 + .long 1071835748 + .long 594038131 + .long 1071841304 + .long 3920147917 + .long 1071845015 + .long 3957142762 + .long 1071850595 + .long 826988438 + .long 1071854324 + .long 242509008 + .long 1071859929 + .long 4173610350 + .long 1071863673 + .long 2518313625 + .long 1071867425 + .long 2671523434 + .long 1071873065 + .long 387544807 + .long 1071876834 + .long 1470497767 + .long 1071880609 + .long 4269259217 + .long 1071886284 + .long 1345663925 + .long 1071890077 + .long 2159323299 + .long 1071893876 + .long 957937516 + .long 1071899588 + .long 2994656967 + .long 1071903404 + .long 556124819 + .long 1071907228 + .long 1631098658 + .long 1071912976 + .long 1368257861 + .long 1071916817 + .long 1309849279 + .long 1071920665 + .long 1567156841 + .long 1071924520 + .long 1179420986 + .long 1071930316 + .long 569448444 + .long 1071934189 + .long 669557459 + .long 1071938069 + .long 1593834700 + .long 1071941956 + .long 3166083125 + .long 1071947800 + .long 211641815 + .long 1071951706 + .long 2780675719 + .long 1071955618 + .long 2400234567 + .long 1071959538 + .long 3482927192 + .long 1071963465 + .long 1852089988 + .long 1071967400 + .long 1020849000 + .long 1071973316 + .long 1718090839 + .long 1071977269 + .long 121152472 + .long 1071981230 + .long 646346839 + .long 1071985198 + .long 3415709705 + .long 1071989173 + .long 4257004898 + .long 1071993156 + .long 3293664199 + .long 1071997147 + .long 649825382 + .long 1072001146 + .long 248887552 + .long 1072007158 + .long 2541522737 + .long 1072011175 + .long 3593780107 + .long 1072015200 + .long 3533041935 + .long 1072019233 + .long 2487426809 + .long 1072023274 + .long 585795318 + .long 1072027323 + .long 2252723088 + .long 1072031379 + .long 3323604690 + .long 1072035443 + .long 3929561382 + .long 1072039515 + .long 4202479723 + .long 1072043595 + .long 4275017539 + .long 1072047683 + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .type static_const_table,@object + .size static_const_table,4224 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/acoshl.S b/external/sgx_libm/ia32/acoshl.S new file mode 100644 index 0000000000..205ab9b444 --- /dev/null +++ b/external/sgx_libm/ia32/acoshl.S @@ -0,0 +1,883 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acoshl.c" + .text +..TXTST0: +# -- Begin acoshl + .text + .align 16,0x90 + .globl acoshl +acoshl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + movl %eax, %ebx + movzbl 17(%ebp), %esi + andl $32767, %ebx + shrl $7, %esi + shll $15, %esi + movl 12(%ebp), %edi + orl %ebx, %esi + movl %edi, %edx + shll $16, %esi + shrl $16, %edx + orl %edx, %esi + addl $-1073709056, %esi + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $1073741824, %esi + jae ..B1.44 +..B1.4: + cmpl $8192, %esi + jae ..B1.21 +..B1.5: + cmpl $64, %esi + jae ..B1.14 +..B1.6: + cmpl $16383, %ebx + je ..B1.39 +..B1.7: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.8: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movl $1, %eax +..B1.11: + fldt 8(%ebp) + testl %eax, %eax + fldl _TWO_52H@GOTOFF(%ecx) + fld %st(0) + fxch %st(2) + faddl 8+_ones@GOTOFF(%ecx) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(0) + fmul %st(1), %st + fld %st(1) + fsub %st(4), %st + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 60+_Q1@GOTOFF(%ecx) + fmul %st(2), %st + fldt 36+_Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_Q1@GOTOFF(%ecx) + fmul %st(3), %st + fldt 24+_Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt _Q1@GOTOFF(%ecx) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st, %st(2) + fld %st(2) + fxch %st(1) + fmulp %st, %st(5) + fadd %st(4), %st + fsqrt + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fld %st(4) + fmul %st(5), %st + fsubrp %st, %st(6) + fld %st(4) + fmul %st(1), %st + fsubrp %st, %st(6) + fxch %st(3) + faddp %st, %st(5) + fdivrp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmulp %st, %st(2) + fadd %st(1), %st + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.13 +..B1.12: + fldcw 14(%esp) +..B1.13: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.42 +..B1.15: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.16: + fldcw 12(%esp) +..B1.17: + movl $1, %eax +..B1.18: + fldt 8(%ebp) + testl %eax, %eax + fldl _TWO_52H@GOTOFF(%ecx) + fldt 132+_Q@GOTOFF(%ecx) + fxch %st(2) + faddl 8+_ones@GOTOFF(%ecx) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fld %st(1) + fsub %st(3), %st + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fxch %st(4) + fstpt 16(%esp) + fldt 16(%esp) + fmul %st(0), %st + fadd %st, %st(4) + fxch %st(3) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 156+_Q@GOTOFF(%ecx) + fmul %st(5), %st + faddp %st, %st(6) + fxch %st(4) + fmul %st, %st(5) + fldt 108+_Q@GOTOFF(%ecx) + faddp %st, %st(6) + fmul %st, %st(5) + fldt 84+_Q@GOTOFF(%ecx) + faddp %st, %st(6) + fmul %st, %st(5) + fldt 60+_Q@GOTOFF(%ecx) + faddp %st, %st(6) + fmul %st, %st(5) + fldt 36+_Q@GOTOFF(%ecx) + faddp %st, %st(6) + fmul %st, %st(5) + fldt 12+_Q@GOTOFF(%ecx) + faddp %st, %st(6) + fmul %st, %st(5) + fldt 144+_Q@GOTOFF(%ecx) + fmul %st(1), %st + fldt 120+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt _Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fldt 180+_Q@GOTOFF(%ecx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fmulp %st, %st(1) + fldt 168+_Q@GOTOFF(%ecx) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(4) + fldt 16(%esp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldl _TWO_52H@GOTOFF(%ecx) + fld %st(0) + fadd %st(3), %st + fsub %st(1), %st + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st, %st(4) + fld %st(4) + fxch %st(1) + fmulp %st, %st(3) + fadd %st(2), %st + fsqrt + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fsubrp %st, %st(3) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(1), %st + fsubrp %st, %st(4) + fxch %st(5) + faddp %st, %st(3) + fdivrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fld %st(0) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmulp %st, %st(4) + fadd %st(3), %st + fmulp %st, %st(4) + fld %st(1) + fmul %st(3), %st + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fmul %st(2), %st + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.20 +..B1.19: + fldcw 14(%esp) +..B1.20: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.21: + movzwl 14(%esp), %esi + movl %esi, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.43 +..B1.22: + orl $-64768, %esi + movw %si, 12(%esp) +..B1.23: + fldcw 12(%esp) +..B1.24: + movzwl 16(%ebp), %eax + movl %eax, %ebx + movl $1, %edx + andl $32767, %ebx +..B1.25: + cmpl $16417, %ebx + jge ..B1.34 +..B1.26: + fldt 8(%ebp) + cmpl $16388, %ebx + jge ..B1.28 +..B1.27: + fldl _TWO_52H@GOTOFF(%ecx) + lea 8+_ones@GOTOFF(%ecx), %eax + fld %st(0) + fld %st(2) + fadd %st(2), %st + fsub %st(2), %st + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + faddl (%eax) + fld %st(0) + fadd %st(2), %st + fsqrt + fadd %st, %st(4) + fxch %st(5) + fsubrp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fsubrp %st, %st(1) + fld %st(3) + fxch %st(4) + fsubr %st, %st(5) + fxch %st(4) + fmul %st(5), %st + fsubrp %st, %st(1) + faddp %st, %st(1) + fld %st(2) + fadd %st(4), %st + fdivrp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(1) + fstpt 16(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl -8(%eax) + jmp ..B1.33 +..B1.28: + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + lea _ones@GOTOFF(%ecx), %eax + fmul %st(1), %st + fld %st(0) + fldl _TWO_32H@GOTOFF(%ecx) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fsubr %st(1), %st + fldl (%eax) + addl $8, %eax + cmpl $16394, %ebx + fldl (%eax) + jge ..B1.30 +..B1.29: + fstp %st(3) + fld %st(3) + fadd %st(3), %st + fld %st(4) + fadd %st(2), %st + fmulp %st, %st(1) + fsqrt + faddp %st, %st(4) + fxch %st(3) + fdivrp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + jmp ..B1.33 +..B1.30: + fstp %st(4) + cmpl $16401, %ebx + jge ..B1.32 +..B1.31: + fld %st(3) + fdiv %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fdivrp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.33 +..B1.32: + fxch %st(2) + fdivrp %st, %st(3) + faddp %st, %st(2) +..B1.33: + fldt 16(%esp) + fld %st(0) + fadd %st(3), %st + fstpt 8(%ebp) + movzwl 16(%ebp), %ebx + andl $32767, %ebx + movl %ebx, %esi + addl $-16383, %ebx + negl %esi + fxch %st(1) + fstpt (%esp) + addl $-2, %esi + movzwl 8(%esp), %edi + andl $32767, %esi + andl $-32768, %edi + orl %esi, %edi + movw %di, 8(%esp) + fldt (%esp) + fmul %st, %st(1) + fxch %st(1) + fstpt 16(%esp) + fmulp %st, %st(1) + jmp ..B1.35 +..B1.34: + fldl _TWO_52H@GOTOFF(%ecx) + andl $-32768, %eax + orl $-49153, %eax + addl $-16382, %ebx + movw %ax, 16(%ebp) + lea 8+_ones@GOTOFF(%ecx), %eax + fldt 8(%ebp) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(1) +..B1.35: + fldt 16(%esp) + fldt 60+_P@GOTOFF(%ecx) + fldt 36+_P@GOTOFF(%ecx) + fldt 12+_P@GOTOFF(%ecx) + movl 12(%ebp), %esi + shrl $23, %esi + andl $255, %esi + movl %ebx, (%esp) + fildl (%esp) + flds __libm_rcp_table_256@GOTOFF(%ecx,%esi,4) + fmul %st, %st(5) + fmulp %st, %st(6) + fxch %st(4) + faddl (%eax) + fld %st(0) + shll $4, %esi + fadd %st(6), %st + fld %st(0) + testl %edx, %edx + fmul %st(1), %st + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fstpt 8(%ebp) + fldt 48+_P@GOTOFF(%ecx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + fmul %st(2), %st + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + fmulp %st, %st(3) + faddl 8+__libm_logl_table_256@GOTOFF(%ecx,%esi) + faddp %st, %st(3) + fxch %st(1) + faddl __libm_logl_table_256@GOTOFF(%esi,%ecx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.37 +..B1.36: + fldcw 14(%esp) +..B1.37: + fldt 16(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + xorl %eax, %eax + jmp ..B1.11 +..B1.39: + cmpl $-2147483648, %edi + jne ..B1.7 +..B1.40: + cmpl $0, 8(%ebp) + jne ..B1.7 +..B1.41: + fldl _zeros@GOTOFF(%ecx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.42: + xorl %eax, %eax + jmp ..B1.18 +..B1.43: + xorl %edx, %edx + jmp ..B1.25 +..B1.44: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.57 +..B1.45: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.46: + fldcw 12(%esp) +..B1.47: + movzwl 16(%ebp), %ebx + movl $1, %edx + andl $32767, %ebx +..B1.48: + cmpl $32767, %ebx + jne ..B1.53 +..B1.49: + cmpl $-2147483648, 12(%ebp) + jne ..B1.52 +..B1.50: + cmpl $0, 8(%ebp) + jne ..B1.52 +..B1.51: + movzbl 17(%ebp), %eax + testl $128, %eax + jne ..B1.53 +..B1.52: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.54 +..B1.53: + fldl _infs@GOTOFF(%ecx) + fmull _zeros@GOTOFF(%ecx) + fstpt (%esp) +..B1.54: + testl %edx, %edx + je ..B1.56 +..B1.55: + fldcw 14(%esp) +..B1.56: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.57: + xorl %edx, %edx + jmp ..B1.48 + .align 16,0x90 + .type acoshl,@function + .size acoshl,.-acoshl + .data +# -- End acoshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49147 + .word 0 + .word 37372 + .word 39321 + .word 39321 + .word 39321 + .word 16377 + .word 0 + .word 18586 + .word 55971 + .word 28086 + .word 46811 + .word 49143 + .word 0 + .word 15813 + .word 59837 + .word 36396 + .word 63715 + .word 16373 + .word 0 + .word 53727 + .word 45078 + .word 40330 + .word 46917 + .word 49140 + .word 0 + .word 48396 + .word 8155 + .word 33124 + .word 36271 + .word 16371 + .word 0 + .type _Q1,@object + .size _Q1,72 + .align 2 +_Q: + .word 48098 + .word 43690 + .word 43690 + .word 43690 + .word 16366 + .word 0 + .word 20923 + .word 52462 + .word 52428 + .word 52428 + .word 49132 + .word 0 + .word 38527 + .word 56172 + .word 28086 + .word 46811 + .word 49143 + .word 0 + .word 47050 + .word 58060 + .word 36408 + .word 63715 + .word 16373 + .word 0 + .word 28121 + .word 12720 + .word 53620 + .word 46917 + .word 49140 + .word 0 + .word 5738 + .word 23392 + .word 25199 + .word 36391 + .word 16371 + .word 0 + .word 9822 + .word 24561 + .word 52037 + .word 58572 + .word 49137 + .word 0 + .word 32045 + .word 31633 + .word 41878 + .word 48451 + .word 16368 + .word 0 + .word 16262 + .word 24754 + .word 13643 + .word 40941 + .word 49135 + .word 0 + .word 36557 + .word 45689 + .word 21168 + .word 35169 + .word 16366 + .word 0 + .word 29793 + .word 40103 + .word 23573 + .word 60969 + .word 49132 + .word 0 + .word 51189 + .word 17117 + .word 14297 + .word 51855 + .word 16363 + .word 0 + .word 6461 + .word 12463 + .word 55551 + .word 38957 + .word 49130 + .word 0 + .word 34939 + .word 19802 + .word 20012 + .word 37205 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43696 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16377 + .word 0 + .type _Q,@object + .size _Q,192 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .type _P,@object + .size _P,72 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/acosl.S b/external/sgx_libm/ia32/acosl.S new file mode 100644 index 0000000000..d13c14dad3 --- /dev/null +++ b/external/sgx_libm/ia32/acosl.S @@ -0,0 +1,1211 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acosl.c" + .text +..TXTST0: +# -- Begin acosl + .text + .align 16,0x90 + .globl acosl +acosl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %edi + pushl %ebx + subl $88, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzbl 17(%ebp), %edx + movzwl 16(%ebp), %eax + andl $128, %edx + andl $32767, %eax + shrl $7, %edx + movzwl 14(%esp), %ecx + cmpl $16383, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jge ..B1.60 +..B1.4: + cmpl $16382, %eax + jge ..B1.47 +..B1.5: + cmpl $16376, %eax + jge ..B1.37 +..B1.6: + cmpl $16371, %eax + jge ..B1.30 +..B1.7: + cmpl $16365, %eax + jge ..B1.23 +..B1.8: + cmpl $16308, %eax + jge ..B1.16 +..B1.9: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.78 +..B1.10: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.11: + fldcw 12(%esp) +..B1.12: + movl $1, %eax +..B1.13: + fldt 12+_pi_02@GOTOFF(%ebx) + testl %eax, %eax + fldt _pi_02@GOTOFF(%ebx) + fldt 8(%ebp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.15 +..B1.14: + fldcw 14(%esp) +..B1.15: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.79 +..B1.17: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.18: + fldcw 12(%esp) +..B1.19: + movl $1, %eax +..B1.20: + fldt 8(%ebp) + testl %eax, %eax + fldt _P4@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fldt 12+_pi_02@GOTOFF(%ebx) + fsubp %st, %st(1) + fldt _pi_02@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.22 +..B1.21: + fldcw 14(%esp) +..B1.22: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.80 +..B1.24: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.25: + fldcw 12(%esp) +..B1.26: + movl $1, %eax +..B1.27: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_P3@GOTOFF(%ebx) + fmul %st(1), %st + fldt _P3@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fldt 12+_pi_02@GOTOFF(%ebx) + fsubp %st, %st(1) + fldt _pi_02@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.29 +..B1.28: + fldcw 14(%esp) +..B1.29: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.30: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.81 +..B1.31: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.32: + fldcw 12(%esp) +..B1.33: + movl $1, %eax +..B1.34: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fld %st(2) + fld %st(3) + fldl _TWO_32H@GOTOFF(%ebx) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fsub %st(1), %st + fldt 36+_P2@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_P2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_P2@GOTOFF(%ebx) + fmulp %st, %st(4) + fldt _P2@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(4) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 12+_pi_02@GOTOFF(%ebx) + fsubp %st, %st(1) + fldt _pi_02@GOTOFF(%ebx) + fsubp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.36 +..B1.35: + fldcw 14(%esp) +..B1.36: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.37: + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.82 +..B1.38: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.39: + fldcw 12(%esp) +..B1.40: + movzwl 16(%ebp), %eax + movl $1, %edx + andl $32767, %eax +..B1.41: + fldt 8(%ebp) + cmpl $16381, %eax + fld %st(0) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fldl _TWO_52H@GOTOFF(%ebx) + fmul %st, %st(2) + fstpt 32(%esp) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fld %st(1) + fsub %st(3), %st + fmul %st, %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fld %st(3) + fmul %st(4), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fld %st(2) + fmul %st(2), %st + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fld %st(1) + fmul %st(2), %st + fadd %st, %st(1) + fxch %st(3) + fstpt 16(%esp) + jge ..B1.43 +..B1.42: + fstp %st(2) + fldt 132+_P1@GOTOFF(%ebx) + fmul %st(2), %st + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_P1@GOTOFF(%ebx) + fldt 120+_P1@GOTOFF(%ebx) + fmul %st(4), %st + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt _P1@GOTOFF(%ebx) + faddp %st, %st(3) + fldt 48(%esp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 16(%esp) + fldt 144+_P1@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + fxch %st(1) + jmp ..B1.44 +..B1.43: + fldt 204+_P@GOTOFF(%ebx) + fmul %st(1), %st + fldt 180+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 156+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 132+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 108+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 192+_P@GOTOFF(%ebx) + fmul %st(2), %st + fldt 168+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 144+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 120+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _P@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 48(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 64(%esp) + fldt 16(%esp) + fldt 228+_P@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(4) + fldt 216+_P@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fld %st(3) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 32(%esp) + fmul %st(3), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) +..B1.44: + fldt (%esp) + testl %edx, %edx + fmulp %st, %st(1) + fld %st(2) + fmul %st(2), %st + faddp %st, %st(1) + faddp %st, %st(2) + fmul %st(2), %st + faddp %st, %st(2) + fldt _pi_02@GOTOFF(%ebx) + fld %st(0) + fsubr %st(3), %st + fchs + fsub %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fldt 12+_pi_02@GOTOFF(%ebx) + fsubp %st, %st(2) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.46 +..B1.45: + fldcw 14(%esp) +..B1.46: + fldt 16(%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.47: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.83 +..B1.48: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.49: + fldcw 12(%esp) +..B1.50: + movl $1, %ecx +..B1.51: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx,%edx,8) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fldl _TWO_32H@GOTOFF(%ebx) + fldl _TWO_52H@GOTOFF(%ebx) + fstpt 16(%esp) + fldt 16(%esp) + fxch %st(3) + fsubrl _ones@GOTOFF(%ebx) + fmul %st(2), %st + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fxch %st(1) + fsub %st(2), %st + fadd %st, %st(1) + fxch %st(1) + fsqrt + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fsubr %st, %st(3) + fld %st(5) + fxch %st(2) + fsub %st(6), %st + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fld %st(4) + fadd %st(1), %st + fdivrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fld %st(2) + fadd %st(2), %st + fld %st(0) + fmul %st(3), %st + fld %st(4) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fstpt 48(%esp) + fldt 48(%esp) + fld %st(1) + fmul %st(4), %st + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + fstpt (%esp) + fld %st(2) + fmul %st(3), %st + fadd %st, %st(1) + fxch %st(2) + fstpt 64(%esp) + fldt 64(%esp) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jbe ..B1.53 +..B1.52: + fstp %st(1) + fldt 132+_P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_P1@GOTOFF(%ebx) + fldt 120+_P1@GOTOFF(%ebx) + fmul %st(3), %st + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _P1@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 48(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt (%esp) + fldt 144+_P1@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(2) + fxch %st(1) + jmp ..B1.54 +..B1.53: + fldt 204+_P@GOTOFF(%ebx) + fmul %st(1), %st + fldt 180+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 156+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 132+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 108+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 192+_P@GOTOFF(%ebx) + fmul %st(2), %st + fldt 168+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 144+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 120+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _P@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 48(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 32(%esp) + fldt (%esp) + fldt 228+_P@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(3) + fldt 216+_P@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fldt 16(%esp) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) +..B1.54: + fldt 64(%esp) + testl %edx, %edx + fmulp %st, %st(2) + fld %st(2) + fmul %st(1), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + je ..B1.56 +..B1.55: + fstp %st(1) + fstp %st(2) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fmul %st, %st(2) + fmulp %st, %st(1) + fldt _pi_00@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fldt 12+_pi_00@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.57 +..B1.56: + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fxch %st(1) + fsub %st, %st(4) + fxch %st(4) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt (%esp) +..B1.57: + testl %ecx, %ecx + je ..B1.59 +..B1.58: + fldcw 14(%esp) +..B1.59: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.60: + movl %ecx, %edi + andl $768, %edi + cmpl $768, %edi + je ..B1.84 +..B1.61: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.62: + fldcw 12(%esp) +..B1.63: + movzwl 16(%ebp), %eax + movl $1, %ecx + andl $32767, %eax +..B1.64: + cmpl $32767, %eax + jne ..B1.68 +..B1.65: + cmpl $-2147483648, 12(%ebp) + jne ..B1.67 +..B1.66: + cmpl $0, 8(%ebp) + je ..B1.74 +..B1.67: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx) + fstpt (%esp) + jmp ..B1.75 +..B1.68: + cmpl $16383, %eax + jne ..B1.74 +..B1.69: + cmpl $-2147483648, 12(%ebp) + jne ..B1.74 +..B1.70: + cmpl $0, 8(%ebp) + jne ..B1.74 +..B1.71: + testl %edx, %edx + je ..B1.73 +..B1.72: + fldt _pi_0l@GOTOFF(%ebx) + fldt _small_value_80@GOTOFF(%ebx) + fsubrp %st, %st(1) + fstpt (%esp) + jmp ..B1.75 +..B1.73: + fldl _zeros@GOTOFF(%ebx) + fstpt (%esp) + jmp ..B1.75 +..B1.74: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpt (%esp) +..B1.75: + testl %ecx, %ecx + je ..B1.77 +..B1.76: + fldcw 14(%esp) +..B1.77: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.78: + xorl %eax, %eax + jmp ..B1.13 +..B1.79: + xorl %eax, %eax + jmp ..B1.20 +..B1.80: + xorl %eax, %eax + jmp ..B1.27 +..B1.81: + xorl %eax, %eax + jmp ..B1.34 +..B1.82: + xorl %edx, %edx + jmp ..B1.41 +..B1.83: + xorl %ecx, %ecx + jmp ..B1.51 +..B1.84: + xorl %ecx, %ecx + jmp ..B1.64 + .align 16,0x90 + .type acosl,@function + .size acosl,.-acosl + .data +# -- End acosl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_pi_02: + .word 0 + .word 0 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 35374 + .word 4889 + .word 2259 + .word 34211 + .word 16349 + .word 0 + .type _pi_02,@object + .size _pi_02,24 + .align 2 +_P4: + .word 43691 + .word 44938 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _P4,@object + .size _P4,12 + .align 2 +_P3: + .word 36763 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 40704 + .word 58046 + .word 39460 + .word 39321 + .word 16379 + .word 0 + .type _P3,@object + .size _P3,24 + .align 2 +_P2: + .word 43688 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 20771 + .word 39331 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 23807 + .word 53798 + .word 28073 + .word 46811 + .word 16378 + .word 0 + .word 35198 + .word 7516 + .word 54204 + .word 63722 + .word 16377 + .word 0 + .type _P2,@object + .size _P2,48 + .align 2 +_P1: + .word 43589 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 39364 + .word 39321 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 17602 + .word 56173 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 47501 + .word 58414 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 27078 + .word 6583 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 39781 + .word 21053 + .word 25224 + .word 36391 + .word 16377 + .word 0 + .word 46568 + .word 6235 + .word 50749 + .word 58572 + .word 16376 + .word 0 + .word 41318 + .word 51558 + .word 37628 + .word 48452 + .word 16376 + .word 0 + .word 55026 + .word 7893 + .word 43866 + .word 40925 + .word 16376 + .word 0 + .word 43387 + .word 19951 + .word 2911 + .word 35445 + .word 16376 + .word 0 + .word 32572 + .word 59281 + .word 11243 + .word 56666 + .word 16375 + .word 0 + .word 49800 + .word 50337 + .word 42707 + .word 39184 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .type _P1,@object + .size _P1,156 + .align 2 +_P: + .word 42691 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 4317 + .word 52400 + .word 52428 + .word 52428 + .word 49134 + .word 0 + .word 26206 + .word 56172 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 36130 + .word 58514 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 21592 + .word 8113 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 3093 + .word 49950 + .word 25215 + .word 36391 + .word 16377 + .word 0 + .word 21499 + .word 24428 + .word 51889 + .word 58572 + .word 16376 + .word 0 + .word 54828 + .word 41264 + .word 61120 + .word 48451 + .word 16376 + .word 0 + .word 10243 + .word 1489 + .word 39717 + .word 40940 + .word 16376 + .word 0 + .word 51433 + .word 46039 + .word 63564 + .word 35220 + .word 16376 + .word 0 + .word 60402 + .word 39286 + .word 25675 + .word 60826 + .word 16375 + .word 0 + .word 34219 + .word 36833 + .word 44839 + .word 57547 + .word 16375 + .word 0 + .word 13013 + .word 26091 + .word 19721 + .word 60832 + .word 16374 + .word 0 + .word 22353 + .word 41544 + .word 55443 + .word 55735 + .word 16376 + .word 0 + .word 14948 + .word 7038 + .word 38091 + .word 38339 + .word 49145 + .word 0 + .word 61727 + .word 61480 + .word 15906 + .word 51927 + .word 16378 + .word 0 + .word 13386 + .word 23084 + .word 64443 + .word 55906 + .word 49146 + .word 0 + .word 17499 + .word 23573 + .word 43947 + .word 42761 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16379 + .word 0 + .type _P,@object + .size _P,240 + .align 2 +_pi_00: + .word 0 + .word 0 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 35374 + .word 4889 + .word 2259 + .word 34211 + .word 16350 + .word 0 + .type _pi_00,@object + .size _pi_00,24 + .align 2 +_pi_0l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49152 + .word 0 + .type _pi_0l,@object + .size _pi_0l,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/asin_wmt.S b/external/sgx_libm/ia32/asin_wmt.S new file mode 100644 index 0000000000..f15bcefa0d --- /dev/null +++ b/external/sgx_libm/ia32/asin_wmt.S @@ -0,0 +1,2008 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asin_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin asin + .text + .align 16,0x90 + .globl asin +asin: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + stmxcsr 16(%esp) + movl 16(%esp), %edx + andl $-24577, %edx + cmpl %edx, 16(%esp) + jne .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + movsd 5984(%ebx), %xmm4 + movsd 6016(%ebx), %xmm3 + xorpd %xmm5, %xmm5 + movsd 6000(%ebx), %xmm2 + movl $8192, %ecx + pinsrw $2, %ecx, %xmm5 + movapd %xmm0, %xmm1 + movsd %xmm0, 8(%esp) + psrlq $44, %xmm0 + movd %xmm0, %edx + movapd %xmm1, %xmm7 + movl $8192, %ecx + pinsrw $2, %ecx, %xmm5 + movapd %xmm1, %xmm0 + movl $524287, %eax + andl %edx, %eax + subl $260864, %eax + cmpl $955, %eax + jae .L_2TAG_PACKET_2.0.3 + mulsd %xmm1, %xmm1 + andl $65535, %edx + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + andpd %xmm7, %xmm2 + andl $-4, %edx + subl $64256, %edx + movsd 3936(%ebx,%edx,2), %xmm1 + orpd %xmm5, %xmm2 + movapd 96(%ebx,%edx,4), %xmm4 + movapd %xmm7, %xmm6 + addsd %xmm2, %xmm7 + subsd %xmm2, %xmm0 + mulsd %xmm7, %xmm0 + mulsd %xmm1, %xmm6 + mulsd %xmm2, %xmm3 + movapd %xmm6, %xmm1 + addsd %xmm3, %xmm6 + divsd %xmm6, %xmm0 + movsd 80(%ebx), %xmm7 + movsd 64(%ebx), %xmm5 + subsd %xmm3, %xmm1 + andpd 6064(%ebx), %xmm2 + movapd %xmm1, %xmm3 + mulsd %xmm1, %xmm1 + movsd 72(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm7 + mulsd %xmm3, %xmm5 + xorpd %xmm2, %xmm4 + mulsd %xmm1, %xmm3 + addsd %xmm7, %xmm6 + mulsd %xmm3, %xmm6 + addsd %xmm4, %xmm5 + pshufd $238, %xmm4, %xmm4 + addsd %xmm5, %xmm6 + orpd %xmm2, %xmm4 + addsd %xmm6, %xmm0 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_3.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_3.0.3: + addsd %xmm4, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_2.0.3: + subl $955, %eax + cmpl $67, %eax + jae .L_2TAG_PACKET_5.0.3 + mulsd %xmm1, %xmm1 + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + movl %edx, %eax + andpd 5984(%ebx), %xmm0 + andpd 6048(%ebx), %xmm7 + movapd %xmm0, %xmm1 + movsd 6016(%ebx), %xmm4 + movapd %xmm7, %xmm6 + subsd %xmm7, %xmm1 + mulsd %xmm7, %xmm7 + addsd %xmm6, %xmm0 + subsd %xmm7, %xmm4 + mulsd %xmm1, %xmm0 + movapd %xmm3, %xmm7 + andpd %xmm3, %xmm2 + psllq $2, %xmm3 + pextrw $3, %xmm3, %edx + orpd %xmm5, %xmm2 + subl $65216, %edx + addl %edx, %edx + mulsd 3936(%ebx,%edx,4), %xmm7 + mulsd %xmm2, %xmm6 + movapd 6080(%ebx), %xmm3 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + subsd %xmm7, %xmm6 + addsd %xmm1, %xmm6 + subsd %xmm2, %xmm4 + addsd %xmm7, %xmm7 + movsd 64(%ebx), %xmm5 + subsd %xmm0, %xmm4 + addsd %xmm6, %xmm7 + movsd 80(%ebx), %xmm0 + divsd %xmm7, %xmm4 + movsd 72(%ebx), %xmm2 + subpd 96(%ebx,%edx,8), %xmm3 + movapd %xmm6, %xmm1 + mulsd %xmm6, %xmm6 + andl $524288, %eax + shrl $4, %eax + mulsd %xmm6, %xmm0 + mulsd %xmm6, %xmm1 + mulsd %xmm1, %xmm5 + mulsd %xmm6, %xmm1 + addsd %xmm2, %xmm0 + pxor %xmm6, %xmm6 + mulsd %xmm1, %xmm0 + addsd %xmm3, %xmm5 + pinsrw $3, %eax, %xmm6 + addsd %xmm5, %xmm0 + movapd %xmm4, %xmm5 + pshufd $238, %xmm3, %xmm3 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm3 + subsd %xmm3, %xmm5 + subsd %xmm5, %xmm0 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_6.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_6.0.3: + xorpd %xmm6, %xmm0 + xorpd %xmm6, %xmm4 + subsd %xmm4, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + addl $15291, %eax + cmpl $14336, %eax + jae .L_2TAG_PACKET_7.0.3 + unpcklpd %xmm7, %xmm7 + movapd (%ebx), %xmm1 + movapd %xmm7, %xmm6 + movapd 16(%ebx), %xmm2 + movapd 32(%ebx), %xmm4 + mulpd %xmm7, %xmm7 + mulpd %xmm7, %xmm6 + mulpd %xmm7, %xmm1 + mulpd %xmm7, %xmm7 + movapd %xmm6, %xmm3 + mulsd %xmm6, %xmm6 + addpd %xmm2, %xmm1 + mulpd %xmm7, %xmm4 + mulsd %xmm3, %xmm6 + addpd %xmm4, %xmm1 + mulpd %xmm6, %xmm1 + pshufd $238, %xmm1, %xmm2 + addsd %xmm2, %xmm1 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_8.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_8.0.3: + addsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_7.0.3: + subl $15358, %eax + cmpl $2, %eax + jae .L_2TAG_PACKET_9.0.3 + mulsd %xmm1, %xmm1 + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + movl %edx, %eax + andpd 6032(%ebx), %xmm7 + pshufd $68, %xmm3, %xmm5 + andpd 6032(%ebx), %xmm3 + movapd %xmm7, %xmm1 + movsd 6016(%ebx), %xmm4 + movapd %xmm7, %xmm6 + subsd %xmm7, %xmm0 + mulsd %xmm7, %xmm7 + addsd %xmm1, %xmm1 + mulsd %xmm0, %xmm1 + subsd %xmm7, %xmm4 + movapd %xmm3, %xmm6 + mulsd %xmm3, %xmm3 + mulsd %xmm0, %xmm0 + subsd %xmm1, %xmm4 + subsd %xmm5, %xmm6 + addsd %xmm5, %xmm5 + subsd %xmm3, %xmm4 + movapd (%ebx), %xmm2 + pshufd $238, %xmm5, %xmm3 + subsd %xmm0, %xmm4 + addsd %xmm6, %xmm5 + pshufd $238, %xmm3, %xmm7 + addsd %xmm3, %xmm3 + mulsd %xmm6, %xmm5 + addsd %xmm5, %xmm4 + pshufd $238, %xmm7, %xmm6 + divsd %xmm3, %xmm4 + movapd 48(%ebx), %xmm1 + movapd 16(%ebx), %xmm5 + movapd 32(%ebx), %xmm0 + mulpd %xmm7, %xmm7 + movapd %xmm6, %xmm3 + mulpd %xmm7, %xmm2 + mulpd %xmm7, %xmm6 + shrl $4, %eax + andl $32768, %eax + mulsd %xmm7, %xmm1 + mulpd %xmm7, %xmm7 + addpd %xmm2, %xmm5 + movapd %xmm6, %xmm2 + mulsd %xmm6, %xmm6 + mulpd %xmm0, %xmm7 + movapd 6080(%ebx), %xmm0 + mulsd %xmm6, %xmm2 + addpd %xmm5, %xmm7 + pshufd $238, %xmm1, %xmm5 + mulsd %xmm2, %xmm6 + mulpd %xmm2, %xmm7 + addsd %xmm5, %xmm1 + xorpd %xmm5, %xmm5 + pshufd $238, %xmm7, %xmm2 + mulsd %xmm6, %xmm1 + pshufd $238, %xmm0, %xmm6 + addsd %xmm2, %xmm7 + movapd %xmm3, %xmm2 + pinsrw $3, %eax, %xmm5 + subsd %xmm6, %xmm3 + addsd %xmm1, %xmm0 + addsd %xmm3, %xmm6 + addsd %xmm4, %xmm7 + subsd %xmm6, %xmm2 + subsd %xmm7, %xmm0 + subsd %xmm2, %xmm0 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_10.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_10.0.3: + xorpd %xmm5, %xmm0 + xorpd %xmm5, %xmm3 + subsd %xmm3, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_9.0.3: + addl $261886, %eax + cmpl $261888, %eax + jb .L_2TAG_PACKET_11.0.3 + movd %xmm0, %ecx + psrlq $32, %xmm0 + movd %xmm0, %edx + andl $2147483647, %edx + movl $1072693248, %eax + subl %edx, %eax + orl %ecx, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_12.0.3 + movq 8(%esp), %xmm2 + movd %xmm2, %edx + psrlq $32, %xmm2 + movd %xmm2, %ecx + andl $2147483647, %ecx + subl $1, %edx + sbbl $2146435072, %ecx + cmpl $0, %ecx + jge .L_2TAG_PACKET_11.0.3 + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %edx + pinsrw $3, %edx, %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $61, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_13.0.3 +.L_2TAG_PACKET_12.0.3: + movsd 5984(%ebx), %xmm1 + movsd 6080(%ebx), %xmm2 + movsd 6088(%ebx), %xmm0 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_14.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_14.0.3: + andnpd %xmm7, %xmm1 + orpd %xmm1, %xmm0 + orpd %xmm1, %xmm2 + addsd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_0.0.3: + movl 16(%esp), %edx + andl $-24577, %edx + movl %edx, 24(%esp) + ldmxcsr 24(%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_11.0.3: + movsd 8(%esp), %xmm0 + xorpd %xmm6, %xmm6 + movapd %xmm0, %xmm7 + pextrw $3, %xmm0, %edx + andl $32752, %edx + subl $16, %edx + cmpl $32736, %edx + jb .L_2TAG_PACKET_15.0.3 + addsd %xmm0, %xmm6 + orpd %xmm6, %xmm0 + mulsd %xmm0, %xmm7 +.L_2TAG_PACKET_15.0.3: + movsd %xmm0, (%esp) + fldl (%esp) +.L_2TAG_PACKET_13.0.3: + movl 16(%esp), %edx + andl $-24577, %edx + cmpl 16(%esp), %edx + je .L_2TAG_PACKET_4.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %edx + andl $24576, %edx + orl %edx, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_4.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type asin,@function + .size asin,.-asin + .data +# -- End asin + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 780903145 + .long 1066854586 + .long 858993459 + .long 1068708659 + .long 3340530119 + .long 1067392113 + .long 1431655765 + .long 1069897045 + .long 1321528399 + .long 1066517740 + .long 3067833783 + .long 1067899757 + .long 2021159460 + .long 1065855096 + .long 2576980378 + .long 1066178969 + .long 1431655765 + .long 1069897045 + .long 858993459 + .long 1068708659 + .long 3067833783 + .long 1067899757 + .long 0 + .long 0 + .long 3822952792 + .long 1021639372 + .long 182792448 + .long 1068507836 + .long 2264213271 + .long 1019558908 + .long 649052928 + .long 1068524253 + .long 1797139609 + .long 1022295143 + .long 1243095296 + .long 1068540671 + .long 1415938756 + .long 1021439537 + .long 2033294592 + .long 1068557090 + .long 2356809978 + .long 1021777916 + .long 3088063744 + .long 1068573510 + .long 2669055318 + .long 1022124482 + .long 180888576 + .long 1068589932 + .long 3566445325 + .long 1021358712 + .long 1970196992 + .long 1068606354 + .long 896980323 + .long 1021319659 + .long 4229555456 + .long 1068622777 + .long 436049712 + .long 1021319758 + .long 2732572160 + .long 1068639202 + .long 583123209 + .long 1020797960 + .long 1842831872 + .long 1068655628 + .long 1370449804 + .long 1021429270 + .long 1628994560 + .long 1068672055 + .long 2411391464 + .long 1021057980 + .long 2159763712 + .long 1068688483 + .long 1208692749 + .long 1021943903 + .long 3503886336 + .long 1068704912 + .long 538793309 + .long 1019744063 + .long 1435187200 + .long 1068721343 + .long 4085087612 + .long 1020608419 + .long 317469952 + .long 1068737775 + .long 144386942 + .long 1021440732 + .long 219617280 + .long 1068754208 + .long 2940088361 + .long 1019981122 + .long 1210558208 + .long 1068770642 + .long 2176850347 + .long 1018373705 + .long 3359268352 + .long 1068787077 + .long 2395611454 + .long 1021889042 + .long 2439803648 + .long 1068803514 + .long 1650705253 + .long 1020227966 + .long 2816203520 + .long 1068819952 + .long 3702166386 + .long 1019379914 + .long 262620672 + .long 1068836392 + .long 1855649370 + .long 1020453124 + .long 3438159616 + .long 1068852832 + .long 923063860 + .long 1019273834 + .long 3822105856 + .long 1068869274 + .long 4289947947 + .long 1019434249 + .long 1483729920 + .long 1068885718 + .long 787455814 + .long 1020738379 + .long 787321088 + .long 1068902163 + .long 3321653337 + .long 1021842569 + .long 1802253312 + .long 1068918609 + .long 2653633526 + .long 1021821525 + .long 302985984 + .long 1068935057 + .long 161272028 + .long 1021655149 + .long 653966080 + .long 1068951506 + .long 2566098667 + .long 1020066219 + .long 2924727296 + .long 1068967956 + .long 3646493722 + .long 1014292285 + .long 2889890304 + .long 1068984408 + .long 1081009196 + .long 1022189620 + .long 619098112 + .long 1069000862 + .long 4011643355 + .long 1021773297 + .long 477017600 + .long 1069017317 + .long 4030305534 + .long 1021292252 + .long 2533403904 + .long 1069033773 + .long 2645187591 + .long 1019527099 + .long 2563102208 + .long 1069050231 + .long 3857293792 + .long 1022311697 + .long 635982336 + .long 1069066691 + .long 3625936637 + .long 1017511744 + .long 1116940800 + .long 1069083152 + .long 3653872993 + .long 1022016631 + .long 4075964160 + .long 1069099614 + .long 2468900271 + .long 1021769532 + .long 993165568 + .long 1069116079 + .long 1358104224 + .long 1021199776 + .long 528586752 + .long 1069132545 + .long 2200950332 + .long 1022024872 + .long 2752395776 + .long 1069149012 + .long 3197072454 + .long 1017751319 + .long 3439855616 + .long 1069165481 + .long 1651081806 + .long 1020809338 + .long 2661257728 + .long 1069181952 + .long 539032752 + .long 1021728805 + .long 486957312 + .long 1069198425 + .long 3136045149 + .long 1016888671 + .long 1282340352 + .long 1069214899 + .long 2593963259 + .long 1018956103 + .long 822921728 + .long 1069231375 + .long 2146032737 + .long 1022306465 + .long 3474216192 + .long 1069247852 + .long 3976811625 + .long 1021350207 + .long 716902656 + .long 1069264332 + .long 718267222 + .long 1018624727 + .long 1211594496 + .long 1069280813 + .long 1485641389 + .long 1018447451 + .long 734070272 + .long 1069297296 + .long 354455128 + .long 1021341291 + .long 3650110720 + .long 1069313780 + .long 682185947 + .long 1021651853 + .long 1440663040 + .long 1069330267 + .long 3558574550 + .long 1021615110 + .long 2766612224 + .long 1069346755 + .long 874607978 + .long 1017746872 + .long 3404011008 + .long 1069363245 + .long 4154988502 + .long 1021439906 + .long 3423949056 + .long 1069379737 + .long 2263202309 + .long 1021479615 + .long 2897587712 + .long 1069396231 + .long 2562065031 + .long 1022090363 + .long 1896159232 + .long 1069412727 + .long 3836237663 + .long 1019867288 + .long 490968576 + .long 1069429225 + .long 3322056743 + .long 1006752762 + .long 3048360192 + .long 1069445724 + .long 1152314833 + .long 1013122252 + .long 1049850624 + .long 1069462226 + .long 3601590727 + .long 1022214610 + .long 3156899584 + .long 1069478729 + .long 1855169970 + .long 1019487271 + .long 851173376 + .long 1069495235 + .long 312649594 + .long 1020868604 + .long 2794281728 + .long 1069511742 + .long 1093490181 + .long 1020777577 + .long 468042496 + .long 1069528252 + .long 1152540679 + .long 1021403732 + .long 2534219264 + .long 1069544763 + .long 2292126035 + .long 1021872430 + .long 1376146432 + .long 1069558527 + .long 3293753641 + .long 1020500454 + .long 4175442432 + .long 1069575044 + .long 3626347564 + .long 1021610969 + .long 3523113472 + .long 1069591566 + .long 339956500 + .long 1021119039 + .long 4003350528 + .long 1069608092 + .long 3429333082 + .long 1022813542 + .long 1611067392 + .long 1069624623 + .long 2298017544 + .long 1021977587 + .long 931782144 + .long 1069641158 + .long 2164684743 + .long 1021250988 + .long 2256725504 + .long 1069657697 + .long 1138762335 + .long 1021443776 + .long 1582853120 + .long 1069674241 + .long 1084010382 + .long 1022994693 + .long 3497758720 + .long 1069690789 + .long 406366244 + .long 1022713586 + .long 3999816960 + .long 1069707342 + .long 1488723042 + .long 1023381290 + .long 3383096064 + .long 1069723900 + .long 2541558953 + .long 1019137887 + .long 1942403584 + .long 1069740463 + .long 1879620343 + .long 1022653642 + .long 4268263680 + .long 1069757030 + .long 3039077047 + .long 1022252545 + .long 2067062272 + .long 1069773603 + .long 4190670677 + .long 1020725863 + .long 4225828096 + .long 1069790180 + .long 1998567321 + .long 1022014385 + .long 2452507136 + .long 1069806763 + .long 1511628873 + .long 1021900300 + .long 1340746240 + .long 1069823351 + .long 788367341 + .long 1022726208 + .long 1190035456 + .long 1069839944 + .long 3856337230 + .long 1021834118 + .long 2300688384 + .long 1069856542 + .long 3211396579 + .long 1022621365 + .long 678886400 + .long 1069873146 + .long 4001011887 + .long 1022042646 + .long 921594112 + .long 1069889755 + .long 557811968 + .long 1023065533 + .long 3331668992 + .long 1069906369 + .long 1877060679 + .long 1022419742 + .long 3917875200 + .long 1069922989 + .long 1181055171 + .long 1022752712 + .long 2984829696 + .long 1069939615 + .long 4294526932 + .long 1021499988 + .long 838049024 + .long 1069956247 + .long 3658081878 + .long 1022957952 + .long 2078928384 + .long 1069972884 + .long 820353701 + .long 1019391107 + .long 2719854336 + .long 1069989527 + .long 1644022489 + .long 1023378240 + .long 3069117696 + .long 1070006176 + .long 2771393702 + .long 1019319954 + .long 3435962368 + .long 1070022831 + .long 3876394145 + .long 1023024433 + .long 4130595328 + .long 1070039492 + .long 1630447748 + .long 1021465882 + .long 1169236224 + .long 1070056160 + .long 2828355997 + .long 1020458120 + .long 3453997312 + .long 1070072833 + .long 164091641 + .long 1020388279 + .long 2708127744 + .long 1070089513 + .long 3036550223 + .long 1023328684 + .long 3540797696 + .long 1070106199 + .long 3710949463 + .long 1022568805 + .long 1972276736 + .long 1070122892 + .long 3885277950 + .long 1019761674 + .long 2613815552 + .long 1070139591 + .long 2764165077 + .long 1022921023 + .long 1487791616 + .long 1070156297 + .long 1330644769 + .long 1023162679 + .long 3207593472 + .long 1070173009 + .long 3911007221 + .long 1022993496 + .long 3797764608 + .long 1070189728 + .long 979712598 + .long 1022554580 + .long 3578920448 + .long 1070206454 + .long 2825738223 + .long 1020223708 + .long 2872795648 + .long 1070223187 + .long 392451124 + .long 1022666279 + .long 2002258432 + .long 1070239927 + .long 3730407632 + .long 1023148291 + .long 1291326464 + .long 1070256674 + .long 3723802980 + .long 1022514089 + .long 1065180928 + .long 1070273428 + .long 2635617463 + .long 1022654470 + .long 1650181632 + .long 1070290189 + .long 2061982883 + .long 1022853411 + .long 3373882880 + .long 1070306957 + .long 319732785 + .long 1022017175 + .long 2270081280 + .long 1070323733 + .long 2237757411 + .long 1023064087 + .long 2963732736 + .long 1070340516 + .long 468839165 + .long 1023293774 + .long 1491099904 + .long 1070357307 + .long 1502657946 + .long 1021533479 + .long 2479636480 + .long 1070374105 + .long 482913562 + .long 1021986286 + .long 1968133632 + .long 1070390911 + .long 3281474337 + .long 1022646400 + .long 291639040 + .long 1070407725 + .long 2453320259 + .long 1022812423 + .long 2081472512 + .long 1070424546 + .long 2939989570 + .long 1023091888 + .long 3380340480 + .long 1070441375 + .long 2850707499 + .long 1021921109 + .long 232287488 + .long 1070458213 + .long 3674625342 + .long 1020725130 + .long 1567614208 + .long 1070475058 + .long 9347334 + .long 1022024009 + .long 3433091072 + .long 1070491911 + .long 282524999 + .long 1021433523 + .long 1876877312 + .long 1070508773 + .long 3470449440 + .long 1019309721 + .long 1538472192 + .long 1070525643 + .long 2089486825 + .long 1019698916 + .long 2763830784 + .long 1070542521 + .long 443498115 + .long 1020505194 + .long 1605381632 + .long 1070559408 + .long 3018871601 + .long 1022869913 + .long 2706946048 + .long 1070576303 + .long 3936260892 + .long 1023175875 + .long 2123887360 + .long 1070593207 + .long 2994220655 + .long 1022825948 + .long 104015104 + .long 1070603108 + .long 335054493 + .long 1023441853 + .long 2904568832 + .long 1070615800 + .long 1451215633 + .long 1023853857 + .long 3456197120 + .long 1070632739 + .long 436334733 + .long 1024026432 + .long 252452352 + .long 1070649697 + .long 34596167 + .long 1024031396 + .long 3328018432 + .long 1070666672 + .long 2644547073 + .long 1024296758 + .long 1255829248 + .long 1070683667 + .long 552832586 + .long 1023763122 + .long 4097058560 + .long 1070700680 + .long 1955640623 + .long 1021394654 + .long 451770112 + .long 1070717714 + .long 3428903777 + .long 1022941142 + .long 408920832 + .long 1070734767 + .long 165503263 + .long 1023894958 + .long 1186960640 + .long 1070751840 + .long 435826450 + .long 1024026134 + .long 19078656 + .long 1070768934 + .long 1834169749 + .long 1022899284 + .long 2743490304 + .long 1070786048 + .long 494581074 + .long 1018818479 + .long 2328961024 + .long 1070803184 + .long 2987908834 + .long 1022581110 + .long 350011392 + .long 1070820342 + .long 240771184 + .long 1024143083 + .long 2692326912 + .long 1070837521 + .long 666056837 + .long 1022394776 + .long 2373274368 + .long 1070854723 + .long 2484337770 + .long 1024228156 + .long 1017131520 + .long 1070871948 + .long 3285648279 + .long 1024025789 + .long 265558272 + .long 1070889196 + .long 392241896 + .long 1024252809 + .long 1778008064 + .long 1070906467 + .long 1536107943 + .long 1023949300 + .long 2937184768 + .long 1070923762 + .long 3541062251 + .long 1019448646 + .long 1144442880 + .long 1070941082 + .long 3691683781 + .long 1022123948 + .long 2410165504 + .long 1070958426 + .long 1804181960 + .long 1023945221 + .long 4174350848 + .long 1070975795 + .long 2016094861 + .long 1021716585 + .long 3897012480 + .long 1070993190 + .long 175294410 + .long 1023703404 + .long 3353623040 + .long 1071010611 + .long 167973242 + .long 1023240839 + .long 45671168 + .long 1071028059 + .long 2166856113 + .long 1021565413 + .long 86063872 + .long 1071045533 + .long 2676254727 + .long 1023985299 + .long 1019772672 + .long 1071063034 + .long 989043593 + .long 1021549587 + .long 414297344 + .long 1071080563 + .long 3960972046 + .long 1024307251 + .long 155173120 + .long 1071098120 + .long 1830919291 + .long 1021592251 + .long 2151562240 + .long 1071115705 + .long 405408666 + .long 1023423128 + .long 4041854720 + .long 1071133319 + .long 2043497827 + .long 1024411503 + .long 3489224192 + .long 1071150963 + .long 3072215864 + .long 1022698635 + .long 2477196288 + .long 1071168637 + .long 1812195139 + .long 1022689192 + .long 3015298816 + .long 1071186341 + .long 764841969 + .long 1021027331 + .long 2844731136 + .long 1071204076 + .long 2878117321 + .long 1019116513 + .long 4028950528 + .long 1071221842 + .long 698911452 + .long 1023265602 + .long 69441536 + .long 1071239641 + .long 3253467847 + .long 1020795075 + .long 1676209920 + .long 1071257471 + .long 4272431167 + .long 1022873982 + .long 2408752384 + .long 1071275334 + .long 648519100 + .long 1024385717 + .long 151623680 + .long 1071293231 + .long 345257017 + .long 1019561408 + .long 1410154240 + .long 1071311161 + .long 197863993 + .long 1023224207 + .long 4131351552 + .long 1071329125 + .long 2620801789 + .long 1024411169 + .long 1999664384 + .long 1071347125 + .long 3952692616 + .long 1024168086 + .long 1617668864 + .long 1071365160 + .long 3019889809 + .long 1021907692 + .long 1032074240 + .long 1071383231 + .long 59469899 + .long 1023656194 + .long 2619492096 + .long 1071401338 + .long 1417526820 + .long 1021457783 + .long 202429440 + .long 1071419483 + .long 2927667935 + .long 1019175447 + .long 525044224 + .long 1071437665 + .long 38166811 + .long 1023981879 + .long 1779258880 + .long 1071455885 + .long 481252500 + .long 1023310234 + .long 2195673600 + .long 1071474144 + .long 3962395981 + .long 1021339088 + .long 44573696 + .long 1071492443 + .long 3936281395 + .long 1023014829 + .long 2226905344 + .long 1071510781 + .long 1515320476 + .long 1024320623 + .long 2800512512 + .long 1071529160 + .long 1225403697 + .long 1021081846 + .long 161113600 + .long 1071547581 + .long 3064809733 + .long 1024173917 + .long 1338410240 + .long 1071566043 + .long 2027604973 + .long 1024362526 + .long 522433280 + .long 1071584548 + .long 2055171723 + .long 1023858825 + .long 539595776 + .long 1071603096 + .long 3868820135 + .long 1022936424 + .long 4264017664 + .long 1071621687 + .long 3228065145 + .long 1023479578 + .long 1733924096 + .long 1071640324 + .long 3511934475 + .long 1022496355 + .long 108880384 + .long 1071651839 + .long 615880967 + .long 1023519706 + .long 3517856512 + .long 1071661202 + .long 3113108559 + .long 1025190289 + .long 4043153152 + .long 1071670589 + .long 1571836218 + .long 1023106116 + .long 3251299072 + .long 1071680000 + .long 3444076102 + .long 1022187841 + .long 2736921600 + .long 1071689435 + .long 272771483 + .long 1025095280 + .long 3897698560 + .long 1071703633 + .long 2075390188 + .long 1022489022 + .long 3209485056 + .long 1071722652 + .long 1438094065 + .long 1021844944 + .long 3781432064 + .long 1071741774 + .long 1675017145 + .long 1024143828 + .long 2684184064 + .long 1071761003 + .long 2259963753 + .long 1024731393 + .long 1840489728 + .long 1071780342 + .long 3372883597 + .long 1023431408 + .long 3764087808 + .long 1071799794 + .long 3307523102 + .long 1024485788 + .long 3006232320 + .long 1071819364 + .long 3088971966 + .long 1025213251 + .long 3374881280 + .long 1071839055 + .long 834437749 + .long 1025236452 + .long 797284864 + .long 1071858872 + .long 3122663941 + .long 1025320473 + .long 545765120 + .long 1071878818 + .long 826539625 + .long 1022450955 + .long 107562240 + .long 1071898898 + .long 339584600 + .long 1022481255 + .long 2123649024 + .long 1071919116 + .long 3912959833 + .long 1024321009 + .long 1562385664 + .long 1071939478 + .long 2846067230 + .long 1023343981 + .long 2963085824 + .long 1071959988 + .long 954548627 + .long 1021475211 + .long 3325550592 + .long 1071980652 + .long 3459651155 + .long 1025305573 + .long 775752448 + .long 1072001476 + .long 3582746667 + .long 1023859460 + .long 3238590720 + .long 1072022464 + .long 634636162 + .long 1024472353 + .long 2758801920 + .long 1072043624 + .long 3078216319 + .long 1025304516 + .long 1370319104 + .long 1072064962 + .long 2570569078 + .long 1025099442 + .long 2615805184 + .long 1072086484 + .long 3729933412 + .long 1024605112 + .long 3077336576 + .long 1072108198 + .long 1948916066 + .long 1024781603 + .long 1099528192 + .long 1072130112 + .long 3139143157 + .long 1023729360 + .long 1231903232 + .long 1072152233 + .long 1349513477 + .long 1024737515 + .long 1507504128 + .long 1072174570 + .long 3484516322 + .long 1024000959 + .long 2214659840 + .long 1072197132 + .long 2563820917 + .long 1025225535 + .long 1804739840 + .long 1072219929 + .long 760038746 + .long 1024482855 + .long 1413746688 + .long 1072242971 + .long 3401734714 + .long 1025129838 + .long 821409536 + .long 1072266269 + .long 3729772551 + .long 1025484796 + .long 3031825664 + .long 1072289834 + .long 122256749 + .long 1024752594 + .long 1710784256 + .long 1072313680 + .long 1518205483 + .long 1024724809 + .long 3025265152 + .long 1072337819 + .long 409951989 + .long 1022835555 + .long 287769088 + .long 1072362267 + .long 800355594 + .long 1022484850 + .long 198179840 + .long 1072387038 + .long 3502926213 + .long 1024209373 + .long 1909130496 + .long 1072412149 + .long 3064694319 + .long 1025380823 + .long 1941732096 + .long 1072437619 + .long 4112930390 + .long 1024294679 + .long 3492010496 + .long 1072463467 + .long 2684918107 + .long 1023220233 + .long 81959680 + .long 1072489716 + .long 220021366 + .long 1020635131 + .long 2297837056 + .long 1072516387 + .long 4027683826 + .long 1021041185 + .long 270404096 + .long 1072543508 + .long 2012766065 + .long 1021780753 + .long 3667376896 + .long 1072571105 + .long 2727981522 + .long 1023009874 + .long 330400256 + .long 1072599212 + .long 2940017003 + .long 1025393439 + .long 1119293952 + .long 1072627861 + .long 1608550416 + .long 1022675612 + .long 3536155904 + .long 1072657091 + .long 349665778 + .long 1025156751 + .long 3078046720 + .long 1072686946 + .long 2016159996 + .long 1022193169 + .long 455228416 + .long 1072705361 + .long 1908539328 + .long 1026126332 + .long 1871505664 + .long 1072720988 + .long 2784700894 + .long 1025922277 + .long 1630994432 + .long 1072737010 + .long 361107678 + .long 1022887244 + .long 2084558336 + .long 1072753462 + .long 2642784509 + .long 1072689083 + .long 1514442531 + .long 1072688953 + .long 333108933 + .long 1072688821 + .long 3392112024 + .long 1072688686 + .long 2099852862 + .long 1072688550 + .long 749609004 + .long 1072688412 + .long 3634632596 + .long 1072688271 + .long 2163248461 + .long 1072688129 + .long 628657846 + .long 1072687985 + .long 3324036511 + .long 1072687838 + .long 1657632815 + .long 1072687690 + .long 4217538760 + .long 1072687539 + .long 2411951597 + .long 1072687387 + .long 533944872 + .long 1072687233 + .long 2876566508 + .long 1072687076 + .long 847936891 + .long 1072686918 + .long 3036019913 + .long 1072686757 + .long 848884575 + .long 1072686595 + .long 2874443326 + .long 1072686430 + .long 520713666 + .long 1072686264 + .long 2375556481 + .long 1072686095 + .long 4141904948 + .long 1072685924 + .long 1522666382 + .long 1072685752 + .long 3105624104 + .long 1072685577 + .long 298666327 + .long 1072685401 + .long 1689524500 + .long 1072685222 + .long 2981002200 + .long 1072685041 + .long 4170844284 + .long 1072684858 + .long 961802263 + .long 1072684674 + .long 1941503454 + .long 1072684487 + .long 2812647170 + .long 1072684298 + .long 3572873869 + .long 1072684107 + .long 4219797823 + .long 1072683914 + .long 456039788 + .long 1072683720 + .long 869096151 + .long 1072683523 + .long 1161535119 + .long 1072683324 + .long 1330865866 + .long 1072683123 + .long 1374571204 + .long 1072682920 + .long 1290107538 + .long 1072682715 + .long 1074904836 + .long 1072682508 + .long 726366587 + .long 1072682299 + .long 241869763 + .long 1072682088 + .long 3913732079 + .long 1072681874 + .long 3149342765 + .long 1072681659 + .long 2240966306 + .long 1072681442 + .long 1185873216 + .long 1072681223 + .long 4276274591 + .long 1072681001 + .long 2919452883 + .long 1072680778 + .long 1407565635 + .long 1072680553 + .long 4032743551 + .long 1072680325 + .long 2202188565 + .long 1072680096 + .long 207977577 + .long 1072679865 + .long 2342160518 + .long 1072679631 + .long 11858423 + .long 1072679396 + .long 1804034453 + .long 1072679158 + .long 3420722787 + .long 1072678918 + .long 563930456 + .long 1072678677 + .long 1820539192 + .long 1072678433 + .long 2892501606 + .long 1072678187 + .long 3776710320 + .long 1072677939 + .long 175063337 + .long 1072677690 + .long 674333171 + .long 1072677438 + .long 976363026 + .long 1072677184 + .long 1077935934 + .long 1072676928 + .long 1921075490 + .long 1072676540 + .long 881493302 + .long 1072676016 + .long 3275752439 + .long 1072675483 + .long 486855588 + .long 1072674943 + .long 1077229111 + .long 1072674394 + .long 723950308 + .long 1072673837 + .long 3693582199 + .long 1072673271 + .long 1367335316 + .long 1072672698 + .long 2305837020 + .long 1072672116 + .long 2184358641 + .long 1072671526 + .long 972682840 + .long 1072670928 + .long 2935101762 + .long 1072670321 + .long 3745513263 + .long 1072669706 + .long 3372320886 + .long 1072669083 + .long 1783464620 + .long 1072668452 + .long 3241386215 + .long 1072667812 + .long 3418125284 + .long 1072667164 + .long 2280219148 + .long 1072666508 + .long 4088700758 + .long 1072665843 + .long 219227400 + .long 1072665171 + .long 3521816918 + .long 1072664489 + .long 1076205279 + .long 1072663800 + .long 1436484616 + .long 1072663102 + .long 271362610 + .long 1072662396 + .long 1838996688 + .long 1072661681 + .long 1807122518 + .long 1072660958 + .long 137953542 + .long 1072660227 + .long 1088178584 + .long 1072659487 + .long 324057537 + .long 1072658739 + .long 2101288076 + .long 1072657982 + .long 2085133974 + .long 1072657217 + .long 235324451 + .long 1072656444 + .long 806051592 + .long 1072655662 + .long 3756033140 + .long 1072654871 + .long 453542543 + .long 1072654073 + .long 3741177327 + .long 1072653265 + .long 691216109 + .long 1072652450 + .long 4145223372 + .long 1072651625 + .long 1174439091 + .long 1072650793 + .long 324416139 + .long 1072649952 + .long 1550246310 + .long 1072649102 + .long 511524674 + .long 1072648244 + .long 1457248482 + .long 1072647377 + .long 45944955 + .long 1072646502 + .long 525537397 + .long 1072645618 + .long 2848440188 + .long 1072644725 + .long 2671555633 + .long 1072643824 + .long 4241172637 + .long 1072642914 + .long 3213094278 + .long 1072641996 + .long 3832503688 + .long 1072641069 + .long 1754091534 + .long 1072640134 + .long 1221921804 + .long 1072639190 + .long 2184526489 + .long 1072638237 + .long 294902089 + .long 1072637276 + .long 4090375270 + .long 1072636305 + .long 632860906 + .long 1072635327 + .long 2753498702 + .long 1072634339 + .long 1808009252 + .long 1072633343 + .long 2036428672 + .long 1072632338 + .long 3383235626 + .long 1072631324 + .long 1497347484 + .long 1072630302 + .long 617018317 + .long 1072629271 + .long 684933058 + .long 1072628231 + .long 1643170798 + .long 1072627182 + .long 3011066360 + .long 1072625592 + .long 957158713 + .long 1072623442 + .long 1390907941 + .long 1072621256 + .long 3819155270 + .long 1072619034 + .long 3443571196 + .long 1072616777 + .long 4045412458 + .long 1072614484 + .long 805503923 + .long 1072612156 + .long 1778922015 + .long 1072609791 + .long 2125033665 + .long 1072607390 + .long 1287203863 + .long 1072604953 + .long 2992629568 + .long 1072602479 + .long 2367267127 + .long 1072599969 + .long 3115526047 + .long 1072597422 + .long 340219539 + .long 1072594839 + .long 2017215719 + .long 1072592218 + .long 3225443424 + .long 1072589560 + .long 3326565673 + .long 1072586865 + .long 1669811211 + .long 1072584133 + .long 1886735022 + .long 1072581363 + .long 3301071171 + .long 1072578555 + .long 928514283 + .long 1072575710 + .long 2656364059 + .long 1072572826 + .long 3473490507 + .long 1072569904 + .long 2649965606 + .long 1072566944 + .long 3736819052 + .long 1072563945 + .long 1680885175 + .long 1072560908 + .long 4413771 + .long 1072557832 + .long 2214869753 + .long 1072554716 + .long 3214725184 + .long 1072551561 + .long 2186079903 + .long 1072548367 + .long 2590372131 + .long 1072545133 + .long 3578146079 + .long 1072541859 + .long 4283712755 + .long 1072538545 + .long 3824834510 + .long 1072535191 + .long 1302400298 + .long 1072531797 + .long 95058636 + .long 1072528362 + .long 3563906063 + .long 1072524885 + .long 2167230730 + .long 1072521368 + .long 3524918334 + .long 1072517809 + .long 2353304918 + .long 1072514209 + .long 1939625839 + .long 1072510567 + .long 1256714581 + .long 1072506883 + .long 3552525848 + .long 1072503156 + .long 3464809522 + .long 1072499387 + .long 4200542593 + .long 1072495575 + .long 355609124 + .long 1072491721 + .long 3684139099 + .long 1072487822 + .long 148355918 + .long 1072483881 + .long 1457689242 + .long 1072479895 + .long 2118591596 + .long 1072475865 + .long 908848089 + .long 1072471791 + .long 877032689 + .long 1072467672 + .long 752012304 + .long 1072463508 + .long 3532301749 + .long 1072459298 + .long 3600563221 + .long 1072455043 + .long 3902857084 + .long 1072450742 + .long 3063101036 + .long 1072446395 + .long 3972344374 + .long 1072442001 + .long 903183549 + .long 1072437561 + .long 983892938 + .long 1072433073 + .long 2722858568 + .long 1072428537 + .long 302790515 + .long 1072423954 + .long 759811057 + .long 1072419322 + .long 2507809922 + .long 1072414641 + .long 2388408813 + .long 1072407528 + .long 2084492942 + .long 1072397870 + .long 2435703301 + .long 1072388010 + .long 1935433360 + .long 1072377945 + .long 2742047290 + .long 1072367671 + .long 2053284205 + .long 1072357185 + .long 657783367 + .long 1072346483 + .long 2893664841 + .long 1072335560 + .long 3718906405 + .long 1072324413 + .long 1547896303 + .long 1072313038 + .long 2494058440 + .long 1072301429 + .long 3133238742 + .long 1072289582 + .long 3327000086 + .long 1072277492 + .long 1860667274 + .long 1072265154 + .long 665340747 + .long 1072252562 + .long 443347841 + .long 1072239710 + .long 581282618 + .long 1072226592 + .long 3349780465 + .long 1072213201 + .long 914217606 + .long 1072199532 + .long 989797661 + .long 1072185576 + .long 945436416 + .long 1072171326 + .long 549291300 + .long 1072156774 + .long 1814636389 + .long 1072141911 + .long 239092858 + .long 1072126729 + .long 1794680724 + .long 1072111217 + .long 1241534678 + .long 1072095366 + .long 3366566214 + .long 1072079164 + .long 1244090828 + .long 1072062601 + .long 1708448120 + .long 1072045663 + .long 3544260650 + .long 1072028337 + .long 1402741403 + .long 1072010610 + .long 2551936888 + .long 1071992465 + .long 617669739 + .long 1071973887 + .long 794002186 + .long 1071954857 + .long 2021237693 + .long 1071935356 + .long 540450384 + .long 1071915364 + .long 1920555537 + .long 1071894857 + .long 2879585206 + .long 1071873811 + .long 3000237455 + .long 1071852199 + .long 3352974346 + .long 1071829991 + .long 569629937 + .long 1071807155 + .long 2077237208 + .long 1071783653 + .long 2284891805 + .long 1071759446 + .long 1226651784 + .long 1071734489 + .long 1102047405 + .long 1071708731 + .long 2009896384 + .long 1071682115 + .long 927419082 + .long 1071654577 + .long 85010366 + .long 1071607413 + .long 696431025 + .long 1071548180 + .long 2611410541 + .long 1071486585 + .long 2612593658 + .long 1071422396 + .long 3548155306 + .long 1071355336 + .long 3887997484 + .long 1071285073 + .long 244854763 + .long 1071211202 + .long 4214445648 + .long 1071133216 + .long 2303966727 + .long 1071050478 + .long 3991040013 + .long 1070962152 + .long 3126952278 + .long 1070867118 + .long 1817448378 + .long 1070763804 + .long 1793814864 + .long 1070649884 + .long 3507224072 + .long 1070447193 + .long 4027609105 + .long 1070148772 + .long 577507993 + .long 1069779414 + .long 2310232419 + .long 1068931829 + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 4294950912 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .long 0 + .long 2147483584 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1073291771 + .type static_const_table,@object + .size static_const_table,6096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/asinf_wmt.S b/external/sgx_libm/ia32/asinf_wmt.S new file mode 100644 index 0000000000..40bb17db58 --- /dev/null +++ b/external/sgx_libm/ia32/asinf_wmt.S @@ -0,0 +1,514 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin asinf + .text + .align 16,0x90 + .globl asinf +asinf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + cvtps2pd %xmm0, %xmm1 + movd %xmm0, %eax + movsd 1040(%ebx), %xmm3 + movl $2139095040, %ecx + movl $8388608, %edx + andl %eax, %ecx + subl $1015021568, %ecx + cmpl $50331648, %ecx + jae .L_2TAG_PACKET_0.0.3 + mulsd %xmm1, %xmm1 + cvtps2pd %xmm0, %xmm2 + shrl $23, %ecx + addl $1, %ecx + shrl %cl, %edx + subsd %xmm1, %xmm3 + orl %edx, %eax + negl %edx + andl %edx, %eax + movd %eax, %xmm4 + sqrtsd %xmm3, %xmm3 + addl %edx, %edx + andl $16777215, %edx + andl %edx, %eax + negl %ecx + addl $24, %ecx + orl $8388608, %eax + shrl %cl, %eax + addl %eax, %eax + movsd (%ebx,%eax,8), %xmm5 + psrlq $31, %xmm0 + movsd 8(%ebx,%eax,8), %xmm1 + psllq $63, %xmm0 + cvtps2pd %xmm4, %xmm4 + mulsd %xmm5, %xmm2 + orpd %xmm1, %xmm0 + movsd 1056(%ebx), %xmm5 + movsd 1072(%ebx), %xmm1 + mulsd %xmm3, %xmm4 + movsd 1088(%ebx), %xmm3 + subsd %xmm4, %xmm2 + pshufd $68, %xmm2, %xmm4 + mulsd %xmm2, %xmm2 + mulsd %xmm4, %xmm5 + mulsd %xmm4, %xmm1 + mulsd %xmm4, %xmm3 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + addsd %xmm5, %xmm3 + addsd %xmm1, %xmm4 + mulsd %xmm3, %xmm2 + addsd %xmm4, %xmm0 + addsd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + jge .L_2TAG_PACKET_2.0.3 + addl $1015021568, %ecx + cmpl $964689920, %ecx + jb .L_2TAG_PACKET_3.0.3 + movsd 1072(%ebx), %xmm2 + movapd %xmm1, %xmm0 + movsd 1088(%ebx), %xmm3 + mulsd %xmm1, %xmm1 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm1 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + mulsd %xmm3, %xmm1 + addsd %xmm2, %xmm0 + addsd %xmm0, %xmm1 + cvtpd2ps %xmm1, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movsd 1104(%ebx), %xmm5 + mulsd %xmm5, %xmm1 + cvtpd2ps %xmm1, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + addl %eax, %eax + cmpl $2130706432, %eax + jne .L_2TAG_PACKET_4.0.3 + movapd 1024(%ebx), %xmm0 + psrlq $63, %xmm1 + psllq $63, %xmm1 + orpd %xmm1, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $-16777216, %eax + ja .L_2TAG_PACKET_5.0.3 + xorps %xmm0, %xmm0 + movl $2139095040, %edx + movd %edx, %xmm1 + mulss %xmm1, %xmm0 + movss %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $62, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_5.0.3: + addss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_1.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type asinf,@function + .size asinf,.-asinf + .data +# -- End asinf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4290772864 + .long 1072693183 + .long 2864569868 + .long 1065353226 + .long 3955135328 + .long 1072692671 + .long 152932388 + .long 1066926224 + .long 1671525387 + .long 1072691647 + .long 2415589551 + .long 1067712845 + .long 2799290704 + .long 1072690109 + .long 3864800403 + .long 1068237715 + .long 2477707161 + .long 1072688057 + .long 725093587 + .long 1068630990 + .long 2787892653 + .long 1072685489 + .long 2536557765 + .long 1068893940 + .long 4138691444 + .long 1072682403 + .long 62552236 + .long 1069157247 + .long 941089134 + .long 1072678798 + .long 165833141 + .long 1069420976 + .long 3045724825 + .long 1072674669 + .long 2611259588 + .long 1069616357 + .long 1338788729 + .long 1072670015 + .long 2616012614 + .long 1069748746 + .long 2049955026 + .long 1072664831 + .long 11397492 + .long 1069881450 + .long 922854000 + .long 1072659114 + .long 2157235516 + .long 1070014503 + .long 326738075 + .long 1072652859 + .long 2788743992 + .long 1070147943 + .long 589211462 + .long 1072646061 + .long 3920198733 + .long 1070281807 + .long 4203970809 + .long 1072638714 + .long 3416546056 + .long 1070416134 + .long 2847908959 + .long 1072630814 + .long 4071425947 + .long 1070550963 + .long 3041144817 + .long 1072622353 + .long 623140044 + .long 1070641216 + .long 254499552 + .long 1072613325 + .long 307519074 + .long 1070709195 + .long 247322296 + .long 1072603721 + .long 2945179265 + .long 1070777488 + .long 1734768715 + .long 1072593533 + .long 3301227932 + .long 1070846119 + .long 512284341 + .long 1072582753 + .long 148694291 + .long 1070915112 + .long 2150320922 + .long 1072571370 + .long 959165711 + .long 1070984490 + .long 307214965 + .long 1072559375 + .long 862254873 + .long 1071054280 + .long 2261822985 + .long 1072546755 + .long 303820077 + .long 1071124509 + .long 2878424532 + .long 1072533499 + .long 1279667396 + .long 1071195205 + .long 1489389340 + .long 1072519594 + .long 3626865975 + .long 1071266398 + .long 1561634021 + .long 1072505025 + .long 1381197995 + .long 1071338121 + .long 1731593006 + .long 1072489777 + .long 685577004 + .long 1071410406 + .long 3972360633 + .long 1072473833 + .long 3426639945 + .long 1071483288 + .long 231016948 + .long 1072457177 + .long 3858097791 + .long 1071556806 + .long 1951983052 + .long 1072439787 + .long 2522397359 + .long 1071631000 + .long 806900869 + .long 1072421644 + .long 1565390008 + .long 1071675292 + .long 2352519275 + .long 1072402724 + .long 2655228975 + .long 1071713130 + .long 3752547712 + .long 1072383003 + .long 3066292715 + .long 1071751375 + .long 1444584515 + .long 1072362455 + .long 933027783 + .long 1071790054 + .long 2960036461 + .long 1072341049 + .long 3589869088 + .long 1071829194 + .long 4214933698 + .long 1072318754 + .long 2973206241 + .long 1071868828 + .long 957213757 + .long 1072295536 + .long 2756129430 + .long 1071908989 + .long 4263431727 + .long 1072271354 + .long 2767348050 + .long 1071949714 + .long 4197201246 + .long 1072246168 + .long 874994578 + .long 1071991044 + .long 1821133236 + .long 1072219931 + .long 3810301671 + .long 1072033022 + .long 2102004657 + .long 1072192590 + .long 4064603671 + .long 1072075699 + .long 1957725919 + .long 1072164088 + .long 276553332 + .long 1072119130 + .long 3365782140 + .long 1072134360 + .long 1120469626 + .long 1072163374 + .long 4096932877 + .long 1072103334 + .long 4291572900 + .long 1072208500 + .long 177757517 + .long 1072070929 + .long 2376322938 + .long 1072254587 + .long 4029755771 + .long 1072037049 + .long 3060434712 + .long 1072301721 + .long 497611374 + .long 1072001591 + .long 4010165530 + .long 1072350003 + .long 3306304935 + .long 1071964429 + .long 388249839 + .long 1072399550 + .long 539435036 + .long 1071925423 + .long 165779504 + .long 1072450495 + .long 2497352827 + .long 1071884403 + .long 1343287957 + .long 1072502997 + .long 884164153 + .long 1071841172 + .long 1828157318 + .long 1072557245 + .long 3653025069 + .long 1071795489 + .long 2128712154 + .long 1072613466 + .long 3056817116 + .long 1071747064 + .long 1489283833 + .long 1072671938 + .long 1840990109 + .long 1071695534 + .long 2059782629 + .long 1072713127 + .long 3931971716 + .long 1071636206 + .long 1027831985 + .long 1072745180 + .long 3187721039 + .long 1071517691 + .long 3329524973 + .long 1072779038 + .long 3649449467 + .long 1071389244 + .long 2110923290 + .long 1072815090 + .long 4055205277 + .long 1071248617 + .long 2992048670 + .long 1072853879 + .long 2715653706 + .long 1071092488 + .long 419466969 + .long 1072896214 + .long 2030806678 + .long 1070915559 + .long 1069790871 + .long 1072943387 + .long 2084655462 + .long 1070708358 + .long 3811755941 + .long 1072997722 + .long 3549768261 + .long 1070304457 + .long 884757291 + .long 1073064302 + .long 4261330719 + .long 1069543419 + .long 3631318613 + .long 1073160613 + .long 1413754136 + .long 1073291771 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 3067833783 + .long 1067899757 + .long 0 + .long 0 + .long 1431655765 + .long 1069897045 + .long 0 + .long 0 + .long 858993459 + .long 1068708659 + .long 0 + .long 0 + .long 1 + .long 1072693248 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,1120 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/asinh_wmt.S b/external/sgx_libm/ia32/asinh_wmt.S new file mode 100644 index 0000000000..0a8baf7567 --- /dev/null +++ b/external/sgx_libm/ia32/asinh_wmt.S @@ -0,0 +1,1860 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinh_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin asinh + .text + .align 16,0x90 + .globl asinh +asinh: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm5 + movsd %xmm0, 8(%esp) + pand 240(%ebx), %xmm0 + pextrw $3, %xmm0, %eax + cmpl $32752, %eax + jge .L_2TAG_PACKET_0.0.2 + cmpl $16304, %eax + jle .L_2TAG_PACKET_1.0.2 + pand 144(%ebx), %xmm5 + movq %xmm5, (%esp) + cmpl $16403, %eax + jle .L_2TAG_PACKET_2.0.2 + cmpl $16816, %eax + jge .L_2TAG_PACKET_3.0.2 + movq 112(%ebx), %xmm1 + movapd %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + addsd 112(%ebx), %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm2, %xmm0 + paddw 256(%ebx), %xmm2 + divsd %xmm0, %xmm1 + movapd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_2.0.2: + movapd %xmm0, %xmm1 + movapd %xmm0, %xmm3 + pand 176(%ebx), %xmm0 + movapd %xmm0, %xmm2 + subsd %xmm0, %xmm1 + addsd %xmm0, %xmm3 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm3 + addsd 112(%ebx), %xmm0 + movapd %xmm3, %xmm4 + addsd %xmm0, %xmm3 + sqrtsd %xmm3, %xmm3 + movapd %xmm3, %xmm5 + pand 176(%ebx), %xmm3 + subsd %xmm3, %xmm5 + movapd %xmm3, %xmm6 + movapd %xmm3, %xmm7 + addsd %xmm3, %xmm2 + mulsd %xmm3, %xmm3 + mulsd %xmm5, %xmm6 + addsd %xmm5, %xmm7 + subsd %xmm3, %xmm0 + subsd %xmm6, %xmm0 + addsd %xmm0, %xmm4 + movapd %xmm2, %xmm0 + divsd %xmm7, %xmm4 + addsd %xmm5, %xmm4 + mulsd 96(%ebx), %xmm4 + addsd %xmm4, %xmm1 +.L_2TAG_PACKET_4.0.2: + movq 208(%ebx), %xmm3 + addsd %xmm1, %xmm0 + movapd %xmm0, %xmm5 + psrlq $41, %xmm5 + pextrw $0, %xmm5, %ecx + pand 176(%ebx), %xmm0 + subsd %xmm0, %xmm2 + addsd %xmm2, %xmm1 + pshufd $68, %xmm0, %xmm4 + pand 160(%ebx), %xmm0 + pand 192(%ebx), %xmm4 + psubd %xmm4, %xmm3 + psubw 112(%ebx), %xmm4 + psrlq $52, %xmm4 + por 112(%ebx), %xmm0 + por 128(%ebx), %xmm4 + mulsd %xmm3, %xmm1 + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_3.0.2: + shrl $4, %eax + subl $1022, %eax + movd %eax, %xmm4 + unpcklpd %xmm4, %xmm4 + movl 12(%esp), %ecx + por 128(%ebx), %xmm4 + pand 160(%ebx), %xmm0 + por 112(%ebx), %xmm0 + movapd %xmm0, %xmm1 + pand 176(%ebx), %xmm0 + subsd %xmm0, %xmm1 + shrl $9, %ecx +.L_2TAG_PACKET_5.0.2: + subpd 128(%ebx), %xmm4 + movq 80(%ebx), %xmm2 + andl $2040, %ecx + mulpd 224(%ebx), %xmm4 + mulsd 4384(%ebx,%ecx), %xmm0 + mulsd 4384(%ebx,%ecx), %xmm1 + subsd 112(%ebx), %xmm0 + movapd %xmm0, %xmm5 + addsd %xmm1, %xmm0 + movapd %xmm0, %xmm3 + unpcklpd %xmm0, %xmm0 + addpd 288(%ebx,%ecx,2), %xmm4 + movhlps %xmm4, %xmm6 + mulpd %xmm0, %xmm0 + mulsd %xmm0, %xmm2 + addpd 64(%ebx), %xmm2 + mulpd %xmm0, %xmm2 + addpd 48(%ebx), %xmm2 + mulpd %xmm0, %xmm2 + movhlps %xmm2, %xmm0 + mulsd %xmm3, %xmm0 + addsd %xmm2, %xmm0 + addsd %xmm1, %xmm0 + movsd (%esp), %xmm1 + addsd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + addsd %xmm5, %xmm0 + por %xmm1, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_1.0.2: + cmpl $15456, %eax + jle .L_2TAG_PACKET_7.0.2 + fldl 8(%esp) + fldl 8(%esp) + fmul %st(0), %st + fldl 32(%ebx) + fmul %st(1), %st + faddl 24(%ebx) + fmul %st(1), %st + faddl 16(%ebx) + fmul %st(1), %st + faddl 8(%ebx) + fmul %st(1), %st + faddl (%ebx) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_7.0.2: + andl $32752, %eax + je .L_2TAG_PACKET_8.0.2 + pextrw $3, %xmm5, %ecx + shrl $15, %ecx + fldl 8(%esp) + fldl 272(%ebx,%ecx,8) + fmul %st(0), %st + fsubrp %st, %st(1) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_8.0.2: + fldl 8(%esp) + fld %st(0) + fmul %st(1), %st + fstpl (%esp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_0.0.2: + addsd %xmm5, %xmm5 + movq %xmm5, (%esp) + fldl (%esp) +.L_2TAG_PACKET_6.0.2: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type asinh,@function + .size asinh,.-asinh + .data +# -- End asinh + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1431655746 + .long 3217380693 + .long 858875226 + .long 1068708659 + .long 2809361764 + .long 3215383405 + .long 1241898124 + .long 1067392054 + .long 966918340 + .long 3214324669 + .long 0 + .long 0 + .long 0 + .long 3219128320 + .long 1431621855 + .long 1070945621 + .long 4294842013 + .long 3218079743 + .long 1289448124 + .long 1070176674 + .long 2077359316 + .long 3217380703 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 0 + .long 4294967295 + .long 0 + .long 4294967295 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 0 + .long 2145386496 + .long 0 + .long 2145386496 + .long 897137782 + .long 1038760431 + .long 4276092928 + .long 1072049730 + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 1048576 + .long 0 + .long 0 + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .long 662290844 + .long 1040545122 + .long 0 + .long 1063257089 + .long 1410206301 + .long 1039423595 + .long 0 + .long 1064833554 + .long 1576129908 + .long 1044327686 + .long 0 + .long 1065621801 + .long 3771466512 + .long 1043372267 + .long 0 + .long 1066152307 + .long 2250061482 + .long 1041942323 + .long 0 + .long 1066510009 + .long 241025648 + .long 1043818160 + .long 0 + .long 1066777242 + .long 3481293707 + .long 1039994007 + .long 0 + .long 1067045544 + .long 17391197 + .long 1042467788 + .long 0 + .long 1067281191 + .long 1429304634 + .long 1045705663 + .long 0 + .long 1067500943 + .long 2258946786 + .long 1045312243 + .long 0 + .long 1067619660 + .long 725099158 + .long 1043780790 + .long 0 + .long 1067755853 + .long 1795694751 + .long 1046370967 + .long 0 + .long 1067875476 + .long 218276363 + .long 1045874206 + .long 0 + .long 1067995528 + .long 3918058606 + .long 1045941877 + .long 0 + .long 1068133258 + .long 2029669416 + .long 1040964778 + .long 0 + .long 1068254238 + .long 111041497 + .long 1042505837 + .long 0 + .long 1068375655 + .long 9214008 + .long 1042394003 + .long 0 + .long 1068497513 + .long 3222421290 + .long 1046711220 + .long 0 + .long 1068559379 + .long 1120482910 + .long 1046024006 + .long 0 + .long 1068620754 + .long 3817590987 + .long 1046519755 + .long 0 + .long 1068682354 + .long 3431328350 + .long 1046805053 + .long 0 + .long 1068744181 + .long 3088376696 + .long 1046390788 + .long 0 + .long 1068806237 + .long 3229576382 + .long 1046428373 + .long 0 + .long 1068859611 + .long 1328753044 + .long 1046554315 + .long 0 + .long 1068922096 + .long 1186666727 + .long 1044788651 + .long 0 + .long 1068984815 + .long 603190068 + .long 1044621365 + .long 0 + .long 1069047769 + .long 1647019864 + .long 1045911122 + .long 0 + .long 1069101918 + .long 4200935885 + .long 1044407410 + .long 0 + .long 1069165314 + .long 3581720604 + .long 1046840144 + .long 0 + .long 1069219844 + .long 2217841072 + .long 1046325234 + .long 0 + .long 1069283688 + .long 1963222525 + .long 1047002562 + .long 0 + .long 1069338605 + .long 2828272122 + .long 1046012177 + .long 0 + .long 1069393703 + .long 3730942205 + .long 1046476867 + .long 0 + .long 1069458213 + .long 3166604115 + .long 1047518079 + .long 0 + .long 1069513705 + .long 2095461845 + .long 1046790089 + .long 0 + .long 1069558451 + .long 322388698 + .long 1046865736 + .long 0 + .long 1069586382 + .long 2407253617 + .long 1047545084 + .long 0 + .long 1069619086 + .long 3437791416 + .long 1047490483 + .long 0 + .long 1069647220 + .long 2693469775 + .long 1045625134 + .long 0 + .long 1069675449 + .long 1454696571 + .long 1045327327 + .long 0 + .long 1069703773 + .long 1940756848 + .long 1043926274 + .long 0 + .long 1069732193 + .long 2244096130 + .long 1047717922 + .long 0 + .long 1069760709 + .long 2856509870 + .long 1047123452 + .long 0 + .long 1069789323 + .long 116200689 + .long 1043361536 + .long 0 + .long 1069813243 + .long 4018367049 + .long 1048385867 + .long 0 + .long 1069842036 + .long 3162755613 + .long 1048496333 + .long 0 + .long 1069870929 + .long 2730655796 + .long 1048315252 + .long 0 + .long 1069899922 + .long 892380602 + .long 1046868829 + .long 0 + .long 1069929016 + .long 3139480334 + .long 1046190510 + .long 0 + .long 1069953338 + .long 1886171545 + .long 1048270714 + .long 0 + .long 1069982617 + .long 2203106387 + .long 1048291228 + .long 0 + .long 1070007095 + .long 659271154 + .long 1044549473 + .long 0 + .long 1070036564 + .long 377790372 + .long 1045759361 + .long 0 + .long 1070066136 + .long 1269824164 + .long 1047357396 + .long 0 + .long 1070090859 + .long 1643831617 + .long 1048231604 + .long 0 + .long 1070115655 + .long 57265969 + .long 1047663307 + .long 0 + .long 1070145508 + .long 2640032722 + .long 1046479978 + .long 0 + .long 1070170467 + .long 2420992102 + .long 1043079769 + .long 0 + .long 1070200516 + .long 2711573521 + .long 1045731911 + .long 0 + .long 1070225639 + .long 1973048145 + .long 1048077010 + .long 0 + .long 1070250837 + .long 4093691059 + .long 1046627963 + .long 0 + .long 1070276112 + .long 4182783767 + .long 1047690348 + .long 0 + .long 1070306542 + .long 2883525439 + .long 1048055018 + .long 0 + .long 1070331985 + .long 3917130655 + .long 1046818760 + .long 0 + .long 1070357506 + .long 2320146059 + .long 1048132455 + .long 0 + .long 1070383104 + .long 3464331364 + .long 1047738634 + .long 0 + .long 1070408781 + .long 674627443 + .long 1046468986 + .long 0 + .long 1070434537 + .long 2152289494 + .long 1046214007 + .long 0 + .long 1070460372 + .long 37897452 + .long 1048575202 + .long 0 + .long 1070486286 + .long 1899477568 + .long 1044793529 + .long 0 + .long 1070512282 + .long 2077140689 + .long 1048534003 + .long 0 + .long 1070538357 + .long 448558287 + .long 1045911230 + .long 0 + .long 1070564515 + .long 3867352000 + .long 1046082819 + .long 0 + .long 1070590754 + .long 2206537816 + .long 1049157739 + .long 0 + .long 1070606585 + .long 1799603998 + .long 1049369388 + .long 0 + .long 1070619787 + .long 4075457018 + .long 1048703324 + .long 0 + .long 1070630379 + .long 572844178 + .long 1049388451 + .long 0 + .long 1070643656 + .long 540240475 + .long 1048063456 + .long 0 + .long 1070656976 + .long 2413664112 + .long 1047739393 + .long 0 + .long 1070670338 + .long 2592177285 + .long 1048727389 + .long 0 + .long 1070681058 + .long 1541931453 + .long 1048698417 + .long 0 + .long 1070694497 + .long 3345398163 + .long 1049085432 + .long 0 + .long 1070707979 + .long 2241984547 + .long 1049164260 + .long 0 + .long 1070718796 + .long 890223989 + .long 1048265646 + .long 0 + .long 1070732357 + .long 1226890683 + .long 1048781783 + .long 0 + .long 1070743237 + .long 1600520378 + .long 1048834273 + .long 0 + .long 1070756877 + .long 1081324478 + .long 1048934847 + .long 0 + .long 1070767821 + .long 1928471339 + .long 1042640487 + .long 0 + .long 1070781542 + .long 982084959 + .long 1048971733 + .long 0 + .long 1070792550 + .long 2380239162 + .long 1047711062 + .long 0 + .long 1070806352 + .long 3609542249 + .long 1048031507 + .long 0 + .long 1070817426 + .long 3466499103 + .long 1049126511 + .long 0 + .long 1070828529 + .long 1626165976 + .long 1048431820 + .long 0 + .long 1070842450 + .long 261635432 + .long 1048113242 + .long 0 + .long 1070853620 + .long 1670437810 + .long 1046604532 + .long 0 + .long 1070864820 + .long 3910575981 + .long 1049365107 + .long 0 + .long 1070876049 + .long 727294688 + .long 1048407484 + .long 0 + .long 1070890129 + .long 3260008354 + .long 1047549258 + .long 0 + .long 1070901427 + .long 872084085 + .long 1048711456 + .long 0 + .long 1070912755 + .long 754632403 + .long 1048687679 + .long 0 + .long 1070924114 + .long 1033413261 + .long 1048105461 + .long 0 + .long 1070935504 + .long 1155773876 + .long 1047412165 + .long 0 + .long 1070946925 + .long 746670859 + .long 1046841493 + .long 0 + .long 1070961245 + .long 1820254373 + .long 1048237327 + .long 0 + .long 1070972736 + .long 3605217861 + .long 1047440922 + .long 0 + .long 1070984259 + .long 2212317823 + .long 1049212421 + .long 0 + .long 1070995813 + .long 2826670683 + .long 1047678316 + .long 0 + .long 1071007400 + .long 3532575187 + .long 1049339451 + .long 0 + .long 1071019018 + .long 413443603 + .long 1049028939 + .long 0 + .long 1071030669 + .long 2964472999 + .long 1043732931 + .long 0 + .long 1071042353 + .long 389771102 + .long 1049430622 + .long 0 + .long 1071051136 + .long 1005132876 + .long 1048342053 + .long 0 + .long 1071062877 + .long 2877512173 + .long 1049492173 + .long 0 + .long 1071074650 + .long 1874411204 + .long 1048724858 + .long 0 + .long 1071086457 + .long 1011596427 + .long 1048646627 + .long 0 + .long 1071098297 + .long 838498113 + .long 1043068341 + .long 0 + .long 1071110171 + .long 409945993 + .long 1047118137 + .long 0 + .long 1071122078 + .long 2035722984 + .long 1049263601 + .long 0 + .long 1071131030 + .long 4272650650 + .long 1048435570 + .long 0 + .long 1071142997 + .long 867757828 + .long 1047923871 + .long 0 + .long 1071154998 + .long 433900304 + .long 1048766295 + .long 0 + .long 1071164021 + .long 2626749065 + .long 1049334020 + .long 0 + .long 1071176082 + .long 2721103389 + .long 1049448370 + .long 0 + .long 1071188178 + .long 3401674810 + .long 1049424769 + .long 0 + .long 1071197273 + .long 3030733799 + .long 1047804815 + .long 0 + .long 1071209431 + .long 1532130487 + .long 1045537774 + .long 0 + .long 1071221624 + .long 225486125 + .long 1049520040 + .long 0 + .long 1071230791 + .long 1326263423 + .long 1044918825 + .long 0 + .long 1071243047 + .long 3029302589 + .long 1049469599 + .long 0 + .long 1071252261 + .long 3326443421 + .long 1042360275 + .long 0 + .long 1071264580 + .long 3770244744 + .long 1048027184 + .long 0 + .long 1071273842 + .long 2568976454 + .long 1045847505 + .long 0 + .long 1071286224 + .long 628040571 + .long 1048248574 + .long 0 + .long 1071295534 + .long 2688775955 + .long 1048311770 + .long 0 + .long 1071307980 + .long 3357093336 + .long 1047484659 + .long 0 + .long 1071317339 + .long 2753529189 + .long 1047343532 + .long 0 + .long 1071329850 + .long 625560417 + .long 1043404964 + .long 0 + .long 1071339258 + .long 2456374941 + .long 1048890167 + .long 0 + .long 1071351834 + .long 748255530 + .long 1049487286 + .long 0 + .long 1071361291 + .long 2246865993 + .long 1048768259 + .long 0 + .long 1071370770 + .long 205672663 + .long 1047230532 + .long 0 + .long 1071383442 + .long 4242870741 + .long 1046367538 + .long 0 + .long 1071392971 + .long 2016709797 + .long 1049037028 + .long 0 + .long 1071402521 + .long 2569308411 + .long 1049159850 + .long 0 + .long 1071415289 + .long 3242472523 + .long 1048132214 + .long 0 + .long 1071424891 + .long 1602055934 + .long 1044691415 + .long 0 + .long 1071434515 + .long 1307177952 + .long 1049244134 + .long 0 + .long 1071444160 + .long 2152237414 + .long 1048407400 + .long 0 + .long 1071457056 + .long 2598207309 + .long 1047639998 + .long 0 + .long 1071466754 + .long 3115077937 + .long 1048719780 + .long 0 + .long 1071476474 + .long 1272724396 + .long 1048321721 + .long 0 + .long 1071486217 + .long 2860867658 + .long 1049612888 + .long 0 + .long 1071495982 + .long 1467300368 + .long 1047143154 + .long 0 + .long 1071509039 + .long 3449085837 + .long 1046095654 + .long 0 + .long 1071518858 + .long 2146871948 + .long 1044681726 + .long 0 + .long 1071528700 + .long 3066750144 + .long 1046492840 + .long 0 + .long 1071538565 + .long 1416401583 + .long 1048453263 + .long 0 + .long 1071548453 + .long 2249840317 + .long 1046959692 + .long 0 + .long 1071558365 + .long 4172904720 + .long 1048039642 + .long 0 + .long 1071568300 + .long 1549017192 + .long 1046702261 + .long 0 + .long 1071578259 + .long 3220736011 + .long 1048855214 + .long 0 + .long 1071588241 + .long 630967006 + .long 1049477219 + .long 0 + .long 1071598247 + .long 3624057028 + .long 1046733189 + .long 0 + .long 1071608278 + .long 3730794064 + .long 1048259820 + .long 0 + .long 1071618332 + .long 570378657 + .long 1049316661 + .long 0 + .long 1071628410 + .long 2814556357 + .long 1048696327 + .long 0 + .long 1071638513 + .long 194866917 + .long 1048899904 + .long 0 + .long 1071646656 + .long 3497355923 + .long 1047579730 + .long 0 + .long 1071651732 + .long 984418162 + .long 1048576793 + .long 0 + .long 1071656820 + .long 1973276684 + .long 1050136256 + .long 0 + .long 1071661920 + .long 3329497336 + .long 1049987327 + .long 0 + .long 1071667033 + .long 1374214759 + .long 1047073231 + .long 0 + .long 1071672159 + .long 2689110139 + .long 1044696853 + .long 0 + .long 1071675583 + .long 3281519615 + .long 1049239454 + .long 0 + .long 1071680729 + .long 106060705 + .long 1049441252 + .long 0 + .long 1071685888 + .long 994445709 + .long 1048383906 + .long 0 + .long 1071691060 + .long 968365306 + .long 1050219142 + .long 0 + .long 1071696244 + .long 1127183666 + .long 1048063436 + .long 0 + .long 1071701442 + .long 1176023037 + .long 1048767474 + .long 0 + .long 1071704914 + .long 494386159 + .long 1048610025 + .long 0 + .long 1071710133 + .long 3484359724 + .long 1048499390 + .long 0 + .long 1071715365 + .long 3217980016 + .long 1048823654 + .long 0 + .long 1071720610 + .long 422622404 + .long 1048883138 + .long 0 + .long 1071724114 + .long 1262752531 + .long 1048980778 + .long 0 + .long 1071729381 + .long 3412819100 + .long 1049899918 + .long 0 + .long 1071734661 + .long 4248496658 + .long 1048338572 + .long 0 + .long 1071738189 + .long 644483909 + .long 1050165690 + .long 0 + .long 1071743491 + .long 3881343467 + .long 1050118499 + .long 0 + .long 1071748807 + .long 2653622880 + .long 1048337361 + .long 0 + .long 1071752359 + .long 2812002981 + .long 1050155308 + .long 0 + .long 1071757697 + .long 224311686 + .long 1050482530 + .long 0 + .long 1071763049 + .long 679701015 + .long 1049869325 + .long 0 + .long 1071766625 + .long 3027506890 + .long 1049908641 + .long 0 + .long 1071772000 + .long 3751375892 + .long 1049481244 + .long 0 + .long 1071777389 + .long 1920294497 + .long 1050102004 + .long 0 + .long 1071780989 + .long 1483524208 + .long 1050119127 + .long 0 + .long 1071786401 + .long 97441208 + .long 1049658186 + .long 0 + .long 1071790017 + .long 3008178484 + .long 1050468097 + .long 0 + .long 1071795452 + .long 3633428993 + .long 1048933205 + .long 0 + .long 1071799084 + .long 272261604 + .long 1048795103 + .long 0 + .long 1071804543 + .long 1886467610 + .long 1049658772 + .long 0 + .long 1071810016 + .long 3703763111 + .long 1048691245 + .long 0 + .long 1071813673 + .long 3272554440 + .long 1049215679 + .long 0 + .long 1071819170 + .long 1615609844 + .long 1047938702 + .long 0 + .long 1071822843 + .long 2101526408 + .long 1049159037 + .long 0 + .long 1071826522 + .long 3501340145 + .long 1048964151 + .long 0 + .long 1071832053 + .long 3398848880 + .long 1050181422 + .long 0 + .long 1071835748 + .long 3113670222 + .long 1047639078 + .long 0 + .long 1071841304 + .long 3113807767 + .long 1050490134 + .long 0 + .long 1071845015 + .long 2638078905 + .long 1050508198 + .long 0 + .long 1071850595 + .long 3402790998 + .long 1048094059 + .long 0 + .long 1071854324 + .long 2677940860 + .long 1046276297 + .long 0 + .long 1071859929 + .long 2914178933 + .long 1050613895 + .long 0 + .long 1071863673 + .long 1395015268 + .long 1049805645 + .long 0 + .long 1071867425 + .long 3443880395 + .long 1049880454 + .long 0 + .long 1071873065 + .long 3880277067 + .long 1046944118 + .long 0 + .long 1071876834 + .long 4190954257 + .long 1048963456 + .long 0 + .long 1071880609 + .long 975315090 + .long 1050660599 + .long 0 + .long 1071886284 + .long 3981445309 + .long 1048841548 + .long 0 + .long 1071890077 + .long 340978156 + .long 1049630357 + .long 0 + .long 1071893876 + .long 3056282856 + .long 1048349819 + .long 0 + .long 1071899588 + .long 3637866925 + .long 1050038234 + .long 0 + .long 1071903404 + .long 1233925752 + .long 1047565029 + .long 0 + .long 1071907228 + .long 3365276628 + .long 1049120293 + .long 0 + .long 1071912976 + .long 1364708917 + .long 1048863613 + .long 0 + .long 1071916817 + .long 2949393003 + .long 1048806573 + .long 0 + .long 1071920665 + .long 2588933741 + .long 1049057850 + .long 0 + .long 1071924520 + .long 1317344960 + .long 1048679202 + .long 0 + .long 1071930316 + .long 4264843208 + .long 1047591051 + .long 0 + .long 1071934189 + .long 1772398646 + .long 1047786577 + .long 0 + .long 1071938069 + .long 855212881 + .long 1049083903 + .long 0 + .long 1071941956 + .long 111728933 + .long 1050121939 + .long 0 + .long 1071947800 + .long 2934994658 + .long 1046035147 + .long 0 + .long 1071951706 + .long 3504420384 + .long 1049933751 + .long 0 + .long 1071955618 + .long 2295312686 + .long 1049747989 + .long 0 + .long 1071959538 + .long 185383186 + .long 1050276648 + .long 0 + .long 1071963465 + .long 2699459344 + .long 1049336105 + .long 0 + .long 1071967400 + .long 3020028019 + .long 1048472693 + .long 0 + .long 1071973316 + .long 365843238 + .long 1049205247 + .long 0 + .long 1071977269 + .long 1597522098 + .long 1045226127 + .long 0 + .long 1071981230 + .long 731482298 + .long 1047741244 + .long 0 + .long 1071985198 + .long 19057756 + .long 1050243827 + .long 0 + .long 1071989173 + .long 2890838867 + .long 1050654615 + .long 0 + .long 1071993156 + .long 2027053605 + .long 1050184234 + .long 0 + .long 1071997147 + .long 858789886 + .long 1047748038 + .long 0 + .long 1072001146 + .long 4288580762 + .long 1046326129 + .long 0 + .long 1072007158 + .long 3861103191 + .long 1049816977 + .long 0 + .long 1072011175 + .long 1902054808 + .long 1050330775 + .long 0 + .long 1072015200 + .long 568089353 + .long 1050301118 + .long 0 + .long 1072019233 + .long 3743438430 + .long 1049790563 + .long 0 + .long 1072023274 + .long 2063211846 + .long 1047622979 + .long 0 + .long 1072027323 + .long 1911797542 + .long 1049675962 + .long 0 + .long 1072031379 + .long 3660869822 + .long 1050198853 + .long 0 + .long 1072035443 + .long 616847508 + .long 1050494731 + .long 0 + .long 1072039515 + .long 225141268 + .long 1050627992 + .long 0 + .long 1072043595 + .long 3898487111 + .long 1050663410 + .long 0 + .long 1072047683 + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .type static_const_table,@object + .size static_const_table,6432 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/asinhf_wmt.S b/external/sgx_libm/ia32/asinhf_wmt.S new file mode 100644 index 0000000000..a754208a16 --- /dev/null +++ b/external/sgx_libm/ia32/asinhf_wmt.S @@ -0,0 +1,1256 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinhf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin asinhf + .text + .align 16,0x90 + .globl asinhf +asinhf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %eax + movl %eax, %ecx + movss %xmm0, 8(%esp) + andl $2147483647, %eax + cmpl $2139095040, %eax + jge .L_2TAG_PACKET_0.0.2 + cmpl $1056964608, %eax + jle .L_2TAG_PACKET_1.0.2 + cvtps2pd %xmm0, %xmm0 + movapd %xmm0, %xmm3 + andpd 128(%ebx), %xmm0 + andpd 112(%ebx), %xmm3 + cmpl $1199570944, %eax + jge .L_2TAG_PACKET_2.0.2 + movapd %xmm0, %xmm1 + mulsd %xmm0, %xmm0 + addsd 96(%ebx), %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + pshufd $85, %xmm0, %xmm1 + movd %xmm1, %eax + movl %eax, %ecx + shrl $20, %eax + shrl $9, %ecx + subl $1023, %eax + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: + movl %eax, %ecx + shrl $23, %eax + subl $126, %eax + shrl $12, %ecx +.L_2TAG_PACKET_3.0.2: + cvtsi2sdl %eax, %xmm2 + andpd 144(%ebx), %xmm0 + orpd 96(%ebx), %xmm0 + andl $2040, %ecx + movq 72(%ebx), %xmm1 + mulsd 2224(%ebx,%ecx), %xmm0 + subsd 96(%ebx), %xmm0 + mulsd 80(%ebx), %xmm2 + mulsd %xmm0, %xmm1 + addsd 64(%ebx), %xmm1 + mulsd %xmm0, %xmm1 + addsd 176(%ebx,%ecx), %xmm2 + mulsd %xmm0, %xmm1 + addsd %xmm1, %xmm0 + addsd %xmm2, %xmm0 + orpd %xmm3, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_1.0.2: + cmpl $838860800, %eax + jle .L_2TAG_PACKET_5.0.2 + cvtps2pd %xmm0, %xmm0 + movapd 48(%ebx), %xmm3 + movapd %xmm0, %xmm1 + mulsd %xmm0, %xmm0 + movapd %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm2 + unpcklpd %xmm0, %xmm0 + mulpd %xmm0, %xmm3 + addpd 32(%ebx), %xmm3 + mulpd %xmm0, %xmm3 + addpd 16(%ebx), %xmm3 + mulpd %xmm0, %xmm3 + addpd (%ebx), %xmm3 + mulpd %xmm2, %xmm3 + pshufd $238, %xmm3, %xmm0 + addsd %xmm3, %xmm0 + mulsd %xmm1, %xmm0 + addsd %xmm1, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_5.0.2: + andl $2139095040, %eax + je .L_2TAG_PACKET_6.0.2 + shrl $31, %ecx + flds 8(%esp) + fsubl 160(%ebx,%ecx,8) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_6.0.2: + flds 8(%esp) + fld %st(0) + fmul %st(1), %st + fstps (%esp) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_0.0.2: + addss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_4.0.2: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type asinhf,@function + .size asinhf,.-asinhf + .data +# -- End asinhf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1429119421 + .long 3217380693 + .long 305580873 + .long 1068708659 + .long 3670928078 + .long 3215383394 + .long 2886529429 + .long 1067391652 + .long 1100460448 + .long 3214332679 + .long 2610913564 + .long 1066477690 + .long 3531562621 + .long 3213313024 + .long 3532580246 + .long 1064553239 + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .long 4277811695 + .long 1072049730 + .long 4277811695 + .long 1072049730 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 0 + .long 862978048 + .long 0 + .long 3010461696 + .long 1440057502 + .long 1063257089 + .long 341338964 + .long 1064833554 + .long 4184355568 + .long 1065621801 + .long 2227658503 + .long 1066152307 + .long 449262470 + .long 1066510009 + .long 1570422842 + .long 1066777242 + .long 121841140 + .long 1067045544 + .long 630691842 + .long 1067281191 + .long 2711485097 + .long 1067500943 + .long 2026622491 + .long 1067619660 + .long 766078039 + .long 1067755853 + .long 4074027864 + .long 1067875476 + .long 3056660584 + .long 1067995528 + .long 3195252556 + .long 1068133258 + .long 116861598 + .long 1068254238 + .long 325086471 + .long 1068375655 + .long 296456961 + .long 1068497513 + .long 2623383041 + .long 1068559379 + .long 1681725707 + .long 1068620754 + .long 2231263004 + .long 1068682354 + .long 2815553124 + .long 1068744181 + .long 2057310944 + .long 1068806237 + .long 2095798018 + .long 1068859611 + .long 2302040698 + .long 1068922096 + .long 745232013 + .long 1068984815 + .long 659581512 + .long 1069047769 + .long 1566132617 + .long 1069101918 + .long 550036981 + .long 1069165314 + .long 2887419564 + .long 1069219844 + .long 1990183441 + .long 1069283688 + .long 3220050856 + .long 1069338605 + .long 1669613218 + .long 1069393703 + .long 2145455994 + .long 1069458213 + .long 4275830246 + .long 1069513705 + .long 1392453108 + .long 1069558451 + .long 1469915213 + .long 1069586382 + .long 2183652476 + .long 1069619086 + .long 2109656884 + .long 1069647220 + .long 636640577 + .long 1069675449 + .long 510517079 + .long 1069703773 + .long 210141498 + .long 1069732193 + .long 2537624622 + .long 1069760709 + .long 1733817001 + .long 1069789323 + .long 137854980 + .long 1069813243 + .long 3905576828 + .long 1069842036 + .long 4131810788 + .long 1069870929 + .long 3760956694 + .long 1069899922 + .long 1473082581 + .long 1069929016 + .long 926113142 + .long 1069953338 + .long 3669742467 + .long 1069982617 + .long 3711755290 + .long 1070007095 + .long 311386407 + .long 1070036564 + .long 705364525 + .long 1070066136 + .long 1973375279 + .long 1070090859 + .long 3589645072 + .long 1070115655 + .long 2425772059 + .long 1070145508 + .long 1074899574 + .long 1070170467 + .long 118003300 + .long 1070200516 + .long 691310403 + .long 1070225639 + .long 3273036717 + .long 1070250837 + .long 1226436560 + .long 1070276112 + .long 2481153995 + .long 1070306542 + .long 3227997535 + .long 1070331985 + .long 1421812646 + .long 1070357506 + .long 3386588242 + .long 1070383104 + .long 2580043380 + .long 1070408781 + .long 1068692560 + .long 1070434537 + .long 938143489 + .long 1070460372 + .long 4293333010 + .long 1070486286 + .long 373864817 + .long 1070512282 + .long 4208958430 + .long 1070538357 + .long 783121462 + .long 1070564515 + .long 870975437 + .long 1070590754 + .long 3338886172 + .long 1070606585 + .long 3772343130 + .long 1070619787 + .long 2408245143 + .long 1070630379 + .long 3811383569 + .long 1070643656 + .long 1622638721 + .long 1070656976 + .long 1290798655 + .long 1070670338 + .long 2457529556 + .long 1070681058 + .long 2398194399 + .long 1070694497 + .long 3190801979 + .long 1070707979 + .long 3352241197 + .long 1070718796 + .long 1829681364 + .long 1070732357 + .long 2568927817 + .long 1070743237 + .long 2676427515 + .long 1070756877 + .long 2882402820 + .long 1070767821 + .long 44944622 + .long 1070781542 + .long 2957945300 + .long 1070792550 + .long 1261787704 + .long 1070806352 + .long 1589923677 + .long 1070817426 + .long 3274931829 + .long 1070828529 + .long 1999843716 + .long 1070842450 + .long 1673619518 + .long 1070853620 + .long 601221319 + .long 1070864820 + .long 3763576649 + .long 1070876049 + .long 1974923437 + .long 1070890129 + .long 1096100617 + .long 1070901427 + .long 2424897952 + .long 1070912755 + .long 2376202600 + .long 1070924114 + .long 1665651958 + .long 1070935504 + .long 1014729354 + .long 1070946925 + .long 722545241 + .long 1070961245 + .long 1800682930 + .long 1070972736 + .long 1029453230 + .long 1070984259 + .long 3450874911 + .long 1070995813 + .long 1228255906 + .long 1071007400 + .long 3711032981 + .long 1071019018 + .long 3075102917 + .long 1071030669 + .long 92696812 + .long 1071042353 + .long 3897749690 + .long 1071051136 + .long 1907922160 + .long 1071062877 + .long 4023807324 + .long 1071074650 + .long 2452345726 + .long 1071086457 + .long 2292128226 + .long 1071098297 + .long 58635942 + .long 1071110171 + .long 864186929 + .long 1071122078 + .long 3555691467 + .long 1071131030 + .long 2003684347 + .long 1071142997 + .long 1479703759 + .long 1071154998 + .long 2537208015 + .long 1071164021 + .long 3699909861 + .long 1071176082 + .long 3934098706 + .long 1071188178 + .long 3885764182 + .long 1071197273 + .long 1357790931 + .long 1071209431 + .long 295956059 + .long 1071221624 + .long 4080877676 + .long 1071230791 + .long 202970280 + .long 1071243047 + .long 3977575845 + .long 1071252261 + .long 35977849 + .long 1071264580 + .long 1585496963 + .long 1071273842 + .long 375247257 + .long 1071286224 + .long 1812199574 + .long 1071295534 + .long 1876912769 + .long 1071307980 + .long 1051846544 + .long 1071317339 + .long 979589448 + .long 1071329850 + .long 71706889 + .long 1071339258 + .long 2790898835 + .long 1071351834 + .long 4013797733 + .long 1071361291 + .long 2541231151 + .long 1071370770 + .long 921733145 + .long 1071383442 + .long 508375805 + .long 1071392971 + .long 3091669954 + .long 1071402521 + .long 3343209673 + .long 1071415289 + .long 1693047557 + .long 1071424891 + .long 173861808 + .long 1071434515 + .long 3515822703 + .long 1071444160 + .long 1974837761 + .long 1071457056 + .long 1189018219 + .long 1071466754 + .long 2441946573 + .long 1071476474 + .long 1887102255 + .long 1071486217 + .long 4271031636 + .long 1071495982 + .long 876995759 + .long 1071509039 + .long 438773454 + .long 1071518858 + .long 172621632 + .long 1071528700 + .long 544035182 + .long 1071538565 + .long 2021801298 + .long 1071548453 + .long 783063308 + .long 1071558365 + .long 1598254051 + .long 1071568300 + .long 651258553 + .long 1071578259 + .long 2719315456 + .long 1071588241 + .long 3993180461 + .long 1071598247 + .long 667093936 + .long 1071608278 + .long 1823716217 + .long 1071618332 + .long 3664357648 + .long 1071628410 + .long 2393914686 + .long 1071638513 + .long 1405419566 + .long 1071646656 + .long 563652001 + .long 1071651732 + .long 1074554091 + .long 1071656820 + .long 3195405229 + .long 1071661920 + .long 2890399284 + .long 1071667033 + .long 420597586 + .long 1071672159 + .long 87278952 + .long 1071675583 + .long 1753119502 + .long 1071680729 + .long 1959759897 + .long 1071685888 + .long 975389815 + .long 1071691060 + .long 3365155278 + .long 1071696244 + .long 811309190 + .long 1071701442 + .long 1269811480 + .long 1071704914 + .long 1108583542 + .long 1071710133 + .long 1034517919 + .long 1071715365 + .long 1327340287 + .long 1071720610 + .long 1388251237 + .long 1071724114 + .long 1488234797 + .long 1071729381 + .long 2711385691 + .long 1071734661 + .long 952179194 + .long 1071738189 + .long 3255685427 + .long 1071743491 + .long 3159039803 + .long 1071748807 + .long 951558972 + .long 1071752359 + .long 3234424125 + .long 1071757697 + .long 3904573547 + .long 1071763049 + .long 2648729924 + .long 1071766625 + .long 2729250212 + .long 1071772000 + .long 2000712574 + .long 1071777389 + .long 3125257108 + .long 1071780989 + .long 3160324803 + .long 1071786401 + .long 2216316974 + .long 1071790017 + .long 3875016090 + .long 1071795452 + .long 1439520610 + .long 1071799084 + .long 1298103361 + .long 1071804543 + .long 2217517956 + .long 1071810016 + .long 1191753587 + .long 1071813673 + .long 1728773900 + .long 1071819170 + .long 747445441 + .long 1071822843 + .long 1670772213 + .long 1071826522 + .long 1471209283 + .long 1071832053 + .long 3287905877 + .long 1071835748 + .long 594038131 + .long 1071841304 + .long 3920147917 + .long 1071845015 + .long 3957142762 + .long 1071850595 + .long 826988438 + .long 1071854324 + .long 242509008 + .long 1071859929 + .long 4173610350 + .long 1071863673 + .long 2518313625 + .long 1071867425 + .long 2671523434 + .long 1071873065 + .long 387544807 + .long 1071876834 + .long 1470497767 + .long 1071880609 + .long 4269259217 + .long 1071886284 + .long 1345663925 + .long 1071890077 + .long 2159323299 + .long 1071893876 + .long 957937516 + .long 1071899588 + .long 2994656967 + .long 1071903404 + .long 556124819 + .long 1071907228 + .long 1631098658 + .long 1071912976 + .long 1368257861 + .long 1071916817 + .long 1309849279 + .long 1071920665 + .long 1567156841 + .long 1071924520 + .long 1179420986 + .long 1071930316 + .long 569448444 + .long 1071934189 + .long 669557459 + .long 1071938069 + .long 1593834700 + .long 1071941956 + .long 3166083125 + .long 1071947800 + .long 211641815 + .long 1071951706 + .long 2780675719 + .long 1071955618 + .long 2400234567 + .long 1071959538 + .long 3482927192 + .long 1071963465 + .long 1852089988 + .long 1071967400 + .long 1020849000 + .long 1071973316 + .long 1718090839 + .long 1071977269 + .long 121152472 + .long 1071981230 + .long 646346839 + .long 1071985198 + .long 3415709705 + .long 1071989173 + .long 4257004898 + .long 1071993156 + .long 3293664199 + .long 1071997147 + .long 649825382 + .long 1072001146 + .long 248887552 + .long 1072007158 + .long 2541522737 + .long 1072011175 + .long 3593780107 + .long 1072015200 + .long 3533041935 + .long 1072019233 + .long 2487426809 + .long 1072023274 + .long 585795318 + .long 1072027323 + .long 2252723088 + .long 1072031379 + .long 3323604690 + .long 1072035443 + .long 3929561382 + .long 1072039515 + .long 4202479723 + .long 1072043595 + .long 4275017539 + .long 1072047683 + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .type static_const_table,@object + .size static_const_table,4272 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/asinhl.S b/external/sgx_libm/ia32/asinhl.S new file mode 100644 index 0000000000..4842b34a58 --- /dev/null +++ b/external/sgx_libm/ia32/asinhl.S @@ -0,0 +1,1003 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinhl.c" + .text +..TXTST0: +# -- Begin asinhl + .text + .align 16,0x90 + .globl asinhl +asinhl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $56, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %ebx + andl $32767, %ebx + movzwl 14(%esp), %eax + cmpl $32767, %ebx + je ..B1.73 +..B1.4: + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $16382, %ebx + jge ..B1.46 +..B1.5: + cmpl $16376, %ebx + jge ..B1.39 +..B1.6: + cmpl $16371, %ebx + jge ..B1.32 +..B1.7: + cmpl $16365, %ebx + jge ..B1.25 +..B1.8: + cmpl $16308, %ebx + jge ..B1.18 +..B1.9: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.67 +..B1.10: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.11: + fldcw 12(%esp) +..B1.12: + movzwl 16(%ebp), %ebx + movl $1, %eax + andl $32767, %ebx +..B1.13: + testl %ebx, %ebx + jle ..B1.63 +..B1.14: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ecx) + fmul %st(1), %st + fsubp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ecx) + fstpt (%esp) +..B1.15: + testl %eax, %eax + je ..B1.17 +..B1.16: + fldcw 14(%esp) +..B1.17: + fldt (%esp) + addl $56, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.68 +..B1.19: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.20: + fldcw 12(%esp) +..B1.21: + movl $1, %eax +..B1.22: + fldt 8(%ebp) + testl %eax, %eax + fldt _Q3@GOTOFF(%ecx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.24 +..B1.23: + fldcw 14(%esp) +..B1.24: + fldt (%esp) + addl $56, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.69 +..B1.26: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.27: + fldcw 12(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_Q2@GOTOFF(%ecx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.31 +..B1.30: + fldcw 14(%esp) +..B1.31: + fldt (%esp) + addl $56, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.70 +..B1.33: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.34: + fldcw 12(%esp) +..B1.35: + movl $1, %eax +..B1.36: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%ecx) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%ecx) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.38 +..B1.37: + fldcw 14(%esp) +..B1.38: + fldt (%esp) + addl $56, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.71 +..B1.40: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.41: + fldcw 12(%esp) +..B1.42: + movl $1, %eax +..B1.43: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fld %st(1) + fldl _TWO_53H@GOTOFF(%ecx) + fmul %st(3), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fmul %st(0), %st + fstpt 32(%esp) + fldt 32(%esp) + fadd %st, %st(2) + fld %st(2) + fmul %st(2), %st + fxch %st(4) + fstpt 16(%esp) + fld %st(1) + fmul %st(1), %st + faddp %st, %st(4) + fld %st(3) + fxch %st(1) + fmul %st(0), %st + fadd %st, %st(1) + fldt 228+_Q@GOTOFF(%ecx) + fmul %st(2), %st + fldt 204+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 180+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 156+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 132+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 108+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 216+_Q@GOTOFF(%ecx) + fmul %st(3), %st + fldt 192+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 168+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 144+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 120+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt _Q@GOTOFF(%ecx) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt 252+_Q@GOTOFF(%ecx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fmulp %st, %st(3) + fldt 240+_Q@GOTOFF(%ecx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 32(%esp) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 16(%esp) + fld %st(0) + fldl _TWO_48H@GOTOFF(%ecx) + fld %st(0) + fadd %st(5), %st + fsubp %st, %st(1) + fmul %st, %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fldt 8(%ebp) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt (%esp) + fmul %st, %st(2) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.45 +..B1.44: + fldcw 14(%esp) +..B1.45: + fldt (%esp) + addl $56, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.72 +..B1.47: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.48: + fldcw 12(%esp) +..B1.49: + movl $1, %edx +..B1.50: + fldt 8(%ebp) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl ones@GOTOFF(%ecx,%eax,8) + fmul %st, %st(1) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + movzwl 16(%ebp), %ebx + movl %ebx, %eax + andl $32767, %eax + cmpl $16421, %eax + jge ..B1.59 +..B1.51: + cmpl $16388, %eax + jge ..B1.53 +..B1.52: + fldl _TWO_52H@GOTOFF(%ecx) + fld %st(0) + fld %st(2) + fadd %st(2), %st + fsub %st(2), %st + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsqrt + fadd %st, %st(4) + fxch %st(5) + fsubrp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fsubrp %st, %st(1) + fld %st(3) + fxch %st(4) + fsubr %st, %st(5) + fxch %st(4) + fmul %st(5), %st + fsubrp %st, %st(1) + faddp %st, %st(1) + fld %st(2) + fadd %st(4), %st + fdivrp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(1) + fstpt 16(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fxch %st(1) + jmp ..B1.58 +..B1.53: + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + cmpl $16394, %eax + fmul %st(1), %st + fld %st(0) + fldl _TWO_32H@GOTOFF(%ecx) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fsubr %st(1), %st + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + jge ..B1.55 +..B1.54: + fstp %st(2) + fld %st(2) + fmul %st(3), %st + fadd %st(2), %st + fsqrt + faddp %st, %st(3) + fxch %st(1) + fdiv %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + jmp ..B1.58 +..B1.55: + fstp %st(3) + cmpl $16401, %eax + jge ..B1.57 +..B1.56: + fld %st(2) + fdiv %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fdivr %st(2), %st + faddp %st, %st(1) + jmp ..B1.58 +..B1.57: + fxch %st(1) + fdivr %st(2), %st + faddp %st, %st(1) +..B1.58: + fldt 16(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 8(%ebp) + movzwl 16(%ebp), %eax + andl $32767, %eax + movl %eax, %ebx + addl $-16383, %eax + negl %ebx + fxch %st(2) + fstpt (%esp) + addl $-2, %ebx + movzwl 8(%esp), %esi + andl $32767, %ebx + andl $-32768, %esi + orl %ebx, %esi + movw %si, 8(%esp) + fldt (%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 16(%esp) + fmulp %st, %st(1) + jmp ..B1.60 +..B1.59: + fstp %st(0) + fldl _TWO_52H@GOTOFF(%ecx) + andl $-32768, %ebx + orl $-49153, %ebx + addl $-16382, %eax + movw %bx, 16(%ebp) + fldt 8(%ebp) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(1) +..B1.60: + fldt 16(%esp) + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + fldt 60+_P@GOTOFF(%ecx) + movl 12(%ebp), %ebx + shrl $23, %ebx + movzbl %bl, %ebx + movl %eax, (%esp) + flds __libm_rcp_table_256@GOTOFF(%ecx,%ebx,4) + fmul %st, %st(3) + shll $4, %ebx + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + testl %edx, %edx + fxch %st(4) + fmulp %st, %st(2) + fxch %st(1) + fadd %st, %st(3) + fld %st(3) + fmul %st(4), %st + fmul %st, %st(2) + fxch %st(4) + fstpt 8(%ebp) + fldt 8(%ebp) + fildl (%esp) + fldt 36+_P@GOTOFF(%ecx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fmulp %st, %st(1) + fldt 48+_P@GOTOFF(%ecx) + fmul %st(5), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt _P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + faddp %st, %st(3) + fldt .L_2il0floatpacket.4@GOTOFF(%ecx) + fmul %st(1), %st + fldt .L_2il0floatpacket.5@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl 8+__libm_logl_table_256@GOTOFF(%ecx,%ebx) + faddp %st, %st(3) + faddl __libm_logl_table_256@GOTOFF(%ebx,%ecx) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%esp) + je ..B1.62 +..B1.61: + fldcw 14(%esp) +..B1.62: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.63: + cmpl $0, 12(%ebp) + jne ..B1.65 +..B1.64: + cmpl $0, 8(%ebp) + je ..B1.66 +..B1.65: + fldt 8(%ebp) + fldt _small_value_80@GOTOFF(%ecx) + movzbl 17(%ebp), %ebx + andl $128, %ebx + shrl $7, %ebx + lea (,%ebx,8), %edx + lea (%edx,%ebx,4), %esi + fldt _small_value_80@GOTOFF(%ecx,%esi) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.66: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.15 +..B1.67: + xorl %eax, %eax + jmp ..B1.13 +..B1.68: + xorl %eax, %eax + jmp ..B1.22 +..B1.69: + xorl %eax, %eax + jmp ..B1.29 +..B1.70: + xorl %eax, %eax + jmp ..B1.36 +..B1.71: + xorl %eax, %eax + jmp ..B1.43 +..B1.72: + xorl %edx, %edx + jmp ..B1.50 +..B1.73: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.79 +..B1.74: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.75: + fldcw 12(%esp) +..B1.76: + fldt 8(%ebp) + fstpt (%esp) +..B1.77: + fldcw 14(%esp) +..B1.78: + fldt (%esp) + addl $56, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.79: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.78 + .align 16,0x90 + .type asinhl,@function + .size asinhl,.-asinhl + .data +# -- End asinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_Q3: + .word 6991 + .word 42216 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 33268 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 9764 + .word 39322 + .word 39161 + .word 39321 + .word 16379 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 43682 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 14144 + .word 39303 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 10686 + .word 40209 + .word 28068 + .word 46811 + .word 49146 + .word 0 + .word 6376 + .word 25459 + .word 13370 + .word 63707 + .word 16377 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 42228 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 4505 + .word 52442 + .word 52428 + .word 52428 + .word 49134 + .word 0 + .word 31967 + .word 56173 + .word 28086 + .word 46811 + .word 49146 + .word 0 + .word 26124 + .word 58234 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 22137 + .word 23222 + .word 53620 + .word 46917 + .word 49145 + .word 0 + .word 45395 + .word 61656 + .word 25205 + .word 36391 + .word 16377 + .word 0 + .word 28077 + .word 15147 + .word 52421 + .word 58572 + .word 49144 + .word 0 + .word 19650 + .word 2873 + .word 50009 + .word 48451 + .word 16376 + .word 0 + .word 47538 + .word 64725 + .word 9133 + .word 40943 + .word 49144 + .word 0 + .word 42460 + .word 64288 + .word 29314 + .word 35191 + .word 16376 + .word 0 + .word 54924 + .word 18085 + .word 19628 + .word 61339 + .word 49143 + .word 0 + .word 8359 + .word 63244 + .word 48955 + .word 54066 + .word 16375 + .word 0 + .word 13301 + .word 22367 + .word 28967 + .word 48066 + .word 49143 + .word 0 + .word 47487 + .word 41074 + .word 54143 + .word 42870 + .word 16375 + .word 0 + .word 18176 + .word 28317 + .word 25378 + .word 37849 + .word 49143 + .word 0 + .word 2947 + .word 59345 + .word 39582 + .word 64148 + .word 16374 + .word 0 + .word 7071 + .word 46945 + .word 60101 + .word 49232 + .word 49142 + .word 0 + .word 33184 + .word 23492 + .word 18153 + .word 62298 + .word 16373 + .word 0 + .word 44779 + .word 60944 + .word 30881 + .word 55868 + .word 49140 + .word 0 + .word 22870 + .word 51718 + .word 28591 + .word 51709 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16379 + .word 0 + .type _Q,@object + .size _Q,264 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .type _P,@object + .size _P,72 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/asinl.S b/external/sgx_libm/ia32/asinl.S new file mode 100644 index 0000000000..99ef476461 --- /dev/null +++ b/external/sgx_libm/ia32/asinl.S @@ -0,0 +1,1176 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinl.c" + .text +..TXTST0: +# -- Begin asinl + .text + .align 16,0x90 + .globl asinl +asinl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %edi + pushl %ebx + subl $88, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzbl 17(%ebp), %edx + movzwl 16(%ebp), %eax + andl $128, %edx + andl $32767, %eax + shrl $7, %edx + movzwl 14(%esp), %ebx + cmpl $16383, %eax + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + jge ..B1.59 +..B1.4: + cmpl $16382, %eax + jge ..B1.49 +..B1.5: + cmpl $16376, %eax + jge ..B1.39 +..B1.6: + cmpl $16371, %eax + jge ..B1.32 +..B1.7: + cmpl $16365, %eax + jge ..B1.25 +..B1.8: + cmpl $16308, %eax + jge ..B1.18 +..B1.9: + movl %ebx, %edi + andl $768, %edi + cmpl $768, %edi + je ..B1.79 +..B1.10: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.11: + fldcw 12(%esp) +..B1.12: + movzwl 16(%ebp), %eax + movl $1, %ebx + andl $32767, %eax +..B1.13: + testl %eax, %eax + jle ..B1.75 +..B1.14: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ecx) + fmul %st(1), %st + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ecx) + fstpt (%esp) +..B1.15: + testl %ebx, %ebx + je ..B1.17 +..B1.16: + fldcw 14(%esp) +..B1.17: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.80 +..B1.19: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.20: + fldcw 12(%esp) +..B1.21: + movl $1, %eax +..B1.22: + fldt 8(%ebp) + testl %eax, %eax + fldt _P4@GOTOFF(%ecx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.24 +..B1.23: + fldcw 14(%esp) +..B1.24: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.81 +..B1.26: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.27: + fldcw 12(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_P3@GOTOFF(%ecx) + fmul %st(1), %st + fldt _P3@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.31 +..B1.30: + fldcw 14(%esp) +..B1.31: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.82 +..B1.33: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.34: + fldcw 12(%esp) +..B1.35: + movl $1, %eax +..B1.36: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_P2@GOTOFF(%ecx) + fmul %st(1), %st + fldt 12+_P2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_P2@GOTOFF(%ecx) + fmulp %st, %st(2) + fldt _P2@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.38 +..B1.37: + fldcw 14(%esp) +..B1.38: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + movl %ebx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.83 +..B1.40: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.41: + fldcw 12(%esp) +..B1.42: + movzwl 16(%ebp), %eax + movl $1, %edx + andl $32767, %eax +..B1.43: + fldt 8(%ebp) + cmpl $16381, %eax + fld %st(0) + fldl _TWO_52H@GOTOFF(%ecx) + fmul %st, %st(1) + fld %st(1) + fadd %st(3), %st + fsubp %st, %st(2) + fld %st(1) + fxch %st(1) + fstpt 16(%esp) + fld %st(1) + fsubr %st(3), %st + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fxch %st(2) + fstpt 64(%esp) + fldt 64(%esp) + fmul %st(0), %st + fld %st(0) + fadd %st(3), %st + fstpt 48(%esp) + fldt 48(%esp) + fld %st(1) + fmul %st(4), %st + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + fstpt 32(%esp) + fldt 32(%esp) + fld %st(2) + fmul %st(3), %st + fld %st(0) + faddp %st, %st(2) + jge ..B1.45 +..B1.44: + fstp %st(0) + fldt 132+_P1@GOTOFF(%ecx) + fmul %st(1), %st + fldt 108+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_P1@GOTOFF(%ecx) + fldt 120+_P1@GOTOFF(%ecx) + fmul %st(3), %st + fldt 96+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _P1@GOTOFF(%ecx) + faddp %st, %st(2) + fldt 48(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt (%esp) + fldt 144+_P1@GOTOFF(%ecx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + jmp ..B1.46 +..B1.45: + fldt 204+_P@GOTOFF(%ecx) + fmul %st(2), %st + fldt 180+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 156+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 132+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 108+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 192+_P@GOTOFF(%ecx) + fmul %st(3), %st + fldt 168+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 144+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 120+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(3) + fldt 48(%esp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 32(%esp) + fldt (%esp) + fldt 228+_P@GOTOFF(%ecx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldt 216+_P@GOTOFF(%ecx) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fld %st(1) + fxch %st(5) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 16(%esp) + fmul %st(1), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fsub %st(3), %st + faddp %st, %st(1) +..B1.46: + fldt 64(%esp) + fld %st(2) + fmul %st(4), %st + testl %edx, %edx + fxch %st(5) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 64(%esp) + je ..B1.48 +..B1.47: + fldcw 14(%esp) +..B1.48: + fldt 64(%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.49: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.84 +..B1.50: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.51: + fldcw 12(%esp) +..B1.52: + movl $1, %ebx +..B1.53: + fldl _ones@GOTOFF(%ecx,%edx,8) + fstl 80(%esp) + fldt 8(%ebp) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fldl _TWO_32H@GOTOFF(%ecx) + fldl _TWO_52H@GOTOFF(%ecx) + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(3) + fsubrl _ones@GOTOFF(%ecx) + fmul %st(2), %st + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fxch %st(1) + fsub %st(2), %st + fadd %st, %st(1) + fxch %st(1) + fsqrt + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fsubr %st, %st(3) + fld %st(5) + fxch %st(2) + fsub %st(6), %st + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fld %st(4) + fadd %st(1), %st + fdivrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fld %st(1) + fld %st(3) + fadd %st(3), %st + fmul %st, %st(1) + fld %st(4) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fld %st(2) + fadd %st(1), %st + fstpt 64(%esp) + fldt 64(%esp) + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fld %st(2) + fmul %st(3), %st + fld %st(0) + faddp %st, %st(2) + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fcompp + fnstsw %ax + sahf + jbe ..B1.55 +..B1.54: + fstp %st(1) + fldt 132+_P1@GOTOFF(%ecx) + fmul %st(1), %st + fldt 108+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_P1@GOTOFF(%ecx) + fldt 120+_P1@GOTOFF(%ecx) + fmul %st(3), %st + fldt 96+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P1@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _P1@GOTOFF(%ecx) + faddp %st, %st(2) + fldt 64(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 16(%esp) + fldt 144+_P1@GOTOFF(%ecx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(2) + fxch %st(1) + jmp ..B1.56 +..B1.55: + fldt 204+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 180+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 156+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 132+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 108+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 192+_P@GOTOFF(%ecx) + fmul %st(2), %st + fldt 168+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 144+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 120+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(2) + fldt 64(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 48(%esp) + fldt 16(%esp) + fldt 228+_P@GOTOFF(%ecx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(3) + fldt 216+_P@GOTOFF(%ecx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fldt 32(%esp) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) +..B1.56: + fldt (%esp) + testl %ebx, %ebx + fmulp %st, %st(2) + fld %st(2) + fmul %st(1), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st(2), %st + faddp %st, %st(2) + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + fmul %st, %st(1) + fmulp %st, %st(2) + fldt _pi_02@GOTOFF(%ecx) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fldt 12+_pi_02@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fmull 80(%esp) + fstpt 16(%esp) + je ..B1.58 +..B1.57: + fldcw 14(%esp) +..B1.58: + fldt 16(%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.59: + movl %ebx, %edi + andl $768, %edi + cmpl $768, %edi + je ..B1.85 +..B1.60: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.61: + fldcw 12(%esp) +..B1.62: + movzwl 16(%ebp), %eax + movl $1, %ebx + andl $32767, %eax +..B1.63: + cmpl $32767, %eax + jne ..B1.67 +..B1.64: + cmpl $-2147483648, 12(%ebp) + jne ..B1.66 +..B1.65: + cmpl $0, 8(%ebp) + je ..B1.71 +..B1.66: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.72 +..B1.67: + cmpl $16383, %eax + jne ..B1.71 +..B1.68: + cmpl $-2147483648, 12(%ebp) + jne ..B1.71 +..B1.69: + cmpl $0, 8(%ebp) + jne ..B1.71 +..B1.70: + lea (,%edx,8), %eax + lea (%eax,%edx,4), %edx + fldt _pi_2l@GOTOFF(%edx,%ecx) + fldt _small_value_80@GOTOFF(%edx,%ecx) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.72 +..B1.71: + fldl _infs@GOTOFF(%ecx) + fmull _zeros@GOTOFF(%ecx) + fstpt (%esp) +..B1.72: + testl %ebx, %ebx + je ..B1.74 +..B1.73: + fldcw 14(%esp) +..B1.74: + fldt (%esp) + addl $88, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.75: + cmpl $0, 12(%ebp) + jne ..B1.77 +..B1.76: + cmpl $0, 8(%ebp) + je ..B1.78 +..B1.77: + fldt 8(%ebp) + lea (,%edx,8), %eax + fldt _small_value_80@GOTOFF(%ecx) + lea (%eax,%edx,4), %edx + fldt _small_value_80@GOTOFF(%ecx,%edx) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.78: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.15 +..B1.79: + xorl %ebx, %ebx + jmp ..B1.13 +..B1.80: + xorl %eax, %eax + jmp ..B1.22 +..B1.81: + xorl %eax, %eax + jmp ..B1.29 +..B1.82: + xorl %eax, %eax + jmp ..B1.36 +..B1.83: + xorl %edx, %edx + jmp ..B1.43 +..B1.84: + xorl %ebx, %ebx + jmp ..B1.53 +..B1.85: + xorl %ebx, %ebx + jmp ..B1.63 + .align 16,0x90 + .type asinl,@function + .size asinl,.-asinl + .data +# -- End asinl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_P4: + .word 43691 + .word 44938 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _P4,@object + .size _P4,12 + .align 2 +_P3: + .word 36763 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 40704 + .word 58046 + .word 39460 + .word 39321 + .word 16379 + .word 0 + .type _P3,@object + .size _P3,24 + .align 2 +_P2: + .word 43688 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 20771 + .word 39331 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 23807 + .word 53798 + .word 28073 + .word 46811 + .word 16378 + .word 0 + .word 35198 + .word 7516 + .word 54204 + .word 63722 + .word 16377 + .word 0 + .type _P2,@object + .size _P2,48 + .align 2 +_P1: + .word 43589 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 39364 + .word 39321 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 17602 + .word 56173 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 47501 + .word 58414 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 27078 + .word 6583 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 39781 + .word 21053 + .word 25224 + .word 36391 + .word 16377 + .word 0 + .word 46568 + .word 6235 + .word 50749 + .word 58572 + .word 16376 + .word 0 + .word 41318 + .word 51558 + .word 37628 + .word 48452 + .word 16376 + .word 0 + .word 55026 + .word 7893 + .word 43866 + .word 40925 + .word 16376 + .word 0 + .word 43387 + .word 19951 + .word 2911 + .word 35445 + .word 16376 + .word 0 + .word 32572 + .word 59281 + .word 11243 + .word 56666 + .word 16375 + .word 0 + .word 49800 + .word 50337 + .word 42707 + .word 39184 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .type _P1,@object + .size _P1,156 + .align 2 +_P: + .word 42691 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 4317 + .word 52400 + .word 52428 + .word 52428 + .word 49134 + .word 0 + .word 26206 + .word 56172 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 36130 + .word 58514 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 21592 + .word 8113 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 3093 + .word 49950 + .word 25215 + .word 36391 + .word 16377 + .word 0 + .word 21499 + .word 24428 + .word 51889 + .word 58572 + .word 16376 + .word 0 + .word 54828 + .word 41264 + .word 61120 + .word 48451 + .word 16376 + .word 0 + .word 10243 + .word 1489 + .word 39717 + .word 40940 + .word 16376 + .word 0 + .word 51433 + .word 46039 + .word 63564 + .word 35220 + .word 16376 + .word 0 + .word 60402 + .word 39286 + .word 25675 + .word 60826 + .word 16375 + .word 0 + .word 34219 + .word 36833 + .word 44839 + .word 57547 + .word 16375 + .word 0 + .word 13013 + .word 26091 + .word 19721 + .word 60832 + .word 16374 + .word 0 + .word 22353 + .word 41544 + .word 55443 + .word 55735 + .word 16376 + .word 0 + .word 14948 + .word 7038 + .word 38091 + .word 38339 + .word 49145 + .word 0 + .word 61727 + .word 61480 + .word 15906 + .word 51927 + .word 16378 + .word 0 + .word 13386 + .word 23084 + .word 64443 + .word 55906 + .word 49146 + .word 0 + .word 17499 + .word 23573 + .word 43947 + .word 42761 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16379 + .word 0 + .type _P,@object + .size _P,240 + .align 2 +_pi_02: + .word 0 + .word 0 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 35374 + .word 4889 + .word 2259 + .word 34211 + .word 16349 + .word 0 + .type _pi_02,@object + .size _pi_02,24 + .align 2 +_pi_2l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .type _pi_2l,@object + .size _pi_2l,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atan2_wmt.S b/external/sgx_libm/ia32/atan2_wmt.S new file mode 100644 index 0000000000..31a1c073cb --- /dev/null +++ b/external/sgx_libm/ia32/atan2_wmt.S @@ -0,0 +1,1219 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin atan2 + .text + .align 16,0x90 + .globl atan2 +atan2: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 136(%esp), %xmm1 + movsd 128(%esp), %xmm0 + pextrw $3, %xmm0, %eax + movq %xmm0, 8(%esp) + andl $32752, %eax + movq %xmm1, 16(%esp) + subl $14448, %eax + cmpl $3840, %eax + ja .L_2TAG_PACKET_0.0.3 + pextrw $3, %xmm1, %eax + andl $32752, %eax + subl $14448, %eax + cmpl $3840, %eax + ja .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + unpcklpd %xmm1, %xmm0 + xorpd %xmm5, %xmm5 + xorpd %xmm3, %xmm3 + movl $2048, %eax + pinsrw $3, %eax, %xmm5 + paddw %xmm1, %xmm5 + psrlq $29, %xmm5 + rcpss %xmm5, %xmm3 + xorpd %xmm4, %xmm4 + movl $14336, %ecx + pinsrw $3, %ecx, %xmm4 + psllq $29, %xmm3 + paddw %xmm4, %xmm3 + mulsd %xmm0, %xmm3 + xorpd %xmm2, %xmm2 + xorpd %xmm6, %xmm6 + xorpd %xmm7, %xmm7 + movl $32768, %eax + pinsrw $2, %eax, %xmm6 + movl $32767, %ecx + pinsrw $3, %ecx, %xmm7 + paddd %xmm6, %xmm3 + andpd %xmm7, %xmm3 + movapd %xmm3, %xmm5 + pextrw $3, %xmm3, %eax + movl $16448, %ecx + pinsrw $3, %ecx, %xmm2 + minsd %xmm2, %xmm3 + movmskpd %xmm0, %edx + psllq $1, %xmm0 + psrlq $1, %xmm0 + cmpsd $2, %xmm2, %xmm5 + psllq $1, %xmm1 + psrlq $1, %xmm1 + movapd %xmm1, %xmm6 + movapd %xmm1, %xmm7 + movapd %xmm0, %xmm2 + movl $0, %ecx + pinsrw $0, %ecx, %xmm6 + subsd %xmm6, %xmm7 + movapd %xmm0, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm4 + mulsd %xmm3, %xmm7 + andpd %xmm5, %xmm0 + subsd %xmm6, %xmm0 + andpd %xmm5, %xmm1 + addsd %xmm1, %xmm4 + subsd %xmm7, %xmm0 + andl $32752, %eax + subl $16286, %eax + cmpl $1121, %eax + ja .L_2TAG_PACKET_3.0.3 + divsd %xmm4, %xmm0 + pextrw $3, %xmm3, %ecx + movsd 2944(%ebx), %xmm2 + movsd 2960(%ebx), %xmm3 + pextrw $0, %xmm5, %eax + addl %edx, %edx + movapd 2688(%ebx,%edx,8), %xmm6 + movapd 2752(%ebx,%edx,8), %xmm1 + subl $16286, %ecx + notl %eax + andl $1, %eax + addl %eax, %ecx + addl %ecx, %ecx + movapd (%ebx,%ecx,8), %xmm5 + xorpd %xmm1, %xmm5 + addpd %xmm6, %xmm5 + movapd %xmm5, %xmm6 + unpckhpd %xmm5, %xmm5 + xorpd %xmm0, %xmm1 + movapd %xmm1, %xmm4 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm2 + addsd %xmm0, %xmm3 + addsd %xmm6, %xmm1 + subsd %xmm1, %xmm6 + addsd %xmm4, %xmm6 + addsd 2952(%ebx), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm4 + addsd %xmm5, %xmm6 + mulsd %xmm4, %xmm2 + addsd 2968(%ebx), %xmm3 + mulsd %xmm3, %xmm2 + addsd %xmm6, %xmm2 + addsd %xmm2, %xmm1 + movsd %xmm1, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_3.0.3: + addl $942, %eax + cmpl $942, %eax + ja .L_2TAG_PACKET_5.0.3 + xorpd %xmm4, %xmm4 + movl $16368, %ecx + pinsrw $3, %ecx, %xmm4 + divsd %xmm1, %xmm4 + addl %edx, %edx + movapd 2752(%ebx,%edx,8), %xmm6 + unpcklpd %xmm3, %xmm3 + xorpd %xmm6, %xmm0 + xorpd %xmm6, %xmm2 + xorpd %xmm6, %xmm3 + movapd 2816(%ebx,%edx,8), %xmm7 + movsd 2944(%ebx), %xmm1 + movsd 2960(%ebx), %xmm5 + andpd 2880(%ebx,%edx,8), %xmm3 + mulsd %xmm4, %xmm2 + mulsd %xmm4, %xmm0 + movapd %xmm2, %xmm6 + mulsd %xmm2, %xmm2 + mulsd %xmm2, %xmm1 + addsd %xmm2, %xmm5 + mulsd %xmm2, %xmm6 + addsd 2952(%ebx), %xmm1 + mulsd %xmm2, %xmm5 + addsd %xmm0, %xmm7 + addpd %xmm3, %xmm7 + mulsd %xmm6, %xmm1 + addsd 2968(%ebx), %xmm5 + mulsd %xmm1, %xmm5 + addsd %xmm7, %xmm5 + unpckhpd %xmm7, %xmm7 + addsd %xmm7, %xmm5 + movsd %xmm5, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + movsd 16(%esp), %xmm1 + movsd 8(%esp), %xmm0 + pextrw $3, %xmm1, %eax + andl $32752, %eax + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl %eax, %ecx + jg .L_2TAG_PACKET_6.0.3 + pextrw $3, %xmm1, %ecx + cmpl $32767, %ecx + jg .L_2TAG_PACKET_7.0.3 + divsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_7.0.3: + andpd 2672(%ebx), %xmm0 + movsd 2640(%ebx), %xmm2 + xorpd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_6.0.3: + andpd 2672(%ebx), %xmm0 + movsd 2624(%ebx), %xmm2 + xorpd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_0.0.3: +.L_2TAG_PACKET_1.0.3: + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + pextrw $3, %xmm1, %eax + andl $32752, %eax + cmpl $32752, %ecx + je .L_2TAG_PACKET_8.0.3 + cmpl $32752, %eax + je .L_2TAG_PACKET_9.0.3 + movsd 2992(%ebx), %xmm3 + movl $1024, %edx + movsd 2976(%ebx), %xmm4 + xorpd %xmm6, %xmm6 + movsd 3008(%ebx), %xmm7 + cmpl $0, %ecx + je .L_2TAG_PACKET_10.0.3 +.L_2TAG_PACKET_11.0.3: + cmpl $0, %eax + je .L_2TAG_PACKET_12.0.3 +.L_2TAG_PACKET_13.0.3: + addl %ecx, %edx + subl %eax, %edx + cmpl $2048, %edx + ja .L_2TAG_PACKET_5.0.3 + addl $15344, %edx + pinsrw $3, %edx, %xmm6 + andpd %xmm4, %xmm0 + andpd %xmm4, %xmm1 + orpd %xmm6, %xmm0 + orpd %xmm7, %xmm1 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_10.0.3: + subl $880, %edx + mulsd %xmm3, %xmm0 + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl $0, %ecx + je .L_2TAG_PACKET_14.0.3 + jmp .L_2TAG_PACKET_11.0.3 +.L_2TAG_PACKET_12.0.3: + addl $880, %edx + mulsd %xmm3, %xmm1 + pextrw $3, %xmm1, %eax + andl $32752, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_15.0.3 + jmp .L_2TAG_PACKET_13.0.3 +.L_2TAG_PACKET_8.0.3: + movd %xmm0, %edx + movapd %xmm0, %xmm2 + psrlq $32, %xmm2 + movd %xmm2, %ecx + andl $1048575, %ecx + orl %edx, %ecx + cmpl $0, %ecx + jne .L_2TAG_PACKET_16.0.3 + psrlq $63, %xmm0 + psllq $63, %xmm0 + cmpl $32752, %eax + jae .L_2TAG_PACKET_17.0.3 + movapd 2624(%ebx), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 +.L_2TAG_PACKET_18.0.3: + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_16.0.3: + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_17.0.3: + movd %xmm1, %eax + movapd %xmm1, %xmm2 + psrlq $32, %xmm2 + movd %xmm2, %ecx + movl $-2147483648, %edx + andl %ecx, %edx + andl $1048575, %ecx + orl %eax, %ecx + cmpl $0, %ecx + jne .L_2TAG_PACKET_19.0.3 + cmpl $0, %edx + jne .L_2TAG_PACKET_20.0.3 + movapd 2656(%ebx), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_19.0.3: + movapd %xmm1, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_20.0.3: + movapd 2656(%ebx), %xmm5 + movapd 2624(%ebx), %xmm6 + addpd %xmm6, %xmm5 + pshufd $238, %xmm5, %xmm6 + addpd %xmm6, %xmm5 + orpd %xmm5, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_9.0.3: + movd %xmm1, %eax + movapd %xmm1, %xmm2 + psrlq $32, %xmm2 + movd %xmm2, %ecx + movl $-2147483648, %edx + andl %ecx, %edx + andl $1048575, %ecx + orl %eax, %ecx + cmpl $0, %ecx + jne .L_2TAG_PACKET_19.0.3 + psrlq $63, %xmm0 + psllq $63, %xmm0 + cmpl $0, %edx + jne .L_2TAG_PACKET_21.0.3 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_21.0.3: + movapd 2640(%ebx), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_14.0.3: + pextrw $3, %xmm1, %edx + andl $32768, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_22.0.3 + movapd 2640(%ebx), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + comisd %xmm0, %xmm1 + orpd %xmm5, %xmm0 + jne .L_2TAG_PACKET_23.0.3 +.L_2TAG_PACKET_24.0.3: + movsd %xmm0, (%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 136(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $37, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_23.0.3: + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_22.0.3: + comisd %xmm0, %xmm1 + jne .L_2TAG_PACKET_23.0.3 + je .L_2TAG_PACKET_24.0.3 +.L_2TAG_PACKET_15.0.3: + movapd 2624(%ebx), %xmm5 + psrlq $63, %xmm0 + psllq $63, %xmm0 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) +.L_2TAG_PACKET_4.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type atan2,@function + .size atan2,.-atan2 + .data +# -- End atan2 + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 3390881280 + .long 1067318733 + .long 1411116779 + .long 1018950063 + .long 2985987840 + .long 1067384211 + .long 2088903695 + .long 1018086027 + .long 3148445184 + .long 1067449685 + .long 2044163806 + .long 1017271335 + .long 3667629184 + .long 1067515494 + .long 2353092775 + .long 1019967309 + .long 1546568832 + .long 1067580954 + .long 611991315 + .long 1017602584 + .long 3815996800 + .long 1067646404 + .long 466038598 + .long 1019686426 + .long 4050241920 + .long 1067711845 + .long 3265026328 + .long 1019626952 + .long 120454912 + .long 1067777277 + .long 1542207696 + .long 1020155608 + .long 2784639744 + .long 1067842697 + .long 3883834623 + .long 1018602870 + .long 1328010624 + .long 1067908107 + .long 1791097456 + .long 1019053126 + .long 2217794048 + .long 1067973505 + .long 551619938 + .long 1018494194 + .long 3333520000 + .long 1068038891 + .long 2390331823 + .long 1019033022 + .long 2557052032 + .long 1068104265 + .long 2423976108 + .long 1019728674 + .long 2067649536 + .long 1068169626 + .long 3757397745 + .long 1018672362 + .long 4047094784 + .long 1068234973 + .long 481613184 + .long 1019275104 + .long 2089853184 + .long 1068300307 + .long 1733914374 + .long 1020124677 + .long 2678003840 + .long 1068365626 + .long 1373600282 + .long 1013935474 + .long 3706496128 + .long 1068430930 + .long 1000610902 + .long 1019673285 + .long 3073179008 + .long 1068496219 + .long 1497143008 + .long 1019900342 + .long 2803716736 + .long 1068562846 + .long 1476677416 + .long 1019444094 + .long 3204984128 + .long 1068628077 + .long 1192335905 + .long 1018748628 + .long 831146624 + .long 1068693273 + .long 2733586224 + .long 1018823295 + .long 243029376 + .long 1068758431 + .long 950106081 + .long 1019046675 + .long 1735561920 + .long 1068823549 + .long 3546440856 + .long 1020104712 + .long 1339217792 + .long 1068888626 + .long 3028812387 + .long 1019818321 + .long 3706342144 + .long 1068953659 + .long 3814564029 + .long 1017763871 + .long 637726976 + .long 1069018648 + .long 3584007699 + .long 1017976868 + .long 1148779264 + .long 1069083589 + .long 2282532133 + .long 1019483954 + .long 1406131392 + .long 1069148481 + .long 1547359113 + .long 1019786342 + .long 1908875904 + .long 1069213322 + .long 1315508410 + .long 1020009473 + .long 3194947520 + .long 1069278110 + .long 3845393201 + .long 1015803761 + .long 1547487744 + .long 1069342844 + .long 3863107865 + .long 1019810104 + .long 1881061952 + .long 1069407521 + .long 4288343548 + .long 1019687581 + .long 563086336 + .long 1069472140 + .long 2582230241 + .long 1020099350 + .long 2594975552 + .long 1069536698 + .long 2306443764 + .long 1019667244 + .long 3438545024 + .long 1069606573 + .long 957455549 + .long 1015587735 + .long 4211357472 + .long 1069670906 + .long 2611778754 + .long 1017877214 + .long 3002835424 + .long 1069735101 + .long 235580458 + .long 1020211685 + .long 3905315424 + .long 1069799150 + .long 3630647617 + .long 1018736849 + .long 2849656576 + .long 1069863047 + .long 2412165062 + .long 1019693004 + .long 507429472 + .long 1069926785 + .long 1397750723 + .long 1018412717 + .long 2307470272 + .long 1069990356 + .long 1796470904 + .long 1019796181 + .long 1271814912 + .long 1070053755 + .long 189761565 + .long 1016149115 + .long 3800538144 + .long 1070116974 + .long 2524871582 + .long 1018263353 + .long 3916203552 + .long 1070180008 + .long 127848658 + .long 1017672664 + .long 457192032 + .long 1070242851 + .long 4020400938 + .long 1019823010 + .long 1385324704 + .long 1070305495 + .long 564511179 + .long 1016079094 + .long 2322869856 + .long 1070367935 + .long 2347103319 + .long 1018927760 + .long 3743438624 + .long 1070430165 + .long 877973862 + .long 1019638162 + .long 2392255552 + .long 1070492180 + .long 2432782267 + .long 1018872629 + .long 4180443328 + .long 1070553973 + .long 3102990015 + .long 1020093101 + .long 2547540832 + .long 1070636485 + .long 3877738253 + .long 1017300424 + .long 2735468912 + .long 1070697461 + .long 2446470256 + .long 1019235378 + .long 542633792 + .long 1070757943 + .long 583606328 + .long 1018624131 + .long 923265984 + .long 1070817911 + .long 1793926708 + .long 1019714161 + .long 918728448 + .long 1070877348 + .long 3726463586 + .long 1019433296 + .long 2572275008 + .long 1070936237 + .long 1845354238 + .long 1019459238 + .long 50974688 + .long 1070994564 + .long 983808064 + .long 1016685418 + .long 1105518320 + .long 1071052313 + .long 2357496692 + .long 1015139882 + .long 1264825328 + .long 1071109472 + .long 2244129354 + .long 1019046344 + .long 961157920 + .long 1071166029 + .long 3124185339 + .long 1018541776 + .long 1162701584 + .long 1071221973 + .long 1279780948 + .long 1019268918 + .long 3284935664 + .long 1071277294 + .long 2670033472 + .long 1019833744 + .long 497441888 + .long 1071331985 + .long 1032737410 + .long 1019795212 + .long 3377383904 + .long 1071386036 + .long 2356897182 + .long 1020205553 + .long 1126962000 + .long 1071439443 + .long 3723724586 + .long 1015212418 + .long 90291008 + .long 1071492199 + .long 4178672431 + .long 1020186971 + .long 190059536 + .long 1071595741 + .long 1763589807 + .long 1019162163 + .long 2497392840 + .long 1071670654 + .long 3036997041 + .long 1020204325 + .long 2616971944 + .long 1071719773 + .long 300151069 + .long 1017041957 + .long 2883518128 + .long 1071767563 + .long 2203981414 + .long 1019190108 + .long 1496354352 + .long 1071814030 + .long 332287966 + .long 1016846435 + .long 483276728 + .long 1071859184 + .long 653845024 + .long 1018830914 + .long 3097401072 + .long 1071903039 + .long 1514746408 + .long 1019278972 + .long 2737217248 + .long 1071945615 + .long 1358845067 + .long 1017268275 + .long 2072577560 + .long 1071986933 + .long 3041024735 + .long 1019929672 + .long 2266405656 + .long 1072027017 + .long 1271261130 + .long 1012925070 + .long 958652544 + .long 1072065894 + .long 2158017058 + .long 1019955372 + .long 3312993840 + .long 1072103591 + .long 765809169 + .long 1019114443 + .long 3177001304 + .long 1072140139 + .long 144180084 + .long 1019822186 + .long 3071642184 + .long 1072175568 + .long 4004602424 + .long 1019420740 + .long 4283953648 + .long 1072209909 + .long 1511950430 + .long 1020176966 + .long 1413754136 + .long 1072243195 + .long 856972295 + .long 1015129638 + .long 4073202944 + .long 1072306725 + .long 4068194804 + .long 1019714860 + .long 946117760 + .long 1072366415 + .long 694980733 + .long 1020150135 + .long 3980632032 + .long 1072422512 + .long 1313251280 + .long 1019948709 + .long 1468297112 + .long 1072475260 + .long 330111143 + .long 1019809198 + .long 3478063816 + .long 1072524887 + .long 2930067044 + .long 1017784081 + .long 1153979856 + .long 1072571613 + .long 2225786102 + .long 1017634481 + .long 2089828808 + .long 1072615641 + .long 474621367 + .long 1017043414 + .long 3531732632 + .long 1072657163 + .long 2276396220 + .long 1018757240 + .long 775214612 + .long 1072694803 + .long 3209744818 + .long 1019963015 + .long 662307284 + .long 1072713319 + .long 1381696763 + .long 1019763781 + .long 1192776652 + .long 1072730830 + .long 3017932994 + .long 1015179769 + .long 744202396 + .long 1072747407 + .long 2073854034 + .long 1019512292 + .long 8337908 + .long 1072763115 + .long 16004448 + .long 1019599514 + .long 3589868768 + .long 1072778013 + .long 1374369804 + .long 1018019237 + .long 121647320 + .long 1072792159 + .long 128481634 + .long 1018115438 + .long 2464923204 + .long 1072805601 + .long 1787331214 + .long 1016798022 + .long 4093304372 + .long 1072830562 + .long 3306868969 + .long 1019384078 + .long 1436891684 + .long 1072853231 + .long 676347266 + .long 1017302183 + .long 1104571840 + .long 1072873890 + .long 2870400285 + .long 1019938149 + .long 2037009832 + .long 1072892781 + .long 2956702105 + .long 1016472908 + .long 3139037960 + .long 1072910111 + .long 916057147 + .long 1018364335 + .long 1826698064 + .long 1072926058 + .long 2171961098 + .long 1019669816 + .long 1353941060 + .long 1072940774 + .long 1722928782 + .long 1019926215 + .long 1803191644 + .long 1072954391 + .long 1547878639 + .long 1020259262 + .long 1092591296 + .long 1072967024 + .long 3070107923 + .long 1018320401 + .long 2205372832 + .long 1072978772 + .long 787328196 + .long 1014621351 + .long 1291577100 + .long 1072989723 + .long 2964757301 + .long 1020242528 + .long 4234512804 + .long 1072999952 + .long 3136030038 + .long 1017522144 + .long 3248069132 + .long 1073009528 + .long 1506192355 + .long 1018050472 + .long 3932628500 + .long 1073018509 + .long 1045823554 + .long 1019946655 + .long 4195697848 + .long 1073026948 + .long 233443322 + .long 1018917447 + .long 2501811452 + .long 1073034892 + .long 901427976 + .long 1017333852 + .long 866379428 + .long 1073049455 + .long 2437443742 + .long 1019678792 + .long 1376865888 + .long 1073062480 + .long 3365790232 + .long 1014547152 + .long 3290094268 + .long 1073074195 + .long 3898947415 + .long 1018683566 + .long 354764884 + .long 1073084787 + .long 3854322404 + .long 1019662058 + .long 3332975496 + .long 1073094406 + .long 3171701655 + .long 1017830922 + .long 1141460088 + .long 1073103181 + .long 3946082701 + .long 1020032019 + .long 745761284 + .long 1073111216 + .long 1347210591 + .long 1019106121 + .long 1673304508 + .long 1073118600 + .long 1760606642 + .long 1017324577 + .long 983388240 + .long 1073125409 + .long 3740651204 + .long 1019514104 + .long 3895509100 + .long 1073131706 + .long 2409629983 + .long 1020069322 + .long 2128523668 + .long 1073137548 + .long 3045605368 + .long 1018579174 + .long 2075485692 + .long 1073142981 + .long 3720571789 + .long 1017557436 + .long 121855976 + .long 1073148047 + .long 2391744767 + .long 1020160645 + .long 4181733780 + .long 1073152780 + .long 995028816 + .long 1019681295 + .long 2887813280 + .long 1073157214 + .long 218733247 + .long 1020003509 + .long 2862180896 + .long 1073161375 + .long 2043806490 + .long 1018602288 + .long 3909375184 + .long 1073168973 + .long 1559903412 + .long 1020103444 + .long 3533966292 + .long 1073175738 + .long 734884149 + .long 1018462962 + .long 3815044608 + .long 1073181799 + .long 3630523428 + .long 1017250093 + .long 739639376 + .long 1073187261 + .long 4167476661 + .long 1020008277 + .long 1068309648 + .long 1073192207 + .long 2110061437 + .long 1019295858 + .long 2350566352 + .long 1073196707 + .long 582596516 + .long 1018568821 + .long 2529520024 + .long 1073200819 + .long 745552787 + .long 1019053165 + .long 1841667508 + .long 1073204591 + .long 3982568700 + .long 1016503327 + .long 2242261080 + .long 1073208063 + .long 3433582258 + .long 1016196763 + .long 715134328 + .long 1073211270 + .long 355901358 + .long 1020087916 + .long 2700735876 + .long 1073214240 + .long 3640957736 + .long 1019780205 + .long 141607580 + .long 1073217000 + .long 2488245051 + .long 1020262395 + .long 287934404 + .long 1073219570 + .long 2392691085 + .long 1019883292 + .long 2363373988 + .long 1073221969 + .long 4194561737 + .long 1019237447 + .long 3829340424 + .long 1073224214 + .long 429455526 + .long 1019490975 + .long 1988805928 + .long 1073226320 + .long 3029848706 + .long 1018104889 + .long 1647572320 + .long 1073230161 + .long 10289938 + .long 1017394880 + .long 3988000624 + .long 1073233576 + .long 1957559169 + .long 1019434816 + .long 4263843944 + .long 1073236633 + .long 204710264 + .long 1019908761 + .long 663197724 + .long 1073239386 + .long 1921757578 + .long 1019778948 + .long 3560800700 + .long 1073241876 + .long 3994348896 + .long 1019230192 + .long 2441785656 + .long 1073244141 + .long 871468611 + .long 1014800505 + .long 3277400272 + .long 1073246209 + .long 4092218139 + .long 1020040842 + .long 3951990120 + .long 1073248105 + .long 4276546478 + .long 1019763677 + .long 2737338540 + .long 1073249850 + .long 252776012 + .long 1018794951 + .long 1511361316 + .long 1073251461 + .long 3119653999 + .long 1018514803 + .long 3969162516 + .long 1073252952 + .long 1037069016 + .long 1016792900 + .long 413985240 + .long 1073254338 + .long 4110171432 + .long 1020001345 + .long 3681283576 + .long 1073255627 + .long 1463092818 + .long 1020260354 + .long 3146455488 + .long 1073256831 + .long 1031209123 + .long 1016554799 + .long 95214512 + .long 1073257958 + .long 1373808632 + .long 1019493031 + .long 4250240828 + .long 1073259013 + .long 3891047882 + .long 1020108730 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1074340347 + .long 856972295 + .long 1017226790 + .long 1413754136 + .long 1072243195 + .long 856972295 + .long 1015129638 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1413754136 + .long 1074340347 + .long 856972295 + .long 1017226790 + .long 1413754136 + .long 3221823995 + .long 856972295 + .long 3164710438 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 856972295 + .long 1017226790 + .long 1413754136 + .long 1074340347 + .long 856972295 + .long 3164710438 + .long 1413754136 + .long 3221823995 + .long 0 + .long 0 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .long 2006262985 + .long 1069310863 + .long 2358449471 + .long 3217342131 + .long 3845454352 + .long 1069952297 + .long 2829679149 + .long 1073771565 + .long 4294967295 + .long 2148532223 + .long 0 + .long 0 + .long 0 + .long 1130364928 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,3024 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atan2dl.S b/external/sgx_libm/ia32/atan2dl.S new file mode 100644 index 0000000000..b468d4da20 --- /dev/null +++ b/external/sgx_libm/ia32/atan2dl.S @@ -0,0 +1,1431 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2dl.c" + .text +..TXTST0: +# -- Begin atand2l + .text + .align 16,0x90 + .globl atand2l +atand2l: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %ebx + subl $60, %esp + fldt 8(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpt (%esp) + fldt 20(%ebp) + fstpt 12(%esp) + call atan2dl@PLT +..B1.2: + addl $60, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type atand2l,@function + .size atand2l,.-atand2l + .data +# -- End atand2l + .text +# -- Begin atan2dl + .text + .align 16,0x90 + .globl atan2dl +atan2dl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $68, %esp +..B2.2: + fnstcw 62(%esp) +..B2.3: + movzbl 29(%ebp), %ecx + movzbl 17(%ebp), %esi + andl $128, %ecx + movzwl 16(%ebp), %edi + andl $128, %esi + andl $32767, %edi + movzwl 28(%ebp), %ebx + shrl $7, %ecx + andl $32767, %ebx + shrl $7, %esi + call ..L4 +..L4: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%edx), %edx + cmpl $32767, %edi + je ..B2.114 +..B2.4: + cmpl $32767, %ebx + je ..B2.95 +..B2.5: + testl %edi, %edi + jne ..B2.8 +..B2.6: + cmpl $0, 12(%ebp) + jne ..B2.8 +..B2.7: + cmpl $0, 8(%ebp) + je ..B2.13 +..B2.8: + testl %ebx, %ebx + jne ..B2.29 +..B2.9: + cmpl $0, 24(%ebp) + jne ..B2.29 +..B2.10: + cmpl $0, 20(%ebp) + jne ..B2.29 +..B2.11: + testl %edi, %edi + jne ..B2.25 +..B2.12: + cmpl $0, 12(%ebp) + je ..B2.122 + jmp ..B2.23 +..B2.13: + jne ..B2.23 +..B2.14: + testl %ebx, %ebx + jne ..B2.19 +..B2.15: + cmpl $0, 24(%ebp) + jne ..B2.18 +..B2.16: + cmpl $0, 20(%ebp) + je ..B2.89 +..B2.17: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 40(%esp) + jmp ..B2.19 +..B2.18: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 40(%esp) +..B2.19: + testl %ecx, %ecx + je ..B2.21 +..B2.20: + fldl c180@GOTOFF(%edx,%esi,8) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.21: + fldl _zeros@GOTOFF(%edx,%esi,8) +..B2.22: + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.23: + testl %ebx, %ebx + jne ..B2.29 +..B2.24: + cmpl $0, 24(%ebp) + jne ..B2.29 +..B2.25: + cmpl $0, 20(%ebp) + jne ..B2.29 +..B2.26: + testl %edi, %edi + jne ..B2.28 +..B2.27: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 40(%esp) +..B2.28: + fldl c90@GOTOFF(%edx,%esi,8) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.29: + cmpl %edi, %ebx + jne ..B2.35 +..B2.30: + movl 24(%ebp), %eax + cmpl 12(%ebp), %eax + jne ..B2.35 +..B2.31: + movl 20(%ebp), %eax + cmpl 8(%ebp), %eax + jne ..B2.35 +..B2.32: + orl %edi, %ebx + jne ..B2.34 +..B2.33: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 40(%esp) +..B2.34: + lea (%esi,%ecx,2), %eax + fldl exact@GOTOFF(%edx,%eax,8) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.35: + movzwl 62(%esp), %eax + movl %eax, (%esp) + andl $3840, %eax + cmpl $768, %eax + je ..B2.94 +..B2.36: + movl (%esp), %eax + andl $-3841, %eax + orl $-64768, %eax + movw %ax, 60(%esp) +..B2.37: + fldcw 60(%esp) +..B2.38: + movl $1, 36(%esp) +..B2.39: + cmpl $8191, %ebx + jg ..B2.43 +..B2.40: + cmpl $8191, %edi + jg ..B2.42 +..B2.41: + fldt _TWO_8192@GOTOFF(%edx) + fldt 20(%ebp) + fmul %st(1), %st + fstpt 20(%ebp) + fldt 20(%ebp) + fldt 8(%ebp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + movzwl 28(%ebp), %ebx + movzwl 16(%ebp), %edi + andl $32767, %ebx + andl $32767, %edi + jmp ..B2.44 +..B2.42: + fldt 20(%ebp) + fldt 8(%ebp) + jmp ..B2.47 +..B2.43: + fldt 20(%ebp) + fldt 8(%ebp) +..B2.44: + cmpl $24575, %ebx + jl ..B2.47 +..B2.45: + cmpl $24575, %edi + jl ..B2.47 +..B2.46: + fldt 12+_TWO_8192@GOTOFF(%edx) + fmul %st, %st(2) + fxch %st(2) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + movzwl 28(%ebp), %ebx + movzwl 16(%ebp), %edi + andl $32767, %ebx + andl $32767, %edi +..B2.47: + fxch %st(1) + fmull _ones@GOTOFF(%edx,%ecx,8) + fld %st(1) + fldl _ones@GOTOFF(%edx,%esi,8) + fmul %st, %st(1) + fxch %st(2) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.75 +..B2.48: + lea 12(%edi), %eax + cmpl %eax, %ebx + jle ..B2.71 +..B2.49: + lea 75(%edi), %eax + cmpl %eax, %ebx + jle ..B2.68 +..B2.50: + fstp %st(0) + fstp %st(0) + fstp %st(0) + testl %ecx, %ecx + je ..B2.52 +..B2.51: + fstp %st(0) + lea (,%esi,8), %eax + lea (%eax,%esi,4), %ecx + fldt _small_value_80@GOTOFF(%edx,%ecx) + fsubrl c180@GOTOFF(%edx,%esi,8) + fstpt 48(%esp) + jmp ..B2.86 +..B2.52: + testl %edi, %edi + jle ..B2.93 +..B2.53: + fstp %st(0) + xorl %eax, %eax +..B2.54: + fldl _TWO_32H@GOTOFF(%edx) + shll $15, %ecx + fld %st(0) + orl $-49153, %ecx + movw %cx, 28(%ebp) + fldt 20(%ebp) + fld %st(0) + fmul %st(3), %st + fld %st(1) + shll $15, %esi + fsubr %st(1), %st + movzwl 16(%ebp), %edi + orl $-49153, %esi + movw %si, 16(%ebp) + andl $32767, %edi + subl %edi, %ebx + fsubrp %st, %st(1) + fld %st(1) + cmpl $16382, %ebx + fsub %st(1), %st + fxch %st(2) + fstpt 24(%esp) + fldt 24(%esp) + fldl _ones@GOTOFF(%edx) + fld %st(0) + fdivp %st, %st(2) + fxch %st(1) + fmul %st, %st(4) + fld %st(4) + fsub %st(1), %st + fsubrp %st, %st(5) + fld %st(4) + fsubr %st(1), %st + fld %st(3) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fxch %st(3) + fmul %st(5), %st + fsubr %st(2), %st + fsubp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(2) + fldl _C180byPi@GOTOFF(%edx) + fmul %st, %st(4) + fmulp %st, %st(2) + fldl 8+_C180byPi@GOTOFF(%edx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 8(%ebp) + fld %st(0) + fmul %st(5), %st + fld %st(1) + fsubr %st(1), %st + fsubrp %st, %st(1) + fxch %st(4) + fmul %st, %st(5) + fld %st(5) + fsub %st(1), %st + fsubrp %st, %st(6) + fsub %st(5), %st + faddp %st, %st(2) + fmul %st, %st(1) + fld %st(0) + fsub %st(4), %st + fmul %st(5), %st + faddp %st, %st(2) + fld %st(1) + fxch %st(5) + fmulp %st, %st(4) + fxch %st(3) + fadd %st, %st(4) + fld %st(4) + fxch %st(1) + fsub %st(5), %st + faddp %st, %st(2) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmul %st(5), %st + fsubr %st, %st(1) + fxch %st(1) + fchs + fsubrp %st, %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fsubrp %st, %st(4) + fxch %st(3) + fstpt 12(%esp) + fldt 12(%esp) + faddp %st, %st(3) + jl ..B2.58 +..B2.55: + fldt _small@GOTOFF(%edx) + addl $-16318, %ebx + fmul %st, %st(3) + cmpl $16382, %ebx + fldt 48(%esp) + fmul %st(1), %st + fstpt 48(%esp) + jl ..B2.57 +..B2.56: + fldt 48(%esp) + addl $-16318, %ebx + fmul %st(1), %st + fstpt 48(%esp) + fldt 48(%esp) + fstpt (%esp) + fmulp %st, %st(3) + jmp ..B2.59 +..B2.57: + fstp %st(0) + fldt 48(%esp) + fstpt (%esp) + jmp ..B2.59 +..B2.58: + fldt 48(%esp) + fstpt (%esp) +..B2.59: + movl %ebx, %ecx + negl %ecx + addl $16383, %ecx + fstpt 12(%esp) + testl %eax, %eax + movw %cx, 20(%esp) + je ..B2.61 +..B2.60: + fldt 12(%esp) + fmull 8+_two64@GOTOFF(%edx) + fstpt 12(%esp) + fldt 12(%esp) + jmp ..B2.62 +..B2.61: + fldt 12(%esp) +..B2.62: + movzwl 8(%esp), %ecx + andl $32767, %ecx + subl %eax, %ecx + subl %ebx, %ecx + cmpl $-9, %ecx + jl ..B2.65 +..B2.63: + testl %ecx, %ecx + jg ..B2.65 +..B2.64: + fldt 48(%esp) + fmul %st(1), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + jmp ..B2.66 +..B2.65: + fldt 48(%esp) + faddp %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) +..B2.66: + fldl _zeros@GOTOFF(%edx) + fldt 48(%esp) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.123 + je ..B2.67 +..B2.123: + fstp %st(0) + fstp %st(0) + jmp ..B2.86 +..B2.67: + fldt 24(%esp) + fdivrp %st, %st(2) + fmulp %st, %st(1) + fstpt 48(%esp) + jmp ..B2.86 +..B2.68: + fstp %st(3) + testl %ecx, %ecx + je ..B2.70 +..B2.69: + fldl _TWO_32H@GOTOFF(%edx) + fxch %st(3) + fdivrp %st, %st(1) + fmul %st, %st(2) + fld %st(2) + fadd %st(1), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fxch %st(3) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _C180byPi@GOTOFF(%edx) + fmul %st, %st(6) + fmulp %st, %st(3) + fldl 8+_C180byPi@GOTOFF(%edx) + fmul %st(2), %st + faddp %st, %st(3) + fldt 36+_P@GOTOFF(%edx) + fmul %st(4), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(5) + fldt _P@GOTOFF(%edx) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fsubrl 8200+__libm_atandl_table_128@GOTOFF(%edx) + faddl 8192+__libm_atandl_table_128@GOTOFF(%edx) + fmulp %st, %st(1) + fstpt 48(%esp) + jmp ..B2.86 +..B2.70: + fldt 36+_P@GOTOFF(%edx) + fld %st(1) + fdiv %st(4), %st + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(3) + fxch %st(5) + fstpl 24(%esp) + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(5) + fldt _P@GOTOFF(%edx) + faddp %st, %st(5) + fxch %st(2) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fld %st(1) + fld %st(1) + fld %st(3) + fld %st(3) + fldl _TWO_32H@GOTOFF(%edx) + fmul %st, %st(4) + fxch %st(2) + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(3) + fsubr %st, %st(5) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(3) + fsub %st(3), %st + fld %st(2) + fxch %st(5) + fmull 8+_C180byPi@GOTOFF(%edx) + fldl _C180byPi@GOTOFF(%edx) + fmul %st, %st(5) + fxch %st(5) + fmul %st, %st(6) + fxch %st(5) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(5) + fadd %st(2), %st + fld %st(4) + fadd %st(6), %st + fsubp %st, %st(6) + fxch %st(4) + fsub %st(5), %st + faddp %st, %st(1) + fxch %st(3) + fdivrl _ones@GOTOFF(%edx) + fmul %st, %st(2) + fld %st(2) + fadd %st(1), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fld %st(2) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(2) + fxch %st(2) + fmul %st(3), %st + fldt (%esp) + fxch %st(1) + faddl 8+_ones@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(6) + fxch %st(5) + fsubrp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fxch %st(3) + fadd %st(4), %st + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmull 24(%esp) + fstpt 48(%esp) + jmp ..B2.86 +..B2.71: + fstp %st(3) + fldl _TWO_63H@GOTOFF(%edx) + fld %st(1) + fxch %st(3) + fstpl 24(%esp) + fld %st(3) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(3), %st + fdiv %st(5), %st + fadd %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(2) + fld %st(4) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmulp %st, %st(3) + fld %st(3) + fldl _TWO_48H@GOTOFF(%edx) + fmul %st, %st(6) + movl 12(%esp), %eax + fxch %st(1) + fadd %st(6), %st + shll $4, %eax + fsubp %st, %st(6) + testl %ecx, %ecx + fxch %st(4) + fsub %st(5), %st + fld %st(0) + fmul %st(4), %st + fxch %st(3) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(6) + fxch %st(2) + fadd %st(6), %st + fld %st(5) + fmul %st(4), %st + fadd %st(3), %st + fxch %st(4) + fmul %st, %st(7) + fxch %st(7) + fsubrp %st, %st(2) + fld %st(3) + fadd %st(1), %st + fxch %st(3) + fmulp %st, %st(7) + fxch %st(6) + fsubrp %st, %st(5) + fld %st(2) + fxch %st(2) + fdivrl _ones@GOTOFF(%edx) + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(5) + fld %st(4) + fsubr %st(1), %st + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(3) + fxch %st(3) + fmul %st(4), %st + faddl 8+_ones@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + fsubrp %st, %st(1) + fld %st(1) + fmul %st(4), %st + fxch %st(3) + fadd %st, %st(4) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fld %st(2) + fxch %st(4) + fmulp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fadd %st(2), %st + fmul %st, %st(4) + fld %st(3) + fmul %st(3), %st + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fxch %st(1) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(4) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _C180byPi@GOTOFF(%edx) + fmul %st, %st(3) + fmulp %st, %st(4) + fldl 8+_C180byPi@GOTOFF(%edx) + fmul %st(5), %st + faddp %st, %st(4) + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(3) + fldt _P@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldl 24(%esp) + je ..B2.73 +..B2.72: + negl %eax + fld %st(2) + fldl 8192+__libm_atandl_table_128@GOTOFF(%edx,%eax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fldl 8200+__libm_atandl_table_128@GOTOFF(%edx,%eax) + fsubp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + jmp ..B2.74 +..B2.73: + fldl __libm_atandl_table_128@GOTOFF(%eax,%edx) + fld %st(3) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fxch %st(2) + faddl 8+__libm_atandl_table_128@GOTOFF(%eax,%edx) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 48(%esp) +..B2.74: + fldt 48(%esp) + fmulp %st, %st(1) + fstpt 48(%esp) + jmp ..B2.86 +..B2.75: + fstp %st(3) + lea 12(%ebx), %eax + cmpl %eax, %edi + jle ..B2.82 +..B2.76: + addl $75, %ebx + cmpl %ebx, %edi + jle ..B2.78 +..B2.77: + fstp %st(2) + fstp %st(1) + fstp %st(0) + lea (,%esi,8), %eax + lea (%eax,%esi,4), %ecx + fldt _small_value_80@GOTOFF(%edx,%ecx) + fsubrl c90@GOTOFF(%edx,%esi,8) + fstpt 48(%esp) + jmp ..B2.86 +..B2.78: + fldl _TWO_32H@GOTOFF(%edx) + testl %ecx, %ecx + fxch %st(1) + fdivrp %st, %st(3) + fmul %st(2), %st + fld %st(0) + fadd %st(3), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(1) + fld %st(0) + fsubr %st(3), %st + fld %st(3) + fmul %st(4), %st + fld %st(0) + fmul %st(1), %st + fxch %st(5) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _C180byPi@GOTOFF(%edx) + fmul %st, %st(4) + fmulp %st, %st(3) + fldl 8+_C180byPi@GOTOFF(%edx) + fmul %st(2), %st + faddp %st, %st(3) + fldt 36+_P@GOTOFF(%edx) + fmul %st(6), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(6), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(7) + fldt _P@GOTOFF(%edx) + faddp %st, %st(7) + fxch %st(1) + fmulp %st, %st(6) + faddp %st, %st(5) + fmulp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fldl 4096+__libm_atandl_table_128@GOTOFF(%edx) + fstpt 48(%esp) + fldl 4104+__libm_atandl_table_128@GOTOFF(%edx) + je ..B2.80 +..B2.79: + fldt 48(%esp) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + jmp ..B2.81 +..B2.80: + fldt 48(%esp) + fxch %st(3) + fsubrp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) +..B2.81: + fldt 48(%esp) + fmulp %st, %st(1) + fstpt 48(%esp) + jmp ..B2.86 +..B2.82: + fldl _TWO_63H@GOTOFF(%edx) + fld %st(3) + fxch %st(3) + fstpl 24(%esp) + fld %st(1) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(5), %st + fdiv %st(3), %st + fadd %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(2) + fld %st(4) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmulp %st, %st(3) + fld %st(3) + fldl _TWO_48H@GOTOFF(%edx) + fmul %st, %st(6) + movl 12(%esp), %eax + fxch %st(2) + fadd %st(6), %st + shll $4, %eax + fsubp %st, %st(6) + fld %st(5) + testl %ecx, %ecx + fmul %st(4), %st + fxch %st(6) + fsubr %st, %st(7) + fxch %st(2) + fmul %st, %st(3) + fxch %st(1) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fld %st(6) + fmul %st(4), %st + fadd %st(5), %st + fxch %st(4) + fmul %st, %st(5) + fxch %st(5) + fsubrp %st, %st(7) + fmul %st, %st(4) + fxch %st(4) + fsubrp %st, %st(1) + fxch %st(3) + faddp %st, %st(4) + fld %st(3) + fadd %st(2), %st + fld %st(4) + fxch %st(1) + fdivrl _ones@GOTOFF(%edx) + fmul %st, %st(2) + fld %st(2) + fadd %st(1), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddl 8+_ones@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(2) + fsubp %st, %st(1) + fld %st(2) + fmul %st(4), %st + fxch %st(2) + fadd %st, %st(4) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fld %st(1) + fxch %st(4) + fmulp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fadd %st(3), %st + fmul %st, %st(4) + fld %st(2) + fmul %st(4), %st + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fxch %st(1) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(4) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _C180byPi@GOTOFF(%edx) + fmul %st, %st(4) + fmulp %st, %st(3) + fldl 8+_C180byPi@GOTOFF(%edx) + fmul %st(5), %st + faddp %st, %st(3) + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(3) + fldt _P@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fldl 24(%esp) + je ..B2.84 +..B2.83: + fldl 4096+__libm_atandl_table_128@GOTOFF(%edx,%eax) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(3) + faddl 4104+__libm_atandl_table_128@GOTOFF(%edx,%eax) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + jmp ..B2.85 +..B2.84: + negl %eax + fld %st(1) + fldl 4096+__libm_atandl_table_128@GOTOFF(%edx,%eax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(3) + fldl 4104+__libm_atandl_table_128@GOTOFF(%edx,%eax) + fsubp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 48(%esp) +..B2.85: + fldt 48(%esp) + fmulp %st, %st(1) + fstpt 48(%esp) +..B2.86: + cmpl $0, 36(%esp) + je ..B2.88 +..B2.87: + fldcw 62(%esp) +..B2.88: + fldt 48(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.89: + testl %ecx, %ecx + je ..B2.91 +..B2.90: + fldl c180@GOTOFF(%edx,%esi,8) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.91: + fldl _zeros@GOTOFF(%edx,%esi,8) +..B2.92: + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.93: + fmull _two64@GOTOFF(%edx) + movl $64, %eax + fstpt 8(%ebp) + jmp ..B2.54 +..B2.94: + movl $0, 36(%esp) + jmp ..B2.39 +..B2.95: + cmpl $-2147483648, 24(%ebp) + jne ..B2.109 +..B2.96: + cmpl $0, 20(%ebp) + jne ..B2.109 +..B2.97: + testl %edi, %edi + jne ..B2.104 +..B2.98: + cmpl $0, 12(%ebp) + jne ..B2.100 +..B2.99: + cmpl $0, 8(%ebp) + je ..B2.103 +..B2.100: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 40(%esp) +..B2.101: + cmpl $32767, %ebx + je ..B2.104 +..B2.102: + fldl c90@GOTOFF(%edx,%esi,8) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.103: + shll $3, %esi + jmp ..B2.105 +..B2.104: + shll $3, %esi + cmpl $32767, %edi + je ..B2.110 +..B2.105: + testl %ecx, %ecx + je ..B2.107 +..B2.106: + fldl c180@GOTOFF(%esi,%edx) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.107: + fldl _zeros@GOTOFF(%esi,%edx) +..B2.108: + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.109: + fldt 20(%ebp) + fldt 8(%ebp) + fmulp %st, %st(1) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.110: + testl %ecx, %ecx + je ..B2.112 +..B2.111: + fldl c135@GOTOFF(%edx,%esi) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.112: + fldl c45@GOTOFF(%edx,%esi) +..B2.113: + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.114: + cmpl $-2147483648, 12(%ebp) + jne ..B2.109 +..B2.115: + cmpl $0, 8(%ebp) + jne ..B2.109 +..B2.116: + cmpl $32767, %ebx + je ..B2.95 +..B2.117: + testl %ebx, %ebx + jne ..B2.101 +..B2.118: + cmpl $0, 24(%ebp) + jne ..B2.100 +..B2.119: + cmpl $0, 20(%ebp) + jne ..B2.100 + jmp ..B2.102 +..B2.122: + cmpl $0, 8(%ebp) + je ..B2.14 + jmp ..B2.23 + .align 16,0x90 + .type atan2dl,@function + .size atan2dl,.-atan2dl + .data +# -- End atan2dl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x80,0x13,0x40,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 16 +_TWO_8192: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .type _TWO_8192,@object + .size _TWO_8192,24 + .space 8, 0x00 # pad + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .space 8, 0x00 # pad + .align 16 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .space 8, 0x00 # pad + .align 16 +_C180byPi: + .long 442499072 + .long 1078765020 + .long 3272251219 + .long 1042157501 + .type _C180byPi,@object + .size _C180byPi,16 + .align 16 +_small: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 65 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32769 + .word 0 + .type _small,@object + .size _small,24 + .space 8, 0x00 # pad + .align 16 +_two64: + .long 0 + .long 1139802112 + .long 0 + .long 1005584384 + .type _two64,@object + .size _two64,16 + .align 16 +_P: + .word 54228 + .word 26975 + .word 60215 + .word 39113 + .word 49155 + .word 0 + .word 30637 + .word 6142 + .word 46044 + .word 46936 + .word 16386 + .word 0 + .word 47408 + .word 26349 + .word 14153 + .word 33526 + .word 49154 + .word 0 + .word 53934 + .word 32714 + .word 35699 + .word 52145 + .word 16385 + .word 0 + .type _P,@object + .size _P,48 + .align 16 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .space 8, 0x00 # pad + .align 16 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 8 +c180: + .long 0x00000000,0x40668000 + .long 0x00000000,0xc0668000 + .type c180,@object + .size c180,16 + .align 8 +c90: + .long 0x00000000,0x40568000 + .long 0x00000000,0xc0568000 + .type c90,@object + .size c90,16 + .align 8 +exact: + .long 0x00000000,0x40468000 + .long 0x00000000,0xc0468000 + .long 0x00000000,0x4060e000 + .long 0x00000000,0xc060e000 + .type exact,@object + .size exact,32 + .align 8 +c135: + .long 0x00000000,0x4060e000 + .long 0x00000000,0xc060e000 + .type c135,@object + .size c135,16 + .align 8 +c45: + .long 0x00000000,0x40468000 + .long 0x00000000,0xc0468000 + .type c45,@object + .size c45,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .data + .hidden __libm_atandl_table_128 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atan2f_wmt.S b/external/sgx_libm/ia32/atan2f_wmt.S new file mode 100644 index 0000000000..ea10669117 --- /dev/null +++ b/external/sgx_libm/ia32/atan2f_wmt.S @@ -0,0 +1,791 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2f_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin atan2f + .text + .align 16,0x90 + .globl atan2f +atan2f: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movss 116(%esp), %xmm1 + movl 112(%esp), %edx + movl 116(%esp), %ecx + movss %xmm0, 8(%esp) + movss %xmm1, 12(%esp) + movl %edx, %eax + andl $2147483647, %edx + subl $528482304, %edx + cmpl $1073741824, %edx + jae .L_2TAG_PACKET_0.0.3 + movl %ecx, %edx + andl $-2147483648, %ecx + andl $2147483647, %edx + subl $528482304, %edx + cmpl $1073741824, %edx + jae .L_2TAG_PACKET_1.0.3 + divss %xmm1, %xmm0 + movss 8(%esp), %xmm5 +.L_2TAG_PACKET_2.0.3: + movl $-262144, %edx + movd %edx, %xmm3 + movss %xmm1, %xmm6 + movl $262144, %edx + movd %edx, %xmm4 + movss %xmm1, %xmm2 + shrl $31, %eax + shrl $30, %ecx + orl %eax, %ecx + andps %xmm3, %xmm6 + subss %xmm6, %xmm1 + andps %xmm0, %xmm3 + movd %xmm0, %edx + orps %xmm4, %xmm3 + mulss %xmm3, %xmm6 + mulss %xmm3, %xmm1 + movl %edx, %eax + andl $2146959360, %edx + subl $1023410176, %edx + cmpl $83361792, %edx + ja .L_2TAG_PACKET_3.0.3 + mulss %xmm5, %xmm3 + subss %xmm6, %xmm5 + addss %xmm3, %xmm2 + subss %xmm1, %xmm5 + divss %xmm2, %xmm5 + shrl $16, %edx + addl $8, %edx + andl $-2147483648, %eax + movd %eax, %xmm0 + movss (%ebx,%edx), %xmm1 + movss 4(%ebx,%edx), %xmm3 + movl $-1096111855, %eax + movd %eax, %xmm4 + movss 1440(%ebx,%ecx,8), %xmm6 + xorps %xmm0, %xmm1 + xorps %xmm0, %xmm3 + movss %xmm1, %xmm7 + addss 1444(%ebx,%ecx,8), %xmm1 + addss %xmm6, %xmm3 + movss 1444(%ebx,%ecx,8), %xmm6 + movss %xmm5, %xmm2 + mulss %xmm5, %xmm5 + movss %xmm1, %xmm0 + subss %xmm1, %xmm6 + mulss %xmm2, %xmm4 + addss %xmm2, %xmm1 + addss %xmm7, %xmm6 + subss %xmm1, %xmm0 + mulss %xmm4, %xmm5 + addss %xmm6, %xmm3 + addss %xmm2, %xmm0 + addss %xmm3, %xmm5 + addss %xmm5, %xmm0 + addss %xmm1, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_3.0.3: + addl $75497472, %edx + cmpl $158859264, %edx + ja .L_2TAG_PACKET_5.0.3 + movss 8(%esp), %xmm0 + movss 12(%esp), %xmm1 + cvtps2pd %xmm0, %xmm0 + cvtps2pd %xmm1, %xmm1 + divsd %xmm1, %xmm0 + movsd 1360(%ebx), %xmm7 + movsd 1368(%ebx), %xmm2 + movss 1440(%ebx,%ecx,8), %xmm3 + movss 1444(%ebx,%ecx,8), %xmm4 + cvtps2pd %xmm3, %xmm3 + cvtps2pd %xmm4, %xmm4 + addsd %xmm4, %xmm3 + mulsd %xmm0, %xmm7 + movapd %xmm0, %xmm1 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + addsd %xmm3, %xmm1 + mulsd %xmm7, %xmm0 + addsd %xmm2, %xmm0 + addsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + addl $947912704, %edx + cmpl $1106771968, %edx + jae .L_2TAG_PACKET_6.0.3 + movss 1440(%ebx,%ecx,8), %xmm2 + movss 1444(%ebx,%ecx,8), %xmm1 + addss %xmm2, %xmm0 + addss %xmm1, %xmm0 +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_6.0.3: + cmpl $1602224128, %edx + jae .L_2TAG_PACKET_8.0.3 + movss 8(%esp), %xmm0 + movss 12(%esp), %xmm1 + movl $-2147483648, %edx + movd %edx, %xmm7 + xorps %xmm7, %xmm0 + cvtps2pd %xmm0, %xmm5 + cvtps2pd %xmm1, %xmm0 + divsd %xmm5, %xmm0 + movsd 1376(%ebx), %xmm2 + andl $1, %ecx + movsd 1344(%ebx,%ecx,8), %xmm3 + mulsd %xmm0, %xmm2 + movapd %xmm0, %xmm1 + mulsd %xmm0, %xmm0 + addsd %xmm3, %xmm1 + mulsd %xmm2, %xmm0 + addsd %xmm1, %xmm0 + cvtsd2ss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_8.0.3: + movss 1408(%ebx), %xmm0 + movss 1412(%ebx), %xmm1 + shll $31, %ecx + movd %ecx, %xmm3 + addss %xmm1, %xmm0 + xorps %xmm3, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_0.0.3: + addl $528482304, %edx + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_9.0.3 + cmpl $0, %edx + je .L_2TAG_PACKET_10.0.3 + movl %ecx, %edx + andl $-2147483648, %ecx + andl $2147483647, %edx + subl $528482304, %edx +.L_2TAG_PACKET_1.0.3: + addl $528482304, %edx + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_11.0.3 + cmpl $0, %edx + je .L_2TAG_PACKET_12.0.3 + cvtss2sd %xmm0, %xmm0 + cvtss2sd %xmm1, %xmm3 + divsd %xmm3, %xmm0 + movss 8(%esp), %xmm5 + pextrw $3, %xmm0, %edx + andl $32767, %edx + subl $15344, %edx + cmpl $2048, %edx + jae .L_2TAG_PACKET_13.0.3 + movd %xmm1, %edx + cvtsd2ss %xmm0, %xmm0 + andl $2147483647, %edx + cmpl $276824064, %edx + jb .L_2TAG_PACKET_14.0.3 + cmpl $1602224128, %edx + ja .L_2TAG_PACKET_15.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_15.0.3: + movl $796917760, %edx + movd %edx, %xmm4 + mulss %xmm4, %xmm1 + mulss %xmm4, %xmm5 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_14.0.3: + movl $1333788672, %edx + movd %edx, %xmm4 + mulss %xmm4, %xmm1 + mulss %xmm4, %xmm5 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_13.0.3: + shrl $31, %eax + shrl $30, %ecx + orl %eax, %ecx + addl $15344, %edx + cmpl $17392, %edx + jae .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_16.0.3: + cmpl $2, %ecx + jb .L_2TAG_PACKET_17.0.3 + movss 1440(%ebx,%ecx,8), %xmm2 + movss 1444(%ebx,%ecx,8), %xmm0 + addss %xmm2, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_17.0.3: + movsd 1392(%ebx), %xmm1 + mulsd %xmm1, %xmm0 + cvtsd2ss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_9.0.3: + ja .L_2TAG_PACKET_18.0.3 + movl %ecx, %edx + andl $-2147483648, %ecx + andl $2147483647, %edx + cmpl $2139095040, %edx + je .L_2TAG_PACKET_19.0.3 + ja .L_2TAG_PACKET_20.0.3 + movss 1408(%ebx), %xmm0 + movss 1412(%ebx), %xmm1 + andl $-2147483648, %eax + movd %eax, %xmm3 + addss %xmm1, %xmm0 + xorps %xmm3, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_19.0.3: + movss 1408(%ebx), %xmm0 + movss 1412(%ebx), %xmm1 + movl $1056964608, %edx + sarl $31, %ecx + andl $12582912, %ecx + addl %ecx, %edx + movd %edx, %xmm2 + addss %xmm1, %xmm0 + mulss %xmm2, %xmm0 + andl $-2147483648, %eax + movd %eax, %xmm3 + xorps %xmm3, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_18.0.3: + addss %xmm1, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_10.0.3: + movl %ecx, %edx + andl $-2147483648, %ecx + andl $2147483647, %edx + cmpl $2139095040, %edx + ja .L_2TAG_PACKET_20.0.3 + cmpl $0, %edx + je .L_2TAG_PACKET_21.0.3 + cmpl $0, %ecx + jne .L_2TAG_PACKET_22.0.3 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_23.0.3: +.L_2TAG_PACKET_22.0.3: + movss 1456(%ebx), %xmm0 + movss 1460(%ebx), %xmm1 + andl $-2147483648, %eax + movd %eax, %xmm3 + addss %xmm1, %xmm0 + xorps %xmm3, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_24.0.3: + movss 1456(%ebx), %xmm0 + movss 1460(%ebx), %xmm1 + andl $-2147483648, %eax + movd %eax, %xmm3 + addss %xmm1, %xmm0 + xorps %xmm3, %xmm0 + jmp .L_2TAG_PACKET_25.0.3 +.L_2TAG_PACKET_21.0.3: + cmpl $0, %ecx + jne .L_2TAG_PACKET_24.0.3 +.L_2TAG_PACKET_25.0.3: + movss %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 116(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $38, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_20.0.3: + movss %xmm1, %xmm0 + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_11.0.3: + ja .L_2TAG_PACKET_20.0.3 + cmpl $0, %ecx + jne .L_2TAG_PACKET_23.0.3 + andl $-2147483648, %eax + movd %eax, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_12.0.3: + movss 1408(%ebx), %xmm0 + movss 1412(%ebx), %xmm1 + andl $-2147483648, %eax + movd %eax, %xmm3 + addss %xmm1, %xmm0 + xorps %xmm3, %xmm0 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_4.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type atan2f,@function + .size atan2f,.-atan2f + .data +# -- End atan2f + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 1023669327 + .long 803928991 + .long 1024193038 + .long 2966692170 + .long 1024716678 + .long 811692700 + .long 1025240245 + .long 792964392 + .long 1025763734 + .long 802148141 + .long 1026287141 + .long 819324013 + .long 1026810463 + .long 790037051 + .long 1027333695 + .long 759154391 + .long 1027856833 + .long 817525057 + .long 1028379874 + .long 808527090 + .long 1028902813 + .long 821626264 + .long 1029425647 + .long 817580405 + .long 1029948372 + .long 2952445505 + .long 1030470983 + .long 801005003 + .long 1030993477 + .long 800387983 + .long 1031515850 + .long 2942256123 + .long 1032048979 + .long 2968250322 + .long 1032570964 + .long 822790803 + .long 1033092672 + .long 826289861 + .long 1033614088 + .long 2976224418 + .long 1034135194 + .long 824490938 + .long 1034655977 + .long 822527213 + .long 1035176421 + .long 784232806 + .long 1035696510 + .long 822531604 + .long 1036216230 + .long 2967672936 + .long 1036735564 + .long 826515440 + .long 1037254499 + .long 2944102134 + .long 1037773019 + .long 2977774463 + .long 1038291108 + .long 795957866 + .long 1038808753 + .long 2972700386 + .long 1039325938 + .long 2975253635 + .long 1039842648 + .long 807079588 + .long 1040402092 + .long 822355304 + .long 1040917290 + .long 805504040 + .long 1041431409 + .long 2978896586 + .long 1041944391 + .long 836680090 + .long 1042456182 + .long 826352980 + .long 1042966726 + .long 2973619487 + .long 1043475968 + .long 2937629464 + .long 1043983855 + .long 831159584 + .long 1044490335 + .long 820394738 + .long 1044995356 + .long 2965290852 + .long 1045498867 + .long 772017454 + .long 1046000819 + .long 2978687103 + .long 1046501162 + .long 836200518 + .long 1046999850 + .long 836883769 + .long 1047496836 + .long 826905524 + .long 1047992074 + .long 824423170 + .long 1048653779 + .long 2993658277 + .long 1049143506 + .long 2988293347 + .long 1049629355 + .long 838635411 + .long 1050111172 + .long 2981083232 + .long 1050588809 + .long 840069395 + .long 1051062131 + .long 2985487843 + .long 1051531009 + .long 2987007755 + .long 1051995325 + .long 2954909954 + .long 1052454971 + .long 2992105648 + .long 1052909846 + .long 2984512837 + .long 1053359860 + .long 2974535271 + .long 1053804931 + .long 834850816 + .long 1054244987 + .long 2990399399 + .long 1054679962 + .long 2986843574 + .long 1055109800 + .long 841668384 + .long 1055534454 + .long 840878179 + .long 1056161628 + .long 2959648204 + .long 1056972004 + .long 2999182783 + .long 1057370275 + .long 2987693957 + .long 1057757908 + .long 848029633 + .long 1058134927 + .long 833824667 + .long 1058501396 + .long 838916473 + .long 1058857417 + .long 2982869562 + .long 1059203123 + .long 2987447445 + .long 1059538675 + .long 2986943103 + .long 1059864257 + .long 2962018373 + .long 1060180073 + .long 3001690183 + .long 1060486341 + .long 3000978470 + .long 1060783292 + .long 855353569 + .long 1061071169 + .long 847903241 + .long 1061350219 + .long 2995336148 + .long 1061620693 + .long 848940038 + .long 1062010885 + .long 848518105 + .long 1062503512 + .long 2989792343 + .long 1062966414 + .long 2998000194 + .long 1063401558 + .long 2966602495 + .long 1063810833 + .long 841421013 + .long 1064196033 + .long 853285487 + .long 1064558850 + .long 831341538 + .long 1064900868 + .long 2999260393 + .long 1065223564 + .long 3001104089 + .long 1065440763 + .long 856880849 + .long 1065584798 + .long 852830020 + .long 1065721082 + .long 862757435 + .long 1065850159 + .long 2998927867 + .long 1065972528 + .long 2998512290 + .long 1066088651 + .long 2998663603 + .long 1066198953 + .long 2996780932 + .long 1066354340 + .long 3007554211 + .long 1066544552 + .long 2996943326 + .long 1066717600 + .long 3000009859 + .long 1066875577 + .long 856175525 + .long 1067020272 + .long 836800017 + .long 1067153216 + .long 3008748444 + .long 1067275724 + .long 851983949 + .long 1067388933 + .long 862585050 + .long 1067493827 + .long 3009301766 + .long 1067591258 + .long 2988483069 + .long 1067681973 + .long 3005223458 + .long 1067766623 + .long 839061141 + .long 1067845782 + .long 2995523700 + .long 1067919954 + .long 2995663457 + .long 1067989585 + .long 858133164 + .long 1068055072 + .long 829335339 + .long 1068146290 + .long 856294518 + .long 1068256389 + .long 3003850806 + .long 1068355146 + .long 856998103 + .long 1068444206 + .long 2999569255 + .long 1068524912 + .long 3011255227 + .long 1068598373 + .long 841513866 + .long 1068665514 + .long 841710807 + .long 1068727109 + .long 2949159239 + .long 1068783812 + .long 2995542644 + .long 1068836179 + .long 3007665083 + .long 1068884685 + .long 3006087365 + .long 1068929739 + .long 2996180184 + .long 1068971695 + .long 3006313179 + .long 1069010859 + .long 849476222 + .long 1069047500 + .long 860722755 + .long 1069081853 + .long 859062603 + .long 1069129538 + .long 2979745798 + .long 1069186846 + .long 842801502 + .long 1069238035 + .long 3010794384 + .long 1069284031 + .long 3010162926 + .long 1069325584 + .long 3005589807 + .long 1069363306 + .long 853875835 + .long 1069397703 + .long 851842476 + .long 1069429195 + .long 3001807968 + .long 1069458133 + .long 859424355 + .long 1069484817 + .long 3004202910 + .long 1069509498 + .long 843503196 + .long 1069532394 + .long 856475636 + .long 1069553692 + .long 2995114457 + .long 1069573552 + .long 860725119 + .long 1069592116 + .long 859745384 + .long 1069609507 + .long 3009201804 + .long 1069633623 + .long 855498560 + .long 1069662574 + .long 858167444 + .long 1069688405 + .long 853306415 + .long 1069711594 + .long 846705105 + .long 1069732526 + .long 858976312 + .long 1069751516 + .long 2999172562 + .long 1069768821 + .long 2999539371 + .long 1069784656 + .long 2998679696 + .long 1069799200 + .long 861304267 + .long 1069812606 + .long 843012447 + .long 1069825002 + .long 3010989671 + .long 1069836497 + .long 3005173143 + .long 1069847186 + .long 853102954 + .long 1069857152 + .long 2993551140 + .long 1069866465 + .long 3000116992 + .long 1069875187 + .long 827148142 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 2147418112 + .long 0 + .long 0 + .long 0 + .long 32768 + .long 0 + .long 0 + .long 1413754136 + .long 1073291771 + .long 1413754136 + .long 3220775419 + .long 2576980378 + .long 1070176665 + .long 1431655765 + .long 3218429269 + .long 1431655765 + .long 3218429269 + .long 0 + .long 0 + .long 4194304 + .long 1072693248 + .long 0 + .long 0 + .long 1070141402 + .long 866263400 + .long 1078530010 + .long 874652008 + .long 1061752794 + .long 857874792 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 874652008 + .long 1078530010 + .long 3022135656 + .long 3226013658 + .type static_const_table,@object + .size static_const_table,1472 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atan2l.S b/external/sgx_libm/ia32/atan2l.S new file mode 100644 index 0000000000..795987a9ca --- /dev/null +++ b/external/sgx_libm/ia32/atan2l.S @@ -0,0 +1,1195 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2l.c" + .text +..TXTST0: +# -- Begin atan2l + .text + .align 16,0x90 + .globl atan2l +atan2l: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp +..B1.2: + fnstcw 30(%esp) +..B1.3: + movzbl 29(%ebp), %edi + movzbl 17(%ebp), %ebx + andl $128, %edi + movzwl 16(%ebp), %ecx + andl $128, %ebx + andl $32767, %ecx + movzwl 28(%ebp), %esi + shrl $7, %edi + andl $32767, %esi + shrl $7, %ebx + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $32767, %ecx + je ..B1.90 +..B1.4: + cmpl $32767, %esi + je ..B1.90 +..B1.5: + testl %ecx, %ecx + jne ..B1.8 +..B1.6: + cmpl $0, 12(%ebp) + jne ..B1.8 +..B1.7: + cmpl $0, 8(%ebp) + je ..B1.11 +..B1.8: + testl %esi, %esi + jne ..B1.32 +..B1.9: + cmpl $0, 24(%ebp) + jne ..B1.32 +..B1.10: + cmpl $0, 20(%ebp) + jne ..B1.32 +..B1.11: + movzwl 30(%esp), %eax + movl %eax, 12(%esp) + andl $768, %eax + cmpl $768, %eax + je ..B1.88 +..B1.12: + movl 12(%esp), %eax + orl $-64768, %eax + movw %ax, 28(%esp) +..B1.13: + fldcw 28(%esp) +..B1.14: + movl $1, %eax +..B1.15: + testl %ecx, %ecx + jne ..B1.28 +..B1.16: + cmpl $0, 12(%ebp) + jne ..B1.27 +..B1.17: + cmpl $0, 8(%ebp) + jne ..B1.26 +..B1.18: + testl %esi, %esi + jne ..B1.23 +..B1.19: + cmpl $0, 24(%ebp) + jne ..B1.22 +..B1.20: + cmpl $0, 20(%ebp) + je ..B1.85 +..B1.21: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 56(%esp) + jmp ..B1.23 +..B1.22: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 56(%esp) +..B1.23: + testl %edi, %edi + je ..B1.25 +..B1.24: + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ebx + fldt _pi_00l@GOTOFF(%ebx,%edx) + fldt _small_value_80@GOTOFF(%ebx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.29 +..B1.25: + fldl _zeros@GOTOFF(%edx,%ebx,8) + fstpt 64(%esp) + jmp ..B1.29 +..B1.26: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 56(%esp) + jmp ..B1.28 +..B1.27: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 56(%esp) +..B1.28: + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ebx + fldt _pi_02l@GOTOFF(%ebx,%edx) + fldt _small_value_80@GOTOFF(%ebx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) +..B1.29: + testl %eax, %eax + je ..B1.31 +..B1.30: + fldcw 30(%esp) +..B1.31: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movzwl 30(%esp), %eax + movl %eax, 12(%esp) + andl $768, %eax + cmpl $768, %eax + je ..B1.89 +..B1.33: + movl 12(%esp), %eax + orl $-64768, %eax + movw %ax, 28(%esp) +..B1.34: + fldcw 28(%esp) +..B1.35: + movl $1, 12(%esp) +..B1.36: + cmpl $8191, %esi + jg ..B1.40 +..B1.37: + cmpl $8191, %ecx + jg ..B1.39 +..B1.38: + fldt _TWO_8192@GOTOFF(%edx) + fldt 20(%ebp) + fmul %st(1), %st + fstpt 20(%ebp) + fldt 20(%ebp) + fldt 8(%ebp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + movzwl 28(%ebp), %esi + movzwl 16(%ebp), %ecx + andl $32767, %esi + andl $32767, %ecx + jmp ..B1.41 +..B1.39: + fldt 20(%ebp) + fldt 8(%ebp) + jmp ..B1.44 +..B1.40: + fldt 20(%ebp) + fldt 8(%ebp) +..B1.41: + cmpl $24575, %esi + jl ..B1.44 +..B1.42: + cmpl $24575, %ecx + jl ..B1.44 +..B1.43: + fldt 12+_TWO_8192@GOTOFF(%edx) + fmul %st, %st(2) + fxch %st(2) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + movzwl 28(%ebp), %esi + movzwl 16(%ebp), %ecx + andl $32767, %esi + andl $32767, %ecx +..B1.44: + fldl _ones@GOTOFF(%edx,%ebx,8) + fld %st(2) + fld %st(2) + fmul %st(2), %st + fxch %st(1) + fmull _ones@GOTOFF(%edx,%edi,8) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B1.68 +..B1.45: + lea 12(%ecx), %eax + cmpl %eax, %esi + jle ..B1.62 +..B1.46: + addl $75, %ecx + cmpl %ecx, %esi + jle ..B1.55 +..B1.47: + fstp %st(1) + fstp %st(0) + fstp %st(0) + testl %edi, %edi + je ..B1.49 +..B1.48: + fstp %st(1) + fstp %st(0) + lea (,%ebx,8), %eax + lea (%eax,%ebx,4), %ecx + fldt _pi_00l@GOTOFF(%ecx,%edx) + fldt _small_value_80@GOTOFF(%ecx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.52 +..B1.49: + fdivp %st, %st(1) + fstpt 64(%esp) + movzwl 72(%esp), %eax + testl $32767, %eax + jne ..B1.51 +..B1.50: + fldt _small_value_80@GOTOFF(%edx) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.52 +..B1.51: + fldt _small_value_80@GOTOFF(%edx) + faddl _ones@GOTOFF(%edx) + fstpt (%esp) +..B1.52: + cmpl $0, 12(%esp) + je ..B1.54 +..B1.53: + fldcw 30(%esp) +..B1.54: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.55: + fstp %st(4) + fstp %st(2) + testl %edi, %edi + je ..B1.59 +..B1.56: + fldt 36+_P@GOTOFF(%edx) + fxch %st(3) + fdivrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(3) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 12+_P@GOTOFF(%edx) + cmpl $0, 12(%esp) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(1) + fldt _P@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + faddp %st, %st(2) + fxch %st(1) + fsubrl 8200+__libm_atanl_table_128@GOTOFF(%edx) + faddl 8192+__libm_atanl_table_128@GOTOFF(%edx) + fmulp %st, %st(1) + fstpt 64(%esp) + je ..B1.58 +..B1.57: + fldcw 30(%esp) +..B1.58: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.59: + fldt 36+_P@GOTOFF(%edx) + fld %st(2) + fdiv %st(4), %st + fld %st(0) + fmul %st(1), %st + fxch %st(3) + fstpl 48(%esp) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(2) + fldt 12+_P@GOTOFF(%edx) + cmpl $0, 12(%esp) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(1) + fld %st(4) + fldt _P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 32(%esp) + fld %st(2) + fld %st(3) + fld %st(3) + fldl _TWO_32H@GOTOFF(%edx) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(5) + fld %st(5) + fadd %st(1), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(3) + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(3) + fsubr %st, %st(4) + fld %st(3) + fxch %st(2) + fdivrl _ones@GOTOFF(%edx) + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fstpt 16(%esp) + fldt 16(%esp) + fsubp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(3) + fxch %st(3) + fmul %st, %st(4) + fld %st(5) + fmul %st(1), %st + fxch %st(2) + fadd %st, %st(6) + fmulp %st, %st(1) + fxch %st(4) + faddl 8+_ones@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + fsubrp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 32(%esp) + faddp %st, %st(2) + faddp %st, %st(1) + fmull 48(%esp) + fstpt 64(%esp) + je ..B1.61 +..B1.60: + fldt 16(%esp) + fstpt 32(%esp) +..B1.123: + fldcw 30(%esp) +..B1.61: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.62: + fstp %st(4) + fstp %st(2) + fldl _TWO_63H@GOTOFF(%edx) + fld %st(2) + fxch %st(2) + fstpl 48(%esp) + fld %st(2) + fld %st(4) + fld %st(5) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(6), %st + fdiv %st(7), %st + fadd %st(4), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubp %st, %st(4) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmulp %st, %st(4) + fldl _TWO_48H@GOTOFF(%edx) + fmul %st, %st(3) + movl 32(%esp), %eax + fxch %st(3) + fadd %st, %st(5) + shll $4, %eax + fsubrp %st, %st(5) + fld %st(4) + testl %edi, %edi + fmul %st(4), %st + fxch %st(5) + fsubr %st, %st(6) + fxch %st(2) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(6) + fld %st(5) + fmul %st(4), %st + fadd %st(7), %st + fxch %st(4) + fmul %st, %st(7) + fxch %st(7) + fsubrp %st, %st(6) + fmul %st, %st(6) + fxch %st(6) + fsubrp %st, %st(1) + fxch %st(5) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fdivrl _ones@GOTOFF(%edx) + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt 16(%esp) + fldt 16(%esp) + fsubp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(4) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(2) + fmul %st, %st(4) + fld %st(0) + fmul %st(6), %st + fxch %st(6) + fadd %st(7), %st + fxch %st(7) + fmulp %st, %st(1) + fxch %st(4) + faddl 8+_ones@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(2) + fsubp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 20(%ebp) + fldt 20(%ebp) + fld %st(1) + fmul %st(3), %st + fld %st(2) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(3) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(3) + fldt _P@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl 48(%esp) + je ..B1.64 +..B1.63: + negl %eax + fld %st(2) + fldl 8192+__libm_atanl_table_128@GOTOFF(%edx,%eax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fldl 8200+__libm_atanl_table_128@GOTOFF(%edx,%eax) + fsubp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B1.65 +..B1.64: + fldl __libm_atanl_table_128@GOTOFF(%eax,%edx) + fld %st(3) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fldl 8+__libm_atanl_table_128@GOTOFF(%eax,%edx) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) +..B1.65: + fstpt 64(%esp) + cmpl $0, 12(%esp) + je ..B1.67 +..B1.66: + fldt 16(%esp) + fstpt 32(%esp) +..B1.124: + fldcw 30(%esp) +..B1.67: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.68: + fstp %st(4) + fstp %st(2) + lea 12(%esi), %eax + cmpl %eax, %ecx + jle ..B1.79 +..B1.69: + addl $75, %esi + cmpl %esi, %ecx + jle ..B1.73 +..B1.70: + fstp %st(1) + fstp %st(1) + fstp %st(0) + cmpl $0, 12(%esp) + lea (,%ebx,8), %eax + lea (%eax,%ebx,4), %ecx + fldt _pi_02l@GOTOFF(%ecx,%edx) + fldt _small_value_80@GOTOFF(%ecx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) + je ..B1.72 +..B1.71: + fldcw 30(%esp) +..B1.72: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.73: + fldt 12+_P@GOTOFF(%edx) + testl %edi, %edi + fxch %st(2) + fdivrp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fld %st(0) + fmul %st(1), %st + fxch %st(4) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 36+_P@GOTOFF(%edx) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(5) + fldt _P@GOTOFF(%edx) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(2) + fldl 4096+__libm_atanl_table_128@GOTOFF(%edx) + fldl 4104+__libm_atanl_table_128@GOTOFF(%edx) + je ..B1.75 +..B1.74: + faddp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B1.76 +..B1.75: + fsubp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) +..B1.76: + fstpt 64(%esp) + cmpl $0, 12(%esp) + je ..B1.78 +..B1.77: + fldcw 30(%esp) +..B1.78: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.79: + fldl _TWO_63H@GOTOFF(%edx) + fld %st(3) + fxch %st(2) + fstpl 48(%esp) + fld %st(2) + fld %st(3) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(6), %st + fdiv %st(5), %st + fadd %st(3), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubp %st, %st(3) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmulp %st, %st(3) + fld %st(5) + fldl _TWO_48H@GOTOFF(%edx) + fmul %st, %st(5) + movl 32(%esp), %eax + fxch %st(1) + fadd %st(5), %st + shll $4, %eax + fsubp %st, %st(5) + testl %edi, %edi + fxch %st(4) + fsubr %st, %st(6) + fld %st(6) + fmul %st(4), %st + fxch %st(3) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(5) + fxch %st(2) + fadd %st(5), %st + fld %st(1) + fmul %st(4), %st + fadd %st(3), %st + fxch %st(4) + fmul %st, %st(6) + fxch %st(6) + fsubrp %st, %st(7) + fxch %st(2) + fmulp %st, %st(5) + fsubp %st, %st(4) + fld %st(1) + fadd %st(1), %st + fdivrl _ones@GOTOFF(%edx) + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fstpt 16(%esp) + fldt 16(%esp) + fsubp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fld %st(3) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + fmul %st(4), %st + fld %st(4) + fmul %st(7), %st + fxch %st(6) + fadd %st, %st(7) + fmulp %st, %st(5) + faddl 8+_ones@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 20(%ebp) + fldt 20(%ebp) + fld %st(1) + fmul %st(3), %st + fld %st(2) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(3) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(3) + fldt _P@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl 48(%esp) + je ..B1.81 +..B1.80: + fldl 4096+__libm_atanl_table_128@GOTOFF(%edx,%eax) + fld %st(3) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fldl 4104+__libm_atanl_table_128@GOTOFF(%edx,%eax) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B1.82 +..B1.81: + negl %eax + fld %st(2) + fldl 4096+__libm_atanl_table_128@GOTOFF(%edx,%eax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fldl 4104+__libm_atanl_table_128@GOTOFF(%edx,%eax) + fsubp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) +..B1.82: + fstpt 64(%esp) + cmpl $0, 12(%esp) + je ..B1.84 +..B1.83: + fldt 16(%esp) + fstpt 32(%esp) +..B1.125: + fldcw 30(%esp) +..B1.84: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.85: + testl %edi, %edi + je ..B1.87 +..B1.86: + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ebx + fldt _pi_00l@GOTOFF(%ebx,%edx) + fldt _small_value_80@GOTOFF(%ebx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.29 +..B1.87: + fldl _zeros@GOTOFF(%edx,%ebx,8) + fstpt 64(%esp) + jmp ..B1.29 +..B1.88: + xorl %eax, %eax + jmp ..B1.15 +..B1.89: + movl $0, 12(%esp) + jmp ..B1.36 +..B1.90: + movzwl 30(%esp), %eax + movl %eax, 12(%esp) + andl $768, %eax + cmpl $768, %eax + je ..B1.120 +..B1.91: + movl 12(%esp), %eax + orl $-64768, %eax + movw %ax, 28(%esp) +..B1.92: + fldcw 28(%esp) +..B1.93: + movl $1, %eax +..B1.94: + cmpl $32767, %ecx + je ..B1.118 +..B1.95: + cmpl $32767, %esi + je ..B1.115 +..B1.96: + testl %ecx, %ecx + jne ..B1.99 +..B1.97: + cmpl $0, 12(%ebp) + jne ..B1.102 +..B1.98: + cmpl $0, 8(%ebp) + jne ..B1.102 +..B1.99: + testl %esi, %esi + jne ..B1.103 +..B1.100: + cmpl $0, 24(%ebp) + jne ..B1.102 +..B1.101: + cmpl $0, 20(%ebp) + je ..B1.104 +..B1.102: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 56(%esp) +..B1.103: + cmpl $32767, %esi + je ..B1.108 +..B1.104: + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ebx + fldt _pi_02l@GOTOFF(%ebx,%edx) + fldt _small_value_80@GOTOFF(%ebx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) +..B1.105: + testl %eax, %eax + je ..B1.107 +..B1.106: + fldcw 30(%esp) +..B1.107: + fldt 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.108: + cmpl $32767, %ecx + je ..B1.112 +..B1.109: + testl %edi, %edi + je ..B1.111 +..B1.110: + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ebx + fldt _pi_00l@GOTOFF(%ebx,%edx) + fldt _small_value_80@GOTOFF(%ebx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.105 +..B1.111: + fldl _zeros@GOTOFF(%edx,%ebx,8) + fstpt 64(%esp) + jmp ..B1.105 +..B1.112: + testl %edi, %edi + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ecx + je ..B1.114 +..B1.113: + fldt _pi_34l@GOTOFF(%ecx,%edx) + fldt _small_value_80@GOTOFF(%ecx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.105 +..B1.114: + fldt _pi_04l@GOTOFF(%ecx,%edx) + fldt _small_value_80@GOTOFF(%ecx,%edx) + fsubrp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.105 +..B1.115: + cmpl $-2147483648, 24(%ebp) + jne ..B1.117 +..B1.116: + cmpl $0, 20(%ebp) + je ..B1.96 +..B1.117: + fldt 20(%ebp) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.105 +..B1.118: + cmpl $-2147483648, 12(%ebp) + jne ..B1.117 +..B1.119: + cmpl $0, 8(%ebp) + jne ..B1.117 + jmp ..B1.95 +..B1.120: + xorl %eax, %eax + jmp ..B1.94 + .align 16,0x90 + .type atan2l,@function + .size atan2l,.-atan2l + .data +# -- End atan2l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 2 +_pi_00l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49152 + .word 0 + .type _pi_00l,@object + .size _pi_00l,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_pi_02l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .type _pi_02l,@object + .size _pi_02l,24 + .align 2 +_TWO_8192: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .type _TWO_8192,@object + .size _TWO_8192,24 + .align 2 +_P: + .word 43664 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 43235 + .word 52379 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 59507 + .word 38278 + .word 9340 + .word 37449 + .word 49148 + .word 0 + .word 9132 + .word 55602 + .word 8665 + .word 58245 + .word 16379 + .word 0 + .type _P,@object + .size _P,48 + .align 2 +_pi_34l: + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 16384 + .word 0 + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 49152 + .word 0 + .type _pi_34l,@object + .size _pi_34l,24 + .align 2 +_pi_04l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16382 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49150 + .word 0 + .type _pi_04l,@object + .size _pi_04l,24 + .data + .hidden __libm_atanl_table_128 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atan_wmt.S b/external/sgx_libm/ia32/atan_wmt.S new file mode 100644 index 0000000000..8d01ca578e --- /dev/null +++ b/external/sgx_libm/ia32/atan_wmt.S @@ -0,0 +1,922 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin atan + .text + .align 16,0x90 + .globl atan +atan: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd 2640(%ebx), %xmm3 + movsd 2624(%ebx), %xmm5 + movsd 2656(%ebx), %xmm4 + movsd %xmm0, 8(%esp) + pextrw $3, %xmm0, %edx + andpd %xmm0, %xmm3 + pshufd $68, %xmm0, %xmm1 + orpd %xmm4, %xmm3 + movl %edx, %eax + andl $32767, %edx + subl $16288, %edx + cmpl $159, %edx + ja .L_2TAG_PACKET_0.0.2 + mulsd %xmm3, %xmm1 + subsd %xmm3, %xmm0 + addsd %xmm5, %xmm1 + divsd %xmm1, %xmm0 + addl $1, %edx + movsd 2672(%ebx), %xmm2 + movsd 2688(%ebx), %xmm4 + andl $32768, %eax + xorpd %xmm7, %xmm7 + pinsrw $3, %eax, %xmm7 + addl %edx, %edx + movsd (%ebx,%edx,8), %xmm6 + movsd 8(%ebx,%edx,8), %xmm5 + xorpd %xmm7, %xmm5 + xorpd %xmm7, %xmm6 + movsd 2680(%ebx), %xmm7 + pshufd $68, %xmm0, %xmm1 + mulsd %xmm0, %xmm0 + pshufd $68, %xmm1, %xmm3 + addsd %xmm6, %xmm1 + mulsd %xmm0, %xmm2 + addsd %xmm0, %xmm4 + subsd %xmm1, %xmm6 + mulsd %xmm0, %xmm4 + addsd %xmm7, %xmm2 + mulsd %xmm3, %xmm0 + addsd %xmm3, %xmm6 + mulsd %xmm2, %xmm0 + addsd 2696(%ebx), %xmm4 + addsd %xmm5, %xmm6 + mulsd %xmm4, %xmm0 + addsd %xmm6, %xmm0 + addsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_0.0.2: + addl $944, %edx + cmpl $1103, %edx + ja .L_2TAG_PACKET_2.0.2 + movsd 2672(%ebx), %xmm4 + movsd 2688(%ebx), %xmm7 + movsd 8(%esp), %xmm0 + mulsd %xmm1, %xmm1 + movsd 2680(%ebx), %xmm2 + movsd 2696(%ebx), %xmm5 + mulsd %xmm1, %xmm4 + addsd %xmm1, %xmm7 + movapd %xmm1, %xmm6 + mulsd %xmm0, %xmm1 + addsd %xmm4, %xmm2 + mulsd %xmm6, %xmm7 + mulsd %xmm1, %xmm2 + addsd %xmm5, %xmm7 + mulsd %xmm7, %xmm2 + addsd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + addl $15344, %edx + cmpl $16368, %edx + ja .L_2TAG_PACKET_3.0.2 + movsd 8(%esp), %xmm0 + movsd 8(%esp), %xmm1 + cmpl $16, %edx + jae .L_2TAG_PACKET_4.0.2 + mulsd %xmm0, %xmm1 +.L_2TAG_PACKET_4.0.2: + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_3.0.2: + cmpl $17392, %edx + jae .L_2TAG_PACKET_5.0.2 + xorpd %xmm1, %xmm1 + movl $49136, %ecx + pinsrw $3, %ecx, %xmm1 + divsd %xmm0, %xmm1 + movsd 2672(%ebx), %xmm2 + movsd 2688(%ebx), %xmm4 + andl $32768, %eax + xorpd %xmm7, %xmm7 + pinsrw $3, %eax, %xmm7 + addl %edx, %edx + movsd 2592(%ebx), %xmm6 + movsd 2600(%ebx), %xmm5 + xorpd %xmm7, %xmm5 + xorpd %xmm7, %xmm6 + movsd 2680(%ebx), %xmm7 + pshufd $68, %xmm1, %xmm0 + mulsd %xmm1, %xmm1 + pshufd $68, %xmm0, %xmm3 + addsd %xmm6, %xmm0 + mulsd %xmm1, %xmm2 + addsd %xmm1, %xmm4 + subsd %xmm0, %xmm6 + mulsd %xmm1, %xmm4 + addsd %xmm7, %xmm2 + mulsd %xmm3, %xmm1 + addsd %xmm3, %xmm6 + mulsd %xmm2, %xmm1 + addsd 2696(%ebx), %xmm4 + addsd %xmm5, %xmm6 + mulsd %xmm4, %xmm1 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_5.0.2: + movsd 8(%esp), %xmm4 + movsd 2608(%ebx), %xmm0 + movsd 2592(%ebx), %xmm2 + movsd 2600(%ebx), %xmm3 + movd %xmm1, %eax + psrlq $32, %xmm1 + movd %xmm1, %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + jae .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_7.0.2: + andnpd %xmm4, %xmm0 + orpd %xmm0, %xmm2 + orpd %xmm3, %xmm0 + addsd %xmm2, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_6.0.2: + subl $2146435072, %edx + orl %edx, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_7.0.2 + movapd %xmm4, %xmm0 + addsd %xmm0, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) +.L_2TAG_PACKET_1.0.2: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type atan,@function + .size atan,.-atan + .data +# -- End atan + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 3819695742 + .long 1067482761 + .long 2398680355 + .long 3155462074 + .long 2998791009 + .long 1067548225 + .long 3868465248 + .long 3157182472 + .long 3339424991 + .long 1067613680 + .long 3296670360 + .long 1010752543 + .long 2710002256 + .long 1067679126 + .long 3403896007 + .long 1010910768 + .long 3275701428 + .long 1067744562 + .long 119959933 + .long 1011482843 + .long 2908636881 + .long 1067809988 + .long 2464489612 + .long 1011545526 + .long 3777889398 + .long 1067875403 + .long 3262682165 + .long 1009703919 + .long 3759667419 + .long 1067940807 + .long 1838130851 + .long 3157373556 + .long 732369940 + .long 1068006200 + .long 1203428313 + .long 1010055371 + .long 1166616461 + .long 1068071580 + .long 2901274051 + .long 3158549977 + .long 2945472892 + .long 1068136947 + .long 3726120658 + .long 1009762715 + .long 3954480976 + .long 1068202301 + .long 1289173457 + .long 1009429861 + .long 2081752829 + .long 1068267642 + .long 1836909874 + .long 1006212095 + .long 3807999788 + .long 1068332968 + .long 2172459940 + .long 3156162078 + .long 2731789884 + .long 1068398280 + .long 3450718392 + .long 3159216547 + .long 1044477961 + .long 1068463577 + .long 2230553229 + .long 1011424339 + .long 1486930287 + .long 1068530218 + .long 2861547474 + .long 1012041376 + .long 2293016881 + .long 1068595466 + .long 136843272 + .long 1012684797 + .long 201518157 + .long 1068660680 + .long 63231984 + .long 1012427198 + .long 4054234584 + .long 1068725856 + .long 3927006960 + .long 1011878955 + .long 1246477213 + .long 1068790995 + .long 1494265652 + .long 3155219350 + .long 678186699 + .long 1068856093 + .long 1264361424 + .long 3159256693 + .long 2690594995 + .long 1068921148 + .long 3906996379 + .long 1009288267 + .long 3362611517 + .long 1068986159 + .long 1650970041 + .long 3158331771 + .long 3102162111 + .long 1069051124 + .long 365917035 + .long 3160264153 + .long 2352611067 + .long 1069116041 + .long 4008970190 + .long 3159478182 + .long 1594134794 + .long 1069180908 + .long 466690178 + .long 1012526501 + .long 1345079306 + .long 1069245723 + .long 2268273568 + .long 3160164092 + .long 2163300970 + .long 1069310484 + .long 2750834800 + .long 3158113482 + .long 352522716 + .long 1069375190 + .long 1750411372 + .long 1011790845 + .long 848541647 + .long 1069439838 + .long 2164207573 + .long 1011698350 + .long 40647312 + .long 1069504427 + .long 2949165434 + .long 3159107267 + .long 2216766270 + .long 1069574357 + .long 2197920765 + .long 3161055954 + .long 1090914384 + .long 1069638757 + .long 2330454674 + .long 1013365998 + .long 387601244 + .long 1069703022 + .long 3185681168 + .long 1013434071 + .long 3991640484 + .long 1069767144 + .long 1313211590 + .long 3161087959 + .long 3322489502 + .long 1069831118 + .long 3013977995 + .long 1013053011 + .long 3121698570 + .long 1069894936 + .long 4069015667 + .long 1013023362 + .long 4289964660 + .long 1069958591 + .long 1736191156 + .long 3158266731 + .long 3903312386 + .long 1070022077 + .long 1833592413 + .long 3159731471 + .long 3818449864 + .long 1070085387 + .long 851036429 + .long 3159730451 + .long 2097480306 + .long 1070148515 + .long 3506390884 + .long 3160462302 + .long 1611694502 + .long 1070211454 + .long 2785735540 + .long 3160465144 + .long 1464694796 + .long 1070274198 + .long 4229277299 + .long 3159907000 + .long 1299612775 + .long 1070336741 + .long 4116653788 + .long 3160427739 + .long 1310544789 + .long 1070399077 + .long 1064430331 + .long 1013218202 + .long 2253168030 + .long 1070461200 + .long 1405044609 + .long 3157623179 + .long 1159567373 + .long 1070523105 + .long 2353445521 + .long 3159992176 + .long 1359373750 + .long 1070605818 + .long 1748171336 + .long 3161879263 + .long 908341706 + .long 1070667034 + .long 3372710815 + .long 3161775245 + .long 1743027350 + .long 1070727765 + .long 687089934 + .long 3160507171 + .long 2055355646 + .long 1070787992 + .long 2392855242 + .long 1013682469 + .long 690426164 + .long 1070847697 + .long 1103926666 + .long 1014052810 + .long 1483247847 + .long 1070906862 + .long 2082645847 + .long 3161345479 + .long 392040270 + .long 1070965472 + .long 2407720023 + .long 1014053754 + .long 2673846014 + .long 1071023511 + .long 1293605532 + .long 3158464385 + .long 1384215810 + .long 1071080967 + .long 2446095872 + .long 3159216407 + .long 3101660631 + .long 1071137826 + .long 698040758 + .long 1014855328 + .long 2094057058 + .long 1071194078 + .long 2282048339 + .long 1014040385 + .long 1712750594 + .long 1071249712 + .long 1204372378 + .long 3162276464 + .long 1411515787 + .long 1071304719 + .long 949080808 + .long 1015006403 + .long 931538085 + .long 1071359091 + .long 3027127039 + .long 1014307233 + .long 179139065 + .long 1071412821 + .long 4285547492 + .long 3161934731 + .long 3387721259 + .long 1071465902 + .long 373225773 + .long 1013486625 + .long 2132236852 + .long 1071544299 + .long 3250533429 + .long 1014031677 + .long 1942070284 + .long 1071645596 + .long 1237964179 + .long 3163239113 + .long 1532707802 + .long 1071695380 + .long 330645583 + .long 1012495610 + .long 2294184979 + .long 1071743834 + .long 3959472897 + .long 1015833116 + .long 3805060714 + .long 1071790961 + .long 2671256142 + .long 1013727772 + .long 2215037898 + .long 1071836770 + .long 2683359117 + .long 1015831902 + .long 483661594 + .long 1071881273 + .long 836288326 + .long 3162648643 + .long 1534679894 + .long 1071924486 + .long 373258696 + .long 3162470096 + .long 1538714628 + .long 1071966430 + .long 3199433068 + .long 1015325501 + .long 527642555 + .long 1072007128 + .long 3636832592 + .long 3161843145 + .long 291339150 + .long 1072046605 + .long 890169537 + .long 3160586117 + .long 2450210201 + .long 1072084888 + .long 1636353294 + .long 3163193400 + .long 2411367951 + .long 1072122007 + .long 374899873 + .long 1011331750 + .long 681549971 + .long 1072157992 + .long 506411689 + .long 1015373954 + .long 1466745541 + .long 1072192873 + .long 2143860931 + .long 1013364334 + .long 2845622366 + .long 1072226682 + .long 2869178209 + .long 3162423682 + .long 2838871438 + .long 1072275456 + .long 3742223599 + .long 1014338577 + .long 4200275274 + .long 1072337034 + .long 1566539915 + .long 3161839550 + .long 3034733530 + .long 1072394897 + .long 652621408 + .long 3162261964 + .long 3207412993 + .long 1072449290 + .long 3206124665 + .long 1014408733 + .long 624461478 + .long 1072500450 + .long 932437485 + .long 1015204343 + .long 767665908 + .long 1072548600 + .long 1037911952 + .long 3163527627 + .long 1110773639 + .long 1072593952 + .long 2371517912 + .long 3160465741 + .long 1940828530 + .long 1072636704 + .long 2731408428 + .long 3162895795 + .long 1911329388 + .long 1072677041 + .long 1773089615 + .long 3159569267 + .long 1764715788 + .long 1072704191 + .long 691346949 + .long 3164069946 + .long 3332979233 + .long 1072722195 + .long 3550733983 + .long 1014770628 + .long 1321870254 + .long 1072739231 + .long 1415315820 + .long 1016224052 + .long 3657429030 + .long 1072755365 + .long 3910539033 + .long 1015966402 + .long 4197624557 + .long 1072770661 + .long 2333399254 + .long 3164546480 + .long 1512059493 + .long 1072785177 + .long 2701510318 + .long 1016178092 + .long 453379037 + .long 1072798965 + .long 4046344253 + .long 3162814364 + .long 1942345162 + .long 1072818388 + .long 621134147 + .long 1016335195 + .long 4210176273 + .long 1072842164 + .long 2701013387 + .long 3164326619 + .long 4185644010 + .long 1072863795 + .long 4163699341 + .long 1016203112 + .long 679688788 + .long 1072883543 + .long 4147276762 + .long 1014066750 + .long 29432865 + .long 1072901630 + .long 970415797 + .long 1016902063 + .long 4070721092 + .long 1072918247 + .long 2539004411 + .long 3163736096 + .long 2252468843 + .long 1072933561 + .long 3424082887 + .long 3163407177 + .long 2929724825 + .long 1072947712 + .long 3661482235 + .long 3163846989 + .long 1377513368 + .long 1072960824 + .long 3987926680 + .long 1013647908 + .long 1031632908 + .long 1072973003 + .long 3672217151 + .long 1016614619 + .long 2516508130 + .long 1072984342 + .long 545855020 + .long 3162728930 + .long 3792452178 + .long 1072994923 + .long 3420119467 + .long 1016471430 + .long 3147791459 + .long 1073004818 + .long 1342204979 + .long 1013937254 + .long 999189752 + .long 1073014090 + .long 1006335472 + .long 3162850919 + .long 711011011 + .long 1073022794 + .long 4633488 + .long 3162966895 + .long 15640363 + .long 1073030980 + .long 1686389560 + .long 3164376226 + .long 1218463589 + .long 1073042382 + .long 1526837110 + .long 3163533985 + .long 2538470555 + .long 1073056144 + .long 2273304406 + .long 3163784996 + .long 1229720947 + .long 1073068489 + .long 2971628206 + .long 3162356540 + .long 3115427016 + .long 1073079621 + .long 4215132957 + .long 3164282762 + .long 4030612557 + .long 1073089709 + .long 1913251691 + .long 3163671292 + .long 2728521257 + .long 1073098892 + .long 2861089500 + .long 1015454459 + .long 1118696283 + .long 1073107285 + .long 1628948053 + .long 1016179658 + .long 2682711255 + .long 1073114984 + .long 2906306266 + .long 1014142643 + .long 2073898081 + .long 1073122072 + .long 1322740454 + .long 3164497217 + .long 1403700297 + .long 1073128618 + .long 416137895 + .long 3162781466 + .long 2502685617 + .long 1073134681 + .long 3242008732 + .long 1014593495 + .long 1531926851 + .long 1073140313 + .long 1362708094 + .long 1016517604 + .long 3572814411 + .long 1073145557 + .long 3709790527 + .long 1012646874 + .long 1695536111 + .long 1073150453 + .long 3980346340 + .long 1016705136 + .long 2363057203 + .long 1073155033 + .long 2551194792 + .long 1012569695 + .long 2873365682 + .long 1073159327 + .long 3181154748 + .long 1017041450 + .long 1053384691 + .long 1073165288 + .long 3074536879 + .long 1016965660 + .long 3270542712 + .long 1073172451 + .long 2535319415 + .long 3163051778 + .long 1353631484 + .long 1073178850 + .long 1173833755 + .long 1015534537 + .long 3511218460 + .long 1073184599 + .long 1243608109 + .long 3161592122 + .long 4121259284 + .long 1073189793 + .long 398584912 + .long 3163829923 + .long 1193862106 + .long 1073194509 + .long 1873745539 + .long 3163802819 + .long 3861949790 + .long 1073198808 + .long 3841261147 + .long 1015587248 + .long 1486904578 + .long 1073202745 + .long 1634726776 + .long 3163847886 + .long 2879153715 + .long 1073206362 + .long 200456242 + .long 3164138657 + .long 385353253 + .long 1073209698 + .long 1186355517 + .long 1014887155 + .long 1125865839 + .long 1073212783 + .long 203561262 + .long 3161244927 + .long 1221361475 + .long 1073215645 + .long 3382476563 + .long 1014936138 + .long 2077323573 + .long 1073218307 + .long 1005121005 + .long 3164430752 + .long 215611373 + .long 1073220790 + .long 353198764 + .long 3164485137 + .long 2347419265 + .long 1073223110 + .long 1103143360 + .long 1016542137 + .long 1379112765 + .long 1073225284 + .long 381583533 + .long 3162870833 + .long 3891198463 + .long 1073228298 + .long 1771275754 + .long 1014654681 + .long 3395914051 + .long 1073231917 + .long 2350900914 + .long 3164013978 + .long 2799919478 + .long 1073235146 + .long 2893950164 + .long 3163260901 + .long 1138673476 + .long 1073238045 + .long 2622204785 + .long 3164174388 + .long 3408855940 + .long 1073240661 + .long 2800881650 + .long 1016008624 + .long 2044858738 + .long 1073243035 + .long 604544785 + .long 1017022901 + .long 2578795176 + .long 1073245198 + .long 2557332925 + .long 1016135165 + .long 4196285314 + .long 1073247177 + .long 2032365307 + .long 1016194735 + .long 224877747 + .long 1073248996 + .long 497926916 + .long 1016947111 + .long 3271386490 + .long 1073250671 + .long 2689994846 + .long 1016631513 + .long 813635989 + .long 1073252221 + .long 747035277 + .long 3164530136 + .long 369829519 + .long 1073253658 + .long 2182033858 + .long 3163190340 + .long 1187679052 + .long 1073254994 + .long 673954443 + .long 1016149821 + .long 4232586098 + .long 1073256239 + .long 497775200 + .long 3162179015 + .long 426690558 + .long 1073257404 + .long 3063343247 + .long 1016865578 + .long 1624065902 + .long 1073258494 + .long 1354224996 + .long 3163503778 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 4294901760 + .long 0 + .long 0 + .long 0 + .long 32768 + .long 0 + .long 0 + .long 2006262985 + .long 1069310863 + .long 2358449471 + .long 3217342131 + .long 3845454352 + .long 1069952297 + .long 2829679149 + .long 1073771565 + .type static_const_table,@object + .size static_const_table,2704 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atandl_table.S b/external/sgx_libm/ia32/atandl_table.S new file mode 100644 index 0000000000..d80f401005 --- /dev/null +++ b/external/sgx_libm/ia32/atandl_table.S @@ -0,0 +1,2100 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atandl_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_atandl_table_128 + .globl __libm_atandl_table_128 +__libm_atandl_table_128: + .long 0 + .long 0 + .long 0 + .long 0 + .long 3896508416 + .long 1071424949 + .long 2497855885 + .long 1035107781 + .long 1447034880 + .long 1072473411 + .long 1733066939 + .long 3185173141 + .long 1421869056 + .long 1073052515 + .long 1368774744 + .long 1038726731 + .long 1314914304 + .long 1073521529 + .long 3636885973 + .long 3186244272 + .long 1199570944 + .long 1073866069 + .long 2275810035 + .long 3185989885 + .long 476053504 + .long 1074100319 + .long 3721769433 + .long 3184582046 + .long 3514826752 + .long 1074334397 + .long 1919096566 + .long 3184722268 + .long 845152256 + .long 1074568277 + .long 2005889037 + .long 1036405998 + .long 2545942528 + .long 1074796164 + .long 4215566178 + .long 1040782263 + .long 4057989120 + .long 1074912862 + .long 2215314489 + .long 1040552811 + .long 3430940672 + .long 1075029419 + .long 314220031 + .long 3187779646 + .long 1717567488 + .long 1075145821 + .long 2152308088 + .long 1040271717 + .long 455081984 + .long 1075262054 + .long 1186928436 + .long 1040902706 + .long 1694498816 + .long 1075378104 + .long 4227739998 + .long 1040491905 + .long 3747610624 + .long 1075493958 + .long 535382953 + .long 1040666985 + .long 1226833920 + .long 1075609604 + .long 1790336138 + .long 1040185867 + .long 2260729856 + .long 1075725027 + .long 3899937368 + .long 3188375434 + .long 3525312512 + .long 1075839595 + .long 4053544535 + .long 3185741100 + .long 3957325824 + .long 1075897065 + .long 4030890856 + .long 1040553080 + .long 3248488448 + .long 1075954405 + .long 1333464106 + .long 3189137055 + .long 452984832 + .long 1076011609 + .long 3448918206 + .long 3189528508 + .long 3615490048 + .long 1076068669 + .long 608092114 + .long 1041523725 + .long 4020240384 + .long 1076125581 + .long 1336102440 + .long 3188870826 + .long 1960837120 + .long 1076182339 + .long 2391933274 + .long 3189275321 + .long 2470445056 + .long 1076238936 + .long 4283795024 + .long 1041937846 + .long 2451570688 + .long 1076295367 + .long 4217000778 + .long 1039765656 + .long 3560964096 + .long 1076351626 + .long 3936906987 + .long 3182578922 + .long 3640655872 + .long 1076407708 + .long 1439536878 + .long 1040659594 + .long 1023410176 + .long 1076463608 + .long 2552585681 + .long 3189615238 + .long 3122659328 + .long 1076519319 + .long 31715936 + .long 1042073699 + .long 689963008 + .long 1076574838 + .long 3139108801 + .long 1040611849 + .long 2164260864 + .long 1076630158 + .long 1139819401 + .long 3187965768 + .long 3623878656 + .long 1076685275 + .long 3513262155 + .long 1039670426 + .long 1679818752 + .long 1076740185 + .long 728891110 + .long 1041952788 + .long 2069889024 + .long 1076794882 + .long 3614319306 + .long 1039599785 + .long 2480930816 + .long 1076849362 + .long 1879438446 + .long 3188546042 + .long 2720006144 + .long 1076895586 + .long 4246516390 + .long 1042916956 + .long 574619648 + .long 1076922603 + .long 3568262924 + .long 1040145602 + .long 3061841920 + .long 1076949504 + .long 290418758 + .long 3187677511 + .long 1539309568 + .long 1076976289 + .long 635731916 + .long 1042641148 + .long 532676608 + .long 1077002955 + .long 4225033962 + .long 3189573420 + .long 545259520 + .long 1077029500 + .long 2007583995 + .long 1042491810 + .long 2369781760 + .long 1077055922 + .long 2061076001 + .long 3190167169 + .long 2774532096 + .long 1077082220 + .long 2608380742 + .long 1042446121 + .long 3112173568 + .long 1077108392 + .long 2901961231 + .long 1042075808 + .long 715128832 + .long 1077134437 + .long 3828632392 + .long 3189418038 + .long 1782579200 + .long 1077160352 + .long 519110621 + .long 1041924126 + .long 4206886912 + .long 1077186136 + .long 2078221814 + .long 1039357043 + .long 1858076672 + .long 1077211789 + .long 2404314454 + .long 3190701797 + .long 1763704832 + .long 1077237308 + .long 1129624783 + .long 3189333294 + .long 2638217216 + .long 1077262692 + .long 1872508293 + .long 3187027668 + .long 3464495104 + .long 1077287940 + .long 2518581518 + .long 1039154339 + .long 3493855232 + .long 1077313051 + .long 2874645533 + .long 3188678970 + .long 2241855488 + .long 1077338024 + .long 182480744 + .long 3187988055 + .long 3783262208 + .long 1077362857 + .long 41710967 + .long 3189176765 + .long 3860856832 + .long 1077387550 + .long 3921914980 + .long 1040188295 + .long 2770337792 + .long 1077412102 + .long 2195237132 + .long 1043018421 + .long 1061158912 + .long 1077436512 + .long 1866130671 + .long 1042885968 + .long 3825205248 + .long 1077460778 + .long 2099274145 + .long 1043277518 + .long 3519021056 + .long 1077484901 + .long 2434136291 + .long 3190760305 + .long 1423966208 + .long 1077508880 + .long 786043090 + .long 3189674834 + .long 3361734656 + .long 1077532713 + .long 1735814367 + .long 1041228653 + .long 2501902336 + .long 1077556401 + .long 2532076405 + .long 1041674477 + .long 832569344 + .long 1077579943 + .long 1067893357 + .long 1041790735 + .long 568328192 + .long 1077603338 + .long 42353869 + .long 1040967961 + .long 4143972352 + .long 1077626585 + .long 3035382168 + .long 1043228732 + .long 1329594368 + .long 1077649686 + .long 2622169537 + .long 1042608561 + .long 3579838464 + .long 1077672638 + .long 3279279360 + .long 1039969098 + .long 1082130432 + .long 1077695443 + .long 152088799 + .long 1042154031 + .long 1409286144 + .long 1077718099 + .long 1577179566 + .long 1043010748 + .long 3743416320 + .long 1077740606 + .long 164745699 + .long 3187116092 + .long 3162505216 + .long 1077762965 + .long 3525309094 + .long 3189988831 + .long 3525312512 + .long 1077785175 + .long 790013831 + .long 3189219565 + .long 287309824 + .long 1077807237 + .long 3014793090 + .long 3190791112 + .long 1965031424 + .long 1077829149 + .long 2967000185 + .long 3189805146 + .long 73400320 + .long 1077850913 + .long 923692587 + .long 1033248306 + .long 3477078016 + .long 1077872527 + .long 797568562 + .long 1037083943 + .long 4024434688 + .long 1077893993 + .long 1829946853 + .long 1043203029 + .long 2319450112 + .long 1077915311 + .long 1559006781 + .long 3189221910 + .long 1704984576 + .long 1077936304 + .long 2364400925 + .long 3186972503 + .long 4104126464 + .long 1077946814 + .long 2278278095 + .long 3191749589 + .long 2438987776 + .long 1077957251 + .long 3465285131 + .long 1042435970 + .long 1606418432 + .long 1077967614 + .long 1692530062 + .long 1043648146 + .long 2273312768 + .long 1077977903 + .long 4155795398 + .long 1043918312 + .long 878706688 + .long 1077988119 + .long 1476207680 + .long 1043900034 + .long 2516582400 + .long 1077998261 + .long 2925970384 + .long 1039575776 + .long 3751804928 + .long 1078008330 + .long 2856171667 + .long 3191395954 + .long 1207959552 + .long 1078018327 + .long 2148760563 + .long 1039453383 + .long 161480704 + .long 1078028251 + .long 3632513556 + .long 3191302868 + .long 1642070016 + .long 1078038102 + .long 3240138768 + .long 1043718443 + .long 2447376384 + .long 1078047881 + .long 3100705142 + .long 3191740341 + .long 3709861888 + .long 1078057588 + .long 1674862667 + .long 1041748151 + .long 2325741568 + .long 1078067224 + .long 4255018693 + .long 1044226144 + .long 3827302400 + .long 1078076788 + .long 4142119676 + .long 3191232448 + .long 899678208 + .long 1078086282 + .long 700553623 + .long 1043581423 + .long 3462397952 + .long 1078095704 + .long 1067893357 + .long 3190322959 + .long 4286578688 + .long 1078105056 + .long 3385731218 + .long 1043691060 + .long 486539264 + .long 1078114339 + .long 2289432889 + .long 1035999008 + .long 2092957696 + .long 1078123551 + .long 653388941 + .long 3186809946 + .long 1996488704 + .long 1078132694 + .long 3139143286 + .long 3191209215 + .long 1709178880 + .long 1078141768 + .long 643854101 + .long 3190510369 + .long 2778726400 + .long 1078150773 + .long 2948057503 + .long 3191040876 + .long 2485125120 + .long 1078159710 + .long 172509481 + .long 1044304413 + .long 2438987776 + .long 1078168579 + .long 1352848207 + .long 1043175137 + .long 4271898624 + .long 1078177380 + .long 2864918449 + .long 1043427968 + .long 1054867456 + .long 1078186115 + .long 1735520057 + .long 1044098886 + .long 3063939072 + .long 1078194782 + .long 2894826982 + .long 1043616305 + .long 3418357760 + .long 1078203383 + .long 442938097 + .long 3191392387 + .long 3844079616 + .long 1078211918 + .long 4004776912 + .long 1043962348 + .long 1801453568 + .long 1078220388 + .long 2102624066 + .long 1044353828 + .long 3355443200 + .long 1078228792 + .long 1225643377 + .long 3190452555 + .long 1700790272 + .long 1078237132 + .long 2531804346 + .long 3191195152 + .long 2936012800 + .long 1078245407 + .long 928991542 + .long 1043548181 + .long 293601280 + .long 1078253619 + .long 3229203938 + .long 1042779359 + .long 4194304000 + .long 1078261766 + .long 1071139240 + .long 1044201053 + .long 3600809984 + .long 1078269851 + .long 3018208080 + .long 1043941200 + .long 371195904 + .long 1078277874 + .long 2039162957 + .long 3189903110 + .long 666894336 + .long 1078285834 + .long 1431034507 + .long 3190628953 + .long 2071986176 + .long 1078293732 + .long 3412027605 + .long 3191381190 + .long 2176843776 + .long 1078301569 + .long 183216755 + .long 3188772215 + .long 2877292544 + .long 1078309345 + .long 3207515339 + .long 3189828782 + .long 1778384896 + .long 1078317061 + .long 847503884 + .long 3191075565 + .long 784334848 + .long 1078324717 + .long 2952309205 + .long 1043794080 + .long 1809842176 + .long 1078332313 + .long 467544888 + .long 1042040199 + .long 2472542208 + .long 1078339850 + .long 3311174937 + .long 1039371295 + .long 396361728 + .long 1078347329 + .long 676857836 + .long 3191368341 + .long 1795162112 + .long 1078354749 + .long 2052116880 + .long 3191818486 + .long 0 + .long 1078362112 + .long 0 + .long 0 + .long 2499805184 + .long 1078369474 + .long 2052116880 + .long 1044334838 + .long 3898605568 + .long 1078376894 + .long 676857836 + .long 1043884693 + .long 1822425088 + .long 1078384373 + .long 3311174937 + .long 3186854943 + .long 2485125120 + .long 1078391910 + .long 467544888 + .long 3189523847 + .long 3510632448 + .long 1078399506 + .long 2952309205 + .long 3191277728 + .long 2516582400 + .long 1078407162 + .long 847503884 + .long 1043591917 + .long 1417674752 + .long 1078414878 + .long 3207515339 + .long 1042345134 + .long 2118123520 + .long 1078422654 + .long 183216755 + .long 1041288567 + .long 2222981120 + .long 1078430491 + .long 3412027605 + .long 1043897542 + .long 3628072960 + .long 1078438389 + .long 1431034507 + .long 1043145305 + .long 3923771392 + .long 1078446349 + .long 2039162957 + .long 1042419462 + .long 694157312 + .long 1078454372 + .long 3018208080 + .long 3191424848 + .long 100663296 + .long 1078462457 + .long 1071139240 + .long 3191684701 + .long 4001366016 + .long 1078470604 + .long 3229203938 + .long 3190263007 + .long 1358954496 + .long 1078478816 + .long 928991542 + .long 3191031829 + .long 2594177024 + .long 1078487091 + .long 2531804346 + .long 1043711504 + .long 939524096 + .long 1078495431 + .long 1225643377 + .long 1042968907 + .long 2493513728 + .long 1078503835 + .long 2102624066 + .long 3191837476 + .long 450887680 + .long 1078512305 + .long 4004776912 + .long 3191445996 + .long 876609536 + .long 1078520840 + .long 442938097 + .long 1043908739 + .long 1231028224 + .long 1078529441 + .long 2894826982 + .long 3191099953 + .long 3240099840 + .long 1078538108 + .long 1735520057 + .long 3191582534 + .long 23068672 + .long 1078546843 + .long 2864918449 + .long 3190911616 + .long 1855979520 + .long 1078555644 + .long 1352848207 + .long 3190658785 + .long 1809842176 + .long 1078564513 + .long 172509481 + .long 3191788061 + .long 1516240896 + .long 1078573450 + .long 2948057503 + .long 1043557228 + .long 2585788416 + .long 1078582455 + .long 643854101 + .long 1043026721 + .long 2298478592 + .long 1078591529 + .long 3139143286 + .long 1043725567 + .long 2202009600 + .long 1078600672 + .long 653388941 + .long 1039326298 + .long 3808428032 + .long 1078609884 + .long 2289432889 + .long 3183482656 + .long 8388608 + .long 1078619167 + .long 3385731218 + .long 3191174708 + .long 832569344 + .long 1078628519 + .long 1067893357 + .long 1042839311 + .long 3395289088 + .long 1078637941 + .long 700553623 + .long 3191065071 + .long 467664896 + .long 1078647435 + .long 4142119676 + .long 1043748800 + .long 1969225728 + .long 1078656999 + .long 4255018693 + .long 3191709792 + .long 585105408 + .long 1078666635 + .long 1674862667 + .long 3189231799 + .long 1847590912 + .long 1078676342 + .long 3100705142 + .long 1044256693 + .long 2652897280 + .long 1078686121 + .long 3240138768 + .long 3191202091 + .long 4133486592 + .long 1078695972 + .long 3632513556 + .long 1043819220 + .long 3087007744 + .long 1078705896 + .long 2148760563 + .long 3186937031 + .long 543162368 + .long 1078715893 + .long 2856171667 + .long 1043912306 + .long 1778384896 + .long 1078725962 + .long 2925970384 + .long 3187059424 + .long 3416260608 + .long 1078736104 + .long 1476207680 + .long 3191383682 + .long 2021654528 + .long 1078746320 + .long 4155795398 + .long 3191401960 + .long 2688548864 + .long 1078756609 + .long 1692530062 + .long 3191131794 + .long 1855979520 + .long 1078766972 + .long 3465285131 + .long 3189919618 + .long 190840832 + .long 1078777409 + .long 2278278095 + .long 1044265941 + .long 2589982720 + .long 1078787919 + .long 2364400925 + .long 1039488855 + .long 987758592 + .long 1078798504 + .long 1559006781 + .long 1041738262 + .long 134217728 + .long 1078809163 + .long 1232510221 + .long 1043398165 + .long 408944640 + .long 1078819896 + .long 797568562 + .long 3184567591 + .long 2109734912 + .long 1078830703 + .long 1936866404 + .long 1044380280 + .long 1166016512 + .long 1078841585 + .long 2811467203 + .long 3191322578 + .long 2004877312 + .long 1078852541 + .long 2787570751 + .long 3190829595 + .long 385875968 + .long 1078863572 + .long 3023722014 + .long 3191478212 + .long 566231040 + .long 1078874677 + .long 3525309094 + .long 1042505183 + .long 2424307712 + .long 1078885856 + .long 1063445218 + .long 3191768956 + .long 1442840576 + .long 1078897110 + .long 1577179566 + .long 3190494396 + .long 1606418432 + .long 1078908438 + .long 152088799 + .long 3189637679 + .long 2503999488 + .long 1078919840 + .long 1405657776 + .long 1044264267 + .long 3630170112 + .long 1078931316 + .long 2622169537 + .long 3190092209 + .long 75497472 + .long 1078942867 + .long 3035382168 + .long 3190712380 + .long 4009754624 + .long 1078954490 + .long 3752802150 + .long 1044153052 + .long 1730150400 + .long 1078966188 + .long 806768485 + .long 1043980860 + .long 895483904 + .long 1078977959 + .long 2588206371 + .long 1044009924 + .long 2380267520 + .long 1078987253 + .long 1393635940 + .long 1044120466 + .long 3938451456 + .long 1078993211 + .long 1171997210 + .long 1044632170 + .long 2342518784 + .long 1078999206 + .long 2612691399 + .long 3192403747 + .long 1191182336 + .long 1079005237 + .long 2099274145 + .long 3190761166 + .long 4028628992 + .long 1079011303 + .long 3828434628 + .long 1045017771 + .long 1455423488 + .long 1079017406 + .long 1622551107 + .long 3192310957 + .long 1182793728 + .long 1079023544 + .long 2124167878 + .long 3191930936 + .long 2275409920 + .long 1079029717 + .long 41710967 + .long 1041693117 + .long 3735027712 + .long 1079035925 + .long 514060819 + .long 3191694645 + .long 201326592 + .long 1079042169 + .long 1430947390 + .long 3192785388 + .long 3428843520 + .long 1079048446 + .long 2518581518 + .long 3186637987 + .long 3636461568 + .long 1079054758 + .long 1552096852 + .long 3192868489 + .long 3854565376 + .long 1079061104 + .long 1865077452 + .long 3191449780 + .long 2757754880 + .long 1079067484 + .long 2620146859 + .long 3192418374 + .long 3242196992 + .long 1079073897 + .long 1679886032 + .long 1045390684 + .long 3848273920 + .long 1079080343 + .long 1008852996 + .long 1045213180 + .long 3042967552 + .long 1079086822 + .long 1190325550 + .long 3191428594 + .long 3516923904 + .long 1079093333 + .long 2901961231 + .long 3189559456 + .long 3600809984 + .long 1079099876 + .long 843293277 + .long 1043776619 + .long 1556086784 + .long 1079106451 + .long 2705956472 + .long 3192552031 + .long 4158652416 + .long 1079113056 + .long 2007583995 + .long 3189975458 + .long 941621248 + .long 1079119693 + .long 1619354403 + .long 3192676122 + .long 2835349504 + .long 1079126359 + .long 4136034317 + .long 1045078976 + .long 3529506816 + .long 1079133055 + .long 290418758 + .long 1040193863 + .long 929038336 + .long 1079139781 + .long 3915023624 + .long 1045366041 + .long 1468006400 + .long 1079146535 + .long 1061629098 + .long 3192285591 + .long 2910846976 + .long 1079153317 + .long 1308671630 + .long 1043573567 + .long 2963275776 + .long 1079160127 + .long 1320907030 + .long 3192436805 + .long 3548381184 + .long 1079166964 + .long 182222777 + .long 3191258117 + .long 2231369728 + .long 1079173828 + .long 3513262155 + .long 3187154074 + .long 803209216 + .long 1079180718 + .long 1139819401 + .long 1040482120 + .long 987758592 + .long 1079187633 + .long 929259512 + .long 3191000897 + .long 146800640 + .long 1079194573 + .long 3229154456 + .long 3191288344 + .long 4167041024 + .long 1079201536 + .long 2552585681 + .long 1042131590 + .long 1692401664 + .long 1079208524 + .long 1439536878 + .long 3188143242 + .long 2776629248 + .long 1079215534 + .long 353720209 + .long 3191860659 + .long 230686720 + .long 1079222567 + .long 2411046197 + .long 3190921481 + .long 3986685952 + .long 1079229620 + .long 3756699850 + .long 3192084150 + .long 2438987776 + .long 1079236695 + .long 1671725142 + .long 1043734190 + .long 1107296256 + .long 1079243790 + .long 1240754629 + .long 1045055957 + .long 1157627904 + .long 1079250904 + .long 1534601222 + .long 1045263230 + .long 3701473280 + .long 1079258036 + .long 3448918206 + .long 1042044860 + .long 1203765248 + .long 1079265187 + .long 3924779397 + .long 1045089235 + .long 3263168512 + .long 1079272354 + .long 3287244582 + .long 1042979553 + .long 2243952640 + .long 1079279538 + .long 820395291 + .long 3190740781 + .long 3349151744 + .long 1079286737 + .long 1366866651 + .long 3192280071 + .long 3143630848 + .long 1079293951 + .long 2762624284 + .long 1045102639 + .long 2449473536 + .long 1079301179 + .long 1845586757 + .long 1044548329 + .long 2040528896 + .long 1079308420 + .long 3762298090 + .long 1045345703 + .long 2654994432 + .long 1079315673 + .long 3683913357 + .long 1045057884 + .long 698351616 + .long 1079322938 + .long 2953393071 + .long 3191482668 + .long 1128267776 + .long 1079330213 + .long 1034464320 + .long 3191720696 + .long 283115520 + .long 1079337498 + .long 1039826403 + .long 1041577546 + .long 3061841920 + .long 1079344791 + .long 19850279 + .long 1042922258 + .long 1449132032 + .long 1079352093 + .long 294154384 + .long 1045031347 + .long 293601280 + .long 1079359402 + .long 1192966610 + .long 3192379901 + .long 119537664 + .long 1079366717 + .long 152130161 + .long 3190257939 + .long 1438646272 + .long 1079374037 + .long 3963433176 + .long 1043378887 + .long 448790528 + .long 1079381362 + .long 2261136335 + .long 1044042197 + .long 1923088384 + .long 1079388690 + .long 3535382687 + .long 1045010726 + .long 2036334592 + .long 1079396021 + .long 3576784639 + .long 3192441914 + .long 1243611136 + .long 1079403354 + .long 3804918049 + .long 3191900478 + .long 0 + .long 1079410688 + .long 0 + .long 0 + .long 3051356160 + .long 1079418021 + .long 3804918049 + .long 1044416830 + .long 2258632704 + .long 1079425354 + .long 3576784639 + .long 1044958266 + .long 2371878912 + .long 1079432685 + .long 3535382687 + .long 3192494374 + .long 3846176768 + .long 1079440013 + .long 2261136335 + .long 3191525845 + .long 2856321024 + .long 1079447338 + .long 3963433176 + .long 3190862535 + .long 4175429632 + .long 1079454658 + .long 152130161 + .long 1042774291 + .long 4001366016 + .long 1079461973 + .long 1192966610 + .long 1044896253 + .long 2845835264 + .long 1079469282 + .long 294154384 + .long 3192514995 + .long 1233125376 + .long 1079476584 + .long 19850279 + .long 3190405906 + .long 4011851776 + .long 1079483877 + .long 1039826403 + .long 3189061194 + .long 3166699520 + .long 1079491162 + .long 1034464320 + .long 1044237048 + .long 3596615680 + .long 1079498437 + .long 2953393071 + .long 1043999020 + .long 1639972864 + .long 1079505702 + .long 3683913357 + .long 3192541532 + .long 2254438400 + .long 1079512955 + .long 3762298090 + .long 3192829351 + .long 1845493760 + .long 1079520196 + .long 1845586757 + .long 3192031977 + .long 1151336448 + .long 1079527424 + .long 2762624284 + .long 3192586287 + .long 945815552 + .long 1079534638 + .long 1366866651 + .long 1044796423 + .long 2051014656 + .long 1079541837 + .long 820395291 + .long 1043257133 + .long 1031798784 + .long 1079549021 + .long 3287244582 + .long 3190463201 + .long 3091202048 + .long 1079556188 + .long 3924779397 + .long 3192572883 + .long 593494016 + .long 1079563339 + .long 3448918206 + .long 3189528508 + .long 3137339392 + .long 1079570471 + .long 1534601222 + .long 3192746878 + .long 3187671040 + .long 1079577585 + .long 1240754629 + .long 3192539605 + .long 1855979520 + .long 1079584680 + .long 1671725142 + .long 3191217838 + .long 308281344 + .long 1079591755 + .long 3756699850 + .long 1044600502 + .long 4064280576 + .long 1079598808 + .long 2411046197 + .long 1043437833 + .long 1518338048 + .long 1079605841 + .long 353720209 + .long 1044377011 + .long 2602565632 + .long 1079612851 + .long 1439536878 + .long 1040659594 + .long 127926272 + .long 1079619839 + .long 2552585681 + .long 3189615238 + .long 4148166656 + .long 1079626802 + .long 3229154456 + .long 1043804696 + .long 3307208704 + .long 1079633742 + .long 929259512 + .long 1043517249 + .long 3491758080 + .long 1079640657 + .long 1139819401 + .long 3187965768 + .long 2063597568 + .long 1079647547 + .long 3513262155 + .long 1039670426 + .long 746586112 + .long 1079654411 + .long 182222777 + .long 1043774469 + .long 1331691520 + .long 1079661248 + .long 1320907030 + .long 1044953157 + .long 1384120320 + .long 1079668058 + .long 1308671630 + .long 3191057215 + .long 2826960896 + .long 1079674840 + .long 1061629098 + .long 1044801943 + .long 3365928960 + .long 1079681594 + .long 3915023624 + .long 3192849689 + .long 765460480 + .long 1079688320 + .long 290418758 + .long 3187677511 + .long 1459617792 + .long 1079695016 + .long 4136034317 + .long 3192562624 + .long 3353346048 + .long 1079701682 + .long 1619354403 + .long 1045192474 + .long 136314880 + .long 1079708319 + .long 2007583995 + .long 1042491810 + .long 2738880512 + .long 1079714924 + .long 2705956472 + .long 1045068383 + .long 694157312 + .long 1079721499 + .long 843293277 + .long 3191260267 + .long 778043392 + .long 1079728042 + .long 2901961231 + .long 1042075808 + .long 1251999744 + .long 1079734553 + .long 1190325550 + .long 1043944946 + .long 446693376 + .long 1079741032 + .long 1008852996 + .long 3192696828 + .long 1052770304 + .long 1079747478 + .long 1679886032 + .long 3192874332 + .long 1537212416 + .long 1079753891 + .long 2620146859 + .long 1044934726 + .long 440401920 + .long 1079760271 + .long 1865077452 + .long 1043966132 + .long 658505728 + .long 1079766617 + .long 1552096852 + .long 1045384841 + .long 866123776 + .long 1079772929 + .long 2518581518 + .long 1039154339 + .long 4093640704 + .long 1079779206 + .long 1430947390 + .long 1045301740 + .long 559939584 + .long 1079785450 + .long 514060819 + .long 1044210997 + .long 2019557376 + .long 1079791658 + .long 41710967 + .long 3189176765 + .long 3112173568 + .long 1079797831 + .long 2124167878 + .long 1044447288 + .long 2839543808 + .long 1079803969 + .long 1622551107 + .long 1044827309 + .long 266338304 + .long 1079810072 + .long 3828434628 + .long 3192501419 + .long 3103784960 + .long 1079816138 + .long 2099274145 + .long 1043277518 + .long 1952448512 + .long 1079822169 + .long 2612691399 + .long 1044920099 + .long 356515840 + .long 1079828164 + .long 1171997210 + .long 3192115818 + .long 1914699776 + .long 1079834122 + .long 1393635940 + .long 3191604114 + .long 1698693120 + .long 1079840044 + .long 3000864111 + .long 1044567581 + .long 3428843520 + .long 1079845929 + .long 3891583054 + .long 1044582113 + .long 2290089984 + .long 1079851778 + .long 3752802150 + .long 3191636700 + .long 2109734912 + .long 1079857590 + .long 3035382168 + .long 1043228732 + .long 2480930816 + .long 1079863365 + .long 2565683088 + .long 3192570771 + .long 3042967552 + .long 1079869103 + .long 1405657776 + .long 3191747915 + .long 3491758080 + .long 1079874804 + .long 152088799 + .long 1042154031 + .long 3573547008 + .long 1079880468 + .long 1577179566 + .long 1043010748 + .long 3082813440 + .long 1079886095 + .long 1063445218 + .long 1044285308 + .long 1864368128 + .long 1079891685 + .long 3525309094 + .long 3189988831 + .long 4102029312 + .long 1079897237 + .long 3023722014 + .long 1043994564 + .long 1145044992 + .long 1079902753 + .long 2787570751 + .long 1043345947 + .long 1564475392 + .long 1079908231 + .long 2811467203 + .long 1043838930 + .long 1092616192 + .long 1079913672 + .long 1936866404 + .long 3191863928 + .long 4091543552 + .long 1079919075 + .long 2980113444 + .long 3192905397 + .long 2080374784 + .long 1079924442 + .long 1232510221 + .long 3190881813 + .long 3800039424 + .long 1079929771 + .long 878865976 + .long 1045236413 + .long 851443712 + .long 1079935064 + .long 1134072023 + .long 1045386565 + .long 2051014656 + .long 1079940319 + .long 1008344600 + .long 1044439573 + .long 3368026112 + .long 1079945537 + .long 1281162365 + .long 3192613919 + .long 803209216 + .long 1079950719 + .long 1692530062 + .long 1043648146 + .long 3284140032 + .long 1079955863 + .long 4155795398 + .long 1043918312 + .long 2587885568 + .long 1079960971 + .long 3556863456 + .long 3192106174 + .long 3405774848 + .long 1079966042 + .long 2925970384 + .long 1039575776 + .long 1874853888 + .long 1079971077 + .long 2866881462 + .long 1044616390 + .long 2751463424 + .long 1079976075 + .long 2148760563 + .long 1039453383 + .long 2227175424 + .long 1079981037 + .long 2478710518 + .long 1044662933 + .long 822083584 + .long 1079985963 + .long 527414264 + .long 3192196970 + .long 3370123264 + .long 1079990852 + .long 597131077 + .long 1044444197 + .long 1855979520 + .long 1079995706 + .long 327513079 + .long 3192718825 + .long 1163919360 + .long 1080000524 + .long 2167457950 + .long 3191943119 + .long 1912602624 + .long 1080005306 + .long 2223907458 + .long 1044698143 + .long 450887680 + .long 1080010053 + .long 1797206836 + .long 3192265480 + .long 1730150400 + .long 1080014764 + .long 806768485 + .long 1045029436 + .long 2143289344 + .long 1080019440 + .long 3385731218 + .long 1043691060 + .long 2390753280 + .long 1080024081 + .long 2289432889 + .long 1035999008 + .long 3193962496 + .long 1080028687 + .long 653388941 + .long 3186809946 + .long 998244352 + .long 1080033259 + .long 3139143286 + .long 3191209215 + .long 427819008 + .long 1080035538 + .long 617352675 + .long 3193137764 + .long 1767899136 + .long 1080037789 + .long 2820938545 + .long 1044793929 + .long 2768240640 + .long 1080040023 + .long 1116869194 + .long 1045935239 + .long 3831496704 + .long 1080042240 + .long 2883013420 + .long 3192429127 + .long 1067450368 + .long 1080044441 + .long 716229612 + .long 1045716128 + .long 3485466624 + .long 1080046624 + .long 3427207267 + .long 3192006748 + .long 2912944128 + .long 1080048791 + .long 1797448570 + .long 1045763212 + .long 4074766336 + .long 1080050941 + .long 963007300 + .long 1046072799 + .long 3107979264 + .long 1080053075 + .long 1001194228 + .long 1045849723 + .long 450887680 + .long 1080055193 + .long 3243655263 + .long 3191879277 + .long 838860800 + .long 1080057294 + .long 1225643377 + .long 3190452555 + .long 425721856 + .long 1080059379 + .long 632951086 + .long 3193270660 + .long 3955228672 + .long 1080061447 + .long 928991542 + .long 1043548181 + .long 3294625792 + .long 1080063500 + .long 3229203938 + .long 1042779359 + .long 3196059648 + .long 1080065537 + .long 1071139240 + .long 1044201053 + .long 4120903680 + .long 1080067558 + .long 754552020 + .long 1045844436 + .long 2239758336 + .long 1080069564 + .long 1637692909 + .long 1045134398 + .long 2313158656 + .long 1080071554 + .long 3579217071 + .long 1046240180 + .long 517996544 + .long 1080073529 + .long 3412027605 + .long 3191381190 + .long 1616904192 + .long 1080075488 + .long 2404468057 + .long 1046410024 + .long 1793064960 + .long 1080077432 + .long 3207515339 + .long 3189828782 + .long 1518338048 + .long 1080079361 + .long 847503884 + .long 3191075565 + .long 1270874112 + .long 1080081275 + .long 3556889995 + .long 3193585111 + .long 1526726656 + .long 1080083174 + .long 478427801 + .long 3192682319 + .long 2766143488 + .long 1080085058 + .long 30743511 + .long 3192873887 + .long 1172307968 + .long 1080086928 + .long 1809054730 + .long 1044630197 + .long 1522532352 + .long 1080088783 + .long 2052116880 + .long 3191818486 + .long 0 + .long 1080090624 + .long 0 + .long 0 + .long 2772434944 + .long 1080092464 + .long 2052116880 + .long 1044334838 + .long 3122659328 + .long 1080094319 + .long 1809054730 + .long 3192113845 + .long 1528823808 + .long 1080096189 + .long 30743511 + .long 1045390239 + .long 2768240640 + .long 1080098073 + .long 478427801 + .long 1045198671 + .long 3024093184 + .long 1080099972 + .long 3556889995 + .long 1046101463 + .long 2776629248 + .long 1080101886 + .long 847503884 + .long 1043591917 + .long 2501902336 + .long 1080103815 + .long 3207515339 + .long 1042345134 + .long 2678063104 + .long 1080105759 + .long 2404468057 + .long 3193893672 + .long 3776970752 + .long 1080107718 + .long 3412027605 + .long 1043897542 + .long 1981808640 + .long 1080109693 + .long 3579217071 + .long 3193723828 + .long 2055208960 + .long 1080111683 + .long 1637692909 + .long 3192618046 + .long 174063616 + .long 1080113689 + .long 754552020 + .long 3193328084 + .long 1098907648 + .long 1080115710 + .long 1071139240 + .long 3191684701 + .long 1000341504 + .long 1080117747 + .long 3229203938 + .long 3190263007 + .long 339738624 + .long 1080119800 + .long 928991542 + .long 3191031829 + .long 3869245440 + .long 1080121868 + .long 632951086 + .long 1045787012 + .long 3456106496 + .long 1080123953 + .long 1225643377 + .long 1042968907 + .long 3844079616 + .long 1080126054 + .long 3243655263 + .long 1044395629 + .long 1186988032 + .long 1080128172 + .long 1001194228 + .long 3193333371 + .long 220200960 + .long 1080130306 + .long 963007300 + .long 3193556447 + .long 1382023168 + .long 1080132456 + .long 1797448570 + .long 3193246860 + .long 809500672 + .long 1080134623 + .long 3427207267 + .long 1044523100 + .long 3227516928 + .long 1080136806 + .long 716229612 + .long 3193199776 + .long 463470592 + .long 1080139007 + .long 2883013420 + .long 1044945479 + .long 1526726656 + .long 1080141224 + .long 1116869194 + .long 3193418887 + .long 2527068160 + .long 1080143458 + .long 2820938545 + .long 3192277577 + .long 3867148288 + .long 1080145709 + .long 617352675 + .long 1045654116 + .long 1648361472 + .long 1080147978 + .long 3139143286 + .long 1043725567 + .long 551550976 + .long 1080150264 + .long 2539927630 + .long 3193943182 + .long 952107008 + .long 1080152567 + .long 2289432889 + .long 3183482656 + .long 3223322624 + .long 1080154887 + .long 3385731218 + .long 3191174708 + .long 3428843520 + .long 1080157225 + .long 3891583054 + .long 1045630689 + .long 1923088384 + .long 1080159581 + .long 3396363878 + .long 3193238139 + .long 3338665984 + .long 1080161954 + .long 2223907458 + .long 3192181791 + .long 3714056192 + .long 1080164345 + .long 1063754673 + .long 3193399320 + .long 3368026112 + .long 1080166754 + .long 1983727109 + .long 3193011467 + .long 2608857088 + .long 1080169181 + .long 1848918109 + .long 1045923309 + .long 1736441856 + .long 1080171626 + .long 527414264 + .long 1044713322 + .long 1033895936 + .long 1080174089 + .long 2478710518 + .long 3192146581 + .long 771751936 + .long 1080176570 + .long 2148760563 + .long 3186937031 + .long 1210056704 + .long 1080179069 + .long 2866881462 + .long 3192100038 + .long 2592079872 + .long 1080181586 + .long 2925970384 + .long 3187059424 + .long 853540864 + .long 1080184122 + .long 3556863456 + .long 1044622526 + .long 505413632 + .long 1080186676 + .long 4155795398 + .long 3191401960 + .long 1744830464 + .long 1080189248 + .long 1724351133 + .long 1046137947 + .long 463470592 + .long 1080191839 + .long 1281162365 + .long 1045130271 + .long 1121976320 + .long 1080194448 + .long 1008344600 + .long 3191923221 + .long 3869245440 + .long 1080197075 + .long 1134072023 + .long 3192870213 + .long 247463936 + .long 1080199722 + .long 878865976 + .long 3192720061 + .long 3254779904 + .long 1080202386 + .long 1232510221 + .long 1043398165 + .long 102760448 + .long 1080205070 + .long 657426926 + .long 3192918181 + .long 3749707776 + .long 1080207771 + .long 3810750695 + .long 3193438561 + .long 1365245952 + .long 1080210492 + .long 2811467203 + .long 3191322578 + .long 1574961152 + .long 1080213231 + .long 2787570751 + .long 3190829595 + .long 96468992 + .long 1080215989 + .long 3023722014 + .long 3191478212 + .long 1216348160 + .long 1080218765 + .long 96207275 + .long 3193803844 + .long 606076928 + .long 1080221560 + .long 1063445218 + .long 3191768956 + .long 2508193792 + .long 1080224373 + .long 1577179566 + .long 3190494396 + .long 2548039680 + .long 1080227205 + .long 258929906 + .long 1046355933 + .long 627048448 + .long 1080230056 + .long 722327380 + .long 3193467565 + .long 908066816 + .long 1080232925 + .long 864642104 + .long 3193085494 + .long 3240099840 + .long 1080235812 + .long 3035382168 + .long 3190712380 + .long 3149922304 + .long 1080238718 + .long 3752802150 + .long 1044153052 + .long 432013312 + .long 1080241643 + .long 201692121 + .long 1045854351 + .long 3445620736 + .long 1080244585 + .long 3000864111 + .long 3192051229 + .long 3338665984 + .long 1080247546 + .long 1799074663 + .long 3193503515 + .long 4116709376 + .long 1080250525 + .long 1171997210 + .long 1044632170 + .long 1170210816 + .long 1080253523 + .long 841137948 + .long 1045685358 + .long 2743074816 + .long 1080256538 + .long 2099274145 + .long 3190761166 + .long 4162846720 + .long 1080259571 + .long 233266334 + .long 3193120170 + .long 727711744 + .long 1080262623 + .long 1622551107 + .long 3192310957 + .long 591396864 + .long 1080265692 + .long 2124167878 + .long 3191930936 + .long 3286237184 + .long 1080268778 + .long 802699433 + .long 3193868388 + .long 4013948928 + .long 1080271882 + .long 3092710267 + .long 1045997234 + .long 2248146944 + .long 1080275004 + .long 1430947390 + .long 3192785388 + .long 1713373184 + .long 1080278143 + .long 1906804220 + .long 1046462221 + .long 1818230784 + .long 1080281299 + .long 1552096852 + .long 3192868489 + .long 1927282688 + .long 1080284472 + .long 1865077452 + .long 3191449780 + .long 1377828864 + .long 1080287662 + .long 2984893867 + .long 1045678044 + .long 3768582144 + .long 1080290868 + .long 1679886032 + .long 1045390684 + .long 4072669184 + .long 1080294091 + .long 3790540798 + .long 3193022465 + .long 1520435200 + .long 1080297331 + .long 1849902261 + .long 1046063747 + .long 3904897024 + .long 1080300586 + .long 4113594719 + .long 1046360821 + .long 1801453568 + .long 1080303858 + .long 862918505 + .long 3193589477 + .long 2925527040 + .long 1080307145 + .long 2705956472 + .long 3192552031 + .long 2078277632 + .long 1080310448 + .long 2970277473 + .long 1046321867 + .long 2617245696 + .long 1080313766 + .long 3485290095 + .long 1045549170 + .long 3565158400 + .long 1080317099 + .long 4136034317 + .long 1045078976 + .long 3913285632 + .long 1080320447 + .long 3346367614 + .long 3193929525 + .long 2613051392 + .long 1080323810 + .long 189971836 + .long 3192946035 + .long 2881486848 + .long 1080327187 + .long 1061629098 + .long 3192285591 + .long 3602907136 + .long 1080330578 + .long 1308671630 + .long 1043573567 + .long 3628072960 + .long 1080333983 + .long 1487030133 + .long 1045668829 + .long 1774190592 + .long 1080337402 + .long 182222777 + .long 3191258117 + .long 1115684864 + .long 1080340834 + .long 3513262155 + .long 3187154074 + .long 402653184 + .long 1080344279 + .long 3185606116 + .long 3193920517 + .long 2640314368 + .long 1080347736 + .long 2988910594 + .long 1046170671 + .long 2220883968 + .long 1080351206 + .long 3229154456 + .long 3191288344 + .long 2084569088 + .long 1080354688 + .long 2524817955 + .long 3193840983 + .long 845152256 + .long 1080358182 + .long 2907804489 + .long 1046431323 + .long 1388314624 + .long 1080361687 + .long 353720209 + .long 3191860659 + .long 2262827008 + .long 1080365203 + .long 2411046197 + .long 3190921481 + .long 1992294400 + .long 1080368730 + .long 2416617371 + .long 1045845156 + .long 3368026112 + .long 1080372267 + .long 1729552362 + .long 3193600084 + .long 553648128 + .long 1080375815 + .long 1240754629 + .long 1045055957 + .long 578813952 + .long 1080379372 + .long 1534601222 + .long 1045263230 + .long 1851785216 + .long 1080382938 + .long 858184436 + .long 3193846404 + .long 2749366272 + .long 1080386513 + .long 3924779397 + .long 1045089235 + .long 1631584256 + .long 1080390097 + .long 3287244582 + .long 1042979553 + .long 1121976320 + .long 1080393689 + .long 820395291 + .long 3190740781 + .long 3821010944 + .long 1080397288 + .long 1464050323 + .long 1045747196 + .long 3720347648 + .long 1080400895 + .long 766171506 + .long 3193077736 + .long 3372220416 + .long 1080404509 + .long 1845586757 + .long 1044548329 + .long 1021313024 + .long 1080408130 + .long 266334603 + .long 3192956204 + .long 3474980864 + .long 1080411756 + .long 3683913357 + .long 1045057884 + .long 348127232 + .long 1080415389 + .long 3556619028 + .long 1046050228 + .long 2711617536 + .long 1080419026 + .long 1034464320 + .long 3191720696 + .long 142606336 + .long 1080422669 + .long 1545623586 + .long 3193875611 + .long 3678404608 + .long 1080426315 + .long 19850279 + .long 1042922258 + .long 2873098240 + .long 1080429966 + .long 2000406456 + .long 3193113382 + .long 146800640 + .long 1080433621 + .long 1192966610 + .long 3192379901 + .long 2206203904 + .long 1080437278 + .long 2665338290 + .long 1046286557 + .long 2866806784 + .long 1080440938 + .long 3963433176 + .long 1043378887 + .long 224395264 + .long 1080444601 + .long 2261136335 + .long 1044042197 + .long 962592768 + .long 1080448265 + .long 2527275953 + .long 3193123692 + .long 3164602368 + .long 1080451930 + .long 2506574977 + .long 1045666274 + .long 620756992 + .long 1080455597 + .long 2392508272 + .long 1045936992 + .long 0 + .long 1080459264 + .long 0 + .long 0 + .type __libm_atandl_table_128,@object + .size __libm_atandl_table_128,8208 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atanf_wmt.S b/external/sgx_libm/ia32/atanf_wmt.S new file mode 100644 index 0000000000..02e10ea064 --- /dev/null +++ b/external/sgx_libm/ia32/atanf_wmt.S @@ -0,0 +1,596 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin atanf + .text + .align 16,0x90 + .globl atanf +atanf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl $-524288, %eax + movd %eax, %xmm3 + movss 1376(%ebx), %xmm5 + movl $262144, %ecx + movd %ecx, %xmm4 + movl 112(%esp), %edx + andps %xmm0, %xmm3 + movss %xmm0, %xmm1 + orps %xmm4, %xmm3 + movl %edx, %eax + andl $2146959360, %edx + subl $1023410176, %edx + cmpl $83361792, %edx + ja .L_2TAG_PACKET_0.0.2 + mulss %xmm3, %xmm1 + subss %xmm3, %xmm0 + addss %xmm5, %xmm1 + divss %xmm1, %xmm0 + shrl $16, %edx + addl $8, %edx + movl $-1096111855, %ecx + movd %ecx, %xmm4 + movss (%ebx,%edx), %xmm2 + movss 4(%ebx,%edx), %xmm3 + andl $-2147483648, %eax + movd %eax, %xmm5 + xorps %xmm5, %xmm2 + xorps %xmm5, %xmm3 + movss %xmm2, %xmm5 + movss %xmm0, %xmm1 + mulss %xmm0, %xmm0 + mulss %xmm1, %xmm4 + addss %xmm1, %xmm2 + subss %xmm2, %xmm5 + mulss %xmm4, %xmm0 + addss %xmm5, %xmm1 + addss %xmm3, %xmm0 + addss %xmm1, %xmm0 + addss %xmm2, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_0.0.2: + addl $75497472, %edx + cmpl $158859264, %edx + ja .L_2TAG_PACKET_2.0.2 + movss 1360(%ebx), %xmm2 + movss 1364(%ebx), %xmm4 + mulss %xmm1, %xmm1 + mulss %xmm0, %xmm4 + mulss %xmm0, %xmm2 + movss %xmm1, %xmm5 + mulss %xmm1, %xmm1 + mulss %xmm5, %xmm4 + mulss %xmm2, %xmm1 + addss %xmm4, %xmm1 + addss %xmm1, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + addl $947912704, %edx + cmpl $1106771968, %edx + jae .L_2TAG_PACKET_3.0.2 + movl $1065353217, %eax + movd %xmm0, %ecx + cmpl $8388608, %edx + cmovb %ecx, %eax + movd %eax, %xmm1 + mulss %xmm1, %xmm1 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_3.0.2: + cmpl $1602224128, %edx + jae .L_2TAG_PACKET_4.0.2 + movl $-1082130432, %ecx + movd %ecx, %xmm1 + divss %xmm0, %xmm1 + cmpl $1182793728, %edx + jae .L_2TAG_PACKET_5.0.2 + movl $-1096111855, %ecx + movd %ecx, %xmm4 + movss 1344(%ebx), %xmm2 + movss 1348(%ebx), %xmm3 + andl $-2147483648, %eax + movd %eax, %xmm5 + xorps %xmm5, %xmm2 + xorps %xmm5, %xmm3 + movss %xmm2, %xmm5 + movss %xmm1, %xmm0 + mulss %xmm1, %xmm1 + mulss %xmm0, %xmm4 + addss %xmm0, %xmm2 + subss %xmm2, %xmm5 + mulss %xmm4, %xmm1 + addss %xmm5, %xmm0 + addss %xmm3, %xmm1 + addss %xmm1, %xmm0 + addss %xmm2, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_5.0.2: + movss 1344(%ebx), %xmm0 + movss 1348(%ebx), %xmm3 + andl $-2147483648, %eax + movd %eax, %xmm5 + xorps %xmm5, %xmm0 + xorps %xmm5, %xmm3 + movss %xmm0, %xmm5 + addss %xmm1, %xmm0 + subss %xmm0, %xmm5 + addss %xmm5, %xmm1 + addss %xmm1, %xmm3 + addss %xmm3, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_4.0.2: + movss 1344(%ebx), %xmm2 + movss 1348(%ebx), %xmm3 + cmpl $2139029504, %edx + ja .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_7.0.2: + andl $-2147483648, %eax + movd %eax, %xmm0 + orps %xmm0, %xmm2 + orps %xmm3, %xmm0 + addss %xmm2, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_6.0.2: + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + je .L_2TAG_PACKET_7.0.2 + addss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_1.0.2: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type atanf,@function + .size atanf,.-atanf + .data +# -- End atanf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 1023669327 + .long 803928991 + .long 1024193038 + .long 2966692170 + .long 1024716678 + .long 811692700 + .long 1025240245 + .long 792964392 + .long 1025763734 + .long 802148141 + .long 1026287141 + .long 819324013 + .long 1026810463 + .long 790037051 + .long 1027333695 + .long 759154391 + .long 1027856833 + .long 817525057 + .long 1028379874 + .long 808527090 + .long 1028902813 + .long 821626264 + .long 1029425647 + .long 817580405 + .long 1029948372 + .long 2952445505 + .long 1030470983 + .long 801005003 + .long 1030993477 + .long 800387983 + .long 1031515850 + .long 2942256123 + .long 1032048979 + .long 2968250322 + .long 1032570964 + .long 822790803 + .long 1033092672 + .long 826289861 + .long 1033614088 + .long 2976224418 + .long 1034135194 + .long 824490938 + .long 1034655977 + .long 822527213 + .long 1035176421 + .long 784232806 + .long 1035696510 + .long 822531604 + .long 1036216230 + .long 2967672936 + .long 1036735564 + .long 826515440 + .long 1037254499 + .long 2944102134 + .long 1037773019 + .long 2977774463 + .long 1038291108 + .long 795957866 + .long 1038808753 + .long 2972700386 + .long 1039325938 + .long 2975253635 + .long 1039842648 + .long 807079588 + .long 1040402092 + .long 822355304 + .long 1040917290 + .long 805504040 + .long 1041431409 + .long 2978896586 + .long 1041944391 + .long 836680090 + .long 1042456182 + .long 826352980 + .long 1042966726 + .long 2973619487 + .long 1043475968 + .long 2937629464 + .long 1043983855 + .long 831159584 + .long 1044490335 + .long 820394738 + .long 1044995356 + .long 2965290852 + .long 1045498867 + .long 772017454 + .long 1046000819 + .long 2978687103 + .long 1046501162 + .long 836200518 + .long 1046999850 + .long 836883769 + .long 1047496836 + .long 826905524 + .long 1047992074 + .long 824423170 + .long 1048653779 + .long 2993658277 + .long 1049143506 + .long 2988293347 + .long 1049629355 + .long 838635411 + .long 1050111172 + .long 2981083232 + .long 1050588809 + .long 840069395 + .long 1051062131 + .long 2985487843 + .long 1051531009 + .long 2987007755 + .long 1051995325 + .long 2954909954 + .long 1052454971 + .long 2992105648 + .long 1052909846 + .long 2984512837 + .long 1053359860 + .long 2974535271 + .long 1053804931 + .long 834850816 + .long 1054244987 + .long 2990399399 + .long 1054679962 + .long 2986843574 + .long 1055109800 + .long 841668384 + .long 1055534454 + .long 840878179 + .long 1056161628 + .long 2959648204 + .long 1056972004 + .long 2999182783 + .long 1057370275 + .long 2987693957 + .long 1057757908 + .long 848029633 + .long 1058134927 + .long 833824667 + .long 1058501396 + .long 838916473 + .long 1058857417 + .long 2982869562 + .long 1059203123 + .long 2987447445 + .long 1059538675 + .long 2986943103 + .long 1059864257 + .long 2962018373 + .long 1060180073 + .long 3001690183 + .long 1060486341 + .long 3000978470 + .long 1060783292 + .long 855353569 + .long 1061071169 + .long 847903241 + .long 1061350219 + .long 2995336148 + .long 1061620693 + .long 848940038 + .long 1062010885 + .long 848518105 + .long 1062503512 + .long 2989792343 + .long 1062966414 + .long 2998000194 + .long 1063401558 + .long 2966602495 + .long 1063810833 + .long 841421013 + .long 1064196033 + .long 853285487 + .long 1064558850 + .long 831341538 + .long 1064900868 + .long 2999260393 + .long 1065223564 + .long 3001104089 + .long 1065440763 + .long 856880849 + .long 1065584798 + .long 852830020 + .long 1065721082 + .long 862757435 + .long 1065850159 + .long 2998927867 + .long 1065972528 + .long 2998512290 + .long 1066088651 + .long 2998663603 + .long 1066198953 + .long 2996780932 + .long 1066354340 + .long 3007554211 + .long 1066544552 + .long 2996943326 + .long 1066717600 + .long 3000009859 + .long 1066875577 + .long 856175525 + .long 1067020272 + .long 836800017 + .long 1067153216 + .long 3008748444 + .long 1067275724 + .long 851983949 + .long 1067388933 + .long 862585050 + .long 1067493827 + .long 3009301766 + .long 1067591258 + .long 2988483069 + .long 1067681973 + .long 3005223458 + .long 1067766623 + .long 839061141 + .long 1067845782 + .long 2995523700 + .long 1067919954 + .long 2995663457 + .long 1067989585 + .long 858133164 + .long 1068055072 + .long 829335339 + .long 1068146290 + .long 856294518 + .long 1068256389 + .long 3003850806 + .long 1068355146 + .long 856998103 + .long 1068444206 + .long 2999569255 + .long 1068524912 + .long 3011255227 + .long 1068598373 + .long 841513866 + .long 1068665514 + .long 841710807 + .long 1068727109 + .long 2949159239 + .long 1068783812 + .long 2995542644 + .long 1068836179 + .long 3007665083 + .long 1068884685 + .long 3006087365 + .long 1068929739 + .long 2996180184 + .long 1068971695 + .long 3006313179 + .long 1069010859 + .long 849476222 + .long 1069047500 + .long 860722755 + .long 1069081853 + .long 859062603 + .long 1069129538 + .long 2979745798 + .long 1069186846 + .long 842801502 + .long 1069238035 + .long 3010794384 + .long 1069284031 + .long 3010162926 + .long 1069325584 + .long 3005589807 + .long 1069363306 + .long 853875835 + .long 1069397703 + .long 851842476 + .long 1069429195 + .long 3001807968 + .long 1069458133 + .long 859424355 + .long 1069484817 + .long 3004202910 + .long 1069509498 + .long 843503196 + .long 1069532394 + .long 856475636 + .long 1069553692 + .long 2995114457 + .long 1069573552 + .long 860725119 + .long 1069592116 + .long 859745384 + .long 1069609507 + .long 3009201804 + .long 1069633623 + .long 855498560 + .long 1069662574 + .long 858167444 + .long 1069688405 + .long 853306415 + .long 1069711594 + .long 846705105 + .long 1069732526 + .long 858976312 + .long 1069751516 + .long 2999172562 + .long 1069768821 + .long 2999539371 + .long 1069784656 + .long 2998679696 + .long 1069799200 + .long 861304267 + .long 1069812606 + .long 843012447 + .long 1069825002 + .long 3010989671 + .long 1069836497 + .long 3005173143 + .long 1069847186 + .long 853102954 + .long 1069857152 + .long 2993551140 + .long 1069866465 + .long 3000116992 + .long 1069875187 + .long 827148142 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 32768 + .long 0 + .long 0 + .long 1431655765 + .long 3218429269 + .long 0 + .long 0 + .long 1070141402 + .long 866263400 + .long 0 + .long 0 + .long 1045220557 + .long 3198855851 + .long 0 + .long 0 + .long 1065353216 + .long 0 + .long 0 + .long 0 + .long 3198855441 + .long 0 + .long 0 + .long 0 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 2146959360 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,1440 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atanh_wmt.S b/external/sgx_libm/ia32/atanh_wmt.S new file mode 100644 index 0000000000..3c618294c5 --- /dev/null +++ b/external/sgx_libm/ia32/atanh_wmt.S @@ -0,0 +1,1380 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanh_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin atanh + .text + .align 16,0x90 + .globl atanh +atanh: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movl 116(%esp), %eax + movl %eax, %ecx + movq %xmm0, 8(%esp) + movl %eax, %edx + andl $2147483647, %eax + cmpl $1072693248, %eax + jge .L_2TAG_PACKET_0.0.3 + cmpl $1068498944, %eax + jl .L_2TAG_PACKET_1.0.3 + movsd 96(%ebx), %xmm2 + movsd 112(%ebx), %xmm4 + movsd 112(%ebx), %xmm3 + movsd 144(%ebx), %xmm6 + andpd %xmm2, %xmm0 + movq %xmm0, %xmm1 + movq %xmm0, %xmm7 + subsd %xmm4, %xmm0 + addsd %xmm4, %xmm1 + divsd %xmm0, %xmm4 + movq %xmm0, %xmm5 + movq %xmm1, %xmm2 + andpd 128(%ebx), %xmm5 + addsd %xmm0, %xmm3 + addsd %xmm2, %xmm6 + subsd %xmm5, %xmm0 + subsd %xmm7, %xmm3 + subsd %xmm7, %xmm6 + mulsd %xmm4, %xmm1 + andpd 128(%ebx), %xmm1 + mulsd %xmm1, %xmm5 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm0 + subsd %xmm5, %xmm2 + subsd %xmm3, %xmm6 + cvtsd2ss %xmm1, %xmm7 + subsd %xmm0, %xmm2 + rcpss %xmm7, %xmm7 + subsd %xmm6, %xmm2 + mulsd %xmm4, %xmm2 + cvtss2sd %xmm7, %xmm3 + paddd 160(%ebx), %xmm3 + andpd 176(%ebx), %xmm3 + mulsd %xmm3, %xmm1 + subsd 192(%ebx), %xmm1 + mulsd %xmm3, %xmm2 + psrlq $40, %xmm3 + movq %xmm1, %xmm4 + addsd %xmm2, %xmm1 + movd %xmm3, %eax + movl $4080, %ecx + andl %eax, %ecx + andl $8384512, %eax + cvtsi2sdl %eax, %xmm3 + movapd 272(%ebx,%ecx), %xmm5 + pshufd $68, %xmm3, %xmm3 + mulpd 208(%ebx), %xmm3 + subpd %xmm3, %xmm5 + pshufd $68, %xmm1, %xmm6 + movapd 224(%ebx), %xmm0 + mulpd %xmm6, %xmm0 + mulsd %xmm1, %xmm1 + addpd 240(%ebx), %xmm0 + pshufd $238, %xmm5, %xmm3 + addsd %xmm2, %xmm5 + movq %xmm3, %xmm7 + addsd %xmm4, %xmm3 + subsd %xmm3, %xmm7 + pshufd $238, %xmm0, %xmm2 + mulsd %xmm1, %xmm0 + addsd %xmm2, %xmm0 + andl $-2147483648, %edx + mulsd %xmm1, %xmm0 + addsd %xmm7, %xmm4 + subsd %xmm6, %xmm0 + addsd %xmm4, %xmm5 + mulsd %xmm6, %xmm0 + movd %edx, %xmm2 + psllq $32, %xmm2 + addsd %xmm5, %xmm0 + addsd %xmm3, %xmm0 + orpd %xmm2, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + cmpl $1003487232, %eax + jl .L_2TAG_PACKET_3.0.3 + movapd 32(%ebx), %xmm1 + movapd %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + movapd %xmm0, %xmm3 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm3 + mulpd %xmm0, %xmm1 + addpd 16(%ebx), %xmm1 + mulpd %xmm0, %xmm1 + addpd (%ebx), %xmm1 + mulpd %xmm3, %xmm1 + movhlps %xmm1, %xmm0 + addsd %xmm1, %xmm0 + mulsd %xmm2, %xmm0 + addsd %xmm2, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + andl $2146435072, %eax + je .L_2TAG_PACKET_4.0.3 + fldl 8(%esp) + fld1 + fld %st(1) + faddp + fmulp + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + fldl 8(%esp) + fld %st(0) + fmul %st(1), %st + fstpl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + movl 8(%esp), %ecx + jne .L_2TAG_PACKET_5.0.3 + testl %ecx, %ecx + je .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_5.0.3: + cmpl $2146435072, %eax + jg .L_2TAG_PACKET_7.0.3 + je .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_9.0.3: + xorpd %xmm0, %xmm0 + mulsd 256(%ebx), %xmm0 + movsd %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $131, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + xorpd %xmm1, %xmm1 + divsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $132, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_8.0.3: + testl %ecx, %ecx + je .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_7.0.3: + addsd %xmm0, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) +.L_2TAG_PACKET_2.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type atanh,@function + .size atanh,.-atanh + .data +# -- End atanh + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1431655765 + .long 1070945621 + .long 2576980801 + .long 1070176665 + .long 2453616913 + .long 1069697316 + .long 1427436931 + .long 1069314503 + .long 2129349532 + .long 1068975486 + .long 1629438381 + .long 1068756329 + .long 0 + .long 3219128320 + .long 1431621855 + .long 1070945621 + .long 4294842013 + .long 3218079743 + .long 1289448124 + .long 1070176674 + .long 2077359316 + .long 3217380703 + .long 0 + .long 0 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 4026531840 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 3220176896 + .long 0 + .long 4293918976 + .long 0 + .long 4293918976 + .long 0 + .long 4294963200 + .long 0 + .long 4294963200 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 3164486458 + .long 1017968538 + .long 4277796864 + .long 1058418242 + .long 2640218915 + .long 3222623584 + .long 4294812536 + .long 3221225471 + .long 1158309786 + .long 1074370979 + .long 1431613876 + .long 1073042773 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 3961250687 + .long 1024388927 + .long 3715808466 + .long 1081484075 + .long 2810985123 + .long 3168028234 + .long 3782743078 + .long 1081484067 + .long 2030471786 + .long 1021588483 + .long 3982853962 + .long 1081484059 + .long 724716906 + .long 1026766458 + .long 20143440 + .long 1081484052 + .long 481208597 + .long 1024261464 + .long 483527638 + .long 1081484044 + .long 769498347 + .long 1026449044 + .long 1077032516 + .long 1081484036 + .long 662383902 + .long 3174188397 + .long 1799662888 + .long 1081484028 + .long 4195513590 + .long 3173820974 + .long 2650434932 + .long 1081484020 + .long 216019017 + .long 3171160333 + .long 3628376034 + .long 1081484012 + .long 3037216435 + .long 3174203912 + .long 437557316 + .long 1081484005 + .long 2242287414 + .long 3173446660 + .long 1666962648 + .long 1081483997 + .long 488659010 + .long 3174389563 + .long 3020684720 + .long 1081483989 + .long 2411277324 + .long 3174261033 + .long 202826760 + .long 1081483982 + .long 1552614370 + .long 3174374647 + .long 1802404272 + .long 1081483974 + .long 1761159654 + .long 1025358045 + .long 3523541100 + .long 1081483966 + .long 1227029918 + .long 1022400056 + .long 1070371174 + .long 1081483959 + .long 1017266216 + .long 1025927327 + .long 3031940236 + .long 1081483951 + .long 541289881 + .long 3173823840 + .long 817434636 + .long 1081483944 + .long 827704132 + .long 1025095119 + .long 3015919542 + .long 1081483936 + .long 12934210 + .long 3172513362 + .long 1036600450 + .long 1081483929 + .long 1022949985 + .long 3172215173 + .long 3468561396 + .long 1081483921 + .long 217728403 + .long 1020883592 + .long 1721026464 + .long 1081483914 + .long 1773946939 + .long 1027063347 + .long 88130720 + .long 1081483907 + .long 3351615536 + .long 3172077507 + .long 2864018200 + .long 1081483899 + .long 4106838151 + .long 3174156261 + .long 1457939880 + .long 1081483892 + .long 2465439606 + .long 3172344168 + .long 164057338 + .long 1081483885 + .long 657024829 + .long 1026968941 + .long 3276540740 + .long 1081483877 + .long 239284496 + .long 1025773300 + .long 2204666832 + .long 1081483870 + .long 563503993 + .long 3172683562 + .long 1242622588 + .long 1081483863 + .long 610254749 + .long 3174232732 + .long 389635916 + .long 1081483856 + .long 1002592152 + .long 1020145289 + .long 3939910132 + .long 1081483848 + .long 3079709802 + .long 1025793649 + .long 3302754668 + .long 1081483841 + .long 4156588929 + .long 3174405388 + .long 2772388732 + .long 1081483834 + .long 2177005711 + .long 3173706385 + .long 2348072008 + .long 1081483827 + .long 430264461 + .long 3174137709 + .long 2029071860 + .long 1081483820 + .long 3379887614 + .long 1025826683 + .long 1814663212 + .long 1081483813 + .long 1712456239 + .long 1026917505 + .long 1704128456 + .long 1081483806 + .long 3085449310 + .long 1022564341 + .long 1696757342 + .long 1081483799 + .long 1141334958 + .long 3171815944 + .long 1791846876 + .long 1081483792 + .long 1462201563 + .long 1025647829 + .long 1988701228 + .long 1081483785 + .long 140047506 + .long 3174122852 + .long 2286631636 + .long 1081483778 + .long 2759845912 + .long 1024469925 + .long 2684956298 + .long 1081483771 + .long 804042514 + .long 1026845100 + .long 3183000296 + .long 1081483764 + .long 3646267136 + .long 3171049236 + .long 3780095494 + .long 1081483757 + .long 2796072414 + .long 1025179136 + .long 180613146 + .long 1081483751 + .long 2935558853 + .long 1026289947 + .long 973833004 + .long 1081483744 + .long 3867040372 + .long 3174062522 + .long 1864139448 + .long 1081483737 + .long 3192294445 + .long 1024114853 + .long 2850890576 + .long 1081483730 + .long 2309059177 + .long 1026558495 + .long 3933450840 + .long 1081483723 + .long 3300904614 + .long 3173180909 + .long 816223656 + .long 1081483717 + .long 2836209699 + .long 1026670938 + .long 2088520500 + .long 1081483710 + .long 3053174336 + .long 3174287073 + .long 3454757072 + .long 1081483703 + .long 875601420 + .long 1025878424 + .long 619355076 + .long 1081483697 + .long 4096202184 + .long 1026024994 + .long 2171644060 + .long 1081483690 + .long 2316702776 + .long 3172256416 + .long 3816057542 + .long 1081483683 + .long 3057023477 + .long 3173172612 + .long 1257034828 + .long 1081483677 + .long 2024148590 + .long 1026183907 + .long 3083922828 + .long 1081483670 + .long 3658022801 + .long 3174540653 + .long 706204916 + .long 1081483664 + .long 965620747 + .long 3174139185 + .long 2713239208 + .long 1081483657 + .long 3558523119 + .long 3173414325 + .long 514520144 + .long 1081483651 + .long 2031819201 + .long 1024415865 + .long 2699416774 + .long 1081483644 + .long 2356933624 + .long 3174155910 + .long 677434328 + .long 1081483638 + .long 62190434 + .long 1027016638 + .long 3037952504 + .long 1081483631 + .long 3933781504 + .long 1025915529 + .long 1190487056 + .long 1081483625 + .long 2941696762 + .long 1025734775 + .long 3724428072 + .long 1081483618 + .long 2414317168 + .long 3170887182 + .long 2049301558 + .long 1081483612 + .long 2475288969 + .long 3174544243 + .long 459540440 + .long 1081483606 + .long 2871120870 + .long 3173072625 + .long 3249582612 + .long 1081483599 + .long 3658024676 + .long 3173912579 + .long 1828968996 + .long 1081483593 + .long 3145428063 + .long 1025702909 + .long 492147244 + .long 1081483587 + .long 3377090674 + .long 1025855275 + .long 3533569804 + .long 1081483580 + .long 441975505 + .long 3174521119 + .long 2362791964 + .long 1081483574 + .long 2700361953 + .long 1024904554 + .long 1274275566 + .long 1081483568 + .long 384688735 + .long 1024271063 + .long 267519784 + .long 1081483562 + .long 3294550047 + .long 1024123281 + .long 3636995640 + .long 1081483555 + .long 1629023504 + .long 3173808292 + .long 2792276776 + .long 1081483549 + .long 2896290296 + .long 1023457608 + .long 2027843168 + .long 1081483543 + .long 4214876422 + .long 3173347505 + .long 1343211900 + .long 1081483537 + .long 2089044909 + .long 1026320237 + .long 737904392 + .long 1081483531 + .long 1248769281 + .long 1026719018 + .long 211446364 + .long 1081483525 + .long 3287536014 + .long 1027064288 + .long 4058335068 + .long 1081483518 + .long 139482549 + .long 3171419957 + .long 3688170062 + .long 1081483512 + .long 2409197073 + .long 3174045711 + .long 3395456928 + .long 1081483506 + .long 469604718 + .long 3170908568 + .long 3179738046 + .long 1081483500 + .long 252575166 + .long 3173898937 + .long 3040559844 + .long 1081483494 + .long 659008259 + .long 3173067756 + .long 2977472740 + .long 1081483488 + .long 2489152120 + .long 1026987818 + .long 2990031104 + .long 1081483482 + .long 1288476519 + .long 3174460243 + .long 3077793216 + .long 1081483476 + .long 1544468634 + .long 3174466384 + .long 3240321200 + .long 1081483470 + .long 1563709080 + .long 1022000721 + .long 3477181002 + .long 1081483464 + .long 2370511724 + .long 3174484932 + .long 3787942340 + .long 1081483458 + .long 1487230717 + .long 3173625849 + .long 4172178648 + .long 1081483452 + .long 2208332257 + .long 3172980377 + .long 334499754 + .long 1081483447 + .long 3734805764 + .long 3173286476 + .long 864421012 + .long 1081483441 + .long 3848175750 + .long 1026823789 + .long 1466559484 + .long 1081483435 + .long 3339650886 + .long 1026799228 + .long 2140503092 + .long 1081483429 + .long 2587112486 + .long 1025074103 + .long 2885843270 + .long 1081483423 + .long 4237329462 + .long 1026571343 + .long 3702174928 + .long 1081483417 + .long 928919292 + .long 3173697437 + .long 294129124 + .long 1081483412 + .long 3350657575 + .long 3169758933 + .long 1251242194 + .long 1081483406 + .long 703498847 + .long 3173578839 + .long 2278151956 + .long 1081483400 + .long 1741773245 + .long 3169646323 + .long 3374466840 + .long 1081483394 + .long 938088363 + .long 3174103745 + .long 244831272 + .long 1081483389 + .long 1870507923 + .long 1024486077 + .long 1478794808 + .long 1081483383 + .long 3798424972 + .long 1026574662 + .long 2781008336 + .long 1081483377 + .long 1376042227 + .long 3171831111 + .long 4151093216 + .long 1081483371 + .long 516241188 + .long 1026864009 + .long 1293706648 + .long 1081483366 + .long 1238744632 + .long 3164368610 + .long 2798410838 + .long 1081483360 + .long 534941416 + .long 3172335234 + .long 74901872 + .long 1081483355 + .long 4279792400 + .long 3172103338 + .long 1712748064 + .long 1081483349 + .long 1565180338 + .long 1018613718 + .long 3416618846 + .long 1081483343 + .long 3951527485 + .long 3168909417 + .long 891186624 + .long 1081483338 + .long 3344344018 + .long 1024361841 + .long 2726028632 + .long 1081483332 + .long 1292300217 + .long 3174285210 + .long 330855832 + .long 1081483327 + .long 3519999099 + .long 1026857199 + .long 2295251240 + .long 1081483321 + .long 4255457731 + .long 1024555694 + .long 28931548 + .long 1081483316 + .long 1490990106 + .long 1024547962 + .long 2121485436 + .long 1081483310 + .long 3260941522 + .long 3172283917 + .long 4277602488 + .long 1081483304 + .long 246767963 + .long 1026252459 + .long 2201975040 + .long 1081483299 + .long 128194825 + .long 1026112424 + .long 189232752 + .long 1081483294 + .long 363902483 + .long 3169513578 + .long 2534007978 + .long 1081483288 + .long 3008515840 + .long 3172261022 + .long 646033852 + .long 1081483283 + .long 352511539 + .long 3170570563 + .long 3114915334 + .long 1081483277 + .long 1843039765 + .long 1026777816 + .long 1350390812 + .long 1081483272 + .long 946690324 + .long 3173265177 + .long 3942070448 + .long 1081483266 + .long 3545145670 + .long 1022546257 + .long 2299697768 + .long 1081483261 + .long 1496129287 + .long 1023820421 + .long 717920726 + .long 1081483256 + .long 3170447711 + .long 1026758832 + .long 3491389776 + .long 1081483250 + .long 3744391389 + .long 3173610490 + .long 2029855968 + .long 1081483245 + .long 394239962 + .long 3173947840 + .long 627974684 + .long 1081483240 + .long 4224315822 + .long 3174184559 + .long 3580403740 + .long 1081483234 + .long 2728751382 + .long 3174034570 + .long 2296901464 + .long 1081483229 + .long 1826853394 + .long 1026771661 + .long 1072130448 + .long 1081483224 + .long 976251207 + .long 1023454847 + .long 4200755644 + .long 1081483218 + .long 3540660088 + .long 3173642356 + .long 3092542436 + .long 1081483213 + .long 642222050 + .long 3174357226 + .long 2042160404 + .long 1081483208 + .long 4271938163 + .long 1024746297 + .long 1049314112 + .long 1081483203 + .long 2763050982 + .long 3171347092 + .long 113710388 + .long 1081483198 + .long 3792557536 + .long 1023308621 + .long 3530025584 + .long 1081483192 + .long 311855242 + .long 1025741510 + .long 2708036380 + .long 1081483187 + .long 246870760 + .long 3174242823 + .long 1942423536 + .long 1081483182 + .long 3741324184 + .long 1024230514 + .long 1232902676 + .long 1081483177 + .long 738314997 + .long 1025672705 + .long 579191580 + .long 1081483172 + .long 2156805174 + .long 1024422082 + .long 4275977444 + .long 1081483166 + .long 1311555958 + .long 3174065520 + .long 3733047680 + .long 1081483161 + .long 3764263691 + .long 3174151698 + .long 3245093668 + .long 1081483156 + .long 3869296466 + .long 3171928183 + .long 2811841556 + .long 1081483151 + .long 690806523 + .long 1025267317 + .long 2433019534 + .long 1081483146 + .long 2145634608 + .long 1026057800 + .long 2108357812 + .long 1081483141 + .long 3978517915 + .long 1027003985 + .long 1837588600 + .long 1081483136 + .long 1798363739 + .long 1024820509 + .long 1620446092 + .long 1081483131 + .long 1050593265 + .long 3173881020 + .long 1456666440 + .long 1081483126 + .long 992424745 + .long 3172306519 + .long 1345987738 + .long 1081483121 + .long 3429191021 + .long 3172872803 + .long 1288150008 + .long 1081483116 + .long 80339595 + .long 1025975133 + .long 1282895172 + .long 1081483111 + .long 1099626523 + .long 3173274851 + .long 1329967044 + .long 1081483106 + .long 37527030 + .long 1026870817 + .long 1429111296 + .long 1081483101 + .long 4119125584 + .long 3165241791 + .long 1580075462 + .long 1081483096 + .long 2270013714 + .long 1025817458 + .long 1782608896 + .long 1081483091 + .long 3203429680 + .long 1025496563 + .long 2036462774 + .long 1081483086 + .long 1148983882 + .long 1026950273 + .long 2341390064 + .long 1081483081 + .long 4068830577 + .long 1025284407 + .long 2697145518 + .long 1081483076 + .long 1923810050 + .long 1026721061 + .long 3103485644 + .long 1081483071 + .long 3762557359 + .long 1025074748 + .long 3560168702 + .long 1081483066 + .long 253913897 + .long 3171090011 + .long 4066954676 + .long 1081483061 + .long 1497751894 + .long 3172734642 + .long 328637968 + .long 1081483057 + .long 3363029157 + .long 3172289292 + .long 934916564 + .long 1081483052 + .long 3896109434 + .long 1024906782 + .long 1590588242 + .long 1081483047 + .long 570002366 + .long 3166515828 + .long 2295419742 + .long 1081483042 + .long 1386275374 + .long 1027010807 + .long 3049179448 + .long 1081483037 + .long 352253063 + .long 1025583264 + .long 3851637384 + .long 1081483032 + .long 606289825 + .long 1026218875 + .long 407597888 + .long 1081483028 + .long 2091542702 + .long 1025209018 + .long 1306768794 + .long 1081483023 + .long 1253650337 + .long 1026509039 + .long 2253957632 + .long 1081483018 + .long 4231155942 + .long 1026471430 + .long 3248940804 + .long 1081483013 + .long 3016566426 + .long 1026594534 + .long 4291496268 + .long 1081483008 + .long 2473443710 + .long 3172512713 + .long 1086436232 + .long 1081483004 + .long 3621506366 + .long 1025637579 + .long 2223476316 + .long 1081482999 + .long 1546124245 + .long 3173819367 + .long 3407431776 + .long 1081482994 + .long 906095450 + .long 3170941588 + .long 343119360 + .long 1081482990 + .long 610131836 + .long 3173841951 + .long 1620259200 + .long 1081482985 + .long 989279629 + .long 3174040346 + .long 2943671008 + .long 1081482980 + .long 3822867778 + .long 1024701039 + .long 18175958 + .long 1081482976 + .long 1622666714 + .long 3174118882 + .long 1433498564 + .long 1081482971 + .long 2171198509 + .long 1026059907 + .long 2894462876 + .long 1081482966 + .long 348671320 + .long 1025985459 + .long 105894376 + .long 1081482962 + .long 3585216657 + .long 3171231928 + .long 1657521836 + .long 1081482957 + .long 3446444124 + .long 1025447652 + .long 3254173534 + .long 1081482952 + .long 1463686921 + .long 3170751639 + .long 600679136 + .long 1081482948 + .long 3946680458 + .long 3172628318 + .long 2286771562 + .long 1081482943 + .long 2898292254 + .long 3173607956 + .long 4017283204 + .long 1081482938 + .long 378425754 + .long 1024364086 + .long 1497047798 + .long 1081482934 + .long 2208076810 + .long 1021550089 + .long 3315802306 + .long 1081482929 + .long 518466868 + .long 3170182275 + .long 883415824 + .long 1081482925 + .long 2262926030 + .long 3173232842 + .long 2789627944 + .long 1081482920 + .long 1857642286 + .long 3174551967 + .long 444310372 + .long 1081482916 + .long 312835987 + .long 1025199986 + .long 2437205282 + .long 1081482911 + .long 1932061261 + .long 3169727498 + .long 178186948 + .long 1081482907 + .long 2992653487 + .long 1024639967 + .long 2257000084 + .long 1081482902 + .long 2345620679 + .long 1020767444 + .long 83521478 + .long 1081482898 + .long 1865371320 + .long 3168909500 + .long 2247498342 + .long 1081482893 + .long 3458599018 + .long 1024937135 + .long 158809936 + .long 1081482889 + .long 2726616459 + .long 1023093864 + .long 2407205926 + .long 1081482884 + .long 3206755402 + .long 1022531411 + .long 402568002 + .long 1081482880 + .long 3974974073 + .long 3174453501 + .long 2734648240 + .long 1081482875 + .long 3634353085 + .long 3173855629 + .long 813330716 + .long 1081482871 + .long 1275754339 + .long 3172404325 + .long 3228369874 + .long 1081482866 + .long 2459942624 + .long 1026394723 + .long 1389652140 + .long 1081482862 + .long 3894317897 + .long 1022143780 + .long 3886934286 + .long 1081482857 + .long 2409656812 + .long 3174419085 + .long 2130105044 + .long 1081482853 + .long 399990141 + .long 3174164192 + .long 413956172 + .long 1081482849 + .long 1897372421 + .long 3171133891 + .long 3033280560 + .long 1081482844 + .long 2252287291 + .long 3171644317 + .long 1397970330 + .long 1081482840 + .long 1092600795 + .long 3174474273 + .long 4097787896 + .long 1081482835 + .long 636054898 + .long 1024727874 + .long 2542627584 + .long 1081482831 + .long 893978442 + .long 3170953397 + .long 1027286708 + .long 1081482827 + .long 1310200238 + .long 3172082428 + .long 3846563656 + .long 1081482822 + .long 1929717761 + .long 3174303818 + .long 2410356004 + .long 1081482818 + .long 2079265613 + .long 3173603756 + .long 1013464276 + .long 1081482814 + .long 138096117 + .long 3172000995 + .long 3950690054 + .long 1081482809 + .long 3014271250 + .long 1025494367 + .long 2631934076 + .long 1081482805 + .long 1516771853 + .long 1025097570 + .long 1352000006 + .long 1081482801 + .long 205057013 + .long 1025200619 + .long 110725238 + .long 1081482797 + .long 4146523933 + .long 3174010180 + .long 3202915484 + .long 1081482792 + .long 1438530950 + .long 3172691622 + .long 2038475574 + .long 1081482788 + .long 3556059382 + .long 1022109351 + .long 912213234 + .long 1081482784 + .long 3429560596 + .long 3174416385 + .long 4118937184 + .long 1081482779 + .long 21605584 + .long 3173029554 + .long 3068555236 + .long 1081482775 + .long 812212829 + .long 3174509580 + .long 2055878076 + .long 1081482771 + .long 3822203782 + .long 3172686714 + .long 1080750056 + .long 1081482767 + .long 2015620057 + .long 1020790313 + .long 143016496 + .long 1081482763 + .long 497128390 + .long 3173548042 + .long 3537490964 + .long 1081482758 + .long 2709103148 + .long 3174501920 + .long 2674086084 + .long 1081482754 + .long 567743127 + .long 3172450622 + .long 1847617306 + .long 1081482750 + .long 2788161622 + .long 3174369501 + .long 1057933720 + .long 1081482746 + .long 3612383344 + .long 3174048564 + .long 304885332 + .long 1081482742 + .long 2310781260 + .long 3173370133 + .long 3883290364 + .long 1081482737 + .long 2417832061 + .long 1025537953 + .long 3203066056 + .long 1081482733 + .long 2228257300 + .long 1023509958 + .long 2559032440 + .long 1081482729 + .long 3413175845 + .long 1026737228 + .long 1951043140 + .long 1081482725 + .long 1019314226 + .long 1026188380 + .long 1378952672 + .long 1081482721 + .long 1939366236 + .long 3173263748 + .long 842616428 + .long 1081482717 + .long 2826522465 + .long 1026654019 + .long 341890668 + .long 1081482713 + .long 510868637 + .long 3173428756 + .long 4171599824 + .long 1081482708 + .long 2348490647 + .long 1026914531 + .long 3741667284 + .long 1081482704 + .long 1992702016 + .long 3171098997 + .long 3346919190 + .long 1081482700 + .long 1915735778 + .long 3171038930 + .long 2987215220 + .long 1081482696 + .long 708866615 + .long 1023303854 + .long 2662415896 + .long 1081482692 + .long 1533252285 + .long 1025288173 + .long 2372382570 + .long 1081482688 + .long 3419174070 + .long 3173768463 + .long 2116977420 + .long 1081482684 + .long 2278659151 + .long 1025060560 + .long 1896063436 + .long 1081482680 + .long 2525715938 + .long 3169189535 + .long 1709504428 + .long 1081482676 + .long 1253833294 + .long 1025773641 + .long 1557165004 + .long 1081482672 + .long 3815681768 + .long 3168831918 + .long 1438910576 + .long 1081482668 + .long 3615821994 + .long 1021226882 + .long 1354607344 + .long 1081482664 + .long 3031132768 + .long 1026704265 + .long 1304122296 + .long 1081482660 + .long 997386977 + .long 3171874671 + .long 1287323204 + .long 1081482656 + .type static_const_table,@object + .size static_const_table,4384 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atanhf_wmt.S b/external/sgx_libm/ia32/atanhf_wmt.S new file mode 100644 index 0000000000..9a19241900 --- /dev/null +++ b/external/sgx_libm/ia32/atanhf_wmt.S @@ -0,0 +1,1328 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanhf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin atanhf + .text + .align 16,0x90 + .globl atanhf +atanhf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 52(%esp) + call static_func + movl %eax, %ebx + movss 128(%esp), %xmm0 + movl 128(%esp), %eax + movss %xmm0, 16(%esp) + andl $2147483647, %eax + cmpl $1065353216, %eax + jge .L_2TAG_PACKET_0.0.3 + cmpl $1056964608, %eax + jl .L_2TAG_PACKET_1.0.3 + pshufd $0, %xmm0, %xmm0 + cvtps2pd %xmm0, %xmm0 + xorpd 176(%ebx), %xmm0 + addpd 112(%ebx), %xmm0 + movapd %xmm0, %xmm1 + psrlq $41, %xmm0 + pextrw $0, %xmm0, %eax + pextrw $4, %xmm0, %ecx + psrlq $11, %xmm0 + movhlps %xmm0, %xmm2 + andl $2040, %eax + andl $2040, %ecx + movq 192(%ebx,%ecx), %xmm3 + subsd 192(%ebx,%eax), %xmm3 + movq 2240(%ebx,%eax), %xmm4 + movhpd 2240(%ebx,%ecx), %xmm4 + psubd %xmm0, %xmm2 + movd %xmm2, %eax + movapd 80(%ebx), %xmm5 + cvtsi2sdl %eax, %xmm2 + mulsd 96(%ebx), %xmm2 + andpd 128(%ebx), %xmm1 + orpd 112(%ebx), %xmm1 + mulpd %xmm4, %xmm1 + subpd 112(%ebx), %xmm1 + mulpd %xmm1, %xmm5 + addpd 64(%ebx), %xmm5 + mulpd %xmm1, %xmm5 + mulpd %xmm1, %xmm5 + addpd %xmm5, %xmm1 + movhlps %xmm1, %xmm0 + addsd %xmm3, %xmm2 + subsd %xmm1, %xmm0 + addsd %xmm2, %xmm0 + psubw 160(%ebx), %xmm0 + movq %xmm0, (%esp) + movhpd %xmm0, 8(%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + cmpl $838860800, %eax + jl .L_2TAG_PACKET_3.0.3 + flds 16(%esp) + flds 16(%esp) + fxch + fmul %st(0), %st + fldl 56(%ebx) + fld %st(1) + fxch %st(2) + fmul %st(0), %st + fldl 48(%ebx) + fxch + fmul %st, %st(2) + fmul %st, %st(1) + fxch %st(2) + faddl 40(%ebx) + fxch + faddl 32(%ebx) + fxch + fmul %st(2), %st + fxch + fmul %st(2), %st + fxch + faddl 24(%ebx) + fxch + faddl 16(%ebx) + fxch + fmul %st(2), %st + fxch + fmul %st(2), %st + fxch + faddl 8(%ebx) + fxch + faddl (%ebx) + fxch + fmulp %st, %st(2) + fmulp %st, %st(2) + faddp + fmul %st(1), %st + faddp + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + andl $2139095040, %eax + je .L_2TAG_PACKET_4.0.3 + flds 16(%esp) + fld1 + fadd %st(1), %st + fstps (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + flds 16(%esp) + fld %st(0) + fmul %st(1), %st + fstps (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + je .L_2TAG_PACKET_5.0.3 + cmpl $2139095040, %eax + jg .L_2TAG_PACKET_6.0.3 + xorps %xmm0, %xmm0 + mulss 144(%ebx), %xmm0 + movss %xmm0, (%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $133, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_5.0.3: + xorps %xmm1, %xmm1 + divss %xmm1, %xmm0 + movss %xmm0, (%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $134, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + addss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_2.0.3: + movl 52(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type atanhf,@function + .size atanhf,.-atanhf + .data +# -- End atanhf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1370222587 + .long 1070945621 + .long 2417412325 + .long 1070176668 + .long 2969394279 + .long 1069697198 + .long 1510013680 + .long 1069319176 + .long 1692635884 + .long 1068924049 + .long 3693828232 + .long 1069068511 + .long 4025937356 + .long 3211315437 + .long 476477515 + .long 1070012413 + .long 3879088107 + .long 3219128321 + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .long 1754324240 + .long 1070945626 + .long 4277811695 + .long 1072049730 + .long 4277811695 + .long 1072049730 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .long 0 + .long 1048576 + .long 0 + .long 1048576 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 1440057502 + .long 1063257089 + .long 341338964 + .long 1064833554 + .long 4184355568 + .long 1065621801 + .long 2227658503 + .long 1066152307 + .long 449262470 + .long 1066510009 + .long 1570422842 + .long 1066777242 + .long 121841140 + .long 1067045544 + .long 630691842 + .long 1067281191 + .long 2711485097 + .long 1067500943 + .long 2026622491 + .long 1067619660 + .long 766078039 + .long 1067755853 + .long 4074027864 + .long 1067875476 + .long 3056660584 + .long 1067995528 + .long 3195252556 + .long 1068133258 + .long 116861598 + .long 1068254238 + .long 325086471 + .long 1068375655 + .long 296456961 + .long 1068497513 + .long 2623383041 + .long 1068559379 + .long 1681725707 + .long 1068620754 + .long 2231263004 + .long 1068682354 + .long 2815553124 + .long 1068744181 + .long 2057310944 + .long 1068806237 + .long 2095798018 + .long 1068859611 + .long 2302040698 + .long 1068922096 + .long 745232013 + .long 1068984815 + .long 659581512 + .long 1069047769 + .long 1566132617 + .long 1069101918 + .long 550036981 + .long 1069165314 + .long 2887419564 + .long 1069219844 + .long 1990183441 + .long 1069283688 + .long 3220050856 + .long 1069338605 + .long 1669613218 + .long 1069393703 + .long 2145455994 + .long 1069458213 + .long 4275830246 + .long 1069513705 + .long 1392453108 + .long 1069558451 + .long 1469915213 + .long 1069586382 + .long 2183652476 + .long 1069619086 + .long 2109656884 + .long 1069647220 + .long 636640577 + .long 1069675449 + .long 510517079 + .long 1069703773 + .long 210141498 + .long 1069732193 + .long 2537624622 + .long 1069760709 + .long 1733817001 + .long 1069789323 + .long 137854980 + .long 1069813243 + .long 3905576828 + .long 1069842036 + .long 4131810788 + .long 1069870929 + .long 3760956694 + .long 1069899922 + .long 1473082581 + .long 1069929016 + .long 926113142 + .long 1069953338 + .long 3669742467 + .long 1069982617 + .long 3711755290 + .long 1070007095 + .long 311386407 + .long 1070036564 + .long 705364525 + .long 1070066136 + .long 1973375279 + .long 1070090859 + .long 3589645072 + .long 1070115655 + .long 2425772059 + .long 1070145508 + .long 1074899574 + .long 1070170467 + .long 118003300 + .long 1070200516 + .long 691310403 + .long 1070225639 + .long 3273036717 + .long 1070250837 + .long 1226436560 + .long 1070276112 + .long 2481153995 + .long 1070306542 + .long 3227997535 + .long 1070331985 + .long 1421812646 + .long 1070357506 + .long 3386588242 + .long 1070383104 + .long 2580043380 + .long 1070408781 + .long 1068692560 + .long 1070434537 + .long 938143489 + .long 1070460372 + .long 4293333010 + .long 1070486286 + .long 373864817 + .long 1070512282 + .long 4208958430 + .long 1070538357 + .long 783121462 + .long 1070564515 + .long 870975437 + .long 1070590754 + .long 3338886172 + .long 1070606585 + .long 3772343130 + .long 1070619787 + .long 2408245143 + .long 1070630379 + .long 3811383569 + .long 1070643656 + .long 1622638721 + .long 1070656976 + .long 1290798655 + .long 1070670338 + .long 2457529556 + .long 1070681058 + .long 2398194399 + .long 1070694497 + .long 3190801979 + .long 1070707979 + .long 3352241197 + .long 1070718796 + .long 1829681364 + .long 1070732357 + .long 2568927817 + .long 1070743237 + .long 2676427515 + .long 1070756877 + .long 2882402820 + .long 1070767821 + .long 44944622 + .long 1070781542 + .long 2957945300 + .long 1070792550 + .long 1261787704 + .long 1070806352 + .long 1589923677 + .long 1070817426 + .long 3274931829 + .long 1070828529 + .long 1999843716 + .long 1070842450 + .long 1673619518 + .long 1070853620 + .long 601221319 + .long 1070864820 + .long 3763576649 + .long 1070876049 + .long 1974923437 + .long 1070890129 + .long 1096100617 + .long 1070901427 + .long 2424897952 + .long 1070912755 + .long 2376202600 + .long 1070924114 + .long 1665651958 + .long 1070935504 + .long 1014729354 + .long 1070946925 + .long 722545241 + .long 1070961245 + .long 1800682930 + .long 1070972736 + .long 1029453230 + .long 1070984259 + .long 3450874911 + .long 1070995813 + .long 1228255906 + .long 1071007400 + .long 3711032981 + .long 1071019018 + .long 3075102917 + .long 1071030669 + .long 92696812 + .long 1071042353 + .long 3897749690 + .long 1071051136 + .long 1907922160 + .long 1071062877 + .long 4023807324 + .long 1071074650 + .long 2452345726 + .long 1071086457 + .long 2292128226 + .long 1071098297 + .long 58635942 + .long 1071110171 + .long 864186929 + .long 1071122078 + .long 3555691467 + .long 1071131030 + .long 2003684347 + .long 1071142997 + .long 1479703759 + .long 1071154998 + .long 2537208015 + .long 1071164021 + .long 3699909861 + .long 1071176082 + .long 3934098706 + .long 1071188178 + .long 3885764182 + .long 1071197273 + .long 1357790931 + .long 1071209431 + .long 295956059 + .long 1071221624 + .long 4080877676 + .long 1071230791 + .long 202970280 + .long 1071243047 + .long 3977575845 + .long 1071252261 + .long 35977849 + .long 1071264580 + .long 1585496963 + .long 1071273842 + .long 375247257 + .long 1071286224 + .long 1812199574 + .long 1071295534 + .long 1876912769 + .long 1071307980 + .long 1051846544 + .long 1071317339 + .long 979589448 + .long 1071329850 + .long 71706889 + .long 1071339258 + .long 2790898835 + .long 1071351834 + .long 4013797733 + .long 1071361291 + .long 2541231151 + .long 1071370770 + .long 921733145 + .long 1071383442 + .long 508375805 + .long 1071392971 + .long 3091669954 + .long 1071402521 + .long 3343209673 + .long 1071415289 + .long 1693047557 + .long 1071424891 + .long 173861808 + .long 1071434515 + .long 3515822703 + .long 1071444160 + .long 1974837761 + .long 1071457056 + .long 1189018219 + .long 1071466754 + .long 2441946573 + .long 1071476474 + .long 1887102255 + .long 1071486217 + .long 4271031636 + .long 1071495982 + .long 876995759 + .long 1071509039 + .long 438773454 + .long 1071518858 + .long 172621632 + .long 1071528700 + .long 544035182 + .long 1071538565 + .long 2021801298 + .long 1071548453 + .long 783063308 + .long 1071558365 + .long 1598254051 + .long 1071568300 + .long 651258553 + .long 1071578259 + .long 2719315456 + .long 1071588241 + .long 3993180461 + .long 1071598247 + .long 667093936 + .long 1071608278 + .long 1823716217 + .long 1071618332 + .long 3664357648 + .long 1071628410 + .long 2393914686 + .long 1071638513 + .long 1405419566 + .long 1071646656 + .long 563652001 + .long 1071651732 + .long 1074554091 + .long 1071656820 + .long 3195405229 + .long 1071661920 + .long 2890399284 + .long 1071667033 + .long 420597586 + .long 1071672159 + .long 87278952 + .long 1071675583 + .long 1753119502 + .long 1071680729 + .long 1959759897 + .long 1071685888 + .long 975389815 + .long 1071691060 + .long 3365155278 + .long 1071696244 + .long 811309190 + .long 1071701442 + .long 1269811480 + .long 1071704914 + .long 1108583542 + .long 1071710133 + .long 1034517919 + .long 1071715365 + .long 1327340287 + .long 1071720610 + .long 1388251237 + .long 1071724114 + .long 1488234797 + .long 1071729381 + .long 2711385691 + .long 1071734661 + .long 952179194 + .long 1071738189 + .long 3255685427 + .long 1071743491 + .long 3159039803 + .long 1071748807 + .long 951558972 + .long 1071752359 + .long 3234424125 + .long 1071757697 + .long 3904573547 + .long 1071763049 + .long 2648729924 + .long 1071766625 + .long 2729250212 + .long 1071772000 + .long 2000712574 + .long 1071777389 + .long 3125257108 + .long 1071780989 + .long 3160324803 + .long 1071786401 + .long 2216316974 + .long 1071790017 + .long 3875016090 + .long 1071795452 + .long 1439520610 + .long 1071799084 + .long 1298103361 + .long 1071804543 + .long 2217517956 + .long 1071810016 + .long 1191753587 + .long 1071813673 + .long 1728773900 + .long 1071819170 + .long 747445441 + .long 1071822843 + .long 1670772213 + .long 1071826522 + .long 1471209283 + .long 1071832053 + .long 3287905877 + .long 1071835748 + .long 594038131 + .long 1071841304 + .long 3920147917 + .long 1071845015 + .long 3957142762 + .long 1071850595 + .long 826988438 + .long 1071854324 + .long 242509008 + .long 1071859929 + .long 4173610350 + .long 1071863673 + .long 2518313625 + .long 1071867425 + .long 2671523434 + .long 1071873065 + .long 387544807 + .long 1071876834 + .long 1470497767 + .long 1071880609 + .long 4269259217 + .long 1071886284 + .long 1345663925 + .long 1071890077 + .long 2159323299 + .long 1071893876 + .long 957937516 + .long 1071899588 + .long 2994656967 + .long 1071903404 + .long 556124819 + .long 1071907228 + .long 1631098658 + .long 1071912976 + .long 1368257861 + .long 1071916817 + .long 1309849279 + .long 1071920665 + .long 1567156841 + .long 1071924520 + .long 1179420986 + .long 1071930316 + .long 569448444 + .long 1071934189 + .long 669557459 + .long 1071938069 + .long 1593834700 + .long 1071941956 + .long 3166083125 + .long 1071947800 + .long 211641815 + .long 1071951706 + .long 2780675719 + .long 1071955618 + .long 2400234567 + .long 1071959538 + .long 3482927192 + .long 1071963465 + .long 1852089988 + .long 1071967400 + .long 1020849000 + .long 1071973316 + .long 1718090839 + .long 1071977269 + .long 121152472 + .long 1071981230 + .long 646346839 + .long 1071985198 + .long 3415709705 + .long 1071989173 + .long 4257004898 + .long 1071993156 + .long 3293664199 + .long 1071997147 + .long 649825382 + .long 1072001146 + .long 248887552 + .long 1072007158 + .long 2541522737 + .long 1072011175 + .long 3593780107 + .long 1072015200 + .long 3533041935 + .long 1072019233 + .long 2487426809 + .long 1072023274 + .long 585795318 + .long 1072027323 + .long 2252723088 + .long 1072031379 + .long 3323604690 + .long 1072035443 + .long 3929561382 + .long 1072039515 + .long 4202479723 + .long 1072043595 + .long 4275017539 + .long 1072047683 + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .type static_const_table,@object + .size static_const_table,4288 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atanhl.S b/external/sgx_libm/ia32/atanhl.S new file mode 100644 index 0000000000..cd538f8a50 --- /dev/null +++ b/external/sgx_libm/ia32/atanhl.S @@ -0,0 +1,905 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanhl.c" + .text +..TXTST0: +# -- Begin atanhl + .text + .align 16,0x90 + .globl atanhl +atanhl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + movzwl 14(%esp), %edx + cmpl $16383, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jge ..B1.53 +..B1.4: + cmpl $16381, %eax + jge ..B1.46 +..B1.5: + cmpl $16376, %eax + jge ..B1.39 +..B1.6: + cmpl $16371, %eax + jge ..B1.32 +..B1.7: + cmpl $16365, %eax + jge ..B1.25 +..B1.8: + cmpl $16308, %eax + jge ..B1.18 +..B1.9: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.68 +..B1.10: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.11: + fldcw 12(%esp) +..B1.12: + movzwl 16(%ebp), %eax + movl $1, %esi + andl $32767, %eax +..B1.13: + testl %eax, %eax + jle ..B1.64 +..B1.14: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ebx) + fstpt (%esp) +..B1.15: + testl %esi, %esi + je ..B1.17 +..B1.16: + fldcw 14(%esp) +..B1.17: + fldt (%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.69 +..B1.19: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.20: + fldcw 12(%esp) +..B1.21: + movl $1, %eax +..B1.22: + fldt 8(%ebp) + testl %eax, %eax + fldt _Q3@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.24 +..B1.23: + fldcw 14(%esp) +..B1.24: + fldt (%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.70 +..B1.26: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.27: + fldcw 12(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_Q2@GOTOFF(%ebx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.31 +..B1.30: + fldcw 14(%esp) +..B1.31: + fldt (%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.71 +..B1.33: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.34: + fldcw 12(%esp) +..B1.35: + movl $1, %eax +..B1.36: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%ebx) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.38 +..B1.37: + fldcw 14(%esp) +..B1.38: + fldt (%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.72 +..B1.40: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.41: + fldcw 12(%esp) +..B1.42: + movl $1, %eax +..B1.43: + fldt 8(%ebp) + testl %eax, %eax + fldl _TWO_52H@GOTOFF(%ebx) + fmul %st(1), %st + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fstpt 16(%esp) + fldt 16(%esp) + fld %st(1) + fmul %st(1), %st + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fmul %st(0), %st + fld %st(0) + fadd %st(3), %st + fmul %st, %st(2) + fld %st(1) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + fmul %st(0), %st + fld %st(0) + fadd %st(3), %st + fldt 132+_Q@GOTOFF(%ebx) + fmul %st(1), %st + fldt 108+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 120+_Q@GOTOFF(%ebx) + fmul %st(2), %st + fldt 96+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_Q@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _Q@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 156+_Q@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(2) + fldt 144+_Q@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 32(%esp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fldt 16(%esp) + fld %st(0) + fldl _TWO_48H@GOTOFF(%ebx) + fadd %st, %st(3) + fsubrp %st, %st(3) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fldt 8(%ebp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(2) + fldt (%esp) + fmul %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.45 +..B1.44: + fldcw 14(%esp) +..B1.45: + fldt (%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.73 +..B1.47: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.48: + fldcw 12(%esp) +..B1.49: + movl $1, %ecx +..B1.50: + fldt 8(%ebp) + fldl _ones@GOTOFF(%ebx) + movzbl 17(%ebp), %edx + fld %st(0) + andl $128, %edx + fld %st(1) + shrl $7, %edx + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fldl _TWO_48H@GOTOFF(%ebx) + movzwl 8(%esp), %edi + fxch %st(4) + fmull _ones@GOTOFF(%ebx,%edx,8) + andl $-32768, %edi + fsubr %st, %st(2) + fld %st(2) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fsubr %st(2), %st + fsub %st(1), %st + fld %st(3) + fadd %st(1), %st + fxch %st(2) + fadd %st, %st(5) + fld %st(5) + fmul %st(7), %st + fadd %st, %st(6) + fsubrp %st, %st(6) + fxch %st(5) + fstpt 16(%esp) + fldt 16(%esp) + fsubr %st(3), %st + faddp %st, %st(5) + fld %st(1) + fdivr %st(3), %st + fmul %st, %st(6) + fld %st(0) + fadd %st(7), %st + fsubp %st, %st(7) + fxch %st(1) + fmul %st(6), %st + fld %st(1) + fsub %st(7), %st + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(4) + fmul %st(6), %st + fsubrp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fldt 16(%esp) + fadd %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 8(%ebp) + fldt 60+_P@GOTOFF(%ebx) + fldt 36+_P@GOTOFF(%ebx) + fldt 12+_P@GOTOFF(%ebx) + movzwl 16(%ebp), %eax + andl $32767, %eax + movl %eax, %esi + addl $-16383, %eax + negl %esi + addl $-2, %esi + andl $32767, %esi + orl %esi, %edi + movw %di, 8(%esp) + fldt (%esp) + movl 12(%ebp), %esi + shrl $23, %esi + fmul %st, %st(4) + fmulp %st, %st(5) + andl $255, %esi + movl %eax, 32(%esp) + fildl 32(%esp) + fxch %st(4) + fmuls __libm_rcp_table_256@GOTOFF(%ebx,%esi,4) + fxch %st(5) + fmuls __libm_rcp_table_256@GOTOFF(%ebx,%esi,4) + fxch %st(5) + faddl 8+_ones@GOTOFF(%ebx) + fld %st(0) + shll $4, %esi + fadd %st(6), %st + fld %st(0) + testl %ecx, %ecx + fmul %st(1), %st + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fstpt 8(%ebp) + fldt 48+_P@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _P@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fmul %st(2), %st + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fmulp %st, %st(3) + faddl 8+__libm_logl_table_256@GOTOFF(%ebx,%esi) + faddp %st, %st(3) + fxch %st(1) + faddl __libm_logl_table_256@GOTOFF(%esi,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + fmull halfs@GOTOFF(%ebx,%edx,8) + fstpt 16(%esp) + je ..B1.52 +..B1.51: + fldcw 14(%esp) +..B1.52: + fldt 16(%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.53: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.79 +..B1.54: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.55: + fldcw 12(%esp) +..B1.56: + movzwl 16(%ebp), %eax + movl $1, %edx + andl $32767, %eax +..B1.57: + cmpl $32767, %eax + jl ..B1.74 +..B1.58: + cmpl $-2147483648, 12(%ebp) + jne ..B1.60 +..B1.59: + cmpl $0, 8(%ebp) + je ..B1.74 +..B1.60: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx) + fstpt (%esp) +..B1.61: + testl %edx, %edx + je ..B1.63 +..B1.62: + fldcw 14(%esp) +..B1.63: + fldt (%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.64: + cmpl $0, 12(%ebp) + jne ..B1.66 +..B1.65: + cmpl $0, 8(%ebp) + je ..B1.67 +..B1.66: + fldt 8(%ebp) + fldt _small_value_80@GOTOFF(%ebx) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.67: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.15 +..B1.68: + xorl %esi, %esi + jmp ..B1.13 +..B1.69: + xorl %eax, %eax + jmp ..B1.22 +..B1.70: + xorl %eax, %eax + jmp ..B1.29 +..B1.71: + xorl %eax, %eax + jmp ..B1.36 +..B1.72: + xorl %eax, %eax + jmp ..B1.43 +..B1.73: + xorl %ecx, %ecx + jmp ..B1.50 +..B1.74: + cmpl $16383, %eax + jne ..B1.78 +..B1.75: + cmpl $-2147483648, 12(%ebp) + jne ..B1.78 +..B1.76: + cmpl $0, 8(%ebp) + jne ..B1.78 +..B1.77: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl _ones@GOTOFF(%ebx,%eax,8) + fdivl _zeros@GOTOFF(%ebx) + fstpt (%esp) + jmp ..B1.61 +..B1.78: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpt (%esp) + jmp ..B1.61 +..B1.79: + xorl %edx, %edx + jmp ..B1.57 + .align 16,0x90 + .type atanhl,@function + .size atanhl,.-atanhl + .data +# -- End atanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 8 +halfs: + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbfe00000 + .type halfs,@object + .size halfs,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q3: + .word 43691 + .word 45330 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 33124 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58478 + .word 29023 + .word 52648 + .word 52428 + .word 16380 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 43686 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 5258 + .word 52447 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 10439 + .word 34405 + .word 9349 + .word 37449 + .word 16380 + .word 0 + .word 25253 + .word 49895 + .word 32943 + .word 58261 + .word 16379 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 43101 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 4657 + .word 52441 + .word 52428 + .word 52428 + .word 16368 + .word 0 + .word 42633 + .word 18723 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 11223 + .word 36719 + .word 14563 + .word 58254 + .word 16379 + .word 0 + .word 64465 + .word 27664 + .word 35746 + .word 47662 + .word 16379 + .word 0 + .word 6969 + .word 8211 + .word 55486 + .word 40329 + .word 16379 + .word 0 + .word 15522 + .word 40807 + .word 33480 + .word 34952 + .word 16379 + .word 0 + .word 44124 + .word 7207 + .word 21918 + .word 61682 + .word 16378 + .word 0 + .word 13236 + .word 62073 + .word 35694 + .word 55158 + .word 16378 + .word 0 + .word 859 + .word 55468 + .word 55479 + .word 50356 + .word 16378 + .word 0 + .word 19186 + .word 33607 + .word 822 + .word 41715 + .word 16378 + .word 0 + .word 51623 + .word 9477 + .word 49456 + .word 61855 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52416 + .word 16380 + .word 0 + .type _Q,@object + .size _Q,168 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .type _P,@object + .size _P,72 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atanl.S b/external/sgx_libm/ia32/atanl.S new file mode 100644 index 0000000000..71ffec484f --- /dev/null +++ b/external/sgx_libm/ia32/atanl.S @@ -0,0 +1,732 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanl.c" + .text +..TXTST0: +# -- Begin atanl + .text + .align 16,0x90 + .globl atanl +atanl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $72, %esp +..B1.2: + fnstcw 38(%esp) +..B1.3: + movzbl 17(%ebp), %ecx + movzwl 16(%ebp), %eax + andl $128, %ecx + andl $32767, %eax + shrl $7, %ecx + movzwl 38(%esp), %ebx + cmpl $16394, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + jge ..B1.48 +..B1.4: + cmpl $16376, %eax + jge ..B1.38 +..B1.5: + cmpl $16371, %eax + jge ..B1.31 +..B1.6: + cmpl $16365, %eax + jge ..B1.24 +..B1.7: + cmpl $16308, %eax + jge ..B1.17 +..B1.8: + movl %ebx, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.68 +..B1.9: + orl $-64768, %ebx + movw %bx, 36(%esp) +..B1.10: + fldcw 36(%esp) +..B1.11: + movzwl 16(%ebp), %eax + movl $1, %ebx + andl $32767, %eax +..B1.12: + testl %eax, %eax + jle ..B1.64 +..B1.13: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%edx) + fmul %st(1), %st + fsubp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%edx) + fstpt (%esp) +..B1.14: + testl %ebx, %ebx + je ..B1.16 +..B1.15: + fldcw 38(%esp) +..B1.16: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.69 +..B1.18: + orl $-64768, %ebx + movw %bx, 36(%esp) +..B1.19: + fldcw 36(%esp) +..B1.20: + movl $1, %eax +..B1.21: + fldt 8(%ebp) + testl %eax, %eax + fldt _P2@GOTOFF(%edx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.23 +..B1.22: + fldcw 38(%esp) +..B1.23: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.24: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.70 +..B1.25: + orl $-64768, %ebx + movw %bx, 36(%esp) +..B1.26: + fldcw 36(%esp) +..B1.27: + movl $1, %eax +..B1.28: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%edx) + fmul %st(1), %st + fldt _P1@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.30 +..B1.29: + fldcw 38(%esp) +..B1.30: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.71 +..B1.32: + orl $-64768, %ebx + movw %bx, 36(%esp) +..B1.33: + fldcw 36(%esp) +..B1.34: + movl $1, %eax +..B1.35: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(2) + fldt _P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.37 +..B1.36: + fldcw 38(%esp) +..B1.37: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.72 +..B1.39: + orl $-64768, %ebx + movw %bx, 36(%esp) +..B1.40: + fldcw 36(%esp) +..B1.41: + movl $1, %ebx +..B1.42: + fldl ones@GOTOFF(%edx,%ecx,8) + fstl 56(%esp) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%edx) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + movzwl 16(%ebp), %eax + andl $32767, %eax + cmpl $16383, %eax + jge ..B1.44 +..B1.43: + fldl _TWO_48H@GOTOFF(%edx) + fld %st(3) + fmul %st(1), %st + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(1) + fxch %st(2) + fmul %st(4), %st + fadd %st(3), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubp %st, %st(3) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmulp %st, %st(3) + fld %st(3) + movl 12(%esp), %eax + fsub %st(3), %st + fld %st(0) + fxch %st(3) + fsubr %st, %st(5) + fxch %st(4) + fmul %st, %st(5) + fmulp %st, %st(4) + fld %st(1) + fmul %st(1), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fsub %st(2), %st + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fadd %st, %st(4) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fstpt (%esp) + fxch %st(3) + fxch %st(4) + fxch %st(1) + fxch %st(2) + jmp ..B1.45 +..B1.44: + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fld %st(3) + fdivr %st(1), %st + fmulp %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fld %st(3) + movl 12(%esp), %eax + fxch %st(3) + fsubrp %st, %st(1) + fld %st(3) + negl %eax + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + addl $256, %eax + fmulp %st, %st(2) + fldl _TWO_48H@GOTOFF(%edx) + fmul %st, %st(1) + fxch %st(1) + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(3) + fmul %st(2), %st + fxch %st(4) + fsubr %st, %st(5) + fld %st(5) + fmul %st(3), %st + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fstpt (%esp) + fldt (%esp) + faddp %st, %st(6) + fld %st(1) + fadd %st(4), %st + fmul %st, %st(3) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(1) + fsubr %st(2), %st + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(5) + fldl _TWO_48H@GOTOFF(%edx) +..B1.45: + fld %st(1) + shll $4, %eax + fadd %st(6), %st + fdivrp %st, %st(4) + testl %ebx, %ebx + fmul %st(3), %st + fld %st(0) + fadd %st(4), %st + fsubp %st, %st(1) + fld %st(0) + fsubr %st(4), %st + fld %st(2) + fmul %st(2), %st + fxch %st(5) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(3) + fxch %st(7) + faddp %st, %st(3) + fxch %st(1) + fstpt 40(%esp) + fldt (%esp) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fldt 40(%esp) + fmulp %st, %st(2) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 36+_P@GOTOFF(%edx) + fmul %st(3), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_P@GOTOFF(%edx) + fmulp %st, %st(4) + fldt _P@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fldl __libm_atanl_table_128@GOTOFF(%edx,%eax) + fld %st(0) + fadd %st(2), %st + fldl _TWO_32H@GOTOFF(%edx) + fmul %st(1), %st + fadd %st, %st(1) + fsubr %st(1), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + faddl 8+__libm_atanl_table_128@GOTOFF(%edx,%eax) + faddp %st, %st(1) + faddp %st, %st(1) + fmull 56(%esp) + fstpt 24(%esp) + je ..B1.80 +..B1.46: + fstpt 12(%esp) +..B1.79: + fldcw 38(%esp) + jmp ..B1.47 +..B1.80: + fstp %st(0) +..B1.47: + fldt 24(%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.48: + movl %ebx, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.76 +..B1.49: + orl $-64768, %ebx + movw %bx, 36(%esp) +..B1.50: + fldcw 36(%esp) +..B1.51: + movzwl 16(%ebp), %eax + movl $1, %ebx + andl $32767, %eax +..B1.52: + cmpl $32767, %eax + je ..B1.73 +..B1.53: + cmpl $16448, %eax + jge ..B1.60 +..B1.54: + fldt 8(%ebp) + xorl %eax, %eax + testl %ecx, %ecx + sete %al + fdivrl ones@GOTOFF(%edx,%eax,8) + fstpt 8(%ebp) + fldt 8(%ebp) + movzwl 16(%ebp), %eax + andl $32767, %eax + fstpt (%esp) + cmpl $16398, %eax + jge ..B1.56 +..B1.55: + fldt (%esp) + fld %st(0) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%edx) + fmul %st(1), %st + fldt _P1@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.59 +..B1.56: + cmpl $16408, %eax + jge ..B1.59 +..B1.57: + fldt _P2@GOTOFF(%edx) + fldt (%esp) + fmul %st, %st(1) + fmul %st, %st(1) + fmul %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) +..B1.59: + fldt .L_2il0floatpacket.4@GOTOFF(%edx) + fldt (%esp) + faddp %st, %st(1) + fldt .L_2il0floatpacket.5@GOTOFF(%edx) + faddp %st, %st(1) + fmull ones@GOTOFF(%edx,%ecx,8) + fstpt (%esp) + jmp ..B1.61 +..B1.60: + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %ecx + fldt _pi_2l@GOTOFF(%ecx,%edx) + fldt _small_value_80@GOTOFF(%ecx,%edx) + fsubrp %st, %st(1) + fstpt (%esp) +..B1.61: + testl %ebx, %ebx + je ..B1.63 +..B1.62: + fldcw 38(%esp) +..B1.63: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.64: + cmpl $0, 12(%ebp) + jne ..B1.66 +..B1.65: + cmpl $0, 8(%ebp) + je ..B1.67 +..B1.66: + fldt _small_value_80@GOTOFF(%edx) + lea (,%ecx,8), %eax + fldt 8(%ebp) + lea (%eax,%ecx,4), %ecx + fldt _small_value_80@GOTOFF(%edx,%ecx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fsubrp %st, %st(1) + fstpt (%esp) + jmp ..B1.14 +..B1.67: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.14 +..B1.68: + xorl %ebx, %ebx + jmp ..B1.12 +..B1.69: + xorl %eax, %eax + jmp ..B1.21 +..B1.70: + xorl %eax, %eax + jmp ..B1.28 +..B1.71: + xorl %eax, %eax + jmp ..B1.35 +..B1.72: + xorl %ebx, %ebx + jmp ..B1.42 +..B1.73: + cmpl $-2147483648, 12(%ebp) + jne ..B1.75 +..B1.74: + cmpl $0, 8(%ebp) + je ..B1.53 +..B1.75: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.61 +..B1.76: + xorl %ebx, %ebx + jmp ..B1.52 + .align 16,0x90 + .type atanl,@function + .size atanl,.-atanl + .data +# -- End atanl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x88,0x19,0x13,0xd3,0x08,0xa3,0x85,0xdd,0x3f,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0xa2,0xda,0x0f,0xc9,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_P2: + .word 43691 + .word 41642 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .type _P2,@object + .size _P2,12 + .align 2 +_P1: + .word 23723 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 22830 + .word 33705 + .word 52154 + .word 52428 + .word 16380 + .word 0 + .type _P1,@object + .size _P1,24 + .align 2 +_P: + .word 43664 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 43235 + .word 52379 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 59507 + .word 38278 + .word 9340 + .word 37449 + .word 49148 + .word 0 + .word 9132 + .word 55602 + .word 8665 + .word 58245 + .word 16379 + .word 0 + .type _P,@object + .size _P,48 + .align 2 +_pi_2l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .type _pi_2l,@object + .size _pi_2l,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_atanl_table_128 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/atanl_table.S b/external/sgx_libm/ia32/atanl_table.S new file mode 100644 index 0000000000..63a3d207c1 --- /dev/null +++ b/external/sgx_libm/ia32/atanl_table.S @@ -0,0 +1,1074 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanl_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_atanl_table_128 + .globl __libm_atanl_table_128 +__libm_atanl_table_128: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x55c00000,0x3f7fffd5 + .long 0x4bfcee57,0xbd5115a3 + .long 0x5bc00000,0x3f8fff55 + .long 0x220c39d5,0xbd623595 + .long 0x18800000,0x3f97fee0 + .long 0x286313f8,0xbdaad1e5 + .long 0xbb800000,0x3f9ffd55 + .long 0x542779d7,0x3da4bb12 + .long 0xf1600000,0x3fa3fd65 + .long 0x2e4614e3,0x3d9393b2 + .long 0x84400000,0x3fa7fb81 + .long 0x0c377c7c,0xbd9e4bac + .long 0xf1400000,0x3fabf8dd + .long 0x89fe34b3,0xbd88eef1 + .long 0xb7400000,0x3faff55b + .long 0x39269b0e,0xbda30216 + .long 0xbf000000,0x3fb1f86d + .long 0xbda88e23,0x3da05ab1 + .long 0x0e800000,0x3fb3f59f + .long 0xa7663af4,0xbd8d5314 + .long 0x4fc00000,0x3fb5f232 + .long 0x62a36910,0x3db2d7b2 + .long 0x26000000,0x3fb7ee18 + .long 0x6093567e,0x3d878874 + .long 0x53c00000,0x3fb9e941 + .long 0xd19970eb,0x3dafb9e2 + .long 0xbe400000,0x3fbbe39e + .long 0xbef71e53,0x3dc783e1 + .long 0x70400000,0x3fbddd21 + .long 0xcd620065,0xbdc0a2c8 + .long 0x9ac00000,0x3fbfd5ba + .long 0x39a6ed0d,0xbdb3d092 + .long 0xcce00000,0x3fc0e6ad + .long 0x8a397391,0x3dc40881 + .long 0xfb000000,0x3fc1e1fa + .long 0x92de9bad,0x3da0dc9b + .long 0xb3000000,0x3fc2dcbd + .long 0x386bc7d5,0xbda17803 + .long 0xe8c00000,0x3fc3d6ee + .long 0x61a3b0cf,0x3da989b1 + .long 0xa9c00000,0x3fc4d087 + .long 0x47cc8fc7,0x3dca4f17 + .long 0x1e400000,0x3fc5c981 + .long 0x0a956580,0xbd83d962 + .long 0x89800000,0x3fc6c1d4 + .long 0xb5aad628,0x3db267b1 + .long 0x4c000000,0x3fc7b97b + .long 0xecb84f4b,0xbdd8d27e + .long 0xe2800000,0x3fc8b06e + .long 0xee732cfd,0x3dae70a2 + .long 0xe9400000,0x3fc9a6a8 + .long 0x0e7b00f4,0x3dd64313 + .long 0x1b400000,0x3fca9c23 + .long 0xd177d13a,0x3d593ca1 + .long 0x52c00000,0x3fcb90d7 + .long 0xfdd09de6,0xbdd6cfae + .long 0x8a800000,0x3fcc84bf + .long 0x656f741a,0xbdb7a324 + .long 0xdf400000,0x3fcd77d5 + .long 0x8e6dcbab,0xbdcfa8c9 + .long 0x8e800000,0x3fce6a14 + .long 0x619ac881,0x3dc6ec4d + .long 0xf9400000,0x3fcf5b75 + .long 0x9d52470c,0xbdc37f22 + .long 0x51200000,0x3fd025fa + .long 0x59cb7da1,0xbdd99a4a + .long 0x97c00000,0x3fd09dc5 + .long 0x58b91ce4,0x3dd86362 + .long 0x36200000,0x3fd1151a + .long 0xb2372370,0x3db0c726 + .long 0xa3200000,0x3fd18bf5 + .long 0xd9e6b717,0xbdd40e87 + .long 0x67e00000,0x3fd20255 + .long 0x73e6e6b8,0x3db1f257 + .long 0x20400000,0x3fd27837 + .long 0xbe20c8b2,0x3dd7ef45 + .long 0x7a800000,0x3fd2ed98 + .long 0xb91258ea,0x3da1e7f1 + .long 0x37000000,0x3fd36277 + .long 0x34e2d5da,0x3dbfaf2f + .long 0x29400000,0x3fd3d6d1 + .long 0xbb20d6f9,0xbdd8eecb + .long 0x36c00000,0x3fd44aa4 + .long 0x45437875,0x3da5784d + .long 0x58600000,0x3fd4bdee + .long 0x86c8e20f,0x3dc121cd + .long 0x99400000,0x3fd530ad + .long 0xdb5336ff,0x3dd1cd49 + .long 0x17400000,0x3fd5a2e0 + .long 0x44edea3e,0x3dde0f4e + .long 0x03000000,0x3fd61484 + .long 0x2c6d4754,0x3dc39fc3 + .long 0x9f400000,0x3fd68597 + .long 0xf6d43f59,0x3ddfa6fd + .long 0x41c00000,0x3fd6f619 + .long 0x4738aa32,0x3de26f78 + .long 0x52800000,0x3fd76607 + .long 0x11774372,0x3d97501f + .long 0x4b400000,0x3fd7d560 + .long 0xad3910b8,0x3de1d9fb + .long 0xb9000000,0x3fd84422 + .long 0x4512bfad,0xbde03514 + .long 0x39400000,0x3fd8b24d + .long 0xdb685d1c,0x3dc4364a + .long 0x7cc00000,0x3fd91fde + .long 0x441d0620,0x3dd0c662 + .long 0x45400000,0x3fd98cd5 + .long 0xcf364c48,0x3dcad630 + .long 0x66000000,0x3fd9f930 + .long 0x8df63ee1,0x3dd68001 + .long 0xc3c00000,0x3fda64ee + .long 0x6d909f25,0x3dc847f9 + .long 0x54400000,0x3fdad00f + .long 0x80ecf31e,0xbdddfa74 + .long 0x1dc00000,0x3fdb3a91 + .long 0x9479e139,0xbdd9a393 + .long 0x37800000,0x3fdba473 + .long 0x519a1b47,0x3db89295 + .long 0xc9400000,0x3fdc0db4 + .long 0x19f18c7b,0x3dcd93df + .long 0x0ac00000,0x3fdc7655 + .long 0x5d2e2ffe,0xbdd28e07 + .long 0x43000000,0x3fdcde53 + .long 0x4ba60b78,0x3de609a8 + .long 0xca000000,0x3fdd45ae + .long 0xced7bdd4,0xbdd379d4 + .long 0x05800000,0x3fddac67 + .long 0x97520377,0xbdde44b0 + .long 0x6b000000,0x3fde127b + .long 0xb53d9e72,0x3dbd12bf + .long 0x7f400000,0x3fde77eb + .long 0xde35847d,0xbde452e5 + .long 0xd4400000,0x3fdedcb6 + .long 0xf25d8cc2,0xbd7ef2c7 + .long 0x0b800000,0x3fdf40dd + .long 0x1a3992dc,0xbde5f5f4 + .long 0xd3400000,0x3fdfa45d + .long 0xb94ac7b8,0xbdeeb6d3 + .long 0x73e00000,0x3fe0039c + .long 0x6ccb2527,0xbdee5bf4 + .long 0x09400000,0x3fe034b7 + .long 0xce0c98e5,0xbdeafb77 + .long 0x94e00000,0x3fe0657e + .long 0xeada4afb,0xbdc33cc0 + .long 0x08600000,0x3fe095f3 + .long 0xdbc9bebd,0x3daa58fd + .long 0x5b600000,0x3fe0c614 + .long 0xcd160bd9,0xbdc2f097 + .long 0x8b600000,0x3fe0f5e2 + .long 0x004c46c6,0x3dcf8a54 + .long 0x9be00000,0x3fe1255d + .long 0xf6a1288f,0x3debd2a8 + .long 0x96400000,0x3fe15485 + .long 0xa5d3e2a4,0xbdd1372c + .long 0x88c00000,0x3fe1835a + .long 0xe778c500,0xbda83ec8 + .long 0x87800000,0x3fe1b1dc + .long 0xede17375,0x3de04284 + .long 0xabe00000,0x3fe1e00b + .long 0xc946f944,0xbda014c0 + .long 0x13e00000,0x3fe20de8 + .long 0x43714561,0x3dd04763 + .long 0xe2c00000,0x3fe23b71 + .long 0x3884393e,0x3dd93cd4 + .long 0x40800000,0x3fe268a9 + .long 0xf1765bb0,0xbde69259 + .long 0x59400000,0x3fe2958e + .long 0x4279cec3,0xbddee39e + .long 0x5e000000,0x3fe2c221 + .long 0xd68fde4c,0x3db2232f + .long 0x84000000,0x3fe2ee62 + .long 0xc5d5e9ff,0x3dcb2f29 + .long 0x04a00000,0x3fe31a52 + .long 0xafcd51e1,0xbde78b41 + .long 0x1ce00000,0x3fe345f0 + .long 0xbbf7bb21,0xbde1c844 + .long 0x0e000000,0x3fe3713d + .long 0x14f789e0,0xbdd275f8 + .long 0x1ce00000,0x3fe39c39 + .long 0x9182198f,0xbdd7d1cc + .long 0x91c00000,0x3fe3c6e4 + .long 0x1ebaf6b0,0x3dce3712 + .long 0xb8a00000,0x3fe3f13f + .long 0x260e96db,0xbda690bc + .long 0xe0800000,0x3fe41b4a + .long 0xec29f5ad,0xbde015be + .long 0x5b800000,0x3fe44506 + .long 0xfbb680b2,0xbdca92a8 + .long 0x7f000000,0x3fe46e72 + .long 0x39b9b1b8,0xbdab8ea1 + .long 0xa3200000,0x3fe4978f + .long 0x920cd440,0x3dca7b84 + .long 0x22e00000,0x3fe4c05e + .long 0x02b07c28,0xbda6b1b7 + .long 0x5ba00000,0x3fe4e8de + .long 0x528cf6fb,0x3de6ec04 + .long 0xadc00000,0x3fe51110 + .long 0x91ee6b42,0x3dc7b604 + .long 0x7b800000,0x3fe538f5 + .long 0x72245aa1,0x3dd20c3d + .long 0x29c00000,0x3fe5608d + .long 0x9939cf0e,0x3dcc30d1 + .long 0x1f800000,0x3fe587d8 + .long 0x57972763,0xbdd9a08a + .long 0xc5800000,0x3fe5aed6 + .long 0x5cc4bdc5,0x3de09517 + .long 0x87000000,0x3fe5d589 + .long 0x10028e4c,0x3de69b18 + .long 0xd0c00000,0x3fe5fbf0 + .long 0xf2598180,0x3de5cc49 + .long 0x11400000,0x3fe6220d + .long 0xed487acb,0x3ded7b8d + .long 0xb8c00000,0x3fe647de + .long 0xf84d7eff,0x3df105c7 + .long 0x39400000,0x3fe66d66 + .long 0x2dd4dfd8,0xbdec1f79 + .long 0x05400000,0x3fe692a4 + .long 0x7652e56a,0x3de6fb6a + .long 0x92000000,0x3fe6b798 + .long 0x2bfe3cf4,0x3dd67b31 + .long 0x55000000,0x3fe6dc44 + .long 0xf203bce5,0x3de553ae + .long 0xc5800000,0x3fe700a7 + .long 0xc61a692d,0xbdcee730 + .long 0x5b400000,0x3fe724c3 + .long 0x1948b32e,0x3ddf5cf6 + .long 0x8f800000,0x3fe74897 + .long 0x82f654c3,0x3dfd4707 + .long 0xdcc00000,0x3fe76c24 + .long 0x1952551b,0x3dcb1b01 + .long 0xbd400000,0x3fe78f6b + .long 0x501a8226,0x3ded315e + .long 0xad400000,0x3fe7b26c + .long 0x73a037cc,0xbde1af02 + .long 0x28c00000,0x3fe7d528 + .long 0x553efbc4,0xbdf02fb6 + .long 0xacc00000,0x3fe7f79e + .long 0x02a357f1,0xbdca1d9e + .long 0xb7400000,0x3fe819d0 + .long 0x9bf7622a,0xbdf53ad9 + .long 0xc6000000,0x3fe83bbe + .long 0xf677c77e,0xbdf908ee + .long 0x57800000,0x3fe85d69 + .long 0xe9499180,0xbde33d3a + .long 0xeb000000,0x3fe87ed0 + .long 0xef50a527,0xbdf1d2ea + .long 0xff800000,0x3fe89ff5 + .long 0x2ab734bc,0xbdf40704 + .long 0x14400000,0x3fe8c0d9 + .long 0x6fa901db,0x3decf49d + .long 0xa9800000,0x3fe8e17a + .long 0xc27cfaaa,0x3decc05d + .long 0x3ec00000,0x3fe901db + .long 0xad0ccbcb,0x3df778c3 + .long 0x54400000,0x3fe921fb + .long 0x1a626331,0x3dc0b461 + .long 0x69800000,0x3fe9421b + .long 0x33179a03,0x3de968a9 + .long 0xff000000,0x3fe9627b + .long 0x354bc911,0xbde4662d + .long 0x94400000,0x3fe9831d + .long 0xe277d043,0xbde49a6c + .long 0xa9000000,0x3fe9a400 + .long 0x714fcd89,0x3df8341c + .long 0xbdc00000,0x3fe9c525 + .long 0x942d841a,0xbde3fff9 + .long 0x51000000,0x3fe9e68d + .long 0x767ac319,0x3deb976b + .long 0xe2c00000,0x3fea0837 + .long 0x177cfdb1,0xbdc64fc6 + .long 0xf1800000,0x3fea2a25 + .long 0x75c01427,0xbdda6038 + .long 0xfbc00000,0x3fea4c57 + .long 0x1bb40f2a,0x3dddc330 + .long 0x80000000,0x3fea6ece + .long 0xc850d6e0,0xbde74662 + .long 0xfb400000,0x3fea9189 + .long 0x00d16965,0x3dea0933 + .long 0xeb000000,0x3feab48a + .long 0x1e8b57b9,0x3df59469 + .long 0xcbc00000,0x3fead7d1 + .long 0x6dc9c51f,0x3da93704 + .long 0x18c00000,0x3feafb5f + .long 0x0e891026,0x3ddb9843 + .long 0x4d400000,0x3feb1f33 + .long 0xfdcc9ff9,0xbdcd5129 + .long 0xe3400000,0x3feb434e + .long 0xa0a41a0e,0xbdf7f601 + .long 0x53800000,0x3feb67b2 + .long 0xc9a51699,0xbdd9f2fc + .long 0x16800000,0x3feb8c5e + .long 0x466f670a,0xbdb71b40 + .long 0xa3400000,0x3febb152 + .long 0xd24367a3,0xbddd4273 + .long 0x6f800000,0x3febd690 + .long 0x44f9ee90,0xbdeb8656 + .long 0xef800000,0x3febfc17 + .long 0x4e4b19cd,0x3df32750 + .long 0x97400000,0x3fec21e9 + .long 0x60174932,0xbde5215d + .long 0xd7c00000,0x3fec4805 + .long 0xca509fcf,0xbddae432 + .long 0x21800000,0x3fec6e6d + .long 0x05a2b966,0xbddc81cf + .long 0xe2c00000,0x3fec951f + .long 0x983639ea,0x3dfbe28c + .long 0x89000000,0x3fecbc1e + .long 0xb8fcc54a,0x3de52a75 + .long 0x7ec00000,0x3fece369 + .long 0x6e2bdd53,0x3da4dfc2 + .long 0x2d000000,0x3fed0b01 + .long 0x7c1f76fe,0xbd957dc5 + .long 0xfac00000,0x3fed32e5 + .long 0x45acb642,0x3db3657b + .long 0x4cc00000,0x3fed5b18 + .long 0x3aa43a9e,0x3de16e2c + .long 0x85c00000,0x3fed8398 + .long 0x02a3c6a5,0xbde63ab4 + .long 0x05800000,0x3fedac67 + .long 0x97520377,0xbdee44b0 + .long 0x29800000,0x3fedd584 + .long 0x41999968,0x3dd42635 + .long 0x4d000000,0x3fedfef0 + .long 0x983da38a,0x3dddfdb5 + .long 0xc8400000,0x3fee28ab + .long 0x43526c5d,0xbdf3c808 + .long 0xf0000000,0x3fee52b6 + .long 0xb06de4fa,0xbde63cc3 + .long 0x16c00000,0x3fee7d12 + .long 0xb04e7d93,0x3d998d80 + .long 0x8b800000,0x3feea7bd + .long 0x6af91f30,0x3dfa218b + .long 0x9a800000,0x3feed2b9 + .long 0x97acf689,0x3de1952c + .long 0x8bc00000,0x3feefe06 + .long 0xdb5c4d1a,0xbdc7762a + .long 0xa4000000,0x3fef29a4 + .long 0x017c85fc,0xbd6a8dc3 + .long 0x24800000,0x3fef5594 + .long 0xbbbb718e,0x3da8e661 + .long 0x4a800000,0x3fef81d5 + .long 0x497cd73d,0x3dc8572a + .long 0x4f400000,0x3fefae68 + .long 0xae6e18fa,0x3de7cbff + .long 0x68000000,0x3fefdb4d + .long 0x7ea78d48,0x3deeec8a + .long 0x62e00000,0x3ff00442 + .long 0x3c43ac1a,0xbdc110e6 + .long 0x4a400000,0x3ff01b07 + .long 0x75bc4774,0x3df01b3f + .long 0x7e400000,0x3ff031f5 + .long 0x4ce2d096,0x3df4adbe + .long 0x10800000,0x3ff0490d + .long 0x82c10772,0xbdcfa151 + .long 0x0fe00000,0x3ff0604e + .long 0x37517bd1,0x3dd3bc3a + .long 0x89200000,0x3ff077b8 + .long 0xe01b22eb,0x3de0f5c6 + .long 0x86600000,0x3ff08f4c + .long 0x34b7fb7b,0xbdf9bc3c + .long 0x0e800000,0x3ff0a70a + .long 0xc68f0ff4,0x3df03bcd + .long 0x26800000,0x3ff0bef1 + .long 0x403b5a47,0x3df68b2b + .long 0xd0000000,0x3ff0d701 + .long 0x57ba4ad6,0x3df35a50 + .long 0x09e00000,0x3ff0ef3c + .long 0x38183ba9,0xbde2d69f + .long 0xcfc00000,0x3ff1079f + .long 0xa4c23582,0xbdecaa57 + .long 0x1a600000,0x3ff1202d + .long 0xe7f15aff,0x3dcad893 + .long 0xdf800000,0x3ff138e3 + .long 0x19efe544,0x3dcc4411 + .long 0x11600000,0x3ff151c4 + .long 0xa76ac475,0x3dee5024 + .long 0x9f200000,0x3ff16acd + .long 0x0e8af659,0x3df44c0b + .long 0x74800000,0x3ff18400 + .long 0xa4ca4f57,0xbdba974c + .long 0x79800000,0x3ff19d5c + .long 0x5a25f72a,0x3dc2df62 + .long 0x92e00000,0x3ff1b6e1 + .long 0xd8da3354,0x3de77c88 + .long 0xa1c00000,0x3ff1d08f + .long 0xf49d1082,0x3de2171a + .long 0x83800000,0x3ff1ea66 + .long 0x7ce9b3be,0xbddb5eef + .long 0x11800000,0x3ff20466 + .long 0x1de424cc,0x3df8d09a + .long 0x22000000,0x3ff21e8e + .long 0x394b3186,0xbdef0ac7 + .long 0x86600000,0x3ff238de + .long 0x8bf7b8bf,0x3dc51f77 + .long 0x0cc00000,0x3ff25357 + .long 0x2bb7111b,0x3dfa95fd + .long 0x7f400000,0x3ff26df7 + .long 0x64b0a9b1,0xbdd1512a + .long 0xa3400000,0x3ff288bf + .long 0x18e684e8,0x3df12419 + .long 0x3ac00000,0x3ff2a3af + .long 0xce4f6ebe,0xbdb72e81 + .long 0x03000000,0x3ff2bec6 + .long 0xa69c6179,0xbdee5b5b + .long 0xb5000000,0x3ff2da03 + .long 0x6b22ae89,0x3deff6ff + .long 0x06000000,0x3ff2f568 + .long 0x29a8e5ae,0xbdecb362 + .long 0xa6000000,0x3ff310f2 + .long 0xd243f145,0x3de88f44 + .long 0x41600000,0x3ff32ca3 + .long 0xdff820e0,0x3de68034 + .long 0x7fa00000,0x3ff34879 + .long 0x5295ddf4,0x3dce7ebe + .long 0x03c00000,0x3ff36475 + .long 0x45f88767,0x3de5eab8 + .long 0x6c600000,0x3ff38095 + .long 0x91c711ec,0x3de886b1 + .long 0x53800000,0x3ff39cda + .long 0x10aefe1c,0x3dbb91fe + .long 0x4e800000,0x3ff3b943 + .long 0x4aa2e1c3,0xbdf356bb + .long 0xee000000,0x3ff3d5cf + .long 0x303c34f3,0xbdf0463a + .long 0xbe200000,0x3ff3f27f + .long 0x2b7ef915,0x3de411bd + .long 0x46a00000,0x3ff40f52 + .long 0x472305ef,0xbde8fd54 + .long 0x09e00000,0x3ff42c47 + .long 0x3560ce8b,0x3dfa68cb + .long 0x86a00000,0x3ff4495d + .long 0xacb59491,0xbdfdcdda + .long 0x35a00000,0x3ff46695 + .long 0xc6803028,0x3dcceec5 + .long 0x8c200000,0x3ff483ed + .long 0xae20cd3f,0x3dec628d + .long 0xfa600000,0x3ff4a165 + .long 0x30a5d59f,0xbdf4f20d + .long 0xeb800000,0x3ff4befd + .long 0xd1246921,0x3db30ba3 + .long 0xc6c00000,0x3ff4dcb4 + .long 0x922b65ab,0xbdd37d68 + .long 0xee400000,0x3ff4fa89 + .long 0x60d4a327,0x3dec287f + .long 0xc0000000,0x3ff5187c + .long 0xe85bc1a4,0x3dc49d56 + .long 0x95200000,0x3ff5368c + .long 0x5bd1e523,0xbdb63036 + .long 0xc2600000,0x3ff554b8 + .long 0x9a653fbc,0x3df14f8e + .long 0x98800000,0x3ff57300 + .long 0x8799adbe,0xbdffddce + .long 0x62c00000,0x3ff59163 + .long 0x4677c807,0x3e0ad3a5 + .long 0x6a000000,0x3ff5afe0 + .long 0xf3e67f75,0xbdec3df7 + .long 0xf0c00000,0x3ff5ce76 + .long 0x1e243ad8,0x3dfc26c9 + .long 0x37000000,0x3ff5ed26 + .long 0x82f9d88f,0x3df69c53 + .long 0x78000000,0x3ff60bed + .long 0xa1b60137,0xbde98cd9 + .long 0xeac00000,0x3ff62acb + .long 0x038d593e,0x3de4c370 + .long 0xc3400000,0x3ff649c0 + .long 0x6a610a4b,0xbe067cb1 + .long 0x30800000,0x3ff668cb + .long 0xaa91e345,0xbdcd59a7 + .long 0x5f000000,0x3ff687ea + .long 0xbb3e0da7,0x3de1c66a + .long 0x77400000,0x3ff6a71d + .long 0x447484ba,0xbdf49f35 + .long 0x9e000000,0x3ff6c663 + .long 0x9fa408f5,0xbdfb4727 + .long 0xf5000000,0x3ff6e5bb + .long 0x95fe5c11,0xbdfc59cc + .long 0x9a800000,0x3ff70525 + .long 0x0aa8b52d,0x3e02d604 + .long 0xaac00000,0x3ff7249f + .long 0x4ae67c31,0xbe034aef + .long 0x3d400000,0x3ff74429 + .long 0x0226c6c8,0x3dc20b8b + .long 0x68800000,0x3ff763c1 + .long 0xf8a3257f,0xbe0161b1 + .long 0x3f000000,0x3ff78367 + .long 0xc02f3514,0x3ddcbd24 + .long 0xd2000000,0x3ff7a319 + .long 0xa2288de1,0xbdfc01f8 + .long 0x2f400000,0x3ff7c2d8 + .long 0x81b988ed,0x3ddbfe74 + .long 0x63800000,0x3ff7e2a1 + .long 0xc80c4d5f,0xbe01cc20 + .long 0x78400000,0x3ff80274 + .long 0xb8ab545b,0x3df3aa42 + .long 0x76800000,0x3ff82250 + .long 0xf0c39b49,0x3de58a51 + .long 0x64c00000,0x3ff84234 + .long 0x594dab29,0xbdd68427 + .long 0x48000000,0x3ff8621f + .long 0x7b64bb5f,0x3e015323 + .long 0x24c00000,0x3ff88210 + .long 0x0881fe1d,0xbddc84da + .long 0xfd400000,0x3ff8a205 + .long 0xb3f75cfe,0x3df5873f + .long 0xd4000000,0x3ff8c1ff + .long 0x90244e94,0xbdfcfc58 + .long 0xa9800000,0x3ff8e1fc + .long 0x22533dd2,0x3de96c66 + .long 0x7ec00000,0x3ff901fb + .long 0xd7b5cc04,0x3e0738ae + .long 0x54400000,0x3ff921fb + .long 0x1a626331,0x3dd0b461 + .long 0x29800000,0x3ff941fb + .long 0xddc59991,0x3df9e8d2 + .long 0xff000000,0x3ff961f9 + .long 0x0fe1b542,0xbdd1700a + .long 0xd4c00000,0x3ff981f6 + .long 0xe2aa7fd3,0xbdfaa976 + .long 0xab400000,0x3ff9a1f0 + .long 0x4d8c56ca,0xbdea5a1e + .long 0x83c00000,0x3ff9c1e6 + .long 0x1ea36240,0x3deef6ce + .long 0x60800000,0x3ff9e1d7 + .long 0x69984526,0xbdfa4c16 + .long 0x43c00000,0x3ffa01c2 + .long 0xc70938c6,0x3debf674 + .long 0x32000000,0x3ffa21a6 + .long 0x5984e061,0xbdc357c3 + .long 0x30400000,0x3ffa4182 + .long 0x56f44585,0xbde6a024 + .long 0x45000000,0x3ffa6155 + .long 0x0ea4e62b,0x3e05f939 + .long 0x79400000,0x3ffa811e + .long 0xcc2cf5d5,0x3db5a936 + .long 0xd6c00000,0x3ffaa0dc + .long 0xd0a64087,0xbdfba3d6 + .long 0x69800000,0x3ffac08f + .long 0xd256453b,0x3db2ae75 + .long 0x40000000,0x3ffae035 + .long 0x3f3bbe4b,0x3e058eca + .long 0x6b400000,0x3ffaffcd + .long 0xb3b162ff,0x3dd862fc + .long 0xfe000000,0x3ffb1f56 + .long 0xdd01d604,0xbdf10ff0 + .long 0x0e000000,0x3ffb3ed1 + .long 0x882038c2,0xbdfd51d7 + .long 0xb3c00000,0x3ffb5e3a + .long 0xdcd07256,0xbdfb4c02 + .long 0x0ac00000,0x3ffb7d93 + .long 0xd32ac572,0xbdfc5ea7 + .long 0x31400000,0x3ffb9cd9 + .long 0xd1a5b653,0x3dfcf965 + .long 0x49800000,0x3ffbbc0c + .long 0x0dbaa75b,0xbda1209a + .long 0x78000000,0x3ffbdb2b + .long 0x0506dc03,0x3de80acb + .long 0xe5800000,0x3ffbfa35 + .long 0x3c1973a2,0xbde558d9 + .long 0xbdc00000,0x3ffc192a + .long 0xa4abd834,0xbdc03c3b + .long 0x30c00000,0x3ffc3809 + .long 0x50f9e6e6,0xbe056fb1 + .long 0x71800000,0x3ffc56d0 + .long 0xeb914ded,0xbdec8445 + .long 0xb7c00000,0x3ffc757f + .long 0x90f3093f,0xbdf3cc98 + .long 0x3e800000,0x3ffc9416 + .long 0x87247153,0x3df6792c + .long 0x45800000,0x3ffcb293 + .long 0x0041a18b,0x3df2b2e6 + .long 0x10000000,0x3ffcd0f6 + .long 0x8a656fab,0x3e041bff + .long 0xe6000000,0x3ffcef3d + .long 0xf2cbf1dc,0x3df70aa1 + .long 0x13400000,0x3ffd0d6a + .long 0xf97727f5,0x3e04de99 + .long 0xe8800000,0x3ffd2b79 + .long 0xc096e590,0x3dd71a16 + .long 0xba400000,0x3ffd496c + .long 0x8ce47feb,0xbdd6e83c + .long 0xe2000000,0x3ffd6741 + .long 0xa721fa7e,0xbe09633a + .long 0xbd000000,0x3ffd84f8 + .long 0x407bac1a,0x3ddca5d9 + .long 0xae400000,0x3ffda290 + .long 0x1147c641,0xbdc59e12 + .long 0x1c400000,0x3ffdc009 + .long 0xb620caf9,0x3dfa28e9 + .long 0x73000000,0x3ffddd61 + .long 0x2b9ed46c,0xbdfb43a8 + .long 0x22400000,0x3ffdfa99 + .long 0x630c9ceb,0xbe0cebfa + .long 0x9e800000,0x3ffe17af + .long 0xafa0c61c,0x3debe2ca + .long 0x61c00000,0x3ffe34a4 + .long 0x58615a48,0x3e0a6c6d + .long 0xea400000,0x3ffe5176 + .long 0xf771b50e,0x3dfe5151 + .long 0xba800000,0x3ffe6e26 + .long 0xbd6d668c,0x3df8a06a + .long 0x5a000000,0x3ffe8ab3 + .long 0xd7d4135c,0x3dfbb0eb + .long 0x55000000,0x3ffea71c + .long 0xb09906dc,0x3dda8442 + .long 0x3c000000,0x3ffec361 + .long 0xc44da8a3,0x3dfc16d7 + .long 0xa4c00000,0x3ffedf81 + .long 0xae5890d5,0xbdc4d95c + .long 0x29000000,0x3ffefb7d + .long 0x3d218a26,0xbdfb75a7 + .long 0x67400000,0x3fff1753 + .long 0xf1656f6c,0xbe0172f4 + .long 0x02800000,0x3fff3304 + .long 0xdf863851,0xbdcf6b8e + .long 0xa2800000,0x3fff4e8e + .long 0xa205a470,0x3df6b3e1 + .long 0xf3800000,0x3fff69f2 + .long 0xa18096af,0xbdde853c + .long 0xa5800000,0x3fff8530 + .long 0x607f6255,0x3df787de + .long 0x6dc00000,0x3fffa047 + .long 0x542c5109,0x3de39a31 + .long 0x05400000,0x3fffbb37 + .long 0x176aa69e,0xbde193d1 + .long 0x29400000,0x3fffd5ff + .long 0x4cbab80a,0x3de95cf6 + .long 0x9bc00000,0x3ffff09f + .long 0x9e85df82,0xbdf23bcc + .long 0x11200000,0x4000058c + .long 0x644dc57f,0xbdfa49be + .long 0x43400000,0x400012b4 + .long 0x29d6ca5c,0x3df7df94 + .long 0x4b800000,0x40001fc8 + .long 0x90b2f333,0xbdf07669 + .long 0x12800000,0x40002cc8 + .long 0xd8d73d10,0x3dee63d8 + .long 0x83600000,0x400039b3 + .long 0xa3aad512,0xbda62b9d + .long 0x8ac00000,0x4000468a + .long 0x20c417ef,0x3dfc9bec + .long 0x17800000,0x4000534d + .long 0x07b1cace,0x3dd7f911 + .long 0x1a000000,0x40005ffb + .long 0xaefbad1c,0x3de4074a + .long 0x84a00000,0x40006c94 + .long 0x7ea63b40,0x3df40e25 + .long 0x4b800000,0x40007919 + .long 0x397bcf5e,0x3df9321e + .long 0x64800000,0x40008589 + .long 0xa7ccd3c1,0x3dd346b9 + .long 0xc7200000,0x400091e4 + .long 0xefccf9c7,0xbdfb00e1 + .long 0x6c800000,0x40009e2b + .long 0xd036d9d3,0xbe04a851 + .long 0x4f600000,0x4000aa5d + .long 0xad856126,0xbdec74ff + .long 0x6c400000,0x4000b67a + .long 0x9512327c,0xbde6003f + .long 0xc1000000,0x4000c282 + .long 0x6614515e,0xbdec61f5 + .long 0x4d000000,0x4000ce76 + .long 0xe577796c,0xbddf8674 + .long 0x11200000,0x4000da55 + .long 0x0f49689f,0x3dc0b366 + .long 0x0fa00000,0x4000e61f + .long 0x1d23a023,0x3dffdf4d + .long 0x4c600000,0x4000f1d4 + .long 0x00a32d5c,0xbdfc94de + .long 0xcc000000,0x4000fd74 + .long 0x7b12a50e,0x3de89cb5 + .long 0x95200000,0x40010900 + .long 0x7f633dfc,0xbde8a71b + .long 0xaf200000,0x40011477 + .long 0xa22c576e,0xbddf043b + .long 0x22e00000,0x40011fda + .long 0xab4658e4,0xbdf583b2 + .long 0xfa400000,0x40012b27 + .long 0xc88a542e,0xbddc7052 + .long 0x40600000,0x40013661 + .long 0xb5fa251c,0x3dfc7430 + .long 0x01a00000,0x40014186 + .long 0x10065ac4,0x3dd53d2d + .long 0x4b200000,0x40014c96 + .long 0xfd4d5831,0x3dde4bf5 + .long 0x2b400000,0x40015792 + .long 0xdd63dfb7,0x3de0ceee + .long 0xb1400000,0x40016279 + .long 0xf44e5d9e,0x3e05a47a + .long 0xeda00000,0x40016d4c + .long 0xa9526aef,0xbd9c196f + .long 0xf1600000,0x4001780b + .long 0xddc7ed97,0xbdf1c75a + .long 0xce800000,0x400182b6 + .long 0x4537fbd1,0x3e03f9fd + .long 0x98600000,0x40018d4d + .long 0xcd4bedf5,0xbe0643b6 + .long 0x62400000,0x400197d0 + .long 0x7be31051,0xbdceee39 + .long 0x41000000,0x4001a23f + .long 0xe43916c2,0x3dab5864 + .long 0x49e00000,0x4001ac9a + .long 0xe65659f4,0x3dca8519 + .long 0x92e00000,0x4001b6e1 + .long 0xd8da3354,0x3df77c88 + .long 0x32e00000,0x4001c115 + .long 0xe2f9d62a,0xbde910ea + .long 0x41200000,0x4001cb35 + .long 0xc81075db,0xbe002e72 + .long 0xd5a00000,0x4001d541 + .long 0x272999cb,0xbdf8dc27 + .long 0x09000000,0x4001df3b + .long 0x46435ee9,0x3de1604f + .long 0xf4a00000,0x4001e920 + .long 0x86402d52,0xbdf84ccd + .long 0xb2000000,0x4001f2f3 + .long 0x7a698864,0xbdc1d852 + .long 0x5b800000,0x4001fcb3 + .long 0xe9f5ef5e,0x3de8ef47 + .long 0x0be00000,0x40020660 + .long 0x9d33bfe4,0x3deef548 + .long 0xde400000,0x40020ff9 + .long 0x9fe2acc6,0x3e07899e + .long 0xee800000,0x40021980 + .long 0x8586539c,0xbdea2a41 + .long 0x58600000,0x400222f5 + .long 0x8233d068,0xbde59a3f + .long 0x38600000,0x40022c57 + .long 0xafae28e0,0x3df61d5b + .long 0xab600000,0x400235a6 + .long 0xc0e105c1,0x3e07d566 + .long 0xcea00000,0x40023ee3 + .long 0x23305012,0x3de397c9 + .long 0xbf600000,0x4002480e + .long 0x7f34ee7e,0x3dedaddf + .long 0x9b800000,0x40025127 + .long 0x7552e9aa,0x3d940c8b + .long 0x80e00000,0x40025a2e + .long 0xe67562cc,0x3e06022a + .long 0x8e200000,0x40026323 + .long 0x36711271,0xbdfe8be0 + .long 0xe1400000,0x40026c06 + .long 0x34e171b8,0x3e03c83c + .long 0x99800000,0x400274d8 + .long 0x22b44c41,0xbdea7471 + .long 0xd5600000,0x40027d98 + .long 0x0cc87ce6,0x3dfb5597 + .long 0xb4400000,0x40028647 + .long 0xf1599d09,0x3df3fd61 + .long 0x55400000,0x40028ee5 + .long 0x432216e7,0x3e0074b2 + .long 0xd7e00000,0x40029771 + .long 0x55426d45,0x3dede47d + .long 0x5b800000,0x40029fed + .long 0xa81068a7,0x3e059214 + .long 0x00000000,0x4002a858 + .long 0xb830bfcf,0xbdd5c614 + .long 0xe4c00000,0x4002b0b1 + .long 0xaba3f9d3,0x3e092d16 + .long 0x2a000000,0x4002b8fb + .long 0xc83d37e0,0xbdefb3d7 + .long 0xef200000,0x4002c133 + .long 0x7f368cdd,0x3e0953b3 + .long 0x54800000,0x4002c95c + .long 0x27d71621,0x3df28d47 + .long 0x79e00000,0x4002d174 + .long 0x316a6da4,0xbdd16890 + .long 0x7f400000,0x4002d97c + .long 0x961b1ace,0xbdf9bc5b + .long 0x84800000,0x4002e184 + .long 0xe02465ce,0x3df0e16c + .long 0xa9e00000,0x4002e99c + .long 0x50352ef1,0xbdd817f9 + .long 0x0f400000,0x4002f1c5 + .long 0x1551a7ab,0xbe03100f + .long 0xd4800000,0x4002f9fd + .long 0xa40bccd6,0xbe01cf65 + .long 0x19800000,0x40030247 + .long 0x7c81d6bf,0x3dfa2d1b + .long 0xfe600000,0x40030aa0 + .long 0x01d5fa59,0x3df1f8ce + .long 0xa2c00000,0x4003130b + .long 0xc1d47c8b,0x3e00b18f + .long 0x26800000,0x40031b87 + .long 0xb6bb61ec,0xbdc357ae + .long 0xa9200000,0x40032413 + .long 0xb27a6369,0xbdf4621b + .long 0x4a200000,0x40032cb1 + .long 0x763f4a8f,0xbdddd864 + .long 0x29000000,0x40033560 + .long 0x71fd6503,0xbded9c9c + .long 0x64e00000,0x40033e20 + .long 0x6523f086,0x3df9c181 + .long 0x1d200000,0x400346f2 + .long 0x95f9190b,0xbdfb092f + .long 0x70600000,0x40034fd5 + .long 0xf5c5232a,0xbdf4ecd6 + .long 0x7d800000,0x400358ca + .long 0xf920fb33,0xbdff7d0c + .long 0x62e00000,0x400361d1 + .long 0x4be8fd7d,0x3de86e2d + .long 0x3f000000,0x40036aea + .long 0x5e8566d0,0xbdc27d37 + .long 0x2fc00000,0x40037415 + .long 0x118d12de,0x3dc5db22 + .long 0x53000000,0x40037d52 + .long 0x56fc208e,0xbe0191c2 + .long 0xc5e00000,0x400386a1 + .long 0x920dd0c2,0x3e0b34f6 + .long 0xa6200000,0x40039003 + .long 0xb58e26b3,0xbe0455cb + .long 0x10000000,0x40039978 + .long 0x34b985e6,0xbe0331cb + .long 0x20200000,0x4003a2ff + .long 0x35fdc794,0xbe0145fa + .long 0xf2800000,0x4003ac98 + .long 0xd680ac6a,0xbdc79adb + .long 0xa2e00000,0x4003b645 + .long 0x9da56c1b,0x3d6f49bd + .long 0x4c600000,0x4003c005 + .long 0x462df6e3,0x3ded84a6 + .long 0x09e00000,0x4003c9d8 + .long 0xa5f60849,0xbdfb2be9 + .long 0xf5600000,0x4003d3bd + .long 0x8540d783,0x3dceb909 + .long 0x28c00000,0x4003ddb7 + .long 0xfd79b218,0x3e02b1b7 + .long 0xbd400000,0x4003e7c3 + .long 0x31f55b0e,0x3e067217 + .long 0xcb800000,0x4003f1e3 + .long 0x4546b57a,0x3df90fbe + .long 0x6b600000,0x4003fc17 + .long 0xfd77cb88,0x3e0a855f + .long 0xb4800000,0x4004065e + .long 0x2dfdfe4d,0x3de26d4b + .long 0xbd600000,0x400410b9 + .long 0x5950035e,0x3de7590b + .long 0x9c200000,0x40041b28 + .long 0x03462c6f,0x3df06510 + .long 0x66200000,0x400425ab + .long 0x467966c2,0xbddbc526 + .long 0x2fe00000,0x40043042 + .long 0xb6a62d3d,0xbdfb6cb1 + .long 0x0d200000,0x40043aed + .long 0x27372402,0xbe00d8ae + .long 0x10c00000,0x400445ac + .long 0x24de2821,0x3de9ef5d + .long 0x4d200000,0x4004507f + .long 0x14d2f0d7,0xbdfec1ad + .long 0xd3200000,0x40045b66 + .long 0x945f6a25,0x3dd07f45 + .long 0xb3400000,0x40046662 + .long 0x51d9d163,0x3dd3d12d + .long 0xfcc00000,0x40047172 + .long 0x3f20ced0,0x3ddcdff6 + .long 0xbe000000,0x40047c97 + .long 0xc460b56d,0xbdefd9cf + .long 0x04200000,0x400487d1 + .long 0x85ec5f71,0x3df3a35d + .long 0xdba00000,0x4004931e + .long 0x80efdcb7,0xbdfdf504 + .long 0x4f400000,0x40049e81 + .long 0xbc54e040,0x3df44857 + .long 0x69400000,0x4004a9f8 + .long 0x937b6963,0x3df8dad6 + .long 0x32600000,0x4004b584 + .long 0x203bef0d,0x3d8c770b + .long 0xb2000000,0x4004c124 + .long 0x6a367be0,0x3e048e13 + .long 0xeec00000,0x4004ccd9 + .long 0x4959d5be,0xbdf35804 + .long 0xed400000,0x4004d8a3 + .long 0x23c13aa2,0x3de4e1b8 + .long 0xb1600000,0x4004e482 + .long 0x0d27a8c0,0x3df468e6 + .long 0x3d600000,0x4004f076 + .long 0x86d3f314,0x3dfab843 + .long 0x92200000,0x4004fc7e + .long 0x9e52e3a3,0x3df78768 + .long 0xaf200000,0x4005089b + .long 0xaab9c284,0xbe029f1b + .long 0x92000000,0x400514cd + .long 0x179103ea,0xbde45027 + .long 0x37400000,0x40052114 + .long 0x61cb6216,0x3e03c415 + .long 0x99e00000,0x40052d6f + .long 0xa75a55d3,0x3dded669 + .long 0xb2e00000,0x400539df + .long 0xcb6409f3,0xbde955aa + .long 0x79c00000,0x40054664 + .long 0xab71c36a,0xbdde1b72 + .long 0xe4600000,0x400552fd + .long 0xe25f9eb7,0x3dc41d1b + .long 0xe6c00000,0x40055fab + .long 0x247755ec,0x3e11a241 + .long 0x73800000,0x40056c6e + .long 0x5982d93b,0x3e07f5ae + .long 0x7b000000,0x40057945 + .long 0x81ce421b,0x3dea714b + .long 0xec000000,0x40058630 + .long 0xe6287509,0xbe10aaa8 + .long 0xb3000000,0x40059330 + .long 0xcdc1a134,0xbe018126 + .long 0xbb000000,0x4005a044 + .long 0x54f98005,0x3e0a53da + .long 0xed800000,0x4005ad6c + .long 0x31fa1c07,0xbe164bbe + .long 0x30800000,0x4005baa9 + .long 0x724fa9e7,0x3dfec315 + .long 0x69c00000,0x4005c7f9 + .long 0x49c8cff7,0xbd839929 + .long 0x7c000000,0x4005d55d + .long 0xa8203893,0xbe1aabb3 + .long 0x47800000,0x4005e2d5 + .long 0x4d9d0f03,0x3dc5d181 + .long 0xab800000,0x4005f060 + .long 0x39a53408,0x3e0a7fb5 + .long 0x84c00000,0x4005fdff + .long 0x01eb07f8,0xbe05ebb4 + .long 0xad400000,0x40060bb1 + .long 0x338ef683,0xbe128b26 + .long 0xfd400000,0x40061976 + .long 0xa822b748,0xbe07c5a2 + .long 0x4ac00000,0x4006274f + .long 0x5b4a549e,0x3e07b699 + .long 0x6a000000,0x4006353a + .long 0xef14ab75,0xbdf8030f + .long 0x2c000000,0x40064338 + .long 0xd329b8ff,0x3dee44e8 + .long 0x60800000,0x40065148 + .long 0xbc20f78f,0xbe13e3e3 + .long 0xd3c00000,0x40065f6a + .long 0x09e8e22c,0x3e11798e + .long 0x51400000,0x40066d9f + .long 0x7dfadb85,0x3e086b2e + .long 0xa1000000,0x40067be5 + .long 0x0b2e31ec,0x3e09f36f + .long 0x89400000,0x40068a3d + .long 0x23a7eaa9,0xbdf1ca09 + .long 0xcd800000,0x400698a6 + .long 0xee7c7516,0xbe0428c8 + .long 0x2f000000,0x4006a721 + .long 0xbdfcb3ab,0x3e0f4af1 + .long 0x6d400000,0x4006b5ac + .long 0x6678c10f,0x3e1197cf + .long 0x45000000,0x4006c448 + .long 0x0097612f,0xbdf8350f + .long 0x70400000,0x4006d2f4 + .long 0xc4ae0128,0xbdeb4341 + .long 0xa7400000,0x4006e1b0 + .long 0x2be5865a,0x3dee7616 + .long 0xa0000000,0x4006f07c + .long 0xbe2a9051,0xbe0d5116 + .long 0x0d800000,0x4006ff58 + .long 0xbe4813cb,0xbda6483b + .long 0xa1400000,0x40070e42 + .long 0xf702ea60,0x3df24157 + .long 0x0a000000,0x40071d3c + .long 0xc8e90440,0x3e11b030 + .long 0xf4800000,0x40072c43 + .long 0x3836de9f,0x3e18b285 + .long 0x0b400000,0x40073b5a + .long 0x707eec44,0x3e0abe53 + .long 0xf6400000,0x40074a7d + .long 0xdf7f7587,0x3e0227a4 + .long 0x5b800000,0x400759af + .long 0x69c4146d,0x3e0cea31 + .long 0xdf000000,0x400768ed + .long 0x2652ac89,0x3e0b070e + .long 0x22800000,0x40077839 + .long 0xb25e69d2,0x3e0029f0 + .long 0xc5800000,0x40078790 + .long 0xf2649c57,0x3e16b25a + .long 0x66400000,0x400796f4 + .long 0x229099f4,0xbe122655 + .long 0x9f800000,0x4007a663 + .long 0x90be8ad7,0x3ded1da0 + .long 0x0b800000,0x4007b5de + .long 0x5c75a10e,0x3e15cced + .long 0x42400000,0x4007c563 + .long 0xd4519719,0x3e102078 + .long 0xd9800000,0x4007d4f2 + .long 0x690de7e8,0x3e134413 + .long 0x65c00000,0x4007e48c + .long 0xfddbebee,0xbdf0721c + .long 0x79000000,0x4007f42f + .long 0x537a47ec,0x3e0472f8 + .long 0xa4800000,0x400803db + .long 0xd84d1e5e,0x3e03e9a5 + .long 0x77800000,0x40081390 + .long 0xa415fcda,0xbdf626df + .long 0x7f800000,0x4008234d + .long 0x279a2fcb,0xbe013463 + .long 0x48c00000,0x40083312 + .long 0x9b75c695,0x3dd9ba26 + .long 0x5e400000,0x400842de + .long 0x2aa926e7,0x3e00b4da + .long 0x49c00000,0x400852b1 + .long 0x44adccf7,0xbe0a51cf + .long 0x93400000,0x4008628a + .long 0x16e3fd45,0xbe15f538 + .long 0xc1c00000,0x40087269 + .long 0xce0df60f,0x3de6596a + .long 0x5c000000,0x4008824e + .long 0x5260007c,0xbe17daca + .long 0xe6400000,0x40089237 + .long 0xff43ed28,0x3df7d75a + .long 0xe5800000,0x4008a225 + .long 0x6082ccc7,0xbe0886df + .long 0xdc800000,0x4008b217 + .long 0xfbad1fdf,0xbdb73f18 + .long 0x4e400000,0x4008c20d + .long 0xc29df075,0xbdf92ca0 + .long 0xbc800000,0x4008d205 + .long 0xdc3f35d7,0xbdc7a0f1 + .long 0xa8c00000,0x4008e200 + .long 0xfa8ff5ca,0x3df9b457 + .long 0x94400000,0x4008f1fd + .long 0x1262ed72,0xbe1633d0 + .long 0xff000000,0x400901fb + .long 0x541ee425,0xbe078e5a + .long 0x69800000,0x400911fb + .long 0xfb02186a,0x3e094f3a + .long 0x54400000,0x400921fb + .long 0x1a626331,0x3de0b461 + .type __libm_atanl_table_128,@object + .size __libm_atanl_table_128,8208 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cabs.S b/external/sgx_libm/ia32/cabs.S new file mode 100644 index 0000000000..b66ec717a8 --- /dev/null +++ b/external/sgx_libm/ia32/cabs.S @@ -0,0 +1,76 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cabs.c" + .text +..TXTST0: +# -- Begin cabs + .text + .align 16,0x90 + .globl cabs +cabs: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %ebx + subl $60, %esp + fldl 16(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpl (%esp) + fldl 8(%ebp) + fstpl 8(%esp) + call hypot@PLT +..B1.4: + addl $60, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type cabs,@function + .size cabs,.-cabs + .data +# -- End cabs + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cabsf.S b/external/sgx_libm/ia32/cabsf.S new file mode 100644 index 0000000000..382d1d02c4 --- /dev/null +++ b/external/sgx_libm/ia32/cabsf.S @@ -0,0 +1,71 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cabsf.c" + .text +..TXTST0: +# -- Begin cabsf + .text + .align 16,0x90 + .globl cabsf +cabsf: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $24, %esp + flds 36(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpl (%esp) + flds 32(%esp) + fstpl 8(%esp) + call hypot@PLT +..B1.4: + addl $24, %esp + popl %ebx + ret + .align 16,0x90 + .type cabsf,@function + .size cabsf,.-cabsf + .data +# -- End cabsf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cabsl.S b/external/sgx_libm/ia32/cabsl.S new file mode 100644 index 0000000000..300d337946 --- /dev/null +++ b/external/sgx_libm/ia32/cabsl.S @@ -0,0 +1,76 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cabsl.c" + .text +..TXTST0: +# -- Begin cabsl + .text + .align 16,0x90 + .globl cabsl +cabsl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %ebx + subl $60, %esp + fldt 20(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpt (%esp) + fldt 8(%ebp) + fstpt 12(%esp) + call hypotl@PLT +..B1.4: + addl $60, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type cabsl,@function + .size cabsl,.-cabsl + .data +# -- End cabsl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cacos.S b/external/sgx_libm/ia32/cacos.S new file mode 100644 index 0000000000..96bcfa3631 --- /dev/null +++ b/external/sgx_libm/ia32/cacos.S @@ -0,0 +1,779 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacos.c" + .text +..TXTST0: +# -- Begin cacos + .text + .align 16,0x90 + .globl cacos +cacos: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 192(%esp) + fstl 176(%esp) + fstpl 184(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 18(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %ecx + jge ..B1.38 +..B1.4: + testl %ecx, %ecx + jle ..B1.64 +..B1.5: + movzwl 26(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + jge ..B1.38 +..B1.6: + testl %edx, %edx + jle ..B1.62 +..B1.7: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.61 +..B1.8: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movl $1, %edi +..B1.11: + fldl 12(%ebp) + fstl 160(%esp) + fabs + fldl 20(%ebp) + fstl 168(%esp) + fabs + fld %st(0) + fmul %st(1), %st + fstpt 120(%esp) + fldt 120(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fld %st(0) + fsubr %st(4), %st + fld %st(0) + fmul %st(1), %st + fadd %st(3), %st + fsqrt + fstpt 88(%esp) + fldt 88(%esp) + fld %st(2) + fadd %st(6), %st + fld %st(0) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(4) + fsqrt + fstpt 104(%esp) + fldt 104(%esp) + fxch %st(1) + fucom %st(2) + fnstsw %ax + faddp %st, %st(1) + fxch %st(1) + fstpt 136(%esp) + sahf + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmul %st, %st(1) + jp ..B1.12 + je ..B1.13 +..B1.12: + fldt 88(%esp) + fldt 136(%esp) + fsubrp %st, %st(1) + fstpt 72(%esp) + jmp ..B1.14 +..B1.13: + fxch %st(4) + fstpt 72(%esp) + fldt 72(%esp) + fxch %st(4) +..B1.14: + fldt _Bcross@GOTOFF(%ebx) + fmul %st(2), %st + fcomp %st(6) + fnstsw %ax + sahf + jbe ..B1.16 +..B1.15: + fstp %st(4) + fld %st(4) + addl $-16, %esp + fdiv %st(1), %st + fstpt (%esp) + fxch %st(4) + fstpl 80(%esp) + fxch %st(1) + fstpt 16(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt 48(%esp) + fstpt 64(%esp) + call acosl@PLT +..B1.104: + fldt 64(%esp) + fldt 48(%esp) + fldt 32(%esp) + fldt 16(%esp) + fldl 80(%esp) + addl $16, %esp + jmp ..B1.19 +..B1.16: + fxch %st(2) + fcom %st(5) + fnstsw %ax + sahf + jb ..B1.18 +..B1.17: + fstp %st(4) + addl $-32, %esp + fld %st(2) + fld %st(1) + fadd %st(6), %st + fmul %st(3), %st + fldt 136(%esp) + faddp %st, %st(2) + fldt 152(%esp) + fdivp %st, %st(2) + fldt 104(%esp) + faddp %st, %st(2) + fmulp %st, %st(1) + fsqrt + fstpt (%esp) + fxch %st(4) + fstpt 12(%esp) + fldt 12(%esp) + fstpl 96(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt 48(%esp) + fstpt 64(%esp) + fstpt 80(%esp) + call atan2l@PLT + jmp ..B1.106 +..B1.18: + fxch %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fxch %st(3) + fstpt (%esp) + fldt (%esp) + addl $-32, %esp + fxch %st(3) + fadd %st(5), %st + fldt 136(%esp) + faddp %st, %st(4) + fdiv %st, %st(3) + fldt 168(%esp) + fldt 120(%esp) + faddp %st, %st(1) + fdivrp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fsqrt + fmulp %st, %st(3) + fxch %st(2) + fstpt (%esp) + fxch %st(2) + fstpt 12(%esp) + fldt 12(%esp) + fstpl 96(%esp) + fxch %st(1) + fstpt 48(%esp) + fstpt 64(%esp) + fldt 32(%esp) + fstpt 32(%esp) + fldt 80(%esp) + fstpt 80(%esp) + call atan2l@PLT +..B1.106: + fldt 80(%esp) + fldt 64(%esp) + fldt 48(%esp) + fldt 32(%esp) + fldl 96(%esp) + addl $32, %esp +..B1.19: + fldt _Across@GOTOFF(%ebx) + fcomp %st(5) + fnstsw %ax + sahf + jb ..B1.24 +..B1.20: + fldt 104(%esp) + faddp %st, %st(2) + fcomp %st(3) + fnstsw %ax + fldt 120(%esp) + fdivp %st, %st(1) + sahf + jae ..B1.22 + jp ..B1.22 +..B1.21: + fldt 72(%esp) + fldt 120(%esp) + fdivp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + jmp ..B1.23 +..B1.22: + fldt 88(%esp) + fldt 136(%esp) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) +..B1.23: + addl $-16, %esp + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%esp) + fstpt 16(%esp) + call log1pl@PLT + jmp ..B1.108 +..B1.24: + fstp %st(1) + fstp %st(1) + fstp %st(0) + fld %st(1) + addl $-16, %esp + fmul %st(2), %st + fsubp %st, %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%esp) + fstpt 16(%esp) + call logl@PLT +..B1.108: + fldt 16(%esp) + addl $16, %esp +..B1.25: + fldl _DBL_PZERO@GOTOFF(%ebx) + fcoml 160(%esp) + fnstsw %ax + sahf + jbe ..B1.27 +..B1.26: + fldt _LDBL_PPI@GOTOFF(%ebx) + fsubp %st, %st(2) +..B1.27: + fldl 168(%esp) + fcompp + fnstsw %ax + sahf + jbe ..B1.29 +..B1.28: + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fmulp %st, %st(2) +..B1.29: + fstpl 176(%esp) + movzwl 182(%esp), %edx + testl $32752, %edx + fstpl 184(%esp) + jne ..B1.32 +..B1.30: + testl $1048575, 180(%esp) + jne ..B1.35 +..B1.31: + cmpl $0, 176(%esp) + jne ..B1.35 +..B1.32: + movzwl 190(%esp), %edx + testl $32752, %edx + jne ..B1.36 +..B1.33: + testl $1048575, 188(%esp) + jne ..B1.35 +..B1.34: + cmpl $0, 184(%esp) + je ..B1.36 +..B1.35: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 152(%esp) +..B1.36: + testl %edi, %edi + je ..B1.59 +..B1.37: + fldcw 14(%esp) + jmp ..B1.59 +..B1.38: + testl %ecx, %ecx + jne ..B1.42 +..B1.39: + testl $1048575, 16(%ebp) + jne ..B1.42 +..B1.40: + cmpl $0, 12(%ebp) + jne ..B1.42 +..B1.41: + fldl _DBL_PPIBY2@GOTOFF(%ebx) + fstl 176(%esp) + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + faddp %st, %st(1) + fstpl 152(%esp) + addl $-16, %esp + fldl 20(%ebp) + fstpl (%esp) + call asinh@PLT +..B1.109: + addl $16, %esp + fchs + fstpl 184(%esp) + jmp ..B1.59 +..B1.42: + movzwl 26(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + je ..B1.98 +..B1.115: + cmpl $2047, %ecx +..B1.43: + je ..B1.88 +..B1.44: + cmpl $2047, %edx + je ..B1.85 +..B1.45: + testl %edx, %edx + jne ..B1.54 +..B1.46: + testl $1048575, 24(%ebp) + jne ..B1.54 +..B1.47: + cmpl $0, 20(%ebp) + jne ..B1.54 +..B1.48: + cmpl $1023, %ecx + jl ..B1.52 +..B1.49: + fldl 12(%ebp) + addl $-16, %esp + fabs + fstpl (%esp) + call acosh@PLT +..B1.110: + addl $16, %esp + movzbl 19(%ebp), %edx + testl $128, %edx + fstpl 184(%esp) + je ..B1.51 +..B1.50: + fldl _DBL_PPI@GOTOFF(%ebx) + fstl 176(%esp) + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + faddp %st, %st(1) + fstpl 152(%esp) + jmp ..B1.53 +..B1.51: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 176(%esp) + jmp ..B1.53 +..B1.52: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 184(%esp) + addl $-16, %esp + fldl 12(%ebp) + fstpl (%esp) + call acos@PLT +..B1.111: + addl $16, %esp + fstpl 176(%esp) +..B1.53: + movzbl 27(%ebp), %edi + shrl $7, %edi + notl %edi + movzbl 191(%esp), %edx + shll $7, %edi + andl $127, %edx + orl %edi, %edx + movb %dl, 191(%esp) + jmp ..B1.59 +..B1.54: + cmpl $2047, %ecx + je ..B1.67 +..B1.55: + jge ..B1.57 +..B1.56: + fldl _DBL_PPIBY2@GOTOFF(%ebx) + fstl 176(%esp) + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + faddp %st, %st(1) + fstpl 152(%esp) + fldl _DBL_PZERO@GOTOFF(%ebx) + faddl 12(%ebp) + fstpl 152(%esp) + jmp ..B1.58 +..B1.57: + fldl 12(%ebp) + faddl _DBL_PZERO@GOTOFF(%ebx) + fstpl 176(%esp) +..B1.58: + fldl 20(%ebp) + fchs + fstpl 184(%esp) +..B1.59: + movl 176(%esp), %edx + movl %edx, (%esi) + movl 180(%esp), %ecx + movl 184(%esp), %edi + movl 188(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 192(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.66 +..B1.60: + movl %esi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.61: + xorl %edi, %edi + jmp ..B1.11 +..B1.62: + testl $1048575, 24(%ebp) + jne ..B1.7 +..B1.63: + cmpl $0, 20(%ebp) + jne ..B1.7 + jmp ..B1.38 +..B1.64: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.65: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.38 +..B1.66: + call __stack_chk_fail@PLT +..B1.67: + testl $1048575, 16(%ebp) + jne ..B1.113 +..B1.68: + cmpl $0, 12(%ebp) + jne ..B1.113 +..B1.69: + fldl 12(%ebp) + cmpl $2047, %edx + fmul %st(0), %st + fstpl 184(%esp) + jge ..B1.76 +..B1.70: + movzbl 19(%ebp), %edx + testl $128, %edx + je ..B1.72 +..B1.71: + fldl _DBL_PPI@GOTOFF(%ebx) + fstl 176(%esp) + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + faddp %st, %st(1) + fstpl 152(%esp) + fldl _DBL_PZERO@GOTOFF(%ebx) + jmp ..B1.73 +..B1.72: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstl 176(%esp) +..B1.73: + movzbl 27(%ebp), %edx + testl $128, %edx + jne ..B1.75 +..B1.74: + movzbl 191(%esp), %edi + movl %edi, %edx + shrl $7, %edi + andl $127, %edx + notl %edi + shll $7, %edi + orl %edi, %edx + movb %dl, 191(%esp) +..B1.75: + faddl 20(%ebp) + fstpl 152(%esp) + jmp ..B1.59 +..B1.76: + testl $1048575, 24(%ebp) + jne ..B1.84 +..B1.77: + cmpl $0, 20(%ebp) + jne ..B1.84 +..B1.78: + movzbl 19(%ebp), %edx + testl $128, %edx + je ..B1.80 +..B1.79: + fldl _DBL_P3PIBY4@GOTOFF(%ebx) + jmp ..B1.81 +..B1.80: + fldl _DBL_PPIBY4@GOTOFF(%ebx) +..B1.81: + movzbl 27(%ebp), %edx + testl $128, %edx + fstl 176(%esp) + jne ..B1.83 +..B1.82: + movzbl 191(%esp), %edi + movl %edi, %edx + shrl $7, %edi + andl $127, %edx + notl %edi + shll $7, %edi + orl %edi, %edx + movb %dl, 191(%esp) +..B1.83: + faddl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fstpl 152(%esp) + jmp ..B1.59 +..B1.84: + fldl 20(%ebp) + fmul %st(0), %st + fstpl 176(%esp) + jmp ..B1.59 +..B1.85: + testl $1048575, 24(%ebp) + jne ..B1.87 +..B1.86: + cmpl $0, 20(%ebp) + je ..B1.54 +..B1.87: + fldl 20(%ebp) + fmul %st(0), %st + fstpl 176(%esp) + fldl 12(%ebp) + fmul %st(0), %st + fstpl 184(%esp) + jmp ..B1.59 +..B1.88: + testl $1048575, 16(%ebp) + jne ..B1.90 +..B1.89: + cmpl $0, 12(%ebp) + je ..B1.92 +..B1.90: + cmpl $2047, %edx + jge ..B1.92 +..B1.91: + fldl 12(%ebp) + fmul %st(0), %st + fstl 176(%esp) + fstpl 184(%esp) + jmp ..B1.59 +..B1.92: + testl $1048575, 16(%ebp) + jne ..B1.94 +..B1.93: + cmpl $0, 12(%ebp) + je ..B1.44 +..B1.94: + cmpl $2047, %edx + jne ..B1.45 +..B1.95: + testl $1048575, 24(%ebp) + jne ..B1.97 +..B1.96: + cmpl $0, 20(%ebp) + je ..B1.85 +..B1.97: + fldl 12(%ebp) + fmul %st(0), %st + fstpl 176(%esp) + fldl 20(%ebp) + fmul %st(0), %st + fstpl 184(%esp) + jmp ..B1.59 +..B1.98: + testl $1048575, 24(%ebp) + jne ..B1.100 +..B1.99: + cmpl $0, 20(%ebp) + je ..B1.112 +..B1.100: + cmpl $2047, %ecx + jge ..B1.43 +..B1.101: + fldl 20(%ebp) + fmul %st(0), %st + fstl 176(%esp) + fstpl 184(%esp) + jmp ..B1.59 +..B1.112: + cmpl $2047, %ecx + je ..B1.88 + jmp ..B1.44 +..B1.113: + cmpl $2047, %ecx + jl ..B1.56 + jmp ..B1.57 + .align 16,0x90 + .type cacos,@function + .size cacos,.-cacos + .data +# -- End cacos + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +_Bcross: + .word -2936 + .word -10277 + .word 29569 + .word -23482 + .word 16382 + .word 0 + .type _Bcross,@object + .size _Bcross,12 + .space 4, 0x00 # pad + .align 16 +_Across: + .word 0 + .word 0 + .word 0 + .word -16384 + .word 16383 + .word 0 + .type _Across,@object + .size _Across,12 + .space 4, 0x00 # pad + .align 16 +_DBL_PZERO: + .long 0 + .long 0 + .type _DBL_PZERO,@object + .size _DBL_PZERO,8 + .space 8, 0x00 # pad + .align 16 +_LDBL_PPI: + .word -15819 + .word 8552 + .word -9566 + .word -14065 + .word 16384 + .word 0 + .type _LDBL_PPI,@object + .size _LDBL_PPI,12 + .space 4, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPIBY2: + .long 1413754136 + .long 1073291771 + .type _DBL_PPIBY2,@object + .size _DBL_PPIBY2,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPI: + .long 1413754136 + .long 1074340347 + .type _DBL_PPI,@object + .size _DBL_PPI,8 + .space 8, 0x00 # pad + .align 16 +_DBL_P3PIBY4: + .long 2134057426 + .long 1073928572 + .type _DBL_P3PIBY4,@object + .size _DBL_P3PIBY4,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPIBY4: + .long 1413754136 + .long 1072243195 + .type _DBL_PPIBY4,@object + .size _DBL_PPIBY4,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cacosf.S b/external/sgx_libm/ia32/cacosf.S new file mode 100644 index 0000000000..2e7bef3937 --- /dev/null +++ b/external/sgx_libm/ia32/cacosf.S @@ -0,0 +1,638 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacosf.c" + .text +..TXTST0: +# -- Begin cacosf + .text + .align 16,0x90 + .globl cacosf +cacosf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %ebx + subl $124, %esp + fldz + movzwl 10(%ebp), %edx + andl $32640, %edx + shrl $7, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %edx + fsts 104(%esp) + fsts 108(%esp) + jge ..B1.28 +..B1.2: + testl %edx, %edx + jle ..B1.50 +..B1.3: + movzwl 14(%ebp), %eax + andl $32640, %eax + shrl $7, %eax + cmpl $255, %eax + jge ..B1.91 +..B1.4: + testl %eax, %eax + jle ..B1.49 +..B1.5: + flds 8(%ebp) + fsts 96(%esp) + fld1 + fsts 92(%esp) + fxch %st(1) + fabs + fld %st(0) + fsub %st(2), %st + fld %st(0) + fmul %st(1), %st + fld %st(2) + faddp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fxch %st(2) + fstl 72(%esp) + flds 12(%ebp) + fsts 100(%esp) + fabs + fld %st(0) + fmul %st(1), %st + fstl 56(%esp) + fadd %st, %st(3) + fxch %st(3) + fsqrt + fstl 64(%esp) + fxch %st(3) + faddp %st, %st(4) + fxch %st(3) + fsqrt + fstl 48(%esp) + fxch %st(1) + fucomp %st(2) + fnstsw %ax + faddp %st, %st(1) + fldl .L_2il0floatpacket.6@GOTOFF(%ebx) + sahf + fmul %st, %st(1) + jp ..B1.6 + je ..B1.7 +..B1.6: + fldl 64(%esp) + fsubl 72(%esp) + fstpl 40(%esp) + jmp ..B1.8 +..B1.7: + fxch %st(2) + fstl 40(%esp) + fxch %st(2) +..B1.8: + fldl _Bcross@GOTOFF(%ebx) + fmul %st(2), %st + fcomp %st(4) + fnstsw %ax + sahf + jbe ..B1.10 +..B1.9: + fstp %st(2) + fld %st(2) + fdiv %st(1), %st + fstpl (%esp) + fxch %st(2) + fstps 80(%esp) + fxch %st(2) + fstpl 16(%esp) + fxch %st(1) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + call acos@PLT + jmp ..B1.85 +..B1.10: + flds 92(%esp) + fcomp %st(4) + fnstsw %ax + sahf + jb ..B1.12 +..B1.11: + fstp %st(2) + fld %st(3) + fld %st(1) + fadd %st(4), %st + fmul %st(3), %st + fxch %st(1) + faddl 48(%esp) + fdivrl 56(%esp) + faddl 40(%esp) + fmulp %st, %st(1) + fsqrt + fxch %st(3) + fstl 8(%esp) + fxch %st(3) + fstpl (%esp) + fxch %st(2) + fstps 80(%esp) + fxch %st(2) + fstpl 16(%esp) + fxch %st(1) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + call atan2@PLT + jmp ..B1.85 +..B1.12: + fldl 72(%esp) + fld %st(2) + fadd %st(5), %st + fxch %st(6) + fstl 16(%esp) + fxch %st(1) + faddl 64(%esp) + fxch %st(1) + faddl 48(%esp) + fdivr %st(6), %st + fxch %st(1) + fdivrp %st, %st(6) + faddp %st, %st(5) + fmul %st, %st(4) + fxch %st(4) + fsqrt + fmulp %st, %st(2) + fxch %st(2) + fstl 8(%esp) + fxch %st(1) + fstpl (%esp) + fstps 80(%esp) + fxch %st(1) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + fldl 16(%esp) + fstpl 16(%esp) + call atan2@PLT +..B1.85: + flds 84(%esp) + fldl 32(%esp) + fldl 24(%esp) + fldl 16(%esp) + flds 80(%esp) +..B1.13: + fldl _Across@GOTOFF(%ebx) + fcomp %st(4) + fnstsw %ax + sahf + jb ..B1.18 +..B1.14: + flds 92(%esp) + fcompp + fnstsw %ax + faddl 48(%esp) + fdivrl 56(%esp) + sahf + jbe ..B1.16 +..B1.15: + fldl 56(%esp) + fdivl 40(%esp) + faddp %st, %st(1) + fmulp %st, %st(1) + jmp ..B1.17 +..B1.16: + fldl 72(%esp) + faddl 64(%esp) + faddp %st, %st(1) + fmulp %st, %st(1) +..B1.17: + fxch %st(1) + fadds 92(%esp) + fmul %st(1), %st + fsqrt + faddp %st, %st(1) + fstpl (%esp) + fxch %st(1) + fstpl 16(%esp) + fstps 84(%esp) + call log1p@PLT + jmp ..B1.87 +..B1.18: + fstp %st(1) + fstp %st(1) + fstp %st(0) + fld %st(0) + fmul %st(1), %st + fsubs 92(%esp) + fsqrt + faddp %st, %st(1) + fstpl (%esp) + fxch %st(1) + fstpl 16(%esp) + fstps 84(%esp) + call log@PLT +..B1.87: + flds 84(%esp) + fldl 16(%esp) +..B1.19: + fxch %st(1) + fcoms 96(%esp) + fnstsw %ax + sahf + jbe ..B1.21 +..B1.20: + fxch %st(1) + fsubrl _DBL_PPI@GOTOFF(%ebx) + fxch %st(1) +..B1.21: + flds 100(%esp) + fcompp + fnstsw %ax + sahf + jbe ..B1.23 +..B1.22: + fxch %st(1) + fchs + fxch %st(1) +..B1.23: + fstps 104(%esp) + movzwl 106(%esp), %eax + testl $32640, %eax + fstps 108(%esp) + jne ..B1.25 +..B1.24: + testl $8388607, 104(%esp) + jne ..B1.27 +..B1.25: + movzwl 110(%esp), %eax + testl $32640, %eax + jne ..B1.48 +..B1.26: + testl $8388607, 108(%esp) + je ..B1.48 +..B1.27: + flds .L_2il0floatpacket.11@GOTOFF(%ebx) + fmul %st(0), %st + fstps 88(%esp) + jmp ..B1.48 +..B1.28: + je ..B1.79 +..B1.29: + testl %edx, %edx + jne ..B1.32 +..B1.30: + testl $8388607, 8(%ebp) + jne ..B1.32 +..B1.31: + fstp %st(0) + movl $1070141403, %eax + movl %eax, 104(%esp) + movl %eax, 88(%esp) + addl $4, %esp + pushl 12(%ebp) + call asinhf@PLT +..B1.88: + fchs + fstps 108(%esp) + jmp ..B1.48 +..B1.32: + movzwl 14(%ebp), %eax + andl $32640, %eax + shrl $7, %eax + cmpl $255, %eax + je ..B1.76 +..B1.33: + cmpl $255, %edx + je ..B1.69 +..B1.34: + cmpl $255, %eax + je ..B1.95 +..B1.35: + testl %eax, %eax + jne ..B1.43 +..B1.36: + testl $8388607, 12(%ebp) + jne ..B1.43 +..B1.37: + cmpl $127, %edx + jl ..B1.41 +..B1.38: + flds 8(%ebp) + fabs + fstps (%esp) + fstps 84(%esp) + call acoshf@PLT +..B1.89: + flds 84(%esp) + movzbl 11(%ebp), %eax + testl $128, %eax + fxch %st(1) + fstps 108(%esp) + je ..B1.40 +..B1.39: + fstp %st(0) + movl $1078530011, %eax + movl %eax, 104(%esp) + movl %eax, 88(%esp) + jmp ..B1.42 +..B1.40: + fstps 104(%esp) + jmp ..B1.42 +..B1.41: + movl 8(%ebp), %eax + fstps 108(%esp) + movl %eax, (%esp) + call acosf@PLT +..B1.90: + fstps 104(%esp) +..B1.42: + movzbl 15(%ebp), %eax + shrl $7, %eax + notl %eax + movzbl 111(%esp), %edx + shll $7, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 111(%esp) + jmp ..B1.48 +..B1.43: + cmpl $255, %edx + je ..B1.51 +..B1.44: + fstp %st(0) + cmpl $255, %edx + jge ..B1.46 +..B1.45: + movl 8(%ebp), %edx + movl $1070141403, %eax + movl %eax, 88(%esp) + movl %eax, 104(%esp) + movl %edx, 88(%esp) + jmp ..B1.47 +..B1.46: + movl 8(%ebp), %eax + movl %eax, 104(%esp) +..B1.47: + flds 12(%ebp) + fchs + fstps 108(%esp) +..B1.48: + movl 104(%esp), %eax + movl 108(%esp), %edx + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.49: + testl $8388607, 12(%ebp) + jne ..B1.5 + jmp ..B1.91 +..B1.50: + testl $8388607, 8(%ebp) + jne ..B1.3 + jmp ..B1.91 +..B1.51: + testl $8388607, 8(%ebp) + jne ..B1.44 +..B1.52: + flds 8(%ebp) + cmpl $255, %eax + fmul %st(0), %st + fstps 108(%esp) + jge ..B1.59 +..B1.53: + movzbl 11(%ebp), %eax + testl $128, %eax + je ..B1.55 +..B1.54: + fstp %st(0) + movl $1078530011, %eax + movl %eax, 104(%esp) + movl %eax, 88(%esp) + jmp ..B1.56 +..B1.55: + fstps 104(%esp) +..B1.56: + movzbl 15(%ebp), %eax + testl $128, %eax + jne ..B1.58 +..B1.57: + movzbl 111(%esp), %eax + movl %eax, %edx + shrl $7, %eax + andl $127, %edx + notl %eax + shll $7, %eax + orl %eax, %edx + movb %dl, 111(%esp) +..B1.58: + movl 12(%ebp), %eax + movl %eax, 88(%esp) + jmp ..B1.48 +..B1.59: + fstp %st(0) + testl $8388607, 12(%ebp) + jne ..B1.66 +..B1.60: + movzbl 11(%ebp), %eax + testl $128, %eax + je ..B1.62 +..B1.61: + flds .L_2il0floatpacket.9@GOTOFF(%ebx) + jmp ..B1.63 +..B1.62: + flds .L_2il0floatpacket.10@GOTOFF(%ebx) +..B1.63: + movzbl 15(%ebp), %eax + testl $128, %eax + fsts 104(%esp) + jne ..B1.65 +..B1.64: + movzbl 111(%esp), %eax + movl %eax, %edx + shrl $7, %eax + andl $127, %edx + notl %eax + shll $7, %eax + orl %eax, %edx + movb %dl, 111(%esp) +..B1.65: + fadds .L_2il0floatpacket.11@GOTOFF(%ebx) + fstps 88(%esp) + jmp ..B1.48 +..B1.66: + flds 12(%ebp) + fmul %st(0), %st + fstps 104(%esp) + jmp ..B1.48 +..B1.95: + testl $8388607, 12(%ebp) +..B1.67: + je ..B1.43 +..B1.68: + fstp %st(0) + flds 12(%ebp) + fmul %st(0), %st + fstps 104(%esp) + flds 8(%ebp) + fmul %st(0), %st + fstps 108(%esp) + jmp ..B1.48 +..B1.69: + testl $8388607, 8(%ebp) + je ..B1.72 +..B1.70: + cmpl $255, %eax + jge ..B1.94 +..B1.71: + fstp %st(0) + flds 8(%ebp) + fmul %st(0), %st + fsts 104(%esp) + fstps 108(%esp) + jmp ..B1.48 +..B1.72: + je ..B1.34 +..B1.73: + cmpl $255, %eax + jne ..B1.35 +..B1.74: + testl $8388607, 12(%ebp) + je ..B1.67 +..B1.75: + fstp %st(0) + flds 8(%ebp) + fmul %st(0), %st + fstps 104(%esp) + flds 12(%ebp) + fmul %st(0), %st + fstps 108(%esp) + jmp ..B1.48 +..B1.76: + testl $8388607, 12(%ebp) + je ..B1.33 +..B1.77: + cmpl $255, %edx + jge ..B1.33 +..B1.78: + fstp %st(0) + flds 12(%ebp) + fmul %st(0), %st + fsts 104(%esp) + fstps 108(%esp) + jmp ..B1.48 +..B1.79: + testl $8388607, 8(%ebp) + je ..B1.32 +..B1.80: + flds 8(%ebp) + fadd %st(0), %st + fstps 8(%ebp) + movzwl 10(%ebp), %edx + andl $32640, %edx + shrl $7, %edx + jmp ..B1.29 +..B1.91: + cmpl $255, %edx + je ..B1.79 + jmp ..B1.29 +..B1.94: + testl $8388607, 8(%ebp) + jne ..B1.73 + jmp ..B1.34 + .align 16,0x90 + .type cacosf,@function + .size cacosf,.-cacosf + .data +# -- End cacosf + .section .rodata, "a" + .align 16 + .align 16 +_Bcross: + .long 1882913663 + .long 1071941838 + .type _Bcross,@object + .size _Bcross,8 + .space 8, 0x00 # pad + .align 16 +_Across: + .long 0 + .long 1073217536 + .type _Across,@object + .size _Across,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPI: + .long 1413754136 + .long 1074340347 + .type _DBL_PPI,@object + .size _DBL_PPI,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 4 +.L_2il0floatpacket.7: + .long 0x3fc90fdb + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,4 + .align 4 +.L_2il0floatpacket.8: + .long 0x40490fdb + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .align 4 +.L_2il0floatpacket.9: + .long 0x4016cbe4 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,4 + .align 4 +.L_2il0floatpacket.10: + .long 0x3f490fdb + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .align 4 +.L_2il0floatpacket.11: + .long 0x00800000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cacosh.S b/external/sgx_libm/ia32/cacosh.S new file mode 100644 index 0000000000..6b85720176 --- /dev/null +++ b/external/sgx_libm/ia32/cacosh.S @@ -0,0 +1,789 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacosh.c" + .text +..TXTST0: +# -- Begin cacosh + .text + .align 16,0x90 + .globl cacosh +cacosh: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 184(%esp) + fstl 168(%esp) + fstpl 176(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 18(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %ecx + jge ..B1.36 +..B1.4: + testl %ecx, %ecx + jle ..B1.71 +..B1.5: + movzwl 26(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + jge ..B1.37 +..B1.6: + testl %edx, %edx + jle ..B1.69 +..B1.7: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.68 +..B1.8: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movl $1, %edi +..B1.11: + fldl 12(%ebp) + fstl 152(%esp) + fabs + fldl 20(%ebp) + fabs + fld %st(0) + fmul %st(1), %st + fstpt 120(%esp) + fldt 120(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fld %st(0) + fsubr %st(4), %st + fld %st(0) + fmul %st(1), %st + fadd %st(3), %st + fsqrt + fstpt 88(%esp) + fldt 88(%esp) + fld %st(2) + fadd %st(6), %st + fld %st(0) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(4) + fsqrt + fstpt 104(%esp) + fldt 104(%esp) + fxch %st(1) + fucom %st(2) + fnstsw %ax + faddp %st, %st(1) + fxch %st(1) + fstpt 136(%esp) + sahf + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmul %st, %st(1) + jp ..B1.12 + je ..B1.13 +..B1.12: + fldt 88(%esp) + fldt 136(%esp) + fsubrp %st, %st(1) + fstpt 72(%esp) + jmp ..B1.14 +..B1.13: + fxch %st(4) + fstpt 72(%esp) + fldt 72(%esp) + fxch %st(4) +..B1.14: + fldt _Bcross@GOTOFF(%ebx) + fmul %st(2), %st + fcomp %st(6) + fnstsw %ax + sahf + jbe ..B1.16 +..B1.15: + fstp %st(4) + fld %st(4) + addl $-16, %esp + fdiv %st(1), %st + fstpt (%esp) + fxch %st(4) + fstpl 80(%esp) + fxch %st(1) + fstpt 16(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt 48(%esp) + fstpt 64(%esp) + call acosl@PLT +..B1.109: + fldt 64(%esp) + fldt 48(%esp) + fldt 32(%esp) + fldt 16(%esp) + fldl 80(%esp) + addl $16, %esp + jmp ..B1.19 +..B1.16: + fxch %st(2) + fcom %st(5) + fnstsw %ax + sahf + jb ..B1.18 +..B1.17: + fstp %st(4) + addl $-32, %esp + fld %st(2) + fld %st(1) + fadd %st(6), %st + fmul %st(3), %st + fldt 136(%esp) + faddp %st, %st(2) + fldt 152(%esp) + fdivp %st, %st(2) + fldt 104(%esp) + faddp %st, %st(2) + fmulp %st, %st(1) + fsqrt + fstpt (%esp) + fxch %st(4) + fstpt 12(%esp) + fldt 12(%esp) + fstpl 96(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt 48(%esp) + fstpt 64(%esp) + fstpt 80(%esp) + call atan2l@PLT + jmp ..B1.111 +..B1.18: + fxch %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fxch %st(3) + fstpt (%esp) + fldt (%esp) + addl $-32, %esp + fxch %st(3) + fadd %st(5), %st + fldt 136(%esp) + faddp %st, %st(4) + fdiv %st, %st(3) + fldt 168(%esp) + fldt 120(%esp) + faddp %st, %st(1) + fdivrp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fsqrt + fmulp %st, %st(3) + fxch %st(2) + fstpt (%esp) + fxch %st(2) + fstpt 12(%esp) + fldt 12(%esp) + fstpl 96(%esp) + fxch %st(1) + fstpt 48(%esp) + fstpt 64(%esp) + fldt 32(%esp) + fstpt 32(%esp) + fldt 80(%esp) + fstpt 80(%esp) + call atan2l@PLT +..B1.111: + fldt 80(%esp) + fldt 64(%esp) + fldt 48(%esp) + fldt 32(%esp) + fldl 96(%esp) + addl $32, %esp +..B1.19: + fldl _DBL_PZERO@GOTOFF(%ebx) + fcompl 152(%esp) + fnstsw %ax + sahf + jbe ..B1.21 +..B1.20: + fldt _LDBL_PPI@GOTOFF(%ebx) + fsubp %st, %st(6) +..B1.21: + fldt _Across@GOTOFF(%ebx) + movzbl 27(%ebp), %ecx + fcomp %st(5) + fnstsw %ax + fxch %st(5) + fstpl 176(%esp) + andl $-128, %ecx + movzbl 183(%esp), %edx + andl $127, %edx + orl %ecx, %edx + movb %dl, 183(%esp) + sahf + jb ..B1.26 +..B1.22: + fldt 104(%esp) + faddp %st, %st(1) + fxch %st(4) + fcomp %st(2) + fnstsw %ax + fldt 120(%esp) + fdivp %st, %st(4) + sahf + jae ..B1.24 + jp ..B1.24 +..B1.23: + fldt 72(%esp) + fldt 120(%esp) + fdivp %st, %st(1) + faddp %st, %st(4) + fmulp %st, %st(3) + jmp ..B1.25 +..B1.24: + fldt 88(%esp) + fldt 136(%esp) + faddp %st, %st(1) + faddp %st, %st(4) + fmulp %st, %st(3) +..B1.25: + addl $-16, %esp + faddp %st, %st(1) + fmul %st(1), %st + fsqrt + faddp %st, %st(1) + fstpt (%esp) + call log1pl@PLT + jmp ..B1.113 +..B1.26: + fstp %st(0) + fstp %st(0) + fstp %st(2) + fld %st(0) + addl $-16, %esp + fmul %st(1), %st + fsubp %st, %st(2) + fxch %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%esp) + call logl@PLT +..B1.113: + addl $16, %esp + fstpl 168(%esp) +..B1.27: + movzwl 174(%esp), %edx + testl $32752, %edx + jne ..B1.30 +..B1.28: + testl $1048575, 172(%esp) + jne ..B1.33 +..B1.29: + cmpl $0, 168(%esp) + jne ..B1.33 +..B1.30: + movzwl 182(%esp), %edx + testl $32752, %edx + jne ..B1.34 +..B1.31: + testl $1048575, 180(%esp) + jne ..B1.33 +..B1.32: + cmpl $0, 176(%esp) + je ..B1.34 +..B1.33: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 160(%esp) +..B1.34: + testl %edi, %edi + je ..B1.66 +..B1.35: + fldcw 14(%esp) + jmp ..B1.66 +..B1.36: + movzwl 26(%ebp), %edx + andl $32752, %edx + shrl $4, %edx +..B1.37: + testl %edx, %edx + jne ..B1.49 +..B1.38: + testl $1048575, 24(%ebp) + jne ..B1.49 +..B1.39: + cmpl $0, 20(%ebp) + jne ..B1.49 +..B1.40: + cmpl $2047, %ecx + jl ..B1.43 +..B1.41: + testl $1048575, 16(%ebp) + jne ..B1.49 +..B1.42: + cmpl $0, 12(%ebp) + jne ..B1.49 +..B1.43: + cmpl $1023, %ecx + jl ..B1.47 +..B1.44: + fldl 12(%ebp) + addl $-16, %esp + fabs + fstpl (%esp) + call acosh@PLT +..B1.114: + addl $16, %esp + movzbl 19(%ebp), %edx + testl $128, %edx + fstpl 168(%esp) + je ..B1.46 +..B1.45: + fldl _DBL_PPI@GOTOFF(%ebx) + fstl 176(%esp) + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + faddp %st, %st(1) + fstpl 160(%esp) + jmp ..B1.48 +..B1.46: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 176(%esp) + jmp ..B1.48 +..B1.47: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 168(%esp) + addl $-16, %esp + fldl 12(%ebp) + fstpl (%esp) + call acos@PLT +..B1.115: + addl $16, %esp + fstpl 176(%esp) +..B1.48: + movzbl 183(%esp), %edx + movzbl 27(%ebp), %edi + andl $127, %edx + andl $-128, %edi + orl %edi, %edx + movb %dl, 183(%esp) + jmp ..B1.66 +..B1.49: + testl %ecx, %ecx + jne ..B1.56 +..B1.50: + testl $1048575, 16(%ebp) + jne ..B1.57 +..B1.51: + cmpl $0, 12(%ebp) + jne ..B1.57 +..B1.52: + cmpl $2047, %edx + jl ..B1.55 +..B1.53: + testl $1048575, 24(%ebp) + jne ..B1.57 +..B1.54: + cmpl $0, 20(%ebp) + jne ..B1.57 +..B1.55: + fldl 20(%ebp) + fstl (%esp) + addl $-16, %esp + fabs + fstpl (%esp) + call asinh@PLT +..B1.117: + fldl 12(%ebp) + addl $16, %esp + fxch %st(1) + fstpl 168(%esp) + addl $-16, %esp + fstpl 8(%esp) + fldl 16(%esp) + fstpl (%esp) + call atan2@PLT +..B1.116: + addl $16, %esp + fstpl 176(%esp) + jmp ..B1.66 +..B1.56: + cmpl $2047, %ecx + je ..B1.97 +..B1.57: + cmpl $2047, %edx + je ..B1.93 +..B1.121: + cmpl $2047, %ecx +..B1.58: + je ..B1.75 +..B1.59: + jge ..B1.64 +..B1.60: + movzbl 27(%ebp), %edx + testl $128, %edx + je ..B1.62 +..B1.61: + fldl _DBL_NPIBY2@GOTOFF(%ebx) + jmp ..B1.63 +..B1.62: + fldl _DBL_PPIBY2@GOTOFF(%ebx) +..B1.63: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fadd %st(1), %st + fstpl 160(%esp) + fstpl 176(%esp) + fldl _DBL_PZERO@GOTOFF(%ebx) + faddl 12(%ebp) + fstpl 160(%esp) + jmp ..B1.65 +..B1.64: + fldl 12(%ebp) + faddl _DBL_PZERO@GOTOFF(%ebx) + fstpl 176(%esp) +..B1.65: + fldl 20(%ebp) + fmul %st(0), %st + fstpl 168(%esp) +..B1.66: + movl 168(%esp), %edx + movl %edx, (%esi) + movl 172(%esp), %ecx + movl 176(%esp), %edi + movl 180(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 184(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.74 +..B1.67: + movl %esi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.68: + xorl %edi, %edi + jmp ..B1.11 +..B1.69: + testl $1048575, 24(%ebp) + jne ..B1.7 +..B1.70: + cmpl $0, 20(%ebp) + jne ..B1.7 + jmp ..B1.37 +..B1.71: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.72: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.36 +..B1.74: + call __stack_chk_fail@PLT +..B1.75: + testl $1048575, 16(%ebp) + jne ..B1.119 +..B1.76: + cmpl $0, 12(%ebp) + jne ..B1.119 +..B1.77: + fldl 12(%ebp) + cmpl $2047, %edx + fmul %st(0), %st + fstpl 168(%esp) + jge ..B1.84 +..B1.78: + movzbl 19(%ebp), %edx + testl $128, %edx + je ..B1.80 +..B1.79: + fldl _DBL_PPI@GOTOFF(%ebx) + fstl 176(%esp) + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + faddp %st, %st(1) + fstpl 160(%esp) + fldl _DBL_PZERO@GOTOFF(%ebx) + jmp ..B1.81 +..B1.80: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstl 176(%esp) +..B1.81: + movzbl 27(%ebp), %edx + testl $128, %edx + je ..B1.83 +..B1.82: + movzbl 183(%esp), %edi + movl %edi, %edx + shrl $7, %edi + andl $127, %edx + notl %edi + shll $7, %edi + orl %edi, %edx + movb %dl, 183(%esp) +..B1.83: + faddl 20(%ebp) + fstpl 160(%esp) + jmp ..B1.66 +..B1.84: + testl $1048575, 24(%ebp) + jne ..B1.92 +..B1.85: + cmpl $0, 20(%ebp) + jne ..B1.92 +..B1.86: + movzbl 19(%ebp), %edx + testl $128, %edx + je ..B1.88 +..B1.87: + fldl _DBL_P3PIBY4@GOTOFF(%ebx) + jmp ..B1.89 +..B1.88: + fldl _DBL_PPIBY4@GOTOFF(%ebx) +..B1.89: + movzbl 27(%ebp), %edx + testl $128, %edx + fstpl 176(%esp) + je ..B1.91 +..B1.90: + movzbl 183(%esp), %edi + movl %edi, %edx + shrl $7, %edi + andl $127, %edx + notl %edi + shll $7, %edi + orl %edi, %edx + movb %dl, 183(%esp) +..B1.91: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + faddl 176(%esp) + fstpl 160(%esp) + jmp ..B1.66 +..B1.92: + fldl 20(%ebp) + fmul %st(0), %st + fstpl 176(%esp) + jmp ..B1.66 +..B1.93: + testl $1048575, 24(%ebp) + jne ..B1.95 +..B1.94: + cmpl $0, 20(%ebp) + je ..B1.118 +..B1.95: + cmpl $2047, %ecx + jge ..B1.58 +..B1.96: + fldl 20(%ebp) + fmul %st(0), %st + fstl 168(%esp) + fstpl 176(%esp) + jmp ..B1.66 +..B1.97: + testl $1048575, 16(%ebp) + jne ..B1.99 +..B1.98: + cmpl $0, 12(%ebp) + je ..B1.100 +..B1.99: + cmpl $2047, %edx + je ..B1.104 +..B1.100: + testl $1048575, 16(%ebp) + jne ..B1.102 +..B1.101: + cmpl $0, 12(%ebp) + je ..B1.57 +..B1.102: + cmpl $2047, %edx + jge ..B1.57 +..B1.103: + fldl 12(%ebp) + fmul %st(0), %st + fstl 168(%esp) + fstpl 176(%esp) + jmp ..B1.66 +..B1.104: + testl $1048575, 24(%ebp) + jne ..B1.106 +..B1.105: + cmpl $0, 20(%ebp) + je ..B1.100 +..B1.106: + fldl 12(%ebp) + fmul %st(0), %st + fstpl 168(%esp) + fldl 20(%ebp) + fmul %st(0), %st + fstpl 176(%esp) + jmp ..B1.66 +..B1.118: + cmpl $2047, %ecx + je ..B1.75 + jmp ..B1.59 +..B1.119: + cmpl $2047, %ecx + jl ..B1.60 + jmp ..B1.64 + .align 16,0x90 + .type cacosh,@function + .size cacosh,.-cacosh + .data +# -- End cacosh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +_Bcross: + .word -2936 + .word -10277 + .word 29569 + .word -23482 + .word 16382 + .word 0 + .type _Bcross,@object + .size _Bcross,12 + .space 4, 0x00 # pad + .align 16 +_DBL_PZERO: + .long 0 + .long 0 + .type _DBL_PZERO,@object + .size _DBL_PZERO,8 + .space 8, 0x00 # pad + .align 16 +_LDBL_PPI: + .word -15819 + .word 8552 + .word -9566 + .word -14065 + .word 16384 + .word 0 + .type _LDBL_PPI,@object + .size _LDBL_PPI,12 + .space 4, 0x00 # pad + .align 16 +_Across: + .word 0 + .word 0 + .word 0 + .word -16384 + .word 16383 + .word 0 + .type _Across,@object + .size _Across,12 + .space 4, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPI: + .long 1413754136 + .long 1074340347 + .type _DBL_PPI,@object + .size _DBL_PPI,8 + .space 8, 0x00 # pad + .align 16 +_DBL_NPIBY2: + .long 1413754136 + .long -1074191877 + .type _DBL_NPIBY2,@object + .size _DBL_NPIBY2,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPIBY2: + .long 1413754136 + .long 1073291771 + .type _DBL_PPIBY2,@object + .size _DBL_PPIBY2,8 + .space 8, 0x00 # pad + .align 16 +_DBL_P3PIBY4: + .long 2134057426 + .long 1073928572 + .type _DBL_P3PIBY4,@object + .size _DBL_P3PIBY4,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPIBY4: + .long 1413754136 + .long 1072243195 + .type _DBL_PPIBY4,@object + .size _DBL_PPIBY4,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cacoshf.S b/external/sgx_libm/ia32/cacoshf.S new file mode 100644 index 0000000000..06b07b0f47 --- /dev/null +++ b/external/sgx_libm/ia32/cacoshf.S @@ -0,0 +1,639 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacoshf.c" + .text +..TXTST0: +# -- Begin cacoshf + .text + .align 16,0x90 + .globl cacoshf +cacoshf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %ebx + subl $108, %esp + fldz + movzwl 10(%ebp), %edx + andl $32640, %edx + shrl $7, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %edx + fsts 100(%esp) + fsts 104(%esp) + jge ..B1.26 +..B1.2: + testl %edx, %edx + jle ..B1.55 +..B1.3: + movzwl 14(%ebp), %eax + andl $32640, %eax + shrl $7, %eax + cmpl $255, %eax + jge ..B1.27 +..B1.4: + testl %eax, %eax + jle ..B1.54 +..B1.5: + flds 8(%ebp) + fsts 92(%esp) + fld1 + fsts 88(%esp) + fxch %st(1) + fabs + fld %st(0) + fsub %st(2), %st + fld %st(0) + fmul %st(1), %st + fld %st(2) + faddp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fxch %st(2) + fstl 72(%esp) + flds 12(%ebp) + fabs + fld %st(0) + fmul %st(1), %st + fstl 56(%esp) + fadd %st, %st(3) + fxch %st(3) + fsqrt + fstl 64(%esp) + fxch %st(3) + faddp %st, %st(4) + fxch %st(3) + fsqrt + fstl 48(%esp) + fxch %st(1) + fucomp %st(2) + fnstsw %ax + faddp %st, %st(1) + fldl .L_2il0floatpacket.6@GOTOFF(%ebx) + sahf + fmul %st, %st(1) + jp ..B1.6 + je ..B1.7 +..B1.6: + fldl 64(%esp) + fsubl 72(%esp) + fstpl 40(%esp) + jmp ..B1.8 +..B1.7: + fxch %st(2) + fstl 40(%esp) + fxch %st(2) +..B1.8: + fldl _Bcross@GOTOFF(%ebx) + fmul %st(2), %st + fcomp %st(4) + fnstsw %ax + sahf + jbe ..B1.10 +..B1.9: + fstp %st(2) + fld %st(2) + fdiv %st(1), %st + fstpl (%esp) + fxch %st(2) + fstps 80(%esp) + fxch %st(2) + fstpl 16(%esp) + fxch %st(1) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + call acos@PLT + jmp ..B1.89 +..B1.10: + flds 88(%esp) + fcomp %st(4) + fnstsw %ax + sahf + jb ..B1.12 +..B1.11: + fstp %st(2) + fld %st(3) + fld %st(1) + fadd %st(4), %st + fmul %st(3), %st + fxch %st(1) + faddl 48(%esp) + fdivrl 56(%esp) + faddl 40(%esp) + fmulp %st, %st(1) + fsqrt + fxch %st(3) + fstl 8(%esp) + fxch %st(3) + fstpl (%esp) + fxch %st(2) + fstps 80(%esp) + fxch %st(2) + fstpl 16(%esp) + fxch %st(1) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + call atan2@PLT + jmp ..B1.89 +..B1.12: + fldl 72(%esp) + fld %st(2) + fadd %st(5), %st + fxch %st(6) + fstl 16(%esp) + fxch %st(1) + faddl 64(%esp) + fxch %st(1) + faddl 48(%esp) + fdivr %st(6), %st + fxch %st(1) + fdivrp %st, %st(6) + faddp %st, %st(5) + fmul %st, %st(4) + fxch %st(4) + fsqrt + fmulp %st, %st(2) + fxch %st(2) + fstl 8(%esp) + fxch %st(1) + fstpl (%esp) + fstps 80(%esp) + fxch %st(1) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + fldl 16(%esp) + fstpl 16(%esp) + call atan2@PLT +..B1.89: + flds 84(%esp) + fldl 32(%esp) + fldl 24(%esp) + fldl 16(%esp) + flds 80(%esp) +..B1.13: + fxch %st(4) + fcomps 92(%esp) + fnstsw %ax + sahf + jbe ..B1.15 +..B1.14: + fxch %st(4) + fsubrl _DBL_PPI@GOTOFF(%ebx) + fxch %st(4) +..B1.15: + fxch %st(4) + fstps 104(%esp) + fldl _Across@GOTOFF(%ebx) + movzbl 107(%esp), %ecx + fcomp %st(2) + fnstsw %ax + movzbl 15(%ebp), %edx + andl $127, %ecx + andl $-128, %edx + orl %edx, %ecx + movb %cl, 107(%esp) + sahf + jb ..B1.20 +..B1.16: + flds 88(%esp) + fcomp %st(3) + fnstsw %ax + fxch %st(2) + fstp %st(0) + fxch %st(2) + faddl 48(%esp) + fdivrl 56(%esp) + sahf + jbe ..B1.18 +..B1.17: + fldl 56(%esp) + fdivl 40(%esp) + faddp %st, %st(1) + fmulp %st, %st(1) + jmp ..B1.19 +..B1.18: + fldl 72(%esp) + faddl 64(%esp) + faddp %st, %st(1) + fmulp %st, %st(1) +..B1.19: + fxch %st(1) + fadds 88(%esp) + fmul %st(1), %st + fsqrt + faddp %st, %st(1) + fstpl (%esp) + call log1p@PLT + jmp ..B1.91 +..B1.20: + fstp %st(3) + fstp %st(2) + fstp %st(0) + fld %st(0) + fmul %st(1), %st + fsubs 88(%esp) + fsqrt + faddp %st, %st(1) + fstpl (%esp) + call log@PLT +..B1.91: + fstps 100(%esp) +..B1.21: + movzwl 102(%esp), %eax + testl $32640, %eax + jne ..B1.23 +..B1.22: + testl $8388607, 100(%esp) + jne ..B1.25 +..B1.23: + movzwl 106(%esp), %eax + testl $32640, %eax + jne ..B1.53 +..B1.24: + testl $8388607, 104(%esp) + je ..B1.53 +..B1.25: + flds .L_2il0floatpacket.10@GOTOFF(%ebx) + fmul %st(0), %st + fstps 96(%esp) + jmp ..B1.53 +..B1.26: + movzwl 14(%ebp), %eax + andl $32640, %eax + shrl $7, %eax +..B1.27: + cmpl $255, %edx + je ..B1.83 +..B1.28: + testl %eax, %eax + jne ..B1.38 +..B1.29: + testl $8388607, 12(%ebp) + jne ..B1.38 +..B1.30: + cmpl $255, %edx + jl ..B1.32 +..B1.31: + testl $8388607, 8(%ebp) + jne ..B1.38 +..B1.32: + cmpl $127, %edx + jl ..B1.36 +..B1.33: + flds 8(%ebp) + fabs + fstps (%esp) + fstps 84(%esp) + call acoshf@PLT +..B1.92: + flds 84(%esp) + movzbl 11(%ebp), %eax + testl $128, %eax + fxch %st(1) + fstps 100(%esp) + je ..B1.35 +..B1.34: + fstp %st(0) + movl $1078530011, %eax + movl %eax, 104(%esp) + movl %eax, 96(%esp) + jmp ..B1.37 +..B1.35: + fstps 104(%esp) + jmp ..B1.37 +..B1.36: + movl 8(%ebp), %eax + fstps 100(%esp) + movl %eax, (%esp) + call acosf@PLT +..B1.93: + fstps 104(%esp) +..B1.37: + movzbl 107(%esp), %edx + movzbl 15(%ebp), %eax + andl $127, %edx + andl $-128, %eax + orl %eax, %edx + movb %dl, 107(%esp) + jmp ..B1.53 +..B1.38: + testl %edx, %edx + jne ..B1.43 +..B1.39: + testl $8388607, 8(%ebp) + jne ..B1.44 +..B1.40: + cmpl $255, %eax + jl ..B1.42 +..B1.41: + testl $8388607, 12(%ebp) + jne ..B1.44 +..B1.42: + fstp %st(0) + flds 12(%ebp) + fsts 16(%esp) + fabs + fstps (%esp) + call asinhf@PLT +..B1.95: + movl 8(%ebp), %eax + movl %eax, 4(%esp) + flds 16(%esp) + fstps (%esp) + fstps 100(%esp) + call atan2f@PLT +..B1.94: + fstps 104(%esp) + jmp ..B1.53 +..B1.43: + cmpl $255, %edx + je ..B1.76 +..B1.44: + cmpl $255, %eax + je ..B1.73 +..B1.45: + cmpl $255, %edx + je ..B1.57 +..B1.46: + fstp %st(0) + cmpl $255, %edx + jge ..B1.51 +..B1.47: + movzbl 15(%ebp), %eax + testl $128, %eax + je ..B1.49 +..B1.48: + flds .L_2il0floatpacket.8@GOTOFF(%ebx) + jmp ..B1.50 +..B1.49: + flds .L_2il0floatpacket.9@GOTOFF(%ebx) +..B1.50: + flds .L_2il0floatpacket.10@GOTOFF(%ebx) + movl 8(%ebp), %eax + fadd %st(1), %st + fstps 96(%esp) + fstps 104(%esp) + movl %eax, 96(%esp) + jmp ..B1.52 +..B1.51: + movl 8(%ebp), %eax + movl %eax, 104(%esp) +..B1.52: + flds 12(%ebp) + fmul %st(0), %st + fstps 100(%esp) +..B1.53: + movl 100(%esp), %eax + movl 104(%esp), %edx + addl $108, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.54: + testl $8388607, 12(%ebp) + jne ..B1.5 + jmp ..B1.27 +..B1.55: + testl $8388607, 8(%ebp) + jne ..B1.3 + jmp ..B1.26 +..B1.57: + testl $8388607, 8(%ebp) + jne ..B1.46 +..B1.58: + flds 8(%ebp) + cmpl $255, %eax + fmul %st(0), %st + fstps 100(%esp) + jge ..B1.65 +..B1.59: + movzbl 11(%ebp), %eax + testl $128, %eax + je ..B1.61 +..B1.60: + fstp %st(0) + movl $1078530011, %eax + movl %eax, 104(%esp) + movl %eax, 96(%esp) + jmp ..B1.62 +..B1.61: + fstps 104(%esp) +..B1.62: + movzbl 15(%ebp), %eax + testl $128, %eax + je ..B1.64 +..B1.63: + movzbl 107(%esp), %eax + movl %eax, %edx + shrl $7, %eax + andl $127, %edx + notl %eax + shll $7, %eax + orl %eax, %edx + movb %dl, 107(%esp) +..B1.64: + movl 12(%ebp), %eax + movl %eax, 96(%esp) + jmp ..B1.53 +..B1.65: + fstp %st(0) + testl $8388607, 12(%ebp) + jne ..B1.72 +..B1.66: + movzbl 11(%ebp), %eax + testl $128, %eax + je ..B1.68 +..B1.67: + movl $1075235812, %edx + jmp ..B1.69 +..B1.68: + movl $1061752795, %edx +..B1.69: + movzbl 15(%ebp), %eax + testl $128, %eax + movl %edx, 104(%esp) + je ..B1.71 +..B1.70: + shrl $24, %edx + orl $-128, %edx + movb %dl, 107(%esp) +..B1.71: + flds .L_2il0floatpacket.10@GOTOFF(%ebx) + fadds 104(%esp) + fstps 96(%esp) + jmp ..B1.53 +..B1.72: + flds 12(%ebp) + fmul %st(0), %st + fstps 104(%esp) + jmp ..B1.53 +..B1.73: + testl $8388607, 12(%ebp) + je ..B1.45 +..B1.74: + cmpl $255, %edx + jge ..B1.45 +..B1.75: + fstp %st(0) + flds 12(%ebp) + fmul %st(0), %st + fsts 100(%esp) + fstps 104(%esp) + jmp ..B1.53 +..B1.76: + testl $8388607, 8(%ebp) + je ..B1.78 +..B1.77: + cmpl $255, %eax + je ..B1.81 +..B1.97: + testl $8388607, 8(%ebp) +..B1.78: + je ..B1.44 +..B1.79: + cmpl $255, %eax + jge ..B1.44 +..B1.80: + fstp %st(0) + flds 8(%ebp) + fmul %st(0), %st + fsts 100(%esp) + fstps 104(%esp) + jmp ..B1.53 +..B1.81: + testl $8388607, 12(%ebp) + je ..B1.96 +..B1.82: + fstp %st(0) + flds 8(%ebp) + fmul %st(0), %st + fstps 100(%esp) + flds 12(%ebp) + fmul %st(0), %st + fstps 104(%esp) + jmp ..B1.53 +..B1.83: + testl $8388607, 8(%ebp) + je ..B1.28 +..B1.84: + flds 8(%ebp) + fadd %st(0), %st + fstps 8(%ebp) + movzwl 10(%ebp), %edx + andl $32640, %edx + shrl $7, %edx + jmp ..B1.28 +..B1.96: + testl $8388607, 8(%ebp) + jne ..B1.79 + jmp ..B1.44 + .align 16,0x90 + .type cacoshf,@function + .size cacoshf,.-cacoshf + .data +# -- End cacoshf + .section .rodata, "a" + .align 16 + .align 16 +_Bcross: + .long 1882913663 + .long 1071941838 + .type _Bcross,@object + .size _Bcross,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPI: + .long 1413754136 + .long 1074340347 + .type _DBL_PPI,@object + .size _DBL_PPI,8 + .space 8, 0x00 # pad + .align 16 +_Across: + .long 0 + .long 1073217536 + .type _Across,@object + .size _Across,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 4 +.L_2il0floatpacket.7: + .long 0x40490fdb + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,4 + .align 4 +.L_2il0floatpacket.8: + .long 0xbfc90fdb + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .align 4 +.L_2il0floatpacket.9: + .long 0x3fc90fdb + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,4 + .align 4 +.L_2il0floatpacket.10: + .long 0x00800000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .align 4 +.L_2il0floatpacket.11: + .long 0x4016cbe4 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,4 + .align 4 +.L_2il0floatpacket.12: + .long 0x3f490fdb + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cacoshl.S b/external/sgx_libm/ia32/cacoshl.S new file mode 100644 index 0000000000..d293f81ceb --- /dev/null +++ b/external/sgx_libm/ia32/cacoshl.S @@ -0,0 +1,459 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacoshl.c" + .text +..TXTST0: +# -- Begin cacoshl + .text + .align 16,0x90 + .globl cacoshl +cacoshl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $308, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl 8(%ebp), %eax + movl %eax, 12(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 268(%esp) + fstpt (%esp) + fldt (%esp) + fstpt 244(%esp) + fldt 244(%esp) + fstpt 256(%esp) +..B1.2: + fnstcw 18(%esp) +..B1.3: + movzwl 18(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.67 +..B1.4: + orl $-64768, %edx + movw %dx, 16(%esp) +..B1.5: + fldcw 16(%esp) +..B1.6: + movl $1, %esi +..B1.7: + movzwl 20(%ebp), %eax + andl $32767, %eax + cmpl $32767, %eax + jge ..B1.16 +..B1.8: + testl %eax, %eax + jle ..B1.46 +..B1.9: + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.16 +..B1.10: + testl %edx, %edx + jle ..B1.44 +..B1.11: + addl $-48, %esp + lea 12(%ebp), %eax + lea 24(%ebp), %edx + lea 264(%esp), %ecx + lea 236(%esp), %edi + movl %eax, (%esp) + lea 208(%esp), %eax + movl %edx, 4(%esp) + lea 180(%esp), %edx + movl %ecx, 8(%esp) + lea 152(%esp), %ecx + movl %edi, 12(%esp) + lea 68(%esp), %edi + movl %eax, 16(%esp) + lea 96(%esp), %eax + movl %edx, 20(%esp) + lea 124(%esp), %edx + movl %ecx, 24(%esp) + movl %edx, 28(%esp) + movl %eax, 32(%esp) + movl %edi, 36(%esp) + call __libm_carctrigprepare_k80 +..B1.70: + lea 96(%esp), %eax + lea 124(%esp), %edx +..B1.12: + lea 12(%ebp), %ecx + movl %ecx, (%esp) + lea 24(%ebp), %ecx + movl %ecx, 4(%esp) + lea 264(%esp), %ecx + movl %ecx, 8(%esp) + lea 236(%esp), %ecx + movl %ecx, 12(%esp) + lea 208(%esp), %ecx + movl %ecx, 16(%esp) + lea 180(%esp), %ecx + movl %ecx, 20(%esp) + lea 152(%esp), %ecx + movl %ecx, 24(%esp) + movl %edx, 28(%esp) + movl %eax, 32(%esp) + movl %edi, 36(%esp) + call __libm_recacoshl_k80 +..B1.71: + lea 96(%esp), %eax + lea 124(%esp), %edx + addl $48, %esp +..B1.13: + fstpt 244(%esp) + addl $-48, %esp + lea 12(%ebp), %ecx + movl %ecx, (%esp) + lea 24(%ebp), %ecx + movl %ecx, 4(%esp) + lea 264(%esp), %ecx + movl %ecx, 8(%esp) + lea 236(%esp), %ecx + movl %ecx, 12(%esp) + lea 208(%esp), %ecx + movl %ecx, 16(%esp) + lea 180(%esp), %ecx + movl %ecx, 20(%esp) + lea 152(%esp), %ecx + movl %ecx, 24(%esp) + movl %edx, 28(%esp) + movl %eax, 32(%esp) + movl %edi, 36(%esp) + call __libm_recacosl_k80 +..B1.72: + addl $48, %esp +..B1.14: + movzbl 33(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl ones@GOTOFF(%ebx,%eax,8) + fmulp %st, %st(1) + fstpt 256(%esp) + jmp ..B1.40 +..B1.16: + movl 28(%ebp), %ecx +..B1.17: + testl %ecx, %ecx + jne ..B1.27 +..B1.81: + cmpl $0, 24(%ebp) +..B1.18: + jne ..B1.27 +..B1.19: + cmpl $32767, %eax + jl ..B1.22 +..B1.20: + movl 16(%ebp), %edi + cmpl $-2147483648, %edi + jne ..B1.28 +..B1.21: + cmpl $0, 12(%ebp) + jne ..B1.34 +..B1.22: + cmpl $16383, %eax + jl ..B1.24 +..B1.23: + fldt 12(%ebp) + movzbl 21(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl ones@GOTOFF(%ebx,%eax,8) + fstl (%esp) + addl $-16, %esp + fmulp %st, %st(1) + fstpt (%esp) + call acoshl@PLT +..B1.74: + addl $16, %esp + fstpt 244(%esp) + addl $-16, %esp + fldl 16(%esp) + fstpt (%esp) + call acosl@PLT + jmp ..B1.75 +..B1.24: + fldt (%esp) + fstpt 244(%esp) + addl $-16, %esp + fldt 12(%ebp) + fstpt (%esp) + call acosl@PLT +..B1.75: + addl $16, %esp + lea 256(%esp), %edx +..B1.25: + movzbl 33(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmull ones@GOTOFF(%ebx,%eax,8) + fstpt (%edx) + jmp ..B1.40 +..B1.27: + movl 16(%ebp), %edi +..B1.28: + testl %edi, %edi + jne ..B1.34 +..B1.29: + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $0, 12(%ebp) + jne ..B1.35 +..B1.30: + cmpl $32767, %edx + jl ..B1.33 +..B1.31: + cmpl $-2147483648, %ecx + jne ..B1.35 +..B1.32: + cmpl $0, 24(%ebp) + jne ..B1.35 +..B1.33: + fldt 24(%ebp) + movzbl 33(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fstpt (%esp) + fldt (%esp) + addl $-16, %esp + fldl ones@GOTOFF(%ebx,%eax,8) + fmulp %st, %st(1) + fstpt (%esp) + call asinhl@PLT +..B1.77: + fldt 12(%ebp) + addl $16, %esp + fxch %st(1) + fstpt 244(%esp) + addl $-32, %esp + fldt 32(%esp) + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT + jmp ..B1.78 +..B1.34: + movzwl 32(%ebp), %edx + andl $32767, %edx +..B1.35: + cmpl $32767, %eax + je ..B1.57 +..B1.36: + cmpl $32767, %edx + je ..B1.53 +..B1.80: + cmpl $32767, %eax +..B1.37: + je ..B1.50 +..B1.38: + fldt 24(%ebp) + fld %st(0) + fmul %st(1), %st + fstpt 244(%esp) + fldt 12(%ebp) + fxch %st(1) +..B1.39: + addl $-32, %esp + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT +..B1.78: + addl $32, %esp + fstpt 256(%esp) +..B1.40: + testl %esi, %esi + je ..B1.42 +..B1.41: + fldcw 18(%esp) +..B1.42: + movl 12(%esp), %eax + movl 244(%esp), %edx + movl 248(%esp), %ecx + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 252(%esp), %esi + movl 256(%esp), %edi + movl 260(%esp), %edx + movl 264(%esp), %ecx + movl %esi, 8(%eax) + movl %edi, 12(%eax) + movl %edx, 16(%eax) + movl %ecx, 20(%eax) + movl 268(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.49 +..B1.43: + movl 12(%esp), %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.44: + movl 28(%ebp), %ecx + testl %ecx, %ecx + jne ..B1.11 +..B1.45: + cmpl $0, 24(%ebp) + jne ..B1.11 + jmp ..B1.18 +..B1.46: + cmpl $0, 16(%ebp) + jne ..B1.9 +..B1.47: + cmpl $0, 12(%ebp) + jne ..B1.9 + jmp ..B1.16 +..B1.49: + call __stack_chk_fail@PLT +..B1.50: + cmpl $-2147483648, %edi + jne ..B1.38 +..B1.51: + cmpl $0, 12(%ebp) + jne ..B1.38 +..B1.52: + fldt 12(%ebp) + fld %st(0) + fmul %st(1), %st + fstpt 244(%esp) + fldt 24(%ebp) + jmp ..B1.39 +..B1.53: + cmpl $-2147483648, %ecx + jne ..B1.55 +..B1.54: + cmpl $0, 24(%ebp) + je ..B1.79 +..B1.55: + cmpl $32767, %eax + jge ..B1.37 +..B1.56: + fldt 24(%ebp) + fmul %st(0), %st + fstpt 244(%esp) + fldt 244(%esp) + fstpt 256(%esp) + jmp ..B1.40 +..B1.57: + cmpl $-2147483648, %edi + jne ..B1.59 +..B1.58: + cmpl $0, 12(%ebp) + je ..B1.61 +..B1.59: + cmpl $32767, %edx + je ..B1.64 +..B1.60: + cmpl $-2147483648, %edi + jne ..B1.62 +..B1.82: + cmpl $0, 12(%ebp) +..B1.61: + je ..B1.36 +..B1.62: + cmpl $32767, %edx + jge ..B1.36 +..B1.63: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 244(%esp) + fldt 244(%esp) + fstpt 256(%esp) + jmp ..B1.40 +..B1.64: + cmpl $-2147483648, %ecx + jne ..B1.66 +..B1.65: + cmpl $0, 24(%ebp) + je ..B1.60 +..B1.66: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 244(%esp) + fldt 24(%ebp) + fmul %st(0), %st + fstpt 256(%esp) + jmp ..B1.40 +..B1.67: + xorl %esi, %esi + jmp ..B1.7 +..B1.79: + cmpl $32767, %eax + je ..B1.50 + jmp ..B1.38 + .align 16,0x90 + .type cacoshl,@function + .size cacoshl,.-cacoshl + .data +# -- End cacoshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .hidden __libm_recacosl_k80 + .hidden __libm_recacoshl_k80 + .hidden __libm_carctrigprepare_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cacosl.S b/external/sgx_libm/ia32/cacosl.S new file mode 100644 index 0000000000..7797c091c0 --- /dev/null +++ b/external/sgx_libm/ia32/cacosl.S @@ -0,0 +1,455 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacosl.c" + .text +..TXTST0: +# -- Begin cacosl + .text + .align 16,0x90 + .globl cacosl +cacosl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $308, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 272(%esp) + fstpt 8(%esp) + fldt 8(%esp) + fstpt 248(%esp) + fldt 248(%esp) + fstpt 260(%esp) +..B1.2: + fnstcw 22(%esp) +..B1.3: + movzwl 22(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.62 +..B1.4: + orl $-64768, %ecx + movw %cx, 20(%esp) +..B1.5: + fldcw 20(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.16 +..B1.8: + testl %ecx, %ecx + jle ..B1.41 +..B1.9: + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.16 +..B1.10: + testl %edx, %edx + jle ..B1.38 +..B1.11: + addl $-48, %esp + lea 12(%ebp), %edx + lea 24(%ebp), %ecx + movl %edx, (%esp) + lea 268(%esp), %edx + movl %ecx, 4(%esp) + lea 100(%esp), %ecx + movl %edx, 8(%esp) + lea 240(%esp), %edx + movl %edx, 12(%esp) + lea 212(%esp), %edx + movl %edx, 16(%esp) + lea 184(%esp), %edx + movl %edx, 20(%esp) + lea 156(%esp), %edx + movl %edx, 24(%esp) + lea 128(%esp), %edx + movl %edx, 28(%esp) + lea 72(%esp), %edx + movl %ecx, 32(%esp) + movl %edx, 36(%esp) + call __libm_carctrigprepare_k80 +..B1.65: + lea 72(%esp), %edx + lea 100(%esp), %ecx +..B1.12: + lea 12(%ebp), %eax + movl %eax, (%esp) + lea 24(%ebp), %eax + movl %eax, 4(%esp) + lea 268(%esp), %eax + movl %eax, 8(%esp) + lea 240(%esp), %eax + movl %eax, 12(%esp) + lea 212(%esp), %eax + movl %eax, 16(%esp) + lea 184(%esp), %eax + movl %eax, 20(%esp) + lea 156(%esp), %eax + movl %eax, 24(%esp) + lea 128(%esp), %eax + movl %eax, 28(%esp) + movl %ecx, 32(%esp) + movl %edx, 36(%esp) + call __libm_recacosl_k80 +..B1.66: + lea 72(%esp), %edx + lea 100(%esp), %ecx + addl $48, %esp +..B1.13: + fstpt 248(%esp) + addl $-48, %esp + lea 12(%ebp), %eax + movl %eax, (%esp) + lea 24(%ebp), %eax + movl %eax, 4(%esp) + lea 268(%esp), %eax + movl %eax, 8(%esp) + lea 240(%esp), %eax + movl %eax, 12(%esp) + lea 212(%esp), %eax + movl %eax, 16(%esp) + lea 184(%esp), %eax + movl %eax, 20(%esp) + lea 156(%esp), %eax + movl %eax, 24(%esp) + lea 128(%esp), %eax + movl %eax, 28(%esp) + movl %ecx, 32(%esp) + movl %edx, 36(%esp) + call __libm_recacoshl_k80 +..B1.67: + addl $48, %esp +..B1.14: + movzbl 33(%ebp), %edx + andl $128, %edx + shrl $7, %edx + xorl $1, %edx + fldl ones@GOTOFF(%ebx,%edx,8) + fmulp %st, %st(1) + fstpt 260(%esp) + jmp ..B1.34 +..B1.16: + movl 16(%ebp), %eax +..B1.17: + testl %eax, %eax + jne ..B1.20 +..B1.77: + cmpl $0, 12(%ebp) +..B1.18: + jne ..B1.20 +..B1.19: + addl $-16, %esp + fldt 24(%esp) + fstpt (%esp) + call acosl@PLT +..B1.69: + fldt 24(%ebp) + addl $16, %esp + fxch %st(1) + fstpt 248(%esp) + addl $-16, %esp + fstpt (%esp) + call asinhl@PLT +..B1.68: + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fstpt 260(%esp) + jmp ..B1.34 +..B1.20: + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.58 +..B1.75: + cmpl $32767, %ecx +..B1.21: + je ..B1.47 +..B1.22: + movl 28(%ebp), %eax +..B1.23: + cmpl $32767, %edx + je ..B1.44 +..B1.24: + testl %eax, %eax + jne ..B1.30 +..B1.25: + cmpl $0, 24(%ebp) + jne ..B1.30 +..B1.26: + fldt 12(%ebp) + cmpl $16383, %ecx + jl ..B1.28 +..B1.27: + movzbl 21(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl ones@GOTOFF(%ebx,%edx,8) + fstl (%esp) + addl $-16, %esp + fmulp %st, %st(1) + fstpt (%esp) + call acoshl@PLT +..B1.71: + fstpt 24(%esp) + fldl 16(%esp) + fstpt (%esp) + call acosl@PLT + jmp ..B1.72 +..B1.28: + addl $-16, %esp + fstpt (%esp) + call acosl@PLT +..B1.72: + addl $16, %esp + fstpt 248(%esp) +..B1.29: + fldt 8(%esp) + movzbl 33(%ebp), %edx + andl $128, %edx + shrl $7, %edx + xorl $1, %edx + fmull ones@GOTOFF(%ebx,%edx,8) + fstpt 260(%esp) + jmp ..B1.34 +..B1.30: + fldt 24(%ebp) + cmpl $32767, %edx + fldt 12(%ebp) + je ..B1.32 +..B1.31: + fld %st(0) + fmul %st(1), %st + jmp ..B1.33 +..B1.32: + fld %st(1) + fmul %st(2), %st +..B1.33: + movzbl 33(%ebp), %edx + andl $128, %edx + shrl $7, %edx + movl %edx, (%esp) + xorl $1, %edx + fmull ones@GOTOFF(%ebx,%edx,8) + fstpt 260(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT +..B1.73: + addl $32, %esp + movl (%esp), %edx + fmull ones@GOTOFF(%ebx,%edx,8) + fstpt 248(%esp) +..B1.34: + testl %edi, %edi + je ..B1.36 +..B1.35: + fldcw 22(%esp) +..B1.36: + movl 248(%esp), %edx + movl %edx, (%esi) + movl 260(%esp), %edx + movl %edx, 12(%esi) + movl 264(%esp), %edx + movl %edx, 16(%esi) + movl 252(%esp), %ecx + movl 256(%esp), %edi + movl 268(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 272(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.43 +..B1.37: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.38: + cmpl $0, 28(%ebp) + jne ..B1.11 +..B1.39: + cmpl $0, 24(%ebp) + jne ..B1.11 + jmp ..B1.16 +..B1.41: + movl 16(%ebp), %eax + testl %eax, %eax + jne ..B1.9 +..B1.42: + cmpl $0, 12(%ebp) + jne ..B1.9 + jmp ..B1.18 +..B1.43: + call __stack_chk_fail@PLT +..B1.44: + cmpl $-2147483648, %eax + jne ..B1.46 +..B1.78: + cmpl $0, 24(%ebp) +..B1.45: + je ..B1.30 +..B1.46: + fldt 24(%ebp) + fmul %st(0), %st + fstpt 248(%esp) + fldt 12(%ebp) + fmul %st(0), %st + fstpt 260(%esp) + jmp ..B1.34 +..B1.47: + cmpl $-2147483648, %eax + jne ..B1.49 +..B1.48: + cmpl $0, 12(%ebp) + je ..B1.52 +..B1.49: + cmpl $32767, %edx + jge ..B1.51 +..B1.50: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 248(%esp) + fldt 248(%esp) + fstpt 260(%esp) + jmp ..B1.34 +..B1.51: + cmpl $-2147483648, %eax + jne ..B1.53 +..B1.76: + cmpl $0, 12(%ebp) +..B1.52: + je ..B1.22 +..B1.53: + movl 28(%ebp), %eax + cmpl $32767, %edx + jne ..B1.24 +..B1.55: + cmpl $-2147483648, %eax + jne ..B1.57 +..B1.56: + cmpl $0, 24(%ebp) + je ..B1.45 +..B1.57: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 248(%esp) + fldt 24(%ebp) + fmul %st(0), %st + fstpt 260(%esp) + jmp ..B1.34 +..B1.58: + cmpl $-2147483648, 28(%ebp) + jne ..B1.60 +..B1.59: + cmpl $0, 24(%ebp) + je ..B1.74 +..B1.60: + cmpl $32767, %ecx + jge ..B1.21 +..B1.61: + fldt 24(%ebp) + fmul %st(0), %st + fstpt 248(%esp) + fldt 248(%esp) + fstpt 260(%esp) + jmp ..B1.34 +..B1.62: + xorl %edi, %edi + jmp ..B1.7 +..B1.74: + cmpl $32767, %ecx + je ..B1.47 + jmp ..B1.22 + .align 16,0x90 + .type cacosl,@function + .size cacosl,.-cacosl + .data +# -- End cacosl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .hidden __libm_recacosl_k80 + .hidden __libm_recacoshl_k80 + .hidden __libm_carctrigprepare_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/carg.S b/external/sgx_libm/ia32/carg.S new file mode 100644 index 0000000000..72a7d2fea1 --- /dev/null +++ b/external/sgx_libm/ia32/carg.S @@ -0,0 +1,94 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "carg.c" + .text +..TXTST0: +# -- Begin carg + .text + .align 16,0x90 + .globl carg +carg: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %ebx + subl $28, %esp + movzwl 14(%ebp), %eax + andl $32752, %eax + cmpl $32752, %eax + je ..B1.4 +..B1.2: + fldl 8(%ebp) +..B1.3: + fldl 16(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fxch %st(1) + fstpl 8(%esp) + fstpl (%esp) + call atan2@PLT +..B1.10: + addl $28, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.4: + testl $1048575, 12(%ebp) + jne ..B1.6 +..B1.5: + cmpl $0, 8(%ebp) + je ..B1.2 +..B1.6: + fldl 8(%ebp) + fmul %st(0), %st + fstl 8(%ebp) + jmp ..B1.3 + .align 16,0x90 + .type carg,@function + .size carg,.-carg + .data +# -- End carg + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cargf.S b/external/sgx_libm/ia32/cargf.S new file mode 100644 index 0000000000..4ab98a5de0 --- /dev/null +++ b/external/sgx_libm/ia32/cargf.S @@ -0,0 +1,71 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cargf.c" + .text +..TXTST0: +# -- Begin cargf + .text + .align 16,0x90 + .globl cargf +cargf: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $24, %esp + flds 36(%esp) + flds 32(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpl 8(%esp) + fstpl (%esp) + call atan2@PLT +..B1.4: + addl $24, %esp + popl %ebx + ret + .align 16,0x90 + .type cargf,@function + .size cargf,.-cargf + .data +# -- End cargf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cargl.S b/external/sgx_libm/ia32/cargl.S new file mode 100644 index 0000000000..3a7cfd7852 --- /dev/null +++ b/external/sgx_libm/ia32/cargl.S @@ -0,0 +1,76 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cargl.c" + .text +..TXTST0: +# -- Begin cargl + .text + .align 16,0x90 + .globl cargl +cargl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %ebx + subl $60, %esp + fldt 20(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpt (%esp) + fldt 8(%ebp) + fstpt 12(%esp) + call atan2l@PLT +..B1.4: + addl $60, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type cargl,@function + .size cargl,.-cargl + .data +# -- End cargl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/casin.S b/external/sgx_libm/ia32/casin.S new file mode 100644 index 0000000000..182c1ccc76 --- /dev/null +++ b/external/sgx_libm/ia32/casin.S @@ -0,0 +1,237 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casin.c" + .text +..TXTST0: +# -- Begin casin + .text + .align 16,0x90 + .globl casin +casin: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $72, %esp + fldz + fldl 20(%ebp) + fldl 12(%ebp) + movzwl 26(%ebp), %ecx + andl $32752, %ecx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 64(%esp) + cmpl $32752, %ecx + fstpl 56(%esp) + fxch %st(1) + fstl 16(%esp) + fstl 24(%esp) + fstl 32(%esp) + fstpl 40(%esp) + fstpl 48(%esp) + jl ..B1.4 +..B1.2: + testl $1048575, 24(%ebp) + jne ..B1.5 +..B1.3: + cmpl $0, 20(%ebp) + jne ..B1.5 +..B1.4: + movzbl 27(%ebp), %edx + notl %edx + movzbl 55(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 55(%esp) +..B1.5: + addl $-32, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea 32(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl 48(%ecx), %ecx + movl %ecx, (%edx) + movl 84(%esp), %ecx + movl %ecx, 4(%edx) + movl 88(%esp), %ecx + movl %ecx, 8(%edx) + movl 92(%esp), %ecx + movl %ecx, 12(%edx) + call casinh@PLT +..B1.14: + addl $28, %esp + fldl (%esp) + movzwl 6(%esp), %edx + andl $32752, %edx + fstl 16(%esp) + cmpl $32752, %edx + fstpl 40(%esp) + fldl 8(%esp) + fstl 24(%esp) + fstpl 32(%esp) + jl ..B1.8 +..B1.6: + testl $1048575, 20(%esp) + jne ..B1.9 +..B1.7: + cmpl $0, 16(%esp) + jne ..B1.9 +..B1.8: + movzbl 23(%esp), %edx + notl %edx + movzbl 47(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 47(%esp) +..B1.9: + movl 32(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 8(%esi) + movl 36(%esp), %ecx + movl 44(%esp), %edx + movl %ecx, 4(%esi) + movl %edx, 12(%esi) + movl 64(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.11 +..B1.10: + movl %esi, %eax + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.11: + call __stack_chk_fail@PLT + .align 16,0x90 + .type casin,@function + .size casin,.-casin + .data +# -- End casin + .text +# -- Begin casinf + .text + .align 16,0x90 + .globl casinf +casinf: +# parameter 1: 48 + %esp +..B2.1: +..L3: + + pushl %ebx + subl $40, %esp + xorl %eax, %eax + movl %eax, 16(%esp) + movl %eax, 20(%esp) + movl %eax, 24(%esp) + movl %eax, 28(%esp) + movzwl 54(%esp), %eax + andl $32640, %eax + movl 52(%esp), %edx + cmpl $32640, %eax + movl 48(%esp), %ecx + movl %edx, 32(%esp) + movl %ecx, 36(%esp) + jl ..B2.3 +..B2.2: + testl $8388607, 52(%esp) + jne ..B2.4 +..B2.3: + movzbl 55(%esp), %eax + notl %eax + movzbl 35(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 35(%esp) +..B2.4: + addl $8, %esp + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + pushl 28(%esp) + pushl 28(%esp) + call casinhf@PLT +..B2.10: + movl %eax, 16(%esp) + movl %eax, 28(%esp) + shrl $16, %eax + andl $32640, %eax + cmpl $32640, %eax + movl %edx, 20(%esp) + movl %edx, 24(%esp) + jl ..B2.6 +..B2.5: + testl $8388607, 16(%esp) + jne ..B2.7 +..B2.6: + movzbl 19(%esp), %eax + notl %eax + movzbl 31(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 31(%esp) +..B2.7: + movl 24(%esp), %eax + movl 28(%esp), %edx + addl $40, %esp + popl %ebx + ret + .align 16,0x90 + .type casinf,@function + .size casinf,.-casinf + .data +# -- End casinf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/casinh.S b/external/sgx_libm/ia32/casinh.S new file mode 100644 index 0000000000..a923b4424a --- /dev/null +++ b/external/sgx_libm/ia32/casinh.S @@ -0,0 +1,783 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casinh.c" + .text +..TXTST0: +# -- Begin casinh + .text + .align 16,0x90 + .globl casinh +casinh: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 192(%esp) + fstl 176(%esp) + fstpl 184(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 18(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %ecx + jge ..B1.38 +..B1.4: + testl %ecx, %ecx + jle ..B1.73 +..B1.5: + movzwl 26(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + jge ..B1.39 +..B1.6: + testl %edx, %edx + jle ..B1.71 +..B1.7: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.70 +..B1.8: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movl $1, %edi +..B1.11: + fldl 20(%ebp) + fstl 160(%esp) + fabs + fldl 12(%ebp) + fstl 152(%esp) + fabs + fld %st(0) + fmul %st(1), %st + fstpt 104(%esp) + fldt 104(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fld %st(0) + fsubr %st(4), %st + fld %st(0) + fmul %st(1), %st + fadd %st(3), %st + fsqrt + fstpt 88(%esp) + fldt 88(%esp) + fld %st(2) + fadd %st(6), %st + fld %st(0) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(4) + fsqrt + fstpt 120(%esp) + fldt 120(%esp) + fxch %st(1) + fucom %st(2) + fnstsw %ax + faddp %st, %st(1) + fxch %st(1) + fstpt 136(%esp) + sahf + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmul %st, %st(1) + jp ..B1.12 + je ..B1.13 +..B1.12: + fldt 88(%esp) + fldt 136(%esp) + fsubrp %st, %st(1) + fstpt 72(%esp) + jmp ..B1.14 +..B1.13: + fxch %st(4) + fstpt 72(%esp) + fldt 72(%esp) + fxch %st(4) +..B1.14: + fldt _Bcross@GOTOFF(%ebx) + fmul %st(2), %st + fcomp %st(6) + fnstsw %ax + sahf + jb ..B1.16 +..B1.15: + fstp %st(4) + fld %st(4) + addl $-16, %esp + fdiv %st(1), %st + fstpt (%esp) + fxch %st(4) + fstpl 80(%esp) + fxch %st(1) + fstpt 16(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt 48(%esp) + fstpt 64(%esp) + call asinl@PLT +..B1.107: + fldt 64(%esp) + fldt 48(%esp) + fldt 32(%esp) + fldt 16(%esp) + fldl 80(%esp) + addl $16, %esp + fxch %st(5) + fstpl 184(%esp) + jmp ..B1.19 +..B1.16: + fxch %st(2) + fcom %st(5) + fnstsw %ax + sahf + jb ..B1.18 +..B1.17: + fstp %st(4) + addl $-32, %esp + fld %st(2) + fld %st(1) + fadd %st(6), %st + fmul %st(3), %st + fxch %st(6) + fstpt (%esp) + fldt (%esp) + fldt 152(%esp) + faddp %st, %st(2) + fldt 136(%esp) + fdivp %st, %st(2) + fldt 104(%esp) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(6) + fxch %st(5) + fsqrt + fstpt 12(%esp) + fxch %st(4) + fstpl 96(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt 48(%esp) + fstpt 64(%esp) + fstpt 80(%esp) + call atan2l@PLT + jmp ..B1.109 +..B1.18: + fxch %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fxch %st(3) + fstpt (%esp) + fldt (%esp) + addl $-32, %esp + fxch %st(3) + fadd %st(5), %st + fxch %st(5) + fstpt (%esp) + fldt (%esp) + fldt 152(%esp) + faddp %st, %st(4) + fxch %st(3) + fdivr %st(5), %st + fldt 168(%esp) + fldt 120(%esp) + faddp %st, %st(1) + fdivrp %st, %st(6) + faddp %st, %st(5) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + fsqrt + fmulp %st, %st(3) + fxch %st(2) + fstpt 12(%esp) + fstpl 96(%esp) + fxch %st(1) + fstpt 48(%esp) + fstpt 64(%esp) + fldt 32(%esp) + fstpt 32(%esp) + fldt 80(%esp) + fstpt 80(%esp) + call atan2l@PLT +..B1.109: + fldt 80(%esp) + fldt 64(%esp) + fldt 48(%esp) + fldt 32(%esp) + fldl 96(%esp) + addl $32, %esp + fxch %st(5) + fstpl 184(%esp) +..B1.19: + fldt _Across@GOTOFF(%ebx) + fcomp %st(4) + fnstsw %ax + sahf + jb ..B1.24 +..B1.20: + fldt 120(%esp) + faddp %st, %st(1) + fxch %st(4) + fcomp %st(2) + fnstsw %ax + fldt 104(%esp) + fdivp %st, %st(4) + sahf + jae ..B1.22 + jp ..B1.22 +..B1.21: + fldt 72(%esp) + fldt 104(%esp) + fdivp %st, %st(1) + faddp %st, %st(4) + fmulp %st, %st(3) + jmp ..B1.23 +..B1.22: + fldt 88(%esp) + fldt 136(%esp) + faddp %st, %st(1) + faddp %st, %st(4) + fmulp %st, %st(3) +..B1.23: + addl $-16, %esp + faddp %st, %st(1) + fmul %st(1), %st + fsqrt + faddp %st, %st(1) + fstpt (%esp) + call log1pl@PLT + jmp ..B1.111 +..B1.24: + fstp %st(0) + fstp %st(0) + fstp %st(2) + fld %st(0) + addl $-16, %esp + fmul %st(1), %st + fsubp %st, %st(2) + fxch %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%esp) + call logl@PLT +..B1.111: + addl $16, %esp + fstpl 176(%esp) +..B1.25: + fldl _DBL_PZERO@GOTOFF(%ebx) + fcoml 160(%esp) + fnstsw %ax + sahf + jbe ..B1.27 +..B1.26: + movzbl 191(%esp), %ecx + movl %ecx, %edx + shrl $7, %ecx + andl $127, %edx + notl %ecx + shll $7, %ecx + orl %ecx, %edx + movb %dl, 191(%esp) +..B1.27: + fcompl 152(%esp) + fnstsw %ax + sahf + jbe ..B1.29 +..B1.28: + movzbl 183(%esp), %ecx + movl %ecx, %edx + shrl $7, %ecx + andl $127, %edx + notl %ecx + shll $7, %ecx + orl %ecx, %edx + movb %dl, 183(%esp) +..B1.29: + movzwl 182(%esp), %edx + testl $32752, %edx + jne ..B1.32 +..B1.30: + testl $1048575, 180(%esp) + jne ..B1.35 +..B1.31: + cmpl $0, 176(%esp) + jne ..B1.35 +..B1.32: + movzwl 190(%esp), %edx + testl $32752, %edx + jne ..B1.36 +..B1.33: + testl $1048575, 188(%esp) + jne ..B1.35 +..B1.34: + cmpl $0, 184(%esp) + je ..B1.36 +..B1.35: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 168(%esp) +..B1.36: + testl %edi, %edi + je ..B1.68 +..B1.37: + fldcw 14(%esp) + jmp ..B1.68 +..B1.38: + movzwl 26(%ebp), %edx + andl $32752, %edx + shrl $4, %edx +..B1.39: + testl %edx, %edx + jne ..B1.43 +..B1.40: + testl $1048575, 24(%ebp) + jne ..B1.43 +..B1.41: + cmpl $0, 20(%ebp) + jne ..B1.43 +..B1.42: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call asinh@PLT +..B1.112: + fldl 20(%ebp) + addl $16, %esp + fstpl 184(%esp) + fstpl 176(%esp) + jmp ..B1.68 +..B1.43: + testl %ecx, %ecx + jne ..B1.56 +..B1.44: + testl $1048575, 16(%ebp) + jne ..B1.57 +..B1.45: + cmpl $0, 12(%ebp) + jne ..B1.57 +..B1.46: + cmpl $2047, %edx + jl ..B1.49 +..B1.47: + testl $1048575, 24(%ebp) + jne ..B1.57 +..B1.48: + cmpl $0, 20(%ebp) + jne ..B1.57 +..B1.49: + cmpl $1023, %edx + jl ..B1.54 +..B1.50: + fldl 20(%ebp) + movzbl 27(%ebp), %edx + andl $128, %edx + shrl $7, %edx + movl %edx, (%esp) + addl $-16, %esp + fmull ones@GOTOFF(%ebx,%edx,8) + fstpl (%esp) + call acosh@PLT +..B1.113: + addl $16, %esp + fstpl 176(%esp) + cmpl $0, (%esp) + je ..B1.52 +..B1.51: + fldl _DBL_NPIBY2@GOTOFF(%ebx) + jmp ..B1.53 +..B1.52: + fldl _DBL_PPIBY2@GOTOFF(%ebx) +..B1.53: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fadd %st(1), %st + fstpl 168(%esp) + fstpl 184(%esp) + fldl 176(%esp) + jmp ..B1.55 +..B1.54: + fldl _DBL_PZERO@GOTOFF(%ebx) + addl $-16, %esp + fldl 20(%ebp) + fstpl (%esp) + fstpl 16(%esp) + call asin@PLT +..B1.114: + fldl 16(%esp) + addl $16, %esp + fxch %st(1) + fstpl 184(%esp) +..B1.55: + movzbl 19(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fmull ones@GOTOFF(%ebx,%edx,8) + fstpl 176(%esp) + jmp ..B1.68 +..B1.56: + cmpl $2047, %ecx + je ..B1.95 +..B1.57: + cmpl $2047, %edx + je ..B1.91 +..B1.118: + cmpl $2047, %ecx +..B1.58: + je ..B1.77 +..B1.59: + jge ..B1.67 +..B1.60: + movzbl 27(%ebp), %edx + testl $128, %edx + je ..B1.62 +..B1.61: + fldl _DBL_NPIBY2@GOTOFF(%ebx) + jmp ..B1.63 +..B1.62: + fldl _DBL_PPIBY2@GOTOFF(%ebx) +..B1.63: + movzbl 19(%ebp), %edx + testl $128, %edx + fstl 184(%esp) + je ..B1.65 +..B1.64: + fldl _DBL_NINF@GOTOFF(%ebx) + jmp ..B1.66 +..B1.65: + fldl _DBL_PINF@GOTOFF(%ebx) +..B1.66: + fstpl 176(%esp) + fldl _DBL_PZERO@GOTOFF(%ebx) + fxch %st(1) + faddl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fstpl 168(%esp) + faddl 12(%ebp) + fstpl 168(%esp) + jmp ..B1.68 +..B1.67: + fldl 20(%ebp) + fstpl 176(%esp) + fldl 12(%ebp) + fmul %st(0), %st + fstpl 184(%esp) +..B1.68: + movl 176(%esp), %edx + movl %edx, (%esi) + movl 180(%esp), %ecx + movl 184(%esp), %edi + movl 188(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 192(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.76 +..B1.69: + movl %esi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.70: + xorl %edi, %edi + jmp ..B1.11 +..B1.71: + testl $1048575, 24(%ebp) + jne ..B1.7 +..B1.72: + cmpl $0, 20(%ebp) + jne ..B1.7 + jmp ..B1.39 +..B1.73: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.74: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.38 +..B1.76: + call __stack_chk_fail@PLT +..B1.77: + testl $1048575, 16(%ebp) + jne ..B1.116 +..B1.78: + cmpl $0, 12(%ebp) + jne ..B1.116 +..B1.79: + fldl 12(%ebp) + cmpl $2047, %edx + fstpl 176(%esp) + jge ..B1.84 +..B1.80: + movzbl 27(%ebp), %edx + testl $128, %edx + je ..B1.82 +..B1.81: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 184(%esp) + fldl _DBL_PZERO@GOTOFF(%ebx) + jmp ..B1.83 +..B1.82: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstl 184(%esp) +..B1.83: + faddl 20(%ebp) + fstpl 168(%esp) + jmp ..B1.68 +..B1.84: + testl $1048575, 24(%ebp) + jne ..B1.90 +..B1.85: + cmpl $0, 20(%ebp) + jne ..B1.90 +..B1.86: + movzbl 27(%ebp), %edx + testl $128, %edx + je ..B1.88 +..B1.87: + fldl _DBL_NPIBY4@GOTOFF(%ebx) + jmp ..B1.89 +..B1.88: + fldl _DBL_PPIBY4@GOTOFF(%ebx) +..B1.89: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fadd %st(1), %st + fstpl 168(%esp) + fstpl 184(%esp) + jmp ..B1.68 +..B1.90: + fldl 20(%ebp) + fmul %st(0), %st + fstpl 184(%esp) + jmp ..B1.68 +..B1.91: + testl $1048575, 24(%ebp) + jne ..B1.93 +..B1.92: + cmpl $0, 20(%ebp) + je ..B1.115 +..B1.93: + cmpl $2047, %ecx + jge ..B1.58 +..B1.94: + fldl 20(%ebp) + fmul %st(0), %st + fstl 176(%esp) + fstpl 184(%esp) + jmp ..B1.68 +..B1.95: + testl $1048575, 16(%ebp) + jne ..B1.97 +..B1.96: + cmpl $0, 12(%ebp) + je ..B1.98 +..B1.97: + cmpl $2047, %edx + je ..B1.102 +..B1.98: + testl $1048575, 16(%ebp) + jne ..B1.100 +..B1.99: + cmpl $0, 12(%ebp) + je ..B1.57 +..B1.100: + cmpl $2047, %edx + jge ..B1.57 +..B1.101: + fldl 12(%ebp) + fmul %st(0), %st + fstl 176(%esp) + fstpl 184(%esp) + jmp ..B1.68 +..B1.102: + testl $1048575, 24(%ebp) + jne ..B1.104 +..B1.103: + cmpl $0, 20(%ebp) + je ..B1.98 +..B1.104: + fldl 12(%ebp) + fmul %st(0), %st + fstpl 176(%esp) + fldl 20(%ebp) + fmul %st(0), %st + fstpl 184(%esp) + jmp ..B1.68 +..B1.115: + cmpl $2047, %ecx + je ..B1.77 + jmp ..B1.59 +..B1.116: + cmpl $2047, %ecx + jl ..B1.60 + jmp ..B1.67 + .align 16,0x90 + .type casinh,@function + .size casinh,.-casinh + .data +# -- End casinh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +_Bcross: + .word 26214 + .word 26214 + .word 26214 + .word -6554 + .word 16382 + .word 0 + .type _Bcross,@object + .size _Bcross,12 + .space 4, 0x00 # pad + .align 16 +_Across: + .word 0 + .word 0 + .word 0 + .word -16384 + .word 16383 + .word 0 + .type _Across,@object + .size _Across,12 + .space 4, 0x00 # pad + .align 16 +_DBL_PZERO: + .long 0 + .long 0 + .type _DBL_PZERO,@object + .size _DBL_PZERO,8 + .space 8, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 16 +_DBL_NPIBY2: + .long 1413754136 + .long -1074191877 + .type _DBL_NPIBY2,@object + .size _DBL_NPIBY2,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPIBY2: + .long 1413754136 + .long 1073291771 + .type _DBL_PPIBY2,@object + .size _DBL_PPIBY2,8 + .space 8, 0x00 # pad + .align 16 +_DBL_NINF: + .long 0 + .long -1048576 + .type _DBL_NINF,@object + .size _DBL_NINF,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PINF: + .long 0 + .long 2146435072 + .type _DBL_PINF,@object + .size _DBL_PINF,8 + .space 8, 0x00 # pad + .align 16 +_DBL_NZERO: + .long 0 + .long -2147483648 + .type _DBL_NZERO,@object + .size _DBL_NZERO,8 + .space 8, 0x00 # pad + .align 16 +_DBL_NPIBY4: + .long 1413754136 + .long -1075240453 + .type _DBL_NPIBY4,@object + .size _DBL_NPIBY4,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPIBY4: + .long 1413754136 + .long 1072243195 + .type _DBL_PPIBY4,@object + .size _DBL_PPIBY4,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/casinhf.S b/external/sgx_libm/ia32/casinhf.S new file mode 100644 index 0000000000..de937f356e --- /dev/null +++ b/external/sgx_libm/ia32/casinhf.S @@ -0,0 +1,630 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casinhf.c" + .text +..TXTST0: +# -- Begin casinhf + .text + .align 16,0x90 + .globl casinhf +casinhf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %edi + pushl %ebx + subl $120, %esp + fldz + movzwl 10(%ebp), %eax + andl $32640, %eax + shrl $7, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %eax + fsts 104(%esp) + fsts 108(%esp) + jge ..B1.28 +..B1.2: + testl %eax, %eax + jle ..B1.57 +..B1.3: + movzwl 14(%ebp), %edx + andl $32640, %edx + shrl $7, %edx + cmpl $255, %edx + jge ..B1.29 +..B1.4: + testl %edx, %edx + jle ..B1.56 +..B1.5: + flds 12(%ebp) + fsts 100(%esp) + fld1 + fsts 92(%esp) + fxch %st(1) + fabs + fld %st(0) + fsub %st(2), %st + fld %st(0) + fmul %st(1), %st + fld %st(2) + faddp %st, %st(4) + fxch %st(3) + fstl 48(%esp) + fmul %st(0), %st + fxch %st(1) + fstl 72(%esp) + flds 8(%ebp) + fsts 96(%esp) + fabs + fld %st(0) + fmul %st(1), %st + fstl 56(%esp) + fadd %st, %st(5) + fxch %st(5) + fsqrt + fstl 64(%esp) + fxch %st(5) + faddp %st, %st(3) + fxch %st(2) + fsqrt + fld %st(0) + fadd %st(5), %st + fxch %st(5) + fucomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + fldl .L_2il0floatpacket.6@GOTOFF(%ebx) + fmul %st, %st(4) + sahf + jp ..B1.6 + je ..B1.7 +..B1.6: + fldl 64(%esp) + fsubl 72(%esp) + fstpl 40(%esp) + jmp ..B1.8 +..B1.7: + fxch %st(2) + fstl 40(%esp) + fxch %st(2) +..B1.8: + fldl _Bcross@GOTOFF(%ebx) + fmul %st(5), %st + fcomp %st(4) + fnstsw %ax + sahf + jb ..B1.10 +..B1.9: + fstp %st(2) + fld %st(2) + fdiv %st(4), %st + fstpl (%esp) + fxch %st(2) + fstps 80(%esp) + fxch %st(1) + fstpl 16(%esp) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + call asin@PLT + jmp ..B1.85 +..B1.10: + flds 92(%esp) + fcomp %st(4) + fnstsw %ax + sahf + jb ..B1.12 +..B1.11: + fstp %st(2) + fldl 48(%esp) + fadd %st(1), %st + fld %st(4) + fadd %st(4), %st + fmul %st(3), %st + fxch %st(1) + fdivrl 56(%esp) + faddl 40(%esp) + fmulp %st, %st(1) + fsqrt + fstpl 8(%esp) + fxch %st(2) + fstl (%esp) + fstps 80(%esp) + fxch %st(1) + fstpl 16(%esp) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + call atan2@PLT + jmp ..B1.85 +..B1.12: + fldl 48(%esp) + fadd %st(2), %st + fxch %st(2) + fstpl 16(%esp) + fld %st(4) + fadd %st(4), %st + fdiv %st, %st(2) + fldl 72(%esp) + faddl 64(%esp) + fdivrp %st, %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fsqrt + fmulp %st, %st(2) + fxch %st(1) + fstpl 8(%esp) + fxch %st(1) + fstl (%esp) + fstps 80(%esp) + fstpl 24(%esp) + fstpl 32(%esp) + fstps 84(%esp) + fldl 16(%esp) + fstpl 16(%esp) + call atan2@PLT +..B1.85: + flds 84(%esp) + fxch %st(1) + fstps 108(%esp) + fldl 32(%esp) + fldl 24(%esp) + fldl 16(%esp) + flds 80(%esp) +..B1.13: + fldl _Across@GOTOFF(%ebx) + fcomp %st(4) + fnstsw %ax + sahf + jb ..B1.18 +..B1.14: + flds 92(%esp) + fcompp + fnstsw %ax + faddl 48(%esp) + fdivrl 56(%esp) + sahf + jbe ..B1.16 +..B1.15: + fldl 56(%esp) + fdivl 40(%esp) + faddp %st, %st(1) + fmulp %st, %st(1) + jmp ..B1.17 +..B1.16: + fldl 72(%esp) + faddl 64(%esp) + faddp %st, %st(1) + fmulp %st, %st(1) +..B1.17: + fxch %st(1) + fadds 92(%esp) + fmul %st(1), %st + fsqrt + faddp %st, %st(1) + fstpl (%esp) + fstps 84(%esp) + call log1p@PLT + jmp ..B1.87 +..B1.18: + fstp %st(1) + fstp %st(1) + fstp %st(0) + fld %st(0) + fmul %st(1), %st + fsubs 92(%esp) + fsqrt + faddp %st, %st(1) + fstpl (%esp) + fstps 84(%esp) + call log@PLT +..B1.87: + flds 84(%esp) + fxch %st(1) + fstps 104(%esp) +..B1.19: + fcoms 100(%esp) + fnstsw %ax + sahf + jbe ..B1.21 +..B1.20: + movzbl 111(%esp), %edi + movl %edi, %eax + shrl $7, %edi + andl $127, %eax + notl %edi + shll $7, %edi + orl %edi, %eax + movb %al, 111(%esp) +..B1.21: + fcomps 96(%esp) + fnstsw %ax + sahf + jbe ..B1.23 +..B1.22: + movzbl 107(%esp), %edi + movl %edi, %eax + shrl $7, %edi + andl $127, %eax + notl %edi + shll $7, %edi + orl %edi, %eax + movb %al, 107(%esp) +..B1.23: + movzwl 106(%esp), %eax + testl $32640, %eax + jne ..B1.25 +..B1.24: + testl $8388607, 104(%esp) + jne ..B1.27 +..B1.25: + movzwl 110(%esp), %eax + testl $32640, %eax + jne ..B1.55 +..B1.26: + testl $8388607, 108(%esp) + je ..B1.55 +..B1.27: + flds .L_2il0floatpacket.9@GOTOFF(%ebx) + fmul %st(0), %st + fstps 88(%esp) + jmp ..B1.55 +..B1.28: + movzwl 14(%ebp), %edx + andl $32640, %edx + shrl $7, %edx +..B1.29: + testl %edx, %edx + jne ..B1.32 +..B1.30: + testl $8388607, 12(%ebp) + jne ..B1.32 +..B1.31: + fstp %st(0) + addl $4, %esp + pushl 8(%ebp) + call asinhf@PLT +..B1.88: + movl 12(%ebp), %eax + fstps 104(%esp) + movl %eax, 108(%esp) + jmp ..B1.55 +..B1.32: + testl %eax, %eax + jne ..B1.43 +..B1.33: + testl $8388607, 8(%ebp) + jne ..B1.44 +..B1.34: + cmpl $255, %edx + jl ..B1.36 +..B1.35: + testl $8388607, 12(%ebp) + jne ..B1.44 +..B1.36: + cmpl $127, %edx + jl ..B1.41 +..B1.37: + fstp %st(0) + flds 12(%ebp) + movzbl 15(%ebp), %edi + andl $128, %edi + shrl $7, %edi + fmuls ones@GOTOFF(%ebx,%edi,4) + fstps (%esp) + call acoshf@PLT +..B1.89: + fstps 104(%esp) + testl %edi, %edi + je ..B1.39 +..B1.38: + flds .L_2il0floatpacket.7@GOTOFF(%ebx) + jmp ..B1.40 +..B1.39: + flds .L_2il0floatpacket.8@GOTOFF(%ebx) +..B1.40: + flds .L_2il0floatpacket.9@GOTOFF(%ebx) + fadd %st(1), %st + fstps 88(%esp) + fstps 108(%esp) + flds 104(%esp) + jmp ..B1.42 +..B1.41: + movl 12(%ebp), %eax + movl %eax, (%esp) + fstps 84(%esp) + call asinf@PLT +..B1.90: + flds 84(%esp) + fxch %st(1) + fstps 108(%esp) +..B1.42: + movzbl 11(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmuls ones@GOTOFF(%ebx,%eax,4) + fstps 104(%esp) + jmp ..B1.55 +..B1.43: + cmpl $255, %eax + je ..B1.74 +..B1.44: + cmpl $255, %edx + je ..B1.71 +..B1.93: + cmpl $255, %eax +..B1.45: + je ..B1.59 +..B1.96: + fstp %st(0) +..B1.46: + jge ..B1.54 +..B1.47: + movzbl 15(%ebp), %eax + testl $128, %eax + je ..B1.49 +..B1.48: + flds .L_2il0floatpacket.7@GOTOFF(%ebx) + jmp ..B1.50 +..B1.49: + flds .L_2il0floatpacket.8@GOTOFF(%ebx) +..B1.50: + movzbl 11(%ebp), %eax + testl $128, %eax + fsts 108(%esp) + je ..B1.52 +..B1.51: + movl $-8388608, %eax + jmp ..B1.53 +..B1.52: + movl $2139095040, %eax +..B1.53: + movl %eax, 104(%esp) + movl 8(%ebp), %eax + fadds .L_2il0floatpacket.9@GOTOFF(%ebx) + fstps 88(%esp) + movl %eax, 88(%esp) + jmp ..B1.55 +..B1.54: + flds 8(%ebp) + fmul %st(0), %st + movl 12(%ebp), %eax + movl %eax, 104(%esp) + fstps 108(%esp) +..B1.55: + movl 104(%esp), %eax + movl 108(%esp), %edx + addl $120, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.56: + testl $8388607, 12(%ebp) + jne ..B1.5 + jmp ..B1.29 +..B1.57: + testl $8388607, 8(%ebp) + jne ..B1.3 + jmp ..B1.28 +..B1.59: + testl $8388607, 8(%ebp) + jne ..B1.92 +..B1.60: + movl 8(%ebp), %eax + cmpl $255, %edx + movl %eax, 104(%esp) + jge ..B1.65 +..B1.61: + movzbl 15(%ebp), %eax + testl $128, %eax + je ..B1.64 +..B1.62: + fstp %st(0) + flds .L_2il0floatpacket.10@GOTOFF(%ebx) +..B1.64: + movl 12(%ebp), %eax + fstps 108(%esp) + movl %eax, 88(%esp) + jmp ..B1.55 +..B1.65: + fstp %st(0) + testl $8388607, 12(%ebp) + jne ..B1.70 +..B1.66: + movzbl 15(%ebp), %eax + testl $128, %eax + je ..B1.68 +..B1.67: + flds .L_2il0floatpacket.11@GOTOFF(%ebx) + jmp ..B1.69 +..B1.68: + flds .L_2il0floatpacket.12@GOTOFF(%ebx) +..B1.69: + flds .L_2il0floatpacket.9@GOTOFF(%ebx) + fadd %st(1), %st + fstps 88(%esp) + fstps 108(%esp) + jmp ..B1.55 +..B1.70: + flds 12(%ebp) + fmul %st(0), %st + fstps 108(%esp) + jmp ..B1.55 +..B1.71: + testl $8388607, 12(%ebp) + je ..B1.91 +..B1.72: + cmpl $255, %eax + jge ..B1.45 +..B1.73: + fstp %st(0) + flds 12(%ebp) + fmul %st(0), %st + fsts 104(%esp) + fstps 108(%esp) + jmp ..B1.55 +..B1.74: + testl $8388607, 8(%ebp) + je ..B1.76 +..B1.75: + cmpl $255, %edx + je ..B1.79 +..B1.95: + testl $8388607, 8(%ebp) +..B1.76: + je ..B1.44 +..B1.77: + cmpl $255, %edx + jge ..B1.44 +..B1.78: + fstp %st(0) + flds 8(%ebp) + fmul %st(0), %st + fsts 104(%esp) + fstps 108(%esp) + jmp ..B1.55 +..B1.79: + testl $8388607, 12(%ebp) + je ..B1.94 +..B1.80: + fstp %st(0) + flds 8(%ebp) + fmul %st(0), %st + fstps 104(%esp) + flds 12(%ebp) + fmul %st(0), %st + fstps 108(%esp) + jmp ..B1.55 +..B1.91: + cmpl $255, %eax + je ..B1.59 + jmp ..B1.96 +..B1.92: + fstp %st(0) + cmpl $255, %eax + jl ..B1.47 + jmp ..B1.54 +..B1.94: + testl $8388607, 8(%ebp) + jne ..B1.77 + jmp ..B1.44 + .align 16,0x90 + .type casinhf,@function + .size casinhf,.-casinhf + .data +# -- End casinhf + .section .rodata, "a" + .align 16 + .align 16 +_Bcross: + .long -858993459 + .long 1072483532 + .type _Bcross,@object + .size _Bcross,8 + .space 8, 0x00 # pad + .align 16 +_Across: + .long 0 + .long 1073217536 + .type _Across,@object + .size _Across,8 + .space 8, 0x00 # pad + .align 16 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 4 +.L_2il0floatpacket.7: + .long 0xbfc90fdb + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,4 + .align 4 +.L_2il0floatpacket.8: + .long 0x3fc90fdb + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .align 4 +.L_2il0floatpacket.9: + .long 0x00800000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,4 + .align 4 +.L_2il0floatpacket.10: + .long 0x80000000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .align 4 +.L_2il0floatpacket.11: + .long 0xbf490fdb + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,4 + .align 4 +.L_2il0floatpacket.12: + .long 0x3f490fdb + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .align 4 +.L_2il0floatpacket.13: + .long 0xff800000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,4 + .align 4 +.L_2il0floatpacket.14: + .long 0x7f800000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/casinhl.S b/external/sgx_libm/ia32/casinhl.S new file mode 100644 index 0000000000..31dd4fbe27 --- /dev/null +++ b/external/sgx_libm/ia32/casinhl.S @@ -0,0 +1,441 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casinhl.c" + .text +..TXTST0: +# -- Begin casinhl + .text + .align 16,0x90 + .globl casinhl +casinhl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $308, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 272(%esp) + fstpt 8(%esp) + fldt 8(%esp) + fstpt 248(%esp) + fldt 248(%esp) + fstpt 260(%esp) +..B1.2: + fnstcw 22(%esp) +..B1.3: + movzwl 22(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.62 +..B1.4: + orl $-64768, %ecx + movw %cx, 20(%esp) +..B1.5: + fldcw 20(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.16 +..B1.8: + testl %ecx, %ecx + jle ..B1.41 +..B1.9: + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.16 +..B1.10: + testl %edx, %edx + jle ..B1.39 +..B1.11: + addl $-48, %esp + lea 24(%ebp), %edx + lea 12(%ebp), %ecx + movl %edx, (%esp) + lea 268(%esp), %edx + movl %ecx, 4(%esp) + movl %edx, 8(%esp) + lea 240(%esp), %edx + movl %edx, 12(%esp) + lea 212(%esp), %edx + movl %edx, 16(%esp) + lea 184(%esp), %edx + movl %edx, 20(%esp) + lea 156(%esp), %edx + movl %edx, 24(%esp) + lea 128(%esp), %edx + movl %edx, 28(%esp) + lea 100(%esp), %edx + movl %edx, 32(%esp) + lea 72(%esp), %edx + movl %edx, 36(%esp) + call __libm_carctrigprepare_k80 +..B1.65: + lea 72(%esp), %edx + lea 12(%ebp), %ecx +..B1.12: + lea 24(%ebp), %eax + movl %eax, (%esp) + lea 268(%esp), %eax + movl %ecx, 4(%esp) + movl %eax, 8(%esp) + lea 240(%esp), %eax + movl %eax, 12(%esp) + lea 212(%esp), %eax + movl %eax, 16(%esp) + lea 184(%esp), %eax + movl %eax, 20(%esp) + lea 156(%esp), %eax + movl %eax, 24(%esp) + lea 128(%esp), %eax + movl %eax, 28(%esp) + lea 100(%esp), %eax + movl %eax, 32(%esp) + movl %edx, 36(%esp) + call __libm_recacoshl_k80 +..B1.66: + lea 72(%esp), %edx + addl $48, %esp + lea 12(%ebp), %ecx +..B1.13: + movzbl 9(%ecx), %eax + andl $128, %eax + shrl $7, %eax + fldl ones@GOTOFF(%ebx,%eax,8) + lea 24(%ebp), %eax + fmulp %st, %st(1) + fstpt 248(%esp) + addl $-48, %esp + movl %eax, (%esp) + movl %ecx, 4(%esp) + lea 268(%esp), %ecx + movl %ecx, 8(%esp) + lea 240(%esp), %ecx + movl %ecx, 12(%esp) + lea 212(%esp), %ecx + movl %ecx, 16(%esp) + lea 184(%esp), %ecx + movl %ecx, 20(%esp) + lea 156(%esp), %ecx + movl %ecx, 24(%esp) + lea 128(%esp), %ecx + movl %ecx, 28(%esp) + lea 100(%esp), %ecx + movl %ecx, 32(%esp) + movl %edx, 36(%esp) + call __libm_recasinl_k80 +..B1.67: + addl $48, %esp +..B1.14: + fstpt 260(%esp) + jmp ..B1.35 +..B1.16: + movl 28(%ebp), %edx +..B1.17: + testl %edx, %edx + jne ..B1.20 +..B1.75: + cmpl $0, 24(%ebp) +..B1.18: + jne ..B1.20 +..B1.19: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call asinhl@PLT +..B1.68: + fldt 24(%ebp) + addl $16, %esp + fstpt 260(%esp) + fstpt 248(%esp) + jmp ..B1.35 +..B1.20: + movl 16(%ebp), %eax + testl %eax, %eax + movl %eax, (%esp) + jne ..B1.29 +..B1.21: + movzwl 32(%ebp), %eax + andl $32767, %eax + cmpl $0, 12(%ebp) + jne ..B1.30 +..B1.22: + cmpl $32767, %eax + jl ..B1.25 +..B1.23: + cmpl $-2147483648, %edx + jne ..B1.30 +..B1.24: + cmpl $0, 24(%ebp) + jne ..B1.30 +..B1.25: + fldt 24(%ebp) + cmpl $16383, %eax + jl ..B1.27 +..B1.26: + movzbl 33(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl ones@GOTOFF(%ebx,%edx,8) + fstl (%esp) + addl $-16, %esp + fmulp %st, %st(1) + fstpt (%esp) + call acoshl@PLT +..B1.70: + fstpt 24(%esp) + fldl 16(%esp) + fstpt (%esp) + call asinl@PLT + jmp ..B1.71 +..B1.27: + addl $-16, %esp + fstpt (%esp) + call asinl@PLT +..B1.71: + addl $16, %esp + fstpt 260(%esp) +..B1.28: + fldt 8(%esp) + movzbl 21(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fmull ones@GOTOFF(%ebx,%edx,8) + fstpt 248(%esp) + jmp ..B1.35 +..B1.29: + movzwl 32(%ebp), %eax + andl $32767, %eax +..B1.30: + cmpl $32767, %ecx + je ..B1.52 +..B1.31: + cmpl $32767, %eax + je ..B1.48 +..B1.74: + cmpl $32767, %ecx +..B1.32: + je ..B1.45 +..B1.33: + fldt 24(%ebp) + fld %st(0) + fmul %st(1), %st + fldt 12(%ebp) + fxch %st(2) +..B1.34: + movzbl 21(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl ones@GOTOFF(%ebx,%edx,8) + fmul %st, %st(2) + fxch %st(2) + fstpt 248(%esp) + addl $-32, %esp + fxch %st(2) + fmulp %st, %st(1) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT +..B1.72: + addl $32, %esp + fstpt 260(%esp) +..B1.35: + testl %edi, %edi + je ..B1.37 +..B1.36: + fldcw 22(%esp) +..B1.37: + movl 248(%esp), %edx + movl %edx, (%esi) + movl 260(%esp), %edx + movl %edx, 12(%esi) + movl 264(%esp), %edx + movl %edx, 16(%esi) + movl 252(%esp), %ecx + movl 256(%esp), %edi + movl 268(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 272(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.44 +..B1.38: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.39: + movl 28(%ebp), %edx + testl %edx, %edx + jne ..B1.11 +..B1.40: + cmpl $0, 24(%ebp) + jne ..B1.11 + jmp ..B1.18 +..B1.41: + cmpl $0, 16(%ebp) + jne ..B1.9 +..B1.42: + cmpl $0, 12(%ebp) + jne ..B1.9 + jmp ..B1.16 +..B1.44: + call __stack_chk_fail@PLT +..B1.45: + cmpl $-2147483648, (%esp) + jne ..B1.33 +..B1.46: + cmpl $0, 12(%ebp) + jne ..B1.33 +..B1.47: + fldt 12(%ebp) + fld %st(0) + fmul %st(1), %st + fldt 24(%ebp) + jmp ..B1.34 +..B1.48: + cmpl $-2147483648, %edx + jne ..B1.50 +..B1.49: + cmpl $0, 24(%ebp) + je ..B1.73 +..B1.50: + cmpl $32767, %ecx + jge ..B1.32 +..B1.51: + fldt 24(%ebp) + fmul %st(0), %st + fstpt 248(%esp) + fldt 248(%esp) + fstpt 260(%esp) + jmp ..B1.35 +..B1.52: + cmpl $-2147483648, (%esp) + jne ..B1.54 +..B1.53: + cmpl $0, 12(%ebp) + je ..B1.56 +..B1.54: + cmpl $32767, %eax + je ..B1.59 +..B1.55: + cmpl $-2147483648, (%esp) + jne ..B1.57 +..B1.76: + cmpl $0, 12(%ebp) +..B1.56: + je ..B1.31 +..B1.57: + cmpl $32767, %eax + jge ..B1.31 +..B1.58: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 248(%esp) + fldt 248(%esp) + fstpt 260(%esp) + jmp ..B1.35 +..B1.59: + cmpl $-2147483648, %edx + jne ..B1.61 +..B1.60: + cmpl $0, 24(%ebp) + je ..B1.55 +..B1.61: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 248(%esp) + fldt 24(%ebp) + fmul %st(0), %st + fstpt 260(%esp) + jmp ..B1.35 +..B1.62: + xorl %edi, %edi + jmp ..B1.7 +..B1.73: + cmpl $32767, %ecx + je ..B1.45 + jmp ..B1.33 + .align 16,0x90 + .type casinhl,@function + .size casinhl,.-casinhl + .data +# -- End casinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .hidden __libm_recasinl_k80 + .hidden __libm_recacoshl_k80 + .hidden __libm_carctrigprepare_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/casinl.S b/external/sgx_libm/ia32/casinl.S new file mode 100644 index 0000000000..efe03286b1 --- /dev/null +++ b/external/sgx_libm/ia32/casinl.S @@ -0,0 +1,210 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casinl.c" + .text +..TXTST0: +# -- Begin casinl + .text + .align 16,0x90 + .globl casinl +casinl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 100(%esp) + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 40(%esp) + fldt 40(%esp) + fstpt 52(%esp) + fldt 52(%esp) + fstpt 64(%esp) +..B1.2: + fnstcw 2(%esp) +..B1.3: + movzwl 2(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.4: + orl $-64768, %ecx + movw %cx, (%esp) +..B1.5: + fldcw (%esp) +..B1.6: + movl $1, %edi +..B1.7: + fldt 24(%ebp) + movzwl 32(%ebp), %edx + andl $32767, %edx + fstpt 52(%esp) + cmpl $32767, %edx + fldt 12(%ebp) + fstpt 64(%esp) + jl ..B1.10 +..B1.8: + cmpl $-2147483648, 28(%ebp) + jne ..B1.11 +..B1.9: + cmpl $0, 24(%ebp) + jne ..B1.11 +..B1.10: + movzbl 33(%ebp), %ecx + notl %ecx + movzbl 61(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 61(%esp) +..B1.11: + addl $-32, %esp + lea 108(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl -24(%ecx), %ecx + movl %ecx, (%edx) + movl 88(%esp), %ecx + movl %ecx, 4(%edx) + movl 92(%esp), %ecx + movl %ecx, 8(%edx) + movl 96(%esp), %ecx + movl %ecx, 12(%edx) + movl 100(%esp), %ecx + movl %ecx, 16(%edx) + movl 104(%esp), %ecx + movl %ecx, 20(%edx) + call casinhl@PLT +..B1.23: + addl $28, %esp + fldt 76(%esp) + movzwl 84(%esp), %edx + andl $32767, %edx + fstpt 4(%esp) + fldt 4(%esp) + cmpl $32767, %edx + fstpt 40(%esp) + fldt 88(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + jl ..B1.14 +..B1.12: + cmpl $-2147483648, 8(%esp) + jne ..B1.15 +..B1.13: + cmpl $0, 4(%esp) + jne ..B1.15 +..B1.14: + movzbl 13(%esp), %ecx + notl %ecx + movzbl 49(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 49(%esp) +..B1.15: + testl %edi, %edi + je ..B1.17 +..B1.16: + fldcw 2(%esp) +..B1.17: + movl 28(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 12(%esi) + movl 44(%esp), %edx + movl %edx, 16(%esi) + movl 32(%esp), %ecx + movl 36(%esp), %edi + movl 48(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 100(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.19 +..B1.18: + movl %esi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.19: + call __stack_chk_fail@PLT +..B1.20: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type casinl,@function + .size casinl,.-casinl + .data +# -- End casinl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/catan.S b/external/sgx_libm/ia32/catan.S new file mode 100644 index 0000000000..6439e8be43 --- /dev/null +++ b/external/sgx_libm/ia32/catan.S @@ -0,0 +1,237 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catan.c" + .text +..TXTST0: +# -- Begin catan + .text + .align 16,0x90 + .globl catan +catan: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $72, %esp + fldz + fldl 20(%ebp) + fldl 12(%ebp) + movzwl 26(%ebp), %ecx + andl $32752, %ecx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 64(%esp) + cmpl $32752, %ecx + fstpl 56(%esp) + fxch %st(1) + fstl 16(%esp) + fstl 24(%esp) + fstl 32(%esp) + fstpl 40(%esp) + fstpl 48(%esp) + jl ..B1.4 +..B1.2: + testl $1048575, 24(%ebp) + jne ..B1.5 +..B1.3: + cmpl $0, 20(%ebp) + jne ..B1.5 +..B1.4: + movzbl 27(%ebp), %edx + notl %edx + movzbl 55(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 55(%esp) +..B1.5: + addl $-32, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea 32(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl 48(%ecx), %ecx + movl %ecx, (%edx) + movl 84(%esp), %ecx + movl %ecx, 4(%edx) + movl 88(%esp), %ecx + movl %ecx, 8(%edx) + movl 92(%esp), %ecx + movl %ecx, 12(%edx) + call catanh@PLT +..B1.14: + addl $28, %esp + fldl (%esp) + movzwl 6(%esp), %edx + andl $32752, %edx + fstl 16(%esp) + cmpl $32752, %edx + fstpl 40(%esp) + fldl 8(%esp) + fstl 24(%esp) + fstpl 32(%esp) + jl ..B1.8 +..B1.6: + testl $1048575, 20(%esp) + jne ..B1.9 +..B1.7: + cmpl $0, 16(%esp) + jne ..B1.9 +..B1.8: + movzbl 23(%esp), %edx + notl %edx + movzbl 47(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 47(%esp) +..B1.9: + movl 32(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 8(%esi) + movl 36(%esp), %ecx + movl 44(%esp), %edx + movl %ecx, 4(%esi) + movl %edx, 12(%esi) + movl 64(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.11 +..B1.10: + movl %esi, %eax + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.11: + call __stack_chk_fail@PLT + .align 16,0x90 + .type catan,@function + .size catan,.-catan + .data +# -- End catan + .text +# -- Begin catanf + .text + .align 16,0x90 + .globl catanf +catanf: +# parameter 1: 48 + %esp +..B2.1: +..L3: + + pushl %ebx + subl $40, %esp + xorl %eax, %eax + movl %eax, 16(%esp) + movl %eax, 20(%esp) + movl %eax, 24(%esp) + movl %eax, 28(%esp) + movzwl 54(%esp), %eax + andl $32640, %eax + movl 52(%esp), %edx + cmpl $32640, %eax + movl 48(%esp), %ecx + movl %edx, 32(%esp) + movl %ecx, 36(%esp) + jl ..B2.3 +..B2.2: + testl $8388607, 52(%esp) + jne ..B2.4 +..B2.3: + movzbl 55(%esp), %eax + notl %eax + movzbl 35(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 35(%esp) +..B2.4: + addl $8, %esp + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + pushl 28(%esp) + pushl 28(%esp) + call catanhf@PLT +..B2.10: + movl %eax, 16(%esp) + movl %eax, 28(%esp) + shrl $16, %eax + andl $32640, %eax + cmpl $32640, %eax + movl %edx, 20(%esp) + movl %edx, 24(%esp) + jl ..B2.6 +..B2.5: + testl $8388607, 16(%esp) + jne ..B2.7 +..B2.6: + movzbl 19(%esp), %eax + notl %eax + movzbl 31(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 31(%esp) +..B2.7: + movl 24(%esp), %eax + movl 28(%esp), %edx + addl $40, %esp + popl %ebx + ret + .align 16,0x90 + .type catanf,@function + .size catanf,.-catanf + .data +# -- End catanf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/catanh.S b/external/sgx_libm/ia32/catanh.S new file mode 100644 index 0000000000..41181a538b --- /dev/null +++ b/external/sgx_libm/ia32/catanh.S @@ -0,0 +1,727 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catanh.c" + .text +..TXTST0: +# -- Begin catanh + .text + .align 16,0x90 + .globl catanh +catanh: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 192(%esp) + fstl 176(%esp) + fstpl 184(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 18(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %edx + jge ..B1.19 +..B1.4: + testl %edx, %edx + jle ..B1.74 +..B1.5: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + jge ..B1.20 +..B1.6: + testl %ecx, %ecx + jle ..B1.72 +..B1.7: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.71 +..B1.8: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movl $1, %edi +..B1.11: + fldl 12(%ebp) + fstl 160(%esp) + fmul %st(0), %st + fstpt 80(%esp) + fldt 80(%esp) + fldl 20(%ebp) + fld %st(0) + fmul %st(1), %st + fstpt 144(%esp) + fldt 144(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fstpt 128(%esp) + fldt 128(%esp) + fsubp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 28(%esp) + fldt 28(%esp) + fabs + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fstpt 96(%esp) + fldt 96(%esp) + fcompp + fnstsw %ax + sahf + jbe ..B1.13 +..B1.12: + fldl 160(%esp) + fldt 128(%esp) + faddp %st, %st(1) + fstpt 112(%esp) + fldt 112(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fxch %st(1) + fstpt 12(%esp) + fstpt 48(%esp) + call atan2l@PLT +..B1.106: + fldt 48(%esp) + addl $32, %esp + fchs + fxch %st(1) + fstpt 40(%esp) + fldt 128(%esp) + fsubl 160(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + fldt 12(%esp) + fstpt 32(%esp) + call atan2l@PLT +..B1.105: + fldt 32(%esp) + addl $32, %esp + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fstpt 16(%esp) + fldt 16(%esp) + fxch %st(2) + fstpt 52(%esp) + fldt 40(%esp) + fldt 52(%esp) + fsubrp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpl 184(%esp) + jmp ..B1.14 +..B1.13: + fldt 28(%esp) + addl $-32, %esp + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT +..B1.107: + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + addl $32, %esp + fstpt 16(%esp) + fldt 16(%esp) + fmulp %st, %st(1) + fstpl 184(%esp) + fldl 160(%esp) + fld %st(0) + fldt 128(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpt 112(%esp) + fsubp %st, %st(1) +..B1.14: + fldt 112(%esp) + fstpt 40(%esp) + fchs + fldt 40(%esp) + fldt 40(%esp) + fmulp %st, %st(1) + fldt 144(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpt 64(%esp) + fxch %st(1) + fstpt 52(%esp) + fldt 52(%esp) + fldt 52(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 28(%esp) + fldt 64(%esp) + fldt 28(%esp) + fsubrp %st, %st(1) + fabs + fldt 28(%esp) + fldt 96(%esp) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B1.16 + jp ..B1.16 +..B1.15: + fldt 64(%esp) + fldt 28(%esp) + addl $-16, %esp + fdivrp %st, %st(1) + fstpt (%esp) + call logl@PLT +..B1.108: + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fstpl 176(%esp) + jmp ..B1.17 +..B1.16: + fldt 80(%esp) + fldt 144(%esp) + faddp %st, %st(1) + fldt 128(%esp) + faddp %st, %st(1) + fstpt 28(%esp) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fmull 160(%esp) + fstpt 64(%esp) + fldt 64(%esp) + fldt 28(%esp) + addl $-16, %esp + fdivrp %st, %st(1) + fstpt (%esp) + call atanhl@PLT +..B1.109: + addl $16, %esp + fldt 16(%esp) + fmulp %st, %st(1) + fstpl 176(%esp) +..B1.17: + testl %edi, %edi + je ..B1.62 +..B1.18: + fldcw 14(%esp) + jmp ..B1.62 +..B1.19: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx +..B1.20: + cmpl $2047, %edx + je ..B1.90 +..B1.21: + cmpl $2047, %ecx + je ..B1.83 +..B1.22: + cmpl $2047, %ecx + jge ..B1.54 +..B1.23: + testl %edx, %edx + jle ..B1.80 +..B1.24: + cmpl $1023, %edx + jge ..B1.28 +..B1.25: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call atanh@PLT +..B1.110: + addl $16, %esp + movzbl 27(%ebp), %edx + testl $128, %edx + fstpl 176(%esp) + je ..B1.27 +..B1.26: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 184(%esp) + jmp ..B1.62 +..B1.27: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 184(%esp) + jmp ..B1.62 +..B1.28: + je ..B1.78 +..B1.29: + cmpl $2047, %edx + jge ..B1.43 +..B1.30: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.77 +..B1.31: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.32: + fldcw 12(%esp) +..B1.33: + movl $1, %edx +..B1.34: + fldl 12(%ebp) + fld %st(0) + fld %st(1) + fmul %st(2), %st + fldl 20(%ebp) + fmul %st(0), %st + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fld %st(0) + fsub %st(5), %st + fchs + fxch %st(1) + fadd %st, %st(4) + fxch %st(4) + fstpt 40(%esp) + fldt 40(%esp) + fldt 40(%esp) + fmulp %st, %st(1) + fadd %st(2), %st + fstpt 64(%esp) + fstpt 52(%esp) + fldt 52(%esp) + fldt 52(%esp) + fmulp %st, %st(1) + fadd %st(1), %st + fstpt 28(%esp) + fldt 64(%esp) + fldt 28(%esp) + fsubrp %st, %st(1) + fabs + fldt 28(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B1.36 + jp ..B1.36 +..B1.35: + fstp %st(2) + fstp %st(1) + fstp %st(0) + fstp %st(0) + fldt 64(%esp) + fldt 28(%esp) + addl $-16, %esp + fdivrp %st, %st(1) + fstpt (%esp) + movl %edx, 16(%esp) + call logl@PLT +..B1.111: + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + fmulp %st, %st(1) + movl 16(%esp), %edx + addl $16, %esp + fstpl 176(%esp) + jmp ..B1.37 +..B1.36: + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 28(%esp) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fldt 28(%esp) + addl $-16, %esp + fdivrp %st, %st(1) + fstpt (%esp) + movl %edx, 16(%esp) + call atanhl@PLT +..B1.112: + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fmulp %st, %st(1) + movl 16(%esp), %edx + addl $16, %esp + fstpl 176(%esp) +..B1.37: + testl %edx, %edx + je ..B1.39 +..B1.38: + fldcw 14(%esp) +..B1.39: + movzbl 27(%ebp), %edx + testl $128, %edx + je ..B1.41 +..B1.40: + fldl _DBL_NPIBY2@GOTOFF(%ebx) + jmp ..B1.42 +..B1.41: + fldl _DBL_PPIBY2@GOTOFF(%ebx) +..B1.42: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fxch %st(1) + fstl 184(%esp) + faddp %st, %st(1) + fstpl 168(%esp) + jmp ..B1.62 +..B1.43: + testl %ecx, %ecx + jne ..B1.47 +..B1.44: + testl $1048575, 24(%ebp) + jne ..B1.46 +..B1.45: + cmpl $0, 20(%ebp) + je ..B1.47 +..B1.46: + fldl .L_2il0floatpacket.12@GOTOFF(%ebx) + faddl 20(%ebp) + fstpl 168(%esp) +..B1.47: + movzbl 19(%ebp), %edx + testl $128, %edx + je ..B1.49 +..B1.48: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 176(%esp) + jmp ..B1.50 +..B1.49: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 176(%esp) +..B1.50: + movzbl 27(%ebp), %edx + testl $128, %edx + je ..B1.52 +..B1.51: + fldl _DBL_NPIBY2@GOTOFF(%ebx) + jmp ..B1.53 +..B1.52: + fldl _DBL_PPIBY2@GOTOFF(%ebx) +..B1.53: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fxch %st(1) + fstl 184(%esp) + faddp %st, %st(1) + fstpl 168(%esp) + jmp ..B1.62 +..B1.54: + testl %edx, %edx + jne ..B1.58 +..B1.55: + testl $1048575, 16(%ebp) + jne ..B1.57 +..B1.56: + cmpl $0, 12(%ebp) + je ..B1.58 +..B1.57: + fldl .L_2il0floatpacket.12@GOTOFF(%ebx) + faddl 12(%ebp) + fstpl 168(%esp) +..B1.58: + movzbl 19(%ebp), %edx + testl $128, %edx + je ..B1.60 +..B1.59: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 176(%esp) + jmp ..B1.61 +..B1.60: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 176(%esp) +..B1.61: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call atan@PLT +..B1.113: + addl $16, %esp + fstpl 184(%esp) +..B1.62: + movzwl 182(%esp), %edx + testl $32752, %edx + jne ..B1.65 +..B1.63: + testl $1048575, 180(%esp) + jne ..B1.68 +..B1.64: + cmpl $0, 176(%esp) + jne ..B1.68 +..B1.65: + movzwl 190(%esp), %edx + testl $32752, %edx + jne ..B1.69 +..B1.66: + testl $1048575, 188(%esp) + jne ..B1.68 +..B1.67: + cmpl $0, 184(%esp) + je ..B1.69 +..B1.68: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 168(%esp) +..B1.69: + movl 176(%esp), %edx + movl %edx, (%esi) + movl 180(%esp), %ecx + movl 184(%esp), %edi + movl 188(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 192(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.82 +..B1.70: + movl %esi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.71: + xorl %edi, %edi + jmp ..B1.11 +..B1.72: + testl $1048575, 24(%ebp) + jne ..B1.7 +..B1.73: + cmpl $0, 20(%ebp) + jne ..B1.7 + jmp ..B1.20 +..B1.74: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.75: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.19 +..B1.77: + xorl %edx, %edx + jmp ..B1.34 +..B1.78: + testl $1048575, 16(%ebp) + jne ..B1.29 +..B1.79: + cmpl $0, 12(%ebp) + je ..B1.25 + jmp ..B1.29 +..B1.80: + testl $1048575, 16(%ebp) + jne ..B1.24 +..B1.81: + cmpl $0, 12(%ebp) + jne ..B1.24 + jmp ..B1.54 +..B1.82: + call __stack_chk_fail@PLT +..B1.83: + testl $1048575, 24(%ebp) + jne ..B1.85 +..B1.84: + cmpl $0, 20(%ebp) + je ..B1.22 +..B1.85: + cmpl $2047, %edx + jge ..B1.22 +..B1.86: + testl %edx, %edx + jle ..B1.88 +..B1.87: + fldl 20(%ebp) + fmul %st(0), %st + fstl 176(%esp) + fstpl 184(%esp) + jmp ..B1.62 +..B1.88: + testl $1048575, 16(%ebp) + jne ..B1.87 +..B1.89: + cmpl $0, 12(%ebp) + jne ..B1.87 + jmp ..B1.22 +..B1.90: + testl $1048575, 16(%ebp) + jne ..B1.92 +..B1.91: + cmpl $0, 12(%ebp) + je ..B1.21 +..B1.92: + fldl 12(%ebp) + cmpl $2047, %ecx + fmul %st(0), %st + jge ..B1.94 +..B1.93: + fstl 12(%ebp) + fmul %st(0), %st + fstl 176(%esp) + fstpl 184(%esp) + jmp ..B1.62 +..B1.94: + testl $1048575, 24(%ebp) + jne ..B1.101 +..B1.95: + cmpl $0, 20(%ebp) + jne ..B1.101 +..B1.96: + fmul %st(0), %st + fstpl 12(%ebp) + fldl _DBL_PZERO@GOTOFF(%ebx) + movzbl 27(%ebp), %edx + testl $128, %edx + fstpl 176(%esp) + je ..B1.98 +..B1.97: + fldl _DBL_NPIBY2@GOTOFF(%ebx) + jmp ..B1.99 +..B1.98: + fldl _DBL_PPIBY2@GOTOFF(%ebx) +..B1.99: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fxch %st(1) + fstl 184(%esp) + faddp %st, %st(1) + fstpl 168(%esp) + jmp ..B1.62 +..B1.101: + fstl 12(%ebp) +..B1.102: + fmul %st(0), %st + fstpl 176(%esp) + fldl 20(%ebp) + fmul %st(0), %st + fstpl 184(%esp) + jmp ..B1.62 + .align 16,0x90 + .type catanh,@function + .size catanh,.-catanh + .data +# -- End catanh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0xc0,0xf5,0x28,0x5c,0x8f,0xc2,0xf5,0xf9,0x3f,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,12 + .space 4, 0x00 # pad + .align 16 +_DBL_NZERO: + .long 0 + .long -2147483648 + .type _DBL_NZERO,@object + .size _DBL_NZERO,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PZERO: + .long 0 + .long 0 + .type _DBL_PZERO,@object + .size _DBL_PZERO,8 + .space 8, 0x00 # pad + .align 16 +_DBL_NPIBY2: + .long 1413754136 + .long -1074191877 + .type _DBL_NPIBY2,@object + .size _DBL_NPIBY2,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PPIBY2: + .long 1413754136 + .long 1073291771 + .type _DBL_PPIBY2,@object + .size _DBL_PPIBY2,8 + .space 8, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/catanhf.S b/external/sgx_libm/ia32/catanhf.S new file mode 100644 index 0000000000..7766d9302a --- /dev/null +++ b/external/sgx_libm/ia32/catanhf.S @@ -0,0 +1,557 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catanhf.c" + .text +..TXTST0: +# -- Begin catanhf + .text + .align 16,0x90 + .globl catanhf +catanhf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $120, %esp + xorl %edi, %edi + movzwl 10(%ebp), %eax + andl $32640, %eax + shrl $7, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %eax + movl %edi, 108(%esp) + movl %edi, 112(%esp) + jge ..B1.11 +..B1.2: + testl %eax, %eax + jle ..B1.53 +..B1.3: + movzwl 14(%ebp), %edx + andl $32640, %edx + shrl $7, %edx + cmpl $255, %edx + jge ..B1.12 +..B1.4: + testl %edx, %edx + jle ..B1.52 +..B1.5: + flds 8(%ebp) + fsts 100(%esp) + fld1 + fsts 96(%esp) + fxch %st(1) + fmul %st(0), %st + fstl 32(%esp) + fsubrp %st, %st(1) + flds 12(%ebp) + fld %st(0) + fmul %st(1), %st + fstl 72(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpl 40(%esp) + fldl 40(%esp) + fabs + fldl .L_2il0floatpacket.6@GOTOFF(%ebx) + fstl 80(%esp) + fcompp + fnstsw %ax + sahf + jbe ..B1.7 +..B1.6: + flds 100(%esp) + fadds 96(%esp) + fstl 88(%esp) + fstpl 8(%esp) + fstl (%esp) + fstpl 16(%esp) + call atan2@PLT +..B1.74: + fldl 16(%esp) + fchs + fxch %st(1) + fstpl 48(%esp) + flds 96(%esp) + fsubs 100(%esp) + fstl 8(%esp) + fxch %st(1) + fstpl (%esp) + fstpl 24(%esp) + call atan2@PLT +..B1.73: + fldl 24(%esp) + fxch %st(1) + fstpl 56(%esp) + fldl 48(%esp) + fldl 56(%esp) + fsubrp %st, %st(1) + fldl .L_2il0floatpacket.7@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + fstps 112(%esp) + fxch %st(1) + jmp ..B1.8 +..B1.7: + fldl 40(%esp) + fstpl 8(%esp) + fldl .L_2il0floatpacket.8@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpl (%esp) + call atan2@PLT +..B1.75: + fldl .L_2il0floatpacket.7@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + fstps 112(%esp) + flds 100(%esp) + fld %st(0) + flds 96(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpl 88(%esp) + fsubp %st, %st(1) +..B1.8: + fldl 88(%esp) + fstpl 48(%esp) + fchs + fldl 48(%esp) + fldl 48(%esp) + fmulp %st, %st(1) + fldl 72(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpl 64(%esp) + fxch %st(1) + fstpl 56(%esp) + fldl 56(%esp) + fldl 56(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpl 40(%esp) + fldl 64(%esp) + fldl 40(%esp) + fsubrp %st, %st(1) + fabs + fldl 40(%esp) + fmull 80(%esp) + fcompp + fnstsw %ax + sahf + jae ..B1.10 + jp ..B1.10 +..B1.9: + fstp %st(0) + fldl 64(%esp) + fldl 40(%esp) + fdivrp %st, %st(1) + fstpl (%esp) + call log@PLT +..B1.76: + fmull .L_2il0floatpacket.9@GOTOFF(%ebx) + fstps 108(%esp) + jmp ..B1.46 +..B1.10: + fldl 72(%esp) + fldl .L_2il0floatpacket.8@GOTOFF(%ebx) + fmuls 100(%esp) + fxch %st(1) + faddl 32(%esp) + fadds 96(%esp) + fstpl 40(%esp) + fstpl 64(%esp) + fldl 64(%esp) + fldl 40(%esp) + fdivrp %st, %st(1) + fstpl (%esp) + fstpl 16(%esp) + call atanh@PLT +..B1.77: + fldl 16(%esp) + fmulp %st, %st(1) + fstps 108(%esp) + jmp ..B1.46 +..B1.11: + movzwl 14(%ebp), %edx + andl $32640, %edx + shrl $7, %edx +..B1.12: + cmpl $255, %eax + je ..B1.62 +..B1.13: + cmpl $255, %edx + je ..B1.57 +..B1.14: + cmpl $255, %edx + jge ..B1.39 +..B1.15: + testl %eax, %eax + jle ..B1.56 +..B1.16: + cmpl $127, %eax + jge ..B1.20 +..B1.17: + addl $4, %esp + pushl 8(%ebp) + call atanhf@PLT +..B1.78: + movzbl 15(%ebp), %eax + testl $128, %eax + fstps 108(%esp) + je ..B1.19 +..B1.18: + movl $-2147483648, 112(%esp) + jmp ..B1.46 +..B1.19: + movl %edi, 112(%esp) + jmp ..B1.46 +..B1.20: + je ..B1.55 +..B1.21: + cmpl $255, %eax + jge ..B1.29 +..B1.22: + flds 8(%ebp) + fld %st(0) + fld %st(1) + fld1 + fadd %st, %st(2) + fxch %st(2) + fstpl 48(%esp) + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fsubr %st(2), %st + fchs + flds 12(%ebp) + fmul %st(0), %st + fldl 48(%esp) + fldl 48(%esp) + fmulp %st, %st(1) + fadd %st(1), %st + fstpl 64(%esp) + fxch %st(1) + fstpl 56(%esp) + fldl 56(%esp) + fldl 56(%esp) + fmulp %st, %st(1) + fadd %st(1), %st + fstpl 40(%esp) + fldl 64(%esp) + fldl 40(%esp) + fsubrp %st, %st(1) + fabs + fldl 40(%esp) + fmull .L_2il0floatpacket.6@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jae ..B1.24 + jp ..B1.24 +..B1.23: + fstp %st(2) + fstp %st(1) + fstp %st(0) + fstp %st(0) + fldl 64(%esp) + fldl 40(%esp) + fdivrp %st, %st(1) + fstpl (%esp) + call log@PLT +..B1.79: + fmull .L_2il0floatpacket.9@GOTOFF(%ebx) + fstps 108(%esp) + jmp ..B1.25 +..B1.24: + faddp %st, %st(1) + faddp %st, %st(1) + fstpl 40(%esp) + fldl .L_2il0floatpacket.8@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpl 64(%esp) + fldl 64(%esp) + fldl 40(%esp) + fdivrp %st, %st(1) + fstpl (%esp) + call atanh@PLT +..B1.80: + fmull .L_2il0floatpacket.7@GOTOFF(%ebx) + fstps 108(%esp) +..B1.25: + movzbl 15(%ebp), %eax + testl $128, %eax + je ..B1.27 +..B1.26: + flds .L_2il0floatpacket.10@GOTOFF(%ebx) + jmp ..B1.28 +..B1.27: + flds .L_2il0floatpacket.11@GOTOFF(%ebx) +..B1.28: + flds .L_2il0floatpacket.14@GOTOFF(%ebx) + fxch %st(1) + fsts 112(%esp) + faddp %st, %st(1) + fstps 104(%esp) + jmp ..B1.46 +..B1.29: + testl %edx, %edx + jne ..B1.32 +..B1.30: + testl $8388607, 12(%ebp) + je ..B1.32 +..B1.31: + flds .L_2il0floatpacket.12@GOTOFF(%ebx) + fadds 12(%ebp) + fstps 104(%esp) +..B1.32: + movzbl 11(%ebp), %eax + testl $128, %eax + je ..B1.34 +..B1.33: + movl $-2147483648, 108(%esp) + jmp ..B1.35 +..B1.34: + movl %edi, 108(%esp) +..B1.35: + movzbl 15(%ebp), %eax + testl $128, %eax + je ..B1.37 +..B1.36: + flds .L_2il0floatpacket.10@GOTOFF(%ebx) + jmp ..B1.38 +..B1.37: + flds .L_2il0floatpacket.11@GOTOFF(%ebx) +..B1.38: + flds .L_2il0floatpacket.14@GOTOFF(%ebx) + fxch %st(1) + fsts 112(%esp) + faddp %st, %st(1) + fstps 104(%esp) + jmp ..B1.46 +..B1.39: + testl %eax, %eax + jne ..B1.42 +..B1.40: + testl $8388607, 8(%ebp) + je ..B1.42 +..B1.41: + flds .L_2il0floatpacket.12@GOTOFF(%ebx) + fadds 8(%ebp) + fstps 104(%esp) +..B1.42: + movzbl 11(%ebp), %eax + testl $128, %eax + je ..B1.44 +..B1.43: + movl $-2147483648, 108(%esp) + jmp ..B1.45 +..B1.44: + movl %edi, 108(%esp) +..B1.45: + movl 12(%ebp), %eax + movl %eax, (%esp) + call atanf@PLT +..B1.81: + fstps 112(%esp) +..B1.46: + movzwl 110(%esp), %eax + testl $32640, %eax + jne ..B1.48 +..B1.47: + testl $8388607, 108(%esp) + jne ..B1.50 +..B1.48: + movzwl 114(%esp), %eax + testl $32640, %eax + jne ..B1.51 +..B1.49: + testl $8388607, 112(%esp) + je ..B1.51 +..B1.50: + flds .L_2il0floatpacket.14@GOTOFF(%ebx) + fmul %st(0), %st + fstps 104(%esp) +..B1.51: + movl 108(%esp), %eax + movl 112(%esp), %edx + addl $120, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.52: + testl $8388607, 12(%ebp) + jne ..B1.5 + jmp ..B1.12 +..B1.53: + testl $8388607, 8(%ebp) + jne ..B1.3 + jmp ..B1.11 +..B1.55: + testl $8388607, 8(%ebp) + je ..B1.17 + jmp ..B1.21 +..B1.56: + testl $8388607, 8(%ebp) + jne ..B1.16 + jmp ..B1.39 +..B1.57: + testl $8388607, 12(%ebp) + je ..B1.14 +..B1.58: + cmpl $255, %eax + jge ..B1.14 +..B1.59: + testl %eax, %eax + jle ..B1.61 +..B1.60: + flds 12(%ebp) + fmul %st(0), %st + fsts 108(%esp) + fstps 112(%esp) + jmp ..B1.46 +..B1.61: + testl $8388607, 8(%ebp) + jne ..B1.60 + jmp ..B1.14 +..B1.62: + testl $8388607, 8(%ebp) + je ..B1.13 +..B1.63: + flds 8(%ebp) + cmpl $255, %edx + fmul %st(0), %st + jge ..B1.65 +..B1.64: + fsts 8(%ebp) + fmul %st(0), %st + fsts 108(%esp) + fstps 112(%esp) + jmp ..B1.46 +..B1.65: + testl $8388607, 12(%ebp) + jne ..B1.70 +..B1.66: + fmul %st(0), %st + movzbl 15(%ebp), %eax + testl $128, %eax + fstps 8(%ebp) + movl %edi, 108(%esp) + je ..B1.68 +..B1.67: + flds .L_2il0floatpacket.10@GOTOFF(%ebx) + jmp ..B1.69 +..B1.68: + flds .L_2il0floatpacket.11@GOTOFF(%ebx) +..B1.69: + flds .L_2il0floatpacket.14@GOTOFF(%ebx) + fxch %st(1) + fsts 112(%esp) + faddp %st, %st(1) + fstps 104(%esp) + jmp ..B1.46 +..B1.70: + fsts 8(%ebp) + fmul %st(0), %st + fstps 108(%esp) + flds 12(%ebp) + fmul %st(0), %st + fstps 112(%esp) + jmp ..B1.46 + .align 16,0x90 + .type catanhf,@function + .size catanhf,.-catanhf + .data +# -- End catanhf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.6: + .long 0xe0000000,0x3f9eb851 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3fd00000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 4 +.L_2il0floatpacket.10: + .long 0xbfc90fdb + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .align 4 +.L_2il0floatpacket.11: + .long 0x3fc90fdb + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,4 + .align 4 +.L_2il0floatpacket.12: + .long 0x3f000000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .align 4 +.L_2il0floatpacket.13: + .long 0x80000000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,4 + .align 4 +.L_2il0floatpacket.14: + .long 0x00800000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/catanhl.S b/external/sgx_libm/ia32/catanhl.S new file mode 100644 index 0000000000..af73cb76de --- /dev/null +++ b/external/sgx_libm/ia32/catanhl.S @@ -0,0 +1,2875 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catanhl.c" + .text +..TXTST0: +# -- Begin catanhl + .text + .align 16,0x90 + .globl catanhl +catanhl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.17@GOTOFF(%ebx) + movl %edx, 28(%esp) + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) +..B1.2: + fnstcw 2(%esp) +..B1.3: + movzwl 2(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.54 +..B1.4: + orl $-64768, %ecx + movw %cx, (%esp) +..B1.5: + fldcw (%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.14 +..B1.8: + testl %ecx, %ecx + jle ..B1.34 +..B1.9: + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.15 +..B1.10: + testl %edx, %edx + jle ..B1.32 +..B1.11: + fldt 12(%ebp) + addl $-32, %esp + fstpt (%esp) + fldt 24(%ebp) + fstpt 12(%esp) + call recatanhl +..B1.57: + addl $32, %esp +..B1.12: + fldt 24(%ebp) + fxch %st(1) + fstpt 4(%esp) + addl $-32, %esp + fldt 12(%ebp) + fstpt (%esp) + fstpt 12(%esp) + call imcatanhl +..B1.58: + addl $32, %esp +..B1.13: + fstpt 16(%esp) + jmp ..B1.28 +..B1.14: + movzwl 32(%ebp), %edx + andl $32767, %edx +..B1.15: + cmpl $32767, %ecx + je ..B1.46 +..B1.16: + cmpl $32767, %edx + je ..B1.40 +..B1.17: + cmpl $32767, %edx + jge ..B1.27 +..B1.18: + movl 16(%ebp), %edx + testl %edx, %edx + jne ..B1.20 +..B1.19: + cmpl $0, 12(%ebp) + je ..B1.27 +..B1.20: + cmpl $16383, %ecx + jge ..B1.22 +..B1.21: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call atanhl@PLT +..B1.59: + fldt 48+_CONSTANTS@GOTOFF(%ebx) + addl $16, %esp + movzbl 33(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + fxch %st(1) + fstpt 4(%esp) + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + fmulp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.28 +..B1.22: + je ..B1.37 +..B1.23: + cmpl $32767, %ecx + jl ..B1.25 +..B1.24: + fldt 48+_CONSTANTS@GOTOFF(%ebx) + movzbl 21(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + movzbl 33(%ebp), %ecx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + andl $128, %ecx + fmulp %st, %st(1) + shrl $7, %ecx + fstpt 4(%esp) + addl $-16, %esp + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + fstpt (%esp) + call asinl@PLT + jmp ..B1.63 +..B1.25: + fldt 12(%ebp) + addl $-32, %esp + fstpt (%esp) + fldt 24(%ebp) + fstpt 12(%esp) + call recatanhl +..B1.61: + addl $32, %esp +..B1.26: + movzbl 33(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + fstpt 4(%esp) + addl $-16, %esp + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + fstpt (%esp) + call asinl@PLT + jmp ..B1.63 +..B1.27: + fldt 48+_CONSTANTS@GOTOFF(%ebx) + fldt 24(%ebp) + movzbl 21(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 4(%esp) + addl $-16, %esp + fstpt (%esp) + call atanl@PLT +..B1.63: + addl $16, %esp + fstpt 16(%esp) +..B1.28: + testl %edi, %edi + je ..B1.30 +..B1.29: + fldcw 2(%esp) +..B1.30: + movl 4(%esp), %edx + movl %edx, (%esi) + movl 16(%esp), %edx + movl %edx, 12(%esi) + movl 20(%esp), %edx + movl %edx, 16(%esi) + movl 8(%esp), %ecx + movl 12(%esp), %edi + movl 24(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 28(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.39 +..B1.31: + movl %esi, %eax + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.32: + cmpl $0, 28(%ebp) + jne ..B1.11 +..B1.33: + cmpl $0, 24(%ebp) + jne ..B1.11 + jmp ..B1.15 +..B1.34: + cmpl $0, 16(%ebp) + jne ..B1.9 +..B1.35: + cmpl $0, 12(%ebp) + jne ..B1.9 + jmp ..B1.14 +..B1.37: + cmpl $-2147483648, %edx + jne ..B1.23 +..B1.38: + cmpl $0, 12(%ebp) + je ..B1.21 + jmp ..B1.23 +..B1.39: + call __stack_chk_fail@PLT +..B1.40: + cmpl $-2147483648, 28(%ebp) + jne ..B1.42 +..B1.41: + cmpl $0, 24(%ebp) + je ..B1.17 +..B1.42: + cmpl $32767, %ecx + jge ..B1.17 +..B1.43: + cmpl $0, 16(%ebp) + jne ..B1.45 +..B1.44: + cmpl $0, 12(%ebp) + je ..B1.17 +..B1.45: + fldt 24(%ebp) + fmul %st(0), %st + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) + jmp ..B1.28 +..B1.46: + cmpl $-2147483648, 16(%ebp) + jne ..B1.48 +..B1.47: + cmpl $0, 12(%ebp) + je ..B1.16 +..B1.48: + cmpl $32767, %edx + jge ..B1.50 +..B1.49: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) + jmp ..B1.28 +..B1.50: + cmpl $-2147483648, 28(%ebp) + jne ..B1.53 +..B1.51: + cmpl $0, 24(%ebp) + jne ..B1.53 +..B1.52: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 12(%ebp) + fldt 48+_CONSTANTS@GOTOFF(%ebx) + fstpt 4(%esp) + addl $-16, %esp + fldt 24(%ebp) + fstpt (%esp) + call atanl@PLT + jmp ..B1.63 +..B1.53: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 4(%esp) + fldt 24(%ebp) + fmul %st(0), %st + fstpt 16(%esp) + jmp ..B1.28 +..B1.54: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type catanhl,@function + .size catanhl,.-catanhl + .data +# -- End catanhl + .text +# -- Begin recatanhl + .text + .align 16,0x90 +recatanhl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $436, %esp + fldt 8(%ebp) + call ..L4 +..L4: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%edx), %edx + movl %edx, 76(%esp) + movl %gs:20, %eax + fldt 48+_CONSTANTS@GOTOFF(%edx) + xorl %esp, %eax + movl %eax, 388(%esp) + movl $0, 160(%esp) + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + fstpt 136(%esp) + fstpt 148(%esp) + addl $4, %esp + lea 132(%esp), %ecx + pushl %ecx + call __libm_normalizel_k80 +..B2.2: + fldt 20(%ebp) + movl $0, 188(%esp) + fstpt 164(%esp) + fldt 32(%esp) + fstpt 176(%esp) + addl $4, %esp + lea 160(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.3: + fldt 32(%esp) + xorl %esi, %esi + movl 76(%esp), %eax + movzwl 144(%esp), %ecx + movl %ecx, %ebx + andl $32767, %ebx + movl %esi, 216(%esp) + cmpl $8383, %ebx + fstpt 204(%esp) + fldt _CONSTANTS@GOTOFF(%eax) + fstpt 192(%esp) + jl ..B2.7 +..B2.4: + cmpl $24383, %ebx + jg ..B2.7 +..B2.5: + movzwl 200(%esp), %edx + movl %edx, 44(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B2.7 +..B2.6: + cmpl $24383, %edx + jle ..B2.10 +..B2.7: + addl $4, %esp + lea 132(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.8: + addl $4, %esp + lea 188(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.9: + movzwl 144(%esp), %ecx + movl %ecx, %ebx + movzwl 200(%esp), %edx + andl $32767, %ebx + movl 216(%esp), %esi + movl %edx, 44(%esp) + andl $32767, %edx +..B2.10: + movl 160(%esp), %eax + movl %eax, 48(%esp) + lea (%ebx,%eax), %edi + movl %edi, 32(%esp) + lea -134(%esi,%edx), %eax + cmpl %eax, %edi + jle ..B2.27 +..B2.11: + movl 140(%esp), %eax + lea 134(%esi,%edx), %edi + cmpl 32(%esp), %edi + jle ..B2.28 +..B2.12: + testl %eax, %eax + jne ..B2.14 +..B2.13: + cmpl $0, 136(%esp) + je ..B2.29 +..B2.14: + cmpl $0, 196(%esp) + jne ..B2.16 +..B2.15: + cmpl $0, 192(%esp) + je ..B2.28 +..B2.16: + cmpl 48(%esp), %esi + je ..B2.18 +..B2.17: + fldt 136(%esp) + fldt 148(%esp) + movl 48(%esp), %eax + subl %esi, %eax + andb $127, 41(%esp) + addl $16383, %eax + movzwl 40(%esp), %edx + andl $32767, %eax + andl $-32768, %edx + orl %eax, %edx + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %esi, 160(%esp) + fxch %st(2) + fstpt 136(%esp) + fldt 136(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 148(%esp) + fldt 148(%esp) + movzwl 144(%esp), %ecx + jmp ..B2.19 +..B2.18: + fldt 136(%esp) + fldt 148(%esp) +..B2.19: + fldt 192(%esp) + andl $32767, %ecx + movl 44(%esp), %eax + fld %st(2) + andl $32767, %eax + fadd %st(1), %st + movl %esi, 244(%esp) + cmpl %eax, %ecx + jg ..B2.24 +..B2.20: + jne ..B2.25 +..B2.21: + movl 140(%esp), %eax + movl 196(%esp), %edx + cmpl %edx, %eax + ja ..B2.24 +..B2.22: + jne ..B2.25 +..B2.23: + movl 136(%esp), %eax + cmpl 192(%esp), %eax + jbe ..B2.25 +..B2.24: + fldt 204(%esp) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + jmp ..B2.26 +..B2.25: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 204(%esp) + faddp %st, %st(2) +..B2.26: + fld %st(1) + fadd %st(1), %st + fstpt 220(%esp) + fldt 220(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 232(%esp) + jmp ..B2.33 +..B2.27: + movl 140(%esp), %eax +..B2.28: + testl %eax, %eax + jne ..B2.30 +..B2.162: + cmpl $0, 136(%esp) +..B2.29: + je ..B2.31 +..B2.30: + lea -16517(%esi,%edx), %ecx + movl 48(%esp), %edx + lea -16383(%edx,%ebx), %ebx + cmpl %ebx, %ecx + jl ..B2.32 +..B2.31: + movl 192(%esp), %eax + movl %eax, 220(%esp) + movl 196(%esp), %edx + movl 200(%esp), %ecx + movl 204(%esp), %ebx + movl 208(%esp), %esi + movl 212(%esp), %edi + movl 216(%esp), %eax + movl %edx, 224(%esp) + movl %ecx, 228(%esp) + movl %ebx, 232(%esp) + movl %esi, 236(%esp) + movl %edi, 240(%esp) + movl %eax, 244(%esp) + jmp ..B2.33 +..B2.32: + movl %eax, 224(%esp) + movl 136(%esp), %edx + movl 144(%esp), %eax + movl 148(%esp), %ecx + movl 152(%esp), %ebx + movl 156(%esp), %esi + movl 48(%esp), %edi + movl %edx, 220(%esp) + movl %eax, 228(%esp) + movl %ecx, 232(%esp) + movl %ebx, 236(%esp) + movl %esi, 240(%esp) + movl %edi, 244(%esp) +..B2.33: + movzwl 228(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.35 +..B2.34: + cmpl $24383, %eax + jle ..B2.37 +..B2.35: + addl $4, %esp + lea 216(%esp), %ebx + pushl %ebx + call __libm_normalizel_k80 +..B2.36: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B2.37: + fldt 220(%esp) + movl 76(%esp), %edx + fld %st(0) + fld %st(1) + fld %st(2) + fldt 232(%esp) + fmulp %st, %st(4) + movl 244(%esp), %eax + fxch %st(3) + fadd %st(0), %st + fldt 60+_CONSTANTS@GOTOFF(%edx) + addl %eax, %eax + fmul %st, %st(3) + movl %eax, 272(%esp) + fxch %st(2) + fsub %st(3), %st + movzwl 172(%esp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(4) + fmul %st(4), %st + cmpl $8383, %eax + fadd %st(0), %st + fxch %st(2) + fstpt 48(%esp) + fxch %st(3) + fmul %st(0), %st + fld %st(1) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 248(%esp) + fldt 248(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 260(%esp) + jl ..B2.39 +..B2.38: + cmpl $24383, %eax + jle ..B2.41 +..B2.39: + addl $4, %esp + lea 160(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.40: + addl $4, %esp + lea 160(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.41: + fldt 164(%esp) + fld %st(0) + fld %st(1) + fldt 48(%esp) + fldt 176(%esp) + fmul %st(4), %st + movzwl 256(%esp), %ecx + movl %ecx, %ebx + andl $32767, %ebx + fadd %st(0), %st + fxch %st(4) + fmulp %st, %st(1) + movl 188(%esp), %esi + fsubr %st, %st(2) + addl %esi, %esi + faddp %st, %st(2) + fld %st(1) + cmpl $8383, %ebx + fmul %st(2), %st + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(2) + movl %esi, 300(%esp) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsub %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(1) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 276(%esp) + fldt 276(%esp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 288(%esp) + fstpt 64(%esp) + jl ..B2.45 +..B2.42: + cmpl $24383, %ebx + jg ..B2.45 +..B2.43: + movzwl 284(%esp), %edx + movl %edx, 44(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B2.45 +..B2.44: + cmpl $24383, %edx + jle ..B2.48 +..B2.45: + addl $4, %esp + lea 244(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.46: + addl $4, %esp + lea 272(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.47: + movzwl 256(%esp), %ecx + movl %ecx, %ebx + movzwl 284(%esp), %edx + andl $32767, %ebx + movl 300(%esp), %esi + movl %edx, 44(%esp) + andl $32767, %edx +..B2.48: + movl 272(%esp), %eax + movl %eax, 80(%esp) + lea (%ebx,%eax), %edi + movl %edi, 60(%esp) + lea -134(%esi,%edx), %eax + cmpl %eax, %edi + jle ..B2.65 +..B2.49: + movl 252(%esp), %eax + lea 134(%esi,%edx), %edi + cmpl 60(%esp), %edi + jle ..B2.66 +..B2.50: + testl %eax, %eax + jne ..B2.52 +..B2.51: + cmpl $0, 248(%esp) + je ..B2.67 +..B2.52: + cmpl $0, 280(%esp) + jne ..B2.54 +..B2.53: + cmpl $0, 276(%esp) + je ..B2.66 +..B2.54: + cmpl 80(%esp), %esi + je ..B2.56 +..B2.55: + fldt 64(%esp) + movl 80(%esp), %eax + fstpt 32(%esp) + subl %esi, %eax + fldt 248(%esp) + addl $16383, %eax + fldt 260(%esp) + andl $32767, %eax + andb $127, 41(%esp) + movzwl 40(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %esi, 272(%esp) + fxch %st(2) + fstpt 248(%esp) + fldt 248(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 260(%esp) + fldt 260(%esp) + fxch %st(1) + fstpt 64(%esp) + movzwl 256(%esp), %ecx + jmp ..B2.57 +..B2.56: + fldt 248(%esp) + fstpt 64(%esp) + fldt 260(%esp) +..B2.57: + fldt 276(%esp) + andl $32767, %ecx + fldt 64(%esp) + movl 44(%esp), %eax + andl $32767, %eax + fadd %st(1), %st + movl %esi, 328(%esp) + cmpl %eax, %ecx + jg ..B2.62 +..B2.58: + jne ..B2.63 +..B2.59: + movl 252(%esp), %eax + movl 280(%esp), %edx + cmpl %edx, %eax + ja ..B2.62 +..B2.60: + jne ..B2.63 +..B2.61: + movl 248(%esp), %eax + cmpl 276(%esp), %eax + jbe ..B2.63 +..B2.62: + fldt 64(%esp) + fsub %st(1), %st + faddp %st, %st(2) + fldt 288(%esp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 64(%esp) + jmp ..B2.64 +..B2.63: + fldt 64(%esp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 288(%esp) + faddp %st, %st(1) + fstpt 64(%esp) +..B2.64: + fldt 64(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 304(%esp) + fldt 304(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 316(%esp) + jmp ..B2.71 +..B2.65: + movl 252(%esp), %eax +..B2.66: + testl %eax, %eax + jne ..B2.68 +..B2.164: + cmpl $0, 248(%esp) +..B2.67: + je ..B2.69 +..B2.68: + lea -16517(%esi,%edx), %ecx + movl 80(%esp), %edx + lea -16383(%edx,%ebx), %ebx + cmpl %ebx, %ecx + jl ..B2.70 +..B2.69: + movl 276(%esp), %eax + movl %eax, 304(%esp) + movl 280(%esp), %edx + movl 284(%esp), %ecx + movl 288(%esp), %ebx + movl 292(%esp), %esi + movl 296(%esp), %edi + movl 300(%esp), %eax + movl %edx, 308(%esp) + movl %ecx, 312(%esp) + movl %ebx, 316(%esp) + movl %esi, 320(%esp) + movl %edi, 324(%esp) + movl %eax, 328(%esp) + jmp ..B2.71 +..B2.70: + movl %eax, 308(%esp) + movl 248(%esp), %edx + movl 256(%esp), %eax + movl 260(%esp), %ecx + movl 264(%esp), %ebx + movl 268(%esp), %esi + movl 80(%esp), %edi + movl %edx, 304(%esp) + movl %eax, 312(%esp) + movl %ecx, 316(%esp) + movl %ebx, 320(%esp) + movl %esi, 324(%esp) + movl %edi, 328(%esp) +..B2.71: + movzwl 144(%esp), %ebx + movl %ebx, %esi + andl $32767, %esi + cmpl $8383, %esi + jl ..B2.75 +..B2.72: + cmpl $24383, %esi + jg ..B2.75 +..B2.73: + movzwl 200(%esp), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B2.75 +..B2.74: + cmpl $24383, %ecx + jle ..B2.78 +..B2.75: + addl $4, %esp + lea 132(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.76: + addl $4, %esp + lea 188(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.77: + movzwl 144(%esp), %ebx + movl %ebx, %esi + movzwl 200(%esp), %ecx + andl $32767, %esi + movl %ecx, 44(%esp) + andl $32767, %ecx +..B2.78: + movl 160(%esp), %eax + movl 216(%esp), %edx + movl %eax, 80(%esp) + lea (%esi,%eax), %edi + movl %edi, 60(%esp) + lea -134(%edx,%ecx), %eax + cmpl %eax, %edi + jle ..B2.95 +..B2.79: + movl 140(%esp), %eax + lea 134(%edx,%ecx), %edi + cmpl 60(%esp), %edi + jle ..B2.96 +..B2.80: + testl %eax, %eax + jne ..B2.82 +..B2.81: + cmpl $0, 136(%esp) + je ..B2.97 +..B2.82: + cmpl $0, 196(%esp) + jne ..B2.84 +..B2.83: + cmpl $0, 192(%esp) + je ..B2.96 +..B2.84: + cmpl 80(%esp), %edx + je ..B2.86 +..B2.85: + fldt 64(%esp) + movl 80(%esp), %eax + fstpt 32(%esp) + subl %edx, %eax + fldt 136(%esp) + addl $16383, %eax + fldt 148(%esp) + andl $32767, %eax + andb $127, 41(%esp) + movzwl 40(%esp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 160(%esp) + fxch %st(2) + fstpt 136(%esp) + fldt 136(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 148(%esp) + fldt 148(%esp) + movzwl 144(%esp), %ebx + jmp ..B2.87 +..B2.86: + fldt 136(%esp) + fldt 148(%esp) +..B2.87: + fldt 192(%esp) + andl $32767, %ebx + movl 44(%esp), %eax + fld %st(2) + andl $32767, %eax + fsub %st(1), %st + movl %edx, 244(%esp) + cmpl %eax, %ebx + jg ..B2.92 +..B2.88: + jne ..B2.93 +..B2.89: + movl 140(%esp), %eax + movl 196(%esp), %edx + cmpl %edx, %eax + ja ..B2.92 +..B2.90: + jne ..B2.93 +..B2.91: + movl 136(%esp), %eax + cmpl 192(%esp), %eax + jbe ..B2.93 +..B2.92: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 204(%esp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + jmp ..B2.94 +..B2.93: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 204(%esp) + fsubrp %st, %st(2) +..B2.94: + fld %st(1) + fadd %st(1), %st + fstpt 220(%esp) + fldt 220(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 232(%esp) + jmp ..B2.101 +..B2.95: + movl 140(%esp), %eax +..B2.96: + testl %eax, %eax + jne ..B2.98 +..B2.161: + cmpl $0, 136(%esp) +..B2.97: + je ..B2.99 +..B2.98: + lea -16517(%edx,%ecx), %ebx + movl 80(%esp), %ecx + lea -16383(%ecx,%esi), %esi + cmpl %esi, %ebx + jl ..B2.100 +..B2.99: + fldt 192(%esp) + fchs + movl %edx, 244(%esp) + fstpt 220(%esp) + fldt 204(%esp) + fchs + fstpt 232(%esp) + jmp ..B2.101 +..B2.100: + movl %eax, 224(%esp) + movl 136(%esp), %edx + movl 144(%esp), %eax + movl 148(%esp), %ecx + movl 152(%esp), %ebx + movl 156(%esp), %esi + movl 80(%esp), %edi + movl %edx, 220(%esp) + movl %eax, 228(%esp) + movl %ecx, 232(%esp) + movl %ebx, 236(%esp) + movl %esi, 240(%esp) + movl %edi, 244(%esp) +..B2.101: + movzwl 228(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.103 +..B2.102: + cmpl $24383, %eax + jle ..B2.105 +..B2.103: + addl $4, %esp + lea 216(%esp), %ebx + pushl %ebx + call __libm_normalizel_k80 +..B2.104: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B2.105: + fldt 220(%esp) + fld %st(0) + fld %st(1) + fldt 48(%esp) + fldt 232(%esp) + fxch %st(1) + fmul %st(4), %st + movl 244(%esp), %ebx + fsubr %st, %st(3) + addl %ebx, %ebx + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(3) + movl %ebx, 272(%esp) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(1) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 248(%esp) + fldt 248(%esp) + fsubrp %st, %st(2) + movzwl 256(%esp), %ecx + fadd %st, %st(1) + movl %ecx, 84(%esp) + andl $32767, %ecx + fxch %st(1) + fstpt 260(%esp) + cmpl $8383, %ecx + fstpt 64(%esp) + jl ..B2.109 +..B2.106: + cmpl $24383, %ecx + jg ..B2.109 +..B2.107: + movzwl 284(%esp), %eax + movl %eax, 60(%esp) + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.109 +..B2.108: + cmpl $24383, %eax + jle ..B2.112 +..B2.109: + addl $4, %esp + lea 244(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.110: + addl $4, %esp + lea 272(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.111: + movzwl 256(%esp), %ecx + movzwl 284(%esp), %eax + movl 272(%esp), %ebx + movl %ecx, 84(%esp) + andl $32767, %ecx + movl %eax, 60(%esp) + andl $32767, %eax +..B2.112: + movl 300(%esp), %edx + lea (%ebx,%ecx), %esi + movl %esi, 80(%esp) + lea -134(%edx,%eax), %edi + cmpl %edi, %esi + jle ..B2.129 +..B2.113: + movl 252(%esp), %esi + lea 134(%edx,%eax), %edi + movl %esi, 44(%esp) + cmpl 80(%esp), %edi + jle ..B2.130 +..B2.114: + cmpl $0, 44(%esp) + jne ..B2.116 +..B2.115: + cmpl $0, 248(%esp) + je ..B2.131 +..B2.116: + cmpl $0, 280(%esp) + jne ..B2.118 +..B2.117: + cmpl $0, 276(%esp) + je ..B2.130 +..B2.118: + cmpl %edx, %ebx + je ..B2.120 +..B2.119: + fldt 64(%esp) + subl %edx, %ebx + fstpt 32(%esp) + addl $16383, %ebx + fldt 248(%esp) + andl $32767, %ebx + fldt 260(%esp) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %ebx, %eax + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 272(%esp) + fxch %st(2) + fstpt 248(%esp) + fldt 248(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 260(%esp) + fldt 260(%esp) + movzwl 256(%esp), %ecx + movl %ecx, 84(%esp) + jmp ..B2.121 +..B2.120: + fldt 248(%esp) + fldt 260(%esp) +..B2.121: + fldt 276(%esp) + fld %st(2) + movl 84(%esp), %eax + fadd %st(1), %st + movl 60(%esp), %ecx + andl $32767, %eax + andl $32767, %ecx + movl %edx, 356(%esp) + cmpl %ecx, %eax + jg ..B2.126 +..B2.122: + jne ..B2.127 +..B2.123: + movl 252(%esp), %eax + movl 280(%esp), %ecx + cmpl %ecx, %eax + ja ..B2.126 +..B2.124: + jne ..B2.127 +..B2.125: + movl 248(%esp), %eax + cmpl 276(%esp), %eax + jbe ..B2.127 +..B2.126: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 288(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.128 +..B2.127: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 288(%esp) + faddp %st, %st(1) +..B2.128: + fld %st(0) + fadd %st(2), %st + fstpt 332(%esp) + fldt 332(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 344(%esp) + jmp ..B2.135 +..B2.129: + movl 252(%esp), %esi + movl %esi, 44(%esp) +..B2.130: + cmpl $0, 44(%esp) + jne ..B2.132 +..B2.163: + cmpl $0, 248(%esp) +..B2.131: + je ..B2.133 +..B2.132: + lea -16517(%edx,%eax), %eax + lea -16383(%ebx,%ecx), %ecx + cmpl %ecx, %eax + jl ..B2.134 +..B2.133: + movl 276(%esp), %eax + movl %eax, 332(%esp) + movl 280(%esp), %ecx + movl 284(%esp), %ebx + movl 288(%esp), %esi + movl 292(%esp), %edi + movl 296(%esp), %eax + movl %ecx, 336(%esp) + movl %ebx, 340(%esp) + movl %esi, 344(%esp) + movl %edi, 348(%esp) + movl %eax, 352(%esp) + movl %edx, 356(%esp) + jmp ..B2.135 +..B2.134: + movl %esi, %edx + movl %edx, 336(%esp) + movl 248(%esp), %eax + movl 256(%esp), %ecx + movl 260(%esp), %ebx + movl 264(%esp), %esi + movl 268(%esp), %edi + movl 272(%esp), %edx + movl %eax, 332(%esp) + movl %ecx, 340(%esp) + movl %ebx, 344(%esp) + movl %esi, 348(%esp) + movl %edi, 352(%esp) + movl %edx, 356(%esp) +..B2.135: + movzwl 312(%esp), %esi + movzwl 340(%esp), %eax + andl $32767, %esi + andl $32767, %eax + movl 328(%esp), %edi + lea (%edi,%esi), %ebx + lea (%edx,%eax), %ecx + subl %ecx, %ebx + cmpl $-1, %ebx + jge ..B2.145 +..B2.136: + cmpl $8383, %esi + jl ..B2.140 +..B2.137: + cmpl $24383, %esi + jg ..B2.140 +..B2.138: + cmpl $8383, %eax + jl ..B2.140 +..B2.139: + cmpl $24383, %eax + jle ..B2.143 +..B2.140: + addl $4, %esp + lea 300(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.141: + addl $4, %esp + lea 328(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.142: + movl 328(%esp), %edi + movl 356(%esp), %edx +..B2.143: + fldt 332(%esp) + subl %edx, %edi + fld %st(0) + fld %st(1) + fldt 304(%esp) + fld %st(0) + fdiv %st(4), %st + fldt 48(%esp) + fld %st(0) + fmul %st(2), %st + fld %st(0) + movl %edi, 104(%esp) + fsubr %st(3), %st + faddp %st, %st(1) + fld %st(0) + fsubr %st(3), %st + fxch %st(2) + fmul %st(7), %st + fsubr %st, %st(6) + faddp %st, %st(6) + fxch %st(4) + fsub %st(5), %st + fld %st(4) + fmul %st(6), %st + fxch %st(2) + fmul %st, %st(6) + fxch %st(1) + fmul %st, %st(5) + fxch %st(6) + faddp %st, %st(5) + fld %st(4) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fsubp %st, %st(1) + fldt 316(%esp) + faddp %st, %st(1) + fldt 344(%esp) + fmul %st(2), %st + fsubrp %st, %st(1) + fdivp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 80(%esp) + fldt 80(%esp) + fsubrp %st, %st(1) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + faddp %st, %st(1) + fstpt 92(%esp) + addl $8, %esp + lea 72(%esp), %eax + lea 352(%esp), %edx + pushl %eax + pushl %edx + call __libm_log_k80 + jmp ..B2.153 +..B2.145: + movzwl 144(%esp), %ecx + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B2.149 +..B2.146: + cmpl $24383, %ecx + jg ..B2.149 +..B2.147: + cmpl $8383, %eax + jl ..B2.149 +..B2.148: + cmpl $24383, %eax + jle ..B2.152 +..B2.149: + addl $4, %esp + lea 132(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.150: + addl $4, %esp + lea 328(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.151: + movl 356(%esp), %edx +..B2.152: + fldt 136(%esp) + fld %st(0) + fldt 332(%esp) + fdivr %st, %st(1) + fld %st(0) + fld %st(1) + fldt 48(%esp) + fld %st(0) + fmul %st(5), %st + fld %st(0) + movl 160(%esp), %eax + fsubr %st(6), %st + subl %edx, %eax + faddp %st, %st(1) + fld %st(0) + addl $2, %eax + movl %eax, 132(%esp) + fsubr %st(6), %st + fxch %st(2) + fmul %st(5), %st + fsubr %st, %st(4) + faddp %st, %st(4) + fxch %st(2) + fsub %st(3), %st + fld %st(2) + fmul %st(4), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fsubrp %st, %st(3) + fldt 148(%esp) + faddp %st, %st(3) + fldt 344(%esp) + fmul %st(2), %st + fsubrp %st, %st(3) + fdivrp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 108(%esp) + fldt 108(%esp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 120(%esp) + fstpt 32(%esp) + addl $8, %esp + lea 100(%esp), %edx + lea 352(%esp), %ecx + pushl %edx + pushl %ecx + call __libm_log1p_k80 +..B2.153: + movl 384(%esp), %eax + addl $-2, %eax + movl %eax, 384(%esp) +..B2.154: + fldt 360(%esp) + fstpt (%esp) + fldt 372(%esp) + fstpt 12(%esp) + movl %eax, 24(%esp) + call __libm_scalbl_k80 +..B2.155: + movl 388(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.157 +..B2.156: + addl $436, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.157: + fstp %st(0) + movl 76(%esp), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type recatanhl,@function + .size recatanhl,.-recatanhl + .data +# -- End recatanhl + .text +# -- Begin imcatanhl + .text + .align 16,0x90 +imcatanhl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B3.1: +..L5: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $436, %esp + fldt 8(%ebp) + movzbl 17(%ebp), %esi + andl $128, %esi + call ..L6 +..L6: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L6](%eax), %eax + shrl $7, %esi + movl %eax, 88(%esp) + fldt 48+_CONSTANTS@GOTOFF(%eax) + movl %gs:20, %edx + xorl %esp, %edx + lea (,%esi,8), %ebx + movl %edx, 428(%esp) + lea (%ebx,%esi,4), %edi + fldt _CONSTANTS@GOTOFF(%eax,%edi) + movzbl 29(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fmulp %st, %st(2) + movl $0, 256(%esp) + lea (,%edx,8), %ecx + fxch %st(1) + fstpt 232(%esp) + lea (%ecx,%edx,4), %ecx + fstpt 32(%esp) + fldt 32(%esp) + fstpt 244(%esp) + fldt 24+_CONSTANTS@GOTOFF(%eax,%ecx) + fstpt 48(%esp) + addl $4, %esp + lea 228(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.2: + fldt 20(%ebp) + fldt 32(%esp) + movzbl 29(%ebp), %edx + andl $128, %edx + shrl $7, %edx + movl 88(%esp), %ecx + movl $0, 284(%esp) + fstpt 272(%esp) + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ebx + fldt _CONSTANTS@GOTOFF(%ecx,%ebx) + fmulp %st, %st(1) + fstpt 260(%esp) + addl $4, %esp + lea 256(%esp), %esi + pushl %esi + call __libm_normalizel_k80 +..B3.3: + fldt 32(%esp) + movl 88(%esp), %eax + movl $0, 312(%esp) + fstpt 300(%esp) + fldt _CONSTANTS@GOTOFF(%eax) + movzwl 240(%esp), %eax + andl $32767, %eax + fstpt 288(%esp) + cmpl $8383, %eax + jl ..B3.5 +..B3.4: + cmpl $24383, %eax + jle ..B3.7 +..B3.5: + addl $4, %esp + lea 228(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.6: + addl $4, %esp + lea 228(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.7: + fldt 232(%esp) + movl 88(%esp), %edx + fld %st(0) + fld %st(1) + fld %st(2) + fld %st(3) + fldt 60+_CONSTANTS@GOTOFF(%edx) + fmul %st, %st(4) + movl 256(%esp), %eax + fxch %st(3) + fsubr %st(4), %st + fld %st(0) + addl %eax, %eax + fchs + movl %eax, 340(%esp) + fadd %st(5), %st + fld %st(0) + fxch %st(2) + fsubrp %st, %st(6) + fxch %st(1) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fsub %st(5), %st + fmul %st, %st(2) + fxch %st(3) + fmul %st, %st(5) + movzwl 268(%esp), %eax + fxch %st(5) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(2) + fxch %st(2) + fstpt 32(%esp) + fld %st(1) + andl $32767, %eax + fadd %st(3), %st + cmpl $8383, %eax + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 244(%esp) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 316(%esp) + fldt 316(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 328(%esp) + jl ..B3.9 +..B3.8: + cmpl $24383, %eax + jle ..B3.11 +..B3.9: + addl $4, %esp + lea 256(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.10: + addl $4, %esp + lea 256(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.11: + fldt 260(%esp) + fld %st(0) + fld %st(1) + fldt 32(%esp) + fmul %st(3), %st + movzwl 296(%esp), %ebx + movl %ebx, %esi + andl $32767, %esi + fsubr %st, %st(2) + movl 284(%esp), %eax + faddp %st, %st(2) + fld %st(1) + addl %eax, %eax + fmul %st(2), %st + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(2) + cmpl $8383, %esi + movl %eax, 368(%esp) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fldt 272(%esp) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 344(%esp) + fldt 344(%esp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 356(%esp) + fstpt 64(%esp) + jl ..B3.15 +..B3.12: + cmpl $24383, %esi + jg ..B3.15 +..B3.13: + movzwl 324(%esp), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B3.15 +..B3.14: + cmpl $24383, %ecx + jle ..B3.18 +..B3.15: + addl $4, %esp + lea 284(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.16: + addl $4, %esp + lea 312(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.17: + movzwl 296(%esp), %ebx + movl %ebx, %esi + movzwl 324(%esp), %ecx + andl $32767, %esi + movl %ecx, 44(%esp) + andl $32767, %ecx +..B3.18: + movl 312(%esp), %eax + movl 340(%esp), %edx + movl %eax, 60(%esp) + lea (%esi,%eax), %edi + movl %edi, 32(%esp) + lea -134(%edx,%ecx), %eax + cmpl %eax, %edi + jle ..B3.35 +..B3.19: + movl 292(%esp), %eax + lea 134(%edx,%ecx), %edi + cmpl 32(%esp), %edi + jle ..B3.36 +..B3.20: + testl %eax, %eax + jne ..B3.22 +..B3.21: + cmpl $0, 288(%esp) + je ..B3.37 +..B3.22: + cmpl $0, 320(%esp) + jne ..B3.24 +..B3.23: + cmpl $0, 316(%esp) + je ..B3.36 +..B3.24: + cmpl 60(%esp), %edx + je ..B3.26 +..B3.25: + fldt 64(%esp) + movl 60(%esp), %eax + fstpt 32(%esp) + subl %edx, %eax + fldt 288(%esp) + addl $16383, %eax + fldt 300(%esp) + andl $32767, %eax + andb $127, 41(%esp) + movzwl 40(%esp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 312(%esp) + fxch %st(2) + fstpt 288(%esp) + fldt 288(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 300(%esp) + fldt 300(%esp) + fxch %st(1) + fstpt 64(%esp) + movzwl 296(%esp), %ebx + jmp ..B3.27 +..B3.26: + fldt 288(%esp) + fstpt 64(%esp) + fldt 300(%esp) +..B3.27: + fldt 316(%esp) + andl $32767, %ebx + fldt 64(%esp) + movl 44(%esp), %eax + andl $32767, %eax + fsub %st(1), %st + movl %edx, 396(%esp) + cmpl %eax, %ebx + jg ..B3.32 +..B3.28: + jne ..B3.33 +..B3.29: + movl 292(%esp), %eax + movl 320(%esp), %edx + cmpl %edx, %eax + ja ..B3.32 +..B3.30: + jne ..B3.33 +..B3.31: + movl 288(%esp), %eax + cmpl 316(%esp), %eax + jbe ..B3.33 +..B3.32: + fldt 64(%esp) + fsub %st(1), %st + fsubp %st, %st(2) + fldt 328(%esp) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 64(%esp) + jmp ..B3.34 +..B3.33: + fldt 64(%esp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fldt 328(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) +..B3.34: + fldt 64(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 372(%esp) + fldt 372(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 384(%esp) + jmp ..B3.41 +..B3.35: + movl 292(%esp), %eax +..B3.36: + testl %eax, %eax + jne ..B3.38 +..B3.179: + cmpl $0, 288(%esp) +..B3.37: + je ..B3.39 +..B3.38: + lea -16517(%edx,%ecx), %ebx + movl 60(%esp), %ecx + lea -16383(%ecx,%esi), %esi + cmpl %esi, %ebx + jl ..B3.40 +..B3.39: + fldt 316(%esp) + fchs + movl %edx, 396(%esp) + fstpt 372(%esp) + fldt 328(%esp) + fchs + fstpt 384(%esp) + jmp ..B3.41 +..B3.40: + movl %eax, 376(%esp) + movl 288(%esp), %edx + movl 296(%esp), %eax + movl 300(%esp), %ecx + movl 304(%esp), %ebx + movl 308(%esp), %esi + movl 60(%esp), %edi + movl %edx, 372(%esp) + movl %eax, 380(%esp) + movl %ecx, 384(%esp) + movl %ebx, 388(%esp) + movl %esi, 392(%esp) + movl %edi, 396(%esp) +..B3.41: + movzwl 380(%esp), %ebx + movl %ebx, %esi + andl $32767, %esi + cmpl $8383, %esi + jl ..B3.45 +..B3.42: + cmpl $24383, %esi + jg ..B3.45 +..B3.43: + movzwl 352(%esp), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B3.45 +..B3.44: + cmpl $24383, %ecx + jle ..B3.48 +..B3.45: + addl $4, %esp + lea 368(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.46: + addl $4, %esp + lea 340(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.47: + movzwl 380(%esp), %ebx + movl %ebx, %esi + movzwl 352(%esp), %ecx + andl $32767, %esi + movl %ecx, 44(%esp) + andl $32767, %ecx +..B3.48: + movl 368(%esp), %edx + movl 396(%esp), %eax + movl %eax, 76(%esp) + lea (%esi,%eax), %edi + movl %edi, 60(%esp) + lea -134(%edx,%ecx), %eax + cmpl %eax, %edi + jle ..B3.65 +..B3.49: + movl 376(%esp), %eax + lea 134(%edx,%ecx), %edi + cmpl 60(%esp), %edi + jle ..B3.66 +..B3.50: + testl %eax, %eax + jne ..B3.52 +..B3.51: + cmpl $0, 372(%esp) + je ..B3.67 +..B3.52: + cmpl $0, 348(%esp) + jne ..B3.54 +..B3.53: + cmpl $0, 344(%esp) + je ..B3.66 +..B3.54: + cmpl 76(%esp), %edx + je ..B3.56 +..B3.55: + fldt 64(%esp) + movl 76(%esp), %eax + fstpt 32(%esp) + subl %edx, %eax + fldt 372(%esp) + addl $16383, %eax + fldt 384(%esp) + andl $32767, %eax + andb $127, 41(%esp) + movzwl 40(%esp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 396(%esp) + fxch %st(2) + fstpt 372(%esp) + fldt 372(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 384(%esp) + fldt 384(%esp) + fstpt 64(%esp) + movzwl 380(%esp), %ebx + jmp ..B3.57 +..B3.56: + fldt 372(%esp) + fldt 384(%esp) + fstpt 64(%esp) +..B3.57: + fldt 344(%esp) + andl $32767, %ebx + movl 44(%esp), %eax + fld %st(1) + andl $32767, %eax + fsub %st(1), %st + movl %edx, 424(%esp) + cmpl %eax, %ebx + jg ..B3.62 +..B3.58: + jne ..B3.63 +..B3.59: + movl 376(%esp), %eax + movl 348(%esp), %ecx + cmpl %ecx, %eax + ja ..B3.62 +..B3.60: + jne ..B3.63 +..B3.61: + movl 372(%esp), %eax + cmpl 344(%esp), %eax + jbe ..B3.63 +..B3.62: + fldt 64(%esp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fldt 356(%esp) + fsubrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) + jmp ..B3.64 +..B3.63: + fldt 356(%esp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fldt 64(%esp) + faddp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) +..B3.64: + fldt 64(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 400(%esp) + fldt 400(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 412(%esp) + jmp ..B3.71 +..B3.65: + movl 376(%esp), %eax +..B3.66: + testl %eax, %eax + jne ..B3.68 +..B3.180: + cmpl $0, 372(%esp) +..B3.67: + je ..B3.69 +..B3.68: + lea -16517(%edx,%ecx), %ebx + movl 76(%esp), %ecx + lea -16383(%ecx,%esi), %esi + cmpl %esi, %ebx + jl ..B3.70 +..B3.69: + fldt 344(%esp) + fchs + movl %edx, 424(%esp) + fstpt 400(%esp) + fldt 356(%esp) + fchs + fstpt 412(%esp) + jmp ..B3.71 +..B3.70: + movl 372(%esp), %edx + movl %edx, 400(%esp) + movl %eax, 404(%esp) + movl 380(%esp), %eax + movl 384(%esp), %ecx + movl 388(%esp), %ebx + movl 392(%esp), %esi + movl 76(%esp), %edx + movl %eax, 408(%esp) + movl %ecx, 412(%esp) + movl %ebx, 416(%esp) + movl %esi, 420(%esp) + movl %edx, 424(%esp) +..B3.71: + movzwl 408(%esp), %eax + andl $32767, %eax + lea -16383(%edx,%eax), %edx + cmpl $-6, %edx + jge ..B3.164 +..B3.72: + movzwl 296(%esp), %esi + movl %esi, 84(%esp) + andl $32767, %esi + cmpl $8383, %esi + jl ..B3.76 +..B3.73: + cmpl $24383, %esi + jg ..B3.76 +..B3.74: + movzwl 240(%esp), %eax + movl %eax, 60(%esp) + andl $32767, %eax + movl %eax, 76(%esp) + cmpl $8383, %eax + jl ..B3.76 +..B3.75: + cmpl $24383, 76(%esp) + jle ..B3.79 +..B3.76: + addl $4, %esp + lea 284(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.77: + addl $4, %esp + lea 228(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.78: + movzwl 240(%esp), %eax + movzwl 296(%esp), %esi + movl %eax, 60(%esp) + andl $32767, %eax + movl %eax, 76(%esp) + movl %esi, 84(%esp) + andl $32767, %esi +..B3.79: + movl 256(%esp), %ecx + movl 312(%esp), %edx + lea (%eax,%ecx), %ebx + lea -134(%ecx,%eax), %edi + movl %edi, 80(%esp) + lea (%esi,%edx), %eax + cmpl %eax, %edi + jge ..B3.96 +..B3.80: + movl 292(%esp), %edi + movl %edi, 44(%esp) + movl 76(%esp), %edi + lea 134(%ecx,%edi), %edi + cmpl %edi, %eax + jge ..B3.97 +..B3.81: + cmpl $0, 44(%esp) + jne ..B3.83 +..B3.82: + cmpl $0, 288(%esp) + je ..B3.98 +..B3.83: + cmpl $0, 236(%esp) + jne ..B3.85 +..B3.84: + cmpl $0, 232(%esp) + je ..B3.97 +..B3.85: + cmpl %ecx, %edx + je ..B3.87 +..B3.86: + fldt 64(%esp) + subl %ecx, %edx + fstpt 32(%esp) + addl $16383, %edx + fldt 288(%esp) + andl $32767, %edx + fldt 300(%esp) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %edx, %eax + movl %ecx, %edx + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 288(%esp) + fldt 288(%esp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 296(%esp), %esi + movl %esi, 84(%esp) + andl $32767, %esi + movl %ecx, 312(%esp) + movl %esi, %eax + fstpt 300(%esp) + fldt 300(%esp) + jmp ..B3.88 +..B3.87: + fldt 288(%esp) + fldt 300(%esp) + movl 84(%esp), %eax + andl $32767, %eax +..B3.88: + fldt 232(%esp) + fld %st(2) + movl 60(%esp), %edi + fadd %st(1), %st + andl $32767, %edi + movl %ecx, 116(%esp) + cmpl %edi, %eax + jg ..B3.93 +..B3.89: + jne ..B3.94 +..B3.90: + movl 292(%esp), %eax + movl 236(%esp), %edi + cmpl %edi, %eax + ja ..B3.93 +..B3.91: + jne ..B3.94 +..B3.92: + movl 288(%esp), %eax + cmpl 232(%esp), %eax + jbe ..B3.94 +..B3.93: + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 244(%esp) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 64(%esp) + jmp ..B3.95 +..B3.94: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 244(%esp) + faddp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) +..B3.95: + fldt 64(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 92(%esp) + fldt 92(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 104(%esp) + jmp ..B3.102 +..B3.96: + movl 292(%esp), %eax + movl %eax, 44(%esp) +..B3.97: + cmpl $0, 44(%esp) + jne ..B3.99 +..B3.178: + cmpl $0, 288(%esp) +..B3.98: + je ..B3.100 +..B3.99: + movl 76(%esp), %eax + lea -16517(%ecx,%eax), %edi + lea -16383(%edx,%esi), %eax + cmpl %eax, %edi + jl ..B3.101 +..B3.100: + movl 232(%esp), %eax + movl 236(%esp), %edi + movl %eax, 92(%esp) + movl %edi, 96(%esp) + movl 240(%esp), %eax + movl 244(%esp), %edi + movl %eax, 100(%esp) + movl %edi, 104(%esp) + movl 248(%esp), %eax + movl 252(%esp), %edi + movl %eax, 108(%esp) + movl %edi, 112(%esp) + movl %ecx, 116(%esp) + jmp ..B3.102 +..B3.101: + movl 288(%esp), %eax + movl 44(%esp), %edi + movl %eax, 92(%esp) + movl %edi, 96(%esp) + movl 296(%esp), %eax + movl 300(%esp), %edi + movl %eax, 100(%esp) + movl %edi, 104(%esp) + movl 304(%esp), %eax + movl 308(%esp), %edi + movl %eax, 108(%esp) + movl %edi, 112(%esp) + movl %edx, 116(%esp) +..B3.102: + cmpl $8383, %esi + jl ..B3.106 +..B3.103: + cmpl $24383, %esi + jg ..B3.106 +..B3.104: + cmpl $8383, 76(%esp) + jl ..B3.106 +..B3.105: + cmpl $24383, 76(%esp) + jle ..B3.109 +..B3.106: + addl $4, %esp + lea 284(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.107: + addl $4, %esp + lea 228(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.108: + movzwl 240(%esp), %eax + movl %eax, 60(%esp) + andl $32767, %eax + movl 256(%esp), %ecx + movl 312(%esp), %edx + lea -134(%ecx,%eax), %esi + movl %esi, 80(%esp) + movzwl 296(%esp), %esi + lea (%ecx,%eax), %ebx + movl %esi, 84(%esp) + andl $32767, %esi +..B3.109: + lea (%edx,%esi), %eax + movl %eax, 44(%esp) + cmpl 80(%esp), %eax + jle ..B3.126 +..B3.110: + movl 292(%esp), %eax + lea 134(%ebx), %edi + cmpl 44(%esp), %edi + jle ..B3.127 +..B3.111: + testl %eax, %eax + jne ..B3.113 +..B3.112: + cmpl $0, 288(%esp) + je ..B3.128 +..B3.113: + cmpl $0, 236(%esp) + jne ..B3.115 +..B3.114: + cmpl $0, 232(%esp) + je ..B3.127 +..B3.115: + cmpl %ecx, %edx + je ..B3.117 +..B3.116: + fldt 64(%esp) + subl %ecx, %edx + fstpt 32(%esp) + addl $16383, %edx + fldt 288(%esp) + andl $32767, %edx + fldt 300(%esp) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %edx, %eax + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %ecx, 312(%esp) + fxch %st(2) + fstpt 288(%esp) + fldt 288(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 300(%esp) + fldt 300(%esp) + movzwl 296(%esp), %edx + fxch %st(1) + fstpt 64(%esp) + movl %edx, 84(%esp) + jmp ..B3.118 +..B3.117: + fldt 288(%esp) + fstpt 64(%esp) + fldt 300(%esp) +..B3.118: + fldt 232(%esp) + fldt 64(%esp) + movl 84(%esp), %eax + movl 60(%esp), %edx + andl $32767, %eax + andl $32767, %edx + fsub %st(1), %st + movl %ecx, 144(%esp) + cmpl %edx, %eax + jg ..B3.123 +..B3.119: + jne ..B3.124 +..B3.120: + movl 292(%esp), %eax + movl 236(%esp), %edx + cmpl %edx, %eax + ja ..B3.123 +..B3.121: + jne ..B3.124 +..B3.122: + movl 288(%esp), %eax + cmpl 232(%esp), %eax + jbe ..B3.124 +..B3.123: + fldt 64(%esp) + fsub %st(1), %st + fsubp %st, %st(2) + fldt 244(%esp) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 64(%esp) + jmp ..B3.125 +..B3.124: + fldt 64(%esp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fldt 244(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) +..B3.125: + fldt 64(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 120(%esp) + fldt 120(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 132(%esp) + jmp ..B3.132 +..B3.126: + movl 292(%esp), %eax +..B3.127: + testl %eax, %eax + jne ..B3.129 +..B3.177: + cmpl $0, 288(%esp) +..B3.128: + je ..B3.130 +..B3.129: + addl $-16517, %ebx + lea -16383(%edx,%esi), %edx + cmpl %edx, %ebx + jl ..B3.131 +..B3.130: + fldt 232(%esp) + fchs + movl %ecx, 144(%esp) + fstpt 120(%esp) + fldt 244(%esp) + fchs + fstpt 132(%esp) + jmp ..B3.132 +..B3.131: + movl %eax, 124(%esp) + movl 288(%esp), %edx + movl 296(%esp), %eax + movl 300(%esp), %ecx + movl 304(%esp), %ebx + movl 308(%esp), %esi + movl 312(%esp), %edi + movl %edx, 120(%esp) + movl %eax, 128(%esp) + movl %ecx, 132(%esp) + movl %ebx, 136(%esp) + movl %esi, 140(%esp) + movl %edi, 144(%esp) +..B3.132: + addl $12, %esp + lea 80(%esp), %eax + lea 136(%esp), %ecx + pushl %eax + lea 252(%esp), %edx + pushl %edx + pushl %ecx + call __libm_atan2l_k80 +..B3.133: + addl $12, %esp + lea 108(%esp), %eax + lea 164(%esp), %ecx + pushl %eax + lea 252(%esp), %edx + pushl %edx + pushl %ecx + call __libm_atan2l_k80 +..B3.134: + movzwl 156(%esp), %ebx + movl %ebx, %esi + andl $32767, %esi + cmpl $8383, %esi + jl ..B3.138 +..B3.135: + cmpl $24383, %esi + jg ..B3.138 +..B3.136: + movzwl 184(%esp), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B3.138 +..B3.137: + cmpl $24383, %ecx + jle ..B3.141 +..B3.138: + addl $4, %esp + lea 144(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.139: + addl $4, %esp + lea 172(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B3.140: + movzwl 156(%esp), %ebx + movl %ebx, %esi + movzwl 184(%esp), %ecx + andl $32767, %esi + movl %ecx, 44(%esp) + andl $32767, %ecx +..B3.141: + movl 200(%esp), %edx + movl 172(%esp), %eax + movl %eax, 76(%esp) + lea (%esi,%eax), %edi + movl %edi, 60(%esp) + lea -134(%edx,%ecx), %eax + cmpl %eax, %edi + jle ..B3.158 +..B3.142: + movl 152(%esp), %eax + lea 134(%edx,%ecx), %edi + cmpl 60(%esp), %edi + jle ..B3.159 +..B3.143: + testl %eax, %eax + jne ..B3.145 +..B3.144: + cmpl $0, 148(%esp) + je ..B3.160 +..B3.145: + cmpl $0, 180(%esp) + jne ..B3.147 +..B3.146: + cmpl $0, 176(%esp) + je ..B3.159 +..B3.147: + cmpl 76(%esp), %edx + je ..B3.149 +..B3.148: + fldt 64(%esp) + movl 76(%esp), %eax + fstpt 32(%esp) + subl %edx, %eax + fldt 148(%esp) + addl $16383, %eax + fldt 160(%esp) + andl $32767, %eax + andb $127, 41(%esp) + movzwl 40(%esp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 172(%esp) + fxch %st(2) + fstpt 148(%esp) + fldt 148(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 160(%esp) + fldt 160(%esp) + movzwl 156(%esp), %ebx + jmp ..B3.150 +..B3.149: + fldt 148(%esp) + fldt 160(%esp) +..B3.150: + fldt 176(%esp) + andl $32767, %ebx + movl 44(%esp), %eax + fld %st(2) + andl $32767, %eax + fadd %st(1), %st + movl %edx, 228(%esp) + cmpl %eax, %ebx + jg ..B3.155 +..B3.151: + jne ..B3.156 +..B3.152: + movl 152(%esp), %eax + movl 180(%esp), %ecx + cmpl %ecx, %eax + ja ..B3.155 +..B3.153: + jne ..B3.156 +..B3.154: + movl 148(%esp), %eax + cmpl 176(%esp), %eax + jbe ..B3.156 +..B3.155: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 188(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + jmp ..B3.157 +..B3.156: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 188(%esp) + faddp %st, %st(1) + fstpt 32(%esp) + fldt 32(%esp) +..B3.157: + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + jmp ..B3.167 +..B3.158: + movl 152(%esp), %eax +..B3.159: + testl %eax, %eax + jne ..B3.161 +..B3.181: + cmpl $0, 148(%esp) +..B3.160: + je ..B3.162 +..B3.161: + lea -16517(%edx,%ecx), %ebx + movl 76(%esp), %ecx + lea -16383(%ecx,%esi), %esi + cmpl %esi, %ebx + jl ..B3.163 +..B3.162: + movl 176(%esp), %eax + movl %eax, 204(%esp) + movl 180(%esp), %ecx + movl 184(%esp), %ebx + movl 188(%esp), %esi + movl 192(%esp), %edi + movl 196(%esp), %eax + movl %ecx, 208(%esp) + movl %ebx, 212(%esp) + fldt 204(%esp) + movl %esi, 216(%esp) + movl %edi, 220(%esp) + movl %eax, 224(%esp) + fldt 216(%esp) + movl %edx, 228(%esp) + jmp ..B3.167 +..B3.163: + movl 148(%esp), %edx + movl %eax, 208(%esp) + movl 156(%esp), %eax + movl 160(%esp), %ecx + movl 164(%esp), %ebx + movl 168(%esp), %esi + movl %edx, 204(%esp) + movl %eax, 212(%esp) + fldt 204(%esp) + movl 76(%esp), %edx + movl %ecx, 216(%esp) + movl %ebx, 220(%esp) + movl %esi, 224(%esp) + fldt 216(%esp) + movl %edx, 228(%esp) + jmp ..B3.167 +..B3.164: + je ..B3.171 +..B3.165: + incl 284(%esp) + addl $12, %esp + lea 388(%esp), %eax + lea 192(%esp), %ecx + pushl %eax + lea 252(%esp), %edx + pushl %edx + pushl %ecx + call __libm_atan2l_k80 +..B3.166: + fldt 204(%esp) + fldt 216(%esp) + movl 228(%esp), %edx +..B3.167: + fldt 48(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fxch %st(1) + fstpt 204(%esp) + fstpt 216(%esp) + movl %edx, 24(%esp) + call __libm_scalbl_k80 +..B3.168: + movl 428(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B3.170 +..B3.169: + addl $436, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B3.170: + fstp %st(0) + movl 88(%esp), %ebx + call __stack_chk_fail@PLT +..B3.171: + movl 88(%esp), %edx + movl 376(%esp), %eax + cmpl 76+_CONSTANTS@GOTOFF(%edx), %eax + jb ..B3.72 +..B3.172: + jne ..B3.165 +..B3.173: + movl 372(%esp), %eax + cmpl 72+_CONSTANTS@GOTOFF(%edx), %eax + jb ..B3.72 + jmp ..B3.165 + .align 16,0x90 + .type imcatanhl,@function + .size imcatanhl,.-imcatanhl + .data +# -- End imcatanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.17: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 32768 + .word 16415 + .word 0 + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,84 + .data + .hidden __libm_normalizel_k80 + .hidden __libm_log_k80 + .hidden __libm_log1p_k80 + .hidden __libm_atan2l_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/catanl.S b/external/sgx_libm/ia32/catanl.S new file mode 100644 index 0000000000..3263ee5461 --- /dev/null +++ b/external/sgx_libm/ia32/catanl.S @@ -0,0 +1,210 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catanl.c" + .text +..TXTST0: +# -- Begin catanl + .text + .align 16,0x90 + .globl catanl +catanl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 100(%esp) + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 40(%esp) + fldt 40(%esp) + fstpt 52(%esp) + fldt 52(%esp) + fstpt 64(%esp) +..B1.2: + fnstcw 2(%esp) +..B1.3: + movzwl 2(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.4: + orl $-64768, %ecx + movw %cx, (%esp) +..B1.5: + fldcw (%esp) +..B1.6: + movl $1, %edi +..B1.7: + fldt 24(%ebp) + movzwl 32(%ebp), %edx + andl $32767, %edx + fstpt 52(%esp) + cmpl $32767, %edx + fldt 12(%ebp) + fstpt 64(%esp) + jl ..B1.10 +..B1.8: + cmpl $-2147483648, 28(%ebp) + jne ..B1.11 +..B1.9: + cmpl $0, 24(%ebp) + jne ..B1.11 +..B1.10: + movzbl 33(%ebp), %ecx + notl %ecx + movzbl 61(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 61(%esp) +..B1.11: + addl $-32, %esp + lea 108(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl -24(%ecx), %ecx + movl %ecx, (%edx) + movl 88(%esp), %ecx + movl %ecx, 4(%edx) + movl 92(%esp), %ecx + movl %ecx, 8(%edx) + movl 96(%esp), %ecx + movl %ecx, 12(%edx) + movl 100(%esp), %ecx + movl %ecx, 16(%edx) + movl 104(%esp), %ecx + movl %ecx, 20(%edx) + call catanhl@PLT +..B1.23: + addl $28, %esp + fldt 76(%esp) + movzwl 84(%esp), %edx + andl $32767, %edx + fstpt 4(%esp) + fldt 4(%esp) + cmpl $32767, %edx + fstpt 40(%esp) + fldt 88(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + jl ..B1.14 +..B1.12: + cmpl $-2147483648, 8(%esp) + jne ..B1.15 +..B1.13: + cmpl $0, 4(%esp) + jne ..B1.15 +..B1.14: + movzbl 13(%esp), %ecx + notl %ecx + movzbl 49(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 49(%esp) +..B1.15: + testl %edi, %edi + je ..B1.17 +..B1.16: + fldcw 2(%esp) +..B1.17: + movl 28(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 12(%esi) + movl 44(%esp), %edx + movl %edx, 16(%esi) + movl 32(%esp), %ecx + movl 36(%esp), %edi + movl 48(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 100(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.19 +..B1.18: + movl %esi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.19: + call __stack_chk_fail@PLT +..B1.20: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type catanl,@function + .size catanl,.-catanl + .data +# -- End catanl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cbrt_wmt.S b/external/sgx_libm/ia32/cbrt_wmt.S new file mode 100644 index 0000000000..5afefab75a --- /dev/null +++ b/external/sgx_libm/ia32/cbrt_wmt.S @@ -0,0 +1,735 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrt_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin cbrt + .text + .align 16,0x90 + .globl cbrt +cbrt: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %esi, 52(%esp) + call static_func + movl %eax, %esi + movsd 128(%esp), %xmm0 + movapd %xmm0, %xmm7 + movsd %xmm0, 8(%esp) + movl $524032, %edx + movsd 64(%esi), %xmm5 + movsd 80(%esi), %xmm3 + psrlq $44, %xmm7 + pextrw $0, %xmm7, %ecx + movd %xmm7, %eax + movsd 96(%esi), %xmm1 + movsd 112(%esi), %xmm2 + movl %ebx, 16(%esp) + andl $248, %ecx + movsd 128(%ecx,%esi), %xmm4 + movl %eax, %ebx + andl %eax, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_0.0.2 + cmpl $524032, %edx + je .L_2TAG_PACKET_1.0.2 + shrl $8, %edx + shrl $8, %ebx + andpd %xmm0, %xmm2 + andpd %xmm5, %xmm0 + orpd %xmm2, %xmm3 + orpd %xmm0, %xmm1 + movapd (%esi), %xmm5 + movl $5462, %eax + movapd 16(%esi), %xmm6 + mull %edx + movl %ebx, %edx + andl $2047, %ebx + shrl $14, %eax + andl $2048, %edx + subl %eax, %ebx + subl %eax, %ebx + subl %eax, %ebx + shll $8, %ebx + addl $682, %eax + orl %edx, %eax + movd %eax, %xmm7 + addl %ebx, %ecx + psllq $52, %xmm7 +.L_2TAG_PACKET_2.0.2: + movapd 32(%esi), %xmm2 + movapd 48(%esi), %xmm0 + subsd %xmm3, %xmm1 + movq %xmm7, %xmm3 + mulsd 384(%ecx,%esi), %xmm7 + mulsd %xmm4, %xmm1 + mulsd 1152(%ecx,%esi), %xmm3 + movapd %xmm1, %xmm4 + unpcklpd %xmm1, %xmm1 + mulpd %xmm1, %xmm5 + mulpd %xmm1, %xmm6 + mulpd %xmm1, %xmm1 + addpd %xmm5, %xmm2 + addpd %xmm6, %xmm0 + mulpd %xmm1, %xmm2 + mulpd %xmm1, %xmm1 + mulsd %xmm7, %xmm4 + addpd %xmm2, %xmm0 + movl 16(%esp), %ebx + mulsd %xmm0, %xmm1 + unpckhpd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm3, %xmm0 + addsd %xmm7, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + mulsd 1984(%esi), %xmm0 + movq %xmm0, %xmm7 + movl $524032, %edx + psrlq $44, %xmm7 + pextrw $0, %xmm7, %ecx + movd %xmm7, %eax + andl $248, %ecx + movsd 128(%ecx,%esi), %xmm4 + movl %eax, %ebx + andl %eax, %edx + shrl $8, %edx + shrl $8, %ebx + cmpl $0, %edx + je .L_2TAG_PACKET_4.0.2 + andpd %xmm0, %xmm2 + andpd %xmm5, %xmm0 + orpd %xmm2, %xmm3 + orpd %xmm0, %xmm1 + movapd (%esi), %xmm5 + movl $5462, %eax + movapd 16(%esi), %xmm6 + mull %edx + movl %ebx, %edx + andl $2047, %ebx + shrl $14, %eax + andl $2048, %edx + subl %eax, %ebx + subl %eax, %ebx + subl %eax, %ebx + shll $8, %ebx + addl $661, %eax + orl %edx, %eax + movd %eax, %xmm7 + addl %ebx, %ecx + psllq $52, %xmm7 + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_4.0.2: + cmpl $0, %ebx + jne .L_2TAG_PACKET_5.0.2 + movl 16(%esp), %ebx + fldl 1952(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_5.0.2: + movl 16(%esp), %ebx + fldl 1968(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_1.0.2: + movl 16(%esp), %ebx + movl 132(%esp), %eax + movl 128(%esp), %edx + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $2146435072, %ecx + ja .L_2TAG_PACKET_6.0.2 + cmpl $0, %edx + jne .L_2TAG_PACKET_6.0.2 + cmpl $2146435072, %eax + jne .L_2TAG_PACKET_7.0.2 + fldl 1920(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_7.0.2: + fldl 1936(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_6.0.2: + movsd 8(%esp), %xmm0 + addsd %xmm0, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) +.L_2TAG_PACKET_3.0.2: + movl 52(%esp), %esi + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type cbrt,@function + .size cbrt,.-cbrt + .data +# -- End cbrt + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1553778919 + .long 3213899486 + .long 3534952507 + .long 3215266280 + .long 1646371399 + .long 3214412045 + .long 477218588 + .long 3216798151 + .long 3582521621 + .long 1066628362 + .long 1007461464 + .long 1068473053 + .long 889629714 + .long 1067378449 + .long 1431655765 + .long 1070945621 + .long 4294967295 + .long 1048575 + .long 0 + .long 0 + .long 0 + .long 3220193280 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 1032192 + .long 0 + .long 0 + .long 528611360 + .long 3220144632 + .long 2884679527 + .long 3220082993 + .long 1991868891 + .long 3220024928 + .long 2298714891 + .long 3219970134 + .long 58835168 + .long 3219918343 + .long 3035110223 + .long 3219869313 + .long 1617585086 + .long 3219822831 + .long 2500867033 + .long 3219778702 + .long 4241943008 + .long 3219736752 + .long 258732970 + .long 3219696825 + .long 404232216 + .long 3219658776 + .long 2172167368 + .long 3219622476 + .long 1544257904 + .long 3219587808 + .long 377579543 + .long 3219554664 + .long 1616385542 + .long 3219522945 + .long 813783277 + .long 3219492562 + .long 3940743189 + .long 3219463431 + .long 2689777499 + .long 3219435478 + .long 1700977147 + .long 3219408632 + .long 3169102082 + .long 3219382828 + .long 327235604 + .long 3219358008 + .long 1244336319 + .long 3219334115 + .long 1300311200 + .long 3219311099 + .long 3095471925 + .long 3219288912 + .long 2166487928 + .long 3219267511 + .long 2913108253 + .long 3219246854 + .long 293672978 + .long 3219226904 + .long 288737297 + .long 3219207624 + .long 1810275472 + .long 3219188981 + .long 174592167 + .long 3219170945 + .long 3539053052 + .long 3219153485 + .long 2164392968 + .long 3219136576 + .long 572345495 + .long 1072698681 + .long 1998204467 + .long 1072709382 + .long 3861501553 + .long 1072719872 + .long 2268192434 + .long 1072730162 + .long 2981979308 + .long 1072740260 + .long 270859143 + .long 1072750176 + .long 2958651392 + .long 1072759916 + .long 313113243 + .long 1072769490 + .long 919449400 + .long 1072778903 + .long 2809328903 + .long 1072788162 + .long 2222981587 + .long 1072797274 + .long 2352530781 + .long 1072806244 + .long 594152517 + .long 1072815078 + .long 1555767199 + .long 1072823780 + .long 4282421314 + .long 1072832355 + .long 2355578597 + .long 1072840809 + .long 1162590619 + .long 1072849145 + .long 797864051 + .long 1072857367 + .long 431273680 + .long 1072865479 + .long 2669831148 + .long 1072873484 + .long 733477752 + .long 1072881387 + .long 4280220604 + .long 1072889189 + .long 801961634 + .long 1072896896 + .long 2915370760 + .long 1072904508 + .long 1159613482 + .long 1072912030 + .long 2689944798 + .long 1072919463 + .long 1248687822 + .long 1072926811 + .long 2967951030 + .long 1072934075 + .long 630170432 + .long 1072941259 + .long 3760898254 + .long 1072948363 + .long 0 + .long 1072955392 + .long 2370273294 + .long 1072962345 + .long 1261754802 + .long 1072972640 + .long 546334065 + .long 1072986123 + .long 1054893830 + .long 1072999340 + .long 1571187597 + .long 1073012304 + .long 1107975175 + .long 1073025027 + .long 3606909377 + .long 1073037519 + .long 1113616747 + .long 1073049792 + .long 4154744632 + .long 1073061853 + .long 3358931423 + .long 1073073713 + .long 4060702372 + .long 1073085379 + .long 747576176 + .long 1073096860 + .long 3023138255 + .long 1073108161 + .long 1419988548 + .long 1073119291 + .long 1914185305 + .long 1073130255 + .long 294389948 + .long 1073141060 + .long 3761802570 + .long 1073151710 + .long 978281566 + .long 1073162213 + .long 823148820 + .long 1073172572 + .long 2420954441 + .long 1073182792 + .long 3815449908 + .long 1073192878 + .long 2046058587 + .long 1073202835 + .long 1807524753 + .long 1073212666 + .long 2628681401 + .long 1073222375 + .long 3225667357 + .long 1073231966 + .long 1555307421 + .long 1073241443 + .long 3454043099 + .long 1073250808 + .long 1208137896 + .long 1073260066 + .long 3659916772 + .long 1073269218 + .long 1886261264 + .long 1073278269 + .long 3593647839 + .long 1073287220 + .long 3086012205 + .long 1073296075 + .long 2769796922 + .long 1073304836 + .long 888716057 + .long 1073317807 + .long 2201465623 + .long 1073334794 + .long 164369365 + .long 1073351447 + .long 3462666733 + .long 1073367780 + .long 2773905457 + .long 1073383810 + .long 1342879088 + .long 1073399550 + .long 2543933975 + .long 1073415012 + .long 1684477781 + .long 1073430209 + .long 3532178543 + .long 1073445151 + .long 1147747300 + .long 1073459850 + .long 1928031793 + .long 1073474314 + .long 2079717015 + .long 1073488553 + .long 4016765315 + .long 1073502575 + .long 3670431139 + .long 1073516389 + .long 3549227225 + .long 1073530002 + .long 11637607 + .long 1073543422 + .long 588220169 + .long 1073556654 + .long 2635407503 + .long 1073569705 + .long 2042029317 + .long 1073582582 + .long 1925128962 + .long 1073595290 + .long 4136375664 + .long 1073607834 + .long 759964600 + .long 1073620221 + .long 4257606771 + .long 1073632453 + .long 297278907 + .long 1073644538 + .long 3655053093 + .long 1073656477 + .long 2442253172 + .long 1073668277 + .long 1111876799 + .long 1073679941 + .long 3330973139 + .long 1073691472 + .long 3438879452 + .long 1073702875 + .long 3671565478 + .long 1073714153 + .long 1317849547 + .long 1073725310 + .long 1642364115 + .long 1073736348 + .long 4050900474 + .long 1014427190 + .long 1157977860 + .long 1016444461 + .long 1374568199 + .long 1017271387 + .long 2809163288 + .long 1016882676 + .long 3742377377 + .long 1013168191 + .long 3101606597 + .long 1017541672 + .long 65224358 + .long 1017217597 + .long 2691591250 + .long 1017266643 + .long 4020758549 + .long 1017689313 + .long 1316310992 + .long 1018030788 + .long 1031537856 + .long 1014090882 + .long 3261395239 + .long 1016413641 + .long 886424999 + .long 1016313335 + .long 3114776834 + .long 1014195875 + .long 1681120620 + .long 1017825416 + .long 1329600273 + .long 1016625740 + .long 465474623 + .long 1017097119 + .long 4251633980 + .long 1017169077 + .long 1986990133 + .long 1017710645 + .long 752958613 + .long 1017159641 + .long 2216216792 + .long 1018020163 + .long 4282860129 + .long 1015924861 + .long 1557627859 + .long 1016039538 + .long 3889219754 + .long 1018086237 + .long 3684996408 + .long 1017353275 + .long 723532103 + .long 1017717141 + .long 2951149676 + .long 1012528470 + .long 831890937 + .long 1017830553 + .long 1031212645 + .long 1017387331 + .long 2741737450 + .long 1017604974 + .long 2863311531 + .long 1003776682 + .long 4276736099 + .long 1013153088 + .long 4111778382 + .long 1015673686 + .long 1728065769 + .long 1016413986 + .long 2708718031 + .long 1018078833 + .long 1069335005 + .long 1015291224 + .long 700037144 + .long 1016482032 + .long 2904566452 + .long 1017226861 + .long 4074156649 + .long 1017622651 + .long 25019565 + .long 1015245366 + .long 3601952608 + .long 1015771755 + .long 3267129373 + .long 1017904664 + .long 503203103 + .long 1014921629 + .long 2122011730 + .long 1018027866 + .long 3927295461 + .long 1014189456 + .long 2790625147 + .long 1016024251 + .long 1330460186 + .long 1016940346 + .long 4033568463 + .long 1015538390 + .long 3695818227 + .long 1017509621 + .long 257573361 + .long 1017208868 + .long 3227697852 + .long 1017337964 + .long 234118548 + .long 1017169577 + .long 4009025803 + .long 1017278524 + .long 1948343394 + .long 1017749310 + .long 678398162 + .long 1018144239 + .long 3083864863 + .long 1016669086 + .long 2415453452 + .long 1017890370 + .long 175467344 + .long 1017330033 + .long 3197359580 + .long 1010339928 + .long 2071276951 + .long 1015941358 + .long 268372543 + .long 1016737773 + .long 938132959 + .long 1017389108 + .long 1816750559 + .long 1017337448 + .long 4119203749 + .long 1017152174 + .long 2578653878 + .long 1013108497 + .long 2470331096 + .long 1014678606 + .long 123855735 + .long 1016553320 + .long 1265650889 + .long 1014782687 + .long 3414398172 + .long 1017182638 + .long 1040773369 + .long 1016158401 + .long 3483628886 + .long 1016886550 + .long 4140499405 + .long 1016191425 + .long 3893477850 + .long 1016964495 + .long 3935319771 + .long 1009634717 + .long 2978982660 + .long 1015027112 + .long 2452709923 + .long 1017990229 + .long 3190365712 + .long 1015835149 + .long 4237588139 + .long 1015832925 + .long 2610678389 + .long 1017962711 + .long 2127316774 + .long 1017405770 + .long 824267502 + .long 1017959463 + .long 2165924042 + .long 1017912225 + .long 2774007076 + .long 1013257418 + .long 4123916326 + .long 1017582284 + .long 1976417958 + .long 1016959909 + .long 4092806412 + .long 1017711279 + .long 119251817 + .long 1015363631 + .long 3475418768 + .long 1017675415 + .long 1972580503 + .long 1015470684 + .long 815541017 + .long 1017517969 + .long 2429917451 + .long 1017397776 + .long 4062888482 + .long 1016749897 + .long 68284153 + .long 1017925678 + .long 2207779246 + .long 1016320298 + .long 1183466520 + .long 1017408657 + .long 143326427 + .long 1017060403 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 4293918720 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 1138753536 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,2000 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cbrtf_wmt.S b/external/sgx_libm/ia32/cbrtf_wmt.S new file mode 100644 index 0000000000..b04fe14b04 --- /dev/null +++ b/external/sgx_libm/ia32/cbrtf_wmt.S @@ -0,0 +1,504 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrtf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin cbrtf + .text + .align 16,0x90 + .globl cbrtf +cbrtf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %esi, 44(%esp) + call static_func + movl %eax, %esi + movss 112(%esp), %xmm0 + movss %xmm0, 4(%esp) + movl %ebx, 8(%esp) + movl $8388607, %edx + movd %edx, %xmm5 + movl $-1081999360, %ebx + movd %ebx, %xmm3 + movl $-1082130432, %ebx + movd %ebx, %xmm1 + movl $8257536, %edx + movd %edx, %xmm2 + pextrw $1, %xmm0, %ecx + movl %ecx, %eax + andl $124, %ecx + movss 16(%ecx,%esi), %xmm4 + shrl $7, %eax + movl $255, %edx + andl %eax, %edx + movl %eax, %ebx + cmpl $0, %edx + je .L_2TAG_PACKET_0.0.2 + cmpl $255, %edx + je .L_2TAG_PACKET_1.0.2 + andps %xmm0, %xmm2 + andps %xmm5, %xmm0 + orps %xmm2, %xmm3 + orps %xmm0, %xmm1 + movss (%esi), %xmm5 + movss 4(%esi), %xmm6 + movl %edx, %eax + addl %eax, %eax + addl %eax, %eax + addl %edx, %eax + movl %eax, %edx + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %edx + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %edx, %eax + movl %ebx, %edx + andl $255, %ebx + subl $1, %ebx + shrl $12, %eax + andl $256, %edx + subl %eax, %ebx + subl %eax, %ebx + subl %eax, %ebx + shll $7, %ebx + addl $85, %eax + orl %edx, %eax + movd %eax, %xmm7 + addl %ebx, %ecx + psllq $23, %xmm7 +.L_2TAG_PACKET_2.0.2: + movss 8(%esi), %xmm2 + movss 12(%esi), %xmm0 + subss %xmm3, %xmm1 + movaps %xmm7, %xmm3 + mulss 144(%ecx,%esi), %xmm7 + mulss %xmm4, %xmm1 + mulss 528(%ecx,%esi), %xmm3 + movss %xmm1, %xmm4 + mulss %xmm1, %xmm5 + mulss %xmm1, %xmm6 + mulss %xmm1, %xmm1 + addss %xmm5, %xmm2 + addss %xmm6, %xmm0 + mulss %xmm1, %xmm2 + mulss %xmm7, %xmm4 + addss %xmm2, %xmm0 + movl 8(%esp), %ebx + mulss %xmm4, %xmm0 + addss %xmm3, %xmm0 + addss %xmm7, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + movq %xmm0, %xmm7 + movd %xmm0, %eax + movl %eax, %ebx + shll $9, %eax + movl $23, %ecx + shrl $23, %ebx +.L_2TAG_PACKET_4.0.2: + cmpl $-2147483648, %eax + jae .L_2TAG_PACKET_5.0.2 + shll $1, %eax + addl $1, %edx + loop .L_2TAG_PACKET_4.0.2 + cmpl $0, %eax + je .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_5.0.2: + movl %edx, %ecx + incl %ecx + movd %ecx, %xmm7 + orl %edx, %ebx + psllq %xmm7, %xmm0 + shrl $24, %eax + andl $124, %eax + movsd 16(%esi,%eax), %xmm4 + movl %eax, %ecx + andps %xmm0, %xmm2 + andps %xmm5, %xmm0 + orps %xmm2, %xmm3 + orps %xmm0, %xmm1 + movss (%esi), %xmm5 + movl $1366, %eax + movss 4(%esi), %xmm6 + mull %edx + movl %ebx, %edx + andl $255, %ebx + addl $1, %ebx + shrl $12, %eax + andl $256, %edx + subl %eax, %ebx + subl %eax, %ebx + subl %eax, %ebx + cmpl $0, %ebx + je .L_2TAG_PACKET_7.0.2 + incl %eax + subl $3, %ebx + negl %ebx +.L_2TAG_PACKET_7.0.2: + shll $7, %ebx + addl %ebx, %ecx + movl $85, %ebx + subl %eax, %ebx + orl %edx, %ebx + movd %ebx, %xmm7 + psllq $23, %xmm7 + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_6.0.2: + cmpl $0, %ebx + jne .L_2TAG_PACKET_8.0.2 + movl 8(%esp), %ebx + fldl 944(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_8.0.2: + movl 8(%esp), %ebx + fldl 960(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_1.0.2: + movl 8(%esp), %ebx + movl 4(%esp), %eax + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $2139095040, %ecx + ja .L_2TAG_PACKET_9.0.2 + cmpl $2139095040, %eax + jne .L_2TAG_PACKET_10.0.2 + fldl 912(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_10.0.2: + fldl 928(%esi) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_9.0.2: + movss 4(%esp), %xmm0 + addss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_3.0.2: + movl 44(%esp), %esi + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type cbrtf,@function + .size cbrtf,.-cbrtf + .data +# -- End cbrtf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 3173551943 + .long 3185806905 + .long 1031591658 + .long 1051372203 + .long 3212578753 + .long 3212085645 + .long 3211621124 + .long 3211182772 + .long 3210768440 + .long 3210376206 + .long 3210004347 + .long 3209651317 + .long 3209315720 + .long 3208996296 + .long 3208691905 + .long 3208401508 + .long 3208124163 + .long 3207859009 + .long 3207605259 + .long 3207362194 + .long 3207129151 + .long 3206905525 + .long 3206690755 + .long 3206484326 + .long 3206285761 + .long 3206094618 + .long 3205910490 + .long 3205732998 + .long 3205561788 + .long 3205396533 + .long 3205236929 + .long 3205082689 + .long 3204933547 + .long 3204789256 + .long 3204649583 + .long 3204514308 + .long 1065396681 + .long 1065482291 + .long 1065566215 + .long 1065648532 + .long 1065729317 + .long 1065808640 + .long 1065886565 + .long 1065963152 + .long 1066038457 + .long 1066112533 + .long 1066185428 + .long 1066257188 + .long 1066327857 + .long 1066397474 + .long 1066466079 + .long 1066533708 + .long 1066600394 + .long 1066666169 + .long 1066731064 + .long 1066795108 + .long 1066858329 + .long 1066920751 + .long 1066982401 + .long 1067043301 + .long 1067103474 + .long 1067162941 + .long 1067221722 + .long 1067279837 + .long 1067337305 + .long 1067394143 + .long 1067450368 + .long 1067505996 + .long 1067588354 + .long 1067696217 + .long 1067801953 + .long 1067905666 + .long 1068007450 + .long 1068107390 + .long 1068205570 + .long 1068302063 + .long 1068396942 + .long 1068490271 + .long 1068582113 + .long 1068672525 + .long 1068761562 + .long 1068849275 + .long 1068935712 + .long 1069020919 + .long 1069104937 + .long 1069187809 + .long 1069269572 + .long 1069350263 + .long 1069429915 + .long 1069508563 + .long 1069586236 + .long 1069662966 + .long 1069738778 + .long 1069813702 + .long 1069887762 + .long 1069960982 + .long 1070033387 + .long 1070104998 + .long 1070175837 + .long 1070245925 + .long 1070349689 + .long 1070485588 + .long 1070618808 + .long 1070749478 + .long 1070877717 + .long 1071003634 + .long 1071127332 + .long 1071248907 + .long 1071368446 + .long 1071486034 + .long 1071601747 + .long 1071715659 + .long 1071827839 + .long 1071938350 + .long 1072047254 + .long 1072154608 + .long 1072260465 + .long 1072364876 + .long 1072467891 + .long 1072569555 + .long 1072669911 + .long 1072769001 + .long 1072866863 + .long 1072963536 + .long 1073059054 + .long 1073153452 + .long 1073246762 + .long 1073339014 + .long 1073430238 + .long 1073520462 + .long 1073609714 + .long 1073698019 + .long 839340838 + .long 867750258 + .long 851786446 + .long 853949398 + .long 864938789 + .long 864102364 + .long 864209792 + .long 865422805 + .long 867593594 + .long 854482593 + .long 848298042 + .long 860064854 + .long 844792593 + .long 870701309 + .long 872023170 + .long 860255342 + .long 849966899 + .long 863561479 + .long 869115319 + .long 871961375 + .long 859537336 + .long 871954398 + .long 863817578 + .long 861687921 + .long 849594757 + .long 816486846 + .long 858183533 + .long 864500406 + .long 850523240 + .long 808125243 + .long 514020693 + .long 861173761 + .long 859000219 + .long 823158129 + .long 871826232 + .long 871183196 + .long 839030530 + .long 867690638 + .long 840440923 + .long 868033274 + .long 855856030 + .long 865094453 + .long 860418487 + .long 866225006 + .long 866458226 + .long 865124659 + .long 864837702 + .long 811742505 + .long 869432099 + .long 864584201 + .long 864183978 + .long 844810573 + .long 869245699 + .long 859556409 + .long 870675446 + .long 814190139 + .long 870686941 + .long 861800510 + .long 855649163 + .long 869347119 + .long 864252033 + .long 867276215 + .long 868189817 + .long 849541095 + .long 866633177 + .long 843967686 + .long 857522493 + .long 862339487 + .long 850054662 + .long 864048556 + .long 868027089 + .long 848093931 + .long 865355299 + .long 848111485 + .long 865557362 + .long 870297525 + .long 863416216 + .long 869675693 + .long 865888071 + .long 825332584 + .long 843309506 + .long 870885636 + .long 869119784 + .long 865466648 + .long 867459244 + .long 861192764 + .long 871247716 + .long 864927982 + .long 869195129 + .long 864849564 + .long 840005936 + .long 852579258 + .long 860852782 + .long 869711141 + .long 862506141 + .long 837959274 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 4293918720 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,976 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cbrtl.S b/external/sgx_libm/ia32/cbrtl.S new file mode 100644 index 0000000000..71fe91a6ac --- /dev/null +++ b/external/sgx_libm/ia32/cbrtl.S @@ -0,0 +1,374 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrtl.c" + .text +..TXTST0: +# -- Begin cbrtl + .text + .align 16,0x90 + .globl cbrtl +cbrtl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp +..B1.2: + fnstcw 30(%esp) +..B1.3: + movzwl 16(%ebp), %esi + movl %esi, %ebx + andl $32767, %ebx + movzwl 30(%esp), %ecx + cmpl $32767, %ebx + je ..B1.23 +..B1.4: + movl %ecx, %edx + movzbl 17(%ebp), %eax + andl $768, %edx + andl $128, %eax + shrl $7, %eax + cmpl $768, %edx + je ..B1.22 +..B1.5: + orl $-64768, %ecx + movw %cx, 28(%esp) +..B1.6: + fldcw 28(%esp) +..B1.7: + movzwl 16(%ebp), %esi + movl %esi, %ebx + movl $1, %edi + andl $32767, %ebx +..B1.8: + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + testl %ebx, %ebx + jne ..B1.15 +..B1.9: + cmpl $0, 12(%ebp) + jne ..B1.14 +..B1.10: + cmpl $0, 8(%ebp) + jne ..B1.14 +..B1.11: + fldl _zeros@GOTOFF(%ecx,%eax,8) + testl %edi, %edi + fstpl (%esp) + je ..B1.13 +..B1.12: + fldcw 30(%esp) +..B1.13: + fldl (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + fldt 8(%ebp) + movl $-25, %edx + fmull _TWO_75@GOTOFF(%ecx) + fstpt 8(%ebp) + movzwl 16(%ebp), %esi + movl %esi, %ebx + andl $32767, %ebx + jmp ..B1.16 +..B1.15: + xorl %edx, %edx +..B1.16: + fldl ones@GOTOFF(%ecx,%eax,8) + andl $-32768, %esi + imull $21845, %ebx, %eax + orl $-49153, %esi + fstpt (%esp) + fldt (%esp) + fldl _TWO_32H@GOTOFF(%ecx) + fld %st(0) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + movw %si, 16(%ebp) + addl $21845, %eax + fldt 8(%ebp) + fmulp %st, %st(4) + shrl $16, %eax + fxch %st(1) + fadd %st(3), %st + movl %edi, 12(%esp) + lea (%eax,%eax), %edi + subl %edi, %ebx + lea 10922(%edx,%eax), %edx + movl 12(%ebp), %edi + fsubp %st, %st(2) + shrl $23, %edi + fxch %st(1) + fsubr %st, %st(2) + fldt 72+_P@GOTOFF(%ecx) + fldt 48+_P@GOTOFF(%ecx) + andl $255, %edi + movzwl 8(%esp), %esi + andl $-32768, %esi + orl %edx, %esi + flds __libm_rcp_table_256@GOTOFF(%ecx,%edi,4) + fld %st(0) + fmulp %st, %st(4) + shll $4, %edi + fxch %st(3) + fsub %st(4), %st + fxch %st(3) + fmulp %st, %st(5) + movw %si, 8(%esp) + subl %eax, %ebx + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fmul %st(3), %st + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fmul %st(1), %st + fldt 60+_P@GOTOFF(%ecx) + fmul %st(4), %st + fldt 36+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt _P@GOTOFF(%ecx) + fmulp %st, %st(1) + faddp %st, %st(2) + fadd %st(1), %st + fstpt 16(%esp) + fldl 8+__libm_cbrtl_table_256@GOTOFF(%ecx,%edi) + fldl __libm_cbrtl_table_256@GOTOFF(%ecx,%edi) + fldt (%esp) + movl 12(%esp), %edi + jne ..B1.18 +..B1.17: + fldt 16(%esp) + fmulp %st, %st(3) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.19 +..B1.18: + fxch %st(2) + fmull -8+_SH@GOTOFF(%ecx,%ebx,8) + fldl 24+_SH@GOTOFF(%ecx,%ebx,8) + fmul %st(2), %st + faddp %st, %st(1) + fxch %st(1) + fmull 8+_SH@GOTOFF(%ecx,%ebx,8) + fmul %st, %st(3) + fldt 16(%esp) + fmulp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 16(%esp) +..B1.19: + testl %edi, %edi + je ..B1.21 +..B1.20: + fldcw 30(%esp) +..B1.21: + fldt 16(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.22: + xorl %edi, %edi + jmp ..B1.8 +..B1.23: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.24: + orl $-64768, %ecx + movw %cx, 28(%esp) +..B1.25: + fldcw 28(%esp) +..B1.26: + fldt 8(%ebp) + fstpt (%esp) +..B1.27: + fldcw 30(%esp) +..B1.28: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.28 + .align 16,0x90 + .type cbrtl,@function + .size cbrtl,.-cbrtl + .data +# -- End cbrtl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +_SH: + .long 0xf98d728b,0x3ff428a2 + .long 0xa53d6e3d,0x3ff965fe + .long 0xf8000000,0x3ff428a2 + .long 0xa4000000,0x3ff965fe + .long 0xae223ddb,0x3e38d728 + .long 0xc82b059a,0x3e33d6e3 + .type _SH,@object + .size _SH,48 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_P: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58320 + .word 36408 + .word 14563 + .word 58254 + .word 49147 + .word 0 + .word 50474 + .word 25890 + .word 59872 + .word 64726 + .word 16378 + .word 0 + .word 45217 + .word 37017 + .word 18069 + .word 43151 + .word 49146 + .word 0 + .word 45059 + .word 7616 + .word 35240 + .word 63288 + .word 16377 + .word 0 + .word 54522 + .word 17175 + .word 48475 + .word 49224 + .word 49145 + .word 0 + .word 568 + .word 55426 + .word 44619 + .word 39848 + .word 16377 + .word 0 + .type _P,@object + .size _P,84 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_cbrtl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cbrtl_table.S b/external/sgx_libm/ia32/cbrtl_table.S new file mode 100644 index 0000000000..336596680a --- /dev/null +++ b/external/sgx_libm/ia32/cbrtl_table.S @@ -0,0 +1,560 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrtl_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_cbrtl_table_256 + .globl __libm_cbrtl_table_256 +__libm_cbrtl_table_256: + .long 0x8e000000,0x3ff002ab + .long 0x20d8688c,0x3e2230dd + .long 0x08000000,0x3ff00808 + .long 0xeff25f12,0x3e3610f3 + .long 0xba000000,0x3ff00d6b + .long 0x3efe3543,0xbe0b4bfa + .long 0xb2000000,0x3ff012d6 + .long 0x2c9e7759,0xbe32d173 + .long 0x4e000000,0x3ff0179a + .long 0x013f2daf,0x3e1eca95 + .long 0x1a000000,0x3ff01d13 + .long 0x1a1a641f,0xbe35afd8 + .long 0x5a000000,0x3ff02293 + .long 0xa40f870c,0x3e3acf85 + .long 0xc6000000,0x3ff02769 + .long 0x8b30b2ed,0xbe1bd4a4 + .long 0x3c000000,0x3ff02cf8 + .long 0xc2b35d57,0xbe10fe10 + .long 0x2e000000,0x3ff031db + .long 0x9aefd6bc,0x3e1dc088 + .long 0x1a000000,0x3ff03778 + .long 0x26cf8b86,0xbe3983d8 + .long 0xcc000000,0x3ff03c67 + .long 0xa0938ea4,0x3e33f7ce + .long 0x8a000000,0x3ff0415d + .long 0x1f4527e6,0x3e1271e1 + .long 0x1e000000,0x3ff04710 + .long 0xe014332a,0x3e2e39c2 + .long 0xf4000000,0x3ff04c12 + .long 0x4801f107,0x3e28aa39 + .long 0xfc000000,0x3ff0511b + .long 0x5e2d9f07,0x3dbd36bd + .long 0x42000000,0x3ff0562b + .long 0xc47ab24f,0x3df8a6e2 + .long 0xd4000000,0x3ff05b40 + .long 0x24da1d13,0x3e249ec6 + .long 0xc2000000,0x3ff0605c + .long 0x31b189b7,0xbe227295 + .long 0x16000000,0x3ff0657f + .long 0x7872e1cd,0x3e17f761 + .long 0xe2000000,0x3ff06aa7 + .long 0xc4a6c979,0xbe18ff8e + .long 0x32000000,0x3ff06fd7 + .long 0x37586fc9,0xbe22bc1f + .long 0x1e000000,0x3ff0744e + .long 0xda6466ae,0x3e213213 + .long 0xb0000000,0x3ff07989 + .long 0xd1b04779,0xbe181829 + .long 0xf0000000,0x3ff07ecb + .long 0x52cf55c8,0xbe2d5de3 + .long 0xea000000,0x3ff08414 + .long 0xa790ab31,0x3e3e5ef6 + .long 0x0a000000,0x3ff088a2 + .long 0x7bee6b1f,0xbe33c01d + .long 0xb2000000,0x3ff08df7 + .long 0xed26e53e,0x3e0b930b + .long 0xc4000000,0x3ff0928f + .long 0x35afee34,0xbe2f72c3 + .long 0x4e000000,0x3ff097f2 + .long 0x1166e9a4,0x3e256094 + .long 0x82000000,0x3ff09c95 + .long 0x5ae9d19c,0xbe01eed4 + .long 0xe8000000,0x3ff0a13d + .long 0x82f9b502,0x3e22e1bc + .long 0xac000000,0x3ff0a6b3 + .long 0xdecb71aa,0xbe13744b + .long 0x7c000000,0x3ff0ab67 + .long 0x79520489,0xbe34918f + .long 0x9e000000,0x3ff0b020 + .long 0xf330a139,0x3df882be + .long 0x20000000,0x3ff0b4df + .long 0xc3236255,0x3e1c8694 + .long 0xe6000000,0x3ff0ba6e + .long 0x119c7384,0xbdd954af + .long 0x30000000,0x3ff0bf39 + .long 0x17946a4f,0x3e17e600 + .long 0xfc000000,0x3ff0c408 + .long 0xa96efefe,0x3dfcfd4a + .long 0x54000000,0x3ff0c8de + .long 0xc29018c1,0x3e137bfa + .long 0x44000000,0x3ff0cdb9 + .long 0x6b55ea13,0x3e075409 + .long 0xd8000000,0x3ff0d299 + .long 0x17222364,0xbe2c80ba + .long 0x1a000000,0x3ff0d780 + .long 0xf030bcdb,0xbe36c2d9 + .long 0xae000000,0x3ff0db99 + .long 0x583eb4fd,0x3e23f39e + .long 0x7a000000,0x3ff0e08a + .long 0x1bc25b4a,0xbe2ee94c + .long 0x14000000,0x3ff0e581 + .long 0x2f4f4e2c,0xbe2785bf + .long 0x88000000,0x3ff0ea7d + .long 0xd8bcbdfc,0x3e3525a2 + .long 0xe6000000,0x3ff0ef7f + .long 0xed67b448,0x3e359433 + .long 0x16000000,0x3ff0f3b1 + .long 0xc931fbd5,0x3e2bf870 + .long 0x6a000000,0x3ff0f8be + .long 0xe78cbbad,0xbe32480c + .long 0xca000000,0x3ff0fcf8 + .long 0x795e6dd9,0x3e1f7d67 + .long 0x3a000000,0x3ff10211 + .long 0xfbf1714f,0x3e239cff + .long 0xce000000,0x3ff1072f + .long 0x55d6f69a,0xbe272643 + .long 0xac000000,0x3ff10b78 + .long 0xfdfa2d3b,0xbe286878 + .long 0xdc000000,0x3ff10fc5 + .long 0xd49627b5,0x3e1c95db + .long 0x0c000000,0x3ff114f5 + .long 0xf6a23fbe,0xbe2e06fe + .long 0xda000000,0x3ff1194b + .long 0x8f075abc,0x3e34ceb2 + .long 0xac000000,0x3ff11e86 + .long 0x90dc17c3,0x3e066bd5 + .long 0x40000000,0x3ff122e7 + .long 0xc04b5d49,0x3e359eb9 + .long 0x54000000,0x3ff1274c + .long 0xaf65cf99,0x3df316d4 + .long 0xec000000,0x3ff12bb5 + .long 0x7163f782,0x3e1b91b5 + .long 0x74000000,0x3ff13107 + .long 0xb1d8a38e,0xbe171e82 + .long 0x1c000000,0x3ff1357b + .long 0x142a679f,0xbe1645ad + .long 0x64000000,0x3ff139f3 + .long 0x03011ac3,0xbe119734 + .long 0x54000000,0x3ff13e70 + .long 0xceefd26a,0x3e12c753 + .long 0xf6000000,0x3ff142f1 + .long 0x1ae3077b,0xbdff336e + .long 0x50000000,0x3ff14778 + .long 0xa313efdd,0x3e3167c3 + .long 0x6e000000,0x3ff14c03 + .long 0xe0d315a6,0x3e23d347 + .long 0x56000000,0x3ff15093 + .long 0x8ec79515,0x3e34284e + .long 0x14000000,0x3ff15528 + .long 0x6ca0e852,0xbdfd2648 + .long 0xae000000,0x3ff159c1 + .long 0x33a7b5b1,0xbe21074d + .long 0x2c000000,0x3ff15e60 + .long 0x6aaf8c8a,0x3e311566 + .long 0x9c000000,0x3ff16303 + .long 0xdfa56cef,0xbe04190c + .long 0x02000000,0x3ff167ac + .long 0x96f8f747,0x3e30bf5f + .long 0x6c000000,0x3ff16c59 + .long 0x67e1e977,0x3dddd97d + .long 0xfc000000,0x3ff1701a + .long 0xf643cd8e,0xbe32877d + .long 0x80000000,0x3ff174d1 + .long 0x618d0ab4,0xbe318a71 + .long 0x1e000000,0x3ff1798d + .long 0xe66a5be3,0x3e373f3e + .long 0xe6000000,0x3ff17e4d + .long 0xca1da90a,0x3e0c534f + .long 0x0e000000,0x3ff1821f + .long 0xe06a8431,0xbe0ec5e5 + .long 0x32000000,0x3ff186e9 + .long 0xbb5373b7,0x3e06cc6a + .long 0x98000000,0x3ff18bb8 + .long 0x80c817c3,0x3e23ddc1 + .long 0x88000000,0x3ff18f95 + .long 0x70817aed,0xbe25cef4 + .long 0x7e000000,0x3ff1946e + .long 0x71612988,0x3e0b7bf2 + .long 0x22000000,0x3ff19853 + .long 0xdad7b32a,0xbe3008d5 + .long 0xc8000000,0x3ff19d35 + .long 0x558f59ee,0x3e3d2925 + .long 0x3c000000,0x3ff1a122 + .long 0x97916e24,0xbe112012 + .long 0xba000000,0x3ff1a60e + .long 0xf6235d3b,0xbe361be1 + .long 0x14000000,0x3ff1aa03 + .long 0xefaa3b2e,0x3e33a9bc + .long 0x8a000000,0x3ff1aef9 + .long 0x95d61bf1,0xbe3045d7 + .long 0xec000000,0x3ff1b2f5 + .long 0xe5b6bd1c,0x3e1a939c + .long 0xea000000,0x3ff1b6f5 + .long 0x00756ed3,0x3e118b3c + .long 0x02000000,0x3ff1bbfb + .long 0x34057364,0xbe20e5cf + .long 0x30000000,0x3ff1c003 + .long 0x701907b3,0xbe0e1837 + .long 0x0c000000,0x3ff1c40f + .long 0x7c6221b9,0xbe282207 + .long 0x9a000000,0x3ff1c81e + .long 0x71d8c073,0xbe09f360 + .long 0x4a000000,0x3ff1cd37 + .long 0x436616b2,0xbe3261a0 + .long 0x40000000,0x3ff1d14f + .long 0xc7c5e4df,0x3df7af5c + .long 0xfe000000,0x3ff1d56a + .long 0x5ae36062,0xbdfc61a1 + .long 0x88000000,0x3ff1d98a + .long 0xed667c98,0x3e167fd8 + .long 0xe6000000,0x3ff1ddad + .long 0xa010e825,0xbe16ada9 + .long 0x1c000000,0x3ff1e1d5 + .long 0x012f4beb,0xbdbb777c + .long 0x92000000,0x3ff1e70b + .long 0xe05d5c18,0x3e275a5a + .long 0x88000000,0x3ff1eb3b + .long 0x87963143,0x3e1f6ec9 + .long 0x6c000000,0x3ff1ef6f + .long 0xc77f5502,0xbdf400a5 + .long 0x44000000,0x3ff1f3a7 + .long 0x83209a84,0xbe2057a6 + .long 0x14000000,0x3ff1f7e3 + .long 0xcdb4bd2e,0x3e3b8696 + .long 0xea000000,0x3ff1fc22 + .long 0x7dac9b38,0xbe29872a + .long 0xc4000000,0x3ff20066 + .long 0x7e34701c,0x3e22a9a1 + .long 0xae000000,0x3ff204ae + .long 0xae177d59,0x3e2257cd + .long 0x4c000000,0x3ff207e7 + .long 0x6fe6d0dd,0xbe119fb7 + .long 0x60000000,0x3ff20c36 + .long 0x22ab7e20,0xbe18a6a1 + .long 0x94000000,0x3ff21089 + .long 0xca9c3288,0x3e2c8440 + .long 0xf2000000,0x3ff214e0 + .long 0x8575ebf1,0x3e200f9a + .long 0x80000000,0x3ff2193c + .long 0x219c164a,0xbe2140a7 + .long 0x44000000,0x3ff21d9c + .long 0x2238e180,0xbe326ebd + .long 0x44000000,0x3ff22200 + .long 0x0f5fa626,0xbe084ae9 + .long 0x10000000,0x3ff2254e + .long 0x20e924cc,0x3e34737d + .long 0x90000000,0x3ff229b9 + .long 0x7241c459,0xbe233bae + .long 0x60000000,0x3ff22e29 + .long 0xecaa31e6,0xbe2cc059 + .long 0x14000000,0x3ff23180 + .long 0x7a5a0dea,0x3e2bcde5 + .long 0x84000000,0x3ff235f7 + .long 0x52b90575,0x3e333da0 + .long 0x5a000000,0x3ff23a73 + .long 0x1b60c92e,0x3e3a7d2b + .long 0x24000000,0x3ff23dd3 + .long 0xb235ec84,0x3df512e9 + .long 0xc0000000,0x3ff24256 + .long 0x1f3855f6,0xbe1a9d64 + .long 0xd6000000,0x3ff246de + .long 0xfe758c34,0x3e12b491 + .long 0xde000000,0x3ff24a47 + .long 0x607a2edb,0xbe320de4 + .long 0xde000000,0x3ff24ed7 + .long 0xbc58ecd4,0x3dd8f375 + .long 0xde000000,0x3ff25246 + .long 0xda99c7ed,0xbe1ee42e + .long 0xe2000000,0x3ff256de + .long 0x88f4f655,0xbe220405 + .long 0xec000000,0x3ff25a53 + .long 0xc2b1fe7f,0x3e0eec7d + .long 0x0c000000,0x3ff25ef4 + .long 0xb6841168,0xbe1523a2 + .long 0x34000000,0x3ff2626f + .long 0x7056af50,0x3e200ef9 + .long 0x8a000000,0x3ff26717 + .long 0x8197860c,0xbe3643a3 + .long 0xe2000000,0x3ff26a98 + .long 0x52183874,0x3e204b1a + .long 0x84000000,0x3ff26f49 + .long 0x89899f96,0x3e2ce41f + .long 0x22000000,0x3ff272d1 + .long 0x2eba11d7,0x3e33edcf + .long 0x2e000000,0x3ff2778a + .long 0x9b69a0ac,0xbdd15cbf + .long 0x26000000,0x3ff27b18 + .long 0x4c9cfc18,0xbe384c83 + .long 0xd8000000,0x3ff27ea8 + .long 0x00ebd8b6,0x3e32abcc + .long 0x16000000,0x3ff2836e + .long 0xf0c27bf5,0xbe334f0d + .long 0x3e000000,0x3ff28705 + .long 0x2c84c19b,0x3e19ba08 + .long 0x34000000,0x3ff28a9f + .long 0x765ba98f,0xbe351348 + .long 0xd6000000,0x3ff28f70 + .long 0x0bb50259,0x3e25fd61 + .long 0x5c000000,0x3ff29311 + .long 0x1f0ba391,0x3e36468e + .long 0xbc000000,0x3ff296b4 + .long 0x5eb0d555,0xbe1b4b50 + .long 0xf4000000,0x3ff29a5a + .long 0x1684aafd,0x3e322e1b + .long 0x10000000,0x3ff29f3d + .long 0x7f3902f7,0xbe1143a0 + .long 0x04000000,0x3ff2a2ea + .long 0x9d87f711,0xbe296bf0 + .long 0xe0000000,0x3ff2a699 + .long 0xd317cd41,0xbe267680 + .long 0xa8000000,0x3ff2aa4c + .long 0x895632cb,0x3de71246 + .long 0x60000000,0x3ff2ae02 + .long 0x70ae3e69,0x3e383f37 + .long 0x48000000,0x3ff2b2f9 + .long 0x183dd905,0x3e019525 + .long 0xee000000,0x3ff2b6b5 + .long 0xb11ed34f,0xbde2956c + .long 0x92000000,0x3ff2ba75 + .long 0xebcee2d4,0x3e139d57 + .long 0x3a000000,0x3ff2be38 + .long 0x25efe1d2,0xbe24080b + .long 0xe8000000,0x3ff2c1fd + .long 0xca843d11,0xbe22f3d1 + .long 0xa0000000,0x3ff2c5c6 + .long 0x27157d0b,0x3e25d6d0 + .long 0x6a000000,0x3ff2c992 + .long 0x47c03cbd,0xbe1f901f + .long 0x46000000,0x3ff2cd61 + .long 0xc7d41505,0x3e0c9c6b + .long 0x3a000000,0x3ff2d133 + .long 0x4c9cbf49,0x3e335b1a + .long 0x4e000000,0x3ff2d508 + .long 0xf0d67754,0xbe31f5cc + .long 0x80000000,0x3ff2d8e0 + .long 0x08d6ec2a,0xbe14dddd + .long 0xd8000000,0x3ff2dcbb + .long 0xd1a31600,0x3df4f684 + .long 0x5a000000,0x3ff2e09a + .long 0xe7cb28ec,0x3e23d67d + .long 0x0c000000,0x3ff2e47c + .long 0x64fad19f,0xbe0416e4 + .long 0xf0000000,0x3ff2e860 + .long 0xc1845328,0x3e15f191 + .long 0x0e000000,0x3ff2ec49 + .long 0x0e8212a2,0xbe3407e4 + .long 0x66000000,0x3ff2f034 + .long 0xa6af14fb,0xbe119cdf + .long 0x00000000,0x3ff2f423 + .long 0xdd2ff4b2,0xbdd785b8 + .long 0xe0000000,0x3ff2f814 + .long 0x3c8bc168,0x3e0f9d26 + .long 0x0c000000,0x3ff2fc0a + .long 0x7f285f7f,0xbe25e721 + .long 0x54000000,0x3ff2feaf + .long 0xe4707431,0xbde3d3dc + .long 0x06000000,0x3ff302aa + .long 0x54e59df9,0x3e1b2c8a + .long 0x12000000,0x3ff306a8 + .long 0x5bf8bf35,0xbe35f560 + .long 0x78000000,0x3ff30aa9 + .long 0x1bf7ce44,0xbe201d62 + .long 0x40000000,0x3ff30eae + .long 0x268d3880,0xbda201ac + .long 0x6e000000,0x3ff312b6 + .long 0x78463451,0x3e323ba0 + .long 0x74000000,0x3ff31568 + .long 0x431ff6b5,0x3e27f197 + .long 0x5c000000,0x3ff31976 + .long 0x1d86063e,0xbe3cd285 + .long 0xb4000000,0x3ff31d87 + .long 0xde58cb2b,0xbe038490 + .long 0x86000000,0x3ff3219c + .long 0x0d0ecee4,0x3e2b6d7a + .long 0x04000000,0x3ff32457 + .long 0x67a045ac,0x3e081609 + .long 0xae000000,0x3ff32871 + .long 0x218aae81,0xbe2e422a + .long 0xde000000,0x3ff32c8f + .long 0x77d29102,0xbe27b381 + .long 0xa0000000,0x3ff32f50 + .long 0x1b3eff6b,0x3e21691f + .long 0xbe000000,0x3ff33374 + .long 0xd026a2c6,0x3e04f8ad + .long 0x72000000,0x3ff3379c + .long 0x4d48535f,0xbe22ae68 + .long 0x94000000,0x3ff33a63 + .long 0x1f2825ca,0x3df10fe6 + .long 0x4c000000,0x3ff33e91 + .long 0x0279faec,0x3e2a71d3 + .long 0xaa000000,0x3ff342c2 + .long 0x78d2f376,0xbe04bba3 + .long 0x46000000,0x3ff34590 + .long 0x998a41e9,0xbe03e672 + .long 0xc0000000,0x3ff349c7 + .long 0x36ef8407,0x3e3019b2 + .long 0xee000000,0x3ff34e02 + .long 0x645bac29,0x3e35fca4 + .long 0x20000000,0x3ff350d7 + .long 0x07bfe20f,0xbe25ac45 + .long 0x86000000,0x3ff35518 + .long 0x5aa1ebf5,0xbe2e6547 + .long 0xe0000000,0x3ff357f0 + .long 0xee89ceb5,0xbe287b40 + .long 0x8c000000,0x3ff35c38 + .long 0xa4e8d2ef,0x3e17e02f + .long 0x1c000000,0x3ff35f15 + .long 0xd982cb35,0xbe1b64a3 + .long 0x22000000,0x3ff36363 + .long 0x51a0e2b8,0xbe398839 + .long 0xfc000000,0x3ff367b4 + .long 0x5db6b242,0xbe243ecf + .long 0x5c000000,0x3ff36a98 + .long 0x04aa635d,0x3e2322a4 + .long 0xaa000000,0x3ff36ef0 + .long 0xdffe6c15,0xbe09399e + .long 0x5e000000,0x3ff371d8 + .long 0x25a11d1c,0xbe330e55 + .long 0xce000000,0x3ff374c1 + .long 0x3129afdf,0xbe268d7b + .long 0x3e000000,0x3ff37923 + .long 0xb97189dc,0xbe26657a + .long 0x10000000,0x3ff37c11 + .long 0xea29a16b,0xbe1fb083 + .long 0x1c000000,0x3ff38079 + .long 0x95fa7d47,0xbe340007 + .long 0x5a000000,0x3ff3836b + .long 0x5dc9ac54,0x3e10d40e + .long 0x12000000,0x3ff387da + .long 0x5012ad99,0x3e10b74e + .long 0xca000000,0x3ff38ad0 + .long 0xf7bd2128,0x3e2b0108 + .long 0x40000000,0x3ff38f46 + .long 0x9cc0ea9d,0x3e35e485 + .long 0x7e000000,0x3ff39241 + .long 0x770980a5,0x3e2ea300 + .long 0x90000000,0x3ff3953e + .long 0xd4c7a782,0xbe344ce9 + .long 0x96000000,0x3ff399bd + .long 0x940f9584,0xbe33e2fe + .long 0x3a000000,0x3ff39cbf + .long 0x24087e1a,0x3e2194f5 + .long 0xba000000,0x3ff39fc2 + .long 0x89c83cca,0xbe231d00 + .long 0x72000000,0x3ff3a44b + .long 0x3f2ced31,0x3e307ed8 + .long 0x98000000,0x3ff3a753 + .long 0x3dad14f7,0x3e34644c + .long 0xa0000000,0x3ff3aa5d + .long 0x44bf6650,0xbe198a0f + .long 0x32000000,0x3ff3aef0 + .long 0x83ce161a,0xbe13523e + .long 0xf2000000,0x3ff3b1fe + .long 0x3e4fb0ba,0xbe2b016e + .long 0x98000000,0x3ff3b50f + .long 0x5a266eb9,0xbe00c90d + .long 0x28000000,0x3ff3b9ac + .long 0x5d6435a9,0x3df6946b + .long 0x9a000000,0x3ff3bcc1 + .long 0xb51ea777,0x3deb71b8 + .long 0xfa000000,0x3ff3bfd8 + .long 0xddbd1e72,0x3e23310e + .long 0x4c000000,0x3ff3c2f2 + .long 0x3b61a362,0xbe036033 + .long 0xee000000,0x3ff3c79b + .long 0xfc551ad6,0xbe125411 + .long 0x22000000,0x3ff3caba + .long 0xf4f97f1b,0x3df6c6c6 + .long 0x4e000000,0x3ff3cdda + .long 0x34b9c5a5,0x3e265154 + .long 0x76000000,0x3ff3d0fc + .long 0x63686af4,0xbe11e3d1 + .long 0x6a000000,0x3ff3d5b3 + .long 0x41549461,0x3e22cde8 + .long 0x8e000000,0x3ff3d8da + .long 0x77ad6645,0xbe270a08 + .long 0xb2000000,0x3ff3dc03 + .long 0x15410840,0x3e008be3 + .long 0xdc000000,0x3ff3df2e + .long 0xcbeff11b,0xbe23e35d + .long 0x0c000000,0x3ff3e25c + .long 0x4f6d956b,0xbe26e298 + .long 0x44000000,0x3ff3e58b + .long 0xccfac644,0x3dfe9b4c + .long 0xee000000,0x3ff3ea55 + .long 0x67939d69,0x3e31da2e + .long 0x48000000,0x3ff3ed8a + .long 0x801a7764,0x3e1351ce + .long 0xb4000000,0x3ff3f0c0 + .long 0x501a20c7,0xbe3857a0 + .long 0x30000000,0x3ff3f3f9 + .long 0x57940f51,0xbdd234a1 + .long 0xc4000000,0x3ff3f733 + .long 0x3f2233b4,0xbe2ac2d6 + .long 0x6e000000,0x3ff3fa70 + .long 0xedca8a34,0x3e18e528 + .long 0x34000000,0x3ff3fdaf + .long 0x08b5b935,0x3de3efe5 + .long 0x16000000,0x3ff400f0 + .long 0x3ba01202,0x3e204ec9 + .long 0x64000000,0x3ff405d5 + .long 0x619a3fdd,0x3e3888e9 + .long 0x9c000000,0x3ff4091b + .long 0x5d7bbc67,0xbe35c660 + .long 0xf4000000,0x3ff40c63 + .long 0x371a5b37,0x3e312962 + .long 0x78000000,0x3ff40fae + .long 0xfd4427e8,0xbe266865 + .long 0x24000000,0x3ff412fb + .long 0xe4fe1e06,0xbe095508 + .long 0xfe000000,0x3ff41649 + .long 0x7f425eed,0xbe2d87f6 + .long 0x04000000,0x3ff4199b + .long 0xed161ccb,0x3e3a37a5 + .long 0x40000000,0x3ff41cee + .long 0xf32e9c13,0x3dd0ac84 + .long 0xb0000000,0x3ff42043 + .long 0x6f5637aa,0xbe33e54f + .long 0x56000000,0x3ff4239b + .long 0xb5063313,0xbe393f2e + .long 0x34000000,0x3ff426f5 + .long 0xbfa6486b,0xbe1a1603 + .type __libm_cbrtl_table_256,@object + .size __libm_cbrtl_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ccos.S b/external/sgx_libm/ia32/ccos.S new file mode 100644 index 0000000000..c17b68ec18 --- /dev/null +++ b/external/sgx_libm/ia32/ccos.S @@ -0,0 +1,181 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccos.c" + .text +..TXTST0: +# -- Begin ccos + .text + .align 16,0x90 + .globl ccos +ccos: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp + fldl 12(%ebp) + fldl 20(%ebp) + movzwl 26(%ebp), %ecx + andl $32752, %ecx + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 32(%esp) + cmpl $32752, %ecx + fstpl 16(%esp) + fstpl 24(%esp) + jl ..B1.4 +..B1.2: + testl $1048575, 24(%ebp) + jne ..B1.5 +..B1.3: + cmpl $0, 20(%ebp) + jne ..B1.5 +..B1.4: + movzbl 27(%ebp), %esi + notl %esi + movzbl 23(%esp), %edx + andl $128, %esi + andl $127, %edx + orl %esi, %edx + movb %dl, 23(%esp) +..B1.5: + addl $-32, %esp + movl 48(%esp), %ecx + lea 32(%esp), %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %esi, (%esp) + lea 4(%esp), %edx + movl %ecx, (%edx) + movl 20(%esi), %ecx + movl %ecx, 4(%edx) + movl 24(%esi), %ecx + movl %ecx, 8(%edx) + movl 28(%esi), %ecx + movl %ecx, 12(%edx) + call ccosh@PLT +..B1.10: + movl (%esi), %edx + addl $28, %esp + movl %edx, (%edi) + movl 4(%esi), %ecx + movl 8(%esi), %edx + movl 12(%esi), %esi + movl %ecx, 4(%edi) + movl %edx, 8(%edi) + movl %esi, 12(%edi) + movl 32(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.7 +..B1.6: + movl %edi, %eax + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.7: + call __stack_chk_fail@PLT + .align 16,0x90 + .type ccos,@function + .size ccos,.-ccos + .data +# -- End ccos + .text +# -- Begin ccosf + .text + .align 16,0x90 + .globl ccosf +ccosf: +# parameter 1: 32 + %esp +..B2.1: +..L3: + + pushl %ebx + subl $24, %esp + movzwl 38(%esp), %ecx + andl $32640, %ecx + movl 32(%esp), %eax + cmpl $32640, %ecx + movl 36(%esp), %edx + movl %eax, 20(%esp) + movl %edx, 16(%esp) + jl ..B2.3 +..B2.2: + testl $8388607, 36(%esp) + jne ..B2.4 +..B2.3: + movzbl 39(%esp), %eax + notl %eax + movzbl 19(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 19(%esp) +..B2.4: + addl $8, %esp + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + pushl 12(%esp) + pushl 12(%esp) + call ccoshf@PLT +..B2.7: + addl $24, %esp + popl %ebx + ret + .align 16,0x90 + .type ccosf,@function + .size ccosf,.-ccosf + .data +# -- End ccosf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ccosh.S b/external/sgx_libm/ia32/ccosh.S new file mode 100644 index 0000000000..258c30ebed --- /dev/null +++ b/external/sgx_libm/ia32/ccosh.S @@ -0,0 +1,468 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccosh.c" + .text +..TXTST0: +# -- Begin ccosh + .text + .align 16,0x90 + .globl ccosh +ccosh: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 88(%esp) + fstl 72(%esp) + fstpl 80(%esp) +..B1.2: + fnstcw 62(%esp) +..B1.3: + movzwl 18(%ebp), %esi + andl $32752, %esi + shrl $4, %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %esi + jge ..B1.19 +..B1.4: + testl %esi, %esi + jle ..B1.55 +..B1.5: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + jge ..B1.20 +..B1.6: + testl %ecx, %ecx + jle ..B1.53 +..B1.7: + cmpl $1034, %esi + jl ..B1.11 +..B1.8: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fldl 20(%ebp) + fstl (%esp) + addl $-16, %esp + fstpl (%esp) + fstpl 24(%esp) + movl %ecx, 32(%esp) + call cos@PLT +..B1.69: + fldl 24(%esp) + fmul %st, %st(1) + fldl 12(%ebp) + movl 32(%esp), %ecx + addl $16, %esp + fmulp %st, %st(1) + testl %ecx, %ecx + fxch %st(1) + fstpl 72(%esp) + jle ..B1.10 +..B1.9: + addl $-16, %esp + fldl 16(%esp) + fstpl (%esp) + fstpl 24(%esp) + call sin@PLT +..B1.70: + fldl 24(%esp) + addl $16, %esp + fmulp %st, %st(1) + fstpl 80(%esp) + jmp ..B1.46 +..B1.10: + fmull (%esp) + fstpl 80(%esp) + jmp ..B1.46 +..B1.11: + movzwl 62(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.52 +..B1.12: + orl $-64768, %ecx + movw %cx, 60(%esp) +..B1.13: + fldcw 60(%esp) +..B1.14: + movl $1, 56(%esp) +..B1.15: + fldl 12(%ebp) + fstpl 48(%esp) + addl $-32, %esp + fldl 20(%ebp) + lea 32(%esp), %edx + lea 44(%esp), %ecx + fstpt (%esp) + movl %edx, 12(%esp) + movl %ecx, 16(%esp) + call sincosl@PLT +..B1.16: + fldl 80(%esp) + lea 56(%esp), %edx + lea 68(%esp), %ecx + fstpt (%esp) + movl %edx, 12(%esp) + movl %ecx, 16(%esp) + call sinhcoshl@PLT +..B1.72: + addl $32, %esp +..B1.17: + fldt 12(%esp) + fldt 36(%esp) + fmulp %st, %st(1) + fstpl 72(%esp) + fldt (%esp) + fldt 24(%esp) + fmulp %st, %st(1) + fstpl 80(%esp) + cmpl $0, 56(%esp) + je ..B1.46 +..B1.18: + fldcw 62(%esp) + jmp ..B1.46 +..B1.19: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx +..B1.20: + testl %ecx, %ecx + jne ..B1.27 +..B1.21: + testl $1048575, 24(%ebp) + jne ..B1.27 +..B1.22: + cmpl $0, 20(%ebp) + jne ..B1.27 +..B1.23: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call cosh@PLT +..B1.73: + fldl 20(%ebp) + addl $16, %esp + fstpl 80(%esp) + cmpl $2047, %esi + fstpl 72(%esp) + jl ..B1.26 +..B1.24: + testl $1048575, 16(%ebp) + jne ..B1.46 +..B1.25: + cmpl $0, 12(%ebp) + jne ..B1.46 +..B1.26: + movzbl 87(%esp), %esi + movl %esi, %edx + movzbl 19(%ebp), %ecx + andl $127, %edx + shrl $7, %esi + shrl $7, %ecx + xorl %ecx, %esi + shll $7, %esi + orl %esi, %edx + movb %dl, 87(%esp) + jmp ..B1.46 +..B1.27: + cmpl $2047, %ecx + jge ..B1.41 +..B1.28: + movl 16(%ebp), %edx + andl $1048575, %edx + testl %esi, %esi + jne ..B1.35 +..B1.29: + testl %edx, %edx + jne ..B1.40 +..B1.30: + cmpl $0, 12(%ebp) + jne ..B1.36 +..B1.31: + fldl 20(%ebp) + fstl 8(%esp) + addl $-16, %esp + fstpl (%esp) + movl %ecx, 32(%esp) + call cos@PLT +..B1.74: + fldl 12(%ebp) + movl 32(%esp), %ecx + addl $16, %esp + fxch %st(1) + fstpl 72(%esp) + testl %ecx, %ecx + jle ..B1.33 +..B1.32: + addl $-16, %esp + fldl 24(%esp) + fstpl (%esp) + fstpl 16(%esp) + call sin@PLT +..B1.75: + fldl 16(%esp) + addl $16, %esp + fmulp %st, %st(1) + jmp ..B1.34 +..B1.33: + fmull 8(%esp) +..B1.34: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fxch %st(1) + fstpl 80(%esp) + fsubl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fstpl 64(%esp) + jmp ..B1.46 +..B1.35: + testl %edx, %edx + jne ..B1.40 +..B1.81: + cmpl $0, 12(%ebp) +..B1.36: + jne ..B1.40 +..B1.37: + fldl 12(%ebp) + cmpl $1023, %ecx + fstl 24(%esp) + fmul %st(0), %st + fstpl 16(%esp) + jge ..B1.39 +..B1.38: + fldl 16(%esp) + fstpl 72(%esp) + fldl 24(%esp) + fmull 20(%ebp) + fstpl 80(%esp) + jmp ..B1.46 +..B1.39: + fldl 20(%ebp) + fstl 8(%esp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.77: + addl $16, %esp + fstpl (%esp) + addl $-16, %esp + fldl 24(%esp) + fstpl (%esp) + call cos@PLT +..B1.76: + addl $16, %esp + fldl 16(%esp) + fmulp %st, %st(1) + fstpl 72(%esp) + fldl 24(%esp) + fmull (%esp) + fstpl 80(%esp) + jmp ..B1.46 +..B1.40: + fldl 12(%ebp) + fmul %st(0), %st + fstl 72(%esp) + fstpl 80(%esp) + jmp ..B1.46 +..B1.41: + cmpl $2047, %esi + jge ..B1.43 +..B1.42: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call cos@PLT + jmp ..B1.79 +..B1.43: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call cosh@PLT +..B1.79: + addl $16, %esp + fstpl 72(%esp) +..B1.44: + testl %esi, %esi + jle ..B1.59 +..B1.45: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.80: + addl $16, %esp + fstpl 80(%esp) +..B1.46: + movzwl 86(%esp), %edx + testl $32752, %edx + jne ..B1.50 +..B1.47: + testl $1048575, 84(%esp) + jne ..B1.49 +..B1.48: + cmpl $0, 80(%esp) + je ..B1.50 +..B1.49: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 64(%esp) +..B1.50: + movl 72(%esp), %edx + movl %edx, (%edi) + movl 76(%esp), %ecx + movl 80(%esp), %esi + movl 84(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 88(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.58 +..B1.51: + movl %edi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.52: + movl $0, 56(%esp) + jmp ..B1.15 +..B1.53: + testl $1048575, 24(%ebp) + jne ..B1.7 +..B1.54: + cmpl $0, 20(%ebp) + jne ..B1.7 + jmp ..B1.20 +..B1.55: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.56: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.19 +..B1.58: + call __stack_chk_fail@PLT +..B1.59: + testl $1048575, 16(%ebp) + jne ..B1.45 +..B1.60: + cmpl $0, 12(%ebp) + jne ..B1.45 +..B1.61: + testl $1048575, 24(%ebp) + jne ..B1.66 +..B1.62: + cmpl $0, 20(%ebp) + jne ..B1.66 +..B1.63: + movzbl 19(%ebp), %ecx + movzbl 27(%ebp), %edx + andl $128, %ecx + andl $128, %edx + shrl $7, %ecx + shrl $7, %edx + cmpl %ecx, %edx + je ..B1.65 +..B1.64: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 80(%esp) + jmp ..B1.46 +..B1.65: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 80(%esp) + jmp ..B1.46 +..B1.66: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 80(%esp) + jmp ..B1.46 + .align 16,0x90 + .type ccosh,@function + .size ccosh,.-ccosh + .data +# -- End ccosh + .section .rodata, "a" + .align 16 + .align 16 +_DBL_MAX_NORMAL: + .long -1 + .long 2146435071 + .type _DBL_MAX_NORMAL,@object + .size _DBL_MAX_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +_DBL_NZERO: + .long 0 + .long -2147483648 + .type _DBL_NZERO,@object + .size _DBL_NZERO,8 + .space 8, 0x00 # pad + .align 16 +_DBL_PZERO: + .long 0 + .long 0 + .type _DBL_PZERO,@object + .size _DBL_PZERO,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ccoshf.S b/external/sgx_libm/ia32/ccoshf.S new file mode 100644 index 0000000000..fdc1d3bfc2 --- /dev/null +++ b/external/sgx_libm/ia32/ccoshf.S @@ -0,0 +1,410 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccoshf.c" + .text +..TXTST0: +# -- Begin ccoshf + .text + .align 16,0x90 + .globl ccoshf +ccoshf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + xorl %eax, %eax + movl %eax, 48(%esp) + movl %eax, 52(%esp) +..B1.2: + fnstcw 38(%esp) +..B1.3: + movzwl 10(%ebp), %esi + andl $32640, %esi + shrl $7, %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %esi + jge ..B1.18 +..B1.4: + testl %esi, %esi + jle ..B1.47 +..B1.5: + movzwl 14(%ebp), %edi + andl $32640, %edi + shrl $7, %edi + cmpl $255, %edi + jge ..B1.19 +..B1.6: + testl %edi, %edi + jle ..B1.46 +..B1.7: + cmpl $138, %esi + jl ..B1.11 +..B1.8: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + flds 12(%ebp) + fsts 8(%esp) + addl $-16, %esp + fstps (%esp) + fstpl 16(%esp) + call cosf@PLT +..B1.57: + fldl 16(%esp) + addl $16, %esp + fmul %st, %st(1) + testl %edi, %edi + fxch %st(1) + fstps 48(%esp) + flds 8(%ebp) + fmulp %st, %st(1) + jle ..B1.10 +..B1.9: + addl $-16, %esp + flds 24(%esp) + fstps (%esp) + fstpl 16(%esp) + call sinf@PLT +..B1.58: + fldl 16(%esp) + addl $16, %esp + fmulp %st, %st(1) + fstps 52(%esp) + jmp ..B1.41 +..B1.10: + fmuls 8(%esp) + fstps 52(%esp) + jmp ..B1.41 +..B1.11: + movzwl 38(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.12: + orl $-64768, %edx + movw %dx, 36(%esp) +..B1.13: + fldcw 36(%esp) +..B1.14: + movl $1, %esi +..B1.15: + flds 8(%ebp) + fstps 32(%esp) + flds 12(%ebp) + fsts 24(%esp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.61: + addl $16, %esp + fstpl 16(%esp) + addl $-16, %esp + flds 40(%esp) + fstpl (%esp) + call cos@PLT +..B1.60: + addl $16, %esp + fstpl 24(%esp) + addl $-16, %esp + flds 48(%esp) + lea 16(%esp), %eax + lea 24(%esp), %edx + fstpl (%esp) + movl %eax, 8(%esp) + movl %edx, 12(%esp) + call sinhcosh@PLT +..B1.59: + addl $16, %esp +..B1.16: + fldl 24(%esp) + testl %esi, %esi + fmull 8(%esp) + fstps 48(%esp) + fldl 16(%esp) + fmull (%esp) + fstps 52(%esp) + je ..B1.41 +..B1.17: + fldcw 38(%esp) + jmp ..B1.41 +..B1.18: + movzwl 14(%ebp), %edi + andl $32640, %edi + shrl $7, %edi +..B1.19: + testl %edi, %edi + jne ..B1.24 +..B1.20: + testl $8388607, 12(%ebp) + jne ..B1.24 +..B1.21: + addl $-16, %esp + movl 8(%ebp), %eax + movl %eax, (%esp) + call coshf@PLT +..B1.62: + movl 12(%ebp), %eax + addl $16, %esp + fstps 48(%esp) + cmpl $255, %esi + movl %eax, 52(%esp) + jl ..B1.23 +..B1.22: + testl $8388607, 8(%ebp) + jne ..B1.41 +..B1.23: + movzbl 55(%esp), %edi + movl %edi, %eax + movzbl 11(%ebp), %esi + andl $127, %eax + shrl $7, %edi + shrl $7, %esi + xorl %esi, %edi + shll $7, %edi + orl %edi, %eax + movb %al, 55(%esp) + jmp ..B1.41 +..B1.24: + cmpl $255, %edi + jge ..B1.36 +..B1.25: + movl 8(%ebp), %eax + andl $8388607, %eax + testl %esi, %esi + jne ..B1.70 +..B1.26: + testl %eax, %eax + jne ..B1.31 +..B1.27: + flds 12(%ebp) + fsts 4(%esp) + addl $-16, %esp + fstps (%esp) + call cosf@PLT +..B1.63: + flds 8(%ebp) + addl $16, %esp + fxch %st(1) + fstps 48(%esp) + testl %edi, %edi + jle ..B1.29 +..B1.28: + addl $-16, %esp + flds 20(%esp) + fstps (%esp) + fstps 16(%esp) + call sinf@PLT +..B1.64: + flds 16(%esp) + addl $16, %esp + fmulp %st, %st(1) + jmp ..B1.30 +..B1.29: + fmuls 4(%esp) +..B1.30: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fxch %st(1) + fstps 52(%esp) + fsubl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fstpl 40(%esp) + jmp ..B1.41 +..B1.70: + testl %eax, %eax +..B1.31: + flds 8(%ebp) + jne ..B1.35 +..B1.32: + fld %st(0) + cmpl $127, %edi + fmul %st(1), %st + fstps 8(%esp) + jge ..B1.34 +..B1.33: + flds 8(%esp) + fstps 48(%esp) + fmuls 12(%ebp) + fstps 52(%esp) + jmp ..B1.41 +..B1.34: + addl $-16, %esp + movl 12(%ebp), %esi + movl %esi, (%esp) + fstps 20(%esp) + call sinf@PLT +..B1.66: + flds 20(%esp) + addl $16, %esp + fxch %st(1) + fstps (%esp) + addl $-16, %esp + movl %esi, (%esp) + fstps 20(%esp) + call cosf@PLT +..B1.65: + flds 20(%esp) + addl $16, %esp + flds 8(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstps 48(%esp) + fmuls (%esp) + fstps 52(%esp) + jmp ..B1.41 +..B1.35: + fmul %st(0), %st + fsts 48(%esp) + fstps 52(%esp) + jmp ..B1.41 +..B1.36: + cmpl $255, %esi + jge ..B1.38 +..B1.37: + addl $-16, %esp + movl 12(%ebp), %eax + movl %eax, (%esp) + call cosf@PLT + jmp ..B1.68 +..B1.38: + addl $-16, %esp + movl 8(%ebp), %eax + movl %eax, (%esp) + call coshf@PLT +..B1.68: + addl $16, %esp + fstps 48(%esp) +..B1.39: + testl %esi, %esi + jle ..B1.49 +..B1.40: + addl $-16, %esp + movl 12(%ebp), %eax + movl %eax, (%esp) + call sinf@PLT +..B1.69: + addl $16, %esp + fstps 52(%esp) +..B1.41: + movzwl 54(%esp), %eax + testl $32640, %eax + jne ..B1.44 +..B1.42: + testl $8388607, 52(%esp) + je ..B1.44 +..B1.43: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 40(%esp) +..B1.44: + movl 48(%esp), %eax + movl 52(%esp), %edx + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + xorl %esi, %esi + jmp ..B1.15 +..B1.46: + testl $8388607, 12(%ebp) + jne ..B1.7 + jmp ..B1.19 +..B1.47: + testl $8388607, 8(%ebp) + jne ..B1.5 + jmp ..B1.18 +..B1.49: + testl $8388607, 8(%ebp) + jne ..B1.40 +..B1.50: + testl $8388607, 12(%ebp) + jne ..B1.53 +..B1.51: + movzbl 11(%ebp), %edx + movzbl 15(%ebp), %eax + andl $128, %edx + andl $128, %eax + shrl $7, %edx + shrl $7, %eax + cmpl %edx, %eax + je ..B1.53 +..B1.52: + movl $-2147483648, 52(%esp) + jmp ..B1.41 +..B1.53: + movl $0, 52(%esp) + jmp ..B1.41 + .align 16,0x90 + .type ccoshf,@function + .size ccoshf,.-ccoshf + .data +# -- End ccoshf + .section .rodata, "a" + .align 16 + .align 16 +_DBL_MAX_NORMAL: + .long -1 + .long 2146435071 + .type _DBL_MAX_NORMAL,@object + .size _DBL_MAX_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .align 4 +.L_2il0floatpacket.6: + .long 0x80000000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ccoshl.S b/external/sgx_libm/ia32/ccoshl.S new file mode 100644 index 0000000000..208111211c --- /dev/null +++ b/external/sgx_libm/ia32/ccoshl.S @@ -0,0 +1,698 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccoshl.c" + .text +..TXTST0: +# -- Begin ccoshl + .text + .align 16,0x90 + .globl ccoshl +ccoshl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $308, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 244(%esp) + fstpt 112(%esp) + fldt 112(%esp) + fstpt 220(%esp) + fldt 220(%esp) + fstpt 232(%esp) +..B1.2: + fnstcw 62(%esp) +..B1.3: + movzwl 62(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.65 +..B1.4: + orl $-64768, %ecx + movw %cx, 60(%esp) +..B1.5: + fldcw 60(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.33 +..B1.8: + testl %ecx, %ecx + jle ..B1.60 +..B1.9: + movzwl 32(%ebp), %edx + andl $32767, %edx + movl %edx, 12(%esp) + cmpl $32767, %edx + jge ..B1.33 +..B1.10: + cmpl $0, 12(%esp) + jle ..B1.58 +..B1.11: + cmpl $16398, %ecx + jl ..B1.19 +..B1.12: + fldt _CONSTANTS@GOTOFF(%ebx) + fmul %st(0), %st + fldt 24(%ebp) + fstpt (%esp) + fldt (%esp) + addl $-16, %esp + fstpt (%esp) + fstpt 32(%esp) + call cosl@PLT +..B1.68: + fldt 32(%esp) + addl $16, %esp + fmul %st, %st(1) + fxch %st(1) + fstpt 220(%esp) + fldt 12(%ebp) + fmulp %st, %st(1) + cmpl $0, 12(%esp) + jle ..B1.14 +..B1.13: + addl $-16, %esp + fldt 16(%esp) + fstpt (%esp) + fstpt 32(%esp) + call sinl@PLT +..B1.69: + fldt 32(%esp) + addl $16, %esp + fmulp %st, %st(1) + jmp ..B1.15 +..B1.14: + fldt (%esp) + fmulp %st, %st(1) +..B1.15: + fstpt 232(%esp) + testl %edi, %edi + je ..B1.17 +..B1.16: + fldcw 62(%esp) +..B1.17: + movl 220(%esp), %edx + movl %edx, (%esi) + movl 232(%esp), %edx + movl %edx, 12(%esi) + movl 236(%esp), %edx + movl %edx, 16(%esi) + movl 224(%esp), %ecx + movl 228(%esp), %edi + movl 240(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 244(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.57 +..B1.18: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.19: + fldt 12(%ebp) + addl $-16, %esp + lea 164(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + call __libm_coshl_k80 +..B1.70: + addl $16, %esp +..B1.20: + fldt 36+_CONSTANTS@GOTOFF(%ebx) + movzwl 20(%ebp), %ecx + fadd %st, %st(1) + fxch %st(1) + fstpt (%esp) + andl $32767, %ecx + fldt 148(%esp) + cmpl $16183, %ecx + fld %st(0) + fldt 160(%esp) + movl (%esp), %edx + fadd %st, %st(1) + fld %st(1) + fxch %st(2) + fsub %st, %st(3) + movl %edx, 28(%esp) + fxch %st(3) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + fsub %st, %st(3) + fsubp %st, %st(3) + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(3) + faddp %st, %st(2) + jge ..B1.22 +..B1.21: + fstp %st(2) + fldt 12(%ebp) + lea 184(%esp), %eax + fldt 24+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt -12(%eax) + fldt -72(%eax) + movzwl -4(%eax), %ecx + movl %ecx, %edx + andl $32767, %edx + andl $-32768, %ecx + addl $-16639, %edx + orl $-49153, %ecx + fstpt (%eax) + movl %edx, 44(%esp) + movw %cx, -4(%eax) + jmp ..B1.24 +..B1.22: + fldt 12(%ebp) + addl $-16, %esp + lea 188(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + fxch %st(2) + fstpt 16(%esp) + fstpt -124(%edx) + fstpt 48(%esp) + call __libm_sinhl_k80 +..B1.71: + fldt 48(%esp) + fldt 64(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.23: + faddp %st, %st(3) + fxch %st(2) + fstpt (%esp) + lea 184(%esp), %eax + movl (%esp), %edx + movl %edx, 44(%esp) + fxch %st(1) +..B1.24: + fldt 172(%esp) + fld %st(0) + fld %st(3) + fldt (%eax) + fadd %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fsubr %st(1), %st + fsubrp %st, %st(1) + fstpt 64(%esp) + fldt 64(%esp) + addl $-16, %esp + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt 24(%ebp) + fstpt (%esp) + lea 212(%esp), %edx + movl %edx, 12(%esp) + fxch %st(1) + fstpt 64(%esp) + fstpt -100(%edx) + fstpt 48(%esp) + call __libm_cosl_k80 +..B1.72: + fldt 48(%esp) + fxch %st(1) + fstpt 96(%esp) + fldt 112(%esp) + fldt 64(%esp) + addl $16, %esp +..B1.25: + fldt 196(%esp) + fld %st(0) + fldt 208(%esp) + movzwl 32(%ebp), %edx + fadd %st, %st(1) + fld %st(1) + andl $32767, %edx + cmpl $16183, %edx + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fld %st(5) + fmul %st(3), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 80(%esp) + fmul %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%esp) + fldt 12+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(1) + jge ..B1.27 +..B1.26: + fldt 24(%ebp) + fldt 24+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 124(%esp) + fldt 112(%esp) + movzwl 132(%esp), %ecx + movl %ecx, %edx + andl $-32768, %ecx + andl $32767, %edx + orl $-49153, %ecx + addl $-16639, %edx + movw %cx, 132(%esp) + fstpt 136(%esp) + fldt 124(%esp) + movl %edx, 12(%esp) + jmp ..B1.29 +..B1.27: + fldt 24(%ebp) + addl $-16, %esp + lea 140(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + fxch %st(1) + fstpt -76(%edx) + fstpt 16(%esp) + fstpt -28(%edx) + fstpt -92(%edx) + call __libm_sinl_k80 +..B1.73: + fldt 48(%esp) + fldt 112(%esp) + fldt 16(%esp) + fldt 64(%esp) + addl $16, %esp +..B1.28: + fldt 124(%esp) + fmul %st(5), %st + fstpt 124(%esp) + fldt 124(%esp) + fldt 136(%esp) + fmulp %st, %st(6) + fxch %st(5) + fstpt 112(%esp) + fldt 112(%esp) + fstpt 136(%esp) + movl $0, 12(%esp) + fxch %st(2) + fxch %st(3) + fxch %st(4) +..B1.29: + fldt 112(%esp) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(6) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fsubr %st(6), %st + fsubrp %st, %st(6) + fxch %st(1) + fsub %st(5), %st + faddp %st, %st(1) + fstpt (%esp) + fld %st(1) + fldt 16(%esp) + fld %st(0) + fmul %st(3), %st + fxch %st(4) + fmulp %st, %st(3) + fldt 80(%esp) + addl $-32, %esp + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl 60(%esp), %edx + movl %edx, 24(%esp) + fstpt 128(%esp) + fstpt 64(%esp) + call __libm_scalbl_k80 +..B1.74: + fldt 64(%esp) + fldt 128(%esp) + addl $32, %esp +..B1.30: + fldt 64(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(2) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(4) + fstpt 220(%esp) + fldt (%esp) + addl $-32, %esp + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl 76(%esp), %edx + addl 44(%esp), %edx + movl %edx, 24(%esp) + call __libm_scalbl_k80 +..B1.75: + addl $32, %esp +..B1.31: + fstpt 232(%esp) + jmp ..B1.53 +..B1.33: + movl 28(%ebp), %edx +..B1.34: + testl %edx, %edx + jne ..B1.40 +..B1.85: + cmpl $0, 24(%ebp) +..B1.35: + jne ..B1.40 +..B1.36: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + movl %ecx, 16(%esp) + call coshl@PLT +..B1.76: + fldt 24(%ebp) + movl 16(%esp), %ecx + addl $16, %esp + fstpt 232(%esp) + cmpl $32767, %ecx + fstpt 220(%esp) + jl ..B1.39 +..B1.37: + cmpl $-2147483648, 16(%ebp) + jne ..B1.53 +..B1.38: + cmpl $0, 12(%ebp) + jne ..B1.53 +..B1.39: + movzbl 241(%esp), %eax + movl %eax, %edx + movzbl 21(%ebp), %ecx + andl $127, %edx + shrl $7, %eax + shrl $7, %ecx + xorl %ecx, %eax + shll $7, %eax + orl %eax, %edx + movb %dl, 241(%esp) + jmp ..B1.53 +..B1.40: + movzwl 32(%ebp), %eax + andl $32767, %eax + movl %eax, 12(%esp) + cmpl $32767, %eax + jge ..B1.43 +..B1.41: + fldt 12(%ebp) + fstpt 32(%esp) + fldt 32(%esp) + addl $-16, %esp + fstpt (%esp) + call coshl@PLT +..B1.78: + fstpt 16(%esp) + addl $16, %esp + fldt 24(%ebp) + fstpt 16(%esp) + fldt 16(%esp) + addl $-16, %esp + fstpt (%esp) + call cosl@PLT +..B1.77: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpt 220(%esp) + cmpl $0, 12(%esp) + jle ..B1.63 +..B1.42: + addl $-16, %esp + fldt 48(%esp) + fstpt (%esp) + call sinhl@PLT +..B1.80: + fstpt 16(%esp) + fldt 32(%esp) + fstpt (%esp) + call sinl@PLT +..B1.79: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpt 232(%esp) + jmp ..B1.53 +..B1.43: + cmpl $32767, %ecx + jge ..B1.45 +..B1.44: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + movl %edx, 16(%esp) + call cosl@PLT + jmp ..B1.82 +..B1.45: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + movl %edx, 16(%esp) + call coshl@PLT +..B1.82: + movl 16(%esp), %edx + addl $16, %esp + fstpt 220(%esp) +..B1.46: + cmpl $0, 16(%ebp) + jne ..B1.48 +..B1.47: + cmpl $0, 12(%ebp) + je ..B1.49 +..B1.48: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + call sinl@PLT +..B1.83: + addl $16, %esp + fstpt 232(%esp) + jmp ..B1.53 +..B1.49: + cmpl $-2147483648, %edx + jne ..B1.52 +..B1.50: + cmpl $0, 24(%ebp) + jne ..B1.52 +..B1.51: + movzbl 21(%ebp), %ecx + fldz + movzbl 33(%ebp), %edx + andl $128, %ecx + andl $128, %edx + shrl $7, %ecx + shrl $7, %edx + xorl %edx, %ecx + fmull ones@GOTOFF(%ebx,%ecx,8) + fstpt 232(%esp) + jmp ..B1.53 +..B1.52: + fldt 112(%esp) + fstpt 232(%esp) +..B1.53: + testl %edi, %edi + je ..B1.55 +..B1.54: + fldcw 62(%esp) +..B1.55: + movl 220(%esp), %edx + movl %edx, (%esi) + movl 232(%esp), %edx + movl %edx, 12(%esi) + movl 236(%esp), %edx + movl %edx, 16(%esi) + movl 224(%esp), %ecx + movl 228(%esp), %edi + movl 240(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 244(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.57 +..B1.56: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.57: + call __stack_chk_fail@PLT +..B1.58: + movl 28(%ebp), %edx + testl %edx, %edx + jne ..B1.11 +..B1.59: + cmpl $0, 24(%ebp) + jne ..B1.11 + jmp ..B1.35 +..B1.60: + cmpl $0, 16(%ebp) + jne ..B1.9 +..B1.61: + cmpl $0, 12(%ebp) + jne ..B1.9 + jmp ..B1.33 +..B1.63: + addl $-16, %esp + fldt 48(%esp) + fstpt (%esp) + call sinhl@PLT +..B1.84: + addl $16, %esp + fldt 16(%esp) + fmulp %st, %st(1) + fstpt 232(%esp) + jmp ..B1.53 +..B1.65: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type ccoshl,@function + .size ccoshl,.-ccoshl + .data +# -- End ccoshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,48 + .align 16 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .hidden __libm_sinl_k80 + .hidden __libm_cosl_k80 + .hidden __libm_sinhl_k80 + .hidden __libm_coshl_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ccosl.S b/external/sgx_libm/ia32/ccosl.S new file mode 100644 index 0000000000..fbbf3f444e --- /dev/null +++ b/external/sgx_libm/ia32/ccosl.S @@ -0,0 +1,183 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccosl.c" + .text +..TXTST0: +# -- Begin ccosl + .text + .align 16,0x90 + .globl ccosl +ccosl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.5@GOTOFF(%ebx) + movl %edx, 76(%esp) + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 40(%esp) +..B1.2: + fnstcw 2(%esp) +..B1.3: + movzwl 2(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.16 +..B1.4: + orl $-64768, %ecx + movw %cx, (%esp) +..B1.5: + fldcw (%esp) +..B1.6: + movl $1, %edi +..B1.7: + fldt 12(%ebp) + movzwl 32(%ebp), %edx + andl $32767, %edx + fstpt 40(%esp) + cmpl $32767, %edx + fldt 24(%ebp) + fstpt 28(%esp) + jl ..B1.10 +..B1.8: + cmpl $-2147483648, 28(%ebp) + jne ..B1.11 +..B1.9: + cmpl $0, 24(%ebp) + jne ..B1.11 +..B1.10: + movzbl 33(%ebp), %ecx + notl %ecx + movzbl 37(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 37(%esp) +..B1.11: + addl $-32, %esp + lea 84(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl -24(%ecx), %ecx + movl %ecx, (%edx) + movl 64(%esp), %ecx + movl %ecx, 4(%edx) + movl 68(%esp), %ecx + movl %ecx, 8(%edx) + movl 72(%esp), %ecx + movl %ecx, 12(%edx) + movl 76(%esp), %ecx + movl %ecx, 16(%edx) + movl 80(%esp), %ecx + movl %ecx, 20(%edx) + call ccoshl@PLT +..B1.19: + addl $28, %esp + fldt 52(%esp) + testl %edi, %edi + fstpt 4(%esp) + fldt 64(%esp) + fstpt 16(%esp) + je ..B1.13 +..B1.12: + fldcw 2(%esp) +..B1.13: + movl 4(%esp), %edx + movl %edx, (%esi) + movl 16(%esp), %edx + movl %edx, 12(%esi) + movl 20(%esp), %edx + movl %edx, 16(%esi) + movl 8(%esp), %ecx + movl 12(%esp), %edi + movl 24(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 76(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.15 +..B1.14: + movl %esi, %eax + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.15: + call __stack_chk_fail@PLT +..B1.16: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type ccosl,@function + .size ccosl,.-ccosl + .data +# -- End ccosl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ceil_wmt.S b/external/sgx_libm/ia32/ceil_wmt.S new file mode 100644 index 0000000000..98442a5cc8 --- /dev/null +++ b/external/sgx_libm/ia32/ceil_wmt.S @@ -0,0 +1,164 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ceil_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin ceil + .text + .align 16,0x90 + .globl ceil +ceil: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + call static_func + movl %eax, %edx + movsd 112(%esp), %xmm0 + pextrw $3, %xmm0, %eax + movl $32752, %ecx + andl %eax, %ecx + cmpl $17184, %ecx + ja .L_2TAG_PACKET_0.0.2 + je .L_2TAG_PACKET_1.0.2 + cmpl $16368, %ecx + jl .L_2TAG_PACKET_2.0.2 + movq (%edx), %xmm1 + addsd %xmm0, %xmm1 + subsd (%edx), %xmm1 + cmpnlesd %xmm1, %xmm0 + movd %xmm0, %eax + movsd %xmm1, 24(%esp) + fldl 24(%esp) + fadds 20(%edx,%eax,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: + pxor %xmm1, %xmm1 + cmpnltsd %xmm0, %xmm1 + movd %xmm1, %ecx + shrl $15, %eax + subl %eax, %ecx + flds 40(%edx,%ecx,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_1.0.2: + pextrw $0, %xmm0, %eax + andl $1, %eax + fldl 112(%esp) + fadds 48(%edx,%eax,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + cmpl $32752, %ecx + fldl 112(%esp) + jae .L_2TAG_PACKET_4.0.2 + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_4.0.2: + fldz + faddp +.L_2TAG_PACKET_3.0.2: + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type ceil,@function + .size ceil,.-ceil + .data +# -- End ceil + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 1065353216 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 1065353216 + .long 0 + .long 0 + .long 1056964608 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .type static_const_table,@object + .size static_const_table,128 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ceilf_gen.S b/external/sgx_libm/ia32/ceilf_gen.S new file mode 100644 index 0000000000..73bdfbe79c --- /dev/null +++ b/external/sgx_libm/ia32/ceilf_gen.S @@ -0,0 +1,140 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ceilf_gen.c" + .text +..TXTST0: +# -- Begin ceilf + .text + .align 16,0x90 + .globl ceilf +ceilf: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movzwl 18(%esp), %edx + andl $32640, %edx + shrl $7, %edx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $149, %edx + jge ..B1.11 +..B1.2: + cmpl $127, %edx + jl ..B1.7 +..B1.3: + flds .L_2il0floatpacket.0@GOTOFF(%eax) + flds 16(%esp) + fld %st(0) + fadd %st(2), %st + fstps (%esp) + flds (%esp) + fsubp %st, %st(2) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.6 +..B1.4: + fld1 + faddp %st, %st(1) +..B1.6: + addl $12, %esp + ret +..B1.7: + testl %edx, %edx + jne ..B1.10 +..B1.8: + testl $8388607, 16(%esp) + jne ..B1.10 +..B1.9: + flds 16(%esp) + addl $12, %esp + ret +..B1.10: + movzbl 19(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + movl 16(%esp), %edx + movl %edx, (%esp) + flds _pone_nzero@GOTOFF(%eax,%ecx,4) + addl $12, %esp + ret +..B1.11: + cmpl $150, %edx + jge ..B1.16 +..B1.12: + flds 16(%esp) + testb $1, 16(%esp) + je ..B1.15 +..B1.13: + fadds .L_2il0floatpacket.1@GOTOFF(%eax) +..B1.15: + addl $12, %esp + ret +..B1.16: + flds 16(%esp) + addl $12, %esp + ret + .align 16,0x90 + .type ceilf,@function + .size ceilf,.-ceilf + .data +# -- End ceilf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4b400000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x3f000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_pone_nzero: + .long 1065353216 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ceill.S b/external/sgx_libm/ia32/ceill.S new file mode 100644 index 0000000000..312cf5ecf6 --- /dev/null +++ b/external/sgx_libm/ia32/ceill.S @@ -0,0 +1,247 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ceill.c" + .text +..TXTST0: +# -- Begin ceill + .text + .align 16,0x90 + .globl ceill +ceill: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $16445, %eax + jge ..B1.21 +..B1.4: + cmpl $16383, %eax + jl ..B1.15 +..B1.5: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.6: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.7: + fldcw 12(%esp) +..B1.8: + movl $1, %ecx +..B1.9: + fldt 8(%ebp) + fld %st(0) + fldl _TWO_63H@GOTOFF(%edx) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt (%esp) + fldt (%esp) + fcompp + fnstsw %ax + sahf + jae ..B1.12 + jp ..B1.12 +..B1.10: + fldt (%esp) + faddl _ones@GOTOFF(%edx) + fstpt (%esp) +..B1.12: + testl %ecx, %ecx + je ..B1.14 +..B1.13: + fldcw 14(%esp) +..B1.14: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.15: + testl %eax, %eax + jne ..B1.20 +..B1.16: + cmpl $0, 12(%ebp) + jne ..B1.19 +..B1.17: + cmpl $0, 8(%ebp) + jne ..B1.19 +..B1.18: + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.19: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 16(%esp) +..B1.20: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl _pone_nzero@GOTOFF(%edx,%eax,8) + movl %ebp, %esp + popl %ebp + ret +..B1.21: + cmpl $16446, %eax + jge ..B1.30 +..B1.22: + testb $1, 8(%ebp) + je ..B1.29 +..B1.23: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.37 +..B1.24: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.25: + fldcw 12(%esp) +..B1.26: + fldt 8(%ebp) + faddl _halfs@GOTOFF(%edx) + fstpt (%esp) +..B1.27: + fldcw 14(%esp) +..B1.28: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.29: + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.30: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.31: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.32: + fldcw 12(%esp) +..B1.33: + fldt 8(%ebp) + fmull _ones@GOTOFF(%edx) + fstpt (%esp) +..B1.34: + fldcw 14(%esp) +..B1.35: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.36: + xorl %ecx, %ecx + jmp ..B1.9 +..B1.37: + fldt 8(%ebp) + faddl _halfs@GOTOFF(%edx) + fstpt (%esp) + jmp ..B1.28 +..B1.38: + fldt 8(%ebp) + fmull _ones@GOTOFF(%edx) + fstpt (%esp) + jmp ..B1.35 + .align 16,0x90 + .type ceill,@function + .size ceill,.-ceill + .data +# -- End ceill + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_pone_nzero: + .long 0 + .long 1072693248 + .long 0 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,16 + .align 4 +_halfs: + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .type _halfs,@object + .size _halfs,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cexp_gen.S b/external/sgx_libm/ia32/cexp_gen.S new file mode 100644 index 0000000000..34e0d3f9ce --- /dev/null +++ b/external/sgx_libm/ia32/cexp_gen.S @@ -0,0 +1,739 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cexp_gen.c" + .text +..TXTST0: +# -- Begin __libm_internal_cexp + .text + .align 16,0x90 + .hidden __libm_internal_cexp + .globl __libm_internal_cexp +__libm_internal_cexp: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 72(%esp) + fsts (%esp) + fstl 56(%esp) + fstpl 64(%esp) +..B1.2: + fnstcw 42(%esp) +..B1.3: + movzwl 18(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %edx + jge ..B1.18 +..B1.4: + testl %edx, %edx + jle ..B1.46 +..B1.5: + movzwl 26(%ebp), %edi + andl $32752, %edi + shrl $4, %edi + cmpl $2047, %edi + jge ..B1.19 +..B1.6: + testl %edi, %edi + jle ..B1.44 +..B1.7: + cmpl $1034, %edx + jl ..B1.11 +..B1.8: + fldl 20(%ebp) + movzbl 19(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + fstl 16(%esp) + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + fldt _BIG_SMALL@GOTOFF(%ebx,%edx) + fmul %st(0), %st + fstpt (%esp) + addl $-16, %esp + fstpt (%esp) + call cosl@PLT +..B1.56: + addl $16, %esp + fldt (%esp) + testl %edi, %edi + fmulp %st, %st(1) + fstpl 56(%esp) + jle ..B1.10 +..B1.9: + addl $-16, %esp + fldl 32(%esp) + fstpt (%esp) + call sinl@PLT +..B1.57: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpl 64(%esp) + jmp ..B1.34 +..B1.10: + fldl 16(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpl 64(%esp) + jmp ..B1.34 +..B1.11: + movzwl 42(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.43 +..B1.12: + orl $-64768, %ecx + movw %cx, 40(%esp) +..B1.13: + fldcw 40(%esp) +..B1.14: + movl $1, 36(%esp) +..B1.15: + fldl 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call expl@PLT +..B1.59: + fldl 20(%ebp) + addl $-16, %esp + lea 32(%esp), %edx + lea 44(%esp), %ecx + fstpt (%esp) + movl %edx, 12(%esp) + movl %ecx, 16(%esp) + fstpt 24(%edx) + call sincosl@PLT +..B1.58: + fldt 56(%esp) + addl $32, %esp +..B1.16: + fldt 12(%esp) + fmul %st(1), %st + fstpl 56(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpl 64(%esp) + cmpl $0, 36(%esp) + je ..B1.34 +..B1.17: + fldcw 42(%esp) + jmp ..B1.34 +..B1.18: + movzwl 26(%ebp), %edi + andl $32752, %edi + shrl $4, %edi +..B1.19: + testl %edi, %edi + jne ..B1.23 +..B1.20: + testl $1048575, 24(%ebp) + jne ..B1.23 +..B1.21: + cmpl $0, 20(%ebp) + jne ..B1.23 +..B1.22: + fldl 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call expl@PLT +..B1.60: + fldl 20(%ebp) + addl $16, %esp + fstpl 64(%esp) + fstpl 56(%esp) + jmp ..B1.34 +..B1.23: + cmpl $2047, %edi + jge ..B1.26 +..B1.24: + fldl 12(%ebp) + addl $-16, %esp + fstpt (%esp) + movl %edx, 28(%esp) + call expl@PLT +..B1.62: + fstpt 16(%esp) + fldl 20(%ebp) + movl 28(%esp), %edx + addl $16, %esp + fstl 16(%esp) + addl $-16, %esp + fstpt (%esp) + movl %edx, 28(%esp) + call cosl@PLT +..B1.61: + movl 28(%esp), %edx + addl $16, %esp + testl %edi, %edi + fldt (%esp) + fmulp %st, %st(1) + fstpl 56(%esp) + jle ..B1.49 +..B1.25: + addl $-16, %esp + fldl 32(%esp) + fstpt (%esp) + call sinl@PLT +..B1.63: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpl 64(%esp) + jmp ..B1.34 +..B1.26: + cmpl $2047, %edx + jge ..B1.28 +..B1.27: + fldl 20(%ebp) + addl $-16, %esp + fstpt (%esp) + call sinl@PLT +..B1.64: + addl $16, %esp + fstl 56(%esp) + fstpl 64(%esp) + jmp ..B1.34 +..B1.28: + testl $1048575, 16(%ebp) + jne ..B1.30 +..B1.29: + cmpl $0, 12(%ebp) + je ..B1.31 +..B1.30: + fldl 12(%ebp) + fmul %st(0), %st + fstl 56(%esp) + fldl 20(%ebp) + fmulp %st, %st(1) + fstpl 64(%esp) + jmp ..B1.34 +..B1.31: + movzbl 19(%ebp), %edx + testl $128, %edx + je ..B1.33 +..B1.32: + fldl 20(%ebp) + fmul %st(0), %st + fstpl 20(%ebp) + flds (%esp) + fstl 56(%esp) + fstpl 64(%esp) + jmp ..B1.34 +..B1.33: + fldl 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call expl@PLT +..B1.66: + fldl 20(%ebp) + addl $16, %esp + fxch %st(1) + fstpl 56(%esp) + addl $-16, %esp + fstpt (%esp) + call sinl@PLT +..B1.65: + addl $16, %esp + fstpl 64(%esp) +..B1.34: + movzwl 62(%esp), %edx + testl $32752, %edx + jne ..B1.37 +..B1.35: + testl $1048575, 60(%esp) + jne ..B1.40 +..B1.36: + cmpl $0, 56(%esp) + jne ..B1.40 +..B1.37: + movzwl 70(%esp), %edx + testl $32752, %edx + jne ..B1.41 +..B1.38: + testl $1048575, 68(%esp) + jne ..B1.40 +..B1.39: + cmpl $0, 64(%esp) + je ..B1.41 +..B1.40: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 48(%esp) +..B1.41: + movl 56(%esp), %edx + movl %edx, (%esi) + movl 60(%esp), %ecx + movl 64(%esp), %edi + movl 68(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 72(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.53 +..B1.42: + movl %esi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.43: + movl $0, 36(%esp) + jmp ..B1.15 +..B1.44: + testl $1048575, 24(%ebp) + jne ..B1.7 +..B1.45: + cmpl $0, 20(%ebp) + jne ..B1.7 + jmp ..B1.19 +..B1.46: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.47: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.18 +..B1.49: + testl %edx, %edx + jne ..B1.52 +..B1.50: + testl $1048575, 16(%ebp) + jne ..B1.52 +..B1.51: + cmpl $0, 12(%ebp) + je ..B1.25 +..B1.52: + fldl 16(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpl 64(%esp) + jmp ..B1.34 +..B1.53: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __libm_internal_cexp,@function + .size __libm_internal_cexp,.-__libm_internal_cexp + .data +# -- End __libm_internal_cexp + .text +# -- Begin cexp + .text + .align 16,0x90 + .globl cexp +cexp: +# parameter 1: 12 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + fldz + fldl 12(%ebp) + fldl 20(%ebp) + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 80(%esp) + fstpl 72(%esp) + fstpl 64(%esp) + fsts (%esp) + fstl 48(%esp) + fstpl 56(%esp) +..B2.2: + fnstcw 38(%esp) +..B2.3: + movzwl 70(%esp), %esi + andl $32752, %esi + shrl $4, %esi + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + cmpl $2047, %esi + jge ..B2.18 +..B2.4: + testl %esi, %esi + jle ..B2.46 +..B2.5: + movzwl 78(%esp), %edi + andl $32752, %edi + shrl $4, %edi + cmpl $2047, %edi + jge ..B2.19 +..B2.6: + testl %edi, %edi + jle ..B2.44 +..B2.7: + cmpl $1034, %esi + jl ..B2.11 +..B2.8: + fldl 72(%esp) + movzbl 71(%esp), %edx + andl $128, %edx + shrl $7, %edx + fstl 16(%esp) + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _BIG_SMALL@GOTOFF(%ebx,%ecx) + fmul %st(0), %st + fstpt (%esp) + addl $-16, %esp + fstpt (%esp) + call cosl@PLT +..B2.56: + addl $16, %esp + fldt (%esp) + testl %edi, %edi + fmulp %st, %st(1) + fstpl 48(%esp) + jle ..B2.10 +..B2.9: + addl $-16, %esp + fldl 32(%esp) + fstpt (%esp) + call sinl@PLT +..B2.57: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpl 56(%esp) + jmp ..B2.34 +..B2.10: + fldl 16(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpl 56(%esp) + jmp ..B2.34 +..B2.11: + movzwl 38(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.43 +..B2.12: + orl $-64768, %edx + movw %dx, 36(%esp) +..B2.13: + fldcw 36(%esp) +..B2.14: + movl $1, %esi +..B2.15: + addl $-16, %esp + fldl 80(%esp) + fstpt (%esp) + call expl@PLT +..B2.59: + addl $-16, %esp + fldl 104(%esp) + lea 32(%esp), %eax + lea 44(%esp), %edx + fstpt (%esp) + movl %eax, 12(%esp) + movl %edx, 16(%esp) + fstpt 24(%eax) + call sincosl@PLT +..B2.58: + fldt 56(%esp) + addl $32, %esp +..B2.16: + fldt 12(%esp) + testl %esi, %esi + fmul %st(1), %st + fstpl 48(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpl 56(%esp) + je ..B2.34 +..B2.17: + fldcw 38(%esp) + jmp ..B2.34 +..B2.18: + movzwl 78(%esp), %edi + andl $32752, %edi + shrl $4, %edi +..B2.19: + testl %edi, %edi + jne ..B2.23 +..B2.20: + testl $1048575, 76(%esp) + jne ..B2.23 +..B2.21: + cmpl $0, 72(%esp) + jne ..B2.23 +..B2.22: + addl $-16, %esp + fldl 80(%esp) + fstpt (%esp) + call expl@PLT +..B2.60: + addl $16, %esp + fldl 72(%esp) + fstpl 56(%esp) + fstpl 48(%esp) + jmp ..B2.34 +..B2.23: + cmpl $2047, %edi + jge ..B2.26 +..B2.24: + fldl 64(%esp) + addl $-16, %esp + fstpt (%esp) + call expl@PLT +..B2.62: + fstpt 16(%esp) + addl $16, %esp + fldl 72(%esp) + fstl 16(%esp) + addl $-16, %esp + fstpt (%esp) + call cosl@PLT +..B2.61: + addl $16, %esp + fldt (%esp) + testl %edi, %edi + fmulp %st, %st(1) + fstpl 48(%esp) + jle ..B2.49 +..B2.25: + addl $-16, %esp + fldl 32(%esp) + fstpt (%esp) + call sinl@PLT +..B2.63: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpl 56(%esp) + jmp ..B2.34 +..B2.26: + cmpl $2047, %esi + jge ..B2.28 +..B2.27: + addl $-16, %esp + fldl 88(%esp) + fstpt (%esp) + call sinl@PLT +..B2.64: + addl $16, %esp + fstl 48(%esp) + fstpl 56(%esp) + jmp ..B2.34 +..B2.28: + testl $1048575, 68(%esp) + jne ..B2.30 +..B2.29: + cmpl $0, 64(%esp) + je ..B2.31 +..B2.30: + fldl 64(%esp) + fmul %st(0), %st + fstl 48(%esp) + fldl 72(%esp) + fmulp %st, %st(1) + fstpl 56(%esp) + jmp ..B2.34 +..B2.31: + movzbl 71(%esp), %eax + testl $128, %eax + je ..B2.33 +..B2.32: + fldl 72(%esp) + fmul %st(0), %st + fstpl 72(%esp) + flds (%esp) + fstl 48(%esp) + fstpl 56(%esp) + jmp ..B2.34 +..B2.33: + addl $-16, %esp + fldl 80(%esp) + fstpt (%esp) + call expl@PLT +..B2.66: + addl $16, %esp + fstpl 48(%esp) + addl $-16, %esp + fldl 88(%esp) + fstpt (%esp) + call sinl@PLT +..B2.65: + addl $16, %esp + fstpl 56(%esp) +..B2.34: + movzwl 54(%esp), %eax + testl $32752, %eax + jne ..B2.37 +..B2.35: + testl $1048575, 52(%esp) + jne ..B2.40 +..B2.36: + cmpl $0, 48(%esp) + jne ..B2.40 +..B2.37: + movzwl 62(%esp), %eax + testl $32752, %eax + jne ..B2.41 +..B2.38: + testl $1048575, 60(%esp) + jne ..B2.40 +..B2.39: + cmpl $0, 56(%esp) + je ..B2.41 +..B2.40: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 40(%esp) +..B2.41: + fldl 48(%esp) + movl 8(%ebp), %eax + movl 52(%esp), %ecx + movl 48(%esp), %edx + movl 60(%esp), %edi + movl 56(%esp), %esi + fstp %st(0) + fldl 56(%esp) + fstp %st(0) + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl %esi, 8(%eax) + movl %edi, 12(%eax) + movl 80(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B2.53 +..B2.42: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B2.43: + xorl %esi, %esi + jmp ..B2.15 +..B2.44: + testl $1048575, 76(%esp) + jne ..B2.7 +..B2.45: + cmpl $0, 72(%esp) + jne ..B2.7 + jmp ..B2.19 +..B2.46: + testl $1048575, 68(%esp) + jne ..B2.5 +..B2.47: + cmpl $0, 64(%esp) + jne ..B2.5 + jmp ..B2.18 +..B2.49: + testl %esi, %esi + jne ..B2.52 +..B2.50: + testl $1048575, 68(%esp) + jne ..B2.52 +..B2.51: + cmpl $0, 64(%esp) + je ..B2.25 +..B2.52: + fldl 16(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpl 56(%esp) + jmp ..B2.34 +..B2.53: + call __stack_chk_fail@PLT + .align 16,0x90 + .type cexp,@function + .size cexp,.-cexp + .data +# -- End cexp + .section .rodata, "a" + .align 16 + .align 16 +_BIG_SMALL: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _BIG_SMALL,@object + .size _BIG_SMALL,24 + .space 8, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cexpf_gen.S b/external/sgx_libm/ia32/cexpf_gen.S new file mode 100644 index 0000000000..59cec37b81 --- /dev/null +++ b/external/sgx_libm/ia32/cexpf_gen.S @@ -0,0 +1,223 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cexpf_gen.c" + .text +..TXTST0: +# -- Begin __libm_internal_cexpf + .text + .align 16,0x90 + .hidden __libm_internal_cexpf + .globl __libm_internal_cexpf +__libm_internal_cexpf: +# parameter 1: 64 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $56, %esp + xorl %ecx, %ecx + flds 64(%esp) + flds 68(%esp) + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 44(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpl 36(%esp) + movl %ecx, 4(%esp) + movl %ecx, 8(%esp) + fstpl 28(%esp) + addl $-32, %esp + movl 60(%esp), %edx + lea 44(%esp), %eax + movl 20(%eax), %ecx + movl %eax, (%esp) + lea 4(%esp), %eax + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 68(%esp), %edx + movl 72(%esp), %ecx + movl %edx, 8(%eax) + movl %ecx, 12(%eax) + call cexp@PLT +..B1.11: + addl $28, %esp + fldl 12(%esp) + fsts 4(%esp) + fldl 20(%esp) + movzwl 6(%esp), %eax + testl $32640, %eax + fsts 8(%esp) + jne ..B1.3 +..B1.2: + testl $8388607, 4(%esp) + jne ..B1.5 +..B1.3: + movzwl 10(%esp), %eax + testl $32640, %eax + jne ..B1.6 +..B1.4: + testl $8388607, 8(%esp) + je ..B1.6 +..B1.5: + fstp %st(0) + fstp %st(0) + flds .L_2il0floatpacket.4@GOTOFF(%ebx) + fmul %st(0), %st + fstps (%esp) + flds 4(%esp) + flds 8(%esp) +..B1.6: + fxch %st(1) + fstps 4(%esp) + fstps 8(%esp) + movl 44(%esp), %ecx + xorl %esp, %ecx + movl 4(%esp), %eax + movl 8(%esp), %edx + cmpl %gs:20, %ecx + jne ..B1.8 +..B1.7: + addl $56, %esp + popl %ebx + ret +..B1.8: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __libm_internal_cexpf,@function + .size __libm_internal_cexpf,.-__libm_internal_cexpf + .data +# -- End __libm_internal_cexpf + .text +# -- Begin cexpf + .text + .align 16,0x90 + .globl cexpf +cexpf: +# parameter 1: 64 + %esp +..B2.1: +..L3: + + pushl %ebx + subl $56, %esp + xorl %ecx, %ecx + flds 64(%esp) + flds 68(%esp) + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 44(%esp) + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + fstpl 36(%esp) + movl %ecx, 4(%esp) + movl %ecx, 8(%esp) + fstpl 28(%esp) + addl $-32, %esp + movl 60(%esp), %edx + lea 44(%esp), %eax + movl 20(%eax), %ecx + movl %eax, (%esp) + lea 4(%esp), %eax + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 68(%esp), %edx + movl 72(%esp), %ecx + movl %edx, 8(%eax) + movl %ecx, 12(%eax) + call cexp@PLT +..B2.11: + addl $28, %esp + fldl 12(%esp) + fsts 4(%esp) + fldl 20(%esp) + movzwl 6(%esp), %eax + testl $32640, %eax + fsts 8(%esp) + jne ..B2.3 +..B2.2: + testl $8388607, 4(%esp) + jne ..B2.5 +..B2.3: + movzwl 10(%esp), %eax + testl $32640, %eax + jne ..B2.6 +..B2.4: + testl $8388607, 8(%esp) + je ..B2.6 +..B2.5: + fstp %st(0) + fstp %st(0) + flds .L_2il0floatpacket.4@GOTOFF(%ebx) + fmul %st(0), %st + fstps (%esp) + flds 4(%esp) + flds 8(%esp) +..B2.6: + fxch %st(1) + fstps 4(%esp) + fstps 8(%esp) + movl 44(%esp), %ecx + xorl %esp, %ecx + movl 4(%esp), %eax + movl 8(%esp), %edx + cmpl %gs:20, %ecx + jne ..B2.8 +..B2.7: + addl $56, %esp + popl %ebx + ret +..B2.8: + call __stack_chk_fail@PLT + .align 16,0x90 + .type cexpf,@function + .size cexpf,.-cexpf + .data +# -- End cexpf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.4: + .long 0x00800000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cexpl.S b/external/sgx_libm/ia32/cexpl.S new file mode 100644 index 0000000000..41bcd10d22 --- /dev/null +++ b/external/sgx_libm/ia32/cexpl.S @@ -0,0 +1,611 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cexpl.c" + .text +..TXTST0: +# -- Begin cexpl + .text + .align 16,0x90 + .globl cexpl +cexpl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + movl %edx, 228(%esp) + fstpt 96(%esp) + fldt 96(%esp) + fstpt 204(%esp) + fldt 204(%esp) + fstpt 216(%esp) +..B1.2: + fnstcw 46(%esp) +..B1.3: + movzwl 46(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.61 +..B1.4: + orl $-64768, %ecx + movw %cx, 44(%esp) +..B1.5: + fldcw 44(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.31 +..B1.8: + testl %edx, %edx + jle ..B1.54 +..B1.9: + movzwl 32(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.31 +..B1.10: + testl %ecx, %ecx + jle ..B1.52 +..B1.11: + fldt 12(%ebp) + lea 180(%esp), %ecx + fstpt (%ecx) + fldt -84(%ecx) + fstpt 12(%ecx) + addl $-16, %esp + lea 172(%esp), %edx + movl %edx, (%esp) + movl %ecx, 4(%esp) + call __libm_expl_k80 +..B1.64: + fstpt 96(%esp) + addl $16, %esp +..B1.12: + movzwl 164(%esp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.51 +..B1.13: + testl %edx, %edx + je ..B1.22 +..B1.14: + fldt 36+_CONSTANTS@GOTOFF(%ebx) + fldt 80(%esp) + faddp %st, %st(1) + fstpt (%esp) + fldt 156(%esp) + fld %st(0) + fldt 168(%esp) + movl (%esp), %edx + fadd %st, %st(1) + fld %st(1) + fxch %st(2) + fsub %st, %st(3) + movl %edx, 28(%esp) + fxch %st(3) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fmul %st, %st(2) + fld %st(2) + fsub %st(4), %st + fsubrp %st, %st(3) + fxch %st(2) + fstpt 32(%esp) + fldt 32(%esp) + addl $-16, %esp + fsubrp %st, %st(3) + faddp %st, %st(2) + fldt 24(%ebp) + fstpt (%esp) + lea 148(%esp), %ecx + movl %ecx, 12(%esp) + fstpt -84(%ecx) + fstpt -68(%ecx) + call __libm_cosl_k80 +..B1.65: + fldt 80(%esp) + fldt 64(%esp) + addl $16, %esp +..B1.15: + fldt 132(%esp) + fld %st(0) + fldt 144(%esp) + movzwl 32(%ebp), %edx + fadd %st, %st(1) + andl $32767, %edx + fxch %st(1) + fsub %st, %st(2) + cmpl $16183, %edx + fxch %st(2) + fsubrp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fld %st(0) + fsub %st(3), %st + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st(4), %st + fxch %st(1) + fmulp %st, %st(4) + fldt 12+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(1) + jge ..B1.17 +..B1.16: + fldt 24(%ebp) + fldt 24+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 108(%esp) + fldt 96(%esp) + movzwl 116(%esp), %ecx + movl %ecx, %edx + andl $-32768, %ecx + andl $32767, %edx + orl $-49153, %ecx + addl $-16639, %edx + movw %cx, 116(%esp) + fstpt 120(%esp) + fldt 108(%esp) + movl %edx, 12(%esp) + jmp ..B1.19 +..B1.17: + fldt 24(%ebp) + addl $-16, %esp + lea 124(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + fxch %st(3) + fstpt 16(%esp) + fxch %st(2) + fstpt -92(%edx) + fxch %st(1) + fstpt -60(%edx) + fstpt -44(%edx) + call __libm_sinl_k80 +..B1.66: + fldt 80(%esp) + fldt 64(%esp) + fldt 32(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.18: + fldt 108(%esp) + fmul %st(5), %st + fstpt 108(%esp) + fldt 108(%esp) + fldt 120(%esp) + fmulp %st, %st(6) + fxch %st(5) + fstpt 96(%esp) + fldt 96(%esp) + fstpt 120(%esp) + movl $0, 12(%esp) + fxch %st(4) +..B1.19: + fldt 96(%esp) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(4) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(3) + fsub %st(2), %st + fsubrp %st, %st(4) + fxch %st(1) + fsub %st(3), %st + faddp %st, %st(1) + fld %st(3) + fmul %st(5), %st + fldt 32(%esp) + addl $-32, %esp + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + fstpt (%esp) + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fstpt 12(%esp) + movl 60(%esp), %edx + movl %edx, 24(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt 80(%esp) + fstpt 96(%esp) + call __libm_scalbl_k80 +..B1.67: + fldt 96(%esp) + fldt 80(%esp) + fldt 32(%esp) + addl $32, %esp +..B1.20: + fxch %st(3) + fstpt 204(%esp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(2) + fldt 32(%esp) + addl $-32, %esp + fld %st(0) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%esp) + movl 60(%esp), %edx + addl 44(%esp), %edx + movl %edx, 24(%esp) + call __libm_scalbl_k80 +..B1.68: + addl $32, %esp +..B1.21: + fstpt 216(%esp) + jmp ..B1.46 +..B1.22: + fldt 12+_CONSTANTS@GOTOFF(%ebx) + fmul %st(0), %st + fstpt 16(%esp) +..B1.23: + fldt 16(%esp) + fstpt 156(%esp) + fldt 24(%ebp) + fstpt (%esp) + fldt (%esp) + addl $-16, %esp + fstpt (%esp) + call cosl@PLT +..B1.69: + addl $16, %esp + fldt 16(%esp) + fmulp %st, %st(1) + movzwl 32(%ebp), %edx + testl $32767, %edx + fstpt 204(%esp) + jle ..B1.25 +..B1.24: + addl $-16, %esp + fldt 16(%esp) + fstpt (%esp) + call sinl@PLT +..B1.70: + addl $16, %esp + fldt 16(%esp) + fmulp %st, %st(1) + fstpt 216(%esp) + jmp ..B1.26 +..B1.25: + fldt (%esp) + fldt 16(%esp) + fmulp %st, %st(1) + fstpt 216(%esp) +..B1.26: + testl %edi, %edi + je ..B1.28 +..B1.27: + fldt 80(%esp) + fstpt (%esp) +..B1.71: + fldcw 46(%esp) +..B1.28: + movl 204(%esp), %edx + movl %edx, (%esi) + movl 216(%esp), %edx + movl %edx, 12(%esi) + movl 220(%esp), %edx + movl %edx, 16(%esi) + movl 208(%esp), %ecx + movl 212(%esp), %edi + movl 224(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 228(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.50 +..B1.29: + movl %esi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.31: + movl 28(%ebp), %ecx +..B1.32: + testl %ecx, %ecx + jne ..B1.35 +..B1.79: + cmpl $0, 24(%ebp) +..B1.33: + jne ..B1.35 +..B1.34: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call expl@PLT +..B1.72: + fldt 24(%ebp) + addl $16, %esp + fstpt 216(%esp) + fstpt 204(%esp) + jmp ..B1.46 +..B1.35: + movzwl 32(%ebp), %ecx + andl $32767, %ecx + movl %ecx, 12(%esp) + cmpl $32767, %ecx + jge ..B1.38 +..B1.36: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call expl@PLT +..B1.74: + fldt 24(%ebp) + fxch %st(1) + fstpt 16(%esp) + fstpt (%esp) + fldt (%esp) + fstpt 32(%esp) + call cosl@PLT +..B1.73: + fldt 32(%esp) + addl $16, %esp + fldt (%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 204(%esp) + cmpl $0, 12(%esp) + jle ..B1.57 +..B1.37: + addl $-16, %esp + fstpt (%esp) + call sinl@PLT +..B1.75: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpt 216(%esp) + jmp ..B1.46 +..B1.38: + cmpl $32767, %edx + jge ..B1.40 +..B1.39: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + call sinl@PLT +..B1.76: + addl $16, %esp + fstpt 204(%esp) + fldt 204(%esp) + fstpt 216(%esp) + jmp ..B1.46 +..B1.40: + cmpl $-2147483648, 16(%ebp) + jne ..B1.42 +..B1.41: + cmpl $0, 12(%ebp) + je ..B1.43 +..B1.42: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 204(%esp) + fldt 204(%esp) + fldt 24(%ebp) + fmulp %st, %st(1) + fstpt 216(%esp) + jmp ..B1.46 +..B1.43: + movzbl 21(%ebp), %edx + testl $128, %edx + je ..B1.45 +..B1.44: + fldt 24(%ebp) + fmul %st(0), %st + fstpt 24(%ebp) + fldt 96(%esp) + fstpt 204(%esp) + fldt 204(%esp) + fstpt 216(%esp) + jmp ..B1.46 +..B1.45: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call expl@PLT +..B1.78: + fldt 24(%ebp) + addl $16, %esp + fxch %st(1) + fstpt 204(%esp) + addl $-16, %esp + fstpt (%esp) + call sinl@PLT +..B1.77: + addl $16, %esp + fstpt 216(%esp) +..B1.46: + testl %edi, %edi + je ..B1.48 +..B1.47: + fldcw 46(%esp) +..B1.48: + movl 204(%esp), %edx + movl %edx, (%esi) + movl 216(%esp), %edx + movl %edx, 12(%esi) + movl 220(%esp), %edx + movl %edx, 16(%esi) + movl 208(%esp), %ecx + movl 212(%esp), %edi + movl 224(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 228(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.50 +..B1.49: + movl %esi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.50: + call __stack_chk_fail@PLT +..B1.51: + fldt _CONSTANTS@GOTOFF(%ebx) + fmul %st(0), %st + fstpt 16(%esp) + jmp ..B1.23 +..B1.52: + cmpl $0, 28(%ebp) + jne ..B1.11 +..B1.53: + cmpl $0, 24(%ebp) + jne ..B1.11 + jmp ..B1.33 +..B1.54: + cmpl $0, 16(%ebp) + jne ..B1.9 +..B1.55: + cmpl $0, 12(%ebp) + jne ..B1.9 + jmp ..B1.31 +..B1.57: + cmpl $0, 16(%ebp) + jne ..B1.59 +..B1.58: + cmpl $0, 12(%ebp) + je ..B1.37 +..B1.59: + fldt (%esp) + fmulp %st, %st(1) + fstpt 216(%esp) + jmp ..B1.46 +..B1.61: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type cexpl,@function + .size cexpl,.-cexpl + .data +# -- End cexpl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,48 + .data + .hidden __libm_cosl_k80 + .hidden __libm_sinl_k80 + .hidden __libm_expl_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cimag.S b/external/sgx_libm/ia32/cimag.S new file mode 100644 index 0000000000..6472dcce03 --- /dev/null +++ b/external/sgx_libm/ia32/cimag.S @@ -0,0 +1,58 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cimag.c" + .text +..TXTST0: +# -- Begin cimag + .text + .align 16,0x90 + .globl cimag +cimag: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + fldl 12(%esp) + ret + .align 16,0x90 + .type cimag,@function + .size cimag,.-cimag + .data +# -- End cimag + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cimagf.S b/external/sgx_libm/ia32/cimagf.S new file mode 100644 index 0000000000..9ab930d96a --- /dev/null +++ b/external/sgx_libm/ia32/cimagf.S @@ -0,0 +1,58 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cimagf.c" + .text +..TXTST0: +# -- Begin cimagf + .text + .align 16,0x90 + .globl cimagf +cimagf: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + flds 8(%esp) + ret + .align 16,0x90 + .type cimagf,@function + .size cimagf,.-cimagf + .data +# -- End cimagf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cimagl.S b/external/sgx_libm/ia32/cimagl.S new file mode 100644 index 0000000000..aeb0c31d74 --- /dev/null +++ b/external/sgx_libm/ia32/cimagl.S @@ -0,0 +1,58 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cimagl.c" + .text +..TXTST0: +# -- Begin cimagl + .text + .align 16,0x90 + .globl cimagl +cimagl: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + fldt 16(%esp) + ret + .align 16,0x90 + .type cimagl,@function + .size cimagl,.-cimagl + .data +# -- End cimagl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/clog10.S b/external/sgx_libm/ia32/clog10.S new file mode 100644 index 0000000000..3832ba4422 --- /dev/null +++ b/external/sgx_libm/ia32/clog10.S @@ -0,0 +1,716 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clog10.c" + .text +..TXTST0: +# -- Begin clog10f + .text + .align 16,0x90 + .globl clog10f +clog10f: +# parameter 1: 64 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $56, %esp + flds 64(%esp) + flds 68(%esp) + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 40(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpl 32(%esp) + fstpl 24(%esp) + addl $-32, %esp + movl 56(%esp), %edx + lea 40(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %eax + movl 20(%ecx), %ecx + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 64(%esp), %edx + movl 68(%esp), %ecx + movl %edx, 8(%eax) + movl %ecx, 12(%eax) + call clog10@PLT +..B1.7: + addl $28, %esp +..B1.2: + fldl 8(%esp) + fstps (%esp) + fldl 16(%esp) + fstps 4(%esp) + movl 40(%esp), %ecx + xorl %esp, %ecx + movl (%esp), %eax + movl 4(%esp), %edx + cmpl %gs:20, %ecx + jne ..B1.4 +..B1.3: + addl $56, %esp + popl %ebx + ret +..B1.4: + call __stack_chk_fail@PLT + .align 16,0x90 + .type clog10f,@function + .size clog10f,.-clog10f + .data +# -- End clog10f + .text +# -- Begin clog10 + .text + .align 16,0x90 + .globl clog10 +clog10: +# parameter 1: 12 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 176(%esp) + fstl 160(%esp) + fstpl 168(%esp) +..B2.2: + fnstcw 150(%esp) +..B2.3: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnan +..B2.67: + addl $16, %esp +..B2.4: + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + testl %eax, %eax + jne ..B2.15 +..B2.5: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnan +..B2.68: + addl $16, %esp +..B2.6: + testl %eax, %eax + jne ..B2.15 +..B2.7: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isinf +..B2.69: + addl $16, %esp +..B2.8: + testl %eax, %eax + jne ..B2.15 +..B2.9: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isinf +..B2.70: + addl $16, %esp +..B2.10: + testl %eax, %eax + jne ..B2.15 +..B2.11: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_iszero +..B2.71: + addl $16, %esp +..B2.12: + testl %eax, %eax + je ..B2.45 +..B2.13: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_iszero +..B2.72: + addl $16, %esp +..B2.14: + testl %eax, %eax + je ..B2.45 +..B2.15: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnan +..B2.73: + addl $16, %esp +..B2.16: + testl %eax, %eax + je ..B2.21 +..B2.17: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isinf +..B2.74: + addl $16, %esp +..B2.18: + testl %eax, %eax + je ..B2.20 +..B2.19: + fldl 20(%ebp) + fmul %st(0), %st + fstpl 160(%esp) + fldl 12(%ebp) + fmul %st(0), %st + fstpl 168(%esp) + jmp ..B2.60 +..B2.20: + fldl 12(%ebp) + fmull 20(%ebp) + fstl 160(%esp) + fstpl 168(%esp) + jmp ..B2.60 +..B2.21: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnan +..B2.75: + addl $16, %esp +..B2.22: + testl %eax, %eax + je ..B2.28 +..B2.23: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isinf +..B2.76: + addl $16, %esp +..B2.24: + testl %eax, %eax + je ..B2.26 +..B2.25: + fldl 12(%ebp) + fmul %st(0), %st + fstpl 160(%esp) + fldl 20(%ebp) + fmul %st(0), %st + jmp ..B2.27 +..B2.26: + fldl 20(%ebp) + fmul %st(0), %st + fstl 160(%esp) +..B2.27: + fstpl 168(%esp) + jmp ..B2.60 +..B2.28: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isinf +..B2.77: + addl $16, %esp +..B2.29: + testl %eax, %eax + je ..B2.35 +..B2.30: + fldl 12(%ebp) + fld1 + fsts 12(%esp) + addl $-16, %esp + fstpl (%esp) + fstl 8(%esp) + fstpl 16(%esp) + call copysign@PLT +..B2.78: + fldl 16(%esp) + fmul %st, %st(1) + addl $16, %esp + fldl 20(%ebp) + fld %st(0) + fmul %st(1), %st + faddp %st, %st(3) + fxch %st(2) + fstpl 160(%esp) + fldt CLOG10RECA@GOTOFF(%ebx) + fldl NEGINFA@GOTOFF(%ebx) + fucomp %st(2) + fnstsw %ax + sahf + jp ..B2.31 + je ..B2.62 +..B2.31: + fldl POSINFA@GOTOFF(%ebx) + fucomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jne ..B2.34 + jp ..B2.34 +..B2.33: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fmulp %st, %st(1) +..B2.34: + addl $-16, %esp + flds 28(%esp) + fstpl (%esp) + fxch %st(1) + fstpl 8(%esp) + fstpt 16(%esp) + call copysign@PLT +..B2.79: + fldt 16(%esp) + addl $16, %esp + fmulp %st, %st(1) + fstpl 168(%esp) + jmp ..B2.60 +..B2.35: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isinf +..B2.80: + addl $16, %esp +..B2.36: + testl %eax, %eax + je ..B2.41 +..B2.37: + fldl 12(%ebp) + fldl POSINFA@GOTOFF(%ebx) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.38 + je ..B2.39 +..B2.38: + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fldt CLOG10RECA@GOTOFF(%ebx) + fmulp %st, %st(1) + jmp ..B2.40 +..B2.39: + fldl ZEROA@GOTOFF(%ebx) +..B2.40: + fldl 20(%ebp) + fxch %st(2) + fmul %st(0), %st + fadd %st(2), %st + fstpl 160(%esp) + fstl 168(%esp) + addl $-16, %esp + fstpl (%esp) + fstpl 8(%esp) + call copysign@PLT +..B2.81: + addl $16, %esp + fstpl 168(%esp) + jmp ..B2.60 +..B2.41: + fldl .L_2il0floatpacket.2@GOTOFF(%ebx) + fdivl ZEROA@GOTOFF(%ebx) + fstpl 160(%esp) + addl $-16, %esp + fldl 12(%ebp) + fstpl (%esp) + call __libm_internal_isnegzero +..B2.82: + addl $16, %esp +..B2.42: + testl %eax, %eax + je ..B2.44 +..B2.43: + fldl 20(%ebp) + addl $-16, %esp + fld1 + fstpl (%esp) + fstpl 8(%esp) + call copysign@PLT +..B2.83: + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fldt CLOG10RECA@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fmulp %st, %st(1) + fstpl 168(%esp) + jmp ..B2.60 +..B2.44: + fldl 20(%ebp) + fstpl 168(%esp) + jmp ..B2.60 +..B2.45: + movzwl 150(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B2.64 +..B2.46: + orl $-64768, %ecx + movw %cx, 148(%esp) +..B2.47: + fldcw 148(%esp) +..B2.48: + movl $1, %edi +..B2.49: + fldl 12(%ebp) + fld %st(0) + fabs + fldl 20(%ebp) + fld %st(0) + fabs + fcom %st(2) + fnstsw %ax + sahf + jae ..B2.51 + jp ..B2.51 +..B2.50: + fld %st(2) + jmp ..B2.52 +..B2.51: + fld %st(0) +..B2.52: + fxch %st(1) + fcom %st(3) + fnstsw %ax + sahf + jbe ..B2.54 +..B2.53: + fstp %st(0) + jmp ..B2.55 +..B2.54: + fstp %st(3) +..B2.55: + fld %st(0) + fmul %st(1), %st + fld %st(0) + fld %st(4) + fmul %st(5), %st + fadd %st, %st(1) + fld1 + fsubr %st(2), %st + fabs + fcompl .L_2il0floatpacket.4@GOTOFF(%ebx) + fnstsw %ax + sahf + jbe ..B2.57 +..B2.56: + fstp %st(5) + fstp %st(2) + fstp %st(3) + fstp %st(2) + addl $-16, %esp + fxch %st(1) + fstpt (%esp) + fstpl 16(%esp) + fstpl 168(%esp) + call logl@PLT +..B2.84: + fldl 168(%esp) + fldl 16(%esp) + addl $16, %esp + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fmulp %st, %st(3) + jmp ..B2.58 +..B2.57: + fstp %st(4) + fstp %st(5) + fstp %st(4) + fldt .L_2il0floatpacket.5@GOTOFF(%ebx) + fld %st(1) + fmulp %st, %st(1) + fxch %st(4) + fstpt 16(%esp) + fxch %st(3) + fstpt 28(%esp) + fxch %st(1) + fstpt (%esp) + fldt 28(%esp) + fldt 28(%esp) + fsub %st(3), %st + fsubrp %st, %st(1) + fstpt 40(%esp) + fldt 40(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 52(%esp) + fldt 40(%esp) + fldt 40(%esp) + fmulp %st, %st(1) + fldt 16(%esp) + fsubrp %st, %st(1) + fldt 52(%esp) + fldt 40(%esp) + fldt 52(%esp) + fldt 52(%esp) + fmulp %st, %st(1) + fldt (%esp) + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + fstpt 64(%esp) + fxch %st(2) + fstpt 76(%esp) + fldt .L_2il0floatpacket.5@GOTOFF(%ebx) + fmul %st(2), %st + fstpt 28(%esp) + fldt 28(%esp) + fldt 28(%esp) + fsub %st(3), %st + fsubrp %st, %st(1) + fstpt 88(%esp) + fldt 88(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 100(%esp) + fldt 88(%esp) + fldt 88(%esp) + fmulp %st, %st(1) + fldt 76(%esp) + fsubrp %st, %st(1) + fldt 100(%esp) + fmulp %st, %st(2) + fldt 88(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 100(%esp) + fldt 100(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 112(%esp) + fldt 16(%esp) + fldt 76(%esp) + faddp %st, %st(1) + fstpt 124(%esp) + fldt 124(%esp) + fldt 16(%esp) + fsubrp %st, %st(1) + fstpt 136(%esp) + fldt 16(%esp) + fldt 124(%esp) + fldt 136(%esp) + fsubrp %st, %st(1) + fsubrp %st, %st(1) + fldt 76(%esp) + fldt 136(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 136(%esp) + fldt 124(%esp) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + fsubrp %st, %st(1) + fstpt 124(%esp) + fldt 124(%esp) + fldt 136(%esp) + fldt 64(%esp) + faddp %st, %st(1) + fldt 112(%esp) + addl $-16, %esp + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + call log1pl@PLT +..B2.85: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fldl 12(%ebp) + fldl 20(%ebp) +..B2.58: + fldt INVLN10A@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + fstpl 160(%esp) + fxch %st(2) + fstpt (%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT +..B2.86: + addl $32, %esp + fldt (%esp) + testl %edi, %edi + fmulp %st, %st(1) + fstpl 168(%esp) + je ..B2.60 +..B2.59: + fldcw 150(%esp) +..B2.60: + movl 160(%esp), %edx + movl %edx, (%esi) + movl 164(%esp), %ecx + movl 168(%esp), %edi + movl 172(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 176(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B2.63 +..B2.61: + movl %esi, %eax + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B2.62: + fstp %st(1) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fmulp %st, %st(1) + jmp ..B2.34 +..B2.63: + call __stack_chk_fail@PLT +..B2.64: + xorl %edi, %edi + jmp ..B2.49 + .align 16,0x90 + .type clog10,@function + .size clog10,.-clog10 + .data +# -- End clog10 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .space 4, 0x00 # pad + .align 16 +CLOG10RECA: + .long 2547844487 + .long 2929975909 + .long 16382 + .long 0 + .type CLOG10RECA,@object + .size CLOG10RECA,16 + .align 16 +NEGINFA: + .long 0 + .long 4293918720 + .type NEGINFA,@object + .size NEGINFA,8 + .space 8, 0x00 # pad + .align 16 +POSINFA: + .long 0 + .long 2146435072 + .type POSINFA,@object + .size POSINFA,8 + .space 8, 0x00 # pad + .align 16 +ZEROA: + .long 0 + .long 0 + .type ZEROA,@object + .size ZEROA,8 + .space 8, 0x00 # pad + .align 16 +INVLN10A: + .long 925397397 + .long 3730561193 + .long 16381 + .long 0 + .type INVLN10A,@object + .size INVLN10A,16 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xeb851eb8,0x3f9eb851 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .data + .hidden __libm_internal_isnegzero + .hidden __libm_internal_iszero + .hidden __libm_internal_isnan + .hidden __libm_internal_isinf + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/clog10l.S b/external/sgx_libm/ia32/clog10l.S new file mode 100644 index 0000000000..089f09f5b8 --- /dev/null +++ b/external/sgx_libm/ia32/clog10l.S @@ -0,0 +1,975 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clog10l.c" + .text +..TXTST0: +# -- Begin clog10l + .text + .align 16,0x90 + .globl clog10l +clog10l: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 224(%esp) + fstpt 80(%esp) + fldt 80(%esp) + fstpt 200(%esp) + fldt 200(%esp) + fstpt 212(%esp) +..B1.2: + fnstcw 46(%esp) +..B1.3: + movzwl 46(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.77 +..B1.4: + orl $-64768, %ecx + movw %cx, 44(%esp) +..B1.5: + fldcw 44(%esp) +..B1.6: + movl $1, %esi +..B1.7: + movzwl 20(%ebp), %ecx + andl $32767, %ecx + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $32767, %ecx + jge ..B1.46 +..B1.8: + cmpl $32767, %edx + jge ..B1.85 +..B1.9: + testl %ecx, %ecx + jne ..B1.15 +..B1.10: + cmpl $0, 16(%ebp) + jne ..B1.15 +..B1.11: + cmpl $0, 12(%ebp) + jne ..B1.15 +..B1.12: + testl %edx, %edx + jne ..B1.15 +..B1.13: + cmpl $0, 28(%ebp) + jne ..B1.15 +..B1.14: + cmpl $0, 24(%ebp) + je ..B1.45 +..B1.15: + fldt 12(%ebp) + fld %st(0) + fabs + fstpt 16(%esp) + fldt 16(%esp) + fldt 24(%ebp) + fld %st(0) + fabs + fstpt (%esp) + fldt (%esp) + movzwl 24(%esp), %ecx + movzwl 8(%esp), %edx + andl $32767, %ecx + andl $32767, %edx + cmpl %edx, %ecx + jl ..B1.20 +..B1.16: + jne ..B1.21 +..B1.17: + movl 20(%esp), %edx + movl 4(%esp), %eax + cmpl %eax, %edx + jb ..B1.20 +..B1.18: + jne ..B1.21 +..B1.19: + movl 16(%esp), %edx + cmpl (%esp), %edx + jae ..B1.21 +..B1.20: + fstpt 16(%esp) + fldt 16(%esp) + movzwl 24(%esp), %ecx + fxch %st(2) + fstpt (%esp) + fldt (%esp) + andl $32767, %ecx +..B1.21: + cmpl $16382, %ecx + jg ..B1.26 +..B1.22: + jne ..B1.42 +..B1.23: + movl 20(%esp), %edx + cmpl 16+_CONSTANTS@GOTOFF(%ebx), %edx + ja ..B1.26 +..B1.24: + jne ..B1.42 +..B1.25: + movl 12+_CONSTANTS@GOTOFF(%ebx), %edx + cmpl 16(%esp), %edx + ja ..B1.42 +..B1.26: + cmpl $16383, %ecx + jl ..B1.31 +..B1.27: + jne ..B1.42 +..B1.28: + movl 20(%esp), %edx + cmpl 28+_CONSTANTS@GOTOFF(%ebx), %edx + jb ..B1.31 +..B1.29: + jne ..B1.42 +..B1.30: + movl 16(%esp), %edx + cmpl 24+_CONSTANTS@GOTOFF(%ebx), %edx + ja ..B1.42 +..B1.31: + movzwl 8(%esp), %edx + andl $32767, %edx + cmpl $8256, %edx + jg ..B1.36 +..B1.32: + jne ..B1.37 +..B1.33: + movl 4(%esp), %eax + cmpl 40+_CONSTANTS@GOTOFF(%ebx), %eax + ja ..B1.36 +..B1.34: + jne ..B1.37 +..B1.35: + movl (%esp), %eax + cmpl 36+_CONSTANTS@GOTOFF(%ebx), %eax + jbe ..B1.37 +..B1.36: + fldt _CONSTANTS@GOTOFF(%ebx) + fld %st(3) + fmul %st(4), %st + fld %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fsubr %st, %st(1) + fxch %st(1) + fabs + fcomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jae ..B1.86 + jp ..B1.86 + jmp ..B1.38 +..B1.37: + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fld %st(3) + fmul %st(4), %st + fsub %st(1), %st + fabs + fldt _CONSTANTS@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jbe ..B1.86 +..B1.38: + fstp %st(2) + cmpl $16183, %edx + jl ..B1.40 +..B1.39: + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fld %st(3) + fmul %st(1), %st + lea _CONSTANTS@GOTOFF(%ebx), %eax + fxch %st(5) + fstpt (%esp) + fld %st(3) + fsubr %st(5), %st + fsubrp %st, %st(5) + fld %st(4) + lea 72(%eax), %edx + fmul %st(5), %st + fld %st(2) + fmulp %st, %st(2) + fxch %st(4) + fsub %st(5), %st + fld %st(2) + addl $84, %eax + movl %edx, 12(%esp) + fsubr %st(2), %st + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + fmul %st(4), %st + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(4) + fmul %st(0), %st + fstpt 48(%esp) + fld %st(5) + fadd %st(3), %st + fsub %st, %st(6) + fxch %st(6) + fsubrp %st, %st(3) + fmulp %st, %st(6) + fmul %st, %st(5) + fxch %st(3) + fsubrp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fld %st(0) + fsub %st(5), %st + fsubr %st, %st(2) + fld %st(1) + fsubp %st, %st(1) + fsubrp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fadd %st(5), %st + fld %st(0) + faddp %st, %st(3) + fld %st(2) + fxch %st(4) + fmul %st(0), %st + fstpt 16(%esp) + fldt 16(%esp) + faddp %st, %st(4) + fxch %st(3) + fstpt 64(%esp) + fldt 64(%esp) + fldt 48(%esp) + faddp %st, %st(1) + fldt 12+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + fldt _Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fmulp %st, %st(1) + fld %st(4) + fsub %st(6), %st + fsubr %st, %st(7) + fsubr %st(5), %st + fsubrp %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fld %st(1) + fsub %st(3), %st + fldt 32(%esp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(3), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fld %st(3) + fldt 64(%esp) + fld %st(0) + fsub %st(3), %st + fldt 16(%esp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(2), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(4) + fsub %st(2), %st + fldt 48(%esp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(6), %st + fsubrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt (%edx) + fld %st(0) + fmul %st(3), %st + fldt (%eax) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 200(%esp) + fldt (%esp) + fxch %st(1) + jmp ..B1.49 +..B1.40: + cmpl $16383, %ecx + je ..B1.55 +..B1.41: + fstp %st(0) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fld %st(2) + fmul %st(1), %st + fld %st(3) + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fmul %st(1), %st + lea 72(%eax), %edx + addl $84, %eax + fsubp %st, %st(3) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(3), %st + fld %st(0) + fld %st(3) + fxch %st(5) + fmul %st(0), %st + movl %edx, 12(%esp) + fadd %st, %st(1) + fxch %st(1) + fadd %st, %st(5) + fxch %st(4) + fsubr %st(5), %st + fxch %st(2) + fsubr %st(4), %st + fsubrp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + faddp %st, %st(2) + fld %st(2) + fmul %st(3), %st + fldt 12+_Q1@GOTOFF(%ebx) + fmul %st(4), %st + fldt _Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(0) + fmul %st(3), %st + fld %st(3) + fsubr %st(1), %st + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt (%edx) + fld %st(0) + fmul %st(3), %st + fldt (%eax) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 200(%esp) + jmp ..B1.49 +..B1.42: + fstp %st(0) + fstp %st(1) + addl $-32, %esp + lea 80(%esp), %edx + movl %edx, (%esp) + fxch %st(1) + fstpt 4(%esp) + fstpt 16(%esp) + call __libm_hypot2l_k80 +..B1.80: + addl $32, %esp +..B1.43: + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fmul %st, %st(1) + fstpt 32(%esp) + fldt 120+_CONSTANTS@GOTOFF(%ebx) + fmul %st(1), %st + fstpt 16(%esp) + fldt 132+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%esp) + addl $-32, %esp + fldt 80(%esp) + lea 124(%esp), %edx + fstpt (%esp) + fldt -32(%edx) + fstpt 12(%esp) + movl %edx, 24(%esp) + call __libm_logl_k80 +..B1.81: + addl $32, %esp +..B1.44: + fldt 32(%esp) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fmulp %st, %st(1) + lea 72(%eax), %edx + fldt 92(%esp) + addl $84, %eax + movl %edx, 12(%esp) + fmul %st(1), %st + fldt 104(%esp) + fmulp %st, %st(2) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fld %st(0) + fmul %st(2), %st + fld %st(0) + fsub %st(3), %st + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fldt (%edx) + fld %st(0) + fmul %st(4), %st + fldt (%eax) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fmulp %st, %st(6) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt 16(%esp) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt (%esp) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 200(%esp) + fldt 12(%ebp) + fxch %st(1) + jmp ..B1.49 +..B1.45: + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fldz + fdivrl .L_2il0floatpacket.12@GOTOFF(%ebx) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fstpt 200(%esp) + lea 72(%eax), %edx + fldt 12(%ebp) + addl $84, %eax + movl %edx, 12(%esp) + fxch %st(1) + jmp ..B1.49 +..B1.46: + je ..B1.70 +..B1.47: + cmpl $32767, %edx + je ..B1.63 +..B1.48: + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fldt 48(%eax) + lea 72(%eax), %edx + fmul %st(0), %st + addl $84, %eax + fstpt 200(%esp) + fldt 12(%ebp) + movl %edx, 12(%esp) + fxch %st(1) +..B1.49: + fldt 80(%esp) + xorl %edx, %edx + movl %edx, 140(%esp) + fstpt 128(%esp) + fldt 128(%esp) + fxch %st(2) + fstpt 116(%esp) + movl %edx, 168(%esp) + fxch %st(1) + fstpt 156(%esp) + fldt 24(%ebp) + fstpt 144(%esp) + addl $-16, %esp + lea 188(%esp), %ecx + lea 160(%esp), %edx + movl %ecx, (%esp) + lea 132(%esp), %ecx + movl %edx, 4(%esp) + movl %ecx, 8(%esp) + movl %eax, -116(%edx) + fstpt -128(%edx) + call __libm_atan2l_k80 +..B1.82: + fldt 32(%esp) + movl 44(%esp), %eax + addl $16, %esp +..B1.50: + fldt 172(%esp) + fmul %st, %st(1) + fld %st(0) + movl 12(%esp), %edx + fsubr %st(2), %st + movl 196(%esp), %ecx + fsubrp %st, %st(2) + fsub %st(1), %st + fldt 184(%esp) + addl $-32, %esp + faddp %st, %st(1) + fldt (%edx) + fld %st(0) + fmul %st(3), %st + fstpt (%esp) + fldt (%eax) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 12(%esp) + movl %ecx, 24(%esp) + call __libm_scalbl_k80 +..B1.83: + addl $32, %esp +..B1.51: + fstpt 212(%esp) + testl %esi, %esi + je ..B1.53 +..B1.52: + fldcw 46(%esp) +..B1.53: + movl 200(%esp), %edx + movl %edx, (%edi) + movl 212(%esp), %edx + movl %edx, 12(%edi) + movl 216(%esp), %edx + movl %edx, 16(%edi) + movl 204(%esp), %ecx + movl 208(%esp), %esi + movl 220(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 20(%edi) + movl 224(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.62 +..B1.54: + movl %edi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.55: + cmpl $-2147483648, 20(%esp) + jne ..B1.41 +..B1.56: + cmpl $0, 16(%esp) + jne ..B1.41 +..B1.57: + fstp %st(2) + fstp %st(0) + cmpl $0, 4(%esp) + jne ..B1.60 +..B1.58: + cmpl $0, (%esp) + jne ..B1.60 +..B1.59: + fstp %st(0) + fldt 80(%esp) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fstpt 200(%esp) + lea 72(%eax), %edx + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + addl $84, %eax + movl %edx, 12(%esp) + jmp ..B1.49 +..B1.60: + fstp %st(1) + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fldt 108(%eax) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + movzwl 8(%esp), %ecx + movl %ecx, %edx + andl $-32768, %ecx + fld %st(0) + orl $-49153, %ecx + fld %st(1) + movw %cx, 8(%esp) + lea 72(%eax), %ecx + fldt (%esp) + addl $84, %eax + fmul %st, %st(2) + fld %st(0) + movl %ecx, 12(%esp) + addl $-32, %esp + andl $32767, %edx + fsubr %st(3), %st + fsubrp %st, %st(3) + fld %st(2) + lea -33167(%edx,%edx), %edx + fmul %st(3), %st + fmul %st, %st(2) + fld %st(2) + fsub %st(1), %st + fsubrp %st, %st(3) + fsub %st(2), %st + fxch %st(1) + fsub %st(3), %st + fmul %st, %st(3) + fxch %st(5) + fmulp %st, %st(3) + fld %st(4) + fmulp %st, %st(5) + fxch %st(2) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fldt (%ecx) + fld %st(0) + fmul %st(4), %st + fstpt (%esp) + fldt (%eax) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + movl %edx, 24(%esp) + movl %eax, 60(%esp) + fstpt 48(%esp) + call __libm_scalbl_k80 +..B1.84: + fldt 48(%esp) + movl 60(%esp), %eax + addl $32, %esp +..B1.61: + fxch %st(1) + fstpt 200(%esp) + fldt 12(%ebp) + fxch %st(1) + jmp ..B1.49 +..B1.62: + call __stack_chk_fail@PLT +..B1.63: + cmpl $-2147483648, 28(%ebp) + jne ..B1.65 +..B1.64: + cmpl $0, 24(%ebp) + je ..B1.48 +..B1.65: + cmpl $32767, %ecx + je ..B1.67 +..B1.66: + fldt 24(%ebp) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fmul %st(0), %st + lea 72(%eax), %edx + fstpt 200(%esp) + addl $84, %eax + fldt 12(%ebp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + movl %edx, 12(%esp) + jmp ..B1.49 +..B1.67: + cmpl $-2147483648, 16(%ebp) + jne ..B1.66 +..B1.68: + cmpl $0, 12(%ebp) + jne ..B1.66 +..B1.69: + fldt 12(%ebp) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fld %st(0) + lea 72(%eax), %edx + fmul %st(1), %st + addl $84, %eax + fstpt 200(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + movl %edx, 12(%esp) + jmp ..B1.49 +..B1.70: + cmpl $-2147483648, 16(%ebp) + jne ..B1.72 +..B1.71: + cmpl $0, 12(%ebp) + je ..B1.47 +..B1.72: + cmpl $32767, %edx + je ..B1.74 +..B1.73: + fldt 12(%ebp) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fldt 24(%ebp) + lea 72(%eax), %edx + fmul %st(1), %st + addl $84, %eax + fstpt 200(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + movl %edx, 12(%esp) + jmp ..B1.49 +..B1.74: + cmpl $-2147483648, 28(%ebp) + jne ..B1.73 +..B1.75: + cmpl $0, 24(%ebp) + jne ..B1.73 +..B1.76: + fldt 24(%ebp) + lea _CONSTANTS@GOTOFF(%ebx), %eax + fmul %st(0), %st + lea 72(%eax), %edx + fstpt 200(%esp) + addl $84, %eax + fldt 12(%ebp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + movl %edx, 12(%esp) + jmp ..B1.49 +..B1.77: + xorl %esi, %esi + jmp ..B1.7 +..B1.85: + cmpl $32767, %ecx + je ..B1.70 + jmp ..B1.47 +..B1.86: + fstp %st(0) + jmp ..B1.42 + .align 16,0x90 + .type clog10l,@function + .size clog10l,.-clog10l + .data +# -- End clog10l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16358 + .word 0 + .word 37342 + .word 47265 + .word 62214 + .word 46340 + .word 16382 + .word 0 + .word 64512 + .word 65535 + .word 31 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8256 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 55465 + .word 56923 + .word 16381 + .word 0 + .word 43711 + .word 54638 + .word 50772 + .word 56481 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16583 + .word 0 + .word 0 + .word 0 + .word 39557 + .word 39456 + .word 16381 + .word 0 + .word 51839 + .word 3796 + .word 3310 + .word 34305 + .word 49112 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,144 + .align 16 +_Q1: + .word 3134 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 49331 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .type _Q1,@object + .size _Q1,24 + .align 8 +.L_2il0floatpacket.12: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .data + .hidden __libm_logl_k80 + .hidden __libm_hypot2l_k80 + .hidden __libm_scalbl_k80 + .hidden __libm_atan2l_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/clog_gen.S b/external/sgx_libm/ia32/clog_gen.S new file mode 100644 index 0000000000..82d47aa12f --- /dev/null +++ b/external/sgx_libm/ia32/clog_gen.S @@ -0,0 +1,756 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clog_gen.c" + .text +..TXTST0: +# -- Begin __libm_internal_clog + .text + .align 16,0x90 + .hidden __libm_internal_clog + .globl __libm_internal_clog +__libm_internal_clog: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 168(%esp) + fstl 152(%esp) + fstpl 160(%esp) +..B1.2: + fnstcw 134(%esp) +..B1.3: + movzwl 18(%ebp), %ecx + andl $32752, %ecx + movzwl 26(%ebp), %edx + andl $32752, %edx + shrl $4, %ecx + shrl $4, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %ecx + jge ..B1.21 +..B1.4: + cmpl $2047, %edx + jge ..B1.48 +..B1.5: + movzwl 134(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.26 +..B1.6: + orl $-64768, %ecx + movw %cx, 132(%esp) +..B1.7: + fldcw 132(%esp) +..B1.8: + movl $1, %edi +..B1.9: + fldl 12(%ebp) + fabs + fldl 20(%ebp) + fabs + fcom %st(1) + fnstsw %ax + sahf + jae ..B1.11 + jp ..B1.11 +..B1.10: + fld %st(1) + jmp ..B1.12 +..B1.11: + fld %st(0) +..B1.12: + fxch %st(1) + fcom %st(2) + fnstsw %ax + sahf + jbe ..B1.14 +..B1.13: + fstp %st(0) + jmp ..B1.15 +..B1.14: + fstp %st(2) +..B1.15: + fld %st(0) + fmul %st(1), %st + fld %st(0) + fld %st(3) + fmul %st(4), %st + fadd %st, %st(1) + fld1 + fsubr %st(2), %st + fabs + fcompl .L_2il0floatpacket.6@GOTOFF(%ebx) + fnstsw %ax + sahf + jbe ..B1.17 +..B1.16: + fstp %st(3) + fstp %st(2) + fstp %st(2) + fstp %st(1) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B1.44: + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fstpl 152(%esp) + jmp ..B1.18 +..B1.17: + fstp %st(1) + fxch %st(3) + fstpt 136(%esp) + fstpt (%esp) + fld %st(0) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fldt 12(%esp) + fsub %st(2), %st + fsubrp %st, %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fsubrp %st, %st(1) + fstpt 36(%esp) + fldt 24(%esp) + fldt 24(%esp) + fmulp %st, %st(1) + fldt (%esp) + fsubrp %st, %st(1) + fldt 36(%esp) + fldt 24(%esp) + fldt 36(%esp) + fldt 36(%esp) + fmulp %st, %st(1) + fldt 136(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + fstpt 48(%esp) + fxch %st(2) + fstpt 60(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fmul %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fldt 12(%esp) + fsub %st(3), %st + fsubrp %st, %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 84(%esp) + fldt 72(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fldt 60(%esp) + fsubrp %st, %st(1) + fldt 84(%esp) + fmulp %st, %st(2) + fldt 72(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 84(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 96(%esp) + fldt (%esp) + fldt 60(%esp) + faddp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + fldt (%esp) + fsubrp %st, %st(1) + fstpt 120(%esp) + fldt (%esp) + fldt 108(%esp) + fldt 120(%esp) + fsubrp %st, %st(1) + fsubrp %st, %st(1) + fldt 60(%esp) + fldt 120(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 120(%esp) + fldt 108(%esp) + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fsubrp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + fldt 120(%esp) + fldt 48(%esp) + faddp %st, %st(1) + fldt 96(%esp) + addl $-16, %esp + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + call log1pl@PLT +..B1.45: + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fstpl 152(%esp) +..B1.18: + testl %edi, %edi + je ..B1.20 +..B1.19: + fldcw 134(%esp) +..B1.20: + fldl 20(%ebp) + addl $-16, %esp + fldl 12(%ebp) + fstpl 8(%esp) + fstpl (%esp) + call atan2@PLT + jmp ..B1.47 +..B1.21: + je ..B1.35 +..B1.22: + cmpl $2047, %edx + je ..B1.28 +..B1.23: + fldl _DBL_PINF@GOTOFF(%ebx) + fstpl 152(%esp) + addl $-16, %esp + fldl 20(%ebp) + fldl 12(%ebp) + fstpl 8(%esp) + fstpl (%esp) + call atan2@PLT +..B1.47: + addl $16, %esp + fstpl 160(%esp) +..B1.24: + movl 152(%esp), %edx + movl %edx, (%esi) + movl 156(%esp), %ecx + movl 160(%esp), %edi + movl 164(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 168(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.27 +..B1.25: + movl %esi, %eax + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.26: + xorl %edi, %edi + jmp ..B1.9 +..B1.27: + call __stack_chk_fail@PLT +..B1.28: + testl $1048575, 24(%ebp) + jne ..B1.30 +..B1.29: + cmpl $0, 20(%ebp) + je ..B1.23 +..B1.30: + fldl 20(%ebp) + cmpl $2047, %ecx + fmul %st(0), %st + fstl 160(%esp) + je ..B1.32 +..B1.31: + fstpl 152(%esp) + jmp ..B1.24 +..B1.32: + testl $1048575, 16(%ebp) + jne ..B1.31 +..B1.33: + cmpl $0, 12(%ebp) + jne ..B1.31 +..B1.34: + fstp %st(0) + fldl 12(%ebp) + fmul %st(0), %st + fstpl 152(%esp) + jmp ..B1.24 +..B1.35: + testl $1048575, 16(%ebp) + jne ..B1.37 +..B1.36: + cmpl $0, 12(%ebp) + je ..B1.22 +..B1.37: + fldl 12(%ebp) + cmpl $2047, %edx + fld %st(0) + fmul %st(1), %st + fstpl 160(%esp) + je ..B1.39 +..B1.38: + fldl 20(%ebp) + fmulp %st, %st(1) + fstpl 152(%esp) + jmp ..B1.24 +..B1.39: + testl $1048575, 24(%ebp) + jne ..B1.38 +..B1.40: + cmpl $0, 20(%ebp) + jne ..B1.38 +..B1.41: + fstp %st(0) + fldl 20(%ebp) + fmul %st(0), %st + fstpl 152(%esp) + jmp ..B1.24 +..B1.48: + cmpl $2047, %ecx + je ..B1.35 + jmp ..B1.22 + .align 16,0x90 + .type __libm_internal_clog,@function + .size __libm_internal_clog,.-__libm_internal_clog + .data +# -- End __libm_internal_clog + .text +# -- Begin clog + .text + .align 16,0x90 + .globl clog +clog: +# parameter 1: 12 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + fldl 12(%ebp) + fldl 20(%ebp) + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 184(%esp) + fstpl 176(%esp) + fstpl 168(%esp) + fstl 152(%esp) + fstpl 160(%esp) +..B2.2: + fnstcw 134(%esp) +..B2.3: + movzwl 174(%esp), %edx + andl $32752, %edx + movzwl 182(%esp), %eax + andl $32752, %eax + shrl $4, %edx + shrl $4, %eax + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + cmpl $2047, %edx + jge ..B2.21 +..B2.4: + cmpl $2047, %eax + jge ..B2.48 +..B2.5: + movzwl 134(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.26 +..B2.6: + orl $-64768, %edx + movw %dx, 132(%esp) +..B2.7: + fldcw 132(%esp) +..B2.8: + movl $1, %esi +..B2.9: + fldl 168(%esp) + fabs + fldl 176(%esp) + fabs + fcom %st(1) + fnstsw %ax + sahf + jae ..B2.11 + jp ..B2.11 +..B2.10: + fld %st(1) + jmp ..B2.12 +..B2.11: + fld %st(0) +..B2.12: + fxch %st(1) + fcom %st(2) + fnstsw %ax + sahf + jbe ..B2.14 +..B2.13: + fstp %st(0) + jmp ..B2.15 +..B2.14: + fstp %st(2) +..B2.15: + fld %st(0) + fmul %st(1), %st + fld %st(0) + fld %st(3) + fmul %st(4), %st + fadd %st, %st(1) + fld1 + fsubr %st(2), %st + fabs + fcompl .L_2il0floatpacket.6@GOTOFF(%ebx) + fnstsw %ax + sahf + jbe ..B2.17 +..B2.16: + fstp %st(3) + fstp %st(2) + fstp %st(2) + fstp %st(1) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B2.44: + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fstpl 152(%esp) + jmp ..B2.18 +..B2.17: + fstp %st(1) + fxch %st(3) + fstpt 136(%esp) + fstpt (%esp) + fld %st(0) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fldt 12(%esp) + fsub %st(2), %st + fsubrp %st, %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fsubrp %st, %st(1) + fstpt 36(%esp) + fldt 24(%esp) + fldt 24(%esp) + fmulp %st, %st(1) + fldt (%esp) + fsubrp %st, %st(1) + fldt 36(%esp) + fldt 24(%esp) + fldt 36(%esp) + fldt 36(%esp) + fmulp %st, %st(1) + fldt 136(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + fstpt 48(%esp) + fxch %st(2) + fstpt 60(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fmul %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fldt 12(%esp) + fsub %st(3), %st + fsubrp %st, %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 84(%esp) + fldt 72(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fldt 60(%esp) + fsubrp %st, %st(1) + fldt 84(%esp) + fmulp %st, %st(2) + fldt 72(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 84(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 96(%esp) + fldt (%esp) + fldt 60(%esp) + faddp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + fldt (%esp) + fsubrp %st, %st(1) + fstpt 120(%esp) + fldt (%esp) + fldt 108(%esp) + fldt 120(%esp) + fsubrp %st, %st(1) + fsubrp %st, %st(1) + fldt 60(%esp) + fldt 120(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 120(%esp) + fldt 108(%esp) + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fsubrp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + fldt 120(%esp) + fldt 48(%esp) + faddp %st, %st(1) + fldt 96(%esp) + addl $-16, %esp + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + call log1pl@PLT +..B2.45: + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fstpl 152(%esp) +..B2.18: + testl %esi, %esi + je ..B2.20 +..B2.19: + fldcw 134(%esp) +..B2.20: + fldl 176(%esp) + fldl 168(%esp) + addl $-16, %esp + fstpl 8(%esp) + fstpl (%esp) + call atan2@PLT + jmp ..B2.47 +..B2.21: + je ..B2.35 +..B2.22: + cmpl $2047, %eax + je ..B2.28 +..B2.23: + fldl _DBL_PINF@GOTOFF(%ebx) + fstpl 152(%esp) + fldl 176(%esp) + fldl 168(%esp) + addl $-16, %esp + fstpl 8(%esp) + fstpl (%esp) + call atan2@PLT +..B2.47: + addl $16, %esp + fstpl 160(%esp) +..B2.24: + fldl 152(%esp) + movl 8(%ebp), %eax + movl 156(%esp), %ecx + movl 152(%esp), %edx + movl 164(%esp), %edi + movl 160(%esp), %esi + fstp %st(0) + fldl 160(%esp) + fstp %st(0) + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl %esi, 8(%eax) + movl %edi, 12(%eax) + movl 184(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B2.27 +..B2.25: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B2.26: + xorl %esi, %esi + jmp ..B2.9 +..B2.27: + call __stack_chk_fail@PLT +..B2.28: + testl $1048575, 180(%esp) + jne ..B2.30 +..B2.29: + cmpl $0, 176(%esp) + je ..B2.23 +..B2.30: + fldl 176(%esp) + cmpl $2047, %edx + fmul %st(0), %st + fstl 160(%esp) + je ..B2.32 +..B2.31: + fstpl 152(%esp) + jmp ..B2.24 +..B2.32: + testl $1048575, 172(%esp) + jne ..B2.31 +..B2.33: + cmpl $0, 168(%esp) + jne ..B2.31 +..B2.34: + fstp %st(0) + fldl 168(%esp) + fmul %st(0), %st + fstpl 152(%esp) + jmp ..B2.24 +..B2.35: + testl $1048575, 172(%esp) + jne ..B2.37 +..B2.36: + cmpl $0, 168(%esp) + je ..B2.22 +..B2.37: + fldl 168(%esp) + cmpl $2047, %eax + fld %st(0) + fmul %st(1), %st + fstpl 160(%esp) + je ..B2.39 +..B2.38: + fldl 176(%esp) + fmulp %st, %st(1) + fstpl 152(%esp) + jmp ..B2.24 +..B2.39: + testl $1048575, 180(%esp) + jne ..B2.38 +..B2.40: + cmpl $0, 176(%esp) + jne ..B2.38 +..B2.41: + fstp %st(0) + fldl 176(%esp) + fmul %st(0), %st + fstpl 152(%esp) + jmp ..B2.24 +..B2.48: + cmpl $2047, %edx + je ..B2.35 + jmp ..B2.22 + .align 16,0x90 + .type clog,@function + .size clog,.-clog + .data +# -- End clog + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +_DBL_PINF: + .long 0 + .long 2146435072 + .type _DBL_PINF,@object + .size _DBL_PINF,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xeb851eb8,0x3f9eb851 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/clogf_wmt.S b/external/sgx_libm/ia32/clogf_wmt.S new file mode 100644 index 0000000000..91bc907cf1 --- /dev/null +++ b/external/sgx_libm/ia32/clogf_wmt.S @@ -0,0 +1,2539 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clogf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin clogf + .text + .align 16,0x90 + .globl clogf +clogf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $136, %esp + movl %esi, 80(%esp) + call static_func + movl %eax, %esi + movss 144(%esp), %xmm0 + movss 148(%esp), %xmm1 + movss %xmm0, (%esp) + movss %xmm1, 4(%esp) + movl %ebx, 8(%esp) + movaps %xmm0, %xmm2 + cvtss2sd %xmm1, %xmm0 + cvtss2sd %xmm2, %xmm1 + movsd %xmm0, 40(%esp) + movsd %xmm1, 32(%esp) + andpd 3248(%esi), %xmm0 + andpd 3248(%esi), %xmm1 + movl 4(%esp), %edx + movl (%esp), %ecx + movl $-2147483648, %eax + andl %edx, %eax + andl $2139095040, %edx + subl $8388608, %edx + cmpl $2130706432, %edx + jae .L_2TAG_PACKET_0.0.2 + movl %ecx, %edx + andl $-2147483648, %ecx + andl $2139095040, %edx + subl $8388608, %edx + cmpl $2130706432, %edx + jae .L_2TAG_PACKET_1.0.2 + movapd %xmm0, %xmm3 + divsd %xmm1, %xmm0 + movq 3232(%esi), %xmm2 + mulsd %xmm1, %xmm1 + mulsd %xmm3, %xmm3 + addsd %xmm3, %xmm1 + movq %xmm1, 16(%esp) + pand %xmm1, %xmm2 + pextrw $3, %xmm1, %edx + subsd 4800(%esi), %xmm1 + pand 3248(%esi), %xmm1 + cmpltsd 2048(%esi), %xmm1 + movmskpd %xmm1, %ebx + por 4800(%esi), %xmm2 + testl $1, %ebx + jne .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_3.0.2: + xorl %ecx, %eax + movl 20(%esp), %ebx + sarl $4, %edx + andl $1044480, %ebx + movsd 4816(%esi), %xmm3 + xorpd %xmm4, %xmm4 + subl $1023, %edx + xorpd %xmm7, %xmm7 + sarl $31, %ecx + movl %edx, 12(%esp) + movd %ecx, %xmm6 + pshufd $0, %xmm6, %xmm6 + andpd 4848(%esi), %xmm6 + andpd %xmm0, %xmm3 + pextrw $3, %xmm0, %edx + shrl $9, %ebx + movsd %xmm0, %xmm1 + subl $16288, %edx + cmpl $1119, %edx + ja .L_2TAG_PACKET_4.0.2 + movl $16464, %ecx + pinsrw $3, %ecx, %xmm4 + shrl $16, %eax + orpd 4832(%esi), %xmm3 + movsd %xmm4, %xmm7 + mulsd (%esi,%ebx), %xmm2 + cmpsd $6, %xmm3, %xmm4 + movsd 4800(%esi), %xmm5 + minsd %xmm7, %xmm3 + andpd %xmm4, %xmm0 + mulsd %xmm3, %xmm1 + andpd %xmm4, %xmm5 + subsd %xmm3, %xmm0 + subsd 4800(%esi), %xmm2 + addsd %xmm5, %xmm1 + movq 3296(%esi), %xmm5 + divsd %xmm1, %xmm0 + cvtsi2sdl 12(%esp), %xmm1 + movl $176, %ecx + cmpl $176, %edx + cmova %ecx, %edx + addl $1, %edx + movsd 4880(%esi), %xmm4 + pinsrw $3, %eax, %xmm7 + addsd 3376(%esi,%edx,8), %xmm6 + xorpd %xmm7, %xmm6 + mulsd %xmm2, %xmm5 + addsd 3288(%esi), %xmm5 + mulsd %xmm2, %xmm5 + addsd 3280(%esi), %xmm5 + mulsd %xmm2, %xmm5 + xorpd %xmm0, %xmm7 + mulsd 3264(%esi), %xmm1 + mulsd %xmm0, %xmm0 + mulsd %xmm7, %xmm4 + addsd %xmm6, %xmm7 + mulsd %xmm4, %xmm0 + addsd 4976(%esi,%ebx), %xmm1 + addsd %xmm7, %xmm0 + addsd %xmm1, %xmm5 + mulsd 2064(%esi), %xmm5 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm5, %xmm5 + movd %xmm0, %edx + movd %xmm5, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_4.0.2: + addl $944, %edx + cmpl $2063, %edx + ja .L_2TAG_PACKET_6.0.2 + movq 4864(%esi), %xmm3 + shrl $16, %eax + movsd 4872(%esi), %xmm4 + mulsd (%esi,%ebx), %xmm2 + pinsrw $3, %eax, %xmm7 + mulsd %xmm1, %xmm1 + subsd 4800(%esi), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm3 + movsd %xmm1, %xmm5 + mulsd %xmm1, %xmm1 + addsd %xmm6, %xmm0 + cvtsi2sdl 12(%esp), %xmm6 + mulsd %xmm5, %xmm4 + mulsd %xmm3, %xmm1 + movq 3296(%esi), %xmm3 + mulsd %xmm2, %xmm3 + addsd 3288(%esi), %xmm3 + mulsd %xmm2, %xmm3 + mulsd 3264(%esi), %xmm6 + addsd 3280(%esi), %xmm3 + addsd 4976(%esi,%ebx), %xmm6 + mulsd %xmm2, %xmm3 + addsd %xmm4, %xmm1 + addsd %xmm6, %xmm3 + addsd %xmm1, %xmm0 + xorpd %xmm7, %xmm0 + mulsd 2064(%esi), %xmm3 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_6.0.2: + addl $15344, %edx + cmpl $17392, %edx + mulsd (%esi,%ebx), %xmm2 + subsd 4800(%esi), %xmm2 + jae .L_2TAG_PACKET_7.0.2 + shrl $16, %eax + pinsrw $3, %eax, %xmm7 + addsd %xmm6, %xmm0 + cvtsi2sdl 12(%esp), %xmm6 + movq 3296(%esi), %xmm3 + mulsd %xmm2, %xmm3 + pextrw $3, %xmm0, %edx + addsd 3288(%esi), %xmm3 + xorpd %xmm7, %xmm0 + andl $32752, %edx + mulsd %xmm2, %xmm3 + mulsd 3264(%esi), %xmm6 + addsd 3280(%esi), %xmm3 + movl $1065353217, %eax + movl $8388608, %ecx + addsd 4976(%esi,%ebx), %xmm6 + mulsd %xmm2, %xmm3 + cmpl $14352, %edx + cmovb %ecx, %eax + movd %eax, %xmm1 + addsd %xmm6, %xmm3 + mulss %xmm1, %xmm1 + mulsd 2064(%esi), %xmm3 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_7.0.2: + movss 4944(%esi), %xmm4 + movss 4948(%esi), %xmm1 + cvtsi2sdl 12(%esp), %xmm6 + shrl $16, %eax + andl $32768, %ecx + movq 3296(%esi), %xmm3 + mulsd %xmm2, %xmm3 + addsd 3288(%esi), %xmm3 + xorl %ecx, %eax + mulsd %xmm2, %xmm3 + xorps %xmm0, %xmm0 + mulsd 3264(%esi), %xmm6 + addsd 3280(%esi), %xmm3 + pinsrw $1, %eax, %xmm0 + addsd 4976(%esi,%ebx), %xmm6 + mulsd %xmm2, %xmm3 + orps %xmm0, %xmm4 + addsd %xmm6, %xmm3 + orps %xmm1, %xmm0 + mulsd 2064(%esi), %xmm3 + cvtsd2ss %xmm3, %xmm3 + addss %xmm4, %xmm0 + movd %xmm0, %edx + movd %xmm3, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_2.0.2: + movsd 32(%esp), %xmm5 + mulsd %xmm5, %xmm5 + movq 16(%esp), %xmm1 + movq 16(%esp), %xmm6 + movq 16(%esp), %xmm2 + subsd %xmm5, %xmm1 + subsd %xmm1, %xmm6 + subsd %xmm1, %xmm3 + subsd %xmm6, %xmm5 + addsd %xmm3, %xmm5 + xorl %ecx, %eax + movsd 4816(%esi), %xmm3 + xorpd %xmm4, %xmm4 + xorpd %xmm7, %xmm7 + sarl $31, %ecx + movd %ecx, %xmm6 + pshufd $0, %xmm6, %xmm6 + andpd 4848(%esi), %xmm6 + subsd 4800(%esi), %xmm2 + andpd %xmm0, %xmm3 + pextrw $3, %xmm0, %edx + movsd %xmm0, %xmm1 + addsd %xmm5, %xmm2 + subl $16288, %edx + cmpl $1119, %edx + ja .L_2TAG_PACKET_8.0.2 + movl $16464, %ecx + pinsrw $3, %ecx, %xmm4 + shrl $16, %eax + orpd 4832(%esi), %xmm3 + movsd %xmm4, %xmm7 + cmpsd $6, %xmm3, %xmm4 + movsd 4800(%esi), %xmm5 + minsd %xmm7, %xmm3 + andpd %xmm4, %xmm0 + mulsd %xmm3, %xmm1 + andpd %xmm4, %xmm5 + subsd %xmm3, %xmm0 + movq 3344(%esi), %xmm3 + addsd %xmm5, %xmm1 + divsd %xmm1, %xmm0 + mulsd %xmm2, %xmm3 + movl $176, %ecx + cmpl $176, %edx + cmova %ecx, %edx + addl $1, %edx + movsd 4880(%esi), %xmm4 + addsd 3336(%esi), %xmm3 + pinsrw $3, %eax, %xmm7 + addsd 3376(%esi,%edx,8), %xmm6 + mulsd %xmm2, %xmm3 + xorpd %xmm7, %xmm6 + addsd 3328(%esi), %xmm3 + xorpd %xmm0, %xmm7 + mulsd %xmm2, %xmm3 + mulsd %xmm0, %xmm0 + addsd 3320(%esi), %xmm3 + mulsd %xmm7, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm6, %xmm7 + addsd 3312(%esi), %xmm3 + mulsd %xmm4, %xmm0 + mulsd %xmm2, %xmm3 + addsd %xmm7, %xmm0 + cvtsd2ss %xmm3, %xmm3 + cvtpd2ps %xmm0, %xmm0 + movd %xmm3, %eax + movd %xmm0, %edx + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_8.0.2: + addl $944, %edx + cmpl $2063, %edx + ja .L_2TAG_PACKET_9.0.2 + movq 4864(%esi), %xmm3 + shrl $16, %eax + movsd 4872(%esi), %xmm4 + pinsrw $3, %eax, %xmm7 + mulsd %xmm1, %xmm1 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm3 + movsd %xmm1, %xmm5 + mulsd %xmm1, %xmm1 + addsd %xmm6, %xmm0 + movq 3344(%esi), %xmm6 + mulsd %xmm2, %xmm6 + addsd 3336(%esi), %xmm6 + mulsd %xmm5, %xmm4 + mulsd %xmm2, %xmm6 + addsd 3328(%esi), %xmm6 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm6 + addsd 3320(%esi), %xmm6 + addsd %xmm4, %xmm1 + mulsd %xmm2, %xmm6 + addsd %xmm1, %xmm0 + addsd 3312(%esi), %xmm6 + xorpd %xmm7, %xmm0 + mulsd %xmm2, %xmm6 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm6, %xmm6 + movd %xmm0, %edx + movd %xmm6, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_9.0.2: + addl $15344, %edx + cmpl $17392, %edx + jae .L_2TAG_PACKET_10.0.2 + movq 3344(%esi), %xmm3 + mulsd %xmm2, %xmm3 + shrl $16, %eax + addsd 3336(%esi), %xmm3 + pinsrw $3, %eax, %xmm7 + mulsd %xmm2, %xmm3 + addsd %xmm6, %xmm0 + addsd 3328(%esi), %xmm3 + pextrw $3, %xmm0, %edx + mulsd %xmm2, %xmm3 + xorpd %xmm7, %xmm0 + addsd 3320(%esi), %xmm3 + andl $32752, %edx + movl $1065353217, %eax + movl 8(%esp), %ecx + movl $8388608, %ecx + mulsd %xmm2, %xmm3 + cmpl $14352, %edx + cmovb %ecx, %eax + movd %eax, %xmm1 + addsd 3312(%esi), %xmm3 + mulss %xmm1, %xmm1 + mulsd %xmm2, %xmm3 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_10.0.2: + movss 4944(%esi), %xmm4 + movq 3344(%esi), %xmm3 + mulsd %xmm2, %xmm3 + movss 4948(%esi), %xmm1 + addsd 3336(%esi), %xmm3 + shrl $16, %eax + mulsd %xmm2, %xmm3 + andl $32768, %ecx + addsd 3328(%esi), %xmm3 + xorl %ecx, %eax + mulsd %xmm2, %xmm3 + xorps %xmm0, %xmm0 + addsd 3320(%esi), %xmm3 + pinsrw $1, %eax, %xmm0 + mulsd %xmm2, %xmm3 + orps %xmm0, %xmm4 + addsd 3312(%esi), %xmm3 + orps %xmm1, %xmm0 + mulsd %xmm2, %xmm3 + addss %xmm4, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_0.0.2: + andl $-2147483648, %ecx +.L_2TAG_PACKET_1.0.2: + movl 4(%esp), %edx + andl $2147483647, %edx + je .L_2TAG_PACKET_11.0.2 + andl $2139095040, %edx + jne .L_2TAG_PACKET_11.0.2 + movss 4(%esp), %xmm0 + orps 4896(%esi), %xmm0 + cvtss2sd %xmm0, %xmm0 + movsd 4928(%esi), %xmm2 + andpd %xmm0, %xmm2 + orpd 4912(%esi), %xmm2 + subsd %xmm2, %xmm0 + movsd %xmm0, 40(%esp) +.L_2TAG_PACKET_11.0.2: + movl (%esp), %edx + andl $2147483647, %edx + je .L_2TAG_PACKET_12.0.2 + andl $2139095040, %edx + jne .L_2TAG_PACKET_12.0.2 + movss (%esp), %xmm1 + orps 4896(%esi), %xmm1 + cvtss2sd %xmm1, %xmm1 + movsd 4928(%esi), %xmm2 + andpd %xmm1, %xmm2 + orpd 4912(%esi), %xmm2 + subsd %xmm2, %xmm1 + movsd %xmm1, 32(%esp) +.L_2TAG_PACKET_12.0.2: + movsd 40(%esp), %xmm0 + movsd 32(%esp), %xmm1 + pextrw $3, %xmm0, %edx + andl $32752, %edx + subl $16, %edx + cmpl $32736, %edx + jae .L_2TAG_PACKET_13.0.2 + pextrw $3, %xmm1, %edx + andl $32752, %edx + subl $16, %edx + cmpl $32736, %edx + jae .L_2TAG_PACKET_14.0.2 + movq %xmm0, %xmm3 + divsd %xmm1, %xmm0 + movq 3232(%esi), %xmm2 + mulsd %xmm1, %xmm1 + mulsd %xmm3, %xmm3 + addsd %xmm3, %xmm1 + movq %xmm1, 16(%esp) + pand %xmm1, %xmm2 + pextrw $3, %xmm1, %edx + subsd 4800(%esi), %xmm1 + pand 3248(%esi), %xmm1 + cmpltsd 2048(%esi), %xmm1 + movmskpd %xmm1, %ebx + por 4800(%esi), %xmm2 + testl $1, %ebx + movl 8(%esp), %ebx + psllq $1, %xmm0 + psrlq $1, %xmm0 + jne .L_2TAG_PACKET_2.0.2 + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_13.0.2: + addl $16, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_15.0.2 + movsd %xmm0, %xmm2 + psllq $12, %xmm2 + xorpd %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + je .L_2TAG_PACKET_16.0.2 + movss 4(%esp), %xmm0 + movl (%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + mulss %xmm0, %xmm0 + jg .L_2TAG_PACKET_17.0.2 + je .L_2TAG_PACKET_18.0.2 + movd %xmm0, %edx + movd %xmm0, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_18.0.2: + movd %xmm0, %edx + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_17.0.2: + movss (%esp), %xmm1 + mulss %xmm0, %xmm0 + mulss %xmm1, %xmm1 + movd %xmm0, %edx + movd %xmm1, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_15.0.2: + pextrw $3, %xmm1, %edx + andl $32752, %edx + cmpl $32752, %edx + jne .L_2TAG_PACKET_19.0.2 + movsd %xmm1, %xmm2 + psllq $12, %xmm2 + xorpd %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + jne .L_2TAG_PACKET_20.0.2 +.L_2TAG_PACKET_19.0.2: + cmpl $0, %ecx + jne .L_2TAG_PACKET_21.0.2 + movl %eax, %edx + movl (%esp), %eax + cmpl $0, %eax + je .L_2TAG_PACKET_22.0.2 + cmpl $2139095040, %eax + je .L_2TAG_PACKET_23.0.2 + movl (%esp), %eax + movl %edx, 28(%esp) + andl $2147483647, %eax + movl %eax, 24(%esp) + jmp .L_2TAG_PACKET_24.0.2 +.L_2TAG_PACKET_21.0.2: + movss 4952(%esi), %xmm2 + movss 4956(%esi), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl (%esp), %eax + cmpl $-2147483648, %eax + je .L_2TAG_PACKET_22.0.2 + cmpl $-8388608, %eax + je .L_2TAG_PACKET_23.0.2 + movl (%esp), %eax + movl %edx, 28(%esp) + andl $2147483647, %eax + movl %eax, 24(%esp) + jmp .L_2TAG_PACKET_24.0.2 +.L_2TAG_PACKET_22.0.2: + pxor %xmm1, %xmm1 + movss 3216(%esi), %xmm0 + divss %xmm1, %xmm0 + movl $-8388608, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_23.0.2: + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_16.0.2: + pextrw $3, %xmm1, %edx + andl $32752, %edx + cmpl $32752, %edx + je .L_2TAG_PACKET_25.0.2 + movss 4944(%esi), %xmm2 + movss 4948(%esi), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_25.0.2: + movsd %xmm1, %xmm2 + psllq $12, %xmm2 + xorpd %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + jne .L_2TAG_PACKET_26.0.2 + cmpl $0, %ecx + je .L_2TAG_PACKET_27.0.2 + movss 4944(%esi), %xmm2 + movss 4948(%esi), %xmm3 + movss 4960(%esi), %xmm4 + movss 4964(%esi), %xmm5 + addss %xmm3, %xmm2 + addss %xmm5, %xmm4 + addss %xmm4, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_27.0.2: + movss 4960(%esi), %xmm4 + movss 4964(%esi), %xmm5 + addss %xmm5, %xmm4 + movd %xmm4, %edx + orl %eax, %edx + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_14.0.2: + addl $16, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_28.0.2 + movsd %xmm1, %xmm2 + psllq $12, %xmm2 + xorps %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + jne .L_2TAG_PACKET_20.0.2 + cmpl $0, %ecx + jne .L_2TAG_PACKET_29.0.2 + movl %eax, %edx + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_29.0.2: + movss 4952(%esi), %xmm2 + movss 4956(%esi), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_28.0.2: + movss 4944(%esi), %xmm2 + movss 4948(%esi), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl 4(%esp), %eax + movl %edx, 28(%esp) + andl $2147483647, %eax + movl %eax, 24(%esp) + jmp .L_2TAG_PACKET_24.0.2 +.L_2TAG_PACKET_20.0.2: + addsd %xmm1, %xmm1 + cvtpd2ps %xmm1, %xmm0 + movd %xmm0, %edx + movl %edx, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_26.0.2: + addsd %xmm1, %xmm1 + cvtpd2ps %xmm1, %xmm0 + movd %xmm0, %edx + movl $2139095040, %eax + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_24.0.2: + movss 24(%esp), %xmm0 + movsd 3168(%esi), %xmm1 + movsd 3184(%esi), %xmm3 + pextrw $1, %xmm0, %eax + movaps %xmm0, %xmm4 + psllq $29, %xmm0 + andpd %xmm0, %xmm1 + orpd %xmm3, %xmm1 + movsd 2080(%esi), %xmm5 + movsd 2088(%esi), %xmm6 + movsd 2096(%esi), %xmm2 + movl %eax, %edx + movl $32639, %ecx + subl %edx, %ecx + subl $128, %edx + orl %ecx, %edx + cmpl $32768, %edx + jae .L_2TAG_PACKET_30.0.2 + movl $16191, %ecx +.L_2TAG_PACKET_31.0.2: + movd %ecx, %xmm0 + movsd 2640(%esi), %xmm3 + andl $127, %eax + addl $1, %eax + andl $254, %eax + addl %eax, %eax + addl %eax, %eax + movsd 2640(%esi,%eax), %xmm7 + psrlq $16, %xmm4 + psubd %xmm0, %xmm4 + psrad $7, %xmm4 + cvtdq2pd %xmm4, %xmm4 + movsd 2112(%esi,%eax), %xmm0 + mulsd %xmm7, %xmm1 + subsd %xmm3, %xmm1 + movsd %xmm1, %xmm7 + mulsd %xmm1, %xmm5 + movsd %xmm1, %xmm3 + mulsd %xmm1, %xmm1 + addsd %xmm6, %xmm5 + mulsd 3264(%esi), %xmm4 + mulsd %xmm1, %xmm7 + mulsd %xmm1, %xmm2 + addsd %xmm3, %xmm2 + mulsd %xmm5, %xmm7 + addsd %xmm4, %xmm0 + addsd %xmm7, %xmm2 + addsd %xmm2, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movd %xmm0, %eax + movl 28(%esp), %edx + movl 8(%esp), %ebx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_30.0.2: + movl 24(%esp), %edx + mulss 3200(%esi), %xmm4 + movsd 3168(%esi), %xmm1 + pextrw $1, %xmm4, %eax + cvtps2pd %xmm4, %xmm0 + andpd %xmm0, %xmm1 + orpd %xmm3, %xmm1 + movl $24383, %ecx + jmp .L_2TAG_PACKET_31.0.2 +.L_2TAG_PACKET_5.0.2: + movl 80(%esp), %esi + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type clogf,@function + .size clogf,.-clogf + .data +# -- End clogf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .long 3951369912 + .long 1067366481 + .long 3951369912 + .long 3214850129 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .long 0 + .long 3218079744 + .long 1431655765 + .long 1070945621 + .long 0 + .long 3219128320 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2969299638 + .long 1066385576 + .long 242759278 + .long 1067418267 + .long 4130528649 + .long 1067938904 + .long 3222363743 + .long 1068436016 + .long 2518406343 + .long 1068712407 + .long 2330290349 + .long 1068953810 + .long 977983493 + .long 1069191789 + .long 1848308976 + .long 1069426439 + .long 2094042057 + .long 1069602686 + .long 4162844547 + .long 1069716818 + .long 1825274911 + .long 1069829419 + .long 1890030541 + .long 1069940528 + .long 34658761 + .long 1070050185 + .long 2633258952 + .long 1070158426 + .long 1317059912 + .long 1070265289 + .long 3348798148 + .long 1070370807 + .long 1848308976 + .long 1070475015 + .long 1834892534 + .long 1070577944 + .long 3799224489 + .long 1070637860 + .long 2880153273 + .long 1070688092 + .long 4224678190 + .long 1070737729 + .long 3135315492 + .long 1070786786 + .long 1432962655 + .long 1070835276 + .long 3256639515 + .long 1070883211 + .long 2267936667 + .long 1070930605 + .long 3210218142 + .long 1070977469 + .long 513480033 + .long 1071023816 + .long 4139503392 + .long 1071069655 + .long 998420681 + .long 1071115000 + .long 2260812359 + .long 1071159859 + .long 471930696 + .long 1071204244 + .long 288677044 + .long 3218237794 + .long 1666870396 + .long 3218194329 + .long 2183652263 + .long 3218151310 + .long 1615681869 + .long 3218108728 + .long 1823715893 + .long 3218053404 + .long 4293333700 + .long 3217969934 + .long 4066729029 + .long 3217887287 + .long 943445964 + .long 3217805447 + .long 1015733272 + .long 3217724397 + .long 3707174790 + .long 3217644122 + .long 1699848676 + .long 3217564609 + .long 2339728692 + .long 3217485842 + .long 1800683248 + .long 3217407808 + .long 2201203741 + .long 3217330493 + .long 2954203727 + .long 3217253884 + .long 709476838 + .long 3217177969 + .long 2183652973 + .long 3217102734 + .long 970708496 + .long 3217025169 + .long 1669614391 + .long 3216877351 + .long 2376949106 + .long 3216730824 + .long 1566133827 + .long 3216585566 + .long 183157569 + .long 3216441555 + .long 1562411141 + .long 3216298769 + .long 2756121236 + .long 3216157188 + .long 3047046473 + .long 3216016792 + .long 3453858674 + .long 3215772531 + .long 346008798 + .long 3215496362 + .long 3559775130 + .long 3215222446 + .long 2313636156 + .long 3214950749 + .long 684243850 + .long 3214428453 + .long 1486053291 + .long 3213893718 + .long 1971906393 + .long 3212840981 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 528611360 + .long 1072660984 + .long 4034666248 + .long 1072629697 + .long 2884679527 + .long 1072599345 + .long 505290270 + .long 1072569886 + .long 1991868891 + .long 1072541280 + .long 490853405 + .long 1072513492 + .long 2298714891 + .long 1072486486 + .long 477218588 + .long 1072460231 + .long 58835168 + .long 1072434695 + .long 348240592 + .long 1072409849 + .long 3035110223 + .long 1072385665 + .long 3164712744 + .long 1072362118 + .long 1617585086 + .long 1072339183 + .long 440509466 + .long 1072316836 + .long 2500867033 + .long 1072295054 + .long 2576980378 + .long 1072273817 + .long 4241943008 + .long 1072253104 + .long 2409371898 + .long 1072232897 + .long 258732970 + .long 1072213177 + .long 409044504 + .long 1072193926 + .long 404232216 + .long 1072175128 + .long 1098712564 + .long 1072156767 + .long 2172167368 + .long 1072138828 + .long 1952257862 + .long 1072121297 + .long 1544257904 + .long 1072104160 + .long 381774871 + .long 1072087404 + .long 377579543 + .long 1072071016 + .long 1493901668 + .long 1072054984 + .long 1616385542 + .long 1072039297 + .long 731058263 + .long 1072023944 + .long 813783277 + .long 1072008914 + .long 1431655765 + .long 1071994197 + .long 3940743189 + .long 1071979783 + .long 2804876601 + .long 1071965664 + .long 2689777499 + .long 1071951830 + .long 1202590843 + .long 1071938273 + .long 1700977147 + .long 1071924984 + .long 336860180 + .long 1071911956 + .long 3169102082 + .long 1071899180 + .long 330382100 + .long 1071886651 + .long 327235604 + .long 1071874360 + .long 4213930177 + .long 1071862300 + .long 1244336319 + .long 1071850467 + .long 3181457256 + .long 1071838852 + .long 1300311200 + .long 1071827451 + .long 702812830 + .long 1071816257 + .long 3095471925 + .long 1071805264 + .long 2454267026 + .long 1071794468 + .long 2166487928 + .long 1071783863 + .long 2109808496 + .long 1071773444 + .long 2913108253 + .long 1071763206 + .long 1629125526 + .long 1071753145 + .long 293672978 + .long 1071743256 + .long 1601513229 + .long 1071733534 + .long 288737297 + .long 1071723976 + .long 286331153 + .long 1071714577 + .long 1810275472 + .long 1071705333 + .long 1337776699 + .long 1071696241 + .long 174592167 + .long 1071687297 + .long 138547332 + .long 1071678497 + .long 3539053052 + .long 1071669837 + .long 272696336 + .long 1071661316 + .long 2164392968 + .long 1071652928 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 1602224128 + .long 1602224128 + .long 0 + .long 0 + .long 1065353216 + .long 1065353216 + .long 0 + .long 0 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4277811695 + .long 1072049730 + .long 4277811695 + .long 1072049730 + .long 0 + .long 1072693248 + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .long 0 + .long 0 + .long 12982 + .long 1071644672 + .long 3503368358 + .long 3218079743 + .long 300625100 + .long 1069897045 + .long 3513684914 + .long 3217031970 + .long 1735899863 + .long 1069129695 + .long 0 + .long 0 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3819695742 + .long 1067482761 + .long 2998791009 + .long 1067548225 + .long 3339424991 + .long 1067613680 + .long 2710002256 + .long 1067679126 + .long 3275701428 + .long 1067744562 + .long 2908636881 + .long 1067809988 + .long 3777889398 + .long 1067875403 + .long 3759667419 + .long 1067940807 + .long 732369940 + .long 1068006200 + .long 1166616461 + .long 1068071580 + .long 2945472892 + .long 1068136947 + .long 3954480976 + .long 1068202301 + .long 2081752829 + .long 1068267642 + .long 3807999788 + .long 1068332968 + .long 2731789884 + .long 1068398280 + .long 1044477961 + .long 1068463577 + .long 1486930287 + .long 1068530218 + .long 2293016881 + .long 1068595466 + .long 201518157 + .long 1068660680 + .long 4054234584 + .long 1068725856 + .long 1246477213 + .long 1068790995 + .long 678186699 + .long 1068856093 + .long 2690594995 + .long 1068921148 + .long 3362611517 + .long 1068986159 + .long 3102162111 + .long 1069051124 + .long 2352611067 + .long 1069116041 + .long 1594134794 + .long 1069180908 + .long 1345079306 + .long 1069245723 + .long 2163300970 + .long 1069310484 + .long 352522716 + .long 1069375190 + .long 848541647 + .long 1069439838 + .long 40647312 + .long 1069504427 + .long 2216766270 + .long 1069574357 + .long 1090914384 + .long 1069638757 + .long 387601244 + .long 1069703022 + .long 3991640484 + .long 1069767144 + .long 3322489502 + .long 1069831118 + .long 3121698570 + .long 1069894936 + .long 4289964660 + .long 1069958591 + .long 3903312386 + .long 1070022077 + .long 3818449864 + .long 1070085387 + .long 2097480306 + .long 1070148515 + .long 1611694502 + .long 1070211454 + .long 1464694796 + .long 1070274198 + .long 1299612775 + .long 1070336741 + .long 1310544789 + .long 1070399077 + .long 2253168030 + .long 1070461200 + .long 1159567373 + .long 1070523105 + .long 1359373750 + .long 1070605818 + .long 908341706 + .long 1070667034 + .long 1743027350 + .long 1070727765 + .long 2055355646 + .long 1070787992 + .long 690426164 + .long 1070847697 + .long 1483247847 + .long 1070906862 + .long 392040270 + .long 1070965472 + .long 2673846014 + .long 1071023511 + .long 1384215810 + .long 1071080967 + .long 3101660631 + .long 1071137826 + .long 2094057058 + .long 1071194078 + .long 1712750594 + .long 1071249712 + .long 1411515787 + .long 1071304719 + .long 931538085 + .long 1071359091 + .long 179139065 + .long 1071412821 + .long 3387721259 + .long 1071465902 + .long 2132236852 + .long 1071544299 + .long 1942070284 + .long 1071645596 + .long 1532707802 + .long 1071695380 + .long 2294184979 + .long 1071743834 + .long 3805060714 + .long 1071790961 + .long 2215037898 + .long 1071836770 + .long 483661594 + .long 1071881273 + .long 1534679894 + .long 1071924486 + .long 1538714628 + .long 1071966430 + .long 527642555 + .long 1072007128 + .long 291339150 + .long 1072046605 + .long 2450210201 + .long 1072084888 + .long 2411367951 + .long 1072122007 + .long 681549971 + .long 1072157992 + .long 1466745541 + .long 1072192873 + .long 2845622366 + .long 1072226682 + .long 2838871438 + .long 1072275456 + .long 4200275274 + .long 1072337034 + .long 3034733530 + .long 1072394897 + .long 3207412993 + .long 1072449290 + .long 624461478 + .long 1072500450 + .long 767665908 + .long 1072548600 + .long 1110773639 + .long 1072593952 + .long 1940828530 + .long 1072636704 + .long 1911329388 + .long 1072677041 + .long 1764715788 + .long 1072704191 + .long 3332979233 + .long 1072722195 + .long 1321870254 + .long 1072739231 + .long 3657429030 + .long 1072755365 + .long 4197624557 + .long 1072770661 + .long 1512059493 + .long 1072785177 + .long 453379037 + .long 1072798965 + .long 1942345162 + .long 1072818388 + .long 4210176273 + .long 1072842164 + .long 4185644010 + .long 1072863795 + .long 679688788 + .long 1072883543 + .long 29432865 + .long 1072901630 + .long 4070721092 + .long 1072918247 + .long 2252468843 + .long 1072933561 + .long 2929724825 + .long 1072947712 + .long 1377513368 + .long 1072960824 + .long 1031632908 + .long 1072973003 + .long 2516508130 + .long 1072984342 + .long 3792452178 + .long 1072994923 + .long 3147791459 + .long 1073004818 + .long 999189752 + .long 1073014090 + .long 711011011 + .long 1073022794 + .long 15640363 + .long 1073030980 + .long 1218463589 + .long 1073042382 + .long 2538470555 + .long 1073056144 + .long 1229720947 + .long 1073068489 + .long 3115427016 + .long 1073079621 + .long 4030612557 + .long 1073089709 + .long 2728521257 + .long 1073098892 + .long 1118696283 + .long 1073107285 + .long 2682711255 + .long 1073114984 + .long 2073898081 + .long 1073122072 + .long 1403700297 + .long 1073128618 + .long 2502685617 + .long 1073134681 + .long 1531926851 + .long 1073140313 + .long 3572814411 + .long 1073145557 + .long 1695536111 + .long 1073150453 + .long 2363057203 + .long 1073155033 + .long 2873365682 + .long 1073159327 + .long 1053384691 + .long 1073165288 + .long 3270542712 + .long 1073172451 + .long 1353631484 + .long 1073178850 + .long 3511218460 + .long 1073184599 + .long 4121259284 + .long 1073189793 + .long 1193862106 + .long 1073194509 + .long 3861949790 + .long 1073198808 + .long 1486904578 + .long 1073202745 + .long 2879153715 + .long 1073206362 + .long 385353253 + .long 1073209698 + .long 1125865839 + .long 1073212783 + .long 1221361475 + .long 1073215645 + .long 2077323573 + .long 1073218307 + .long 215611373 + .long 1073220790 + .long 2347419265 + .long 1073223110 + .long 1379112765 + .long 1073225284 + .long 3891198463 + .long 1073228298 + .long 3395914051 + .long 1073231917 + .long 2799919478 + .long 1073235146 + .long 1138673476 + .long 1073238045 + .long 3408855940 + .long 1073240661 + .long 2044858738 + .long 1073243035 + .long 2578795176 + .long 1073245198 + .long 4196285314 + .long 1073247177 + .long 224877747 + .long 1073248996 + .long 3271386490 + .long 1073250671 + .long 813635989 + .long 1073252221 + .long 369829519 + .long 1073253658 + .long 1187679052 + .long 1073254994 + .long 4232586098 + .long 1073256239 + .long 426690558 + .long 1073257404 + .long 1624065902 + .long 1073258494 + .long 84029729 + .long 1073260006 + .long 700437654 + .long 1073261820 + .long 1437260555 + .long 1073263438 + .long 2813372195 + .long 1073264890 + .long 1607849324 + .long 1073266201 + .long 1011572952 + .long 1073267390 + .long 2039290225 + .long 1073268473 + .long 2435855138 + .long 1073269464 + .long 3389310384 + .long 1073270374 + .long 2790682322 + .long 1073271213 + .long 960266323 + .long 1073271989 + .long 1766929455 + .long 1073272708 + .long 627058932 + .long 1073273377 + .long 2388650377 + .long 1073274000 + .long 422252385 + .long 1073274583 + .long 2848853896 + .long 1073275128 + .long 1413754136 + .long 1073291771 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 2147418112 + .long 0 + .long 2147418112 + .long 0 + .long 32768 + .long 0 + .long 32768 + .long 1413754136 + .long 3221823995 + .long 0 + .long 0 + .long 2576980378 + .long 1070176665 + .long 1431655765 + .long 3218429269 + .long 1431655765 + .long 3218429269 + .long 1431655765 + .long 3218429269 + .long 8388608 + .long 0 + .long 0 + .long 0 + .long 0 + .long 940572672 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 1070141402 + .long 866263400 + .long 1078530010 + .long 874652008 + .long 1061752794 + .long 857874792 + .long 0 + .long 0 + .long 1440057502 + .long 1063257089 + .long 341338964 + .long 1064833554 + .long 4184355568 + .long 1065621801 + .long 2227658503 + .long 1066152307 + .long 449262470 + .long 1066510009 + .long 1570422842 + .long 1066777242 + .long 121841140 + .long 1067045544 + .long 630691842 + .long 1067281191 + .long 2711485097 + .long 1067500943 + .long 2026622491 + .long 1067619660 + .long 766078039 + .long 1067755853 + .long 4074027864 + .long 1067875476 + .long 3056660584 + .long 1067995528 + .long 3195252556 + .long 1068133258 + .long 116861598 + .long 1068254238 + .long 325086471 + .long 1068375655 + .long 296456961 + .long 1068497513 + .long 2623383041 + .long 1068559379 + .long 1681725707 + .long 1068620754 + .long 2231263004 + .long 1068682354 + .long 2815553124 + .long 1068744181 + .long 2057310944 + .long 1068806237 + .long 2095798018 + .long 1068859611 + .long 2302040698 + .long 1068922096 + .long 745232013 + .long 1068984815 + .long 659581512 + .long 1069047769 + .long 1566132617 + .long 1069101918 + .long 550036981 + .long 1069165314 + .long 2887419564 + .long 1069219844 + .long 1990183441 + .long 1069283688 + .long 3220050856 + .long 1069338605 + .long 1669613218 + .long 1069393703 + .long 2145455994 + .long 1069458213 + .long 4275830246 + .long 1069513705 + .long 1392453108 + .long 1069558451 + .long 1469915213 + .long 1069586382 + .long 2183652476 + .long 1069619086 + .long 2109656884 + .long 1069647220 + .long 636640577 + .long 1069675449 + .long 510517079 + .long 1069703773 + .long 210141498 + .long 1069732193 + .long 2537624622 + .long 1069760709 + .long 1733817001 + .long 1069789323 + .long 137854980 + .long 1069813243 + .long 3905576828 + .long 1069842036 + .long 4131810788 + .long 1069870929 + .long 3760956694 + .long 1069899922 + .long 1473082581 + .long 1069929016 + .long 926113142 + .long 1069953338 + .long 3669742467 + .long 1069982617 + .long 3711755290 + .long 1070007095 + .long 311386407 + .long 1070036564 + .long 705364525 + .long 1070066136 + .long 1973375279 + .long 1070090859 + .long 3589645072 + .long 1070115655 + .long 2425772059 + .long 1070145508 + .long 1074899574 + .long 1070170467 + .long 118003300 + .long 1070200516 + .long 691310403 + .long 1070225639 + .long 3273036717 + .long 1070250837 + .long 1226436560 + .long 1070276112 + .long 2481153995 + .long 1070306542 + .long 3227997535 + .long 1070331985 + .long 1421812646 + .long 1070357506 + .long 3386588242 + .long 1070383104 + .long 2580043380 + .long 1070408781 + .long 1068692560 + .long 1070434537 + .long 938143489 + .long 1070460372 + .long 4293333010 + .long 1070486286 + .long 373864817 + .long 1070512282 + .long 4208958430 + .long 1070538357 + .long 783121462 + .long 1070564515 + .long 870975437 + .long 1070590754 + .long 3338886172 + .long 1070606585 + .long 3772343130 + .long 1070619787 + .long 2408245143 + .long 1070630379 + .long 3811383569 + .long 1070643656 + .long 1622638721 + .long 1070656976 + .long 1290798655 + .long 1070670338 + .long 2457529556 + .long 1070681058 + .long 2398194399 + .long 1070694497 + .long 3190801979 + .long 1070707979 + .long 3352241197 + .long 1070718796 + .long 1829681364 + .long 1070732357 + .long 2568927817 + .long 1070743237 + .long 2676427515 + .long 1070756877 + .long 2882402820 + .long 1070767821 + .long 44944622 + .long 1070781542 + .long 2957945300 + .long 1070792550 + .long 1261787704 + .long 1070806352 + .long 1589923677 + .long 1070817426 + .long 3274931829 + .long 1070828529 + .long 1999843716 + .long 1070842450 + .long 1673619518 + .long 1070853620 + .long 601221319 + .long 1070864820 + .long 3763576649 + .long 1070876049 + .long 1974923437 + .long 1070890129 + .long 1096100617 + .long 1070901427 + .long 2424897952 + .long 1070912755 + .long 2376202600 + .long 1070924114 + .long 1665651958 + .long 1070935504 + .long 1014729354 + .long 1070946925 + .long 722545241 + .long 1070961245 + .long 1800682930 + .long 1070972736 + .long 1029453230 + .long 1070984259 + .long 3450874911 + .long 1070995813 + .long 1228255906 + .long 1071007400 + .long 3711032981 + .long 1071019018 + .long 3075102917 + .long 1071030669 + .long 92696812 + .long 1071042353 + .long 3897749690 + .long 1071051136 + .long 1907922160 + .long 1071062877 + .long 4023807324 + .long 1071074650 + .long 2452345726 + .long 1071086457 + .long 2292128226 + .long 1071098297 + .long 58635942 + .long 1071110171 + .long 864186929 + .long 1071122078 + .long 3555691467 + .long 1071131030 + .long 2003684347 + .long 1071142997 + .long 1479703759 + .long 1071154998 + .long 2537208015 + .long 1071164021 + .long 3699909861 + .long 1071176082 + .long 3934098706 + .long 1071188178 + .long 3885764182 + .long 1071197273 + .long 1357790931 + .long 1071209431 + .long 295956059 + .long 1071221624 + .long 4080877676 + .long 1071230791 + .long 202970280 + .long 1071243047 + .long 3977575845 + .long 1071252261 + .long 35977849 + .long 1071264580 + .long 1585496963 + .long 1071273842 + .long 375247257 + .long 1071286224 + .long 1812199574 + .long 1071295534 + .long 1876912769 + .long 1071307980 + .long 1051846544 + .long 1071317339 + .long 979589448 + .long 1071329850 + .long 71706889 + .long 1071339258 + .long 2790898835 + .long 1071351834 + .long 4013797733 + .long 1071361291 + .long 2541231151 + .long 1071370770 + .long 921733145 + .long 1071383442 + .long 508375805 + .long 1071392971 + .long 3091669954 + .long 1071402521 + .long 3343209673 + .long 1071415289 + .long 1693047557 + .long 1071424891 + .long 173861808 + .long 1071434515 + .long 3515822703 + .long 1071444160 + .long 1974837761 + .long 1071457056 + .long 1189018219 + .long 1071466754 + .long 2441946573 + .long 1071476474 + .long 1887102255 + .long 1071486217 + .long 4271031636 + .long 1071495982 + .long 876995759 + .long 1071509039 + .long 438773454 + .long 1071518858 + .long 172621632 + .long 1071528700 + .long 544035182 + .long 1071538565 + .long 2021801298 + .long 1071548453 + .long 783063308 + .long 1071558365 + .long 1598254051 + .long 1071568300 + .long 651258553 + .long 1071578259 + .long 2719315456 + .long 1071588241 + .long 3993180461 + .long 1071598247 + .long 667093936 + .long 1071608278 + .long 1823716217 + .long 1071618332 + .long 3664357648 + .long 1071628410 + .long 2393914686 + .long 1071638513 + .long 1405419566 + .long 1071646656 + .long 563652001 + .long 1071651732 + .long 1074554091 + .long 1071656820 + .long 3195405229 + .long 1071661920 + .long 2890399284 + .long 1071667033 + .long 420597586 + .long 1071672159 + .long 87278952 + .long 1071675583 + .long 1753119502 + .long 1071680729 + .long 1959759897 + .long 1071685888 + .long 975389815 + .long 1071691060 + .long 3365155278 + .long 1071696244 + .long 811309190 + .long 1071701442 + .long 1269811480 + .long 1071704914 + .long 1108583542 + .long 1071710133 + .long 1034517919 + .long 1071715365 + .long 1327340287 + .long 1071720610 + .long 1388251237 + .long 1071724114 + .long 1488234797 + .long 1071729381 + .long 2711385691 + .long 1071734661 + .long 952179194 + .long 1071738189 + .long 3255685427 + .long 1071743491 + .long 3159039803 + .long 1071748807 + .long 951558972 + .long 1071752359 + .long 3234424125 + .long 1071757697 + .long 3904573547 + .long 1071763049 + .long 2648729924 + .long 1071766625 + .long 2729250212 + .long 1071772000 + .long 2000712574 + .long 1071777389 + .long 3125257108 + .long 1071780989 + .long 3160324803 + .long 1071786401 + .long 2216316974 + .long 1071790017 + .long 3875016090 + .long 1071795452 + .long 1439520610 + .long 1071799084 + .long 1298103361 + .long 1071804543 + .long 2217517956 + .long 1071810016 + .long 1191753587 + .long 1071813673 + .long 1728773900 + .long 1071819170 + .long 747445441 + .long 1071822843 + .long 1670772213 + .long 1071826522 + .long 1471209283 + .long 1071832053 + .long 3287905877 + .long 1071835748 + .long 594038131 + .long 1071841304 + .long 3920147917 + .long 1071845015 + .long 3957142762 + .long 1071850595 + .long 826988438 + .long 1071854324 + .long 242509008 + .long 1071859929 + .long 4173610350 + .long 1071863673 + .long 2518313625 + .long 1071867425 + .long 2671523434 + .long 1071873065 + .long 387544807 + .long 1071876834 + .long 1470497767 + .long 1071880609 + .long 4269259217 + .long 1071886284 + .long 1345663925 + .long 1071890077 + .long 2159323299 + .long 1071893876 + .long 957937516 + .long 1071899588 + .long 2994656967 + .long 1071903404 + .long 556124819 + .long 1071907228 + .long 1631098658 + .long 1071912976 + .long 1368257861 + .long 1071916817 + .long 1309849279 + .long 1071920665 + .long 1567156841 + .long 1071924520 + .long 1179420986 + .long 1071930316 + .long 569448444 + .long 1071934189 + .long 669557459 + .long 1071938069 + .long 1593834700 + .long 1071941956 + .long 3166083125 + .long 1071947800 + .long 211641815 + .long 1071951706 + .long 2780675719 + .long 1071955618 + .long 2400234567 + .long 1071959538 + .long 3482927192 + .long 1071963465 + .long 1852089988 + .long 1071967400 + .long 1020849000 + .long 1071973316 + .long 1718090839 + .long 1071977269 + .long 121152472 + .long 1071981230 + .long 646346839 + .long 1071985198 + .long 3415709705 + .long 1071989173 + .long 4257004898 + .long 1071993156 + .long 3293664199 + .long 1071997147 + .long 649825382 + .long 1072001146 + .long 248887552 + .long 1072007158 + .long 2541522737 + .long 1072011175 + .long 3593780107 + .long 1072015200 + .long 3533041935 + .long 1072019233 + .long 2487426809 + .long 1072023274 + .long 585795318 + .long 1072027323 + .long 2252723088 + .long 1072031379 + .long 3323604690 + .long 1072035443 + .long 3929561382 + .long 1072039515 + .long 4202479723 + .long 1072043595 + .long 4275017539 + .long 1072047683 + .type static_const_table,@object + .size static_const_table,7024 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/clogl.S b/external/sgx_libm/ia32/clogl.S new file mode 100644 index 0000000000..995d8729e9 --- /dev/null +++ b/external/sgx_libm/ia32/clogl.S @@ -0,0 +1,751 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clogl.c" + .text +..TXTST0: +# -- Begin clogl + .text + .align 16,0x90 + .globl clogl +clogl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + movl %edx, 124(%esp) + fstpt 100(%esp) + fldt 100(%esp) + fstpt 112(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.78 +..B1.4: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.5: + fldcw 12(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %ecx + andl $32767, %ecx + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $32767, %ecx + jge ..B1.47 +..B1.8: + cmpl $32767, %edx + jge ..B1.89 +..B1.9: + testl %ecx, %ecx + jne ..B1.15 +..B1.10: + cmpl $0, 16(%ebp) + jne ..B1.15 +..B1.11: + cmpl $0, 12(%ebp) + jne ..B1.15 +..B1.12: + testl %edx, %edx + jne ..B1.15 +..B1.13: + cmpl $0, 28(%ebp) + jne ..B1.15 +..B1.14: + cmpl $0, 24(%ebp) + je ..B1.46 +..B1.15: + fldt 12(%ebp) + fld %st(0) + fabs + fstpt (%esp) + fldt (%esp) + fldt 24(%ebp) + fld %st(0) + fabs + fstpt 16(%esp) + fldt 16(%esp) + movzwl 8(%esp), %ecx + movzwl 24(%esp), %edx + andl $32767, %ecx + andl $32767, %edx + cmpl %edx, %ecx + jl ..B1.20 +..B1.16: + jne ..B1.21 +..B1.17: + movl 4(%esp), %edx + movl 20(%esp), %eax + cmpl %eax, %edx + jb ..B1.20 +..B1.18: + jne ..B1.21 +..B1.19: + movl (%esp), %edx + cmpl 16(%esp), %edx + jae ..B1.21 +..B1.20: + fstpt (%esp) + fldt (%esp) + movzwl 8(%esp), %ecx + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + andl $32767, %ecx +..B1.21: + cmpl $16382, %ecx + jg ..B1.26 +..B1.22: + jne ..B1.43 +..B1.23: + movl 4(%esp), %edx + cmpl 16+_CONSTANTS@GOTOFF(%ebx), %edx + ja ..B1.26 +..B1.24: + jne ..B1.43 +..B1.25: + movl 12+_CONSTANTS@GOTOFF(%ebx), %edx + cmpl (%esp), %edx + ja ..B1.43 +..B1.26: + cmpl $16383, %ecx + jl ..B1.31 +..B1.27: + jne ..B1.43 +..B1.28: + movl 4(%esp), %edx + cmpl 28+_CONSTANTS@GOTOFF(%ebx), %edx + jb ..B1.31 +..B1.29: + jne ..B1.43 +..B1.30: + movl (%esp), %edx + cmpl 24+_CONSTANTS@GOTOFF(%ebx), %edx + ja ..B1.43 +..B1.31: + movzwl 24(%esp), %edx + andl $32767, %edx + cmpl $8256, %edx + jg ..B1.36 +..B1.32: + jne ..B1.37 +..B1.33: + movl 20(%esp), %eax + cmpl 64+_CONSTANTS@GOTOFF(%ebx), %eax + ja ..B1.36 +..B1.34: + jne ..B1.37 +..B1.35: + movl 16(%esp), %eax + cmpl 60+_CONSTANTS@GOTOFF(%ebx), %eax + jbe ..B1.37 +..B1.36: + fldt _CONSTANTS@GOTOFF(%ebx) + fld %st(3) + fmul %st(4), %st + fld %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + fsubr %st, %st(1) + fxch %st(1) + fabs + fxch %st(2) + fcomp %st(2) + fnstsw %ax + sahf + fxch %st(1) + ja ..B1.38 + jmp ..B1.90 +..B1.37: + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + fld %st(3) + fmul %st(4), %st + fsub %st(1), %st + fabs + fldt _CONSTANTS@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.90 +..B1.38: + cmpl $16183, %edx + jl ..B1.40 +..B1.39: + fstp %st(0) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fld %st(4) + fxch %st(4) + fstpt (%esp) + fxch %st(5) + fstpt 16(%esp) + fld %st(3) + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + fsub %st, %st(4) + fsubp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fld %st(3) + fxch %st(5) + fsubr %st, %st(6) + fxch %st(2) + fmul %st(4), %st + fsub %st, %st(5) + fsubp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fxch %st(4) + fsub %st(5), %st + fxch %st(5) + fmul %st(7), %st + fmul %st(5), %st + fstpt 56(%esp) + fldt 56(%esp) + fxch %st(5) + fmul %st(0), %st + fstpt 72(%esp) + fld %st(0) + fadd %st(4), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(6) + fmulp %st, %st(1) + fmul %st(4), %st + fxch %st(1) + fsubrp %st, %st(5) + fld %st(4) + fadd %st(2), %st + fld %st(0) + fsub %st(6), %st + fsubr %st, %st(3) + fld %st(1) + fsubp %st, %st(1) + fsubrp %st, %st(6) + fxch %st(5) + faddp %st, %st(2) + fld %st(4) + fadd %st(1), %st + fld %st(0) + faddp %st, %st(4) + fld %st(3) + fxch %st(5) + fmul %st(0), %st + fstpt 40(%esp) + fldt 40(%esp) + faddp %st, %st(5) + fxch %st(4) + fstpt 88(%esp) + fldt 88(%esp) + fldt 72(%esp) + faddp %st, %st(1) + fldt 12+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + fldt _Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fmulp %st, %st(1) + fld %st(5) + fsub %st(7), %st + fsubr %st, %st(3) + fsubr %st(6), %st + fsubrp %st, %st(7) + fxch %st(6) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(2) + fsub %st(4), %st + fldt 56(%esp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(4), %st + fsubrp %st, %st(5) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fldt 88(%esp) + fld %st(0) + fsub %st(3), %st + fldt 40(%esp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(2), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(2) + fsub %st(2), %st + fldt 72(%esp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(4), %st + fsubrp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 100(%esp) + addl $-32, %esp + fldt 32(%esp) + fstpt (%esp) + fldt 48(%esp) + fstpt 12(%esp) + call atan2l@PLT + jmp ..B1.87 +..B1.40: + cmpl $16383, %ecx + je ..B1.54 +..B1.41: + fstp %st(2) + fxch %st(1) + fstpt 28(%esp) +..B1.42: + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fmul %st(3), %st + fld %st(3) + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fsubp %st, %st(2) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(3), %st + fld %st(0) + fxch %st(4) + fmul %st(0), %st + fadd %st, %st(4) + fxch %st(1) + fsubr %st(4), %st + fsubrp %st, %st(1) + fld %st(1) + fadd %st(4), %st + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + faddp %st, %st(3) + fld %st(0) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fldt _Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 100(%esp) + addl $-32, %esp + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT + jmp ..B1.87 +..B1.43: + fstp %st(2) + fstp %st(1) + addl $-32, %esp + lea 72(%esp), %edx + movl %edx, (%esp) + fxch %st(1) + fstpt 4(%esp) + fstpt 16(%esp) + call __libm_hypot2l_k80 +..B1.83: + addl $32, %esp +..B1.44: + fldt 36+_CONSTANTS@GOTOFF(%ebx) + fmul %st(1), %st + fstpt 16(%esp) + fldt 48+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%esp) + addl $-32, %esp + fldt 72(%esp) + lea 96(%esp), %edx + fstpt (%esp) + fldt -12(%edx) + fstpt 12(%esp) + movl %edx, 24(%esp) + call __libm_logl_k80 +..B1.84: + addl $32, %esp +..B1.45: + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmulp %st, %st(1) + fldt 64(%esp) + fmul %st(1), %st + fldt 76(%esp) + fmulp %st, %st(2) + fldt 16(%esp) + fld %st(0) + fadd %st(2), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt (%esp) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 100(%esp) + addl $-32, %esp + fldt 24(%ebp) + fstpt (%esp) + fldt 12(%ebp) + fstpt 12(%esp) + call atan2l@PLT + jmp ..B1.87 +..B1.46: + fldt 24(%ebp) + fldz + fldt 12(%ebp) + fxch %st(1) + fdivrl .L_2il0floatpacket.8@GOTOFF(%ebx) + fstpt 100(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT + jmp ..B1.87 +..B1.47: + je ..B1.71 +..B1.48: + cmpl $32767, %edx + je ..B1.64 +..B1.49: + fldt 72+_CONSTANTS@GOTOFF(%ebx) + fmul %st(0), %st + fstpt 100(%esp) + addl $-32, %esp + fldt 24(%ebp) + fstpt (%esp) + fldt 12(%ebp) + fstpt 12(%esp) + call atan2l@PLT +..B1.87: + addl $32, %esp + fstpt 112(%esp) +..B1.50: + testl %edi, %edi + je ..B1.52 +..B1.51: + fldcw 14(%esp) +..B1.52: + movl 100(%esp), %edx + movl %edx, (%esi) + movl 112(%esp), %edx + movl %edx, 12(%esi) + movl 116(%esp), %edx + movl %edx, 16(%esi) + movl 104(%esp), %ecx + movl 108(%esp), %edi + movl 120(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 124(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.63 +..B1.53: + movl %esi, %eax + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.54: + cmpl $-2147483648, 4(%esp) + jne ..B1.41 +..B1.56: + cmpl $0, (%esp) + jne ..B1.41 +..B1.58: + fstp %st(0) + fstp %st(0) + fstp %st(2) + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fmul %st(2), %st + fmulp %st, %st(2) + fxch %st(1) + fstpt 28(%esp) + fldt 28(%esp) + movzwl 36(%esp), %edx + testl $32767, %edx + jne ..B1.62 +..B1.59: + cmpl $0, 32(%esp) + jne ..B1.61 +..B1.60: + cmpl $0, 28(%esp) + je ..B1.62 +..B1.61: + fldt 84+_CONSTANTS@GOTOFF(%ebx) + fmul %st(0), %st + faddp %st, %st(1) + fstpt 28(%esp) + fldt 28(%esp) +..B1.62: + fstpt 100(%esp) + addl $-32, %esp + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT + jmp ..B1.87 +..B1.63: + call __stack_chk_fail@PLT +..B1.64: + cmpl $-2147483648, 28(%ebp) + jne ..B1.66 +..B1.65: + cmpl $0, 24(%ebp) + je ..B1.49 +..B1.66: + fldt 24(%ebp) + cmpl $32767, %ecx + fmul %st(0), %st + fstpt 112(%esp) + fldt 112(%esp) + je ..B1.68 +..B1.67: + fstpt 100(%esp) + jmp ..B1.50 +..B1.68: + cmpl $-2147483648, 16(%ebp) + jne ..B1.67 +..B1.69: + cmpl $0, 12(%ebp) + jne ..B1.67 +..B1.70: + fstp %st(0) + fldt 12(%ebp) + fmul %st(0), %st + fstpt 100(%esp) + jmp ..B1.50 +..B1.71: + cmpl $-2147483648, 16(%ebp) + jne ..B1.73 +..B1.72: + cmpl $0, 12(%ebp) + je ..B1.48 +..B1.73: + fldt 12(%ebp) + cmpl $32767, %edx + fld %st(0) + fmul %st(1), %st + fstpt 112(%esp) + je ..B1.75 +..B1.74: + fldt 24(%ebp) + fmulp %st, %st(1) + fstpt 100(%esp) + jmp ..B1.50 +..B1.75: + cmpl $-2147483648, 28(%ebp) + jne ..B1.74 +..B1.76: + cmpl $0, 24(%ebp) + jne ..B1.74 +..B1.77: + fstp %st(0) + fldt 24(%ebp) + fmul %st(0), %st + fstpt 100(%esp) + jmp ..B1.50 +..B1.78: + xorl %edi, %edi + jmp ..B1.7 +..B1.89: + cmpl $32767, %ecx + je ..B1.71 + jmp ..B1.48 +..B1.90: + fstp %st(0) + fstp %st(0) + jmp ..B1.43 + .align 16,0x90 + .type clogl,@function + .size clogl,.-clogl + .data +# -- End clogl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16358 + .word 0 + .word 37342 + .word 47265 + .word 62214 + .word 46340 + .word 16382 + .word 0 + .word 64512 + .word 65535 + .word 31 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 53710 + .word 6135 + .word 45426 + .word 16381 + .word 0 + .word 505 + .word 55756 + .word 58609 + .word 48341 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8256 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,96 + .align 16 +_Q1: + .word 3134 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 49331 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .type _Q1,@object + .size _Q1,24 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .data + .hidden __libm_logl_k80 + .hidden __libm_hypot2l_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/complex_real.S b/external/sgx_libm/ia32/complex_real.S new file mode 100644 index 0000000000..8bcc1ddca2 --- /dev/null +++ b/external/sgx_libm/ia32/complex_real.S @@ -0,0 +1,291 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "complex_real.c" + .text +..TXTST0: +# -- Begin __libm_internal_isinf + .text + .align 16,0x90 + .hidden __libm_internal_isinf + .globl __libm_internal_isinf +__libm_internal_isinf: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + jne ..B1.4 +..B1.2: + cmpl $0, 4(%esp) + jne ..B1.4 +..B1.3: + movl $1, %eax + ret +..B1.4: + xorl %eax, %eax + ret + .align 16,0x90 + .type __libm_internal_isinf,@function + .size __libm_internal_isinf,.-__libm_internal_isinf + .data +# -- End __libm_internal_isinf + .text +# -- Begin __libm_internal_ispinf + .text + .align 16,0x90 + .hidden __libm_internal_ispinf + .globl __libm_internal_ispinf +__libm_internal_ispinf: +# parameter 1: 4 + %esp +..B2.1: +..L2: + + cmpl $2146435072, 8(%esp) + jne ..B2.4 +..B2.2: + cmpl $0, 4(%esp) + jne ..B2.4 +..B2.3: + movl $1, %eax + ret +..B2.4: + xorl %eax, %eax + ret + .align 16,0x90 + .type __libm_internal_ispinf,@function + .size __libm_internal_ispinf,.-__libm_internal_ispinf + .data +# -- End __libm_internal_ispinf + .text +# -- Begin __libm_internal_isninf + .text + .align 16,0x90 + .hidden __libm_internal_isninf + .globl __libm_internal_isninf +__libm_internal_isninf: +# parameter 1: 4 + %esp +..B3.1: +..L3: + + cmpl $-1048576, 8(%esp) + jne ..B3.4 +..B3.2: + cmpl $0, 4(%esp) + jne ..B3.4 +..B3.3: + movl $1, %eax + ret +..B3.4: + xorl %eax, %eax + ret + .align 16,0x90 + .type __libm_internal_isninf,@function + .size __libm_internal_isninf,.-__libm_internal_isninf + .data +# -- End __libm_internal_isninf + .text +# -- Begin __libm_internal_isnan + .text + .align 16,0x90 + .hidden __libm_internal_isnan + .globl __libm_internal_isnan +__libm_internal_isnan: +# parameter 1: 4 + %esp +..B4.1: +..L4: + + movl 8(%esp), %edx + movl %edx, %eax + andl $2146435072, %eax + cmpl $2146435072, %eax + jne ..B4.5 +..B4.2: + testl $1048575, %edx + jne ..B4.4 +..B4.3: + cmpl $0, 4(%esp) + je ..B4.5 +..B4.4: + movl $1, %eax + ret +..B4.5: + xorl %eax, %eax + ret + .align 16,0x90 + .type __libm_internal_isnan,@function + .size __libm_internal_isnan,.-__libm_internal_isnan + .data +# -- End __libm_internal_isnan + .text +# -- Begin __libm_internal_isposzero + .text + .align 16,0x90 + .hidden __libm_internal_isposzero + .globl __libm_internal_isposzero +__libm_internal_isposzero: +# parameter 1: 4 + %esp +..B5.1: +..L5: + + cmpl $0, 8(%esp) + jne ..B5.4 +..B5.2: + cmpl $0, 4(%esp) + jne ..B5.4 +..B5.3: + movl $1, %eax + ret +..B5.4: + xorl %eax, %eax + ret + .align 16,0x90 + .type __libm_internal_isposzero,@function + .size __libm_internal_isposzero,.-__libm_internal_isposzero + .data +# -- End __libm_internal_isposzero + .text +# -- Begin __libm_internal_iszero + .text + .align 16,0x90 + .hidden __libm_internal_iszero + .globl __libm_internal_iszero +__libm_internal_iszero: +# parameter 1: 4 + %esp +..B6.1: +..L6: + + testl $2147483647, 8(%esp) + jne ..B6.4 +..B6.2: + cmpl $0, 4(%esp) + jne ..B6.4 +..B6.3: + movl $1, %eax + ret +..B6.4: + xorl %eax, %eax + ret + .align 16,0x90 + .type __libm_internal_iszero,@function + .size __libm_internal_iszero,.-__libm_internal_iszero + .data +# -- End __libm_internal_iszero + .text +# -- Begin __libm_internal_isnegzero + .text + .align 16,0x90 + .hidden __libm_internal_isnegzero + .globl __libm_internal_isnegzero +__libm_internal_isnegzero: +# parameter 1: 4 + %esp +..B7.1: +..L7: + + cmpl $-2147483648, 8(%esp) + jne ..B7.4 +..B7.2: + cmpl $0, 4(%esp) + jne ..B7.4 +..B7.3: + movl $1, %eax + ret +..B7.4: + xorl %eax, %eax + ret + .align 16,0x90 + .type __libm_internal_isnegzero,@function + .size __libm_internal_isnegzero,.-__libm_internal_isnegzero + .data +# -- End __libm_internal_isnegzero + .text +# -- Begin __libm_internal_isnzfinite + .text + .align 16,0x90 + .hidden __libm_internal_isnzfinite + .globl __libm_internal_isnzfinite +__libm_internal_isnzfinite: +# parameter 1: 4 + %esp +..B8.1: +..L8: + + movl 8(%esp), %edx + movl %edx, %eax + andl $2146435072, %eax + cmpl $2146435072, %eax + jae ..B8.3 +..B8.2: + andl $2147483647, %edx + orl 4(%esp), %edx + jne ..B8.4 +..B8.3: + xorl %eax, %eax + ret +..B8.4: + movl $1, %eax + ret + .align 16,0x90 + .type __libm_internal_isnzfinite,@function + .size __libm_internal_isnzfinite,.-__libm_internal_isnzfinite + .data +# -- End __libm_internal_isnzfinite + .text +# -- Begin __libm_internal_isfinite + .text + .align 16,0x90 + .hidden __libm_internal_isfinite + .globl __libm_internal_isfinite +__libm_internal_isfinite: +# parameter 1: 4 + %esp +..B9.1: +..L9: + + movl 8(%esp), %eax + andl $2146435072, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __libm_internal_isfinite,@function + .size __libm_internal_isfinite,.-__libm_internal_isfinite + .data +# -- End __libm_internal_isfinite + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/conj.S b/external/sgx_libm/ia32/conj.S new file mode 100644 index 0000000000..0ecb94916a --- /dev/null +++ b/external/sgx_libm/ia32/conj.S @@ -0,0 +1,91 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "conj.c" + .text +..TXTST0: +# -- Begin conj + .text + .align 16,0x90 + .globl conj +conj: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp + fldl 12(%ebp) + fldl 20(%ebp) + movl 8(%ebp), %eax + fchs + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 16(%esp) + movl 16(%ebp), %edx + movl 12(%ebp), %ecx + fstpl 8(%esp) + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%esp), %ecx + movl 12(%esp), %edx + fstpl (%esp) + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + movl 16(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.3 +..B1.2: + movl %ebp, %esp + popl %ebp + ret $4 +..B1.3: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type conj,@function + .size conj,.-conj + .data +# -- End conj + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/conjf.S b/external/sgx_libm/ia32/conjf.S new file mode 100644 index 0000000000..69b5023b59 --- /dev/null +++ b/external/sgx_libm/ia32/conjf.S @@ -0,0 +1,65 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "conjf.c" + .text +..TXTST0: +# -- Begin conjf + .text + .align 16,0x90 + .globl conjf +conjf: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + flds 20(%esp) + fchs + fstps 4(%esp) + movl 16(%esp), %eax + movl 4(%esp), %edx + movl %eax, (%esp) + addl $12, %esp + ret + .align 16,0x90 + .type conjf,@function + .size conjf,.-conjf + .data +# -- End conjf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/conjl.S b/external/sgx_libm/ia32/conjl.S new file mode 100644 index 0000000000..795764f468 --- /dev/null +++ b/external/sgx_libm/ia32/conjl.S @@ -0,0 +1,98 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "conjl.c" + .text +..TXTST0: +# -- Begin conjl + .text + .align 16,0x90 + .globl conjl +conjl: +# parameter 1: 36 + %esp +..B1.1: +..L1: + + subl $28, %esp + fldt 36(%esp) + fldt 48(%esp) + movl 32(%esp), %eax + fchs + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 24(%esp) + movl 40(%esp), %edx + movl 36(%esp), %ecx + fstpt 12(%esp) + fstpt (%esp) + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%esp), %ecx + movl 12(%esp), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + movl 16(%esp), %ecx + movl 20(%esp), %edx + movl %ecx, 16(%eax) + movl %edx, 20(%eax) + movl 24(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.3 +..B1.2: + addl $28, %esp + ret $4 +..B1.3: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type conjl,@function + .size conjl,.-conjl + .data +# -- End conjl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/copysign_wmt.S b/external/sgx_libm/ia32/copysign_wmt.S new file mode 100644 index 0000000000..ecd9d241b4 --- /dev/null +++ b/external/sgx_libm/ia32/copysign_wmt.S @@ -0,0 +1,108 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "copysign_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin copysign + .text + .align 16,0x90 + .globl copysign +copysign: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd 120(%esp), %xmm1 + xorpd %xmm3, %xmm3 + addsd %xmm1, %xmm3 + movq (%ebx), %xmm2 + pand %xmm2, %xmm0 + pandn %xmm1, %xmm2 + por %xmm2, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type copysign,@function + .size copysign,.-copysign + .data +# -- End copysign + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/copysignf_wmt.S b/external/sgx_libm/ia32/copysignf_wmt.S new file mode 100644 index 0000000000..dd79812725 --- /dev/null +++ b/external/sgx_libm/ia32/copysignf_wmt.S @@ -0,0 +1,118 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "copysignf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin copysignf + .text + .align 16,0x90 + .globl copysignf +copysignf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 36(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movss 116(%esp), %xmm1 + movl 112(%esp), %eax + movl 116(%esp), %ecx + ucomiss %xmm0, %xmm0 + jp .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + ucomiss %xmm1, %xmm1 + andl $2147483647, %eax + andl $-2147483648, %ecx + orl %ecx, %eax + movl %eax, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_0.0.2: + xorps %xmm2, %xmm2 + addss %xmm2, %xmm0 + movd %xmm0, %eax + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + movl 36(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type copysignf,@function + .size copysignf,.-copysignf + .data +# -- End copysignf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/copysignl.S b/external/sgx_libm/ia32/copysignl.S new file mode 100644 index 0000000000..ef77a51b39 --- /dev/null +++ b/external/sgx_libm/ia32/copysignl.S @@ -0,0 +1,119 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "copysignl.c" + .text +..TXTST0: +# -- Begin copysignl + .text + .align 16,0x90 + .globl copysignl +copysignl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $48, %esp + fldt 8(%ebp) + fstpt 24(%esp) +..B1.2: + fnstcw 38(%esp) +..B1.3: + movzwl 38(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.10 +..B1.4: + orl $-64768, %edx + movw %dx, 36(%esp) +..B1.5: + fldcw 36(%esp) +..B1.6: + movl $1, %eax +..B1.7: + fldt 20(%ebp) + fldt 24(%esp) + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + movzbl 29(%ebp), %ecx + andl $-128, %ecx + fldl _ones@GOTOFF(%edx) + fmul %st, %st(1) + fxch %st(1) + fstpt 12(%esp) + fmulp %st, %st(1) + movzbl 21(%esp), %edx + andl $127, %edx + orl %ecx, %edx + fstpt (%esp) + testl %eax, %eax + movb %dl, 21(%esp) + je ..B1.9 +..B1.8: + fldcw 38(%esp) +..B1.9: + fldt 12(%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.10: + xorl %eax, %eax + jmp ..B1.7 + .align 16,0x90 + .type copysignl,@function + .size copysignl,.-copysignl + .data +# -- End copysignl + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cos_wmt.S b/external/sgx_libm/ia32/cos_wmt.S new file mode 100644 index 0000000000..2b50954709 --- /dev/null +++ b/external/sgx_libm/ia32/cos_wmt.S @@ -0,0 +1,765 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cos_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin cos + .text + .align 16,0x90 + .globl cos +cos: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 56(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + pextrw $3, %xmm0, %eax + andl $32767, %eax + subl $12336, %eax + cmpl $4293, %eax + ja .L_2TAG_PACKET_0.0.2 + movsd 2160(%ebx), %xmm1 + mulsd %xmm0, %xmm1 + movapd 2240(%ebx), %xmm5 + movsd 2224(%ebx), %xmm4 + andpd %xmm0, %xmm4 + orps %xmm4, %xmm5 + movsd 2128(%ebx), %xmm3 + movapd 2112(%ebx), %xmm2 + addpd %xmm5, %xmm1 + cvttsd2si %xmm1, %edx + cvtsi2sdl %edx, %xmm1 + mulsd %xmm1, %xmm3 + unpcklpd %xmm1, %xmm1 + addl $1865232, %edx + movapd %xmm0, %xmm4 + andl $63, %edx + movapd 2096(%ebx), %xmm5 + lea (%ebx), %eax + shll $5, %edx + addl %edx, %eax + mulpd %xmm1, %xmm2 + subsd %xmm3, %xmm0 + mulsd 2144(%ebx), %xmm1 + subsd %xmm3, %xmm4 + movsd 8(%eax), %xmm7 + unpcklpd %xmm0, %xmm0 + movapd %xmm4, %xmm3 + subsd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + movapd 2064(%ebx), %xmm6 + mulsd %xmm4, %xmm7 + subsd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subsd %xmm2, %xmm3 + movapd (%eax), %xmm2 + subsd %xmm3, %xmm1 + movsd 24(%eax), %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm7 + mulsd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulsd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm0 + addpd 2080(%ebx), %xmm5 + mulsd (%eax), %xmm4 + addpd 2048(%ebx), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, %xmm0 + addsd 8(%eax), %xmm3 + mulpd %xmm7, %xmm1 + movapd %xmm4, %xmm7 + addsd %xmm3, %xmm4 + addpd %xmm5, %xmm6 + movsd 8(%eax), %xmm5 + subsd %xmm3, %xmm5 + subsd %xmm4, %xmm3 + addsd 16(%eax), %xmm1 + mulpd %xmm2, %xmm6 + addsd %xmm0, %xmm5 + addsd %xmm7, %xmm3 + addsd %xmm5, %xmm1 + addsd %xmm3, %xmm1 + addsd %xmm6, %xmm1 + unpckhpd %xmm6, %xmm6 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm4 + movsd %xmm4, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_0.0.2: + jg .L_2TAG_PACKET_2.0.2 + pextrw $3, %xmm0, %eax + andl $32767, %eax + pinsrw $3, %eax, %xmm0 + movsd 2192(%ebx), %xmm1 + subsd %xmm0, %xmm1 + movsd %xmm1, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + movl 132(%esp), %eax + andl $2146435072, %eax + cmpl $2146435072, %eax + je .L_2TAG_PACKET_3.0.2 + subl $32, %esp + movsd %xmm0, (%esp) + lea 40(%esp), %eax + movl %eax, 8(%esp) + movl $1, %eax + movl %eax, 12(%esp) + call __libm_sincos_huge + addl $32, %esp + fldl 8(%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_3.0.2: + fldl 128(%esp) + fmull 2208(%ebx) +.L_2TAG_PACKET_1.0.2: + movl 56(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type cos,@function + .size cos,.-cos + .data +# -- End cos + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 1072693248 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1071644672 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 1071644672 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1070596096 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 1070596096 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1069547520 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 3217031168 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 3218079744 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 3218079744 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 3219128320 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 3220176896 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3219128320 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 3219128320 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3218079744 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 3218079744 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 1069547520 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 1070596096 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 1070596096 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 1071644672 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 1072693248 + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .long 1413480448 + .long 1069097467 + .long 0 + .long 0 + .long 771977331 + .long 996350346 + .long 0 + .long 0 + .long 1841940611 + .long 1076125488 + .long 0 + .long 0 + .long 0 + .long 1127743488 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .type static_const_table,@object + .size static_const_table,2256 + .data + .hidden __libm_sincos_huge + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cosdl.S b/external/sgx_libm/ia32/cosdl.S new file mode 100644 index 0000000000..384287a1c8 --- /dev/null +++ b/external/sgx_libm/ia32/cosdl.S @@ -0,0 +1,689 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosdl.c" + .text +..TXTST0: +# -- Begin cosdl + .text + .align 16,0x90 + .globl cosdl +cosdl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp +..B1.2: + fnstcw 30(%esp) +..B1.3: + movzwl 30(%esp), %edx + movl %edx, %eax + andl $3840, %eax + cmpl $768, %eax + je ..B1.38 +..B1.4: + andl $-3841, %edx + orl $-64768, %edx + movw %dx, 28(%esp) +..B1.5: + fldcw 28(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 16(%ebp), %esi + andl $32767, %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $16446, %esi + jge ..B1.19 +..B1.8: + cmpl $16318, %esi + jge ..B1.12 +..B1.9: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fldt 8(%ebp) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + testl %edi, %edi + fmuls ones@GOTOFF(%ebx,%eax,4) + fsubrp %st, %st(1) + fstpt (%esp) + je ..B1.11 +..B1.10: + fldcw 30(%esp) +..B1.11: + fldt (%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.12: + fldt 8(%ebp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fldt _Rcp90@GOTOFF(%ebx) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fxch %st(4) + fmuls ones@GOTOFF(%ebx,%edx,4) + fmul %st, %st(2) + fxch %st(2) + fadd %st(3), %st + fstpt 92(%esp) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 92(%esp) + movl 92(%esp), %edx + fsubp %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + incl %edx + movl %edx, %ecx + fsubrp %st, %st(1) + andl $2, %ecx + fucom %st(1) + fnstsw %ax + fxch %st(1) + fstp %st(0) + shrl $1, %ecx + sahf + jp ..B1.13 + je ..B1.31 +..B1.13: + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + testb $1, %dl + fmul %st(1), %st + fld %st(1) + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(2) + fsub %st(2), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(3) + fld %st(1) + fld %st(4) + fldl _TWO_53H@GOTOFF(%ebx) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fxch %st(1) + fmul %st, %st(2) + fld %st(5) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + fstpt 80(%esp) + fld %st(4) + fmul %st(5), %st + fld %st(0) + fmul %st(1), %st + flds ones@GOTOFF(%ebx,%ecx,4) + fstps 12(%esp) + je ..B1.15 +..B1.14: + fstp %st(6) + fstp %st(2) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(1) + fld %st(2) + fmul %st(5), %st + fxch %st(4) + fstpt (%esp) + fldt (%esp) + fld %st(3) + fmul %st(7), %st + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(5) + fld %st(1) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(1) + faddp %st, %st(3) + fldt 84+_cosdl_poly_coeff@GOTOFF(%ebx) + fmul %st(5), %st + fldt 60+_cosdl_poly_coeff@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 36+_cosdl_poly_coeff@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_cosdl_poly_coeff@GOTOFF(%ebx) + fmul %st(6), %st + fldt 48+_cosdl_poly_coeff@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(6), %st + fldt 24+_cosdl_poly_coeff@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fldl 24+_cosdl_mp_poly_coeff@GOTOFF(%ebx) + fmulp %st, %st(5) + faddp %st, %st(4) + fldl 8+_cosdl_mp_poly_coeff@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 16+_cosdl_mp_poly_coeff@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldl _cosdl_mp_poly_coeff@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt (%esp) + fmulp %st, %st(2) + fld %st(1) + fldt 16(%esp) + fmulp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + flds 12(%esp) + fld %st(0) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fld %st(0) + fadd %st(4), %st + fmul %st, %st(2) + fsubrp %st, %st(1) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.16 +..B1.15: + fld %st(6) + fmul %st(2), %st + fstpt 32(%esp) + fld %st(4) + fmul %st(4), %st + fmul %st, %st(3) + fxch %st(6) + fmul %st(7), %st + fxch %st(2) + fstpt 16(%esp) + fxch %st(3) + fstpt (%esp) + fldt 80(%esp) + fmul %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fld %st(4) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fsubrp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 96+_sindl_poly_coeff@GOTOFF(%ebx) + fmul %st(1), %st + fldt 72+_sindl_poly_coeff@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_sindl_poly_coeff@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_sindl_poly_coeff@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 60+_sindl_poly_coeff@GOTOFF(%ebx) + fldt 36+_sindl_poly_coeff@GOTOFF(%ebx) + fldt 16(%esp) + fmulp %st, %st(3) + fldt 84+_sindl_poly_coeff@GOTOFF(%ebx) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 32(%esp) + fmul %st, %st(1) + fldl 24+_sindl_mp_poly_coeff@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl 8+_sindl_mp_poly_coeff@GOTOFF(%ebx) + fmulp %st, %st(4) + faddp %st, %st(3) + fldl 16+_sindl_mp_poly_coeff@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldl _sindl_mp_poly_coeff@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt (%esp) + fmulp %st, %st(2) + fld %st(1) + fldt 48(%esp) + fmulp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + flds 12(%esp) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 64(%esp) +..B1.16: + testl %edi, %edi + je ..B1.18 +..B1.17: + fldcw 30(%esp) +..B1.18: + fldt 64(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + cmpl $32767, %esi + je ..B1.37 +..B1.20: + lea -16446(%esi), %ecx + cmpl $14, %ecx + jle ..B1.22 +..B1.21: + addl $-16449, %esi + movl $715827883, %eax + imull %esi + movl %esi, %ecx + sarl $1, %edx + sarl $31, %ecx + subl %ecx, %edx + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %eax + subl %eax, %esi + lea 3(%esi), %ecx +..B1.22: + movl %edi, (%esp) + movl $381774871, %eax + movl 12(%ebp), %edi + movl %edi, %esi + shll $8, %esi + andl $-16777216, %edi + movl %esi, %edx + shrl $3, %edx + mull %edx + shrl $2, %edx + imull $-360, %edx, %eax + movl %edi, %edx + shrl $19, %edi + addl %eax, %esi + movl $381774871, %eax + shrl $16, %edx + movl %edx, 4(%esp) + mull %edi + shrl $2, %edx + imull $-360, %edx, %edi + movl 4(%esp), %eax + addl %edi, %eax + movl 8(%ebp), %edi + movl %edi, %edx + shrl $3, %edx + addl %eax, %esi + movl $381774871, %eax + mull %edx + shrl $2, %edx + imull $-360, %edx, %eax + addl %eax, %edi + movl $-1240768329, %eax + addl %edi, %esi + shll %cl, %esi + imull %esi + addl %esi, %edx + movl %esi, %ecx + sarl $8, %edx + sarl $31, %ecx + subl %ecx, %edx + imull $-360, %edx, %eax + addl %eax, %esi + movl (%esp), %edi + cmpl $180, %esi + jl ..B1.24 +..B1.23: + addl $-180, %esi + movl $3, %eax + jmp ..B1.25 +..B1.24: + movl $1, %eax +..B1.25: + cmpl $90, %esi + jl ..B1.27 +..B1.26: + incl %eax + addl $-90, %esi +..B1.27: + movl %eax, %edx + andl $1, %eax + shll $4, %eax + andl $2, %edx + shll $5, %esi + addl %esi, %eax + shrl $1, %edx + fldl __libm_sindl_cosdl_table@GOTOFF(%eax,%ebx) + faddl 8+__libm_sindl_cosdl_table@GOTOFF(%ebx,%eax) + fmuls ones@GOTOFF(%ebx,%edx,4) + fstpt (%esp) +..B1.28: + testl %edi, %edi + je ..B1.30 +..B1.29: + fldcw 30(%esp) +..B1.30: + fldt (%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + fstp %st(0) + testb $1, %dl + je ..B1.33 +..B1.32: + flds ones@GOTOFF(%ebx,%ecx,4) + fstps (%esp) + jmp ..B1.34 +..B1.33: + fldz + fstps (%esp) +..B1.34: + testl %edi, %edi + je ..B1.36 +..B1.35: + fldcw 30(%esp) +..B1.36: + flds (%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.37: + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.28 +..B1.38: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type cosdl,@function + .size cosdl,.-cosdl + .data +# -- End cosdl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3e,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb4,0x05,0x40,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +_cosdl_poly_coeff: + .word 52350 + .word 41213 + .word 3800 + .word 40885 + .word 49138 + .word 0 + .word 28613 + .word 7908 + .word 35668 + .word 34008 + .word 16355 + .word 0 + .word 19927 + .word 58728 + .word 49885 + .word 45261 + .word 49106 + .word 0 + .word 32884 + .word 22035 + .word 23267 + .word 64541 + .word 16320 + .word 0 + .word 36401 + .word 51897 + .word 8309 + .word 57265 + .word 49070 + .word 0 + .word 34286 + .word 2728 + .word 41564 + .word 34642 + .word 16284 + .word 0 + .word 63248 + .word 18030 + .word 35596 + .word 60796 + .word 49032 + .word 0 + .word 52149 + .word 21294 + .word 63985 + .word 40123 + .word 16245 + .word 0 + .type _cosdl_poly_coeff,@object + .size _cosdl_poly_coeff,96 + .align 16 +_cosdl_mp_poly_coeff: + .long 3675529145 + .long 3206805153 + .long 2134983071 + .long 3151100167 + .long 1787026573 + .long 1043372817 + .long 205083639 + .long 988746860 + .type _cosdl_mp_poly_coeff,@object + .size _cosdl_mp_poly_coeff,32 + .align 16 +_sindl_poly_coeff: + .word 51374 + .word 38121 + .word 13586 + .word 36602 + .word 16377 + .word 0 + .word 50116 + .word 41339 + .word 4204 + .word 60892 + .word 49130 + .word 0 + .word 33704 + .word 2155 + .word 42839 + .word 60780 + .word 16346 + .word 0 + .word 21250 + .word 19076 + .word 27901 + .word 57780 + .word 49097 + .word 0 + .word 9076 + .word 49244 + .word 613 + .word 64083 + .word 16311 + .word 0 + .word 40572 + .word 30418 + .word 36251 + .word 46520 + .word 49061 + .word 0 + .word 3227 + .word 25505 + .word 5540 + .word 47626 + .word 16274 + .word 0 + .word 60933 + .word 3300 + .word 57416 + .word 36218 + .word 49023 + .word 0 + .word 45811 + .word 42646 + .word 37125 + .word 42185 + .word 16235 + .word 0 + .type _sindl_poly_coeff,@object + .size _sindl_poly_coeff,108 + .space 4, 0x00 # pad + .align 16 +_sindl_mp_poly_coeff: + .long 2723323193 + .long 1066524486 + .long 2863989530 + .long 1008058840 + .long 227815288 + .long 3199056770 + .long 3752327299 + .long 3142458725 + .type _sindl_mp_poly_coeff,@object + .size _sindl_mp_poly_coeff,32 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 2 +_Rcp90: + .word 46603 + .word 2912 + .word 24758 + .word 46603 + .word 16376 + .word 0 + .type _Rcp90,@object + .size _Rcp90,12 + .data + .hidden __libm_sindl_cosdl_table + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cosf_wmt.S b/external/sgx_libm/ia32/cosf_wmt.S new file mode 100644 index 0000000000..871b6636b2 --- /dev/null +++ b/external/sgx_libm/ia32/cosf_wmt.S @@ -0,0 +1,590 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin cosf + .text + .align 16,0x90 + .globl cosf +cosf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 36(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %ecx + subl $16, %esp + stmxcsr 4(%esp) + movl 4(%esp), %eax + andl $-24577, %eax + cmpl %eax, 4(%esp) + jne .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + movapd %xmm0, %xmm1 + cvtps2pd %xmm1, %xmm1 + movsd 1296(%ebx), %xmm2 + movl $2147483647, %eax + movl $1241513983, %edx + andl %ecx, %eax + subl %eax, %edx + subl $964689920, %eax + orl %eax, %edx + jl .L_2TAG_PACKET_2.0.2 + movsd 1312(%ebx), %xmm4 + mulsd %xmm1, %xmm2 + movsd 1328(%ebx), %xmm3 + movapd %xmm2, %xmm5 + addsd %xmm4, %xmm2 + movd %xmm2, %ecx + subsd %xmm4, %xmm2 + mulsd %xmm3, %xmm1 +.L_2TAG_PACKET_3.0.2: + movl $384, %eax + movsd 1344(%ebx), %xmm4 + subsd %xmm2, %xmm5 + addl %ecx, %ecx + movl %ecx, %edx + shll $24, %ecx + sarl $31, %ecx + andl %edx, %eax + addl %ecx, %edx + xorl %ecx, %edx + addsd %xmm5, %xmm1 + andl $254, %edx + movsd (%ebx,%edx,8), %xmm3 + movsd 1352(%ebx), %xmm0 + pshufd $68, %xmm1, %xmm2 + mulsd %xmm1, %xmm1 + movsd 8(%ebx,%edx,8), %xmm5 + movl %eax, %ecx + andl $256, %ecx + shll $23, %ecx + mulsd %xmm2, %xmm3 + movd %ecx, %xmm2 + subsd %xmm1, %xmm0 + addl $128, %eax + andl $256, %eax + shll $23, %eax + subsd %xmm1, %xmm4 + psllq $32, %xmm2 + movd %eax, %xmm1 + xorpd %xmm2, %xmm4 + mulsd %xmm5, %xmm0 + mulsd %xmm4, %xmm3 + psllq $32, %xmm1 + xorpd %xmm1, %xmm0 + addsd %xmm3, %xmm0 + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_4.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_4.0.2: + cvtpd2ps %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_2.0.2: + andl $2147483647, %ecx + cmpl $1040187392, %ecx + ja .L_2TAG_PACKET_6.0.2 + movl $1065353216, %eax + movd %eax, %xmm0 + cmpl $0, %ecx + je .L_2TAG_PACKET_7.0.2 + movl $805306368, %eax + movd %eax, %xmm1 + subss %xmm1, %xmm0 +.L_2TAG_PACKET_7.0.2: + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_8.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_8.0.2: + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_0.0.2: + movl 4(%esp), %eax + andl $-24577, %eax + movl %eax, 8(%esp) + ldmxcsr 8(%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_6.0.2: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_9.0.2 + shrl $23, %ecx + subl $142, %ecx + andl $65528, %ecx + movsd 1040(%ebx,%ecx,2), %xmm3 + movsd 1048(%ebx,%ecx,2), %xmm5 + movsd 1360(%ebx), %xmm2 + xorpd %xmm4, %xmm4 + movl $17208, %eax + pinsrw $3, %eax, %xmm4 + andpd %xmm3, %xmm2 + psllq $40, %xmm3 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + movapd %xmm2, %xmm0 + addsd %xmm3, %xmm2 + movapd %xmm2, %xmm5 + subsd %xmm2, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm0, %xmm3 + movd %xmm2, %ecx + subsd %xmm4, %xmm2 + addsd %xmm3, %xmm1 + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_9.0.2: + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_10.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_10.0.2: + subss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_5.0.2: + addl $16, %esp + movl 36(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type cosf,@function + .size cosf,.-cosf + .data +# -- End cosf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 3384690142 + .long 1060355388 + .long 918535681 + .long 3195026356 + .long 735532773 + .long 1060354999 + .long 3431923622 + .long 3196074611 + .long 2385983684 + .long 1060353830 + .long 3670374716 + .long 3196605580 + .long 2769466396 + .long 1060351883 + .long 3087185898 + .long 3197121906 + .long 2627920248 + .long 1060349159 + .long 624330694 + .long 3197386271 + .long 418831766 + .long 1060345660 + .long 1991825541 + .long 3197649836 + .long 900924147 + .long 1060341387 + .long 3917367244 + .long 3197912443 + .long 2243801771 + .long 1060336343 + .long 2803392399 + .long 3198165367 + .long 316258674 + .long 1060330532 + .long 2429158325 + .long 3198295476 + .long 1563320407 + .long 1060323956 + .long 1382541649 + .long 3198424870 + .long 1522351063 + .long 1060316620 + .long 4207787592 + .long 3198553470 + .long 1992674941 + .long 1060308528 + .long 321119318 + .long 3198681201 + .long 2434209605 + .long 1060299685 + .long 2865853451 + .long 3198807983 + .long 4249822861 + .long 1060290096 + .long 1666812989 + .long 3198933742 + .long 2181617495 + .long 1060279768 + .long 2082609563 + .long 3199058401 + .long 1475857720 + .long 1060268706 + .long 3726787968 + .long 3199181885 + .long 687004205 + .long 1060256917 + .long 2478530408 + .long 3199254748 + .long 250409509 + .long 1060244408 + .long 3681356269 + .long 3199315204 + .long 2463945945 + .long 1060231186 + .long 1535093810 + .long 3199374963 + .long 2878576948 + .long 1060217260 + .long 350661592 + .long 3199433988 + .long 3162654741 + .long 1060202638 + .long 2042383238 + .long 3199492243 + .long 2490283769 + .long 1060187329 + .long 1925003623 + .long 3199549694 + .long 1813501338 + .long 1060171342 + .long 1689375324 + .long 3199606306 + .long 3838419993 + .long 1060154686 + .long 902054988 + .long 3199662045 + .long 115411415 + .long 1060137373 + .long 1388494065 + .long 3199716877 + .long 1077921708 + .long 1060119411 + .long 3024934267 + .long 3199770769 + .long 3311502568 + .long 1060091288 + .long 3823857331 + .long 3199823689 + .long 1148832537 + .long 1060052839 + .long 17970311 + .long 3199875606 + .long 652328457 + .long 1060013161 + .long 3322544997 + .long 3199926486 + .long 1395127179 + .long 1059972278 + .long 2361617751 + .long 3199976301 + .long 1772140623 + .long 1059930215 + .long 1401987205 + .long 3200025020 + .long 3231311734 + .long 1059886997 + .long 3250975870 + .long 3200072613 + .long 1618129506 + .long 1059842651 + .long 742418353 + .long 3200119053 + .long 4288148241 + .long 1059797202 + .long 2580634211 + .long 3200164310 + .long 4268074870 + .long 1059750679 + .long 3348027550 + .long 3200208358 + .long 1659779181 + .long 1059703110 + .long 755484892 + .long 3200251171 + .long 3567792879 + .long 1059654522 + .long 2993330 + .long 3200273337 + .long 2550341159 + .long 1059604946 + .long 488211833 + .long 3200293469 + .long 2313428161 + .long 1059554411 + .long 3436142021 + .long 3200312945 + .long 453708735 + .long 1059502948 + .long 1407782048 + .long 3200331755 + .long 1264637048 + .long 1059450587 + .long 1575056534 + .long 3200349886 + .long 2771364651 + .long 1059397360 + .long 4275292648 + .long 3200367327 + .long 944109265 + .long 1059343300 + .long 3039475318 + .long 3200384069 + .long 2500108843 + .long 1059288438 + .long 1799297257 + .long 3200400101 + .long 3344537919 + .long 1059232808 + .long 2028347177 + .long 3200415413 + .long 1369913724 + .long 1059176444 + .long 2767093429 + .long 3200429996 + .long 664370609 + .long 1059119379 + .long 646746141 + .long 3200443842 + .long 1372808103 + .long 1059061535 + .long 2796885356 + .long 3200456941 + .long 941816458 + .long 1058944809 + .long 1097233945 + .long 3200469287 + .long 1373383079 + .long 1058826890 + .long 2262842797 + .long 3200480871 + .long 2796081240 + .long 1058707849 + .long 2093526290 + .long 3200491687 + .long 3945677176 + .long 1058587758 + .long 2671784286 + .long 3200501728 + .long 1979618421 + .long 1058466690 + .long 3789723003 + .long 3200510988 + .long 879820317 + .long 1058344717 + .long 2964703016 + .long 3200519462 + .long 2674059679 + .long 1058221912 + .long 4043704933 + .long 3200527144 + .long 2950925715 + .long 1058098350 + .long 36665700 + .long 3200534031 + .long 2811721921 + .long 1057935027 + .long 3193221610 + .long 3200540116 + .long 3297207428 + .long 1057685321 + .long 2063766514 + .long 3200545398 + .long 544295963 + .long 1057434550 + .long 163641427 + .long 3200549873 + .long 3381119115 + .long 1057182863 + .long 3096463640 + .long 3200553537 + .long 3054827835 + .long 1056896220 + .long 1381230637 + .long 3200556390 + .long 3419039295 + .long 1056390099 + .long 522802171 + .long 3200558429 + .long 1693671239 + .long 1055850091 + .long 3836476539 + .long 3200559652 + .long 1466910230 + .long 1054802127 + .long 3861233235 + .long 3200560060 + .long 0 + .long 0 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1916669064 + .long 1072155675 + .long 660066805 + .long 1024797180 + .long 3829231700 + .long 1062745828 + .long 2884172442 + .long 1017445907 + .long 540874025 + .long 1055617650 + .long 4198409884 + .long 1011844330 + .long 2839315448 + .long 1046639136 + .long 4204424928 + .long 1000582120 + .long 1329339431 + .long 1038229673 + .long 1295478839 + .long 993391741 + .long 658191860 + .long 1024797180 + .long 3691886121 + .long 979325773 + .long 1966800710 + .long 1020436418 + .long 1882642597 + .long 977095991 + .long 2100977488 + .long 1012908661 + .long 1840335565 + .long 967470816 + .long 4198093645 + .long 1000582120 + .long 3307942521 + .long 957055414 + .long 2839123165 + .long 996851343 + .long 1387472776 + .long 952638316 + .long 2788761024 + .long 988712873 + .long 3005712498 + .long 944467026 + .long 3694676832 + .long 979325773 + .long 1326507024 + .long 934847846 + .long 221775557 + .long 970149340 + .long 1133527550 + .long 924162364 + .long 4286578688 + .long 1072693247 + .long 0 + .long 0 + .long 1845493760 + .long 1078222640 + .long 0 + .long 0 + .long 0 + .long 1127743488 + .long 0 + .long 0 + .long 2908765579 + .long 3193641918 + .long 0 + .long 0 + .long 2308576600 + .long 1086551075 + .long 1646446368 + .long 1084878895 + .long 4278190080 + .long 4294967295 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,1376 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cosh_wmt.S b/external/sgx_libm/ia32/cosh_wmt.S new file mode 100644 index 0000000000..49ce3ddac9 --- /dev/null +++ b/external/sgx_libm/ia32/cosh_wmt.S @@ -0,0 +1,1351 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosh_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin cosh + .text + .align 16,0x90 + .globl cosh +cosh: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd 4240(%ebx), %xmm3 + xorpd %xmm4, %xmm4 + movsd 4192(%ebx), %xmm1 + movsd 4200(%ebx), %xmm2 + movl $32768, %eax + pinsrw $3, %eax, %xmm4 + movsd 4096(%ebx), %xmm6 + pextrw $3, %xmm0, %ecx + andpd %xmm0, %xmm3 + andnpd %xmm0, %xmm4 + pshufd $68, %xmm4, %xmm5 + andl $32767, %ecx + subl $16320, %ecx + cmpl $200, %ecx + jae .L_2TAG_PACKET_0.0.3 + subsd %xmm3, %xmm4 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm2 + cvtsd2si %xmm3, %eax + movapd %xmm3, %xmm7 + addsd %xmm6, %xmm3 + mulsd %xmm4, %xmm1 + xorpd %xmm5, %xmm5 + subsd %xmm6, %xmm3 + movapd 4112(%ebx), %xmm4 + addsd %xmm1, %xmm2 + movapd 4128(%ebx), %xmm6 + subsd %xmm3, %xmm7 + movl $32704, %edx + pinsrw $3, %edx, %xmm5 + movapd 4144(%ebx), %xmm1 + addsd %xmm7, %xmm2 + movl $127, %edx + andl %eax, %edx + addl %edx, %edx + shrl $3, %eax + andl $65520, %eax + addl $16352, %eax + xorpd %xmm0, %xmm0 + cmpl $184, %ecx + jae .L_2TAG_PACKET_1.0.3 + pshufd $68, %xmm5, %xmm5 + pinsrw $3, %eax, %xmm0 + pshufd $68, %xmm0, %xmm0 + psubw %xmm0, %xmm5 + mulpd (%ebx,%edx,8), %xmm0 + mulpd 2048(%ebx,%edx,8), %xmm5 + pshufd $68, %xmm2, %xmm3 + movapd 4160(%ebx), %xmm7 + pshufd $68, %xmm2, %xmm2 + mulpd %xmm3, %xmm3 + mulpd %xmm2, %xmm4 + mulpd %xmm2, %xmm6 + mulpd 4176(%ebx), %xmm2 + mulpd %xmm3, %xmm1 + mulpd %xmm3, %xmm7 + mulpd %xmm3, %xmm4 + mulpd %xmm3, %xmm1 + addpd %xmm7, %xmm6 + movapd %xmm0, %xmm7 + addpd %xmm1, %xmm4 + shufpd $0, %xmm5, %xmm7 + addpd %xmm5, %xmm0 + mulpd %xmm7, %xmm2 + addpd %xmm6, %xmm4 + subsd %xmm0, %xmm7 + mulpd %xmm2, %xmm4 + pshufd $238, %xmm0, %xmm6 + addsd %xmm5, %xmm7 + addpd %xmm2, %xmm4 + addsd %xmm6, %xmm7 + pshufd $238, %xmm4, %xmm2 + addsd %xmm7, %xmm2 + addsd %xmm4, %xmm2 + addsd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + addl $16320, %ecx + cmpl $16320, %ecx + ja .L_2TAG_PACKET_3.0.3 + cmpl $15952, %ecx + jae .L_2TAG_PACKET_4.0.3 + addsd %xmm2, %xmm6 + movsd 4248(%ebx), %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + subl $16352, %eax + movl %eax, %ecx + andl $32752, %eax + shrl $1, %eax + andl $65520, %eax + subl %eax, %ecx + addl $16352, %eax + pinsrw $3, %eax, %xmm0 + pshufd $68, %xmm0, %xmm0 + mulpd (%ebx,%edx,8), %xmm0 + pshufd $68, %xmm2, %xmm3 + movsd 4160(%ebx), %xmm7 + mulsd %xmm3, %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm6 + mulsd 4176(%ebx), %xmm2 + mulsd %xmm3, %xmm1 + mulsd %xmm3, %xmm7 + mulsd %xmm3, %xmm4 + addl $16368, %ecx + pinsrw $3, %ecx, %xmm5 + mulsd %xmm3, %xmm1 + addsd %xmm7, %xmm6 + addsd %xmm1, %xmm4 + mulsd %xmm0, %xmm2 + addsd %xmm6, %xmm4 + mulsd %xmm2, %xmm4 + pshufd $238, %xmm0, %xmm6 + addsd %xmm6, %xmm4 + addsd %xmm4, %xmm2 + addsd %xmm2, %xmm0 + mulsd %xmm5, %xmm0 + pextrw $3, %xmm0, %eax + andl $32752, %eax + movl $64, %edx + cmpl $32752, %eax + je .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + movapd 4208(%ebx), %xmm1 + mulpd %xmm5, %xmm5 + movapd 4224(%ebx), %xmm2 + xorpd %xmm3, %xmm3 + movapd %xmm5, %xmm0 + mulpd %xmm5, %xmm1 + movsd 4248(%ebx), %xmm6 + mulpd %xmm5, %xmm5 + movl $16352, %eax + pinsrw $3, %eax, %xmm3 + addpd %xmm2, %xmm1 + mulpd %xmm5, %xmm1 + pshufd $238, %xmm1, %xmm2 + mulsd %xmm1, %xmm5 + mulsd %xmm3, %xmm0 + addsd %xmm5, %xmm2 + addsd %xmm2, %xmm0 + addsd %xmm6, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $32752, %ecx + jae .L_2TAG_PACKET_6.0.3 + xorpd %xmm0, %xmm0 + movl $32736, %eax + pinsrw $3, %eax, %xmm0 + mulsd %xmm0, %xmm0 + movl $64, %edx +.L_2TAG_PACKET_5.0.3: + movsd %xmm0, (%esp) + movsd 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_6.0.3: + mulsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_7.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type cosh,@function + .size cosh,.-cosh + .data +# -- End cosh + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 2851812149 + .long 1072698941 + .long 2595802551 + .long 1016815913 + .long 1048019041 + .long 1072704666 + .long 1398474845 + .long 3161559171 + .long 3899555717 + .long 1072710421 + .long 427280750 + .long 3163595548 + .long 3541402996 + .long 1072716208 + .long 2759177317 + .long 1015903202 + .long 702412510 + .long 1072722027 + .long 3803266087 + .long 3163328991 + .long 410360776 + .long 1072727877 + .long 1269990655 + .long 1013024446 + .long 3402036099 + .long 1072733758 + .long 405889334 + .long 1016154232 + .long 1828292879 + .long 1072739672 + .long 1255956747 + .long 1016636974 + .long 728909815 + .long 1072745618 + .long 383930225 + .long 1016078044 + .long 852742562 + .long 1072751596 + .long 667253586 + .long 1010842135 + .long 2952712987 + .long 1072757606 + .long 3293494651 + .long 3161168877 + .long 3490863953 + .long 1072763649 + .long 960797498 + .long 3163997456 + .long 3228316108 + .long 1072769725 + .long 3010241991 + .long 3159471380 + .long 2930322912 + .long 1072775834 + .long 2599499422 + .long 3163762623 + .long 3366293073 + .long 1072781976 + .long 3119426314 + .long 1015169130 + .long 1014845819 + .long 1072788152 + .long 3117910646 + .long 3162607681 + .long 948735466 + .long 1072794361 + .long 3516338028 + .long 3163623459 + .long 3949972341 + .long 1072800603 + .long 2068408548 + .long 1015962444 + .long 2214878420 + .long 1072806880 + .long 892270087 + .long 3164164998 + .long 828946858 + .long 1072813191 + .long 10642492 + .long 1016988014 + .long 586995997 + .long 1072819536 + .long 41662348 + .long 3163676568 + .long 2288159958 + .long 1072825915 + .long 2169144469 + .long 1015924597 + .long 2440944790 + .long 1072832329 + .long 2492769774 + .long 1015196030 + .long 1853186616 + .long 1072838778 + .long 3066496371 + .long 1016705150 + .long 1337108031 + .long 1072845262 + .long 3203724452 + .long 1015726421 + .long 1709341917 + .long 1072851781 + .long 2571168217 + .long 1015201075 + .long 3790955393 + .long 1072858335 + .long 2352942462 + .long 3164228666 + .long 4112506593 + .long 1072864925 + .long 2947355221 + .long 1015419624 + .long 3504003472 + .long 1072871551 + .long 3594001060 + .long 3158379228 + .long 2799960843 + .long 1072878213 + .long 1423655381 + .long 1016070727 + .long 2839424854 + .long 1072884911 + .long 1171596163 + .long 1014090255 + .long 171030293 + .long 1072891646 + .long 3526460132 + .long 1015477354 + .long 4232894513 + .long 1072898416 + .long 2383938684 + .long 1015717095 + .long 2992903935 + .long 1072905224 + .long 2218154406 + .long 1016276769 + .long 1603444721 + .long 1072912069 + .long 1548633640 + .long 3163249902 + .long 926591435 + .long 1072918951 + .long 3208833762 + .long 3163962090 + .long 1829099622 + .long 1072925870 + .long 1016661181 + .long 3164509581 + .long 887463927 + .long 1072932827 + .long 3596744163 + .long 3161842742 + .long 3272845541 + .long 1072939821 + .long 928852419 + .long 3164536824 + .long 1276261410 + .long 1072946854 + .long 300981948 + .long 1015732745 + .long 78413852 + .long 1072953925 + .long 4183226867 + .long 3164065827 + .long 569847338 + .long 1072961034 + .long 472945272 + .long 3160339305 + .long 3645941911 + .long 1072968181 + .long 3814685081 + .long 3162621917 + .long 1617004845 + .long 1072975368 + .long 82804944 + .long 1011391354 + .long 3978100823 + .long 1072982593 + .long 3513027190 + .long 1016894539 + .long 3049340112 + .long 1072989858 + .long 3062915824 + .long 1014219171 + .long 4040676318 + .long 1072997162 + .long 4090609238 + .long 1016712034 + .long 3577096743 + .long 1073004506 + .long 2951496418 + .long 1014842263 + .long 2583551245 + .long 1073011890 + .long 3161094195 + .long 1016655067 + .long 1990012071 + .long 1073019314 + .long 3529070563 + .long 3163861769 + .long 2731501122 + .long 1073026778 + .long 1774031855 + .long 3163518597 + .long 1453150082 + .long 1073034283 + .long 498154669 + .long 3162536638 + .long 3395129871 + .long 1073041828 + .long 4025345435 + .long 3163383964 + .long 917841882 + .long 1073049415 + .long 18715565 + .long 1016707884 + .long 3566716925 + .long 1073057042 + .long 1536826856 + .long 1015191009 + .long 3712504873 + .long 1073064711 + .long 88491949 + .long 1016476236 + .long 2321106615 + .long 1073072422 + .long 2171176610 + .long 1010584347 + .long 363667784 + .long 1073080175 + .long 813753950 + .long 1016833785 + .long 3111574537 + .long 1073087969 + .long 2606161479 + .long 3163808322 + .long 2956612997 + .long 1073095806 + .long 2118169751 + .long 3163784129 + .long 885834528 + .long 1073103686 + .long 1973258547 + .long 3163310140 + .long 2186617381 + .long 1073111608 + .long 2270764084 + .long 3164321289 + .long 3561793907 + .long 1073119573 + .long 1157054053 + .long 1012938926 + .long 1719614413 + .long 1073127582 + .long 330458198 + .long 3164331316 + .long 1963711167 + .long 1073135634 + .long 1744767757 + .long 3161622870 + .long 1013258799 + .long 1073143730 + .long 1748797611 + .long 3161177658 + .long 4182873220 + .long 1073151869 + .long 629542646 + .long 3163044879 + .long 3907805044 + .long 1073160053 + .long 2257091225 + .long 3162598983 + .long 1218806132 + .long 1073168282 + .long 1818613052 + .long 3163597017 + .long 1447192521 + .long 1073176555 + .long 1462857171 + .long 3163563097 + .long 1339972927 + .long 1073184873 + .long 167908909 + .long 1016620728 + .long 1944781191 + .long 1073193236 + .long 3993278767 + .long 3162772855 + .long 19972402 + .long 1073201645 + .long 3507899862 + .long 1017057868 + .long 919555682 + .long 1073210099 + .long 3121969534 + .long 1013996802 + .long 1413356050 + .long 1073218599 + .long 1651349291 + .long 3163716742 + .long 2571947539 + .long 1073227145 + .long 3558159064 + .long 3164425245 + .long 1176749997 + .long 1073235738 + .long 2738998779 + .long 3163084420 + .long 2604962541 + .long 1073244377 + .long 2614425274 + .long 3164587768 + .long 3649726105 + .long 1073253063 + .long 4085036346 + .long 1016698050 + .long 1110089947 + .long 1073261797 + .long 1451641639 + .long 1016523249 + .long 380978316 + .long 1073270578 + .long 854188970 + .long 3161511262 + .long 2568320822 + .long 1073279406 + .long 2732824428 + .long 1015401491 + .long 194117574 + .long 1073288283 + .long 777528612 + .long 3164460665 + .long 2966275557 + .long 1073297207 + .long 2176155324 + .long 3160891335 + .long 3418903055 + .long 1073306180 + .long 2527457337 + .long 3161869180 + .long 2682146384 + .long 1073315202 + .long 2082178513 + .long 3164411995 + .long 1892288442 + .long 1073324273 + .long 2446255666 + .long 3163648957 + .long 2191782032 + .long 1073333393 + .long 2960257726 + .long 1014791238 + .long 434316067 + .long 1073342563 + .long 2028358766 + .long 1014506698 + .long 2069751141 + .long 1073351782 + .long 1562170675 + .long 3163773257 + .long 3964284211 + .long 1073361051 + .long 2111583915 + .long 1016475740 + .long 2990417245 + .long 1073370371 + .long 3683467745 + .long 3164417902 + .long 321958744 + .long 1073379742 + .long 3401933767 + .long 1016843134 + .long 1434058175 + .long 1073389163 + .long 251133233 + .long 1016134345 + .long 3218338682 + .long 1073398635 + .long 3404164304 + .long 3163525684 + .long 2572866477 + .long 1073408159 + .long 878562433 + .long 1016570317 + .long 697153126 + .long 1073417735 + .long 1283515429 + .long 3164331765 + .long 3092190715 + .long 1073427362 + .long 814012168 + .long 3160571998 + .long 2380618042 + .long 1073437042 + .long 3149557219 + .long 3164369375 + .long 4076559943 + .long 1073446774 + .long 2119478331 + .long 3161806927 + .long 815859274 + .long 1073456560 + .long 240396590 + .long 3164536019 + .long 2420883922 + .long 1073466398 + .long 2049810052 + .long 1015168464 + .long 1540824585 + .long 1073476290 + .long 1064017011 + .long 3164536266 + .long 3716502172 + .long 1073486235 + .long 2303740125 + .long 1015091301 + .long 1610600570 + .long 1073496235 + .long 3766732298 + .long 1016808759 + .long 777507147 + .long 1073506289 + .long 4282924205 + .long 1016236109 + .long 2483480501 + .long 1073516397 + .long 1216371780 + .long 1014082748 + .long 3706687593 + .long 1073526560 + .long 3521726940 + .long 1014301643 + .long 1432208378 + .long 1073536779 + .long 1401068914 + .long 3163412539 + .long 1242007932 + .long 1073547053 + .long 1132034716 + .long 3164388407 + .long 135105010 + .long 1073557383 + .long 1906148728 + .long 3164424315 + .long 3707479175 + .long 1073567768 + .long 3613079303 + .long 1015213314 + .long 382305176 + .long 1073578211 + .long 2347622376 + .long 3163627201 + .long 64696965 + .long 1073588710 + .long 1768797490 + .long 1016865536 + .long 4076975200 + .long 1073599265 + .long 2029000899 + .long 1016257111 + .long 863738719 + .long 1073609879 + .long 1326992220 + .long 3163661773 + .long 351641897 + .long 1073620550 + .long 2172261526 + .long 3164059175 + .long 3884662774 + .long 1073631278 + .long 2158611599 + .long 1015258761 + .long 4224142467 + .long 1073642065 + .long 3389820386 + .long 1016255778 + .long 2728693978 + .long 1073652911 + .long 396109971 + .long 3164511267 + .long 764307441 + .long 1073663816 + .long 3021057420 + .long 3164378099 + .long 3999357479 + .long 1073674779 + .long 2258941616 + .long 1016973300 + .long 929806999 + .long 1073685803 + .long 3205336643 + .long 1016308133 + .long 1533953344 + .long 1073696886 + .long 769171851 + .long 1016714209 + .long 2912730644 + .long 1073708029 + .long 3490067722 + .long 3164453650 + .long 2174652632 + .long 1073719233 + .long 4087714590 + .long 1015498835 + .long 730821105 + .long 1073730498 + .long 2523232743 + .long 1013115764 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 730821105 + .long 1072681922 + .long 2523232743 + .long 1012067188 + .long 2174652632 + .long 1072670657 + .long 4087714590 + .long 1014450259 + .long 2912730644 + .long 1072659453 + .long 3490067722 + .long 3163405074 + .long 1533953344 + .long 1072648310 + .long 769171851 + .long 1015665633 + .long 929806999 + .long 1072637227 + .long 3205336643 + .long 1015259557 + .long 3999357479 + .long 1072626203 + .long 2258941616 + .long 1015924724 + .long 764307441 + .long 1072615240 + .long 3021057420 + .long 3163329523 + .long 2728693978 + .long 1072604335 + .long 396109971 + .long 3163462691 + .long 4224142467 + .long 1072593489 + .long 3389820386 + .long 1015207202 + .long 3884662774 + .long 1072582702 + .long 2158611599 + .long 1014210185 + .long 351641897 + .long 1072571974 + .long 2172261526 + .long 3163010599 + .long 863738719 + .long 1072561303 + .long 1326992220 + .long 3162613197 + .long 4076975200 + .long 1072550689 + .long 2029000899 + .long 1015208535 + .long 64696965 + .long 1072540134 + .long 1768797490 + .long 1015816960 + .long 382305176 + .long 1072529635 + .long 2347622376 + .long 3162578625 + .long 3707479175 + .long 1072519192 + .long 3613079303 + .long 1014164738 + .long 135105010 + .long 1072508807 + .long 1906148728 + .long 3163375739 + .long 1242007932 + .long 1072498477 + .long 1132034716 + .long 3163339831 + .long 1432208378 + .long 1072488203 + .long 1401068914 + .long 3162363963 + .long 3706687593 + .long 1072477984 + .long 3521726940 + .long 1013253067 + .long 2483480501 + .long 1072467821 + .long 1216371780 + .long 1013034172 + .long 777507147 + .long 1072457713 + .long 4282924205 + .long 1015187533 + .long 1610600570 + .long 1072447659 + .long 3766732298 + .long 1015760183 + .long 3716502172 + .long 1072437659 + .long 2303740125 + .long 1014042725 + .long 1540824585 + .long 1072427714 + .long 1064017011 + .long 3163487690 + .long 2420883922 + .long 1072417822 + .long 2049810052 + .long 1014119888 + .long 815859274 + .long 1072407984 + .long 240396590 + .long 3163487443 + .long 4076559943 + .long 1072398198 + .long 2119478331 + .long 3160758351 + .long 2380618042 + .long 1072388466 + .long 3149557219 + .long 3163320799 + .long 3092190715 + .long 1072378786 + .long 814012168 + .long 3159523422 + .long 697153126 + .long 1072369159 + .long 1283515429 + .long 3163283189 + .long 2572866477 + .long 1072359583 + .long 878562433 + .long 1015521741 + .long 3218338682 + .long 1072350059 + .long 3404164304 + .long 3162477108 + .long 1434058175 + .long 1072340587 + .long 251133233 + .long 1015085769 + .long 321958744 + .long 1072331166 + .long 3401933767 + .long 1015794558 + .long 2990417245 + .long 1072321795 + .long 3683467745 + .long 3163369326 + .long 3964284211 + .long 1072312475 + .long 2111583915 + .long 1015427164 + .long 2069751141 + .long 1072303206 + .long 1562170675 + .long 3162724681 + .long 434316067 + .long 1072293987 + .long 2028358766 + .long 1013458122 + .long 2191782032 + .long 1072284817 + .long 2960257726 + .long 1013742662 + .long 1892288442 + .long 1072275697 + .long 2446255666 + .long 3162600381 + .long 2682146384 + .long 1072266626 + .long 2082178513 + .long 3163363419 + .long 3418903055 + .long 1072257604 + .long 2527457337 + .long 3160820604 + .long 2966275557 + .long 1072248631 + .long 2176155324 + .long 3159842759 + .long 194117574 + .long 1072239707 + .long 777528612 + .long 3163412089 + .long 2568320822 + .long 1072230830 + .long 2732824428 + .long 1014352915 + .long 380978316 + .long 1072222002 + .long 854188970 + .long 3160462686 + .long 1110089947 + .long 1072213221 + .long 1451641639 + .long 1015474673 + .long 3649726105 + .long 1072204487 + .long 4085036346 + .long 1015649474 + .long 2604962541 + .long 1072195801 + .long 2614425274 + .long 3163539192 + .long 1176749997 + .long 1072187162 + .long 2738998779 + .long 3162035844 + .long 2571947539 + .long 1072178569 + .long 3558159064 + .long 3163376669 + .long 1413356050 + .long 1072170023 + .long 1651349291 + .long 3162668166 + .long 919555682 + .long 1072161523 + .long 3121969534 + .long 1012948226 + .long 19972402 + .long 1072153069 + .long 3507899862 + .long 1016009292 + .long 1944781191 + .long 1072144660 + .long 3993278767 + .long 3161724279 + .long 1339972927 + .long 1072136297 + .long 167908909 + .long 1015572152 + .long 1447192521 + .long 1072127979 + .long 1462857171 + .long 3162514521 + .long 1218806132 + .long 1072119706 + .long 1818613052 + .long 3162548441 + .long 3907805044 + .long 1072111477 + .long 2257091225 + .long 3161550407 + .long 4182873220 + .long 1072103293 + .long 629542646 + .long 3161996303 + .long 1013258799 + .long 1072095154 + .long 1748797611 + .long 3160129082 + .long 1963711167 + .long 1072087058 + .long 1744767757 + .long 3160574294 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 3561793907 + .long 1072070997 + .long 1157054053 + .long 1011890350 + .long 2186617381 + .long 1072063032 + .long 2270764084 + .long 3163272713 + .long 885834528 + .long 1072055110 + .long 1973258547 + .long 3162261564 + .long 2956612997 + .long 1072047230 + .long 2118169751 + .long 3162735553 + .long 3111574537 + .long 1072039393 + .long 2606161479 + .long 3162759746 + .long 363667784 + .long 1072031599 + .long 813753950 + .long 1015785209 + .long 2321106615 + .long 1072023846 + .long 2171176610 + .long 1009535771 + .long 3712504873 + .long 1072016135 + .long 88491949 + .long 1015427660 + .long 3566716925 + .long 1072008466 + .long 1536826856 + .long 1014142433 + .long 917841882 + .long 1072000839 + .long 18715565 + .long 1015659308 + .long 3395129871 + .long 1071993252 + .long 4025345435 + .long 3162335388 + .long 1453150082 + .long 1071985707 + .long 498154669 + .long 3161488062 + .long 2731501122 + .long 1071978202 + .long 1774031855 + .long 3162470021 + .long 1990012071 + .long 1071970738 + .long 3529070563 + .long 3162813193 + .long 2583551245 + .long 1071963314 + .long 3161094195 + .long 1015606491 + .long 3577096743 + .long 1071955930 + .long 2951496418 + .long 1013793687 + .long 4040676318 + .long 1071948586 + .long 4090609238 + .long 1015663458 + .long 3049340112 + .long 1071941282 + .long 3062915824 + .long 1013170595 + .long 3978100823 + .long 1071934017 + .long 3513027190 + .long 1015845963 + .long 1617004845 + .long 1071926792 + .long 82804944 + .long 1010342778 + .long 3645941911 + .long 1071919605 + .long 3814685081 + .long 3161573341 + .long 569847338 + .long 1071912458 + .long 472945272 + .long 3159290729 + .long 78413852 + .long 1071905349 + .long 4183226867 + .long 3163017251 + .long 1276261410 + .long 1071898278 + .long 300981948 + .long 1014684169 + .long 3272845541 + .long 1071891245 + .long 928852419 + .long 3163488248 + .long 887463927 + .long 1071884251 + .long 3596744163 + .long 3160794166 + .long 1829099622 + .long 1071877294 + .long 1016661181 + .long 3163461005 + .long 926591435 + .long 1071870375 + .long 3208833762 + .long 3162913514 + .long 1603444721 + .long 1071863493 + .long 1548633640 + .long 3162201326 + .long 2992903935 + .long 1071856648 + .long 2218154406 + .long 1015228193 + .long 4232894513 + .long 1071849840 + .long 2383938684 + .long 1014668519 + .long 171030293 + .long 1071843070 + .long 3526460132 + .long 1014428778 + .long 2839424854 + .long 1071836335 + .long 1171596163 + .long 1013041679 + .long 2799960843 + .long 1071829637 + .long 1423655381 + .long 1015022151 + .long 3504003472 + .long 1071822975 + .long 3594001060 + .long 3157330652 + .long 4112506593 + .long 1071816349 + .long 2947355221 + .long 1014371048 + .long 3790955393 + .long 1071809759 + .long 2352942462 + .long 3163180090 + .long 1709341917 + .long 1071803205 + .long 2571168217 + .long 1014152499 + .long 1337108031 + .long 1071796686 + .long 3203724452 + .long 1014677845 + .long 1853186616 + .long 1071790202 + .long 3066496371 + .long 1015656574 + .long 2440944790 + .long 1071783753 + .long 2492769774 + .long 1014147454 + .long 2288159958 + .long 1071777339 + .long 2169144469 + .long 1014876021 + .long 586995997 + .long 1071770960 + .long 41662348 + .long 3162627992 + .long 828946858 + .long 1071764615 + .long 10642492 + .long 1015939438 + .long 2214878420 + .long 1071758304 + .long 892270087 + .long 3163116422 + .long 3949972341 + .long 1071752027 + .long 2068408548 + .long 1014913868 + .long 948735466 + .long 1071745785 + .long 3516338028 + .long 3162574883 + .long 1014845819 + .long 1071739576 + .long 3117910646 + .long 3161559105 + .long 3366293073 + .long 1071733400 + .long 3119426314 + .long 1014120554 + .long 2930322912 + .long 1071727258 + .long 2599499422 + .long 3162714047 + .long 3228316108 + .long 1071721149 + .long 3010241991 + .long 3158422804 + .long 3490863953 + .long 1071715073 + .long 960797498 + .long 3162948880 + .long 2952712987 + .long 1071709030 + .long 3293494651 + .long 3160120301 + .long 852742562 + .long 1071703020 + .long 667253586 + .long 1009793559 + .long 728909815 + .long 1071697042 + .long 383930225 + .long 1015029468 + .long 1828292879 + .long 1071691096 + .long 1255956747 + .long 1015588398 + .long 3402036099 + .long 1071685182 + .long 405889334 + .long 1015105656 + .long 410360776 + .long 1071679301 + .long 1269990655 + .long 1011975870 + .long 702412510 + .long 1071673451 + .long 3803266087 + .long 3162280415 + .long 3541402996 + .long 1071667632 + .long 2759177317 + .long 1014854626 + .long 3899555717 + .long 1071661845 + .long 427280750 + .long 3162546972 + .long 1048019041 + .long 1071656090 + .long 1398474845 + .long 3160510595 + .long 2851812149 + .long 1071650365 + .long 2595802551 + .long 1015767337 + .long 0 + .long 1127743488 + .long 0 + .long 3275227136 + .long 3607404736 + .long 1044146952 + .long 3607404736 + .long 3191630600 + .long 4277811695 + .long 1063661122 + .long 4277811695 + .long 3211144770 + .long 2140175755 + .long 1033864261 + .long 2140175755 + .long 1033864261 + .long 4289495988 + .long 1054113747 + .long 4289495988 + .long 1054113747 + .long 4277811695 + .long 1064709698 + .long 4277811695 + .long 3212193346 + .long 1610612736 + .long 1080497479 + .long 4166901572 + .long 1053077003 + .long 3078135644 + .long 1049787983 + .long 381774870 + .long 1062650220 + .long 436314137 + .long 1056571808 + .long 1431655765 + .long 1067799893 + .long 4160749568 + .long 2147483647 + .long 0 + .long 1072693248 + .type static_const_table,@object + .size static_const_table,4256 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/coshf_wmt.S b/external/sgx_libm/ia32/coshf_wmt.S new file mode 100644 index 0000000000..59ce011471 --- /dev/null +++ b/external/sgx_libm/ia32/coshf_wmt.S @@ -0,0 +1,405 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "coshf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin coshf + .text + .align 16,0x90 + .globl coshf +coshf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movsd 608(%ebx), %xmm3 + movsd 512(%ebx), %xmm6 + movss %xmm0, 8(%esp) + movd %xmm0, %ecx + psllq $33, %xmm0 + psrlq $4, %xmm0 + movapd 528(%ebx), %xmm4 + andl $2147418112, %ecx + subl $1040187392, %ecx + cmpl $79691776, %ecx + jae .L_2TAG_PACKET_0.0.3 + mulsd %xmm0, %xmm3 + movapd %xmm3, %xmm2 + addsd %xmm6, %xmm3 + xorpd %xmm0, %xmm0 + movd %xmm3, %eax + subsd %xmm6, %xmm3 + movapd 544(%ebx), %xmm1 + xorpd %xmm5, %xmm5 + subsd %xmm3, %xmm2 + movl $31, %edx + andl %eax, %edx + shrl $1, %eax + addl %edx, %edx + andl $65520, %eax + addl $16352, %eax + cmpl $71303168, %ecx + jae .L_2TAG_PACKET_1.0.3 + pinsrw $3, %eax, %xmm0 + movl $32704, %ecx + subl %eax, %ecx + movapd 560(%ebx), %xmm3 + movapd (%ebx,%edx,8), %xmm7 + pinsrw $3, %ecx, %xmm5 + pshufd $68, %xmm2, %xmm2 + shufpd $0, %xmm5, %xmm0 + movapd 576(%ebx), %xmm6 + mulpd %xmm2, %xmm4 + mulpd %xmm2, %xmm1 + mulpd %xmm2, %xmm3 + mulpd %xmm7, %xmm0 + mulpd %xmm2, %xmm4 + addpd %xmm1, %xmm6 + mulpd %xmm0, %xmm3 + addpd %xmm6, %xmm4 + mulpd %xmm3, %xmm4 + addpd %xmm4, %xmm0 + pshufd $78, %xmm0, %xmm4 + addpd %xmm4, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + addl $1040187392, %ecx + cmpl $1040187392, %ecx + ja .L_2TAG_PACKET_3.0.3 + cmpl $956301312, %ecx + jae .L_2TAG_PACKET_4.0.3 + movss 592(%ebx), %xmm3 + mulss %xmm3, %xmm3 + fld1 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + pinsrw $3, %eax, %xmm0 + movsd 560(%ebx), %xmm3 + pshufd $68, %xmm2, %xmm2 + mulsd (%ebx,%edx,8), %xmm0 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm1, %xmm4 + mulsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm3, %xmm4 + mulsd %xmm0, %xmm4 + addsd %xmm4, %xmm0 + cvtsd2ss %xmm0, %xmm0 + pextrw $1, %xmm0, %eax + andl $32640, %eax + movl $65, %edx + cmpl $32640, %eax + je .L_2TAG_PACKET_5.0.3 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + movss 592(%ebx), %xmm7 + movss 8(%esp), %xmm1 + mulss %xmm1, %xmm1 + movss 596(%ebx), %xmm2 + movl $1056964608, %eax + movd %eax, %xmm3 + movss %xmm1, %xmm0 + mulss %xmm1, %xmm7 + movl $1065353216, %edx + movd %edx, %xmm6 + mulss %xmm1, %xmm1 + addss %xmm2, %xmm7 + mulps %xmm1, %xmm7 + mulss %xmm3, %xmm0 + addss %xmm7, %xmm0 + addss %xmm6, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $2139095040, %ecx + jae .L_2TAG_PACKET_6.0.3 + xorps %xmm0, %xmm0 + movl $32512, %eax + pinsrw $1, %eax, %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_5.0.3: + movss %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $65, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + movss 8(%esp), %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_2.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type coshf,@function + .size coshf,.-coshf + .data +# -- End coshf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 3541402996 + .long 1072716208 + .long 1533953344 + .long 1072648310 + .long 1828292879 + .long 1072739672 + .long 2728693978 + .long 1072604335 + .long 3490863953 + .long 1072763649 + .long 863738719 + .long 1072561303 + .long 1014845819 + .long 1072788152 + .long 3707479175 + .long 1072519192 + .long 828946858 + .long 1072813191 + .long 3706687593 + .long 1072477984 + .long 1853186616 + .long 1072838778 + .long 3716502172 + .long 1072437659 + .long 4112506593 + .long 1072864925 + .long 4076559943 + .long 1072398198 + .long 171030293 + .long 1072891646 + .long 2572866477 + .long 1072359583 + .long 926591435 + .long 1072918951 + .long 2990417245 + .long 1072321795 + .long 1276261410 + .long 1072946854 + .long 2191782032 + .long 1072284817 + .long 1617004845 + .long 1072975368 + .long 2966275557 + .long 1072248631 + .long 3577096743 + .long 1073004506 + .long 1110089947 + .long 1072213221 + .long 1453150082 + .long 1073034283 + .long 2571947539 + .long 1072178569 + .long 3712504873 + .long 1073064711 + .long 1944781191 + .long 1072144660 + .long 2956612997 + .long 1073095806 + .long 3907805044 + .long 1072111477 + .long 1719614413 + .long 1073127582 + .long 1719614413 + .long 1072079006 + .long 3907805044 + .long 1073160053 + .long 2956612997 + .long 1072047230 + .long 1944781191 + .long 1073193236 + .long 3712504873 + .long 1072016135 + .long 2571947539 + .long 1073227145 + .long 1453150082 + .long 1071985707 + .long 1110089947 + .long 1073261797 + .long 3577096743 + .long 1071955930 + .long 2966275557 + .long 1073297207 + .long 1617004845 + .long 1071926792 + .long 2191782032 + .long 1073333393 + .long 1276261410 + .long 1071898278 + .long 2990417245 + .long 1073370371 + .long 926591435 + .long 1071870375 + .long 2572866477 + .long 1073408159 + .long 171030293 + .long 1071843070 + .long 4076559943 + .long 1073446774 + .long 4112506593 + .long 1071816349 + .long 3716502172 + .long 1073486235 + .long 1853186616 + .long 1071790202 + .long 3706687593 + .long 1073526560 + .long 828946858 + .long 1071764615 + .long 3707479175 + .long 1073567768 + .long 1014845819 + .long 1071739576 + .long 863738719 + .long 1073609879 + .long 3490863953 + .long 1071715073 + .long 2728693978 + .long 1073652911 + .long 1828292879 + .long 1071691096 + .long 1533953344 + .long 1073696886 + .long 3541402996 + .long 1071667632 + .long 0 + .long 1127743488 + .long 0 + .long 3275227136 + .long 4289495988 + .long 1058308051 + .long 4289495988 + .long 1058308051 + .long 4277811695 + .long 1065758274 + .long 4277811695 + .long 3213241922 + .long 4277811695 + .long 1066806850 + .long 4277811695 + .long 3214290498 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 985008993 + .long 1026206379 + .long 0 + .long 0 + .long 1697350398 + .long 2017924423 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,640 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/coshl.S b/external/sgx_libm/ia32/coshl.S new file mode 100644 index 0000000000..5b0301b800 --- /dev/null +++ b/external/sgx_libm/ia32/coshl.S @@ -0,0 +1,942 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "coshl.c" + .text +..TXTST0: +# -- Begin coshl + .text + .align 16,0x90 + .globl coshl +coshl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $72, %esp +..B1.2: + fnstcw 58(%esp) +..B1.3: + movzwl 16(%ebp), %ebx + andl $32767, %ebx + movl 12(%ebp), %ecx + movl %ebx, %esi + movl %ecx, %edx + shll $16, %esi + shrl $16, %edx + movzbl 17(%ebp), %eax + orl %edx, %esi + andl $128, %eax + shrl $7, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $1073992020, %esi + jae ..B1.50 +..B1.4: + movzwl 58(%esp), %ecx + cmpl $16382, %ebx + jge ..B1.43 +..B1.5: + cmpl $16378, %ebx + jge ..B1.36 +..B1.6: + cmpl $16372, %ebx + jge ..B1.29 +..B1.7: + cmpl $16365, %ebx + jge ..B1.22 +..B1.8: + cmpl $16308, %ebx + jge ..B1.16 +..B1.9: + movl %ecx, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.69 +..B1.10: + orl $-64768, %ecx + movw %cx, 56(%esp) +..B1.11: + fldcw 56(%esp) +..B1.12: + movzbl 17(%ebp), %eax + movl $1, %ecx + andl $128, %eax + shrl $7, %eax +..B1.13: + fldt 8(%ebp) + testl %ecx, %ecx + fmull ones@GOTOFF(%edx,%eax,8) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.15 +..B1.14: + fldcw 58(%esp) +..B1.15: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.70 +..B1.17: + orl $-64768, %ecx + movw %cx, 56(%esp) +..B1.18: + fldcw 56(%esp) +..B1.19: + fldt 8(%ebp) + fldt _Q3@GOTOFF(%edx) + fmul %st(1), %st + fmulp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + fstpt (%esp) +..B1.20: + fldcw 58(%esp) +..B1.21: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.22: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.71 +..B1.23: + orl $-64768, %ecx + movw %cx, 56(%esp) +..B1.24: + fldcw 56(%esp) +..B1.25: + movl $1, %eax +..B1.26: + fldt 8(%ebp) + testl %eax, %eax + fmul %st(0), %st + fldt 12+_Q2@GOTOFF(%edx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.28 +..B1.27: + fldcw 58(%esp) +..B1.28: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.72 +..B1.30: + orl $-64768, %ecx + movw %cx, 56(%esp) +..B1.31: + fldcw 56(%esp) +..B1.32: + movl $1, %eax +..B1.33: + fldt 8(%ebp) + testl %eax, %eax + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%edx) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%edx) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.35 +..B1.34: + fldcw 58(%esp) +..B1.35: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.36: + movl %ecx, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.73 +..B1.37: + orl $-64768, %ecx + movw %cx, 56(%esp) +..B1.38: + fldcw 56(%esp) +..B1.39: + movzbl 17(%ebp), %eax + movl $1, %ecx + andl $128, %eax + shrl $7, %eax +..B1.40: + fldl _TWO_48H@GOTOFF(%edx) + testl %ecx, %ecx + fld %st(0) + fldt 8(%ebp) + fmull ones@GOTOFF(%edx,%eax,8) + fstpt 8(%ebp) + fldt 8(%ebp) + fadd %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fld %st(2) + fmul %st(3), %st + fld %st(0) + fmul %st(1), %st + fldt 84+_Q@GOTOFF(%edx) + fmul %st(1), %st + fldt 72+_Q@GOTOFF(%edx) + fmul %st(2), %st + fldt 60+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fld %st(4) + fmul %st(4), %st + fxch %st(6) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(5) + fxch %st(3) + fmul %st(0), %st + fldt 12+_Q@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fldt 108+_Q@GOTOFF(%edx) + fld %st(0) + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fmul %st, %st(1) + fldt 96+_Q@GOTOFF(%edx) + fld %st(0) + fmul %st(5), %st + fxch %st(3) + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(2) + fmul %st, %st(3) + fld %st(3) + fxch %st(3) + fmulp %st, %st(1) + fadd %st, %st(2) + fldl _TWO_48H@GOTOFF(%edx) + fadd %st, %st(3) + fsubr %st(3), %st + fsubr %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + je ..B1.83 +..B1.41: + fstpt 44(%esp) +..B1.82: + fldcw 58(%esp) + jmp ..B1.42 +..B1.83: + fstp %st(0) +..B1.42: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.43: + movl %ecx, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.74 +..B1.44: + orl $-64768, %ecx + movw %cx, 56(%esp) +..B1.45: + fldcw 56(%esp) +..B1.46: + movzbl 17(%ebp), %eax + movl $1, %ecx + andl $128, %eax + shrl $7, %eax +..B1.47: + fldt 8(%ebp) + fmull ones@GOTOFF(%edx,%eax,8) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%edx) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(2), %st + fadd %st(1), %st + fstpt 44(%esp) + fldt 44(%esp) + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmul %st(1), %st + movl 44(%esp), %eax + fsubrp %st, %st(2) + fld %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmulp %st, %st(2) + movsbl %al, %esi + fsub %st(1), %st + fldl _TWO_32P@GOTOFF(%edx) + subl %esi, %eax + fmul %st(1), %st + fxch %st(1) + fmull _TWO_32@GOTOFF(%edx) + shll $4, %esi + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + shrl $8, %eax + fxch %st(2) + fsubrp %st, %st(3) + movl %eax, %ebx + negl %eax + shll $23, %ebx + fadd %st(2), %st + fld %st(0) + addl $1056964608, %ebx + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + shll $23, %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + addl $1056964608, %eax + fldt 12+_P@GOTOFF(%edx) + movl %ebx, 12(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + movl %eax, 28(%esp) + fxch %st(2) + faddp %st, %st(4) + fld %st(3) + fldt _P@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + fadd %st, %st(1) + fsubp %st, %st(3) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%esi) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%esi) + negl %esi + fstpt 16(%esp) + fldt 16(%esp) + testl %ecx, %ecx + fadd %st(1), %st + fmulp %st, %st(2) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(2) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%esi) + fld %st(0) + fmul %st(4), %st + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%esi) + fld %st(0) + fadd %st(3), %st + fmulp %st, %st(7) + fxch %st(1) + fsubrp %st, %st(6) + fxch %st(5) + fstpt 32(%esp) + fldt 16(%esp) + fld %st(0) + fmul %st(5), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + fmul %st(4), %st + fld %st(4) + fsub %st(1), %st + fsubr %st, %st(5) + fxch %st(1) + fsubrp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fldt 32(%esp) + faddp %st, %st(3) + flds 12(%esp) + fmul %st, %st(2) + fmulp %st, %st(1) + flds 28(%esp) + fmul %st, %st(4) + fld %st(4) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.49 +..B1.48: + fldcw 58(%esp) +..B1.49: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.50: + cmpl $16396, %ebx + jge ..B1.58 +..B1.51: + movzwl 58(%esp), %ebx + movl %ebx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.75 +..B1.52: + orl $-64768, %ebx + movw %bx, 56(%esp) +..B1.53: + fldcw 56(%esp) +..B1.54: + movzbl 17(%ebp), %eax + movl $1, %ecx + andl $128, %eax + shrl $7, %eax +..B1.55: + fldt 8(%ebp) + fmull ones@GOTOFF(%edx,%eax,8) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fstpt (%esp) + fldl _TWO_63H@GOTOFF(%edx) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(2), %st + movzwl 8+.L_2il0floatpacket.3@GOTOFF(%edx), %ebx + fadd %st(1), %st + fstpt 44(%esp) + fldt 44(%esp) + andl $-32768, %ebx + movl 44(%esp), %eax + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmul %st(1), %st + movsbl %al, %esi + fsubrp %st, %st(2) + fld %st(1) + subl %esi, %eax + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmulp %st, %st(2) + shll $4, %esi + fsub %st(1), %st + fldl _TWO_32@GOTOFF(%edx) + fldl _TWO_32P@GOTOFF(%edx) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + shrl $8, %eax + fxch %st(2) + fsubrp %st, %st(1) + fld %st(0) + addl $16350, %eax + andl $32767, %eax + fxch %st(1) + fsubr %st, %st(4) + orl %eax, %ebx + fxch %st(3) + fsubrp %st, %st(4) + movw %bx, 8(%esp) + testl %ecx, %ecx + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(5) + fldt _P@GOTOFF(%edx) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%esi) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%esi) + fld %st(0) + fmul %st(5), %st + fxch %st(4) + fadd %st, %st(5) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldt (%esp) + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.57 +..B1.56: + fldcw 58(%esp) +..B1.57: + fldt 16(%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.58: + je ..B1.77 +..B1.59: + movzwl 58(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.76 +..B1.60: + orl $-64768, %ecx + movw %cx, 56(%esp) +..B1.61: + fldcw 56(%esp) +..B1.62: + movzwl 16(%ebp), %ebx + movl $1, %ecx + andl $32767, %ebx +..B1.63: + cmpl $32767, %ebx + jne ..B1.65 +..B1.64: + fldt 8(%ebp) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmull ones@GOTOFF(%edx,%eax,8) + fstpt (%esp) + jmp ..B1.66 +..B1.65: + fldt _large_value_80@GOTOFF(%edx) + fmul %st(0), %st + fstpt (%esp) +..B1.66: + testl %ecx, %ecx + je ..B1.68 +..B1.67: + fldcw 58(%esp) +..B1.68: + fldt (%esp) + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.69: + xorl %ecx, %ecx + jmp ..B1.13 +..B1.70: + fldt 8(%ebp) + fldt _Q3@GOTOFF(%edx) + fmul %st(1), %st + fmulp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.21 +..B1.71: + xorl %eax, %eax + jmp ..B1.26 +..B1.72: + xorl %eax, %eax + jmp ..B1.33 +..B1.73: + xorl %ecx, %ecx + jmp ..B1.40 +..B1.74: + xorl %ecx, %ecx + jmp ..B1.47 +..B1.75: + xorl %ecx, %ecx + jmp ..B1.55 +..B1.76: + xorl %ecx, %ecx + jmp ..B1.63 +..B1.77: + cmpl $-1317741120, %ecx + jb ..B1.51 +..B1.78: + jne ..B1.59 +..B1.79: + cmpl $833536233, 8(%ebp) + jbe ..B1.51 + jmp ..B1.59 + .align 16,0x90 + .type coshl,@function + .size coshl,.-coshl + .data +# -- End coshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 2 +_Q3: + .word 21845 + .word 213 + .word 0 + .word 32768 + .word 16382 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 62430 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 22894 + .word 21845 + .word 43733 + .word 43690 + .word 16378 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 65531 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 7054 + .word 43693 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 25016 + .word 58228 + .word 24755 + .word 46603 + .word 16373 + .word 0 + .word 57397 + .word 35800 + .word 53031 + .word 53262 + .word 16367 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 18360 + .word 43637 + .word 28980 + .word 40373 + .word 49076 + .word 0 + .word 16302 + .word 43691 + .word 43690 + .word 43690 + .word 16362 + .word 0 + .word 46125 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .word 29965 + .word 3335 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 54950 + .word 46751 + .word 32187 + .word 37874 + .word 16361 + .word 0 + .word 30733 + .word 25775 + .word 51110 + .word 36726 + .word 16354 + .word 0 + .word 49850 + .word 450 + .word 9929 + .word 51659 + .word 16346 + .word 0 + .word 2776 + .word 45191 + .word 37201 + .word 55334 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16378 + .word 0 + .type _Q,@object + .size _Q,120 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cosl.S b/external/sgx_libm/ia32/cosl.S new file mode 100644 index 0000000000..2db539db3c --- /dev/null +++ b/external/sgx_libm/ia32/cosl.S @@ -0,0 +1,1022 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosl.c" + .text +..TXTST0: +# -- Begin cosl + .text + .align 16,0x90 + .globl cosl +cosl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 136(%esp) +..B1.2: + fnstcw 46(%esp) +..B1.3: + movzwl 16(%ebp), %edx + andl $32767, %edx + movzwl 46(%esp), %eax + cmpl $16378, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jge ..B1.47 +..B1.4: + cmpl $16372, %edx + jge ..B1.39 +..B1.5: + cmpl $16364, %edx + jge ..B1.31 +..B1.6: + cmpl $16308, %edx + jge ..B1.23 +..B1.7: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.77 +..B1.8: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.9: + fldcw 44(%esp) +..B1.10: + movzwl 16(%ebp), %edx + movl $1, %eax + andl $32767, %edx +..B1.11: + testl %edx, %edx + jne ..B1.17 +..B1.12: + cmpl $0, 12(%ebp) + jne ..B1.14 +..B1.13: + cmpl $0, 8(%ebp) + je ..B1.18 +..B1.91: + cmpl $0, 12(%ebp) +..B1.14: + jne ..B1.16 +..B1.15: + cmpl $0, 8(%ebp) + je ..B1.17 +..B1.16: + fldl _smallest_value_64@GOTOFF(%ebx) + fstpl (%esp) +..B1.17: + fldt _small_value_80@GOTOFF(%ebx) + fsubrl _ones@GOTOFF(%ebx) + fstpt 8(%esp) + jmp ..B1.19 +..B1.18: + fldl _ones@GOTOFF(%ebx) + fstpt 8(%esp) +..B1.19: + testl %eax, %eax + je ..B1.21 +..B1.20: + fldcw 46(%esp) +..B1.21: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.76 +..B1.22: + fldt 8(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.79 +..B1.24: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.25: + fldcw 44(%esp) +..B1.26: + movl $1, %eax +..B1.27: + fldt 8(%ebp) + testl %eax, %eax + fldt _CP3@GOTOFF(%ebx) + fmul %st(1), %st + fmulp %st, %st(1) + faddl _ones@GOTOFF(%ebx) + fstpt 8(%esp) + je ..B1.29 +..B1.28: + fldcw 46(%esp) +..B1.29: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.76 +..B1.30: + fldt 8(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.81 +..B1.32: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.33: + fldcw 44(%esp) +..B1.34: + movl $1, %eax +..B1.35: + fldt 8(%ebp) + testl %eax, %eax + fmul %st(0), %st + fldt 12+_CP2@GOTOFF(%ebx) + fmul %st(1), %st + fldt _CP2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddl _ones@GOTOFF(%ebx) + fstpt 8(%esp) + je ..B1.37 +..B1.36: + fldcw 46(%esp) +..B1.37: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.76 +..B1.38: + fldt 8(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.83 +..B1.40: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.41: + fldcw 44(%esp) +..B1.42: + movl $1, %eax +..B1.43: + fldt 8(%ebp) + testl %eax, %eax + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_CP1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_CP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_CP1@GOTOFF(%ebx) + fmulp %st, %st(2) + fldt _CP1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddl _ones@GOTOFF(%ebx) + fstpt 8(%esp) + je ..B1.45 +..B1.44: + fldcw 46(%esp) +..B1.45: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.76 +..B1.46: + fldt 8(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.47: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.86 +..B1.48: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.49: + fldcw 44(%esp) +..B1.50: + movzwl 16(%ebp), %edx + movl $1, %esi + andl $32767, %edx +..B1.51: + cmpl $16413, %edx + jge ..B1.58 +..B1.52: + fldt 8(%ebp) + fldl _Pi4Inv@GOTOFF(%ebx) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fxch %st(1) + fmull _ones@GOTOFF(%ebx,%eax,8) + fmul %st, %st(1) + fxch %st(1) + fstpt 20(%esp) + movzwl 28(%esp), %ecx + andl $32767, %ecx + cmpl $16383, %ecx + jge ..B1.54 +..B1.53: + fldl _TWO_52H@GOTOFF(%ebx) + xorl %eax, %eax + fmul %st(1), %st + fld %st(1) + movl $1, %ecx + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(1) + fsub %st(1), %st + fxch %st(2) + fxch %st(1) + fxch %st(2) + jmp ..B1.69 +..B1.54: + fldl _TWO_32H@GOTOFF(%ebx) + negl %ecx + addl $30, %ecx + movl 24(%esp), %eax + shrl %cl, %eax + lea 1(%eax), %ecx + movl %ecx, %edi + andl $-2, %edi + movl %edi, 8(%esp) + cmpl $16400, %edx + fildl 8(%esp) + jge ..B1.56 +..B1.55: + fldl _Pi04x3@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x3@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_Pi04x3@GOTOFF(%ebx) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + jmp ..B1.57 +..B1.56: + fldl _Pi04x5@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x5@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl 24+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl 32+_Pi04x5@GOTOFF(%ebx) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) +..B1.57: + fldl _TWO_52H@GOTOFF(%ebx) + addl $3, %eax + fmul %st(1), %st + fld %st(1) + shrl $2, %eax + fadd %st(1), %st + andl $1, %eax + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fxch %st(1) + fxch %st(2) + jmp ..B1.69 +..B1.58: + cmpl $32767, %edx + jne ..B1.67 +..B1.59: + cmpl $-2147483648, 12(%ebp) + jne ..B1.62 +..B1.60: + cmpl $0, 8(%ebp) + jne ..B1.62 +..B1.61: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpt 8(%esp) + jmp ..B1.63 +..B1.62: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx) + fstpt 8(%esp) +..B1.63: + testl %esi, %esi + je ..B1.65 +..B1.64: + fldcw 46(%esp) +..B1.65: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.76 +..B1.66: + fldt 8(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.67: + fldt 8(%ebp) + addl $-32, %esp + movzbl 17(%ebp), %eax + lea 152(%esp), %edx + andl $128, %eax + shrl $7, %eax + fmull _ones@GOTOFF(%ebx,%eax,8) + fstpt (%esp) + movl $0, 12(%esp) + movl %edx, 16(%esp) + call __libm_reduce_pi04l +..B1.89: + movl %eax, %ecx + addl $32, %esp +..B1.68: + fldl 120(%esp) + lea 3(%ecx), %eax + fldl _TWO_52H@GOTOFF(%ebx) + incl %ecx + fmul %st(1), %st + fld %st(0) + shrl $2, %eax + fadd %st(2), %st + andl $1, %eax + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddl 128(%esp) + fadd %st, %st(1) +..B1.69: + fldl _TWO_53H@GOTOFF(%ebx) + testb $2, %cl + fstpt 48(%esp) + fld %st(2) + fmul %st(1), %st + fld %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fstpt 80(%esp) + fldt 80(%esp) + fld %st(3) + fmul %st(4), %st + fld %st(0) + fadd %st(2), %st + fstpt 32(%esp) + fldt 32(%esp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fld %st(1) + fmul %st(2), %st + fld %st(0) + faddp %st, %st(2) + fldl _ones@GOTOFF(%ebx,%eax,8) + fstpl 112(%esp) + je ..B1.71 +..B1.70: + fldt 96+_SP@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(6) + fstpt 8(%esp) + fldt 84+_SP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 72+_SP@GOTOFF(%ebx) + faddp %st, %st(7) + fxch %st(2) + fmul %st, %st(6) + fldt 60+_SP@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(7) + fmul %st, %st(6) + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(7) + fmul %st, %st(6) + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(6) + fldt 32(%esp) + fmulp %st, %st(6) + fxch %st(1) + faddp %st, %st(5) + fldt 64(%esp) + fldt 80(%esp) + fldt 120+_SP@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(7) + fxch %st(1) + fmulp %st, %st(2) + fldt 108+_SP@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(1) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(5) + fxch %st(1) + fadd %st(4), %st + fld %st(2) + fldt 48(%esp) + fmul %st(2), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(5) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 8(%esp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fadd %st, %st(1) + fldl 112(%esp) + fmul %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%esp) + jmp ..B1.72 +..B1.71: + fstp %st(3) + fstp %st(3) + fstp %st(3) + fldt 96+_CP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 84+_CP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 72+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 32(%esp) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 64(%esp) + fldt 80(%esp) + fldt 120+_CP@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldt 108+_CP@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fldt 48(%esp) + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(0) + fldl 112(%esp) + fldl _ones@GOTOFF(%ebx) + fadd %st, %st(2) + fsub %st(2), %st + faddp %st, %st(3) + fxch %st(2) + fadd %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%esp) +..B1.72: + testl %esi, %esi + je ..B1.92 +..B1.73: + fstpt 20(%esp) +..B1.90: + fldcw 46(%esp) + jmp ..B1.74 +..B1.92: + fstp %st(0) +..B1.74: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.76 +..B1.75: + fldt 96(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.76: + call __stack_chk_fail@PLT +..B1.77: + xorl %eax, %eax + jmp ..B1.11 +..B1.79: + xorl %eax, %eax + jmp ..B1.27 +..B1.81: + xorl %eax, %eax + jmp ..B1.35 +..B1.83: + xorl %eax, %eax + jmp ..B1.43 +..B1.86: + xorl %esi, %esi + jmp ..B1.51 + .align 16,0x90 + .type cosl,@function + .size cosl,.-cosl + .data +# -- End cosl + .section .rodata, "a" + .align 16 + .align 16 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 16 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .space 8, 0x00 # pad + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_CP3: + .word 0 + .word 65450 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .type _CP3,@object + .size _CP3,12 + .space 4, 0x00 # pad + .align 16 +_CP2: + .word 63855 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 18238 + .word 17476 + .word 43656 + .word 43690 + .word 16378 + .word 0 + .type _CP2,@object + .size _CP2,24 + .space 8, 0x00 # pad + .align 16 +_CP1: + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 47533 + .word 43689 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 14131 + .word 49466 + .word 24756 + .word 46603 + .word 49141 + .word 0 + .word 37142 + .word 18013 + .word 35855 + .word 53259 + .word 16367 + .word 0 + .type _CP1,@object + .size _CP1,48 + .align 16 +_Pi4Inv: + .long 1841940611 + .long 1072979760 + .type _Pi4Inv,@object + .size _Pi4Inv,8 + .space 8, 0x00 # pad + .align 16 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .space 8, 0x00 # pad + .align 16 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .space 8, 0x00 # pad + .align 16 +_Pi04x3: + .long 1413754112 + .long 1072243195 + .long 2563527040 + .long 1021855384 + .long 3417685868 + .long 3118450936 + .type _Pi04x3,@object + .size _Pi04x3,24 + .space 8, 0x00 # pad + .align 16 +_Pi04x5: + .long 1413480448 + .long 1072243195 + .long 442499072 + .long 1036039265 + .long 771751936 + .long 999496074 + .long 622854144 + .long 963347354 + .long 1396597664 + .long 922906692 + .type _Pi04x5,@object + .size _Pi04x5,40 + .space 8, 0x00 # pad + .align 16 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 16 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 16 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .space 8, 0x00 # pad + .align 16 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .type _SP,@object + .size _SP,132 + .space 12, 0x00 # pad + .align 16 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .type _CP,@object + .size _CP,132 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cpow.S b/external/sgx_libm/ia32/cpow.S new file mode 100644 index 0000000000..541a0cb524 --- /dev/null +++ b/external/sgx_libm/ia32/cpow.S @@ -0,0 +1,898 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cpow.c" + .text +..TXTST0: +# -- Begin cpowf + .text + .align 16,0x90 + .globl cpowf +cpowf: +# parameter 1: 80 + %esp +# parameter 2: 88 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $72, %esp + flds 80(%esp) + flds 84(%esp) + flds 88(%esp) + flds 92(%esp) + movl %gs:20, %ecx + xorl %esp, %ecx + movl %ecx, 56(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpl 48(%esp) + fxch %st(2) + fstpl 24(%esp) + fstpl 32(%esp) + fstpl 40(%esp) + addl $-48, %esp + movl 72(%esp), %ecx + lea 56(%esp), %eax + movl %eax, (%esp) + lea 4(%esp), %edx + movl 20(%eax), %eax + movl %ecx, (%edx) + movl %eax, 4(%edx) + movl 80(%esp), %ecx + movl 84(%esp), %eax + movl %ecx, 8(%edx) + movl %eax, 12(%edx) + lea 20(%esp), %eax + movl 88(%esp), %edx + movl %edx, (%eax) + movl 92(%esp), %edx + movl %edx, 4(%eax) + movl 96(%esp), %ecx + movl 100(%esp), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call cpow@PLT +..B1.7: + addl $44, %esp +..B1.2: + fldl 8(%esp) + fstps (%esp) + fldl 16(%esp) + fstps 4(%esp) + movl 56(%esp), %ecx + xorl %esp, %ecx + movl (%esp), %eax + movl 4(%esp), %edx + cmpl %gs:20, %ecx + jne ..B1.4 +..B1.3: + addl $72, %esp + popl %ebx + ret +..B1.4: + call __stack_chk_fail@PLT + .align 16,0x90 + .type cpowf,@function + .size cpowf,.-cpowf + .data +# -- End cpowf + .text +# -- Begin cpow + .text + .align 16,0x90 + .globl cpow +cpow: +# parameter 1: 12 + %ebp +# parameter 2: 28 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 224(%esp) + fstl 208(%esp) + fstpl 216(%esp) +..B2.2: + fnstcw 206(%esp) +..B2.3: + movzwl 206(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B2.38 +..B2.4: + orl $-64768, %ecx + movw %cx, 204(%esp) +..B2.5: + fldcw 204(%esp) +..B2.6: + movl $1, %esi +..B2.7: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnzfinite +..B2.41: + addl $16, %esp +..B2.8: + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + testl %eax, %eax + jne ..B2.31 +..B2.9: + fldl 20(%ebp) + fldl ZEROA@GOTOFF(%ebx) + fucom %st(1) + fnstsw %ax + sahf + jp ..B2.10 + je ..B2.27 +..B2.10: + fldl 28(%ebp) + fucom %st(1) + fnstsw %ax + sahf + jp ..B2.11 + je ..B2.25 +..B2.11: + fxch %st(2) + fucom %st(1) + fnstsw %ax + sahf + jp ..B2.12 + je ..B2.20 +..B2.12: + fstp %st(2) + fldl 36(%ebp) + fucompp + fnstsw %ax + sahf + jp ..B2.13 + je ..B2.19 +..B2.13: + fldl 12(%ebp) + fstpt 36(%esp) + fstpt 48(%esp) + fldt 36(%esp) + fldt 36(%esp) + fmulp %st, %st(1) + fldt 48(%esp) + fldt 48(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B2.49: + addl $16, %esp + fstpt 120(%esp) + fldt 48(%esp) + fldt 36(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2dl@PLT +..B2.48: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + addl $32, %esp + fstpt (%esp) + fldt (%esp) + fxch %st(1) + fstpt 60(%esp) + fldt 120(%esp) + addl $-16, %esp + fldl 28(%ebp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%esp) + call expl@PLT +..B2.47: + fldt _LD_PI_DIV_180@GOTOFF(%ebx) + addl $16, %esp + fxch %st(1) + fstpt 156(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 36(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + call expl@PLT +..B2.46: + fldl 36(%ebp) + addl $16, %esp + fxch %st(1) + fstpt 168(%esp) + fldt 156(%esp) + fldt 168(%esp) + fdivrp %st, %st(1) + fstpt 72(%esp) + fldt 120(%esp) + addl $-16, %esp + fldt 16(%esp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%esp) + call cosl@PLT +..B2.45: + addl $16, %esp + fstpt 132(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call cosdl@PLT +..B2.44: + addl $16, %esp + fstpt 84(%esp) + fldt 120(%esp) + addl $-16, %esp + fldt 16(%esp) + fmull 36(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + call sinl@PLT +..B2.43: + addl $16, %esp + fstpt 144(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call sindl@PLT +..B2.42: + addl $16, %esp + fstpt 96(%esp) + fldt 132(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + fldt 144(%esp) + fldt 96(%esp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt 180(%esp) + fldt 144(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + fldt 96(%esp) + fldt 132(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 192(%esp) + fldt 180(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 208(%esp) + fldt 192(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 216(%esp) +..B2.14: + testl %esi, %esi + je ..B2.16 +..B2.15: + fldcw 206(%esp) +..B2.16: + movl 208(%esp), %edx + movl %edx, (%edi) + movl 212(%esp), %ecx + movl 216(%esp), %esi + movl 220(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 224(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B2.18 +..B2.17: + movl %edi, %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B2.18: + call __stack_chk_fail@PLT +..B2.19: + fldl 12(%ebp) + fstpt 36(%esp) + fstpt 48(%esp) + fldt 36(%esp) + fldt 36(%esp) + fmulp %st, %st(1) + fldt 48(%esp) + fldt 48(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + addl $-32, %esp + fstpt (%esp) + fldl .L_2il0floatpacket.0@GOTOFF(%ebx) + fmull 28(%ebp) + fstpt 12(%esp) + call powl@PLT +..B2.53: + addl $32, %esp + fstpt 72(%esp) + fldt 48(%esp) + fldt 36(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2dl@PLT +..B2.52: + addl $32, %esp + fstpt 60(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call cosdl@PLT +..B2.51: + addl $16, %esp + fstpt 132(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call sindl@PLT +..B2.50: + addl $16, %esp + fstpt 144(%esp) + fldt 72(%esp) + fldt 132(%esp) + fmulp %st, %st(1) + fstpl 208(%esp) + fldt 72(%esp) + fldt 144(%esp) + fmulp %st, %st(1) + fstpl 216(%esp) + jmp ..B2.14 +..B2.20: + fldl 12(%ebp) + fcom %st(2) + fnstsw %ax + sahf + jbe ..B2.22 +..B2.21: + fstp %st(1) + fstp %st(1) + addl $-32, %esp + fstpt (%esp) + fstpt 12(%esp) + call powl@PLT +..B2.57: + fldl 12(%ebp) + addl $32, %esp + fxch %st(1) + fstpt 72(%esp) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B2.56: + addl $16, %esp + fstpt 24(%esp) + fldt 24(%esp) + addl $-16, %esp + fmull 36(%ebp) + fstpt (%esp) + call cosl@PLT +..B2.55: + addl $16, %esp + fstpt 132(%esp) + fldt 24(%esp) + addl $-16, %esp + fmull 36(%ebp) + fstpt (%esp) + call sinl@PLT +..B2.54: + addl $16, %esp + fstpt 144(%esp) + fldt 132(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 208(%esp) + fldt 144(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 216(%esp) + jmp ..B2.14 +..B2.22: + fstp %st(3) + fxch %st(1) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B2.24 +..B2.23: + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fchs + fstpt 12(%esp) + fstpt 48(%esp) + fldt 12(%esp) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B2.65: + addl $16, %esp + fstpt 120(%esp) + fldt 48(%esp) + fldt 36(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2dl@PLT +..B2.64: + addl $32, %esp + fstpt 60(%esp) + fldt 120(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call expl@PLT +..B2.63: + fldt _LD_PI_DIV_180@GOTOFF(%ebx) + addl $16, %esp + fxch %st(1) + fstpt 156(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 36(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + call expl@PLT +..B2.62: + addl $16, %esp + fstpt 168(%esp) + fldt 156(%esp) + fldt 168(%esp) + fdivrp %st, %st(1) + fstpt 72(%esp) + fldt 120(%esp) + addl $-16, %esp + fmull 36(%ebp) + fstpt (%esp) + call cosl@PLT +..B2.61: + addl $16, %esp + fstpt 132(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call cosdl@PLT +..B2.60: + addl $16, %esp + fstpt 84(%esp) + fldt 120(%esp) + addl $-16, %esp + fmull 36(%ebp) + fstpt (%esp) + call sinl@PLT +..B2.59: + addl $16, %esp + fstpt 144(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call sindl@PLT +..B2.58: + addl $16, %esp + fstpt 96(%esp) + fldt 132(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + fldt 144(%esp) + fldt 96(%esp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt 180(%esp) + fldt 144(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + fldt 96(%esp) + fldt 132(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 192(%esp) + fldt 180(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 208(%esp) + fldt 192(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 216(%esp) + jmp ..B2.14 +..B2.24: + fxch %st(1) + fstpl 208(%esp) + fstpl 216(%esp) + jmp ..B2.14 +..B2.25: + fldl 36(%ebp) + fucomp %st(2) + fnstsw %ax + sahf + jne ..B2.11 + jp ..B2.11 +..B2.26: + fstp %st(0) + fstp %st(0) + fldl 12(%ebp) + fstpt 36(%esp) + fstpt 48(%esp) + fldt 36(%esp) + fldt 36(%esp) + fmulp %st, %st(1) + fldt 48(%esp) + fldt 48(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B2.69: + addl $16, %esp + fstpt 120(%esp) + fldt 48(%esp) + fldt 36(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2l@PLT +..B2.68: + addl $32, %esp + fstpt 60(%esp) + fldt 120(%esp) + fldt 60(%esp) + addl $-16, %esp + faddp %st, %st(1) + fstpt (%esp) + call sinl@PLT +..B2.67: + fldl ZEROA@GOTOFF(%ebx) + fld1 + addl $16, %esp + fstpl 208(%esp) + addl $-16, %esp + fstpl (%esp) + fstpl 8(%esp) + call copysign@PLT +..B2.66: + addl $16, %esp + fstpl 216(%esp) + jmp ..B2.14 +..B2.27: + fldl 36(%ebp) + fucomp %st(1) + fnstsw %ax + sahf + jne ..B2.10 + jp ..B2.10 +..B2.28: + fldl 12(%ebp) + fxch %st(1) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.30 +..B2.29: + fstpt 36(%esp) + fldt 36(%esp) + fchs + fstpt 12(%esp) + fstpt 48(%esp) + fldt 48(%esp) + fldt 36(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2dl@PLT +..B2.73: + fldl 28(%ebp) + addl $32, %esp + fxch %st(1) + fstpt 60(%esp) + fldt 12(%esp) + addl $-32, %esp + fstpt (%esp) + fstpt 12(%esp) + call powl@PLT +..B2.72: + addl $32, %esp + fstpt 72(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call cosdl@PLT +..B2.71: + addl $16, %esp + fstpt 84(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call sindl@PLT +..B2.70: + addl $16, %esp + fstpt 96(%esp) + fldt 72(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + fstpl 208(%esp) + fldt 72(%esp) + fldt 96(%esp) + fmulp %st, %st(1) + fstpl 216(%esp) + jmp ..B2.14 +..B2.30: + fldl 28(%ebp) + addl $-16, %esp + fstpl 8(%esp) + fstpl (%esp) + fstpl 16(%esp) + call pow@PLT +..B2.74: + fldl 16(%esp) + addl $16, %esp + fstpl 216(%esp) + fstpl 208(%esp) + jmp ..B2.14 +..B2.31: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnzfinite +..B2.75: + addl $16, %esp +..B2.32: + testl %eax, %eax + je ..B2.9 +..B2.33: + fldl 28(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnzfinite +..B2.76: + addl $16, %esp +..B2.34: + testl %eax, %eax + je ..B2.9 +..B2.35: + fldl 36(%ebp) + addl $-16, %esp + fstpl (%esp) + call __libm_internal_isnzfinite +..B2.77: + addl $16, %esp +..B2.36: + testl %eax, %eax + je ..B2.9 +..B2.37: + fldl 12(%ebp) + fstpt 36(%esp) + fldl 20(%ebp) + fstpt 48(%esp) + fldt 36(%esp) + fldt 36(%esp) + fmulp %st, %st(1) + fldt 48(%esp) + fldt 48(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 108(%esp) + fldt 108(%esp) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B2.85: + addl $16, %esp + fstpt 120(%esp) + fldt 48(%esp) + fldt 36(%esp) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + call atan2dl@PLT +..B2.84: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + addl $32, %esp + fstpt (%esp) + fldt (%esp) + fxch %st(1) + fstpt 60(%esp) + fldt 120(%esp) + addl $-16, %esp + fldl 28(%ebp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%esp) + call expl@PLT +..B2.83: + fldt _LD_PI_DIV_180@GOTOFF(%ebx) + addl $16, %esp + fxch %st(1) + fstpt 156(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 36(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + call expl@PLT +..B2.82: + fldl 36(%ebp) + addl $16, %esp + fxch %st(1) + fstpt 168(%esp) + fldt 156(%esp) + fldt 168(%esp) + fdivrp %st, %st(1) + fstpt 72(%esp) + fldt 120(%esp) + addl $-16, %esp + fldt 16(%esp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%esp) + call cosl@PLT +..B2.81: + addl $16, %esp + fstpt 132(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call cosdl@PLT +..B2.80: + addl $16, %esp + fstpt 84(%esp) + fldt 120(%esp) + addl $-16, %esp + fldt 16(%esp) + fmull 36(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + call sinl@PLT +..B2.79: + addl $16, %esp + fstpt 144(%esp) + fldt 60(%esp) + addl $-16, %esp + fmull 28(%ebp) + fstpt (%esp) + call sindl@PLT +..B2.78: + addl $16, %esp + fstpt 96(%esp) + fldt 132(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + fldt 144(%esp) + fldt 96(%esp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt 180(%esp) + fldt 144(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + fldt 96(%esp) + fldt 132(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 192(%esp) + fldt 180(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 208(%esp) + fldt 192(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + fstpl 216(%esp) + jmp ..B2.14 +..B2.38: + xorl %esi, %esi + jmp ..B2.7 + .align 16,0x90 + .type cpow,@function + .size cpow,.-cpow + .data +# -- End cpow + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +ZEROA: + .long 0 + .long 0 + .type ZEROA,@object + .size ZEROA,8 + .space 8, 0x00 # pad + .align 16 +_LD_PI_DIV_180: + .word 51374 + .word 38121 + .word 13586 + .word 36602 + .word 16377 + .word 0 + .type _LD_PI_DIV_180,@object + .size _LD_PI_DIV_180,12 + .space 4, 0x00 # pad + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .hidden __libm_internal_isnzfinite + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cpowl.S b/external/sgx_libm/ia32/cpowl.S new file mode 100644 index 0000000000..232f82c9a2 --- /dev/null +++ b/external/sgx_libm/ia32/cpowl.S @@ -0,0 +1,190 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cpowl.c" + .text +..TXTST0: +# -- Begin cpowl + .text + .align 16,0x90 + .globl cpowl +cpowl: +# parameter 1: 12 + %ebp +# parameter 2: 36 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $104, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %eax + xorl %esp, %eax + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + movl %eax, 100(%esp) + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) +..B1.2: + fnstcw 2(%esp) +..B1.3: + movzwl 2(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.12 +..B1.4: + orl $-64768, %edx + movw %dx, (%esp) +..B1.5: + fldcw (%esp) +..B1.6: + movl $1, %esi +..B1.7: + addl $-32, %esp + movl 12(%ebp), %ecx + lea 60(%esp), %edx + movl %edx, (%esp) + lea 4(%esp), %eax + movl 16(%ebp), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 20(%ebp), %ecx + movl 24(%ebp), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + movl 28(%ebp), %ecx + movl 32(%ebp), %edx + movl %ecx, 16(%eax) + movl %edx, 20(%eax) + call clogl@PLT +..B1.16: + fldt 36(%ebp) + addl $28, %esp + fld %st(0) + fldt 48(%ebp) + fld %st(0) + fldt 28(%esp) + fmul %st, %st(3) + fmulp %st, %st(2) + fldt 40(%esp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(2) + fstpt 76(%esp) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 88(%esp) + addl $-32, %esp + movl 108(%esp), %ecx + lea 84(%esp), %edx + movl %edx, (%esp) + lea 4(%esp), %eax + movl 28(%edx), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 116(%esp), %ecx + movl 120(%esp), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + movl 124(%esp), %ecx + movl 128(%esp), %edx + movl %ecx, 16(%eax) + movl %edx, 20(%eax) + call cexpl@PLT +..B1.15: + addl $28, %esp + fldt 52(%esp) + testl %esi, %esi + fstpt 4(%esp) + fldt 64(%esp) + fstpt 16(%esp) + je ..B1.9 +..B1.8: + fldcw 2(%esp) +..B1.9: + movl 8(%ebp), %eax + movl 4(%esp), %edx + movl 8(%esp), %ecx + movl 12(%esp), %esi + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl %esi, 8(%eax) + movl 16(%esp), %edx + movl 20(%esp), %ecx + movl 24(%esp), %esi + movl %edx, 12(%eax) + movl %ecx, 16(%eax) + movl %esi, 20(%eax) + movl 100(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.11 +..B1.10: + addl $104, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.11: + call __stack_chk_fail@PLT +..B1.12: + xorl %esi, %esi + jmp ..B1.7 + .align 16,0x90 + .type cpowl,@function + .size cpowl,.-cpowl + .data +# -- End cpowl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cproj.S b/external/sgx_libm/ia32/cproj.S new file mode 100644 index 0000000000..1cff21c17e --- /dev/null +++ b/external/sgx_libm/ia32/cproj.S @@ -0,0 +1,164 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cproj.c" + .text +..TXTST0: +# -- Begin cproj + .text + .align 16,0x90 + .globl cproj +cproj: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp + fldz + movl %gs:20, %ecx + movl 8(%ebp), %eax + xorl %esp, %ecx + movl %ecx, 16(%esp) + movzwl 18(%ebp), %ecx + andl $32752, %ecx + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $32752, %ecx + je ..B1.15 +..B1.2: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + cmpl $32752, %ecx + je ..B1.6 +..B1.3: + fstp %st(0) + movl 12(%ebp), %ecx + movl %ecx, (%eax) + movl 16(%ebp), %ecx + movl %ecx, 4(%eax) + movl 20(%ebp), %ecx + movl %ecx, 8(%eax) + movl 24(%ebp), %ecx + movl %ecx, 12(%eax) + movl 16(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.5 +..B1.4: + movl %ebp, %esp + popl %ebp + ret $4 +..B1.5: + movl %edx, %ebx + call __stack_chk_fail@PLT +..B1.6: + testl $1048575, 24(%ebp) + jne ..B1.3 +..B1.7: + cmpl $0, 20(%ebp) + jne ..B1.3 +..B1.8: + fstl 8(%esp) + fstpl (%esp) +..B1.9: + fldl DBL_PINFA@GOTOFF(%edx) + movzbl 27(%ebp), %ecx + testl $128, %ecx + fstpl (%esp) + je ..B1.11 +..B1.10: + fldl DBL_NZEROA@GOTOFF(%edx) + fstpl 8(%esp) + jmp ..B1.12 +..B1.11: + fldl DBL_PZEROA@GOTOFF(%edx) + fstpl 8(%esp) +..B1.12: + movl (%esp), %ecx + movl %ecx, (%eax) + movl 4(%esp), %ecx + movl %ecx, 4(%eax) + movl 8(%esp), %ecx + movl %ecx, 8(%eax) + movl 12(%esp), %ecx + movl %ecx, 12(%eax) + movl 16(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.5 + jmp ..B1.4 +..B1.15: + testl $1048575, 16(%ebp) + jne ..B1.2 +..B1.16: + cmpl $0, 12(%ebp) + je ..B1.8 + jmp ..B1.2 + .align 16,0x90 + .type cproj,@function + .size cproj,.-cproj + .data +# -- End cproj + .section .rodata, "a" + .align 16 + .align 16 +DBL_PINFA: + .long 0 + .long 2146435072 + .type DBL_PINFA,@object + .size DBL_PINFA,8 + .space 8, 0x00 # pad + .align 16 +DBL_NZEROA: + .long 0 + .long 2147483648 + .type DBL_NZEROA,@object + .size DBL_NZEROA,8 + .space 8, 0x00 # pad + .align 16 +DBL_PZEROA: + .long 0 + .long 0 + .type DBL_PZEROA,@object + .size DBL_PZEROA,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cprojf.S b/external/sgx_libm/ia32/cprojf.S new file mode 100644 index 0000000000..7ad2437823 --- /dev/null +++ b/external/sgx_libm/ia32/cprojf.S @@ -0,0 +1,110 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cprojf.c" + .text +..TXTST0: +# -- Begin cprojf + .text + .align 16,0x90 + .globl cprojf +cprojf: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movzwl 18(%esp), %eax + andl $32640, %eax + cmpl $32640, %eax + je ..B1.10 +..B1.2: + movzwl 22(%esp), %eax + andl $32640, %eax + cmpl $32640, %eax + je ..B1.4 +..B1.3: + movl 16(%esp), %eax + movl 20(%esp), %edx + addl $12, %esp + ret +..B1.4: + testl $8388607, 20(%esp) + jne ..B1.3 +..B1.5: + xorl %eax, %eax + movl %eax, 4(%esp) + movl %eax, (%esp) +..B1.6: + movzbl 23(%esp), %eax + testl $128, %eax + movl $2139095040, (%esp) + je ..B1.8 +..B1.7: + movl $-2147483648, 4(%esp) + jmp ..B1.9 +..B1.8: + xorl %eax, %eax + movl %eax, 4(%esp) +..B1.9: + movl (%esp), %eax + movl 4(%esp), %edx + addl $12, %esp + ret +..B1.10: + testl $8388607, 16(%esp) + je ..B1.5 + jmp ..B1.2 + .align 16,0x90 + .type cprojf,@function + .size cprojf,.-cprojf + .data +# -- End cprojf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.5: + .long 0x7f800000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,4 + .align 4 +.L_2il0floatpacket.6: + .long 0x80000000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/cprojl.S b/external/sgx_libm/ia32/cprojl.S new file mode 100644 index 0000000000..f04c70da83 --- /dev/null +++ b/external/sgx_libm/ia32/cprojl.S @@ -0,0 +1,155 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cprojl.c" + .text +..TXTST0: +# -- Begin cprojl + .text + .align 16,0x90 + .globl cprojl +cprojl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %ebx + subl $28, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movzwl 20(%ebp), %ecx + andl $32767, %ecx + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + movl %gs:20, %edx + movl 8(%ebp), %eax + xorl %esp, %edx + movl %edx, 24(%esp) + cmpl $32767, %ecx + movzbl 9+.L_2il0floatpacket.7@GOTOFF(%ebx), %edx + je ..B1.11 +..B1.2: + movzwl 32(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.7 +..B1.3: + fstp %st(0) + fldt 12(%ebp) + fstpt (%esp) + fldt 24(%ebp) + fstpt 12(%esp) +..B1.4: + movl (%esp), %edx + movl 4(%esp), %ecx + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 8(%esp), %edx + movl 12(%esp), %ecx + movl %edx, 8(%eax) + movl %ecx, 12(%eax) + movl 16(%esp), %edx + movl 20(%esp), %ecx + movl %edx, 16(%eax) + movl %ecx, 20(%eax) + movl 24(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.6 +..B1.5: + addl $28, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret $4 +..B1.6: + call __stack_chk_fail@PLT +..B1.7: + cmpl $-2147483648, 28(%ebp) + jne ..B1.3 +..B1.8: + cmpl $0, 24(%ebp) + jne ..B1.3 +..B1.9: + fstpt 12(%esp) + fldt 12(%esp) + fstpt (%esp) + fldt (%esp) +..B1.10: + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + andl $127, %edx + movzwl 8+.L_2il0floatpacket.8@GOTOFF(%ebx), %ecx + fstpt (%esp) + orl $-32769, %ecx + movw %cx, 8(%esp) + movzbl 33(%ebp), %ecx + andl $-128, %ecx + fstpt 12(%esp) + orl %ecx, %edx + movb %dl, 21(%esp) + jmp ..B1.4 +..B1.11: + cmpl $-2147483648, 16(%ebp) + jne ..B1.2 +..B1.12: + cmpl $0, 12(%ebp) + je ..B1.9 + jmp ..B1.2 + .align 16,0x90 + .type cprojl,@function + .size cprojl,.-cprojl + .data +# -- End cprojl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/creal.S b/external/sgx_libm/ia32/creal.S new file mode 100644 index 0000000000..4cea6579ee --- /dev/null +++ b/external/sgx_libm/ia32/creal.S @@ -0,0 +1,58 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "creal.c" + .text +..TXTST0: +# -- Begin creal + .text + .align 16,0x90 + .globl creal +creal: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + fldl 4(%esp) + ret + .align 16,0x90 + .type creal,@function + .size creal,.-creal + .data +# -- End creal + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/crealf.S b/external/sgx_libm/ia32/crealf.S new file mode 100644 index 0000000000..263d39c9ac --- /dev/null +++ b/external/sgx_libm/ia32/crealf.S @@ -0,0 +1,58 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "crealf.c" + .text +..TXTST0: +# -- Begin crealf + .text + .align 16,0x90 + .globl crealf +crealf: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + flds 4(%esp) + ret + .align 16,0x90 + .type crealf,@function + .size crealf,.-crealf + .data +# -- End crealf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/creall.S b/external/sgx_libm/ia32/creall.S new file mode 100644 index 0000000000..a9c3e1b82f --- /dev/null +++ b/external/sgx_libm/ia32/creall.S @@ -0,0 +1,58 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "creall.c" + .text +..TXTST0: +# -- Begin creall + .text + .align 16,0x90 + .globl creall +creall: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + fldt 4(%esp) + ret + .align 16,0x90 + .type creall,@function + .size creall,.-creall + .data +# -- End creall + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csin.S b/external/sgx_libm/ia32/csin.S new file mode 100644 index 0000000000..2d9cb57967 --- /dev/null +++ b/external/sgx_libm/ia32/csin.S @@ -0,0 +1,237 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csin.c" + .text +..TXTST0: +# -- Begin csin + .text + .align 16,0x90 + .globl csin +csin: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $72, %esp + fldz + fldl 20(%ebp) + fldl 12(%ebp) + movzwl 26(%ebp), %ecx + andl $32752, %ecx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 64(%esp) + cmpl $32752, %ecx + fstpl 56(%esp) + fxch %st(1) + fstl 16(%esp) + fstl 24(%esp) + fstl 32(%esp) + fstpl 40(%esp) + fstpl 48(%esp) + jl ..B1.4 +..B1.2: + testl $1048575, 24(%ebp) + jne ..B1.5 +..B1.3: + cmpl $0, 20(%ebp) + jne ..B1.5 +..B1.4: + movzbl 27(%ebp), %edx + notl %edx + movzbl 55(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 55(%esp) +..B1.5: + addl $-32, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea 32(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl 48(%ecx), %ecx + movl %ecx, (%edx) + movl 84(%esp), %ecx + movl %ecx, 4(%edx) + movl 88(%esp), %ecx + movl %ecx, 8(%edx) + movl 92(%esp), %ecx + movl %ecx, 12(%edx) + call csinh@PLT +..B1.14: + addl $28, %esp + fldl (%esp) + movzwl 6(%esp), %edx + andl $32752, %edx + fstl 16(%esp) + cmpl $32752, %edx + fstpl 40(%esp) + fldl 8(%esp) + fstl 24(%esp) + fstpl 32(%esp) + jl ..B1.8 +..B1.6: + testl $1048575, 20(%esp) + jne ..B1.9 +..B1.7: + cmpl $0, 16(%esp) + jne ..B1.9 +..B1.8: + movzbl 23(%esp), %edx + notl %edx + movzbl 47(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 47(%esp) +..B1.9: + movl 32(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 8(%esi) + movl 36(%esp), %ecx + movl 44(%esp), %edx + movl %ecx, 4(%esi) + movl %edx, 12(%esi) + movl 64(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.11 +..B1.10: + movl %esi, %eax + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.11: + call __stack_chk_fail@PLT + .align 16,0x90 + .type csin,@function + .size csin,.-csin + .data +# -- End csin + .text +# -- Begin csinf + .text + .align 16,0x90 + .globl csinf +csinf: +# parameter 1: 48 + %esp +..B2.1: +..L3: + + pushl %ebx + subl $40, %esp + xorl %eax, %eax + movl %eax, 16(%esp) + movl %eax, 20(%esp) + movl %eax, 24(%esp) + movl %eax, 28(%esp) + movzwl 54(%esp), %eax + andl $32640, %eax + movl 52(%esp), %edx + cmpl $32640, %eax + movl 48(%esp), %ecx + movl %edx, 32(%esp) + movl %ecx, 36(%esp) + jl ..B2.3 +..B2.2: + testl $8388607, 52(%esp) + jne ..B2.4 +..B2.3: + movzbl 55(%esp), %eax + notl %eax + movzbl 35(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 35(%esp) +..B2.4: + addl $8, %esp + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + pushl 28(%esp) + pushl 28(%esp) + call csinhf@PLT +..B2.10: + movl %eax, 16(%esp) + movl %eax, 28(%esp) + shrl $16, %eax + andl $32640, %eax + cmpl $32640, %eax + movl %edx, 20(%esp) + movl %edx, 24(%esp) + jl ..B2.6 +..B2.5: + testl $8388607, 16(%esp) + jne ..B2.7 +..B2.6: + movzbl 19(%esp), %eax + notl %eax + movzbl 31(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 31(%esp) +..B2.7: + movl 24(%esp), %eax + movl 28(%esp), %edx + addl $40, %esp + popl %ebx + ret + .align 16,0x90 + .type csinf,@function + .size csinf,.-csinf + .data +# -- End csinf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csinh.S b/external/sgx_libm/ia32/csinh.S new file mode 100644 index 0000000000..ff2ae257ef --- /dev/null +++ b/external/sgx_libm/ia32/csinh.S @@ -0,0 +1,408 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csinh.c" + .text +..TXTST0: +# -- Begin csinh + .text + .align 16,0x90 + .globl csinh +csinh: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 88(%esp) + fstl 72(%esp) + fstpl 80(%esp) +..B1.2: + fnstcw 62(%esp) +..B1.3: + movzwl 18(%ebp), %esi + andl $32752, %esi + shrl $4, %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %esi + jge ..B1.19 +..B1.4: + testl %esi, %esi + jle ..B1.56 +..B1.5: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + jge ..B1.20 +..B1.6: + testl %ecx, %ecx + jle ..B1.54 +..B1.7: + cmpl $1034, %esi + jl ..B1.11 +..B1.8: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 8(%esp) + fldl 20(%ebp) + fstl (%esp) + addl $-16, %esp + fstpl (%esp) + movl %ecx, 32(%esp) + call cos@PLT +..B1.62: + movl 32(%esp), %ecx + addl $16, %esp + testl %ecx, %ecx + fmull 8(%esp) + fmull 12(%ebp) + fstpl 72(%esp) + jle ..B1.10 +..B1.9: + addl $-16, %esp + fldl 16(%esp) + fstpl (%esp) + call sin@PLT +..B1.63: + addl $16, %esp + fldl 8(%esp) + fmulp %st, %st(1) + fstpl 80(%esp) + jmp ..B1.44 +..B1.10: + fldl 8(%esp) + fmull (%esp) + fstpl 80(%esp) + jmp ..B1.44 +..B1.11: + movzwl 62(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.53 +..B1.12: + orl $-64768, %ecx + movw %cx, 60(%esp) +..B1.13: + fldcw 60(%esp) +..B1.14: + movl $1, 56(%esp) +..B1.15: + fldl 12(%ebp) + fstpl 48(%esp) + addl $-32, %esp + fldl 20(%ebp) + lea 32(%esp), %edx + lea 44(%esp), %ecx + fstpt (%esp) + movl %edx, 12(%esp) + movl %ecx, 16(%esp) + call sincosl@PLT +..B1.16: + fldl 80(%esp) + lea 56(%esp), %edx + lea 68(%esp), %ecx + fstpt (%esp) + movl %edx, 12(%esp) + movl %ecx, 16(%esp) + call sinhcoshl@PLT +..B1.65: + addl $32, %esp +..B1.17: + fldt 24(%esp) + fldt 12(%esp) + fmulp %st, %st(1) + fstpl 72(%esp) + fldt 36(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpl 80(%esp) + cmpl $0, 56(%esp) + je ..B1.44 +..B1.18: + fldcw 62(%esp) + jmp ..B1.44 +..B1.19: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx +..B1.20: + testl %ecx, %ecx + jne ..B1.24 +..B1.21: + testl $1048575, 24(%ebp) + jne ..B1.24 +..B1.22: + cmpl $0, 20(%ebp) + jne ..B1.24 +..B1.23: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call sinh@PLT +..B1.66: + fldl 20(%ebp) + addl $16, %esp + fstpl 80(%esp) + fstpl 72(%esp) + jmp ..B1.44 +..B1.24: + cmpl $2047, %ecx + jge ..B1.38 +..B1.25: + movl 16(%ebp), %edx + andl $1048575, %edx + testl %esi, %esi + jne ..B1.32 +..B1.26: + testl %edx, %edx + jne ..B1.37 +..B1.27: + cmpl $0, 12(%ebp) + jne ..B1.33 +..B1.28: + fldl 20(%ebp) + addl $-16, %esp + fstl (%esp) + fstpl 16(%esp) + movl %ecx, 32(%esp) + call cos@PLT +..B1.67: + fldl 16(%esp) + fxch %st(1) + fmull 12(%ebp) + movl 32(%esp), %ecx + addl $16, %esp + fstpl 72(%esp) + testl %ecx, %ecx + jle ..B1.31 +..B1.29: + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.68: + addl $16, %esp +..B1.31: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fxch %st(1) + fstpl 80(%esp) + fsubl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fstpl 64(%esp) + jmp ..B1.44 +..B1.32: + testl %edx, %edx + jne ..B1.37 +..B1.73: + cmpl $0, 12(%ebp) +..B1.33: + jne ..B1.37 +..B1.34: + fldl 12(%ebp) + cmpl $1023, %ecx + fstl 16(%esp) + fmul %st(0), %st + fstpl 24(%esp) + jge ..B1.36 +..B1.35: + fldl 16(%esp) + fstpl 72(%esp) + fldl 24(%esp) + fmull 20(%ebp) + fstpl 80(%esp) + jmp ..B1.44 +..B1.36: + fldl 20(%ebp) + fstl 8(%esp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.70: + addl $16, %esp + fstpl (%esp) + addl $-16, %esp + fldl 24(%esp) + fstpl (%esp) + call cos@PLT +..B1.69: + addl $16, %esp + fldl 16(%esp) + fmulp %st, %st(1) + fstpl 72(%esp) + fldl 24(%esp) + fmull (%esp) + fstpl 80(%esp) + jmp ..B1.44 +..B1.37: + fldl 12(%ebp) + fmul %st(0), %st + fstl 72(%esp) + fstpl 80(%esp) + jmp ..B1.44 +..B1.38: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.71: + addl $16, %esp + fstl 80(%esp) + cmpl $2047, %esi + je ..B1.42 +..B1.39: + testl %esi, %esi + jne ..B1.43 +..B1.40: + testl $1048575, 16(%ebp) + jne ..B1.43 +..B1.41: + cmpl $0, 12(%ebp) + jne ..B1.43 +..B1.42: + fstp %st(0) + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call sinh@PLT +..B1.72: + addl $16, %esp + fstpl 72(%esp) + jmp ..B1.44 +..B1.43: + fldl 12(%ebp) + fmulp %st, %st(1) + fstpl 72(%esp) +..B1.44: + movzwl 78(%esp), %edx + testl $32752, %edx + jne ..B1.47 +..B1.45: + testl $1048575, 76(%esp) + jne ..B1.50 +..B1.46: + cmpl $0, 72(%esp) + jne ..B1.50 +..B1.47: + movzwl 86(%esp), %edx + testl $32752, %edx + jne ..B1.51 +..B1.48: + testl $1048575, 84(%esp) + jne ..B1.50 +..B1.49: + cmpl $0, 80(%esp) + je ..B1.51 +..B1.50: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 64(%esp) +..B1.51: + movl 72(%esp), %edx + movl %edx, (%edi) + movl 76(%esp), %ecx + movl 80(%esp), %esi + movl 84(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 88(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.59 +..B1.52: + movl %edi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.53: + movl $0, 56(%esp) + jmp ..B1.15 +..B1.54: + testl $1048575, 24(%ebp) + jne ..B1.7 +..B1.55: + cmpl $0, 20(%ebp) + jne ..B1.7 + jmp ..B1.20 +..B1.56: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.57: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.19 +..B1.59: + call __stack_chk_fail@PLT + .align 16,0x90 + .type csinh,@function + .size csinh,.-csinh + .data +# -- End csinh + .section .rodata, "a" + .align 16 + .align 16 +_DBL_MAX_NORMAL: + .long -1 + .long 2146435071 + .type _DBL_MAX_NORMAL,@object + .size _DBL_MAX_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csinhf.S b/external/sgx_libm/ia32/csinhf.S new file mode 100644 index 0000000000..e646fcc0d2 --- /dev/null +++ b/external/sgx_libm/ia32/csinhf.S @@ -0,0 +1,368 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csinhf.c" + .text +..TXTST0: +# -- Begin csinhf + .text + .align 16,0x90 + .globl csinhf +csinhf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + xorl %ecx, %ecx + movl %ecx, 48(%esp) + movl %ecx, 52(%esp) +..B1.2: + fnstcw 38(%esp) +..B1.3: + movzwl 10(%ebp), %esi + andl $32640, %esi + shrl $7, %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %esi + jge ..B1.18 +..B1.4: + testl %esi, %esi + jle ..B1.47 +..B1.5: + movzwl 14(%ebp), %edi + andl $32640, %edi + shrl $7, %edi + cmpl $255, %edi + jge ..B1.19 +..B1.6: + testl %edi, %edi + jle ..B1.46 +..B1.7: + cmpl $138, %esi + jl ..B1.11 +..B1.8: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl (%esp) + flds 12(%ebp) + fsts 8(%esp) + addl $-16, %esp + fstps (%esp) + call cosf@PLT +..B1.51: + addl $16, %esp + fmull (%esp) + testl %edi, %edi + fmuls 8(%ebp) + fstps 48(%esp) + jle ..B1.10 +..B1.9: + addl $-16, %esp + flds 24(%esp) + fstps (%esp) + call sinf@PLT +..B1.52: + addl $16, %esp + fldl (%esp) + fmulp %st, %st(1) + fstps 52(%esp) + jmp ..B1.39 +..B1.10: + fldl (%esp) + fmuls 8(%esp) + fstps 52(%esp) + jmp ..B1.39 +..B1.11: + movzwl 38(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.12: + orl $-64768, %edx + movw %dx, 36(%esp) +..B1.13: + fldcw 36(%esp) +..B1.14: + movl $1, %esi +..B1.15: + flds 8(%ebp) + fstps 32(%esp) + flds 12(%ebp) + fsts 24(%esp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.55: + addl $16, %esp + fstpl 16(%esp) + addl $-16, %esp + flds 40(%esp) + fstpl (%esp) + call cos@PLT +..B1.54: + addl $16, %esp + fstpl 24(%esp) + addl $-16, %esp + flds 48(%esp) + lea 16(%esp), %eax + lea 24(%esp), %edx + fstpl (%esp) + movl %eax, 8(%esp) + movl %edx, 12(%esp) + call sinhcosh@PLT +..B1.53: + addl $16, %esp +..B1.16: + fldl (%esp) + testl %esi, %esi + fmull 24(%esp) + fstps 48(%esp) + fldl 8(%esp) + fmull 16(%esp) + fstps 52(%esp) + je ..B1.39 +..B1.17: + fldcw 38(%esp) + jmp ..B1.39 +..B1.18: + movzwl 14(%ebp), %edi + andl $32640, %edi + shrl $7, %edi +..B1.19: + testl %edi, %edi + jne ..B1.22 +..B1.20: + testl $8388607, 12(%ebp) + jne ..B1.22 +..B1.21: + addl $-16, %esp + movl 8(%ebp), %eax + movl %eax, (%esp) + call sinhf@PLT +..B1.56: + movl 12(%ebp), %eax + addl $16, %esp + fstps 48(%esp) + movl %eax, 52(%esp) + jmp ..B1.39 +..B1.22: + cmpl $255, %edi + jge ..B1.34 +..B1.23: + movl 8(%ebp), %eax + andl $8388607, %eax + testl %esi, %esi + jne ..B1.63 +..B1.24: + testl %eax, %eax + jne ..B1.29 +..B1.25: + flds 12(%ebp) + addl $-16, %esp + fsts (%esp) + fstps 16(%esp) + call cosf@PLT +..B1.57: + flds 16(%esp) + addl $16, %esp + fxch %st(1) + fmuls 8(%ebp) + testl %edi, %edi + fstps 48(%esp) + jle ..B1.28 +..B1.26: + addl $-16, %esp + fstps (%esp) + call sinf@PLT +..B1.58: + addl $16, %esp +..B1.28: + fldl _DBL_MAX_NORMAL@GOTOFF(%ebx) + fxch %st(1) + fstps 52(%esp) + fsubl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fstpl 40(%esp) + jmp ..B1.39 +..B1.63: + testl %eax, %eax +..B1.29: + flds 8(%ebp) + jne ..B1.33 +..B1.30: + fld %st(0) + cmpl $127, %edi + fmul %st(1), %st + fstps 8(%esp) + jge ..B1.32 +..B1.31: + flds 8(%esp) + fxch %st(1) + fstps 48(%esp) + fmuls 12(%ebp) + fstps 52(%esp) + jmp ..B1.39 +..B1.32: + addl $-16, %esp + movl 12(%ebp), %esi + movl %esi, (%esp) + fstps 20(%esp) + call sinf@PLT +..B1.60: + flds 20(%esp) + addl $16, %esp + fxch %st(1) + fstps (%esp) + addl $-16, %esp + movl %esi, (%esp) + fstps 20(%esp) + call cosf@PLT +..B1.59: + flds 20(%esp) + addl $16, %esp + fmulp %st, %st(1) + fstps 48(%esp) + flds 8(%esp) + fmuls (%esp) + fstps 52(%esp) + jmp ..B1.39 +..B1.33: + fmul %st(0), %st + fsts 48(%esp) + fstps 52(%esp) + jmp ..B1.39 +..B1.34: + addl $-16, %esp + movl 12(%ebp), %eax + movl %eax, (%esp) + call sinf@PLT +..B1.61: + addl $16, %esp + fsts 52(%esp) + cmpl $255, %esi + je ..B1.37 +..B1.35: + testl %esi, %esi + jne ..B1.38 +..B1.36: + testl $8388607, 8(%ebp) + jne ..B1.38 +..B1.37: + fstp %st(0) + addl $-16, %esp + movl 8(%ebp), %eax + movl %eax, (%esp) + call sinhf@PLT +..B1.62: + addl $16, %esp + fstps 48(%esp) + jmp ..B1.39 +..B1.38: + flds 8(%ebp) + fmulp %st, %st(1) + fstps 48(%esp) +..B1.39: + movzwl 50(%esp), %eax + testl $32640, %eax + jne ..B1.41 +..B1.40: + testl $8388607, 48(%esp) + jne ..B1.43 +..B1.41: + movzwl 54(%esp), %eax + testl $32640, %eax + jne ..B1.44 +..B1.42: + testl $8388607, 52(%esp) + je ..B1.44 +..B1.43: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 40(%esp) +..B1.44: + movl 48(%esp), %eax + movl 52(%esp), %edx + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + movl %ecx, %esi + jmp ..B1.15 +..B1.46: + testl $8388607, 12(%ebp) + jne ..B1.7 + jmp ..B1.19 +..B1.47: + testl $8388607, 8(%ebp) + jne ..B1.5 + jmp ..B1.18 + .align 16,0x90 + .type csinhf,@function + .size csinhf,.-csinhf + .data +# -- End csinhf + .section .rodata, "a" + .align 16 + .align 16 +_DBL_MAX_NORMAL: + .long -1 + .long 2146435071 + .type _DBL_MAX_NORMAL,@object + .size _DBL_MAX_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csinhl.S b/external/sgx_libm/ia32/csinhl.S new file mode 100644 index 0000000000..9a215bb5b3 --- /dev/null +++ b/external/sgx_libm/ia32/csinhl.S @@ -0,0 +1,655 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csinhl.c" + .text +..TXTST0: +# -- Begin csinhl + .text + .align 16,0x90 + .globl csinhl +csinhl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $308, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + movl %edx, 244(%esp) + fstpt 112(%esp) + fldt 112(%esp) + fstpt 220(%esp) + fldt 220(%esp) + fstpt 232(%esp) +..B1.2: + fnstcw 62(%esp) +..B1.3: + movzwl 62(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.59 +..B1.4: + orl $-64768, %ecx + movw %cx, 60(%esp) +..B1.5: + fldcw 60(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.33 +..B1.8: + testl %edx, %edx + jle ..B1.52 +..B1.9: + movzwl 32(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.33 +..B1.10: + testl %ecx, %ecx + jle ..B1.50 +..B1.11: + cmpl $16398, %edx + jl ..B1.19 +..B1.12: + fldt _CONSTANTS@GOTOFF(%ebx) + fmul %st(0), %st + fldt 12(%ebp) + fmul %st(1), %st + fstpt (%esp) + fldt 24(%ebp) + fstpt 16(%esp) + fldt 16(%esp) + addl $-16, %esp + fstpt (%esp) + fstpt 48(%esp) + movl %ecx, 28(%esp) + call cosl@PLT +..B1.62: + fldt 48(%esp) + movl 28(%esp), %ecx + addl $16, %esp + fldt (%esp) + testl %ecx, %ecx + fmulp %st, %st(2) + fxch %st(1) + fstpt 220(%esp) + jle ..B1.14 +..B1.13: + addl $-16, %esp + fldt 32(%esp) + fstpt (%esp) + fstpt 48(%esp) + call sinl@PLT +..B1.63: + fldt 48(%esp) + addl $16, %esp + fmulp %st, %st(1) + jmp ..B1.15 +..B1.14: + fldt 16(%esp) + fmulp %st, %st(1) +..B1.15: + fstpt 232(%esp) + testl %edi, %edi + je ..B1.17 +..B1.16: + fldcw 62(%esp) +..B1.17: + movl 220(%esp), %edx + movl %edx, (%esi) + movl 232(%esp), %edx + movl %edx, 12(%esi) + movl 236(%esp), %edx + movl %edx, 16(%esi) + movl 224(%esp), %ecx + movl 228(%esp), %edi + movl 240(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 244(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.49 +..B1.18: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.19: + fldt 12(%ebp) + addl $-16, %esp + lea 164(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + call __libm_coshl_k80 +..B1.64: + addl $16, %esp +..B1.20: + fldt 36+_CONSTANTS@GOTOFF(%ebx) + movzwl 20(%ebp), %ecx + fadd %st, %st(1) + fxch %st(1) + fstpt (%esp) + andl $32767, %ecx + fldt 148(%esp) + cmpl $16183, %ecx + fld %st(0) + fldt 160(%esp) + movl (%esp), %edx + fadd %st, %st(1) + fld %st(1) + fxch %st(2) + fsub %st, %st(3) + movl %edx, 28(%esp) + fxch %st(3) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + fsub %st, %st(3) + fsubp %st, %st(3) + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(3) + faddp %st, %st(2) + jge ..B1.22 +..B1.21: + fstp %st(2) + fldt 12(%ebp) + lea 184(%esp), %eax + fldt 24+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt -12(%eax) + fldt -72(%eax) + movzwl -4(%eax), %ecx + movl %ecx, %edx + andl $32767, %edx + andl $-32768, %ecx + addl $-16639, %edx + orl $-49153, %ecx + fstpt (%eax) + movl %edx, 44(%esp) + movw %cx, -4(%eax) + jmp ..B1.24 +..B1.22: + fldt 12(%ebp) + addl $-16, %esp + lea 188(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + fxch %st(2) + fstpt 16(%esp) + fstpt 48(%esp) + fstpt -124(%edx) + call __libm_sinhl_k80 +..B1.65: + fldt 64(%esp) + fldt 48(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.23: + faddp %st, %st(3) + fxch %st(2) + fstpt (%esp) + lea 184(%esp), %eax + movl (%esp), %edx + movl %edx, 44(%esp) + fxch %st(1) +..B1.24: + fldt 172(%esp) + fld %st(0) + fld %st(3) + fldt (%eax) + fadd %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fsubr %st(1), %st + fsubrp %st, %st(1) + fstpt 64(%esp) + fldt 64(%esp) + addl $-16, %esp + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt 24(%ebp) + fstpt (%esp) + lea 212(%esp), %edx + movl %edx, 12(%esp) + fstpt -100(%edx) + fstpt 48(%esp) + fstpt 64(%esp) + call __libm_cosl_k80 +..B1.66: + fldt 64(%esp) + fxch %st(1) + fstpt 96(%esp) + fldt 48(%esp) + fldt 112(%esp) + addl $16, %esp +..B1.25: + fldt 196(%esp) + fld %st(0) + fldt 208(%esp) + movzwl 32(%ebp), %edx + fadd %st, %st(1) + fld %st(1) + andl $32767, %edx + cmpl $16183, %edx + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fld %st(5) + fmul %st(3), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 80(%esp) + fmul %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%esp) + fldt 12+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(1) + jge ..B1.27 +..B1.26: + fldt 24(%ebp) + fldt 24+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 124(%esp) + fldt 112(%esp) + movzwl 132(%esp), %ecx + movl %ecx, %edx + andl $-32768, %ecx + andl $32767, %edx + orl $-49153, %ecx + addl $-16639, %edx + movw %cx, 132(%esp) + fstpt 136(%esp) + fldt 124(%esp) + movl %edx, 12(%esp) + jmp ..B1.29 +..B1.27: + fldt 24(%ebp) + addl $-16, %esp + lea 140(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + fxch %st(1) + fstpt -28(%edx) + fstpt 16(%esp) + fstpt -92(%edx) + fstpt -76(%edx) + call __libm_sinl_k80 +..B1.67: + fldt 64(%esp) + fldt 48(%esp) + fldt 16(%esp) + fldt 112(%esp) + addl $16, %esp +..B1.28: + fldt 124(%esp) + fmul %st(5), %st + fstpt 124(%esp) + fldt 124(%esp) + fldt 136(%esp) + fmulp %st, %st(6) + fxch %st(5) + fstpt 112(%esp) + fldt 112(%esp) + fstpt 136(%esp) + movl $0, 12(%esp) + fxch %st(2) + fxch %st(3) + fxch %st(4) +..B1.29: + fldt 112(%esp) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(6) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fsubr %st(6), %st + fsubrp %st, %st(6) + fxch %st(1) + fsub %st(5), %st + faddp %st, %st(1) + fstpt (%esp) + fld %st(1) + fldt 64(%esp) + fld %st(0) + fmul %st(3), %st + fxch %st(4) + fmulp %st, %st(3) + fldt 80(%esp) + addl $-32, %esp + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl 76(%esp), %edx + movl %edx, 24(%esp) + fstpt 64(%esp) + fstpt 80(%esp) + call __libm_scalbl_k80 +..B1.68: + fldt 80(%esp) + fldt 64(%esp) + addl $32, %esp +..B1.30: + fldt 16(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(2) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(4) + fstpt 220(%esp) + fldt (%esp) + addl $-32, %esp + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl 60(%esp), %edx + addl 44(%esp), %edx + movl %edx, 24(%esp) + call __libm_scalbl_k80 +..B1.69: + addl $32, %esp +..B1.31: + fstpt 232(%esp) + jmp ..B1.45 +..B1.33: + movl 28(%ebp), %ecx +..B1.34: + testl %ecx, %ecx + jne ..B1.37 +..B1.78: + cmpl $0, 24(%ebp) +..B1.35: + jne ..B1.37 +..B1.36: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call sinhl@PLT +..B1.70: + fldt 24(%ebp) + addl $16, %esp + fstpt 232(%esp) + fstpt 220(%esp) + jmp ..B1.45 +..B1.37: + movzwl 32(%ebp), %ecx + andl $32767, %ecx + movl %ecx, 12(%esp) + cmpl $32767, %ecx + jge ..B1.40 +..B1.38: + fldt 12(%ebp) + fstpt 32(%esp) + fldt 32(%esp) + addl $-16, %esp + fstpt (%esp) + call sinhl@PLT +..B1.72: + fstpt 16(%esp) + addl $16, %esp + fldt 24(%ebp) + fstpt 16(%esp) + fldt 16(%esp) + addl $-16, %esp + fstpt (%esp) + call cosl@PLT +..B1.71: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpt 220(%esp) + cmpl $0, 12(%esp) + jle ..B1.55 +..B1.39: + addl $-16, %esp + fldt 48(%esp) + fstpt (%esp) + call coshl@PLT +..B1.74: + fstpt 16(%esp) + fldt 32(%esp) + fstpt (%esp) + call sinl@PLT +..B1.73: + addl $16, %esp + fldt (%esp) + fmulp %st, %st(1) + fstpt 232(%esp) + jmp ..B1.45 +..B1.40: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + movl %edx, 16(%esp) + call sinl@PLT +..B1.75: + movl 16(%esp), %edx + addl $16, %esp + fstpt 232(%esp) + fldt 232(%esp) + cmpl $32767, %edx + je ..B1.43 +..B1.41: + cmpl $0, 16(%ebp) + jne ..B1.44 +..B1.42: + cmpl $0, 12(%ebp) + jne ..B1.44 +..B1.43: + fstp %st(0) + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call sinhl@PLT +..B1.76: + addl $16, %esp + fstpt 220(%esp) + jmp ..B1.45 +..B1.44: + fldt 12(%ebp) + fmulp %st, %st(1) + fstpt 220(%esp) +..B1.45: + testl %edi, %edi + je ..B1.47 +..B1.46: + fldcw 62(%esp) +..B1.47: + movl 220(%esp), %edx + movl %edx, (%esi) + movl 232(%esp), %edx + movl %edx, 12(%esi) + movl 236(%esp), %edx + movl %edx, 16(%esi) + movl 224(%esp), %ecx + movl 228(%esp), %edi + movl 240(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 244(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.49 +..B1.48: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.49: + call __stack_chk_fail@PLT +..B1.50: + cmpl $0, 28(%ebp) + jne ..B1.11 +..B1.51: + cmpl $0, 24(%ebp) + jne ..B1.11 + jmp ..B1.35 +..B1.52: + cmpl $0, 16(%ebp) + jne ..B1.9 +..B1.53: + cmpl $0, 12(%ebp) + jne ..B1.9 + jmp ..B1.33 +..B1.55: + cmpl $0, 16(%ebp) + jne ..B1.57 +..B1.56: + cmpl $0, 12(%ebp) + je ..B1.39 +..B1.57: + addl $-16, %esp + fldt 48(%esp) + fstpt (%esp) + call coshl@PLT +..B1.77: + addl $16, %esp + fldt 16(%esp) + fmulp %st, %st(1) + fstpt 232(%esp) + jmp ..B1.45 +..B1.59: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type csinhl,@function + .size csinhl,.-csinhl + .data +# -- End csinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,48 + .data + .hidden __libm_sinl_k80 + .hidden __libm_cosl_k80 + .hidden __libm_sinhl_k80 + .hidden __libm_coshl_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csinl.S b/external/sgx_libm/ia32/csinl.S new file mode 100644 index 0000000000..5b9c99558e --- /dev/null +++ b/external/sgx_libm/ia32/csinl.S @@ -0,0 +1,210 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csinl.c" + .text +..TXTST0: +# -- Begin csinl + .text + .align 16,0x90 + .globl csinl +csinl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 100(%esp) + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 40(%esp) + fldt 40(%esp) + fstpt 52(%esp) + fldt 52(%esp) + fstpt 64(%esp) +..B1.2: + fnstcw 2(%esp) +..B1.3: + movzwl 2(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.4: + orl $-64768, %ecx + movw %cx, (%esp) +..B1.5: + fldcw (%esp) +..B1.6: + movl $1, %edi +..B1.7: + fldt 24(%ebp) + movzwl 32(%ebp), %edx + andl $32767, %edx + fstpt 52(%esp) + cmpl $32767, %edx + fldt 12(%ebp) + fstpt 64(%esp) + jl ..B1.10 +..B1.8: + cmpl $-2147483648, 28(%ebp) + jne ..B1.11 +..B1.9: + cmpl $0, 24(%ebp) + jne ..B1.11 +..B1.10: + movzbl 33(%ebp), %ecx + notl %ecx + movzbl 61(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 61(%esp) +..B1.11: + addl $-32, %esp + lea 108(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl -24(%ecx), %ecx + movl %ecx, (%edx) + movl 88(%esp), %ecx + movl %ecx, 4(%edx) + movl 92(%esp), %ecx + movl %ecx, 8(%edx) + movl 96(%esp), %ecx + movl %ecx, 12(%edx) + movl 100(%esp), %ecx + movl %ecx, 16(%edx) + movl 104(%esp), %ecx + movl %ecx, 20(%edx) + call csinhl@PLT +..B1.23: + addl $28, %esp + fldt 76(%esp) + movzwl 84(%esp), %edx + andl $32767, %edx + fstpt 4(%esp) + fldt 4(%esp) + cmpl $32767, %edx + fstpt 40(%esp) + fldt 88(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + jl ..B1.14 +..B1.12: + cmpl $-2147483648, 8(%esp) + jne ..B1.15 +..B1.13: + cmpl $0, 4(%esp) + jne ..B1.15 +..B1.14: + movzbl 13(%esp), %ecx + notl %ecx + movzbl 49(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 49(%esp) +..B1.15: + testl %edi, %edi + je ..B1.17 +..B1.16: + fldcw 2(%esp) +..B1.17: + movl 28(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 12(%esi) + movl 44(%esp), %edx + movl %edx, 16(%esi) + movl 32(%esp), %ecx + movl 36(%esp), %edi + movl 48(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 100(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.19 +..B1.18: + movl %esi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.19: + call __stack_chk_fail@PLT +..B1.20: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type csinl,@function + .size csinl,.-csinl + .data +# -- End csinl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csqrt_wmt.S b/external/sgx_libm/ia32/csqrt_wmt.S new file mode 100644 index 0000000000..fff8343914 --- /dev/null +++ b/external/sgx_libm/ia32/csqrt_wmt.S @@ -0,0 +1,763 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csqrt_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin csqrt + .text + .align 16,0x90 + .globl csqrt +csqrt: +# parameter 1: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $184, %esp + movl %esi, 128(%esp) + call static_func + movl %eax, %esi + movl 192(%esp), %edx + movsd 196(%esp), %xmm0 + movsd 204(%esp), %xmm1 + movl %edx, (%esp) + movsd %xmm0, 16(%esp) + movsd %xmm1, 24(%esp) + lea 16(%esp), %ecx + movq (%esi), %xmm2 + movl %edx, (%esp) + movl %ebx, 40(%esp) + movl %ecx, 44(%esp) + movq (%esi), %xmm3 + movq 32(%esi), %xmm7 + pand %xmm0, %xmm2 + pand %xmm1, %xmm3 + pand 16(%esi), %xmm0 + pand 16(%esi), %xmm1 + movq %xmm2, %xmm4 + movq %xmm3, %xmm5 + movl 4(%ecx), %eax + movl 12(%ecx), %ebx + andl $2147483647, %eax + andl $2147483647, %ebx + subl $591396864, %eax + movq %xmm0, 64(%esp) + subl $591396864, %ebx + cmpl $1017118720, %eax + movq %xmm1, 72(%esp) + jae .L_2TAG_PACKET_0.0.2 + cmpl $1017118720, %ebx + jae .L_2TAG_PACKET_0.0.2 + addl $591396864, %eax + addl $591396864, %ebx + movl %eax, %edx + subl %ebx, %edx + cmpl $60817408, %edx + jg .L_2TAG_PACKET_1.0.2 + cmpl $-60817408, %edx + movl (%esp), %edx + jl .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_3.0.2: + subsd %xmm2, %xmm0 + subsd %xmm3, %xmm1 + mulsd %xmm2, %xmm2 + mulsd %xmm3, %xmm3 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm5 + movq %xmm2, %xmm6 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + movq %xmm7, 80(%esp) + movq %xmm2, %xmm7 + addsd %xmm3, %xmm2 + addsd %xmm4, %xmm0 + subsd %xmm2, %xmm7 + addsd %xmm5, %xmm1 + movq %xmm2, 56(%esp) + addsd %xmm7, %xmm2 + addsd %xmm7, %xmm3 + movq 56(%esp), %xmm7 + addsd %xmm4, %xmm0 + subsd %xmm2, %xmm6 + addsd %xmm5, %xmm1 + movq 56(%esp), %xmm5 + movq %xmm0, %xmm2 + movq %xmm0, %xmm4 + addsd %xmm3, %xmm6 + addsd %xmm1, %xmm0 + subsd %xmm0, %xmm2 + movq %xmm0, %xmm3 + addsd %xmm2, %xmm0 + addsd %xmm2, %xmm1 + pshufd $221, %xmm7, %xmm2 + subsd %xmm0, %xmm4 + movq 48(%esi), %xmm0 + addsd %xmm4, %xmm1 + pand %xmm7, %xmm0 + addsd %xmm3, %xmm7 + addsd %xmm6, %xmm1 + subsd %xmm7, %xmm5 + subsd %xmm0, %xmm7 + movq %xmm0, %xmm4 + addsd %xmm5, %xmm3 + movq %xmm0, %xmm5 + addsd %xmm7, %xmm1 + movq %xmm0, %xmm7 + psrlq $29, %xmm0 + addsd %xmm3, %xmm1 + pand 64(%esi), %xmm0 + movq 160(%esi), %xmm3 + pxor 80(%esi), %xmm0 + addsd %xmm1, %xmm4 + paddd 96(%esi), %xmm0 + psubd 112(%esi), %xmm2 + rsqrtss %xmm0, %xmm0 + pand 128(%esi), %xmm2 + psrld $3, %xmm0 + psrld $1, %xmm2 + paddd 144(%esi), %xmm0 + psubd %xmm2, %xmm0 + psllq $32, %xmm0 + movq %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm7 + mulsd %xmm1, %xmm0 + subsd 32(%esi), %xmm7 + addsd %xmm0, %xmm7 + movq 176(%esi), %xmm0 + movq %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm0 + addsd 192(%esi), %xmm3 + addsd 208(%esi), %xmm0 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm0 + addsd 224(%esi), %xmm3 + mulsd %xmm6, %xmm3 + addsd %xmm0, %xmm3 + movq 64(%esp), %xmm0 + mulsd %xmm2, %xmm3 + mulsd %xmm4, %xmm3 + movq 64(%esp), %xmm4 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + movq %xmm5, %xmm2 + addsd 64(%esp), %xmm5 + movq 48(%esi), %xmm7 + addsd %xmm3, %xmm1 + subsd %xmm5, %xmm4 + movq %xmm5, %xmm3 + addsd %xmm4, %xmm5 + addsd %xmm2, %xmm4 + subsd %xmm5, %xmm0 + addsd %xmm0, %xmm4 + movq 240(%esi), %xmm0 + addsd %xmm1, %xmm4 + movq %xmm3, %xmm1 + movq %xmm3, %xmm2 + addsd %xmm4, %xmm3 + subsd %xmm3, %xmm1 + mulsd %xmm3, %xmm0 + pand %xmm0, %xmm7 + addsd %xmm1, %xmm3 + addsd %xmm4, %xmm1 + movq %xmm7, %xmm4 + subsd %xmm2, %xmm3 + movq %xmm7, %xmm5 + pshufd $221, %xmm0, %xmm2 + subsd %xmm7, %xmm0 + subsd %xmm3, %xmm1 + mulsd 240(%esi), %xmm1 + addsd %xmm0, %xmm1 + movq %xmm7, %xmm0 + psrlq $29, %xmm7 + movq 160(%esi), %xmm3 + pand 64(%esi), %xmm7 + psubd 112(%esi), %xmm2 + pxor 80(%esi), %xmm7 + addsd %xmm1, %xmm4 + paddd 96(%esi), %xmm7 + rsqrtss %xmm7, %xmm7 + psrld $3, %xmm7 + pand 128(%esi), %xmm2 + psrld $1, %xmm2 + paddd 144(%esi), %xmm7 + psubd %xmm2, %xmm7 + psllq $32, %xmm7 + movq %xmm7, %xmm2 + mulsd %xmm7, %xmm7 + mulsd %xmm7, %xmm0 + mulsd %xmm1, %xmm7 + subsd 32(%esi), %xmm0 + addsd %xmm7, %xmm0 + movq 176(%esi), %xmm7 + movq %xmm0, %xmm6 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm7 + addsd 192(%esi), %xmm3 + addsd 208(%esi), %xmm7 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm7 + addsd 224(%esi), %xmm3 + mulsd %xmm6, %xmm3 + movq 72(%esp), %xmm6 + addsd %xmm7, %xmm3 + mulsd 240(%esi), %xmm6 + mulsd %xmm2, %xmm3 + mulsd %xmm3, %xmm4 + pxor %xmm7, %xmm7 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + cmpnlesd (%ecx), %xmm7 + addsd %xmm4, %xmm1 + movq 48(%esi), %xmm4 + pand %xmm6, %xmm4 + subsd %xmm4, %xmm6 + addsd %xmm5, %xmm1 + movq %xmm2, %xmm5 + mulsd %xmm4, %xmm2 + mulsd %xmm3, %xmm4 + movq %xmm1, %xmm0 + pand %xmm7, %xmm0 + mulsd %xmm6, %xmm3 + mulsd %xmm5, %xmm6 + movq 8(%ecx), %xmm5 + addsd %xmm4, %xmm3 + addsd %xmm3, %xmm6 + addsd %xmm6, %xmm2 + movq %xmm7, %xmm6 + pandn %xmm2, %xmm6 + pand %xmm7, %xmm2 + pandn %xmm1, %xmm7 + pand 256(%esi), %xmm5 + por %xmm6, %xmm0 + por %xmm7, %xmm2 + por %xmm5, %xmm0 + mulsd 80(%esp), %xmm2 + mulsd 80(%esp), %xmm0 + movsd %xmm2, (%edx) + movsd %xmm0, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_0.0.2: + addl $591396864, %eax + addl $591396864, %ebx + cmpl $2146435072, %eax + jge .L_2TAG_PACKET_5.0.2 + cmpl $2146435072, %ebx + jge .L_2TAG_PACKET_6.0.2 + movl (%ecx), %edx + orl %eax, %edx + movl 8(%ecx), %edx + je .L_2TAG_PACKET_7.0.2 + orl %ebx, %edx + je .L_2TAG_PACKET_8.0.2 + movl %eax, %edx + subl %ebx, %edx + cmpl $60817408, %edx + jg .L_2TAG_PACKET_1.0.2 + cmpl $-60817408, %edx + jl .L_2TAG_PACKET_2.0.2 + cmpl $1072693248, %eax + jl .L_2TAG_PACKET_9.0.2 + mulsd 272(%esi), %xmm0 + mulsd 272(%esi), %xmm1 + movq 288(%esi), %xmm7 + movq 48(%esi), %xmm2 + movq 48(%esi), %xmm3 + pand %xmm0, %xmm2 + pand %xmm1, %xmm3 + movq %xmm2, %xmm4 + movl (%esp), %edx + movq %xmm3, %xmm5 + movq %xmm0, 64(%esp) + movq %xmm1, 72(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_9.0.2: + mulsd 304(%esi), %xmm0 + mulsd 304(%esi), %xmm1 + movq 320(%esi), %xmm7 + movq 48(%esi), %xmm2 + movq 48(%esi), %xmm3 + pand %xmm0, %xmm2 + pand %xmm1, %xmm3 + movq %xmm2, %xmm4 + movl (%esp), %edx + movq %xmm3, %xmm5 + movq %xmm0, 64(%esp) + movq %xmm1, 72(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: +.L_2TAG_PACKET_7.0.2: + cmpl $2097152, %ebx + movl (%esp), %edx + jl .L_2TAG_PACKET_10.0.2 + mulsd 240(%esi), %xmm1 + sqrtsd %xmm1, %xmm1 + movsd 8(%ecx), %xmm2 + pand 256(%esi), %xmm2 + movsd %xmm1, (%edx) + por %xmm2, %xmm1 + movsd %xmm1, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_10.0.2: + mulsd 336(%esi), %xmm1 + sqrtsd %xmm1, %xmm1 + movsd 8(%ecx), %xmm2 + pand 256(%esi), %xmm2 + mulsd 352(%esi), %xmm1 + movsd %xmm1, (%edx) + por %xmm2, %xmm1 + movsd %xmm1, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_8.0.2: + sqrtsd %xmm0, %xmm0 + movl 4(%ecx), %eax + cmpl $0, %eax + movl (%esp), %edx + jl .L_2TAG_PACKET_11.0.2 + movsd 8(%ecx), %xmm2 + pand 256(%esi), %xmm2 + movsd %xmm2, 8(%edx) + movsd %xmm0, (%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_11.0.2: + pxor %xmm3, %xmm3 + movsd %xmm3, (%edx) + movsd 8(%ecx), %xmm2 + pand 256(%esi), %xmm2 + por %xmm0, %xmm2 + movsd %xmm2, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_1.0.2: + cmpl $57671680, %ebx + movsd %xmm0, %xmm4 + subsd %xmm2, %xmm0 + movq %xmm2, %xmm5 + movq %xmm2, %xmm7 + pshufd $221, %xmm2, %xmm1 + jl .L_2TAG_PACKET_12.0.2 + mulsd 416(%esi), %xmm2 + mulsd 416(%esi), %xmm0 + mulsd 416(%esi), %xmm4 + movsd %xmm2, %xmm5 + movsd %xmm2, %xmm7 + pshufd $221, %xmm2, %xmm1 + shrl $21, %eax + shrl $20, %ebx + psrlq $29, %xmm2 + pand 64(%esi), %xmm2 + pxor 80(%esi), %xmm2 + paddd 96(%esi), %xmm2 + rsqrtss %xmm2, %xmm2 + subl $511, %eax + subl $1023, %ebx + psubd 112(%esi), %xmm1 + psrld $3, %xmm2 + pand 128(%esi), %xmm1 + psrld $1, %xmm1 + paddd 144(%esi), %xmm2 + psubd %xmm1, %xmm2 + subl %eax, %ebx + psllq $32, %xmm2 + movq %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + mulsd %xmm2, %xmm7 + mulsd %xmm0, %xmm2 + subsd 32(%esi), %xmm7 + cmpl $-1020, %ebx + addsd %xmm2, %xmm7 + movq %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + movq 160(%esi), %xmm3 + movq 176(%esi), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 192(%esi), %xmm3 + addsd 208(%esi), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 224(%esi), %xmm3 + mulsd %xmm6, %xmm3 + addsd %xmm2, %xmm3 + mulsd %xmm1, %xmm3 + mulsd %xmm3, %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + addsd %xmm4, %xmm0 + mulsd 448(%esi), %xmm5 + mulsd 448(%esi), %xmm0 + mulsd 432(%esi), %xmm1 + mulsd 432(%esi), %xmm3 + jl .L_2TAG_PACKET_13.0.2 + movsd 72(%esp), %xmm2 + addsd %xmm5, %xmm0 + mulsd 240(%esi), %xmm1 + mulsd 240(%esi), %xmm3 + movq 48(%esi), %xmm4 + pand %xmm2, %xmm4 + subsd %xmm4, %xmm2 + movq %xmm1, %xmm5 + mulsd %xmm4, %xmm1 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm3 + mulsd %xmm5, %xmm2 + addsd %xmm4, %xmm3 + addsd %xmm3, %xmm2 + addsd %xmm2, %xmm1 +.L_2TAG_PACKET_14.0.2: + movsd 8(%ecx), %xmm3 + pand 256(%esi), %xmm3 + movl 4(%ecx), %eax + cmpl $0, %eax + movl (%esp), %edx + jl .L_2TAG_PACKET_15.0.2 + por %xmm3, %xmm1 + movsd %xmm0, (%edx) + movsd %xmm1, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_15.0.2: + por %xmm3, %xmm0 + movsd %xmm1, (%edx) + movsd %xmm0, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_12.0.2: + psrlq $29, %xmm2 + pand 64(%esi), %xmm2 + pxor 80(%esi), %xmm2 + paddd 96(%esi), %xmm2 + rsqrtss %xmm2, %xmm2 + psubd 112(%esi), %xmm1 + psrld $3, %xmm2 + pand 128(%esi), %xmm1 + psrld $1, %xmm1 + paddd 144(%esi), %xmm2 + psubd %xmm1, %xmm2 + psllq $32, %xmm2 + movq %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + mulsd %xmm2, %xmm7 + mulsd %xmm0, %xmm2 + subsd 32(%esi), %xmm7 + addsd %xmm2, %xmm7 + movq %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + movq 160(%esi), %xmm3 + movq 176(%esi), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 192(%esi), %xmm3 + addsd 208(%esi), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 224(%esi), %xmm3 + mulsd %xmm6, %xmm3 + addsd %xmm2, %xmm3 + mulsd %xmm1, %xmm3 + mulsd %xmm3, %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + addsd %xmm4, %xmm0 +.L_2TAG_PACKET_13.0.2: + addsd %xmm5, %xmm0 + movq 72(%esp), %xmm2 + mulsd 368(%esi), %xmm2 + mulsd 336(%esi), %xmm2 + movq 48(%esi), %xmm4 + pand %xmm2, %xmm4 + subsd %xmm4, %xmm2 + movq %xmm1, %xmm5 + mulsd %xmm4, %xmm1 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm3 + mulsd %xmm5, %xmm2 + addsd %xmm4, %xmm3 + addsd %xmm3, %xmm2 + movq %xmm1, %xmm3 + addsd %xmm2, %xmm1 + pextrw $3, %xmm1, %eax + mulsd 384(%esi), %xmm1 + mulsd 400(%esi), %xmm1 + cmpl $19216, %eax + jge .L_2TAG_PACKET_14.0.2 + movq 384(%esi), %xmm5 + mulsd %xmm5, %xmm5 + cmpl $19056, %eax + jle .L_2TAG_PACKET_14.0.2 + movq 48(%esi), %xmm1 + pand %xmm3, %xmm1 + subsd %xmm1, %xmm3 + addsd %xmm3, %xmm2 + mulsd 384(%esi), %xmm1 + mulsd 384(%esi), %xmm2 + mulsd 400(%esi), %xmm1 + mulsd 400(%esi), %xmm2 + addsd %xmm2, %xmm1 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_6.0.2: +.L_2TAG_PACKET_16.0.2: + movq 32(%esi), %xmm0 + addsd 8(%ecx), %xmm0 + movsd %xmm0, 8(%edx) + mulsd %xmm0, %xmm0 + movsd %xmm0, (%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_5.0.2: + movsd (%ecx), %xmm1 + mulsd %xmm1, %xmm1 + cmpl $2146435072, %ebx + jl .L_2TAG_PACKET_17.0.2 + movl 8(%ecx), %ebx + jg .L_2TAG_PACKET_18.0.2 + andl %ebx, %ebx + jne .L_2TAG_PACKET_18.0.2 + jmp .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_18.0.2: + movq 32(%esi), %xmm0 + addsd 8(%ecx), %xmm0 + cmpl $2146435072, %eax + movl (%ecx), %ebx + jg .L_2TAG_PACKET_19.0.2 + andl %ebx, %ebx + movl 4(%ecx), %ebx + jne .L_2TAG_PACKET_19.0.2 + cmpl $2146435072, %ebx + je .L_2TAG_PACKET_20.0.2 + mulsd %xmm1, %xmm1 + movsd %xmm0, (%edx) + movsd %xmm1, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_19.0.2: +.L_2TAG_PACKET_20.0.2: + movsd %xmm1, (%edx) + movsd %xmm0, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_17.0.2: + cmpl $2146435072, %eax + movl (%ecx), %eax + jg .L_2TAG_PACKET_21.0.2 + andl %eax, %eax + jne .L_2TAG_PACKET_21.0.2 + pxor %xmm2, %xmm2 + movl 4(%ecx), %eax + movq 8(%ecx), %xmm3 + testl $-2147483648, %eax + pand 256(%esi), %xmm3 + jne .L_2TAG_PACKET_22.0.2 + por %xmm3, %xmm2 + movsd %xmm1, (%edx) + movsd %xmm2, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_22.0.2: + por %xmm3, %xmm1 + movsd %xmm2, (%edx) + movsd %xmm1, 8(%edx) + movl 40(%esp), %ebx + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_21.0.2: + movsd %xmm1, (%edx) + movsd %xmm1, 8(%edx) + movl 40(%esp), %ebx +.L_2TAG_PACKET_4.0.2: + movl 128(%esp), %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B2.3: + .align 16,0x90 + .type csqrt,@function + .size csqrt,.-csqrt + .data +# -- End csqrt + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4160749568 + .long 2147483647 + .long 4160749568 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .long 16777215 + .long 16777215 + .long 16777215 + .long 16777215 + .long 8388608 + .long 8388608 + .long 8388608 + .long 8388608 + .long 1065353216 + .long 1065353216 + .long 1065353216 + .long 1065353216 + .long 1048576 + .long 1048576 + .long 1048576 + .long 1048576 + .long 4292870144 + .long 4292870144 + .long 4292870144 + .long 4292870144 + .long 1475346432 + .long 1475346432 + .long 1475346432 + .long 1475346432 + .long 0 + .long 3218046976 + .long 0 + .long 3218046976 + .long 0 + .long 1070694400 + .long 0 + .long 1070694400 + .long 0 + .long 3218341888 + .long 0 + .long 3218341888 + .long 0 + .long 1071120384 + .long 0 + .long 1071120384 + .long 0 + .long 3219128320 + .long 0 + .long 3219128320 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 533725184 + .long 0 + .long 533725184 + .long 0 + .long 1342177280 + .long 0 + .long 1342177280 + .long 0 + .long 1722810368 + .long 0 + .long 1722810368 + .long 0 + .long 747634688 + .long 0 + .long 747634688 + .long 0 + .long 1281359872 + .long 0 + .long 1281359872 + .long 0 + .long 967835648 + .long 0 + .long 967835648 + .long 0 + .long 2121269248 + .long 0 + .long 2121269248 + .long 0 + .long 24117248 + .long 0 + .long 24117248 + .long 0 + .long 862978048 + .long 0 + .long 862978048 + .long 0 + .long 1062207488 + .long 0 + .long 1062207488 + .long 0 + .long 1067450368 + .long 0 + .long 1067450368 + .long 0 + .long 1077936128 + .long 0 + .long 1077936128 + .type static_const_table,@object + .size static_const_table,464 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csqrtf_wmt.S b/external/sgx_libm/ia32/csqrtf_wmt.S new file mode 100644 index 0000000000..e551616238 --- /dev/null +++ b/external/sgx_libm/ia32/csqrtf_wmt.S @@ -0,0 +1,351 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csqrtf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin csqrtf + .text + .align 16,0x90 + .globl csqrtf +csqrtf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $216, %esp + movl %ebx, 160(%esp) + call static_func + movl %eax, %ebx + movss 224(%esp), %xmm0 + movss 228(%esp), %xmm1 + movss %xmm0, (%esp) + movss %xmm1, 4(%esp) + movl (%esp), %eax + movl 4(%esp), %ecx + unpcklps %xmm1, %xmm0 + movl %ecx, %edx + andl $2139095040, %eax + andl $2139095040, %ecx + subl $8388608, %eax + subl $8388608, %ecx + andl $2139095040, %eax + andl $2139095040, %ecx + subl $2130706432, %eax + subl $2130706432, %ecx + testl %ecx, %eax + jns .L_2TAG_PACKET_0.0.2 + cvtps2pd %xmm0, %xmm0 + pxor %xmm4, %xmm4 + movl $16, %eax + movapd %xmm0, %xmm1 + unpckhpd %xmm1, %xmm1 + movapd %xmm0, %xmm7 + mulsd %xmm0, %xmm0 + movapd %xmm7, %xmm6 + mulsd %xmm1, %xmm1 + pinsrw $3, %eax, %xmm4 + addsd %xmm1, %xmm0 + andpd (%ebx), %xmm7 + sqrtsd %xmm0, %xmm0 + addsd %xmm7, %xmm0 + psubd %xmm4, %xmm0 + movsd %xmm0, %xmm7 + movdqa %xmm0, %xmm1 + pand 16(%ebx), %xmm0 + movdqa %xmm1, %xmm2 + paddd 32(%ebx), %xmm0 + psrld $1, %xmm1 + psrlq $29, %xmm0 + pand 48(%ebx), %xmm1 + rsqrtss %xmm0, %xmm0 + psubd 64(%ebx), %xmm1 + psllq $29, %xmm0 + movapd 80(%ebx), %xmm3 + psubd %xmm1, %xmm0 + movapd 96(%ebx), %xmm1 + mulsd %xmm0, %xmm2 + movapd 48(%ebx), %xmm4 + mulsd %xmm0, %xmm2 + subsd %xmm4, %xmm2 + mulsd %xmm2, %xmm3 + addsd %xmm1, %xmm3 + mulsd %xmm2, %xmm3 + mulsd %xmm0, %xmm3 + addsd %xmm3, %xmm0 + mulpd 112(%ebx), %xmm7 + unpcklpd %xmm0, %xmm0 +.L_2TAG_PACKET_1.0.2: + pextrw $3, %xmm6, %eax + mulpd %xmm7, %xmm0 + andl $-2147483648, %edx + cvtpd2ps %xmm0, %xmm1 + testl $32768, %eax + pshufd $17, %xmm1, %xmm2 + je .L_2TAG_PACKET_2.0.2 + movd %xmm1, %ecx + movd %xmm2, %eax + orl %ecx, %edx + testl $2139095040, %eax + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: + movd %xmm2, %ecx + movd %xmm1, %eax + orl %ecx, %edx + testl $2139095040, %ecx +.L_2TAG_PACKET_3.0.2: + je .L_2TAG_PACKET_4.0.2 + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_4.0.2: + testl $2147483647, 4(%esp) + jne .L_2TAG_PACKET_6.0.2 + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_6.0.2: + movhpd %xmm0, 112(%esp) + testl $2139095040, %eax + fldl 112(%esp) + fstps 112(%esp) + je .L_2TAG_PACKET_7.0.2 + andl $-2147483648, %edx + orl 112(%esp), %edx + jmp .L_2TAG_PACKET_8.0.2 +.L_2TAG_PACKET_7.0.2: + movl 112(%esp), %eax +.L_2TAG_PACKET_8.0.2: + movl $8388608, 116(%esp) + flds 112(%esp) + fmul %st(0), %st + fstps 112(%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_0.0.2: + movdqa %xmm0, %xmm2 + movdqa 128(%ebx), %xmm4 + pshufd $80, %xmm0, %xmm0 + pxor %xmm5, %xmm5 + movdqa %xmm2, %xmm3 + pand 144(%ebx), %xmm0 + pshufd $115, %xmm2, %xmm2 + pcmpeqd %xmm4, %xmm0 + movdqa %xmm2, %xmm6 + movmskps %xmm0, %eax + pand %xmm2, %xmm4 + testl %eax, %eax + jne .L_2TAG_PACKET_9.0.2 + pxor %xmm0, %xmm0 +.L_2TAG_PACKET_10.0.2: + pand (%ebx), %xmm2 + pcmpeqd %xmm5, %xmm4 + movdqa %xmm4, %xmm3 + pand 160(%ebx), %xmm4 + psrlq $3, %xmm2 + pand 176(%ebx), %xmm3 + por %xmm4, %xmm2 + paddd 192(%ebx), %xmm3 + subpd %xmm4, %xmm2 + paddd %xmm3, %xmm2 + pandn %xmm2, %xmm0 + pxor %xmm4, %xmm4 + movl $16, %eax + movapd %xmm0, %xmm1 + unpckhpd %xmm1, %xmm1 + movapd %xmm0, %xmm7 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + pinsrw $3, %eax, %xmm4 + addsd %xmm1, %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm7, %xmm0 + psubd %xmm4, %xmm0 + movsd %xmm0, %xmm7 + sqrtsd %xmm0, %xmm1 + movapd 48(%ebx), %xmm0 + divsd %xmm1, %xmm0 + mulpd 112(%ebx), %xmm7 + unpcklpd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_9.0.2: + cmpl $5, %eax + je .L_2TAG_PACKET_11.0.2 + testl $10, %eax + jne .L_2TAG_PACKET_12.0.2 + pshufd $160, %xmm0, %xmm0 + jmp .L_2TAG_PACKET_10.0.2 +.L_2TAG_PACKET_11.0.2: + xorl %eax, %eax + andl $-2147483648, %edx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_12.0.2: + movl %edx, %ecx + andl $2147483647, %ecx + movd %xmm3, %eax + cmpl $2139095040, %ecx + je .L_2TAG_PACKET_13.0.2 + ja .L_2TAG_PACKET_14.0.2 + andl $-2147483648, %edx + cmpl $-8388608, %eax + je .L_2TAG_PACKET_15.0.2 + cmpl $2139095040, %eax + jne .L_2TAG_PACKET_16.0.2 + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_15.0.2: + xorl %eax, %eax + orl $2139095040, %edx + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_14.0.2: + cmpl $2139095040, %eax + je .L_2TAG_PACKET_17.0.2 + cmpl $-8388608, %eax + je .L_2TAG_PACKET_18.0.2 +.L_2TAG_PACKET_16.0.2: + mulss %xmm3, %xmm1 + flds (%esp) + flds 4(%esp) + movd %xmm1, %eax + movl %eax, %edx + jmp .L_2TAG_PACKET_19.0.2 +.L_2TAG_PACKET_17.0.2: + flds 4(%esp) + flds 4(%esp) + orl $4194304, %edx + jmp .L_2TAG_PACKET_19.0.2 +.L_2TAG_PACKET_18.0.2: + flds 4(%esp) + flds 4(%esp) + movl %edx, %eax + movl $2139095040, %edx + orl $4194304, %eax + jmp .L_2TAG_PACKET_19.0.2 +.L_2TAG_PACKET_13.0.2: + flds (%esp) + fld1 + movl $2139095040, %eax +.L_2TAG_PACKET_19.0.2: + fmulp + fstp %st(0) +.L_2TAG_PACKET_5.0.2: + movl 160(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type csqrtf,@function + .size csqrtf,.-csqrtf + .data +# -- End csqrtf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2097151 + .long 4294967295 + .long 2097151 + .long 0 + .long 132120576 + .long 0 + .long 132120576 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 1475346432 + .long 0 + .long 1475346432 + .long 2148429837 + .long 1071120401 + .long 2148429837 + .long 1071120401 + .long 195330 + .long 3219128325 + .long 195330 + .long 3219128325 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 0 + .long 2139095040 + .long 0 + .long 2139095040 + .long 2147483647 + .long 2139095040 + .long 2147483647 + .long 2139095040 + .long 0 + .long 133169152 + .long 0 + .long 133169152 + .long 0 + .long 4162846720 + .long 0 + .long 4162846720 + .long 0 + .long 939524096 + .long 0 + .long 939524096 + .type static_const_table,@object + .size static_const_table,208 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/csqrtl.S b/external/sgx_libm/ia32/csqrtl.S new file mode 100644 index 0000000000..becf7f5166 --- /dev/null +++ b/external/sgx_libm/ia32/csqrtl.S @@ -0,0 +1,739 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csqrtl.c" + .text +..TXTST0: +# -- Begin csqrtl + .text + .align 16,0x90 + .globl csqrtl +csqrtl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl 8(%ebp), %eax + movl %eax, 44(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 196(%esp) + fstpt 172(%esp) + fldt 172(%esp) + fstpt 184(%esp) +..B1.2: + fnstcw 62(%esp) +..B1.3: + movzwl 62(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.69 +..B1.4: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.5: + fldcw 60(%esp) +..B1.6: + movl $1, %esi +..B1.7: + movzwl 20(%ebp), %ecx + movl %ecx, %edi + andl $32767, %edi + cmpl $32767, %edi + jge ..B1.30 +..B1.8: + cmpl $0, 16(%ebp) + jne ..B1.10 +..B1.9: + cmpl $0, 12(%ebp) + je ..B1.30 +..B1.10: + movzwl 32(%ebp), %eax + movl %eax, %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.48 +..B1.11: + cmpl $0, 28(%ebp) + jne ..B1.13 +..B1.12: + cmpl $0, 24(%ebp) + je ..B1.32 +..B1.13: + fldt 12(%ebp) + testl %edi, %edi + jle ..B1.56 +..B1.14: + andl $-32768, %ecx + addl $-16383, %edi + fstpt 148(%esp) + fldt 148(%esp) + orl $-49153, %ecx + movw %cx, 156(%esp) +..B1.15: + fldt 24(%ebp) + testl %edx, %edx + movb $63, 157(%esp) + jle ..B1.55 +..B1.16: + andl $-32768, %eax + addl $-16383, %edx + fstpt 76(%esp) + fldt 76(%esp) + orl $-49153, %eax + movw %ax, 84(%esp) +..B1.17: + fldt 72+_CONSTANTS@GOTOFF(%ebx) + movb $63, 85(%esp) + fstpt 88(%esp) + fldt 88(%esp) + addl $-32, %esp + lea 132(%esp), %eax + movl %eax, (%esp) + fxch %st(2) + fstpt 4(%esp) + fstpt 16(%esp) + fstpt 32(%esp) + movl %edx, -72(%eax) + call __libm_hypot2l_k80 +..B1.72: + fldt 32(%esp) + movl 60(%esp), %edx + addl $32, %esp +..B1.18: + fldt 132+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fldt 100(%esp) + fld %st(0) + fsqrt + fldt 84+_CONSTANTS@GOTOFF(%ebx) + fstpt 32(%esp) + fldt 32(%esp) + fmul %st(1), %st + fld %st(0) + movl (%esp), %eax + fsubr %st(2), %st + sarl $1, %eax + faddp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fldt 112(%esp) + faddp %st, %st(2) + fldt 24+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(1) + fdivr %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 124(%esp) + fldt 124(%esp) + fsubr %st, %st(1) + movzwl 132(%esp), %ecx + fxch %st(1) + faddp %st, %st(2) + andl $32767, %ecx + movl %ecx, 12(%esp) + fxch %st(1) + fstpt 136(%esp) + fldt 136(%esp) + lea -16464(%ecx,%eax), %ecx + cmpl %ecx, %edi + jle ..B1.22 +..B1.19: + movl 12(%esp), %ecx + lea -16302(%ecx,%eax), %ecx + cmpl %ecx, %edi + jge ..B1.21 +..B1.20: + fstp %st(2) + subl %eax, %edi + fld %st(0) + addl $16383, %edi + fld %st(1) + movzwl 156(%esp), %ecx + andl $32767, %edi + andl $-32768, %ecx + orl %edi, %ecx + movl %eax, %edi + movw %cx, 156(%esp) + fldt 148(%esp) + fadd %st, %st(2) + fld %st(2) + fxch %st(2) + fsubr %st(3), %st + fsubr %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fsubp %st, %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + jmp ..B1.23 +..B1.21: + fstp %st(0) + fstp %st(0) + fldt 148(%esp) + jmp ..B1.23 +..B1.22: + fstp %st(2) + movl %eax, %edi +..B1.23: + fldt 32(%esp) + lea 1(%edi), %ecx + andl $1, %ecx + subl %ecx, %edi + decl %edi + sarl $1, %edi + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %eax + fldt 48+_CONSTANTS@GOTOFF(%eax,%ebx) + fmul %st, %st(2) + fld %st(2) + fsqrt + fmul %st, %st(2) + fld %st(2) + fsubr %st(1), %st + faddp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fxch %st(2) + fmulp %st, %st(5) + fld %st(2) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt 16(%esp) + fmulp %st, %st(2) + fxch %st(1) + fdiv %st(2), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%esp) + fldt 48(%esp) + addl $-32, %esp + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + fldt 12(%esp) + movl %edi, 24(%esp) + fstpt 96(%esp) + movl %edx, 60(%esp) + call __libm_scalbl_k80 +..B1.73: + fldt 96(%esp) + movl 60(%esp), %edx + fxch %st(1) + fstpt 32(%esp) + addl $32, %esp +..B1.24: + fldt 76(%esp) + subl %edi, %edx + fldt 48(%esp) + fld %st(0) + fdivr %st(2), %st + fmul %st, %st(3) + fld %st(1) + fldt 32(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + fsubr %st(4), %st + faddp %st, %st(1) + fld %st(0) + fsubr %st(4), %st + fxch %st(2) + fmul %st(5), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fmul %st(2), %st + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fld %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + fsubrp %st, %st(3) + fldt 88(%esp) + faddp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fldt 48(%esp) + fdivrp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 16(%esp) + fmul %st, %st(2) + fmulp %st, %st(1) + addl $-32, %esp + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl %edx, 24(%esp) + call __libm_scalbl_k80 +..B1.74: + addl $32, %esp +..B1.25: + movzbl 21(%ebp), %eax + testl $128, %eax + jne ..B1.27 +..B1.26: + fldt (%esp) + lea 184(%esp), %edi + fstpt -12(%edi) + jmp ..B1.28 +..B1.27: + fldt (%esp) + lea 184(%esp), %edi + fxch %st(1) + fstpt -12(%edi) +..B1.28: + movzbl 33(%ebp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _CONSTANTS@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt (%edi) + jmp ..B1.51 +..B1.30: + movzwl 32(%ebp), %edx + andl $32767, %edx +..B1.31: + cmpl $32767, %edx + jge ..B1.48 +..B1.32: + movl 16(%ebp), %eax + testl %eax, %eax + jne ..B1.40 +..B1.33: + cmpl $0, 12(%ebp) + jne ..B1.40 +..B1.34: + cmpl $0, 28(%ebp) + jne ..B1.36 +..B1.35: + cmpl $0, 24(%ebp) + je ..B1.40 +..B1.36: + fldt 24(%ebp) + movzbl 33(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + cmpl $2, %edx + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %eax + fldt _CONSTANTS@GOTOFF(%eax,%ebx) + jl ..B1.38 +..B1.37: + fldt 24+_CONSTANTS@GOTOFF(%ebx,%eax) + fmulp %st, %st(2) + fxch %st(1) + fsqrt + jmp ..B1.39 +..B1.38: + fldt 108+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fsqrt + fldt 156+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.39: + fstpt 172(%esp) + fldt 172(%esp) + fmulp %st, %st(1) + fstpt 184(%esp) + jmp ..B1.51 +..B1.40: + cmpl $32767, %edi + jl ..B1.43 +..B1.41: + cmpl $-2147483648, %eax + jne ..B1.47 +..B1.42: + cmpl $0, 12(%ebp) + jne ..B1.47 +..B1.43: + fldt 12(%ebp) + fldt 72+_CONSTANTS@GOTOFF(%ebx) + movzbl 21(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + testl %ecx, %ecx + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %edx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 148(%esp) + fldt 148(%esp) + fsqrt + jne ..B1.45 +..B1.44: + fstpt 172(%esp) + lea 184(%esp), %edi + jmp ..B1.46 +..B1.45: + fxch %st(1) + fstpt 172(%esp) + lea 184(%esp), %edi +..B1.46: + movzbl 33(%ebp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _CONSTANTS@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt (%edi) + jmp ..B1.51 +..B1.47: + fldt 12(%ebp) + fmul %st(0), %st + fstpt 172(%esp) + fldt 172(%esp) + fstpt 184(%esp) + jmp ..B1.51 +..B1.48: + je ..B1.63 +..B1.49: + cmpl $32767, %edi + je ..B1.58 +..B1.50: + fldt 12(%ebp) + fld %st(0) + fldt 24(%ebp) + fmul %st, %st(1) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fstpt 172(%esp) + fmulp %st, %st(1) + fstpt 184(%esp) +..B1.51: + testl %esi, %esi + je ..B1.53 +..B1.52: + fldcw 62(%esp) +..B1.53: + movl 44(%esp), %eax + movl 172(%esp), %edx + movl 176(%esp), %ecx + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 180(%esp), %esi + movl 184(%esp), %edi + movl 188(%esp), %edx + movl 192(%esp), %ecx + movl %esi, 8(%eax) + movl %edi, 12(%eax) + movl %edx, 16(%eax) + movl %ecx, 20(%eax) + movl 196(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.57 +..B1.54: + movl 44(%esp), %eax + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.55: + fldt 120+_CONSTANTS@GOTOFF(%ebx) + fmul %st(1), %st + fstpt 76(%esp) + movzwl 84(%esp), %eax + movl %eax, %edx + andl $-32768, %eax + andl $32767, %edx + orl $-49153, %eax + addl $-16639, %edx + movw %ax, 84(%esp) + jmp ..B1.17 +..B1.56: + fldt 120+_CONSTANTS@GOTOFF(%ebx) + fmul %st(1), %st + fstpt 148(%esp) + movzwl 156(%esp), %ecx + movl %ecx, %edi + andl $-32768, %ecx + andl $32767, %edi + orl $-49153, %ecx + addl $-16639, %edi + movw %cx, 156(%esp) + jmp ..B1.15 +..B1.57: + call __stack_chk_fail@PLT +..B1.58: + cmpl $-2147483648, 16(%ebp) + jne ..B1.50 +..B1.59: + cmpl $0, 12(%ebp) + jne ..B1.50 +..B1.60: + fldt 12(%ebp) + movzbl 21(%ebp), %eax + testl $128, %eax + fmul %st(0), %st + fldt 24(%ebp) + fmul %st(0), %st + jne ..B1.62 +..B1.61: + fxch %st(1) + fstpt 172(%esp) + fstpt 184(%esp) + jmp ..B1.51 +..B1.62: + fstpt 172(%esp) + fstpt 184(%esp) + jmp ..B1.51 +..B1.63: + cmpl $-2147483648, 28(%ebp) + jne ..B1.49 +..B1.64: + cmpl $0, 24(%ebp) + jne ..B1.49 +..B1.65: + fldt 24(%ebp) + movzbl 33(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fmul %st(0), %st + cmpl $32767, %edi + fstpt 172(%esp) + fldt 172(%esp) + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _CONSTANTS@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt 184(%esp) + jne ..B1.51 +..B1.66: + cmpl $-2147483648, 16(%ebp) + jne ..B1.68 +..B1.67: + cmpl $0, 12(%ebp) + je ..B1.51 +..B1.68: + fldt 12(%ebp) + fldt _CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 12(%ebp) + jmp ..B1.51 +..B1.69: + xorl %esi, %esi + jmp ..B1.7 + .align 16,0x90 + .type csqrtl,@function + .size csqrtl,.-csqrtl + .data +# -- End csqrtl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 32768 + .word 16415 + .word 0 + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16127 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,168 + .data + .hidden __libm_hypot2l_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ctan.S b/external/sgx_libm/ia32/ctan.S new file mode 100644 index 0000000000..15a3451d26 --- /dev/null +++ b/external/sgx_libm/ia32/ctan.S @@ -0,0 +1,237 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctan.c" + .text +..TXTST0: +# -- Begin ctan + .text + .align 16,0x90 + .globl ctan +ctan: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $72, %esp + fldz + fldl 20(%ebp) + fldl 12(%ebp) + movzwl 26(%ebp), %ecx + andl $32752, %ecx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 64(%esp) + cmpl $32752, %ecx + fstpl 56(%esp) + fxch %st(1) + fstl 16(%esp) + fstl 24(%esp) + fstl 32(%esp) + fstpl 40(%esp) + fstpl 48(%esp) + jl ..B1.4 +..B1.2: + testl $1048575, 24(%ebp) + jne ..B1.5 +..B1.3: + cmpl $0, 20(%ebp) + jne ..B1.5 +..B1.4: + movzbl 27(%ebp), %edx + notl %edx + movzbl 55(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 55(%esp) +..B1.5: + addl $-32, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea 32(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl 48(%ecx), %ecx + movl %ecx, (%edx) + movl 84(%esp), %ecx + movl %ecx, 4(%edx) + movl 88(%esp), %ecx + movl %ecx, 8(%edx) + movl 92(%esp), %ecx + movl %ecx, 12(%edx) + call ctanh@PLT +..B1.14: + addl $28, %esp + fldl (%esp) + movzwl 6(%esp), %edx + andl $32752, %edx + fstl 16(%esp) + cmpl $32752, %edx + fstpl 40(%esp) + fldl 8(%esp) + fstl 24(%esp) + fstpl 32(%esp) + jl ..B1.8 +..B1.6: + testl $1048575, 20(%esp) + jne ..B1.9 +..B1.7: + cmpl $0, 16(%esp) + jne ..B1.9 +..B1.8: + movzbl 23(%esp), %edx + notl %edx + movzbl 47(%esp), %ecx + andl $128, %edx + andl $127, %ecx + orl %edx, %ecx + movb %cl, 47(%esp) +..B1.9: + movl 32(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 8(%esi) + movl 36(%esp), %ecx + movl 44(%esp), %edx + movl %ecx, 4(%esi) + movl %edx, 12(%esi) + movl 64(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.11 +..B1.10: + movl %esi, %eax + addl $72, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.11: + call __stack_chk_fail@PLT + .align 16,0x90 + .type ctan,@function + .size ctan,.-ctan + .data +# -- End ctan + .text +# -- Begin ctanf + .text + .align 16,0x90 + .globl ctanf +ctanf: +# parameter 1: 48 + %esp +..B2.1: +..L3: + + pushl %ebx + subl $40, %esp + xorl %eax, %eax + movl %eax, 16(%esp) + movl %eax, 20(%esp) + movl %eax, 24(%esp) + movl %eax, 28(%esp) + movzwl 54(%esp), %eax + andl $32640, %eax + movl 52(%esp), %edx + cmpl $32640, %eax + movl 48(%esp), %ecx + movl %edx, 32(%esp) + movl %ecx, 36(%esp) + jl ..B2.3 +..B2.2: + testl $8388607, 52(%esp) + jne ..B2.4 +..B2.3: + movzbl 55(%esp), %eax + notl %eax + movzbl 35(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 35(%esp) +..B2.4: + addl $8, %esp + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + pushl 28(%esp) + pushl 28(%esp) + call ctanhf@PLT +..B2.10: + movl %eax, 16(%esp) + movl %eax, 28(%esp) + shrl $16, %eax + andl $32640, %eax + cmpl $32640, %eax + movl %edx, 20(%esp) + movl %edx, 24(%esp) + jl ..B2.6 +..B2.5: + testl $8388607, 16(%esp) + jne ..B2.7 +..B2.6: + movzbl 19(%esp), %eax + notl %eax + movzbl 31(%esp), %edx + andl $128, %eax + andl $127, %edx + orl %eax, %edx + movb %dl, 31(%esp) +..B2.7: + movl 24(%esp), %eax + movl 28(%esp), %edx + addl $40, %esp + popl %ebx + ret + .align 16,0x90 + .type ctanf,@function + .size ctanf,.-ctanf + .data +# -- End ctanf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ctanh.S b/external/sgx_libm/ia32/ctanh.S new file mode 100644 index 0000000000..6f34afcfcb --- /dev/null +++ b/external/sgx_libm/ia32/ctanh.S @@ -0,0 +1,565 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctanh.c" + .text +..TXTST0: +# -- Begin ctanh + .text + .align 16,0x90 + .globl ctanh +ctanh: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + fldz + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + movl %edx, 80(%esp) + fstl 64(%esp) + fstpl 72(%esp) +..B1.2: + fnstcw 50(%esp) +..B1.3: + movzwl 18(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %edx + jge ..B1.31 +..B1.4: + testl %edx, %edx + jle ..B1.54 +..B1.5: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + jge ..B1.32 +..B1.6: + cmpl $1032, %edx + jl ..B1.23 +..B1.7: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + movzbl 19(%ebp), %edx + andl $128, %edx + shrl $7, %edx + testl %ecx, %ecx + fldl ones@GOTOFF(%ebx,%edx,8) + fsub %st(1), %st + fstpl 64(%esp) + jne ..B1.15 +..B1.8: + testl $1048575, 24(%ebp) + jne ..B1.13 +..B1.9: + cmpl $0, 20(%ebp) + jne ..B1.13 +..B1.10: + fstp %st(0) + movzbl 27(%ebp), %edx + testl $128, %edx + jne ..B1.12 +..B1.11: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.12: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.13: + fldl 20(%ebp) + jmp ..B1.16 +..B1.15: + fldl 20(%ebp) + jne ..B1.19 +..B1.16: + movzbl 27(%ebp), %edx + testl $128, %edx + fadd %st(0), %st + fstpl 56(%esp) + jne ..B1.18 +..B1.17: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.22 +..B1.18: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.22 +..B1.19: + addl $-16, %esp + fstl (%esp) + fstpl 24(%esp) + fstpl 40(%esp) + call sin@PLT +..B1.104: + fldl 40(%esp) + fldl 24(%esp) + addl $16, %esp + fxch %st(2) + fstpl (%esp) + addl $-16, %esp + fxch %st(1) + fstpl (%esp) + fstpl 40(%esp) + call cos@PLT +..B1.103: + fldl 40(%esp) + addl $16, %esp + fldl (%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpl 16(%esp) + movzbl 23(%esp), %edx + testl $128, %edx + jne ..B1.21 +..B1.20: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.22 +..B1.21: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) +..B1.22: + fmul %st(0), %st + fstpl 56(%esp) + jmp ..B1.44 +..B1.23: + movzwl 50(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.53 +..B1.24: + orl $-64768, %ecx + movw %cx, 48(%esp) +..B1.25: + fldcw 48(%esp) +..B1.26: + movl $1, %edi +..B1.27: + fldl 12(%ebp) + addl $-32, %esp + lea 32(%esp), %edx + lea 44(%esp), %ecx + fstpt (%esp) + movl %edx, 12(%esp) + movl %ecx, 16(%esp) + call sinhcoshl@PLT +..B1.28: + fldl 20(%ebp) + lea 56(%esp), %edx + lea 68(%esp), %ecx + fstpt (%esp) + movl %edx, 12(%esp) + movl %ecx, 16(%esp) + call sincosl@PLT +..B1.106: + addl $32, %esp +..B1.29: + fldt (%esp) + testl %edi, %edi + fld %st(0) + fmul %st(1), %st + fldt 36(%esp) + fld %st(0) + fmul %st(1), %st + faddp %st, %st(2) + fldt 12(%esp) + fmulp %st, %st(3) + fxch %st(1) + fdivr %st, %st(2) + fxch %st(2) + fstpl 64(%esp) + fldt 24(%esp) + fmulp %st, %st(1) + fdivp %st, %st(1) + fstpl 72(%esp) + je ..B1.44 +..B1.30: + fldcw 50(%esp) + jmp ..B1.44 +..B1.31: + movzwl 26(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx +..B1.32: + cmpl $2047, %edx + je ..B1.62 +..B1.33: + cmpl $2047, %ecx + je ..B1.58 +..B1.34: + testl %edx, %edx + jne ..B1.43 +..B1.35: + testl $1048575, 16(%ebp) + jne ..B1.43 +..B1.36: + cmpl $0, 12(%ebp) + jne ..B1.43 +..B1.37: + testl %ecx, %ecx + jne ..B1.41 +..B1.38: + testl $1048575, 24(%ebp) + jne ..B1.41 +..B1.39: + cmpl $0, 20(%ebp) + jne ..B1.41 +..B1.40: + fldl 12(%ebp) + fstpl 64(%esp) + fldl 20(%ebp) + fstpl 72(%esp) + jmp ..B1.44 +..B1.41: + cmpl $2047, %ecx + jge ..B1.44 +..B1.42: + fldl 12(%ebp) + fstpl 64(%esp) + addl $-16, %esp + fldl 20(%ebp) + fstpl (%esp) + call tan@PLT +..B1.107: + addl $16, %esp + fstpl 72(%esp) + jmp ..B1.44 +..B1.43: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call tanh@PLT +..B1.108: + fldl 20(%ebp) + addl $16, %esp + fstpl 72(%esp) + fstpl 64(%esp) +..B1.44: + movzwl 70(%esp), %edx + testl $32752, %edx + jne ..B1.47 +..B1.45: + testl $1048575, 68(%esp) + jne ..B1.50 +..B1.46: + cmpl $0, 64(%esp) + jne ..B1.50 +..B1.47: + movzwl 78(%esp), %edx + testl $32752, %edx + jne ..B1.51 +..B1.48: + testl $1048575, 76(%esp) + jne ..B1.50 +..B1.49: + cmpl $0, 72(%esp) + je ..B1.51 +..B1.50: + fldl _DBL_MIN_NORMAL@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 56(%esp) +..B1.51: + movl 64(%esp), %edx + movl %edx, (%esi) + movl 68(%esp), %ecx + movl 72(%esp), %edi + movl 76(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 12(%esi) + movl 80(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.57 +..B1.52: + movl %esi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.53: + xorl %edi, %edi + jmp ..B1.27 +..B1.54: + testl $1048575, 16(%ebp) + jne ..B1.5 +..B1.55: + cmpl $0, 12(%ebp) + jne ..B1.5 + jmp ..B1.31 +..B1.57: + call __stack_chk_fail@PLT +..B1.58: + testl $1048575, 24(%ebp) + jne ..B1.61 +..B1.59: + cmpl $0, 20(%ebp) + jne ..B1.61 +..B1.60: + fldl 20(%ebp) + addl $-16, %esp + fstpl (%esp) + call tan@PLT +..B1.109: + addl $16, %esp + fstl 64(%esp) + fstpl 72(%esp) + jmp ..B1.44 +..B1.61: + fldl 20(%ebp) + fmul %st(0), %st + fstl 64(%esp) + fstpl 72(%esp) + jmp ..B1.44 +..B1.62: + testl $1048575, 16(%ebp) + jne ..B1.80 +..B1.63: + cmpl $0, 12(%ebp) + jne ..B1.112 +..B1.64: + movzbl 19(%ebp), %edx + andl $128, %edx + shrl $7, %edx + testl %ecx, %ecx + fldl ones@GOTOFF(%ebx,%edx,8) + fstpl 64(%esp) + jne ..B1.70 +..B1.65: + testl $1048575, 24(%ebp) + jne ..B1.71 +..B1.66: + cmpl $0, 20(%ebp) + jne ..B1.71 +..B1.67: + movzbl 27(%ebp), %edx + testl $128, %edx + jne ..B1.69 +..B1.68: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.69: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.70: + cmpl $2047, %ecx + je ..B1.92 +..B1.71: + cmpl $1023, %ecx + jge ..B1.77 +..B1.72: + testl %ecx, %ecx + jne ..B1.74 +..B1.73: + fldl 20(%ebp) + fadd %st(0), %st + fstpl 56(%esp) +..B1.74: + movzbl 27(%ebp), %edx + testl $128, %edx + jne ..B1.76 +..B1.75: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.76: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.77: + fldl 20(%ebp) + fstl 8(%esp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.111: + addl $16, %esp + fstpl (%esp) + addl $-16, %esp + fldl 24(%esp) + fstpl (%esp) + call cos@PLT +..B1.110: + addl $16, %esp + fldl (%esp) + fmulp %st, %st(1) + fstpl 16(%esp) + movzbl 23(%esp), %edx + testl $128, %edx + jne ..B1.79 +..B1.78: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.79: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.80: + jne ..B1.82 +..B1.81: + cmpl $0, 12(%ebp) + je ..B1.33 +..B1.82: + fldl 12(%ebp) + testl %ecx, %ecx + fmul %st(0), %st + fstl 64(%esp) + jne ..B1.90 +..B1.83: + testl $1048575, 24(%ebp) + jne ..B1.91 +..B1.84: + cmpl $0, 20(%ebp) + jne ..B1.91 +..B1.85: + fstp %st(0) + movzbl 27(%ebp), %edx + testl $128, %edx + jne ..B1.87 +..B1.86: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.87: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.90: + cmpl $2047, %ecx + je ..B1.98 +..B1.91: + fstpl 72(%esp) + jmp ..B1.44 +..B1.92: + testl $1048575, 24(%ebp) + jne ..B1.97 +..B1.93: + cmpl $0, 20(%ebp) + jne ..B1.97 +..B1.94: + movzbl 27(%ebp), %edx + testl $128, %edx + jne ..B1.96 +..B1.95: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.96: + fldl _DBL_NZERO@GOTOFF(%ebx) + fstpl 72(%esp) + jmp ..B1.44 +..B1.97: + fldl _DBL_PZERO@GOTOFF(%ebx) + fstpl 72(%esp) + fldl 20(%ebp) + fmul %st(0), %st + fstpl 56(%esp) + jmp ..B1.44 +..B1.98: + testl $1048575, 24(%ebp) + jne ..B1.100 +..B1.99: + cmpl $0, 20(%ebp) + je ..B1.91 +..B1.100: + fstp %st(0) + fldl 20(%ebp) + fmul %st(0), %st + fstpl 72(%esp) + jmp ..B1.44 +..B1.112: + testl $1048575, 16(%ebp) + jne ..B1.82 + jmp ..B1.81 + .align 16,0x90 + .type ctanh,@function + .size ctanh,.-ctanh + .data +# -- End ctanh + .section .rodata, "a" + .align 16 + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .space 8, 0x00 # pad + .align 16 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 16 +_DBL_PZERO: + .long 0 + .long 0 + .type _DBL_PZERO,@object + .size _DBL_PZERO,8 + .space 8, 0x00 # pad + .align 16 +_DBL_NZERO: + .long 0 + .long -2147483648 + .type _DBL_NZERO,@object + .size _DBL_NZERO,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ctanhf.S b/external/sgx_libm/ia32/ctanhf.S new file mode 100644 index 0000000000..e859a5cccd --- /dev/null +++ b/external/sgx_libm/ia32/ctanhf.S @@ -0,0 +1,470 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctanhf.c" + .text +..TXTST0: +# -- Begin ctanhf + .text + .align 16,0x90 + .globl ctanhf +ctanhf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + fldz + fsts 16(%esp) + fsts 36(%esp) + fstps 40(%esp) +..B1.2: + fnstcw 30(%esp) +..B1.3: + movzwl 10(%ebp), %eax + andl $32640, %eax + shrl $7, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %eax + jge ..B1.28 +..B1.4: + testl %eax, %eax + jle ..B1.46 +..B1.5: + movzwl 14(%ebp), %ecx + andl $32640, %ecx + shrl $7, %ecx + cmpl $255, %ecx + jge ..B1.29 +..B1.6: + cmpl $133, %eax + jl ..B1.21 +..B1.7: + flds .L_2il0floatpacket.6@GOTOFF(%ebx) + movzbl 11(%ebp), %eax + andl $128, %eax + shrl $7, %eax + testl %ecx, %ecx + flds ones@GOTOFF(%ebx,%eax,4) + fsub %st(1), %st + fstps 36(%esp) + jne ..B1.13 +..B1.8: + testl $8388607, 12(%ebp) + jne ..B1.12 +..B1.9: + fstp %st(0) + movzbl 15(%ebp), %eax + testl $128, %eax + jne ..B1.11 +..B1.10: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.11: + movl $-2147483648, 40(%esp) + jmp ..B1.39 +..B1.12: + flds 12(%ebp) + jmp ..B1.14 +..B1.13: + flds 12(%ebp) + jne ..B1.17 +..B1.14: + movzbl 15(%ebp), %eax + testl $128, %eax + fadd %st(0), %st + fstps 32(%esp) + jne ..B1.19 +..B1.15: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.20 +..B1.17: + addl $-16, %esp + fsts (%esp) + fstps 24(%esp) + fstps 28(%esp) + call sinf@PLT +..B1.86: + flds 28(%esp) + flds 24(%esp) + addl $16, %esp + fxch %st(2) + fstps (%esp) + addl $-16, %esp + fxch %st(1) + fstps (%esp) + fstps 28(%esp) + call cosf@PLT +..B1.85: + flds 28(%esp) + addl $16, %esp + flds (%esp) + fmulp %st, %st(2) + fxch %st(1) + fstps 4(%esp) + movzbl 7(%esp), %eax + testl $128, %eax + jne ..B1.19 +..B1.18: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.20 +..B1.19: + movl $-2147483648, 40(%esp) +..B1.20: + fmul %st(0), %st + fstps 32(%esp) + jmp ..B1.39 +..B1.21: + movzwl 30(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.22: + orl $-64768, %edx + movw %dx, 28(%esp) +..B1.23: + fldcw 28(%esp) +..B1.24: + movl $1, %esi +..B1.25: + flds 8(%ebp) + addl $-16, %esp + lea 16(%esp), %eax + lea 24(%esp), %edx + fstpl (%esp) + movl %eax, 8(%esp) + movl %edx, 12(%esp) + call sinhcosh@PLT +..B1.87: + addl $16, %esp +..B1.26: + flds 12(%ebp) + fsts 24(%esp) + addl $-16, %esp + fstpl (%esp) + call sin@PLT +..B1.89: + addl $16, %esp + fstpl 16(%esp) + addl $-16, %esp + flds 40(%esp) + fstpl (%esp) + call cos@PLT +..B1.88: + addl $16, %esp + fld %st(0) + testl %esi, %esi + fmul %st(1), %st + fxch %st(1) + fmull 16(%esp) + fldl (%esp) + fld %st(0) + fmul %st(1), %st + faddp %st, %st(3) + fxch %st(1) + fdiv %st(2), %st + fstps 40(%esp) + fmull 8(%esp) + fdivp %st, %st(1) + fstps 36(%esp) + je ..B1.39 +..B1.27: + fldcw 30(%esp) + jmp ..B1.39 +..B1.28: + movzwl 14(%ebp), %ecx + andl $32640, %ecx + shrl $7, %ecx +..B1.29: + cmpl $255, %eax + je ..B1.51 +..B1.30: + cmpl $255, %ecx + je ..B1.48 +..B1.31: + testl %eax, %eax + jne ..B1.38 +..B1.32: + testl $8388607, 8(%ebp) + jne ..B1.38 +..B1.33: + testl %ecx, %ecx + jne ..B1.36 +..B1.34: + testl $8388607, 12(%ebp) + jne ..B1.36 +..B1.35: + movl 8(%ebp), %eax + movl 12(%ebp), %edx + movl %eax, 36(%esp) + movl %edx, 40(%esp) + jmp ..B1.39 +..B1.36: + cmpl $255, %ecx + jge ..B1.39 +..B1.37: + movl 8(%ebp), %eax + movl %eax, 36(%esp) + addl $-16, %esp + movl 12(%ebp), %edx + movl %edx, (%esp) + call tanf@PLT +..B1.90: + addl $16, %esp + fstps 40(%esp) + jmp ..B1.39 +..B1.38: + addl $-16, %esp + movl 8(%ebp), %eax + movl %eax, (%esp) + call tanhf@PLT +..B1.91: + movl 12(%ebp), %eax + addl $16, %esp + fstps 36(%esp) + movl %eax, 40(%esp) +..B1.39: + movzwl 38(%esp), %eax + testl $32640, %eax + jne ..B1.41 +..B1.40: + testl $8388607, 36(%esp) + jne ..B1.43 +..B1.41: + movzwl 42(%esp), %eax + testl $32640, %eax + jne ..B1.44 +..B1.42: + testl $8388607, 40(%esp) + je ..B1.44 +..B1.43: + flds .L_2il0floatpacket.6@GOTOFF(%ebx) + fmul %st(0), %st + fstps 32(%esp) +..B1.44: + movl 36(%esp), %eax + movl 40(%esp), %edx + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + xorl %esi, %esi + jmp ..B1.25 +..B1.46: + testl $8388607, 8(%ebp) + jne ..B1.5 + jmp ..B1.28 +..B1.48: + testl $8388607, 12(%ebp) + jne ..B1.50 +..B1.49: + addl $-16, %esp + movl 12(%ebp), %eax + movl %eax, (%esp) + call tanf@PLT +..B1.92: + addl $16, %esp + fsts 36(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.50: + flds 12(%ebp) + fmul %st(0), %st + fsts 36(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.51: + testl $8388607, 8(%ebp) + jne ..B1.67 +..B1.52: + movzbl 11(%ebp), %eax + andl $128, %eax + shrl $7, %eax + testl %ecx, %ecx + movl ones@GOTOFF(%ebx,%eax,4), %edx + movl %edx, 36(%esp) + jne ..B1.57 +..B1.53: + testl $8388607, 12(%ebp) + jne ..B1.58 +..B1.54: + movzbl 15(%ebp), %eax + testl $128, %eax + jne ..B1.11 +..B1.55: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.57: + cmpl $255, %ecx + je ..B1.76 +..B1.58: + cmpl $127, %ecx + jge ..B1.64 +..B1.59: + testl %ecx, %ecx + jne ..B1.61 +..B1.60: + flds 12(%ebp) + fadd %st(0), %st + fstps 32(%esp) +..B1.61: + movzbl 15(%ebp), %eax + testl $128, %eax + jne ..B1.11 +..B1.62: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.64: + addl $-16, %esp + movl 12(%ebp), %esi + movl %esi, (%esp) + call sinf@PLT +..B1.94: + addl $16, %esp + fstps (%esp) + addl $-16, %esp + movl %esi, (%esp) + call cosf@PLT +..B1.93: + addl $16, %esp + flds (%esp) + fmulp %st, %st(1) + fstps 4(%esp) + movzbl 7(%esp), %eax + testl $128, %eax + jne ..B1.11 +..B1.65: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.67: + je ..B1.30 +..B1.68: + flds 8(%ebp) + testl %ecx, %ecx + fmul %st(0), %st + fsts 36(%esp) + jne ..B1.74 +..B1.69: + testl $8388607, 12(%ebp) + jne ..B1.75 +..B1.70: + fstp %st(0) + movzbl 15(%ebp), %eax + testl $128, %eax + jne ..B1.11 +..B1.71: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.74: + cmpl $255, %ecx + je ..B1.81 +..B1.75: + fstps 40(%esp) + jmp ..B1.39 +..B1.76: + testl $8388607, 12(%ebp) + jne ..B1.80 +..B1.77: + movzbl 15(%ebp), %eax + testl $128, %eax + jne ..B1.11 +..B1.78: + flds 16(%esp) + fstps 40(%esp) + jmp ..B1.39 +..B1.80: + flds 16(%esp) + fstps 40(%esp) + flds 12(%ebp) + fmul %st(0), %st + fstps 32(%esp) + jmp ..B1.39 +..B1.81: + testl $8388607, 12(%ebp) + je ..B1.75 +..B1.82: + fstp %st(0) + flds 12(%ebp) + fmul %st(0), %st + fstps 40(%esp) + jmp ..B1.39 + .align 16,0x90 + .type ctanhf,@function + .size ctanhf,.-ctanhf + .data +# -- End ctanhf + .section .rodata, "a" + .align 16 + .align 16 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +.L_2il0floatpacket.6: + .long 0x00800000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,4 + .align 4 +.L_2il0floatpacket.7: + .long 0x80000000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ctanhl.S b/external/sgx_libm/ia32/ctanhl.S new file mode 100644 index 0000000000..3d8f2c4a0e --- /dev/null +++ b/external/sgx_libm/ia32/ctanhl.S @@ -0,0 +1,975 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctanhl.c" + .text +..TXTST0: +# -- Begin ctanhl + .text + .align 16,0x90 + .globl ctanhl +ctanhl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $308, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 304(%esp) + fstpt 280(%esp) + fldt 280(%esp) + fstpt 292(%esp) +..B1.2: + fnstcw 94(%esp) +..B1.3: + movzwl 94(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.81 +..B1.4: + orl $-64768, %ecx + movw %cx, 92(%esp) +..B1.5: + fldcw 92(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzwl 20(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.50 +..B1.8: + movzwl 32(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.50 +..B1.9: + cmpl $0, 16(%ebp) + jne ..B1.11 +..B1.10: + cmpl $0, 12(%ebp) + je ..B1.50 +..B1.11: + cmpl $16396, %edx + jl ..B1.22 +..B1.12: + fldt 24+_CONSTANTS@GOTOFF(%ebx) + movzbl 21(%ebp), %eax + andl $128, %eax + shrl $7, %eax + cmpl $0, 28(%ebp) + lea (,%eax,8), %edx + lea (%edx,%eax,4), %edx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + fsub %st(1), %st + fstpt 280(%esp) + jne ..B1.14 +..B1.13: + cmpl $0, 24(%ebp) + je ..B1.15 +..B1.14: + fmul %st(0), %st + fstpt 292(%esp) + jmp ..B1.16 +..B1.15: + fstp %st(0) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fstpt 292(%esp) +..B1.16: + testl %ecx, %ecx + jle ..B1.74 +..B1.17: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + call tanl@PLT +..B1.84: + addl $16, %esp + fstpt 172(%esp) + movzbl 301(%esp), %edx + movzbl 181(%esp), %ecx + andl $127, %edx + andl $-128, %ecx + orl %ecx, %edx +..B1.18: + movb %dl, 301(%esp) + testl %edi, %edi + je ..B1.20 +..B1.19: + fldcw 94(%esp) +..B1.20: + movl 280(%esp), %edx + movl %edx, (%esi) + movl 292(%esp), %edx + movl %edx, 12(%esi) + movl 296(%esp), %edx + movl %edx, 16(%esi) + movl 284(%esp), %ecx + movl 288(%esp), %edi + movl 300(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 304(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.73 +..B1.21: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.22: + fldt 12(%ebp) + addl $-16, %esp + lea 224(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + call __libm_coshl_k80 +..B1.85: + addl $16, %esp +..B1.23: + fldt 48+_CONSTANTS@GOTOFF(%ebx) + fstpt 64(%esp) + fldt 64(%esp) + faddp %st, %st(1) + fstpt (%esp) + fldt 208(%esp) + fld %st(0) + fldt 220(%esp) + movzwl 20(%ebp), %ecx + fadd %st, %st(1) + andl $32767, %ecx + fxch %st(1) + fsub %st, %st(2) + movl (%esp), %edx + cmpl $16183, %ecx + movl %edx, 76(%esp) + fxch %st(2) + fsubrp %st, %st(1) + fstpt 40(%esp) + jge ..B1.25 +..B1.24: + fldt 12(%ebp) + lea 196(%esp), %eax + fldt 36+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt -12(%eax) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + movzwl -4(%eax), %ecx + movl %ecx, %edx + andl $32767, %edx + andl $-32768, %ecx + addl $-16639, %edx + orl $-49153, %ecx + fstpt (%eax) + movl %edx, 52(%esp) + movw %cx, -4(%eax) + jmp ..B1.27 +..B1.25: + fldt 12(%ebp) + addl $-16, %esp + lea 200(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + fstpt 32(%esp) + call __libm_sinhl_k80 +..B1.86: + fldt 32(%esp) + addl $16, %esp +..B1.26: + fldt 64(%esp) + lea 196(%esp), %eax + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + movl (%esp), %edx + movl %edx, 52(%esp) +..B1.27: + fldt 184(%esp) + fld %st(0) + fldt (%eax) + fadd %st, %st(1) + fxch %st(1) + fstpt 28(%esp) + fldt 28(%esp) + addl $-16, %esp + fsubp %st, %st(2) + fsubp %st, %st(1) + fldt 24(%ebp) + fstpt (%esp) + lea 248(%esp), %edx + movl %edx, 12(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt -104(%edx) + call __libm_cosl_k80 +..B1.87: + fldt 144(%esp) + fldt 32(%esp) + addl $16, %esp +..B1.28: + fldt 232(%esp) + fld %st(0) + fldt 244(%esp) + movl 52(%esp), %ecx + fadd %st, %st(1) + movzwl 36(%esp), %edx + fxch %st(1) + fsub %st, %st(2) + andl $32767, %edx + fxch %st(2) + fsubrp %st, %st(1) + fxch %st(1) + fmul %st(4), %st + fxch %st(1) + fmulp %st, %st(4) + addl %ecx, 76(%esp) + addl %ecx, %edx + fxch %st(3) + fstpt (%esp) + fldt (%esp) + fld %st(1) + fldt 24+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(5) + fxch %st(4) + fstpt 144(%esp) + fldt 144(%esp) + fstpt 16(%esp) + fldt 28(%esp) + fld %st(0) + fld %st(1) + fxch %st(2) + fstpt 96(%esp) + fldt 96(%esp) + fldt 96+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + movzwl 24(%esp), %ecx + fxch %st(2) + fsub %st, %st(3) + andl $32767, %ecx + fsubp %st, %st(3) + fsub %st(2), %st + fadd %st(5), %st + fld %st(4) + fmul %st(2), %st + fsub %st, %st(7) + fsubp %st, %st(7) + fxch %st(4) + fsub %st(6), %st + fxch %st(1) + fstpt 80(%esp) + fld %st(1) + lea 64(%ecx), %eax + fmul %st(6), %st + cmpl %eax, %edx + fldt 40(%esp) + faddp %st, %st(2) + fld %st(1) + fmul %st(5), %st + fxch %st(7) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(6) + fmulp %st, %st(1) + faddp %st, %st(4) + fld %st(3) + fadd %st(2), %st + fstpt 112(%esp) + fldt 112(%esp) + fsubp %st, %st(2) + fxch %st(1) + fsubrp %st, %st(3) + fldt 144(%esp) + jge ..B1.33 +..B1.29: + addl $-64, %ecx + cmpl %ecx, %edx + jle ..B1.100 +..B1.30: + movl 52(%esp), %edx + fstpt 28(%esp) + fstpt 40(%esp) + lea (%edx,%edx), %ecx + movl %ecx, 12(%esp) + movzwl 36(%esp), %ecx + movl %ecx, %eax + subl %edx, %ecx + andl $-32768, %eax + andl $32767, %ecx + orl %ecx, %eax + movzwl 8(%esp), %ecx + andl $32767, %ecx + subl %edx, %ecx + movw %ax, 36(%esp) + testl %ecx, %ecx + jle ..B1.32 +..B1.31: + fldt 28(%esp) + movzwl 48(%esp), %edx + movl %edx, %ecx + subl 52(%esp), %edx + andl $-32768, %ecx + andl $32767, %edx + orl %edx, %ecx + movw %cx, 48(%esp) + fxch %st(1) + jmp ..B1.36 +..B1.32: + fldt 28(%esp) + fxch %st(1) + jmp ..B1.36 +..B1.33: + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 40(%esp) + fldt 40(%esp) + jl ..B1.35 +..B1.34: + fstp %st(2) + fstp %st(0) + movl 52(%esp), %edx + lea (%edx,%edx), %ecx + movl %ecx, 12(%esp) + fxch %st(1) + jmp ..B1.36 +..B1.35: + fstp %st(3) + fstpt 96(%esp) + movl $0, 12(%esp) +..B1.36: + addl $-32, %esp + lea 288(%esp), %edx + movl %edx, (%esp) + fldt 128(%esp) + fstpt 4(%esp) + fxch %st(1) + fstpt 16(%esp) + fstpt -128(%edx) + fstpt -112(%edx) + call __libm_hypot2l_k80 +..B1.88: + fldt 176(%esp) + fldt 160(%esp) + addl $32, %esp +..B1.37: + fldt 64(%esp) + movzwl 8+_CONSTANTS@GOTOFF(%ebx), %edx + movl %edx, %eax + andl $-32768, %eax + faddp %st, %st(3) + fxch %st(2) + fstpt 52(%esp) + fldt _CONSTANTS@GOTOFF(%ebx) + movl 52(%esp), %ecx + addl %edx, %ecx + andl $32767, %ecx + fstpt 172(%esp) + orl %ecx, %eax + fldt 256(%esp) + fldt 268(%esp) + fldt 96(%esp) + fldt 28(%esp) + fldt 84+_CONSTANTS@GOTOFF(%ebx) + movw %ax, 180(%esp) + fmul %st, %st(2) + fxch %st(6) + fmulp %st, %st(2) + fmulp %st, %st(5) + fldt 172(%esp) + fmul %st, %st(3) + fxch %st(3) + fstpt 144(%esp) + fldt 144(%esp) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + fstpt 256(%esp) + fldt 256(%esp) + fldt 40(%esp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fstpt 268(%esp) + fldt 268(%esp) + fldt 112(%esp) + fld %st(0) + fdiv %st(4), %st + fstpt 160(%esp) + fldt 160(%esp) + fldt 72+_CONSTANTS@GOTOFF(%ebx) + fld %st(0) + fmul %st(2), %st + fld %st(0) + fsubr %st(3), %st + faddp %st, %st(1) + fld %st(0) + fsubrp %st, %st(3) + fxch %st(1) + fstpt 128(%esp) + fldt 128(%esp) + fmul %st(6), %st + fld %st(6) + fsub %st(1), %st + faddp %st, %st(1) + fld %st(0) + fsubrp %st, %st(7) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fmul %st(7), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fxch %st(4) + fsubrp %st, %st(1) + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 160(%esp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(0) + fldt 144(%esp) + addl $-32, %esp + fdivrp %st, %st(3) + fadd %st(2), %st + fstpt (%esp) + fldt (%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 12(%esp) + movl 108(%esp), %edx + subl 44(%esp), %edx + movl %edx, 24(%esp) + call __libm_scalbl_k80 +..B1.89: + addl $32, %esp +..B1.38: + fstpt 280(%esp) + cmpl $0, 28(%ebp) + jne ..B1.44 +..B1.39: + cmpl $0, 24(%ebp) + jne ..B1.44 +..B1.40: + fldt 24(%ebp) + testl %edi, %edi + fstpt 292(%esp) + je ..B1.42 +..B1.41: + fldcw 94(%esp) +..B1.42: + movl 280(%esp), %edx + movl %edx, (%esi) + movl 292(%esp), %edx + movl %edx, 12(%esi) + movl 296(%esp), %edx + movl %edx, 16(%esi) + movl 284(%esp), %ecx + movl 288(%esp), %edi + movl 300(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 304(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.73 +..B1.43: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.44: + movzwl 32(%ebp), %edx + andl $32767, %edx + cmpl $16183, %edx + jge ..B1.46 +..B1.45: + fldt 24(%ebp) + fldt 36+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 52(%esp) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + movzwl 60(%esp), %edx + movl %edx, %ecx + andl $-32768, %edx + andl $32767, %ecx + orl $-49153, %edx + addl $-16639, %ecx + movw %dx, 60(%esp) + fstpt 64(%esp) + fldt 64(%esp) + fldt 52(%esp) + fxch %st(1) + jmp ..B1.48 +..B1.46: + fldt 24(%ebp) + addl $-16, %esp + lea 68(%esp), %edx + fstpt (%esp) + movl %edx, 12(%esp) + call __libm_sinl_k80 +..B1.90: + addl $16, %esp +..B1.47: + fldt 52(%esp) + xorl %ecx, %ecx + fmul %st(1), %st + fstpt 52(%esp) + fldt 52(%esp) + fldt 64(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) +..B1.48: + fldt 80(%esp) + fld %st(0) + fld %st(3) + fadd %st(3), %st + fmul %st, %st(1) + fsub %st, %st(4) + fxch %st(4) + fsubrp %st, %st(3) + fld %st(3) + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fldt 16(%esp) + fmul %st, %st(2) + fld %st(0) + fsubr %st(3), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fxch %st(1) + fsub %st(2), %st + fxch %st(2) + fstpt 28(%esp) + fldt 28(%esp) + fldt (%esp) + faddp %st, %st(3) + fld %st(2) + fmul %st(5), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + fstpt 40(%esp) + fldt 256(%esp) + fld %st(0) + fdivr %st(2), %st + fld %st(1) + fldt 128(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + fsubr %st(4), %st + faddp %st, %st(1) + fld %st(0) + fsubr %st(4), %st + fxch %st(2) + fmul %st(5), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fmul %st(2), %st + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fld %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt 268(%esp) + fmul %st(3), %st + fsubrp %st, %st(2) + fldt 256(%esp) + fdivrp %st, %st(2) + addl $-32, %esp + fadd %st(1), %st + fstpt (%esp) + fldt (%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%esp) + subl 44(%esp), %ecx + movl %ecx, 24(%esp) + call __libm_scalbl_k80 +..B1.91: + addl $32, %esp +..B1.49: + fstpt 292(%esp) + jmp ..B1.69 +..B1.50: + movl 28(%ebp), %eax + testl %eax, %eax + jne ..B1.53 +..B1.51: + cmpl $0, 24(%ebp) + jne ..B1.53 +..B1.52: + movl 16(%ebp), %ecx + jmp ..B1.55 +..B1.53: + movzwl 32(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + jge ..B1.60 +..B1.54: + movl 16(%ebp), %ecx + cmpl $32767, %edx + je ..B1.77 +..B1.55: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + movl %ecx, 16(%esp) + call tanhl@PLT +..B1.92: + movl 16(%esp), %ecx + addl $16, %esp + fstpt 280(%esp) + testl %ecx, %ecx + jne ..B1.57 +..B1.56: + cmpl $0, 12(%ebp) + je ..B1.59 +..B1.57: + movzwl 32(%ebp), %edx + testl $32767, %edx + jle ..B1.76 +..B1.58: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + call tanl@PLT +..B1.93: + fldt 60+_CONSTANTS@GOTOFF(%ebx) + addl $16, %esp + fmulp %st, %st(1) + fstpt 292(%esp) + jmp ..B1.69 +..B1.59: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + call tanl@PLT +..B1.94: + addl $16, %esp + fstpt 292(%esp) + jmp ..B1.69 +..B1.60: + cmpl $32767, %edx + jge ..B1.62 +..B1.61: + fldt 24(%ebp) + addl $-16, %esp + fstpt (%esp) + call tanl@PLT +..B1.95: + addl $16, %esp + fstpt 280(%esp) + fldt 280(%esp) + fstpt 292(%esp) + jmp ..B1.69 +..B1.62: + cmpl $-2147483648, 16(%ebp) + jne ..B1.64 +..B1.63: + cmpl $0, 12(%ebp) + je ..B1.65 +..B1.64: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call tanhl@PLT +..B1.96: + fldt 24(%ebp) + addl $16, %esp + fmul %st(1), %st + fstpt 292(%esp) + fstpt 280(%esp) + jmp ..B1.69 +..B1.65: + cmpl $-2147483648, %eax + jne ..B1.67 +..B1.66: + cmpl $0, 24(%ebp) + je ..B1.68 +..B1.67: + fldt 24(%ebp) + addl $-16, %esp + fmul %st(0), %st + fstpt 24(%ebp) + fldt 12(%ebp) + fstpt (%esp) + call tanhl@PLT +..B1.97: + fldt 60+_CONSTANTS@GOTOFF(%ebx) + addl $16, %esp + fstpt 292(%esp) + fstpt 280(%esp) + jmp ..B1.69 +..B1.68: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call tanhl@PLT +..B1.98: + fldt 60+_CONSTANTS@GOTOFF(%ebx) + addl $16, %esp + movzbl 33(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + fxch %st(1) + fstpt 280(%esp) + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + fldt _CONSTANTS@GOTOFF(%ebx,%edx) + fmulp %st, %st(1) + fstpt 292(%esp) +..B1.69: + testl %edi, %edi + je ..B1.71 +..B1.70: + fldcw 94(%esp) +..B1.71: + movl 280(%esp), %edx + movl %edx, (%esi) + movl 292(%esp), %edx + movl %edx, 12(%esi) + movl 296(%esp), %edx + movl %edx, 16(%esi) + movl 284(%esp), %ecx + movl 288(%esp), %edi + movl 300(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 304(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.73 +..B1.72: + movl %esi, %eax + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.73: + call __stack_chk_fail@PLT +..B1.74: + movzbl 301(%esp), %edx + movzbl 33(%ebp), %ecx + andl $127, %edx + andl $-128, %ecx + orl %ecx, %edx + jmp ..B1.18 +..B1.76: + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fldt 24(%ebp) + fmulp %st, %st(1) + fstpt 292(%esp) + jmp ..B1.69 +..B1.77: + cmpl $-2147483648, %ecx + jne ..B1.60 +..B1.78: + cmpl $0, 12(%ebp) + jne ..B1.60 +..B1.79: + fldt 12(%ebp) + addl $-16, %esp + fstpt (%esp) + call tanhl@PLT +..B1.99: + addl $16, %esp + fstpt 280(%esp) + jmp ..B1.57 +..B1.81: + xorl %edi, %edi + jmp ..B1.7 +..B1.100: + cmpl %eax, %edx + jmp ..B1.33 + .align 16,0x90 + .type ctanhl,@function + .size ctanhl,.-ctanhl + .data +# -- End ctanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 32768 + .word 16415 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .word 0 + .word 16384 + .word 0 + .word 32768 + .word 16416 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,108 + .data + .hidden __libm_sinl_k80 + .hidden __libm_cosl_k80 + .hidden __libm_sinhl_k80 + .hidden __libm_coshl_k80 + .hidden __libm_hypot2l_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ctanl.S b/external/sgx_libm/ia32/ctanl.S new file mode 100644 index 0000000000..0d6e6e8894 --- /dev/null +++ b/external/sgx_libm/ia32/ctanl.S @@ -0,0 +1,210 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctanl.c" + .text +..TXTST0: +# -- Begin ctanl + .text + .align 16,0x90 + .globl ctanl +ctanl: +# parameter 1: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + movl 8(%ebp), %esi + xorl %esp, %edx + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + movl %edx, 100(%esp) + fstpt 4(%esp) + fldt 4(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + fldt 28(%esp) + fstpt 40(%esp) + fldt 40(%esp) + fstpt 52(%esp) + fldt 52(%esp) + fstpt 64(%esp) +..B1.2: + fnstcw 2(%esp) +..B1.3: + movzwl 2(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.4: + orl $-64768, %ecx + movw %cx, (%esp) +..B1.5: + fldcw (%esp) +..B1.6: + movl $1, %edi +..B1.7: + fldt 24(%ebp) + movzwl 32(%ebp), %edx + andl $32767, %edx + fstpt 52(%esp) + cmpl $32767, %edx + fldt 12(%ebp) + fstpt 64(%esp) + jl ..B1.10 +..B1.8: + cmpl $-2147483648, 28(%ebp) + jne ..B1.11 +..B1.9: + cmpl $0, 24(%ebp) + jne ..B1.11 +..B1.10: + movzbl 33(%ebp), %ecx + notl %ecx + movzbl 61(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 61(%esp) +..B1.11: + addl $-32, %esp + lea 108(%esp), %ecx + movl %ecx, (%esp) + lea 4(%esp), %edx + movl -24(%ecx), %ecx + movl %ecx, (%edx) + movl 88(%esp), %ecx + movl %ecx, 4(%edx) + movl 92(%esp), %ecx + movl %ecx, 8(%edx) + movl 96(%esp), %ecx + movl %ecx, 12(%edx) + movl 100(%esp), %ecx + movl %ecx, 16(%edx) + movl 104(%esp), %ecx + movl %ecx, 20(%edx) + call ctanhl@PLT +..B1.23: + addl $28, %esp + fldt 76(%esp) + movzwl 84(%esp), %edx + andl $32767, %edx + fstpt 4(%esp) + fldt 4(%esp) + cmpl $32767, %edx + fstpt 40(%esp) + fldt 88(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 28(%esp) + jl ..B1.14 +..B1.12: + cmpl $-2147483648, 8(%esp) + jne ..B1.15 +..B1.13: + cmpl $0, 4(%esp) + jne ..B1.15 +..B1.14: + movzbl 13(%esp), %ecx + notl %ecx + movzbl 49(%esp), %edx + andl $128, %ecx + andl $127, %edx + orl %ecx, %edx + movb %dl, 49(%esp) +..B1.15: + testl %edi, %edi + je ..B1.17 +..B1.16: + fldcw 2(%esp) +..B1.17: + movl 28(%esp), %edx + movl %edx, (%esi) + movl 40(%esp), %edx + movl %edx, 12(%esi) + movl 44(%esp), %edx + movl %edx, 16(%esi) + movl 32(%esp), %ecx + movl 36(%esp), %edi + movl 48(%esp), %edx + movl %ecx, 4(%esi) + movl %edi, 8(%esi) + movl %edx, 20(%esi) + movl 100(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.19 +..B1.18: + movl %esi, %eax + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B1.19: + call __stack_chk_fail@PLT +..B1.20: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type ctanl,@function + .size ctanl,.-ctanl + .data +# -- End ctanl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/dpml_ux_bessel.S b/external/sgx_libm/ia32/dpml_ux_bessel.S new file mode 100644 index 0000000000..1f582af9a9 --- /dev/null +++ b/external/sgx_libm/ia32/dpml_ux_bessel.S @@ -0,0 +1,7116 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_bessel.c" + .text +..TXTST0: +# -- Begin __dpml_ux_bessel__ + .text + .align 16,0x90 +__dpml_ux_bessel__: +# parameter 1: %eax +# parameter 2: 196 + %esp +# parameter 3: 204 + %esp +# parameter 4: %edx +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $172, %esp + movl %eax, %ebp + movl %edx, 44(%esp) + movl $2, %edx + movl %gs:20, %ecx + movl 196(%esp), %esi + xorl %esp, %ecx + subl %edx, %esi + movl %ecx, 168(%esp) + movl $0, %ecx + movl 200(%esp), %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + sbbl %ecx, %edi + jge ..B1.28 +..B1.2: + movl 204(%esp), %edi + movl 196(%esp), %esi + movl 12(%ebp), %ecx + movl %ecx, 40(%esp) + movl 4(%ebp), %ecx + lea (%esi,%edi), %esi + movl 8(%ebp), %edx + lea (%esi,%esi,2), %esi + cmpl $5, %ecx + jle ..B1.20 +..B1.72: + lea __bessel_x_table@GOTOFF(%ebx), %edi +..B1.3: + xorl %ecx, %ecx + lea 144(%esp), %edx + addl $20, %esp + pushl %edx + pushl %ecx + pushl $2 + pushl %ebp + pushl %ecx + call __dpml_divide__ +..B1.4: + movl 196(%esp), %edx + orl 200(%esp), %edx + jne ..B1.6 +..B1.5: + movl $10, 32(%esp) + lea 18168(%edi), %ecx + addl $18504, %edi + jmp ..B1.7 +..B1.6: + movl $9, 32(%esp) + lea 18872(%edi), %ecx + addl $19208, %edi +..B1.7: + addl $28, %esp + lea 20(%esp), %edx + pushl %edx + pushl $268435456 + pushl $68 + pushl $0 + pushl $9 + pushl %ecx + lea 140(%esp), %ecx + pushl %ecx + call __dpml_evaluate_rational__ +..B1.8: + xorl %ecx, %ecx + lea 72(%esp), %edx + addl $28, %esp + pushl %edx + pushl %ecx + pushl $70 + pushl %ecx + pushl 20(%esp) + pushl %edi + lea 140(%esp), %esi + pushl %esi + call __dpml_evaluate_rational__ +..B1.9: + movl 200(%esp), %edi + movl 196(%esp), %esi + lea (%edi,%edi), %ecx + lea (%esi,%esi), %edx + shrl $31, %esi + orl %ecx, %esi + movl $1, %ecx + xorl %eax, %eax + subl %edx, %ecx + movl $0, %edx + lea 96(%esp), %edi + sbbl %esi, %eax + subl 204(%esp), %ecx + sbbl 208(%esp), %eax + addl $24, %esp + pushl %edi + pushl %edx + pushl $3 + pushl %eax + pushl %ecx + pushl %ebp + call __dpml_ux_sincos +..B1.10: + addl $12, %esp + lea 36(%esp), %edx + pushl %edx + lea 88(%esp), %eax + pushl %eax + pushl %edx + call __dpml_multiply__ +..B1.11: + addl $12, %esp + lea 60(%esp), %edx + lea 108(%esp), %eax + pushl %edx + pushl %eax + pushl %edx + call __dpml_multiply__ +..B1.12: + movl 196(%esp), %eax + orl 200(%esp), %eax + je ..B1.14 +..B1.13: + xorl %eax, %eax + jmp ..B1.15 +..B1.14: + movl $1, %eax +..B1.15: + addl $20, %esp + lea 28(%esp), %edx + pushl %edx + pushl $0 + pushl %eax + lea 64(%esp), %eax + pushl %eax + pushl %edx + call __dpml_addsub__ +..B1.16: + lea 72(%esp), %ecx + pushl %ecx + pushl $0 + pushl $1 + lea 156(%esp), %ebp + pushl %ebp + call __dpml_ux_sqrt_evaluation__ +..B1.17: + addl $28, %esp + pushl 32(%esp) + lea 64(%esp), %eax + pushl %eax + lea 44(%esp), %edx + pushl %edx + call __dpml_multiply__ +..B1.18: + movl 168(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.31 +..B1.19: + addl $172, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.20: + je ..B1.63 +..B1.21: + movl 19552+__bessel_x_table@GOTOFF(%ebx,%esi,8), %esi + testl %ecx, %ecx + lea __bessel_x_table@GOTOFF(%ebx,%esi), %edi + jl ..B1.33 +..B1.22: + negl %ecx + addl $5, %ecx + cmpl $31, %ecx + jbe ..B1.24 +..B1.23: + movl 40(%esp), %edx + movl $0, 32(%esp) + shrl %cl, %edx +..B1.25: + movl 32(%esp), %ecx + jmp ..B1.26 +..B1.24: + movl 40(%esp), %esi + shrdl %cl, %esi, %edx + shrl %cl, %esi + movl %esi, 32(%esp) + jmp ..B1.25 +..B1.27: + movl 12(%edi), %esi + andl $1023, %esi + addl %esi, %edi +..B1.26: + movl %edx, %eax + movl %ecx, %esi + subl (%edi), %eax + sbbl 4(%edi), %esi + jb ..B1.33 +..B1.68: + orl %esi, %eax + je ..B1.33 + jmp ..B1.27 +..B1.28: + movl 196(%esp), %ecx + movl %ebp, %eax + movl 200(%esp), %esi + movl 204(%esp), %edi + movl 208(%esp), %edx + movl %ecx, 4(%esp) + movl %esi, 8(%esp) + movl %edi, 12(%esp) + movl %edx, 16(%esp) + movl 44(%esp), %edx + call __dpml_ux_large_order_bessel__ +..B1.29: + movl 168(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.31 +..B1.30: + addl $172, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.31: + call __stack_chk_fail@PLT +..B1.33: + movl 12(%edi), %edx + xorl %ecx, %ecx + movl 8(%edi), %esi + movl %edx, 40(%esp) + movl %esi, %edx + andl $8388608, %edx + orl %ecx, %edx + jne ..B1.35 +..B1.34: + movl %ebp, 36(%esp) + jmp ..B1.38 +..B1.35: + movl 16(%edi), %edx + lea 48(%esp), %ecx + movl 20(%edi), %eax + movl %edx, 32(%ecx) + movl %eax, 36(%ecx) + movl 24(%edi), %edx + movl 28(%edi), %eax + movl %edx, 40(%ecx) + xorl %edx, %edx + movl %eax, 44(%ecx) + movl %edx, 24(%ecx) + movl 40(%edi), %eax + andl $7, %eax + movl %eax, -16(%ecx) + movl %eax, 28(%ecx) + lea 72(%esp), %eax + addl $20, %esp + pushl %ecx + pushl %edx + pushl $1 + pushl %eax + pushl %ebp + call __dpml_addsub__ +..B1.36: + movl 32(%edi), %edx + movl 36(%edi), %ecx + movl %edx, 80(%esp) + movl %ecx, 84(%esp) + movl 40(%edi), %edx + movl 44(%edi), %ecx + movl %edx, 88(%esp) + movl 32(%esp), %edx + addl $-128, %edx + movl %ecx, 92(%esp) + movl %edx, 76(%esp) + addl $20, %esp + lea 28(%esp), %ecx + pushl %ecx + pushl $0 + pushl $1 + lea 64(%esp), %edx + pushl %edx + pushl %ecx + call __dpml_addsub__ +..B1.37: + lea 48(%esp), %edx + movl %edx, -12(%edx) +..B1.38: + movl %esi, %edx + movl %esi, %eax + shrl $14, %edx + andl $16777216, %eax + xorl %ecx, %ecx + addl $48, %edi + andl $127, %edx + orl %ecx, %eax + je ..B1.43 +..B1.39: + addl $-48, %esp + movl 84(%esp), %ecx + movl %ecx, (%esp) + movl %edx, 4(%esp) + movl %esi, %edx + shrl $7, %edx + andl $127, %edx + movl $0, 8(%esp) + cmpl $31, %edx + movl %edi, 12(%esp) + movl %edx, 80(%esp) + jbe ..B1.41 +..B1.40: + movl $1, %edx + xorl %edi, %edi + movl 80(%esp), %ecx + shll %cl, %edx + jmp ..B1.42 +..B1.41: + xorl %edx, %edx + movl $1, %edi + movl 80(%esp), %ecx + shldl %cl, %edi, %edx + shll %cl, %edi +..B1.42: + addl $-1, %edi + adcl $-1, %edx + movl %edi, 16(%esp) + movl %edx, 20(%esp) + movl %esi, %edx + andl $127, %edx + movl %edx, 24(%esp) + movl $0, 28(%esp) + movl 92(%esp), %ecx + movl %ecx, 32(%esp) + call __dpml_evaluate_packed_poly__@PLT +..B1.71: + addl $48, %esp + jmp ..B1.44 +..B1.43: + addl $28, %esp + pushl 16(%esp) + pushl 16(%esp) + pushl %esi + pushl $0 + pushl %edx + pushl %edi + pushl 32(%esp) + call __dpml_evaluate_rational__ +..B1.44: + movl %esi, %ecx + xorl %edx, %edx + shrl $11, %ecx + andl $3, %ecx + orl %ecx, %edx + je ..B1.46 +..B1.45: + addl $20, %esp + xorl %edi, %edi + addl $-1, %ecx + movl 24(%esp), %edx + pushl %edx + adcl $-1, %edi + pushl %edi + pushl %ecx + lea 24(%edx), %ecx + pushl %ecx + pushl %edx + call __dpml_addsub__ +..B1.46: + movl %esi, %ecx + xorl %edx, %edx + andl $4194304, %ecx + orl %edx, %ecx + je ..B1.48 +..B1.47: + addl $12, %esp + movl 32(%esp), %edx + pushl %edx + pushl %edx + pushl 32(%esp) + call __dpml_multiply__ +..B1.48: + movl %esi, %ecx + xorl %edx, %edx + andl $8192, %ecx + orl %edx, %ecx + je ..B1.50 +..B1.49: + movl 44(%esp), %edx + xorl $-2147483648, (%edx) +..B1.50: + andl $2097152, %esi + xorl %edx, %edx + orl %edx, %esi + je ..B1.58 +..B1.51: + cmpl 36(%esp), %ebp + jne ..B1.53 +..B1.52: + movl 40(%esp), %edx + sarl $26, %edx + subl %edx, 4(%ebp) +..B1.53: + movl $1, %edx + negl %edx + addl 196(%esp), %edx + orl 200(%esp), %edx + je ..B1.61 +..B1.54: + addl $12, %esp + lea 19664+__bessel_x_table@GOTOFF(%ebx), %ecx + lea 36(%esp), %esi + pushl %esi + pushl %ecx + pushl %ebp + call __dpml_ux_log__ +..B1.55: + movl 196(%esp), %ecx + xorl %edx, %edx + movl 200(%esp), %edi + movl %ebp, %eax + movl %ecx, 4(%esp) + movl %edi, 8(%esp) + movl %edx, 12(%esp) + movl %edx, 16(%esp) + lea 72(%esp), %edx + call __dpml_ux_bessel__ +..B1.56: + addl $12, %esp + pushl %esi + pushl %esi + lea 68(%esp), %eax + pushl %eax + call __dpml_multiply__ +..B1.57: + addl $20, %esp + movl 24(%esp), %eax + pushl %eax + pushl $0 + pushl $1 + pushl %eax + pushl %esi + call __dpml_addsub__ +..B1.58: + movl 168(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.31 + jmp ..B1.19 +..B1.61: + addl $20, %esp + lea 19640+__bessel_x_table@GOTOFF(%ebx), %ecx + lea 52(%esp), %edx + pushl %edx + pushl $0 + pushl $2 + pushl %ebp + pushl %ecx + call __dpml_divide__ +..B1.62: + addl $20, %esp + xorl %edx, %edx + movl 24(%esp), %esi + pushl %esi + pushl %edx + pushl %edx + lea 64(%esp), %ecx + pushl %ecx + pushl %esi + call __dpml_addsub__ + jmp ..B1.54 +..B1.63: + movl %edx, %eax + lea __bessel_x_table@GOTOFF(%ebx), %edi + subl 19544+__bessel_x_table@GOTOFF(%ebx,%esi,8), %eax + movl %eax, 36(%esp) + movl 40(%esp), %eax + sbbl 19548+__bessel_x_table@GOTOFF(%ebx,%esi,8), %eax + movl %eax, 32(%esp) + jb ..B1.64 +..B1.69: + movl 36(%esp), %eax + orl 32(%esp), %eax + jne ..B1.3 +..B1.64: + movl 19552+__bessel_x_table@GOTOFF(%ebx,%esi,8), %esi + addl %esi, %edi + jmp ..B1.22 + .align 16,0x90 + .type __dpml_ux_bessel__,@function + .size __dpml_ux_bessel__,.-__dpml_ux_bessel__ + .data +# -- End __dpml_ux_bessel__ + .text +# -- Begin __dpml_ux_large_order_bessel__ + .text + .align 16,0x90 +__dpml_ux_large_order_bessel__: +# parameter 1: %eax +# parameter 2: 12 + %ebp +# parameter 3: 20 + %ebp +# parameter 4: %edx +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $292, %esp + xorl %ebx, %ebx + movl %edx, 76(%esp) + lea 240(%esp), %edx + movl %gs:20, %ecx + movl %eax, %esi + xorl %esp, %ecx + movl %ecx, 48(%edx) + addl $20, %esp + pushl %edx + pushl %ebx + pushl $2 + pushl %esi + pushl %ebx + call __dpml_divide__ +..B2.2: + movl 12(%ebp), %ebx + lea 168(%esp), %eax + movl 16(%ebp), %edi + lea 192(%esp), %edx + movl %eax, -108(%eax) + lea 216(%esp), %ecx + movl %edx, -52(%eax) + movl %ecx, -76(%eax) + movl %ebx, 8(%eax) + movl %edi, 12(%eax) + addl $12, %esp + pushl $0 + pushl $2 + pushl %eax + call __dpml_ffs_and_shift__ +..B2.3: + movl $64, %ecx + xorl %edi, %edi + subl %eax, %ecx + movl 4(%esi), %eax + sbbl %edx, %edi + cltd + movl %edx, %ebx + movl %ecx, %edx + movl %eax, 64(%esp) + subl %eax, %edx + movl 12(%ebp), %eax + movl %eax, 120(%esp) + movl 16(%ebp), %eax + movl %esi, 32(%esp) + movl %edi, %esi + movl %eax, 124(%esp) + sbbl %ebx, %esi + fildll 120(%esp) + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + fstpl 128(%esp) + fldl 128(%esp) + movl %edx, 120(%esp) + fldt .L_2il0floatpacket.96@GOTOFF(%ebx) + movl %esi, 124(%esp) + movl %edx, 44(%esp) + movl $1, %edx + subl %ecx, %edx + movl %esi, 40(%esp) + movl $0, %esi + sbbl %edi, %esi + fstpt 104(%esp) + fldt 104(%esp) + fildll 120(%esp) + movl %ecx, 120(%esp) + movl %edi, 124(%esp) + movl $2, %edi + fstpl 128(%esp) + negl %edi + fldl 128(%esp) + fildll 120(%esp) + fstpl 128(%esp) + fldt .L_2il0floatpacket.97@GOTOFF(%ebx) + movl %edx, 120(%esp) + fsubrp %st, %st(1) + fmulp %st, %st(2) + fldl 128(%esp) + fldt .L_2il0floatpacket.98@GOTOFF(%ebx) + movl %esi, 124(%esp) + fsubrp %st, %st(1) + fmulp %st, %st(1) + addl 20(%ebp), %edi + fsubrp %st, %st(1) + fstpl 128(%esp) + fldl 128(%esp) + fildll 120(%esp) + fstpl 128(%esp) + fldl 128(%esp) + movl 32(%esp), %esi + fsub %st(1), %st + fstpl 128(%esp) + fldl 128(%esp) + orl 24(%ebp), %edi + je ..B2.62 +..B2.4: + fstp %st(1) + fldt .L_2il0floatpacket.100@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jbe ..B2.8 +..B2.5: + movl $-65536, %ecx + xorl %eax, %eax +..B2.6: + movl 76(%esp), %edx + movl %eax, (%edx) + xorl %eax, %eax + movl %ecx, 4(%edx) + movl %eax, 8(%edx) + movl $-2147483648, 12(%edx) + movl %eax, 16(%edx) + movl %eax, 20(%edx) + movl 288(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B2.41 +..B2.7: + addl $292, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.8: + negl %ecx + movl 8(%esi), %edx + addl $64, %ecx + movl %edx, 48(%esp) + cmpl $31, %ecx + movl 12(%esi), %edx + jbe ..B2.10 +..B2.9: + movl %edx, %edi + shrl %cl, %edi + movl $0, 36(%esp) + movl %edi, 32(%esp) + jmp ..B2.11 +..B2.10: + movl 48(%esp), %edi + shrdl %cl, %edx, %edi + movl %edi, 32(%esp) + movl %edx, %edi + shrl %cl, %edi + movl %edi, 36(%esp) +..B2.11: + xorl %ecx, %ecx + movl 40(%esp), %edi + subl %ecx, %edi + jl ..B2.47 +..B2.66: + orl 44(%esp), %edi + je ..B2.47 +..B2.12: + movl %edx, %ecx + movl 48(%esp), %eax + shll $31, %ecx + shrl $1, %eax + shrl $1, %edx + orl %eax, %ecx + movl %ecx, 120(%esp) + movl %edx, 124(%esp) + fildll 120(%esp) + movl 12(%ebp), %edx + movl 16(%ebp), %esi + movl %edx, 120(%esp) + movl %esi, 124(%esp) + fstps 44(%esp) + fildll 120(%esp) + fstps 120(%esp) + flds 120(%esp) + fstpt 32(%esp) + fldt 32(%esp) + fstps (%esp) + call log2f@PLT +..B2.13: + fldt .L_2il0floatpacket.101@GOTOFF(%ebx) + fmul %st(1), %st + fldt .L_2il0floatpacket.102@GOTOFF(%ebx) + faddp %st, %st(1) + fstps 120(%esp) + fldt .L_2il0floatpacket.103@GOTOFF(%ebx) + fldt 32(%esp) + faddp %st, %st(1) + flds 44(%esp) + fxch %st(1) + fadds 120(%esp) + fstps 120(%esp) + flds 120(%esp) + fstpt 80(%esp) + fstps (%esp) + fstpt 48(%esp) + call log2f@PLT +..B2.71: + fldt 48(%esp) +..B2.14: + fldt .L_2il0floatpacket.104@GOTOFF(%ebx) + fldt .L_2il0floatpacket.105@GOTOFF(%ebx) + fldt 104(%esp) + fldt 32(%esp) + movl 64(%esp), %eax + fadd %st(1), %st + addl $-64, %eax + movl %eax, 120(%esp) + fildl 120(%esp) + fstps 120(%esp) + fldt 80(%esp) + fxch %st(6) + fadds 120(%esp) + faddp %st, %st(4) + fxch %st(3) + fstps 120(%esp) + flds 120(%esp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fsts 44(%esp) + fsubp %st, %st(3) + fxch %st(2) + fstpl 128(%esp) + fldl 128(%esp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstps 120(%esp) + flds 120(%esp) + fstpt 48(%esp) + fstps (%esp) + call log2f@PLT +..B2.15: + fldt .L_2il0floatpacket.106@GOTOFF(%ebx) + fstpt 64(%esp) + fldt 64(%esp) + fld %st(1) + fmulp %st, %st(1) + fxch %st(1) + fsubs 44(%esp) + fstpl 128(%esp) + fldt 48(%esp) + faddp %st, %st(1) + fldl 128(%esp) + fdivrp %st, %st(1) + fstps 120(%esp) + fldt 80(%esp) + fldt 104(%esp) + fxch %st(1) + fadds 120(%esp) + fstpl 128(%esp) + fldl 128(%esp) + fmulp %st, %st(1) + fstps 120(%esp) + flds 120(%esp) + fstpt 32(%esp) + fldt 32(%esp) + fstps (%esp) + call log2f@PLT +..B2.16: + fldt 64(%esp) + fldt 48(%esp) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fldt 32(%esp) + fxch %st(2) + fsubs 44(%esp) + fstpl 128(%esp) + fldl 128(%esp) + fdivrp %st, %st(1) + fstps 120(%esp) + fldt 104(%esp) + fxch %st(1) + fadds 120(%esp) + fstpl 128(%esp) + fldl 128(%esp) + fmulp %st, %st(1) + fstps 120(%esp) + flds 120(%esp) + fstpt 80(%esp) + fldt 80(%esp) + fstps (%esp) + call log2f@PLT +..B2.17: + fldt 64(%esp) + movl $-2147483648, %ecx + fmul %st(1), %st + fxch %st(1) + fsubs 44(%esp) + fstpl 128(%esp) + fldt 48(%esp) + movl 16(%ebp), %edx + faddp %st, %st(1) + fldl 128(%esp) + fdivrp %st, %st(1) + fstps 120(%esp) + fldt 80(%esp) + fldt 104(%esp) + fldt .L_2il0floatpacket.107@GOTOFF(%ebx) + flds .L_2il0floatpacket.108@GOTOFF(%ebx) + fxch %st(3) + fadds 120(%esp) + fstpl 128(%esp) + fldl 128(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstps 120(%esp) + flds 120(%esp) + faddp %st, %st(1) + fcom %st(1) + fnstsw %ax + fsub %st, %st(1) + sahf + jae ..L5 + fst %st(1) +..L5: + fstp %st(0) + jae ..L6 + movl $0, %ecx +..L6: + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 96(%esp) + fldcw 32(%esp) + movl 12(%ebp), %eax + addl $1, %eax + movl 96(%esp), %esi + adcl $0, %edx + addl 100(%esp), %ecx + movl %esi, 140(%esp) + subl %eax, %esi + movl %ecx, %edi + movl %edx, 136(%esp) + sbbl %edx, %edi + jb ..B2.19 +..B2.67: + orl %edi, %esi + je ..B2.19 +..B2.18: + movl %ecx, 136(%esp) + jmp ..B2.20 +..B2.19: + movl %eax, 140(%esp) +..B2.20: + movl 140(%esp), %edx + xorl %eax, %eax + andl $1, %edx + movl %eax, 168(%esp) + orl %eax, %edx + movl $-262144, 172(%esp) + movl %eax, 176(%esp) + movl %eax, 180(%esp) + movl %eax, 184(%esp) + movl %eax, 188(%esp) + movl %eax, 192(%esp) + movl $1, 196(%esp) + movl %eax, 200(%esp) + movl $-2147483648, 204(%esp) + movl %eax, 208(%esp) + movl %eax, 212(%esp) + movl %eax, 144(%esp) + je ..B2.22 +..B2.21: + movl $-262144, 148(%esp) + movl %eax, 152(%esp) + movl %eax, 156(%esp) + movl %eax, 160(%esp) + movl %eax, 164(%esp) + jmp ..B2.23 +..B2.22: + movl $1, 148(%esp) + movl %eax, 152(%esp) + movl $-2147483648, 156(%esp) + movl %eax, 160(%esp) + movl %eax, 164(%esp) +..B2.23: + movl 136(%esp), %esi + movl 140(%esp), %ecx + movl %ecx, %eax + shrl $31, %eax + lea (%esi,%esi), %edi + orl %edi, %eax + addl %ecx, %ecx + movl %ecx, 272(%esp) + movl %eax, 276(%esp) + addl $12, %esp + lea 252(%esp), %edx + pushl $0 + pushl $2 + pushl %edx + call __dpml_ffs_and_shift__ +..B2.24: + movl 268(%esp), %ecx + addl $-2, %ecx + cmpl $31, %ecx + jbe ..B2.26 +..B2.25: + movl $-2147483648, %eax + xorl %edx, %edx + shrl %cl, %eax + jmp ..B2.27 +..B2.26: + xorl %eax, %eax + movl $-2147483648, %edx + shrdl %cl, %edx, %eax + shrl %cl, %edx +..B2.27: + movl %ebx, 44(%esp) + movl %edx, 32(%esp) + movl %eax, 36(%esp) + movl 92(%esp), %ebx + movl 60(%esp), %esi +..B2.28: + addl $12, %esp + pushl %ebx + lea 256(%esp), %eax + pushl %eax + lea 236(%esp), %edx + pushl %edx + call __dpml_multiply__ +..B2.29: + addl $12, %esp + pushl %ebx + pushl %ebx + pushl 112(%esp) + call __dpml_multiply__ +..B2.30: + addl $12, %esp + xorl %ecx, %ecx + pushl %ecx + pushl %ecx + pushl %ebx + call __dpml_ffs_and_shift__ +..B2.31: + addl $12, %esp + xorl %ecx, %ecx + pushl %ecx + pushl %ecx + pushl %esi + call __dpml_ffs_and_shift__ +..B2.32: + addl $20, %esp + pushl %ebx + pushl $0 + pushl $1 + pushl %esi + pushl %ebx + call __dpml_addsub__ +..B2.33: + movl 140(%esp), %eax + addl $-1, %eax + movl 136(%esp), %edx + adcl $-1, %edx + movl %eax, 140(%esp) + orl %edx, %eax + movl %edx, 136(%esp) + je ..B2.42 +..B2.34: + movl 140(%esp), %edx + movl 136(%esp), %eax + subl 12(%ebp), %edx + subl 16(%ebp), %eax + orl %eax, %edx + jne ..B2.36 +..B2.35: + movl 76(%esp), %eax + movl (%ebx), %edx + movl 4(%ebx), %ecx + movl 8(%ebx), %edi + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl %edi, 8(%eax) + movl 12(%ebx), %edx + movl 16(%ebx), %ecx + movl 20(%ebx), %edi + movl %edx, 12(%eax) + movl %ecx, 16(%eax) + movl %edi, 20(%eax) +..B2.36: + movl 140(%esp), %edx + xorl %eax, %eax + andl $1, %edx + orl %eax, %edx + jne ..B2.38 +..B2.37: + addl $20, %esp + lea 124(%esp), %edx + pushl %edx + pushl %eax + pushl %eax + pushl %ebx + pushl %edx + call __dpml_addsub__ +..B2.38: + movl %esi, %eax + movl $-2147483648, %ecx + movl 116(%esp), %esi + movl %ebx, 116(%esp) + movl %eax, %ebx + movl 272(%esp), %eax + subl 36(%esp), %eax + movl 276(%esp), %edx + sbbl 32(%esp), %edx + movl %edx, %edi + subl %ecx, %edi + jae ..B2.40 +..B2.39: + addl %eax, %eax + movl 36(%esp), %ecx + adcl %edx, %edx + addl %ecx, %ecx + movl 32(%esp), %edi + adcl %edi, %edi + decl 268(%esp) + movl %ecx, 36(%esp) + movl %edi, 32(%esp) +..B2.40: + movl %eax, 272(%esp) + movl %edx, 276(%esp) + jmp ..B2.28 +..B2.41: + call __stack_chk_fail@PLT +..B2.42: + movl %ebx, 92(%esp) + lea 144(%esp), %esi + movl -100(%esi), %ebx + xorl %eax, %eax + incl 4(%esi) + addl $20, %esp + pushl %esi + pushl %eax + pushl %eax + pushl %esi + pushl 88(%esp) + call __dpml_addsub__ +..B2.43: + addl $20, %esp + movl 56(%esp), %eax + pushl %eax + pushl $0 + pushl $2 + pushl %esi + pushl %eax + call __dpml_divide__ +..B2.44: + movl 288(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.41 + jmp ..B2.7 +..B2.47: + movl 44(%esp), %ecx + orl 40(%esp), %ecx + jne ..B2.49 +..B2.48: + movl 32(%esp), %ecx + subl 12(%ebp), %ecx + movl 36(%esp), %edi + sbbl 16(%ebp), %edi + jb ..B2.12 +..B2.49: + movl 20(%ebp), %edi + xorl %ecx, %ecx + movl 24(%ebp), %edx + movl %esi, %eax + movl %ecx, 4(%esp) + movl %ecx, 8(%esp) + movl %edi, 12(%esp) + movl %edx, 16(%esp) + lea 168(%esp), %edx + call __dpml_ux_bessel__ +..B2.50: + movl 20(%ebp), %ecx + movl %esi, %eax + movl 24(%ebp), %edi + movl $1, 4(%esp) + movl $0, 8(%esp) + movl %ecx, 12(%esp) + movl %edi, 16(%esp) + movl 116(%esp), %edx + call __dpml_ux_bessel__ +..B2.51: + movl 12(%ebp), %esi + xorl %edx, %edx + addl $-1, %esi + movl 16(%ebp), %eax + adcl $-1, %eax + movl $-2147483648, %ecx + movl %ebx, 44(%esp) + movl %edx, 264(%esp) + movl $2, 268(%esp) + movl %edx, 272(%esp) + movl $-2147483648, 276(%esp) + movl %edx, 280(%esp) + movl %edx, 284(%esp) + movl %ecx, 36(%esp) + movl %eax, 40(%esp) + movl %edx, 32(%esp) + movl 92(%esp), %ebx +..B2.52: + addl $12, %esp + pushl %ebx + lea 256(%esp), %eax + pushl %eax + lea 236(%esp), %edx + pushl %edx + call __dpml_multiply__ +..B2.53: + addl $12, %esp + pushl %ebx + pushl %ebx + pushl 112(%esp) + call __dpml_multiply__ +..B2.54: + addl $20, %esp + pushl %ebx + pushl $0 + pushl $1 + pushl 52(%esp) + pushl %ebx + call __dpml_addsub__ +..B2.55: + addl $-1, %esi + movl 40(%esp), %eax + adcl $-1, %eax + xorl %edx, %edx + movl %eax, 40(%esp) + subl %edx, %eax + jl ..B2.76 +..B2.68: + orl %esi, %eax + je ..B2.76 +..B2.56: + movl 60(%esp), %ecx + movl 116(%esp), %edx + movl 32(%esp), %eax + movl %ebx, 116(%esp) + movl %ecx, %ebx + movl 272(%esp), %ecx + addl %eax, %ecx + movl %edx, 60(%esp) + movl %ecx, %edi + movl 276(%esp), %edx + adcl 36(%esp), %edx + subl %eax, %edi + movl %edx, %eax + sbbl 36(%esp), %eax + jae ..B2.58 +..B2.57: + movl %edx, %edi + shll $31, %edi + shrl $1, %ecx + orl %edi, %ecx + movl 36(%esp), %edi + movl %edi, %eax + shrl $1, %edi + movl %edi, 36(%esp) + movl 32(%esp), %edi + shll $31, %eax + shrl $1, %edi + shrl $1, %edx + orl %eax, %edi + incl 268(%esp) + addl $-2147483648, %edx + movl %edi, 32(%esp) +..B2.58: + movl %ecx, 272(%esp) + movl %edx, 276(%esp) + jmp ..B2.52 +..B2.76: + movl %ebx, 92(%esp) + movl 44(%esp), %ebx +..B2.59: + movl 92(%esp), %eax + movl 76(%esp), %edx + movl (%eax), %ecx + movl 4(%eax), %esi + movl %ecx, (%edx) + movl %esi, 4(%edx) + movl 8(%eax), %edi + movl 12(%eax), %ecx + movl 16(%eax), %esi + movl 20(%eax), %eax + movl %edi, 8(%edx) + movl %ecx, 12(%edx) + movl %esi, 16(%edx) + movl %eax, 20(%edx) + movl 288(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B2.41 + jmp ..B2.7 +..B2.62: + fstp %st(0) + fldt .L_2il0floatpacket.99@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jae ..B2.49 + jp ..B2.49 +..B2.63: + movl $65536, %ecx + movl $-2147483648, %eax + jmp ..B2.6 + .align 16,0x90 + .type __dpml_ux_large_order_bessel__,@function + .size __dpml_ux_large_order_bessel__,.-__dpml_ux_large_order_bessel__ + .data +# -- End __dpml_ux_large_order_bessel__ + .text +# -- Begin __j0q + .text + .align 16,0x90 + .globl __j0q +__j0q: +# parameter 1: 24 + %ebp +..B3.1: +..L7: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + xorl %esi, %esi + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 160(%esp) + call ..L8 +..L8: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L8](%ebx), %ebx + movl $1, 40(%esp) + movl %esi, 44(%esp) + movl %esi, 32(%esp) + lea __bessel_x_table@GOTOFF(%ebx), %ecx + movl %esi, 36(%esp) + addl $24, %esp + lea 8(%esp), %eax + lea 84(%esp), %edx + pushl %eax + lea 124(%esp), %eax + pushl %eax + pushl %ecx + pushl %edx + pushl %esi + lea 24(%ebp), %ecx + pushl %ecx + call __dpml_unpack_x_or_y__ +..B3.2: + subl %esi, %edx + jl ..B3.6 +..B3.4: + movl %esi, 4(%esp) + lea 60(%esp), %edx + movl %esi, 8(%esp) + lea 108(%esp), %eax + movl %esi, 12(%esp) + movl %esi, (%eax) + movl %esi, 16(%esp) + call __dpml_ux_bessel__ +..B3.5: + addl $28, %esp + lea 4(%esp), %edx + pushl %edx + pushl %esi + pushl %esi + pushl %esi + pushl %esi + lea 136(%esp), %ecx + pushl %ecx + lea 56(%esp), %esi + pushl %esi + call __dpml_pack__ +..B3.6: + movl 144(%esp), %edx + movl %edx, (%edi) + movl 148(%esp), %ecx + movl 152(%esp), %esi + movl 156(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 160(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B3.8 +..B3.7: + movl %edi, %eax + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B3.8: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __j0q,@function + .size __j0q,.-__j0q + .data +# -- End __j0q + .text +# -- Begin __j1q + .text + .align 16,0x90 + .globl __j1q +__j1q: +# parameter 1: 24 + %ebp +..B4.1: +..L9: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + xorl %ecx, %ecx + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 160(%esp) + call ..L10 +..L10: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L10](%ebx), %ebx + movl $1, 40(%esp) + movl %ecx, 44(%esp) + movl %ecx, 32(%esp) + lea 8+__bessel_x_table@GOTOFF(%ebx), %esi + movl %ecx, 36(%esp) + addl $24, %esp + lea 8(%esp), %eax + lea 84(%esp), %edx + pushl %eax + lea 124(%esp), %eax + pushl %eax + pushl %esi + pushl %edx + pushl %ecx + movl 36(%ebp), %esi + lea 24(%ebp), %ecx + pushl %ecx + andl $-2147483648, %esi + call __dpml_unpack_x_or_y__ +..B4.16: + movl %edx, %ecx +..B4.2: + xorl %edx, %edx + subl %edx, %ecx + jge ..B4.6 +..B4.3: + movl 156(%esp), %ecx + movl %ecx, %edx + movl $2147418112, %eax + andl $2147418112, %edx + subl %eax, %edx + xorl %eax, %eax + orl %edx, %eax + movl 152(%esp), %edx + je ..B4.5 +..B4.4: + orl %esi, %ecx +..B4.5: + movl %edx, 152(%esp) + movl %ecx, 156(%esp) + jmp ..B4.11 +..B4.6: + movl $1, 4(%esp) + lea 60(%esp), %edx + xorl %ecx, %ecx + lea 108(%esp), %eax + movl %ecx, 8(%esp) + movl %ecx, 12(%esp) + movl %ecx, (%eax) + movl %ecx, 16(%esp) + call __dpml_ux_bessel__ +..B4.7: + xorl %esi, 60(%esp) + je ..B4.9 +..B4.8: + movl $8, %ecx + jmp ..B4.10 +..B4.9: + xorl %ecx, %ecx +..B4.10: + movl $513, %esi + addl $28, %esp + shrl %cl, %esi + lea 4(%esp), %edx + andl $255, %esi + pushl %edx + pushl 4+__bessel_error_codes@GOTOFF(%ebx) + pushl __bessel_error_codes@GOTOFF(%ebx) + pushl 4+__bessel_error_codes@GOTOFF(%ebx,%esi,8) + pushl __bessel_error_codes@GOTOFF(%ebx,%esi,8) + lea 136(%esp), %edx + pushl %edx + lea 56(%esp), %edx + pushl %edx + call __dpml_pack__ +..B4.11: + movl 144(%esp), %edx + movl %edx, (%edi) + movl 148(%esp), %ecx + movl 152(%esp), %esi + movl 156(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 160(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B4.13 +..B4.12: + movl %edi, %eax + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B4.13: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __j1q,@function + .size __j1q,.-__j1q + .data +# -- End __j1q + .text +# -- Begin __jnq + .text + .align 16,0x90 + .globl __jnq +__jnq: +# parameter 1: 12 + %ebp +# parameter 2: 24 + %ebp +..B5.1: +..L11: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + movl 8(%ebp), %esi + movl %esi, 64(%esp) + movl 12(%ebp), %esi + movl %esi, %eax + cltd + movl %gs:20, %ecx + movl %edx, %ebx + xorl %esp, %ecx + movl %ecx, 160(%esp) + xorl %ecx, %ecx + movl 36(%ebp), %edi + subl %ecx, %edx + movl $1, 40(%esp) + movl %ecx, 44(%esp) + movl %ecx, 32(%esp) + movl %ecx, 36(%esp) + jge ..B5.3 +..B5.2: + movl %esi, %edx + xorl %esi, %esi + xorl $-2147483648, %edi + subl %edx, %esi + movl %ebx, %edx + movl %ecx, %ebx + sbbl %edx, %ebx +..B5.3: + movl %esi, %ecx + xorl %edx, %edx + andl $1, %ecx + orl %edx, %ecx + jne ..B5.6 +..B5.5: + xorl %edi, %edi +..B5.6: + movl $2, %ecx + movl %esi, %edx + andl $-2147483648, %edi + movl %ebx, %eax + subl %ecx, %edx + movl $0, %ecx + sbbl %ecx, %eax + jl ..B5.8 +..B5.24: + orl %eax, %edx + je ..B5.8 +..B5.7: + movl $2, %edx + jmp ..B5.9 +..B5.8: + movl %esi, %edx +..B5.9: + call ..L12 +..L12: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L12](%ecx), %ecx + addl $24, %esp + movl %ecx, 36(%esp) + lea 8(%esp), %eax + lea __bessel_x_table@GOTOFF(%ecx,%edx,8), %edx + lea 92(%esp), %ecx + pushl %eax + lea 124(%esp), %eax + pushl %eax + pushl %edx + pushl %ecx + pushl $0 + lea 24(%ebp), %edx + pushl %edx + call __dpml_unpack_x_or_y__ +..B5.25: + movl %edx, %ecx +..B5.10: + xorl %edx, %edx + subl %edx, %ecx + jge ..B5.14 +..B5.11: + movl 156(%esp), %edx + movl %edx, %eax + movl $2147418112, %ebx + andl $2147418112, %eax + subl %ebx, %eax + xorl %esi, %esi + movl 152(%esp), %ecx + orl %eax, %esi + je ..B5.13 +..B5.12: + orl %edi, %edx +..B5.13: + movl %ecx, 152(%esp) + movl %edx, 156(%esp) + jmp ..B5.19 +..B5.14: + movl %esi, 4(%esp) + lea 68(%esp), %edx + movl %ebx, 8(%esp) + lea 116(%esp), %eax + xorl %ecx, %ecx + movl %ecx, 12(%esp) + movl %ecx, (%eax) + movl %ecx, 16(%esp) + call __dpml_ux_bessel__ +..B5.15: + xorl %edi, 68(%esp) + je ..B5.17 +..B5.16: + movl $8, %ecx + jmp ..B5.18 +..B5.17: + xorl %ecx, %ecx +..B5.18: + addl $28, %esp + movl $1027, %edx + shrl %cl, %edx + lea 4(%esp), %eax + pushl %eax + movl 28(%eax), %ebx + movzbl %dl, %edx + pushl 4+__bessel_error_codes@GOTOFF(%ebx) + pushl __bessel_error_codes@GOTOFF(%ebx) + pushl 4+__bessel_error_codes@GOTOFF(%ebx,%edx,8) + pushl __bessel_error_codes@GOTOFF(%ebx,%edx,8) + lea 136(%esp), %esi + pushl %esi + lea 64(%esp), %edi + pushl %edi + call __dpml_pack__ +..B5.19: + movl 64(%esp), %esi + movl 144(%esp), %eax + movl 148(%esp), %edx + movl 152(%esp), %ecx + movl 156(%esp), %ebx + movl %eax, (%esi) + movl %edx, 4(%esi) + movl %ecx, 8(%esi) + movl %ebx, 12(%esi) + movl 160(%esp), %edi + xorl %esp, %edi + cmpl %gs:20, %edi + jne ..B5.21 +..B5.20: + movl %esi, %eax + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B5.21: + movl 60(%esp), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type __jnq,@function + .size __jnq,.-__jnq + .data +# -- End __jnq + .text +# -- Begin __y0q + .text + .align 16,0x90 + .globl __y0q +__y0q: +# parameter 1: 24 + %ebp +..B6.1: +..L13: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + xorl %esi, %esi + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 160(%esp) + call ..L14 +..L14: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L14](%ebx), %ebx + movl $1, 40(%esp) + movl %esi, 44(%esp) + movl %esi, 32(%esp) + lea 40+__bessel_x_table@GOTOFF(%ebx), %ecx + movl %esi, 36(%esp) + addl $24, %esp + lea 8(%esp), %eax + lea 84(%esp), %edx + pushl %eax + lea 124(%esp), %eax + pushl %eax + pushl %ecx + pushl %edx + pushl %esi + lea 24(%ebp), %ecx + pushl %ecx + call __dpml_unpack_x_or_y__ +..B6.2: + subl %esi, %edx + jl ..B6.6 +..B6.4: + movl %esi, 4(%esp) + lea 60(%esp), %edx + movl %esi, 8(%esp) + lea 108(%esp), %eax + movl $2, 12(%esp) + movl %esi, (%eax) + movl %esi, 16(%esp) + call __dpml_ux_bessel__ +..B6.5: + addl $28, %esp + lea 4(%esp), %edx + pushl %edx + pushl %esi + pushl %esi + pushl %esi + pushl %esi + lea 136(%esp), %ecx + pushl %ecx + lea 56(%esp), %esi + pushl %esi + call __dpml_pack__ +..B6.6: + movl 144(%esp), %edx + movl %edx, (%edi) + movl 148(%esp), %ecx + movl 152(%esp), %esi + movl 156(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 160(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B6.8 +..B6.7: + movl %edi, %eax + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B6.8: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __y0q,@function + .size __y0q,.-__y0q + .data +# -- End __y0q + .text +# -- Begin __y1q + .text + .align 16,0x90 + .globl __y1q +__y1q: +# parameter 1: 24 + %ebp +..B7.1: +..L15: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + xorl %ecx, %ecx + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 160(%esp) + call ..L16 +..L16: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L16](%ebx), %ebx + movl $1, 40(%esp) + movl %ecx, 44(%esp) + movl %ecx, 32(%esp) + lea 48+__bessel_x_table@GOTOFF(%ebx), %esi + movl %ecx, 36(%esp) + addl $24, %esp + lea 8(%esp), %eax + lea 84(%esp), %edx + pushl %eax + lea 124(%esp), %eax + pushl %eax + pushl %esi + pushl %edx + pushl %ecx + movl 36(%ebp), %esi + lea 24(%ebp), %ecx + pushl %ecx + andl $-2147483648, %esi + call __dpml_unpack_x_or_y__ +..B7.16: + movl %edx, %ecx +..B7.2: + xorl %edx, %edx + subl %edx, %ecx + jge ..B7.6 +..B7.3: + movl 156(%esp), %ecx + movl %ecx, %edx + movl $2147418112, %eax + andl $2147418112, %edx + subl %eax, %edx + xorl %eax, %eax + orl %edx, %eax + movl 152(%esp), %edx + je ..B7.5 +..B7.4: + orl %esi, %ecx +..B7.5: + movl %edx, 152(%esp) + movl %ecx, 156(%esp) + jmp ..B7.11 +..B7.6: + movl $1, 4(%esp) + lea 60(%esp), %edx + xorl %ecx, %ecx + lea 108(%esp), %eax + movl %ecx, 8(%esp) + movl $2, 12(%esp) + movl %ecx, (%eax) + movl %ecx, 16(%esp) + call __dpml_ux_bessel__ +..B7.7: + xorl %esi, 60(%esp) + je ..B7.9 +..B7.8: + movl $24, %ecx + jmp ..B7.10 +..B7.9: + movl $16, %ecx +..B7.10: + movl $83886080, %esi + addl $28, %esp + shrl %cl, %esi + lea 4(%esp), %edx + andl $255, %esi + pushl %edx + pushl 4+__bessel_error_codes@GOTOFF(%ebx,%esi,8) + pushl __bessel_error_codes@GOTOFF(%ebx,%esi,8) + pushl 4+__bessel_error_codes@GOTOFF(%ebx) + pushl __bessel_error_codes@GOTOFF(%ebx) + lea 136(%esp), %edx + pushl %edx + lea 56(%esp), %edx + pushl %edx + call __dpml_pack__ +..B7.11: + movl 144(%esp), %edx + movl %edx, (%edi) + movl 148(%esp), %ecx + movl 152(%esp), %esi + movl 156(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 160(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B7.13 +..B7.12: + movl %edi, %eax + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B7.13: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __y1q,@function + .size __y1q,.-__y1q + .data +# -- End __y1q + .text +# -- Begin __ynq + .text + .align 16,0x90 + .globl __ynq +__ynq: +# parameter 1: 12 + %ebp +# parameter 2: 24 + %ebp +..B8.1: +..L17: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + movl 8(%ebp), %esi + movl %esi, 64(%esp) + movl 12(%ebp), %esi + movl %esi, %eax + cltd + movl %gs:20, %ecx + movl %edx, %ebx + xorl %esp, %ecx + movl %ecx, 160(%esp) + xorl %ecx, %ecx + movl 36(%ebp), %edi + subl %ecx, %edx + movl $1, 40(%esp) + movl %ecx, 44(%esp) + movl %ecx, 32(%esp) + movl %ecx, 36(%esp) + jge ..B8.3 +..B8.2: + movl %esi, %edx + xorl %esi, %esi + xorl $-2147483648, %edi + subl %edx, %esi + movl %ebx, %edx + movl %ecx, %ebx + sbbl %edx, %ebx +..B8.3: + movl %esi, %ecx + xorl %edx, %edx + andl $1, %ecx + orl %edx, %ecx + jne ..B8.6 +..B8.5: + xorl %edi, %edi +..B8.6: + movl $2, %ecx + movl %esi, %edx + andl $-2147483648, %edi + movl %ebx, %eax + subl %ecx, %edx + movl $0, %ecx + sbbl %ecx, %eax + jl ..B8.8 +..B8.24: + orl %eax, %edx + je ..B8.8 +..B8.7: + movl $2, %edx + jmp ..B8.9 +..B8.8: + movl %esi, %edx +..B8.9: + call ..L18 +..L18: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L18](%ecx), %ecx + addl $24, %esp + movl %ecx, 36(%esp) + lea 8(%esp), %eax + lea 40+__bessel_x_table@GOTOFF(%ecx,%edx,8), %edx + lea 92(%esp), %ecx + pushl %eax + lea 124(%esp), %eax + pushl %eax + pushl %edx + pushl %ecx + pushl $0 + lea 24(%ebp), %edx + pushl %edx + call __dpml_unpack_x_or_y__ +..B8.25: + movl %edx, %ecx +..B8.10: + xorl %edx, %edx + subl %edx, %ecx + jge ..B8.14 +..B8.11: + movl 156(%esp), %edx + movl %edx, %eax + movl $2147418112, %ebx + andl $2147418112, %eax + subl %ebx, %eax + xorl %esi, %esi + movl 152(%esp), %ecx + orl %eax, %esi + je ..B8.13 +..B8.12: + orl %edi, %edx +..B8.13: + movl %ecx, 152(%esp) + movl %edx, 156(%esp) + jmp ..B8.19 +..B8.14: + movl %esi, 4(%esp) + lea 68(%esp), %edx + movl %ebx, 8(%esp) + lea 116(%esp), %eax + movl $2, 12(%esp) + xorl %ecx, %ecx + movl %ecx, (%eax) + movl %ecx, 16(%esp) + call __dpml_ux_bessel__ +..B8.15: + xorl %edi, 68(%esp) + je ..B8.17 +..B8.16: + movl $24, %ecx + jmp ..B8.18 +..B8.17: + movl $16, %ecx +..B8.18: + addl $28, %esp + movl $117833728, %edx + shrl %cl, %edx + lea 4(%esp), %eax + pushl %eax + movzbl %dl, %edx + movl 28(%eax), %ebx + pushl 4+__bessel_error_codes@GOTOFF(%ebx,%edx,8) + pushl __bessel_error_codes@GOTOFF(%ebx,%edx,8) + pushl 4+__bessel_error_codes@GOTOFF(%ebx) + pushl __bessel_error_codes@GOTOFF(%ebx) + lea 136(%esp), %esi + pushl %esi + lea 64(%esp), %edi + pushl %edi + call __dpml_pack__ +..B8.19: + movl 64(%esp), %esi + movl 144(%esp), %eax + movl 148(%esp), %edx + movl 152(%esp), %ecx + movl 156(%esp), %ebx + movl %eax, (%esi) + movl %edx, 4(%esi) + movl %ecx, 8(%esi) + movl %ebx, 12(%esi) + movl 160(%esp), %edi + xorl %esp, %edi + cmpl %gs:20, %edi + jne ..B8.21 +..B8.20: + movl %esi, %eax + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B8.21: + movl 60(%esp), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type __ynq,@function + .size __ynq,.-__ynq + .data +# -- End __ynq + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.96: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.96,@object + .size .L_2il0floatpacket.96,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.97: + .byte 0x00,0xf0,0x25,0x8d,0xd1,0x3a,0xaa,0xb8,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.97,@object + .size .L_2il0floatpacket.97,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.98: + .byte 0x00,0xe0,0x96,0x4f,0xd2,0x1c,0xb2,0xe9,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.98,@object + .size .L_2il0floatpacket.98,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.99: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0d,0x40,0x00,0x00 + .type .L_2il0floatpacket.99,@object + .size .L_2il0floatpacket.99,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.100: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0xdc,0x80,0x0d,0xc0,0x00,0x00 + .type .L_2il0floatpacket.100,@object + .size .L_2il0floatpacket.100,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.101: + .byte 0x00,0x00,0x00,0x00,0x00,0xe2,0x95,0x8f,0x02,0x40,0x00,0x00 + .type .L_2il0floatpacket.101,@object + .size .L_2il0floatpacket.101,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.102: + .byte 0x00,0x00,0x00,0x00,0x00,0x91,0xdd,0xa3,0x03,0x40,0x00,0x00 + .type .L_2il0floatpacket.102,@object + .size .L_2il0floatpacket.102,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.103: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.103,@object + .size .L_2il0floatpacket.103,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.104: + .byte 0x00,0x00,0x00,0x00,0x00,0x3b,0xaa,0xb8,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.104,@object + .size .L_2il0floatpacket.104,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.105: + .byte 0x00,0x00,0x00,0x00,0x00,0xa9,0xe2,0xe6,0x05,0x40,0x00,0x00 + .type .L_2il0floatpacket.105,@object + .size .L_2il0floatpacket.105,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.106: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x01,0x40,0x00,0x00 + .type .L_2il0floatpacket.106,@object + .size .L_2il0floatpacket.106,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.107: + .byte 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.107,@object + .size .L_2il0floatpacket.107,12 + .space 4, 0x00 # pad + .align 8 +__bessel_error_codes: + .long 0x00000000,0x00000000 + .long 0x00000081,0x00000000 + .long 0x00000082,0x00000000 + .long 0x00000083,0x00000000 + .long 0x00000084,0x00000000 + .long 0x0000008c,0x00000000 + .long 0x00000090,0x00000000 + .long 0x0000008f,0x00000000 + .type __bessel_error_codes,@object + .size __bessel_error_codes,64 + .align 4 +__bessel_x_table: + .long 4527112 + .long 882002208 + .long 4527112 + .long 609222656 + .long 4527112 + .long 340787200 + .long 0 + .long 0 + .long 2 + .long 0 + .long 2162758664 + .long 1056696334 + .long 15799304 + .long 796782607 + .long 2163807240 + .long 536868879 + .long 0 + .long 0 + .long 136 + .long 0 + .long 137 + .long 0 + .long 138 + .long 0 + .long 139 + .long 0 + .long 141 + .long 0 + .long 142 + .long 0 + .long 2943289511 + .long 514282869 + .long 12841452 + .long 4160750144 + .long 3101294049 + .long 2582161780 + .long 1312087176 + .long 1489306811 + .long 19644348 + .long 45583118 + .long 2057404378 + .long 3169098683 + .long 3035415578 + .long 893843444 + .long 337 + .long 0 + .long 1783633315 + .long 1777532950 + .long 15440 + .long 0 + .long 1098024042 + .long 3019602458 + .long 814258 + .long 0 + .long 225592541 + .long 3983311110 + .long 37212291 + .long 0 + .long 2852953733 + .long 2839658485 + .long 1458597808 + .long 0 + .long 4135355606 + .long 2153351721 + .long 1172250754 + .long 11 + .long 1418543880 + .long 1134849789 + .long 691229967 + .long 312 + .long 221999422 + .long 2942275987 + .long 892175906 + .long 7082 + .long 183528404 + .long 1091137495 + .long 33669418 + .long 128779 + .long 2062842702 + .long 3593466159 + .long 2350547321 + .long 1825862 + .long 3242024385 + .long 1732973365 + .long 1193716022 + .long 19485117 + .long 1037993584 + .long 3230003709 + .long 1091314384 + .long 149320065 + .long 865418991 + .long 2685299556 + .long 265703573 + .long 769292094 + .long 699915261 + .long 300027119 + .long 1754654657 + .long 2412548808 + .long 1339780591 + .long 830077839 + .long 3026944889 + .long 3889644321 + .long 4103150545 + .long 428322165 + .long 2828272473 + .long 2229721522 + .long 2 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 367384380 + .long 4326353 + .long 2148 + .long 0 + .long 3463681883 + .long 689773508 + .long 115915 + .long 0 + .long 1865635225 + .long 1707083401 + .long 5659280 + .long 0 + .long 57566505 + .long 2904667094 + .long 238211523 + .long 0 + .long 2506436672 + .long 4038967033 + .long 4242689712 + .long 1 + .long 900230770 + .long 2061385255 + .long 3485051853 + .long 59 + .long 3028033191 + .long 3312441247 + .long 2225862006 + .long 1485 + .long 2615755381 + .long 2826778077 + .long 1673380806 + .long 29835 + .long 355106258 + .long 2404984212 + .long 1016211595 + .long 472327 + .long 1503440334 + .long 2187913929 + .long 749248049 + .long 5704462 + .long 3147631426 + .long 2675016444 + .long 3447985920 + .long 50328354 + .long 3866449770 + .long 2131485908 + .long 579515915 + .long 305317757 + .long 1140039843 + .long 2720631446 + .long 456203296 + .long 1162742504 + .long 3233022265 + .long 2052397230 + .long 3523447208 + .long 2379802096 + .long 4168515076 + .long 4109278998 + .long 173166154 + .long 1854372776 + .long 2 + .long 0 + .long 1759813577 + .long 941616103 + .long 12816876 + .long 4227858976 + .long 1634871482 + .long 2963569369 + .long 683137648 + .long 2191944453 + .long 1580116130 + .long 3956925442 + .long 2076563715 + .long 714524096 + .long 1425042529 + .long 556010 + .long 0 + .long 0 + .long 2705967279 + .long 111702325 + .long 0 + .long 0 + .long 3713308765 + .long 3252247564 + .long 4 + .long 0 + .long 2100681787 + .long 1255672466 + .long 747 + .long 0 + .long 3619987580 + .long 2926178414 + .long 99420 + .long 0 + .long 2512861058 + .long 4217543322 + .long 11034432 + .long 0 + .long 2336326559 + .long 4282922616 + .long 1003296232 + .long 0 + .long 961767164 + .long 880412311 + .long 74952366 + .long 17 + .long 651638352 + .long 3978983768 + .long 3866178891 + .long 965 + .long 1596163871 + .long 1924711161 + .long 2529806704 + .long 41195 + .long 4143448985 + .long 965000726 + .long 2579935101 + .long 1257069 + .long 3252814079 + .long 2428688082 + .long 440599394 + .long 25575240 + .long 2037391762 + .long 3718324471 + .long 2593618161 + .long 310260222 + .long 3513168611 + .long 3970741434 + .long 128123702 + .long 1820672813 + .long 3402733470 + .long 3892867495 + .long 1270945360 + .long 2922852432 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1986947947 + .long 53265381 + .long 0 + .long 0 + .long 3270284272 + .long 1932314788 + .long 2 + .long 0 + .long 4084347788 + .long 3083682757 + .long 409 + .long 0 + .long 2552809164 + .long 4060325593 + .long 58254 + .long 0 + .long 3829133869 + .long 1310009699 + .long 6940915 + .long 0 + .long 3083277873 + .long 3078742755 + .long 680947971 + .long 0 + .long 3385783917 + .long 3611832980 + .long 2295622592 + .long 12 + .long 3171596108 + .long 2891115348 + .long 838843771 + .long 777 + .long 3771422218 + .long 1148182025 + .long 434950258 + .long 36482 + .long 393135174 + .long 80483983 + .long 3817092537 + .long 1235511 + .long 594123027 + .long 65162621 + .long 1218473398 + .long 28145623 + .long 3536617861 + .long 375824456 + .long 425129817 + .long 385237492 + .long 633237591 + .long 649365651 + .long 313906709 + .long 2545942344 + .long 873029334 + .long 423671385 + .long 1111949612 + .long 4235958077 + .long 4294967293 + .long 0 + .long 4159743234 + .long 1365459778 + .long 12825068 + .long 4227858976 + .long 1727418030 + .long 2322967398 + .long 1034782148 + .long 1761143608 + .long 748103118 + .long 681764742 + .long 1945985884 + .long 1037518188 + .long 2731139269 + .long 559058 + .long 0 + .long 0 + .long 3638286185 + .long 115784543 + .long 0 + .long 0 + .long 484918398 + .long 4013875548 + .long 4 + .long 0 + .long 868380236 + .long 106340102 + .long 775 + .long 0 + .long 3771022282 + .long 1666157217 + .long 103048 + .long 0 + .long 470645992 + .long 2100027425 + .long 11422638 + .long 0 + .long 1279250702 + .long 1788924811 + .long 1036227271 + .long 0 + .long 3067063928 + .long 3886781995 + .long 2181909072 + .long 17 + .long 103786080 + .long 119465851 + .long 1602069376 + .long 987 + .long 314091048 + .long 4120514941 + .long 1703984391 + .long 41665 + .long 3153492716 + .long 1769936992 + .long 3277791366 + .long 1248908 + .long 2480865882 + .long 357555572 + .long 1426486202 + .long 24641724 + .long 925215435 + .long 3875415602 + .long 2242310174 + .long 283170307 + .long 1206749920 + .long 1745236754 + .long 421850802 + .long 1512988987 + .long 554528472 + .long 4124376878 + .long 999726568 + .long 2331757501 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 844883384 + .long 48877615 + .long 0 + .long 0 + .long 613626429 + .long 1016694622 + .long 2 + .long 0 + .long 733791182 + .long 4037492605 + .long 370 + .long 0 + .long 2511602797 + .long 962949943 + .long 52209 + .long 0 + .long 2469661725 + .long 4226370589 + .long 6143972 + .long 0 + .long 2060721069 + .long 3581658067 + .long 593539814 + .long 0 + .long 2839602819 + .long 4222464368 + .long 3064291281 + .long 10 + .long 592311022 + .long 275206449 + .long 2221002398 + .long 647 + .long 3453980290 + .long 1100410175 + .long 2256369516 + .long 29367 + .long 965726650 + .long 341239821 + .long 1020304938 + .long 947922 + .long 2152956293 + .long 1358966229 + .long 796742083 + .long 20128900 + .long 2203770174 + .long 4010517667 + .long 1001215390 + .long 247246889 + .long 118635824 + .long 336180557 + .long 907042493 + .long 1379503488 + .long 1731363265 + .long 2376282645 + .long 3253758107 + .long 2155609720 + .long 4294967293 + .long 0 + .long 1133938837 + .long 1788275660 + .long 12816876 + .long 4227858976 + .long 328577348 + .long 3165265924 + .long 1527252342 + .long 1339392541 + .long 2394531985 + .long 243403399 + .long 1651082908 + .long 3768234999 + .long 1764410062 + .long 1127868 + .long 0 + .long 0 + .long 380965293 + .long 236501030 + .long 0 + .long 0 + .long 4057780011 + .long 296466121 + .long 10 + .long 0 + .long 1915520970 + .long 2413700929 + .long 1578 + .long 0 + .long 2515416277 + .long 1400529095 + .long 209346 + .long 0 + .long 1507502659 + .long 119133009 + .long 23121417 + .long 0 + .long 822245729 + .long 2123535665 + .long 2086838594 + .long 0 + .long 2761614169 + .long 2187408238 + .long 28089432 + .long 35 + .long 552668793 + .long 2572470762 + .long 825632309 + .long 1954 + .long 1089676525 + .long 4007660420 + .long 2284740089 + .long 81273 + .long 3790860620 + .long 4250011568 + .long 3911718864 + .long 2386138 + .long 1569325755 + .long 1413720016 + .long 751491568 + .long 45731817 + .long 955105128 + .long 1250521740 + .long 2097840313 + .long 506337017 + .long 1624392615 + .long 4258574603 + .long 3379569620 + .long 2624122564 + .long 4107144163 + .long 2368467334 + .long 1634973330 + .long 3993629493 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 818934838 + .long 89458952 + .long 0 + .long 0 + .long 1917175450 + .long 275918876 + .long 4 + .long 0 + .long 745599157 + .long 3172395316 + .long 667 + .long 0 + .long 2952822384 + .long 492051402 + .long 92937 + .long 0 + .long 2206545778 + .long 108664272 + .long 10789849 + .long 0 + .long 3593487476 + .long 2223761325 + .long 1025213015 + .long 0 + .long 4186460497 + .long 2115107000 + .long 546575231 + .long 18 + .long 4222869425 + .long 1697786641 + .long 1644425336 + .long 1067 + .long 2279245768 + .long 3297743944 + .long 144043411 + .long 46814 + .long 528690514 + .long 2305832912 + .long 3885610801 + .long 1446642 + .long 3948180674 + .long 1400240622 + .long 2848238597 + .long 29038477 + .long 365799999 + .long 3493109055 + .long 720503959 + .long 333431672 + .long 4157886487 + .long 4286999543 + .long 464978815 + .long 1767352013 + .long 3339500879 + .long 5789261 + .long 740497786 + .long 2709489262 + .long 4294967292 + .long 0 + .long 675685466 + .long 2210650544 + .long 12825068 + .long 4227858976 + .long 2475592912 + .long 4007987703 + .long 795233231 + .long 3544111414 + .long 3119445785 + .long 4019086602 + .long 1815298636 + .long 3651400695 + .long 250417896 + .long 1132895 + .long 0 + .long 0 + .long 1599660003 + .long 238893558 + .long 0 + .long 0 + .long 4178878964 + .long 640014589 + .long 10 + .long 0 + .long 3652653430 + .long 1664916825 + .long 1586 + .long 0 + .long 506609104 + .long 279824532 + .long 209578 + .long 0 + .long 3394823516 + .long 2710891899 + .long 23032181 + .long 0 + .long 1068742364 + .long 3396859346 + .long 2065409978 + .long 0 + .long 1532264156 + .long 1783373111 + .long 1537162281 + .long 34 + .long 3404313527 + .long 645034109 + .long 1238696626 + .long 1897 + .long 2815751506 + .long 1216048877 + .long 2381163022 + .long 77819 + .long 681356606 + .long 1742374831 + .long 1470157118 + .long 2245756 + .long 3583839604 + .long 3430133311 + .long 3428750273 + .long 42198880 + .long 2624104293 + .long 3836925937 + .long 2616934709 + .long 458497922 + .long 4091889117 + .long 2154475757 + .long 1334377092 + .long 2344404304 + .long 3811467832 + .long 4225344580 + .long 3014131639 + .long 3548440700 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2101683395 + .long 163038220 + .long 0 + .long 0 + .long 1150331703 + .long 1497034637 + .long 7 + .long 0 + .long 1295008257 + .long 2962522183 + .long 1195 + .long 0 + .long 193789761 + .long 1257830278 + .long 164530 + .long 0 + .long 3810960890 + .long 1878269909 + .long 18845080 + .long 0 + .long 2863024615 + .long 258783337 + .long 1761897164 + .long 0 + .long 2435461135 + .long 4254653612 + .long 2378780257 + .long 30 + .long 3635296493 + .long 4161741958 + .long 2074908190 + .long 1757 + .long 3250897880 + .long 2210089015 + .long 2132559608 + .long 74948 + .long 2166588251 + .long 3427170173 + .long 756319997 + .long 2241223 + .long 107629526 + .long 2814783011 + .long 580266263 + .long 43402774 + .long 2488417593 + .long 4037868436 + .long 2684236844 + .long 482393505 + .long 1636043988 + .long 2549915956 + .long 1055410979 + .long 2500896928 + .long 2063349270 + .long 3231350804 + .long 4156853657 + .long 3802515847 + .long 4294967291 + .long 0 + .long 191176124 + .long 2632795962 + .long 12816876 + .long 4227858976 + .long 1355787731 + .long 2425457148 + .long 539364904 + .long 1079897623 + .long 897043330 + .long 2066037045 + .long 1494461853 + .long 2159441332 + .long 2366379069 + .long 1131867 + .long 0 + .long 0 + .long 161545432 + .long 239220328 + .long 0 + .long 0 + .long 762722372 + .long 576200370 + .long 10 + .long 0 + .long 3468035492 + .long 1642011913 + .long 1578 + .long 0 + .long 4253764606 + .long 2733292311 + .long 207600 + .long 0 + .long 2811470101 + .long 3269311219 + .long 22691285 + .long 0 + .long 1825255966 + .long 1189284970 + .long 2021353589 + .long 0 + .long 717526141 + .long 2244953537 + .long 1522450794 + .long 33 + .long 693565287 + .long 2333767130 + .long 715945548 + .long 1824 + .long 2985180089 + .long 935432992 + .long 3298648348 + .long 73985 + .long 1392357808 + .long 2627674694 + .long 3107871798 + .long 2108973 + .long 3903806984 + .long 3473675411 + .long 4215247699 + .long 39146099 + .long 2236383345 + .long 2775867013 + .long 1051360344 + .long 420899965 + .long 715332657 + .long 3204539120 + .long 3177676604 + .long 2136936117 + .long 1567224951 + .long 2092241552 + .long 1304170706 + .long 3225156278 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3855812151 + .long 148081926 + .long 0 + .long 0 + .long 1028065361 + .long 2668697612 + .long 6 + .long 0 + .long 728439685 + .long 892227407 + .long 1067 + .long 0 + .long 615906957 + .long 1950415562 + .long 145255 + .long 0 + .long 3284206690 + .long 4202823521 + .long 16428718 + .long 0 + .long 1576659798 + .long 3860187404 + .long 1513740564 + .long 0 + .long 1223428711 + .long 1000755308 + .long 3492805977 + .long 25 + .long 1363712775 + .long 563079876 + .long 2891886022 + .long 1456 + .long 1912616499 + .long 4019273916 + .long 1170042322 + .long 60815 + .long 2578791056 + .long 3763338518 + .long 4013988507 + .long 1778302 + .long 596369036 + .long 4167829437 + .long 495223280 + .long 33706721 + .long 3069656582 + .long 1025646758 + .long 2029385299 + .long 368055588 + .long 4229256156 + .long 252497843 + .long 655863054 + .long 1886199584 + .long 3468886839 + .long 4222796798 + .long 2935312587 + .long 2855531945 + .long 4294967291 + .long 0 + .long 2797952740 + .long 3054806814 + .long 12825068 + .long 4227858976 + .long 2679935261 + .long 2846977675 + .long 1518593598 + .long 771365947 + .long 2901840529 + .long 102047653 + .long 404923885 + .long 709259131 + .long 475240934 + .long 1125214 + .long 0 + .long 0 + .long 1836195777 + .long 237921320 + .long 0 + .long 0 + .long 620715017 + .long 203920416 + .long 10 + .long 0 + .long 2730396855 + .long 4074598327 + .long 1558 + .long 0 + .long 149951721 + .long 1542475780 + .long 204126 + .long 0 + .long 895086698 + .long 26046181 + .long 22194201 + .long 0 + .long 1052098554 + .long 3499556639 + .long 1964976743 + .long 0 + .long 3912081837 + .long 3256319751 + .long 845978380 + .long 32 + .long 2103533506 + .long 1288917748 + .long 344362072 + .long 1747 + .long 586607141 + .long 2789855780 + .long 789521480 + .long 70264 + .long 1029756229 + .long 2597195099 + .long 1036923741 + .long 1985929 + .long 570319344 + .long 1441637551 + .long 3714173380 + .long 36574571 + .long 1955754200 + .long 3807195269 + .long 90410504 + .long 390763661 + .long 2874958444 + .long 3633243115 + .long 2931863300 + .long 1975635819 + .long 32243731 + .long 2591757144 + .long 3895319176 + .long 2976685396 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3502958424 + .long 134252990 + .long 0 + .long 0 + .long 2150545646 + .long 4111632521 + .long 5 + .long 0 + .long 2999463670 + .long 3120574364 + .long 951 + .long 0 + .long 681502082 + .long 4195687681 + .long 128253 + .long 0 + .long 442998991 + .long 979480158 + .long 14344565 + .long 0 + .long 151969242 + .long 4070078334 + .long 1305331397 + .long 0 + .long 1826390155 + .long 1249420678 + .long 4104872299 + .long 21 + .long 1355768955 + .long 3758834208 + .long 3412700795 + .long 1220 + .long 1644384830 + .long 2135273975 + .long 2887874099 + .long 50190 + .long 1150050798 + .long 2243957583 + .long 2798432622 + .long 1445747 + .long 3460890697 + .long 2393108922 + .long 2317365582 + .long 27037249 + .long 135336093 + .long 93459488 + .long 4047224670 + .long 292116325 + .long 2632066877 + .long 2478679361 + .long 3592211274 + .long 1486901023 + .long 4259160346 + .long 2383522946 + .long 1229950112 + .long 2245322564 + .long 4294967291 + .long 0 + .long 4131724546 + .long 247119503 + .long 229390 + .long 4227858728 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1920268374 + .long 676671 + .long 0 + .long 0 + .long 2648589321 + .long 145893005 + .long 0 + .long 0 + .long 86363579 + .long 792199897 + .long 6 + .long 0 + .long 3569661012 + .long 3338031321 + .long 964 + .long 0 + .long 3537357668 + .long 2546852361 + .long 127350 + .long 0 + .long 1674639321 + .long 989707703 + .long 14008565 + .long 0 + .long 633069455 + .long 3178427980 + .long 1260770870 + .long 0 + .long 2929308222 + .long 1214878390 + .long 581189477 + .long 21 + .long 3037977477 + .long 3608983388 + .long 2481839655 + .long 1183 + .long 1571270935 + .long 1253493999 + .long 1158050441 + .long 49710 + .long 2588063047 + .long 3245086386 + .long 381774870 + .long 1491308 + .long 2638540175 + .long 477218587 + .long 3340530119 + .long 29826161 + .long 1326835123 + .long 1431655765 + .long 1431655765 + .long 357913941 + .long 4293747565 + .long 4294967295 + .long 4294967295 + .long 2147483647 + .long 4294964933 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .long 105434711 + .long 715574136 + .long 12825068 + .long 4227858976 + .long 2071479615 + .long 4114262957 + .long 3040350773 + .long 3578447305 + .long 1647168078 + .long 978698920 + .long 1144287138 + .long 3827795094 + .long 3787403973 + .long 562609 + .long 0 + .long 0 + .long 1649578671 + .long 117913179 + .long 0 + .long 0 + .long 3082368152 + .long 40122077 + .long 5 + .long 0 + .long 602895375 + .long 3952322020 + .long 783 + .long 0 + .long 3838465116 + .long 2181233212 + .long 103846 + .long 0 + .long 851468155 + .long 4001763569 + .long 11469451 + .long 0 + .long 3659498813 + .long 523695164 + .long 1037041443 + .long 0 + .long 2978199351 + .long 773277203 + .long 2051066178 + .long 17 + .long 4092624060 + .long 3930860161 + .long 3294762475 + .long 984 + .long 1105652893 + .long 1066438988 + .long 3642064414 + .long 41652 + .long 2196971596 + .long 2146191353 + .long 3442355222 + .long 1259557 + .long 3918894073 + .long 188553237 + .long 818155667 + .long 25403502 + .long 852571760 + .long 3121326526 + .long 2509267963 + .long 306918409 + .long 2896427178 + .long 2552665716 + .long 2229539464 + .long 1835168886 + .long 1453277625 + .long 518768794 + .long 1711011538 + .long 3459676865 + .long 0 + .long 0 + .long 2062472710 + .long 69166 + .long 0 + .long 0 + .long 673615662 + .long 23833985 + .long 0 + .long 0 + .long 630248642 + .long 363685088 + .long 1 + .long 0 + .long 288759411 + .long 2697305718 + .long 181 + .long 0 + .long 2130785052 + .long 823708847 + .long 25870 + .long 0 + .long 1430316470 + .long 3023974030 + .long 3089586 + .long 0 + .long 3827036731 + .long 3302510044 + .long 304068797 + .long 0 + .long 3738696708 + .long 3274114857 + .long 2670490624 + .long 5 + .long 287265850 + .long 4109473262 + .long 3360573366 + .long 350 + .long 38249035 + .long 2812769293 + .long 2052670485 + .long 16622 + .long 3926290357 + .long 206759826 + .long 2443135158 + .long 571444 + .long 1809246839 + .long 3759763742 + .long 1694050886 + .long 13356266 + .long 1847069514 + .long 3357213528 + .long 2594247192 + .long 192045418 + .long 1427481913 + .long 3504276391 + .long 3430325004 + .long 1423790384 + .long 900295939 + .long 3843660490 + .long 2372410664 + .long 3611630842 + .long 4294967294 + .long 0 + .long 774013863 + .long 1145724988 + .long 12816876 + .long 4227858976 + .long 2744287014 + .long 3766464413 + .long 1053213460 + .long 3969062622 + .long 1083456455 + .long 3049621789 + .long 3365086587 + .long 561540346 + .long 2996396832 + .long 575091 + .long 0 + .long 0 + .long 42660608 + .long 117761546 + .long 0 + .long 0 + .long 3056183536 + .long 25400137 + .long 5 + .long 0 + .long 3539354956 + .long 964064098 + .long 784 + .long 0 + .long 1133846550 + .long 3354628177 + .long 103987 + .long 0 + .long 837408368 + .long 1875825334 + .long 11493772 + .long 0 + .long 4020356818 + .long 15105701 + .long 1039623118 + .long 0 + .long 2432213228 + .long 4116600081 + .long 2213395342 + .long 17 + .long 346536517 + .long 2329406249 + .long 1562759336 + .long 985 + .long 1904777685 + .long 777730941 + .long 3468653957 + .long 41521 + .long 2565172885 + .long 3392131685 + .long 216627896 + .long 1245806 + .long 777484384 + .long 1373172746 + .long 529073424 + .long 24734325 + .long 1189796029 + .long 1140288371 + .long 1770133260 + .long 289389693 + .long 2194668596 + .long 3631308278 + .long 3147219318 + .long 1613893367 + .long 344927104 + .long 1168140252 + .long 980702046 + .long 2577974684 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1881749350 + .long 46062706 + .long 0 + .long 0 + .long 2009952654 + .long 475434148 + .long 2 + .long 0 + .long 3595153284 + .long 3894518978 + .long 350 + .long 0 + .long 1401741016 + .long 800557075 + .long 49546 + .long 0 + .long 1250374609 + .long 1417939249 + .long 5854570 + .long 0 + .long 3066837935 + .long 3745800702 + .long 568662855 + .long 0 + .long 4187727968 + .long 1730013373 + .long 1461665574 + .long 10 + .long 3341641980 + .long 2588791038 + .long 1829968615 + .long 631 + .long 888818201 + .long 3523374130 + .long 852659386 + .long 29067 + .long 3905449900 + .long 720793762 + .long 1836357526 + .long 959598 + .long 711023215 + .long 2187868163 + .long 363719992 + .long 21124528 + .long 3782390642 + .long 1386816912 + .long 3690959132 + .long 275994811 + .long 3562870039 + .long 2887822114 + .long 2407074109 + .long 1720896075 + .long 723327461 + .long 1298307143 + .long 454424891 + .long 2939711024 + .long 4294967293 + .long 0 + .long 4220957082 + .long 1571153381 + .long 12825068 + .long 4227858976 + .long 4024519172 + .long 2730919557 + .long 1456036120 + .long 3256132268 + .long 2931624203 + .long 1339507405 + .long 1357793012 + .long 1094045067 + .long 1129712150 + .long 1138961 + .long 0 + .long 0 + .long 2372829177 + .long 237557530 + .long 0 + .long 0 + .long 534122416 + .long 423932365 + .long 10 + .long 0 + .long 4247263216 + .long 4283734547 + .long 1580 + .long 0 + .long 2387955306 + .long 607897802 + .long 209396 + .long 0 + .long 2812500241 + .long 994269493 + .long 23101510 + .long 0 + .long 3000333735 + .long 388858992 + .long 2083539857 + .long 0 + .long 1161363350 + .long 3153424268 + .long 4076649817 + .long 34 + .long 1819801357 + .long 1812729011 + .long 330148996 + .long 1953 + .long 3163500019 + .long 3864465446 + .long 4064814974 + .long 81467 + .long 3858761013 + .long 3692736596 + .long 1902533809 + .long 2406436 + .long 3293643408 + .long 375345917 + .long 2826147377 + .long 46631566 + .long 4164807482 + .long 4162856869 + .long 2610851470 + .long 525451848 + .long 2048614181 + .long 1569367797 + .long 3543942876 + .long 2777034414 + .long 3312093651 + .long 708453697 + .long 1978042629 + .long 4289897122 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2071065822 + .long 86614531 + .long 0 + .long 0 + .long 2391713785 + .long 4060239028 + .long 3 + .long 0 + .long 4029056008 + .long 1846783416 + .long 650 + .long 0 + .long 161647879 + .long 3413412248 + .long 90917 + .long 0 + .long 436274283 + .long 2466277660 + .long 10613189 + .long 0 + .long 671943584 + .long 553150431 + .long 1015563947 + .long 0 + .long 1753238306 + .long 1517906611 + .long 532738342 + .long 18 + .long 618689867 + .long 596492050 + .long 2460930076 + .long 1080 + .long 414131426 + .long 1367052230 + .long 3308909536 + .long 48209 + .long 4126473295 + .long 3381931776 + .long 1805298000 + .long 1525871 + .long 636148702 + .long 2186154781 + .long 2942928489 + .long 31683165 + .long 999999630 + .long 4126401816 + .long 259460410 + .long 380946890 + .long 231980038 + .long 363549591 + .long 883055596 + .long 2118559672 + .long 3622330114 + .long 1609129610 + .long 63100786 + .long 3373399958 + .long 4294967292 + .long 0 + .long 1588683414 + .long 1994957096 + .long 12816876 + .long 4227858976 + .long 2267877675 + .long 3576551320 + .long 1765045200 + .long 3464483214 + .long 1351689592 + .long 3801296041 + .long 352384788 + .long 331703635 + .long 605298272 + .long 1136492 + .long 0 + .long 0 + .long 2681104739 + .long 238950871 + .long 0 + .long 0 + .long 3149807504 + .long 621710226 + .long 10 + .long 0 + .long 2595166296 + .long 121246070 + .long 1585 + .long 0 + .long 2215012362 + .long 2482367452 + .long 209363 + .long 0 + .long 470943915 + .long 668008525 + .long 23014074 + .long 0 + .long 3763658407 + .long 3343124614 + .long 2065508072 + .long 0 + .long 249623666 + .long 2390602642 + .long 1795904366 + .long 34 + .long 1346725057 + .long 2927659279 + .long 1029310809 + .long 1906 + .long 3831989490 + .long 3024162362 + .long 457912312 + .long 78555 + .long 1623643704 + .long 979247650 + .long 4029398248 + .long 2282874 + .long 2791098952 + .long 2391841680 + .long 2696257895 + .long 43306505 + .long 262637107 + .long 3763159487 + .long 2938992385 + .long 475778611 + .long 3299175406 + .long 3677201670 + .long 2349553020 + .long 2458659840 + .long 206020084 + .long 2363120772 + .long 2638136209 + .long 3751386051 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3034634732 + .long 80259059 + .long 0 + .long 0 + .long 2987375659 + .long 2703374687 + .long 3 + .long 0 + .long 1215607278 + .long 4163686255 + .long 592 + .long 0 + .long 781938720 + .long 2086477677 + .long 82005 + .long 0 + .long 3556471813 + .long 3031971904 + .long 9451560 + .long 0 + .long 2005655437 + .long 2494233436 + .long 890598760 + .long 0 + .long 1167836918 + .long 114850616 + .long 2568442225 + .long 15 + .long 2351511177 + .long 1547877599 + .long 2724662709 + .long 908 + .long 1583056039 + .long 1830443712 + .long 1719394286 + .long 39382 + .long 1124627201 + .long 674092017 + .long 1868383046 + .long 1202161 + .long 4262245498 + .long 1815295967 + .long 3756878985 + .long 23872494 + .long 1013133814 + .long 1390137141 + .long 1845508344 + .long 272711216 + .long 2632746813 + .long 493954138 + .long 4257964097 + .long 1450886530 + .long 1659393003 + .long 4235627183 + .long 3605632322 + .long 2252460395 + .long 4294967292 + .long 0 + .long 1932081087 + .long 2418003218 + .long 12825068 + .long 4227858976 + .long 675685466 + .long 2210650544 + .long 2635457388 + .long 3001216681 + .long 2383987892 + .long 1958452314 + .long 200318573 + .long 1670080688 + .long 1772035109 + .long 1132935 + .long 0 + .long 0 + .long 2224132738 + .long 239067824 + .long 0 + .long 0 + .long 2504702558 + .long 548466910 + .long 10 + .long 0 + .long 120798343 + .long 3554901277 + .long 1577 + .long 0 + .long 2434954499 + .long 1660365081 + .long 207659 + .long 0 + .long 2744534538 + .long 1767005024 + .long 22722744 + .long 0 + .long 1354085614 + .long 573653951 + .long 2027648348 + .long 0 + .long 2302238895 + .long 940817979 + .long 2333007942 + .long 33 + .long 4044378246 + .long 2424318367 + .long 54614345 + .long 1841 + .long 3277428544 + .long 937510890 + .long 2353849014 + .long 75024 + .long 4005612974 + .long 1580435742 + .long 1601652905 + .long 2151432 + .long 3782038889 + .long 2892349902 + .long 3709353570 + .long 40211969 + .long 2209533886 + .long 1632935844 + .long 1972351296 + .long 435469920 + .long 2489865929 + .long 3249608891 + .long 2176055770 + .long 2225282526 + .long 4163770951 + .long 1426482641 + .long 75146285 + .long 3375249381 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2220915002 + .long 147504303 + .long 0 + .long 0 + .long 3383683424 + .long 2662024159 + .long 6 + .long 0 + .long 4203741875 + .long 3065385408 + .long 1071 + .long 0 + .long 94574798 + .long 3694012699 + .long 146649 + .long 0 + .long 548197575 + .long 3705365680 + .long 16693691 + .long 0 + .long 2971661595 + .long 3995690294 + .long 1550219778 + .long 0 + .long 3364157924 + .long 536970539 + .long 2951498969 + .long 26 + .long 3606982515 + .long 2998613798 + .long 1572386296 + .long 1523 + .long 54159713 + .long 2382254602 + .long 1960159626 + .long 64476 + .long 164299812 + .long 2501105432 + .long 2657580848 + .long 1915496 + .long 4191466314 + .long 1475491836 + .long 409725690 + .long 36942237 + .long 2000214888 + .long 3808326374 + .long 4191271566 + .long 410491162 + .long 3021924263 + .long 3759042010 + .long 567945948 + .long 2137524835 + .long 2922089864 + .long 3203830329 + .long 752382353 + .long 3278805360 + .long 4294967291 + .long 0 + .long 223335381 + .long 2840633637 + .long 12816876 + .long 4227858976 + .long 191176124 + .long 2632795962 + .long 792829484 + .long 4194095148 + .long 1561179743 + .long 586327156 + .long 2807878837 + .long 3545818423 + .long 1415596998 + .long 1125924 + .long 0 + .long 0 + .long 2335397241 + .long 237899312 + .long 0 + .long 0 + .long 898966976 + .long 220219689 + .long 10 + .long 0 + .long 3140042207 + .long 3171383055 + .long 1560 + .long 0 + .long 2021920923 + .long 1061467961 + .long 204590 + .long 0 + .long 1780915469 + .long 3394528573 + .long 22279398 + .long 0 + .long 2938289575 + .long 3726010345 + .long 1976658045 + .long 0 + .long 1742882295 + .long 3191343047 + .long 2047550512 + .long 32 + .long 3647296052 + .long 2253947992 + .long 1300129447 + .long 1768 + .long 2864334604 + .long 1571083743 + .long 2473956825 + .long 71411 + .long 902177211 + .long 1309134586 + .long 1494319522 + .long 2027873 + .long 1978202312 + .long 2898857432 + .long 1838265108 + .long 37534288 + .long 440015974 + .long 4230775195 + .long 1255344562 + .long 402981746 + .long 1205443830 + .long 4140044432 + .long 3282462476 + .long 2046231097 + .long 2809323527 + .long 1074462473 + .long 1051546203 + .long 3093465233 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1994591040 + .long 134874738 + .long 0 + .long 0 + .long 1154796671 + .long 33466848 + .long 6 + .long 0 + .long 944609558 + .long 611410016 + .long 964 + .long 0 + .long 3394269576 + .long 3253723903 + .long 130617 + .long 0 + .long 1604599336 + .long 2571734283 + .long 14700043 + .long 0 + .long 2720136884 + .long 1760790051 + .long 1347449133 + .long 0 + .long 3340661604 + .long 3195040324 + .long 3680379603 + .long 22 + .long 3451695816 + .long 2081337828 + .long 1427065647 + .long 1283 + .long 2755833528 + .long 3578899323 + .long 1127406403 + .long 53342 + .long 2103438216 + .long 2925829331 + .long 133275521 + .long 1554875 + .long 3003940918 + .long 1302060887 + .long 2008749614 + .long 29436400 + .long 4279932662 + .long 1473928468 + .long 533396292 + .long 321840330 + .long 3248261436 + .long 2035472962 + .long 372258839 + .long 1655927148 + .long 3127294521 + .long 3128066919 + .long 2865156314 + .long 2523236171 + .long 4294967291 + .long 0 + .long 1890690921 + .long 3263011055 + .long 12825068 + .long 4227858976 + .long 2797952740 + .long 3054806814 + .long 1894667006 + .long 214237447 + .long 1296756846 + .long 4060330468 + .long 1098085821 + .long 3604642180 + .long 1726893371 + .long 1115219 + .long 0 + .long 0 + .long 494710856 + .long 235638241 + .long 0 + .long 0 + .long 1193585816 + .long 3981686648 + .long 9 + .long 0 + .long 143797405 + .long 762868814 + .long 1536 + .long 0 + .long 898881458 + .long 2220674218 + .long 200569 + .long 0 + .long 271788931 + .long 1836576498 + .long 21741122 + .long 0 + .long 3732597210 + .long 2567748600 + .long 1918751890 + .long 0 + .long 3683010637 + .long 2674911154 + .long 1453366689 + .long 31 + .long 3314792629 + .long 3590832641 + .long 792084225 + .long 1695 + .long 710884882 + .long 1421882797 + .long 453673326 + .long 67984 + .long 4289998525 + .long 1545801705 + .long 2082770245 + .long 1917055 + .long 1427259630 + .long 3087470940 + .long 1747456958 + .long 35251400 + .long 2597591904 + .long 3049486553 + .long 2056710479 + .long 376393410 + .long 2213091204 + .long 2641098163 + .long 3971809407 + .long 1903717223 + .long 3244722564 + .long 177715146 + .long 3090222263 + .long 2872209565 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 4193727727 + .long 246007177 + .long 0 + .long 0 + .long 768822418 + .long 3782320021 + .long 10 + .long 0 + .long 2196079823 + .long 201893182 + .long 1732 + .long 0 + .long 1661061158 + .long 4260475543 + .long 232537 + .long 0 + .long 3959757821 + .long 1648015928 + .long 25908825 + .long 0 + .long 2136418328 + .long 2790862444 + .long 2348699355 + .long 0 + .long 14984150 + .long 3359899422 + .long 1557173094 + .long 39 + .long 2579163115 + .long 4209094591 + .long 2975956643 + .long 2181 + .long 809874233 + .long 1287653529 + .long 1784169535 + .long 89477 + .long 836980350 + .long 209256478 + .long 3015626027 + .long 2573945 + .long 2016221741 + .long 1745099515 + .long 1018088912 + .long 48139690 + .long 3329474215 + .long 1010710723 + .long 642962579 + .long 521003091 + .long 801578433 + .long 3224757113 + .long 3341503980 + .long 2660978634 + .long 2199935228 + .long 4052003304 + .long 2221814426 + .long 4038241008 + .long 4294967290 + .long 0 + .long 3178730751 + .long 116147812 + .long 14854636 + .long 416 + .long 416371481 + .long 2823641499 + .long 2506915568 + .long 4124207639 + .long 950494682 + .long 256731865 + .long 619428904 + .long 3037288495 + .long 4208811624 + .long 884105690 + .long 0 + .long 0 + .long 3410106176 + .long 4245208708 + .long 126 + .long 0 + .long 3116091236 + .long 3070791485 + .long 44137 + .long 0 + .long 1379902983 + .long 2256834745 + .long 12232777 + .long 0 + .long 2097914520 + .long 545273602 + .long 2619411277 + .long 0 + .long 215423817 + .long 3507318412 + .long 256238311 + .long 97 + .long 3668117219 + .long 4022295396 + .long 2420542464 + .long 10890 + .long 3822143167 + .long 3930114069 + .long 1325150521 + .long 798528 + .long 3699121161 + .long 791807715 + .long 67391017 + .long 33958538 + .long 3257898816 + .long 678025854 + .long 1894699409 + .long 674718922 + .long 1201340557 + .long 2594901103 + .long 3933905415 + .long 3704843775 + .long 4294967294 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 982743186 + .long 1840382683 + .long 8 + .long 0 + .long 2770471380 + .long 1232287742 + .long 3186 + .long 0 + .long 2689925901 + .long 4291161637 + .long 993651 + .long 0 + .long 1865452386 + .long 278667130 + .long 243198017 + .long 0 + .long 941914362 + .long 1579381843 + .long 2208801237 + .long 10 + .long 4030005343 + .long 1439537596 + .long 2913266490 + .long 1415 + .long 897709932 + .long 2611261457 + .long 3831192043 + .long 129715 + .long 2599986828 + .long 562288571 + .long 873738186 + .long 7347842 + .long 1676792497 + .long 2643238970 + .long 1059645264 + .long 218261805 + .long 3968061936 + .long 1814410518 + .long 4215318874 + .long 2360677848 + .long 4294967294 + .long 0 + .long 1965065697 + .long 125333813 + .long 29671681 + .long 368 + .long 2696892906 + .long 3837883846 + .long 4163818448 + .long 2636579655 + .long 352076257 + .long 2995873374 + .long 2356022824 + .long 2864685933 + .long 507647155 + .long 87534215 + .long 364999993 + .long 2297262027 + .long 3804603314 + .long 421232362 + .long 623004025 + .long 2436698064 + .long 857209363 + .long 4104727312 + .long 1300779075 + .long 2300222395 + .long 3549420260 + .long 815695431 + .long 3490474032 + .long 2175015012 + .long 273829883 + .long 837019448 + .long 1150859439 + .long 4129001094 + .long 166114890 + .long 262582295 + .long 2200440235 + .long 3934411649 + .long 4260765987 + .long 1496016656 + .long 613554758 + .long 3765455772 + .long 1537995402 + .long 3112915065 + .long 3831973801 + .long 3621881222 + .long 371259347 + .long 563988192 + .long 2577068580 + .long 3504039397 + .long 3892719810 + .long 2774136061 + .long 761863973 + .long 3413069278 + .long 932429307 + .long 3533847854 + .long 670352073 + .long 3351189942 + .long 332608650 + .long 3102655069 + .long 2958547113 + .long 3322177573 + .long 146996155 + .long 3411645617 + .long 2215850181 + .long 3332037184 + .long 590982538 + .long 2197714658 + .long 1764878165 + .long 3390200984 + .long 952267699 + .long 417090737 + .long 3487943763 + .long 3519763458 + .long 1338819266 + .long 2605877443 + .long 347561299 + .long 3761505334 + .long 3379093939 + .long 2405540353 + .long 1506019226 + .long 3884741458 + .long 2785505456 + .long 3086386584 + .long 2046080941 + .long 3789068741 + .long 1518238185 + .long 1088338119 + .long 1804079185 + .long 4226925859 + .long 2303172266 + .long 2741263628 + .long 633622237 + .long 3777083586 + .long 3757196004 + .long 294895316 + .long 27640459 + .long 432 + .long 2828420652 + .long 3361833042 + .long 1412248364 + .long 2211183849 + .long 0 + .long 3547577142 + .long 1 + .long 0 + .long 2851890648 + .long 450899591 + .long 287024625 + .long 4159553752 + .long 3788600515 + .long 2561792324 + .long 3962766183 + .long 3512577319 + .long 2861699545 + .long 2196522185 + .long 1554209519 + .long 4198958626 + .long 3194489346 + .long 2786967510 + .long 3304318871 + .long 3344542374 + .long 4105608152 + .long 867728568 + .long 2708443992 + .long 3505223656 + .long 1032912387 + .long 3711167273 + .long 1214238009 + .long 2611213035 + .long 3368625691 + .long 5584441 + .long 2611408711 + .long 2384597091 + .long 1152098306 + .long 3591611965 + .long 2962228819 + .long 3281323244 + .long 3071980506 + .long 3920864562 + .long 3855393805 + .long 2582452787 + .long 3343479107 + .long 1168797990 + .long 3053975971 + .long 3222544278 + .long 3909139483 + .long 1083468961 + .long 2101774947 + .long 2160722632 + .long 2110801092 + .long 4019214560 + .long 1350065479 + .long 2376260138 + .long 42240602 + .long 3769900699 + .long 2854857645 + .long 2686999005 + .long 4198697477 + .long 4081736268 + .long 2846299562 + .long 2478988733 + .long 427675101 + .long 2445602520 + .long 4233423029 + .long 2355264427 + .long 1558515652 + .long 2279564152 + .long 62666641 + .long 3298296210 + .long 1417642332 + .long 61859471 + .long 2115062510 + .long 2696409612 + .long 326492679 + .long 2534854374 + .long 1679925266 + .long 2160906787 + .long 3251033635 + .long 2671487866 + .long 2862247032 + .long 3574405396 + .long 3009660033 + .long 339349497 + .long 3007548001 + .long 2840034127 + .long 2252903388 + .long 1330394071 + .long 2157393054 + .long 2200692478 + .long 621144332 + .long 3987984878 + .long 1728372573 + .long 3841939891 + .long 2649374871 + .long 2008708732 + .long 1354882191 + .long 2904204888 + .long 3398077461 + .long 3906455313 + .long 2501808239 + .long 2340852904 + .long 257973487 + .long 728759453 + .long 30163463 + .long 848 + .long 3266633231 + .long 4249524844 + .long 2065907802 + .long 2501410748 + .long 2077120351 + .long 1559182036 + .long 2148606178 + .long 4119882265 + .long 315045067 + .long 14812806 + .long 1274331647 + .long 3156365682 + .long 238086315 + .long 2517423111 + .long 2041601736 + .long 2711078025 + .long 3652406632 + .long 753691269 + .long 2734041400 + .long 3820625006 + .long 2380832782 + .long 158270193 + .long 2340065183 + .long 2273321385 + .long 393890025 + .long 2894667190 + .long 1573700686 + .long 4092887025 + .long 464562897 + .long 303515614 + .long 3848216904 + .long 3328255744 + .long 1036006886 + .long 2121885428 + .long 3704818897 + .long 3211297370 + .long 1325824312 + .long 3493125121 + .long 3338748802 + .long 3232443331 + .long 3112594497 + .long 3307298736 + .long 2809691794 + .long 3731360010 + .long 3573632495 + .long 2312925567 + .long 629450595 + .long 3622381915 + .long 989010185 + .long 3398558103 + .long 4153621291 + .long 3607201927 + .long 2629100272 + .long 1953994464 + .long 1943384301 + .long 2759420002 + .long 2305022315 + .long 2391039855 + .long 612094863 + .long 3951603967 + .long 1340433416 + .long 3334026995 + .long 1491763737 + .long 4186248678 + .long 4198464715 + .long 87224683 + .long 4220145159 + .long 3881216024 + .long 2007772778 + .long 1722917095 + .long 2388984076 + .long 3799859053 + .long 732951595 + .long 3919415462 + .long 528829945 + .long 3610037081 + .long 3992395594 + .long 4037851002 + .long 1844118200 + .long 3714769074 + .long 3432638667 + .long 3108186388 + .long 746542694 + .long 3818486016 + .long 557823754 + .long 2427510280 + .long 3516120961 + .long 3892142094 + .long 1703329579 + .long 996501429 + .long 4081661750 + .long 3974028169 + .long 480847786 + .long 3006112619 + .long 1403431905 + .long 4065364793 + .long 1900483787 + .long 2649330773 + .long 651669812 + .long 4162988739 + .long 1619173352 + .long 1864819711 + .long 1131374484 + .long 4267744761 + .long 1834860043 + .long 2423625113 + .long 288099716 + .long 2190363742 + .long 2708503338 + .long 4126097102 + .long 3654529011 + .long 2251412339 + .long 3753107947 + .long 3496449780 + .long 2610603179 + .long 2317533940 + .long 3862344650 + .long 1030964414 + .long 451338797 + .long 2389337002 + .long 2524196363 + .long 569491811 + .long 2946926522 + .long 2467527406 + .long 196512138 + .long 497579000 + .long 2195809742 + .long 2552928386 + .long 1662952651 + .long 780129586 + .long 2880189481 + .long 2646511583 + .long 1545658730 + .long 789982365 + .long 191310475 + .long 2749424166 + .long 1470909419 + .long 1234100077 + .long 2044585165 + .long 2862876216 + .long 928663178 + .long 2102054363 + .long 3690288476 + .long 2988326180 + .long 2216922123 + .long 2305139484 + .long 4174545259 + .long 3130608048 + .long 1755153610 + .long 918723953 + .long 2738745609 + .long 3294047809 + .long 721728203 + .long 1773737866 + .long 4101484425 + .long 3433511350 + .long 1857351114 + .long 2879235855 + .long 1363799643 + .long 3536910801 + .long 4061718601 + .long 908917583 + .long 3005712244 + .long 4215915540 + .long 243897838 + .long 7660553 + .long 2731769662 + .long 2727825412 + .long 1695068807 + .long 2615038300 + .long 234665196 + .long 3149409338 + .long 2025012071 + .long 1264893574 + .long 1155162898 + .long 2643506208 + .long 3781832745 + .long 2126832235 + .long 1395780981 + .long 2754722035 + .long 4274723882 + .long 199777100 + .long 1853759306 + .long 3583381494 + .long 3072425958 + .long 993425135 + .long 3004341385 + .long 3435215656 + .long 3198694093 + .long 620059688 + .long 2085750463 + .long 2400804391 + .long 1026440073 + .long 2116228661 + .long 3422860059 + .long 3767238370 + .long 376557070 + .long 669608662 + .long 2826299222 + .long 4021726431 + .long 97861608 + .long 623049618 + .long 457143492 + .long 3494791496 + .long 647336461 + .long 20390326 + .long 156262610 + .long 3457815221 + .long 2242302115 + .long 1153736377 + .long 29917573 + .long 608 + .long 956831540 + .long 3804294695 + .long 1233656524 + .long 1169011973 + .long 3512247603 + .long 731707668 + .long 3804813427 + .long 3532496868 + .long 3861713254 + .long 3920998321 + .long 3249242362 + .long 2983748142 + .long 4254521127 + .long 3419828215 + .long 3612752470 + .long 3427243214 + .long 1865130836 + .long 1528519591 + .long 3104638828 + .long 2778394947 + .long 2428343797 + .long 2183879732 + .long 1050296790 + .long 3773933110 + .long 3652345540 + .long 2906583603 + .long 1426288469 + .long 3900013225 + .long 3885984869 + .long 2566242072 + .long 2597085889 + .long 3387828672 + .long 3402407620 + .long 2004411987 + .long 1378225957 + .long 3062031935 + .long 3648787989 + .long 92338370 + .long 4236899602 + .long 2817389734 + .long 1952242004 + .long 2304097414 + .long 127945474 + .long 2582972800 + .long 4281889637 + .long 2697225196 + .long 2199799063 + .long 2368525439 + .long 2882311446 + .long 2124741744 + .long 2454581530 + .long 2175676414 + .long 1363442533 + .long 235950345 + .long 3278607019 + .long 3991475143 + .long 2338347060 + .long 892652237 + .long 3886541672 + .long 3654822706 + .long 2206999749 + .long 359442761 + .long 1344250324 + .long 3448127457 + .long 2316542980 + .long 3829127353 + .long 220674587 + .long 3338303659 + .long 280815351 + .long 3269930602 + .long 4246425196 + .long 2475208849 + .long 3336161088 + .long 2206265573 + .long 1212344344 + .long 2473891454 + .long 491190659 + .long 2156317952 + .long 2981239741 + .long 2515194909 + .long 3609278228 + .long 1234146757 + .long 1026744012 + .long 2624029530 + .long 2704274272 + .long 1975162568 + .long 3276945619 + .long 2578639571 + .long 1034382165 + .long 2590969465 + .long 713762072 + .long 2201806508 + .long 4228198051 + .long 3980119693 + .long 4056525840 + .long 3097891989 + .long 2284336932 + .long 1932639591 + .long 1092540108 + .long 4171705026 + .long 1025654624 + .long 2806138305 + .long 3009647326 + .long 4248184906 + .long 1890367717 + .long 2289438980 + .long 2899757860 + .long 2719293081 + .long 2021534083 + .long 143536689 + .long 3592569555 + .long 2232683115 + .long 1092535430 + .long 1236892532 + .long 4153044331 + .long 2589276857 + .long 3416977538 + .long 1252322112 + .long 2546684106 + .long 3041465242 + .long 1082461383 + .long 209063033 + .long 689512483 + .long 3233542783 + .long 2486702483 + .long 195380297 + .long 3370408231 + .long 2473507057 + .long 2649928714 + .long 3477888857 + .long 4011137876 + .long 2392519727 + .long 735960098 + .long 892635115 + .long 2839435691 + .long 3648562506 + .long 4276128797 + .long 1399354710 + .long 1604489874 + .long 3300188966 + .long 3618086195 + .long 2363035047 + .long 3798645379 + .long 2910302351 + .long 2872403096 + .long 1995870309 + .long 1272108261 + .long 2577818883 + .long 1355290640 + .long 1576944867 + .long 29835783 + .long 528 + .long 602586217 + .long 2744039853 + .long 1836018387 + .long 1812008391 + .long 2257334696 + .long 1529386301 + .long 1071982020 + .long 1483132946 + .long 4031485769 + .long 2132222880 + .long 3196630878 + .long 2436179952 + .long 499786504 + .long 1744292863 + .long 2290711216 + .long 2504292584 + .long 1896329063 + .long 3237324739 + .long 2330780121 + .long 3744707929 + .long 1734827082 + .long 3296507779 + .long 823995655 + .long 3906271181 + .long 1416288288 + .long 2226659999 + .long 3321781362 + .long 3715853563 + .long 2544842791 + .long 504837419 + .long 2958966103 + .long 2231720942 + .long 750175301 + .long 4084077163 + .long 2549224941 + .long 3250807824 + .long 1369606438 + .long 3223323496 + .long 2083589876 + .long 3384767572 + .long 4248382916 + .long 4144081438 + .long 3229998485 + .long 3165770641 + .long 3223334087 + .long 2485373121 + .long 3818931504 + .long 3388848075 + .long 1252536709 + .long 1652370242 + .long 2624409840 + .long 2964694704 + .long 823791654 + .long 1167018965 + .long 2939238153 + .long 2953436515 + .long 884228550 + .long 292276865 + .long 734484637 + .long 2205305082 + .long 1913113287 + .long 3765099297 + .long 3745471985 + .long 4167966771 + .long 2931697765 + .long 3673300473 + .long 2182221826 + .long 2649024091 + .long 1975627272 + .long 3727134676 + .long 3712743943 + .long 2356773214 + .long 1995177638 + .long 1132588444 + .long 1959425557 + .long 2466886350 + .long 1844669961 + .long 3530525712 + .long 760398624 + .long 4132176514 + .long 1979460773 + .long 796554174 + .long 3170959411 + .long 3438043671 + .long 1989653354 + .long 84033345 + .long 407935807 + .long 2705661215 + .long 1743925380 + .long 3102969454 + .long 3987162576 + .long 3388329870 + .long 1765097355 + .long 2209606903 + .long 1187505799 + .long 2507493218 + .long 161532103 + .long 2079767141 + .long 2713931831 + .long 2181209439 + .long 3726577836 + .long 2678974047 + .long 4042300458 + .long 3044993725 + .long 569618662 + .long 2942019385 + .long 2267421895 + .long 3217189858 + .long 2072134893 + .long 690975306 + .long 3699981379 + .long 4279355559 + .long 3941553639 + .long 955448001 + .long 4102577460 + .long 2173892384 + .long 1871059570 + .long 2340022155 + .long 2864020166 + .long 2805153080 + .long 3271562790 + .long 928990650 + .long 4206766333 + .long 3357221519 + .long 685259147 + .long 3780305127 + .long 2513405378 + .long 4289834595 + .long 2048010913 + .long 1999500835 + .long 12816876 + .long 4227858976 + .long 255479044 + .long 3586592293 + .long 3058876998 + .long 264515361 + .long 3124897887 + .long 2490659405 + .long 1648870444 + .long 499533912 + .long 41235212 + .long 1135645 + .long 0 + .long 0 + .long 1870875844 + .long 237807939 + .long 0 + .long 0 + .long 1220251845 + .long 534075739 + .long 10 + .long 0 + .long 1566916386 + .long 2806728368 + .long 1584 + .long 0 + .long 359612094 + .long 1988210364 + .long 209791 + .long 0 + .long 4018390684 + .long 3143652161 + .long 23114812 + .long 0 + .long 1385310342 + .long 3191552623 + .long 2079730388 + .long 0 + .long 391712962 + .long 3496232483 + .long 3188676879 + .long 34 + .long 712670475 + .long 2384468018 + .long 3612170541 + .long 1928 + .long 2944407817 + .long 162857838 + .long 3871824152 + .long 79642 + .long 1897150183 + .long 2209645725 + .long 1648691441 + .long 2316814 + .long 4189666301 + .long 2103634775 + .long 2832836870 + .long 43914735 + .long 100148761 + .long 3544145710 + .long 882453749 + .long 480946030 + .long 743895637 + .long 1440146064 + .long 1167801510 + .long 2472892869 + .long 2527288726 + .long 3429197137 + .long 3389012105 + .long 3751366970 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3328931461 + .long 85211143 + .long 0 + .long 0 + .long 1806098240 + .long 3730920547 + .long 3 + .long 0 + .long 1452363271 + .long 241457122 + .long 632 + .long 0 + .long 2408523024 + .long 2523801313 + .long 87488 + .long 0 + .long 2245774023 + .long 1447128763 + .long 10087333 + .long 0 + .long 741575833 + .long 1516712297 + .long 950654827 + .long 0 + .long 188657751 + .long 2834063720 + .long 2756671478 + .long 16 + .long 1878890455 + .long 1600190830 + .long 298103694 + .long 968 + .long 2704961479 + .long 3096990934 + .long 62735862 + .long 41831 + .long 4224033960 + .long 872206772 + .long 3368762420 + .long 1269793 + .long 1493275548 + .long 4226875193 + .long 156115358 + .long 24976936 + .long 3675413693 + .long 3939858976 + .long 1188049005 + .long 281407884 + .long 4246420658 + .long 2584806369 + .long 1500891563 + .long 1472264476 + .long 3550606718 + .long 2355970614 + .long 848338822 + .long 2246143015 + .long 4294967292 + .long 0 + .long 4176598204 + .long 2421744458 + .long 12825068 + .long 4227858976 + .long 26255947 + .long 2214716320 + .long 3008850950 + .long 1148166722 + .long 3688411584 + .long 3263035913 + .long 28940749 + .long 823708345 + .long 2778463383 + .long 1133123 + .long 0 + .long 0 + .long 3375994644 + .long 239287696 + .long 0 + .long 0 + .long 1307882943 + .long 652616536 + .long 10 + .long 0 + .long 1617272991 + .long 332362201 + .long 1584 + .long 0 + .long 1120342694 + .long 786793736 + .long 208818 + .long 0 + .long 1754116211 + .long 4140995168 + .long 22886713 + .long 0 + .long 1065416575 + .long 2365212708 + .long 2045489262 + .long 0 + .long 4094841 + .long 1336050951 + .long 3805124179 + .long 33 + .long 2857461896 + .long 1181810454 + .long 3505581240 + .long 1861 + .long 317401726 + .long 1588400515 + .long 2236524720 + .long 75909 + .long 1498310037 + .long 3569634182 + .long 656796315 + .long 2175950 + .long 1147851401 + .long 3112077225 + .long 3624068591 + .long 40608505 + .long 3302439284 + .long 1412013598 + .long 1600554036 + .long 438608161 + .long 1138396370 + .long 2245711018 + .long 3467973442 + .long 2233633025 + .long 867533488 + .long 947112014 + .long 1198607031 + .long 3375241932 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1112979214 + .long 155431282 + .long 0 + .long 0 + .long 751906521 + .long 4198567473 + .long 6 + .long 0 + .long 1613582890 + .long 3858662071 + .long 1129 + .long 0 + .long 750469660 + .long 730914801 + .long 154615 + .long 0 + .long 3704035494 + .long 424802513 + .long 17595297 + .long 0 + .long 3547752153 + .long 653012047 + .long 1632696395 + .long 0 + .long 3895749118 + .long 1312132433 + .long 283540480 + .long 28 + .long 69337464 + .long 2039495909 + .long 480366968 + .long 1598 + .long 3999973752 + .long 512131576 + .long 3264765906 + .long 67376 + .long 1470627556 + .long 3527817596 + .long 506357093 + .long 1990112 + .long 1150644769 + .long 1706533685 + .long 1646793404 + .long 38078290 + .long 2272838918 + .long 315551185 + .long 931114118 + .long 418976801 + .long 799519248 + .long 833405850 + .long 3700723307 + .long 2157812839 + .long 1885423178 + .long 2894024424 + .long 986247108 + .long 3272778907 + .long 4294967291 + .long 0 + .long 205941362 + .long 2843814473 + .long 12816876 + .long 4227858976 + .long 4284396776 + .long 2636211962 + .long 2729248679 + .long 228940808 + .long 2721630221 + .long 4033427380 + .long 3518215373 + .long 3318265016 + .long 1583232401 + .long 1129188 + .long 0 + .long 0 + .long 2240090200 + .long 238747566 + .long 0 + .long 0 + .long 2182354368 + .long 422793662 + .long 10 + .long 0 + .long 2344384525 + .long 3611967473 + .long 1569 + .long 0 + .long 2363261376 + .long 55742926 + .long 206011 + .long 0 + .long 2169713945 + .long 2081106389 + .long 22457193 + .long 0 + .long 808249952 + .long 3928968053 + .long 1994189663 + .long 0 + .long 2498399120 + .long 610170797 + .long 3374767919 + .long 32 + .long 2499128949 + .long 806866088 + .long 2667994898 + .long 1785 + .long 1293127093 + .long 1533235693 + .long 3364558966 + .long 72094 + .long 3484449920 + .long 4142457389 + .long 393414345 + .long 2045553 + .long 1815566734 + .long 3205349654 + .long 1699048752 + .long 37804868 + .long 885836718 + .long 797019709 + .long 3601921623 + .long 405043970 + .long 1414187968 + .long 4238799387 + .long 2244838147 + .long 2051616278 + .long 2091776204 + .long 3735546130 + .long 1436809887 + .long 3093461814 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 194035164 + .long 141017056 + .long 0 + .long 0 + .long 3307569967 + .long 1206991859 + .long 6 + .long 0 + .long 3663448937 + .long 3391377880 + .long 1007 + .long 0 + .long 4126701083 + .long 2994857527 + .long 136467 + .long 0 + .long 1667733955 + .long 4058943102 + .long 15345719 + .long 0 + .long 2611265876 + .long 3831769830 + .long 1404776386 + .long 0 + .long 209321266 + .long 573187068 + .long 3359330694 + .long 23 + .long 1677262110 + .long 637572110 + .long 2122511782 + .long 1331 + .long 3496561941 + .long 3652813901 + .long 3559168047 + .long 55128 + .long 1750715127 + .long 4228815409 + .long 1050316 + .long 1598795 + .long 1840387030 + .long 2463042611 + .long 3094434052 + .long 30079053 + .long 2629602118 + .long 2049759618 + .long 945167723 + .long 326505049 + .long 3298129216 + .long 3410065465 + .long 1686243051 + .long 1666911635 + .long 3383305094 + .long 1693255217 + .long 2403972032 + .long 2519963779 + .long 4294967291 + .long 0 + .long 3238416553 + .long 3265778049 + .long 12825068 + .long 4227858976 + .long 3177200532 + .long 3057752043 + .long 1963397648 + .long 3926923754 + .long 1015831100 + .long 3054277238 + .long 214260357 + .long 3388682645 + .long 329260597 + .long 1120080 + .long 0 + .long 0 + .long 1129382972 + .long 236791308 + .long 0 + .long 0 + .long 200550114 + .long 4225205647 + .long 9 + .long 0 + .long 3987740840 + .long 662463985 + .long 1546 + .long 0 + .long 3625695977 + .long 942803776 + .long 202014 + .long 0 + .long 4082097994 + .long 2934588234 + .long 21910543 + .long 0 + .long 2081364333 + .long 826431917 + .long 1934499234 + .long 0 + .long 1761358361 + .long 1915853684 + .long 2581201468 + .long 31 + .long 1458338458 + .long 480335293 + .long 641318311 + .long 1709 + .long 2934587087 + .long 1935466844 + .long 4209158963 + .long 68508 + .long 2290297886 + .long 2520183995 + .long 2347470795 + .long 1930078 + .long 1214972608 + .long 3678131539 + .long 56536087 + .long 35444212 + .long 1624218450 + .long 2947499939 + .long 75007111 + .long 377830189 + .long 794554122 + .long 1484978356 + .long 1550658172 + .long 1907426674 + .long 1950966402 + .long 3741059307 + .long 468440577 + .long 2872207806 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2513119405 + .long 255601926 + .long 0 + .long 0 + .long 1340053149 + .long 1293535308 + .long 11 + .long 0 + .long 2520596056 + .long 243966073 + .long 1798 + .long 0 + .long 1240269441 + .long 1692289976 + .long 241208 + .long 0 + .long 486505533 + .long 4176826391 + .long 26843964 + .long 0 + .long 1085031321 + .long 2229862700 + .long 2429583838 + .long 0 + .long 3607912919 + .long 1284443184 + .long 2708483256 + .long 40 + .long 4286170020 + .long 2109173108 + .long 2872722597 + .long 2245 + .long 3765965368 + .long 2873757161 + .long 2280026745 + .long 91776 + .long 975034122 + .long 907445528 + .long 4183785771 + .long 2628820 + .long 2401876752 + .long 1790794470 + .long 4120636181 + .long 48923208 + .long 3456079977 + .long 3312351896 + .long 2533182876 + .long 526592659 + .long 300202939 + .long 3214183676 + .long 2700781633 + .long 2674019932 + .long 3409370037 + .long 142796896 + .long 590138558 + .long 4034348900 + .long 4294967290 + .long 0 + .long 2441521498 + .long 242594037 + .long 2326542 + .long 4227858728 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 292802143 + .long 2930268 + .long 0 + .long 0 + .long 535415153 + .long 618901269 + .long 0 + .long 0 + .long 1086559041 + .long 2797303288 + .long 25 + .long 0 + .long 4140762130 + .long 803311064 + .long 3903 + .long 0 + .long 3260682281 + .long 805348165 + .long 501094 + .long 0 + .long 946699523 + .long 2655018074 + .long 53417808 + .long 0 + .long 3184188054 + .long 357148693 + .long 343191017 + .long 1 + .long 2991785955 + .long 1885266767 + .long 2475080337 + .long 74 + .long 3202232014 + .long 1390745085 + .long 1906741299 + .long 3974 + .long 2460394114 + .long 145617371 + .long 1237048646 + .long 157131 + .long 2499420999 + .long 890518540 + .long 2984098479 + .long 4365826 + .long 4044160094 + .long 3502963765 + .long 4084883256 + .long 78771967 + .long 1855836510 + .long 1773383726 + .long 696038818 + .long 812348145 + .long 1371130586 + .long 4224739114 + .long 2913286396 + .long 3734813411 + .long 3022964429 + .long 4251306649 + .long 3856945722 + .long 3368235169 + .long 4294967295 + .long 0 + .long 3259021111 + .long 321006842 + .long 29835651 + .long 528 + .long 4287764257 + .long 2359162534 + .long 538435925 + .long 1893177075 + .long 2620595140 + .long 1125567552 + .long 2991073306 + .long 2159239491 + .long 623213113 + .long 2440954329 + .long 3454983919 + .long 2690441248 + .long 1981777827 + .long 3070641374 + .long 600396448 + .long 3989904562 + .long 503111015 + .long 2398913263 + .long 3729609173 + .long 2560895207 + .long 4264522276 + .long 1827510236 + .long 1453587439 + .long 2856034995 + .long 3530335573 + .long 2910390539 + .long 3830755809 + .long 3395214488 + .long 581887236 + .long 170861812 + .long 3783767784 + .long 3801720292 + .long 3874334995 + .long 3776894534 + .long 3941576344 + .long 4151651145 + .long 672178724 + .long 1876155966 + .long 2300153670 + .long 2280168405 + .long 2930820789 + .long 310363638 + .long 2337608734 + .long 2504022121 + .long 679615860 + .long 1866145491 + .long 925134179 + .long 2749395452 + .long 4164495461 + .long 1691717726 + .long 3504269286 + .long 3018609133 + .long 4091749652 + .long 2913918638 + .long 75440378 + .long 3313861766 + .long 2260863989 + .long 1783565696 + .long 3478989690 + .long 3637556251 + .long 386210930 + .long 165743778 + .long 2898550894 + .long 3992273458 + .long 138300613 + .long 2474605972 + .long 1444508693 + .long 2190379430 + .long 3716173044 + .long 211495398 + .long 2076026756 + .long 2402948622 + .long 884026613 + .long 3273453185 + .long 2774793032 + .long 2635331838 + .long 862601524 + .long 3461868441 + .long 1569319307 + .long 2889017487 + .long 2379289701 + .long 4014175908 + .long 4105967090 + .long 3165345439 + .long 4280005796 + .long 3658970897 + .long 1734788832 + .long 3465258574 + .long 1142155173 + .long 2128929843 + .long 1454912392 + .long 3791483352 + .long 1572825138 + .long 4100167805 + .long 2209491991 + .long 4149468636 + .long 1302034421 + .long 2240019943 + .long 2903825538 + .long 2241250238 + .long 1470684676 + .long 2909933371 + .long 1614391894 + .long 2346034557 + .long 3663942245 + .long 150553254 + .long 581996432 + .long 2853498413 + .long 2851485478 + .long 1062112106 + .long 2360862824 + .long 4080591848 + .long 3037166561 + .long 3942859811 + .long 2491765597 + .long 2637624859 + .long 3670749589 + .long 1175994297 + .long 2568760650 + .long 2257943156 + .long 4233645441 + .long 2769385451 + .long 3183971100 + .long 4072128784 + .long 1432427446 + .long 3380851706 + .long 2013943478 + .long 2236760609 + .long 4221662466 + .long 494326959 + .long 27640328 + .long 432 + .long 4152930537 + .long 3261335210 + .long 1647304022 + .long 2421513631 + .long 0 + .long 2182303040 + .long 2 + .long 0 + .long 2440707372 + .long 2648025301 + .long 1920343642 + .long 4033309261 + .long 228472035 + .long 951557190 + .long 1587559315 + .long 2974493459 + .long 2596925677 + .long 961292909 + .long 2340517507 + .long 4069972126 + .long 3800775586 + .long 2435894136 + .long 1723862257 + .long 2750240234 + .long 1983413582 + .long 438211295 + .long 1298530652 + .long 3389699362 + .long 2457352961 + .long 2834143237 + .long 3251433817 + .long 4162244914 + .long 2624345295 + .long 2198133979 + .long 1723202388 + .long 2299670239 + .long 3808420354 + .long 1821904843 + .long 3390094422 + .long 2531701946 + .long 1851152974 + .long 2701629785 + .long 1724191120 + .long 2482272915 + .long 648872229 + .long 865545185 + .long 2559674717 + .long 2406027884 + .long 910915727 + .long 2144582723 + .long 1642929274 + .long 4137212570 + .long 2336042754 + .long 239465408 + .long 3865561517 + .long 3439416156 + .long 2422534192 + .long 3569472253 + .long 2978472155 + .long 2559905612 + .long 2875291331 + .long 4046158321 + .long 3949085588 + .long 3503570860 + .long 2128927569 + .long 1225899162 + .long 2147335523 + .long 2230618794 + .long 2283389284 + .long 1333752198 + .long 1465231956 + .long 2336128911 + .long 2753251442 + .long 2966939997 + .long 2922138241 + .long 2536578790 + .long 2666112773 + .long 3385813147 + .long 623901210 + .long 3462131994 + .long 668414005 + .long 3701008851 + .long 3126176950 + .long 3345113301 + .long 358440900 + .long 3717742396 + .long 3947881290 + .long 3263003015 + .long 2610140914 + .long 3090322344 + .long 447998310 + .long 4170300383 + .long 397141160 + .long 2942373728 + .long 3824192808 + .long 2641349034 + .long 2658982609 + .long 4233303079 + .long 2524818000 + .long 3312990274 + .long 228893295 + .long 2515147602 + .long 3476745001 + .long 2698739548 + .long 2970265182 + .long 931672352 + .long 30032391 + .long 720 + .long 1031893951 + .long 2915037812 + .long 3514686481 + .long 3480585297 + .long 183393903 + .long 2624056858 + .long 28546027 + .long 1683875686 + .long 92539635 + .long 470440642 + .long 3104544566 + .long 2542111380 + .long 2423082850 + .long 4223302981 + .long 1880783390 + .long 3172707188 + .long 2733291596 + .long 4028584963 + .long 3133521808 + .long 2155982074 + .long 1545518760 + .long 2360167907 + .long 1514977624 + .long 3361750727 + .long 1775829359 + .long 1268098089 + .long 293245362 + .long 2922889930 + .long 4260567272 + .long 2130738070 + .long 78442230 + .long 3811451694 + .long 3185114409 + .long 1528069252 + .long 1469017227 + .long 3009687218 + .long 817620842 + .long 541098266 + .long 3429120157 + .long 3247469802 + .long 1386496969 + .long 2684347079 + .long 284179228 + .long 4184596161 + .long 3638765322 + .long 371021313 + .long 2606681771 + .long 2672602875 + .long 1153440841 + .long 681666828 + .long 2588485140 + .long 3667250000 + .long 2323000426 + .long 796579017 + .long 4170606170 + .long 2503045697 + .long 3134166249 + .long 3700272898 + .long 3134839549 + .long 3388945252 + .long 703661802 + .long 1462722757 + .long 1341451622 + .long 2296227379 + .long 443948971 + .long 1838486354 + .long 1829780795 + .long 3113397699 + .long 3423557800 + .long 3677683794 + .long 2988390605 + .long 4220311422 + .long 2364782699 + .long 377168398 + .long 988912816 + .long 2859792771 + .long 2272449576 + .long 2425114493 + .long 3394168911 + .long 3875037301 + .long 2614813611 + .long 1136311064 + .long 3219605340 + .long 2624778863 + .long 2109052744 + .long 2469309985 + .long 1975730813 + .long 3554907757 + .long 1295201579 + .long 391105893 + .long 1554957189 + .long 2406549547 + .long 576394664 + .long 1543244524 + .long 1882413337 + .long 3257006239 + .long 1017054059 + .long 1977139902 + .long 2097363325 + .long 2203699043 + .long 1908366122 + .long 67963273 + .long 641406479 + .long 2982177629 + .long 3746196521 + .long 1016392834 + .long 2077695946 + .long 4016838075 + .long 2069372298 + .long 3280381472 + .long 2122130600 + .long 2685921991 + .long 1883255817 + .long 3264982359 + .long 4098768927 + .long 3758603957 + .long 3506210954 + .long 1836307129 + .long 2822017765 + .long 2764063917 + .long 2012804049 + .long 1836928984 + .long 1054120456 + .long 2619585574 + .long 1055724672 + .long 2194227394 + .long 2447214543 + .long 2687690031 + .long 1327427687 + .long 1655178620 + .long 3028234167 + .long 3556180690 + .long 2927424394 + .long 229520228 + .long 65594667 + .long 3227047264 + .long 1689555076 + .long 4247943379 + .long 172770419 + .long 3675678736 + .long 657796043 + .long 288113065 + .long 2256116365 + .long 2460956283 + .long 2381283399 + .long 3352776929 + .long 3687288864 + .long 3224422563 + .long 672976042 + .long 857803139 + .long 2956970725 + .long 3269238901 + .long 2326138918 + .long 3946484787 + .long 3349422960 + .long 2579382025 + .long 3310332749 + .long 822582390 + .long 2446752418 + .long 2381540812 + .long 4287345289 + .long 449373617 + .long 1629474989 + .long 2287047921 + .long 3156879118 + .long 2932312680 + .long 4059116599 + .long 3501115759 + .long 2653478600 + .long 1047527497 + .long 2387670671 + .long 2153577515 + .long 4278907533 + .long 1522300626 + .long 2248985742 + .long 2923309751 + .long 2050095503 + .long 1358740372 + .long 29884806 + .long 576 + .long 189636935 + .long 2307472755 + .long 73850715 + .long 2629855449 + .long 3883672823 + .long 618265067 + .long 3875053116 + .long 3917969758 + .long 1449807750 + .long 2492768441 + .long 781111022 + .long 3190435238 + .long 1482976409 + .long 3746699123 + .long 673296220 + .long 2543135664 + .long 1097012132 + .long 2731166546 + .long 2691838079 + .long 3591085575 + .long 4108503415 + .long 2072634685 + .long 3936623385 + .long 2185856579 + .long 1923690262 + .long 3646023575 + .long 4216469600 + .long 2465929342 + .long 431460727 + .long 596938224 + .long 2153081083 + .long 2604407262 + .long 2280668022 + .long 3134357508 + .long 2589033740 + .long 2773504679 + .long 2807242375 + .long 2817121462 + .long 2773778968 + .long 2997091783 + .long 1733040470 + .long 818736373 + .long 2513276750 + .long 3273702286 + .long 3677662487 + .long 322072717 + .long 1865747051 + .long 3233516951 + .long 2915555540 + .long 937584400 + .long 659945040 + .long 2820584615 + .long 2133192181 + .long 2691571362 + .long 4196086611 + .long 2727659532 + .long 896759672 + .long 1769906504 + .long 3035342266 + .long 2750209132 + .long 1576632880 + .long 1478621509 + .long 1238707153 + .long 3507491969 + .long 126298229 + .long 3524093915 + .long 2681332129 + .long 2656870434 + .long 2282193125 + .long 2123250942 + .long 2537777848 + .long 2313555892 + .long 2236573588 + .long 3014805274 + .long 1599407648 + .long 4251279069 + .long 1359728578 + .long 2438133930 + .long 1558056398 + .long 2562927734 + .long 3023480919 + .long 1448378982 + .long 1701562892 + .long 2340149056 + .long 1506041285 + .long 779806113 + .long 4234929211 + .long 2470659521 + .long 3801687606 + .long 3749889093 + .long 4112153792 + .long 4129315601 + .long 3087235106 + .long 3558690450 + .long 4001893244 + .long 3474539130 + .long 508945001 + .long 2957303106 + .long 3788800591 + .long 2700334225 + .long 1697795651 + .long 4047812965 + .long 4036703836 + .long 3519182687 + .long 4240516712 + .long 1475971627 + .long 1575184661 + .long 2515949915 + .long 1673437412 + .long 2377231640 + .long 3395057130 + .long 2344040799 + .long 1065264411 + .long 1317525997 + .long 664446688 + .long 3082671496 + .long 1521403251 + .long 50174553 + .long 2566979079 + .long 3666263822 + .long 3888565980 + .long 425393181 + .long 383974 + .long 2211658859 + .long 3190477332 + .long 1452652764 + .long 881590408 + .long 2658571543 + .long 2768922591 + .long 607349007 + .long 1340513656 + .long 2982866930 + .long 2042743989 + .long 2907958666 + .long 2030930082 + .long 2170145182 + .long 1493033626 + .long 3329402172 + .long 1968890141 + .long 2331822590 + .long 2408886146 + .long 1783184274 + .long 12825068 + .long 4227858976 + .long 2710581281 + .long 3153889734 + .long 3238022506 + .long 4176533952 + .long 1531340198 + .long 4025201404 + .long 2485789300 + .long 650490227 + .long 2321085797 + .long 625172 + .long 0 + .long 0 + .long 1069281709 + .long 251624587 + .long 0 + .long 0 + .long 4197074614 + .long 91585281 + .long 10 + .long 0 + .long 2135656897 + .long 267376913 + .long 1588 + .long 0 + .long 3403656332 + .long 967418652 + .long 209472 + .long 0 + .long 463318414 + .long 1993660658 + .long 23089564 + .long 0 + .long 1930917064 + .long 2053446879 + .long 2077215423 + .long 0 + .long 657157488 + .long 2477268698 + .long 3166180846 + .long 34 + .long 1532275274 + .long 3903843069 + .long 3017665745 + .long 1932 + .long 3296114418 + .long 3153699036 + .long 1621212020 + .long 80134 + .long 1258014930 + .long 2176092298 + .long 1175504463 + .long 2347208 + .long 1382073311 + .long 570037013 + .long 1129603108 + .long 44970025 + .long 2202866424 + .long 1579426883 + .long 3017508354 + .long 499448209 + .long 4088025423 + .long 891205158 + .long 1193661411 + .long 2604580528 + .long 2532457727 + .long 3946349630 + .long 1951385266 + .long 3993662730 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2589520468 + .long 104644116 + .long 0 + .long 0 + .long 3884787564 + .long 2761065855 + .long 3 + .long 0 + .long 3187602994 + .long 4135562377 + .long 626 + .long 0 + .long 1724989792 + .long 1713856870 + .long 86304 + .long 0 + .long 2484708115 + .long 4089533751 + .long 10036248 + .long 0 + .long 275209371 + .long 2697520380 + .long 952228456 + .long 0 + .long 3236472558 + .long 1226316501 + .long 3598685087 + .long 16 + .long 3284813591 + .long 1063192554 + .long 3944393543 + .long 991 + .long 1278466978 + .long 2628971736 + .long 1168074903 + .long 43599 + .long 848711725 + .long 2087159795 + .long 759297680 + .long 1353656 + .long 1425592604 + .long 1129358307 + .long 2754552431 + .long 27432831 + .long 3204498819 + .long 300826889 + .long 3605445756 + .long 320203780 + .long 1698536723 + .long 3065896691 + .long 309908814 + .long 1734061231 + .long 3912468499 + .long 396401915 + .long 3674073704 + .long 2719285114 + .long 4294967292 + .long 0 + .long 3981914375 + .long 2206547233 + .long 12816876 + .long 4227858976 + .long 4096021827 + .long 3999001670 + .long 1063371522 + .long 3989528078 + .long 874562813 + .long 2447814409 + .long 1858302676 + .long 4162682718 + .long 1605953959 + .long 1135435 + .long 0 + .long 0 + .long 2549031326 + .long 239160205 + .long 0 + .long 0 + .long 454697744 + .long 620180210 + .long 10 + .long 0 + .long 2436299213 + .long 3355768607 + .long 1582 + .long 0 + .long 351390256 + .long 799610387 + .long 208707 + .long 0 + .long 25800287 + .long 698915934 + .long 22891066 + .long 0 + .long 4130988338 + .long 676217935 + .long 2048657779 + .long 0 + .long 2657270905 + .long 3829767903 + .long 59128891 + .long 34 + .long 1037582638 + .long 2935003680 + .long 713523288 + .long 1875 + .long 901580945 + .long 1268517119 + .long 2358220346 + .long 76826 + .long 1912766477 + .long 222206216 + .long 632792841 + .long 2216812 + .long 4065471431 + .long 1410808044 + .long 2022595908 + .long 41710361 + .long 438075994 + .long 598703158 + .long 1085011105 + .long 454516776 + .long 604410846 + .long 4058435110 + .long 2236814241 + .long 2333657313 + .long 2448294355 + .long 2704068860 + .long 1114425723 + .long 3548452336 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3769919769 + .long 153956907 + .long 0 + .long 0 + .long 646070119 + .long 4028818701 + .long 6 + .long 0 + .long 2588679469 + .long 1052177761 + .long 1128 + .long 0 + .long 2209274989 + .long 523514771 + .long 155204 + .long 0 + .long 2126396778 + .long 3565792859 + .long 17775584 + .long 0 + .long 2013180833 + .long 1908602229 + .long 1662519428 + .long 0 + .long 3793993839 + .long 1441646378 + .long 3693455390 + .long 28 + .long 3379423244 + .long 3965194379 + .long 1988414356 + .long 1663 + .long 1712981619 + .long 805217952 + .long 1789525478 + .long 71195 + .long 1327601011 + .long 2853644807 + .long 2041759317 + .long 2141557 + .long 944030315 + .long 2463564559 + .long 1071870408 + .long 41839542 + .long 3377497270 + .long 1387686562 + .long 1015294515 + .long 470457582 + .long 3802633795 + .long 4019363939 + .long 1055805497 + .long 2472026772 + .long 1903142729 + .long 1756051618 + .long 411357926 + .long 3811072860 + .long 4294967291 + .long 0 + .long 2342180209 + .long 2629357739 + .long 12825068 + .long 4227858976 + .long 4176598204 + .long 2421744458 + .long 608412369 + .long 593975024 + .long 2402997778 + .long 853372562 + .long 4106233885 + .long 999432807 + .long 1956711771 + .long 1129902 + .long 0 + .long 0 + .long 3668311682 + .long 238634701 + .long 0 + .long 0 + .long 1969498866 + .long 413457374 + .long 10 + .long 0 + .long 2816017558 + .long 1616523229 + .long 1570 + .long 0 + .long 3757647515 + .long 3035182130 + .long 206269 + .long 0 + .long 2187487164 + .long 1784472528 + .long 22516356 + .long 0 + .long 559031239 + .long 1740008181 + .long 2003371129 + .long 0 + .long 661394403 + .long 1757559962 + .long 108872688 + .long 33 + .long 2108184885 + .long 2675738113 + .long 243072689 + .long 1805 + .long 1896660970 + .long 944386947 + .long 1395829566 + .long 73206 + .long 2645692570 + .long 1073605584 + .long 391090218 + .long 2088195 + .long 3576186609 + .long 249080280 + .long 1318613440 + .long 38820429 + .long 1698387538 + .long 1714182690 + .long 2486672428 + .long 418377280 + .long 786186663 + .long 550325920 + .long 34733209 + .long 2130294753 + .long 123703415 + .long 1830333669 + .long 555170427 + .long 3225161241 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 372615672 + .long 141112893 + .long 0 + .long 0 + .long 3315900643 + .long 1327290262 + .long 6 + .long 0 + .long 3811139837 + .long 3724885846 + .long 1016 + .long 0 + .long 989130504 + .long 3252199933 + .long 138436 + .long 0 + .long 1221640456 + .long 1442402103 + .long 15666709 + .long 0 + .long 4152936768 + .long 1813348380 + .long 1445091735 + .long 0 + .long 4193896088 + .long 3387134533 + .long 2948009907 + .long 24 + .long 2262704738 + .long 1989650954 + .long 3803792063 + .long 1396 + .long 2783464578 + .long 434957745 + .long 1316597970 + .long 58551 + .long 1368551733 + .long 528983851 + .long 2424303193 + .long 1721511 + .long 2488297655 + .long 3464245304 + .long 3652031881 + .long 32861225 + .long 3506409524 + .long 3965838759 + .long 4041530878 + .long 361842100 + .long 1191665382 + .long 3299555859 + .long 1239122770 + .long 1871471448 + .long 3889602930 + .long 4175372373 + .long 3489971328 + .long 2859914059 + .long 4294967291 + .long 0 + .long 4097644266 + .long 3051847358 + .long 12816876 + .long 4227858976 + .long 205941362 + .long 2843814473 + .long 1373054629 + .long 908624394 + .long 572230967 + .long 3772158671 + .long 2295107357 + .long 875890232 + .long 1676909203 + .long 1121011 + .long 0 + .long 0 + .long 3140758008 + .long 236890113 + .long 0 + .long 0 + .long 78883718 + .long 4270561461 + .long 9 + .long 0 + .long 653004353 + .long 1003106748 + .long 1549 + .long 0 + .long 1997655276 + .long 2810156938 + .long 202673 + .long 0 + .long 816790074 + .long 126500350 + .long 22018895 + .long 0 + .long 483718758 + .long 1693602023 + .long 1948244742 + .long 0 + .long 1719888843 + .long 3024114415 + .long 3912173698 + .long 31 + .long 857585795 + .long 2024050081 + .long 2152155389 + .long 1731 + .long 2161391665 + .long 4153338473 + .long 3453597175 + .long 69665 + .long 690916841 + .long 3408680089 + .long 1481878010 + .long 1970802 + .long 4244781337 + .long 1956485181 + .long 3004849658 + .long 36347304 + .long 3508046261 + .long 2375922782 + .long 3796433011 + .long 389053187 + .long 1871421647 + .long 319248902 + .long 2844007792 + .long 1971197416 + .long 814256252 + .long 534724998 + .long 4096580698 + .long 2976687819 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1862921762 + .long 128829141 + .long 0 + .long 0 + .long 2226943868 + .long 3083060057 + .long 5 + .long 0 + .long 3790004556 + .long 3473372331 + .long 913 + .long 0 + .long 1912405170 + .long 4207391429 + .long 123223 + .long 0 + .long 2818206388 + .long 546560525 + .long 13795947 + .long 0 + .long 926024359 + .long 466562391 + .long 1257280106 + .long 0 + .long 3443963035 + .long 4102181261 + .long 824629355 + .long 21 + .long 1095781235 + .long 2590304783 + .long 3003378070 + .long 1181 + .long 3706684271 + .long 2607807817 + .long 1026954074 + .long 48765 + .long 2542600140 + .long 2410120938 + .long 1491060906 + .long 1411271 + .long 1675138874 + .long 3651173547 + .long 1198416212 + .long 26539599 + .long 842200953 + .long 401492709 + .long 2211503215 + .long 288538794 + .long 1943642431 + .long 940486719 + .long 4288006473 + .long 1478519853 + .long 2666730960 + .long 3798148012 + .long 941219805 + .long 2247821888 + .long 4294967291 + .long 0 + .long 3590128009 + .long 612654688 + .long 716769122 + .long 2 + .long 1828204245 + .long 1775926740 + .long 862431319 + .long 1672 + .long 437955120 + .long 677313132 + .long 3681074436 + .long 185717 + .long 2884200252 + .long 2090641138 + .long 3992138721 + .long 6428191 + .long 3221531446 + .long 2371910721 + .long 4237081542 + .long 91796659 + .long 3709028830 + .long 1986863955 + .long 2283696654 + .long 618613015 + .long 1322699753 + .long 485003501 + .long 4170891366 + .long 2092077992 + .long 1956040154 + .long 1117518145 + .long 962574367 + .long 3571830532 + .long 3307700780 + .long 4011234461 + .long 1774218710 + .long 2881343143 + .long 391584861 + .long 529954976 + .long 2825691418 + .long 856722023 + .long 0 + .long 0 + .long 3298396499 + .long 2495110602 + .long 2303999958 + .long 1 + .long 2542348583 + .long 3627482097 + .long 3224340298 + .long 1074 + .long 967783320 + .long 1406672934 + .long 4087851085 + .long 117404 + .long 4177416572 + .long 3106181469 + .long 261241013 + .long 4043478 + .long 202539330 + .long 3294545774 + .long 2496277142 + .long 57629426 + .long 720582238 + .long 1814713548 + .long 3091376339 + .long 388014697 + .long 146526450 + .long 4271301162 + .long 2338306966 + .long 1311627297 + .long 2070656804 + .long 1921999658 + .long 2258254113 + .long 2238807899 + .long 242296837 + .long 3253310178 + .long 207686852 + .long 1805761504 + .long 0 + .long 0 + .long 0 + .long 536870912 + .long 3 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3266800725 + .long 2413762801 + .long 3330613244 + .long 98 + .long 1201359419 + .long 2714872150 + .long 3208385380 + .long 20210 + .long 1956238602 + .long 4223228119 + .long 2784422263 + .long 1028397 + .long 3439473030 + .long 2410851869 + .long 3292470576 + .long 20253447 + .long 1686397776 + .long 592553810 + .long 969547707 + .long 185741930 + .long 3468583933 + .long 1250725515 + .long 2117116206 + .long 869064170 + .long 3909100790 + .long 1843251452 + .long 3871208694 + .long 2155104570 + .long 4148130288 + .long 2464912491 + .long 1300300682 + .long 2809133898 + .long 4014582188 + .long 344247779 + .long 2796123058 + .long 1784697576 + .long 195792426 + .long 264977488 + .long 3560329357 + .long 428361011 + .long 4294967290 + .long 0 + .long 258978617 + .long 1401350217 + .long 414758348 + .long 0 + .long 3858563520 + .long 693344438 + .long 929988021 + .long 164 + .long 3412169140 + .long 2002911005 + .long 1900957617 + .long 27838 + .long 201299732 + .long 2653786175 + .long 836100553 + .long 1342443 + .long 112595646 + .long 24843945 + .long 2773043450 + .long 25894040 + .long 839565763 + .long 2401088019 + .long 1862800896 + .long 235227666 + .long 241900887 + .long 2111181527 + .long 559246656 + .long 1095314964 + .long 1679323588 + .long 170716610 + .long 3844392689 + .long 2709031418 + .long 2888224069 + .long 91827283 + .long 2484028115 + .long 3525834755 + .long 3046356865 + .long 465368430 + .long 2789327597 + .long 2238015503 + .long 0 + .long 0 + .long 0 + .long 536870912 + .long 3 + .long 0 + .long 1629800756 + .long 211083125 + .long 74954925 + .long 0 + .long 1545370875 + .long 1864504884 + .long 4276848488 + .long 99 + .long 535444102 + .long 452832597 + .long 341934841 + .long 25395 + .long 995111971 + .long 3604718273 + .long 313159131 + .long 1483348 + .long 467529526 + .long 927033629 + .long 3631579950 + .long 30995691 + .long 2550211567 + .long 3003753623 + .long 1495846756 + .long 281435025 + .long 1095077789 + .long 2892497672 + .long 2221613791 + .long 1215372727 + .long 1191801615 + .long 1667552124 + .long 2428434537 + .long 2551716115 + .long 1201465291 + .long 1874197394 + .long 578557072 + .long 2461680298 + .long 391584923 + .long 529954976 + .long 2825691418 + .long 856722023 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 677405811 + .long 113109491 + .long 129649144 + .long 114 + .long 3825428504 + .long 3691782001 + .long 3484121609 + .long 31057 + .long 2790365057 + .long 1503600960 + .long 2128362517 + .long 1842108 + .long 1815120706 + .long 3864377339 + .long 1520525307 + .long 38689413 + .long 2352056310 + .long 3376817110 + .long 3997253088 + .long 352036787 + .long 1198120374 + .long 2050750776 + .long 3970142361 + .long 1521787235 + .long 3363842978 + .long 1133863107 + .long 832963017 + .long 3196692150 + .long 3821983599 + .long 1263968260 + .long 873004851 + .long 3084767199 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 2 + .long 0 + .long 2651322308 + .long 3386393833 + .long 2831116449 + .long 5 + .long 4289850283 + .long 2368640529 + .long 3021143330 + .long 3284 + .long 1866387201 + .long 153493322 + .long 2018528397 + .long 295326 + .long 712913332 + .long 628654228 + .long 3881360594 + .long 8668773 + .long 2507640802 + .long 239249479 + .long 2566710297 + .long 108181087 + .long 2758175823 + .long 567857163 + .long 2134567225 + .long 650389544 + .long 3640757112 + .long 2804269303 + .long 645858985 + .long 1991928169 + .long 804414238 + .long 2280600022 + .long 3914463340 + .long 3114948090 + .long 1937917503 + .long 2252804771 + .long 1940556944 + .long 2322010631 + .long 293688586 + .long 2544949880 + .long 3193010387 + .long 642541517 + .long 4294967291 + .long 0 + .long 453133727 + .long 877370797 + .long 1558279443 + .long 6 + .long 2547899573 + .long 3360184680 + .long 1178296802 + .long 2954 + .long 1755214995 + .long 2061159704 + .long 3531983056 + .long 253712 + .long 543505238 + .long 128612626 + .long 629116815 + .long 7334610 + .long 100838038 + .long 3022980312 + .long 2298747174 + .long 90954203 + .long 3014766307 + .long 96539771 + .long 3590315363 + .long 545180116 + .long 2964798914 + .long 2705356255 + .long 3013291713 + .long 1667101568 + .long 3407956254 + .long 2146783552 + .long 2206958848 + .long 2604739160 + .long 1922050233 + .long 3165283613 + .long 2563978608 + .long 1940712607 + .long 0 + .long 0 + .long 0 + .long 536870912 + .long 3 + .long 0 + .long 2797952740 + .long 3054806814 + .long 120 + .long 0 + .long 18168 + .long 0 + .long 1890690921 + .long 3263011055 + .long 3960 + .long 0 + .long 18872 + .long 0 + .long 3238416553 + .long 3265778049 + .long 8064 + .long 0 + .long 18168 + .long 0 + .long 4097644266 + .long 3051847358 + .long 13440 + .long 0 + .long 18872 + .long 0 + .long 0 + .long 0 + .long 1313084713 + .long 2734261102 + .long 4113882560 + .long 4230436817 + .long 0 + .long 4294967295 + .long 4105493977 + .long 3790490747 + .long 2885543867 + .long 1813033052 + .long 0 + .long 0 + .type __bessel_x_table,@object + .size __bessel_x_table,19696 + .align 4 +.L_2il0floatpacket.108: + .long 0x5f000000 + .type .L_2il0floatpacket.108,@object + .size .L_2il0floatpacket.108,4 + .data + .hidden __dpml_ux_sqrt_evaluation__ + .hidden __dpml_multiply__ + .hidden __dpml_divide__ + .hidden __dpml_ux_log__ + .hidden __dpml_ux_sincos + .hidden __dpml_ffs_and_shift__ + .hidden __dpml_addsub__ + .hidden __dpml_evaluate_rational__ + .hidden __dpml_pack__ + .hidden __dpml_unpack_x_or_y__ + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/dpml_ux_log.S b/external/sgx_libm/ia32/dpml_ux_log.S new file mode 100644 index 0000000000..d199fe4588 --- /dev/null +++ b/external/sgx_libm/ia32/dpml_ux_log.S @@ -0,0 +1,365 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_log.c" + .text +..TXTST0: +# -- Begin __dpml_ux_log_poly__ + .text + .align 16,0x90 + .hidden __dpml_ux_log_poly__ + .globl __dpml_ux_log_poly__ +__dpml_ux_log_poly__: +# parameter 1: 48 + %esp +# parameter 2: 52 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + subl $36, %esp + xorl %eax, %eax + movl 52(%esp), %edi + addl $28, %esp + pushl %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + pushl %eax + pushl $6 + pushl %eax + pushl $17 + lea 128+__log_x_table@GOTOFF(%ebx), %edx + pushl %edx + pushl 44(%esp) + call __dpml_evaluate_rational__ +..B1.2: + addl $12, %esp + lea 472+__log_x_table@GOTOFF(%ebx), %eax + pushl %edi + pushl %eax + pushl %edi + call __dpml_multiply__ +..B1.3: + addl $36, %esp + popl %ebx + popl %edi + ret + .align 16,0x90 + .type __dpml_ux_log_poly__,@function + .size __dpml_ux_log_poly__,.-__dpml_ux_log_poly__ + .data +# -- End __dpml_ux_log_poly__ + .text +# -- Begin __dpml_ux_log__ + .text + .align 16,0x90 + .hidden __dpml_ux_log__ + .globl __dpml_ux_log__ +__dpml_ux_log__: +# parameter 1: 112 + %esp +# parameter 2: 116 + %esp +# parameter 3: 120 + %esp +..B2.1: +..L3: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $92, %esp + movl 112(%esp), %ecx + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + movl 8(%ecx), %esi + movl %gs:20, %eax + xorl %esp, %eax + subl 112+__log_x_table@GOTOFF(%ebx), %esi + movl 12(%ecx), %ebp + movl 4(%ecx), %edx + movl %edx, %edi + movl %eax, 80(%esp) + sbbl 116+__log_x_table@GOTOFF(%ebx), %ebp + jb ..B2.2 +..B2.19: + orl %ebp, %esi + jne ..B2.3 +..B2.2: + lea -1(%edx), %edi +..B2.3: + addl $20, %esp + lea 424+__log_x_table@GOTOFF(%ebx), %ebp + subl %edi, %edx + lea 12(%esp), %esi + pushl %esi + pushl $0 + pushl $6 + pushl %ebp + pushl %ecx + movl %edx, 4(%ecx) + call __dpml_addsub__ +..B2.4: + movl 112(%esp), %ecx + movl 120(%esp), %ebp + addl $20, %esp + addl %edi, 4(%ecx) + lea 36(%esp), %edx + pushl %ebp + pushl $0 + pushl $2 + pushl %esi + pushl %edx + call __dpml_divide__ +..B2.5: + addl $28, %esp + xorl %edx, %edx + pushl %esi + pushl %edx + pushl $6 + pushl %edx + pushl $17 + lea 128+__log_x_table@GOTOFF(%ebx), %ecx + pushl %ecx + pushl %ebp + call __dpml_evaluate_rational__ +..B2.6: + addl $12, %esp + movl %edi, %eax + pushl $0 + pushl $1 + cltd + pushl %ebp + movl %edi, 8(%ebp) + movl %edx, 12(%ebp) + call __dpml_ffs_and_shift__ +..B2.7: + addl $20, %esp + pushl %ebp + pushl $0 + pushl $8 + pushl %esi + pushl %ebp + call __dpml_addsub__ +..B2.8: + movl 116(%esp), %esi + testl %esi, %esi + je ..B2.10 +..B2.9: + addl $12, %esp + pushl %ebp + pushl %esi + pushl %ebp + call __dpml_multiply__ +..B2.10: + cmpl $-262144, 60(%esp) + je ..B2.15 +..B2.11: + movl $1, %eax +..B2.12: + movl 80(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B2.14 +..B2.13: + xorl %edx, %edx + addl $92, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B2.14: + call __stack_chk_fail@PLT +..B2.15: + testl %esi, %esi + jne ..B2.11 +..B2.16: + xorl %eax, %eax + jmp ..B2.12 + .align 16,0x90 + .type __dpml_ux_log__,@function + .size __dpml_ux_log__,.-__dpml_ux_log__ + .data +# -- End __dpml_ux_log__ + .section .rodata, "a" + .align 4 + .align 4 +__log_x_table: + .long 1088750600 + .long 519758862 + .long 58 + .long 0 + .long 59 + .long 0 + .long 60 + .long 0 + .long 1088750600 + .long 519758862 + .long 61 + .long 0 + .long 62 + .long 0 + .long 63 + .long 0 + .long 1088750600 + .long 519758862 + .long 64 + .long 0 + .long 65 + .long 0 + .long 66 + .long 0 + .long 15008776 + .long 336609536 + .long 58 + .long 0 + .long 4192101508 + .long 3037000499 + .long 4243534402 + .long 1518500249 + .long 1261892956 + .long 1305769775 + .long 706307789 + .long 114052365 + .long 2125978754 + .long 1401519948 + .long 2628436525 + .long 90640697 + .long 1075745124 + .long 4046945230 + .long 850547722 + .long 100185346 + .long 3858047057 + .long 2069326047 + .long 3415016796 + .long 106820841 + .long 196219186 + .long 3461778520 + .long 1283971156 + .long 114747264 + .long 133398994 + .long 3894487089 + .long 1548005786 + .long 123926548 + .long 4002430868 + .long 3905024888 + .long 1104860464 + .long 134702783 + .long 1396868873 + .long 2152947579 + .long 2102985887 + .long 147531619 + .long 361329122 + .long 2531697111 + .long 2794113080 + .long 163061263 + .long 2117398987 + .long 2352680084 + .long 3122626672 + .long 182244941 + .long 299366278 + .long 2801833386 + .long 1248329477 + .long 206544267 + .long 99864504 + .long 1693623838 + .long 1770762254 + .long 238320308 + .long 959885721 + .long 1462617677 + .long 2483170600 + .long 281651273 + .long 2353710846 + .long 1786830293 + .long 2080549112 + .long 344240445 + .long 2781107612 + .long 1683788319 + .long 2061424959 + .long 442594858 + .long 2924123738 + .long 1498310185 + .long 3744988402 + .long 619632801 + .long 2019498699 + .long 1065527877 + .long 1946680041 + .long 1032721336 + .long 1763524233 + .long 3196583632 + .long 1545072827 + .long 3098164009 + .long 2 + .long 0 + .long 0 + .long 1 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3520035243 + .long 2977044471 + .long 66254511 + .long 3387143064 + .long 0 + .long 4294967295 + .long 4224710552 + .long 2585827972 + .long 192713080 + .long 2408143276 + .long 0 + .long 0 + .type __log_x_table,@object + .size __log_x_table,528 + .data + .hidden __dpml_multiply__ + .hidden __dpml_divide__ + .hidden __dpml_ffs_and_shift__ + .hidden __dpml_addsub__ + .hidden __dpml_evaluate_rational__ + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/dpml_ux_ops.S b/external/sgx_libm/ia32/dpml_ux_ops.S new file mode 100644 index 0000000000..6a06e77f6f --- /dev/null +++ b/external/sgx_libm/ia32/dpml_ux_ops.S @@ -0,0 +1,3653 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_ops.c" + .text +..TXTST0: +# -- Begin __dpml_ffs_and_shift__ + .text + .align 16,0x90 + .hidden __dpml_ffs_and_shift__ + .globl __dpml_ffs_and_shift__ +__dpml_ffs_and_shift__: +# parameter 1: 64 + %esp +# parameter 2: 68 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $44, %esp + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + movl %eax, 28(%esp) + movl 64(%esp), %ecx + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 40(%esp) + movl 72(%esp), %eax + movl 68(%esp), %edx + movl 8(%ecx), %ebp + orl %eax, %edx + movl 12(%ecx), %ebx + jne ..B1.4 +..B1.2: + movl 64(%esp), %eax + xorl %ecx, %ecx + movl %ebx, %esi + subl %ecx, %esi + movl 4(%eax), %edx + movl %edx, 20(%esp) + jl ..B1.13 +..B1.3: + movl 64(%esp), %eax + movl 16(%eax), %esi + movl 20(%eax), %edx + jmp ..B1.9 +..B1.4: + movl $1, %edx + movl 68(%esp), %ecx + subl %edx, %ecx + orl %eax, %ecx + jne ..B1.7 +..B1.5: + xorl %eax, %eax + movl %ebx, %edx + subl %eax, %edx + jl ..B1.16 + jmp ..B1.8 +..B1.7: + xorl %eax, %eax +..B1.8: + movl 64(%esp), %edx + xorl %esi, %esi + movl $64, 20(%esp) + movl %ebp, 8(%edx) + movl %ebx, 12(%edx) + movl %esi, 16(%edx) + movl %esi, 20(%edx) + movl %eax, (%edx) + xorl %edx, %edx +..B1.9: + xorl %ecx, %ecx + movl $2, %edi + xorl %eax, %eax + movl %eax, 24(%esp) + movl %ebx, (%esp) + movl %ebp, 4(%esp) + movl %eax, %ebx + jmp ..B1.10 +..B1.12: + xorl %esi, %esi + xorl %edx, %edx +..B1.10: + movl 4(%esp), %ebp + orl (%esp), %ebp + jne ..B1.20 +..B1.11: + addl $64, %eax + movl %edx, (%esp) + adcl $0, %ebx + addl $-1, %edi + movl %edi, %edx + adcl $-1, %ecx + movl %esi, 4(%esp) + orl %ecx, %edx + jne ..B1.12 + jmp ..B1.17 +..B1.13: + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.15 +..B1.14: + xorl %eax, %eax + xorl %edx, %edx + addl $44, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.15: + movl 28(%esp), %ebx + call __stack_chk_fail@PLT +..B1.16: + xorl %edx, %edx + movl %ebp, %eax + xorl %ebp, %ebp + movl %ebx, %ecx + xorl %ebx, %ebx + subl %eax, %ebp + sbbl %ecx, %ebx + movl $-2147483648, %eax + jmp ..B1.8 +..B1.17: + movl 64(%esp), %edx + movl %ebx, 24(%esp) + movl $-262144, 4(%edx) + movl 40(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.15 +..B1.18: + movl %ebx, %edx + addl $44, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.20: + movl %ebx, 24(%esp) + xorl %ecx, %ecx + movl (%esp), %ebx + movl %ebx, %edi + movl 4(%esp), %ebp + subl %ecx, %edi + jl ..B1.36 +..B1.21: + movl %ebx, %ecx + xorl %edi, %edi + shrl $26, %ecx + andl $30, %ecx + orl %ecx, %edi + je ..B1.23 +..B1.22: + movl $21932, %edi + shrl %cl, %edi + andl $3, %edi + incl %edi + movl %edi, 16(%esp) + movl $0, 12(%esp) + jmp ..B1.26 +..B1.23: + movl %ebp, %edi + movl %ebx, %ecx + andl $-256, %edi + orl %edi, %ecx + jne ..B1.25 +..B1.24: + movl %ebp, %edi +..B1.25: + movl %edi, (%esp) + movl %ebx, %edi + movl %ebx, 4(%esp) + fildll (%esp) + shrl $31, %edi + movl 28(%esp), %ecx + movl %edx, 8(%esp) + faddl .L_2il0floatpacket.1@GOTOFF(%ecx,%edi,8) + movl $1086, %edi + fstpl 32(%esp) + movl 36(%esp), %edx + movl %edx, %ecx + sarl $20, %ecx + sarl $31, %edx + subl %ecx, %edi + movl $0, %ecx + sbbl %edx, %ecx + movl 8(%esp), %edx + movl %edi, 16(%esp) + movl %ecx, 12(%esp) +..B1.26: + cmpl $31, 16(%esp) + jbe ..B1.28 +..B1.27: + movl %ebp, %ebx + movl %edi, %ecx + movl $0, 4(%esp) + shll %cl, %ebx + jmp ..B1.29 +..B1.28: + movl %edi, %ecx + shldl %cl, %ebp, %ebx + shll %cl, %ebp + movl %ebp, 4(%esp) +..B1.29: + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B1.31 +..B1.30: + movl %edx, %ebp + movl $0, (%esp) + shrl %cl, %ebp + jmp ..B1.32 +..B1.31: + movl %edx, %edi + movl %esi, %ebp + shrl %cl, %edi + shrdl %cl, %edx, %ebp + movl %edi, (%esp) +..B1.32: + orl 4(%esp), %ebp + orl (%esp), %ebx + movl %esi, 8(%esp) + cmpl $31, 16(%esp) + jbe ..B1.34 +..B1.33: + movl 16(%esp), %ecx + xorl %esi, %esi + movl 8(%esp), %edx + shll %cl, %edx + jmp ..B1.35 +..B1.34: + movl 16(%esp), %ecx + shldl %cl, %esi, %edx + shll %cl, %esi +..B1.35: + addl 16(%esp), %eax + movl 24(%esp), %ecx + adcl 12(%esp), %ecx + movl %ecx, 24(%esp) +..B1.36: + movl 64(%esp), %ecx + movl %edx, 20(%ecx) + movl 20(%esp), %edx + subl %eax, %edx + movl %ebp, 8(%ecx) + movl %ebx, 12(%ecx) + movl %esi, 16(%ecx) + movl %edx, 4(%ecx) + movl 40(%esp), %ebx + xorl %esp, %ebx + cmpl %gs:20, %ebx + jne ..B1.15 +..B1.37: + movl 24(%esp), %edx + addl $44, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret + .align 16,0x90 + .type __dpml_ffs_and_shift__,@function + .size __dpml_ffs_and_shift__,.-__dpml_ffs_and_shift__ + .data +# -- End __dpml_ffs_and_shift__ + .text +# -- Begin __dpml_unpack2__ + .text + .align 16,0x90 + .hidden __dpml_unpack2__ + .globl __dpml_unpack2__ +__dpml_unpack2__: +# parameter 1: 64 + %esp +# parameter 2: 68 + %esp +# parameter 3: 72 + %esp +# parameter 4: 76 + %esp +# parameter 5: 80 + %esp +# parameter 6: 84 + %esp +# parameter 7: 88 + %esp +..B2.1: +..L3: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $44, %esp + movl 80(%esp), %ebx + movl 84(%esp), %eax + movl 88(%esp), %edx + movl %ebx, 12(%esp) + movl %eax, 16(%esp) + movl %edx, 20(%esp) + xorl %edx, %edx + movl 64(%esp), %eax + movl 72(%esp), %ecx + call __dpml_unpack_x_or_y__..0 +..B2.13: + movl %eax, %esi + movl %edx, %ebp +..B2.2: + xorl %ecx, %ecx + movl %ebp, %edi + subl %ecx, %edi + jl ..B2.9 +..B2.3: + cmpl $0, 68(%esp) + je ..B2.9 +..B2.4: + addl $-32, %esp + lea (,%esi,4), %ecx + movl 8(%ebx), %edi + cmpl $31, %ecx + movl 12(%ebx), %eax + jbe ..B2.6 +..B2.5: + sarl %cl, %eax + jmp ..B2.7 +..B2.6: + movl %eax, %edx + movl %edi, %eax + shrdl %cl, %edx, %eax +..B2.7: + andl $15, %eax + movl 116(%esp), %edi + movl 120(%esp), %ecx + movl 100(%esp), %edx + lea (%ebx,%eax,8), %ebx + movl %ebx, 12(%esp) + movl %edi, 16(%esp) + movl %ecx, 20(%esp) + movl 96(%esp), %eax + movl 108(%esp), %ecx + call __dpml_unpack_x_or_y__. +..B2.8: + movl %esi, %ecx + shrl $28, %ecx + shll $4, %esi + shll $4, %ebp + orl %eax, %esi + orl %ebp, %ecx + movl %esi, %eax + orl %ecx, %edx + addl $76, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B2.9: + movl %esi, %eax + movl %ebp, %edx + addl $44, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret + .align 16,0x90 + .type __dpml_unpack2__,@function + .size __dpml_unpack2__,.-__dpml_unpack2__ + .data +# -- End __dpml_unpack2__ + .text +# -- Begin __dpml_unpack_x_or_y__..0 + .text + .align 16,0x90 +__dpml_unpack_x_or_y__..0: +# parameter 1: %eax +# parameter 2: %edx +# parameter 3: %ecx +# parameter 4: 156 + %esp +# parameter 5: 160 + %esp +# parameter 6: 164 + %esp +..B3.1: +..L4: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $124, %esp + call ..L5 +..L5: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L5](%edx), %edx + movl %edx, 52(%esp) + movl 12(%eax), %edx + movl %ecx, 64(%esp) + movl %edx, %edi + movl %eax, 56(%esp) + andl $-2147483648, %edi + movl %gs:20, %ebp + xorl %esp, %ebp + movl %ebp, 116(%esp) + movl 164(%esp), %ebx + movl %edi, (%ecx) + movl %edx, %ecx + shrl $16, %ecx + andl $32767, %ecx + movl 8(%eax), %esi + movl %eax, 20(%ebx) + movl %edx, %ebx + movl %ecx, 60(%esp) + movl 4(%eax), %edi + lea -16382(%ecx), %ebp + movl %ebp, 16(%esp) + movl %esi, %ebp + shrl $17, %ebp + shll $15, %esi + shll $15, %ebx + movl (%eax), %ecx + movl %edi, %eax + shrl $17, %eax + orl %ebx, %ebp + movl %esi, %ebx + orl $-2147483648, %ebp + addl %esi, %ebx + movl %ebp, 20(%esp) + adcl %ebp, %ebp + orl %eax, %esi + movl %ecx, %eax + orl %edi, %ebp + shll $15, %eax + orl %ecx, %ebx + movl %esi, 76(%esp) + movl %ecx, %esi + movl %eax, 72(%esp) + movl %edi, %eax + shrl $17, %esi + lea -65536(%edx), %edi + shll $15, %eax + xorl %ecx, %ecx + orl %eax, %esi + lea 65536(%edx), %eax + movl %esi, 68(%esp) + movl %edx, %esi + xorl %edi, %eax + shrl $31, %esi + movl %edi, 24(%esp) + subl %ecx, %eax + movl 76(%esp), %edi + jl ..B3.39 +..B3.2: + movl 64(%esp), %eax + movl 72(%esp), %edx + movl 68(%esp), %ebx + movl %edi, 8(%eax) + movl 20(%esp), %edi + movl 16(%esp), %ebp + movl %edx, 16(%eax) + movl $4, %edx + movl %ebx, 20(%eax) + movl %edi, 12(%eax) + movl %ebp, 4(%eax) +..B3.3: + movl 164(%esp), %eax + addl %edx, %esi + movl $1, %edx + movl %esi, %ecx + movl %edx, 32(%esp) + movl (%eax), %ebp + movl %ebp, %edi + shll %cl, %edx + shll $10, %ebp + movl 4(%eax), %ebx + orl %edx, %ebp + shrl $22, %edi + shll $10, %ebx + movl %edx, 36(%esp) + xorl %edx, %edx + orl %ebx, %edi + movl %ebp, (%eax) + orl %esi, %edx + movl %edi, 4(%eax) + jne ..B3.5 +..B3.4: + movl $2139095040, 48(%esp) + flds 48(%esp) + flds 48(%esp) + fsubrp %st, %st(1) + fstps 48(%esp) +..B3.5: + movl $6, %eax + mull %esi + movl 156(%esp), %ebx + cmpl $31, %eax + movl (%ebx), %edi + movl 4(%ebx), %ebx + jbe ..B3.7 +..B3.6: + movl %eax, %ecx + movl %ebx, %edi + sarl %cl, %edi + jmp ..B3.8 +..B3.7: + movl %eax, %ecx + shrdl %cl, %ebx, %edi +..B3.8: + movl %edi, %ecx + xorl %edx, %edx + shrl $3, %edi + xorl %eax, %eax + andl $7, %edi + andl $7, %ecx + shrl $28, %ebx + orl %edi, %eax + je ..B3.32 +..B3.9: + movl 36(%esp), %ebp + movl %edx, %eax + andl $240, %ebp + movl %ebp, 24(%esp) + subl %edx, %eax + jl ..B3.10 +..B3.72: + orl %ecx, %eax + jne ..B3.14 +..B3.10: + movl %ecx, %ebx + orl %edx, %ebx + jne ..B3.12 +..B3.11: + movl 56(%esp), %ebx + movl %ebx, 20(%esp) + jmp ..B3.13 +..B3.12: + movl $0, 20(%esp) +..B3.13: + movl %ebp, %ebx + movl %ebx, 16(%esp) + jmp ..B3.15 +..B3.14: + addl %ecx, %ebx + movl 156(%esp), %edx + movl 52(%esp), %ebp + movl -8(%edx,%ebx,8), %ecx + movl -4(%edx,%ebx,8), %edx + movl 32(%esp), %ebx + shll %cl, %ebx + andl $240, %ebx + movl %ebx, 16(%esp) + movl %ecx, %ebx + shll $4, %ebx + addl __x_constants__@GOT(%ebp), %ebx + movl %ebx, 20(%esp) +..B3.15: + movl $7, %ebp + xorl %ebx, %ebx + negl %ebp + addl %edi, %ebp + orl %ebx, %ebp + je ..B3.36 +..B3.16: + movl 164(%esp), %ebx + movl 8(%ebx), %ebp + orl 12(%ebx), %ebp + je ..B3.19 +..B3.17: + movl 16(%esp), %ebp + xorl %ebx, %ebx + orl 24(%esp), %ebp + orl %ebx, %ebp + je ..B3.19 +..B3.18: + movl $1182793727, 44(%esp) + flds 44(%esp) + flds 44(%esp) + fmulp %st, %st(1) + fstps 44(%esp) +..B3.19: + movl 20(%esp), %ebx + movl 32(%esp), %eax + negl %eax + movl 8(%ebx), %ebp + addl %edi, %eax + movl %ebp, 16(%esp) + movl 12(%ebx), %ebp + xorl %ebx, %ebx + orl %ebx, %eax + je ..B3.35 +..B3.20: + movl $3, %eax + negl %eax + addl %edi, %eax + orl %ebx, %eax + je ..B3.25 +..B3.21: + movl $4, %eax + negl %eax + addl %edi, %eax + orl %ebx, %eax + jne ..B3.23 +..B3.22: + andl $2147483647, %ebp + jmp ..B3.26 +..B3.23: + movl $5, %ebx + subl %ebx, %edi + xorl %ebx, %ebx + orl %ebx, %edi + jne ..B3.26 +..B3.24: + movl 56(%esp), %ebx + andl $2147483647, %ebp + movl 12(%ebx), %edi + andl $-2147483648, %edi + orl %edi, %ebp + jmp ..B3.26 +..B3.25: + xorl $-2147483648, %ebp +..B3.26: + movl 160(%esp), %ebx + movl 16(%esp), %edi + testl $192, 36(%esp) + movl %ebp, 12(%ebx) + movl 20(%esp), %ebp + movl %edi, 8(%ebx) + movl (%ebp), %edi + movl 4(%ebp), %ebp + movl %edi, (%ebx) + movl %ebp, 4(%ebx) + je ..B3.30 +..B3.27: + xorl %ebx, %ebx + subl %ebx, %edx + jl ..B3.28 +..B3.73: + orl %edx, %ecx + jne ..B3.30 +..B3.28: + movl 164(%esp), %edx + movl 8(%edx), %ebx + orl 12(%edx), %ebx + je ..B3.30 +..B3.29: + movl 52(%esp), %edx + movl $8388608, 40(%esp) + flds 40(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%edx) + fmulp %st, %st(1) + fstps 40(%esp) +..B3.30: + movl 116(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B3.34 +..B3.31: + movl %esi, %eax + movl $-2147483648, %edx + addl $124, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B3.32: + movl 116(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B3.34 +..B3.33: + movl %esi, %eax + xorl %edx, %edx + addl $124, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B3.34: + movl 52(%esp), %ebx + call __stack_chk_fail@PLT +..B3.35: + orl $32768, %ebp + jmp ..B3.26 +..B3.36: + movl 160(%esp), %edi + andl $-2013265921, %ecx + orl $268435456, %ecx + movl %ecx, 56(%esp) + movl (%edi), %ebx + movl 4(%edi), %ebp + movl %ebx, 84(%esp) + movl %ebp, 88(%esp) + movl 8(%edi), %ebx + movl 12(%edi), %ebp + movl %ebx, 92(%esp) + movl %ebp, 96(%esp) + movl %edx, 60(%esp) + addl $4, %esp + lea 52(%esp), %edx + pushl %edx + call __dpml_exception +..B3.37: + movl 160(%esp), %ecx + movl (%eax), %edx + movl 4(%eax), %ebx + movl %edx, (%ecx) + movl %ebx, 4(%ecx) + movl 8(%eax), %ebp + movl 12(%eax), %edi + movl %ebp, 8(%ecx) + movl %edi, 12(%ecx) + jmp ..B3.30 +..B3.39: + movl 24(%esp), %ecx + xorl %eax, %eax + xorl %edx, %ecx + subl %eax, %ecx + jl ..B3.43 +..B3.40: + movl 64(%esp), %eax + orl %ebp, %ebx + movl 72(%esp), %ecx + movl %edi, 8(%eax) + movl 20(%esp), %edi + movl %ecx, 16(%eax) + movl %edi, 12(%eax) + movl 68(%esp), %ecx + movl 16(%esp), %edi + movl %ecx, 20(%eax) + movl %edi, 4(%eax) + jne ..B3.42 +..B3.41: + movl $2, %edx + jmp ..B3.3 +..B3.42: + shrl $15, %edx + movl %edx, %esi + xorl %edx, %edx + andl $1, %esi + jmp ..B3.3 +..B3.43: + orl %ebp, %ebx + jne ..B3.45 +..B3.44: + movl 64(%esp), %eax + movl 72(%esp), %edx + movl 68(%esp), %ebx + movl %edi, 8(%eax) + movl 20(%esp), %edi + movl 16(%esp), %ebp + movl %edx, 16(%eax) + movl $8, %edx + movl %ebx, 20(%eax) + movl %edi, 12(%eax) + movl %ebp, 4(%eax) + jmp ..B3.3 +..B3.45: + movl 20(%esp), %ebx + xorl %edx, %edx + addl $-2147483648, %ebx + movl %ebx, %eax + addl $-16381, 60(%esp) + movl %ebx, 20(%esp) + subl %edx, %eax + movl %edi, 36(%esp) + jl ..B3.69 +..B3.46: + movl 72(%esp), %edx + xorl %ecx, %ecx + movl %edx, 24(%esp) + movl $2, %eax + movl %edi, 76(%esp) + xorl %ebp, %ebp + movl 68(%esp), %edx + movl 24(%esp), %edi + movl %ecx, 32(%esp) + movl %esi, 16(%esp) + jmp ..B3.47 +..B3.49: + xorl %edi, %edi + xorl %edx, %edx +..B3.47: + movl 36(%esp), %esi + orl %ebx, %esi + jne ..B3.52 +..B3.48: + addl $64, 32(%esp) + movl %edx, %ebx + movl %edi, 36(%esp) + adcl $0, %ebp + addl $-1, %eax + movl %eax, %edx + adcl $-1, %ecx + orl %ecx, %edx + jne ..B3.49 +..B3.50: + movl 64(%esp), %ebp + movl 76(%esp), %edi + movl 72(%esp), %edx + movl %edi, 8(%ebp) + movl 68(%esp), %ebx + movl 20(%esp), %edi + movl 16(%esp), %esi + movl %edx, 16(%ebp) + movl %ebx, 20(%ebp) + movl %edi, 12(%ebp) + movl $-262144, 4(%ebp) +..B3.51: + movl $2048, 28(%esp) + movl $6, %edx + flds 28(%esp) + flds 28(%esp) + faddp %st, %st(1) + fstps 28(%esp) + jmp ..B3.3 +..B3.52: + movl %edi, 24(%esp) + movl %ebx, %edi + xorl %ebp, %ebp + movl 16(%esp), %esi + subl %ebp, %edi + jl ..B3.68 +..B3.53: + movl %ebx, %ecx + shrl $26, %ecx + andl $30, %ecx + orl %ecx, %ebp + je ..B3.55 +..B3.54: + movl $21932, %eax + shrl %cl, %eax + andl $3, %eax + incl %eax + jmp ..B3.58 +..B3.55: + movl 36(%esp), %edi + movl %ebx, %ebp + andl $-256, %edi + orl %edi, %ebp + jne ..B3.57 +..B3.56: + movl 36(%esp), %edi +..B3.57: + movl %edi, 16(%esp) + movl %ebx, %edi + movl %ebx, 20(%esp) + fildll 16(%esp) + shrl $31, %edi + movl 52(%esp), %ebp + faddl .L_2il0floatpacket.1@GOTOFF(%ebp,%edi,8) + fstpl 68(%esp) + movl 72(%esp), %eax + sarl $20, %eax + negl %eax + addl $1086, %eax +..B3.58: + cmpl $31, %eax + jbe ..B3.60 +..B3.59: + movl %eax, %ecx + xorl %edi, %edi + movl 36(%esp), %ebx + shll %cl, %ebx + jmp ..B3.61 +..B3.60: + movl %eax, %ecx + movl 36(%esp), %edi + shldl %cl, %edi, %ebx + shll %cl, %edi +..B3.61: + movl %eax, %ecx + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B3.63 +..B3.62: + movl %edx, %ebp + shrl %cl, %ebp + movl $0, 16(%esp) + movl %ebp, 36(%esp) + jmp ..B3.64 +..B3.63: + movl 24(%esp), %ebp + shrdl %cl, %edx, %ebp + movl %ebp, 36(%esp) + movl %edx, %ebp + shrl %cl, %ebp + movl %ebp, 16(%esp) +..B3.64: + orl %edi, 36(%esp) + orl 16(%esp), %ebx + movl 24(%esp), %ebp + cmpl $31, %eax + jbe ..B3.66 +..B3.65: + movl %eax, %ecx + movl %ebp, %edx + movl $0, 24(%esp) + shll %cl, %edx + jmp ..B3.67 +..B3.66: + movl %eax, %ecx + shldl %cl, %ebp, %edx + shll %cl, %ebp + movl %ebp, 24(%esp) +..B3.67: + addl %eax, 32(%esp) +..B3.68: + movl 64(%esp), %edi + movl 36(%esp), %ebp + movl %edx, 20(%edi) + movl 60(%esp), %edx + movl %ebx, 12(%edi) + movl 24(%esp), %ebx + subl 32(%esp), %edx + movl %ebp, 8(%edi) + movl %ebx, 16(%edi) + movl %edx, 4(%edi) + jmp ..B3.51 +..B3.69: + movl 64(%esp), %eax + movl 72(%esp), %edx + movl 68(%esp), %ebx + movl %edi, 8(%eax) + movl 20(%esp), %edi + movl 60(%esp), %ebp + movl %edx, 16(%eax) + movl %ebx, 20(%eax) + movl %edi, 12(%eax) + movl %ebp, 4(%eax) + jmp ..B3.51 + .align 16,0x90 + .type __dpml_unpack_x_or_y__..0,@function + .size __dpml_unpack_x_or_y__..0,.-__dpml_unpack_x_or_y__..0 + .data +# -- End __dpml_unpack_x_or_y__..0 + .text +# -- Begin __dpml_unpack_x_or_y__ + .text + .align 16,0x90 + .hidden __dpml_unpack_x_or_y__ + .globl __dpml_unpack_x_or_y__ +__dpml_unpack_x_or_y__: +# parameter 1: %eax +# parameter 2: %edx +# parameter 3: %ecx +# parameter 4: 172 + %esp +# parameter 5: 176 + %esp +# parameter 6: 180 + %esp +..B4.1: +..L6: + + movl 4(%esp), %eax + movl 8(%esp), %edx + movl 12(%esp), %ecx + .hidden __dpml_unpack_x_or_y__. + .globl __dpml_unpack_x_or_y__. +__dpml_unpack_x_or_y__.: + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $140, %esp + xorl %edi, %edi + testl %edx, %edx + movl %eax, 68(%esp) + movl %edi, %eax + movl %ecx, 88(%esp) + setne %al + movl %edx, 60(%esp) + movl %gs:20, %ebp + xorl %esp, %ebp + movl %ebp, 128(%esp) + orl %eax, %edi + movl %eax, 56(%esp) + je ..B4.3 +..B4.2: + movl %edx, %eax + jmp ..B4.4 +..B4.3: + movl 68(%esp), %eax +..B4.4: + movl 180(%esp), %edx + movl 56(%esp), %ebx + movl 8(%eax), %esi + movl %eax, 20(%edx,%ebx,4) + movl 12(%eax), %edx + movl %edx, %edi + movl %edx, %ebp + shrl $16, %edi + andl $-2147483648, %ebp + movl %ecx, %ebx + andl $32767, %edi + movl %edx, %ecx + shll $15, %ecx + movl %ebp, (%ebx) + movl %esi, %ebx + shrl $17, %ebx + lea -16382(%edi), %ebp + movl %edi, 72(%esp) + orl %ecx, %ebx + movl (%eax), %edi + orl $-2147483648, %ebx + movl 4(%eax), %eax + movl %eax, %ecx + shll $15, %esi + movl %ebp, 24(%esp) + movl %esi, %ebp + shrl $17, %ecx + addl %esi, %ebp + movl %ebx, 20(%esp) + adcl %ebx, %ebx + orl %ecx, %esi + movl %esi, 84(%esp) + movl %edi, %esi + shll $15, %esi + movl %edi, %ecx + movl %esi, 80(%esp) + movl %eax, %esi + shrl $17, %ecx + orl %edi, %ebp + shll $15, %esi + orl %eax, %ebx + orl %esi, %ecx + lea -65536(%edx), %edi + movl %edx, %esi + lea 65536(%edx), %eax + movl %edi, 16(%esp) + xorl %edi, %eax + xorl %edi, %edi + shrl $31, %esi + movl %ecx, 76(%esp) + subl %edi, %eax + call ..L7 +..L7: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L7](%edi), %edi + movl %edi, 64(%esp) + movl 20(%esp), %edi + jl ..B4.42 +..B4.5: + movl 88(%esp), %eax + movl 80(%esp), %edx + movl %ecx, %ebx + movl %edi, 12(%eax) + movl 84(%esp), %ebp + movl 24(%esp), %edi + movl %edx, 16(%eax) + movl $4, %edx + movl %ebx, 20(%eax) + movl %ebp, 8(%eax) + movl %edi, 4(%eax) +..B4.6: + movl 180(%esp), %eax + addl %edx, %esi + movl $1, %edx + movl %esi, %ecx + movl %edx, 28(%esp) + movl (%eax), %ebp + movl %ebp, %edi + shll %cl, %edx + shll $10, %ebp + movl 4(%eax), %ebx + orl %edx, %ebp + shrl $22, %edi + shll $10, %ebx + movl %edx, 36(%esp) + xorl %edx, %edx + orl %ebx, %edi + movl %ebp, (%eax) + orl %esi, %edx + movl %edi, 4(%eax) + jne ..B4.8 +..B4.7: + movl $2139095040, 52(%esp) + flds 52(%esp) + flds 52(%esp) + fsubrp %st, %st(1) + fstps 52(%esp) +..B4.8: + movl $6, %eax + mull %esi + movl 172(%esp), %ebx + cmpl $31, %eax + movl (%ebx), %edx + movl 4(%ebx), %ebp + jbe ..B4.10 +..B4.9: + movl %eax, %ecx + movl %ebp, %edx + sarl %cl, %edx + jmp ..B4.11 +..B4.10: + movl %eax, %ecx + shrdl %cl, %ebp, %edx +..B4.11: + movl %edx, %ecx + xorl %ebx, %ebx + shrl $3, %edx + xorl %edi, %edi + andl $7, %edx + andl $7, %ecx + shrl $28, %ebp + orl %edx, %edi + je ..B4.35 +..B4.12: + movl %ecx, %edi + movl 36(%esp), %eax + andl $240, %eax + subl 56(%esp), %edi + movl %eax, 16(%esp) + movl %edi, 24(%esp) + movl %ebx, %edi + sbbl %ebx, %edi + movl %edi, 20(%esp) + jl ..B4.13 +..B4.75: + movl 24(%esp), %eax + orl 20(%esp), %eax + jne ..B4.17 +..B4.13: + movl %ecx, %ebp + orl %ebx, %ebp + jne ..B4.16 +..B4.14: + movl 68(%esp), %ebp + movl %ebp, 60(%esp) +..B4.16: + movl 16(%esp), %ebp + jmp ..B4.18 +..B4.17: + addl %ecx, %ebp + movl 172(%esp), %ebx + movl 64(%esp), %eax + movl -8(%ebx,%ebp,8), %ecx + movl %ecx, %edi + shll $4, %edi + movl -4(%ebx,%ebp,8), %ebx + movl 28(%esp), %ebp + shll %cl, %ebp + addl __x_constants__@GOT(%eax), %edi + andl $240, %ebp + movl %edi, 60(%esp) +..B4.18: + movl $7, %edi + xorl %eax, %eax + negl %edi + addl %edx, %edi + orl %eax, %edi + je ..B4.39 +..B4.19: + movl 180(%esp), %eax + movl 8(%eax), %edi + orl 12(%eax), %edi + je ..B4.22 +..B4.20: + orl 16(%esp), %ebp + xorl %eax, %eax + orl %eax, %ebp + je ..B4.22 +..B4.21: + movl $1182793727, 48(%esp) + flds 48(%esp) + flds 48(%esp) + fmulp %st, %st(1) + fstps 48(%esp) +..B4.22: + movl 60(%esp), %eax + xorl %edi, %edi + movl 8(%eax), %ebp + movl %ebp, 16(%esp) + movl 12(%eax), %ebp + movl 28(%esp), %eax + negl %eax + addl %edx, %eax + orl %edi, %eax + je ..B4.38 +..B4.23: + movl $3, %edi + xorl %eax, %eax + negl %edi + addl %edx, %edi + orl %eax, %edi + je ..B4.28 +..B4.24: + movl $4, %edi + negl %edi + addl %edx, %edi + orl %eax, %edi + jne ..B4.26 +..B4.25: + andl $2147483647, %ebp + jmp ..B4.29 +..B4.26: + movl $5, %eax + xorl %edi, %edi + subl %eax, %edx + orl %edi, %edx + jne ..B4.29 +..B4.27: + movl 68(%esp), %edx + andl $2147483647, %ebp + movl 12(%edx), %edx + andl $-2147483648, %edx + orl %edx, %ebp + jmp ..B4.29 +..B4.28: + xorl $-2147483648, %ebp +..B4.29: + movl 176(%esp), %edx + movl 16(%esp), %eax + testl $192, 36(%esp) + movl %ebp, 12(%edx) + movl 60(%esp), %ebp + movl %eax, 8(%edx) + movl (%ebp), %edi + movl 4(%ebp), %ebp + movl %edi, (%edx) + movl %ebp, 4(%edx) + je ..B4.33 +..B4.30: + xorl %edx, %edx + subl 56(%esp), %ecx + sbbl %edx, %ebx + jl ..B4.31 +..B4.76: + orl %ebx, %ecx + jne ..B4.33 +..B4.31: + movl 180(%esp), %edx + movl 8(%edx), %ebx + orl 12(%edx), %ebx + je ..B4.33 +..B4.32: + movl 64(%esp), %edx + movl $8388608, 44(%esp) + flds 44(%esp) + fldt .L_2il0floatpacket.8@GOTOFF(%edx) + fmulp %st, %st(1) + fstps 44(%esp) +..B4.33: + movl 128(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B4.37 +..B4.34: + movl %esi, %eax + movl $-2147483648, %edx + addl $140, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B4.35: + movl 128(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B4.37 +..B4.36: + movl %esi, %eax + xorl %edx, %edx + addl $140, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B4.37: + movl 64(%esp), %ebx + call __stack_chk_fail@PLT +..B4.38: + orl $32768, %ebp + jmp ..B4.29 +..B4.39: + movl 176(%esp), %eax + andl $-2013265921, %ecx + orl $268435456, %ecx + movl %ecx, 68(%esp) + movl (%eax), %edx + movl 4(%eax), %ebp + movl %edx, 96(%esp) + movl %ebp, 100(%esp) + movl 8(%eax), %edx + movl 12(%eax), %ebp + movl %edx, 104(%esp) + movl %ebp, 108(%esp) + movl %ebx, 72(%esp) + addl $4, %esp + lea 64(%esp), %ebx + pushl %ebx + call __dpml_exception +..B4.40: + movl 176(%esp), %ecx + movl (%eax), %edx + movl 4(%eax), %ebx + movl %edx, (%ecx) + movl %ebx, 4(%ecx) + movl 8(%eax), %ebp + movl 12(%eax), %edi + movl %ebp, 8(%ecx) + movl %edi, 12(%ecx) + jmp ..B4.33 +..B4.42: + movl 16(%esp), %ecx + xorl %eax, %eax + xorl %edx, %ecx + subl %eax, %ecx + jl ..B4.46 +..B4.43: + movl 88(%esp), %eax + orl %ebx, %ebp + movl 80(%esp), %ecx + movl %ecx, 16(%eax) + movl 76(%esp), %ecx + movl %ecx, 20(%eax) + movl %edi, 12(%eax) + movl 84(%esp), %ecx + movl 24(%esp), %edi + movl %ecx, 8(%eax) + movl %edi, 4(%eax) + jne ..B4.45 +..B4.44: + movl $2, %edx + jmp ..B4.6 +..B4.45: + shrl $15, %edx + movl %edx, %esi + xorl %edx, %edx + andl $1, %esi + jmp ..B4.6 +..B4.46: + orl %ebx, %ebp + jne ..B4.48 +..B4.47: + movl 88(%esp), %eax + movl 80(%esp), %edx + movl 76(%esp), %ebx + movl %edi, 12(%eax) + movl 84(%esp), %ebp + movl 24(%esp), %edi + movl %edx, 16(%eax) + movl $8, %edx + movl %ebx, 20(%eax) + movl %ebp, 8(%eax) + movl %edi, 4(%eax) + jmp ..B4.6 +..B4.48: + addl $-2147483648, %edi + movl %edi, %ebp + addl $-16381, 72(%esp) + movl 84(%esp), %edx + subl %eax, %ebp + movl %edi, 40(%esp) + jl ..B4.72 +..B4.49: + movl 80(%esp), %ebp + movl 76(%esp), %ebx + movl %ebp, 28(%esp) + movl $2, %ebp + movl %ebx, 24(%esp) + xorl %ebx, %ebx + movl %edi, 20(%esp) + movl %esi, 16(%esp) + movl %eax, 36(%esp) + movl 28(%esp), %esi + movl 24(%esp), %edi + jmp ..B4.50 +..B4.52: + xorl %esi, %esi + xorl %edi, %edi +..B4.50: + movl %edx, %ecx + orl 40(%esp), %ecx + jne ..B4.55 +..B4.51: + addl $64, 36(%esp) + movl %esi, %edx + movl %edi, 40(%esp) + adcl $0, %ebx + addl $-1, %ebp + movl %ebp, %ecx + adcl $-1, %eax + orl %eax, %ecx + jne ..B4.52 +..B4.53: + movl 88(%esp), %eax + movl 20(%esp), %edi + movl 80(%esp), %edx + movl 76(%esp), %ebx + movl 84(%esp), %ebp + movl 16(%esp), %esi + movl %edx, 16(%eax) + movl %ebx, 20(%eax) + movl %ebp, 8(%eax) + movl %edi, 12(%eax) + movl $-262144, 4(%eax) +..B4.54: + movl $2048, 32(%esp) + movl $6, %edx + flds 32(%esp) + flds 32(%esp) + faddp %st, %st(1) + fstps 32(%esp) + jmp ..B4.6 +..B4.55: + xorl %ebx, %ebx + movl 40(%esp), %ebp + movl %esi, 28(%esp) + subl %ebx, %ebp + movl %edi, 24(%esp) + movl 16(%esp), %esi + jl ..B4.71 +..B4.56: + movl 40(%esp), %ecx + shrl $26, %ecx + andl $30, %ecx + orl %ecx, %ebx + je ..B4.58 +..B4.57: + movl $21932, %ebp + shrl %cl, %ebp + andl $3, %ebp + incl %ebp + jmp ..B4.61 +..B4.58: + movl %edx, %ebp + andl $-256, %ebp + movl 40(%esp), %ebx + orl %ebp, %ebx + jne ..B4.60 +..B4.59: + movl %edx, %ebp +..B4.60: + movl 40(%esp), %ebx + movl %ebp, 16(%esp) + movl %ebx, 20(%esp) + fildll 16(%esp) + shrl $31, %ebx + movl 64(%esp), %ebp + faddl .L_2il0floatpacket.1@GOTOFF(%ebp,%ebx,8) + fstpl 76(%esp) + movl 80(%esp), %ebp + sarl $20, %ebp + negl %ebp + addl $1086, %ebp +..B4.61: + cmpl $31, %ebp + jbe ..B4.63 +..B4.62: + movl %ebp, %ecx + xorl %ebx, %ebx + shll %cl, %edx + movl %edx, 40(%esp) + jmp ..B4.64 +..B4.63: + movl %ebp, %ecx + movl 40(%esp), %ebx + shldl %cl, %edx, %ebx + movl %ebx, 40(%esp) + movl %edx, %ebx + shll %cl, %ebx +..B4.64: + movl %ebp, %ecx + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B4.66 +..B4.65: + movl %edi, %edx + xorl %edi, %edi + shrl %cl, %edx + jmp ..B4.67 +..B4.66: + movl 28(%esp), %edx + shrdl %cl, %edi, %edx + shrl %cl, %edi +..B4.67: + orl %edi, 40(%esp) + orl %ebx, %edx + movl 28(%esp), %ebx + cmpl $31, %ebp + jbe ..B4.69 +..B4.68: + movl %ebp, %ecx + shll %cl, %ebx + movl $0, 28(%esp) + movl %ebx, 24(%esp) + jmp ..B4.70 +..B4.69: + movl %ebp, %ecx + movl 24(%esp), %edi + shldl %cl, %ebx, %edi + shll %cl, %ebx + movl %edi, 24(%esp) + movl %ebx, 28(%esp) +..B4.70: + addl %ebp, 36(%esp) +..B4.71: + movl 88(%esp), %eax + movl 72(%esp), %edi + movl 28(%esp), %ebx + movl %edx, 8(%eax) + movl 40(%esp), %edx + movl 24(%esp), %ebp + subl 36(%esp), %edi + movl %edx, 12(%eax) + movl %ebx, 16(%eax) + movl %ebp, 20(%eax) + movl %edi, 4(%eax) + jmp ..B4.54 +..B4.72: + movl 88(%esp), %eax + movl 80(%esp), %edx + movl 76(%esp), %ebx + movl %edi, 12(%eax) + movl 84(%esp), %ebp + movl 72(%esp), %edi + movl %edx, 16(%eax) + movl %ebx, 20(%eax) + movl %ebp, 8(%eax) + movl %edi, 4(%eax) + jmp ..B4.54 + .align 16,0x90 + .type __dpml_unpack_x_or_y__,@function + .size __dpml_unpack_x_or_y__,.-__dpml_unpack_x_or_y__ + .data +# -- End __dpml_unpack_x_or_y__ + .text +# -- Begin __dpml_pack__ + .text + .align 16,0x90 + .hidden __dpml_pack__ + .globl __dpml_pack__ +__dpml_pack__: +# parameter 1: 160 + %esp +# parameter 2: 164 + %esp +# parameter 3: 168 + %esp +# parameter 4: 176 + %esp +# parameter 5: 184 + %esp +..B5.1: +..L8: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $140, %esp + movl 160(%esp), %edx + call ..L9 +..L9: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L9](%ecx), %ecx + movl %ecx, 48(%esp) + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 136(%esp) + movl 12(%edx), %esi + movl %esi, %edi + movl 8(%edx), %ecx + movl %ecx, %ebp + movl 4(%edx), %eax + xorl %edx, %edx + movl %esi, %ebx + subl %edx, %edi + jl ..B5.7 +..B5.2: + movl 160(%esp), %edi + movl $2, 32(%esp) + movl %ebx, 68(%esp) + movl 16(%edi), %edx + movl %edx, 56(%esp) + movl 20(%edi), %edx + xorl %edi, %edi + movl %edi, 52(%esp) + movl %esi, 44(%esp) + movl %ecx, 36(%esp) + movl %eax, 60(%esp) + movl %ebp, 64(%esp) + movl 56(%esp), %esi + movl %edi, %ebx + movl 52(%esp), %eax + movl 32(%esp), %ecx + jmp ..B5.3 +..B5.5: + xorl %esi, %esi + xorl %edx, %edx +..B5.3: + movl 64(%esp), %ebp + orl 68(%esp), %ebp + jne ..B5.47 +..B5.4: + addl $64, %eax + movl %edx, 68(%esp) + adcl $0, %ebx + addl $-1, %ecx + movl %ecx, %edx + adcl $-1, %edi + movl %esi, 64(%esp) + orl %edi, %edx + jne ..B5.5 +..B5.6: + movl 160(%esp), %eax + movl 44(%esp), %esi + movl 36(%esp), %ecx + movl $-262144, 4(%eax) + movl $-262144, %eax +..B5.7: + cmpl $-262144, %eax + je ..B5.44 +..B5.8: + movl $-16381, %ebx + movl $-1, %ebp + cltd + subl %eax, %ebx + sbbl %edx, %ebp + xorl %edi, %edi + movl %ebp, %edx + subl %edi, %edx + jl ..B5.16 +..B5.66: + orl %ebx, %edx + je ..B5.16 +..B5.9: + movl 160(%esp), %edx + addl %ebx, %eax + movl %eax, 116(%esp) + lea 112(%esp), %eax + movl %edx, %ecx + movl (%edx), %esi + movl %edi, 8(%esp) + movl %edi, 8(%eax) + movl $-2147483648, 12(%eax) + movl %edi, 16(%eax) + movl %edi, 20(%eax) + movl %esi, (%eax) + movl %edi, 12(%esp) + call __dpml_addsub__..0 +..B5.10: + movl $113, %eax + movl %ebx, %ecx + subl %eax, %ecx + movl %ebp, %eax + sbbl %edi, %eax + jl ..B5.15 +..B5.67: + orl %eax, %ecx + je ..B5.15 +..B5.11: + movl $245763, %eax + negl %eax + addl %ebx, %eax + orl %ebp, %eax + je ..B5.39 +..B5.12: + movl $49155, %edx + movl $-16383, %eax + subl %edx, %ebx + sbbl %edi, %ebp + jl ..B5.14 +..B5.68: + orl %ebp, %ebx + je ..B5.14 +..B5.13: + movl 160(%esp), %edx + decl %eax + movl 8(%edx), %ecx + movl 12(%edx), %esi + jmp ..B5.16 +..B5.14: + movl 160(%esp), %edx + movl 8(%edx), %ecx + movl 12(%edx), %esi + jmp ..B5.16 +..B5.15: + movl 160(%esp), %edx + movl $-16382, %eax + movl 8(%edx), %ecx + movl 12(%edx), %esi +..B5.16: + movl 160(%esp), %ebx + movl $16384, %edx + movl 16(%ebx), %edi + addl $16384, %edi + movl %edi, %ebp + movl 20(%ebx), %ebx + adcl $0, %ebx + subl %edx, %ebp + movl $0, %edx + movl %ebx, %ebp + sbbl %edx, %ebp + jae ..B5.18 +..B5.17: + movl $1, %ebp + jmp ..B5.19 +..B5.18: + xorl %ebp, %ebp +..B5.19: + movl %ebx, %edx + addl %ebp, %ecx + adcl $0, %esi + shll $17, %edx + shrl $15, %edi + orl %edi, %edx + movl %ecx, %edi + shrl $15, %ebx + subl %ebp, %edi + movl $0, %ebp + movl %esi, %edi + sbbl %ebp, %edi + jae ..B5.22 +..B5.20: + movl $1, %ebp +..B5.22: + movl %ecx, %edi + shll $17, %edi + orl %edi, %ebx + movl 164(%esp), %edi + shrl $15, %ecx + movl %ebx, 4(%edi) + movl %esi, %ebx + shll $17, %ebx + movl %edx, (%edi) + xorl %edx, %edx + shrl $15, %esi + orl %ecx, %ebx + orl %edx, %ebp + je ..B5.24 +..B5.23: + incl %eax + xorl %ebx, %ebx + movl $65536, %esi +..B5.24: + movl %eax, %ecx + cltd + addl $16381, %ecx + movl %edx, %ebp + movl %ecx, %edx + adcl $0, %ebp + shll $16, %edx + addl %esi, %edx + movl 160(%esp), %esi + movl (%esi), %edi + orl %edi, %edx + movl %edi, 32(%esp) + movl $32766, %esi + movl %ecx, %edi + subl %esi, %edi + movl $0, %esi + sbbl %esi, %ebp + jae ..B5.29 +..B5.25: + movl 164(%esp), %eax + movl %edx, 12(%eax) + movl 184(%esp), %edx + movl %ebx, 8(%eax) + movl 8(%edx), %ecx + orl 12(%edx), %ecx + je ..B5.27 +..B5.26: + movl $1182793727, 40(%esp) + flds 40(%esp) + flds 40(%esp) + fmulp %st, %st(1) + fstps 40(%esp) +..B5.27: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B5.40 +..B5.28: + addl $140, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B5.29: + testl %eax, %eax + movl 168(%esp), %ebp + movl 172(%esp), %eax + jl ..L10 + movl 176(%esp), %ebp +..L10: + jl ..L11 + movl 180(%esp), %eax +..L11: + incl %ecx + testl %ecx, %ecx + jg ..B5.35 +..B5.30: + js ..B5.42 +..B5.31: + movl 164(%esp), %ecx + movl %edx, 12(%ecx) + movl 184(%esp), %edx + movl %ebx, 8(%ecx) + movl 8(%edx), %ebx + orl 12(%edx), %ebx + je ..B5.33 +..B5.32: + orl $-2147483648, %eax + jmp ..B5.36 +..B5.33: + movl 136(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B5.40 +..B5.34: + addl $140, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B5.35: + movl 164(%esp), %ecx + movl %ebx, 8(%ecx) + movl %edx, 12(%ecx) +..B5.36: + movl 164(%esp), %ebx + andl $-2013265921, %ebp + orl $268435456, %ebp + movl %ebp, 52(%esp) + movl (%ebx), %edx + movl 4(%ebx), %ecx + movl 8(%ebx), %esi + movl 12(%ebx), %edi + movl %edx, 80(%esp) + movl %ecx, 84(%esp) + movl %esi, 88(%esp) + movl %edi, 92(%esp) + movl %eax, 56(%esp) + addl $4, %esp + lea 48(%esp), %eax + pushl %eax + call __dpml_exception +..B5.69: + movl %eax, %ecx +..B5.37: + movl 164(%esp), %ebp + movl (%ecx), %eax + movl 4(%ecx), %edx + movl %eax, (%ebp) + movl %edx, 4(%ebp) + movl 8(%ecx), %ebx + movl 12(%ecx), %ecx + movl %ebx, 8(%ebp) + movl %ecx, 12(%ebp) + movl 136(%esp), %esi + xorl %esp, %esi + cmpl %gs:20, %esi + jne ..B5.40 +..B5.38: + addl $140, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B5.39: + movl $-16382, %eax + jmp ..B5.13 +..B5.40: + movl 48(%esp), %ebx + call __stack_chk_fail@PLT +..B5.42: + movl 164(%esp), %ecx + movl 32(%esp), %edx + movl $0, 8(%ecx) + movl %edx, 12(%ecx) + jmp ..B5.36 +..B5.44: + movl 160(%esp), %eax + xorl %edx, %edx + movl 164(%esp), %ebx + movl (%eax), %ecx + movl %edx, (%ebx) + movl %edx, 4(%ebx) + movl %edx, 8(%ebx) + movl %ecx, 12(%ebx) + movl 136(%esp), %ebp + xorl %esp, %ebp + cmpl %gs:20, %ebp + jne ..B5.40 + jmp ..B5.28 +..B5.47: + movl 68(%esp), %ebx + xorl %ecx, %ecx + movl %esi, 56(%esp) + movl %ebx, %esi + movl %eax, 52(%esp) + subl %ecx, %esi + movl 60(%esp), %eax + movl 64(%esp), %ebp + jl ..B5.63 +..B5.48: + movl %ebx, %ecx + xorl %esi, %esi + shrl $26, %ecx + andl $30, %ecx + orl %ecx, %esi + je ..B5.50 +..B5.49: + movl $21932, %esi + shrl %cl, %esi + andl $3, %esi + incl %esi + jmp ..B5.53 +..B5.50: + movl %ebp, %esi + movl %ebx, %ecx + andl $-256, %esi + orl %esi, %ecx + jne ..B5.52 +..B5.51: + movl %ebp, %esi +..B5.52: + movl %esi, 32(%esp) + movl %ebx, %esi + movl %ebx, 36(%esp) + fildll 32(%esp) + shrl $31, %esi + movl 48(%esp), %ecx + faddl .L_2il0floatpacket.1@GOTOFF(%ecx,%esi,8) + fstpl 60(%esp) + movl 64(%esp), %esi + sarl $20, %esi + negl %esi + addl $1086, %esi +..B5.53: + cmpl $31, %esi + jbe ..B5.55 +..B5.54: + movl %esi, %ecx + movl %ebp, %ebx + movl $0, 32(%esp) + shll %cl, %ebx + jmp ..B5.56 +..B5.55: + movl %esi, %ecx + shldl %cl, %ebp, %ebx + shll %cl, %ebp + movl %ebp, 32(%esp) +..B5.56: + movl %esi, %ecx + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B5.58 +..B5.57: + movl %edx, %ebp + movl $0, 36(%esp) + shrl %cl, %ebp + jmp ..B5.59 +..B5.58: + movl %edx, %edi + movl 56(%esp), %ebp + shrl %cl, %edi + shrdl %cl, %edx, %ebp + movl %edi, 36(%esp) +..B5.59: + orl 32(%esp), %ebp + orl 36(%esp), %ebx + movl 56(%esp), %edi + cmpl $31, %esi + jbe ..B5.61 +..B5.60: + movl %esi, %ecx + movl %edi, %edx + movl $0, 56(%esp) + shll %cl, %edx + jmp ..B5.62 +..B5.61: + movl %esi, %ecx + shldl %cl, %edi, %edx + shll %cl, %edi + movl %edi, 56(%esp) +..B5.62: + addl %esi, 52(%esp) +..B5.63: + movl 160(%esp), %edi + movl %ebx, %esi + subl 52(%esp), %eax + movl %ebp, %ecx + movl %ebx, 12(%edi) + movl 56(%esp), %ebx + movl %ebp, 8(%edi) + movl %ebx, 16(%edi) + movl %edx, 20(%edi) + movl %eax, 4(%edi) + jmp ..B5.7 + .align 16,0x90 + .type __dpml_pack__,@function + .size __dpml_pack__,.-__dpml_pack__ + .data +# -- End __dpml_pack__ + .text +# -- Begin __dpml_addsub__..0 + .text + .align 16,0x90 +__dpml_addsub__..0: +# parameter 1: %eax +# parameter 2: %edx +# parameter 3: 184 + %esp +# parameter 4: %ecx +..B6.1: +..L12: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $156, %esp + movl %edx, %edi + movl %eax, %ebx + movl %ecx, 132(%esp) + movl %gs:20, %ebp + xorl %esp, %ebp + movl %ebp, 144(%esp) + movl (%ebx), %ebp + movl (%edi), %eax + xorl %ebp, %eax + shrl $31, %eax + movl 4(%ebx), %ecx + movl %eax, 124(%esp) + movl %ecx, %eax + cltd + movl 4(%edi), %eax + movl %edx, %esi + cltd + movl %edx, %eax + movl %ecx, %edx + subl 4(%edi), %edx + movl %ecx, 104(%esp) + sbbl %eax, %esi + xorl %eax, %eax + movl %esi, %ecx + movl $0, 112(%esp) + subl %eax, %ecx + movl 104(%esp), %eax + jl ..B6.3 +..B6.2: + movl $0, 92(%esp) + jmp ..B6.7 +..B6.3: + movl %ebx, %ecx + movl %edi, %ebx + movl %ecx, %edi + movl %edx, %ecx + xorl %edx, %edx + subl %ecx, %edx + movl %esi, %ecx + movl $0, %esi + sbbl %ecx, %esi + addl %edx, %eax + movl 124(%esp), %ecx + orl 112(%esp), %ecx + jne ..B6.5 +..B6.4: + xorl %ecx, %ecx + jmp ..B6.6 +..B6.5: + movl $-2147483648, %ecx +..B6.6: + movl $-2147483648, 92(%esp) + xorl %ecx, %ebp +..B6.7: + movl 16(%edi), %ecx + movl %ecx, 100(%esp) + movl 20(%edi), %ecx + movl %ecx, 96(%esp) + movl 8(%edi), %ecx + movl 12(%edi), %edi + movl %ecx, 120(%esp) + movl %edi, 116(%esp) + movl $2, %edi + movl $0, (%esp) + call ..L13 +..L13: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L13](%ecx), %ecx + movl %ebp, 108(%esp) + movl %ecx, 8(%esp) + movl %edi, 4(%esp) + movl %eax, 104(%esp) + movl %ebx, 128(%esp) + movl (%esp), %ebp + jmp ..B6.8 +..B6.10: + xorl %eax, %eax + movl %eax, 120(%esp) + movl %eax, 116(%esp) +..B6.8: + movl $64, %ebx + xorl %edi, %edi + xorl %eax, %eax + subl %edx, %ebx + sbbl %esi, %eax + movl %eax, %ecx + subl %edi, %ecx + jl ..B6.9 +..B6.85: + orl %ebx, %ecx + jne ..B6.14 +..B6.9: + movl 116(%esp), %esi + movl 120(%esp), %edx + movl %esi, 96(%esp) + xorl %esi, %esi + movl %edx, 100(%esp) + xorl %edx, %edx + subl %ebx, %edx + sbbl %eax, %esi + movl 4(%esp), %eax + addl $-1, %eax + movl %eax, 4(%esp) + adcl $-1, %ebp + orl %ebp, %eax + jne ..B6.10 +..B6.11: + movl 132(%esp), %eax + movl 128(%esp), %ebx + movl 8(%ebx), %ecx + movl 12(%ebx), %esi + movl %ecx, 8(%eax) + movl %esi, 12(%eax) + movl 4(%ebx), %edx + movl 16(%ebx), %edi + movl 20(%ebx), %ebx + movl 108(%esp), %ebp + movl %edx, 4(%eax) + movl %edi, 16(%eax) + movl %ebx, 20(%eax) + movl %ebp, (%eax) + movl 144(%esp), %ebp + xorl %esp, %ebp + cmpl %gs:20, %ebp + jne ..B6.13 +..B6.12: + addl $156, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B6.13: + movl 8(%esp), %ebx + call __stack_chk_fail@PLT +..B6.14: + movl %ebx, 4(%esp) + orl %edx, %esi + movl 108(%esp), %ebp + movl 104(%esp), %eax + movl 128(%esp), %ebx + je ..B6.25 +..B6.15: + cmpl $31, %edx + jbe ..B6.17 +..B6.16: + movl %edx, %ecx + xorl %esi, %esi + movl 96(%esp), %edi + shrl %cl, %edi + movl %edi, 100(%esp) + jmp ..B6.18 +..B6.17: + movl %edx, %ecx + movl 100(%esp), %edi + movl 96(%esp), %esi + shrdl %cl, %esi, %edi + movl %edi, 100(%esp) + shrl %cl, %esi +..B6.18: + cmpl $31, 4(%esp) + jbe ..B6.20 +..B6.19: + movl 4(%esp), %ecx + movl 120(%esp), %edi + shll %cl, %edi + movl $0, (%esp) + movl %edi, 96(%esp) + jmp ..B6.21 +..B6.20: + movl %ebp, 108(%esp) + movl 4(%esp), %ecx + movl 116(%esp), %edi + movl 120(%esp), %ebp + shldl %cl, %ebp, %edi + shll %cl, %ebp + movl %ebp, (%esp) + movl %edi, 96(%esp) + movl 108(%esp), %ebp +..B6.21: + movl (%esp), %edi + orl %edi, 100(%esp) + orl %esi, 96(%esp) + movl 116(%esp), %esi + cmpl $31, %edx + jbe ..B6.23 +..B6.22: + movl %edx, %ecx + shrl %cl, %esi + movl $0, 116(%esp) + movl %esi, 120(%esp) +..B6.25: + xorl %esi, %esi + movl %ebp, 108(%esp) + movl %esi, 48(%esp) + movl %eax, 104(%esp) + movl %ebx, 128(%esp) + jmp ..B6.26 +..B6.23: + movl %edx, %ecx + movl 120(%esp), %edi + shrdl %cl, %esi, %edi + shrl %cl, %esi + movl %edi, 120(%esp) + movl %esi, 116(%esp) + jmp ..B6.25 +..B6.55: + movl 128(%esp), %edi + movl $1, %edx + movl 124(%esp), %eax + xorl %ecx, %ecx + subl %eax, %edx + movl 108(%esp), %ebp + movl 4(%edi), %eax + movl 112(%esp), %ebx + sbbl %ebx, %ecx + xorl 92(%esp), %ebp + xorl $2, %esi + addl $24, 132(%esp) + movl %edx, 124(%esp) + movl %ecx, 112(%esp) + movl %ebp, 108(%esp) + movl %eax, 104(%esp) +..B6.26: + movl 128(%esp), %edx + movl 124(%esp), %eax + orl 112(%esp), %eax + movl 16(%edx), %ebx + movl 20(%edx), %edx + jne ..B6.38 +..B6.27: + movl %ebx, %ebp + movl %edx, %ecx + addl 100(%esp), %ebp + movl %ebp, %eax + adcl 96(%esp), %ecx + andl $15, %esi + subl %ebx, %eax + movl %ecx, %ebx + movl $0, 48(%esp) + sbbl %edx, %ebx + jae ..B6.29 +..B6.28: + movl $1, 72(%esp) + jmp ..B6.30 +..B6.29: + movl $0, 72(%esp) +..B6.30: + movl 128(%esp), %edi + movl 72(%esp), %edx + movl 8(%edi), %ebx + movl %ebx, 52(%esp) + movl 120(%esp), %ebx + movl 12(%edi), %eax + addl %edx, %ebx + movl %eax, 80(%esp) + movl %ebx, %eax + movl 116(%esp), %edi + adcl $0, %edi + subl %edx, %eax + movl $0, %edx + movl %edi, %eax + sbbl %edx, %eax + jae ..B6.32 +..B6.31: + movl $1, 68(%esp) + jmp ..B6.33 +..B6.32: + movl $0, 68(%esp) +..B6.33: + movl 52(%esp), %eax + addl %eax, %ebx + movl %ebx, %edx + adcl 80(%esp), %edi + subl %eax, %edx + movl %edi, %eax + sbbl 80(%esp), %eax + jae ..B6.35 +..B6.34: + movl $1, %edx + jmp ..B6.36 +..B6.35: + xorl %edx, %edx +..B6.36: + movl 68(%esp), %eax + addl %edx, %eax + xorl %edx, %edx + orl %edx, %eax + je ..B6.52 +..B6.37: + movl %ecx, %eax + movl %ebx, %edx + shll $31, %eax + shrl $1, %ebp + orl %eax, %ebp + movl %edi, %eax + shrl $1, %ecx + shll $31, %edx + shll $31, %eax + orl %edx, %ecx + shrl $1, %edi + shrl $1, %ebx + orl $-2147483648, %edi + incl 104(%esp) + orl %eax, %ebx + jmp ..B6.52 +..B6.38: + addl $-8, %esi + movl 100(%esp), %ecx + adcl $-1, 48(%esp) + subl %ebx, %ecx + movl 96(%esp), %eax + sbbl %edx, %eax + jb ..B6.40 +..B6.86: + orl %eax, %ecx + je ..B6.40 +..B6.39: + movl $1, %eax + jmp ..B6.41 +..B6.40: + xorl %eax, %eax +..B6.41: + movl 128(%esp), %edi + movl %ebx, %ebp + subl 100(%esp), %ebp + movl %edx, %ecx + movl 116(%esp), %ebx + movl 8(%edi), %edx + movl %edx, 60(%esp) + movl 12(%edi), %edx + movl 120(%esp), %edi + sbbl 96(%esp), %ecx + addl %eax, %edi + movl %edi, 56(%esp) + adcl $0, %ebx + subl %eax, %edi + movl $0, %eax + movl %ebx, 76(%esp) + sbbl %eax, %ebx + jae ..B6.43 +..B6.42: + movl $1, 64(%esp) + jmp ..B6.44 +..B6.43: + movl $0, 64(%esp) +..B6.44: + movl 60(%esp), %eax + movl %eax, %ebx + subl 56(%esp), %ebx + movl %edx, %edi + sbbl 76(%esp), %edi + subl %ebx, %eax + sbbl %edi, %edx + jae ..B6.46 +..B6.45: + movl $1, %edx + jmp ..B6.47 +..B6.46: + xorl %edx, %edx +..B6.47: + movl 64(%esp), %eax + addl %edx, %eax + xorl %edx, %edx + orl %edx, %eax + je ..B6.52 +..B6.48: + xorl %eax, %eax + movl %ebp, %edx + xorl %ebp, %ebp + subl %edx, %ebp + movl %ecx, %edx + movl %eax, %ecx + movl %ebp, %eax + sbbl %edx, %ecx + xorl $-2147483648, 108(%esp) + orl %ecx, %eax + jne ..B6.50 +..B6.49: + movl $0, 44(%esp) + jmp ..B6.51 +..B6.50: + movl $-1, 44(%esp) +..B6.51: + movl 44(%esp), %eax + cltd + movl %ebx, %eax + movl 44(%esp), %ebx + subl %eax, %ebx + movl %edi, %eax + movl %edx, %edi + movl $-2147483648, 92(%esp) + sbbl %eax, %edi +..B6.52: + movl 132(%esp), %edx + movl 108(%esp), %eax + movl %eax, (%edx) + movl %esi, %edx + andl $16, %edx + xorl %eax, %eax + orl %eax, %edx + jne ..B6.56 +..B6.53: + movl 132(%esp), %edx + movl 104(%esp), %eax + movl %eax, 4(%edx) + movl %ebp, 16(%edx) + movl %ecx, 20(%edx) + movl %ebx, 8(%edx) + movl %edi, 12(%edx) +..B6.54: + movl %esi, %edx + xorl %eax, %eax + andl $2, %edx + orl %eax, %edx + jne ..B6.55 + jmp ..B6.61 +..B6.56: + movl %edi, %edx + movl %ebx, 84(%esp) + subl %eax, %edx + movl %edi, 88(%esp) + jl ..B6.53 +..B6.57: + movl $2, %edx + movl %ebp, 36(%esp) + movl %ecx, 40(%esp) + movl %eax, 32(%esp) + movl %ebx, 12(%esp) + movl %esi, 28(%esp) + movl %edi, 20(%esp) + movl %ecx, 24(%esp) + movl %ebp, 16(%esp) + movl 36(%esp), %esi + movl 40(%esp), %edi + movl %eax, %ebx + movl 32(%esp), %ecx + jmp ..B6.58 +..B6.60: + xorl %esi, %esi + xorl %edi, %edi +..B6.58: + movl 84(%esp), %ebp + orl 88(%esp), %ebp + jne ..B6.65 +..B6.59: + addl $64, %ecx + movl %esi, 84(%esp) + adcl $0, %ebx + addl $-1, %edx + movl %edx, %ebp + adcl $-1, %eax + movl %edi, 88(%esp) + orl %eax, %ebp + jne ..B6.60 + jmp ..B6.64 +..B6.61: + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B6.13 + jmp ..B6.12 +..B6.64: + movl 132(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ebp + movl 20(%esp), %edi + movl 24(%esp), %ecx + movl 28(%esp), %esi + movl %ebp, 16(%eax) + movl %ecx, 20(%eax) + movl %ebx, 8(%eax) + movl %edi, 12(%eax) + movl $-262144, 4(%eax) + jmp ..B6.54 +..B6.65: + xorl %eax, %eax + movl 88(%esp), %edx + movl %esi, 36(%esp) + subl %eax, %edx + movl %edi, 40(%esp) + movl %ecx, 32(%esp) + movl 28(%esp), %esi + jl ..B6.81 +..B6.66: + movl 88(%esp), %ecx + shrl $26, %ecx + andl $30, %ecx + orl %ecx, %eax + je ..B6.68 +..B6.67: + movl $21932, %edx + shrl %cl, %edx + andl $3, %edx + incl %edx + jmp ..B6.71 +..B6.68: + movl 84(%esp), %edx + andl $-256, %edx + movl 88(%esp), %eax + orl %edx, %eax + jne ..B6.70 +..B6.69: + movl 84(%esp), %edx +..B6.70: + movl 88(%esp), %eax + movl %edx, (%esp) + movl %eax, 4(%esp) + fildll (%esp) + shrl $31, %eax + movl 8(%esp), %edx + faddl .L_2il0floatpacket.1@GOTOFF(%edx,%eax,8) + fstpl 136(%esp) + movl 140(%esp), %edx + sarl $20, %edx + negl %edx + addl $1086, %edx +..B6.71: + cmpl $31, %edx + jbe ..B6.73 +..B6.72: + movl %edx, %ecx + xorl %eax, %eax + movl 84(%esp), %ebx + shll %cl, %ebx + movl %ebx, 88(%esp) + jmp ..B6.74 +..B6.73: + movl %edx, %ecx + movl 84(%esp), %eax + movl 88(%esp), %ebx + shldl %cl, %eax, %ebx + movl %ebx, 88(%esp) + shll %cl, %eax +..B6.74: + movl %edx, %ecx + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B6.76 +..B6.75: + movl %edi, %ebx + xorl %ebp, %ebp + shrl %cl, %ebx + movl %ebx, 84(%esp) + jmp ..B6.77 +..B6.76: + movl 36(%esp), %ebx + movl %edi, %ebp + shrdl %cl, %ebp, %ebx + movl %ebx, 84(%esp) + shrl %cl, %ebp +..B6.77: + orl %eax, 84(%esp) + orl %ebp, 88(%esp) + movl 36(%esp), %ebx + cmpl $31, %edx + jbe ..B6.79 +..B6.78: + movl %edx, %ecx + shll %cl, %ebx + movl $0, 36(%esp) + movl %ebx, 40(%esp) + jmp ..B6.80 +..B6.79: + movl %edx, %ecx + movl %edi, %eax + shldl %cl, %ebx, %eax + shll %cl, %ebx + movl %eax, 40(%esp) + movl %ebx, 36(%esp) +..B6.80: + addl %edx, 32(%esp) +..B6.81: + movl 132(%esp), %edi + movl 104(%esp), %ebp + movl 84(%esp), %eax + movl 88(%esp), %edx + movl 36(%esp), %ecx + movl 40(%esp), %ebx + subl 32(%esp), %ebp + movl %eax, 8(%edi) + movl %edx, 12(%edi) + movl %ecx, 16(%edi) + movl %ebx, 20(%edi) + movl %ebp, 4(%edi) + jmp ..B6.54 + .align 16,0x90 + .type __dpml_addsub__..0,@function + .size __dpml_addsub__..0,.-__dpml_addsub__..0 + .data +# -- End __dpml_addsub__..0 + .text +# -- Begin __dpml_evaluate_packed_poly__ + .text + .align 16,0x90 + .globl __dpml_evaluate_packed_poly__ +__dpml_evaluate_packed_poly__: +# parameter 1: 160 + %esp +# parameter 2: 164 + %esp +# parameter 3: 172 + %esp +# parameter 4: 176 + %esp +# parameter 5: 184 + %esp +# parameter 6: 192 + %esp +..B7.1: +..L14: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $140, %esp + movl 172(%esp), %esi + movl 192(%esp), %ebp + movl %gs:20, %ecx + xorl %esp, %ecx + movl %ecx, 124(%esp) + movl 12(%esi), %ecx + movl (%esi), %ebx + movl %ebx, %edx + movl 176(%esp), %edi + notl %edi + movl %ecx, 12(%ebp) + andl %edi, %edx + movl 8(%esi), %eax + movl 4(%esi), %ecx + movl %edi, 68(%esp) + movl %ecx, %edi + movl %edx, 16(%ebp) + movl %ebx, %edx + shll $31, %ecx + andl $1, %edx + shrl $1, %ebx + movl %eax, 8(%ebp) + orl %ebx, %ecx + movl 180(%esp), %eax + notl %eax + andl 176(%esp), %ecx + andl %eax, %edi + movl %eax, 64(%esp) + xorl %eax, %eax + subl 184(%esp), %ecx + movl %edi, 20(%ebp) + orl %eax, %edx + jne ..B7.3 +..B7.2: + movl %eax, %edx + jmp ..B7.4 +..B7.3: + movl $-2147483648, %edx +..B7.4: + movl 164(%esp), %edi + addl $-1, %edi + movl %ecx, 4(%ebp) + movl 168(%esp), %ecx + adcl $-1, %ecx + movl %edx, (%ebp) + movl %ecx, %edx + call ..L15 +..L15: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L15](%ebx), %ebx + subl %eax, %edx + jl ..B7.16 +..B7.5: + movl %eax, 104(%esp) + movl %eax, 100(%esp) + movl %ecx, 80(%esp) + movl %ebx, 40(%esp) + movl %edi, 76(%esp) + movl %esi, 72(%esp) +..B7.6: + addl $12, %esp + movl 180(%esp), %eax + pushl %eax + pushl %eax + pushl 156(%esp) + call __dpml_multiply__ +..B7.7: + movl 192(%esp), %eax + xorl %ecx, %ecx + movl 12(%eax), %ebp + movl %ebp, %ebx + movl 4(%eax), %edx + subl %ecx, %ebx + movl 8(%eax), %esi + movl %edx, 56(%esp) + jl ..B7.13 +..B7.8: + movl 192(%esp), %edx + xorl %eax, %eax + movl %eax, 60(%esp) + movl %ebp, 88(%esp) + movl 16(%edx), %ebx + movl 20(%edx), %edi + movl $2, %edx + movl %esi, 84(%esp) + movl %eax, %ebp + movl 60(%esp), %ecx + jmp ..B7.9 +..B7.11: + xorl %ebx, %ebx + xorl %edi, %edi +..B7.9: + movl 84(%esp), %esi + orl 88(%esp), %esi + jne ..B7.19 +..B7.10: + addl $64, %ecx + movl %ebx, 84(%esp) + adcl $0, %ebp + addl $-1, %edx + movl %edx, %ebx + adcl $-1, %eax + movl %edi, 88(%esp) + orl %eax, %ebx + jne ..B7.11 +..B7.12: + movl 192(%esp), %eax + movl $-262144, 4(%eax) +..B7.13: + movl 72(%esp), %esi + addl $16, %esi + movl 68(%esp), %edi + movl 64(%esp), %edx + movl %esi, 72(%esp) + movl 8(%esi), %ebx + movl %ebx, 108(%esp) + movl (%esi), %eax + andl %eax, %edi + movl 4(%esi), %ebx + andl %ebx, %edx + shll $31, %ebx + movl %eax, %ecx + shrl $1, %eax + andl $1, %ecx + orl %eax, %ebx + movl 192(%esp), %eax + andl 176(%esp), %ebx + movl 12(%esi), %ebp + movl %edx, 120(%esp) + lea 100(%esp), %edx + movl %ecx, 8(%esp) + movl %eax, %ecx + movl %ebp, 12(%edx) + movl %edi, 16(%edx) + subl 184(%esp), %ebx + movl $0, 12(%esp) + call __dpml_addsub__. +..B7.14: + movl 192(%esp), %eax + xorl %ecx, %ecx + addl $-1, 76(%esp) + movl 80(%esp), %edx + adcl $-1, %edx + addl %ebx, 4(%eax) + movl %edx, 80(%esp) + subl %ecx, %edx + jge ..B7.6 +..B7.15: + movl 40(%esp), %ebx +..B7.16: + movl 124(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B7.18 +..B7.17: + addl $140, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B7.18: + call __stack_chk_fail@PLT +..B7.19: + movl 88(%esp), %ebp + movl %ebp, %edx + xorl %eax, %eax + movl 84(%esp), %esi + subl %eax, %edx + movl %ecx, 60(%esp) + jl ..B7.35 +..B7.20: + movl %ebp, %ecx + shrl $26, %ecx + andl $30, %ecx + orl %ecx, %eax + je ..B7.22 +..B7.21: + movl $21932, %eax + shrl %cl, %eax + andl $3, %eax + incl %eax + jmp ..B7.25 +..B7.22: + movl %esi, %edx + movl %ebp, %eax + andl $-256, %edx + orl %edx, %eax + jne ..B7.24 +..B7.23: + movl %esi, %edx +..B7.24: + movl %edx, 32(%esp) + movl %ebp, %edx + movl %ebp, 36(%esp) + fildll 32(%esp) + shrl $31, %edx + movl 40(%esp), %eax + faddl .L_2il0floatpacket.1@GOTOFF(%eax,%edx,8) + fstpl 92(%esp) + movl 96(%esp), %eax + sarl $20, %eax + negl %eax + addl $1086, %eax +..B7.25: + cmpl $31, %eax + jbe ..B7.27 +..B7.26: + movl %eax, %ecx + movl %esi, %ebp + movl $0, 48(%esp) + shll %cl, %ebp + jmp ..B7.28 +..B7.27: + movl %eax, %ecx + shldl %cl, %esi, %ebp + shll %cl, %esi + movl %esi, 48(%esp) +..B7.28: + movl %eax, %ecx + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B7.30 +..B7.29: + movl %edi, %esi + movl $0, 44(%esp) + shrl %cl, %esi + jmp ..B7.31 +..B7.30: + movl %edi, %edx + movl %ebx, %esi + shrl %cl, %edx + shrdl %cl, %edi, %esi + movl %edx, 44(%esp) +..B7.31: + orl 48(%esp), %esi + orl 44(%esp), %ebp + movl %ebx, 52(%esp) + cmpl $31, %eax + jbe ..B7.33 +..B7.32: + movl %eax, %ecx + xorl %ebx, %ebx + movl 52(%esp), %edi + shll %cl, %edi + jmp ..B7.34 +..B7.33: + movl %eax, %ecx + shldl %cl, %ebx, %edi + shll %cl, %ebx +..B7.34: + addl %eax, 60(%esp) +..B7.35: + movl 192(%esp), %eax + movl %ebx, 16(%eax) + movl 56(%esp), %ebx + subl 60(%esp), %ebx + movl %esi, 8(%eax) + movl %ebp, 12(%eax) + movl %edi, 20(%eax) + movl %ebx, 4(%eax) + jmp ..B7.13 + .align 16,0x90 + .type __dpml_evaluate_packed_poly__,@function + .size __dpml_evaluate_packed_poly__,.-__dpml_evaluate_packed_poly__ + .data +# -- End __dpml_evaluate_packed_poly__ + .text +# -- Begin __dpml_addsub__ + .text + .align 16,0x90 + .hidden __dpml_addsub__ + .globl __dpml_addsub__ +__dpml_addsub__: +# parameter 1: %eax +# parameter 2: %edx +# parameter 3: 184 + %esp +# parameter 4: %ecx +..B8.1: +..L16: + + movl 4(%esp), %eax + movl 8(%esp), %edx + movl 20(%esp), %ecx + .hidden __dpml_addsub__. + .globl __dpml_addsub__. +__dpml_addsub__.: + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $156, %esp + movl %eax, %esi + movl %edx, %ebp + movl 188(%esp), %edx + movl 184(%esp), %edi + movl %edi, %ebx + movl %edx, 48(%esp) + movl %edi, %edx + movl %ecx, 132(%esp) + andl $4, %ebx + movl (%esi), %eax + shll $31, %edx + movl %gs:20, %ecx + xorl %esp, %ecx + movl %ecx, 144(%esp) + xorl %ecx, %ecx + movl %eax, 108(%esp) + xorl %edx, %eax + xorl (%ebp), %eax + orl %ecx, %ebx + je ..B8.3 +..B8.2: + movl $0, 108(%esp) + jmp ..B8.4 +..B8.3: + movl %eax, %edx +..B8.4: + movl 4(%esi), %ecx + movl %ecx, %eax + shrl $31, %edx + movl %edx, 124(%esp) + cltd + movl 4(%ebp), %eax + movl %edx, %ebx + cltd + movl %ecx, %eax + subl 4(%ebp), %eax + movl %ecx, 104(%esp) + sbbl %edx, %ebx + xorl %edx, %edx + movl %ebx, %ecx + movl $0, 112(%esp) + subl %edx, %ecx + movl 124(%esp), %edx + jl ..B8.6 +..B8.5: + movl $0, 92(%esp) + jmp ..B8.10 +..B8.6: + movl %esi, %ecx + movl %ebp, %esi + movl %ecx, %ebp + movl %eax, %ecx + xorl %eax, %eax + subl %ecx, %eax + movl %ebx, %ecx + movl $0, %ebx + sbbl %ecx, %ebx + movl %edx, %ecx + addl %eax, 104(%esp) + orl 112(%esp), %ecx + jne ..B8.8 +..B8.7: + xorl %ecx, %ecx + jmp ..B8.9 +..B8.8: + movl $-2147483648, %ecx +..B8.9: + xorl %ecx, 108(%esp) + movl $-2147483648, 92(%esp) +..B8.10: + movl 16(%ebp), %ecx + movl %ecx, 100(%esp) + movl 20(%ebp), %ecx + movl %ecx, 96(%esp) + movl 8(%ebp), %ecx + movl 12(%ebp), %ebp + movl %ecx, 120(%esp) + movl %ebp, 116(%esp) + movl $2, %ebp + movl $0, (%esp) + call ..L17 +..L17: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L17](%ecx), %ecx + movl %esi, 128(%esp) + movl %ecx, 8(%esp) + movl %edi, 40(%esp) + movl %ebp, 4(%esp) + movl %edx, 124(%esp) + movl (%esp), %esi + jmp ..B8.11 +..B8.13: + xorl %edx, %edx + movl %edx, 120(%esp) + movl %edx, 116(%esp) +..B8.11: + movl $64, %ebp + xorl %edi, %edi + xorl %edx, %edx + subl %eax, %ebp + sbbl %ebx, %edx + movl %edx, %ecx + subl %edi, %ecx + jl ..B8.12 +..B8.90: + orl %ebp, %ecx + jne ..B8.19 +..B8.12: + movl 116(%esp), %ebx + movl 120(%esp), %eax + movl %ebx, 96(%esp) + xorl %ebx, %ebx + movl %eax, 100(%esp) + xorl %eax, %eax + subl %ebp, %eax + sbbl %edx, %ebx + movl 4(%esp), %edx + addl $-1, %edx + movl %edx, 4(%esp) + adcl $-1, %esi + orl %esi, %edx + jne ..B8.13 +..B8.14: + movl 132(%esp), %eax + movl 128(%esp), %esi + movl 8(%esi), %ecx + movl 12(%esi), %ebx + movl 4(%esi), %edx + movl %ecx, 8(%eax) + movl %ebx, 12(%eax) + movl %edx, 4(%eax) + movl 16(%esi), %ebp + movl 20(%esi), %edx + movl 108(%esp), %ecx + movl 40(%esp), %edi + movl %ebp, 16(%eax) + andl $2, %edi + movl %edx, 20(%eax) + movl %ecx, (%eax) + xorl %eax, %eax + orl %eax, %edi + je ..B8.16 +..B8.15: + movl 132(%esp), %eax + movl 8(%esi), %ecx + movl 12(%esi), %ebx + movl %ecx, 32(%eax) + movl %ebx, 36(%eax) + movl 108(%esp), %edi + movl 4(%esi), %edx + movl 16(%esi), %ebp + movl 20(%esi), %esi + xorl 92(%esp), %edi + movl %edx, 28(%eax) + movl %ebp, 40(%eax) + movl %esi, 44(%eax) + movl %edi, 24(%eax) +..B8.16: + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B8.18 +..B8.17: + addl $156, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B8.18: + movl 8(%esp), %ebx + call __stack_chk_fail@PLT +..B8.19: + movl %ebp, 4(%esp) + orl %eax, %ebx + movl 40(%esp), %edi + movl 124(%esp), %edx + movl 128(%esp), %esi + je ..B8.30 +..B8.20: + cmpl $31, %eax + jbe ..B8.22 +..B8.21: + movl %eax, %ecx + xorl %ebx, %ebx + movl 96(%esp), %ebp + shrl %cl, %ebp + movl %ebp, 100(%esp) + jmp ..B8.23 +..B8.22: + movl %eax, %ecx + movl 100(%esp), %ebp + movl 96(%esp), %ebx + shrdl %cl, %ebx, %ebp + movl %ebp, 100(%esp) + shrl %cl, %ebx +..B8.23: + cmpl $31, 4(%esp) + jbe ..B8.25 +..B8.24: + movl 4(%esp), %ecx + movl 120(%esp), %ebp + shll %cl, %ebp + movl $0, (%esp) + movl %ebp, 96(%esp) + jmp ..B8.26 +..B8.25: + movl %edi, 40(%esp) + movl 4(%esp), %ecx + movl 116(%esp), %edi + movl 120(%esp), %ebp + shldl %cl, %ebp, %edi + movl %edi, 96(%esp) + shll %cl, %ebp + movl %ebp, (%esp) + movl 40(%esp), %edi +..B8.26: + movl (%esp), %ebp + orl %ebp, 100(%esp) + orl %ebx, 96(%esp) + movl 116(%esp), %ebx + cmpl $31, %eax + jbe ..B8.28 +..B8.27: + movl %eax, %ecx + shrl %cl, %ebx + movl $0, 116(%esp) + movl %ebx, 120(%esp) +..B8.30: + movl %edx, 124(%esp) + movl %esi, 128(%esp) + jmp ..B8.31 +..B8.28: + movl %eax, %ecx + movl 120(%esp), %ebp + shrdl %cl, %ebx, %ebp + shrl %cl, %ebx + movl %ebp, 120(%esp) + movl %ebx, 116(%esp) + jmp ..B8.30 +..B8.60: + movl 128(%esp), %esi + movl $1, %edx + movl 124(%esp), %eax + xorl %ecx, %ecx + subl %eax, %edx + movl 108(%esp), %ebp + movl 4(%esi), %eax + movl 112(%esp), %ebx + sbbl %ebx, %ecx + xorl 92(%esp), %ebp + xorl $2, %edi + addl $24, 132(%esp) + movl %edx, 124(%esp) + movl %ecx, 112(%esp) + movl %ebp, 108(%esp) + movl %eax, 104(%esp) +..B8.31: + movl 128(%esp), %edx + movl 124(%esp), %eax + orl 112(%esp), %eax + movl 16(%edx), %ebx + movl 20(%edx), %edx + jne ..B8.43 +..B8.32: + movl %ebx, %ebp + movl %edx, %ecx + addl 100(%esp), %ebp + movl %ebp, %eax + adcl 96(%esp), %ecx + andl $15, %edi + subl %ebx, %eax + movl %ecx, %ebx + movl $0, 48(%esp) + sbbl %edx, %ebx + jae ..B8.34 +..B8.33: + movl $1, 72(%esp) + jmp ..B8.35 +..B8.34: + movl $0, 72(%esp) +..B8.35: + movl 128(%esp), %esi + movl 72(%esp), %edx + movl 8(%esi), %ebx + movl %ebx, 52(%esp) + movl 120(%esp), %ebx + movl 12(%esi), %eax + addl %edx, %ebx + movl %eax, 80(%esp) + movl %ebx, %eax + movl 116(%esp), %esi + adcl $0, %esi + subl %edx, %eax + movl $0, %edx + movl %esi, %eax + sbbl %edx, %eax + jae ..B8.37 +..B8.36: + movl $1, 68(%esp) + jmp ..B8.38 +..B8.37: + movl $0, 68(%esp) +..B8.38: + movl 52(%esp), %eax + addl %eax, %ebx + movl %ebx, %edx + adcl 80(%esp), %esi + subl %eax, %edx + movl %esi, %eax + sbbl 80(%esp), %eax + jae ..B8.40 +..B8.39: + movl $1, %edx + jmp ..B8.41 +..B8.40: + xorl %edx, %edx +..B8.41: + movl 68(%esp), %eax + addl %edx, %eax + xorl %edx, %edx + orl %edx, %eax + je ..B8.57 +..B8.42: + movl %ecx, %eax + movl %ebx, %edx + shll $31, %eax + shrl $1, %ebp + orl %eax, %ebp + movl %esi, %eax + shrl $1, %ecx + shll $31, %edx + shll $31, %eax + orl %edx, %ecx + shrl $1, %esi + shrl $1, %ebx + orl $-2147483648, %esi + incl 104(%esp) + orl %eax, %ebx + jmp ..B8.57 +..B8.43: + addl $-8, %edi + movl 100(%esp), %ecx + adcl $-1, 48(%esp) + subl %ebx, %ecx + movl 96(%esp), %eax + sbbl %edx, %eax + jb ..B8.45 +..B8.91: + orl %eax, %ecx + je ..B8.45 +..B8.44: + movl $1, %eax + jmp ..B8.46 +..B8.45: + xorl %eax, %eax +..B8.46: + movl 128(%esp), %esi + movl %ebx, %ebp + subl 100(%esp), %ebp + movl %edx, %ecx + movl 116(%esp), %ebx + movl 8(%esi), %edx + movl %edx, 60(%esp) + movl 12(%esi), %edx + movl 120(%esp), %esi + sbbl 96(%esp), %ecx + addl %eax, %esi + movl %esi, 56(%esp) + adcl $0, %ebx + subl %eax, %esi + movl $0, %eax + movl %ebx, 76(%esp) + sbbl %eax, %ebx + jae ..B8.48 +..B8.47: + movl $1, 64(%esp) + jmp ..B8.49 +..B8.48: + movl $0, 64(%esp) +..B8.49: + movl 60(%esp), %eax + movl %eax, %ebx + subl 56(%esp), %ebx + movl %edx, %esi + sbbl 76(%esp), %esi + subl %ebx, %eax + sbbl %esi, %edx + jae ..B8.51 +..B8.50: + movl $1, %edx + jmp ..B8.52 +..B8.51: + xorl %edx, %edx +..B8.52: + movl 64(%esp), %eax + addl %edx, %eax + xorl %edx, %edx + orl %edx, %eax + je ..B8.57 +..B8.53: + xorl %eax, %eax + movl %ebp, %edx + xorl %ebp, %ebp + subl %edx, %ebp + movl %ecx, %edx + movl %eax, %ecx + movl %ebp, %eax + sbbl %edx, %ecx + xorl $-2147483648, 108(%esp) + orl %ecx, %eax + jne ..B8.55 +..B8.54: + movl $0, 44(%esp) + jmp ..B8.56 +..B8.55: + movl $-1, 44(%esp) +..B8.56: + movl 44(%esp), %eax + cltd + movl %ebx, %eax + movl 44(%esp), %ebx + subl %eax, %ebx + movl %esi, %eax + movl %edx, %esi + movl $-2147483648, 92(%esp) + sbbl %eax, %esi +..B8.57: + movl 132(%esp), %edx + movl 108(%esp), %eax + movl %eax, (%edx) + movl %edi, %edx + andl $16, %edx + xorl %eax, %eax + orl %eax, %edx + jne ..B8.61 +..B8.58: + movl 132(%esp), %edx + movl 104(%esp), %eax + movl %eax, 4(%edx) + movl %ebp, 16(%edx) + movl %ecx, 20(%edx) + movl %ebx, 8(%edx) + movl %esi, 12(%edx) +..B8.59: + movl %edi, %edx + xorl %eax, %eax + andl $2, %edx + orl %eax, %edx + jne ..B8.60 + jmp ..B8.66 +..B8.61: + movl %esi, %edx + movl %ebx, 84(%esp) + subl %eax, %edx + movl %esi, 88(%esp) + jl ..B8.58 +..B8.62: + movl $2, %edx + movl %ebp, 32(%esp) + movl %ecx, 36(%esp) + movl %eax, 28(%esp) + movl %ebx, 12(%esp) + movl %edi, 40(%esp) + movl %esi, 20(%esp) + movl %ecx, 24(%esp) + movl %ebp, 16(%esp) + movl 32(%esp), %esi + movl 36(%esp), %edi + movl %eax, %ebx + movl 28(%esp), %ecx + jmp ..B8.63 +..B8.65: + xorl %esi, %esi + xorl %edi, %edi +..B8.63: + movl 84(%esp), %ebp + orl 88(%esp), %ebp + jne ..B8.70 +..B8.64: + addl $64, %ecx + movl %esi, 84(%esp) + adcl $0, %ebx + addl $-1, %edx + movl %edx, %ebp + adcl $-1, %eax + movl %edi, 88(%esp) + orl %eax, %ebp + jne ..B8.65 + jmp ..B8.69 +..B8.66: + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B8.18 + jmp ..B8.17 +..B8.69: + movl 132(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ebp + movl 20(%esp), %esi + movl 24(%esp), %ecx + movl 40(%esp), %edi + movl %ebp, 16(%eax) + movl %ecx, 20(%eax) + movl %ebx, 8(%eax) + movl %esi, 12(%eax) + movl $-262144, 4(%eax) + jmp ..B8.59 +..B8.70: + xorl %eax, %eax + movl 88(%esp), %edx + movl %edi, 36(%esp) + subl %eax, %edx + movl %esi, 32(%esp) + movl %ecx, 28(%esp) + movl 40(%esp), %edi + jl ..B8.86 +..B8.71: + movl 88(%esp), %ecx + shrl $26, %ecx + andl $30, %ecx + orl %ecx, %eax + je ..B8.73 +..B8.72: + movl $21932, %edx + shrl %cl, %edx + andl $3, %edx + incl %edx + jmp ..B8.76 +..B8.73: + movl 84(%esp), %edx + andl $-256, %edx + movl 88(%esp), %eax + orl %edx, %eax + jne ..B8.75 +..B8.74: + movl 84(%esp), %edx +..B8.75: + movl 88(%esp), %eax + movl %edx, (%esp) + movl %eax, 4(%esp) + fildll (%esp) + shrl $31, %eax + movl 8(%esp), %edx + faddl .L_2il0floatpacket.1@GOTOFF(%edx,%eax,8) + fstpl 136(%esp) + movl 140(%esp), %edx + sarl $20, %edx + negl %edx + addl $1086, %edx +..B8.76: + cmpl $31, %edx + jbe ..B8.78 +..B8.77: + movl %edx, %ecx + xorl %eax, %eax + movl 84(%esp), %ebx + shll %cl, %ebx + movl %ebx, 88(%esp) + jmp ..B8.79 +..B8.78: + movl %edx, %ecx + movl 84(%esp), %eax + movl 88(%esp), %ebx + shldl %cl, %eax, %ebx + movl %ebx, 88(%esp) + shll %cl, %eax +..B8.79: + movl %edx, %ecx + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B8.81 +..B8.80: + movl 36(%esp), %ebx + xorl %ebp, %ebp + shrl %cl, %ebx + movl %ebx, 84(%esp) + jmp ..B8.82 +..B8.81: + movl %esi, %ebx + movl 36(%esp), %ebp + shrdl %cl, %ebp, %ebx + movl %ebx, 84(%esp) + shrl %cl, %ebp +..B8.82: + orl %eax, 84(%esp) + orl %ebp, 88(%esp) + movl %esi, %ebx + cmpl $31, %edx + jbe ..B8.84 +..B8.83: + movl %edx, %ecx + shll %cl, %ebx + movl $0, 32(%esp) + movl %ebx, 36(%esp) + jmp ..B8.85 +..B8.84: + movl %edx, %ecx + movl 36(%esp), %eax + shldl %cl, %ebx, %eax + shll %cl, %ebx + movl %eax, 36(%esp) + movl %ebx, 32(%esp) +..B8.85: + addl %edx, 28(%esp) +..B8.86: + movl 132(%esp), %esi + movl 104(%esp), %ebp + movl 84(%esp), %eax + movl 88(%esp), %edx + movl 32(%esp), %ecx + movl 36(%esp), %ebx + subl 28(%esp), %ebp + movl %eax, 8(%esi) + movl %edx, 12(%esi) + movl %ecx, 16(%esi) + movl %ebx, 20(%esi) + movl %ebp, 4(%esi) + jmp ..B8.59 + .align 16,0x90 + .type __dpml_addsub__,@function + .size __dpml_addsub__,.-__dpml_addsub__ + .data +# -- End __dpml_addsub__ + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x00000000,0x00000000,0x00000000,0x43f00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xe6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .align 4 + .globl __x_constants__ +__x_constants__: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1073610752 + .long 0 + .long 0 + .long 0 + .long 1073676288 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 3306619320 + .long 2221509004 + .long 3041149649 + .long 1073648159 + .long 3306619320 + .long 2221509004 + .long 3041149649 + .long 1073779231 + .long 2479964490 + .long 592389929 + .long 3354604061 + .long 1073753495 + .long 3306619320 + .long 2221509004 + .long 3041149649 + .long 1073713695 + .long 0 + .long 0 + .long 0 + .long 1074030592 + .long 0 + .long 0 + .long 0 + .long 1074096128 + .long 0 + .long 0 + .long 0 + .long 1074138624 + .long 0 + .long 0 + .long 0 + .long 1074161664 + .long 0 + .long 0 + .long 0 + .long 2147418112 + .type __x_constants__,@object + .size __x_constants__,208 + .data + .hidden __dpml_multiply__ + .hidden __dpml_exception + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/dpml_ux_ops_64.S b/external/sgx_libm/ia32/dpml_ux_ops_64.S new file mode 100644 index 0000000000..8b6fdba73d --- /dev/null +++ b/external/sgx_libm/ia32/dpml_ux_ops_64.S @@ -0,0 +1,4636 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_ops_64.c" + .text +..TXTST0: +# -- Begin __dpml_multiply__ + .text + .align 16,0x90 + .hidden __dpml_multiply__ + .globl __dpml_multiply__ +__dpml_multiply__: +# parameter 1: 64 + %esp +# parameter 2: 68 + %esp +# parameter 3: 72 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $44, %esp + movl 68(%esp), %edi + movl 64(%esp), %esi + movl 12(%edi), %ebx + movl %ebx, %edx + movl 12(%esi), %ebp + movl 8(%esi), %eax + movl 8(%edi), %ecx + movl %ebp, (%esp) + imull %ecx, %ebp + imull %eax, %edx + movl %eax, 4(%esp) + addl %edx, %ebp + mull %ecx + addl %ebp, %edx + movl %eax, %esi + movl %edx, 24(%esp) + movl %ecx, %eax + movl 64(%esp), %edx + movl 68(%esp), %ebp + movl 64(%esp), %edi + mull 16(%edx) + movl 16(%ebp), %ebp + movl %ecx, %eax + movl %ebp, 20(%esp) + movl 68(%esp), %ebp + movl 20(%edi), %edi + movl %ecx, 8(%esp) + movl 20(%ebp), %ebp + movl %ebp, 16(%esp) + movl %edx, %ebp + mull %edi + movl 64(%esp), %ecx + addl %eax, %ebp + movl %edi, 36(%esp) + movl %edx, %edi + adcl $0, %edi + movl 16(%ecx), %eax + mull %ebx + addl %ebp, %eax + movl %ebx, 12(%esp) + adcl %edi, %edx + subl %ebp, %eax + movl %edx, 28(%esp) + movl 24(%esp), %ebx + sbbl %edi, %edx + jae ..B1.3 +..B1.2: + movl $1, %ebp + jmp ..B1.4 +..B1.3: + xorl %ebp, %ebp +..B1.4: + movl 36(%esp), %eax + mull 12(%esp) + addl %edx, %ebp + addl 28(%esp), %eax + movl %eax, 32(%esp) + movl 64(%esp), %eax + adcl $0, %ebp + movl 68(%esp), %edi + movl 72(%esp), %ecx + movl (%eax), %edx + xorl (%edi), %edx + movl %edx, (%ecx) + movl 4(%eax), %edx + addl 4(%edi), %edx + movl 4(%esp), %eax + movl 20(%esp), %edi + movl %edx, 4(%ecx) + mull %edi + movl %edi, %eax + movl %edx, %ecx + mull (%esp) + addl %eax, %ecx + movl %edx, %edi + movl 4(%esp), %eax + adcl $0, %edi + mull 16(%esp) + addl %ecx, %eax + adcl %edi, %edx + subl %ecx, %eax + movl %edx, 24(%esp) + sbbl %edi, %edx + jae ..B1.6 +..B1.5: + movl $1, %ecx + jmp ..B1.7 +..B1.6: + xorl %ecx, %ecx +..B1.7: + movl 16(%esp), %eax + mull (%esp) + addl %edx, %ecx + addl 24(%esp), %eax + movl 32(%esp), %edi + adcl $0, %ecx + addl %edi, %esi + movl %eax, 20(%esp) + movl %esi, %eax + adcl %ebp, %ebx + subl %edi, %eax + movl %ebx, %edx + sbbl %ebp, %edx + jae ..B1.9 +..B1.8: + movl $1, 24(%esp) + jmp ..B1.10 +..B1.9: + movl $0, 24(%esp) +..B1.10: + movl 8(%esp), %edi + movl %edi, %eax + mull 4(%esp) + movl %edi, %eax + movl %edx, %ebp + mull (%esp) + addl %eax, %ebp + movl %edx, %edi + movl 4(%esp), %eax + adcl $0, %edi + mull 12(%esp) + addl %ebp, %eax + adcl %edi, %edx + subl %ebp, %eax + movl %edx, 16(%esp) + sbbl %edi, %edx + jae ..B1.12 +..B1.11: + movl $1, %ebp + jmp ..B1.13 +..B1.12: + xorl %ebp, %ebp +..B1.13: + movl (%esp), %eax + mull 12(%esp) + addl %edx, %ebp + addl 16(%esp), %eax + movl 20(%esp), %edi + adcl $0, %ebp + addl %edi, %esi + movl %esi, %edx + adcl %ecx, %ebx + subl %edi, %edx + movl %ebx, %edi + sbbl %ecx, %edi + jae ..B1.15 +..B1.14: + movl $1, %edx + jmp ..B1.16 +..B1.15: + xorl %edx, %edx +..B1.16: + movl 24(%esp), %ecx + addl %edx, %ecx + movl 72(%esp), %edx + addl %ecx, %eax + adcl $0, %ebp + movl %esi, 16(%edx) + movl %ebx, 20(%edx) + movl %eax, 8(%edx) + movl %ebp, 12(%edx) + addl $44, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret + .align 16,0x90 + .type __dpml_multiply__,@function + .size __dpml_multiply__,.-__dpml_multiply__ + .data +# -- End __dpml_multiply__ + .text +# -- Begin __dpml_extended_multiply__ + .text + .align 16,0x90 + .hidden __dpml_extended_multiply__ + .globl __dpml_extended_multiply__ +__dpml_extended_multiply__: +# parameter 1: 80 + %esp +# parameter 2: 84 + %esp +# parameter 3: 88 + %esp +# parameter 4: 92 + %esp +..B2.1: +..L2: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $60, %esp + movl 80(%esp), %esi + movl 84(%esp), %edi + movl 20(%esi), %ebx + movl 20(%edi), %edx + movl 16(%edi), %ecx + movl 16(%esi), %ebp + movl %ebp, %eax + movl %ebx, 24(%esp) + movl %edx, 16(%esp) + imull %ecx, %ebx + imull %ebp, %edx + addl %edx, %ebx + mull %ecx + movl %eax, 36(%esp) + movl %ecx, %eax + addl %ebx, %edx + movl %edx, 40(%esp) + mull %ebp + movl 8(%esi), %ebx + movl %ecx, %eax + movl 12(%esi), %esi + movl %esi, (%esp) + movl 8(%edi), %esi + movl %esi, 12(%esp) + movl 12(%edi), %esi + movl %edx, %edi + mull 24(%esp) + addl %eax, %edi + movl %ebp, %eax + movl %esi, 4(%esp) + movl %edx, %esi + adcl $0, %esi + mull 16(%esp) + addl %edi, %eax + movl %ebx, 8(%esp) + movl %edx, %ebx + adcl %esi, %ebx + subl %edi, %eax + movl %ecx, 20(%esp) + movl %ebx, %ecx + sbbl %esi, %ecx + jae ..B2.3 +..B2.2: + movl $1, %ecx + jmp ..B2.4 +..B2.3: + xorl %ecx, %ecx +..B2.4: + movl 24(%esp), %eax + movl 16(%esp), %edi + mull %edi + addl %edx, %ecx + addl %ebx, %eax + movl 92(%esp), %esi + movl %edi, %ebx + adcl $0, %ecx + movl %ebp, 44(%esp) + movl %ecx, 52(%esp) + movl 36(%esp), %ebp + movl 40(%esp), %ecx + movl %ebp, 16(%esi) + movl %ecx, 20(%esi) + movl 80(%esp), %ebp + movl 84(%esp), %esi + movl %eax, 48(%esp) + movl 4(%ebp), %edx + movl 4(%esi), %eax + movl (%ebp), %ecx + xorl (%esi), %ecx + lea -128(%edx,%eax), %esi + movl %esi, 56(%esp) + movl (%esp), %esi + lea (%edx,%eax), %ebp + movl 8(%esp), %edx + movl 20(%esp), %eax + imull %edx, %ebx + imull %eax, %esi + mull %edx + addl %esi, %ebx + movl %edx, %edi + addl %ebx, %edi + movl %eax, %esi + movl 88(%esp), %ebx + movl 12(%esp), %edx + movl 4(%esp), %eax + movl %ecx, (%ebx) + movl %ebp, 4(%ebx) + movl 24(%esp), %ebx + movl 44(%esp), %ebp + imull %edx, %ebx + imull %ebp, %eax + addl %eax, %ebx + movl %ebp, %eax + mull %edx + addl %ebx, %edx + movl 92(%esp), %ebx + movl %edx, 32(%esp) + movl %eax, 28(%esp) + movl %ecx, (%ebx) + movl 56(%esp), %ecx + movl %ecx, 4(%ebx) + movl 48(%esp), %ebx + addl %esi, %ebx + movl %ebx, %edx + movl 52(%esp), %ecx + adcl %edi, %ecx + subl %esi, %edx + movl %ecx, %esi + sbbl %edi, %esi + jae ..B2.6 +..B2.5: + movl $1, %esi + jmp ..B2.7 +..B2.6: + xorl %esi, %esi +..B2.7: + movl %esi, 44(%esp) + movl (%esp), %edi + movl 12(%esp), %esi + movl 4(%esp), %edx + movl 8(%esp), %eax + imull %esi, %edi + imull %eax, %edx + addl %edx, %edi + mull %esi + movl 28(%esp), %esi + addl %edi, %edx + addl %esi, %ebx + movl %edx, 40(%esp) + movl %ebx, %edx + movl 32(%esp), %edi + adcl %edi, %ecx + subl %esi, %edx + movl %ecx, %edx + movl 44(%esp), %esi + sbbl %edi, %edx + movl %eax, 36(%esp) + jae ..B2.9 +..B2.8: + movl $1, %edx + jmp ..B2.10 +..B2.9: + xorl %edx, %edx +..B2.10: + addl %edx, %esi + movl %ebp, %eax + movl 92(%esp), %edx + movl %ecx, 12(%edx) + movl 12(%esp), %ecx + movl %ebx, 8(%edx) + mull %ecx + movl %ecx, %eax + movl %edx, %edi + mull 24(%esp) + addl %eax, %edi + movl %ebp, %eax + movl %edx, %ebx + adcl $0, %ebx + mull 4(%esp) + addl %edi, %eax + movl %edx, %ecx + adcl %ebx, %ecx + subl %edi, %eax + movl %ecx, %ebp + sbbl %ebx, %ebp + jae ..B2.12 +..B2.11: + movl $1, %edi + jmp ..B2.13 +..B2.12: + xorl %edi, %edi +..B2.13: + movl 24(%esp), %eax + mull 4(%esp) + addl %edx, %edi + addl %ecx, %eax + movl 36(%esp), %ebx + adcl $0, %edi + addl %ebx, %esi + movl %eax, 28(%esp) + movl %esi, %ebp + movl 40(%esp), %eax + movl %eax, %ecx + adcl $0, %ecx + subl %ebx, %ebp + movl %ecx, %edx + sbbl %eax, %edx + jae ..B2.15 +..B2.14: + movl $1, %ebp + jmp ..B2.16 +..B2.15: + xorl %ebp, %ebp +..B2.16: + movl 20(%esp), %ebx + movl %ebx, %eax + mull 8(%esp) + movl %ebx, %eax + movl %ecx, 32(%esp) + movl %edx, %ecx + mull (%esp) + addl %eax, %ecx + movl %edx, %ebx + movl 8(%esp), %eax + adcl $0, %ebx + mull 16(%esp) + addl %ecx, %eax + adcl %ebx, %edx + subl %ecx, %eax + movl %edx, 24(%esp) + movl 32(%esp), %ecx + sbbl %ebx, %edx + jae ..B2.18 +..B2.17: + movl $1, %ebx + jmp ..B2.19 +..B2.18: + xorl %ebx, %ebx +..B2.19: + movl 16(%esp), %eax + mull (%esp) + addl %edx, %ebx + addl 24(%esp), %eax + movl %eax, 20(%esp) + movl 28(%esp), %eax + adcl $0, %ebx + addl %eax, %esi + movl %esi, %edx + adcl %edi, %ecx + subl %eax, %edx + movl %ecx, %eax + sbbl %edi, %eax + jae ..B2.21 +..B2.20: + movl $1, %eax + jmp ..B2.22 +..B2.21: + xorl %eax, %eax +..B2.22: + movl 12(%esp), %edi + addl %eax, %ebp + movl %edi, %eax + mull 8(%esp) + movl %edi, %eax + movl %ebp, 24(%esp) + movl %edx, %ebp + mull (%esp) + addl %eax, %ebp + movl %edx, %edi + movl 8(%esp), %eax + adcl $0, %edi + mull 4(%esp) + addl %ebp, %eax + adcl %edi, %edx + subl %ebp, %eax + movl %edx, 16(%esp) + movl 24(%esp), %ebp + sbbl %edi, %edx + jae ..B2.24 +..B2.23: + movl $1, %edi + jmp ..B2.25 +..B2.24: + xorl %edi, %edi +..B2.25: + movl (%esp), %eax + mull 4(%esp) + addl %edx, %edi + addl 16(%esp), %eax + movl %eax, 8(%esp) + movl 20(%esp), %eax + adcl $0, %edi + addl %eax, %esi + movl %esi, %edx + adcl %ebx, %ecx + subl %eax, %edx + movl %ecx, %eax + sbbl %ebx, %eax + jae ..B2.27 +..B2.26: + movl $1, %eax + jmp ..B2.28 +..B2.27: + xorl %eax, %eax +..B2.28: + addl %eax, %ebp + movl 88(%esp), %eax + movl %ecx, 20(%eax) + movl 8(%esp), %ecx + addl %ebp, %ecx + movl %esi, 16(%eax) + adcl $0, %edi + movl %ecx, 8(%eax) + movl %edi, 12(%eax) + addl $60, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret + .align 16,0x90 + .type __dpml_extended_multiply__,@function + .size __dpml_extended_multiply__,.-__dpml_extended_multiply__ + .data +# -- End __dpml_extended_multiply__ + .text +# -- Begin __dpml_divide__ + .text + .align 16,0x90 + .hidden __dpml_divide__ + .globl __dpml_divide__ +__dpml_divide__: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +# parameter 4: 24 + %ebp +..B3.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $148, %esp + call ..L4 +..L4: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ecx), %ecx + movl 12(%ebp), %edi + testl %edi, %edi + movl 8(%ebp), %ebx + movl %ecx, 92(%esp) + lea __ux_one__@GOTOFF(%ecx), %edx + jne ..L5 + movl %edx, %edi +..L5: + testl %ebx, %ebx + movl %gs:20, %eax + jne ..L6 + movl %edx, %ebx +..L6: + xorl %esp, %eax + movl %eax, 140(%esp) + cmpl %edx, %edi + movl 16(%edi), %esi + movl 8(%edi), %eax + movl 12(%edi), %ecx + movl %esi, 104(%esp) + movl %ebx, 108(%esp) + movl %eax, 96(%esp) + movl %ecx, 100(%esp) + movl 20(%edi), %esi + je ..B3.69 +..B3.2: + xorl %edx, %edx + subl %edx, %ecx + jl ..B3.5 +..B3.3: + addl $12, %esp + pushl %edx + pushl %edx + pushl %edi + call __dpml_ffs_and_shift__ +..B3.4: + movl 8(%edi), %eax + movl 12(%edi), %edx + movl 16(%edi), %ecx + movl 20(%edi), %esi + movl %eax, 96(%esp) + movl %edx, 100(%esp) + movl %ecx, 104(%esp) +..B3.5: + addl $4, %esp + lea 108(%esp), %edx + pushl %edx + movl -20(%edx), %ebx + call fegetenv@PLT +..B3.6: + movl %esi, 56(%esp) + movl 100(%esp), %esi + movl %esi, %eax + movl 96(%esp), %ecx + movl %ecx, %edx + movl %edi, 28(%esp) + movl %esi, %edi + shll $31, %eax + shrl $1, %edx + shrl $1, %edi + orl %edx, %eax + movl %eax, 32(%esp) + movl %esi, %eax + movl %edi, 36(%esp) + andl $-64, %eax + fildll 32(%esp) + andl $63, %esi + fstpl 48(%esp) + xorl %edx, %edx + fldl 48(%esp) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fdiv %st, %st(1) + shrl $1, %eax + movl %eax, 36(%esp) + movl %ecx, %eax + movl 108(%esp), %edi + shrl $17, %eax + shll $15, %esi + movl %edx, 32(%esp) + orl %esi, %eax + movl 56(%esp), %esi + shll $15, %ecx + shrl $17, %esi + orl %esi, %ecx + movl 12(%edi), %esi + movl %esi, 80(%esp) + fxch %st(1) + fstpl 48(%esp) + fldl 48(%esp) + movl (%edi), %esi + fld %st(0) + fildll 32(%esp) + movl %eax, 36(%esp) + movl %ecx, 32(%esp) + movl 8(%edi), %eax + movl 16(%edi), %ecx + movl %eax, 84(%esp) + movl %ecx, 72(%esp) + movl 20(%edi), %eax + movl 28(%esp), %ecx + movl %eax, 76(%esp) + movl 24(%ebp), %eax + xorl (%ecx), %esi + fstpl 48(%esp) + fldl 48(%esp) + fildll 32(%esp) + movl %esi, (%eax) + fstpl 48(%esp) + fxch %st(1) + fnstcw 16(%esp) + movzwl 16(%esp), %eax + orl $3072, %eax + movl %eax, 24(%esp) + fldcw 24(%esp) + fistpll 40(%esp) + fldcw 16(%esp) + movl %edx, 32(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fldl 48(%esp) + movl 40(%esp), %eax + addl $-1280, %eax + movl 44(%esp), %esi + adcl $-1, %esi + fmul %st(1), %st + andl $-16, %esi + movl %esi, 36(%esp) + fstpl 48(%esp) + fldl 48(%esp) + fildll 32(%esp) + fstpl 48(%esp) + fldl 48(%esp) + fmul %st, %st(3) + movl 4(%edi), %edi + fxch %st(3) + fsubrp %st, %st(5) + fmul %st(2), %st + movl %esi, 88(%esp) + fsubrp %st, %st(4) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + movl 80(%esp), %eax + movl %eax, %ebx + movl 84(%esp), %esi + subl 4(%ecx), %edi + movl %esi, %ecx + shll $21, %ebx + shrl $11, %ecx + fmulp %st, %st(3) + orl %ecx, %ebx + movl %edi, 60(%esp) + movl %eax, %edi + shrl $1, %edi + movl %ebx, %ecx + shrl $22, %ecx + andl $-1024, %edi + shll $10, %ebx + orl %edi, %ecx + movl %ebx, 32(%esp) + movl %eax, %ebx + movl %ecx, 36(%esp) + andl $-64, %ebx + fxch %st(2) + fmulp %st, %st(3) + andl $63, %eax + shrl $1, %ebx + movl 76(%esp), %ecx + shll $15, %eax + shrl $17, %ecx + fxch %st(2) + fstpl 48(%esp) + fldl 48(%esp) + fildll 32(%esp) + movl %edx, 32(%esp) + movl %esi, %edx + movl %ebx, 36(%esp) + shrl $17, %edx + shll $15, %esi + orl %eax, %edx + orl %ecx, %esi + fstpl 48(%esp) + fldl 48(%esp) + movl 92(%esp), %eax + fmul %st(1), %st + fildll 32(%esp) + movl %esi, 32(%esp) + movl %edx, 36(%esp) + fstpl 48(%esp) + fldl 48(%esp) + fildll 32(%esp) + fstpl 48(%esp) + fldl 48(%esp) + fmulp %st, %st(4) + fxch %st(3) + fstpl 48(%esp) + fldl 48(%esp) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + fmulp %st, %st(5) + fxch %st(4) + fstpl 48(%esp) + fldl 48(%esp) + fmul %st, %st(3) + fxch %st(3) + fstpl 48(%esp) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldl 48(%esp) + fxch %st(2) + fstpl 48(%esp) + fldl 48(%esp) + fldt .L_2il0floatpacket.4@GOTOFF(%eax) + fmulp %st, %st(3) + fxch %st(2) + fnstcw 16(%esp) + movzwl 16(%esp), %eax + orl $3072, %eax + movl %eax, 24(%esp) + fldcw 24(%esp) + fistpll 40(%esp) + fldcw 16(%esp) + movl 40(%esp), %ebx + movl %ebx, %edx + movl 44(%esp), %ecx + movl %ecx, %edi + fxch %st(1) + fnstcw 16(%esp) + movzwl 16(%esp), %eax + orl $3072, %eax + movl %eax, 24(%esp) + fldcw 24(%esp) + fistpll 40(%esp) + fldcw 16(%esp) + shrl $30, %edx + shll $2, %ebx + shll $2, %ecx + movl 40(%esp), %esi + orl %ecx, %edx + addl %esi, %ebx + movl %ebx, %ecx + movl 44(%esp), %eax + adcl %eax, %edx + shrl $30, %edi + subl %esi, %ecx + movl %edx, 64(%esp) + movl %edi, 68(%esp) + sbbl %eax, %edx + movl 56(%esp), %esi + movl 88(%esp), %edx + jae ..B3.8 +..B3.7: + movl $1, %ecx + jmp ..B3.9 +..B3.8: + xorl %ecx, %ecx +..B3.9: + addl %ecx, 68(%esp) + movl $1, %ecx + movl 16(%ebp), %edi + subl %ecx, %edi + orl 20(%ebp), %edi + jne ..B3.11 +..B3.10: + fstp %st(0) + xorl %eax, %eax + xorl %edx, %edx + jmp ..B3.59 +..B3.11: + movl 92(%esp), %ecx + fldt .L_2il0floatpacket.5@GOTOFF(%ecx) + fmulp %st, %st(1) + fnstcw 16(%esp) + movzwl 16(%esp), %eax + orl $3072, %eax + movl %eax, 24(%esp) + fldcw 24(%esp) + fistpll 40(%esp) + fldcw 16(%esp) + movl 44(%esp), %edi + movl 40(%esp), %ecx + movl %ecx, 28(%esp) + lea (%edi,%edx,4), %edx + movl %edx, 32(%esp) + orl %edx, %ecx + jne ..B3.13 +..B3.12: + movl $-1, %edx + movl %edx, 28(%esp) + movl %edx, 32(%esp) +..B3.13: + movl %ebx, %eax + xorl %edi, %edi + mull 104(%esp) + xorl %ecx, %ecx + movl %ebx, %eax + subl 68(%esp), %ecx + movl %ecx, 16(%esp) + movl %edx, %ecx + sbbl $0, %edi + mull %esi + addl %eax, %ecx + movl 104(%esp), %eax + movl %edi, 52(%esp) + movl %edx, %edi + adcl $0, %edi + mull 64(%esp) + addl %ecx, %eax + adcl %edi, %edx + subl %ecx, %eax + movl %edx, 20(%esp) + movl 52(%esp), %ecx + sbbl %edi, %edx + jae ..B3.15 +..B3.14: + movl $1, 48(%esp) + jmp ..B3.16 +..B3.15: + movl $0, 48(%esp) +..B3.16: + movl %esi, %eax + movl %esi, 56(%esp) + movl 64(%esp), %esi + mull %esi + movl %ecx, 52(%esp) + movl 48(%esp), %ecx + addl %edx, %ecx + movl %esi, %edx + addl 20(%esp), %eax + movl 96(%esp), %esi + adcl $0, %ecx + movl %ecx, 48(%esp) + movl 100(%esp), %ecx + movl %ecx, %edi + imull %ebx, %edi + imull %esi, %edx + movl %eax, 44(%esp) + movl %esi, %eax + addl %edx, %edi + mull %ebx + movl %eax, 24(%esp) + movl %ebx, %eax + addl %edi, %edx + movl %edx, 36(%esp) + mull %esi + movl %ebx, %eax + movl %edx, %edi + mull %ecx + addl %eax, %edi + movl %esi, %eax + movl %edx, %ecx + adcl $0, %ecx + mull 64(%esp) + addl %edi, %eax + movl 56(%esp), %esi + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 40(%esp) + sbbl %ecx, %edx + movl 52(%esp), %ecx + jae ..B3.18 +..B3.17: + movl $1, %edi + jmp ..B3.19 +..B3.18: + xorl %edi, %edi +..B3.19: + movl %ebx, 20(%esp) + andl %ecx, %esi + movl 100(%esp), %ebx + movl %ebx, %eax + mull 64(%esp) + addl %edx, %edi + andl %ebx, %ecx + addl 40(%esp), %eax + movl %eax, 56(%esp) + movl 104(%esp), %edx + adcl $0, %edi + movl 16(%esp), %eax + andl %eax, %edx + movl 44(%esp), %ebx + andl 96(%esp), %eax + addl %ebx, %edx + movl %eax, 16(%esp) + movl 48(%esp), %eax + adcl %eax, %esi + movl %edx, 104(%esp) + subl %ebx, %edx + movl %esi, %ebx + sbbl %eax, %ebx + movl 20(%esp), %ebx + jae ..B3.21 +..B3.20: + movl $1, %edx + jmp ..B3.22 +..B3.21: + xorl %edx, %edx +..B3.22: + movl %ecx, 52(%esp) + movl 24(%esp), %ecx + movl 104(%esp), %eax + addl %ecx, %eax + movl %ebx, 20(%esp) + movl 36(%esp), %ebx + adcl %ebx, %esi + movl %eax, 104(%esp) + subl %ecx, %eax + movl %esi, %ecx + sbbl %ebx, %ecx + movl 20(%esp), %ebx + movl 52(%esp), %ecx + jae ..B3.24 +..B3.23: + movl $1, %eax + jmp ..B3.25 +..B3.24: + xorl %eax, %eax +..B3.25: + addl %eax, %edx + movl %edx, 24(%esp) + movl 56(%esp), %edx + movl 16(%esp), %eax + addl %edx, %eax + movl %eax, 16(%esp) + adcl %edi, %ecx + subl %edx, %eax + movl %ecx, %edx + sbbl %edi, %edx + movl 24(%esp), %edx + jae ..B3.27 +..B3.26: + movl $1, 24(%esp) + jmp ..B3.28 +..B3.27: + movl $0, 24(%esp) +..B3.28: + movl 16(%esp), %edi + addl %edx, %edi + movl %edi, 16(%esp) + adcl $0, %ecx + subl %edx, %edi + movl $0, %edx + movl %ecx, %edi + sbbl %edx, %edi + jae ..B3.30 +..B3.29: + movl $1, %edi + jmp ..B3.31 +..B3.30: + xorl %edi, %edi +..B3.31: + xorl %eax, %eax + movl 24(%esp), %edx + addl %edi, %edx + xorl %edi, %edi + subl %edx, %edi + movl %eax, %edx + movl 72(%esp), %eax + sbbl $0, %edx + subl 104(%esp), %eax + movl 76(%esp), %eax + sbbl %esi, %eax + jae ..B3.33 +..B3.32: + movl $1, 40(%esp) + jmp ..B3.34 +..B3.33: + movl $0, 40(%esp) +..B3.34: + movl 72(%esp), %eax + subl 104(%esp), %eax + movl %eax, 36(%esp) + movl 76(%esp), %eax + sbbl %esi, %eax + movl 84(%esp), %esi + subl 16(%esp), %esi + movl 80(%esp), %esi + movl %eax, 24(%esp) + sbbl %ecx, %esi + jae ..B3.36 +..B3.35: + movl $1, %esi + jmp ..B3.37 +..B3.36: + xorl %esi, %esi +..B3.37: + subl %esi, %edi + movl 84(%esp), %esi + sbbl $0, %edx + subl 16(%esp), %esi + movl 80(%esp), %eax + movl %esi, 44(%esp) + sbbl %ecx, %eax + xorl %ecx, %ecx + subl 40(%esp), %esi + movl %eax, %esi + sbbl %ecx, %esi + jae ..B3.40 +..B3.38: + movl $1, %ecx +..B3.40: + subl %ecx, %edi + movl 44(%esp), %ecx + sbbl $0, %edx + subl 40(%esp), %ecx + sbbl $0, %eax + orl %eax, %ecx + je ..B3.42 +..B3.41: + movl $1, %esi + jmp ..B3.43 +..B3.42: + xorl %esi, %esi +..B3.43: + orl %edi, %esi + movl %esi, %ecx + movl %edx, 40(%esp) + orl %edx, %ecx + jne ..B3.46 +..B3.44: + movl 96(%esp), %edi + movl 100(%esp), %edx +..B3.46: + movl 96(%esp), %ecx + xorl %edi, %ecx + movl 100(%esp), %eax + movl 36(%esp), %edi + xorl %edx, %eax + subl %ecx, %edi + movl %ebx, 20(%esp) + movl 24(%esp), %ebx + sbbl %eax, %ebx + movl 28(%esp), %eax + mull %edi + movl 28(%esp), %eax + movl %edx, %ecx + mull %ebx + addl %eax, %ecx + movl %edi, %eax + movl %ebx, 24(%esp) + movl %edx, %ebx + adcl $0, %ebx + mull 32(%esp) + addl %ecx, %eax + adcl %ebx, %edx + subl %ecx, %eax + movl %edx, 16(%esp) + sbbl %ebx, %edx + movl 20(%esp), %ebx + jae ..B3.48 +..B3.47: + movl $1, %ecx + jmp ..B3.49 +..B3.48: + xorl %ecx, %ecx +..B3.49: + movl 24(%esp), %eax + xorl %edi, %edi + mull 32(%esp) + addl %edx, %ecx + addl 16(%esp), %eax + adcl $0, %ecx + movl %ecx, %edx + subl %edi, %edx + jl ..B3.51 +..B3.50: + xorl %edx, %edx + jmp ..B3.52 +..B3.51: + movl $1, %edx +..B3.52: + movl 84(%esp), %edi + addl %edx, %esi + movl 80(%esp), %edx + adcl $0, 40(%esp) + orl 72(%esp), %edi + orl 76(%esp), %edx + orl %edx, %edi + je ..B3.54 +..B3.53: + movl $1, %edi + jmp ..B3.55 +..B3.54: + xorl %edi, %edi +..B3.55: + movl %eax, %edx + addl %eax, %eax + shrl $31, %edx + addl %ecx, %ecx + orl %ecx, %edx + addl %edi, %eax + movl 40(%esp), %ecx + adcl $0, %edx + addl %esi, %ebx + movl %ebx, %edi + adcl %ecx, 64(%esp) + subl %esi, %edi + movl 64(%esp), %esi + sbbl %ecx, %esi + jae ..B3.57 +..B3.56: + movl $1, %ecx + jmp ..B3.58 +..B3.57: + xorl %ecx, %ecx +..B3.58: + movl 40(%esp), %esi + sarl $31, %esi + movl 68(%esp), %edi + addl %esi, %edi + addl %ecx, %edi + movl %edi, 68(%esp) +..B3.59: + movl 68(%esp), %ecx + movl %ecx, %esi + shll $31, %esi + cmpl $31, %ecx + jbe ..B3.61 +..B3.60: + movl 64(%esp), %edi + shrl %cl, %edi + movl $0, 20(%esp) + movl %edi, 24(%esp) + jmp ..B3.62 +..B3.61: + movl %ebx, %edi + movl %eax, 16(%esp) + movl 64(%esp), %eax + shrdl %cl, %eax, %edi + shrl %cl, %eax + movl %eax, 20(%esp) + movl %edi, 24(%esp) + movl 16(%esp), %eax +..B3.62: + movl 24(%ebp), %edi + orl 20(%esp), %esi + movl 24(%esp), %ecx + movl %esi, 12(%edi) + movl 68(%esp), %esi + andl %esi, %ebx + shll $31, %ebx + movl %ecx, 8(%edi) + cmpl $31, %esi + jbe ..B3.64 +..B3.63: + movl %edx, %eax + xorl %esi, %esi + movl 68(%esp), %ecx + shrl %cl, %eax + jmp ..B3.65 +..B3.64: + movl %edx, %esi + movl 68(%esp), %ecx + shrdl %cl, %edx, %eax + shrl %cl, %esi +..B3.65: + addl $4, %esp + orl %esi, %ebx + movl 24(%ebp), %ecx + lea 108(%esp), %edx + pushl %edx + movl %eax, 16(%ecx) + movl -52(%edx), %eax + addl -44(%edx), %eax + movl %ebx, 20(%ecx) + movl -20(%edx), %ebx + movl %eax, 4(%ecx) + call fesetenv@PLT +..B3.66: + movl 140(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B3.68 +..B3.67: + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B3.68: + call __stack_chk_fail@PLT +..B3.69: + movl %ebx, %eax + movl 24(%ebp), %edx + movl 8(%eax), %esi + movl 12(%eax), %edi + movl (%eax), %ecx + movl %esi, 8(%edx) + movl %edi, 12(%edx) + movl %ecx, (%edx) + movl 4(%eax), %ebx + movl 16(%eax), %ecx + movl 20(%eax), %eax + movl %ebx, 4(%edx) + movl %ecx, 16(%edx) + movl %eax, 20(%edx) + movl 140(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + je ..B3.67 +..B3.71: + movl 92(%esp), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type __dpml_divide__,@function + .size __dpml_divide__,.-__dpml_divide__ + .data +# -- End __dpml_divide__ + .text +# -- Begin __dpml_evaluate_rational__ + .text + .align 16,0x90 + .hidden __dpml_evaluate_rational__ + .globl __dpml_evaluate_rational__ +__dpml_evaluate_rational__: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +# parameter 4: 24 + %ebp +# parameter 5: 32 + %ebp +..B4.1: +..L7: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $196, %esp + movl 12(%ebp), %eax + movl %eax, 96(%esp) + xorl %eax, %eax + movl 8(%ebp), %ecx + movl %gs:20, %edx + movl 24(%ebp), %esi + xorl %esp, %edx + movl %edx, 180(%esp) + movl %esi, %edx + movl 28(%ebp), %edi + andl $68, %edx + sarl $26, %edi + addl 4(%ecx), %edi + movl %esi, 104(%esp) + orl %eax, %edx + movl %edi, 4(%ecx) + jne ..B4.3 +..B4.2: + movl 8(%ebp), %ebx + movl $136, %edx + cmpl $0, (%ebx) + jne ..L8 + movl $0, %edx +..L8: + xorl %esi, %edx + movl %edx, 104(%esp) + jmp ..B4.19 +..B4.3: + movl %edi, 56(%esp) + movl 8(%ebp), %edi + movl %esi, 88(%esp) + movl 12(%edi), %esi + movl %esi, %ebx + movl 8(%edi), %ecx + movl %ecx, %eax + imull %ecx, %ebx + mull %ecx + addl %ebx, %ebx + addl %ebx, %edx + movl 16(%edi), %ebx + movl %eax, 36(%esp) + movl %ebx, %eax + movl %edx, 40(%esp) + mull %ecx + movl 20(%edi), %edi + movl %edi, 48(%esp) + movl %edx, %edi + movl 48(%esp), %eax + mull %ecx + addl %eax, %edi + movl %esi, %eax + movl %ecx, 44(%esp) + movl %edx, %ecx + adcl $0, %ecx + mull %ebx + addl %edi, %eax + movl %esi, 32(%esp) + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 52(%esp) + movl %ebx, 64(%esp) + lea 156(%esp), %ebx + movl -68(%ebx), %esi + sbbl %ecx, %edx + movl -100(%ebx), %edi + jae ..B4.5 +..B4.4: + movl $1, %ecx + jmp ..B4.6 +..B4.5: + xorl %ecx, %ecx +..B4.6: + movl %ebx, 72(%esp) + addl %edi, %edi + movl 32(%esp), %eax + movl 48(%esp), %ebx + mull %ebx + addl %edx, %ecx + addl 52(%esp), %eax + movl %eax, 60(%esp) + adcl $0, %ecx + movl %ecx, 68(%esp) + movl 64(%esp), %ecx + movl %ecx, %eax + movl %edi, 160(%esp) + movl 44(%esp), %edi + mull %edi + movl 32(%esp), %eax + movl %esi, 88(%esp) + movl %edx, %esi + mull %ecx + addl %eax, %esi + movl %ebx, %eax + movl %edx, %ecx + adcl $0, %ecx + mull %edi + addl %esi, %eax + movl $0, 156(%esp) + adcl %ecx, %edx + subl %esi, %eax + movl %edx, 56(%esp) + movl 88(%esp), %esi + sbbl %ecx, %edx + movl 72(%esp), %ebx + movl 68(%esp), %ecx + jae ..B4.8 +..B4.7: + movl $1, %edi + jmp ..B4.9 +..B4.8: + xorl %edi, %edi +..B4.9: + movl 32(%esp), %eax + mull 48(%esp) + addl %edx, %edi + addl 56(%esp), %eax + movl %eax, 52(%esp) + adcl $0, %edi + movl %edi, 64(%esp) + movl 36(%esp), %eax + movl 60(%esp), %edi + addl %edi, %eax + movl 40(%esp), %edx + adcl %ecx, %edx + movl %eax, 36(%esp) + subl %edi, %eax + movl %edx, 40(%esp) + movl 64(%esp), %edi + sbbl %ecx, %edx + jae ..B4.11 +..B4.10: + movl $1, 48(%esp) + jmp ..B4.12 +..B4.11: + movl $0, 48(%esp) +..B4.12: + movl 32(%esp), %eax + mull 44(%esp) + movl %esi, 88(%esp) + movl %eax, %esi + movl 44(%esp), %eax + movl %edx, %ecx + mull %eax + movl %edx, %eax + movl %ecx, %edx + addl %esi, %eax + adcl $0, %edx + addl %eax, %esi + adcl %edx, %ecx + subl %eax, %esi + movl %ecx, 56(%esp) + movl 88(%esp), %esi + sbbl %edx, %ecx + jae ..B4.14 +..B4.13: + movl $1, %ecx + jmp ..B4.15 +..B4.14: + xorl %ecx, %ecx +..B4.15: + movl 32(%esp), %eax + mull %eax + addl %edx, %ecx + addl 56(%esp), %eax + movl %eax, 44(%esp) + adcl $0, %ecx + movl %ecx, 60(%esp) + movl 36(%esp), %eax + movl 52(%esp), %ecx + addl %ecx, %eax + movl 40(%esp), %edx + adcl %edi, %edx + movl %eax, 36(%esp) + subl %ecx, %eax + movl %edx, 40(%esp) + movl 60(%esp), %ecx + sbbl %edi, %edx + jae ..B4.17 +..B4.16: + movl $1, %edi + jmp ..B4.18 +..B4.17: + xorl %edi, %edi +..B4.18: + movl 48(%esp), %edx + addl %edi, %edx + movl 36(%esp), %edi + movl %edi, 172(%esp) + movl 40(%esp), %edi + movl %edi, 176(%esp) + movl 44(%esp), %edi + addl %edx, %edi + movl %edi, 164(%esp) + adcl $0, %ecx + movl %ecx, 168(%esp) +..B4.19: + addl $12, %esp + xorl %ecx, %ecx + pushl %ecx + pushl %ecx + pushl %ebx + call __dpml_ffs_and_shift__ +..B4.20: + xorl %ecx, %ecx + movl 4(%ebx), %eax + cltd + xorl %eax, %eax + movl 16(%ebp), %edi + subl %edi, %eax + sbbl 20(%ebp), %ecx + imull 4(%ebx), %ecx + imull %eax, %edx + addl %edx, %ecx + mull 4(%ebx) + addl %ecx, %edx + movl %esi, %ecx + movl %edx, 112(%esp) + andl $512, %ecx + xorl %edx, %edx + shll $4, %edi + movl %eax, 108(%esp) + orl %edx, %ecx + movl %edi, 100(%esp) + je ..B4.22 +..B4.21: + movl %esi, %ecx + andl $1024, %ecx + orl %edx, %ecx + je ..B4.23 +..B4.22: + xorl %edx, %edx + jmp ..B4.24 +..B4.23: + movl $1, %edx +..B4.24: + movl 32(%ebp), %ecx + lea (%edx,%edx,2), %edx + movl %esi, %eax + lea (,%edx,8), %edi + andl $15, %eax + lea (%ecx,%edx,8), %ecx + xorl %edx, %edx + orl %edx, %eax + call ..L9 +..L9: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L9](%edx), %edx + movl %edx, 124(%esp) + je ..B4.52 +..B4.25: + negl %edi + xorl %edx, %edx + addl 32(%ebp), %edi + movl 104(%esp), %eax + addl $24, %edi + andl $8, %eax + orl %edx, %eax + je ..B4.27 +..B4.26: + movl 124(%esp), %edx + lea __eval_neg_poly@GOTOFF(%edx), %edx + movl %edx, 32(%esp) + jmp ..B4.28 +..B4.27: + movl 124(%esp), %eax + lea __eval_pos_poly@GOTOFF(%eax), %edx + lea __eval_neg_poly@GOTOFF(%eax), %eax + movl %eax, 32(%esp) +..B4.28: + movl %esi, 88(%esp) + andl $240, %esi + xorl %eax, %eax + movl %esi, 116(%esp) + orl %esi, %eax + movl 88(%esp), %esi + jne ..B4.30 +..B4.29: + movl 32(%ebp), %ecx +..B4.30: + cmpl 32(%esp), %edx + jne ..B4.32 +..B4.31: + movl 108(%esp), %edx + movl %ebx, %eax + movl %edx, 4(%esp) + movl 112(%esp), %edx + movl %edx, 8(%esp) + movl 16(%ebp), %edx + movl %edx, 16(%esp) + movl 20(%ebp), %edx + movl %edx, 20(%esp) + movl 96(%esp), %edx + movl %ecx, 32(%esp) + call __eval_neg_poly. + jmp ..B4.153 +..B4.32: + movl 108(%esp), %edx + movl %ebx, %eax + movl %edx, 4(%esp) + movl 112(%esp), %edx + movl %edx, 8(%esp) + movl 16(%ebp), %edx + movl %edx, 16(%esp) + movl 20(%ebp), %edx + movl %edx, 20(%esp) + movl 96(%esp), %edx + movl %ecx, 32(%esp) + call __eval_pos_poly. +..B4.153: + movl 32(%esp), %ecx +..B4.33: + movl %esi, %eax + xorl %edx, %edx + andl $2, %eax + orl %edx, %eax + jne ..B4.35 +..B4.34: + movl 4(%ecx), %edx + movl %edx, 92(%esp) + jmp ..B4.51 +..B4.35: + movl 8(%ebp), %edx + movl %edi, 48(%esp) + movl %esi, 88(%esp) + movl 12(%edx), %esi + movl 12(%ecx), %edi + movl 8(%edx), %eax + movl %ebx, 72(%esp) + movl 8(%ecx), %ebx + movl %esi, 32(%esp) + movl %edi, 36(%esp) + imull %ebx, %esi + imull %eax, %edi + movl %eax, 52(%esp) + addl %edi, %esi + mull %ebx + addl %esi, %edx + movl %edx, 44(%esp) + movl 8(%ebp), %edx + movl %eax, 40(%esp) + movl %ebx, %eax + movl 8(%ebp), %edi + mull 16(%edx) + movl 16(%ecx), %esi + movl %ebx, %eax + movl %esi, 64(%esp) + movl 20(%ecx), %esi + movl 20(%edi), %edi + movl %esi, 60(%esp) + movl %edx, %esi + mull %edi + movl %ebx, 56(%esp) + addl %eax, %esi + movl 8(%ebp), %ebx + movl %edi, 84(%esp) + movl %edx, %edi + adcl $0, %edi + movl 16(%ebx), %eax + mull 36(%esp) + addl %esi, %eax + movl 72(%esp), %ebx + adcl %edi, %edx + subl %esi, %eax + movl %edx, 68(%esp) + movl 88(%esp), %esi + sbbl %edi, %edx + movl 48(%esp), %edi + jae ..B4.37 +..B4.36: + movl $1, 80(%esp) + jmp ..B4.38 +..B4.37: + movl $0, 80(%esp) +..B4.38: + movl 84(%esp), %eax + mull 36(%esp) + movl %esi, 88(%esp) + movl 80(%esp), %esi + addl %edx, %esi + addl 68(%esp), %eax + movl %edi, 48(%esp) + adcl $0, %esi + movl %esi, 80(%esp) + movl 8(%ebp), %esi + movl %eax, 76(%esp) + movl 52(%esp), %eax + movl 4(%esi), %edx + movl (%esi), %edi + addl 4(%ecx), %edx + xorl %edi, (%ecx) + movl 64(%esp), %edi + movl %edx, 92(%esp) + movl %edx, 4(%ecx) + mull %edi + movl %edi, %eax + movl %edx, %esi + mull 32(%esp) + addl %eax, %esi + movl %edx, %edi + movl 52(%esp), %eax + adcl $0, %edi + mull 60(%esp) + addl %esi, %eax + adcl %edi, %edx + subl %esi, %eax + movl %edx, 72(%esp) + movl 88(%esp), %esi + sbbl %edi, %edx + movl 48(%esp), %edi + jae ..B4.40 +..B4.39: + movl $1, 68(%esp) + jmp ..B4.41 +..B4.40: + movl $0, 68(%esp) +..B4.41: + movl 60(%esp), %eax + mull 32(%esp) + movl %esi, 88(%esp) + movl 68(%esp), %esi + addl %edx, %esi + addl 72(%esp), %eax + movl %eax, 64(%esp) + adcl $0, %esi + movl %esi, 68(%esp) + movl 76(%esp), %esi + movl 40(%esp), %eax + addl %esi, %eax + movl %edi, 48(%esp) + movl 44(%esp), %edi + movl 80(%esp), %edx + adcl %edx, %edi + movl %eax, 40(%esp) + subl %esi, %eax + movl %edi, 44(%esp) + movl 88(%esp), %esi + sbbl %edx, %edi + movl 48(%esp), %edi + jae ..B4.43 +..B4.42: + movl $1, 72(%esp) + jmp ..B4.44 +..B4.43: + movl $0, 72(%esp) +..B4.44: + movl %edi, 48(%esp) + movl 56(%esp), %edi + movl %edi, %eax + mull 52(%esp) + movl %edi, %eax + movl %esi, 88(%esp) + movl %edx, %esi + mull 32(%esp) + addl %eax, %esi + movl %edx, %edi + movl 52(%esp), %eax + adcl $0, %edi + mull 36(%esp) + addl %esi, %eax + adcl %edi, %edx + subl %esi, %eax + movl %edx, 60(%esp) + movl 88(%esp), %esi + sbbl %edi, %edx + movl 48(%esp), %edi + jae ..B4.46 +..B4.45: + movl $1, 56(%esp) + jmp ..B4.47 +..B4.46: + movl $0, 56(%esp) +..B4.47: + movl 32(%esp), %eax + mull 36(%esp) + movl %esi, 88(%esp) + movl 56(%esp), %esi + addl %edx, %esi + addl 60(%esp), %eax + movl %eax, 52(%esp) + adcl $0, %esi + movl %esi, 56(%esp) + movl 64(%esp), %esi + movl 40(%esp), %eax + addl %esi, %eax + movl %edi, 48(%esp) + movl 44(%esp), %edi + movl 68(%esp), %edx + adcl %edx, %edi + movl %eax, 40(%esp) + subl %esi, %eax + movl %edi, 44(%esp) + movl 88(%esp), %esi + sbbl %edx, %edi + movl 48(%esp), %edi + jae ..B4.49 +..B4.48: + movl $1, %edx + jmp ..B4.50 +..B4.49: + xorl %edx, %edx +..B4.50: + movl 72(%esp), %eax + addl %edx, %eax + movl 40(%esp), %edx + movl %edx, 16(%ecx) + movl 44(%esp), %edx + movl %edx, 20(%ecx) + movl 52(%esp), %edx + addl %eax, %edx + movl 56(%esp), %eax + adcl $0, %eax + movl %edx, 8(%ecx) + movl %eax, 12(%ecx) +..B4.51: + movl 96(%esp), %edx + movl 100(%esp), %eax + lea 24(%edx,%eax), %edx + movl 92(%esp), %eax + addl -8(%edx), %eax + movl %edx, 96(%esp) + movl %eax, 4(%ecx) + jmp ..B4.54 +..B4.52: + orl $-1792, %esi + movl %esi, %edx + movl %esi, %eax + andl $240, %edx + andl $1024, %eax + movl %edx, 116(%esp) + xorl %edx, %edx + movl 32(%ebp), %edi + orl %edx, %eax + je ..B4.54 +..B4.53: + movl 96(%esp), %edx + movl 100(%esp), %eax + lea 24(%edx,%eax), %edx + movl %edx, 96(%esp) +..B4.54: + xorl %edx, %edx + movl 116(%esp), %eax + orl %edx, %eax + je ..B4.82 +..B4.55: + movl 104(%esp), %eax + andl $128, %eax + orl %edx, %eax + je ..B4.57 +..B4.56: + movl 124(%esp), %edx + lea __eval_neg_poly@GOTOFF(%edx), %eax + movl %eax, %edx + jmp ..B4.58 +..B4.57: + movl 124(%esp), %edx + lea __eval_pos_poly@GOTOFF(%edx), %eax + lea __eval_neg_poly@GOTOFF(%edx), %edx +..B4.58: + cmpl %edx, %eax + jne ..B4.60 +..B4.59: + movl 108(%esp), %edx + movl %ebx, %eax + movl %edx, 4(%esp) + movl %edi, %ecx + movl 112(%esp), %edx + movl %edx, 8(%esp) + movl 16(%ebp), %edx + movl %edx, 16(%esp) + movl 20(%ebp), %edx + movl %edx, 20(%esp) + movl 96(%esp), %edx + call __eval_neg_poly. + jmp ..B4.61 +..B4.60: + movl 108(%esp), %edx + movl %ebx, %eax + movl %edx, 4(%esp) + movl %edi, %ecx + movl 112(%esp), %edx + movl %edx, 8(%esp) + movl 16(%ebp), %edx + movl %edx, 16(%esp) + movl 20(%ebp), %edx + movl %edx, 20(%esp) + movl 96(%esp), %edx + call __eval_pos_poly. +..B4.61: + movl %esi, %edx + xorl %eax, %eax + andl $32, %edx + orl %eax, %edx + jne ..B4.63 +..B4.62: + movl 4(%edi), %ebx + jmp ..B4.79 +..B4.63: + movl 8(%ebp), %ebx + movl %esi, 88(%esp) + movl 12(%edi), %edx + movl 12(%ebx), %esi + movl 8(%ebx), %eax + movl 8(%edi), %ebx + movl %esi, 32(%esp) + movl %edx, 36(%esp) + imull %ebx, %esi + imull %eax, %edx + movl %eax, 48(%esp) + addl %edx, %esi + mull %ebx + addl %esi, %edx + movl %edx, 44(%esp) + movl 8(%ebp), %edx + movl %eax, 40(%esp) + movl %ebx, %eax + movl 8(%ebp), %esi + mull 16(%edx) + movl 20(%esi), %ecx + movl %ebx, %eax + movl 16(%edi), %esi + movl %esi, 68(%esp) + movl 20(%edi), %esi + movl %esi, 56(%esp) + movl %edx, %esi + mull %ecx + movl %ebx, 52(%esp) + movl %edx, %ebx + movl 8(%ebp), %edx + addl %eax, %esi + movl %ecx, 76(%esp) + adcl $0, %ebx + movl 16(%edx), %eax + mull 36(%esp) + addl %esi, %eax + adcl %ebx, %edx + subl %esi, %eax + movl %edx, 72(%esp) + movl 88(%esp), %esi + sbbl %ebx, %edx + jae ..B4.65 +..B4.64: + movl $1, %ecx + jmp ..B4.66 +..B4.65: + xorl %ecx, %ecx +..B4.66: + movl 76(%esp), %eax + mull 36(%esp) + addl %edx, %ecx + addl 72(%esp), %eax + movl %eax, 64(%esp) + movl 8(%ebp), %eax + adcl $0, %ecx + movl %ecx, 80(%esp) + movl 68(%esp), %ecx + movl 4(%eax), %edx + addl 4(%edi), %edx + movl (%eax), %ebx + movl 48(%esp), %eax + movl %edx, 84(%esp) + movl %edx, 4(%edi) + mull %ecx + movl %ecx, %eax + xorl %ebx, (%edi) + movl %edx, %ebx + mull 32(%esp) + addl %eax, %ebx + movl %edx, %ecx + movl 48(%esp), %eax + adcl $0, %ecx + mull 56(%esp) + addl %ebx, %eax + adcl %ecx, %edx + subl %ebx, %eax + movl %edx, 60(%esp) + movl 84(%esp), %ebx + sbbl %ecx, %edx + movl 80(%esp), %ecx + jae ..B4.68 +..B4.67: + movl $1, 72(%esp) + jmp ..B4.69 +..B4.68: + movl $0, 72(%esp) +..B4.69: + movl 56(%esp), %eax + mull 32(%esp) + movl %esi, 88(%esp) + movl 72(%esp), %esi + addl %edx, %esi + addl 60(%esp), %eax + movl %eax, 68(%esp) + adcl $0, %esi + movl %esi, 72(%esp) + movl 40(%esp), %eax + movl 64(%esp), %esi + addl %esi, %eax + movl 44(%esp), %edx + adcl %ecx, %edx + movl %eax, 40(%esp) + subl %esi, %eax + movl %edx, 44(%esp) + movl 88(%esp), %esi + sbbl %ecx, %edx + jae ..B4.71 +..B4.70: + movl $1, 60(%esp) + jmp ..B4.72 +..B4.71: + movl $0, 60(%esp) +..B4.72: + movl 52(%esp), %ecx + movl %ecx, %eax + mull 48(%esp) + movl %ecx, %eax + movl %esi, 88(%esp) + movl %edx, %esi + mull 32(%esp) + addl %eax, %esi + movl %edx, %ecx + movl 48(%esp), %eax + adcl $0, %ecx + mull 36(%esp) + addl %esi, %eax + adcl %ecx, %edx + subl %esi, %eax + movl %edx, 56(%esp) + movl 88(%esp), %esi + sbbl %ecx, %edx + jae ..B4.74 +..B4.73: + movl $1, %ecx + jmp ..B4.75 +..B4.74: + xorl %ecx, %ecx +..B4.75: + movl 32(%esp), %eax + mull 36(%esp) + addl %edx, %ecx + addl 56(%esp), %eax + movl %esi, 88(%esp) + adcl $0, %ecx + movl %ecx, 52(%esp) + movl 68(%esp), %esi + movl 40(%esp), %ecx + addl %esi, %ecx + movl %eax, 48(%esp) + movl 44(%esp), %edx + movl 72(%esp), %eax + adcl %eax, %edx + movl %ecx, 40(%esp) + subl %esi, %ecx + movl %edx, 44(%esp) + movl 52(%esp), %ecx + sbbl %eax, %edx + movl 88(%esp), %esi + jae ..B4.77 +..B4.76: + movl $1, %edx + jmp ..B4.78 +..B4.77: + xorl %edx, %edx +..B4.78: + movl 60(%esp), %eax + addl %edx, %eax + movl 40(%esp), %edx + movl %edx, 16(%edi) + movl 44(%esp), %edx + movl %edx, 20(%edi) + movl 48(%esp), %edx + addl %eax, %edx + movl %edx, 8(%edi) + adcl $0, %ecx + movl %ecx, 12(%edi) +..B4.79: + movl 96(%esp), %edx + xorl %ecx, %ecx + movl 100(%esp), %eax + addl 16(%eax,%edx), %ebx + movl %ebx, 4(%edi) + movl %esi, %ebx + andl $1024, %ebx + orl %ecx, %ebx + je ..B4.83 +..B4.80: + movl 180(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B4.148 +..B4.81: + addl $196, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B4.82: + orl $-256, %esi +..B4.83: + andl $256, %esi + xorl %eax, %eax + orl %eax, %esi + jne ..B4.146 +..B4.84: + movl 124(%esp), %eax + movl 32(%ebp), %ecx + movl %ecx, %edi + addl $24, %edi + lea __ux_one__@GOTOFF(%eax), %edx + jne ..L10 + movl %edx, %edi +..L10: + testl %ecx, %ecx + movl 12(%edi), %esi + jne ..L11 + movl %edx, %ecx +..L11: + movl 8(%edi), %ebx + cmpl %edx, %edi + movl 16(%edi), %eax + movl %esi, 112(%esp) + movl %ecx, 120(%esp) + movl %ebx, 108(%esp) + movl %eax, 116(%esp) + movl 20(%edi), %esi + je ..B4.150 +..B4.85: + xorl %edx, %edx + movl 112(%esp), %ecx + subl %edx, %ecx + jl ..B4.88 +..B4.86: + addl $12, %esp + pushl %edx + pushl %edx + pushl %edi + call __dpml_ffs_and_shift__ +..B4.87: + movl 8(%edi), %eax + movl 12(%edi), %edx + movl 16(%edi), %ecx + movl 20(%edi), %esi + movl %eax, 108(%esp) + movl %edx, 112(%esp) + movl %ecx, 116(%esp) +..B4.88: + addl $4, %esp + lea 124(%esp), %edx + pushl %edx + movl -4(%edx), %ebx + call fegetenv@PLT +..B4.89: + movl %esi, 72(%esp) + movl 112(%esp), %esi + movl %esi, %eax + movl 108(%esp), %ecx + movl %ecx, %edx + movl %edi, 44(%esp) + movl %esi, %edi + shll $31, %eax + shrl $1, %edx + shrl $1, %edi + orl %edx, %eax + movl %eax, 48(%esp) + movl %esi, %eax + movl %edi, 52(%esp) + andl $-64, %eax + fildll 48(%esp) + andl $63, %esi + fstpl 64(%esp) + xorl %edx, %edx + fldl 64(%esp) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fdiv %st, %st(1) + shrl $1, %eax + movl %eax, 52(%esp) + movl %ecx, %eax + movl 120(%esp), %edi + shrl $17, %eax + shll $15, %esi + movl %edx, 48(%esp) + orl %esi, %eax + movl 72(%esp), %esi + shll $15, %ecx + shrl $17, %esi + orl %esi, %ecx + movl 12(%edi), %esi + movl %esi, 88(%esp) + fxch %st(1) + fstpl 64(%esp) + fldl 64(%esp) + movl (%edi), %esi + fld %st(0) + fildll 48(%esp) + movl %eax, 52(%esp) + movl %ecx, 48(%esp) + movl 8(%edi), %eax + movl 16(%edi), %ecx + movl %eax, 92(%esp) + movl %ecx, 80(%esp) + movl 20(%edi), %eax + movl 44(%esp), %ecx + movl %eax, 84(%esp) + movl 32(%ebp), %eax + xorl (%ecx), %esi + fstpl 64(%esp) + fldl 64(%esp) + fildll 48(%esp) + movl %esi, (%eax) + fstpl 64(%esp) + fxch %st(1) + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 56(%esp) + fldcw 32(%esp) + movl %edx, 48(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fldl 64(%esp) + movl 56(%esp), %eax + addl $-1280, %eax + movl 60(%esp), %esi + adcl $-1, %esi + fmul %st(1), %st + andl $-16, %esi + movl %esi, 52(%esp) + fstpl 64(%esp) + fldl 64(%esp) + fildll 48(%esp) + fstpl 64(%esp) + fldl 64(%esp) + fmul %st, %st(3) + movl 4(%edi), %edi + fxch %st(3) + fsubrp %st, %st(5) + fmul %st(2), %st + movl %esi, 96(%esp) + fsubrp %st, %st(4) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + movl 88(%esp), %eax + movl %eax, %ebx + movl 92(%esp), %esi + subl 4(%ecx), %edi + movl %esi, %ecx + shll $21, %ebx + shrl $11, %ecx + fmulp %st, %st(3) + orl %ecx, %ebx + movl %edi, 100(%esp) + movl %eax, %edi + shrl $1, %edi + movl %ebx, %ecx + shrl $22, %ecx + andl $-1024, %edi + shll $10, %ebx + orl %edi, %ecx + movl %ebx, 48(%esp) + movl %eax, %ebx + movl %ecx, 52(%esp) + andl $-64, %ebx + fxch %st(2) + fmulp %st, %st(3) + andl $63, %eax + shrl $1, %ebx + movl 84(%esp), %ecx + shll $15, %eax + shrl $17, %ecx + fxch %st(2) + fstpl 64(%esp) + fldl 64(%esp) + fildll 48(%esp) + movl %edx, 48(%esp) + movl %esi, %edx + movl %ebx, 52(%esp) + shrl $17, %edx + shll $15, %esi + orl %eax, %edx + orl %ecx, %esi + fstpl 64(%esp) + fldl 64(%esp) + movl 124(%esp), %eax + fmul %st(1), %st + fildll 48(%esp) + movl %esi, 48(%esp) + movl %edx, 52(%esp) + fstpl 64(%esp) + fldl 64(%esp) + fildll 48(%esp) + fstpl 64(%esp) + fldl 64(%esp) + fmulp %st, %st(4) + fxch %st(3) + fstpl 64(%esp) + fldl 64(%esp) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + fmulp %st, %st(5) + fxch %st(4) + fstpl 64(%esp) + fldl 64(%esp) + fmul %st, %st(3) + fxch %st(3) + fstpl 64(%esp) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldl 64(%esp) + fxch %st(2) + fstpl 64(%esp) + fldl 64(%esp) + fldt .L_2il0floatpacket.4@GOTOFF(%eax) + fmulp %st, %st(3) + fxch %st(2) + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 56(%esp) + fldcw 32(%esp) + movl 56(%esp), %ebx + movl %ebx, %edx + movl 60(%esp), %ecx + movl %ecx, %edi + fxch %st(1) + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 56(%esp) + fldcw 32(%esp) + shrl $30, %edx + shll $2, %ebx + shll $2, %ecx + movl 56(%esp), %esi + orl %ecx, %edx + addl %esi, %ebx + movl %ebx, %ecx + movl 60(%esp), %eax + adcl %eax, %edx + shrl $30, %edi + subl %esi, %ecx + movl %edx, 76(%esp) + movl %edi, 104(%esp) + sbbl %eax, %edx + movl 72(%esp), %esi + movl 96(%esp), %edx + jae ..B4.91 +..B4.90: + movl $1, %ecx + jmp ..B4.92 +..B4.91: + xorl %ecx, %ecx +..B4.92: + addl %ecx, 104(%esp) + movl 124(%esp), %ecx + fldt .L_2il0floatpacket.5@GOTOFF(%ecx) + fmulp %st, %st(1) + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 56(%esp) + fldcw 32(%esp) + movl 60(%esp), %edi + movl 56(%esp), %ecx + movl %ecx, 44(%esp) + lea (%edi,%edx,4), %edx + movl %edx, 48(%esp) + orl %edx, %ecx + jne ..B4.94 +..B4.93: + movl $-1, %edx + movl %edx, 44(%esp) + movl %edx, 48(%esp) +..B4.94: + movl %ebx, %eax + xorl %edi, %edi + mull 116(%esp) + xorl %ecx, %ecx + movl %ebx, %eax + subl 104(%esp), %ecx + movl %ecx, 32(%esp) + movl %edx, %ecx + sbbl $0, %edi + mull %esi + addl %eax, %ecx + movl 116(%esp), %eax + movl %edi, 68(%esp) + movl %edx, %edi + adcl $0, %edi + mull 76(%esp) + addl %ecx, %eax + adcl %edi, %edx + subl %ecx, %eax + movl %edx, 36(%esp) + movl 68(%esp), %ecx + sbbl %edi, %edx + jae ..B4.96 +..B4.95: + movl $1, 64(%esp) + jmp ..B4.97 +..B4.96: + movl $0, 64(%esp) +..B4.97: + movl %esi, %eax + movl %esi, 72(%esp) + movl 76(%esp), %esi + mull %esi + movl %ecx, 68(%esp) + movl 64(%esp), %ecx + addl %edx, %ecx + movl %esi, %edx + addl 36(%esp), %eax + movl 108(%esp), %esi + adcl $0, %ecx + movl %ecx, 64(%esp) + movl 112(%esp), %ecx + movl %ecx, %edi + imull %ebx, %edi + imull %esi, %edx + movl %eax, 60(%esp) + movl %esi, %eax + addl %edx, %edi + mull %ebx + movl %eax, 40(%esp) + movl %ebx, %eax + addl %edi, %edx + movl %edx, 52(%esp) + mull %esi + movl %ebx, %eax + movl %edx, %edi + mull %ecx + addl %eax, %edi + movl %esi, %eax + movl %edx, %ecx + adcl $0, %ecx + mull 76(%esp) + addl %edi, %eax + movl 72(%esp), %esi + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 56(%esp) + sbbl %ecx, %edx + movl 68(%esp), %ecx + jae ..B4.99 +..B4.98: + movl $1, %edi + jmp ..B4.100 +..B4.99: + xorl %edi, %edi +..B4.100: + movl %ebx, 36(%esp) + andl %ecx, %esi + movl 112(%esp), %ebx + movl %ebx, %eax + mull 76(%esp) + addl %edx, %edi + andl %ebx, %ecx + addl 56(%esp), %eax + movl %eax, 72(%esp) + movl 116(%esp), %edx + adcl $0, %edi + movl 32(%esp), %eax + andl %eax, %edx + movl 60(%esp), %ebx + andl 108(%esp), %eax + addl %ebx, %edx + movl %eax, 32(%esp) + movl 64(%esp), %eax + adcl %eax, %esi + movl %edx, 116(%esp) + subl %ebx, %edx + movl %esi, %ebx + sbbl %eax, %ebx + movl 36(%esp), %ebx + jae ..B4.102 +..B4.101: + movl $1, %edx + jmp ..B4.103 +..B4.102: + xorl %edx, %edx +..B4.103: + movl %ecx, 68(%esp) + movl 40(%esp), %ecx + movl 116(%esp), %eax + addl %ecx, %eax + movl %ebx, 36(%esp) + movl 52(%esp), %ebx + adcl %ebx, %esi + movl %eax, 116(%esp) + subl %ecx, %eax + movl %esi, %ecx + sbbl %ebx, %ecx + movl 36(%esp), %ebx + movl 68(%esp), %ecx + jae ..B4.105 +..B4.104: + movl $1, %eax + jmp ..B4.106 +..B4.105: + xorl %eax, %eax +..B4.106: + addl %eax, %edx + movl %edx, 40(%esp) + movl 72(%esp), %edx + movl 32(%esp), %eax + addl %edx, %eax + movl %eax, 32(%esp) + adcl %edi, %ecx + subl %edx, %eax + movl %ecx, %edx + sbbl %edi, %edx + movl 40(%esp), %edx + jae ..B4.108 +..B4.107: + movl $1, 40(%esp) + jmp ..B4.109 +..B4.108: + movl $0, 40(%esp) +..B4.109: + movl 32(%esp), %edi + addl %edx, %edi + movl %edi, 32(%esp) + adcl $0, %ecx + subl %edx, %edi + movl $0, %edx + movl %ecx, %edi + sbbl %edx, %edi + jae ..B4.111 +..B4.110: + movl $1, %edi + jmp ..B4.112 +..B4.111: + xorl %edi, %edi +..B4.112: + xorl %eax, %eax + movl 40(%esp), %edx + addl %edi, %edx + xorl %edi, %edi + subl %edx, %edi + movl %eax, %edx + movl 80(%esp), %eax + sbbl $0, %edx + subl 116(%esp), %eax + movl 84(%esp), %eax + sbbl %esi, %eax + jae ..B4.114 +..B4.113: + movl $1, 56(%esp) + jmp ..B4.115 +..B4.114: + movl $0, 56(%esp) +..B4.115: + movl 80(%esp), %eax + subl 116(%esp), %eax + movl %eax, 52(%esp) + movl 84(%esp), %eax + sbbl %esi, %eax + movl 92(%esp), %esi + subl 32(%esp), %esi + movl 88(%esp), %esi + movl %eax, 40(%esp) + sbbl %ecx, %esi + jae ..B4.117 +..B4.116: + movl $1, %esi + jmp ..B4.118 +..B4.117: + xorl %esi, %esi +..B4.118: + subl %esi, %edi + movl 92(%esp), %esi + sbbl $0, %edx + subl 32(%esp), %esi + movl 88(%esp), %eax + sbbl %ecx, %eax + movl %esi, %ecx + subl 56(%esp), %ecx + movl $0, %ecx + movl %eax, 60(%esp) + sbbl %ecx, %eax + jae ..B4.121 +..B4.119: + movl $1, %ecx +..B4.121: + subl %ecx, %edi + movl 60(%esp), %ecx + sbbl $0, %edx + subl 56(%esp), %esi + sbbl $0, %ecx + orl %ecx, %esi + je ..B4.123 +..B4.122: + movl $1, %ecx + jmp ..B4.124 +..B4.123: + xorl %ecx, %ecx +..B4.124: + orl %edi, %ecx + movl %ecx, %esi + movl %edx, 56(%esp) + orl %edx, %esi + jne ..B4.127 +..B4.125: + movl 108(%esp), %edi + movl 112(%esp), %edx +..B4.127: + movl %ebx, 36(%esp) + movl 108(%esp), %ebx + xorl %edi, %ebx + movl 112(%esp), %eax + movl 52(%esp), %edi + xorl %edx, %eax + subl %ebx, %edi + movl 40(%esp), %esi + sbbl %eax, %esi + movl 44(%esp), %eax + mull %edi + movl 44(%esp), %eax + movl %edx, %ebx + mull %esi + addl %eax, %ebx + movl %edi, %eax + movl %esi, 40(%esp) + movl %edx, %esi + adcl $0, %esi + mull 48(%esp) + addl %ebx, %eax + adcl %esi, %edx + subl %ebx, %eax + movl %edx, 32(%esp) + movl 36(%esp), %ebx + sbbl %esi, %edx + jae ..B4.129 +..B4.128: + movl $1, %esi + jmp ..B4.130 +..B4.129: + xorl %esi, %esi +..B4.130: + movl 40(%esp), %eax + xorl %edi, %edi + mull 48(%esp) + addl %edx, %esi + addl 32(%esp), %eax + adcl $0, %esi + movl %esi, %edx + subl %edi, %edx + jl ..B4.132 +..B4.131: + xorl %edx, %edx + jmp ..B4.133 +..B4.132: + movl $1, %edx +..B4.133: + movl 92(%esp), %edi + addl %edx, %ecx + movl 88(%esp), %edx + adcl $0, 56(%esp) + orl 80(%esp), %edi + orl 84(%esp), %edx + orl %edx, %edi + je ..B4.135 +..B4.134: + movl $1, %edx + jmp ..B4.136 +..B4.135: + xorl %edx, %edx +..B4.136: + movl %eax, %edi + addl %eax, %eax + shrl $31, %edi + addl %esi, %esi + orl %esi, %edi + addl %edx, %eax + movl 56(%esp), %edx + adcl $0, %edi + addl %ecx, %ebx + movl %ebx, %esi + movl %edi, 32(%esp) + movl 76(%esp), %edi + adcl %edx, %edi + subl %ecx, %esi + movl %edi, 76(%esp) + sbbl %edx, %edi + jae ..B4.138 +..B4.137: + movl $1, %edx + jmp ..B4.139 +..B4.138: + xorl %edx, %edx +..B4.139: + movl 56(%esp), %edi + sarl $31, %edi + movl 104(%esp), %ecx + addl %edi, %ecx + addl %edx, %ecx + movl %ecx, %edi + shll $31, %edi + movl %ecx, 104(%esp) + cmpl $31, %ecx + jbe ..B4.141 +..B4.140: + xorl %edx, %edx + movl 76(%esp), %esi + shrl %cl, %esi + jmp ..B4.142 +..B4.141: + movl %ebx, %esi + movl 76(%esp), %edx + shrdl %cl, %edx, %esi + shrl %cl, %edx +..B4.142: + orl %edx, %edi + movl 32(%ebp), %edx + andl %ecx, %ebx + shll $31, %ebx + movl %esi, 8(%edx) + cmpl $31, %ecx + movl %edi, 12(%edx) + jbe ..B4.144 +..B4.143: + xorl %edx, %edx + movl 32(%esp), %eax + shrl %cl, %eax + jmp ..B4.145 +..B4.144: + movl 32(%esp), %edx + shrdl %cl, %edx, %eax + shrl %cl, %edx +..B4.145: + addl $4, %esp + orl %edx, %ebx + movl 32(%ebp), %edx + lea 124(%esp), %ecx + pushl %ecx + movl %eax, 16(%edx) + movl -28(%ecx), %eax + addl -24(%ecx), %eax + movl %ebx, 20(%edx) + movl -4(%ecx), %ebx + movl %eax, 4(%edx) + call fesetenv@PLT +..B4.146: + movl 180(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B4.148 +..B4.147: + addl $196, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B4.148: + movl 124(%esp), %ebx + call __stack_chk_fail@PLT +..B4.150: + movl %ecx, %eax + movl 32(%ebp), %edx + movl 8(%eax), %esi + movl 12(%eax), %edi + movl (%eax), %ecx + movl %esi, 8(%edx) + movl %edi, 12(%edx) + movl %ecx, (%edx) + movl 4(%eax), %ebx + movl 16(%eax), %ecx + movl 20(%eax), %eax + movl %ebx, 4(%edx) + movl %ecx, 16(%edx) + movl %eax, 20(%edx) + jmp ..B4.146 + .align 16,0x90 + .type __dpml_evaluate_rational__,@function + .size __dpml_evaluate_rational__,.-__dpml_evaluate_rational__ + .data +# -- End __dpml_evaluate_rational__ + .text +# -- Begin __eval_neg_poly + .text + .align 16,0x90 +__eval_neg_poly: +# parameter 1: %eax +# parameter 2: 148 + %esp +# parameter 3: %edx +# parameter 4: 160 + %esp +# parameter 5: %ecx +..B5.1: +..L12: + + movl 4(%esp), %eax + movl 16(%esp), %edx + movl 28(%esp), %ecx +__eval_neg_poly.: + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $124, %esp + movl %edx, 88(%esp) + movl 8(%eax), %edx + movl %edx, 72(%esp) + movl 12(%eax), %edx + movl %edx, 80(%esp) + movl 16(%eax), %edx + movl %edx, 76(%esp) + movl 20(%eax), %edx + movl 4(%eax), %eax + movl 164(%esp), %esi + movl %edx, 92(%esp) + cltd + movl 160(%esp), %edi + movl %esi, 96(%esp) + xorl %esi, %esi + movl %edi, 84(%esp) + movl %edx, %edi + xorl %edx, %edx + subl %eax, %edx + movl 148(%esp), %ebx + sbbl %edi, %esi + movl %ecx, (%esp) + movl %ebx, %ecx + movl %esi, 4(%esp) + movl $128, %esi + subl %esi, %ecx + movl $0, %esi + movl 152(%esp), %ebp + movl %ebp, %ecx + sbbl %esi, %ecx + jge ..B5.4 +..B5.2: + movl $1, %esi +..B5.4: + testl %esi, %esi + jne ..B5.8 +..B5.5: + movl %edx, 16(%esp) + movl %eax, 64(%esp) + movl %edi, 68(%esp) + movl 96(%esp), %edx + movl 84(%esp), %esi + movl 88(%esp), %eax +..B5.6: + addl 64(%esp), %ebx + movl %ebx, %ecx + adcl 68(%esp), %ebp + movl $128, %edi + addl $-1, %esi + adcl $-1, %edx + addl $16, %eax + subl %edi, %ecx + movl $0, %edi + movl %ebp, %ecx + sbbl %edi, %ecx + jge ..B5.6 +..B5.7: + movl %edx, 96(%esp) + movl %eax, 88(%esp) + movl %esi, 84(%esp) + movl 16(%esp), %edx + movl 68(%esp), %edi + movl 64(%esp), %eax +..B5.8: + movl $64, %esi + movl %ebx, %ecx + subl %esi, %ecx + movl $0, %esi + movl %ebp, %ecx + sbbl %esi, %ecx + jge ..B5.11 +..B5.9: + movl $1, %esi +..B5.11: + testl %esi, %esi + je ..B5.13 +..B5.12: + xorl %esi, %esi + movl %esi, 100(%esp) + movl %esi, 104(%esp) + jmp ..B5.28 +..B5.13: + movl %edi, 68(%esp) + movl %edx, 16(%esp) + movl %eax, 64(%esp) + movl 96(%esp), %esi + movl 88(%esp), %edi +..B5.14: + movl 8(%edi), %edx + lea -64(%ebx), %ecx + movl 12(%edi), %eax + cmpl $31, %ecx + jbe ..B5.16 +..B5.15: + movl %eax, %edx + movl $0, 104(%esp) + shrl %cl, %edx + jmp ..B5.17 +..B5.16: + shrdl %cl, %eax, %edx + shrl %cl, %eax + movl %eax, 104(%esp) +..B5.17: + addl 64(%esp), %ebx + movl %ebx, %ecx + adcl 68(%esp), %ebp + movl $64, %eax + addl $16, %edi + addl $-1, 84(%esp) + adcl $-1, %esi + subl %eax, %ecx + movl $0, %eax + movl %ebp, %ecx + sbbl %eax, %ecx + jl ..B5.102 +..B5.18: + movl %edx, %eax + orl 104(%esp), %eax + je ..B5.14 +..B5.19: + movl %edx, 100(%esp) + movl %edi, 88(%esp) + movl %esi, 96(%esp) + movl 16(%esp), %edx + movl 104(%esp), %esi + movl 100(%esp), %edi + movl %ebp, 36(%esp) +..B5.20: + movl 72(%esp), %eax + mull %edi + movl %edi, %eax + movl %edx, %ebp + mull 80(%esp) + addl %eax, %ebp + movl %edx, %ecx + movl 72(%esp), %eax + adcl $0, %ecx + mull %esi + addl %ebp, %eax + movl %edx, %edi + adcl %ecx, %edi + subl %ebp, %eax + movl %edi, %edx + sbbl %ecx, %edx + jae ..B5.22 +..B5.21: + movl $1, %ebp + jmp ..B5.23 +..B5.22: + xorl %ebp, %ebp +..B5.23: + movl 80(%esp), %eax + lea -64(%ebx), %ecx + mull %esi + movl 88(%esp), %esi + addl %edx, %ebp + addl %edi, %eax + adcl $0, %ebp + movl 8(%esi), %edi + cmpl $31, %ecx + movl 12(%esi), %edx + jbe ..B5.25 +..B5.24: + movl %edx, %edi + xorl %esi, %esi + shrl %cl, %edi + jmp ..B5.26 +..B5.25: + movl %edx, %esi + shrdl %cl, %edx, %edi + shrl %cl, %esi +..B5.26: + addl 64(%esp), %ebx + movl 36(%esp), %edx + adcl 68(%esp), %edx + addl $-1, 84(%esp) + movl %edx, 36(%esp) + adcl $-1, 96(%esp) + subl %eax, %edi + movl %ebx, %eax + sbbl %ebp, %esi + movl $64, %ebp + addl $16, 88(%esp) + subl %ebp, %eax + movl $0, %ebp + sbbl %ebp, %edx + jge ..B5.20 +..B5.27: + movl %edi, 100(%esp) + movl %esi, 104(%esp) + movl 36(%esp), %ebp + movl 16(%esp), %edx + movl 68(%esp), %edi + movl 64(%esp), %eax +..B5.28: + xorl %ecx, %ecx + xorl %esi, %esi + subl %ebx, %esi + movl %esi, 8(%esp) + movl %ebx, %esi + sbbl %ebp, %ecx + movl %ecx, 12(%esp) + orl %ebp, %esi + jne ..B5.30 +..B5.29: + xorl %edx, %edx + xorl %esi, %esi + jmp ..B5.78 +..B5.30: + movl %ebp, 36(%esp) + movl %edx, 16(%esp) + movl %edi, 68(%esp) + movl %eax, 64(%esp) +..B5.31: + movl 72(%esp), %esi + movl %esi, %eax + movl 100(%esp), %ebp + mull %ebp + movl %ebp, %eax + movl %edx, %edi + mull 80(%esp) + addl %eax, %edi + movl %esi, %eax + movl %edx, %ebp + adcl $0, %ebp + mull 104(%esp) + addl %edi, %eax + movl %edx, %esi + adcl %ebp, %esi + subl %edi, %eax + movl %esi, %eax + sbbl %ebp, %eax + jae ..B5.33 +..B5.32: + movl $1, %ebp + jmp ..B5.34 +..B5.33: + xorl %ebp, %ebp +..B5.34: + movl 104(%esp), %eax + mull 80(%esp) + movl 88(%esp), %edi + addl %edx, %ebp + addl %esi, %eax + movl %eax, 32(%esp) + movl 12(%edi), %esi + adcl $0, %ebp + movl %esi, 20(%esp) + cmpl $31, %ebx + movl 8(%edi), %edx + movl (%edi), %eax + movl 4(%edi), %esi + jbe ..B5.36 +..B5.35: + movl %ebx, %ecx + movl %esi, %eax + shrl %cl, %eax + xorl %edi, %edi + jmp ..B5.37 +..B5.36: + movl %ebx, %ecx + movl %esi, %edi + shrdl %cl, %esi, %eax + shrl %cl, %edi +..B5.37: + movl 8(%esp), %esi + lea 64(%esi), %ecx + cmpl $31, %ecx + jbe ..B5.39 +..B5.38: + movl %edx, %esi + shll %cl, %esi + movl $0, 24(%esp) + movl %esi, 28(%esp) + jmp ..B5.40 +..B5.39: + movl 20(%esp), %esi + shldl %cl, %edx, %esi + movl %esi, 28(%esp) + movl %edx, %esi + shll %cl, %esi + movl %esi, 24(%esp) +..B5.40: + orl 24(%esp), %eax + orl 28(%esp), %edi + cmpl $31, %ebx + jbe ..B5.42 +..B5.41: + movl %ebx, %ecx + xorl %esi, %esi + movl 20(%esp), %edx + shrl %cl, %edx + jmp ..B5.43 +..B5.42: + movl %ebx, %ecx + movl 20(%esp), %esi + shrdl %cl, %esi, %edx + shrl %cl, %esi +..B5.43: + movl 8(%esp), %ecx + addl 16(%esp), %ecx + movl %ecx, 8(%esp) + movl 12(%esp), %ecx + adcl 4(%esp), %ecx + addl 64(%esp), %ebx + movl %ecx, 12(%esp) + movl 36(%esp), %ecx + adcl 68(%esp), %ecx + addl $-1, 84(%esp) + movl %ecx, 36(%esp) + movl %eax, %ecx + adcl $-1, 96(%esp) + subl 32(%esp), %ecx + movl %ecx, 100(%esp) + movl %edi, %ecx + sbbl %ebp, %ecx + addl $16, 88(%esp) + movl 100(%esp), %ebp + subl %eax, %ebp + movl %ecx, 104(%esp) + movl %ecx, %eax + sbbl %edi, %eax + jb ..B5.45 +..B5.105: + orl %eax, %ebp + je ..B5.45 +..B5.44: + movl $1, %eax + jmp ..B5.46 +..B5.45: + xorl %eax, %eax +..B5.46: + subl %eax, %edx + movl %ebx, %eax + sbbl $0, %esi + orl 36(%esp), %eax + je ..B5.78 +..B5.47: + movl %edx, %eax + orl %esi, %eax + je ..B5.31 +..B5.48: + movl %esi, 108(%esp) + movl %edx, 112(%esp) + movl %ebx, 12(%esp) +..B5.49: + movl 80(%esp), %ecx + movl 112(%esp), %esi + movl 108(%esp), %ebx + movl 72(%esp), %eax + imull %esi, %ecx + imull %eax, %ebx + mull %esi + movl 88(%esp), %ebp + addl %ebx, %ecx + addl %ecx, %edx + movl %eax, 8(%esp) + movl %edx, 4(%esp) + movl 8(%ebp), %ebx + movl 12(%ebp), %eax + movl (%ebp), %esi + movl 4(%ebp), %edx + cmpl $31, 12(%esp) + jbe ..B5.51 +..B5.50: + movl %edx, %esi + movl 12(%esp), %ecx + movl $0, 52(%esp) + shrl %cl, %esi + jmp ..B5.52 +..B5.51: + movl 12(%esp), %ecx + shrdl %cl, %edx, %esi + shrl %cl, %edx + movl %edx, 52(%esp) +..B5.52: + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B5.54 +..B5.53: + movl %ebx, %ebp + xorl %edx, %edx + shll %cl, %ebp + jmp ..B5.55 +..B5.54: + movl %eax, %ebp + movl %ebx, %edx + shldl %cl, %ebx, %ebp + shll %cl, %edx +..B5.55: + orl %ebp, 52(%esp) + orl %edx, %esi + cmpl $31, 12(%esp) + jbe ..B5.57 +..B5.56: + movl %eax, %ebx + xorl %ebp, %ebp + movl 12(%esp), %ecx + shrl %cl, %ebx + jmp ..B5.58 +..B5.57: + movl %eax, %ebp + movl 12(%esp), %ecx + shrdl %cl, %eax, %ebx + shrl %cl, %ebp +..B5.58: + movl 112(%esp), %ecx + movl %ecx, %eax + mull 76(%esp) + movl %ecx, %eax + movl %edx, %edi + mull 92(%esp) + addl %eax, %edi + movl %edx, %ecx + movl 76(%esp), %eax + adcl $0, %ecx + mull 108(%esp) + addl %edi, %eax + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 32(%esp) + sbbl %ecx, %edx + jae ..B5.60 +..B5.59: + movl $1, %edi + jmp ..B5.61 +..B5.60: + xorl %edi, %edi +..B5.61: + movl 92(%esp), %eax + mull 108(%esp) + addl %edx, %edi + addl 32(%esp), %eax + movl %eax, 48(%esp) + movl %esi, %eax + adcl $0, %edi + subl 8(%esp), %eax + movl 52(%esp), %ecx + movl %ecx, %edx + sbbl 4(%esp), %edx + movl %eax, 20(%esp) + subl %esi, %eax + movl %edx, 16(%esp) + sbbl %ecx, %edx + jb ..B5.63 +..B5.106: + orl %edx, %eax + je ..B5.63 +..B5.62: + movl $1, %eax + jmp ..B5.64 +..B5.63: + xorl %eax, %eax +..B5.64: + movl 100(%esp), %ecx + subl %eax, %ebx + movl 72(%esp), %eax + sbbl $0, %ebp + mull %ecx + movl %ecx, %eax + movl %edx, %esi + mull 80(%esp) + addl $-1, 84(%esp) + movl %edx, %ecx + adcl $-1, 96(%esp) + addl %eax, %esi + movl 72(%esp), %eax + adcl $0, %ecx + mull 104(%esp) + addl %esi, %eax + adcl %ecx, %edx + subl %esi, %eax + movl %edx, 40(%esp) + sbbl %ecx, %edx + jae ..B5.66 +..B5.65: + movl $1, %ecx + jmp ..B5.67 +..B5.66: + xorl %ecx, %ecx +..B5.67: + movl 104(%esp), %eax + mull 80(%esp) + addl %edx, %ecx + addl 40(%esp), %eax + movl %eax, 56(%esp) + movl 20(%esp), %eax + movl %eax, %esi + adcl $0, %ecx + subl 48(%esp), %esi + movl %esi, 24(%esp) + movl 16(%esp), %esi + movl %esi, %edx + sbbl %edi, %edx + movl 24(%esp), %edi + subl %eax, %edi + movl %edx, 28(%esp) + sbbl %esi, %edx + jb ..B5.69 +..B5.107: + orl %edx, %edi + je ..B5.69 +..B5.68: + movl $1, %eax + jmp ..B5.70 +..B5.69: + xorl %eax, %eax +..B5.70: + subl %eax, %ebx + movl 12(%esp), %esi + sbbl $0, %ebp + addl 64(%esp), %esi + movl 36(%esp), %edx + adcl 68(%esp), %edx + movl %esi, 12(%esp) + movl 72(%esp), %eax + movl 112(%esp), %esi + movl %edx, 36(%esp) + mull %esi + movl %esi, %eax + movl %edx, %edi + mull 80(%esp) + addl %eax, %edi + movl %edx, %esi + movl 72(%esp), %eax + adcl $0, %esi + mull 108(%esp) + addl %edi, %eax + adcl %esi, %edx + subl %edi, %eax + movl %edx, 44(%esp) + sbbl %esi, %edx + jae ..B5.72 +..B5.71: + movl $1, %esi + jmp ..B5.73 +..B5.72: + xorl %esi, %esi +..B5.73: + movl 80(%esp), %eax + mull 108(%esp) + addl %edx, %esi + addl 44(%esp), %eax + movl 24(%esp), %edi + adcl $0, %esi + movl %esi, 60(%esp) + movl %edi, %esi + subl 56(%esp), %esi + movl %esi, 100(%esp) + movl 28(%esp), %esi + movl %esi, %edx + sbbl %ecx, %edx + movl %edx, 104(%esp) + movl 100(%esp), %edx + subl %edi, %edx + movl 104(%esp), %ecx + sbbl %esi, %ecx + movl 60(%esp), %esi + jb ..B5.75 +..B5.108: + orl %ecx, %edx + je ..B5.75 +..B5.74: + movl $1, %edx + jmp ..B5.76 +..B5.75: + xorl %edx, %edx +..B5.76: + subl %edx, %ebx + sbbl $0, %ebp + subl %eax, %ebx + movl 12(%esp), %eax + sbbl %esi, %ebp + addl $16, 88(%esp) + movl %ebx, 112(%esp) + movl %ebp, 108(%esp) + orl 36(%esp), %eax + jne ..B5.49 +..B5.77: + movl %ebp, %esi + movl %ebx, %edx +..B5.78: + xorl %eax, %eax + movl 96(%esp), %ecx + subl %eax, %ecx + jl ..B5.100 +..B5.79: + movl %esi, 108(%esp) + movl %edx, 112(%esp) +..B5.80: + movl 108(%esp), %ebp + movl %ebp, %edx + movl 80(%esp), %ecx + movl 112(%esp), %edi + movl 72(%esp), %eax + imull %edi, %ecx + imull %eax, %edx + addl %edx, %ecx + mull %edi + movl 88(%esp), %esi + addl %ecx, %edx + movl %edx, 20(%esp) + movl %eax, 12(%esp) + movl %edi, %eax + movl 8(%esi), %ecx + movl 4(%esi), %edx + movl %ecx, 52(%esp) + movl 12(%esi), %ecx + movl (%esi), %ebx + movl 76(%esp), %esi + movl %edx, 40(%esp) + mull %esi + movl %edi, %eax + movl %ebx, 28(%esp) + movl %edx, %ebx + mull 92(%esp) + addl %eax, %ebx + movl %esi, %eax + movl %edx, %edi + adcl $0, %edi + mull %ebp + addl %ebx, %eax + movl %edx, %ebp + adcl %edi, %ebp + subl %ebx, %eax + movl %ebp, %ebx + sbbl %edi, %ebx + jae ..B5.82 +..B5.81: + movl $1, %ebx + jmp ..B5.83 +..B5.82: + xorl %ebx, %ebx +..B5.83: + movl 92(%esp), %eax + mull 108(%esp) + addl %edx, %ebx + addl %ebp, %eax + movl 28(%esp), %edi + movl %edi, %esi + adcl $0, %ebx + subl 12(%esp), %esi + movl 40(%esp), %ebp + movl %eax, 44(%esp) + movl %ebp, %eax + sbbl 20(%esp), %eax + movl %esi, 8(%esp) + subl %edi, %esi + movl %eax, 4(%esp) + sbbl %ebp, %eax + jb ..B5.85 +..B5.109: + orl %eax, %esi + je ..B5.85 +..B5.84: + movl $1, %eax + jmp ..B5.86 +..B5.85: + xorl %eax, %eax +..B5.86: + movl 72(%esp), %esi + subl %eax, 52(%esp) + movl %esi, %eax + movl 100(%esp), %ebp + sbbl $0, %ecx + mull %ebp + movl %ebp, %eax + movl %edx, %edi + mull 80(%esp) + addl $-1, 84(%esp) + movl %edx, %ebp + adcl $-1, 96(%esp) + addl %eax, %edi + movl %esi, %eax + adcl $0, %ebp + mull 104(%esp) + addl %edi, %eax + adcl %ebp, %edx + subl %edi, %eax + movl %edx, 36(%esp) + sbbl %ebp, %edx + jae ..B5.88 +..B5.87: + movl $1, %ebp + jmp ..B5.89 +..B5.88: + xorl %ebp, %ebp +..B5.89: + movl 104(%esp), %eax + mull 80(%esp) + addl %edx, %ebp + addl 36(%esp), %eax + movl 8(%esp), %edi + movl %eax, 48(%esp) + movl %edi, %eax + adcl $0, %ebp + subl 44(%esp), %eax + movl 4(%esp), %edx + movl %edx, %esi + sbbl %ebx, %esi + movl %eax, 16(%esp) + subl %edi, %eax + movl %esi, 24(%esp) + sbbl %edx, %esi + jb ..B5.91 +..B5.110: + orl %esi, %eax + je ..B5.91 +..B5.90: + movl $1, %eax + jmp ..B5.92 +..B5.91: + xorl %eax, %eax +..B5.92: + movl 72(%esp), %esi + subl %eax, 52(%esp) + movl %esi, %eax + movl 112(%esp), %ebx + sbbl $0, %ecx + mull %ebx + movl %ebx, %eax + movl %edx, %edi + mull 80(%esp) + addl %eax, %edi + movl %esi, %eax + movl %edx, %ebx + adcl $0, %ebx + mull 108(%esp) + addl %edi, %eax + adcl %ebx, %edx + subl %edi, %eax + movl %edx, 32(%esp) + sbbl %ebx, %edx + jae ..B5.94 +..B5.93: + movl $1, %ebx + jmp ..B5.95 +..B5.94: + xorl %ebx, %ebx +..B5.95: + movl 80(%esp), %eax + mull 108(%esp) + addl %edx, %ebx + addl 32(%esp), %eax + movl 16(%esp), %edi + movl %edi, %esi + adcl $0, %ebx + subl 48(%esp), %esi + movl %esi, 100(%esp) + movl 24(%esp), %esi + movl %esi, %edx + sbbl %ebp, %edx + movl 100(%esp), %ebp + subl %edi, %ebp + movl %edx, 104(%esp) + sbbl %esi, %edx + jb ..B5.97 +..B5.111: + orl %edx, %ebp + je ..B5.97 +..B5.96: + movl $1, %edx + jmp ..B5.98 +..B5.97: + xorl %edx, %edx +..B5.98: + movl 52(%esp), %ebp + subl %edx, %ebp + movl 96(%esp), %edx + sbbl $0, %ecx + subl %eax, %ebp + sbbl %ebx, %ecx + xorl %eax, %eax + addl $16, 88(%esp) + movl %ebp, 112(%esp) + subl %eax, %edx + movl %ecx, 108(%esp) + jge ..B5.80 +..B5.99: + movl %ecx, %esi + movl %ebp, %edx +..B5.100: + movl (%esp), %ebx + movl 100(%esp), %eax + movl 104(%esp), %ecx + movl %edx, 8(%ebx) + xorl %edx, %edx + movl %eax, 16(%ebx) + movl %ecx, 20(%ebx) + movl %esi, 12(%ebx) + movl %edx, 4(%ebx) + movl %edx, (%ebx) + addl $124, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B5.102: + movl %edx, 100(%esp) + movl %edi, 88(%esp) + movl %esi, 96(%esp) + movl 16(%esp), %edx + movl 68(%esp), %edi + movl 64(%esp), %eax + jmp ..B5.28 + .align 16,0x90 + .type __eval_neg_poly,@function + .size __eval_neg_poly,.-__eval_neg_poly + .data +# -- End __eval_neg_poly + .text +# -- Begin __eval_pos_poly + .text + .align 16,0x90 +__eval_pos_poly: +# parameter 1: %eax +# parameter 2: 180 + %esp +# parameter 3: %edx +# parameter 4: 192 + %esp +# parameter 5: %ecx +..B6.1: +..L13: + + movl 4(%esp), %eax + movl 16(%esp), %edx + movl 28(%esp), %ecx +__eval_pos_poly.: + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $156, %esp + movl 192(%esp), %esi + movl %esi, 84(%esp) + movl 8(%eax), %esi + movl %esi, 68(%esp) + movl 12(%eax), %esi + movl %esi, 72(%esp) + movl 16(%eax), %esi + movl %esi, 76(%esp) + movl 20(%eax), %esi + movl %esi, 80(%esp) + xorl %esi, %esi + movl %ecx, 48(%esp) + xorl %ecx, %ecx + movl 196(%esp), %edi + movl 4(%eax), %eax + subl %eax, %ecx + movl %edx, 64(%esp) + cltd + movl %edi, 140(%esp) + movl %esi, %edi + movl 180(%esp), %ebx + sbbl %edx, %edi + movl %eax, 148(%esp) + movl $128, %eax + movl %edx, 144(%esp) + movl %ebx, %edx + subl %eax, %edx + movl 184(%esp), %ebp + movl %ebp, %edx + sbbl %esi, %edx + jge ..B6.3 +..B6.2: + movl $1, %edx + jmp ..B6.4 +..B6.3: + xorl %edx, %edx +..B6.4: + testl %edx, %edx + jne ..B6.8 +..B6.5: + movl %edi, 8(%esp) + movl %ecx, 12(%esp) + movl 140(%esp), %esi + movl 84(%esp), %eax + movl 64(%esp), %edx +..B6.6: + addl 148(%esp), %ebx + movl %ebx, %ecx + adcl 144(%esp), %ebp + movl $128, %edi + addl $-1, %eax + adcl $-1, %esi + addl $16, %edx + subl %edi, %ecx + movl $0, %edi + movl %ebp, %ecx + sbbl %edi, %ecx + jge ..B6.6 +..B6.7: + movl %esi, 140(%esp) + movl %eax, 84(%esp) + movl %edx, 64(%esp) + movl 8(%esp), %edi + movl 12(%esp), %ecx +..B6.8: + movl $64, %eax + movl %ebx, %edx + xorl %esi, %esi + subl %eax, %edx + movl %ebp, %edx + sbbl %esi, %edx + jge ..B6.10 +..B6.9: + movl $1, %edx + jmp ..B6.11 +..B6.10: + xorl %edx, %edx +..B6.11: + testl %edx, %edx + je ..B6.13 +..B6.12: + xorl %edx, %edx + xorl %esi, %esi + movl %esi, 88(%esp) + movl %esi, 96(%esp) + jmp ..B6.31 +..B6.13: + movl %edi, 8(%esp) + movl %ecx, 12(%esp) + movl 140(%esp), %edx + movl 64(%esp), %esi +..B6.14: + movl 8(%esi), %edi + lea -64(%ebx), %ecx + movl 12(%esi), %eax + cmpl $31, %ecx + jbe ..B6.16 +..B6.15: + movl %eax, %edi + movl $0, 96(%esp) + shrl %cl, %edi + jmp ..B6.17 +..B6.16: + shrdl %cl, %eax, %edi + shrl %cl, %eax + movl %eax, 96(%esp) +..B6.17: + addl 148(%esp), %ebx + movl %ebx, %ecx + adcl 144(%esp), %ebp + movl $64, %eax + addl $16, %esi + addl $-1, 84(%esp) + adcl $-1, %edx + subl %eax, %ecx + movl $0, %eax + movl %ebp, %ecx + sbbl %eax, %ecx + jl ..B6.126 +..B6.18: + movl %edi, %eax + orl 96(%esp), %eax + je ..B6.14 +..B6.19: + movl %edi, 88(%esp) + movl %ebx, 60(%esp) + movl %ebp, 56(%esp) + movl %edx, 140(%esp) + movl %esi, 64(%esp) + movl 96(%esp), %ebx + movl 88(%esp), %ebp +..B6.20: + movl 68(%esp), %esi + movl %esi, %eax + mull %ebp + movl %ebp, %eax + movl %edx, %ecx + mull 72(%esp) + addl %eax, %ecx + movl %esi, %eax + movl %edx, %edi + adcl $0, %edi + mull %ebx + addl %ecx, %eax + movl %edx, %ebp + adcl %edi, %ebp + subl %ecx, %eax + movl %ebp, %edx + sbbl %edi, %edx + jae ..B6.22 +..B6.21: + movl $1, %esi + jmp ..B6.23 +..B6.22: + xorl %esi, %esi +..B6.23: + movl 72(%esp), %eax + mull %ebx + movl 64(%esp), %ecx + addl %edx, %esi + movl 60(%esp), %ebx + addl %ebp, %eax + movl 8(%ecx), %ebp + adcl $0, %esi + movl 12(%ecx), %edx + lea -64(%ebx), %ecx + cmpl $31, %ecx + jbe ..B6.25 +..B6.24: + movl %edx, %ebp + xorl %ebx, %ebx + shrl %cl, %ebp + jmp ..B6.26 +..B6.25: + movl %edx, %ebx + shrdl %cl, %edx, %ebp + shrl %cl, %ebx +..B6.26: + movl 60(%esp), %ecx + movl $64, %edi + addl 148(%esp), %ecx + movl 56(%esp), %edx + adcl 144(%esp), %edx + addl $-1, 84(%esp) + movl %ecx, 60(%esp) + adcl $-1, 140(%esp) + addl %eax, %ebp + movl %edx, 56(%esp) + adcl %esi, %ebx + addl $16, 64(%esp) + subl %edi, %ecx + movl $0, %edi + sbbl %edi, %edx + jge ..B6.20 +..B6.27: + movl %ebp, 88(%esp) + movl %ebp, %edx + subl %eax, %edx + movl %ebx, 96(%esp) + movl %ebx, %eax + movl 60(%esp), %ebx + sbbl %esi, %eax + movl 56(%esp), %ebp + movl 8(%esp), %edi + movl 12(%esp), %ecx + jae ..B6.29 +..B6.28: + movl $1, %edx + jmp ..B6.30 +..B6.29: + xorl %edx, %edx +..B6.30: + xorl %esi, %esi +..B6.31: + movl %esi, 92(%esp) + xorl %esi, %esi + xorl %eax, %eax + subl %ebx, %eax + movl %eax, 4(%esp) + movl %ebx, %eax + sbbl %ebp, %esi + movl %esi, (%esp) + orl %ebp, %eax + movl 92(%esp), %esi + je ..B6.54 +..B6.32: + xorl %eax, %eax + orl %edx, %eax + jne ..B6.52 +..B6.33: + movl %edi, 8(%esp) + movl %ebp, 56(%esp) + movl %ecx, 12(%esp) + movl 96(%esp), %esi + movl 88(%esp), %edi +..B6.34: + movl 68(%esp), %eax + mull %edi + movl %edi, %eax + movl %edx, %ebp + mull 72(%esp) + addl %eax, %ebp + movl %edx, %ecx + movl 68(%esp), %eax + adcl $0, %ecx + mull %esi + addl %ebp, %eax + movl %edx, %edi + adcl %ecx, %edi + subl %ebp, %eax + movl %edi, %edx + sbbl %ecx, %edx + jae ..B6.36 +..B6.35: + movl $1, %ebp + jmp ..B6.37 +..B6.36: + xorl %ebp, %ebp +..B6.37: + movl 72(%esp), %eax + mull %esi + movl 64(%esp), %esi + addl %edx, %ebp + addl %edi, %eax + movl %eax, 28(%esp) + movl 12(%esi), %edi + adcl $0, %ebp + movl %edi, 16(%esp) + cmpl $31, %ebx + movl 8(%esi), %edx + movl (%esi), %edi + movl 4(%esi), %eax + jbe ..B6.39 +..B6.38: + movl %ebx, %ecx + movl %eax, %edi + shrl %cl, %edi + xorl %esi, %esi + jmp ..B6.40 +..B6.39: + movl %ebx, %ecx + movl %eax, %esi + shrdl %cl, %eax, %edi + shrl %cl, %esi +..B6.40: + movl 4(%esp), %eax + lea 64(%eax), %ecx + cmpl $31, %ecx + jbe ..B6.42 +..B6.41: + movl %edx, %eax + shll %cl, %eax + movl $0, 20(%esp) + movl %eax, 24(%esp) + jmp ..B6.43 +..B6.42: + movl 16(%esp), %eax + shldl %cl, %edx, %eax + movl %eax, 24(%esp) + movl %edx, %eax + shll %cl, %eax + movl %eax, 20(%esp) +..B6.43: + orl 20(%esp), %edi + orl 24(%esp), %esi + cmpl $31, %ebx + jbe ..B6.45 +..B6.44: + movl %ebx, %ecx + movl 16(%esp), %edx + movl $0, 92(%esp) + shrl %cl, %edx + jmp ..B6.46 +..B6.45: + movl %ebx, %ecx + movl 16(%esp), %eax + shrdl %cl, %eax, %edx + shrl %cl, %eax + movl %eax, 92(%esp) +..B6.46: + movl 4(%esp), %eax + addl 12(%esp), %eax + movl (%esp), %ecx + adcl 8(%esp), %ecx + addl 148(%esp), %ebx + movl %eax, 4(%esp) + movl 56(%esp), %eax + adcl 144(%esp), %eax + addl $-1, 84(%esp) + movl %ecx, (%esp) + movl 28(%esp), %ecx + adcl $-1, 140(%esp) + addl %ecx, %edi + movl %eax, 56(%esp) + movl %edi, %eax + adcl %ebp, %esi + addl $16, 64(%esp) + subl %ecx, %eax + movl %esi, %ecx + sbbl %ebp, %ecx + jae ..B6.48 +..B6.47: + movl $1, %ebp + jmp ..B6.49 +..B6.48: + xorl %ebp, %ebp +..B6.49: + addl %ebp, %edx + movl %ebx, %ebp + adcl $0, 92(%esp) + orl 56(%esp), %ebp + je ..B6.123 +..B6.50: + movl %edx, %ebp + orl 92(%esp), %ebp + je ..B6.34 +..B6.51: + movl %esi, 96(%esp) + movl %edi, 88(%esp) + movl 56(%esp), %ebp + movl 92(%esp), %esi +..B6.52: + xorl %eax, %eax + movl 140(%esp), %edi + subl %eax, %edi + jge ..B6.124 +..B6.53: + movl 48(%esp), %ebp + movl 88(%esp), %ecx + movl 96(%esp), %ebx + movl %ecx, 16(%ebp) + movl %ebx, 20(%ebp) + movl %edx, 8(%ebp) + movl %esi, 12(%ebp) + movl %eax, 4(%ebp) + movl $0, (%ebp) + addl $156, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B6.54: + xorl %eax, %eax + movl %esi, 92(%esp) + movl %eax, 52(%esp) + movl %edx, 112(%esp) +..B6.55: + xorl %eax, %eax + movl 140(%esp), %edx + subl %eax, %edx + jl ..B6.125 +..B6.56: + movl 92(%esp), %esi + movl %esi, %ebp + movl 112(%esp), %ecx + movl 68(%esp), %eax + imull %eax, %ebp + mull %ecx + movl 72(%esp), %edi + imull %ecx, %edi + addl %ebp, %edi + movl %edx, %ebp + movl 64(%esp), %edx + addl %edi, %ebp + movl %eax, 104(%esp) + movl %ecx, %eax + movl 8(%edx), %edi + movl 12(%edx), %ebx + movl %edi, 100(%esp) + movl %ebx, 108(%esp) + movl (%edx), %edi + movl 4(%edx), %ebx + mull 76(%esp) + movl %ecx, %eax + movl %ebx, 136(%esp) + movl %edx, %ebx + mull 80(%esp) + addl %eax, %ebx + movl %edx, %ecx + movl 76(%esp), %eax + adcl $0, %ecx + mull %esi + addl %ebx, %eax + adcl %ecx, %edx + subl %ebx, %eax + movl %edx, 128(%esp) + movl 136(%esp), %ebx + sbbl %ecx, %edx + jae ..B6.58 +..B6.57: + movl $1, %ecx + jmp ..B6.59 +..B6.58: + xorl %ecx, %ecx +..B6.59: + movl 80(%esp), %eax + mull 92(%esp) + addl %edx, %ecx + addl 128(%esp), %eax + movl 104(%esp), %esi + adcl $0, %ecx + addl %esi, %edi + movl %eax, 132(%esp) + movl %edi, %eax + adcl %ebp, %ebx + subl %esi, %eax + movl %ebx, %edx + sbbl %ebp, %edx + jae ..B6.61 +..B6.60: + movl $1, 116(%esp) + jmp ..B6.62 +..B6.61: + movl $0, 116(%esp) +..B6.62: + movl 68(%esp), %eax + movl 88(%esp), %ebp + mull %ebp + movl %ebp, %eax + movl %edx, %esi + mull 72(%esp) + addl $-1, 84(%esp) + movl %edx, %ebp + adcl $-1, 140(%esp) + addl %eax, %esi + movl 68(%esp), %eax + adcl $0, %ebp + mull 96(%esp) + addl %esi, %eax + adcl %ebp, %edx + subl %esi, %eax + movl %edx, 124(%esp) + sbbl %ebp, %edx + jae ..B6.64 +..B6.63: + movl $1, %ebp + jmp ..B6.65 +..B6.64: + xorl %ebp, %ebp +..B6.65: + movl 96(%esp), %eax + mull 72(%esp) + movl %eax, %esi + addl %edx, %ebp + addl 124(%esp), %esi + movl 132(%esp), %eax + adcl $0, %ebp + addl %eax, %edi + movl %edi, %edx + adcl %ecx, %ebx + subl %eax, %edx + movl %ebx, %eax + sbbl %ecx, %eax + jae ..B6.67 +..B6.66: + movl $1, %eax + jmp ..B6.68 +..B6.67: + xorl %eax, %eax +..B6.68: + movl 112(%esp), %ecx + addl %eax, 116(%esp) + movl %ecx, %eax + mull 68(%esp) + movl %ecx, %eax + movl %ebx, 136(%esp) + movl %edx, %ebx + mull 72(%esp) + addl %eax, %ebx + movl %edx, %ecx + movl 68(%esp), %eax + adcl $0, %ecx + mull 92(%esp) + addl %ebx, %eax + adcl %ecx, %edx + subl %ebx, %eax + movl %edx, 120(%esp) + movl 136(%esp), %ebx + sbbl %ecx, %edx + jae ..B6.70 +..B6.69: + movl $1, %ecx + jmp ..B6.71 +..B6.70: + xorl %ecx, %ecx +..B6.71: + movl 72(%esp), %eax + mull 92(%esp) + addl %edx, %ecx + addl 120(%esp), %eax + adcl $0, %ecx + addl %esi, %edi + movl %edi, 88(%esp) + adcl %ebp, %ebx + subl %esi, %edi + movl %ebx, 96(%esp) + sbbl %ebp, %ebx + jae ..B6.73 +..B6.72: + movl $1, %edx + jmp ..B6.74 +..B6.73: + xorl %edx, %edx +..B6.74: + movl 116(%esp), %ebx + xorl %esi, %esi + addl %edx, %ebx + movl 100(%esp), %edx + addl %ebx, %edx + movl 108(%esp), %ebp + adcl $0, %ebp + movl %edx, 100(%esp) + subl %ebx, %edx + movl %ebp, 108(%esp) + sbbl %esi, %ebp + jae ..B6.76 +..B6.75: + movl $1, %edx + jmp ..B6.77 +..B6.76: + xorl %edx, %edx +..B6.77: + movl %eax, %ebx + movl %ecx, %ebp + addl 100(%esp), %ebx + movl %ebx, 112(%esp) + adcl 108(%esp), %ebp + addl $16, 64(%esp) + subl %eax, %ebx + movl %ebp, 92(%esp) + sbbl %ecx, %ebp + jae ..B6.79 +..B6.78: + movl $1, %eax + jmp ..B6.80 +..B6.79: + xorl %eax, %eax +..B6.80: + addl %eax, %edx + xorl %eax, %eax + orl %eax, %edx + je ..B6.55 +..B6.81: + movl 96(%esp), %ebx + movl %ebx, %eax + movl 112(%esp), %esi + movl %esi, %ecx + movl 92(%esp), %edi + movl %edi, %ebp + movl 88(%esp), %edx + shll $31, %eax + shrl $1, %edx + shrl $1, %ebx + orl %eax, %edx + shll $31, %ecx + xorl %eax, %eax + shll $31, %ebp + orl %ecx, %ebx + shrl $1, %edi + shrl $1, %esi + orl $-2147483648, %edi + movl %edx, 88(%esp) + orl %ebp, %esi + incl 52(%esp) + movl 140(%esp), %edx + movl %ebx, 96(%esp) + subl %eax, %edx + movl %esi, 112(%esp) + movl %edi, 92(%esp) + jge ..B6.83 +..B6.82: + movl %edi, %esi + movl 52(%esp), %eax + movl 112(%esp), %edx + jmp ..B6.53 +..B6.83: + movl $1, %ebx + xorl %ebp, %ebp +..B6.129: + movl %ebx, 60(%esp) + movl %ebp, 56(%esp) + movl 92(%esp), %esi +..B6.84: + movl %esi, %ecx + movl 72(%esp), %ebx + movl 112(%esp), %ebp + movl 68(%esp), %eax + imull %ebp, %ebx + imull %eax, %ecx + mull %ebp + addl %ecx, %ebx + addl %ebx, %edx + movl %edx, 8(%esp) + movl 64(%esp), %edx + movl %eax, (%esp) + cmpl $31, 60(%esp) + movl 8(%edx), %edi + movl 12(%edx), %eax + movl (%edx), %ebx + movl 4(%edx), %edx + movl %edi, 24(%esp) + jbe ..B6.86 +..B6.85: + movl %edx, %ebx + xorl %ebp, %ebp + movl 60(%esp), %ecx + shrl %cl, %ebx + jmp ..B6.87 +..B6.86: + movl %edx, %ebp + movl 60(%esp), %ecx + shrdl %cl, %edx, %ebx + shrl %cl, %ebp +..B6.87: + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B6.89 +..B6.88: + xorl %edx, %edx + shll %cl, %edi + movl %edi, 44(%esp) + jmp ..B6.90 +..B6.89: + movl %eax, %edi + movl 24(%esp), %edx + shldl %cl, %edx, %edi + movl %edi, 44(%esp) + shll %cl, %edx +..B6.90: + orl 44(%esp), %ebp + orl %edx, %ebx + cmpl $31, 60(%esp) + jbe ..B6.92 +..B6.91: + movl 60(%esp), %ecx + shrl %cl, %eax + movl $0, 4(%esp) + movl %eax, 24(%esp) + jmp ..B6.93 +..B6.92: + movl 60(%esp), %ecx + movl 24(%esp), %edx + shrdl %cl, %eax, %edx + shrl %cl, %eax + movl %edx, 24(%esp) + movl %eax, 4(%esp) +..B6.93: + movl 112(%esp), %ecx + movl %ecx, %eax + mull 76(%esp) + movl %ecx, %eax + movl %edx, %edi + mull 80(%esp) + addl %eax, %edi + movl %edx, %ecx + movl 76(%esp), %eax + adcl $0, %ecx + mull %esi + addl %edi, %eax + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 40(%esp) + sbbl %ecx, %edx + jae ..B6.95 +..B6.94: + movl $1, %edi + jmp ..B6.96 +..B6.95: + xorl %edi, %edi +..B6.96: + movl 80(%esp), %eax + mull %esi + addl %edx, %edi + addl 40(%esp), %eax + movl %eax, 32(%esp) + movl (%esp), %eax + adcl $0, %edi + addl %eax, %ebx + movl %ebx, %edx + movl 8(%esp), %ecx + adcl %ecx, %ebp + subl %eax, %edx + movl %ebp, %eax + sbbl %ecx, %eax + jae ..B6.98 +..B6.97: + movl $1, 12(%esp) + jmp ..B6.99 +..B6.98: + movl $0, 12(%esp) +..B6.99: + movl 68(%esp), %eax + movl 88(%esp), %ecx + mull %ecx + movl %ecx, %eax + movl %ebp, 36(%esp) + movl %edx, %ebp + mull 72(%esp) + addl $-1, 84(%esp) + movl %edx, %ecx + adcl $-1, 140(%esp) + addl %eax, %ebp + movl 68(%esp), %eax + adcl $0, %ecx + mull 96(%esp) + addl %ebp, %eax + adcl %ecx, %edx + subl %ebp, %eax + movl %edx, 16(%esp) + movl 36(%esp), %ebp + sbbl %ecx, %edx + jae ..B6.101 +..B6.100: + movl $1, %ecx + jmp ..B6.102 +..B6.101: + xorl %ecx, %ecx +..B6.102: + movl 96(%esp), %eax + mull 72(%esp) + addl %edx, %ecx + addl 16(%esp), %eax + movl %eax, 28(%esp) + movl 32(%esp), %eax + adcl $0, %ecx + addl %eax, %ebx + movl %ebx, %edx + adcl %edi, %ebp + subl %eax, %edx + movl %ebp, %eax + sbbl %edi, %eax + jae ..B6.104 +..B6.103: + movl $1, %eax + jmp ..B6.105 +..B6.104: + xorl %eax, %eax +..B6.105: + movl %ebp, 36(%esp) + movl 60(%esp), %ebp + addl 148(%esp), %ebp + movl 56(%esp), %edx + movl %ebp, 60(%esp) + adcl 144(%esp), %edx + movl 112(%esp), %ebp + addl %eax, 12(%esp) + movl %ebp, %eax + movl %edx, 56(%esp) + mull 68(%esp) + movl %ebp, %eax + movl %edx, %edi + mull 72(%esp) + addl %eax, %edi + movl %edx, %ebp + movl 68(%esp), %eax + adcl $0, %ebp + mull %esi + addl %edi, %eax + adcl %ebp, %edx + subl %edi, %eax + movl %edx, 20(%esp) + sbbl %ebp, %edx + movl 36(%esp), %ebp + jae ..B6.107 +..B6.106: + movl $1, %edi + jmp ..B6.108 +..B6.107: + xorl %edi, %edi +..B6.108: + movl 72(%esp), %eax + mull %esi + addl %edx, %edi + addl 20(%esp), %eax + movl 28(%esp), %esi + adcl $0, %edi + addl %esi, %ebx + movl %ebx, 88(%esp) + adcl %ecx, %ebp + subl %esi, %ebx + movl %ebp, 96(%esp) + sbbl %ecx, %ebp + jae ..B6.110 +..B6.109: + movl $1, %edx + jmp ..B6.111 +..B6.110: + xorl %edx, %edx +..B6.111: + movl 12(%esp), %ecx + xorl %ebp, %ebp + addl %edx, %ecx + movl 24(%esp), %edx + addl %ecx, %edx + movl 4(%esp), %ebx + adcl $0, %ebx + movl %edx, 24(%esp) + subl %ecx, %edx + movl %ebx, 4(%esp) + sbbl %ebp, %ebx + jae ..B6.113 +..B6.112: + movl $1, %edx + jmp ..B6.114 +..B6.113: + xorl %edx, %edx +..B6.114: + movl %eax, %ecx + movl %edi, %esi + addl 24(%esp), %ecx + movl %ecx, 112(%esp) + adcl 4(%esp), %esi + addl $16, 64(%esp) + subl %eax, %ecx + movl %esi, %eax + sbbl %edi, %eax + jae ..B6.116 +..B6.115: + movl $1, %eax + jmp ..B6.117 +..B6.116: + xorl %eax, %eax +..B6.117: + addl %eax, %edx + xorl %eax, %eax + orl %eax, %edx + je ..B6.119 +..B6.118: + movl 96(%esp), %ebx + movl %ebx, %eax + movl 112(%esp), %edi + movl %edi, %ecx + movl %esi, %ebp + addl $1, 60(%esp) + movl 88(%esp), %edx + adcl $0, 56(%esp) + shll $31, %eax + shrl $1, %ebx + shrl $1, %edx + shll $31, %ecx + orl %eax, %edx + shll $31, %ebp + orl %ecx, %ebx + shrl $1, %edi + shrl $1, %esi + orl %ebp, %edi + incl 52(%esp) + orl $-2147483648, %esi + movl %edx, 88(%esp) + movl %ebx, 96(%esp) + movl %edi, 112(%esp) +..B6.119: + movl 60(%esp), %eax + orl 56(%esp), %eax + je ..B6.122 +..B6.120: + xorl %eax, %eax + movl 140(%esp), %edx + subl %eax, %edx + jge ..B6.84 +..B6.121: + movl 52(%esp), %eax + movl 112(%esp), %edx + jmp ..B6.53 +..B6.122: + movl %esi, 92(%esp) + jmp ..B6.55 +..B6.123: + movl %esi, 96(%esp) + movl %edi, 88(%esp) + movl 92(%esp), %esi + jmp ..B6.54 +..B6.124: + movl %esi, 92(%esp) + movl %eax, 52(%esp) + movl %edx, 112(%esp) + jmp ..B6.129 +..B6.125: + movl 92(%esp), %esi + movl 52(%esp), %eax + movl 112(%esp), %edx + jmp ..B6.53 +..B6.126: + movl %edx, 140(%esp) + xorl %edx, %edx + movl %edi, 88(%esp) + movl %esi, 64(%esp) + xorl %esi, %esi + movl 8(%esp), %edi + movl 12(%esp), %ecx + jmp ..B6.31 + .align 16,0x90 + .type __eval_pos_poly,@function + .size __eval_pos_poly,.-__eval_pos_poly + .data +# -- End __eval_pos_poly + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x7b,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xef,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x47,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc3,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3d,0x40,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .align 4 +__ux_one__: + .long 0 + .long 1 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .type __ux_one__,@object + .size __ux_one__,24 + .data + .hidden __dpml_ffs_and_shift__ + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/dpml_ux_sqrt.S b/external/sgx_libm/ia32/dpml_ux_sqrt.S new file mode 100644 index 0000000000..e1b2ac2e06 --- /dev/null +++ b/external/sgx_libm/ia32/dpml_ux_sqrt.S @@ -0,0 +1,1321 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_sqrt.c" + .text +..TXTST0: +# -- Begin __dpml_ux_sqrt_evaluation__ + .text + .align 16,0x90 + .hidden __dpml_ux_sqrt_evaluation__ + .globl __dpml_ux_sqrt_evaluation__ +__dpml_ux_sqrt_evaluation__: +# parameter 1: %eax +# parameter 2: 12 + %ebp +# parameter 3: %edx +..B1.1: +..L1: + + movl 4(%esp), %eax + movl 16(%esp), %edx + .hidden __dpml_ux_sqrt_evaluation__. + .globl __dpml_ux_sqrt_evaluation__. +__dpml_ux_sqrt_evaluation__.: + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $148, %esp + movl %edx, %esi + movl %eax, 44(%esp) + movl %gs:20, %ecx + xorl %esp, %ecx + movl %ecx, 136(%esp) + addl $4, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea 80(%esp), %eax + pushl %eax + call fegetenv@PLT +..B1.2: + movl 44(%esp), %edx + movl %ebx, 80(%esp) + movl %esi, 40(%esp) + movl 8(%edx), %edi + movl %edi, %ecx + movl 12(%edx), %eax + movl %eax, %ebx + shll $21, %ebx + shrl $11, %ecx + orl %ecx, %ebx + movl 4(%edx), %ecx + movl 20(%edx), %esi + movl %ecx, %edx + andl $1, %edx + movl %esi, 36(%esp) + movl %eax, %esi + shrl $11, %esi + addl %edx, %ecx + addl $1070596096, %esi + movl %esi, 68(%esp) + lea 8(%edx), %esi + movl %esi, 32(%esp) + negl %esi + sarl $1, %ecx + movl %ecx, 72(%esp) + movl %esi, %ecx + negl %ecx + movl %ebx, 64(%esp) + addl $31, %ecx + movl %edi, %ebx + shrl %cl, %ebx + movl %esi, %ecx + movl %eax, 76(%esp) + shrl $1, %ebx + shll %cl, %eax + shll %cl, %edi + orl %ebx, %eax + movl 80(%esp), %ebx + movl 40(%esp), %esi +..B1.3: + movl 32(%esp), %ecx + shrl %cl, 36(%esp) +..B1.5: + fldl 64(%esp) + movl %eax, %ecx + orl 36(%esp), %edi + shll $21, %ecx + shrl $11, %edi + shrl $11, %eax + orl %edi, %ecx + movl %ecx, 48(%esp) + movl %eax, 52(%esp) + fildll 48(%esp) + fstpl 56(%esp) + fldl 56(%esp) +..B1.6: + movl 32(%esp), %ecx + movl 76(%esp), %eax + shrl %cl, %eax +..B1.8: + fmull 136+__sqrt_x_table@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + movl 76(%esp), %ecx + shrl $24, %ecx + shll $7, %edx + xorl %edx, %ecx + shll $4, %ecx + movl __sqrt_t_table@GOT(%ebx), %edx + movl %eax, 48(%esp) + fildl 48(%esp) + fstpl 56(%esp) + fldl 56(%esp) + fmull 128+__sqrt_x_table@GOTOFF(%ebx) + fstpl 56(%esp) + fldl 56(%esp) + fxch %st(2) + fstpl 56(%esp) + fldl 56(%esp) + fld %st(0) + movl %ebx, 80(%esp) + fadd %st(3), %st + fxch %st(2) + fmuls (%edx,%ecx) + flds 4(%edx,%ecx) + fmulp %st, %st(5) + fxch %st(4) + faddl 8(%edx,%ecx) + faddp %st, %st(4) + fxch %st(3) + fstpl 56(%esp) + fldl 56(%esp) + fmull 96+__sqrt_x_table@GOTOFF(%ebx) + fstpl 56(%esp) + fldl 56(%esp) + fxch %st(1) + fstpl 56(%esp) + fldl 56(%esp) + fld %st(0) + fmul %st(2), %st + fstps 48(%esp) + flds 48(%esp) + fxch %st(2) + fstps 48(%esp) + flds 48(%esp) + fmul %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fld %st(3) + fmulp %st, %st(2) + fldl 152+__sqrt_x_table@GOTOFF(%ebx) + fmulp %st, %st(3) + fld %st(3) + fmul %st(4), %st + fmulp %st, %st(3) + fxch %st(1) + fsubrl 104+__sqrt_x_table@GOTOFF(%ebx) + fsubp %st, %st(1) + fstpl 56(%esp) + fldl 56(%esp) + fldl 112+__sqrt_x_table@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + fsubrl 144+__sqrt_x_table@GOTOFF(%ebx) + fmulp %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpl 56(%esp) + fldl 56(%esp) + flds .L_2il0floatpacket.20@GOTOFF(%ebx) + fld %st(0) + fsubr %st(3), %st + fxch %st(1) + fcomp %st(3) + fnstsw %ax + fxch %st(1) + fmull 120+__sqrt_x_table@GOTOFF(%ebx) + sahf + fxch %st(2) + jp ..L4 + jbe ..L3 +..L4: + fst %st(1) +..L3: + fstp %st(0) + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 64(%esp) + fldcw 32(%esp) + movl 64(%esp), %edx + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 64(%esp) + fldcw 32(%esp) + shll $7, %edx + movl 64(%esp), %ecx + movl %ecx, %ebx + movl 68(%esp), %edi + movl %edi, %eax + shll $20, %eax + shrl $12, %ebx + shrl $11, %ecx + orl %ebx, %eax + sarl $12, %edi + andl $1, %ecx + addl %edi, %edx + addl %ecx, %eax + adcl $0, %edx + xorl %ebx, %ebx + movl %edx, %ecx + andl $1073741824, %ecx + orl %ebx, %ecx + movl 80(%esp), %ebx + je ..B1.10 +..B1.9: + movl $2147483647, 32(%esp) + jmp ..B1.11 +..B1.10: + movl $-1, 32(%esp) +..B1.11: + movl %edx, %edi + xorl %ecx, %ecx + subl %ecx, %edi + jl ..B1.13 +..B1.12: + movl 32(%esp), %edx + movl $-1, %eax +..B1.13: + movl 72(%esp), %ecx + xorl %edi, %edi + negl %ecx + incl %ecx + movl %edi, 48(%esp) + movl %ecx, 52(%esp) + movl %eax, 56(%esp) + movl %edx, 60(%esp) + movl %edi, 64(%esp) + movl %edi, 68(%esp) + addl $12, %esp + lea 100(%esp), %eax + lea 36(%esp), %edx + pushl %eax + pushl 36(%esp) + pushl %edx + call __dpml_multiply__ +..B1.14: + addl $12, %esp + pushl %esi + lea 104(%esp), %eax + pushl %eax + lea 44(%esp), %edx + pushl %edx + call __dpml_multiply__ +..B1.15: + addl $20, %esp + lea 160+__sqrt_x_table@GOTOFF(%ebx), %eax + pushl %esi + pushl $0 + pushl $9 + pushl %esi + pushl %eax + call __dpml_addsub__ +..B1.16: + movl 12(%ebp), %edx + andl $1, %edx + orl %edi, %edx + je ..B1.18 +..B1.17: + lea 112(%esp), %eax + jmp ..B1.19 +..B1.18: + lea 48(%esp), %eax +..B1.19: + addl $12, %esp + pushl %esi + pushl %eax + pushl %esi + call __dpml_multiply__ +..B1.20: + addl $4, %esp + decl 4(%esi) + lea 80(%esp), %eax + pushl %eax + call fesetenv@PLT +..B1.21: + movl 12(%ebp), %edx + xorl %eax, %eax + andl $2, %edx + orl %eax, %edx + jne ..B1.26 +..B1.23: + movl 136(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.25 +..B1.24: + xorl %edx, %edx + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + call __stack_chk_fail@PLT +..B1.26: + addl $12, %esp + pushl %eax + pushl %eax + pushl %esi + call __dpml_ffs_and_shift__ +..B1.27: + movl 16(%esi), %edx + xorl %ecx, %ecx + movl 20(%esi), %eax + movl %edx, 40(%esp) + movl %eax, 36(%esp) + lea 8(%edx), %edi + andl $16368, %edi + orl %ecx, %edi + je ..B1.29 +..B1.28: + xorl %eax, %eax + jmp ..B1.23 +..B1.29: + lea 48(%esp), %edi + pushl %edi + lea 116(%esp), %eax + pushl %eax + pushl %esi + pushl %esi + movl %edx, %edi + andl $-32768, %edi + movl %edi, -72(%eax) + addl $16384, %edi + movl -76(%eax), %edx + adcl $0, %edx + movl %edx, -80(%eax) + movl %edi, 16(%esi) + movl %edx, 20(%esi) + call __dpml_extended_multiply__ +..B1.30: + addl $36, %esp + lea 92(%esp), %eax + pushl %eax + pushl $0 + pushl $1 + pushl %eax + pushl 40(%esp) + call __dpml_addsub__ +..B1.31: + addl $20, %esp + lea 92(%esp), %edx + pushl %edx + pushl $0 + pushl $1 + lea 40(%esp), %eax + pushl %eax + pushl %edx + call __dpml_addsub__ +..B1.32: + movl 112(%esp), %eax + testl %eax, %eax + movl 32(%esp), %edx + je ..L5 + movl 40(%esp), %edi +..L5: + je ..L6 + movl 36(%esp), %edx +..L6: + xorl %ecx, %ecx + movl %edi, 16(%esi) + movl 12(%ebp), %edi + andl $4, %edi + movl %edx, 20(%esi) + orl %ecx, %edi + je ..B1.28 +..B1.33: + movl 4(%esi), %edx + testl %eax, %eax + movl $0, %eax + sete %al + addl $-113, %edx + subl %edx, 116(%esp) + addl $20, %esp + orl $8, %eax + lea 92(%esp), %ecx + pushl %ecx + pushl $0 + pushl %eax + pushl %esi + pushl %ecx + call __dpml_addsub__ +..B1.34: + movl $8192, %eax + movl 128(%esp), %edx + subl %eax, %edx + orl 132(%esp), %edx + jne ..B1.28 +..B1.35: + movl $1, %eax + jmp ..B1.23 + .align 16,0x90 + .type __dpml_ux_sqrt_evaluation__,@function + .size __dpml_ux_sqrt_evaluation__,.-__dpml_ux_sqrt_evaluation__ + .data +# -- End __dpml_ux_sqrt_evaluation__ + .text +# -- Begin __sqrtq + .text + .align 16,0x90 + .globl __sqrtq +__sqrtq: +# parameter 1: 24 + %ebp +..B2.1: +..L7: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $132, %esp + xorl %esi, %esi + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 128(%esp) + call ..L8 +..L8: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L8](%ebx), %ebx + movl $1, 40(%esp) + movl %esi, 44(%esp) + movl %esi, 32(%esp) + lea __sqrt_x_table@GOTOFF(%ebx), %ecx + movl %esi, 36(%esp) + addl $24, %esp + lea 8(%esp), %eax + lea 60(%esp), %edx + pushl %eax + lea 92(%esp), %eax + pushl %eax + pushl %ecx + pushl %edx + pushl %esi + lea 24(%ebp), %ecx + pushl %ecx + call __dpml_unpack_x_or_y__ +..B2.2: + subl %esi, %edx + jl ..B2.8 +..B2.3: + movl $7, 4(%esp) + lea 60(%esp), %edx + movl $0, 8(%esp) + lea 84(%esp), %eax + call __dpml_ux_sqrt_evaluation__. +..B2.4: + orl %edx, %eax + jne ..B2.6 +..B2.5: + movl $1, %edx + jmp ..B2.7 +..B2.6: + movl %esi, %edx +..B2.7: + movl %edx, 40(%esp) + movl %esi, 44(%esp) + addl $28, %esp + lea 4(%esp), %edx + pushl %edx + pushl %esi + pushl %esi + pushl %esi + pushl %esi + lea 104(%esp), %ecx + pushl %ecx + lea 56(%esp), %esi + pushl %esi + call __dpml_pack__ +..B2.8: + movl 112(%esp), %edx + movl %edx, (%edi) + movl 116(%esp), %ecx + movl 120(%esp), %esi + movl 124(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 128(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B2.10 +..B2.9: + movl %edi, %eax + addl $132, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B2.10: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __sqrtq,@function + .size __sqrtq,.-__sqrtq + .data +# -- End __sqrtq + .text +# -- Begin __rsqrtq + .text + .align 16,0x90 + .globl __rsqrtq +__rsqrtq: +# parameter 1: 24 + %ebp +..B3.1: +..L9: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $132, %esp + xorl %esi, %esi + movl %gs:20, %edx + movl 8(%ebp), %edi + xorl %esp, %edx + movl %edx, 128(%esp) + call ..L10 +..L10: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L10](%ebx), %ebx + movl $1, 40(%esp) + movl %esi, 44(%esp) + movl %esi, 32(%esp) + lea 8+__sqrt_x_table@GOTOFF(%ebx), %ecx + movl %esi, 36(%esp) + addl $24, %esp + lea 8(%esp), %eax + lea 60(%esp), %edx + pushl %eax + lea 92(%esp), %eax + pushl %eax + pushl %ecx + pushl %edx + pushl %esi + lea 24(%ebp), %ecx + pushl %ecx + call __dpml_unpack_x_or_y__ +..B3.2: + subl %esi, %edx + jl ..B3.8 +..B3.3: + movl %esi, 4(%esp) + lea 60(%esp), %edx + movl %esi, 8(%esp) + lea 84(%esp), %eax + call __dpml_ux_sqrt_evaluation__. +..B3.4: + orl %edx, %eax + jne ..B3.6 +..B3.5: + movl $1, %edx + jmp ..B3.7 +..B3.6: + movl %esi, %edx +..B3.7: + movl %edx, 40(%esp) + movl %esi, 44(%esp) + addl $28, %esp + lea 4(%esp), %edx + pushl %edx + pushl %esi + pushl %esi + pushl %esi + pushl %esi + lea 104(%esp), %ecx + pushl %ecx + lea 56(%esp), %esi + pushl %esi + call __dpml_pack__ +..B3.8: + movl 112(%esp), %edx + movl %edx, (%edi) + movl 116(%esp), %ecx + movl 120(%esp), %esi + movl 124(%esp), %edx + movl %ecx, 4(%edi) + movl %esi, 8(%edi) + movl %edx, 12(%edi) + movl 128(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B3.10 +..B3.9: + movl %edi, %eax + addl $132, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret $4 +..B3.10: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __rsqrtq,@function + .size __rsqrtq,.-__rsqrtq + .data +# -- End __rsqrtq + .text +# -- Begin __dpml_ux_hypot__ + .text + .align 16,0x90 + .globl __dpml_ux_hypot__ +__dpml_ux_hypot__: +# parameter 1: 144 + %esp +# parameter 2: 148 + %esp +# parameter 3: 152 + %esp +..B4.1: +..L11: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $124, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl 144(%esp), %edx + movl %eax, 112(%esp) + addl $12, %esp + lea 28(%esp), %esi + pushl %esi + pushl %edx + pushl %edx + call __dpml_multiply__ +..B4.2: + addl $12, %esp + movl 136(%esp), %eax + lea 52(%esp), %ebx + pushl %ebx + pushl %eax + pushl %eax + call __dpml_multiply__ +..B4.3: + addl $20, %esp + xorl %ebp, %ebp + lea 68(%esp), %edi + pushl %edi + pushl %ebp + pushl %ebp + pushl %ebx + pushl %esi + call __dpml_addsub__ +..B4.4: + addl $12, %esp + pushl %ebp + pushl %ebp + pushl %edi + call __dpml_ffs_and_shift__ +..B4.5: + movl %edi, %eax + movl $7, 4(%esp) + movl 152(%esp), %edx + movl $0, 8(%esp) + call __dpml_ux_sqrt_evaluation__..0 +..B4.6: + movl %eax, %ecx + orl %edx, %ecx + je ..B4.27 +..B4.7: + movl 44(%esp), %eax + subl 68(%esp), %eax + cltd + movl %edx, %edi + subl %ebp, %edi + jge ..B4.9 +..B4.8: + movl %eax, %esi + movl %ebp, %eax + subl %esi, %eax + movl %edx, %edi + movl %ebp, %edx + movl %ebx, %esi + sbbl %edi, %edx +..B4.9: + movl $128, %ebx + movl %eax, %edi + subl %ebx, %edi + movl %edx, %ebx + sbbl %ebp, %ebx + jl ..B4.11 +..B4.34: + orl %ebx, %edi + je ..B4.11 +..B4.10: + movl %ebp, %eax + movl %eax, %edx + jmp ..B4.27 +..B4.11: + movl $1, %ecx + movl %ebp, %edi +..B4.12: + movl 8(%esi,%ecx,8), %ebp + movl 12(%esi,%ecx,8), %ebx + movl %ebp, 36(%esp) + orl %ebx, %ebp + movl %ebx, 32(%esp) + jne ..B4.31 +..B4.13: + movl $64, %ebx + movl %eax, %ebp + subl %ebx, %ebp + movl $0, %ebx + movl %edx, %ebp + sbbl %ebx, %ebp + jl ..B4.15 +..B4.14: + addl $-64, %eax + adcl $-1, %edx + addl $-1, %ecx + adcl $-1, %edi + movl %edi, %ebp + subl %ebx, %ebp + jge ..B4.12 +..B4.15: + movl 36(%esp), %esi + xorl %ebp, %ebp +..B4.16: + cmpl $31, %eax + jbe ..B4.18 +..B4.17: + movl %eax, %ecx + movl %ebp, %edx + movl 32(%esp), %ebx + shrl %cl, %ebx + jmp ..B4.19 +..B4.18: + movl %eax, %ecx + movl %esi, %ebx + movl 32(%esp), %edx + shrdl %cl, %edx, %ebx + shrl %cl, %edx +..B4.19: + cmpl $31, %eax + jbe ..B4.21 +..B4.20: + movl %eax, %ecx + movl %ebx, %edx + shll %cl, %edx + movl %ebp, %edi + jmp ..B4.22 +..B4.21: + movl %eax, %ecx + movl %ebx, %edi + shldl %cl, %ebx, %edx + shll %cl, %edi +..B4.22: + movl 32(%esp), %eax + subl %edi, %esi + subl %edx, %eax + orl %eax, %esi + jne ..B4.24 +..B4.23: + movl $1, %eax + jmp ..B4.25 +..B4.24: + movl %ebp, %eax +..B4.25: + movl %ebp, %edx +..B4.27: + movl 112(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B4.29 +..B4.28: + addl $124, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B4.29: + call ..L12 +..L12: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L12](%ebx), %ebx + call __stack_chk_fail@PLT +..B4.31: + xorl %ebp, %ebp + movl %ebp, %eax + xorl %edx, %edx + jmp ..B4.27 + .align 16,0x90 + .type __dpml_ux_hypot__,@function + .size __dpml_ux_hypot__,.-__dpml_ux_hypot__ + .data +# -- End __dpml_ux_hypot__ + .text +# -- Begin __dpml_ux_sqrt_evaluation__..0 + .text + .align 16,0x90 +__dpml_ux_sqrt_evaluation__..0: +# parameter 1: %eax +# parameter 2: 12 + %ebp +# parameter 3: %edx +..B5.1: +..L13: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $148, %esp + movl %edx, 76(%esp) + movl %eax, 72(%esp) + movl %gs:20, %ecx + xorl %esp, %ecx + movl %ecx, 136(%esp) + addl $4, %esp + call ..L14 +..L14: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L14](%ebx), %ebx + lea 80(%esp), %eax + pushl %eax + call fegetenv@PLT +..B5.2: + movl 72(%esp), %esi + movl %ebx, 36(%esp) + movl 8(%esi), %edi + movl %edi, %edx + movl 12(%esi), %eax + movl %eax, %ecx + shll $21, %ecx + shrl $11, %edx + orl %edx, %ecx + movl 4(%esi), %edx + movl 20(%esi), %ebx + movl %edx, %esi + andl $1, %esi + movl %ebx, 40(%esp) + movl %eax, %ebx + shrl $11, %ebx + addl %esi, %edx + addl $1070596096, %ebx + movl %ebx, 68(%esp) + lea 8(%esi), %ebx + movl %ebx, 32(%esp) + negl %ebx + movl %ecx, 64(%esp) + movl %ebx, %ecx + negl %ecx + sarl $1, %edx + addl $31, %ecx + movl %edx, 44(%esp) + movl %edi, %edx + shrl %cl, %edx + movl %ebx, %ecx + movl %eax, 80(%esp) + shrl $1, %edx + shll %cl, %eax + shll %cl, %edi + orl %edx, %eax + movl 40(%esp), %edx + movl 36(%esp), %ebx +..B5.3: + movl 32(%esp), %ecx + shrl %cl, %edx +..B5.5: + fldl 64(%esp) + orl %edx, %edi + movl %eax, %edx + shll $21, %edx + shrl $11, %edi + shrl $11, %eax + orl %edi, %edx + movl %edx, 48(%esp) + movl %eax, 52(%esp) + fildll 48(%esp) + fstpl 56(%esp) + fldl 56(%esp) +..B5.6: + movl 80(%esp), %eax + shrl %cl, %eax +..B5.8: + fmull 136+__sqrt_x_table@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + movl 80(%esp), %ecx + shrl $24, %ecx + shll $7, %esi + xorl %esi, %ecx + shll $4, %ecx + movl __sqrt_t_table@GOT(%ebx), %edx + movl %eax, 48(%esp) + fildl 48(%esp) + fstpl 56(%esp) + fldl 56(%esp) + fmull 128+__sqrt_x_table@GOTOFF(%ebx) + fstpl 56(%esp) + fldl 56(%esp) + fxch %st(2) + fstpl 56(%esp) + fldl 56(%esp) + fld %st(0) + fadd %st(3), %st + fxch %st(2) + fmuls (%edx,%ecx) + flds 4(%edx,%ecx) + fmulp %st, %st(5) + fxch %st(4) + faddl 8(%edx,%ecx) + faddp %st, %st(4) + fxch %st(3) + fstpl 56(%esp) + fldl 56(%esp) + fmull 96+__sqrt_x_table@GOTOFF(%ebx) + fstpl 56(%esp) + fldl 56(%esp) + fxch %st(1) + fstpl 56(%esp) + fldl 56(%esp) + fld %st(0) + fmul %st(2), %st + fstps 48(%esp) + flds 48(%esp) + fxch %st(2) + fstps 48(%esp) + flds 48(%esp) + fmul %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fld %st(3) + fmulp %st, %st(2) + fldl 152+__sqrt_x_table@GOTOFF(%ebx) + fmulp %st, %st(3) + fld %st(3) + fmul %st(4), %st + fmulp %st, %st(3) + fxch %st(1) + fsubrl 104+__sqrt_x_table@GOTOFF(%ebx) + fsubp %st, %st(1) + fstpl 56(%esp) + fldl 56(%esp) + fldl 112+__sqrt_x_table@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + fsubrl 144+__sqrt_x_table@GOTOFF(%ebx) + fmulp %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpl 56(%esp) + fldl 56(%esp) + flds .L_2il0floatpacket.20@GOTOFF(%ebx) + fld %st(0) + fsubr %st(3), %st + fxch %st(1) + fcomp %st(3) + fnstsw %ax + fxch %st(1) + fmull 120+__sqrt_x_table@GOTOFF(%ebx) + sahf + fxch %st(2) + jp ..L16 + jbe ..L15 +..L16: + fst %st(1) +..L15: + fstp %st(0) + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 64(%esp) + fldcw 32(%esp) + movl 64(%esp), %edx + fnstcw 32(%esp) + movzwl 32(%esp), %eax + orl $3072, %eax + movl %eax, 40(%esp) + fldcw 40(%esp) + fistpll 64(%esp) + fldcw 32(%esp) + shll $7, %edx + movl 64(%esp), %ecx + movl %ecx, %esi + movl 68(%esp), %edi + movl %edi, %eax + shll $20, %eax + shrl $12, %esi + shrl $11, %ecx + orl %esi, %eax + sarl $12, %edi + andl $1, %ecx + addl %edi, %edx + addl %ecx, %eax + adcl $0, %edx + xorl %esi, %esi + movl %edx, %ecx + andl $1073741824, %ecx + orl %esi, %ecx + je ..B5.10 +..B5.9: + movl $2147483647, %edi + jmp ..B5.11 +..B5.10: + movl $-1, %edi +..B5.11: + movl %edx, %esi + xorl %ecx, %ecx + subl %ecx, %esi + jl ..B5.13 +..B5.12: + movl $-1, %eax + movl %edi, %edx +..B5.13: + movl 44(%esp), %esi + xorl %ecx, %ecx + negl %esi + incl %esi + movl %ecx, 48(%esp) + movl %esi, 52(%esp) + movl %eax, 56(%esp) + movl %edx, 60(%esp) + movl %ecx, 64(%esp) + movl %ecx, 68(%esp) + addl $12, %esp + lea 100(%esp), %esi + lea 36(%esp), %eax + pushl %esi + pushl 64(%esp) + pushl %eax + call __dpml_multiply__ +..B5.14: + addl $12, %esp + pushl 64(%esp) + pushl %esi + lea 44(%esp), %eax + pushl %eax + call __dpml_multiply__ +..B5.15: + addl $20, %esp + lea 160+__sqrt_x_table@GOTOFF(%ebx), %edx + movl 56(%esp), %eax + pushl %eax + pushl $0 + pushl $9 + pushl %eax + pushl %edx + call __dpml_addsub__ +..B5.16: + addl $12, %esp + movl 64(%esp), %eax + pushl %eax + pushl %esi + pushl %eax + call __dpml_multiply__ +..B5.17: + addl $4, %esp + lea 80(%esp), %eax + pushl %eax + movl -8(%eax), %edx + decl 4(%edx) + call fesetenv@PLT +..B5.18: + addl $12, %esp + xorl %ecx, %ecx + pushl %ecx + pushl %ecx + pushl 72(%esp) + call __dpml_ffs_and_shift__ +..B5.19: + movl 76(%esp), %eax + xorl %edi, %edi + movl 16(%eax), %ecx + movl 20(%eax), %edx + movl %ecx, 44(%esp) + movl %edx, 40(%esp) + lea 8(%ecx), %eax + andl $16368, %eax + orl %edi, %eax + jne ..B5.32 +..B5.21: + lea 48(%esp), %eax + pushl %eax + pushl %esi + movl 28(%eax), %edi + pushl %edi + pushl %edi + movl %ecx, %edx + andl $-32768, %edx + movl %edx, -4(%eax) + addl $16384, %edx + movl -8(%eax), %ecx + adcl $0, %ecx + movl %edx, -12(%eax) + movl %ecx, -16(%eax) + movl %edx, 16(%edi) + movl %ecx, 20(%edi) + call __dpml_extended_multiply__ +..B5.22: + addl $36, %esp + pushl %esi + pushl $0 + pushl $1 + pushl %esi + pushl 68(%esp) + call __dpml_addsub__ +..B5.23: + addl $20, %esp + pushl %esi + pushl $0 + pushl $1 + lea 40(%esp), %eax + pushl %eax + pushl %esi + call __dpml_addsub__ +..B5.24: + movl 112(%esp), %eax + testl %eax, %eax + jne ..B5.26 +..B5.25: + movl %edi, %ecx + movl 36(%esp), %eax + movl 32(%esp), %edx + movl 4(%ecx), %edi + addl $-113, %edi + movl %eax, 16(%ecx) + movl %edx, 20(%ecx) + subl %edi, 116(%esp) + jmp ..B5.27 +..B5.26: + movl 44(%esp), %edx + movl 40(%esp), %ecx + movl %edx, 16(%edi) + movl 4(%edi), %edx + addl $-113, %edx + subl %edx, 116(%esp) + movl %ecx, 20(%edi) + testl %eax, %eax + jne ..B5.28 +..B5.27: + movl $1, %eax + jmp ..B5.29 +..B5.28: + xorl %eax, %eax +..B5.29: + addl $20, %esp + orl $8, %eax + pushl %esi + pushl $0 + pushl %eax + pushl 68(%esp) + pushl %esi + call __dpml_addsub__ +..B5.30: + movl $8192, %eax + movl 128(%esp), %edx + subl %eax, %edx + orl 132(%esp), %edx + jne ..B5.32 +..B5.31: + movl $1, %eax + jmp ..B5.34 +..B5.32: + xorl %eax, %eax +..B5.34: + movl 136(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B5.36 +..B5.35: + xorl %edx, %edx + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B5.36: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __dpml_ux_sqrt_evaluation__..0,@function + .size __dpml_ux_sqrt_evaluation__..0,.-__dpml_ux_sqrt_evaluation__..0 + .data +# -- End __dpml_ux_sqrt_evaluation__..0 + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.20: + .long 0x5f000000 + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,4 + .align 4 +__sqrt_x_table: + .long 1088750600 + .long 605086734 + .long 1088766984 + .long 519758862 + .long 112 + .long 0 + .long 113 + .long 0 + .long 114 + .long 0 + .long 0 + .long 0 + .long 0 + .long 268435456 + .long 858997845 + .long 34 + .long 1636176969 + .long 409044504 + .long 1099306057 + .long 404751376 + .long 545392672 + .long 404783624 + .long 142938632 + .long 302522498 + .long 1719614413 + .long 1073127582 + .long 0 + .long 1072693248 + .long 0 + .long 1097859072 + .long 0 + .long 1151336448 + .long 0 + .long 1047527424 + .long 0 + .long 991952896 + .long 0 + .long 1072431104 + .long 0 + .long 1071120384 + .long 0 + .long 2 + .long 0 + .long 3221225472 + .long 0 + .long 0 + .long 0 + .long 0 + .type __sqrt_x_table,@object + .size __sqrt_x_table,192 + .data + .hidden __dpml_extended_multiply__ + .hidden __dpml_multiply__ + .hidden __dpml_ffs_and_shift__ + .hidden __dpml_addsub__ + .hidden __dpml_pack__ + .hidden __dpml_unpack_x_or_y__ + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/dpml_ux_trig.S b/external/sgx_libm/ia32/dpml_ux_trig.S new file mode 100644 index 0000000000..111fd34910 --- /dev/null +++ b/external/sgx_libm/ia32/dpml_ux_trig.S @@ -0,0 +1,4138 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_trig.c" + .text +..TXTST0: +# -- Begin __dpml_ux_radian_reduce__ + .text + .align 16,0x90 +__dpml_ux_radian_reduce__: +# parameter 1: 176 + %esp +# parameter 2: 180 + %esp +# parameter 3: 188 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $156, %esp + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + movl %eax, 76(%esp) + movl 176(%esp), %eax + movl 8(%eax), %edx + movl 12(%eax), %ecx + movl %edx, 108(%esp) + movl %ecx, 104(%esp) + movl 16(%eax), %edx + movl 20(%eax), %ecx + movl 4(%eax), %ebp + testl %ebp, %ebp + movl (%eax), %ebx + movl %edx, 128(%esp) + movl %ecx, 132(%esp) + movl %ebp, 112(%esp) + movl %ebx, 80(%esp) + jl ..B1.120 +..B1.2: + movl %ebp, %eax + xorl %ebp, %ebp + cltd + addl $8, %eax + movl %eax, %edi + adcl $0, %edx + andl $63, %eax + movl 76(%esp), %ebx + shll $26, %edx + shrl $6, %edi + orl %edx, %edi + movl __four_over_pi@GOT(%ebx), %esi + movl %edi, 72(%esp) + movl %eax, 112(%esp) + lea (%esi,%edi,8), %ecx + movl (%ecx), %ebx + movl 4(%ecx), %esi + movl %ebx, 60(%esp) + movl %esi, 56(%esp) + movl 8(%ecx), %edx + movl 12(%ecx), %edi + movl 16(%ecx), %ebx + movl 20(%ecx), %esi + movl %edx, 68(%esp) + movl %edi, 64(%esp) + movl %ebx, 36(%esp) + movl %esi, 32(%esp) + movl 24(%ecx), %ebx + movl 28(%ecx), %esi + movl 32(%ecx), %edx + movl 36(%ecx), %edi + addl $40, %ecx + movl %edx, 120(%esp) + orl %eax, %ebp + movl %edi, 124(%esp) + movl %ecx, 116(%esp) + je ..B1.28 +..B1.3: + movl %eax, %ecx + movl %ecx, %edx + negl %edx + addl $64, %edx + movl %edx, 72(%esp) + cmpl $31, %ecx + jbe ..B1.5 +..B1.4: + xorl %edx, %edx + movl 60(%esp), %ebp + shll %cl, %ebp + movl %ebp, 56(%esp) + jmp ..B1.6 +..B1.5: + movl 56(%esp), %ebp + movl 60(%esp), %edx + shldl %cl, %edx, %ebp + movl %ebp, 56(%esp) + shll %cl, %edx +..B1.6: + cmpl $31, 72(%esp) + jbe ..B1.8 +..B1.7: + movl 72(%esp), %ecx + xorl %ebp, %ebp + movl 64(%esp), %edi + shrl %cl, %edi + movl %edi, 60(%esp) + jmp ..B1.9 +..B1.8: + movl 72(%esp), %ecx + movl 68(%esp), %edi + movl 64(%esp), %ebp + shrdl %cl, %ebp, %edi + movl %edi, 60(%esp) + shrl %cl, %ebp +..B1.9: + orl %edx, 60(%esp) + orl %ebp, 56(%esp) + cmpl $31, 112(%esp) + jbe ..B1.11 +..B1.10: + movl %eax, %ecx + xorl %edx, %edx + movl 68(%esp), %ebp + shll %cl, %ebp + movl %ebp, 64(%esp) + jmp ..B1.12 +..B1.11: + movl %eax, %ecx + movl 64(%esp), %ebp + movl 68(%esp), %edx + shldl %cl, %edx, %ebp + movl %ebp, 64(%esp) + shll %cl, %edx +..B1.12: + cmpl $31, 72(%esp) + jbe ..B1.14 +..B1.13: + movl 72(%esp), %ecx + xorl %ebp, %ebp + movl 32(%esp), %edi + shrl %cl, %edi + movl %edi, 68(%esp) + jmp ..B1.15 +..B1.14: + movl 72(%esp), %ecx + movl 36(%esp), %edi + movl 32(%esp), %ebp + shrdl %cl, %ebp, %edi + movl %edi, 68(%esp) + shrl %cl, %ebp +..B1.15: + orl %edx, 68(%esp) + orl %ebp, 64(%esp) + cmpl $31, 112(%esp) + jbe ..B1.17 +..B1.16: + movl %eax, %ecx + xorl %edx, %edx + movl 36(%esp), %ebp + shll %cl, %ebp + movl %ebp, 32(%esp) + jmp ..B1.18 +..B1.17: + movl %eax, %ecx + movl 32(%esp), %ebp + movl 36(%esp), %edx + shldl %cl, %edx, %ebp + movl %ebp, 32(%esp) + shll %cl, %edx +..B1.18: + cmpl $31, 72(%esp) + jbe ..B1.20 +..B1.19: + movl %esi, %edi + xorl %ebp, %ebp + movl 72(%esp), %ecx + shrl %cl, %edi + movl %edi, 36(%esp) + jmp ..B1.21 +..B1.20: + movl %ebx, %ebp + movl 72(%esp), %ecx + shrdl %cl, %esi, %ebp + movl %ebp, 36(%esp) + movl %esi, %ebp + shrl %cl, %ebp +..B1.21: + orl %edx, 36(%esp) + orl %ebp, 32(%esp) + cmpl $31, 112(%esp) + jbe ..B1.23 +..B1.22: + movl %ebx, %esi + xorl %edx, %edx + movl %eax, %ecx + shll %cl, %esi + jmp ..B1.24 +..B1.23: + movl %ebx, %edx + movl %eax, %ecx + shldl %cl, %ebx, %esi + shll %cl, %edx +..B1.24: + cmpl $31, 72(%esp) + jbe ..B1.26 +..B1.25: + movl 72(%esp), %ecx + xorl %ebp, %ebp + movl 124(%esp), %ebx + shrl %cl, %ebx + jmp ..B1.27 +..B1.26: + movl 72(%esp), %ecx + movl 120(%esp), %ebx + movl 124(%esp), %ebp + shrdl %cl, %ebp, %ebx + shrl %cl, %ebp +..B1.27: + orl %edx, %ebx + orl %ebp, %esi +..B1.28: + movl %ebx, %eax + movl 128(%esp), %ecx + mull %ecx + movl %ebx, %eax + movl %edx, %ebp + mull 132(%esp) + addl %eax, %ebp + movl %ecx, %eax + movl %edx, %edi + adcl $0, %edi + mull %esi + addl %ebp, %eax + movl %edx, %ecx + adcl %edi, %ecx + subl %ebp, %eax + movl %ecx, %edx + sbbl %edi, %edx + jae ..B1.30 +..B1.29: + movl $1, %ebp + jmp ..B1.31 +..B1.30: + xorl %ebp, %ebp +..B1.31: + movl %esi, %eax + movl 132(%esp), %edi + mull %edi + addl %edx, %ebp + addl %ecx, %eax + movl %esi, %ecx + movl %eax, 88(%esp) + adcl $0, %ebp + movl 128(%esp), %eax + imull %ebx, %edi + imull %eax, %ecx + mull %ebx + addl %ecx, %edi + movl 104(%esp), %ecx + addl %edi, %edx + movl %edx, 100(%esp) + movl %esi, %edi + movl %ecx, %edx + movl %ebp, 92(%esp) + movl 108(%esp), %ebp + imull %ebp, %edi + imull %ebx, %edx + movl %eax, 96(%esp) + movl %ebx, %eax + addl %edx, %edi + mull %ebp + movl %eax, 40(%esp) + movl %ebx, %eax + addl %edi, %edx + movl %edx, 44(%esp) + mull %ebp + movl %ebx, %eax + movl %edx, %edi + mull %ecx + addl %eax, %edi + movl %ebp, %eax + movl %edx, %ebx + adcl $0, %ebx + mull %esi + addl %edi, %eax + movl 92(%esp), %ebp + adcl %ebx, %edx + subl %edi, %eax + movl %edx, 48(%esp) + sbbl %ebx, %edx + movl 88(%esp), %ebx + jae ..B1.33 +..B1.32: + movl $1, %ecx + jmp ..B1.34 +..B1.33: + xorl %ecx, %ecx +..B1.34: + movl %esi, %eax + mull 104(%esp) + movl %eax, %esi + addl %edx, %ecx + addl 48(%esp), %esi + movl 40(%esp), %eax + adcl $0, %ecx + addl %eax, %ebx + movl %ebx, %edx + movl 44(%esp), %edi + adcl %edi, %ebp + subl %eax, %edx + movl %ebp, %eax + sbbl %edi, %eax + jae ..B1.36 +..B1.35: + movl $1, %eax + jmp ..B1.37 +..B1.36: + xorl %eax, %eax +..B1.37: + addl %eax, %esi + movl %ebx, 88(%esp) + movl %esi, 84(%esp) + adcl $0, %ecx + movl 132(%esp), %ebx + movl %ebx, %edi + movl 32(%esp), %esi + movl %esi, %edx + movl %ebp, 92(%esp) + movl %ecx, 136(%esp) + movl 36(%esp), %ecx + movl 128(%esp), %ebp + movl %ebp, %eax + imull %ecx, %edi + imull %ebp, %edx + addl %edx, %edi + mull %ecx + movl %eax, 44(%esp) + movl %ebp, %eax + addl %edi, %edx + movl %edx, 48(%esp) + mull %ecx + movl %ecx, %eax + movl %edx, %edi + mull %ebx + addl %eax, %edi + movl %ebp, %eax + movl %edx, %ecx + adcl $0, %ecx + mull %esi + addl %edi, %eax + movl 84(%esp), %esi + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 52(%esp) + movl 88(%esp), %ebx + sbbl %ecx, %edx + movl 136(%esp), %ecx + movl 92(%esp), %ebp + jae ..B1.39 +..B1.38: + movl $1, %edi + jmp ..B1.40 +..B1.39: + xorl %edi, %edi +..B1.40: + movl 32(%esp), %eax + mull 132(%esp) + addl %edx, %edi + addl 52(%esp), %eax + movl %eax, 40(%esp) + movl 44(%esp), %eax + adcl $0, %edi + addl %eax, %ebx + movl %ebx, %edx + adcl 48(%esp), %ebp + subl %eax, %edx + movl %ebp, %eax + sbbl 48(%esp), %eax + jae ..B1.42 +..B1.41: + movl $1, 44(%esp) + jmp ..B1.43 +..B1.42: + movl $0, 44(%esp) +..B1.43: + movl 44(%esp), %eax + addl %eax, %esi + movl %esi, %edx + adcl $0, %ecx + subl %eax, %edx + movl $0, %eax + movl %ecx, %edx + sbbl %eax, %edx + jae ..B1.45 +..B1.44: + movl $1, 52(%esp) + jmp ..B1.46 +..B1.45: + movl $0, 52(%esp) +..B1.46: + movl 40(%esp), %eax + addl %eax, %esi + movl %esi, %edx + adcl %edi, %ecx + subl %eax, %edx + movl %ecx, %eax + sbbl %edi, %eax + jae ..B1.48 +..B1.47: + movl $1, %eax + jmp ..B1.49 +..B1.48: + xorl %eax, %eax +..B1.49: + movl %esi, 84(%esp) + movl %ebx, 88(%esp) + movl 104(%esp), %ebx + movl %ebx, %edi + movl 32(%esp), %esi + movl %esi, %edx + movl %ebp, 92(%esp) + movl %ecx, 136(%esp) + movl 36(%esp), %ecx + movl 108(%esp), %ebp + imull %ecx, %edi + imull %ebp, %edx + addl %eax, 52(%esp) + movl %ebp, %eax + addl %edx, %edi + mull %ecx + movl %eax, 40(%esp) + movl %ebp, %eax + addl %edi, %edx + movl %edx, 44(%esp) + mull %ecx + movl %ecx, %eax + movl %edx, %edi + mull %ebx + addl %eax, %edi + movl %ebp, %eax + movl %edx, %ecx + adcl $0, %ecx + mull %esi + addl %edi, %eax + movl 88(%esp), %ebx + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 48(%esp) + movl 84(%esp), %esi + sbbl %ecx, %edx + movl 136(%esp), %ecx + movl 92(%esp), %ebp + jae ..B1.51 +..B1.50: + movl $1, %edi + jmp ..B1.52 +..B1.51: + xorl %edi, %edi +..B1.52: + movl 32(%esp), %eax + mull 104(%esp) + addl %edx, %edi + addl 48(%esp), %eax + movl %eax, 36(%esp) + movl 40(%esp), %eax + adcl $0, %edi + addl %eax, %esi + movl %esi, %edx + adcl 44(%esp), %ecx + subl %eax, %edx + movl %ecx, %eax + sbbl 44(%esp), %eax + jae ..B1.54 +..B1.53: + movl $1, %eax + jmp ..B1.55 +..B1.54: + xorl %eax, %eax +..B1.55: + movl 52(%esp), %edx + addl 36(%esp), %edx + movl %ebp, 92(%esp) + adcl $0, %edi + addl %eax, %edx + movl %ecx, 136(%esp) + movl 132(%esp), %ecx + adcl $0, %edi + movl 64(%esp), %ebp + movl %esi, 84(%esp) + movl %ecx, %esi + movl %edx, 52(%esp) + movl %ebp, %edx + movl %ebx, 88(%esp) + movl %edi, 48(%esp) + movl 68(%esp), %edi + movl 128(%esp), %ebx + movl %ebx, %eax + imull %edi, %esi + imull %ebx, %edx + addl %edx, %esi + mull %edi + movl %eax, 32(%esp) + movl %ebx, %eax + addl %esi, %edx + movl %edx, 40(%esp) + mull %edi + movl %edi, %eax + movl %edx, %esi + mull %ecx + addl %eax, %esi + movl %ebx, %eax + movl %edx, %edi + adcl $0, %edi + mull %ebp + addl %esi, %eax + movl 88(%esp), %ebx + adcl %edi, %edx + subl %esi, %eax + movl %edx, 44(%esp) + movl 136(%esp), %ecx + sbbl %edi, %edx + movl 48(%esp), %edi + movl 84(%esp), %esi + movl 92(%esp), %ebp + jae ..B1.57 +..B1.56: + movl $1, 48(%esp) + jmp ..B1.58 +..B1.57: + movl $0, 48(%esp) +..B1.58: + movl 64(%esp), %eax + mull 132(%esp) + movl %ebx, 88(%esp) + movl 48(%esp), %ebx + addl %edx, %ebx + addl 44(%esp), %eax + movl %eax, 36(%esp) + movl 32(%esp), %eax + adcl $0, %ebx + addl %eax, %esi + movl %esi, %edx + movl %ebx, 48(%esp) + movl 40(%esp), %ebx + adcl %ebx, %ecx + subl %eax, %edx + movl %ecx, %eax + sbbl %ebx, %eax + movl 88(%esp), %ebx + jae ..B1.60 +..B1.59: + movl $1, 32(%esp) + jmp ..B1.61 +..B1.60: + movl $0, 32(%esp) +..B1.61: + movl %esi, 84(%esp) + movl %ebx, 88(%esp) + movl 104(%esp), %esi + movl 68(%esp), %ebx + movl 108(%esp), %eax + movl 64(%esp), %edx + imull %ebx, %esi + imull %eax, %edx + addl %edx, %esi + mull %ebx + movl %ecx, 136(%esp) + movl %eax, %ecx + movl %edx, %ebx + addl %esi, %ebx + addl 52(%esp), %ecx + movl 60(%esp), %esi + movl 56(%esp), %edx + adcl %edi, %ebx + movl 132(%esp), %edi + movl 128(%esp), %eax + imull %esi, %edi + imull %eax, %edx + addl %edx, %edi + mull %esi + addl 36(%esp), %ecx + adcl 48(%esp), %ebx + addl %edi, %edx + addl 32(%esp), %ecx + adcl $0, %ebx + addl %ecx, %eax + movl 180(%esp), %ecx + movl %ecx, %edi + adcl %ebx, %edx + negl %edi + cmpl $0, 80(%esp) + movl %eax, 140(%esp) + jne ..L3 + movl %ecx, %edi +..L3: + xorl %eax, %eax + shll $29, %edi + addl %edi, %edx + movl %eax, 44(%esp) + movl 88(%esp), %ebx + movl %edx, 152(%esp) + movl %eax, 40(%esp) + jmp ..B1.62 +..B1.96: + addl $64, 44(%esp) + movl 152(%esp), %ecx + movl 136(%esp), %edx + movl 84(%esp), %eax + movl 32(%esp), %esi + movl 36(%esp), %edi + movl %ebx, 84(%esp) + movl %ebp, 136(%esp) + movl 96(%esp), %ebx + movl 100(%esp), %ebp + adcl $0, 40(%esp) + andl $-536870912, %ecx + andl $536870911, %edx + orl %edx, %ecx + movl %eax, 140(%esp) + movl %ecx, 152(%esp) + movl %esi, 96(%esp) + movl %edi, 100(%esp) +..B1.62: + movl 152(%esp), %eax + xorl %edx, %edx + lea 4194304(%eax), %ecx + andl $1065353216, %ecx + orl %edx, %ecx + jne ..B1.119 +..B1.63: + movl 116(%esp), %eax + movl 120(%esp), %esi + movl 124(%esp), %edi + movl (%eax), %edx + movl %edx, 120(%esp) + xorl %edx, %edx + movl 4(%eax), %ecx + addl $8, %eax + movl %ecx, 124(%esp) + movl %eax, 116(%esp) + orl 112(%esp), %edx + je ..B1.71 +..B1.64: + cmpl $31, 112(%esp) + jbe ..B1.66 +..B1.65: + movl %esi, %edi + xorl %edx, %edx + movl 112(%esp), %ecx + shll %cl, %edi + jmp ..B1.67 +..B1.66: + movl %esi, %edx + movl 112(%esp), %ecx + shldl %cl, %esi, %edi + shll %cl, %edx +..B1.67: + cmpl $31, 72(%esp) + jbe ..B1.69 +..B1.68: + movl 72(%esp), %ecx + xorl %eax, %eax + movl 124(%esp), %esi + shrl %cl, %esi + jmp ..B1.70 +..B1.69: + movl 72(%esp), %ecx + movl 120(%esp), %esi + movl 124(%esp), %eax + shrdl %cl, %eax, %esi + shrl %cl, %eax +..B1.70: + orl %edx, %esi + orl %eax, %edi +..B1.71: + movl 132(%esp), %ecx + movl %edi, %edx + movl %ebx, 88(%esp) + movl %ecx, %ebx + movl %ebp, 92(%esp) + movl 128(%esp), %ebp + movl %ebp, %eax + imull %esi, %ebx + imull %ebp, %edx + addl %edx, %ebx + mull %esi + movl %eax, 32(%esp) + movl %ebp, %eax + addl %ebx, %edx + movl %edx, 36(%esp) + mull %esi + movl %esi, %eax + movl %edx, %ebx + mull %ecx + addl %eax, %ebx + movl %ebp, %eax + movl %edx, %ecx + adcl $0, %ecx + mull %edi + addl %ebx, %eax + movl 92(%esp), %ebp + adcl %ecx, %edx + subl %ebx, %eax + movl %edx, 56(%esp) + movl 88(%esp), %ebx + sbbl %ecx, %edx + jae ..B1.73 +..B1.72: + movl $1, %ecx + jmp ..B1.74 +..B1.73: + xorl %ecx, %ecx +..B1.74: + movl 132(%esp), %eax + mull %edi + addl %edx, %ecx + addl 56(%esp), %eax + movl 96(%esp), %edx + adcl $0, %ecx + addl %eax, %edx + movl %ebx, 88(%esp) + movl 100(%esp), %ebx + adcl %ecx, %ebx + movl %edx, 96(%esp) + subl %eax, %edx + movl %ebx, 100(%esp) + sbbl %ecx, %ebx + movl 88(%esp), %ebx + jae ..B1.76 +..B1.75: + movl $1, %ecx + jmp ..B1.77 +..B1.76: + xorl %ecx, %ecx +..B1.77: + movl 104(%esp), %edx + addl %ecx, %ebx + movl 108(%esp), %eax + movl %edi, 64(%esp) + adcl $0, %ebp + imull %esi, %edx + imull %eax, %edi + addl %edi, %edx + movl %ebx, %edi + movl %edx, 68(%esp) + mull %esi + addl 68(%esp), %edx + subl %ecx, %edi + movl $0, %ecx + movl %edx, 52(%esp) + movl %ebp, %edx + movl %eax, 48(%esp) + sbbl %ecx, %edx + movl 64(%esp), %edi + jae ..B1.80 +..B1.78: + movl $1, %ecx +..B1.80: + movl 108(%esp), %eax + mull %esi + movl %esi, %eax + movl %ebx, 88(%esp) + movl %edx, %ebx + mull 104(%esp) + addl %eax, %ebx + movl %edx, %esi + movl 108(%esp), %eax + adcl $0, %esi + mull %edi + addl %ebx, %eax + adcl %esi, %edx + subl %ebx, %eax + movl %edx, 60(%esp) + movl 88(%esp), %ebx + sbbl %esi, %edx + jae ..B1.82 +..B1.81: + movl $1, %esi + jmp ..B1.83 +..B1.82: + xorl %esi, %esi +..B1.83: + movl 104(%esp), %eax + mull %edi + addl %edx, %esi + addl 60(%esp), %eax + movl %eax, 144(%esp) + movl 48(%esp), %edx + adcl $0, %esi + movl 96(%esp), %eax + addl %edx, %eax + movl %esi, 148(%esp) + movl 52(%esp), %esi + movl 100(%esp), %edi + adcl %esi, %edi + movl %eax, 96(%esp) + subl %edx, %eax + movl %edi, 100(%esp) + movl 144(%esp), %eax + sbbl %esi, %edi + movl 148(%esp), %esi + jae ..B1.85 +..B1.84: + movl $1, %edx + jmp ..B1.86 +..B1.85: + xorl %edx, %edx +..B1.86: + addl %edx, %ebx + movl %ebx, %edi + adcl $0, %ebp + subl %edx, %edi + movl $0, %edx + movl %ebp, %edi + sbbl %edx, %edi + jae ..B1.89 +..B1.87: + movl $1, %edx +..B1.89: + addl %eax, %ebx + adcl %esi, %ebp + addl %edx, %ecx + movl %ebx, %edx + subl %eax, %edx + movl %ebp, %eax + sbbl %esi, %eax + jae ..B1.91 +..B1.90: + movl $1, %eax + jmp ..B1.92 +..B1.91: + xorl %eax, %eax +..B1.92: + addl %eax, %ecx + xorl %eax, %eax + orl %eax, %ecx + je ..B1.95 +..B1.93: + movl 84(%esp), %eax + addl $1, %eax + movl 136(%esp), %edx + adcl $0, %edx + movl %eax, 84(%esp) + orl %edx, %eax + movl %edx, 136(%esp) + jne ..B1.95 +..B1.94: + addl $1, 140(%esp) + adcl $0, 152(%esp) +..B1.95: + movl 140(%esp), %ecx + movl %ecx, %eax + movl 152(%esp), %esi + shrl $23, %eax + shll $9, %esi + orl %esi, %eax + movl 136(%esp), %edx + movl %eax, %edi + shrl $23, %edx + shll $9, %ecx + sarl $31, %edi + orl %ecx, %edx + xorl %edi, %edx + xorl %edi, %eax + orl %eax, %edx + je ..B1.96 +..B1.97: + movl 136(%esp), %ecx + movl 84(%esp), %esi + movl 152(%esp), %edx +..B1.98: + movl %ebx, 88(%esp) + lea (,%edx,4), %edi + movl 140(%esp), %ebx + movl %ebx, %eax + sarl $2, %edi + subl %ebx, %eax + movl %eax, 32(%esp) + movl %edi, %eax + sbbl %edi, %edx + sarl $31, %eax + subl %eax, %ebx + negl %eax + addl %edi, %eax + movl %edi, 36(%esp) + orl %eax, %ebx + movl 88(%esp), %ebx + jne ..B1.100 +..B1.99: + movl %esi, 140(%esp) + movl %ebx, %esi + movl %ecx, 36(%esp) + movl %ebp, %ecx + movl 96(%esp), %ebx + movl 100(%esp), %ebp + addl $64, 44(%esp) +..B1.100: + xorl %eax, %eax + subl %eax, %edi + jge ..B1.103 +..B1.102: + movl $-2147483648, %eax +..B1.103: + testl %eax, %eax + je ..B1.111 +..B1.104: + notl %ebx + notl %ebp + addl $1, %ebx + notl %esi + movl %ebx, %edi + notl %ecx + adcl $0, %ebp + notl 140(%esp) + orl %ebp, %edi + notl 36(%esp) + jne ..B1.106 +..B1.105: + movl $1, %edi + jmp ..B1.107 +..B1.106: + xorl %edi, %edi +..B1.107: + addl %edi, %esi + movl %esi, %edi + adcl $0, %ecx + orl %ecx, %edi + jne ..B1.109 +..B1.108: + movl $1, %edi + jmp ..B1.110 +..B1.109: + xorl %edi, %edi +..B1.110: + addl %edi, 140(%esp) + adcl $0, 36(%esp) +..B1.111: + movl %ebp, 92(%esp) + xorl %edi, %edi + movl %ebx, 88(%esp) + addl $12, %esp + pushl %edi + pushl %edi + movl 184(%esp), %ebx + xorl %ebp, %ebp + pushl %ebx + subl 32(%esp), %ebp + movl 80(%esp), %ebp + sbbl %edx, %edi + testl %ebp, %ebp + movl $3, 4(%ebx) + jne ..L4 + movl %edx, %edi +..L4: + xorl %ebp, %eax + movl %eax, (%ebx) + movl 140(%esp), %eax + movl 36(%esp), %edx + movl %eax, 8(%ebx) + movl %edx, 12(%ebx) + movl %esi, 16(%ebx) + movl %ecx, 20(%ebx) + movl %edi, 40(%esp) + movl 88(%esp), %ebx + movl 92(%esp), %ebp + call __dpml_ffs_and_shift__ +..B1.112: + movl 188(%esp), %ecx + movl 4(%ecx), %eax + movl %eax, %ecx + cltd + addl $-3, %ecx + adcl $-1, %edx + orl %ecx, %edx + je ..B1.117 +..B1.113: + movl 188(%esp), %esi + addl $64, %ecx + cmpl $31, %ecx + movl 16(%esi), %edx + movl 20(%esi), %esi + jbe ..B1.115 +..B1.114: + movl %ebp, %ebx + xorl %edi, %edi + shrl %cl, %ebx + jmp ..B1.116 +..B1.115: + movl %ebp, %edi + shrdl %cl, %ebp, %ebx + shrl %cl, %edi +..B1.116: + movl 188(%esp), %ecx + orl %ebx, %edx + orl %edi, %esi + movl %edx, 16(%ecx) + movl %esi, 20(%ecx) +..B1.117: + addl $12, %esp + movl 176(%esp), %ebx + pushl %ebx + movl 68(%esp), %edx + lea 1008+__trig_x_table@GOTOFF(%edx), %ecx + pushl %ecx + pushl %ebx + subl 44(%esp), %eax + movl %eax, 4(%ebx) + call __dpml_multiply__ +..B1.118: + movl 40(%esp), %eax + xorl %edx, %edx + shrl $30, %eax + addl $156, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.119: + movl 136(%esp), %ecx + movl 84(%esp), %esi + movl %eax, %edx + jmp ..B1.98 +..B1.120: + movl %ebx, %eax + sarl $31, %eax + movl 180(%esp), %ecx + cltd + addl %ecx, %eax + movl %eax, %ebp + movl 184(%esp), %ebx + adcl %ebx, %edx + andl $1, %ebp + addl %ebp, %eax + movl %eax, %edi + adcl $0, %edx + subl %eax, %ecx + movl %edx, %ebp + movl %edx, %esi + sbbl %edx, %ebx + shll $31, %ebp + shrl $1, %edi + sarl $1, %esi + orl %edi, %ebp + movl %esi, 32(%esp) + orl %ebx, %ecx + movl %ebp, 36(%esp) + je ..B1.125 +..B1.121: + xorl %eax, %eax + subl %eax, %ebx + jge ..B1.124 +..B1.123: + movl $1, %eax +..B1.124: + addl $20, %esp + pushl 168(%esp) + pushl $0 + pushl %eax + movl 68(%esp), %eax + lea 1008+__trig_x_table@GOTOFF(%eax), %edx + pushl %edx + pushl 172(%esp) + call __dpml_addsub__ + jmp ..B1.126 +..B1.125: + movl 188(%esp), %eax + movl 176(%esp), %esi + movl 108(%esp), %ebx + movl 104(%esp), %ebp + movl 80(%esp), %edx + movl %ebx, 8(%eax) + movl %ebp, 12(%eax) + movl %edx, (%eax) + movl 112(%esp), %ecx + movl 16(%esi), %edi + movl 20(%esi), %edx + movl %ecx, 4(%eax) + movl %edi, 16(%eax) + movl %edx, 20(%eax) +..B1.126: + movl 36(%esp), %eax + movl 32(%esp), %edx + addl $156, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret + .align 16,0x90 + .type __dpml_ux_radian_reduce__,@function + .size __dpml_ux_radian_reduce__,.-__dpml_ux_radian_reduce__ + .data +# -- End __dpml_ux_radian_reduce__ + .text +# -- Begin __dpml_ux_degree_reduce__ + .text + .align 16,0x90 +__dpml_ux_degree_reduce__: +# parameter 1: 128 + %esp +# parameter 2: 132 + %esp +# parameter 3: 140 + %esp +..B2.1: +..L5: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $108, %esp + movl 128(%esp), %ecx + call ..L6 +..L6: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L6](%eax), %eax + movl (%ecx), %edx + movl 4(%ecx), %ebx + cmpl $142, %ebx + movl %eax, 52(%esp) + movl %edx, 48(%esp) + jle ..B2.6 +..B2.2: + movl %eax, %ebp + lea 32641(%ebx), %esi + movl %esi, %eax + cltd + movl %edx, %ecx + mull 264+__trig_x_table@GOTOFF(%ebp) + movl %esi, %eax + movl 268+__trig_x_table@GOTOFF(%ebp), %edi + movl %edx, %ebp + mull %edi + movl %edx, %esi + addl %eax, %ebp + movl 52(%esp), %edx + adcl $0, %esi + movl 264+__trig_x_table@GOTOFF(%edx), %eax + mull %ecx + addl %ebp, %eax + adcl %esi, %edx + subl %ebp, %eax + movl %edx, 16(%esp) + sbbl %esi, %edx +..B2.5: + movl %edi, %eax + mull %ecx + addl 16(%esp), %eax + movl 128(%esp), %edi + lea (,%eax,8), %ebp + lea (%ebp,%eax,4), %esi + negl %esi + lea 32772(%esi,%ebx), %ebx + movl %ebx, 4(%edi) +..B2.6: + cmpl $16, %ebx + jl ..B2.61 +..B2.7: + movl %ebx, %eax + movl %ebx, %ebp + cltd + addl $-15, %ebp + movl %edx, %esi + movl %ebp, %ecx + adcl $-1, %esi + xorl %edx, %edx + andl $63, %ecx + movl %esi, %edi + subl %ecx, %ebx + shll $26, %edi + shrl $6, %ebp + sarl $6, %esi + orl %ebp, %edi + movl %edi, 56(%esp) + orl %ecx, %edx + je ..B2.21 +..B2.8: + movl 128(%esp), %edx + movl %ecx, %edi + negl %edi + addl $64, %edi + movl 20(%edx), %ebp + cmpl $31, %ecx + movl %edi, 28(%esp) + movl 16(%edx), %edi + movl %ebp, 16(%esp) + jbe ..B2.10 +..B2.9: + movl %edi, %edx + xorl %ebp, %ebp + shll %cl, %edx + jmp ..B2.11 +..B2.10: + movl %edi, %ebp + movl 16(%esp), %edx + shldl %cl, %edi, %edx + shll %cl, %ebp +..B2.11: + movl 128(%esp), %eax + cmpl $31, %ecx + movl %ebp, 16(%eax) + movl 12(%eax), %ebp + movl %edx, 20(%eax) + movl 8(%eax), %edx + movl %ebp, 24(%esp) + jbe ..B2.13 +..B2.12: + movl %edx, %ebp + movl $0, 32(%esp) + shll %cl, %ebp + jmp ..B2.14 +..B2.13: + movl %edx, %eax + shll %cl, %eax + shldl %cl, %edx, %ebp + movl %eax, 32(%esp) +..B2.14: + cmpl $31, 28(%esp) + jbe ..B2.16 +..B2.15: + movl 28(%esp), %ecx + movl 16(%esp), %edi + movl $0, 20(%esp) + shrl %cl, %edi + jmp ..B2.17 +..B2.16: + movl 28(%esp), %ecx + movl 16(%esp), %eax + shrdl %cl, %eax, %edi + shrl %cl, %eax + movl %eax, 20(%esp) +..B2.17: + movl 32(%esp), %eax + orl %edi, %eax + movl 128(%esp), %edi + orl 20(%esp), %ebp + cmpl $31, 28(%esp) + movl %eax, 8(%edi) + movl %ebp, 12(%edi) + jbe ..B2.19 +..B2.18: + xorl %ebp, %ebp + movl 24(%esp), %edx + shrl %cl, %edx + jmp ..B2.22 +..B2.19: + movl 24(%esp), %ebp + shrdl %cl, %ebp, %edx + shrl %cl, %ebp + jmp ..B2.22 +..B2.21: + xorl %edx, %edx + xorl %ebp, %ebp +..B2.22: + movl 128(%esp), %edi + movl %esi, %ecx + movl %edx, (%edi) + movl 56(%esp), %edx + movl %ebp, 4(%edi) + movl 8(%edi,%edx,8), %eax + movl 12(%edi,%edx,8), %edi + movl %edi, %ebp + xorl %edx, %edx + shrl $20, %ebp + subl %edx, %ecx + jl ..B2.55 +..B2.23: + movl 56(%esp), %edi + addl $1, %edi + movl %edi, 32(%esp) + adcl $0, %esi + movl %esi, %eax + movl %edi, 72(%esp) + testl %eax, %eax + jge ..B2.25 +..B2.24: + addl $1, 72(%esp) + adcl $0, %eax +..B2.25: + movl 72(%esp), %edi + shrdl $1, %eax, %edi + sarl $1, %eax + movl %edi, 72(%esp) + xorl %edi, %edi + movl %eax, %ecx + movl %edi, 28(%esp) + subl %edi, %ecx + movl %edi, 24(%esp) + jb ..B2.104 +..B2.107: + orl 72(%esp), %ecx + je ..B2.104 +..B2.26: + xorl %ecx, %ecx + movl %ecx, 64(%esp) + movl %ecx, 60(%esp) + movl %eax, 76(%esp) + movl %edi, 68(%esp) + movl %ebx, 20(%esp) + movl %esi, 16(%esp) + movl %edi, 80(%esp) + movl 28(%esp), %ecx + movl 24(%esp), %eax +..B2.27: + movl 56(%esp), %edi + movl 64(%esp), %ebx + movl 128(%esp), %esi + addl %edi, %ebx + movl %ebx, 84(%esp) + movl (%esi,%ebx,8), %edi + movl %edi, 100(%esp) + movl 4(%esi,%ebx,8), %edi + movl %edi, 88(%esp) + xorl %edi, %edi + movl %edi, (%esi,%ebx,8) + movl %edi, 4(%esi,%ebx,8) + movl %ecx, %esi + movl 100(%esp), %ebx + orl %eax, %esi + je ..B2.35 +..B2.28: + cmpl $31, %ecx + jbe ..B2.30 +..B2.29: + xorl %esi, %esi + jmp ..B2.31 +..B2.30: + movl %ebx, %esi + shll %cl, %esi +..B2.31: + andl $4095, %esi + xorl %edi, %edi + addl %esi, %ebp + adcl $0, %edx + movl $12, %esi + subl %ecx, %esi + sbbl %eax, %edi + movl %edi, 36(%esp) + cmpl $31, %esi + jbe ..B2.33 +..B2.32: + movl %esi, %ecx + xorl %eax, %eax + movl 88(%esp), %ebx + shrl %cl, %ebx + jmp ..B2.34 +..B2.33: + movl %esi, %ecx + movl 88(%esp), %eax + shrdl %cl, %eax, %ebx + shrl %cl, %eax +..B2.34: + movl %eax, 88(%esp) + xorl %eax, %eax + xorl %ecx, %ecx + subl %esi, %ecx + sbbl 36(%esp), %eax +..B2.35: + movl 88(%esp), %edi + movl %edi, %esi + shrl $28, %edi + andl $268435455, %esi + addl %edi, %ebx + adcl $0, %esi + addl %ebp, %ebx + adcl %edx, %esi + addl $4, %ecx + movl %esi, 96(%esp) + movl 128(%esp), %esi + adcl $0, %eax + movl 84(%esp), %edx + movl -4(%esi,%edx,8), %edi + movl -8(%esi,%edx,8), %ebp + movl %edi, 92(%esp) + xorl %edi, %edi + movl %edi, -8(%esi,%edx,8) + movl %edi, -4(%esi,%edx,8) + movl %ecx, %edx + orl %eax, %edx + je ..B2.43 +..B2.36: + cmpl $31, %ecx + jbe ..B2.38 +..B2.37: + movl $0, 44(%esp) + jmp ..B2.39 +..B2.38: + movl %ebp, %edx + shll %cl, %edx + movl %edx, 44(%esp) +..B2.39: + movl 44(%esp), %edx + xorl %esi, %esi + andl $4095, %edx + addl %edx, %ebx + adcl $0, 96(%esp) + movl $12, %edx + subl %ecx, %edx + sbbl %eax, %esi + movl %esi, 40(%esp) + cmpl $31, %edx + jbe ..B2.41 +..B2.40: + movl %edx, %ecx + xorl %eax, %eax + movl 92(%esp), %ebp + shrl %cl, %ebp + jmp ..B2.42 +..B2.41: + movl %edx, %ecx + movl 92(%esp), %eax + shrdl %cl, %eax, %ebp + shrl %cl, %eax +..B2.42: + movl %eax, 92(%esp) + xorl %eax, %eax + xorl %ecx, %ecx + subl %edx, %ecx + sbbl 40(%esp), %eax +..B2.43: + movl 92(%esp), %esi + movl %esi, %edx + shrl $28, %esi + andl $268435455, %edx + addl %esi, %ebp + movl 68(%esp), %edi + adcl $0, %edx + addl %ebx, %ebp + movl 80(%esp), %ebx + adcl 96(%esp), %edx + addl $4, %ecx + adcl $0, %eax + addl $-2, 64(%esp) + adcl $-1, 60(%esp) + addl $1, %ebx + movl %ebx, 80(%esp) + adcl $0, %edi + subl 72(%esp), %ebx + movl %edi, 68(%esp) + sbbl 76(%esp), %edi + jb ..B2.27 +..B2.44: + movl 80(%esp), %edi + movl %eax, 24(%esp) + movl %edi, %eax + movl %ecx, 28(%esp) + addl %edi, %edi + movl 68(%esp), %ecx + shrl $31, %eax + addl %ecx, %ecx + orl %ecx, %eax + addl $1, %edi + movl 20(%esp), %ebx + movl 16(%esp), %esi + adcl $0, %eax +..B2.45: + movl %edi, %ecx + addl $-1, %ecx + adcl $-1, %eax + subl %ecx, 32(%esp) + sbbl %eax, %esi + jb ..B2.103 +..B2.108: + movl 32(%esp), %eax + orl %esi, %eax + je ..B2.103 +..B2.46: + negl %edi + xorl %ecx, %ecx + addl 56(%esp), %edi + movl 128(%esp), %eax + movl 8(%eax,%edi,8), %esi + movl %esi, 16(%esp) + movl 12(%eax,%edi,8), %esi + movl %ecx, 8(%eax,%edi,8) + movl %ecx, 12(%eax,%edi,8) + movl 24(%esp), %edi + orl 28(%esp), %edi + je ..B2.54 +..B2.47: + cmpl $31, 28(%esp) + jbe ..B2.49 +..B2.48: + xorl %edi, %edi + jmp ..B2.50 +..B2.49: + movl 28(%esp), %ecx + movl 16(%esp), %edi + shll %cl, %edi +..B2.50: + andl $4095, %edi + addl %edi, %ebp + movl 28(%esp), %edi + adcl $0, %edx + negl %edi + addl $12, %edi + movl %edi, 28(%esp) + cmpl $31, %edi + jbe ..B2.52 +..B2.51: + movl %edi, %ecx + xorl %edi, %edi + shrl %cl, %esi + movl %esi, 16(%esp) + jmp ..B2.53 +..B2.52: + movl %edi, %ecx + movl 16(%esp), %edi + shrdl %cl, %esi, %edi + movl %edi, 16(%esp) + movl %esi, %edi + shrl %cl, %edi +..B2.53: + movl %edi, %esi +..B2.54: + movl %esi, %eax + shrl $28, %esi + andl $268435455, %eax + movl 16(%esp), %edi + addl %esi, %edi + movl 128(%esp), %esi + adcl $0, %eax + addl %edi, %ebp + movl 56(%esp), %edi + adcl %eax, %edx + movl 8(%esi,%edi,8), %eax + movl 12(%esi,%edi,8), %edi +..B2.55: + movl %edx, %esi + movl %ebp, %ecx + shll $20, %esi + shrl $12, %ecx + orl %ecx, %esi + shrl $12, %edx + movl %esi, %ecx + orl %edx, %ecx + je ..B2.59 +..B2.57: + andl $4095, %ebp + addl %esi, %ebp + movl %ebp, %ecx + adcl $0, %edx + movl %edx, %esi + shll $20, %esi + shrl $12, %ecx + orl %ecx, %esi + shrl $12, %edx + movl %esi, %ecx + orl %edx, %ecx + jne ..B2.57 +..B2.59: + addl $12, %esp + xorl %esi, %esi + pushl %esi + pushl %esi + movl 124(%esp), %edx + andl $1048575, %edi + pushl %edx + shll $20, %ebp + orl %ebp, %edi + movl 56(%esp), %ebp + movl %ebx, 4(%edx) + movl %eax, 8(%edx,%ebp,8) + movl %edi, 12(%edx,%ebp,8) + call __dpml_ffs_and_shift__ +..B2.60: + subl %eax, %ebx +..B2.61: + movl %ebx, %eax + addl $-5, %ebx + cltd + movl 128(%esp), %esi + adcl $-1, %edx + xorl %edi, %edi + subl %edi, %edx + movl %edi, (%esi) + movl 8(%esi), %ebp + movl 12(%esi), %esi + jl ..B2.66 +..B2.109: + orl %ebx, %edx + je ..B2.66 +..B2.62: + movl 52(%esp), %edi + movl %ebp, %eax + mull 256+__trig_x_table@GOTOFF(%edi) + movl %ebp, %eax + movl 260+__trig_x_table@GOTOFF(%edi), %ecx + movl %edx, %edi + mull %ecx + movl %ecx, 16(%esp) + movl %edx, %ecx + movl 52(%esp), %edx + addl %eax, %edi + adcl $0, %ecx + movl 256+__trig_x_table@GOTOFF(%edx), %eax + mull %esi + addl %edi, %eax + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 20(%esp) + sbbl %ecx, %edx + jae ..B2.64 +..B2.63: + movl $1, 28(%esp) + jmp ..B2.65 +..B2.64: + movl $0, 28(%esp) +..B2.65: + movl 16(%esp), %eax + mull %esi + movl 28(%esp), %edi + addl %edx, %edi + addl 20(%esp), %eax + movl %eax, 24(%esp) + adcl $0, %edi + movl %edi, 28(%esp) + jmp ..B2.67 +..B2.66: + xorl %edx, %edx + movl $1, %ebx + movl %edx, 24(%esp) + movl %edx, 28(%esp) +..B2.67: + negl %ebx + movl 132(%esp), %eax + andl $1, %eax + incl %eax + lea 64(%ebx), %edx + addl $63, %ebx + movl %edx, 16(%esp) + cmpl $31, %ebx + jbe ..B2.69 +..B2.68: + movl %ebx, %ecx + movl %eax, %edi + shll %cl, %edi + xorl %edx, %edx + jmp ..B2.70 +..B2.69: + movl %ebx, %ecx + xorl %edi, %edi + movl %eax, %edx + shldl %cl, %eax, %edi + shll %cl, %edx +..B2.70: + addl 24(%esp), %edx + adcl 28(%esp), %edi + cmpl $31, 16(%esp) + jbe ..B2.72 +..B2.71: + movl $1, %ebx + xorl %eax, %eax + movl 16(%esp), %ecx + shll %cl, %ebx + jmp ..B2.73 +..B2.72: + xorl %ebx, %ebx + movl $1, %eax + movl 16(%esp), %ecx + shldl %cl, %eax, %ebx + shll %cl, %eax +..B2.73: + addl $-1, %eax + notl %eax + adcl $-1, %ebx + andl %eax, %edx + notl %ebx + andl %ebx, %edi + cmpl $31, 16(%esp) + jbe ..B2.75 +..B2.74: + movl %edi, %eax + shrl %cl, %eax + jmp ..B2.76 +..B2.75: + movl %edx, %eax + shrdl %cl, %edi, %eax +..B2.76: + movl %eax, %ebx + negl %ebx + cmpl $0, 48(%esp) + jne ..L7 + movl %eax, %ebx +..L7: + movl 132(%esp), %eax + shrl $1, %eax + addl %ebx, %eax + movl %eax, 24(%esp) + movl $-1275068416, %eax + mull %edx + movl $-1275068416, %eax + movl %edx, %ecx + mull %edi + movl %edx, %ebx + movl %esi, %edi + movl %ebp, %edx + addl %ecx, %eax + adcl $0, %ebx + andl $3, %ebp + shll $30, %edi + shrl $2, %edx + orl %edx, %edi + shrl $2, %esi + subl %eax, %edi + sbbl %ebx, %esi + movl %edi, %ebx + shll $2, %edi + shrl $30, %ebx + orl %edi, %ebp + xorl %edi, %edi + lea (,%esi,4), %ecx + orl %ecx, %ebx + subl %edi, %esi + jl ..B2.99 +..B2.77: + addl $12, %esp + xorl %eax, %eax + pushl %eax + pushl %eax + movl 124(%esp), %edx + pushl %edx + movl %ebp, 8(%edx) + movl %ebx, 12(%edx) + call __dpml_ffs_and_shift__ +..B2.78: + movl 128(%esp), %esi + xorl %ebx, %ebx + andl $536870911, 24(%esp) + movl 8(%esi), %edi + movl %edi, %eax + movl 4(%esi), %ecx + movl 12(%esi), %esi + orl %esi, %eax + jne ..B2.81 +..B2.79: + movl 24(%esp), %ecx + xorl %eax, %eax + andl $2, %ecx + movl $536870912, %ebx + orl %eax, %ecx + je ..B2.97 +..B2.80: + movl 128(%esp), %eax + xorl $-2147483648, (%eax) + jmp ..B2.97 +..B2.81: + cmpl $5, %ecx + jl ..B2.96 +..B2.82: + movl 128(%esp), %eax + movl 16(%eax), %ebp + orl 20(%eax), %ebp + jne ..B2.96 +..B2.83: + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B2.85 +..B2.84: + movl %esi, %ebp + movl $0, 16(%esp) + shrl %cl, %ebp + jmp ..B2.86 +..B2.85: + movl %esi, %eax + movl %edi, %ebp + shrl %cl, %eax + shrdl %cl, %esi, %ebp + movl %eax, 16(%esp) +..B2.86: + cmpl $31, %ecx + jbe ..B2.88 +..B2.87: + movl %ebp, %eax + movl $0, 20(%esp) + shll %cl, %eax + jmp ..B2.89 +..B2.88: + movl %ebp, %edx + movl 16(%esp), %eax + shll %cl, %edx + shldl %cl, %ebp, %eax + movl %edx, 20(%esp) +..B2.89: + subl 20(%esp), %edi + subl %eax, %esi + orl %esi, %edi + jne ..B2.96 +..B2.90: + movl $30, %eax + negl %eax + addl %ebp, %eax + orl 16(%esp), %eax + jne ..B2.94 +..B2.91: + movl 24(%esp), %ecx + xorl %eax, %eax + andl $1, %ecx + orl %eax, %ecx + jne ..B2.96 +..B2.92: + movl 128(%esp), %ecx + movl $1073741824, %ebx + movl 48(%esp), %eax + xorl %eax, (%ecx) + jmp ..B2.97 +..B2.94: + movl $45, %eax + subl %eax, %ebp + orl 16(%esp), %ebp + jne ..B2.96 +..B2.95: + movl $-2147483648, %ebx +..B2.96: + movl 128(%esp), %ecx + movl 48(%esp), %eax + xorl %eax, (%ecx) +..B2.97: + addl $12, %esp + pushl 128(%esp) + movl 44(%esp), %eax + lea 216+__trig_x_table@GOTOFF(%eax), %ecx + pushl %ecx + pushl 124(%esp) + call __dpml_multiply__ +..B2.98: + movl 24(%esp), %eax + movl %ebx, %edx + addl $108, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B2.99: + movl 128(%esp), %edx + xorl %eax, %eax + xorl $-2147483648, 48(%esp) + movl 16(%edx), %ecx + movl 20(%edx), %esi + xorl %edx, %edx + subl %ecx, %edx + sbbl %esi, %eax + orl %esi, %ecx + je ..B2.101 +..B2.100: + movl $1, %ecx + jmp ..B2.102 +..B2.101: + xorl %ecx, %ecx +..B2.102: + movl 128(%esp), %esi + addl %ecx, %ebp + adcl $0, %ebx + movl %edx, 16(%esi) + xorl %edx, %edx + movl %eax, 20(%esi) + movl %ebp, %eax + xorl %ebp, %ebp + movl %ebx, %ecx + xorl %ebx, %ebx + subl %eax, %ebp + sbbl %ecx, %ebx + jmp ..B2.77 +..B2.103: + movl 56(%esp), %edi + movl 128(%esp), %esi + movl 8(%esi,%edi,8), %eax + movl 12(%esi,%edi,8), %edi + jmp ..B2.55 +..B2.104: + movl $1, %edi + xorl %eax, %eax + jmp ..B2.45 + .align 16,0x90 + .type __dpml_ux_degree_reduce__,@function + .size __dpml_ux_degree_reduce__,.-__dpml_ux_degree_reduce__ + .data +# -- End __dpml_ux_degree_reduce__ + .text +# -- Begin __dpml_ux_sincos + .text + .align 16,0x90 + .hidden __dpml_ux_sincos + .globl __dpml_ux_sincos +__dpml_ux_sincos: +# parameter 1: 192 + %esp +# parameter 2: 196 + %esp +# parameter 3: 204 + %esp +# parameter 4: 212 + %esp +..B3.1: +..L8: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $172, %esp + xorl %ecx, %ecx + call ..L9 +..L9: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L9](%eax), %eax + movl %eax, 148(%esp) + movl 204(%esp), %eax + andl $16, %eax + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 156(%esp) + orl %ecx, %eax + je ..B3.3 +..B3.2: + movl 148(%esp), %eax + lea __dpml_ux_degree_reduce__@GOTOFF(%eax), %edx + movl %edx, %eax + jmp ..B3.4 +..B3.3: + movl 148(%esp), %eax + lea __dpml_ux_radian_reduce__@GOTOFF(%eax), %edx + lea __dpml_ux_degree_reduce__@GOTOFF(%eax), %eax +..B3.4: + cmpl %eax, %edx + jne ..B3.119 +..B3.5: + movl 192(%esp), %edx + movl (%edx), %eax + movl 4(%edx), %ebx + cmpl $142, %ebx + movl %eax, 68(%esp) + jle ..B3.10 +..B3.6: + movl 148(%esp), %ebp + lea 32641(%ebx), %esi + movl %esi, %eax + cltd + movl %edx, %ecx + mull 264+__trig_x_table@GOTOFF(%ebp) + movl %esi, %eax + movl 268+__trig_x_table@GOTOFF(%ebp), %edi + movl %edx, %ebp + mull %edi + movl %edx, %esi + addl %eax, %ebp + movl 148(%esp), %edx + adcl $0, %esi + movl 264+__trig_x_table@GOTOFF(%edx), %eax + mull %ecx + addl %ebp, %eax + adcl %esi, %edx + subl %ebp, %eax + movl %edx, 32(%esp) + sbbl %esi, %edx +..B3.9: + movl %edi, %eax + mull %ecx + addl 32(%esp), %eax + movl 192(%esp), %edi + lea (,%eax,8), %ebp + lea (%ebp,%eax,4), %esi + negl %esi + lea 32772(%esi,%ebx), %ebx + movl %ebx, 4(%edi) +..B3.10: + cmpl $16, %ebx + jl ..B3.65 +..B3.11: + movl %ebx, %eax + movl %ebx, %ebp + cltd + addl $-15, %ebp + movl %edx, %esi + movl %ebp, %ecx + adcl $-1, %esi + xorl %edx, %edx + andl $63, %ecx + movl %esi, %edi + subl %ecx, %ebx + shll $26, %edi + shrl $6, %ebp + sarl $6, %esi + orl %ebp, %edi + movl %edi, 72(%esp) + orl %ecx, %edx + je ..B3.25 +..B3.12: + movl 192(%esp), %edx + movl %ecx, %edi + negl %edi + addl $64, %edi + movl 20(%edx), %ebp + cmpl $31, %ecx + movl %edi, 44(%esp) + movl 16(%edx), %edi + movl %ebp, 32(%esp) + jbe ..B3.14 +..B3.13: + movl %edi, %edx + xorl %ebp, %ebp + shll %cl, %edx + jmp ..B3.15 +..B3.14: + movl %edi, %ebp + movl 32(%esp), %edx + shldl %cl, %edi, %edx + shll %cl, %ebp +..B3.15: + movl 192(%esp), %eax + cmpl $31, %ecx + movl %ebp, 16(%eax) + movl 12(%eax), %ebp + movl %edx, 20(%eax) + movl 8(%eax), %edx + movl %ebp, 40(%esp) + jbe ..B3.17 +..B3.16: + movl %edx, %ebp + movl $0, 48(%esp) + shll %cl, %ebp + jmp ..B3.18 +..B3.17: + movl %edx, %eax + shll %cl, %eax + shldl %cl, %edx, %ebp + movl %eax, 48(%esp) +..B3.18: + cmpl $31, 44(%esp) + jbe ..B3.20 +..B3.19: + movl 44(%esp), %ecx + movl 32(%esp), %edi + movl $0, 36(%esp) + shrl %cl, %edi + jmp ..B3.21 +..B3.20: + movl 44(%esp), %ecx + movl 32(%esp), %eax + shrdl %cl, %eax, %edi + shrl %cl, %eax + movl %eax, 36(%esp) +..B3.21: + movl 48(%esp), %eax + orl %edi, %eax + movl 192(%esp), %edi + orl 36(%esp), %ebp + cmpl $31, 44(%esp) + movl %eax, 8(%edi) + movl %ebp, 12(%edi) + jbe ..B3.23 +..B3.22: + xorl %ebp, %ebp + movl 40(%esp), %edx + shrl %cl, %edx + jmp ..B3.26 +..B3.23: + movl 40(%esp), %ebp + shrdl %cl, %ebp, %edx + shrl %cl, %ebp + jmp ..B3.26 +..B3.25: + xorl %edx, %edx + xorl %ebp, %ebp +..B3.26: + movl 192(%esp), %edi + movl %edx, (%edi) + movl 72(%esp), %edx + movl %ebp, 4(%edi) + movl 8(%edi,%edx,8), %eax + movl 12(%edi,%edx,8), %edi + movl %edi, %ebp + shrl $20, %ebp + xorl %edx, %edx + movl %ebp, 48(%esp) + movl %esi, %ebp + subl %edx, %ebp + jl ..B3.59 +..B3.27: + movl 72(%esp), %eax + addl $1, %eax + movl %eax, 52(%esp) + adcl $0, %esi + movl %esi, %ebp + testl %ebp, %ebp + jge ..B3.29 +..B3.28: + addl $1, %eax + adcl $0, %ebp +..B3.29: + shrdl $1, %ebp, %eax + sarl $1, %ebp + xorl %edi, %edi + movl %ebp, %ecx + movl %edi, 44(%esp) + subl %edi, %ecx + movl %edi, 40(%esp) + jb ..B3.229 +..B3.262: + orl %eax, %ecx + je ..B3.229 +..B3.30: + xorl %ecx, %ecx + movl %ecx, 80(%esp) + movl %ecx, 76(%esp) + movl %ebp, 92(%esp) + movl %eax, 88(%esp) + movl %edi, 84(%esp) + movl %ebx, 32(%esp) + movl %esi, 36(%esp) + movl %edi, 100(%esp) + movl 44(%esp), %ecx + movl 40(%esp), %eax + movl 48(%esp), %ebp +..B3.31: + movl 72(%esp), %edi + movl 80(%esp), %ebx + movl 192(%esp), %esi + addl %edi, %ebx + movl %ebx, 96(%esp) + movl (%esi,%ebx,8), %edi + movl %edi, 116(%esp) + movl 4(%esi,%ebx,8), %edi + movl %edi, 104(%esp) + xorl %edi, %edi + movl %edi, (%esi,%ebx,8) + movl %edi, 4(%esi,%ebx,8) + movl %ecx, %esi + movl 116(%esp), %ebx + orl %eax, %esi + je ..B3.39 +..B3.32: + cmpl $31, %ecx + jbe ..B3.34 +..B3.33: + xorl %esi, %esi + jmp ..B3.35 +..B3.34: + movl %ebx, %esi + shll %cl, %esi +..B3.35: + andl $4095, %esi + xorl %edi, %edi + addl %esi, %ebp + adcl $0, %edx + movl $12, %esi + subl %ecx, %esi + sbbl %eax, %edi + movl %edi, 56(%esp) + cmpl $31, %esi + jbe ..B3.37 +..B3.36: + movl %esi, %ecx + xorl %eax, %eax + movl 104(%esp), %ebx + shrl %cl, %ebx + jmp ..B3.38 +..B3.37: + movl %esi, %ecx + movl 104(%esp), %eax + shrdl %cl, %eax, %ebx + shrl %cl, %eax +..B3.38: + movl %eax, 104(%esp) + xorl %eax, %eax + xorl %ecx, %ecx + subl %esi, %ecx + sbbl 56(%esp), %eax +..B3.39: + movl 104(%esp), %edi + movl %edi, %esi + shrl $28, %edi + andl $268435455, %esi + addl %edi, %ebx + adcl $0, %esi + addl %ebp, %ebx + adcl %edx, %esi + addl $4, %ecx + movl %esi, 112(%esp) + movl 192(%esp), %esi + adcl $0, %eax + movl 96(%esp), %edx + movl -4(%esi,%edx,8), %edi + movl -8(%esi,%edx,8), %ebp + movl %edi, 108(%esp) + xorl %edi, %edi + movl %edi, -8(%esi,%edx,8) + movl %edi, -4(%esi,%edx,8) + movl %ecx, %edx + orl %eax, %edx + je ..B3.47 +..B3.40: + cmpl $31, %ecx + jbe ..B3.42 +..B3.41: + movl $0, 64(%esp) + jmp ..B3.43 +..B3.42: + movl %ebp, %edx + shll %cl, %edx + movl %edx, 64(%esp) +..B3.43: + movl 64(%esp), %edx + xorl %esi, %esi + andl $4095, %edx + addl %edx, %ebx + adcl $0, 112(%esp) + movl $12, %edx + subl %ecx, %edx + sbbl %eax, %esi + movl %esi, 60(%esp) + cmpl $31, %edx + jbe ..B3.45 +..B3.44: + movl %edx, %ecx + xorl %eax, %eax + movl 108(%esp), %ebp + shrl %cl, %ebp + jmp ..B3.46 +..B3.45: + movl %edx, %ecx + movl 108(%esp), %eax + shrdl %cl, %eax, %ebp + shrl %cl, %eax +..B3.46: + movl %eax, 108(%esp) + xorl %eax, %eax + xorl %ecx, %ecx + subl %edx, %ecx + sbbl 60(%esp), %eax +..B3.47: + movl 108(%esp), %esi + movl %esi, %edx + shrl $28, %esi + andl $268435455, %edx + addl %esi, %ebp + movl 84(%esp), %edi + adcl $0, %edx + addl %ebx, %ebp + movl 100(%esp), %ebx + adcl 112(%esp), %edx + addl $4, %ecx + adcl $0, %eax + addl $-2, 80(%esp) + adcl $-1, 76(%esp) + addl $1, %ebx + movl %ebx, 100(%esp) + adcl $0, %edi + subl 88(%esp), %ebx + movl %edi, 84(%esp) + sbbl 92(%esp), %edi + jb ..B3.31 +..B3.48: + movl 100(%esp), %edi + movl %eax, 40(%esp) + movl %edi, %eax + movl %ebp, 48(%esp) + addl %edi, %edi + movl 84(%esp), %ebp + shrl $31, %eax + addl %ebp, %ebp + orl %ebp, %eax + addl $1, %edi + movl 32(%esp), %ebx + movl 36(%esp), %esi + adcl $0, %eax + movl %ecx, 44(%esp) +..B3.49: + movl %edi, %ebp + addl $-1, %ebp + adcl $-1, %eax + subl %ebp, 52(%esp) + sbbl %eax, %esi + jb ..B3.228 +..B3.263: + movl 52(%esp), %ebp + orl %esi, %ebp + je ..B3.228 +..B3.50: + negl %edi + xorl %esi, %esi + addl 72(%esp), %edi + movl 192(%esp), %eax + movl 8(%eax,%edi,8), %ebp + movl %ebp, 32(%esp) + movl 12(%eax,%edi,8), %ebp + movl %esi, 8(%eax,%edi,8) + movl %esi, 12(%eax,%edi,8) + movl 40(%esp), %edi + orl 44(%esp), %edi + je ..B3.58 +..B3.51: + cmpl $31, 44(%esp) + ja ..B3.54 +..B3.53: + movl 44(%esp), %ecx + movl 32(%esp), %esi + shll %cl, %esi +..B3.54: + andl $4095, %esi + addl %esi, 48(%esp) + movl 44(%esp), %esi + adcl $0, %edx + negl %esi + addl $12, %esi + movl %esi, 44(%esp) + cmpl $31, %esi + jbe ..B3.56 +..B3.55: + movl %esi, %ecx + xorl %esi, %esi + shrl %cl, %ebp + movl %ebp, 32(%esp) + jmp ..B3.57 +..B3.56: + movl %esi, %ecx + movl 32(%esp), %esi + shrdl %cl, %ebp, %esi + movl %esi, 32(%esp) + movl %ebp, %esi + shrl %cl, %esi +..B3.57: + movl %esi, %ebp +..B3.58: + movl %ebp, %edi + shrl $28, %ebp + andl $268435455, %edi + movl 32(%esp), %esi + addl %ebp, %esi + movl 192(%esp), %ebp + adcl $0, %edi + addl %esi, 48(%esp) + movl 72(%esp), %esi + adcl %edi, %edx + movl 8(%ebp,%esi,8), %eax + movl 12(%ebp,%esi,8), %edi +..B3.59: + movl %edx, %esi + movl 48(%esp), %ebp + shll $20, %esi + shrl $12, %ebp + orl %ebp, %esi + shrl $12, %edx + movl %esi, %ebp + orl %edx, %ebp + je ..B3.63 +..B3.60: + movl 48(%esp), %ebp +..B3.61: + andl $4095, %ebp + addl %esi, %ebp + movl %ebp, %ecx + adcl $0, %edx + movl %edx, %esi + shll $20, %esi + shrl $12, %ecx + orl %ecx, %esi + shrl $12, %edx + movl %esi, %ecx + orl %edx, %ecx + jne ..B3.61 +..B3.62: + movl %ebp, 48(%esp) +..B3.63: + addl $12, %esp + xorl %ebp, %ebp + pushl %ebp + pushl %ebp + movl 188(%esp), %edx + andl $1048575, %edi + pushl %edx + movl 48(%esp), %esi + shll $20, %esi + orl %esi, %edi + movl 72(%esp), %esi + movl %ebx, 4(%edx) + movl %eax, 8(%edx,%esi,8) + movl %edi, 12(%edx,%esi,8) + call __dpml_ffs_and_shift__ +..B3.64: + subl %eax, %ebx +..B3.65: + movl %ebx, %eax + addl $-5, %ebx + cltd + movl 192(%esp), %esi + adcl $-1, %edx + xorl %edi, %edi + subl %edi, %edx + movl %edi, (%esi) + movl 8(%esi), %ebp + movl 12(%esi), %esi + jl ..B3.70 +..B3.264: + orl %ebx, %edx + je ..B3.70 +..B3.66: + movl 148(%esp), %edi + movl %ebp, %eax + mull 256+__trig_x_table@GOTOFF(%edi) + movl %ebp, %eax + movl 260+__trig_x_table@GOTOFF(%edi), %ecx + movl %edx, %edi + mull %ecx + movl %ecx, 32(%esp) + movl %edx, %ecx + movl 148(%esp), %edx + addl %eax, %edi + adcl $0, %ecx + movl 256+__trig_x_table@GOTOFF(%edx), %eax + mull %esi + addl %edi, %eax + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 36(%esp) + sbbl %ecx, %edx + jae ..B3.68 +..B3.67: + movl $1, 44(%esp) + jmp ..B3.69 +..B3.68: + movl $0, 44(%esp) +..B3.69: + movl 32(%esp), %eax + mull %esi + movl 44(%esp), %edi + addl %edx, %edi + addl 36(%esp), %eax + movl %eax, 40(%esp) + adcl $0, %edi + movl %edi, 44(%esp) + jmp ..B3.71 +..B3.70: + xorl %edx, %edx + movl $1, %ebx + movl %edx, 40(%esp) + movl %edx, 44(%esp) +..B3.71: + negl %ebx + movl 196(%esp), %eax + andl $1, %eax + incl %eax + lea 64(%ebx), %edx + addl $63, %ebx + movl %edx, 32(%esp) + cmpl $31, %ebx + jbe ..B3.73 +..B3.72: + movl %ebx, %ecx + movl %eax, %edi + shll %cl, %edi + xorl %edx, %edx + jmp ..B3.74 +..B3.73: + movl %ebx, %ecx + xorl %edi, %edi + movl %eax, %edx + shldl %cl, %eax, %edi + shll %cl, %edx +..B3.74: + addl 40(%esp), %edx + adcl 44(%esp), %edi + cmpl $31, 32(%esp) + jbe ..B3.76 +..B3.75: + movl $1, %ebx + xorl %eax, %eax + movl 32(%esp), %ecx + shll %cl, %ebx + jmp ..B3.77 +..B3.76: + xorl %ebx, %ebx + movl $1, %eax + movl 32(%esp), %ecx + shldl %cl, %eax, %ebx + shll %cl, %eax +..B3.77: + addl $-1, %eax + notl %eax + adcl $-1, %ebx + andl %eax, %edx + notl %ebx + andl %ebx, %edi + cmpl $31, 32(%esp) + jbe ..B3.79 +..B3.78: + movl %edi, %eax + shrl %cl, %eax + jmp ..B3.80 +..B3.79: + movl %edx, %eax + shrdl %cl, %edi, %eax +..B3.80: + movl %eax, %ebx + negl %ebx + cmpl $0, 68(%esp) + jne ..L10 + movl %eax, %ebx +..L10: + movl 196(%esp), %eax + shrl $1, %eax + addl %ebx, %eax + movl %eax, 44(%esp) + movl $-1275068416, %eax + mull %edx + movl $-1275068416, %eax + movl %edx, %ecx + mull %edi + movl %edx, %ebx + movl %esi, %edi + movl %ebp, %edx + addl %ecx, %eax + adcl $0, %ebx + andl $3, %ebp + shll $30, %edi + shrl $2, %edx + orl %edx, %edi + shrl $2, %esi + subl %eax, %edi + sbbl %ebx, %esi + movl %edi, %ebx + shll $2, %edi + shrl $30, %ebx + orl %edi, %ebp + xorl %edi, %edi + lea (,%esi,4), %ecx + orl %ecx, %ebx + subl %edi, %esi + jl ..B3.224 +..B3.81: + addl $12, %esp + xorl %eax, %eax + pushl %eax + pushl %eax + movl 188(%esp), %edx + pushl %edx + movl %ebp, 8(%edx) + movl %ebx, 12(%edx) + call __dpml_ffs_and_shift__ +..B3.82: + movl 192(%esp), %ebp + xorl %ebx, %ebx + movl 8(%ebp), %esi + movl %esi, %eax + movl 4(%ebp), %ecx + movl 12(%ebp), %ebp + orl %ebp, %eax + jne ..B3.85 +..B3.83: + movl 44(%esp), %edx + xorl %eax, %eax + andl $2, %edx + movl $536870912, %ebx + orl %eax, %edx + je ..B3.101 +..B3.84: + movl 192(%esp), %eax + xorl $-2147483648, (%eax) + jmp ..B3.101 +..B3.85: + cmpl $5, %ecx + jl ..B3.100 +..B3.86: + movl 192(%esp), %eax + movl 16(%eax), %edx + orl 20(%eax), %edx + jne ..B3.100 +..B3.87: + negl %ecx + addl $64, %ecx + cmpl $31, %ecx + jbe ..B3.89 +..B3.88: + movl %ebp, %edx + movl $0, 32(%esp) + shrl %cl, %edx + jmp ..B3.90 +..B3.89: + movl %ebp, %eax + movl %esi, %edx + shrl %cl, %eax + shrdl %cl, %ebp, %edx + movl %eax, 32(%esp) +..B3.90: + cmpl $31, %ecx + jbe ..B3.92 +..B3.91: + movl %edx, %eax + movl $0, 36(%esp) + shll %cl, %eax + jmp ..B3.93 +..B3.92: + movl %edx, %edi + movl 32(%esp), %eax + shll %cl, %edi + shldl %cl, %edx, %eax + movl %edi, 36(%esp) +..B3.93: + subl 36(%esp), %esi + subl %eax, %ebp + orl %ebp, %esi + jne ..B3.100 +..B3.94: + movl $30, %eax + negl %eax + addl %edx, %eax + orl 32(%esp), %eax + jne ..B3.98 +..B3.95: + movl 44(%esp), %edx + xorl %eax, %eax + andl $1, %edx + orl %eax, %edx + jne ..B3.100 +..B3.96: + movl 192(%esp), %edx + movl $1073741824, %ebx + movl 68(%esp), %eax + xorl %eax, (%edx) + jmp ..B3.101 +..B3.98: + movl $45, %eax + subl %eax, %edx + orl 32(%esp), %edx + jne ..B3.100 +..B3.99: + movl $-2147483648, %ebx +..B3.100: + movl 192(%esp), %edx + movl 68(%esp), %eax + xorl %eax, (%edx) +..B3.101: + addl $12, %esp + lea 36(%esp), %eax + pushl %eax + movl 100(%eax), %edx + lea 216+__trig_x_table@GOTOFF(%edx), %ecx + pushl %ecx + pushl 188(%esp) + call __dpml_multiply__ +..B3.103: + movl 204(%esp), %esi + movl $3, %eax + andl $-17, %esi + movl %esi, %edx + subl %eax, %edx + orl 208(%esp), %edx + jne ..B3.106 +..B3.105: + movl $1, %eax +..B3.106: + sarl $29, %ebx + andl %eax, %ebx + xorl %eax, %eax + orl %eax, %ebx + jne ..B3.108 +..B3.107: + movl $1, %ebp + jmp ..B3.109 +..B3.108: + xorl %ebp, %ebp +..B3.109: + movl %esi, %ecx + movl $3, %edx + subl %edx, %ecx + movl 44(%esp), %ebx + andl $1, %ebx + orl 208(%esp), %ecx + je ..B3.220 +..B3.110: + xorl %edx, %edx + orl %edx, %ebx + je ..B3.112 +..B3.111: + movl $1216, %ecx + jmp ..B3.113 +..B3.112: + movl $1038, %ecx +..B3.113: + addl $28, %esp + xorl %edx, %edx + movl 184(%esp), %ebx + pushl %ebx + pushl %edx + pushl %ecx + pushl %edx + pushl $13 + movl 140(%esp), %ecx + lea 272+__trig_x_table@GOTOFF(%ecx), %edi + pushl %edi + lea 44(%esp), %edx + pushl %edx + call __dpml_evaluate_rational__ +..B3.114: + movl 44(%esp), %ecx + xorl %edx, %edx + andl $2, %ecx + orl %edx, %ecx + je ..B3.116 +..B3.115: + xorl $-2147483648, (%ebx) +..B3.116: + movl $3, %edx + subl %edx, %esi + orl 208(%esp), %esi + je ..B3.216 +..B3.117: + movl 156(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B3.215 +..B3.118: + movl %ebp, %eax + xorl %edx, %edx + addl $172, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B3.119: + movl 192(%esp), %ebp + movl 8(%ebp), %eax + movl 12(%ebp), %edx + movl 16(%ebp), %ecx + movl 20(%ebp), %ebx + movl 4(%ebp), %edi + testl %edi, %edi + movl (%ebp), %esi + movl %eax, 104(%esp) + movl %edx, 100(%esp) + movl %ecx, 108(%esp) + movl %ebx, 112(%esp) + movl %edi, 128(%esp) + movl %esi, 76(%esp) + jl ..B3.253 +..B3.120: + movl %edi, %eax + cltd + addl $8, %eax + movl %eax, %edi + adcl $0, %edx + andl $63, %eax + movl 148(%esp), %ebp + shll $26, %edx + shrl $6, %edi + orl %edx, %edi + movl __four_over_pi@GOT(%ebp), %esi + movl %edi, 72(%esp) + movl %eax, 128(%esp) + lea (%esi,%edi,8), %ecx + movl (%ecx), %ebx + movl 4(%ecx), %ebp + movl 8(%ecx), %esi + movl 12(%ecx), %edi + movl 20(%ecx), %edx + movl %ebx, 60(%esp) + movl %ebp, 56(%esp) + movl %esi, 68(%esp) + movl %edi, 64(%esp) + movl %edx, 32(%esp) + movl 16(%ecx), %ebp + movl 24(%ecx), %edi + movl 28(%ecx), %esi + movl 32(%ecx), %ebx + movl 36(%ecx), %edx + addl $40, %ecx + movl %ecx, 120(%esp) + xorl %ecx, %ecx + movl %ebx, 116(%esp) + orl %eax, %ecx + movl %edx, 124(%esp) + je ..B3.146 +..B3.121: + movl %eax, %ecx + movl %ecx, %edx + negl %edx + addl $64, %edx + movl %edx, 72(%esp) + cmpl $31, %ecx + jbe ..B3.123 +..B3.122: + xorl %eax, %eax + movl 60(%esp), %edx + shll %cl, %edx + movl %edx, 56(%esp) + jmp ..B3.124 +..B3.123: + movl 56(%esp), %edx + movl 60(%esp), %eax + shldl %cl, %eax, %edx + movl %edx, 56(%esp) + shll %cl, %eax +..B3.124: + cmpl $31, 72(%esp) + jbe ..B3.126 +..B3.125: + movl 72(%esp), %ecx + xorl %edx, %edx + movl 64(%esp), %ebx + shrl %cl, %ebx + movl %ebx, 60(%esp) + jmp ..B3.127 +..B3.126: + movl 72(%esp), %ecx + movl 68(%esp), %ebx + movl 64(%esp), %edx + shrdl %cl, %edx, %ebx + movl %ebx, 60(%esp) + shrl %cl, %edx +..B3.127: + orl %eax, 60(%esp) + orl %edx, 56(%esp) + cmpl $31, 128(%esp) + jbe ..B3.129 +..B3.128: + movl 128(%esp), %ecx + xorl %eax, %eax + movl 68(%esp), %edx + shll %cl, %edx + movl %edx, 64(%esp) + jmp ..B3.130 +..B3.129: + movl 128(%esp), %ecx + movl 64(%esp), %edx + movl 68(%esp), %eax + shldl %cl, %eax, %edx + movl %edx, 64(%esp) + shll %cl, %eax +..B3.130: + cmpl $31, 72(%esp) + jbe ..B3.132 +..B3.131: + movl 72(%esp), %ecx + xorl %edx, %edx + movl 32(%esp), %ebx + shrl %cl, %ebx + movl %ebx, 68(%esp) + jmp ..B3.133 +..B3.132: + movl %ebp, %ebx + movl 72(%esp), %ecx + movl 32(%esp), %edx + shrdl %cl, %edx, %ebx + movl %ebx, 68(%esp) + shrl %cl, %edx +..B3.133: + orl %eax, 68(%esp) + orl %edx, 64(%esp) + cmpl $31, 128(%esp) + jbe ..B3.135 +..B3.134: + movl 128(%esp), %ecx + xorl %edx, %edx + shll %cl, %ebp + movl %ebp, 32(%esp) + jmp ..B3.136 +..B3.135: + movl 128(%esp), %ecx + movl 32(%esp), %edx + shldl %cl, %ebp, %edx + movl %edx, 32(%esp) + movl %ebp, %edx + shll %cl, %edx +..B3.136: + cmpl $31, 72(%esp) + jbe ..B3.138 +..B3.137: + movl %esi, %ebp + xorl %ebx, %ebx + movl 72(%esp), %ecx + shrl %cl, %ebp + jmp ..B3.139 +..B3.138: + movl %edi, %ebp + movl %esi, %ebx + movl 72(%esp), %ecx + shrdl %cl, %esi, %ebp + shrl %cl, %ebx +..B3.139: + orl %ebx, 32(%esp) + orl %edx, %ebp + cmpl $31, 128(%esp) + jbe ..B3.141 +..B3.140: + movl %edi, %esi + xorl %edx, %edx + movl 128(%esp), %ecx + shll %cl, %esi + jmp ..B3.142 +..B3.141: + movl %edi, %edx + movl 128(%esp), %ecx + shldl %cl, %edi, %esi + shll %cl, %edx +..B3.142: + cmpl $31, 72(%esp) + jbe ..B3.144 +..B3.143: + movl 72(%esp), %ecx + xorl %ebx, %ebx + movl 124(%esp), %edi + shrl %cl, %edi + jmp ..B3.145 +..B3.144: + movl 72(%esp), %ecx + movl 116(%esp), %edi + movl 124(%esp), %ebx + shrdl %cl, %ebx, %edi + shrl %cl, %ebx +..B3.145: + orl %edx, %edi + orl %ebx, %esi +..B3.146: + movl %edi, %eax + mull 108(%esp) + movl %edi, %eax + movl %edx, %ecx + mull 112(%esp) + addl %eax, %ecx + movl %edx, %ebx + movl 108(%esp), %eax + adcl $0, %ebx + mull %esi + addl %ecx, %eax + adcl %ebx, %edx + subl %ecx, %eax + movl %edx, 48(%esp) + sbbl %ebx, %edx + jae ..B3.148 +..B3.147: + movl $1, %ebx + jmp ..B3.149 +..B3.148: + xorl %ebx, %ebx +..B3.149: + movl %esi, %eax + movl 112(%esp), %ecx + mull %ecx + addl %edx, %ebx + addl 48(%esp), %eax + movl %eax, 84(%esp) + adcl $0, %ebx + movl %ebx, 88(%esp) + movl %esi, %ebx + movl 108(%esp), %eax + imull %edi, %ecx + imull %eax, %ebx + mull %edi + addl %ebx, %ecx + movl 100(%esp), %ebx + addl %ecx, %edx + movl %ebp, 52(%esp) + movl %esi, %ebp + movl %edx, 96(%esp) + movl %ebx, %edx + movl 104(%esp), %ecx + imull %ecx, %ebp + imull %edi, %edx + movl %eax, 92(%esp) + movl %edi, %eax + addl %edx, %ebp + mull %ecx + movl %eax, 36(%esp) + movl %edi, %eax + addl %ebp, %edx + movl %edx, 40(%esp) + mull %ecx + movl %edi, %eax + movl %edx, %ebp + mull %ebx + addl %eax, %ebp + movl %ecx, %eax + movl %edx, %edi + adcl $0, %edi + mull %esi + addl %ebp, %eax + movl 88(%esp), %ebx + adcl %edi, %edx + subl %ebp, %eax + movl %edx, 44(%esp) + movl 52(%esp), %ebp + sbbl %edi, %edx + jae ..B3.151 +..B3.150: + movl $1, %ecx + jmp ..B3.152 +..B3.151: + xorl %ecx, %ecx +..B3.152: + movl %esi, %eax + mull 100(%esp) + movl %eax, %esi + addl %edx, %ecx + addl 44(%esp), %esi + movl 36(%esp), %edi + movl 84(%esp), %eax + adcl $0, %ecx + addl %edi, %eax + movl 40(%esp), %edx + adcl %edx, %ebx + movl %eax, 84(%esp) + subl %edi, %eax + movl %ebx, %edi + sbbl %edx, %edi + jae ..B3.154 +..B3.153: + movl $1, %edx + jmp ..B3.155 +..B3.154: + xorl %edx, %edx +..B3.155: + addl %edx, %esi + movl %esi, 80(%esp) + adcl $0, %ecx + movl %ecx, 132(%esp) + movl 112(%esp), %ecx + movl %ecx, %edi + movl 32(%esp), %esi + movl %esi, %edx + movl %ebx, 88(%esp) + movl 108(%esp), %ebx + movl %ebx, %eax + imull %ebp, %edi + imull %ebx, %edx + addl %edx, %edi + mull %ebp + movl %eax, 40(%esp) + movl %ebx, %eax + addl %edi, %edx + movl %edx, 44(%esp) + mull %ebp + movl %ebp, %eax + movl %edx, %edi + mull %ecx + addl %eax, %edi + movl %ebx, %eax + movl %edx, %ecx + adcl $0, %ecx + mull %esi + addl %edi, %eax + movl 80(%esp), %esi + adcl %ecx, %edx + subl %edi, %eax + movl %edx, 48(%esp) + movl 88(%esp), %ebx + sbbl %ecx, %edx + movl 132(%esp), %ecx + jae ..B3.157 +..B3.156: + movl $1, %edi + jmp ..B3.158 +..B3.157: + xorl %edi, %edi +..B3.158: + movl 32(%esp), %eax + mull 112(%esp) + addl %edx, %edi + addl 48(%esp), %eax + movl %eax, 36(%esp) + adcl $0, %edi + movl %edi, 52(%esp) + movl 40(%esp), %edi + movl 84(%esp), %eax + addl %edi, %eax + movl 44(%esp), %edx + adcl %edx, %ebx + movl %eax, 84(%esp) + subl %edi, %eax + movl %ebx, %edi + sbbl %edx, %edi + movl 52(%esp), %edi + jae ..B3.160 +..B3.159: + movl $1, 40(%esp) + jmp ..B3.161 +..B3.160: + movl $0, 40(%esp) +..B3.161: + movl 40(%esp), %edx + addl %edx, %esi + movl %esi, %eax + adcl $0, %ecx + subl %edx, %eax + movl $0, %edx + movl %ecx, %eax + sbbl %edx, %eax + jae ..B3.163 +..B3.162: + movl $1, 48(%esp) + jmp ..B3.164 +..B3.163: + movl $0, 48(%esp) +..B3.164: + movl 36(%esp), %edx + addl %edx, %esi + movl %esi, %eax + adcl %edi, %ecx + subl %edx, %eax + movl %ecx, %edx + sbbl %edi, %edx + jae ..B3.166 +..B3.165: + movl $1, %edx + jmp ..B3.167 +..B3.166: + xorl %edx, %edx +..B3.167: + movl %esi, 80(%esp) + movl %ecx, 132(%esp) + movl 100(%esp), %ecx + movl %ecx, %edi + movl 32(%esp), %esi + addl %edx, 48(%esp) + movl %esi, %edx + movl %ebx, 88(%esp) + movl 104(%esp), %ebx + movl %ebx, %eax + imull %ebp, %edi + imull %ebx, %edx + addl %edx, %edi + mull %ebp + movl %eax, 36(%esp) + movl %ebx, %eax + addl %edi, %edx + movl %edx, 40(%esp) + mull %ebp + movl %ebp, %eax + movl %edx, %edi + mull %ecx + addl %eax, %edi + movl %ebx, %eax + movl %edx, %ebp + adcl $0, %ebp + mull %esi + addl %edi, %eax + movl 132(%esp), %ecx + adcl %ebp, %edx + subl %edi, %eax + movl %edx, 44(%esp) + movl 80(%esp), %esi + sbbl %ebp, %edx + movl 88(%esp), %ebx + jae ..B3.169 +..B3.168: + movl $1, %ebp + jmp ..B3.170 +..B3.169: + xorl %ebp, %ebp +..B3.170: + movl 32(%esp), %eax + mull 100(%esp) + addl %edx, %ebp + addl 44(%esp), %eax + movl 36(%esp), %edi + adcl $0, %ebp + addl %edi, %esi + movl %esi, %edx + adcl 40(%esp), %ecx + subl %edi, %edx + movl %ecx, %edi + sbbl 40(%esp), %edi + jae ..B3.172 +..B3.171: + movl $1, %edx + jmp ..B3.173 +..B3.172: + xorl %edx, %edx +..B3.173: + movl %ebx, 88(%esp) + movl 48(%esp), %ebx + addl %eax, %ebx + movl %esi, 80(%esp) + adcl $0, %ebp + addl %edx, %ebx + movl %ecx, 132(%esp) + movl 112(%esp), %ecx + movl %ecx, %edi + movl 64(%esp), %esi + movl %esi, %edx + adcl $0, %ebp + movl %ebx, 48(%esp) + movl %ebp, 44(%esp) + movl 68(%esp), %ebp + movl 108(%esp), %ebx + movl %ebx, %eax + imull %ebp, %edi + imull %ebx, %edx + addl %edx, %edi + mull %ebp + movl %eax, 32(%esp) + movl %ebx, %eax + addl %edi, %edx + movl %edx, 36(%esp) + mull %ebp + movl %ebp, %eax + movl %edx, %edi + mull %ecx + addl %eax, %edi + movl %ebx, %eax + movl %edx, %ebp + adcl $0, %ebp + mull %esi + addl %edi, %eax + movl 132(%esp), %ecx + adcl %ebp, %edx + subl %edi, %eax + movl %edx, 40(%esp) + movl 80(%esp), %esi + sbbl %ebp, %edx + movl 44(%esp), %ebp + movl 88(%esp), %ebx + jae ..B3.175 +..B3.174: + movl $1, 52(%esp) + jmp ..B3.176 +..B3.175: + movl $0, 52(%esp) +..B3.176: + movl 64(%esp), %eax + mull 112(%esp) + movl 52(%esp), %edi + addl %edx, %edi + addl 40(%esp), %eax + movl %eax, 44(%esp) + movl 32(%esp), %eax + adcl $0, %edi + addl %eax, %esi + movl %esi, %edx + movl %edi, 52(%esp) + movl 36(%esp), %edi + adcl %edi, %ecx + subl %eax, %edx + movl %ecx, %eax + sbbl %edi, %eax + jae ..B3.178 +..B3.177: + movl $1, 32(%esp) + jmp ..B3.179 +..B3.178: + movl $0, 32(%esp) +..B3.179: + movl %esi, 80(%esp) + movl 100(%esp), %edi + movl 68(%esp), %esi + movl 104(%esp), %eax + movl 64(%esp), %edx + imull %esi, %edi + imull %eax, %edx + addl %edx, %edi + mull %esi + movl %ecx, 132(%esp) + movl %eax, %ecx + movl %edx, %esi + addl %edi, %esi + addl 48(%esp), %ecx + movl 60(%esp), %edi + movl 56(%esp), %edx + adcl %ebp, %esi + movl 112(%esp), %ebp + movl 108(%esp), %eax + imull %edi, %ebp + imull %eax, %edx + addl %edx, %ebp + mull %edi + addl 44(%esp), %ecx + adcl 52(%esp), %esi + addl %ebp, %edx + addl 32(%esp), %ecx + adcl $0, %esi + addl %ecx, %eax + movl 196(%esp), %ecx + movl %ecx, %ebp + adcl %esi, %edx + negl %ebp + cmpl $0, 76(%esp) + movl %eax, 136(%esp) + jne ..L11 + movl %ecx, %ebp +..L11: + xorl %eax, %eax + shll $29, %ebp + addl %ebp, %edx + movl %eax, 40(%esp) + movl 84(%esp), %ebp + movl %edx, 152(%esp) + movl %eax, 36(%esp) + jmp ..B3.180 +..B3.214: + addl $64, 40(%esp) + movl 152(%esp), %ecx + movl 132(%esp), %edx + movl 80(%esp), %eax + movl 32(%esp), %esi + movl 44(%esp), %edi + movl %ebp, 80(%esp) + movl %ebx, 132(%esp) + movl 92(%esp), %ebp + movl 96(%esp), %ebx + adcl $0, 36(%esp) + andl $-536870912, %ecx + andl $536870911, %edx + orl %edx, %ecx + movl %eax, 136(%esp) + movl %ecx, 152(%esp) + movl %esi, 92(%esp) + movl %edi, 96(%esp) +..B3.180: + movl 152(%esp), %eax + xorl %edx, %edx + lea 4194304(%eax), %ecx + andl $1065353216, %ecx + orl %edx, %ecx + jne ..B3.252 +..B3.181: + movl 120(%esp), %eax + movl 116(%esp), %esi + movl 124(%esp), %edi + movl (%eax), %edx + movl %edx, 116(%esp) + xorl %edx, %edx + movl 4(%eax), %ecx + addl $8, %eax + movl %ecx, 124(%esp) + movl %eax, 120(%esp) + orl 128(%esp), %edx + je ..B3.189 +..B3.182: + cmpl $31, 128(%esp) + jbe ..B3.184 +..B3.183: + movl %esi, %edi + xorl %edx, %edx + movl 128(%esp), %ecx + shll %cl, %edi + jmp ..B3.185 +..B3.184: + movl %esi, %edx + movl 128(%esp), %ecx + shldl %cl, %esi, %edi + shll %cl, %edx +..B3.185: + cmpl $31, 72(%esp) + jbe ..B3.187 +..B3.186: + movl 72(%esp), %ecx + xorl %eax, %eax + movl 124(%esp), %esi + shrl %cl, %esi + jmp ..B3.188 +..B3.187: + movl 72(%esp), %ecx + movl 116(%esp), %esi + movl 124(%esp), %eax + shrdl %cl, %eax, %esi + shrl %cl, %eax +..B3.188: + orl %edx, %esi + orl %eax, %edi +..B3.189: + movl 112(%esp), %ecx + movl %edi, %edx + movl %ebx, 88(%esp) + movl %ecx, %ebx + movl %ebp, 84(%esp) + movl 108(%esp), %ebp + movl %ebp, %eax + imull %esi, %ebx + imull %ebp, %edx + addl %edx, %ebx + mull %esi + movl %eax, 32(%esp) + movl %ebp, %eax + addl %ebx, %edx + movl %edx, 44(%esp) + mull %esi + movl %esi, %eax + movl %edx, %ebx + mull %ecx + addl %eax, %ebx + movl %ebp, %eax + movl %edx, %ecx + adcl $0, %ecx + mull %edi + addl %ebx, %eax + movl 84(%esp), %ebp + adcl %ecx, %edx + subl %ebx, %eax + movl %edx, 56(%esp) + movl 88(%esp), %ebx + sbbl %ecx, %edx + jae ..B3.191 +..B3.190: + movl $1, %ecx + jmp ..B3.192 +..B3.191: + xorl %ecx, %ecx +..B3.192: + movl 112(%esp), %eax + mull %edi + addl %edx, %ecx + addl 56(%esp), %eax + movl 92(%esp), %edx + adcl $0, %ecx + addl %eax, %edx + movl %ebp, 84(%esp) + movl 96(%esp), %ebp + adcl %ecx, %ebp + movl %edx, 92(%esp) + subl %eax, %edx + movl %ebp, 96(%esp) + sbbl %ecx, %ebp + movl 84(%esp), %ebp + jae ..B3.194 +..B3.193: + movl $1, %ecx + jmp ..B3.195 +..B3.194: + xorl %ecx, %ecx +..B3.195: + movl 100(%esp), %edx + addl %ecx, %ebp + movl 104(%esp), %eax + movl %edi, 64(%esp) + adcl $0, %ebx + imull %esi, %edx + imull %eax, %edi + addl %edi, %edx + movl %ebp, %edi + movl %edx, 68(%esp) + mull %esi + addl 68(%esp), %edx + subl %ecx, %edi + movl $0, %ecx + movl %edx, 52(%esp) + movl %ebx, %edx + movl %eax, 48(%esp) + sbbl %ecx, %edx + movl 64(%esp), %edi + jae ..B3.198 +..B3.196: + movl $1, %ecx +..B3.198: + movl 104(%esp), %eax + mull %esi + movl %esi, %eax + movl %ebp, 84(%esp) + movl %edx, %ebp + mull 100(%esp) + addl %eax, %ebp + movl %edx, %esi + movl 104(%esp), %eax + adcl $0, %esi + mull %edi + addl %ebp, %eax + adcl %esi, %edx + subl %ebp, %eax + movl %edx, 60(%esp) + movl 84(%esp), %ebp + sbbl %esi, %edx + jae ..B3.200 +..B3.199: + movl $1, %esi + jmp ..B3.201 +..B3.200: + xorl %esi, %esi +..B3.201: + movl 100(%esp), %eax + mull %edi + addl %edx, %esi + addl 60(%esp), %eax + movl %eax, 140(%esp) + movl 48(%esp), %edx + adcl $0, %esi + movl 92(%esp), %eax + addl %edx, %eax + movl %esi, 144(%esp) + movl 52(%esp), %esi + movl 96(%esp), %edi + adcl %esi, %edi + movl %eax, 92(%esp) + subl %edx, %eax + movl %edi, 96(%esp) + movl 140(%esp), %eax + sbbl %esi, %edi + movl 144(%esp), %esi + jae ..B3.203 +..B3.202: + movl $1, %edx + jmp ..B3.204 +..B3.203: + xorl %edx, %edx +..B3.204: + addl %edx, %ebp + movl %ebp, %edi + adcl $0, %ebx + subl %edx, %edi + movl $0, %edx + movl %ebx, %edi + sbbl %edx, %edi + jae ..B3.207 +..B3.205: + movl $1, %edx +..B3.207: + addl %eax, %ebp + adcl %esi, %ebx + addl %edx, %ecx + movl %ebp, %edx + subl %eax, %edx + movl %ebx, %eax + sbbl %esi, %eax + jae ..B3.209 +..B3.208: + movl $1, %eax + jmp ..B3.210 +..B3.209: + xorl %eax, %eax +..B3.210: + addl %eax, %ecx + xorl %eax, %eax + orl %eax, %ecx + je ..B3.213 +..B3.211: + movl 80(%esp), %eax + addl $1, %eax + movl 132(%esp), %edx + adcl $0, %edx + movl %eax, 80(%esp) + orl %edx, %eax + movl %edx, 132(%esp) + jne ..B3.213 +..B3.212: + addl $1, 136(%esp) + adcl $0, 152(%esp) +..B3.213: + movl 136(%esp), %ecx + movl %ecx, %eax + movl 152(%esp), %esi + shrl $23, %eax + shll $9, %esi + orl %esi, %eax + movl 132(%esp), %edx + movl %eax, %edi + shrl $23, %edx + shll $9, %ecx + sarl $31, %edi + orl %ecx, %edx + xorl %edi, %edx + xorl %edi, %eax + orl %eax, %edx + jne ..B3.230 + jmp ..B3.214 +..B3.215: + movl 148(%esp), %ebx + call __stack_chk_fail@PLT +..B3.216: + movl 32(%ebx), %edx + orl 36(%ebx), %edx + jne ..B3.218 +..B3.217: + movl $0, 24(%ebx) + jmp ..B3.117 +..B3.218: + movl 44(%esp), %ecx + xorl %edx, %edx + incl %ecx + andl $2, %ecx + orl %edx, %ecx + je ..B3.117 +..B3.219: + xorl $-2147483648, 24(%ebx) + jmp ..B3.117 +..B3.220: + xorl %edx, %edx + orl %edx, %ebx + je ..B3.222 +..B3.221: + movl $512, %ecx + jmp ..B3.223 +..B3.222: + xorl %ecx, %ecx +..B3.223: + orl $462, %ecx + jmp ..B3.113 +..B3.224: + movl 192(%esp), %edx + xorl %eax, %eax + xorl $-2147483648, 68(%esp) + movl 16(%edx), %ecx + movl 20(%edx), %esi + xorl %edx, %edx + subl %ecx, %edx + sbbl %esi, %eax + orl %esi, %ecx + je ..B3.226 +..B3.225: + movl $1, %ecx + jmp ..B3.227 +..B3.226: + xorl %ecx, %ecx +..B3.227: + movl 192(%esp), %esi + addl %ecx, %ebp + adcl $0, %ebx + movl %edx, 16(%esi) + xorl %edx, %edx + movl %eax, 20(%esi) + movl %ebp, %eax + xorl %ebp, %ebp + movl %ebx, %ecx + xorl %ebx, %ebx + subl %eax, %ebp + sbbl %ecx, %ebx + jmp ..B3.81 +..B3.228: + movl 72(%esp), %esi + movl 192(%esp), %ebp + movl 8(%ebp,%esi,8), %eax + movl 12(%ebp,%esi,8), %edi + jmp ..B3.59 +..B3.229: + movl $1, %edi + xorl %eax, %eax + jmp ..B3.49 +..B3.230: + movl %ebp, 84(%esp) + movl 132(%esp), %ecx + movl 80(%esp), %esi + movl 152(%esp), %edx +..B3.231: + movl 136(%esp), %edi + lea (,%edx,4), %eax + movl %edi, %ebp + sarl $2, %eax + subl %edi, %ebp + movl %ebp, 32(%esp) + movl %eax, %ebp + sbbl %eax, %edx + sarl $31, %ebp + subl %ebp, %edi + negl %ebp + addl %eax, %ebp + movl %eax, 36(%esp) + orl %ebp, %edi + jne ..B3.233 +..B3.232: + movl %ecx, %eax + movl %ebx, %ecx + movl 92(%esp), %ebx + movl %esi, 136(%esp) + movl 84(%esp), %esi + movl %ebx, 84(%esp) + movl 96(%esp), %ebx + addl $64, 40(%esp) +..B3.233: + xorl %ebp, %ebp + movl 36(%esp), %edi + subl %ebp, %edi + jge ..B3.236 +..B3.235: + movl $-2147483648, %ebp +..B3.236: + testl %ebp, %ebp + je ..B3.244 +..B3.237: + movl 84(%esp), %edi + notl %ebx + notl %edi + notl %eax + addl $1, %edi + notl %esi + movl %edi, 84(%esp) + notl %ecx + adcl $0, %ebx + notl 136(%esp) + orl %ebx, %edi + jne ..B3.239 +..B3.238: + movl $1, %edi + jmp ..B3.240 +..B3.239: + xorl %edi, %edi +..B3.240: + addl %edi, %esi + movl %esi, %edi + adcl $0, %ecx + orl %ecx, %edi + jne ..B3.242 +..B3.241: + movl $1, %edi + jmp ..B3.243 +..B3.242: + xorl %edi, %edi +..B3.243: + addl %edi, 136(%esp) + adcl $0, %eax +..B3.244: + xorl %edi, %edi + movl %ebx, 88(%esp) + xorl %ebx, %ebx + subl 32(%esp), %ebx + movl 76(%esp), %ebx + sbbl %edx, %edi + testl %ebx, %ebx + movl $3, 52(%esp) + jne ..L12 + movl %edx, %edi +..L12: + xorl %ebx, %ebp + movl %ebp, 48(%esp) + movl 136(%esp), %ebp + movl %edi, 44(%esp) + movl %ebp, 56(%esp) + movl %eax, 60(%esp) + movl %esi, 64(%esp) + movl %ecx, 68(%esp) + addl $12, %esp + xorl %ecx, %ecx + lea 36(%esp), %esi + pushl %ecx + pushl %ecx + pushl %esi + movl 40(%esi), %ebx + call __dpml_ffs_and_shift__ +..B3.245: + movl 52(%esp), %eax + movl %eax, %ecx + cltd + addl $-3, %ecx + adcl $-1, %edx + orl %ecx, %edx + je ..B3.250 +..B3.246: + addl $64, %ecx + movl 64(%esp), %esi + cmpl $31, %ecx + movl 68(%esp), %ebp + jbe ..B3.248 +..B3.247: + shrl %cl, %ebx + xorl %edx, %edx + movl %ebx, 84(%esp) + jmp ..B3.249 +..B3.248: + movl 84(%esp), %edx + shrdl %cl, %ebx, %edx + movl %edx, 84(%esp) + movl %ebx, %edx + shrl %cl, %edx +..B3.249: + orl 84(%esp), %esi + orl %edx, %ebp + movl %esi, 64(%esp) + movl %ebp, 68(%esp) +..B3.250: + subl 40(%esp), %eax + movl %eax, 52(%esp) + addl $12, %esp + lea 36(%esp), %ecx + pushl %ecx + movl 100(%ecx), %eax + lea 1008+__trig_x_table@GOTOFF(%eax), %edx + pushl %edx + pushl %ecx + call __dpml_multiply__ +..B3.251: + shrl $30, 44(%esp) + xorl %ebx, %ebx + jmp ..B3.103 +..B3.252: + movl %ebp, 84(%esp) + movl 132(%esp), %ecx + movl 80(%esp), %esi + movl %eax, %edx + jmp ..B3.231 +..B3.253: + movl %esi, %eax + sarl $31, %eax + movl 196(%esp), %ebp + cltd + addl %ebp, %eax + movl %eax, %ebx + adcl 200(%esp), %edx + andl $1, %ebx + addl %ebx, %eax + movl %eax, %ecx + adcl $0, %edx + shrl $1, %ecx + subl %eax, %ebp + movl %ecx, 44(%esp) + movl %edx, %ebx + movl 200(%esp), %ecx + sbbl %edx, %ecx + sarl $1, %ebx + orl %ecx, %ebp + je ..B3.258 +..B3.254: + xorl %eax, %eax + subl %eax, %ecx + jge ..B3.257 +..B3.256: + movl $1, %eax +..B3.257: + addl $20, %esp + lea 28(%esp), %edx + pushl %edx + pushl $0 + pushl %eax + movl 100(%edx), %eax + lea 1008+__trig_x_table@GOTOFF(%eax), %ecx + pushl %ecx + pushl 188(%esp) + call __dpml_addsub__ + jmp ..B3.103 +..B3.258: + movl %esi, %eax + movl %edi, %edx + movl 104(%esp), %ecx + movl 100(%esp), %ebp + movl 108(%esp), %esi + movl 112(%esp), %edi + movl %eax, 48(%esp) + movl %edx, 52(%esp) + movl %ecx, 56(%esp) + movl %ebp, 60(%esp) + movl %esi, 64(%esp) + movl %edi, 68(%esp) + jmp ..B3.103 + .align 16,0x90 + .type __dpml_ux_sincos,@function + .size __dpml_ux_sincos,.-__dpml_ux_sincos + .data +# -- End __dpml_ux_sincos + .section .rodata, "a" + .align 4 + .align 4 +__trig_x_table: + .long 15442952 + .long 1678786816 + .long 15709192 + .long 1414612240 + .long 15975432 + .long 1141915904 + .long 16241672 + .long 873463808 + .long 16507912 + .long 609305872 + .long 16774152 + .long 336592896 + .long 2 + .long 0 + .long 103 + .long 0 + .long 22 + .long 0 + .long 104 + .long 0 + .long 107 + .long 0 + .long 23 + .long 0 + .long 105 + .long 0 + .long 15176712 + .long 336609536 + .long 115 + .long 0 + .long 15176712 + .long 336592896 + .long 118 + .long 0 + .long 15176712 + .long 519700480 + .long 28 + .long 0 + .long 29 + .long 0 + .long 30 + .long 0 + .long 15176712 + .long 528281504 + .long 34 + .long 0 + .long 32 + .long 0 + .long 33 + .long 0 + .long 35 + .long 0 + .long 36 + .long 0 + .long 0 + .long 4294967291 + .long 2498349230 + .long 2398762258 + .long 2491794649 + .long 247854702 + .long 0 + .long 0 + .long 0 + .long 1073676288 + .long 95443718 + .long 1527099483 + .long 1431655766 + .long 357913941 + .long 2657305954 + .long 3 + .long 0 + .long 0 + .long 3705764381 + .long 2553 + .long 0 + .long 0 + .long 138031221 + .long 1532340 + .long 0 + .long 0 + .long 2983678984 + .long 775364077 + .long 0 + .long 0 + .long 20739419 + .long 3530365445 + .long 75 + .long 0 + .long 674366505 + .long 499172021 + .long 25931 + .long 0 + .long 1191312077 + .long 2630803580 + .long 7053263 + .long 0 + .long 2382099329 + .long 2712937970 + .long 1481185358 + .long 0 + .long 2412211635 + .long 2311528398 + .long 3431649258 + .long 53 + .long 3364759590 + .long 865053377 + .long 3819263687 + .long 5917 + .long 1745256079 + .long 2154301056 + .long 109078534 + .long 426088 + .long 286331142 + .long 286331153 + .long 286331153 + .long 17895697 + .long 1431655765 + .long 1431655765 + .long 1431655765 + .long 357913941 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 2851833826 + .long 97 + .long 0 + .long 0 + .long 1768459388 + .long 63846 + .long 0 + .long 0 + .long 2009193996 + .long 35243820 + .long 0 + .long 0 + .long 1368406537 + .long 3397743743 + .long 3 + .long 0 + .long 3946395699 + .long 2652434014 + .long 1440 + .long 0 + .long 2553743692 + .long 4190957063 + .long 440828 + .long 0 + .long 595011843 + .long 807348040 + .long 105798954 + .long 0 + .long 883371940 + .long 908455249 + .long 2075540478 + .long 4 + .long 761938407 + .long 3951975904 + .long 3388403475 + .long 591 + .long 217841633 + .long 3490513104 + .long 13634816 + .long 53261 + .long 3626846480 + .long 2195205506 + .long 763549741 + .long 2982616 + .long 1431655403 + .long 1431655765 + .long 1431655765 + .long 89478485 + .long 4294967292 + .long 4294967295 + .long 4294967295 + .long 1073741823 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2877741414 + .long 48456580 + .long 4555740 + .long 0 + .long 3312728015 + .long 4268104823 + .long 3744444631 + .long 1 + .long 6483522 + .long 3858350617 + .long 1187701358 + .long 879 + .long 3780777519 + .long 2626127639 + .long 2801410624 + .long 158172 + .long 3864078256 + .long 3316933375 + .long 1275824684 + .long 11667904 + .long 1744149096 + .long 2725495384 + .long 3617949641 + .long 318163395 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 3422290646 + .long 426546810 + .long 43450 + .long 0 + .long 3479121894 + .long 3493673009 + .long 236644653 + .long 0 + .long 4247003031 + .long 1084451344 + .long 1285072157 + .long 46 + .long 1927283714 + .long 2972340862 + .long 2243521359 + .long 13184 + .long 739625925 + .long 4125699428 + .long 1446479475 + .long 1522115 + .long 2250255868 + .long 2030226330 + .long 3149913922 + .long 70000510 + .long 312493331 + .long 1293839619 + .long 2186293876 + .long 1033991278 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 0 + .long 0 + .long 560513588 + .long 3373259426 + .long 2161908945 + .long 3301335691 + .long 0 + .long 0 + .type __trig_x_table,@object + .size __trig_x_table,1040 + .data + .hidden __dpml_multiply__ + .hidden __dpml_ffs_and_shift__ + .hidden __dpml_addsub__ + .hidden __dpml_evaluate_rational__ + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/erf.S b/external/sgx_libm/ia32/erf.S new file mode 100644 index 0000000000..ef56cf4dcb --- /dev/null +++ b/external/sgx_libm/ia32/erf.S @@ -0,0 +1,583 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erf.c" + .text +..TXTST0: +# -- Begin erf + .text + .align 16,0x90 + .globl erf +erf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + subl $24, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movl 12(%ebp), %ecx + movl %ecx, %eax + andl $-2147483648, %eax + andl $2147483647, %ecx + orl $1065353216, %eax + movl %eax, 16(%esp) + cmpl $1075298304, %ecx + flds 16(%esp) + movl 8(%ebp), %esi + fstpt (%esp) + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + jge ..B1.11 +..B1.4: + movzwl 14(%esp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.15 +..B1.5: + orl $-64768, %esi + movw %si, 12(%esp) +..B1.6: + fldcw 12(%esp) +..B1.7: + movl $1, %eax +..B1.8: + fldl 8(%ebp) + lea -1074331648(%ecx), %esi + shrl $20, %ecx + fabs + fldt (%esp) + addl $-1021, %ecx + cmpl $458751, %esi + ja ..L3 + movl $5, %ecx +..L3: + testl %ecx, %ecx + jg ..L4 + movl $0, %ecx +..L4: + movl %ecx, %edi + lea (%ecx,%ecx,2), %esi + shll $4, %edi + shll $7, %ecx + shll $4, %esi + testl %eax, %eax + fxch %st(1) + fmull erfRRTable@GOTOFF(%edi,%edx) + fldl 120+_dbA@GOTOFF(%edx,%ecx) + fldt 36+_ldbA@GOTOFF(%edx,%esi) + fldt 24+_ldbA@GOTOFF(%edx,%esi) + fldt 12+_ldbA@GOTOFF(%edx,%esi) + fldt _ldbA@GOTOFF(%edx,%esi) + fxch %st(5) + faddl 8+erfRRTable@GOTOFF(%edx,%edi) + fmul %st, %st(4) + fxch %st(4) + faddl 112+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 104+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 96+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 88+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 80+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 72+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 64+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 56+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 48+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 40+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 32+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 24+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 16+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl 8+_dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddl _dbA@GOTOFF(%edx,%ecx) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.10 +..B1.9: + fldcw 14(%esp) +..B1.10: + fldt (%esp) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + cmpl $2146435072, %ecx + jl ..B1.14 +..B1.12: + je ..B1.16 +..B1.13: + fldl 8(%ebp) + fadd %st(0), %st + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + fldl 768+_dbA@GOTOFF(%edx) + fldl 776+_dbA@GOTOFF(%edx) + fldt (%esp) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + xorl %eax, %eax + jmp ..B1.8 +..B1.16: + testl %esi, %esi + jne ..B1.13 +..B1.17: + fldt (%esp) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type erf,@function + .size erf,.-erf + .data +# -- End erf + .section .rodata, "a" + .align 16 + .align 16 +erfRRTable: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3fd00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xc00d0000 + .type erfRRTable,@object + .size erfRRTable,96 + .align 16 +_dbA: + .long 0 + .long 0 + .long 436480805 + .long 1069343474 + .long 0 + .long 0 + .long 824702180 + .long 3214639822 + .long 0 + .long 0 + .long 3500778474 + .long 1064658364 + .long 0 + .long 0 + .long 596585212 + .long 3209429723 + .long 0 + .long 0 + .long 1470240973 + .long 1059035690 + .long 0 + .long 0 + .long 718843426 + .long 3203353528 + .long 0 + .long 0 + .long 2710426178 + .long 1052473157 + .long 0 + .long 0 + .long 3010232270 + .long 3196296923 + .long 3936437656 + .long 1065568693 + .long 2299323409 + .long 3210429089 + .long 2523607943 + .long 3208348791 + .long 2965083678 + .long 1059250351 + .long 798914934 + .long 1055054643 + .long 3446493953 + .long 3202367749 + .long 3957742900 + .long 1049125428 + .long 3166330044 + .long 1049915994 + .long 2437497479 + .long 3193689582 + .long 3701813711 + .long 3192118067 + .long 4254294173 + .long 1041707319 + .long 3041595886 + .long 1039011503 + .long 177055818 + .long 3184215269 + .long 4076941640 + .long 3180389574 + .long 3283211378 + .long 1031330936 + .long 2299430385 + .long 1025878376 + .long 1560943562 + .long 3215381929 + .long 649600356 + .long 3213783607 + .long 1925487767 + .long 1066650173 + .long 2787104668 + .long 3212012915 + .long 3819886810 + .long 3210959588 + .long 3292869653 + .long 1062994816 + .long 595535285 + .long 3206044511 + .long 2833470226 + .long 3207638255 + .long 3150087827 + .long 1058299310 + .long 4226975388 + .long 1056101349 + .long 3511121228 + .long 3203239297 + .long 4191453678 + .long 1050931364 + .long 2398545468 + .long 1052356106 + .long 1036696996 + .long 3197521914 + .long 406902450 + .long 3195737434 + .long 932124879 + .long 1046963798 + .long 2984826674 + .long 3213958277 + .long 1416337143 + .long 1067493301 + .long 1528223327 + .long 3215470371 + .long 2077734896 + .long 1068079284 + .long 500891590 + .long 3215043166 + .long 1614001607 + .long 1065167414 + .long 397732724 + .long 1066426356 + .long 245285475 + .long 3214320360 + .long 2942435727 + .long 1065970365 + .long 2515085614 + .long 1062242098 + .long 2059023426 + .long 3212710123 + .long 3590542062 + .long 1064841017 + .long 1069940521 + .long 1062119991 + .long 329470371 + .long 1062390329 + .long 2904189456 + .long 1064709094 + .long 1072026573 + .long 1063487818 + .long 2999885720 + .long 3188887951 + .long 3321998034 + .long 3194165661 + .long 778559078 + .long 3198831619 + .long 4123899724 + .long 3202964980 + .long 708728771 + .long 3206666523 + .long 2191638927 + .long 3209872513 + .long 2647513773 + .long 3212706538 + .long 349076715 + .long 3215092788 + .long 3464000864 + .long 3217125251 + .long 2469419808 + .long 3218694220 + .long 396951367 + .long 3219923315 + .long 545534675 + .long 3220654754 + .long 3101724493 + .long 3220952863 + .long 496398401 + .long 3220607311 + .long 1221104108 + .long 3219519496 + .long 4256169036 + .long 3217191486 + .long 2904280702 + .long 3204470624 + .long 1218817182 + .long 1057276414 + .long 54035796 + .long 3204757890 + .long 4162943463 + .long 1056998848 + .long 3226000836 + .long 3203731619 + .long 1250945068 + .long 1055200853 + .long 1745105165 + .long 3201249698 + .long 1720233031 + .long 1051395895 + .long 2751609749 + .long 1047829350 + .long 3766093227 + .long 3196386836 + .long 2511730864 + .long 1047725585 + .long 1042659329 + .long 3192914318 + .long 2981264223 + .long 3189366070 + .long 673045009 + .long 1042560833 + .long 421746295 + .long 3188353310 + .long 3454229363 + .long 3184015574 + .long 4294967295 + .long 1072693247 + .long 0 + .long 1017102336 + .type _dbA,@object + .size _dbA,784 + .align 16 +_ldbA: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26765 + .word 5339 + .word 47746 + .word 36974 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13107 + .word 7119 + .word 41816 + .word 49299 + .word 49149 + .word 0 + .word 64355 + .word 59506 + .word 19372 + .word 46606 + .word 16382 + .word 0 + .word 9448 + .word 50838 + .word 8555 + .word 42135 + .word 16381 + .word 0 + .word 14173 + .word 43489 + .word 45601 + .word 63202 + .word 49147 + .word 0 + .word 56288 + .word 45938 + .word 11407 + .word 56180 + .word 16374 + .word 0 + .word 64911 + .word 39894 + .word 43704 + .word 63314 + .word 16382 + .word 0 + .word 18164 + .word 49445 + .word 47413 + .word 62353 + .word 16379 + .word 0 + .word 62471 + .word 20699 + .word 19176 + .word 46765 + .word 49148 + .word 0 + .word 45860 + .word 23381 + .word 351 + .word 36373 + .word 16380 + .word 0 + .word 52190 + .word 2479 + .word 36194 + .word 65534 + .word 16382 + .word 0 + .word 53234 + .word 6547 + .word 29917 + .word 37380 + .word 16371 + .word 0 + .word 61321 + .word 42597 + .word 44875 + .word 56070 + .word 49141 + .word 0 + .word 35023 + .word 36587 + .word 42382 + .word 52955 + .word 16375 + .word 0 + .word 65130 + .word 65535 + .word 65535 + .word 65535 + .word 16382 + .word 0 + .word 49987 + .word 10941 + .word 20175 + .word 44229 + .word 16331 + .word 0 + .word 45301 + .word 36641 + .word 152 + .word 62959 + .word 49108 + .word 0 + .word 7729 + .word 55572 + .word 4515 + .word 43787 + .word 49115 + .word 0 + .word 12218 + .word 25069 + .word 64268 + .word 65535 + .word 16382 + .word 0 + .word 39514 + .word 2562 + .word 14458 + .word 38069 + .word 16364 + .word 0 + .word 36514 + .word 39186 + .word 15150 + .word 34500 + .word 49134 + .word 0 + .word 9125 + .word 14475 + .word 36819 + .word 40101 + .word 16367 + .word 0 + .type _ldbA,@object + .size _ldbA,288 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/erfc.S b/external/sgx_libm/ia32/erfc.S new file mode 100644 index 0000000000..29656dfd8b --- /dev/null +++ b/external/sgx_libm/ia32/erfc.S @@ -0,0 +1,3498 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfc.c" + .text +..TXTST0: +# -- Begin erfc + .text + .align 16,0x90 + .globl erfc +erfc: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $68, %esp + movzwl 14(%ebp), %ebx + andl $32752, %ebx + shrl $4, %ebx + movzbl 15(%ebp), %ecx + movl %ebx, %eax + shrl $7, %ecx + shll $31, %ecx + shll $20, %eax + movl 12(%ebp), %edx + orl %eax, %ecx + andl $1048575, %edx + orl %edx, %ecx +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.41 +..B1.4: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.5: + fldcw 12(%esp) +..B1.6: + movl $1, %edx +..B1.7: + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $2047, %ebx + jne ..B1.16 +..B1.8: + testl $1048575, 12(%ebp) + jne ..B1.13 +..B1.9: + cmpl $0, 8(%ebp) + jne ..B1.13 +..B1.10: + movzbl 15(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + testl %edx, %edx + je ..B1.12 +..B1.11: + fldcw 14(%esp) +..B1.12: + flds zero_two@GOTOFF(%eax,%ecx,4) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + testl %edx, %edx + je ..B1.15 +..B1.14: + fldcw 14(%esp) +..B1.15: + fldl 8(%ebp) + fmul %st(0), %st + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + testl %ebx, %ebx + jne ..B1.22 +..B1.17: + testl $1048575, 12(%ebp) + jne ..B1.22 +..B1.18: + cmpl $0, 8(%ebp) + jne ..B1.22 +..B1.19: + testl %edx, %edx + je ..B1.21 +..B1.20: + fldcw 14(%esp) +..B1.21: + fld1 + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.22: + cmpl $1077578514, %ecx + jae ..B1.26 +..B1.23: + fldl 8(%ebp) + fld %st(0) + fld %st(1) + fld1 + movzwl 8+.L_2il0floatpacket.2@GOTOFF(%eax), %edi + fadd %st(3), %st + fmul %st(0), %st + andl $-32768, %edi + fmul %st(0), %st + fstpt 24(%esp) + fldl .L_2il0floatpacket.0@GOTOFF(%eax) + fmul %st(3), %st + movzwl 32(%esp), %ebx + fsub %st, %st(2) + andl $32767, %ebx + fsubp %st, %st(2) + fld %st(1) + lea (%ebx,%ebx,2), %ebx + fmul %st(2), %st + fchs + fxch %st(1) + fsub %st(2), %st + fldt .L_2il0floatpacket.1@GOTOFF(%eax) + shll $6, %ebx + fmulp %st, %st(3) + fmul %st, %st(2) + fmul %st(0), %st + fsubrp %st, %st(2) + fldt _EXPL_TABLE@GOTOFF(%eax) + fmul %st(1), %st + fldt 36+_EXPL_TABLE@GOTOFF(%eax) + fadd %st, %st(1) + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fsubp %st, %st(1) + fldt -3145536+_ERFC_TABLE@GOTOFF(%ebx,%eax) + movl 36(%esp), %ecx + movl %ecx, %esi + andl $-128, %esi + andl $127, %ecx + addl $2097024, %esi + fsubrp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fldt .L_2il0floatpacket.2@GOTOFF(%eax) + fstpt 48(%esp) + fldt 12+_EXPL_TABLE@GOTOFF(%eax) + fmul %st(2), %st + shrl $7, %esi + fsubrp %st, %st(3) + fldt 24+_EXPL_TABLE@GOTOFF(%eax) + andl $32767, %esi + fmul %st(2), %st + orl %esi, %edi + movw %di, 56(%esp) + lea (,%ecx,8), %esi + testl %edx, %edx + lea (%esi,%ecx,4), %ecx + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt -3145356+_ERFC_TABLE@GOTOFF(%eax,%ebx) + fmul %st(3), %st + fldt -3145380+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145404+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145428+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145452+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145476+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145500+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145524+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fldt -3145368+_ERFC_TABLE@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fldt -3145392+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145416+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145440+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145464+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145488+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt -3145512+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(4) + fxch %st(4) + fmulp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt 72+_EXP_POLY@GOTOFF(%eax) + fmul %st(1), %st + fldt 60+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt _EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fldt 48(%esp) + fldt _T_TABLE@GOTOFF(%eax,%ecx) + fmulp %st, %st(1) + fmulp %st, %st(1) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.46 +..B1.24: + fstpt 36(%esp) +..B1.44: + fldcw 14(%esp) + jmp ..B1.25 +..B1.46: + fstp %st(0) +..B1.25: + fldt (%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + cmpl $1077673984, %ecx + jae ..B1.30 +..B1.27: + fldl 8(%ebp) + fld %st(0) + fld %st(1) + fld1 + movzwl 8+.L_2il0floatpacket.2@GOTOFF(%eax), %edi + fadd %st(3), %st + fmul %st(0), %st + andl $-32768, %edi + fmul %st(0), %st + fstpt 24(%esp) + fldl .L_2il0floatpacket.0@GOTOFF(%eax) + fmul %st(3), %st + movzwl 32(%esp), %ebx + fsub %st, %st(2) + andl $32767, %ebx + fsubp %st, %st(2) + fld %st(1) + lea (%ebx,%ebx,2), %ebx + fmul %st(2), %st + fchs + fxch %st(1) + fsub %st(2), %st + fldt .L_2il0floatpacket.1@GOTOFF(%eax) + shll $6, %ebx + fmulp %st, %st(3) + fmul %st, %st(2) + fmul %st(0), %st + fsubrp %st, %st(2) + fldt _EXPL_TABLE@GOTOFF(%eax) + fmul %st(1), %st + fldt 36+_EXPL_TABLE@GOTOFF(%eax) + fadd %st, %st(1) + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fsubp %st, %st(1) + fldt -3145536+_ERFC_TABLE@GOTOFF(%ebx,%eax) + movl 36(%esp), %ecx + movl %ecx, %esi + andl $-128, %esi + andl $127, %ecx + addl $2097024, %esi + fsubrp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fldt .L_2il0floatpacket.2@GOTOFF(%eax) + fstpt 48(%esp) + fldt 12+_EXPL_TABLE@GOTOFF(%eax) + fmul %st(1), %st + shrl $7, %esi + fsubrp %st, %st(3) + fldt 24+_EXPL_TABLE@GOTOFF(%eax) + andl $32767, %esi + fmulp %st, %st(1) + orl %esi, %edi + movw %di, 56(%esp) + lea (,%ecx,8), %esi + testl %edx, %edx + lea (%esi,%ecx,4), %ecx + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt -3145356+_ERFC_TABLE@GOTOFF(%eax,%ebx) + fmul %st(2), %st + fldt -3145380+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt -3145404+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt -3145428+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt -3145452+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt -3145476+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt -3145500+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt -3145524+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fldt -3145368+_ERFC_TABLE@GOTOFF(%eax,%ebx) + fmul %st(3), %st + fldt -3145392+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145416+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145440+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145464+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt -3145488+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt -3145512+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 72+_EXP_POLY@GOTOFF(%eax) + fmul %st(2), %st + fldt 60+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _EXP_POLY@GOTOFF(%eax) + faddp %st, %st(2) + fldt 48(%esp) + fldt _T_TABLE@GOTOFF(%eax,%ecx) + fmulp %st, %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpl 16(%esp) + je ..B1.29 +..B1.28: + fldcw 14(%esp) +..B1.29: + fldl 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.30: + cmpl $2146435072, %ecx + jb ..B1.38 +..B1.31: + cmpl $-1072168960, %ecx + jae ..B1.35 +..B1.32: + fldl 8(%ebp) + fld %st(0) + fld %st(1) + fchs + fld1 + movzwl 8+.L_2il0floatpacket.2@GOTOFF(%eax), %edi + fadd %st(1), %st + fmul %st(0), %st + andl $-32768, %edi + fmul %st(0), %st + fstpt 24(%esp) + fldl .L_2il0floatpacket.0@GOTOFF(%eax) + fmul %st(3), %st + movzwl 32(%esp), %ebx + fsub %st, %st(2) + andl $32767, %ebx + fsubp %st, %st(2) + fld %st(1) + lea (%ebx,%ebx,2), %ebx + fmul %st(2), %st + fchs + fxch %st(2) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.1@GOTOFF(%eax) + shll $6, %ebx + fmulp %st, %st(1) + fmul %st(3), %st + fxch %st(3) + fmul %st(0), %st + fsubrp %st, %st(3) + fldt _EXPL_TABLE@GOTOFF(%eax) + fmul %st(2), %st + fldt 36+_EXPL_TABLE@GOTOFF(%eax) + fadd %st, %st(1) + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fsubp %st, %st(1) + fldt -3145536+_ERFC_TABLE@GOTOFF(%ebx,%eax) + movl 36(%esp), %ecx + movl %ecx, %esi + andl $-128, %esi + andl $127, %ecx + addl $2097024, %esi + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fldt .L_2il0floatpacket.2@GOTOFF(%eax) + fstpt 48(%esp) + fldt 12+_EXPL_TABLE@GOTOFF(%eax) + fmul %st(2), %st + shrl $7, %esi + fsubrp %st, %st(4) + fldt 24+_EXPL_TABLE@GOTOFF(%eax) + andl $32767, %esi + fmul %st(2), %st + orl %esi, %edi + movw %di, 56(%esp) + lea (,%ecx,8), %esi + testl %edx, %edx + lea (%esi,%ecx,4), %ecx + fsubrp %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fldt -3145356+_ERFC_TABLE@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fldt -3145380+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145404+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145428+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145452+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145476+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145500+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt -3145524+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fldt -3145368+_ERFC_TABLE@GOTOFF(%eax,%ebx) + fmul %st(5), %st + fldt -3145392+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(5), %st + fldt -3145416+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(5), %st + fldt -3145440+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(5), %st + fldt -3145464+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmul %st(5), %st + fldt -3145488+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt -3145512+_ERFC_TABLE@GOTOFF(%eax,%ebx) + faddp %st, %st(5) + fxch %st(2) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fldt 72+_EXP_POLY@GOTOFF(%eax) + fmul %st(2), %st + fldt 60+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_EXP_POLY@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _EXP_POLY@GOTOFF(%eax) + faddp %st, %st(2) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + fldt 48(%esp) + fldt _T_TABLE@GOTOFF(%eax,%ecx) + fmulp %st, %st(1) + fmulp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fsubp %st, %st(1) + fldt 60+_EXPL_TABLE@GOTOFF(%eax) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.47 +..B1.33: + fstpt 36(%esp) +..B1.45: + fldcw 14(%esp) + jmp ..B1.34 +..B1.47: + fstp %st(0) +..B1.34: + fldt (%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.35: + fldt 48+_EXPL_TABLE@GOTOFF(%eax) + testl %edx, %edx + fldt 72+_EXPL_TABLE@GOTOFF(%eax) + fmulp %st, %st(1) + fstpl 16(%esp) + je ..B1.37 +..B1.36: + fldcw 14(%esp) +..B1.37: + fldl 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + fldt 84+_EXPL_TABLE@GOTOFF(%eax) + testl %edx, %edx + fmul %st(0), %st + fstpl 16(%esp) + je ..B1.40 +..B1.39: + fldcw 14(%esp) +..B1.40: + fldl 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + xorl %edx, %edx + jmp ..B1.7 + .align 16,0x90 + .type erfc,@function + .size erfc,.-erfc + .data +# -- End erfc + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +zero_two: + .long 0x00000000 + .long 0x40000000 + .type zero_two,@object + .size zero_two,8 + .space 8, 0x00 # pad + .align 16 +_ERFC_TABLE: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 26765 + .word 5339 + .word 47746 + .word 36974 + .word 49151 + .word 0 + .word 65515 + .word 65535 + .word 65535 + .word 65535 + .word 16382 + .word 0 + .word 10533 + .word 7119 + .word 41816 + .word 49299 + .word 49150 + .word 0 + .word 52669 + .word 65527 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 16123 + .word 5294 + .word 46560 + .word 39439 + .word 49149 + .word 0 + .word 45245 + .word 18034 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 4032 + .word 40793 + .word 62556 + .word 45073 + .word 49147 + .word 0 + .word 4147 + .word 29718 + .word 43156 + .word 43690 + .word 16378 + .word 0 + .word 16916 + .word 58237 + .word 36396 + .word 40065 + .word 49145 + .word 0 + .word 30369 + .word 5547 + .word 38547 + .word 34949 + .word 16376 + .word 0 + .word 5723 + .word 34549 + .word 4774 + .word 58209 + .word 49142 + .word 0 + .word 32046 + .word 45872 + .word 27437 + .word 46045 + .word 16373 + .word 0 + .word 53798 + .word 26622 + .word 41794 + .word 32792 + .word 49140 + .word 0 + .word 43993 + .word 60371 + .word 27258 + .word 64442 + .word 16369 + .word 0 + .word 19322 + .word 28101 + .word 33420 + .word 49599 + .word 16380 + .word 0 + .word 7793 + .word 15289 + .word 7920 + .word 53594 + .word 16382 + .word 0 + .word 28952 + .word 49971 + .word 44506 + .word 53668 + .word 49150 + .word 0 + .word 36016 + .word 10961 + .word 40954 + .word 43439 + .word 16382 + .word 0 + .word 20915 + .word 61681 + .word 29972 + .word 60599 + .word 49149 + .word 0 + .word 24299 + .word 42445 + .word 45918 + .word 37706 + .word 16381 + .word 0 + .word 61980 + .word 35870 + .word 4262 + .word 42772 + .word 49148 + .word 0 + .word 2378 + .word 21048 + .word 27187 + .word 44880 + .word 16379 + .word 0 + .word 26023 + .word 38535 + .word 63103 + .word 44029 + .word 49146 + .word 0 + .word 51865 + .word 42701 + .word 357 + .word 40715 + .word 16377 + .word 0 + .word 52714 + .word 49990 + .word 38847 + .word 35713 + .word 49144 + .word 0 + .word 43806 + .word 65105 + .word 55139 + .word 59728 + .word 16374 + .word 0 + .word 64429 + .word 64517 + .word 6745 + .word 47746 + .word 49141 + .word 0 + .word 3465 + .word 57626 + .word 20546 + .word 36179 + .word 16372 + .word 0 + .word 22094 + .word 56102 + .word 37959 + .word 48728 + .word 49138 + .word 0 + .word 23306 + .word 25455 + .word 51183 + .word 43976 + .word 16368 + .word 0 + .word 37393 + .word 59257 + .word 52431 + .word 54291 + .word 16381 + .word 0 + .word 39090 + .word 10024 + .word 15035 + .word 43415 + .word 16382 + .word 0 + .word 43741 + .word 37879 + .word 6777 + .word 37983 + .word 49150 + .word 0 + .word 35426 + .word 24730 + .word 14790 + .word 55364 + .word 16381 + .word 0 + .word 35922 + .word 59851 + .word 47783 + .word 35355 + .word 49149 + .word 0 + .word 26997 + .word 19270 + .word 26422 + .word 40719 + .word 16380 + .word 0 + .word 44927 + .word 10365 + .word 61824 + .word 43075 + .word 49147 + .word 0 + .word 58693 + .word 50832 + .word 29111 + .word 42397 + .word 16378 + .word 0 + .word 18548 + .word 6343 + .word 29493 + .word 39194 + .word 49145 + .word 0 + .word 63186 + .word 18681 + .word 63761 + .word 34279 + .word 16376 + .word 0 + .word 30590 + .word 51670 + .word 24700 + .word 57056 + .word 49142 + .word 0 + .word 12395 + .word 18187 + .word 53964 + .word 45381 + .word 16373 + .word 0 + .word 8442 + .word 17290 + .word 60340 + .word 34554 + .word 49140 + .word 0 + .word 42583 + .word 52808 + .word 14422 + .word 49744 + .word 16370 + .word 0 + .word 38491 + .word 10790 + .word 17138 + .word 62758 + .word 49136 + .word 0 + .word 64957 + .word 43359 + .word 35041 + .word 51589 + .word 16366 + .word 0 + .word 54760 + .word 44346 + .word 63893 + .word 44681 + .word 16382 + .word 0 + .word 58037 + .word 18353 + .word 47660 + .word 34940 + .word 16382 + .word 0 + .word 12942 + .word 61844 + .word 37020 + .word 52609 + .word 49149 + .word 0 + .word 9074 + .word 21010 + .word 41308 + .word 34012 + .word 16381 + .word 0 + .word 33111 + .word 27346 + .word 43463 + .word 39226 + .word 49148 + .word 0 + .word 56229 + .word 38650 + .word 52618 + .word 41280 + .word 16379 + .word 0 + .word 28394 + .word 30437 + .word 45662 + .word 40246 + .word 49146 + .word 0 + .word 60627 + .word 1334 + .word 52268 + .word 36747 + .word 16377 + .word 0 + .word 31481 + .word 19361 + .word 56420 + .word 63358 + .word 49143 + .word 0 + .word 4433 + .word 31036 + .word 44150 + .word 51896 + .word 16374 + .word 0 + .word 21935 + .word 37845 + .word 52167 + .word 40591 + .word 49141 + .word 0 + .word 52857 + .word 25760 + .word 12934 + .word 60865 + .word 16371 + .word 0 + .word 30097 + .word 40209 + .word 51883 + .word 43747 + .word 49138 + .word 0 + .word 3097 + .word 41736 + .word 19718 + .word 59248 + .word 16368 + .word 0 + .word 62213 + .word 58640 + .word 23379 + .word 34650 + .word 49135 + .word 0 + .word 39490 + .word 47564 + .word 3293 + .word 51441 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 37057 + .word 51893 + .word 15367 + .word 56044 + .word 16381 + .word 0 + .word 32940 + .word 48642 + .word 29176 + .word 35810 + .word 49149 + .word 0 + .word 5161 + .word 6502 + .word 37918 + .word 40467 + .word 16380 + .word 0 + .word 17565 + .word 33655 + .word 49092 + .word 41537 + .word 49147 + .word 0 + .word 53678 + .word 44288 + .word 26743 + .word 39397 + .word 16378 + .word 0 + .word 31872 + .word 15269 + .word 30938 + .word 34942 + .word 49145 + .word 0 + .word 20440 + .word 62677 + .word 51881 + .word 58469 + .word 16375 + .word 0 + .word 54439 + .word 520 + .word 12343 + .word 46457 + .word 49142 + .word 0 + .word 50526 + .word 61632 + .word 2909 + .word 35241 + .word 16373 + .word 0 + .word 37830 + .word 61581 + .word 47207 + .word 51261 + .word 49139 + .word 0 + .word 25082 + .word 64640 + .word 37139 + .word 35852 + .word 16370 + .word 0 + .word 4883 + .word 40101 + .word 42814 + .word 48151 + .word 49136 + .word 0 + .word 19629 + .word 49380 + .word 65167 + .word 60688 + .word 16366 + .word 0 + .word 28545 + .word 10321 + .word 37155 + .word 65097 + .word 49132 + .word 0 + .word 64819 + .word 9690 + .word 1918 + .word 43254 + .word 16362 + .word 0 + .word 21215 + .word 7025 + .word 57507 + .word 45167 + .word 16383 + .word 0 + .word 55056 + .word 34238 + .word 8713 + .word 44914 + .word 16381 + .word 0 + .word 4267 + .word 1060 + .word 46425 + .word 48156 + .word 49148 + .word 0 + .word 14908 + .word 57526 + .word 48994 + .word 46896 + .word 16379 + .word 0 + .word 21326 + .word 53665 + .word 1969 + .word 42227 + .word 49146 + .word 0 + .word 25051 + .word 4472 + .word 10229 + .word 35587 + .word 16377 + .word 0 + .word 2076 + .word 31531 + .word 22832 + .word 56640 + .word 49143 + .word 0 + .word 60662 + .word 38735 + .word 55096 + .word 42849 + .word 16374 + .word 0 + .word 46215 + .word 1268 + .word 63191 + .word 61960 + .word 49140 + .word 0 + .word 4281 + .word 13548 + .word 25997 + .word 42995 + .word 16371 + .word 0 + .word 59094 + .word 61396 + .word 50012 + .word 57465 + .word 49137 + .word 0 + .word 56623 + .word 39859 + .word 52689 + .word 37061 + .word 16368 + .word 0 + .word 9718 + .word 28760 + .word 6243 + .word 45969 + .word 49134 + .word 0 + .word 22149 + .word 16273 + .word 53084 + .word 53283 + .word 16364 + .word 0 + .word 34037 + .word 57333 + .word 5882 + .word 51824 + .word 49130 + .word 0 + .word 11184 + .word 36893 + .word 23744 + .word 61115 + .word 16359 + .word 0 + .word 51465 + .word 62396 + .word 58983 + .word 59913 + .word 16383 + .word 0 + .word 21679 + .word 9895 + .word 5635 + .word 36049 + .word 16381 + .word 0 + .word 37768 + .word 22289 + .word 42182 + .word 64290 + .word 49147 + .word 0 + .word 29929 + .word 29351 + .word 11432 + .word 53291 + .word 16378 + .word 0 + .word 58374 + .word 18153 + .word 737 + .word 41523 + .word 49145 + .word 0 + .word 31896 + .word 56867 + .word 6398 + .word 61321 + .word 16375 + .word 0 + .word 55425 + .word 64032 + .word 46488 + .word 43176 + .word 49142 + .word 0 + .word 62735 + .word 35007 + .word 19863 + .word 58262 + .word 16372 + .word 0 + .word 2759 + .word 46881 + .word 15376 + .word 37816 + .word 49139 + .word 0 + .word 27202 + .word 45269 + .word 46930 + .word 47379 + .word 16369 + .word 0 + .word 36329 + .word 2846 + .word 16122 + .word 57442 + .word 49135 + .word 0 + .word 7470 + .word 414 + .word 53668 + .word 33732 + .word 16366 + .word 0 + .word 4702 + .word 32984 + .word 47709 + .word 38156 + .word 49132 + .word 0 + .word 59392 + .word 2467 + .word 11268 + .word 40167 + .word 16362 + .word 0 + .word 49683 + .word 209 + .word 55200 + .word 35020 + .word 49128 + .word 0 + .word 45504 + .word 61587 + .word 60548 + .word 36340 + .word 16357 + .word 0 + .word 27380 + .word 54941 + .word 64714 + .word 38724 + .word 16384 + .word 0 + .word 47150 + .word 21425 + .word 33441 + .word 58047 + .word 16380 + .word 0 + .word 10709 + .word 48511 + .word 39648 + .word 42794 + .word 49147 + .word 0 + .word 60862 + .word 8841 + .word 14633 + .word 59785 + .word 16377 + .word 0 + .word 38166 + .word 61183 + .word 58848 + .word 39827 + .word 49144 + .word 0 + .word 18364 + .word 43708 + .word 39063 + .word 50867 + .word 16374 + .word 0 + .word 61920 + .word 34013 + .word 44157 + .word 62530 + .word 49140 + .word 0 + .word 62014 + .word 46109 + .word 55800 + .word 37115 + .word 16371 + .word 0 + .word 46135 + .word 31864 + .word 22791 + .word 42668 + .word 49137 + .word 0 + .word 58857 + .word 54577 + .word 2989 + .word 47612 + .word 16367 + .word 0 + .word 34902 + .word 37732 + .word 51405 + .word 51663 + .word 49133 + .word 0 + .word 9364 + .word 27291 + .word 20920 + .word 54522 + .word 16363 + .word 0 + .word 37485 + .word 50 + .word 60675 + .word 55504 + .word 49129 + .word 0 + .word 35187 + .word 50155 + .word 51754 + .word 52385 + .word 16359 + .word 0 + .word 14814 + .word 63962 + .word 41088 + .word 40486 + .word 49125 + .word 0 + .word 11362 + .word 25769 + .word 50575 + .word 36669 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .word 26223 + .word 5353 + .word 5097 + .word 46924 + .word 16380 + .word 0 + .word 30267 + .word 42379 + .word 29288 + .word 57013 + .word 49146 + .word 0 + .word 42189 + .word 50693 + .word 61652 + .word 33311 + .word 16377 + .word 0 + .word 47396 + .word 16957 + .word 12509 + .word 37576 + .word 49143 + .word 0 + .word 23478 + .word 31241 + .word 24950 + .word 41038 + .word 16373 + .word 0 + .word 17240 + .word 63077 + .word 25824 + .word 43503 + .word 49139 + .word 0 + .word 25576 + .word 39889 + .word 51350 + .word 44857 + .word 16369 + .word 0 + .word 13068 + .word 16791 + .word 29619 + .word 45074 + .word 49135 + .word 0 + .word 60332 + .word 2969 + .word 19586 + .word 44206 + .word 16365 + .word 0 + .word 37599 + .word 42283 + .word 62126 + .word 42363 + .word 49131 + .word 0 + .word 41529 + .word 34093 + .word 65146 + .word 39638 + .word 16361 + .word 0 + .word 10083 + .word 55225 + .word 38396 + .word 35838 + .word 49127 + .word 0 + .word 53136 + .word 32600 + .word 23694 + .word 59889 + .word 16356 + .word 0 + .word 63669 + .word 4602 + .word 61995 + .word 40592 + .word 49122 + .word 0 + .word 64442 + .word 41272 + .word 29937 + .word 63695 + .word 16350 + .word 0 + .word 21215 + .word 7025 + .word 57507 + .word 61551 + .word 16384 + .word 0 + .word 60759 + .word 43057 + .word 21108 + .word 38100 + .word 16380 + .word 0 + .word 19048 + .word 27034 + .word 20875 + .word 38100 + .word 49146 + .word 0 + .word 43286 + .word 62467 + .word 46495 + .word 37059 + .word 16376 + .word 0 + .word 18535 + .word 3739 + .word 31085 + .word 35131 + .word 49142 + .word 0 + .word 47338 + .word 988 + .word 43337 + .word 65023 + .word 16371 + .word 0 + .word 53014 + .word 19205 + .word 31790 + .word 58830 + .word 49137 + .word 0 + .word 64942 + .word 4422 + .word 52367 + .word 52104 + .word 16367 + .word 0 + .word 18376 + .word 62542 + .word 21190 + .word 45226 + .word 49133 + .word 0 + .word 36541 + .word 5903 + .word 55315 + .word 38509 + .word 16363 + .word 0 + .word 58232 + .word 34982 + .word 30759 + .word 64373 + .word 49128 + .word 0 + .word 53034 + .word 58877 + .word 34756 + .word 52727 + .word 16358 + .word 0 + .word 43589 + .word 44050 + .word 54239 + .word 41804 + .word 49124 + .word 0 + .word 58188 + .word 24032 + .word 18788 + .word 61115 + .word 16353 + .word 0 + .word 53178 + .word 32234 + .word 55399 + .word 35974 + .word 49119 + .word 0 + .word 32107 + .word 65066 + .word 9168 + .word 48562 + .word 16347 + .word 0 + .word 25732 + .word 63966 + .word 62259 + .word 38148 + .word 16385 + .word 0 + .word 1290 + .word 5604 + .word 33063 + .word 62145 + .word 16379 + .word 0 + .word 61015 + .word 23258 + .word 11350 + .word 51162 + .word 49145 + .word 0 + .word 27005 + .word 25391 + .word 61437 + .word 41308 + .word 16375 + .word 0 + .word 36713 + .word 64273 + .word 62675 + .word 65487 + .word 49140 + .word 0 + .word 27734 + .word 12066 + .word 17277 + .word 51007 + .word 16370 + .word 0 + .word 22545 + .word 24708 + .word 32287 + .word 39069 + .word 49136 + .word 0 + .word 7137 + .word 26934 + .word 42406 + .word 58901 + .word 16365 + .word 0 + .word 28920 + .word 48738 + .word 2272 + .word 43725 + .word 49131 + .word 0 + .word 12386 + .word 49194 + .word 59841 + .word 63966 + .word 16360 + .word 0 + .word 12291 + .word 20618 + .word 59744 + .word 46112 + .word 49126 + .word 0 + .word 45255 + .word 8860 + .word 16074 + .word 65374 + .word 16355 + .word 0 + .word 24201 + .word 30931 + .word 20557 + .word 44934 + .word 49121 + .word 0 + .word 57092 + .word 56173 + .word 59274 + .word 56860 + .word 16350 + .word 0 + .word 421 + .word 9843 + .word 65450 + .word 57636 + .word 49115 + .word 0 + .word 26834 + .word 64481 + .word 48830 + .word 33265 + .word 16344 + .word 0 + .word 27380 + .word 54941 + .word 64714 + .word 46916 + .word 16385 + .word 0 + .word 16042 + .word 6176 + .word 23933 + .word 50894 + .word 16379 + .word 0 + .word 15496 + .word 30354 + .word 41738 + .word 34536 + .word 49145 + .word 0 + .word 16771 + .word 22379 + .word 52151 + .word 46241 + .word 16374 + .word 0 + .word 13611 + .word 51387 + .word 33531 + .word 61111 + .word 49139 + .word 0 + .word 58938 + .word 199 + .word 35276 + .word 39876 + .word 16369 + .word 0 + .word 34069 + .word 62119 + .word 6313 + .word 51412 + .word 49134 + .word 0 + .word 26024 + .word 61062 + .word 29148 + .word 65510 + .word 16363 + .word 0 + .word 21349 + .word 54243 + .word 12871 + .word 41265 + .word 49129 + .word 0 + .word 4785 + .word 38663 + .word 43132 + .word 51413 + .word 16358 + .word 0 + .word 24101 + .word 62567 + .word 22734 + .word 63346 + .word 49123 + .word 0 + .word 15399 + .word 49395 + .word 40313 + .word 38484 + .word 16353 + .word 0 + .word 28161 + .word 41902 + .word 27845 + .word 45418 + .word 49118 + .word 0 + .word 12182 + .word 20933 + .word 3877 + .word 49303 + .word 16347 + .word 0 + .word 20492 + .word 46011 + .word 10667 + .word 42720 + .word 49112 + .word 0 + .word 46757 + .word 22481 + .word 16184 + .word 41956 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57344 + .word 16385 + .word 0 + .word 15972 + .word 32891 + .word 13820 + .word 41838 + .word 16379 + .word 0 + .word 63823 + .word 14280 + .word 41618 + .word 46885 + .word 49144 + .word 0 + .word 62247 + .word 60117 + .word 61219 + .word 52049 + .word 16373 + .word 0 + .word 4514 + .word 2791 + .word 14455 + .word 57256 + .word 49138 + .word 0 + .word 8237 + .word 29451 + .word 46967 + .word 62423 + .word 16367 + .word 0 + .word 38621 + .word 18263 + .word 65293 + .word 33733 + .word 49133 + .word 0 + .word 20437 + .word 17700 + .word 46099 + .word 36151 + .word 16362 + .word 0 + .word 7628 + .word 50188 + .word 47081 + .word 38422 + .word 49127 + .word 0 + .word 27034 + .word 6950 + .word 65014 + .word 40504 + .word 16356 + .word 0 + .word 929 + .word 31466 + .word 57314 + .word 42341 + .word 49121 + .word 0 + .word 51218 + .word 18814 + .word 40699 + .word 43755 + .word 16350 + .word 0 + .word 60139 + .word 33609 + .word 1443 + .word 43987 + .word 49115 + .word 0 + .word 28121 + .word 19894 + .word 16 + .word 40667 + .word 16344 + .word 0 + .word 47275 + .word 5106 + .word 2805 + .word 59896 + .word 49108 + .word 0 + .word 45414 + .word 34202 + .word 16579 + .word 49848 + .word 16336 + .word 0 + .word 43375 + .word 36280 + .word 61521 + .word 34871 + .word 16386 + .word 0 + .word 16506 + .word 6420 + .word 3056 + .word 34509 + .word 16379 + .word 0 + .word 1987 + .word 42760 + .word 41343 + .word 63988 + .word 49143 + .word 0 + .word 60842 + .word 56864 + .word 63566 + .word 58939 + .word 16372 + .word 0 + .word 55417 + .word 6969 + .word 17921 + .word 53943 + .word 49137 + .word 0 + .word 51573 + .word 24611 + .word 61942 + .word 49060 + .word 16366 + .word 0 + .word 60047 + .word 61936 + .word 1505 + .word 44346 + .word 49131 + .word 0 + .word 6985 + .word 28094 + .word 62181 + .word 39841 + .word 16360 + .word 0 + .word 44966 + .word 25211 + .word 37807 + .word 35582 + .word 49125 + .word 0 + .word 18549 + .word 30768 + .word 43886 + .word 63182 + .word 16353 + .word 0 + .word 28367 + .word 55574 + .word 54863 + .word 55743 + .word 49118 + .word 0 + .word 14135 + .word 59968 + .word 11402 + .word 48712 + .word 16347 + .word 0 + .word 10831 + .word 6630 + .word 39162 + .word 41467 + .word 49112 + .word 0 + .word 44318 + .word 36886 + .word 57433 + .word 64946 + .word 16340 + .word 0 + .word 48971 + .word 52692 + .word 39577 + .word 40471 + .word 49105 + .word 0 + .word 51132 + .word 42759 + .word 59794 + .word 56909 + .word 16332 + .word 0 + .word 25732 + .word 63966 + .word 62259 + .word 42244 + .word 16386 + .word 0 + .word 59756 + .word 3318 + .word 14822 + .word 57094 + .word 16378 + .word 0 + .word 53698 + .word 1627 + .word 14262 + .word 43879 + .word 49143 + .word 0 + .word 39975 + .word 26109 + .word 52231 + .word 33570 + .word 16372 + .word 0 + .word 51646 + .word 31403 + .word 31812 + .word 51139 + .word 49136 + .word 0 + .word 2483 + .word 26589 + .word 1676 + .word 38780 + .word 16365 + .word 0 + .word 48498 + .word 1356 + .word 1608 + .word 58560 + .word 49129 + .word 0 + .word 3924 + .word 17004 + .word 812 + .word 44025 + .word 16358 + .word 0 + .word 46861 + .word 28945 + .word 33303 + .word 32957 + .word 49123 + .word 0 + .word 44566 + .word 64586 + .word 45755 + .word 49135 + .word 16351 + .word 0 + .word 24613 + .word 10799 + .word 48364 + .word 36456 + .word 49116 + .word 0 + .word 30085 + .word 45589 + .word 61330 + .word 53663 + .word 16344 + .word 0 + .word 33497 + .word 5155 + .word 3788 + .word 38522 + .word 49109 + .word 0 + .word 14725 + .word 21779 + .word 34456 + .word 50904 + .word 16337 + .word 0 + .word 52940 + .word 10411 + .word 49330 + .word 53514 + .word 49101 + .word 0 + .word 34723 + .word 21028 + .word 57012 + .word 63430 + .word 16328 + .word 0 + .word 27380 + .word 54941 + .word 64714 + .word 51012 + .word 16386 + .word 0 + .word 45653 + .word 64195 + .word 32236 + .word 47349 + .word 16378 + .word 0 + .word 879 + .word 33324 + .word 35436 + .word 60443 + .word 49142 + .word 0 + .word 46894 + .word 26961 + .word 28118 + .word 38458 + .word 16371 + .word 0 + .word 44554 + .word 3572 + .word 63976 + .word 48787 + .word 49135 + .word 0 + .word 2272 + .word 4313 + .word 35324 + .word 61701 + .word 16363 + .word 0 + .word 30703 + .word 23672 + .word 41539 + .word 38897 + .word 49128 + .word 0 + .word 37671 + .word 61454 + .word 12213 + .word 48895 + .word 16356 + .word 0 + .word 61848 + .word 29005 + .word 2524 + .word 61278 + .word 49120 + .word 0 + .word 28836 + .word 16521 + .word 28345 + .word 38282 + .word 16349 + .word 0 + .word 22288 + .word 21607 + .word 62473 + .word 47665 + .word 49113 + .word 0 + .word 61670 + .word 56396 + .word 40174 + .word 58939 + .word 16341 + .word 0 + .word 11500 + .word 65235 + .word 61923 + .word 35576 + .word 49106 + .word 0 + .word 11242 + .word 2180 + .word 826 + .word 39560 + .word 16334 + .word 0 + .word 43321 + .word 47027 + .word 63349 + .word 35004 + .word 49098 + .word 0 + .word 4958 + .word 42423 + .word 31587 + .word 34920 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 16386 + .word 0 + .word 62439 + .word 8267 + .word 42241 + .word 39352 + .word 16378 + .word 0 + .word 51100 + .word 10343 + .word 41485 + .word 41791 + .word 49142 + .word 0 + .word 22569 + .word 27301 + .word 5322 + .word 44285 + .word 16370 + .word 0 + .word 35593 + .word 39735 + .word 46317 + .word 46825 + .word 49134 + .word 0 + .word 62209 + .word 35548 + .word 38355 + .word 49405 + .word 16362 + .word 0 + .word 41076 + .word 45055 + .word 12154 + .word 52016 + .word 49126 + .word 0 + .word 33794 + .word 34841 + .word 26433 + .word 54648 + .word 16354 + .word 0 + .word 32708 + .word 8606 + .word 28372 + .word 57292 + .word 49118 + .word 0 + .word 58537 + .word 41843 + .word 17546 + .word 59935 + .word 16346 + .word 0 + .word 14261 + .word 60109 + .word 32952 + .word 62535 + .word 49110 + .word 0 + .word 15086 + .word 37621 + .word 31044 + .word 64853 + .word 16338 + .word 0 + .word 41112 + .word 8679 + .word 1028 + .word 32860 + .word 49103 + .word 0 + .word 5006 + .word 59706 + .word 53773 + .word 61388 + .word 16330 + .word 0 + .word 8320 + .word 26227 + .word 30276 + .word 45657 + .word 49094 + .word 0 + .word 12516 + .word 27384 + .word 49627 + .word 38295 + .word 16321 + .word 0 + .word 43375 + .word 36280 + .word 61521 + .word 36919 + .word 16387 + .word 0 + .word 13964 + .word 47780 + .word 48486 + .word 65532 + .word 16377 + .word 0 + .word 53655 + .word 14178 + .word 29810 + .word 57985 + .word 49141 + .word 0 + .word 40644 + .word 13825 + .word 33576 + .word 51229 + .word 16369 + .word 0 + .word 43867 + .word 51159 + .word 21808 + .word 45192 + .word 49133 + .word 0 + .word 64774 + .word 25334 + .word 42575 + .word 39806 + .word 16361 + .word 0 + .word 8550 + .word 43268 + .word 19146 + .word 35010 + .word 49125 + .word 0 + .word 10274 + .word 39807 + .word 58829 + .word 61491 + .word 16352 + .word 0 + .word 64510 + .word 64333 + .word 45409 + .word 53921 + .word 49116 + .word 0 + .word 7837 + .word 47962 + .word 10236 + .word 47211 + .word 16344 + .word 0 + .word 58632 + .word 16136 + .word 57648 + .word 41252 + .word 49108 + .word 0 + .word 50839 + .word 20695 + .word 9993 + .word 35851 + .word 16336 + .word 0 + .word 53977 + .word 3173 + .word 20021 + .word 60931 + .word 49099 + .word 0 + .word 21252 + .word 21065 + .word 18238 + .word 47764 + .word 16327 + .word 0 + .word 15598 + .word 48005 + .word 54092 + .word 59667 + .word 49090 + .word 0 + .word 43865 + .word 24204 + .word 30376 + .word 42053 + .word 16317 + .word 0 + .word 25732 + .word 63966 + .word 62259 + .word 44292 + .word 16387 + .word 0 + .word 57042 + .word 17954 + .word 41982 + .word 54649 + .word 16377 + .word 0 + .word 35272 + .word 59341 + .word 60292 + .word 40343 + .word 49141 + .word 0 + .word 50299 + .word 52389 + .word 64962 + .word 59502 + .word 16368 + .word 0 + .word 39701 + .word 8675 + .word 64086 + .word 43833 + .word 49132 + .word 0 + .word 32919 + .word 36749 + .word 17653 + .word 64514 + .word 16359 + .word 0 + .word 20450 + .word 29105 + .word 54347 + .word 47425 + .word 49123 + .word 0 + .word 51457 + .word 46834 + .word 19008 + .word 34827 + .word 16351 + .word 0 + .word 56572 + .word 25900 + .word 35557 + .word 51097 + .word 49114 + .word 0 + .word 52629 + .word 22805 + .word 35492 + .word 37443 + .word 16342 + .word 0 + .word 60134 + .word 44346 + .word 29251 + .word 54790 + .word 49105 + .word 0 + .word 40525 + .word 1894 + .word 29226 + .word 39888 + .word 16333 + .word 0 + .word 58308 + .word 40784 + .word 61879 + .word 56822 + .word 49096 + .word 0 + .word 39626 + .word 13594 + .word 33728 + .word 37362 + .word 16324 + .word 0 + .word 30018 + .word 64156 + .word 50426 + .word 39179 + .word 49087 + .word 0 + .word 26770 + .word 35175 + .word 34395 + .word 46390 + .word 16313 + .word 0 + .word 27380 + .word 54941 + .word 64714 + .word 53060 + .word 16387 + .word 0 + .word 21489 + .word 47049 + .word 52913 + .word 45633 + .word 16377 + .word 0 + .word 34273 + .word 45339 + .word 64425 + .word 56278 + .word 49140 + .word 0 + .word 9281 + .word 44296 + .word 1457 + .word 34678 + .word 16368 + .word 0 + .word 54032 + .word 26533 + .word 19904 + .word 42704 + .word 49131 + .word 0 + .word 4885 + .word 48150 + .word 35442 + .word 52549 + .word 16358 + .word 0 + .word 37026 + .word 46558 + .word 719 + .word 64617 + .word 49121 + .word 0 + .word 24924 + .word 32254 + .word 45168 + .word 39698 + .word 16349 + .word 0 + .word 58798 + .word 11406 + .word 38703 + .word 48743 + .word 49112 + .word 0 + .word 65026 + .word 39487 + .word 36015 + .word 59805 + .word 16339 + .word 0 + .word 17049 + .word 61342 + .word 62907 + .word 36661 + .word 49103 + .word 0 + .word 29048 + .word 51483 + .word 25283 + .word 44910 + .word 16330 + .word 0 + .word 26979 + .word 49508 + .word 25129 + .word 54883 + .word 49093 + .word 0 + .word 1679 + .word 10398 + .word 12735 + .word 33027 + .word 16321 + .word 0 + .word 27523 + .word 22868 + .word 1994 + .word 36413 + .word 49084 + .word 0 + .word 13664 + .word 7895 + .word 2857 + .word 54679 + .word 16310 + .word 0 + .type _ERFC_TABLE,@object + .size _ERFC_TABLE,3840 + .space 768, 0x00 # pad + .align 16 +_EXP_POLY: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 46603 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .type _EXP_POLY,@object + .size _EXP_POLY,84 + .space 12, 0x00 # pad + .align 16 +_T_TABLE: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 43884 + .word 55705 + .word 60751 + .word 32945 + .word 16383 + .word 0 + .word 1907 + .word 48131 + .word 53747 + .word 33124 + .word 16383 + .word 0 + .word 9708 + .word 29692 + .word 44867 + .word 33304 + .word 16383 + .word 0 + .word 41431 + .word 44075 + .word 34456 + .word 33485 + .word 16383 + .word 0 + .word 60983 + .word 61366 + .word 22862 + .word 33667 + .word 16383 + .word 0 + .word 16454 + .word 44254 + .word 10435 + .word 33850 + .word 16383 + .word 0 + .word 6697 + .word 14236 + .word 63062 + .word 34033 + .word 16383 + .word 0 + .word 31509 + .word 52296 + .word 50023 + .word 34218 + .word 16383 + .word 0 + .word 47620 + .word 37439 + .word 37211 + .word 34404 + .word 16383 + .word 0 + .word 4112 + .word 40589 + .word 24982 + .word 34591 + .word 16383 + .word 0 + .word 55186 + .word 63128 + .word 13695 + .word 34779 + .word 16383 + .word 0 + .word 34087 + .word 37594 + .word 3712 + .word 34968 + .word 16383 + .word 0 + .word 24541 + .word 24974 + .word 60931 + .word 35157 + .word 16383 + .word 0 + .word 64922 + .word 18798 + .word 54645 + .word 35348 + .word 16383 + .word 0 + .word 35108 + .word 11378 + .word 50757 + .word 35540 + .word 16383 + .word 0 + .word 55015 + .word 60043 + .word 49635 + .word 35733 + .word 16383 + .word 0 + .word 19934 + .word 25711 + .word 51652 + .word 35927 + .word 16383 + .word 0 + .word 43494 + .word 32347 + .word 57179 + .word 36122 + .word 16383 + .word 0 + .word 40150 + .word 8934 + .word 1056 + .word 36319 + .word 16383 + .word 0 + .word 21440 + .word 17869 + .word 14731 + .word 36516 + .word 16383 + .word 0 + .word 58820 + .word 59080 + .word 33047 + .word 36714 + .word 16383 + .word 0 + .word 45532 + .word 5222 + .word 56387 + .word 36913 + .word 16383 + .word 0 + .word 45355 + .word 61156 + .word 19595 + .word 37114 + .word 16383 + .word 0 + .word 49974 + .word 43793 + .word 54131 + .word 37315 + .word 16383 + .word 0 + .word 63916 + .word 38193 + .word 29309 + .word 37518 + .word 16383 + .word 0 + .word 59692 + .word 5094 + .word 11055 + .word 37722 + .word 16383 + .word 0 + .word 1206 + .word 43804 + .word 65295 + .word 37926 + .word 16383 + .word 0 + .word 2401 + .word 65271 + .word 61352 + .word 38132 + .word 16383 + .word 0 + .word 32751 + .word 54988 + .word 65158 + .word 38339 + .word 16383 + .word 0 + .word 23040 + .word 8216 + .word 11575 + .word 38548 + .word 16383 + .word 0 + .word 45198 + .word 61818 + .word 32073 + .word 38757 + .word 16383 + .word 0 + .word 43375 + .word 36280 + .word 61521 + .word 38967 + .word 16383 + .word 0 + .word 35242 + .word 26305 + .word 34786 + .word 39179 + .word 16383 + .word 0 + .word 64101 + .word 8375 + .word 17811 + .word 39392 + .word 16383 + .word 0 + .word 34378 + .word 38143 + .word 11004 + .word 39606 + .word 16383 + .word 0 + .word 21817 + .word 54606 + .word 14777 + .word 39821 + .word 16383 + .word 0 + .word 11309 + .word 11971 + .word 29544 + .word 40037 + .word 16383 + .word 0 + .word 46929 + .word 11519 + .word 55719 + .word 40254 + .word 16383 + .word 0 + .word 9248 + .word 40263 + .word 28184 + .word 40473 + .word 16383 + .word 0 + .word 4526 + .word 37281 + .word 12896 + .word 40693 + .word 16383 + .word 0 + .word 56582 + .word 25600 + .word 10277 + .word 40914 + .word 16383 + .word 0 + .word 20418 + .word 47473 + .word 20751 + .word 41136 + .word 16383 + .word 0 + .word 46820 + .word 34116 + .word 44746 + .word 41359 + .word 16383 + .word 0 + .word 26649 + .word 3145 + .word 17155 + .word 41584 + .word 16383 + .word 0 + .word 48019 + .word 59394 + .word 3944 + .word 41810 + .word 16383 + .word 0 + .word 32926 + .word 2534 + .word 5550 + .word 42037 + .word 16383 + .word 0 + .word 62265 + .word 48798 + .word 22406 + .word 42265 + .word 16383 + .word 0 + .word 14570 + .word 45393 + .word 54953 + .word 42494 + .word 16383 + .word 0 + .word 27422 + .word 61160 + .word 38095 + .word 42725 + .word 16383 + .word 0 + .word 13674 + .word 59749 + .word 37812 + .word 42957 + .word 16383 + .word 0 + .word 3593 + .word 31538 + .word 54550 + .word 43190 + .word 16383 + .word 0 + .word 3832 + .word 60028 + .word 23220 + .word 43425 + .word 16383 + .word 0 + .word 30249 + .word 60560 + .word 9810 + .word 43661 + .word 16383 + .word 0 + .word 54071 + .word 43326 + .word 14773 + .word 43898 + .word 16383 + .word 0 + .word 59689 + .word 48703 + .word 38564 + .word 44136 + .word 16383 + .word 0 + .word 19142 + .word 17057 + .word 16106 + .word 44376 + .word 16383 + .word 0 + .word 47118 + .word 51765 + .word 13394 + .word 44617 + .word 16383 + .word 0 + .word 17269 + .word 26890 + .word 30893 + .word 44859 + .word 16383 + .word 0 + .word 17796 + .word 46816 + .word 3531 + .word 45103 + .word 16383 + .word 0 + .word 9616 + .word 53932 + .word 62849 + .word 45347 + .word 16383 + .word 0 + .word 65083 + .word 26136 + .word 12710 + .word 45594 + .word 16383 + .word 0 + .word 9353 + .word 43281 + .word 50194 + .word 45841 + .word 16383 + .word 0 + .word 38977 + .word 25931 + .word 44706 + .word 46090 + .word 16383 + .word 0 + .word 25732 + .word 63966 + .word 62259 + .word 46340 + .word 16383 + .word 0 + .word 63340 + .word 24277 + .word 37800 + .word 46592 + .word 16383 + .word 0 + .word 30609 + .word 10449 + .word 37347 + .word 46845 + .word 16383 + .word 0 + .word 7804 + .word 36004 + .word 61386 + .word 47099 + .word 16383 + .word 0 + .word 40681 + .word 25339 + .word 44871 + .word 47355 + .word 16383 + .word 0 + .word 40427 + .word 11275 + .word 53829 + .word 47612 + .word 16383 + .word 0 + .word 17915 + .word 4926 + .word 23218 + .word 47871 + .word 16383 + .word 0 + .word 64269 + .word 62185 + .word 19070 + .word 48131 + .word 16383 + .word 0 + .word 14015 + .word 22540 + .word 41887 + .word 48392 + .word 16383 + .word 0 + .word 37858 + .word 34313 + .word 26633 + .word 48655 + .word 16383 + .word 0 + .word 4227 + .word 31347 + .word 39350 + .word 48919 + .word 16383 + .word 0 + .word 36272 + .word 61648 + .word 15009 + .word 49185 + .word 16383 + .word 0 + .word 37974 + .word 26224 + .word 19658 + .word 49452 + .word 16383 + .word 0 + .word 26227 + .word 7741 + .word 53809 + .word 49720 + .word 16383 + .word 0 + .word 25607 + .word 9367 + .word 52442 + .word 49990 + .word 16383 + .word 0 + .word 52019 + .word 21300 + .word 16076 + .word 50262 + .word 16383 + .word 0 + .word 56029 + .word 21766 + .word 10769 + .word 50535 + .word 16383 + .word 0 + .word 24441 + .word 43556 + .word 37045 + .word 50809 + .word 16383 + .word 0 + .word 45405 + .word 43961 + .word 29896 + .word 51085 + .word 16383 + .word 0 + .word 11333 + .word 36862 + .word 55388 + .word 51362 + .word 16383 + .word 0 + .word 10147 + .word 28207 + .word 48518 + .word 51641 + .word 16383 + .word 0 + .word 30542 + .word 17040 + .word 9822 + .word 51922 + .word 16383 + .word 0 + .word 31837 + .word 62066 + .word 5374 + .word 52204 + .word 16383 + .word 0 + .word 52690 + .word 20541 + .word 35718 + .word 52487 + .word 16383 + .word 0 + .word 32996 + .word 8068 + .word 35861 + .word 52772 + .word 16383 + .word 0 + .word 6337 + .word 6425 + .word 6351 + .word 53059 + .word 16383 + .word 0 + .word 9621 + .word 61227 + .word 13274 + .word 53347 + .word 16383 + .word 0 + .word 39622 + .word 20841 + .word 57186 + .word 53636 + .word 16383 + .word 0 + .word 58458 + .word 61738 + .word 7569 + .word 53928 + .word 16383 + .word 0 + .word 50041 + .word 34202 + .word 61593 + .word 54220 + .word 16383 + .word 0 + .word 64031 + .word 53229 + .word 23211 + .word 54515 + .word 16383 + .word 0 + .word 52743 + .word 40859 + .word 24062 + .word 54811 + .word 16383 + .word 0 + .word 27380 + .word 54941 + .word 64714 + .word 55108 + .word 16383 + .word 0 + .word 11396 + .word 28083 + .word 14668 + .word 55408 + .word 16383 + .word 0 + .word 55222 + .word 30895 + .word 5570 + .word 55709 + .word 16383 + .word 0 + .word 52338 + .word 10953 + .word 37999 + .word 56011 + .word 16383 + .word 0 + .word 14165 + .word 56050 + .word 46999 + .word 56315 + .word 16383 + .word 0 + .word 19488 + .word 2098 + .word 33157 + .word 56621 + .word 16383 + .word 0 + .word 37156 + .word 24078 + .word 62594 + .word 56928 + .word 16383 + .word 0 + .word 17440 + .word 47344 + .word 4830 + .word 57238 + .word 16383 + .word 0 + .word 57617 + .word 10900 + .word 57068 + .word 57548 + .word 16383 + .word 0 + .word 54121 + .word 65155 + .word 23295 + .word 57861 + .word 16383 + .word 0 + .word 23121 + .word 48778 + .word 35186 + .word 58175 + .word 16383 + .word 0 + .word 43149 + .word 14141 + .word 27808 + .word 58491 + .word 16383 + .word 0 + .word 18600 + .word 31875 + .word 1767 + .word 58809 + .word 16383 + .word 0 + .word 52770 + .word 60959 + .word 23210 + .word 59128 + .word 16383 + .word 0 + .word 56424 + .word 15435 + .word 27216 + .word 59449 + .word 16383 + .word 0 + .word 35927 + .word 27727 + .word 14400 + .word 59772 + .word 16383 + .word 0 + .word 14639 + .word 56612 + .word 50919 + .word 60096 + .word 16383 + .word 0 + .word 48604 + .word 19484 + .word 6326 + .word 60423 + .word 16383 + .word 0 + .word 11140 + .word 55700 + .word 12318 + .word 60751 + .word 16383 + .word 0 + .word 603 + .word 3491 + .word 3992 + .word 61081 + .word 16383 + .word 0 + .word 62923 + .word 56538 + .word 47515 + .word 61412 + .word 16383 + .word 0 + .word 17673 + .word 44297 + .word 12455 + .word 61746 + .word 16383 + .word 0 + .word 45370 + .word 23039 + .word 30524 + .word 62081 + .word 16383 + .word 0 + .word 6747 + .word 14948 + .word 36830 + .word 62418 + .word 16383 + .word 0 + .word 52268 + .word 9350 + .word 32021 + .word 62757 + .word 16383 + .word 0 + .word 33902 + .word 29503 + .word 16748 + .word 63098 + .word 16383 + .word 0 + .word 15289 + .word 2769 + .word 57203 + .word 63440 + .word 16383 + .word 0 + .word 47732 + .word 24020 + .word 22971 + .word 63785 + .word 16383 + .word 0 + .word 826 + .word 29226 + .word 45787 + .word 64131 + .word 16383 + .word 0 + .word 40009 + .word 58864 + .word 60780 + .word 64479 + .word 16383 + .word 0 + .word 49525 + .word 62598 + .word 3084 + .word 64830 + .word 16383 + .word 0 + .word 34892 + .word 31631 + .word 4444 + .word 65182 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .type _T_TABLE,@object + .size _T_TABLE,1548 + .space 4, 0x00 # pad + .align 8 +.L_2il0floatpacket.0: + .long 0x00100000,0x41f00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 2 +_EXPL_TABLE: + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 16390 + .word 0 + .word 0 + .word 53760 + .word 6135 + .word 45426 + .word 16375 + .word 0 + .word 40944 + .word 28977 + .word 20696 + .word 49689 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 16382 + .word 0 + .word 1 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 1 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .word 1 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _EXPL_TABLE,@object + .size _EXPL_TABLE,96 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/erfcf.S b/external/sgx_libm/ia32/erfcf.S new file mode 100644 index 0000000000..468faf1c02 --- /dev/null +++ b/external/sgx_libm/ia32/erfcf.S @@ -0,0 +1,635 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfcf.c" + .text +..TXTST0: +# -- Begin erfcf + .text + .align 16,0x90 + .globl erfcf +erfcf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $56, %esp + movl 8(%ebp), %edi + movl %edi, %eax + andl $2147483647, %eax + shrl $31, %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2139095040, %eax + jae ..B1.24 +..B1.2: + cmpl range@GOTOFF(%ebx,%edi,4), %eax + jae ..B1.21 +..B1.3: + cmpl $1081081856, %eax + jae ..B1.15 +..B1.4: + cmpl $1073741824, %eax + jae ..B1.11 +..B1.5: + cmpl $1056964608, %eax + jae ..B1.10 +..B1.6: + flds 8(%ebp) + cmpl $847249408, %eax + jae ..B1.8 +..B1.7: + fld1 + fsubp %st, %st(1) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.8: + fldl 40+_A@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fld1 + fxch %st(3) + faddl 24+_A@GOTOFF(%ebx) + fmul %st(1), %st + fldl 48+_A@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 8+_A@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(1) + faddl 32+_A@GOTOFF(%ebx) + fmul %st(1), %st + faddl 16+_A@GOTOFF(%ebx) + fmulp %st, %st(1) + faddl _A@GOTOFF(%ebx) + fmulp %st, %st(2) + faddp %st, %st(1) +..B1.9: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.10: + flds 8(%ebp) + fabs + fld1 + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 48+_AP@GOTOFF(%ebx) + fmul %st(1), %st + fldl 56+_AP@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 32+_AP@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 40+_AP@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 16+_AP@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 24+_AP@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl _AP@GOTOFF(%ebx) + fldl 48+_AQ@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + faddl 8+_AP@GOTOFF(%ebx) + fmul %st(4), %st + faddp %st, %st(1) + fldl 56+_AQ@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + faddl 32+_AQ@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + faddl 40+_AQ@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + faddl 16+_AQ@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + faddl 24+_AQ@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(1) + faddl _AQ@GOTOFF(%ebx) + fxch %st(2) + faddl 8+_AQ@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fdivrp %st, %st(1) + fmuls _ones@GOTOFF(%ebx,%edi,4) + faddl _erfc1@GOTOFF(%ebx,%edi,8) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + flds 8(%ebp) + testl %edi, %edi + fabs + faddl .L_2il0floatpacket.2@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + je ..B1.13 +..B1.12: + fldl 48+_BP1@GOTOFF(%ebx) + fmul %st(1), %st + fldl 40+_BP1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 32+_BP1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 24+_BP1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 16+_BP1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 8+_BP1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl _BP1@GOTOFF(%ebx) + fldl 48+_BQ1@GOTOFF(%ebx) + fmul %st(3), %st + fldl 40+_BQ1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 32+_BQ1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 24+_BQ1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 16+_BQ1@GOTOFF(%ebx) + fmulp %st, %st(4) + faddl 8+_BQ1@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(2) + faddl _BQ1@GOTOFF(%ebx) + fxch %st(2) + jmp ..B1.14 +..B1.13: + fldl 80+_BP2@GOTOFF(%ebx) + fmul %st(1), %st + fldl 88+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 64+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 72+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 48+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 56+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 32+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 40+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 16+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 24+_BP2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl _BP2@GOTOFF(%ebx) + fldl 64+_BQ2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(2) + faddl 8+_BP2@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl 48+_BQ2@GOTOFF(%ebx) + fmul %st(3), %st + fldl 56+_BQ2@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 32+_BQ2@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 40+_BQ2@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 16+_BQ2@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 24+_BQ2@GOTOFF(%ebx) + fmulp %st, %st(4) + faddl _BQ2@GOTOFF(%ebx) + fxch %st(3) + faddl 8+_BQ2@GOTOFF(%ebx) + fmulp %st, %st(4) +..B1.14: + faddp %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fdivrp %st, %st(1) + fmuls _ones@GOTOFF(%ebx,%edi,4) + faddl _erfc4@GOTOFF(%ebx,%edi,8) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + flds 8(%ebp) + fabs + fld1 + fdiv %st(1), %st + fstpl 24(%esp) + fmul %st(0), %st + fchs + fstpl (%esp) + call __libm_exp_k32 +..B1.16: + fldl 24(%esp) + testl %edi, %edi + fmul %st, %st(1) + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fldl 56+_R1@GOTOFF(%ebx) + fmul %st(1), %st + fldl 48+_R1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 40+_R1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 32+_R1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 24+_R1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 16+_R1@GOTOFF(%ebx) + fmulp %st, %st(2) + faddl 8+_R1@GOTOFF(%ebx) + fmulp %st, %st(2) + faddl _R1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + jne ..B1.20 +..B1.17: + fsts 20(%esp) + cmpl $8388608, 20(%esp) + jl ..B1.28 +..B1.19: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.20: + fsubrs .L_2il0floatpacket.0@GOTOFF(%ebx) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.21: + testl %edi, %edi + je ..B1.29 +..B1.22: + flds .L_2il0floatpacket.0@GOTOFF(%ebx) +..B1.23: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.24: + jne ..B1.26 +..B1.25: + flds zero_two@GOTOFF(%ebx,%edi,4) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + flds 8(%ebp) +..B1.27: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.28: + fstp %st(0) + flds .L_2il0floatpacket.1@GOTOFF(%ebx) + fmul %st(0), %st + fstps 16(%esp) + flds 20(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + flds .L_2il0floatpacket.1@GOTOFF(%ebx) + fmul %st(0), %st + fsts 20(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type erfcf,@function + .size erfcf,.-erfcf + .data +# -- End erfcf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0xc0000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x40000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x0d800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +range: + .long 1092825907 + .long 1081791557 + .type range,@object + .size range,8 + .align 4 +_A: + .long 1346541978 + .long 3220311511 + .long 1794662342 + .long 1071125108 + .long 250944106 + .long 3216827122 + .long 215131671 + .long 1067156170 + .long 548330146 + .long 3212141823 + .long 76350191 + .long 1061937114 + .long 2772654316 + .long 3206307213 + .type _A,@object + .size _A,56 + .align 4 +_AP: + .long 4064916629 + .long 3190878451 + .long 2877165718 + .long 3218164236 + .long 2764139057 + .long 1068232842 + .long 168293639 + .long 3215329394 + .long 881203975 + .long 3215292554 + .long 342818617 + .long 1065638313 + .long 817546319 + .long 3212004140 + .long 1510911299 + .long 3202390104 + .type _AP,@object + .size _AP,64 + .align 4 +_AQ: + .long 1883560946 + .long 1071960885 + .long 853592313 + .long 1071685196 + .long 191605458 + .long 1071250674 + .long 2183121159 + .long 1070390698 + .long 3347411101 + .long 1068928985 + .long 273856425 + .long 1067608207 + .long 671820230 + .long 1065177551 + .long 2414119437 + .long 1063328696 + .type _AQ,@object + .size _AQ,64 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_erfc1: + .long 1879048192 + .long 1069818465 + .long 3523215360 + .long 1073576883 + .type _erfc1,@object + .size _erfc1,16 + .align 4 +_BP1: + .long 4019088381 + .long 1060143686 + .long 4231883845 + .long 3209038463 + .long 1510730124 + .long 1061755778 + .long 2929202078 + .long 3208591153 + .long 1409179897 + .long 1059475758 + .long 439372548 + .long 3204538649 + .long 3357266387 + .long 1053229132 + .type _BP1,@object + .size _BP1,56 + .align 4 +_BQ1: + .long 3444570556 + .long 1068208773 + .long 4145425017 + .long 1069029647 + .long 1145740212 + .long 1069192522 + .long 2413502193 + .long 1068797491 + .long 2712383784 + .long 1068007659 + .long 3941762314 + .long 1066743858 + .long 3272105283 + .long 1065447630 + .type _BQ1,@object + .size _BQ1,56 + .align 4 +_BP2: + .long 3138848853 + .long 1062211012 + .long 544119287 + .long 3211644465 + .long 2662071917 + .long 1064935492 + .long 2106254088 + .long 3212505578 + .long 377059754 + .long 1064517936 + .long 3523110848 + .long 3210978388 + .long 64932799 + .long 1062023575 + .long 2232373525 + .long 3207568747 + .long 3004568351 + .long 1057518327 + .long 1553969795 + .long 3201939481 + .long 865068135 + .long 1050709866 + .long 348213498 + .long 3193161330 + .type _BP2,@object + .size _BP2,96 + .align 4 +_BQ2: + .long 2220299070 + .long 1070256111 + .long 1607355279 + .long 1069737707 + .long 3222185356 + .long 1069664669 + .long 1988590515 + .long 1068489586 + .long 2612211906 + .long 1067468794 + .long 3802943557 + .long 1065572613 + .long 4286646379 + .long 1063895282 + .long 45248763 + .long 1061257684 + .long 3494068347 + .long 1058887001 + .type _BQ2,@object + .size _BQ2,72 + .align 4 +_erfc4: + .long 0 + .long 1045463040 + .long 4225761280 + .long 1073741823 + .type _erfc4,@object + .size _erfc4,16 + .align 4 +_R1: + .long 1340517714 + .long 1071779287 + .long 1760660317 + .long 3218214358 + .long 3277598851 + .long 1071322187 + .long 1776282588 + .long 3220235438 + .long 2229586924 + .long 1074588991 + .long 2042215417 + .long 3224150558 + .long 1374528972 + .long 1078534706 + .long 1825320511 + .long 3227067102 + .type _R1,@object + .size _R1,64 + .align 4 +zero_two: + .long 0x00000000 + .long 0x40000000 + .type zero_two,@object + .size zero_two,8 + .data + .hidden __libm_exp_k32 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/erfcl.S b/external/sgx_libm/ia32/erfcl.S new file mode 100644 index 0000000000..4433175004 --- /dev/null +++ b/external/sgx_libm/ia32/erfcl.S @@ -0,0 +1,3850 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfcl.c" + .text +..TXTST0: +# -- Begin erfcl + .text + .align 16,0x90 + .globl erfcl +erfcl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + fldt 8(%ebp) + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 148(%esp) + fstpt 56(%esp) +..B1.2: + fnstcw 70(%esp) +..B1.3: + movzwl 70(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.76 +..B1.4: + orl $-64768, %edx + movw %dx, 68(%esp) +..B1.5: + fldcw 68(%esp) +..B1.6: + movl $1, %edx +..B1.7: + movl 16(%ebp), %eax + movl %eax, %esi + shrl $15, %esi + andl $32767, %eax + andl $1, %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $32767, %eax + je ..B1.56 +..B1.8: + fldt 8(%ebp) + fldl _zeros@GOTOFF(%ebx) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B1.9 + je ..B1.51 +..B1.9: + fldt _erfcl_RT1@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.15 + jp ..B1.15 +..B1.10: + fldt 12+_erfcl_RT1@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B1.15 +..B1.11: + fstp %st(0) + fldt _Epsilon@GOTOFF(%ebx) + testl %edx, %edx + fsubrl _ones@GOTOFF(%ebx) + fstpt 12(%esp) + je ..B1.13 +..B1.12: + fldcw 70(%esp) +..B1.13: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 +..B1.14: + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + fldl 8+_erfcl_ASYMPT@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B1.46 +..B1.16: + fcompl _erfcl_ASYMPT@GOTOFF(%ebx) + fnstsw %ax + sahf + jae ..B1.21 +..B1.17: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + testl %edx, %edx + fldt _Epsilon@GOTOFF(%ebx) + fsubrp %st, %st(1) + fstpt 12(%esp) + je ..B1.19 +..B1.18: + fldcw 70(%esp) +..B1.19: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 +..B1.20: + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.21: + fldl _ones@GOTOFF(%ebx) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + andl $32767, 64(%esp) + fstpt 24(%esp) + fldt 24(%esp) + fldt 56(%esp) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 12(%esp) + fld %st(0) + fmulp %st, %st(2) + fld %st(0) + movl 20(%esp), %edi + fsub %st(2), %st + andl $32767, %edi + faddp %st, %st(2) + fld %st(1) + lea -16383(%edi), %eax + fmul %st(2), %st + movl %edi, 52(%esp) + movl %eax, %edi + shll $6, %edi + fchs + fld %st(1) + shll $7, %eax + fsub %st(3), %st + fmul %st, %st(3) + addl %eax, %edi + fxch %st(3) + fchs + lea 100(%esp), %eax + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + fstpt 12(%eax) + addl $-16, %esp + fstpt (%eax) + lea 140(%esp), %ecx + movl %ecx, (%esp) + movl %eax, 4(%esp) + fstpt -60(%eax) + movl %edx, -64(%eax) + call __libm_expl_k80 +..B1.79: + fldt 56(%esp) + movl 52(%esp), %edx + addl $16, %esp +..B1.22: + fldl _TWO_63H@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + movl 12(%esp), %ecx + cmpl $-16300, %ecx + fstpt 12(%esp) + fldt 12(%esp) + jle ..B1.24 +..B1.23: + fldt 124(%esp) + addl $16383, %ecx + movzwl 20(%esp), %eax + andl $32767, %ecx + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 20(%esp) + lea 136(%esp), %eax + fldt (%eax) + fxch %st(1) + jmp ..B1.25 +..B1.24: + fldl _TWO_POW_M400@GOTOFF(%ebx) + fldt 124(%esp) + movl %edi, 36(%esp) + movzwl 20(%esp), %edi + movl %edi, %eax + andl $-32768, %eax + fmul %st(1), %st + lea 400(%edi,%ecx), %ecx + andl $32767, %ecx + orl %ecx, %eax + movw %ax, 20(%esp) + lea 136(%esp), %eax + fldt (%eax) + fmulp %st, %st(2) + movl -100(%eax), %edi +..B1.25: + fldt 24(%esp) + fld %st(1) + fxch %st(1) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%eax) + fldt (%eax) + fxch %st(1) + fstpt 124(%esp) + fldt 56(%esp) + fldt _erfcl_CHDX@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.27 +..B1.26: + fldl _erfcl_DX@GOTOFF(%ebx) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + fadd %st(2), %st + fxch %st(1) + jmp ..B1.28 +..B1.27: + fldl 8+_erfcl_DX@GOTOFF(%ebx) + fld %st(1) + fadd %st(1), %st + fld %st(2) + fsub %st(1), %st + faddp %st, %st(2) +..B1.28: + fldt 24(%esp) + testl %esi, %esi + fld %st(0) + fld %st(2) + fxch %st(6) + fstpt 88(%esp) + fld %st(2) + movl 52(%esp), %ecx + fadd %st(4), %st + fdivr %st(7), %st + lea -131064(,%ecx,8), %eax + fmul %st, %st(1) + lea -65532(%eax,%ecx,4), %eax + fxch %st(7) + fstpt 40(%esp) + fld %st(0) + fadd %st(7), %st + fsubp %st, %st(1) + fsubr %st, %st(6) + fld %st(2) + fmul %st(2), %st + fadd %st, %st(6) + fsubrp %st, %st(6) + fxch %st(2) + fsub %st(5), %st + faddp %st, %st(3) + fld %st(5) + fmul %st(3), %st + fld %st(2) + fmul %st(6), %st + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(5) + fmul %st(6), %st + faddp %st, %st(5) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fld %st(0) + fsub %st(3), %st + fxch %st(1) + fstpt 56(%esp) + fldt 56(%esp) + fsub %st(1), %st + fsubp %st, %st(3) + fxch %st(5) + fsubrp %st, %st(2) + fld %st(0) + fmul %st(5), %st + fld %st(5) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fld %st(5) + fmul %st(2), %st + fld %st(3) + fmul %st(6), %st + fxch %st(3) + fmulp %st, %st(4) + faddp %st, %st(3) + fld %st(0) + fmul %st(2), %st + fxch %st(5) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(2) + fld %st(0) + fadd %st(4), %st + fsubp %st, %st(4) + fsub %st(3), %st + faddp %st, %st(1) + fldt _erfcl_C@GOTOFF(%eax,%ebx) + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fldt 168+_erfcl_Q@GOTOFF(%ebx,%edi) + fmul %st(1), %st + fldt 144+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 120+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt _erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fldt 180+_erfcl_Q@GOTOFF(%ebx,%edi) + fmul %st(2), %st + fldt 156+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 132+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 108+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 12+_erfcl_Q@GOTOFF(%ebx,%edi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(3) + fldt 40(%esp) + fld %st(0) + fadd %st(4), %st + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fld %st(5) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fldt 88(%esp) + fldt _erfcl_S@GOTOFF(%eax,%ebx) + fmul %st, %st(5) + fxch %st(3) + fmul %st(5), %st + fxch %st(3) + fmulp %st, %st(2) + fld %st(4) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fldt 72(%esp) + fld %st(0) + fmul %st(5), %st + fmul %st, %st(7) + fxch %st(3) + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(2) + fadd %st(7), %st + fsubp %st, %st(7) + fxch %st(2) + fsub %st(6), %st + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fld %st(2) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 12(%esp) + je ..B1.30 +..B1.29: + fldt 56(%esp) + fxch %st(1) + fmul %st, %st(2) + fmulp %st, %st(3) + fld %st(0) + fsub %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + fsub %st(2), %st + fsub %st(3), %st + faddp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + jmp ..B1.33 +..B1.30: + fld %st(1) + fadd %st(3), %st + fmul %st(1), %st + fstpt 12(%esp) + movzwl 20(%esp), %eax + testl $32767, %eax + jne ..B1.33 +..B1.31: + movzwl 18(%esp), %eax + testl %eax, %eax + jbe ..B1.33 +..B1.32: + fldt 24(%esp) + fmul %st(2), %st + fld %st(2) + fsubr %st(1), %st + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + fadd %st(3), %st + fmul %st(1), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 12(%esp) +..B1.33: + fstp %st(0) + fstp %st(1) + fstp %st(0) + fldt 8(%ebp) + fldt _erfcl_UNDERFLOW_INT@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jp ..B1.34 + jbe ..B1.41 +..B1.34: + testl %edx, %edx + je ..B1.36 +..B1.35: + fldcw 70(%esp) +..B1.36: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 +..B1.37: + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.41: + fldt _small_value_80@GOTOFF(%ebx) + testl %edx, %edx + fmul %st(0), %st + fstpt (%esp) + je ..B1.43 +..B1.42: + fldcw 70(%esp) +..B1.43: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 + jmp ..B1.14 +..B1.46: + fstp %st(0) + fldt _Epsilon@GOTOFF(%ebx) + testl %edx, %edx + fmul %st(0), %st + fstpt 12(%esp) + je ..B1.48 +..B1.47: + fldcw 70(%esp) +..B1.48: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 + jmp ..B1.14 +..B1.51: + fstp %st(0) + fldl _ones@GOTOFF(%ebx) + testl %edx, %edx + fstpt 12(%esp) + je ..B1.53 +..B1.52: + fldcw 70(%esp) +..B1.53: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 + jmp ..B1.14 +..B1.56: + movl 12(%ebp), %eax + testl %esi, %esi + jne ..B1.63 +..B1.57: + cmpl $-2147483648, %eax + jne ..B1.69 +..B1.58: + cmpl $0, 8(%ebp) + jne ..B1.69 +..B1.59: + fldl _zeros@GOTOFF(%ebx) + testl %edx, %edx + fstpt 12(%esp) + je ..B1.61 +..B1.60: + fldcw 70(%esp) +..B1.61: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 +..B1.62: + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.63: + cmpl $-2147483648, %eax + jne ..B1.69 +..B1.64: + cmpl $0, 8(%ebp) + jne ..B1.69 +..B1.65: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + testl %edx, %edx + fstpt 12(%esp) + je ..B1.67 +..B1.66: + fldcw 70(%esp) +..B1.67: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 +..B1.68: + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.69: + fldt 8(%ebp) + testl %edx, %edx + fmull _ones@GOTOFF(%ebx) + fstpt 12(%esp) + je ..B1.71 +..B1.70: + fldcw 70(%esp) +..B1.71: + fldt 12(%esp) + movl 148(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.38 +..B1.72: + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.76: + xorl %edx, %edx + jmp ..B1.7 + .align 16,0x90 + .type erfcl,@function + .size erfcl,.-erfcl + .data +# -- End erfcl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_erfcl_ASYMPT: + .long 0 + .long 3222929408 + .long 0 + .long 1079689216 + .type _erfcl_ASYMPT,@object + .size _erfcl_ASYMPT,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_POW_M400: + .long 0 + .long 653262848 + .type _TWO_POW_M400,@object + .size _TWO_POW_M400,8 + .align 4 +_erfcl_DX: + .long 0 + .long 1072431104 + .long 0 + .long 1071906816 + .type _erfcl_DX,@object + .size _erfcl_DX,16 + .align 2 +_erfcl_RT1: + .word 21820 + .word 42875 + .word 50317 + .word 58079 + .word 49086 + .word 0 + .word 21820 + .word 42875 + .word 50317 + .word 58079 + .word 16317 + .word 0 + .type _erfcl_RT1,@object + .size _erfcl_RT1,24 + .align 2 +_Epsilon: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _Epsilon,@object + .size _Epsilon,12 + .align 2 +_erfcl_CHDX: + .word 54762 + .word 44346 + .word 63893 + .word 44681 + .word 16382 + .word 0 + .type _erfcl_CHDX,@object + .size _erfcl_CHDX,12 + .align 2 +_erfcl_C: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50944 + .word 39545 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 61184 + .word 35913 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 55108 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 38967 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 58112 + .word 52540 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 34340 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 43938 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 55351 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 34462 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 42532 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 52130 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 63543 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 38558 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 46628 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 56226 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 63488 + .word 33819 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 40606 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 48676 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 58274 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 63488 + .word 34843 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 41630 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 49700 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 59298 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 63488 + .word 35355 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 42142 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 50212 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 54690 + .word 16389 + .word 0 + .type _erfcl_C,@object + .size _erfcl_C,336 + .align 2 +_erfcl_Q: + .word 13465 + .word 63964 + .word 23888 + .word 38962 + .word 49066 + .word 0 + .word 56793 + .word 9364 + .word 2074 + .word 60725 + .word 16376 + .word 0 + .word 38094 + .word 52495 + .word 21659 + .word 37955 + .word 49149 + .word 0 + .word 56255 + .word 60659 + .word 19352 + .word 51197 + .word 16381 + .word 0 + .word 38745 + .word 34996 + .word 58130 + .word 47148 + .word 49149 + .word 0 + .word 27061 + .word 31727 + .word 37700 + .word 35458 + .word 16381 + .word 0 + .word 30316 + .word 60982 + .word 15920 + .word 46457 + .word 49148 + .word 0 + .word 52759 + .word 48094 + .word 27926 + .word 54790 + .word 16379 + .word 0 + .word 31704 + .word 15513 + .word 33742 + .word 59335 + .word 49146 + .word 0 + .word 10280 + .word 12123 + .word 40636 + .word 59798 + .word 16377 + .word 0 + .word 55231 + .word 62106 + .word 54809 + .word 56625 + .word 49144 + .word 0 + .word 36666 + .word 22902 + .word 8427 + .word 50746 + .word 16375 + .word 0 + .word 46592 + .word 43726 + .word 50753 + .word 43230 + .word 49142 + .word 0 + .word 64491 + .word 43284 + .word 59259 + .word 34800 + .word 16373 + .word 0 + .word 61229 + .word 19548 + .word 49801 + .word 49926 + .word 49139 + .word 0 + .word 1687 + .word 39069 + .word 16746 + .word 48555 + .word 16369 + .word 0 + .word 55359 + .word 55853 + .word 34963 + .word 33408 + .word 16366 + .word 0 + .word 24851 + .word 44488 + .word 55772 + .word 44700 + .word 49147 + .word 0 + .word 44447 + .word 58130 + .word 38723 + .word 40258 + .word 49147 + .word 0 + .word 1500 + .word 15080 + .word 64595 + .word 34359 + .word 16380 + .word 0 + .word 52078 + .word 14763 + .word 48694 + .word 63117 + .word 49147 + .word 0 + .word 4694 + .word 53159 + .word 65475 + .word 45416 + .word 16379 + .word 0 + .word 37430 + .word 32424 + .word 1930 + .word 56261 + .word 49146 + .word 0 + .word 33679 + .word 45771 + .word 8173 + .word 62515 + .word 16377 + .word 0 + .word 49757 + .word 3681 + .word 5948 + .word 63753 + .word 49144 + .word 0 + .word 9193 + .word 10955 + .word 22026 + .word 60547 + .word 16375 + .word 0 + .word 55541 + .word 20458 + .word 54828 + .word 54096 + .word 49142 + .word 0 + .word 47142 + .word 16345 + .word 20299 + .word 45812 + .word 16373 + .word 0 + .word 29126 + .word 37494 + .word 48225 + .word 36984 + .word 49140 + .word 0 + .word 15107 + .word 34726 + .word 44130 + .word 57191 + .word 16370 + .word 0 + .word 57806 + .word 26620 + .word 53230 + .word 42777 + .word 49137 + .word 0 + .word 45097 + .word 47803 + .word 25447 + .word 61330 + .word 16367 + .word 0 + .word 40016 + .word 15109 + .word 58793 + .word 33461 + .word 16367 + .word 0 + .word 6456 + .word 21547 + .word 27586 + .word 56453 + .word 49147 + .word 0 + .word 5294 + .word 26959 + .word 24309 + .word 57122 + .word 49144 + .word 0 + .word 9256 + .word 20178 + .word 27285 + .word 56054 + .word 16378 + .word 0 + .word 11974 + .word 6713 + .word 58610 + .word 53898 + .word 49146 + .word 0 + .word 56155 + .word 5104 + .word 43351 + .word 37953 + .word 16378 + .word 0 + .word 31236 + .word 18492 + .word 31580 + .word 45205 + .word 49145 + .word 0 + .word 20337 + .word 4737 + .word 24808 + .word 48018 + .word 16376 + .word 0 + .word 43780 + .word 34731 + .word 45426 + .word 46730 + .word 49143 + .word 0 + .word 61467 + .word 48142 + .word 38368 + .word 42346 + .word 16374 + .word 0 + .word 39936 + .word 34435 + .word 51154 + .word 36121 + .word 49141 + .word 0 + .word 41171 + .word 26385 + .word 45942 + .word 58461 + .word 16371 + .word 0 + .word 31471 + .word 18426 + .word 18937 + .word 45145 + .word 49138 + .word 0 + .word 23734 + .word 23053 + .word 7429 + .word 33424 + .word 16369 + .word 0 + .word 28624 + .word 21549 + .word 30360 + .word 48021 + .word 49135 + .word 0 + .word 9108 + .word 57175 + .word 16609 + .word 33031 + .word 16366 + .word 0 + .word 44968 + .word 30293 + .word 53704 + .word 38182 + .word 16364 + .word 0 + .word 63279 + .word 65139 + .word 8683 + .word 42110 + .word 49144 + .word 0 + .word 43283 + .word 52727 + .word 26719 + .word 56933 + .word 49146 + .word 0 + .word 18528 + .word 63869 + .word 40120 + .word 60712 + .word 16378 + .word 0 + .word 28913 + .word 42968 + .word 213 + .word 43569 + .word 49146 + .word 0 + .word 2240 + .word 11347 + .word 26371 + .word 51717 + .word 16377 + .word 0 + .word 7147 + .word 20723 + .word 31050 + .word 54241 + .word 49144 + .word 0 + .word 49648 + .word 51324 + .word 11444 + .word 51872 + .word 16375 + .word 0 + .word 8690 + .word 5809 + .word 9903 + .word 46065 + .word 49142 + .word 0 + .word 1296 + .word 54160 + .word 11620 + .word 38443 + .word 16373 + .word 0 + .word 251 + .word 19098 + .word 34161 + .word 60807 + .word 49139 + .word 0 + .word 46412 + .word 5592 + .word 55877 + .word 45861 + .word 16370 + .word 0 + .word 5959 + .word 21591 + .word 50019 + .word 33145 + .word 49137 + .word 0 + .word 2025 + .word 457 + .word 9244 + .word 46095 + .word 16367 + .word 0 + .word 54038 + .word 55252 + .word 55370 + .word 62518 + .word 49133 + .word 0 + .word 47036 + .word 16304 + .word 12880 + .word 40628 + .word 16364 + .word 0 + .word 18241 + .word 19196 + .word 21406 + .word 57530 + .word 16365 + .word 0 + .word 21199 + .word 5012 + .word 49009 + .word 34179 + .word 49146 + .word 0 + .word 54990 + .word 53386 + .word 65270 + .word 33668 + .word 49145 + .word 0 + .word 28726 + .word 33993 + .word 32251 + .word 45542 + .word 16377 + .word 0 + .word 13837 + .word 35230 + .word 52966 + .word 64362 + .word 49144 + .word 0 + .word 39173 + .word 47380 + .word 34462 + .word 36139 + .word 16376 + .word 0 + .word 39489 + .word 64902 + .word 49120 + .word 35472 + .word 49143 + .word 0 + .word 21714 + .word 58783 + .word 27254 + .word 63315 + .word 16373 + .word 0 + .word 7367 + .word 49518 + .word 65112 + .word 52470 + .word 49140 + .word 0 + .word 43556 + .word 37199 + .word 28377 + .word 40908 + .word 16371 + .word 0 + .word 37864 + .word 51941 + .word 23210 + .word 60543 + .word 49137 + .word 0 + .word 51520 + .word 41236 + .word 58920 + .word 42796 + .word 16368 + .word 0 + .word 27066 + .word 4055 + .word 50549 + .word 58076 + .word 49134 + .word 0 + .word 8077 + .word 7791 + .word 5643 + .word 37977 + .word 16365 + .word 0 + .word 56642 + .word 7120 + .word 1392 + .word 48650 + .word 49131 + .word 0 + .word 33215 + .word 4176 + .word 55081 + .word 59653 + .word 16361 + .word 0 + .word 38962 + .word 43845 + .word 18883 + .word 41782 + .word 16366 + .word 0 + .word 9405 + .word 19610 + .word 41716 + .word 40526 + .word 49146 + .word 0 + .word 22463 + .word 33011 + .word 2834 + .word 59404 + .word 49138 + .word 0 + .word 23962 + .word 42196 + .word 52880 + .word 56044 + .word 16375 + .word 0 + .word 56651 + .word 1819 + .word 25970 + .word 41984 + .word 49143 + .word 0 + .word 36494 + .word 8013 + .word 55275 + .word 45183 + .word 16374 + .word 0 + .word 29601 + .word 10973 + .word 29140 + .word 41460 + .word 49141 + .word 0 + .word 33142 + .word 6988 + .word 53485 + .word 34321 + .word 16372 + .word 0 + .word 42305 + .word 46215 + .word 46985 + .word 52653 + .word 49138 + .word 0 + .word 32750 + .word 12648 + .word 9511 + .word 38000 + .word 16369 + .word 0 + .word 28037 + .word 7223 + .word 39341 + .word 52115 + .word 49135 + .word 0 + .word 43511 + .word 40096 + .word 33119 + .word 34189 + .word 16366 + .word 0 + .word 41081 + .word 59110 + .word 54072 + .word 43128 + .word 49132 + .word 0 + .word 52022 + .word 40239 + .word 12039 + .word 52524 + .word 16362 + .word 0 + .word 9970 + .word 11940 + .word 19019 + .word 62959 + .word 49128 + .word 0 + .word 8444 + .word 14648 + .word 8577 + .word 36069 + .word 16359 + .word 0 + .word 47055 + .word 6244 + .word 23935 + .word 45569 + .word 16364 + .word 0 + .word 17962 + .word 25012 + .word 42920 + .word 38222 + .word 49146 + .word 0 + .word 32361 + .word 55573 + .word 62116 + .word 40518 + .word 16375 + .word 0 + .word 23469 + .word 12285 + .word 11074 + .word 41169 + .word 16373 + .word 0 + .word 29710 + .word 22026 + .word 53610 + .word 45713 + .word 49141 + .word 0 + .word 19101 + .word 51375 + .word 37915 + .word 49464 + .word 16372 + .word 0 + .word 1487 + .word 25012 + .word 26269 + .word 42849 + .word 49139 + .word 0 + .word 24702 + .word 7300 + .word 26639 + .word 32851 + .word 16370 + .word 0 + .word 5625 + .word 62032 + .word 62646 + .word 46360 + .word 49136 + .word 0 + .word 16670 + .word 28857 + .word 9900 + .word 61429 + .word 16366 + .word 0 + .word 46530 + .word 36341 + .word 10884 + .word 38667 + .word 49133 + .word 0 + .word 26979 + .word 7608 + .word 53990 + .word 46612 + .word 16363 + .word 0 + .word 13306 + .word 33772 + .word 42194 + .word 54094 + .word 49129 + .word 0 + .word 5215 + .word 26849 + .word 40637 + .word 60704 + .word 16359 + .word 0 + .word 22157 + .word 10775 + .word 9954 + .word 33697 + .word 49126 + .word 0 + .word 62485 + .word 60905 + .word 33942 + .word 35703 + .word 16356 + .word 0 + .word 47033 + .word 9473 + .word 12114 + .word 36373 + .word 16366 + .word 0 + .word 18718 + .word 57887 + .word 63790 + .word 64802 + .word 49145 + .word 0 + .word 60436 + .word 32137 + .word 16772 + .word 44812 + .word 16375 + .word 0 + .word 22870 + .word 68 + .word 14788 + .word 47045 + .word 49139 + .word 0 + .word 13858 + .word 11038 + .word 51083 + .word 33832 + .word 49139 + .word 0 + .word 24411 + .word 53664 + .word 52423 + .word 44992 + .word 16370 + .word 0 + .word 23130 + .word 50537 + .word 29298 + .word 38364 + .word 49137 + .word 0 + .word 59445 + .word 25072 + .word 42634 + .word 55036 + .word 16367 + .word 0 + .word 27750 + .word 60051 + .word 51021 + .word 35697 + .word 49134 + .word 0 + .word 41673 + .word 42346 + .word 29154 + .word 43180 + .word 16364 + .word 0 + .word 24646 + .word 17588 + .word 60780 + .word 49501 + .word 49130 + .word 0 + .word 30636 + .word 48402 + .word 41439 + .word 54315 + .word 16360 + .word 0 + .word 53530 + .word 51574 + .word 33266 + .word 57402 + .word 49126 + .word 0 + .word 24832 + .word 32214 + .word 6566 + .word 58730 + .word 16356 + .word 0 + .word 57338 + .word 52017 + .word 53845 + .word 59748 + .word 49122 + .word 0 + .word 1236 + .word 12983 + .word 25321 + .word 57902 + .word 16352 + .word 0 + .word 42696 + .word 11590 + .word 13704 + .word 47288 + .word 16367 + .word 0 + .word 20112 + .word 35255 + .word 63039 + .word 51665 + .word 49145 + .word 0 + .word 20272 + .word 45351 + .word 26440 + .word 36407 + .word 16375 + .word 0 + .word 23351 + .word 42139 + .word 19582 + .word 38935 + .word 49140 + .word 0 + .word 65431 + .word 27369 + .word 16464 + .word 36140 + .word 16367 + .word 0 + .word 53584 + .word 5561 + .word 32961 + .word 55717 + .word 16367 + .word 0 + .word 39374 + .word 7231 + .word 45599 + .word 56117 + .word 49134 + .word 0 + .word 1294 + .word 6051 + .word 44462 + .word 39418 + .word 16365 + .word 0 + .word 34729 + .word 52585 + .word 9627 + .word 47645 + .word 49131 + .word 0 + .word 17858 + .word 59905 + .word 65371 + .word 52695 + .word 16361 + .word 0 + .word 43933 + .word 27878 + .word 22295 + .word 54792 + .word 49127 + .word 0 + .word 57164 + .word 8466 + .word 41536 + .word 54342 + .word 16357 + .word 0 + .word 62613 + .word 13809 + .word 4914 + .word 51847 + .word 49123 + .word 0 + .word 51382 + .word 5505 + .word 45058 + .word 47893 + .word 16353 + .word 0 + .word 20574 + .word 54447 + .word 25989 + .word 44189 + .word 49119 + .word 0 + .word 20867 + .word 50041 + .word 5177 + .word 38746 + .word 16349 + .word 0 + .word 51710 + .word 33997 + .word 26466 + .word 39335 + .word 16367 + .word 0 + .word 35180 + .word 39426 + .word 44580 + .word 39632 + .word 49145 + .word 0 + .word 39102 + .word 49560 + .word 46254 + .word 52105 + .word 16374 + .word 0 + .word 49858 + .word 3610 + .word 18403 + .word 60348 + .word 49139 + .word 0 + .word 63577 + .word 52764 + .word 23423 + .word 53731 + .word 16368 + .word 0 + .word 17746 + .word 20210 + .word 17254 + .word 46087 + .word 49131 + .word 0 + .word 57780 + .word 38655 + .word 62917 + .word 51922 + .word 49131 + .word 0 + .word 56818 + .word 27103 + .word 46800 + .word 44610 + .word 16362 + .word 0 + .word 42772 + .word 47939 + .word 39429 + .word 53363 + .word 49128 + .word 0 + .word 7127 + .word 43872 + .word 47188 + .word 55109 + .word 16358 + .word 0 + .word 35603 + .word 15923 + .word 26337 + .word 52288 + .word 49124 + .word 0 + .word 15540 + .word 23148 + .word 44469 + .word 46826 + .word 16354 + .word 0 + .word 38573 + .word 44351 + .word 49528 + .word 40134 + .word 49120 + .word 0 + .word 46922 + .word 10206 + .word 58026 + .word 33232 + .word 16350 + .word 0 + .word 48893 + .word 37264 + .word 47364 + .word 55135 + .word 49115 + .word 0 + .word 34563 + .word 54412 + .word 19025 + .word 43320 + .word 16345 + .word 0 + .word 50485 + .word 58441 + .word 18478 + .word 53939 + .word 16366 + .word 0 + .word 57295 + .word 1543 + .word 39725 + .word 59283 + .word 49144 + .word 0 + .word 61902 + .word 50672 + .word 60234 + .word 34832 + .word 16374 + .word 0 + .word 47445 + .word 686 + .word 22678 + .word 38214 + .word 49139 + .word 0 + .word 38808 + .word 16930 + .word 17219 + .word 37683 + .word 16368 + .word 0 + .word 15851 + .word 55325 + .word 43407 + .word 60214 + .word 49132 + .word 0 + .word 1143 + .word 605 + .word 3834 + .word 44087 + .word 16360 + .word 0 + .word 37926 + .word 51721 + .word 32650 + .word 51423 + .word 16358 + .word 0 + .word 719 + .word 37404 + .word 19156 + .word 44137 + .word 49125 + .word 0 + .word 35866 + .word 56877 + .word 40751 + .word 46818 + .word 16355 + .word 0 + .word 17240 + .word 30023 + .word 36586 + .word 42015 + .word 49121 + .word 0 + .word 54230 + .word 7254 + .word 30602 + .word 34461 + .word 16351 + .word 0 + .word 8012 + .word 12609 + .word 22719 + .word 53286 + .word 49116 + .word 0 + .word 30585 + .word 22802 + .word 38382 + .word 39498 + .word 16346 + .word 0 + .word 49910 + .word 61459 + .word 13066 + .word 58648 + .word 49111 + .word 0 + .word 4234 + .word 29117 + .word 43487 + .word 41014 + .word 16341 + .word 0 + .word 15283 + .word 31 + .word 53183 + .word 37265 + .word 16366 + .word 0 + .word 38704 + .word 430 + .word 57551 + .word 43591 + .word 49144 + .word 0 + .word 53647 + .word 31489 + .word 59377 + .word 44715 + .word 16373 + .word 0 + .word 58843 + .word 40196 + .word 27184 + .word 44045 + .word 49138 + .word 0 + .word 21712 + .word 17792 + .word 22495 + .word 41091 + .word 16367 + .word 0 + .word 4064 + .word 22340 + .word 38581 + .word 35349 + .word 49132 + .word 0 + .word 24218 + .word 42337 + .word 60128 + .word 52640 + .word 16360 + .word 0 + .word 20378 + .word 19984 + .word 2299 + .word 54122 + .word 49124 + .word 0 + .word 31249 + .word 59274 + .word 16273 + .word 55107 + .word 49119 + .word 0 + .word 52834 + .word 54517 + .word 12431 + .word 49909 + .word 16351 + .word 0 + .word 54832 + .word 24393 + .word 30353 + .word 51256 + .word 49117 + .word 0 + .word 65180 + .word 60129 + .word 24669 + .word 41244 + .word 16347 + .word 0 + .word 6591 + .word 13357 + .word 31681 + .word 59287 + .word 49112 + .word 0 + .word 26454 + .word 14700 + .word 42966 + .word 39875 + .word 16342 + .word 0 + .word 2956 + .word 33652 + .word 3414 + .word 53265 + .word 49107 + .word 0 + .word 52370 + .word 22181 + .word 28024 + .word 33144 + .word 16337 + .word 0 + .word 13170 + .word 827 + .word 21750 + .word 47190 + .word 16367 + .word 0 + .word 46086 + .word 34614 + .word 16391 + .word 63371 + .word 49143 + .word 0 + .word 23901 + .word 55438 + .word 56964 + .word 55951 + .word 16372 + .word 0 + .word 6825 + .word 37234 + .word 16184 + .word 48173 + .word 49137 + .word 0 + .word 100 + .word 15349 + .word 44285 + .word 40213 + .word 16366 + .word 0 + .word 46705 + .word 62401 + .word 15619 + .word 64493 + .word 49130 + .word 0 + .word 5832 + .word 45818 + .word 5603 + .word 48870 + .word 16359 + .word 0 + .word 26154 + .word 11509 + .word 12905 + .word 33853 + .word 49124 + .word 0 + .word 57899 + .word 64916 + .word 17522 + .word 39399 + .word 16352 + .word 0 + .word 11797 + .word 62659 + .word 15787 + .word 52982 + .word 49115 + .word 0 + .word 4387 + .word 49305 + .word 27685 + .word 41688 + .word 49112 + .word 0 + .word 8893 + .word 53993 + .word 6961 + .word 62732 + .word 16342 + .word 0 + .word 6561 + .word 49840 + .word 37854 + .word 49392 + .word 49108 + .word 0 + .word 22913 + .word 52496 + .word 16836 + .word 64532 + .word 16337 + .word 0 + .word 61478 + .word 12903 + .word 22917 + .word 40137 + .word 49103 + .word 0 + .word 20254 + .word 5653 + .word 41280 + .word 45163 + .word 16332 + .word 0 + .word 9250 + .word 21583 + .word 29887 + .word 42398 + .word 16367 + .word 0 + .word 21296 + .word 56033 + .word 20302 + .word 45697 + .word 49143 + .word 0 + .word 2595 + .word 14223 + .word 9373 + .word 34428 + .word 16372 + .word 0 + .word 43880 + .word 13192 + .word 17465 + .word 51046 + .word 49136 + .word 0 + .word 10750 + .word 52386 + .word 15061 + .word 37140 + .word 16365 + .word 0 + .word 43380 + .word 26688 + .word 4603 + .word 52842 + .word 49129 + .word 0 + .word 57923 + .word 50589 + .word 40806 + .word 36546 + .word 16358 + .word 0 + .word 41550 + .word 43340 + .word 52700 + .word 48703 + .word 49122 + .word 0 + .word 2829 + .word 50954 + .word 33981 + .word 61546 + .word 16350 + .word 0 + .word 53540 + .word 53334 + .word 26985 + .word 35726 + .word 49115 + .word 0 + .word 1383 + .word 41626 + .word 39002 + .word 35204 + .word 16343 + .word 0 + .word 4988 + .word 17152 + .word 47624 + .word 42298 + .word 49106 + .word 0 + .word 13081 + .word 59676 + .word 51281 + .word 43278 + .word 49102 + .word 0 + .word 20576 + .word 9083 + .word 44900 + .word 60572 + .word 16332 + .word 0 + .word 5241 + .word 64752 + .word 26216 + .word 43285 + .word 49098 + .word 0 + .word 54740 + .word 4493 + .word 22744 + .word 47855 + .word 16327 + .word 0 + .word 43008 + .word 40170 + .word 38190 + .word 50840 + .word 16367 + .word 0 + .word 64000 + .word 51124 + .word 38392 + .word 32771 + .word 49143 + .word 0 + .word 6193 + .word 27449 + .word 18043 + .word 41906 + .word 16371 + .word 0 + .word 55083 + .word 10857 + .word 24850 + .word 53024 + .word 49135 + .word 0 + .word 39204 + .word 24043 + .word 43883 + .word 33151 + .word 16364 + .word 0 + .word 16615 + .word 33399 + .word 37109 + .word 40897 + .word 49128 + .word 0 + .word 45005 + .word 13768 + .word 23576 + .word 49662 + .word 16356 + .word 0 + .word 19875 + .word 47904 + .word 27295 + .word 59169 + .word 49120 + .word 0 + .word 50767 + .word 38341 + .word 26349 + .word 34421 + .word 16349 + .word 0 + .word 61460 + .word 9200 + .word 49063 + .word 38824 + .word 49113 + .word 0 + .word 17698 + .word 13464 + .word 19312 + .word 41938 + .word 16341 + .word 0 + .word 14145 + .word 49711 + .word 41841 + .word 42410 + .word 49105 + .word 0 + .word 52259 + .word 38890 + .word 11861 + .word 38197 + .word 16333 + .word 0 + .word 37928 + .word 15208 + .word 58116 + .word 52459 + .word 49096 + .word 0 + .word 32955 + .word 48671 + .word 55988 + .word 42873 + .word 49084 + .word 0 + .word 10284 + .word 13591 + .word 10015 + .word 45425 + .word 16321 + .word 0 + .word 60165 + .word 7231 + .word 29309 + .word 47020 + .word 16366 + .word 0 + .word 2826 + .word 34241 + .word 10052 + .word 46822 + .word 49142 + .word 0 + .word 38150 + .word 11520 + .word 57874 + .word 50634 + .word 16370 + .word 0 + .word 13154 + .word 32010 + .word 59285 + .word 54374 + .word 49134 + .word 0 + .word 3630 + .word 36258 + .word 15737 + .word 57945 + .word 16362 + .word 0 + .word 33484 + .word 32040 + .word 11194 + .word 61229 + .word 49126 + .word 0 + .word 29890 + .word 19177 + .word 6587 + .word 64088 + .word 16354 + .word 0 + .word 47912 + .word 33375 + .word 45262 + .word 33179 + .word 49119 + .word 0 + .word 35727 + .word 49010 + .word 4249 + .word 33927 + .word 16347 + .word 0 + .word 48287 + .word 11774 + .word 34966 + .word 34177 + .word 49111 + .word 0 + .word 59219 + .word 12218 + .word 14591 + .word 33807 + .word 16339 + .word 0 + .word 45587 + .word 38263 + .word 60150 + .word 65351 + .word 49102 + .word 0 + .word 64248 + .word 19753 + .word 11467 + .word 61248 + .word 16330 + .word 0 + .word 8987 + .word 4417 + .word 35296 + .word 54967 + .word 49094 + .word 0 + .word 58348 + .word 59855 + .word 58179 + .word 46574 + .word 16322 + .word 0 + .word 838 + .word 40288 + .word 16803 + .word 34203 + .word 49086 + .word 0 + .word 19985 + .word 64792 + .word 35689 + .word 34160 + .word 16365 + .word 0 + .word 63242 + .word 24737 + .word 37564 + .word 33357 + .word 49142 + .word 0 + .word 21080 + .word 30395 + .word 32053 + .word 60879 + .word 16369 + .word 0 + .word 31967 + .word 27284 + .word 22818 + .word 55292 + .word 49133 + .word 0 + .word 25886 + .word 29922 + .word 20917 + .word 49964 + .word 16361 + .word 0 + .word 16415 + .word 22145 + .word 37135 + .word 44903 + .word 49125 + .word 0 + .word 60061 + .word 56529 + .word 59607 + .word 40115 + .word 16353 + .word 0 + .word 61716 + .word 63444 + .word 60667 + .word 35604 + .word 49117 + .word 0 + .word 44658 + .word 58531 + .word 9530 + .word 62744 + .word 16344 + .word 0 + .word 62260 + .word 39586 + .word 42345 + .word 54833 + .word 49108 + .word 0 + .word 28253 + .word 12485 + .word 44364 + .word 47473 + .word 16336 + .word 0 + .word 12640 + .word 24607 + .word 1626 + .word 40656 + .word 49100 + .word 0 + .word 34428 + .word 36370 + .word 1024 + .word 34362 + .word 16328 + .word 0 + .word 29040 + .word 20316 + .word 63988 + .word 57186 + .word 49091 + .word 0 + .word 56625 + .word 35023 + .word 4494 + .word 47694 + .word 16319 + .word 0 + .word 12074 + .word 64589 + .word 55447 + .word 37930 + .word 49083 + .word 0 + .word 50967 + .word 1382 + .word 5204 + .word 52101 + .word 16367 + .word 0 + .word 3284 + .word 33134 + .word 2262 + .word 47439 + .word 49141 + .word 0 + .word 46363 + .word 11691 + .word 13356 + .word 36476 + .word 16369 + .word 0 + .word 3419 + .word 29155 + .word 56063 + .word 55913 + .word 49132 + .word 0 + .word 46070 + .word 27060 + .word 45787 + .word 42709 + .word 16360 + .word 0 + .word 48455 + .word 49617 + .word 63339 + .word 65012 + .word 49123 + .word 0 + .word 11309 + .word 38321 + .word 50476 + .word 49291 + .word 16351 + .word 0 + .word 63177 + .word 54179 + .word 19446 + .word 37218 + .word 49115 + .word 0 + .word 17008 + .word 20702 + .word 63396 + .word 55953 + .word 16342 + .word 0 + .word 58916 + .word 21526 + .word 44533 + .word 41856 + .word 49106 + .word 0 + .word 4054 + .word 60910 + .word 64524 + .word 62288 + .word 16333 + .word 0 + .word 572 + .word 56463 + .word 6651 + .word 46074 + .word 49097 + .word 0 + .word 294 + .word 32916 + .word 12940 + .word 33845 + .word 16325 + .word 0 + .word 61241 + .word 23461 + .word 12133 + .word 49362 + .word 49088 + .word 0 + .word 43813 + .word 54697 + .word 47595 + .word 36628 + .word 16316 + .word 0 + .word 7023 + .word 63196 + .word 1211 + .word 52552 + .word 49079 + .word 0 + .word 49710 + .word 23216 + .word 57316 + .word 57937 + .word 16366 + .word 0 + .word 16917 + .word 54685 + .word 15559 + .word 33684 + .word 49141 + .word 0 + .word 19402 + .word 20755 + .word 35177 + .word 43607 + .word 16368 + .word 0 + .word 18988 + .word 7708 + .word 26373 + .word 56330 + .word 49131 + .word 0 + .word 31678 + .word 36048 + .word 15370 + .word 36299 + .word 16359 + .word 0 + .word 62053 + .word 9463 + .word 59420 + .word 46669 + .word 49122 + .word 0 + .word 43189 + .word 37083 + .word 47017 + .word 59851 + .word 16349 + .word 0 + .word 56431 + .word 23594 + .word 54456 + .word 38275 + .word 49113 + .word 0 + .word 57207 + .word 5358 + .word 61057 + .word 48816 + .word 16340 + .word 0 + .word 55955 + .word 61547 + .word 7096 + .word 62073 + .word 49103 + .word 0 + .word 38324 + .word 43297 + .word 2038 + .word 39337 + .word 16331 + .word 0 + .word 48019 + .word 63539 + .word 58854 + .word 49683 + .word 49094 + .word 0 + .word 38415 + .word 45891 + .word 48038 + .word 62495 + .word 16321 + .word 0 + .word 6285 + .word 58141 + .word 38062 + .word 39153 + .word 49085 + .word 0 + .word 8535 + .word 47970 + .word 20521 + .word 50223 + .word 16312 + .word 0 + .word 3599 + .word 31205 + .word 53376 + .word 62523 + .word 49075 + .word 0 + .word 53390 + .word 39428 + .word 31508 + .word 33365 + .word 16367 + .word 0 + .word 24907 + .word 1998 + .word 17203 + .word 47787 + .word 49140 + .word 0 + .word 65154 + .word 44054 + .word 55771 + .word 52050 + .word 16367 + .word 0 + .word 59345 + .word 56252 + .word 17241 + .word 56609 + .word 49130 + .word 0 + .word 21068 + .word 33081 + .word 36502 + .word 61470 + .word 16357 + .word 0 + .word 5838 + .word 32265 + .word 27141 + .word 33320 + .word 49121 + .word 0 + .word 13157 + .word 36097 + .word 56398 + .word 36061 + .word 16348 + .word 0 + .word 34641 + .word 3406 + .word 61161 + .word 38959 + .word 49111 + .word 0 + .word 36822 + .word 2107 + .word 7812 + .word 42013 + .word 16338 + .word 0 + .word 57689 + .word 7026 + .word 46609 + .word 45217 + .word 49101 + .word 0 + .word 65442 + .word 46672 + .word 32230 + .word 48567 + .word 16328 + .word 0 + .word 38794 + .word 56166 + .word 59740 + .word 52052 + .word 49091 + .word 0 + .word 7020 + .word 42539 + .word 58408 + .word 55641 + .word 16318 + .word 0 + .word 5792 + .word 16154 + .word 40642 + .word 59348 + .word 49081 + .word 0 + .word 45758 + .word 39239 + .word 10684 + .word 64996 + .word 16308 + .word 0 + .word 17135 + .word 25280 + .word 14240 + .word 34593 + .word 49072 + .word 0 + .word 22956 + .word 27174 + .word 6236 + .word 35739 + .word 16367 + .word 0 + .word 41448 + .word 9608 + .word 15061 + .word 33872 + .word 49140 + .word 0 + .word 35041 + .word 22115 + .word 31787 + .word 62060 + .word 16366 + .word 0 + .word 47943 + .word 57954 + .word 5630 + .word 56794 + .word 49129 + .word 0 + .word 12256 + .word 51468 + .word 48243 + .word 51918 + .word 16356 + .word 0 + .word 16861 + .word 555 + .word 19712 + .word 47409 + .word 49119 + .word 0 + .word 14521 + .word 28998 + .word 64476 + .word 43241 + .word 16346 + .word 0 + .word 42742 + .word 52364 + .word 18112 + .word 39394 + .word 49109 + .word 0 + .word 11937 + .word 57143 + .word 59317 + .word 35844 + .word 16336 + .word 0 + .word 54775 + .word 41142 + .word 37066 + .word 65147 + .word 49098 + .word 0 + .word 52047 + .word 20166 + .word 2989 + .word 59124 + .word 16325 + .word 0 + .word 63890 + .word 14576 + .word 19973 + .word 53583 + .word 49088 + .word 0 + .word 51017 + .word 21644 + .word 32682 + .word 48474 + .word 16315 + .word 0 + .word 14951 + .word 9527 + .word 54932 + .word 43797 + .word 49078 + .word 0 + .word 19956 + .word 63323 + .word 21590 + .word 40697 + .word 16305 + .word 0 + .word 13287 + .word 59412 + .word 52293 + .word 36781 + .word 49068 + .word 0 + .word 20654 + .word 3963 + .word 37243 + .word 46202 + .word 16367 + .word 0 + .word 14259 + .word 41161 + .word 56379 + .word 47991 + .word 49139 + .word 0 + .word 29552 + .word 20159 + .word 19967 + .word 36969 + .word 16366 + .word 0 + .word 36671 + .word 37033 + .word 31146 + .word 56915 + .word 49128 + .word 0 + .word 40096 + .word 16159 + .word 8745 + .word 43779 + .word 16355 + .word 0 + .word 31426 + .word 40251 + .word 6629 + .word 33649 + .word 49118 + .word 0 + .word 62460 + .word 14572 + .word 46922 + .word 51685 + .word 16344 + .word 0 + .word 21330 + .word 50824 + .word 20752 + .word 39663 + .word 49107 + .word 0 + .word 59043 + .word 6300 + .word 36178 + .word 60824 + .word 16333 + .word 0 + .word 11117 + .word 55297 + .word 15596 + .word 46598 + .word 49096 + .word 0 + .word 52972 + .word 24185 + .word 7857 + .word 35668 + .word 16323 + .word 0 + .word 48165 + .word 35957 + .word 4973 + .word 54554 + .word 49085 + .word 0 + .word 40559 + .word 40135 + .word 50657 + .word 41665 + .word 16312 + .word 0 + .word 22209 + .word 12399 + .word 38770 + .word 63599 + .word 49074 + .word 0 + .word 21134 + .word 56966 + .word 28654 + .word 49967 + .word 16301 + .word 0 + .word 55252 + .word 38724 + .word 60696 + .word 38196 + .word 49064 + .word 0 + .word 50324 + .word 38050 + .word 41691 + .word 52128 + .word 16367 + .word 0 + .word 57576 + .word 19017 + .word 35093 + .word 33984 + .word 49139 + .word 0 + .word 45261 + .word 53464 + .word 26203 + .word 44021 + .word 16365 + .word 0 + .word 59506 + .word 58350 + .word 50456 + .word 56993 + .word 49127 + .word 0 + .word 39656 + .word 29013 + .word 30706 + .word 36875 + .word 16354 + .word 0 + .word 15950 + .word 25278 + .word 29858 + .word 47692 + .word 49116 + .word 0 + .word 44951 + .word 52254 + .word 26639 + .word 61649 + .word 16342 + .word 0 + .word 14884 + .word 15288 + .word 36355 + .word 39823 + .word 49105 + .word 0 + .word 33589 + .word 37339 + .word 42662 + .word 51420 + .word 16331 + .word 0 + .word 59837 + .word 52901 + .word 27833 + .word 33178 + .word 49094 + .word 0 + .word 23530 + .word 8792 + .word 46326 + .word 42790 + .word 16320 + .word 0 + .word 22918 + .word 41993 + .word 30280 + .word 55154 + .word 49082 + .word 0 + .word 22935 + .word 40180 + .word 10208 + .word 35510 + .word 16309 + .word 0 + .word 24655 + .word 6092 + .word 5569 + .word 45708 + .word 49071 + .word 0 + .word 1836 + .word 9946 + .word 17030 + .word 60600 + .word 16297 + .word 0 + .word 58034 + .word 64044 + .word 12732 + .word 39095 + .word 49060 + .word 0 + .word 54043 + .word 4884 + .word 4993 + .word 50896 + .word 16365 + .word 0 + .word 52175 + .word 36282 + .word 1403 + .word 48115 + .word 49138 + .word 0 + .word 8979 + .word 278 + .word 60581 + .word 52397 + .word 16364 + .word 0 + .word 62427 + .word 36042 + .word 64958 + .word 57041 + .word 49126 + .word 0 + .word 22617 + .word 56486 + .word 29933 + .word 62075 + .word 16352 + .word 0 + .word 6668 + .word 34800 + .word 16726 + .word 33764 + .word 49115 + .word 0 + .word 58438 + .word 34332 + .word 45904 + .word 36716 + .word 16341 + .word 0 + .word 64514 + .word 12491 + .word 17770 + .word 39912 + .word 49103 + .word 0 + .word 38781 + .word 4147 + .word 20350 + .word 43369 + .word 16329 + .word 0 + .word 11653 + .word 23288 + .word 23101 + .word 47107 + .word 49091 + .word 0 + .word 24538 + .word 52112 + .word 19258 + .word 51147 + .word 16317 + .word 0 + .word 55081 + .word 11864 + .word 2795 + .word 55511 + .word 49079 + .word 0 + .word 30359 + .word 7516 + .word 42523 + .word 60199 + .word 16305 + .word 0 + .word 51632 + .word 54516 + .word 60788 + .word 65273 + .word 49067 + .word 0 + .word 8259 + .word 26817 + .word 16640 + .word 36463 + .word 16294 + .word 0 + .word 25358 + .word 21633 + .word 63088 + .word 39650 + .word 49056 + .word 0 + .word 37940 + .word 45084 + .word 22741 + .word 53976 + .word 16366 + .word 0 + .word 56905 + .word 35663 + .word 13071 + .word 34053 + .word 49138 + .word 0 + .word 6338 + .word 45524 + .word 29128 + .word 62353 + .word 16363 + .word 0 + .word 53870 + .word 55231 + .word 26051 + .word 57072 + .word 49125 + .word 0 + .word 25356 + .word 27338 + .word 39402 + .word 52225 + .word 16351 + .word 0 + .word 53832 + .word 61470 + .word 21273 + .word 47778 + .word 49113 + .word 0 + .word 58577 + .word 63695 + .word 35460 + .word 43698 + .word 16339 + .word 0 + .word 4520 + .word 44723 + .word 47409 + .word 39956 + .word 49101 + .word 0 + .word 1812 + .word 29018 + .word 42821 + .word 36525 + .word 16327 + .word 0 + .word 59061 + .word 29228 + .word 16191 + .word 33380 + .word 49089 + .word 0 + .word 39396 + .word 18010 + .word 60638 + .word 60994 + .word 16314 + .word 0 + .word 49088 + .word 9900 + .word 51011 + .word 55711 + .word 49076 + .word 0 + .word 37150 + .word 50516 + .word 56492 + .word 50852 + .word 16302 + .word 0 + .word 28484 + .word 40361 + .word 52896 + .word 46416 + .word 49064 + .word 0 + .word 62255 + .word 31126 + .word 18737 + .word 43665 + .word 16290 + .word 0 + .word 12057 + .word 58357 + .word 2287 + .word 39984 + .word 49052 + .word 0 + .word 10303 + .word 34822 + .word 30753 + .word 42638 + .word 16367 + .word 0 + .word 35383 + .word 38620 + .word 16953 + .word 48193 + .word 49137 + .word 0 + .word 33393 + .word 6703 + .word 23267 + .word 37093 + .word 16363 + .word 0 + .word 15343 + .word 55882 + .word 8818 + .word 57090 + .word 49124 + .word 0 + .word 43704 + .word 64267 + .word 56511 + .word 43925 + .word 16350 + .word 0 + .word 4607 + .word 47760 + .word 9543 + .word 33791 + .word 49112 + .word 0 + .word 56389 + .word 24814 + .word 13621 + .word 51980 + .word 16337 + .word 0 + .word 53957 + .word 28278 + .word 52920 + .word 39972 + .word 49099 + .word 0 + .word 44558 + .word 56829 + .word 64035 + .word 61466 + .word 16324 + .word 0 + .word 38720 + .word 53021 + .word 48635 + .word 47250 + .word 49086 + .word 0 + .word 44746 + .word 16730 + .word 48948 + .word 36315 + .word 16312 + .word 0 + .word 35899 + .word 1861 + .word 5901 + .word 55812 + .word 49073 + .word 0 + .word 22074 + .word 38313 + .word 14608 + .word 42863 + .word 16299 + .word 0 + .word 55515 + .word 23576 + .word 64018 + .word 32920 + .word 49061 + .word 0 + .word 12839 + .word 2194 + .word 19804 + .word 52126 + .word 16286 + .word 0 + .word 11439 + .word 41150 + .word 15351 + .word 40172 + .word 49048 + .word 0 + .word 29431 + .word 9874 + .word 45662 + .word 49530 + .word 16366 + .word 0 + .word 65266 + .word 58931 + .word 1289 + .word 34097 + .word 49137 + .word 0 + .word 37900 + .word 52013 + .word 19533 + .word 44126 + .word 16362 + .word 0 + .word 56648 + .word 29183 + .word 44293 + .word 57098 + .word 49123 + .word 0 + .word 6159 + .word 2813 + .word 55364 + .word 36937 + .word 16349 + .word 0 + .word 43479 + .word 31839 + .word 13895 + .word 47785 + .word 49110 + .word 0 + .word 5187 + .word 20139 + .word 24873 + .word 61810 + .word 16335 + .word 0 + .word 122 + .word 12763 + .word 63612 + .word 39970 + .word 49097 + .word 0 + .word 44050 + .word 14658 + .word 36451 + .word 51689 + .word 16322 + .word 0 + .word 25644 + .word 4873 + .word 38936 + .word 33417 + .word 49084 + .word 0 + .word 47798 + .word 57836 + .word 54492 + .word 43203 + .word 16309 + .word 0 + .word 13594 + .word 52300 + .word 36178 + .word 55848 + .word 49070 + .word 0 + .word 62324 + .word 37045 + .word 44215 + .word 36078 + .word 16296 + .word 0 + .word 9408 + .word 55695 + .word 35369 + .word 46620 + .word 49057 + .word 0 + .word 55933 + .word 58459 + .word 63135 + .word 62102 + .word 16282 + .word 0 + .word 9035 + .word 28599 + .word 9663 + .word 40267 + .word 49044 + .word 0 + .word 64440 + .word 9942 + .word 11459 + .word 51063 + .word 16366 + .word 0 + .word 54621 + .word 1381 + .word 54593 + .word 57593 + .word 49136 + .word 0 + .word 57672 + .word 22144 + .word 48770 + .word 34240 + .word 16362 + .word 0 + .word 41335 + .word 40315 + .word 35384 + .word 40709 + .word 49123 + .word 0 + .word 44154 + .word 2667 + .word 29983 + .word 48395 + .word 16348 + .word 0 + .word 11933 + .word 28752 + .word 33333 + .word 57526 + .word 49109 + .word 0 + .word 28038 + .word 64578 + .word 40018 + .word 34186 + .word 16335 + .word 0 + .word 37517 + .word 65009 + .word 17291 + .word 40628 + .word 49096 + .word 0 + .word 55118 + .word 35846 + .word 36301 + .word 48278 + .word 16321 + .word 0 + .word 8485 + .word 24440 + .word 14912 + .word 57363 + .word 49082 + .word 0 + .word 32377 + .word 28880 + .word 65211 + .word 34074 + .word 16308 + .word 0 + .word 34616 + .word 16831 + .word 8616 + .word 40478 + .word 49069 + .word 0 + .word 8999 + .word 50919 + .word 12017 + .word 48079 + .word 16294 + .word 0 + .word 35787 + .word 61739 + .word 12812 + .word 57101 + .word 49055 + .word 0 + .word 44504 + .word 58876 + .word 42861 + .word 33904 + .word 16281 + .word 0 + .word 47876 + .word 27247 + .word 49503 + .word 40257 + .word 49042 + .word 0 + .type _erfcl_Q,@object + .size _erfcl_Q,5376 + .align 2 +_erfcl_S: + .word 0 + .word 0 + .word 0 + .word 57344 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56559 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55197 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45662 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45290 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44607 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43781 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42924 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42104 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41357 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40696 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40122 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39629 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39210 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38855 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38556 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38304 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38091 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37913 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37763 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37637 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37531 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37442 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37368 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37305 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37252 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37208 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37189 + .word 16382 + .word 0 + .type _erfcl_S,@object + .size _erfcl_S,336 + .align 2 +_erfcl_UNDERFLOW_INT: + .word 42217 + .word 46880 + .word 24677 + .word 54546 + .word 16389 + .word 0 + .type _erfcl_UNDERFLOW_INT,@object + .size _erfcl_UNDERFLOW_INT,12 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_expl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/erff.S b/external/sgx_libm/ia32/erff.S new file mode 100644 index 0000000000..2280e0db4c --- /dev/null +++ b/external/sgx_libm/ia32/erff.S @@ -0,0 +1,251 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erff.c" + .text +..TXTST0: +# -- Begin erff + .text + .align 16,0x90 + .globl erff +erff: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movl 16(%esp), %edx + movl %edx, %eax + andl $-2147483648, %eax + andl $2147483647, %edx + orl $1065353216, %eax + movl %eax, (%esp) + cmpl $2139095040, %edx + flds (%esp) + jge ..B1.8 +..B1.2: + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $1081791744, %edx + jge ..B1.7 +..B1.3: + cmpl $1065353216, %edx + jl ..B1.5 +..B1.4: + movl %edx, %ecx + andl $8388607, %edx + shrl $23, %ecx + orl $1065353216, %edx + movl %edx, (%esp) + flds (%esp) + fsubl .L_2il0floatpacket.0@GOTOFF(%eax) + fld %st(0) + lea (%ecx,%ecx,2), %ecx + shll $5, %ecx + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldl -12104+_dbA@GOTOFF(%eax,%ecx) + fmul %st(3), %st + fldl -12120+_dbA@GOTOFF(%eax,%ecx) + fmul %st(4), %st + fxch %st(1) + faddl -12112+_dbA@GOTOFF(%eax,%ecx) + fmul %st(3), %st + faddp %st, %st(1) + fldl -12072+_dbA@GOTOFF(%eax,%ecx) + fmul %st(4), %st + fxch %st(1) + faddl -12128+_dbA@GOTOFF(%eax,%ecx) + fxch %st(1) + faddl -12080+_dbA@GOTOFF(%eax,%ecx) + fmul %st(3), %st + fldl -12088+_dbA@GOTOFF(%eax,%ecx) + fmul %st(5), %st + faddp %st, %st(1) + fldl -12040+_dbA@GOTOFF(%eax,%ecx) + fmul %st(5), %st + fxch %st(1) + faddl -12096+_dbA@GOTOFF(%eax,%ecx) + fxch %st(1) + faddl -12048+_dbA@GOTOFF(%eax,%ecx) + fmulp %st, %st(4) + fldl -12056+_dbA@GOTOFF(%eax,%ecx) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + faddl -12064+_dbA@GOTOFF(%eax,%ecx) + fmul %st(1), %st + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + addl $12, %esp + ret +..B1.5: + fstp %st(0) + flds 16(%esp) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldl 48+_dbA@GOTOFF(%eax) + fmul %st(1), %st + fldl 56+_dbA@GOTOFF(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 32+_dbA@GOTOFF(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 40+_dbA@GOTOFF(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 16+_dbA@GOTOFF(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 24+_dbA@GOTOFF(%eax) + fmulp %st, %st(2) + faddl _dbA@GOTOFF(%eax) + fxch %st(1) + faddl 8+_dbA@GOTOFF(%eax) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) +..B1.6: + addl $12, %esp + ret +..B1.7: + fldl 256+_dbA@GOTOFF(%eax) + fmulp %st, %st(1) + addl $12, %esp + ret +..B1.8: + je ..B1.11 +..B1.9: + fstp %st(0) + flds 16(%esp) + fadd %st(0), %st +..B1.11: + addl $12, %esp + ret + .align 16,0x90 + .type erff,@function + .size erff,.-erff + .data +# -- End erff + .section .rodata, "a" + .align 16 + .align 16 +_dbA: + .long 1346373606 + .long 1072827863 + .long 1710987328 + .long 3218608756 + .long 2039146822 + .long 1069343472 + .long 2052989911 + .long 3214639770 + .long 3741021613 + .long 1064657550 + .long 2828932584 + .long 3209415657 + .long 556515485 + .long 1058898537 + .long 1493771156 + .long 3202627648 + .long 1460823802 + .long 1072622165 + .long 647757120 + .long 1069445687 + .long 1478820123 + .long 3217479081 + .long 827266439 + .long 1069662880 + .long 4153551678 + .long 3215381932 + .long 3249389370 + .long 3213783616 + .long 3875823656 + .long 1066650297 + .long 2479749796 + .long 3212012677 + .long 4079794357 + .long 3210967401 + .long 3292960271 + .long 1062989018 + .long 1338933997 + .long 3204757561 + .long 4209598023 + .long 3207545998 + .long 2886434981 + .long 1072693201 + .long 1721637260 + .long 1060257935 + .long 960688093 + .long 3210436681 + .long 1128797080 + .long 1064950642 + .long 798939459 + .long 3213958757 + .long 937205111 + .long 1067493282 + .long 3504975339 + .long 3215465534 + .long 3388113641 + .long 1068080152 + .long 9542307 + .long 3215088353 + .long 1310184383 + .long 1065080747 + .long 3264801679 + .long 1066837484 + .long 3394984936 + .long 3214223095 + .long 4294967295 + .long 1072693247 + .type _dbA,@object + .size _dbA,264 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3ff80000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/erfl.S b/external/sgx_libm/ia32/erfl.S new file mode 100644 index 0000000000..8a7b0eb63c --- /dev/null +++ b/external/sgx_libm/ia32/erfl.S @@ -0,0 +1,1925 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfl.c" + .text +..TXTST0: +# -- Begin erfl + .text + .align 16,0x90 + .globl erfl +erfl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $68, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.39 +..B1.4: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.5: + fldcw 12(%esp) +..B1.6: + movl $1, %ecx +..B1.7: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movzwl 16(%ebp), %esi + andl $32767, %esi + flds ones@GOTOFF(%ebx,%edx,4) + movl %esi, %edx + movl 12(%ebp), %edi + movl %edi, %eax + shll $16, %edx + shrl $16, %eax + orl %eax, %edx + fstpt 48(%esp) + cmpl $32767, %esi + je ..B1.32 +..B1.8: + cmpl $1073860832, %edx + jge ..B1.26 +..B1.9: + fldt 8(%ebp) + fstpt 32(%esp) + fldt 32(%esp) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fucompp + fnstsw %ax + sahf + jp ..B1.10 + je ..B1.29 +..B1.10: + cmpl $16343, %esi + jle ..B1.18 +..B1.11: + cmpl $16380, %esi + jge ..B1.15 +..B1.12: + fldt 32(%esp) + testl %ecx, %ecx + fld %st(0) + fmul %st(1), %st + fld %st(1) + fld %st(2) + fldl _TWO_32H@GOTOFF(%ebx) + fmul %st(4), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fsub %st(1), %st + fldt 96+_ldbA@GOTOFF(%ebx) + fmul %st(3), %st + fldt 84+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 12+_ldbA@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(3) + fmulp %st, %st(4) + fldt _ldbA@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%esp) + je ..B1.14 +..B1.13: + fldcw 14(%esp) +..B1.14: + fldt 32(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + fldt 48(%esp) + lea -1073793024(%edx), %eax + fldt 32(%esp) + shrl $16, %edx + addl $-16380, %edx + cmpl $47103, %eax + fmulp %st, %st(1) + ja ..L3 + movl $6, %edx +..L3: + movl %edx, %esi + shll $4, %esi + imull $360, %edx, %edx + fmull erfRRTable@GOTOFF(%esi,%ebx) + fldt 456+_ldbA@GOTOFF(%ebx,%edx) + testl %ecx, %ecx + fldt 444+_ldbA@GOTOFF(%ebx,%edx) + fldt 432+_ldbA@GOTOFF(%ebx,%edx) + fldt 420+_ldbA@GOTOFF(%ebx,%edx) + fldt 408+_ldbA@GOTOFF(%ebx,%edx) + fldt 396+_ldbA@GOTOFF(%ebx,%edx) + fldt 384+_ldbA@GOTOFF(%ebx,%edx) + fxch %st(7) + faddl 8+erfRRTable@GOTOFF(%ebx,%esi) + fmul %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fxch %st(4) + fmul %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fxch %st(2) + fmul %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st(1), %st + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + fldt 372+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 360+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 348+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 336+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 324+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 312+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 300+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 288+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 276+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 264+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fmul %st, %st(1) + fld %st(0) + fldt 252+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 240+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 228+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(3) + fmul %st, %st(2) + fld %st(0) + fldt 216+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fldt 204+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(4) + fxch %st(3) + fstpt (%esp) + fldl _TWO_32H@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fld %st(0) + fxch %st(3) + fsub %st(4), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fmul %st(6), %st + fmul %st(2), %st + faddp %st, %st(3) + fld %st(3) + fmul %st(1), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + fsub %st(4), %st + faddp %st, %st(2) + fldt 132+_ldbA@GOTOFF(%ebx,%edx) + fld %st(0) + fmul %st(6), %st + fstpt 16(%esp) + fmul %st(1), %st + fldt 144+_ldbA@GOTOFF(%ebx,%edx) + fmul %st(7), %st + faddp %st, %st(1) + fldt 180+_ldbA@GOTOFF(%ebx,%edx) + fmul %st, %st(6) + fmulp %st, %st(2) + fldt 192+_ldbA@GOTOFF(%ebx,%edx) + fmulp %st, %st(7) + fxch %st(6) + faddp %st, %st(1) + fldt 156+_ldbA@GOTOFF(%ebx,%edx) + fld %st(0) + fadd %st(6), %st + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(6) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 168+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(1) + fld %st(4) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fmul %st(4), %st + fxch %st(3) + fsubr %st, %st(5) + fxch %st(1) + faddp %st, %st(5) + fxch %st(3) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 108+_ldbA@GOTOFF(%ebx,%edx) + fld %st(0) + fldt 16(%esp) + fadd %st, %st(1) + fld %st(1) + fadd %st(5), %st + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(5) + faddp %st, %st(2) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fldt 32(%esp) + fld %st(0) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fldt (%esp) + fmulp %st, %st(1) + fldt 120+_ldbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 48(%esp) + fmulp %st, %st(1) + fstpt 48(%esp) + je ..B1.17 +..B1.16: + fldcw 14(%esp) +..B1.17: + fldt 48(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + fldt _TWO5600@GOTOFF(%ebx) + testl %esi, %esi + fldt 32(%esp) + fmul %st(1), %st + fstpt 32(%esp) + fldt 32(%esp) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_32H@GOTOFF(%ebx) + fld %st(0) + fmul %st(2), %st + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(1) + fld %st(0) + fsubr %st(3), %st + fldt _ldbA@GOTOFF(%ebx) + fmul %st, %st(2) + fmulp %st, %st(1) + fldt 12+_ldbA@GOTOFF(%ebx) + fmulp %st, %st(4) + faddp %st, %st(3) + jne ..B1.22 +..B1.19: + testl $65520, %edx + je ..B1.22 +..B1.20: + fldt 48(%esp) + fldt 32(%esp) + fmulp %st, %st(1) + fldt _DenoBND@GOTOFF(%ebx) + fmul %st(5), %st + fcompp + fnstsw %ax + sahf + jbe ..B1.22 +..B1.21: + fstp %st(3) + fld %st(2) + fadd %st(2), %st + fmul %st, %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fldt 12+_TWO5600@GOTOFF(%ebx) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.23 +..B1.22: + fstp %st(1) + fstp %st(2) + faddp %st, %st(1) + fldt 12+_TWO5600@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%esp) +..B1.23: + testl %ecx, %ecx + je ..B1.25 +..B1.24: + fldcw 14(%esp) +..B1.25: + fldt (%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + fldt _Epsilon@GOTOFF(%ebx) + testl %ecx, %ecx + fldt 48(%esp) + fmul %st, %st(1) + fsubp %st, %st(1) + fstpt 48(%esp) + je ..B1.28 +..B1.27: + fldcw 14(%esp) +..B1.28: + fldt 48(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + testl %ecx, %ecx + je ..B1.31 +..B1.30: + fldcw 14(%esp) + fldt 8(%ebp) + fstpt 32(%esp) +..B1.31: + fldt 32(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + cmpl $-2147483648, %edi + jne ..B1.34 +..B1.33: + cmpl $0, 8(%ebp) + je ..B1.36 +..B1.34: + fldt 8(%ebp) + fadd %st(0), %st + fstpt 48(%esp) +..B1.36: + testl %ecx, %ecx + je ..B1.38 +..B1.37: + fldcw 14(%esp) +..B1.38: + fldt 48(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + xorl %ecx, %ecx + jmp ..B1.7 + .align 16,0x90 + .type erfl,@function + .size erfl,.-erfl + .data +# -- End erfl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +_ldbA: + .word 0 + .word 0 + .word 47746 + .word 36974 + .word 16383 + .word 0 + .word 30720 + .word 36515 + .word 17515 + .word 42715 + .word 16348 + .word 0 + .word 13842 + .word 7119 + .word 41816 + .word 49299 + .word 49149 + .word 0 + .word 3215 + .word 8543 + .word 37072 + .word 59159 + .word 16379 + .word 0 + .word 33545 + .word 17489 + .word 29065 + .word 56342 + .word 49145 + .word 0 + .word 23161 + .word 4543 + .word 59015 + .word 43821 + .word 16375 + .word 0 + .word 15198 + .word 65095 + .word 55656 + .word 57366 + .word 49140 + .word 0 + .word 11319 + .word 61676 + .word 11803 + .word 64720 + .word 16369 + .word 0 + .word 23735 + .word 16978 + .word 56014 + .word 63664 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 61888 + .word 54818 + .word 16380 + .word 0 + .word 10044 + .word 28505 + .word 55013 + .word 60780 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 27524 + .word 35697 + .word 16380 + .word 0 + .word 61965 + .word 13477 + .word 25391 + .word 40556 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 8518 + .word 53546 + .word 49142 + .word 0 + .word 60180 + .word 52984 + .word 38086 + .word 60834 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 60744 + .word 44249 + .word 49140 + .word 0 + .word 63138 + .word 9916 + .word 20408 + .word 61684 + .word 16340 + .word 0 + .word 50506 + .word 17424 + .word 9343 + .word 52291 + .word 16367 + .word 0 + .word 50365 + .word 34444 + .word 5016 + .word 49178 + .word 16364 + .word 0 + .word 17941 + .word 44182 + .word 56946 + .word 34035 + .word 49128 + .word 0 + .word 41364 + .word 35872 + .word 36905 + .word 43189 + .word 49124 + .word 0 + .word 47342 + .word 2906 + .word 40861 + .word 33222 + .word 16352 + .word 0 + .word 48408 + .word 44394 + .word 43316 + .word 61646 + .word 16347 + .word 0 + .word 52639 + .word 32949 + .word 29686 + .word 51873 + .word 49111 + .word 0 + .word 13354 + .word 8312 + .word 46883 + .word 36813 + .word 49107 + .word 0 + .word 10783 + .word 42642 + .word 20549 + .word 33739 + .word 16335 + .word 0 + .word 42435 + .word 44080 + .word 27835 + .word 37640 + .word 16330 + .word 0 + .word 55413 + .word 51626 + .word 37570 + .word 37609 + .word 49094 + .word 0 + .word 62471 + .word 35756 + .word 61962 + .word 33520 + .word 49089 + .word 0 + .word 40388 + .word 48302 + .word 32466 + .word 36673 + .word 16317 + .word 0 + .word 21782 + .word 37556 + .word 26897 + .word 52597 + .word 16311 + .word 0 + .word 35272 + .word 16771 + .word 34830 + .word 63430 + .word 49075 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26972 + .word 52968 + .word 16381 + .word 0 + .word 34629 + .word 50944 + .word 29785 + .word 56844 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 26328 + .word 64248 + .word 16380 + .word 0 + .word 5285 + .word 428 + .word 53188 + .word 60110 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 19746 + .word 48186 + .word 49145 + .word 0 + .word 3964 + .word 321 + .word 7123 + .word 45083 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 25230 + .word 61571 + .word 49142 + .word 0 + .word 57803 + .word 48946 + .word 59164 + .word 36732 + .word 49110 + .word 0 + .word 46948 + .word 32819 + .word 54758 + .word 43668 + .word 16372 + .word 0 + .word 16614 + .word 63709 + .word 23635 + .word 47684 + .word 16368 + .word 0 + .word 5734 + .word 50071 + .word 41702 + .word 52540 + .word 49134 + .word 0 + .word 1767 + .word 50346 + .word 34241 + .word 45792 + .word 49129 + .word 0 + .word 21673 + .word 57712 + .word 23306 + .word 47181 + .word 16360 + .word 0 + .word 30917 + .word 34592 + .word 23220 + .word 33297 + .word 16352 + .word 0 + .word 55246 + .word 63001 + .word 17535 + .word 33707 + .word 49122 + .word 0 + .word 5457 + .word 35457 + .word 53300 + .word 62645 + .word 16347 + .word 0 + .word 9460 + .word 62267 + .word 29700 + .word 39878 + .word 16347 + .word 0 + .word 54791 + .word 30369 + .word 50586 + .word 36074 + .word 49110 + .word 0 + .word 2078 + .word 44475 + .word 65531 + .word 40136 + .word 49108 + .word 0 + .word 65081 + .word 909 + .word 65384 + .word 51785 + .word 16335 + .word 0 + .word 42502 + .word 52825 + .word 47801 + .word 35033 + .word 16333 + .word 0 + .word 56809 + .word 22568 + .word 24289 + .word 58056 + .word 49096 + .word 0 + .word 53182 + .word 10272 + .word 7761 + .word 53779 + .word 49093 + .word 0 + .word 48071 + .word 2665 + .word 17237 + .word 54209 + .word 16321 + .word 0 + .word 49513 + .word 25795 + .word 55780 + .word 36409 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19372 + .word 46606 + .word 16382 + .word 0 + .word 22905 + .word 34398 + .word 64354 + .word 59506 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 8556 + .word 42135 + .word 16381 + .word 0 + .word 15826 + .word 39989 + .word 27742 + .word 58791 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 45602 + .word 63202 + .word 49147 + .word 0 + .word 61021 + .word 62759 + .word 37190 + .word 44093 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 11408 + .word 56180 + .word 16374 + .word 0 + .word 10545 + .word 4814 + .word 18495 + .word 39194 + .word 49109 + .word 0 + .word 49818 + .word 2604 + .word 44885 + .word 39501 + .word 16376 + .word 0 + .word 35457 + .word 26400 + .word 3144 + .word 55829 + .word 49141 + .word 0 + .word 1168 + .word 22940 + .word 48307 + .word 56355 + .word 49139 + .word 0 + .word 60825 + .word 56496 + .word 32133 + .word 38661 + .word 16370 + .word 0 + .word 41837 + .word 62246 + .word 39292 + .word 38617 + .word 16366 + .word 0 + .word 61718 + .word 27283 + .word 11883 + .word 33288 + .word 49134 + .word 0 + .word 51738 + .word 39830 + .word 42849 + .word 49937 + .word 16360 + .word 0 + .word 45393 + .word 52381 + .word 54757 + .word 41874 + .word 16361 + .word 0 + .word 45169 + .word 44591 + .word 30009 + .word 57007 + .word 49125 + .word 0 + .word 11552 + .word 4380 + .word 40671 + .word 40665 + .word 49124 + .word 0 + .word 28211 + .word 31057 + .word 64947 + .word 47497 + .word 16353 + .word 0 + .word 61755 + .word 33819 + .word 30246 + .word 61557 + .word 16350 + .word 0 + .word 57599 + .word 65445 + .word 31608 + .word 55873 + .word 49116 + .word 0 + .word 21063 + .word 33239 + .word 23242 + .word 34595 + .word 49113 + .word 0 + .word 24566 + .word 16137 + .word 47167 + .word 52509 + .word 16343 + .word 0 + .word 20857 + .word 62758 + .word 44126 + .word 43729 + .word 16338 + .word 0 + .word 26678 + .word 64201 + .word 37761 + .word 41436 + .word 49106 + .word 0 + .word 15315 + .word 3435 + .word 56025 + .word 62814 + .word 16331 + .word 0 + .word 19814 + .word 59948 + .word 14740 + .word 56311 + .word 16332 + .word 0 + .word 36977 + .word 22840 + .word 9289 + .word 39778 + .word 49096 + .word 0 + .word 62085 + .word 64048 + .word 54574 + .word 65118 + .word 49094 + .word 0 + .word 28752 + .word 34202 + .word 22833 + .word 38817 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 43704 + .word 63314 + .word 16382 + .word 0 + .word 17048 + .word 17271 + .word 64911 + .word 39894 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 47414 + .word 62353 + .word 16379 + .word 0 + .word 53119 + .word 3173 + .word 58504 + .word 64362 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 19176 + .word 46765 + .word 49148 + .word 0 + .word 36591 + .word 64385 + .word 59980 + .word 41399 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 352 + .word 36373 + .word 16380 + .word 0 + .word 63217 + .word 55085 + .word 16723 + .word 42154 + .word 49116 + .word 0 + .word 62758 + .word 20699 + .word 19176 + .word 46765 + .word 49146 + .word 0 + .word 18142 + .word 49445 + .word 47413 + .word 62353 + .word 49144 + .word 0 + .word 54343 + .word 9201 + .word 60310 + .word 40529 + .word 16377 + .word 0 + .word 62797 + .word 60885 + .word 40240 + .word 39787 + .word 49143 + .word 0 + .word 7512 + .word 45008 + .word 10012 + .word 39639 + .word 49142 + .word 0 + .word 20359 + .word 48234 + .word 1564 + .word 57372 + .word 16373 + .word 0 + .word 11764 + .word 26683 + .word 64145 + .word 49882 + .word 49137 + .word 0 + .word 32393 + .word 50330 + .word 31801 + .word 34151 + .word 49139 + .word 0 + .word 5247 + .word 4806 + .word 33577 + .word 41709 + .word 16369 + .word 0 + .word 43823 + .word 34097 + .word 44124 + .word 38558 + .word 16367 + .word 0 + .word 65526 + .word 14942 + .word 25531 + .word 60526 + .word 49134 + .word 0 + .word 38557 + .word 7794 + .word 42920 + .word 40918 + .word 16362 + .word 0 + .word 31363 + .word 35665 + .word 11710 + .word 52655 + .word 16363 + .word 0 + .word 33312 + .word 35439 + .word 34687 + .word 46194 + .word 49129 + .word 0 + .word 21144 + .word 58026 + .word 60687 + .word 57306 + .word 49127 + .word 0 + .word 20701 + .word 12315 + .word 12846 + .word 54836 + .word 16358 + .word 0 + .word 45362 + .word 30760 + .word 28723 + .word 42182 + .word 16354 + .word 0 + .word 16353 + .word 46602 + .word 41748 + .word 42697 + .word 49123 + .word 0 + .word 20735 + .word 3347 + .word 26735 + .word 62816 + .word 16351 + .word 0 + .word 13205 + .word 16964 + .word 38504 + .word 48289 + .word 16351 + .word 0 + .word 28004 + .word 15789 + .word 31604 + .word 37913 + .word 49117 + .word 0 + .word 17923 + .word 56666 + .word 63953 + .word 36481 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 36194 + .word 65534 + .word 16382 + .word 0 + .word 12232 + .word 62525 + .word 48597 + .word 39676 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 29918 + .word 37380 + .word 16371 + .word 0 + .word 48638 + .word 64479 + .word 2811 + .word 58988 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 44876 + .word 56070 + .word 49141 + .word 0 + .word 64093 + .word 3811 + .word 8439 + .word 45892 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 42382 + .word 52955 + .word 16375 + .word 0 + .word 7924 + .word 29399 + .word 61525 + .word 36582 + .word 16343 + .word 0 + .word 46606 + .word 18426 + .word 11663 + .word 35044 + .word 49145 + .word 0 + .word 15382 + .word 23178 + .word 43683 + .word 34109 + .word 16378 + .word 0 + .word 6438 + .word 10314 + .word 6872 + .word 49529 + .word 49146 + .word 0 + .word 64583 + .word 11206 + .word 41955 + .word 52421 + .word 16378 + .word 0 + .word 13495 + .word 31464 + .word 61723 + .word 36178 + .word 49146 + .word 0 + .word 28427 + .word 18799 + .word 40522 + .word 59729 + .word 16375 + .word 0 + .word 47510 + .word 26829 + .word 39947 + .word 33535 + .word 16377 + .word 0 + .word 64666 + .word 11700 + .word 15653 + .word 46358 + .word 49145 + .word 0 + .word 6475 + .word 64324 + .word 16618 + .word 52067 + .word 16376 + .word 0 + .word 31765 + .word 32664 + .word 9436 + .word 33916 + .word 16373 + .word 0 + .word 38078 + .word 37286 + .word 55507 + .word 62195 + .word 49143 + .word 0 + .word 16438 + .word 19728 + .word 54394 + .word 45557 + .word 16375 + .word 0 + .word 34868 + .word 45266 + .word 60847 + .word 41133 + .word 49140 + .word 0 + .word 6929 + .word 9316 + .word 56077 + .word 32933 + .word 49142 + .word 0 + .word 60039 + .word 42217 + .word 20756 + .word 52409 + .word 16373 + .word 0 + .word 38571 + .word 57934 + .word 18985 + .word 61369 + .word 49138 + .word 0 + .word 44492 + .word 40353 + .word 2663 + .word 35859 + .word 49140 + .word 0 + .word 54254 + .word 26892 + .word 54523 + .word 56697 + .word 16370 + .word 0 + .word 63636 + .word 38694 + .word 30824 + .word 51163 + .word 49138 + .word 0 + .word 56107 + .word 41638 + .word 48577 + .word 57632 + .word 49138 + .word 0 + .word 13301 + .word 46198 + .word 34221 + .word 52080 + .word 16368 + .word 0 + .word 6730 + .word 19704 + .word 41453 + .word 49062 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 32541 + .word 25746 + .word 20185 + .word 50811 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 40118 + .word 38623 + .word 16333 + .word 0 + .word 63899 + .word 60569 + .word 18971 + .word 35021 + .word 49068 + .word 0 + .word 0 + .word 0 + .word 35006 + .word 57940 + .word 49105 + .word 0 + .word 31190 + .word 18012 + .word 64261 + .word 44050 + .word 16305 + .word 0 + .word 0 + .word 0 + .word 44288 + .word 57137 + .word 16341 + .word 0 + .word 30741 + .word 21478 + .word 2085 + .word 43126 + .word 49077 + .word 0 + .word 43184 + .word 28511 + .word 48193 + .word 41628 + .word 49113 + .word 0 + .word 38069 + .word 12322 + .word 59848 + .word 47812 + .word 16348 + .word 0 + .word 14423 + .word 51984 + .word 32740 + .word 45128 + .word 49119 + .word 0 + .word 4208 + .word 46602 + .word 27709 + .word 35782 + .word 16354 + .word 0 + .word 36873 + .word 25112 + .word 30428 + .word 48402 + .word 49124 + .word 0 + .word 10843 + .word 45056 + .word 322 + .word 58525 + .word 16358 + .word 0 + .word 34740 + .word 5397 + .word 19459 + .word 63343 + .word 49128 + .word 0 + .word 43258 + .word 62838 + .word 12965 + .word 52557 + .word 16362 + .word 0 + .word 52181 + .word 57107 + .word 24596 + .word 44275 + .word 49132 + .word 0 + .word 8033 + .word 61170 + .word 58452 + .word 55638 + .word 16366 + .word 0 + .word 18754 + .word 55045 + .word 40463 + .word 41822 + .word 49134 + .word 0 + .word 31326 + .word 56708 + .word 50347 + .word 42397 + .word 49136 + .word 0 + .word 54840 + .word 45764 + .word 11355 + .word 33431 + .word 49141 + .word 0 + .word 56285 + .word 35328 + .word 49599 + .word 58875 + .word 49141 + .word 0 + .word 42904 + .word 46324 + .word 60880 + .word 56231 + .word 16375 + .word 0 + .word 42754 + .word 64912 + .word 63809 + .word 36632 + .word 16379 + .word 0 + .word 28983 + .word 59630 + .word 18663 + .word 33292 + .word 16381 + .word 0 + .word 56135 + .word 38086 + .word 60740 + .word 37575 + .word 16382 + .word 0 + .word 11769 + .word 21615 + .word 56585 + .word 54481 + .word 16382 + .word 0 + .word 64055 + .word 1299 + .word 36942 + .word 50744 + .word 16382 + .word 0 + .word 6073 + .word 42872 + .word 14757 + .word 53598 + .word 16381 + .word 0 + .word 7021 + .word 43375 + .word 58781 + .word 46458 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 64268 + .word 65535 + .word 16382 + .word 0 + .word 36579 + .word 26545 + .word 24435 + .word 50138 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 14458 + .word 38069 + .word 16364 + .word 0 + .word 15998 + .word 59065 + .word 36918 + .word 41001 + .word 16328 + .word 0 + .word 0 + .word 0 + .word 15150 + .word 34500 + .word 49134 + .word 0 + .word 33246 + .word 7128 + .word 23211 + .word 39186 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 36820 + .word 40101 + .word 16367 + .word 0 + .word 45920 + .word 25716 + .word 39121 + .word 51060 + .word 49103 + .word 0 + .word 52724 + .word 56956 + .word 1384 + .word 33467 + .word 49136 + .word 0 + .word 16783 + .word 11603 + .word 62021 + .word 42511 + .word 16368 + .word 0 + .word 34064 + .word 49622 + .word 4121 + .word 42444 + .word 49136 + .word 0 + .word 14084 + .word 4161 + .word 1985 + .word 33838 + .word 16368 + .word 0 + .word 65189 + .word 58247 + .word 7682 + .word 43141 + .word 49135 + .word 0 + .word 15983 + .word 3226 + .word 43602 + .word 43186 + .word 16366 + .word 0 + .word 7235 + .word 9522 + .word 4836 + .word 63885 + .word 49132 + .word 0 + .word 33104 + .word 49991 + .word 48728 + .word 55353 + .word 16362 + .word 0 + .word 10837 + .word 43216 + .word 47090 + .word 42202 + .word 16359 + .word 0 + .word 11340 + .word 13469 + .word 16673 + .word 42993 + .word 49128 + .word 0 + .word 19848 + .word 42271 + .word 35005 + .word 38963 + .word 16359 + .word 0 + .word 38280 + .word 23060 + .word 26803 + .word 65491 + .word 49124 + .word 0 + .word 3155 + .word 63825 + .word 24453 + .word 53521 + .word 49121 + .word 0 + .word 8736 + .word 25576 + .word 59728 + .word 40305 + .word 16354 + .word 0 + .word 21836 + .word 54867 + .word 10689 + .word 53743 + .word 49120 + .word 0 + .word 35590 + .word 40641 + .word 40511 + .word 35834 + .word 16349 + .word 0 + .word 42959 + .word 52506 + .word 48660 + .word 55474 + .word 16348 + .word 0 + .word 62734 + .word 58818 + .word 9020 + .word 51302 + .word 49115 + .word 0 + .word 59117 + .word 1762 + .word 19420 + .word 58690 + .word 16344 + .word 0 + .word 54865 + .word 3647 + .word 6267 + .word 65292 + .word 16342 + .word 0 + .word 35287 + .word 43939 + .word 50577 + .word 38705 + .word 49110 + .word 0 + .word 78 + .word 46283 + .word 25201 + .word 34088 + .word 16338 + .word 0 + .type _ldbA,@object + .size _ldbA,2628 + .space 12, 0x00 # pad + .align 16 +erfRRTable: + .long 0x00000000,0x40200000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x40100000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x40000000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3fd00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xc00d0000 + .type erfRRTable,@object + .size erfRRTable,112 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_TWO5600: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 21983 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 10783 + .word 0 + .type _TWO5600,@object + .size _TWO5600,24 + .align 2 +_DenoBND: + .word 43678 + .word 54205 + .word 57926 + .word 29039 + .word 0 + .word 0 + .type _DenoBND,@object + .size _DenoBND,12 + .align 2 +_Epsilon: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16313 + .word 0 + .type _Epsilon,@object + .size _Epsilon,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/exp10_wmt.S b/external/sgx_libm/ia32/exp10_wmt.S new file mode 100644 index 0000000000..3357dec2b8 --- /dev/null +++ b/external/sgx_libm/ia32/exp10_wmt.S @@ -0,0 +1,580 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp10_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin exp10 + .text + .align 16,0x90 + .globl exp10 +exp10: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + unpcklpd %xmm0, %xmm0 + movapd 64(%ebx), %xmm1 + movapd 48(%ebx), %xmm6 + movapd 80(%ebx), %xmm2 + movapd 96(%ebx), %xmm3 + pextrw $3, %xmm0, %eax + andl $32767, %eax + movl $16500, %edx + subl %eax, %edx + subl $15472, %eax + orl %eax, %edx + cmpl $-2147483648, %edx + jae .L_2TAG_PACKET_0.0.3 + mulpd %xmm0, %xmm1 + addpd %xmm6, %xmm1 + movapd %xmm1, %xmm7 + subpd %xmm6, %xmm1 + mulpd %xmm1, %xmm2 + movapd 112(%ebx), %xmm4 + mulpd %xmm1, %xmm3 + movapd 1168(%ebx), %xmm1 + movapd 128(%ebx), %xmm5 + subpd %xmm2, %xmm0 + movd %xmm7, %eax + movl %eax, %ecx + andl $63, %ecx + shll $4, %ecx + sarl $6, %eax + movl %eax, %edx + subpd %xmm3, %xmm0 + movapd 144(%ebx,%ecx), %xmm2 + mulpd %xmm0, %xmm4 + mulpd %xmm0, %xmm1 + mulpd %xmm0, %xmm0 + addpd %xmm4, %xmm5 + mulsd %xmm0, %xmm0 + addsd %xmm2, %xmm1 + unpckhpd %xmm2, %xmm2 + movdqa 16(%ebx), %xmm6 + pand %xmm6, %xmm7 + movdqa 32(%ebx), %xmm6 + paddq %xmm6, %xmm7 + psllq $46, %xmm7 + mulpd %xmm5, %xmm0 + addsd %xmm0, %xmm1 + orpd %xmm7, %xmm2 + unpckhpd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + addl $894, %edx + cmpl $1916, %edx + ja .L_2TAG_PACKET_1.0.3 + mulsd %xmm2, %xmm0 + addsd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + fstcw 24(%esp) + movzwl 24(%esp), %edx + orl $768, %edx + movw %dx, 28(%esp) + fldcw 28(%esp) + movl %eax, %edx + sarl $1, %eax + subl %eax, %edx + movdqa (%ebx), %xmm6 + pandn %xmm2, %xmm6 + addl $1023, %eax + movd %eax, %xmm3 + psllq $52, %xmm3 + orpd %xmm3, %xmm6 + addl $1023, %edx + movd %edx, %xmm4 + psllq $52, %xmm4 + movsd %xmm0, 8(%esp) + fldl 8(%esp) + movsd %xmm6, 16(%esp) + fldl 16(%esp) + fmul %st, %st(1) + faddp %st, %st(1) + movsd %xmm4, 8(%esp) + fldl 8(%esp) + fmulp %st, %st(1) + fstpl 8(%esp) + movsd 8(%esp), %xmm0 + fldcw 24(%esp) + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl $32752, %ecx + jae .L_2TAG_PACKET_3.0.3 + movl $265, %edx + cmpl $0, %ecx + je .L_2TAG_PACKET_4.0.3 + jmp .L_2TAG_PACKET_2.0.3 + cmpl $-2147483648, %ecx + jb .L_2TAG_PACKET_3.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + movl $166, %edx +.L_2TAG_PACKET_4.0.3: + movsd %xmm0, (%esp) + movsd 128(%esp), %xmm0 + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_6.0.3: + cmpl $2146435072, %eax + jae .L_2TAG_PACKET_7.0.3 + movl 132(%esp), %eax + cmpl $-2147483648, %eax + jae .L_2TAG_PACKET_8.0.3 + movsd 1208(%ebx), %xmm0 + mulsd %xmm0, %xmm0 + movl $166, %edx + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_8.0.3: + movsd 1216(%ebx), %xmm0 + mulsd %xmm0, %xmm0 + movl $265, %edx + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_7.0.3: + movl 128(%esp), %edx + cmpl $2146435072, %eax + ja .L_2TAG_PACKET_9.0.3 + cmpl $0, %edx + jne .L_2TAG_PACKET_9.0.3 + movl 132(%esp), %eax + cmpl $2146435072, %eax + jne .L_2TAG_PACKET_10.0.3 + movsd 1192(%ebx), %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_10.0.3: + movsd 1200(%ebx), %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_9.0.3: + movsd 128(%esp), %xmm0 + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + movl 132(%esp), %eax + andl $2147483647, %eax + cmpl $1081344000, %eax + jae .L_2TAG_PACKET_6.0.3 + movsd 128(%esp), %xmm0 + addsd 1184(%ebx), %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 48(%esp) + fldl 48(%esp) +.L_2TAG_PACKET_5.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type exp10,@function + .size exp10,.-exp10 + .data +# -- End exp10 + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 4293918720 + .long 0 + .long 4293918720 + .long 4294967232 + .long 0 + .long 4294967232 + .long 0 + .long 65472 + .long 0 + .long 65472 + .long 0 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 158966641 + .long 1080726351 + .long 158966641 + .long 1080726351 + .long 1352531968 + .long 1064518675 + .long 1352531968 + .long 1064518675 + .long 824119987 + .long 1027055599 + .long 824119987 + .long 1027055599 + .long 3549356600 + .long 1071727285 + .long 2447043358 + .long 1073760005 + .long 2974317904 + .long 1072872823 + .long 3342652200 + .long 1074083108 + .long 0 + .long 0 + .long 0 + .long 0 + .long 235107661 + .long 1018002367 + .long 1048019040 + .long 11418 + .long 896005651 + .long 1015861842 + .long 3541402996 + .long 22960 + .long 1642514529 + .long 1012987726 + .long 410360776 + .long 34629 + .long 1568897900 + .long 1016568486 + .long 1828292879 + .long 46424 + .long 1882168529 + .long 1010744893 + .long 852742562 + .long 58348 + .long 509852888 + .long 1017336174 + .long 3490863952 + .long 70401 + .long 653277307 + .long 1017431380 + .long 2930322911 + .long 82586 + .long 1649557430 + .long 1017729363 + .long 1014845818 + .long 94904 + .long 1058231231 + .long 1015777676 + .long 3949972341 + .long 107355 + .long 1044000607 + .long 1016786167 + .long 828946858 + .long 119943 + .long 1151779725 + .long 1015705409 + .long 2288159958 + .long 132667 + .long 3819481236 + .long 1016499965 + .long 1853186616 + .long 145530 + .long 2552227826 + .long 1015039787 + .long 1709341917 + .long 158533 + .long 1829350193 + .long 1015216097 + .long 4112506593 + .long 171677 + .long 1913391795 + .long 1015756674 + .long 2799960843 + .long 184965 + .long 1303423926 + .long 1015238005 + .long 171030293 + .long 198398 + .long 1574172746 + .long 1016061241 + .long 2992903935 + .long 211976 + .long 3424156969 + .long 1017196428 + .long 926591434 + .long 225703 + .long 1938513547 + .long 1017631273 + .long 887463926 + .long 239579 + .long 2804567149 + .long 1015390024 + .long 1276261410 + .long 253606 + .long 631083525 + .long 1017690182 + .long 569847337 + .long 267786 + .long 1623370770 + .long 1011049453 + .long 1617004845 + .long 282120 + .long 3667985273 + .long 1013894369 + .long 3049340112 + .long 296610 + .long 3145379760 + .long 1014403278 + .long 3577096743 + .long 311258 + .long 2603100681 + .long 1017152460 + .long 1990012070 + .long 326066 + .long 3249202951 + .long 1017448880 + .long 1453150081 + .long 341035 + .long 419288974 + .long 1016280325 + .long 917841882 + .long 356167 + .long 3793507337 + .long 1016095713 + .long 3712504873 + .long 371463 + .long 728023093 + .long 1016345318 + .long 363667784 + .long 386927 + .long 2582678538 + .long 1017123460 + .long 2956612996 + .long 402558 + .long 7592966 + .long 1016721543 + .long 2186617380 + .long 418360 + .long 228611441 + .long 1016696141 + .long 1719614412 + .long 434334 + .long 2261665670 + .long 1017457593 + .long 1013258798 + .long 450482 + .long 544148907 + .long 1017323666 + .long 3907805043 + .long 466805 + .long 2383914918 + .long 1017143586 + .long 1447192520 + .long 483307 + .long 1176412038 + .long 1017267372 + .long 1944781190 + .long 499988 + .long 2882956373 + .long 1013312481 + .long 919555682 + .long 516851 + .long 3154077648 + .long 1016528543 + .long 2571947538 + .long 533897 + .long 348651999 + .long 1016405780 + .long 2604962540 + .long 551129 + .long 3253791412 + .long 1015920431 + .long 1110089947 + .long 568549 + .long 1509121860 + .long 1014756995 + .long 2568320822 + .long 586158 + .long 2617649212 + .long 1017340090 + .long 2966275556 + .long 603959 + .long 553214634 + .long 1016457425 + .long 2682146383 + .long 621954 + .long 730975783 + .long 1014083580 + .long 2191782032 + .long 640145 + .long 1486499517 + .long 1016818996 + .long 2069751140 + .long 658534 + .long 2595788928 + .long 1016407932 + .long 2990417244 + .long 677123 + .long 1853053619 + .long 1015310724 + .long 1434058175 + .long 695915 + .long 2462790535 + .long 1015814775 + .long 2572866477 + .long 714911 + .long 3693944214 + .long 1017259110 + .long 3092190714 + .long 734114 + .long 2979333550 + .long 1017188654 + .long 4076559942 + .long 753526 + .long 174054861 + .long 1014300631 + .long 2420883922 + .long 773150 + .long 816778419 + .long 1014197934 + .long 3716502172 + .long 792987 + .long 3507050924 + .long 1015341199 + .long 777507147 + .long 813041 + .long 1821514088 + .long 1013410604 + .long 3706687593 + .long 833312 + .long 920623539 + .long 1016295433 + .long 1242007931 + .long 853805 + .long 2789017511 + .long 1014276997 + .long 3707479175 + .long 874520 + .long 3586233004 + .long 1015962192 + .long 64696965 + .long 895462 + .long 474650514 + .long 1016642419 + .long 863738718 + .long 916631 + .long 1614448851 + .long 1014281732 + .long 3884662774 + .long 938030 + .long 2450082086 + .long 1016164135 + .long 2728693977 + .long 959663 + .long 1101668360 + .long 1015989180 + .long 3999357479 + .long 981531 + .long 835814894 + .long 1015702697 + .long 1533953344 + .long 1003638 + .long 1301400989 + .long 1014466875 + .long 2174652632 + .long 1025985 + .long 3149223190 + .long 1073900465 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 4294967295 + .long 2146435071 + .long 0 + .long 1048576 + .type static_const_table,@object + .size static_const_table,1224 + .data + .section .note.GNU-stack, "" +# End + + .globl pow10 + .equ pow10, exp10 + diff --git a/external/sgx_libm/ia32/exp10f_wmt.S b/external/sgx_libm/ia32/exp10f_wmt.S new file mode 100644 index 0000000000..c09cfab5d8 --- /dev/null +++ b/external/sgx_libm/ia32/exp10f_wmt.S @@ -0,0 +1,763 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp10f_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin exp10f + .text + .align 16,0x90 + .globl exp10f +exp10f: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %ecx + movsd 2064(%ebx), %xmm3 + xorpd %xmm7, %xmm7 + movl $17208, %eax + pinsrw $3, %eax, %xmm7 + cvtps2pd %xmm0, %xmm1 + andl $2147483647, %ecx + subl $830472192, %ecx + cmpl $278378496, %ecx + jae .L_2TAG_PACKET_0.0.3 + movsd 2048(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + movapd %xmm7, %xmm2 + xorpd %xmm1, %xmm1 + addsd %xmm3, %xmm7 + movsd 2056(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + addl $830472192, %ecx + cmpl $830472192, %ecx + jb .L_2TAG_PACKET_2.0.3 + cmpl $1115684864, %ecx + jae .L_2TAG_PACKET_3.0.3 + movsd 2048(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + movapd %xmm7, %xmm2 + xorpd %xmm1, %xmm1 + addsd %xmm3, %xmm7 + movsd 2056(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movd %xmm0, %eax + cmpl $8388608, %eax + jb .L_2TAG_PACKET_4.0.3 + cmpl $2139095040, %eax + je .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movd %xmm0, %edx + cmpl $2139095040, %ecx + jae .L_2TAG_PACKET_6.0.3 + testl $-2147483648, %edx + je .L_2TAG_PACKET_5.0.3 + movl $8388608, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_4.0.3: + movl $266, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_5.0.3: + movl $2130706432, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 + movl $167, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_2.0.3: + movl $1065353216, %eax + movd %eax, %xmm1 + addss %xmm1, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_6.0.3: + cmpl $-8388608, %edx + je .L_2TAG_PACKET_9.0.3 + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_9.0.3: + fldz + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_1.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type exp10f,@function + .size exp10f,.-exp10f + .data +# -- End exp10f + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 4200250559 + .long 1072696090 + .long 2851812149 + .long 1072698941 + .long 339411585 + .long 1072701800 + .long 1048019041 + .long 1072704666 + .long 772914124 + .long 1072707540 + .long 3899555717 + .long 1072710421 + .long 1928746161 + .long 1072713311 + .long 3541402996 + .long 1072716208 + .long 238821257 + .long 1072719114 + .long 702412510 + .long 1072722027 + .long 728934454 + .long 1072724948 + .long 410360776 + .long 1072727877 + .long 4133881824 + .long 1072730813 + .long 3402036099 + .long 1072733758 + .long 2602514713 + .long 1072736711 + .long 1828292879 + .long 1072739672 + .long 1172597893 + .long 1072742641 + .long 728909815 + .long 1072745618 + .long 590962156 + .long 1072748603 + .long 852742562 + .long 1072751596 + .long 1608493509 + .long 1072754597 + .long 2952712987 + .long 1072757606 + .long 685187902 + .long 1072760624 + .long 3490863953 + .long 1072763649 + .long 2875075254 + .long 1072766683 + .long 3228316108 + .long 1072769725 + .long 351405227 + .long 1072772776 + .long 2930322912 + .long 1072775834 + .long 2471440686 + .long 1072778901 + .long 3366293073 + .long 1072781976 + .long 1416741826 + .long 1072785060 + .long 1014845819 + .long 1072788152 + .long 2257959872 + .long 1072791252 + .long 948735466 + .long 1072794361 + .long 1480023343 + .long 1072797478 + .long 3949972341 + .long 1072800603 + .long 4162030108 + .long 1072803737 + .long 2214878420 + .long 1072806880 + .long 2502433899 + .long 1072810031 + .long 828946858 + .long 1072813191 + .long 1588871207 + .long 1072816359 + .long 586995997 + .long 1072819536 + .long 2218315341 + .long 1072822721 + .long 2288159958 + .long 1072825915 + .long 897099801 + .long 1072829118 + .long 2440944790 + .long 1072832329 + .long 2725843665 + .long 1072835549 + .long 1853186616 + .long 1072838778 + .long 4219606026 + .long 1072842015 + .long 1337108031 + .long 1072845262 + .long 1897844341 + .long 1072848517 + .long 1709341917 + .long 1072851781 + .long 874372905 + .long 1072855054 + .long 3790955393 + .long 1072858335 + .long 1972484976 + .long 1072861626 + .long 4112506593 + .long 1072864925 + .long 1724976915 + .long 1072868234 + .long 3504003472 + .long 1072871551 + .long 964107055 + .long 1072874878 + .long 2799960843 + .long 1072878213 + .long 526652809 + .long 1072881558 + .long 2839424854 + .long 1072884911 + .long 1253935211 + .long 1072888274 + .long 171030293 + .long 1072891646 + .long 3991843581 + .long 1072895026 + .long 4232894513 + .long 1072898416 + .long 1000925746 + .long 1072901816 + .long 2992903935 + .long 1072905224 + .long 1726216749 + .long 1072908642 + .long 1603444721 + .long 1072912069 + .long 2732492859 + .long 1072915505 + .long 926591435 + .long 1072918951 + .long 589198666 + .long 1072922406 + .long 1829099622 + .long 1072925870 + .long 460407023 + .long 1072929344 + .long 887463927 + .long 1072932827 + .long 3219942644 + .long 1072936319 + .long 3272845541 + .long 1072939821 + .long 1156440435 + .long 1072943333 + .long 1276261410 + .long 1072946854 + .long 3743175029 + .long 1072950384 + .long 78413852 + .long 1072953925 + .long 3278348324 + .long 1072957474 + .long 569847338 + .long 1072961034 + .long 654919306 + .long 1072964603 + .long 3645941911 + .long 1072968181 + .long 1065662932 + .long 1072971770 + .long 1617004845 + .long 1072975368 + .long 1118294578 + .long 1072978976 + .long 3978100823 + .long 1072982593 + .long 1720398391 + .long 1072986221 + .long 3049340112 + .long 1072989858 + .long 3784486610 + .long 1072993505 + .long 4040676318 + .long 1072997162 + .long 3933059031 + .long 1073000829 + .long 3577096743 + .long 1073004506 + .long 3088564500 + .long 1073008193 + .long 2583551245 + .long 1073011890 + .long 2178460671 + .long 1073015597 + .long 1990012071 + .long 1073019314 + .long 2135241198 + .long 1073023041 + .long 2731501122 + .long 1073026778 + .long 3896463087 + .long 1073030525 + .long 1453150082 + .long 1073034283 + .long 4109806887 + .long 1073038050 + .long 3395129871 + .long 1073041828 + .long 3723038930 + .long 1073045616 + .long 917841882 + .long 1073049415 + .long 3689071823 + .long 1073053223 + .long 3566716925 + .long 1073057042 + .long 671025100 + .long 1073060872 + .long 3712504873 + .long 1073064711 + .long 4222122499 + .long 1073068561 + .long 2321106615 + .long 1073072422 + .long 2425981843 + .long 1073076293 + .long 363667784 + .long 1073080175 + .long 551349105 + .long 1073084067 + .long 3111574537 + .long 1073087969 + .long 3872257780 + .long 1073091882 + .long 2956612997 + .long 1073095806 + .long 488188413 + .long 1073099741 + .long 885834528 + .long 1073103686 + .long 4273770423 + .long 1073107641 + .long 2186617381 + .long 1073111608 + .long 3339203574 + .long 1073115585 + .long 3561793907 + .long 1073119573 + .long 2979960120 + .long 1073123572 + .long 1719614413 + .long 1073127582 + .long 4201977662 + .long 1073131602 + .long 1963711167 + .long 1073135634 + .long 3721688645 + .long 1073139676 + .long 1013258799 + .long 1073143730 + .long 2555984613 + .long 1073147794 + .long 4182873220 + .long 1073151869 + .long 1727278727 + .long 1073155956 + .long 3907805044 + .long 1073160053 + .long 2263535754 + .long 1073164162 + .long 1218806132 + .long 1073168282 + .long 903334909 + .long 1073172413 + .long 1447192521 + .long 1073176555 + .long 2980802057 + .long 1073180708 + .long 1339972927 + .long 1073184873 + .long 950803702 + .long 1073189049 + .long 1944781191 + .long 1073193236 + .long 158781403 + .long 1073197435 + .long 19972402 + .long 1073201645 + .long 1660913392 + .long 1073205866 + .long 919555682 + .long 1073210099 + .long 2224145553 + .long 1073214343 + .long 1413356050 + .long 1073218599 + .long 2916157145 + .long 1073222866 + .long 2571947539 + .long 1073227145 + .long 515457527 + .long 1073231436 + .long 1176749997 + .long 1073235738 + .long 396319521 + .long 1073240052 + .long 2604962541 + .long 1073244377 + .long 3643909174 + .long 1073248714 + .long 3649726105 + .long 1073253063 + .long 2759350287 + .long 1073257424 + .long 1110089947 + .long 1073261797 + .long 3134592888 + .long 1073266181 + .long 380978316 + .long 1073270578 + .long 1577608921 + .long 1073274986 + .long 2568320822 + .long 1073279406 + .long 3492293770 + .long 1073283838 + .long 194117574 + .long 1073288283 + .long 1403662306 + .long 1073292739 + .long 2966275557 + .long 1073297207 + .long 727685349 + .long 1073301688 + .long 3418903055 + .long 1073306180 + .long 2591453363 + .long 1073310685 + .long 2682146384 + .long 1073315202 + .long 3833209506 + .long 1073319731 + .long 1892288442 + .long 1073324273 + .long 1297350157 + .long 1073328827 + .long 2191782032 + .long 1073333393 + .long 424392917 + .long 1073337972 + .long 434316067 + .long 1073342563 + .long 2366108318 + .long 1073347166 + .long 2069751141 + .long 1073351782 + .long 3985553595 + .long 1073356410 + .long 3964284211 + .long 1073361051 + .long 2152073944 + .long 1073365705 + .long 2990417245 + .long 1073370371 + .long 2331271250 + .long 1073375050 + .long 321958744 + .long 1073379742 + .long 1405169241 + .long 1073384446 + .long 1434058175 + .long 1073389163 + .long 557149882 + .long 1073393893 + .long 3218338682 + .long 1073398635 + .long 977020788 + .long 1073403391 + .long 2572866477 + .long 1073408159 + .long 3861050111 + .long 1073412940 + .long 697153126 + .long 1073417735 + .long 1822067026 + .long 1073422542 + .long 3092190715 + .long 1073427362 + .long 364333489 + .long 1073432196 + .long 2380618042 + .long 1073437042 + .long 703710506 + .long 1073441902 + .long 4076559943 + .long 1073446774 + .long 4062661092 + .long 1073451660 + .long 815859274 + .long 1073456560 + .long 3080351519 + .long 1073461472 + .long 2420883922 + .long 1073466398 + .long 3287523847 + .long 1073471337 + .long 1540824585 + .long 1073476290 + .long 1631695677 + .long 1073481256 + .long 3716502172 + .long 1073486235 + .long 3657065772 + .long 1073491228 + .long 1610600570 + .long 1073496235 + .long 2029714210 + .long 1073501255 + .long 777507147 + .long 1073506289 + .long 2307442995 + .long 1073511336 + .long 2483480501 + .long 1073516397 + .long 1464976603 + .long 1073521472 + .long 3706687593 + .long 1073526560 + .long 778901109 + .long 1073531663 + .long 1432208378 + .long 1073536779 + .long 1532734324 + .long 1073541909 + .long 1242007932 + .long 1073547053 + .long 721996136 + .long 1073552211 + .long 135105010 + .long 1073557383 + .long 3939148246 + .long 1073562568 + .long 3707479175 + .long 1073567768 + .long 3898795731 + .long 1073572982 + .long 382305176 + .long 1073578211 + .long 1912561781 + .long 1073583453 + .long 64696965 + .long 1073588710 + .long 3594158869 + .long 1073593980 + .long 4076975200 + .long 1073599265 + .long 1679558232 + .long 1073604565 + .long 863738719 + .long 1073609879 + .long 1796832535 + .long 1073615207 + .long 351641897 + .long 1073620550 + .long 991358482 + .long 1073625907 + .long 3884662774 + .long 1073631278 + .long 610758006 + .long 1073636665 + .long 4224142467 + .long 1073642065 + .long 2009970496 + .long 1073647481 + .long 2728693978 + .long 1073652911 + .long 2256325230 + .long 1073658356 + .long 764307441 + .long 1073663816 + .long 2719515920 + .long 1073669290 + .long 3999357479 + .long 1073674779 + .long 481706282 + .long 1073680284 + .long 929806999 + .long 1073685803 + .long 1222472308 + .long 1073691337 + .long 1533953344 + .long 1073696886 + .long 2038973688 + .long 1073702450 + .long 2912730644 + .long 1073708029 + .long 35929225 + .long 1073713624 + .long 2174652632 + .long 1073719233 + .long 915592468 + .long 1073724858 + .long 730821105 + .long 1073730498 + .long 1797923801 + .long 1073736153 + .long 4286760334 + .long 1053736893 + .long 4277826245 + .long 1063661122 + .long 158966641 + .long 1082823503 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,2088 + .data + .section .note.GNU-stack, "" +# End + + .globl pow10f + .equ pow10f, exp10f + diff --git a/external/sgx_libm/ia32/exp10l.S b/external/sgx_libm/ia32/exp10l.S new file mode 100644 index 0000000000..d351269cc8 --- /dev/null +++ b/external/sgx_libm/ia32/exp10l.S @@ -0,0 +1,1162 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp10l.c" + .text +..TXTST0: +# -- Begin exp10l + .text + .align 16,0x90 + .globl exp10l +exp10l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp +..B1.2: + fnstcw 74(%esp) +..B1.3: + movzbl 17(%ebp), %edx + movl %edx, %ecx + movzwl 16(%ebp), %ebx + movl %ebx, %esi + shrl $7, %ecx + andl $32767, %esi + shll $15, %ecx + orl %esi, %ecx + shll $16, %ecx + movzwl 14(%ebp), %eax + orl %eax, %ecx + addl $-1073709056, %ecx + cmpl $284672, %ecx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + ja ..B1.6 +..B1.4: + fldt 8(%ebp) + fld %st(0) + fldl _TWO_23H@GOTOFF(%ecx) + fadd %st, %st(1) + fxch %st(1) + fstps 68(%esp) + flds 68(%esp) + fsubp %st, %st(1) + fucompp + fnstsw %ax + sahf + jp ..B1.5 + je ..B1.85 +..B1.5: + movl %ebx, %esi + andl $32767, %esi +..B1.6: + cmpl $16388, %esi + jge ..B1.45 +..B1.7: + movzwl 74(%esp), %eax + cmpl $16375, %esi + jge ..B1.38 +..B1.8: + cmpl $16368, %esi + jge ..B1.31 +..B1.9: + cmpl $16357, %esi + jge ..B1.24 +..B1.10: + cmpl $16316, %esi + jge ..B1.17 +..B1.11: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.74 +..B1.12: + orl $-64768, %eax + movw %ax, 72(%esp) +..B1.13: + fldcw 72(%esp) +..B1.14: + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + fldt 8(%ebp) + faddp %st, %st(1) + fstpt (%esp) +..B1.15: + fldcw 74(%esp) +..B1.16: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.75 +..B1.18: + orl $-64768, %eax + movw %ax, 72(%esp) +..B1.19: + fldcw 72(%esp) +..B1.20: + movl $1, %eax +..B1.21: + fldt 8(%ebp) + testl %eax, %eax + fldt 12+_Q2@GOTOFF(%ecx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.23 +..B1.22: + fldcw 74(%esp) +..B1.23: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.24: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.76 +..B1.25: + orl $-64768, %eax + movw %ax, 72(%esp) +..B1.26: + fldcw 72(%esp) +..B1.27: + movl $1, %eax +..B1.28: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%ecx) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%ecx) + fmul %st(2), %st + fldt 12+_Q1@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.30 +..B1.29: + fldcw 74(%esp) +..B1.30: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.77 +..B1.32: + orl $-64768, %eax + movw %ax, 72(%esp) +..B1.33: + fldcw 72(%esp) +..B1.34: + movl $1, %eax +..B1.35: + fldl _TWO_48H@GOTOFF(%ecx) + testl %eax, %eax + fldt 8(%ebp) + fld %st(0) + fmul %st(1), %st + fld %st(1) + fadd %st(3), %st + fsub %st, %st(3) + fld %st(2) + fsub %st(4), %st + fldt 84+_Q0@GOTOFF(%ecx) + fmul %st(3), %st + fldt 72+_Q0@GOTOFF(%ecx) + fmul %st(4), %st + fldt 60+_Q0@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 48+_Q0@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 36+_Q0@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 24+_Q0@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 12+_Q0@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fldt _Q0@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 96+_Q0@GOTOFF(%ecx) + fmul %st, %st(4) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + je ..B1.91 +..B1.36: + fstpt 24(%esp) +..B1.88: + fldcw 74(%esp) + jmp ..B1.37 +..B1.91: + fstp %st(0) +..B1.37: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.78 +..B1.39: + orl $-64768, %eax + movw %ax, 72(%esp) +..B1.40: + fldcw 72(%esp) +..B1.41: + movl $1, %ebx +..B1.42: + fldl _TWO_63H@GOTOFF(%ecx) + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st(1), %st + fadd %st(2), %st + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmul %st(2), %st + movl 24(%esp), %eax + fsubrp %st, %st(1) + fld %st(0) + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + fmulp %st, %st(3) + movsbl %al, %edx + fsub %st(2), %st + fldl _TWO_48H@GOTOFF(%ecx) + subl %edx, %eax + shll $4, %edx + fadd %st, %st(1) + shrl $8, %eax + fsubr %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + shll $23, %eax + fxch %st(4) + fsubrp %st, %st(3) + addl $1065353216, %eax + fadd %st(2), %st + fld %st(0) + testl %ebx, %ebx + fmul %st(1), %st + fldt 60+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%ecx) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%ecx) + movl %eax, 36(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 72+_P@GOTOFF(%ecx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(3) + fldl 2056+__libm_expl_table_256@GOTOFF(%ecx,%edx) + fldl 2048+__libm_expl_table_256@GOTOFF(%ecx,%edx) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(5), %st + fmul %st(2), %st + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(3) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmuls 36(%esp) + fstpt (%esp) + je ..B1.92 +..B1.43: + fstpt 24(%esp) +..B1.89: + fldcw 74(%esp) + jmp ..B1.44 +..B1.92: + fstp %st(0) +..B1.44: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ebx + movzwl 8+_ranges@GOTOFF(%ebx,%ecx), %eax + andl $32767, %eax + cmpl %eax, %esi + jl ..B1.50 +..B1.46: + jne ..B1.63 +..B1.47: + movl 12(%ebp), %eax + cmpl 4+_ranges@GOTOFF(%ebx,%ecx), %eax + jb ..B1.50 +..B1.48: + jne ..B1.63 +..B1.49: + movl 8(%ebp), %eax + cmpl _ranges@GOTOFF(%ebx,%ecx), %eax + jae ..B1.63 +..B1.50: + movzwl 74(%esp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.79 +..B1.51: + orl $-64768, %esi + movw %si, 72(%esp) +..B1.52: + fldcw 72(%esp) +..B1.53: + movl $1, %esi +..B1.54: + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + fstpt (%esp) + fldl _TWO_63H@GOTOFF(%ecx) + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st(1), %st + movl %ebx, 36(%esp) + fadd %st(2), %st + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmul %st(2), %st + movl 24(%esp), %eax + movl %eax, %ebx + movsbl %al, %edi + addl $4196735, %eax + subl %edi, %ebx + fsubr %st(1), %st + fld %st(0) + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + fmulp %st, %st(4) + shll $4, %edi + fsub %st(3), %st + fldl _TWO_48H@GOTOFF(%ecx) + shrl $8, %ebx + fadd %st, %st(1) + fxch %st(1) + fstpt 40(%esp) + fldt 40(%esp) + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + addl SC2_BIAS@GOTOFF(%ecx,%edx,4), %ebx + fxch %st(4) + fsubrp %st, %st(2) + movl %esi, 52(%esp) + andl $32767, %ebx + movzwl 8+.L_2il0floatpacket.3@GOTOFF(%ecx), %esi + fadd %st(1), %st + fld %st(0) + andl $-32768, %esi + fmul %st(1), %st + orl %ebx, %esi + fldt 60+_P@GOTOFF(%ecx) + cmpl $3070, %eax + fmul %st(1), %st + fldt 48+_P@GOTOFF(%ecx) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%ecx) + movw %si, 8(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ecx) + movl 52(%esp), %esi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%ecx) + movl 36(%esp), %ebx + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 72+_P@GOTOFF(%ecx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(3) + fldl 2048+__libm_expl_table_256@GOTOFF(%ecx,%edi) + fld %st(0) + fmul %st(2), %st + fxch %st(2) + fadd %st(4), %st + fxch %st(1) + fmul %st, %st(4) + faddp %st, %st(4) + fmull 2056+__libm_expl_table_256@GOTOFF(%ecx,%edi) + faddp %st, %st(1) + faddl 2056+__libm_expl_table_256@GOTOFF(%ecx,%edi) + ja ..B1.57 +..B1.55: + fldt _exp10but@GOTOFF(%ecx) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B1.57 +..B1.56: + fstp %st(1) + fldl _TWO_12H@GOTOFF(%ecx) + fld %st(2) + fadd %st(2), %st + fmul %st, %st(1) + fadd %st(1), %st + fstpt 40(%esp) + fldt 40(%esp) + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt _SC2@GOTOFF(%ebx,%ecx) + fldt (%esp) + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 56(%esp) + jmp ..B1.58 +..B1.57: + fstp %st(1) + fldt (%esp) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt _SC2@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt 56(%esp) +..B1.58: + fldt _minnorm@GOTOFF(%ecx) + fldt 56(%esp) + fcompp + fnstsw %ax + sahf + jae ..B1.60 + jp ..B1.60 +..B1.59: + fldt _small_value_80@GOTOFF(%ecx) + fmul %st(0), %st + fstpt 12(%esp) +..B1.60: + testl %esi, %esi + je ..B1.62 +..B1.61: + fldt 40(%esp) + fstpt 24(%esp) +..B1.90: + fldcw 74(%esp) +..B1.62: + fldt 56(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.63: + movzwl 74(%esp), %ebx + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.84 +..B1.64: + orl $-64768, %ebx + movw %bx, 72(%esp) +..B1.65: + fldcw 72(%esp) +..B1.66: + movzwl 16(%ebp), %esi + movl $1, %eax + andl $32767, %esi +..B1.67: + cmpl $32767, %esi + je ..B1.80 +..B1.68: + testl %edx, %edx + je ..B1.70 +..B1.69: + fldt _small_value_80@GOTOFF(%ecx) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.71 +..B1.70: + fldt _large_value_80@GOTOFF(%ecx) + fmul %st(0), %st + fstpt (%esp) +..B1.71: + testl %eax, %eax + je ..B1.73 +..B1.72: + fldcw 74(%esp) +..B1.73: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.74: + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + fldt 8(%ebp) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.16 +..B1.75: + xorl %eax, %eax + jmp ..B1.21 +..B1.76: + xorl %eax, %eax + jmp ..B1.28 +..B1.77: + xorl %eax, %eax + jmp ..B1.35 +..B1.78: + xorl %ebx, %ebx + jmp ..B1.42 +..B1.79: + xorl %esi, %esi + jmp ..B1.54 +..B1.80: + cmpl $-2147483648, 12(%ebp) + jne ..B1.83 +..B1.81: + cmpl $0, 8(%ebp) + jne ..B1.83 +..B1.82: + fldl _inf_zeros@GOTOFF(%ecx,%edx,8) + fstpt (%esp) + jmp ..B1.71 +..B1.83: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.71 +..B1.84: + xorl %eax, %eax + jmp ..B1.67 +..B1.85: + movl 68(%esp), %edx + andl $4194303, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ebx + fldt -12+_exact_values@GOTOFF(%ecx,%ebx) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type exp10l,@function + .size exp10l,.-exp10l + .data +# -- End exp10l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x88,0x1b,0xcd,0x4b,0x78,0x9a,0xd4,0x08,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x85,0x9a,0x20,0x9a,0xf5,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0xc8,0xd4,0x0e,0xee,0x0c,0x01,0x86,0xd0,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .align 4 +_TWO_23H: + .long 0 + .long 1097334784 + .type _TWO_23H,@object + .size _TWO_23H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +SC2_BIAS: + .long 8191 + .long 24575 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_inf_zeros: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zeros,@object + .size _inf_zeros,16 + .align 2 +_Q2: + .word 45097 + .word 43688 + .word 36317 + .word 37725 + .word 16384 + .word 0 + .word 18666 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 44055 + .word 43688 + .word 36317 + .word 37725 + .word 16384 + .word 0 + .word 17466 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .word 8942 + .word 31610 + .word 11407 + .word 33336 + .word 16384 + .word 0 + .word 11423 + .word 35775 + .word 45136 + .word 38379 + .word 16383 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q0: + .word 11092 + .word 42962 + .word 43694 + .word 58436 + .word 49135 + .word 0 + .word 17467 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .word 8985 + .word 61797 + .word 11406 + .word 33336 + .word 16384 + .word 0 + .word 8830 + .word 60614 + .word 45135 + .word 38379 + .word 16383 + .word 0 + .word 62265 + .word 59600 + .word 65512 + .word 35348 + .word 16382 + .word 0 + .word 36045 + .word 15298 + .word 47170 + .word 54262 + .word 16380 + .word 0 + .word 33342 + .word 6003 + .word 33899 + .word 35698 + .word 16379 + .word 0 + .word 20958 + .word 58269 + .word 28628 + .word 41099 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37726 + .word 16384 + .word 0 + .type _Q0,@object + .size _Q0,108 + .align 2 +_P: + .word 405 + .word 44055 + .word 43688 + .word 36317 + .word 16368 + .word 0 + .word 17467 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .word 7929 + .word 61789 + .word 11406 + .word 33336 + .word 16384 + .word 0 + .word 36964 + .word 60605 + .word 45135 + .word 38379 + .word 16383 + .word 0 + .word 55739 + .word 36897 + .word 684 + .word 35349 + .word 16382 + .word 0 + .word 13923 + .word 51509 + .word 48217 + .word 54262 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37725 + .word 16384 + .word 0 + .type _P,@object + .size _P,84 + .align 2 +_ranges: + .word 63385 + .word 64463 + .word 39556 + .word 39456 + .word 16395 + .word 0 + .word 55376 + .word 5815 + .word 21149 + .word 39608 + .word 16395 + .word 0 + .type _ranges,@object + .size _ranges,24 + .align 2 +_exp10but: + .word 6424 + .word 10152 + .word 51584 + .word 39451 + .word 49163 + .word 0 + .type _exp10but,@object + .size _exp10but,12 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .type _SC2,@object + .size _SC2,24 + .align 2 +_minnorm: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _minnorm,@object + .size _minnorm,12 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_exact_values: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40000 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50000 + .word 16399 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62500 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39062 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 8192 + .word 48828 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 10240 + .word 61035 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 63744 + .word 38146 + .word 16416 + .word 0 + .word 0 + .word 0 + .word 46912 + .word 47683 + .word 16419 + .word 0 + .word 0 + .word 0 + .word 42256 + .word 59604 + .word 16422 + .word 0 + .word 0 + .word 0 + .word 59178 + .word 37252 + .word 16426 + .word 0 + .word 0 + .word 32768 + .word 8436 + .word 46566 + .word 16429 + .word 0 + .word 0 + .word 40960 + .word 43313 + .word 58207 + .word 16432 + .word 0 + .word 0 + .word 1024 + .word 51647 + .word 36379 + .word 16436 + .word 0 + .word 0 + .word 50432 + .word 48174 + .word 45474 + .word 16439 + .word 0 + .word 0 + .word 30272 + .word 27450 + .word 56843 + .word 16442 + .word 0 + .word 0 + .word 35304 + .word 8964 + .word 35527 + .word 16446 + .word 0 + .word 0 + .word 44130 + .word 60357 + .word 44408 + .word 16449 + .word 0 + .word 32768 + .word 6010 + .word 9911 + .word 55511 + .word 16452 + .word 0 + .word 36864 + .word 28332 + .word 30770 + .word 34694 + .word 16456 + .word 0 + .word 46080 + .word 2647 + .word 5695 + .word 43368 + .word 16459 + .word 0 + .word 41216 + .word 52461 + .word 7118 + .word 54210 + .word 16462 + .word 0 + .word 33952 + .word 16404 + .word 20833 + .word 33881 + .word 16466 + .word 0 + .word 42440 + .word 36889 + .word 42425 + .word 42351 + .word 16469 + .word 0 + .word 3898 + .word 62496 + .word 36647 + .word 52939 + .word 16472 + .word 0 + .type _exact_values,@object + .size _exact_values,324 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End + + .globl pow10l + .equ pow10l, exp10l + diff --git a/external/sgx_libm/ia32/exp2_wmt.S b/external/sgx_libm/ia32/exp2_wmt.S new file mode 100644 index 0000000000..3d17e6a948 --- /dev/null +++ b/external/sgx_libm/ia32/exp2_wmt.S @@ -0,0 +1,908 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp2_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin exp2 + .text + .align 16,0x90 + .globl exp2 +exp2: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + stmxcsr 16(%esp) + movl 16(%esp), %edx + andl $-24577, %edx + cmpl %edx, 16(%esp) + jne .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + movsd 2112(%ebx), %xmm1 + movsd (%ebx), %xmm2 + paddd %xmm0, %xmm1 + pextrw $3, %xmm0, %ecx + andl $32767, %ecx + movl $16527, %edx + subl %ecx, %edx + subl $15504, %ecx + orl %ecx, %edx + cmpl $-2147483648, %edx + jae .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cvtsd2si %xmm1, %eax + movq %xmm1, %xmm0 + addsd %xmm2, %xmm1 + movapd 2064(%ebx), %xmm6 + subsd %xmm2, %xmm1 + movapd 2080(%ebx), %xmm7 + subsd %xmm1, %xmm0 + movsd 2096(%ebx), %xmm2 + unpcklpd %xmm0, %xmm0 + movapd %xmm0, %xmm1 + movl %eax, %ecx + sarl $7, %ecx + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + andl $2032, %eax + movsd 16(%ebx,%eax), %xmm3 + movsd 24(%ebx,%eax), %xmm4 + addl $1023, %ecx + pinsrw $0, %ecx, %xmm5 + psllq $52, %xmm5 + mulpd %xmm0, %xmm6 + mulpd %xmm0, %xmm0 + orpd %xmm5, %xmm3 + mulsd %xmm1, %xmm2 + addpd %xmm7, %xmm6 + movl $2046, %edx + subl %ecx, %edx + subl $60, %ecx + orl %ecx, %edx + cmpl $-2147483648, %edx + jae .L_2TAG_PACKET_4.0.3 + movapd %xmm3, %xmm7 + mulsd %xmm0, %xmm3 + mulsd %xmm6, %xmm0 + unpckhpd %xmm6, %xmm6 + mulsd %xmm7, %xmm2 + mulsd %xmm5, %xmm4 + addsd %xmm6, %xmm0 + addsd %xmm4, %xmm2 + mulsd %xmm3, %xmm0 + addsd %xmm2, %xmm0 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_5.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_5.0.3: + addsd %xmm7, %xmm0 + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_4.0.3: + xorpd %xmm5, %xmm3 + addl $60, %ecx + movl %ecx, %edx + subl $1023, %ecx + movl %ecx, %eax + sarl $1, %ecx + subl %ecx, %eax + addl $1023, %ecx + addl $1023, %eax + movd %eax, %xmm7 + psllq $52, %xmm7 + movl $1, %eax + subl %edx, %eax + movd %eax, %xmm5 + movsd 2160(%ebx), %xmm1 + psllq %xmm5, %xmm1 + orpd %xmm7, %xmm3 + mulsd %xmm7, %xmm4 + movapd %xmm3, %xmm7 + movd %ecx, %xmm5 + psllq $52, %xmm5 + andpd %xmm3, %xmm1 + mulsd %xmm0, %xmm3 + mulsd %xmm6, %xmm0 + unpckhpd %xmm6, %xmm6 + mulsd %xmm7, %xmm2 + addsd %xmm6, %xmm0 + addsd %xmm4, %xmm2 + subsd %xmm1, %xmm7 + mulsd %xmm3, %xmm0 + addsd %xmm2, %xmm0 + addsd %xmm7, %xmm0 + cmpl $2047, %edx + jge .L_2TAG_PACKET_7.0.3 + mulsd %xmm5, %xmm1 + mulsd %xmm5, %xmm0 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_8.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_8.0.3: + addsd %xmm1, %xmm0 + pextrw $3, %xmm0, %eax + movl $162, %edx + andl $32752, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_9.0.3 + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_7.0.3: + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_10.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_10.0.3: + addsd %xmm1, %xmm0 + mulsd %xmm5, %xmm0 + pextrw $3, %xmm0, %eax + movl $161, %edx + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_9.0.3 + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_0.0.3: + movl 16(%esp), %edx + andl $-24577, %edx + movl %edx, 24(%esp) + ldmxcsr 24(%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_9.0.3: + movsd %xmm0, (%esp) + movsd 128(%esp), %xmm0 + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_11.0.3 +.L_2TAG_PACKET_12.0.3: + cmpl $32752, %ecx + jae .L_2TAG_PACKET_13.0.3 + movl 132(%esp), %ecx + cmpl $-2147483648, %ecx + jae .L_2TAG_PACKET_14.0.3 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_15.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_15.0.3: + movsd 2144(%ebx), %xmm0 + mulsd %xmm0, %xmm0 + movl $161, %edx + jmp .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_14.0.3: + cmpl $-1064253440, %ecx + jbe .L_2TAG_PACKET_3.0.3 + shrl $4, %ecx + subl $201919680, %ecx + shrl $31, %ecx + xorpd %xmm0, %xmm0 + movd %ecx, %xmm0 + movl 16(%esp), %eax + andl $-24577, %eax + cmpl 16(%esp), %eax + je .L_2TAG_PACKET_16.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %eax + andl $24576, %eax + orl %eax, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_16.0.3: + movsd 2152(%ebx), %xmm1 + mulsd %xmm1, %xmm1 + movl $162, %edx + jmp .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_13.0.3: + movl 128(%esp), %edx + movl 132(%esp), %eax + movl $2147483647, %ecx + andl %eax, %ecx + cmpl $2146435072, %ecx + ja .L_2TAG_PACKET_17.0.3 + cmpl $0, %edx + jne .L_2TAG_PACKET_17.0.3 + cmpl $2146435072, %eax + jne .L_2TAG_PACKET_18.0.3 + movsd 2128(%ebx), %xmm0 + jmp .L_2TAG_PACKET_19.0.3 +.L_2TAG_PACKET_18.0.3: + movsd 2136(%ebx), %xmm0 + jmp .L_2TAG_PACKET_19.0.3 +.L_2TAG_PACKET_17.0.3: + movsd 128(%esp), %xmm0 + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_19.0.3 +.L_2TAG_PACKET_2.0.3: + addl $15504, %ecx + cmpl $16527, %ecx + jae .L_2TAG_PACKET_12.0.3 + movsd 128(%esp), %xmm0 + addsd 2120(%ebx), %xmm0 + jmp .L_2TAG_PACKET_19.0.3 +.L_2TAG_PACKET_6.0.3: + movsd %xmm0, 48(%esp) + fldl 48(%esp) + jmp .L_2TAG_PACKET_11.0.3 +.L_2TAG_PACKET_19.0.3: + movsd %xmm0, 48(%esp) + fldl 48(%esp) + movl 16(%esp), %edx + andl $-24577, %edx + cmpl 16(%esp), %edx + je .L_2TAG_PACKET_11.0.3 + stmxcsr 24(%esp) + movl 16(%esp), %edx + andl $24576, %edx + orl %edx, 24(%esp) + ldmxcsr 24(%esp) +.L_2TAG_PACKET_11.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type exp2,@function + .size exp2,.-exp2 + .data +# -- End exp2 + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2851812149 + .long 5693 + .long 2595802551 + .long 1016815913 + .long 1048019041 + .long 11418 + .long 1398474845 + .long 3161559171 + .long 3899555717 + .long 17173 + .long 427280750 + .long 3163595548 + .long 3541402996 + .long 22960 + .long 2759177317 + .long 1015903202 + .long 702412510 + .long 28779 + .long 3803266086 + .long 3163328991 + .long 410360776 + .long 34629 + .long 1269990655 + .long 1013024446 + .long 3402036099 + .long 40510 + .long 405889333 + .long 1016154232 + .long 1828292879 + .long 46424 + .long 1255956746 + .long 1016636974 + .long 728909815 + .long 52370 + .long 383930225 + .long 1016078044 + .long 852742562 + .long 58348 + .long 667253586 + .long 1010842135 + .long 2952712987 + .long 64358 + .long 3293494651 + .long 3161168877 + .long 3490863953 + .long 70401 + .long 960797497 + .long 3163997456 + .long 3228316108 + .long 76477 + .long 3010241991 + .long 3159471380 + .long 2930322912 + .long 82586 + .long 2599499422 + .long 3163762623 + .long 3366293073 + .long 88728 + .long 3119426313 + .long 1015169130 + .long 1014845819 + .long 94904 + .long 3117910645 + .long 3162607681 + .long 948735466 + .long 101113 + .long 3516338027 + .long 3163623459 + .long 3949972341 + .long 107355 + .long 2068408548 + .long 1015962444 + .long 2214878420 + .long 113632 + .long 892270087 + .long 3164164998 + .long 828946858 + .long 119943 + .long 10642492 + .long 1016988014 + .long 586995997 + .long 126288 + .long 41662347 + .long 3163676568 + .long 2288159958 + .long 132667 + .long 2169144468 + .long 1015924597 + .long 2440944790 + .long 139081 + .long 2492769773 + .long 1015196030 + .long 1853186616 + .long 145530 + .long 3066496370 + .long 1016705150 + .long 1337108031 + .long 152014 + .long 3203724452 + .long 1015726421 + .long 1709341917 + .long 158533 + .long 2571168217 + .long 1015201075 + .long 3790955393 + .long 165087 + .long 2352942461 + .long 3164228666 + .long 4112506593 + .long 171677 + .long 2947355221 + .long 1015419624 + .long 3504003472 + .long 178303 + .long 3594001059 + .long 3158379228 + .long 2799960843 + .long 184965 + .long 1423655380 + .long 1016070727 + .long 2839424854 + .long 191663 + .long 1171596163 + .long 1014090255 + .long 171030293 + .long 198398 + .long 3526460132 + .long 1015477354 + .long 4232894513 + .long 205168 + .long 2383938684 + .long 1015717095 + .long 2992903935 + .long 211976 + .long 2218154405 + .long 1016276769 + .long 1603444721 + .long 218821 + .long 1548633640 + .long 3163249902 + .long 926591435 + .long 225703 + .long 3208833761 + .long 3163962090 + .long 1829099622 + .long 232622 + .long 1016661180 + .long 3164509581 + .long 887463927 + .long 239579 + .long 3596744162 + .long 3161842742 + .long 3272845541 + .long 246573 + .long 928852419 + .long 3164536824 + .long 1276261410 + .long 253606 + .long 300981947 + .long 1015732745 + .long 78413852 + .long 260677 + .long 4183226867 + .long 3164065827 + .long 569847338 + .long 267786 + .long 472945272 + .long 3160339305 + .long 3645941911 + .long 274933 + .long 3814685080 + .long 3162621917 + .long 1617004845 + .long 282120 + .long 82804943 + .long 1011391354 + .long 3978100823 + .long 289345 + .long 3513027190 + .long 1016894539 + .long 3049340112 + .long 296610 + .long 3062915824 + .long 1014219171 + .long 4040676318 + .long 303914 + .long 4090609238 + .long 1016712034 + .long 3577096743 + .long 311258 + .long 2951496418 + .long 1014842263 + .long 2583551245 + .long 318642 + .long 3161094195 + .long 1016655067 + .long 1990012071 + .long 326066 + .long 3529070563 + .long 3163861769 + .long 2731501122 + .long 333530 + .long 1774031854 + .long 3163518597 + .long 1453150082 + .long 341035 + .long 498154668 + .long 3162536638 + .long 3395129871 + .long 348580 + .long 4025345434 + .long 3163383964 + .long 917841882 + .long 356167 + .long 18715564 + .long 1016707884 + .long 3566716925 + .long 363794 + .long 1536826855 + .long 1015191009 + .long 3712504873 + .long 371463 + .long 88491948 + .long 1016476236 + .long 2321106615 + .long 379174 + .long 2171176610 + .long 1010584347 + .long 363667784 + .long 386927 + .long 813753949 + .long 1016833785 + .long 3111574537 + .long 394721 + .long 2606161479 + .long 3163808322 + .long 2956612997 + .long 402558 + .long 2118169750 + .long 3163784129 + .long 885834528 + .long 410438 + .long 1973258546 + .long 3163310140 + .long 2186617381 + .long 418360 + .long 2270764083 + .long 3164321289 + .long 3561793907 + .long 426325 + .long 1157054052 + .long 1012938926 + .long 1719614413 + .long 434334 + .long 330458197 + .long 3164331316 + .long 1963711167 + .long 442386 + .long 1744767756 + .long 3161622870 + .long 1013258799 + .long 450482 + .long 1748797610 + .long 3161177658 + .long 4182873220 + .long 458621 + .long 629542646 + .long 3163044879 + .long 3907805044 + .long 466805 + .long 2257091225 + .long 3162598983 + .long 1218806132 + .long 475034 + .long 1818613051 + .long 3163597017 + .long 1447192521 + .long 483307 + .long 1462857171 + .long 3163563097 + .long 1339972927 + .long 491625 + .long 167908908 + .long 1016620728 + .long 1944781191 + .long 499988 + .long 3993278767 + .long 3162772855 + .long 19972402 + .long 508397 + .long 3507899861 + .long 1017057868 + .long 919555682 + .long 516851 + .long 3121969534 + .long 1013996802 + .long 1413356050 + .long 525351 + .long 1651349290 + .long 3163716742 + .long 2571947539 + .long 533897 + .long 3558159063 + .long 3164425245 + .long 1176749997 + .long 542490 + .long 2738998779 + .long 3163084420 + .long 2604962541 + .long 551129 + .long 2614425274 + .long 3164587768 + .long 3649726105 + .long 559815 + .long 4085036346 + .long 1016698050 + .long 1110089947 + .long 568549 + .long 1451641638 + .long 1016523249 + .long 380978316 + .long 577330 + .long 854188970 + .long 3161511262 + .long 2568320822 + .long 586158 + .long 2732824428 + .long 1015401491 + .long 194117574 + .long 595035 + .long 777528611 + .long 3164460665 + .long 2966275557 + .long 603959 + .long 2176155323 + .long 3160891335 + .long 3418903055 + .long 612932 + .long 2527457337 + .long 3161869180 + .long 2682146384 + .long 621954 + .long 2082178512 + .long 3164411995 + .long 1892288442 + .long 631025 + .long 2446255666 + .long 3163648957 + .long 2191782032 + .long 640145 + .long 2960257726 + .long 1014791238 + .long 434316067 + .long 649315 + .long 2028358766 + .long 1014506698 + .long 2069751141 + .long 658534 + .long 1562170674 + .long 3163773257 + .long 3964284211 + .long 667803 + .long 2111583915 + .long 1016475740 + .long 2990417245 + .long 677123 + .long 3683467745 + .long 3164417902 + .long 321958744 + .long 686494 + .long 3401933766 + .long 1016843134 + .long 1434058175 + .long 695915 + .long 251133233 + .long 1016134345 + .long 3218338682 + .long 705387 + .long 3404164304 + .long 3163525684 + .long 2572866477 + .long 714911 + .long 878562433 + .long 1016570317 + .long 697153126 + .long 724487 + .long 1283515428 + .long 3164331765 + .long 3092190715 + .long 734114 + .long 814012167 + .long 3160571998 + .long 2380618042 + .long 743794 + .long 3149557219 + .long 3164369375 + .long 4076559943 + .long 753526 + .long 2119478330 + .long 3161806927 + .long 815859274 + .long 763312 + .long 240396590 + .long 3164536019 + .long 2420883922 + .long 773150 + .long 2049810052 + .long 1015168464 + .long 1540824585 + .long 783042 + .long 1064017010 + .long 3164536266 + .long 3716502172 + .long 792987 + .long 2303740125 + .long 1015091301 + .long 1610600570 + .long 802987 + .long 3766732298 + .long 1016808759 + .long 777507147 + .long 813041 + .long 4282924204 + .long 1016236109 + .long 2483480501 + .long 823149 + .long 1216371780 + .long 1014082748 + .long 3706687593 + .long 833312 + .long 3521726939 + .long 1014301643 + .long 1432208378 + .long 843531 + .long 1401068914 + .long 3163412539 + .long 1242007932 + .long 853805 + .long 1132034716 + .long 3164388407 + .long 135105010 + .long 864135 + .long 1906148727 + .long 3164424315 + .long 3707479175 + .long 874520 + .long 3613079302 + .long 1015213314 + .long 382305176 + .long 884963 + .long 2347622376 + .long 3163627201 + .long 64696965 + .long 895462 + .long 1768797490 + .long 1016865536 + .long 4076975200 + .long 906017 + .long 2029000898 + .long 1016257111 + .long 863738719 + .long 916631 + .long 1326992219 + .long 3163661773 + .long 351641897 + .long 927302 + .long 2172261526 + .long 3164059175 + .long 3884662774 + .long 938030 + .long 2158611599 + .long 1015258761 + .long 4224142467 + .long 948817 + .long 3389820385 + .long 1016255778 + .long 2728693978 + .long 959663 + .long 396109971 + .long 3164511267 + .long 764307441 + .long 970568 + .long 3021057420 + .long 3164378099 + .long 3999357479 + .long 981531 + .long 2258941616 + .long 1016973300 + .long 929806999 + .long 992555 + .long 3205336643 + .long 1016308133 + .long 1533953344 + .long 1003638 + .long 769171850 + .long 1016714209 + .long 2912730644 + .long 1014781 + .long 3490067721 + .long 3164453650 + .long 2174652632 + .long 1025985 + .long 4087714590 + .long 1015498835 + .long 730821105 + .long 1037250 + .long 2523232743 + .long 1013115764 + .long 3884607281 + .long 1025890431 + .long 3607404735 + .long 1046244104 + .long 1874480759 + .long 1036235435 + .long 4286760334 + .long 1055834045 + .long 4277811695 + .long 1064709698 + .long 0 + .long 0 + .long 0 + .long 7340032 + .long 0 + .long 1072693248 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 4294967295 + .long 2146435071 + .long 0 + .long 508559360 + .long 4294967295 + .long 4294967295 + .type static_const_table,@object + .size static_const_table,2168 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/exp2f_wmt.S b/external/sgx_libm/ia32/exp2f_wmt.S new file mode 100644 index 0000000000..acfe909d67 --- /dev/null +++ b/external/sgx_libm/ia32/exp2f_wmt.S @@ -0,0 +1,754 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp2f_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin exp2f + .text + .align 16,0x90 + .globl exp2f +exp2f: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %ecx + xorpd %xmm7, %xmm7 + movl $17080, %eax + pinsrw $3, %eax, %xmm7 + cvtps2pd %xmm0, %xmm3 + andl $2147483647, %ecx + subl $830472192, %ecx + cmpl $293339136, %ecx + jae .L_2TAG_PACKET_0.0.3 + movsd 2048(%ebx), %xmm6 + movapd %xmm7, %xmm2 + addsd %xmm3, %xmm7 + xorpd %xmm1, %xmm1 + movsd 2056(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + addl $830472192, %ecx + cmpl $830472192, %ecx + jb .L_2TAG_PACKET_2.0.3 + cmpl $1126170624, %ecx + jae .L_2TAG_PACKET_3.0.3 + movsd 2048(%ebx), %xmm6 + movapd %xmm7, %xmm2 + addsd %xmm3, %xmm7 + xorpd %xmm1, %xmm1 + movsd 2056(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movd %xmm0, %eax + cmpl $8388608, %eax + jb .L_2TAG_PACKET_4.0.3 + cmpl $2139095040, %eax + je .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movd %xmm0, %edx + cmpl $2139095040, %ecx + jae .L_2TAG_PACKET_6.0.3 + testl $-2147483648, %edx + je .L_2TAG_PACKET_5.0.3 + movl $8388608, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_4.0.3: + movl $164, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_5.0.3: + movl $2130706432, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 + movl $163, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_2.0.3: + movl $1065353216, %eax + movd %eax, %xmm1 + addss %xmm1, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_6.0.3: + cmpl $-8388608, %edx + je .L_2TAG_PACKET_9.0.3 + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_9.0.3: + fldz + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_1.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type exp2f,@function + .size exp2f,.-exp2f + .data +# -- End exp2f + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 4200250559 + .long 1072696090 + .long 2851812149 + .long 1072698941 + .long 339411585 + .long 1072701800 + .long 1048019041 + .long 1072704666 + .long 772914124 + .long 1072707540 + .long 3899555717 + .long 1072710421 + .long 1928746161 + .long 1072713311 + .long 3541402996 + .long 1072716208 + .long 238821257 + .long 1072719114 + .long 702412510 + .long 1072722027 + .long 728934454 + .long 1072724948 + .long 410360776 + .long 1072727877 + .long 4133881824 + .long 1072730813 + .long 3402036099 + .long 1072733758 + .long 2602514713 + .long 1072736711 + .long 1828292879 + .long 1072739672 + .long 1172597893 + .long 1072742641 + .long 728909815 + .long 1072745618 + .long 590962156 + .long 1072748603 + .long 852742562 + .long 1072751596 + .long 1608493509 + .long 1072754597 + .long 2952712987 + .long 1072757606 + .long 685187902 + .long 1072760624 + .long 3490863953 + .long 1072763649 + .long 2875075254 + .long 1072766683 + .long 3228316108 + .long 1072769725 + .long 351405227 + .long 1072772776 + .long 2930322912 + .long 1072775834 + .long 2471440686 + .long 1072778901 + .long 3366293073 + .long 1072781976 + .long 1416741826 + .long 1072785060 + .long 1014845819 + .long 1072788152 + .long 2257959872 + .long 1072791252 + .long 948735466 + .long 1072794361 + .long 1480023343 + .long 1072797478 + .long 3949972341 + .long 1072800603 + .long 4162030108 + .long 1072803737 + .long 2214878420 + .long 1072806880 + .long 2502433899 + .long 1072810031 + .long 828946858 + .long 1072813191 + .long 1588871207 + .long 1072816359 + .long 586995997 + .long 1072819536 + .long 2218315341 + .long 1072822721 + .long 2288159958 + .long 1072825915 + .long 897099801 + .long 1072829118 + .long 2440944790 + .long 1072832329 + .long 2725843665 + .long 1072835549 + .long 1853186616 + .long 1072838778 + .long 4219606026 + .long 1072842015 + .long 1337108031 + .long 1072845262 + .long 1897844341 + .long 1072848517 + .long 1709341917 + .long 1072851781 + .long 874372905 + .long 1072855054 + .long 3790955393 + .long 1072858335 + .long 1972484976 + .long 1072861626 + .long 4112506593 + .long 1072864925 + .long 1724976915 + .long 1072868234 + .long 3504003472 + .long 1072871551 + .long 964107055 + .long 1072874878 + .long 2799960843 + .long 1072878213 + .long 526652809 + .long 1072881558 + .long 2839424854 + .long 1072884911 + .long 1253935211 + .long 1072888274 + .long 171030293 + .long 1072891646 + .long 3991843581 + .long 1072895026 + .long 4232894513 + .long 1072898416 + .long 1000925746 + .long 1072901816 + .long 2992903935 + .long 1072905224 + .long 1726216749 + .long 1072908642 + .long 1603444721 + .long 1072912069 + .long 2732492859 + .long 1072915505 + .long 926591435 + .long 1072918951 + .long 589198666 + .long 1072922406 + .long 1829099622 + .long 1072925870 + .long 460407023 + .long 1072929344 + .long 887463927 + .long 1072932827 + .long 3219942644 + .long 1072936319 + .long 3272845541 + .long 1072939821 + .long 1156440435 + .long 1072943333 + .long 1276261410 + .long 1072946854 + .long 3743175029 + .long 1072950384 + .long 78413852 + .long 1072953925 + .long 3278348324 + .long 1072957474 + .long 569847338 + .long 1072961034 + .long 654919306 + .long 1072964603 + .long 3645941911 + .long 1072968181 + .long 1065662932 + .long 1072971770 + .long 1617004845 + .long 1072975368 + .long 1118294578 + .long 1072978976 + .long 3978100823 + .long 1072982593 + .long 1720398391 + .long 1072986221 + .long 3049340112 + .long 1072989858 + .long 3784486610 + .long 1072993505 + .long 4040676318 + .long 1072997162 + .long 3933059031 + .long 1073000829 + .long 3577096743 + .long 1073004506 + .long 3088564500 + .long 1073008193 + .long 2583551245 + .long 1073011890 + .long 2178460671 + .long 1073015597 + .long 1990012071 + .long 1073019314 + .long 2135241198 + .long 1073023041 + .long 2731501122 + .long 1073026778 + .long 3896463087 + .long 1073030525 + .long 1453150082 + .long 1073034283 + .long 4109806887 + .long 1073038050 + .long 3395129871 + .long 1073041828 + .long 3723038930 + .long 1073045616 + .long 917841882 + .long 1073049415 + .long 3689071823 + .long 1073053223 + .long 3566716925 + .long 1073057042 + .long 671025100 + .long 1073060872 + .long 3712504873 + .long 1073064711 + .long 4222122499 + .long 1073068561 + .long 2321106615 + .long 1073072422 + .long 2425981843 + .long 1073076293 + .long 363667784 + .long 1073080175 + .long 551349105 + .long 1073084067 + .long 3111574537 + .long 1073087969 + .long 3872257780 + .long 1073091882 + .long 2956612997 + .long 1073095806 + .long 488188413 + .long 1073099741 + .long 885834528 + .long 1073103686 + .long 4273770423 + .long 1073107641 + .long 2186617381 + .long 1073111608 + .long 3339203574 + .long 1073115585 + .long 3561793907 + .long 1073119573 + .long 2979960120 + .long 1073123572 + .long 1719614413 + .long 1073127582 + .long 4201977662 + .long 1073131602 + .long 1963711167 + .long 1073135634 + .long 3721688645 + .long 1073139676 + .long 1013258799 + .long 1073143730 + .long 2555984613 + .long 1073147794 + .long 4182873220 + .long 1073151869 + .long 1727278727 + .long 1073155956 + .long 3907805044 + .long 1073160053 + .long 2263535754 + .long 1073164162 + .long 1218806132 + .long 1073168282 + .long 903334909 + .long 1073172413 + .long 1447192521 + .long 1073176555 + .long 2980802057 + .long 1073180708 + .long 1339972927 + .long 1073184873 + .long 950803702 + .long 1073189049 + .long 1944781191 + .long 1073193236 + .long 158781403 + .long 1073197435 + .long 19972402 + .long 1073201645 + .long 1660913392 + .long 1073205866 + .long 919555682 + .long 1073210099 + .long 2224145553 + .long 1073214343 + .long 1413356050 + .long 1073218599 + .long 2916157145 + .long 1073222866 + .long 2571947539 + .long 1073227145 + .long 515457527 + .long 1073231436 + .long 1176749997 + .long 1073235738 + .long 396319521 + .long 1073240052 + .long 2604962541 + .long 1073244377 + .long 3643909174 + .long 1073248714 + .long 3649726105 + .long 1073253063 + .long 2759350287 + .long 1073257424 + .long 1110089947 + .long 1073261797 + .long 3134592888 + .long 1073266181 + .long 380978316 + .long 1073270578 + .long 1577608921 + .long 1073274986 + .long 2568320822 + .long 1073279406 + .long 3492293770 + .long 1073283838 + .long 194117574 + .long 1073288283 + .long 1403662306 + .long 1073292739 + .long 2966275557 + .long 1073297207 + .long 727685349 + .long 1073301688 + .long 3418903055 + .long 1073306180 + .long 2591453363 + .long 1073310685 + .long 2682146384 + .long 1073315202 + .long 3833209506 + .long 1073319731 + .long 1892288442 + .long 1073324273 + .long 1297350157 + .long 1073328827 + .long 2191782032 + .long 1073333393 + .long 424392917 + .long 1073337972 + .long 434316067 + .long 1073342563 + .long 2366108318 + .long 1073347166 + .long 2069751141 + .long 1073351782 + .long 3985553595 + .long 1073356410 + .long 3964284211 + .long 1073361051 + .long 2152073944 + .long 1073365705 + .long 2990417245 + .long 1073370371 + .long 2331271250 + .long 1073375050 + .long 321958744 + .long 1073379742 + .long 1405169241 + .long 1073384446 + .long 1434058175 + .long 1073389163 + .long 557149882 + .long 1073393893 + .long 3218338682 + .long 1073398635 + .long 977020788 + .long 1073403391 + .long 2572866477 + .long 1073408159 + .long 3861050111 + .long 1073412940 + .long 697153126 + .long 1073417735 + .long 1822067026 + .long 1073422542 + .long 3092190715 + .long 1073427362 + .long 364333489 + .long 1073432196 + .long 2380618042 + .long 1073437042 + .long 703710506 + .long 1073441902 + .long 4076559943 + .long 1073446774 + .long 4062661092 + .long 1073451660 + .long 815859274 + .long 1073456560 + .long 3080351519 + .long 1073461472 + .long 2420883922 + .long 1073466398 + .long 3287523847 + .long 1073471337 + .long 1540824585 + .long 1073476290 + .long 1631695677 + .long 1073481256 + .long 3716502172 + .long 1073486235 + .long 3657065772 + .long 1073491228 + .long 1610600570 + .long 1073496235 + .long 2029714210 + .long 1073501255 + .long 777507147 + .long 1073506289 + .long 2307442995 + .long 1073511336 + .long 2483480501 + .long 1073516397 + .long 1464976603 + .long 1073521472 + .long 3706687593 + .long 1073526560 + .long 778901109 + .long 1073531663 + .long 1432208378 + .long 1073536779 + .long 1532734324 + .long 1073541909 + .long 1242007932 + .long 1073547053 + .long 721996136 + .long 1073552211 + .long 135105010 + .long 1073557383 + .long 3939148246 + .long 1073562568 + .long 3707479175 + .long 1073567768 + .long 3898795731 + .long 1073572982 + .long 382305176 + .long 1073578211 + .long 1912561781 + .long 1073583453 + .long 64696965 + .long 1073588710 + .long 3594158869 + .long 1073593980 + .long 4076975200 + .long 1073599265 + .long 1679558232 + .long 1073604565 + .long 863738719 + .long 1073609879 + .long 1796832535 + .long 1073615207 + .long 351641897 + .long 1073620550 + .long 991358482 + .long 1073625907 + .long 3884662774 + .long 1073631278 + .long 610758006 + .long 1073636665 + .long 4224142467 + .long 1073642065 + .long 2009970496 + .long 1073647481 + .long 2728693978 + .long 1073652911 + .long 2256325230 + .long 1073658356 + .long 764307441 + .long 1073663816 + .long 2719515920 + .long 1073669290 + .long 3999357479 + .long 1073674779 + .long 481706282 + .long 1073680284 + .long 929806999 + .long 1073685803 + .long 1222472308 + .long 1073691337 + .long 1533953344 + .long 1073696886 + .long 2038973688 + .long 1073702450 + .long 2912730644 + .long 1073708029 + .long 35929225 + .long 1073713624 + .long 2174652632 + .long 1073719233 + .long 915592468 + .long 1073724858 + .long 730821105 + .long 1073730498 + .long 1797923801 + .long 1073736153 + .long 4286760334 + .long 1070514109 + .long 4277826245 + .long 1072049730 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,2080 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/exp2l.S b/external/sgx_libm/ia32/exp2l.S new file mode 100644 index 0000000000..7318adec21 --- /dev/null +++ b/external/sgx_libm/ia32/exp2l.S @@ -0,0 +1,1010 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp2l.c" + .text +..TXTST0: +# -- Begin exp2l + .text + .align 16,0x90 + .globl exp2l +exp2l: +# parameter 1: 80 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + subl $64, %esp +..B1.2: + fnstcw 54(%esp) +..B1.3: + movzwl 88(%esp), %ebx + movl %ebx, %eax + andl $32767, %eax + lea -16383(%eax), %edx + cmpl $15, %edx + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + jae ..B1.10 +..B1.4: + movl %eax, %ecx + movl $-1, %esi + negl %ecx + addl $30, %ecx + shll %cl, %esi + notl %esi + andl 84(%esp), %esi + orl 80(%esp), %esi + jne ..B1.10 +..B1.5: + fldt 80(%esp) + faddl _TWO_23H@GOTOFF(%edx) + fstps 48(%esp) + movl 48(%esp), %ecx + shll $10, %ecx + sarl $10, %ecx + lea 16445(%ecx), %eax + cmpl $32828, %eax + ja ..B1.9 +..B1.6: + movl %ecx, %edx + andb $127, 21(%esp) + addl $16383, %edx + jle ..B1.77 +..B1.7: + movzwl 20(%esp), %eax + andl $32767, %edx + andl $-32768, %eax + orl %edx, %eax + movw %ax, 20(%esp) + movl $-2147483648, 16(%esp) + movl $0, 12(%esp) +..B1.8: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.9: + movl %ebx, %eax + andl $32767, %eax +..B1.10: + cmpl $16389, %eax + jge ..B1.49 +..B1.11: + movzwl 54(%esp), %ecx + cmpl $16377, %eax + jge ..B1.42 +..B1.12: + cmpl $16369, %eax + jge ..B1.35 +..B1.13: + cmpl $16359, %eax + jge ..B1.28 +..B1.14: + cmpl $16316, %eax + jge ..B1.21 +..B1.15: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.80 +..B1.16: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.17: + fldcw 52(%esp) +..B1.18: + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fldt 80(%esp) + faddp %st, %st(1) + fstpt 12(%esp) +..B1.19: + fldcw 54(%esp) +..B1.20: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.21: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.81 +..B1.22: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.23: + fldcw 52(%esp) +..B1.24: + movl $1, %eax +..B1.25: + fldt 80(%esp) + testl %eax, %eax + fldt 12+_Q2@GOTOFF(%edx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + faddp %st, %st(1) + fstpt 12(%esp) + je ..B1.27 +..B1.26: + fldcw 54(%esp) +..B1.27: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.28: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.82 +..B1.29: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.30: + fldcw 52(%esp) +..B1.31: + movl $1, %eax +..B1.32: + fldt 80(%esp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%edx) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%edx) + fmul %st(2), %st + fldt 12+_Q1@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + faddp %st, %st(1) + fstpt 12(%esp) + je ..B1.34 +..B1.33: + fldcw 54(%esp) +..B1.34: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.35: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.83 +..B1.36: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.37: + fldcw 52(%esp) +..B1.38: + movl $1, %eax +..B1.39: + fldl _TWO_48H@GOTOFF(%edx) + testl %eax, %eax + fldt 80(%esp) + fld %st(0) + fmul %st(1), %st + fld %st(1) + fadd %st(3), %st + fsub %st, %st(3) + fld %st(2) + fsub %st(4), %st + fldt 84+_Q0@GOTOFF(%edx) + fmul %st(3), %st + fldt 72+_Q0@GOTOFF(%edx) + fmul %st(4), %st + fldt 60+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 48+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 36+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 24+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 12+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fldt _Q0@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 96+_Q0@GOTOFF(%edx) + fmul %st, %st(4) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + je ..B1.100 +..B1.40: + fstpt 24(%esp) +..B1.96: + fldcw 54(%esp) + jmp ..B1.41 +..B1.100: + fstp %st(0) +..B1.41: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.42: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.84 +..B1.43: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.44: + fldcw 52(%esp) +..B1.45: + movl $1, %ebx +..B1.46: + fldl _TWO_63H@GOTOFF(%edx) + fldt 80(%esp) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(1), %st + fadd %st(2), %st + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmulp %st, %st(2) + movl 24(%esp), %eax + fsubp %st, %st(1) + fldl _TWO_48H@GOTOFF(%edx) + fld %st(0) + movsbl %al, %ecx + fadd %st(2), %st + subl %ecx, %eax + fsub %st, %st(1) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + shll $4, %ecx + fxch %st(2) + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fldt 60+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%edx) + shrl $8, %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + shll $23, %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + addl $1065353216, %eax + fldt 12+_P@GOTOFF(%edx) + testl %ebx, %ebx + movl %eax, 36(%esp) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fldt _P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 72+_P@GOTOFF(%edx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(2) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%ecx) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%ecx) + fld %st(0) + fmul %st(5), %st + fxch %st(4) + fadd %st, %st(5) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fmul %st(3), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmuls 36(%esp) + fstpt 12(%esp) + je ..B1.101 +..B1.47: + fstpt 24(%esp) +..B1.97: + fldcw 54(%esp) + jmp ..B1.48 +..B1.101: + fstp %st(0) +..B1.48: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.49: + movzbl 89(%esp), %ebx + andl $128, %ebx + shrl $7, %ebx + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ecx + movzwl 8+_ranges@GOTOFF(%ecx,%edx), %esi + andl $32767, %esi + cmpl %esi, %eax + jl ..B1.54 +..B1.50: + jne ..B1.66 +..B1.51: + movl 84(%esp), %esi + cmpl 4+_ranges@GOTOFF(%ecx,%edx), %esi + jb ..B1.54 +..B1.52: + jne ..B1.66 +..B1.53: + movl 80(%esp), %esi + cmpl _ranges@GOTOFF(%ecx,%edx), %esi + jae ..B1.66 +..B1.54: + movzwl 54(%esp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.88 +..B1.55: + orl $-64768, %esi + movw %si, 52(%esp) +..B1.56: + fldcw 52(%esp) +..B1.57: + movl $1, %esi +..B1.58: + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fstpt 36(%esp) + fldl _TWO_63H@GOTOFF(%edx) + fldt 80(%esp) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(1), %st + movl %ecx, 12(%esp) + fadd %st(2), %st + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmulp %st, %st(2) + movl 24(%esp), %eax + movl %eax, %ecx + movsbl %al, %edi + addl $4196735, %eax + subl %edi, %ecx + fsubp %st, %st(1) + fldl _TWO_48H@GOTOFF(%edx) + fld %st(0) + shll $4, %edi + fadd %st(2), %st + shrl $8, %ecx + fsub %st, %st(1) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + addl SC2_BIAS@GOTOFF(%edx,%ebx,4), %ecx + fxch %st(2) + fadd %st(3), %st + fld %st(0) + andl $32767, %ecx + fmul %st(1), %st + fldt 60+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%edx) + movl %esi, 16(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + movzwl 8+.L_2il0floatpacket.2@GOTOFF(%edx), %esi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + andl $-32768, %esi + fldt 12+_P@GOTOFF(%edx) + orl %ecx, %esi + movw %si, 44(%esp) + cmpl $3070, %eax + movl 16(%esp), %esi + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fldt _P@GOTOFF(%edx) + movl 12(%esp), %ecx + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 72+_P@GOTOFF(%edx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(2) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%edi) + fld %st(0) + fmul %st(4), %st + fxch %st(3) + fadd %st, %st(4) + fmul %st(1), %st + faddp %st, %st(1) + fxch %st(3) + fmull 2056+__libm_expl_table_256@GOTOFF(%edx,%edi) + faddp %st, %st(2) + fldt 80(%esp) + fxch %st(2) + faddl 2056+__libm_expl_table_256@GOTOFF(%edx,%edi) + ja ..B1.61 +..B1.59: + fldt _exp2but@GOTOFF(%edx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B1.61 +..B1.60: + fstp %st(1) + fstp %st(1) + fldl _TWO_12H@GOTOFF(%edx) + fld %st(2) + fadd %st(2), %st + fmul %st, %st(1) + fadd %st(1), %st + fsub %st, %st(1) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt _SC2@GOTOFF(%ecx,%edx) + fldt 36(%esp) + fmul %st, %st(4) + fxch %st(1) + fmul %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) + jmp ..B1.62 +..B1.61: + fstp %st(2) + fldt 36(%esp) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fldt _SC2@GOTOFF(%ecx,%edx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) +..B1.62: + fldt _minnorm@GOTOFF(%edx) + fcompp + fnstsw %ax + sahf + ja ..B1.85 +..B1.63: + testl %esi, %esi + je ..B1.102 +..B1.64: + fstpt 24(%esp) +..B1.98: + fldcw 54(%esp) + jmp ..B1.65 +..B1.102: + fstp %st(0) +..B1.65: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.66: + movzwl 54(%esp), %esi + movl %esi, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.93 +..B1.67: + orl $-64768, %esi + movw %si, 52(%esp) +..B1.68: + fldcw 52(%esp) +..B1.69: + movzwl 88(%esp), %eax + movl $1, %ecx + andl $32767, %eax +..B1.70: + cmpl $32767, %eax + je ..B1.89 +..B1.71: + testl %ebx, %ebx + je ..B1.73 +..B1.72: + fldt _small_value_80@GOTOFF(%edx) + fmul %st(0), %st + fstpt 12(%esp) + jmp ..B1.74 +..B1.73: + fldt _large_value_80@GOTOFF(%edx) + fmul %st(0), %st + fstpt 12(%esp) +..B1.74: + testl %ecx, %ecx + je ..B1.76 +..B1.75: + fldcw 54(%esp) +..B1.76: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.77: + movzwl 20(%esp), %eax + andl $-32768, %eax + movw %ax, 20(%esp) + cmpl $-31, %edx + jle ..B1.79 +..B1.78: + addl $16413, %ecx + movl $1, %eax + shll %cl, %eax + movl %eax, 16(%esp) + movl $0, 12(%esp) + jmp ..B1.8 +..B1.79: + addl $16413, %ecx + movl $1, %eax + shll %cl, %eax + movl $0, 16(%esp) + movl %eax, 12(%esp) + jmp ..B1.8 +..B1.80: + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fldt 80(%esp) + faddp %st, %st(1) + fstpt 12(%esp) + jmp ..B1.20 +..B1.81: + xorl %eax, %eax + jmp ..B1.25 +..B1.82: + xorl %eax, %eax + jmp ..B1.32 +..B1.83: + xorl %eax, %eax + jmp ..B1.39 +..B1.84: + xorl %ebx, %ebx + jmp ..B1.46 +..B1.85: + fldt _small_value_80@GOTOFF(%edx) + testl %esi, %esi + fmul %st(0), %st + fstpt (%esp) + je ..B1.103 +..B1.86: + fstpt 24(%esp) +..B1.99: + fldcw 54(%esp) + jmp ..B1.87 +..B1.103: + fstp %st(0) +..B1.87: + fldt 12(%esp) + addl $64, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.88: + xorl %esi, %esi + jmp ..B1.58 +..B1.89: + cmpl $-2147483648, 84(%esp) + jne ..B1.92 +..B1.90: + cmpl $0, 80(%esp) + jne ..B1.92 +..B1.91: + fldl _inf_zeros@GOTOFF(%edx,%ebx,8) + fstpt 12(%esp) + jmp ..B1.74 +..B1.92: + fldt 80(%esp) + fstpt 12(%esp) + jmp ..B1.74 +..B1.93: + xorl %ecx, %ecx + jmp ..B1.70 + .align 16,0x90 + .type exp2l,@function + .size exp2l,.-exp2l + .data +# -- End exp2l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf7,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .align 4 +_TWO_23H: + .long 0 + .long 1097334784 + .type _TWO_23H,@object + .size _TWO_23H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +SC2_BIAS: + .long 8191 + .long 24575 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_inf_zeros: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zeros,@object + .size _inf_zeros,16 + .align 2 +_Q2: + .word 32967 + .word 53711 + .word 6135 + .word 45426 + .word 16382 + .word 0 + .word 32541 + .word 5676 + .word 61436 + .word 62973 + .word 16380 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 31148 + .word 53711 + .word 6135 + .word 45426 + .word 16382 + .word 0 + .word 30019 + .word 5676 + .word 61436 + .word 62973 + .word 16380 + .word 0 + .word 64504 + .word 31847 + .word 18104 + .word 58200 + .word 16378 + .word 0 + .word 27878 + .word 3845 + .word 23422 + .word 40341 + .word 16376 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q0: + .word 20226 + .word 52574 + .word 36475 + .word 49086 + .word 16363 + .word 0 + .word 30019 + .word 5676 + .word 61436 + .word 62973 + .word 16380 + .word 0 + .word 64711 + .word 9477 + .word 18104 + .word 58200 + .word 16378 + .word 0 + .word 47522 + .word 53875 + .word 23421 + .word 40341 + .word 16376 + .word 0 + .word 43745 + .word 20212 + .word 65340 + .word 44739 + .word 16373 + .word 0 + .word 65207 + .word 12853 + .word 35196 + .word 41348 + .word 16370 + .word 0 + .word 16083 + .word 62062 + .word 13520 + .word 65510 + .word 16366 + .word 0 + .word 39312 + .word 30281 + .word 14077 + .word 45408 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45426 + .word 16382 + .word 0 + .type _Q0,@object + .size _Q0,108 + .align 2 +_P: + .word 12039 + .word 52575 + .word 36475 + .word 49086 + .word 16363 + .word 0 + .word 30020 + .word 5676 + .word 61436 + .word 62973 + .word 16380 + .word 0 + .word 64966 + .word 9463 + .word 18104 + .word 58200 + .word 16378 + .word 0 + .word 46891 + .word 53866 + .word 23421 + .word 40341 + .word 16376 + .word 0 + .word 12114 + .word 63546 + .word 699 + .word 44740 + .word 16373 + .word 0 + .word 63250 + .word 29232 + .word 35994 + .word 41348 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45426 + .word 16382 + .word 0 + .type _P,@object + .size _P,84 + .align 2 +_ranges: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16397 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 32894 + .word 16397 + .word 0 + .type _ranges,@object + .size _ranges,24 + .align 2 +_exp2but: + .word 0 + .word 0 + .word 0 + .word 65528 + .word 49164 + .word 0 + .type _exp2but,@object + .size _exp2but,12 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .type _SC2,@object + .size _SC2,24 + .align 2 +_minnorm: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _minnorm,@object + .size _minnorm,12 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/exp_table.S b/external/sgx_libm/ia32/exp_table.S new file mode 100644 index 0000000000..4463ad2089 --- /dev/null +++ b/external/sgx_libm/ia32/exp_table.S @@ -0,0 +1,522 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_exp_hi_table_64 + .globl __libm_exp_hi_table_64 +__libm_exp_hi_table_64: + .long 0x667f3c00,0x3fe6a09e + .long 0x3c651a40,0x3fe6dfb2 + .long 0xe8ec5f80,0x3fe71f75 + .long 0x56426800,0x3fe75feb + .long 0x73eb01c0,0x3fe7a114 + .long 0x36cf4e80,0x3fe7e2f3 + .long 0x994cce20,0x3fe82589 + .long 0x9b449300,0x3fe868d9 + .long 0x422aa0e0,0x3fe8ace5 + .long 0x99157740,0x3fe8f1ae + .long 0xb0cdc600,0x3fe93737 + .long 0x9fde4e60,0x3fe97d82 + .long 0x82a3f0a0,0x3fe9c491 + .long 0x7b5de580,0x3fea0c66 + .long 0xb23e2560,0x3fea5503 + .long 0x5579fdc0,0x3fea9e6b + .long 0x995ad3c0,0x3feae89f + .long 0xb84f1600,0x3feb33a2 + .long 0xf2fb5e60,0x3feb7f76 + .long 0x904bc1e0,0x3febcc1e + .long 0xdd8552a0,0x3fec199b + .long 0x2e57d150,0x3fec67f1 + .long 0xdcef9070,0x3fecb720 + .long 0x4a078980,0x3fed072d + .long 0xdcfba490,0x3fed5818 + .long 0x03db3290,0x3feda9e6 + .long 0x337b9b60,0x3fedfc97 + .long 0xe78b3ff8,0x3fee502e + .long 0xa2a490e0,0x3feea4af + .long 0xee615a28,0x3feefa1b + .long 0x5b6e4544,0x3fef5076 + .long 0x819e90da,0x3fefa7c1 + .long 0x00000000,0x3ff00000 + .long 0x3e778060,0x3ff02c9a + .long 0xd3158574,0x3ff059b0 + .long 0x18759bc8,0x3ff08745 + .long 0x6cf9890c,0x3ff0b558 + .long 0x32d3d1a0,0x3ff0e3ec + .long 0xd0125b50,0x3ff11301 + .long 0xaea92dd8,0x3ff1429a + .long 0x3c7d5178,0x3ff172b8 + .long 0xeb6fcb70,0x3ff1a35b + .long 0x3168b9a8,0x3ff1d487 + .long 0x88628cd0,0x3ff2063b + .long 0x6e756230,0x3ff2387a + .long 0x65e27cd0,0x3ff26b45 + .long 0xf51fdee0,0x3ff29e9d + .long 0xa6e40300,0x3ff2d285 + .long 0x0a31b710,0x3ff306fe + .long 0xb26416f0,0x3ff33c08 + .long 0x373aa9c0,0x3ff371a7 + .long 0x34e59ff0,0x3ff3a7db + .long 0x4c123420,0x3ff3dea6 + .long 0x21f72e20,0x3ff4160a + .long 0x60618920,0x3ff44e08 + .long 0xb5c13cc0,0x3ff486a2 + .long 0xd5362a20,0x3ff4bfda + .long 0x769d2ca0,0x3ff4f9b2 + .long 0x569d4f80,0x3ff5342b + .long 0x36b527c0,0x3ff56f47 + .long 0xdd485420,0x3ff5ab07 + .long 0x15ad2140,0x3ff5e76f + .long 0xb03a5580,0x3ff6247e + .long 0x82552220,0x3ff66238 + .long 0x667f3bc0,0x3ff6a09e + .type __libm_exp_hi_table_64,@object + .size __libm_exp_hi_table_64,520 + .space 8, 0x00 # pad + .align 16 + .hidden __libm_exp_mi_table_64 + .globl __libm_exp_mi_table_64 +__libm_exp_mi_table_64: + .long 0x33018800,0xbfd2bec3 + .long 0x8735cb80,0xbfd2409b + .long 0x2e274100,0xbfd1c114 + .long 0x537b3000,0xbfd14029 + .long 0x1829fc80,0xbfd0bdd7 + .long 0x92616300,0xbfd03a19 + .long 0x9accc780,0xbfcf69d9 + .long 0x92edb400,0xbfce5c99 + .long 0xf7557c80,0xbfcd4c6a + .long 0x9baa2300,0xbfcc3945 + .long 0x3cc8e800,0xbfcb2321 + .long 0x8086c680,0xbfca09f5 + .long 0xf5703d80,0xbfc8edb9 + .long 0x12886a00,0xbfc7ce66 + .long 0x37076a80,0xbfc6abf1 + .long 0xaa180900,0xbfc58652 + .long 0x9a94b100,0xbfc45d81 + .long 0x1ec3a800,0xbfc33175 + .long 0x34128680,0xbfc20224 + .long 0xbed0f880,0xbfc0cf85 + .long 0x13d56b00,0xbfbf3321 + .long 0x8d417580,0xbfbcc076 + .long 0x18837c80,0xbfba46f9 + .long 0xafc3b400,0xbfb7c695 + .long 0x1822db80,0xbfb53f39 + .long 0xe1266b80,0xbfb2b0cf + .long 0x64232500,0xbfb01b46 + .long 0x874c0080,0xbfaafd11 + .long 0xd5b6f200,0xbfa5b505 + .long 0x19ea5d80,0xbfa05e41 + .long 0x92375780,0xbf95f134 + .long 0x985bc980,0xbf860f9f + .long 0x00000000,0x00000000 + .long 0x3bc03000,0x3f864d1f + .long 0xc5615d00,0x3f966c34 + .long 0x0eb37900,0x3fa0e8a3 + .long 0x9f312180,0x3fa6ab0d + .long 0x5a7a3400,0x3fac7d86 + .long 0x0125b500,0x3fb1301d + .long 0xea92dd80,0x3fb429aa + .long 0xc7d51780,0x3fb72b83 + .long 0xb6fcb700,0x3fba35be + .long 0x168b9a80,0x3fbd4873 + .long 0x43146680,0x3fc031dc + .long 0x73ab1180,0x3fc1c3d3 + .long 0x2f13e680,0x3fc35a2b + .long 0xa8fef700,0x3fc4f4ef + .long 0x37201800,0x3fc6942d + .long 0x518db880,0x3fc837f0 + .long 0x9320b780,0x3fc9e045 + .long 0xb9d54e00,0x3fcb8d39 + .long 0xa72cff80,0x3fcd3ed9 + .long 0x6091a100,0x3fcef532 + .long 0x87dcb880,0x3fd05828 + .long 0x81862480,0x3fd13821 + .long 0xd704f300,0x3fd21a8a + .long 0x54d8a880,0x3fd2ff6b + .long 0xda74b280,0x3fd3e6c9 + .long 0x5a753e00,0x3fd4d0ad + .long 0xdad49f00,0x3fd5bd1c + .long 0x75215080,0x3fd6ac1f + .long 0x56b48500,0x3fd79dbc + .long 0xc0e95600,0x3fd891fa + .long 0x09548880,0x3fd988e2 + .long 0x99fcef00,0x3fda8279 + .type __libm_exp_mi_table_64,@object + .size __libm_exp_mi_table_64,520 + .space 8, 0x00 # pad + .align 16 + .hidden __libm_exp_lo_table_64 + .globl __libm_exp_lo_table_64 +__libm_exp_lo_table_64: + .long 0x682764c9,0xbcf9b7ba + .long 0x1d341e44,0xbce10ddf + .long 0x1e1a21ea,0xbcd845b9 + .long 0xb2ae62dc,0xbcfba048 + .long 0x77ee0499,0xbcfc9415 + .long 0xfd45ea87,0xbcedefa2 + .long 0xeea0a997,0xbcdaea60 + .long 0xe26f53db,0xbce37f1b + .long 0xea979b4e,0xbcc29160 + .long 0xb17471a2,0xbcd3a8cf + .long 0xe3c0dabf,0xbceb0baf + .long 0x6df06e17,0xbce07461 + .long 0x729f1c1b,0xbcdfc707 + .long 0x25747355,0xbceb4d65 + .long 0xdb71a83c,0xbcbba5ed + .long 0x78840167,0xbc97829b + .long 0xcb2e88ce,0xbce2a178 + .long 0xbc6109ae,0xbcc42500 + .long 0x4f7e54ac,0xbce91558 + .long 0xbe174986,0xbcdbb708 + .long 0xa76afb72,0xbcbeeef9 + .long 0x200b7c35,0xbcc2d77b + .long 0xd0b85ad9,0xbccbabf0 + .long 0x743797aa,0xbcc1cbc3 + .long 0xf4a29324,0xbcd1b44b + .long 0xfcb49256,0xbcd51ee7 + .long 0x53c612d7,0xbca46973 + .long 0xcfeac66e,0xbcad8c2e + .long 0x3179c289,0xbcc9e9c2 + .long 0xbcada4a8,0xbc911c05 + .long 0xda44ebcf,0xbcbcc583 + .long 0x818b4d9c,0xbcad16f5 + .long 0x00000000,0x00000000 + .long 0x95949ef4,0x3cadcdef + .long 0xa475b465,0x3c8d73e2 + .long 0x4bb284ff,0x3c6186be + .long 0xc95b8c21,0x3ccb14c5 + .long 0x1727c57b,0x3cc0103a + .long 0xe35db263,0x3ca49d77 + .long 0x0650ec96,0x3cdecd04 + .long 0xe4628759,0x3cc6e6fb + .long 0x63da4b47,0x3cd4f2da + .long 0xc0144c88,0x3cc3c02d + .long 0xac0a5425,0x3cd8ee3b + .long 0xf5b6382c,0x3ce0cd83 + .long 0xce6503a7,0x3cea4af4 + .long 0x15f5a24b,0x3cb2c25d + .long 0x3aa6da0f,0x3ce68012 + .long 0x56918c17,0x3cd4b7a3 + .long 0x0c21b2cd,0x3cee9939 + .long 0xaa05e8a9,0x3ce54e28 + .long 0x24a67828,0x3cdba86f + .long 0x911f09ec,0x3cc1ada0 + .long 0x4b71e7b7,0x3ce3f086 + .long 0xde813be0,0x3cea0626 + .long 0xa3b69063,0x3cf013c1 + .long 0x5ebfb10c,0x3cdc750e + .long 0x62da6a82,0x3cdab4cf + .long 0x3c49d86a,0x3cbdf0a8 + .long 0xb004764f,0x3cfa66ec + .long 0x602a323d,0x3ce2b192 + .long 0xc9840733,0x3ce0dd37 + .long 0xe81bf4b7,0x3cd2c7c3 + .long 0x678a6e3d,0x3cd2449f + .long 0x5f626cdd,0x3ce92116 + .type __libm_exp_lo_table_64,@object + .size __libm_exp_lo_table_64,520 + .space 8, 0x00 # pad + .align 16 + .hidden __libm_exp_table_128 + .globl __libm_exp_table_128 +__libm_exp_table_128: + .long 0x908b2fb1,0x3def3bcc + .long 0x66600000,0x3fe6a09e + .long 0xdaed5330,0x3dd7b57d + .long 0x75000000,0x3fe6c012 + .long 0xc8838b30,0x3dc468bb + .long 0x3c600000,0x3fe6dfb2 + .long 0xcf87e1b5,0x3de19483 + .long 0xf9400000,0x3fe6ff7d + .long 0xba46e1e6,0x3dd8bee7 + .long 0xe8e00000,0x3fe71f75 + .long 0xf572693a,0x3dc605ce + .long 0x48a00000,0x3fe73f9a + .long 0xfb74d51a,0x3db33e45 + .long 0x56400000,0x3fe75feb + .long 0x619ae028,0x3dee5d3f + .long 0x4fc00000,0x3fe78069 + .long 0xafaa2048,0x3dd6030d + .long 0x73e00000,0x3fe7a114 + .long 0x7c493344,0x3de0c132 + .long 0x01200000,0x3fe7c1ed + .long 0x20ba0574,0x3dde9cc4 + .long 0x36c00000,0x3fe7e2f3 + .long 0xb60de676,0x3dee1a11 + .long 0x54200000,0x3fe80427 + .long 0x159f115f,0x3dd99c25 + .long 0x99400000,0x3fe82589 + .long 0x7297b5cc,0x3dbe3d66 + .long 0x46200000,0x3fe8471a + .long 0x03907643,0x3dc24bb2 + .long 0x9b400000,0x3fe868d9 + .long 0xcca6179c,0x3dd4cd32 + .long 0xd9800000,0x3fe88ac7 + .long 0xb74f8ab4,0x3dd541b6 + .long 0x42200000,0x3fe8ace5 + .long 0xef2aa1cd,0x3de5448b + .long 0x16a00000,0x3fe8cf32 + .long 0x2b982746,0x3de57736 + .long 0x99000000,0x3fe8f1ae + .long 0x88a61b47,0x3de1ffc5 + .long 0x0b800000,0x3fe9145b + .long 0xe8a0387e,0x3ddb8bc9 + .long 0xb0c00000,0x3fe93737 + .long 0xd36906d3,0x3dd0a41d + .long 0xcbc00000,0x3fe95a44 + .long 0x8b9e9210,0x3dee4e4f + .long 0x9fc00000,0x3fe97d82 + .long 0x74621372,0x3dd40f73 + .long 0x70c00000,0x3fe9a0f1 + .long 0xe3e23584,0x3dbf8480 + .long 0x82a00000,0x3fe9c491 + .long 0xc12653c7,0x3db91918 + .long 0x19e00000,0x3fe9e863 + .long 0xb29ada8c,0x3dede564 + .long 0x7b400000,0x3fea0c66 + .long 0xb182e3ef,0x3dd45a66 + .long 0xec400000,0x3fea309b + .long 0x8b424492,0x3dee255c + .long 0xb2200000,0x3fea5503 + .long 0x6f2dfb2b,0x3de0b358 + .long 0x13200000,0x3fea799e + .long 0x43eb243c,0x3de9fdbf + .long 0x55600000,0x3fea9e6b + .long 0xc0db966a,0x3de3f379 + .long 0xbfc00000,0x3feac36b + .long 0x5e8734d1,0x3dead3ad + .long 0x99400000,0x3feae89f + .long 0x2108559c,0x3ddb6ccb + .long 0x29800000,0x3feb0e07 + .long 0xed7fa1cf,0x3dde2bf5 + .long 0xb8400000,0x3feb33a2 + .long 0x38e20444,0x3dc564e6 + .long 0x8de00000,0x3feb5972 + .long 0xeaa7b082,0x3deb5e46 + .long 0xf2e00000,0x3feb7f76 + .long 0x40cb3c6b,0x3da06498 + .long 0x30a00000,0x3feba5b0 + .long 0x48f741e9,0x3dd783a4 + .long 0x90400000,0x3febcc1e + .long 0x8408d702,0x3de71e08 + .long 0x5bc00000,0x3febf2c2 + .long 0x88832c4b,0x3dc54a70 + .long 0xdd800000,0x3fec199b + .long 0x6d14df82,0x3defd07a + .long 0x5fe00000,0x3fec40ab + .long 0x4a2137fd,0x3de7d14b + .long 0x2e400000,0x3fec67f1 + .long 0x46b2f122,0x3dcb9ed4 + .long 0x94000000,0x3fec8f6d + .long 0x2a0797a4,0x3ddf20d2 + .long 0xdce00000,0x3fecb720 + .long 0xc44f8959,0x3dedc3f9 + .long 0x55400000,0x3fecdf0b + .long 0x343c8bc8,0x3dce25ee + .long 0x4a000000,0x3fed072d + .long 0x15bc2473,0x3ddb13e3 + .long 0x08000000,0x3fed2f87 + .long 0x25da05af,0x3deba487 + .long 0xdce00000,0x3fed5818 + .long 0x7709f3a1,0x3dd3072f + .long 0x16c00000,0x3fed80e3 + .long 0x708c01a6,0x3deb3285 + .long 0x03c00000,0x3feda9e6 + .long 0xb695de3c,0x3dab4604 + .long 0xf3000000,0x3fedd321 + .long 0xb968cac4,0x3deb9b5e + .long 0x33600000,0x3fedfc97 + .long 0xa12761fa,0x3de5a128 + .long 0x14e00000,0x3fee2646 + .long 0x4e7a2603,0x3dd67fec + .long 0xe7800000,0x3fee502e + .long 0x2d522ca1,0x3dcd320d + .long 0xfbc00000,0x3fee7a51 + .long 0x163dce86,0x3dc24366 + .long 0xa2a00000,0x3feea4af + .long 0x1b60625f,0x3ddccfe1 + .long 0x2d800000,0x3feecf48 + .long 0x71fd21a9,0x3da5a277 + .long 0xee600000,0x3feefa1b + .long 0x9d0d2df8,0x3dd7752e + .long 0x37600000,0x3fef252b + .long 0xce9f096f,0x3ddc8a80 + .long 0x5b600000,0x3fef5076 + .long 0x8913b4c0,0x3decbe13 + .long 0xad800000,0x3fef7bfd + .long 0x2e90a7e7,0x3dee90d8 + .long 0x81800000,0x3fefa7c1 + .long 0x12eb7496,0x3ddee3e2 + .long 0x2b800000,0x3fefd3c2 + .long 0x00000000,0x00000000 + .long 0x00000000,0x3ff00000 + .long 0x6d84a66b,0x3dfb3335 + .long 0xa9e00000,0x3ff0163d + .long 0xee6f7cad,0x3df78060 + .long 0x3e600000,0x3ff02c9a + .long 0x7ae71f34,0x3decff09 + .long 0xe8600000,0x3ff04315 + .long 0x3ae7c549,0x3df58574 + .long 0xd3000000,0x3ff059b0 + .long 0xc6dc403b,0x3dfdf6dd + .long 0x29c00000,0x3ff0706b + .long 0x08c35f26,0x3df59bc8 + .long 0x18600000,0x3ff08745 + .long 0x14878183,0x3ddbce0d + .long 0xcac00000,0x3ff09e3e + .long 0x6298b92b,0x3df9890f + .long 0x6ce00000,0x3ff0b558 + .long 0x407b705c,0x3df247f7 + .long 0x2b600000,0x3ff0cc92 + .long 0x020742e5,0x3df3d1a2 + .long 0x32c00000,0x3ff0e3ec + .long 0xf232091e,0x3dfed31a + .long 0xafe00000,0x3ff0fb66 + .long 0xa4ebbf1b,0x3df25b50 + .long 0xd0000000,0x3ff11301 + .long 0xf72575a6,0x3de86397 + .long 0xc0600000,0x3ff12abd + .long 0x66820328,0x3de25bbf + .long 0xaea00000,0x3ff1429a + .long 0x920355cf,0x3dd63944 + .long 0xc8a00000,0x3ff15a98 + .long 0xdcdf7c8c,0x3dfd517a + .long 0x3c600000,0x3ff172b8 + .long 0x777ee173,0x3de91bd3 + .long 0x38800000,0x3ff18af9 + .long 0x796d31ed,0x3def96ea + .long 0xeb600000,0x3ff1a35b + .long 0x6ac79cad,0x3dd1734e + .long 0x84000000,0x3ff1bbe0 + .long 0xf00b7005,0x3de17354 + .long 0x31600000,0x3ff1d487 + .long 0xb8819ff6,0x3dfcd91c + .long 0x22e00000,0x3ff1ed50 + .long 0xdc775815,0x3dc466b1 + .long 0x88600000,0x3ff2063b + .long 0x2552fd29,0x3dfddc96 + .long 0x91600000,0x3ff21f49 + .long 0x66c1fadb,0x3df56238 + .long 0x6e600000,0x3ff2387a + .long 0x3582ab7e,0x3df2a63f + .long 0x4fa00000,0x3ff251ce + .long 0x2bd33994,0x3dc3e6e9 + .long 0x65e00000,0x3ff26b45 + .long 0x96cf15cf,0x3df56380 + .long 0xe1e00000,0x3ff284df + .long 0x2c25d15f,0x3dffdee1 + .long 0xf5000000,0x3ff29e9d + .long 0xfddea465,0x3dfad98f + .long 0xd0c00000,0x3ff2b87f + .long 0x0024754e,0x3dd00c2d + .long 0xa6e00000,0x3ff2d285 + .long 0x11ca0f46,0x3dfe2f56 + .long 0xa9200000,0x3ff2ecaf + .long 0x2de8d5a4,0x3df1b715 + .long 0x0a200000,0x3ff306fe + .long 0x6a739e38,0x3de9b062 + .long 0xfc400000,0x3ff32170 + .long 0x32721843,0x3dd05bfd + .long 0xb2600000,0x3ff33c08 + .long 0xc9462347,0x3df29ff0 + .long 0x5f800000,0x3ff356c5 + .long 0xa7145503,0x3dfaa9ca + .long 0x37200000,0x3ff371a7 + .long 0x16a72c36,0x3dd76196 + .long 0x6d000000,0x3ff38cae + .long 0xa86f24a6,0x3dd67fdb + .long 0x34e00000,0x3ff3a7db + .long 0x84001f23,0x3df3a8e4 + .long 0xc3000000,0x3ff3c32d + .long 0x35b41224,0x3df23422 + .long 0x4c000000,0x3ff3dea6 + .long 0x417ee035,0x3de90037 + .long 0x04a00000,0x3ff3fa45 + .long 0xf84325b9,0x3df72e29 + .long 0x21e00000,0x3ff4160a + .long 0xdc704439,0x3df0a896 + .long 0xd9400000,0x3ff431f5 + .long 0x3136f40a,0x3db892d0 + .long 0x60600000,0x3ff44e08 + .long 0x72512f46,0x3dfd0057 + .long 0xed000000,0x3ff46a41 + .long 0x3c1a3b69,0x3db3cd01 + .long 0xb5c00000,0x3ff486a2 + .long 0x672d8bcf,0x3df7d3de + .long 0xf0c00000,0x3ff4a32a + .long 0x1d4397b0,0x3df62a27 + .long 0xd5200000,0x3ff4bfda + .long 0x63b36ef2,0x3dfddd0d + .long 0x99e00000,0x3ff4dcb2 + .long 0xad33d8b7,0x3dfd2ca6 + .long 0x76800000,0x3ff4f9b2 + .long 0x8225ea59,0x3deecc83 + .long 0xa2c00000,0x3ff516da + .long 0xdf0a83c5,0x3dfd4f81 + .long 0x56800000,0x3ff5342b + .long 0xc52ec620,0x3dfd920e + .long 0xca400000,0x3ff551a4 + .long 0x66ecb004,0x3df527da + .long 0x36a00000,0x3ff56f47 + .long 0x252bc2b7,0x3df7c7fd + .long 0xd4800000,0x3ff58d12 + .long 0xb192602a,0x3de0a852 + .long 0xdd400000,0x3ff5ab07 + .long 0x01c4b1b8,0x3df946b7 + .long 0x8a400000,0x3ff5c926 + .long 0xdd37c984,0x3dea4290 + .long 0x15a00000,0x3ff5e76f + .long 0xb076f593,0x3df6dc08 + .long 0xb9600000,0x3ff605e1 + .long 0xb1f0fa07,0x3dfa5584 + .long 0xb0200000,0x3ff6247e + .long 0x8edf0e2a,0x3de9863f + .long 0x34c00000,0x3ff64346 + .long 0x9127d9e3,0x3df52224 + .long 0x82400000,0x3ff66238 + .long 0x1038ae45,0x3de952e6 + .long 0xd4400000,0x3ff68155 + .long 0x908b2fb1,0x3dff3bcc + .long 0x66600000,0x3ff6a09e + .type __libm_exp_table_128,@object + .size __libm_exp_table_128,2064 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/exp_wmt.S b/external/sgx_libm/ia32/exp_wmt.S new file mode 100644 index 0000000000..6b9e3cda83 --- /dev/null +++ b/external/sgx_libm/ia32/exp_wmt.S @@ -0,0 +1,587 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin exp + .text + .align 16,0x90 + .globl exp +exp: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + unpcklpd %xmm0, %xmm0 + movapd 64(%ebx), %xmm1 + movapd 48(%ebx), %xmm6 + movapd 80(%ebx), %xmm2 + movapd 96(%ebx), %xmm3 + pextrw $3, %xmm0, %eax + andl $32767, %eax + movl $16527, %edx + subl %eax, %edx + subl $15504, %eax + orl %eax, %edx + cmpl $-2147483648, %edx + jae .L_2TAG_PACKET_0.0.3 + mulpd %xmm0, %xmm1 + addpd %xmm6, %xmm1 + movapd %xmm1, %xmm7 + subpd %xmm6, %xmm1 + mulpd %xmm1, %xmm2 + movapd 128(%ebx), %xmm4 + mulpd %xmm1, %xmm3 + movapd 144(%ebx), %xmm5 + subpd %xmm2, %xmm0 + movd %xmm7, %eax + movl %eax, %ecx + andl $63, %ecx + shll $4, %ecx + sarl $6, %eax + movl %eax, %edx + movdqa 16(%ebx), %xmm6 + pand %xmm6, %xmm7 + movdqa 32(%ebx), %xmm6 + paddq %xmm6, %xmm7 + psllq $46, %xmm7 + subpd %xmm3, %xmm0 + movapd 160(%ebx,%ecx), %xmm2 + mulpd %xmm0, %xmm4 + movapd %xmm0, %xmm6 + movapd %xmm0, %xmm1 + mulpd %xmm6, %xmm6 + mulpd %xmm6, %xmm0 + addpd %xmm4, %xmm5 + mulsd %xmm6, %xmm0 + mulpd 112(%ebx), %xmm6 + addsd %xmm2, %xmm1 + unpckhpd %xmm2, %xmm2 + mulpd %xmm5, %xmm0 + addsd %xmm0, %xmm1 + orpd %xmm7, %xmm2 + unpckhpd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + addsd %xmm6, %xmm0 + addl $894, %edx + cmpl $1916, %edx + ja .L_2TAG_PACKET_1.0.3 + mulsd %xmm2, %xmm0 + addsd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + fstcw 24(%esp) + movzwl 24(%esp), %edx + orl $768, %edx + movw %dx, 28(%esp) + fldcw 28(%esp) + movl %eax, %edx + sarl $1, %eax + subl %eax, %edx + movdqa (%ebx), %xmm6 + pandn %xmm2, %xmm6 + addl $1023, %eax + movd %eax, %xmm3 + psllq $52, %xmm3 + orpd %xmm3, %xmm6 + addl $1023, %edx + movd %edx, %xmm4 + psllq $52, %xmm4 + movsd %xmm0, 8(%esp) + fldl 8(%esp) + movsd %xmm6, 16(%esp) + fldl 16(%esp) + fmul %st, %st(1) + faddp %st, %st(1) + movsd %xmm4, 8(%esp) + fldl 8(%esp) + fmulp %st, %st(1) + fstpl 8(%esp) + movsd 8(%esp), %xmm0 + fldcw 24(%esp) + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl $32752, %ecx + jae .L_2TAG_PACKET_3.0.3 + cmpl $0, %ecx + je .L_2TAG_PACKET_4.0.3 + jmp .L_2TAG_PACKET_2.0.3 + cmpl $-2147483648, %ecx + jb .L_2TAG_PACKET_3.0.3 + cmpl $-1064950997, %ecx + jb .L_2TAG_PACKET_2.0.3 + ja .L_2TAG_PACKET_4.0.3 + movl 128(%esp), %edx + cmpl $-17155601, %edx + jb .L_2TAG_PACKET_2.0.3 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_3.0.3: + movl $14, %edx + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_4.0.3: + movl $15, %edx +.L_2TAG_PACKET_5.0.3: + movsd %xmm0, (%esp) + movsd 128(%esp), %xmm0 + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_7.0.3: + cmpl $2146435072, %eax + jae .L_2TAG_PACKET_8.0.3 + movl 132(%esp), %eax + cmpl $-2147483648, %eax + jae .L_2TAG_PACKET_9.0.3 + movsd 1208(%ebx), %xmm0 + mulsd %xmm0, %xmm0 + movl $14, %edx + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_9.0.3: + movsd 1216(%ebx), %xmm0 + mulsd %xmm0, %xmm0 + movl $15, %edx + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_8.0.3: + movl 128(%esp), %edx + cmpl $2146435072, %eax + ja .L_2TAG_PACKET_10.0.3 + cmpl $0, %edx + jne .L_2TAG_PACKET_10.0.3 + movl 132(%esp), %eax + cmpl $2146435072, %eax + jne .L_2TAG_PACKET_11.0.3 + movsd 1192(%ebx), %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_11.0.3: + movsd 1200(%ebx), %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_10.0.3: + movsd 128(%esp), %xmm0 + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + movl 132(%esp), %eax + andl $2147483647, %eax + cmpl $1083179008, %eax + jae .L_2TAG_PACKET_7.0.3 + movsd 128(%esp), %xmm0 + addsd 1184(%ebx), %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 48(%esp) + fldl 48(%esp) +.L_2TAG_PACKET_6.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type exp,@function + .size exp,.-exp + .data +# -- End exp + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 4293918720 + .long 0 + .long 4293918720 + .long 4294967232 + .long 0 + .long 4294967232 + .long 0 + .long 65472 + .long 0 + .long 65472 + .long 0 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 1697350398 + .long 1079448903 + .long 1697350398 + .long 1079448903 + .long 4277796864 + .long 1065758274 + .long 4277796864 + .long 1065758274 + .long 3164486458 + .long 1025308570 + .long 3164486458 + .long 1025308570 + .long 4294967294 + .long 1071644671 + .long 4294967294 + .long 1071644671 + .long 3811088480 + .long 1062650204 + .long 1432067621 + .long 1067799893 + .long 3230715663 + .long 1065423125 + .long 1431604129 + .long 1069897045 + .long 0 + .long 0 + .long 0 + .long 0 + .long 235107661 + .long 1018002367 + .long 1048019040 + .long 11418 + .long 896005651 + .long 1015861842 + .long 3541402996 + .long 22960 + .long 1642514529 + .long 1012987726 + .long 410360776 + .long 34629 + .long 1568897900 + .long 1016568486 + .long 1828292879 + .long 46424 + .long 1882168529 + .long 1010744893 + .long 852742562 + .long 58348 + .long 509852888 + .long 1017336174 + .long 3490863952 + .long 70401 + .long 653277307 + .long 1017431380 + .long 2930322911 + .long 82586 + .long 1649557430 + .long 1017729363 + .long 1014845818 + .long 94904 + .long 1058231231 + .long 1015777676 + .long 3949972341 + .long 107355 + .long 1044000607 + .long 1016786167 + .long 828946858 + .long 119943 + .long 1151779725 + .long 1015705409 + .long 2288159958 + .long 132667 + .long 3819481236 + .long 1016499965 + .long 1853186616 + .long 145530 + .long 2552227826 + .long 1015039787 + .long 1709341917 + .long 158533 + .long 1829350193 + .long 1015216097 + .long 4112506593 + .long 171677 + .long 1913391795 + .long 1015756674 + .long 2799960843 + .long 184965 + .long 1303423926 + .long 1015238005 + .long 171030293 + .long 198398 + .long 1574172746 + .long 1016061241 + .long 2992903935 + .long 211976 + .long 3424156969 + .long 1017196428 + .long 926591434 + .long 225703 + .long 1938513547 + .long 1017631273 + .long 887463926 + .long 239579 + .long 2804567149 + .long 1015390024 + .long 1276261410 + .long 253606 + .long 631083525 + .long 1017690182 + .long 569847337 + .long 267786 + .long 1623370770 + .long 1011049453 + .long 1617004845 + .long 282120 + .long 3667985273 + .long 1013894369 + .long 3049340112 + .long 296610 + .long 3145379760 + .long 1014403278 + .long 3577096743 + .long 311258 + .long 2603100681 + .long 1017152460 + .long 1990012070 + .long 326066 + .long 3249202951 + .long 1017448880 + .long 1453150081 + .long 341035 + .long 419288974 + .long 1016280325 + .long 917841882 + .long 356167 + .long 3793507337 + .long 1016095713 + .long 3712504873 + .long 371463 + .long 728023093 + .long 1016345318 + .long 363667784 + .long 386927 + .long 2582678538 + .long 1017123460 + .long 2956612996 + .long 402558 + .long 7592966 + .long 1016721543 + .long 2186617380 + .long 418360 + .long 228611441 + .long 1016696141 + .long 1719614412 + .long 434334 + .long 2261665670 + .long 1017457593 + .long 1013258798 + .long 450482 + .long 544148907 + .long 1017323666 + .long 3907805043 + .long 466805 + .long 2383914918 + .long 1017143586 + .long 1447192520 + .long 483307 + .long 1176412038 + .long 1017267372 + .long 1944781190 + .long 499988 + .long 2882956373 + .long 1013312481 + .long 919555682 + .long 516851 + .long 3154077648 + .long 1016528543 + .long 2571947538 + .long 533897 + .long 348651999 + .long 1016405780 + .long 2604962540 + .long 551129 + .long 3253791412 + .long 1015920431 + .long 1110089947 + .long 568549 + .long 1509121860 + .long 1014756995 + .long 2568320822 + .long 586158 + .long 2617649212 + .long 1017340090 + .long 2966275556 + .long 603959 + .long 553214634 + .long 1016457425 + .long 2682146383 + .long 621954 + .long 730975783 + .long 1014083580 + .long 2191782032 + .long 640145 + .long 1486499517 + .long 1016818996 + .long 2069751140 + .long 658534 + .long 2595788928 + .long 1016407932 + .long 2990417244 + .long 677123 + .long 1853053619 + .long 1015310724 + .long 1434058175 + .long 695915 + .long 2462790535 + .long 1015814775 + .long 2572866477 + .long 714911 + .long 3693944214 + .long 1017259110 + .long 3092190714 + .long 734114 + .long 2979333550 + .long 1017188654 + .long 4076559942 + .long 753526 + .long 174054861 + .long 1014300631 + .long 2420883922 + .long 773150 + .long 816778419 + .long 1014197934 + .long 3716502172 + .long 792987 + .long 3507050924 + .long 1015341199 + .long 777507147 + .long 813041 + .long 1821514088 + .long 1013410604 + .long 3706687593 + .long 833312 + .long 920623539 + .long 1016295433 + .long 1242007931 + .long 853805 + .long 2789017511 + .long 1014276997 + .long 3707479175 + .long 874520 + .long 3586233004 + .long 1015962192 + .long 64696965 + .long 895462 + .long 474650514 + .long 1016642419 + .long 863738718 + .long 916631 + .long 1614448851 + .long 1014281732 + .long 3884662774 + .long 938030 + .long 2450082086 + .long 1016164135 + .long 2728693977 + .long 959663 + .long 1101668360 + .long 1015989180 + .long 3999357479 + .long 981531 + .long 835814894 + .long 1015702697 + .long 1533953344 + .long 1003638 + .long 1301400989 + .long 1014466875 + .long 2174652632 + .long 1025985 + .long 0 + .long 1072693248 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 4294967295 + .long 2146435071 + .long 0 + .long 1048576 + .type static_const_table,@object + .size static_const_table,1224 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/expf_wmt.S b/external/sgx_libm/ia32/expf_wmt.S new file mode 100644 index 0000000000..73a3aa54a6 --- /dev/null +++ b/external/sgx_libm/ia32/expf_wmt.S @@ -0,0 +1,759 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin expf + .text + .align 16,0x90 + .globl expf +expf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %ecx + movsd 2064(%ebx), %xmm3 + xorpd %xmm7, %xmm7 + movl $17208, %eax + pinsrw $3, %eax, %xmm7 + cvtps2pd %xmm0, %xmm1 + andl $2147483647, %ecx + subl $830472192, %ecx + cmpl $288180587, %ecx + jae .L_2TAG_PACKET_0.0.3 + movsd 2048(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + movapd %xmm7, %xmm2 + xorpd %xmm1, %xmm1 + addsd %xmm3, %xmm7 + movsd 2056(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + addl $830472192, %ecx + cmpl $830472192, %ecx + jb .L_2TAG_PACKET_2.0.3 + cmpl $1124073472, %ecx + jae .L_2TAG_PACKET_3.0.3 + movsd 2048(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + movapd %xmm7, %xmm2 + xorpd %xmm1, %xmm1 + addsd %xmm3, %xmm7 + movsd 2056(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movd %xmm0, %eax + cmpl $8388608, %eax + jb .L_2TAG_PACKET_4.0.3 + cmpl $2139095040, %eax + je .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movd %xmm0, %edx + cmpl $2139095040, %ecx + jae .L_2TAG_PACKET_6.0.3 + testl $-2147483648, %edx + je .L_2TAG_PACKET_5.0.3 + movl $8388608, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_4.0.3: + movl $17, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_5.0.3: + movl $2130706432, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 + movl $16, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_2.0.3: + movl $1065353216, %eax + movd %eax, %xmm1 + addss %xmm1, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_6.0.3: + cmpl $-8388608, %edx + je .L_2TAG_PACKET_9.0.3 + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_9.0.3: + fldz + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_1.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type expf,@function + .size expf,.-expf + .data +# -- End expf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 4200250559 + .long 1072696090 + .long 2851812149 + .long 1072698941 + .long 339411585 + .long 1072701800 + .long 1048019041 + .long 1072704666 + .long 772914124 + .long 1072707540 + .long 3899555717 + .long 1072710421 + .long 1928746161 + .long 1072713311 + .long 3541402996 + .long 1072716208 + .long 238821257 + .long 1072719114 + .long 702412510 + .long 1072722027 + .long 728934454 + .long 1072724948 + .long 410360776 + .long 1072727877 + .long 4133881824 + .long 1072730813 + .long 3402036099 + .long 1072733758 + .long 2602514713 + .long 1072736711 + .long 1828292879 + .long 1072739672 + .long 1172597893 + .long 1072742641 + .long 728909815 + .long 1072745618 + .long 590962156 + .long 1072748603 + .long 852742562 + .long 1072751596 + .long 1608493509 + .long 1072754597 + .long 2952712987 + .long 1072757606 + .long 685187902 + .long 1072760624 + .long 3490863953 + .long 1072763649 + .long 2875075254 + .long 1072766683 + .long 3228316108 + .long 1072769725 + .long 351405227 + .long 1072772776 + .long 2930322912 + .long 1072775834 + .long 2471440686 + .long 1072778901 + .long 3366293073 + .long 1072781976 + .long 1416741826 + .long 1072785060 + .long 1014845819 + .long 1072788152 + .long 2257959872 + .long 1072791252 + .long 948735466 + .long 1072794361 + .long 1480023343 + .long 1072797478 + .long 3949972341 + .long 1072800603 + .long 4162030108 + .long 1072803737 + .long 2214878420 + .long 1072806880 + .long 2502433899 + .long 1072810031 + .long 828946858 + .long 1072813191 + .long 1588871207 + .long 1072816359 + .long 586995997 + .long 1072819536 + .long 2218315341 + .long 1072822721 + .long 2288159958 + .long 1072825915 + .long 897099801 + .long 1072829118 + .long 2440944790 + .long 1072832329 + .long 2725843665 + .long 1072835549 + .long 1853186616 + .long 1072838778 + .long 4219606026 + .long 1072842015 + .long 1337108031 + .long 1072845262 + .long 1897844341 + .long 1072848517 + .long 1709341917 + .long 1072851781 + .long 874372905 + .long 1072855054 + .long 3790955393 + .long 1072858335 + .long 1972484976 + .long 1072861626 + .long 4112506593 + .long 1072864925 + .long 1724976915 + .long 1072868234 + .long 3504003472 + .long 1072871551 + .long 964107055 + .long 1072874878 + .long 2799960843 + .long 1072878213 + .long 526652809 + .long 1072881558 + .long 2839424854 + .long 1072884911 + .long 1253935211 + .long 1072888274 + .long 171030293 + .long 1072891646 + .long 3991843581 + .long 1072895026 + .long 4232894513 + .long 1072898416 + .long 1000925746 + .long 1072901816 + .long 2992903935 + .long 1072905224 + .long 1726216749 + .long 1072908642 + .long 1603444721 + .long 1072912069 + .long 2732492859 + .long 1072915505 + .long 926591435 + .long 1072918951 + .long 589198666 + .long 1072922406 + .long 1829099622 + .long 1072925870 + .long 460407023 + .long 1072929344 + .long 887463927 + .long 1072932827 + .long 3219942644 + .long 1072936319 + .long 3272845541 + .long 1072939821 + .long 1156440435 + .long 1072943333 + .long 1276261410 + .long 1072946854 + .long 3743175029 + .long 1072950384 + .long 78413852 + .long 1072953925 + .long 3278348324 + .long 1072957474 + .long 569847338 + .long 1072961034 + .long 654919306 + .long 1072964603 + .long 3645941911 + .long 1072968181 + .long 1065662932 + .long 1072971770 + .long 1617004845 + .long 1072975368 + .long 1118294578 + .long 1072978976 + .long 3978100823 + .long 1072982593 + .long 1720398391 + .long 1072986221 + .long 3049340112 + .long 1072989858 + .long 3784486610 + .long 1072993505 + .long 4040676318 + .long 1072997162 + .long 3933059031 + .long 1073000829 + .long 3577096743 + .long 1073004506 + .long 3088564500 + .long 1073008193 + .long 2583551245 + .long 1073011890 + .long 2178460671 + .long 1073015597 + .long 1990012071 + .long 1073019314 + .long 2135241198 + .long 1073023041 + .long 2731501122 + .long 1073026778 + .long 3896463087 + .long 1073030525 + .long 1453150082 + .long 1073034283 + .long 4109806887 + .long 1073038050 + .long 3395129871 + .long 1073041828 + .long 3723038930 + .long 1073045616 + .long 917841882 + .long 1073049415 + .long 3689071823 + .long 1073053223 + .long 3566716925 + .long 1073057042 + .long 671025100 + .long 1073060872 + .long 3712504873 + .long 1073064711 + .long 4222122499 + .long 1073068561 + .long 2321106615 + .long 1073072422 + .long 2425981843 + .long 1073076293 + .long 363667784 + .long 1073080175 + .long 551349105 + .long 1073084067 + .long 3111574537 + .long 1073087969 + .long 3872257780 + .long 1073091882 + .long 2956612997 + .long 1073095806 + .long 488188413 + .long 1073099741 + .long 885834528 + .long 1073103686 + .long 4273770423 + .long 1073107641 + .long 2186617381 + .long 1073111608 + .long 3339203574 + .long 1073115585 + .long 3561793907 + .long 1073119573 + .long 2979960120 + .long 1073123572 + .long 1719614413 + .long 1073127582 + .long 4201977662 + .long 1073131602 + .long 1963711167 + .long 1073135634 + .long 3721688645 + .long 1073139676 + .long 1013258799 + .long 1073143730 + .long 2555984613 + .long 1073147794 + .long 4182873220 + .long 1073151869 + .long 1727278727 + .long 1073155956 + .long 3907805044 + .long 1073160053 + .long 2263535754 + .long 1073164162 + .long 1218806132 + .long 1073168282 + .long 903334909 + .long 1073172413 + .long 1447192521 + .long 1073176555 + .long 2980802057 + .long 1073180708 + .long 1339972927 + .long 1073184873 + .long 950803702 + .long 1073189049 + .long 1944781191 + .long 1073193236 + .long 158781403 + .long 1073197435 + .long 19972402 + .long 1073201645 + .long 1660913392 + .long 1073205866 + .long 919555682 + .long 1073210099 + .long 2224145553 + .long 1073214343 + .long 1413356050 + .long 1073218599 + .long 2916157145 + .long 1073222866 + .long 2571947539 + .long 1073227145 + .long 515457527 + .long 1073231436 + .long 1176749997 + .long 1073235738 + .long 396319521 + .long 1073240052 + .long 2604962541 + .long 1073244377 + .long 3643909174 + .long 1073248714 + .long 3649726105 + .long 1073253063 + .long 2759350287 + .long 1073257424 + .long 1110089947 + .long 1073261797 + .long 3134592888 + .long 1073266181 + .long 380978316 + .long 1073270578 + .long 1577608921 + .long 1073274986 + .long 2568320822 + .long 1073279406 + .long 3492293770 + .long 1073283838 + .long 194117574 + .long 1073288283 + .long 1403662306 + .long 1073292739 + .long 2966275557 + .long 1073297207 + .long 727685349 + .long 1073301688 + .long 3418903055 + .long 1073306180 + .long 2591453363 + .long 1073310685 + .long 2682146384 + .long 1073315202 + .long 3833209506 + .long 1073319731 + .long 1892288442 + .long 1073324273 + .long 1297350157 + .long 1073328827 + .long 2191782032 + .long 1073333393 + .long 424392917 + .long 1073337972 + .long 434316067 + .long 1073342563 + .long 2366108318 + .long 1073347166 + .long 2069751141 + .long 1073351782 + .long 3985553595 + .long 1073356410 + .long 3964284211 + .long 1073361051 + .long 2152073944 + .long 1073365705 + .long 2990417245 + .long 1073370371 + .long 2331271250 + .long 1073375050 + .long 321958744 + .long 1073379742 + .long 1405169241 + .long 1073384446 + .long 1434058175 + .long 1073389163 + .long 557149882 + .long 1073393893 + .long 3218338682 + .long 1073398635 + .long 977020788 + .long 1073403391 + .long 2572866477 + .long 1073408159 + .long 3861050111 + .long 1073412940 + .long 697153126 + .long 1073417735 + .long 1822067026 + .long 1073422542 + .long 3092190715 + .long 1073427362 + .long 364333489 + .long 1073432196 + .long 2380618042 + .long 1073437042 + .long 703710506 + .long 1073441902 + .long 4076559943 + .long 1073446774 + .long 4062661092 + .long 1073451660 + .long 815859274 + .long 1073456560 + .long 3080351519 + .long 1073461472 + .long 2420883922 + .long 1073466398 + .long 3287523847 + .long 1073471337 + .long 1540824585 + .long 1073476290 + .long 1631695677 + .long 1073481256 + .long 3716502172 + .long 1073486235 + .long 3657065772 + .long 1073491228 + .long 1610600570 + .long 1073496235 + .long 2029714210 + .long 1073501255 + .long 777507147 + .long 1073506289 + .long 2307442995 + .long 1073511336 + .long 2483480501 + .long 1073516397 + .long 1464976603 + .long 1073521472 + .long 3706687593 + .long 1073526560 + .long 778901109 + .long 1073531663 + .long 1432208378 + .long 1073536779 + .long 1532734324 + .long 1073541909 + .long 1242007932 + .long 1073547053 + .long 721996136 + .long 1073552211 + .long 135105010 + .long 1073557383 + .long 3939148246 + .long 1073562568 + .long 3707479175 + .long 1073567768 + .long 3898795731 + .long 1073572982 + .long 382305176 + .long 1073578211 + .long 1912561781 + .long 1073583453 + .long 64696965 + .long 1073588710 + .long 3594158869 + .long 1073593980 + .long 4076975200 + .long 1073599265 + .long 1679558232 + .long 1073604565 + .long 863738719 + .long 1073609879 + .long 1796832535 + .long 1073615207 + .long 351641897 + .long 1073620550 + .long 991358482 + .long 1073625907 + .long 3884662774 + .long 1073631278 + .long 610758006 + .long 1073636665 + .long 4224142467 + .long 1073642065 + .long 2009970496 + .long 1073647481 + .long 2728693978 + .long 1073652911 + .long 2256325230 + .long 1073658356 + .long 764307441 + .long 1073663816 + .long 2719515920 + .long 1073669290 + .long 3999357479 + .long 1073674779 + .long 481706282 + .long 1073680284 + .long 929806999 + .long 1073685803 + .long 1222472308 + .long 1073691337 + .long 1533953344 + .long 1073696886 + .long 2038973688 + .long 1073702450 + .long 2912730644 + .long 1073708029 + .long 35929225 + .long 1073713624 + .long 2174652632 + .long 1073719233 + .long 915592468 + .long 1073724858 + .long 730821105 + .long 1073730498 + .long 1797923801 + .long 1073736153 + .long 4286760334 + .long 1053736893 + .long 4277826245 + .long 1063661122 + .long 1697350398 + .long 1081546055 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,2088 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/expl.S b/external/sgx_libm/ia32/expl.S new file mode 100644 index 0000000000..48b0f7f0dd --- /dev/null +++ b/external/sgx_libm/ia32/expl.S @@ -0,0 +1,969 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expl.c" + .text +..TXTST0: +# -- Begin expl + .text + .align 16,0x90 + .globl expl +expl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp +..B1.2: + fnstcw 70(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $16389, %eax + jge ..B1.50 +..B1.4: + movzwl 70(%esp), %ecx + cmpl $16378, %eax + jge ..B1.43 +..B1.5: + cmpl $16372, %eax + jge ..B1.36 +..B1.6: + cmpl $16365, %eax + jge ..B1.29 +..B1.7: + cmpl $16357, %eax + jge ..B1.22 +..B1.8: + cmpl $16316, %eax + jge ..B1.15 +..B1.9: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.78 +..B1.10: + orl $-64768, %ecx + movw %cx, 68(%esp) +..B1.11: + fldcw 68(%esp) +..B1.12: + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fldt 8(%ebp) + faddp %st, %st(1) + fstpt (%esp) +..B1.13: + fldcw 70(%esp) +..B1.14: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.79 +..B1.16: + orl $-64768, %ecx + movw %cx, 68(%esp) +..B1.17: + fldcw 68(%esp) +..B1.18: + movl $1, %eax +..B1.19: + fldt 8(%ebp) + testl %eax, %eax + fldt _Q3@GOTOFF(%edx) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.21 +..B1.20: + fldcw 70(%esp) +..B1.21: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.22: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.80 +..B1.23: + orl $-64768, %ecx + movw %cx, 68(%esp) +..B1.24: + fldcw 68(%esp) +..B1.25: + movl $1, %eax +..B1.26: + fldt 8(%ebp) + testl %eax, %eax + fldt 12+_Q2@GOTOFF(%edx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.28 +..B1.27: + fldcw 70(%esp) +..B1.28: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.81 +..B1.30: + orl $-64768, %ecx + movw %cx, 68(%esp) +..B1.31: + fldcw 68(%esp) +..B1.32: + movl $1, %eax +..B1.33: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(1) + fldt 36+_Q1@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_Q1@GOTOFF(%edx) + fmul %st(3), %st + fldt 12+_Q1@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt _Q1@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fadd %st, %st(2) + fsubr %st(2), %st + fsubrp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.35 +..B1.34: + fldcw 70(%esp) +..B1.35: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.36: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.82 +..B1.37: + orl $-64768, %ecx + movw %cx, 68(%esp) +..B1.38: + fldcw 68(%esp) +..B1.39: + movl $1, %eax +..B1.40: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 84+_Q0@GOTOFF(%edx) + fmul %st(1), %st + fldt 72+_Q0@GOTOFF(%edx) + fmul %st(2), %st + fldt 60+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmul %st(3), %st + fldt _Q0@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fadd %st, %st(1) + fsubr %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.42 +..B1.41: + fldcw 70(%esp) +..B1.42: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.43: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.83 +..B1.44: + orl $-64768, %ecx + movw %cx, 68(%esp) +..B1.45: + fldcw 68(%esp) +..B1.46: + movl $1, %ebx +..B1.47: + fldl _TWO_63H@GOTOFF(%edx) + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(1), %st + fadd %st(2), %st + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmul %st(2), %st + movl 24(%esp), %eax + fsubrp %st, %st(1) + fld %st(0) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmulp %st, %st(3) + movsbl %al, %ecx + fsub %st(2), %st + fldl _TWO_32H@GOTOFF(%edx) + subl %ecx, %eax + shll $4, %ecx + fadd %st, %st(1) + shrl $8, %eax + fsubr %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + shll $23, %eax + fxch %st(4) + fsubrp %st, %st(3) + addl $1065353216, %eax + fadd %st(2), %st + fld %st(0) + testl %ebx, %ebx + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + movl %eax, 36(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + faddp %st, %st(2) + fldt _P@GOTOFF(%edx) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%ecx) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%ecx) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(5), %st + fmul %st(2), %st + faddp %st, %st(4) + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmuls 36(%esp) + fstpt (%esp) + je ..B1.95 +..B1.48: + fstpt 24(%esp) +..B1.93: + fldcw 70(%esp) + jmp ..B1.49 +..B1.95: + fstp %st(0) +..B1.49: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.50: + movzbl 17(%ebp), %ebx + andl $128, %ebx + shrl $7, %ebx + lea (,%ebx,8), %ecx + lea (%ecx,%ebx,4), %ecx + movzwl 8+_ranges@GOTOFF(%ecx,%edx), %esi + andl $32767, %esi + cmpl %esi, %eax + jl ..B1.55 +..B1.51: + jne ..B1.67 +..B1.52: + movl 12(%ebp), %esi + cmpl 4+_ranges@GOTOFF(%ecx,%edx), %esi + jb ..B1.55 +..B1.53: + jne ..B1.67 +..B1.54: + movl 8(%ebp), %esi + cmpl _ranges@GOTOFF(%ecx,%edx), %esi + jae ..B1.67 +..B1.55: + movzwl 70(%esp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.85 +..B1.56: + orl $-64768, %esi + movw %si, 68(%esp) +..B1.57: + fldcw 68(%esp) +..B1.58: + movl $1, %esi +..B1.59: + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fstpt (%esp) + fldl _TWO_63H@GOTOFF(%edx) + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(1), %st + movl %ecx, 36(%esp) + fadd %st(2), %st + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmul %st(2), %st + movl 24(%esp), %eax + movl %eax, %ecx + movsbl %al, %edi + addl $4196735, %eax + subl %edi, %ecx + fsubr %st(1), %st + fld %st(0) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmulp %st, %st(4) + shll $4, %edi + fsub %st(3), %st + fldl _TWO_32H@GOTOFF(%edx) + shrl $8, %ecx + fadd %st, %st(1) + fxch %st(1) + fstpt 40(%esp) + fldt 40(%esp) + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + addl SC2_BIAS@GOTOFF(%edx,%ebx,4), %ecx + fxch %st(4) + fsubrp %st, %st(2) + movl %esi, 52(%esp) + andl $32767, %ecx + movzwl 8+.L_2il0floatpacket.3@GOTOFF(%edx), %esi + fadd %st(1), %st + fld %st(0) + andl $-32768, %esi + fmul %st(1), %st + orl %ecx, %esi + fldt 48+_P@GOTOFF(%edx) + cmpl $3070, %eax + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + movw %si, 8(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + movl 52(%esp), %esi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + movl 36(%esp), %ecx + faddp %st, %st(2) + fldt _P@GOTOFF(%edx) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%edi) + fld %st(0) + fmul %st(2), %st + fxch %st(2) + fadd %st(4), %st + fxch %st(1) + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + fxch %st(1) + fmull 2056+__libm_expl_table_256@GOTOFF(%edx,%edi) + faddp %st, %st(2) + faddl 2056+__libm_expl_table_256@GOTOFF(%edx,%edi) + faddp %st, %st(1) + ja ..B1.62 +..B1.60: + fldt _expbut@GOTOFF(%edx) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B1.62 +..B1.61: + fstp %st(1) + fldl _TWO_12H@GOTOFF(%edx) + fld %st(2) + fadd %st(2), %st + fmul %st, %st(1) + fadd %st(1), %st + fstpt 40(%esp) + fldt 40(%esp) + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt _SC2@GOTOFF(%ecx,%edx) + fldt (%esp) + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 56(%esp) + jmp ..B1.63 +..B1.62: + fstp %st(1) + fldt (%esp) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt _SC2@GOTOFF(%ecx,%edx) + fmulp %st, %st(1) + fstpt 56(%esp) +..B1.63: + fldt _minnorm@GOTOFF(%edx) + fldt 56(%esp) + fcompp + fnstsw %ax + sahf + jp ..B1.64 + jb ..B1.84 +..B1.64: + testl %esi, %esi + je ..B1.66 +..B1.65: + fldt 40(%esp) + fstpt 24(%esp) +..B1.94: + fldcw 70(%esp) +..B1.66: + fldt 56(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.67: + movzwl 70(%esp), %esi + movl %esi, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.90 +..B1.68: + orl $-64768, %esi + movw %si, 68(%esp) +..B1.69: + fldcw 68(%esp) +..B1.70: + movzwl 16(%ebp), %eax + movl $1, %ecx + andl $32767, %eax +..B1.71: + cmpl $32767, %eax + je ..B1.86 +..B1.72: + testl %ebx, %ebx + je ..B1.74 +..B1.73: + fldt _small_value_80@GOTOFF(%edx) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.75 +..B1.74: + fldt _large_value_80@GOTOFF(%edx) + fmul %st(0), %st + fstpt (%esp) +..B1.75: + testl %ecx, %ecx + je ..B1.77 +..B1.76: + fldcw 70(%esp) +..B1.77: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.78: + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + fldt 8(%ebp) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.14 +..B1.79: + xorl %eax, %eax + jmp ..B1.19 +..B1.80: + xorl %eax, %eax + jmp ..B1.26 +..B1.81: + xorl %eax, %eax + jmp ..B1.33 +..B1.82: + xorl %eax, %eax + jmp ..B1.40 +..B1.83: + xorl %ebx, %ebx + jmp ..B1.47 +..B1.84: + fldt _small_value_80@GOTOFF(%edx) + fmul %st(0), %st + fstpt 12(%esp) + jmp ..B1.64 +..B1.85: + xorl %esi, %esi + jmp ..B1.59 +..B1.86: + cmpl $-2147483648, 12(%ebp) + jne ..B1.89 +..B1.87: + cmpl $0, 8(%ebp) + jne ..B1.89 +..B1.88: + fldl _inf_zeros@GOTOFF(%edx,%ebx,8) + fstpt (%esp) + jmp ..B1.75 +..B1.89: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.75 +..B1.90: + xorl %ecx, %ecx + jmp ..B1.71 + .align 16,0x90 + .type expl,@function + .size expl,.-expl + .data +# -- End expl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +SC2_BIAS: + .long 8191 + .long 24575 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_inf_zeros: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zeros,@object + .size _inf_zeros,16 + .align 2 +_Q3: + .word 1 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 21845 + .word 85 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 13107 + .word 43827 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 65172 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 43275 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 49902 + .word 27670 + .word 43713 + .word 43690 + .word 16378 + .word 0 + .word 39976 + .word 2496 + .word 34972 + .word 34952 + .word 16376 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q0: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 62628 + .word 43690 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 53890 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 62001 + .word 21104 + .word 24757 + .word 46603 + .word 16373 + .word 0 + .word 21793 + .word 10330 + .word 207 + .word 53261 + .word 16370 + .word 0 + .word 18027 + .word 53571 + .word 10421 + .word 53262 + .word 16367 + .word 0 + .word 54394 + .word 23739 + .word 10794 + .word 47344 + .word 16364 + .word 0 + .type _Q0,@object + .size _Q0,96 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_ranges: + .word 31148 + .word 53711 + .word 6135 + .word 45426 + .word 16396 + .word 0 + .word 488 + .word 27074 + .word 50247 + .word 45600 + .word 16396 + .word 0 + .type _ranges,@object + .size _ranges,24 + .align 2 +_expbut: + .word 60207 + .word 4624 + .word 35943 + .word 45420 + .word 49164 + .word 0 + .type _expbut,@object + .size _expbut,12 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .type _SC2,@object + .size _SC2,24 + .align 2 +_minnorm: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _minnorm,@object + .size _minnorm,12 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/expl_table.S b/external/sgx_libm/ia32/expl_table.S new file mode 100644 index 0000000000..a3b1c92bfa --- /dev/null +++ b/external/sgx_libm/ia32/expl_table.S @@ -0,0 +1,562 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expl_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_expl_table_256 + .globl __libm_expl_table_256 +__libm_expl_table_256: + .long 0x66800000,0x3fe6a09e + .long 0xee9a09d9,0xbd98866d + .long 0xfa800000,0x3fe6b052 + .long 0xcb8e15a7,0xbdd5d183 + .long 0x75000000,0x3fe6c012 + .long 0xdaed5330,0x3dd7b57d + .long 0xde000000,0x3fe6cfdc + .long 0x470aac92,0xbdf5c4dd + .long 0x3c400000,0x3fe6dfb2 + .long 0x79107166,0x3df28d17 + .long 0x98400000,0x3fe6ef92 + .long 0xbd1a2d88,0x3de93ae4 + .long 0xf9400000,0x3fe6ff7d + .long 0xcf87e1b5,0x3de19483 + .long 0x67000000,0x3fe70f74 + .long 0xf314dd96,0xbdd7a2f1 + .long 0xe9000000,0x3fe71f75 + .long 0x22dc8f0d,0xbde3a08c + .long 0x87000000,0x3fe72f82 + .long 0x482a80b3,0xbde52f76 + .long 0x48c00000,0x3fe73f9a + .long 0x42a365b2,0xbdea7e8c + .long 0x35c00000,0x3fe74fbd + .long 0x411ff586,0x3de7cbfd + .long 0x56400000,0x3fe75feb + .long 0xfb74d51a,0x3db33e45 + .long 0xb1c00000,0x3fe77024 + .long 0x921e23a6,0xbde491f6 + .long 0x4fc00000,0x3fe78069 + .long 0x619ae028,0x3dee5d3f + .long 0x38c00000,0x3fe790b9 + .long 0xb2d95e75,0xbde3e309 + .long 0x74000000,0x3fe7a114 + .long 0x282aefdc,0xbde4fe79 + .long 0x09800000,0x3fe7b17b + .long 0xdf5dac23,0xbdd2604a + .long 0x01000000,0x3fe7c1ed + .long 0x3e2499a2,0x3df86099 + .long 0x63000000,0x3fe7d26a + .long 0x4224048d,0xbd8e43ee + .long 0x36c00000,0x3fe7e2f3 + .long 0x20ba0574,0x3dde9cc4 + .long 0x84800000,0x3fe7f387 + .long 0xdf01dc61,0x3de1c490 + .long 0x54400000,0x3fe80427 + .long 0x9f21989b,0xbdae5ee4 + .long 0xae000000,0x3fe814d2 + .long 0x573791e6,0xbdf77c93 + .long 0x99400000,0x3fe82589 + .long 0x159f115f,0x3dd99c25 + .long 0x1e800000,0x3fe8364c + .long 0xb3373464,0x3dfca0fb + .long 0x46400000,0x3fe8471a + .long 0x31ad0947,0xbdec3853 + .long 0x17800000,0x3fe857f4 + .long 0xf9162dc2,0x3def5b20 + .long 0x9b400000,0x3fe868d9 + .long 0x03907643,0x3dc24bb2 + .long 0xd9400000,0x3fe879ca + .long 0xa8b4a0b5,0xbddcb793 + .long 0xd9800000,0x3fe88ac7 + .long 0xcca6179c,0x3dd4cd32 + .long 0xa4800000,0x3fe89bd0 + .long 0x2ac6abb9,0xbdce9fc2 + .long 0x42400000,0x3fe8ace5 + .long 0xa4583aa6,0xbde55f24 + .long 0xbac00000,0x3fe8be05 + .long 0x7b2d7bf1,0x3de61778 + .long 0x16c00000,0x3fe8cf32 + .long 0x21aabc66,0xbdd576e8 + .long 0x5e400000,0x3fe8e06a + .long 0xae2294e0,0xbdfbcc93 + .long 0x99000000,0x3fe8f1ae + .long 0x2b982746,0x3de57736 + .long 0xd0000000,0x3fe902fe + .long 0x2b25950c,0x3df41645 + .long 0x0b800000,0x3fe9145b + .long 0x88a61b47,0x3de1ffc5 + .long 0x53800000,0x3fe925c3 + .long 0xecbaa05a,0x3df517f0 + .long 0xb0c00000,0x3fe93737 + .long 0xe8a0387e,0x3ddb8bc9 + .long 0x2b400000,0x3fe948b8 + .long 0xc478530d,0x3def98e4 + .long 0xcbc00000,0x3fe95a44 + .long 0xd36906d3,0x3dd0a41d + .long 0x9a400000,0x3fe96bdd + .long 0x7c8b4d30,0x3dfb3859 + .long 0x9fc00000,0x3fe97d82 + .long 0x8b9e9210,0x3dee4e4f + .long 0xe4800000,0x3fe98f33 + .long 0x8d509577,0xbdc77577 + .long 0x70c00000,0x3fe9a0f1 + .long 0x74621372,0x3dd40f73 + .long 0x4d400000,0x3fe9b2bb + .long 0x889ec6c8,0x3de3fe0c + .long 0x82800000,0x3fe9c491 + .long 0x0e3e2358,0x3df1f848 + .long 0x19400000,0x3fe9d674 + .long 0x574a0ae1,0x3dd771a9 + .long 0x19c00000,0x3fe9e863 + .long 0x8c12653c,0x3df19191 + .long 0x8d000000,0x3fe9fa5e + .long 0x5ab18aa8,0x3dcfca77 + .long 0x7b400000,0x3fea0c66 + .long 0xb29ada8c,0x3dede564 + .long 0xed800000,0x3fea1e7a + .long 0xe330c774,0x3ddd7176 + .long 0xec400000,0x3fea309b + .long 0xb182e3ef,0x3dd45a66 + .long 0x80400000,0x3fea42c9 + .long 0x5587fa76,0x3dc82b5e + .long 0xb2400000,0x3fea5503 + .long 0x4bdbb6e3,0xbdadaa37 + .long 0x8b000000,0x3fea674a + .long 0xeaf0a9d0,0xbdd73f5b + .long 0x13400000,0x3fea799e + .long 0x21a409aa,0xbdde994f + .long 0x53c00000,0x3fea8bfe + .long 0xc1e61351,0x3da2e58a + .long 0x55400000,0x3fea9e6b + .long 0xa1f5921e,0x3dfcfedf + .long 0x21400000,0x3feab0e5 + .long 0x9d8f3894,0xbdd5228b + .long 0xbfc00000,0x3feac36b + .long 0xc0db966a,0x3de3f379 + .long 0x3a400000,0x3fead5ff + .long 0x0218892a,0xbdbec45d + .long 0x99800000,0x3feae89f + .long 0x50bc6597,0xbdf29629 + .long 0xe6400000,0x3feafb4c + .long 0x52cbf03d,0xbded0d01 + .long 0x29800000,0x3feb0e07 + .long 0x2108559c,0x3ddb6ccb + .long 0x6c800000,0x3feb20ce + .long 0x53740928,0x3dea8952 + .long 0xb8800000,0x3feb33a2 + .long 0x84a0178c,0xbdf87502 + .long 0x15c00000,0x3feb4684 + .long 0x3eec7bd4,0xbdd16c9e + .long 0x8e000000,0x3feb5972 + .long 0x71c77eef,0xbdeaa6c6 + .long 0x2a000000,0x3feb6c6e + .long 0x6ab8656c,0xbddc75ab + .long 0xf3000000,0x3feb7f76 + .long 0x55613df9,0xbdc286e4 + .long 0xf2400000,0x3feb928c + .long 0x6dc85953,0xbde8b61c + .long 0x30c00000,0x3feba5b0 + .long 0x7bf34c39,0xbdeef9b6 + .long 0xb7c00000,0x3febb8e0 + .long 0x80fa968e,0xbdf2c870 + .long 0x90400000,0x3febcc1e + .long 0x48f741e9,0x3dd783a4 + .long 0xc4000000,0x3febdf69 + .long 0x0384c46c,0xbdd8bbf2 + .long 0x5c000000,0x3febf2c2 + .long 0xbdfb947f,0xbdf470fb + .long 0x61400000,0x3fec0628 + .long 0x4eb4abc1,0x3dab33cc + .long 0xdd800000,0x3fec199b + .long 0x88832c4b,0x3dc54a70 + .long 0xd9c00000,0x3fec2d1c + .long 0xd235d3d0,0x3dfd3295 + .long 0x60000000,0x3fec40ab + .long 0x75903ef8,0xbd77c2c9 + .long 0x79000000,0x3fec5447 + .long 0xed0f8db7,0xbdc41376 + .long 0x2e400000,0x3fec67f1 + .long 0x4a2137fd,0x3de7d14b + .long 0x89c00000,0x3fec7ba8 + .long 0x9e76bbbe,0xbdfb9b66 + .long 0x94000000,0x3fec8f6d + .long 0x46b2f122,0x3dcb9ed4 + .long 0x57400000,0x3feca340 + .long 0xd01a825e,0x3de1c4da + .long 0xdd000000,0x3fecb720 + .long 0xeafc342e,0xbde06f96 + .long 0x2e800000,0x3feccb0f + .long 0x1d220f86,0xbde2e98b + .long 0x55400000,0x3fecdf0b + .long 0xc44f8959,0x3dedc3f9 + .long 0x5b800000,0x3fecf315 + .long 0x3411d371,0xbdf22a46 + .long 0x4a000000,0x3fed072d + .long 0x343c8bc8,0x3dce25ee + .long 0x2b000000,0x3fed1b53 + .long 0xaab1b10d,0x3dd192d0 + .long 0x08000000,0x3fed2f87 + .long 0x15bc2473,0x3ddb13e3 + .long 0xeac00000,0x3fed43c8 + .long 0x9eda9dfb,0x3dd543ac + .long 0xdd000000,0x3fed5818 + .long 0x6897e945,0xbdc16de3 + .long 0xe8400000,0x3fed6c76 + .long 0x83fd0f49,0x3df17369 + .long 0x16c00000,0x3fed80e3 + .long 0x7709f3a1,0x3dd3072f + .long 0x72000000,0x3fed955d + .long 0xfd692233,0xbd93f152 + .long 0x04000000,0x3feda9e6 + .long 0x47b9ff2d,0xbdf266bd + .long 0xd6400000,0x3fedbe7c + .long 0xb76f1927,0xbdc5f3ad + .long 0xf3000000,0x3fedd321 + .long 0xb695de3c,0x3dab4604 + .long 0x64000000,0x3fede7d5 + .long 0x8d6ab5c6,0x3dec0657 + .long 0x33800000,0x3fedfc97 + .long 0x1a5cd4f2,0xbdc19285 + .long 0x6b000000,0x3fee1167 + .long 0xed4ad643,0x3de97d16 + .long 0x15000000,0x3fee2646 + .long 0xbdb13c0c,0xbdd4bdae + .long 0x3b000000,0x3fee3b33 + .long 0x982d6f38,0x3de6ee11 + .long 0xe7c00000,0x3fee502e + .long 0xec61767f,0xbdfa6004 + .long 0x24800000,0x3fee6539 + .long 0x2c7ff0ea,0xbde8928a + .long 0xfbc00000,0x3fee7a51 + .long 0x2d522ca1,0x3dcd320d + .long 0x77c00000,0x3fee8f79 + .long 0x77bb5bfa,0x3ddb6e7f + .long 0xa2c00000,0x3feea4af + .long 0x7a708c5e,0xbdeb6f26 + .long 0x86800000,0x3feeb9f4 + .long 0x6f9a1bae,0xbdb9ac8d + .long 0x2d800000,0x3feecf48 + .long 0x1b60625f,0x3ddccfe1 + .long 0xa2000000,0x3feee4aa + .long 0x471a3692,0x3de88510 + .long 0xee400000,0x3feefa1b + .long 0xbb8fe90d,0x3df0ad13 + .long 0x1cc00000,0x3fef0f9c + .long 0x99100329,0xbdd37dac + .long 0x37800000,0x3fef252b + .long 0xb1796904,0xbde44568 + .long 0x48c00000,0x3fef3ac9 + .long 0xe6a5a5c1,0x3ded7273 + .long 0x5b800000,0x3fef5076 + .long 0x98b07b49,0xbde1babf + .long 0x79800000,0x3fef6632 + .long 0xfd1bd9aa,0x3dd089f0 + .long 0xadc00000,0x3fef7bfd + .long 0x3b7625a0,0xbdf1a0f6 + .long 0x02400000,0x3fef91d8 + .long 0x08975454,0xbdebc377 + .long 0x81c00000,0x3fefa7c1 + .long 0xe8b7ac0c,0xbdf0b793 + .long 0x36800000,0x3fefbdba + .long 0xe6988ceb,0x3de2d513 + .long 0x2b800000,0x3fefd3c2 + .long 0x12eb7496,0x3ddee3e2 + .long 0x6b400000,0x3fefe9d9 + .long 0xeb59fc8c,0xbde5dc26 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0x00000000 + .long 0xfa600000,0x3ff00b1a + .long 0xa7b5953b,0xbdd50d04 + .long 0xaa000000,0x3ff0163d + .long 0x49ed6654,0xbdd3332a + .long 0x14400000,0x3ff02168 + .long 0x95f9887e,0xbdd3f5fc + .long 0x3e800000,0x3ff02c9a + .long 0x232106a7,0xbde0ff3e + .long 0x2e200000,0x3ff037d4 + .long 0xea97ee11,0xbdec8867 + .long 0xe8800000,0x3ff04315 + .long 0x428c7066,0xbdf1807b + .long 0x73000000,0x3ff04e5f + .long 0xacf21b15,0xbde3569d + .long 0xd3200000,0x3ff059b0 + .long 0x8a30756e,0xbde4f517 + .long 0x0e400000,0x3ff0650a + .long 0xb96f6af3,0xbdcf03ba + .long 0x29e00000,0x3ff0706b + .long 0xc91dfe2b,0xbdc04911 + .long 0x2b800000,0x3ff07bd4 + .long 0xb3732eaf,0xbdeaaf93 + .long 0x18800000,0x3ff08745 + .long 0xee7941b4,0xbde4c86f + .long 0xf6600000,0x3ff092bd + .long 0x97f9c7ff,0x3dd81f7e + .long 0xcac00000,0x3ff09e3e + .long 0x14878183,0x3ddbce0d + .long 0x9b200000,0x3ff0a9c7 + .long 0x8ba4de31,0xbda8dcda + .long 0x6d000000,0x3ff0b558 + .long 0x759d1b52,0xbdd9dbc2 + .long 0x45e00000,0x3ff0c0f1 + .long 0x4f98906d,0x3dd1b215 + .long 0x2b600000,0x3ff0cc92 + .long 0x407b705c,0x3df247f7 + .long 0x23400000,0x3ff0d83b + .long 0xbc14de44,0xbdda8851 + .long 0x32e00000,0x3ff0e3ec + .long 0xfbf17a36,0xbde85cbb + .long 0x5fe00000,0x3ff0efa5 + .long 0x9db9bc54,0xbd958ed4 + .long 0xb0000000,0x3ff0fb66 + .long 0xdcdf6e22,0xbdb2ce50 + .long 0x28c00000,0x3ff10730 + .long 0x3a8dd62d,0x3df7233e + .long 0xd0200000,0x3ff11301 + .long 0xb62881ca,0xbdeb495e + .long 0xab600000,0x3ff11edb + .long 0x29153dc1,0xbdbd54a7 + .long 0xc0600000,0x3ff12abd + .long 0xf72575a6,0x3de86397 + .long 0x14e00000,0x3ff136a8 + .long 0xf477b823,0x3df204aa + .long 0xaea00000,0x3ff1429a + .long 0x66820328,0x3de25bbf + .long 0x93600000,0x3ff14e95 + .long 0x3723d073,0xbdf0ced2 + .long 0xc8a00000,0x3ff15a98 + .long 0x920355cf,0x3dd63944 + .long 0x54600000,0x3ff166a4 + .long 0x063c8ee1,0x3df1c3c2 + .long 0x3c800000,0x3ff172b8 + .long 0x19041b9d,0xbdc57429 + .long 0x86a00000,0x3ff17ed4 + .long 0xdec3803b,0xbde4887f + .long 0x38800000,0x3ff18af9 + .long 0x777ee173,0x3de91bd3 + .long 0x58400000,0x3ff19726 + .long 0x5aa913d0,0xbde145a1 + .long 0xeb600000,0x3ff1a35b + .long 0x796d31ed,0x3def96ea + .long 0xf8200000,0x3ff1af99 + .long 0x4203d2da,0xbde8ebc7 + .long 0x84000000,0x3ff1bbe0 + .long 0x6ac79cad,0x3dd1734e + .long 0x95200000,0x3ff1c82f + .long 0x804bbc01,0x3de038d6 + .long 0x31800000,0x3ff1d487 + .long 0x87fa47fd,0xbdf74655 + .long 0x5ec00000,0x3ff1e0e7 + .long 0xb7eec044,0xbde77fb2 + .long 0x23000000,0x3ff1ed50 + .long 0x3bf3004f,0xbdc9371a + .long 0x84400000,0x3ff1f9c1 + .long 0xbf524a09,0xbddcc6cd + .long 0x88600000,0x3ff2063b + .long 0xdc775815,0x3dc466b1 + .long 0x35600000,0x3ff212be + .long 0x4d64b4b4,0x3df8a819 + .long 0x91800000,0x3ff21f49 + .long 0xd56816b7,0xbdc11b4e + .long 0xa2800000,0x3ff22bdd + .long 0x16582554,0xbddbb4bb + .long 0x6e800000,0x3ff2387a + .long 0x327c0a4a,0xbde53b8f + .long 0xfba00000,0x3ff2451f + .long 0xca6066de,0xbdfdebf5 + .long 0x4fc00000,0x3ff251ce + .long 0x94faa904,0xbdeab381 + .long 0x71200000,0x3ff25e85 + .long 0x07976d4f,0xbdb318ab + .long 0x65e00000,0x3ff26b45 + .long 0x2bd33994,0x3dc3e6e9 + .long 0x34200000,0x3ff2780e + .long 0x3f307f41,0xbdc106b4 + .long 0xe1e00000,0x3ff284df + .long 0x96cf15cf,0x3df56380 + .long 0x75800000,0x3ff291ba + .long 0xda671baf,0x3df1bb6f + .long 0xf5200000,0x3ff29e9d + .long 0xed175053,0xbd808f69 + .long 0x66c00000,0x3ff2ab8a + .long 0x9aa2f39c,0x3df10f12 + .long 0xd0e00000,0x3ff2b87f + .long 0x08856e6b,0xbdd499c0 + .long 0x39600000,0x3ff2c57e + .long 0xabfae964,0x3df71b2e + .long 0xa7000000,0x3ff2d285 + .long 0xbff6e2ad,0xbdfbfcf4 + .long 0x1f600000,0x3ff2df96 + .long 0xd16cffbc,0x3dd05625 + .long 0xa9400000,0x3ff2ecaf + .long 0xe35f0ba3,0xbdbd0a9e + .long 0x4ac00000,0x3ff2f9d2 + .long 0x54f1554d,0xbdc3bca8 + .long 0x0a200000,0x3ff306fe + .long 0x2de8d5a4,0x3df1b715 + .long 0xee000000,0x3ff31432 + .long 0xcd4cb818,0xbdf14d02 + .long 0xfc400000,0x3ff32170 + .long 0x6a739e38,0x3de9b062 + .long 0x3ba00000,0x3ff32eb8 + .long 0x1dd0be1a,0x3de1d463 + .long 0xb2600000,0x3ff33c08 + .long 0x32721843,0x3dd05bfd + .long 0x66e00000,0x3ff34962 + .long 0xca58a6cf,0x3dcfd166 + .long 0x5fa00000,0x3ff356c5 + .long 0x6d73b971,0xbdeac01e + .long 0xa2e00000,0x3ff36431 + .long 0x8628940e,0xbdb77c53 + .long 0x37400000,0x3ff371a7 + .long 0x63aeabf4,0xbdd558d5 + .long 0x23200000,0x3ff37f26 + .long 0x7d72a7b4,0xbdb8ab66 + .long 0x6d000000,0x3ff38cae + .long 0x16a72c36,0x3dd76196 + .long 0x1b800000,0x3ff39a40 + .long 0xcd4d2fe4,0xbded7e22 + .long 0x34e00000,0x3ff3a7db + .long 0xa86f24a6,0x3dd67fdb + .long 0xc0000000,0x3ff3b57f + .long 0xaace6476,0xbdf3930b + .long 0xc3200000,0x3ff3c32d + .long 0xf7ffc1bb,0xbde8ae36 + .long 0x44e00000,0x3ff3d0e5 + .long 0x3fd1a118,0x3debc2e6 + .long 0x4c200000,0x3ff3dea6 + .long 0x9497dbb8,0xbdeb97bb + .long 0xdf200000,0x3ff3ec70 + .long 0xaf6637b9,0xbdcd7459 + .long 0x04a00000,0x3ff3fa45 + .long 0x417ee035,0x3de90037 + .long 0xc3600000,0x3ff40822 + .long 0xdeefc5b8,0x3dde8090 + .long 0x22000000,0x3ff4160a + .long 0x0f79b48e,0xbde1a3ac + .long 0x27000000,0x3ff423fb + .long 0x3dce91fa,0x3de28d13 + .long 0xd9600000,0x3ff431f5 + .long 0x471f778d,0xbdeeaed2 + .long 0x3f800000,0x3ff43ffa + .long 0xc405f4b8,0x3dd2e750 + .long 0x60600000,0x3ff44e08 + .long 0x3136f40a,0x3db892d0 + .long 0x42a00000,0x3ff45c20 + .long 0xcf37ccfa,0x3ddf48c7 + .long 0xed200000,0x3ff46a41 + .long 0x6d7685d3,0xbdc7fd44 + .long 0x66800000,0x3ff4786d + .long 0x1ef87896,0x3de6646d + .long 0xb5c00000,0x3ff486a2 + .long 0x3c1a3b69,0x3db3cd01 + .long 0xe1a00000,0x3ff494e1 + .long 0x4eca2579,0xbdeaa25c + .long 0xf0e00000,0x3ff4a32a + .long 0x31a4e861,0xbde05843 + .long 0xea800000,0x3ff4b17d + .long 0x224b70fe,0xbdf24829 + .long 0xd5400000,0x3ff4bfda + .long 0xc578d0a0,0xbde3abb1 + .long 0xb8000000,0x3ff4ce41 + .long 0x4178a5a4,0x3df7c114 + .long 0x9a000000,0x3ff4dcb2 + .long 0xe2648873,0xbdc11794 + .long 0x81e00000,0x3ff4eb2d + .long 0x5257d2e6,0xbddd5005 + .long 0x76a00000,0x3ff4f9b2 + .long 0x96613a4b,0xbdc69aca + .long 0x7f400000,0x3ff50841 + .long 0x68926d27,0x3dd4c7b8 + .long 0xa2c00000,0x3ff516da + .long 0x8225ea59,0x3deecc83 + .long 0xe8400000,0x3ff5257d + .long 0x9331a87e,0xbda62223 + .long 0x56a00000,0x3ff5342b + .long 0x07abe1db,0xbdc583f1 + .long 0xf4e00000,0x3ff542e2 + .long 0x2f24da32,0x3df6ad27 + .long 0xca600000,0x3ff551a4 + .long 0xd689ceff,0xbdc36f89 + .long 0xde000000,0x3ff56070 + .long 0x43edb85a,0xbdf6ef2e + .long 0x36800000,0x3ff56f47 + .long 0x33765802,0x3e0a93ed + .long 0xdbc00000,0x3ff57e27 + .long 0x5e8ce6eb,0x3e016267 + .long 0xd4800000,0x3ff58d12 + .long 0x252bc2b7,0x3df7c7fd + .long 0x28000000,0x3ff59c08 + .long 0xf1677234,0xbdaf068b + .long 0xdd400000,0x3ff5ab07 + .long 0xb192602a,0x3de0a852 + .long 0xfb800000,0x3ff5ba11 + .long 0x4910bd68,0x3e043d01 + .long 0x8a400000,0x3ff5c926 + .long 0x01c4b1b8,0x3df946b7 + .long 0x90800000,0x3ff5d845 + .long 0x8ca5615d,0x3df98b92 + .long 0x15800000,0x3ff5e76f + .long 0x374df261,0x3e0690a4 + .long 0x20c00000,0x3ff5f6a3 + .long 0xcc2a4438,0x3dfceb70 + .long 0xb9800000,0x3ff605e1 + .long 0x9f1214db,0xbde247ee + .long 0xe6c00000,0x3ff6152a + .long 0xf259f256,0x3debede8 + .long 0xb0400000,0x3ff6247e + .long 0x383c17e4,0xbdd6a9ed + .long 0x1d000000,0x3ff633dd + .long 0x611c42fb,0x3df929fd + .long 0x34c00000,0x3ff64346 + .long 0x8edf0e2a,0x3de9863f + .long 0xfec00000,0x3ff652b9 + .long 0x5c7ab935,0xbdcb824b + .long 0x82400000,0x3ff66238 + .long 0x9127d9e3,0x3df52224 + .long 0xc7000000,0x3ff671c1 + .long 0x85e3369e,0x3de067eb + .long 0xd4400000,0x3ff68155 + .long 0x1038ae45,0x3de952e6 + .long 0xb1c00000,0x3ff690f4 + .long 0xe7fb4265,0xbe00b563 + .long 0x66800000,0x3ff6a09e + .long 0xee9a09d9,0xbda8866d + .type __libm_expl_table_256,@object + .size __libm_expl_table_256,4112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/expm1_wmt.S b/external/sgx_libm/ia32/expm1_wmt.S new file mode 100644 index 0000000000..6a5235a8eb --- /dev/null +++ b/external/sgx_libm/ia32/expm1_wmt.S @@ -0,0 +1,703 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expm1_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin expm1 + .text + .align 16,0x90 + .globl expm1 +expm1: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + unpcklpd %xmm0, %xmm0 + movapd 64(%ebx), %xmm1 + movapd 48(%ebx), %xmm6 + movapd 80(%ebx), %xmm2 + movapd 96(%ebx), %xmm3 + pextrw $3, %xmm0, %eax + andl $32767, %eax + movl $16527, %edx + subl %eax, %edx + subl $16304, %eax + orl %eax, %edx + cmpl $-2147483648, %edx + jae .L_2TAG_PACKET_0.0.3 + mulpd %xmm0, %xmm1 + addpd %xmm6, %xmm1 + movapd %xmm1, %xmm7 + subpd %xmm6, %xmm1 + mulpd %xmm1, %xmm2 + movapd 112(%ebx), %xmm4 + mulpd %xmm1, %xmm3 + movapd 128(%ebx), %xmm5 + subpd %xmm2, %xmm0 + movd %xmm7, %eax + movl %eax, %ecx + andl $63, %ecx + shll $4, %ecx + sarl $6, %eax + movl %eax, %edx + subpd %xmm3, %xmm0 + movapd 160(%ebx,%ecx), %xmm2 + movsd 144(%ebx), %xmm3 + mulpd %xmm0, %xmm4 + movapd %xmm0, %xmm1 + mulpd %xmm0, %xmm0 + mulsd %xmm0, %xmm3 + addpd %xmm4, %xmm5 + mulsd %xmm0, %xmm0 + movapd %xmm2, %xmm4 + unpckhpd %xmm2, %xmm2 + movdqa 16(%ebx), %xmm6 + pand %xmm6, %xmm7 + movdqa 32(%ebx), %xmm6 + paddq %xmm6, %xmm7 + psllq $46, %xmm7 + mulsd %xmm0, %xmm3 + mulpd %xmm5, %xmm0 + addsd %xmm3, %xmm0 + addl $894, %edx + cmpl $1916, %edx + ja .L_2TAG_PACKET_1.0.3 + xorpd %xmm3, %xmm3 + movl $16368, %eax + pinsrw $3, %eax, %xmm3 + orpd %xmm7, %xmm2 + mulsd %xmm4, %xmm7 + movapd %xmm3, %xmm6 + addsd %xmm1, %xmm3 + pextrw $3, %xmm2, %edx + pshufd $238, %xmm0, %xmm5 + psrlq $38, %xmm3 + psllq $38, %xmm3 + movapd %xmm2, %xmm4 + subsd %xmm3, %xmm6 + addsd %xmm5, %xmm0 + addsd %xmm6, %xmm1 + addsd %xmm7, %xmm4 + mulsd %xmm3, %xmm7 + mulsd %xmm2, %xmm3 + xorpd %xmm5, %xmm5 + movl $16368, %eax + pinsrw $3, %eax, %xmm5 + addsd %xmm1, %xmm0 + movl $17184, %ecx + subl %edx, %ecx + subl $16256, %edx + orl %edx, %ecx + jl .L_2TAG_PACKET_2.0.3 + mulsd %xmm4, %xmm0 + subsd %xmm5, %xmm3 + addsd %xmm7, %xmm0 + addsd %xmm3, %xmm0 +.L_2TAG_PACKET_3.0.3: + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_2.0.3: + cmpl $0, %edx + jl .L_2TAG_PACKET_5.0.3 + mulsd %xmm4, %xmm0 + subsd %xmm5, %xmm7 + addsd %xmm7, %xmm0 + addsd %xmm3, %xmm0 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_5.0.3: + mulsd %xmm4, %xmm0 + addsd %xmm7, %xmm0 + addsd %xmm3, %xmm0 + subsd %xmm5, %xmm0 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_1.0.3: + movl 132(%esp), %ecx + addsd %xmm0, %xmm1 + unpckhpd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + cmpl $0, %ecx + jl .L_2TAG_PACKET_6.0.3 + fstcw 24(%esp) + movzwl 24(%esp), %edx + orl $768, %edx + movw %dx, 28(%esp) + fldcw 28(%esp) + movl %eax, %edx + sarl $1, %eax + subl %eax, %edx + movdqa (%ebx), %xmm6 + pandn %xmm2, %xmm6 + addl $1023, %eax + movd %eax, %xmm3 + psllq $52, %xmm3 + orpd %xmm3, %xmm6 + mulsd %xmm3, %xmm4 + movsd %xmm0, 8(%esp) + fldl 8(%esp) + movsd %xmm6, 16(%esp) + fldl 16(%esp) + movsd %xmm4, 16(%esp) + fldl 16(%esp) + addl $1023, %edx + movd %edx, %xmm4 + psllq $52, %xmm4 + faddp %st, %st(1) + fmul %st, %st(1) + faddp %st, %st(1) + movsd %xmm4, 8(%esp) + fldl 8(%esp) + fmulp %st, %st(1) + fstpl 8(%esp) + movsd 8(%esp), %xmm0 + fldcw 24(%esp) + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl $32752, %ecx + jae .L_2TAG_PACKET_7.0.3 + jmp .L_2TAG_PACKET_4.0.3 + cmpl $-2147483648, %ecx + jb .L_2TAG_PACKET_7.0.3 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_7.0.3: + movl $41, %edx +.L_2TAG_PACKET_8.0.3: + movsd %xmm0, (%esp) + movsd 128(%esp), %xmm0 + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_10.0.3: + cmpl $2146435072, %eax + jae .L_2TAG_PACKET_11.0.3 + movsd 1272(%ebx), %xmm0 + mulsd %xmm0, %xmm0 + movl $41, %edx + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_11.0.3: + movl 132(%esp), %eax + movl 128(%esp), %edx + movl %eax, %ecx + andl $2147483647, %eax + cmpl $2146435072, %eax + ja .L_2TAG_PACKET_12.0.3 + cmpl $0, %edx + jne .L_2TAG_PACKET_12.0.3 + cmpl $0, %ecx + jl .L_2TAG_PACKET_13.0.3 + movsd 1256(%ebx), %xmm0 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_13.0.3: + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_12.0.3: + movsd 128(%esp), %xmm0 + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_14.0.3: + addl $16304, %eax + cmpl $15504, %eax + jb .L_2TAG_PACKET_15.0.3 + movapd 1184(%ebx), %xmm2 + pshufd $68, %xmm0, %xmm1 + movapd 1200(%ebx), %xmm3 + movapd 1216(%ebx), %xmm4 + movsd 1232(%ebx), %xmm5 + mulsd %xmm1, %xmm1 + xorpd %xmm6, %xmm6 + movl $16352, %eax + pinsrw $3, %eax, %xmm6 + mulpd %xmm0, %xmm2 + xorpd %xmm7, %xmm7 + movl $16368, %edx + pinsrw $3, %edx, %xmm7 + addpd %xmm3, %xmm2 + mulsd %xmm1, %xmm5 + pshufd $228, %xmm1, %xmm3 + mulpd %xmm1, %xmm1 + mulsd %xmm0, %xmm6 + mulpd %xmm0, %xmm2 + addpd %xmm4, %xmm2 + movapd %xmm7, %xmm4 + addsd %xmm6, %xmm7 + mulpd %xmm3, %xmm1 + psrlq $27, %xmm7 + psllq $27, %xmm7 + movsd 1288(%ebx), %xmm3 + subsd %xmm7, %xmm4 + mulpd %xmm1, %xmm2 + addsd %xmm4, %xmm6 + pshufd $238, %xmm2, %xmm1 + addsd %xmm2, %xmm6 + andpd %xmm0, %xmm3 + movapd %xmm0, %xmm4 + addsd %xmm6, %xmm1 + subsd %xmm3, %xmm0 + addsd %xmm5, %xmm1 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm0 + mulsd %xmm1, %xmm4 + addsd %xmm4, %xmm0 + addsd %xmm3, %xmm0 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_15.0.3: + cmpl $16, %eax + jae .L_2TAG_PACKET_3.0.3 + movapd %xmm0, %xmm2 + movd %xmm0, %eax + psrlq $31, %xmm2 + movd %xmm2, %ecx + orl %ecx, %eax + je .L_2TAG_PACKET_3.0.3 + movl $16, %edx + xorpd %xmm1, %xmm1 + pinsrw $3, %edx, %xmm1 + mulsd %xmm1, %xmm1 + movl $42, %edx + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_0.0.3: + cmpl $0, %eax + jl .L_2TAG_PACKET_14.0.3 + movl 132(%esp), %eax + cmpl $1083179008, %eax + jge .L_2TAG_PACKET_10.0.3 + cmpl $-1048576, %eax + jae .L_2TAG_PACKET_11.0.3 +.L_2TAG_PACKET_6.0.3: + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_4.0.3: + movsd %xmm0, 48(%esp) + fldl 48(%esp) +.L_2TAG_PACKET_9.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type expm1,@function + .size expm1,.-expm1 + .data +# -- End expm1 + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 4293918720 + .long 0 + .long 4293918720 + .long 4294967232 + .long 0 + .long 4294967232 + .long 0 + .long 65472 + .long 0 + .long 65472 + .long 0 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 1697350398 + .long 1079448903 + .long 1697350398 + .long 1079448903 + .long 4277796864 + .long 1065758274 + .long 4277796864 + .long 1065758274 + .long 3164486458 + .long 1025308570 + .long 3164486458 + .long 1025308570 + .long 1963358694 + .long 1065423121 + .long 1431655765 + .long 1069897045 + .long 1431655765 + .long 1067799893 + .long 0 + .long 1071644672 + .long 381774871 + .long 1062650220 + .long 381774871 + .long 1062650220 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1000070955 + .long 1042145304 + .long 1040187392 + .long 11418 + .long 988267849 + .long 1039500660 + .long 3539992576 + .long 22960 + .long 36755401 + .long 1042114290 + .long 402653184 + .long 34629 + .long 3634769483 + .long 1042178627 + .long 1820327936 + .long 46424 + .long 2155991225 + .long 1041560680 + .long 847249408 + .long 58348 + .long 2766913307 + .long 1039293264 + .long 3489660928 + .long 70401 + .long 3651174602 + .long 1040488175 + .long 2927624192 + .long 82586 + .long 3073892131 + .long 1042240606 + .long 1006632960 + .long 94904 + .long 1328391742 + .long 1042019037 + .long 3942645760 + .long 107355 + .long 2650893825 + .long 1041903210 + .long 822083584 + .long 119943 + .long 2397289153 + .long 1041802037 + .long 2281701376 + .long 132667 + .long 430997175 + .long 1042110606 + .long 1845493760 + .long 145530 + .long 1230936525 + .long 1041801015 + .long 1702887424 + .long 158533 + .long 740675935 + .long 1040178913 + .long 4110417920 + .long 171677 + .long 3489810261 + .long 1041825986 + .long 2793406464 + .long 184965 + .long 2532600530 + .long 1040767882 + .long 167772160 + .long 198398 + .long 3542557060 + .long 1041827263 + .long 2986344448 + .long 211976 + .long 1401563777 + .long 1041061093 + .long 922746880 + .long 225703 + .long 3129406026 + .long 1041852413 + .long 880803840 + .long 239579 + .long 900993572 + .long 1039283234 + .long 1275068416 + .long 253606 + .long 2115029358 + .long 1042140042 + .long 562036736 + .long 267786 + .long 1086643152 + .long 1041785419 + .long 1610612736 + .long 282120 + .long 82864366 + .long 1041256244 + .long 3045064704 + .long 296610 + .long 2392968152 + .long 1040913683 + .long 3573547008 + .long 311258 + .long 2905856183 + .long 1040002214 + .long 1988100096 + .long 326066 + .long 3742008261 + .long 1040011137 + .long 1451229184 + .long 341035 + .long 863393794 + .long 1040880621 + .long 914358272 + .long 356167 + .long 1446136837 + .long 1041372426 + .long 3707764736 + .long 371463 + .long 927855201 + .long 1040617636 + .long 360710144 + .long 386927 + .long 1492679939 + .long 1041050306 + .long 2952790016 + .long 402558 + .long 608827001 + .long 1041582217 + .long 2181038080 + .long 418360 + .long 606260204 + .long 1042271987 + .long 1711276032 + .long 434334 + .long 3163044019 + .long 1041843851 + .long 1006632960 + .long 450482 + .long 4148747325 + .long 1041962972 + .long 3900702720 + .long 466805 + .long 802924201 + .long 1041275378 + .long 1442840576 + .long 483307 + .long 3052749833 + .long 1041940577 + .long 1937768448 + .long 499988 + .long 2216116399 + .long 1041486744 + .long 914358272 + .long 516851 + .long 2729697836 + .long 1041445764 + .long 2566914048 + .long 533897 + .long 540608356 + .long 1041310907 + .long 2600468480 + .long 551129 + .long 2916344493 + .long 1040535661 + .long 1107296256 + .long 568549 + .long 731391814 + .long 1039497014 + .long 2566914048 + .long 586158 + .long 1024722704 + .long 1041461625 + .long 2961178624 + .long 603959 + .long 3806831748 + .long 1041732499 + .long 2675965952 + .long 621954 + .long 238953304 + .long 1040316488 + .long 2189426688 + .long 640145 + .long 749123235 + .long 1041725785 + .long 2063597568 + .long 658534 + .long 1168187977 + .long 1041175214 + .long 2986344448 + .long 677123 + .long 3506096399 + .long 1042186095 + .long 1426063360 + .long 695915 + .long 1470221620 + .long 1041675499 + .long 2566914048 + .long 714911 + .long 3182425146 + .long 1041483134 + .long 3087007744 + .long 734114 + .long 3131698208 + .long 1042208657 + .long 4068474880 + .long 753526 + .long 2300504125 + .long 1041428596 + .long 2415919104 + .long 773150 + .long 2290297931 + .long 1037388400 + .long 3716153344 + .long 792987 + .long 3532148223 + .long 1041626194 + .long 771751936 + .long 813041 + .long 1161884404 + .long 1042015258 + .long 3699376128 + .long 833312 + .long 876383176 + .long 1037968878 + .long 1241513984 + .long 853805 + .long 3379986796 + .long 1042213153 + .long 3699376128 + .long 874520 + .long 1545797737 + .long 1041681569 + .long 58720256 + .long 895462 + .long 2925146801 + .long 1042212567 + .long 855638016 + .long 916631 + .long 1316627971 + .long 1038516204 + .long 3883925504 + .long 938030 + .long 3267869137 + .long 1040337004 + .long 2726297600 + .long 959663 + .long 3720868999 + .long 1041782409 + .long 3992977408 + .long 981531 + .long 433316142 + .long 1041994064 + .long 1526726656 + .long 1003638 + .long 781232103 + .long 1040093400 + .long 2172649472 + .long 1025985 + .long 2773927732 + .long 1053236707 + .long 381774871 + .long 1062650220 + .long 379653899 + .long 1056571845 + .long 286331153 + .long 1065423121 + .long 436314138 + .long 1059717536 + .long 1431655765 + .long 1067799893 + .long 1431655765 + .long 1069897045 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 4294967295 + .long 2146435071 + .long 0 + .long 1048576 + .long 4227858432 + .long 4294967295 + .type static_const_table,@object + .size static_const_table,1296 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/expm1f_wmt.S b/external/sgx_libm/ia32/expm1f_wmt.S new file mode 100644 index 0000000000..72ccdac276 --- /dev/null +++ b/external/sgx_libm/ia32/expm1f_wmt.S @@ -0,0 +1,808 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expm1f_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin expm1f + .text + .align 16,0x90 + .globl expm1f +expm1f: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %ecx + movsd 2112(%ebx), %xmm3 + xorpd %xmm7, %xmm7 + movl $17208, %eax + pinsrw $3, %eax, %xmm7 + cvtps2pd %xmm0, %xmm1 + movl %ecx, %edx + andl $2147483647, %ecx + subl $1043662067, %ecx + cmpl $74990712, %ecx + jae .L_2TAG_PACKET_0.0.3 + movsd 2096(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + movapd %xmm7, %xmm2 + xorpd %xmm1, %xmm1 + addsd %xmm3, %xmm7 + movsd 2104(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + subsd %xmm1, %xmm0 + cvtpd2ps %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + addl $1043662067, %ecx + cmpl $1043662067, %ecx + jb .L_2TAG_PACKET_2.0.3 + cmpl $0, %edx + jl .L_2TAG_PACKET_3.0.3 + cmpl $1124073472, %ecx + jae .L_2TAG_PACKET_4.0.3 + movsd 2096(%ebx), %xmm6 + mulsd %xmm1, %xmm3 + movapd %xmm7, %xmm2 + xorpd %xmm1, %xmm1 + addsd %xmm3, %xmm7 + movsd 2104(%ebx), %xmm5 + movd %xmm7, %eax + subsd %xmm7, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + xorpd %xmm4, %xmm4 + movl %eax, %ecx + andl $255, %eax + movsd (%ebx,%eax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movd %xmm0, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $2139095040, %ecx + jae .L_2TAG_PACKET_6.0.3 + movl $2130706432, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_5.0.3: + movl $43, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_2.0.3: + cmpl $855638016, %ecx + jb .L_2TAG_PACKET_9.0.3 + cmpl $998244352, %ecx + jb .L_2TAG_PACKET_10.0.3 + movapd 2048(%ebx), %xmm2 + pshufd $68, %xmm1, %xmm0 + pshufd $68, %xmm1, %xmm1 + movapd 2064(%ebx), %xmm4 + mulpd %xmm0, %xmm2 + mulpd %xmm1, %xmm1 + pshufd $68, %xmm0, %xmm7 + addpd %xmm4, %xmm2 + movapd 2080(%ebx), %xmm6 + mulsd %xmm1, %xmm7 + mulpd %xmm0, %xmm2 + mulsd %xmm7, %xmm1 + addpd %xmm6, %xmm2 + mulpd %xmm1, %xmm2 + pshufd $238, %xmm2, %xmm3 + addsd %xmm3, %xmm2 + addsd %xmm2, %xmm0 + cvtpd2ps %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_10.0.3: + movl $1042983595, %eax + movd %eax, %xmm2 + movss %xmm0, %xmm1 + movl $1056964608, %edx + movd %edx, %xmm3 + mulss %xmm0, %xmm2 + mulss %xmm1, %xmm1 + addss %xmm3, %xmm2 + mulss %xmm1, %xmm2 + addss %xmm2, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_9.0.3: + cmpl $8388608, %ecx + jb .L_2TAG_PACKET_11.0.3 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_11.0.3: + cmpl $0, %ecx + je .L_2TAG_PACKET_1.0.3 + movl $8388608, %eax + movd %eax, %xmm2 + mulss %xmm2, %xmm2 + movl $44, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $2139095040, %ecx + ja .L_2TAG_PACKET_6.0.3 + movl $-1082130432, %edx + movd %edx, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_6.0.3: + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_1.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type expm1f,@function + .size expm1f,.-expm1f + .data +# -- End expm1f + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 4200250559 + .long 1072696090 + .long 2851812149 + .long 1072698941 + .long 339411585 + .long 1072701800 + .long 1048019041 + .long 1072704666 + .long 772914124 + .long 1072707540 + .long 3899555717 + .long 1072710421 + .long 1928746161 + .long 1072713311 + .long 3541402996 + .long 1072716208 + .long 238821257 + .long 1072719114 + .long 702412510 + .long 1072722027 + .long 728934454 + .long 1072724948 + .long 410360776 + .long 1072727877 + .long 4133881824 + .long 1072730813 + .long 3402036099 + .long 1072733758 + .long 2602514713 + .long 1072736711 + .long 1828292879 + .long 1072739672 + .long 1172597893 + .long 1072742641 + .long 728909815 + .long 1072745618 + .long 590962156 + .long 1072748603 + .long 852742562 + .long 1072751596 + .long 1608493509 + .long 1072754597 + .long 2952712987 + .long 1072757606 + .long 685187902 + .long 1072760624 + .long 3490863953 + .long 1072763649 + .long 2875075254 + .long 1072766683 + .long 3228316108 + .long 1072769725 + .long 351405227 + .long 1072772776 + .long 2930322912 + .long 1072775834 + .long 2471440686 + .long 1072778901 + .long 3366293073 + .long 1072781976 + .long 1416741826 + .long 1072785060 + .long 1014845819 + .long 1072788152 + .long 2257959872 + .long 1072791252 + .long 948735466 + .long 1072794361 + .long 1480023343 + .long 1072797478 + .long 3949972341 + .long 1072800603 + .long 4162030108 + .long 1072803737 + .long 2214878420 + .long 1072806880 + .long 2502433899 + .long 1072810031 + .long 828946858 + .long 1072813191 + .long 1588871207 + .long 1072816359 + .long 586995997 + .long 1072819536 + .long 2218315341 + .long 1072822721 + .long 2288159958 + .long 1072825915 + .long 897099801 + .long 1072829118 + .long 2440944790 + .long 1072832329 + .long 2725843665 + .long 1072835549 + .long 1853186616 + .long 1072838778 + .long 4219606026 + .long 1072842015 + .long 1337108031 + .long 1072845262 + .long 1897844341 + .long 1072848517 + .long 1709341917 + .long 1072851781 + .long 874372905 + .long 1072855054 + .long 3790955393 + .long 1072858335 + .long 1972484976 + .long 1072861626 + .long 4112506593 + .long 1072864925 + .long 1724976915 + .long 1072868234 + .long 3504003472 + .long 1072871551 + .long 964107055 + .long 1072874878 + .long 2799960843 + .long 1072878213 + .long 526652809 + .long 1072881558 + .long 2839424854 + .long 1072884911 + .long 1253935211 + .long 1072888274 + .long 171030293 + .long 1072891646 + .long 3991843581 + .long 1072895026 + .long 4232894513 + .long 1072898416 + .long 1000925746 + .long 1072901816 + .long 2992903935 + .long 1072905224 + .long 1726216749 + .long 1072908642 + .long 1603444721 + .long 1072912069 + .long 2732492859 + .long 1072915505 + .long 926591435 + .long 1072918951 + .long 589198666 + .long 1072922406 + .long 1829099622 + .long 1072925870 + .long 460407023 + .long 1072929344 + .long 887463927 + .long 1072932827 + .long 3219942644 + .long 1072936319 + .long 3272845541 + .long 1072939821 + .long 1156440435 + .long 1072943333 + .long 1276261410 + .long 1072946854 + .long 3743175029 + .long 1072950384 + .long 78413852 + .long 1072953925 + .long 3278348324 + .long 1072957474 + .long 569847338 + .long 1072961034 + .long 654919306 + .long 1072964603 + .long 3645941911 + .long 1072968181 + .long 1065662932 + .long 1072971770 + .long 1617004845 + .long 1072975368 + .long 1118294578 + .long 1072978976 + .long 3978100823 + .long 1072982593 + .long 1720398391 + .long 1072986221 + .long 3049340112 + .long 1072989858 + .long 3784486610 + .long 1072993505 + .long 4040676318 + .long 1072997162 + .long 3933059031 + .long 1073000829 + .long 3577096743 + .long 1073004506 + .long 3088564500 + .long 1073008193 + .long 2583551245 + .long 1073011890 + .long 2178460671 + .long 1073015597 + .long 1990012071 + .long 1073019314 + .long 2135241198 + .long 1073023041 + .long 2731501122 + .long 1073026778 + .long 3896463087 + .long 1073030525 + .long 1453150082 + .long 1073034283 + .long 4109806887 + .long 1073038050 + .long 3395129871 + .long 1073041828 + .long 3723038930 + .long 1073045616 + .long 917841882 + .long 1073049415 + .long 3689071823 + .long 1073053223 + .long 3566716925 + .long 1073057042 + .long 671025100 + .long 1073060872 + .long 3712504873 + .long 1073064711 + .long 4222122499 + .long 1073068561 + .long 2321106615 + .long 1073072422 + .long 2425981843 + .long 1073076293 + .long 363667784 + .long 1073080175 + .long 551349105 + .long 1073084067 + .long 3111574537 + .long 1073087969 + .long 3872257780 + .long 1073091882 + .long 2956612997 + .long 1073095806 + .long 488188413 + .long 1073099741 + .long 885834528 + .long 1073103686 + .long 4273770423 + .long 1073107641 + .long 2186617381 + .long 1073111608 + .long 3339203574 + .long 1073115585 + .long 3561793907 + .long 1073119573 + .long 2979960120 + .long 1073123572 + .long 1719614413 + .long 1073127582 + .long 4201977662 + .long 1073131602 + .long 1963711167 + .long 1073135634 + .long 3721688645 + .long 1073139676 + .long 1013258799 + .long 1073143730 + .long 2555984613 + .long 1073147794 + .long 4182873220 + .long 1073151869 + .long 1727278727 + .long 1073155956 + .long 3907805044 + .long 1073160053 + .long 2263535754 + .long 1073164162 + .long 1218806132 + .long 1073168282 + .long 903334909 + .long 1073172413 + .long 1447192521 + .long 1073176555 + .long 2980802057 + .long 1073180708 + .long 1339972927 + .long 1073184873 + .long 950803702 + .long 1073189049 + .long 1944781191 + .long 1073193236 + .long 158781403 + .long 1073197435 + .long 19972402 + .long 1073201645 + .long 1660913392 + .long 1073205866 + .long 919555682 + .long 1073210099 + .long 2224145553 + .long 1073214343 + .long 1413356050 + .long 1073218599 + .long 2916157145 + .long 1073222866 + .long 2571947539 + .long 1073227145 + .long 515457527 + .long 1073231436 + .long 1176749997 + .long 1073235738 + .long 396319521 + .long 1073240052 + .long 2604962541 + .long 1073244377 + .long 3643909174 + .long 1073248714 + .long 3649726105 + .long 1073253063 + .long 2759350287 + .long 1073257424 + .long 1110089947 + .long 1073261797 + .long 3134592888 + .long 1073266181 + .long 380978316 + .long 1073270578 + .long 1577608921 + .long 1073274986 + .long 2568320822 + .long 1073279406 + .long 3492293770 + .long 1073283838 + .long 194117574 + .long 1073288283 + .long 1403662306 + .long 1073292739 + .long 2966275557 + .long 1073297207 + .long 727685349 + .long 1073301688 + .long 3418903055 + .long 1073306180 + .long 2591453363 + .long 1073310685 + .long 2682146384 + .long 1073315202 + .long 3833209506 + .long 1073319731 + .long 1892288442 + .long 1073324273 + .long 1297350157 + .long 1073328827 + .long 2191782032 + .long 1073333393 + .long 424392917 + .long 1073337972 + .long 434316067 + .long 1073342563 + .long 2366108318 + .long 1073347166 + .long 2069751141 + .long 1073351782 + .long 3985553595 + .long 1073356410 + .long 3964284211 + .long 1073361051 + .long 2152073944 + .long 1073365705 + .long 2990417245 + .long 1073370371 + .long 2331271250 + .long 1073375050 + .long 321958744 + .long 1073379742 + .long 1405169241 + .long 1073384446 + .long 1434058175 + .long 1073389163 + .long 557149882 + .long 1073393893 + .long 3218338682 + .long 1073398635 + .long 977020788 + .long 1073403391 + .long 2572866477 + .long 1073408159 + .long 3861050111 + .long 1073412940 + .long 697153126 + .long 1073417735 + .long 1822067026 + .long 1073422542 + .long 3092190715 + .long 1073427362 + .long 364333489 + .long 1073432196 + .long 2380618042 + .long 1073437042 + .long 703710506 + .long 1073441902 + .long 4076559943 + .long 1073446774 + .long 4062661092 + .long 1073451660 + .long 815859274 + .long 1073456560 + .long 3080351519 + .long 1073461472 + .long 2420883922 + .long 1073466398 + .long 3287523847 + .long 1073471337 + .long 1540824585 + .long 1073476290 + .long 1631695677 + .long 1073481256 + .long 3716502172 + .long 1073486235 + .long 3657065772 + .long 1073491228 + .long 1610600570 + .long 1073496235 + .long 2029714210 + .long 1073501255 + .long 777507147 + .long 1073506289 + .long 2307442995 + .long 1073511336 + .long 2483480501 + .long 1073516397 + .long 1464976603 + .long 1073521472 + .long 3706687593 + .long 1073526560 + .long 778901109 + .long 1073531663 + .long 1432208378 + .long 1073536779 + .long 1532734324 + .long 1073541909 + .long 1242007932 + .long 1073547053 + .long 721996136 + .long 1073552211 + .long 135105010 + .long 1073557383 + .long 3939148246 + .long 1073562568 + .long 3707479175 + .long 1073567768 + .long 3898795731 + .long 1073572982 + .long 382305176 + .long 1073578211 + .long 1912561781 + .long 1073583453 + .long 64696965 + .long 1073588710 + .long 3594158869 + .long 1073593980 + .long 4076975200 + .long 1073599265 + .long 1679558232 + .long 1073604565 + .long 863738719 + .long 1073609879 + .long 1796832535 + .long 1073615207 + .long 351641897 + .long 1073620550 + .long 991358482 + .long 1073625907 + .long 3884662774 + .long 1073631278 + .long 610758006 + .long 1073636665 + .long 4224142467 + .long 1073642065 + .long 2009970496 + .long 1073647481 + .long 2728693978 + .long 1073652911 + .long 2256325230 + .long 1073658356 + .long 764307441 + .long 1073663816 + .long 2719515920 + .long 1073669290 + .long 3999357479 + .long 1073674779 + .long 481706282 + .long 1073680284 + .long 929806999 + .long 1073685803 + .long 1222472308 + .long 1073691337 + .long 1533953344 + .long 1073696886 + .long 2038973688 + .long 1073702450 + .long 2912730644 + .long 1073708029 + .long 35929225 + .long 1073713624 + .long 2174652632 + .long 1073719233 + .long 915592468 + .long 1073724858 + .long 730821105 + .long 1073730498 + .long 1797923801 + .long 1073736153 + .long 436314138 + .long 1059717536 + .long 1431655765 + .long 1067799893 + .long 872628277 + .long 1062650688 + .long 1431655765 + .long 1069897045 + .long 286331153 + .long 1065423121 + .long 0 + .long 1071644672 + .long 4286760334 + .long 1053736893 + .long 4277826245 + .long 1063661122 + .long 1697350398 + .long 1081546055 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,2136 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/expm1l.S b/external/sgx_libm/ia32/expm1l.S new file mode 100644 index 0000000000..f10c63d328 --- /dev/null +++ b/external/sgx_libm/ia32/expm1l.S @@ -0,0 +1,1235 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expm1l.c" + .text +..TXTST0: +# -- Begin expm1l + .text + .align 16,0x90 + .globl expm1l +expm1l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $68, %esp +..B1.2: + fnstcw 58(%esp) +..B1.3: + movzwl 16(%ebp), %ebx + andl $32767, %ebx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $16389, %ebx + jge ..B1.55 +..B1.4: + movzwl 58(%esp), %eax + cmpl $16381, %ebx + jge ..B1.45 +..B1.5: + cmpl $16370, %ebx + jge ..B1.38 +..B1.6: + cmpl $16359, %ebx + jge ..B1.31 +..B1.7: + cmpl $16345, %ebx + jge ..B1.24 +..B1.8: + cmpl $16308, %ebx + jge ..B1.18 +..B1.9: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.88 +..B1.10: + orl $-64768, %eax + movw %ax, 56(%esp) +..B1.11: + fldcw 56(%esp) +..B1.12: + movzwl 16(%ebp), %ebx + movl $1, %edx + andl $32767, %ebx +..B1.13: + testl %ebx, %ebx + jle ..B1.84 +..B1.14: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ecx) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmul %st(1), %st + fxch %st(1) + fmull ones@GOTOFF(%ecx,%eax,8) + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ecx) + fstpt 16(%esp) +..B1.15: + testl %edx, %edx + je ..B1.17 +..B1.16: + fldcw 58(%esp) +..B1.17: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.89 +..B1.19: + orl $-64768, %eax + movw %ax, 56(%esp) +..B1.20: + fldcw 56(%esp) +..B1.21: + fldt 8(%ebp) + fldt _Q3@GOTOFF(%ecx) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) +..B1.22: + fldcw 58(%esp) +..B1.23: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.24: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.90 +..B1.25: + orl $-64768, %eax + movw %ax, 56(%esp) +..B1.26: + fldcw 56(%esp) +..B1.27: + movl $1, %eax +..B1.28: + fldt 8(%ebp) + testl %eax, %eax + fldt 12+_Q2@GOTOFF(%ecx) + fmul %st(1), %st + fmul %st(1), %st + fldt _Q2@GOTOFF(%ecx) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.30 +..B1.29: + fldcw 58(%esp) +..B1.30: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.91 +..B1.32: + orl $-64768, %eax + movw %ax, 56(%esp) +..B1.33: + fldcw 56(%esp) +..B1.34: + movl $1, %eax +..B1.35: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%ecx) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%ecx) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.37 +..B1.36: + fldcw 58(%esp) +..B1.37: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.92 +..B1.39: + orl $-64768, %eax + movw %ax, 56(%esp) +..B1.40: + fldcw 56(%esp) +..B1.41: + movl $1, %eax +..B1.42: + fldl _TWO_54H@GOTOFF(%ecx) + testl %eax, %eax + fld %st(0) + fldt 8(%ebp) + fld %st(0) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + fsubp %st, %st(3) + fsub %st(2), %st + fld %st(1) + fmul %st(2), %st + fldt 156+_Q@GOTOFF(%ecx) + fmul %st(1), %st + fldt 144+_Q@GOTOFF(%ecx) + fmul %st(2), %st + fldt 132+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_Q@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fld %st(4) + fmul %st(3), %st + fld %st(4) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(5) + fldt _Q@GOTOFF(%ecx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(3) + fld %st(5) + fmul %st(6), %st + fmul %st, %st(2) + fld %st(4) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(2) + fldt 192+_Q@GOTOFF(%ecx) + fmul %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fld %st(3) + fldt 180+_Q@GOTOFF(%ecx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(2) + fldt 168+_Q@GOTOFF(%ecx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fmulp %st, %st(2) + fldt 8(%ebp) + fld %st(0) + fadd %st(4), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fsubr %st, %st(1) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%esp) + je ..B1.44 +..B1.43: + fldt 16(%esp) + fstpt 44(%esp) +..B1.103: + fldcw 58(%esp) +..B1.44: + fldt 32(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.93 +..B1.46: + orl $-64768, %eax + movw %ax, 56(%esp) +..B1.47: + fldcw 56(%esp) +..B1.48: + movl $1, %eax +..B1.49: + fldl _TWO_63H@GOTOFF(%ecx) + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st(1), %st + fadd %st(2), %st + fstpt 44(%esp) + fldt 44(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmul %st(2), %st + movl 44(%esp), %edx + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + fmulp %st, %st(2) + fld %st(0) + movsbl %dl, %ebx + fsub %st(2), %st + fldl _TWO_32H@GOTOFF(%ecx) + subl %ebx, %edx + shll $4, %ebx + fadd %st, %st(1) + shrl $8, %edx + fsubr %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + shll $23, %edx + fxch %st(4) + fsubrp %st, %st(3) + addl $1065353216, %edx + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%ecx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ecx) + movl %edx, 12(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmul %st(2), %st + fldt 12+_P@GOTOFF(%ecx) + movzbl 17(%ebp), %edx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + andl $128, %edx + fmulp %st, %st(3) + shrl $7, %edx + faddp %st, %st(2) + fldt _P@GOTOFF(%ecx) + testl %edx, %edx + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fldl 2056+__libm_expl_table_256@GOTOFF(%ecx,%ebx) + fldl 2048+__libm_expl_table_256@GOTOFF(%ecx,%ebx) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(5), %st + fmul %st(2), %st + faddp %st, %st(4) + fmul %st, %st(4) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + flds 12(%esp) + fmul %st, %st(3) + fmulp %st, %st(2) + je ..B1.51 +..B1.50: + fldt .L_2il0floatpacket.4@GOTOFF(%ecx) + fadd %st(3), %st + fstpt 16(%esp) + fldt 16(%esp) + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + faddp %st, %st(1) + fsubp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + jmp ..B1.52 +..B1.51: + movzwl 16(%ebp), %esi + shll $15, %edx + andl $32767, %esi + orl %esi, %edx + shll $16, %edx + movzwl 14(%ebp), %edi + orl %edi, %edx + cmpl $1074049228, %edx + movl $0, %edx + setb %dl + fldl zero_one@GOTOFF(%ecx,%edx,8) + xorl $1, %edx + fsubrp %st, %st(3) + fxch %st(2) + fstpt 16(%esp) + fsubl zero_one@GOTOFF(%ecx,%edx,8) +..B1.52: + fldt 16(%esp) + testl %eax, %eax + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.107 +..B1.53: + fstpt 44(%esp) +..B1.104: + fldcw 58(%esp) + jmp ..B1.54 +..B1.107: + fstp %st(0) +..B1.54: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.55: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %eax + movzwl 8+_ranges@GOTOFF(%eax,%ecx), %esi + andl $32767, %esi + cmpl %esi, %ebx + jl ..B1.60 +..B1.56: + jne ..B1.74 +..B1.57: + movl 12(%ebp), %esi + cmpl 4+_ranges@GOTOFF(%eax,%ecx), %esi + jb ..B1.60 +..B1.58: + jne ..B1.74 +..B1.59: + movl 8(%ebp), %esi + cmpl _ranges@GOTOFF(%eax,%ecx), %esi + jae ..B1.74 +..B1.60: + movzwl 58(%esp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.94 +..B1.61: + orl $-64768, %esi + movw %si, 56(%esp) +..B1.62: + fldcw 56(%esp) +..B1.63: + movzwl 16(%ebp), %ebx + movl $1, %edi + andl $32767, %ebx +..B1.64: + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + cmpl $16396, %ebx + movzwl 8+.L_2il0floatpacket.3@GOTOFF(%ecx), %esi + movl %esi, 40(%esp) + fstpt 28(%esp) + fldt 28(%esp) + fldl _TWO_63H@GOTOFF(%ecx) + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st(1), %st + fadd %st(2), %st + fstpt 44(%esp) + fldt 44(%esp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmul %st(2), %st + movl 44(%esp), %eax + fsubrp %st, %st(1) + fld %st(0) + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + fmulp %st, %st(3) + fsub %st(2), %st + fldl _TWO_32H@GOTOFF(%ecx) + movsbl %al, %esi + fadd %st, %st(1) + fsubr %st(1), %st + fsubr %st, %st(2) + fxch %st(3) + fsubrp %st, %st(2) + jge ..B1.71 +..B1.65: + fldt 48+_P@GOTOFF(%ecx) + fxch %st(1) + fstpt 16(%esp) + fld %st(2) + fadd %st(2), %st + fld %st(0) + subl %esi, %eax + fmul %st(1), %st + fmul %st, %st(2) + fldt 36+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%ecx) + shll $4, %esi + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fmul %st, %st(3) + fldt 12+_P@GOTOFF(%ecx) + shrl $8, %eax + faddp %st, %st(2) + fmul %st, %st(1) + addl $16383, %eax + fxch %st(2) + fmulp %st, %st(1) + andl $32767, %eax + movl %edi, 12(%esp) + faddp %st, %st(2) + fldt _P@GOTOFF(%ecx) + fmulp %st, %st(1) + movl 40(%esp), %edi + faddp %st, %st(1) + andl $-32768, %edi + faddp %st, %st(1) + fldl 2048+__libm_expl_table_256@GOTOFF(%ecx,%esi) + orl %eax, %edi + fld %st(0) + testl %edx, %edx + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fld %st(0) + movw %di, 36(%esp) + fadd %st(4), %st + movl 12(%esp), %edi + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fldt 28(%esp) + fmul %st, %st(4) + fxch %st(2) + fmull 2056+__libm_expl_table_256@GOTOFF(%ecx,%esi) + faddp %st, %st(3) + faddl 2056+__libm_expl_table_256@GOTOFF(%ecx,%esi) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt 16(%esp) + je ..B1.67 +..B1.66: + fldt .L_2il0floatpacket.4@GOTOFF(%ecx) + fadd %st(3), %st + fstpt 16(%esp) + fldt 16(%esp) + faddp %st, %st(4) + fxch %st(2) + fsubrp %st, %st(3) + fsubp %st, %st(2) + fxch %st(1) + jmp ..B1.68 +..B1.67: + fstp %st(3) + movzbl 17(%ebp), %eax + xorl %edx, %edx + shrl $7, %eax + shll $15, %eax + orl %ebx, %eax + shll $16, %eax + movzwl 14(%ebp), %esi + orl %esi, %eax + cmpl $1074049228, %eax + setb %dl + fldl zero_one@GOTOFF(%ecx,%edx,8) + xorl $1, %edx + fsubrp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fsubl zero_one@GOTOFF(%ecx,%edx,8) +..B1.68: + fldt 16(%esp) + testl %edi, %edi + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.108 +..B1.69: + fstpt 44(%esp) +..B1.105: + fldcw 58(%esp) + jmp ..B1.70 +..B1.108: + fstp %st(0) +..B1.70: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.71: + fstp %st(3) + fldt 48+_P@GOTOFF(%ecx) + fld %st(2) + fadd %st(2), %st + fld %st(0) + subl %esi, %eax + fmul %st(1), %st + fmul %st, %st(2) + fldt 36+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%ecx) + shll $4, %esi + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fmul %st, %st(3) + fldt 12+_P@GOTOFF(%ecx) + shrl $8, %eax + faddp %st, %st(2) + fmul %st, %st(1) + addl $8191, %eax + fxch %st(2) + fmulp %st, %st(1) + andl $32767, %eax + movzwl 36(%esp), %edx + faddp %st, %st(2) + fldt _P@GOTOFF(%ecx) + andl $-32768, %edx + fmulp %st, %st(1) + orl %eax, %edx + movw %dx, 36(%esp) + testl %edi, %edi + faddp %st, %st(1) + faddp %st, %st(1) + fldl 2056+__libm_expl_table_256@GOTOFF(%ecx,%esi) + fldl 2048+__libm_expl_table_256@GOTOFF(%ecx,%esi) + fld %st(0) + fmul %st(3), %st + fxch %st(3) + fadd %st(4), %st + fmul %st(2), %st + faddp %st, %st(3) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 28(%esp) + fmulp %st, %st(1) + fldt _SC2@GOTOFF(%ecx) + fmulp %st, %st(1) + fstpt 16(%esp) + je ..B1.109 +..B1.72: + fstpt 44(%esp) +..B1.106: + fldcw 58(%esp) + jmp ..B1.73 +..B1.109: + fstp %st(0) +..B1.73: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.74: + movzwl 58(%esp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.100 +..B1.75: + orl $-64768, %esi + movw %si, 56(%esp) +..B1.76: + fldcw 56(%esp) +..B1.77: + movzwl 16(%ebp), %ebx + movl $1, %eax + andl $32767, %ebx +..B1.78: + cmpl $32767, %ebx + je ..B1.96 +..B1.79: + testl %edx, %edx + je ..B1.95 +..B1.80: + fldt .L_2il0floatpacket.4@GOTOFF(%ecx) + fldt _small_value_80@GOTOFF(%ecx) + faddp %st, %st(1) + fstpt 16(%esp) +..B1.81: + testl %eax, %eax + je ..B1.83 +..B1.82: + fldcw 58(%esp) +..B1.83: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.84: + cmpl $0, 12(%ebp) + jne ..B1.86 +..B1.85: + cmpl $0, 8(%ebp) + je ..B1.87 +..B1.86: + fldt _small_value_80@GOTOFF(%ecx) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmul %st(0), %st + fstpt (%esp) + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(1) + fmull ones@GOTOFF(%ecx,%eax,8) + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ecx) + fstpt 16(%esp) + jmp ..B1.15 +..B1.87: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.15 +..B1.88: + xorl %edx, %edx + jmp ..B1.13 +..B1.89: + fldt 8(%ebp) + fldt _Q3@GOTOFF(%ecx) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.23 +..B1.90: + xorl %eax, %eax + jmp ..B1.28 +..B1.91: + xorl %eax, %eax + jmp ..B1.35 +..B1.92: + xorl %eax, %eax + jmp ..B1.42 +..B1.93: + xorl %eax, %eax + jmp ..B1.49 +..B1.94: + xorl %edi, %edi + jmp ..B1.64 +..B1.95: + fldt _large_value_80@GOTOFF(%ecx) + fmul %st(0), %st + fstpt 16(%esp) + jmp ..B1.81 +..B1.96: + cmpl $-2147483648, 12(%ebp) + jne ..B1.99 +..B1.97: + cmpl $0, 8(%ebp) + jne ..B1.99 +..B1.98: + fldl _inf_none@GOTOFF(%ecx,%edx,8) + fstpt 16(%esp) + jmp ..B1.81 +..B1.99: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.81 +..B1.100: + xorl %eax, %eax + jmp ..B1.78 + .align 16,0x90 + .type expm1l,@function + .size expm1l,.-expm1l + .data +# -- End expm1l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +zero_one: + .long 0x00000000,0x00000000 + .long 0x00000000,0x3ff00000 + .type zero_one,@object + .size zero_one,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_54H: + .long 0 + .long 1129840640 + .type _TWO_54H,@object + .size _TWO_54H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_inf_none: + .long 0 + .long 2146435072 + .long 0 + .long 3220176896 + .type _inf_none,@object + .size _inf_none,16 + .align 2 +_Q3: + .word 1 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 2731 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 46967 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 65530 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 43687 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 52365 + .word 52428 + .word 43692 + .word 43690 + .word 16378 + .word 0 + .word 56491 + .word 10318 + .word 34954 + .word 34952 + .word 16376 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 39683 + .word 36691 + .word 42743 + .word 55145 + .word 16297 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16370 + .word 0 + .word 43680 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 46686 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .word 53372 + .word 3328 + .word 208 + .word 53261 + .word 16370 + .word 0 + .word 5395 + .word 3321 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 7401 + .word 46642 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 52768 + .word 7506 + .word 32188 + .word 37874 + .word 16361 + .word 0 + .word 23003 + .word 12485 + .word 11072 + .word 55090 + .word 16357 + .word 0 + .word 3702 + .word 18929 + .word 50035 + .word 36726 + .word 16354 + .word 0 + .word 2630 + .word 23096 + .word 11140 + .word 45202 + .word 16350 + .word 0 + .word 46660 + .word 62794 + .word 49270 + .word 51706 + .word 16346 + .word 0 + .word 61237 + .word 7998 + .word 19059 + .word 55154 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43648 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43648 + .word 16378 + .word 0 + .type _Q,@object + .size _Q,204 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_ranges: + .word 31148 + .word 53711 + .word 6135 + .word 45426 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16389 + .word 0 + .type _ranges,@object + .size _ranges,24 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .type _SC2,@object + .size _SC2,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fabs.S b/external/sgx_libm/ia32/fabs.S new file mode 100644 index 0000000000..93c7d46fa0 --- /dev/null +++ b/external/sgx_libm/ia32/fabs.S @@ -0,0 +1,61 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fabs.c" + .text +..TXTST0: +# -- Begin fabs + .text + .align 16,0x90 + .globl fabs +fabs: +# parameter 1: 4 + %esp +..B1.1: +..L1: + +..B1.2: + fldl 4(%esp) + fabs + ret +..B1.3: + .align 16,0x90 + .type fabs,@function + .size fabs,.-fabs + .data +# -- End fabs + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fabsf.S b/external/sgx_libm/ia32/fabsf.S new file mode 100644 index 0000000000..7cb3dfc071 --- /dev/null +++ b/external/sgx_libm/ia32/fabsf.S @@ -0,0 +1,61 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fabsf.c" + .text +..TXTST0: +# -- Begin fabsf + .text + .align 16,0x90 + .globl fabsf +fabsf: +# parameter 1: 4 + %esp +..B1.1: +..L1: + +..B1.2: + flds 4(%esp) + fabs + ret +..B1.3: + .align 16,0x90 + .type fabsf,@function + .size fabsf,.-fabsf + .data +# -- End fabsf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fabsl.S b/external/sgx_libm/ia32/fabsl.S new file mode 100644 index 0000000000..38a16d68ec --- /dev/null +++ b/external/sgx_libm/ia32/fabsl.S @@ -0,0 +1,121 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fabsl.c" + .text +..TXTST0: +# -- Begin fabsl + .text + .align 16,0x90 + .globl fabsl +fabsl: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + subl $28, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.15 +..B1.4: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.5: + fldcw 12(%esp) +..B1.6: + movl $1, %eax +..B1.7: + movzwl 40(%esp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.12 +..B1.8: + fldt 32(%esp) + movzbl 41(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + fmull ones@GOTOFF(%edx,%ecx,8) + fstpt (%esp) +..B1.9: + testl %eax, %eax + je ..B1.11 +..B1.10: + fldcw 14(%esp) +..B1.11: + fldt (%esp) + addl $28, %esp + ret +..B1.12: + cmpl $-2147483648, 36(%esp) + jne ..B1.14 +..B1.13: + cmpl $0, 32(%esp) + je ..B1.8 +..B1.14: + fldt 32(%esp) + movzbl 41(%esp), %edx + fstpt (%esp) + andl $127, %edx + movb %dl, 9(%esp) + jmp ..B1.9 +..B1.15: + xorl %eax, %eax + jmp ..B1.7 + .align 16,0x90 + .type fabsl,@function + .size fabsl,.-fabsl + .data +# -- End fabsl + .section .rodata, "a" + .align 8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fdim_wmt.S b/external/sgx_libm/ia32/fdim_wmt.S new file mode 100644 index 0000000000..92c666fe59 --- /dev/null +++ b/external/sgx_libm/ia32/fdim_wmt.S @@ -0,0 +1,181 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fdim_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fdim + .text + .align 16,0x90 + .globl fdim +fdim: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + stmxcsr 8(%esp) + movsd 112(%esp), %xmm0 + movsd 120(%esp), %xmm1 + movapd %xmm0, %xmm2 + ucomisd %xmm0, %xmm1 + movl 8(%esp), %eax + jp .L_2TAG_PACKET_0.0.3 + testl $8, %eax + cmpnlesd %xmm1, %xmm0 + andpd %xmm0, %xmm1 + andpd %xmm2, %xmm0 + jne .L_2TAG_PACKET_1.0.3 + subsd %xmm1, %xmm0 + andpd (%ebx), %xmm0 + pextrw $3, %xmm0, %eax + cmpl $32751, %eax + jb .L_2TAG_PACKET_2.0.3 + stmxcsr 12(%esp) + movl 12(%esp), %eax + testl $8, %eax + jne .L_2TAG_PACKET_3.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + andl $-9, %eax + movl %eax, 12(%esp) + ldmxcsr 12(%esp) + cmpnlesd %xmm1, %xmm0 + andpd %xmm0, %xmm1 + andpd %xmm2, %xmm0 + subsd %xmm1, %xmm0 + andpd (%ebx), %xmm0 + stmxcsr 12(%esp) + movl 12(%esp), %eax + testl $8, %eax + jne .L_2TAG_PACKET_3.0.3 + ldmxcsr 8(%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + fldl 112(%esp) + fldl 120(%esp) + faddp %st, %st(1) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_3.0.3: + movl $196, %edx +.L_2TAG_PACKET_5.0.3: + movsd %xmm0, (%esp) + movsd 112(%esp), %xmm0 + movsd 120(%esp), %xmm1 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 120(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 32(%esp) + fldl 32(%esp) +.L_2TAG_PACKET_4.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fdim,@function + .size fdim,.-fdim + .data +# -- End fdim + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fdimf_wmt.S b/external/sgx_libm/ia32/fdimf_wmt.S new file mode 100644 index 0000000000..b2ac1a5c69 --- /dev/null +++ b/external/sgx_libm/ia32/fdimf_wmt.S @@ -0,0 +1,181 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fdimf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fdimf + .text + .align 16,0x90 + .globl fdimf +fdimf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + stmxcsr 8(%esp) + movss 112(%esp), %xmm0 + movss 116(%esp), %xmm1 + movss %xmm0, %xmm2 + ucomiss %xmm0, %xmm1 + movl 8(%esp), %eax + jp .L_2TAG_PACKET_0.0.3 + testl $8, %eax + cmpnless %xmm1, %xmm0 + andps %xmm0, %xmm1 + andps %xmm2, %xmm0 + jne .L_2TAG_PACKET_1.0.3 + subss %xmm1, %xmm0 + andps (%ebx), %xmm0 + movd %xmm0, %eax + cmpl $2139095039, %eax + jb .L_2TAG_PACKET_2.0.3 + stmxcsr 12(%esp) + movl 12(%esp), %eax + testl $8, %eax + jne .L_2TAG_PACKET_3.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + andl $-9, %eax + movl %eax, 12(%esp) + ldmxcsr 12(%esp) + cmpnless %xmm1, %xmm0 + andps %xmm0, %xmm1 + andps %xmm2, %xmm0 + subss %xmm1, %xmm0 + andps (%ebx), %xmm0 + stmxcsr 12(%esp) + movl 12(%esp), %eax + testl $8, %eax + jne .L_2TAG_PACKET_3.0.3 + ldmxcsr 8(%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + flds 112(%esp) + flds 116(%esp) + faddp %st, %st(1) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_3.0.3: + movl $196, %edx +.L_2TAG_PACKET_5.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + movss 116(%esp), %xmm1 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 116(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_2.0.3: + movss %xmm0, 32(%esp) + flds 32(%esp) +.L_2TAG_PACKET_4.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fdimf,@function + .size fdimf,.-fdimf + .data +# -- End fdimf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 2147483647 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fdiml.S b/external/sgx_libm/ia32/fdiml.S new file mode 100644 index 0000000000..2170a2c478 --- /dev/null +++ b/external/sgx_libm/ia32/fdiml.S @@ -0,0 +1,292 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fdiml.c" + .text +..TXTST0: +# -- Begin fdiml + .text + .align 16,0x90 + .globl fdiml +fdiml: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %edi + pushl %ebx + subl $24, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %ecx + andl $32767, %ecx + movzwl 28(%ebp), %edx + andl $32767, %edx + cmpl $32767, %ecx + je ..B1.39 +..B1.4: + cmpl $32767, %edx + je ..B1.30 +..B1.5: + movzwl 14(%esp), %ebx + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.6: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.7: + fldcw 12(%esp) +..B1.8: + movl $1, %edi +..B1.9: + fldt 20(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fldl _zeros@GOTOFF(%ebx) + fstpt (%esp) + fldt 8(%ebp) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B1.43 +..B1.10: + cmpl $32767, %ecx + je ..B1.14 +..B1.11: + cmpl $32767, %edx + je ..B1.14 +..B1.12: + cmpl $32766, %ecx + je ..B1.26 +..B1.13: + cmpl $32766, %edx + je ..B1.18 +..B1.14: + fsubp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.43: + fstp %st(0) + fstp %st(0) +..B1.15: + testl %edi, %edi + je ..B1.17 +..B1.16: + fldcw 14(%esp) +..B1.17: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + testl %ecx, %ecx + jne ..B1.22 +..B1.19: + cmpl $0, 12(%ebp) + jne ..B1.21 +..B1.20: + cmpl $0, 8(%ebp) + je ..B1.22 +..B1.21: + fldt _ranges@GOTOFF(%ebx) + fxch %st(2) + fsubrp %st, %st(1) + fstpt (%esp) + fldt (%esp) + fucompp + fnstsw %ax + sahf + jne ..B1.15 + jp ..B1.15 + jmp ..B1.24 +..B1.22: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fmul %st, %st(1) + fmulp %st, %st(2) + fsubp %st, %st(1) + fldt 12+_ranges@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jp ..B1.23 + jbe ..B1.25 +..B1.23: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.24: + fldt _large_value_80@GOTOFF(%ebx) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.15 +..B1.25: + fstp %st(0) + fldt _large_value_80@GOTOFF(%ebx) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.15 +..B1.26: + testl %edx, %edx + jne ..B1.22 +..B1.27: + cmpl $0, 24(%ebp) + jne ..B1.21 +..B1.28: + cmpl $0, 20(%ebp) + jne ..B1.21 + jmp ..B1.22 +..B1.29: + xorl %edi, %edi + jmp ..B1.9 +..B1.30: + cmpl $-2147483648, 24(%ebp) + jne ..B1.32 +..B1.31: + cmpl $0, 20(%ebp) + je ..B1.5 +..B1.32: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.33: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.34: + fldcw 12(%esp) +..B1.35: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) +..B1.36: + fldcw 14(%esp) +..B1.37: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.37 +..B1.39: + cmpl $-2147483648, 12(%ebp) + jne ..B1.32 +..B1.40: + cmpl $0, 8(%ebp) + je ..B1.4 + jmp ..B1.32 + .align 16,0x90 + .type fdiml,@function + .size fdiml,.-fdiml + .data +# -- End fdiml + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_ranges: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .type _ranges,@object + .size _ranges,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/feclearexcept.S b/external/sgx_libm/ia32/feclearexcept.S new file mode 100644 index 0000000000..a0bf0865ef --- /dev/null +++ b/external/sgx_libm/ia32/feclearexcept.S @@ -0,0 +1,94 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feclearexcept.c" + .text +..TXTST0: +# -- Begin feclearexcept + .text + .align 16,0x90 + .globl feclearexcept +feclearexcept: +# parameter 1: 48 + %esp +..B1.1: +..L1: + + subl $44, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 32(%esp) + movl 48(%esp), %eax + andl $63, %eax + je ..B1.8 +..B1.2: + fnstenv 4(%esp) +..B1.3: + notl %eax + andw %ax, 8(%esp) +..B1.4: + fnclex +..B1.5: + fldenv 4(%esp) +..B1.6: + stmxcsr (%esp) + movl (%esp), %edx +..B1.7: + andl %eax, %edx + movl %edx, (%esp) + ldmxcsr (%esp) +..B1.8: + movl 32(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.10 +..B1.9: + xorl %eax, %eax + addl $44, %esp + ret +..B1.10: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type feclearexcept,@function + .size feclearexcept,.-feclearexcept + .data +# -- End feclearexcept + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fedisableexcept.S b/external/sgx_libm/ia32/fedisableexcept.S new file mode 100644 index 0000000000..619a544f81 --- /dev/null +++ b/external/sgx_libm/ia32/fedisableexcept.S @@ -0,0 +1,99 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fedisableexcept.c" + .text +..TXTST0: +# -- Begin fedisableexcept + .text + .align 16,0x90 + .globl fedisableexcept +fedisableexcept: +# parameter 1: 48 + %esp +..B1.1: +..L1: + + subl $44, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 36(%esp) + movl 48(%esp), %eax + andl $63, %eax +..B1.2: + fnstcw 4(%esp) +..B1.3: + testl %eax, %eax + je ..B1.10 +..B1.4: + fnstenv 6(%esp) +..B1.5: + orw %ax, 6(%esp) +..B1.6: + fnclex +..B1.7: + fldenv 6(%esp) +..B1.8: + stmxcsr (%esp) +..B1.9: + shll $7, %eax + orl (%esp), %eax + movl %eax, (%esp) + ldmxcsr (%esp) +..B1.10: + movzwl 4(%esp), %eax + movl 36(%esp), %edx + notl %eax + xorl %esp, %edx + andl $63, %eax + cmpl %gs:20, %edx + jne ..B1.12 +..B1.11: + addl $44, %esp + ret +..B1.12: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type fedisableexcept,@function + .size fedisableexcept,.-fedisableexcept + .data +# -- End fedisableexcept + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/feenableexcept.S b/external/sgx_libm/ia32/feenableexcept.S new file mode 100644 index 0000000000..a25752ab85 --- /dev/null +++ b/external/sgx_libm/ia32/feenableexcept.S @@ -0,0 +1,102 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feenableexcept.c" + .text +..TXTST0: +# -- Begin feenableexcept + .text + .align 16,0x90 + .globl feenableexcept +feenableexcept: +# parameter 1: 48 + %esp +..B1.1: +..L1: + + subl $44, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 36(%esp) + movl 48(%esp), %edx + andl $63, %edx +..B1.2: + fnstcw 4(%esp) +..B1.3: + testl %edx, %edx + je ..B1.10 +..B1.4: + fnstenv 6(%esp) +..B1.5: + movl %edx, %eax + notl %eax + andw %ax, 6(%esp) +..B1.6: + fnclex +..B1.7: + fldenv 6(%esp) +..B1.8: + stmxcsr (%esp) +..B1.9: + shll $7, %edx + notl %edx + andl (%esp), %edx + movl %edx, (%esp) + ldmxcsr (%esp) +..B1.10: + movzwl 4(%esp), %eax + movl 36(%esp), %edx + notl %eax + xorl %esp, %edx + andl $63, %eax + cmpl %gs:20, %edx + jne ..B1.12 +..B1.11: + addl $44, %esp + ret +..B1.12: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type feenableexcept,@function + .size feenableexcept,.-feenableexcept + .data +# -- End feenableexcept + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fegetenv.S b/external/sgx_libm/ia32/fegetenv.S new file mode 100644 index 0000000000..6479bf83c9 --- /dev/null +++ b/external/sgx_libm/ia32/fegetenv.S @@ -0,0 +1,75 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fegetenv.c" + .text +..TXTST0: +# -- Begin fegetenv + .text + .align 16,0x90 + .globl fegetenv +fegetenv: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp +..B1.2: + movl 16(%esp), %eax +..B1.3: + fnstenv (%eax) +..B1.4: + fnclex +..B1.5: + fldenv (%eax) +..B1.6: + stmxcsr (%esp) + movl (%esp), %eax +..B1.7: + movl 16(%esp), %edx + andl $63, %eax + orw %ax, 4(%edx) + xorl %eax, %eax + addl $12, %esp + ret + .align 16,0x90 + .type fegetenv,@function + .size fegetenv,.-fegetenv + .data +# -- End fegetenv + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fegetexcept.S b/external/sgx_libm/ia32/fegetexcept.S new file mode 100644 index 0000000000..021aab378b --- /dev/null +++ b/external/sgx_libm/ia32/fegetexcept.S @@ -0,0 +1,64 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fegetexcept.c" + .text +..TXTST0: +# -- Begin fegetexcept + .text + .align 16,0x90 + .globl fegetexcept +fegetexcept: +..B1.1: +..L1: + + subl $12, %esp +..B1.2: + fstcw (%esp) +..B1.3: + movzwl (%esp), %eax + notl %eax + andl $63, %eax + addl $12, %esp + ret + .align 16,0x90 + .type fegetexcept,@function + .size fegetexcept,.-fegetexcept + .data +# -- End fegetexcept + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fegetexceptflag.S b/external/sgx_libm/ia32/fegetexceptflag.S new file mode 100644 index 0000000000..14aa8d1bca --- /dev/null +++ b/external/sgx_libm/ia32/fegetexceptflag.S @@ -0,0 +1,73 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fegetexceptflag.c" + .text +..TXTST0: +# -- Begin fegetexceptflag + .text + .align 16,0x90 + .globl fegetexceptflag +fegetexceptflag: +# parameter 1: 16 + %esp +# parameter 2: 20 + %esp +..B1.1: +..L1: + + subl $12, %esp + movl 20(%esp), %eax + andl $63, %eax +..B1.2: + fnstsw 4(%esp) +..B1.3: + stmxcsr (%esp) +..B1.4: + movl 16(%esp), %ecx + movzwl 4(%esp), %edx + orl (%esp), %edx + andl %eax, %edx + xorl %eax, %eax + movw %dx, (%ecx) + addl $12, %esp + ret + .align 16,0x90 + .type fegetexceptflag,@function + .size fegetexceptflag,.-fegetexceptflag + .data +# -- End fegetexceptflag + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fegetround.S b/external/sgx_libm/ia32/fegetround.S new file mode 100644 index 0000000000..f636955a37 --- /dev/null +++ b/external/sgx_libm/ia32/fegetround.S @@ -0,0 +1,63 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fegetround.c" + .text +..TXTST0: +# -- Begin fegetround + .text + .align 16,0x90 + .globl fegetround +fegetround: +..B1.1: +..L1: + + subl $12, %esp +..B1.2: + fnstcw (%esp) +..B1.3: + movzwl (%esp), %eax + andl $3072, %eax + addl $12, %esp + ret + .align 16,0x90 + .type fegetround,@function + .size fegetround,.-fegetround + .data +# -- End fegetround + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/feholdexcept.S b/external/sgx_libm/ia32/feholdexcept.S new file mode 100644 index 0000000000..74ba663802 --- /dev/null +++ b/external/sgx_libm/ia32/feholdexcept.S @@ -0,0 +1,102 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feholdexcept.c" + .text +..TXTST0: +# -- Begin feholdexcept + .text + .align 16,0x90 + .globl feholdexcept +feholdexcept: +# parameter 1: 48 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $40, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 32(%esp) + stmxcsr (%esp) + movl (%esp), %ecx +..B1.2: + fnstenv 4(%esp) +..B1.3: + movl 48(%esp), %eax + movl %ecx, %ebx + andl $63, %ebx + andl $-64, %ecx + movzwl 8(%esp), %edx + orl %edx, %ebx + movw %bx, 4(%eax) + andl $-64, %edx + movzwl 4(%esp), %ebx + orl $8064, %ecx + movw %bx, (%eax) + orl $63, %ebx + movw %dx, 8(%esp) + movw %bx, 4(%esp) +..B1.4: + fnclex +..B1.5: + fldenv 4(%esp) +..B1.6: + movl %ecx, (%esp) + movl 32(%esp), %eax + xorl %esp, %eax + ldmxcsr (%esp) + cmpl %gs:20, %eax + jne ..B1.8 +..B1.7: + xorl %eax, %eax + addl $40, %esp + popl %ebx + ret +..B1.8: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type feholdexcept,@function + .size feholdexcept,.-feholdexcept + .data +# -- End feholdexcept + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/feraiseexcept.S b/external/sgx_libm/ia32/feraiseexcept.S new file mode 100644 index 0000000000..cb7981847a --- /dev/null +++ b/external/sgx_libm/ia32/feraiseexcept.S @@ -0,0 +1,185 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feraiseexcept.c" + .text +..TXTST0: +# -- Begin feraiseexcept + .text + .align 16,0x90 + .globl feraiseexcept +feraiseexcept: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movl 16(%esp), %eax + testb $1, %al + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + je ..B1.3 +..B1.2: + flds d_zero@GOTOFF(%edx) + fwait + flds d_zero@GOTOFF(%edx) + fwait + fdivrp %st, %st(1) + fwait + fstps (%esp) + fwait +..B1.3: + testb $4, %al + je ..B1.5 +..B1.4: + movl p_one@GOTOFF(%edx), %ecx + flds (%ecx) + fwait + movl p_zero@GOTOFF(%edx), %ecx + flds (%ecx) + fwait + fdivrp %st, %st(1) + fwait + fstps (%esp) + fwait +..B1.5: + testb $2, %al + je ..B1.7 +..B1.6: + flds d_tiny@GOTOFF(%edx) + fwait + flds d_tiny@GOTOFF(%edx) + fwait + faddp %st, %st(1) + fwait + fstps (%esp) + fwait +..B1.7: + testb $8, %al + je ..B1.9 +..B1.8: + flds d_huge@GOTOFF(%edx) + fwait + flds d_huge@GOTOFF(%edx) + fwait + fmulp %st, %st(1) + fwait + fstps (%esp) + fwait +..B1.9: + testb $16, %al + je ..B1.11 +..B1.10: + flds d_norm@GOTOFF(%edx) + fwait + flds d_norm@GOTOFF(%edx) + fwait + fmulp %st, %st(1) + fwait + fstps (%esp) + fwait +..B1.11: + testb $32, %al + je ..B1.13 +..B1.12: + movl p_one@GOTOFF(%edx), %eax + movl p_norm@GOTOFF(%edx), %edx + flds (%eax) + fwait + flds (%edx) + fwait + faddp %st, %st(1) + fwait + fstps (%esp) + fwait +..B1.13: + xorl %eax, %eax + addl $12, %esp + ret + .align 16,0x90 + .type feraiseexcept,@function + .size feraiseexcept,.-feraiseexcept + .data +# -- End feraiseexcept + .section .rodata, "a" + .align 4 + .align 4 +d_zero: + .long 0 + .type d_zero,@object + .size d_zero,4 + .align 4 +d_one: + .long 1065353216 + .type d_one,@object + .size d_one,4 + .align 4 +d_tiny: + .long 8388607 + .type d_tiny,@object + .size d_tiny,4 + .align 4 +d_huge: + .long 2139095039 + .type d_huge,@object + .size d_huge,4 + .align 4 +d_norm: + .long 8388608 + .type d_norm,@object + .size d_norm,4 + .section .data.rel.ro.local, "aw",@progbits + .align 4 + .align 4 +p_one: + .long d_one + .type p_one,@object + .size p_one,4 + .align 4 +p_zero: + .long d_zero + .type p_zero,@object + .size p_zero,4 + .align 4 +p_norm: + .long d_norm + .type p_norm,@object + .size p_norm,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fesetenv.S b/external/sgx_libm/ia32/fesetenv.S new file mode 100644 index 0000000000..44b7335baa --- /dev/null +++ b/external/sgx_libm/ia32/fesetenv.S @@ -0,0 +1,124 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fesetenv.c" + .text +..TXTST0: +# -- Begin fesetenv + .text + .align 16,0x90 + .globl fesetenv +fesetenv: +# parameter 1: 64 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + pushl %ebp + subl $48, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 32(%esp) + stmxcsr (%esp) + movl (%esp), %ecx +..B1.2: + fnstenv 4(%esp) +..B1.3: + movzwl 4(%esp), %edi + andl $-32704, %ecx + movzwl 8(%esp), %eax + andl $-3136, %edi + movl 64(%esp), %ebp + andl $-64, %eax + cmpl $-1, %ebp + je ..B1.10 +..B1.4: + movzwl (%ebp), %edx + movl %edx, %ebx + movzwl 4(%ebp), %ebp + andl $3135, %ebx + andl $63, %ebp + orl %ebx, %edi + orl %ebp, %eax + movw %ax, 8(%esp) + movl %edx, %eax + andl $63, %eax + andl $3072, %edx + shll $7, %eax + shll $3, %edx + orl %eax, %ecx + orl %edx, %ecx + movw %di, 4(%esp) + orl %ebp, %ecx +..B1.5: + fnclex +..B1.6: + fldenv 4(%esp) +..B1.7: + movl %ecx, (%esp) + movl 32(%esp), %eax + xorl %esp, %eax + ldmxcsr (%esp) + cmpl %gs:20, %eax + jne ..B1.9 +..B1.8: + xorl %eax, %eax + addl $48, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.9: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT +..B1.10: + orl $63, %edi + orl $8064, %ecx + movw %ax, 8(%esp) + movw %di, 4(%esp) + jmp ..B1.5 + .align 16,0x90 + .type fesetenv,@function + .size fesetenv,.-fesetenv + .data +# -- End fesetenv + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fesetexceptflag.S b/external/sgx_libm/ia32/fesetexceptflag.S new file mode 100644 index 0000000000..6574e54d20 --- /dev/null +++ b/external/sgx_libm/ia32/fesetexceptflag.S @@ -0,0 +1,109 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fesetexceptflag.c" + .text +..TXTST0: +# -- Begin fesetexceptflag + .text + .align 16,0x90 + .globl fesetexceptflag +fesetexceptflag: +# parameter 1: 48 + %esp +# parameter 2: 52 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + subl $36, %esp + movl %gs:20, %eax + movl 52(%esp), %ecx + xorl %esp, %eax + movl %eax, 32(%esp) + andl $63, %ecx + je ..B1.8 +..B1.2: + fnstenv 4(%esp) +..B1.3: + movl 48(%esp), %edx + movl %ecx, %eax + notl %eax + movzwl 8(%esp), %edi + movzwl (%edx), %ebx + andl %eax, %edi + andl %ecx, %ebx + orl %ebx, %edi + movw %di, 8(%esp) +..B1.4: + fnclex +..B1.5: + fldenv 4(%esp) +..B1.6: + stmxcsr (%esp) + movl (%esp), %ebx +..B1.7: + andl %eax, %ebx + movzwl (%edx), %eax + andl %ecx, %eax + orl %eax, %ebx + movl %ebx, (%esp) + ldmxcsr (%esp) +..B1.8: + movl 32(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.10 +..B1.9: + xorl %eax, %eax + addl $36, %esp + popl %ebx + popl %edi + ret +..B1.10: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type fesetexceptflag,@function + .size fesetexceptflag,.-fesetexceptflag + .data +# -- End fesetexceptflag + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fesetround.S b/external/sgx_libm/ia32/fesetround.S new file mode 100644 index 0000000000..37e6202a5f --- /dev/null +++ b/external/sgx_libm/ia32/fesetround.S @@ -0,0 +1,107 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fesetround.c" + .text +..TXTST0: +# -- Begin fesetround + .text + .align 16,0x90 + .globl fesetround +fesetround: +# parameter 1: 48 + %esp +..B1.1: +..L1: + + subl $44, %esp + movl %gs:20, %eax + movl 48(%esp), %edx + xorl %esp, %eax + movl %eax, 32(%esp) + testl $-3073, %edx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + jne ..B1.9 +..B1.2: + fnstenv 4(%esp) +..B1.3: + movzwl 4(%esp), %eax + andl $-3073, %eax + orl %edx, %eax + movw %ax, 4(%esp) +..B1.4: + fnclex +..B1.5: + fldenv 4(%esp) +..B1.6: + stmxcsr (%esp) + movl (%esp), %eax +..B1.7: + andl $-24577, %eax + shll $3, %edx + orl %edx, %eax + movl %eax, (%esp) + movl 32(%esp), %eax + xorl %esp, %eax + ldmxcsr (%esp) + cmpl %gs:20, %eax + jne ..B1.11 +..B1.8: + xorl %eax, %eax + addl $44, %esp + ret +..B1.9: + movl 32(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.11 +..B1.10: + movl $1, %eax + addl $44, %esp + ret +..B1.11: + movl %ecx, %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type fesetround,@function + .size fesetround,.-fesetround + .data +# -- End fesetround + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fetestexcept.S b/external/sgx_libm/ia32/fetestexcept.S new file mode 100644 index 0000000000..72b9f7572e --- /dev/null +++ b/external/sgx_libm/ia32/fetestexcept.S @@ -0,0 +1,74 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fetestexcept.c" + .text +..TXTST0: +# -- Begin fetestexcept + .text + .align 16,0x90 + .globl fetestexcept +fetestexcept: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movl 16(%esp), %edx + andl $63, %edx + je ..B1.5 +..B1.2: + fnstsw 4(%esp) +..B1.3: + stmxcsr (%esp) +..B1.4: + movzwl 4(%esp), %eax + orl (%esp), %eax + andl %edx, %eax + addl $12, %esp + ret +..B1.5: + xorl %eax, %eax + addl $12, %esp + ret + .align 16,0x90 + .type fetestexcept,@function + .size fetestexcept,.-fetestexcept + .data +# -- End fetestexcept + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/feupdateenv.S b/external/sgx_libm/ia32/feupdateenv.S new file mode 100644 index 0000000000..4c564b74e2 --- /dev/null +++ b/external/sgx_libm/ia32/feupdateenv.S @@ -0,0 +1,83 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feupdateenv.c" + .text +..TXTST0: +# -- Begin feupdateenv + .text + .align 16,0x90 + .globl feupdateenv +feupdateenv: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $8, %esp +..B1.2: + fnstsw 4(%esp) +..B1.3: + stmxcsr (%esp) + movl (%esp), %eax +..B1.4: + movl 16(%esp), %edx + orw %ax, 4(%esp) + addl $-16, %esp + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %edx, (%esp) + call fesetenv@PLT +..B1.5: + movzwl 20(%esp), %eax + andl $63, %eax + movl %eax, (%esp) + call feraiseexcept@PLT +..B1.6: + xorl %eax, %eax + addl $24, %esp + popl %ebx + ret + .align 16,0x90 + .type feupdateenv,@function + .size feupdateenv,.-feupdateenv + .data +# -- End feupdateenv + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/floor_wmt.S b/external/sgx_libm/ia32/floor_wmt.S new file mode 100644 index 0000000000..93d2632114 --- /dev/null +++ b/external/sgx_libm/ia32/floor_wmt.S @@ -0,0 +1,152 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "floor_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin floor + .text + .align 16,0x90 + .globl floor +floor: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + pextrw $3, %xmm0, %eax + movl $32752, %ecx + andl %eax, %ecx + cmpl $17184, %ecx + ja .L_2TAG_PACKET_0.0.2 + je .L_2TAG_PACKET_1.0.2 + cmpl $16368, %ecx + jl .L_2TAG_PACKET_2.0.2 + movq (%ebx), %xmm1 + addsd %xmm0, %xmm1 + subsd (%ebx), %xmm1 + cmpltsd %xmm1, %xmm0 + movq %xmm1, (%esp) + movd %xmm0, %eax + fldl (%esp) + fsubs 20(%ebx,%eax,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: + pxor %xmm1, %xmm1 + cmpnlesd %xmm0, %xmm1 + movd %xmm1, %ecx + shrl $15, %eax + subl %ecx, %eax + flds 32(%ebx,%eax,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_1.0.2: + pextrw $0, %xmm0, %eax + andl $1, %eax + movq %xmm0, (%esp) + fldl (%esp) + fsubs 48(%ebx,%eax,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + cmpl $32752, %ecx + movq %xmm0, (%esp) + fldl (%esp) + jae .L_2TAG_PACKET_4.0.2 + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_4.0.2: + fldz + faddp +.L_2TAG_PACKET_3.0.2: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type floor,@function + .size floor,.-floor + .data +# -- End floor + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1127743488 + .long 0 + .long 0 + .long 1065353216 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 3212836864 + .long 0 + .long 0 + .long 1056964608 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,64 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/floorf_gen.S b/external/sgx_libm/ia32/floorf_gen.S new file mode 100644 index 0000000000..bd3d935fd3 --- /dev/null +++ b/external/sgx_libm/ia32/floorf_gen.S @@ -0,0 +1,145 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "floorf_gen.c" + .text +..TXTST0: +# -- Begin floorf + .text + .align 16,0x90 + .globl floorf +floorf: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movzwl 18(%esp), %eax + andl $32640, %eax + shrl $7, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $149, %eax + jge ..B1.11 +..B1.2: + cmpl $127, %eax + jl ..B1.7 +..B1.3: + flds .L_2il0floatpacket.0@GOTOFF(%edx) + flds 16(%esp) + fld %st(0) + fadd %st(2), %st + fstps (%esp) + flds (%esp) + fsubp %st, %st(2) + fcomp %st(1) + fnstsw %ax + sahf + jae ..B1.6 + jp ..B1.6 +..B1.4: + fadds .L_2il0floatpacket.1@GOTOFF(%edx) +..B1.6: + addl $12, %esp + ret +..B1.7: + testl %eax, %eax + jne ..B1.10 +..B1.8: + testl $8388607, 16(%esp) + jne ..B1.10 +..B1.9: + flds 16(%esp) + addl $12, %esp + ret +..B1.10: + movzbl 19(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + movl 16(%esp), %eax + movl %eax, (%esp) + flds _pzero_none@GOTOFF(%edx,%ecx,4) + addl $12, %esp + ret +..B1.11: + cmpl $150, %eax + jge ..B1.16 +..B1.12: + flds 16(%esp) + testb $1, 16(%esp) + je ..B1.15 +..B1.13: + fadds .L_2il0floatpacket.2@GOTOFF(%edx) +..B1.15: + addl $12, %esp + ret +..B1.16: + flds 16(%esp) + addl $12, %esp + ret + .align 16,0x90 + .type floorf,@function + .size floorf,.-floorf + .data +# -- End floorf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4b400000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0xbf800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0xbf000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +_pzero_none: + .long 0 + .long 3212836864 + .type _pzero_none,@object + .size _pzero_none,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/floorl.S b/external/sgx_libm/ia32/floorl.S new file mode 100644 index 0000000000..00c0faac22 --- /dev/null +++ b/external/sgx_libm/ia32/floorl.S @@ -0,0 +1,246 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "floorl.c" + .text +..TXTST0: +# -- Begin floorl + .text + .align 16,0x90 + .globl floorl +floorl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $16445, %eax + jge ..B1.21 +..B1.4: + cmpl $16383, %eax + jl ..B1.15 +..B1.5: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.6: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.7: + fldcw 12(%esp) +..B1.8: + movl $1, %ecx +..B1.9: + fldt 8(%ebp) + fld %st(0) + fldl _TWO_63H@GOTOFF(%edx) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt (%esp) + fldt (%esp) + fcompp + fnstsw %ax + sahf + jbe ..B1.12 +..B1.10: + fldt (%esp) + faddl 8+_ones@GOTOFF(%edx) + fstpt (%esp) +..B1.12: + testl %ecx, %ecx + je ..B1.14 +..B1.13: + fldcw 14(%esp) +..B1.14: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.15: + testl %eax, %eax + jne ..B1.20 +..B1.16: + cmpl $0, 12(%ebp) + jne ..B1.19 +..B1.17: + cmpl $0, 8(%ebp) + jne ..B1.19 +..B1.18: + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.19: + fldl _smallest_value_64@GOTOFF(%edx) + fstpl 16(%esp) +..B1.20: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl _pzero_none@GOTOFF(%edx,%eax,8) + movl %ebp, %esp + popl %ebp + ret +..B1.21: + cmpl $16446, %eax + jge ..B1.30 +..B1.22: + testb $1, 8(%ebp) + je ..B1.29 +..B1.23: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.37 +..B1.24: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.25: + fldcw 12(%esp) +..B1.26: + fldt 8(%ebp) + faddl 8+_halfs@GOTOFF(%edx) + fstpt (%esp) +..B1.27: + fldcw 14(%esp) +..B1.28: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.29: + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.30: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.31: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.32: + fldcw 12(%esp) +..B1.33: + fldt 8(%ebp) + fmull _ones@GOTOFF(%edx) + fstpt (%esp) +..B1.34: + fldcw 14(%esp) +..B1.35: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.36: + xorl %ecx, %ecx + jmp ..B1.9 +..B1.37: + fldt 8(%ebp) + faddl 8+_halfs@GOTOFF(%edx) + fstpt (%esp) + jmp ..B1.28 +..B1.38: + fldt 8(%ebp) + fmull _ones@GOTOFF(%edx) + fstpt (%esp) + jmp ..B1.35 + .align 16,0x90 + .type floorl,@function + .size floorl,.-floorl + .data +# -- End floorl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_pzero_none: + .long 0 + .long 0 + .long 0 + .long 3220176896 + .type _pzero_none,@object + .size _pzero_none,16 + .align 4 +_halfs: + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .type _halfs,@object + .size _halfs,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fma.S b/external/sgx_libm/ia32/fma.S new file mode 100644 index 0000000000..d7cc6ab0a1 --- /dev/null +++ b/external/sgx_libm/ia32/fma.S @@ -0,0 +1,1208 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fma.c" + .text +..TXTST0: +# -- Begin fma + .text + .align 16,0x90 + .globl fma +fma: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 24 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp +..B1.2: + fnstcw 80(%esp) +..B1.3: + movl 12(%ebp), %esi + movl 16(%ebp), %ecx + movl 24(%ebp), %eax + movzwl 80(%esp), %edx + movl %esi, 60(%esp) + andl $2147483647, %esi + andl $3072, %edx + movl %edx, 56(%esp) + movl 20(%ebp), %edx + movl %edx, %edi + movl %ecx, 76(%esp) + andl $2147483647, %edi + movl 28(%ebp), %ecx + movl %eax, 72(%esp) + movl %esi, %eax + movl 8(%ebp), %ebx + movl %ecx, 68(%esp) + andl $2147483647, %ecx + orl %ebx, %eax + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + movl %eax, 64(%esp) + jne ..B1.4 +..B1.130: + cmpl $2146435072, %esi + ja ..B1.8 + jmp ..B1.6 +..B1.4: + cmpl $2146435072, %esi + jb ..B1.9 +..B1.5: + ja ..B1.8 +..B1.6: + jne ..B1.134 +..B1.7: + testl %ebx, %ebx + jne ..B1.8 +..B1.133: + cmpl $2146435072, %edi + ja ..B1.15 + jmp ..B1.13 +..B1.8: + fldl 8(%ebp) + faddl 16(%ebp) + fmull 24(%ebp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + lea -1072693248(%esi), %eax + orl %ebx, %eax + je ..B1.133 +..B1.10: + movl %edi, %eax + orl 76(%esp), %eax + je ..B1.133 +..B1.11: + cmpl $2146435072, %edi + jae ..B1.12 + jmp ..B1.16 +..B1.134: + cmpl $2146435072, %edi +..B1.12: + ja ..B1.15 +..B1.13: + jne ..B1.138 +..B1.14: + cmpl $0, 76(%esp) + jne ..B1.15 +..B1.137: + cmpl $2146435072, %ecx + ja ..B1.22 + jmp ..B1.20 +..B1.15: + fldl 16(%ebp) + faddl 24(%ebp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + lea -1072693248(%edi), %eax + orl 76(%esp), %eax + je ..B1.137 +..B1.17: + movl %ecx, %eax + orl 72(%esp), %eax + je ..B1.137 +..B1.18: + cmpl $2146435072, %ecx + jae ..B1.19 + jmp ..B1.28 +..B1.138: + cmpl $2146435072, %ecx +..B1.19: + ja ..B1.22 +..B1.20: + jne ..B1.23 +..B1.21: + cmpl $0, 72(%esp) + je ..B1.23 +..B1.22: + fldl 24(%ebp) + movl 64(%esp), %eax + fmull _ones@GOTOFF(%eax) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + cmpl $2146435072, %esi + jae ..B1.27 +..B1.24: + cmpl $2146435072, %edi + jae ..B1.27 +..B1.25: + cmpl $2146435072, %ecx + jb ..B1.27 +..B1.26: + fldl 24(%ebp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.27: + fldl 8(%ebp) + fmull 16(%ebp) + faddl 24(%ebp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.28: + cmpl $1048576, %esi + jae ..B1.30 +..B1.29: + movl 60(%esp), %ebx + movl %ebx, %eax + shrl $31, %eax + orl $1072693248, %ebx + movl 64(%esp), %esi + movl %ebx, 12(%ebp) + fldl 8(%ebp) + fsubl _ones@GOTOFF(%esi,%eax,8) + fstpl 8(%ebp) + movl 12(%ebp), %esi + movl %esi, 60(%esp) + andl $2147483647, %esi + movl %esi, %eax + shrl $20, %eax + addl $-1022, %eax + movl 8(%ebp), %ebx + movl %eax, 4(%esp) + jmp ..B1.31 +..B1.30: + movl %esi, %eax + shrl $20, %eax + movl %eax, 4(%esp) +..B1.31: + cmpl $1048576, %edi + jae ..B1.33 +..B1.32: + movl %edx, %edi + orl $1072693248, %edx + shrl $31, %edi + movl %edx, 20(%ebp) + fldl 16(%ebp) + movl 64(%esp), %edx + fsubl _ones@GOTOFF(%edx,%edi,8) + fstpl 16(%ebp) + movl 20(%ebp), %edx + movl %edx, %edi + movl 16(%ebp), %eax + andl $2147483647, %edi + movl %eax, 76(%esp) + movl %edi, %eax + shrl $20, %eax + addl $-1022, %eax + movl %eax, 16(%esp) + jmp ..B1.34 +..B1.33: + movl %edi, %eax + shrl $20, %eax + movl %eax, 16(%esp) +..B1.34: + cmpl $1048576, %ecx + jae ..B1.36 +..B1.35: + movl 68(%esp), %eax + movl %eax, %ecx + shrl $31, %ecx + orl $1072693248, %eax + movl %eax, 28(%ebp) + fldl 24(%ebp) + movl 64(%esp), %eax + fsubl _ones@GOTOFF(%eax,%ecx,8) + fstpl 24(%ebp) + movl 28(%ebp), %ecx + movl 24(%ebp), %eax + movl %ecx, 68(%esp) + andl $2147483647, %ecx + movl %eax, 72(%esp) + movl %ecx, %eax + shrl $20, %eax + addl $-1022, %eax + movl %eax, (%esp) + jmp ..B1.37 +..B1.36: + movl %ecx, %eax + shrl $20, %eax + movl %eax, (%esp) +..B1.37: + andl $1048575, %ecx + movl %ebx, %eax + orl $1048576, %ecx + andl $1048575, %esi + movl %ecx, 20(%esp) + orl $1048576, %esi + movl 60(%esp), %ecx + andl $1048575, %edi + xorl %edx, %ecx + orl $1048576, %edi + andl $-2147483648, %ecx + movl %ecx, 60(%esp) + movl 4(%esp), %edx + movl 16(%esp), %ecx + lea -1023(%edx,%ecx), %edx + movl 76(%esp), %ecx + movl %edx, 32(%esp) + mull %ecx + movl %eax, 44(%esp) + movl %ecx, %eax + movl %edx, 24(%esp) + mull %esi + movl %eax, %ecx + movl %ebx, %eax + movl %edx, 28(%esp) + mull %edi + movl %eax, 52(%esp) + movl %esi, %eax + movl %edx, %ebx + xorl %esi, %esi + mull %edi + addl 52(%esp), %ecx + movl 28(%esp), %edi + adcl $0, %esi + addl 24(%esp), %ecx + movl %ecx, 48(%esp) + adcl $0, %esi + addl %eax, %esi + movl $0, %eax + movl 20(%esp), %ecx + adcl $0, %eax + addl %ebx, %edi + movl $0, %ebx + adcl $0, %ebx + addl %edi, %esi + movl %esi, 40(%esp) + adcl %ebx, %eax + addl %eax, %edx + movl %edx, 36(%esp) + testl $512, %edx + je ..B1.39 +..B1.38: + movl %esi, %eax + shll $11, %edx + shrl $21, %eax + orl %eax, %edx + movl %edx, 36(%esp) + movl 48(%esp), %eax + movl %eax, %ebx + movl 44(%esp), %edx + movl %edx, %edi + shll $11, %esi + shrl $21, %ebx + shll $11, %eax + orl %ebx, %esi + shrl $21, %edi + shll $11, %edx + orl %edi, %eax + incl 32(%esp) + movl %esi, 40(%esp) + movl %eax, 48(%esp) + movl %edx, 44(%esp) + jmp ..B1.40 +..B1.39: + movl %esi, %eax + shll $12, %edx + shrl $20, %eax + orl %eax, %edx + movl %edx, 36(%esp) + movl 48(%esp), %eax + movl %eax, %ebx + movl 44(%esp), %edx + movl %edx, %edi + shll $12, %esi + shrl $20, %ebx + shll $12, %eax + orl %ebx, %esi + shrl $20, %edi + shll $12, %edx + orl %edi, %eax + movl %esi, 40(%esp) + movl %eax, 48(%esp) + movl %edx, 44(%esp) +..B1.40: + movl 32(%esp), %eax + cmpl (%esp), %eax + jg ..B1.45 +..B1.41: + cmpl (%esp), %eax + jne ..B1.46 +..B1.42: + cmpl 36(%esp), %ecx + jb ..B1.45 +..B1.43: + jne ..B1.46 +..B1.44: + movl 72(%esp), %eax + cmpl 40(%esp), %eax + ja ..B1.46 +..B1.45: + movl 72(%esp), %eax + movl 32(%esp), %edx + movl 68(%esp), %ebx + movl %eax, 24(%esp) + andl $-2147483648, %ebx + xorl %eax, %eax + subl (%esp), %edx + movl %ecx, 20(%esp) + movl %ebx, 16(%esp) + movl %eax, 28(%esp) + jmp ..B1.47 +..B1.46: + movl 36(%esp), %ebx + movl %ebx, 20(%esp) + movl 72(%esp), %ebx + movl %ebx, 40(%esp) + movl (%esp), %eax + movl %eax, %edx + movl 60(%esp), %ebx + movl 48(%esp), %edi + movl %ebx, 16(%esp) + subl 32(%esp), %edx + movl 68(%esp), %ebx + movl %eax, 32(%esp) + andl $-2147483648, %ebx + movl 44(%esp), %eax + movl %ebx, 60(%esp) + xorl %ebx, %ebx + movl %esi, 24(%esp) + movl %edi, 28(%esp) + movl %ecx, 36(%esp) + movl %ebx, 44(%esp) + movl %ebx, 48(%esp) +..B1.47: + testl %edx, %edx + je ..B1.57 +..B1.48: + cmpl $32, %edx + jge ..B1.50 +..B1.49: + movl %edx, %esi + movl %edx, %ecx + negl %esi + movl %eax, %ebx + movl %esi, (%esp) + movl $-1, %esi + shrl %cl, %esi + movl (%esp), %ecx + notl %esi + shll %cl, %ebx + movl 28(%esp), %edi + andl %esi, %ebx + movl %ebx, 52(%esp) + movl %edi, %ebx + shll %cl, %ebx + movl %edx, %ecx + shrl %cl, %eax + andl %esi, %ebx + orl %ebx, %eax + movl %eax, 4(%esp) + movl 24(%esp), %eax + movl %eax, %ebx + movl (%esp), %ecx + shll %cl, %ebx + movl %edx, %ecx + shrl %cl, %edi + andl %esi, %ebx + orl %ebx, %edi + movl 20(%esp), %ebx + movl %edi, 28(%esp) + movl %ebx, %edi + movl (%esp), %ecx + shll %cl, %edi + movl %edx, %ecx + shrl %cl, %eax + andl %esi, %edi + orl %edi, %eax + movl %eax, 24(%esp) + shrl %cl, %ebx + movl %ebx, 20(%esp) + movl 4(%esp), %eax + jmp ..B1.58 +..B1.50: + cmpl $64, %edx + jge ..B1.52 +..B1.51: + movl %edx, %esi + movl %edx, %ecx + movl $-1, %edi + negl %esi + movl %esi, (%esp) + testl %eax, %eax + movl 28(%esp), %ebx + movl $0, %eax + setne %al + shrl %cl, %edi + movl (%esp), %ecx + notl %edi + shll %cl, %ebx + andl %edi, %ebx + movl 24(%esp), %esi + orl %eax, %ebx + movl %esi, %eax + shll %cl, %eax + movl %edx, %ecx + movl %ebx, 52(%esp) + andl %edi, %eax + movl 28(%esp), %ebx + shrl %cl, %ebx + movl (%esp), %ecx + orl %ebx, %eax + movl 20(%esp), %ebx + shll %cl, %ebx + movl %edx, %ecx + shrl %cl, %esi + andl %edi, %ebx + orl %esi, %ebx + movl %ebx, 28(%esp) + movl 20(%esp), %ebx + shrl %cl, %ebx + movl %ebx, 24(%esp) + movl $0, 20(%esp) + jmp ..B1.58 +..B1.52: + cmpl $96, %edx + jge ..B1.54 +..B1.53: + movl %edx, %edi + movl %edx, %ecx + movl $-1, %esi + negl %edi + movl %edi, (%esp) + shrl %cl, %esi + orl 28(%esp), %eax + notl %esi + movl (%esp), %ecx + movl $0, %eax + movl 24(%esp), %ebx + setne %al + shll %cl, %ebx + andl %esi, %ebx + orl %eax, %ebx + movl %ebx, 52(%esp) + movl 20(%esp), %ebx + movl %ebx, %eax + shll %cl, %eax + movl %edx, %ecx + andl %esi, %eax + xorl %edx, %edx + movl 24(%esp), %esi + shrl %cl, %esi + shrl %cl, %ebx + orl %esi, %eax + movl %ebx, 28(%esp) + movl %edx, 24(%esp) + movl %edx, 20(%esp) + jmp ..B1.58 +..B1.54: + cmpl $128, %edx + jge ..B1.56 +..B1.55: + movl %edx, %ebx + movl %edx, %ecx + negl %ebx + movl $-1, %edi + movl 20(%esp), %esi + shrl %cl, %edi + movl %ebx, %ecx + movl %esi, %ebx + notl %edi + shll %cl, %ebx + movl 24(%esp), %ecx + andl %edi, %ebx + orl 28(%esp), %ecx + orl %eax, %ecx + movl $0, %eax + movl %edx, %ecx + setne %al + xorl %edx, %edx + orl %eax, %ebx + movl %esi, %eax + movl %ebx, 52(%esp) + shrl %cl, %eax + movl %edx, 28(%esp) + movl %edx, 24(%esp) + movl %edx, 20(%esp) + jmp ..B1.58 +..B1.56: + movl 20(%esp), %edi + orl 24(%esp), %edi + orl 28(%esp), %edi + orl %eax, %edi + movl $0, %eax + setne %al + movl %eax, 52(%esp) + xorl %eax, %eax + movl %eax, 28(%esp) + movl %eax, 24(%esp) + movl %eax, 20(%esp) + jmp ..B1.58 +..B1.57: + movl $0, 52(%esp) +..B1.58: + movl 60(%esp), %ecx + cmpl 16(%esp), %ecx + jne ..B1.62 +..B1.59: + movl 44(%esp), %esi + addl %esi, %eax + xorl %ecx, %ecx + cmpl %esi, %eax + movl 48(%esp), %ebx + setb %cl + xorl %edi, %edi + addl 28(%esp), %ebx + adcl $0, %edi + addl %ecx, %ebx + movl 40(%esp), %ecx + adcl $0, %edi + addl 24(%esp), %ecx + movl %ebx, 48(%esp) + movl $0, %ebx + adcl $0, %ebx + addl %edi, %ecx + movl %ecx, 40(%esp) + movl 36(%esp), %ecx + adcl $0, %ebx + addl 20(%esp), %ecx + addl %ebx, %ecx + movl %ecx, 36(%esp) + testl $2097152, %ecx + je ..B1.61 +..B1.60: + orl 48(%esp), %eax + orl 52(%esp), %eax + movl 40(%esp), %esi + movl %esi, %edx + movl %ecx, %ebx + movl $0, %eax + movl %ebx, %ecx + setne %al + shll $31, %edx + shll $31, %ecx + orl %eax, %edx + shrl $1, %esi + shrl $1, %ebx + orl %ecx, %esi + andl $1048575, %ebx + incl 32(%esp) + movl %edx, 20(%esp) + movl %esi, 40(%esp) + movl %ebx, 36(%esp) + jmp ..B1.84 +..B1.61: + orl 52(%esp), %eax + movl $0, %eax + setne %al + orl 48(%esp), %eax + andl $1048575, 36(%esp) + movl %eax, 20(%esp) + jmp ..B1.84 +..B1.62: + xorl %ebx, %ebx + negl 52(%esp) + movl 44(%esp), %esi + setne %bl + xorl %edi, %edi + subl %eax, %esi + movl $0, %eax + sbbl $0, %eax + subl %ebx, %esi + movl 48(%esp), %ecx + sbbl $0, %eax + subl 28(%esp), %ecx + cltd + sbbl $0, %edi + addl %eax, %ecx + movl 40(%esp), %ebx + adcl %edx, %edi + subl 24(%esp), %ebx + movl %edi, %eax + movl %esi, 44(%esp) + movl $0, %esi + cltd + sbbl $0, %esi + addl %ebx, %edi + movl 36(%esp), %eax + adcl %edx, %esi + subl 20(%esp), %eax + movl %ecx, 48(%esp) + addl %esi, %eax + movl %edi, 16(%esp) + movl %eax, 36(%esp) + je ..B1.64 +..B1.63: + shll $11, %eax + movl $0, 4(%esp) + jmp ..B1.72 +..B1.64: + cmpl $0, 16(%esp) + je ..B1.66 +..B1.65: + movl %edi, %eax + movl $21, 4(%esp) + jmp ..B1.72 +..B1.66: + cmpl $0, 48(%esp) + je ..B1.68 +..B1.67: + movl %ecx, %eax + movl $53, 4(%esp) + jmp ..B1.72 +..B1.68: + cmpl $0, 44(%esp) + je ..B1.70 +..B1.69: + movl 44(%esp), %eax + movl $85, 4(%esp) + jmp ..B1.72 +..B1.70: + cmpl $0, 52(%esp) + je ..B1.123 +..B1.71: + movl 52(%esp), %eax + movl $117, 4(%esp) +..B1.72: + testl $-2147483648, %eax + jne ..B1.76 +..B1.73: + movl 4(%esp), %edx +..B1.74: + addl %eax, %eax + incl %edx + testl $-2147483648, %eax + je ..B1.74 +..B1.75: + movl %edx, 4(%esp) +..B1.76: + cmpl $32, 4(%esp) + jge ..B1.78 +..B1.77: + movl 4(%esp), %ebx + movl %ebx, %esi + movl 44(%esp), %eax + negl %esi + orl 52(%esp), %eax + movl %ebx, %ecx + movl %esi, (%esp) + movl $0, %eax + movl 48(%esp), %esi + movl %esi, %edx + setne %al + movl $1, %edi + shll %cl, %edx + orl %eax, %edx + movl %edx, 20(%esp) + movl 16(%esp), %edx + movl %edx, %eax + shll %cl, %edi + shll %cl, %eax + decl %edi + movl (%esp), %ecx + shrl %cl, %esi + movl %ebx, %ecx + andl %edi, %esi + orl %esi, %eax + movl %eax, 40(%esp) + movl 36(%esp), %eax + shll %cl, %eax + movl (%esp), %ecx + shrl %cl, %edx + andl %edi, %edx + orl %edx, %eax + andl $1048575, %eax + movl %eax, 36(%esp) + jmp ..B1.83 +..B1.78: + cmpl $64, 4(%esp) + jge ..B1.80 +..B1.79: + movl 4(%esp), %ebx + movl %ebx, %esi + cmpl $0, 52(%esp) + movl %ebx, %ecx + movl $0, %eax + setne %al + movl $1, %edi + negl %esi + movl %esi, (%esp) + movl 44(%esp), %esi + movl %esi, %edx + shll %cl, %edx + orl %eax, %edx + movl %edx, 20(%esp) + movl 48(%esp), %edx + movl %edx, %eax + shll %cl, %edi + shll %cl, %eax + decl %edi + movl (%esp), %ecx + shrl %cl, %esi + movl %ebx, %ecx + andl %edi, %esi + orl %esi, %eax + movl %eax, 40(%esp) + movl 16(%esp), %eax + shll %cl, %eax + movl (%esp), %ecx + shrl %cl, %edx + andl %edi, %edx + orl %edx, %eax + andl $1048575, %eax + movl %eax, 36(%esp) + jmp ..B1.83 +..B1.80: + cmpl $96, 4(%esp) + jge ..B1.82 +..B1.81: + movl 4(%esp), %edi + movl %edi, %ebx + negl %ebx + movl %edi, %ecx + movl %ebx, (%esp) + movl $1, %ebx + movl 44(%esp), %esi + movl %esi, %edx + movl 52(%esp), %eax + shll %cl, %ebx + shll %cl, %eax + decl %ebx + shll %cl, %edx + movl (%esp), %ecx + movl %eax, 20(%esp) + shrl %cl, %eax + movl %edi, %ecx + andl %ebx, %eax + orl %eax, %edx + movl %edx, 40(%esp) + movl 48(%esp), %edx + shll %cl, %edx + movl (%esp), %ecx + shrl %cl, %esi + andl %ebx, %esi + orl %esi, %edx + andl $1048575, %edx + movl %edx, 36(%esp) + jmp ..B1.83 +..B1.82: + movl 4(%esp), %ecx + xorl %eax, %eax + movl 44(%esp), %edx + shll %cl, %edx + andl $1048575, %edx + cmpl $128, %ecx + movl %eax, 20(%esp) + jl ..L3 + movl $0, %edx +..L3: + movl %eax, 40(%esp) + movl %edx, 36(%esp) +..B1.83: + movl 32(%esp), %eax + subl 4(%esp), %eax + movl %eax, 32(%esp) +..B1.84: + movl 32(%esp), %eax + lea -1(%eax), %edx + cmpl $2046, %edx + jb ..B1.92 +..B1.85: + cmpl $2047, 32(%esp) + jge ..B1.91 +..B1.86: + negl %eax + incl %eax + orl $1048576, 36(%esp) + movl %eax, 32(%esp) + cmpl $32, %eax + jge ..B1.88 +..B1.87: + movl %eax, %ecx + movl %ecx, %edx + negl %edx + movl $-1, %edi + movl 20(%esp), %eax + movl %eax, %ebx + shrl %cl, %edi + movl %edx, %ecx + movl 40(%esp), %esi + notl %edi + shll %cl, %esi + movl 32(%esp), %ecx + andl %edi, %esi + shrl %cl, %ebx + movl %edx, %ecx + shll %cl, %eax + orl %ebx, %esi + testl %edi, %eax + movl $0, %eax + setne %al + orl %esi, %eax + movl %eax, 20(%esp) + movl 36(%esp), %eax + movl %eax, %esi + shll %cl, %esi + movl 32(%esp), %ecx + andl %edi, %esi + movl 40(%esp), %edi + shrl %cl, %edi + orl %esi, %edi + movl %edi, 40(%esp) + shrl %cl, %eax + jmp ..B1.93 +..B1.88: + xorl %eax, %eax + cmpl $53, 32(%esp) + jg ..B1.90 +..B1.89: + movl %eax, (%esp) + movl 32(%esp), %eax + movl %eax, %edx + negl %edx + movl %eax, %ecx + movl %edx, 4(%esp) + movl $-1, %edx + shrl %cl, %edx + movl 4(%esp), %ecx + notl %edx + movl 36(%esp), %edi + movl 40(%esp), %esi + movl %esi, %ebx + shll %cl, %edi + movl %eax, %ecx + shrl %cl, %ebx + andl %edx, %edi + movl 4(%esp), %ecx + orl %ebx, %edi + shll %cl, %esi + movl %eax, %ecx + andl %edx, %esi + xorl %edx, %edx + orl 20(%esp), %esi + movl 36(%esp), %esi + setne %dl + shrl %cl, %esi + orl %edi, %edx + movl (%esp), %eax + movl %edx, 20(%esp) + movl %esi, 40(%esp) + jmp ..B1.93 +..B1.90: + movl $1, 20(%esp) + movl %eax, 40(%esp) + jmp ..B1.94 +..B1.91: + movl 60(%esp), %eax + shrl $31, %eax + movl 64(%esp), %edx + fldl _large_value_64@GOTOFF(%edx,%eax,8) + fmull _large_value_64@GOTOFF(%edx) + fstl 8(%esp) + fstl (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.92: + movl %eax, %edx + shll $20, %edx + movl 36(%esp), %eax + orl %edx, %eax +..B1.93: + cmpl $0, 20(%esp) + je ..B1.122 +..B1.94: + movl 64(%esp), %edx + cmpl $0, 56(%esp) + fldl _small_value_64@GOTOFF(%edx) + fldl _ones@GOTOFF(%edx) + fadd %st(1), %st + fstpl 8(%esp) + je ..B1.124 +..B1.95: + cmpl $3072, 56(%esp) + je ..B1.118 +..B1.96: + cmpl $2048, 56(%esp) + jne ..B1.107 +..B1.97: + cmpl $0, 60(%esp) + je ..B1.99 +..B1.98: + cmpl $1048576, %eax + jb ..B1.104 + jmp ..B1.139 +..B1.99: + cmpl $1048575, %eax + jb ..B1.104 +..B1.100: + jne ..B1.105 +..B1.101: + cmpl $-1, 40(%esp) + jb ..B1.104 +..B1.102: + jne ..B1.105 +..B1.103: + cmpl $-2147483648, 20(%esp) + jae ..B1.105 +..B1.104: + fmul %st(0), %st + fstl 8(%esp) + cmpl $0, 60(%esp) + jne ..B1.139 +..B1.105: + fstp %st(0) + xorl %edx, %edx + incl 40(%esp) + sete %dl + addl %edx, %eax + cmpl $2146435072, %eax + jb ..B1.122 +..B1.106: + movl 60(%esp), %eax + shrl $31, %eax + movl 64(%esp), %edx + fldl _large_value_64@GOTOFF(%edx,%eax,8) + fmull _large_value_64@GOTOFF(%edx) + fstl 8(%esp) + fstl (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.107: + cmpl $1024, 56(%esp) + jne ..B1.139 +..B1.108: + cmpl $0, 60(%esp) + jne ..B1.110 +..B1.109: + cmpl $1048576, %eax + jb ..B1.115 + jmp ..B1.139 +..B1.110: + cmpl $1048575, %eax + jb ..B1.115 +..B1.111: + jne ..B1.116 +..B1.112: + cmpl $-1, 40(%esp) + jb ..B1.115 +..B1.113: + jne ..B1.116 +..B1.114: + cmpl $-2147483648, 20(%esp) + jae ..B1.116 +..B1.115: + fmul %st(0), %st + fstl 8(%esp) + cmpl $0, 60(%esp) + je ..B1.139 +..B1.116: + fstp %st(0) + xorl %edx, %edx + incl 40(%esp) + sete %dl + addl %edx, %eax + cmpl $2146435072, %eax + jb ..B1.122 +..B1.117: + movl 60(%esp), %eax + shrl $31, %eax + movl 64(%esp), %edx + fldl _large_value_64@GOTOFF(%edx,%eax,8) + fmull _large_value_64@GOTOFF(%edx) + fstl 8(%esp) + fstl (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.118: + cmpl $1048576, %eax + jb ..B1.121 +..B1.119: + lea -1048576(%eax), %edx + orl 40(%esp), %edx + jne ..B1.139 +..B1.120: + cmpl $-2147483648, 20(%esp) + jne ..B1.139 +..B1.121: + fmul %st(0), %st + fstpl 8(%esp) +..B1.122: + movl 60(%esp), %edx + orl %eax, %edx + movl 40(%esp), %eax + movl %edx, 4(%esp) + movl %eax, (%esp) + fldl (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.123: + xorl %eax, %eax + cmpl $1024, 56(%esp) + movl 64(%esp), %edi + sete %al + fldl _zeros@GOTOFF(%edi,%eax,8) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.124: + testl $-2147483648, 20(%esp) + je ..B1.118 +..B1.125: + movl 40(%esp), %ecx + movl 20(%esp), %edx + andl $1, %ecx + andl $2147483647, %edx + orl %edx, %ecx + je ..B1.118 +..B1.126: + xorl %edx, %edx + incl 40(%esp) + sete %dl + addl %edx, %eax + cmpl $2146435072, %eax + jb ..B1.118 +..B1.127: + fstp %st(0) + movl 60(%esp), %eax + shrl $31, %eax + movl 64(%esp), %edx + fldl _large_value_64@GOTOFF(%edx,%eax,8) + fmull _large_value_64@GOTOFF(%edx) + fstl 8(%esp) + fstl (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.139: + fstp %st(0) + jmp ..B1.122 + .align 16,0x90 + .type fma,@function + .size fma,.-fma + .data +# -- End fma + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmaf_wmt.S b/external/sgx_libm/ia32/fmaf_wmt.S new file mode 100644 index 0000000000..b76202b99e --- /dev/null +++ b/external/sgx_libm/ia32/fmaf_wmt.S @@ -0,0 +1,425 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmaf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fmaf + .text + .align 16,0x90 + .globl fmaf +fmaf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $136, %esp + movl %ebx, 80(%esp) + call static_func + movl %eax, %ebx + movss 144(%esp), %xmm0 + movss 148(%esp), %xmm1 + movss 152(%esp), %xmm2 + movss %xmm0, 8(%esp) + movss %xmm1, 16(%esp) + movss %xmm2, 24(%esp) + movl 8(%esp), %eax + ucomiss %xmm1, %xmm0 + movl 16(%esp), %ecx + jp .L_2TAG_PACKET_0.0.2 + movl 24(%esp), %edx + ucomiss %xmm2, %xmm2 + jp .L_2TAG_PACKET_1.0.2 + andl $2147483647, %eax + je .L_2TAG_PACKET_2.0.2 + cmpl $1065353216, %eax + je .L_2TAG_PACKET_3.0.2 + cmpl $2139095040, %eax + je .L_2TAG_PACKET_4.0.2 + andl $2147483647, %ecx + je .L_2TAG_PACKET_2.0.2 + cmpl $1065353216, %ecx + je .L_2TAG_PACKET_3.0.2 + cmpl $2139095040, %ecx + je .L_2TAG_PACKET_4.0.2 + andl $2147483647, %edx + je .L_2TAG_PACKET_5.0.2 + cmpl $2139095040, %edx + je .L_2TAG_PACKET_6.0.2 + cmpl $8388608, %eax + jl .L_2TAG_PACKET_7.0.2 + cvtps2pd %xmm0, %xmm3 +.L_2TAG_PACKET_8.0.2: + cmpl $8388608, %ecx + jl .L_2TAG_PACKET_9.0.2 + cvtps2pd %xmm1, %xmm4 +.L_2TAG_PACKET_10.0.2: + cmpl $8388608, %edx + jl .L_2TAG_PACKET_11.0.2 + cvtps2pd %xmm2, %xmm0 +.L_2TAG_PACKET_12.0.2: + mulsd %xmm4, %xmm3 + pextrw $3, %xmm3, %edx + andl $32752, %edx + movl $96, %eax + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + addl %edx, %eax + subl %ecx, %eax + cmpl $560, %eax + jae .L_2TAG_PACKET_13.0.2 + addsd %xmm3, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_0.0.2: +.L_2TAG_PACKET_2.0.2: +.L_2TAG_PACKET_3.0.2: +.L_2TAG_PACKET_4.0.2: +.L_2TAG_PACKET_5.0.2: + flds 8(%esp) + fmuls 16(%esp) + fadds 24(%esp) + jmp .L_2TAG_PACKET_15.0.2 +.L_2TAG_PACKET_1.0.2: + flds 8(%esp) + fadds 24(%esp) + jmp .L_2TAG_PACKET_15.0.2 +.L_2TAG_PACKET_6.0.2: + flds 24(%esp) + jmp .L_2TAG_PACKET_15.0.2 +.L_2TAG_PACKET_7.0.2: + movaps (%ebx), %xmm3 + pand %xmm0, %xmm3 + movaps 48(%ebx), %xmm5 + orpd 16(%ebx), %xmm3 + pand %xmm0, %xmm5 + subsd 16(%ebx), %xmm3 + psllq $32, %xmm5 + mulsd 32(%ebx), %xmm3 + orpd %xmm5, %xmm3 + jmp .L_2TAG_PACKET_8.0.2 +.L_2TAG_PACKET_9.0.2: + movaps (%ebx), %xmm4 + pand %xmm1, %xmm4 + movaps 48(%ebx), %xmm5 + orpd 16(%ebx), %xmm4 + pand %xmm1, %xmm5 + subsd 16(%ebx), %xmm4 + psllq $32, %xmm5 + mulsd 32(%ebx), %xmm4 + orpd %xmm5, %xmm4 + jmp .L_2TAG_PACKET_10.0.2 +.L_2TAG_PACKET_11.0.2: + movaps (%ebx), %xmm0 + pand %xmm2, %xmm0 + movaps 48(%ebx), %xmm5 + orpd 16(%ebx), %xmm0 + pand %xmm2, %xmm5 + subsd 16(%ebx), %xmm0 + psllq $32, %xmm5 + mulsd 32(%ebx), %xmm0 + orpd %xmm5, %xmm0 + jmp .L_2TAG_PACKET_12.0.2 +.L_2TAG_PACKET_13.0.2: + pextrw $1, %xmm2, %ecx + pextrw $3, %xmm3, %edx + sarl $4, %eax + xorl %edx, %ecx + testl $32768, %ecx + jne .L_2TAG_PACKET_16.0.2 + cmpl $53, %eax + jge .L_2TAG_PACKET_17.0.2 + cmpl $-19, %eax + jle .L_2TAG_PACKET_18.0.2 + cmpl $6, %eax + jge .L_2TAG_PACKET_19.0.2 + movl $6, %ecx + subl %eax, %ecx + addl $58, %eax + movsd 64(%ebx), %xmm1 + pand 64(%ebx), %xmm3 + pxor %xmm5, %xmm5 + por 96(%ebx), %xmm3 + pxor %xmm2, %xmm2 + pinsrw $0, %eax, %xmm5 + pinsrw $0, %ecx, %xmm2 + pand %xmm0, %xmm1 + pand 80(%ebx), %xmm0 + movdqa %xmm3, %xmm4 + psllq %xmm5, %xmm3 + por 96(%ebx), %xmm1 + psrlq %xmm2, %xmm4 + psrlq $40, %xmm3 + paddq %xmm4, %xmm1 + movdqa %xmm1, %xmm5 + psrlq $53, %xmm1 + movdqa %xmm5, %xmm4 + psrlq %xmm1, %xmm5 + pand %xmm1, %xmm4 + psllq $52, %xmm1 + por %xmm3, %xmm5 + paddq %xmm1, %xmm0 + por %xmm4, %xmm5 + pand 64(%ebx), %xmm5 + por %xmm5, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_17.0.2: + movapd 112(%ebx), %xmm0 + orpd %xmm3, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_18.0.2: + orpd 112(%ebx), %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_19.0.2: + movl $70, %ecx + subl %eax, %ecx + subl $6, %eax + movsd 64(%ebx), %xmm1 + pand 64(%ebx), %xmm0 + pxor %xmm5, %xmm5 + por 96(%ebx), %xmm0 + pxor %xmm2, %xmm2 + pinsrw $0, %ecx, %xmm5 + pinsrw $0, %eax, %xmm2 + pand %xmm3, %xmm1 + pand 80(%ebx), %xmm3 + movdqa %xmm0, %xmm4 + psllq %xmm5, %xmm0 + por 96(%ebx), %xmm1 + psrlq %xmm2, %xmm4 + pxor %xmm2, %xmm2 + psrlq $18, %xmm0 + psubq %xmm0, %xmm2 + paddq %xmm4, %xmm1 + psrlq $63, %xmm2 + movdqa %xmm1, %xmm0 + psrlq $53, %xmm1 + movdqa %xmm0, %xmm4 + psrlq %xmm1, %xmm0 + pand %xmm1, %xmm4 + psllq $52, %xmm1 + por %xmm2, %xmm0 + paddq %xmm1, %xmm3 + por %xmm4, %xmm0 + pand 64(%ebx), %xmm0 + por %xmm3, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_16.0.2: + cmpl $53, %eax + jge .L_2TAG_PACKET_20.0.2 + cmpl $-22, %eax + jle .L_2TAG_PACKET_21.0.2 + cmpl $6, %eax + jge .L_2TAG_PACKET_22.0.2 + movl $6, %ecx + subl %eax, %ecx + addl $58, %eax + movsd 64(%ebx), %xmm1 + pand 64(%ebx), %xmm3 + pxor %xmm5, %xmm5 + por 96(%ebx), %xmm3 + pxor %xmm2, %xmm2 + pinsrw $0, %eax, %xmm5 + pinsrw $0, %ecx, %xmm2 + pand %xmm0, %xmm1 + pand 80(%ebx), %xmm0 + movdqa %xmm3, %xmm4 + psllq %xmm5, %xmm3 + por 96(%ebx), %xmm1 + psrlq %xmm2, %xmm4 + pxor %xmm2, %xmm2 + psrlq $37, %xmm3 + psubq %xmm3, %xmm2 + psubq %xmm4, %xmm1 + psrlq $63, %xmm2 + psubq %xmm2, %xmm1 + movdqa %xmm1, %xmm3 + movsd 112(%ebx), %xmm2 + psrlq $52, %xmm1 + psubq %xmm1, %xmm2 + movdqa %xmm2, %xmm1 + psllq $52, %xmm2 + psllq %xmm1, %xmm3 + pand 64(%ebx), %xmm3 + psubq %xmm2, %xmm0 + por %xmm3, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_20.0.2: + movsd 64(%ebx), %xmm1 + pand %xmm3, %xmm1 + por 96(%ebx), %xmm1 + psubq 112(%ebx), %xmm1 + movapd %xmm1, %xmm0 + psrlq $52, %xmm1 + movapd 112(%ebx), %xmm4 + psubq %xmm1, %xmm4 + psllq %xmm4, %xmm0 + psllq $52, %xmm4 + pand 80(%ebx), %xmm3 + psubq %xmm4, %xmm3 + pand 64(%ebx), %xmm0 + por %xmm3, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_21.0.2: + movsd 64(%ebx), %xmm1 + pand %xmm0, %xmm1 + por 96(%ebx), %xmm1 + psubq 112(%ebx), %xmm1 + movapd %xmm1, %xmm2 + psrlq $52, %xmm1 + movapd 112(%ebx), %xmm3 + psubq %xmm1, %xmm3 + psllq %xmm3, %xmm2 + psllq $52, %xmm3 + pand 80(%ebx), %xmm0 + psubq %xmm3, %xmm0 + pand 64(%ebx), %xmm2 + por %xmm2, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_22.0.2: + movl $70, %ecx + subl %eax, %ecx + subl $6, %eax + movsd 64(%ebx), %xmm1 + pand 64(%ebx), %xmm0 + pxor %xmm5, %xmm5 + por 96(%ebx), %xmm0 + pxor %xmm2, %xmm2 + pinsrw $0, %ecx, %xmm5 + pinsrw $0, %eax, %xmm2 + pand %xmm3, %xmm1 + pand 80(%ebx), %xmm3 + movdqa %xmm0, %xmm4 + psllq %xmm5, %xmm0 + por 96(%ebx), %xmm1 + psrlq %xmm2, %xmm4 + pxor %xmm2, %xmm2 + psrlq $18, %xmm0 + psubq %xmm0, %xmm2 + psubq %xmm4, %xmm1 + psrlq $63, %xmm2 + psubq %xmm2, %xmm1 + movdqa %xmm1, %xmm0 + movsd 112(%ebx), %xmm2 + psrlq $52, %xmm1 + psubq %xmm1, %xmm2 + movdqa %xmm2, %xmm1 + psllq $52, %xmm2 + psllq %xmm1, %xmm0 + pand 64(%ebx), %xmm0 + psubq %xmm2, %xmm3 + por %xmm3, %xmm0 + jmp .L_2TAG_PACKET_14.0.2 +.L_2TAG_PACKET_14.0.2: + movq %xmm0, (%esp) + fldl (%esp) + fstps 32(%esp) + flds 32(%esp) +.L_2TAG_PACKET_15.0.2: + movl 80(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fmaf,@function + .size fmaf,.-fmaf + .data +# -- End fmaf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 970981376 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 4294967295 + .long 1048575 + .long 0 + .long 0 + .long 0 + .long 4293918720 + .long 0 + .long 0 + .long 0 + .long 1048576 + .long 0 + .long 0 + .long 1 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,128 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmal.S b/external/sgx_libm/ia32/fmal.S new file mode 100644 index 0000000000..d7267db387 --- /dev/null +++ b/external/sgx_libm/ia32/fmal.S @@ -0,0 +1,1483 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmal.c" + .text +..TXTST0: +# -- Begin fmal + .text + .align 16,0x90 + .globl fmal +fmal: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 32 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $100, %esp +..B1.2: + fnstcw 62(%esp) +..B1.3: + fnstcw 88(%esp) +..B1.4: + movzbl 17(%ebp), %edi + movzbl 41(%ebp), %ebx + andl $128, %edi + andl $128, %ebx + movzbl 29(%ebp), %edx + shrl $7, %edi + andl $128, %edx + shrl $7, %ebx + movzwl 88(%esp), %ecx + movl %edi, 80(%esp) + andl $3072, %ecx + movl %ebx, 84(%esp) + movzwl 16(%ebp), %edi + movzwl 40(%ebp), %ebx + movl %ebx, %eax + movl %ecx, 72(%esp) + movl %edi, %ecx + shrl $7, %edx + andl $32767, %ecx + movzwl 28(%ebp), %esi + andl $32767, %eax + movl %edx, 32(%esp) + movl %esi, %edx + movl %eax, 56(%esp) + andl $32767, %edx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $32767, %ecx + movl %eax, 76(%esp) + je ..B1.21 +..B1.5: + testl %ecx, %ecx + jne ..B1.8 +..B1.6: + cmpl $0, 12(%ebp) + jne ..B1.9 +..B1.7: + cmpl $0, 8(%ebp) + je ..B1.20 + jmp ..B1.9 +..B1.8: + cmpl $16383, %ecx + je ..B1.204 +..B1.9: + cmpl $32767, %edx + je ..B1.18 +..B1.10: + testl %edx, %edx + jne ..B1.13 +..B1.11: + cmpl $0, 24(%ebp) + jne ..B1.14 +..B1.12: + cmpl $0, 20(%ebp) + je ..B1.18 + jmp ..B1.14 +..B1.13: + cmpl $16383, %edx + je ..B1.202 +..B1.14: + cmpl $32767, 56(%esp) + je ..B1.18 +..B1.15: + cmpl $0, 56(%esp) + jne ..B1.54 +..B1.16: + cmpl $0, 36(%ebp) + jne ..B1.54 +..B1.17: + cmpl $0, 32(%ebp) + jne ..B1.54 +..B1.18: + testl %ecx, %ecx + jne ..B1.21 +..B1.19: + cmpl $0, 12(%ebp) + jne ..B1.27 +..B1.209: + cmpl $0, 8(%ebp) +..B1.20: + jne ..B1.27 +..B1.21: + testl %edx, %edx + jne ..B1.24 +..B1.22: + cmpl $0, 24(%ebp) + jne ..B1.27 +..B1.23: + cmpl $0, 20(%ebp) + jne ..B1.27 +..B1.24: + cmpl $0, 56(%esp) + jne ..B1.28 +..B1.25: + cmpl $0, 36(%ebp) + jne ..B1.27 +..B1.26: + cmpl $0, 32(%ebp) + je ..B1.28 +..B1.27: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 64(%esp) +..B1.28: + cmpl $32767, %ecx + je ..B1.185 +..B1.29: + cmpl $32767, %edx + je ..B1.176 +..B1.30: + cmpl $32767, 56(%esp) + je ..B1.167 +..B1.31: + cmpl $32767, %ecx + jge ..B1.34 +..B1.32: + cmpl $32767, %edx + jge ..B1.34 +..B1.33: + cmpl $32767, 56(%esp) + je ..B1.206 +..B1.34: + movzwl 62(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.166 +..B1.35: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.36: + fldcw 60(%esp) +..B1.37: + movzwl 16(%ebp), %edi + movl $1, %edx +..B1.38: + fldt 8(%ebp) + testl $32767, %edi + fldt 20(%ebp) + fmulp %st, %st(1) + jne ..B1.41 +..B1.39: + cmpl $0, 12(%ebp) + jne ..B1.41 +..B1.40: + cmpl $0, 8(%ebp) + je ..B1.50 +..B1.41: + movzwl 28(%ebp), %eax + testl $32767, %eax + jne ..B1.46 +..B1.42: + cmpl $0, 24(%ebp) + jne ..B1.46 +..B1.43: + cmpl $0, 20(%ebp) + je ..B1.50 +..B1.46: + fstpt 20(%esp) + fldt 20(%esp) +..B1.47: + movzwl 28(%esp), %eax + testl $32767, %eax + jne ..B1.50 +..B1.48: + cmpl $0, 24(%esp) + jne ..B1.50 +..B1.49: + cmpl $0, 20(%esp) + je ..B1.51 +..B1.50: + fldt 32(%ebp) + faddp %st, %st(1) + fstpt 20(%esp) + fldt 20(%esp) +..B1.51: + fstp %st(0) + testl %edx, %edx + je ..B1.53 +..B1.52: + fldcw 62(%esp) +..B1.53: + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.54: + testl %ecx, %ecx + je ..B1.57 +..B1.55: + testl %edx, %edx + je ..B1.57 +..B1.56: + cmpl $0, 56(%esp) + jne ..B1.69 +..B1.57: + fldl _smallest_value_64@GOTOFF(%eax) + movzwl 62(%esp), %eax + movl %eax, (%esp) + andl $768, %eax + fstpl 64(%esp) + cmpl $768, %eax + je ..B1.201 +..B1.58: + movl (%esp), %eax + orl $-64768, %eax + movw %ax, 60(%esp) +..B1.59: + fldcw 60(%esp) +..B1.60: + movzwl 16(%ebp), %edi + movl $1, %eax + movzwl 28(%ebp), %esi + movzwl 40(%ebp), %ebx +..B1.61: + testl $32767, %edi + jne ..B1.63 +..B1.62: + andl $-32768, %edi + orl $-49153, %edi + movw %di, 16(%ebp) + movl 76(%esp), %ecx + movl 80(%esp), %edi + orl $-2147483648, 12(%ebp) + fldt 8(%ebp) + fsubl _ones@GOTOFF(%ecx,%edi,8) + fstpt 8(%ebp) + movzwl 16(%ebp), %ecx + andl $32767, %ecx + addl $-16382, %ecx +..B1.63: + testl $32767, %esi + jne ..B1.65 +..B1.64: + andl $-32768, %esi + orl $-49153, %esi + movw %si, 28(%ebp) + movl 76(%esp), %edx + movl 32(%esp), %esi + orl $-2147483648, 24(%ebp) + fldt 20(%ebp) + fsubl _ones@GOTOFF(%edx,%esi,8) + fstpt 20(%ebp) + movzwl 28(%ebp), %edx + andl $32767, %edx + addl $-16382, %edx +..B1.65: + testl $32767, %ebx + jne ..B1.67 +..B1.66: + andl $-32768, %ebx + orl $-49153, %ebx + movw %bx, 40(%ebp) + movl 76(%esp), %ebx + movl 84(%esp), %esi + orl $-2147483648, 36(%ebp) + fldt 32(%ebp) + fsubl _ones@GOTOFF(%ebx,%esi,8) + fstpt 32(%ebp) + movzwl 40(%ebp), %edi + andl $32767, %edi + addl $-16382, %edi + movl %edi, 56(%esp) +..B1.67: + testl %eax, %eax + je ..B1.69 +..B1.68: + fldcw 62(%esp) +..B1.69: + movl 36(%ebp), %eax + lea -16383(%ecx,%edx), %edx + movl %eax, 4(%esp) + movl 32(%ebp), %eax + movl %eax, (%esp) + movl 32(%esp), %eax + movl 8(%ebp), %edi + xorl %eax, 80(%esp) + movl %edi, %eax + movl 20(%ebp), %ebx + movl %edx, 52(%esp) + mull %ebx + movl %eax, 44(%esp) + movl %ebx, %eax + movl 12(%ebp), %esi + movl %edx, 20(%esp) + mull %esi + movl %eax, %ecx + movl %edi, %eax + movl 24(%ebp), %ebx + movl %edx, 24(%esp) + mull %ebx + movl %eax, %edi + movl %esi, %eax + movl %edx, 28(%esp) + xorl %esi, %esi + addl %edi, %ecx + adcl $0, %esi + mull %ebx + addl 20(%esp), %ecx + movl %edx, %ebx + movl %ecx, 48(%esp) + adcl $0, %esi + xorl %edx, %edx + addl %eax, %esi + movl 24(%esp), %ecx + adcl $0, %edx + xorl %eax, %eax + addl 28(%esp), %ecx + adcl $0, %eax + addl %ecx, %esi + adcl %eax, %edx + addl %edx, %ebx + movl 52(%esp), %edx + testl $-2147483648, %ebx + je ..B1.71 +..B1.70: + incl %edx + jmp ..B1.72 +..B1.71: + movl %esi, %edi + addl %ebx, %ebx + shrl $31, %edi + addl %esi, %esi + movl 48(%esp), %eax + orl %edi, %ebx + movl %eax, %edi + addl %eax, %eax + shrl $31, %edi + movl 44(%esp), %ecx + orl %edi, %esi + movl %ecx, %edi + addl %ecx, %ecx + shrl $31, %edi + orl %edi, %eax + movl %eax, 48(%esp) + movl %ecx, 44(%esp) +..B1.72: + cmpl 56(%esp), %edx + jg ..B1.77 +..B1.73: + jne ..B1.78 +..B1.74: + cmpl 4(%esp), %ebx + ja ..B1.77 +..B1.75: + jne ..B1.78 +..B1.76: + cmpl (%esp), %esi + jb ..B1.78 +..B1.77: + movl %edx, %eax + subl 56(%esp), %eax + movl 4(%esp), %edi + movl %eax, 32(%esp) + movl (%esp), %eax + movl %edi, 28(%esp) + xorl %edi, %edi + movl %eax, 36(%esp) + movl %edi, 40(%esp) + jmp ..B1.79 +..B1.78: + movl 56(%esp), %eax + movl %eax, %edi + subl %edx, %edi + movl %eax, %edx + movl 80(%esp), %eax + movl %eax, 84(%esp) + movzbl 41(%ebp), %eax + movl %ebx, 28(%esp) + andl $128, %eax + movl 48(%esp), %ebx + movl %edi, 32(%esp) + shrl $7, %eax + movl %esi, 36(%esp) + movl %ebx, 40(%esp) + movl 44(%esp), %edi + movl %eax, 80(%esp) + xorl %eax, %eax + movl 4(%esp), %ebx + movl (%esp), %esi + movl %eax, 44(%esp) + movl %eax, 48(%esp) +..B1.79: + cmpl $0, 32(%esp) + je ..B1.89 +..B1.80: + cmpl $32, 32(%esp) + jge ..B1.82 +..B1.81: + movl %esi, 20(%esp) + movl %edi, %eax + movl 32(%esp), %esi + movl %esi, %ecx + movl %edx, 52(%esp) + movl %esi, %edx + movl %ebx, 24(%esp) + negl %edx + movl $-1, %ebx + shrl %cl, %ebx + movl %edx, %ecx + shll %cl, %eax + notl %ebx + movl %eax, 56(%esp) + movl 40(%esp), %eax + shll %cl, %eax + movl %esi, %ecx + shrl %cl, %edi + andl %ebx, %eax + orl %eax, %edi + movl %edx, %ecx + movl %edi, 4(%esp) + movl 36(%esp), %edi + movl %edi, %eax + shll %cl, %eax + movl %esi, %ecx + andl %ebx, %eax + movl %eax, (%esp) + movl 40(%esp), %eax + shrl %cl, %eax + movl %edx, %ecx + orl (%esp), %eax + movl 28(%esp), %edx + movl %eax, 40(%esp) + movl %edx, %eax + shll %cl, %eax + movl %esi, %ecx + shrl %cl, %edi + andl %ebx, %eax + shrl %cl, %edx + orl %eax, %edi + movl %edi, 36(%esp) + movl %edx, 28(%esp) + movl 20(%esp), %esi + movl 52(%esp), %edx + movl 24(%esp), %ebx + movl 4(%esp), %edi + jmp ..B1.90 +..B1.82: + cmpl $64, 32(%esp) + jge ..B1.84 +..B1.83: + movl %ebx, 24(%esp) + movl 32(%esp), %ebx + movl %ebx, %ecx + movl %edx, 52(%esp) + movl %ebx, %edx + movl %esi, 20(%esp) + negl %edx + movl $-1, %esi + shrl %cl, %esi + movl %edx, %ecx + movl 40(%esp), %eax + notl %esi + shll %cl, %eax + xorl %ecx, %ecx + testl %edi, %edi + movl %esi, (%esp) + setne %cl + andl (%esp), %eax + movl 36(%esp), %esi + orl %ecx, %eax + movl %edx, %ecx + movl %esi, %edi + shll %cl, %edi + movl %ebx, %ecx + movl %eax, 56(%esp) + movl 40(%esp), %eax + andl (%esp), %edi + shrl %cl, %eax + movl %edx, %ecx + movl 28(%esp), %edx + orl %eax, %edi + movl %edx, %eax + shll %cl, %eax + movl %ebx, %ecx + andl (%esp), %eax + shrl %cl, %esi + shrl %cl, %edx + orl %esi, %eax + movl %edx, 36(%esp) + movl %eax, 40(%esp) + movl $0, 28(%esp) + movl 20(%esp), %esi + movl 52(%esp), %edx + movl 24(%esp), %ebx + jmp ..B1.90 +..B1.84: + cmpl $96, 32(%esp) + jge ..B1.86 +..B1.85: + movl %edx, 52(%esp) + movl 32(%esp), %edx + movl %edx, %ecx + movl %ebx, 24(%esp) + movl %edx, %ebx + movl %esi, 20(%esp) + movl $-1, %esi + negl %ebx + movl %ebx, (%esp) + shrl %cl, %esi + xorl %ebx, %ebx + orl 40(%esp), %edi + notl %esi + movl (%esp), %ecx + movl 36(%esp), %eax + setne %bl + shll %cl, %eax + andl %esi, %eax + orl %ebx, %eax + movl %eax, 56(%esp) + movl 28(%esp), %eax + movl %eax, %edi + shll %cl, %edi + movl %edx, %ecx + andl %esi, %edi + xorl %edx, %edx + movl 36(%esp), %esi + shrl %cl, %esi + shrl %cl, %eax + orl %esi, %edi + movl %edx, 36(%esp) + movl %edx, 28(%esp) + movl %eax, 40(%esp) + movl 20(%esp), %esi + movl 52(%esp), %edx + movl 24(%esp), %ebx + jmp ..B1.90 +..B1.86: + cmpl $128, 32(%esp) + jge ..B1.88 +..B1.87: + movl %edx, 52(%esp) + movl 32(%esp), %edx + movl %edx, %eax + movl %ebx, 24(%esp) + negl %eax + movl %edx, %ecx + movl $-1, %ebx + movl %esi, 20(%esp) + movl 28(%esp), %esi + shrl %cl, %ebx + movl %eax, %ecx + movl %esi, %eax + notl %ebx + shll %cl, %eax + movl 36(%esp), %ecx + andl %ebx, %eax + orl 40(%esp), %ecx + xorl %ebx, %ebx + orl %edi, %ecx + movl %edx, %ecx + movl %esi, %edi + setne %bl + xorl %edx, %edx + movl %edx, 40(%esp) + orl %ebx, %eax + movl %edx, 36(%esp) + movl %edx, 28(%esp) + movl %eax, 56(%esp) + shrl %cl, %edi + movl 20(%esp), %esi + movl 52(%esp), %edx + movl 24(%esp), %ebx + jmp ..B1.90 +..B1.88: + movl 28(%esp), %ecx + orl 36(%esp), %ecx + xorl %eax, %eax + orl 40(%esp), %ecx + orl %edi, %ecx + setne %al + xorl %edi, %edi + movl %eax, 56(%esp) + movl %edi, 40(%esp) + movl %edi, 36(%esp) + movl %edi, 28(%esp) + jmp ..B1.90 +..B1.89: + movl $0, 56(%esp) +..B1.90: + movl 80(%esp), %eax + cmpl 84(%esp), %eax + jne ..B1.94 +..B1.91: + movl 44(%esp), %eax + addl %eax, %edi + cmpl %eax, %edi + movl $0, %eax + movl 48(%esp), %ecx + setb %al + addl 40(%esp), %ecx + movl %edi, 4(%esp) + movl $0, %edi + adcl $0, %edi + addl %eax, %ecx + adcl $0, %edi + xorl %eax, %eax + addl 36(%esp), %esi + movl %ecx, 48(%esp) + adcl $0, %eax + addl %edi, %esi + adcl $0, %eax + xorl %edi, %edi + addl 28(%esp), %ebx + adcl $0, %edi + addl %eax, %ebx + adcl $0, %edi + movl 4(%esp), %edi + je ..B1.93 +..B1.92: + orl 48(%esp), %edi + movl %esi, %eax + shll $31, %eax + incl %edx + orl 56(%esp), %edi + movl %eax, 36(%esp) + movl %ebx, %edi + movl $0, %eax + setne %al + shll $31, %edi + shrl $1, %esi + shrl $1, %ebx + orl %edi, %esi + orl %eax, 36(%esp) + orl $-2147483648, %ebx + jmp ..B1.116 +..B1.93: + orl 56(%esp), %edi + movl $0, %eax + setne %al + orl 48(%esp), %eax + movl %eax, 36(%esp) + jmp ..B1.116 +..B1.94: + negl 56(%esp) + movl %edx, 52(%esp) + movl $0, %edx + movl 44(%esp), %ecx + setne %dl + xorl %eax, %eax + subl %edi, %ecx + movl 48(%esp), %edi + sbbl $0, %eax + subl %edx, %ecx + movl %ecx, 44(%esp) + sbbl $0, %eax + xorl %ecx, %ecx + subl 40(%esp), %edi + cltd + sbbl $0, %ecx + addl %eax, %edi + movl %edi, 48(%esp) + adcl %edx, %ecx + xorl %edi, %edi + subl 36(%esp), %esi + movl %ecx, %eax + cltd + sbbl $0, %edi + addl %esi, %ecx + movl %ecx, 32(%esp) + adcl %edx, %edi + subl 28(%esp), %ebx + movl 52(%esp), %edx + addl %edi, %ebx + je ..B1.96 +..B1.95: + movl $0, 28(%esp) + movl %ebx, %eax + jmp ..B1.104 +..B1.96: + cmpl $0, 32(%esp) + je ..B1.98 +..B1.97: + movl %ecx, %eax + movl $32, 28(%esp) + jmp ..B1.104 +..B1.98: + cmpl $0, 48(%esp) + je ..B1.100 +..B1.99: + movl 48(%esp), %eax + movl $64, 28(%esp) + jmp ..B1.104 +..B1.100: + cmpl $0, 44(%esp) + je ..B1.102 +..B1.101: + movl 44(%esp), %eax + movl $96, 28(%esp) + jmp ..B1.104 +..B1.102: + cmpl $0, 56(%esp) + je ..B1.165 +..B1.103: + movl 56(%esp), %eax + movl $128, 28(%esp) +..B1.104: + testl $-2147483648, %eax + jne ..B1.108 +..B1.105: + movl 28(%esp), %esi +..B1.106: + addl %eax, %eax + incl %esi + testl $-2147483648, %eax + je ..B1.106 +..B1.107: + movl %esi, 28(%esp) +..B1.108: + cmpl $32, 28(%esp) + jge ..B1.110 +..B1.109: + movl 28(%esp), %edi + movl %edi, %esi + movl %edx, 52(%esp) + movl %edi, %ecx + movl $1, %edx + negl %esi + movl %esi, (%esp) + shll %cl, %edx + movl 44(%esp), %esi + decl %edx + orl 56(%esp), %esi + movl %ebx, 24(%esp) + movl 48(%esp), %ebx + movl %ebx, %eax + movl %edx, 4(%esp) + movl $0, %edx + setne %dl + shll %cl, %eax + orl %edx, %eax + movl %eax, 36(%esp) + movl 32(%esp), %eax + movl %eax, %esi + shll %cl, %esi + movl (%esp), %ecx + shrl %cl, %ebx + movl %edi, %ecx + andl 4(%esp), %ebx + orl %ebx, %esi + movl 24(%esp), %ebx + shll %cl, %ebx + movl (%esp), %ecx + shrl %cl, %eax + andl 4(%esp), %eax + movl 52(%esp), %edx + orl %eax, %ebx + jmp ..B1.115 +..B1.110: + cmpl $64, 28(%esp) + jge ..B1.112 +..B1.111: + movl 28(%esp), %eax + movl %eax, %ecx + movl %edx, 52(%esp) + movl $1, %edx + shll %cl, %edx + movl %eax, %esi + decl %edx + negl %esi + cmpl $0, 56(%esp) + movl 44(%esp), %edi + movl %edi, %ebx + movl %edx, 4(%esp) + movl $0, %edx + setne %dl + shll %cl, %ebx + orl %edx, %ebx + movl %ebx, 36(%esp) + movl %esi, (%esp) + movl 48(%esp), %ebx + movl %ebx, %esi + shll %cl, %esi + movl (%esp), %ecx + shrl %cl, %edi + movl %eax, %ecx + andl 4(%esp), %edi + orl %edi, %esi + movl 32(%esp), %edi + shll %cl, %edi + movl (%esp), %ecx + shrl %cl, %ebx + andl 4(%esp), %ebx + movl 52(%esp), %edx + orl %edi, %ebx + jmp ..B1.115 +..B1.112: + cmpl $96, 28(%esp) + jge ..B1.114 +..B1.113: + movl 28(%esp), %eax + movl %eax, %esi + movl %eax, %ecx + movl $1, %edi + movl %edx, 52(%esp) + negl %esi + movl 56(%esp), %edx + movl 44(%esp), %ebx + shll %cl, %edx + movl %esi, (%esp) + movl %ebx, %esi + movl %edx, 36(%esp) + shll %cl, %edi + shll %cl, %esi + decl %edi + movl (%esp), %ecx + shrl %cl, %edx + movl %eax, %ecx + andl %edi, %edx + orl %edx, %esi + movl 48(%esp), %edx + shll %cl, %edx + movl (%esp), %ecx + shrl %cl, %ebx + andl %edi, %ebx + orl %edx, %ebx + movl 52(%esp), %edx + jmp ..B1.115 +..B1.114: + movl 28(%esp), %ecx + xorl %eax, %eax + movl 44(%esp), %ebx + xorl %esi, %esi + shll %cl, %ebx + cmpl $128, %ecx + movl %eax, 36(%esp) + jl ..L3 + movl $0, %ebx +..L3: +..B1.115: + subl 28(%esp), %edx +..B1.116: + lea -1(%edx), %edi + cmpl $32766, %edi + jb ..B1.126 +..B1.117: + cmpl $32767, %edx + jge ..B1.164 +..B1.118: + negl %edx + incl %edx + cmpl $32, %edx + jge ..B1.120 +..B1.119: + movl %edx, %edi + movl %edx, %ecx + negl %edi + xorl %eax, %eax + movl %edi, (%esp) + movl $-1, %edi + shrl %cl, %edi + cmpl $0, 36(%esp) + notl %edi + movl (%esp), %ecx + movl %esi, 20(%esp) + setne %al + shll %cl, %esi + andl %edi, %esi + orl %esi, %eax + movl %eax, 36(%esp) + movl %ebx, %eax + movl (%esp), %ecx + shll %cl, %eax + movl %edx, %ecx + movl 20(%esp), %esi + andl %edi, %eax + shrl %cl, %esi + shrl %cl, %ebx + orl %eax, %esi + jmp ..B1.125 +..B1.120: + cmpl $64, %edx + jge ..B1.122 +..B1.121: + movl %edx, %edi + movl %edx, %ecx + negl %edi + movl $-1, %eax + shrl %cl, %eax + movl %edi, %ecx + movl %ebx, %edi + notl %eax + shll %cl, %edi + movl %edx, %ecx + andl %eax, %edi + xorl %eax, %eax + orl 36(%esp), %esi + movl %ebx, %esi + setne %al + xorl %ebx, %ebx + orl %edi, %eax + movl %eax, 36(%esp) + shrl %cl, %esi + jmp ..B1.125 +..B1.122: + cmpl $96, %edx + jge ..B1.124 +..B1.123: + movl %edx, %edi + movl %edx, %ecx + negl %edi + movl $-1, %eax + movl %ebx, %edx + shrl %cl, %eax + shrl %cl, %edx + movl %edi, %ecx + shll %cl, %ebx + notl %eax + andl %eax, %ebx + orl %esi, %ebx + orl 36(%esp), %ebx + movl $0, %ebx + setne %bl + xorl %esi, %esi + orl %edx, %ebx + movl %ebx, 36(%esp) + xorl %ebx, %ebx + jmp ..B1.125 +..B1.124: + xorl %esi, %esi + movl $1, 36(%esp) + xorl %ebx, %ebx +..B1.125: + xorl %edx, %edx +..B1.126: + cmpl $0, 36(%esp) + je ..B1.163 +..B1.127: + movl 76(%esp), %edi + cmpl $0, 72(%esp) + fldt _small_value_80@GOTOFF(%edi) + fldl _ones@GOTOFF(%edi) + fadd %st(1), %st + fstpt 8(%esp) + je ..B1.194 +..B1.128: + cmpl $3072, 72(%esp) + je ..B1.159 +..B1.129: + cmpl $2048, 72(%esp) + jne ..B1.144 +..B1.130: + testl %edx, %edx + jne ..B1.138 +..B1.131: + cmpl $0, 80(%esp) + jne ..B1.137 +..B1.132: + cmpl $2147483647, %ebx + jb ..B1.137 +..B1.133: + jne ..B1.139 +..B1.134: + cmpl $-1, %esi + jb ..B1.137 +..B1.135: + jne ..B1.139 +..B1.136: + cmpl $-2147483648, 36(%esp) + jae ..B1.139 +..B1.137: + fmul %st(0), %st + fstpt 8(%esp) + fldt 8(%esp) +..B1.138: + cmpl $0, 80(%esp) + jne ..B1.211 +..B1.139: + fstp %st(0) + incl %esi + jne ..B1.142 +..B1.140: + movl $-2147483648, %edi + testl %edx, %edx + je ..L4 + movl $0, %edi +..L4: + incl %ebx + cmpl %edi, %ebx + jne ..B1.142 +..B1.141: + orl $-2147483648, %ebx + incl %edx +..B1.142: + cmpl $32767, %edx + jl ..B1.163 +..B1.143: + movl 80(%esp), %edx + movl 76(%esp), %ebx + lea (,%edx,8), %eax + fldt _large_value_80@GOTOFF(%ebx) + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt 8(%esp) + fldt 8(%esp) + fstpt 20(%esp) + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.144: + cmpl $1024, 72(%esp) + jne ..B1.211 +..B1.145: + testl %edx, %edx + jne ..B1.153 +..B1.146: + cmpl $0, 80(%esp) + je ..B1.152 +..B1.147: + cmpl $2147483647, %ebx + jb ..B1.152 +..B1.148: + jne ..B1.154 +..B1.149: + cmpl $-1, %esi + jb ..B1.152 +..B1.150: + jne ..B1.154 +..B1.151: + cmpl $-2147483648, 36(%esp) + jae ..B1.154 +..B1.152: + fmul %st(0), %st + fstpt 8(%esp) + fldt 8(%esp) +..B1.153: + cmpl $0, 80(%esp) + je ..B1.211 +..B1.154: + fstp %st(0) + incl %esi + jne ..B1.157 +..B1.155: + movl $-2147483648, %edi + testl %edx, %edx + je ..L5 + movl $0, %edi +..L5: + incl %ebx + cmpl %edi, %ebx + jne ..B1.157 +..B1.156: + orl $-2147483648, %ebx + incl %edx +..B1.157: + cmpl $32767, %edx + jl ..B1.163 +..B1.158: + movl 80(%esp), %edx + movl 76(%esp), %ebx + lea (,%edx,8), %eax + fldt _large_value_80@GOTOFF(%ebx) + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt 8(%esp) + fldt 8(%esp) + fstpt 20(%esp) + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.159: + testl %edx, %edx + je ..B1.162 +..B1.160: + lea -1(%edx), %eax + lea -2147483648(%ebx), %edi + orl %edi, %eax + orl %esi, %eax + jne ..B1.211 +..B1.161: + cmpl $-2147483648, 36(%esp) + jne ..B1.211 +..B1.162: + fmul %st(0), %st + fstpt 8(%esp) +..B1.163: + movzbl 29(%esp), %eax + andl $32767, %edx + movl 80(%esp), %edi + andl $127, %eax + shll $7, %edi + orl %edi, %eax + movb %al, 29(%esp) + movzwl 28(%esp), %edi + andl $-32768, %edi + orl %edx, %edi + movw %di, 28(%esp) + movl %ebx, 24(%esp) + movl %esi, 20(%esp) + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.164: + movl 80(%esp), %edx + movl 76(%esp), %ebx + lea (,%edx,8), %eax + fldt _large_value_80@GOTOFF(%ebx) + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt 8(%esp) + fldt 8(%esp) + fstpt 20(%esp) + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.165: + xorl %eax, %eax + cmpl $1024, 72(%esp) + movl 76(%esp), %edi + sete %al + fldl _zeros@GOTOFF(%edi,%eax,8) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.166: + xorl %edx, %edx + jmp ..B1.38 +..B1.167: + cmpl $-2147483648, 36(%ebp) + jne ..B1.169 +..B1.168: + cmpl $0, 32(%ebp) + je ..B1.31 +..B1.169: + movzwl 62(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.175 +..B1.170: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.171: + fldcw 60(%esp) +..B1.172: + fldt 32(%ebp) + fldt 8(%ebp) + fmulp %st, %st(1) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt 20(%esp) +..B1.173: + fldcw 62(%esp) +..B1.174: + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.175: + fldt 32(%ebp) + fldt 8(%ebp) + fmulp %st, %st(1) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt 20(%esp) + jmp ..B1.174 +..B1.176: + cmpl $-2147483648, 24(%ebp) + jne ..B1.178 +..B1.177: + cmpl $0, 20(%ebp) + je ..B1.30 +..B1.178: + movzwl 62(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.184 +..B1.179: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.180: + fldcw 60(%esp) +..B1.181: + fldt 20(%ebp) + fldt 32(%ebp) + fmulp %st, %st(1) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt 20(%esp) +..B1.182: + fldcw 62(%esp) +..B1.183: + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.184: + fldt 20(%ebp) + fldt 32(%ebp) + fmulp %st, %st(1) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt 20(%esp) + jmp ..B1.183 +..B1.185: + cmpl $-2147483648, 12(%ebp) + jne ..B1.187 +..B1.186: + cmpl $0, 8(%ebp) + je ..B1.29 +..B1.187: + movzwl 62(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.193 +..B1.188: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.189: + fldcw 60(%esp) +..B1.190: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fldt 32(%ebp) + fmulp %st, %st(1) + fstpt 20(%esp) +..B1.191: + fldcw 62(%esp) +..B1.192: + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.193: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fldt 32(%ebp) + fmulp %st, %st(1) + fstpt 20(%esp) + jmp ..B1.192 +..B1.194: + testl $-2147483648, 36(%esp) + je ..B1.159 +..B1.195: + movl %esi, %eax + movl 36(%esp), %edi + andl $1, %eax + andl $2147483647, %edi + orl %edi, %eax + je ..B1.159 +..B1.196: + incl %esi + jne ..B1.199 +..B1.197: + movl $-2147483648, %edi + testl %edx, %edx + je ..L6 + movl $0, %edi +..L6: + incl %ebx + cmpl %edi, %ebx + jne ..B1.199 +..B1.198: + orl $-2147483648, %ebx + incl %edx +..B1.199: + cmpl $32767, %edx + jl ..B1.159 +..B1.200: + fstp %st(0) + movl 80(%esp), %edx + movl 76(%esp), %ebx + lea (,%edx,8), %eax + fldt _large_value_80@GOTOFF(%ebx) + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt 8(%esp) + fldt 8(%esp) + fstpt 20(%esp) + fldt 20(%esp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.201: + xorl %eax, %eax + jmp ..B1.61 +..B1.202: + cmpl $-2147483648, 24(%ebp) + jne ..B1.14 +..B1.203: + cmpl $0, 20(%ebp) + je ..B1.18 + jmp ..B1.14 +..B1.204: + cmpl $-2147483648, 12(%ebp) + jne ..B1.9 +..B1.205: + cmpl $0, 8(%ebp) + je ..B1.21 + jmp ..B1.9 +..B1.206: + fldt 32(%ebp) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.211: + fstp %st(0) + jmp ..B1.163 + .align 16,0x90 + .type fmal,@function + .size fmal,.-fmal + .data +# -- End fmal + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmax_wmt.S b/external/sgx_libm/ia32/fmax_wmt.S new file mode 100644 index 0000000000..4359fdb54f --- /dev/null +++ b/external/sgx_libm/ia32/fmax_wmt.S @@ -0,0 +1,113 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmax_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fmax + .text + .align 16,0x90 + .globl fmax +fmax: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $88, %esp + movl %ebx, 32(%esp) + call static_func + movl %eax, %ebx + movsd 96(%esp), %xmm0 + movsd 104(%esp), %xmm1 + ucomisd %xmm0, %xmm1 + jp .L_2TAG_PACKET_0.0.2 + jc .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + fldl 104(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + ucomisd %xmm0, %xmm0 + jp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + fldl 96(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_3.0.2: + movl 32(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fmax,@function + .size fmax,.-fmax + .data +# -- End fmax + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmaxf_wmt.S b/external/sgx_libm/ia32/fmaxf_wmt.S new file mode 100644 index 0000000000..736bb2354a --- /dev/null +++ b/external/sgx_libm/ia32/fmaxf_wmt.S @@ -0,0 +1,113 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmaxf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fmaxf + .text + .align 16,0x90 + .globl fmaxf +fmaxf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $88, %esp + movl %ebx, 32(%esp) + call static_func + movl %eax, %ebx + movss 96(%esp), %xmm0 + movss 100(%esp), %xmm1 + ucomiss %xmm0, %xmm1 + jp .L_2TAG_PACKET_0.0.2 + jc .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + flds 100(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + ucomiss %xmm0, %xmm0 + jp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + flds 96(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_3.0.2: + movl 32(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fmaxf,@function + .size fmaxf,.-fmaxf + .data +# -- End fmaxf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmaxl.S b/external/sgx_libm/ia32/fmaxl.S new file mode 100644 index 0000000000..6f40bb3fc4 --- /dev/null +++ b/external/sgx_libm/ia32/fmaxl.S @@ -0,0 +1,189 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmaxl.c" + .text +..TXTST0: +# -- Begin fmaxl + .text + .align 16,0x90 + .globl fmaxl +fmaxl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + movl %eax, %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.33 +..B1.4: + movzwl 28(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.16 +..B1.5: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.15 +..B1.6: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.7: + fldcw 12(%esp) +..B1.8: + movl $1, %edx +..B1.9: + fldt 8(%ebp) + fstpt 16(%esp) + fldt 16(%esp) + fldt 20(%ebp) + fxch %st(1) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.11 +..B1.10: + fstp %st(0) + jmp ..B1.12 +..B1.11: + fstpt 16(%esp) +..B1.12: + testl %edx, %edx + je ..B1.14 +..B1.13: + fldcw 14(%esp) +..B1.14: + fldt 16(%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.15: + xorl %edx, %edx + jmp ..B1.9 +..B1.16: + cmpl $-2147483648, 24(%ebp) + jne ..B1.18 +..B1.17: + cmpl $0, 20(%ebp) + je ..B1.5 +..B1.18: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.32 +..B1.19: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.20: + fldcw 12(%esp) +..B1.21: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) +..B1.22: + fldcw 14(%esp) + movzwl 16(%ebp), %eax +..B1.23: + andl $32767, %eax + cmpl $32767, %eax + je ..B1.25 +..B1.24: + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.25: + cmpl $-2147483648, 12(%ebp) + jne ..B1.27 +..B1.26: + cmpl $0, 8(%ebp) + je ..B1.24 +..B1.27: + movzwl 28(%ebp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.29 +..B1.28: + fldt 20(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.29: + cmpl $-2147483648, 24(%ebp) + jne ..B1.31 +..B1.30: + cmpl $0, 20(%ebp) + je ..B1.28 +..B1.31: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.32: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.23 +..B1.33: + cmpl $-2147483648, 12(%ebp) + jne ..B1.18 +..B1.34: + cmpl $0, 8(%ebp) + je ..B1.4 + jmp ..B1.18 + .align 16,0x90 + .type fmaxl,@function + .size fmaxl,.-fmaxl + .data +# -- End fmaxl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmin_wmt.S b/external/sgx_libm/ia32/fmin_wmt.S new file mode 100644 index 0000000000..1fd7131d75 --- /dev/null +++ b/external/sgx_libm/ia32/fmin_wmt.S @@ -0,0 +1,113 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmin_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fmin + .text + .align 16,0x90 + .globl fmin +fmin: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $88, %esp + movl %ebx, 32(%esp) + call static_func + movl %eax, %ebx + movsd 96(%esp), %xmm0 + movsd 104(%esp), %xmm1 + ucomisd %xmm1, %xmm0 + jp .L_2TAG_PACKET_0.0.2 + jc .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + fldl 104(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + ucomisd %xmm0, %xmm0 + jp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + fldl 96(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_3.0.2: + movl 32(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fmin,@function + .size fmin,.-fmin + .data +# -- End fmin + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fminf_wmt.S b/external/sgx_libm/ia32/fminf_wmt.S new file mode 100644 index 0000000000..ccc69eb475 --- /dev/null +++ b/external/sgx_libm/ia32/fminf_wmt.S @@ -0,0 +1,113 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fminf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fminf + .text + .align 16,0x90 + .globl fminf +fminf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $88, %esp + movl %ebx, 32(%esp) + call static_func + movl %eax, %ebx + movss 96(%esp), %xmm0 + movss 100(%esp), %xmm1 + ucomiss %xmm1, %xmm0 + jp .L_2TAG_PACKET_0.0.2 + jc .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + flds 100(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + ucomiss %xmm0, %xmm0 + jp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + flds 96(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_3.0.2: + movl 32(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fminf,@function + .size fminf,.-fminf + .data +# -- End fminf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fminl.S b/external/sgx_libm/ia32/fminl.S new file mode 100644 index 0000000000..ea94a255d0 --- /dev/null +++ b/external/sgx_libm/ia32/fminl.S @@ -0,0 +1,190 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fminl.c" + .text +..TXTST0: +# -- Begin fminl + .text + .align 16,0x90 + .globl fminl +fminl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + movl %eax, %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.33 +..B1.4: + movzwl 28(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.16 +..B1.5: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.15 +..B1.6: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.7: + fldcw 12(%esp) +..B1.8: + movl $1, %edx +..B1.9: + fldt 8(%ebp) + fstpt 16(%esp) + fldt 16(%esp) + fldt 20(%ebp) + fcom %st(1) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jbe ..B1.11 +..B1.10: + fstp %st(0) + jmp ..B1.12 +..B1.11: + fstpt 16(%esp) +..B1.12: + testl %edx, %edx + je ..B1.14 +..B1.13: + fldcw 14(%esp) +..B1.14: + fldt 16(%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.15: + xorl %edx, %edx + jmp ..B1.9 +..B1.16: + cmpl $-2147483648, 24(%ebp) + jne ..B1.18 +..B1.17: + cmpl $0, 20(%ebp) + je ..B1.5 +..B1.18: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.32 +..B1.19: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.20: + fldcw 12(%esp) +..B1.21: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) +..B1.22: + fldcw 14(%esp) + movzwl 16(%ebp), %eax +..B1.23: + andl $32767, %eax + cmpl $32767, %eax + je ..B1.25 +..B1.24: + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.25: + cmpl $-2147483648, 12(%ebp) + jne ..B1.27 +..B1.26: + cmpl $0, 8(%ebp) + je ..B1.24 +..B1.27: + movzwl 28(%ebp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.29 +..B1.28: + fldt 20(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.29: + cmpl $-2147483648, 24(%ebp) + jne ..B1.31 +..B1.30: + cmpl $0, 20(%ebp) + je ..B1.28 +..B1.31: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.32: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.23 +..B1.33: + cmpl $-2147483648, 12(%ebp) + jne ..B1.18 +..B1.34: + cmpl $0, 8(%ebp) + je ..B1.4 + jmp ..B1.18 + .align 16,0x90 + .type fminl,@function + .size fminl,.-fminl + .data +# -- End fminl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmod_wmt.S b/external/sgx_libm/ia32/fmod_wmt.S new file mode 100644 index 0000000000..5355b80710 --- /dev/null +++ b/external/sgx_libm/ia32/fmod_wmt.S @@ -0,0 +1,214 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmod_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin fmod + .text + .align 16,0x90 + .globl fmod +fmod: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 120(%esp), %xmm1 + movsd 112(%esp), %xmm0 + fldl 120(%esp) + fldl 112(%esp) + unpcklpd %xmm0, %xmm1 + movdqa (%ebx), %xmm2 + pshufd $212, %xmm1, %xmm1 + movdqa 16(%ebx), %xmm3 + pand %xmm2, %xmm1 + pcmpeqd %xmm1, %xmm3 + movmskps %xmm3, %eax + cmpl $2, %eax + jg .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + fprem + fstsw %ax + sahf + jp .L_2TAG_PACKET_1.0.3 + fstp %st(1) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + movl %eax, %edx + andl $3, %eax + cmpl $3, %eax + jne .L_2TAG_PACKET_3.0.3 + movl 112(%esp), %edx + movl 116(%esp), %ecx + xorl %eax, %eax + andl $2147483647, %ecx + subl %edx, %eax + orl %edx, %eax + shrl $31, %eax + orl %eax, %ecx + cmpl $2146435072, %ecx + ja .L_2TAG_PACKET_4.0.3 + fstp %st(0) + fstp %st(0) + movl $2139095040, 8(%esp) + fldz + flds 8(%esp) + fmulp + fstpl (%esp) + movl $121, %edx +.L_2TAG_PACKET_5.0.3: + movsd 112(%esp), %xmm0 + movsd 120(%esp), %xmm1 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 120(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_3.0.3: + movl 112(%esp), %eax + xorl %ecx, %ecx + subl %eax, %ecx + orl %ecx, %eax + shrl $31, %eax + movl 116(%esp), %ecx + orl %ecx, %eax + andl $2147483647, %eax + movl 120(%esp), %edx + xorl %ecx, %ecx + subl %edx, %ecx + orl %ecx, %edx + shrl $31, %edx + movl 124(%esp), %ecx + orl %ecx, %edx + andl $2147483647, %edx + cmpl $2146435072, %eax + ja .L_2TAG_PACKET_4.0.3 + cmpl $2146435072, %edx + ja .L_2TAG_PACKET_4.0.3 + cmpl $2146435072, %eax + je .L_2TAG_PACKET_7.0.3 + fstp %st(1) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + faddp + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_7.0.3: + fstp %st(1) + fldz + fmulp + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_2.0.3: +.L_2TAG_PACKET_6.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type fmod,@function + .size fmod,.-fmod + .data +# -- End fmod + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 2147483647 + .long 2146435072 + .long 2146435072 + .long 0 + .long 0 + .long 2146435072 + .long 2146435072 + .type static_const_table,@object + .size static_const_table,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmodf.S b/external/sgx_libm/ia32/fmodf.S new file mode 100644 index 0000000000..45adea29c7 --- /dev/null +++ b/external/sgx_libm/ia32/fmodf.S @@ -0,0 +1,156 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmodf.c" + .text +..TXTST0: +# -- Begin fmodf + .text + .align 16,0x90 + .globl fmodf +fmodf: +# parameter 1: 16 + %esp +# parameter 2: 20 + %esp +..B1.1: +..L1: + + subl $12, %esp + movzwl 22(%esp), %ecx + andl $32640, %ecx + shrl $7, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + testl %ecx, %ecx + jne ..B1.3 +..B1.2: + testl $8388607, 20(%esp) + je ..B1.8 +..B1.3: + movzwl 18(%esp), %edx + andl $32640, %edx + shrl $7, %edx + cmpl $255, %edx + je ..B1.22 +..B1.4: + cmpl $255, %ecx + je ..B1.12 +..B1.6: + flds 20(%esp) + flds 16(%esp) +.L_2TAG_PACKET_0.0.2: + fprem + fstsw %ax + sahf + jp .L_2TAG_PACKET_0.0.2 + fstp %st(1) + fstps (%esp) +..B1.7: + flds (%esp) + addl $12, %esp + ret +..B1.8: + movzwl 18(%esp), %edx + andl $32640, %edx + cmpl $32640, %edx + jne ..B1.11 +..B1.9: + testl $8388607, 16(%esp) + je ..B1.11 +..B1.10: + flds 16(%esp) + fadds 20(%esp) + addl $12, %esp + ret +..B1.11: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%eax) + fsts (%esp) + addl $12, %esp + ret +..B1.12: + testl $8388607, 20(%esp) + jne ..B1.16 +..B1.13: + cmpl $255, %edx + je ..B1.20 +..B1.14: + cmpl $255, %ecx + je ..B1.17 + jmp ..B1.6 +..B1.16: + flds 16(%esp) + fadds 20(%esp) + addl $12, %esp + ret +..B1.17: + testl $8388607, 20(%esp) + jne ..B1.6 +..B1.18: + flds 16(%esp) + addl $12, %esp + ret +..B1.20: + testl $8388607, 16(%esp) + jne ..B1.14 +..B1.21: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%eax) + addl $12, %esp + ret +..B1.22: + testl $8388607, 16(%esp) + jne ..B1.16 +..B1.23: + cmpl $255, %ecx + je ..B1.12 + jmp ..B1.13 + .align 16,0x90 + .type fmodf,@function + .size fmodf,.-fmodf + .data +# -- End fmodf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x7f800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fmodl.S b/external/sgx_libm/ia32/fmodl.S new file mode 100644 index 0000000000..7413bbd1ba --- /dev/null +++ b/external/sgx_libm/ia32/fmodl.S @@ -0,0 +1,336 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmodl.c" + .text +..TXTST0: +# -- Begin fmodl + .text + .align 16,0x90 + .globl fmodl +fmodl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + subl $28, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 28(%ebp), %edx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + andl $32767, %edx + jne ..B1.6 +..B1.4: + cmpl $0, 24(%ebp) + jne ..B1.6 +..B1.5: + cmpl $0, 20(%ebp) + je ..B1.45 +..B1.6: + movzwl 16(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.42 +..B1.7: + cmpl $32767, %edx + je ..B1.17 +..B1.8: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.16 +..B1.9: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.10: + fldcw 12(%esp) +..B1.11: + movl $1, %esi +..B1.12: + addl $-16, %esp + lea 8(%ebp), %eax + movl %eax, (%esp) + call __fmodl +..B1.60: + fstpt 16(%esp) + addl $16, %esp +..B1.13: + testl %esi, %esi + je ..B1.15 +..B1.14: + fldcw 14(%esp) +..B1.15: + fldt (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + xorl %esi, %esi + jmp ..B1.12 +..B1.17: + cmpl $-2147483648, 24(%ebp) + jne ..B1.19 +..B1.18: + cmpl $0, 20(%ebp) + je ..B1.25 +..B1.19: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.31 +..B1.20: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.21: + fldcw 12(%esp) +..B1.22: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) +..B1.23: + fldcw 14(%esp) +..B1.24: + fldt (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + cmpl $32767, %ecx + je ..B1.32 +..B1.26: + testl %ecx, %ecx + jne ..B1.30 +..B1.27: + cmpl $0, 12(%ebp) + jne ..B1.29 +..B1.28: + cmpl $0, 8(%ebp) + je ..B1.30 +..B1.29: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 16(%esp) +..B1.30: + fldt 8(%ebp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.24 +..B1.32: + cmpl $-2147483648, 12(%ebp) + jne ..B1.30 +..B1.33: + cmpl $0, 8(%ebp) + jne ..B1.30 +..B1.34: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.41 +..B1.35: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.36: + fldcw 12(%esp) +..B1.37: + movl $1, %edx +..B1.38: + fldl _infs@GOTOFF(%eax) + testl %edx, %edx + fmull _zeros@GOTOFF(%eax) + fstpl (%esp) + je ..B1.40 +..B1.39: + fldcw 14(%esp) +..B1.40: + fldl (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + xorl %edx, %edx + jmp ..B1.38 +..B1.42: + cmpl $-2147483648, 12(%ebp) + jne ..B1.19 +..B1.43: + cmpl $0, 8(%ebp) + jne ..B1.19 +..B1.44: + cmpl $32767, %edx + je ..B1.17 + jmp ..B1.25 +..B1.45: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.57 +..B1.46: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.47: + fldcw 12(%esp) +..B1.48: + movl $1, %ecx +..B1.49: + movzwl 16(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + jne ..B1.53 +..B1.50: + cmpl $-2147483648, 12(%ebp) + jne ..B1.52 +..B1.51: + cmpl $0, 8(%ebp) + je ..B1.53 +..B1.52: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) + jmp ..B1.54 +..B1.53: + fldl _infs@GOTOFF(%eax) + fmull _zeros@GOTOFF(%eax) + fstpt (%esp) +..B1.54: + testl %ecx, %ecx + je ..B1.56 +..B1.55: + fldcw 14(%esp) +..B1.56: + fldt (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.57: + xorl %ecx, %ecx + jmp ..B1.49 + .align 16,0x90 + .type fmodl,@function + .size fmodl,.-fmodl + .data +# -- End fmodl + .text +# -- Begin __fmodl + .text + .align 16,0x90 +__fmodl: +# parameter 1: 4 + %esp +..B2.1: +..L3: + +..B2.2: + movl 4(%esp), %ecx + fldt 12(%ecx) + fldt (%ecx) +.L_2TAG_PACKET_0.0.2: + fprem + fstsw %ax + sahf + jp .L_2TAG_PACKET_0.0.2 + fstp %st(1) + ret +..B2.3: + .align 16,0x90 + .type __fmodl,@function + .size __fmodl,.-__fmodl + .data +# -- End __fmodl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/fpclassify.S b/external/sgx_libm/ia32/fpclassify.S new file mode 100644 index 0000000000..9eec1838b3 --- /dev/null +++ b/external/sgx_libm/ia32/fpclassify.S @@ -0,0 +1,465 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fpclassify.c" + .text +..TXTST0: +# -- Begin __fpclassifyd + .text + .align 16,0x90 + .globl __fpclassifyd +__fpclassifyd: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + fldl 4(%esp) + fwait + fstp %st(0) + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + cmpl $2146435072, %edx + jb ..B1.6 +..B1.2: + movl $2146435072, %eax + subl %eax, %edx + jb ..B1.4 +..B1.14: + orl %edx, %ecx + je ..B1.4 +..B1.3: + xorl %eax, %eax + ret +..B1.4: + movl $1, %eax +..B1.5: + ret +..B1.6: + cmpl $1048576, %edx + jae ..B1.11 +..B1.7: + orl %edx, %ecx + je ..B1.9 +..B1.8: + movl $3, %eax + ret +..B1.9: + movl $2, %eax +..B1.10: + ret +..B1.11: + movl $4, %eax + ret + .align 16,0x90 + .type __fpclassifyd,@function + .size __fpclassifyd,.-__fpclassifyd + .data +# -- End __fpclassifyd + .text +# -- Begin fpclassifyd + .text + .align 16,0x90 + .globl fpclassifyd +fpclassifyd: +# parameter 1: 4 + %esp +..B2.1: +..L2: + + fldl 4(%esp) + fwait + fstp %st(0) + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + cmpl $2146435072, %edx + jb ..B2.6 +..B2.2: + movl $2146435072, %eax + subl %eax, %edx + jb ..B2.4 +..B2.14: + orl %edx, %ecx + je ..B2.4 +..B2.3: + xorl %eax, %eax + ret +..B2.4: + movl $1, %eax +..B2.5: + ret +..B2.6: + cmpl $1048576, %edx + jae ..B2.11 +..B2.7: + orl %edx, %ecx + je ..B2.9 +..B2.8: + movl $3, %eax + ret +..B2.9: + movl $2, %eax +..B2.10: + ret +..B2.11: + movl $4, %eax + ret + .align 16,0x90 + .type fpclassifyd,@function + .size fpclassifyd,.-fpclassifyd + .data +# -- End fpclassifyd + .text +# -- Begin __fpclassify + .text + .align 16,0x90 + .globl __fpclassify +__fpclassify: +# parameter 1: 4 + %esp +..B3.1: +..L3: + + fldl 4(%esp) + fwait + fstp %st(0) + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + cmpl $2146435072, %edx + jb ..B3.6 +..B3.2: + movl $2146435072, %eax + subl %eax, %edx + jb ..B3.4 +..B3.14: + orl %edx, %ecx + je ..B3.4 +..B3.3: + xorl %eax, %eax + ret +..B3.4: + movl $1, %eax +..B3.5: + ret +..B3.6: + cmpl $1048576, %edx + jae ..B3.11 +..B3.7: + orl %edx, %ecx + je ..B3.9 +..B3.8: + movl $3, %eax + ret +..B3.9: + movl $2, %eax +..B3.10: + ret +..B3.11: + movl $4, %eax + ret + .align 16,0x90 + .type __fpclassify,@function + .size __fpclassify,.-__fpclassify + .data +# -- End __fpclassify + .text +# -- Begin fpclassify + .text + .align 16,0x90 + .globl fpclassify +fpclassify: +# parameter 1: 4 + %esp +..B4.1: +..L4: + + fldl 4(%esp) + fwait + fstp %st(0) + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + cmpl $2146435072, %edx + jb ..B4.6 +..B4.2: + movl $2146435072, %eax + subl %eax, %edx + jb ..B4.4 +..B4.14: + orl %edx, %ecx + je ..B4.4 +..B4.3: + xorl %eax, %eax + ret +..B4.4: + movl $1, %eax +..B4.5: + ret +..B4.6: + cmpl $1048576, %edx + jae ..B4.11 +..B4.7: + orl %edx, %ecx + je ..B4.9 +..B4.8: + movl $3, %eax + ret +..B4.9: + movl $2, %eax +..B4.10: + ret +..B4.11: + movl $4, %eax + ret + .align 16,0x90 + .type fpclassify,@function + .size fpclassify,.-fpclassify + .data +# -- End fpclassify + .text +# -- Begin __fpclassifyf + .text + .align 16,0x90 + .globl __fpclassifyf +__fpclassifyf: +# parameter 1: 4 + %esp +..B5.1: +..L5: + + flds 4(%esp) + fwait + fstp %st(0) + movl 4(%esp), %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jb ..B5.3 +..B5.2: + movl $0, %eax + setbe %al + ret +..B5.3: + cmpl $8388608, %edx + jae ..B5.5 +..B5.4: + testl %edx, %edx + movl $0, %eax + setne %al + addl $2, %eax + ret +..B5.5: + movl $4, %eax + ret + .align 16,0x90 + .type __fpclassifyf,@function + .size __fpclassifyf,.-__fpclassifyf + .data +# -- End __fpclassifyf + .text +# -- Begin fpclassifyf + .text + .align 16,0x90 + .globl fpclassifyf +fpclassifyf: +# parameter 1: 4 + %esp +..B6.1: +..L6: + + flds 4(%esp) + fwait + fstp %st(0) + movl 4(%esp), %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jb ..B6.3 +..B6.2: + movl $0, %eax + setbe %al + ret +..B6.3: + cmpl $8388608, %edx + jae ..B6.5 +..B6.4: + testl %edx, %edx + movl $0, %eax + setne %al + addl $2, %eax + ret +..B6.5: + movl $4, %eax + ret + .align 16,0x90 + .type fpclassifyf,@function + .size fpclassifyf,.-fpclassifyf + .data +# -- End fpclassifyf + .text +# -- Begin __fpclassifyl + .text + .align 16,0x90 + .globl __fpclassifyl +__fpclassifyl: +# parameter 1: 8 + %esp +..B7.1: +..L7: + + pushl %ebx + movzwl 16(%esp), %ecx + andl $32767, %ecx + movl 12(%esp), %ebx + movl %ecx, %eax + movl %ebx, %edx + shll $16, %eax + shrl $16, %edx + orl %edx, %eax + cmpl $2147418112, %eax + jb ..B7.5 +..B7.2: + cmpl $32767, %ecx + je ..B7.12 +..B7.3: + xorl %eax, %eax +..B7.4: + popl %ebx + ret +..B7.5: + cmpl $65536, %eax + jae ..B7.11 +..B7.6: + testl %ebx, %ebx + jne ..B7.8 +..B7.7: + cmpl $0, 8(%esp) + je ..B7.9 +..B7.8: + movl $3, %eax + popl %ebx + ret +..B7.9: + movl $2, %eax +..B7.10: + popl %ebx + ret +..B7.11: + andl $32768, %eax + shrl $15, %eax + addl $3, %eax + popl %ebx + ret +..B7.12: + cmpl $-2147483648, %ebx + jne ..B7.3 +..B7.13: + cmpl $0, 8(%esp) + jne ..B7.3 +..B7.14: + movl $1, %eax + popl %ebx + ret + .align 16,0x90 + .type __fpclassifyl,@function + .size __fpclassifyl,.-__fpclassifyl + .data +# -- End __fpclassifyl + .text +# -- Begin fpclassifyl + .text + .align 16,0x90 + .globl fpclassifyl +fpclassifyl: +# parameter 1: 8 + %esp +..B8.1: +..L8: + + pushl %ebx + movzwl 16(%esp), %ecx + andl $32767, %ecx + movl 12(%esp), %ebx + movl %ecx, %eax + movl %ebx, %edx + shll $16, %eax + shrl $16, %edx + orl %edx, %eax + cmpl $2147418112, %eax + jb ..B8.5 +..B8.2: + cmpl $32767, %ecx + je ..B8.12 +..B8.3: + xorl %eax, %eax +..B8.4: + popl %ebx + ret +..B8.5: + cmpl $65536, %eax + jae ..B8.11 +..B8.6: + testl %ebx, %ebx + jne ..B8.8 +..B8.7: + cmpl $0, 8(%esp) + je ..B8.9 +..B8.8: + movl $3, %eax + popl %ebx + ret +..B8.9: + movl $2, %eax +..B8.10: + popl %ebx + ret +..B8.11: + andl $32768, %eax + shrl $15, %eax + addl $3, %eax + popl %ebx + ret +..B8.12: + cmpl $-2147483648, %ebx + jne ..B8.3 +..B8.13: + cmpl $0, 8(%esp) + jne ..B8.3 +..B8.14: + movl $1, %eax + popl %ebx + ret + .align 16,0x90 + .type fpclassifyl,@function + .size fpclassifyl,.-fpclassifyl + .data +# -- End fpclassifyl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/frexp_wmt.S b/external/sgx_libm/ia32/frexp_wmt.S new file mode 100644 index 0000000000..28f863b30d --- /dev/null +++ b/external/sgx_libm/ia32/frexp_wmt.S @@ -0,0 +1,149 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "frexp_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin frexp + .text + .align 16,0x90 + .globl frexp +frexp: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd %xmm0, 8(%esp) + movl 120(%esp), %ecx + pextrw $3, %xmm0, %eax + movq (%ebx), %xmm1 + andl $32767, %eax + movq 16(%ebx), %xmm2 + subl $16, %eax + js .L_2TAG_PACKET_0.0.2 + cmpl $32736, %eax + jae .L_2TAG_PACKET_1.0.2 + shrl $4, %eax + pand %xmm1, %xmm0 + subl $1021, %eax + por %xmm2, %xmm0 + movl %eax, (%ecx) + movq %xmm0, 8(%esp) + fldl 8(%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_0.0.2: + pxor %xmm3, %xmm3 + movq 32(%ebx), %xmm4 + xorl %eax, %eax + comisd %xmm3, %xmm0 + je .L_2TAG_PACKET_3.0.2 + mulsd %xmm4, %xmm0 + pextrw $3, %xmm0, %eax + andl $32767, %eax + pand %xmm1, %xmm0 + shrl $4, %eax + por %xmm2, %xmm0 + subl $1077, %eax + movq %xmm0, 8(%esp) +.L_2TAG_PACKET_3.0.2: + movl %eax, (%ecx) + fldl 8(%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + xorl %eax, %eax + fld1 + movl %eax, (%ecx) + fmull 8(%esp) +.L_2TAG_PACKET_2.0.2: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type frexp,@function + .size frexp,.-frexp + .data +# -- End frexp + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 2148532223 + .long 4294967295 + .long 2148532223 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 0 + .long 1130364928 + .long 0 + .long 1130364928 + .type static_const_table,@object + .size static_const_table,48 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/frexpf.S b/external/sgx_libm/ia32/frexpf.S new file mode 100644 index 0000000000..56c001b928 --- /dev/null +++ b/external/sgx_libm/ia32/frexpf.S @@ -0,0 +1,112 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "frexpf.c" + .text +..TXTST0: +# -- Begin frexpf + .text + .align 16,0x90 + .globl frexpf +frexpf: +# parameter 1: 8 + %esp +# parameter 2: 12 + %esp +..B1.1: +..L1: + + pushl %edi + movl 8(%esp), %ecx + movl %ecx, %edx + andl $2147483647, %edx + movl 12(%esp), %eax + lea -8388608(%edx), %edi + cmpl $2130706432, %edi + jb ..B1.5 +..B1.2: + decl %edx + cmpl $2139095039, %edx + jae ..B1.6 +..B1.3: + flds 8(%esp) + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + fmuls .L_2il0floatpacket.0@GOTOFF(%edx) + fstps 8(%esp) + movl 8(%esp), %ecx + movl %ecx, %edi + andl $2147483647, %edi + andl $-2139095041, %ecx + shrl $23, %edi + orl $1056964608, %ecx + movl %ecx, 8(%esp) + addl $-151, %edi + flds 8(%esp) + movl %edi, (%eax) +..B1.4: + popl %edi + ret +..B1.5: + andl $-2139095041, %ecx + shrl $23, %edi + orl $1056964608, %ecx + movl %ecx, 8(%esp) + addl $-125, %edi + flds 8(%esp) + movl %edi, (%eax) + popl %edi + ret +..B1.6: + flds 8(%esp) + movl $0, (%eax) + popl %edi + ret + .align 16,0x90 + .type frexpf,@function + .size frexpf,.-frexpf + .data +# -- End frexpf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/frexpl.S b/external/sgx_libm/ia32/frexpl.S new file mode 100644 index 0000000000..09d572fc81 --- /dev/null +++ b/external/sgx_libm/ia32/frexpl.S @@ -0,0 +1,171 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "frexpl.c" + .text +..TXTST0: +# -- Begin frexpl + .text + .align 16,0x90 + .globl frexpl +frexpl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp + movl 20(%ebp), %edx +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %ecx + movl %ecx, %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.16 +..B1.4: + testl %eax, %eax + jne ..B1.14 +..B1.5: + cmpl $0, 12(%ebp) + jne ..B1.8 +..B1.6: + cmpl $0, 8(%ebp) + jne ..B1.8 +..B1.7: + fldt 8(%ebp) + movl $0, (%edx) + movl %ebp, %esp + popl %ebp + ret +..B1.8: + movzwl 14(%esp), %eax + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + je ..B1.15 +..B1.9: + orl $-64768, %eax + movl $0, (%edx) + movw %ax, 12(%esp) +..B1.10: + fldcw 12(%esp) +..B1.11: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%ecx) + fstpt 8(%ebp) +..B1.12: + fldcw 14(%esp) +..B1.13: + movzwl 16(%ebp), %ecx + movl %ecx, %eax + andl $-32768, %ecx + andl $32767, %eax + orl $-49154, %ecx + addl $-16457, %eax + movw %cx, 16(%ebp) + fldt 8(%ebp) + movl %eax, (%edx) + movl %ebp, %esp + popl %ebp + ret +..B1.14: + andl $-32768, %ecx + addl $-16382, %eax + orl $-49154, %ecx + movw %cx, 16(%ebp) + fldt 8(%ebp) + movl %eax, (%edx) + movl %ebp, %esp + popl %ebp + ret +..B1.15: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%ecx) + fstpt 8(%ebp) + jmp ..B1.13 +..B1.16: + movl $0, (%edx) + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.22 +..B1.17: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.18: + fldcw 12(%esp) +..B1.19: + fldt 8(%ebp) + fstpt (%esp) +..B1.20: + fldcw 14(%esp) +..B1.21: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.22: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.21 + .align 16,0x90 + .type frexpl,@function + .size frexpl,.-frexpl + .data +# -- End frexpl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/hypot_wmt.S b/external/sgx_libm/ia32/hypot_wmt.S new file mode 100644 index 0000000000..36b50289d9 --- /dev/null +++ b/external/sgx_libm/ia32/hypot_wmt.S @@ -0,0 +1,230 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "hypot_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin hypot + .text + .align 16,0x90 + .globl hypot +hypot: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $152, %esp + movl %ebx, 96(%esp) + call static_func + movl %eax, %ebx + movapd (%ebx), %xmm3 + movsd 160(%esp), %xmm0 + movsd 168(%esp), %xmm1 + andpd %xmm3, %xmm0 + andpd %xmm3, %xmm1 + pextrw $3, %xmm0, %eax + pextrw $3, %xmm1, %edx + cmpl $24528, %eax + ja .L_2TAG_PACKET_0.0.3 + cmpl $24528, %edx + ja .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + fldl 160(%esp) + fldl 168(%esp) + fxch %st(1) + fmul %st(0), %st + fxch %st(1) + nop + fmul %st(0), %st + faddp %st, %st(1) + fsqrt + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + cmpl $32752, %eax + movl %eax, %ecx + jae .L_2TAG_PACKET_3.0.3 + subl %edx, %ecx + cmpl $32752, %edx + jae .L_2TAG_PACKET_3.0.3 + addl $928, %ecx + addl %edx, %eax + cmpl $1856, %ecx + ja .L_2TAG_PACKET_4.0.3 + cmpl $49056, %eax + jb .L_2TAG_PACKET_1.0.3 + fldl 160(%esp) + fldl 168(%esp) + fxch %st(1) + fmul %st(0), %st + fxch %st(1) + nop + fmul %st(0), %st + faddp %st, %st(1) + fsqrt +.L_2TAG_PACKET_5.0.3: + fstl (%esp) + fstpt 16(%esp) + xorl %eax, %eax + movw 24(%esp), %ax + cmpl $17407, %eax + jae .L_2TAG_PACKET_6.0.3 + fldl (%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_4.0.3: + movsd %xmm0, 32(%esp) + movsd %xmm1, 40(%esp) + fldl 32(%esp) + faddl 40(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_6.0.3: + movl $46, %edx +.L_2TAG_PACKET_8.0.3: + movsd 160(%esp), %xmm0 + movsd 168(%esp), %xmm1 + subl $32, %esp + lea 160(%esp), %eax + movl %eax, (%esp) + lea 168(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_3.0.3: + shufpd $0, %xmm1, %xmm0 + movdqa %xmm0, %xmm2 + movdqa 16(%ebx), %xmm3 + movsd %xmm0, 32(%esp) + movsd %xmm1, 40(%esp) + cmppd $3, %xmm0, %xmm2 + cmppd $0, %xmm0, %xmm3 + movmskpd %xmm2, %edx + movmskpd %xmm3, %eax + testl %edx, %edx + je .L_2TAG_PACKET_9.0.3 + fldl 32(%esp) + fmull 40(%esp) + testl $1, %eax + jne .L_2TAG_PACKET_10.0.3 + testl $2, %eax + jne .L_2TAG_PACKET_11.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_9.0.3: + fldl 32(%esp) + faddl 40(%esp) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_10.0.3: + fstpl 40(%esp) + fldl 32(%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_11.0.3: + fstpl 32(%esp) + fldl 40(%esp) + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_2.0.3: +.L_2TAG_PACKET_7.0.3: + movl 96(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type hypot,@function + .size hypot,.-hypot + .data +# -- End hypot + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .type static_const_table,@object + .size static_const_table,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/hypotf.S b/external/sgx_libm/ia32/hypotf.S new file mode 100644 index 0000000000..c57ab39b1f --- /dev/null +++ b/external/sgx_libm/ia32/hypotf.S @@ -0,0 +1,183 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "hypotf.c" + .text +..TXTST0: +# -- Begin hypotf + .text + .align 16,0x90 + .globl hypotf +hypotf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp + movzwl 10(%ebp), %ecx + andl $32640, %ecx + movzwl 14(%ebp), %edx + andl $32640, %edx + shrl $7, %ecx + shrl $7, %edx + cmpl $255, %ecx + je ..B1.9 +..B1.2: + cmpl $255, %edx + je ..B1.9 +..B1.3: + movl %ecx, %eax + subl %edx, %eax + addl $28, %eax + cmpl $56, %eax + ja ..B1.5 +..B1.4: + flds 8(%ebp) + addl %edx, %ecx + fmul %st(0), %st + cmpl $378, %ecx + flds 12(%ebp) + fmul %st(0), %st + faddp %st, %st(1) + fsqrt + jg ..B1.7 + jmp ..B1.6 +..B1.5: + flds 8(%ebp) + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + fabs + flds 12(%ebp) + fabs + fldl .L_2il0floatpacket.0@GOTOFF(%eax) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstps 8(%esp) + flds 8(%esp) + fmuls .L_2il0floatpacket.1@GOTOFF(%eax) + cmpl $2130706432, 8(%esp) +..B1.6: + movl %ebp, %esp + popl %ebp + ret +..B1.7: + fstl (%esp) + cmpl $1206910976, 4(%esp) + jl ..B1.6 +..B1.8: + movl %ebp, %esp + popl %ebp + ret +..B1.9: + andb $127, 11(%ebp) + andb $127, 15(%ebp) + cmpl $255, %ecx + je ..B1.21 +..B1.10: + cmpl $255, %edx + je ..B1.19 +..B1.11: + flds 8(%ebp) + fld %st(0) + fadds 12(%ebp) + fstps 8(%esp) +..B1.12: + cmpl $255, %ecx + je ..B1.17 +..B1.13: + fstp %st(0) + cmpl $255, %edx + jne ..B1.16 +..B1.14: + testl $8388607, 12(%ebp) + jne ..B1.16 +..B1.15: + flds 12(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.16: + flds 8(%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.17: + testl $8388607, 8(%ebp) + jne ..B1.13 +..B1.18: + movl %ebp, %esp + popl %ebp + ret +..B1.19: + testl $8388607, 12(%ebp) + je ..B1.11 +..B1.20: + flds 8(%ebp) + fld %st(0) + fmuls 12(%ebp) + fstps 8(%esp) + jmp ..B1.12 +..B1.21: + testl $8388607, 8(%ebp) + jne ..B1.20 + jmp ..B1.10 + .align 16,0x90 + .type hypotf,@function + .size hypotf,.-hypotf + .data +# -- End hypotf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 4 +.L_2il0floatpacket.1: + .long 0x40000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/hypotl.S b/external/sgx_libm/ia32/hypotl.S new file mode 100644 index 0000000000..0533320ea7 --- /dev/null +++ b/external/sgx_libm/ia32/hypotl.S @@ -0,0 +1,858 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "hypotl.c" + .text +..TXTST0: +# -- Begin hypotl + .text + .align 16,0x90 + .globl hypotl +hypotl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $24, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + andb $127, 17(%ebp) + andb $127, 29(%ebp) + movzwl 16(%ebp), %esi + andl $32767, %esi + movzwl 28(%ebp), %ebx + andl $32767, %ebx + cmpl $32767, %esi + je ..B1.73 +..B1.4: + cmpl $32767, %ebx + je ..B1.73 +..B1.5: + movl %esi, %eax + subl %ebx, %eax + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + lea 64(%eax), %edx + cmpl $128, %edx + ja ..B1.27 +..B1.6: + lea (%esi,%ebx), %edx + cmpl $18376, %edx + jge ..B1.38 +..B1.7: + testl %esi, %esi + jne ..B1.14 +..B1.8: + cmpl $0, 12(%ebp) + jne ..B1.14 +..B1.9: + cmpl $0, 8(%ebp) + jne ..B1.14 +..B1.10: + testl %ebx, %ebx + jne ..B1.14 +..B1.11: + cmpl $0, 24(%ebp) + jne ..B1.14 +..B1.12: + cmpl $0, 20(%ebp) + jne ..B1.14 +..B1.13: + fldl _zeros@GOTOFF(%ecx) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + movzwl 14(%esp), %ebx + movl %ebx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.37 +..B1.15: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.16: + fldcw 12(%esp) +..B1.17: + movl $1, %ebx +..B1.18: + fldt _scales@GOTOFF(%ecx) + lea 4(%eax), %edx + fldt 8(%ebp) + cmpl $8, %edx + fmul %st(1), %st + fldt 20(%ebp) + fmulp %st, %st(2) + ja ..B1.22 +..B1.19: + fldl _TWO_48H@GOTOFF(%ecx) + fld %st(1) + fmul %st(1), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fxch %st(3) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fld %st(4) + fsub %st(3), %st + fmul %st, %st(2) + fld %st(6) + fsub %st(5), %st + fmul %st, %st(2) + fxch %st(6) + fcom %st(7) + fnstsw %ax + fmulp %st, %st(1) + sahf + faddp %st, %st(2) + fxch %st(5) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmul %st(0), %st + fld %st(0) + fxch %st(2) + fmul %st(0), %st + fadd %st, %st(2) + fldl _TWO_32H@GOTOFF(%ecx) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + jbe ..B1.21 +..B1.20: + fxch %st(1) + fsubr %st(3), %st + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + jmp ..B1.24 +..B1.21: + fxch %st(2) + fsubr %st(3), %st + fsubrp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + jmp ..B1.24 +..B1.22: + fldl _TWO_48H@GOTOFF(%ecx) + testl %eax, %eax + fldl _TWO_32H@GOTOFF(%ecx) + jle ..B1.36 +..B1.23: + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(3) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + fxch %st(1) + fxch %st(2) + fxch %st(1) +..B1.24: + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fld %st(1) + testl %ebx, %ebx + fadd %st(4), %st + fsqrt + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fsubrp %st, %st(3) + fld %st(3) + fxch %st(1) + fsub %st(4), %st + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(4) + faddp %st, %st(2) + fld %st(2) + fadd %st(4), %st + fdivrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 12+_scales@GOTOFF(%ecx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.26 +..B1.25: + fldcw 14(%esp) +..B1.26: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.27: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.72 +..B1.28: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.29: + fldcw 12(%esp) +..B1.30: + movl $1, %edx +..B1.31: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt (%esp) + fldt (%esp) + fldt 12+_ranges@GOTOFF(%ecx) + fcompp + fnstsw %ax + sahf + jae ..B1.33 + jp ..B1.33 +..B1.32: + fldt _large_value_80@GOTOFF(%ecx) + fmul %st(0), %st + fstpt (%esp) +..B1.33: + testl %edx, %edx + je ..B1.35 +..B1.34: + fldcw 14(%esp) +..B1.35: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.36: + fxch %st(1) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(0), %st + jmp ..B1.24 +..B1.37: + xorl %ebx, %ebx + jmp ..B1.18 +..B1.38: + movzwl 14(%esp), %ebx + cmpl $47156, %edx + jle ..B1.54 +..B1.39: + movl %ebx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.69 +..B1.40: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.41: + fldcw 12(%esp) +..B1.42: + xorl %ebx, %ebx + incl %ebx +..B1.43: + fldt 12+_scales@GOTOFF(%ecx) + lea 4(%eax), %edx + fldt 8(%ebp) + cmpl $8, %edx + fmul %st(1), %st + fldt 20(%ebp) + fmulp %st, %st(2) + ja ..B1.47 +..B1.44: + fldl _TWO_48H@GOTOFF(%ecx) + fld %st(1) + fmul %st(1), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fxch %st(3) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fld %st(4) + fsub %st(3), %st + fmul %st, %st(2) + fld %st(6) + fsub %st(5), %st + fmul %st, %st(2) + fxch %st(6) + fcom %st(7) + fnstsw %ax + fmulp %st, %st(1) + sahf + faddp %st, %st(2) + fxch %st(5) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmul %st(0), %st + fld %st(0) + fxch %st(2) + fmul %st(0), %st + fadd %st, %st(2) + fldl _TWO_32H@GOTOFF(%ecx) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + jbe ..B1.46 +..B1.45: + fxch %st(1) + fsubr %st(3), %st + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + jmp ..B1.49 +..B1.46: + fxch %st(2) + fsubr %st(3), %st + fsubrp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + jmp ..B1.49 +..B1.47: + fldl _TWO_48H@GOTOFF(%ecx) + testl %eax, %eax + fldl _TWO_32H@GOTOFF(%ecx) + jle ..B1.68 +..B1.48: + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(3) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + fxch %st(1) + fxch %st(2) + fxch %st(1) +..B1.49: + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fld %st(1) + fadd %st(4), %st + fsqrt + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fsubrp %st, %st(3) + fld %st(3) + fxch %st(1) + fsub %st(4), %st + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(4) + faddp %st, %st(2) + fld %st(2) + fadd %st(4), %st + fdivrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + fldt (%esp) + fldt _ranges@GOTOFF(%ecx) + fcompp + fnstsw %ax + sahf + jp ..B1.50 + jbe ..B1.67 +..B1.50: + fldt _scales@GOTOFF(%ecx) + fldt (%esp) + fmulp %st, %st(1) + fstpt (%esp) +..B1.51: + testl %ebx, %ebx + je ..B1.53 +..B1.52: + fldcw 14(%esp) +..B1.53: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.54: + movl %ebx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.71 +..B1.55: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.56: + fldcw 12(%esp) +..B1.57: + xorl %ebx, %ebx + incl %ebx +..B1.58: + lea 4(%eax), %edx + cmpl $8, %edx + ja ..B1.62 +..B1.59: + fldt 8(%ebp) + fld %st(0) + fld %st(1) + fld %st(2) + fldt 20(%ebp) + fld %st(0) + fxch %st(5) + fcom %st(1) + fnstsw %ax + fldl _TWO_48H@GOTOFF(%ecx) + fmul %st, %st(5) + sahf + fxch %st(4) + fadd %st(5), %st + fsubp %st, %st(5) + fld %st(4) + fld %st(2) + fxch %st(3) + fmul %st, %st(5) + fxch %st(3) + fadd %st(5), %st + fsubp %st, %st(5) + fld %st(4) + fxch %st(4) + fsub %st(6), %st + fmul %st, %st(1) + fxch %st(5) + fsubr %st, %st(7) + fxch %st(4) + fmul %st(7), %st + fxch %st(2) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fmul %st(0), %st + fld %st(0) + fxch %st(2) + fmul %st(0), %st + fadd %st, %st(2) + fldl _TWO_32H@GOTOFF(%ecx) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + jbe ..B1.61 +..B1.60: + fxch %st(1) + fsubr %st(3), %st + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + fxch %st(1) + jmp ..B1.64 +..B1.61: + fxch %st(2) + fsubr %st(3), %st + fsubrp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + fxch %st(1) + jmp ..B1.64 +..B1.62: + fldt 8(%ebp) + testl %eax, %eax + fldt 20(%ebp) + fldl _TWO_48H@GOTOFF(%ecx) + fldl _TWO_32H@GOTOFF(%ecx) + jle ..B1.70 +..B1.63: + fxch %st(1) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(0), %st + fxch %st(2) + fxch %st(1) + fxch %st(2) +..B1.64: + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fld %st(1) + testl %ebx, %ebx + fadd %st(3), %st + fsqrt + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fsubrp %st, %st(3) + fld %st(4) + fxch %st(1) + fsub %st(5), %st + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(3) + fadd %st(3), %st + fdivrp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.66 +..B1.65: + fldcw 14(%esp) +..B1.66: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.67: + fldt _large_value_80@GOTOFF(%ecx) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.51 +..B1.68: + fxch %st(1) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(0), %st + jmp ..B1.49 +..B1.69: + xorl %ebx, %ebx + jmp ..B1.43 +..B1.70: + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(3) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + jmp ..B1.64 +..B1.71: + xorl %ebx, %ebx + jmp ..B1.58 +..B1.72: + xorl %edx, %edx + jmp ..B1.31 +..B1.73: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.96 +..B1.74: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.75: + fldcw 12(%esp) +..B1.76: + movl $1, %eax +..B1.77: + cmpl $32767, %esi + je ..B1.94 +..B1.78: + cmpl $32767, %ebx + je ..B1.91 +..B1.79: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt (%esp) +..B1.80: + testl %eax, %eax + je ..B1.82 +..B1.81: + fldcw 14(%esp) +..B1.82: + cmpl $32767, %esi + je ..B1.88 +..B1.83: + cmpl $32767, %ebx + jne ..B1.87 +..B1.84: + cmpl $-2147483648, 24(%ebp) + jne ..B1.87 +..B1.85: + cmpl $0, 20(%ebp) + jne ..B1.87 +..B1.86: + fldt 20(%ebp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.87: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.88: + cmpl $-2147483648, 12(%ebp) + jne ..B1.83 +..B1.89: + cmpl $0, 8(%ebp) + jne ..B1.83 +..B1.90: + fldt 8(%ebp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.91: + cmpl $-2147483648, 24(%ebp) + jne ..B1.93 +..B1.92: + cmpl $0, 20(%ebp) + je ..B1.79 +..B1.93: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.80 +..B1.94: + cmpl $-2147483648, 12(%ebp) + jne ..B1.93 +..B1.95: + cmpl $0, 8(%ebp) + jne ..B1.93 + jmp ..B1.78 +..B1.96: + xorl %eax, %eax + jmp ..B1.77 + .align 16,0x90 + .type hypotl,@function + .size hypotl,.-hypotl + .data +# -- End hypotl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_scales: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24653 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8113 + .word 0 + .type _scales,@object + .size _scales,24 + .align 2 +_ranges: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24497 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 32766 + .word 0 + .type _ranges,@object + .size _ranges,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ilogb_wmt.S b/external/sgx_libm/ia32/ilogb_wmt.S new file mode 100644 index 0000000000..0f482dfe93 --- /dev/null +++ b/external/sgx_libm/ia32/ilogb_wmt.S @@ -0,0 +1,171 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ilogb_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin ilogb + .text + .align 16,0x90 + .globl ilogb +ilogb: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd %xmm0, 8(%esp) + psrlq $52, %xmm0 + movd %xmm0, %eax + andl $2047, %eax + subl $1, %eax + cmpl $2046, %eax + jae .L_2TAG_PACKET_0.0.3 + subl $1022, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + movq 8(%esp), %xmm0 + movq (%ebx), %xmm1 + pxor %xmm2, %xmm2 + testl %eax, %eax + jg .L_2TAG_PACKET_2.0.3 + comisd %xmm2, %xmm0 + mulsd %xmm1, %xmm0 + je .L_2TAG_PACKET_3.0.3 + psrlq $52, %xmm0 + movd %xmm0, %eax + andl $2047, %eax + subl $1078, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + ucomisd %xmm0, %xmm0 + movl $2147483647, %eax + movl $-2147483648, %edx + cmovc %edx, %eax + xorpd %xmm0, %xmm0 + movq 16(%ebx), %xmm1 + mulsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movl $-2147483648, %edx + movl %edx, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $157, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movl (%esp), %eax + xorpd %xmm0, %xmm0 + movq 16(%ebx), %xmm1 + mulsd %xmm0, %xmm1 +.L_2TAG_PACKET_1.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type ilogb,@function + .size ilogb,.-ilogb + .data +# -- End ilogb + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1130364928 + .long 0 + .long 1130364928 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .type static_const_table,@object + .size static_const_table,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ilogbf.S b/external/sgx_libm/ia32/ilogbf.S new file mode 100644 index 0000000000..b6ea2b1e32 --- /dev/null +++ b/external/sgx_libm/ia32/ilogbf.S @@ -0,0 +1,129 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ilogbf.c" + .text +..TXTST0: +# -- Begin ilogbf + .text + .align 16,0x90 + .globl ilogbf +ilogbf: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movl 16(%esp), %eax + andl $2147483647, %eax + addl $-8388608, %eax + cmpl $2130706432, %eax + jb ..B1.6 +..B1.2: + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + testl %eax, %eax + jl ..B1.7 +..B1.3: + fldz + cmpl $2130706432, %eax + fmuls .L_2il0floatpacket.0@GOTOFF(%edx) + fstps (%esp) + je ..B1.5 +..B1.4: + flds 16(%esp) + movl $-2147483648, %eax + fmul %st(0), %st + fstps 16(%esp) + movl 16(%esp), %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jae ..L3 + movl $0, %eax +..L3: + addl $12, %esp + ret +..B1.5: + movl $2147483647, %eax + addl $12, %esp + ret +..B1.6: + shrl $23, %eax + addl $-126, %eax + addl $12, %esp + ret +..B1.7: + cmpl $-8388608, %eax + je ..B1.9 +..B1.8: + flds 16(%esp) + fmuls .L_2il0floatpacket.1@GOTOFF(%edx) + fstps 16(%esp) + movl 16(%esp), %eax + andl $2147483647, %eax + shrl $23, %eax + addl $-152, %eax + addl $12, %esp + ret +..B1.9: + fldz + movl $-2147483648, %eax + fmuls .L_2il0floatpacket.0@GOTOFF(%edx) + fstps (%esp) + addl $12, %esp + ret + .align 16,0x90 + .type ilogbf,@function + .size ilogbf,.-ilogbf + .data +# -- End ilogbf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x7f800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ilogbl.S b/external/sgx_libm/ia32/ilogbl.S new file mode 100644 index 0000000000..7165b3f701 --- /dev/null +++ b/external/sgx_libm/ia32/ilogbl.S @@ -0,0 +1,200 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ilogbl.c" + .text +..TXTST0: +# -- Begin ilogbl + .text + .align 16,0x90 + .globl ilogbl +ilogbl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $32767, %eax + je ..B1.20 +..B1.4: + testl %eax, %eax + jne ..B1.13 +..B1.5: + cmpl $0, 12(%ebp) + jne ..B1.7 +..B1.6: + cmpl $0, 8(%ebp) + je ..B1.14 +..B1.7: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.19 +..B1.8: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%edx) + fstpt 8(%ebp) +..B1.11: + fldcw 14(%esp) +..B1.12: + movzwl 16(%ebp), %eax + andl $32767, %eax + addl $-16458, %eax + movl %ebp, %esp + popl %ebp + ret +..B1.13: + addl $-16383, %eax + movl %ebp, %esp + popl %ebp + ret +..B1.14: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.18 +..B1.15: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.16: + fldcw 12(%esp) +..B1.17: + fldcw 14(%esp) +..B1.18: + fldl _infs@GOTOFF(%edx) + movl $-2147483648, %eax + fmull _zeros@GOTOFF(%edx) + fstpl 16(%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.19: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%edx) + fstpt 8(%ebp) + jmp ..B1.12 +..B1.20: + cmpl $-2147483648, 12(%ebp) + fldl _infs@GOTOFF(%edx) + fmull _zeros@GOTOFF(%edx) + fstpl 16(%esp) + jne ..B1.23 +..B1.21: + cmpl $0, 8(%ebp) + jne ..B1.23 +..B1.22: + movl $2147483647, %eax + movl %ebp, %esp + popl %ebp + ret +..B1.23: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.24: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.25: + fldcw 12(%esp) +..B1.26: + fldt 8(%ebp) + fstpt (%esp) +..B1.27: + fldcw 14(%esp) +..B1.28: + movl $-2147483648, %eax + movl %ebp, %esp + popl %ebp + ret +..B1.29: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.28 + .align 16,0x90 + .type ilogbl,@function + .size ilogbl,.-ilogbl + .data +# -- End ilogbl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/intel_quad_exception.S b/external/sgx_libm/ia32/intel_quad_exception.S new file mode 100644 index 0000000000..c5fabfb8ce --- /dev/null +++ b/external/sgx_libm/ia32/intel_quad_exception.S @@ -0,0 +1,2258 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "intel_quad_exception.c" + .text +..TXTST0: +# -- Begin __dpml_exception + .text + .align 16,0x90 + .hidden __dpml_exception + .globl __dpml_exception +__dpml_exception: +# parameter 1: 48 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $28, %esp + xorl %eax, %eax + movl 48(%esp), %edx + movl (%edx), %ecx + movl 4(%edx), %edx + movl %edx, %ebx + subl %eax, %ebx + jge ..B1.3 +..B1.2: + andl $2147483647, %edx +..B1.3: + call ..L2 +..L2: + popl %ebp + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebp), %ebp + movl %ecx, %ebx + andl $134217727, %ecx + movl %edx, %esi + shll $5, %esi + shrl $27, %ebx + orl %ebx, %esi + movzbl 7+__dpml_response_table@GOTOFF(%ebp,%ecx,8), %edi + movzbl 6+__dpml_response_table@GOTOFF(%ebp,%ecx,8), %ebx + movl %ebx, %eax + movl %edi, 16(%esp) + movl $4, %edi + subl %edi, %eax + xorl %edi, %edi + orl %edi, %eax + jne ..B1.5 +..B1.4: + movl 48(%esp), %eax + lea 28(%eax), %edi + jmp ..B1.6 +..B1.5: + movl 16(%esp), %eax + shll $5, %eax + lea (%eax,%esi,8), %edi + addl __dpml_globals_table@GOT(%ebp), %edi +..B1.6: + addl $-4, %ecx + movl %ecx, %esi + adcl $-1, %edx + movl $171, %eax + subl %eax, %esi + movl $0, %eax + sbbl %eax, %edx + jb ..B1.7 +..B1.89: + orl %edx, %esi + jne ..B1.74 +..B1.7: + movzbl .2.9_2.switchtab.1@GOTOFF(%ebp,%ecx), %eax + lea ..1.1_0.TAG.12.0.1@GOTOFF(%ebp,%eax), %eax + jmp *%eax +..1.1_0.TAG.12.0.1: +..1.1_0.TAG.9.0.1: +..1.1_0.TAG.11.0.1: +..1.1_0.TAG.8.0.1: +..B1.64: + movl 48(%esp), %edi + xorl %ebx, %ebx + lea 28(%edi), %edi + jmp ..B1.75 +..1.1_0.TAG.171.0.1: +..1.1_0.TAG.170.0.1: +..1.1_0.TAG.145.0.1: +..1.1_0.TAG.144.0.1: +..1.1_0.TAG.140.0.1: +..1.1_0.TAG.139.0.1: +..1.1_0.TAG.138.0.1: +..1.1_0.TAG.136.0.1: +..1.1_0.TAG.135.0.1: +..1.1_0.TAG.133.0.1: +..1.1_0.TAG.128.0.1: +..1.1_0.TAG.127.0.1: +..1.1_0.TAG.126.0.1: +..1.1_0.TAG.125.0.1: +..1.1_0.TAG.116.0.1: +..1.1_0.TAG.115.0.1: +..1.1_0.TAG.114.0.1: +..1.1_0.TAG.112.0.1: +..1.1_0.TAG.111.0.1: +..1.1_0.TAG.104.0.1: +..1.1_0.TAG.103.0.1: +..1.1_0.TAG.102.0.1: +..1.1_0.TAG.101.0.1: +..1.1_0.TAG.100.0.1: +..1.1_0.TAG.99.0.1: +..1.1_0.TAG.98.0.1: +..1.1_0.TAG.97.0.1: +..1.1_0.TAG.79.0.1: +..1.1_0.TAG.76.0.1: +..1.1_0.TAG.67.0.1: +..1.1_0.TAG.64.0.1: +..1.1_0.TAG.62.0.1: +..1.1_0.TAG.61.0.1: +..1.1_0.TAG.59.0.1: +..1.1_0.TAG.58.0.1: +..1.1_0.TAG.56.0.1: +..1.1_0.TAG.55.0.1: +..1.1_0.TAG.34.0.1: +..1.1_0.TAG.33.0.1: +..1.1_0.TAG.32.0.1: +..1.1_0.TAG.31.0.1: +..1.1_0.TAG.30.0.1: +..1.1_0.TAG.29.0.1: +..1.1_0.TAG.28.0.1: +..1.1_0.TAG.26.0.1: +..1.1_0.TAG.25.0.1: +..1.1_0.TAG.24.0.1: +..1.1_0.TAG.23.0.1: +..1.1_0.TAG.22.0.1: +..1.1_0.TAG.19.0.1: +..1.1_0.TAG.18.0.1: +..1.1_0.TAG.13.0.1: +..1.1_0.TAG.10.0.1: +..1.1_0.TAG.7.0.1: +..1.1_0.TAG.6.0.1: +..1.1_0.TAG.4.0.1: +..1.1_0.TAG.3.0.1: +..1.1_0.TAG.2.0.1: +..1.1_0.SWBASE.0.1: +..1.1_0.TAG.0.0.1: +..B1.74: + movl %ebx, %esi + movl $4, %edx + xorl %ecx, %ecx + subl %edx, %esi + sbbl %ecx, %ecx + jb ..B1.75 +..B1.90: + orl %ecx, %esi + jne ..B1.86 +..B1.75: + movzbl .2.9_2.switchtab.2@GOTOFF(%ebp,%ebx), %eax + lea ..1.1_1.TAG.4.0.1@GOTOFF(%ebp,%eax), %eax + jmp *%eax +..1.1_1.TAG.4.0.1: +..B1.77: + fldt .L_2il0floatpacket.2@GOTOFF(%ebp) + movl $8388608, 12(%esp) + flds 12(%esp) + fmulp %st, %st(1) + fstps 12(%esp) + jmp ..B1.86 +..1.1_1.TAG.3.0.1: +..B1.79: + movl $2130706432, 8(%esp) + flds 8(%esp) + flds 8(%esp) + fmulp %st, %st(1) + fstps 8(%esp) + jmp ..B1.86 +..1.1_1.TAG.2.0.1: +..B1.81: + movl $0, 4(%esp) +..B1.82: + flds 4(%esp) + fldt .L_2il0floatpacket.3@GOTOFF(%ebp) + fdivp %st, %st(1) + fstps 4(%esp) + jmp ..B1.86 +..1.1_1.TAG.1.0.1: +..B1.84: + movl $2139095040, (%esp) + flds (%esp) + flds (%esp) + fsubrp %st, %st(1) + fstps (%esp) +..1.1_1.TAG.0.0.1: +..B1.86: + movl %edi, %eax + addl $28, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret + .align 16,0x90 + .type __dpml_exception,@function + .size __dpml_exception,.-__dpml_exception + .section .rodata, "a" + .align 16 + .align 1 +.2.9_2.switchtab.1: + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .align 1 +.2.9_2.switchtab.2: + .byte ..1.1_1.TAG.0.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.1.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.2.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.3.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.4.0.1 - ..1.1_1.TAG.4.0.1 + .data +# -- End __dpml_exception + .text +# -- Begin __dpml_intel_atan_fixup + .text + .align 16,0x90 + .globl __dpml_intel_atan_fixup +__dpml_intel_atan_fixup: +# parameter 1: 32 + %esp +# parameter 2: 40 + %esp +# parameter 3: 44 + %esp +# parameter 4: 52 + %esp +..B2.1: +..L3: + + pushl %esi + pushl %edi + pushl %ebp + subl $16, %esp + movl 52(%esp), %eax + movl 36(%esp), %esi + andl $2147483647, %esi + movl 32(%esp), %edx + orl 56(%esp), %eax + je ..B2.3 +..B2.2: + movl %esi, %eax + movl %edx, %ecx + shll $28, %eax + andl $15, %ecx + shrl $4, %edx + shrl $4, %esi + orl %eax, %edx + jmp ..B2.4 +..B2.3: + movl $4, %ecx +..B2.4: + movl $10, %eax + lea (%esi,%esi,4), %edi + mull %edx + movl %eax, %esi + lea (%edx,%edi,2), %eax + addl %ecx, %esi + adcl $0, %eax + movl $77, %ecx + xorl %ebp, %ebp + addl $-22, %esi + movl %esi, %edx + adcl $-1, %eax + subl %ecx, %edx + sbbl %ebp, %eax + jb ..B2.5 +..B2.110: + orl %eax, %edx + jne ..B2.107 +..B2.5: + call ..L4 +..L4: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%edi), %edi + movl 44(%esp), %ecx + movl 48(%esp), %edx + movl __x_constants__@GOT(%edi), %ebp + movzwl .2.10_2.switchtab.4@GOTOFF(%edi,%esi,2), %eax + lea ..1.2_0.TAG.77.0.2@GOTOFF(%edi,%eax), %eax + jmp *%eax +..1.2_0.TAG.77.0.2: +..B2.7: + orl %edx, %ecx + je ..B2.9 +..B2.8: + movl $5, %esi + jmp ..B2.10 +..B2.9: + movl $11, %esi +..B2.10: + movl $3, %eax + jmp ..B2.101 +..1.2_0.TAG.76.0.2: +..B2.12: + movl $3, %eax + xorl %esi, %esi + jmp ..B2.104 +..1.2_0.TAG.75.0.2: +..1.2_0.TAG.73.0.2: +..1.2_0.TAG.71.0.2: +..1.2_0.TAG.65.0.2: +..1.2_0.TAG.63.0.2: +..1.2_0.TAG.61.0.2: +..1.2_0.TAG.57.0.2: +..1.2_0.TAG.56.0.2: +..1.2_0.TAG.51.0.2: +..1.2_0.TAG.47.0.2: +..1.2_0.TAG.46.0.2: +..1.2_0.TAG.41.0.2: +..1.2_0.TAG.37.0.2: +..1.2_0.TAG.36.0.2: +..1.2_0.TAG.31.0.2: +..1.2_0.TAG.27.0.2: +..1.2_0.TAG.26.0.2: +..1.2_0.TAG.21.0.2: +..1.2_0.TAG.17.0.2: +..1.2_0.TAG.16.0.2: +..1.2_0.TAG.15.0.2: +..1.2_0.TAG.14.0.2: +..1.2_0.TAG.13.0.2: +..1.2_0.TAG.12.0.2: +..1.2_0.TAG.7.0.2: +..1.2_0.TAG.6.0.2: +..1.2_0.TAG.5.0.2: +..1.2_0.TAG.4.0.2: +..1.2_0.TAG.3.0.2: +..1.2_0.TAG.2.0.2: +..B2.14: + xorl %eax, %eax + orl %edx, %ecx + jmp ..B2.101 +..1.2_0.TAG.67.0.2: +..B2.20: + orl %edx, %ecx + je ..B2.22 +..B2.21: + movl $5, %esi + jmp ..B2.100 +..B2.22: + movl $11, %esi + jmp ..B2.100 +..1.2_0.TAG.66.0.2: +..B2.25: + movl $2, %eax + xorl %esi, %esi + jmp ..B2.104 +..1.2_0.TAG.11.0.2: +..B2.69: + orl %edx, %ecx + je ..B2.71 +..B2.70: + movl $6, %esi + jmp ..B2.72 +..B2.71: + movl $10, %esi +..B2.72: + movl $3, %eax + jmp ..B2.101 +..1.2_0.TAG.10.0.2: +..B2.74: + orl %edx, %ecx + je ..B2.76 +..B2.75: + movl $4, %esi + jmp ..B2.77 +..B2.76: + movl $8, %esi +..B2.77: + movl $3, %eax + jmp ..B2.101 +..1.2_0.TAG.1.0.2: +..B2.92: + orl %edx, %ecx + je ..B2.94 +..B2.93: + movl $6, %esi + jmp ..B2.100 +..B2.94: + movl $10, %esi + jmp ..B2.100 +..1.2_0.TAG.0.0.2: +..B2.97: + orl %edx, %ecx + je ..B2.99 +..B2.98: + movl $4, %esi + jmp ..B2.100 +..B2.99: + movl $8, %esi +..B2.100: + movl $2, %eax +..B2.101: + je ..B2.103 +..B2.102: + movl $1182793727, (%esp) + flds (%esp) + flds (%esp) + fmulp %st, %st(1) + fstps (%esp) +..B2.103: + xorl %edx, %edx + orl %eax, %edx + je ..B2.107 +..B2.104: + shll $4, %esi + movl $3, %edi + subl %edi, %eax + xorl %edi, %edi + orl %edi, %eax + movl 8(%ebp,%esi), %ecx + movl 12(%ebp,%esi), %edx + jne ..B2.106 +..B2.105: + xorl $-2147483648, %edx +..B2.106: + movl 40(%esp), %eax + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + movl (%ebp,%esi), %edx + movl 4(%ebp,%esi), %ecx + movl %edx, (%eax) + movl %ecx, 4(%eax) + addl $16, %esp + popl %ebp + popl %edi + popl %esi + ret +..1.2_0.SWBASE.0.2: +..B2.107: + addl $16, %esp + popl %ebp + popl %edi + popl %esi + ret + .align 16,0x90 + .type __dpml_intel_atan_fixup,@function + .size __dpml_intel_atan_fixup,.-__dpml_intel_atan_fixup + .section .rodata, "a" + .space 1, 0x00 # pad + .align 2 +.2.10_2.switchtab.4: + .word ..1.2_0.TAG.0.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.1.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.10.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.11.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.66.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.67.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.76.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.77.0.2 - ..1.2_0.TAG.77.0.2 + .data +# -- End __dpml_intel_atan_fixup + .text +# -- Begin __dpml_intel_pow_fixup + .text + .align 16,0x90 + .globl __dpml_intel_pow_fixup +__dpml_intel_pow_fixup: +# parameter 1: 96 + %esp +# parameter 2: 104 + %esp +# parameter 3: 108 + %esp +# parameter 4: 112 + %esp +# parameter 5: 116 + %esp +# parameter 6: 120 + %esp +# parameter 7: 124 + %esp +..B3.1: +..L5: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $76, %esp + xorl %ecx, %ecx + call ..L6 +..L6: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L6](%eax), %eax + movl 96(%esp), %esi + movl %esi, %ebp + movl 100(%esp), %ebx + andl $15, %ebp + shrl $4, %esi + movl %eax, 40(%esp) + movl %ebx, %eax + andl $15, %esi + subl %ecx, %eax + jl ..B3.41 +..B3.2: + movl 112(%esp), %ecx + movl $-2147483648, %eax + movl 12(%ecx), %edi + subl %eax, %edi + orl 8(%ecx), %edi + jne ..B3.4 +..B3.3: + movl $1, %ecx + jmp ..B3.5 +..B3.4: + xorl %ecx, %ecx +..B3.5: + movl 112(%esp), %eax + movl 16(%eax), %edi + orl 20(%eax), %edi + jne ..B3.7 +..B3.6: + movl $1, %eax + jmp ..B3.8 +..B3.7: + xorl %eax, %eax +..B3.8: + andl %eax, %ecx + movl $10, %eax + mull %esi + movl $94, %esi + addl %ebp, %eax + adcl $0, %edx + negl %esi + addl %eax, %esi + orl %edx, %esi + je ..B3.37 +..B3.9: + movl %eax, %esi + movl $1, %edi + addl $-42, %esi + movl %ebp, 36(%esp) + movl %edx, %ebp + adcl $-1, %ebp + subl %edi, %esi + movl $0, %edi + sbbl %edi, %ebp + movl %ebp, 32(%esp) + movl 36(%esp), %ebp + jb ..B3.28 +..B3.58: + orl 32(%esp), %esi + je ..B3.28 +..B3.10: + movl %eax, %esi + movl $1, %edi + addl $-52, %esi + movl %ebp, 36(%esp) + movl %edx, %ebp + adcl $-1, %ebp + subl %edi, %esi + movl $0, %edi + sbbl %edi, %ebp + movl %ebp, 32(%esp) + movl 36(%esp), %ebp + jb ..B3.28 +..B3.59: + orl 32(%esp), %esi + je ..B3.28 +..B3.11: + movl %eax, %esi + movl %edx, %ecx + addl $-34, %esi + adcl $-1, %ecx + movl $1, %edi + subl %edi, %esi + movl $0, %edi + sbbl %edi, %ecx + jb ..B3.12 +..B3.60: + orl %ecx, %esi + jne ..B3.19 +..B3.12: + movl 40(%esp), %eax + movl __x_constants__@GOT(%eax), %ecx + movl 104(%esp), %eax + movl (%ecx), %esi + movl 4(%ecx), %edi + movl %esi, (%eax) + movl %edi, 4(%eax) + movl $5, %eax + subl %eax, %ebp + xorl %eax, %eax + orl %eax, %ebp + je ..B3.15 +..B3.13: + movl $2147418112, %eax +..B3.15: + movl $3, %ecx + movl 124(%esp), %esi + subl %ecx, %esi + movl 128(%esp), %ebp + orl %ebp, %esi + je ..B3.17 +..B3.16: + xorl %ecx, %ecx + jmp ..B3.18 +..B3.17: + movl $-2147483648, %ecx +..B3.18: + xorl %ecx, %eax + orl $-2147483648, %ebx + movl 104(%esp), %ecx + movl $0, 8(%ecx) + movl %eax, 12(%ecx) + jmp ..B3.34 +..B3.19: + movl $44, %ecx + subl %ecx, %eax + orl %edx, %eax + jne ..B3.34 +..B3.20: + movl 116(%esp), %eax + movl %eax, %ecx + movl 40(%esp), %ebp + movl 8(%eax), %edi + movl __x_constants__@GOT(%ebp), %eax + movl 12(%ecx), %esi + subl 24(%eax), %edi + subl 28(%eax), %esi + orl %esi, %edi + jne ..B3.34 +..B3.21: + movl 116(%esp), %ecx + movl %ecx, %ebp + movl (%ecx), %edi + movl 4(%ebp), %esi + subl 16(%eax), %edi + subl 20(%eax), %esi + orl %esi, %edi + jne ..B3.34 +..B3.22: + movl 120(%esp), %ebp + pushl %ebp + pushl $0 + pushl $7 + pushl 124(%esp) + call __dpml_ux_sqrt_evaluation__ +..B3.65: + addl $16, %esp +..B3.23: + orl %edx, %eax + jne ..B3.25 +..B3.24: + movl $1, %eax + jmp ..B3.26 +..B3.25: + xorl %eax, %eax +..B3.26: + xorl %ecx, %ecx + movl %eax, 40(%esp) + movl %ecx, 44(%esp) + addl $28, %esp + lea 4(%esp), %eax + pushl %eax + pushl %ecx + pushl %ecx + pushl %ecx + pushl %ecx + pushl 96(%esp) + pushl %ebp + call __dpml_pack__ + jmp ..B3.33 +..B3.28: + movl 40(%esp), %esi + movl __x_constants__@GOT(%esi), %edx + movl 40(%edx), %edi + movl %edi, 32(%esp) + movl 44(%edx), %esi + movl 32(%edx), %eax + movl 36(%edx), %edi + movl 104(%esp), %edx + movl %eax, (%edx) + movl 112(%esp), %eax + movl %edi, 4(%edx) + movl 4(%eax), %eax + cmpl $1, %eax + je ..B3.35 +..B3.29: + movl $2, %ecx + xorl %esi, %esi + subl %ecx, %ebp + orl %esi, %ebp + je ..B3.31 +..B3.30: + xorl %ecx, %ecx + jmp ..B3.32 +..B3.31: + movl $1, %ecx +..B3.32: + testl %eax, %eax + movl $0, %eax + movl 104(%esp), %esi + setle %al + cmpl %eax, %ecx + movl $2147418112, %ecx + movl $0, 8(%esi) + jne ..L7 + movl $0, %ecx +..L7: + movl %ecx, 12(%esi) +..B3.33: + orl $-2147483648, %ebx +..B3.34: + movl 96(%esp), %eax + movl %ebx, %edx + addl $76, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B3.35: + xorl %edi, %edi + orl %edi, %ecx + je ..B3.29 +..B3.36: + movl 104(%esp), %ecx + movl 32(%esp), %eax + movl %eax, 8(%ecx) + movl %esi, 12(%ecx) + jmp ..B3.33 +..B3.37: + movl $3, %eax + movl 124(%esp), %ebp + subl %eax, %ebp + movl 128(%esp), %ecx + orl %ecx, %ebp + je ..B3.39 +..B3.38: + xorl %eax, %eax + jmp ..B3.40 +..B3.39: + movl $-2147483648, %eax +..B3.40: + movl 104(%esp), %edi + orl $-2147483648, %ebx + movl %eax, 12(%edi) + movl 108(%esp), %eax + movl %eax, %ecx + movl $0, 8(%edi) + movl (%eax), %ebp + movl 4(%ecx), %esi + movl %ebp, (%edi) + movl %esi, 4(%edi) + jmp ..B3.34 +..B3.41: + movl $10, %eax + movl $95, %ecx + mull %esi + addl %eax, %ebp + adcl $0, %edx + negl %ecx + addl %ebp, %ecx + orl %edx, %ecx + je ..B3.53 +..B3.42: + movl %ebp, %edi + movl %edx, %esi + addl $-40, %edi + adcl $-1, %esi + movl $1, %eax + xorl %ecx, %ecx + subl %eax, %edi + sbbl %ecx, %esi + jb ..B3.50 +..B3.61: + orl %esi, %edi + je ..B3.50 +..B3.43: + movl %ebp, %edi + movl %edx, %esi + addl $-80, %edi + adcl $-1, %esi + subl %eax, %edi + sbbl %ecx, %esi + jb ..B3.49 +..B3.62: + orl %esi, %edi + je ..B3.49 +..B3.44: + movl %ebp, %edi + movl %edx, %esi + addl $-90, %edi + adcl $-1, %esi + subl %eax, %edi + sbbl %ecx, %esi + jb ..B3.49 +..B3.63: + orl %esi, %edi + je ..B3.49 +..B3.45: + addl $-46, %ebp + adcl $-1, %edx + subl %eax, %ebp + sbbl %ecx, %edx + jb ..B3.46 +..B3.64: + orl %edx, %ebp + jne ..B3.34 +..B3.46: + movl 108(%esp), %eax + movl %eax, %ecx + movl 40(%esp), %ebp + movl 8(%eax), %edi + movl __x_constants__@GOT(%ebp), %eax + movl 12(%ecx), %esi + subl 40(%eax), %edi + subl 44(%eax), %esi + orl %esi, %edi + jne ..B3.48 +..B3.47: + movl 108(%esp), %ecx + movl %ecx, %ebp + movl (%ecx), %edi + movl 4(%ebp), %esi + subl 32(%eax), %edi + subl 36(%eax), %esi + orl %esi, %edi + je ..B3.34 +..B3.48: + movl $1182793727, 60(%esp) + flds 60(%esp) + flds 60(%esp) + fmulp %st, %st(1) + fstps 60(%esp) + jmp ..B3.34 +..B3.49: + movl 116(%esp), %ecx + movl %ecx, %ebp + movl 104(%esp), %eax + movl 8(%ecx), %esi + movl 12(%ebp), %edi + orl $32768, %edi + movl %esi, 8(%eax) + movl %edi, 12(%eax) + movl (%ecx), %ebp + movl 4(%ecx), %ecx + movl %ebp, (%eax) + movl %ecx, 4(%eax) + jmp ..B3.34 +..B3.50: + movl 40(%esp), %eax + movl 108(%esp), %ecx + movl 108(%esp), %ebp + movl __x_constants__@GOT(%eax), %eax + movl 8(%ecx), %ecx + movl 12(%ebp), %ebp + movl 40(%eax), %edi + subl %edi, %ecx + movl 44(%eax), %esi + subl %esi, %ebp + orl %ebp, %ecx + jne ..B3.49 +..B3.51: + movl 32(%eax), %ebp + movl 36(%eax), %ecx + movl 108(%esp), %eax + movl 108(%esp), %edx + movl (%eax), %eax + movl 4(%edx), %edx + subl %ebp, %eax + subl %ecx, %edx + orl %edx, %eax + jne ..B3.49 +..B3.52: + movl 104(%esp), %eax + movl %esi, 12(%eax) + movl %ebp, %esi + movl %edi, 8(%eax) + movl %esi, (%eax) + movl %ecx, 4(%eax) + jmp ..B3.34 +..B3.53: + movl 128(%esp), %ecx + movl 124(%esp), %eax + orl %eax, %ecx + je ..B3.34 +..B3.54: + movl 124(%esp), %ecx + xorl %eax, %eax + andl $2, %ecx + orl %eax, %ecx + je ..B3.34 +..B3.55: + movl 104(%esp), %eax + xorl $-2147483648, 12(%eax) + jmp ..B3.34 + .align 16,0x90 + .type __dpml_intel_pow_fixup,@function + .size __dpml_intel_pow_fixup,.-__dpml_intel_pow_fixup + .data +# -- End __dpml_intel_pow_fixup + .text +# -- Begin __dpml_d_intel_order_fixup + .text + .align 16,0x90 + .globl __dpml_d_intel_order_fixup +__dpml_d_intel_order_fixup: +# parameter 1: 4 + %esp +..B4.1: +..L8: + + fldl 4(%esp) + ret + .align 16,0x90 + .type __dpml_d_intel_order_fixup,@function + .size __dpml_d_intel_order_fixup,.-__dpml_d_intel_order_fixup + .data +# -- End __dpml_d_intel_order_fixup + .section .rodata, "a" + .space 2, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xe6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .align 4 +__dpml_response_table: + .long 0 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 1 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 2 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 3 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 3 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 4 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 4 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 6 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 7 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 8 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 8 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 8 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 9 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 9 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 9 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 10 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 10 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 10 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 11 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 11 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 39 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 39 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 12 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 13 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 14 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 33 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 33 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 33 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 33 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 33 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 33 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 34 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 34 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 34 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 34 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 34 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 34 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 34 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 34 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 16 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 16 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 16 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 16 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 17 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 17 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 17 + .byte 0 + .byte 12 + .byte 0 + .byte 12 + .long 38 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 38 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 38 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 47 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 47 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 47 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 47 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 47 + .byte 0 + .byte 8 + .byte 0 + .byte 8 + .long 47 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 47 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 47 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 37 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 18 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 18 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 18 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 19 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 19 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 19 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 20 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 20 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 20 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 45 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 45 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 21 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 21 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 21 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 40 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 40 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 40 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 40 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 22 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 22 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 22 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 22 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 22 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 22 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 22 + .byte 0 + .byte 11 + .byte 0 + .byte 11 + .long 22 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 22 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 22 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 22 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 22 + .byte 0 + .byte 8 + .byte 0 + .byte 8 + .long 22 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 22 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 22 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 41 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 41 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 41 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 41 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 41 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 41 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 41 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 48 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 48 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 23 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 23 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 23 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 24 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 31 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 32 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 32 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 25 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 25 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 26 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 26 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 26 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 27 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 63 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 63 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 28 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 29 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 29 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 29 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 29 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 29 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 30 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 30 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 35 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 36 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 36 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 49 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 50 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 51 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 50 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 50 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 51 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 51 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 42 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 43 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 44 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 42 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 42 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 43 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 43 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 43 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 44 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 44 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 44 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 44 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 46 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 46 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 46 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 46 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 46 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 53 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 78 + .byte 0 + .byte 1 + .byte 0 + .byte 0 + .long 64 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 64 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 64 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 64 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 66 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 66 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 66 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 67 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 67 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 67 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 65 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 65 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 65 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 65 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 65 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 65 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 65 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 68 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 69 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 70 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 71 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 72 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 72 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 72 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 73 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 73 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 73 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 73 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 74 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 74 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 77 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 77 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 77 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 77 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 77 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 77 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 79 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 79 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .type __dpml_response_table,@object + .size __dpml_response_table,1520 + .align 4 + .globl __dpml_globals_table +__dpml_globals_table: + .long 4290772992 + .long 0 + .long 0 + .long 4294443008 + .long 0 + .long 0 + .long 0 + .long 4294934528 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 1 + .long 0 + .long 1 + .long 0 + .long 0 + .long 0 + .long 2147483649 + .long 0 + .long 1 + .long 2147483648 + .long 1 + .long 0 + .long 0 + .long 2147483648 + .long 2139095039 + .long 0 + .long 4294967295 + .long 2146435071 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 2147418111 + .long 4286578687 + .long 0 + .long 4294967295 + .long 4293918719 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294901759 + .long 2139095040 + .long 0 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 2147418112 + .long 4286578688 + .long 0 + .long 0 + .long 4293918720 + .long 0 + .long 0 + .long 0 + .long 4294901760 + .long 872415232 + .long 0 + .long 0 + .long 1018167296 + .long 0 + .long 0 + .long 0 + .long 1066336256 + .long 3019898880 + .long 0 + .long 0 + .long 3165650944 + .long 0 + .long 0 + .long 0 + .long 3213819904 + .long 1065353216 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 1073676288 + .long 3212836864 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 3221159936 + .type __dpml_globals_table,@object + .size __dpml_globals_table,416 + .data + .hidden __dpml_ux_sqrt_evaluation__ + .hidden __dpml_pack__ + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/isfinite.S b/external/sgx_libm/ia32/isfinite.S new file mode 100644 index 0000000000..d6e0559c12 --- /dev/null +++ b/external/sgx_libm/ia32/isfinite.S @@ -0,0 +1,389 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isfinite.c" + .text +..TXTST0: +# -- Begin isfinitel + .text + .align 16,0x90 + .globl isfinitel +isfinitel: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movzwl 12(%esp), %edx + shll $16, %edx + movzwl 10(%esp), %eax + orl %eax, %edx + andl $2147483647, %edx + xorl %eax, %eax + cmpl $2147418112, %edx + setb %al + ret + .align 16,0x90 + .type isfinitel,@function + .size isfinitel,.-isfinitel + .data +# -- End isfinitel + .text +# -- Begin __isfinitel + .text + .align 16,0x90 + .globl __isfinitel +__isfinitel: +# parameter 1: 4 + %esp +..B2.1: +..L2: + + movzwl 12(%esp), %edx + shll $16, %edx + movzwl 10(%esp), %eax + orl %eax, %edx + andl $2147483647, %edx + xorl %eax, %eax + cmpl $2147418112, %edx + setb %al + ret + .align 16,0x90 + .type __isfinitel,@function + .size __isfinitel,.-__isfinitel + .data +# -- End __isfinitel + .text +# -- Begin isfinitef + .text + .align 16,0x90 + .globl isfinitef +isfinitef: +# parameter 1: 4 + %esp +..B3.1: +..L3: + + movl 4(%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type isfinitef,@function + .size isfinitef,.-isfinitef + .data +# -- End isfinitef + .text +# -- Begin __isfinitef + .text + .align 16,0x90 + .globl __isfinitef +__isfinitef: +# parameter 1: 4 + %esp +..B4.1: +..L4: + + movl 4(%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __isfinitef,@function + .size __isfinitef,.-__isfinitef + .data +# -- End __isfinitef + .text +# -- Begin isfinite + .text + .align 16,0x90 + .globl isfinite +isfinite: +# parameter 1: 4 + %esp +..B5.1: +..L5: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type isfinite,@function + .size isfinite,.-isfinite + .data +# -- End isfinite + .text +# -- Begin __isfinite + .text + .align 16,0x90 + .globl __isfinite +__isfinite: +# parameter 1: 4 + %esp +..B6.1: +..L6: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __isfinite,@function + .size __isfinite,.-__isfinite + .data +# -- End __isfinite + .text +# -- Begin isfinited + .text + .align 16,0x90 + .globl isfinited +isfinited: +# parameter 1: 4 + %esp +..B7.1: +..L7: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type isfinited,@function + .size isfinited,.-isfinited + .data +# -- End isfinited + .text +# -- Begin __isfinited + .text + .align 16,0x90 + .globl __isfinited +__isfinited: +# parameter 1: 4 + %esp +..B8.1: +..L8: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __isfinited,@function + .size __isfinited,.-__isfinited + .data +# -- End __isfinited + .text +# -- Begin finitel + .text + .align 16,0x90 + .globl finitel +finitel: +# parameter 1: 4 + %esp +..B9.1: +..L9: + + movzwl 12(%esp), %edx + shll $16, %edx + movzwl 10(%esp), %eax + orl %eax, %edx + andl $2147483647, %edx + xorl %eax, %eax + cmpl $2147418112, %edx + setb %al + ret + .align 16,0x90 + .type finitel,@function + .size finitel,.-finitel + .data +# -- End finitel + .text +# -- Begin __finitel + .text + .align 16,0x90 + .globl __finitel +__finitel: +# parameter 1: 4 + %esp +..B10.1: +..L10: + + movzwl 12(%esp), %edx + shll $16, %edx + movzwl 10(%esp), %eax + orl %eax, %edx + andl $2147483647, %edx + xorl %eax, %eax + cmpl $2147418112, %edx + setb %al + ret + .align 16,0x90 + .type __finitel,@function + .size __finitel,.-__finitel + .data +# -- End __finitel + .text +# -- Begin finitef + .text + .align 16,0x90 + .globl finitef +finitef: +# parameter 1: 4 + %esp +..B11.1: +..L11: + + movl 4(%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type finitef,@function + .size finitef,.-finitef + .data +# -- End finitef + .text +# -- Begin __finitef + .text + .align 16,0x90 + .globl __finitef +__finitef: +# parameter 1: 4 + %esp +..B12.1: +..L12: + + movl 4(%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __finitef,@function + .size __finitef,.-__finitef + .data +# -- End __finitef + .text +# -- Begin finite + .text + .align 16,0x90 + .globl finite +finite: +# parameter 1: 4 + %esp +..B13.1: +..L13: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type finite,@function + .size finite,.-finite + .data +# -- End finite + .text +# -- Begin __finite + .text + .align 16,0x90 + .globl __finite +__finite: +# parameter 1: 4 + %esp +..B14.1: +..L14: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __finite,@function + .size __finite,.-__finite + .data +# -- End __finite + .text +# -- Begin finited + .text + .align 16,0x90 + .globl finited +finited: +# parameter 1: 4 + %esp +..B15.1: +..L15: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type finited,@function + .size finited,.-finited + .data +# -- End finited + .text +# -- Begin __finited + .text + .align 16,0x90 + .globl __finited +__finited: +# parameter 1: 4 + %esp +..B16.1: +..L16: + + movl 8(%esp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __finited,@function + .size __finited,.-__finited + .data +# -- End __finited + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/isinf.S b/external/sgx_libm/ia32/isinf.S new file mode 100644 index 0000000000..bed0122708 --- /dev/null +++ b/external/sgx_libm/ia32/isinf.S @@ -0,0 +1,313 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isinf.c" + .text +..TXTST0: +# -- Begin __isinfd + .text + .align 16,0x90 + .globl __isinfd +__isinfd: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movl $2146435072, %ecx + negl %ecx + movl 8(%esp), %eax + addl %eax, %ecx + movl 4(%esp), %edx + orl %edx, %ecx + jne ..B1.3 +..B1.2: + movl $1, %eax + ret +..B1.3: + movl $-1048576, %ecx + subl %ecx, %eax + orl %eax, %edx + jne ..B1.5 +..B1.4: + movl $-1, %eax + ret +..B1.5: + xorl %eax, %eax +..B1.6: + ret + .align 16,0x90 + .type __isinfd,@function + .size __isinfd,.-__isinfd + .data +# -- End __isinfd + .text +# -- Begin isinfd + .text + .align 16,0x90 + .globl isinfd +isinfd: +# parameter 1: 4 + %esp +..B2.1: +..L2: + + movl $2146435072, %ecx + negl %ecx + movl 8(%esp), %eax + addl %eax, %ecx + movl 4(%esp), %edx + orl %edx, %ecx + jne ..B2.3 +..B2.2: + movl $1, %eax + ret +..B2.3: + movl $-1048576, %ecx + subl %ecx, %eax + orl %eax, %edx + jne ..B2.5 +..B2.4: + movl $-1, %eax + ret +..B2.5: + xorl %eax, %eax +..B2.6: + ret + .align 16,0x90 + .type isinfd,@function + .size isinfd,.-isinfd + .data +# -- End isinfd + .text +# -- Begin __isinf + .text + .align 16,0x90 + .globl __isinf +__isinf: +# parameter 1: 4 + %esp +..B3.1: +..L3: + + movl $2146435072, %ecx + negl %ecx + movl 8(%esp), %eax + addl %eax, %ecx + movl 4(%esp), %edx + orl %edx, %ecx + jne ..B3.3 +..B3.2: + movl $1, %eax + ret +..B3.3: + movl $-1048576, %ecx + subl %ecx, %eax + orl %eax, %edx + jne ..B3.5 +..B3.4: + movl $-1, %eax + ret +..B3.5: + xorl %eax, %eax +..B3.6: + ret + .align 16,0x90 + .type __isinf,@function + .size __isinf,.-__isinf + .data +# -- End __isinf + .text +# -- Begin isinf + .text + .align 16,0x90 + .globl isinf +isinf: +# parameter 1: 4 + %esp +..B4.1: +..L4: + + movl $2146435072, %ecx + negl %ecx + movl 8(%esp), %eax + addl %eax, %ecx + movl 4(%esp), %edx + orl %edx, %ecx + jne ..B4.3 +..B4.2: + movl $1, %eax + ret +..B4.3: + movl $-1048576, %ecx + subl %ecx, %eax + orl %eax, %edx + jne ..B4.5 +..B4.4: + movl $-1, %eax + ret +..B4.5: + xorl %eax, %eax +..B4.6: + ret + .align 16,0x90 + .type isinf,@function + .size isinf,.-isinf + .data +# -- End isinf + .text +# -- Begin __isinff + .text + .align 16,0x90 + .globl __isinff +__isinff: +# parameter 1: 4 + %esp +..B5.1: +..L5: + + movl 4(%esp), %edx + cmpl $2139095040, %edx + jne ..B5.3 +..B5.2: + movl $1, %eax + ret +..B5.3: + cmpl $-8388608, %edx + movl $0, %eax + setne %al + decl %eax + ret + .align 16,0x90 + .type __isinff,@function + .size __isinff,.-__isinff + .data +# -- End __isinff + .text +# -- Begin isinff + .text + .align 16,0x90 + .globl isinff +isinff: +# parameter 1: 4 + %esp +..B6.1: +..L6: + + movl 4(%esp), %edx + cmpl $2139095040, %edx + jne ..B6.3 +..B6.2: + movl $1, %eax + ret +..B6.3: + cmpl $-8388608, %edx + movl $0, %eax + setne %al + decl %eax + ret + .align 16,0x90 + .type isinff,@function + .size isinff,.-isinff + .data +# -- End isinff + .text +# -- Begin __isinfl + .text + .align 16,0x90 + .globl __isinfl +__isinfl: +# parameter 1: 4 + %esp +..B7.1: +..L7: + + movzwl 12(%esp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B7.3 +..B7.2: + xorl %eax, %eax + ret +..B7.3: + cmpl $-2147483648, 8(%esp) + jne ..B7.2 +..B7.4: + cmpl $0, 4(%esp) + jne ..B7.2 +..B7.5: + movzbl 13(%esp), %eax + notl %eax + andl $128, %eax + shrl $6, %eax + decl %eax + ret + .align 16,0x90 + .type __isinfl,@function + .size __isinfl,.-__isinfl + .data +# -- End __isinfl + .text +# -- Begin isinfl + .text + .align 16,0x90 + .globl isinfl +isinfl: +# parameter 1: 4 + %esp +..B8.1: +..L8: + + movzwl 12(%esp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B8.3 +..B8.2: + xorl %eax, %eax + ret +..B8.3: + cmpl $-2147483648, 8(%esp) + jne ..B8.2 +..B8.4: + cmpl $0, 4(%esp) + jne ..B8.2 +..B8.5: + movzbl 13(%esp), %eax + notl %eax + andl $128, %eax + shrl $6, %eax + decl %eax + ret + .align 16,0x90 + .type isinfl,@function + .size isinfl,.-isinfl + .data +# -- End isinfl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/isnan.S b/external/sgx_libm/ia32/isnan.S new file mode 100644 index 0000000000..e49ab0acab --- /dev/null +++ b/external/sgx_libm/ia32/isnan.S @@ -0,0 +1,271 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isnan.c" + .text +..TXTST0: +# -- Begin __isnand + .text + .align 16,0x90 + .globl __isnand +__isnand: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movl $2146435072, %eax + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + subl %eax, %edx + jb ..B1.3 +..B1.7: + orl %edx, %ecx + je ..B1.3 +..B1.2: + movl $1, %eax + ret +..B1.3: + xorl %eax, %eax +..B1.4: + ret + .align 16,0x90 + .type __isnand,@function + .size __isnand,.-__isnand + .data +# -- End __isnand + .text +# -- Begin isnand + .text + .align 16,0x90 + .globl isnand +isnand: +# parameter 1: 4 + %esp +..B2.1: +..L2: + + movl $2146435072, %eax + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + subl %eax, %edx + jb ..B2.3 +..B2.7: + orl %edx, %ecx + je ..B2.3 +..B2.2: + movl $1, %eax + ret +..B2.3: + xorl %eax, %eax +..B2.4: + ret + .align 16,0x90 + .type isnand,@function + .size isnand,.-isnand + .data +# -- End isnand + .text +# -- Begin __isnan + .text + .align 16,0x90 + .globl __isnan +__isnan: +# parameter 1: 4 + %esp +..B3.1: +..L3: + + movl $2146435072, %eax + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + subl %eax, %edx + jb ..B3.3 +..B3.7: + orl %edx, %ecx + je ..B3.3 +..B3.2: + movl $1, %eax + ret +..B3.3: + xorl %eax, %eax +..B3.4: + ret + .align 16,0x90 + .type __isnan,@function + .size __isnan,.-__isnan + .data +# -- End __isnan + .text +# -- Begin isnan + .text + .align 16,0x90 + .globl isnan +isnan: +# parameter 1: 4 + %esp +..B4.1: +..L4: + + movl $2146435072, %eax + movl 8(%esp), %edx + andl $2147483647, %edx + movl 4(%esp), %ecx + subl %eax, %edx + jb ..B4.3 +..B4.7: + orl %edx, %ecx + je ..B4.3 +..B4.2: + movl $1, %eax + ret +..B4.3: + xorl %eax, %eax +..B4.4: + ret + .align 16,0x90 + .type isnan,@function + .size isnan,.-isnan + .data +# -- End isnan + .text +# -- Begin __isnanf + .text + .align 16,0x90 + .globl __isnanf +__isnanf: +# parameter 1: 4 + %esp +..B5.1: +..L5: + + movl 4(%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + movl $0, %eax + seta %al + ret + .align 16,0x90 + .type __isnanf,@function + .size __isnanf,.-__isnanf + .data +# -- End __isnanf + .text +# -- Begin isnanf + .text + .align 16,0x90 + .globl isnanf +isnanf: +# parameter 1: 4 + %esp +..B6.1: +..L6: + + movl 4(%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + movl $0, %eax + seta %al + ret + .align 16,0x90 + .type isnanf,@function + .size isnanf,.-isnanf + .data +# -- End isnanf + .text +# -- Begin __isnanl + .text + .align 16,0x90 + .globl __isnanl +__isnanl: +# parameter 1: 4 + %esp +..B7.1: +..L7: + + movzwl 12(%esp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B7.4 +..B7.2: + xorl %eax, %eax +..B7.3: + ret +..B7.4: + cmpl $-2147483648, 8(%esp) + jne ..B7.6 +..B7.5: + cmpl $0, 4(%esp) + je ..B7.2 +..B7.6: + movl $1, %eax + ret + .align 16,0x90 + .type __isnanl,@function + .size __isnanl,.-__isnanl + .data +# -- End __isnanl + .text +# -- Begin isnanl + .text + .align 16,0x90 + .globl isnanl +isnanl: +# parameter 1: 4 + %esp +..B8.1: +..L8: + + movzwl 12(%esp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B8.4 +..B8.2: + xorl %eax, %eax +..B8.3: + ret +..B8.4: + cmpl $-2147483648, 8(%esp) + jne ..B8.6 +..B8.5: + cmpl $0, 4(%esp) + je ..B8.2 +..B8.6: + movl $1, %eax + ret + .align 16,0x90 + .type isnanl,@function + .size isnanl,.-isnanl + .data +# -- End isnanl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/isnormal.S b/external/sgx_libm/ia32/isnormal.S new file mode 100644 index 0000000000..abc76f0b8d --- /dev/null +++ b/external/sgx_libm/ia32/isnormal.S @@ -0,0 +1,241 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isnormal.c" + .text +..TXTST0: +# -- Begin __isnormald + .text + .align 16,0x90 + .globl __isnormald +__isnormald: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movl 8(%esp), %eax + andl $2147483647, %eax + addl $-1048576, %eax + cmpl $2145386496, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __isnormald,@function + .size __isnormald,.-__isnormald + .data +# -- End __isnormald + .text +# -- Begin isnormald + .text + .align 16,0x90 + .globl isnormald +isnormald: +# parameter 1: 4 + %esp +..B2.1: +..L2: + + movl 8(%esp), %eax + andl $2147483647, %eax + addl $-1048576, %eax + cmpl $2145386496, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type isnormald,@function + .size isnormald,.-isnormald + .data +# -- End isnormald + .text +# -- Begin __isnormal + .text + .align 16,0x90 + .globl __isnormal +__isnormal: +# parameter 1: 4 + %esp +..B3.1: +..L3: + + movl 8(%esp), %eax + andl $2147483647, %eax + addl $-1048576, %eax + cmpl $2145386496, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __isnormal,@function + .size __isnormal,.-__isnormal + .data +# -- End __isnormal + .text +# -- Begin isnormal + .text + .align 16,0x90 + .globl isnormal +isnormal: +# parameter 1: 4 + %esp +..B4.1: +..L4: + + movl 8(%esp), %eax + andl $2147483647, %eax + addl $-1048576, %eax + cmpl $2145386496, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type isnormal,@function + .size isnormal,.-isnormal + .data +# -- End isnormal + .text +# -- Begin __isnormalf + .text + .align 16,0x90 + .globl __isnormalf +__isnormalf: +# parameter 1: 4 + %esp +..B5.1: +..L5: + + movl 4(%esp), %eax + andl $2147483647, %eax + addl $-8388608, %eax + cmpl $2130706432, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type __isnormalf,@function + .size __isnormalf,.-__isnormalf + .data +# -- End __isnormalf + .text +# -- Begin isnormalf + .text + .align 16,0x90 + .globl isnormalf +isnormalf: +# parameter 1: 4 + %esp +..B6.1: +..L6: + + movl 4(%esp), %eax + andl $2147483647, %eax + addl $-8388608, %eax + cmpl $2130706432, %eax + movl $0, %eax + setb %al + ret + .align 16,0x90 + .type isnormalf,@function + .size isnormalf,.-isnormalf + .data +# -- End isnormalf + .text +# -- Begin __isnormall + .text + .align 16,0x90 + .globl __isnormall +__isnormall: +# parameter 1: 4 + %esp +..B7.1: +..L7: + + movzwl 12(%esp), %edx + shll $16, %edx + movzwl 10(%esp), %eax + orl %eax, %edx + andl $2147483647, %edx + cmpl $4096, %edx + jb ..B7.4 +..B7.2: + testl $32768, %edx + jne ..B7.4 +..B7.3: + xorl %eax, %eax + ret +..B7.4: + addl $-65536, %edx + xorl %eax, %eax + cmpl $2147352576, %edx + setb %al + ret + .align 16,0x90 + .type __isnormall,@function + .size __isnormall,.-__isnormall + .data +# -- End __isnormall + .text +# -- Begin isnormall + .text + .align 16,0x90 + .globl isnormall +isnormall: +# parameter 1: 4 + %esp +..B8.1: +..L8: + + movzwl 12(%esp), %edx + shll $16, %edx + movzwl 10(%esp), %eax + orl %eax, %edx + andl $2147483647, %edx + cmpl $4096, %edx + jb ..B8.4 +..B8.2: + testl $32768, %edx + jne ..B8.4 +..B8.3: + xorl %eax, %eax + ret +..B8.4: + addl $-65536, %edx + xorl %eax, %eax + cmpl $2147352576, %edx + setb %al + ret + .align 16,0x90 + .type isnormall,@function + .size isnormall,.-isnormall + .data +# -- End isnormall + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/j0.S b/external/sgx_libm/ia32/j0.S new file mode 100644 index 0000000000..e0d0e8793e --- /dev/null +++ b/external/sgx_libm/ia32/j0.S @@ -0,0 +1,2689 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j0.c" + .text +..TXTST0: +# -- Begin __j0l + .text + .align 16,0x90 + .hidden __j0l + .globl __j0l +__j0l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %ebx + subl $120, %esp + fldt 8(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fldt 132+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B1.9 +..B1.2: + fldt _S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.4 +..B1.3: + fldt _Z@GOTOFF(%ebx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt _P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 168+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 180+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 192+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 204+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 216+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 228+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 240+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.4: + movl $1, %edx +..B1.5: + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %ecx + fldt _S@GOTOFF(%ebx,%ecx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.8 + jp ..B1.8 +..B1.6: + incl %edx + cmpl $11, %edx + jl ..B1.5 +..B1.7: + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx +..B1.8: + fldt _Z@GOTOFF(%ecx,%ebx) + movl %edx, %eax + fsubrp %st, %st(1) + shll $4, %eax + fld %st(0) + subl %edx, %eax + shll $4, %eax + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt -240+_P@GOTOFF(%eax,%ebx) + fmul %st(1), %st + fldt -228+_P@GOTOFF(%eax,%ebx) + fmul %st(2), %st + fldt -216+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -204+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -192+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -180+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -168+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -156+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -144+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -132+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -120+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -108+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -96+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -84+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -72+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -60+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -48+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -36+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -24+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -12+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + fldl _ones@GOTOFF(%ebx) + lea 92(%esp), %eax + fdiv %st(1), %st + lea 64(%esp), %edx + fxch %st(1) + fxch %st(1) + fstpt -60(%eax) + fldt -60(%eax) + fxch %st(1) + fstpt (%esp) + fldt _val_36_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt -28(%eax) + fldt -28(%eax) + movl %eax, 12(%esp) + movl %edx, 16(%esp) + movl $-1, 20(%esp) + fxch %st(1) + fstpt (%eax) + fldt (%eax) + fldt _PP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _QP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 96+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 108+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt -44(%eax) + fldt 108+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt -12(%eax) + call __libm_sincos_pi4l +..B1.10: + fldt 8(%ebp) + fldt 80(%esp) + fldt 48(%esp) + fldt 64(%esp) + fmulp %st, %st(1) + fldt 92(%esp) + fmulp %st, %st(2) + fsub %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt _val_0_03L@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B1.12 + jp ..B1.12 +..B1.11: + fstp %st(1) + fldt _tonpi@GOTOFF(%ebx) + fldt 32(%esp) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.12: + fstp %st(0) + lea 32(%esp), %esi + movl %esi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.19: + addl $-32, %esp + movl (%esi), %ecx + lea 80(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%esi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%esi), %ecx + movl 12(%esi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __j0q@PLT +..B1.18: + addl $28, %esp +..B1.13: + movl 48(%esp), %eax + movl %eax, (%esi) + movl 52(%esp), %edx + movl 56(%esp), %ecx + movl 60(%esp), %eax + addl $4, %esp + pushl %esi + movl %edx, 4(%esi) + movl %ecx, 8(%esi) + movl %eax, 12(%esi) + call __qtol@PLT +..B1.14: + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __j0l,@function + .size __j0l,.-__j0l + .data +# -- End __j0l + .text +# -- Begin j0 + .text + .align 16,0x90 + .globl j0 +j0: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp +..B2.2: + fnstcw 46(%esp) +..B2.3: + movl 12(%ebp), %eax + andl $2147483647, %eax + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + cmpl $2146435072, %eax + jge ..B2.26 +..B2.4: + cmpl $1012924416, %eax + jl ..B2.25 +..B2.5: + movzwl 46(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.31 +..B2.6: + orl $-64768, %edx + movw %dx, 44(%esp) +..B2.7: + fldcw 44(%esp) +..B2.8: + movl $1, %edi +..B2.9: + fldl 8(%ebp) + fabs + fldt 132+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B2.17 +..B2.10: + fldt _S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.12 +..B2.11: + fldt _Z@GOTOFF(%ebx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 76(%esp) + fldt 76(%esp) + fldt _P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 168+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 180+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 192+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 204+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 216+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 228+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 240+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B2.22 +..B2.12: + movl $1, %edx +..B2.13: + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %ecx + fldt _S@GOTOFF(%ebx,%ecx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B2.16 + jp ..B2.16 +..B2.14: + incl %edx + cmpl $11, %edx + jl ..B2.13 +..B2.15: + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx +..B2.16: + fldt _Z@GOTOFF(%ecx,%ebx) + movl %edx, %eax + shll $4, %eax + fsubrp %st, %st(1) + subl %edx, %eax + fld %st(0) + shll $4, %eax + fmul %st(1), %st + fstpt 76(%esp) + fldt 76(%esp) + fldt -240+_P@GOTOFF(%eax,%ebx) + fmul %st(1), %st + fldt -228+_P@GOTOFF(%eax,%ebx) + fmul %st(2), %st + fldt -216+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -204+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -192+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -180+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -168+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -156+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -144+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -132+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -120+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -108+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -96+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -84+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -72+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -60+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -48+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -36+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -24+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -12+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B2.22 +..B2.17: + fldl _ones@GOTOFF(%ebx) + fdiv %st(1), %st + fstpt (%esp) + fldt (%esp) + fldt _val_36_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + fstpt 76(%esp) + fldt 76(%esp) + addl $-32, %esp + lea 108(%esp), %eax + lea 64(%esp), %edx + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fldt _PP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP@GOTOFF(%ebx) + movl %eax, 12(%esp) + faddp %st, %st(1) + fmul %st(2), %st + fldt _QP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP@GOTOFF(%ebx) + movl %edx, 16(%esp) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_PP@GOTOFF(%ebx) + movl $-1, 20(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fstpt -12(%eax) + fldt 24+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 108+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt -60(%eax) + fldt 108+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -28(%eax) + call __libm_sincos_pi4l +..B2.34: + fldt 96(%esp) + fldt 80(%esp) + fldt 48(%esp) + addl $32, %esp +..B2.18: + fldt 32(%esp) + fmulp %st, %st(1) + fldt 76(%esp) + fmulp %st, %st(2) + fsub %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt _val_0_03L@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B2.20 + jp ..B2.20 +..B2.19: + fstp %st(1) + fldt _tonpi@GOTOFF(%ebx) + fldt (%esp) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + fstpt 16(%esp) + jmp ..B2.22 +..B2.20: + fstp %st(0) + addl $-16, %esp + lea 16(%esp), %esi + movl %esi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B2.36: + addl $-16, %esp + movl (%esi), %ecx + lea 48(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%esi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%esi), %ecx + movl 12(%esi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __j0q@PLT +..B2.35: + addl $28, %esp +..B2.21: + movl 16(%esp), %eax + movl %eax, (%esi) + movl 20(%esp), %edx + movl 24(%esp), %ecx + movl 28(%esp), %eax + addl $-16, %esp + movl %edx, 4(%esi) + movl %ecx, 8(%esi) + movl %eax, 12(%esi) + movl %esi, (%esp) + call __qtol@PLT +..B2.37: + fstpt 32(%esp) + addl $16, %esp +..B2.22: + testl %edi, %edi + je ..B2.24 +..B2.23: + fldcw 46(%esp) +..B2.24: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.25: + fldl 8(%ebp) + fabs + fsubrl _ones@GOTOFF(%ebx) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.26: + andl $-2146435073, %eax + orl 8(%ebp), %eax + je ..B2.28 +..B2.27: + fldl _ones@GOTOFF(%ebx) + fmull 8(%ebp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.28: + fldl _zeros@GOTOFF(%ebx) +..B2.29: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.31: + xorl %edi, %edi + jmp ..B2.9 + .align 16,0x90 + .type j0,@function + .size j0,.-j0 + .data +# -- End j0 + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_S: + .word 17728 + .word 31608 + .word 43949 + .word 62778 + .word 16384 + .word 0 + .word 32551 + .word 41874 + .word 44957 + .word 57471 + .word 16385 + .word 0 + .word 18949 + .word 61409 + .word 34437 + .word 41670 + .word 16386 + .word 0 + .word 4396 + .word 34605 + .word 55192 + .word 54573 + .word 16386 + .word 0 + .word 9307 + .word 10310 + .word 55728 + .word 33731 + .word 16387 + .word 0 + .word 7613 + .word 2917 + .word 18234 + .word 40173 + .word 16387 + .word 0 + .word 24292 + .word 42693 + .word 42782 + .word 46612 + .word 16387 + .word 0 + .word 12570 + .word 29960 + .word 47214 + .word 53050 + .word 16387 + .word 0 + .word 24415 + .word 36838 + .word 59299 + .word 59487 + .word 16387 + .word 0 + .word 32322 + .word 22879 + .word 15219 + .word 32962 + .word 16388 + .word 0 + .word 56404 + .word 12107 + .word 18542 + .word 36180 + .word 16388 + .word 0 + .word 18639 + .word 44635 + .word 10526 + .word 39398 + .word 16388 + .word 0 + .type _S,@object + .size _S,144 + .align 2 +_Z: + .word 64993 + .word 47321 + .word 43380 + .word 39400 + .word 16384 + .word 0 + .word 10427 + .word 24946 + .word 31449 + .word 45220 + .word 16385 + .word 0 + .word 20142 + .word 26358 + .word 43878 + .word 35445 + .word 16386 + .word 0 + .word 45380 + .word 5013 + .word 8196 + .word 48298 + .word 16386 + .word 0 + .word 36049 + .word 37774 + .word 2551 + .word 61157 + .word 16386 + .word 0 + .word 44499 + .word 20687 + .word 35324 + .word 37009 + .word 16387 + .word 0 + .word 37149 + .word 40892 + .word 28299 + .word 43441 + .word 16387 + .word 0 + .word 59921 + .word 2742 + .word 56472 + .word 49873 + .word 16387 + .word 0 + .word 35749 + .word 60152 + .word 42287 + .word 56306 + .word 16387 + .word 0 + .word 36553 + .word 24054 + .word 44174 + .word 62739 + .word 16387 + .word 0 + .word 12707 + .word 13183 + .word 28829 + .word 34586 + .word 16388 + .word 0 + .word 24309 + .word 45263 + .word 7124 + .word 37803 + .word 16388 + .word 0 + .type _Z,@object + .size _Z,144 + .align 2 +_P1: + .word 41974 + .word 50359 + .word 55 + .word 49432 + .word 49085 + .word 0 + .word 46729 + .word 24287 + .word 10077 + .word 43682 + .word 16323 + .word 0 + .word 54556 + .word 53463 + .word 26566 + .word 47408 + .word 16327 + .word 0 + .word 61625 + .word 30678 + .word 34691 + .word 56786 + .word 49099 + .word 0 + .word 32205 + .word 55323 + .word 47622 + .word 59679 + .word 49103 + .word 0 + .word 29650 + .word 64976 + .word 4011 + .word 64391 + .word 16339 + .word 0 + .word 31057 + .word 21065 + .word 6935 + .word 59041 + .word 16343 + .word 0 + .word 36662 + .word 39842 + .word 13910 + .word 57058 + .word 49115 + .word 0 + .word 21879 + .word 21964 + .word 7382 + .word 44566 + .word 49119 + .word 0 + .word 35904 + .word 38403 + .word 56995 + .word 38056 + .word 16355 + .word 0 + .word 18301 + .word 44371 + .word 51380 + .word 49148 + .word 16358 + .word 0 + .word 24372 + .word 2933 + .word 6164 + .word 36455 + .word 49130 + .word 0 + .word 49391 + .word 5716 + .word 15337 + .word 37270 + .word 49133 + .word 0 + .word 25965 + .word 16194 + .word 56568 + .word 46953 + .word 16368 + .word 0 + .word 45667 + .word 13925 + .word 5584 + .word 35484 + .word 16371 + .word 0 + .word 49022 + .word 26773 + .word 37576 + .word 36812 + .word 49142 + .word 0 + .word 36832 + .word 53763 + .word 58864 + .word 36312 + .word 49144 + .word 0 + .word 33543 + .word 46187 + .word 17185 + .word 59351 + .word 16378 + .word 0 + .word 40102 + .word 5284 + .word 63312 + .word 56590 + .word 16379 + .word 0 + .word 857 + .word 43156 + .word 55730 + .word 34022 + .word 49150 + .word 0 + .word 52121 + .word 9280 + .word 35775 + .word 47190 + .word 16318 + .word 0 + .type _P1,@object + .size _P1,252 + .align 2 +_P: + .word 25701 + .word 56152 + .word 43593 + .word 44746 + .word 49091 + .word 0 + .word 48832 + .word 40943 + .word 62738 + .word 40407 + .word 49095 + .word 0 + .word 27954 + .word 18691 + .word 56371 + .word 61331 + .word 16331 + .word 0 + .word 59673 + .word 34431 + .word 10026 + .word 51320 + .word 16335 + .word 0 + .word 19628 + .word 6656 + .word 43961 + .word 34852 + .word 49108 + .word 0 + .word 10797 + .word 38877 + .word 18617 + .word 49740 + .word 49111 + .word 0 + .word 55276 + .word 31862 + .word 41256 + .word 61817 + .word 16347 + .word 0 + .word 56169 + .word 58452 + .word 6548 + .word 36482 + .word 16351 + .word 0 + .word 22526 + .word 12680 + .word 38609 + .word 41195 + .word 49123 + .word 0 + .word 35707 + .word 29316 + .word 48923 + .word 38609 + .word 49126 + .word 0 + .word 54924 + .word 17159 + .word 27854 + .word 39283 + .word 16362 + .word 0 + .word 7410 + .word 20104 + .word 60324 + .word 54971 + .word 16364 + .word 0 + .word 42961 + .word 8606 + .word 41997 + .word 49951 + .word 49136 + .word 0 + .word 20439 + .word 51893 + .word 4000 + .word 47026 + .word 49138 + .word 0 + .word 59638 + .word 54459 + .word 36852 + .word 37873 + .word 16374 + .word 0 + .word 53889 + .word 4789 + .word 65352 + .word 38847 + .word 16375 + .word 0 + .word 1714 + .word 3910 + .word 34394 + .word 55562 + .word 49146 + .word 0 + .word 303 + .word 16967 + .word 38717 + .word 64635 + .word 49145 + .word 0 + .word 5713 + .word 19393 + .word 12368 + .word 44599 + .word 16381 + .word 0 + .word 21960 + .word 14969 + .word 53843 + .word 43675 + .word 16319 + .word 0 + .word 52500 + .word 174 + .word 33388 + .word 44907 + .word 16323 + .word 0 + .word 36805 + .word 62602 + .word 43329 + .word 35133 + .word 16327 + .word 0 + .word 27761 + .word 25841 + .word 3607 + .word 63286 + .word 49099 + .word 0 + .word 6612 + .word 54609 + .word 58140 + .word 43860 + .word 49103 + .word 0 + .word 37993 + .word 17870 + .word 56109 + .word 35856 + .word 16340 + .word 0 + .word 61675 + .word 27140 + .word 56422 + .word 41440 + .word 16343 + .word 0 + .word 56971 + .word 52432 + .word 57814 + .word 63191 + .word 49115 + .word 0 + .word 25412 + .word 37118 + .word 3118 + .word 58735 + .word 49118 + .word 0 + .word 38291 + .word 36319 + .word 26004 + .word 41665 + .word 16355 + .word 0 + .word 50251 + .word 22788 + .word 9163 + .word 59245 + .word 16357 + .word 0 + .word 15018 + .word 28 + .word 26139 + .word 39028 + .word 49130 + .word 0 + .word 33331 + .word 48247 + .word 16919 + .word 39314 + .word 49132 + .word 0 + .word 9684 + .word 33609 + .word 24106 + .word 48128 + .word 16368 + .word 0 + .word 51011 + .word 47822 + .word 659 + .word 60363 + .word 16369 + .word 0 + .word 37534 + .word 11575 + .word 45084 + .word 34566 + .word 49142 + .word 0 + .word 45912 + .word 27680 + .word 6912 + .word 42099 + .word 49142 + .word 0 + .word 56715 + .word 12873 + .word 49782 + .word 46172 + .word 16378 + .word 0 + .word 26728 + .word 49648 + .word 65144 + .word 32891 + .word 16377 + .word 0 + .word 40426 + .word 15254 + .word 52157 + .word 35579 + .word 49149 + .word 0 + .word 38384 + .word 45177 + .word 47511 + .word 58357 + .word 16319 + .word 0 + .word 58158 + .word 44133 + .word 45474 + .word 44841 + .word 49091 + .word 0 + .word 25822 + .word 50828 + .word 25446 + .word 60617 + .word 49094 + .word 0 + .word 15324 + .word 12408 + .word 38243 + .word 63699 + .word 16331 + .word 0 + .word 14774 + .word 16677 + .word 5572 + .word 37105 + .word 16335 + .word 0 + .word 22149 + .word 54660 + .word 59654 + .word 35846 + .word 49108 + .word 0 + .word 11697 + .word 52785 + .word 2274 + .word 34156 + .word 49111 + .word 0 + .word 53627 + .word 64285 + .word 10253 + .word 62534 + .word 16347 + .word 0 + .word 24801 + .word 65406 + .word 2005 + .word 46814 + .word 16350 + .word 0 + .word 32190 + .word 19121 + .word 50201 + .word 40636 + .word 49123 + .word 0 + .word 54751 + .word 12899 + .word 38715 + .word 45207 + .word 49125 + .word 0 + .word 43490 + .word 42082 + .word 27556 + .word 37283 + .word 16362 + .word 0 + .word 22028 + .word 56865 + .word 50900 + .word 56715 + .word 16363 + .word 0 + .word 16346 + .word 12991 + .word 64075 + .word 44659 + .word 49136 + .word 0 + .word 52492 + .word 22409 + .word 7105 + .word 40702 + .word 49137 + .word 0 + .word 6702 + .word 59476 + .word 47051 + .word 61808 + .word 16373 + .word 0 + .word 62316 + .word 14189 + .word 19866 + .word 53935 + .word 16373 + .word 0 + .word 9195 + .word 51568 + .word 61124 + .word 40040 + .word 49146 + .word 0 + .word 6439 + .word 11299 + .word 34414 + .word 41343 + .word 49144 + .word 0 + .word 46739 + .word 24947 + .word 62261 + .word 60937 + .word 16380 + .word 0 + .word 58365 + .word 23430 + .word 12962 + .word 38007 + .word 49087 + .word 0 + .word 58251 + .word 41189 + .word 49383 + .word 44339 + .word 16323 + .word 0 + .word 48598 + .word 60621 + .word 33089 + .word 52046 + .word 16326 + .word 0 + .word 15609 + .word 33598 + .word 37151 + .word 63031 + .word 49099 + .word 0 + .word 47302 + .word 16218 + .word 41542 + .word 62539 + .word 49102 + .word 0 + .word 57122 + .word 24762 + .word 37625 + .word 35182 + .word 16340 + .word 0 + .word 14554 + .word 11813 + .word 4690 + .word 56239 + .word 16342 + .word 0 + .word 54525 + .word 1724 + .word 15173 + .word 60713 + .word 49115 + .word 0 + .word 63047 + .word 59633 + .word 16097 + .word 37474 + .word 49118 + .word 0 + .word 47674 + .word 64044 + .word 50935 + .word 38909 + .word 16355 + .word 0 + .word 10733 + .word 57181 + .word 7346 + .word 35019 + .word 16357 + .word 0 + .word 60139 + .word 34186 + .word 61790 + .word 35089 + .word 49130 + .word 0 + .word 42252 + .word 41404 + .word 34184 + .word 42385 + .word 49131 + .word 0 + .word 1522 + .word 6058 + .word 55347 + .word 41209 + .word 16368 + .word 0 + .word 8896 + .word 65510 + .word 60684 + .word 58885 + .word 16368 + .word 0 + .word 5547 + .word 57306 + .word 64532 + .word 55968 + .word 49141 + .word 0 + .word 14723 + .word 16104 + .word 43168 + .word 38160 + .word 49141 + .word 0 + .word 64145 + .word 20360 + .word 50512 + .word 35772 + .word 16378 + .word 0 + .word 36202 + .word 63428 + .word 51591 + .word 58021 + .word 16375 + .word 0 + .word 65464 + .word 45991 + .word 59516 + .word 54144 + .word 49148 + .word 0 + .word 24568 + .word 20436 + .word 61634 + .word 37862 + .word 49086 + .word 0 + .word 45319 + .word 25104 + .word 37206 + .word 43484 + .word 49091 + .word 0 + .word 21849 + .word 55910 + .word 13070 + .word 44688 + .word 49094 + .word 0 + .word 3252 + .word 24429 + .word 41684 + .word 61678 + .word 16331 + .word 0 + .word 18877 + .word 5474 + .word 3532 + .word 52835 + .word 16334 + .word 0 + .word 29000 + .word 47276 + .word 64838 + .word 34154 + .word 49108 + .word 0 + .word 20967 + .word 63980 + .word 13404 + .word 46613 + .word 49110 + .word 0 + .word 52562 + .word 53463 + .word 21966 + .word 58373 + .word 16347 + .word 0 + .word 9777 + .word 2939 + .word 17549 + .word 60815 + .word 16349 + .word 0 + .word 26283 + .word 15936 + .word 57935 + .word 36992 + .word 49123 + .word 0 + .word 53769 + .word 29752 + .word 63351 + .word 55571 + .word 49124 + .word 0 + .word 39733 + .word 64164 + .word 46820 + .word 32952 + .word 16362 + .word 0 + .word 176 + .word 24001 + .word 47175 + .word 32916 + .word 16363 + .word 0 + .word 42514 + .word 53223 + .word 40190 + .word 38228 + .word 49136 + .word 0 + .word 32337 + .word 51109 + .word 43299 + .word 44928 + .word 49136 + .word 0 + .word 59799 + .word 62803 + .word 25577 + .word 51379 + .word 16373 + .word 0 + .word 14970 + .word 20015 + .word 15936 + .word 57562 + .word 16372 + .word 0 + .word 65161 + .word 31438 + .word 7531 + .word 65214 + .word 49145 + .word 0 + .word 20513 + .word 44789 + .word 62889 + .word 43571 + .word 49143 + .word 0 + .word 4307 + .word 19900 + .word 64182 + .word 49211 + .word 16380 + .word 0 + .word 23601 + .word 8473 + .word 7427 + .word 49494 + .word 49087 + .word 0 + .word 7362 + .word 8526 + .word 7254 + .word 42403 + .word 16323 + .word 0 + .word 35188 + .word 37258 + .word 23196 + .word 38516 + .word 16326 + .word 0 + .word 28716 + .word 28394 + .word 59353 + .word 59952 + .word 49099 + .word 0 + .word 5380 + .word 17306 + .word 43095 + .word 44938 + .word 49102 + .word 0 + .word 62603 + .word 29353 + .word 43042 + .word 32969 + .word 16340 + .word 0 + .word 14219 + .word 29360 + .word 8286 + .word 39065 + .word 16342 + .word 0 + .word 51755 + .word 8774 + .word 37073 + .word 55906 + .word 49115 + .word 0 + .word 56892 + .word 44416 + .word 43797 + .word 50190 + .word 49117 + .word 0 + .word 61329 + .word 48733 + .word 6023 + .word 35132 + .word 16355 + .word 0 + .word 7541 + .word 9021 + .word 40244 + .word 45179 + .word 16356 + .word 0 + .word 26533 + .word 29344 + .word 18926 + .word 62060 + .word 49129 + .word 0 + .word 30572 + .word 2598 + .word 8389 + .word 52807 + .word 49130 + .word 0 + .word 51943 + .word 22643 + .word 23287 + .word 35717 + .word 16368 + .word 0 + .word 64388 + .word 35284 + .word 47919 + .word 35658 + .word 16368 + .word 0 + .word 29632 + .word 11036 + .word 42088 + .word 47700 + .word 49141 + .word 0 + .word 31422 + .word 44089 + .word 40511 + .word 45376 + .word 49140 + .word 0 + .word 24082 + .word 23937 + .word 40663 + .word 60291 + .word 16377 + .word 0 + .word 35871 + .word 18767 + .word 59204 + .word 34260 + .word 16375 + .word 0 + .word 55945 + .word 59437 + .word 40276 + .word 45420 + .word 49148 + .word 0 + .word 36087 + .word 44447 + .word 31316 + .word 65259 + .word 16318 + .word 0 + .word 33015 + .word 55199 + .word 13485 + .word 41205 + .word 49091 + .word 0 + .word 28040 + .word 38678 + .word 23200 + .word 33402 + .word 49094 + .word 0 + .word 24126 + .word 8131 + .word 32863 + .word 58069 + .word 16331 + .word 0 + .word 35392 + .word 16287 + .word 64004 + .word 38564 + .word 16334 + .word 0 + .word 24419 + .word 65021 + .word 26451 + .word 63502 + .word 49107 + .word 0 + .word 50428 + .word 39809 + .word 46675 + .word 33151 + .word 49110 + .word 0 + .word 43497 + .word 65182 + .word 62592 + .word 53510 + .word 16347 + .word 0 + .word 13653 + .word 47792 + .word 51483 + .word 42124 + .word 16349 + .word 0 + .word 51670 + .word 53417 + .word 2690 + .word 33418 + .word 49123 + .word 0 + .word 18048 + .word 20017 + .word 2806 + .word 37530 + .word 49124 + .word 0 + .word 28377 + .word 1564 + .word 33730 + .word 58682 + .word 16361 + .word 0 + .word 50365 + .word 41139 + .word 10086 + .word 43478 + .word 16362 + .word 0 + .word 61280 + .word 6173 + .word 58518 + .word 33596 + .word 49136 + .word 0 + .word 37780 + .word 41188 + .word 55897 + .word 58318 + .word 49135 + .word 0 + .word 54954 + .word 62311 + .word 27470 + .word 44684 + .word 16373 + .word 0 + .word 57442 + .word 38159 + .word 64608 + .word 36945 + .word 16372 + .word 0 + .word 24087 + .word 55434 + .word 11948 + .word 56328 + .word 49145 + .word 0 + .word 3958 + .word 29640 + .word 49133 + .word 55700 + .word 49142 + .word 0 + .word 27700 + .word 45302 + .word 5983 + .word 42389 + .word 16380 + .word 0 + .word 40427 + .word 54367 + .word 12482 + .word 37240 + .word 16320 + .word 0 + .word 59852 + .word 29007 + .word 23004 + .word 39969 + .word 16323 + .word 0 + .word 34211 + .word 57602 + .word 36659 + .word 58360 + .word 16325 + .word 0 + .word 44442 + .word 16364 + .word 9911 + .word 56161 + .word 49099 + .word 0 + .word 28102 + .word 25155 + .word 37530 + .word 33414 + .word 49102 + .word 0 + .word 6555 + .word 37232 + .word 8513 + .word 61132 + .word 16339 + .word 0 + .word 19389 + .word 63961 + .word 54328 + .word 56964 + .word 16341 + .word 0 + .word 46901 + .word 14299 + .word 54235 + .word 51269 + .word 49115 + .word 0 + .word 21562 + .word 53008 + .word 37762 + .word 35900 + .word 49117 + .word 0 + .word 39053 + .word 49830 + .word 37166 + .word 63741 + .word 16354 + .word 0 + .word 45681 + .word 41863 + .word 1807 + .word 63504 + .word 16355 + .word 0 + .word 32524 + .word 20075 + .word 31047 + .word 55727 + .word 49129 + .word 0 + .word 19491 + .word 55333 + .word 6932 + .word 36559 + .word 49130 + .word 0 + .word 44244 + .word 33552 + .word 34722 + .word 63577 + .word 16367 + .word 0 + .word 16901 + .word 42071 + .word 41001 + .word 48810 + .word 16367 + .word 0 + .word 62438 + .word 12223 + .word 44142 + .word 42160 + .word 49141 + .word 0 + .word 23223 + .word 6493 + .word 11343 + .word 61664 + .word 49139 + .word 0 + .word 62523 + .word 30008 + .word 29610 + .word 53050 + .word 16377 + .word 0 + .word 14947 + .word 31100 + .word 26993 + .word 46432 + .word 16374 + .word 0 + .word 54892 + .word 55125 + .word 25696 + .word 39893 + .word 49148 + .word 0 + .word 64089 + .word 10154 + .word 50994 + .word 64131 + .word 16319 + .word 0 + .word 25208 + .word 35455 + .word 35497 + .word 38745 + .word 49091 + .word 0 + .word 22601 + .word 23897 + .word 16529 + .word 51375 + .word 49093 + .word 0 + .word 39957 + .word 27913 + .word 24611 + .word 54302 + .word 16331 + .word 0 + .word 45382 + .word 20134 + .word 36574 + .word 58452 + .word 16333 + .word 0 + .word 42298 + .word 30543 + .word 37555 + .word 58890 + .word 49107 + .word 0 + .word 22768 + .word 53677 + .word 2298 + .word 49504 + .word 49109 + .word 0 + .word 58111 + .word 6687 + .word 35097 + .word 49208 + .word 16347 + .word 0 + .word 10603 + .word 28285 + .word 57192 + .word 62022 + .word 16348 + .word 0 + .word 32868 + .word 54034 + .word 283 + .word 60966 + .word 49122 + .word 0 + .word 45349 + .word 58038 + .word 8163 + .word 54564 + .word 49123 + .word 0 + .word 55920 + .word 35455 + .word 60237 + .word 53133 + .word 16361 + .word 0 + .word 60123 + .word 63321 + .word 17152 + .word 62548 + .word 16361 + .word 0 + .word 39317 + .word 30736 + .word 60380 + .word 60458 + .word 49135 + .word 0 + .word 49393 + .word 44945 + .word 51803 + .word 41616 + .word 49135 + .word 0 + .word 20738 + .word 26362 + .word 9659 + .word 40012 + .word 16373 + .word 0 + .word 60223 + .word 27976 + .word 18717 + .word 52467 + .word 16371 + .word 0 + .word 54339 + .word 42843 + .word 18062 + .word 50282 + .word 49145 + .word 0 + .word 34001 + .word 60559 + .word 43103 + .word 39476 + .word 49142 + .word 0 + .word 26526 + .word 28531 + .word 16125 + .word 37792 + .word 16380 + .word 0 + .word 6095 + .word 56607 + .word 38079 + .word 40348 + .word 49087 + .word 0 + .word 15971 + .word 7192 + .word 49983 + .word 37562 + .word 16323 + .word 0 + .word 50443 + .word 47213 + .word 11879 + .word 45566 + .word 16325 + .word 0 + .word 11802 + .word 10368 + .word 62578 + .word 52530 + .word 49099 + .word 0 + .word 31461 + .word 32590 + .word 25910 + .word 51580 + .word 49101 + .word 0 + .word 23034 + .word 4503 + .word 56149 + .word 56800 + .word 16339 + .word 0 + .word 23084 + .word 49532 + .word 8891 + .word 43466 + .word 16341 + .word 0 + .word 52278 + .word 51985 + .word 56128 + .word 47325 + .word 49115 + .word 0 + .word 64046 + .word 3409 + .word 24460 + .word 54209 + .word 49116 + .word 0 + .word 21815 + .word 55080 + .word 59949 + .word 58476 + .word 16354 + .word 0 + .word 52803 + .word 16320 + .word 8321 + .word 47500 + .word 16355 + .word 0 + .word 52718 + .word 62993 + .word 9405 + .word 50844 + .word 49129 + .word 0 + .word 54524 + .word 45491 + .word 53115 + .word 54272 + .word 49129 + .word 0 + .word 17147 + .word 2195 + .word 64554 + .word 57739 + .word 16367 + .word 0 + .word 25716 + .word 30593 + .word 61559 + .word 36022 + .word 16367 + .word 0 + .word 34582 + .word 27844 + .word 9712 + .word 38156 + .word 49141 + .word 0 + .word 11089 + .word 32571 + .word 7121 + .word 45346 + .word 49139 + .word 0 + .word 19256 + .word 10500 + .word 41195 + .word 47904 + .word 16377 + .word 0 + .word 34688 + .word 57357 + .word 16578 + .word 34099 + .word 16374 + .word 0 + .word 33812 + .word 7938 + .word 37351 + .word 35991 + .word 49148 + .word 0 + .word 39461 + .word 41125 + .word 38968 + .word 43650 + .word 16319 + .word 0 + .word 44025 + .word 18687 + .word 5475 + .word 36436 + .word 49091 + .word 0 + .word 23695 + .word 42035 + .word 32968 + .word 40701 + .word 49093 + .word 0 + .word 38927 + .word 50812 + .word 3019 + .word 50863 + .word 16331 + .word 0 + .word 61445 + .word 40975 + .word 17938 + .word 45887 + .word 16333 + .word 0 + .word 29652 + .word 52899 + .word 3582 + .word 54866 + .word 49107 + .word 0 + .word 20058 + .word 59066 + .word 2994 + .word 38517 + .word 49109 + .word 0 + .word 39274 + .word 56137 + .word 36322 + .word 45609 + .word 16347 + .word 0 + .word 15638 + .word 5070 + .word 53701 + .word 47866 + .word 16348 + .word 0 + .word 51166 + .word 27629 + .word 45907 + .word 56238 + .word 49122 + .word 0 + .word 29387 + .word 28474 + .word 13265 + .word 41814 + .word 49123 + .word 0 + .word 6001 + .word 55757 + .word 63641 + .word 48808 + .word 16361 + .word 0 + .word 65207 + .word 5152 + .word 25385 + .word 47657 + .word 16361 + .word 0 + .word 16879 + .word 18288 + .word 49778 + .word 55345 + .word 49135 + .word 0 + .word 63014 + .word 23411 + .word 42365 + .word 63147 + .word 49134 + .word 0 + .word 41060 + .word 50204 + .word 58630 + .word 36532 + .word 16373 + .word 0 + .word 38440 + .word 64136 + .word 63792 + .word 39699 + .word 16371 + .word 0 + .word 22495 + .word 32960 + .word 60573 + .word 45833 + .word 49145 + .word 0 + .word 59007 + .word 19608 + .word 21801 + .word 59681 + .word 49141 + .word 0 + .word 39231 + .word 52779 + .word 63106 + .word 34425 + .word 16380 + .word 0 + .word 40257 + .word 55273 + .word 33242 + .word 51859 + .word 16320 + .word 0 + .type _P,@object + .size _P,2640 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,12 + .align 2 +_PP: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP,@object + .size _PP,120 + .align 2 +_QP: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .type _QP,@object + .size _QP,120 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,12 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .type _tonpi,@object + .size _tonpi,12 + .data + .hidden __libm_sincos_pi4l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/j0f.S b/external/sgx_libm/ia32/j0f.S new file mode 100644 index 0000000000..574ec9509c --- /dev/null +++ b/external/sgx_libm/ia32/j0f.S @@ -0,0 +1,588 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j0f.c" + .text +..TXTST0: +# -- Begin j0f + .text + .align 16,0x90 + .globl j0f +j0f: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %ebx + subl $124, %esp + movl 8(%ebp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + jae ..B1.24 +..B1.2: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $1099154394, %eax + jae ..B1.22 +..B1.3: + cmpl $1081424556, %eax + jae ..B1.14 +..B1.4: + cmpl $1048576000, %eax + jae ..B1.13 +..B1.5: + cmpl $998244352, %eax + jae ..B1.12 +..B1.6: + cmpl $947912704, %eax + jae ..B1.11 +..B1.7: + flds 8(%ebp) + cmpl $838860800, %eax + fld1 + jae ..B1.9 +..B1.8: + fxch %st(1) + fabs + fsubrp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.9: + fxch %st(1) + fmul %st(0), %st + fsubrp %st, %st(1) +..B1.10: + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.11: + flds 8(%ebp) + fmul %st(0), %st + fld1 + fldl 8+_Q3@GOTOFF(%ebx) + fmul %st(2), %st + faddl _Q3@GOTOFF(%ebx) + fmulp %st, %st(2) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.12: + flds 8(%ebp) + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fld1 + fldl 24+_Q2@GOTOFF(%ebx) + fmul %st(2), %st + fldl 16+_Q2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 8+_Q2@GOTOFF(%ebx) + fmulp %st, %st(3) + faddl _Q2@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.13: + flds 8(%ebp) + fabs + fldl 104+_Q1@GOTOFF(%ebx) + fldl 88+_Q1@GOTOFF(%ebx) + fldl 96+_Q1@GOTOFF(%ebx) + fldl 80+_Q1@GOTOFF(%ebx) + fxch %st(4) + fsubl 112+_Q1@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 72+_Q1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 56+_Q1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 40+_Q1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 24+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 64+_Q1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 8+_Q1@GOTOFF(%ebx) + fmulp %st, %st(1) + fxch %st(2) + faddl 32+_Q1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 48+_Q1@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(2) + faddl 16+_Q1@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddl _Q1@GOTOFF(%ebx) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.14: + cmpl $1092798087, %eax + jae ..B1.18 +..B1.15: + cmpl $1088454576, %eax + jae ..B1.17 +..B1.16: + lea _P1@GOTOFF(%ebx), %eax + jmp ..B1.21 +..B1.17: + lea _P2@GOTOFF(%ebx), %eax + jmp ..B1.21 +..B1.18: + cmpl $1096101336, %eax + jae ..B1.20 +..B1.19: + lea _P3@GOTOFF(%ebx), %eax + jmp ..B1.21 +..B1.20: + lea _P4@GOTOFF(%ebx), %eax +..B1.21: + flds 8(%ebp) + fabs + fldl 96(%eax) + fldl 80(%eax) + fldl 88(%eax) + fldl 72(%eax) + fxch %st(4) + fsubl 104(%eax) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 64(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 48(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 32(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 16(%eax) + fmul %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 56(%eax) + fmul %st(4), %st + fxch %st(3) + faddl (%eax) + fxch %st(5) + faddl 40(%eax) + fmulp %st, %st(4) + fxch %st(2) + faddl 24(%eax) + fmulp %st, %st(1) + fmul %st(1), %st + fxch %st(2) + faddl 8(%eax) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.22: + flds 8(%ebp) + lea 32(%esp), %eax + fabs + lea 40(%esp), %edx + fld1 + fdiv %st(1), %st + fstl 16(%eax) + fldl _val_16_0@GOTOFF(%ebx) + fmulp %st, %st(1) + fstl 24(%eax) + fmul %st(0), %st + fstl 32(%eax) + fmul %st(0), %st + fxch %st(1) + fstpl (%esp) + movl %eax, 8(%esp) + movl %edx, 12(%esp) + movl $-1, 16(%esp) + fstpl 40(%eax) + call __libm_sincos_k32 +..B1.23: + fldl 72(%esp) + fldl 64(%esp) + fldl _tonpi@GOTOFF(%ebx) + fmull 48(%esp) + fsqrt + fldl 40+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fldl 32+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 24+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 16+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 8+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl _PP@GOTOFF(%ebx) + faddp %st, %st(1) + fldl 40+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + fmull 40(%esp) + fxch %st(1) + faddl 24+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fldl 32+_QP@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(1) + faddl 8+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + faddl 16+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + faddl _QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmull 56(%esp) + fmull 32(%esp) + fsubrp %st, %st(2) + fmulp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.24: + ja ..B1.26 +..B1.25: + fldz + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.26: + flds 8(%ebp) +..B1.27: + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type j0f,@function + .size j0f,.-j0f + .data +# -- End j0f + .section .rodata, "a" + .align 4 + .align 4 +_Q3: + .long 4294966841 + .long 3218079743 + .long 477219499 + .long 1066401791 + .type _Q3,@object + .size _Q3,16 + .align 4 +_Q2: + .long 4294967005 + .long 3218079743 + .long 4292583532 + .long 1066401791 + .long 2963922746 + .long 3208409541 + .long 1698509326 + .long 1054632110 + .type _Q2,@object + .size _Q2,32 + .align 4 +_Q1: + .long 569392270 + .long 3163659129 + .long 911539783 + .long 3219168475 + .long 3927550863 + .long 1069261278 + .long 1680954783 + .long 1068301032 + .long 3247602706 + .long 3212950300 + .long 1528576945 + .long 3210869138 + .long 2120930432 + .long 1060197251 + .long 3147753376 + .long 1057418557 + .long 3445667889 + .long 3201446637 + .long 160313185 + .long 3198274950 + .long 2157358765 + .long 1047004568 + .long 1405517519 + .long 1043512506 + .long 3055202941 + .long 3187001715 + .long 562966967 + .long 3183555197 + .long 781654848 + .long 1073954069 + .type _Q1,@object + .size _Q1,120 + .align 4 +_P1: + .long 2556390964 + .long 3162487616 + .long 168113101 + .long 1070974694 + .long 3865632959 + .long 3214905202 + .long 3384884860 + .long 3215663440 + .long 3461368592 + .long 1064499199 + .long 2947775703 + .long 1063419441 + .long 1964351934 + .long 3207001659 + .long 1081690493 + .long 3204998104 + .long 2315304668 + .long 1053480462 + .long 3655541446 + .long 1050880364 + .long 988219424 + .long 3194139699 + .long 2647984383 + .long 3191029766 + .long 3459760917 + .long 1038956170 + .long 1529622085 + .long 1075188879 + .type _P1,@object + .size _P1,112 + .align 4 +_P2: + .long 2989381656 + .long 3164006638 + .long 2007135498 + .long 3218169721 + .long 3461465629 + .long 1066405759 + .long 1292000183 + .long 1067879320 + .long 1048188593 + .long 3211038307 + .long 2811900586 + .long 3210797269 + .long 275024305 + .long 1058896216 + .long 2179928921 + .long 1057456107 + .long 2316750355 + .long 3200463196 + .long 1626245786 + .long 3198355713 + .long 2429961783 + .long 1046264853 + .long 3081665457 + .long 1043557342 + .long 3760684269 + .long 3186121773 + .long 1825365706 + .long 1075924661 + .type _P2,@object + .size _P2,112 + .align 4 +_P3: + .long 915277891 + .long 3163740397 + .long 1721892699 + .long 1070448958 + .long 3433548142 + .long 3213111280 + .long 3603643349 + .long 3215166749 + .long 2193444562 + .long 1062884841 + .long 1036402988 + .long 1063136790 + .long 2039602830 + .long 3205750717 + .long 2039806946 + .long 3204828766 + .long 3757243411 + .long 1052487712 + .long 2819184679 + .long 1050816211 + .long 1638789445 + .long 3193302656 + .long 96077275 + .long 3191008024 + .long 34207204 + .long 1038327735 + .long 8549046 + .long 1076335940 + .type _P3,@object + .size _P3,112 + .align 4 +_P4: + .long 4010378302 + .long 3164933090 + .long 260862994 + .long 3217715229 + .long 793353311 + .long 1065112761 + .long 2823013001 + .long 1067546520 + .long 4006575139 + .long 3209863700 + .long 3390737311 + .long 3210433566 + .long 1793352299 + .long 1057800372 + .long 3528876835 + .long 1057234714 + .long 2505438989 + .long 3199512871 + .long 2785865938 + .long 3198229698 + .long 565130724 + .long 1045495083 + .long 410977742 + .long 1043470609 + .long 4266013081 + .long 3185543354 + .long 1056076242 + .long 1076747425 + .type _P4,@object + .size _P4,112 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_PP: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP,@object + .size _PP,48 + .align 4 +_QP: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP,@object + .size _QP,48 + .data + .hidden __libm_sincos_k32 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/j0l.S b/external/sgx_libm/ia32/j0l.S new file mode 100644 index 0000000000..c834714533 --- /dev/null +++ b/external/sgx_libm/ia32/j0l.S @@ -0,0 +1,106 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j0l.c" + .text +..TXTST0: +# -- Begin j0l + .text + .align 16,0x90 + .globl j0l +j0l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $56, %esp + fldt 8(%ebp) + lea 16(%esp), %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.6: + addl $-32, %esp + movl (%edi), %ecx + lea 64(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%edi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __j0q@PLT +..B1.5: + addl $28, %esp +..B1.2: + movl 32(%esp), %eax + movl %eax, (%edi) + movl 36(%esp), %edx + movl 40(%esp), %ecx + movl 44(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B1.7: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type j0l,@function + .size j0l,.-j0l + .data +# -- End j0l + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/j1.S b/external/sgx_libm/ia32/j1.S new file mode 100644 index 0000000000..ebd71cb540 --- /dev/null +++ b/external/sgx_libm/ia32/j1.S @@ -0,0 +1,2716 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j1.c" + .text +..TXTST0: +# -- Begin __j1l + .text + .align 16,0x90 + .hidden __j1l + .globl __j1l +__j1l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %ebx + subl $120, %esp + fldt 8(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fldt 132+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.9 +..B1.2: + fldt _S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.4 +..B1.3: + fldt 12+_P1@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fstpt 88(%esp) + fmul %st, %st(1) + fstpt 76(%esp) + fldt 76(%esp) + fldt _P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 72+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 120+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 132+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 144+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 156+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 168+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 180+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 192+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 204+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt 216+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.4: + movl $1, %edx +..B1.5: + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %esi + fldt _S@GOTOFF(%ebx,%esi) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.8 + jp ..B1.8 +..B1.6: + incl %edx + cmpl $11, %edx + jl ..B1.5 +..B1.8: + lea -8(,%edx,8), %ecx + lea -1(%edx), %eax + movl %eax, %esi + lea -4(%ecx,%edx,4), %edx + fldt _Z@GOTOFF(%ebx,%edx) + shll $4, %esi + fsubrp %st, %st(1) + subl %eax, %esi + fld %st(0) + shll $4, %esi + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fstpt 88(%esp) + fstpt 76(%esp) + fldt 76(%esp) + fldt _P@GOTOFF(%esi,%ebx) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%esi,%ebx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 168+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 180+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 192+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 204+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 216+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 228+_P@GOTOFF(%esi,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + fldl _ones@GOTOFF(%ebx) + lea 76(%esp), %eax + fdiv %st(1), %st + lea 88(%esp), %edx + fxch %st(1) + fxch %st(1) + fstpt -44(%eax) + fldt -44(%eax) + fxch %st(1) + fstpt (%esp) + fldt _val_36_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 12(%eax) + fldt 12(%eax) + movl %eax, 12(%esp) + movl %edx, 16(%esp) + movl $-3, 20(%esp) + fxch %st(1) + fstpt (%eax) + fldt (%eax) + fldt _PP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _QP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 96+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 108+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt -28(%eax) + fldt 108+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt -12(%eax) + call __libm_sincos_pi4l +..B1.10: + fldt 8(%ebp) + fldt 64(%esp) + fldt 48(%esp) + fldt 88(%esp) + fmulp %st, %st(1) + fldt 76(%esp) + fmulp %st, %st(2) + fsub %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt _val_0_03L@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B1.12 + jp ..B1.12 +..B1.11: + fstp %st(1) + fldt _tonpi@GOTOFF(%ebx) + fldt 32(%esp) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.12: + fstp %st(0) + lea 32(%esp), %esi + movl %esi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.19: + addl $-32, %esp + movl (%esi), %ecx + lea 80(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%esi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%esi), %ecx + movl 12(%esi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __j1q@PLT +..B1.18: + addl $28, %esp +..B1.13: + movl 48(%esp), %eax + movl %eax, (%esi) + movl 52(%esp), %edx + movl 56(%esp), %ecx + movl 60(%esp), %eax + addl $4, %esp + pushl %esi + movl %edx, 4(%esi) + movl %ecx, 8(%esi) + movl %eax, 12(%esi) + call __qtol@PLT +..B1.14: + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __j1l,@function + .size __j1l,.-__j1l + .data +# -- End __j1l + .text +# -- Begin j1 + .text + .align 16,0x90 + .globl j1 +j1: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp +..B2.2: + fnstcw 46(%esp) +..B2.3: + movl 12(%ebp), %edi + movl %edi, %edx + andl $2147483647, %edx + shrl $31, %edi + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + cmpl $2146435072, %edx + jge ..B2.34 +..B2.4: + cmpl $1012924416, %edx + jge ..B2.11 +..B2.5: + cmpl $2097152, %edx + jl ..B2.7 +..B2.6: + fldl 8(%ebp) + fmull .L_2il0floatpacket.0@GOTOFF(%ebx) + fldl .L_2il0floatpacket.1@GOTOFF(%ebx) + fmul %st(1), %st + fldl .L_2il0floatpacket.2@GOTOFF(%ebx) + fmulp %st, %st(2) + fsubp %st, %st(1) + fstpl 88(%esp) + fldl 88(%esp) + fmull .L_2il0floatpacket.3@GOTOFF(%ebx) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.7: + movl 8(%ebp), %eax + orl %eax, %edx + je ..B2.9 +..B2.8: + fldl _small_value_64@GOTOFF(%ebx,%edi,8) + fmull _small_value_64@GOTOFF(%ebx) + fstpl 88(%esp) + fldl 88(%esp) + fldl 8(%ebp) + fmull .L_2il0floatpacket.1@GOTOFF(%ebx) + fsubp %st, %st(1) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.9: + fldl 8(%ebp) +..B2.10: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.11: + movzwl 46(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.39 +..B2.12: + orl $-64768, %edx + movw %dx, 44(%esp) +..B2.13: + fldcw 44(%esp) +..B2.14: + movl $1, %esi +..B2.15: + fldl 8(%ebp) + fabs + fldt 132+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.23 +..B2.16: + fldt _S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.18 +..B2.17: + fldt _P1@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 72(%esp) + fstpt 60(%esp) + fldt 60(%esp) + fldt 12+_P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 72+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 120+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 132+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 144+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 156+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 168+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 180+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 192+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 204+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt 216+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B2.28 +..B2.18: + movl $1, %edx +..B2.19: + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %eax + fldt _S@GOTOFF(%ebx,%eax) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B2.22 + jp ..B2.22 +..B2.20: + incl %edx + cmpl $11, %edx + jl ..B2.19 +..B2.22: + lea -8(,%edx,8), %ecx + lea -1(%edx), %eax + lea -4(%ecx,%edx,4), %edx + movl %eax, %ecx + fldt _Z@GOTOFF(%ebx,%edx) + shll $4, %ecx + fsubrp %st, %st(1) + subl %eax, %ecx + fld %st(0) + shll $4, %ecx + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fstpt 72(%esp) + fstpt 60(%esp) + fldt 60(%esp) + fldt _P@GOTOFF(%ecx,%ebx) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%ecx,%ebx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 168+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 180+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 192+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 204+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 216+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 228+_P@GOTOFF(%ecx,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B2.28 +..B2.23: + fldl _ones@GOTOFF(%ebx) + fdiv %st(1), %st + fstpt (%esp) + fldt (%esp) + fldt _val_36_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 72(%esp) + fldt 72(%esp) + fxch %st(1) + fstpt 60(%esp) + fldt 60(%esp) + addl $-32, %esp + lea 92(%esp), %eax + lea 104(%esp), %edx + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fldt _PP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP@GOTOFF(%ebx) + movl %eax, 12(%esp) + faddp %st, %st(1) + fmul %st(2), %st + fldt _QP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP@GOTOFF(%ebx) + movl %edx, 16(%esp) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_PP@GOTOFF(%ebx) + movl $-3, 20(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fstpt -12(%eax) + fldt 24+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 108+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt -44(%eax) + fldt 108+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -28(%eax) + call __libm_sincos_pi4l +..B2.42: + fldt 80(%esp) + fldt 64(%esp) + fldt 48(%esp) + addl $32, %esp +..B2.24: + fldt 72(%esp) + fmulp %st, %st(1) + fldt 60(%esp) + fmulp %st, %st(2) + fsub %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt _val_0_03L@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B2.26 + jp ..B2.26 +..B2.25: + fstp %st(1) + fldt _tonpi@GOTOFF(%ebx) + fldt (%esp) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + fstpt 16(%esp) + jmp ..B2.28 +..B2.26: + fstp %st(0) + addl $-16, %esp + lea 16(%esp), %edx + movl %edx, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B2.44: + lea 16(%esp), %edx + addl $-16, %esp + lea 48(%esp), %ecx + movl %ecx, (%esp) + lea 16(%esp), %eax + movl (%edx), %ecx + movl %ecx, (%eax) + movl 4(%edx), %ecx + movl %ecx, 4(%eax) + movl 8(%edx), %ecx + movl %ecx, 8(%eax) + movl 12(%edx), %ecx + movl %ecx, 12(%eax) + call __j1q@PLT +..B2.43: + lea 28(%esp), %edx + addl $28, %esp +..B2.27: + movl 16(%esp), %eax + movl 20(%esp), %ecx + movl %eax, (%edx) + movl %ecx, 4(%edx) + movl 24(%esp), %eax + movl 28(%esp), %ecx + addl $-16, %esp + movl %eax, 8(%edx) + movl %ecx, 12(%edx) + movl %edx, (%esp) + call __qtol@PLT +..B2.45: + fstpt 32(%esp) + addl $16, %esp +..B2.28: + testl %esi, %esi + je ..B2.30 +..B2.29: + fldcw 46(%esp) +..B2.30: + testl %edi, %edi + je ..B2.33 +..B2.31: + fldt 16(%esp) + fchs + fstpt 16(%esp) +..B2.33: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.34: + andl $-2146435073, %edx + orl 8(%ebp), %edx + je ..B2.36 +..B2.35: + fldl _ones@GOTOFF(%ebx) + fmull 8(%ebp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.36: + fldl _zeros@GOTOFF(%ebx,%edi,8) +..B2.37: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.39: + xorl %esi, %esi + jmp ..B2.15 + .align 16,0x90 + .type j1,@function + .size j1,.-j1 + .data +# -- End j1 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x43b00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3c700000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x3c300000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_S: + .word 64993 + .word 47321 + .word 43380 + .word 39400 + .word 16384 + .word 0 + .word 10427 + .word 24946 + .word 31449 + .word 45220 + .word 16385 + .word 0 + .word 20142 + .word 26358 + .word 43878 + .word 35445 + .word 16386 + .word 0 + .word 45380 + .word 5013 + .word 8196 + .word 48298 + .word 16386 + .word 0 + .word 36049 + .word 37774 + .word 2551 + .word 61157 + .word 16386 + .word 0 + .word 44499 + .word 20687 + .word 35324 + .word 37009 + .word 16387 + .word 0 + .word 37149 + .word 40892 + .word 28299 + .word 43441 + .word 16387 + .word 0 + .word 59921 + .word 2742 + .word 56472 + .word 49873 + .word 16387 + .word 0 + .word 35749 + .word 60152 + .word 42287 + .word 56306 + .word 16387 + .word 0 + .word 36553 + .word 24054 + .word 44174 + .word 62739 + .word 16387 + .word 0 + .word 12707 + .word 13183 + .word 28829 + .word 34586 + .word 16388 + .word 0 + .word 24309 + .word 45263 + .word 7124 + .word 37803 + .word 16388 + .word 0 + .type _S,@object + .size _S,144 + .align 2 +_P1: + .word 26041 + .word 45178 + .word 34801 + .word 41495 + .word 49090 + .word 0 + .word 65370 + .word 9956 + .word 39004 + .word 61276 + .word 49094 + .word 0 + .word 9622 + .word 32383 + .word 51277 + .word 45692 + .word 16332 + .word 0 + .word 53955 + .word 64596 + .word 5222 + .word 35592 + .word 49100 + .word 0 + .word 34986 + .word 10535 + .word 24469 + .word 42796 + .word 49108 + .word 0 + .word 2569 + .word 3934 + .word 58827 + .word 40937 + .word 49103 + .word 0 + .word 16535 + .word 14264 + .word 30755 + .word 37884 + .word 16348 + .word 0 + .word 39497 + .word 52694 + .word 37205 + .word 63078 + .word 49104 + .word 0 + .word 50010 + .word 60332 + .word 8210 + .word 49710 + .word 49123 + .word 0 + .word 10498 + .word 63852 + .word 64151 + .word 35274 + .word 49105 + .word 0 + .word 55591 + .word 43795 + .word 24807 + .word 46603 + .word 16362 + .word 0 + .word 15642 + .word 32907 + .word 52420 + .word 55914 + .word 49103 + .word 0 + .word 53151 + .word 24867 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 37497 + .word 10412 + .word 6022 + .word 55715 + .word 49100 + .word 0 + .word 14397 + .word 43702 + .word 43690 + .word 43690 + .word 16374 + .word 0 + .word 57427 + .word 55015 + .word 8445 + .word 53508 + .word 49095 + .word 0 + .word 64958 + .word 65535 + .word 65535 + .word 65535 + .word 49146 + .word 0 + .word 64696 + .word 39566 + .word 31598 + .word 54025 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .type _P1,@object + .size _P1,228 + .align 2 +_Z: + .word 17728 + .word 31608 + .word 43949 + .word 62778 + .word 16384 + .word 0 + .word 32551 + .word 41874 + .word 44957 + .word 57471 + .word 16385 + .word 0 + .word 18949 + .word 61409 + .word 34437 + .word 41670 + .word 16386 + .word 0 + .word 4396 + .word 34605 + .word 55192 + .word 54573 + .word 16386 + .word 0 + .word 9307 + .word 10310 + .word 55728 + .word 33731 + .word 16387 + .word 0 + .word 7613 + .word 2917 + .word 18234 + .word 40173 + .word 16387 + .word 0 + .word 24292 + .word 42693 + .word 42782 + .word 46612 + .word 16387 + .word 0 + .word 12570 + .word 29960 + .word 47214 + .word 53050 + .word 16387 + .word 0 + .word 24415 + .word 36838 + .word 59299 + .word 59487 + .word 16387 + .word 0 + .word 32322 + .word 22879 + .word 15219 + .word 32962 + .word 16388 + .word 0 + .word 56404 + .word 12107 + .word 18542 + .word 36180 + .word 16388 + .word 0 + .type _Z,@object + .size _Z,132 + .align 2 +_P: + .word 43464 + .word 52019 + .word 16370 + .word 39301 + .word 16323 + .word 0 + .word 45212 + .word 20213 + .word 4367 + .word 36322 + .word 16327 + .word 0 + .word 62182 + .word 43016 + .word 65056 + .word 63104 + .word 49099 + .word 0 + .word 45004 + .word 1793 + .word 2432 + .word 46043 + .word 49103 + .word 0 + .word 10697 + .word 46113 + .word 34013 + .word 35792 + .word 16340 + .word 0 + .word 9065 + .word 41098 + .word 5532 + .word 44900 + .word 16343 + .word 0 + .word 26003 + .word 49876 + .word 4534 + .word 63025 + .word 49115 + .word 0 + .word 42133 + .word 20669 + .word 62629 + .word 33244 + .word 49119 + .word 0 + .word 10663 + .word 14825 + .word 55564 + .word 41652 + .word 16355 + .word 0 + .word 21046 + .word 62601 + .word 18713 + .word 35715 + .word 16358 + .word 0 + .word 28431 + .word 25084 + .word 11881 + .word 39361 + .word 49130 + .word 0 + .word 40049 + .word 63841 + .word 60004 + .word 52172 + .word 49132 + .word 0 + .word 992 + .word 25066 + .word 14104 + .word 49616 + .word 16368 + .word 0 + .word 44948 + .word 43537 + .word 5801 + .word 46886 + .word 16370 + .word 0 + .word 65381 + .word 44162 + .word 41036 + .word 37465 + .word 49142 + .word 0 + .word 14125 + .word 39149 + .word 41569 + .word 43450 + .word 49143 + .word 0 + .word 9425 + .word 2504 + .word 59629 + .word 56004 + .word 16378 + .word 0 + .word 7469 + .word 36200 + .word 7418 + .word 55109 + .word 16378 + .word 0 + .word 63186 + .word 26107 + .word 31425 + .word 52790 + .word 49149 + .word 0 + .word 52143 + .word 25611 + .word 44594 + .word 35227 + .word 49085 + .word 0 + .word 35717 + .word 29166 + .word 20585 + .word 41467 + .word 49091 + .word 0 + .word 2832 + .word 5439 + .word 21266 + .word 33717 + .word 49095 + .word 0 + .word 5378 + .word 24417 + .word 51356 + .word 63335 + .word 16331 + .word 0 + .word 48412 + .word 30659 + .word 29190 + .word 42335 + .word 16335 + .word 0 + .word 9054 + .word 19776 + .word 30431 + .word 35870 + .word 49108 + .word 0 + .word 1836 + .word 17934 + .word 4966 + .word 40411 + .word 49111 + .word 0 + .word 4836 + .word 40500 + .word 17629 + .word 63063 + .word 16347 + .word 0 + .word 23076 + .word 41820 + .word 25860 + .word 58134 + .word 16350 + .word 0 + .word 39832 + .word 57656 + .word 52920 + .word 41521 + .word 49123 + .word 0 + .word 22342 + .word 1014 + .word 59094 + .word 59974 + .word 49125 + .word 0 + .word 25371 + .word 16474 + .word 28775 + .word 38931 + .word 16362 + .word 0 + .word 48127 + .word 54624 + .word 55306 + .word 41258 + .word 16364 + .word 0 + .word 60537 + .word 50282 + .word 14991 + .word 48309 + .word 49136 + .word 0 + .word 15691 + .word 57338 + .word 50654 + .word 33690 + .word 49138 + .word 0 + .word 40468 + .word 19472 + .word 58347 + .word 35325 + .word 16374 + .word 0 + .word 2985 + .word 7922 + .word 38039 + .word 52517 + .word 16374 + .word 0 + .word 33464 + .word 30509 + .word 7663 + .word 49252 + .word 49146 + .word 0 + .word 63790 + .word 6933 + .word 28208 + .word 44856 + .word 49145 + .word 0 + .word 21342 + .word 14964 + .word 50588 + .word 39336 + .word 16381 + .word 0 + .word 56226 + .word 19816 + .word 23757 + .word 47758 + .word 16316 + .word 0 + .word 41064 + .word 34118 + .word 40187 + .word 42472 + .word 16323 + .word 0 + .word 9004 + .word 37522 + .word 42571 + .word 60097 + .word 16326 + .word 0 + .word 40290 + .word 31235 + .word 60424 + .word 63498 + .word 49099 + .word 0 + .word 59943 + .word 36153 + .word 34778 + .word 37099 + .word 49103 + .word 0 + .word 23867 + .word 38881 + .word 17085 + .word 35787 + .word 16340 + .word 0 + .word 43845 + .word 22338 + .word 8742 + .word 34578 + .word 16343 + .word 0 + .word 21920 + .word 9728 + .word 29300 + .word 62498 + .word 49115 + .word 0 + .word 43241 + .word 30911 + .word 50314 + .word 48209 + .word 49118 + .word 0 + .word 5869 + .word 26658 + .word 63775 + .word 40733 + .word 16355 + .word 0 + .word 50245 + .word 25343 + .word 31579 + .word 47683 + .word 16357 + .word 0 + .word 51932 + .word 37189 + .word 37317 + .word 37600 + .word 49130 + .word 0 + .word 35305 + .word 45319 + .word 11991 + .word 61881 + .word 49131 + .word 0 + .word 43727 + .word 7380 + .word 41898 + .word 45538 + .word 16368 + .word 0 + .word 55996 + .word 31666 + .word 20048 + .word 46502 + .word 16369 + .word 0 + .word 20142 + .word 56563 + .word 4676 + .word 64142 + .word 49141 + .word 0 + .word 42758 + .word 26948 + .word 20336 + .word 64653 + .word 49141 + .word 0 + .word 18102 + .word 54076 + .word 11950 + .word 42374 + .word 16378 + .word 0 + .word 55144 + .word 962 + .word 65430 + .word 51473 + .word 16376 + .word 0 + .word 35076 + .word 30182 + .word 41634 + .word 65458 + .word 49148 + .word 0 + .word 45599 + .word 55541 + .word 39885 + .word 63330 + .word 49086 + .word 0 + .word 11397 + .word 64373 + .word 55097 + .word 42716 + .word 49091 + .word 0 + .word 7278 + .word 1186 + .word 16759 + .word 52647 + .word 49094 + .word 0 + .word 55821 + .word 1941 + .word 7835 + .word 62966 + .word 16331 + .word 0 + .word 43692 + .word 51803 + .word 23893 + .word 63855 + .word 16334 + .word 0 + .word 7306 + .word 740 + .word 42177 + .word 35243 + .word 49108 + .word 0 + .word 20304 + .word 26112 + .word 14593 + .word 58152 + .word 49110 + .word 0 + .word 44429 + .word 26104 + .word 43204 + .word 60999 + .word 16347 + .word 0 + .word 43100 + .word 25366 + .word 26069 + .word 39382 + .word 16350 + .word 0 + .word 53318 + .word 3475 + .word 36258 + .word 39277 + .word 49123 + .word 0 + .word 61289 + .word 34432 + .word 35705 + .word 37567 + .word 49125 + .word 0 + .word 47881 + .word 43207 + .word 60352 + .word 35669 + .word 16362 + .word 0 + .word 3664 + .word 62231 + .word 63343 + .word 46625 + .word 16363 + .word 0 + .word 41733 + .word 11611 + .word 33384 + .word 42291 + .word 49136 + .word 0 + .word 22414 + .word 28668 + .word 61827 + .word 33289 + .word 49137 + .word 0 + .word 39839 + .word 31083 + .word 29085 + .word 58078 + .word 16373 + .word 0 + .word 45039 + .word 64406 + .word 35589 + .word 44277 + .word 16373 + .word 0 + .word 21856 + .word 35851 + .word 11264 + .word 37516 + .word 49146 + .word 0 + .word 38193 + .word 55017 + .word 53611 + .word 34369 + .word 49144 + .word 0 + .word 50065 + .word 40254 + .word 39875 + .word 57241 + .word 16380 + .word 0 + .word 21434 + .word 36257 + .word 28860 + .word 44273 + .word 16318 + .word 0 + .word 24899 + .word 55058 + .word 27384 + .word 42408 + .word 16323 + .word 0 + .word 23952 + .word 61552 + .word 63266 + .word 45785 + .word 16326 + .word 0 + .word 20309 + .word 44505 + .word 41003 + .word 61821 + .word 49099 + .word 0 + .word 9759 + .word 19768 + .word 52219 + .word 54624 + .word 49102 + .word 0 + .word 3188 + .word 41981 + .word 52169 + .word 34347 + .word 16340 + .word 0 + .word 7467 + .word 53297 + .word 24491 + .word 48747 + .word 16342 + .word 0 + .word 26956 + .word 25629 + .word 26154 + .word 58912 + .word 49115 + .word 0 + .word 2746 + .word 62708 + .word 29606 + .word 64476 + .word 49117 + .word 0 + .word 23526 + .word 40632 + .word 17955 + .word 37512 + .word 16355 + .word 0 + .word 58003 + .word 45489 + .word 17648 + .word 59859 + .word 16356 + .word 0 + .word 12684 + .word 55359 + .word 8573 + .word 33616 + .word 49130 + .word 0 + .word 29881 + .word 6055 + .word 26438 + .word 36076 + .word 49131 + .word 0 + .word 37160 + .word 17925 + .word 32887 + .word 39269 + .word 16368 + .word 0 + .word 52986 + .word 52867 + .word 51415 + .word 50108 + .word 16368 + .word 0 + .word 29602 + .word 44157 + .word 62211 + .word 53157 + .word 49141 + .word 0 + .word 14158 + .word 17332 + .word 5318 + .word 65232 + .word 49140 + .word 0 + .word 63939 + .word 33203 + .word 7646 + .word 33955 + .word 16378 + .word 0 + .word 29120 + .word 11480 + .word 39280 + .word 50030 + .word 16375 + .word 0 + .word 42029 + .word 1146 + .word 14309 + .word 51502 + .word 49148 + .word 0 + .word 13934 + .word 45324 + .word 64176 + .word 62054 + .word 49087 + .word 0 + .word 407 + .word 40447 + .word 21497 + .word 41724 + .word 49091 + .word 0 + .word 29047 + .word 47840 + .word 58616 + .word 39773 + .word 49094 + .word 0 + .word 45982 + .word 37340 + .word 60343 + .word 60272 + .word 16331 + .word 0 + .word 61708 + .word 5158 + .word 50916 + .word 46783 + .word 16334 + .word 0 + .word 15241 + .word 33011 + .word 52635 + .word 33255 + .word 49108 + .word 0 + .word 27136 + .word 17183 + .word 21500 + .word 41066 + .word 49110 + .word 0 + .word 41313 + .word 44818 + .word 44575 + .word 56585 + .word 16347 + .word 0 + .word 1149 + .word 8286 + .word 16932 + .word 53342 + .word 16349 + .word 0 + .word 29145 + .word 29789 + .word 51640 + .word 35705 + .word 49123 + .word 0 + .word 48645 + .word 17912 + .word 55357 + .word 48589 + .word 49124 + .word 0 + .word 34105 + .word 33794 + .word 2760 + .word 63371 + .word 16361 + .word 0 + .word 30589 + .word 55184 + .word 63547 + .word 57492 + .word 16362 + .word 0 + .word 36766 + .word 25700 + .word 37915 + .word 36654 + .word 49136 + .word 0 + .word 54115 + .word 65102 + .word 9808 + .word 39287 + .word 49136 + .word 0 + .word 15191 + .word 22168 + .word 7058 + .word 49192 + .word 16373 + .word 0 + .word 21631 + .word 11360 + .word 58072 + .word 50534 + .word 16372 + .word 0 + .word 52725 + .word 34636 + .word 1139 + .word 62446 + .word 49145 + .word 0 + .word 53409 + .word 43718 + .word 34635 + .word 38501 + .word 49143 + .word 0 + .word 21083 + .word 16045 + .word 34961 + .word 47202 + .word 16380 + .word 0 + .word 38780 + .word 63942 + .word 22964 + .word 35475 + .word 16316 + .word 0 + .word 58574 + .word 20162 + .word 19964 + .word 40809 + .word 16323 + .word 0 + .word 36576 + .word 45489 + .word 13327 + .word 34648 + .word 16326 + .word 0 + .word 40869 + .word 46352 + .word 6352 + .word 58511 + .word 49099 + .word 0 + .word 38766 + .word 2767 + .word 13055 + .word 40283 + .word 49102 + .word 0 + .word 11002 + .word 40490 + .word 24288 + .word 64180 + .word 16339 + .word 0 + .word 21330 + .word 2672 + .word 53484 + .word 34906 + .word 16342 + .word 0 + .word 11637 + .word 63948 + .word 58709 + .word 54245 + .word 49115 + .word 0 + .word 16451 + .word 23295 + .word 46139 + .word 44738 + .word 49117 + .word 0 + .word 40013 + .word 16865 + .word 3459 + .word 33992 + .word 16355 + .word 0 + .word 28055 + .word 62424 + .word 59084 + .word 40217 + .word 16356 + .word 0 + .word 37015 + .word 7577 + .word 64481 + .word 59907 + .word 49129 + .word 0 + .word 8219 + .word 9822 + .word 27279 + .word 47011 + .word 49130 + .word 0 + .word 859 + .word 2558 + .word 12826 + .word 34425 + .word 16368 + .word 0 + .word 34289 + .word 12934 + .word 665 + .word 63599 + .word 16367 + .word 0 + .word 15142 + .word 54455 + .word 30227 + .word 45946 + .word 49141 + .word 0 + .word 13599 + .word 50987 + .word 20426 + .word 40603 + .word 49140 + .word 0 + .word 224 + .word 55674 + .word 54991 + .word 58096 + .word 16377 + .word 0 + .word 12803 + .word 33902 + .word 43760 + .word 61618 + .word 16374 + .word 0 + .word 3255 + .word 47153 + .word 28829 + .word 43826 + .word 49148 + .word 0 + .word 57503 + .word 42370 + .word 48259 + .word 34977 + .word 16317 + .word 0 + .word 28464 + .word 31222 + .word 4873 + .word 39771 + .word 49091 + .word 0 + .word 7076 + .word 4355 + .word 19850 + .word 60674 + .word 49093 + .word 0 + .word 58695 + .word 18024 + .word 41082 + .word 56674 + .word 16331 + .word 0 + .word 1100 + .word 13540 + .word 64577 + .word 34943 + .word 16334 + .word 0 + .word 25873 + .word 27686 + .word 11323 + .word 61856 + .word 49107 + .word 0 + .word 12188 + .word 35264 + .word 2250 + .word 59962 + .word 49109 + .word 0 + .word 59387 + .word 26772 + .word 9493 + .word 52010 + .word 16347 + .word 0 + .word 50361 + .word 26279 + .word 61391 + .word 38047 + .word 16349 + .word 0 + .word 40446 + .word 22175 + .word 52931 + .word 64839 + .word 49122 + .word 0 + .word 16288 + .word 22519 + .word 41833 + .word 33884 + .word 49124 + .word 0 + .word 22795 + .word 59507 + .word 36930 + .word 56848 + .word 16361 + .word 0 + .word 9090 + .word 34727 + .word 62738 + .word 39279 + .word 16362 + .word 0 + .word 6548 + .word 61899 + .word 57259 + .word 65037 + .word 49135 + .word 0 + .word 20477 + .word 44577 + .word 947 + .word 52780 + .word 49135 + .word 0 + .word 9901 + .word 21929 + .word 34492 + .word 43241 + .word 16373 + .word 0 + .word 52812 + .word 31464 + .word 11463 + .word 33533 + .word 16372 + .word 0 + .word 16273 + .word 3725 + .word 28705 + .word 54534 + .word 49145 + .word 0 + .word 28551 + .word 65013 + .word 38971 + .word 50753 + .word 49142 + .word 0 + .word 55907 + .word 45101 + .word 33737 + .word 41084 + .word 16380 + .word 0 + .word 43426 + .word 25495 + .word 20291 + .word 49461 + .word 49086 + .word 0 + .word 1975 + .word 51775 + .word 24779 + .word 38683 + .word 16323 + .word 0 + .word 29807 + .word 50650 + .word 32397 + .word 53456 + .word 16325 + .word 0 + .word 5564 + .word 52273 + .word 7778 + .word 54851 + .word 49099 + .word 0 + .word 7750 + .word 4868 + .word 38403 + .word 61120 + .word 49101 + .word 0 + .word 15407 + .word 2698 + .word 46605 + .word 59622 + .word 16339 + .word 0 + .word 137 + .word 48802 + .word 34590 + .word 52040 + .word 16341 + .word 0 + .word 61391 + .word 58349 + .word 18865 + .word 49927 + .word 49115 + .word 0 + .word 11732 + .word 37228 + .word 55154 + .word 32778 + .word 49117 + .word 0 + .word 21770 + .word 7395 + .word 32621 + .word 61994 + .word 16354 + .word 0 + .word 14091 + .word 47411 + .word 37523 + .word 57988 + .word 16355 + .word 0 + .word 50358 + .word 51525 + .word 37270 + .word 54151 + .word 49129 + .word 0 + .word 22903 + .word 22329 + .word 47941 + .word 33412 + .word 49130 + .word 0 + .word 47512 + .word 65334 + .word 39843 + .word 61750 + .word 16367 + .word 0 + .word 35590 + .word 32984 + .word 45077 + .word 44683 + .word 16367 + .word 0 + .word 56839 + .word 21073 + .word 60125 + .word 40948 + .word 49141 + .word 0 + .word 16525 + .word 17598 + .word 3587 + .word 56588 + .word 49139 + .word 0 + .word 56933 + .word 2767 + .word 44815 + .word 51549 + .word 16377 + .word 0 + .word 35966 + .word 59943 + .word 1117 + .word 42745 + .word 16374 + .word 0 + .word 40172 + .word 7271 + .word 14707 + .word 38800 + .word 49148 + .word 0 + .word 8476 + .word 4419 + .word 45780 + .word 62512 + .word 49087 + .word 0 + .word 49137 + .word 16671 + .word 19871 + .word 37593 + .word 49091 + .word 0 + .word 63934 + .word 59521 + .word 24158 + .word 47409 + .word 49093 + .word 0 + .word 31258 + .word 33926 + .word 28141 + .word 53090 + .word 16331 + .word 0 + .word 17384 + .word 36966 + .word 994 + .word 53889 + .word 16333 + .word 0 + .word 55527 + .word 7910 + .word 53076 + .word 57518 + .word 49107 + .word 0 + .word 18447 + .word 54969 + .word 49626 + .word 45611 + .word 49109 + .word 0 + .word 13282 + .word 62682 + .word 5627 + .word 48010 + .word 16347 + .word 0 + .word 7550 + .word 10759 + .word 6881 + .word 57138 + .word 16348 + .word 0 + .word 65344 + .word 23540 + .word 39388 + .word 59430 + .word 49122 + .word 0 + .word 2956 + .word 21512 + .word 45255 + .word 50285 + .word 49123 + .word 0 + .word 29054 + .word 47408 + .word 36565 + .word 51766 + .word 16361 + .word 0 + .word 19154 + .word 63758 + .word 53467 + .word 57697 + .word 16361 + .word 0 + .word 22082 + .word 2480 + .word 53967 + .word 58888 + .word 49135 + .word 0 + .word 52243 + .word 32283 + .word 44909 + .word 38447 + .word 49135 + .word 0 + .word 7267 + .word 45206 + .word 61308 + .word 38976 + .word 16373 + .word 0 + .word 10717 + .word 24270 + .word 52189 + .word 48572 + .word 16371 + .word 0 + .word 40118 + .word 3643 + .word 65534 + .word 49002 + .word 49145 + .word 0 + .word 44194 + .word 5661 + .word 50617 + .word 36641 + .word 49142 + .word 0 + .word 26911 + .word 20494 + .word 63331 + .word 36858 + .word 16380 + .word 0 + .word 20013 + .word 62028 + .word 17108 + .word 33468 + .word 16320 + .word 0 + .word 9949 + .word 25572 + .word 4049 + .word 36529 + .word 16323 + .word 0 + .word 39945 + .word 24442 + .word 45585 + .word 42322 + .word 16325 + .word 0 + .word 59756 + .word 52868 + .word 48949 + .word 51417 + .word 49099 + .word 0 + .word 35066 + .word 41141 + .word 44695 + .word 47881 + .word 49101 + .word 0 + .word 42453 + .word 21162 + .word 44569 + .word 55557 + .word 16339 + .word 0 + .word 30136 + .word 39390 + .word 37319 + .word 40338 + .word 16341 + .word 0 + .word 60101 + .word 48639 + .word 6972 + .word 46254 + .word 49115 + .word 0 + .word 56660 + .word 41165 + .word 63413 + .word 50313 + .word 49116 + .word 0 + .word 13109 + .word 12767 + .word 29074 + .word 57119 + .word 16354 + .word 0 + .word 2453 + .word 26502 + .word 15952 + .word 44109 + .word 16355 + .word 0 + .word 44844 + .word 50072 + .word 22431 + .word 49646 + .word 49129 + .word 0 + .word 33416 + .word 16999 + .word 40271 + .word 50445 + .word 49129 + .word 0 + .word 26560 + .word 32264 + .word 54945 + .word 56373 + .word 16367 + .word 0 + .word 58100 + .word 55846 + .word 35515 + .word 33528 + .word 16367 + .word 0 + .word 44190 + .word 42353 + .word 4741 + .word 37259 + .word 49141 + .word 0 + .word 47772 + .word 5308 + .word 50468 + .word 42281 + .word 49139 + .word 0 + .word 53822 + .word 6159 + .word 32580 + .word 46797 + .word 16377 + .word 0 + .word 5509 + .word 51700 + .word 62457 + .word 63728 + .word 16373 + .word 0 + .word 52274 + .word 35926 + .word 43999 + .word 35182 + .word 49148 + .word 0 + .word 33647 + .word 41025 + .word 45844 + .word 37383 + .word 16317 + .word 0 + .type _P,@object + .size _P,2640 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,12 + .align 2 +_PP: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP,@object + .size _PP,120 + .align 2 +_QP: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .type _QP,@object + .size _QP,120 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,12 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .type _tonpi,@object + .size _tonpi,12 + .data + .hidden __libm_sincos_pi4l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/j1f.S b/external/sgx_libm/ia32/j1f.S new file mode 100644 index 0000000000..dec0258eb9 --- /dev/null +++ b/external/sgx_libm/ia32/j1f.S @@ -0,0 +1,695 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j1f.c" + .text +..TXTST0: +# -- Begin j1f + .text + .align 16,0x90 + .globl j1f +j1f: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %ebx + subl $120, %esp + movl 8(%ebp), %esi + movl %esi, %eax + andl $2147483647, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2139095040, %eax + jae ..B1.37 +..B1.2: + cmpl $1099993482, %eax + jae ..B1.32 +..B1.3: + cmpl $1075439785, %eax + jae ..B1.19 +..B1.4: + cmpl $1048576000, %eax + jae ..B1.15 +..B1.5: + cmpl $998244352, %eax + jae ..B1.14 +..B1.6: + cmpl $838860800, %eax + jae ..B1.13 +..B1.7: + shrl $31, %esi + cmpl $16777216, %eax + jb ..B1.9 +..B1.8: + flds 8(%ebp) + fmuls .L_2il0floatpacket.1@GOTOFF(%ebx) + flds .L_2il0floatpacket.0@GOTOFF(%ebx) + fmul %st(1), %st + fldl .L_2il0floatpacket.2@GOTOFF(%ebx) + fmulp %st, %st(2) + fsubp %st, %st(1) + fstps 32(%esp) + flds 32(%esp) + fmuls .L_2il0floatpacket.3@GOTOFF(%ebx) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + testl %eax, %eax + je ..B1.11 +..B1.10: + flds _small_value_32@GOTOFF(%ebx,%esi,4) + fmuls .L_2il0floatpacket.4@GOTOFF(%ebx) + fsts 32(%esp) + flds 8(%ebp) + fmuls .L_2il0floatpacket.0@GOTOFF(%ebx) + fsubp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + flds 8(%ebp) +..B1.12: + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + flds 8(%ebp) + fmuls .L_2il0floatpacket.0@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fldl 8+_Q2@GOTOFF(%ebx) + fmul %st(1), %st + faddl _Q2@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + flds 8(%ebp) + fmuls .L_2il0floatpacket.0@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldl 24+_Q2@GOTOFF(%ebx) + fmul %st(1), %st + fldl 16+_Q2@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 8+_Q2@GOTOFF(%ebx) + fmulp %st, %st(2) + faddl _Q2@GOTOFF(%ebx) + fmulp %st, %st(2) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + flds 8(%ebp) + testl $-2147483648, %esi + fabs + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldl 88+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + fldl 72+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 56+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 40+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 24+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 8+_Q1@GOTOFF(%ebx) + fmul %st(3), %st + faddp %st, %st(1) + fldl 64+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fldl 80+_Q1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 32+_Q1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 48+_Q1@GOTOFF(%ebx) + fmulp %st, %st(3) + faddl _Q1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl 16+_Q1@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + je ..B1.18 +..B1.16: + fchs +..B1.18: + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + flds 8(%ebp) + andl $-2147483648, %esi + fabs + cmpl $1097786634, %eax + jae ..B1.27 +..B1.20: + cmpl $1091204523, %eax + jae ..B1.24 +..B1.21: + cmpl $1085318267, %eax + jae ..B1.23 +..B1.22: + lea _P1@GOTOFF(%ebx), %eax + jmp ..B1.28 +..B1.23: + lea _P2@GOTOFF(%ebx), %eax + jmp ..B1.28 +..B1.24: + cmpl $1094494752, %eax + jae ..B1.26 +..B1.25: + lea _P3@GOTOFF(%ebx), %eax + jmp ..B1.28 +..B1.26: + lea _P4@GOTOFF(%ebx), %eax + jmp ..B1.28 +..B1.27: + lea _P5@GOTOFF(%ebx), %eax +..B1.28: + fldl 104(%eax) + testl %esi, %esi + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldl 96(%eax) + fmul %st(1), %st + fldl 80(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 64(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 48(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 32(%eax) + fmul %st(2), %st + fxch %st(1) + faddl 16(%eax) + fmul %st(3), %st + faddp %st, %st(1) + fldl 72(%eax) + fmul %st(2), %st + fxch %st(1) + faddl (%eax) + fxch %st(1) + faddl 40(%eax) + fmul %st(2), %st + fldl 88(%eax) + fmul %st(3), %st + fxch %st(1) + faddl 8(%eax) + fmul %st(5), %st + fxch %st(1) + faddl 56(%eax) + fmulp %st, %st(3) + fxch %st(2) + faddl 24(%eax) + fmulp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + je ..B1.31 +..B1.29: + fchs +..B1.31: + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + flds 8(%ebp) + lea 40(%esp), %eax + fabs + lea 48(%esp), %edx + fld1 + fdiv %st(1), %st + andl $-2147483648, %esi + fstl 16(%eax) + fldl _val_16_0@GOTOFF(%ebx) + fmulp %st, %st(1) + fstl 24(%eax) + fmul %st(0), %st + fstl 32(%eax) + fmul %st(0), %st + fxch %st(1) + fstpl (%esp) + movl %eax, 8(%esp) + movl %edx, 12(%esp) + movl $-3, 16(%esp) + fstpl 40(%eax) + call __libm_sincos_k32 +..B1.33: + fldl 80(%esp) + testl %esi, %esi + fldl 72(%esp) + fldl _tonpi@GOTOFF(%ebx) + fmull 56(%esp) + fsqrt + fldl 40+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fldl 32+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 24+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 16+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 8+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl _PP@GOTOFF(%ebx) + faddp %st, %st(1) + fldl 40+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + fmull 48(%esp) + fxch %st(1) + faddl 24+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fldl 32+_QP@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(1) + faddl 8+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + faddl 16+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + faddl _QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmull 64(%esp) + fmull 40(%esp) + fsubrp %st, %st(2) + fmulp %st, %st(1) + je ..B1.36 +..B1.34: + fchs +..B1.36: + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.37: + ja ..B1.39 +..B1.38: + shrl $31, %esi + flds _zeros@GOTOFF(%ebx,%esi,4) + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + flds 8(%ebp) +..B1.40: + addl $120, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type j1f,@function + .size j1f,.-j1f + .data +# -- End j1f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3e500000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x3f000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4d800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x31800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +.L_2il0floatpacket.4: + .long 0x0d800000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_Q2: + .long 4294942533 + .long 3219128319 + .long 1380922587 + .long 1068848469 + .long 4229217063 + .long 3212603831 + .long 2485211372 + .long 1060546867 + .type _Q2,@object + .size _Q2,32 + .align 4 +_Q1: + .long 4294875887 + .long 1071644671 + .long 4170968197 + .long 1038133990 + .long 82133904 + .long 3215982592 + .long 2332230043 + .long 1043853917 + .long 2564340116 + .long 1063605580 + .long 220691470 + .long 1046506888 + .long 254563561 + .long 3205265147 + .long 694808779 + .long 1046622203 + .long 4019568744 + .long 1051070668 + .long 1556554770 + .long 1044540217 + .long 1786312313 + .long 3191946521 + .long 1750363188 + .long 1039907362 + .type _Q1,@object + .size _Q1,96 + .align 4 +_P1: + .long 3288017007 + .long 3163666881 + .long 1479173198 + .long 3218720463 + .long 2681037136 + .long 1068165283 + .long 482223942 + .long 1068193949 + .long 1641242500 + .long 3212130132 + .long 3602486439 + .long 3210890035 + .long 1295520927 + .long 1059513544 + .long 2893642677 + .long 1057503730 + .long 2144568350 + .long 3200875225 + .long 914896231 + .long 3198366754 + .long 1774974526 + .long 1046581392 + .long 3090631217 + .long 1043566169 + .long 3310618599 + .long 3186783429 + .long 1974431497 + .long 1074702165 + .type _P1,@object + .size _P1,112 + .align 4 +_P2: + .long 216484910 + .long 1015040375 + .long 3011708428 + .long 1070806296 + .long 3332724636 + .long 3214272269 + .long 3160644008 + .long 3215461507 + .long 2925435221 + .long 1063888050 + .long 725350898 + .long 1063337916 + .long 297499451 + .long 3206574940 + .long 3278099830 + .long 3204945545 + .long 2222993240 + .long 1053042193 + .long 2059286351 + .long 1050869046 + .long 306569625 + .long 3193793299 + .long 95256688 + .long 3191038309 + .long 616794992 + .long 1039029534 + .long 4088689232 + .long 1075580917 + .type _P2,@object + .size _P2,112 + .align 4 +_P3: + .long 1314465059 + .long 1017127215 + .long 1413823668 + .long 3218077268 + .long 4087546795 + .long 1065951807 + .long 3559351807 + .long 1067757765 + .long 338531188 + .long 3210711466 + .long 2516776276 + .long 3210695105 + .long 1548953411 + .long 1058452686 + .long 3819184955 + .long 1057373236 + .long 1262833741 + .long 3200137243 + .long 325214128 + .long 3198310046 + .long 1253465703 + .long 1045913252 + .long 3453826356 + .long 1043528319 + .long 2667154656 + .long 3186140571 + .long 3502111785 + .long 1076123856 + .type _P3,@object + .size _P3,112 + .align 4 +_P4: + .long 1657852450 + .long 3163577804 + .long 2020212262 + .long 1070330675 + .long 774106997 + .long 3212888122 + .long 2119717923 + .long 3215085957 + .long 2098754573 + .long 1062575793 + .long 2137093530 + .long 1063017421 + .long 2437037263 + .long 3205513537 + .long 2698759453 + .long 3204752976 + .long 1998212634 + .long 1052165362 + .long 2817762251 + .long 1050764623 + .long 357372240 + .long 3193071576 + .long 3891599306 + .long 3190966182 + .long 2865549426 + .long 1038348895 + .long 4077970850 + .long 1076536762 + .type _P4,@object + .size _P4,112 + .align 4 +_P5: + .long 1537387514 + .long 3166104464 + .long 4237757176 + .long 3217630662 + .long 789391682 + .long 1064857043 + .long 3122547501 + .long 1067488355 + .long 3303098147 + .long 3209681410 + .long 2944525948 + .long 3210343613 + .long 1468487066 + .long 1057519518 + .long 285546763 + .long 1057172625 + .long 830693909 + .long 3199311383 + .long 1284260698 + .long 3198182585 + .long 1823688212 + .long 1045254801 + .long 1962790020 + .long 1043427779 + .long 1867031598 + .long 3185590079 + .long 906299589 + .long 1076918395 + .type _P5,@object + .size _P5,112 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_PP: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP,@object + .size _PP,48 + .align 4 +_QP: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP,@object + .size _QP,48 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .data + .hidden __libm_sincos_k32 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/j1l.S b/external/sgx_libm/ia32/j1l.S new file mode 100644 index 0000000000..5c7f1c4c13 --- /dev/null +++ b/external/sgx_libm/ia32/j1l.S @@ -0,0 +1,106 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j1l.c" + .text +..TXTST0: +# -- Begin j1l + .text + .align 16,0x90 + .globl j1l +j1l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $56, %esp + fldt 8(%ebp) + lea 16(%esp), %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.6: + addl $-32, %esp + movl (%edi), %ecx + lea 64(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%edi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __j1q@PLT +..B1.5: + addl $28, %esp +..B1.2: + movl 32(%esp), %eax + movl %eax, (%edi) + movl 36(%esp), %edx + movl 40(%esp), %ecx + movl 44(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B1.7: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type j1l,@function + .size j1l,.-j1l + .data +# -- End j1l + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/jn.S b/external/sgx_libm/ia32/jn.S new file mode 100644 index 0000000000..f3e165bf3b --- /dev/null +++ b/external/sgx_libm/ia32/jn.S @@ -0,0 +1,1477 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "jn.c" + .text +..TXTST0: +# -- Begin jn + .text + .align 16,0x90 + .globl jn +jn: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + movl 8(%ebp), %edx +..B1.2: + fnstcw 102(%esp) +..B1.3: + movzwl 18(%ebp), %eax + andl $32752, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $32752, %eax + je ..B1.75 +..B1.4: + testl %edx, %edx + je ..B1.51 +..B1.5: + fldl 12(%ebp) + fldl _zeros@GOTOFF(%ebx) + fucom %st(1) + fnstsw %ax + sahf + jp ..B1.6 + je ..B1.79 +..B1.6: + testl %edx, %edx + jl ..B1.74 +..B1.7: + movl $1, %edi +..B1.8: + fcom %st(1) + fnstsw %ax + sahf + jbe ..B1.10 +..B1.9: + movl %edi, %eax + fxch %st(1) + fchs + negl %eax + testb $1, %dl + fstl 12(%ebp) + je ..L3 + movl %eax, %edi +..L3: + fxch %st(1) +..B1.10: + cmpl $1, %edx + je ..B1.71 +..B1.11: + movl %edx, %eax + sarl $5, %eax + cmpl $160, %eax + jg ..B1.13 +..B1.12: + fldl XZERO@GOTOFF(%ebx,%eax,8) + jmp ..B1.14 +..B1.13: + lea -640(,%eax,4), %eax + lea (,%eax,8), %ecx + subl %eax, %ecx + movl %ecx, 80(%esp) + fildl 80(%esp) + faddl .L_2il0floatpacket.0@GOTOFF(%ebx) +..B1.14: + fcomp %st(2) + fnstsw %ax + sahf + ja ..B1.50 +..B1.15: + fstp %st(0) + movzwl 102(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.70 +..B1.16: + fstp %st(0) + orl $-64768, %ecx + movw %cx, 100(%esp) +..B1.17: + fldcw 100(%esp) +..B1.18: + fldl 12(%ebp) + movl $1, %esi +..B1.19: + movl %edx, 80(%esp) + cmpl $1753, %edx + fildl 80(%esp) + jg ..B1.28 +..B1.20: + fldt val_0_4@GOTOFF(%ebx) + fmul %st(1), %st + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B1.28 +..B1.21: + fstp %st(0) + fldt _val_2_0L@GOTOFF(%ebx) + testl %edx, %edx + fdivrp %st, %st(1) + fldt _val_1_0L@GOTOFF(%ebx) + fld %st(0) + fld %st(0) + fld %st(2) + fld %st(3) + jle ..B1.24 +..B1.22: + xorl %eax, %eax +..B1.23: + incl %eax + fmul %st(5), %st + cmpl %edx, %eax + fxch %st(1) + fmul %st(3), %st + fxch %st(3) + fadd %st(4), %st + fxch %st(3) + fxch %st(1) + jb ..B1.23 +..B1.24: + fstp %st(3) +..B1.25: + fxch %st(4) + fmul %st(0), %st + xorl %ecx, %ecx + fchs +..B1.26: + incl %ecx + incl %edx + movl %ecx, %ebx + fld %st(3) + imull %edx, %ebx + fxch %st(1) + fmul %st, %st(2) + movl %ebx, 80(%esp) + fildl 80(%esp) + fdivrp %st, %st(3) + fxch %st(2) + fadd %st, %st(4) + fxch %st(1) + fucomp %st(4) + fnstsw %ax + sahf + fxch %st(1) + jne ..B1.26 + jp ..B1.26 +..B1.27: + fstp %st(0) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(2) + fdivrp %st, %st(1) + fxch %st(1) + fstpt 56(%esp) + jmp ..B1.41 +..B1.28: + fcom %st(1) + fnstsw %ax + sahf + ja ..B1.47 +..B1.29: + fldt _val_20_0L@GOTOFF(%ebx) + fmul %st(1), %st + fldt _val_1000_0L@GOTOFF(%ebx) + faddp %st, %st(1) + fcomp %st(2) + fnstsw %ax + sahf + ja ..B1.53 +..B1.30: + fldt _val_4_0L@GOTOFF(%ebx) + movl $-1, %eax + movl %ebx, 12(%esp) + xorl %ecx, %ecx + fstpt 152(%esp) + fldt 152(%esp) + fld %st(1) + fmulp %st, %st(1) + fmulp %st, %st(1) + fstpt 184(%esp) + fldt 184(%esp) + fxch %st(1) + fstpt 104(%esp) + fldt 104(%esp) + fldt _val_8_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 168(%esp) + fldt 168(%esp) + fldt _val_1_0L@GOTOFF(%ebx) + fld %st(0) + fsubrp %st, %st(3) + fxch %st(1) + fdivrp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 88(%esp) + fldt _val_2_0L@GOTOFF(%ebx) + fstpt 136(%esp) + fldt 136(%esp) + fstpt 48(%esp) + fldt _val_3_0L@GOTOFF(%ebx) + fstpt 120(%esp) + fldt 120(%esp) + fldt _val_5_0L@GOTOFF(%ebx) + movl %eax, %ebx + fstpt (%esp) + fldt (%esp) + fldt 120(%esp) + fldt 48(%esp) + fldt 16(%esp) +..B1.31: + fldt 168(%esp) + fld %st(3) + fmul %st(4), %st + testl %ebx, %ebx + fxch %st(4) + fstpt 120(%esp) + fxch %st(2) + fstpt 48(%esp) + fldt 48(%esp) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fstpt 72(%esp) + fldt 72(%esp) + fldt 184(%esp) + fsub %st, %st(4) + fxch %st(3) + fdivrp %st, %st(4) + fxch %st(6) + fmulp %st, %st(3) + fld %st(3) + fmul %st(4), %st + fsubrp %st, %st(2) + fdivrp %st, %st(1) + fmul %st(1), %st + fldt 120(%esp) + fldt 48(%esp) + jle ..B1.33 +..B1.32: + fxch %st(3) + faddp %st, %st(6) + fldt 32(%esp) + fadd %st(2), %st + fstpt 32(%esp) + jmp ..B1.34 +..B1.33: + fxch %st(3) + fsubrp %st, %st(6) + fldt 32(%esp) + fsub %st(2), %st + fstpt 32(%esp) +..B1.34: + fldt 136(%esp) + fadd %st, %st(3) + faddp %st, %st(5) + fldt 152(%esp) + fadd %st, %st(1) + faddp %st, %st(4) + fld %st(1) + fdiv %st(6), %st + fabs + fldt 88(%esp) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.36 +..B1.35: + fstpt 88(%esp) + movl $1, %ecx + jmp ..B1.37 +..B1.36: + fstp %st(0) + testl %ecx, %ecx + jne ..B1.52 +..B1.37: + fldt (%esp) + negl %ebx + fucomp %st(6) + fnstsw %ax + sahf + fxch %st(2) + fxch %st(1) + fxch %st(5) + jne ..B1.31 + jp ..B1.31 +..B1.38: + fstp %st(4) + fstp %st(1) + fstp %st(0) + fstp %st(0) + fldt 72(%esp) + movl 12(%esp), %ebx + fstpt (%esp) + fstpt 16(%esp) + fstpt 56(%esp) + fldt 104(%esp) +..B1.39: + addl $-32, %esp + addl %edx, %edx + negl %edx + lea 32(%esp), %eax + decl %edx + lea 88(%esp), %ecx + fstpt (%esp) + fldt (%esp) + movl %eax, 12(%esp) + movl %ecx, 16(%esp) + movl %edx, 20(%esp) + fstpt 104(%eax) + call __libm_sincos_pi4l +..B1.82: + fldt 136(%esp) + addl $32, %esp +..B1.40: + fldt _tonpi@GOTOFF(%ebx) + fdivp %st, %st(1) + fsqrt + fldt 56(%esp) + fldt 16(%esp) + fmulp %st, %st(1) + fldt (%esp) + fldt 32(%esp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fmulp %st, %st(1) +..B1.41: + testl %edi, %edi + jl ..B1.43 +..B1.42: + fstpt (%esp) + jmp ..B1.44 +..B1.43: + fchs + fstpt (%esp) +..B1.44: + testl %esi, %esi + je ..B1.46 +..B1.45: + fldcw 102(%esp) +..B1.46: + fldt (%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.47: + fstp %st(0) + fldt _val_0_0L@GOTOFF(%ebx) + lea (%edx,%edx), %eax + movl %eax, 80(%esp) + fstpt 32(%esp) + fld %st(0) + fmul %st(1), %st + fchs + fstpt 64(%esp) + fld %st(0) + fxch %st(1) + fstpt 104(%esp) + fldt _val_1_0L@GOTOFF(%ebx) + fstpt (%esp) + fldt (%esp) + fld %st(0) + fxch %st(1) + fstpt 16(%esp) + fildl 80(%esp) + fld %st(0) + fldt _val_2_0L@GOTOFF(%ebx) + fstpt 48(%esp) + fldt (%esp) + jmp ..B1.48 +..B1.49: + fstp %st(0) + fxch %st(4) + fxch %st(3) + fxch %st(2) +..B1.48: + fldt 48(%esp) + faddp %st, %st(2) + fld %st(4) + fmul %st(2), %st + fldt 64(%esp) + fmul %st, %st(2) + fldt 32(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(3) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(5) + fstpt 32(%esp) + fld %st(4) + fxch %st(1) + fdivr %st, %st(5) + fxch %st(4) + fucom %st(5) + fnstsw %ax + sahf + jne ..B1.49 + jp ..B1.49 + jmp ..B1.63 +..B1.50: + fstp %st(1) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.51: + fldl 12(%ebp) + addl $-16, %esp + fstpl (%esp) + call j0@PLT +..B1.83: + addl $260, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.52: + fstp %st(4) + fstp %st(3) + fstp %st(0) + fstp %st(0) + fldt 72(%esp) + movl 12(%esp), %ebx + fstpt (%esp) + fxch %st(1) + fstpt 16(%esp) + fstpt 56(%esp) + fldt 104(%esp) + jmp ..B1.39 +..B1.53: + fstp %st(0) + fldt _val_36_0L@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B1.57 +..B1.54: + fstp %st(0) + addl $-16, %esp + fstpt (%esp) + fldt (%esp) + movl %edx, 52(%esp) + fstpt 120(%esp) + call __j0l@PLT +..B1.84: + fldt 120(%esp) + movl 52(%esp), %edx + addl $16, %esp +..B1.55: + fxch %st(1) + fstpt 56(%esp) + addl $-16, %esp + fstpt (%esp) + fldt (%esp) + movl %edx, 52(%esp) + fstpt 120(%esp) + call __j1l@PLT +..B1.85: + fldt 120(%esp) + movl 52(%esp), %edx + addl $16, %esp +..B1.56: + fxch %st(1) + jmp ..B1.59 +..B1.57: + fldl _ones@GOTOFF(%ebx) + fdiv %st(2), %st + fmul %st, %st(1) + fld %st(1) + fmul %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fxch %st(1) + fstpt 24(%esp) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fldt _PP0@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _PP1@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_PP1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_PP1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 96+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 108+_PP0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fstpt 40(%esp) + addl $-32, %esp + lea 44(%esp), %eax + lea 32(%esp), %ecx + fxch %st(3) + fstpt (%esp) + fldt (%esp) + fldt 108+_PP1@GOTOFF(%ebx) + movl %eax, 12(%esp) + faddp %st, %st(4) + fldt _QP0@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP0@GOTOFF(%ebx) + movl %ecx, 16(%esp) + faddp %st, %st(1) + fmul %st(3), %st + fldt _QP1@GOTOFF(%ebx) + fmul %st(4), %st + fldt 12+_QP1@GOTOFF(%ebx) + movl $-1, 20(%esp) + faddp %st, %st(1) + fmul %st(4), %st + fxch %st(5) + fstpt 60(%eax) + movl %edx, 24(%eax) + fxch %st(1) + fstpt 92(%eax) + fldt 24+_QP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_QP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_QP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_QP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_QP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_QP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_QP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fldt 36+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 48+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 60+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 72+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 84+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 96+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmulp %st, %st(3) + fldt 108+_QP0@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fstpt 44(%eax) + fldt 108+_QP1@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 76(%eax) + call __libm_sincos_pi4l +..B1.86: + fldt 136(%esp) + fldt 120(%esp) + fldt 104(%esp) + fldt 88(%esp) + movl 68(%esp), %edx + addl $32, %esp +..B1.58: + fldt _tonpi@GOTOFF(%ebx) + fldt 24(%esp) + fmulp %st, %st(1) + fsqrt + fldt (%esp) + fldt 12(%esp) + fmul %st, %st(3) + fmulp %st, %st(4) + fldt 40(%esp) + fmul %st(1), %st + fsubp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fstpt 56(%esp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) +..B1.59: + fldt _val_2_0L@GOTOFF(%ebx) + cmpl $1, %edx + fld %st(0) + jle ..B1.91 +..B1.60: + fldt 56(%esp) + decl %edx + xorl %eax, %eax +..B1.61: + fld %st(1) + incl %eax + fdiv %st(5), %st + cmpl %edx, %eax + fmul %st(4), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(2) + fsubp %st, %st(1) + fld %st(3) + jae ..B1.62 +..B1.92: + fstp %st(4) + fxch %st(3) + jmp ..B1.61 +..B1.62: + fstp %st(0) + fstp %st(1) + fstp %st(3) + fstp %st(0) + fstpt 56(%esp) + jmp ..B1.41 +..B1.63: + fstp %st(1) + fstp %st(3) + fstp %st(0) + fstp %st(2) + fstp %st(1) + fldt 48(%esp) + decl %edx + fldt 16(%esp) + xorl %eax, %eax + movl %edx, 80(%esp) + fld %st(0) + fxch %st(1) + fdiv %st, %st(3) + fildl 80(%esp) + fmul %st(3), %st + fldt 104(%esp) + fdivr %st, %st(3) +..B1.64: + fld %st(5) + incl %eax + fmul %st(2), %st + fxch %st(2) + fsub %st(5), %st + fxch %st(1) + fmul %st, %st(3) + cmpl %edx, %eax + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fld %st(5) + fld %st(1) + jge ..B1.65 +..B1.93: + fstp %st(7) + fstp %st(1) + fxch %st(2) + jmp ..B1.64 +..B1.65: + fstp %st(0) + fstp %st(4) + fstp %st(4) + fstp %st(0) + fxch %st(2) + fstpt 56(%esp) + fldt 56(%esp) + fxch %st(1) + fabs + fxch %st(1) + fabs + fcompp + fnstsw %ax + fxch %st(1) + fstpt (%esp) + sahf + jae ..B1.68 + jp ..B1.68 +..B1.66: + addl $-16, %esp + fstpt (%esp) + call __j1l@PLT +..B1.87: + addl $16, %esp +..B1.67: + fldt (%esp) + fdivrp %st, %st(1) + jmp ..B1.41 +..B1.68: + addl $-16, %esp + fstpt (%esp) + call __j0l@PLT +..B1.88: + addl $16, %esp +..B1.69: + fldt 56(%esp) + fdivrp %st, %st(1) + jmp ..B1.41 +..B1.70: + xorl %esi, %esi + jmp ..B1.19 +..B1.71: + fstp %st(0) + addl $-16, %esp + fstpl (%esp) + call j1@PLT +..B1.89: + addl $16, %esp + testl %edi, %edi + jge ..B1.73 +..B1.72: + fchs +..B1.73: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.74: + movl %edx, %eax + negl %edx + notl %eax + andl $1, %eax + lea -1(%eax,%eax), %edi + jmp ..B1.8 +..B1.75: + testl $1048575, 16(%ebp) + jne ..B1.77 +..B1.76: + cmpl $0, 12(%ebp) + je ..B1.78 +..B1.77: + fldl 12(%ebp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.78: + movzbl 19(%ebp), %ecx + movl %edx, %eax + andl $128, %ecx + shrl $7, %ecx + shrl $31, %eax + xorl %eax, %ecx + andl %edx, %ecx + fldl _zeros@GOTOFF(%ebx,%ecx,8) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.79: + fstp %st(0) + fstp %st(0) + movzbl 19(%ebp), %ecx + movl %edx, %eax + andl $128, %ecx + shrl $7, %ecx + shrl $31, %eax + xorl %eax, %ecx + andl %edx, %ecx + fldl _zeros@GOTOFF(%ebx,%ecx,8) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.91: + fstp %st(0) + fstp %st(2) + fstp %st(1) + jmp ..B1.41 + .align 16,0x90 + .type jn,@function + .size jn,.-jn + .data +# -- End jn + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40add600 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +XZERO: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x33333333,0x3fd33333 + .long 0x66666666,0x3ff66666 + .long 0x00000000,0x400c0000 + .long 0x00000000,0x401c0000 + .long 0x00000000,0x40280000 + .long 0xcccccccd,0x40324ccc + .long 0x00000000,0x403a0000 + .long 0x00000000,0x40418000 + .long 0x9999999a,0x40469999 + .long 0x00000000,0x404c4000 + .long 0x33333333,0x40513333 + .long 0x00000000,0x40548000 + .long 0x00000000,0x40580000 + .long 0x33333333,0x405bb333 + .long 0xcccccccd,0x405f8ccc + .long 0xcccccccd,0x4061cccc + .long 0x33333333,0x4063e333 + .long 0xcccccccd,0x40660ccc + .long 0x33333333,0x40684333 + .long 0xcccccccd,0x406a8ccc + .long 0x33333333,0x406ce333 + .long 0x66666666,0x406f4666 + .long 0x9999999a,0x4070d999 + .long 0x00000000,0x40721800 + .long 0x9999999a,0x40735999 + .long 0x9999999a,0x4074a199 + .long 0x66666666,0x4075ee66 + .long 0x00000000,0x40774000 + .long 0xcccccccd,0x407894cc + .long 0x66666666,0x4079ee66 + .long 0x33333333,0x407b4b33 + .long 0x33333333,0x407cab33 + .long 0x00000000,0x407e1000 + .long 0x66666666,0x407f7666 + .long 0xcccccccd,0x408070cc + .long 0x33333333,0x40812733 + .long 0x33333333,0x4081df33 + .long 0xcccccccd,0x408298cc + .long 0x33333333,0x40835333 + .long 0x33333333,0x40840f33 + .long 0xcccccccd,0x4084cccc + .long 0x66666666,0x40858a66 + .long 0x66666666,0x40864a66 + .long 0x66666666,0x40870a66 + .long 0x00000000,0x4087cc00 + .long 0x66666666,0x40888e66 + .long 0x9999999a,0x40895199 + .long 0x9999999a,0x408a1599 + .long 0x33333333,0x408adb33 + .long 0xcccccccd,0x408ba0cc + .long 0x00000000,0x408c6000 + .long 0x00000000,0x408d2800 + .long 0x00000000,0x408df000 + .long 0x00000000,0x408ec000 + .long 0x00000000,0x408f8800 + .long 0x00000000,0x40902800 + .long 0x00000000,0x40909000 + .long 0x00000000,0x4090f400 + .long 0x00000000,0x40915c00 + .long 0x00000000,0x4091c000 + .long 0x00000000,0x40922800 + .long 0x00000000,0x40929000 + .long 0x00000000,0x4092f800 + .long 0x00000000,0x40935c00 + .long 0x00000000,0x4093c400 + .long 0x00000000,0x40943000 + .long 0x00000000,0x40949800 + .long 0x00000000,0x40950000 + .long 0x00000000,0x40956800 + .long 0x00000000,0x4095d000 + .long 0x00000000,0x40963c00 + .long 0x00000000,0x4096a400 + .long 0x00000000,0x40971000 + .long 0x00000000,0x40977800 + .long 0x00000000,0x4097e400 + .long 0x00000000,0x40984c00 + .long 0x00000000,0x4098b800 + .long 0x00000000,0x40992400 + .long 0x00000000,0x40999000 + .long 0x00000000,0x4099f800 + .long 0x00000000,0x409a6400 + .long 0x00000000,0x409ad000 + .long 0x00000000,0x409b3c00 + .long 0x00000000,0x409ba800 + .long 0x00000000,0x409c1400 + .long 0x00000000,0x409c8000 + .long 0x00000000,0x409cec00 + .long 0x00000000,0x409d5c00 + .long 0x00000000,0x409dc800 + .long 0x00000000,0x409e3400 + .long 0x00000000,0x409ea000 + .long 0x00000000,0x409f1000 + .long 0x00000000,0x409f7c00 + .long 0x00000000,0x409fe800 + .long 0x00000000,0x40a02c00 + .long 0x00000000,0x40a06200 + .long 0x00000000,0x40a09a00 + .long 0x00000000,0x40a0d000 + .long 0x00000000,0x40a10800 + .long 0x00000000,0x40a13e00 + .long 0x00000000,0x40a17600 + .long 0x00000000,0x40a1ae00 + .long 0x00000000,0x40a1e400 + .long 0x00000000,0x40a21c00 + .long 0x00000000,0x40a25400 + .long 0x00000000,0x40a28c00 + .long 0x00000000,0x40a2c200 + .long 0x00000000,0x40a2fa00 + .long 0x00000000,0x40a33200 + .long 0x00000000,0x40a36a00 + .long 0x00000000,0x40a3a200 + .long 0x00000000,0x40a3da00 + .long 0x00000000,0x40a41200 + .long 0x00000000,0x40a44a00 + .long 0x00000000,0x40a48200 + .long 0x00000000,0x40a4ba00 + .long 0x00000000,0x40a4f200 + .long 0x00000000,0x40a52a00 + .long 0x00000000,0x40a56200 + .long 0x00000000,0x40a59a00 + .long 0x00000000,0x40a5d200 + .long 0x00000000,0x40a60a00 + .long 0x00000000,0x40a64400 + .long 0x00000000,0x40a67c00 + .long 0x00000000,0x40a6b400 + .long 0x00000000,0x40a6ec00 + .long 0x00000000,0x40a72600 + .long 0x00000000,0x40a75e00 + .long 0x00000000,0x40a79600 + .long 0x00000000,0x40a7d000 + .long 0x00000000,0x40a80800 + .long 0x00000000,0x40a84000 + .long 0x00000000,0x40a87a00 + .long 0x00000000,0x40a8b200 + .long 0x00000000,0x40a8ec00 + .long 0x00000000,0x40a92400 + .long 0x00000000,0x40a95c00 + .long 0x00000000,0x40a99600 + .long 0x00000000,0x40a9ce00 + .long 0x00000000,0x40aa0800 + .long 0x00000000,0x40aa4200 + .long 0x00000000,0x40aa7a00 + .long 0x00000000,0x40aab400 + .long 0x00000000,0x40aaec00 + .long 0x00000000,0x40ab2600 + .long 0x00000000,0x40ab6000 + .long 0x00000000,0x40ab9800 + .long 0x00000000,0x40abd200 + .long 0x00000000,0x40ac0a00 + .long 0x00000000,0x40ac4400 + .long 0x00000000,0x40ac7e00 + .long 0x00000000,0x40acb800 + .long 0x00000000,0x40acf000 + .long 0x00000000,0x40ad2a00 + .long 0x00000000,0x40ad6400 + .long 0x00000000,0x40ad9e00 + .long 0x00000000,0x40add600 + .type XZERO,@object + .size XZERO,1288 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +val_0_4: + .byte 0x00,0xd0,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xfd,0x3f,0x00,0x00 + .type val_0_4,@object + .size val_0_4,12 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_val_2_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .type _val_2_0L,@object + .size _val_2_0L,12 + .align 2 +_val_1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _val_1_0L,@object + .size _val_1_0L,12 + .align 2 +_val_20_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16387 + .word 0 + .type _val_20_0L,@object + .size _val_20_0L,12 + .align 2 +_val_1000_0L: + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .type _val_1000_0L,@object + .size _val_1000_0L,12 + .align 2 +_val_4_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16385 + .word 0 + .type _val_4_0L,@object + .size _val_4_0L,12 + .align 2 +_val_8_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16386 + .word 0 + .type _val_8_0L,@object + .size _val_8_0L,12 + .align 2 +_val_3_0L: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .type _val_3_0L,@object + .size _val_3_0L,12 + .align 2 +_val_5_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16385 + .word 0 + .type _val_5_0L,@object + .size _val_5_0L,12 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .type _tonpi,@object + .size _tonpi,12 + .align 2 +_val_0_0L: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _val_0_0L,@object + .size _val_0_0L,12 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,12 + .align 2 +_PP0: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP0,@object + .size _PP0,120 + .align 2 +_PP1: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP1,@object + .size _PP1,120 + .align 2 +_QP0: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .type _QP0,@object + .size _QP0,120 + .align 2 +_QP1: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .type _QP1,@object + .size _QP1,120 + .data + .hidden __libm_sincos_pi4l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/jnf.S b/external/sgx_libm/ia32/jnf.S new file mode 100644 index 0000000000..e62e1f69fb --- /dev/null +++ b/external/sgx_libm/ia32/jnf.S @@ -0,0 +1,1401 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "jnf.c" + .text +..TXTST0: +# -- Begin jnf + .text + .align 16,0x90 + .globl jnf +jnf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + movl 12(%ebp), %edi + movl %edi, %edx + andl $2147483647, %edx + movl 8(%ebp), %esi + cmpl $2139095040, %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jae ..B1.41 +..B1.2: + testl %esi, %esi + je ..B1.39 +..B1.3: + xorl %esi, %edi + shrl $31, %edi + andl %esi, %edi + testl %edx, %edx + je ..B1.38 +..B1.4: + flds 12(%ebp) + movl %esi, %eax + cltd + xorl %edx, %esi + fabs + subl %edx, %esi + fsts 12(%ebp) + cmpl $1, %esi + je ..B1.61 +..B1.5: + movl %esi, %edx + sarl $3, %edx + cmpl $320, %edx + jg ..B1.7 +..B1.6: + flds function_zeros@GOTOFF(%ebx,%edx,4) + jmp ..B1.8 +..B1.7: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + lea -320(%edx), %ecx + lea -2560(,%edx,8), %edx + subl %ecx, %edx + movl %edx, 168(%esp) + fildl 168(%esp) + fstps 168(%esp) + flds 168(%esp) + faddp %st, %st(1) + fstps 168(%esp) + flds 168(%esp) +..B1.8: + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.37 +..B1.9: + movl %esi, 168(%esp) + cmpl $170, %esi + fildl 168(%esp) + fstpl 192(%esp) + fldl 192(%esp) + jg ..B1.18 +..B1.10: + fldl _val_0_6@GOTOFF(%ebx) + fmul %st(1), %st + fcomp %st(2) + fnstsw %ax + sahf + jb ..B1.18 +..B1.11: + fstp %st(2) + fstp %st(1) + fldl _val_2_0@GOTOFF(%ebx) + testl %esi, %esi + fdivrp %st, %st(1) + fstpl 192(%esp) + fld1 + fld %st(0) + fld %st(1) + fldl 192(%esp) + jle ..B1.15 +..B1.12: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fld %st(2) + xorl %edx, %edx + .align 16,0x90 +..B1.13: + fxch %st(2) + fmul %st, %st(3) + incl %edx + fxch %st(3) + fstpl 192(%esp) + cmpl %esi, %edx + fxch %st(1) + fmul %st, %st(3) + fadd %st(1), %st + fldl 192(%esp) + fxch %st(4) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(4) + fxch %st(3) + fxch %st(2) + fxch %st(1) + fxch %st(4) + jb ..B1.13 +..B1.14: + fstp %st(1) + fstp %st(0) +..B1.15: + fldl _TWO_19H@GOTOFF(%ebx) + xorl %edx, %edx + fxch %st(1) + fmul %st(0), %st + fchs + fstpl 192(%esp) + fxch %st(3) + fstl 176(%esp) + fstl 56(%esp) + fldl 192(%esp) +..B1.16: + fldl 176(%esp) + incl %edx + incl %esi + movl %edx, %ecx + imull %esi, %ecx + fmul %st(1), %st + fldl 56(%esp) + movl %ecx, 168(%esp) + fildl 168(%esp) + fstpl 192(%esp) + fldl 192(%esp) + fdivrp %st, %st(2) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fstl 176(%esp) + faddp %st, %st(1) + fstpl 192(%esp) + fld %st(4) + fldl 192(%esp) + fmul %st, %st(1) + fxch %st(1) + fstpl 192(%esp) + fstl 56(%esp) + fldl 192(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpl 184(%esp) + fldl 184(%esp) + fsubp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(2) + fucomp %st(2) + fnstsw %ax + sahf + jne ..B1.16 + jp ..B1.16 +..B1.17: + fstp %st(0) + fstp %st(0) + fstp %st(2) + fxch %st(1) + fmull 56(%esp) + fdivp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + jmp ..B1.30 +..B1.18: + fcom %st(1) + fnstsw %ax + sahf + ja ..B1.34 +..B1.19: + lea (%esi,%esi,4), %edx + lea 1000(,%edx,4), %ecx + movl %ecx, 168(%esp) + fildl 168(%esp) + fstpl 192(%esp) + fldl 192(%esp) + fcomp %st(2) + fnstsw %ax + sahf + ja ..B1.47 +..B1.20: + fstp %st(2) + fldl _val_4_0@GOTOFF(%ebx) + movl $-1, %ecx + fstl 152(%esp) + fld %st(2) + fmulp %st, %st(1) + xorl %edx, %edx + fmulp %st, %st(2) + fxch %st(1) + fstpl 192(%esp) + fstpt 112(%esp) + fldt 112(%esp) + fldl 192(%esp) + fld %st(0) + fxch %st(1) + fstpt 128(%esp) + fldl _val_8_0@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fstpt 96(%esp) + fldt 96(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fstpt 80(%esp) + fldt 80(%esp) + fsubrp %st, %st(2) + fdivrp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fstpt 64(%esp) + fldt 64(%esp) + fstpl 176(%esp) + fldl _val_2_0@GOTOFF(%ebx) + fstl 144(%esp) + fldl _val_3_0@GOTOFF(%ebx) + fstpt 48(%esp) + fldt 48(%esp) + fldl _val_5_0@GOTOFF(%ebx) + fstpt 32(%esp) + fld1 + fld %st(0) + fstpl 160(%esp) + fldt 80(%esp) + fldt 32(%esp) + fldt 48(%esp) +..B1.21: + fldt 96(%esp) + fld %st(6) + fmul %st(1), %st + testl %ecx, %ecx + fxch %st(1) + fmul %st(6), %st + fxch %st(5) + fstpl 56(%esp) + fld %st(1) + fmul %st(2), %st + fxch %st(4) + fstpt 80(%esp) + fldt 128(%esp) + fsub %st, %st(4) + fxch %st(1) + fdivrp %st, %st(4) + fld %st(2) + fmul %st(3), %st + fsubrp %st, %st(1) + fdivp %st, %st(4) + fxch %st(2) + fmull 176(%esp) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(3) + fstpl 192(%esp) + fldl 192(%esp) + fmul %st(3), %st + fstpl 192(%esp) + fldl 192(%esp) + fldt 80(%esp) + jle ..B1.46 +..B1.22: + faddp %st, %st(4) + fxch %st(3) + fstpl 192(%esp) + fldl 192(%esp) + fldt 64(%esp) + fadd %st(4), %st + fstpl 192(%esp) + fldl 192(%esp) + fstpt 64(%esp) +..B1.23: + fldl 144(%esp) + fadd %st, %st(6) + fxch %st(6) + fstpl 192(%esp) + fxch %st(5) + faddp %st, %st(4) + fxch %st(2) + fstl 176(%esp) + fdiv %st(4), %st + fldl 192(%esp) + fxch %st(4) + fstpl 192(%esp) + fldl 192(%esp) + fldl 152(%esp) + fadd %st, %st(3) + fxch %st(3) + fstpl 192(%esp) + fxch %st(2) + faddp %st, %st(3) + fldl 192(%esp) + fxch %st(3) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fabs + fldl 160(%esp) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.25 +..B1.24: + fstpl 160(%esp) + movl $1, %edx + jmp ..B1.26 +..B1.25: + fstp %st(0) + testl %edx, %edx + jne ..B1.45 +..B1.26: + fldl _TWO_19H@GOTOFF(%ebx) + negl %ecx + fmul %st(5), %st + fstpl 192(%esp) + fld %st(4) + fldl 192(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpl 184(%esp) + fldl 184(%esp) + fsubp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fldl 56(%esp) + fucomp %st(1) + fnstsw %ax + sahf + fxch %st(3) + fxch %st(2) + fxch %st(4) + fxch %st(5) + fxch %st(2) + jne ..B1.21 + jp ..B1.21 +..B1.27: + fstp %st(3) + fstp %st(2) + fstp %st(1) + fstp %st(1) + fstp %st(1) + fldt 112(%esp) + fxch %st(1) + fstpt 80(%esp) +..B1.28: + addl %esi, %esi + lea 56(%esp), %edx + negl %esi + lea 176(%esp), %ecx + fstl (%esp) + decl %esi + movl %edx, 8(%esp) + movl %ecx, 12(%esp) + movl %esi, 16(%esp) + fstpt 56(%edx) + call __libm_sincos_k32 +..B1.29: + fldt 112(%esp) + fldt 80(%esp) + fmull 176(%esp) + fldl _tonpi@GOTOFF(%ebx) + fdivp %st, %st(2) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fsqrt + fstpl 192(%esp) + fldl 192(%esp) + fldt 64(%esp) + fmull 56(%esp) + fsubrp %st, %st(2) + fmulp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) +..B1.30: + testl %edi, %edi + je ..B1.33 +..B1.31: + fchs +..B1.33: + fstps 168(%esp) + flds 168(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.34: + fstp %st(0) + fldl _val_2_0@GOTOFF(%ebx) + lea (%esi,%esi), %edx + movl %edx, 168(%esp) + fstpl 88(%esp) + fld %st(0) + fmul %st(1), %st + fchs + fld1 + fstl 176(%esp) + fld %st(0) + fxch %st(3) + fstl 48(%esp) + fxch %st(1) + fstpt 32(%esp) + fxch %st(3) + fstl 56(%esp) + fxch %st(3) + fstpt 112(%esp) + fildl 168(%esp) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fstpt 64(%esp) + fldl _TWO_19H@GOTOFF(%ebx) + fstpl 80(%esp) + fld %st(0) + fldl 48(%esp) + jmp ..B1.35 +..B1.36: + fstp %st(1) + fstl 56(%esp) + fstpl 176(%esp) + fxch %st(2) + fxch %st(3) + fxch %st(1) + fxch %st(4) + fxch %st(1) +..B1.35: + fldt 64(%esp) + fmul %st, %st(5) + fld %st(1) + fxch %st(1) + fmulp %st, %st(5) + fld %st(3) + fxch %st(3) + faddl 88(%esp) + fstpl 192(%esp) + fldl 192(%esp) + fmul %st, %st(1) + fxch %st(6) + faddp %st, %st(1) + fstpl 192(%esp) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(3) + fldl 192(%esp) + fld %st(0) + fxch %st(4) + fstpl 192(%esp) + fldl 192(%esp) + fdivr %st, %st(1) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fld %st(0) + fld %st(1) + fxch %st(1) + fmull 80(%esp) + fstpl 192(%esp) + fldl 192(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpl 184(%esp) + fldl 184(%esp) + fsubp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fldl 176(%esp) + fucomp %st(1) + fnstsw %ax + sahf + jne ..B1.36 + jp ..B1.36 + jmp ..B1.57 +..B1.37: + fstp %st(0) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + fstp %st(0) + flds _zeros@GOTOFF(%ebx,%edi,4) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + fstpl 56(%esp) + addl $4, %esp + pushl 12(%ebp) + call j0f@PLT +..B1.40: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + fstp %st(0) + ja ..B1.43 +..B1.42: + xorl %esi, %edi + shrl $31, %edi + andl %esi, %edi + flds _zeros@GOTOFF(%ebx,%edi,4) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.43: + flds 12(%ebp) +..B1.44: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + fstp %st(2) + fstp %st(1) + fstp %st(0) + fstp %st(0) + fldt 112(%esp) + fxch %st(1) + fstpt 80(%esp) + jmp ..B1.28 +..B1.46: + fsubp %st, %st(4) + fxch %st(3) + fstpl 192(%esp) + fldl 192(%esp) + fldt 64(%esp) + fsub %st(4), %st + fstpl 192(%esp) + fldl 192(%esp) + fstpt 64(%esp) + jmp ..B1.23 +..B1.47: + fstp %st(0) + fxch %st(1) + fstpl 56(%esp) + fldl _val_17_0@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.51 +..B1.48: + fstl (%esp) + fstpt 112(%esp) + call j0@PLT +..B1.69: + fldt 112(%esp) +..B1.49: + fstl (%esp) + fxch %st(1) + fstpl 176(%esp) + fstpt 112(%esp) + call j1@PLT +..B1.70: + fldt 112(%esp) +..B1.50: + fxch %st(1) + jmp ..B1.53 +..B1.51: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + lea 96(%esp), %edx + fdiv %st(1), %st + lea 104(%esp), %ecx + fstpl 96(%edx) + fldl 96(%edx) + fstpt -64(%edx) + fldt -64(%edx) + fldl _val_16_0@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpl 96(%edx) + fldl 96(%edx) + fld %st(0) + fmul %st(1), %st + fstpl 96(%edx) + fldl 96(%edx) + fld %st(0) + fmul %st(1), %st + fstpl 96(%edx) + fldl 96(%edx) + fxch %st(3) + fstl (%esp) + movl %edx, 8(%esp) + movl %ecx, 12(%esp) + movl $-1, 16(%esp) + fxch %st(1) + fstpt -48(%edx) + fxch %st(2) + fstpt -32(%edx) + fstpt -16(%edx) + fstpt 16(%edx) + call __libm_sincos_k32 +..B1.52: + fldt 112(%esp) + fldt 80(%esp) + fldt 64(%esp) + fldt 48(%esp) + fldl 40+_PP0@GOTOFF(%ebx) + fmul %st(2), %st + fldl 32+_PP0@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 24+_PP0@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 16+_PP0@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 8+_PP0@GOTOFF(%ebx) + fmul %st(2), %st + fstpl 192(%esp) + fldl 192(%esp) + fldl 32+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl _PP0@GOTOFF(%ebx) + fstpl 192(%esp) + fldl 192(%esp) + faddp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fldl 40+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl 16+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl 24+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl _PP1@GOTOFF(%ebx) + fldl 32+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl 8+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + faddp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fldl 40+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl 16+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl 24+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl _QP0@GOTOFF(%ebx) + fmul %st(6), %st + fxch %st(3) + faddl 8+_QP0@GOTOFF(%ebx) + fmul %st(4), %st + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fstpl 192(%esp) + fldl 192(%esp) + fldl 40+_QP1@GOTOFF(%ebx) + fmul %st(5), %st + faddl 24+_QP1@GOTOFF(%ebx) + fmul %st(5), %st + faddl 8+_QP1@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fldl 32+_QP1@GOTOFF(%ebx) + fmul %st(5), %st + faddl 16+_QP1@GOTOFF(%ebx) + fmulp %st, %st(5) + fldl _tonpi@GOTOFF(%ebx) + fxch %st(5) + faddl _QP1@GOTOFF(%ebx) + fmulp %st, %st(6) + faddp %st, %st(5) + fxch %st(4) + fstpl 192(%esp) + fldl 192(%esp) + fldt 32(%esp) + fmulp %st, %st(4) + fxch %st(3) + fstpl 192(%esp) + fldl 192(%esp) + fsqrt + fstpl 192(%esp) + fldl 192(%esp) + fldl 96(%esp) + fmul %st, %st(3) + fmulp %st, %st(2) + fldl 104(%esp) + fmul %st, %st(5) + fxch %st(3) + fsubrp %st, %st(5) + fmul %st, %st(4) + fxch %st(4) + fstpl 176(%esp) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) +..B1.53: + fldl _val_2_0@GOTOFF(%ebx) + cmpl $1, %esi + fdivp %st, %st(2) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + jle ..B1.74 +..B1.54: + fldl 176(%esp) + movl $1, %edx +..B1.55: + movl %edx, 168(%esp) + incl %edx + fildl 168(%esp) + fstpl 192(%esp) + fld %st(2) + fldl 192(%esp) + cmpl %esi, %edx + fmul %st(3), %st + fmulp %st, %st(4) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(2) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(2) + jl ..B1.55 +..B1.56: + fstp %st(0) + fstp %st(0) + jmp ..B1.30 +..B1.57: + fstp %st(3) + fstp %st(2) + fstp %st(3) + fstp %st(1) + fstp %st(1) + fstp %st(1) + fldl 88(%esp) + lea -2(%esi,%esi), %edx + fldt 32(%esp) + decl %esi + fldt 112(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fdiv %st, %st(4) + movl %edx, 168(%esp) + xorl %edx, %edx + fxch %st(4) + fstpl 192(%esp) + fdivr %st, %st(3) + fildl 168(%esp) + fldl 192(%esp) + fxch %st(1) + fstpl 192(%esp) + fldl 192(%esp) + fxch %st(5) + fstpl 192(%esp) + fldl 192(%esp) +..B1.58: + fld %st(1) + incl %edx + fmul %st(6), %st + fxch %st(5) + fsubr %st, %st(6) + fxch %st(3) + fmul %st, %st(4) + cmpl %esi, %edx + fxch %st(4) + fsubrp %st, %st(5) + fmul %st, %st(4) + fxch %st(4) + fstpl 192(%esp) + fld %st(0) + fldl 192(%esp) + fld %st(0) + fxch %st(7) + fstpl 192(%esp) + fldl 192(%esp) + jge ..B1.59 +..B1.75: + fstp %st(3) + fstp %st(0) + fxch %st(3) + fxch %st(2) + fxch %st(4) + fxch %st(5) + fxch %st(1) + fxch %st(5) + jmp ..B1.58 +..B1.59: + fstp %st(6) + fstp %st(3) + fstp %st(0) + fstp %st(4) + fstp %st(2) + fxch %st(1) + fstpl 176(%esp) + fxch %st(1) + fstpl 56(%esp) + fstpl (%esp) + call j0@PLT +..B1.60: + fldl 176(%esp) + fdivrp %st, %st(1) + fstpl 192(%esp) + fldl 192(%esp) + jmp ..B1.30 +..B1.61: + fxch %st(1) + fstpl 56(%esp) + fstps (%esp) + call j1f@PLT +..B1.62: + testl %edi, %edi + je ..B1.65 +..B1.63: + fchs +..B1.65: + fstps 168(%esp) + flds 168(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.74: + fstp %st(0) + jmp ..B1.30 + .align 16,0x90 + .type jnf,@function + .size jnf,.-jnf + .data +# -- End jnf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x8e,0x0a,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 4 +function_zeros: + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x3f000000 + .long 0x3fcccccd + .long 0x40600000 + .long 0x40c33333 + .long 0x4111999a + .long 0x414b3333 + .long 0x4184cccd + .long 0x41a66666 + .long 0x41ca6666 + .long 0x41f0cccd + .long 0x420c0000 + .long 0x42206666 + .long 0x4235999a + .long 0x424b3333 + .long 0x42613333 + .long 0x42780000 + .long 0x42876666 + .long 0x42930000 + .long 0x429ecccd + .long 0x42aacccd + .long 0x42b6cccd + .long 0x42c30000 + .long 0x42cf6666 + .long 0x42dbcccd + .long 0x42e86666 + .long 0x42f50000 + .long 0x4300e666 + .long 0x43074ccd + .long 0x430db333 + .long 0x43143333 + .long 0x431ab333 + .long 0x43214ccd + .long 0x4327e666 + .long 0x432e8000 + .long 0x4335199a + .long 0x433bcccd + .long 0x43428000 + .long 0x43493333 + .long 0x43500000 + .long 0x43560000 + .long 0x435d0000 + .long 0x43640000 + .long 0x436b0000 + .long 0x43720000 + .long 0x43780000 + .long 0x437f0000 + .long 0x43830000 + .long 0x43868000 + .long 0x438a0000 + .long 0x438d8000 + .long 0x43910000 + .long 0x43948000 + .long 0x43980000 + .long 0x439b8000 + .long 0x439f0000 + .long 0x43a28000 + .long 0x43a60000 + .long 0x43a98000 + .long 0x43ad0000 + .long 0x43b08000 + .long 0x43b40000 + .long 0x43b78000 + .long 0x43bb0000 + .long 0x43bf0000 + .long 0x43c28000 + .long 0x43c60000 + .long 0x43c98000 + .long 0x43cd0000 + .long 0x43d08000 + .long 0x43d40000 + .long 0x43d80000 + .long 0x43db8000 + .long 0x43df0000 + .long 0x43e28000 + .long 0x43e60000 + .long 0x43ea0000 + .long 0x43ed8000 + .long 0x43f10000 + .long 0x43f48000 + .long 0x43f88000 + .long 0x43fc0000 + .long 0x43ff8000 + .long 0x44018000 + .long 0x44038000 + .long 0x44054000 + .long 0x44070000 + .long 0x44090000 + .long 0x440ac000 + .long 0x440c8000 + .long 0x440e4000 + .long 0x44104000 + .long 0x44120000 + .long 0x4413c000 + .long 0x4415c000 + .long 0x44178000 + .long 0x44194000 + .long 0x441b4000 + .long 0x441d0000 + .long 0x441ec000 + .long 0x4420c000 + .long 0x44228000 + .long 0x44244000 + .long 0x44264000 + .long 0x44280000 + .long 0x442a0000 + .long 0x442bc000 + .long 0x442d8000 + .long 0x442f8000 + .long 0x44314000 + .long 0x44334000 + .long 0x44350000 + .long 0x4436c000 + .long 0x4438c000 + .long 0x443a8000 + .long 0x443c8000 + .long 0x443e4000 + .long 0x44400000 + .long 0x44420000 + .long 0x4443c000 + .long 0x4445c000 + .long 0x44478000 + .long 0x44498000 + .long 0x444b4000 + .long 0x444d0000 + .long 0x444f0000 + .long 0x4450c000 + .long 0x4452c000 + .long 0x44548000 + .long 0x44568000 + .long 0x44584000 + .long 0x445a4000 + .long 0x445c0000 + .long 0x445e0000 + .long 0x445fc000 + .long 0x4461c000 + .long 0x44638000 + .long 0x44658000 + .long 0x44674000 + .long 0x44694000 + .long 0x446b0000 + .long 0x446cc000 + .long 0x446ec000 + .long 0x44708000 + .long 0x44728000 + .long 0x44744000 + .long 0x44764000 + .long 0x44784000 + .long 0x447a0000 + .long 0x447c0000 + .long 0x447dc000 + .long 0x447fc000 + .long 0x4480c000 + .long 0x4481c000 + .long 0x4482a000 + .long 0x4483a000 + .long 0x44848000 + .long 0x44858000 + .long 0x44866000 + .long 0x44876000 + .long 0x44884000 + .long 0x44894000 + .long 0x448a2000 + .long 0x448b2000 + .long 0x448c0000 + .long 0x448d0000 + .long 0x448e0000 + .long 0x448ee000 + .long 0x448fe000 + .long 0x4490c000 + .long 0x4491c000 + .long 0x4492a000 + .long 0x4493a000 + .long 0x44948000 + .long 0x44958000 + .long 0x44968000 + .long 0x44976000 + .long 0x44986000 + .long 0x44994000 + .long 0x449a4000 + .long 0x449b2000 + .long 0x449c2000 + .long 0x449d2000 + .long 0x449e0000 + .long 0x449f0000 + .long 0x449fe000 + .long 0x44a0e000 + .long 0x44a1c000 + .long 0x44a2c000 + .long 0x44a3c000 + .long 0x44a4a000 + .long 0x44a5a000 + .long 0x44a68000 + .long 0x44a78000 + .long 0x44a88000 + .long 0x44a96000 + .long 0x44aa6000 + .long 0x44ab4000 + .long 0x44ac4000 + .long 0x44ad4000 + .long 0x44ae2000 + .long 0x44af2000 + .long 0x44b00000 + .long 0x44b10000 + .long 0x44b20000 + .long 0x44b2e000 + .long 0x44b3e000 + .long 0x44b4c000 + .long 0x44b5c000 + .long 0x44b6c000 + .long 0x44b7a000 + .long 0x44b8a000 + .long 0x44b9a000 + .long 0x44ba8000 + .long 0x44bb8000 + .long 0x44bc6000 + .long 0x44bd6000 + .long 0x44be6000 + .long 0x44bf4000 + .long 0x44c04000 + .long 0x44c14000 + .long 0x44c22000 + .long 0x44c32000 + .long 0x44c40000 + .long 0x44c50000 + .long 0x44c60000 + .long 0x44c6e000 + .long 0x44c7e000 + .long 0x44c8e000 + .long 0x44c9c000 + .long 0x44cac000 + .long 0x44cba000 + .long 0x44cca000 + .long 0x44cda000 + .long 0x44ce8000 + .long 0x44cf8000 + .long 0x44d08000 + .long 0x44d16000 + .long 0x44d26000 + .long 0x44d36000 + .long 0x44d44000 + .long 0x44d54000 + .long 0x44d64000 + .long 0x44d72000 + .long 0x44d82000 + .long 0x44d92000 + .long 0x44da0000 + .long 0x44db0000 + .long 0x44dc0000 + .long 0x44dce000 + .long 0x44dde000 + .long 0x44dec000 + .long 0x44dfc000 + .long 0x44e0c000 + .long 0x44e1a000 + .long 0x44e2a000 + .long 0x44e3a000 + .long 0x44e48000 + .long 0x44e58000 + .long 0x44e68000 + .long 0x44e76000 + .long 0x44e86000 + .long 0x44e96000 + .long 0x44ea4000 + .long 0x44eb4000 + .long 0x44ec4000 + .long 0x44ed4000 + .long 0x44ee2000 + .long 0x44ef2000 + .long 0x44f02000 + .long 0x44f10000 + .long 0x44f20000 + .long 0x44f30000 + .long 0x44f3e000 + .long 0x44f4e000 + .long 0x44f5e000 + .long 0x44f6c000 + .long 0x44f7c000 + .long 0x44f8c000 + .long 0x44f9a000 + .long 0x44faa000 + .long 0x44fba000 + .long 0x44fc8000 + .long 0x44fd8000 + .long 0x44fe8000 + .long 0x44ff6000 + .long 0x45003000 + .long 0x4500b000 + .long 0x45013000 + .long 0x4501a000 + .long 0x45022000 + .long 0x4502a000 + .long 0x45031000 + .long 0x45039000 + .long 0x45041000 + .long 0x45048000 + .long 0x45050000 + .long 0x45058000 + .long 0x4505f000 + .long 0x45067000 + .long 0x4506f000 + .long 0x45077000 + .long 0x4507e000 + .long 0x45086000 + .long 0x4508e000 + .long 0x45095000 + .long 0x4509d000 + .long 0x450a5000 + .long 0x450ac000 + .long 0x450b4000 + .long 0x450bc000 + .long 0x450c4000 + .long 0x450cb000 + .long 0x450d3000 + .long 0x450db000 + .long 0x450e2000 + .long 0x450ea000 + .type function_zeros,@object + .size function_zeros,1284 + .align 4 +_val_0_6: + .long 858993459 + .long 1071854387 + .type _val_0_6,@object + .size _val_0_6,8 + .align 4 +_val_2_0: + .long 0 + .long 1073741824 + .type _val_2_0,@object + .size _val_2_0,8 + .align 4 +_TWO_19H: + .long 0 + .long 1093140480 + .type _TWO_19H,@object + .size _TWO_19H,8 + .align 4 +_val_4_0: + .long 0 + .long 1074790400 + .type _val_4_0,@object + .size _val_4_0,8 + .align 4 +_val_8_0: + .long 0 + .long 1075838976 + .type _val_8_0,@object + .size _val_8_0,8 + .align 4 +_val_3_0: + .long 0 + .long 1074266112 + .type _val_3_0,@object + .size _val_3_0,8 + .align 4 +_val_5_0: + .long 0 + .long 1075052544 + .type _val_5_0,@object + .size _val_5_0,8 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_val_17_0: + .long 0 + .long 1076953088 + .type _val_17_0,@object + .size _val_17_0,8 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_PP0: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP0,@object + .size _PP0,48 + .align 4 +_PP1: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP1,@object + .size _PP1,48 + .align 4 +_QP0: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP0,@object + .size _QP0,48 + .align 4 +_QP1: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP1,@object + .size _QP1,48 + .data + .hidden __libm_sincos_k32 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/jnl.S b/external/sgx_libm/ia32/jnl.S new file mode 100644 index 0000000000..4879bd4aa8 --- /dev/null +++ b/external/sgx_libm/ia32/jnl.S @@ -0,0 +1,109 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "jnl.c" + .text +..TXTST0: +# -- Begin jnl + .text + .align 16,0x90 + .globl jnl +jnl: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $56, %esp + fldt 12(%ebp) + lea 16(%esp), %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.6: + addl $-32, %esp + movl 8(%ebp), %ecx + lea 64(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl %ecx, 4(%esp) + movl (%edi), %edx + movl 4(%edi), %ecx + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 8(%edi), %edx + movl 12(%edi), %ecx + movl %edx, 8(%eax) + movl %ecx, 12(%eax) + call __jnq@PLT +..B1.5: + addl $28, %esp +..B1.2: + movl 32(%esp), %eax + movl %eax, (%edi) + movl 36(%esp), %edx + movl 40(%esp), %ecx + movl 44(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B1.7: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type jnl,@function + .size jnl,.-jnl + .data +# -- End jnl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/l2q.S b/external/sgx_libm/ia32/l2q.S new file mode 100644 index 0000000000..bd2cb43042 --- /dev/null +++ b/external/sgx_libm/ia32/l2q.S @@ -0,0 +1,109 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "l2q.c" + .text +..TXTST0: +# -- Begin __ltoq + .text + .align 16,0x90 + .globl __ltoq +__ltoq: +# parameter 1: 32 + %esp +# parameter 2: 36 + %esp +..B1.1: +..L1: + + pushl %edi + subl $24, %esp +..B1.2: + fnstcw 12(%esp) +..B1.3: + movzwl 12(%esp), %eax + orl $-64768, %eax + movw %ax, 14(%esp) +..B1.4: + fldcw 14(%esp) +..B1.5: + fldt 36(%esp) + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + fldt __l_one@GOTOFF(%eax) + fmulp %st, %st(1) + fstpt (%esp) +..B1.6: + fldcw 12(%esp) +..B1.7: + movl 32(%esp), %edx + movl (%esp), %ecx + movl %ecx, %edi + shll $17, %edi + movl %edi, 4(%edx) + movl 4(%esp), %edi + movl %edi, %eax + shll $17, %eax + shrl $15, %ecx + shrl $15, %edi + orl %ecx, %eax + movl 8(%esp), %ecx + movzwl %di, %edi + shll $16, %ecx + orl %ecx, %edi + movl $0, (%edx) + movl %eax, 8(%edx) + movl %edi, 12(%edx) + addl $24, %esp + popl %edi + ret + .align 16,0x90 + .type __ltoq,@function + .size __ltoq,.-__ltoq + .data +# -- End __ltoq + .section .rodata, "a" + .align 4 + .align 4 +__l_one: + .long 0 + .long 2147483648 + .long 16383 + .type __l_one,@object + .size __l_one,12 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ldexp_wmt.S b/external/sgx_libm/ia32/ldexp_wmt.S new file mode 100644 index 0000000000..3db7e3e8dd --- /dev/null +++ b/external/sgx_libm/ia32/ldexp_wmt.S @@ -0,0 +1,242 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ldexp_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin ldexp + .text + .align 16,0x90 + .globl ldexp +ldexp: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movq 64(%ebx), %xmm4 + movsd 128(%esp), %xmm0 + movsd %xmm0, 8(%esp) + movl 136(%esp), %ecx + movl $65536, %eax + movl $-65536, %edx + cmpl %eax, %ecx + cmovg %eax, %ecx + cmpl %edx, %ecx + cmovl %edx, %ecx + andpd %xmm0, %xmm4 + xorpd %xmm4, %xmm0 + ucomisd 128(%ebx), %xmm0 + jp .L_2TAG_PACKET_0.0.3 + je .L_2TAG_PACKET_0.0.3 + comisd 80(%ebx), %xmm0 + jc .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + movapd %xmm0, %xmm2 + movapd (%ebx), %xmm3 + psrlq $52, %xmm2 + movd %ecx, %xmm1 + andpd %xmm3, %xmm2 + paddq %xmm1, %xmm2 + movd %xmm2, %eax + movapd 16(%ebx), %xmm3 + testl %eax, %eax + jle .L_2TAG_PACKET_3.0.3 + cmpl $2047, %eax + jge .L_2TAG_PACKET_4.0.3 + andpd %xmm3, %xmm0 + psllq $52, %xmm2 + xorpd %xmm4, %xmm0 + orpd %xmm2, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_0.0.3: + fldl 8(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_1.0.3: + comisd 144(%ebx), %xmm0 + je .L_2TAG_PACKET_0.0.3 + mulsd 96(%ebx), %xmm0 + subl $55, %ecx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $-52, %eax + jl .L_2TAG_PACKET_6.0.3 + xorpd %xmm5, %xmm5 + andpd %xmm3, %xmm0 + shufpd $1, %xmm3, %xmm3 + paddq %xmm3, %xmm2 + xorpd %xmm4, %xmm0 + psllq $52, %xmm2 + orpd %xmm2, %xmm0 + mulsd 112(%ebx), %xmm0 + comisd %xmm5, %xmm0 + je .L_2TAG_PACKET_6.0.3 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_4.0.3: + lea 32(%ebx), %edx + movl $146, %ecx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_6.0.3: + lea 48(%ebx), %edx + movl $147, %ecx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_7.0.3: + pextrw $3, %xmm4, %eax + shrl $12, %eax + addl %edx, %eax + movq (%edx), %xmm0 + mulsd (%eax), %xmm0 + movq %xmm0, (%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 136(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %ecx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) +.L_2TAG_PACKET_5.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type ldexp,@function + .size ldexp,.-ldexp + .data +# -- End ldexp + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 2047 + .long 0 + .long 4294967241 + .long 4294967295 + .long 4294967295 + .long 2148532223 + .long 55 + .long 0 + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 1048576 + .long 0 + .long 1048576 + .long 0 + .long 1130364928 + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .long 0 + .long 1015021568 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,160 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ldexpf.S b/external/sgx_libm/ia32/ldexpf.S new file mode 100644 index 0000000000..9cfcd9f517 --- /dev/null +++ b/external/sgx_libm/ia32/ldexpf.S @@ -0,0 +1,202 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ldexpf.c" + .text +..TXTST0: +# -- Begin ldexpf + .text + .align 16,0x90 + .globl ldexpf +ldexpf: +# parameter 1: 16 + %esp +# parameter 2: 20 + %esp +..B1.1: +..L1: + + pushl %ebx + pushl %ebp + pushl %esi + movzwl 18(%esp), %eax + movl %eax, %ecx + andl $32640, %ecx + shrl $7, %ecx + movl 20(%esp), %edx + cmpl $255, %ecx + je ..B1.15 +..B1.2: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + testl %ecx, %ecx + jne ..B1.5 +..B1.3: + testl $8388607, 16(%esp) + je ..B1.9 +..B1.4: + flds 16(%esp) + fmuls .L_2il0floatpacket.0@GOTOFF(%ebx) + fstps 16(%esp) + movzwl 18(%esp), %eax + movl %eax, %ecx + andl $32640, %ecx + shrl $7, %ecx + addl $-25, %ecx +..B1.5: + cmpl $65536, %edx + jle ..L3 + movl $65536, %edx +..L3: + cmpl $-65536, %edx + jg ..L4 + movl $-65536, %edx +..L4: + lea (%ecx,%edx), %ebp + testl %ebp, %ebp + jle ..B1.11 +..B1.6: + cmpl $255, %ebp + jge ..B1.10 +..B1.7: + andl $255, %ebp + andl $-32641, %eax + shll $7, %ebp + orl %ebp, %eax + movw %ax, 18(%esp) + flds 16(%esp) +..B1.8: + popl %ecx + popl %ebp + popl %ebx + ret +..B1.9: + flds 16(%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.10: + movzbl 19(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _large_value_32@GOTOFF(%ebx,%eax,4) + fmuls .L_2il0floatpacket.1@GOTOFF(%ebx) + fsts (%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.11: + cmpl $-23, %ebp + jl ..B1.14 +..B1.12: + movl 16(%esp), %eax + lea 25(%ecx,%edx), %edx + movl %eax, (%esp) + shrl $16, %eax + movzbl %dl, %edx + andl $-32641, %eax + shll $7, %edx + orl %edx, %eax + movw %ax, 2(%esp) + flds (%esp) + fmuls .L_2il0floatpacket.3@GOTOFF(%ebx) + fsts (%esp) +..B1.13: + popl %ecx + popl %ebp + popl %ebx + ret +..B1.14: + movzbl 19(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _small_value_32@GOTOFF(%ebx,%eax,4) + fmuls .L_2il0floatpacket.2@GOTOFF(%ebx) + fsts (%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.15: + flds 16(%esp) + popl %ecx + popl %ebp + popl %ebx + ret + .align 16,0x90 + .type ldexpf,@function + .size ldexpf,.-ldexpf + .data +# -- End ldexpf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x0d800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x33000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ldexpl.S b/external/sgx_libm/ia32/ldexpl.S new file mode 100644 index 0000000000..dffdf3c60b --- /dev/null +++ b/external/sgx_libm/ia32/ldexpl.S @@ -0,0 +1,337 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ldexpl.c" + .text +..TXTST0: +# -- Begin ldexpl + .text + .align 16,0x90 + .globl ldexpl +ldexpl: +# parameter 1: 32 + %esp +# parameter 2: 44 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + pushl %ebp + subl $16, %esp + movl 44(%esp), %ebx +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 40(%esp), %eax + movl %eax, %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %ebp + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebp), %ebp + cmpl $32767, %ecx + je ..B1.43 +..B1.4: + testl %ecx, %ecx + jne ..B1.14 +..B1.5: + cmpl $0, 36(%esp) + jne ..B1.8 +..B1.6: + cmpl $0, 32(%esp) + jne ..B1.8 +..B1.7: + fldt 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.8: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.42 +..B1.9: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.10: + fldcw 12(%esp) +..B1.11: + fldt 32(%esp) + fmull _TWO_75@GOTOFF(%ebp) + fstpt 32(%esp) +..B1.12: + fldcw 14(%esp) +..B1.13: + movzwl 40(%esp), %eax + movl %eax, %ecx + andl $32767, %ecx + addl $-75, %ecx +..B1.14: + cmpl $65536, %ebx + jle ..L3 + movl $65536, %ebx +..L3: + cmpl $-65536, %ebx + jg ..L4 + movl $-65536, %ebx +..L4: + lea (%ecx,%ebx), %edi + testl %edi, %edi + jle ..B1.25 +..B1.15: + cmpl $32767, %edi + jge ..B1.17 +..B1.16: + andl $-32768, %eax + andl $32767, %edi + orl %edi, %eax + movw %ax, 40(%esp) + fldt 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.17: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.24 +..B1.18: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.19: + fldcw 12(%esp) +..B1.20: + movl $1, %ebx +..B1.21: + fldt _large_value_80@GOTOFF(%ebp) + movzbl 41(%esp), %edx + andl $128, %edx + shrl $7, %edx + testl %ebx, %ebx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%ebp,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.23 +..B1.22: + fldcw 14(%esp) +..B1.23: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.24: + xorl %ebx, %ebx + jmp ..B1.21 +..B1.25: + movzwl 14(%esp), %edx + cmpl $-63, %edi + jl ..B1.34 +..B1.26: + movl %edx, %edi + andl $768, %edi + cmpl $768, %edi + je ..B1.33 +..B1.27: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.28: + fldcw 12(%esp) +..B1.29: + movzwl 40(%esp), %eax + movl $1, %edi +..B1.30: + fldt 32(%esp) + lea 75(%ecx,%ebx), %edx + andl $-32768, %eax + andl $32767, %edx + fstpt (%esp) + orl %edx, %eax + movw %ax, 8(%esp) + testl %edi, %edi + fldt (%esp) + fmull 8+_TWO_75@GOTOFF(%ebp) + fstpt (%esp) + je ..B1.32 +..B1.31: + fldcw 14(%esp) +..B1.32: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.33: + xorl %edi, %edi + jmp ..B1.30 +..B1.34: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.41 +..B1.35: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.36: + fldcw 12(%esp) +..B1.37: + movl $1, %ebx +..B1.38: + fldt _small_value_80@GOTOFF(%ebp) + movzbl 41(%esp), %edx + andl $128, %edx + shrl $7, %edx + testl %ebx, %ebx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%ebp,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.40 +..B1.39: + fldcw 14(%esp) +..B1.40: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.41: + xorl %ebx, %ebx + jmp ..B1.38 +..B1.42: + fldt 32(%esp) + fmull _TWO_75@GOTOFF(%ebp) + fstpt 32(%esp) + jmp ..B1.13 +..B1.43: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.49 +..B1.44: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.45: + fldcw 12(%esp) +..B1.46: + fldt 32(%esp) + fmull _ones@GOTOFF(%ebp) + fstpt (%esp) +..B1.47: + fldcw 14(%esp) +..B1.48: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.49: + fldt 32(%esp) + fmull _ones@GOTOFF(%ebp) + fstpt (%esp) + jmp ..B1.48 + .align 16,0x90 + .type ldexpl,@function + .size ldexpl,.-ldexpl + .data +# -- End ldexpl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lgamma.S b/external/sgx_libm/ia32/lgamma.S new file mode 100644 index 0000000000..ef07e0fff1 --- /dev/null +++ b/external/sgx_libm/ia32/lgamma.S @@ -0,0 +1,6404 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lgamma.c" + .text +..TXTST0: +# -- Begin lgamma + .text + .align 16,0x90 + .globl lgamma +lgamma: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + subl $28, %esp + fldl 32(%esp) + lea 16(%esp), %eax + fstpl (%esp) + movl %eax, 8(%esp) + call __libm_lgamma +..B1.2: + addl $28, %esp + ret + .align 16,0x90 + .type lgamma,@function + .size lgamma,.-lgamma + .data +# -- End lgamma + .text +# -- Begin __libm_lgamma + .text + .align 16,0x90 +__libm_lgamma: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L2: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + movl 16(%ebp), %eax + movzwl 14(%ebp), %ecx + andl $32752, %ecx + movl %eax, 16(%esp) + shrl $4, %ecx + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 144(%esp) + movl 12(%ebp), %eax + movzbl 15(%ebp), %edx + andl $1048575, %eax + movl %ecx, 4(%esp) + andl $128, %edx + shll $20, %ecx + shrl $7, %edx + orl %eax, %ecx + movl %ecx, 12(%esp) + movl %edx, (%esp) +..B2.2: + fnstcw 46(%esp) +..B2.3: + call fegetround +..B2.208: + movl %eax, 28(%esp) +..B2.4: + cmpl $0, 28(%esp) + jne ..B2.6 +..B2.5: + xorl %edi, %edi + jmp ..B2.8 +..B2.6: + addl $-16, %esp + movl $0, (%esp) + call fesetround +..B2.209: + addl $16, %esp +..B2.7: + movl $1, %edi +..B2.8: + movzwl 46(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.205 +..B2.9: + orl $-64768, %edx + movw %dx, 44(%esp) +..B2.10: + fldcw 44(%esp) +..B2.11: + movl $1, %esi +..B2.12: + call ..L3 +..L3: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L3](%ebx), %ebx + cmpl $2047, 4(%esp) + jne ..B2.19 +..B2.13: + movl 16(%esp), %eax + testl %esi, %esi + movl $1, (%eax) + je ..B2.15 +..B2.14: + fldcw 46(%esp) +..B2.15: + testl %edi, %edi + je ..B2.17 +..B2.16: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.210: + addl $16, %esp +..B2.17: + fldl 8(%ebp) + movl 144(%esp), %eax + xorl %esp, %eax + fmul %st(0), %st + cmpl %gs:20, %eax + jne ..B2.99 +..B2.18: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.19: + cmpl $0, 4(%esp) + jne ..B2.24 +..B2.20: + testl $1048575, 12(%ebp) + jne ..B2.24 +..B2.21: + cmpl $0, 8(%ebp) + je ..B2.100 +..B2.24: + movl 16(%esp), %eax + movl $1, (%eax) +..B2.25: + cmpl $0, (%esp) + je ..B2.126 +..B2.26: + fldl 8(%ebp) + addl $-16, %esp + fstpl (%esp) + call nearbyint@PLT +..B2.211: + fldl 8(%ebp) + addl $16, %esp + fxch %st(1) + fstpl 112(%esp) + fldl 112(%esp) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.27 + je ..B2.119 +..B2.27: + fldl .L_2il0floatpacket.0@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jae ..B2.244 + jp ..B2.244 +..B2.28: + fld %st(1) + frndint + fcom %st(2) + fnstsw %ax + sahf + jnb ..L4 + fld1 + faddp %st, %st(1) +..L4: + fstpl 112(%esp) + fldl 112(%esp) + faddp %st, %st(1) + fstpl 112(%esp) + testb $1, 112(%esp) + jne ..B2.31 +..B2.29: + movl 16(%esp), %eax + movl $-1, (%eax) + jmp ..B2.31 +..B2.244: + fstp %st(0) +..B2.31: + cmpl $1073741824, 12(%esp) + jae ..B2.43 +..B2.32: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.111 +..B2.33: + fld %st(0) +..B2.34: + fmul %st(2), %st + fxch %st(1) + fadd %st, %st(2) + fcom %st(2) + fnstsw %ax + sahf + fxch %st(1) + ja ..B2.34 +..B2.35: + fstp %st(1) + fstpt 72(%esp) +..B2.36: + andb $127, 81(%esp) + addl $-16, %esp + fldt 88(%esp) + fstpt (%esp) + fstpt 104(%esp) + call logl@PLT +..B2.213: + fldt 104(%esp) + addl $16, %esp + fxch %st(1) + fstpt 72(%esp) + fldt 72(%esp) + addl $-16, %esp + fxch %st(1) + fstpt (%esp) + fstpt 16(%esp) + call lgamma_pos +..B2.212: + fldt 16(%esp) + addl $16, %esp + testl %edi, %edi + je ..B2.39 +..B2.37: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.214: + fldt 16(%esp) + addl $16, %esp +..B2.38: + fldt 72(%esp) +..B2.39: + testl %esi, %esi + fsubrp %st, %st(1) + fstpl 112(%esp) + je ..B2.41 +..B2.40: + fldcw 46(%esp) +..B2.41: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.42: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.43: + cmpl $1076756480, 12(%esp) + jae ..B2.73 +..B2.44: + fldl _TWO_52H@GOTOFF(%ebx) + fld %st(1) + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + fxch %st(1) + faddl .L_2il0floatpacket.3@GOTOFF(%ebx) + fstpl 64(%esp) + fldl 64(%esp) + fsubr %st(2), %st + fstpl 112(%esp) + fldl 112(%esp) + movl 112(%esp), %ecx + fsubp %st, %st(2) + fxch %st(1) + fstpl 112(%esp) + lea 1(%ecx), %edx + fldl 112(%esp) + fldl 64(%esp) + faddp %st, %st(1) + fcompp + fnstsw %ax + sahf + jp ..L6 + jb ..L5 +..L6: + movl %ecx, %edx +..L5: + lea (%edx,%edx,2), %ecx + fcoml _LRIB@GOTOFF(%ebx,%ecx,8) + fnstsw %ax + sahf + jbe ..B2.53 +..B2.45: + fldl 16+_LRIB@GOTOFF(%ebx,%ecx,8) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.53 +..B2.46: + fldl _LRP16@GOTOFF(%ebx,%edx,8) + fxch %st(1) + fsubl 8+_LRIB@GOTOFF(%ebx,%ecx,8) + shll $6, %ecx + fld %st(0) + testl %edi, %edi + fmul %st(1), %st + fmul %st, %st(2) + fldt 64+_LRP@GOTOFF(%ecx,%ebx) + fldt 32+_LRP@GOTOFF(%ecx,%ebx) + fldt _LRP@GOTOFF(%ecx,%ebx) + fldt 48+_LRP@GOTOFF(%ecx,%ebx) + fldt 16+_LRP@GOTOFF(%ecx,%ebx) + fxch %st(7) + faddl 152+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(5), %st + faddl 136+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(5), %st + faddl 120+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(5), %st + faddl 104+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(5), %st + faddl 88+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fldl 160+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(3), %st + faddl 144+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(3), %st + faddl 128+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(3), %st + faddl 112+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(3), %st + faddl 96+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(3), %st + faddl 80+_LRP@GOTOFF(%ecx,%ebx) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + je ..B2.49 +..B2.47: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.215: + addl $16, %esp +..B2.48: + fldt 72(%esp) +..B2.49: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstpl 112(%esp) + je ..B2.51 +..B2.50: + fldcw 46(%esp) +..B2.51: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.52: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.53: + fcoml _RRIB@GOTOFF(%ebx,%ecx,8) + fnstsw %ax + sahf + jbe ..B2.62 +..B2.54: + fldl 16+_RRIB@GOTOFF(%ebx,%ecx,8) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.62 +..B2.55: + fsubl 8+_RRIB@GOTOFF(%ebx,%ecx,8) + fld %st(0) + lea (%edx,%edx,4), %eax + shll $5, %eax + fmul %st(1), %st + testl %edi, %edi + fldl 72+_RRP@GOTOFF(%eax,%ebx) + fmul %st(1), %st + fldt 32+_RRP@GOTOFF(%eax,%ebx) + fldt _RRP@GOTOFF(%eax,%ebx) + fldl 64+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 120+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 112+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 88+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 80+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 136+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 128+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 104+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 96+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + fxch %st(3) + faddl 152+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fldt 48+_RRP@GOTOFF(%eax,%ebx) + fldt 16+_RRP@GOTOFF(%eax,%ebx) + fxch %st(3) + faddl 144+_RRP@GOTOFF(%eax,%ebx) + fmul %st(4), %st + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fstpt (%esp) + je ..B2.58 +..B2.56: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.216: + addl $16, %esp +..B2.57: + fldt 72(%esp) +..B2.58: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstpl 112(%esp) + je ..B2.60 +..B2.59: + fldcw 46(%esp) +..B2.60: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.61: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.62: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.115 +..B2.63: + fld %st(0) +..B2.64: + fmul %st(2), %st + fxch %st(1) + fadd %st, %st(2) + fcom %st(2) + fnstsw %ax + sahf + fxch %st(1) + ja ..B2.64 +..B2.65: + fstp %st(1) + fstpt 72(%esp) +..B2.66: + andb $127, 81(%esp) + addl $-16, %esp + fldt 88(%esp) + fstpt (%esp) + fstpt 104(%esp) + call logl@PLT +..B2.218: + fldt 104(%esp) + addl $16, %esp + fxch %st(1) + fstpt 72(%esp) + fldt 72(%esp) + addl $-16, %esp + fxch %st(1) + fstpt (%esp) + fstpt 16(%esp) + call lgamma_pos +..B2.217: + fldt 16(%esp) + addl $16, %esp + testl %edi, %edi + je ..B2.69 +..B2.67: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.219: + fldt 16(%esp) + addl $16, %esp +..B2.68: + fldt 72(%esp) +..B2.69: + testl %esi, %esi + fsubrp %st, %st(1) + fstpl 112(%esp) + je ..B2.71 +..B2.70: + fldcw 46(%esp) +..B2.71: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.72: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.73: + cmpl $1076953088, 12(%esp) + jae ..B2.84 +..B2.74: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fstpt 120(%esp) + fldt 120(%esp) + fcom %st(1) + fnstsw %ax + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + fstpt 132(%esp) + fldt 132(%esp) + sahf + jbe ..B2.245 +..B2.75: + fldt .L_2il0floatpacket.5@GOTOFF(%ebx) + fstpt 16(%esp) + fstpt (%esp) + .align 16,0x90 +..B2.76: + fldt (%esp) + fstp %st(0) + fld %st(1) + fxch %st(2) + fldt 16(%esp) + fld %st(0) + fmul %st(2), %st + fadd %st, %st(4) + fxch %st(4) + fstpt 100(%esp) + fldt 100(%esp) + fsubp %st, %st(4) + fld %st(1) + fsub %st(4), %st + fxch %st(2) + fadd %st(3), %st + fcom %st(3) + fnstsw %ax + fldt 120(%esp) + fmul %st, %st(2) + fld %st(0) + sahf + fadd %st(3), %st + fstpt 100(%esp) + fldt 132(%esp) + fldt 100(%esp) + fsubp %st, %st(4) + fxch %st(1) + fsub %st(3), %st + faddp %st, %st(1) + fld %st(3) + fmul %st(1), %st + fld %st(6) + fmul %st(4), %st + fxch %st(2) + fmulp %st, %st(7) + faddp %st, %st(6) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fadd %st(2), %st + fstpt 120(%esp) + fldt 120(%esp) + fsubp %st, %st(2) + fxch %st(3) + fsubp %st, %st(1) + fstpt 132(%esp) + jp ..B2.77 + jb ..B2.76 +..B2.77: + fstp %st(0) +..B2.78: + andb $127, 129(%esp) + addl $-16, %esp + fldt 136(%esp) + fstpt (%esp) + fstpt 104(%esp) + call logl@PLT +..B2.221: + fldt 104(%esp) + fxch %st(1) + fstpt 32(%esp) + fstpt (%esp) + call lgamma_pos +..B2.220: + addl $16, %esp + testl %edi, %edi + je ..B2.80 +..B2.79: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.222: + fldt 16(%esp) + addl $16, %esp +..B2.80: + fldt 16(%esp) + testl %esi, %esi + fsubrp %st, %st(1) + fstpl 112(%esp) + je ..B2.82 +..B2.81: + fldcw 46(%esp) +..B2.82: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.83: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.84: + cmpl $1082130432, 12(%esp) + jb ..B2.92 +..B2.85: + fldt _LN_SQRT_TWO_PI@GOTOFF(%ebx) + fstpt (%esp) + addl $-16, %esp + fld %st(0) + fchs + fstpt (%esp) + fldt (%esp) + fstpt 32(%esp) + fstpt 104(%esp) + fldt 104(%esp) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fsubrp %st, %st(1) + fstpt 64(%esp) + call logl@PLT +..B2.223: + fldt 104(%esp) + fldt 64(%esp) + fmulp %st, %st(2) + fldt 32(%esp) + addl $16, %esp + fldt (%esp) + testl %edi, %edi + fsubrp %st, %st(3) + fxch %st(1) + fsubr %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fdiv %st(1), %st + fld %st(0) + fmul %st(1), %st + fmull _W4@GOTOFF(%ebx) + fldt _W2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl _TWO_52H@GOTOFF(%ebx) + fstl 112(%esp) + fldl 112(%esp) + fsubp %st, %st(2) + fxch %st(1) + fstpl 112(%esp) + fldl 112(%esp) + fsubp %st, %st(1) + fstpl 112(%esp) + fldl 112(%esp) + fsubrp %st, %st(1) + fstpt 32(%esp) + fldt 32(%esp) + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fldl _S26@GOTOFF(%ebx) + fmul %st(1), %st + fldt _S10@GOTOFF(%ebx) + fldt _S06@GOTOFF(%ebx) + fldt _S02@GOTOFF(%ebx) + fldl _S28@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl _S22@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl _S24@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl _S18@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl _S20@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl _S14@GOTOFF(%ebx) + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(3) + faddl _S16@GOTOFF(%ebx) + fmul %st(1), %st + fldt _S12@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _S08@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _S04@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 72(%esp) + fldt 72(%esp) + je ..B2.88 +..B2.86: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + fstpt 64(%esp) + call fesetround +..B2.224: + fldt 64(%esp) + addl $16, %esp +..B2.87: + fldt 72(%esp) +..B2.88: + andb $127, 41(%esp) + addl $-16, %esp + fldt 48(%esp) + fstpt (%esp) + fsubrp %st, %st(1) + fstpt 64(%esp) + call logl@PLT +..B2.225: + fldt 64(%esp) + addl $16, %esp + testl %esi, %esi + fsubp %st, %st(1) + fstpl 112(%esp) + je ..B2.90 +..B2.89: + fldcw 46(%esp) +..B2.90: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.91: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.92: + fldl _TWO_52H@GOTOFF(%ebx) + fstl 112(%esp) + fldl 112(%esp) + fsub %st(2), %st + fstpl 112(%esp) + fxch %st(1) + fchs + fldl 112(%esp) + fsubp %st, %st(2) + fxch %st(1) + fstpl 112(%esp) + fldl 112(%esp) + fsubr %st(1), %st + fstpt 32(%esp) + fldt 32(%esp) + fmul %st(0), %st + fstpt (%esp) + addl $-16, %esp + fstpt (%esp) + call logl@PLT +..B2.227: + fchs + fldl 8(%ebp) + fchs + fstpt (%esp) + fstpt 32(%esp) + call lgamma_pos +..B2.226: + fldt 32(%esp) + addl $16, %esp + fldt (%esp) + testl %edi, %edi + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fldl _S26@GOTOFF(%ebx) + fmul %st(1), %st + fldt _S10@GOTOFF(%ebx) + fldt _S06@GOTOFF(%ebx) + fldt _S02@GOTOFF(%ebx) + fldt _S12@GOTOFF(%ebx) + fxch %st(4) + faddl _S22@GOTOFF(%ebx) + fmul %st(5), %st + faddl _S18@GOTOFF(%ebx) + fmul %st(5), %st + faddl _S14@GOTOFF(%ebx) + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(4) + fldl _S28@GOTOFF(%ebx) + fmul %st(2), %st + fldt _S08@GOTOFF(%ebx) + fldt _S04@GOTOFF(%ebx) + fxch %st(2) + faddl _S24@GOTOFF(%ebx) + fmul %st(4), %st + faddl _S20@GOTOFF(%ebx) + fmul %st(4), %st + faddl _S16@GOTOFF(%ebx) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 72(%esp) + fldt 72(%esp) + je ..B2.95 +..B2.93: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + fstpt 32(%esp) + call fesetround +..B2.228: + fldt 32(%esp) + addl $16, %esp +..B2.94: + fldt 72(%esp) +..B2.95: + andb $127, 41(%esp) + addl $-16, %esp + fldt 48(%esp) + fstpt (%esp) + fsubrp %st, %st(1) + fstpt 32(%esp) + call logl@PLT +..B2.229: + fldt 32(%esp) + addl $16, %esp + testl %esi, %esi + fsubp %st, %st(1) + fstpl 112(%esp) + je ..B2.97 +..B2.96: + fldcw 46(%esp) +..B2.97: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.98: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.99: + fstp %st(0) + call __stack_chk_fail@PLT +..B2.100: + cmpl $0, (%esp) + je ..B2.102 +..B2.101: + movl 16(%esp), %eax + movl $-1, (%eax) + jmp ..B2.103 +..B2.102: + movl 16(%esp), %eax + movl $1, (%eax) +..B2.103: + testl %edi, %edi + je ..B2.105 +..B2.104: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.230: + addl $16, %esp +..B2.105: + fld1 + fldz + testl %esi, %esi + fstpl 112(%esp) + fldl 112(%esp) + fdivrp %st, %st(1) + fstpl 112(%esp) + je ..B2.107 +..B2.106: + fldcw 46(%esp) +..B2.107: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 + jmp ..B2.18 +..B2.111: + fstpt 72(%esp) + jmp ..B2.36 +..B2.115: + fstpt 72(%esp) + jmp ..B2.66 +..B2.119: + fstp %st(0) + testl %edi, %edi + je ..B2.121 +..B2.120: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.231: + addl $16, %esp +..B2.121: + fld1 + fldz + testl %esi, %esi + fstpl 112(%esp) + fldl 112(%esp) + fdivrp %st, %st(1) + fstpl 112(%esp) + je ..B2.123 +..B2.122: + fldcw 46(%esp) +..B2.123: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 + jmp ..B2.18 +..B2.126: + movzwl 14(%ebp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2037, %eax + jg ..B2.198 +..B2.127: + je ..B2.195 +..B2.128: + fldl 8(%ebp) + fld1 + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.129 + je ..B2.188 +..B2.129: + cmpl $1032, 4(%esp) + jb ..B2.136 +..B2.130: + fldt _LN_SQRT_TWO_PI@GOTOFF(%ebx) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fsubr %st(2), %st + fstpt (%esp) + addl $-16, %esp + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fxch %st(1) + fstpt 48(%esp) + fstpt 32(%esp) + call logl@PLT +..B2.232: + fldt 32(%esp) + fldt 48(%esp) + addl $16, %esp + fldt (%esp) + testl %edi, %edi + fmulp %st, %st(3) + faddp %st, %st(2) + fsubr %st, %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fdivp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fmull _W4@GOTOFF(%ebx) + fldt _W2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + je ..B2.132 +..B2.131: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 48(%esp) + call fesetround +..B2.233: + fldt 48(%esp) + fldt 16(%esp) + addl $16, %esp +..B2.132: + testl %esi, %esi + faddp %st, %st(1) + fstpl 112(%esp) + je ..B2.134 +..B2.133: + fldcw 46(%esp) +..B2.134: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.135: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.136: + cmpl $1025, 4(%esp) + jb ..B2.143 +..B2.137: + movl 4(%esp), %eax + fsubl -8200+_A@GOTOFF(%ebx,%eax,8) + fmull -8200+_B@GOTOFF(%ebx,%eax,8) + lea -9225(%eax,%eax,8), %edx + shll $5, %edx + fld %st(0) + fmul %st(1), %st + testl %edi, %edi + fldt 12+_C5@GOTOFF(%edx,%ebx) + fmul %st(2), %st + fadd %st(1), %st + fldt _C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fldt 36+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 24+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 60+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 48+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 84+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 72+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 108+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 96+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 132+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 120+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 156+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 144+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 180+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 168+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 204+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 192+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 228+_C5@GOTOFF(%edx,%ebx) + fmul %st(3), %st + fadd %st(2), %st + fldt 216+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 252+_C5@GOTOFF(%edx,%ebx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 240+_C5@GOTOFF(%edx,%ebx) + faddp %st, %st(1) + fmul %st, %st(1) + fxch %st(1) + fstpt 8(%esp) + fstpt 72(%esp) + je ..B2.139 +..B2.138: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + movl %edx, 16(%esp) + call fesetround +..B2.234: + movl 16(%esp), %edx + addl $16, %esp +..B2.139: + fldt 264+_C5@GOTOFF(%edx,%ebx) + testl %esi, %esi + fldt 8(%esp) + fmulp %st, %st(1) + fstpl 112(%esp) + je ..B2.141 +..B2.140: + fldcw 46(%esp) +..B2.141: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.142: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.143: + cmpl $1073872896, 12(%esp) + jb ..B2.150 +..B2.144: + fldt 12+_C4@GOTOFF(%ebx) + testl %edi, %edi + fmul %st(1), %st + fld %st(1) + fmul %st(2), %st + fadd %st, %st(1) + fldt _C4@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 36+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 24+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 60+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 48+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 84+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 72+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 108+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 96+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 132+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 120+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 156+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 144+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 180+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 168+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 204+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 192+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 228+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st(1), %st + fldt 216+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 252+_C4@GOTOFF(%ebx) + fmul %st(3), %st + faddp %st, %st(1) + fldt 240+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st, %st(1) + fstpt 72(%esp) + fldt 264+_C4@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B2.146 +..B2.145: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + fstpt 32(%esp) + call fesetround +..B2.235: + fldt 32(%esp) + addl $16, %esp +..B2.146: + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + testl %esi, %esi + fsubrp %st, %st(1) + fldt (%esp) + fmulp %st, %st(1) + fstpl 112(%esp) + je ..B2.148 +..B2.147: + fldcw 46(%esp) +..B2.148: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.149: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.150: + cmpl $1073479680, 12(%esp) + jb ..B2.158 +..B2.151: + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + testl %edi, %edi + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 168+_C3@GOTOFF(%ebx) + fmul %st(1), %st + fldl 160+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 152+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 144+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 136+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 128+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 120+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 112+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 104+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 96+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 88+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 80+_C3@GOTOFF(%ebx) + fmul %st(2), %st + fldt 64+_C3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 32+_C3@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _C3@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + fstpt 72(%esp) + fldt 72(%esp) + fldt 48+_C3@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 16+_C3@GOTOFF(%ebx) + faddp %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + je ..B2.154 +..B2.152: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.236: + addl $16, %esp +..B2.153: + fldt 72(%esp) +..B2.154: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstpl 112(%esp) + je ..B2.156 +..B2.155: + fldcw 46(%esp) +..B2.156: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.157: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.158: + cmpl $1072955392, 12(%esp) + jb ..B2.166 +..B2.159: + fldt _LM@GOTOFF(%ebx) + testl %edi, %edi + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 184+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(1), %st + fldt 80+_LGAMMA_C2@GOTOFF(%ebx) + fldt 48+_LGAMMA_C2@GOTOFF(%ebx) + fldt 16+_LGAMMA_C2@GOTOFF(%ebx) + fldt 32+_LGAMMA_C2@GOTOFF(%ebx) + fldt _LGAMMA_C2@GOTOFF(%ebx) + fxch %st(5) + faddl 168+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(6), %st + faddl 152+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(6), %st + faddl 136+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(6), %st + faddl 120+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(6), %st + faddl 104+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fmulp %st, %st(4) + fxch %st(3) + fstpt 72(%esp) + fldt 72(%esp) + fldl 176+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(3), %st + fldt 64+_LGAMMA_C2@GOTOFF(%ebx) + fxch %st(1) + faddl 160+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(4), %st + faddl 144+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(4), %st + faddl 128+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(4), %st + faddl 112+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(4), %st + faddl 96+_LGAMMA_C2@GOTOFF(%ebx) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + je ..B2.162 +..B2.160: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.237: + addl $16, %esp +..B2.161: + fldt 72(%esp) +..B2.162: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstpl 112(%esp) + je ..B2.164 +..B2.163: + fldcw 46(%esp) +..B2.164: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.165: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.166: + cmpl $1072431104, 12(%esp) + jb ..B2.174 +..B2.167: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + testl %edi, %edi + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 168+_C1@GOTOFF(%ebx) + fmul %st(1), %st + fldl 160+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 152+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 144+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 136+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 128+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 120+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 112+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 104+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 96+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 88+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 80+_C1@GOTOFF(%ebx) + fmul %st(2), %st + fldt 64+_C1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 32+_C1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _C1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + fstpt 72(%esp) + fldt 72(%esp) + fldt 48+_C1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 16+_C1@GOTOFF(%ebx) + faddp %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + je ..B2.170 +..B2.168: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.238: + addl $16, %esp +..B2.169: + fldt 72(%esp) +..B2.170: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstpl 112(%esp) + je ..B2.172 +..B2.171: + fldcw 46(%esp) +..B2.172: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.173: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.174: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + addl $-16, %esp + fadd %st(1), %st + fstpt (%esp) + fstpt 32(%esp) + call lgamma_pos +..B2.240: + fldt 32(%esp) + fxch %st(1) + fstpt 16(%esp) + fstpt (%esp) + call logl@PLT +..B2.239: + addl $16, %esp + fstpt 72(%esp) + fldt 72(%esp) + testl %edi, %edi + je ..B2.177 +..B2.175: + fstp %st(0) + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.241: + addl $16, %esp +..B2.176: + fldt 72(%esp) +..B2.177: + fldt (%esp) + testl %esi, %esi + fsubp %st, %st(1) + fstpl 112(%esp) + je ..B2.179 +..B2.178: + fldcw 46(%esp) +..B2.179: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 +..B2.180: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.188: + fstp %st(0) + testl %esi, %esi + je ..B2.190 +..B2.189: + fldcw 46(%esp) +..B2.190: + testl %edi, %edi + je ..B2.192 +..B2.191: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.242: + addl $16, %esp +..B2.192: + movl 144(%esp), %eax + fldz + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 + jmp ..B2.18 +..B2.195: + movl 12(%ebp), %eax + andl $1048575, %eax + cmpl $480473, %eax + jg ..B2.198 +..B2.196: + jne ..B2.128 +..B2.197: + cmpl $663441831, 8(%ebp) + jbe ..B2.128 +..B2.198: + testl %edi, %edi + je ..B2.200 +..B2.199: + addl $-16, %esp + movl 44(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.243: + addl $16, %esp +..B2.200: + fldl _PBIG@GOTOFF(%ebx) + testl %esi, %esi + fmul %st(0), %st + fstpl 112(%esp) + je ..B2.202 +..B2.201: + fldcw 46(%esp) +..B2.202: + fldl 112(%esp) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.99 + jmp ..B2.18 +..B2.205: + xorl %esi, %esi + jmp ..B2.12 +..B2.245: + fstp %st(1) + fstp %st(0) + jmp ..B2.78 + .align 16,0x90 + .type __libm_lgamma,@function + .size __libm_lgamma,.-__libm_lgamma + .data +# -- End __libm_lgamma + .text +# -- Begin lgamma_pos + .text + .align 16,0x90 +lgamma_pos: +# parameter 1: 8 + %ebp +..B3.1: +..L7: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp + fldt 8(%ebp) + fstl (%esp) + movzwl 6(%esp), %ecx + andl $32752, %ecx + shrl $4, %ecx + movl 4(%esp), %edx + shll $20, %ecx + andl $1048575, %edx + orl %edx, %ecx + call ..L8 +..L8: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L8](%eax), %eax + cmpl $1074790400, %ecx + jb ..B3.3 +..B3.2: + addl $-1074790400, %ecx + sarl $20, %ecx + fldl _A@GOTOFF(%eax,%ecx,8) + lea (%ecx,%ecx,8), %edx + shll $5, %edx + fsubrp %st, %st(1) + fmull _B@GOTOFF(%eax,%ecx,8) + fld %st(0) + fmul %st(1), %st + fldt 12+_C5@GOTOFF(%eax,%edx) + fmul %st(2), %st + fadd %st(1), %st + fldt 36+_C5@GOTOFF(%eax,%edx) + fmul %st(3), %st + fadd %st(2), %st + fldt 24+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fldt 60+_C5@GOTOFF(%eax,%edx) + fmul %st(4), %st + fadd %st(3), %st + fldt 48+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fldt 84+_C5@GOTOFF(%eax,%edx) + fmul %st(5), %st + fadd %st(4), %st + fldt 108+_C5@GOTOFF(%eax,%edx) + fmul %st(6), %st + fadd %st(5), %st + fldt _C5@GOTOFF(%edx,%eax) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + fldt 72+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 96+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 132+_C5@GOTOFF(%eax,%edx) + fmul %st(3), %st + fadd %st(2), %st + fldt 120+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 156+_C5@GOTOFF(%eax,%edx) + fmul %st(3), %st + fadd %st(2), %st + fldt 144+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 180+_C5@GOTOFF(%eax,%edx) + fmul %st(3), %st + fadd %st(2), %st + fldt 168+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 204+_C5@GOTOFF(%eax,%edx) + fmul %st(3), %st + fadd %st(2), %st + fldt 192+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 228+_C5@GOTOFF(%eax,%edx) + fmul %st(3), %st + fadd %st(2), %st + fldt 216+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 252+_C5@GOTOFF(%eax,%edx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 240+_C5@GOTOFF(%eax,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 264+_C5@GOTOFF(%eax,%edx) + fmulp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.3: + cmpl $1073872896, %ecx + jb ..B3.5 +..B3.4: + fldt 12+_C4@GOTOFF(%eax) + fmul %st(1), %st + fld %st(1) + fmul %st(2), %st + fadd %st, %st(1) + fldt _C4@GOTOFF(%eax) + faddp %st, %st(2) + fldt 36+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 24+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 60+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 48+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 84+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 72+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 108+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 96+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 132+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 120+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 156+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 144+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 180+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 168+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 204+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 192+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 228+_C4@GOTOFF(%eax) + fmul %st(3), %st + fadd %st(1), %st + fldt 216+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 252+_C4@GOTOFF(%eax) + fmul %st(3), %st + faddp %st, %st(1) + fldt 240+_C4@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 264+_C4@GOTOFF(%eax) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.6@GOTOFF(%eax) + fsubrp %st, %st(2) + fmulp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.5: + cmpl $1073479680, %ecx + jb ..B3.7 +..B3.6: + fldt .L_2il0floatpacket.6@GOTOFF(%eax) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 160+_C3@GOTOFF(%eax) + fmul %st(1), %st + fldt 48+_C3@GOTOFF(%eax) + fldt 16+_C3@GOTOFF(%eax) + fldt 64+_C3@GOTOFF(%eax) + fldt 32+_C3@GOTOFF(%eax) + fldt _C3@GOTOFF(%eax) + fxch %st(5) + faddl 144+_C3@GOTOFF(%eax) + fmul %st(6), %st + faddl 128+_C3@GOTOFF(%eax) + fmul %st(6), %st + faddl 112+_C3@GOTOFF(%eax) + fmul %st(6), %st + faddl 96+_C3@GOTOFF(%eax) + fmul %st(6), %st + faddl 80+_C3@GOTOFF(%eax) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldl 168+_C3@GOTOFF(%eax) + fmul %st(5), %st + faddl 152+_C3@GOTOFF(%eax) + fmul %st(5), %st + faddl 136+_C3@GOTOFF(%eax) + fmul %st(5), %st + faddl 120+_C3@GOTOFF(%eax) + fmul %st(5), %st + faddl 104+_C3@GOTOFF(%eax) + fmul %st(5), %st + faddl 88+_C3@GOTOFF(%eax) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.7: + cmpl $1072955392, %ecx + jb ..B3.9 +..B3.8: + fldt _LM@GOTOFF(%eax) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 176+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(1), %st + fldt 64+_LGAMMA_C2@GOTOFF(%eax) + fldt 32+_LGAMMA_C2@GOTOFF(%eax) + fldt _LGAMMA_C2@GOTOFF(%eax) + fldt 48+_LGAMMA_C2@GOTOFF(%eax) + fldt 80+_LGAMMA_C2@GOTOFF(%eax) + fxch %st(5) + faddl 160+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(6), %st + faddl 144+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(6), %st + faddl 128+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(6), %st + faddl 112+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(6), %st + faddl 96+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fldl 184+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(4), %st + faddl 168+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(4), %st + faddl 152+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(4), %st + faddl 136+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(4), %st + faddl 120+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(4), %st + faddl 104+_LGAMMA_C2@GOTOFF(%eax) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 16+_LGAMMA_C2@GOTOFF(%eax) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.9: + cmpl $1072431104, %ecx + jb ..B3.11 +..B3.10: + fldt .L_2il0floatpacket.1@GOTOFF(%eax) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 160+_C1@GOTOFF(%eax) + fmul %st(1), %st + fldt 48+_C1@GOTOFF(%eax) + fldt 16+_C1@GOTOFF(%eax) + fldt 64+_C1@GOTOFF(%eax) + fldt 32+_C1@GOTOFF(%eax) + fldt _C1@GOTOFF(%eax) + fxch %st(5) + faddl 144+_C1@GOTOFF(%eax) + fmul %st(6), %st + faddl 128+_C1@GOTOFF(%eax) + fmul %st(6), %st + faddl 112+_C1@GOTOFF(%eax) + fmul %st(6), %st + faddl 96+_C1@GOTOFF(%eax) + fmul %st(6), %st + faddl 80+_C1@GOTOFF(%eax) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldl 168+_C1@GOTOFF(%eax) + fmul %st(5), %st + faddl 152+_C1@GOTOFF(%eax) + fmul %st(5), %st + faddl 136+_C1@GOTOFF(%eax) + fmul %st(5), %st + faddl 120+_C1@GOTOFF(%eax) + fmul %st(5), %st + faddl 104+_C1@GOTOFF(%eax) + fmul %st(5), %st + faddl 88+_C1@GOTOFF(%eax) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.11: + fstp %st(0) + fldz +..B3.12: + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type lgamma_pos,@function + .size lgamma_pos,.-lgamma_pos + .data +# -- End lgamma_pos + .text +# -- Begin gamma + .text + .align 16,0x90 + .globl gamma +gamma: +# parameter 1: 32 + %esp +..B4.1: +..L9: + + subl $28, %esp + fldl 32(%esp) + lea 16(%esp), %eax + fstpl (%esp) + movl %eax, 8(%esp) + call __libm_lgamma +..B4.2: + addl $28, %esp + ret + .align 16,0x90 + .type gamma,@function + .size gamma,.-gamma + .data +# -- End gamma + .text +# -- Begin lgamma_r + .text + .align 16,0x90 + .globl lgamma_r +lgamma_r: +# parameter 1: 4 + %esp +# parameter 2: 12 + %esp +..B5.1: +..L10: + + jmp __libm_lgamma + .align 16,0x90 + .type lgamma_r,@function + .size lgamma_r,.-lgamma_r + .data +# -- End lgamma_r + .text +# -- Begin gamma_r + .text + .align 16,0x90 + .globl gamma_r +gamma_r: +# parameter 1: 4 + %esp +# parameter 2: 12 + %esp +..B6.1: +..L11: + + jmp __libm_lgamma + .align 16,0x90 + .type gamma_r,@function + .size gamma_r,.-gamma_r + .data +# -- End gamma_r + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .space 4, 0x00 # pad + .align 16 +_LRIB: + .long 3639930760 + .long 3221638968 + .long 169597185 + .long 3221617473 + .long 994230906 + .long 3221595977 + .long 249193764 + .long 3222253755 + .long 1417424869 + .long 3222250609 + .long 2585655974 + .long 3222247463 + .long 679699934 + .long 3222534303 + .long 2054089469 + .long 3222533975 + .long 3428479004 + .long 3222533647 + .long 1666697798 + .long 3222798023 + .long 4119983117 + .long 3222797970 + .long 2278301140 + .long 3222797918 + .long 753528318 + .long 3223060435 + .long 4151019248 + .long 3223060427 + .long 3253542882 + .long 3223060420 + .long 1221915992 + .long 3223322618 + .long 2139183567 + .long 3223322617 + .long 3056451142 + .long 3223322616 + .long 2968798493 + .long 3223453695 + .long 2743618512 + .long 3223453695 + .long 2518438531 + .long 3223453695 + .long 4156721779 + .long 3223584767 + .long 4139833280 + .long 3223584767 + .long 4122944781 + .long 3223584767 + .long 4282834537 + .long 3223715839 + .long 4280864212 + .long 3223715839 + .long 4278893887 + .long 3223715839 + .long 4293918703 + .long 3223846911 + .long 4293792039 + .long 3223846911 + .long 4293665375 + .long 3223846911 + .long 4294888151 + .long 3223977983 + .long 4294876892 + .long 3223977983 + .long 4294865633 + .long 3223977983 + .long 4294961261 + .long 3224109055 + .long 4294960839 + .long 3224109055 + .long 4294960417 + .long 3224109055 + .long 4294966894 + .long 3224240127 + .long 4294966866 + .long 3224240127 + .long 4294966838 + .long 3224240127 + .type _LRIB,@object + .size _LRIB,312 + .space 8, 0x00 # pad + .align 16 +_LRP16: + .long 2378050348 + .long 1101969305 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .type _LRP16,@object + .size _LRP16,104 + .space 8, 0x00 # pad + .align 16 +_LRP: + .word 17751 + .word 54196 + .word 10629 + .word 51164 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 41133 + .word 9612 + .word 27976 + .word 62729 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 42459 + .word 13010 + .word 63969 + .word 39219 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 65437 + .word 25696 + .word 54808 + .word 41154 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 58026 + .word 20377 + .word 22118 + .word 64130 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 35937 + .word 22559 + .word 22660 + .word 49256 + .word 8259 + .word 31940 + .word 14143 + .word 16516 + .word 36722 + .word 48879 + .word 8761 + .word 49313 + .word 17702 + .word 59215 + .word 47717 + .word 16573 + .word 13453 + .word 50588 + .word 11555 + .word 49370 + .word 8896 + .word 4195 + .word 22549 + .word 16631 + .word 8306 + .word 47544 + .word 1832 + .word 49429 + .word 60153 + .word 61869 + .word 6523 + .word 16691 + .word 63612 + .word 2764 + .word 26286 + .word 49489 + .word 63356 + .word 31621 + .word 64278 + .word 16751 + .word 24055 + .word 64192 + .word 21464 + .word 49552 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49769 + .word 49242 + .word 6580 + .word 61152 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 7708 + .word 25266 + .word 60595 + .word 42444 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 45975 + .word 8629 + .word 62832 + .word 64438 + .word 16390 + .word 0 + .word 0 + .word 0 + .word 39855 + .word 22905 + .word 44266 + .word 59689 + .word 49162 + .word 0 + .word 0 + .word 0 + .word 10240 + .word 41089 + .word 5368 + .word 62588 + .word 16398 + .word 0 + .word 0 + .word 0 + .word 3194 + .word 32877 + .word 5879 + .word 49457 + .word 40173 + .word 43959 + .word 59635 + .word 16755 + .word 53371 + .word 1664 + .word 56254 + .word 49591 + .word 34510 + .word 44659 + .word 12150 + .word 16893 + .word 33872 + .word 42862 + .word 8799 + .word 49730 + .word 10662 + .word 44157 + .word 53571 + .word 17030 + .word 55074 + .word 58798 + .word 65525 + .word 49868 + .word 1276 + .word 34610 + .word 36363 + .word 17170 + .word 7041 + .word 29575 + .word 61144 + .word 50007 + .word 19121 + .word 53977 + .word 34010 + .word 17312 + .word 54457 + .word 12310 + .word 48419 + .word 50149 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55737 + .word 12115 + .word 42602 + .word 40775 + .word 16337 + .word 0 + .word 0 + .word 0 + .word 42581 + .word 53029 + .word 20983 + .word 59666 + .word 49157 + .word 0 + .word 0 + .word 0 + .word 24816 + .word 20947 + .word 58172 + .word 55961 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 3130 + .word 13042 + .word 49143 + .word 34463 + .word 49170 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 24697 + .word 14253 + .word 47765 + .word 16408 + .word 0 + .word 0 + .word 0 + .word 32693 + .word 5691 + .word 15709 + .word 49649 + .word 20491 + .word 21402 + .word 35932 + .word 16986 + .word 44071 + .word 16276 + .word 1675 + .word 49861 + .word 13758 + .word 14468 + .word 65445 + .word 17200 + .word 60394 + .word 3375 + .word 60434 + .word 50075 + .word 49748 + .word 2796 + .word 14419 + .word 17415 + .word 61579 + .word 22133 + .word 33066 + .word 50291 + .word 25055 + .word 28661 + .word 31699 + .word 17632 + .word 55823 + .word 18661 + .word 6347 + .word 50508 + .word 58142 + .word 19935 + .word 64799 + .word 17849 + .word 41216 + .word 59562 + .word 42287 + .word 50726 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16006 + .word 65034 + .word 42959 + .word 34185 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 40843 + .word 53953 + .word 46369 + .word 45839 + .word 49160 + .word 0 + .word 0 + .word 0 + .word 54179 + .word 42767 + .word 58812 + .word 64462 + .word 16400 + .word 0 + .word 0 + .word 0 + .word 50676 + .word 3143 + .word 1093 + .word 60276 + .word 49177 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56865 + .word 38982 + .word 63406 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 65273 + .word 45226 + .word 24230 + .word 49857 + .word 23450 + .word 59950 + .word 19796 + .word 17236 + .word 4038 + .word 16755 + .word 26702 + .word 50152 + .word 24087 + .word 51196 + .word 62539 + .word 17533 + .word 25486 + .word 58858 + .word 44079 + .word 50450 + .word 31845 + .word 29909 + .word 37453 + .word 17831 + .word 19699 + .word 12384 + .word 3664 + .word 50750 + .word 26808 + .word 47918 + .word 18611 + .word 18131 + .word 25376 + .word 13791 + .word 62285 + .word 51048 + .word 64886 + .word 33542 + .word 28786 + .word 18433 + .word 54686 + .word 5814 + .word 3500 + .word 51351 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33175 + .word 51870 + .word 55516 + .word 61254 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 3685 + .word 30034 + .word 48430 + .word 40287 + .word 49163 + .word 0 + .word 0 + .word 0 + .word 3323 + .word 33320 + .word 53546 + .word 49572 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 19902 + .word 19517 + .word 60782 + .word 40648 + .word 49186 + .word 0 + .word 0 + .word 0 + .word 28672 + .word 31090 + .word 60187 + .word 37497 + .word 16430 + .word 0 + .word 0 + .word 0 + .word 4362 + .word 57115 + .word 1063 + .word 50082 + .word 17298 + .word 34206 + .word 30558 + .word 17506 + .word 19701 + .word 2977 + .word 30695 + .word 50467 + .word 45209 + .word 25144 + .word 62418 + .word 17892 + .word 6287 + .word 3260 + .word 59477 + .word 50854 + .word 26251 + .word 62311 + .word 23506 + .word 18281 + .word 50215 + .word 3065 + .word 23294 + .word 51244 + .word 519 + .word 28602 + .word 60080 + .word 18671 + .word 56824 + .word 33188 + .word 7096 + .word 51634 + .word 27357 + .word 50961 + .word 5574 + .word 19062 + .word 7770 + .word 52374 + .word 38304 + .word 52025 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33559 + .word 2783 + .word 4720 + .word 38214 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 65291 + .word 24589 + .word 47090 + .word 40315 + .word 49166 + .word 0 + .word 0 + .word 0 + .word 7930 + .word 21505 + .word 15205 + .word 49607 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 61775 + .word 9936 + .word 17817 + .word 40691 + .word 49195 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 37628 + .word 658 + .word 37550 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 14352 + .word 33815 + .word 3114 + .word 50322 + .word 43816 + .word 13363 + .word 33081 + .word 17794 + .word 62601 + .word 27719 + .word 33798 + .word 50803 + .word 1036 + .word 16074 + .word 700 + .word 18277 + .word 33117 + .word 56648 + .word 64173 + .word 51286 + .word 17251 + .word 52492 + .word 29265 + .word 18761 + .word 11155 + .word 27451 + .word 30367 + .word 51772 + .word 7487 + .word 7247 + .word 2371 + .word 19248 + .word 14759 + .word 9929 + .word 13587 + .word 52258 + .word 11730 + .word 26190 + .word 56262 + .word 19733 + .word 56923 + .word 11047 + .word 18072 + .word 52745 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37589 + .word 36570 + .word 62298 + .word 45320 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 17708 + .word 57749 + .word 28642 + .word 45359 + .word 49169 + .word 0 + .word 0 + .word 0 + .word 40067 + .word 38581 + .word 2689 + .word 62790 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 36505 + .word 63458 + .word 34596 + .word 57945 + .word 49204 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 38946 + .word 9029 + .word 60159 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 61014 + .word 7077 + .word 17362 + .word 50576 + .word 11572 + .word 44638 + .word 49972 + .word 18098 + .word 64171 + .word 46242 + .word 17172 + .word 51158 + .word 7607 + .word 1130 + .word 63213 + .word 18682 + .word 20847 + .word 56361 + .word 38627 + .word 51744 + .word 49497 + .word 58620 + .word 43800 + .word 19268 + .word 63056 + .word 11021 + .word 657 + .word 52330 + .word 42127 + .word 49291 + .word 30722 + .word 19856 + .word 13674 + .word 31481 + .word 1908 + .word 52917 + .word 60194 + .word 12516 + .word 3868 + .word 20445 + .word 3386 + .word 31577 + .word 62924 + .word 53506 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44838 + .word 25647 + .word 6736 + .word 62345 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 31560 + .word 12645 + .word 60726 + .word 56699 + .word 49172 + .word 0 + .word 0 + .word 0 + .word 56942 + .word 25011 + .word 17364 + .word 49055 + .word 16425 + .word 0 + .word 0 + .word 0 + .word 3371 + .word 3119 + .word 24466 + .word 56588 + .word 49214 + .word 0 + .word 0 + .word 0 + .word 14336 + .word 15684 + .word 2636 + .word 36719 + .word 16468 + .word 0 + .word 0 + .word 0 + .word 47554 + .word 44810 + .word 53673 + .word 50840 + .word 53371 + .word 50832 + .word 58584 + .word 18417 + .word 46548 + .word 9025 + .word 35353 + .word 51530 + .word 2727 + .word 25780 + .word 5967 + .word 19108 + .word 27113 + .word 1073 + .word 59097 + .word 52222 + .word 11834 + .word 38905 + .word 4058 + .word 19800 + .word 56017 + .word 55971 + .word 60637 + .word 52914 + .word 5287 + .word 8439 + .word 65517 + .word 20493 + .word 37028 + .word 58958 + .word 62480 + .word 53607 + .word 57582 + .word 43721 + .word 1738 + .word 21188 + .word 9819 + .word 37368 + .word 17165 + .word 54304 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13429 + .word 7444 + .word 20593 + .word 34837 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 49742 + .word 37689 + .word 16091 + .word 38981 + .word 49176 + .word 0 + .word 0 + .word 0 + .word 46524 + .word 21314 + .word 39987 + .word 46372 + .word 16432 + .word 0 + .word 0 + .word 0 + .word 14081 + .word 37459 + .word 64348 + .word 36776 + .word 49225 + .word 0 + .word 0 + .word 0 + .word 30720 + .word 57650 + .word 51740 + .word 32812 + .word 16482 + .word 0 + .word 0 + .word 0 + .word 13868 + .word 61714 + .word 32487 + .word 51118 + .word 53288 + .word 8914 + .word 15189 + .word 18750 + .word 25547 + .word 51031 + .word 54157 + .word 51918 + .word 4587 + .word 22569 + .word 2868 + .word 19552 + .word 4628 + .word 56702 + .word 63256 + .word 52720 + .word 60585 + .word 38579 + .word 10763 + .word 20354 + .word 20343 + .word 32825 + .word 42223 + .word 53523 + .word 15259 + .word 21287 + .word 25207 + .word 21157 + .word 19232 + .word 27853 + .word 30722 + .word 54327 + .word 6202 + .word 34921 + .word 46892 + .word 21963 + .word 54314 + .word 63337 + .word 3818 + .word 55135 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12932 + .word 7413 + .word 50416 + .word 52775 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 49070 + .word 42612 + .word 57119 + .word 58471 + .word 49179 + .word 0 + .word 0 + .word 0 + .word 37517 + .word 48554 + .word 12217 + .word 52169 + .word 16439 + .word 0 + .word 0 + .word 0 + .word 3686 + .word 14060 + .word 10284 + .word 62061 + .word 49235 + .word 0 + .word 0 + .word 0 + .word 12288 + .word 36186 + .word 45004 + .word 41528 + .word 16496 + .word 0 + .word 0 + .word 0 + .word 36572 + .word 10708 + .word 62070 + .word 51404 + .word 43863 + .word 23526 + .word 34237 + .word 19093 + .word 49453 + .word 49937 + .word 30100 + .word 52320 + .word 42622 + .word 48103 + .word 45810 + .word 20009 + .word 63343 + .word 18283 + .word 24986 + .word 53236 + .word 211 + .word 7406 + .word 23986 + .word 20928 + .word 55487 + .word 58939 + .word 35978 + .word 54154 + .word 20786 + .word 29108 + .word 45903 + .word 21845 + .word 43676 + .word 27033 + .word 56912 + .word 55073 + .word 56762 + .word 13326 + .word 51569 + .word 22766 + .word 11195 + .word 61166 + .word 50980 + .word 55993 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8176 + .word 5164 + .word 64154 + .word 36090 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 19140 + .word 63711 + .word 39190 + .word 47508 + .word 49183 + .word 0 + .word 0 + .word 0 + .word 61957 + .word 29915 + .word 7046 + .word 34440 + .word 16447 + .word 0 + .word 0 + .word 0 + .word 29909 + .word 15770 + .word 39264 + .word 33288 + .word 49247 + .word 0 + .word 0 + .word 0 + .word 38912 + .word 2108 + .word 35420 + .word 36197 + .word 16511 + .word 0 + .word 0 + .word 0 + .word 63755 + .word 16362 + .word 32791 + .word 51700 + .word 7043 + .word 34288 + .word 50374 + .word 19448 + .word 36869 + .word 13569 + .word 51161 + .word 52734 + .word 30422 + .word 39536 + .word 34368 + .word 20483 + .word 2356 + .word 27571 + .word 10627 + .word 53769 + .word 24204 + .word 35273 + .word 27312 + .word 21520 + .word 8451 + .word 46569 + .word 41820 + .word 54805 + .word 23553 + .word 63476 + .word 47626 + .word 22556 + .word 30024 + .word 47627 + .word 14141 + .word 55843 + .word 22061 + .word 10635 + .word 17534 + .word 23595 + .word 50593 + .word 17237 + .word 38322 + .word 56882 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26357 + .word 41545 + .word 7157 + .word 37888 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 28550 + .word 47270 + .word 51275 + .word 41572 + .word 49187 + .word 0 + .word 0 + .word 0 + .word 7474 + .word 4460 + .word 27226 + .word 52743 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 18816 + .word 51641 + .word 26417 + .word 44610 + .word 49258 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 61733 + .word 61279 + .word 42447 + .word 16526 + .word 0 + .word 0 + .word 0 + .word 45407 + .word 18829 + .word 2399 + .word 52005 + .word 35928 + .word 2098 + .word 15792 + .word 19814 + .word 23614 + .word 62930 + .word 12196 + .word 53160 + .word 7674 + .word 56712 + .word 55660 + .word 20970 + .word 53358 + .word 2019 + .word 18277 + .word 54318 + .word 57563 + .word 186 + .word 18788 + .word 22129 + .word 38957 + .word 32276 + .word 61462 + .word 55475 + .word 46995 + .word 58305 + .word 12150 + .word 23287 + .word 60702 + .word 18274 + .word 9955 + .word 56635 + .word 40407 + .word 43665 + .word 14520 + .word 24448 + .word 50736 + .word 28578 + .word 16181 + .word 57795 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5404 + .word 12511 + .word 60447 + .word 38763 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 42770 + .word 34093 + .word 51209 + .word 39016 + .word 49191 + .word 0 + .word 0 + .word 0 + .word 6888 + .word 59302 + .word 12508 + .word 46457 + .word 16462 + .word 0 + .word 0 + .word 0 + .word 49565 + .word 60790 + .word 42341 + .word 36877 + .word 49270 + .word 0 + .word 0 + .word 0 + .word 28672 + .word 39351 + .word 39031 + .word 32932 + .word 16542 + .word 0 + .word 0 + .word 0 + .word 35933 + .word 37102 + .word 41613 + .word 52318 + .word 59745 + .word 3284 + .word 26050 + .word 20190 + .word 16458 + .word 62792 + .word 1547 + .word 53599 + .word 38519 + .word 37566 + .word 10560 + .word 21472 + .word 36560 + .word 62869 + .word 6875 + .word 54881 + .word 58623 + .word 15626 + .word 21634 + .word 22754 + .word 22503 + .word 3380 + .word 55147 + .word 56163 + .word 21679 + .word 23644 + .word 42908 + .word 24037 + .word 43760 + .word 1032 + .word 52442 + .word 57447 + .word 14782 + .word 45605 + .word 45261 + .word 25322 + .word 22271 + .word 11633 + .word 47287 + .word 58733 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _LRP,@object + .size _LRP,2496 + .align 16 +_RRIB: + .long 4234632914 + .long 3221491298 + .long 2516645996 + .long 3221465084 + .long 798659078 + .long 3221438870 + .long 2133702104 + .long 3221835523 + .long 3164494255 + .long 3221825037 + .long 4195286406 + .long 3221814551 + .long 816546054 + .long 3222285677 + .long 2019136897 + .long 3222284366 + .long 3221727740 + .long 3222283055 + .long 2093868532 + .long 3222538608 + .long 1475393241 + .long 3222538346 + .long 856917950 + .long 3222538084 + .long 2471449286 + .long 3222798751 + .long 629767309 + .long 3222798699 + .long 3083052628 + .long 3222798646 + .long 862741805 + .long 3223060539 + .long 4260232735 + .long 3223060531 + .long 3362756369 + .long 3223060524 + .long 3046734174 + .long 3223322627 + .long 1076409337 + .long 3223322627 + .long 3401051796 + .long 3223322626 + .long 1762435764 + .long 3223453696 + .long 1551329531 + .long 3223453696 + .long 1340223298 + .long 3223453696 + .long 175962963 + .long 3223584768 + .long 155133815 + .long 3223584768 + .long 134304667 + .long 3223584768 + .long 16073407 + .long 3223715840 + .long 14103082 + .long 3223715840 + .long 12132757 + .long 3223715840 + .long 1330068 + .long 3223846912 + .long 1175257 + .long 3223846912 + .long 1020446 + .long 3223846912 + .long 101663 + .long 3223977984 + .long 90404 + .long 3223977984 + .long 79145 + .long 3223977984 + .long 7020 + .long 3224109056 + .long 6457 + .long 3224109056 + .long 5894 + .long 3224109056 + .type _RRIB,@object + .size _RRIB,312 + .space 8, 0x00 # pad + .align 16 +_RRP: + .word 26273 + .word 65347 + .word 56168 + .word 33169 + .word 16329 + .word 0 + .word 0 + .word 0 + .word 899 + .word 31387 + .word 19253 + .word 49663 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 58984 + .word 6058 + .word 23936 + .word 39799 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 62168 + .word 21442 + .word 12332 + .word 46245 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 32619 + .word 37054 + .word 53131 + .word 16575 + .word 61379 + .word 13125 + .word 14178 + .word 16562 + .word 10270 + .word 45115 + .word 37615 + .word 16506 + .word 38745 + .word 51073 + .word 34560 + .word 16498 + .word 53490 + .word 20212 + .word 2544 + .word 16440 + .word 38291 + .word 26669 + .word 54063 + .word 16440 + .word 45779 + .word 11956 + .word 18019 + .word 16540 + .word 18677 + .word 64033 + .word 42794 + .word 16529 + .word 35035 + .word 51098 + .word 10618 + .word 16473 + .word 64107 + .word 31719 + .word 36522 + .word 16468 + .word 8831 + .word 57419 + .word 13215 + .word 16407 + .word 40450 + .word 31904 + .word 29069 + .word 16417 + .word 3821 + .word 29651 + .word 12061 + .word 62640 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 3177 + .word 32099 + .word 13049 + .word 63749 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 10153 + .word 35464 + .word 38075 + .word 52902 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 20859 + .word 27364 + .word 47250 + .word 57481 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 12411 + .word 3381 + .word 24721 + .word 16978 + .word 33723 + .word 48761 + .word 26869 + .word 16934 + .word 60995 + .word 48715 + .word 17741 + .word 16804 + .word 43031 + .word 16238 + .word 40105 + .word 16761 + .word 3889 + .word 41280 + .word 47482 + .word 16635 + .word 43797 + .word 63405 + .word 37827 + .word 16594 + .word 62186 + .word 39109 + .word 61647 + .word 16889 + .word 62356 + .word 27755 + .word 9779 + .word 16848 + .word 54712 + .word 4438 + .word 22518 + .word 16720 + .word 46932 + .word 1372 + .word 7843 + .word 16677 + .word 64555 + .word 14297 + .word 39523 + .word 16553 + .word 24913 + .word 15735 + .word 26400 + .word 16514 + .word 23128 + .word 31275 + .word 33489 + .word 52246 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 56543 + .word 37040 + .word 59300 + .word 54866 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 35342 + .word 2554 + .word 44652 + .word 41504 + .word 16391 + .word 0 + .word 0 + .word 0 + .word 60438 + .word 21728 + .word 35033 + .word 43725 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 2425 + .word 35124 + .word 13908 + .word 17426 + .word 60985 + .word 47869 + .word 25665 + .word 17352 + .word 21213 + .word 45459 + .word 26876 + .word 17133 + .word 52591 + .word 14597 + .word 24526 + .word 17060 + .word 20426 + .word 18941 + .word 5374 + .word 16845 + .word 38724 + .word 49064 + .word 24125 + .word 16773 + .word 29994 + .word 36366 + .word 21088 + .word 17279 + .word 13269 + .word 25406 + .word 24800 + .word 17205 + .word 56893 + .word 35190 + .word 33689 + .word 16988 + .word 18235 + .word 52539 + .word 13276 + .word 16916 + .word 8454 + .word 46451 + .word 9758 + .word 16704 + .word 59084 + .word 57882 + .word 27928 + .word 16633 + .word 38110 + .word 57460 + .word 5118 + .word 49980 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 32056 + .word 19825 + .word 28737 + .word 63161 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 37650 + .word 4479 + .word 6518 + .word 59238 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 47963 + .word 64405 + .word 49841 + .word 37534 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 53082 + .word 25478 + .word 58397 + .word 17968 + .word 35980 + .word 11362 + .word 59289 + .word 17858 + .word 37178 + .word 29007 + .word 44012 + .word 17530 + .word 40762 + .word 17715 + .word 56491 + .word 17422 + .word 58318 + .word 3223 + .word 43216 + .word 17097 + .word 46157 + .word 23530 + .word 32141 + .word 16991 + .word 63138 + .word 35190 + .word 24151 + .word 17748 + .word 9862 + .word 36309 + .word 14376 + .word 17639 + .word 38034 + .word 65220 + .word 2337 + .word 17314 + .word 16819 + .word 31850 + .word 22525 + .word 17205 + .word 7604 + .word 29558 + .word 57367 + .word 16883 + .word 27719 + .word 62170 + .word 8797 + .word 16778 + .word 19348 + .word 65423 + .word 37299 + .word 53534 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 8233 + .word 55180 + .word 9457 + .word 46319 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 43066 + .word 26574 + .word 6722 + .word 65137 + .word 16400 + .word 0 + .word 0 + .word 0 + .word 4285 + .word 7102 + .word 7454 + .word 61224 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 1453 + .word 4915 + .word 61926 + .word 18584 + .word 43088 + .word 28644 + .word 50480 + .word 18434 + .word 16532 + .word 18100 + .word 54137 + .word 17983 + .word 49885 + .word 46980 + .word 54409 + .word 17832 + .word 24326 + .word 38273 + .word 20489 + .word 17385 + .word 28149 + .word 12270 + .word 61982 + .word 17236 + .word 4581 + .word 37632 + .word 45525 + .word 18282 + .word 46626 + .word 30655 + .word 34430 + .word 18132 + .word 63429 + .word 60638 + .word 37201 + .word 17683 + .word 18031 + .word 50879 + .word 14891 + .word 17535 + .word 64064 + .word 1811 + .word 54229 + .word 17089 + .word 27163 + .word 21077 + .word 40059 + .word 16943 + .word 43177 + .word 42972 + .word 46613 + .word 45511 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 51480 + .word 49923 + .word 15697 + .word 40352 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 9513 + .word 31676 + .word 11989 + .word 49652 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 30527 + .word 7034 + .word 38319 + .word 40746 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 7022 + .word 27009 + .word 58741 + .word 19257 + .word 64033 + .word 16049 + .word 22023 + .word 19062 + .word 45243 + .word 42262 + .word 39716 + .word 18476 + .word 50731 + .word 20793 + .word 36853 + .word 18281 + .word 36100 + .word 48270 + .word 37858 + .word 17699 + .word 42104 + .word 28941 + .word 36380 + .word 17506 + .word 23499 + .word 6717 + .word 19492 + .word 18866 + .word 55911 + .word 14060 + .word 7353 + .word 18672 + .word 26519 + .word 16988 + .word 4787 + .word 18087 + .word 28065 + .word 5309 + .word 5697 + .word 17893 + .word 40193 + .word 22022 + .word 5795 + .word 17314 + .word 8456 + .word 42078 + .word 24130 + .word 17122 + .word 59016 + .word 62162 + .word 39673 + .word 39540 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 38154 + .word 49049 + .word 18422 + .word 40324 + .word 16398 + .word 0 + .word 0 + .word 0 + .word 42164 + .word 50610 + .word 50330 + .word 49617 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 25875 + .word 59750 + .word 15469 + .word 40704 + .word 16427 + .word 0 + .word 0 + .word 0 + .word 34173 + .word 58862 + .word 54392 + .word 19977 + .word 59819 + .word 8454 + .word 18296 + .word 19734 + .word 30024 + .word 20882 + .word 32589 + .word 19004 + .word 29754 + .word 31085 + .word 31060 + .word 18761 + .word 52191 + .word 27376 + .word 34749 + .word 18035 + .word 4562 + .word 4929 + .word 33854 + .word 17794 + .word 25001 + .word 9100 + .word 13901 + .word 19490 + .word 47424 + .word 1290 + .word 2840 + .word 19248 + .word 22386 + .word 25633 + .word 77 + .word 18519 + .word 15514 + .word 17548 + .word 1870 + .word 18277 + .word 63012 + .word 41083 + .word 3742 + .word 17554 + .word 48968 + .word 51531 + .word 22462 + .word 17314 + .word 41404 + .word 42732 + .word 62757 + .word 38778 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 7009 + .word 42712 + .word 36892 + .word 45360 + .word 16401 + .word 0 + .word 0 + .word 0 + .word 39847 + .word 2109 + .word 39294 + .word 62791 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 32179 + .word 43914 + .word 44915 + .word 57947 + .word 16436 + .word 0 + .word 0 + .word 0 + .word 27779 + .word 16034 + .word 51140 + .word 20738 + .word 17003 + .word 57008 + .word 53620 + .word 20444 + .word 23469 + .word 38349 + .word 865 + .word 19562 + .word 25226 + .word 11109 + .word 43957 + .word 19268 + .word 36845 + .word 29881 + .word 17299 + .word 18390 + .word 19837 + .word 16116 + .word 50064 + .word 18098 + .word 57862 + .word 29290 + .word 2992 + .word 20149 + .word 46818 + .word 59090 + .word 31382 + .word 19856 + .word 61466 + .word 30954 + .word 38749 + .word 18976 + .word 30984 + .word 39998 + .word 63388 + .word 18682 + .word 41543 + .word 16681 + .word 17428 + .word 17808 + .word 20643 + .word 64049 + .word 24643 + .word 17517 + .word 52468 + .word 15578 + .word 48717 + .word 44571 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 54595 + .word 6191 + .word 4821 + .word 56700 + .word 16404 + .word 0 + .word 0 + .word 0 + .word 50514 + .word 10282 + .word 25695 + .word 49055 + .word 16425 + .word 0 + .word 0 + .word 0 + .word 13176 + .word 11594 + .word 38881 + .word 56588 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 28019 + .word 59660 + .word 42453 + .word 21536 + .word 50810 + .word 20541 + .word 28938 + .word 21188 + .word 53928 + .word 47752 + .word 60679 + .word 20146 + .word 24270 + .word 60826 + .word 4097 + .word 19800 + .word 57327 + .word 59875 + .word 35368 + .word 18762 + .word 31038 + .word 58486 + .word 58593 + .word 18417 + .word 41074 + .word 26743 + .word 60755 + .word 20839 + .word 49334 + .word 8669 + .word 63919 + .word 20493 + .word 20472 + .word 19395 + .word 59120 + .word 19454 + .word 27230 + .word 61299 + .word 5980 + .word 19108 + .word 60536 + .word 14479 + .word 53684 + .word 18072 + .word 24589 + .word 24698 + .word 60903 + .word 17729 + .word 24724 + .word 11272 + .word 24781 + .word 60135 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 54850 + .word 34200 + .word 16766 + .word 38981 + .word 16408 + .word 0 + .word 0 + .word 0 + .word 58717 + .word 18738 + .word 40849 + .word 46372 + .word 16432 + .word 0 + .word 0 + .word 0 + .word 11614 + .word 63671 + .word 65373 + .word 36776 + .word 16457 + .word 0 + .word 0 + .word 0 + .word 54464 + .word 24503 + .word 3823 + .word 22367 + .word 6780 + .word 11041 + .word 46896 + .word 21963 + .word 31922 + .word 33372 + .word 42225 + .word 20755 + .word 24666 + .word 18144 + .word 10765 + .word 20354 + .word 1690 + .word 51390 + .word 54159 + .word 19150 + .word 40728 + .word 53860 + .word 15190 + .word 18750 + .word 62163 + .word 16835 + .word 30725 + .word 21559 + .word 49586 + .word 46435 + .word 25209 + .word 21157 + .word 392 + .word 18629 + .word 63258 + .word 19952 + .word 57023 + .word 35208 + .word 2869 + .word 19552 + .word 15849 + .word 23514 + .word 32489 + .word 18350 + .word 45455 + .word 56342 + .word 1433 + .word 17952 + .word 26203 + .word 24931 + .word 14914 + .word 64372 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 32494 + .word 4334 + .word 57160 + .word 58471 + .word 16411 + .word 0 + .word 0 + .word 0 + .word 38313 + .word 48554 + .word 12217 + .word 52169 + .word 16439 + .word 0 + .word 0 + .word 0 + .word 13841 + .word 14060 + .word 10284 + .word 62061 + .word 16467 + .word 0 + .word 0 + .word 0 + .word 27928 + .word 25887 + .word 22600 + .word 23226 + .word 25867 + .word 43031 + .word 24792 + .word 22767 + .word 61361 + .word 28179 + .word 36008 + .word 21386 + .word 1901 + .word 19713 + .word 23997 + .word 20928 + .word 53849 + .word 49977 + .word 30100 + .word 19552 + .word 12987 + .word 23545 + .word 34237 + .word 19093 + .word 36035 + .word 18526 + .word 55738 + .word 22305 + .word 4173 + .word 53170 + .word 44844 + .word 21845 + .word 20134 + .word 6065 + .word 24986 + .word 20468 + .word 63684 + .word 40633 + .word 45810 + .word 20009 + .word 28281 + .word 10708 + .word 62070 + .word 18636 + .word 42557 + .word 63889 + .word 18197 + .word 18180 + .word 24464 + .word 43564 + .word 52277 + .word 36083 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 8651 + .word 37688 + .word 39193 + .word 47508 + .word 16415 + .word 0 + .word 0 + .word 0 + .word 61957 + .word 29915 + .word 7046 + .word 34440 + .word 16447 + .word 0 + .word 0 + .word 0 + .word 29909 + .word 15770 + .word 39264 + .word 33288 + .word 16479 + .word 0 + .word 0 + .word 0 + .word 16042 + .word 19253 + .word 38322 + .word 24114 + .word 28448 + .word 10617 + .word 17534 + .word 23595 + .word 64229 + .word 46570 + .word 41820 + .word 22037 + .word 23727 + .word 35273 + .word 27312 + .word 21520 + .word 36874 + .word 13569 + .word 51161 + .word 19966 + .word 7043 + .word 34288 + .word 50374 + .word 19448 + .word 38316 + .word 47529 + .word 14141 + .word 23075 + .word 12297 + .word 63477 + .word 47626 + .word 22556 + .word 1229 + .word 27571 + .word 10627 + .word 21001 + .word 30426 + .word 39536 + .word 34368 + .word 20483 + .word 63755 + .word 16362 + .word 32791 + .word 18932 + .word 1939 + .word 19329 + .word 44209 + .word 18417 + .word 1291 + .word 6677 + .word 4999 + .word 37888 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 36671 + .word 58224 + .word 51275 + .word 41572 + .word 16419 + .word 0 + .word 0 + .word 0 + .word 7476 + .word 4460 + .word 27226 + .word 52743 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 18838 + .word 51641 + .word 26417 + .word 44610 + .word 16490 + .word 0 + .word 0 + .word 0 + .word 10710 + .word 48640 + .word 32083 + .word 25027 + .word 33620 + .word 55766 + .word 26236 + .word 24448 + .word 24667 + .word 39142 + .word 61464 + .word 22707 + .word 56170 + .word 8470 + .word 18789 + .word 22129 + .word 23296 + .word 62931 + .word 12196 + .word 20392 + .word 57231 + .word 2098 + .word 15792 + .word 19814 + .word 1704 + .word 49608 + .word 9547 + .word 23867 + .word 46419 + .word 24648 + .word 11891 + .word 23287 + .word 19376 + .word 1296 + .word 18277 + .word 21550 + .word 46223 + .word 56399 + .word 55660 + .word 20970 + .word 45364 + .word 18829 + .word 2399 + .word 19237 + .word 9387 + .word 60414 + .word 47613 + .word 18660 + .type _RRP,@object + .size _RRP,2080 + .align 16 +_LN_SQRT_TWO_PI: + .word 42293 + .word 9717 + .word 36419 + .word 60223 + .word 16382 + .word 0 + .type _LN_SQRT_TWO_PI,@object + .size _LN_SQRT_TWO_PI,12 + .space 4, 0x00 # pad + .align 16 +_W2: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16379 + .word 0 + .type _W2,@object + .size _W2,12 + .space 4, 0x00 # pad + .align 16 +_S10: + .word 26777 + .word 63736 + .word 61426 + .word 52480 + .word 49148 + .word 0 + .type _S10,@object + .size _S10,12 + .space 4, 0x00 # pad + .align 16 +_S06: + .word 26251 + .word 64205 + .word 25991 + .word 44448 + .word 49149 + .word 0 + .type _S06,@object + .size _S06,12 + .space 4, 0x00 # pad + .align 16 +_S02: + .word 39072 + .word 38974 + .word 13074 + .word 53901 + .word 49151 + .word 0 + .type _S02,@object + .size _S02,12 + .space 4, 0x00 # pad + .align 16 +_S12: + .word 13864 + .word 61389 + .word 41932 + .word 43701 + .word 49148 + .word 0 + .type _S12,@object + .size _S12,12 + .space 4, 0x00 # pad + .align 16 +_S08: + .word 6565 + .word 12686 + .word 39772 + .word 32901 + .word 49149 + .word 0 + .type _S08,@object + .size _S08,12 + .space 4, 0x00 # pad + .align 16 +_S04: + .word 60211 + .word 16071 + .word 37206 + .word 35465 + .word 49150 + .word 0 + .type _S04,@object + .size _S04,12 + .space 4, 0x00 # pad + .align 16 +_A: + .long 0 + .long 1074790400 + .long 0 + .long 1075838976 + .long 0 + .long 1076887552 + .long 0 + .long 1077936128 + .long 0 + .long 1078984704 + .long 0 + .long 1080033280 + .long 0 + .long 1081081856 + .type _A,@object + .size _A,56 + .space 8, 0x00 # pad + .align 16 +_B: + .long 0 + .long 1070596096 + .long 0 + .long 1069547520 + .long 0 + .long 1068498944 + .long 0 + .long 1067450368 + .long 0 + .long 1066401792 + .long 0 + .long 1065353216 + .long 0 + .long 1064304640 + .type _B,@object + .size _B,56 + .space 8, 0x00 # pad + .align 16 +_C5: + .word 65250 + .word 31226 + .word 64195 + .word 51294 + .word 16385 + .word 0 + .word 2062 + .word 11523 + .word 15490 + .word 40735 + .word 49153 + .word 0 + .word 32754 + .word 31980 + .word 31403 + .word 49421 + .word 16385 + .word 0 + .word 43174 + .word 39951 + .word 44282 + .word 37916 + .word 49153 + .word 0 + .word 17740 + .word 24638 + .word 31711 + .word 45907 + .word 16385 + .word 0 + .word 40119 + .word 37337 + .word 13155 + .word 65076 + .word 49152 + .word 0 + .word 17604 + .word 23486 + .word 20029 + .word 41172 + .word 16385 + .word 0 + .word 33185 + .word 5727 + .word 44714 + .word 50187 + .word 49152 + .word 0 + .word 59315 + .word 25153 + .word 8859 + .word 35740 + .word 16385 + .word 0 + .word 56975 + .word 59828 + .word 57702 + .word 65082 + .word 49151 + .word 0 + .word 44451 + .word 24185 + .word 18874 + .word 60288 + .word 16384 + .word 0 + .word 63603 + .word 63450 + .word 63770 + .word 55108 + .word 49150 + .word 0 + .word 29224 + .word 39171 + .word 38378 + .word 49676 + .word 16384 + .word 0 + .word 11522 + .word 59843 + .word 6225 + .word 34695 + .word 16381 + .word 0 + .word 52920 + .word 16467 + .word 35974 + .word 40266 + .word 16384 + .word 0 + .word 32911 + .word 20526 + .word 49212 + .word 40083 + .word 16383 + .word 0 + .word 50633 + .word 19120 + .word 5716 + .word 64631 + .word 16383 + .word 0 + .word 27278 + .word 20509 + .word 60679 + .word 63371 + .word 16383 + .word 0 + .word 47711 + .word 23018 + .word 38994 + .word 51179 + .word 16383 + .word 0 + .word 57200 + .word 35818 + .word 16826 + .word 37630 + .word 16384 + .word 0 + .word 2413 + .word 19605 + .word 64315 + .word 49218 + .word 16381 + .word 0 + .word 41670 + .word 6403 + .word 34702 + .word 40993 + .word 16383 + .word 0 + .word 6011 + .word 2134 + .word 32659 + .word 52266 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42605 + .word 32107 + .word 35187 + .word 43545 + .word 16382 + .word 0 + .word 3574 + .word 60450 + .word 45882 + .word 53610 + .word 16383 + .word 0 + .word 2808 + .word 20835 + .word 5027 + .word 56256 + .word 16383 + .word 0 + .word 3021 + .word 28181 + .word 33636 + .word 39028 + .word 16384 + .word 0 + .word 14493 + .word 33433 + .word 18281 + .word 35725 + .word 16384 + .word 0 + .word 39323 + .word 51299 + .word 2596 + .word 32961 + .word 16384 + .word 0 + .word 28336 + .word 24032 + .word 53553 + .word 44237 + .word 16384 + .word 0 + .word 52853 + .word 63658 + .word 36534 + .word 41882 + .word 16383 + .word 0 + .word 47917 + .word 51227 + .word 19034 + .word 54081 + .word 16384 + .word 0 + .word 51044 + .word 31166 + .word 18963 + .word 37856 + .word 16381 + .word 0 + .word 35962 + .word 40199 + .word 871 + .word 65049 + .word 16384 + .word 0 + .word 39889 + .word 54182 + .word 40011 + .word 55797 + .word 49150 + .word 0 + .word 29169 + .word 47361 + .word 8730 + .word 38268 + .word 16385 + .word 0 + .word 39706 + .word 37143 + .word 20168 + .word 33289 + .word 49152 + .word 0 + .word 16433 + .word 42895 + .word 21426 + .word 43820 + .word 16385 + .word 0 + .word 1625 + .word 9463 + .word 65082 + .word 51468 + .word 49152 + .word 0 + .word 58247 + .word 1594 + .word 2790 + .word 48648 + .word 16385 + .word 0 + .word 20868 + .word 31765 + .word 34026 + .word 33401 + .word 49153 + .word 0 + .word 23737 + .word 4448 + .word 39427 + .word 52225 + .word 16385 + .word 0 + .word 3456 + .word 40222 + .word 65015 + .word 38939 + .word 49153 + .word 0 + .word 35551 + .word 41260 + .word 40325 + .word 54131 + .word 16385 + .word 0 + .word 8973 + .word 47485 + .word 2472 + .word 41842 + .word 49153 + .word 0 + .word 43053 + .word 31703 + .word 19755 + .word 33274 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36731 + .word 27611 + .word 11212 + .word 55816 + .word 16382 + .word 0 + .word 63893 + .word 30149 + .word 45246 + .word 60594 + .word 16383 + .word 0 + .word 47198 + .word 37666 + .word 57801 + .word 61119 + .word 16383 + .word 0 + .word 25856 + .word 56265 + .word 35798 + .word 40402 + .word 16384 + .word 0 + .word 6470 + .word 34102 + .word 54471 + .word 38654 + .word 16384 + .word 0 + .word 9295 + .word 39366 + .word 17179 + .word 34081 + .word 16384 + .word 0 + .word 45822 + .word 31766 + .word 42784 + .word 47587 + .word 16384 + .word 0 + .word 5059 + .word 11140 + .word 37473 + .word 43359 + .word 16383 + .word 0 + .word 58055 + .word 60744 + .word 5900 + .word 57832 + .word 16384 + .word 0 + .word 38212 + .word 45613 + .word 58947 + .word 40054 + .word 16381 + .word 0 + .word 7938 + .word 56610 + .word 27106 + .word 34591 + .word 16385 + .word 0 + .word 32824 + .word 16764 + .word 60057 + .word 56720 + .word 49150 + .word 0 + .word 10908 + .word 30532 + .word 62164 + .word 40510 + .word 16385 + .word 0 + .word 63750 + .word 13029 + .word 27501 + .word 34026 + .word 49152 + .word 0 + .word 33477 + .word 11068 + .word 13144 + .word 46215 + .word 16385 + .word 0 + .word 42530 + .word 57434 + .word 58521 + .word 52671 + .word 49152 + .word 0 + .word 18986 + .word 9605 + .word 39740 + .word 51163 + .word 16385 + .word 0 + .word 28928 + .word 13634 + .word 42974 + .word 34196 + .word 49153 + .word 0 + .word 35215 + .word 30142 + .word 47225 + .word 54824 + .word 16385 + .word 0 + .word 28719 + .word 4316 + .word 52012 + .word 39873 + .word 49153 + .word 0 + .word 4508 + .word 8703 + .word 27075 + .word 56773 + .word 16385 + .word 0 + .word 26288 + .word 30246 + .word 8808 + .word 42848 + .word 49153 + .word 0 + .word 44455 + .word 3575 + .word 25942 + .word 45691 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2794 + .word 62330 + .word 8461 + .word 63853 + .word 16382 + .word 0 + .word 21479 + .word 44765 + .word 7865 + .word 64840 + .word 16383 + .word 0 + .word 31874 + .word 33681 + .word 56423 + .word 65041 + .word 16383 + .word 0 + .word 21473 + .word 44172 + .word 64358 + .word 41494 + .word 16384 + .word 0 + .word 32222 + .word 10523 + .word 55592 + .word 40956 + .word 16384 + .word 0 + .word 21434 + .word 30837 + .word 63797 + .word 34911 + .word 16384 + .word 0 + .word 39649 + .word 32992 + .word 36682 + .word 50257 + .word 16384 + .word 0 + .word 13095 + .word 39473 + .word 7384 + .word 44359 + .word 16383 + .word 0 + .word 31843 + .word 64809 + .word 59872 + .word 60895 + .word 16384 + .word 0 + .word 8672 + .word 5021 + .word 16314 + .word 40945 + .word 16381 + .word 0 + .word 39714 + .word 18801 + .word 4723 + .word 36324 + .word 16385 + .word 0 + .word 614 + .word 42734 + .word 5731 + .word 57950 + .word 49150 + .word 0 + .word 64434 + .word 24821 + .word 2679 + .word 42435 + .word 16385 + .word 0 + .word 12194 + .word 23846 + .word 20957 + .word 34750 + .word 49152 + .word 0 + .word 10830 + .word 21930 + .word 2400 + .word 48308 + .word 16385 + .word 0 + .word 22166 + .word 52453 + .word 43476 + .word 53777 + .word 49152 + .word 0 + .word 47257 + .word 46311 + .word 24367 + .word 53391 + .word 16385 + .word 0 + .word 54217 + .word 40926 + .word 61378 + .word 34907 + .word 49153 + .word 0 + .word 63951 + .word 56465 + .word 60729 + .word 57145 + .word 16385 + .word 0 + .word 26614 + .word 13946 + .word 18662 + .word 40698 + .word 49153 + .word 0 + .word 1838 + .word 12847 + .word 15941 + .word 59142 + .word 16385 + .word 0 + .word 4759 + .word 49273 + .word 38799 + .word 43731 + .word 49153 + .word 0 + .word 26568 + .word 56798 + .word 57629 + .word 34217 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25804 + .word 39657 + .word 51638 + .word 34652 + .word 16383 + .word 0 + .word 2771 + .word 24731 + .word 11874 + .word 33806 + .word 16384 + .word 0 + .word 19474 + .word 34269 + .word 14010 + .word 33912 + .word 16384 + .word 0 + .word 56824 + .word 53459 + .word 23053 + .word 42279 + .word 16384 + .word 0 + .word 18742 + .word 13031 + .word 52011 + .word 42483 + .word 16384 + .word 0 + .word 5937 + .word 64580 + .word 50859 + .word 35501 + .word 16384 + .word 0 + .word 23055 + .word 38603 + .word 6524 + .word 51938 + .word 16384 + .word 0 + .word 3664 + .word 27625 + .word 50793 + .word 45121 + .word 16383 + .word 0 + .word 52489 + .word 3557 + .word 32438 + .word 62735 + .word 16384 + .word 0 + .word 894 + .word 16203 + .word 51477 + .word 42152 + .word 16381 + .word 0 + .word 34963 + .word 47118 + .word 6430 + .word 37322 + .word 16385 + .word 0 + .word 26422 + .word 42936 + .word 42081 + .word 58310 + .word 49150 + .word 0 + .word 13130 + .word 21399 + .word 54693 + .word 43505 + .word 16385 + .word 0 + .word 30323 + .word 50910 + .word 30337 + .word 35076 + .word 49152 + .word 0 + .word 38115 + .word 10576 + .word 10000 + .word 49442 + .word 16385 + .word 0 + .word 37599 + .word 18432 + .word 63354 + .word 54317 + .word 49152 + .word 0 + .word 58822 + .word 42699 + .word 64187 + .word 54575 + .word 16385 + .word 0 + .word 64288 + .word 61574 + .word 23831 + .word 35266 + .word 49153 + .word 0 + .word 11805 + .word 33285 + .word 40274 + .word 58365 + .word 16385 + .word 0 + .word 20167 + .word 739 + .word 36989 + .word 41119 + .word 49153 + .word 0 + .word 62447 + .word 46690 + .word 58491 + .word 60379 + .word 16385 + .word 0 + .word 1463 + .word 47000 + .word 35484 + .word 44185 + .word 49153 + .word 0 + .word 64817 + .word 40328 + .word 40776 + .word 61320 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60250 + .word 42976 + .word 52322 + .word 36598 + .word 16383 + .word 0 + .word 26918 + .word 53639 + .word 1629 + .word 34777 + .word 16384 + .word 0 + .word 192 + .word 43979 + .word 65472 + .word 34978 + .word 16384 + .word 0 + .word 52261 + .word 56023 + .word 49807 + .word 42881 + .word 16384 + .word 0 + .word 1627 + .word 46939 + .word 43260 + .word 43630 + .word 16384 + .word 0 + .word 60557 + .word 13735 + .word 20430 + .word 35946 + .word 16384 + .word 0 + .word 37731 + .word 15708 + .word 47147 + .word 53188 + .word 16384 + .word 0 + .word 21753 + .word 29315 + .word 41089 + .word 45691 + .word 16383 + .word 0 + .word 6001 + .word 56966 + .word 64901 + .word 64096 + .word 16384 + .word 0 + .word 60203 + .word 9392 + .word 60017 + .word 43055 + .word 16381 + .word 0 + .word 63698 + .word 8838 + .word 668 + .word 38058 + .word 16385 + .word 0 + .word 63354 + .word 11979 + .word 38628 + .word 58569 + .word 49150 + .word 0 + .word 14495 + .word 23154 + .word 18917 + .word 44293 + .word 16385 + .word 0 + .word 21391 + .word 34042 + .word 43308 + .word 35313 + .word 49152 + .word 0 + .word 19364 + .word 56057 + .word 34969 + .word 50274 + .word 16385 + .word 0 + .word 24688 + .word 56191 + .word 53239 + .word 54710 + .word 49152 + .word 0 + .word 29387 + .word 5660 + .word 12964 + .word 55444 + .word 16385 + .word 0 + .word 35686 + .word 64227 + .word 46433 + .word 35526 + .word 49153 + .word 0 + .word 36666 + .word 59843 + .word 47733 + .word 59258 + .word 16385 + .word 0 + .word 36678 + .word 17293 + .word 20572 + .word 41425 + .word 49153 + .word 0 + .word 18431 + .word 63251 + .word 49151 + .word 61285 + .word 16385 + .word 0 + .word 60545 + .word 37455 + .word 56348 + .word 44514 + .word 49153 + .word 0 + .word 37261 + .word 1613 + .word 29792 + .word 57954 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15271 + .word 17124 + .word 50042 + .word 38057 + .word 16383 + .word 0 + .word 7933 + .word 60764 + .word 31972 + .word 35498 + .word 16384 + .word 0 + .word 36698 + .word 903 + .word 21735 + .word 35834 + .word 16384 + .word 0 + .word 61921 + .word 64342 + .word 37428 + .word 43367 + .word 16384 + .word 0 + .word 25723 + .word 57108 + .word 17005 + .word 44538 + .word 16384 + .word 0 + .word 55361 + .word 30601 + .word 552 + .word 36302 + .word 16384 + .word 0 + .word 60144 + .word 14680 + .word 32635 + .word 54172 + .word 16384 + .word 0 + .word 56958 + .word 12456 + .word 10479 + .word 46147 + .word 16383 + .word 0 + .word 483 + .word 34108 + .word 14727 + .word 65164 + .word 16384 + .word 0 + .word 43794 + .word 49057 + .word 50532 + .word 43789 + .word 16381 + .word 0 + .word 12225 + .word 29228 + .word 35085 + .word 38633 + .word 16385 + .word 0 + .word 54219 + .word 64754 + .word 11030 + .word 58760 + .word 49150 + .word 0 + .word 52932 + .word 63137 + .word 8758 + .word 44908 + .word 16385 + .word 0 + .word 27270 + .word 37632 + .word 62601 + .word 35495 + .word 49152 + .word 0 + .word 53773 + .word 63879 + .word 47305 + .word 50923 + .word 16385 + .word 0 + .word 29965 + .word 53650 + .word 14162 + .word 55014 + .word 49152 + .word 0 + .word 10444 + .word 24307 + .word 52989 + .word 56120 + .word 16385 + .word 0 + .word 12949 + .word 6021 + .word 2059 + .word 35728 + .word 49153 + .word 0 + .word 41140 + .word 26313 + .word 26076 + .word 59954 + .word 16385 + .word 0 + .word 53675 + .word 12584 + .word 54309 + .word 41661 + .word 49153 + .word 0 + .word 28849 + .word 13964 + .word 11627 + .word 61991 + .word 16385 + .word 0 + .word 33057 + .word 63851 + .word 41026 + .word 44769 + .word 49153 + .word 0 + .word 61939 + .word 60366 + .word 37868 + .word 56319 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _C5,@object + .size _C5,2016 + .align 16 +_C4: + .word 39764 + .word 13333 + .word 46799 + .word 55432 + .word 16385 + .word 0 + .word 6306 + .word 35111 + .word 59607 + .word 63624 + .word 49153 + .word 0 + .word 40772 + .word 10749 + .word 40067 + .word 48311 + .word 16382 + .word 0 + .word 17977 + .word 41258 + .word 10043 + .word 63023 + .word 16381 + .word 0 + .word 17757 + .word 54940 + .word 38650 + .word 52104 + .word 16384 + .word 0 + .word 36152 + .word 14316 + .word 50442 + .word 43322 + .word 49148 + .word 0 + .word 48990 + .word 25502 + .word 42020 + .word 58640 + .word 16385 + .word 0 + .word 57431 + .word 49505 + .word 17362 + .word 46284 + .word 49151 + .word 0 + .word 34483 + .word 2420 + .word 54299 + .word 50782 + .word 16386 + .word 0 + .word 37575 + .word 3091 + .word 26415 + .word 50860 + .word 49152 + .word 0 + .word 5185 + .word 25440 + .word 63351 + .word 37946 + .word 16387 + .word 0 + .word 37934 + .word 12918 + .word 47534 + .word 41618 + .word 49153 + .word 0 + .word 59537 + .word 51974 + .word 16286 + .word 51369 + .word 16387 + .word 0 + .word 31611 + .word 51820 + .word 58572 + .word 58708 + .word 49153 + .word 0 + .word 57757 + .word 54077 + .word 23114 + .word 64558 + .word 16387 + .word 0 + .word 63584 + .word 48263 + .word 62815 + .word 37616 + .word 49154 + .word 0 + .word 281 + .word 14439 + .word 46939 + .word 38182 + .word 16388 + .word 0 + .word 63169 + .word 10307 + .word 53265 + .word 44896 + .word 49154 + .word 0 + .word 22654 + .word 54923 + .word 22649 + .word 42855 + .word 16388 + .word 0 + .word 37607 + .word 64061 + .word 25856 + .word 50581 + .word 49154 + .word 0 + .word 47296 + .word 11647 + .word 64103 + .word 45853 + .word 16388 + .word 0 + .word 30544 + .word 55384 + .word 11467 + .word 54194 + .word 49154 + .word 0 + .word 39553 + .word 55407 + .word 30581 + .word 33698 + .word 49111 + .word 0 + .type _C4,@object + .size _C4,276 + .space 12, 0x00 # pad + .align 16 +_C3: + .word 28854 + .word 1182 + .word 12345 + .word 55415 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 12848 + .word 12413 + .word 26149 + .word 42266 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 13313 + .word 43952 + .word 210 + .word 35312 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 13187 + .word 60452 + .word 5475 + .word 43161 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 20972 + .word 51120 + .word 32272 + .word 61954 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 22296 + .word 60123 + .word 44502 + .word 16231 + .word 21517 + .word 49855 + .word 35525 + .word 48979 + .word 44698 + .word 63620 + .word 45930 + .word 16192 + .word 34147 + .word 51190 + .word 16340 + .word 48941 + .word 42301 + .word 55313 + .word 4730 + .word 16154 + .word 35999 + .word 24973 + .word 36325 + .word 48903 + .word 63277 + .word 55760 + .word 33014 + .word 16117 + .word 6314 + .word 46281 + .word 52205 + .word 48867 + .word 12513 + .word 17037 + .word 21130 + .word 16082 + .word 49946 + .word 1999 + .word 4813 + .word 48833 + .word 595 + .word 34534 + .word 265 + .word 16049 + .word 36690 + .word 64093 + .word 7546 + .word 48800 + .type _C3,@object + .size _C3,176 + .align 16 +_LM: + .word 64512 + .word 46577 + .word 49946 + .word 47894 + .word 16383 + .word 0 + .type _LM,@object + .size _LM,12 + .space 4, 0x00 # pad + .align 16 +_LGAMMA_C2: + .word 3599 + .word 7250 + .word 52710 + .word 63693 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 31159 + .word 473 + .word 17060 + .word 35466 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 23705 + .word 29125 + .word 24135 + .word 63417 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 8259 + .word 13793 + .word 15470 + .word 38689 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 1592 + .word 43035 + .word 5286 + .word 33882 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 34241 + .word 35161 + .word 18170 + .word 34381 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 17215 + .word 38817 + .word 26343 + .word 16274 + .word 43407 + .word 38166 + .word 8095 + .word 49029 + .word 9256 + .word 10755 + .word 64736 + .word 16248 + .word 19293 + .word 8064 + .word 12058 + .word 49006 + .word 55284 + .word 28504 + .word 33554 + .word 16226 + .word 50892 + .word 40251 + .word 63876 + .word 48982 + .word 34903 + .word 32886 + .word 50950 + .word 16204 + .word 5270 + .word 55866 + .word 9779 + .word 48962 + .word 8284 + .word 46907 + .word 3681 + .word 16183 + .word 12968 + .word 35363 + .word 2442 + .word 48942 + .word 52637 + .word 49970 + .word 50463 + .word 16163 + .word 28134 + .word 34361 + .word 26628 + .word 48914 + .type _LGAMMA_C2,@object + .size _LGAMMA_C2,192 + .align 16 +_C1: + .word 51111 + .word 32176 + .word 26595 + .word 37828 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 38980 + .word 38974 + .word 13074 + .word 53901 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30416 + .word 21910 + .word 43743 + .word 52518 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 47709 + .word 16075 + .word 37206 + .word 35465 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 15719 + .word 21694 + .word 57533 + .word 54364 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 13628 + .word 45309 + .word 46092 + .word 16325 + .word 18814 + .word 7557 + .word 28730 + .word 49090 + .word 30522 + .word 27866 + .word 4275 + .word 16320 + .word 35905 + .word 26356 + .word 32871 + .word 49084 + .word 38506 + .word 60969 + .word 40989 + .word 16313 + .word 18199 + .word 53198 + .word 18595 + .word 49079 + .word 21817 + .word 41319 + .word 22094 + .word 16309 + .word 3261 + .word 2506 + .word 46646 + .word 49075 + .word 41261 + .word 44393 + .word 26269 + .word 16306 + .word 45347 + .word 5923 + .word 3109 + .word 49073 + .word 3843 + .word 55608 + .word 31192 + .word 16299 + .word 33944 + .word 58380 + .word 1271 + .word 49050 + .type _C1,@object + .size _C1,176 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xc3300000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x40080000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_W4: + .long 381774871 + .long 3211182444 + .type _W4,@object + .size _W4,8 + .align 4 +_S26: + .long 1826776023 + .long 1070820717 + .type _S26,@object + .size _S26,8 + .align 4 +_S28: + .long 2468013457 + .long 3218873328 + .type _S28,@object + .size _S28,8 + .align 4 +_S22: + .long 342869935 + .long 3214497781 + .type _S22,@object + .size _S22,8 + .align 4 +_S24: + .long 3872164012 + .long 3218225849 + .type _S24,@object + .size _S24,8 + .align 4 +_S18: + .long 1060196486 + .long 3216761200 + .type _S18,@object + .size _S18,8 + .align 4 +_S20: + .long 1339685656 + .long 3216855407 + .type _S20,@object + .size _S20,8 + .align 4 +_S14: + .long 3265047626 + .long 3217180894 + .type _S14,@object + .size _S14,8 + .align 4 +_S16: + .long 618803264 + .long 3217033139 + .type _S16,@object + .size _S16,8 + .align 4 +_PBIG: + .long 4294967295 + .long 2146435071 + .type _PBIG,@object + .size _PBIG,8 + .data + .hidden fesetround + .hidden fegetround + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lgammaf.S b/external/sgx_libm/ia32/lgammaf.S new file mode 100644 index 0000000000..650c48a2f9 --- /dev/null +++ b/external/sgx_libm/ia32/lgammaf.S @@ -0,0 +1,2280 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lgammaf.c" + .text +..TXTST0: +# -- Begin lgammaf + .text + .align 16,0x90 + .globl lgammaf +lgammaf: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + subl $20, %esp + lea 8(%esp), %eax + pushl %eax + pushl 28(%esp) + call __libm_lgammaf +..B1.2: + addl $28, %esp + ret + .align 16,0x90 + .type lgammaf,@function + .size lgammaf,.-lgammaf + .data +# -- End lgammaf + .text +# -- Begin __libm_lgammaf + .text + .align 16,0x90 +__libm_lgammaf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L2: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + movzwl 10(%ebp), %ebx + andl $32640, %ebx + shrl $7, %ebx + movl %ebx, %edi + movzbl 11(%ebp), %ecx + movl 8(%ebp), %edx + andl $128, %ecx + movl 12(%ebp), %eax + andl $8388607, %edx + shll $23, %edi + shrl $7, %ecx + orl %edx, %edi + movl %eax, 12(%esp) + movl %ecx, (%esp) +..B2.2: + fnstcw 90(%esp) +..B2.3: + call fegetround +..B2.164: + movl %eax, 84(%esp) +..B2.4: + cmpl $0, 84(%esp) + jne ..B2.6 +..B2.5: + xorl %edx, %edx + jmp ..B2.8 +..B2.6: + addl $-16, %esp + movl $0, (%esp) + call fesetround +..B2.165: + addl $16, %esp +..B2.7: + movl $1, %edx +..B2.8: + movzwl 90(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.161 +..B2.9: + orl $-64768, %ecx + movw %cx, 88(%esp) +..B2.10: + fldcw 88(%esp) +..B2.11: + movl $1, %esi +..B2.12: + cmpl $255, %ebx + jne ..B2.18 +..B2.13: + movl 12(%esp), %eax + testl %esi, %esi + movl $1, (%eax) + je ..B2.15 +..B2.14: + fldcw 90(%esp) +..B2.15: + testl %edx, %edx + je ..B2.17 +..B2.16: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.166: + addl $16, %esp +..B2.17: + flds 8(%ebp) + fmul %st(0), %st + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.18: + testl %edi, %edi + je ..B2.153 +..B2.19: + movl 12(%esp), %eax + call ..L3 +..L3: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L3](%ebx), %ebx + movl $1, (%eax) + cmpl $0, (%esp) + jne ..B2.76 +..B2.20: + cmpl $2084876174, %edi + jae ..B2.140 +..B2.21: + flds 8(%ebp) + fld1 + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.22 + je ..B2.135 +..B2.22: + cmpl $1174405120, %edi + jb ..B2.28 +..B2.23: + fldt _LN_SQRT_TWO_PI@GOTOFF(%ebx) + fstpt (%esp) + addl $-16, %esp + fstl (%esp) + fstpt 32(%esp) + fldt 32(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + movl %edx, 96(%esp) + fsubrp %st, %st(1) + fstpt 48(%esp) + call log@PLT +..B2.167: + fldt 32(%esp) + fldt 48(%esp) + movl 96(%esp), %edx + addl $16, %esp + fmulp %st, %st(2) + testl %edx, %edx + fxch %st(1) + je ..B2.25 +..B2.24: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + fstpt 48(%esp) + fstpt 32(%esp) + call fesetround +..B2.168: + fldt 32(%esp) + fldt 48(%esp) + addl $16, %esp +..B2.25: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fsubp %st, %st(1) + fstps 76(%esp) + je ..B2.27 +..B2.26: + fldcw 90(%esp) +..B2.27: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.28: + cmpl $1082130432, %edi + jb ..B2.35 +..B2.29: + addl $-1082130432, %edi + sarl $23, %edi + movl %edi, %eax + shll $6, %eax + testl %edx, %edx + fsubs _A@GOTOFF(%ebx,%edi,4) + fmuls _B@GOTOFF(%ebx,%edi,4) + lea (%edi,%edi,2), %ecx + fld %st(0) + fmul %st(1), %st + fldl 8+_C5@GOTOFF(%eax,%ebx) + fmul %st(1), %st + faddl 40+_C5@GOTOFF(%eax,%ebx) + fmul %st(1), %st + faddl 8+_C5_0@GOTOFF(%ebx,%ecx,8) + fmul %st(1), %st + faddl 56+_C5@GOTOFF(%eax,%ebx) + fmul %st(1), %st + faddl 24+_C5@GOTOFF(%eax,%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fldl _C5@GOTOFF(%eax,%ebx) + fmul %st(2), %st + faddl 32+_C5@GOTOFF(%eax,%ebx) + fmul %st(2), %st + faddl _C5_0@GOTOFF(%ebx,%ecx,8) + fmul %st(2), %st + faddl 48+_C5@GOTOFF(%eax,%ebx) + fmul %st(2), %st + faddl 16+_C5@GOTOFF(%eax,%ebx) + fmulp %st, %st(2) + fxch %st(1) + faddl 16+_C5_0@GOTOFF(%ebx,%ecx,8) + fstpt (%esp) + je ..B2.32 +..B2.30: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.169: + addl $16, %esp +..B2.31: + fldt 36(%esp) +..B2.32: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstps 76(%esp) + je ..B2.34 +..B2.33: + fldcw 90(%esp) +..B2.34: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.35: + flds .L_2il0floatpacket.3@GOTOFF(%ebx) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.36 + je ..B2.130 +..B2.36: + cmpl $1073741824, %edi + jbe ..B2.42 +..B2.37: + fldl 8+_C4@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + testl %edx, %edx + fmul %st, %st(1) + fldl _C4@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(2) + faddl 40+_C4@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(2) + faddl 32+_C4@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(2) + faddl 72+_C4@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(2) + faddl 64+_C4@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(2) + faddl 56+_C4@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(2) + faddl 48+_C4@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(2) + faddl 24+_C4@GOTOFF(%ebx) + fmul %st(3), %st + fstpt 36(%esp) + fldt 36(%esp) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + fsubrp %st, %st(4) + fxch %st(2) + faddl 16+_C4@GOTOFF(%ebx) + fmulp %st, %st(1) + faddl 80+_C4@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + je ..B2.39 +..B2.38: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.170: + fldt 16(%esp) + addl $16, %esp +..B2.39: + fstps 76(%esp) + testl %esi, %esi + je ..B2.41 +..B2.40: + fldcw 90(%esp) +..B2.41: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.42: + cmpl $1071644672, %edi + jb ..B2.49 +..B2.43: + fldl 16+_C3@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + testl %edx, %edx + fmul %st, %st(1) + fxch %st(1) + faddl 48+_C3@GOTOFF(%ebx) + fmul %st(1), %st + faddl 32+_C3@GOTOFF(%ebx) + fmul %st(1), %st + faddl 64+_C3@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fldl 8+_C3@GOTOFF(%ebx) + fmul %st(2), %st + faddl 40+_C3@GOTOFF(%ebx) + fmul %st(2), %st + faddl 24+_C3@GOTOFF(%ebx) + fmul %st(2), %st + faddl 56+_C3@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + faddl _C3@GOTOFF(%ebx) + fstpt (%esp) + je ..B2.46 +..B2.44: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.171: + addl $16, %esp +..B2.45: + fldt 36(%esp) +..B2.46: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstps 76(%esp) + je ..B2.48 +..B2.47: + fldcw 90(%esp) +..B2.48: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.49: + cmpl $1069547520, %edi + jb ..B2.56 +..B2.50: + fldl 16+_LGAMMAF_C2@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + testl %edx, %edx + fmul %st, %st(1) + fxch %st(1) + faddl 48+_LGAMMAF_C2@GOTOFF(%ebx) + fmul %st(1), %st + faddl 32+_LGAMMAF_C2@GOTOFF(%ebx) + fmul %st(1), %st + faddl 64+_LGAMMAF_C2@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fldl 8+_LGAMMAF_C2@GOTOFF(%ebx) + fmul %st(2), %st + faddl 40+_LGAMMAF_C2@GOTOFF(%ebx) + fmul %st(2), %st + faddl 24+_LGAMMAF_C2@GOTOFF(%ebx) + fmul %st(2), %st + faddl 56+_LGAMMAF_C2@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + faddl _LGAMMAF_C2@GOTOFF(%ebx) + fstpt (%esp) + je ..B2.53 +..B2.51: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.172: + addl $16, %esp +..B2.52: + fldt 36(%esp) +..B2.53: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstps 76(%esp) + je ..B2.55 +..B2.54: + fldcw 90(%esp) +..B2.55: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.56: + cmpl $1067450368, %edi + jb ..B2.63 +..B2.57: + fldl 16+_C1@GOTOFF(%ebx) + testl %edx, %edx + fxch %st(1) + fsubl _LM@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(2) + faddl 48+_C1@GOTOFF(%ebx) + fmul %st(2), %st + faddl 32+_C1@GOTOFF(%ebx) + fmul %st(2), %st + faddl 64+_C1@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fldl 8+_C1@GOTOFF(%ebx) + fmul %st(2), %st + faddl 40+_C1@GOTOFF(%ebx) + fmul %st(2), %st + faddl 24+_C1@GOTOFF(%ebx) + fmul %st(2), %st + faddl 56+_C1@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + faddl _C1@GOTOFF(%ebx) + fstpt (%esp) + je ..B2.60 +..B2.58: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.173: + addl $16, %esp +..B2.59: + fldt 36(%esp) +..B2.60: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstps 76(%esp) + je ..B2.62 +..B2.61: + fldcw 90(%esp) +..B2.62: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.63: + cmpl $1065353216, %edi + jb ..B2.70 +..B2.64: + fldl 16+_C0@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + testl %edx, %edx + fmul %st, %st(1) + fxch %st(1) + faddl 48+_C0@GOTOFF(%ebx) + fmul %st(1), %st + faddl 32+_C0@GOTOFF(%ebx) + fmul %st(1), %st + faddl 64+_C0@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fldl 8+_C0@GOTOFF(%ebx) + fmul %st(2), %st + faddl 40+_C0@GOTOFF(%ebx) + fmul %st(2), %st + faddl 24+_C0@GOTOFF(%ebx) + fmul %st(2), %st + faddl 56+_C0@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + faddl _C0@GOTOFF(%ebx) + fstpt (%esp) + je ..B2.67 +..B2.65: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.174: + addl $16, %esp +..B2.66: + fldt 36(%esp) +..B2.67: + fldt (%esp) + testl %esi, %esi + faddp %st, %st(1) + fstps 76(%esp) + je ..B2.69 +..B2.68: + fldcw 90(%esp) +..B2.69: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.70: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + addl $-16, %esp + fadd %st(1), %st + fstpt (%esp) + fstpt 32(%esp) + movl %edx, 96(%esp) + call lgammaf_pos +..B2.176: + fldt 32(%esp) + movl 96(%esp), %edx + fxch %st(1) + fstpt 16(%esp) + fstpl (%esp) + movl %edx, 96(%esp) + call log@PLT +..B2.175: + movl 96(%esp), %edx + addl $16, %esp + fstpt 36(%esp) + fldt 36(%esp) + testl %edx, %edx + je ..B2.73 +..B2.71: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.177: + addl $16, %esp +..B2.72: + fldt 36(%esp) +..B2.73: + fldt (%esp) + testl %esi, %esi + fsubp %st, %st(1) + fstps 76(%esp) + je ..B2.75 +..B2.74: + fldcw 90(%esp) +..B2.75: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.76: + addl $-16, %esp + movl 8(%ebp), %eax + movl %eax, (%esp) + movl %edx, 96(%esp) + call nearbyintf@PLT +..B2.178: + flds 8(%ebp) + movl 96(%esp), %edx + addl $16, %esp + fxch %st(1) + fstps 76(%esp) + flds 76(%esp) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.77 + je ..B2.148 +..B2.77: + fcoms .L_2il0floatpacket.0@GOTOFF(%ebx) + fnstsw %ax + sahf + jbe ..B2.80 +..B2.78: + fld %st(0) + frndint + fcom %st(1) + fnstsw %ax + sahf + jnb ..L4 + fld1 + faddp %st, %st(1) +..L4: + fistpl 16(%esp) + movl 16(%esp), %eax + testb $1, %al + jne ..B2.80 +..B2.79: + movl 12(%esp), %eax + movl $-1, (%eax) +..B2.80: + cmpl $1073741824, %edi + jae ..B2.91 +..B2.81: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.145 +..B2.82: + fld %st(0) +..B2.83: + fmul %st(2), %st + fxch %st(1) + fadd %st, %st(2) + fcom %st(2) + fnstsw %ax + sahf + fxch %st(1) + ja ..B2.83 +..B2.84: + fstp %st(1) + fstpt 36(%esp) +..B2.85: + andb $127, 45(%esp) + fldt 36(%esp) + addl $-16, %esp + fstpl (%esp) + fstpt 80(%esp) + movl %edx, 96(%esp) + call log@PLT +..B2.180: + fldt 80(%esp) + movl 96(%esp), %edx + addl $16, %esp + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + addl $-16, %esp + fxch %st(1) + fstpt (%esp) + fstpt 16(%esp) + movl %edx, 96(%esp) + call lgammaf_pos +..B2.179: + fldt 16(%esp) + movl 96(%esp), %edx + addl $16, %esp + testl %edx, %edx + je ..B2.88 +..B2.86: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.181: + fldt 16(%esp) + addl $16, %esp +..B2.87: + fldt 36(%esp) +..B2.88: + testl %esi, %esi + fsubrp %st, %st(1) + fstps 76(%esp) + je ..B2.90 +..B2.89: + fldcw 90(%esp) +..B2.90: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.91: + cmpl $1082130432, %edi + jae ..B2.108 +..B2.92: + flds .L_2il0floatpacket.4@GOTOFF(%ebx) + fsub %st(1), %st + fstps 76(%esp) + flds 76(%esp) + flds .L_2il0floatpacket.5@GOTOFF(%ebx) + fadd %st, %st(1) + fxch %st(1) + fstps 76(%esp) + flds 76(%esp) + movl 76(%esp), %edi + fsubp %st, %st(1) + andl $1, %edi + fstps 76(%esp) + lea (%edi,%edi,2), %ecx + fcoml _LRIB@GOTOFF(%ebx,%ecx,8) + fnstsw %ax + sahf + jbe ..B2.95 +..B2.93: + fldl 16+_LRIB@GOTOFF(%ebx,%ecx,8) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.95 +..B2.94: + fldl 8+_LRIB@GOTOFF(%ebx,%ecx,8) + shll $5, %edi + fsubrp %st, %st(1) + fldl _LRP@GOTOFF(%edi,%ebx) + fmul %st(1), %st + faddl 8+_LRP@GOTOFF(%edi,%ebx) + fmul %st(1), %st + faddl 16+_LRP@GOTOFF(%edi,%ebx) + fmulp %st, %st(1) + faddl 24+_LRP@GOTOFF(%edi,%ebx) + jmp ..B2.103 +..B2.95: + fcoml _RRIB@GOTOFF(%ebx,%ecx,8) + fnstsw %ax + sahf + jbe ..B2.98 +..B2.96: + fldl 16+_RRIB@GOTOFF(%ebx,%ecx,8) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.98 +..B2.97: + fldl 8+_RRIB@GOTOFF(%ebx,%ecx,8) + shll $5, %edi + fsubrp %st, %st(1) + fldl _RRP@GOTOFF(%edi,%ebx) + fmul %st(1), %st + faddl 8+_RRP@GOTOFF(%edi,%ebx) + fmul %st(1), %st + faddl 16+_RRP@GOTOFF(%edi,%ebx) + fmulp %st, %st(1) + faddl 24+_RRP@GOTOFF(%edi,%ebx) + jmp ..B2.103 +..B2.98: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.146 +..B2.99: + fld %st(0) +..B2.100: + fmul %st(2), %st + fxch %st(1) + fadd %st, %st(2) + fcom %st(2) + fnstsw %ax + sahf + fxch %st(1) + ja ..B2.100 +..B2.101: + fstp %st(1) + fstpt 36(%esp) +..B2.102: + andb $127, 45(%esp) + fldt 36(%esp) + addl $-16, %esp + fstpl (%esp) + fstpt 80(%esp) + movl %edx, 96(%esp) + call log@PLT +..B2.183: + fldt 80(%esp) + movl 96(%esp), %edx + addl $16, %esp + fxch %st(1) + fstl (%esp) + fstpt 36(%esp) + addl $-16, %esp + fstpt (%esp) + movl %edx, 96(%esp) + call lgammaf_pos +..B2.182: + movl 96(%esp), %edx + addl $16, %esp + fsubl (%esp) +..B2.103: + testl %edx, %edx + je ..B2.105 +..B2.104: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.184: + fldt 16(%esp) + addl $16, %esp +..B2.105: + fstps 76(%esp) + testl %esi, %esi + je ..B2.107 +..B2.106: + fldcw 90(%esp) +..B2.107: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.108: + cmpl $1091567616, %edi + jae ..B2.119 +..B2.109: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.147 +..B2.110: + fld %st(0) +..B2.111: + fmul %st(2), %st + fxch %st(1) + fadd %st, %st(2) + fcom %st(2) + fnstsw %ax + sahf + fxch %st(1) + ja ..B2.111 +..B2.112: + fstp %st(1) + fstpt 36(%esp) +..B2.113: + andb $127, 45(%esp) + fldt 36(%esp) + addl $-16, %esp + fstpl (%esp) + fstpt 80(%esp) + movl %edx, 96(%esp) + call log@PLT +..B2.186: + fldt 80(%esp) + movl 96(%esp), %edx + addl $16, %esp + fxch %st(1) + fstpt 36(%esp) + fldt 36(%esp) + addl $-16, %esp + fxch %st(1) + fstpt (%esp) + fstpt 16(%esp) + movl %edx, 96(%esp) + call lgammaf_pos +..B2.185: + fldt 16(%esp) + movl 96(%esp), %edx + addl $16, %esp + testl %edx, %edx + je ..B2.116 +..B2.114: + fstp %st(0) + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.187: + fldt 16(%esp) + addl $16, %esp +..B2.115: + fldt 36(%esp) +..B2.116: + testl %esi, %esi + fsubrp %st, %st(1) + fstps 76(%esp) + je ..B2.118 +..B2.117: + fldcw 90(%esp) +..B2.118: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.119: + flds .L_2il0floatpacket.5@GOTOFF(%ebx) + cmpl $1174405120, %edi + jb ..B2.125 +..B2.120: + fldt _LN_SQRT_TWO_PI@GOTOFF(%ebx) + fstpt 24(%esp) + addl $-16, %esp + fld %st(1) + fchs + fstpl (%esp) + fstps 16(%esp) + fstpt 80(%esp) + fldt 80(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + movl %edx, 96(%esp) + fsubrp %st, %st(1) + fstpt 24(%esp) + call log@PLT +..B2.189: + fldt 80(%esp) + flds 16(%esp) + fldt 24(%esp) + movl 96(%esp), %edx + addl $16, %esp + fmulp %st, %st(3) + fsts 76(%esp) + fldt 24(%esp) + fsubrp %st, %st(3) + fxch %st(1) + fsubr %st, %st(2) + fchs + flds 76(%esp) + fldl _S16@GOTOFF(%ebx) + fxch %st(1) + fsubs 8(%ebp) + fstps 76(%esp) + flds 76(%esp) + fsubp %st, %st(3) + fxch %st(2) + fstps 76(%esp) + flds 76(%esp) + fsubrp %st, %st(1) + fstpt 52(%esp) + fldt 52(%esp) + fmul %st(0), %st + fmul %st, %st(1) + andb $127, 61(%esp) + fxch %st(1) + faddl _S14@GOTOFF(%ebx) + fmul %st(1), %st + faddl _S12@GOTOFF(%ebx) + fmul %st(1), %st + faddl _S10@GOTOFF(%ebx) + fmul %st(1), %st + faddl _S08@GOTOFF(%ebx) + fmul %st(1), %st + faddl _S06@GOTOFF(%ebx) + fmul %st(1), %st + faddl _S04@GOTOFF(%ebx) + fmul %st(1), %st + faddl _S02@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fsubrp %st, %st(1) + fldt 52(%esp) + addl $-16, %esp + fstpl (%esp) + fstpt 24(%esp) + movl %edx, 96(%esp) + call log@PLT +..B2.188: + fldt 24(%esp) + movl 96(%esp), %edx + addl $16, %esp + testl %edx, %edx + fxch %st(1) + je ..B2.122 +..B2.121: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + fstpl 16(%esp) + fstpt 24(%esp) + call fesetround +..B2.190: + fldt 24(%esp) + fldl 16(%esp) + addl $16, %esp +..B2.122: + testl %esi, %esi + fsubrp %st, %st(1) + fstps 76(%esp) + je ..B2.124 +..B2.123: + fldcw 90(%esp) +..B2.124: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.125: + fld %st(0) + fsub %st(2), %st + fstps 76(%esp) + flds 76(%esp) + fsubp %st, %st(1) + fstps 76(%esp) + fld %st(0) + fchs + fstpt 40(%esp) + fldt 40(%esp) + fxch %st(1) + fchs + flds 76(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 52(%esp) + fldt 52(%esp) + fmul %st(0), %st + fstpt 24(%esp) + addl $-16, %esp + fstpl (%esp) + movl %edx, 96(%esp) + call log@PLT +..B2.193: + movl 96(%esp), %edx + fchs + fldt 56(%esp) + fstpt (%esp) + fstpt 24(%esp) + movl %edx, 96(%esp) + call lgammaf_pos +..B2.192: + fldt 24(%esp) + movl 96(%esp), %edx + fsubp %st, %st(1) + addl $16, %esp + fldt 24(%esp) + fld %st(0) + fmul %st(1), %st + fldl _S14@GOTOFF(%ebx) + fmul %st(1), %st + fldl _S16@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl _S10@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl _S12@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl _S06@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl _S08@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl _S02@GOTOFF(%ebx) + fmulp %st, %st(3) + faddl _S04@GOTOFF(%ebx) + fmulp %st, %st(1) + andb $127, 61(%esp) + faddp %st, %st(1) + fstpt 36(%esp) + fldt 36(%esp) + fsubrp %st, %st(1) + fldt 52(%esp) + addl $-16, %esp + fstpl (%esp) + fstpt 24(%esp) + movl %edx, 96(%esp) + call log@PLT +..B2.191: + fldt 24(%esp) + movl 96(%esp), %edx + addl $16, %esp + testl %edx, %edx + fxch %st(1) + je ..B2.127 +..B2.126: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + fstpl 16(%esp) + fstpt 24(%esp) + call fesetround +..B2.194: + fldt 24(%esp) + fldl 16(%esp) + addl $16, %esp +..B2.127: + testl %esi, %esi + fsubrp %st, %st(1) + fstps 76(%esp) + je ..B2.129 +..B2.128: + fldcw 90(%esp) +..B2.129: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.130: + fstp %st(0) + testl %esi, %esi + je ..B2.132 +..B2.131: + fldcw 90(%esp) +..B2.132: + testl %edx, %edx + je ..B2.134 +..B2.133: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.195: + addl $16, %esp +..B2.134: + fldz + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.135: + fstp %st(0) + testl %esi, %esi + je ..B2.137 +..B2.136: + fldcw 90(%esp) +..B2.137: + testl %edx, %edx + je ..B2.139 +..B2.138: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.196: + addl $16, %esp +..B2.139: + fldz + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.140: + testl %edx, %edx + je ..B2.142 +..B2.141: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.197: + addl $16, %esp +..B2.142: + fldl _PBIG@GOTOFF(%ebx) + testl %esi, %esi + fmul %st(0), %st + fstps 76(%esp) + je ..B2.144 +..B2.143: + fldcw 90(%esp) +..B2.144: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.145: + fstpt 36(%esp) + jmp ..B2.85 +..B2.146: + fstpt 36(%esp) + jmp ..B2.102 +..B2.147: + fstpt 36(%esp) + jmp ..B2.113 +..B2.148: + fstp %st(0) + testl %edx, %edx + je ..B2.150 +..B2.149: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.198: + addl $16, %esp +..B2.150: + fld1 + movl $0, 76(%esp) + testl %esi, %esi + flds 76(%esp) + fdivrp %st, %st(1) + fstps 76(%esp) + je ..B2.152 +..B2.151: + fldcw 90(%esp) +..B2.152: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.153: + cmpl $0, (%esp) + je ..B2.155 +..B2.154: + movl 12(%esp), %eax + movl $-1, (%eax) + jmp ..B2.156 +..B2.155: + movl 12(%esp), %eax + movl $1, (%eax) +..B2.156: + testl %edx, %edx + je ..B2.158 +..B2.157: + addl $-16, %esp + movl 100(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.199: + addl $16, %esp +..B2.158: + fld1 + movl $0, 76(%esp) + testl %esi, %esi + flds 76(%esp) + fdivrp %st, %st(1) + fstps 76(%esp) + je ..B2.160 +..B2.159: + fldcw 90(%esp) +..B2.160: + flds 76(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.161: + xorl %esi, %esi + jmp ..B2.12 + .align 16,0x90 + .type __libm_lgammaf,@function + .size __libm_lgammaf,.-__libm_lgammaf + .data +# -- End __libm_lgammaf + .text +# -- Begin lgammaf_pos + .text + .align 16,0x90 +lgammaf_pos: +# parameter 1: 8 + %ebp +..B3.1: +..L5: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp + fldt 8(%ebp) + fstl (%esp) + movzwl 6(%esp), %edx + andl $32752, %edx + shrl $4, %edx + movl 4(%esp), %eax + shll $20, %edx + andl $1048575, %eax + orl %eax, %edx + call ..L6 +..L6: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L6](%ecx), %ecx + cmpl $1074790400, %edx + jb ..B3.3 +..B3.2: + addl $-1074790400, %edx + sarl $20, %edx + movl %edx, %eax + shll $6, %eax + flds _A@GOTOFF(%ecx,%edx,4) + fsubrp %st, %st(1) + fmuls _B@GOTOFF(%ecx,%edx,4) + lea (%edx,%edx,2), %edx + fld %st(0) + fmul %st(1), %st + fldl _C5@GOTOFF(%eax,%ecx) + fmul %st(1), %st + fldl 8+_C5@GOTOFF(%ecx,%eax) + fmul %st(2), %st + fxch %st(1) + faddl 32+_C5@GOTOFF(%ecx,%eax) + fmul %st(2), %st + fxch %st(1) + faddl 40+_C5@GOTOFF(%ecx,%eax) + fmul %st(2), %st + fxch %st(1) + faddl _C5_0@GOTOFF(%ecx,%edx,8) + fmul %st(2), %st + fxch %st(1) + faddl 8+_C5_0@GOTOFF(%ecx,%edx,8) + fmul %st(2), %st + fxch %st(1) + faddl 48+_C5@GOTOFF(%ecx,%eax) + fmul %st(2), %st + fxch %st(1) + faddl 56+_C5@GOTOFF(%ecx,%eax) + fmul %st(2), %st + fxch %st(1) + faddl 16+_C5@GOTOFF(%ecx,%eax) + fmulp %st, %st(2) + faddl 24+_C5@GOTOFF(%ecx,%eax) + fmulp %st, %st(2) + faddl 16+_C5_0@GOTOFF(%ecx,%edx,8) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.3: + cmpl $1073741824, %edx + jne ..B3.5 +..B3.4: + fstp %st(0) + fldt .L_2il0floatpacket.7@GOTOFF(%ecx) + movl %ebp, %esp + popl %ebp + ret +..B3.5: + jbe ..B3.7 +..B3.6: + fldl _C4@GOTOFF(%ecx) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fldl 8+_C4@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 32+_C4@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 40+_C4@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 64+_C4@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 72+_C4@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 48+_C4@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 56+_C4@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 16+_C4@GOTOFF(%ecx) + fmulp %st, %st(1) + fxch %st(1) + faddl 24+_C4@GOTOFF(%ecx) + fmul %st(2), %st + fxch %st(1) + faddl 80+_C4@GOTOFF(%ecx) + faddp %st, %st(1) + fldt .L_2il0floatpacket.6@GOTOFF(%ecx) + fsubrp %st, %st(2) + fmulp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.7: + cmpl $1073479680, %edx + jb ..B3.9 +..B3.8: + fldl 8+_C3@GOTOFF(%ecx) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fldl 16+_C3@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 40+_C3@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 48+_C3@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 24+_C3@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 32+_C3@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 56+_C3@GOTOFF(%ecx) + fmulp %st, %st(1) + fxch %st(1) + faddl 64+_C3@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl _C3@GOTOFF(%ecx) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.9: + cmpl $1073217536, %edx + jb ..B3.11 +..B3.10: + fldl 8+_LGAMMAF_C2@GOTOFF(%ecx) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fldl 16+_LGAMMAF_C2@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 40+_LGAMMAF_C2@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 48+_LGAMMAF_C2@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 24+_LGAMMAF_C2@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 32+_LGAMMAF_C2@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 56+_LGAMMAF_C2@GOTOFF(%ecx) + fmulp %st, %st(1) + fxch %st(1) + faddl 64+_LGAMMAF_C2@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl _LGAMMAF_C2@GOTOFF(%ecx) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.11: + cmpl $1072955392, %edx + jb ..B3.13 +..B3.12: + fldl _LM@GOTOFF(%ecx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl 8+_C1@GOTOFF(%ecx) + fmul %st(1), %st + fldl 16+_C1@GOTOFF(%ecx) + fmul %st(2), %st + fxch %st(1) + faddl 40+_C1@GOTOFF(%ecx) + fmul %st(2), %st + fxch %st(1) + faddl 48+_C1@GOTOFF(%ecx) + fmul %st(2), %st + fxch %st(1) + faddl 24+_C1@GOTOFF(%ecx) + fmul %st(2), %st + fxch %st(1) + faddl 32+_C1@GOTOFF(%ecx) + fmul %st(2), %st + fxch %st(1) + faddl 56+_C1@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl 64+_C1@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl _C1@GOTOFF(%ecx) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.13: + cmpl $1072693248, %edx + jb ..B3.15 +..B3.14: + fldl 8+_C0@GOTOFF(%ecx) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fldl 16+_C0@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 40+_C0@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 48+_C0@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 24+_C0@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 32+_C0@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(2) + faddl 56+_C0@GOTOFF(%ecx) + fmulp %st, %st(1) + fxch %st(1) + faddl 64+_C0@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl _C0@GOTOFF(%ecx) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B3.15: + fstp %st(0) + fldz +..B3.16: + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type lgammaf_pos,@function + .size lgammaf_pos,.-lgammaf_pos + .data +# -- End lgammaf_pos + .text +# -- Begin gammaf + .text + .align 16,0x90 + .globl gammaf +gammaf: +# parameter 1: 32 + %esp +..B4.1: +..L7: + + subl $20, %esp + lea 8(%esp), %eax + pushl %eax + pushl 28(%esp) + call __libm_lgammaf +..B4.2: + addl $28, %esp + ret + .align 16,0x90 + .type gammaf,@function + .size gammaf,.-gammaf + .data +# -- End gammaf + .text +# -- Begin lgammaf_r + .text + .align 16,0x90 + .globl lgammaf_r +lgammaf_r: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +..B5.1: +..L8: + + jmp __libm_lgammaf + .align 16,0x90 + .type lgammaf_r,@function + .size lgammaf_r,.-lgammaf_r + .data +# -- End lgammaf_r + .text +# -- Begin gammaf_r + .text + .align 16,0x90 + .globl gammaf_r +gammaf_r: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +..B6.1: +..L9: + + jmp __libm_lgammaf + .align 16,0x90 + .type gammaf_r,@function + .size gammaf_r,.-gammaf_r + .data +# -- End gammaf_r + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .space 4, 0x00 # pad + .align 16 +_LN_SQRT_TWO_PI: + .word 42293 + .word 9717 + .word 36419 + .word 60223 + .word 16382 + .word 0 + .type _LN_SQRT_TWO_PI,@object + .size _LN_SQRT_TWO_PI,12 + .space 4, 0x00 # pad + .align 16 +_A: + .long 1082130432 + .long 1090519040 + .long 1098907648 + .long 1107296256 + .long 1115684864 + .long 1124073472 + .long 1132462080 + .long 1140850688 + .long 1149239296 + .long 1157627904 + .long 1166016512 + .type _A,@object + .size _A,44 + .space 4, 0x00 # pad + .align 16 +_B: + .long 1048576000 + .long 1040187392 + .long 1031798784 + .long 1023410176 + .long 1015021568 + .long 1006632960 + .long 998244352 + .long 989855744 + .long 981467136 + .long 973078528 + .long 964689920 + .type _B,@object + .size _B,44 + .space 4, 0x00 # pad + .align 16 +_C5: + .long 2219950285 + .long 1064025046 + .long 657069815 + .long 3214307011 + .long 2744833897 + .long 1073883684 + .long 3746154693 + .long 1075058958 + .long 24044097 + .long 1068577021 + .long 1852002888 + .long 3217117620 + .long 426096126 + .long 1071550305 + .long 3945160253 + .long 3219869968 + .long 889741930 + .long 1064529657 + .long 2918550257 + .long 3214927323 + .long 3306758232 + .long 1074858655 + .long 2801363753 + .long 1076895752 + .long 216130741 + .long 1069082446 + .long 2022127190 + .long 3217667546 + .long 4043317980 + .long 1072274701 + .long 948933764 + .long 3220711872 + .long 1837011561 + .long 1065353117 + .long 614133169 + .long 3215620106 + .long 128884864 + .long 1075872424 + .long 1749057555 + .long 1078324632 + .long 1278187959 + .long 1069867493 + .long 1878987920 + .long 3218464301 + .long 2508500615 + .long 1073176520 + .long 3716705454 + .long 3221664954 + .long 1971591775 + .long 1066198339 + .long 3489274850 + .long 3216507307 + .long 2978044890 + .long 1076904104 + .long 399657850 + .long 1079744937 + .long 2176842243 + .long 1070795947 + .long 1642919051 + .long 3219397359 + .long 325839939 + .long 1074155724 + .long 1189620011 + .long 3222667808 + .long 583706808 + .long 1067149757 + .long 1974968851 + .long 3217478792 + .long 3433705325 + .long 1077944360 + .long 3946626575 + .long 1081121452 + .long 1495561758 + .long 1071787114 + .long 4062466621 + .long 3220390645 + .long 1556755231 + .long 1075170624 + .long 75679593 + .long 3223694033 + .long 3504606470 + .long 1068150172 + .long 1348305099 + .long 3218489288 + .long 3580634696 + .long 1078988808 + .long 1259291510 + .long 1082352761 + .long 652214916 + .long 1072807425 + .long 4143445962 + .long 3221412067 + .long 2123749472 + .long 1076202613 + .long 4248403985 + .long 3224731560 + .long 1507106795 + .long 1069174188 + .long 3519298167 + .long 3219518582 + .long 3633366982 + .long 1080035328 + .long 2867629808 + .long 1083583554 + .long 3975256969 + .long 1073841792 + .long 2533063588 + .long 3222447083 + .long 3711656185 + .long 1077242956 + .long 3206083648 + .long 3225774644 + .long 4129446490 + .long 1070209876 + .long 3121668168 + .long 3220557159 + .long 3645659330 + .long 1081082878 + .long 1254870306 + .long 1084814091 + .long 1589013900 + .long 1074883091 + .long 485315198 + .long 3223488795 + .long 402512060 + .long 1078287430 + .long 1922980292 + .long 3226820482 + .long 157052617 + .long 1071251449 + .long 2992469705 + .long 3221600396 + .long 1492808525 + .long 1082130942 + .long 3131814131 + .long 1086044499 + .long 2683002247 + .long 1075927855 + .long 2649378904 + .long 3224533843 + .long 3018380877 + .long 1079333956 + .long 653917322 + .long 3227867691 + .long 2713966257 + .long 1072296037 + .long 4209563533 + .long 3222646006 + .long 943575735 + .long 1083179262 + .long 512478091 + .long 1087274844 + .long 3856346814 + .long 1076974372 + .long 1324813592 + .long 3225580569 + .long 1409229319 + .long 1080381507 + .long 3787450294 + .long 3228915583 + .long 3333539597 + .long 1073342203 + .long 2943809629 + .long 3223692845 + .long 794946536 + .long 1084227710 + .long 1068889795 + .long 1088463522 + .long 3231716378 + .long 1078021787 + .long 4072054083 + .long 3226628144 + .long 1998042203 + .long 1081429569 + .long 1148344549 + .long 3229963818 + .type _C5,@object + .size _C5,704 + .align 16 +_C5_0: + .long 2415979356 + .long 1070304454 + .long 2697119297 + .long 3218348439 + .long 4195263586 + .long 1073523467 + .long 3725211212 + .long 1070931684 + .long 2560716363 + .long 3219131775 + .long 4079479268 + .long 1075907809 + .long 1732432466 + .long 1071796064 + .long 3508892908 + .long 3219947991 + .long 2788858919 + .long 1077667382 + .long 2647999156 + .long 1072759450 + .long 547175205 + .long 3220886396 + .long 4254853098 + .long 1079215590 + .long 2099688739 + .long 1073767129 + .long 1386213411 + .long 3221881825 + .long 1373988558 + .long 1080631372 + .long 3012547841 + .long 1074795638 + .long 3012018428 + .long 3222904295 + .long 3968063321 + .long 1082046682 + .long 2372211290 + .long 1075829504 + .long 1852200321 + .long 3223939920 + .long 822603622 + .long 1083320025 + .long 2940107565 + .long 1076868074 + .long 1118670349 + .long 3224982033 + .long 4034033966 + .long 1084551076 + .long 3328910691 + .long 1077911588 + .long 4065388177 + .long 3226027369 + .long 3374537656 + .long 1085781831 + .long 3604631852 + .long 1078957575 + .long 786281660 + .long 3227074315 + .long 3320933858 + .long 1087012393 + .long 4128496013 + .long 1080004805 + .long 820316847 + .long 3228122065 + .long 596318476 + .long 1088242837 + .type _C5_0,@object + .size _C5_0,264 + .space 8, 0x00 # pad + .align 16 +_C4: + .long 951661919 + .long 3199388794 + .long 406044492 + .long 1057185581 + .long 2144499589 + .long 3220511658 + .long 1533861631 + .long 1073519965 + .long 4190848711 + .long 3208779382 + .long 4195628742 + .long 1064581106 + .long 501584638 + .long 3218581252 + .long 4276665641 + .long 1072296199 + .long 2679252139 + .long 3214810152 + .long 1146917984 + .long 1069511714 + .long 3597634954 + .long 3220184694 + .type _C4,@object + .size _C4,88 + .space 8, 0x00 # pad + .align 16 +_C3: + .long 953601802 + .long 1073782987 + .long 53392282 + .long 1061851682 + .long 2280564131 + .long 3213671573 + .long 126074441 + .long 1073190208 + .long 1099663909 + .long 3221770684 + .long 2017365083 + .long 1069271442 + .long 1709742889 + .long 3219105406 + .long 4029656968 + .long 1074967560 + .long 3888843833 + .long 3222480972 + .type _C3,@object + .size _C3,72 + .space 8, 0x00 # pad + .align 16 +_LGAMMAF_C2: + .long 4192182476 + .long 1073863432 + .long 3945858175 + .long 1063638439 + .long 2616885214 + .long 3215216300 + .long 3886441432 + .long 1074077679 + .long 3758761250 + .long 3222447567 + .long 984616456 + .long 1070653784 + .long 2508733349 + .long 3220210863 + .long 2272977058 + .long 1075337602 + .long 3074119607 + .long 3222665277 + .type _LGAMMAF_C2,@object + .size _LGAMMAF_C2,72 + .space 8, 0x00 # pad + .align 16 +_C1: + .long 3166931522 + .long 3216972217 + .long 900077338 + .long 1065586189 + .long 3591574455 + .long 3213040571 + .long 425993680 + .long 1068534592 + .long 2772351024 + .long 3217220647 + .long 3693139651 + .long 1066567133 + .long 2619486276 + .long 3214985484 + .long 3371509884 + .long 1071576875 + .long 2931564028 + .long 1032391485 + .type _C1,@object + .size _C1,72 + .space 8, 0x00 # pad + .align 16 +_LM: + .long 1666629183 + .long 1073177304 + .type _LM,@object + .size _LM,8 + .space 8, 0x00 # pad + .align 16 +_C0: + .long 561403216 + .long 1074066324 + .long 3155481408 + .long 1068272863 + .long 4228834524 + .long 3219267730 + .long 2107372888 + .long 1076349696 + .long 3392182390 + .long 3224133636 + .long 3282054928 + .long 1074040136 + .long 4253763640 + .long 3223020498 + .long 1528000942 + .long 1076400076 + .long 4059292707 + .long 3223275314 + .type _C0,@object + .size _C0,72 + .space 8, 0x00 # pad + .align 16 +_LRIB: + .long 2838661661 + .long 3221617475 + .long 169597185 + .long 3221617473 + .long 1795500005 + .long 3221617470 + .long 3503748181 + .long 3222250619 + .long 1417424869 + .long 3222250609 + .long 2147483648 + .long 3222250589 + .type _LRIB,@object + .size _LRIB,48 + .align 16 +_LRP: + .long 3272807679 + .long 3224639578 + .long 1009311715 + .long 1076045439 + .long 2835657108 + .long 3221135661 + .long 817526409 + .long 1017707397 + .long 2658191496 + .long 3232572725 + .long 2929834182 + .long 1081046750 + .long 2523682372 + .long 3224680861 + .long 915934040 + .long 3166559235 + .type _LRP,@object + .size _LRP,64 + .align 16 +_RRIB: + .long 890743176 + .long 3221465087 + .long 2516645996 + .long 3221465084 + .long 4142548816 + .long 3221465081 + .long 1538591435 + .long 3221825040 + .long 3164494255 + .long 3221825037 + .long 495429779 + .long 3221825035 + .type _RRIB,@object + .size _RRIB,48 + .align 16 +_RRP: + .long 93164946 + .long 1073124518 + .long 2953029931 + .long 1075015403 + .long 1722766176 + .long 1073233897 + .long 1830807661 + .long 1016083003 + .long 308861496 + .long 1079775543 + .long 2541562915 + .long 1077531858 + .long 1596959842 + .long 1075781798 + .long 3819862626 + .long 1021220357 + .type _RRP,@object + .size _RRP,64 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .align 4 +.L_2il0floatpacket.0: + .long 0xcb400000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x40000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +.L_2il0floatpacket.4: + .long 0xc0200000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .align 4 +.L_2il0floatpacket.5: + .long 0x4b400000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,4 + .align 4 +_S16: + .long 2760304672 + .long 3218442033 + .type _S16,@object + .size _S16,8 + .align 4 +_S14: + .long 3264091561 + .long 3215213868 + .type _S14,@object + .size _S14,8 + .align 4 +_S12: + .long 1381164920 + .long 3217582605 + .type _S12,@object + .size _S12,8 + .align 4 +_S10: + .long 3387828299 + .long 3217636872 + .type _S10,@object + .size _S10,8 + .align 4 +_S08: + .long 3786959951 + .long 3218084854 + .type _S08,@object + .size _S08,8 + .align 4 +_S06: + .long 2675586079 + .long 3218453489 + .type _S06,@object + .size _S06,8 + .align 4 +_S04: + .long 1432133341 + .long 3219214642 + .type _S04,@object + .size _S04,8 + .align 4 +_S02: + .long 1648889397 + .long 3220853158 + .type _S02,@object + .size _S02,8 + .align 4 +_PBIG: + .long 2139095039 + .long 2139095039 + .type _PBIG,@object + .size _PBIG,8 + .data + .hidden fesetround + .hidden fegetround + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lgammal.S b/external/sgx_libm/ia32/lgammal.S new file mode 100644 index 0000000000..ff23a64296 --- /dev/null +++ b/external/sgx_libm/ia32/lgammal.S @@ -0,0 +1,8398 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lgammal.c" + .text +..TXTST0: +# -- Begin lgammal + .text + .align 16,0x90 + .globl lgammal +lgammal: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + subl $28, %esp + fldt 32(%esp) + lea 16(%esp), %eax + fstpt (%esp) + movl %eax, 12(%esp) + call __libm_lgammal +..B1.2: + addl $28, %esp + ret + .align 16,0x90 + .type lgammal,@function + .size lgammal,.-lgammal + .data +# -- End lgammal + .text +# -- Begin __libm_lgammal + .text + .align 16,0x90 +__libm_lgammal: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B2.1: +..L2: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + movl 20(%ebp), %eax + movl %eax, 44(%esp) + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 232(%esp) +..B2.2: + fnstcw 182(%esp) +..B2.3: + call fegetround +..B2.291: + movl %eax, 140(%esp) +..B2.4: + cmpl $0, 140(%esp) + jne ..B2.6 +..B2.5: + xorl %edi, %edi + jmp ..B2.8 +..B2.6: + addl $-16, %esp + movl $0, (%esp) + call fesetround +..B2.292: + addl $16, %esp +..B2.7: + movl $1, %edi +..B2.8: + movzwl 182(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.288 +..B2.9: + orl $-64768, %edx + movw %dx, 180(%esp) +..B2.10: + fldcw 180(%esp) +..B2.11: + movl $1, %esi +..B2.12: + movzbl 17(%ebp), %eax + movl %eax, (%esp) + andl $128, %eax + shrl $7, %eax + call ..L3 +..L3: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L3](%ebx), %ebx + movzwl 16(%ebp), %edx + andl $32767, %edx + flds ones@GOTOFF(%ebx,%eax,4) + shll $15, %eax + movl 12(%ebp), %ecx + orl %edx, %eax + movl %ecx, 8(%esp) + shll $16, %eax + shrl $16, %ecx + orl %ecx, %eax + movl %eax, 4(%esp) + cmpl $32767, %edx + je ..B2.273 +..B2.13: + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fucom %st(1) + fnstsw %ax + sahf + jp ..B2.14 + je ..B2.266 +..B2.14: + fldt _OFW_BOUND@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + sahf + jb ..B2.258 +..B2.15: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fucom %st(2) + fnstsw %ax + sahf + jp ..B2.16 + je ..B2.249 +..B2.16: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fstpt 168(%esp) + fldt 168(%esp) + fucomp %st(3) + fnstsw %ax + sahf + jp ..B2.17 + je ..B2.249 +..B2.17: + cmpl $0, 4(%esp) + jl ..B2.241 +..B2.18: + cmpl $16382, %edx + jl ..B2.177 +..B2.19: + cmpl $16463, %edx + jge ..B2.170 +..B2.20: + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B2.160 +..B2.21: + fldt .L_2il0floatpacket.5@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jae ..B2.121 + jp ..B2.121 +..B2.22: + fstp %st(3) + movl 4(%esp), %eax + andl $2147483647, %eax + cmpl $1073659904, %eax + jl ..B2.112 +..B2.23: + fcom %st(1) + fnstsw %ax + sahf + jae ..B2.26 + jp ..B2.26 +..B2.24: + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B2.26 +..B2.25: + fstp %st(0) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + movl 44(%esp), %eax + movl $1, (%eax) + jmp ..B2.29 +..B2.26: + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fcom %st(2) + fnstsw %ax + sahf + jae ..B2.39 + jp ..B2.39 +..B2.27: + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B2.39 +..B2.28: + fstp %st(1) + movl 44(%esp), %eax + movl $1, (%eax) +..B2.29: + fcomp %st(1) + fnstsw %ax + lea 2100+_ldbA@GOTOFF(%ebx), %edx + sahf + lea 480+_dbA@GOTOFF(%ebx), %ecx + jae ..B2.31 + jp ..B2.31 +..B2.30: + fstp %st(1) + fldt 168(%esp) + addl $176, %ecx + addl $84, %edx + fsubrp %st, %st(1) + jmp ..B2.32 +..B2.31: + fsubrp %st, %st(1) +..B2.32: + fldl _TWO_32H@GOTOFF(%ebx) + fld %st(1) + fmul %st(1), %st + fld %st(2) + testl %edi, %edi + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(2) + fsub %st(1), %st + fldl 88(%ecx) + fmul %st(4), %st + fldt (%edx) + fldt 36(%edx) + fldt 12(%edx) + fxch %st(3) + faddl 104(%ecx) + fmul %st(7), %st + faddl 96(%ecx) + fmul %st(7), %st + faddl 80(%ecx) + fmul %st(7), %st + faddl 152(%ecx) + fmul %st(7), %st + faddl 120(%ecx) + fmul %st(7), %st + faddl 112(%ecx) + fmul %st(7), %st + faddl 136(%ecx) + fmul %st(7), %st + faddl 128(%ecx) + fmul %st(7), %st + faddl 40(%ecx) + fmul %st(7), %st + faddl 32(%ecx) + fmul %st(7), %st + faddl 56(%ecx) + fmul %st(7), %st + faddl 48(%ecx) + fmul %st(7), %st + faddl 144(%ecx) + fmul %st(7), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(1) + fmul %st(5), %st + faddp %st, %st(1) + fmul %st(4), %st + fldt 48(%edx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 24(%edx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 60(%edx) + faddp %st, %st(1) + fmul %st(4), %st + fld %st(3) + fldt 72(%edx) + faddp %st, %st(2) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + fmul %st(6), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fldl (%ecx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(5) + fmul %st(2), %st + fxch %st(1) + faddl 72(%ecx) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st(5), %st + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldl 16(%ecx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl 168(%ecx) + faddp %st, %st(2) + fld %st(5) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldl 64(%ecx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl 8(%ecx) + faddp %st, %st(2) + fld %st(5) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldl 160(%ecx) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(6) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddl 24(%ecx) + faddp %st, %st(1) + fld %st(1) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(2) + fmul %st(4), %st + fxch %st(1) + fsub %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 4(%esp) + fldt 4(%esp) + fxch %st(1) + je ..B2.35 +..B2.33: + fstp %st(1) + fstp %st(0) + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.293: + addl $16, %esp +..B2.34: + fldt 4(%esp) + fldt 16(%esp) +..B2.35: + testl %esi, %esi + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.37 +..B2.36: + fldcw 182(%esp) +..B2.37: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.38: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.39: + fstp %st(0) + fcom %st(1) + fnstsw %ax + sahf + jae ..B2.48 + jp ..B2.48 +..B2.40: + fldt 168(%esp) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B2.48 +..B2.41: + fstp %st(2) + fstp %st(1) + movl 44(%esp), %eax + addl $-32, %esp + lea 832+_dbA@GOTOFF(%ebx), %edx + lea 36(%esp), %ecx + movl $1, (%eax) + lea 2268+_ldbA@GOTOFF(%ebx), %eax + fldt (%eax) + addl $12, %eax + fsubrp %st, %st(1) + fstpt (%esp) + call __libm_p25 +..B2.294: + addl $32, %esp +..B2.42: + testl %edi, %edi + je ..B2.44 +..B2.43: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.295: + addl $16, %esp +..B2.44: + fldt 4(%esp) + testl %esi, %esi + fldt 16(%esp) + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.46 +..B2.45: + fldcw 182(%esp) +..B2.46: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.47: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.48: + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.103 +..B2.49: + fldt .L_2il0floatpacket.14@GOTOFF(%ebx) + fcom %st(2) + fnstsw %ax + sahf + jae ..B2.58 + jp ..B2.58 +..B2.50: + fstp %st(0) + fldt .L_2il0floatpacket.15@GOTOFF(%ebx) + fcom %st(2) + fnstsw %ax + sahf + jbe ..B2.58 +..B2.51: + fstp %st(3) + fstp %st(0) + movl 44(%esp), %eax + addl $-32, %esp + fsubp %st, %st(1) + movl $-1, (%eax) + lea 2568+_ldbA@GOTOFF(%ebx), %eax + fstpt (%esp) + lea 1360+_dbA@GOTOFF(%ebx), %edx + lea 36(%esp), %ecx + call __libm_p25 +..B2.296: + addl $32, %esp +..B2.52: + testl %edi, %edi + je ..B2.54 +..B2.53: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.297: + addl $16, %esp +..B2.54: + fldt 4(%esp) + testl %esi, %esi + fldt 16(%esp) + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.56 +..B2.55: + fldcw 182(%esp) +..B2.56: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.57: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.58: + fstp %st(0) + addl $-16, %esp + fxch %st(1) + fstpt (%esp) + fldt (%esp) + movl %edx, 16(%esp) + fxch %st(2) + fstpt 144(%esp) + fstpt 160(%esp) + fstpt 48(%esp) + call nearbyintl@PLT +..B2.298: + fldt 48(%esp) + movl 16(%esp), %edx + fucom %st(1) + fnstsw %ax + fldt 160(%esp) + fldt 144(%esp) + addl $16, %esp + sahf + jp ..B2.59 + je ..B2.205 +..B2.59: + fldt .L_2il0floatpacket.17@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + ja ..B2.71 + jp ..B2.71 +..B2.60: + fldt .L_2il0floatpacket.18@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jb ..B2.71 +..B2.61: + fstp %st(3) + fldt .L_2il0floatpacket.19@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + sahf + jae ..B2.63 + jp ..B2.63 +..B2.62: + movl 44(%esp), %eax + movl $-1, (%eax) + jmp ..B2.64 +..B2.63: + movl 44(%esp), %eax + movl $1, (%eax) +..B2.64: + fxch %st(2) + faddp %st, %st(1) + fstpt 84(%esp) + fldt 84(%esp) + fld %st(0) + movzbl 93(%esp), %eax + andl $128, %eax + fmul %st(1), %st + shrl $7, %eax + fstpt 72(%esp) + fld %st(0) + fchs + fstpt (%esp) + addl $-32, %esp + fmuls ones@GOTOFF(%ebx,%eax,4) + lea 216(%esp), %edx + fstpt (%esp) + fstpt 12(%esp) + movl %edx, 24(%esp) + call __libm_logl_k80 +..B2.299: + fstp %st(0) + addl $32, %esp +..B2.65: + fldt 84(%esp) + testl %edi, %edi + fldt (%esp) + fldl 1560+_dbA@GOTOFF(%ebx) + fmul %st(2), %st + fldt 2700+_ldbA@GOTOFF(%ebx) + fldt 2688+_ldbA@GOTOFF(%ebx) + fldt 2676+_ldbA@GOTOFF(%ebx) + fldt 2664+_ldbA@GOTOFF(%ebx) + fldt 2736+_ldbA@GOTOFF(%ebx) + fxch %st(5) + faddl 1552+_dbA@GOTOFF(%ebx) + fmul %st(7), %st + faddl 1544+_dbA@GOTOFF(%ebx) + fmul %st(7), %st + faddl 1536+_dbA@GOTOFF(%ebx) + fmul %st(7), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + faddp %st, %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fmulp %st, %st(3) + fldl 1568+_dbA@GOTOFF(%ebx) + fmul %st(2), %st + fldt 72(%esp) + fldt 2748+_ldbA@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(3) + fmul %st, %st(2) + fxch %st(1) + faddl 1576+_dbA@GOTOFF(%ebx) + fmul %st(3), %st + fldt 2724+_ldbA@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddl 1584+_dbA@GOTOFF(%ebx) + fmul %st(3), %st + faddl 1592+_dbA@GOTOFF(%ebx) + fmul %st(3), %st + faddl 1600+_dbA@GOTOFF(%ebx) + fmul %st(3), %st + faddl 1608+_dbA@GOTOFF(%ebx) + fmul %st(3), %st + faddl 1616+_dbA@GOTOFF(%ebx) + fmul %st(3), %st + faddl 1624+_dbA@GOTOFF(%ebx) + fmul %st(3), %st + fmul %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fstpt 208(%esp) + fldt 208(%esp) + faddp %st, %st(3) + fldt 2712+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fsubp %st, %st(1) + je ..B2.67 +..B2.66: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.300: + fldt 16(%esp) + addl $16, %esp +..B2.67: + fldt 196(%esp) + testl %esi, %esi + fsubrp %st, %st(1) + fldt 184(%esp) + fsubrp %st, %st(1) + fstpt 116(%esp) + je ..B2.69 +..B2.68: + fldcw 182(%esp) +..B2.69: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.70: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.71: + fstp %st(0) + fxch %st(2) + fnstcw (%esp) + movzwl (%esp), %eax + orl $3072, %eax + movl %eax, 8(%esp) + fldcw 8(%esp) + fistl 16(%esp) + fldcw (%esp) + fld %st(1) + movl 16(%esp), %ecx + fsubp %st, %st(1) + negl %ecx + lea -2(%ecx), %eax + movl %eax, 12(%esp) + andl $1, %ecx + jne ..B2.74 +..B2.72: + fcom %st(2) + fnstsw %ax + sahf + jae ..B2.75 + jp ..B2.75 +..B2.73: + movl 44(%esp), %eax + movl $-1, (%eax) + jmp ..B2.76 +..B2.74: + jne ..B2.202 +..B2.75: + movl 44(%esp), %eax + movl $1, (%eax) +..B2.76: + fldt .L_2il0floatpacket.20@GOTOFF(%ebx) + movl 12(%esp), %ecx + fcomp %st(2) + fnstsw %ax + sahf + fcom %st(2) + fnstsw %ax + jae ..L4 + jp ..L4 + movl $0, %ecx +..L4: + sahf + movl $17, %eax + ja ..L5 + movl $0, %eax +..L5: + addl %eax, %ecx + movl %ecx, 12(%esp) + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %eax + fldt 636+_ldbA@GOTOFF(%eax,%ebx) + lea (%ecx,%ecx,2), %ecx + fsubr %st(2), %st + fldt 1068+_ldbA@GOTOFF(%ebx,%ecx,8) + fcomp %st(3) + fnstsw %ax + sahf + jae ..B2.86 + jp ..B2.86 +..B2.77: + fldt 1080+_ldbA@GOTOFF(%ebx,%ecx,8) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B2.86 +..B2.79: + fstp %st(2) + fstp %st(2) + movl 12(%esp), %edx + addl $-32, %esp + lea (,%edx,4), %eax + fstpt (%esp) + lea (%edx,%edx,4), %edx + shll $5, %edx + lea 3360(%eax,%eax,8), %ecx + fstpt 32(%esp) + lea _ldbA@GOTOFF(%ebx,%ecx), %eax + lea 240(%esp), %ecx + lea 2432+_dbA@GOTOFF(%ebx,%edx), %edx + call __libm_p19root +..B2.301: + fldt 32(%esp) + addl $32, %esp +..B2.80: + testl %edi, %edi + je ..B2.82 +..B2.81: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.302: + fldt 16(%esp) + addl $16, %esp +..B2.82: + fldt 208(%esp) + testl %esi, %esi + fldt 220(%esp) + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.344 +..B2.83: + fstpt 84(%esp) +..B2.303: + fldcw 182(%esp) + jmp ..B2.84 +..B2.344: + fstp %st(0) +..B2.84: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.85: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.86: + fstp %st(0) + fstpt 84(%esp) +..B2.87: + lea -16382(%edx), %ecx + cmpl $2, %ecx + jne ..B2.89 +..B2.88: + fldt .L_2il0floatpacket.21@GOTOFF(%ebx) + addl $-16380, %edx + fcomp %st(1) + fnstsw %ax + sahf + jbe ..L6 + movl %edx, %ecx +..L6: +..B2.89: + fldt .L_2il0floatpacket.19@GOTOFF(%ebx) + movl %ecx, %eax + fmul %st, %st(1) + lea (,%ecx,8), %edx + shll $7, %eax + fxch %st(1) + fstpt 156(%esp) + subl %edx, %eax + fxch %st(1) + fstpt 144(%esp) + lea (%ecx,%ecx,4), %edx + fldt .L_2il0floatpacket.16@GOTOFF(%ebx) + movzwl 164(%esp), %ecx + fldt 2868+_ldbA@GOTOFF(%ebx,%eax) + andl $-32768, %ecx + fldt 2856+_ldbA@GOTOFF(%ebx,%eax) + orl $-49153, %ecx + fldt 2820+_ldbA@GOTOFF(%ebx,%eax) + fldt 2808+_ldbA@GOTOFF(%ebx,%eax) + movw %cx, 164(%esp) + fldt 156(%esp) + shll $5, %edx + fsubp %st, %st(5) + fxch %st(4) + fstpt 156(%esp) + fldt 156(%esp) + fldl 1784+_dbA@GOTOFF(%ebx,%edx) + fmul %st(1), %st + fldt 2844+_ldbA@GOTOFF(%ebx,%eax) + fxch %st(1) + faddl 1776+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1768+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1760+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1752+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1744+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1736+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1728+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1720+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1712+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1704+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddl 1696+_dbA@GOTOFF(%ebx,%edx) + fmul %st(2), %st + faddp %st, %st(5) + fxch %st(1) + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 2832+_ldbA@GOTOFF(%ebx,%eax) + faddp %st, %st(3) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st(1), %st + fldt 2796+_ldbA@GOTOFF(%ebx,%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 2784+_ldbA@GOTOFF(%ebx,%eax) + faddp %st, %st(1) + fmul %st(1), %st + fld %st(1) + fldt 2772+_ldbA@GOTOFF(%ebx,%eax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 2760+_ldbA@GOTOFF(%ebx,%eax) + faddp %st, %st(1) + fldl _TWO_32H@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(2) + fstpt 48(%esp) + fldt 48(%esp) + fld %st(2) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(2), %st + fxch %st(1) + fsubr %st, %st(3) + fld %st(3) + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(6) + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(3) + fstpt 16(%esp) + fldt 16(%esp) + fldl 1632+_dbA@GOTOFF(%ebx,%edx) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + fld %st(4) + fxch %st(1) + faddl 1640+_dbA@GOTOFF(%ebx,%edx) + faddp %st, %st(3) + fld %st(1) + fmul %st(5), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fld %st(4) + fmul %st(4), %st + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(2) + fldl 1680+_dbA@GOTOFF(%ebx,%edx) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + fld %st(4) + fxch %st(1) + faddl 1688+_dbA@GOTOFF(%ebx,%edx) + faddp %st, %st(3) + fld %st(1) + fmul %st(5), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fld %st(4) + fmul %st(4), %st + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(2) + fldl 1664+_dbA@GOTOFF(%ebx,%edx) + fld %st(0) + fadd %st(5), %st + fmul %st, %st(2) + fxch %st(2) + fstpt 72(%esp) + fldt 72(%esp) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(5) + fld %st(1) + fadd %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(4) + faddl 1672+_dbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fxch %st(3) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fldl 1648+_dbA@GOTOFF(%ebx,%edx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fldt 8(%ebp) + fmulp %st, %st(4) + faddl 1656+_dbA@GOTOFF(%ebx,%edx) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + addl $-32, %esp + lea 240(%esp), %eax + fxch %st(1) + fstpt (%esp) + fldt -64(%eax) + fstpt 12(%esp) + fldt 12(%esp) + movl %eax, 24(%esp) + fxch %st(1) + fstpt 64(%esp) + fstpt -64(%eax) + call __libm_logl_k80 +..B2.304: + fstp %st(0) + fldt 176(%esp) + fldt 64(%esp) + addl $32, %esp +..B2.90: + fldt 84(%esp) + movzbl 93(%esp), %eax + addl $-32, %esp + andl $128, %eax + lea 216(%esp), %edx + shrl $7, %eax + fmuls ones@GOTOFF(%ebx,%eax,4) + fstpt (%esp) + fldt (%esp) + fxch %st(2) + fstpt 12(%esp) + movl %edx, 24(%esp) + fxch %st(1) + fstpt 80(%esp) + fstpt 64(%esp) + call __libm_logl_k80 +..B2.305: + fstp %st(0) + fldt 64(%esp) + fldt 80(%esp) + addl $32, %esp +..B2.91: + fldt 16(%esp) + fld %st(1) + fmul %st(1), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(2) + fsub %st(1), %st + fxch %st(3) + fmul %st(0), %st + fldt 408+_ldbA@GOTOFF(%ebx) + fmul %st(1), %st + fldt 396+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 384+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 372+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 360+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 348+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 336+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 324+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 312+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 300+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 288+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 276+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 264+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 252+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fld %st(3) + fldt 240+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(2) + fldt 228+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 168(%esp) + fmulp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fxch %st(5) + fmul %st(0), %st + faddp %st, %st(5) + fld %st(2) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fld %st(1) + fxch %st(3) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(6) + fld %st(4) + fmul %st(2), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(1) + fld %st(3) + fmul %st(3), %st + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(2) + fmul %st(5), %st + faddp %st, %st(1) + fldl 64+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(4) + fmul %st(3), %st + fxch %st(1) + faddl 72+_dbA@GOTOFF(%ebx) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fmul %st(5), %st + fld %st(3) + fmul %st(3), %st + faddp %st, %st(1) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fldl 48+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddl 56+_dbA@GOTOFF(%ebx) + faddp %st, %st(2) + fld %st(0) + fadd %st(4), %st + fsubp %st, %st(4) + fsub %st(3), %st + faddp %st, %st(1) + fld %st(1) + fmul %st(3), %st + fxch %st(3) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(2) + fld %st(3) + fldt (%esp) + faddp %st, %st(2) + fxch %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fldt 208(%esp) + fld %st(0) + fxch %st(1) + fadd %st, %st(3) + fldt 220(%esp) + movzbl 81(%esp), %edx + fadd %st, %st(2) + fxch %st(2) + fstpt 60(%esp) + fldt 60(%esp) + andl $128, %edx + movzbl 69(%esp), %ecx + andl $128, %ecx + shrl $7, %edx + shrl $7, %ecx + fxch %st(3) + fmuls ones@GOTOFF(%ebx,%edx,4) + fstpt 72(%esp) + fldt 72(%esp) + fxch %st(3) + fmuls ones@GOTOFF(%ebx,%ecx,4) + fstpt 60(%esp) + fldt 60(%esp) + fcomp %st(3) + fnstsw %ax + fxch %st(2) + fstp %st(0) + sahf + jae ..B2.93 + jp ..B2.93 +..B2.92: + fxch %st(2) + fsubr %st, %st(5) + fxch %st(1) + faddp %st, %st(5) + fldt (%esp) + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + jmp ..B2.94 +..B2.93: + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(5) + faddp %st, %st(4) + fldt (%esp) + faddp %st, %st(4) +..B2.94: + fldt 184(%esp) + fld %st(2) + fadd %st(1), %st + fchs + fadd %st, %st(1) + fxch %st(1) + fchs + fsubp %st, %st(3) + fldt 196(%esp) + fsubrp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fld %st(2) + fadd %st(2), %st + fstpt 72(%esp) + fldt 72(%esp) + fld %st(1) + movzbl 81(%esp), %edx + fsubr %st(4), %st + andl $128, %edx + shrl $7, %edx + flds ones@GOTOFF(%ebx,%edx,4) + fmulp %st, %st(2) + fxch %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fld %st(2) + fadd %st(6), %st + fstpt 60(%esp) + fldt 60(%esp) + movzbl 69(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + flds ones@GOTOFF(%ebx,%ecx,4) + fmulp %st, %st(1) + fxch %st(1) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.96 +..B2.95: + fxch %st(1) + fsubr %st, %st(4) + fxch %st(2) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(2) + fxch %st(1) + jmp ..B2.97 +..B2.96: + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(4) + fxch %st(4) + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) +..B2.97: + testl %edi, %edi + je ..B2.99 +..B2.98: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 32(%esp) + fstpt 48(%esp) + call fesetround +..B2.306: + fldt 48(%esp) + fldt 32(%esp) + fldt 16(%esp) + addl $16, %esp +..B2.99: + testl %esi, %esi + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.345 +..B2.100: + fstpt 60(%esp) +..B2.307: + fldcw 182(%esp) + jmp ..B2.101 +..B2.345: + fstp %st(0) +..B2.101: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.102: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.103: + fstp %st(2) + fstp %st(1) + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + lea 1008+_dbA@GOTOFF(%ebx), %ecx + movl 44(%esp), %eax + cmpl $16385, %edx + movl %ecx, (%esp) + fmul %st, %st(1) + movl $1, (%eax) + lea 2376+_ldbA@GOTOFF(%ebx), %eax + jne ..B2.105 +..B2.104: + fmul %st, %st(1) + addl $96, %eax + addl $176, (%esp) +..B2.105: + fstp %st(0) + fldt .L_2il0floatpacket.16@GOTOFF(%ebx) + addl $-32, %esp + fsubrp %st, %st(1) + fstpt (%esp) + lea 36(%esp), %ecx + movl 32(%esp), %edx + call __libm_p25 +..B2.308: + addl $32, %esp +..B2.106: + testl %edi, %edi + je ..B2.108 +..B2.107: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.309: + addl $16, %esp +..B2.108: + fldt 4(%esp) + testl %esi, %esi + fldt 16(%esp) + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.110 +..B2.109: + fldcw 182(%esp) +..B2.110: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.111: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.112: + fstp %st(2) + fstp %st(1) + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fld %st(1) + cmpl $0, 4(%esp) + lea 1908+_ldbA@GOTOFF(%ebx), %eax + lea 128+_dbA@GOTOFF(%ebx), %edx + fsub %st(1), %st + jl ..B2.214 +..B2.113: + fstp %st(1) + fstp %st(1) + movl 44(%esp), %ecx + movl $1, (%ecx) +..B2.114: + addl $-32, %esp + lea 36(%esp), %ecx + fstpt (%esp) + call __libm_p25 +..B2.310: + addl $32, %esp +..B2.115: + testl %edi, %edi + je ..B2.117 +..B2.116: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.311: + addl $16, %esp +..B2.117: + fldt 4(%esp) + testl %esi, %esi + fldt 16(%esp) + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.119 +..B2.118: + fldcw 182(%esp) +..B2.119: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.120: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.121: + addl $-16, %esp + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fxch %st(2) + fstpt 144(%esp) + fxch %st(2) + fstps 44(%esp) + fxch %st(1) + fstpt 160(%esp) + fstpt 48(%esp) + call nearbyintl@PLT +..B2.312: + fldt 48(%esp) + fld %st(0) + fsub %st(2), %st + fldt 160(%esp) + fucom %st(1) + fnstsw %ax + flds 44(%esp) + fldt 144(%esp) + addl $16, %esp + sahf + jp ..B2.122 + je ..B2.223 +..B2.122: + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fcomp %st(5) + fnstsw %ax + sahf + jae ..B2.139 + jp ..B2.139 +..B2.123: + fxch %st(5) + fnstcw (%esp) + movzwl (%esp), %eax + orl $3072, %eax + movl %eax, 8(%esp) + fldcw 8(%esp) + fistl 16(%esp) + fldcw (%esp) + movl 16(%esp), %edx + fxch %st(3) + fcom %st(2) + fnstsw %ax + movl %edx, 12(%esp) + negl %edx + lea -2(%edx), %ecx + addl $15, %edx + sahf + ja ..L7 + movl %ecx, %edx +..L7: + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt 636+_ldbA@GOTOFF(%ecx,%ebx) + lea (%edx,%edx,2), %ecx + fsubr %st(5), %st + fldt 1068+_ldbA@GOTOFF(%ebx,%ecx,8) + fcomp %st(6) + fnstsw %ax + sahf + jae ..B2.137 + jp ..B2.137 +..B2.124: + fldt 1080+_ldbA@GOTOFF(%ebx,%ecx,8) + fcomp %st(6) + fnstsw %ax + sahf + jbe ..B2.137 +..B2.125: + fstp %st(6) + fstp %st(3) + fstp %st(3) + fstp %st(2) + movl 12(%esp), %eax + negl %eax + andl $1, %eax + movl %eax, 12(%esp) + jne ..B2.128 +..B2.126: + fcom %st(1) + fnstsw %ax + sahf + jae ..B2.129 + jp ..B2.129 +..B2.127: + fstp %st(1) + movl 44(%esp), %eax + movl $-1, (%eax) + jmp ..B2.130 +..B2.128: + cmpl $0, 12(%esp) + jne ..B2.216 +..B2.129: + fstp %st(1) + movl 44(%esp), %eax + movl $1, (%eax) +..B2.130: + addl $-32, %esp + lea (,%edx,4), %eax + lea (%edx,%edx,4), %edx + shll $5, %edx + lea 3360(%eax,%eax,8), %ecx + lea _ldbA@GOTOFF(%ebx,%ecx), %eax + fxch %st(1) + fstpt (%esp) + lea 240(%esp), %ecx + fstpt 32(%esp) + lea 2432+_dbA@GOTOFF(%ebx,%edx), %edx + call __libm_p19root +..B2.313: + fldt 32(%esp) + addl $32, %esp +..B2.131: + testl %edi, %edi + je ..B2.133 +..B2.132: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.314: + fldt 16(%esp) + addl $16, %esp +..B2.133: + fldt 208(%esp) + testl %esi, %esi + fldt 220(%esp) + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.346 +..B2.134: + fstpt 84(%esp) +..B2.315: + fldcw 182(%esp) + jmp ..B2.135 +..B2.346: + fstp %st(0) +..B2.135: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.136: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.137: + fstp %st(0) + fstpt 84(%esp) + fldt 84(%esp) + fxch %st(5) + fxch %st(3) + fxch %st(5) + jmp ..B2.140 +..B2.139: + fxch %st(3) + fstpt 84(%esp) + fldt 84(%esp) +..B2.140: + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + fmul %st, %st(6) + fstpt 96(%esp) + addl $-16, %esp + fxch %st(5) + fstpt (%esp) + fldt (%esp) + fstpt 32(%esp) + fxch %st(4) + fstpt 16(%esp) + fxch %st(1) + fstpt 144(%esp) + fxch %st(2) + fstps 44(%esp) + fxch %st(1) + fstpt 160(%esp) + fstpt 48(%esp) + call nearbyintl@PLT +..B2.316: + fldt 48(%esp) + fldt 160(%esp) + flds 44(%esp) + fldt 144(%esp) + fldt 16(%esp) + fldt 32(%esp) + addl $16, %esp + fucomp %st(6) + fnstsw %ax + fxch %st(5) + fstp %st(0) + sahf + jp ..B2.141 + je ..B2.220 +..B2.141: + fxch %st(4) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B2.143 +..B2.142: + movl 44(%esp), %eax + movl $-1, (%eax) + jmp ..B2.144 +..B2.143: + movl 44(%esp), %eax + movl $1, (%eax) +..B2.144: + fmulp %st, %st(2) + fxch %st(1) + fstpt 156(%esp) + fldt 156(%esp) + addl $-32, %esp + lea 240(%esp), %eax + fstpt (%esp) + fstpt 12(%esp) + fldt 12(%esp) + movl %eax, 24(%esp) + fxch %st(1) + fstpt -80(%eax) + fstpt -64(%eax) + call __libm_logl_k80 +..B2.317: + fstp %st(0) + fldt 176(%esp) + fldt 160(%esp) + addl $32, %esp +..B2.145: + fldt 156(%esp) + lea 420+_ldbA@GOTOFF(%ebx), %ecx + fld %st(0) + fld %st(1) + fxch %st(4) + fstpt 144(%esp) + lea 80+_dbA@GOTOFF(%ebx), %edx + fxch %st(2) + fstpt 128(%esp) + fldt 128(%esp) + fldl _TWO_32H@GOTOFF(%ebx) + fstpt (%esp) + fldt (%esp) + fmul %st, %st(3) + fxch %st(3) + fadd %st, %st(4) + fsubrp %st, %st(4) + fxch %st(3) + fstpt 48(%esp) + fldt 48(%esp) + fld %st(1) + fsub %st(1), %st + fldt 208(%esp) + fldt 96(%esp) + fld %st(0) + fmul %st(2), %st + fstpt 112(%esp) + fxch %st(6) + fsubrp %st, %st(1) + fmul %st, %st(4) + fxch %st(4) + fstpt 72(%esp) + fldt 72(%esp) + fld %st(4) + fadd %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fsubr %st, %st(5) + fmul %st(2), %st + fldt 220(%esp) + fmul %st, %st(7) + faddp %st, %st(6) + fxch %st(4) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fld %st(0) + fldt 112(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + fldt 144(%esp) + fldt 128(%esp) + sahf + jbe ..B2.147 +..B2.146: + addl $108, %ecx + addl $16, %edx +..B2.147: + fldt (%esp) + fld %st(0) + fld %st(4) + movzbl 93(%esp), %eax + fadd %st(6), %st + fdivr %st(3), %st + andl $128, %eax + fmul %st, %st(1) + fld %st(5) + fxch %st(5) + fstpt 144(%esp) + fld %st(1) + shrl $7, %eax + fadd %st(1), %st + fsubp %st, %st(2) + fxch %st(1) + fmul %st, %st(5) + fxch %st(3) + fsubrp %st, %st(5) + fsub %st(2), %st + fld %st(0) + fadd %st(3), %st + fmul %st, %st(6) + fxch %st(1) + fmul %st, %st(4) + fxch %st(6) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + fsubrp %st, %st(3) + fld %st(0) + fadd %st(3), %st + fmul %st(0), %st + fldt 96(%ecx) + fmul %st(1), %st + fldt 84(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldl (%edx) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(4) + fld %st(0) + fadd %st(5), %st + fsubp %st, %st(5) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(4), %st + fstpt 208(%esp) + fldt 208(%esp) + fxch %st(2) + fsub %st(4), %st + fxch %st(4) + fmul %st(5), %st + fxch %st(1) + faddl 8(%edx) + faddp %st, %st(4) + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 220(%esp) + fldt 220(%esp) + fldl 112+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddl 120+_dbA@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt 96(%esp) + fldt 84(%esp) + addl $-32, %esp + fmuls ones@GOTOFF(%ebx,%eax,4) + lea 216(%esp), %edx + fstpt (%esp) + fldt (%esp) + fldt -40(%edx) + fstpt 12(%esp) + movl %edx, 24(%esp) + fstpt -72(%edx) + fstpt -56(%edx) + call __libm_logl_k80 +..B2.318: + fstp %st(0) + fldt 160(%esp) + fldt 144(%esp) + addl $32, %esp +..B2.148: + fldt (%esp) + fld %st(1) + fmul %st(1), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(2) + fsub %st(1), %st + fxch %st(3) + fmul %st(0), %st + fldt 408+_ldbA@GOTOFF(%ebx) + fmul %st(1), %st + fldt 396+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 384+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 372+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 360+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 348+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 336+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 324+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 312+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 300+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 288+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 276+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 264+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 252+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 240+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fldt 228+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fld %st(3) + fmul %st(1), %st + fldt 168(%esp) + fmulp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fxch %st(5) + fmul %st(0), %st + faddp %st, %st(5) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fld %st(2) + fxch %st(2) + fsub %st(4), %st + faddp %st, %st(6) + fld %st(4) + fmul %st(3), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fmul %st(5), %st + fld %st(3) + fmul %st(3), %st + faddp %st, %st(1) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fldl 64+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fxch %st(1) + faddl 72+_dbA@GOTOFF(%ebx) + faddp %st, %st(3) + fld %st(4) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + fld %st(3) + fmul %st(2), %st + faddp %st, %st(1) + fxch %st(1) + fmul %st(5), %st + faddp %st, %st(1) + fldl 48+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(2) + fsub %st(4), %st + fld %st(3) + fmul %st(5), %st + fxch %st(5) + fmul %st(6), %st + fxch %st(3) + faddl 56+_dbA@GOTOFF(%ebx) + faddp %st, %st(2) + faddp %st, %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(4) + fadd %st(3), %st + fstpt 48(%esp) + fldt 48(%esp) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 96(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 184(%esp) + fld %st(0) + fchs + fldt 32(%esp) + fld %st(0) + fadd %st(3), %st + fstpt 116(%esp) + fldt 116(%esp) + fxch %st(1) + fcomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + fldt 196(%esp) + sahf + jbe ..B2.150 +..B2.149: + fldt 32(%esp) + fsub %st(2), %st + faddp %st, %st(3) + fldt 16(%esp) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + jmp ..B2.151 +..B2.150: + fldt 32(%esp) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 16(%esp) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) +..B2.151: + movzbl 125(%esp), %edx + fld %st(0) + movzbl 57(%esp), %ecx + andl $128, %edx + andl $128, %ecx + fadd %st(2), %st + shrl $7, %edx + shrl $7, %ecx + flds ones@GOTOFF(%ebx,%edx,4) + fmul %st(2), %st + fstpt 72(%esp) + fldt 72(%esp) + flds ones@GOTOFF(%ebx,%ecx,4) + fmul %st(4), %st + fxch %st(1) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.153 +..B2.152: + fldt 32(%esp) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + jmp ..B2.154 +..B2.153: + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt 32(%esp) + faddp %st, %st(2) +..B2.154: + testl %edi, %edi + je ..B2.156 +..B2.155: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 32(%esp) + fstpt 48(%esp) + call fesetround +..B2.319: + fldt 48(%esp) + fldt 32(%esp) + fldt 16(%esp) + addl $16, %esp +..B2.156: + testl %esi, %esi + faddp %st, %st(1) + fchs + fstpt 116(%esp) + je ..B2.347 +..B2.157: + fstpt 60(%esp) +..B2.320: + fldcw 182(%esp) + jmp ..B2.158 +..B2.347: + fstp %st(0) +..B2.158: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.159: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.160: + fstp %st(3) + movl 44(%esp), %eax + addl $-32, %esp + lea 240(%esp), %edx + movl $1, (%eax) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl %edx, 24(%esp) + fstpt -80(%edx) + call __libm_logl_k80 +..B2.321: + fstp %st(0) + fldt 160(%esp) + addl $32, %esp +..B2.161: + fldt 8(%ebp) + lea 420+_ldbA@GOTOFF(%ebx), %ecx + fld %st(0) + fld %st(1) + fxch %st(3) + fstpt 128(%esp) + fldt 128(%esp) + fld %st(2) + fldl _TWO_32H@GOTOFF(%ebx) + lea 80+_dbA@GOTOFF(%ebx), %edx + fmul %st, %st(3) + fxch %st(3) + fadd %st, %st(5) + fsubrp %st, %st(5) + fxch %st(4) + fstpt 32(%esp) + fldt 32(%esp) + fsubr %st, %st(4) + fxch %st(2) + fstpt 48(%esp) + fldt 48(%esp) + fldt 208(%esp) + fld %st(0) + fxch %st(3) + fsubrp %st, %st(1) + fmul %st, %st(1) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fld %st(1) + fadd %st(1), %st + fstpt (%esp) + fldt (%esp) + fsubp %st, %st(1) + fmul %st, %st(5) + fsubr %st, %st(1) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + fstpt 64(%esp) + fldt 220(%esp) + fmul %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(5) + fmulp %st, %st(2) + fld %st(1) + fldt 64(%esp) + fadd %st, %st(1) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 128(%esp) + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B2.163 +..B2.162: + addl $108, %ecx + addl $16, %edx +..B2.163: + fldt 32(%esp) + testl %edi, %edi + fsubr %st, %st(3) + fxch %st(4) + fstpt 64(%esp) + fld %st(3) + fadd %st(3), %st + fdivr %st(1), %st + fxch %st(2) + fstpt 80(%esp) + fldt 48(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + fadd %st(4), %st + fsubp %st, %st(1) + fsubr %st, %st(3) + fld %st(3) + fadd %st(1), %st + fmul %st, %st(5) + fld %st(6) + fmul %st(5), %st + faddp %st, %st(6) + fxch %st(1) + fmul %st, %st(6) + fxch %st(3) + fsubrp %st, %st(6) + fxch %st(4) + faddp %st, %st(5) + fxch %st(4) + fmulp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fmul %st(0), %st + fldt 96(%ecx) + fmul %st(1), %st + fldt 84(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldl (%edx) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(1) + fsub %st(4), %st + fld %st(3) + fmul %st(5), %st + fstpt 208(%esp) + fldt 208(%esp) + fxch %st(3) + fmul %st, %st(5) + fxch %st(2) + faddl 8(%edx) + faddp %st, %st(1) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 220(%esp) + fldt 220(%esp) + fldl 112+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fldt 64(%esp) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fxch %st(1) + faddl 120+_dbA@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 80(%esp) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + je ..B2.166 +..B2.164: + fstpt 116(%esp) + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 80(%esp) + call fesetround +..B2.322: + fldt 80(%esp) + addl $16, %esp +..B2.165: + fldt 116(%esp) +..B2.166: + testl %esi, %esi + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.168 +..B2.167: + fldt 32(%esp) + fstpt 48(%esp) + fldt (%esp) + fstpt 60(%esp) + fldt 16(%esp) + fstpt 72(%esp) +..B2.323: + fldcw 182(%esp) +..B2.168: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.169: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.170: + fstp %st(3) + movl 44(%esp), %eax + addl $-32, %esp + lea 240(%esp), %edx + movl $1, (%eax) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl %edx, 24(%esp) + fstpt -80(%edx) + call __libm_logl_k80 +..B2.324: + fstp %st(0) + fldt 160(%esp) + addl $32, %esp +..B2.171: + fldt 8(%ebp) + testl %edi, %edi + fldt 12+_TWO5600@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_32H@GOTOFF(%ebx) + fld %st(0) + fmul %st(2), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fsubr %st(2), %st + fldt 208(%esp) + fsubp %st, %st(5) + fxch %st(1) + fmul %st(4), %st + fld %st(4) + fadd %st(1), %st + fld %st(0) + fsub %st(2), %st + fmul %st, %st(3) + fxch %st(6) + fstpt 208(%esp) + fldt 208(%esp) + fsub %st(6), %st + fldt 220(%esp) + faddp %st, %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + fmul %st, %st(4) + fxch %st(2) + fxch %st(3) + fxch %st(4) + fxch %st(1) + je ..B2.173 +..B2.172: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 32(%esp) + fstpt 48(%esp) + fstpt 64(%esp) + fstpt 80(%esp) + call fesetround +..B2.325: + fldt 80(%esp) + fldt 64(%esp) + fldt 48(%esp) + fldt 32(%esp) + fldt 16(%esp) + addl $16, %esp +..B2.173: + fldt _TWO5600@GOTOFF(%ebx) + testl %esi, %esi + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 116(%esp) + je ..B2.348 +..B2.174: + fstpt 48(%esp) + fstpt 60(%esp) + fstpt 72(%esp) +..B2.326: + fldcw 182(%esp) + jmp ..B2.175 +..B2.348: + fstp %st(2) + fstp %st(1) + fstp %st(0) +..B2.175: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.176: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.177: + fstp %st(0) + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B2.179 +..B2.178: + movl 44(%esp), %eax + movl $-1, (%eax) + jmp ..B2.180 +..B2.179: + movl 44(%esp), %eax + movl $1, (%eax) +..B2.180: + fxch %st(2) + fmulp %st, %st(1) + addl $-32, %esp + fstpt (%esp) + fldt (%esp) + lea 240(%esp), %eax + fxch %st(1) + fstpt 12(%esp) + movl %eax, 24(%esp) + movl %edx, 32(%esp) + fstpt 64(%esp) + call __libm_logl_k80 +..B2.327: + fstp %st(0) + fldt 64(%esp) + movl 32(%esp), %edx + addl $32, %esp +..B2.181: + cmpl $16313, %edx + jge ..B2.188 +..B2.182: + fldt 208(%esp) + testl %edi, %edi + fldt 220(%esp) + faddp %st, %st(1) + fchs + fstpt 116(%esp) + je ..B2.184 +..B2.183: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 48(%esp) + call fesetround +..B2.328: + fldt 48(%esp) + addl $16, %esp +..B2.184: + testl %esi, %esi + je ..B2.349 +..B2.185: + fstpt 156(%esp) +..B2.329: + fldcw 182(%esp) + jmp ..B2.186 +..B2.349: + fstp %st(0) +..B2.186: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.187: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.188: + fldt 216+_ldbA@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(1) + fstpt 156(%esp) + fldt 156(%esp) + fldt 204+_ldbA@GOTOFF(%ebx) + cmpl $0, 4(%esp) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 192+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 180+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 168+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 156+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 144+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 132+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 120+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 108+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 96+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 84+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 72+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 60+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 48+_ldbA@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fld %st(0) + fldt 36+_ldbA@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fld %st(0) + fldt 24+_ldbA@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fldt 12+_ldbA@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt _ldbA@GOTOFF(%ebx) + faddp %st, %st(4) + fld %st(3) + fldl _TWO_32H@GOTOFF(%ebx) + fld %st(0) + fmul %st(6), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fmul %st, %st(3) + fxch %st(3) + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(1) + fsub %st(4), %st + fld %st(5) + fsub %st(2), %st + fmul %st(5), %st + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fxch %st(1) + fmul %st(4), %st + fxch %st(3) + fstpt 48(%esp) + fldt 48(%esp) + fldl 32+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + fld %st(1) + fmul %st(5), %st + fxch %st(1) + faddl 40+_dbA@GOTOFF(%ebx) + faddp %st, %st(3) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fld %st(3) + fmul %st(5), %st + fld %st(2) + fmul %st(6), %st + fxch %st(3) + fmul %st(7), %st + faddp %st, %st(1) + fxch %st(4) + fmul %st(6), %st + faddp %st, %st(4) + fldl 16+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl 24+_dbA@GOTOFF(%ebx) + faddp %st, %st(5) + fld %st(1) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(5) + faddp %st, %st(3) + fld %st(2) + fmul %st(6), %st + fxch %st(5) + fmul %st(7), %st + faddp %st, %st(5) + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(4) + fldl _dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(2) + fxch %st(2) + fstpt 104(%esp) + fldt 104(%esp) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fstpt 88(%esp) + fldt 88(%esp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fsubr %st, %st(2) + fmul %st(7), %st + fxch %st(3) + faddl 8+_dbA@GOTOFF(%ebx) + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fld %st(0) + fmul %st(5), %st + faddp %st, %st(2) + fmulp %st, %st(5) + faddp %st, %st(4) + fldt 208(%esp) + jl ..B2.234 +..B2.189: + fstp %st(1) + fldt 220(%esp) + fld %st(2) + testl %edi, %edi + fsub %st(2), %st + fadd %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fxch %st(2) + je ..B2.192 +..B2.190: + fstpt 116(%esp) + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 32(%esp) + fstpt 48(%esp) + call fesetround +..B2.330: + fldt 48(%esp) + fldt 32(%esp) + addl $16, %esp +..B2.191: + fldt 116(%esp) +..B2.192: + testl %esi, %esi + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.350 +..B2.193: + fldt 104(%esp) + fstpt 72(%esp) + fstpt 48(%esp) + fldt 88(%esp) + fstpt 60(%esp) +..B2.331: + fldcw 182(%esp) + jmp ..B2.194 +..B2.350: + fstp %st(0) +..B2.194: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 +..B2.195: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.196: + fstp %st(0) + call __stack_chk_fail@PLT +..B2.202: + fcom %st(2) + fnstsw %ax + sahf + ja ..B2.73 + jmp ..B2.75 +..B2.205: + fstp %st(0) + fstp %st(2) + fstp %st(0) + fstp %st(0) + movl 44(%esp), %eax + testl %edi, %edi + movl $1, (%eax) + je ..B2.207 +..B2.206: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.332: + addl $16, %esp +..B2.207: + fld1 + fldz + testl %esi, %esi + fdivrp %st, %st(1) + fstpt 116(%esp) + je ..B2.209 +..B2.208: + fldcw 182(%esp) +..B2.209: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.214: + fstp %st(0) + movl 44(%esp), %ecx + addl $176, %edx + addl $96, %eax + faddp %st, %st(1) + movl $-1, (%ecx) + jmp ..B2.114 +..B2.216: + fcom %st(1) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jbe ..B2.218 +..B2.217: + movl 44(%esp), %eax + movl $-1, (%eax) + jmp ..B2.130 +..B2.218: + movl 44(%esp), %eax + movl $1, (%eax) + jmp ..B2.130 +..B2.220: + fxch %st(4) + fcomp %st(2) + fnstsw %ax + sahf + jae ..B2.143 + jp ..B2.143 + jmp ..B2.142 +..B2.223: + fstp %st(0) + fstp %st(4) + fstp %st(2) + fstp %st(1) + fstp %st(1) + movl 44(%esp), %eax + testl %edi, %edi + movl $1, (%eax) + je ..B2.225 +..B2.224: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B2.333: + fldt 16(%esp) + addl $16, %esp +..B2.225: + fld1 + fldz + testl %esi, %esi + fdivrp %st, %st(1) + fstpt 116(%esp) + je ..B2.351 +..B2.226: + fstpt 84(%esp) +..B2.334: + fldcw 182(%esp) + jmp ..B2.227 +..B2.351: + fstp %st(0) +..B2.227: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.234: + fldt 408+_ldbA@GOTOFF(%ebx) + testl %edi, %edi + fxch %st(1) + fstpt 16(%esp) + fld %st(1) + fsub %st(4), %st + fxch %st(2) + fmul %st(0), %st + fmul %st, %st(1) + fxch %st(5) + fstpt (%esp) + fxch %st(3) + fstpt 32(%esp) + fldt 32(%esp) + fldt 396+_ldbA@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 384+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 372+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 360+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 348+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 336+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 324+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 312+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 300+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 288+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 276+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 264+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 252+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 240+_ldbA@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt 228+_ldbA@GOTOFF(%ebx) + faddp %st, %st(4) + fld %st(3) + fld %st(3) + fmul %st(4), %st + fldt 168(%esp) + fmulp %st, %st(5) + fxch %st(2) + fmul %st, %st(4) + fmul %st(0), %st + faddp %st, %st(4) + fld %st(1) + fldt 48(%esp) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(6) + fld %st(0) + fmul %st(7), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(6) + fmul %st(5), %st + fld %st(3) + fmul %st(7), %st + faddp %st, %st(1) + fxch %st(5) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(5) + fldl 64+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl 72+_dbA@GOTOFF(%ebx) + faddp %st, %st(6) + fld %st(1) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(5) + faddp %st, %st(2) + fld %st(2) + fmul %st(5), %st + fxch %st(5) + fmul %st(6), %st + fld %st(3) + fmul %st(3), %st + faddp %st, %st(1) + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(2) + fldl 48+_dbA@GOTOFF(%ebx) + fld %st(0) + fadd %st(6), %st + fmul %st, %st(2) + fsubr %st, %st(1) + fxch %st(6) + faddp %st, %st(1) + faddl 56+_dbA@GOTOFF(%ebx) + faddp %st, %st(2) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(5), %st + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(4) + faddp %st, %st(3) + fld %st(0) + fldt 16(%esp) + fadd %st, %st(1) + fxch %st(1) + fchs + fadd %st, %st(1) + fxch %st(1) + fchs + fsubp %st, %st(2) + fldt 220(%esp) + fsubrp %st, %st(2) + fldt (%esp) + fsubrp %st, %st(2) + fld %st(0) + fsub %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fchs + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fldt 32(%esp) + fxch %st(2) + fxch %st(1) + je ..B2.236 +..B2.235: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 32(%esp) + fstpt 48(%esp) + call fesetround +..B2.335: + fldt 48(%esp) + fldt 32(%esp) + fldt 16(%esp) + addl $16, %esp +..B2.236: + testl %esi, %esi + faddp %st, %st(1) + fstpt 116(%esp) + je ..B2.352 +..B2.237: + fldt 104(%esp) + fstpt 72(%esp) + fstpt 48(%esp) + fldt 88(%esp) + fstpt 60(%esp) +..B2.336: + fldcw 182(%esp) + jmp ..B2.238 +..B2.352: + fstp %st(0) +..B2.238: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.241: + cmpl $16446, %edx + jle ..B2.18 +..B2.242: + fstp %st(0) + fstp %st(1) + fstp %st(0) + fstp %st(0) + movl 44(%esp), %eax + testl %edi, %edi + movl $1, (%eax) + je ..B2.244 +..B2.243: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.337: + addl $16, %esp +..B2.244: + fld1 + fldz + testl %esi, %esi + fdivrp %st, %st(1) + fstpt 116(%esp) + je ..B2.246 +..B2.245: + fldcw 182(%esp) +..B2.246: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.249: + fstp %st(0) + fstp %st(1) + fstp %st(1) + movl 44(%esp), %eax + movl $1, (%eax) +..B2.250: + testl %edi, %edi + je ..B2.252 +..B2.251: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + fstpt 160(%esp) + call fesetround +..B2.338: + fldt 160(%esp) + addl $16, %esp +..B2.252: + fstpt 116(%esp) + testl %esi, %esi + je ..B2.254 +..B2.253: + fldcw 182(%esp) +..B2.254: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.258: + fstp %st(0) + fstp %st(1) + movl 44(%esp), %eax + testl %edi, %edi + movl $1, (%eax) + je ..B2.261 +..B2.259: + fstp %st(0) + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.339: + addl $16, %esp +..B2.260: + fldt 8(%ebp) +..B2.261: + fld %st(0) + testl %esi, %esi + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 116(%esp) + je ..B2.263 +..B2.262: + fldcw 182(%esp) +..B2.263: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.266: + fstp %st(1) + fstp %st(0) + fstp %st(0) + testl %edi, %edi + je ..B2.268 +..B2.267: + movl 44(%esp), %eax + addl $-16, %esp + movl 156(%esp), %edx + movl $1, (%eax) + movl %edx, (%esp) + call fesetround +..B2.340: + movzbl 17(%ebp), %eax + addl $16, %esp + movl %eax, (%esp) +..B2.268: + fld1 + fldz + fdivrp %st, %st(1) + movl (%esp), %eax + andl $128, %eax + shrl $7, %eax + movl 44(%esp), %edx + addl %eax, %eax + negl %eax + incl %eax + fstpt 116(%esp) + testl %esi, %esi + movl %eax, (%edx) + je ..B2.270 +..B2.269: + fldcw 182(%esp) +..B2.270: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.273: + fstp %st(0) + cmpl $-2147483648, 8(%esp) + jne ..B2.275 +..B2.274: + cmpl $0, 8(%ebp) + je ..B2.278 +..B2.275: + movl 44(%esp), %eax + testl %edi, %edi + movl $0, (%eax) + je ..B2.277 +..B2.276: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.341: + addl $16, %esp +..B2.277: + fldt 8(%ebp) + fadd %st(0), %st + fstpt 116(%esp) + jmp ..B2.281 +..B2.278: + movl 44(%esp), %eax + testl %edi, %edi + movl $1, (%eax) + je ..B2.280 +..B2.279: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.342: + addl $16, %esp +..B2.280: + fldt 8(%ebp) + fmul %st(0), %st + fstpt 116(%esp) +..B2.281: + testl %edi, %edi + je ..B2.283 +..B2.282: + addl $-16, %esp + movl 156(%esp), %eax + movl %eax, (%esp) + call fesetround +..B2.343: + addl $16, %esp +..B2.283: + testl %esi, %esi + je ..B2.285 +..B2.284: + fldcw 182(%esp) +..B2.285: + fldt 116(%esp) + movl 232(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.196 + jmp ..B2.38 +..B2.288: + xorl %esi, %esi + jmp ..B2.12 + .align 16,0x90 + .type __libm_lgammal,@function + .size __libm_lgammal,.-__libm_lgammal + .data +# -- End __libm_lgammal + .text +# -- Begin __libm_p25 + .text + .align 16,0x90 +__libm_p25: +# parameter 1: 8 + %esp +# parameter 2: %eax +# parameter 3: %edx +# parameter 4: %ecx +..B3.1: +..L8: + + pushl %edi + movl %eax, %edi + fldt 8(%esp) + call ..L9 +..L9: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L9](%eax), %eax + fld %st(0) + fld %st(1) + fldl 56(%edx) + fmul %st(3), %st + fldl _TWO_32H@GOTOFF(%eax) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(3) + fsub %st(3), %st + fldt 48(%edi) + fxch %st(2) + faddl 48(%edx) + fmul %st(5), %st + fldt (%edi) + fldt 60(%edi) + fxch %st(2) + faddl 152(%edx) + fmul %st(7), %st + faddl 144(%edx) + fmul %st(7), %st + faddl 168(%edx) + fmul %st(7), %st + faddl 160(%edx) + fmul %st(7), %st + faddl 104(%edx) + fmul %st(7), %st + faddl 96(%edx) + fmul %st(7), %st + faddl 120(%edx) + fmul %st(7), %st + faddl 112(%edx) + fmul %st(7), %st + faddl 136(%edx) + fmul %st(7), %st + faddl 128(%edx) + fmul %st(7), %st + faddl 40(%edx) + fmul %st(7), %st + faddl 32(%edx) + fmul %st(7), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 12(%edi) + faddp %st, %st(1) + fmul %st(4), %st + fldt 72(%edi) + faddp %st, %st(1) + fmul %st(4), %st + fldt 24(%edi) + faddp %st, %st(1) + fmul %st(4), %st + fldt 84(%edi) + faddp %st, %st(1) + fmul %st(4), %st + fld %st(2) + fldt 36(%edi) + faddp %st, %st(2) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + fmul %st(6), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fldl (%edx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(4) + fmul %st(2), %st + fxch %st(1) + faddl 88(%edx) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st(5), %st + fld %st(4) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldl 64(%edx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(4) + fmul %st(3), %st + fxch %st(1) + faddl 72(%edx) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fld %st(4) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldl 16(%edx) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(4) + fmul %st, %st(5) + fsubr %st, %st(2) + fmulp %st, %st(3) + fxch %st(3) + faddl 24(%edx) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fldl 80(%edx) + fld %st(0) + fadd %st(2), %st + fstpt (%ecx) + fldt (%ecx) + fsubrp %st, %st(1) + faddp %st, %st(1) + faddl 8(%edx) + faddp %st, %st(1) + fstpt 12(%ecx) + popl %edi + ret + .align 16,0x90 + .type __libm_p25,@function + .size __libm_p25,.-__libm_p25 + .data +# -- End __libm_p25 + .text +# -- Begin __libm_p19root + .text + .align 16,0x90 +__libm_p19root: +# parameter 1: 32 + %esp +# parameter 2: %eax +# parameter 3: %edx +# parameter 4: %ecx +..B4.1: +..L10: + + pushl %edi + subl $24, %esp + fldt 32(%esp) + call ..L11 +..L11: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L11](%edi), %edi + fld %st(0) + fld %st(1) + fldl 152(%edx) + fmul %st(3), %st + fldl _TWO_32H@GOTOFF(%edi) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(3) + fsub %st(3), %st + fldt 24(%eax) + fxch %st(2) + faddl 144(%edx) + fmul %st(5), %st + fldt 12(%eax) + fldt (%eax) + fxch %st(2) + faddl 136(%edx) + fmul %st(7), %st + faddl 128(%edx) + fmul %st(7), %st + faddl 120(%edx) + fmul %st(7), %st + faddl 112(%edx) + fmul %st(7), %st + faddl 104(%edx) + fmul %st(7), %st + faddl 96(%edx) + fmul %st(7), %st + faddl 88(%edx) + fmul %st(7), %st + faddl 80(%edx) + fmul %st(7), %st + faddl 72(%edx) + fmul %st(7), %st + faddl 64(%edx) + fmul %st(7), %st + faddl 56(%edx) + fmul %st(7), %st + faddl 48(%edx) + fmul %st(7), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fld %st(1) + fld %st(3) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + fmul %st(6), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldl 32(%edx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(4) + fmul %st(2), %st + fxch %st(1) + faddl 40(%edx) + faddp %st, %st(4) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fmul %st(5), %st + fld %st(4) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldl 16(%edx) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(1) + fmul %st(4), %st + fxch %st(2) + fsub %st(4), %st + fxch %st(4) + fmulp %st, %st(5) + faddl 24(%edx) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt (%esp) + fldt (%esp) + fldl (%edx) + fld %st(0) + fld %st(1) + fadd %st(4), %st + fldl 8(%edx) + fadd %st, %st(2) + fxch %st(2) + fstpt 12(%esp) + fldt 12(%esp) + movzbl 9(%esp), %edx + movzbl 21(%esp), %eax + andl $128, %edx + andl $128, %eax + shrl $7, %edx + shrl $7, %eax + fxch %st(4) + fmuls ones@GOTOFF(%edi,%edx,4) + fstpt (%esp) + fldt (%esp) + fxch %st(4) + fmuls ones@GOTOFF(%edi,%eax,4) + fcomp %st(4) + fnstsw %ax + fxch %st(3) + fstp %st(0) + sahf + jae ..B4.3 + jp ..B4.3 +..B4.2: + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + jmp ..B4.4 +..B4.3: + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) +..B4.4: + fstpt (%ecx) + fstpt 12(%ecx) + addl $24, %esp + popl %edi + ret + .align 16,0x90 + .type __libm_p19root,@function + .size __libm_p19root,.-__libm_p19root + .data +# -- End __libm_p19root + .text +# -- Begin gammal + .text + .align 16,0x90 + .globl gammal +gammal: +# parameter 1: 32 + %esp +..B5.1: +..L12: + + subl $28, %esp + fldt 32(%esp) + lea 16(%esp), %eax + fstpt (%esp) + movl %eax, 12(%esp) + call __libm_lgammal +..B5.2: + addl $28, %esp + ret + .align 16,0x90 + .type gammal,@function + .size gammal,.-gammal + .data +# -- End gammal + .text +# -- Begin lgammal_r + .text + .align 16,0x90 + .globl lgammal_r +lgammal_r: +# parameter 1: 4 + %esp +# parameter 2: 16 + %esp +..B6.1: +..L13: + + jmp __libm_lgammal + .align 16,0x90 + .type lgammal_r,@function + .size lgammal_r,.-lgammal_r + .data +# -- End lgammal_r + .text +# -- Begin gammal_r + .text + .align 16,0x90 + .globl gammal_r +gammal_r: +# parameter 1: 4 + %esp +# parameter 2: 16 + %esp +..B7.1: +..L14: + + jmp __libm_lgammal + .align 16,0x90 + .type gammal_r,@function + .size gammal_r,.-gammal_r + .data +# -- End gammal_r + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,0x40,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,0xc0,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x02,0x40,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0x03,0xc0,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.12: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.14: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xa6,0x00,0xc0,0x00,0x00 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.15: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x00,0xc0,0x00,0x00 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.16: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.17: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.18: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0xbf,0x00,0x00 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.19: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.19,@object + .size .L_2il0floatpacket.19,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.20: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0x00 + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.21: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0xc0,0x00,0x00 + .type .L_2il0floatpacket.21,@object + .size .L_2il0floatpacket.21,12 + .space 4, 0x00 # pad + .align 16 +_ldbA: + .word 48403 + .word 16065 + .word 37206 + .word 35465 + .word 16381 + .word 0 + .word 32498 + .word 21186 + .word 57533 + .word 54364 + .word 49148 + .word 0 + .word 48455 + .word 64043 + .word 25991 + .word 44448 + .word 16380 + .word 0 + .word 36906 + .word 8596 + .word 53485 + .word 37761 + .word 49148 + .word 0 + .word 16786 + .word 63789 + .word 39740 + .word 32901 + .word 16380 + .word 0 + .word 43334 + .word 50722 + .word 13591 + .word 58371 + .word 49147 + .word 0 + .word 51242 + .word 42271 + .word 52839 + .word 52480 + .word 16379 + .word 0 + .word 22272 + .word 27707 + .word 58025 + .word 47684 + .word 49147 + .word 0 + .word 48537 + .word 42093 + .word 143 + .word 43693 + .word 16379 + .word 0 + .word 5437 + .word 23105 + .word 19142 + .word 40288 + .word 49147 + .word 0 + .word 43105 + .word 25781 + .word 60600 + .word 37244 + .word 16379 + .word 0 + .word 64996 + .word 46896 + .word 33038 + .word 34212 + .word 49147 + .word 0 + .word 8055 + .word 35794 + .word 25027 + .word 61223 + .word 16378 + .word 0 + .word 26586 + .word 4739 + .word 1082 + .word 51475 + .word 49146 + .word 0 + .word 65450 + .word 65402 + .word 39793 + .word 38562 + .word 16378 + .word 0 + .word 18875 + .word 24550 + .word 64026 + .word 48031 + .word 49145 + .word 0 + .word 3811 + .word 11690 + .word 33485 + .word 45433 + .word 16376 + .word 0 + .word 21488 + .word 64404 + .word 56511 + .word 56861 + .word 49142 + .word 0 + .word 64157 + .word 44249 + .word 62935 + .word 34811 + .word 16372 + .word 0 + .word 1503 + .word 1560 + .word 25992 + .word 44448 + .word 49149 + .word 0 + .word 53495 + .word 49976 + .word 39767 + .word 32901 + .word 49149 + .word 0 + .word 21693 + .word 55175 + .word 61890 + .word 52480 + .word 49148 + .word 0 + .word 18005 + .word 14879 + .word 27421 + .word 43701 + .word 49148 + .word 0 + .word 4785 + .word 48109 + .word 28463 + .word 37451 + .word 49148 + .word 0 + .word 17404 + .word 30303 + .word 36440 + .word 32768 + .word 49148 + .word 0 + .word 19413 + .word 44833 + .word 30216 + .word 58252 + .word 49147 + .word 0 + .word 61231 + .word 61633 + .word 10791 + .word 52455 + .word 49147 + .word 0 + .word 18500 + .word 21868 + .word 57423 + .word 47400 + .word 49147 + .word 0 + .word 24302 + .word 39700 + .word 47161 + .word 45652 + .word 49147 + .word 0 + .word 48514 + .word 20900 + .word 46081 + .word 58518 + .word 49146 + .word 0 + .word 11885 + .word 12460 + .word 35625 + .word 41968 + .word 49148 + .word 0 + .word 41690 + .word 14982 + .word 21018 + .word 53469 + .word 16380 + .word 0 + .word 2894 + .word 27339 + .word 226 + .word 41728 + .word 49150 + .word 0 + .word 26025 + .word 18501 + .word 20978 + .word 46979 + .word 16382 + .word 0 + .word 53900 + .word 55553 + .word 17653 + .word 38916 + .word 49150 + .word 0 + .word 46603 + .word 2912 + .word 24758 + .word 46603 + .word 49142 + .word 0 + .word 53261 + .word 3328 + .word 208 + .word 53261 + .word 16372 + .word 0 + .word 39946 + .word 2496 + .word 49308 + .word 39945 + .word 49140 + .word 0 + .word 6840 + .word 51193 + .word 61784 + .word 56488 + .word 16372 + .word 0 + .word 58384 + .word 51683 + .word 34508 + .word 64341 + .word 49141 + .word 0 + .word 53773 + .word 3360 + .word 8402 + .word 53773 + .word 16375 + .word 0 + .word 48865 + .word 31388 + .word 13912 + .word 61972 + .word 49145 + .word 0 + .word 65489 + .word 61491 + .word 45504 + .word 47092 + .word 16380 + .word 0 + .word 53102 + .word 49401 + .word 14344 + .word 45627 + .word 49151 + .word 0 + .word 2166 + .word 2831 + .word 24758 + .word 46603 + .word 49142 + .word 0 + .word 9580 + .word 21681 + .word 206 + .word 53261 + .word 16372 + .word 0 + .word 30177 + .word 46479 + .word 48966 + .word 39945 + .word 49140 + .word 0 + .word 52333 + .word 51482 + .word 18491 + .word 56488 + .word 16372 + .word 0 + .word 40942 + .word 14796 + .word 26057 + .word 64313 + .word 49141 + .word 0 + .word 50177 + .word 16139 + .word 15070 + .word 53362 + .word 16375 + .word 0 + .word 2931 + .word 59423 + .word 29748 + .word 57837 + .word 49145 + .word 0 + .word 12931 + .word 12185 + .word 50840 + .word 32873 + .word 16380 + .word 0 + .word 60991 + .word 64091 + .word 63067 + .word 49777 + .word 49149 + .word 0 + .word 24747 + .word 1987 + .word 58544 + .word 40255 + .word 49152 + .word 0 + .word 31726 + .word 62157 + .word 28132 + .word 51504 + .word 49152 + .word 0 + .word 1560 + .word 52396 + .word 29634 + .word 33090 + .word 49153 + .word 0 + .word 51301 + .word 34230 + .word 21183 + .word 41027 + .word 49153 + .word 0 + .word 26476 + .word 19428 + .word 22828 + .word 49163 + .word 49153 + .word 0 + .word 62911 + .word 28656 + .word 40943 + .word 57345 + .word 49153 + .word 0 + .word 51702 + .word 17823 + .word 6657 + .word 32768 + .word 49154 + .word 0 + .word 55405 + .word 47943 + .word 739 + .word 36864 + .word 49154 + .word 0 + .word 47506 + .word 63803 + .word 73 + .word 40960 + .word 49154 + .word 0 + .word 21270 + .word 47505 + .word 6 + .word 45056 + .word 49154 + .word 0 + .word 51059 + .word 36726 + .word 0 + .word 49152 + .word 49154 + .word 0 + .word 8970 + .word 2825 + .word 0 + .word 53248 + .word 49154 + .word 0 + .word 52133 + .word 201 + .word 0 + .word 57344 + .word 49154 + .word 0 + .word 29690 + .word 13 + .word 0 + .word 61440 + .word 49154 + .word 0 + .word 27552 + .word 0 + .word 0 + .word 32768 + .word 49155 + .word 0 + .word 1621 + .word 0 + .word 0 + .word 34816 + .word 49155 + .word 0 + .word 90 + .word 0 + .word 0 + .word 36864 + .word 49155 + .word 0 + .word 5 + .word 0 + .word 0 + .word 38912 + .word 49155 + .word 0 + .word 1630 + .word 57032 + .word 2128 + .word 45018 + .word 49152 + .word 0 + .word 10332 + .word 57727 + .word 35491 + .word 64803 + .word 49152 + .word 0 + .word 59042 + .word 30551 + .word 48083 + .word 40890 + .word 49153 + .word 0 + .word 27388 + .word 36768 + .word 38828 + .word 49140 + .word 49153 + .word 0 + .word 32744 + .word 23607 + .word 24507 + .word 57342 + .word 49153 + .word 0 + .word 30841 + .word 2766 + .word 52220 + .word 65535 + .word 49153 + .word 0 + .word 33024 + .word 16990 + .word 64796 + .word 36863 + .word 49154 + .word 0 + .word 64973 + .word 1725 + .word 65462 + .word 40959 + .word 49154 + .word 0 + .word 40731 + .word 18030 + .word 65529 + .word 45055 + .word 49154 + .word 0 + .word 14452 + .word 28809 + .word 65535 + .word 49151 + .word 49154 + .word 0 + .word 56566 + .word 62710 + .word 65535 + .word 53247 + .word 49154 + .word 0 + .word 13403 + .word 65334 + .word 65535 + .word 57343 + .word 49154 + .word 0 + .word 35846 + .word 65522 + .word 65535 + .word 61439 + .word 49154 + .word 0 + .word 10432 + .word 65535 + .word 65535 + .word 65535 + .word 49154 + .word 0 + .word 63915 + .word 65535 + .word 65535 + .word 34815 + .word 49155 + .word 0 + .word 65446 + .word 65535 + .word 65535 + .word 36863 + .word 49155 + .word 0 + .word 65531 + .word 65535 + .word 65535 + .word 38911 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38912 + .word 49152 + .word 0 + .word 47937 + .word 50671 + .word 32821 + .word 51896 + .word 49152 + .word 0 + .word 8469 + .word 62640 + .word 24113 + .word 51168 + .word 49152 + .word 0 + .word 23666 + .word 39283 + .word 12728 + .word 33144 + .word 49153 + .word 0 + .word 1338 + .word 16824 + .word 25401 + .word 33044 + .word 49153 + .word 0 + .word 38006 + .word 50858 + .word 35636 + .word 41038 + .word 49153 + .word 0 + .word 6523 + .word 10616 + .word 46244 + .word 41017 + .word 49153 + .word 0 + .word 30889 + .word 22666 + .word 15710 + .word 49165 + .word 49153 + .word 0 + .word 22694 + .word 63464 + .word 47653 + .word 49161 + .word 49153 + .word 0 + .word 7860 + .word 665 + .word 58690 + .word 57345 + .word 49153 + .word 0 + .word 35199 + .word 5838 + .word 25732 + .word 57345 + .word 49153 + .word 0 + .word 27551 + .word 53562 + .word 7766 + .word 32768 + .word 49154 + .word 0 + .word 34954 + .word 15277 + .word 5706 + .word 32768 + .word 49154 + .word 0 + .word 10026 + .word 1321 + .word 863 + .word 36864 + .word 49154 + .word 0 + .word 38128 + .word 3645 + .word 634 + .word 36864 + .word 49154 + .word 0 + .word 22656 + .word 19824 + .word 86 + .word 40960 + .word 49154 + .word 0 + .word 3271 + .word 26602 + .word 63 + .word 40960 + .word 49154 + .word 0 + .word 57583 + .word 55422 + .word 7 + .word 45056 + .word 49154 + .word 0 + .word 8869 + .word 50081 + .word 5 + .word 45056 + .word 49154 + .word 0 + .word 59569 + .word 42847 + .word 0 + .word 49152 + .word 49154 + .word 0 + .word 6316 + .word 31480 + .word 0 + .word 49152 + .word 49154 + .word 0 + .word 65078 + .word 3295 + .word 0 + .word 53248 + .word 49154 + .word 0 + .word 35775 + .word 2421 + .word 0 + .word 53248 + .word 49154 + .word 0 + .word 28054 + .word 235 + .word 0 + .word 57344 + .word 49154 + .word 0 + .word 63410 + .word 172 + .word 0 + .word 57344 + .word 49154 + .word 0 + .word 45561 + .word 15 + .word 0 + .word 61440 + .word 49154 + .word 0 + .word 34811 + .word 11 + .word 0 + .word 61440 + .word 49154 + .word 0 + .word 32144 + .word 0 + .word 0 + .word 32768 + .word 49155 + .word 0 + .word 23616 + .word 0 + .word 0 + .word 32768 + .word 49155 + .word 0 + .word 1891 + .word 0 + .word 0 + .word 34816 + .word 49155 + .word 0 + .word 1389 + .word 0 + .word 0 + .word 34816 + .word 49155 + .word 0 + .word 105 + .word 0 + .word 0 + .word 36864 + .word 49155 + .word 0 + .word 77 + .word 0 + .word 0 + .word 36864 + .word 49155 + .word 0 + .word 6 + .word 0 + .word 0 + .word 38912 + .word 49155 + .word 0 + .word 5 + .word 0 + .word 0 + .word 38912 + .word 49155 + .word 0 + .word 30094 + .word 17612 + .word 34825 + .word 45621 + .word 49152 + .word 0 + .word 27787 + .word 64487 + .word 61865 + .word 44498 + .word 49152 + .word 0 + .word 45180 + .word 62215 + .word 30788 + .word 64910 + .word 49152 + .word 0 + .word 56909 + .word 5419 + .word 21954 + .word 64678 + .word 49152 + .word 0 + .word 26983 + .word 61012 + .word 55414 + .word 40900 + .word 49153 + .word 0 + .word 17042 + .word 26812 + .word 58543 + .word 40878 + .word 49153 + .word 0 + .word 17649 + .word 49100 + .word 16895 + .word 49142 + .word 49153 + .word 0 + .word 47753 + .word 6644 + .word 42105 + .word 49138 + .word 49153 + .word 0 + .word 56665 + .word 15855 + .word 40064 + .word 57342 + .word 49153 + .word 0 + .word 9214 + .word 11959 + .word 6291 + .word 57342 + .word 49153 + .word 0 + .word 44995 + .word 64071 + .word 54163 + .word 65535 + .word 49153 + .word 0 + .word 35553 + .word 53091 + .word 49943 + .word 65535 + .word 49153 + .word 0 + .word 39205 + .word 16423 + .word 64904 + .word 36863 + .word 49154 + .word 0 + .word 61074 + .word 52942 + .word 64669 + .word 36863 + .word 49154 + .word 0 + .word 11000 + .word 54094 + .word 65472 + .word 40959 + .word 49154 + .word 0 + .word 41911 + .word 24986 + .word 65449 + .word 40959 + .word 49154 + .word 0 + .word 33350 + .word 16833 + .word 65530 + .word 45055 + .word 49154 + .word 0 + .word 41532 + .word 8229 + .word 65528 + .word 45055 + .word 49154 + .word 0 + .word 52046 + .word 34170 + .word 65535 + .word 49151 + .word 49154 + .word 0 + .word 9080 + .word 22531 + .word 65535 + .word 49151 + .word 49154 + .word 0 + .word 19128 + .word 63123 + .word 65535 + .word 53247 + .word 49154 + .word 0 + .word 61194 + .word 62227 + .word 65535 + .word 53247 + .word 49154 + .word 0 + .word 43497 + .word 65363 + .word 65535 + .word 57343 + .word 49154 + .word 0 + .word 46501 + .word 65299 + .word 65535 + .word 57343 + .word 49154 + .word 0 + .word 33483 + .word 65524 + .word 65535 + .word 61439 + .word 49154 + .word 0 + .word 16207 + .word 65520 + .word 65535 + .word 61439 + .word 49154 + .word 0 + .word 18477 + .word 65535 + .word 65535 + .word 65535 + .word 49154 + .word 0 + .word 1013 + .word 65535 + .word 65535 + .word 65535 + .word 49154 + .word 0 + .word 64152 + .word 65535 + .word 65535 + .word 34815 + .word 49155 + .word 0 + .word 63638 + .word 65535 + .word 65535 + .word 34815 + .word 49155 + .word 0 + .word 65459 + .word 65535 + .word 65535 + .word 36863 + .word 49155 + .word 0 + .word 65431 + .word 65535 + .word 65535 + .word 36863 + .word 49155 + .word 0 + .word 65532 + .word 65535 + .word 65535 + .word 38911 + .word 49155 + .word 0 + .word 65531 + .word 65535 + .word 65535 + .word 38911 + .word 49155 + .word 0 + .word 16368 + .word 23276 + .word 14028 + .word 45039 + .word 16386 + .word 0 + .word 59281 + .word 7220 + .word 1358 + .word 44002 + .word 16385 + .word 0 + .word 209 + .word 31529 + .word 17251 + .word 45971 + .word 16384 + .word 0 + .word 22774 + .word 54591 + .word 46864 + .word 55119 + .word 16383 + .word 0 + .word 36309 + .word 6992 + .word 45734 + .word 65508 + .word 49154 + .word 0 + .word 57509 + .word 44567 + .word 44472 + .word 62561 + .word 49153 + .word 0 + .word 24352 + .word 36914 + .word 35595 + .word 62910 + .word 49152 + .word 0 + .word 36298 + .word 16311 + .word 10079 + .word 34683 + .word 49152 + .word 0 + .word 8745 + .word 24487 + .word 32401 + .word 58540 + .word 16393 + .word 0 + .word 64710 + .word 25493 + .word 17440 + .word 41602 + .word 16391 + .word 0 + .word 9540 + .word 49275 + .word 24345 + .word 64260 + .word 16388 + .word 0 + .word 32123 + .word 43450 + .word 42726 + .word 58824 + .word 16386 + .word 0 + .word 56179 + .word 18517 + .word 55467 + .word 35137 + .word 49163 + .word 0 + .word 59411 + .word 7122 + .word 11027 + .word 48002 + .word 49160 + .word 0 + .word 11599 + .word 47165 + .word 19459 + .word 34091 + .word 49158 + .word 0 + .word 3871 + .word 11740 + .word 51838 + .word 51028 + .word 49155 + .word 0 + .word 54329 + .word 49239 + .word 6514 + .word 47686 + .word 16379 + .word 0 + .word 32133 + .word 56 + .word 14391 + .word 58371 + .word 16379 + .word 0 + .word 29265 + .word 29887 + .word 53486 + .word 37761 + .word 16380 + .word 0 + .word 40734 + .word 56364 + .word 61890 + .word 52480 + .word 16379 + .word 0 + .word 62017 + .word 50151 + .word 39767 + .word 32901 + .word 16380 + .word 0 + .word 62465 + .word 1557 + .word 25992 + .word 44448 + .word 16380 + .word 0 + .word 46350 + .word 21258 + .word 57533 + .word 54364 + .word 16380 + .word 0 + .word 28472 + .word 57318 + .word 11755 + .word 48239 + .word 49136 + .word 0 + .word 64030 + .word 27012 + .word 42555 + .word 59902 + .word 49138 + .word 0 + .word 15295 + .word 64624 + .word 11797 + .word 40022 + .word 49141 + .word 0 + .word 40088 + .word 48672 + .word 55416 + .word 53395 + .word 16369 + .word 0 + .word 32150 + .word 7351 + .word 22467 + .word 34203 + .word 16372 + .word 0 + .word 32397 + .word 56161 + .word 46934 + .word 48494 + .word 16374 + .word 0 + .word 35896 + .word 51119 + .word 32272 + .word 61954 + .word 49143 + .word 0 + .word 64369 + .word 46577 + .word 49946 + .word 47894 + .word 16383 + .word 0 + .word 13507 + .word 11243 + .word 36867 + .word 37912 + .word 16374 + .word 0 + .word 13500 + .word 7397 + .word 345 + .word 51175 + .word 16375 + .word 0 + .word 36308 + .word 1299 + .word 15549 + .word 37687 + .word 16377 + .word 0 + .word 1494 + .word 43036 + .word 5286 + .word 33882 + .word 16379 + .word 0 + .word 51612 + .word 44256 + .word 49203 + .word 47051 + .word 49141 + .word 0 + .word 24103 + .word 45476 + .word 53751 + .word 61816 + .word 49142 + .word 0 + .word 18204 + .word 4207 + .word 64680 + .word 43260 + .word 49144 + .word 0 + .word 39634 + .word 35210 + .word 18170 + .word 34381 + .word 49146 + .word 0 + .word 30073 + .word 2874 + .word 60159 + .word 61890 + .word 16373 + .word 0 + .word 21923 + .word 37483 + .word 63587 + .word 45930 + .word 16375 + .word 0 + .word 17610 + .word 34235 + .word 25953 + .word 38432 + .word 16377 + .word 0 + .word 27391 + .word 45200 + .word 21903 + .word 41572 + .word 16379 + .word 0 + .word 8472 + .word 18376 + .word 37439 + .word 36904 + .word 49141 + .word 0 + .word 15138 + .word 28105 + .word 43771 + .word 52749 + .word 49142 + .word 0 + .word 19597 + .word 13484 + .word 38971 + .word 41168 + .word 49144 + .word 0 + .word 3303 + .word 60299 + .word 50447 + .word 38102 + .word 49146 + .word 0 + .word 47075 + .word 52558 + .word 55475 + .word 37762 + .word 16374 + .word 0 + .word 52173 + .word 35461 + .word 11437 + .word 59897 + .word 16375 + .word 0 + .word 36076 + .word 14373 + .word 35326 + .word 54659 + .word 16377 + .word 0 + .word 59562 + .word 13882 + .word 310 + .word 33073 + .word 16380 + .word 0 + .word 21162 + .word 13390 + .word 51910 + .word 43836 + .word 49141 + .word 0 + .word 25864 + .word 5553 + .word 52105 + .word 33196 + .word 49143 + .word 0 + .word 50214 + .word 4354 + .word 50978 + .word 55906 + .word 49144 + .word 0 + .word 22538 + .word 16515 + .word 54348 + .word 57115 + .word 49146 + .word 0 + .word 25669 + .word 8964 + .word 45428 + .word 52429 + .word 16390 + .word 0 + .word 42066 + .word 12451 + .word 5346 + .word 32773 + .word 16389 + .word 0 + .word 59247 + .word 49506 + .word 42126 + .word 43753 + .word 16387 + .word 0 + .word 41212 + .word 16190 + .word 63627 + .word 33236 + .word 16386 + .word 0 + .word 43030 + .word 44942 + .word 52710 + .word 59310 + .word 49135 + .word 0 + .word 4241 + .word 60350 + .word 9519 + .word 55057 + .word 49131 + .word 0 + .word 13201 + .word 63684 + .word 48400 + .word 58952 + .word 49135 + .word 0 + .word 43405 + .word 43520 + .word 7800 + .word 38026 + .word 49140 + .word 0 + .word 51109 + .word 32176 + .word 26595 + .word 37828 + .word 16382 + .word 0 + .word 39193 + .word 38974 + .word 13074 + .word 53901 + .word 16382 + .word 0 + .word 18403 + .word 21914 + .word 43743 + .word 52518 + .word 16381 + .word 0 + .word 11905 + .word 16066 + .word 37206 + .word 35465 + .word 16381 + .word 0 + .word 39192 + .word 38974 + .word 13074 + .word 53901 + .word 16383 + .word 0 + .word 16822 + .word 16066 + .word 37206 + .word 35465 + .word 16382 + .word 0 + .word 12453 + .word 1560 + .word 25992 + .word 44448 + .word 16381 + .word 0 + .word 46918 + .word 49948 + .word 39767 + .word 32901 + .word 16381 + .word 0 + .word 993 + .word 37711 + .word 1229 + .word 53967 + .word 16378 + .word 0 + .word 22241 + .word 58002 + .word 54887 + .word 56142 + .word 49145 + .word 0 + .word 8639 + .word 23392 + .word 41786 + .word 61781 + .word 16376 + .word 0 + .word 824 + .word 14446 + .word 39837 + .word 35166 + .word 49144 + .word 0 + .word 4398 + .word 47415 + .word 48788 + .word 40961 + .word 16375 + .word 0 + .word 53320 + .word 18702 + .word 33902 + .word 48514 + .word 49142 + .word 0 + .word 47965 + .word 49933 + .word 53838 + .word 58200 + .word 16373 + .word 0 + .word 46987 + .word 9286 + .word 62309 + .word 35268 + .word 49141 + .word 0 + .word 6461 + .word 640 + .word 17377 + .word 43104 + .word 16372 + .word 0 + .word 30338 + .word 25067 + .word 12218 + .word 53050 + .word 49139 + .word 0 + .word 3327 + .word 27408 + .word 8301 + .word 61564 + .word 16378 + .word 0 + .word 59387 + .word 42287 + .word 60059 + .word 60716 + .word 49145 + .word 0 + .word 13826 + .word 21215 + .word 7405 + .word 64741 + .word 16376 + .word 0 + .word 26137 + .word 29234 + .word 53880 + .word 36165 + .word 49144 + .word 0 + .word 10231 + .word 52926 + .word 36203 + .word 41655 + .word 16375 + .word 0 + .word 23407 + .word 27273 + .word 49305 + .word 49005 + .word 49142 + .word 0 + .word 11641 + .word 23288 + .word 44339 + .word 58553 + .word 16373 + .word 0 + .word 25249 + .word 6483 + .word 6272 + .word 35397 + .word 49141 + .word 0 + .word 42921 + .word 12425 + .word 13798 + .word 43198 + .word 16372 + .word 0 + .word 50188 + .word 64017 + .word 41333 + .word 53119 + .word 49139 + .word 0 + .word 25097 + .word 45200 + .word 21903 + .word 41572 + .word 16379 + .word 0 + .word 10972 + .word 60304 + .word 50447 + .word 38102 + .word 49146 + .word 0 + .word 15639 + .word 33828 + .word 25953 + .word 38432 + .word 16377 + .word 0 + .word 37131 + .word 35786 + .word 38971 + .word 41168 + .word 49144 + .word 0 + .word 11219 + .word 39714 + .word 63573 + .word 45930 + .word 16375 + .word 0 + .word 59109 + .word 9738 + .word 44211 + .word 52749 + .word 49142 + .word 0 + .word 51163 + .word 1079 + .word 49343 + .word 61890 + .word 16373 + .word 0 + .word 19090 + .word 15031 + .word 12079 + .word 36906 + .word 49141 + .word 0 + .word 28236 + .word 6956 + .word 155 + .word 44549 + .word 16372 + .word 0 + .word 54475 + .word 22231 + .word 8036 + .word 54711 + .word 49139 + .word 0 + .word 43885 + .word 13882 + .word 310 + .word 33073 + .word 16380 + .word 0 + .word 49382 + .word 16501 + .word 54348 + .word 57115 + .word 49146 + .word 0 + .word 54884 + .word 14552 + .word 35326 + .word 54659 + .word 16377 + .word 0 + .word 24455 + .word 7515 + .word 50978 + .word 55906 + .word 49144 + .word 0 + .word 57687 + .word 611 + .word 11437 + .word 59897 + .word 16375 + .word 0 + .word 26110 + .word 1729 + .word 52102 + .word 33196 + .word 49143 + .word 0 + .word 49827 + .word 25553 + .word 55506 + .word 37762 + .word 16374 + .word 0 + .word 45356 + .word 51283 + .word 52132 + .word 43836 + .word 49141 + .word 0 + .word 37526 + .word 52421 + .word 6331 + .word 51720 + .word 16372 + .word 0 + .word 23504 + .word 7355 + .word 4713 + .word 61833 + .word 49139 + .word 0 + .word 28030 + .word 45200 + .word 21903 + .word 41572 + .word 16379 + .word 0 + .word 64882 + .word 60298 + .word 50447 + .word 38102 + .word 49146 + .word 0 + .word 36628 + .word 34230 + .word 25953 + .word 38432 + .word 16377 + .word 0 + .word 2186 + .word 13495 + .word 38971 + .word 41168 + .word 49144 + .word 0 + .word 42048 + .word 38474 + .word 63587 + .word 45930 + .word 16375 + .word 0 + .word 44984 + .word 21655 + .word 43771 + .word 52749 + .word 49142 + .word 0 + .word 10340 + .word 31180 + .word 60154 + .word 61890 + .word 16373 + .word 0 + .word 29368 + .word 33685 + .word 37418 + .word 36904 + .word 49141 + .word 0 + .word 632 + .word 28858 + .word 25336 + .word 44574 + .word 16372 + .word 0 + .word 47657 + .word 7722 + .word 28520 + .word 54386 + .word 49139 + .word 0 + .word 48861 + .word 21442 + .word 12332 + .word 46245 + .word 16383 + .word 0 + .word 55836 + .word 1266 + .word 27621 + .word 35724 + .word 16386 + .word 0 + .word 19864 + .word 22843 + .word 65282 + .word 47516 + .word 16385 + .word 0 + .word 55755 + .word 27362 + .word 47250 + .word 57481 + .word 16389 + .word 0 + .word 27703 + .word 47960 + .word 491 + .word 37689 + .word 16392 + .word 0 + .word 41421 + .word 53711 + .word 6590 + .word 52435 + .word 16394 + .word 0 + .word 57789 + .word 21731 + .word 35033 + .word 43725 + .word 16395 + .word 0 + .word 55298 + .word 55134 + .word 50960 + .word 52072 + .word 16399 + .word 0 + .word 30636 + .word 39282 + .word 62891 + .word 33072 + .word 16404 + .word 0 + .word 7959 + .word 64403 + .word 49841 + .word 37534 + .word 16402 + .word 0 + .word 5854 + .word 54131 + .word 61334 + .word 53522 + .word 16408 + .word 0 + .word 5803 + .word 45364 + .word 48027 + .word 40704 + .word 16415 + .word 0 + .word 1370 + .word 7138 + .word 7454 + .word 61224 + .word 16409 + .word 0 + .word 57336 + .word 44117 + .word 55954 + .word 64739 + .word 16418 + .word 0 + .word 54670 + .word 41483 + .word 43064 + .word 36510 + .word 16428 + .word 0 + .word 42312 + .word 7696 + .word 38319 + .word 40746 + .word 16418 + .word 0 + .word 12302 + .word 62594 + .word 5410 + .word 37618 + .word 16430 + .word 0 + .word 9293 + .word 14879 + .word 6832 + .word 37045 + .word 16442 + .word 0 + .word 2958 + .word 50542 + .word 15469 + .word 40704 + .word 16427 + .word 0 + .word 42649 + .word 12819 + .word 63050 + .word 37565 + .word 16442 + .word 0 + .word 6063 + .word 43732 + .word 62723 + .word 36980 + .word 16457 + .word 0 + .word 22453 + .word 18298 + .word 44915 + .word 57947 + .word 16436 + .word 0 + .word 20554 + .word 96 + .word 8145 + .word 60162 + .word 16454 + .word 0 + .word 27743 + .word 60960 + .word 41480 + .word 33312 + .word 16473 + .word 0 + .word 22238 + .word 6527 + .word 38867 + .word 56588 + .word 16446 + .word 0 + .word 38516 + .word 42313 + .word 15095 + .word 36719 + .word 16468 + .word 0 + .word 36587 + .word 28039 + .word 41391 + .word 50829 + .word 16489 + .word 0 + .word 29867 + .word 13204 + .word 65176 + .word 36776 + .word 16457 + .word 0 + .word 31042 + .word 28858 + .word 52725 + .word 32812 + .word 16482 + .word 0 + .word 10384 + .word 4515 + .word 18607 + .word 62455 + .word 16506 + .word 0 + .word 9765 + .word 184 + .word 10999 + .word 62061 + .word 16467 + .word 0 + .word 31509 + .word 19231 + .word 45642 + .word 41528 + .word 16496 + .word 0 + .word 9807 + .word 42010 + .word 46528 + .word 59283 + .word 16524 + .word 0 + .word 34508 + .word 54054 + .word 11762 + .word 33288 + .word 16479 + .word 0 + .word 35651 + .word 17126 + .word 61083 + .word 36196 + .word 16511 + .word 0 + .word 61937 + .word 2245 + .word 55342 + .word 41983 + .word 16543 + .word 0 + .word 55800 + .word 52004 + .word 63053 + .word 44600 + .word 16490 + .word 0 + .word 1794 + .word 6965 + .word 62764 + .word 42435 + .word 16526 + .word 0 + .word 31259 + .word 48342 + .word 51287 + .word 43067 + .word 16562 + .word 0 + .word 51054 + .word 24828 + .word 3408 + .word 36750 + .word 16502 + .word 0 + .word 10851 + .word 65289 + .word 49628 + .word 32780 + .word 16542 + .word 0 + .word 55922 + .word 53580 + .word 2985 + .word 62379 + .word 16581 + .word 0 + .word 3514 + .word 59781 + .word 19773 + .word 36749 + .word 16514 + .word 0 + .word 6233 + .word 41678 + .word 56685 + .word 32779 + .word 16558 + .word 0 + .word 7397 + .word 40156 + .word 60492 + .word 62376 + .word 16601 + .word 0 + .word 64764 + .word 30182 + .word 28471 + .word 44055 + .word 16526 + .word 0 + .word 47394 + .word 43518 + .word 20307 + .word 41745 + .word 16574 + .word 0 + .word 48961 + .word 13130 + .word 26792 + .word 42193 + .word 16622 + .word 0 + .word 13149 + .word 49204 + .word 39329 + .word 62843 + .word 16538 + .word 0 + .word 63753 + .word 8765 + .word 38452 + .word 33516 + .word 16591 + .word 0 + .word 60000 + .word 22498 + .word 28021 + .word 38134 + .word 16643 + .word 0 + .word 10643 + .word 26389 + .word 15903 + .word 44739 + .word 16551 + .word 0 + .word 24943 + .word 57881 + .word 5976 + .word 53687 + .word 16607 + .word 0 + .word 62568 + .word 44908 + .word 48389 + .word 34359 + .word 16664 + .word 0 + .word 36352 + .word 25695 + .word 54808 + .word 41154 + .word 49155 + .word 0 + .word 53950 + .word 20364 + .word 22118 + .word 64130 + .word 16388 + .word 0 + .word 29016 + .word 1013 + .word 8897 + .word 49860 + .word 49158 + .word 0 + .word 48790 + .word 22905 + .word 44266 + .word 59689 + .word 49162 + .word 0 + .word 10097 + .word 41173 + .word 5368 + .word 62588 + .word 16398 + .word 0 + .word 18460 + .word 26935 + .word 48131 + .word 34999 + .word 49171 + .word 0 + .word 39812 + .word 13033 + .word 49143 + .word 34463 + .word 49170 + .word 0 + .word 11756 + .word 24889 + .word 14253 + .word 47765 + .word 16408 + .word 0 + .word 27397 + .word 56992 + .word 59569 + .word 35306 + .word 49183 + .word 0 + .word 1499 + .word 3328 + .word 1093 + .word 60276 + .word 49177 + .word 0 + .word 54443 + .word 57316 + .word 38982 + .word 63406 + .word 16418 + .word 0 + .word 46810 + .word 23189 + .word 13701 + .word 35573 + .word 49196 + .word 0 + .word 40551 + .word 19489 + .word 60782 + .word 40648 + .word 49186 + .word 0 + .word 16371 + .word 31130 + .word 60187 + .word 37497 + .word 16430 + .word 0 + .word 56271 + .word 55717 + .word 16120 + .word 36897 + .word 49210 + .word 0 + .word 11488 + .word 11046 + .word 17817 + .word 40691 + .word 49195 + .word 0 + .word 54617 + .word 39007 + .word 658 + .word 37550 + .word 16442 + .word 0 + .word 32140 + .word 49295 + .word 21536 + .word 36961 + .word 49225 + .word 0 + .word 5702 + .word 58081 + .word 34597 + .word 57945 + .word 49204 + .word 0 + .word 48280 + .word 56894 + .word 9030 + .word 60159 + .word 16454 + .word 0 + .word 61535 + .word 4768 + .word 37086 + .word 33310 + .word 49241 + .word 0 + .word 53564 + .word 21787 + .word 24446 + .word 56588 + .word 49214 + .word 0 + .word 35771 + .word 11952 + .word 2619 + .word 36719 + .word 16468 + .word 0 + .word 47624 + .word 53808 + .word 19802 + .word 50829 + .word 49257 + .word 0 + .word 42706 + .word 15946 + .word 64291 + .word 36776 + .word 49225 + .word 0 + .word 8317 + .word 44716 + .word 51672 + .word 32812 + .word 16482 + .word 0 + .word 31251 + .word 20899 + .word 16102 + .word 62455 + .word 49274 + .word 0 + .word 2105 + .word 17517 + .word 10872 + .word 62061 + .word 49235 + .word 0 + .word 60728 + .word 14335 + .word 45529 + .word 41528 + .word 16496 + .word 0 + .word 1336 + .word 56903 + .word 46326 + .word 59283 + .word 49292 + .word 0 + .word 34501 + .word 54054 + .word 11762 + .word 33288 + .word 49247 + .word 0 + .word 35638 + .word 17126 + .word 61083 + .word 36196 + .word 16511 + .word 0 + .word 12489 + .word 2246 + .word 55342 + .word 41983 + .word 49311 + .word 0 + .word 55790 + .word 52004 + .word 63053 + .word 44600 + .word 49258 + .word 0 + .word 1778 + .word 6965 + .word 62764 + .word 42435 + .word 16526 + .word 0 + .word 47762 + .word 48342 + .word 51287 + .word 43067 + .word 49330 + .word 0 + .word 51047 + .word 24828 + .word 3408 + .word 36750 + .word 49270 + .word 0 + .word 10839 + .word 65289 + .word 49628 + .word 32780 + .word 16542 + .word 0 + .word 14289 + .word 53581 + .word 2985 + .word 62379 + .word 49349 + .word 0 + .word 3506 + .word 59781 + .word 19773 + .word 36749 + .word 49282 + .word 0 + .word 6220 + .word 41678 + .word 56685 + .word 32779 + .word 16558 + .word 0 + .word 31299 + .word 40156 + .word 60492 + .word 62376 + .word 49369 + .word 0 + .word 64754 + .word 30182 + .word 28471 + .word 44055 + .word 49294 + .word 0 + .word 47368 + .word 43518 + .word 20307 + .word 41745 + .word 16574 + .word 0 + .word 65114 + .word 13130 + .word 26792 + .word 42193 + .word 49390 + .word 0 + .word 13136 + .word 49204 + .word 39329 + .word 62843 + .word 49306 + .word 0 + .word 63757 + .word 8765 + .word 38452 + .word 33516 + .word 16591 + .word 0 + .word 9085 + .word 22499 + .word 28021 + .word 38134 + .word 49411 + .word 0 + .word 10631 + .word 26389 + .word 15903 + .word 44739 + .word 49319 + .word 0 + .word 24915 + .word 57881 + .word 5976 + .word 53687 + .word 16607 + .word 0 + .word 16910 + .word 44909 + .word 48389 + .word 34359 + .word 49432 + .word 0 + .type _ldbA,@object + .size _ldbA,4620 + .space 4, 0x00 # pad + .align 16 +_dbA: + .long 4235179544 + .long 3219290252 + .long 3295226828 + .long 3164508998 + .long 1649608659 + .long 1072320934 + .long 3173846476 + .long 1014071527 + .long 1542107862 + .long 3218711765 + .long 2540989727 + .long 3163202496 + .long 1649608660 + .long 3220853158 + .long 859914669 + .long 1017880115 + .long 717740104 + .long 3219214642 + .long 2376945980 + .long 3162254827 + .long 1431655765 + .long 1068848469 + .long 1431655765 + .long 1012225365 + .long 1431655765 + .long 1068848469 + .long 42583435 + .long 1011709190 + .long 3362045620 + .long 1072523249 + .long 4064281872 + .long 1016386130 + .long 4002465326 + .long 3220678216 + .long 1750589542 + .long 1014054706 + .long 2343010478 + .long 3220651595 + .long 2022209519 + .long 3165213628 + .long 3582788241 + .long 1077376220 + .long 3584976419 + .long 3225506388 + .long 2237448112 + .long 1085305363 + .long 634573353 + .long 3233318238 + .long 2248101888 + .long 1073427871 + .long 1861873466 + .long 1016835790 + .long 2560862412 + .long 1071060948 + .long 30404090 + .long 3163588833 + .long 1673151062 + .long 1081107801 + .long 641486499 + .long 3229145757 + .long 2847476088 + .long 1079825078 + .long 4109693297 + .long 3227890617 + .long 80699903 + .long 1078574114 + .long 2114691410 + .long 3226679074 + .long 1354791574 + .long 1083527322 + .long 1238563653 + .long 3231741049 + .long 2909836308 + .long 1082322123 + .long 2961745666 + .long 3230453807 + .long 4254370204 + .long 3222569838 + .long 2523116623 + .long 1016608103 + .long 3036354677 + .long 3220338375 + .long 4197032384 + .long 3163739097 + .long 618767413 + .long 1086658447 + .long 4224046954 + .long 3235503748 + .long 918515347 + .long 1104466354 + .long 1558545744 + .long 3253448772 + .long 3598672851 + .long 1075147148 + .long 1862579612 + .long 1019557195 + .long 814211565 + .long 1073042505 + .long 3816489657 + .long 3166119701 + .long 1438601496 + .long 1094947899 + .long 3932640262 + .long 3243813893 + .long 1025077628 + .long 1092155011 + .long 4084583552 + .long 3241103782 + .long 2491631644 + .long 1089473568 + .long 3212116569 + .long 3238261210 + .long 764386880 + .long 1100022671 + .long 1839771210 + .long 3248755462 + .long 3990369246 + .long 1097905463 + .long 1112302030 + .long 3246751353 + .long 717740104 + .long 1070682418 + .long 230143214 + .long 1014072542 + .long 1542107862 + .long 1071228117 + .long 2869986399 + .long 1017025354 + .long 2620920409 + .long 1068568872 + .long 3005931917 + .long 1068498895 + .long 3773030413 + .long 1068741081 + .long 221735135 + .long 1068648815 + .long 1649608659 + .long 1072320934 + .long 2259103138 + .long 1014410184 + .long 1798481678 + .long 1068036068 + .long 1435858614 + .long 1066348979 + .long 2798813559 + .long 1068114295 + .long 1711004053 + .long 1067747678 + .long 2010902109 + .long 1068166444 + .long 2474987820 + .long 1068059813 + .long 780818753 + .long 1068375890 + .long 4117616766 + .long 1068267614 + .long 1604677386 + .long 1068848813 + .long 1854392195 + .long 1067982657 + .long 4235179544 + .long 1071806604 + .long 2606438347 + .long 1015960145 + .long 2893907075 + .long 1066734370 + .long 2294698909 + .long 1014073149 + .long 441808390 + .long 3216064000 + .long 1880662273 + .long 1012321168 + .long 3253204732 + .long 3200326446 + .long 3649195207 + .long 1051723342 + .long 1676415034 + .long 3202599881 + .long 856428669 + .long 1053972858 + .long 3299217318 + .long 1070900044 + .long 4151699616 + .long 1010498715 + .long 1123572530 + .long 1044951237 + .long 3942090667 + .long 3191111442 + .long 179320158 + .long 3191607973 + .long 648955671 + .long 3189543958 + .long 338963396 + .long 3195730567 + .long 729244107 + .long 1047109933 + .long 491939632 + .long 3198035439 + .long 2441649049 + .long 1049392674 + .long 4000663347 + .long 1056276700 + .long 3497022620 + .long 3193423889 + .long 119575502 + .long 1071320806 + .long 3893526980 + .long 3160417465 + .long 2378611747 + .long 3217220647 + .long 3721041488 + .long 3160948136 + .long 212213087 + .long 1003805565 + .long 3707885569 + .long 946762142 + .long 954325311 + .long 1061996326 + .long 2572405945 + .long 3208784108 + .long 2047107390 + .long 1053958905 + .long 2157300588 + .long 3201555925 + .long 3371055275 + .long 1071576875 + .long 1069844800 + .long 1015429887 + .long 3166931521 + .long 3216972217 + .long 3220968514 + .long 3161728497 + .long 4141120019 + .long 1057975373 + .long 3048513049 + .long 3204734413 + .long 1172170140 + .long 1059250739 + .long 2600146741 + .long 3206041877 + .long 2751605624 + .long 1060573214 + .long 1663282963 + .long 3207426590 + .long 3895324829 + .long 1055298027 + .long 157415216 + .long 3202171477 + .long 3734613381 + .long 1056602430 + .long 277770430 + .long 3203481600 + .long 3198889327 + .long 3217706325 + .long 2705408501 + .long 1014676637 + .long 59787751 + .long 1073579891 + .long 1470716836 + .long 1013369721 + .long 2045320829 + .long 1061536716 + .long 93552279 + .long 3208285776 + .long 1578930691 + .long 1053381091 + .long 2541023 + .long 3199217833 + .long 2303467340 + .long 1072252569 + .long 567354353 + .long 1016170573 + .long 4277811695 + .long 1072049730 + .long 3950020367 + .long 3160819724 + .long 2523318625 + .long 1057215902 + .long 2302510246 + .long 3203993877 + .long 298082853 + .long 1058616118 + .long 2097322096 + .long 3205466603 + .long 1798601470 + .long 1060132265 + .long 1407285416 + .long 3206822737 + .long 4077669298 + .long 1054450862 + .long 2333929458 + .long 3201533971 + .long 2747507284 + .long 1055881541 + .long 2839080721 + .long 3202576178 + .long 3383958356 + .long 3218498155 + .long 613656875 + .long 1017795528 + .long 173059452 + .long 1075530818 + .long 704088483 + .long 1015836313 + .long 669591746 + .long 1061765380 + .long 2029568326 + .long 3208524070 + .long 4157429832 + .long 1054150757 + .long 704852271 + .long 3201323640 + .long 846452204 + .long 1073165719 + .long 1707052239 + .long 1015225852 + .long 1011120585 + .long 1074996836 + .long 2354399398 + .long 3161432137 + .long 954697072 + .long 1057288366 + .long 1270411324 + .long 3204047380 + .long 711769130 + .long 1058758297 + .long 1128721 + .long 3205559284 + .long 179011054 + .long 1060257504 + .long 4204770871 + .long 3206955261 + .long 3137275514 + .long 1053955134 + .long 762311517 + .long 3199983289 + .long 728345252 + .long 1056011172 + .long 1369631397 + .long 3202845593 + .long 3569027386 + .long 3214047105 + .long 3629871173 + .long 3159432582 + .long 2480864277 + .long 1072801415 + .long 765976303 + .long 1016615598 + .long 759560957 + .long 1082479958 + .long 4267700141 + .long 3214355674 + .long 519344805 + .long 3246817843 + .long 220815467 + .long 3246677566 + .long 585197945 + .long 1074992152 + .long 3068616556 + .long 1020233496 + .long 4125953813 + .long 3215772665 + .long 1932096513 + .long 3151829739 + .long 891522464 + .long 1087323966 + .long 2489260670 + .long 3237524288 + .long 198576582 + .long 1086294508 + .long 1118764770 + .long 3231025522 + .long 4028480604 + .long 1084377135 + .long 1979567970 + .long 3223360994 + .long 4063308394 + .long 3244561236 + .long 4166146281 + .long 3246077527 + .long 2664161993 + .long 3240072782 + .long 259025260 + .long 3242645417 + .long 378360574 + .long 1070238620 + .long 2959696752 + .long 1069921292 + .long 573154909 + .long 1069707436 + .long 4044344316 + .long 1069551882 + .long 477218588 + .long 1069314503 + .long 0 + .long 3217031168 + .long 2454267026 + .long 1069697316 + .long 1431655765 + .long 3217380693 + .long 2576980378 + .long 1070176665 + .long 0 + .long 3218079744 + .long 1431655765 + .long 1070945621 + .long 0 + .long 3219128320 + .long 2759451285 + .long 3216787420 + .long 439852373 + .long 3160440428 + .long 925239789 + .long 1070204188 + .long 1052235825 + .long 1014694615 + .long 2825585883 + .long 3219218351 + .long 1250510261 + .long 3158266606 + .long 4280873151 + .long 1070880196 + .long 3382653115 + .long 1014364358 + .long 3432120556 + .long 1060112640 + .long 1689864936 + .long 3206804514 + .long 2559966835 + .long 1058598642 + .long 1675881979 + .long 3205446725 + .long 3157807190 + .long 1057195995 + .long 83437824 + .long 3203930944 + .long 714759041 + .long 1055696489 + .long 94115283 + .long 3202310560 + .long 231342353 + .long 1053665780 + .long 2283895727 + .long 3199602663 + .long 2514471110 + .long 1050042839 + .long 1783553765 + .long 3194406773 + .long 2977985131 + .long 3217141333 + .long 1199854581 + .long 3162366396 + .long 2962538897 + .long 3216960405 + .long 4143040985 + .long 3159573871 + .long 1505583242 + .long 1067626192 + .long 1685935487 + .long 1007379916 + .long 1307717362 + .long 1071507942 + .long 2592844004 + .long 1015649171 + .long 799685378 + .long 1060113448 + .long 3181808512 + .long 3206805166 + .long 237118685 + .long 1058600582 + .long 1021521704 + .long 3205452843 + .long 562863096 + .long 1057199158 + .long 124222188 + .long 3203968611 + .long 666083857 + .long 1055962453 + .long 2573104645 + .long 3202709164 + .long 3241565485 + .long 1053885149 + .long 1335355988 + .long 3200533016 + .long 1040080838 + .long 1054134824 + .long 2847172487 + .long 3201012249 + .long 3198889327 + .long 3217706325 + .long 1543330549 + .long 3160864782 + .long 4277811695 + .long 1072049730 + .long 993295933 + .long 1014676638 + .long 59787751 + .long 1073579891 + .long 130295530 + .long 1013369744 + .long 2303467340 + .long 1072252569 + .long 3943765603 + .long 1016170278 + .long 3608922566 + .long 1060045649 + .long 1453569939 + .long 3207287740 + .long 3338057825 + .long 3206066477 + .long 3038862383 + .long 3208900206 + .long 2094875998 + .long 3209983096 + .long 1016858122 + .long 3211012944 + .long 2854570659 + .long 3211659217 + .long 1144696552 + .long 3211904901 + .long 2176258130 + .long 3211749311 + .long 3478125247 + .long 3210994876 + .long 2355567962 + .long 3209692799 + .long 3598755244 + .long 3207186288 + .long 3383958356 + .long 3218498155 + .long 141035778 + .long 3162876606 + .long 1011120585 + .long 1074996836 + .long 1865540452 + .long 1017795522 + .long 173059452 + .long 1075530818 + .long 1582816653 + .long 1015838421 + .long 846452204 + .long 1073165719 + .long 2382960778 + .long 1015259319 + .long 3627221817 + .long 1060257525 + .long 782594551 + .long 3206955283 + .long 1981242537 + .long 1058758037 + .long 1755079229 + .long 3205559658 + .long 2436997517 + .long 1057278666 + .long 3384076381 + .long 3204067450 + .long 2476719666 + .long 1056224805 + .long 337705071 + .long 3201230508 + .long 776493412 + .long 3197801902 + .long 2139883963 + .long 3204685556 + .long 1475852201 + .long 3204789337 + .long 945638604 + .long 3203947238 + .long 3198889327 + .long 3217706325 + .long 4282828456 + .long 3160832800 + .long 4277811695 + .long 1072049730 + .long 993624082 + .long 1014676638 + .long 59787751 + .long 1073579891 + .long 1881378167 + .long 1013369744 + .long 2303467340 + .long 1072252569 + .long 2285482445 + .long 1016170301 + .long 2583886559 + .long 1060132251 + .long 2972085422 + .long 3206822622 + .long 1867851267 + .long 1058615355 + .long 680445507 + .long 3205461644 + .long 1455562209 + .long 1057201491 + .long 2171135678 + .long 3203931082 + .long 973516116 + .long 1055683749 + .long 442346719 + .long 3202274605 + .long 3339219778 + .long 1053603010 + .long 4261370927 + .long 3199529466 + .long 1389725956 + .long 1049937931 + .long 3421055527 + .long 3194266408 + .long 3440444171 + .long 3149749917 + .long 2683862484 + .long 3093774621 + .long 1722766174 + .long 1073233897 + .long 1535800986 + .long 1017782563 + .long 2952983900 + .long 1075015403 + .long 1613333390 + .long 1019450778 + .long 1747624399 + .long 1077465903 + .long 1323746741 + .long 1077414384 + .long 2170768622 + .long 1079283370 + .long 3681271869 + .long 1079585146 + .long 2395326938 + .long 1081247483 + .long 1534348539 + .long 1081774816 + .long 339892429 + .long 1083288020 + .long 3528406654 + .long 1083985153 + .long 2588043907 + .long 1085376283 + .long 2346296707 + .long 1086214596 + .long 207705063 + .long 1087509517 + .long 2560418979 + .long 1088486188 + .long 2868926017 + .long 1088759609 + .long 1843351610 + .long 1091968574 + .long 2991121454 + .long 1008150290 + .long 2149211495 + .long 952864023 + .long 1596959828 + .long 1075781798 + .long 2172289614 + .long 1019977377 + .long 2540785903 + .long 1077531858 + .long 1236674410 + .long 1020936929 + .long 4153228343 + .long 1087542211 + .long 2696338690 + .long 1090238842 + .long 878599865 + .long 1092951715 + .long 1553131440 + .long 1095784438 + .long 1380037893 + .long 1098488966 + .long 2667481451 + .long 1101284640 + .long 2282526011 + .long 1104162081 + .long 2355356013 + .long 1106903006 + .long 2198000318 + .long 1109722332 + .long 415847444 + .long 1112609215 + .long 1244368631 + .long 1115409383 + .long 1504872183 + .long 1118250351 + .long 1483597343 + .long 1121215185 + .long 2372686104 + .long 1123791138 + .long 2950620603 + .long 1012416763 + .long 1854687498 + .long 952811571 + .long 4103214658 + .long 1077594716 + .long 2773032534 + .long 1020189917 + .long 3447799694 + .long 1081361429 + .long 400789830 + .long 1023147708 + .long 3214535591 + .long 1099259453 + .long 1237622722 + .long 1103959294 + .long 3800166525 + .long 1108620252 + .long 3349752687 + .long 1113359257 + .long 1736707866 + .long 1118068670 + .long 1604218008 + .long 1122855127 + .long 472376766 + .long 1127573289 + .long 2849635624 + .long 1132420823 + .long 1552594705 + .long 1137123494 + .long 3251899291 + .long 1141973158 + .long 523050174 + .long 1146711894 + .long 2820496385 + .long 1151553661 + .long 507113183 + .long 1156515491 + .long 3382661695 + .long 1160984436 + .long 1797993220 + .long 1014085677 + .long 1007534641 + .long 957814894 + .long 136949250 + .long 1079957294 + .long 360284395 + .long 1016466469 + .long 784478107 + .long 1086123203 + .long 2737766812 + .long 1029538613 + .long 1541190179 + .long 1113554317 + .long 209153222 + .long 1120512208 + .long 2353533988 + .long 1127569405 + .long 445988592 + .long 1134692642 + .long 3579939511 + .long 1141824664 + .long 1580626808 + .long 1148890066 + .long 214151816 + .long 1156005346 + .long 2068712408 + .long 1163158821 + .long 839406419 + .long 1170342165 + .long 3247543387 + .long 1177546316 + .long 4025420415 + .long 1184654254 + .long 956971024 + .long 1191825477 + .long 2268897124 + .long 1199100768 + .long 3197790250 + .long 1206020453 + .long 2712668744 + .long 1014362371 + .long 420246125 + .long 958137372 + .long 2654663338 + .long 1082564068 + .long 4161996347 + .long 1025251297 + .long 1213005072 + .long 1091554851 + .long 789699257 + .long 1035400076 + .long 800710857 + .long 1129640478 + .long 2496483081 + .long 1139363849 + .long 599798751 + .long 1149188652 + .long 1701185240 + .long 1158910290 + .long 2369516264 + .long 1168692319 + .long 283492325 + .long 1178587937 + .long 3183141054 + .long 1188335795 + .long 3641040163 + .long 1198179274 + .long 561697907 + .long 1208059224 + .long 1909654917 + .long 1217858291 + .long 2831089635 + .long 1227776627 + .long 2923368563 + .long 1237613769 + .long 3277782853 + .long 1247623400 + .long 2305379544 + .long 1257247294 + .long 2173558120 + .long 3167899773 + .long 3928519072 + .long 3112134976 + .long 2855828427 + .long 1085518855 + .long 2402042833 + .long 1029906467 + .long 3668949703 + .long 1097350789 + .long 1498999354 + .long 1041534216 + .long 1894732623 + .long 1147309596 + .long 3157447236 + .long 1159959522 + .long 1106557451 + .long 1172641345 + .long 2830063624 + .long 1185354419 + .long 1827524850 + .long 1198100435 + .long 3148494391 + .long 1210882790 + .long 408406249 + .long 1223697282 + .long 1409028207 + .long 1236424336 + .long 3586220107 + .long 1249179206 + .long 1522157876 + .long 1261965775 + .long 1820647987 + .long 1274787293 + .long 141517691 + .long 1287671841 + .long 1169226569 + .long 1300517027 + .long 1216765362 + .long 1313047128 + .long 1448028998 + .long 1021264728 + .long 3859033985 + .long 964258238 + .long 4275468065 + .long 1088663688 + .long 2839015045 + .long 1031960699 + .long 2471825140 + .long 1103641144 + .long 2116308392 + .long 1045704405 + .long 320063693 + .long 1166181438 + .long 1786259137 + .long 1181976509 + .long 2022503488 + .long 1197803342 + .long 3654410397 + .long 1213661261 + .long 3612544687 + .long 1229551918 + .long 2586390227 + .long 1245478664 + .long 4037720966 + .long 1261441627 + .long 425603198 + .long 1277313397 + .long 2335359117 + .long 1293212748 + .long 663099774 + .long 1309143515 + .long 3275152075 + .long 1325108897 + .long 3939307299 + .long 1341142935 + .long 2389223216 + .long 1357131850 + .long 3001851795 + .long 1372807567 + .long 2843660044 + .long 1027797837 + .long 4081430736 + .long 972886614 + .long 59873159 + .long 1091970578 + .long 89491691 + .long 1036070212 + .long 800587417 + .long 1110354163 + .long 1316695415 + .long 1054362062 + .long 1053415956 + .long 1186120592 + .long 1951112295 + .long 1205224339 + .long 3452306653 + .long 1224406940 + .long 3087408826 + .long 1243649885 + .long 3141065505 + .long 1262791580 + .long 1611223017 + .long 1282016047 + .long 2457220276 + .long 1301315843 + .long 567478369 + .long 1320490698 + .long 744018712 + .long 1339759601 + .long 3767838035 + .long 1359052970 + .long 2731826519 + .long 1378265330 + .long 2965944329 + .long 1397620918 + .long 3792836018 + .long 1416954415 + .long 4140163483 + .long 1435938859 + .long 3803251356 + .long 1031449026 + .long 1468351707 + .long 974519095 + .long 1510773204 + .long 1095479170 + .long 3459876679 + .long 1039900066 + .long 2329980675 + .long 1117254636 + .long 1442547585 + .long 1060380811 + .long 3793321184 + .long 1207035105 + .long 3851928555 + .long 1229621800 + .long 221632261 + .long 1252267869 + .long 2942953492 + .long 1274996464 + .long 3017520070 + .long 1297616871 + .long 239470767 + .long 1320348902 + .long 1043025700 + .long 1343095998 + .long 252688637 + .long 1365768517 + .long 3880214591 + .long 1388528317 + .long 3579258508 + .long 1411323545 + .long 4034496078 + .long 1434003397 + .long 4007330572 + .long 1456787727 + .long 4167750282 + .long 1479686237 + .long 1263363363 + .long 1502124177 + .long 1204128515 + .long 3180787222 + .long 711751003 + .long 3124411148 + .long 655669005 + .long 1099106472 + .long 1779452985 + .long 1041271036 + .long 3714137145 + .long 1124508819 + .long 3422050113 + .long 1068643358 + .long 2129754319 + .long 1228815190 + .long 1696310114 + .long 1255068559 + .long 1933048134 + .long 1281362741 + .long 1387613391 + .long 1307637530 + .long 3120180336 + .long 1333930483 + .long 2543548174 + .long 1360241860 + .long 1743952085 + .long 1386572739 + .long 830746048 + .long 1412924879 + .long 3823372438 + .long 1439300663 + .long 3126160514 + .long 1465701841 + .long 3650788872 + .long 1492126330 + .long 1753940109 + .long 1518485640 + .long 4158688957 + .long 1544943454 + .long 2419002512 + .long 1571054314 + .long 1387068573 + .long 1036196119 + .long 693317055 + .long 975620966 + .long 85037501 + .long 1102875900 + .long 2766547698 + .long 1047046221 + .long 692715848 + .long 1132034342 + .long 4084350207 + .long 1074738271 + .long 3670967869 + .long 1251313085 + .long 877136010 + .long 1281389973 + .long 2367669872 + .long 1311355635 + .long 127681551 + .long 1341415835 + .long 294488793 + .long 1371561390 + .long 2268228308 + .long 1401588863 + .long 1971903155 + .long 1431680659 + .long 3068569563 + .long 1461838328 + .long 2810042085 + .long 1491968471 + .long 1803405805 + .long 1522051425 + .long 2718559511 + .long 1552192554 + .long 1282364655 + .long 1582403523 + .long 2077022624 + .long 1612690417 + .long 3574791831 + .long 1642467624 + .long 1679930357 + .long 3189181796 + .long 2680901783 + .long 3131938295 + .long 3217922759 + .long 1106719372 + .long 512421297 + .long 1047804811 + .long 767402551 + .long 1139855610 + .long 1780644693 + .long 1084244525 + .long 2568107092 + .long 1274594461 + .long 3742446639 + .long 1308542877 + .long 2828203709 + .long 1342408213 + .long 1035153137 + .long 1376332101 + .long 135830143 + .long 1410361976 + .long 3493601403 + .long 1444258562 + .long 2859691870 + .long 1478279541 + .long 289914903 + .long 1512259079 + .long 388251426 + .long 1546250265 + .long 3047966471 + .long 1580303536 + .long 3861742472 + .long 1614266653 + .long 1260166508 + .long 1648392316 + .long 904399223 + .long 1682450578 + .long 3334685854 + .long 1716212562 + .long 883499133 + .long 1045834798 + .long 1040153219 + .long 987496666 + .long 789418155 + .long 1110723643 + .long 2045920566 + .long 1052287721 + .long 682953991 + .long 1147781119 + .long 96584340 + .long 1092099645 + .long 666163210 + .long 1298545479 + .long 1527740296 + .long 1336421526 + .long 43027861 + .long 1374344588 + .long 1893757912 + .long 1412317817 + .long 3310921752 + .long 1450264132 + .long 1086815150 + .long 1488186400 + .long 2822587825 + .long 1526147814 + .long 1629445394 + .long 1564156239 + .long 2622810410 + .long 1602221540 + .long 2876661682 + .long 1640163607 + .long 151499969 + .long 1678143447 + .long 3591180187 + .long 1716205976 + .long 126024331 + .long 1754364017 + .long 3251093187 + .long 1792100966 + .long 2455853998 + .long 3194846833 + .long 2105329433 + .long 3137419111 + .long 1677091468 + .long 1114834807 + .long 3103559369 + .long 1057563919 + .long 156965555 + .long 1155965375 + .long 1332523955 + .long 1098438055 + .long 2734085455 + .long 1323184128 + .long 3116950081 + .long 1365165587 + .long 2683234966 + .long 1407189808 + .long 2373753488 + .long 1449192848 + .long 1367022160 + .long 1491213979 + .long 3828829922 + .long 1533253445 + .long 649201501 + .long 1575312310 + .long 1349232455 + .long 1617392311 + .long 2871919995 + .long 1659495809 + .long 3481654166 + .long 1701624529 + .long 3617101938 + .long 1743779051 + .long 431481593 + .long 1785867563 + .long 121308995 + .long 1828052659 + .long 357611834 + .long 1869892289 + .long 294133886 + .long 3202139689 + .long 3712546231 + .long 3146198591 + .long 3880935161 + .long 1119029102 + .long 59549724 + .long 1063684005 + .long 3647913141 + .long 1164353962 + .long 4227156178 + .long 1109331949 + .long 3682674216 + .long 1348349871 + .long 2807072537 + .long 1394525619 + .long 2124002856 + .long 1440744183 + .long 2605559380 + .long 1486941516 + .long 2185296140 + .long 1533156938 + .long 3364132884 + .long 1579390693 + .long 3636842097 + .long 1625643843 + .long 1564856349 + .long 1671918127 + .long 282911834 + .long 1718215904 + .long 224295158 + .long 1764538898 + .long 1397797422 + .long 1810887684 + .long 130160665 + .long 1857170584 + .long 3494254532 + .long 1903549984 + .long 2087544159 + .long 1949584056 + .long 2070009724 + .long 3207114478 + .long 3313155961 + .long 3151739743 + .long 1799064076 + .long 1123301109 + .long 3318052585 + .long 1067728611 + .long 1398608221 + .long 1172933154 + .long 3195587656 + .long 1117275768 + .long 3966862011 + .long 1374007527 + .long 3094801078 + .long 1424457063 + .long 201966774 + .long 1474951107 + .long 1216746698 + .long 1525492144 + .long 4169038329 + .long 1576047750 + .long 2574869838 + .long 1626540825 + .long 3353136223 + .long 1677069826 + .long 246421124 + .long 1727641760 + .long 3497001028 + .long 1778265406 + .long 1014877316 + .long 1828833334 + .long 2620327651 + .long 1879376562 + .long 1343179361 + .long 1929994932 + .long 3499694378 + .long 1980775534 + .long 852481763 + .long 2031094897 + .long 858300611 + .long 1060903333 + .long 1069421656 + .long 1004554972 + .long 381774873 + .long 1127661932 + .long 2890562600 + .long 1072008419 + .long 3230239600 + .long 1181757061 + .long 1093463150 + .long 1126994478 + .long 2041459920 + .long 1400246667 + .long 1834149192 + .long 1455089424 + .long 3431867819 + .long 1509997896 + .long 673297555 + .long 1564813682 + .long 2939272129 + .long 1619727956 + .long 2561583193 + .long 1674674892 + .long 1592460776 + .long 1729549373 + .long 4229377564 + .long 1784543364 + .long 3147274091 + .long 1839450750 + .long 199676655 + .long 1894400365 + .long 515597810 + .long 1949398723 + .long 2826001657 + .long 2004337665 + .long 1832191040 + .long 2059473164 + .long 486033509 + .long 2114113687 + .long 2615285763 + .long 3215685247 + .long 3139164341 + .long 3160067829 + .long 2576980377 + .long 1132042649 + .long 2136544456 + .long 1076438044 + .long 1202590842 + .long 1190427361 + .long 3058408830 + .long 1135356281 + .long 2163381214 + .long 1426480799 + .long 2353327718 + .long 1485745575 + .long 3794661129 + .long 1544911246 + .long 3594844771 + .long 1604225727 + .long 3801864141 + .long 1663434111 + .long 1474426882 + .long 1722809436 + .long 2103181697 + .long 1782019277 + .long 1306699518 + .long 1841386098 + .long 2394149058 + .long 1900657427 + .long 2802357954 + .long 1959997432 + .long 4190579671 + .long 2019374921 + .long 1589399104 + .long 2078657782 + .long 459261522 + .long 2137266825 + .long 4294967295 + .long 2146435071 + .long 158971950 + .long 3154658393 + .long 3459173435 + .long 3099360488 + .long 2835657100 + .long 3221135661 + .long 3134582638 + .long 3163662002 + .long 1009146449 + .long 1076045439 + .long 2177907437 + .long 1020724564 + .long 2093419253 + .long 1082406719 + .long 3184966549 + .long 3231785529 + .long 3799028631 + .long 1086175845 + .long 81768581 + .long 3235523877 + .long 1017495356 + .long 1089951767 + .long 1546026610 + .long 3239380678 + .long 980092412 + .long 1093867758 + .long 4064795288 + .long 3243341671 + .long 3027586419 + .long 1097863735 + .long 1002816472 + .long 3247290528 + .long 985745927 + .long 1101758613 + .long 1714999460 + .long 3251222455 + .long 808706777 + .long 1105883774 + .long 2540867906 + .long 3255308994 + .long 1548702939 + .long 3157340334 + .long 1276328330 + .long 3102548777 + .long 2523682374 + .long 3224680861 + .long 1002691513 + .long 3168986622 + .long 2919511741 + .long 1081046750 + .long 3737147325 + .long 1024759629 + .long 2879373926 + .long 1098115315 + .long 103788827 + .long 3250052030 + .long 3732555687 + .long 1107111798 + .long 3845853773 + .long 3259114079 + .long 3808164400 + .long 1116131626 + .long 1738785984 + .long 3268214722 + .long 581652 + .long 1125291233 + .long 3382894442 + .long 3277322952 + .long 2879368705 + .long 1134502288 + .long 2391566275 + .long 3286518813 + .long 274553400 + .long 1143638273 + .long 512789562 + .long 3295790146 + .long 3583864087 + .long 1152986324 + .long 2337425402 + .long 3304798727 + .long 1854575809 + .long 3159867196 + .long 1765059742 + .long 3103980390 + .long 1056564255 + .long 3227329098 + .long 957604928 + .long 3170301297 + .long 1737111893 + .long 1086018364 + .long 3821479224 + .long 1030262355 + .long 1397067068 + .long 1113230428 + .long 1054232731 + .long 3267692171 + .long 1978243918 + .long 1127284645 + .long 3722409577 + .long 3281775634 + .long 1918858489 + .long 1141323813 + .long 3391721543 + .long 3295903979 + .long 2607178807 + .long 1155564765 + .long 3212344015 + .long 3310103974 + .long 3369531970 + .long 1169698149 + .long 335451402 + .long 3324302881 + .long 431247382 + .long 1183973580 + .long 3717434926 + .long 3338657222 + .long 1904523769 + .long 1198380992 + .long 8765522 + .long 3352646819 + .long 2089515505 + .long 1016996008 + .long 1260660699 + .long 961055715 + .long 2755288594 + .long 3230032374 + .long 651647436 + .long 3174928677 + .long 3079991920 + .long 1091533276 + .long 3443268597 + .long 1035583207 + .long 3925746702 + .long 1129598292 + .long 1087270140 + .long 3286788174 + .long 494941268 + .long 1149105228 + .long 1413067450 + .long 3306335280 + .long 2943951130 + .long 1168609830 + .long 1917094202 + .long 3325955583 + .long 3282582259 + .long 1188254230 + .long 205065768 + .long 3345548222 + .long 3975827413 + .long 1207978573 + .long 608024766 + .long 3365228477 + .long 514952666 + .long 1227617187 + .long 1683103546 + .long 3384985256 + .long 3324939681 + .long 1247457575 + .long 4078451799 + .long 3404527118 + .long 3100987862 + .long 1019853288 + .long 2384335067 + .long 962691388 + .long 2781784351 + .long 3233000439 + .long 1271614660 + .long 3176489869 + .long 626016822 + .long 1097348250 + .long 3842822006 + .long 1040353260 + .long 2239739676 + .long 1147303774 + .long 189136319 + .long 3307436007 + .long 2396687400 + .long 1172632530 + .long 1908223243 + .long 3332827221 + .long 2121588596 + .long 1198087089 + .long 3983173167 + .long 3358350016 + .long 2487337699 + .long 1223686165 + .long 3249965797 + .long 3383895554 + .long 3887284480 + .long 1249163916 + .long 138948171 + .long 3409430498 + .long 1463100005 + .long 1274763805 + .long 34738943 + .long 3435142323 + .long 2889101777 + .long 1300502035 + .long 2665757401 + .long 3460504734 + .long 987318156 + .long 3170486179 + .long 252831213 + .long 3113594951 + .long 4266405771 + .long 3236147062 + .long 52757777 + .long 3180182741 + .long 1823142101 + .long 1103640807 + .long 3806357955 + .long 1046313461 + .long 875359927 + .long 1166180665 + .long 1815208659 + .long 3329459206 + .long 1303129141 + .long 1197802172 + .long 4280462790 + .long 3361143469 + .long 626701262 + .long 1229550147 + .long 2303856491 + .long 3392960132 + .long 2759522360 + .long 1261440286 + .long 145515022 + .long 3424795397 + .long 2201193688 + .long 1293210725 + .long 2057332964 + .long 3456624552 + .long 3539517099 + .long 1325105434 + .long 1364231459 + .long 3488625947 + .long 3421843712 + .long 1357133388 + .long 200896422 + .long 3520281853 + .long 951171540 + .long 1026768452 + .long 3090769089 + .long 971487574 + .long 4234403032 + .long 3239454189 + .long 1460268972 + .long 3184474466 + .long 1346899734 + .long 1110354113 + .long 145456861 + .long 1052864217 + .long 2924701438 + .long 1186120500 + .long 3023147446 + .long 3352707860 + .long 1486479387 + .long 1224406765 + .long 1193997181 + .long 3391133412 + .long 2679629000 + .long 1262791412 + .long 2670450976 + .long 3429499462 + .long 1831795719 + .long 1301315682 + .long 3473315319 + .long 3467974125 + .long 2616420704 + .long 1339759302 + .long 1949536880 + .long 3506536322 + .long 2518396463 + .long 1378264708 + .long 142869669 + .long 3545106524 + .long 804820494 + .long 1416958345 + .long 2985125801 + .long 3583414179 + .long 2729716642 + .long 3174389784 + .long 1779261930 + .long 3115790859 + .long 2784196366 + .long 3242962813 + .long 2825451289 + .long 3185986297 + .long 2032114899 + .long 1117254632 + .long 1505002334 + .long 1059738942 + .long 3277658686 + .long 1207035096 + .long 498115686 + .long 3377105433 + .long 1711172328 + .long 1252267855 + .long 261417437 + .long 3422480089 + .long 1133240684 + .long 1297616851 + .long 1456800292 + .long 3467832532 + .long 2145797446 + .long 1343095967 + .long 2516644728 + .long 3513252141 + .long 725820954 + .long 1388528302 + .long 3986994814 + .long 3558807006 + .long 1955265405 + .long 1434003000 + .long 122646123 + .long 3604272992 + .long 1491943337 + .long 1479689885 + .long 1036478018 + .long 3649599135 + .long 523859850 + .long 3181400160 + .long 3846079041 + .long 3121433884 + .long 3639230521 + .long 3246590119 + .long 2638130497 + .long 3191278647 + .long 2154057324 + .long 1124508819 + .long 3236410824 + .long 1069265219 + .long 175871336 + .long 1228815189 + .long 2852522281 + .long 3402552205 + .long 1806384070 + .long 1281362740 + .long 423509286 + .long 3455121177 + .long 1160294737 + .long 1333930482 + .long 3543120866 + .long 3507725506 + .long 1036273485 + .long 1386572737 + .long 2942188771 + .long 3560408527 + .long 2777944578 + .long 1439300670 + .long 2738100981 + .long 3613185349 + .long 527942274 + .long 1492126097 + .long 1294011372 + .long 3665970729 + .long 3274455694 + .long 1544947882 + .long 1889769429 + .long 3718530789 + .long 136073262 + .long 1038797747 + .long 502134597 + .long 982165232 + .long 4211775762 + .long 3250359547 + .long 1347037926 + .long 3194312374 + .long 543769047 + .long 1132034342 + .long 1153606166 + .long 1076402838 + .long 3293430877 + .long 1251313085 + .long 540290119 + .long 3428873621 + .long 1766589444 + .long 1311355635 + .long 3887512491 + .long 3488899482 + .long 4113271272 + .long 1371561389 + .long 1216453194 + .long 3549072511 + .long 761821280 + .long 1431680659 + .long 3412859739 + .long 3609321978 + .long 1736216465 + .long 1491968482 + .long 1379671921 + .long 3669534956 + .long 871564305 + .long 1552192257 + .long 3755076681 + .long 3729888559 + .long 465380849 + .long 1612696812 + .long 1801521440 + .long 3789943511 + .long 926050541 + .long 3187761455 + .long 2363428923 + .long 3130505121 + .long 3212464044 + .long 3254203020 + .long 1767044225 + .long 3196691034 + .long 767402551 + .long 1139855610 + .long 3251527812 + .long 1084244526 + .long 2568107110 + .long 1274594461 + .long 3742439917 + .long 3456026525 + .long 2828194370 + .long 1342408213 + .long 1036563767 + .long 3523815749 + .long 138125806 + .long 1410361976 + .long 3332253618 + .long 3591742210 + .long 2265969007 + .long 1478279541 + .long 2044799860 + .long 3659742729 + .long 3159788672 + .long 1546250274 + .long 3040087996 + .long 3727787101 + .long 3566786041 + .long 1614266310 + .long 3445702274 + .long 3795877266 + .long 1647738551 + .long 1682455451 + .long 820553625 + .long 3863686600 + .long 2466985759 + .long 1045839115 + .long 2115301394 + .long 988248469 + .long 789067623 + .long 3258207291 + .long 2594430310 + .long 3200300918 + .long 682953991 + .long 1147781119 + .long 334308353 + .long 1092099647 + .long 666163226 + .long 1298545479 + .long 1527735017 + .long 3483905174 + .long 43015025 + .long 1374344588 + .long 1895454381 + .long 3559801465 + .long 3313337462 + .long 1450264132 + .long 938251762 + .long 3635670048 + .long 2344246077 + .long 1526147814 + .long 3329926839 + .long 3711639890 + .long 2189826955 + .long 1602221552 + .long 307911546 + .long 3787647166 + .long 4271816317 + .long 1678143122 + .long 3455709496 + .long 3863691777 + .long 509127304 + .long 1754367541 + .long 2246034954 + .long 3939578533 + .long 309332673 + .long 3194846686 + .long 4050026421 + .long 3139306075 + .long 1677069013 + .long 3262318455 + .long 407665306 + .long 3207206552 + .long 156965555 + .long 1155965375 + .long 2320115828 + .long 1098438062 + .long 2734085477 + .long 1323184128 + .long 3116943360 + .long 3512649235 + .long 2683227306 + .long 1407189808 + .long 2374702532 + .long 3596676496 + .long 1369556142 + .long 1491213979 + .long 3682738445 + .long 3680737093 + .long 208207094 + .long 1575312310 + .long 1070212038 + .long 3764875962 + .long 1332751409 + .long 1659495819 + .long 2960239586 + .long 3849108041 + .long 1328259946 + .long 1743778590 + .long 2152673987 + .long 3933352648 + .long 2459568424 + .long 1828057070 + .long 1053026559 + .long 4017368800 + .long 4272716315 + .long 3202139688 + .long 2347479448 + .long 3145750572 + .long 3880933726 + .long 3266512750 + .long 1526392126 + .long 3209922805 + .long 3647913141 + .long 1164353962 + .long 3796124307 + .long 1109331951 + .long 3682674239 + .long 1348349871 + .long 2807065817 + .long 3542009267 + .long 2123995152 + .long 1440744183 + .long 2606508288 + .long 3634425164 + .long 2187838465 + .long 1533156938 + .long 3218070138 + .long 3726874341 + .long 3194985081 + .long 1625643843 + .long 1282672122 + .long 3819401778 + .long 3085269549 + .long 1718215913 + .long 4171823927 + .long 3912022409 + .long 2286527342 + .long 1810887222 + .long 4263058773 + .long 4004655668 + .long 276869381 + .long 1903554397 + .long 2981609009 + .long 4097060567 + .long 2069415824 + .long 3207114478 + .long 3815897610 + .long 3150201997 + .long 1799063985 + .long 3270784757 + .long 609928762 + .long 3210962773 + .long 1398608221 + .long 1172933154 + .long 2839394180 + .long 1117275773 + .long 3966862031 + .long 1374007527 + .long 3094795956 + .long 3571940711 + .long 201952387 + .long 1474951107 + .long 1218377639 + .long 3672975792 + .long 4171572408 + .long 1576047750 + .long 2433360787 + .long 3774024473 + .long 2872117748 + .long 1677069826 + .long 1125668053 + .long 3875125411 + .long 1838424462 + .long 1778265418 + .long 1923560800 + .long 3976316898 + .long 2192672438 + .long 1879376253 + .long 2795231406 + .long 4077480577 + .long 3134618972 + .long 1980778833 + .long 2542206299 + .long 4178570441 + .long 858317418 + .long 1060903333 + .long 3120786235 + .long 1004681431 + .long 381774867 + .long 3275145580 + .long 1575769843 + .long 3219836452 + .long 3230239600 + .long 1181757061 + .long 1694309796 + .long 1126994475 + .long 2041459926 + .long 1400246667 + .long 1834143305 + .long 3602573072 + .long 3431862699 + .long 1509997896 + .long 674489055 + .long 3712297330 + .long 2942256815 + .long 1619727956 + .long 2430104127 + .long 3822158540 + .long 1181772448 + .long 1729549373 + .long 3316918483 + .long 3932027016 + .long 2290692518 + .long 1839450757 + .long 717742192 + .long 4041883887 + .long 2723262413 + .long 1949398481 + .long 726994291 + .long 4151823214 + .long 2316520017 + .long 2059476550 + .long 3506192554 + .long 4261590717 + .long 2615285756 + .long 3215685247 + .long 3456994573 + .long 3158988097 + .long 2576980377 + .long 3279526297 + .long 457772008 + .long 3222963352 + .long 1202590842 + .long 1190427361 + .long 3150210795 + .long 1135356295 + .long 2163381170 + .long 1426480799 + .long 2353315751 + .long 3633229223 + .long 3794716365 + .long 1544911246 + .long 3598226895 + .long 3751709375 + .long 3778743776 + .long 1663434111 + .long 1038551128 + .long 3870293084 + .long 2177305923 + .long 1782019278 + .long 316150431 + .long 3988869748 + .long 3666573938 + .long 1900657340 + .long 1225202613 + .long 4107481261 + .long 4106613245 + .long 2019377222 + .long 3685171119 + .long 4226128894 + .long 3001847201 + .long 2137308914 + .long 4294967295 + .long 4293918719 + .type _dbA,@object + .size _dbA,8032 + .space 672, 0x00 # pad + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_OFW_BOUND: + .word 60404 + .word 65533 + .word 19595 + .word 47317 + .word 32753 + .word 0 + .type _OFW_BOUND,@object + .size _OFW_BOUND,12 + .align 2 +_TWO5600: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 21983 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 10783 + .word 0 + .type _TWO5600,@object + .size _TWO5600,24 + .data + .hidden __libm_logl_k80 + .hidden fesetround + .hidden fegetround + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_atan2l_k80.S b/external/sgx_libm/ia32/libm_atan2l_k80.S new file mode 100644 index 0000000000..525d374d7f --- /dev/null +++ b/external/sgx_libm/ia32/libm_atan2l_k80.S @@ -0,0 +1,1634 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_atan2l_k80.c" + .text +..TXTST0: +# -- Begin __libm_atan2l_k80 + .text + .align 16,0x90 + .hidden __libm_atan2l_k80 + .globl __libm_atan2l_k80 +__libm_atan2l_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + movl 16(%ebp), %edx + movl 12(%ebp), %ecx + movl %gs:20, %eax + movzbl 9(%edx), %esi + xorl %esp, %eax + andl $128, %esi + movl %eax, 172(%esp) + shrl $7, %esi + movl %esi, 44(%esp) + movzbl 9(%ecx), %esi + movzwl 8(%ecx), %eax + andl $128, %esi + andl $32767, %eax + movzwl 8(%edx), %edi + shrl $7, %esi + andl $32767, %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $32767, %eax + je ..B1.110 +..B1.2: + cmpl $32767, %edi + je ..B1.97 +..B1.3: + movl 4(%ecx), %eax + testl %eax, %eax + jne ..B1.5 +..B1.4: + cmpl $0, (%ecx) + je ..B1.8 +..B1.5: + cmpl $0, 4(%edx) + jne ..B1.20 +..B1.6: + cmpl $0, (%edx) + jne ..B1.20 +..B1.7: + testl %eax, %eax + jne ..B1.17 +..B1.116: + cmpl $0, (%ecx) +..B1.8: + jne ..B1.17 +..B1.9: + cmpl $0, 4(%edx) + jne ..B1.14 +..B1.10: + cmpl $0, (%edx) + jne ..B1.14 +..B1.11: + movl 8(%ebp), %eax + cmpl $0, 44(%esp) + movl $0, 24(%eax) + je ..B1.13 +..B1.12: + movl 8(%ebp), %ecx + lea (,%esi,8), %eax + lea (%eax,%esi,4), %edx + fldt _pi_00l@GOTOFF(%edx,%ebx) + fstpt (%ecx) + fldt _pilo_00l@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%edx,%ebx) + fsubrp %st, %st(1) + fstpt 12(%ecx) + jmp ..B1.18 +..B1.13: + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fldz + fmull ones@GOTOFF(%ebx,%esi,8) + movl 8(%ebp), %eax + fstpt (%eax) + fstpt 12(%eax) + jmp ..B1.18 +..B1.14: + movl 8(%ebp), %eax + cmpl $0, 44(%esp) + movl $0, 24(%eax) + je ..B1.16 +..B1.15: + movl 8(%ebp), %ecx + lea (,%esi,8), %eax + lea (%eax,%esi,4), %edx + fldt _pi_00l@GOTOFF(%edx,%ebx) + fstpt (%ecx) + fldt _pilo_00l@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%edx,%ebx) + fsubrp %st, %st(1) + fstpt 12(%ecx) + jmp ..B1.18 +..B1.16: + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fldz + fmull ones@GOTOFF(%ebx,%esi,8) + movl 8(%ebp), %eax + fstpt (%eax) + fstpt 12(%eax) + jmp ..B1.18 +..B1.17: + movl 8(%ebp), %edx + lea (,%esi,8), %eax + lea (%eax,%esi,4), %esi + fldt _pi_02l@GOTOFF(%esi,%ebx) + movl $0, 24(%edx) + fstpt (%edx) + fldt _pilo_02l@GOTOFF(%esi,%ebx) + fldt _small_value_80@GOTOFF(%esi,%ebx) + fsubrp %st, %st(1) + fstpt 12(%edx) +..B1.18: + movl 172(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.89 +..B1.19: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.20: + movl (%edx), %edi + lea 116(%esp), %eax + movl %edi, (%eax) + movl 4(%edx), %edi + movl %edi, 4(%eax) + movl 8(%edx), %edi + movl %edi, 8(%eax) + movl 12(%edx), %edi + movl %edi, 12(%eax) + movl 16(%edx), %edi + movl %edi, 16(%eax) + movl 20(%edx), %edi + movl 24(%edx), %edx + movl %edi, 20(%eax) + movl %edx, 24(%eax) + movl (%ecx), %edx + movl 4(%ecx), %edi + movl %edx, 28(%eax) + movl %edi, 32(%eax) + movl 8(%ecx), %edx + movl 12(%ecx), %edi + movl %edx, 36(%eax) + movl %edi, 40(%eax) + movl 16(%ecx), %edx + movl 20(%ecx), %edi + movl 24(%ecx), %ecx + movl %edx, 44(%eax) + movl %edi, 48(%eax) + movl %ecx, 52(%eax) + addl $4, %esp + pushl %eax + call __libm_normalizel_k80 +..B1.21: + addl $4, %esp + lea 140(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.22: + fldt 116(%esp) + fld %st(0) + fldt 128(%esp) + movl 44(%esp), %eax + fadd %st, %st(1) + movl 140(%esp), %ecx + fxch %st(1) + fsub %st, %st(2) + movl 168(%esp), %edx + cmpl %edx, %ecx + fxch %st(2) + fsubrp %st, %st(1) + fldt 144(%esp) + fld %st(0) + fldt 156(%esp) + fadd %st, %st(1) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fldl ones@GOTOFF(%ebx,%eax,8) + fmul %st, %st(4) + fmulp %st, %st(3) + fldl ones@GOTOFF(%ebx,%esi,8) + fmul %st, %st(2) + fmul %st, %st(1) + jg ..B1.25 +..B1.23: + jne ..B1.75 +..B1.24: + fxch %st(4) + fcom %st(2) + fnstsw %ax + sahf + fxch %st(4) + jbe ..B1.75 +..B1.25: + lea 12(%edx), %eax + cmpl %eax, %ecx + jle ..B1.70 +..B1.26: + lea 75(%edx), %eax + cmpl %eax, %ecx + jle ..B1.43 +..B1.27: + cmpl $0, 44(%esp) + je ..B1.29 +..B1.28: + fstp %st(0) + fstp %st(2) + fstp %st(1) + fstp %st(0) + fstp %st(0) + movl 8(%ebp), %edx + lea (,%esi,8), %eax + lea (%eax,%esi,4), %esi + fldt _pi_00l@GOTOFF(%esi,%ebx) + movl $0, 24(%edx) + fstpt (%edx) + fldt _pilo_00l@GOTOFF(%esi,%ebx) + fldt _small_value_80@GOTOFF(%esi,%ebx) + fsubrp %st, %st(1) + fstpt 12(%edx) + jmp ..B1.41 +..B1.29: + fxch %st(2) + fstpt 144(%esp) + fldt 144(%esp) + movzwl 152(%esp), %eax + andl $32767, %eax + fxch %st(4) + fstpt 116(%esp) + fldt 116(%esp) + cmpl $8383, %eax + jge ..B1.31 +..B1.30: + fstp %st(4) + fstp %st(3) + fxch %st(2) + fstpt 156(%esp) + fstpt 128(%esp) + jmp ..B1.37 +..B1.31: + cmpl $24383, %eax + jg ..B1.30 +..B1.33: + movzwl 124(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.30 +..B1.35: + cmpl $24383, %eax + fxch %st(3) + fxch %st(2) + fxch %st(4) + fxch %st(1) + jle ..B1.40 +..B1.36: + fstp %st(1) + fstp %st(2) + fxch %st(1) + fstpt 156(%esp) + fstpt 128(%esp) +..B1.37: + addl $4, %esp + lea 140(%esp), %eax + pushl %eax + fstpt -40(%eax) + call __libm_normalizel_k80 +..B1.38: + fldt 104(%esp) + addl $4, %esp + lea 112(%esp), %eax + pushl %eax + fstpt -12(%eax) + call __libm_normalizel_k80 +..B1.39: + fldt 104(%esp) + fldt 116(%esp) + fldt 128(%esp) + fldt 144(%esp) + fldt 156(%esp) + movl 140(%esp), %ecx + movl 168(%esp), %edx +..B1.40: + fld %st(1) + subl %ecx, %edx + fdiv %st(4), %st + fstpt 48(%esp) + fldt 48(%esp) + fxch %st(5) + fstpt 104(%esp) + fxch %st(3) + fstpt 32(%esp) + fldt 32(%esp) + fldt .L_2il0floatpacket.16@GOTOFF(%ebx) + fld %st(0) + fmul %st(6), %st + fld %st(0) + movl 8(%ebp), %eax + fsubr %st(7), %st + movl %edx, 24(%eax) + faddp %st, %st(1) + fld %st(0) + fsubrp %st, %st(7) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fsub %st(1), %st + faddp %st, %st(1) + fsubr %st, %st(2) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(7), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(6) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(5) + fsubrp %st, %st(1) + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 48(%esp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(0) + fldt 32(%esp) + fdivrp %st, %st(3) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 104(%esp) + fmul %st, %st(1) + fxch %st(1) + fstpt (%eax) + fmulp %st, %st(1) + fstpt 12(%eax) + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + fldt _small_value_80@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt 16(%esp) +..B1.41: + movl 172(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.89 +..B1.42: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.43: + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + subl %ecx, %edx + movzwl 8+.L_2il0floatpacket.12@GOTOFF(%ebx), %eax + addl $16383, %edx + movl %eax, 28(%esp) + andl $-32768, %eax + andl $32767, %edx + fstpt 88(%esp) + fldt 88(%esp) + orl %edx, %eax + movw %ax, 96(%esp) + xorl %edx, %edx + fxch %st(5) + fstpt 116(%esp) + fldt 116(%esp) + xorl %eax, %eax + fxch %st(5) + fstpt 64(%esp) + xorl %ecx, %ecx + fldt 88(%esp) + fmul %st, %st(3) + fxch %st(3) + fstpt 144(%esp) + fldt 144(%esp) + movzwl 152(%esp), %esi + andl $32767, %esi + fxch %st(3) + fmulp %st, %st(2) + cmpl $0, 44(%esp) + je ..B1.57 +..B1.44: + cmpl $8383, %esi + jge ..B1.46 +..B1.45: + fstp %st(2) + fstp %st(3) + movl %eax, 168(%esp) + movl %eax, 140(%esp) + fxch %st(2) + fstpt 156(%esp) + fstpt 128(%esp) + jmp ..B1.52 +..B1.46: + cmpl $24383, %esi + jg ..B1.45 +..B1.48: + movzwl 124(%esp), %esi + andl $32767, %esi + cmpl $8383, %esi + jl ..B1.45 +..B1.50: + cmpl $24383, %esi + fxch %st(4) + fxch %st(3) + fxch %st(2) + fxch %st(1) + jle ..B1.55 +..B1.51: + fstp %st(1) + fstp %st(2) + movl %eax, 168(%esp) + movl %eax, 140(%esp) + fxch %st(1) + fstpt 156(%esp) + fstpt 128(%esp) +..B1.52: + addl $4, %esp + lea 140(%esp), %eax + pushl %eax + fstpt -40(%eax) + call __libm_normalizel_k80 +..B1.53: + fldt 104(%esp) + addl $4, %esp + lea 112(%esp), %eax + pushl %eax + fstpt -12(%eax) + call __libm_normalizel_k80 +..B1.54: + fldt 104(%esp) + fldt 116(%esp) + fldt 128(%esp) + fldt 144(%esp) + fldt 156(%esp) + movl 140(%esp), %edx + movl 168(%esp), %ecx +..B1.55: + fld %st(1) + subl %edx, %ecx + fdiv %st(4), %st + addl $16383, %ecx + fstpt 48(%esp) + fldt 48(%esp) + andl $32767, %ecx + fxch %st(5) + fstpt 104(%esp) + fxch %st(3) + fstpt 32(%esp) + fldt 32(%esp) + fldt .L_2il0floatpacket.16@GOTOFF(%ebx) + fld %st(0) + fmul %st(6), %st + fld %st(0) + movl 28(%esp), %eax + fsubr %st(7), %st + andl $-32768, %eax + faddp %st, %st(1) + fld %st(0) + orl %ecx, %eax + movl 8(%ebp), %edx + fsubrp %st, %st(7) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fsub %st(1), %st + faddp %st, %st(1) + fsubr %st, %st(2) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(7), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(6) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(5) + fsubrp %st, %st(1) + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 48(%esp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fldt 32(%esp) + fdivrp %st, %st(2) + faddp %st, %st(1) + fldt 64(%esp) + fstpt 88(%esp) + fldt 36+_P@GOTOFF(%ebx) + fldt 12+_P@GOTOFF(%ebx) + fldt 24+_P@GOTOFF(%ebx) + fldt _P@GOTOFF(%ebx) + movw %ax, 96(%esp) + fldt 88(%esp) + fmulp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + fadd %st(1), %st + fxch %st(1) + fstpt 88(%esp) + fldl 8192+__libm_atanl_table_128@GOTOFF(%ebx) + fldl 8200+__libm_atanl_table_128@GOTOFF(%ebx) + movl $0, 24(%edx) + fsubp %st, %st(2) + fldt 104(%esp) + fmul %st, %st(1) + fld %st(1) + fxch %st(1) + fmulp %st, %st(3) + fadd %st(2), %st + fstpt (%edx) + fldt (%edx) + fsubp %st, %st(1) + fsubrp %st, %st(1) + fstpt 12(%edx) + movl 172(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.89 +..B1.56: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.57: + cmpl $8383, %esi + jge ..B1.59 +..B1.58: + fstp %st(2) + fstp %st(3) + movl %eax, 168(%esp) + movl %eax, 140(%esp) + fxch %st(2) + fstpt 156(%esp) + fstpt 128(%esp) + jmp ..B1.65 +..B1.59: + cmpl $24383, %esi + jg ..B1.58 +..B1.61: + movzwl 124(%esp), %esi + andl $32767, %esi + cmpl $8383, %esi + jl ..B1.58 +..B1.63: + cmpl $24383, %esi + fxch %st(4) + fxch %st(3) + fxch %st(2) + fxch %st(1) + jle ..B1.68 +..B1.64: + fstp %st(1) + fstp %st(2) + movl %eax, 168(%esp) + movl %eax, 140(%esp) + fxch %st(1) + fstpt 156(%esp) + fstpt 128(%esp) +..B1.65: + addl $4, %esp + lea 140(%esp), %eax + pushl %eax + fstpt -40(%eax) + call __libm_normalizel_k80 +..B1.66: + fldt 104(%esp) + addl $4, %esp + lea 112(%esp), %eax + pushl %eax + fstpt -12(%eax) + call __libm_normalizel_k80 +..B1.67: + fldt 104(%esp) + fldt 116(%esp) + fldt 128(%esp) + fldt 144(%esp) + fldt 156(%esp) + movl 140(%esp), %edx + movl 168(%esp), %ecx +..B1.68: + fld %st(1) + subl %edx, %ecx + fdiv %st(4), %st + addl $16383, %ecx + fstpt 48(%esp) + fldt 48(%esp) + andl $32767, %ecx + fxch %st(5) + fstpt 104(%esp) + fxch %st(3) + fstpt 32(%esp) + fldt 32(%esp) + fldt .L_2il0floatpacket.16@GOTOFF(%ebx) + fld %st(0) + fmul %st(6), %st + fld %st(0) + movl 28(%esp), %eax + fsubr %st(7), %st + andl $-32768, %eax + faddp %st, %st(1) + fld %st(0) + orl %ecx, %eax + movl 8(%ebp), %edx + fsubrp %st, %st(7) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + movl $0, 24(%edx) + fsub %st(1), %st + faddp %st, %st(1) + fsubr %st, %st(2) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(7), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(6) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(5) + fsubrp %st, %st(1) + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 48(%esp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fldt 32(%esp) + fdivrp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 64(%esp) + fstpt 88(%esp) + fldt 36+_P@GOTOFF(%ebx) + fldt 12+_P@GOTOFF(%ebx) + fldt _P@GOTOFF(%ebx) + movw %ax, 96(%esp) + fldt 88(%esp) + fmul %st, %st(4) + fmul %st, %st(4) + fld %st(4) + fmul %st(5), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(1) + fmul %st, %st(6) + fmulp %st, %st(6) + fxch %st(4) + fstpt 88(%esp) + fldt 88(%esp) + fldt 24+_P@GOTOFF(%ebx) + fmulp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(2) + fldt 104(%esp) + fmul %st, %st(1) + fxch %st(1) + fstpt (%edx) + fmulp %st, %st(1) + fstpt 12(%edx) + movl 172(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.89 +..B1.69: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.70: + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + subl %ecx, %edx + addl $16383, %edx + movzwl 8+.L_2il0floatpacket.12@GOTOFF(%ebx), %eax + andl $32767, %edx + andl $-32768, %eax + fstpt 88(%esp) + orl %edx, %eax + movw %ax, 96(%esp) + fld %st(4) + fxch %st(1) + fstpt 104(%esp) + xorl %edx, %edx + fxch %st(4) + fstpt 116(%esp) + fldt 116(%esp) + fxch %st(3) + fstpt 128(%esp) + fldt 128(%esp) + fldt 88(%esp) + fmul %st, %st(3) + fxch %st(3) + fstpt 144(%esp) + fldt 144(%esp) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpt 156(%esp) + fldt 156(%esp) + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + fmul %st(3), %st + fdiv %st(4), %st + fldt .L_2il0floatpacket.14@GOTOFF(%ebx) + movl %edx, 140(%esp) + movl %edx, 168(%esp) + fxch %st(1) + faddl _TWO_63H@GOTOFF(%ebx) + fstpt 76(%esp) + fldt 76(%esp) + fldl _TWO_48H@GOTOFF(%ebx) + movl 76(%esp), %eax + shll $4, %eax + fxch %st(1) + fsubl _TWO_63H@GOTOFF(%ebx) + fmulp %st, %st(2) + fld %st(5) + fmul %st(1), %st + cmpl $0, 44(%esp) + fadd %st, %st(7) + fxch %st(7) + fstpt 76(%esp) + fldt 76(%esp) + fsubp %st, %st(7) + fxch %st(5) + fsub %st(6), %st + faddp %st, %st(3) + fld %st(4) + fmul %st(4), %st + fld %st(0) + fadd %st(5), %st + fstpt 76(%esp) + fldt 76(%esp) + fsubp %st, %st(1) + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fld %st(3) + fmul %st(1), %st + fadd %st(3), %st + fld %st(2) + fmul %st(2), %st + fadd %st(7), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + fsubrp %st, %st(5) + fxch %st(3) + fmulp %st, %st(6) + fxch %st(5) + fsubrp %st, %st(1) + fld %st(4) + fadd %st(2), %st + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + fdivp %st, %st(1) + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fstpt 76(%esp) + fxch %st(4) + fstpt 88(%esp) + fldt 88(%esp) + fxch %st(2) + fmul %st(4), %st + fldt 76(%esp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(5), %st + fld %st(6) + fmul %st(1), %st + faddp %st, %st(2) + fxch %st(3) + fmul %st, %st(6) + fldt .L_2il0floatpacket.15@GOTOFF(%ebx) + faddp %st, %st(7) + fxch %st(1) + faddp %st, %st(6) + fxch %st(5) + fmulp %st, %st(4) + fxch %st(3) + fsubrp %st, %st(1) + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fld %st(1) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(2) + fmul %st(3), %st + fxch %st(2) + fadd %st(3), %st + fld %st(1) + fmul %st(1), %st + faddp %st, %st(3) + fld %st(3) + fmul %st(4), %st + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fldt 36+_P@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%ebx) + fmulp %st, %st(2) + fldt _P@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 104(%esp) + je ..B1.72 +..B1.71: + negl %eax + fld %st(2) + fldl 8192+__libm_atanl_table_128@GOTOFF(%ebx,%eax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fxch %st(3) + fstpt 88(%esp) + fldt 88(%esp) + fldl 8200+__libm_atanl_table_128@GOTOFF(%ebx,%eax) + fsubp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.73 +..B1.72: + fldl __libm_atanl_table_128@GOTOFF(%eax,%ebx) + fld %st(3) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) + fstpt 88(%esp) + fldt 88(%esp) + fldl 8+__libm_atanl_table_128@GOTOFF(%eax,%ebx) + faddp %st, %st(3) + faddp %st, %st(2) +..B1.73: + fmul %st, %st(2) + fld %st(2) + fxch %st(2) + fmulp %st, %st(1) + movl 8(%ebp), %eax + fadd %st, %st(1) + movl $0, 24(%eax) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fstpt 12(%eax) + fstpt (%eax) + movl 172(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.89 +..B1.74: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.75: + lea 12(%ecx), %eax + cmpl %eax, %edx + jle ..B1.84 +..B1.76: + fstp %st(3) + fstp %st(0) + lea 75(%ecx), %eax + cmpl %eax, %edx + jg ..B1.82 +..B1.77: + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + subl %ecx, %edx + addl $16383, %edx + movzwl 8+.L_2il0floatpacket.12@GOTOFF(%ebx), %eax + andl $32767, %edx + andl $-32768, %eax + fstpt 88(%esp) + orl %edx, %eax + fldt 36+_P@GOTOFF(%ebx) + fldt _P@GOTOFF(%ebx) + movw %ax, 96(%esp) + fldt 88(%esp) + fmulp %st, %st(3) + fxch %st(2) + fdivrp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fldt 12+_P@GOTOFF(%ebx) + movl 8(%ebp), %edx + faddp %st, %st(3) + fmul %st, %st(2) + fldt 24+_P@GOTOFF(%ebx) + fmulp %st, %st(1) + cmpl $0, 44(%esp) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(2) + fldl 4096+__libm_atanl_table_128@GOTOFF(%ebx) + fmul %st(1), %st + fldl 4104+__libm_atanl_table_128@GOTOFF(%ebx) + movl $0, 24(%edx) + je ..B1.79 +..B1.78: + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + jmp ..B1.80 +..B1.79: + fsubp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) +..B1.80: + fld %st(0) + movl 8(%ebp), %eax + fadd %st(2), %st + fstpt (%eax) + fldt (%eax) + fsubp %st, %st(1) + fsubrp %st, %st(1) + fstpt 12(%eax) + movl 172(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.89 +..B1.81: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.82: + fstp %st(1) + fstp %st(0) + fstp %st(0) + movl 8(%ebp), %edx + lea (,%esi,8), %eax + lea (%eax,%esi,4), %esi + fldt _pi_02l@GOTOFF(%esi,%ebx) + movl $0, 24(%edx) + fstpt (%edx) + fldt _pilo_02l@GOTOFF(%esi,%ebx) + fldt _small_value_80@GOTOFF(%esi,%ebx) + fsubrp %st, %st(1) + fstpt 12(%edx) + movl 172(%esp), %ecx + xorl %esp, %ecx + cmpl %gs:20, %ecx + jne ..B1.89 +..B1.83: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.84: + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + subl %ecx, %edx + addl $16383, %edx + movzwl 8+.L_2il0floatpacket.12@GOTOFF(%ebx), %eax + andl $32767, %edx + andl $-32768, %eax + fstpt 88(%esp) + orl %edx, %eax + movw %ax, 96(%esp) + fld %st(4) + fxch %st(1) + fstpt 104(%esp) + xorl %edx, %edx + fxch %st(4) + fstpt 116(%esp) + fldt 116(%esp) + fxch %st(3) + fstpt 128(%esp) + fldt 128(%esp) + fldt 88(%esp) + fmul %st, %st(3) + fxch %st(3) + fstpt 144(%esp) + fldt 144(%esp) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpt 156(%esp) + fldt 156(%esp) + fldt .L_2il0floatpacket.13@GOTOFF(%ebx) + fmul %st(4), %st + fdiv %st(3), %st + fldt .L_2il0floatpacket.14@GOTOFF(%ebx) + movl %edx, 140(%esp) + movl %edx, 168(%esp) + fxch %st(1) + faddl _TWO_63H@GOTOFF(%ebx) + fstpt 76(%esp) + fld %st(4) + fldt 76(%esp) + movl 76(%esp), %eax + shll $4, %eax + fsubl _TWO_63H@GOTOFF(%ebx) + fmulp %st, %st(2) + fldl _TWO_48H@GOTOFF(%ebx) + fmul %st, %st(7) + cmpl $0, 44(%esp) + fxch %st(1) + fadd %st(7), %st + fstpt 76(%esp) + fldt 76(%esp) + fsubp %st, %st(7) + fxch %st(5) + fsub %st(6), %st + faddp %st, %st(3) + fld %st(4) + fmul %st(4), %st + fld %st(0) + fadd %st(5), %st + fstpt 76(%esp) + fldt 76(%esp) + fsubp %st, %st(1) + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fld %st(5) + fmul %st(1), %st + fadd %st(2), %st + fstpt 32(%esp) + fld %st(2) + fmul %st(1), %st + fadd %st(4), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(6) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + fldt 32(%esp) + fadd %st(2), %st + fldt 32(%esp) + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + fdivp %st, %st(2) + fxch %st(1) + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fstpt 76(%esp) + fxch %st(4) + fstpt 88(%esp) + fldt 88(%esp) + fxch %st(3) + fmul %st(4), %st + fldt 76(%esp) + fsubp %st, %st(4) + fld %st(3) + fsubr %st(5), %st + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 32(%esp) + fmul %st(4), %st + fldt .L_2il0floatpacket.15@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fsubp %st, %st(3) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fadd %st(4), %st + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fld %st(2) + fxch %st(4) + fmulp %st, %st(2) + fmul %st(1), %st + fld %st(2) + fadd %st(2), %st + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%ebx) + fmulp %st, %st(2) + fldt _P@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 104(%esp) + je ..B1.86 +..B1.85: + fldl 4096+__libm_atanl_table_128@GOTOFF(%ebx,%eax) + fld %st(3) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) + fstpt 88(%esp) + fldt 88(%esp) + fldl 4104+__libm_atanl_table_128@GOTOFF(%ebx,%eax) + faddp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.87 +..B1.86: + negl %eax + fld %st(2) + fldl 4096+__libm_atanl_table_128@GOTOFF(%ebx,%eax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fxch %st(3) + fstpt 88(%esp) + fldt 88(%esp) + fldl 4104+__libm_atanl_table_128@GOTOFF(%ebx,%eax) + fsubp %st, %st(3) + faddp %st, %st(2) +..B1.87: + fmul %st, %st(2) + fld %st(2) + fxch %st(2) + fmulp %st, %st(1) + movl 8(%ebp), %eax + fadd %st, %st(1) + movl $0, 24(%eax) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fstpt 12(%eax) + fstpt (%eax) + movl 172(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.89 +..B1.88: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.89: + call __stack_chk_fail@PLT +..B1.97: + cmpl $-2147483648, 4(%edx) + jne ..B1.99 +..B1.98: + cmpl $0, (%edx) + je ..B1.100 +..B1.99: + fldt (%edx) + fldt (%ecx) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + movl 8(%ebp), %eax + movl $0, 24(%eax) + fstpt 12(%eax) + fstpt (%eax) + jmp ..B1.104 +..B1.100: + movl 8(%ebp), %edx + cmpl $32767, %eax + movl $0, 24(%edx) + je ..B1.107 +..B1.101: + cmpl $0, 44(%esp) + je ..B1.103 +..B1.102: + movl 8(%ebp), %ecx + lea (,%esi,8), %eax + lea (%eax,%esi,4), %edx + fldt _pi_00l@GOTOFF(%edx,%ebx) + fstpt (%ecx) + fldt _pilo_00l@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%edx,%ebx) + fsubrp %st, %st(1) + fstpt 12(%ecx) + jmp ..B1.104 +..B1.103: + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fldz + fmull ones@GOTOFF(%ebx,%esi,8) + movl 8(%ebp), %eax + fstpt (%eax) + fstpt 12(%eax) +..B1.104: + movl 172(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.89 + jmp ..B1.19 +..B1.107: + cmpl $0, 44(%esp) + lea (,%esi,8), %eax + lea (%eax,%esi,4), %edx + je ..B1.109 +..B1.108: + fldt _pi_34l@GOTOFF(%edx,%ebx) + fldt _pilo_34l@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%edx,%ebx) + movl 8(%ebp), %eax + fsubrp %st, %st(1) + fstpt 12(%eax) + fstpt (%eax) + jmp ..B1.104 +..B1.109: + fldt _pi_04l@GOTOFF(%edx,%ebx) + fldt _pilo_04l@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%edx,%ebx) + movl 8(%ebp), %eax + fsubrp %st, %st(1) + fstpt 12(%eax) + fstpt (%eax) + jmp ..B1.104 +..B1.110: + cmpl $-2147483648, 4(%ecx) + jne ..B1.99 +..B1.111: + cmpl $0, (%ecx) + jne ..B1.99 +..B1.112: + cmpl $32767, %edi + je ..B1.97 +..B1.113: + movl 8(%ebp), %edx + lea (,%esi,8), %eax + lea (%eax,%esi,4), %esi + fldt _pi_02l@GOTOFF(%esi,%ebx) + movl $0, 24(%edx) + fstpt (%edx) + fldt _pilo_02l@GOTOFF(%esi,%ebx) + fldt _small_value_80@GOTOFF(%esi,%ebx) + fsubrp %st, %st(1) + fstpt 12(%edx) + jmp ..B1.104 + .align 16,0x90 + .type __libm_atan2l_k80,@function + .size __libm_atan2l_k80,.-__libm_atan2l_k80 + .data +# -- End __libm_atan2l_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.12: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.14: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.15: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.16: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 2 +_pi_00l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49152 + .word 0 + .type _pi_00l,@object + .size _pi_00l,24 + .align 2 +_pilo_00l: + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49086 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 16318 + .word 0 + .type _pilo_00l,@object + .size _pilo_00l,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_pi_02l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .type _pi_02l,@object + .size _pi_02l,24 + .align 2 +_pilo_02l: + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49085 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 16317 + .word 0 + .type _pilo_02l,@object + .size _pilo_02l,24 + .align 2 +_P: + .word 43664 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 43235 + .word 52379 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 59507 + .word 38278 + .word 9340 + .word 37449 + .word 49148 + .word 0 + .word 9132 + .word 55602 + .word 8665 + .word 58245 + .word 16379 + .word 0 + .type _P,@object + .size _P,48 + .align 2 +_pi_34l: + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 16384 + .word 0 + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 49152 + .word 0 + .type _pi_34l,@object + .size _pi_34l,24 + .align 2 +_pilo_34l: + .word 54470 + .word 48821 + .word 27694 + .word 55510 + .word 49087 + .word 0 + .word 54470 + .word 48821 + .word 27694 + .word 55510 + .word 16319 + .word 0 + .type _pilo_34l,@object + .size _pilo_34l,24 + .align 2 +_pi_04l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16382 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49150 + .word 0 + .type _pi_04l,@object + .size _pi_04l,24 + .align 2 +_pilo_04l: + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49084 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 16316 + .word 0 + .type _pilo_04l,@object + .size _pilo_04l,24 + .data + .hidden __libm_atanl_table_128 + .hidden __libm_normalizel_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_coshl_k80.S b/external/sgx_libm/ia32/libm_coshl_k80.S new file mode 100644 index 0000000000..88642ecaeb --- /dev/null +++ b/external/sgx_libm/ia32/libm_coshl_k80.S @@ -0,0 +1,724 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_coshl_k80.c" + .text +..TXTST0: +# -- Begin __libm_coshl_k80 + .text + .align 16,0x90 + .hidden __libm_coshl_k80 + .globl __libm_coshl_k80 +__libm_coshl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $68, %esp + movzwl 16(%ebp), %eax + andl $32767, %eax + movl 20(%ebp), %ebx + cmpl $16405, %eax + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + jge ..B1.17 +..B1.2: + cmpl $16382, %eax + jge ..B1.13 +..B1.3: + cmpl $16378, %eax + jge ..B1.11 +..B1.4: + fldt .L_2il0floatpacket.1@GOTOFF(%esi) + cmpl $16372, %eax + jge ..B1.10 +..B1.5: + cmpl $16365, %eax + jge ..B1.9 +..B1.6: + fstpt (%ebx) + cmpl $16308, %eax + jge ..B1.8 +..B1.7: + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + fstpt 12(%ebx) + fldt 12(%ebx) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.8: + fldt 8(%ebp) + fldt _Q3@GOTOFF(%esi) + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + fldt 8(%ebp) + fmul %st(0), %st + fxch %st(1) + fstpt (%ebx) + fldt 12+_Q2@GOTOFF(%esi) + fmul %st(1), %st + fldt _Q2@GOTOFF(%esi) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.10: + fldt 8(%ebp) + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt (%ebx) + fldt 36+_Q1@GOTOFF(%esi) + fmul %st(2), %st + fldt 12+_Q1@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_Q1@GOTOFF(%esi) + fmulp %st, %st(3) + fldt _Q1@GOTOFF(%esi) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + fldt 8(%ebp) + fld %st(0) + fld %st(1) + fld %st(2) + fmul %st(3), %st + fld %st(0) + fmul %st(1), %st + fldl _TWO_48H@GOTOFF(%esi) + fadd %st, %st(4) + fxch %st(4) + fstpt 56(%esp) + fldt 56(%esp) + fsub %st(4), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(1) + fmul %st(4), %st + fxch %st(6) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(5) + fxch %st(2) + fmul %st(0), %st + fldt 72+_Q@GOTOFF(%esi) + fmul %st(3), %st + fldt 48+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_Q@GOTOFF(%esi) + fmul %st(4), %st + fldt 60+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(4), %st + fldt 36+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmulp %st, %st(4) + fld %st(5) + fldt 12+_Q@GOTOFF(%esi) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fldt 108+_Q@GOTOFF(%esi) + fld %st(0) + fmul %st(7), %st + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmul %st, %st(2) + fldt 96+_Q@GOTOFF(%esi) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fmulp %st, %st(4) + fld %st(1) + fadd %st(4), %st + fadd %st(3), %st + fstpt 56(%esp) + fldt 56(%esp) + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.1@GOTOFF(%esi) + faddp %st, %st(1) + fstpt (%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) +..B1.12: + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%esi) + fldt _KLN2@GOTOFF(%esi) + fldt _LN2K@GOTOFF(%esi) + fldt 12+_LN2K@GOTOFF(%esi) + fldl _TWO_32@GOTOFF(%esi) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fxch %st(5) + fmull ones@GOTOFF(%esi,%eax,8) + fmul %st, %st(3) + fxch %st(3) + fadd %st(4), %st + fstpt 56(%esp) + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 56(%esp) + movl 56(%esp), %eax + fsubp %st, %st(4) + fxch %st(1) + fmul %st(3), %st + movsbl %al, %ecx + fsubrp %st, %st(1) + fld %st(0) + subl %ecx, %eax + fxch %st(2) + fmulp %st, %st(3) + movzwl 16(%ebp), %edx + fxch %st(1) + fsub %st(2), %st + fldl _TWO_32P@GOTOFF(%esi) + andl $32767, %edx + fmul %st(1), %st + fxch %st(4) + fmulp %st, %st(1) + sarl $8, %eax + fsubrp %st, %st(3) + fld %st(2) + cmpl $16387, %edx + fxch %st(1) + fsub %st(3), %st + fsubp %st, %st(2) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%esi) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(1), %st + fldt _P@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%esi) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%esi) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + jle ..B1.15 +..B1.14: + shll $4, %ecx + decl %eax + movl %eax, 48(%esp) + faddp %st, %st(1) + fildl 48(%esp) + fldl 2056+__libm_expl_table_256@GOTOFF(%esi,%ecx) + fldl 2048+__libm_expl_table_256@GOTOFF(%esi,%ecx) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(5), %st + fmul %st(2), %st + movzbl 17(%ebp), %eax + faddp %st, %st(4) + fmul %st, %st(4) + fld %st(0) + andl $128, %eax + shrl $7, %eax + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fldl ones@GOTOFF(%esi,%eax,8) + fmul %st, %st(3) + fxch %st(3) + fstpt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + je ..B1.20 +..B1.16: + fldt .L_2il0floatpacket.1@GOTOFF(%esi) + lea -1(%eax), %edi + shll $4, %ecx + fstpt (%esp) + fld %st(0) + movl %edi, 48(%esp) + movl %eax, %edi + negl %edi + fadd %st(2), %st + fxch %st(2) + fsubrp %st, %st(1) + fld %st(2) + addl $16383, %edi + fldl 2056+__libm_expl_table_256@GOTOFF(%esi,%ecx) + subl %eax, %edi + fldl 2048+__libm_expl_table_256@GOTOFF(%esi,%ecx) + negl %ecx + fstpt 16(%esp) + fldt 16(%esp) + andl $32767, %edi + movzwl 8+.L_2il0floatpacket.1@GOTOFF(%esi), %edx + fadd %st(1), %st + fmulp %st, %st(4) + fld %st(4) + fmul %st(1), %st + andl $-32768, %edx + faddp %st, %st(4) + fldl 2056+__libm_expl_table_256@GOTOFF(%esi,%ecx) + orl %edi, %edx + fmul %st, %st(2) + fldl 2048+__libm_expl_table_256@GOTOFF(%esi,%ecx) + fld %st(0) + movw %dx, 8(%esp) + fadd %st(2), %st + fmulp %st, %st(5) + movzbl 17(%ebp), %eax + fxch %st(3) + fsubrp %st, %st(4) + fxch %st(3) + fstpt 32(%esp) + fld %st(4) + fxch %st(2) + fmul %st, %st(5) + andl $128, %eax + fldt 16(%esp) + fmul %st, %st(3) + fld %st(0) + shrl $7, %eax + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fsub %st(5), %st + fsubr %st, %st(4) + fxch %st(5) + fsubrp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fld %st(0) + fldt 32(%esp) + faddp %st, %st(3) + fldt (%esp) + fmul %st, %st(5) + fxch %st(1) + fadd %st(5), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fmulp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldl ones@GOTOFF(%esi,%eax,8) + fmul %st, %st(1) + fxch %st(1) + fstpt (%ebx) + fmulp %st, %st(1) + fstpt 12(%ebx) + fildl 48(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + cmpl $32767, %eax + je ..B1.23 +..B1.18: + fldt _infs@GOTOFF(%esi) + fstpt (%ebx) + fldt (%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + fstpt 12(%ebx) +..B1.19: + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.20: + movl 12(%ebp), %edx + cmpl $-782985146, %edx + ja ..B1.14 +..B1.21: + jne ..B1.16 +..B1.22: + cmpl $1501741449, 8(%ebp) + ja ..B1.14 + jmp ..B1.16 +..B1.23: + fldt 8(%ebp) + fmul %st(0), %st + fstpt (%ebx) + fldt (%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + fstpt 12(%ebx) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __libm_coshl_k80,@function + .size __libm_coshl_k80,.-__libm_coshl_k80 + .data +# -- End __libm_coshl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 2 +_Q3: + .word 21845 + .word 213 + .word 0 + .word 32768 + .word 16382 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 62430 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 22894 + .word 21845 + .word 43733 + .word 43690 + .word 16378 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 65531 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 7054 + .word 43693 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 25016 + .word 58228 + .word 24755 + .word 46603 + .word 16373 + .word 0 + .word 57397 + .word 35800 + .word 53031 + .word 53262 + .word 16367 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 18360 + .word 43637 + .word 28980 + .word 40373 + .word 49076 + .word 0 + .word 16302 + .word 43691 + .word 43690 + .word 43690 + .word 16362 + .word 0 + .word 46125 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .word 29965 + .word 3335 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 54950 + .word 46751 + .word 32187 + .word 37874 + .word 16361 + .word 0 + .word 30733 + .word 25775 + .word 51110 + .word 36726 + .word 16354 + .word 0 + .word 49850 + .word 450 + .word 9929 + .word 51659 + .word 16346 + .word 0 + .word 2776 + .word 45191 + .word 37201 + .word 55334 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16378 + .word 0 + .type _Q,@object + .size _Q,120 + .align 2 +_KLN2: + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 16391 + .word 0 + .type _KLN2,@object + .size _KLN2,12 + .align 2 +_LN2K: + .word 0 + .word 0 + .word 6134 + .word 45426 + .word 16374 + .word 0 + .word 55756 + .word 58609 + .word 48341 + .word 59623 + .word 16343 + .word 0 + .type _LN2K,@object + .size _LN2K,24 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_infs: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .type _infs,@object + .size _infs,12 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_cosl_k80.S b/external/sgx_libm/ia32/libm_cosl_k80.S new file mode 100644 index 0000000000..f711b5787d --- /dev/null +++ b/external/sgx_libm/ia32/libm_cosl_k80.S @@ -0,0 +1,703 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_cosl_k80.c" + .text +..TXTST0: +# -- Begin __libm_cosl_k80 + .text + .align 16,0x90 + .hidden __libm_cosl_k80 + .globl __libm_cosl_k80 +__libm_cosl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %ebx + subl $184, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 144(%esp) + movzwl 16(%ebp), %eax + andl $32767, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $16378, %eax + movl 20(%ebp), %esi + jge ..B1.18 +..B1.2: + cmpl $16372, %eax + jge ..B1.16 +..B1.3: + cmpl $16364, %eax + jge ..B1.14 +..B1.4: + cmpl $16308, %eax + jge ..B1.12 +..B1.5: + testl %eax, %eax + jne ..B1.8 +..B1.6: + cmpl $0, 12(%ebp) + jne ..B1.8 +..B1.7: + cmpl $0, 8(%ebp) + je ..B1.9 +..B1.8: + fldl _ones@GOTOFF(%ebx) + fldt _small_value_80@GOTOFF(%ebx) + fsubr %st(1), %st + fstpt (%esi) + fldl _zeros@GOTOFF(%ebx) + fstpt 12(%esi) + jmp ..B1.10 +..B1.9: + fldl _ones@GOTOFF(%ebx) + fstpt (%esi) + fldt (%esi) + fldl _zeros@GOTOFF(%ebx) + fstpt 12(%esi) +..B1.10: + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.28 +..B1.11: + addl $184, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.12: + fldl _ones@GOTOFF(%ebx) + fstpt (%esi) + fldt (%esi) + fldt 8(%ebp) + fldt _CP3@GOTOFF(%ebx) + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 12(%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.28 +..B1.13: + addl $184, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + fldt 8(%ebp) + fmul %st(0), %st + fldl _ones@GOTOFF(%ebx) + fstpt (%esi) + fldt (%esi) + fldt 12+_CP2@GOTOFF(%ebx) + fmul %st(2), %st + fldt _CP2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.28 +..B1.15: + addl $184, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + fldt 8(%ebp) + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fldl _ones@GOTOFF(%ebx) + fstpt (%esi) + fldt (%esi) + fldt 36+_CP1@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_CP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_CP1@GOTOFF(%ebx) + fmulp %st, %st(3) + fldt _CP1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.28 +..B1.17: + addl $184, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + cmpl $16382, %eax + jge ..B1.20 +..B1.19: + fldt 8(%ebp) + fldl _TWO_52H@GOTOFF(%ebx) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fxch %st(1) + fmull _ones@GOTOFF(%ebx,%eax,8) + xorl %eax, %eax + fmul %st, %st(1) + xorl %edx, %edx + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fxch %st(1) + fstpt 112(%esp) + fldt 112(%esp) + fstpt 8(%ebp) + jmp ..B1.23 +..B1.20: + je ..B1.33 +..B1.21: + fldt 8(%ebp) + lea 128(%esp), %edx + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmull _ones@GOTOFF(%ebx,%eax,8) + fstpt (%esp) + fldt (%esp) + movl $0, 12(%esp) + fstpt 8(%ebp) + movl %edx, 16(%esp) + call __libm_reduce_pi04l +..B1.38: + movl %eax, %edx +..B1.22: + fldl 128(%esp) + lea 3(%edx), %eax + fldl _TWO_52H@GOTOFF(%ebx) + fmul %st(1), %st + fld %st(0) + shrl $2, %eax + fadd %st(2), %st + andl $1, %eax + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddl 136(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpt 112(%esp) +..B1.23: + fldt 112(%esp) + fld %st(2) + fmul %st(2), %st + fld %st(2) + fmulp %st, %st(2) + incl %edx + faddp %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fld %st(2) + fmul %st(3), %st + testb $2, %dl + fld %st(0) + fadd %st(2), %st + fstpt 48(%esp) + fldt 48(%esp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 80(%esp) + fldt 80(%esp) + fld %st(1) + fmul %st(2), %st + fld %st(0) + faddp %st, %st(2) + fldl _TWO_53H@GOTOFF(%ebx) + fstpt 64(%esp) + fldl _ones@GOTOFF(%ebx,%eax,8) + je ..B1.25 +..B1.24: + fldt 84+_SP@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + fstpt 32(%esp) + fldt 60+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_SP@GOTOFF(%ebx) + fldt 96+_SP@GOTOFF(%ebx) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(3) + fldt 48(%esp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 80(%esp) + fldt 96(%esp) + fldt 120+_SP@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldt 108+_SP@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fld %st(3) + fldt 64(%esp) + fmul %st(4), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fmul %st(3), %st + fxch %st(2) + fsub %st(3), %st + faddp %st, %st(1) + fxch %st(2) + fmul %st(4), %st + fldt 112(%esp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt (%esi) + fmulp %st, %st(1) + fstpt 12(%esi) + fldl _ones@GOTOFF(%ebx) + jmp ..B1.26 +..B1.25: + fstp %st(4) + fstp %st(4) + fldt 84+_CP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 60+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_CP@GOTOFF(%ebx) + fldt 96+_CP@GOTOFF(%ebx) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 48(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 80(%esp) + fldt 96(%esp) + fldt 120+_CP@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(5) + fldt 108+_CP@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fld %st(4) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fadd %st, %st(1) + fldt 64(%esp) + fmul %st(2), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fldl _ones@GOTOFF(%ebx) + fadd %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + fstpt (%esi) + fmulp %st, %st(1) + fstpt 12(%esi) +..B1.26: + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.28 +..B1.27: + addl $184, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.28: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.33: + movl 12(%ebp), %eax + cmpl $-921707870, %eax + jb ..B1.19 +..B1.34: + jne ..B1.21 +..B1.35: + cmpl $560513589, 8(%ebp) + jbe ..B1.19 + jmp ..B1.21 + .align 16,0x90 + .type __libm_cosl_k80,@function + .size __libm_cosl_k80,.-__libm_cosl_k80 + .data +# -- End __libm_cosl_k80 + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_CP3: + .word 0 + .word 65450 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .type _CP3,@object + .size _CP3,12 + .align 2 +_CP2: + .word 63855 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 18238 + .word 17476 + .word 43656 + .word 43690 + .word 16378 + .word 0 + .type _CP2,@object + .size _CP2,24 + .align 2 +_CP1: + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 47533 + .word 43689 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 14131 + .word 49466 + .word 24756 + .word 46603 + .word 49141 + .word 0 + .word 37142 + .word 18013 + .word 35855 + .word 53259 + .word 16367 + .word 0 + .type _CP1,@object + .size _CP1,48 + .align 2 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .type _SP,@object + .size _SP,132 + .align 2 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .type _CP,@object + .size _CP,132 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_exp_k32.S b/external/sgx_libm/ia32/libm_exp_k32.S new file mode 100644 index 0000000000..e659995caa --- /dev/null +++ b/external/sgx_libm/ia32/libm_exp_k32.S @@ -0,0 +1,237 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_exp_k32.c" + .text +..TXTST0: +# -- Begin __libm_exp_k32 + .text + .align 16,0x90 + .hidden __libm_exp_k32 + .globl __libm_exp_k32 +__libm_exp_k32: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %edi + pushl %ebx + subl $24, %esp + movl 12(%ebp), %eax + movl %eax, %edx + andl $2147483647, %edx + shrl $31, %eax + cmpl $1012924416, %edx + jb ..B1.3 +..B1.2: + fldl 8(%ebp) + xorl %edx, %edx + call ..L2 +..L2: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edi), %edi + fld1 + fldl _TWO_52H@GOTOFF(%edi) + fldl .L_2il0floatpacket.0@GOTOFF(%edi) + fmul %st(3), %st + movl %edx, 16(%esp) + fadd %st(1), %st + fstpl (%esp) + fldl (%esp) + movl (%esp), %ecx + movl %ecx, %ebx + shll $25, %ebx + fsubp %st, %st(1) + fldl .L_2il0floatpacket.1@GOTOFF(%edi) + fmul %st(1), %st + sarl $25, %ebx + fsubrp %st, %st(3) + fld %st(2) + subl %ebx, %ecx + fxch %st(3) + fstl 8(%ebp) + fldl .L_2il0floatpacket.2@GOTOFF(%edi) + fmulp %st, %st(2) + shll $4, %ebx + fxch %st(1) + fsubr %st, %st(3) + fld %st(3) + fxch %st(2) + fsub %st(4), %st + shrl $7, %ecx + fsubp %st, %st(1) + addl SC2_BIAS@GOTOFF(%edi,%eax,4), %ecx + fadd %st, %st(1) + fld %st(1) + fmul %st(2), %st + fxch %st(3) + fadd %st(4), %st + fstpl 8(%esp) + fldl .L_2il0floatpacket.3@GOTOFF(%edi) + fldl .L_2il0floatpacket.6@GOTOFF(%edi) + movl %edx, 8(%esp) + fmul %st(4), %st + fldl 8(%esp) + shll $20, %ecx + fadd %st, %st(2) + movl %ecx, 20(%esp) + fxch %st(2) + fsubrp %st, %st(6) + fxch %st(5) + faddp %st, %st(2) + fldl .L_2il0floatpacket.4@GOTOFF(%edi) + fmul %st(4), %st + fxch %st(5) + faddl .L_2il0floatpacket.7@GOTOFF(%edi) + fmulp %st, %st(3) + fxch %st(4) + faddl .L_2il0floatpacket.5@GOTOFF(%edi) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldl .L_2il0floatpacket.8@GOTOFF(%edi) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldl 1032+__libm_exp_table_128@GOTOFF(%edi,%ebx) + fld %st(0) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(3) + fmulp %st, %st(1) + fxch %st(2) + fmull 1024+__libm_exp_table_128@GOTOFF(%edi,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + fmull 16(%esp) + fmull _SC2@GOTOFF(%edi,%eax,8) + addl $24, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.3: + fld1 + faddl 8(%ebp) +..B1.4: + addl $24, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __libm_exp_k32,@function + .size __libm_exp_k32,.-__libm_exp_k32 + .data +# -- End __libm_exp_k32 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +SC2_BIAS: + .long 511 + .long 1535 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_SC2: + .long 0 + .long 1609564160 + .long 0 + .long 535822336 + .type _SC2,@object + .size _SC2,16 + .data + .hidden __libm_exp_table_128 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_expl_k80.S b/external/sgx_libm/ia32/libm_expl_k80.S new file mode 100644 index 0000000000..c519786475 --- /dev/null +++ b/external/sgx_libm/ia32/libm_expl_k80.S @@ -0,0 +1,386 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_expl_k80.c" + .text +..TXTST0: +# -- Begin __libm_expl_k80 + .text + .align 16,0x90 + .hidden __libm_expl_k80 + .globl __libm_expl_k80 +__libm_expl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %edi + pushl %ebx + subl $40, %esp + movl 12(%ebp), %ebx + movl 8(%ebp), %ecx + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + fldt (%ebx) + movzbl 9(%ebx), %eax + movzwl 8(%ebx), %edi + andl $128, %eax + andl $32767, %edi + shrl $7, %eax + fstpt 24(%esp) + fldt 24(%esp) + cmpl $32767, %edi + fldt 12(%ebx) + je ..B1.11 +..B1.2: + cmpl $16358, %edi + jge ..B1.7 +..B1.3: + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + cmpl $16183, %edi + jge ..B1.5 +..B1.4: + fstp %st(2) + fstp %st(0) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fstpt 12(%ecx) + fldt 12(%ecx) + fxch %st(1) + fstpt (%ecx) + addl $40, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.5: + fldt 12+_P1@GOTOFF(%edx) + fmul %st(3), %st + fldt _P1@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(3), %st + fmul %st(3), %st + faddp %st, %st(3) + fld %st(0) + fadd %st(3), %st + fstpt (%ecx) + fldt (%ecx) + fsubrp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%ecx) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) +..B1.6: + addl $40, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.7: + cmpl $16405, %edi + jge ..B1.9 +..B1.8: + fldt _KLN2@GOTOFF(%edx) + fmulp %st, %st(2) + fldt _TWO_63H@GOTOFF(%edx) + fadd %st, %st(2) + fxch %st(2) + fstpt (%esp) + fldt (%esp) + movl (%esp), %eax + fsubp %st, %st(2) + fldt 24(%esp) + fldt _LN2K@GOTOFF(%edx) + fmul %st(3), %st + fstpt (%esp) + fxch %st(2) + fchs + fldt (%esp) + movsbl %al, %ebx + fsubrp %st, %st(3) + fldt 12+_LN2K@GOTOFF(%edx) + subl %ebx, %eax + fmulp %st, %st(1) + fstpt (%esp) + fldt (%esp) + shll $4, %ebx + fadd %st(2), %st + fld %st(0) + sarl $8, %eax + fsub %st(3), %st + fld %st(1) + movl %eax, 16(%esp) + fsub %st(1), %st + fsubrp %st, %st(4) + fldt (%esp) + fsubp %st, %st(1) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fld %st(2) + fsub %st(2), %st + fchs + fld %st(0) + fsubr %st(3), %st + fsubrp %st, %st(4) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt 48+_P@GOTOFF(%edx) + fmul %st(1), %st + fildl 16(%esp) + fldt 24+_P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt _P@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(3), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%ebx) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%ebx) + fld %st(0) + fmul %st(3), %st + fxch %st(3) + fadd %st(5), %st + fmul %st(2), %st + faddp %st, %st(3) + fmul %st, %st(4) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(2) + fadd %st(1), %st + fstpt (%ecx) + fldt (%ecx) + fsubrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%ecx) + addl $40, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + fstp %st(1) + fstp %st(0) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + lea (,%eax,8), %ebx + fstpt 12(%ecx) + lea (%ebx,%eax,4), %eax + fldt _inf_zeros@GOTOFF(%edx,%eax) + fstpt (%ecx) + fldt (%ecx) +..B1.10: + addl $40, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + fstp %st(0) + cmpl $-2147483648, 28(%esp) + jne ..B1.15 +..B1.12: + cmpl $0, 24(%esp) + jne ..B1.15 +..B1.13: + fstp %st(0) + lea (,%eax,8), %ebx + lea (%ebx,%eax,4), %eax + fldt _inf_zeros@GOTOFF(%edx,%eax) +..B1.15: + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fstpt 12(%ecx) + fstpt (%ecx) + fldt (%ecx) + addl $40, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __libm_expl_k80,@function + .size __libm_expl_k80,.-__libm_expl_k80 + .data +# -- End __libm_expl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 2 +_P1: + .word 43691 + .word 10 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 30584 + .word 43703 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _P1,@object + .size _P1,24 + .align 2 +_KLN2: + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 16391 + .word 0 + .type _KLN2,@object + .size _KLN2,12 + .align 2 +_TWO_63H: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .type _TWO_63H,@object + .size _TWO_63H,12 + .align 2 +_LN2K: + .word 0 + .word 0 + .word 6134 + .word 45426 + .word 16374 + .word 0 + .word 55756 + .word 58609 + .word 48341 + .word 59623 + .word 16343 + .word 0 + .type _LN2K,@object + .size _LN2K,24 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_inf_zeros: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _inf_zeros,@object + .size _inf_zeros,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_hypot2l_k80.S b/external/sgx_libm/ia32/libm_hypot2l_k80.S new file mode 100644 index 0000000000..7238ad258a --- /dev/null +++ b/external/sgx_libm/ia32/libm_hypot2l_k80.S @@ -0,0 +1,497 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_hypot2l_k80.c" + .text +..TXTST0: +# -- Begin __libm_hypot2l_k80 + .text + .align 16,0x90 + .hidden __libm_hypot2l_k80 + .globl __libm_hypot2l_k80 +__libm_hypot2l_k80: +# parameter 1: 64 + %esp +# parameter 2: 68 + %esp +# parameter 3: 80 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + subl $48, %esp + movzwl 76(%esp), %eax + testl $32767, %eax + movl 64(%esp), %ecx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jne ..B1.8 +..B1.2: + cmpl $0, 72(%esp) + jne ..B1.8 +..B1.3: + cmpl $0, 68(%esp) + jne ..B1.8 +..B1.4: + movzwl 88(%esp), %eax + testl $32767, %eax + jne ..B1.8 +..B1.5: + cmpl $0, 84(%esp) + jne ..B1.8 +..B1.6: + cmpl $0, 80(%esp) + jne ..B1.8 +..B1.7: + fldt 68(%esp) + fstpt (%ecx) + fldt 80(%esp) + fstpt 12(%ecx) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + addl $48, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.8: + fldt 68(%esp) + fabs + fstpt (%esp) + fldt (%esp) + fldt 80(%esp) + fabs + fstpt 12(%esp) + fldt 12(%esp) + movzwl 8(%esp), %edx + movzwl 20(%esp), %eax + andl $32767, %edx + andl $32767, %eax + cmpl %eax, %edx + jg ..B1.13 +..B1.9: + jne ..B1.14 +..B1.10: + movl 4(%esp), %esi + movl 16(%esp), %edi + cmpl %edi, %esi + ja ..B1.65 +..B1.11: + jne ..B1.64 +..B1.12: + movl (%esp), %esi + cmpl 12(%esp), %esi + jbe ..B1.64 +..B1.65: + cmpl %eax, %edx +..B1.13: + fxch %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fld %st(0) + fxch %st(2) + fxch %st(1) + fxch %st(2) + jl ..B1.20 + jmp ..B1.16 +..B1.14: + fstpt 24(%esp) + fldt 24(%esp) + fld %st(0) +..B1.15: + jl ..B1.20 +..B1.16: + jne ..B1.21 +..B1.17: + movl 4(%esp), %eax + movl 16(%esp), %edx + cmpl %edx, %eax + jb ..B1.20 +..B1.18: + jne ..B1.21 +..B1.19: + movl (%esp), %eax + cmpl 12(%esp), %eax + jae ..B1.21 +..B1.20: + fstp %st(1) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) + jmp ..B1.22 +..B1.21: + fstp %st(2) + fstpt 12(%esp) + fldt 12(%esp) +..B1.22: + movswl 20(%esp), %eax + testl %eax, %eax + je ..B1.24 +..B1.23: + addl $-16383, %eax + jmp ..B1.29 +..B1.24: + movzwl 20(%esp), %eax + testl $32767, %eax + jne ..B1.28 +..B1.25: + cmpl $0, 16(%esp) + jne ..B1.28 +..B1.26: + cmpl $0, 12(%esp) + jne ..B1.28 +..B1.27: + movl $-16526, %eax + jmp ..B1.29 +..B1.28: + fldt 72+_CONSTANTS@GOTOFF(%ebx) + fmul %st(1), %st + fldt 84+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%esp) + movswl 8(%esp), %eax + addl $-32828, %eax +..B1.29: + movswl 32(%esp), %edx + testl %edx, %edx + je ..B1.31 +..B1.30: + addl $-16383, %edx + jmp ..B1.32 +..B1.31: + fldt 72+_CONSTANTS@GOTOFF(%ebx) + fmul %st(2), %st + fldt 84+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%esp) + movswl 8(%esp), %edx + addl $-32828, %edx +..B1.32: + addl $-67, %edx + cmpl %edx, %eax + jg ..B1.34 +..B1.33: + fstp %st(0) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) +..B1.34: + movzwl 32(%esp), %eax + andl $32767, %eax + cmpl $24709, %eax + jg ..B1.39 +..B1.35: + jne ..B1.40 +..B1.36: + movl 28(%esp), %edx + cmpl 4+_CONSTANTS@GOTOFF(%ebx), %edx + ja ..B1.39 +..B1.37: + jne ..B1.40 +..B1.38: + movl 24(%esp), %edx + cmpl _CONSTANTS@GOTOFF(%ebx), %edx + jb ..B1.40 +..B1.39: + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fmul %st, %st(2) + fxch %st(2) + fstpt 24(%esp) + fldt 24(%esp) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + jmp ..B1.61 +..B1.40: + cmpl $24573, %eax + jg ..B1.45 +..B1.41: + jne ..B1.46 +..B1.42: + movl 28(%esp), %edx + cmpl 16+_CONSTANTS@GOTOFF(%ebx), %edx + ja ..B1.45 +..B1.43: + jne ..B1.46 +..B1.44: + movl 24(%esp), %edx + cmpl 12+_CONSTANTS@GOTOFF(%ebx), %edx + jb ..B1.46 +..B1.45: + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + fstpt 24(%esp) + fldt 24(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + jmp ..B1.61 +..B1.46: + cmpl $8127, %eax + jl ..B1.51 +..B1.47: + jne ..B1.52 +..B1.48: + movl 28(%esp), %edx + cmpl 28+_CONSTANTS@GOTOFF(%ebx), %edx + jb ..B1.51 +..B1.49: + jne ..B1.52 +..B1.50: + movl 24(%esp), %edx + cmpl 24+_CONSTANTS@GOTOFF(%ebx), %edx + ja ..B1.52 +..B1.51: + fldt 48+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fmul %st, %st(2) + fxch %st(2) + fstpt 24(%esp) + fldt 24(%esp) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fldt .L_2il0floatpacket.5@GOTOFF(%ebx) + jmp ..B1.61 +..B1.52: + cmpl $8323, %eax + jl ..B1.57 +..B1.53: + jne ..B1.60 +..B1.54: + movl 28(%esp), %eax + cmpl 40+_CONSTANTS@GOTOFF(%ebx), %eax + jb ..B1.57 +..B1.55: + jne ..B1.60 +..B1.56: + movl 24(%esp), %eax + cmpl 36+_CONSTANTS@GOTOFF(%ebx), %eax + ja ..B1.60 +..B1.57: + fldt 48+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + fstpt 24(%esp) + fldt 24(%esp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + jmp ..B1.61 +..B1.60: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) +..B1.61: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fld %st(3) + fmul %st(1), %st + fld %st(4) + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(4) + fxch %st(2) + fsubr %st, %st(6) + fxch %st(3) + fmul %st(5), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(5) + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(4) + fmul %st(7), %st + fxch %st(4) + fmulp %st, %st(1) + fmul %st(5), %st + fld %st(1) + fadd %st(4), %st + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fxch %st(6) + fmul %st(0), %st + faddp %st, %st(3) + fld %st(0) + fadd %st(2), %st + fld %st(0) + fadd %st(7), %st + fstpt (%ecx) + fldt (%ecx) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(4) + fmul %st(0), %st + fxch %st(2) + fsubp %st, %st(4) + fxch %st(3) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 12(%ecx) + addl $48, %esp + popl %ebx + popl %edi + popl %esi + ret +..B1.64: + cmpl %eax, %edx + jmp ..B1.14 + .align 16,0x90 + .type __libm_hypot2l_k80,@function + .size __libm_hypot2l_k80,.-__libm_hypot2l_k80 + .data +# -- End __libm_hypot2l_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0e,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0d,0x40,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0e,0xc0,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0d,0xc0,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24709 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 24573 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 8127 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8323 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24576 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8190 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16445 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,96 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_log1pl_k80.S b/external/sgx_libm/ia32/libm_log1pl_k80.S new file mode 100644 index 0000000000..1025023f13 --- /dev/null +++ b/external/sgx_libm/ia32/libm_log1pl_k80.S @@ -0,0 +1,1912 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_log1pl_k80.c" + .text +..TXTST0: +# -- Begin __libm_log1p_k80 + .text + .align 16,0x90 + .globl __libm_log1p_k80 +__libm_log1p_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + movl 12(%ebp), %esi + movl %gs:20, %eax + xorl %esp, %eax + movzwl 8(%esi), %ecx + andl $32767, %ecx + movl %eax, 116(%esp) + movl 24(%esi), %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl 8(%ebp), %edi + lea (%eax,%ecx), %edx + cmpl $16511, %edx + jge ..B1.9 +..B1.2: + cmpl $16255, %edx + jle ..B1.8 +..B1.3: + addl $-8383, %ecx + cmpl $16000, %ecx + jbe ..B1.6 +..B1.4: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B1.5: + movl 24(%esi), %eax +..B1.6: + fldt (%esi) + addl $16383, %eax + fldt 12(%esi) + andl $32767, %eax + andb $127, 41(%esp) + lea 68(%esp), %edx + movzwl -28(%edx), %ecx + andl $-32768, %ecx + orl %eax, %ecx + lea 92(%esp), %eax + movw %cx, -52(%eax) + movl $-2147483648, -56(%eax) + movl $0, -60(%eax) + fldt -60(%eax) + fmul %st, %st(2) + fxch %st(2) + fstpt (%edx) + fmulp %st, %st(1) + fstpt -12(%eax) + call __libm_log1pl_k80. +..B1.7: + fldt 92(%esp) + fmul %st(1), %st + movl $0, 24(%edi) + fstpt (%edi) + fldt 104(%esp) + fmulp %st, %st(1) + fstpt 12(%edi) + jmp ..B1.19 +..B1.8: + movl (%esi), %eax + movl %eax, (%edi) + movl 4(%esi), %edx + movl %edx, 4(%edi) + movl 8(%esi), %ecx + movl %ecx, 8(%edi) + movl 12(%esi), %eax + movl %eax, 12(%edi) + movl 16(%esi), %edx + movl %edx, 16(%edi) + movl 20(%esi), %ecx + movl %ecx, 20(%edi) + movl 24(%esi), %esi + movl %esi, 24(%edi) + jmp ..B1.19 +..B1.9: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B1.10: + fildl 24(%esi) + fstpt 32(%esp) + lea 92(%esp), %eax + fldt (%esi) + fstpt (%esp) + fldt (%esp) + fstpt -24(%eax) + fldt 12(%esi) + fstpt 12(%esp) + fldt 12(%esp) + fstpt -12(%eax) + movl %eax, 24(%esp) + call __libm_logl_k80 +..B1.11: + fldt 92(%esp) + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt 104(%esp) + fmulp %st, %st(2) + movzwl 100(%esp), %edx + andl $32767, %edx + fxch %st(1) + fstpt 104(%esp) + fldt 104(%esp) + fldt 216+_CONSTANTS@GOTOFF(%ebx) + fldt 228+_CONSTANTS@GOTOFF(%ebx) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 44(%esp) + fldt 44(%esp) + fld %st(0) + movzwl 52(%esp), %eax + fadd %st(5), %st + fxch %st(3) + fmulp %st, %st(2) + andl $32767, %eax + fxch %st(1) + fstpt 56(%esp) + fldt 56(%esp) + cmpl %edx, %eax + movl $0, 24(%edi) + jg ..B1.16 +..B1.12: + jne ..B1.17 +..B1.13: + movl 48(%esp), %eax + movl 96(%esp), %edx + cmpl %edx, %eax + ja ..B1.16 +..B1.14: + jne ..B1.17 +..B1.15: + movl 44(%esp), %eax + cmpl 92(%esp), %eax + jbe ..B1.17 +..B1.16: + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.18 +..B1.17: + fxch %st(2) + fsubr %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) +..B1.18: + fld %st(1) + fadd %st(1), %st + fstpt (%edi) + fldt (%edi) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%edi) +..B1.19: + movl 116(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.21 +..B1.20: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.21: + call __stack_chk_fail@PLT + .align 16,0x90 + .type __libm_log1p_k80,@function + .size __libm_log1p_k80,.-__libm_log1p_k80 + .data +# -- End __libm_log1p_k80 + .text +# -- Begin __libm_log1pl_k80 + .text + .align 16,0x90 + .hidden __libm_log1pl_k80 + .globl __libm_log1pl_k80 +__libm_log1pl_k80: +# parameter 1: %eax +# parameter 2: %edx +..B2.1: +..L3: + + movl 4(%esp), %eax + movl 8(%esp), %edx + .hidden __libm_log1pl_k80. + .globl __libm_log1pl_k80. +__libm_log1pl_k80.: + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $404, %esp + movl %eax, %ecx + fldt (%edx) + fld %st(0) + fldt 12(%edx) + movl %gs:20, %eax + fadd %st, %st(1) + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + fxch %st(1) + fsub %st, %st(2) + xorl %esp, %eax + fxch %st(2) + fsubrp %st, %st(1) + fldt 48+_CONSTANTS@GOTOFF(%ebx) + movl %eax, 388(%esp) + fstpt 12(%ecx) + fldt 12(%ecx) + fxch %st(2) + fstpt (%esp) + fldt (%esp) + movzbl 9(%esp), %eax + andl $128, %eax + shrl $7, %eax + movzwl 8(%esp), %esi + movl %eax, 16(%esp) + andl $32767, %esi + shll $15, %eax + movl 4(%esp), %edi + orl %esi, %eax + movl %edi, 12(%esp) + shll $16, %eax + shrl $16, %edi + orl %edi, %eax + cmpl $32767, %esi + je ..B2.116 +..B2.2: + cmpl $-1073774592, %eax + jae ..B2.101 +..B2.3: + fstp %st(1) + fxch %st(1) + fstpt (%ecx) + fldt (%ecx) +..B2.4: + cmpl $16375, %esi + jge ..B2.52 +..B2.5: + fstp %st(0) + cmpl $16363, %esi + jge ..B2.30 +..B2.6: + fstp %st(0) + cmpl $16298, %esi + jge ..B2.8 +..B2.7: + fldt (%edx) + fstpt (%ecx) + fldt 12(%edx) + fstpt 12(%ecx) + fldt _CONSTANTS@GOTOFF(%ebx) + jmp ..B2.104 +..B2.8: + fldt (%edx) + fld %st(0) + fld %st(1) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(2) + fld %st(1) + fld %st(3) + fsub %st(3), %st + fmul %st, %st(1) + fxch %st(1) + fadd %st(0), %st + fld %st(0) + fld %st(4) + fmul %st(5), %st + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(2) + fld %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(5) + fxch %st(5) + fstpt 16(%esp) + fldt 16(%esp) + fxch %st(3) + fstpt 32(%esp) + fldt 32(%esp) + fldt 12(%edx) + fmulp %st, %st(6) + fxch %st(5) + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 96+_CONSTANTS@GOTOFF(%ebx) + fld %st(0) + fmul %st(2), %st + fstpt 48(%esp) + fldt 48(%esp) + fxch %st(1) + fmul %st(3), %st + fstpt (%esp) + fldt (%esp) + fstpt 304(%esp) + fld %st(1) + fsub %st(5), %st + faddp %st, %st(5) + fld %st(1) + fsub %st(5), %st + fxch %st(1) + fstpt 292(%esp) + fxch %st(6) + fmulp %st, %st(2) + fld %st(2) + fmul %st(4), %st + fxch %st(3) + fmul %st(6), %st + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(4) + fld %st(3) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fldt 12(%edx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt 72+_CONSTANTS@GOTOFF(%ebx) + fld %st(0) + fld %st(1) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + fxch %st(1) + fmul %st(6), %st + fsubr %st, %st(4) + faddp %st, %st(4) + fxch %st(3) + fstpt 64(%esp) + fldt 64(%esp) + fld %st(5) + fsub %st(1), %st + fld %st(2) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(2) + fmul %st(4), %st + fldt 84+_CONSTANTS@GOTOFF(%ebx) + fmul %st(6), %st + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 316(%esp) + fldt 316(%esp) + fsubr %st, %st(1) + movzwl 324(%esp), %eax + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 80(%esp) + fldt 80(%esp) + andl $32767, %eax + fstpt 328(%esp) + fldt 16(%esp) + fld %st(0) + fxch %st(1) + fmul %st(3), %st + fldt 64(%esp) + fmul %st, %st(2) + fldt 32(%esp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fld %st(1) + fldt (%edx) + fmul %st, %st(5) + fldt 12(%edx) + fmulp %st, %st(7) + fxch %st(6) + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fldt 120+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(4) + fstpt 340(%esp) + fldt 340(%esp) + fadd %st, %st(1) + fxch %st(4) + fmulp %st, %st(3) + movzwl 348(%esp), %esi + andl $32767, %esi + fxch %st(2) + fstpt 352(%esp) + fldt 352(%esp) + cmpl %esi, %eax + fldt 48(%esp) + fldt 80(%esp) + jg ..B2.13 +..B2.9: + jne ..B2.14 +..B2.10: + movl 320(%esp), %eax + movl 344(%esp), %esi + cmpl %esi, %eax + ja ..B2.13 +..B2.11: + jne ..B2.14 +..B2.12: + movl 316(%esp), %eax + cmpl 340(%esp), %eax + jbe ..B2.14 +..B2.13: + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + jmp ..B2.15 +..B2.14: + fxch %st(4) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) +..B2.15: + fld %st(2) + movzwl 300(%esp), %eax + fadd %st(1), %st + fstpt 364(%esp) + fldt 364(%esp) + andl $32767, %eax + movzwl 372(%esp), %esi + fld %st(2) + andl $32767, %esi + fadd %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + cmpl %esi, %eax + fxch %st(2) + faddp %st, %st(4) + fxch %st(3) + fstpt 376(%esp) + fldt 376(%esp) + jg ..B2.20 +..B2.16: + jne ..B2.21 +..B2.17: + movl 296(%esp), %eax + movl 368(%esp), %esi + cmpl %esi, %eax + ja ..B2.20 +..B2.18: + jne ..B2.21 +..B2.19: + movl 292(%esp), %eax + cmpl 364(%esp), %eax + jbe ..B2.21 +..B2.20: + fldt (%esp) + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.22 +..B2.21: + fldt (%esp) + fxch %st(2) + fsub %st(4), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) +..B2.22: + fld %st(0) + movzwl 8(%edx), %eax + fadd %st(2), %st + fstpt 268(%esp) + fldt 268(%esp) + andl $32767, %eax + movzwl 276(%esp), %esi + fsubr %st, %st(2) + andl $32767, %esi + fxch %st(2) + faddp %st, %st(1) + fstpt 280(%esp) + fldt 280(%esp) + cmpl %esi, %eax + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 12(%ecx) + fldt 12(%ecx) + jg ..B2.27 +..B2.23: + jne ..B2.28 +..B2.24: + movl 272(%esp), %eax + cmpl 4(%edx), %eax + jb ..B2.27 +..B2.25: + jne ..B2.28 +..B2.26: + movl (%edx), %eax + cmpl 268(%esp), %eax + jbe ..B2.28 +..B2.27: + fldt (%edx) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%edx) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + jmp ..B2.29 +..B2.28: + fldt (%edx) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 12(%edx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + fldt 16(%esp) +..B2.29: + fld %st(1) + fadd %st(1), %st + fstpt (%ecx) + fldt (%ecx) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%ecx) + fldt _CONSTANTS@GOTOFF(%ebx) + jmp ..B2.104 +..B2.30: + fldt (%edx) + fld %st(0) + fld %st(1) + fld %st(2) + fxch %st(4) + fstpt 48(%esp) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(2) + fld %st(1) + fld %st(2) + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(5) + fxch %st(1) + fmul %st(5), %st + fadd %st(0), %st + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fld %st(5) + fmul %st(6), %st + faddp %st, %st(4) + fld %st(4) + fxch %st(2) + fstpt 64(%esp) + fldt 64(%esp) + fldt 12(%edx) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fmul %st, %st(3) + fld %st(0) + fsub %st(4), %st + faddp %st, %st(4) + fld %st(2) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fxch %st(4) + fstpt 16(%esp) + fldt 16(%esp) + fld %st(1) + fsub %st(4), %st + fmul %st, %st(3) + fxch %st(4) + fmul %st(7), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(5), %st + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(4) + fld %st(4) + fmulp %st, %st(3) + fstpt 80(%esp) + fldt 80(%esp) + fldt 12(%edx) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(3) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st, %st(3) + fld %st(1) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fstpt 96(%esp) + fldt 96(%esp) + fld %st(1) + fsub %st(1), %st + fldt 64(%esp) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(2), %st + fxch %st(3) + fmul %st(7), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fldt 12(%edx) + fmul %st(3), %st + faddp %st, %st(5) + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fstpt 112(%esp) + fldt 112(%esp) + faddp %st, %st(3) + fldt 48(%esp) + fmulp %st, %st(3) + fxch %st(2) + fstpt (%esp) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fldt 72+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(1) + fld %st(0) + fsub %st(2), %st + faddp %st, %st(2) + fld %st(1) + fld %st(1) + fsub %st(3), %st + fxch %st(3) + fmul %st(6), %st + fxch %st(2) + fmulp %st, %st(4) + fxch %st(2) + fmul %st, %st(5) + fldt 96(%esp) + fmul %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + fldt 16(%esp) + fldt 84+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fstpt 316(%esp) + fldt 316(%esp) + fsubr %st, %st(3) + movzwl 324(%esp), %eax + fxch %st(3) + faddp %st, %st(1) + andl $32767, %eax + fstpt 328(%esp) + fldt 328(%esp) + fldt 96+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 304(%esp) + fldt 80(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 292(%esp) + fldt 292(%esp) + fldt 120+_CONSTANTS@GOTOFF(%ebx) + fldt 32(%esp) + fmul %st(1), %st + fstpt 340(%esp) + fldt 340(%esp) + movzwl 348(%esp), %esi + andl $32767, %esi + fstpt 32(%esp) + fldt 32(%esp) + cmpl %esi, %eax + fldt 112(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 352(%esp) + fldt 352(%esp) + fldt 204+_CONSTANTS@GOTOFF(%ebx) + fldt 192+_CONSTANTS@GOTOFF(%ebx) + fldt 48(%esp) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 180+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 168+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 156+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 144+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt 132+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(1) + fld %st(5) + faddp %st, %st(3) + fldt (%esp) + fmulp %st, %st(1) + fstpt (%esp) + fldt (%edx) + jg ..B2.35 +..B2.31: + jne ..B2.36 +..B2.32: + movl 320(%esp), %eax + movl 344(%esp), %esi + cmpl %esi, %eax + ja ..B2.35 +..B2.33: + jne ..B2.36 +..B2.34: + movl 316(%esp), %eax + cmpl 340(%esp), %eax + jbe ..B2.36 +..B2.35: + fldt 32(%esp) + fxch %st(3) + fsubr %st, %st(6) + fxch %st(3) + faddp %st, %st(6) + fxch %st(1) + faddp %st, %st(5) + fxch %st(3) + faddp %st, %st(4) + jmp ..B2.37 +..B2.36: + fldt 32(%esp) + fsub %st(3), %st + faddp %st, %st(6) + fxch %st(4) + faddp %st, %st(5) + faddp %st, %st(4) +..B2.37: + fld %st(3) + movzwl 300(%esp), %eax + fadd %st(1), %st + fstpt 364(%esp) + fldt 364(%esp) + andl $32767, %eax + movzwl 372(%esp), %esi + fsubr %st, %st(1) + andl $32767, %esi + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) + fstpt 376(%esp) + fldt 376(%esp) + fld %st(1) + cmpl %esi, %eax + fadd %st(4), %st + jg ..B2.42 +..B2.38: + jne ..B2.43 +..B2.39: + movl 296(%esp), %eax + movl 368(%esp), %esi + cmpl %esi, %eax + ja ..B2.42 +..B2.40: + jne ..B2.43 +..B2.41: + movl 292(%esp), %eax + cmpl 364(%esp), %eax + jbe ..B2.43 +..B2.42: + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 16(%esp) + faddp %st, %st(1) + fxch %st(2) + jmp ..B2.44 +..B2.43: + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fldt 16(%esp) + faddp %st, %st(4) + faddp %st, %st(3) +..B2.44: + fld %st(2) + movzwl 8(%edx), %eax + fadd %st(1), %st + fstpt 268(%esp) + fldt 268(%esp) + andl $32767, %eax + movzwl 276(%esp), %esi + fsubr %st, %st(1) + andl $32767, %esi + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + fstpt 280(%esp) + fldt 280(%esp) + cmpl %esi, %eax + fxch %st(1) + fadd %st(2), %st + fstpt 12(%ecx) + fldt 12(%ecx) + jg ..B2.49 +..B2.45: + jne ..B2.50 +..B2.46: + movl 272(%esp), %eax + cmpl 4(%edx), %eax + jb ..B2.49 +..B2.47: + jne ..B2.50 +..B2.48: + movl (%edx), %eax + cmpl 268(%esp), %eax + jbe ..B2.50 +..B2.49: + fldt (%edx) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%edx) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + jmp ..B2.51 +..B2.50: + fldt (%edx) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 12(%edx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + fldt 16(%esp) +..B2.51: + fld %st(1) + fadd %st(1), %st + fstpt (%ecx) + fldt (%ecx) + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt (%esp) + faddp %st, %st(1) + fstpt 12(%ecx) + fldt _CONSTANTS@GOTOFF(%ebx) + jmp ..B2.104 +..B2.52: + fstp %st(1) + fldt (%edx) + movzwl 8(%edx), %esi + fld %st(0) + fldt _CONSTANTS@GOTOFF(%ebx) + andl $32767, %esi + movzwl 8+_CONSTANTS@GOTOFF(%ebx), %eax + cmpl $16383, %esi + movl %eax, 12(%esp) + fadd %st, %st(1) + jg ..B2.57 +..B2.53: + jne ..B2.58 +..B2.54: + movl 4(%edx), %eax + cmpl 4+_CONSTANTS@GOTOFF(%ebx), %eax + ja ..B2.57 +..B2.55: + jne ..B2.58 +..B2.56: + movl (%edx), %eax + cmpl _CONSTANTS@GOTOFF(%ebx), %eax + jbe ..B2.58 +..B2.57: + fldt 12(%edx) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + fadd %st, %st(3) + fxch %st(3) + fadd %st(4), %st + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.59 +..B2.58: + fldt 12(%edx) + fld %st(1) + fsub %st(3), %st + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + fadd %st(3), %st +..B2.59: + fld %st(0) + fadd %st(2), %st + fstpt 128(%esp) + fldt 128(%esp) + fsubr %st, %st(2) + movzwl 136(%esp), %edx + fxch %st(2) + faddp %st, %st(1) + movl 132(%esp), %eax + andl $32767, %edx + shrl $23, %eax + movzbl %al, %eax + movl %edx, 16(%esp) + fstpt 140(%esp) + fldt 140(%esp) + lea -16383(%edx), %edx + cmpl $16383, %edx + flds __libm_rcp_table_256@GOTOFF(%ebx,%eax,4) + jge ..B2.61 +..B2.60: + movl %edx, %esi + negl %esi + addl $16383, %esi + movl 12(%esp), %edi + andl $32767, %esi + andl $-32768, %edi + fxch %st(3) + fstpt (%esp) + fldt (%esp) + orl %esi, %edi + movw %di, 8(%esp) + fldt (%esp) + fxch %st(1) + fxch %st(4) + fxch %st(1) + jmp ..B2.62 +..B2.61: + fldt 240+_CONSTANTS@GOTOFF(%ebx) +..B2.62: + movzwl 148(%esp), %esi + andl $32767, %esi + addl $128, %esi + fmul %st, %st(3) + cmpl 16(%esp), %esi + jle ..B2.64 +..B2.63: + fmulp %st, %st(2) + fxch %st(1) + jmp ..B2.65 +..B2.64: + fstp %st(0) + fstp %st(1) + fld %st(3) +..B2.65: + fldt 36+_CONSTANTS@GOTOFF(%ebx) + movl %edx, 112(%esp) + fxch %st(4) + fstpt 96(%esp) + shll $4, %eax + fstpt 16(%esp) + fld %st(1) + fildl 112(%esp) + fldt 24+_CONSTANTS@GOTOFF(%ebx) + fmul %st(1), %st + fxch %st(5) + fmulp %st, %st(1) + fld %st(3) + fxch %st(5) + faddl __libm_logl_table_256@GOTOFF(%eax,%ebx) + fstpt 48(%esp) + fldt 48(%esp) + fstpt (%esp) + fld %st(3) + fxch %st(4) + fmul %st(6), %st + fxch %st(1) + faddl 8+__libm_logl_table_256@GOTOFF(%ebx,%eax) + fstpt 32(%esp) + fld %st(2) + fldt 60+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + fsubr %st, %st(5) + faddp %st, %st(5) + fxch %st(4) + fsubr %st, %st(5) + fxch %st(2) + fmul %st, %st(4) + fstpt 64(%esp) + fld %st(2) + fsub %st(4), %st + faddp %st, %st(4) + fld %st(2) + fsub %st(4), %st + fld %st(2) + fmul %st(5), %st + fxch %st(5) + fmul %st(6), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(5), %st + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fldt 16(%esp) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 128(%esp) + fldt 128(%esp) + fsubr %st, %st(1) + movzwl 136(%esp), %eax + fxch %st(1) + faddp %st, %st(2) + andl $32767, %eax + fxch %st(1) + fstpt 140(%esp) + fldt 140(%esp) + cmpl $16383, %eax + fldt 96(%esp) + fld %st(0) + fsubr %st(3), %st + fstpt 80(%esp) + jg ..B2.70 +..B2.66: + jne ..B2.71 +..B2.67: + movl 132(%esp), %eax + cmpl 4+_CONSTANTS@GOTOFF(%ebx), %eax + ja ..B2.70 +..B2.68: + jne ..B2.71 +..B2.69: + movl 128(%esp), %eax + cmpl _CONSTANTS@GOTOFF(%ebx), %eax + jbe ..B2.71 +..B2.70: + fldt 80(%esp) + fsubrp %st, %st(3) + fsubr %st, %st(2) + fxch %st(3) + fsubrp %st, %st(2) + faddp %st, %st(1) + jmp ..B2.72 +..B2.71: + fldt 80(%esp) + fadd %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) +..B2.72: + fldt 80(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 160(%esp) + fldt 160(%esp) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 176(%esp) + fxch %st(2) + fstpt 96(%esp) + fld %st(0) + fxch %st(2) + fstpt 80(%esp) + fldt 80(%esp) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fldt 64(%esp) + fld %st(0) + fmul %st(2), %st + fsubr %st, %st(4) + faddp %st, %st(4) + fld %st(3) + fld %st(2) + fsub %st(5), %st + fmul %st, %st(1) + fxch %st(1) + fadd %st(0), %st + fld %st(0) + fld %st(6) + fmul %st(7), %st + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(2) + fld %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(5) + fmul %st(5), %st + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 128(%esp) + fldt 128(%esp) + fld %st(1) + fsub %st(4), %st + faddp %st, %st(4) + fxch %st(1) + fstpt 208(%esp) + fldt 208(%esp) + fld %st(6) + fmul %st(4), %st + fxch %st(1) + fsub %st(4), %st + fxch %st(3) + fmul %st, %st(4) + fxch %st(7) + fstpt 192(%esp) + fldt 192(%esp) + fmul %st(3), %st + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(2) + fld %st(3) + fmulp %st, %st(1) + fld %st(4) + fldt 208(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fstpt 224(%esp) + fldt 224(%esp) + fldt 64(%esp) + fldt 192(%esp) + fxch %st(1) + fmul %st(2), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fstpt 240(%esp) + fldt 240(%esp) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fmul %st(7), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fld %st(2) + fmulp %st, %st(4) + fldt 224(%esp) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fstpt 144(%esp) + fldt 144(%esp) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fstpt 256(%esp) + fldt 256(%esp) + faddp %st, %st(2) + fldt 176(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 112(%esp) + fldt 64(%esp) + fldt 240(%esp) + fldt 72+_CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fld %st(2) + fmul %st(2), %st + fld %st(1) + fsub %st(4), %st + fmul %st, %st(3) + fxch %st(4) + fmul %st(7), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(2) + fldt 84+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 316(%esp) + fldt 316(%esp) + fsubr %st, %st(2) + movzwl 324(%esp), %eax + fxch %st(2) + faddp %st, %st(1) + andl $32767, %eax + fstpt 328(%esp) + fldt 328(%esp) + fldt 96+_CONSTANTS@GOTOFF(%ebx) + fldt 120+_CONSTANTS@GOTOFF(%ebx) + fldt 208(%esp) + fmul %st(2), %st + fstpt 292(%esp) + fldt 292(%esp) + fldt 128(%esp) + fmulp %st, %st(3) + fxch %st(2) + fstpt 128(%esp) + fldt 128(%esp) + fstpt 304(%esp) + fldt 144(%esp) + fmul %st(1), %st + fstpt 340(%esp) + fldt 340(%esp) + movzwl 348(%esp), %edx + andl $32767, %edx + fstpt 144(%esp) + fldt 144(%esp) + cmpl %edx, %eax + fldt 256(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 352(%esp) + fldt 352(%esp) + fldt 204+_CONSTANTS@GOTOFF(%ebx) + fldt 192+_CONSTANTS@GOTOFF(%ebx) + fldt 176(%esp) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 180+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 168+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 156+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 144+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt 132+_CONSTANTS@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 112(%esp) + fmulp %st, %st(1) + fstpt 112(%esp) + fld %st(4) + faddp %st, %st(2) + fldt 96(%esp) + fldt 160(%esp) + jg ..B2.77 +..B2.73: + jne ..B2.78 +..B2.74: + movl 320(%esp), %eax + movl 344(%esp), %edx + cmpl %edx, %eax + ja ..B2.77 +..B2.75: + jne ..B2.78 +..B2.76: + movl 316(%esp), %eax + cmpl 340(%esp), %eax + jbe ..B2.78 +..B2.77: + fldt 144(%esp) + fxch %st(4) + fsubr %st, %st(7) + fxch %st(4) + faddp %st, %st(7) + fxch %st(2) + faddp %st, %st(6) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fxch %st(4) + jmp ..B2.79 +..B2.78: + fldt 144(%esp) + fsub %st(4), %st + faddp %st, %st(7) + fxch %st(5) + faddp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) +..B2.79: + fld %st(0) + movzwl 300(%esp), %eax + fadd %st(2), %st + fstpt 364(%esp) + fldt 364(%esp) + andl $32767, %eax + movzwl 372(%esp), %edx + fld %st(3) + andl $32767, %edx + fadd %st(1), %st + fxch %st(1) + fsubr %st, %st(3) + cmpl %edx, %eax + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 376(%esp) + fldt 376(%esp) + jg ..B2.84 +..B2.80: + jne ..B2.85 +..B2.81: + movl 296(%esp), %eax + movl 368(%esp), %edx + cmpl %edx, %eax + ja ..B2.84 +..B2.82: + jne ..B2.85 +..B2.83: + movl 292(%esp), %eax + cmpl 364(%esp), %eax + jbe ..B2.85 +..B2.84: + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 128(%esp) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.86 +..B2.85: + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fldt 128(%esp) + faddp %st, %st(2) + faddp %st, %st(1) +..B2.86: + fld %st(0) + movzwl 24(%esp), %eax + fadd %st(2), %st + fstpt 268(%esp) + fldt 268(%esp) + andl $32767, %eax + movzwl 276(%esp), %edx + fld %st(3) + andl $32767, %edx + fadd %st(1), %st + fxch %st(1) + fsubr %st, %st(3) + cmpl %edx, %eax + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 280(%esp) + fldt 280(%esp) + jg ..B2.91 +..B2.87: + jne ..B2.92 +..B2.88: + movl 20(%esp), %eax + movl 272(%esp), %edx + cmpl %edx, %eax + ja ..B2.91 +..B2.89: + jne ..B2.92 +..B2.90: + movl 16(%esp), %eax + cmpl 268(%esp), %eax + jbe ..B2.92 +..B2.91: + fldt 80(%esp) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.93 +..B2.92: + fldt 80(%esp) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) +..B2.93: + fldt 112(%esp) + fld %st(1) + movzwl 8(%esp), %edx + fadd %st(3), %st + fstpt 16(%esp) + fldt 16(%esp) + andl $32767, %edx + movzwl 24(%esp), %eax + fsubr %st, %st(3) + andl $32767, %eax + fxch %st(2) + faddp %st, %st(3) + cmpl %edx, %eax + faddp %st, %st(2) + fldt 48(%esp) + fadd %st(1), %st + jg ..B2.98 +..B2.94: + jne ..B2.99 +..B2.95: + movl 20(%esp), %eax + movl 4(%esp), %edx + cmpl %edx, %eax + ja ..B2.98 +..B2.96: + jne ..B2.99 +..B2.97: + movl 16(%esp), %eax + cmpl (%esp), %eax + jbe ..B2.99 +..B2.98: + fldt 48(%esp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 32(%esp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + jmp ..B2.100 +..B2.99: + fldt 48(%esp) + fsub %st(1), %st + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%esp) + faddp %st, %st(1) +..B2.100: + fld %st(0) + fadd %st(2), %st + fstpt (%ecx) + fldt (%ecx) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%ecx) + jmp ..B2.104 +..B2.101: + cmpl $1, 16(%esp) + je ..B2.108 +..B2.123: + fstp %st(1) +..B2.102: + fldt 12+_CONSTANTS@GOTOFF(%ebx) + fxch %st(1) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.103 + je ..B2.107 +..B2.103: + fstp %st(0) + fldt 252+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%ecx) + fldt _CONSTANTS@GOTOFF(%ebx) +..B2.104: + movl 388(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.106 +..B2.105: + addl $404, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.106: + fstp %st(0) + call __stack_chk_fail@PLT +..B2.107: + fdivp %st, %st(1) + fstpt (%ecx) + fldt _CONSTANTS@GOTOFF(%ebx) + jmp ..B2.104 +..B2.108: + cmpl $16383, %esi + jne ..B2.123 +..B2.109: + cmpl $-2147483648, 12(%esp) + jne ..B2.123 +..B2.110: + cmpl $0, (%esp) + jne ..B2.123 +..B2.111: + fxch %st(1) + fstpt (%esp) + movzbl 9(%esp), %eax + testl $128, %eax + jne ..B2.102 +..B2.112: + cmpl $0, 4(%esp) + jne ..B2.115 +..B2.114: + cmpl $0, (%esp) + je ..B2.102 +..B2.115: + fxch %st(1) + fstpt (%ecx) + fldt (%ecx) + jmp ..B2.4 +..B2.116: + fstp %st(1) + cmpl $0, 16(%esp) + je ..B2.120 +..B2.117: + cmpl $-2147483648, 12(%esp) + jne ..B2.120 +..B2.118: + cmpl $0, (%esp) + jne ..B2.120 +..B2.119: + fstp %st(0) + fldt 252+_CONSTANTS@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt (%ecx) + fldt _CONSTANTS@GOTOFF(%ebx) + jmp ..B2.104 +..B2.120: + fstp %st(1) + fldt _CONSTANTS@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + fstpt (%ecx) + jmp ..B2.104 + .align 16,0x90 + .type __libm_log1pl_k80,@function + .size __libm_log1pl_k80,.-__libm_log1pl_k80 + .data +# -- End __libm_log1pl_k80 + .section .rodata, "a" + .align 16 + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 53711 + .word 6135 + .word 45426 + .word 16382 + .word 0 + .word 2022 + .word 26416 + .word 37831 + .word 62295 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 32768 + .word 16415 + .word 0 + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16317 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49149 + .word 0 + .word 52429 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 37449 + .word 18724 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49148 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 16379 + .word 0 + .word 52429 + .word 52428 + .word 52428 + .word 52428 + .word 49147 + .word 0 + .word 11916 + .word 59578 + .word 35746 + .word 47662 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 6136 + .word 45426 + .word 16382 + .word 0 + .word 12704 + .word 55409 + .word 6480 + .word 47298 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16384 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,252 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .hidden __libm_logl_k80 + .hidden __libm_normalizel_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_log_k32.S b/external/sgx_libm/ia32/libm_log_k32.S new file mode 100644 index 0000000000..ed0867162c --- /dev/null +++ b/external/sgx_libm/ia32/libm_log_k32.S @@ -0,0 +1,164 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_log_k32.c" + .text +..TXTST0: +# -- Begin __libm_log_k32 + .text + .align 16,0x90 + .hidden __libm_log_k32 + .globl __libm_log_k32 +__libm_log_k32: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp + movl 12(%ebp), %edx + movl %edx, %eax + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + andl $2146435072, %eax + negl %eax + addl $2145386496, %eax + fldl .L_2il0floatpacket.0@GOTOFF(%ecx) + movl %eax, 12(%esp) + lea -1072676864(%edx), %eax + movl $0, 8(%esp) + cmpl $24576, %eax + jae ..B1.3 +..B1.2: + fldl 8(%ebp) + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstl 8(%ebp) + fldl 32+_Q@GOTOFF(%ecx) + fmul %st(2), %st + fldl 24+_Q@GOTOFF(%ecx) + fmul %st(3), %st + fxch %st(1) + faddl 16+_Q@GOTOFF(%ecx) + fmul %st(3), %st + fxch %st(1) + faddl 8+_Q@GOTOFF(%ecx) + fmul %st(2), %st + faddp %st, %st(1) + faddl _Q@GOTOFF(%ecx) + fmulp %st, %st(2) + faddp %st, %st(1) + movl %ebp, %esp + popl %ebp + ret +..B1.3: + fldl 8(%ebp) + movl %edx, %eax + fmull 8(%esp) + shrl $12, %edx + movzbl %dl, %edx + shrl $20, %eax + addl $-1023, %eax + movl %eax, (%esp) + fmuls __libm_rcp_table_256@GOTOFF(%ecx,%edx,4) + faddp %st, %st(1) + fstl 8(%ebp) + fldl 8+_P@GOTOFF(%ecx) + fmul %st(1), %st + fildl (%esp) + fxch %st(1) + faddl _P@GOTOFF(%ecx) + fmul %st(2), %st + fmul %st(2), %st + faddp %st, %st(2) + fmull _LN2@GOTOFF(%ecx) + faddl __libm_logf_table_256@GOTOFF(%ecx,%edx,8) + faddp %st, %st(1) +..B1.4: + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __libm_log_k32,@function + .size __libm_log_k32,.-__libm_log_k32 + .data +# -- End __libm_log_k32 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 4 +_Q: + .long 4294868184 + .long 3219128319 + .long 1443356411 + .long 1070945621 + .long 823147527 + .long 3218079745 + .long 748089218 + .long 1070176642 + .long 1053536005 + .long 3217353219 + .type _Q,@object + .size _Q,40 + .align 4 +_P: + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .type _P,@object + .size _P,16 + .align 4 +_LN2: + .long 4277811695 + .long 1072049730 + .type _LN2,@object + .size _LN2,8 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logf_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_logl.S b/external/sgx_libm/ia32/libm_logl.S new file mode 100644 index 0000000000..32f2852a38 --- /dev/null +++ b/external/sgx_libm/ia32/libm_logl.S @@ -0,0 +1,737 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_logl.c" + .text +..TXTST0: +# -- Begin __libm_logl + .text + .align 16,0x90 + .globl __libm_logl +__libm_logl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzbl 17(%ebp), %edi + andl $128, %edi + shrl $7, %edi + movzwl 16(%ebp), %edx + movl %edx, %eax + movl %edi, %ebx + andl $32767, %eax + shll $15, %ebx + movl 12(%ebp), %esi + orl %eax, %ebx + movl %esi, %ecx + shll $16, %ebx + shrl $16, %ecx + orl %ecx, %ebx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $2147450880, %ebx + jae ..B1.32 +..B1.4: + lea -1073674240(%ebx), %edi + cmpl $36864, %edi + ja ..B1.21 +..B1.5: + addl $-1073676287, %ebx + cmpl $32769, %ebx + ja ..B1.14 +..B1.6: + cmpl $16383, %eax + je ..B1.42 +..B1.7: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.41 +..B1.8: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movl $1, %eax +..B1.11: + fldt 8(%ebp) + testl %eax, %eax + fldt 36+_Q1@GOTOFF(%ecx) + fldt 12+_Q1@GOTOFF(%ecx) + fldt 24+_Q1@GOTOFF(%ecx) + fldt _Q1@GOTOFF(%ecx) + fxch %st(4) + faddl 8+_ones@GOTOFF(%ecx) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fadd %st(1), %st + fstpt (%esp) + fstpt 8(%ebp) + je ..B1.13 +..B1.12: + fldcw 14(%esp) +..B1.13: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.15: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.16: + fldcw 12(%esp) +..B1.17: + movl $1, %eax +..B1.18: + fldt 8(%ebp) + testl %eax, %eax + fldl _TWO_52H@GOTOFF(%ecx) + fldt 156+_Q2@GOTOFF(%ecx) + fldt 132+_Q2@GOTOFF(%ecx) + fxch %st(3) + faddl 8+_ones@GOTOFF(%ecx) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fld %st(1) + fsub %st(4), %st + fstpt 16(%esp) + fldt 16(%esp) + fmul %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(0) + fld %st(4) + fmul %st(5), %st + fadd %st, %st(1) + fxch %st(1) + fmul %st, %st(4) + fxch %st(6) + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 108+_Q2@GOTOFF(%ecx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + fldt 84+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 60+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 36+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 12+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 144+_Q2@GOTOFF(%ecx) + fmul %st(6), %st + fldt 120+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(6), %st + fldt 96+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(6), %st + fldt 72+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(6), %st + fldt 48+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(6), %st + fldt 24+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(6) + fldt _Q2@GOTOFF(%ecx) + faddp %st, %st(6) + fxch %st(2) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fldt 180+_Q2@GOTOFF(%ecx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(1) + fld %st(1) + fldt 168+_Q2@GOTOFF(%ecx) + fld %st(0) + fmul %st(4), %st + faddp %st, %st(3) + fldt 16(%esp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(5) + fxch %st(1) + fmul %st(4), %st + fxch %st(2) + fadd %st, %st(4) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.20 +..B1.19: + fldcw 14(%esp) +..B1.20: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.21: + movzwl 14(%esp), %esi + movl %esi, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.49 +..B1.22: + orl $-64768, %esi + movw %si, 12(%esp) +..B1.23: + fldcw 12(%esp) +..B1.24: + movzwl 16(%ebp), %edx + movl %edx, %eax + movl $1, %esi + andl $32767, %eax +..B1.25: + testl %eax, %eax + jne ..B1.28 +..B1.26: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%ecx) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _zeros@GOTOFF(%ecx) + fxch %st(1) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B1.27 + je ..B1.46 +..B1.27: + fstp %st(0) + movzwl 16(%ebp), %edx + movl %edx, %eax + movl $-16458, %ebx + andl $32767, %eax + jmp ..B1.29 +..B1.28: + movl $-16383, %ebx +..B1.29: + fldl _TWO_32H@GOTOFF(%ecx) + andl $-32768, %edx + fldt 60+_P@GOTOFF(%ecx) + orl $-49153, %edx + fldt 36+_P@GOTOFF(%ecx) + addl %eax, %ebx + movw %dx, 16(%ebp) + fldt 8(%ebp) + fld %st(0) + movl 12(%ebp), %eax + fadd %st(4), %st + shrl $23, %eax + fsubp %st, %st(4) + movzbl %al, %eax + fsub %st(3), %st + flds __libm_rcp_table_256@GOTOFF(%ecx,%eax,4) + fmul %st, %st(4) + fmulp %st, %st(1) + fxch %st(3) + faddl 8+_ones@GOTOFF(%ecx) + fld %st(0) + movl %ebx, 16(%esp) + fadd %st(4), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + shll $4, %eax + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + testl %esi, %esi + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fildl 16(%esp) + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(1) + fmulp %st, %st(4) + fldt 48+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st(1), %st + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl 8+__libm_logl_table_256@GOTOFF(%ecx,%eax) + faddp %st, %st(3) + faddl __libm_logl_table_256@GOTOFF(%eax,%ecx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.31 +..B1.30: + fldcw 14(%esp) +..B1.31: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.58 +..B1.33: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.34: + fldcw 12(%esp) +..B1.35: + movzbl 17(%ebp), %edi + movl $1, %edx + andl $128, %edi + shrl $7, %edi +..B1.36: + testl %edi, %edi + jne ..B1.50 +..B1.37: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ecx) + fstpt (%esp) +..B1.38: + testl %edx, %edx + je ..B1.40 +..B1.39: + fldcw 14(%esp) +..B1.40: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + xorl %eax, %eax + jmp ..B1.11 +..B1.42: + cmpl $-2147483648, %esi + jne ..B1.7 +..B1.43: + cmpl $0, 8(%ebp) + jne ..B1.7 +..B1.44: + fldl _zeros@GOTOFF(%ecx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + xorl %eax, %eax + jmp ..B1.18 +..B1.46: + fldl 8+_ones@GOTOFF(%ecx) + testl %esi, %esi + fdivp %st, %st(1) + fstpl (%esp) + je ..B1.48 +..B1.47: + fldcw 14(%esp) +..B1.48: + fldl (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.49: + xorl %esi, %esi + jmp ..B1.25 +..B1.50: + movzwl 16(%ebp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.53 +..B1.51: + cmpl $-2147483648, 12(%ebp) + jne ..B1.37 +..B1.52: + cmpl $0, 8(%ebp) + jne ..B1.37 + jmp ..B1.57 +..B1.53: + testl %eax, %eax + jne ..B1.57 +..B1.54: + cmpl $0, 12(%ebp) + jne ..B1.57 +..B1.55: + cmpl $0, 8(%ebp) + jne ..B1.57 +..B1.56: + fldl 8+_ones@GOTOFF(%ecx) + fdivl _zeros@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.38 +..B1.57: + fldl _infs@GOTOFF(%ecx) + fmull _zeros@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.38 +..B1.58: + xorl %edx, %edx + jmp ..B1.36 + .align 16,0x90 + .type __libm_logl,@function + .size __libm_logl,.-__libm_logl + .data +# -- End __libm_logl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q1: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 5458 + .word 43692 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 44682 + .word 49156 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 63914 + .word 24446 + .word 52434 + .word 52426 + .word 16380 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q2: + .word 58950 + .word 11767 + .word 59949 + .word 40744 + .word 49076 + .word 0 + .word 44486 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 65514 + .word 65535 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 49718 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 36693 + .word 43691 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 41156 + .word 18852 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 14101 + .word 65290 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 21744 + .word 48151 + .word 14557 + .word 58254 + .word 16379 + .word 0 + .word 57454 + .word 983 + .word 52353 + .word 52428 + .word 49147 + .word 0 + .word 54021 + .word 59409 + .word 39452 + .word 47662 + .word 16379 + .word 0 + .word 35608 + .word 4659 + .word 11214 + .word 43692 + .word 49147 + .word 0 + .word 35524 + .word 31332 + .word 8749 + .word 40326 + .word 16379 + .word 0 + .word 54832 + .word 20873 + .word 17674 + .word 36915 + .word 49147 + .word 0 + .word 48567 + .word 9481 + .word 46911 + .word 55870 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .type _Q2,@object + .size _Q2,192 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .type _P,@object + .size _P,72 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_logl_k80.S b/external/sgx_libm/ia32/libm_logl_k80.S new file mode 100644 index 0000000000..f7dd736fcb --- /dev/null +++ b/external/sgx_libm/ia32/libm_logl_k80.S @@ -0,0 +1,1277 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_logl_k80.c" + .text +..TXTST0: +# -- Begin __libm_logl_k80 + .text + .align 16,0x90 + .hidden __libm_logl_k80 + .globl __libm_logl_k80 +__libm_logl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 32 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp + fldt 8(%ebp) + movzbl 17(%ebp), %esi + andl $128, %esi + shrl $7, %esi + movzwl 16(%ebp), %ebx + movl %esi, %eax + movl %ebx, 12(%esp) + andl $32767, %ebx + shll $15, %eax + movl 12(%ebp), %edx + orl %ebx, %eax + movl %edx, %edi + shll $16, %eax + shrl $16, %edi + orl %edi, %eax + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $2147450880, %eax + fstpt 24(%esp) + fldt 24(%esp) + fldt 20(%ebp) + jae ..B1.14 +..B1.2: + lea -1073674240(%eax), %esi + cmpl $36864, %esi + ja ..B1.7 +..B1.3: + addl $-1073676287, %eax + cmpl $32769, %eax + ja ..B1.6 +..B1.4: + fldl _ones@GOTOFF(%ecx) + fucom %st(2) + fnstsw %ax + sahf + jp ..B1.5 + je ..B1.23 +..B1.5: + fldt 36+_Q1@GOTOFF(%ecx) + fld %st(3) + movl 32(%ebp), %eax + fsub %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubrp %st, %st(5) + faddp %st, %st(4) + fld %st(2) + fadd %st(4), %st + fld %st(0) + fxch %st(1) + fsub %st, %st(5) + fxch %st(5) + fsubrp %st, %st(4) + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fldt 12+_Q1@GOTOFF(%ecx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 24+_Q1@GOTOFF(%ecx) + fmul %st(1), %st + fldt _Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(3) + fadd %st(1), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 12(%eax) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.6: + fldl 8+_ones@GOTOFF(%ecx) + fld %st(2) + movl 32(%ebp), %eax + fadd %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fadd %st, %st(1) + fld %st(1) + fld %st(2) + fxch %st(3) + fstpt 24(%esp) + fldt 24(%esp) + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fldl _TWO_52H@GOTOFF(%ecx) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(4) + fxch %st(5) + faddp %st, %st(4) + fxch %st(3) + fstpt (%esp) + fldt (%esp) + fmul %st, %st(3) + fmul %st(2), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fldt 156+_Q2@GOTOFF(%ecx) + fmul %st(1), %st + fldt 132+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 108+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 144+_Q2@GOTOFF(%ecx) + fmul %st(2), %st + fldt 120+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _Q2@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 180+_Q2@GOTOFF(%ecx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(2) + fld %st(2) + fldt 168+_Q2@GOTOFF(%ecx) + fld %st(0) + fmul %st(5), %st + faddp %st, %st(4) + fldt (%esp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fmul %st(1), %st + faddp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%eax) + fldl _ones@GOTOFF(%ecx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.7: + fldl _zeros@GOTOFF(%ecx) + testl %ebx, %ebx + jne ..B1.10 +..B1.8: + fldl _TWO_75@GOTOFF(%ecx) + fmul %st, %st(3) + fxch %st(3) + fucom %st(1) + fnstsw %ax + fxch %st(3) + fmulp %st, %st(2) + sahf + jp ..B1.9 + je ..B1.27 +..B1.9: + fxch %st(2) + fstpt 24(%esp) + movl $-16458, %esi + movzwl 32(%esp), %ebx + movl 28(%esp), %edx + movl %ebx, 12(%esp) + andl $32767, %ebx + jmp ..B1.11 +..B1.10: + fstp %st(2) + movl $-16383, %esi +..B1.11: + addl %ebx, %esi + fucom %st(1) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jp ..B1.12 + je ..B1.13 +..B1.12: + fstpt (%esp) + movzwl 8(%esp), %eax + movl %eax, %edi + subl %ebx, %eax + andl $-32768, %edi + addl $16383, %eax + andl $32767, %eax + orl %eax, %edi + movw %di, 8(%esp) + fldt (%esp) +..B1.13: + fldl _TWO_32H@GOTOFF(%ecx) + fldl 8+_ones@GOTOFF(%ecx) + fldt 60+_P@GOTOFF(%ecx) + movl 12(%esp), %eax + andl $-32768, %eax + orl $-49153, %eax + movw %ax, 32(%esp) + fldt 24(%esp) + fld %st(0) + shrl $23, %edx + fadd %st(4), %st + movzbl %dl, %edx + fsubp %st, %st(4) + movl %esi, 16(%esp) + fsub %st(3), %st + flds __libm_rcp_table_256@GOTOFF(%ecx,%edx,4) + fmul %st, %st(4) + fmul %st, %st(1) + fmulp %st, %st(5) + fxch %st(4) + fstpt (%esp) + fldt (%esp) + fld %st(2) + shll $4, %edx + fadd %st(4), %st + movl 32(%ebp), %ebx + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fld %st(3) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fadd %st, %st(3) + fld %st(3) + fmul %st(4), %st + fmul %st, %st(2) + fxch %st(4) + fstpt 24(%esp) + fldt 24(%esp) + fildl 16(%esp) + fldt 36+_P@GOTOFF(%ecx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fmulp %st, %st(1) + fldt 48+_P@GOTOFF(%ecx) + fmul %st(5), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt _P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + faddp %st, %st(3) + fldt .L_2il0floatpacket.2@GOTOFF(%ecx) + fmul %st(1), %st + fldt .L_2il0floatpacket.3@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl 8+__libm_logl_table_256@GOTOFF(%ecx,%edx) + faddp %st, %st(3) + faddl __libm_logl_table_256@GOTOFF(%edx,%ecx) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt (%ebx) + fldt (%ebx) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 12(%ebx) + fldl _ones@GOTOFF(%ecx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + fstp %st(0) + testl %esi, %esi + jne ..B1.16 +..B1.15: + fldl _ones@GOTOFF(%ecx) + fmul %st, %st(1) + fldl _zeros@GOTOFF(%ecx) + fxch %st(2) + fxch %st(1) + jmp ..B1.22 +..B1.16: + cmpl $32767, %ebx + je ..B1.25 +..B1.17: + fstp %st(0) + testl %ebx, %ebx + jne ..B1.21 +..B1.18: + testl %edx, %edx + jne ..B1.21 +..B1.19: + cmpl $0, 24(%esp) + jne ..B1.21 +..B1.20: + fldl _zeros@GOTOFF(%ecx) + fldl 8+_ones@GOTOFF(%ecx) + fdiv %st(1), %st + fldl _ones@GOTOFF(%ecx) + jmp ..B1.22 +..B1.21: + fldl _zeros@GOTOFF(%ecx) + fldl _infs@GOTOFF(%ecx) + fmul %st(1), %st + fldl _ones@GOTOFF(%ecx) +..B1.22: + movl 32(%ebp), %eax + fxch %st(1) + fstpt (%eax) + fxch %st(1) + fstpt 12(%eax) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + fldl _zeros@GOTOFF(%ecx) + fucom %st(2) + fnstsw %ax + sahf + jp ..B1.30 + je ..B1.24 +..B1.30: + fstp %st(0) + jmp ..B1.5 +..B1.24: + fstp %st(1) + fstp %st(2) + fstp %st(0) + movl 32(%ebp), %eax + fld %st(0) + fxch %st(1) + fstpt (%eax) + fldt (%eax) + fstpt 12(%eax) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + cmpl $-2147483648, %edx + jne ..B1.15 +..B1.26: + cmpl $0, 24(%esp) + jne ..B1.15 + jmp ..B1.31 +..B1.27: + fstp %st(2) + fstp %st(0) + fldl 8+_ones@GOTOFF(%ecx) + fdiv %st(1), %st + movl 32(%ebp), %eax + fstpt (%eax) + fstpt 12(%eax) + fldl _ones@GOTOFF(%ecx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + fstp %st(0) + jmp ..B1.21 + .align 16,0x90 + .type __libm_logl_k80,@function + .size __libm_logl_k80,.-__libm_logl_k80 + .data +# -- End __libm_logl_k80 + .text +# -- Begin __libm_log_k80 + .text + .align 16,0x90 + .hidden __libm_log_k80 + .globl __libm_log_k80 +__libm_log_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $100, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 84(%esp) + addl $4, %esp + movl 12(%ebp), %ebx + pushl %ebx + call __libm_normalizel_k80 +..B2.2: + fldt (%ebx) + fldt 12(%ebx) + movl 24(%ebx), %eax + cmpl $-1, %eax + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + je ..B2.41 +..B2.3: + movl %eax, 48(%esp) + fildl 48(%esp) +..B2.4: + fxch %st(2) + fstpt 32(%esp) + fldt 32(%esp) + movzbl 41(%esp), %esi + andl $128, %esi + shrl $7, %esi + movzwl 40(%esp), %edx + movl %esi, %eax + movl %edx, 28(%esp) + andl $32767, %edx + shll $15, %eax + movl 36(%esp), %ecx + orl %edx, %eax + movl %ecx, %edi + shll $16, %eax + shrl $16, %edi + orl %edi, %eax + cmpl $2147450880, %eax + jae ..B2.17 +..B2.5: + lea -1073674240(%eax), %esi + cmpl $36864, %esi + ja ..B2.10 +..B2.6: + fldl _ones@GOTOFF(%ebx) + addl $-1073676287, %eax + cmpl $32769, %eax + ja ..B2.9 +..B2.7: + fucom %st(1) + fnstsw %ax + sahf + jp ..B2.8 + je ..B2.35 +..B2.8: + fldt 12+_Q1@GOTOFF(%ebx) + fld %st(2) + fsub %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + fld %st(3) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(4) + fld %st(2) + fadd %st(4), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(3) + fmul %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 24+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + fldt _Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(3) + jmp ..B2.26 +..B2.9: + fldl 8+_ones@GOTOFF(%ebx) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(3) + fstpt 32(%esp) + fld %st(0) + fadd %st(2), %st + fld %st(0) + fld %st(1) + fxch %st(5) + fstpt 16(%esp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fldl _TWO_52H@GOTOFF(%ebx) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fxch %st(4) + fstpt 48(%esp) + fldt 48(%esp) + fmul %st, %st(4) + fmul %st(3), %st + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fldt 156+_Q2@GOTOFF(%ebx) + fmul %st(1), %st + fldt 132+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 108+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 144+_Q2@GOTOFF(%ebx) + fmul %st(2), %st + fldt 120+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _Q2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 180+_Q2@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fmulp %st, %st(3) + fld %st(0) + fldt 168+_Q2@GOTOFF(%ebx) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(5) + fldt 48(%esp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + fmul %st(3), %st + fxch %st(3) + fadd %st(4), %st + fmul %st(1), %st + faddp %st, %st(3) + faddp %st, %st(2) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%esp) + fldt 16(%esp) + fxch %st(3) + fxch %st(1) + jmp ..B2.26 +..B2.10: + fldl _zeros@GOTOFF(%ebx) + testl %edx, %edx + jne ..B2.13 +..B2.11: + fldl _TWO_75@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + fucom %st(1) + fnstsw %ax + fxch %st(2) + fmulp %st, %st(3) + sahf + jp ..B2.12 + je ..B2.37 +..B2.12: + fxch %st(1) + fstpt 32(%esp) + movl $-16458, %esi + movzwl 40(%esp), %edx + movl 36(%esp), %ecx + movl %edx, 28(%esp) + andl $32767, %edx + jmp ..B2.14 +..B2.13: + fstp %st(1) + movl $-16383, %esi +..B2.14: + addl %edx, %esi + fucomp %st(1) + fnstsw %ax + sahf + jp ..B2.15 + je ..B2.16 +..B2.15: + fstpt 16(%esp) + movzwl 24(%esp), %eax + movl %eax, %edi + subl %edx, %eax + andl $-32768, %edi + addl $16383, %eax + andl $32767, %eax + orl %eax, %edi + movw %di, 24(%esp) + fldt 16(%esp) +..B2.16: + fldl _TWO_32H@GOTOFF(%ebx) + fldt 36+_P@GOTOFF(%ebx) + movl 28(%esp), %eax + andl $-32768, %eax + orl $-49153, %eax + movw %ax, 40(%esp) + fldt 32(%esp) + fld %st(0) + shrl $23, %ecx + fadd %st(3), %st + movzbl %cl, %ecx + fsubp %st, %st(3) + movl %esi, 48(%esp) + fsub %st(2), %st + fildl 48(%esp) + flds __libm_rcp_table_256@GOTOFF(%ebx,%ecx,4) + fmul %st, %st(4) + fmul %st, %st(2) + fmulp %st, %st(5) + shll $4, %ecx + fxch %st(1) + faddp %st, %st(4) + fldl 8+_ones@GOTOFF(%ebx) + fld %st(0) + fadd %st(4), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(5) + faddp %st, %st(2) + fxch %st(5) + faddp %st, %st(1) + fadd %st, %st(4) + fld %st(4) + fmul %st(5), %st + fldt 60+_P@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(4) + fmul %st, %st(3) + fldt 12+_P@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fxch %st(5) + fmulp %st, %st(3) + fldt 48+_P@GOTOFF(%ebx) + fmul %st(5), %st + fldt 24+_P@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(5), %st + fldt _P@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fmul %st(1), %st + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fmulp %st, %st(2) + faddl 8+__libm_logl_table_256@GOTOFF(%ebx,%ecx) + faddp %st, %st(3) + fldl _ones@GOTOFF(%ebx) + fxch %st(1) + faddl __libm_logl_table_256@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + jmp ..B2.26 +..B2.17: + fstp %st(1) + testl %esi, %esi + jne ..B2.19 +..B2.18: + fldl _ones@GOTOFF(%ebx) + fmul %st, %st(1) + fldl _zeros@GOTOFF(%ebx) + fxch %st(2) + fxch %st(1) + jmp ..B2.26 +..B2.19: + cmpl $32767, %edx + je ..B2.39 +..B2.20: + fstp %st(0) + testl %edx, %edx + jne ..B2.24 +..B2.21: + testl %ecx, %ecx + jne ..B2.24 +..B2.22: + cmpl $0, 32(%esp) + jne ..B2.24 +..B2.23: + fldl _zeros@GOTOFF(%ebx) + fldl 8+_ones@GOTOFF(%ebx) + fdiv %st(1), %st + fldl _ones@GOTOFF(%ebx) + jmp ..B2.26 +..B2.24: + fldl _zeros@GOTOFF(%ebx) + fldl _infs@GOTOFF(%ebx) + fmul %st(1), %st + fldl _ones@GOTOFF(%ebx) +..B2.26: + fldt 12+_LN2_K80@GOTOFF(%ebx) + lea 72(%esp), %edx + fmul %st(4), %st + movl 8(%ebp), %eax + fstpt -44(%edx) + fldt -44(%edx) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fstpt -12(%edx) + fldt -12(%edx) + fxch %st(3) + fmulp %st, %st(2) + movzwl -4(%edx), %esi + andl $32767, %esi + fxch %st(1) + fstpt (%edx) + fldt (%edx) + fldt _LN2_K80@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + fstpt -56(%edx) + fldt -56(%edx) + fld %st(2) + movzwl -48(%edx), %ecx + fadd %st(1), %st + andl $32767, %ecx + movl $0, 24(%eax) + cmpl %esi, %ecx + jg ..B2.31 +..B2.27: + jne ..B2.32 +..B2.28: + movl 20(%esp), %edx + movl 64(%esp), %ecx + cmpl %ecx, %edx + ja ..B2.31 +..B2.29: + jne ..B2.32 +..B2.30: + movl 16(%esp), %edx + cmpl 60(%esp), %edx + jbe ..B2.32 +..B2.31: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + jmp ..B2.33 +..B2.32: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) +..B2.33: + fld %st(0) + fadd %st(2), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 12(%eax) + movl 84(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.38 +..B2.34: + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.35: + fldl _zeros@GOTOFF(%ebx) + fucom %st(3) + fnstsw %ax + sahf + jp ..B2.44 + je ..B2.36 +..B2.44: + fstp %st(0) + jmp ..B2.8 +..B2.36: + fstp %st(2) + fstp %st(2) + fstp %st(1) + fld %st(0) + fld %st(1) + fxch %st(1) + fxch %st(2) + fxch %st(1) + jmp ..B2.26 +..B2.37: + fstp %st(1) + fstp %st(1) + fldl 8+_ones@GOTOFF(%ebx) + fdiv %st(1), %st + fldl _ones@GOTOFF(%ebx) + jmp ..B2.26 +..B2.38: + call __stack_chk_fail@PLT +..B2.39: + cmpl $-2147483648, %ecx + jne ..B2.18 +..B2.40: + cmpl $0, 32(%esp) + jne ..B2.18 + jmp ..B2.45 +..B2.41: + fldl _zeros@GOTOFF(%ebx) + fldt halfs@GOTOFF(%ebx) + fmul %st, %st(3) + fmulp %st, %st(2) + jmp ..B2.4 +..B2.45: + fstp %st(0) + jmp ..B2.24 + .align 16,0x90 + .type __libm_log_k80,@function + .size __libm_log_k80,.-__libm_log_k80 + .data +# -- End __libm_log_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +halfs: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00 + .type halfs,@object + .size halfs,24 + .align 2 +_Q1: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 5458 + .word 43692 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 44682 + .word 49156 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 63914 + .word 24446 + .word 52434 + .word 52426 + .word 16380 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q2: + .word 58950 + .word 11767 + .word 59949 + .word 40744 + .word 49076 + .word 0 + .word 44486 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 65514 + .word 65535 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 49718 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 36693 + .word 43691 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 41156 + .word 18852 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 14101 + .word 65290 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 21744 + .word 48151 + .word 14557 + .word 58254 + .word 16379 + .word 0 + .word 57454 + .word 983 + .word 52353 + .word 52428 + .word 49147 + .word 0 + .word 54021 + .word 59409 + .word 39452 + .word 47662 + .word 16379 + .word 0 + .word 35608 + .word 4659 + .word 11214 + .word 43692 + .word 49147 + .word 0 + .word 35524 + .word 31332 + .word 8749 + .word 40326 + .word 16379 + .word 0 + .word 54832 + .word 20873 + .word 17674 + .word 36915 + .word 49147 + .word 0 + .word 48567 + .word 9481 + .word 46911 + .word 55870 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .type _Q2,@object + .size _Q2,192 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .type _P,@object + .size _P,72 + .align 2 +_LN2_K80: + .word 0 + .word 0 + .word 6136 + .word 45426 + .word 16382 + .word 0 + .word 12704 + .word 55409 + .word 6480 + .word 47298 + .word 49116 + .word 0 + .type _LN2_K80,@object + .size _LN2_K80,24 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .hidden __libm_normalizel_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_normalizel_k80.S b/external/sgx_libm/ia32/libm_normalizel_k80.S new file mode 100644 index 0000000000..66068b39a5 --- /dev/null +++ b/external/sgx_libm/ia32/libm_normalizel_k80.S @@ -0,0 +1,163 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_normalizel_k80.c" + .text +..TXTST0: +# -- Begin __libm_normalizel_k80 + .text + .align 16,0x90 + .hidden __libm_normalizel_k80 + .globl __libm_normalizel_k80 +__libm_normalizel_k80: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + pushl %ebp + movl 16(%esp), %ecx + cmpl $0, 4(%ecx) + jne ..B1.3 +..B1.2: + cmpl $0, (%ecx) + je ..B1.14 +..B1.3: + movzwl 8(%ecx), %ebx + movl %ebx, %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.14 +..B1.4: + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + testl %eax, %eax + jle ..B1.16 +..B1.5: + andl $-32768, %ebx + addl $-16383, %eax + orl $-49153, %ebx +..B1.6: + movw %bx, 8(%ecx) + cmpl $0, 16(%ecx) + jne ..B1.8 +..B1.7: + cmpl $0, 12(%ecx) + je ..B1.13 +..B1.8: + movzwl 20(%ecx), %ebp + movl %ebp, %edi + andl $32767, %edi + jle ..B1.15 +..B1.9: + andl $-32768, %ebp + addl $-16383, %edi + orl $-49153, %ebp +..B1.10: + lea -256(%eax), %ebx + cmpl %ebx, %edi + jle ..B1.12 +..B1.11: + subl %eax, %edi + andl $-32768, %ebp + addl $16383, %edi + andl $32767, %edi + orl %edi, %ebp + movw %bp, 20(%ecx) + jmp ..B1.13 +..B1.12: + fldt _CONSTANTS@GOTOFF(%edx) + fstpt 12(%ecx) +..B1.13: + addl %eax, 24(%ecx) +..B1.14: + popl %ebp + popl %ebx + popl %edi + ret +..B1.15: + fldt 12(%ecx) + fldt 12+_CONSTANTS@GOTOFF(%edx) + fmulp %st, %st(1) + fstpt 12(%ecx) + movzwl 20(%ecx), %ebp + movl %ebp, %edi + andl $32767, %edi + andl $-32768, %ebp + addl $-16639, %edi + orl $-49153, %ebp + jmp ..B1.10 +..B1.16: + fldt (%ecx) + fldt 12+_CONSTANTS@GOTOFF(%edx) + fmulp %st, %st(1) + fstpt (%ecx) + movzwl 8(%ecx), %ebx + movl %ebx, %eax + andl $32767, %eax + andl $-32768, %ebx + addl $-16639, %eax + orl $-49153, %ebx + jmp ..B1.6 + .align 16,0x90 + .type __libm_normalizel_k80,@function + .size __libm_normalizel_k80,.-__libm_normalizel_k80 + .data +# -- End __libm_normalizel_k80 + .section .rodata, "a" + .align 16 + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_recacoshl_k80.S b/external/sgx_libm/ia32/libm_recacoshl_k80.S new file mode 100644 index 0000000000..529a516ef0 --- /dev/null +++ b/external/sgx_libm/ia32/libm_recacoshl_k80.S @@ -0,0 +1,1806 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_recacoshl_k80.c" + .text +..TXTST0: +# -- Begin __libm_recacoshl_k80 + .text + .align 16,0x90 + .hidden __libm_recacoshl_k80 + .globl __libm_recacoshl_k80 +__libm_recacoshl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +# parameter 4: 20 + %ebp +# parameter 5: 24 + %ebp +# parameter 6: 28 + %ebp +# parameter 7: 32 + %ebp +# parameter 8: 36 + %ebp +# parameter 9: 40 + %ebp +# parameter 10: 44 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $436, %esp + movl 8(%ebp), %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + movl %eax, 76(%esp) + movzwl 8(%ecx), %eax + andl $32767, %eax + movl %gs:20, %edx + xorl %esp, %edx + movl %edx, 428(%esp) + cmpl $16383, %eax + movl 24(%ebp), %ebx + movl 40(%ebp), %esi + jl ..B1.33 +..B1.2: + movzwl 8(%esi), %ecx + movl %ecx, %edi + andl $32767, %edi + cmpl $8383, %edi + jl ..B1.6 +..B1.3: + cmpl $24383, %edi + jg ..B1.6 +..B1.4: + movzwl 8(%ebx), %edx + movl %edx, 44(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.6 +..B1.5: + cmpl $24383, %edx + jle ..B1.9 +..B1.6: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B1.7: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B1.8: + movzwl 8(%esi), %ecx + movl %ecx, %edi + movzwl 8(%ebx), %edx + andl $32767, %edi + movl %edx, 44(%esp) + andl $32767, %edx +..B1.9: + movl 24(%ebx), %eax + movl 24(%esi), %esi + movl %eax, 52(%esp) + movl %esi, 48(%esp) + lea -134(%eax,%edx), %eax + addl %edi, %esi + movl %esi, 36(%esp) + cmpl %esi, %eax + movl 40(%ebp), %esi + jge ..B1.26 +..B1.10: + movl 4(%esi), %eax + movl %eax, 32(%esp) + movl 52(%esp), %eax + lea 134(%eax,%edx), %eax + cmpl 36(%esp), %eax + jle ..B1.27 +..B1.11: + cmpl $0, 32(%esp) + jne ..B1.13 +..B1.12: + cmpl $0, (%esi) + je ..B1.28 +..B1.13: + cmpl $0, 4(%ebx) + jne ..B1.15 +..B1.14: + cmpl $0, (%ebx) + je ..B1.27 +..B1.15: + movl 52(%esp), %eax + cmpl 48(%esp), %eax + je ..B1.17 +..B1.16: + fldt (%esi) + fldt 12(%esi) + movl 48(%esp), %ecx + movl %eax, %edx + subl %edx, %ecx + andb $127, 41(%esp) + addl $16383, %ecx + movzwl 40(%esp), %eax + andl $32767, %ecx + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 24(%esi) + fxch %st(2) + fstpt (%esi) + fldt (%esi) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esi) + fldt 12(%esi) + movl 24(%ebx), %edi + movzwl 8(%ebx), %eax + movl %edi, 52(%esp) + movzwl 8(%esi), %ecx + movl %eax, 44(%esp) + jmp ..B1.18 +..B1.17: + fldt (%esi) + fldt 12(%esi) +..B1.18: + fldt (%ebx) + andl $32767, %ecx + movl 44(%esp), %edx + fld %st(2) + andl $32767, %edx + fadd %st(1), %st + movl 52(%esp), %eax + cmpl %edx, %ecx + movl %eax, 116(%esp) + jg ..B1.23 +..B1.19: + jne ..B1.24 +..B1.20: + movl 4(%esi), %eax + cmpl 4(%ebx), %eax + ja ..B1.23 +..B1.21: + jne ..B1.24 +..B1.22: + movl (%esi), %eax + cmpl (%ebx), %eax + jbe ..B1.24 +..B1.23: + fldt 12(%ebx) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%esp) + fldt 32(%esp) + jmp ..B1.25 +..B1.24: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%ebx) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) +..B1.25: + fld %st(0) + fadd %st(2), %st + fstpt 92(%esp) + fldt 92(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 104(%esp) + jmp ..B1.32 +..B1.26: + movl 4(%esi), %eax + movl %eax, 32(%esp) +..B1.27: + cmpl $0, 32(%esp) + jne ..B1.29 +..B1.225: + cmpl $0, (%esi) +..B1.28: + je ..B1.30 +..B1.29: + movl 52(%esp), %eax + lea -16517(%eax,%edx), %ecx + movl 48(%esp), %edx + lea -16383(%edx,%edi), %edi + cmpl %edi, %ecx + jl ..B1.31 +..B1.30: + movl (%ebx), %eax + movl %eax, 92(%esp) + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl 12(%ebx), %esi + movl 16(%ebx), %edi + movl 20(%ebx), %eax + movl 24(%ebx), %ebx + movl %edx, 96(%esp) + movl %ecx, 100(%esp) + movl %esi, 104(%esp) + movl %edi, 108(%esp) + movl %eax, 112(%esp) + movl %ebx, 116(%esp) + jmp ..B1.32 +..B1.31: + movl (%esi), %eax + movl %eax, 92(%esp) + movl 4(%esi), %edx + movl 8(%esi), %ecx + movl 12(%esi), %ebx + movl 16(%esi), %edi + movl 20(%esi), %eax + movl 24(%esi), %esi + movl %edx, 96(%esp) + movl %ecx, 100(%esp) + movl %ebx, 104(%esp) + movl %edi, 108(%esp) + movl %eax, 112(%esp) + movl %esi, 116(%esp) +..B1.32: + movl 76(%esp), %eax + movl $0, 144(%esp) + fldt .L_2il0floatpacket.10@GOTOFF(%eax) + fstpt 120(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%eax) + fstpt 132(%esp) + fldt 132(%esp) + jmp ..B1.63 +..B1.33: + movl 32(%ebp), %eax + movl 4(%eax), %ecx + movl 8(%eax), %edi + movl %ecx, 96(%esp) + movl 16(%eax), %ecx + movl %edi, 100(%esp) + movl 20(%eax), %edi + movl %ecx, 108(%esp) + movl (%eax), %edx + movzwl 8(%esi), %ecx + movl %edi, 112(%esp) + movl %ecx, %edi + movl %edx, 92(%esp) + andl $32767, %edi + movl 12(%eax), %edx + cmpl $8383, %edi + movl 24(%eax), %eax + movl %edx, 104(%esp) + movl %eax, 116(%esp) + jl ..B1.37 +..B1.34: + cmpl $24383, %edi + jg ..B1.37 +..B1.35: + movzwl 8(%ebx), %edx + movl %edx, 44(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.37 +..B1.36: + cmpl $24383, %edx + jle ..B1.40 +..B1.37: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B1.38: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B1.39: + movzwl 8(%esi), %ecx + movl %ecx, %edi + movzwl 8(%ebx), %edx + andl $32767, %edi + movl %edx, 44(%esp) + andl $32767, %edx +..B1.40: + movl 24(%ebx), %eax + movl 24(%esi), %esi + movl %eax, 52(%esp) + movl %esi, 48(%esp) + lea -134(%eax,%edx), %eax + addl %edi, %esi + movl %esi, 36(%esp) + cmpl %esi, %eax + movl 40(%ebp), %esi + jge ..B1.57 +..B1.41: + movl 4(%esi), %eax + movl %eax, 32(%esp) + movl 52(%esp), %eax + lea 134(%eax,%edx), %eax + cmpl 36(%esp), %eax + jle ..B1.58 +..B1.42: + cmpl $0, 32(%esp) + jne ..B1.44 +..B1.43: + cmpl $0, (%esi) + je ..B1.59 +..B1.44: + cmpl $0, 4(%ebx) + jne ..B1.46 +..B1.45: + cmpl $0, (%ebx) + je ..B1.58 +..B1.46: + movl 52(%esp), %eax + cmpl 48(%esp), %eax + je ..B1.48 +..B1.47: + fldt (%esi) + fldt 12(%esi) + movl 48(%esp), %ecx + movl %eax, %edx + subl %edx, %ecx + andb $127, 41(%esp) + addl $16383, %ecx + movzwl 40(%esp), %eax + andl $32767, %ecx + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 24(%esi) + fxch %st(2) + fstpt (%esi) + fldt (%esi) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esi) + fldt 12(%esi) + movl 24(%ebx), %edi + movzwl 8(%ebx), %eax + movl %edi, 52(%esp) + movzwl 8(%esi), %ecx + movl %eax, 44(%esp) + jmp ..B1.49 +..B1.48: + fldt (%esi) + fldt 12(%esi) +..B1.49: + fldt (%ebx) + andl $32767, %ecx + movl 44(%esp), %edx + fld %st(2) + andl $32767, %edx + fsub %st(1), %st + movl 52(%esp), %eax + cmpl %edx, %ecx + movl %eax, 144(%esp) + jg ..B1.54 +..B1.50: + jne ..B1.55 +..B1.51: + movl 4(%esi), %eax + cmpl 4(%ebx), %eax + ja ..B1.54 +..B1.52: + jne ..B1.55 +..B1.53: + movl (%esi), %eax + cmpl (%ebx), %eax + jbe ..B1.55 +..B1.54: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 12(%ebx) + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 32(%esp) + fldt 32(%esp) + jmp ..B1.56 +..B1.55: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%ebx) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) +..B1.56: + fld %st(1) + movl 76(%esp), %eax + fadd %st(1), %st + fstpt 120(%esp) + fldt 120(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 132(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%eax) + jmp ..B1.63 +..B1.57: + movl 4(%esi), %eax + movl %eax, 32(%esp) +..B1.58: + cmpl $0, 32(%esp) + jne ..B1.60 +..B1.224: + cmpl $0, (%esi) +..B1.59: + je ..B1.61 +..B1.60: + movl 52(%esp), %eax + lea -16517(%eax,%edx), %ecx + movl 48(%esp), %edx + lea -16383(%edx,%edi), %edi + cmpl %edi, %ecx + jl ..B1.62 +..B1.61: + fldt (%ebx) + movl 76(%esp), %edx + fchs + movl 52(%esp), %eax + movl %eax, 144(%esp) + fstpt 120(%esp) + fldt 12(%ebx) + fchs + fstpt 132(%esp) + fldt .L_2il0floatpacket.9@GOTOFF(%edx) + jmp ..B1.63 +..B1.62: + movl (%esi), %eax + movl %eax, 120(%esp) + movl 20(%esi), %eax + movl %eax, 140(%esp) + movl 76(%esp), %eax + movl 4(%esi), %edx + movl 8(%esi), %ecx + fldt .L_2il0floatpacket.9@GOTOFF(%eax) + movl 12(%esi), %ebx + movl 16(%esi), %edi + movl 24(%esi), %esi + movl %edx, 124(%esp) + movl %ecx, 128(%esp) + movl %ebx, 132(%esp) + movl %edi, 136(%esp) + movl %esi, 144(%esp) +..B1.63: + movl 44(%ebp), %edx + movl 76(%esp), %eax + movl $0, 172(%esp) + movzwl 8(%edx), %ecx + movl %ecx, %ebx + fldt .L_2il0floatpacket.11@GOTOFF(%eax) + andl $32767, %ebx + fstpt 148(%esp) + cmpl $8383, %ebx + fstpt 160(%esp) + jl ..B1.67 +..B1.64: + cmpl $24383, %ebx + jg ..B1.67 +..B1.65: + movzwl 156(%esp), %edx + movl %edx, 48(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.67 +..B1.66: + cmpl $24383, %edx + jle ..B1.70 +..B1.67: + addl $4, %esp + pushl 44(%ebp) + call __libm_normalizel_k80 +..B1.68: + addl $4, %esp + lea 144(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.69: + movl 44(%ebp), %ecx + movzwl 156(%esp), %edx + movl %edx, 48(%esp) + andl $32767, %edx + movzwl 8(%ecx), %ecx + movl %ecx, %ebx + andl $32767, %ebx +..B1.70: + movl 44(%ebp), %esi + movl 172(%esp), %eax + movl 24(%esi), %edi + movl %edi, 56(%esp) + lea (%ebx,%edi), %esi + movl %esi, 52(%esp) + lea -134(%eax,%edx), %edi + cmpl %edi, %esi + jle ..B1.87 +..B1.71: + movl 44(%ebp), %esi + movl 4(%esi), %edi + lea 134(%eax,%edx), %esi + movl %edi, 44(%esp) + cmpl 52(%esp), %esi + jle ..B1.88 +..B1.72: + cmpl $0, 44(%esp) + jne ..B1.74 +..B1.73: + movl 44(%ebp), %esi + cmpl $0, (%esi) + je ..B1.89 +..B1.74: + cmpl $0, 152(%esp) + jne ..B1.76 +..B1.75: + cmpl $0, 148(%esp) + je ..B1.88 +..B1.76: + cmpl 56(%esp), %eax + je ..B1.78 +..B1.77: + movl 56(%esp), %edx + subl %eax, %edx + andb $127, 41(%esp) + addl $16383, %edx + movl 44(%ebp), %ebx + andl $32767, %edx + movzwl 40(%esp), %ecx + andl $-32768, %ecx + fldt (%ebx) + orl %edx, %ecx + fldt 12(%ebx) + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %eax, 24(%ebx) + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt 12(%ebx) + movzwl 8(%ebx), %ecx + jmp ..B1.79 +..B1.78: + movl 44(%ebp), %edx + fldt (%edx) + fldt 12(%edx) +..B1.79: + fldt 148(%esp) + andl $32767, %ecx + movl %eax, 200(%esp) + fld %st(2) + movl 48(%esp), %eax + fadd %st(1), %st + andl $32767, %eax + cmpl %eax, %ecx + jg ..B1.84 +..B1.80: + movl 48(%esp), %eax + andl $32767, %eax + cmpl %eax, %ecx + jne ..B1.85 +..B1.81: + movl 44(%ebp), %eax + movl 4(%eax), %edx + cmpl 152(%esp), %edx + ja ..B1.84 +..B1.82: + jne ..B1.85 +..B1.83: + movl 44(%ebp), %eax + movl (%eax), %edx + cmpl 148(%esp), %edx + jbe ..B1.85 +..B1.84: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 160(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.86 +..B1.85: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 160(%esp) + faddp %st, %st(1) +..B1.86: + fld %st(0) + fadd %st(2), %st + fstpt 176(%esp) + fldt 176(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 188(%esp) + jmp ..B1.93 +..B1.87: + movl 44(%ebp), %ecx + movl 4(%ecx), %esi + movl %esi, 44(%esp) +..B1.88: + cmpl $0, 44(%esp) + jne ..B1.90 +..B1.226: + movl 44(%ebp), %ecx + cmpl $0, (%ecx) +..B1.89: + je ..B1.91 +..B1.90: + lea -16517(%eax,%edx), %ecx + movl 56(%esp), %edx + lea -16383(%edx,%ebx), %ebx + cmpl %ebx, %ecx + jl ..B1.92 +..B1.91: + movl 148(%esp), %edx + movl %edx, 176(%esp) + movl 152(%esp), %ecx + movl 156(%esp), %ebx + movl 160(%esp), %esi + movl 164(%esp), %edi + movl 168(%esp), %edx + movl %ecx, 180(%esp) + movl %ebx, 184(%esp) + movl %esi, 188(%esp) + movl %edi, 192(%esp) + movl %edx, 196(%esp) + movl %eax, 200(%esp) + jmp ..B1.93 +..B1.92: + movl 44(%ebp), %eax + movl (%eax), %edx + movl %edx, 176(%esp) + movl 4(%eax), %ecx + movl 8(%eax), %ebx + movl 12(%eax), %esi + movl 16(%eax), %edi + movl 20(%eax), %edx + movl 24(%eax), %eax + movl %ecx, 180(%esp) + movl %ebx, 184(%esp) + movl %esi, 188(%esp) + movl %edi, 192(%esp) + movl %edx, 196(%esp) + movl %eax, 200(%esp) +..B1.93: + movzwl 184(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.97 +..B1.94: + cmpl $24383, %eax + jg ..B1.97 +..B1.95: + movzwl 100(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.97 +..B1.96: + cmpl $24383, %eax + jle ..B1.99 +..B1.97: + addl $4, %esp + lea 172(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.98: + addl $4, %esp + lea 88(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.99: + fldt 176(%esp) + movl 76(%esp), %edx + fld %st(0) + fld %st(1) + fldt 92(%esp) + fld %st(0) + fldt .L_2il0floatpacket.12@GOTOFF(%edx) + fld %st(0) + fmul %st(6), %st + movl 36(%ebp), %esi + fsubr %st, %st(5) + movzwl 8(%esi), %edi + movl %edi, %ecx + movl 200(%esp), %eax + andl $32767, %ecx + addl 116(%esp), %eax + faddp %st, %st(5) + fld %st(4) + fld %st(3) + fxch %st(2) + fstpt 48(%esp) + fldt 48(%esp) + cmpl $8383, %ecx + fmul %st(4), %st + movl 28(%ebp), %ebx + fsubr %st, %st(3) + movl %eax, 228(%esp) + faddp %st, %st(3) + fmul %st(2), %st + fxch %st(4) + fsub %st(5), %st + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 104(%esp) + fmulp %st, %st(4) + fldt 188(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 204(%esp) + fldt 204(%esp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 216(%esp) + fstpt 64(%esp) + jl ..B1.103 +..B1.100: + cmpl $24383, %ecx + jg ..B1.103 +..B1.101: + movzwl 8(%ebx), %edx + movl %edx, 60(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.103 +..B1.102: + cmpl $24383, %edx + jle ..B1.106 +..B1.103: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B1.104: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B1.105: + movzwl 8(%esi), %edi + movl %edi, %ecx + movzwl 8(%ebx), %edx + andl $32767, %ecx + movl %edx, 60(%esp) + andl $32767, %edx +..B1.106: + movl 24(%ebx), %eax + movl 24(%esi), %esi + movl %eax, 88(%esp) + movl %esi, 84(%esp) + lea -134(%eax,%edx), %eax + addl %ecx, %esi + movl %esi, 80(%esp) + cmpl %eax, %esi + movl 36(%ebp), %esi + jle ..B1.123 +..B1.107: + movl 4(%esi), %eax + movl %eax, 44(%esp) + movl 88(%esp), %eax + lea 134(%eax,%edx), %eax + cmpl 80(%esp), %eax + jle ..B1.124 +..B1.108: + cmpl $0, 44(%esp) + jne ..B1.110 +..B1.109: + cmpl $0, (%esi) + je ..B1.125 +..B1.110: + cmpl $0, 4(%ebx) + jne ..B1.112 +..B1.111: + cmpl $0, (%ebx) + je ..B1.124 +..B1.112: + movl 88(%esp), %eax + cmpl 84(%esp), %eax + je ..B1.114 +..B1.113: + fldt 64(%esp) + movl 84(%esp), %edi + movl %eax, %edx + subl %edx, %edi + fstpt 32(%esp) + addl $16383, %edi + fldt (%esi) + andl $32767, %edi + fldt 12(%esi) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 24(%esi) + fxch %st(2) + fstpt (%esi) + fldt (%esi) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esi) + fldt 12(%esi) + movl 24(%ebx), %ecx + movzwl 8(%ebx), %eax + movl %ecx, 88(%esp) + movzwl 8(%esi), %edi + movl %eax, 60(%esp) + jmp ..B1.115 +..B1.114: + fldt (%esi) + fldt 12(%esi) +..B1.115: + fldt (%ebx) + andl $32767, %edi + movl 60(%esp), %edx + fld %st(2) + andl $32767, %edx + fadd %st(1), %st + movl 88(%esp), %eax + cmpl %edx, %edi + movl %eax, 256(%esp) + jg ..B1.120 +..B1.116: + jne ..B1.121 +..B1.117: + movl 4(%esi), %eax + cmpl 4(%ebx), %eax + ja ..B1.120 +..B1.118: + jne ..B1.121 +..B1.119: + movl (%esi), %eax + cmpl (%ebx), %eax + jbe ..B1.121 +..B1.120: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 12(%ebx) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.122 +..B1.121: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 12(%ebx) + faddp %st, %st(1) +..B1.122: + fld %st(0) + fadd %st(2), %st + fstpt 232(%esp) + fldt 232(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 244(%esp) + jmp ..B1.129 +..B1.123: + movl 4(%esi), %eax + movl %eax, 44(%esp) +..B1.124: + cmpl $0, 44(%esp) + jne ..B1.126 +..B1.227: + cmpl $0, (%esi) +..B1.125: + je ..B1.127 +..B1.126: + movl 88(%esp), %eax + lea -16517(%eax,%edx), %edi + movl 84(%esp), %edx + lea -16383(%edx,%ecx), %ecx + cmpl %ecx, %edi + jl ..B1.128 +..B1.127: + movl (%ebx), %eax + movl %eax, 232(%esp) + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl 12(%ebx), %esi + movl 16(%ebx), %edi + movl 20(%ebx), %eax + movl 24(%ebx), %ebx + movl %edx, 236(%esp) + movl %ecx, 240(%esp) + movl %esi, 244(%esp) + movl %edi, 248(%esp) + movl %eax, 252(%esp) + movl %ebx, 256(%esp) + jmp ..B1.129 +..B1.128: + movl (%esi), %eax + movl %eax, 232(%esp) + movl 4(%esi), %edx + movl 8(%esi), %ecx + movl 12(%esi), %ebx + movl 16(%esi), %edi + movl 20(%esi), %eax + movl 24(%esi), %esi + movl %edx, 236(%esp) + movl %ecx, 240(%esp) + movl %ebx, 244(%esp) + movl %edi, 248(%esp) + movl %eax, 252(%esp) + movl %esi, 256(%esp) +..B1.129: + movzwl 240(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.133 +..B1.130: + cmpl $24383, %eax + jg ..B1.133 +..B1.131: + movzwl 128(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.133 +..B1.132: + cmpl $24383, %eax + jle ..B1.135 +..B1.133: + addl $4, %esp + lea 228(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.134: + addl $4, %esp + lea 116(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.135: + fldt 232(%esp) + fld %st(0) + fld %st(1) + fldt 48(%esp) + fld %st(0) + fmul %st(4), %st + movl 256(%esp), %edx + fsubr %st, %st(3) + movzwl 212(%esp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + addl 144(%esp), %edx + fxch %st(2) + fsub %st(3), %st + fldt 120(%esp) + cmpl $8383, %eax + fmul %st, %st(2) + fld %st(0) + movl %edx, 284(%esp) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 132(%esp) + fmulp %st, %st(4) + fldt 244(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 260(%esp) + fldt 260(%esp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 272(%esp) + fldt 272(%esp) + jl ..B1.139 +..B1.136: + cmpl $24383, %eax + jg ..B1.139 +..B1.137: + movzwl 268(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.139 +..B1.138: + cmpl $24383, %eax + jle ..B1.142 +..B1.139: + fstp %st(1) + fstp %st(0) + addl $4, %esp + lea 200(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.140: + addl $4, %esp + lea 256(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.141: + fldt 260(%esp) + fldt 272(%esp) + movl 284(%esp), %edx +..B1.142: + fldt 204(%esp) + fld %st(2) + fdivr %st(1), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(4) + fstpt 80(%esp) + fldt 80(%esp) + fldt 48(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + movl 228(%esp), %eax + fsubr %st(4), %st + subl %edx, %eax + faddp %st, %st(1) + fld %st(0) + decl %eax + movl %eax, 312(%esp) + fsubr %st(4), %st + fxch %st(2) + fmul %st(3), %st + fsubr %st, %st(7) + faddp %st, %st(7) + fxch %st(2) + fsub %st(6), %st + fld %st(2) + fmul %st(7), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(3) + fxch %st(7) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(6) + faddp %st, %st(5) + fsubrp %st, %st(2) + fxch %st(3) + fsubrp %st, %st(1) + fldt 216(%esp) + faddp %st, %st(1) + fsubp %st, %st(1) + fldt 80(%esp) + fdivrp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 288(%esp) + fldt 288(%esp) + fsubrp %st, %st(2) + movzwl 296(%esp), %esi + movl %esi, %ebx + andl $32767, %ebx + fadd %st, %st(1) + fxch %st(1) + fstpt 300(%esp) + cmpl $8383, %ebx + fstpt 64(%esp) + jl ..B1.146 +..B1.143: + cmpl $24383, %ebx + jg ..B1.146 +..B1.144: + movzwl 156(%esp), %ecx + movl %ecx, 60(%esp) + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B1.146 +..B1.145: + cmpl $24383, %ecx + jle ..B1.149 +..B1.146: + addl $4, %esp + lea 284(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.147: + addl $4, %esp + lea 144(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.148: + movzwl 296(%esp), %esi + movl %esi, %ebx + movzwl 156(%esp), %ecx + andl $32767, %ebx + movl 312(%esp), %eax + movl %ecx, 60(%esp) + andl $32767, %ecx +..B1.149: + movl 172(%esp), %edi + lea (%eax,%ebx), %edx + movl %edi, 84(%esp) + movl %edx, 80(%esp) + lea -134(%edi,%ecx), %edi + cmpl %edi, %edx + jle ..B1.166 +..B1.150: + movl 84(%esp), %edi + movl 292(%esp), %edx + movl %edx, 44(%esp) + lea 134(%edi,%ecx), %edx + cmpl 80(%esp), %edx + jle ..B1.167 +..B1.151: + cmpl $0, 44(%esp) + jne ..B1.153 +..B1.152: + cmpl $0, 288(%esp) + je ..B1.168 +..B1.153: + cmpl $0, 152(%esp) + jne ..B1.155 +..B1.154: + cmpl $0, 148(%esp) + je ..B1.167 +..B1.155: + cmpl 84(%esp), %eax + je ..B1.157 +..B1.156: + fldt 64(%esp) + movl %edi, %ecx + subl %ecx, %eax + fstpt 32(%esp) + addl $16383, %eax + fldt 288(%esp) + andl $32767, %eax + fldt 300(%esp) + andb $127, 41(%esp) + movzwl 40(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movl %ecx, %eax + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 288(%esp) + fldt 288(%esp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 296(%esp), %esi + movl %esi, %ebx + andl $32767, %ebx + movl %ecx, 312(%esp) + movl %ebx, %ecx + fstpt 300(%esp) + fldt 300(%esp) + jmp ..B1.158 +..B1.157: + fldt 288(%esp) + movl %esi, %ecx + fldt 300(%esp) + andl $32767, %ecx +..B1.158: + fldt 148(%esp) + fld %st(2) + movl 60(%esp), %edi + fadd %st(1), %st + andl $32767, %edi + movl 84(%esp), %edx + cmpl %edi, %ecx + movl %edx, 340(%esp) + jg ..B1.163 +..B1.159: + movl 60(%esp), %edx + andl $32767, %esi + andl $32767, %edx + cmpl %edx, %esi + jne ..B1.164 +..B1.160: + movl 292(%esp), %edx + cmpl 152(%esp), %edx + ja ..B1.163 +..B1.161: + jne ..B1.164 +..B1.162: + movl 288(%esp), %edx + cmpl 148(%esp), %edx + jbe ..B1.164 +..B1.163: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 160(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.165 +..B1.164: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 160(%esp) + faddp %st, %st(1) +..B1.165: + fld %st(0) + fadd %st(2), %st + fstpt 316(%esp) + fldt 316(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 328(%esp) + jmp ..B1.172 +..B1.166: + movl 292(%esp), %edx + movl %edx, 44(%esp) +..B1.167: + cmpl $0, 44(%esp) + jne ..B1.169 +..B1.229: + cmpl $0, 288(%esp) +..B1.168: + je ..B1.170 +..B1.169: + movl 84(%esp), %edx + lea -16383(%eax,%ebx), %esi + lea -16517(%edx,%ecx), %ecx + cmpl %esi, %ecx + jl ..B1.171 +..B1.170: + movl 148(%esp), %edx + movl 152(%esp), %ecx + movl 156(%esp), %esi + movl %edx, 316(%esp) + movl %ecx, 320(%esp) + movl %esi, 324(%esp) + movl 160(%esp), %edi + movl 164(%esp), %edx + movl 168(%esp), %ecx + movl 84(%esp), %esi + movl %edi, 328(%esp) + movl %edx, 332(%esp) + movl %ecx, 336(%esp) + movl %esi, 340(%esp) + jmp ..B1.172 +..B1.171: + movl 288(%esp), %edx + movl 44(%esp), %ecx + movl 296(%esp), %esi + movl %edx, 316(%esp) + movl %ecx, 320(%esp) + movl %esi, 324(%esp) + movl 300(%esp), %edi + movl 304(%esp), %edx + movl 308(%esp), %ecx + movl 312(%esp), %esi + movl %edi, 328(%esp) + movl %edx, 332(%esp) + movl %ecx, 336(%esp) + movl %esi, 340(%esp) +..B1.172: + cmpl $8383, %ebx + jl ..B1.176 +..B1.173: + cmpl $24383, %ebx + jg ..B1.176 +..B1.174: + movzwl 324(%esp), %edx + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.176 +..B1.175: + cmpl $24383, %edx + jle ..B1.179 +..B1.176: + addl $4, %esp + lea 284(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.177: + addl $4, %esp + lea 312(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.178: + movl 312(%esp), %eax +..B1.179: + fldt 288(%esp) + fld %st(0) + fld %st(1) + fldt 48(%esp) + fld %st(0) + fmul %st(4), %st + addl 340(%esp), %eax + fsubr %st, %st(3) + movl %eax, 368(%esp) + faddp %st, %st(3) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fldt 316(%esp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 328(%esp) + fmulp %st, %st(4) + fldt 300(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 344(%esp) + fldt 344(%esp) + fsubr %st, %st(1) + movzwl 352(%esp), %edx + fxch %st(1) + faddp %st, %st(2) + andl $32767, %edx + fxch %st(1) + fstpt 356(%esp) + fldt 356(%esp) + cmpl $383, %edx + fxch %st(1) + fstpt 64(%esp) + jl ..B1.181 +..B1.180: + cmpl $32383, %edx + jle ..B1.183 +..B1.181: + fstp %st(0) + addl $4, %esp + lea 340(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.182: + fldt 344(%esp) + fstpt 64(%esp) + fldt 356(%esp) + movl 368(%esp), %eax +..B1.183: + testb $1, %al + jne ..B1.220 +..B1.184: + movl 76(%esp), %edx + fldt .L_2il0floatpacket.13@GOTOFF(%edx) +..B1.185: + fldt 64(%esp) + fld %st(0) + fsqrt + fldt 48(%esp) + fmul %st(1), %st + fld %st(0) + movzwl 296(%esp), %ebx + movl %ebx, %esi + andl $32767, %esi + fsubr %st(2), %st + sarl $1, %eax + faddp %st, %st(1) + fld %st(0) + cmpl $8383, %esi + movl %eax, 396(%esp) + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fmulp %st, %st(1) + fdiv %st(1), %st + fld %st(0) + fadd %st(2), %st + fstpt 372(%esp) + fldt 372(%esp) + fsubrp %st, %st(2) + fadd %st, %st(1) + fxch %st(1) + fstpt 384(%esp) + fstpt 64(%esp) + jl ..B1.189 +..B1.186: + cmpl $24383, %esi + jg ..B1.189 +..B1.187: + movzwl 380(%esp), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B1.189 +..B1.188: + cmpl $24383, %ecx + jle ..B1.192 +..B1.189: + addl $4, %esp + lea 284(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.190: + addl $4, %esp + lea 368(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.191: + movzwl 296(%esp), %ebx + movl %ebx, %esi + movzwl 380(%esp), %ecx + andl $32767, %esi + movl 396(%esp), %eax + movl %ecx, 44(%esp) + andl $32767, %ecx +..B1.192: + movl 312(%esp), %edx + movl %edx, 52(%esp) + lea (%esi,%edx), %edi + movl %edi, 48(%esp) + lea -134(%eax,%ecx), %edx + cmpl %edx, %edi + jle ..B1.209 +..B1.193: + movl 292(%esp), %edx + lea 134(%eax,%ecx), %edi + cmpl 48(%esp), %edi + jle ..B1.210 +..B1.194: + testl %edx, %edx + jne ..B1.196 +..B1.195: + cmpl $0, 288(%esp) + je ..B1.211 +..B1.196: + cmpl $0, 376(%esp) + jne ..B1.198 +..B1.197: + cmpl $0, 372(%esp) + je ..B1.210 +..B1.198: + cmpl 52(%esp), %eax + je ..B1.200 +..B1.199: + fldt 64(%esp) + movl 52(%esp), %edx + fstpt 32(%esp) + subl %eax, %edx + fldt 288(%esp) + addl $16383, %edx + fldt 300(%esp) + andl $32767, %edx + andb $127, 41(%esp) + movzwl 40(%esp), %ecx + andl $-32768, %ecx + orl %edx, %ecx + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 288(%esp) + fldt 288(%esp) + fxch %st(2) + fmulp %st, %st(1) + movl %eax, 312(%esp) + fstpt 300(%esp) + fldt 300(%esp) + movzwl 296(%esp), %ebx + jmp ..B1.201 +..B1.200: + fldt 288(%esp) + fldt 300(%esp) +..B1.201: + fldt 372(%esp) + fld %st(2) + movl %eax, 424(%esp) + movl %ebx, %eax + movl 44(%esp), %edx + andl $32767, %eax + andl $32767, %edx + fadd %st(1), %st + cmpl %edx, %eax + jg ..B1.206 +..B1.202: + movl 44(%esp), %eax + andl $32767, %ebx + andl $32767, %eax + cmpl %eax, %ebx + jne ..B1.207 +..B1.203: + movl 292(%esp), %eax + cmpl 376(%esp), %eax + ja ..B1.206 +..B1.204: + jne ..B1.207 +..B1.205: + movl 288(%esp), %eax + cmpl 372(%esp), %eax + jbe ..B1.207 +..B1.206: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 384(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + jmp ..B1.208 +..B1.207: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 384(%esp) + faddp %st, %st(1) + fstpt 32(%esp) + fldt 32(%esp) +..B1.208: + fld %st(0) + fadd %st(2), %st + fstpt 400(%esp) + fldt 400(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 412(%esp) + jmp ..B1.215 +..B1.209: + movl 292(%esp), %edx +..B1.210: + testl %edx, %edx + jne ..B1.212 +..B1.228: + cmpl $0, 288(%esp) +..B1.211: + je ..B1.213 +..B1.212: + lea -16517(%eax,%ecx), %ecx + movl 52(%esp), %eax + lea -16383(%eax,%esi), %ebx + cmpl %ebx, %ecx + jl ..B1.214 +..B1.213: + movl 372(%esp), %eax + movl %eax, 400(%esp) + movl 376(%esp), %edx + movl 380(%esp), %ecx + movl 384(%esp), %ebx + movl 388(%esp), %esi + movl 392(%esp), %edi + movl 396(%esp), %eax + movl %edx, 404(%esp) + movl %ecx, 408(%esp) + movl %ebx, 412(%esp) + movl %esi, 416(%esp) + movl %edi, 420(%esp) + movl %eax, 424(%esp) + jmp ..B1.215 +..B1.214: + movl %edx, 404(%esp) + movl 288(%esp), %eax + movl 296(%esp), %edx + movl 300(%esp), %ecx + movl 304(%esp), %ebx + movl 308(%esp), %esi + movl 52(%esp), %edi + movl %eax, 400(%esp) + movl %edx, 408(%esp) + movl %ecx, 412(%esp) + movl %ebx, 416(%esp) + movl %esi, 420(%esp) + movl %edi, 424(%esp) +..B1.215: + addl $8, %esp + lea 392(%esp), %eax + lea 24(%esp), %edx + pushl %eax + pushl %edx + call __libm_log1p_k80 +..B1.216: + fldt 32(%esp) + movl 56(%esp), %eax + fstpt (%esp) + fldt 44(%esp) + fstpt 12(%esp) + movl %eax, 24(%esp) + call __libm_scalbl_k80 +..B1.217: + movl 428(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.219 +..B1.218: + addl $436, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.219: + fstp %st(0) + movl 76(%esp), %ebx + call __stack_chk_fail@PLT +..B1.220: + fldt 64(%esp) + incl %eax + movl 76(%esp), %edx + movl %eax, 368(%esp) + fldt .L_2il0floatpacket.13@GOTOFF(%edx) + fmul %st, %st(1) + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fstpt 356(%esp) + fldt 356(%esp) + fxch %st(1) + fstpt 344(%esp) + fxch %st(1) + jmp ..B1.185 + .align 16,0x90 + .type __libm_recacoshl_k80,@function + .size __libm_recacoshl_k80,.-__libm_recacoshl_k80 + .data +# -- End __libm_recacoshl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.12: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,12 + .data + .hidden __libm_log1p_k80 + .hidden __libm_normalizel_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_recacosl_recasinl_k80.S b/external/sgx_libm/ia32/libm_recacosl_recasinl_k80.S new file mode 100644 index 0000000000..d833921901 --- /dev/null +++ b/external/sgx_libm/ia32/libm_recacosl_recasinl_k80.S @@ -0,0 +1,6111 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_recacosl_recasinl_k80.c" + .text +..TXTST0: +# -- Begin __libm_carctrigprepare_k80 + .text + .align 16,0x90 + .hidden __libm_carctrigprepare_k80 + .globl __libm_carctrigprepare_k80 +__libm_carctrigprepare_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +# parameter 4: 20 + %ebp +# parameter 5: 24 + %ebp +# parameter 6: 28 + %ebp +# parameter 7: 32 + %ebp +# parameter 8: 36 + %ebp +# parameter 9: 40 + %ebp +# parameter 10: 44 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $212, %esp + xorl %ecx, %ecx + movl 8(%ebp), %esi + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + movl 16(%ebp), %ebx + movl %edx, 60(%esp) + fldt _CONSTANTS@GOTOFF(%edx) + fldt 24+_CONSTANTS@GOTOFF(%edx) + movl (%esi), %edi + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 200(%esp) + movl %edi, (%ebx) + movl 4(%esi), %eax + movl %eax, 4(%ebx) + movl 8(%esi), %edx + movl %edx, 8(%ebx) + shrl $8, %edx + movl %ecx, 112(%esp) + fstpt 16(%esp) + fldt 16(%esp) + fxch %st(1) + fstpt 88(%esp) + fstpt 100(%esp) + fldt 100(%esp) + addl $4, %esp + movzbl %dl, %edx + pushl %ebx + andl $127, %edx + movl %ecx, 24(%ebx) + movb %dl, 9(%ebx) + fstpt 12(%ebx) + call __libm_normalizel_k80 +..B1.2: + movl 12(%ebp), %edx + addl $4, %esp + movl 20(%ebp), %esi + pushl %esi + fldt 16(%esp) + movl (%edx), %edi + movl %edi, (%esi) + movl 4(%edx), %eax + movl %eax, 4(%esi) + movl 8(%edx), %ecx + movl %ecx, 8(%esi) + shrl $8, %ecx + movzbl %cl, %ecx + andl $127, %ecx + movl $0, 24(%esi) + movb %cl, 9(%esi) + fstpt 12(%esi) + call __libm_normalizel_k80 +..B1.3: + fldt (%esi) + movl 60(%esp), %edx + fld %st(0) + fld %st(1) + fld %st(2) + fldt 12(%esi) + fmulp %st, %st(4) + movl 32(%ebp), %ecx + fxch %st(3) + fadd %st(0), %st + fldt 36+_CONSTANTS@GOTOFF(%edx) + fmul %st, %st(3) + movl 24(%esi), %eax + fxch %st(2) + fsub %st(3), %st + addl %eax, %eax + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(4) + fmul %st(4), %st + movl %eax, 24(%ecx) + fadd %st(0), %st + fxch %st(4) + fmul %st(0), %st + fxch %st(2) + fstpt 32(%esp) + fld %st(3) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt (%ecx) + fldt (%ecx) + fsubrp %st, %st(1) + movzwl 8(%ebx), %eax + fadd %st(1), %st + movl %eax, 68(%esp) + andl $32767, %eax + fstpt 12(%ecx) + cmpl $8383, %eax + fstpt 48(%esp) + jl ..B1.7 +..B1.4: + cmpl $24383, %eax + jg ..B1.7 +..B1.5: + movzwl 96(%esp), %edx + movl %edx, 44(%esp) + andl $32767, %edx + movl %edx, 28(%esp) + cmpl $8383, %edx + jl ..B1.7 +..B1.6: + cmpl $24383, 28(%esp) + jle ..B1.10 +..B1.7: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B1.8: + addl $4, %esp + lea 84(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.9: + movzwl 96(%esp), %edx + movzwl 8(%ebx), %eax + movl %edx, 44(%esp) + andl $32767, %edx + movl %eax, 68(%esp) + andl $32767, %eax + movl %edx, 28(%esp) +..B1.10: + movl 24(%ebx), %ecx + movl 112(%esp), %esi + movl %ecx, 64(%esp) + lea (%eax,%ecx), %edi + movl %edi, 20(%esp) + lea (%edx,%esi), %ecx + lea -134(%esi,%edx), %edx + cmpl %edi, %edx + jge ..B1.27 +..B1.11: + movl 4(%ebx), %edi + movl %edi, 16(%esp) + movl 28(%esp), %edi + lea 134(%esi,%edi), %edi + cmpl 20(%esp), %edi + jle ..B1.28 +..B1.12: + cmpl $0, 16(%esp) + jne ..B1.14 +..B1.13: + cmpl $0, (%ebx) + je ..B1.29 +..B1.14: + cmpl $0, 92(%esp) + jne ..B1.16 +..B1.15: + cmpl $0, 88(%esp) + je ..B1.28 +..B1.16: + cmpl 64(%esp), %esi + je ..B1.18 +..B1.17: + fldt 48(%esp) + movl 64(%esp), %eax + fstpt 16(%esp) + subl %esi, %eax + fldt (%ebx) + addl $16383, %eax + fldt 12(%ebx) + andl $32767, %eax + andb $127, 25(%esp) + movzwl 24(%esp), %edi + andl $-32768, %edi + orl %eax, %edi + movw %di, 24(%esp) + movl $-2147483648, 20(%esp) + movl $0, 16(%esp) + fldt 16(%esp) + fmul %st, %st(2) + movl %esi, 24(%ebx) + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + movzwl 8(%ebx), %eax + fstpt 48(%esp) + movl %eax, 68(%esp) + jmp ..B1.19 +..B1.18: + fldt (%ebx) + fstpt 48(%esp) +..B1.19: + fldt 88(%esp) + fldt 48(%esp) + movl 28(%ebp), %eax + movl 68(%esp), %edi + fadd %st(1), %st + movl %esi, 24(%eax) + andl $32767, %edi + fstpt 12(%eax) + fldt 12(%eax) + movl 44(%esp), %eax + andl $32767, %eax + movl %edi, 68(%esp) + cmpl %eax, %edi + jg ..B1.24 +..B1.20: + movl 44(%esp), %eax + andl $32767, %eax + cmpl 68(%esp), %eax + jne ..B1.25 +..B1.21: + movl 4(%ebx), %eax + cmpl 92(%esp), %eax + ja ..B1.24 +..B1.22: + jne ..B1.25 +..B1.23: + movl (%ebx), %eax + cmpl 88(%esp), %eax + jbe ..B1.25 +..B1.24: + fldt 48(%esp) + fsub %st(1), %st + faddp %st, %st(2) + fldt 100(%esp) + faddp %st, %st(2) + fldt 12(%ebx) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + jmp ..B1.26 +..B1.25: + fldt 48(%esp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 100(%esp) + fldt 12(%ebx) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) +..B1.26: + fldt 48(%esp) + fld %st(0) + movl 28(%ebp), %eax + fadd %st(2), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%eax) + jmp ..B1.33 +..B1.27: + movl 4(%ebx), %edi + movl %edi, 16(%esp) +..B1.28: + cmpl $0, 16(%esp) + jne ..B1.30 +..B1.210: + cmpl $0, (%ebx) +..B1.29: + je ..B1.31 +..B1.30: + movl 28(%esp), %edi + lea -16517(%esi,%edi), %ebx + movl 64(%esp), %edi + lea -16383(%edi,%eax), %eax + cmpl %eax, %ebx + movl 16(%ebp), %ebx + jl ..B1.32 +..B1.31: + movl 28(%ebp), %eax + movl 88(%esp), %edi + movl %edi, (%eax) + movl 92(%esp), %edi + movl %edi, 4(%eax) + movl 96(%esp), %edi + movl %edi, 8(%eax) + movl 100(%esp), %edi + movl %edi, 12(%eax) + movl 104(%esp), %edi + movl %edi, 16(%eax) + movl 108(%esp), %edi + movl %edi, 20(%eax) + movl %esi, 24(%eax) + jmp ..B1.33 +..B1.32: + movl 28(%ebp), %eax + movl (%ebx), %edi + movl %edi, (%eax) + movl 4(%ebx), %edi + movl %edi, 4(%eax) + movl 8(%ebx), %edi + movl %edi, 8(%eax) + movl 12(%ebx), %edi + movl %edi, 12(%eax) + movl 16(%ebx), %edi + movl %edi, 16(%eax) + movl 20(%ebx), %edi + movl %edi, 20(%eax) + movl 24(%ebx), %edi + movl %edi, 24(%eax) +..B1.33: + movzwl 8(%ebx), %eax + movl %eax, 64(%esp) + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.37 +..B1.34: + cmpl $24383, %eax + jg ..B1.37 +..B1.35: + cmpl $8383, 28(%esp) + jl ..B1.37 +..B1.36: + cmpl $24383, 28(%esp) + jle ..B1.40 +..B1.37: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B1.38: + addl $4, %esp + lea 84(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.39: + movzwl 96(%esp), %edx + movl %edx, 44(%esp) + andl $32767, %edx + movl 112(%esp), %esi + movzwl 8(%ebx), %eax + movl %eax, 64(%esp) + andl $32767, %eax + lea (%esi,%edx), %ecx + lea -134(%esi,%edx), %edx +..B1.40: + movl 24(%ebx), %edi + movl %edi, 72(%esp) + addl %eax, %edi + movl %edi, 68(%esp) + cmpl %edi, %edx + jge ..B1.57 +..B1.41: + movl 4(%ebx), %edx + lea 134(%ecx), %edi + movl %edx, 28(%esp) + cmpl 68(%esp), %edi + jle ..B1.58 +..B1.42: + cmpl $0, 28(%esp) + jne ..B1.44 +..B1.43: + cmpl $0, (%ebx) + je ..B1.59 +..B1.44: + cmpl $0, 92(%esp) + jne ..B1.46 +..B1.45: + cmpl $0, 88(%esp) + je ..B1.58 +..B1.46: + cmpl 72(%esp), %esi + je ..B1.48 +..B1.47: + fldt 48(%esp) + movl 72(%esp), %eax + fstpt 16(%esp) + subl %esi, %eax + fldt (%ebx) + addl $16383, %eax + fldt 12(%ebx) + andl $32767, %eax + andb $127, 25(%esp) + movzwl 24(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 24(%esp) + movl $-2147483648, 20(%esp) + movl $0, 16(%esp) + fldt 16(%esp) + fmul %st, %st(2) + movl %esi, 24(%ebx) + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + movzwl 8(%ebx), %ecx + movl %ecx, 64(%esp) + jmp ..B1.49 +..B1.48: + fldt (%ebx) +..B1.49: + fldt 88(%esp) + fld %st(1) + movl 28(%ebp), %eax + fadd %st(1), %st + movl 64(%esp), %edx + movl 44(%esp), %ecx + andl $32767, %edx + andl $32767, %ecx + movl %esi, 24(%eax) + cmpl %ecx, %edx + fstpt 12(%eax) + fldt 12(%eax) + movl %edx, 64(%esp) + jg ..B1.54 +..B1.50: + movl 44(%esp), %eax + andl $32767, %eax + cmpl 64(%esp), %eax + jne ..B1.55 +..B1.51: + movl 4(%ebx), %eax + cmpl 92(%esp), %eax + ja ..B1.54 +..B1.52: + jne ..B1.55 +..B1.53: + movl (%ebx), %eax + cmpl 88(%esp), %eax + jbe ..B1.55 +..B1.54: + fldt 100(%esp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 12(%ebx) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.56 +..B1.55: + fldt 12(%ebx) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 100(%esp) + faddp %st, %st(1) +..B1.56: + fld %st(0) + movl 28(%ebp), %eax + fadd %st(2), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%eax) + jmp ..B1.63 +..B1.57: + movl 4(%ebx), %edx + movl %edx, 28(%esp) +..B1.58: + cmpl $0, 28(%esp) + jne ..B1.60 +..B1.209: + cmpl $0, (%ebx) +..B1.59: + je ..B1.61 +..B1.60: + movl 72(%esp), %edx + addl $-16517, %ecx + lea -16383(%edx,%eax), %eax + cmpl %eax, %ecx + jl ..B1.62 +..B1.61: + movl 28(%ebp), %eax + movl 88(%esp), %edx + movl 92(%esp), %ecx + movl 96(%esp), %edi + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl %edi, 8(%eax) + movl 100(%esp), %edx + movl 104(%esp), %ecx + movl 108(%esp), %edi + movl %edx, 12(%eax) + movl %ecx, 16(%eax) + movl %edi, 20(%eax) + movl %esi, 24(%eax) + jmp ..B1.63 +..B1.62: + movl 28(%ebp), %eax + movl (%ebx), %edx + movl %edx, (%eax) + movl 4(%ebx), %ecx + movl %ecx, 4(%eax) + movl 8(%ebx), %esi + movl %esi, 8(%eax) + movl 12(%ebx), %edi + movl %edi, 12(%eax) + movl 16(%ebx), %edx + movl %edx, 16(%eax) + movl 20(%ebx), %ecx + movl %ecx, 20(%eax) + movl 24(%ebx), %esi + movl %esi, 24(%eax) +..B1.63: + movl 28(%ebp), %eax + movzwl 8(%eax), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.65 +..B1.64: + cmpl $24383, %eax + jle ..B1.67 +..B1.65: + addl $4, %esp + pushl 28(%ebp) + call __libm_normalizel_k80 +..B1.66: + addl $4, %esp + pushl 28(%ebp) + call __libm_normalizel_k80 +..B1.67: + fldt 32(%esp) + movl 28(%ebp), %eax + fldt (%eax) + fmul %st, %st(1) + fld %st(0) + movl 24(%eax), %edi + fsub %st(2), %st + addl %edi, %edi + faddp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fld %st(1) + fsub %st(3), %st + fmul %st, %st(3) + movl %edi, 140(%esp) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsub %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(1) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(3) + fldt 12(%eax) + fmulp %st, %st(2) + fxch %st(1) + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 116(%esp) + fldt 116(%esp) + fsubrp %st, %st(1) + movzwl 124(%esp), %ecx + movl %ecx, %esi + andl $32767, %esi + fadd %st(1), %st + fstpt 128(%esp) + cmpl $8383, %esi + fstpt 48(%esp) + jl ..B1.71 +..B1.68: + cmpl $24383, %esi + jg ..B1.71 +..B1.69: + movl 32(%ebp), %eax + movzwl 8(%eax), %edx + movl %edx, 44(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.71 +..B1.70: + cmpl $24383, %edx + jle ..B1.74 +..B1.71: + addl $4, %esp + lea 112(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.72: + addl $4, %esp + pushl 32(%ebp) + call __libm_normalizel_k80 +..B1.73: + movl 32(%ebp), %eax + movzwl 124(%esp), %ecx + movl %ecx, %esi + movl 140(%esp), %edi + andl $32767, %esi + movzwl 8(%eax), %edx + movl %edx, 44(%esp) + andl $32767, %edx +..B1.74: + movl 32(%ebp), %ebx + lea (%edi,%esi), %eax + movl %eax, 64(%esp) + movl 24(%ebx), %ebx + movl %ebx, 68(%esp) + lea -134(%ebx,%edx), %ebx + cmpl %ebx, %eax + movl 16(%ebp), %ebx + jle ..B1.91 +..B1.75: + movl 120(%esp), %eax + movl %eax, 28(%esp) + movl 68(%esp), %eax + lea 134(%eax,%edx), %eax + cmpl 64(%esp), %eax + jle ..B1.92 +..B1.76: + cmpl $0, 28(%esp) + jne ..B1.78 +..B1.77: + cmpl $0, 116(%esp) + je ..B1.93 +..B1.78: + movl 32(%ebp), %eax + cmpl $0, 4(%eax) + jne ..B1.80 +..B1.79: + movl 32(%ebp), %eax + cmpl $0, (%eax) + je ..B1.92 +..B1.80: + cmpl 68(%esp), %edi + je ..B1.82 +..B1.81: + fldt 48(%esp) + movl 68(%esp), %edx + subl %edx, %edi + fstpt 16(%esp) + addl $16383, %edi + fldt 116(%esp) + andl $32767, %edi + fldt 128(%esp) + andb $127, 25(%esp) + movzwl 24(%esp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 24(%esp) + movl $-2147483648, 20(%esp) + movl $0, 16(%esp) + fldt 16(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 116(%esp) + fldt 116(%esp) + fxch %st(2) + fmulp %st, %st(1) + movl %edx, 140(%esp) + fstpt 128(%esp) + fldt 128(%esp) + movzwl 124(%esp), %ecx + jmp ..B1.83 +..B1.82: + fldt 116(%esp) + fldt 128(%esp) +..B1.83: + movl 32(%ebp), %edx + movl %ecx, %esi + movl 44(%esp), %edi + andl $32767, %esi + andl $32767, %edi + fld %st(1) + fldt (%edx) + cmpl %edi, %esi + movl 68(%esp), %eax + fadd %st, %st(1) + movl %eax, 168(%esp) + movl %edi, 44(%esp) + jg ..B1.88 +..B1.84: + andl $32767, %ecx + cmpl 44(%esp), %ecx + jne ..B1.89 +..B1.85: + movl 32(%ebp), %eax + movl 4(%eax), %edx + cmpl 120(%esp), %edx + jb ..B1.88 +..B1.86: + jne ..B1.89 +..B1.87: + movl 32(%ebp), %edx + movl 116(%esp), %eax + cmpl (%edx), %eax + jbe ..B1.89 +..B1.88: + movl 32(%ebp), %eax + fxch %st(1) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 12(%eax) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + jmp ..B1.90 +..B1.89: + movl 32(%ebp), %eax + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%eax) + faddp %st, %st(2) +..B1.90: + fld %st(1) + fadd %st(1), %st + fstpt 144(%esp) + fldt 144(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 156(%esp) + jmp ..B1.97 +..B1.91: + movl 120(%esp), %eax + movl %eax, 28(%esp) +..B1.92: + cmpl $0, 28(%esp) + jne ..B1.94 +..B1.212: + cmpl $0, 116(%esp) +..B1.93: + je ..B1.95 +..B1.94: + movl 68(%esp), %eax + lea -16383(%edi,%esi), %ecx + lea -16517(%eax,%edx), %edx + cmpl %ecx, %edx + jl ..B1.96 +..B1.95: + movl 32(%ebp), %eax + movl (%eax), %edx + movl 4(%eax), %ecx + movl %edx, 144(%esp) + movl %ecx, 148(%esp) + movl 8(%eax), %esi + movl 12(%eax), %edi + movl 16(%eax), %edx + movl 20(%eax), %ecx + movl 24(%eax), %eax + movl %esi, 152(%esp) + movl %edi, 156(%esp) + movl %edx, 160(%esp) + movl %ecx, 164(%esp) + movl %eax, 168(%esp) + jmp ..B1.97 +..B1.96: + movl 116(%esp), %eax + movl 28(%esp), %edx + movl %eax, 144(%esp) + movl %edx, 148(%esp) + movl 124(%esp), %ecx + movl 128(%esp), %esi + movl 132(%esp), %edi + movl 136(%esp), %eax + movl 140(%esp), %edx + movl %ecx, 152(%esp) + movl %esi, 156(%esp) + movl %edi, 160(%esp) + movl %eax, 164(%esp) + movl %edx, 168(%esp) +..B1.97: + movzwl 152(%esp), %eax + andl $32767, %eax + cmpl $383, %eax + jl ..B1.99 +..B1.98: + cmpl $32383, %eax + jle ..B1.100 +..B1.99: + addl $4, %esp + lea 140(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.100: + movl 168(%esp), %edx + testb $1, %dl + jne ..B1.205 +..B1.101: + fldt 144(%esp) + movl 60(%esp), %eax + fstpt 64(%esp) + fldt 156(%esp) + fldt 48+_CONSTANTS@GOTOFF(%eax) + fstpt 48(%esp) +..B1.102: + fldt 64(%esp) + fld %st(0) + fsqrt + fldt 32(%esp) + movl 36(%ebp), %eax + fmul %st(1), %st + fld %st(0) + sarl $1, %edx + fsubr %st(2), %st + movl %edx, 24(%eax) + faddp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 48(%esp) + fmulp %st, %st(1) + fdiv %st(1), %st + fld %st(0) + fadd %st(2), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(2) + movzwl 8(%ebx), %ecx + movl %ecx, %esi + andl $32767, %esi + fadd %st, %st(1) + fxch %st(1) + fstpt 12(%eax) + cmpl $8383, %esi + fstpt 64(%esp) + jl ..B1.106 +..B1.103: + cmpl $24383, %esi + jg ..B1.106 +..B1.104: + movzwl 96(%esp), %edx + movl %edx, 44(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.106 +..B1.105: + cmpl $24383, %edx + jle ..B1.109 +..B1.106: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B1.107: + addl $4, %esp + lea 84(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.108: + movzwl 8(%ebx), %ecx + movl %ecx, %esi + movzwl 96(%esp), %edx + andl $32767, %esi + movl %edx, 44(%esp) + andl $32767, %edx +..B1.109: + movl 24(%ebx), %edi + movl %edi, 80(%esp) + lea (%esi,%edi), %eax + movl 112(%esp), %edi + movl %edi, 84(%esp) + movl %eax, 76(%esp) + lea -134(%edi,%edx), %edi + cmpl %edi, %eax + jle ..B1.126 +..B1.110: + movl 84(%esp), %edi + movl 4(%ebx), %eax + movl %eax, 28(%esp) + lea 134(%edi,%edx), %eax + cmpl 76(%esp), %eax + jle ..B1.127 +..B1.111: + cmpl $0, 28(%esp) + jne ..B1.113 +..B1.112: + cmpl $0, (%ebx) + je ..B1.128 +..B1.113: + cmpl $0, 92(%esp) + jne ..B1.115 +..B1.114: + cmpl $0, 88(%esp) + je ..B1.127 +..B1.115: + movl %edi, %eax + cmpl 80(%esp), %eax + je ..B1.117 +..B1.116: + fldt 64(%esp) + movl 80(%esp), %eax + movl %edi, %ecx + subl %ecx, %eax + fstpt 16(%esp) + addl $16383, %eax + fldt (%ebx) + andl $32767, %eax + fldt 12(%ebx) + andb $127, 25(%esp) + movzwl 24(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 24(%esp) + movl $-2147483648, 20(%esp) + movl $0, 16(%esp) + fldt 16(%esp) + fmul %st, %st(2) + movl %ecx, 24(%ebx) + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + movzwl 8(%ebx), %ecx + jmp ..B1.118 +..B1.117: + fldt (%ebx) +..B1.118: + fldt 88(%esp) + fld %st(1) + movl 24(%ebp), %edx + andl $32767, %ecx + movl 44(%esp), %esi + fsub %st(1), %st + andl $32767, %esi + movl %edi, %eax + cmpl %esi, %ecx + movl %eax, 24(%edx) + fstpt 12(%edx) + fldt 12(%edx) + jg ..B1.123 +..B1.119: + movl 44(%esp), %eax + andl $32767, %eax + cmpl %eax, %ecx + jne ..B1.124 +..B1.120: + movl 4(%ebx), %eax + cmpl 92(%esp), %eax + ja ..B1.123 +..B1.121: + jne ..B1.124 +..B1.122: + movl (%ebx), %eax + cmpl 88(%esp), %eax + jbe ..B1.124 +..B1.123: + fldt 12(%ebx) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fldt 100(%esp) + fsubrp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.125 +..B1.124: + fldt 100(%esp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fldt 12(%ebx) + faddp %st, %st(3) + fsubrp %st, %st(2) +..B1.125: + fld %st(1) + movl 24(%ebp), %eax + fadd %st(1), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 12(%eax) + jmp ..B1.132 +..B1.126: + movl 4(%ebx), %eax + movl %eax, 28(%esp) +..B1.127: + cmpl $0, 28(%esp) + jne ..B1.129 +..B1.208: + cmpl $0, (%ebx) +..B1.128: + je ..B1.130 +..B1.129: + movl 84(%esp), %eax + lea -16517(%eax,%edx), %ecx + movl 80(%esp), %edx + lea -16383(%edx,%esi), %esi + cmpl %esi, %ecx + jl ..B1.131 +..B1.130: + fldt 88(%esp) + movl 24(%ebp), %edx + fchs + movl 84(%esp), %eax + movl %eax, 24(%edx) + fstpt (%edx) + fldt 100(%esp) + fchs + fstpt 12(%edx) + jmp ..B1.132 +..B1.131: + movl 24(%ebp), %eax + movl (%ebx), %edx + movl %edx, (%eax) + movl 4(%ebx), %ecx + movl %ecx, 4(%eax) + movl 8(%ebx), %esi + movl %esi, 8(%eax) + movl 12(%ebx), %edi + movl %edi, 12(%eax) + movl 16(%ebx), %edx + movl %edx, 16(%eax) + movl 20(%ebx), %ecx + movl %ecx, 20(%eax) + movl 24(%ebx), %ebx + movl %ebx, 24(%eax) +..B1.132: + movl 24(%ebp), %eax + movzwl 8(%eax), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.134 +..B1.133: + cmpl $24383, %eax + jle ..B1.136 +..B1.134: + addl $4, %esp + pushl 24(%ebp) + call __libm_normalizel_k80 +..B1.135: + addl $4, %esp + pushl 24(%ebp) + call __libm_normalizel_k80 +..B1.136: + fldt 32(%esp) + movl 24(%ebp), %eax + fldt (%eax) + fmul %st, %st(1) + fld %st(0) + movl 24(%eax), %esi + fsub %st(2), %st + addl %esi, %esi + faddp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fld %st(1) + fsub %st(3), %st + fmul %st, %st(3) + movl %esi, 140(%esp) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsub %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(1) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(3) + fldt 12(%eax) + fmulp %st, %st(2) + fxch %st(1) + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 116(%esp) + fldt 116(%esp) + fsubrp %st, %st(1) + movzwl 124(%esp), %ecx + movl %ecx, %ebx + andl $32767, %ebx + fadd %st(1), %st + fstpt 128(%esp) + cmpl $8383, %ebx + fstpt 64(%esp) + jl ..B1.140 +..B1.137: + cmpl $24383, %ebx + jg ..B1.140 +..B1.138: + movl 32(%ebp), %eax + movzwl 8(%eax), %edx + movl %edx, 44(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.140 +..B1.139: + cmpl $24383, %edx + jle ..B1.143 +..B1.140: + addl $4, %esp + lea 112(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.141: + addl $4, %esp + pushl 32(%ebp) + call __libm_normalizel_k80 +..B1.142: + movl 32(%ebp), %eax + movzwl 124(%esp), %ecx + movl %ecx, %ebx + movl 140(%esp), %esi + andl $32767, %ebx + movzwl 8(%eax), %edx + movl %edx, 44(%esp) + andl $32767, %edx +..B1.143: + movl 32(%ebp), %edi + lea (%esi,%ebx), %eax + movl %eax, 76(%esp) + movl 24(%edi), %edi + movl %edi, 80(%esp) + lea -134(%edi,%edx), %edi + cmpl %edi, %eax + jle ..B1.160 +..B1.144: + movl 80(%esp), %edi + movl 120(%esp), %eax + movl %eax, 28(%esp) + lea 134(%edi,%edx), %eax + cmpl 76(%esp), %eax + jle ..B1.161 +..B1.145: + cmpl $0, 28(%esp) + jne ..B1.147 +..B1.146: + cmpl $0, 116(%esp) + je ..B1.162 +..B1.147: + movl 32(%ebp), %eax + cmpl $0, 4(%eax) + jne ..B1.149 +..B1.148: + movl 32(%ebp), %eax + cmpl $0, (%eax) + je ..B1.161 +..B1.149: + cmpl 80(%esp), %esi + je ..B1.151 +..B1.150: + fldt 64(%esp) + movl %edi, %edx + subl %edx, %esi + fstpt 16(%esp) + addl $16383, %esi + fldt 116(%esp) + andl $32767, %esi + fldt 128(%esp) + andb $127, 25(%esp) + movzwl 24(%esp), %eax + andl $-32768, %eax + orl %esi, %eax + movw %ax, 24(%esp) + movl $-2147483648, 20(%esp) + movl $0, 16(%esp) + fldt 16(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 116(%esp) + fldt 116(%esp) + fxch %st(2) + fmulp %st, %st(1) + movl %edx, 140(%esp) + fstpt 128(%esp) + fldt 128(%esp) + movzwl 124(%esp), %ecx + jmp ..B1.152 +..B1.151: + fldt 116(%esp) + fldt 128(%esp) +..B1.152: + movl 32(%ebp), %edx + movl %ecx, %ebx + movl 44(%esp), %esi + andl $32767, %ebx + andl $32767, %esi + fld %st(1) + fldt (%edx) + cmpl %esi, %ebx + movl %edi, %eax + fadd %st, %st(1) + movl %eax, 196(%esp) + movl %esi, 44(%esp) + jg ..B1.157 +..B1.153: + andl $32767, %ecx + cmpl 44(%esp), %ecx + jne ..B1.158 +..B1.154: + movl 32(%ebp), %eax + movl 4(%eax), %edx + cmpl 120(%esp), %edx + jb ..B1.157 +..B1.155: + jne ..B1.158 +..B1.156: + movl 32(%ebp), %edx + movl 116(%esp), %eax + cmpl (%edx), %eax + jbe ..B1.158 +..B1.157: + movl 32(%ebp), %eax + fxch %st(1) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 12(%eax) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + jmp ..B1.159 +..B1.158: + movl 32(%ebp), %eax + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%eax) + faddp %st, %st(2) +..B1.159: + fld %st(1) + fadd %st(1), %st + fstpt 172(%esp) + fldt 172(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 184(%esp) + jmp ..B1.166 +..B1.160: + movl 120(%esp), %eax + movl %eax, 28(%esp) +..B1.161: + cmpl $0, 28(%esp) + jne ..B1.163 +..B1.211: + cmpl $0, 116(%esp) +..B1.162: + je ..B1.164 +..B1.163: + movl 80(%esp), %eax + lea -16383(%esi,%ebx), %ecx + lea -16517(%eax,%edx), %edx + cmpl %ecx, %edx + jl ..B1.165 +..B1.164: + movl 32(%ebp), %eax + movl (%eax), %edx + movl %edx, 172(%esp) + movl 4(%eax), %ecx + movl 8(%eax), %ebx + movl 12(%eax), %esi + movl 16(%eax), %edi + movl 20(%eax), %edx + movl 24(%eax), %eax + movl %ecx, 176(%esp) + movl %ebx, 180(%esp) + movl %esi, 184(%esp) + movl %edi, 188(%esp) + movl %edx, 192(%esp) + movl %eax, 196(%esp) + jmp ..B1.166 +..B1.165: + movl 116(%esp), %eax + movl %eax, 172(%esp) + movl 28(%esp), %edx + movl 124(%esp), %ecx + movl 128(%esp), %ebx + movl 132(%esp), %esi + movl 136(%esp), %edi + movl 140(%esp), %eax + movl %edx, 176(%esp) + movl %ecx, 180(%esp) + movl %ebx, 184(%esp) + movl %esi, 188(%esp) + movl %edi, 192(%esp) + movl %eax, 196(%esp) +..B1.166: + movzwl 180(%esp), %eax + andl $32767, %eax + cmpl $383, %eax + jl ..B1.168 +..B1.167: + cmpl $32383, %eax + jle ..B1.169 +..B1.168: + addl $4, %esp + lea 168(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B1.169: + movl 196(%esp), %ecx + testb $1, %cl + jne ..B1.204 +..B1.170: + fldt 172(%esp) + fstpt 64(%esp) + fldt 184(%esp) +..B1.171: + fldt 64(%esp) + fld %st(0) + fsqrt + fldt 32(%esp) + fmul %st(1), %st + fld %st(0) + movl 40(%ebp), %ebx + fsubr %st(2), %st + movl 36(%ebp), %eax + faddp %st, %st(1) + fld %st(0) + sarl $1, %ecx + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + movl %ecx, 24(%ebx) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 48(%esp) + fmulp %st, %st(1) + fdiv %st(1), %st + fld %st(0) + fadd %st(2), %st + fstpt (%ebx) + fldt (%ebx) + fsubrp %st, %st(2) + movzwl 8(%eax), %edx + fadd %st, %st(1) + movl %edx, 44(%esp) + andl $32767, %edx + fxch %st(1) + fstpt 12(%ebx) + cmpl $8383, %edx + fstpt 64(%esp) + jl ..B1.175 +..B1.172: + cmpl $24383, %edx + jg ..B1.175 +..B1.173: + movzwl 8(%ebx), %eax + movl %eax, 32(%esp) + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.175 +..B1.174: + cmpl $24383, %eax + jle ..B1.178 +..B1.175: + addl $4, %esp + pushl 36(%ebp) + call __libm_normalizel_k80 +..B1.176: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B1.177: + movl 36(%ebp), %edx + movzwl 8(%ebx), %eax + movl 24(%ebx), %ecx + movzwl 8(%edx), %edx + movl %edx, 44(%esp) + andl $32767, %edx + movl %eax, 32(%esp) + andl $32767, %eax +..B1.178: + movl 36(%ebp), %esi + movl 24(%esi), %edi + movl %edi, 40(%esp) + lea (%edx,%edi), %esi + movl %esi, 36(%esp) + lea -134(%ecx,%eax), %edi + cmpl %edi, %esi + jle ..B1.195 +..B1.179: + movl 36(%ebp), %esi + movl 4(%esi), %edi + lea 134(%ecx,%eax), %esi + movl %edi, 28(%esp) + cmpl 36(%esp), %esi + jle ..B1.196 +..B1.180: + cmpl $0, 28(%esp) + jne ..B1.182 +..B1.181: + movl 36(%ebp), %esi + cmpl $0, (%esi) + je ..B1.197 +..B1.182: + cmpl $0, 4(%ebx) + jne ..B1.184 +..B1.183: + cmpl $0, (%ebx) + je ..B1.196 +..B1.184: + cmpl 40(%esp), %ecx + je ..B1.186 +..B1.185: + fldt 64(%esp) + movl 40(%esp), %eax + fstpt 16(%esp) + subl %ecx, %eax + andb $127, 25(%esp) + addl $16383, %eax + movl 36(%ebp), %esi + andl $32767, %eax + movzwl 24(%esp), %edx + andl $-32768, %edx + fldt (%esi) + orl %eax, %edx + fldt 12(%esi) + movw %dx, 24(%esp) + movl $-2147483648, 20(%esp) + movl $0, 16(%esp) + fldt 16(%esp) + fmul %st, %st(2) + movl %ecx, 24(%esi) + fxch %st(2) + fstpt (%esi) + fldt (%esi) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esi) + movzwl 8(%esi), %edi + movzwl 8(%ebx), %eax + movl 24(%ebx), %ecx + movl %edi, 44(%esp) + movl %eax, 32(%esp) + jmp ..B1.187 +..B1.186: + movl 36(%ebp), %eax + fldt (%eax) +..B1.187: + fldt (%ebx) + fld %st(1) + movl 44(%ebp), %eax + fadd %st(1), %st + movl %ecx, 24(%eax) + movl 44(%esp), %edx + movl 32(%esp), %ecx + andl $32767, %edx + andl $32767, %ecx + fstpt 12(%eax) + fldt 12(%eax) + cmpl %ecx, %edx + jg ..B1.192 +..B1.188: + jne ..B1.193 +..B1.189: + movl 36(%ebp), %eax + movl 4(%eax), %edx + cmpl 4(%ebx), %edx + ja ..B1.192 +..B1.190: + jne ..B1.193 +..B1.191: + movl 36(%ebp), %eax + movl (%eax), %edx + cmpl (%ebx), %edx + jbe ..B1.193 +..B1.192: + fldt 12(%ebx) + fxch %st(1) + fsubr %st, %st(3) + movl 36(%ebp), %eax + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 12(%eax) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + jmp ..B1.194 +..B1.193: + movl 36(%ebp), %eax + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fldt 12(%eax) + faddp %st, %st(1) + fldt 12(%ebx) + faddp %st, %st(1) + fstpt 16(%esp) + fldt 16(%esp) +..B1.194: + fld %st(0) + movl 44(%ebp), %eax + fadd %st(2), %st + fstpt (%eax) + fldt (%eax) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%eax) + jmp ..B1.201 +..B1.195: + movl 36(%ebp), %esi + movl 4(%esi), %edi + movl %edi, 28(%esp) +..B1.196: + cmpl $0, 28(%esp) + jne ..B1.198 +..B1.213: + movl 36(%ebp), %esi + cmpl $0, (%esi) +..B1.197: + je ..B1.199 +..B1.198: + lea -16517(%ecx,%eax), %ecx + movl 40(%esp), %eax + lea -16383(%eax,%edx), %edx + cmpl %edx, %ecx + jl ..B1.200 +..B1.199: + movl 44(%ebp), %eax + movl (%ebx), %edx + movl %edx, (%eax) + movl 4(%ebx), %ecx + movl %ecx, 4(%eax) + movl 8(%ebx), %esi + movl %esi, 8(%eax) + movl 12(%ebx), %edi + movl %edi, 12(%eax) + movl 16(%ebx), %edx + movl %edx, 16(%eax) + movl 20(%ebx), %ecx + movl %ecx, 20(%eax) + movl 24(%ebx), %ebx + movl %ebx, 24(%eax) + jmp ..B1.201 +..B1.200: + movl 36(%ebp), %eax + movl 44(%ebp), %edx + movl (%eax), %ecx + movl %ecx, (%edx) + movl 4(%eax), %ebx + movl %ebx, 4(%edx) + movl 8(%eax), %esi + movl %esi, 8(%edx) + movl 12(%eax), %edi + movl %edi, 12(%edx) + movl 16(%eax), %ecx + movl %ecx, 16(%edx) + movl 20(%eax), %ebx + movl %ebx, 20(%edx) + movl 24(%eax), %eax + movl %eax, 24(%edx) +..B1.201: + movl 200(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.203 +..B1.202: + addl $212, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.203: + movl 60(%esp), %ebx + call __stack_chk_fail@PLT +..B1.204: + fldt 172(%esp) + incl %ecx + fldt 48(%esp) + fmul %st, %st(1) + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fstpt 172(%esp) + fldt 184(%esp) + fmulp %st, %st(1) + movl %ecx, 196(%esp) + fstpt 184(%esp) + fldt 184(%esp) + jmp ..B1.171 +..B1.205: + fldt 144(%esp) + incl %edx + movl 60(%esp), %eax + movl %edx, 168(%esp) + fldt 48+_CONSTANTS@GOTOFF(%eax) + fmul %st, %st(1) + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fstpt 144(%esp) + fstpt 48(%esp) + fldt 48(%esp) + fldt 156(%esp) + fmulp %st, %st(1) + fstpt 156(%esp) + fldt 156(%esp) + jmp ..B1.102 + .align 16,0x90 + .type __libm_carctrigprepare_k80,@function + .size __libm_carctrigprepare_k80,.-__libm_carctrigprepare_k80 + .data +# -- End __libm_carctrigprepare_k80 + .text +# -- Begin __libm_recacosl_k80 + .text + .align 16,0x90 + .hidden __libm_recacosl_k80 + .globl __libm_recacosl_k80 +__libm_recacosl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +# parameter 4: 20 + %ebp +# parameter 5: 24 + %ebp +# parameter 6: 28 + %ebp +# parameter 7: 32 + %ebp +# parameter 8: 36 + %ebp +# parameter 9: 40 + %ebp +# parameter 10: 44 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $500, %esp + movl 16(%ebp), %esi + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 488(%esp) + movzwl 8(%esi), %eax + andl $32767, %eax + movl 44(%ebp), %edi + cmpl $8383, %eax + jl ..B2.5 +..B2.2: + cmpl $24383, %eax + jg ..B2.5 +..B2.3: + movzwl 8(%edi), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.5 +..B2.4: + cmpl $24383, %eax + jle ..B2.7 +..B2.5: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B2.6: + addl $4, %esp + pushl %edi + call __libm_normalizel_k80 +..B2.7: + fldt (%esi) + fld %st(0) + fldt (%edi) + fdivr %st, %st(1) + fld %st(0) + call ..L4 +..L4: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%eax), %eax + fld %st(1) + movl 24(%esi), %ebx + subl 24(%edi), %ebx + fldt 36+_CONSTANTS@GOTOFF(%eax) + fld %st(0) + fmul %st(5), %st + lea 1(%ebx), %edx + fld %st(0) + movl %eax, 92(%esp) + fsubr %st(6), %st + movl %edx, 484(%esp) + faddp %st, %st(1) + fld %st(0) + fsubr %st(6), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(4) + fld %st(4) + fsub %st(4), %st + fxch %st(3) + fstpt 80(%esp) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fsubrp %st, %st(3) + fldt 12(%esi) + faddp %st, %st(3) + fldt 12(%edi) + fmul %st(2), %st + fsubrp %st, %st(3) + fdivrp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 460(%esp) + fldt 460(%esp) + fsubrp %st, %st(1) + movzwl 468(%esp), %ecx + fadd %st(1), %st + andl $32767, %ecx + fstpt 472(%esp) + fstpt 48(%esp) + lea 1(%ecx,%ebx), %eax + cmpl $16382, %eax + jl ..B2.200 +..B2.8: + movl 8(%ebp), %eax + movl 40(%ebp), %ebx + movzwl 8(%eax), %edx + andl $32767, %edx + cmpl $16383, %edx + jl ..B2.39 +..B2.9: + movl 32(%ebp), %eax + movl (%eax), %edx + movl %edx, 264(%esp) + movl 8(%eax), %edx + movl 4(%eax), %ecx + movl %edx, 272(%esp) + movl 16(%eax), %edx + movl %ecx, 268(%esp) + movl 12(%eax), %ecx + movl %edx, 280(%esp) + movzwl 8(%ebx), %edx + movl %ecx, 276(%esp) + movl 20(%eax), %ecx + movl %edx, 68(%esp) + andl $32767, %edx + movl 24(%eax), %eax + cmpl $8383, %edx + movl %ecx, 284(%esp) + movl %eax, 288(%esp) + jl ..B2.13 +..B2.10: + cmpl $24383, %edx + jg ..B2.13 +..B2.11: + movl 24(%ebp), %eax + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) + cmpl $8383, %ecx + jl ..B2.13 +..B2.12: + cmpl $24383, 40(%esp) + jle ..B2.16 +..B2.13: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B2.14: + addl $4, %esp + pushl 24(%ebp) + call __libm_normalizel_k80 +..B2.15: + movl 24(%ebp), %eax + movzwl 8(%ebx), %edx + movl %edx, 68(%esp) + andl $32767, %edx + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) +..B2.16: + movl 24(%ebp), %ecx + movl 24(%ecx), %eax + movl 40(%esp), %ecx + movl %eax, 64(%esp) + lea -134(%eax,%ecx), %eax + movl 24(%ebx), %ecx + movl %ecx, 60(%esp) + addl %edx, %ecx + movl %ecx, 36(%esp) + cmpl %ecx, %eax + jge ..B2.33 +..B2.17: + movl 4(%ebx), %eax + movl %eax, 32(%esp) + movl 64(%esp), %ecx + movl 40(%esp), %eax + lea 134(%ecx,%eax), %ecx + cmpl 36(%esp), %ecx + jle ..B2.34 +..B2.18: + cmpl $0, 32(%esp) + jne ..B2.20 +..B2.19: + cmpl $0, (%ebx) + je ..B2.35 +..B2.20: + movl 24(%ebp), %eax + cmpl $0, 4(%eax) + jne ..B2.22 +..B2.21: + movl 24(%ebp), %eax + cmpl $0, (%eax) + je ..B2.34 +..B2.22: + movl 64(%esp), %eax + cmpl 60(%esp), %eax + je ..B2.24 +..B2.23: + fldt 48(%esp) + movl 60(%esp), %eax + movl 64(%esp), %ecx + subl %ecx, %eax + fstpt 32(%esp) + addl $16383, %eax + fldt (%ebx) + andl $32767, %eax + fldt 12(%ebx) + andb $127, 41(%esp) + movzwl 40(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %ecx, 24(%ebx) + movl 24(%ebp), %ecx + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fstpt 48(%esp) + fmulp %st, %st(1) + movl 24(%ecx), %eax + fstpt 12(%ebx) + fldt 12(%ebx) + movl %eax, 64(%esp) + movzwl 8(%ebx), %edx + movzwl 8(%ecx), %eax + movl %edx, 68(%esp) + movl %eax, 44(%esp) + jmp ..B2.25 +..B2.24: + fldt (%ebx) + fstpt 48(%esp) + fldt 12(%ebx) +..B2.25: + fldt 48(%esp) + movl 24(%ebp), %edx + movl 64(%esp), %eax + movl %eax, 316(%esp) + fldt (%edx) + movl 68(%esp), %ecx + fadd %st, %st(1) + movl 44(%esp), %eax + andl $32767, %ecx + andl $32767, %eax + cmpl %eax, %ecx + jg ..B2.30 +..B2.26: + jne ..B2.31 +..B2.27: + movl 24(%ebp), %edx + movl 4(%ebx), %eax + cmpl 4(%edx), %eax + ja ..B2.30 +..B2.28: + jne ..B2.31 +..B2.29: + movl 24(%ebp), %edx + movl (%ebx), %eax + cmpl (%edx), %eax + jbe ..B2.31 +..B2.30: + fldt 48(%esp) + movl 24(%ebp), %eax + fsub %st(2), %st + faddp %st, %st(1) + fldt 12(%eax) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + jmp ..B2.32 +..B2.31: + fldt 48(%esp) + fxch %st(1) + fsub %st(2), %st + movl 24(%ebp), %eax + faddp %st, %st(1) + faddp %st, %st(2) + fldt 12(%eax) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) +..B2.32: + fldt 48(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 292(%esp) + fldt 292(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 304(%esp) + jmp ..B2.69 +..B2.33: + movl 4(%ebx), %eax + movl %eax, 32(%esp) +..B2.34: + cmpl $0, 32(%esp) + jne ..B2.36 +..B2.241: + cmpl $0, (%ebx) +..B2.35: + je ..B2.37 +..B2.36: + movl 64(%esp), %ecx + movl 40(%esp), %eax + lea -16517(%ecx,%eax), %eax + movl 60(%esp), %ecx + lea -16383(%ecx,%edx), %edx + cmpl %edx, %eax + jl ..B2.38 +..B2.37: + movl 24(%ebp), %eax + movl (%eax), %edx + movl 4(%eax), %ecx + movl 8(%eax), %ebx + movl %edx, 292(%esp) + movl %ecx, 296(%esp) + movl %ebx, 300(%esp) + movl 12(%eax), %edx + movl 16(%eax), %ecx + movl 20(%eax), %ebx + movl 24(%eax), %eax + movl %edx, 304(%esp) + movl %ecx, 308(%esp) + movl %ebx, 312(%esp) + movl %eax, 316(%esp) + jmp ..B2.69 +..B2.38: + movl (%ebx), %eax + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl %eax, 292(%esp) + movl %edx, 296(%esp) + movl %ecx, 300(%esp) + movl 12(%ebx), %eax + movl 16(%ebx), %edx + movl 20(%ebx), %ecx + movl 24(%ebx), %ebx + movl %eax, 304(%esp) + movl %edx, 308(%esp) + movl %ecx, 312(%esp) + movl %ebx, 316(%esp) + jmp ..B2.69 +..B2.39: + movl 92(%esp), %eax + movzwl 8(%ebx), %edx + movl %edx, 68(%esp) + andl $32767, %edx + fldt _CONSTANTS@GOTOFF(%eax) + cmpl $8383, %edx + movl $0, 316(%esp) + fstpt 292(%esp) + fldt 24+_CONSTANTS@GOTOFF(%eax) + fstpt 304(%esp) + jl ..B2.43 +..B2.40: + cmpl $24383, %edx + jg ..B2.43 +..B2.41: + movl 24(%ebp), %eax + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) + cmpl $8383, %ecx + jl ..B2.43 +..B2.42: + cmpl $24383, 40(%esp) + jle ..B2.46 +..B2.43: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B2.44: + addl $4, %esp + pushl 24(%ebp) + call __libm_normalizel_k80 +..B2.45: + movl 24(%ebp), %eax + movzwl 8(%ebx), %edx + movl %edx, 68(%esp) + andl $32767, %edx + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) +..B2.46: + movl 24(%ebp), %ecx + movl 24(%ecx), %eax + movl 40(%esp), %ecx + movl %eax, 64(%esp) + lea -134(%eax,%ecx), %eax + movl 24(%ebx), %ecx + movl %ecx, 60(%esp) + addl %edx, %ecx + movl %ecx, 36(%esp) + cmpl %ecx, %eax + jge ..B2.63 +..B2.47: + movl 4(%ebx), %eax + movl %eax, 32(%esp) + movl 64(%esp), %ecx + movl 40(%esp), %eax + lea 134(%ecx,%eax), %ecx + cmpl 36(%esp), %ecx + jle ..B2.64 +..B2.48: + cmpl $0, 32(%esp) + jne ..B2.50 +..B2.49: + cmpl $0, (%ebx) + je ..B2.65 +..B2.50: + movl 24(%ebp), %eax + cmpl $0, 4(%eax) + jne ..B2.52 +..B2.51: + movl 24(%ebp), %eax + cmpl $0, (%eax) + je ..B2.64 +..B2.52: + movl 64(%esp), %eax + cmpl 60(%esp), %eax + je ..B2.54 +..B2.53: + fldt 48(%esp) + movl 60(%esp), %eax + movl 64(%esp), %ecx + subl %ecx, %eax + fstpt 32(%esp) + addl $16383, %eax + fldt (%ebx) + andl $32767, %eax + fldt 12(%ebx) + andb $127, 41(%esp) + movzwl 40(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %ecx, 24(%ebx) + movl 24(%ebp), %ecx + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + movl 24(%ecx), %eax + fstpt 12(%ebx) + fldt 12(%ebx) + movl %eax, 64(%esp) + movzwl 8(%ebx), %edx + movzwl 8(%ecx), %eax + fstpt 48(%esp) + movl %edx, 68(%esp) + movl %eax, 44(%esp) + jmp ..B2.55 +..B2.54: + fldt (%ebx) + fldt 12(%ebx) + fstpt 48(%esp) +..B2.55: + movl 24(%ebp), %edx + fld %st(0) + movl 64(%esp), %eax + movl %eax, 288(%esp) + fldt (%edx) + movl 68(%esp), %ecx + fsubr %st, %st(1) + movl 44(%esp), %eax + andl $32767, %ecx + andl $32767, %eax + cmpl %eax, %ecx + jg ..B2.60 +..B2.56: + jne ..B2.61 +..B2.57: + movl 24(%ebp), %edx + movl 4(%ebx), %eax + cmpl 4(%edx), %eax + ja ..B2.60 +..B2.58: + jne ..B2.61 +..B2.59: + movl 24(%ebp), %edx + movl (%ebx), %eax + cmpl (%edx), %eax + jbe ..B2.61 +..B2.60: + fldt 48(%esp) + fxch %st(2) + fsubr %st, %st(3) + movl 24(%ebp), %eax + fxch %st(1) + fsubrp %st, %st(3) + fldt 12(%eax) + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 48(%esp) + jmp ..B2.62 +..B2.61: + movl 24(%ebp), %eax + fadd %st(1), %st + fsubrp %st, %st(2) + fldt 48(%esp) + faddp %st, %st(2) + fldt 12(%eax) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) +..B2.62: + fldt 48(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 264(%esp) + fldt 264(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 276(%esp) + jmp ..B2.69 +..B2.63: + movl 4(%ebx), %eax + movl %eax, 32(%esp) +..B2.64: + cmpl $0, 32(%esp) + jne ..B2.66 +..B2.240: + cmpl $0, (%ebx) +..B2.65: + je ..B2.67 +..B2.66: + movl 64(%esp), %eax + movl 40(%esp), %ecx + movl 60(%esp), %ebx + lea -16517(%eax,%ecx), %eax + lea -16383(%ebx,%edx), %edx + movl 40(%ebp), %ebx + cmpl %edx, %eax + jl ..B2.68 +..B2.67: + movl 24(%ebp), %edx + movl 64(%esp), %eax + movl %eax, 288(%esp) + fldt (%edx) + fchs + fstpt 264(%esp) + fldt 12(%edx) + fchs + fstpt 276(%esp) + jmp ..B2.69 +..B2.68: + movl (%ebx), %eax + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl %eax, 264(%esp) + movl %edx, 268(%esp) + movl %ecx, 272(%esp) + movl 12(%ebx), %eax + movl 16(%ebx), %edx + movl 20(%ebx), %ecx + movl 24(%ebx), %ebx + movl %eax, 276(%esp) + movl %edx, 280(%esp) + movl %ecx, 284(%esp) + movl %ebx, 288(%esp) +..B2.69: + movzwl 8(%esi), %eax + movl %eax, 68(%esp) + andl $32767, %eax + movl 24(%esi), %ecx + incl %ecx + movl %ecx, 24(%esi) + cmpl $8383, %eax + movl %eax, 76(%esp) + jl ..B2.73 +..B2.70: + cmpl $24383, 76(%esp) + jg ..B2.73 +..B2.71: + movzwl 8(%edi), %edx + movl %edx, %eax + andl $32767, %eax + movl %eax, 72(%esp) + cmpl $8383, %eax + jl ..B2.73 +..B2.72: + cmpl $24383, 72(%esp) + jle ..B2.76 +..B2.73: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B2.74: + addl $4, %esp + pushl %edi + call __libm_normalizel_k80 +..B2.75: + movzwl 8(%esi), %edx + movl %edx, 68(%esp) + andl $32767, %edx + movl %edx, 76(%esp) + movzwl 8(%edi), %edx + movl %edx, %eax + andl $32767, %eax + movl %eax, 72(%esp) + movl 24(%esi), %ecx +..B2.76: + movl 76(%esp), %ebx + movl 24(%edi), %edi + movl %edi, 64(%esp) + lea (%ecx,%ebx), %eax + movl 72(%esp), %ebx + movl %eax, 60(%esp) + lea -134(%edi,%ebx), %edi + cmpl %edi, %eax + movl 44(%ebp), %edi + jle ..B2.93 +..B2.77: + movl 4(%esi), %eax + movl %eax, 44(%esp) + movl 64(%esp), %ebx + movl 72(%esp), %eax + lea 134(%ebx,%eax), %ebx + cmpl 60(%esp), %ebx + jle ..B2.94 +..B2.78: + cmpl $0, 44(%esp) + jne ..B2.80 +..B2.79: + cmpl $0, (%esi) + je ..B2.95 +..B2.80: + cmpl $0, 4(%edi) + jne ..B2.82 +..B2.81: + cmpl $0, (%edi) + je ..B2.94 +..B2.82: + cmpl 64(%esp), %ecx + je ..B2.84 +..B2.83: + fldt 48(%esp) + movl 64(%esp), %edx + subl %edx, %ecx + fstpt 32(%esp) + addl $16383, %ecx + fldt (%esi) + andl $32767, %ecx + fldt 12(%esi) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %ecx, %eax + movl %edx, %ecx + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 24(%esi) + fxch %st(2) + fstpt (%esi) + fldt (%esi) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esi) + fldt 12(%esi) + movl 24(%edi), %ebx + movzwl 8(%esi), %eax + movl %ebx, 64(%esp) + movl %eax, 68(%esp) + movzwl 8(%edi), %edx + jmp ..B2.85 +..B2.84: + fldt (%esi) + fldt 12(%esi) +..B2.85: + fldt (%edi) + fld %st(2) + movl 64(%esp), %eax + fadd %st(1), %st + movl %eax, 344(%esp) + movl %edx, %eax + movl 68(%esp), %ebx + andl $32767, %eax + andl $32767, %ebx + cmpl %eax, %ebx + jg ..B2.90 +..B2.86: + jne ..B2.91 +..B2.87: + movl 4(%esi), %eax + cmpl 4(%edi), %eax + ja ..B2.90 +..B2.88: + jne ..B2.91 +..B2.89: + movl (%esi), %eax + cmpl (%edi), %eax + jbe ..B2.91 +..B2.90: + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 12(%edi) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + jmp ..B2.92 +..B2.91: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%edi) + faddp %st, %st(2) +..B2.92: + fld %st(1) + fadd %st(1), %st + fstpt 320(%esp) + fldt 320(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 332(%esp) + jmp ..B2.99 +..B2.93: + movl 4(%esi), %eax + movl %eax, 44(%esp) +..B2.94: + cmpl $0, 44(%esp) + jne ..B2.96 +..B2.242: + cmpl $0, (%esi) +..B2.95: + je ..B2.97 +..B2.96: + movl 64(%esp), %ebx + movl 72(%esp), %eax + lea -16517(%ebx,%eax), %eax + movl 76(%esp), %ebx + lea -16383(%ecx,%ebx), %ebx + cmpl %ebx, %eax + jl ..B2.98 +..B2.97: + movl (%edi), %eax + movl %eax, 320(%esp) + movl 4(%edi), %ebx + movl 8(%edi), %eax + movl %ebx, 324(%esp) + movl %eax, 328(%esp) + movl 12(%edi), %ebx + movl 16(%edi), %eax + movl %ebx, 332(%esp) + movl %eax, 336(%esp) + movl 20(%edi), %ebx + movl 24(%edi), %eax + movl %ebx, 340(%esp) + movl %eax, 344(%esp) + jmp ..B2.99 +..B2.98: + movl (%esi), %eax + movl %eax, 320(%esp) + movl 4(%esi), %ebx + movl 8(%esi), %eax + movl %ebx, 324(%esp) + movl %eax, 328(%esp) + movl 12(%esi), %ebx + movl 16(%esi), %eax + movl %ebx, 332(%esp) + movl %eax, 336(%esp) + movl 20(%esi), %ebx + movl 24(%esi), %eax + movl %ebx, 340(%esp) + movl %eax, 344(%esp) +..B2.99: + movzwl 328(%esp), %eax + decl %ecx + andl $32767, %eax + movl %ecx, 24(%esi) + cmpl $8383, %eax + jl ..B2.103 +..B2.100: + cmpl $24383, %eax + jg ..B2.103 +..B2.101: + movzwl 272(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.103 +..B2.102: + cmpl $24383, %eax + jle ..B2.105 +..B2.103: + addl $4, %esp + lea 316(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.104: + addl $4, %esp + lea 260(%esp), %eax + pushl %eax + call __libm_normalizel_k80 + movzwl 8(%edi), %edx +..B2.105: + fldt 320(%esp) + andl $32767, %edx + fld %st(0) + fld %st(1) + fldt 80(%esp) + fld %st(0) + fmul %st(4), %st + movl 344(%esp), %eax + fsubr %st, %st(3) + addl 288(%esp), %eax + faddp %st, %st(3) + fld %st(2) + cmpl $8383, %edx + movl %eax, 372(%esp) + fxch %st(2) + fsub %st(3), %st + fldt 264(%esp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 276(%esp) + fmulp %st, %st(4) + fldt 332(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 348(%esp) + fldt 348(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 360(%esp) + jl ..B2.109 +..B2.106: + cmpl $24383, %edx + jg ..B2.109 +..B2.107: + movzwl 300(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.109 +..B2.108: + cmpl $24383, %eax + jle ..B2.111 +..B2.109: + addl $4, %esp + pushl %edi + call __libm_normalizel_k80 +..B2.110: + addl $4, %esp + lea 288(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.111: + fldt (%edi) + fld %st(0) + fld %st(1) + fldt 80(%esp) + fld %st(0) + fmul %st(4), %st + movl 36(%ebp), %ebx + fsubr %st, %st(3) + movl 316(%esp), %eax + faddp %st, %st(3) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fldt 292(%esp) + fmul %st, %st(2) + fld %st(0) + addl 24(%edi), %eax + fsub %st(3), %st + movl 28(%ebp), %esi + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + movl %eax, 400(%esp) + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 304(%esp) + fmulp %st, %st(4) + fldt 12(%edi) + fmulp %st, %st(1) + movzwl 8(%ebx), %edi + movl %edi, %ecx + andl $32767, %ecx + faddp %st, %st(3) + cmpl $8383, %ecx + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 376(%esp) + fldt 376(%esp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 388(%esp) + fstpt 48(%esp) + jl ..B2.115 +..B2.112: + cmpl $24383, %ecx + jg ..B2.115 +..B2.113: + movzwl 8(%esi), %edx + movl %edx, 60(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B2.115 +..B2.114: + cmpl $24383, %edx + jle ..B2.118 +..B2.115: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B2.116: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B2.117: + movzwl 8(%ebx), %edi + movl %edi, %ecx + movzwl 8(%esi), %edx + andl $32767, %ecx + movl %edx, 60(%esp) + andl $32767, %edx +..B2.118: + movl 24(%esi), %eax + movl 24(%ebx), %ebx + movl %eax, 72(%esp) + movl %ebx, 68(%esp) + lea -134(%eax,%edx), %eax + addl %ecx, %ebx + movl %ebx, 64(%esp) + cmpl %eax, %ebx + movl 36(%ebp), %ebx + jle ..B2.135 +..B2.119: + movl 4(%ebx), %eax + movl %eax, 44(%esp) + movl 72(%esp), %eax + lea 134(%eax,%edx), %eax + cmpl 64(%esp), %eax + jle ..B2.136 +..B2.120: + cmpl $0, 44(%esp) + jne ..B2.122 +..B2.121: + cmpl $0, (%ebx) + je ..B2.137 +..B2.122: + cmpl $0, 4(%esi) + jne ..B2.124 +..B2.123: + cmpl $0, (%esi) + je ..B2.136 +..B2.124: + movl 72(%esp), %eax + cmpl 68(%esp), %eax + je ..B2.126 +..B2.125: + fldt 48(%esp) + movl 68(%esp), %edi + movl %eax, %edx + subl %edx, %edi + fstpt 32(%esp) + addl $16383, %edi + fldt (%ebx) + andl $32767, %edi + fldt 12(%ebx) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 24(%ebx) + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt 12(%ebx) + movl 24(%esi), %ecx + movzwl 8(%esi), %eax + movl %ecx, 72(%esp) + movzwl 8(%ebx), %edi + movl %eax, 60(%esp) + jmp ..B2.127 +..B2.126: + fldt (%ebx) + fldt 12(%ebx) +..B2.127: + fldt (%esi) + andl $32767, %edi + movl 60(%esp), %edx + fld %st(2) + andl $32767, %edx + fadd %st(1), %st + movl 72(%esp), %eax + cmpl %edx, %edi + movl %eax, 428(%esp) + jg ..B2.132 +..B2.128: + jne ..B2.133 +..B2.129: + movl 4(%ebx), %eax + cmpl 4(%esi), %eax + ja ..B2.132 +..B2.130: + jne ..B2.133 +..B2.131: + movl (%ebx), %eax + cmpl (%esi), %eax + jbe ..B2.133 +..B2.132: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 12(%esi) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.134 +..B2.133: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 12(%esi) + faddp %st, %st(1) +..B2.134: + fld %st(0) + fadd %st(2), %st + fstpt 404(%esp) + fldt 404(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 416(%esp) + jmp ..B2.141 +..B2.135: + movl 4(%ebx), %eax + movl %eax, 44(%esp) +..B2.136: + cmpl $0, 44(%esp) + jne ..B2.138 +..B2.243: + cmpl $0, (%ebx) +..B2.137: + je ..B2.139 +..B2.138: + movl 72(%esp), %eax + lea -16517(%eax,%edx), %edi + movl 68(%esp), %edx + lea -16383(%edx,%ecx), %ecx + cmpl %ecx, %edi + jl ..B2.140 +..B2.139: + movl (%esi), %eax + movl %eax, 404(%esp) + movl 4(%esi), %edx + movl 8(%esi), %ecx + movl 12(%esi), %ebx + movl 16(%esi), %edi + movl 20(%esi), %eax + movl 24(%esi), %esi + movl %edx, 408(%esp) + movl %ecx, 412(%esp) + movl %ebx, 416(%esp) + movl %edi, 420(%esp) + movl %eax, 424(%esp) + movl %esi, 428(%esp) + jmp ..B2.141 +..B2.140: + movl (%ebx), %eax + movl %eax, 404(%esp) + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl 12(%ebx), %esi + movl 16(%ebx), %edi + movl 20(%ebx), %eax + movl 24(%ebx), %ebx + movl %edx, 408(%esp) + movl %ecx, 412(%esp) + movl %esi, 416(%esp) + movl %edi, 420(%esp) + movl %eax, 424(%esp) + movl %ebx, 428(%esp) +..B2.141: + movzwl 384(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.145 +..B2.142: + cmpl $24383, %eax + jg ..B2.145 +..B2.143: + movzwl 412(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.145 +..B2.144: + cmpl $24383, %eax + jle ..B2.147 +..B2.145: + addl $4, %esp + lea 372(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.146: + addl $4, %esp + lea 400(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.147: + fldt 376(%esp) + fld %st(0) + fld %st(1) + fldt 80(%esp) + fld %st(0) + fmul %st(4), %st + movl 400(%esp), %edx + fsubr %st, %st(3) + movzwl 356(%esp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + addl 428(%esp), %edx + fxch %st(2) + fsub %st(3), %st + fldt 404(%esp) + cmpl $8383, %eax + fmul %st, %st(2) + fld %st(0) + movl %edx, 456(%esp) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 416(%esp) + fmulp %st, %st(4) + fldt 388(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 432(%esp) + fldt 432(%esp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 444(%esp) + fldt 444(%esp) + jl ..B2.151 +..B2.148: + cmpl $24383, %eax + jg ..B2.151 +..B2.149: + movzwl 440(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.151 +..B2.150: + cmpl $24383, %eax + jle ..B2.154 +..B2.151: + fstp %st(1) + fstp %st(0) + addl $4, %esp + lea 344(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.152: + addl $4, %esp + lea 428(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.153: + fldt 432(%esp) + fldt 444(%esp) + movl 456(%esp), %edx +..B2.154: + fldt 348(%esp) + fld %st(2) + fdivr %st(1), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(4) + fstpt 64(%esp) + fldt 64(%esp) + fldt 80(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + movl 372(%esp), %eax + fsubr %st(4), %st + subl %edx, %eax + faddp %st, %st(1) + fld %st(0) + movl 8(%ebp), %edx + fsubr %st(4), %st + fxch %st(2) + fmul %st(3), %st + movzbl 9(%edx), %ecx + testl $128, %ecx + fsubr %st, %st(7) + faddp %st, %st(7) + fxch %st(2) + fsub %st(6), %st + fld %st(2) + fmul %st(7), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(3) + fxch %st(7) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fxch %st(4) + fsubrp %st, %st(2) + fxch %st(3) + fsubrp %st, %st(1) + fldt 360(%esp) + faddp %st, %st(1) + fsubp %st, %st(1) + fldt 64(%esp) + fdivrp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fstpt 48(%esp) + jne ..B2.163 +..B2.155: + fstpt 32(%esp) + fldt 32(%esp) + decl %eax + movzwl 40(%esp), %edx + andl $32767, %edx + movl %eax, 56(%esp) + cmpl $383, %edx + fxch %st(1) + fstpt 44(%esp) + fldt 44(%esp) + jl ..B2.157 +..B2.156: + cmpl $32383, %edx + jle ..B2.159 +..B2.157: + fstp %st(0) + fstp %st(0) + addl $4, %esp + lea 28(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.158: + fldt 32(%esp) + fldt 44(%esp) + movl 56(%esp), %eax +..B2.159: + testb $1, %al + jne ..B2.234 +..B2.160: + movl 92(%esp), %edx + fldt 48+_CONSTANTS@GOTOFF(%edx) +..B2.161: + fldt 80(%esp) + fld %st(3) + fsqrt + lea 236(%esp), %edx + fmul %st, %st(1) + fld %st(1) + sarl $1, %eax + fsubr %st(1), %st + movl %eax, 24(%edx) + lea 208(%esp), %eax + faddp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + fdivr %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 28(%eax) + fldt 28(%eax) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 40(%eax) + call asinpoly +..B2.162: + fldt 208(%esp) + fldt 220(%esp) + movl 232(%esp), %eax + incl %eax + movl %eax, 232(%esp) + jmp ..B2.231 +..B2.163: + fstpt 124(%esp) + fldt 124(%esp) + decl %eax + movzwl 132(%esp), %edx + andl $32767, %edx + movl %eax, 148(%esp) + cmpl $383, %edx + fxch %st(1) + fstpt 136(%esp) + fldt 136(%esp) + jl ..B2.165 +..B2.164: + cmpl $32383, %edx + jle ..B2.167 +..B2.165: + fstp %st(0) + fstp %st(0) + addl $4, %esp + lea 120(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.166: + fldt 124(%esp) + fldt 136(%esp) + movl 148(%esp), %eax +..B2.167: + testb $1, %al + jne ..B2.235 +..B2.168: + movl 92(%esp), %edx + fldt 48+_CONSTANTS@GOTOFF(%edx) +..B2.169: + fldt 80(%esp) + fld %st(3) + fsqrt + lea 152(%esp), %edx + fmul %st, %st(1) + fld %st(1) + sarl $1, %eax + fsubr %st(1), %st + movl %eax, 24(%edx) + lea 96(%esp), %eax + faddp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + fdivr %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 56(%eax) + fldt 56(%eax) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 68(%eax) + call asinpoly +..B2.170: + movl 92(%esp), %edx + movl $1, %esi + movl 120(%esp), %eax + incl %eax + fldt 60+_CONSTANTS@GOTOFF(%edx) + movzwl 68+_CONSTANTS@GOTOFF(%edx), %edi + andl $32767, %edi + movl %eax, 120(%esp) + cmpl $8383, %edi + movl %esi, 204(%esp) + fstpt 180(%esp) + fldt 72+_CONSTANTS@GOTOFF(%edx) + fstpt 192(%esp) + jl ..B2.174 +..B2.171: + cmpl $24383, %edi + jg ..B2.174 +..B2.172: + movzwl 104(%esp), %ebx + andl $32767, %ebx + cmpl $8383, %ebx + jl ..B2.174 +..B2.173: + cmpl $24383, %ebx + jle ..B2.177 +..B2.174: + addl $4, %esp + lea 176(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.175: + addl $4, %esp + lea 92(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.176: + movzwl 188(%esp), %edi + movzwl 104(%esp), %ebx + andl $32767, %edi + movl 120(%esp), %eax + andl $32767, %ebx + movl 204(%esp), %esi +..B2.177: + lea (%esi,%edi), %edx + movl %edx, 44(%esp) + lea -134(%eax,%ebx), %ecx + cmpl %ecx, %edx + jle ..B2.194 +..B2.178: + movl 184(%esp), %ecx + lea 134(%eax,%ebx), %edx + cmpl 44(%esp), %edx + jle ..B2.195 +..B2.179: + testl %ecx, %ecx + jne ..B2.181 +..B2.180: + cmpl $0, 180(%esp) + je ..B2.196 +..B2.181: + movl 100(%esp), %edx + testl %edx, %edx + jne ..B2.183 +..B2.182: + cmpl $0, 96(%esp) + je ..B2.195 +..B2.183: + cmpl %eax, %esi + je ..B2.185 +..B2.184: + fldt 48(%esp) + subl %eax, %esi + fstpt 32(%esp) + addl $16383, %esi + fldt 180(%esp) + andl $32767, %esi + fldt 192(%esp) + andb $127, 41(%esp) + movzwl 40(%esp), %ecx + andl $-32768, %ecx + orl %esi, %ecx + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 180(%esp) + fldt 180(%esp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 188(%esp), %edi + movl %eax, 204(%esp) + andl $32767, %edi + fstpt 192(%esp) + fldt 192(%esp) + jmp ..B2.186 +..B2.185: + fldt 180(%esp) + fldt 192(%esp) +..B2.186: + fldt 96(%esp) + fld %st(2) + movl %eax, 232(%esp) + cmpl %ebx, %edi + fsub %st(1), %st + jg ..B2.191 +..B2.187: + jne ..B2.192 +..B2.188: + movl 184(%esp), %ecx + cmpl %edx, %ecx + ja ..B2.191 +..B2.189: + jne ..B2.192 +..B2.190: + movl 180(%esp), %edx + cmpl 96(%esp), %edx + jbe ..B2.192 +..B2.191: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 108(%esp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + jmp ..B2.193 +..B2.192: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 108(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) +..B2.193: + fld %st(0) + fadd %st(2), %st + fstpt 208(%esp) + fldt 208(%esp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 220(%esp) + fldt 220(%esp) + jmp ..B2.231 +..B2.194: + movl 184(%esp), %ecx +..B2.195: + testl %ecx, %ecx + jne ..B2.197 +..B2.244: + cmpl $0, 180(%esp) +..B2.196: + je ..B2.198 +..B2.197: + lea -16517(%eax,%ebx), %edx + lea -16383(%esi,%edi), %ebx + cmpl %ebx, %edx + jl ..B2.199 +..B2.198: + fldt 96(%esp) + fchs + movl %eax, 232(%esp) + fstpt 208(%esp) + fldt 208(%esp) + fldt 108(%esp) + fchs + fstpt 220(%esp) + fldt 220(%esp) + jmp ..B2.231 +..B2.199: + movl 180(%esp), %eax + movl %ecx, 212(%esp) + movl 188(%esp), %edx + movl 192(%esp), %ecx + movl 196(%esp), %ebx + movl 200(%esp), %esi + movl %eax, 208(%esp) + movl %edx, 216(%esp) + fldt 208(%esp) + movl 204(%esp), %eax + movl %ecx, 220(%esp) + movl %ebx, 224(%esp) + movl %esi, 228(%esp) + fldt 220(%esp) + movl %eax, 232(%esp) + jmp ..B2.231 +..B2.200: + movl 92(%esp), %eax + lea 460(%esp), %edx + movl $0, 84(%esp) + fldt 60+_CONSTANTS@GOTOFF(%eax) + fstpt 60(%esp) + fldt 72+_CONSTANTS@GOTOFF(%eax) + lea 96(%esp), %eax + fstpt -24(%eax) + call asinpoly +..B2.201: + fldt 96(%esp) + fldt 108(%esp) + movl 8(%ebp), %eax + movl 92(%esp), %esi + movzwl 68(%esp), %edi + movzbl 9(%eax), %ecx + andl $32767, %edi + andl $128, %ecx + shrl $7, %ecx + cmpl $8383, %edi + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %ebx + fldt _CONSTANTS@GOTOFF(%ebx,%esi) + fmul %st, %st(2) + fxch %st(2) + fstpt 96(%esp) + fmulp %st, %st(1) + fstpt 108(%esp) + jl ..B2.205 +..B2.202: + cmpl $24383, %edi + jg ..B2.205 +..B2.203: + movzwl 104(%esp), %esi + andl $32767, %esi + cmpl $8383, %esi + jl ..B2.205 +..B2.204: + cmpl $24383, %esi + jle ..B2.208 +..B2.205: + addl $4, %esp + lea 56(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.206: + addl $4, %esp + lea 92(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B2.207: + movzwl 104(%esp), %esi + movzwl 68(%esp), %edi + andl $32767, %esi + andl $32767, %edi +..B2.208: + movl 120(%esp), %eax + movl 84(%esp), %ebx + lea -134(%eax,%esi), %ecx + lea (%edi,%ebx), %edx + movl %edx, 32(%esp) + cmpl %ecx, %edx + jle ..B2.225 +..B2.209: + movl 64(%esp), %ecx + lea 134(%eax,%esi), %edx + cmpl 32(%esp), %edx + jle ..B2.226 +..B2.210: + testl %ecx, %ecx + jne ..B2.212 +..B2.211: + cmpl $0, 60(%esp) + je ..B2.227 +..B2.212: + movl 100(%esp), %edx + testl %edx, %edx + jne ..B2.214 +..B2.213: + cmpl $0, 96(%esp) + je ..B2.226 +..B2.214: + cmpl %eax, %ebx + je ..B2.216 +..B2.215: + fldt 48(%esp) + subl %eax, %ebx + fstpt 32(%esp) + addl $16383, %ebx + fldt 60(%esp) + andl $32767, %ebx + fldt 72(%esp) + andb $127, 41(%esp) + movzwl 40(%esp), %ecx + andl $-32768, %ecx + orl %ebx, %ecx + movw %cx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 60(%esp) + fldt 60(%esp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 68(%esp), %edi + movl %eax, 84(%esp) + andl $32767, %edi + fstpt 72(%esp) + fldt 72(%esp) + jmp ..B2.217 +..B2.216: + fldt 60(%esp) + fldt 72(%esp) +..B2.217: + fldt 96(%esp) + fld %st(2) + movl %eax, 232(%esp) + cmpl %esi, %edi + fsub %st(1), %st + jg ..B2.222 +..B2.218: + jne ..B2.223 +..B2.219: + movl 64(%esp), %ecx + cmpl %edx, %ecx + ja ..B2.222 +..B2.220: + jne ..B2.223 +..B2.221: + movl 60(%esp), %edx + cmpl 96(%esp), %edx + jbe ..B2.223 +..B2.222: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 108(%esp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + jmp ..B2.224 +..B2.223: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 108(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) +..B2.224: + fld %st(0) + fadd %st(2), %st + fstpt 208(%esp) + fldt 208(%esp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 220(%esp) + fldt 220(%esp) + jmp ..B2.231 +..B2.225: + movl 64(%esp), %ecx +..B2.226: + testl %ecx, %ecx + jne ..B2.228 +..B2.245: + cmpl $0, 60(%esp) +..B2.227: + je ..B2.198 +..B2.228: + lea -16517(%eax,%esi), %edx + lea -16383(%ebx,%edi), %esi + cmpl %esi, %edx + jge ..B2.198 +..B2.230: + movl %ecx, 212(%esp) + movl 60(%esp), %eax + movl 68(%esp), %edx + movl 72(%esp), %ecx + movl 76(%esp), %esi + movl 80(%esp), %edi + movl %eax, 208(%esp) + movl %ebx, %eax + movl %edx, 216(%esp) + fldt 208(%esp) + movl %ecx, 220(%esp) + movl %esi, 224(%esp) + movl %edi, 228(%esp) + fldt 220(%esp) + movl %eax, 232(%esp) +..B2.231: + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl %eax, 24(%esp) + call __libm_scalbl_k80 +..B2.232: + movl 488(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B2.236 +..B2.233: + addl $500, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.234: + movl 92(%esp), %edx + incl %eax + movl %eax, 56(%esp) + fldt 48+_CONSTANTS@GOTOFF(%edx) + fmul %st, %st(2) + fxch %st(2) + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + fmul %st(2), %st + fstpt 44(%esp) + fldt 44(%esp) + fxch %st(1) + fxch %st(2) + jmp ..B2.161 +..B2.235: + movl 92(%esp), %edx + incl %eax + movl %eax, 148(%esp) + fldt 48+_CONSTANTS@GOTOFF(%edx) + fmul %st, %st(2) + fxch %st(2) + fstpt 124(%esp) + fldt 124(%esp) + fxch %st(1) + fmul %st(2), %st + fstpt 136(%esp) + fldt 136(%esp) + fxch %st(1) + fxch %st(2) + jmp ..B2.169 +..B2.236: + fstp %st(0) + movl 92(%esp), %ebx + call __stack_chk_fail@PLT + .align 16,0x90 + .type __libm_recacosl_k80,@function + .size __libm_recacosl_k80,.-__libm_recacosl_k80 + .data +# -- End __libm_recacosl_k80 + .text +# -- Begin asinpoly + .text + .align 16,0x90 +asinpoly: +# parameter 1: %eax +# parameter 2: %edx +..B3.1: +..L5: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $164, %esp + movl %edx, %esi + call ..L6 +..L6: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L6](%ecx), %ecx + movl %eax, %ebx + movl 24(%esi), %edx + fldt _CONSTANTS@GOTOFF(%ecx) + movzwl 8+_CONSTANTS@GOTOFF(%ecx), %eax + andl $-32768, %eax + lea 16383(%edx), %edi + andl $32767, %edi + orl %edi, %eax + movzwl 8(%esi), %edi + andl $32767, %edi + addl %edi, %edx + fstpt 136(%esp) + cmpl $16343, %edx + jl ..B3.38 +..B3.2: + fldt (%esi) + fldt 12(%esi) + fldt 264+_CONSTANTS@GOTOFF(%ecx) + fldt 240+_CONSTANTS@GOTOFF(%ecx) + fldt 216+_CONSTANTS@GOTOFF(%ecx) + movw %ax, 144(%esp) + fldt 136(%esp) + fmul %st, %st(5) + fld %st(5) + fmul %st(6), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fmulp %st, %st(6) + fxch %st(5) + fstpt 40(%esp) + fldt 40(%esp) + fxch %st(6) + fstpt 104(%esp) + fldt 104(%esp) + fstpt (%esp) + fldt (%esp) + fldt 288+_CONSTANTS@GOTOFF(%ecx) + fmul %st(2), %st + faddp %st, %st(5) + fxch %st(1) + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 192+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 168+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 144+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 276+_CONSTANTS@GOTOFF(%ecx) + fmul %st(1), %st + fldt 252+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 228+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 204+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 180+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 156+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 132+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fld %st(1) + fldt 36+_CONSTANTS@GOTOFF(%ecx) + fstpt 72(%esp) + fldt 72(%esp) + fmul %st(3), %st + movzwl 20(%esp), %eax + fsubr %st, %st(1) + andl $32767, %eax + faddp %st, %st(1) + fld %st(0) + cmpl $16377, %eax + fsubr %st(3), %st + fstpt 56(%esp) + fldt 56(%esp) + fld %st(1) + fmul %st(2), %st + fxch %st(5) + fmulp %st, %st(4) + fxch %st(3) + fadd %st(0), %st + fxch %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fmul %st(3), %st + fadd %st(0), %st + fld %st(0) + fadd %st(5), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(6) + fxch %st(2) + faddp %st, %st(6) + fxch %st(4) + fmul %st(0), %st + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 88(%esp) + fldt 88(%esp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 120(%esp) + fldt 120+_CONSTANTS@GOTOFF(%ecx) + fld %st(0) + fadd %st(2), %st + jg ..B3.7 +..B3.3: + jne ..B3.8 +..B3.4: + movl 16(%esp), %eax + cmpl 124+_CONSTANTS@GOTOFF(%ecx), %eax + ja ..B3.7 +..B3.5: + jne ..B3.8 +..B3.6: + movl 12(%esp), %eax + cmpl 120+_CONSTANTS@GOTOFF(%ecx), %eax + jbe ..B3.8 +..B3.7: + fldt 336+_CONSTANTS@GOTOFF(%ecx) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 24+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + jmp ..B3.9 +..B3.8: + fldt 24+_CONSTANTS@GOTOFF(%ecx) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 336+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) +..B3.9: + fldt 88(%esp) + fld %st(0) + fld %st(2) + fadd %st(4), %st + fld %st(0) + fld %st(1) + fxch %st(2) + fsubr %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fxch %st(3) + fmul %st, %st(5) + fldt 72(%esp) + fld %st(0) + fmul %st(6), %st + fsubr %st, %st(5) + faddp %st, %st(5) + fxch %st(2) + fsub %st(4), %st + fld %st(1) + fmulp %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fstpt 136(%esp) + fldt 136(%esp) + fsubr %st, %st(2) + fxch %st(2) + fstpt 152(%esp) + fldt 152(%esp) + fld %st(3) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(4) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fldt 120(%esp) + fmulp %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fldt 152(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubr %st, %st(2) + movzwl 20(%esp), %eax + fxch %st(1) + faddp %st, %st(2) + fldt 108+_CONSTANTS@GOTOFF(%ecx) + andl $32767, %eax + fld %st(0) + cmpl $16378, %eax + fadd %st(2), %st + jg ..B3.14 +..B3.10: + jne ..B3.15 +..B3.11: + movl 16(%esp), %eax + cmpl 112+_CONSTANTS@GOTOFF(%ecx), %eax + ja ..B3.14 +..B3.12: + jne ..B3.15 +..B3.13: + movl 12(%esp), %eax + cmpl 108+_CONSTANTS@GOTOFF(%ecx), %eax + jbe ..B3.15 +..B3.14: + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 324+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + jmp ..B3.16 +..B3.15: + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt 324+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(2) +..B3.16: + fldt 136(%esp) + fld %st(0) + fld %st(3) + fadd %st(3), %st + fld %st(0) + fld %st(1) + fxch %st(2) + fsubr %st, %st(5) + fxch %st(6) + faddp %st, %st(5) + fldt 72(%esp) + fmul %st(6), %st + fsubr %st, %st(1) + faddp %st, %st(1) + fmul %st, %st(2) + fsubr %st, %st(1) + fxch %st(1) + fmul %st, %st(3) + fldt 152(%esp) + fmul %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt 120(%esp) + fmulp %st, %st(5) + fldt 88(%esp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubr %st, %st(1) + movzwl 20(%esp), %eax + fxch %st(2) + faddp %st, %st(1) + fldt 96+_CONSTANTS@GOTOFF(%ecx) + andl $32767, %eax + fld %st(0) + cmpl $16379, %eax + fadd %st(3), %st + jg ..B3.21 +..B3.17: + jne ..B3.22 +..B3.18: + movl 16(%esp), %eax + cmpl 100+_CONSTANTS@GOTOFF(%ecx), %eax + ja ..B3.21 +..B3.19: + jne ..B3.22 +..B3.20: + movl 12(%esp), %eax + cmpl 96+_CONSTANTS@GOTOFF(%ecx), %eax + jbe ..B3.22 +..B3.21: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 312+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + jmp ..B3.23 +..B3.22: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 312+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(1) +..B3.23: + fldt 136(%esp) + fld %st(0) + fld %st(2) + fadd %st(4), %st + fld %st(0) + fld %st(1) + fxch %st(2) + fsubr %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fldt 72(%esp) + fmul %st(5), %st + fsubr %st, %st(1) + faddp %st, %st(1) + fmul %st, %st(2) + fsubr %st, %st(1) + fxch %st(1) + fmul %st, %st(3) + fldt 152(%esp) + fmul %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 120(%esp) + fmulp %st, %st(3) + fldt 88(%esp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubr %st, %st(2) + movzwl 20(%esp), %eax + fxch %st(1) + faddp %st, %st(2) + fldt 84+_CONSTANTS@GOTOFF(%ecx) + andl $32767, %eax + fld %st(0) + cmpl $16380, %eax + fadd %st(2), %st + jg ..B3.28 +..B3.24: + jne ..B3.29 +..B3.25: + movl 16(%esp), %eax + cmpl 88+_CONSTANTS@GOTOFF(%ecx), %eax + ja ..B3.28 +..B3.26: + jne ..B3.29 +..B3.27: + movl 12(%esp), %eax + cmpl 84+_CONSTANTS@GOTOFF(%ecx), %eax + jbe ..B3.29 +..B3.28: + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 300+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + jmp ..B3.30 +..B3.29: + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt 300+_CONSTANTS@GOTOFF(%ecx) + faddp %st, %st(2) +..B3.30: + fldt 72(%esp) + fld %st(2) + movzwl 8(%esp), %edx + fadd %st(2), %st + fmul %st, %st(1) + fld %st(0) + andl $32767, %edx + fsub %st(2), %st + faddp %st, %st(2) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(2) + fsub %st(1), %st + fldt 136(%esp) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(2), %st + fldt 152(%esp) + fmul %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(1) + fldt 120(%esp) + fmulp %st, %st(5) + fldt 88(%esp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(2) + fldt 72(%esp) + fmul %st(4), %st + fsubr %st, %st(1) + faddp %st, %st(1) + fsubr %st, %st(1) + fldt 24(%esp) + fld %st(0) + fmul %st(2), %st + fxch %st(1) + fmul %st(3), %st + fldt 56(%esp) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(0) + fldt 40(%esp) + fmulp %st, %st(5) + fldt 104(%esp) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fadd %st(3), %st + fstpt 12(%esp) + fldt 12(%esp) + fsubr %st, %st(1) + movzwl 20(%esp), %eax + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fadd %st(2), %st + andl $32767, %eax + cmpl %edx, %eax + jg ..B3.35 +..B3.31: + jne ..B3.36 +..B3.32: + movl 16(%esp), %eax + movl 4(%esp), %edx + cmpl %edx, %eax + ja ..B3.35 +..B3.33: + jne ..B3.36 +..B3.34: + movl 12(%esp), %eax + cmpl (%esp), %eax + jbe ..B3.36 +..B3.35: + fldt 104(%esp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 40(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + jmp ..B3.37 +..B3.36: + fldt 104(%esp) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 40(%esp) + faddp %st, %st(2) +..B3.37: + fld %st(1) + movl $0, 24(%ebx) + fadd %st(1), %st + fstpt (%ebx) + fldt (%ebx) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 12(%ebx) + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B3.38: + movl (%esi), %eax + movl 4(%esi), %edx + movl %eax, (%ebx) + movl %edx, 4(%ebx) + movl 8(%esi), %ecx + movl 12(%esi), %edi + movl 16(%esi), %eax + movl 20(%esi), %edx + movl 24(%esi), %esi + movl %ecx, 8(%ebx) + movl %edi, 12(%ebx) + movl %eax, 16(%ebx) + movl %edx, 20(%ebx) + movl %esi, 24(%ebx) +..B3.39: + addl $164, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type asinpoly,@function + .size asinpoly,.-asinpoly + .data +# -- End asinpoly + .text +# -- Begin __libm_recasinl_k80 + .text + .align 16,0x90 + .hidden __libm_recasinl_k80 + .globl __libm_recasinl_k80 +__libm_recasinl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +# parameter 4: 20 + %ebp +# parameter 5: 24 + %ebp +# parameter 6: 28 + %ebp +# parameter 7: 32 + %ebp +# parameter 8: 36 + %ebp +# parameter 9: 40 + %ebp +# parameter 10: 44 + %ebp +..B4.1: +..L7: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $436, %esp + movl 16(%ebp), %esi + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 432(%esp) + movzwl 8(%esi), %eax + andl $32767, %eax + movl 44(%ebp), %edi + cmpl $8383, %eax + jl ..B4.5 +..B4.2: + cmpl $24383, %eax + jg ..B4.5 +..B4.3: + movzwl 8(%edi), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.5 +..B4.4: + cmpl $24383, %eax + jle ..B4.7 +..B4.5: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B4.6: + addl $4, %esp + pushl %edi + call __libm_normalizel_k80 +..B4.7: + fldt (%esi) + fld %st(0) + fldt (%edi) + fdivr %st, %st(1) + fld %st(0) + call ..L8 +..L8: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L8](%eax), %eax + fld %st(1) + movl 24(%esi), %ebx + subl 24(%edi), %ebx + fldt 36+_CONSTANTS@GOTOFF(%eax) + fld %st(0) + fmul %st(5), %st + lea 1(%ebx), %edx + fld %st(0) + movl %eax, 92(%esp) + fsubr %st(6), %st + movl %edx, 428(%esp) + faddp %st, %st(1) + fld %st(0) + fsubr %st(6), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(4) + fld %st(4) + fsub %st(4), %st + fxch %st(3) + fstpt 80(%esp) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fsubrp %st, %st(3) + fldt 12(%esi) + faddp %st, %st(3) + fldt 12(%edi) + fmul %st(2), %st + fsubrp %st, %st(3) + fdivrp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 404(%esp) + fldt 404(%esp) + fsubrp %st, %st(1) + movzwl 412(%esp), %ecx + fadd %st(1), %st + andl $32767, %ecx + fstpt 416(%esp) + fstpt 48(%esp) + lea 1(%ecx,%ebx), %eax + cmpl $16382, %eax + jl ..B4.191 +..B4.8: + movl 8(%ebp), %eax + movl 40(%ebp), %ebx + movzwl 8(%eax), %edx + andl $32767, %edx + cmpl $16383, %edx + jl ..B4.39 +..B4.9: + movl 32(%ebp), %eax + movl (%eax), %edx + movl %edx, 96(%esp) + movl 8(%eax), %edx + movl 4(%eax), %ecx + movl %edx, 104(%esp) + movl 16(%eax), %edx + movl %ecx, 100(%esp) + movl 12(%eax), %ecx + movl %edx, 112(%esp) + movzwl 8(%ebx), %edx + movl %ecx, 108(%esp) + movl 20(%eax), %ecx + movl %edx, 68(%esp) + andl $32767, %edx + movl 24(%eax), %eax + cmpl $8383, %edx + movl %ecx, 116(%esp) + movl %eax, 120(%esp) + jl ..B4.13 +..B4.10: + cmpl $24383, %edx + jg ..B4.13 +..B4.11: + movl 24(%ebp), %eax + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) + cmpl $8383, %ecx + jl ..B4.13 +..B4.12: + cmpl $24383, 40(%esp) + jle ..B4.16 +..B4.13: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B4.14: + addl $4, %esp + pushl 24(%ebp) + call __libm_normalizel_k80 +..B4.15: + movl 24(%ebp), %eax + movzwl 8(%ebx), %edx + movl %edx, 68(%esp) + andl $32767, %edx + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) +..B4.16: + movl 24(%ebp), %ecx + movl 24(%ecx), %eax + movl 40(%esp), %ecx + movl %eax, 64(%esp) + lea -134(%eax,%ecx), %eax + movl 24(%ebx), %ecx + movl %ecx, 60(%esp) + addl %edx, %ecx + movl %ecx, 36(%esp) + cmpl %ecx, %eax + jge ..B4.33 +..B4.17: + movl 4(%ebx), %eax + movl %eax, 32(%esp) + movl 64(%esp), %ecx + movl 40(%esp), %eax + lea 134(%ecx,%eax), %ecx + cmpl 36(%esp), %ecx + jle ..B4.34 +..B4.18: + cmpl $0, 32(%esp) + jne ..B4.20 +..B4.19: + cmpl $0, (%ebx) + je ..B4.35 +..B4.20: + movl 24(%ebp), %eax + cmpl $0, 4(%eax) + jne ..B4.22 +..B4.21: + movl 24(%ebp), %eax + cmpl $0, (%eax) + je ..B4.34 +..B4.22: + movl 64(%esp), %eax + cmpl 60(%esp), %eax + je ..B4.24 +..B4.23: + fldt 48(%esp) + movl 60(%esp), %eax + movl 64(%esp), %ecx + subl %ecx, %eax + fstpt 32(%esp) + addl $16383, %eax + fldt (%ebx) + andl $32767, %eax + fldt 12(%ebx) + andb $127, 41(%esp) + movzwl 40(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %ecx, 24(%ebx) + movl 24(%ebp), %ecx + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fstpt 48(%esp) + fmulp %st, %st(1) + movl 24(%ecx), %eax + fstpt 12(%ebx) + fldt 12(%ebx) + movl %eax, 64(%esp) + movzwl 8(%ebx), %edx + movzwl 8(%ecx), %eax + movl %edx, 68(%esp) + movl %eax, 44(%esp) + jmp ..B4.25 +..B4.24: + fldt (%ebx) + fstpt 48(%esp) + fldt 12(%ebx) +..B4.25: + fldt 48(%esp) + movl 24(%ebp), %edx + movl 64(%esp), %eax + movl %eax, 148(%esp) + fldt (%edx) + movl 68(%esp), %ecx + fadd %st, %st(1) + movl 44(%esp), %eax + andl $32767, %ecx + andl $32767, %eax + cmpl %eax, %ecx + jg ..B4.30 +..B4.26: + jne ..B4.31 +..B4.27: + movl 24(%ebp), %edx + movl 4(%ebx), %eax + cmpl 4(%edx), %eax + ja ..B4.30 +..B4.28: + jne ..B4.31 +..B4.29: + movl 24(%ebp), %edx + movl (%ebx), %eax + cmpl (%edx), %eax + jbe ..B4.31 +..B4.30: + fldt 48(%esp) + movl 24(%ebp), %eax + fsub %st(2), %st + faddp %st, %st(1) + fldt 12(%eax) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + jmp ..B4.32 +..B4.31: + fldt 48(%esp) + fxch %st(1) + fsub %st(2), %st + movl 24(%ebp), %eax + faddp %st, %st(1) + faddp %st, %st(2) + fldt 12(%eax) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) +..B4.32: + fldt 48(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 124(%esp) + fldt 124(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 136(%esp) + jmp ..B4.69 +..B4.33: + movl 4(%ebx), %eax + movl %eax, 32(%esp) +..B4.34: + cmpl $0, 32(%esp) + jne ..B4.36 +..B4.202: + cmpl $0, (%ebx) +..B4.35: + je ..B4.37 +..B4.36: + movl 64(%esp), %ecx + movl 40(%esp), %eax + lea -16517(%ecx,%eax), %eax + movl 60(%esp), %ecx + lea -16383(%ecx,%edx), %edx + cmpl %edx, %eax + jl ..B4.38 +..B4.37: + movl 24(%ebp), %eax + movl (%eax), %edx + movl 4(%eax), %ecx + movl 8(%eax), %ebx + movl %edx, 124(%esp) + movl %ecx, 128(%esp) + movl %ebx, 132(%esp) + movl 12(%eax), %edx + movl 16(%eax), %ecx + movl 20(%eax), %ebx + movl 24(%eax), %eax + movl %edx, 136(%esp) + movl %ecx, 140(%esp) + movl %ebx, 144(%esp) + movl %eax, 148(%esp) + jmp ..B4.69 +..B4.38: + movl (%ebx), %eax + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl %eax, 124(%esp) + movl %edx, 128(%esp) + movl %ecx, 132(%esp) + movl 12(%ebx), %eax + movl 16(%ebx), %edx + movl 20(%ebx), %ecx + movl 24(%ebx), %ebx + movl %eax, 136(%esp) + movl %edx, 140(%esp) + movl %ecx, 144(%esp) + movl %ebx, 148(%esp) + jmp ..B4.69 +..B4.39: + movl 92(%esp), %eax + movzwl 8(%ebx), %edx + movl %edx, 68(%esp) + andl $32767, %edx + fldt _CONSTANTS@GOTOFF(%eax) + cmpl $8383, %edx + movl $0, 148(%esp) + fstpt 124(%esp) + fldt 24+_CONSTANTS@GOTOFF(%eax) + fstpt 136(%esp) + jl ..B4.43 +..B4.40: + cmpl $24383, %edx + jg ..B4.43 +..B4.41: + movl 24(%ebp), %eax + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) + cmpl $8383, %ecx + jl ..B4.43 +..B4.42: + cmpl $24383, 40(%esp) + jle ..B4.46 +..B4.43: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B4.44: + addl $4, %esp + pushl 24(%ebp) + call __libm_normalizel_k80 +..B4.45: + movl 24(%ebp), %eax + movzwl 8(%ebx), %edx + movl %edx, 68(%esp) + andl $32767, %edx + movzwl 8(%eax), %ecx + movl %ecx, 44(%esp) + andl $32767, %ecx + movl %ecx, 40(%esp) +..B4.46: + movl 24(%ebp), %ecx + movl 24(%ecx), %eax + movl 40(%esp), %ecx + movl %eax, 64(%esp) + lea -134(%eax,%ecx), %eax + movl 24(%ebx), %ecx + movl %ecx, 60(%esp) + addl %edx, %ecx + movl %ecx, 36(%esp) + cmpl %ecx, %eax + jge ..B4.63 +..B4.47: + movl 4(%ebx), %eax + movl %eax, 32(%esp) + movl 64(%esp), %ecx + movl 40(%esp), %eax + lea 134(%ecx,%eax), %ecx + cmpl 36(%esp), %ecx + jle ..B4.64 +..B4.48: + cmpl $0, 32(%esp) + jne ..B4.50 +..B4.49: + cmpl $0, (%ebx) + je ..B4.65 +..B4.50: + movl 24(%ebp), %eax + cmpl $0, 4(%eax) + jne ..B4.52 +..B4.51: + movl 24(%ebp), %eax + cmpl $0, (%eax) + je ..B4.64 +..B4.52: + movl 64(%esp), %eax + cmpl 60(%esp), %eax + je ..B4.54 +..B4.53: + fldt 48(%esp) + movl 60(%esp), %eax + movl 64(%esp), %ecx + subl %ecx, %eax + fstpt 32(%esp) + addl $16383, %eax + fldt (%ebx) + andl $32767, %eax + fldt 12(%ebx) + andb $127, 41(%esp) + movzwl 40(%esp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %ecx, 24(%ebx) + movl 24(%ebp), %ecx + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + movl 24(%ecx), %eax + fstpt 12(%ebx) + fldt 12(%ebx) + movl %eax, 64(%esp) + movzwl 8(%ebx), %edx + movzwl 8(%ecx), %eax + fstpt 48(%esp) + movl %edx, 68(%esp) + movl %eax, 44(%esp) + jmp ..B4.55 +..B4.54: + fldt (%ebx) + fldt 12(%ebx) + fstpt 48(%esp) +..B4.55: + movl 24(%ebp), %edx + fld %st(0) + movl 64(%esp), %eax + movl %eax, 120(%esp) + fldt (%edx) + movl 68(%esp), %ecx + fsubr %st, %st(1) + movl 44(%esp), %eax + andl $32767, %ecx + andl $32767, %eax + cmpl %eax, %ecx + jg ..B4.60 +..B4.56: + jne ..B4.61 +..B4.57: + movl 24(%ebp), %edx + movl 4(%ebx), %eax + cmpl 4(%edx), %eax + ja ..B4.60 +..B4.58: + jne ..B4.61 +..B4.59: + movl 24(%ebp), %edx + movl (%ebx), %eax + cmpl (%edx), %eax + jbe ..B4.61 +..B4.60: + fldt 48(%esp) + fxch %st(2) + fsubr %st, %st(3) + movl 24(%ebp), %eax + fxch %st(1) + fsubrp %st, %st(3) + fldt 12(%eax) + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 48(%esp) + jmp ..B4.62 +..B4.61: + movl 24(%ebp), %eax + fadd %st(1), %st + fsubrp %st, %st(2) + fldt 48(%esp) + faddp %st, %st(2) + fldt 12(%eax) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) +..B4.62: + fldt 48(%esp) + fld %st(0) + fadd %st(2), %st + fstpt 96(%esp) + fldt 96(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 108(%esp) + jmp ..B4.69 +..B4.63: + movl 4(%ebx), %eax + movl %eax, 32(%esp) +..B4.64: + cmpl $0, 32(%esp) + jne ..B4.66 +..B4.201: + cmpl $0, (%ebx) +..B4.65: + je ..B4.67 +..B4.66: + movl 64(%esp), %eax + movl 40(%esp), %ecx + movl 60(%esp), %ebx + lea -16517(%eax,%ecx), %eax + lea -16383(%ebx,%edx), %edx + movl 40(%ebp), %ebx + cmpl %edx, %eax + jl ..B4.68 +..B4.67: + movl 24(%ebp), %edx + movl 64(%esp), %eax + movl %eax, 120(%esp) + fldt (%edx) + fchs + fstpt 96(%esp) + fldt 12(%edx) + fchs + fstpt 108(%esp) + jmp ..B4.69 +..B4.68: + movl (%ebx), %eax + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl %eax, 96(%esp) + movl %edx, 100(%esp) + movl %ecx, 104(%esp) + movl 12(%ebx), %eax + movl 16(%ebx), %edx + movl 20(%ebx), %ecx + movl 24(%ebx), %ebx + movl %eax, 108(%esp) + movl %edx, 112(%esp) + movl %ecx, 116(%esp) + movl %ebx, 120(%esp) +..B4.69: + movzwl 8(%esi), %eax + movl %eax, 68(%esp) + andl $32767, %eax + movl 24(%esi), %ecx + incl %ecx + movl %ecx, 24(%esi) + cmpl $8383, %eax + movl %eax, 76(%esp) + jl ..B4.73 +..B4.70: + cmpl $24383, 76(%esp) + jg ..B4.73 +..B4.71: + movzwl 8(%edi), %edx + movl %edx, %eax + andl $32767, %eax + movl %eax, 72(%esp) + cmpl $8383, %eax + jl ..B4.73 +..B4.72: + cmpl $24383, 72(%esp) + jle ..B4.76 +..B4.73: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B4.74: + addl $4, %esp + pushl %edi + call __libm_normalizel_k80 +..B4.75: + movzwl 8(%esi), %edx + movl %edx, 68(%esp) + andl $32767, %edx + movl %edx, 76(%esp) + movzwl 8(%edi), %edx + movl %edx, %eax + andl $32767, %eax + movl %eax, 72(%esp) + movl 24(%esi), %ecx +..B4.76: + movl 76(%esp), %ebx + movl 24(%edi), %edi + movl %edi, 64(%esp) + lea (%ecx,%ebx), %eax + movl 72(%esp), %ebx + movl %eax, 60(%esp) + lea -134(%edi,%ebx), %edi + cmpl %edi, %eax + movl 44(%ebp), %edi + jle ..B4.93 +..B4.77: + movl 4(%esi), %eax + movl %eax, 44(%esp) + movl 64(%esp), %ebx + movl 72(%esp), %eax + lea 134(%ebx,%eax), %ebx + cmpl 60(%esp), %ebx + jle ..B4.94 +..B4.78: + cmpl $0, 44(%esp) + jne ..B4.80 +..B4.79: + cmpl $0, (%esi) + je ..B4.95 +..B4.80: + cmpl $0, 4(%edi) + jne ..B4.82 +..B4.81: + cmpl $0, (%edi) + je ..B4.94 +..B4.82: + cmpl 64(%esp), %ecx + je ..B4.84 +..B4.83: + fldt 48(%esp) + movl 64(%esp), %edx + subl %edx, %ecx + fstpt 32(%esp) + addl $16383, %ecx + fldt (%esi) + andl $32767, %ecx + fldt 12(%esi) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %ecx, %eax + movl %edx, %ecx + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 24(%esi) + fxch %st(2) + fstpt (%esi) + fldt (%esi) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%esi) + fldt 12(%esi) + movl 24(%edi), %ebx + movzwl 8(%esi), %eax + movl %ebx, 64(%esp) + movl %eax, 68(%esp) + movzwl 8(%edi), %edx + jmp ..B4.85 +..B4.84: + fldt (%esi) + fldt 12(%esi) +..B4.85: + fldt (%edi) + fld %st(2) + movl 64(%esp), %eax + fadd %st(1), %st + movl %eax, 176(%esp) + movl %edx, %eax + movl 68(%esp), %ebx + andl $32767, %eax + andl $32767, %ebx + cmpl %eax, %ebx + jg ..B4.90 +..B4.86: + jne ..B4.91 +..B4.87: + movl 4(%esi), %eax + cmpl 4(%edi), %eax + ja ..B4.90 +..B4.88: + jne ..B4.91 +..B4.89: + movl (%esi), %eax + cmpl (%edi), %eax + jbe ..B4.91 +..B4.90: + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 12(%edi) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + jmp ..B4.92 +..B4.91: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 12(%edi) + faddp %st, %st(2) +..B4.92: + fld %st(1) + fadd %st(1), %st + fstpt 152(%esp) + fldt 152(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 164(%esp) + jmp ..B4.99 +..B4.93: + movl 4(%esi), %eax + movl %eax, 44(%esp) +..B4.94: + cmpl $0, 44(%esp) + jne ..B4.96 +..B4.203: + cmpl $0, (%esi) +..B4.95: + je ..B4.97 +..B4.96: + movl 64(%esp), %ebx + movl 72(%esp), %eax + lea -16517(%ebx,%eax), %eax + movl 76(%esp), %ebx + lea -16383(%ecx,%ebx), %ebx + cmpl %ebx, %eax + jl ..B4.98 +..B4.97: + movl (%edi), %eax + movl %eax, 152(%esp) + movl 4(%edi), %ebx + movl 8(%edi), %eax + movl %ebx, 156(%esp) + movl %eax, 160(%esp) + movl 12(%edi), %ebx + movl 16(%edi), %eax + movl %ebx, 164(%esp) + movl %eax, 168(%esp) + movl 20(%edi), %ebx + movl 24(%edi), %eax + movl %ebx, 172(%esp) + movl %eax, 176(%esp) + jmp ..B4.99 +..B4.98: + movl (%esi), %eax + movl %eax, 152(%esp) + movl 4(%esi), %ebx + movl 8(%esi), %eax + movl %ebx, 156(%esp) + movl %eax, 160(%esp) + movl 12(%esi), %ebx + movl 16(%esi), %eax + movl %ebx, 164(%esp) + movl %eax, 168(%esp) + movl 20(%esi), %ebx + movl 24(%esi), %eax + movl %ebx, 172(%esp) + movl %eax, 176(%esp) +..B4.99: + movzwl 160(%esp), %eax + decl %ecx + andl $32767, %eax + movl %ecx, 24(%esi) + cmpl $8383, %eax + jl ..B4.103 +..B4.100: + cmpl $24383, %eax + jg ..B4.103 +..B4.101: + movzwl 104(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.103 +..B4.102: + cmpl $24383, %eax + jle ..B4.105 +..B4.103: + addl $4, %esp + lea 148(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.104: + addl $4, %esp + lea 92(%esp), %eax + pushl %eax + call __libm_normalizel_k80 + movzwl 8(%edi), %edx +..B4.105: + fldt 152(%esp) + andl $32767, %edx + fld %st(0) + fld %st(1) + fldt 80(%esp) + fld %st(0) + fmul %st(4), %st + movl 176(%esp), %eax + fsubr %st, %st(3) + addl 120(%esp), %eax + faddp %st, %st(3) + fld %st(2) + cmpl $8383, %edx + movl %eax, 204(%esp) + fxch %st(2) + fsub %st(3), %st + fldt 96(%esp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 108(%esp) + fmulp %st, %st(4) + fldt 164(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 180(%esp) + fldt 180(%esp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 192(%esp) + jl ..B4.109 +..B4.106: + cmpl $24383, %edx + jg ..B4.109 +..B4.107: + movzwl 132(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.109 +..B4.108: + cmpl $24383, %eax + jle ..B4.111 +..B4.109: + addl $4, %esp + pushl %edi + call __libm_normalizel_k80 +..B4.110: + addl $4, %esp + lea 120(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.111: + fldt (%edi) + fld %st(0) + fld %st(1) + fldt 80(%esp) + fld %st(0) + fmul %st(4), %st + movl 36(%ebp), %ebx + fsubr %st, %st(3) + movl 148(%esp), %eax + faddp %st, %st(3) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fldt 124(%esp) + fmul %st, %st(2) + fld %st(0) + addl 24(%edi), %eax + fsub %st(3), %st + movl 28(%ebp), %esi + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + movl %eax, 232(%esp) + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 136(%esp) + fmulp %st, %st(4) + fldt 12(%edi) + fmulp %st, %st(1) + movzwl 8(%ebx), %edi + movl %edi, %ecx + andl $32767, %ecx + faddp %st, %st(3) + cmpl $8383, %ecx + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 208(%esp) + fldt 208(%esp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 220(%esp) + fstpt 48(%esp) + jl ..B4.115 +..B4.112: + cmpl $24383, %ecx + jg ..B4.115 +..B4.113: + movzwl 8(%esi), %edx + movl %edx, 60(%esp) + andl $32767, %edx + cmpl $8383, %edx + jl ..B4.115 +..B4.114: + cmpl $24383, %edx + jle ..B4.118 +..B4.115: + addl $4, %esp + pushl %ebx + call __libm_normalizel_k80 +..B4.116: + addl $4, %esp + pushl %esi + call __libm_normalizel_k80 +..B4.117: + movzwl 8(%ebx), %edi + movl %edi, %ecx + movzwl 8(%esi), %edx + andl $32767, %ecx + movl %edx, 60(%esp) + andl $32767, %edx +..B4.118: + movl 24(%esi), %eax + movl 24(%ebx), %ebx + movl %eax, 72(%esp) + movl %ebx, 68(%esp) + lea -134(%eax,%edx), %eax + addl %ecx, %ebx + movl %ebx, 64(%esp) + cmpl %eax, %ebx + movl 36(%ebp), %ebx + jle ..B4.135 +..B4.119: + movl 4(%ebx), %eax + movl %eax, 44(%esp) + movl 72(%esp), %eax + lea 134(%eax,%edx), %eax + cmpl 64(%esp), %eax + jle ..B4.136 +..B4.120: + cmpl $0, 44(%esp) + jne ..B4.122 +..B4.121: + cmpl $0, (%ebx) + je ..B4.137 +..B4.122: + cmpl $0, 4(%esi) + jne ..B4.124 +..B4.123: + cmpl $0, (%esi) + je ..B4.136 +..B4.124: + movl 72(%esp), %eax + cmpl 68(%esp), %eax + je ..B4.126 +..B4.125: + fldt 48(%esp) + movl 68(%esp), %edi + movl %eax, %edx + subl %edx, %edi + fstpt 32(%esp) + addl $16383, %edi + fldt (%ebx) + andl $32767, %edi + fldt 12(%ebx) + andb $127, 41(%esp) + movzwl 40(%esp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + movl %edx, 24(%ebx) + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt 12(%ebx) + movl 24(%esi), %ecx + movzwl 8(%esi), %eax + movl %ecx, 72(%esp) + movzwl 8(%ebx), %edi + movl %eax, 60(%esp) + jmp ..B4.127 +..B4.126: + fldt (%ebx) + fldt 12(%ebx) +..B4.127: + fldt (%esi) + andl $32767, %edi + movl 60(%esp), %edx + fld %st(2) + andl $32767, %edx + fadd %st(1), %st + movl 72(%esp), %eax + cmpl %edx, %edi + movl %eax, 260(%esp) + jg ..B4.132 +..B4.128: + jne ..B4.133 +..B4.129: + movl 4(%ebx), %eax + cmpl 4(%esi), %eax + ja ..B4.132 +..B4.130: + jne ..B4.133 +..B4.131: + movl (%ebx), %eax + cmpl (%esi), %eax + jbe ..B4.133 +..B4.132: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 12(%esi) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B4.134 +..B4.133: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 12(%esi) + faddp %st, %st(1) +..B4.134: + fld %st(0) + fadd %st(2), %st + fstpt 236(%esp) + fldt 236(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 248(%esp) + jmp ..B4.141 +..B4.135: + movl 4(%ebx), %eax + movl %eax, 44(%esp) +..B4.136: + cmpl $0, 44(%esp) + jne ..B4.138 +..B4.204: + cmpl $0, (%ebx) +..B4.137: + je ..B4.139 +..B4.138: + movl 72(%esp), %eax + lea -16517(%eax,%edx), %edi + movl 68(%esp), %edx + lea -16383(%edx,%ecx), %ecx + cmpl %ecx, %edi + jl ..B4.140 +..B4.139: + movl (%esi), %eax + movl %eax, 236(%esp) + movl 4(%esi), %edx + movl 8(%esi), %ecx + movl 12(%esi), %ebx + movl 16(%esi), %edi + movl 20(%esi), %eax + movl 24(%esi), %esi + movl %edx, 240(%esp) + movl %ecx, 244(%esp) + movl %ebx, 248(%esp) + movl %edi, 252(%esp) + movl %eax, 256(%esp) + movl %esi, 260(%esp) + jmp ..B4.141 +..B4.140: + movl (%ebx), %eax + movl %eax, 236(%esp) + movl 4(%ebx), %edx + movl 8(%ebx), %ecx + movl 12(%ebx), %esi + movl 16(%ebx), %edi + movl 20(%ebx), %eax + movl 24(%ebx), %ebx + movl %edx, 240(%esp) + movl %ecx, 244(%esp) + movl %esi, 248(%esp) + movl %edi, 252(%esp) + movl %eax, 256(%esp) + movl %ebx, 260(%esp) +..B4.141: + movzwl 216(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.145 +..B4.142: + cmpl $24383, %eax + jg ..B4.145 +..B4.143: + movzwl 244(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.145 +..B4.144: + cmpl $24383, %eax + jle ..B4.147 +..B4.145: + addl $4, %esp + lea 204(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.146: + addl $4, %esp + lea 232(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.147: + fldt 208(%esp) + fld %st(0) + fld %st(1) + fldt 80(%esp) + fld %st(0) + fmul %st(4), %st + movl 232(%esp), %edx + fsubr %st, %st(3) + movzwl 188(%esp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + addl 260(%esp), %edx + fxch %st(2) + fsub %st(3), %st + fldt 236(%esp) + cmpl $8383, %eax + fmul %st, %st(2) + fld %st(0) + movl %edx, 288(%esp) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 248(%esp) + fmulp %st, %st(4) + fldt 220(%esp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 264(%esp) + fldt 264(%esp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 276(%esp) + fldt 276(%esp) + jl ..B4.151 +..B4.148: + cmpl $24383, %eax + jg ..B4.151 +..B4.149: + movzwl 272(%esp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.151 +..B4.150: + cmpl $24383, %eax + jle ..B4.154 +..B4.151: + fstp %st(1) + fstp %st(0) + addl $4, %esp + lea 176(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.152: + addl $4, %esp + lea 260(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.153: + fldt 264(%esp) + fldt 276(%esp) + movl 288(%esp), %edx +..B4.154: + fldt 180(%esp) + fld %st(2) + fdivr %st(1), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(4) + fstpt 64(%esp) + fldt 64(%esp) + fldt 80(%esp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + movl 204(%esp), %ecx + fsubr %st(4), %st + subl %edx, %ecx + faddp %st, %st(1) + fld %st(0) + decl %ecx + movl %ecx, 316(%esp) + fsubr %st(4), %st + fxch %st(2) + fmul %st(3), %st + fsubr %st, %st(7) + faddp %st, %st(7) + fxch %st(2) + fsub %st(6), %st + fld %st(2) + fmul %st(7), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(3) + fxch %st(7) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fxch %st(4) + fsubrp %st, %st(2) + fxch %st(3) + fsubrp %st, %st(1) + fldt 192(%esp) + faddp %st, %st(1) + fsubp %st, %st(1) + fldt 64(%esp) + fdivrp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 292(%esp) + fldt 292(%esp) + fsubr %st, %st(2) + movzwl 300(%esp), %eax + fxch %st(1) + fadd %st, %st(2) + andl $32767, %eax + fxch %st(2) + fstpt 304(%esp) + fldt 304(%esp) + cmpl $383, %eax + fxch %st(2) + fstpt 48(%esp) + fxch %st(1) + jl ..B4.156 +..B4.155: + cmpl $32383, %eax + jle ..B4.158 +..B4.156: + fstp %st(0) + fstp %st(0) + addl $4, %esp + lea 288(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.157: + fldt 292(%esp) + fldt 304(%esp) + movl 316(%esp), %ecx +..B4.158: + testb $1, %cl + jne ..B4.196 +..B4.159: + movl 92(%esp), %eax + fldt 48+_CONSTANTS@GOTOFF(%eax) +..B4.160: + fldt 80(%esp) + fld %st(3) + fsqrt + lea 320(%esp), %eax + fmul %st, %st(1) + lea 348(%esp), %edx + fld %st(1) + sarl $1, %ecx + fsubr %st(1), %st + movl %ecx, 52(%eax) + faddp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + fdivr %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 28(%eax) + fldt 28(%eax) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 40(%eax) + call asinpoly +..B4.161: + movl 92(%esp), %eax + xorl %ebx, %ebx + movl 344(%esp), %esi + incl %esi + fldt 60+_CONSTANTS@GOTOFF(%eax) + movzwl 68+_CONSTANTS@GOTOFF(%eax), %edi + andl $32767, %edi + movl %esi, 344(%esp) + cmpl $8383, %edi + movl %ebx, 400(%esp) + fstpt 376(%esp) + fldt 72+_CONSTANTS@GOTOFF(%eax) + fstpt 388(%esp) + jl ..B4.165 +..B4.162: + cmpl $24383, %edi + jg ..B4.165 +..B4.163: + movzwl 328(%esp), %ecx + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B4.165 +..B4.164: + cmpl $24383, %ecx + jle ..B4.168 +..B4.165: + addl $4, %esp + lea 372(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.166: + addl $4, %esp + lea 316(%esp), %eax + pushl %eax + call __libm_normalizel_k80 +..B4.167: + movzwl 384(%esp), %edi + movzwl 328(%esp), %ecx + andl $32767, %edi + movl 344(%esp), %esi + andl $32767, %ecx + movl 400(%esp), %ebx +..B4.168: + lea (%ebx,%edi), %eax + movl %eax, 44(%esp) + lea -134(%esi,%ecx), %edx + cmpl %edx, %eax + jle ..B4.185 +..B4.169: + movl 380(%esp), %edx + lea 134(%esi,%ecx), %eax + cmpl 44(%esp), %eax + jle ..B4.186 +..B4.170: + testl %edx, %edx + jne ..B4.172 +..B4.171: + cmpl $0, 376(%esp) + je ..B4.187 +..B4.172: + movl 324(%esp), %eax + testl %eax, %eax + jne ..B4.174 +..B4.173: + cmpl $0, 320(%esp) + je ..B4.186 +..B4.174: + cmpl %esi, %ebx + je ..B4.176 +..B4.175: + fldt 48(%esp) + subl %esi, %ebx + fstpt 32(%esp) + addl $16383, %ebx + fldt 376(%esp) + andl $32767, %ebx + fldt 388(%esp) + andb $127, 41(%esp) + movzwl 40(%esp), %edx + andl $-32768, %edx + orl %ebx, %edx + movw %dx, 40(%esp) + movl $-2147483648, 36(%esp) + movl $0, 32(%esp) + fldt 32(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 376(%esp) + fldt 376(%esp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 384(%esp), %edi + movl %esi, 400(%esp) + andl $32767, %edi + fstpt 388(%esp) + fldt 388(%esp) + jmp ..B4.177 +..B4.176: + fldt 376(%esp) + fldt 388(%esp) +..B4.177: + fldt 320(%esp) + fld %st(2) + movl %esi, 68(%esp) + cmpl %ecx, %edi + fsub %st(1), %st + jg ..B4.182 +..B4.178: + jne ..B4.183 +..B4.179: + movl 380(%esp), %edx + cmpl %eax, %edx + ja ..B4.182 +..B4.180: + jne ..B4.183 +..B4.181: + movl 376(%esp), %eax + cmpl 320(%esp), %eax + jbe ..B4.183 +..B4.182: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 332(%esp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + jmp ..B4.184 +..B4.183: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 332(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) +..B4.184: + fld %st(0) + fadd %st(2), %st + fstpt 44(%esp) + fldt 44(%esp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 56(%esp) + fldt 56(%esp) + jmp ..B4.193 +..B4.185: + movl 380(%esp), %edx +..B4.186: + testl %edx, %edx + jne ..B4.188 +..B4.205: + cmpl $0, 376(%esp) +..B4.187: + je ..B4.189 +..B4.188: + lea -16517(%esi,%ecx), %eax + lea -16383(%ebx,%edi), %ecx + cmpl %ecx, %eax + jl ..B4.190 +..B4.189: + fldt 320(%esp) + fchs + movl %esi, 68(%esp) + fstpt 44(%esp) + fldt 44(%esp) + fldt 332(%esp) + fchs + fstpt 56(%esp) + fldt 56(%esp) + jmp ..B4.193 +..B4.190: + movl %edx, 48(%esp) + movl 396(%esp), %esi + movl 376(%esp), %eax + movl 384(%esp), %edx + movl 388(%esp), %ecx + movl 392(%esp), %ebx + movl %esi, 64(%esp) + movl %eax, 44(%esp) + movl %edx, 52(%esp) + fldt 44(%esp) + movl 400(%esp), %esi + movl %ecx, 56(%esp) + movl %ebx, 60(%esp) + fldt 56(%esp) + movl %esi, 68(%esp) + jmp ..B4.193 +..B4.191: + lea 44(%esp), %eax + lea 404(%esp), %edx + call asinpoly +..B4.192: + fldt 44(%esp) + fldt 56(%esp) + movl 68(%esp), %esi +..B4.193: + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl %esi, 24(%esp) + call __libm_scalbl_k80 +..B4.194: + movl 8(%ebp), %eax + movl 92(%esp), %ebx + movl 432(%esp), %edi + movzbl 9(%eax), %ecx + xorl %esp, %edi + andl $128, %ecx + shrl $7, %ecx + cmpl %gs:20, %edi + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %esi + fldt _CONSTANTS@GOTOFF(%ebx,%esi) + fmulp %st, %st(1) + jne ..B4.197 +..B4.195: + addl $436, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B4.196: + movl 92(%esp), %eax + incl %ecx + movl %ecx, 316(%esp) + fldt 48+_CONSTANTS@GOTOFF(%eax) + fmul %st, %st(2) + fxch %st(2) + fstpt 292(%esp) + fldt 292(%esp) + fxch %st(1) + fmul %st(2), %st + fstpt 304(%esp) + fldt 304(%esp) + fxch %st(1) + fxch %st(2) + jmp ..B4.160 +..B4.197: + fstp %st(0) + call __stack_chk_fail@PLT + .align 16,0x90 + .type __libm_recasinl_k80,@function + .size __libm_recasinl_k80,.-__libm_recasinl_k80 + .data +# -- End __libm_recasinl_k80 + .section .rodata, "a" + .align 16 + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 32768 + .word 16415 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 39322 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 28087 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 36409 + .word 63715 + .word 16377 + .word 0 + .word 62186 + .word 9163 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 11943 + .word 18321 + .word 25215 + .word 36391 + .word 16377 + .word 0 + .word 12527 + .word 63486 + .word 51909 + .word 58572 + .word 16376 + .word 0 + .word 16437 + .word 53165 + .word 60799 + .word 48451 + .word 16376 + .word 0 + .word 39560 + .word 816 + .word 43435 + .word 40940 + .word 16376 + .word 0 + .word 47763 + .word 38463 + .word 31161 + .word 35220 + .word 16376 + .word 0 + .word 61035 + .word 37666 + .word 58653 + .word 60832 + .word 16375 + .word 0 + .word 4110 + .word 2419 + .word 35453 + .word 57515 + .word 16375 + .word 0 + .word 3126 + .word 47859 + .word 6163 + .word 61068 + .word 16374 + .word 0 + .word 56145 + .word 58008 + .word 18829 + .word 55579 + .word 16376 + .word 0 + .word 17944 + .word 24712 + .word 25688 + .word 38195 + .word 49145 + .word 0 + .word 27414 + .word 34244 + .word 64801 + .word 51841 + .word 16378 + .word 0 + .word 63442 + .word 25896 + .word 35822 + .word 55851 + .word 49146 + .word 0 + .word 37640 + .word 1996 + .word 32075 + .word 42748 + .word 16378 + .word 0 + .word 39460 + .word 64770 + .word 43690 + .word 43690 + .word 49115 + .word 0 + .word 48327 + .word 21484 + .word 52058 + .word 52428 + .word 49114 + .word 0 + .word 52692 + .word 45548 + .word 47571 + .word 37453 + .word 49112 + .word 0 + .word 9214 + .word 45875 + .word 56244 + .word 56360 + .word 49110 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,348 + .data + .hidden __libm_normalizel_k80 + .hidden __libm_scalbl_k80 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_reduce_pi04d.S b/external/sgx_libm/ia32/libm_reduce_pi04d.S new file mode 100644 index 0000000000..c84df0c92d --- /dev/null +++ b/external/sgx_libm/ia32/libm_reduce_pi04d.S @@ -0,0 +1,365 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_reduce_pi04d.c" + .text +..TXTST0: +# -- Begin __libm_reduce_pi04d + .text + .align 16,0x90 + .hidden __libm_reduce_pi04d + .globl __libm_reduce_pi04d +__libm_reduce_pi04d: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp + movl 16(%ebp), %eax + movl 20(%ebp), %ebx + movl %eax, 8(%esp) +..B1.2: + fnstcw 26(%esp) +..B1.3: + movzwl 26(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.19 +..B1.4: + orl $-64768, %ecx + movw %cx, 24(%esp) +..B1.5: + fldcw 24(%esp) +..B1.6: + movl $1, 12(%esp) +..B1.7: + movzwl 14(%ebp), %edi + movl %edi, %ecx + andl $32752, %ecx + andl $-32753, %edi + shrl $4, %ecx + movl $1374389535, %eax + lea -200(%ecx), %esi + andl $2047, %esi + shll $4, %esi + orl %esi, %edi + lea -1052(%ecx), %esi + imull %esi + sarl $3, %edx + sarl $31, %esi + subl %esi, %edx + movw %di, 14(%ebp) + fldl 8(%ebp) + imull $-25, %edx, %edi + andl $-134217728, 8(%ebp) + lea -1052(%edi,%ecx), %ecx + fldl 8(%ebp) + cmpl $17, %ecx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + fsubr %st, %st(1) + movl %ecx, 20(%esp) + jl ..B1.9 +..B1.8: + fldl _DP@GOTOFF(%ecx,%edx,8) + fmul %st(2), %st + fldl 8+_DP@GOTOFF(%ecx,%edx,8) + incl %edx + fmul %st(2), %st + faddp %st, %st(1) + fstl (%esp) + andl $-1048576, (%esp) + fsubl (%esp) + jmp ..B1.10 +..B1.9: + fldz +..B1.10: + fld %st(1) + fld %st(2) + fldl 8+_DP@GOTOFF(%ecx,%edx,8) + fmul %st, %st(2) + fmul %st(5), %st + fldl _DP@GOTOFF(%ecx,%edx,8) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fldl 16+_DP@GOTOFF(%ecx,%edx,8) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fadd %st(2), %st + fstpl (%esp) + movzwl 6(%esp), %ecx + andl $32752, %ecx + shrl $4, %ecx + negl %ecx + addl $1075, %ecx + movl 4(%esp), %esi + cmpl $31, %ecx + movl (%esp), %edi + jbe ..B1.12 +..B1.11: + movl %esi, %edi + movl %edi, %esi + sarl $31, %esi + sarl %cl, %edi + jmp ..B1.13 +..B1.12: + shrdl %cl, %esi, %edi + sarl %cl, %esi +..B1.13: + movl %edi, (%esp) + cmpl $31, %ecx + movl %esi, 4(%esp) + jbe ..B1.15 +..B1.14: + movl %edi, %esi + movl $0, 16(%esp) + shll %cl, %esi + jmp ..B1.16 +..B1.15: + movl %edi, %eax + shll %cl, %eax + shldl %cl, %edi, %esi + movl %eax, 16(%esp) +..B1.16: + movl 16(%esp), %ecx + addl %edi, %ebx + movl %ecx, (%esp) + fld %st(3) + movl %esi, 4(%esp) + movl %ebx, %esi + andl $1, %esi + movl 20(%esp), %edi + fxch %st(1) + fmul %st(5), %st + fxch %st(3) + fsubl (%esp) + fldl 24+_DP@GOTOFF(%edi,%edx,8) + fldl 32+_DP@GOTOFF(%edi,%edx,8) + cmpl $0, 12(%esp) + fxch %st(2) + faddl zero_none@GOTOFF(%edi,%esi,8) + faddp %st, %st(4) + fld %st(5) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fld %st(4) + fmul %st(1), %st + fxch %st(4) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + fmul %st(4), %st + fldl 40+_DP@GOTOFF(%edi,%edx,8) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(2) + fxch %st(2) + fmul %st(4), %st + fxch %st(3) + fmull 56+_DP@GOTOFF(%edi,%edx,8) + fldl 48+_DP@GOTOFF(%edi,%edx,8) + fmul %st, %st(3) + movl 8(%esp), %edx + fxch %st(3) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fmull .L_2il0floatpacket.0@GOTOFF(%edi) + fstpl (%edx) + je ..B1.18 +..B1.17: + fldcw 26(%esp) +..B1.18: + movl %ebx, %eax + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + movl $0, 12(%esp) + jmp ..B1.7 + .align 16,0x90 + .type __libm_reduce_pi04d,@function + .size __libm_reduce_pi04d,.-__libm_reduce_pi04d + .data +# -- End __libm_reduce_pi04d + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x54442d18,0x3fe921fb + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +zero_none: + .long 0x00000000,0x00000000 + .long 0x00000000,0xbff00000 + .type zero_none,@object + .size zero_none,16 + .align 4 +_DP: + .long 0 + .long 0 + .long 1610612736 + .long 1282694960 + .long 0 + .long 1256952721 + .long 536870912 + .long 1229269500 + .long 3221225472 + .long 1202544455 + .long 0 + .long 1176818551 + .long 2147483648 + .long 1148939346 + .long 536870912 + .long 1124701124 + .long 3758096384 + .long 1099498527 + .long 3758096384 + .long 1071929578 + .long 1342177280 + .long 1046982385 + .long 805306368 + .long 1020320658 + .long 2147483648 + .long 993817732 + .long 0 + .long 968598976 + .long 2684354560 + .long 942220475 + .long 2415919104 + .long 915426956 + .long 0 + .long 885849629 + .long 536870912 + .long 863855510 + .long 1610612736 + .long 836031391 + .long 4026531840 + .long 810828058 + .long 1073741824 + .long 784674491 + .long 1610612736 + .long 757207974 + .long 3489660928 + .long 732020890 + .long 0 + .long 703061904 + .long 1610612736 + .long 679713053 + .long 2147483648 + .long 652001705 + .long 1073741824 + .long 626850382 + .long 2147483648 + .long 597786158 + .long 805306368 + .long 575535400 + .long 536870912 + .long 548814833 + .long 268435456 + .long 523239288 + .long 3758096384 + .long 495550718 + .long 2952790016 + .long 469954840 + .long 1073741824 + .long 442925723 + .long 1073741824 + .long 416247094 + .long 3758096384 + .long 392128403 + .long 2147483648 + .long 364254062 + .long 3221225472 + .long 339643518 + .long 2684354560 + .long 313162111 + .long 805306368 + .long 286354345 + .long 2952790016 + .long 260811902 + .long 1610612736 + .long 234667567 + .long 3758096384 + .long 207520668 + .long 1073741824 + .long 182175017 + .long 4026531840 + .long 155380331 + .long 805306368 + .long 129417058 + .long 536870912 + .long 103691636 + .long 0 + .long 73760972 + .long 3221225472 + .long 48348958 + .type _DP,@object + .size _DP,392 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_reduce_pi04l.S b/external/sgx_libm/ia32/libm_reduce_pi04l.S new file mode 100644 index 0000000000..e61e1f36b6 --- /dev/null +++ b/external/sgx_libm/ia32/libm_reduce_pi04l.S @@ -0,0 +1,3729 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_reduce_pi04l.c" + .text +..TXTST0: +# -- Begin __libm_reduce_pi04l + .text + .align 16,0x90 + .hidden __libm_reduce_pi04l + .globl __libm_reduce_pi04l +__libm_reduce_pi04l: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 24 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $20, %esp + movzwl 16(%ebp), %ebx + andl $32767, %ebx + movl 20(%ebp), %eax + cmpl $16413, %ebx + movl 24(%ebp), %esi + call ..L2 +..L2: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edi), %edi + movl %eax, 4(%esp) + jge ..B1.8 +..B1.2: + fldt 8(%ebp) + fldl __4onpi_d@GOTOFF(%edi) + fmul %st(1), %st + fstpt 8(%esp) + movzwl 16(%esp), %ecx + negl %ecx + addl $30, %ecx + movl 12(%esp), %eax + shrl %cl, %eax + cmpl $0, 4(%esp) + jne ..B1.4 +..B1.3: + lea 1(%eax), %ecx + andl $-2, %ecx + jmp ..B1.5 +..B1.4: + movl %eax, %ecx + addl 4(%esp), %eax + movl %eax, %edx + andl $1, %edx + addl %edx, %ecx +..B1.5: + fldl _TWO_32H@GOTOFF(%edi) + cmpl $16400, %ebx + movl %ecx, (%esp) + fildl (%esp) + jge ..B1.7 +..B1.6: + fldl _pi04_3d@GOTOFF(%edi) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_pi04_3d@GOTOFF(%edi) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_pi04_3d@GOTOFF(%edi) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.15 +..B1.7: + fldl _pi04_5d@GOTOFF(%edi) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_pi04_5d@GOTOFF(%edi) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_pi04_5d@GOTOFF(%edi) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl 24+_pi04_5d@GOTOFF(%edi) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl 32+_pi04_5d@GOTOFF(%edi) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.15 +..B1.8: + fldt 8(%ebp) + lea -16417(%ebx), %ecx + fmull _SCALE@GOTOFF(%edi) + movl $-2078209981, %eax + imull %ecx + sarl $31, %ecx + lea -16417(%edx,%ebx), %eax + sarl $4, %eax + subl %ecx, %eax + movl %eax, %ecx + shll $5, %ecx + negl %ecx + addl %eax, %ecx + fstpt 8(%ebp) + fldt 8(%ebp) + movl $0, 8(%ebp) + fldt 8(%ebp) + lea -16417(%ecx,%ebx), %ebx + cmpl $17, %ebx + fsubr %st, %st(1) + jl ..B1.10 +..B1.9: + lea (,%eax,8), %edx + lea (%edx,%eax,4), %ecx + incl %eax + fldt __4onpi_31l@GOTOFF(%ecx,%edi) + fmul %st(2), %st + fldt 12+__4onpi_31l@GOTOFF(%edi,%ecx) + fmul %st(2), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 8(%esp) + andl $-16777216, 8(%esp) + fldt 8(%esp) + fsubrp %st, %st(1) + jmp ..B1.11 +..B1.10: + fldl _zeros@GOTOFF(%edi) + fld %st(0) +..B1.11: + fld %st(0) + lea (,%eax,8), %edx + fld %st(3) + lea (%edx,%eax,4), %eax + fldt __4onpi_31l@GOTOFF(%eax,%edi) + fmul %st(6), %st + movl %eax, (%esp) + fadd %st, %st(2) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt 12+__4onpi_31l@GOTOFF(%eax,%edi) + fmul %st, %st(2) + fld %st(2) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fadd %st(3), %st + fxch %st(2) + fmul %st(5), %st + fadd %st, %st(2) + fld %st(4) + fldt 24+__4onpi_31l@GOTOFF(%eax,%edi) + fmul %st, %st(1) + fxch %st(1) + fadd %st, %st(4) + fxch %st(4) + fstpt 8(%esp) + movzwl 16(%esp), %ebx + andl $32767, %ebx + cmpl $16415, %ebx + jge ..B1.13 +..B1.12: + negl %ebx + addl $30, %ebx + movl %ebx, %ecx + movl 12(%esp), %eax + shrl %cl, %eax + shll %cl, %eax + movl %eax, 12(%esp) + movl $0, 8(%esp) + shrl %cl, %eax + jmp ..B1.14 +..B1.13: + negl %ebx + addl $30, %ebx + movl %ebx, %ecx + movl 8(%esp), %edx + shrl %cl, %edx + shll %cl, %edx + negl %ecx + movl 12(%esp), %eax + shll %cl, %eax + movl %ebx, %ecx + movl %edx, 8(%esp) + shrl %cl, %edx + orl %edx, %eax +..B1.14: + fldt 8(%esp) + addl 4(%esp), %eax + fsubrp %st, %st(3) + fmul %st(6), %st + fld %st(4) + movl %eax, %edx + andl $1, %edx + fadd %st(3), %st + movl (%esp), %ecx + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fld %st(1) + fxch %st(3) + faddl zero_none@GOTOFF(%edi,%edx,8) + fadd %st, %st(3) + fsub %st(3), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(2) + fldt 36+__4onpi_31l@GOTOFF(%ecx,%edi) + fmul %st, %st(1) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmul %st(4), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(2) + fldt 48+__4onpi_31l@GOTOFF(%ecx,%edi) + fmul %st, %st(1) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(3) + fxch %st(2) + fmul %st(5), %st + fldt 60+__4onpi_31l@GOTOFF(%ecx,%edi) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fld %st(3) + fxch %st(2) + fmul %st(5), %st + fldt 72+__4onpi_31l@GOTOFF(%ecx,%edi) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(4) + fldt 84+__4onpi_31l@GOTOFF(%edi,%ecx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fldl _TWO_32H@GOTOFF(%edi) + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldl _pi04_2d@GOTOFF(%edi) + fld %st(0) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + fmull 8+_pi04_2d@GOTOFF(%edi) + faddp %st, %st(1) +..B1.15: + fldl _TWO_12H@GOTOFF(%edi) + fld %st(2) + fadd %st(2), %st + fmul %st, %st(1) + fstpt 8(%esp) + fldt 8(%esp) + fadd %st(1), %st + fsubp %st, %st(1) + fstl (%esi) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpl 8(%esi) + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __libm_reduce_pi04l,@function + .size __libm_reduce_pi04l,.-__libm_reduce_pi04l + .data +# -- End __libm_reduce_pi04l + .section .rodata, "a" + .align 8 + .align 8 +zero_none: + .long 0x00000000,0x00000000 + .long 0x00000000,0xbff00000 + .type zero_none,@object + .size zero_none,16 + .align 4 +__4onpi_d: + .long 1841940611 + .long 1072979760 + .type __4onpi_d,@object + .size __4onpi_d,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_pi04_3d: + .long 1413754112 + .long 1072243195 + .long 2563527040 + .long 1021855384 + .long 3417685868 + .long 3118450936 + .type _pi04_3d,@object + .size _pi04_3d,24 + .align 4 +_pi04_5d: + .long 1413480448 + .long 1072243195 + .long 442499072 + .long 1036039265 + .long 771751936 + .long 999496074 + .long 622854144 + .long 963347354 + .long 1396597664 + .long 922906692 + .type _pi04_5d,@object + .size _pi04_5d,40 + .align 4 +_SCALE: + .long 0 + .long 845152256 + .type _SCALE,@object + .size _SCALE,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_pi04_2d: + .long 1413480448 + .long 1072243195 + .long 442655537 + .long 1036039265 + .type _pi04_2d,@object + .size _pi04_2d,16 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 2 +__4onpi_31l: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33646 + .word 41721 + .word 16600 + .word 0 + .word 0 + .word 0 + .word 10832 + .word 40072 + .word 16567 + .word 0 + .word 0 + .word 0 + .word 44008 + .word 65043 + .word 16537 + .word 0 + .word 0 + .word 0 + .word 28384 + .word 64154 + .word 16505 + .word 0 + .word 0 + .word 0 + .word 38272 + .word 56162 + .word 16472 + .word 0 + .word 0 + .word 0 + .word 7298 + .word 51682 + .word 16445 + .word 0 + .word 0 + .word 0 + .word 45504 + .word 65320 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 61204 + .word 44922 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 18652 + .word 50030 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 14144 + .word 59657 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 37450 + .word 47105 + .word 16290 + .word 0 + .word 0 + .word 0 + .word 14898 + .word 56641 + .word 16259 + .word 0 + .word 0 + .word 0 + .word 34680 + .word 34623 + .word 16226 + .word 0 + .word 0 + .word 0 + .word 4760 + .word 45515 + .word 16196 + .word 0 + .word 0 + .word 0 + .word 41480 + .word 40187 + .word 16166 + .word 0 + .word 0 + .word 0 + .word 47852 + .word 55252 + .word 16134 + .word 0 + .word 0 + .word 0 + .word 54072 + .word 35081 + .word 16103 + .word 0 + .word 0 + .word 0 + .word 26808 + .word 57421 + .word 16071 + .word 0 + .word 0 + .word 0 + .word 20068 + .word 57232 + .word 16042 + .word 0 + .word 0 + .word 0 + .word 49576 + .word 60188 + .word 16009 + .word 0 + .word 0 + .word 0 + .word 10016 + .word 52861 + .word 15978 + .word 0 + .word 0 + .word 0 + .word 30648 + .word 35825 + .word 15947 + .word 0 + .word 0 + .word 0 + .word 60542 + .word 58528 + .word 15918 + .word 0 + .word 0 + .word 0 + .word 65468 + .word 61743 + .word 15887 + .word 0 + .word 0 + .word 0 + .word 64960 + .word 45825 + .word 15851 + .word 0 + .word 0 + .word 0 + .word 50604 + .word 38792 + .word 15825 + .word 0 + .word 0 + .word 0 + .word 18394 + .word 33435 + .word 15794 + .word 0 + .word 0 + .word 0 + .word 55780 + .word 42703 + .word 15763 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 63841 + .word 15731 + .word 0 + .word 0 + .word 0 + .word 63080 + .word 62563 + .word 15700 + .word 0 + .word 0 + .word 0 + .word 20840 + .word 62207 + .word 15669 + .word 0 + .word 0 + .word 0 + .word 30094 + .word 59983 + .word 15639 + .word 0 + .word 0 + .word 0 + .word 61818 + .word 60389 + .word 15608 + .word 0 + .word 0 + .word 0 + .word 40186 + .word 40579 + .word 15577 + .word 0 + .word 0 + .word 0 + .word 42170 + .word 58004 + .word 15546 + .word 0 + .word 0 + .word 0 + .word 55276 + .word 39678 + .word 15514 + .word 0 + .word 0 + .word 0 + .word 44672 + .word 36806 + .word 15481 + .word 0 + .word 0 + .word 0 + .word 13060 + .word 34144 + .word 15452 + .word 0 + .word 0 + .word 0 + .word 28016 + .word 57231 + .word 15419 + .word 0 + .word 0 + .word 0 + .word 16112 + .word 44995 + .word 15390 + .word 0 + .word 0 + .word 0 + .word 53464 + .word 33387 + .word 15358 + .word 0 + .word 0 + .word 0 + .word 7296 + .word 60751 + .word 15325 + .word 0 + .word 0 + .word 0 + .word 29452 + .word 45231 + .word 15297 + .word 0 + .word 0 + .word 0 + .word 26208 + .word 49689 + .word 15266 + .word 0 + .word 0 + .word 0 + .word 37900 + .word 44002 + .word 15235 + .word 0 + .word 0 + .word 0 + .word 57340 + .word 33800 + .word 15204 + .word 0 + .word 0 + .word 0 + .word 27544 + .word 50178 + .word 15173 + .word 0 + .word 0 + .word 0 + .word 6168 + .word 40132 + .word 15142 + .word 0 + .word 0 + .word 0 + .word 21392 + .word 43702 + .word 15109 + .word 0 + .word 0 + .word 0 + .word 45168 + .word 54372 + .word 15081 + .word 0 + .word 0 + .word 0 + .word 8986 + .word 40688 + .word 15050 + .word 0 + .word 0 + .word 0 + .word 1648 + .word 53745 + .word 15018 + .word 0 + .word 0 + .word 0 + .word 30520 + .word 55795 + .word 14986 + .word 0 + .word 0 + .word 0 + .word 43060 + .word 32914 + .word 14956 + .word 0 + .word 0 + .word 0 + .word 46172 + .word 52771 + .word 14925 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 45285 + .word 14893 + .word 0 + .word 0 + .word 0 + .word 53590 + .word 44868 + .word 14864 + .word 0 + .word 0 + .word 0 + .word 40786 + .word 35970 + .word 14833 + .word 0 + .word 0 + .word 0 + .word 33436 + .word 65411 + .word 14801 + .word 0 + .word 0 + .word 0 + .word 32006 + .word 61382 + .word 14771 + .word 0 + .word 0 + .word 0 + .word 37856 + .word 45239 + .word 14738 + .word 0 + .word 0 + .word 0 + .word 60894 + .word 49555 + .word 14709 + .word 0 + .word 0 + .word 0 + .word 48064 + .word 53065 + .word 14674 + .word 0 + .word 0 + .word 0 + .word 48624 + .word 54844 + .word 14647 + .word 0 + .word 0 + .word 0 + .word 7988 + .word 40762 + .word 14616 + .word 0 + .word 0 + .word 0 + .word 16270 + .word 58745 + .word 14585 + .word 0 + .word 0 + .word 0 + .word 37064 + .word 50168 + .word 14553 + .word 0 + .word 0 + .word 0 + .word 18624 + .word 63736 + .word 14519 + .word 0 + .word 0 + .word 0 + .word 60758 + .word 44966 + .word 14492 + .word 0 + .word 0 + .word 0 + .word 33304 + .word 47465 + .word 14461 + .word 0 + .word 0 + .word 0 + .word 6226 + .word 60503 + .word 14430 + .word 0 + .word 0 + .word 0 + .word 26380 + .word 54900 + .word 14398 + .word 0 + .word 0 + .word 0 + .word 44352 + .word 49860 + .word 14368 + .word 0 + .word 0 + .word 0 + .word 11904 + .word 42646 + .word 14337 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 50279 + .word 14300 + .word 0 + .word 0 + .word 0 + .word 15474 + .word 50606 + .word 14275 + .word 0 + .word 0 + .word 0 + .word 45062 + .word 44137 + .word 14244 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 36063 + .word 14210 + .word 0 + .word 0 + .word 0 + .word 40658 + .word 53854 + .word 14182 + .word 0 + .word 0 + .word 0 + .word 28652 + .word 43690 + .word 14151 + .word 0 + .word 0 + .word 0 + .word 24640 + .word 64348 + .word 14118 + .word 0 + .word 0 + .word 0 + .word 30284 + .word 41980 + .word 14088 + .word 0 + .word 0 + .word 0 + .word 45652 + .word 38222 + .word 14057 + .word 0 + .word 0 + .word 0 + .word 15900 + .word 62940 + .word 14026 + .word 0 + .word 0 + .word 0 + .word 31494 + .word 50741 + .word 13996 + .word 0 + .word 0 + .word 0 + .word 43194 + .word 55096 + .word 13965 + .word 0 + .word 0 + .word 0 + .word 1740 + .word 45646 + .word 13933 + .word 0 + .word 0 + .word 0 + .word 28936 + .word 44150 + .word 13903 + .word 0 + .word 0 + .word 0 + .word 8996 + .word 42955 + .word 13872 + .word 0 + .word 0 + .word 0 + .word 44096 + .word 61205 + .word 13839 + .word 0 + .word 0 + .word 0 + .word 44614 + .word 54550 + .word 13810 + .word 0 + .word 0 + .word 0 + .word 24926 + .word 57347 + .word 13779 + .word 0 + .word 0 + .word 0 + .word 3312 + .word 61415 + .word 13745 + .word 0 + .word 0 + .word 0 + .word 64336 + .word 63884 + .word 13717 + .word 0 + .word 0 + .word 0 + .word 2748 + .word 62259 + .word 13685 + .word 0 + .word 0 + .word 0 + .word 56672 + .word 51775 + .word 13653 + .word 0 + .word 0 + .word 0 + .word 32438 + .word 55423 + .word 13624 + .word 0 + .word 0 + .word 0 + .word 17652 + .word 45713 + .word 13593 + .word 0 + .word 0 + .word 0 + .word 65408 + .word 51586 + .word 13558 + .word 0 + .word 0 + .word 0 + .word 40416 + .word 55736 + .word 13531 + .word 0 + .word 0 + .word 0 + .word 52546 + .word 37734 + .word 13500 + .word 0 + .word 0 + .word 0 + .word 48880 + .word 64238 + .word 13469 + .word 0 + .word 0 + .word 0 + .word 56004 + .word 46833 + .word 13437 + .word 0 + .word 0 + .word 0 + .word 61760 + .word 38110 + .word 13405 + .word 0 + .word 0 + .word 0 + .word 41496 + .word 35659 + .word 13374 + .word 0 + .word 0 + .word 0 + .word 25472 + .word 41269 + .word 13342 + .word 0 + .word 0 + .word 0 + .word 45444 + .word 36018 + .word 13314 + .word 0 + .word 0 + .word 0 + .word 6510 + .word 56417 + .word 13283 + .word 0 + .word 0 + .word 0 + .word 3072 + .word 56837 + .word 13252 + .word 0 + .word 0 + .word 0 + .word 61338 + .word 48440 + .word 13221 + .word 0 + .word 0 + .word 0 + .word 49568 + .word 57088 + .word 13189 + .word 0 + .word 0 + .word 0 + .word 4240 + .word 39283 + .word 13157 + .word 0 + .word 0 + .word 0 + .word 18562 + .word 33537 + .word 13128 + .word 0 + .word 0 + .word 0 + .word 31422 + .word 44487 + .word 13097 + .word 0 + .word 0 + .word 0 + .word 31930 + .word 60459 + .word 13066 + .word 0 + .word 0 + .word 0 + .word 42272 + .word 36641 + .word 13033 + .word 0 + .word 0 + .word 0 + .word 28940 + .word 36150 + .word 13004 + .word 0 + .word 0 + .word 0 + .word 21010 + .word 50925 + .word 12973 + .word 0 + .word 0 + .word 0 + .word 29448 + .word 64886 + .word 12941 + .word 0 + .word 0 + .word 0 + .word 20500 + .word 54600 + .word 12911 + .word 0 + .word 0 + .word 0 + .word 54258 + .word 46233 + .word 12880 + .word 0 + .word 0 + .word 0 + .word 32628 + .word 42502 + .word 12848 + .word 0 + .word 0 + .word 0 + .word 61608 + .word 55072 + .word 12818 + .word 0 + .word 0 + .word 0 + .word 6236 + .word 57871 + .word 12786 + .word 0 + .word 0 + .word 0 + .word 42408 + .word 34616 + .word 12756 + .word 0 + .word 0 + .word 0 + .word 56692 + .word 51963 + .word 12724 + .word 0 + .word 0 + .word 0 + .word 39094 + .word 48526 + .word 12694 + .word 0 + .word 0 + .word 0 + .word 59870 + .word 38783 + .word 12663 + .word 0 + .word 0 + .word 0 + .word 26560 + .word 33165 + .word 12632 + .word 0 + .word 0 + .word 0 + .word 58666 + .word 37666 + .word 12601 + .word 0 + .word 0 + .word 0 + .word 58728 + .word 39788 + .word 12569 + .word 0 + .word 0 + .word 0 + .word 9048 + .word 43530 + .word 12538 + .word 0 + .word 0 + .word 0 + .word 58496 + .word 57659 + .word 12505 + .word 0 + .word 0 + .word 0 + .word 12324 + .word 37025 + .word 12477 + .word 0 + .word 0 + .word 0 + .word 38432 + .word 55856 + .word 12445 + .word 0 + .word 0 + .word 0 + .word 35210 + .word 45960 + .word 12415 + .word 0 + .word 0 + .word 0 + .word 45644 + .word 51345 + .word 12384 + .word 0 + .word 0 + .word 0 + .word 32854 + .word 63883 + .word 12353 + .word 0 + .word 0 + .word 0 + .word 29348 + .word 41450 + .word 12321 + .word 0 + .word 0 + .word 0 + .word 27384 + .word 38024 + .word 12289 + .word 0 + .word 0 + .word 0 + .word 57356 + .word 57291 + .word 12260 + .word 0 + .word 0 + .word 0 + .word 61164 + .word 51521 + .word 12228 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 59151 + .word 12196 + .word 0 + .word 0 + .word 0 + .word 36704 + .word 39943 + .word 12165 + .word 0 + .word 0 + .word 0 + .word 45864 + .word 50151 + .word 12136 + .word 0 + .word 0 + .word 0 + .word 37892 + .word 63687 + .word 12104 + .word 0 + .word 0 + .word 0 + .word 14560 + .word 51615 + .word 12073 + .word 0 + .word 0 + .word 0 + .word 38776 + .word 55684 + .word 12041 + .word 0 + .word 0 + .word 0 + .word 59136 + .word 53570 + .word 12010 + .word 0 + .word 0 + .word 0 + .word 55556 + .word 37955 + .word 11981 + .word 0 + .word 0 + .word 0 + .word 54458 + .word 44670 + .word 11950 + .word 0 + .word 0 + .word 0 + .word 36446 + .word 34084 + .word 11919 + .word 0 + .word 0 + .word 0 + .word 46416 + .word 51693 + .word 11886 + .word 0 + .word 0 + .word 0 + .word 21432 + .word 34376 + .word 11857 + .word 0 + .word 0 + .word 0 + .word 56036 + .word 34809 + .word 11826 + .word 0 + .word 0 + .word 0 + .word 10562 + .word 55654 + .word 11795 + .word 0 + .word 0 + .word 0 + .word 20264 + .word 53052 + .word 11763 + .word 0 + .word 0 + .word 0 + .word 64064 + .word 50415 + .word 11729 + .word 0 + .word 0 + .word 0 + .word 17444 + .word 48295 + .word 11701 + .word 0 + .word 0 + .word 0 + .word 11874 + .word 52677 + .word 11671 + .word 0 + .word 0 + .word 0 + .word 60808 + .word 39275 + .word 11640 + .word 0 + .word 0 + .word 0 + .word 31792 + .word 55677 + .word 11606 + .word 0 + .word 0 + .word 0 + .word 60710 + .word 49006 + .word 11578 + .word 0 + .word 0 + .word 0 + .word 10520 + .word 37403 + .word 11546 + .word 0 + .word 0 + .word 0 + .word 20004 + .word 59470 + .word 11515 + .word 0 + .word 0 + .word 0 + .word 28096 + .word 37612 + .word 11485 + .word 0 + .word 0 + .word 0 + .word 20268 + .word 44280 + .word 11453 + .word 0 + .word 0 + .word 0 + .word 50740 + .word 61588 + .word 11422 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 58835 + .word 11390 + .word 0 + .word 0 + .word 0 + .word 8576 + .word 42496 + .word 11355 + .word 0 + .word 0 + .word 0 + .word 33920 + .word 54912 + .word 11324 + .word 0 + .word 0 + .word 0 + .word 35620 + .word 54843 + .word 11298 + .word 0 + .word 0 + .word 0 + .word 736 + .word 43591 + .word 11264 + .word 0 + .word 0 + .word 0 + .word 39632 + .word 61060 + .word 11235 + .word 0 + .word 0 + .word 0 + .word 63452 + .word 63129 + .word 11206 + .word 0 + .word 0 + .word 0 + .word 56798 + .word 58512 + .word 11175 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 46333 + .word 11141 + .word 0 + .word 0 + .word 0 + .word 37300 + .word 36598 + .word 11112 + .word 0 + .word 0 + .word 0 + .word 41952 + .word 41639 + .word 11079 + .word 0 + .word 0 + .word 0 + .word 52452 + .word 33459 + .word 11050 + .word 0 + .word 0 + .word 0 + .word 58558 + .word 33287 + .word 11020 + .word 0 + .word 0 + .word 0 + .word 7570 + .word 43843 + .word 10989 + .word 0 + .word 0 + .word 0 + .word 59416 + .word 63990 + .word 10957 + .word 0 + .word 0 + .word 0 + .word 65298 + .word 47744 + .word 10927 + .word 0 + .word 0 + .word 0 + .word 21076 + .word 34089 + .word 10896 + .word 0 + .word 0 + .word 0 + .word 7048 + .word 57394 + .word 10865 + .word 0 + .word 0 + .word 0 + .word 12872 + .word 55405 + .word 10832 + .word 0 + .word 0 + .word 0 + .word 12608 + .word 51669 + .word 10798 + .word 0 + .word 0 + .word 0 + .word 5350 + .word 48455 + .word 10772 + .word 0 + .word 0 + .word 0 + .word 23568 + .word 58692 + .word 10740 + .word 0 + .word 0 + .word 0 + .word 40784 + .word 37046 + .word 10708 + .word 0 + .word 0 + .word 0 + .word 38992 + .word 43861 + .word 10678 + .word 0 + .word 0 + .word 0 + .word 10064 + .word 40199 + .word 10648 + .word 0 + .word 0 + .word 0 + .word 26368 + .word 35771 + .word 10611 + .word 0 + .word 0 + .word 0 + .word 23994 + .word 60721 + .word 10586 + .word 0 + .word 0 + .word 0 + .word 25052 + .word 34302 + .word 10554 + .word 0 + .word 0 + .word 0 + .word 39842 + .word 54964 + .word 10524 + .word 0 + .word 0 + .word 0 + .word 11568 + .word 58277 + .word 10491 + .word 0 + .word 0 + .word 0 + .word 26160 + .word 46438 + .word 10461 + .word 0 + .word 0 + .word 0 + .word 23252 + .word 43049 + .word 10431 + .word 0 + .word 0 + .word 0 + .word 35288 + .word 58000 + .word 10400 + .word 0 + .word 0 + .word 0 + .word 14614 + .word 50216 + .word 10369 + .word 0 + .word 0 + .word 0 + .word 1168 + .word 48804 + .word 10336 + .word 0 + .word 0 + .word 0 + .word 60934 + .word 33006 + .word 10307 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 62247 + .word 10272 + .word 0 + .word 0 + .word 0 + .word 59968 + .word 43121 + .word 10240 + .word 0 + .word 0 + .word 0 + .word 25560 + .word 39974 + .word 10212 + .word 0 + .word 0 + .word 0 + .word 1978 + .word 49353 + .word 10183 + .word 0 + .word 0 + .word 0 + .word 16290 + .word 38807 + .word 10152 + .word 0 + .word 0 + .word 0 + .word 8646 + .word 65226 + .word 10121 + .word 0 + .word 0 + .word 0 + .word 56896 + .word 34317 + .word 10088 + .word 0 + .word 0 + .word 0 + .word 40136 + .word 39118 + .word 10057 + .word 0 + .word 0 + .word 0 + .word 14200 + .word 41756 + .word 10026 + .word 0 + .word 0 + .word 0 + .word 59256 + .word 63202 + .word 9995 + .word 0 + .word 0 + .word 0 + .word 22968 + .word 63553 + .word 9965 + .word 0 + .word 0 + .word 0 + .word 736 + .word 44292 + .word 9933 + .word 0 + .word 0 + .word 0 + .word 23186 + .word 37760 + .word 9904 + .word 0 + .word 0 + .word 0 + .word 51008 + .word 34950 + .word 9869 + .word 0 + .word 0 + .word 0 + .word 1664 + .word 64248 + .word 9836 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 35199 + .word 9811 + .word 0 + .word 0 + .word 0 + .word 34656 + .word 63747 + .word 9780 + .word 0 + .word 0 + .word 0 + .word 44330 + .word 49864 + .word 9749 + .word 0 + .word 0 + .word 0 + .word 11654 + .word 35567 + .word 9718 + .word 0 + .word 0 + .word 0 + .word 7924 + .word 58919 + .word 9686 + .word 0 + .word 0 + .word 0 + .word 2532 + .word 32800 + .word 9655 + .word 0 + .word 0 + .word 0 + .word 30024 + .word 53799 + .word 9624 + .word 0 + .word 0 + .word 0 + .word 30172 + .word 64347 + .word 9593 + .word 0 + .word 0 + .word 0 + .word 60036 + .word 51382 + .word 9562 + .word 0 + .word 0 + .word 0 + .word 58576 + .word 33093 + .word 9531 + .word 0 + .word 0 + .word 0 + .word 13888 + .word 38760 + .word 9500 + .word 0 + .word 0 + .word 0 + .word 9322 + .word 52460 + .word 9470 + .word 0 + .word 0 + .word 0 + .word 20944 + .word 41077 + .word 9437 + .word 0 + .word 0 + .word 0 + .word 17976 + .word 41861 + .word 9407 + .word 0 + .word 0 + .word 0 + .word 55176 + .word 55158 + .word 9377 + .word 0 + .word 0 + .word 0 + .word 4976 + .word 35223 + .word 9346 + .word 0 + .word 0 + .word 0 + .word 7816 + .word 39783 + .word 9314 + .word 0 + .word 0 + .word 0 + .word 27656 + .word 55669 + .word 9284 + .word 0 + .word 0 + .word 0 + .word 64944 + .word 53184 + .word 9250 + .word 0 + .word 0 + .word 0 + .word 12544 + .word 49190 + .word 9222 + .word 0 + .word 0 + .word 0 + .word 50612 + .word 44644 + .word 9190 + .word 0 + .word 0 + .word 0 + .word 8832 + .word 63111 + .word 9155 + .word 0 + .word 0 + .word 0 + .word 11744 + .word 36870 + .word 9129 + .word 0 + .word 0 + .word 0 + .word 9404 + .word 63025 + .word 9098 + .word 0 + .word 0 + .word 0 + .word 47316 + .word 43381 + .word 9067 + .word 0 + .word 0 + .word 0 + .word 55716 + .word 47433 + .word 9035 + .word 0 + .word 0 + .word 0 + .word 46414 + .word 48441 + .word 9005 + .word 0 + .word 0 + .word 0 + .word 19116 + .word 39506 + .word 8974 + .word 0 + .word 0 + .word 0 + .word 48060 + .word 53381 + .word 8943 + .word 0 + .word 0 + .word 0 + .word 57112 + .word 50739 + .word 8911 + .word 0 + .word 0 + .word 0 + .word 5840 + .word 60581 + .word 8879 + .word 0 + .word 0 + .word 0 + .word 62112 + .word 57199 + .word 8846 + .word 0 + .word 0 + .word 0 + .word 35908 + .word 59499 + .word 8818 + .word 0 + .word 0 + .word 0 + .word 13760 + .word 48116 + .word 8787 + .word 0 + .word 0 + .word 0 + .word 3136 + .word 56059 + .word 8752 + .word 0 + .word 0 + .word 0 + .word 37596 + .word 39221 + .word 8726 + .word 0 + .word 0 + .word 0 + .word 3232 + .word 48550 + .word 8691 + .word 0 + .word 0 + .word 0 + .word 22872 + .word 42749 + .word 8662 + .word 0 + .word 0 + .word 0 + .word 41948 + .word 40319 + .word 8633 + .word 0 + .word 0 + .word 0 + .word 31196 + .word 64693 + .word 8601 + .word 0 + .word 0 + .word 0 + .word 62052 + .word 52923 + .word 8571 + .word 0 + .word 0 + .word 0 + .word 2750 + .word 33544 + .word 8540 + .word 0 + .word 0 + .word 0 + .word 12462 + .word 46179 + .word 8509 + .word 0 + .word 0 + .word 0 + .word 25128 + .word 45120 + .word 8476 + .word 0 + .word 0 + .word 0 + .word 51634 + .word 62523 + .word 8447 + .word 0 + .word 0 + .word 0 + .word 15758 + .word 42163 + .word 8416 + .word 0 + .word 0 + .word 0 + .word 34022 + .word 36267 + .word 8385 + .word 0 + .word 0 + .word 0 + .word 41252 + .word 39796 + .word 8353 + .word 0 + .word 0 + .word 0 + .word 49782 + .word 54423 + .word 8323 + .word 0 + .word 0 + .word 0 + .word 25428 + .word 42086 + .word 8291 + .word 0 + .word 0 + .word 0 + .word 34388 + .word 44810 + .word 8260 + .word 0 + .word 0 + .word 0 + .word 7456 + .word 64092 + .word 8228 + .word 0 + .word 0 + .word 0 + .word 48336 + .word 62448 + .word 8196 + .word 0 + .word 0 + .word 0 + .word 60912 + .word 61622 + .word 8167 + .word 0 + .word 0 + .word 0 + .word 17852 + .word 37250 + .word 8137 + .word 0 + .word 0 + .word 0 + .word 57940 + .word 56453 + .word 8106 + .word 0 + .word 0 + .word 0 + .word 47256 + .word 59825 + .word 8074 + .word 0 + .word 0 + .word 0 + .word 3774 + .word 59120 + .word 8044 + .word 0 + .word 0 + .word 0 + .word 43448 + .word 62852 + .word 8012 + .word 0 + .word 0 + .word 0 + .word 4840 + .word 57195 + .word 7982 + .word 0 + .word 0 + .word 0 + .word 40862 + .word 52565 + .word 7951 + .word 0 + .word 0 + .word 0 + .word 1440 + .word 60474 + .word 7919 + .word 0 + .word 0 + .word 0 + .word 55520 + .word 38648 + .word 7889 + .word 0 + .word 0 + .word 0 + .word 15316 + .word 52422 + .word 7857 + .word 0 + .word 0 + .word 0 + .word 18704 + .word 47227 + .word 7827 + .word 0 + .word 0 + .word 0 + .word 48892 + .word 54283 + .word 7795 + .word 0 + .word 0 + .word 0 + .word 12670 + .word 41990 + .word 7765 + .word 0 + .word 0 + .word 0 + .word 27570 + .word 49842 + .word 7734 + .word 0 + .word 0 + .word 0 + .word 47230 + .word 47992 + .word 7703 + .word 0 + .word 0 + .word 0 + .word 41020 + .word 56253 + .word 7671 + .word 0 + .word 0 + .word 0 + .word 23404 + .word 58312 + .word 7641 + .word 0 + .word 0 + .word 0 + .word 35176 + .word 51854 + .word 7610 + .word 0 + .word 0 + .word 0 + .word 49188 + .word 59051 + .word 7578 + .word 0 + .word 0 + .word 0 + .word 16656 + .word 54507 + .word 7546 + .word 0 + .word 0 + .word 0 + .word 41320 + .word 48565 + .word 7517 + .word 0 + .word 0 + .word 0 + .word 302 + .word 42490 + .word 7486 + .word 0 + .word 0 + .word 0 + .word 26680 + .word 39967 + .word 7454 + .word 0 + .word 0 + .word 0 + .word 41304 + .word 43638 + .word 7424 + .word 0 + .word 0 + .word 0 + .word 2314 + .word 48533 + .word 7393 + .word 0 + .word 0 + .word 0 + .word 63294 + .word 35693 + .word 7362 + .word 0 + .word 0 + .word 0 + .word 24538 + .word 48319 + .word 7331 + .word 0 + .word 0 + .word 0 + .word 56296 + .word 47263 + .word 7300 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 38599 + .word 7268 + .word 0 + .word 0 + .word 0 + .word 6594 + .word 62116 + .word 7238 + .word 0 + .word 0 + .word 0 + .word 47104 + .word 63573 + .word 7198 + .word 0 + .word 0 + .word 0 + .word 34812 + .word 34303 + .word 7176 + .word 0 + .word 0 + .word 0 + .word 5144 + .word 33695 + .word 7145 + .word 0 + .word 0 + .word 0 + .word 24966 + .word 55768 + .word 7114 + .word 0 + .word 0 + .word 0 + .word 62720 + .word 43946 + .word 7078 + .word 0 + .word 0 + .word 0 + .word 31542 + .word 56062 + .word 7052 + .word 0 + .word 0 + .word 0 + .word 62356 + .word 59096 + .word 7020 + .word 0 + .word 0 + .word 0 + .word 28412 + .word 40533 + .word 6990 + .word 0 + .word 0 + .word 0 + .word 24080 + .word 50467 + .word 6958 + .word 0 + .word 0 + .word 0 + .word 33296 + .word 46841 + .word 6925 + .word 0 + .word 0 + .word 0 + .word 39600 + .word 38627 + .word 6897 + .word 0 + .word 0 + .word 0 + .word 14436 + .word 37607 + .word 6865 + .word 0 + .word 0 + .word 0 + .word 39032 + .word 56421 + .word 6833 + .word 0 + .word 0 + .word 0 + .word 64032 + .word 54987 + .word 6804 + .word 0 + .word 0 + .word 0 + .word 27648 + .word 42212 + .word 6768 + .word 0 + .word 0 + .word 0 + .word 43840 + .word 46107 + .word 6739 + .word 0 + .word 0 + .word 0 + .word 17316 + .word 36574 + .word 6711 + .word 0 + .word 0 + .word 0 + .word 8928 + .word 37652 + .word 6677 + .word 0 + .word 0 + .word 0 + .word 24944 + .word 47433 + .word 6648 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 57430 + .word 6616 + .word 0 + .word 0 + .word 0 + .word 39848 + .word 43340 + .word 6585 + .word 0 + .word 0 + .word 0 + .word 64160 + .word 43542 + .word 6555 + .word 0 + .word 0 + .word 0 + .word 35226 + .word 63015 + .word 6525 + .word 0 + .word 0 + .word 0 + .word 40736 + .word 64368 + .word 6493 + .word 0 + .word 0 + .word 0 + .word 42168 + .word 49526 + .word 6462 + .word 0 + .word 0 + .word 0 + .word 45596 + .word 34243 + .word 6432 + .word 0 + .word 0 + .word 0 + .word 20690 + .word 39705 + .word 6401 + .word 0 + .word 0 + .word 0 + .word 54448 + .word 46856 + .word 6368 + .word 0 + .word 0 + .word 0 + .word 64392 + .word 62736 + .word 6337 + .word 0 + .word 0 + .word 0 + .word 12780 + .word 56461 + .word 6307 + .word 0 + .word 0 + .word 0 + .word 15360 + .word 49145 + .word 6277 + .word 0 + .word 0 + .word 0 + .word 20512 + .word 49931 + .word 6242 + .word 0 + .word 0 + .word 0 + .word 54512 + .word 55820 + .word 6212 + .word 0 + .word 0 + .word 0 + .word 8402 + .word 39333 + .word 6184 + .word 0 + .word 0 + .word 0 + .word 34094 + .word 53593 + .word 6153 + .word 0 + .word 0 + .word 0 + .word 31960 + .word 38817 + .word 6121 + .word 0 + .word 0 + .word 0 + .word 16954 + .word 39291 + .word 6091 + .word 0 + .word 0 + .word 0 + .word 49600 + .word 48765 + .word 6056 + .word 0 + .word 0 + .word 0 + .word 59580 + .word 56541 + .word 6029 + .word 0 + .word 0 + .word 0 + .word 35624 + .word 44550 + .word 5998 + .word 0 + .word 0 + .word 0 + .word 4142 + .word 47316 + .word 5967 + .word 0 + .word 0 + .word 0 + .word 43520 + .word 43612 + .word 5935 + .word 0 + .word 0 + .word 0 + .word 20976 + .word 40896 + .word 5902 + .word 0 + .word 0 + .word 0 + .word 63576 + .word 57729 + .word 5874 + .word 0 + .word 0 + .word 0 + .word 37288 + .word 33122 + .word 5843 + .word 0 + .word 0 + .word 0 + .word 24384 + .word 52079 + .word 5809 + .word 0 + .word 0 + .word 0 + .word 47952 + .word 58719 + .word 5779 + .word 0 + .word 0 + .word 0 + .word 44242 + .word 55445 + .word 5750 + .word 0 + .word 0 + .word 0 + .word 61232 + .word 38847 + .word 5716 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 46039 + .word 5683 + .word 0 + .word 0 + .word 0 + .word 13396 + .word 42933 + .word 5657 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 43305 + .word 5622 + .word 0 + .word 0 + .word 0 + .word 40708 + .word 35319 + .word 5595 + .word 0 + .word 0 + .word 0 + .word 44408 + .word 55685 + .word 5564 + .word 0 + .word 0 + .word 0 + .word 42090 + .word 44607 + .word 5533 + .word 0 + .word 0 + .word 0 + .word 25504 + .word 53466 + .word 5500 + .word 0 + .word 0 + .word 0 + .word 24208 + .word 33149 + .word 5470 + .word 0 + .word 0 + .word 0 + .word 5268 + .word 45375 + .word 5440 + .word 0 + .word 0 + .word 0 + .word 144 + .word 40000 + .word 5409 + .word 0 + .word 0 + .word 0 + .word 56688 + .word 52358 + .word 5376 + .word 0 + .word 0 + .word 0 + .word 25848 + .word 56175 + .word 5345 + .word 0 + .word 0 + .word 0 + .word 57900 + .word 44055 + .word 5315 + .word 0 + .word 0 + .word 0 + .word 24800 + .word 43437 + .word 5283 + .word 0 + .word 0 + .word 0 + .word 17984 + .word 54872 + .word 5249 + .word 0 + .word 0 + .word 0 + .word 25744 + .word 41345 + .word 5223 + .word 0 + .word 0 + .word 0 + .word 7668 + .word 43682 + .word 5191 + .word 0 + .word 0 + .word 0 + .word 47434 + .word 36705 + .word 5161 + .word 0 + .word 0 + .word 0 + .word 20888 + .word 40323 + .word 5129 + .word 0 + .word 0 + .word 0 + .word 3962 + .word 43032 + .word 5099 + .word 0 + .word 0 + .word 0 + .word 50270 + .word 49260 + .word 5068 + .word 0 + .word 0 + .word 0 + .word 20160 + .word 64041 + .word 5032 + .word 0 + .word 0 + .word 0 + .word 25624 + .word 36013 + .word 5004 + .word 0 + .word 0 + .word 0 + .word 48328 + .word 59345 + .word 4975 + .word 0 + .word 0 + .word 0 + .word 51508 + .word 63920 + .word 4943 + .word 0 + .word 0 + .word 0 + .word 27872 + .word 39135 + .word 4913 + .word 0 + .word 0 + .word 0 + .word 13590 + .word 58857 + .word 4882 + .word 0 + .word 0 + .word 0 + .word 50880 + .word 61323 + .word 4847 + .word 0 + .word 0 + .word 0 + .word 44802 + .word 37181 + .word 4820 + .word 0 + .word 0 + .word 0 + .word 53808 + .word 57813 + .word 4789 + .word 0 + .word 0 + .word 0 + .word 64424 + .word 49714 + .word 4757 + .word 0 + .word 0 + .word 0 + .word 31652 + .word 44011 + .word 4727 + .word 0 + .word 0 + .word 0 + .word 28252 + .word 50834 + .word 4696 + .word 0 + .word 0 + .word 0 + .word 30370 + .word 38742 + .word 4665 + .word 0 + .word 0 + .word 0 + .word 57728 + .word 58403 + .word 4628 + .word 0 + .word 0 + .word 0 + .word 35900 + .word 37112 + .word 4603 + .word 0 + .word 0 + .word 0 + .word 40764 + .word 40914 + .word 4572 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 46910 + .word 4541 + .word 0 + .word 0 + .word 0 + .word 17854 + .word 35030 + .word 4510 + .word 0 + .word 0 + .word 0 + .word 4378 + .word 35776 + .word 4479 + .word 0 + .word 0 + .word 0 + .word 57962 + .word 55295 + .word 4448 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 56717 + .word 4415 + .word 0 + .word 0 + .word 0 + .word 37744 + .word 49416 + .word 4384 + .word 0 + .word 0 + .word 0 + .word 38484 + .word 35759 + .word 4355 + .word 0 + .word 0 + .word 0 + .word 55020 + .word 54969 + .word 4324 + .word 0 + .word 0 + .word 0 + .word 9188 + .word 55223 + .word 4292 + .word 0 + .word 0 + .word 0 + .word 6822 + .word 43079 + .word 4262 + .word 0 + .word 0 + .word 0 + .word 48870 + .word 40943 + .word 4231 + .word 0 + .word 0 + .word 0 + .word 9936 + .word 42731 + .word 4198 + .word 0 + .word 0 + .word 0 + .word 23430 + .word 43136 + .word 4169 + .word 0 + .word 0 + .word 0 + .word 4700 + .word 55665 + .word 4137 + .word 0 + .word 0 + .word 0 + .word 8056 + .word 40216 + .word 4106 + .word 0 + .word 0 + .word 0 + .word 3716 + .word 45403 + .word 4075 + .word 0 + .word 0 + .word 0 + .word 53440 + .word 49488 + .word 4044 + .word 0 + .word 0 + .word 0 + .word 41776 + .word 50188 + .word 4013 + .word 0 + .word 0 + .word 0 + .word 20994 + .word 64556 + .word 3983 + .word 0 + .word 0 + .word 0 + .word 16252 + .word 60661 + .word 3951 + .word 0 + .word 0 + .word 0 + .word 61252 + .word 65021 + .word 3920 + .word 0 + .word 0 + .word 0 + .word 16236 + .word 43803 + .word 3889 + .word 0 + .word 0 + .word 0 + .word 63064 + .word 35308 + .word 3857 + .word 0 + .word 0 + .word 0 + .word 49096 + .word 39848 + .word 3828 + .word 0 + .word 0 + .word 0 + .word 15680 + .word 48673 + .word 3797 + .word 0 + .word 0 + .word 0 + .word 48068 + .word 50957 + .word 3766 + .word 0 + .word 0 + .word 0 + .word 20824 + .word 56086 + .word 3734 + .word 0 + .word 0 + .word 0 + .word 46504 + .word 43224 + .word 3704 + .word 0 + .word 0 + .word 0 + .word 52428 + .word 46094 + .word 3672 + .word 0 + .word 0 + .word 0 + .word 17548 + .word 52066 + .word 3642 + .word 0 + .word 0 + .word 0 + .word 61738 + .word 35565 + .word 3611 + .word 0 + .word 0 + .word 0 + .word 31184 + .word 50588 + .word 3579 + .word 0 + .word 0 + .word 0 + .word 1716 + .word 52681 + .word 3549 + .word 0 + .word 0 + .word 0 + .word 44656 + .word 43385 + .word 3518 + .word 0 + .word 0 + .word 0 + .word 12668 + .word 43259 + .word 3486 + .word 0 + .word 0 + .word 0 + .word 24544 + .word 35408 + .word 3453 + .word 0 + .word 0 + .word 0 + .word 28854 + .word 65018 + .word 3425 + .word 0 + .word 0 + .word 0 + .word 5696 + .word 40391 + .word 3393 + .word 0 + .word 0 + .word 0 + .word 39580 + .word 56400 + .word 3363 + .word 0 + .word 0 + .word 0 + .word 20428 + .word 39579 + .word 3332 + .word 0 + .word 0 + .word 0 + .word 32328 + .word 36727 + .word 3301 + .word 0 + .word 0 + .word 0 + .word 34020 + .word 54457 + .word 3270 + .word 0 + .word 0 + .word 0 + .word 34016 + .word 48400 + .word 3238 + .word 0 + .word 0 + .word 0 + .word 6922 + .word 51417 + .word 3208 + .word 0 + .word 0 + .word 0 + .word 27208 + .word 64641 + .word 3176 + .word 0 + .word 0 + .word 0 + .word 1802 + .word 48886 + .word 3146 + .word 0 + .word 0 + .word 0 + .word 35440 + .word 61590 + .word 3115 + .word 0 + .word 0 + .word 0 + .word 60610 + .word 51604 + .word 3084 + .word 0 + .word 0 + .word 0 + .word 5440 + .word 38199 + .word 3050 + .word 0 + .word 0 + .word 0 + .word 6914 + .word 43867 + .word 3022 + .word 0 + .word 0 + .word 0 + .word 24000 + .word 45256 + .word 2989 + .word 0 + .word 0 + .word 0 + .word 51496 + .word 57396 + .word 2959 + .word 0 + .word 0 + .word 0 + .word 11538 + .word 46256 + .word 2929 + .word 0 + .word 0 + .word 0 + .word 36802 + .word 48020 + .word 2898 + .word 0 + .word 0 + .word 0 + .word 57910 + .word 57903 + .word 2867 + .word 0 + .word 0 + .word 0 + .word 47484 + .word 48798 + .word 2835 + .word 0 + .word 0 + .word 0 + .word 57766 + .word 57709 + .word 2805 + .word 0 + .word 0 + .word 0 + .word 54064 + .word 47856 + .word 2774 + .word 0 + .word 0 + .word 0 + .word 49340 + .word 48080 + .word 2743 + .word 0 + .word 0 + .word 0 + .word 36454 + .word 56731 + .word 2712 + .word 0 + .word 0 + .word 0 + .word 51548 + .word 63385 + .word 2681 + .word 0 + .word 0 + .word 0 + .word 56000 + .word 48716 + .word 2645 + .word 0 + .word 0 + .word 0 + .word 44992 + .word 50040 + .word 2615 + .word 0 + .word 0 + .word 0 + .word 43136 + .word 58177 + .word 2585 + .word 0 + .word 0 + .word 0 + .word 49730 + .word 33270 + .word 2557 + .word 0 + .word 0 + .word 0 + .word 29808 + .word 51063 + .word 2526 + .word 0 + .word 0 + .word 0 + .word 25276 + .word 46724 + .word 2494 + .word 0 + .word 0 + .word 0 + .word 17324 + .word 35928 + .word 2463 + .word 0 + .word 0 + .word 0 + .word 52284 + .word 63916 + .word 2433 + .word 0 + .word 0 + .word 0 + .word 5414 + .word 46704 + .word 2402 + .word 0 + .word 0 + .word 0 + .word 51710 + .word 57168 + .word 2371 + .word 0 + .word 0 + .word 0 + .word 27366 + .word 49253 + .word 2340 + .word 0 + .word 0 + .word 0 + .word 45332 + .word 53033 + .word 2309 + .word 0 + .word 0 + .word 0 + .word 54152 + .word 37418 + .word 2276 + .word 0 + .word 0 + .word 0 + .word 53076 + .word 47398 + .word 2247 + .word 0 + .word 0 + .word 0 + .word 14374 + .word 59477 + .word 2216 + .word 0 + .word 0 + .word 0 + .word 59336 + .word 33435 + .word 2184 + .word 0 + .word 0 + .word 0 + .word 21612 + .word 43267 + .word 2154 + .word 0 + .word 0 + .word 0 + .word 34664 + .word 39372 + .word 2121 + .word 0 + .word 0 + .word 0 + .word 172 + .word 62761 + .word 2091 + .word 0 + .word 0 + .word 0 + .word 9816 + .word 40715 + .word 2060 + .word 0 + .word 0 + .word 0 + .word 65116 + .word 40481 + .word 2030 + .word 0 + .word 0 + .word 0 + .word 28066 + .word 39184 + .word 1999 + .word 0 + .word 0 + .word 0 + .word 37408 + .word 63923 + .word 1968 + .word 0 + .word 0 + .word 0 + .word 15760 + .word 42305 + .word 1937 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 59340 + .word 1905 + .word 0 + .word 0 + .word 0 + .word 43258 + .word 59402 + .word 1875 + .word 0 + .word 0 + .word 0 + .word 19988 + .word 50087 + .word 1844 + .word 0 + .word 0 + .word 0 + .word 63456 + .word 47833 + .word 1810 + .word 0 + .word 0 + .word 0 + .word 65184 + .word 61426 + .word 1781 + .word 0 + .word 0 + .word 0 + .word 52982 + .word 48456 + .word 1751 + .word 0 + .word 0 + .word 0 + .word 30020 + .word 62809 + .word 1719 + .word 0 + .word 0 + .word 0 + .word 9096 + .word 63061 + .word 1688 + .word 0 + .word 0 + .word 0 + .word 59648 + .word 44374 + .word 1654 + .word 0 + .word 0 + .word 0 + .word 11456 + .word 33847 + .word 1625 + .word 0 + .word 0 + .word 0 + .word 12392 + .word 50500 + .word 1595 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 59196 + .word 1563 + .word 0 + .word 0 + .word 0 + .word 61008 + .word 40265 + .word 1532 + .word 0 + .word 0 + .word 0 + .word 37842 + .word 33270 + .word 1503 + .word 0 + .word 0 + .word 0 + .word 37916 + .word 44543 + .word 1471 + .word 0 + .word 0 + .word 0 + .word 11490 + .word 36421 + .word 1441 + .word 0 + .word 0 + .word 0 + .word 19040 + .word 38397 + .word 1409 + .word 0 + .word 0 + .word 0 + .word 31224 + .word 47162 + .word 1379 + .word 0 + .word 0 + .word 0 + .word 52056 + .word 41461 + .word 1347 + .word 0 + .word 0 + .word 0 + .word 10810 + .word 56374 + .word 1317 + .word 0 + .word 0 + .word 0 + .word 5358 + .word 35086 + .word 1286 + .word 0 + .word 0 + .word 0 + .word 36640 + .word 50226 + .word 1251 + .word 0 + .word 0 + .word 0 + .word 33856 + .word 45597 + .word 1222 + .word 0 + .word 0 + .word 0 + .word 21552 + .word 63128 + .word 1191 + .word 0 + .word 0 + .word 0 + .word 1198 + .word 35616 + .word 1162 + .word 0 + .word 0 + .word 0 + .word 1232 + .word 59506 + .word 1131 + .word 0 + .word 0 + .word 0 + .word 51086 + .word 34963 + .word 1100 + .word 0 + .word 0 + .word 0 + .word 3960 + .word 39061 + .word 1067 + .word 0 + .word 0 + .word 0 + .word 4564 + .word 57134 + .word 1037 + .word 0 + .word 0 + .word 0 + .word 59468 + .word 35285 + .word 1007 + .word 0 + .word 0 + .word 0 + .word 63422 + .word 35431 + .word 976 + .word 0 + .word 0 + .word 0 + .word 38352 + .word 51462 + .word 945 + .word 0 + .word 0 + .word 0 + .word 25806 + .word 55660 + .word 914 + .word 0 + .word 0 + .word 0 + .word 38842 + .word 41327 + .word 883 + .word 0 + .word 0 + .word 0 + .word 17980 + .word 50458 + .word 852 + .word 0 + .word 0 + .word 0 + .word 61194 + .word 59710 + .word 821 + .word 0 + .word 0 + .word 0 + .word 21098 + .word 42086 + .word 790 + .word 0 + .word 0 + .word 0 + .word 16704 + .word 43341 + .word 757 + .word 0 + .word 0 + .word 0 + .word 46316 + .word 52840 + .word 728 + .word 0 + .word 0 + .word 0 + .word 20386 + .word 33936 + .word 697 + .word 0 + .word 0 + .word 0 + .word 20064 + .word 51864 + .word 664 + .word 0 + .word 0 + .word 0 + .word 2268 + .word 57500 + .word 634 + .word 0 + .word 0 + .word 0 + .word 11152 + .word 51171 + .word 604 + .word 0 + .word 0 + .word 0 + .word 23164 + .word 63727 + .word 572 + .word 0 + .word 0 + .word 0 + .word 20514 + .word 40280 + .word 542 + .word 0 + .word 0 + .word 0 + .word 21818 + .word 57922 + .word 511 + .word 0 + .word 0 + .word 0 + .word 32366 + .word 46413 + .word 480 + .word 0 + .word 0 + .word 0 + .word 53972 + .word 43148 + .word 449 + .word 0 + .word 0 + .word 0 + .word 30134 + .word 65133 + .word 418 + .word 0 + .word 0 + .word 0 + .word 15282 + .word 61516 + .word 387 + .word 0 + .word 0 + .word 0 + .word 49872 + .word 49222 + .word 355 + .word 0 + .word 0 + .word 0 + .word 9484 + .word 63958 + .word 325 + .word 0 + .word 0 + .word 0 + .word 47028 + .word 35341 + .word 294 + .word 0 + .word 0 + .word 0 + .word 6770 + .word 58613 + .word 263 + .word 0 + .word 0 + .word 0 + .word 33372 + .word 43448 + .word 232 + .word 0 + .word 0 + .word 0 + .word 27792 + .word 51629 + .word 198 + .word 0 + .word 0 + .word 0 + .word 19712 + .word 53691 + .word 170 + .word 0 + .word 0 + .word 0 + .word 42144 + .word 60929 + .word 135 + .word 0 + .word 0 + .word 0 + .word 35240 + .word 48799 + .word 107 + .word 0 + .word 0 + .word 0 + .word 910 + .word 51212 + .word 77 + .word 0 + .word 0 + .word 0 + .word 65062 + .word 33668 + .word 46 + .word 0 + .word 0 + .word 0 + .word 52624 + .word 51799 + .word 14 + .word 0 + .type __4onpi_31l,@object + .size __4onpi_31l,6444 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_scalbl_k80.S b/external/sgx_libm/ia32/libm_scalbl_k80.S new file mode 100644 index 0000000000..72e69a7f51 --- /dev/null +++ b/external/sgx_libm/ia32/libm_scalbl_k80.S @@ -0,0 +1,264 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_scalbl_k80.c" + .text +..TXTST0: +# -- Begin __libm_scalbl_k80 + .text + .align 16,0x90 + .hidden __libm_scalbl_k80 + .globl __libm_scalbl_k80 +__libm_scalbl_k80: +# parameter 1: 48 + %esp +# parameter 2: 60 + %esp +# parameter 3: 72 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %ebx + subl $36, %esp + fldt 60(%esp) + fldt 48(%esp) + fld %st(0) + movl 72(%esp), %ebx + fadd %st(2), %st + cmpl $0, 52(%esp) + jne ..B1.4 +..B1.2: + cmpl $0, 48(%esp) + jne ..B1.4 +..B1.3: + fstp %st(2) + fstp %st(1) + fstpt 24(%esp) + fldt 24(%esp) + addl $36, %esp + popl %ebx + popl %esi + ret +..B1.4: + movzwl 56(%esp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.3 +..B1.5: + fstpt 24(%esp) + fldt 24(%esp) + movzwl 32(%esp), %esi + movl %esi, %edx + andl $32767, %edx + lea -1(%ebx,%edx), %ecx + cmpl $32765, %ecx + lea (%ebx,%edx), %eax + ja ..B1.7 +..B1.6: + fstp %st(1) + fstp %st(1) + fstp %st(0) + andl $-32768, %esi + andl $32767, %eax + orl %eax, %esi + movw %si, 32(%esp) + fldt 24(%esp) + addl $36, %esp + popl %ebx + popl %esi + ret +..B1.7: + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $32766, %eax + jle ..B1.9 +..B1.8: + fstp %st(2) + fstp %st(1) + fldt _CONSTANTS@GOTOFF(%ecx) + fmul %st(0), %st + fmulp %st, %st(1) + fstpt 24(%esp) + fldt 24(%esp) + addl $36, %esp + popl %ebx + popl %esi + ret +..B1.9: + cmpl $-63, %eax + fldt 12+_CONSTANTS@GOTOFF(%ecx) + jge ..B1.11 +..B1.10: + fstp %st(3) + fstp %st(0) + fxch %st(1) + fmul %st(0), %st + fmulp %st, %st(1) + fstpt 24(%esp) + fldt 24(%esp) + addl $36, %esp + popl %ebx + popl %esi + ret +..B1.11: + cmpl $-19, %eax + jge ..B1.13 +..B1.12: + fstp %st(2) + fstp %st(2) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + movzwl 8+.L_2il0floatpacket.0@GOTOFF(%ecx), %eax + andl $-32768, %eax + fstpt (%esp) + fmul %st(0), %st + faddp %st, %st(1) + fstpt 24(%esp) + movzwl 32(%esp), %edx + lea 256(%ebx,%edx), %ebx + andl $-32768, %edx + andl $32767, %ebx + orl $-49409, %edx + orl %ebx, %eax + movw %ax, 8(%esp) + fldt (%esp) + movw %dx, 32(%esp) + fldt 24(%esp) + fmulp %st, %st(1) + fstpt 24(%esp) + fldt 24(%esp) + addl $36, %esp + popl %ebx + popl %esi + ret +..B1.13: + fstp %st(1) + fldt 24+_CONSTANTS@GOTOFF(%ecx) + fxch %st(1) + fmul %st(0), %st + movzwl 8+.L_2il0floatpacket.0@GOTOFF(%ecx), %eax + faddp %st, %st(2) + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + andl $-32768, %eax + fmul %st(2), %st + fld %st(0) + fsub %st(3), %st + fsubrp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fsubrp %st, %st(2) + movzwl 20(%esp), %edx + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + lea -16383(%edx), %esi + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + negl %esi + addl $16383, %esi + lea -32512(%ebx,%edx), %ecx + andl $32767, %esi + andl $32767, %ecx + fstpt (%esp) + orl %esi, %eax + movw %ax, 8(%esp) + movl %edx, %esi + fldt (%esp) + andl $-32768, %esi + fmulp %st, %st(1) + andl $-32768, %eax + orl $-49409, %esi + orl %ecx, %eax + movw %si, 20(%esp) + fldt 12(%esp) + movw %ax, 8(%esp) + fldt (%esp) + fmul %st, %st(1) + fxch %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 24(%esp) + fldt 24(%esp) +..B1.14: + addl $36, %esp + popl %ebx + popl %esi + ret + .align 16,0x90 + .type __libm_scalbl_k80,@function + .size __libm_scalbl_k80,.-__libm_scalbl_k80 + .data +# -- End __libm_scalbl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16127 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,36 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_sincos_huge.S b/external/sgx_libm/ia32/libm_sincos_huge.S new file mode 100644 index 0000000000..b25c4d96b5 --- /dev/null +++ b/external/sgx_libm/ia32/libm_sincos_huge.S @@ -0,0 +1,708 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sincos_huge.c" + .text +..TXTST0: +# -- Begin __libm_sincos_huge + .text + .align 16,0x90 + .hidden __libm_sincos_huge + .globl __libm_sincos_huge +__libm_sincos_huge: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + movl 16(%ebp), %eax + movl 20(%ebp), %edx + movl %eax, 16(%esp) + movl %edx, 20(%esp) + movl %gs:20, %ecx + xorl %esp, %ecx + movl %ecx, 40(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + fldl 8(%ebp) + movl 12(%ebp), %edi + movl %edi, %eax + andl $2147483647, %eax + fabs + shrl $31, %edi + movl %eax, 24(%esp) + cmpl $1104150528, %eax + fstl 8(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jae ..B1.14 +..B1.4: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + fldl _Pi4Inv@GOTOFF(%ebx) + fmul %st(1), %st + fstpl (%esp) + je ..B1.52 +..B1.5: + fstp %st(0) + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.6: + fldcw 12(%esp) +..B1.7: + fldl 8(%ebp) + movl $1, %esi +..B1.8: + movl (%esp), %eax + movl 4(%esp), %edx + movl %edx, %ecx + movl %eax, 8(%esp) + movl %edx, %eax + andl $1048575, %eax + shrl $20, %ecx + orl $1048576, %eax + cmpl $1094713344, %edx + jae ..B1.10 +..B1.9: + negl %ecx + addl $19, %ecx + shrl %cl, %eax + jmp ..B1.11 +..B1.10: + movl %ecx, %edx + lea 13(%edx), %ecx + negl %edx + addl $19, %edx + shll %cl, %eax + movl %edx, %ecx + movl 8(%esp), %edx + shrl %cl, %edx + orl %edx, %eax +..B1.11: + lea 1(%eax), %edx + movl %edx, %ecx + andl $-2, %ecx + movl %ecx, (%esp) + fildl (%esp) + cmpl $1094713344, 24(%esp) + jae ..B1.13 +..B1.12: + fldl _Pi4x3@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(2) + fldl 8+_Pi4x3@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(2) + fldl 16+_Pi4x3@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(1) + jmp ..B1.20 +..B1.13: + fldl _Pi4x4@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(2) + fldl 8+_Pi4x4@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(2) + fldl 16+_Pi4x4@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(2) + fldl 24+_Pi4x4@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(1) + jmp ..B1.20 +..B1.14: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.60 +..B1.15: + fstp %st(0) + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.16: + fldcw 12(%esp) +..B1.17: + fldl 8(%ebp) + movl $1, %esi +..B1.18: + addl $-32, %esp + lea 56(%esp), %eax + fstpt (%esp) + movl $0, 12(%esp) + movl %eax, 16(%esp) + call __libm_reduce_pi04l +..B1.63: + addl $32, %esp +..B1.19: + fldl 24(%esp) + lea 1(%eax), %edx + faddl 32(%esp) +..B1.20: + movl %edx, %ecx + addl $3, %eax + shrl $2, %ecx + andl $1, %ecx + shrl $2, %eax + xorl %ecx, %edi + movl 20(%esp), %ecx + andl $1, %eax + andl $3, %ecx + cmpl $3, %ecx + jne ..B1.30 +..B1.21: + fldt 84+_SP@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + testb $2, %dl + fmul %st, %st(1) + fldt 72+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 60+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 84+_CP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 72+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldl _ones@GOTOFF(%ebx,%edi,8) + fldl _ones@GOTOFF(%ebx,%eax,8) + je ..B1.26 +..B1.22: + fmulp %st, %st(4) + testl %esi, %esi + fxch %st(2) + fmul %st(3), %st + movl 16(%esp), %eax + faddp %st, %st(3) + fxch %st(2) + fstpl (%eax) + fmul %st, %st(1) + faddp %st, %st(1) + fstpl 8(%eax) + je ..B1.24 +..B1.23: + fldcw 14(%esp) +..B1.24: + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.53 +..B1.25: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + fxch %st(1) + fmulp %st, %st(4) + testl %esi, %esi + fxch %st(2) + fmul %st(3), %st + movl 16(%esp), %eax + faddp %st, %st(3) + fxch %st(2) + fstpl 8(%eax) + fmul %st, %st(1) + faddp %st, %st(1) + fstpl (%eax) + je ..B1.28 +..B1.27: + fldcw 14(%esp) +..B1.28: + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.53 +..B1.29: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.30: + testb $2, 20(%esp) + je ..B1.40 +..B1.31: + fld %st(0) + testb $2, %dl + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + je ..B1.36 +..B1.32: + fstp %st(2) + fldt 84+_CP@GOTOFF(%ebx) + testl %esi, %esi + fmul %st(2), %st + fldt 72+_CP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 60+_CP@GOTOFF(%ebx) + movl 16(%esp), %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl _ones@GOTOFF(%ebx,%edi,8) + fmul %st, %st(1) + faddp %st, %st(1) + fstpl 8(%eax) + je ..B1.34 +..B1.33: + fldcw 14(%esp) +..B1.34: + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.53 +..B1.35: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.36: + fldt 84+_SP@GOTOFF(%ebx) + testl %esi, %esi + fmul %st(1), %st + fxch %st(3) + fmull _ones@GOTOFF(%ebx,%edi,8) + fldt 72+_SP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 60+_SP@GOTOFF(%ebx) + movl 16(%esp), %eax + faddp %st, %st(5) + fxch %st(2) + fmul %st, %st(4) + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(5) + fmul %st, %st(4) + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(5) + fmulp %st, %st(4) + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + faddp %st, %st(1) + fstpl 8(%eax) + je ..B1.38 +..B1.37: + fldcw 14(%esp) +..B1.38: + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.53 +..B1.39: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.40: + testb $1, 20(%esp) + je ..B1.50 +..B1.41: + fld %st(0) + testb $2, %dl + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + je ..B1.46 +..B1.42: + fldt 84+_SP@GOTOFF(%ebx) + testl %esi, %esi + fmul %st(1), %st + fxch %st(3) + fmull _ones@GOTOFF(%ebx,%eax,8) + fldt 72+_SP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 60+_SP@GOTOFF(%ebx) + movl 16(%esp), %eax + faddp %st, %st(5) + fxch %st(2) + fmul %st, %st(4) + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(5) + fmul %st, %st(4) + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(5) + fmulp %st, %st(4) + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(1) + faddp %st, %st(1) + fstpl (%eax) + je ..B1.44 +..B1.43: + fldcw 14(%esp) +..B1.44: + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.53 +..B1.45: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + fstp %st(2) + fldt 84+_CP@GOTOFF(%ebx) + testl %esi, %esi + fmul %st(2), %st + fldt 72+_CP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 60+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl _ones@GOTOFF(%ebx,%eax,8) + fmul %st, %st(1) + movl 16(%esp), %eax + faddp %st, %st(1) + fstpl (%eax) + je ..B1.48 +..B1.47: + fldcw 14(%esp) +..B1.48: + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.53 +..B1.49: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.50: + fstp %st(0) + movl 40(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.53 +..B1.51: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.52: + xorl %esi, %esi + jmp ..B1.8 +..B1.53: + call __stack_chk_fail@PLT +..B1.60: + xorl %esi, %esi + jmp ..B1.18 + .align 16,0x90 + .type __libm_sincos_huge,@function + .size __libm_sincos_huge,.-__libm_sincos_huge + .data +# -- End __libm_sincos_huge + .section .rodata, "a" + .align 16 + .align 16 +_Pi4Inv: + .long 1841940611 + .long 1072979760 + .type _Pi4Inv,@object + .size _Pi4Inv,8 + .space 8, 0x00 # pad + .align 16 +_Pi4x3: + .long 1413754880 + .long 3219726843 + .long 993632256 + .long 1027030475 + .long 3773204808 + .long 3129236486 + .type _Pi4x3,@object + .size _Pi4x3,24 + .space 8, 0x00 # pad + .align 16 +_Pi4x4: + .long 1413480448 + .long 3219726843 + .long 442499072 + .long 3183522913 + .long 771751936 + .long 3146979722 + .long 622873025 + .long 3110831002 + .type _Pi4x4,@object + .size _Pi4x4,32 + .align 16 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 34951 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 50471 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 17910 + .word 46614 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 33371 + .word 14743 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 48947 + .word 35764 + .word 12250 + .word 45202 + .word 16350 + .word 0 + .word 17574 + .word 60698 + .word 10735 + .word 55102 + .word 49110 + .word 0 + .word 34320 + .word 12415 + .word 25249 + .word 51489 + .word 16334 + .word 0 + .type _SP,@object + .size _SP,96 + .align 16 +_CP: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 39983 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 61476 + .word 3244 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 1022 + .word 16229 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 55373 + .word 44526 + .word 50840 + .word 36726 + .word 16354 + .word 0 + .word 55994 + .word 65145 + .word 59958 + .word 51657 + .word 49114 + .word 0 + .word 15046 + .word 2976 + .word 1998 + .word 54661 + .word 16338 + .word 0 + .type _CP,@object + .size _CP,96 + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_sincos_k32.S b/external/sgx_libm/ia32/libm_sincos_k32.S new file mode 100644 index 0000000000..25e11ef7ed --- /dev/null +++ b/external/sgx_libm/ia32/libm_sincos_k32.S @@ -0,0 +1,337 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sincos_k32.c" + .text +..TXTST0: +# -- Begin __libm_sincos_k32 + .text + .align 16,0x90 + .hidden __libm_sincos_k32 + .globl __libm_sincos_k32 +__libm_sincos_k32: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 20 + %ebp +# parameter 4: 24 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + fldl 8(%ebp) + movl 12(%ebp), %edi + movl %edi, %edx + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + andl $2147483647, %edx + fabs + shrl $31, %edi + movl 24(%ebp), %ecx + movl 16(%ebp), %eax + movl 20(%ebp), %ebx + imull iones@GOTOFF(%esi,%edi,4), %ecx + movl %eax, 36(%esp) + cmpl $1103101952, %edx + jae ..B1.9 +..B1.2: + cmpl $1073283072, %edx + ja ..B1.6 +..B1.3: + incl %ecx + movl %ecx, %edx + andl $2, %edx + je ..B1.5 +..B1.4: + fsubl .L_2il0floatpacket.0@GOTOFF(%esi) + fstl 8(%ebp) + jmp ..B1.11 +..B1.5: + fstl 8(%ebp) + jmp ..B1.11 +..B1.6: + fldl _INV_PI04@GOTOFF(%esi) + fmul %st(1), %st + movl %edi, 32(%esp) + fxch %st(1) + fstl 8(%ebp) + fldl _TWO_52H@GOTOFF(%esi) + fadd %st(2), %st + fstpl 16(%esp) + fildl 16(%esp) + movl 16(%esp), %edi + fcomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + movl $1, %eax + ja ..L3 + movl $0, %eax +..L3: + subl %eax, %edi + addl %edi, %ecx + movl %ecx, %eax + andl $1, %eax + addl %eax, %edi + addl %eax, %ecx + movl %edi, 24(%esp) + cmpl $1090519040, %edx + fildl 24(%esp) + movl 32(%esp), %edi + jae ..B1.8 +..B1.7: + fldl _DP2@GOTOFF(%esi) + movl %ecx, %edx + fmul %st(1), %st + andl $2, %edx + fsubrp %st, %st(2) + fldl 8+_DP2@GOTOFF(%esi) + fmul %st(1), %st + fsubrp %st, %st(2) + fldl 16+_DP2@GOTOFF(%esi) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstl 8(%ebp) + jmp ..B1.11 +..B1.8: + fstp %st(1) + fldl _DP3@GOTOFF(%esi) + movl %ecx, %edx + fmul %st(1), %st + andl $2, %edx + fldl 8+_DP3@GOTOFF(%esi) + fmul %st(2), %st + fxch %st(1) + fsubrl 8(%ebp) + fsubp %st, %st(1) + fldl 16+_DP3@GOTOFF(%esi) + fmul %st(2), %st + fsubrp %st, %st(1) + fldl 24+_DP3@GOTOFF(%esi) + fmulp %st, %st(2) + fsubp %st, %st(1) + fstl 8(%ebp) + jmp ..B1.11 +..B1.9: + fstl (%esp) + lea 8(%ebp), %eax + movl %eax, 8(%esp) + fstpl (%eax) + movl %ecx, 12(%esp) + call __libm_reduce_pi04d +..B1.17: + movl %eax, %ecx +..B1.10: + fldl 8(%ebp) + incl %ecx + movl %ecx, %edx + andl $2, %edx +..B1.11: + fldl 24+_CP@GOTOFF(%esi) + fld %st(1) + fmul %st(2), %st + lea 2(%ecx), %eax + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fld1 + fxch %st(3) + faddl 8+_CP@GOTOFF(%esi) + fmul %st(1), %st + shrl $2, %ecx + faddp %st, %st(3) + fldl 32+_CP@GOTOFF(%esi) + andl $1, %ecx + fmul %st(1), %st + xorl %ecx, %edi + fldl 24+_SP@GOTOFF(%esi) + fmul %st(2), %st + fxch %st(1) + faddl 16+_CP@GOTOFF(%esi) + fmul %st(2), %st + fxch %st(1) + faddl 8+_SP@GOTOFF(%esi) + fmul %st(2), %st + fmul %st(5), %st + shrl $2, %eax + fadd %st(5), %st + fxch %st(1) + faddl _CP@GOTOFF(%esi) + fmul %st(3), %st + andl $1, %eax + testl %edx, %edx + faddp %st, %st(4) + fldl 32+_SP@GOTOFF(%esi) + fmul %st(2), %st + faddl 16+_SP@GOTOFF(%esi) + fmulp %st, %st(2) + fxch %st(1) + faddl _SP@GOTOFF(%esi) + fmulp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fldl ones@GOTOFF(%esi,%edi,8) + je ..B1.13 +..B1.12: + fxch %st(2) + fmull ones@GOTOFF(%esi,%eax,8) + fxch %st(2) + fmulp %st, %st(1) + movl 36(%esp), %edx + fstpl (%edx) + fstpl (%ebx) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + fxch %st(1) + fmull ones@GOTOFF(%esi,%eax,8) + fxch %st(2) + fmulp %st, %st(1) + movl 36(%esp), %edx + fstpl (%edx) + fstpl (%ebx) +..B1.14: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __libm_sincos_k32,@function + .size __libm_sincos_k32,.-__libm_sincos_k32 + .data +# -- End __libm_sincos_k32 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x54442d18,0x3fe921fb + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_INV_PI04: + .long 1841940611 + .long 1072979760 + .type _INV_PI04,@object + .size _INV_PI04,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_DP2: + .long 1413742592 + .long 1072243195 + .long 1279262720 + .long 1031179299 + .long 1880851354 + .long 996723793 + .type _DP2,@object + .size _DP2,24 + .align 4 +_DP3: + .long 1073741824 + .long 1072243195 + .long 0 + .long 1046758445 + .long 2147483648 + .long 1021855384 + .long 1880851354 + .long 996723793 + .type _DP3,@object + .size _DP3,32 + .align 4 +_CP: + .long 4294960802 + .long 3219128319 + .long 1427442001 + .long 1067799893 + .long 2926645240 + .long 3210133867 + .long 2571283200 + .long 1056571689 + .long 2069816734 + .long 3197257552 + .type _CP,@object + .size _CP,40 + .align 4 +_SP: + .long 1431654765 + .long 3217380693 + .long 285032968 + .long 1065423121 + .long 3653044354 + .long 3207201183 + .long 2777006020 + .long 1053236634 + .long 43514947 + .long 3193610888 + .type _SP,@object + .size _SP,40 + .data + .hidden __libm_reduce_pi04d + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_sinhl_k80.S b/external/sgx_libm/ia32/libm_sinhl_k80.S new file mode 100644 index 0000000000..b429851799 --- /dev/null +++ b/external/sgx_libm/ia32/libm_sinhl_k80.S @@ -0,0 +1,723 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sinhl_k80.c" + .text +..TXTST0: +# -- Begin __libm_sinhl_k80 + .text + .align 16,0x90 + .hidden __libm_sinhl_k80 + .globl __libm_sinhl_k80 +__libm_sinhl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp + movzwl 16(%ebp), %eax + andl $32767, %eax + movl 20(%ebp), %ebx + cmpl $16405, %eax + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + jge ..B1.17 +..B1.2: + cmpl $16382, %eax + jge ..B1.13 +..B1.3: + fldt 8(%ebp) + cmpl $16378, %eax + jge ..B1.11 +..B1.4: + cmpl $16373, %eax + jge ..B1.10 +..B1.5: + cmpl $16366, %eax + jge ..B1.9 +..B1.6: + fstpt (%ebx) + fldt (%ebx) + cmpl $16308, %eax + jge ..B1.8 +..B1.7: + fstp %st(0) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + fstpt 12(%ebx) + fldt 12(%ebx) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.8: + fldt _Q3@GOTOFF(%esi) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + fldt 12+_Q2@GOTOFF(%esi) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fxch %st(2) + fstpt (%ebx) + fldt (%ebx) + fldt _Q2@GOTOFF(%esi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.10: + fldt 36+_Q1@GOTOFF(%esi) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(3) + fstpt (%ebx) + fldt (%ebx) + fldt 12+_Q1@GOTOFF(%esi) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 24+_Q1@GOTOFF(%esi) + fmulp %st, %st(4) + fldt _Q1@GOTOFF(%esi) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + fldl _TWO_48H@GOTOFF(%esi) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fld %st(3) + fadd %st(3), %st + fstpt 72(%esp) + fxch %st(3) + fstpt (%esp) + fldt (%esp) + fldt 72(%esp) + fsubp %st, %st(3) + fld %st(2) + fld %st(1) + fsub %st(4), %st + fmul %st, %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(3) + fstpt 16(%esp) + fldt 16(%esp) + fmul %st(0), %st + fldt 84+_Q@GOTOFF(%esi) + fmul %st(5), %st + fldt 60+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(5), %st + fldt 36+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(5), %st + fldt 12+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(5), %st + fldt 72+_Q@GOTOFF(%esi) + fmul %st(6), %st + fldt 48+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(6), %st + fldt 24+_Q@GOTOFF(%esi) + faddp %st, %st(1) + fmulp %st, %st(6) + fldt _Q@GOTOFF(%esi) + faddp %st, %st(6) + fxch %st(3) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(2) + fld %st(0) + fldt 96+_Q@GOTOFF(%esi) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(2) + fmul %st(3), %st + fldt (%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 16(%esp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fstpt (%ebx) + fldt (%ebx) + fsubrp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 12(%ebx) + fldt .L_2il0floatpacket.0@GOTOFF(%esi) +..B1.12: + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%esi) + fldt _KLN2@GOTOFF(%esi) + fldt _LN2K@GOTOFF(%esi) + fldl _TWO_32@GOTOFF(%esi) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl ones@GOTOFF(%esi,%eax,8) + fmul %st, %st(5) + fxch %st(3) + fmul %st(5), %st + fadd %st(4), %st + fstpt 72(%esp) + fxch %st(4) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 72(%esp) + movl 72(%esp), %eax + fsubp %st, %st(4) + fxch %st(1) + fmul %st(3), %st + movsbl %al, %ecx + fsubrp %st, %st(1) + fld %st(0) + subl %ecx, %eax + fldt 12+_LN2K@GOTOFF(%esi) + fmulp %st, %st(4) + movzwl 16(%ebp), %edx + fsub %st(3), %st + fldl _TWO_32P@GOTOFF(%esi) + andl $32767, %edx + fmul %st(1), %st + fxch %st(5) + fmulp %st, %st(1) + sarl $8, %eax + fsubrp %st, %st(4) + fld %st(3) + cmpl $16387, %edx + fxch %st(1) + fsub %st(4), %st + fsubp %st, %st(3) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%esi) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(1), %st + fldt _P@GOTOFF(%esi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%esi) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%esi) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + jle ..B1.15 +..B1.14: + shll $4, %ecx + decl %eax + movl %eax, 64(%esp) + faddp %st, %st(2) + fildl 64(%esp) + fldl 2056+__libm_expl_table_256@GOTOFF(%esi,%ecx) + fldl 2048+__libm_expl_table_256@GOTOFF(%esi,%ecx) + fld %st(0) + fmul %st(5), %st + fxch %st(5) + fadd %st(6), %st + fmul %st(2), %st + faddp %st, %st(5) + fmul %st, %st(5) + fld %st(0) + fadd %st(6), %st + fsubr %st, %st(1) + fxch %st(6) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fstpt (%ebx) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%ebx) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + je ..B1.20 +..B1.16: + fldt .L_2il0floatpacket.1@GOTOFF(%esi) + lea -1(%eax), %edi + shll $4, %ecx + fstpt (%esp) + fld %st(0) + movl %edi, 64(%esp) + movl %eax, %edi + negl %edi + fadd %st(3), %st + fxch %st(3) + fsubrp %st, %st(1) + fxch %st(1) + fstpt 16(%esp) + fld %st(2) + fldl 2056+__libm_expl_table_256@GOTOFF(%esi,%ecx) + addl $16383, %edi + fldl 2048+__libm_expl_table_256@GOTOFF(%esi,%ecx) + negl %ecx + fstpt 32(%esp) + fldt 32(%esp) + subl %eax, %edi + movzwl 8+.L_2il0floatpacket.1@GOTOFF(%esi), %edx + andl $32767, %edi + andl $-32768, %edx + fadd %st(1), %st + fmulp %st, %st(4) + fld %st(4) + fmul %st(1), %st + orl %edi, %edx + faddp %st, %st(4) + fldl 2056+__libm_expl_table_256@GOTOFF(%esi,%ecx) + fldl 2048+__libm_expl_table_256@GOTOFF(%esi,%ecx) + fld %st(0) + movw %dx, 8(%esp) + fadd %st(2), %st + fmulp %st, %st(5) + fld %st(6) + fmul %st(2), %st + fsubrp %st, %st(5) + fxch %st(4) + fstpt 48(%esp) + fxch %st(3) + fmul %st, %st(5) + fldt 32(%esp) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fsub %st(5), %st + fsubr %st, %st(4) + fxch %st(5) + fsubrp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fld %st(0) + fldt 48(%esp) + faddp %st, %st(3) + fldt (%esp) + fmul %st, %st(5) + fxch %st(1) + fsub %st(5), %st + fsubr %st, %st(2) + fxch %st(5) + fsubrp %st, %st(2) + fmulp %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt 16(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt (%ebx) + fmulp %st, %st(1) + fstpt 12(%ebx) + fildl 64(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + cmpl $32767, %eax + je ..B1.23 +..B1.18: + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + lea (,%edx,8), %eax + fstpt 12(%ebx) + lea (%eax,%edx,4), %edx + fldt _infs@GOTOFF(%esi,%edx) + fstpt (%ebx) + fldt _infs@GOTOFF(%esi) +..B1.19: + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.20: + movl 12(%ebp), %edx + cmpl $-782985146, %edx + ja ..B1.14 +..B1.21: + jne ..B1.16 +..B1.22: + cmpl $1501741449, 8(%ebp) + ja ..B1.14 + jmp ..B1.16 +..B1.23: + fldt 8(%ebp) + fstpt (%ebx) + fldt (%ebx) + fmul %st(0), %st + fldt .L_2il0floatpacket.0@GOTOFF(%esi) + fstpt 12(%ebx) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __libm_sinhl_k80,@function + .size __libm_sinhl_k80,.-__libm_sinhl_k80 + .data +# -- End __libm_sinhl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 2 +_Q3: + .word 21845 + .word 44373 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 29491 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 1838 + .word 3745 + .word 35050 + .word 34952 + .word 16376 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 56472 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 6470 + .word 8609 + .word 207 + .word 53261 + .word 16370 + .word 0 + .word 51515 + .word 9159 + .word 10794 + .word 47344 + .word 16364 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 43620 + .word 43690 + .word 43690 + .word 43690 + .word 16364 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 52382 + .word 3328 + .word 208 + .word 53261 + .word 16370 + .word 0 + .word 44665 + .word 46658 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 15678 + .word 35942 + .word 11071 + .word 55090 + .word 16357 + .word 0 + .word 10412 + .word 23121 + .word 12507 + .word 45202 + .word 16350 + .word 0 + .word 37213 + .word 41879 + .word 65084 + .word 55102 + .word 16342 + .word 0 + .word 1721 + .word 42148 + .word 19309 + .word 52099 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16380 + .word 0 + .type _Q,@object + .size _Q,108 + .align 2 +_KLN2: + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 16391 + .word 0 + .type _KLN2,@object + .size _KLN2,12 + .align 2 +_LN2K: + .word 0 + .word 0 + .word 6134 + .word 45426 + .word 16374 + .word 0 + .word 55756 + .word 58609 + .word 48341 + .word 59623 + .word 16343 + .word 0 + .type _LN2K,@object + .size _LN2K,24 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_infs: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 65535 + .word 0 + .type _infs,@object + .size _infs,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_sinl_k80.S b/external/sgx_libm/ia32/libm_sinl_k80.S new file mode 100644 index 0000000000..a1a3c58489 --- /dev/null +++ b/external/sgx_libm/ia32/libm_sinl_k80.S @@ -0,0 +1,676 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sinl_k80.c" + .text +..TXTST0: +# -- Begin __libm_sinl_k80 + .text + .align 16,0x90 + .hidden __libm_sinl_k80 + .globl __libm_sinl_k80 +__libm_sinl_k80: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 144(%esp) + movzwl 16(%ebp), %eax + andl $32767, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $16378, %eax + movl 20(%ebp), %edi + jge ..B1.13 +..B1.2: + fldt 8(%ebp) + cmpl $16372, %eax + jge ..B1.11 +..B1.3: + cmpl $16364, %eax + jge ..B1.9 +..B1.4: + fstpt (%edi) + fldt (%edi) + cmpl $16308, %eax + jge ..B1.6 +..B1.5: + fstp %st(0) + fldl _zeros@GOTOFF(%ebx) + fstpt 12(%edi) + fldl _ones@GOTOFF(%ebx) + jmp ..B1.7 +..B1.6: + fldt _SP3@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 12(%edi) + fldl _ones@GOTOFF(%ebx) +..B1.7: + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.23 +..B1.8: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + fldt 12+_SP2@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fxch %st(2) + fstpt (%edi) + fldt (%edi) + fldt _SP2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fmulp %st, %st(1) + fstpt 12(%edi) + fldl _ones@GOTOFF(%ebx) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.23 +..B1.10: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + fldt 36+_SP1@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(3) + fstpt (%edi) + fldt (%edi) + fldt 12+_SP1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 24+_SP1@GOTOFF(%ebx) + fmulp %st, %st(4) + fldt _SP1@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 12(%edi) + fldl _ones@GOTOFF(%ebx) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.23 +..B1.12: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + cmpl $16382, %eax + jge ..B1.15 +..B1.14: + fldt 8(%ebp) + xorl %edx, %edx + fldl _TWO_52H@GOTOFF(%ebx) + movzbl 17(%ebp), %esi + andl $128, %esi + shrl $7, %esi + fxch %st(1) + fmull _ones@GOTOFF(%ebx,%esi,8) + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt 32(%esp) + fstpt 112(%esp) + fldt 112(%esp) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 32(%esp) + fsubp %st, %st(2) + fld %st(1) + fsubrp %st, %st(1) + jmp ..B1.18 +..B1.15: + je ..B1.27 +..B1.16: + fldt 8(%ebp) + lea 128(%esp), %eax + movzbl 17(%ebp), %esi + andl $128, %esi + shrl $7, %esi + fmull _ones@GOTOFF(%ebx,%esi,8) + fstpt (%esp) + fldt (%esp) + movl $0, 12(%esp) + fstpt 8(%ebp) + movl %eax, 16(%esp) + call __libm_reduce_pi04l +..B1.32: + movl %eax, %edx +..B1.17: + fldl 128(%esp) + lea 1(%edx), %eax + fldl _TWO_52H@GOTOFF(%ebx) + fmul %st(1), %st + fld %st(0) + shrl $2, %eax + fadd %st(2), %st + fstpt 32(%esp) + xorl %eax, %esi + fldt 32(%esp) + andl $1, %esi + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddl 136(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpt 112(%esp) +..B1.18: + fldt 112(%esp) + fld %st(2) + fmul %st(2), %st + fld %st(2) + fmulp %st, %st(2) + incl %edx + faddp %st, %st(1) + fstpt 48(%esp) + fldt 48(%esp) + fld %st(2) + fmul %st(3), %st + testb $2, %dl + fld %st(0) + fadd %st(2), %st + fstpt 80(%esp) + fldt 80(%esp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fmul %st(0), %st + fld %st(0) + faddp %st, %st(2) + fldl _TWO_53H@GOTOFF(%ebx) + je ..B1.20 +..B1.19: + fstp %st(3) + fstp %st(3) + fldt 84+_CP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 60+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_CP@GOTOFF(%ebx) + fldt 96+_CP@GOTOFF(%ebx) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 80(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 64(%esp) + fldt 48(%esp) + fldt 96(%esp) + fldt 120+_CP@GOTOFF(%ebx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(5) + fldt 108+_CP@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fld %st(4) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fadd %st(1), %st + fmul %st, %st(2) + fadd %st(2), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldl _ones@GOTOFF(%ebx) + fld %st(0) + fxch %st(1) + fadd %st, %st(2) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldl _ones@GOTOFF(%ebx,%esi,8) + fmul %st, %st(1) + fxch %st(1) + fstpt (%edi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 12(%edi) + jmp ..B1.21 +..B1.20: + fldt 84+_SP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 60+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_SP@GOTOFF(%ebx) + fldt 96+_SP@GOTOFF(%ebx) + fmul %st(5), %st + faddp %st, %st(1) + fmul %st(4), %st + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(4) + fldt 80(%esp) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt 64(%esp) + fldt 48(%esp) + fldt 120+_SP@GOTOFF(%ebx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(3) + fldt 108+_SP@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fldt 96(%esp) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fmul %st, %st(1) + fadd %st(1), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fmul %st(4), %st + fldt 112(%esp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldl _ones@GOTOFF(%ebx,%esi,8) + fmul %st, %st(2) + fxch %st(2) + fstpt (%edi) + fmulp %st, %st(1) + fstpt 12(%edi) + fldl _ones@GOTOFF(%ebx) +..B1.21: + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.23 +..B1.22: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.27: + movl 12(%ebp), %eax + cmpl $-921707870, %eax + jb ..B1.14 +..B1.28: + jne ..B1.16 +..B1.29: + cmpl $560513589, 8(%ebp) + jbe ..B1.14 + jmp ..B1.16 + .align 16,0x90 + .type __libm_sinl_k80,@function + .size __libm_sinl_k80,.-__libm_sinl_k80 + .data +# -- End __libm_sinl_k80 + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 2 +_SP3: + .word 17476 + .word 43656 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .type _SP3,@object + .size _SP3,12 + .align 2 +_SP2: + .word 43210 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 1587 + .word 57422 + .word 34932 + .word 34952 + .word 16376 + .word 0 + .type _SP2,@object + .size _SP2,24 + .align 2 +_SP1: + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 12518 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 43088 + .word 7396 + .word 207 + .word 53261 + .word 49138 + .word 0 + .word 55827 + .word 48618 + .word 3602 + .word 47342 + .word 16364 + .word 0 + .type _SP1,@object + .size _SP1,48 + .align 2 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .type _CP,@object + .size _CP,132 + .align 2 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .type _SP,@object + .size _SP,132 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_strtoull.S b/external/sgx_libm/ia32/libm_strtoull.S new file mode 100644 index 0000000000..2656daf3b5 --- /dev/null +++ b/external/sgx_libm/ia32/libm_strtoull.S @@ -0,0 +1,1128 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_strtoull.c" + .text +..TXTST0: +# -- Begin __libm_conv_strtoull + .text + .align 16,0x90 + .hidden __libm_conv_strtoull + .globl __libm_conv_strtoull +__libm_conv_strtoull: +# parameter 1: 64 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $44, %esp + movl 64(%esp), %eax + testl %eax, %eax + je ..B1.21 +..B1.2: + movsbl (%eax), %ebx + testl %ebx, %ebx + je ..B1.21 +..B1.3: + xorl %edx, %edx + movl %eax, %ecx +..B1.4: + incl %ecx + incl %edx + cmpb $0, (%ecx) + jne ..B1.4 +..B1.5: + testl %edx, %edx + je ..B1.21 +..B1.6: + lea -48(%ebx), %ebp + cmpl $9, %ebp + ja ..B1.21 +..B1.8: + cmpl $48, %ebx + je ..B1.25 +..B1.9: + cmpl $1, %edx + jle ..B1.14 +..B1.10: + movl $1, %ebx +..B1.11: + movsbl (%ebx,%eax), %ebp + addl $-48, %ebp + cmpl $9, %ebp + ja ..B1.21 +..B1.12: + incl %ebx + cmpl %edx, %ebx + jl ..B1.11 +..B1.14: + cmpl $64, %edx + movl %edx, %ebx + jb ..L2 + movl $64, %ebx +..L2: + testl %edx, %edx + jle ..B1.21 +..B1.15: + movl %ebx, %edx + xorl %ebp, %ebp + shrl $1, %edx + xorl %esi, %esi + call ..L3 +..L3: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L3](%edi), %edi + testl %edx, %edx + jbe ..B1.23 +..B1.16: + movl %ecx, (%esp) + xorl %eax, %eax + movl %edx, 12(%esp) + movl %ebx, 8(%esp) + movl %ecx, 4(%esp) + movl (%esp), %edx +..B1.17: + movzbl -1(%edx), %ebx + addl $-48, %ebx + movsbl %bl, %ecx + lea (%eax,%eax,4), %ebx + shll $5, %ebx + incl %eax + lea _C_MUL_10_POW_I@GOTOFF(%edi,%ecx,8), %ecx + addl (%ecx,%ebx), %ebp + adcl 4(%ecx,%ebx), %esi + movzbl -2(%edx), %ecx + addl $-2, %edx + addl $-48, %ecx + movsbl %cl, %ecx + lea _C_MUL_10_POW_I@GOTOFF(%edi,%ecx,8), %ecx + addl 80(%ecx,%ebx), %ebp + adcl 84(%ecx,%ebx), %esi + cmpl 12(%esp), %eax + jb ..B1.17 +..B1.18: + movl 8(%esp), %ebx + lea 1(%eax,%eax), %eax + movl 4(%esp), %ecx +..B1.19: + lea -1(%eax), %edx + cmpl %edx, %ebx + jbe ..B1.22 +..B1.20: + subl %eax, %ecx + lea (%eax,%eax,4), %ebx + shll $4, %ebx + movzbl (%ecx), %ecx + addl $-48, %ecx + movsbl %cl, %ecx + lea (%ebx,%ecx,8), %ecx + addl -80+_C_MUL_10_POW_I@GOTOFF(%edi,%ecx), %ebp + adcl -76+_C_MUL_10_POW_I@GOTOFF(%edi,%ecx), %esi + jmp ..B1.22 +..B1.21: + xorl %ebp, %ebp + xorl %esi, %esi +..B1.22: + movl %ebp, %eax + movl %esi, %edx + addl $44, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.23: + movl $1, %eax + jmp ..B1.19 +..B1.25: + cmpl $3, %edx + jl ..B1.27 +..B1.26: + movsbl 1(%eax), %ebx + andl $-33, %ebx + cmpl $88, %ebx + je ..B1.51 + jmp ..B1.28 +..B1.27: + cmpl $1, %edx + jle ..B1.32 +..B1.28: + movl $1, %ebx +..B1.29: + movsbl (%ebx,%eax), %ebp + addl $-48, %ebp + cmpl $7, %ebp + ja ..B1.21 +..B1.30: + incl %ebx + cmpl %edx, %ebx + jl ..B1.29 +..B1.32: + decl %edx + cmpl $22, %edx + movl %edx, %edi + jb ..L4 + movl $22, %edi +..L4: + testl %edx, %edx + jle ..B1.21 +..B1.33: + movl %edi, %eax + xorl %ebp, %ebp + shrl $1, %eax + xorl %esi, %esi + testl %eax, %eax + jbe ..B1.49 +..B1.34: + movl %ecx, %ebx + movl %ebp, 16(%esp) + movl %eax, 8(%esp) + movl %edi, (%esp) + movl %ecx, 4(%esp) +..B1.35: + movl 16(%esp), %edi + movzbl -1(%ebx), %ecx + addl $-48, %ecx + movsbl %cl, %eax + lea (%edi,%edi,2), %ecx + movl %ecx, 12(%esp) + addl %ecx, %ecx + cmpl $31, %ecx + cltd + jbe ..B1.37 +..B1.36: + movl %eax, %edx + xorl %edi, %edi + shll %cl, %edx + jmp ..B1.38 +..B1.37: + movl %eax, %edi + shldl %cl, %edi, %edx + shll %cl, %edi +..B1.38: + addl %edi, %ebp + movl 12(%esp), %edi + movzbl -2(%ebx), %ecx + adcl %edx, %esi + addl $-48, %ecx + movsbl %cl, %eax + lea 3(%edi,%edi), %ecx + cltd + cmpl $31, %ecx + jbe ..B1.40 +..B1.39: + movl %eax, %edx + xorl %edi, %edi + shll %cl, %edx + jmp ..B1.41 +..B1.40: + movl %eax, %edi + shldl %cl, %eax, %edx + shll %cl, %edi +..B1.41: + addl %edi, %ebp + movl 16(%esp), %ecx + adcl %edx, %esi + incl %ecx + addl $-2, %ebx + movl %ecx, 16(%esp) + cmpl 8(%esp), %ecx + jb ..B1.35 +..B1.42: + movl %ecx, %edx + lea 1(%edx,%edx), %ebx + movl (%esp), %edi + movl 4(%esp), %ecx +..B1.43: + lea -1(%ebx), %eax + cmpl %eax, %edi + jbe ..B1.22 +..B1.44: + subl %ebx, %ecx + movzbl (%ecx), %ecx + addl $-48, %ecx + movsbl %cl, %eax + lea -3(%ebx,%ebx,2), %ecx + cltd + cmpl $31, %ecx + jbe ..B1.46 +..B1.45: + movl %eax, %edx + xorl %ebx, %ebx + shll %cl, %edx +..B1.47: + addl %ebx, %ebp + adcl %edx, %esi + jmp ..B1.22 +..B1.46: + movl %eax, %ebx + shldl %cl, %eax, %edx + shll %cl, %ebx + jmp ..B1.47 +..B1.49: + movl $1, %ebx + jmp ..B1.43 +..B1.51: + addl $-2, %edx + xorl %ebx, %ebx +..B1.52: + movsbl 2(%ebx,%eax), %esi + lea -48(%esi), %ebp + cmpl $9, %ebp + jbe ..B1.55 +..B1.53: + lea -97(%esi), %ebp + cmpl $5, %ebp + jbe ..B1.55 +..B1.54: + addl $-65, %esi + cmpl $5, %esi + ja ..B1.21 +..B1.55: + incl %ebx + cmpl %edx, %ebx + jb ..B1.52 +..B1.56: + cmpl $16, %edx + movl %edx, %eax + jb ..L5 + movl $16, %eax +..L5: + testl %edx, %edx + jle ..B1.21 +..B1.57: + movl %eax, %edx + xorl %ebp, %ebp + shrl $1, %edx + xorl %esi, %esi + testl %edx, %edx + jbe ..B1.89 +..B1.58: + movl %ecx, %edi + xorl %ebx, %ebx + movl %edi, 32(%esp) + movl %edx, 28(%esp) + movl %eax, (%esp) + movl %ecx, 4(%esp) +..B1.59: + movl 32(%esp), %edi + movsbl -1(%edi), %ecx + movl %ecx, 20(%esp) + lea -48(%ecx), %ecx + movl %ecx, 8(%esp) + cmpl $9, %ecx + ja ..B1.61 +..B1.60: + movsbl 8(%esp), %eax + jmp ..B1.64 +..B1.61: + movl 20(%esp), %ecx + lea -97(%ecx), %edi + cmpl $5, %edi + ja ..B1.63 +..B1.62: + addl $-87, %ecx + movsbl %cl, %eax + jmp ..B1.64 +..B1.63: + addl $-55, %ecx + movsbl %cl, %eax +..B1.64: + cltd + lea (,%ebx,8), %ecx + cmpl $31, %ecx + jbe ..B1.66 +..B1.65: + movl %eax, %edx + movl $0, 16(%esp) + shll %cl, %edx + jmp ..B1.67 +..B1.66: + shldl %cl, %eax, %edx + shll %cl, %eax + movl %eax, 16(%esp) +..B1.67: + movl 32(%esp), %edi + addl 16(%esp), %ebp + movsbl -2(%edi), %ecx + adcl %edx, %esi + movl %ecx, 24(%esp) + lea -48(%ecx), %ecx + movl %ecx, 12(%esp) + cmpl $9, %ecx + ja ..B1.69 +..B1.68: + movsbl 12(%esp), %eax + jmp ..B1.72 +..B1.69: + movl 24(%esp), %ecx + lea -97(%ecx), %edi + cmpl $5, %edi + ja ..B1.71 +..B1.70: + addl $-87, %ecx + movsbl %cl, %eax + jmp ..B1.72 +..B1.71: + addl $-55, %ecx + movsbl %cl, %eax +..B1.72: + cltd + lea 4(,%ebx,8), %ecx + cmpl $31, %ecx + jbe ..B1.74 +..B1.73: + movl %eax, %edx + xorl %edi, %edi + shll %cl, %edx + jmp ..B1.75 +..B1.74: + movl %eax, %edi + shldl %cl, %eax, %edx + shll %cl, %edi +..B1.75: + addl %edi, %ebp + adcl %edx, %esi + incl %ebx + addl $-2, 32(%esp) + cmpl 28(%esp), %ebx + jb ..B1.59 +..B1.76: + movl (%esp), %eax + lea 1(%ebx,%ebx), %edi + movl 4(%esp), %ecx +..B1.77: + lea -1(%edi), %ebx + cmpl %ebx, %eax + jbe ..B1.22 +..B1.78: + subl %edi, %ecx + movsbl (%ecx), %ebx + lea -48(%ebx), %ecx + cmpl $9, %ecx + ja ..B1.80 +..B1.79: + movsbl %cl, %eax + jmp ..B1.83 +..B1.80: + lea -97(%ebx), %ecx + cmpl $5, %ecx + ja ..B1.82 +..B1.81: + addl $-87, %ebx + movsbl %bl, %eax + jmp ..B1.83 +..B1.82: + addl $-55, %ebx + movsbl %bl, %eax +..B1.83: + cltd + lea -4(,%edi,4), %ecx + cmpl $31, %ecx + jbe ..B1.85 +..B1.84: + movl %eax, %edx + xorl %ebx, %ebx + shll %cl, %edx +..B1.86: + addl %ebx, %ebp + adcl %edx, %esi + jmp ..B1.22 +..B1.85: + movl %eax, %ebx + shldl %cl, %eax, %edx + shll %cl, %ebx + jmp ..B1.86 +..B1.89: + movl $1, %edi + jmp ..B1.77 + .align 16,0x90 + .type __libm_conv_strtoull,@function + .size __libm_conv_strtoull,.-__libm_conv_strtoull + .data +# -- End __libm_conv_strtoull + .section .rodata, "a" + .align 8 + .align 8 +_C_MUL_10_POW_I: + .long 0x00000000,0x00000000 + .long 0x00000001,0x00000000 + .long 0x00000002,0x00000000 + .long 0x00000003,0x00000000 + .long 0x00000004,0x00000000 + .long 0x00000005,0x00000000 + .long 0x00000006,0x00000000 + .long 0x00000007,0x00000000 + .long 0x00000008,0x00000000 + .long 0x00000009,0x00000000 + .long 0x00000000,0x00000000 + .long 0x0000000a,0x00000000 + .long 0x00000014,0x00000000 + .long 0x0000001e,0x00000000 + .long 0x00000028,0x00000000 + .long 0x00000032,0x00000000 + .long 0x0000003c,0x00000000 + .long 0x00000046,0x00000000 + .long 0x00000050,0x00000000 + .long 0x0000005a,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000064,0x00000000 + .long 0x000000c8,0x00000000 + .long 0x0000012c,0x00000000 + .long 0x00000190,0x00000000 + .long 0x000001f4,0x00000000 + .long 0x00000258,0x00000000 + .long 0x000002bc,0x00000000 + .long 0x00000320,0x00000000 + .long 0x00000384,0x00000000 + .long 0x00000000,0x00000000 + .long 0x000003e8,0x00000000 + .long 0x000007d0,0x00000000 + .long 0x00000bb8,0x00000000 + .long 0x00000fa0,0x00000000 + .long 0x00001388,0x00000000 + .long 0x00001770,0x00000000 + .long 0x00001b58,0x00000000 + .long 0x00001f40,0x00000000 + .long 0x00002328,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00002710,0x00000000 + .long 0x00004e20,0x00000000 + .long 0x00007530,0x00000000 + .long 0x00009c40,0x00000000 + .long 0x0000c350,0x00000000 + .long 0x0000ea60,0x00000000 + .long 0x00011170,0x00000000 + .long 0x00013880,0x00000000 + .long 0x00015f90,0x00000000 + .long 0x00000000,0x00000000 + .long 0x000186a0,0x00000000 + .long 0x00030d40,0x00000000 + .long 0x000493e0,0x00000000 + .long 0x00061a80,0x00000000 + .long 0x0007a120,0x00000000 + .long 0x000927c0,0x00000000 + .long 0x000aae60,0x00000000 + .long 0x000c3500,0x00000000 + .long 0x000dbba0,0x00000000 + .long 0x00000000,0x00000000 + .long 0x000f4240,0x00000000 + .long 0x001e8480,0x00000000 + .long 0x002dc6c0,0x00000000 + .long 0x003d0900,0x00000000 + .long 0x004c4b40,0x00000000 + .long 0x005b8d80,0x00000000 + .long 0x006acfc0,0x00000000 + .long 0x007a1200,0x00000000 + .long 0x00895440,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00989680,0x00000000 + .long 0x01312d00,0x00000000 + .long 0x01c9c380,0x00000000 + .long 0x02625a00,0x00000000 + .long 0x02faf080,0x00000000 + .long 0x03938700,0x00000000 + .long 0x042c1d80,0x00000000 + .long 0x04c4b400,0x00000000 + .long 0x055d4a80,0x00000000 + .long 0x00000000,0x00000000 + .long 0x05f5e100,0x00000000 + .long 0x0bebc200,0x00000000 + .long 0x11e1a300,0x00000000 + .long 0x17d78400,0x00000000 + .long 0x1dcd6500,0x00000000 + .long 0x23c34600,0x00000000 + .long 0x29b92700,0x00000000 + .long 0x2faf0800,0x00000000 + .long 0x35a4e900,0x00000000 + .long 0x00000000,0x00000000 + .long 0x3b9aca00,0x00000000 + .long 0x77359400,0x00000000 + .long 0xb2d05e00,0x00000000 + .long 0xee6b2800,0x00000000 + .long 0x2a05f200,0x00000001 + .long 0x65a0bc00,0x00000001 + .long 0xa13b8600,0x00000001 + .long 0xdcd65000,0x00000001 + .long 0x18711a00,0x00000002 + .long 0x00000000,0x00000000 + .long 0x540be400,0x00000002 + .long 0xa817c800,0x00000004 + .long 0xfc23ac00,0x00000006 + .long 0x502f9000,0x00000009 + .long 0xa43b7400,0x0000000b + .long 0xf8475800,0x0000000d + .long 0x4c533c00,0x00000010 + .long 0xa05f2000,0x00000012 + .long 0xf46b0400,0x00000014 + .long 0x00000000,0x00000000 + .long 0x4876e800,0x00000017 + .long 0x90edd000,0x0000002e + .long 0xd964b800,0x00000045 + .long 0x21dba000,0x0000005d + .long 0x6a528800,0x00000074 + .long 0xb2c97000,0x0000008b + .long 0xfb405800,0x000000a2 + .long 0x43b74000,0x000000ba + .long 0x8c2e2800,0x000000d1 + .long 0x00000000,0x00000000 + .long 0xd4a51000,0x000000e8 + .long 0xa94a2000,0x000001d1 + .long 0x7def3000,0x000002ba + .long 0x52944000,0x000003a3 + .long 0x27395000,0x0000048c + .long 0xfbde6000,0x00000574 + .long 0xd0837000,0x0000065d + .long 0xa5288000,0x00000746 + .long 0x79cd9000,0x0000082f + .long 0x00000000,0x00000000 + .long 0x4e72a000,0x00000918 + .long 0x9ce54000,0x00001230 + .long 0xeb57e000,0x00001b48 + .long 0x39ca8000,0x00002461 + .long 0x883d2000,0x00002d79 + .long 0xd6afc000,0x00003691 + .long 0x25226000,0x00003faa + .long 0x73950000,0x000048c2 + .long 0xc207a000,0x000051da + .long 0x00000000,0x00000000 + .long 0x107a4000,0x00005af3 + .long 0x20f48000,0x0000b5e6 + .long 0x316ec000,0x000110d9 + .long 0x41e90000,0x00016bcc + .long 0x52634000,0x0001c6bf + .long 0x62dd8000,0x000221b2 + .long 0x7357c000,0x00027ca5 + .long 0x83d20000,0x0002d798 + .long 0x944c4000,0x0003328b + .long 0x00000000,0x00000000 + .long 0xa4c68000,0x00038d7e + .long 0x498d0000,0x00071afd + .long 0xee538000,0x000aa87b + .long 0x931a0000,0x000e35fa + .long 0x37e08000,0x0011c379 + .long 0xdca70000,0x001550f7 + .long 0x816d8000,0x0018de76 + .long 0x26340000,0x001c6bf5 + .long 0xcafa8000,0x001ff973 + .long 0x00000000,0x00000000 + .long 0x6fc10000,0x002386f2 + .long 0xdf820000,0x00470de4 + .long 0x4f430000,0x006a94d7 + .long 0xbf040000,0x008e1bc9 + .long 0x2ec50000,0x00b1a2bc + .long 0x9e860000,0x00d529ae + .long 0x0e470000,0x00f8b0a1 + .long 0x7e080000,0x011c3793 + .long 0xedc90000,0x013fbe85 + .long 0x00000000,0x00000000 + .long 0x5d8a0000,0x01634578 + .long 0xbb140000,0x02c68af0 + .long 0x189e0000,0x0429d069 + .long 0x76280000,0x058d15e1 + .long 0xd3b20000,0x06f05b59 + .long 0x313c0000,0x0853a0d2 + .long 0x8ec60000,0x09b6e64a + .long 0xec500000,0x0b1a2bc2 + .long 0x49da0000,0x0c7d713b + .long 0x00000000,0x00000000 + .long 0xa7640000,0x0de0b6b3 + .long 0x4ec80000,0x1bc16d67 + .long 0xf62c0000,0x29a2241a + .long 0x9d900000,0x3782dace + .long 0x44f40000,0x45639182 + .long 0xec580000,0x53444835 + .long 0x93bc0000,0x6124fee9 + .long 0x3b200000,0x6f05b59d + .long 0xe2840000,0x7ce66c50 + .long 0x00000000,0x00000000 + .long 0x89e80000,0x8ac72304 + .long 0x13d00000,0x158e4609 + .long 0x9db80000,0xa055690d + .long 0x27a00000,0x2b1c8c12 + .long 0xb1880000,0xb5e3af16 + .long 0x3b700000,0x40aad21b + .long 0xc5580000,0xcb71f51f + .long 0x4f400000,0x56391824 + .long 0xd9280000,0xe1003b28 + .long 0x00000000,0x00000000 + .long 0x63100000,0x6bc75e2d + .long 0xc6200000,0xd78ebc5a + .long 0x29300000,0x43561a88 + .long 0x8c400000,0xaf1d78b5 + .long 0xef500000,0x1ae4d6e2 + .long 0x52600000,0x86ac3510 + .long 0xb5700000,0xf273933d + .long 0x18800000,0x5e3af16b + .long 0x7b900000,0xca024f98 + .long 0x00000000,0x00000000 + .long 0xdea00000,0x35c9adc5 + .long 0xbd400000,0x6b935b8b + .long 0x9be00000,0xa15d0951 + .long 0x7a800000,0xd726b717 + .long 0x59200000,0x0cf064dd + .long 0x37c00000,0x42ba12a3 + .long 0x16600000,0x7883c069 + .long 0xf5000000,0xae4d6e2e + .long 0xd3a00000,0xe4171bf4 + .long 0x00000000,0x00000000 + .long 0xb2400000,0x19e0c9ba + .long 0x64800000,0x33c19375 + .long 0x16c00000,0x4da25d30 + .long 0xc9000000,0x678326ea + .long 0x7b400000,0x8163f0a5 + .long 0x2d800000,0x9b44ba60 + .long 0xdfc00000,0xb525841a + .long 0x92000000,0xcf064dd5 + .long 0x44400000,0xe8e71790 + .long 0x00000000,0x00000000 + .long 0xf6800000,0x02c7e14a + .long 0xed000000,0x058fc295 + .long 0xe3800000,0x0857a3e0 + .long 0xda000000,0x0b1f852b + .long 0xd0800000,0x0de76676 + .long 0xc7000000,0x10af47c1 + .long 0xbd800000,0x1377290c + .long 0xb4000000,0x163f0a57 + .long 0xaa800000,0x1906eba2 + .long 0x00000000,0x00000000 + .long 0xa1000000,0x1bcecced + .long 0x42000000,0x379d99db + .long 0xe3000000,0x536c66c8 + .long 0x84000000,0x6f3b33b6 + .long 0x25000000,0x8b0a00a4 + .long 0xc6000000,0xa6d8cd91 + .long 0x67000000,0xc2a79a7f + .long 0x08000000,0xde76676d + .long 0xa9000000,0xfa45345a + .long 0x00000000,0x00000000 + .long 0x4a000000,0x16140148 + .long 0x94000000,0x2c280290 + .long 0xde000000,0x423c03d8 + .long 0x28000000,0x58500521 + .long 0x72000000,0x6e640669 + .long 0xbc000000,0x847807b1 + .long 0x06000000,0x9a8c08fa + .long 0x50000000,0xb0a00a42 + .long 0x9a000000,0xc6b40b8a + .long 0x00000000,0x00000000 + .long 0xe4000000,0xdcc80cd2 + .long 0xc8000000,0xb99019a5 + .long 0xac000000,0x96582678 + .long 0x90000000,0x7320334b + .long 0x74000000,0x4fe8401e + .long 0x58000000,0x2cb04cf1 + .long 0x3c000000,0x097859c4 + .long 0x20000000,0xe6406697 + .long 0x04000000,0xc308736a + .long 0x00000000,0x00000000 + .long 0xe8000000,0x9fd0803c + .long 0xd0000000,0x3fa10079 + .long 0xb8000000,0xdf7180b6 + .long 0xa0000000,0x7f4200f3 + .long 0x88000000,0x1f128130 + .long 0x70000000,0xbee3016d + .long 0x58000000,0x5eb381aa + .long 0x40000000,0xfe8401e7 + .long 0x28000000,0x9e548224 + .long 0x00000000,0x00000000 + .long 0x10000000,0x3e250261 + .long 0x20000000,0x7c4a04c2 + .long 0x30000000,0xba6f0723 + .long 0x40000000,0xf8940984 + .long 0x50000000,0x36b90be5 + .long 0x60000000,0x74de0e46 + .long 0x70000000,0xb30310a7 + .long 0x80000000,0xf1281308 + .long 0x90000000,0x2f4d1569 + .long 0x00000000,0x00000000 + .long 0xa0000000,0x6d7217ca + .long 0x40000000,0xdae42f95 + .long 0xe0000000,0x4856475f + .long 0x80000000,0xb5c85f2a + .long 0x20000000,0x233a76f5 + .long 0xc0000000,0x90ac8ebf + .long 0x60000000,0xfe1ea68a + .long 0x00000000,0x6b90be55 + .long 0xa0000000,0xd902d61f + .long 0x00000000,0x00000000 + .long 0x40000000,0x4674edea + .long 0x80000000,0x8ce9dbd4 + .long 0xc0000000,0xd35ec9be + .long 0x00000000,0x19d3b7a9 + .long 0x40000000,0x6048a593 + .long 0x80000000,0xa6bd937d + .long 0xc0000000,0xed328167 + .long 0x00000000,0x33a76f52 + .long 0x40000000,0x7a1c5d3c + .long 0x00000000,0x00000000 + .long 0x80000000,0xc0914b26 + .long 0x00000000,0x8122964d + .long 0x80000000,0x41b3e173 + .long 0x00000000,0x02452c9a + .long 0x80000000,0xc2d677c0 + .long 0x00000000,0x8367c2e7 + .long 0x80000000,0x43f90e0d + .long 0x00000000,0x048a5934 + .long 0x80000000,0xc51ba45a + .long 0x00000000,0x00000000 + .long 0x00000000,0x85acef81 + .long 0x00000000,0x0b59df02 + .long 0x00000000,0x9106ce83 + .long 0x00000000,0x16b3be04 + .long 0x00000000,0x9c60ad85 + .long 0x00000000,0x220d9d06 + .long 0x00000000,0xa7ba8c87 + .long 0x00000000,0x2d677c08 + .long 0x00000000,0xb3146b89 + .long 0x00000000,0x00000000 + .long 0x00000000,0x38c15b0a + .long 0x00000000,0x7182b614 + .long 0x00000000,0xaa44111e + .long 0x00000000,0xe3056c28 + .long 0x00000000,0x1bc6c732 + .long 0x00000000,0x5488223c + .long 0x00000000,0x8d497d46 + .long 0x00000000,0xc60ad850 + .long 0x00000000,0xfecc335a + .long 0x00000000,0x00000000 + .long 0x00000000,0x378d8e64 + .long 0x00000000,0x6f1b1cc8 + .long 0x00000000,0xa6a8ab2c + .long 0x00000000,0xde363990 + .long 0x00000000,0x15c3c7f4 + .long 0x00000000,0x4d515658 + .long 0x00000000,0x84dee4bc + .long 0x00000000,0xbc6c7320 + .long 0x00000000,0xf3fa0184 + .long 0x00000000,0x00000000 + .long 0x00000000,0x2b878fe8 + .long 0x00000000,0x570f1fd0 + .long 0x00000000,0x8296afb8 + .long 0x00000000,0xae1e3fa0 + .long 0x00000000,0xd9a5cf88 + .long 0x00000000,0x052d5f70 + .long 0x00000000,0x30b4ef58 + .long 0x00000000,0x5c3c7f40 + .long 0x00000000,0x87c40f28 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb34b9f10 + .long 0x00000000,0x66973e20 + .long 0x00000000,0x19e2dd30 + .long 0x00000000,0xcd2e7c40 + .long 0x00000000,0x807a1b50 + .long 0x00000000,0x33c5ba60 + .long 0x00000000,0xe7115970 + .long 0x00000000,0x9a5cf880 + .long 0x00000000,0x4da89790 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00f436a0 + .long 0x00000000,0x01e86d40 + .long 0x00000000,0x02dca3e0 + .long 0x00000000,0x03d0da80 + .long 0x00000000,0x04c51120 + .long 0x00000000,0x05b947c0 + .long 0x00000000,0x06ad7e60 + .long 0x00000000,0x07a1b500 + .long 0x00000000,0x0895eba0 + .long 0x00000000,0x00000000 + .long 0x00000000,0x098a2240 + .long 0x00000000,0x13144480 + .long 0x00000000,0x1c9e66c0 + .long 0x00000000,0x26288900 + .long 0x00000000,0x2fb2ab40 + .long 0x00000000,0x393ccd80 + .long 0x00000000,0x42c6efc0 + .long 0x00000000,0x4c511200 + .long 0x00000000,0x55db3440 + .long 0x00000000,0x00000000 + .long 0x00000000,0x5f655680 + .long 0x00000000,0xbecaad00 + .long 0x00000000,0x1e300380 + .long 0x00000000,0x7d955a00 + .long 0x00000000,0xdcfab080 + .long 0x00000000,0x3c600700 + .long 0x00000000,0x9bc55d80 + .long 0x00000000,0xfb2ab400 + .long 0x00000000,0x5a900a80 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb9f56100 + .long 0x00000000,0x73eac200 + .long 0x00000000,0x2de02300 + .long 0x00000000,0xe7d58400 + .long 0x00000000,0xa1cae500 + .long 0x00000000,0x5bc04600 + .long 0x00000000,0x15b5a700 + .long 0x00000000,0xcfab0800 + .long 0x00000000,0x89a06900 + .long 0x00000000,0x00000000 + .long 0x00000000,0x4395ca00 + .long 0x00000000,0x872b9400 + .long 0x00000000,0xcac15e00 + .long 0x00000000,0x0e572800 + .long 0x00000000,0x51ecf200 + .long 0x00000000,0x9582bc00 + .long 0x00000000,0xd9188600 + .long 0x00000000,0x1cae5000 + .long 0x00000000,0x60441a00 + .long 0x00000000,0x00000000 + .long 0x00000000,0xa3d9e400 + .long 0x00000000,0x47b3c800 + .long 0x00000000,0xeb8dac00 + .long 0x00000000,0x8f679000 + .long 0x00000000,0x33417400 + .long 0x00000000,0xd71b5800 + .long 0x00000000,0x7af53c00 + .long 0x00000000,0x1ecf2000 + .long 0x00000000,0xc2a90400 + .long 0x00000000,0x00000000 + .long 0x00000000,0x6682e800 + .long 0x00000000,0xcd05d000 + .long 0x00000000,0x3388b800 + .long 0x00000000,0x9a0ba000 + .long 0x00000000,0x008e8800 + .long 0x00000000,0x67117000 + .long 0x00000000,0xcd945800 + .long 0x00000000,0x34174000 + .long 0x00000000,0x9a9a2800 + .long 0x00000000,0x00000000 + .long 0x00000000,0x011d1000 + .long 0x00000000,0x023a2000 + .long 0x00000000,0x03573000 + .long 0x00000000,0x04744000 + .long 0x00000000,0x05915000 + .long 0x00000000,0x06ae6000 + .long 0x00000000,0x07cb7000 + .long 0x00000000,0x08e88000 + .long 0x00000000,0x0a059000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x0b22a000 + .long 0x00000000,0x16454000 + .long 0x00000000,0x2167e000 + .long 0x00000000,0x2c8a8000 + .long 0x00000000,0x37ad2000 + .long 0x00000000,0x42cfc000 + .long 0x00000000,0x4df26000 + .long 0x00000000,0x59150000 + .long 0x00000000,0x6437a000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x6f5a4000 + .long 0x00000000,0xdeb48000 + .long 0x00000000,0x4e0ec000 + .long 0x00000000,0xbd690000 + .long 0x00000000,0x2cc34000 + .long 0x00000000,0x9c1d8000 + .long 0x00000000,0x0b77c000 + .long 0x00000000,0x7ad20000 + .long 0x00000000,0xea2c4000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x59868000 + .long 0x00000000,0xb30d0000 + .long 0x00000000,0x0c938000 + .long 0x00000000,0x661a0000 + .long 0x00000000,0xbfa08000 + .long 0x00000000,0x19270000 + .long 0x00000000,0x72ad8000 + .long 0x00000000,0xcc340000 + .long 0x00000000,0x25ba8000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x7f410000 + .long 0x00000000,0xfe820000 + .long 0x00000000,0x7dc30000 + .long 0x00000000,0xfd040000 + .long 0x00000000,0x7c450000 + .long 0x00000000,0xfb860000 + .long 0x00000000,0x7ac70000 + .long 0x00000000,0xfa080000 + .long 0x00000000,0x79490000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xf88a0000 + .long 0x00000000,0xf1140000 + .long 0x00000000,0xe99e0000 + .long 0x00000000,0xe2280000 + .long 0x00000000,0xdab20000 + .long 0x00000000,0xd33c0000 + .long 0x00000000,0xcbc60000 + .long 0x00000000,0xc4500000 + .long 0x00000000,0xbcda0000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb5640000 + .long 0x00000000,0x6ac80000 + .long 0x00000000,0x202c0000 + .long 0x00000000,0xd5900000 + .long 0x00000000,0x8af40000 + .long 0x00000000,0x40580000 + .long 0x00000000,0xf5bc0000 + .long 0x00000000,0xab200000 + .long 0x00000000,0x60840000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x15e80000 + .long 0x00000000,0x2bd00000 + .long 0x00000000,0x41b80000 + .long 0x00000000,0x57a00000 + .long 0x00000000,0x6d880000 + .long 0x00000000,0x83700000 + .long 0x00000000,0x99580000 + .long 0x00000000,0xaf400000 + .long 0x00000000,0xc5280000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xdb100000 + .long 0x00000000,0xb6200000 + .long 0x00000000,0x91300000 + .long 0x00000000,0x6c400000 + .long 0x00000000,0x47500000 + .long 0x00000000,0x22600000 + .long 0x00000000,0xfd700000 + .long 0x00000000,0xd8800000 + .long 0x00000000,0xb3900000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x8ea00000 + .long 0x00000000,0x1d400000 + .long 0x00000000,0xabe00000 + .long 0x00000000,0x3a800000 + .long 0x00000000,0xc9200000 + .long 0x00000000,0x57c00000 + .long 0x00000000,0xe6600000 + .long 0x00000000,0x75000000 + .long 0x00000000,0x03a00000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x92400000 + .long 0x00000000,0x24800000 + .long 0x00000000,0xb6c00000 + .long 0x00000000,0x49000000 + .long 0x00000000,0xdb400000 + .long 0x00000000,0x6d800000 + .long 0x00000000,0xffc00000 + .long 0x00000000,0x92000000 + .long 0x00000000,0x24400000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb6800000 + .long 0x00000000,0x6d000000 + .long 0x00000000,0x23800000 + .long 0x00000000,0xda000000 + .long 0x00000000,0x90800000 + .long 0x00000000,0x47000000 + .long 0x00000000,0xfd800000 + .long 0x00000000,0xb4000000 + .long 0x00000000,0x6a800000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x21000000 + .long 0x00000000,0x42000000 + .long 0x00000000,0x63000000 + .long 0x00000000,0x84000000 + .long 0x00000000,0xa5000000 + .long 0x00000000,0xc6000000 + .long 0x00000000,0xe7000000 + .long 0x00000000,0x08000000 + .long 0x00000000,0x29000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x4a000000 + .long 0x00000000,0x94000000 + .long 0x00000000,0xde000000 + .long 0x00000000,0x28000000 + .long 0x00000000,0x72000000 + .long 0x00000000,0xbc000000 + .long 0x00000000,0x06000000 + .long 0x00000000,0x50000000 + .long 0x00000000,0x9a000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xe4000000 + .long 0x00000000,0xc8000000 + .long 0x00000000,0xac000000 + .long 0x00000000,0x90000000 + .long 0x00000000,0x74000000 + .long 0x00000000,0x58000000 + .long 0x00000000,0x3c000000 + .long 0x00000000,0x20000000 + .long 0x00000000,0x04000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xe8000000 + .long 0x00000000,0xd0000000 + .long 0x00000000,0xb8000000 + .long 0x00000000,0xa0000000 + .long 0x00000000,0x88000000 + .long 0x00000000,0x70000000 + .long 0x00000000,0x58000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x28000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x10000000 + .long 0x00000000,0x20000000 + .long 0x00000000,0x30000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x50000000 + .long 0x00000000,0x60000000 + .long 0x00000000,0x70000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x90000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xa0000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0xe0000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x20000000 + .long 0x00000000,0xc0000000 + .long 0x00000000,0x60000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xa0000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0xc0000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0xc0000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .type _C_MUL_10_POW_I,@object + .size _C_MUL_10_POW_I,5120 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/libm_tancot_huge.S b/external/sgx_libm/ia32/libm_tancot_huge.S new file mode 100644 index 0000000000..f1b018ed73 --- /dev/null +++ b/external/sgx_libm/ia32/libm_tancot_huge.S @@ -0,0 +1,800 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_tancot_huge.c" + .text +..TXTST0: +# -- Begin __libm_tancot_huge + .text + .align 16,0x90 + .hidden __libm_tancot_huge + .globl __libm_tancot_huge +__libm_tancot_huge: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + movl 16(%ebp), %eax + movl 20(%ebp), %edx + movl %eax, 28(%esp) + movl %edx, 32(%esp) + movl %gs:20, %ecx + xorl %esp, %ecx + movl %ecx, 64(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movl 12(%ebp), %edx + movl %edx, %eax + andl $2147483647, %eax + shrl $31, %edx + movl %edx, 44(%esp) + cmpl $1104150528, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jae ..B1.14 +..B1.4: + fldl 8(%ebp) + fabs + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + fstpt 16(%esp) + fldt 16(%esp) + cmpl $768, %edx + fstl 8(%ebp) + fldl _Pi4Inv@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpl (%esp) + je ..B1.46 +..B1.5: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.6: + fldcw 12(%esp) +..B1.7: + fldl 8(%ebp) + movl $1, %esi + fstpt 16(%esp) +..B1.8: + movl (%esp), %edx + movl 4(%esp), %ecx + movl %ecx, %edi + movl %edx, 8(%esp) + movl %ecx, %edx + andl $1048575, %edx + shrl $20, %edi + orl $1048576, %edx + cmpl $1094713344, %ecx + jae ..B1.10 +..B1.9: + movl %edi, %ecx + negl %ecx + addl $19, %ecx + shrl %cl, %edx + jmp ..B1.11 +..B1.10: + lea 13(%edi), %ecx + negl %edi + addl $19, %edi + shll %cl, %edx + movl %edi, %ecx + movl 8(%esp), %edi + shrl %cl, %edi + orl %edi, %edx +..B1.11: + lea 1(%edx), %ecx + andl $-2, %ecx + movl %ecx, (%esp) + cmpl $1094713344, %eax + fildl (%esp) + jae ..B1.13 +..B1.12: + fldl _Pi4x3@GOTOFF(%ebx) + fmul %st(1), %st + fldl 8+_Pi4x3@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(2) + fmull 16+_Pi4x3@GOTOFF(%ebx) + fldt 16(%esp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.20 +..B1.13: + fldl _Pi4x4@GOTOFF(%ebx) + fmul %st(1), %st + fldl 8+_Pi4x4@GOTOFF(%ebx) + fmul %st(2), %st + fldl 16+_Pi4x4@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(3) + fmull 24+_Pi4x4@GOTOFF(%ebx) + fldt 16(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.20 +..B1.14: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.51 +..B1.15: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.16: + fldcw 12(%esp) +..B1.17: + movl $1, %esi +..B1.18: + fldl 8(%ebp) + addl $-32, %esp + fabs + lea 80(%esp), %eax + fstpt (%esp) + movl $0, 12(%esp) + movl %eax, 16(%esp) + call __libm_reduce_pi04l +..B1.54: + movl %eax, %edx + addl $32, %esp +..B1.19: + fldl 48(%esp) + faddl 56(%esp) + fstpt 16(%esp) +..B1.20: + movl 32(%esp), %eax + andl $3, %eax + cmpl $3, %eax + jne ..B1.28 +..B1.21: + fldl _ones@GOTOFF(%ebx) + incl %edx + fldt 16(%esp) + testb $2, %dl + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fdivr %st, %st(3) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fldt 36+_TP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_TP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_TP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _TP@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 36+_TQ@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_TQ@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_TQ@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _TQ@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt 32(%esp) + fldt 132+_GP@GOTOFF(%ebx) + fmul %st(4), %st + fldt 120+_GP@GOTOFF(%ebx) + fmul %st(5), %st + fldt 108+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 96+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 84+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 72+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 60+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 48+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 36+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 24+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fldt 12+_GP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt _GP@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%esp) + je ..B1.23 +..B1.22: + fldt (%esp) + fxch %st(1) + fdivrp %st, %st(3) + fmulp %st, %st(2) + fldt 16(%esp) + movl 44(%esp), %eax + xorl $1, %eax + fmul %st, %st(2) + fldl _ones@GOTOFF(%ebx,%eax,8) + fmul %st, %st(2) + fmul %st, %st(4) + fmul %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + faddp %st, %st(1) + fstpt 32(%esp) + jmp ..B1.24 +..B1.23: + fdivrp %st, %st(2) + fldt (%esp) + fmulp %st, %st(2) + fldt 16(%esp) + fmul %st, %st(2) + movl 44(%esp), %eax + fldl _ones@GOTOFF(%ebx,%eax,8) + fmul %st, %st(3) + fmul %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + fstpt 32(%esp) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) +..B1.24: + testl %esi, %esi + je ..B1.26 +..B1.25: + fldcw 14(%esp) +..B1.26: + fldt 32(%esp) + fldt (%esp) + movl 28(%esp), %eax + fstpl 8(%eax) + fstpl (%eax) + movl 64(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.47 +..B1.27: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.28: + testb $2, 32(%esp) + je ..B1.36 +..B1.29: + fldt 16(%esp) + incl %edx + testb $2, %dl + fmul %st(0), %st + je ..B1.31 +..B1.30: + fldl _ones@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fldt 16(%esp) + fdivr %st, %st(2) + fldt 132+_GP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 120+_GP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 108+_GP@GOTOFF(%ebx) + movl 44(%esp), %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + xorl $1, %eax + fldt 96+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 72+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 36+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt 12+_GP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt _GP@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fldl _ones@GOTOFF(%ebx,%eax,8) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.32 +..B1.31: + fldt 36+_TP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_TP@GOTOFF(%ebx) + movl 44(%esp), %eax + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_TQ@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_TQ@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12+_TQ@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _TQ@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 12+_TP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt _TP@GOTOFF(%ebx) + faddp %st, %st(1) + fdivp %st, %st(1) + fmulp %st, %st(1) + fldl _ones@GOTOFF(%ebx,%eax,8) + fldt 16(%esp) + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) +..B1.32: + testl %esi, %esi + je ..B1.34 +..B1.33: + fldcw 14(%esp) +..B1.34: + fldt 16(%esp) + movl 28(%esp), %eax + fstpl (%eax) + movl 64(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.47 +..B1.35: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.36: + testb $1, 32(%esp) + je ..B1.44 +..B1.37: + fldt 16(%esp) + incl %edx + testb $2, %dl + fmul %st(0), %st + fstpt (%esp) + je ..B1.39 +..B1.38: + fldt 36+_TP@GOTOFF(%ebx) + fldt 24+_TP@GOTOFF(%ebx) + fldt 12+_TP@GOTOFF(%ebx) + fldt _TP@GOTOFF(%ebx) + fldt 36+_TQ@GOTOFF(%ebx) + fldt 24+_TQ@GOTOFF(%ebx) + fldt 12+_TQ@GOTOFF(%ebx) + fldt (%esp) + fmul %st, %st(7) + movl 44(%esp), %eax + fxch %st(6) + faddp %st, %st(7) + fxch %st(5) + fmul %st, %st(6) + xorl $1, %eax + fxch %st(4) + faddp %st, %st(6) + fxch %st(3) + fmul %st, %st(5) + fxch %st(2) + faddp %st, %st(5) + fmul %st(1), %st + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st(1), %st + fldt _TQ@GOTOFF(%ebx) + faddp %st, %st(1) + fdivrp %st, %st(2) + fmulp %st, %st(1) + fldl _ones@GOTOFF(%ebx,%eax,8) + fldt 16(%esp) + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.40 +..B1.39: + fldl _ones@GOTOFF(%ebx) + fldt 16(%esp) + fdivr %st, %st(1) + fldt (%esp) + fld %st(0) + fmul %st(1), %st + fldt 132+_GP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 120+_GP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 108+_GP@GOTOFF(%ebx) + movl 44(%esp), %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_GP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 12+_GP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt _GP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldl _ones@GOTOFF(%ebx,%eax,8) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) +..B1.40: + testl %esi, %esi + je ..B1.42 +..B1.41: + fldcw 14(%esp) +..B1.42: + fldt (%esp) + movl 28(%esp), %eax + fstpl 8(%eax) + movl 64(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.47 +..B1.43: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.44: + movl 64(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.47 +..B1.45: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + xorl %esi, %esi + jmp ..B1.8 +..B1.47: + call __stack_chk_fail@PLT +..B1.51: + xorl %esi, %esi + jmp ..B1.18 + .align 16,0x90 + .type __libm_tancot_huge,@function + .size __libm_tancot_huge,.-__libm_tancot_huge + .data +# -- End __libm_tancot_huge + .section .rodata, "a" + .align 16 + .align 16 +_Pi4Inv: + .long 1841940611 + .long 1072979760 + .type _Pi4Inv,@object + .size _Pi4Inv,8 + .space 8, 0x00 # pad + .align 16 +_Pi4x3: + .long 1413754880 + .long 3219726843 + .long 993632256 + .long 1027030475 + .long 3773204808 + .long 3129236486 + .type _Pi4x3,@object + .size _Pi4x3,24 + .space 8, 0x00 # pad + .align 16 +_Pi4x4: + .long 1413480448 + .long 3219726843 + .long 442499072 + .long 3183522913 + .long 771751936 + .long 3146979722 + .long 622873025 + .long 3110831002 + .type _Pi4x4,@object + .size _Pi4x4,32 + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_TP: + .word 19670 + .word 44908 + .word 50960 + .word 50786 + .word 49149 + .word 0 + .word 19206 + .word 45228 + .word 54194 + .word 52268 + .word 16377 + .word 0 + .word 227 + .word 51280 + .word 43560 + .word 38195 + .word 49139 + .word 0 + .word 12272 + .word 18029 + .word 6715 + .word 45670 + .word 16357 + .word 0 + .type _TP,@object + .size _TP,48 + .align 16 +_TQ: + .word 14748 + .word 33681 + .word 5452 + .word 38090 + .word 49151 + .word 0 + .word 46755 + .word 50026 + .word 17634 + .word 35372 + .word 16382 + .word 0 + .word 46863 + .word 53352 + .word 42702 + .word 59869 + .word 49145 + .word 0 + .word 33295 + .word 20942 + .word 32118 + .word 39935 + .word 16371 + .word 0 + .type _TQ,@object + .size _TQ,48 + .align 16 +_GP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 46639 + .word 2912 + .word 24758 + .word 46603 + .word 49145 + .word 0 + .word 57255 + .word 2218 + .word 21984 + .word 35507 + .word 49142 + .word 0 + .word 34208 + .word 43033 + .word 48281 + .word 56811 + .word 49138 + .word 0 + .word 28773 + .word 27191 + .word 31071 + .word 45908 + .word 49135 + .word 0 + .word 43257 + .word 33777 + .word 11976 + .word 37184 + .word 49132 + .word 0 + .word 62410 + .word 35990 + .word 36363 + .word 60269 + .word 49128 + .word 0 + .word 13659 + .word 55568 + .word 26569 + .word 48851 + .word 49125 + .word 0 + .word 10347 + .word 46238 + .word 47188 + .word 39576 + .word 49122 + .word 0 + .word 2161 + .word 6703 + .word 25719 + .word 64708 + .word 49118 + .word 0 + .word 42329 + .word 7593 + .word 44754 + .word 47734 + .word 49115 + .word 0 + .word 163 + .word 32746 + .word 39875 + .word 61957 + .word 49112 + .word 0 + .type _GP,@object + .size _GP,144 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/llrint.S b/external/sgx_libm/ia32/llrint.S new file mode 100644 index 0000000000..07c6aac047 --- /dev/null +++ b/external/sgx_libm/ia32/llrint.S @@ -0,0 +1,171 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llrint.c" + .text +..TXTST0: +# -- Begin llrint + .text + .align 16,0x90 + .globl llrint +llrint: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp + movl 12(%ebp), %ebx + movl %ebx, %edi + andl $2147483647, %edi + cmpl $1137704960, %edi + jae ..B1.4 +..B1.2: + fldl 8(%ebp) + fistpll 16(%esp) +..B1.3: + movl 16(%esp), %eax + movl 20(%esp), %edx + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.4: + cmpl $1139802112, %edi + jae ..B1.7 +..B1.5: + movl %edi, %edx + andl $1048575, %edi + shrl $20, %edx + orl $1048576, %edi + movl 8(%ebp), %esi + xorl %eax, %eax + shrl $31, %ebx + movl %ebx, (%esp) + addl $-1, %ebx + lea 13(%edx), %ecx + movl %ecx, 4(%esp) + adcl $2147483647, %eax + negl %edx + addl $19, %edx + shll %cl, %edi + movl %edx, %ecx + movl %esi, %edx + shrl %cl, %edx + movl 4(%esp), %ecx + orl %edx, %edi + shll %cl, %esi + movl %edi, %ecx + movl %esi, %edx + subl %ebx, %edx + movl (%esp), %ebx + sbbl %eax, %ecx + jb ..B1.6 +..B1.10: + orl %ecx, %edx + jne ..B1.7 +..B1.6: + xorl %eax, %eax + xorl %edx, %edx + subl %esi, %eax + sbbl %edi, %edx + testl %ebx, %ebx + jne ..L2 + movl %esi, %eax +..L2: + jne ..L3 + movl %edi, %edx +..L3: + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.7: + call ..L4 +..L4: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%eax), %eax + movl $-2147483648, %edx + movl $0, 16(%esp) + movl $-2147483648, 20(%esp) + fldl _infs@GOTOFF(%eax) + fmull _zeros@GOTOFF(%eax) + xorl %eax, %eax + fstpl 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type llrint,@function + .size llrint,.-llrint + .data +# -- End llrint + .section .rodata, "a" + .align 4 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/llrintf.S b/external/sgx_libm/ia32/llrintf.S new file mode 100644 index 0000000000..f3e668b7e8 --- /dev/null +++ b/external/sgx_libm/ia32/llrintf.S @@ -0,0 +1,143 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llrintf.c" + .text +..TXTST0: +# -- Begin llrintf + .text + .align 16,0x90 + .globl llrintf +llrintf: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + pushl %ebx + pushl %ebp + subl $20, %esp + movl 32(%esp), %ebp + movl %ebp, %ebx + andl $2147483647, %ebx + cmpl $1585446912, %ebx + jae ..B1.4 +..B1.2: + flds 32(%esp) + fistpll 8(%esp) +..B1.3: + movl 8(%esp), %eax + movl 12(%esp), %edx + addl $20, %esp + popl %ebp + popl %ebx + ret +..B1.4: + cmpl $1602224128, %ebx + jae ..B1.7 +..B1.5: + shrl $31, %ebp + movl %ebx, %ecx + shrl $23, %ecx + andl $8388607, %ebx + movl %ebp, %eax + orl $8388608, %ebx + xorl %edx, %edx + addl $-1, %eax + adcl $2147483647, %edx + addl $10, %ecx + shll %cl, %ebx + xorl %ecx, %ecx + subl %eax, %ecx + movl %ebx, %eax + sbbl %edx, %eax + jb ..B1.6 +..B1.10: + orl %eax, %ecx + jne ..B1.7 +..B1.6: + movl %ebx, %edx + xorl %eax, %eax + negl %edx + testl %ebp, %ebp + jne ..L2 + movl %ebx, %edx +..L2: + addl $20, %esp + popl %ebp + popl %ebx + ret +..B1.7: + call ..L3 +..L3: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L3](%eax), %eax + movl $-2147483648, %edx + movl $0, 8(%esp) + movl $-2147483648, 12(%esp) + fldl _infs@GOTOFF(%eax) + fmull _zeros@GOTOFF(%eax) + xorl %eax, %eax + fstpl (%esp) + addl $20, %esp + popl %ebp + popl %ebx + ret + .align 16,0x90 + .type llrintf,@function + .size llrintf,.-llrintf + .data +# -- End llrintf + .section .rodata, "a" + .align 4 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/llrintl.S b/external/sgx_libm/ia32/llrintl.S new file mode 100644 index 0000000000..c61248bbf7 --- /dev/null +++ b/external/sgx_libm/ia32/llrintl.S @@ -0,0 +1,339 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llrintl.c" + .text +..TXTST0: +# -- Begin llrintl + .text + .align 16,0x90 + .globl llrintl +llrintl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + movzbl 17(%ebp), %eax + movzwl 16(%ebp), %edx + andl $128, %eax + andl $32767, %edx + shrl $7, %eax + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $16445, %edx + jge ..B1.8 +..B1.2: + testl %edx, %edx + jne ..B1.6 +..B1.3: + cmpl $0, 12(%ebp) + jne ..B1.5 +..B1.4: + cmpl $0, 8(%ebp) + je ..B1.6 +..B1.5: + fldl _smallest_value_64@GOTOFF(%ecx) + fstpl 24(%esp) +..B1.6: + fldt 8(%ebp) + fistpll 40(%esp) +..B1.7: + movl 40(%esp), %eax + movl 44(%esp), %edx + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.8: + cmpl $16447, %edx + jge ..B1.35 +..B1.9: + movl %eax, %ebx + xorl %esi, %esi + addl $-1, %ebx + movl %ebx, 36(%esp) + adcl $2147483647, %esi + movl %esi, 32(%esp) + cmpl $16446, %edx + jge ..B1.21 +..B1.10: + fnstcw 20(%esp) +..B1.11: + movl 8(%ebp), %ebx + movzwl 20(%esp), %esi + movl %ebx, 12(%esp) + andl $1, %ebx + movl %ebx, 8(%esp) + andl $3072, %esi + jne ..B1.13 +..B1.12: + movl 12(%esp), %esi + movl %eax, (%esp) + movl %esi, %eax + movl 12(%ebp), %edi + movl %edi, %ebx + shll $31, %edi + andl $3, %esi + shrl $1, %eax + orl %eax, %edi + cmpl $3, %esi + movl $0, %eax + sete %al + shrl $1, %ebx + addl %eax, %edi + movl (%esp), %eax + adcl $0, %ebx + jmp ..B1.22 +..B1.13: + cmpl $2048, %esi + jne ..B1.15 +..B1.14: + xorl %ebx, %ebx + testl %eax, %eax + setne %bl + movl %ebx, (%esp) + jmp ..B1.16 +..B1.15: + movl $0, (%esp) + cmpl $1024, %esi + je ..B1.17 +..B1.16: + movl $0, 4(%esp) + jmp ..B1.18 +..B1.17: + xorl %ebx, %ebx + testl %eax, %eax + sete %bl + movl %ebx, 4(%esp) +..B1.18: + cmpl $3072, %esi + movl $0, %ebx + sete %bl + orl (%esp), %ebx + movl 12(%ebp), %edi + orl 4(%esp), %ebx + je ..B1.20 +..B1.19: + movl 12(%esp), %esi + movl %edi, %ebx + shll $31, %edi + shrl $1, %esi + shrl $1, %ebx + orl %esi, %edi + jmp ..B1.22 +..B1.20: + movl 12(%esp), %esi + movl %edi, %ebx + movl %eax, (%esp) + movl %esi, %eax + shll $31, %edi + andl $1, %esi + shrl $1, %eax + orl %eax, %edi + shrl $1, %ebx + addl %esi, %edi + movl (%esp), %eax + adcl $0, %ebx + jmp ..B1.22 +..B1.21: + movl 12(%ebp), %ebx + movl 8(%ebp), %edi + movl $0, 8(%esp) +..B1.22: + testl %eax, %eax + je ..B1.24 +..B1.23: + xorl %eax, %eax + xorl %esi, %esi + subl %edi, %eax + movl %eax, (%esp) + sbbl %ebx, %esi + movl %esi, 12(%esp) + movl %esi, 4(%esp) + jmp ..B1.25 +..B1.24: + movl %ebx, 12(%esp) + movl %edi, %eax + movl %edi, (%esp) + movl %ebx, 4(%esp) +..B1.25: + movl %eax, %esi + subl %edi, %esi + movl 12(%esp), %esi + sbbl %ebx, %esi + jb ..B1.27 +..B1.26: + movl $1, %esi + jmp ..B1.28 +..B1.27: + xorl %esi, %esi +..B1.28: + subl 36(%esp), %edi + sbbl 32(%esp), %ebx + jb ..B1.29 +..B1.46: + orl %ebx, %edi + jne ..B1.30 +..B1.29: + movl $1, %ebx + jmp ..B1.31 +..B1.30: + xorl %ebx, %ebx +..B1.31: + testl %ebx, %esi + je ..B1.35 +..B1.32: + cmpl $0, 8(%esp) + je ..B1.34 +..B1.33: + fldl _ones@GOTOFF(%ecx) + movl (%esp), %eax + movl 4(%esp), %edx + movl %eax, 40(%esp) + movl %edx, 44(%esp) + movl %edx, 12(%esp) + faddl _small_value_64@GOTOFF(%ecx) + fstpl 24(%esp) +..B1.34: + movl 12(%esp), %edx + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.35: + fldl _infs@GOTOFF(%ecx) + cmpl $32767, %edx + fmull _zeros@GOTOFF(%ecx) + fstpl 24(%esp) + movl $0, 40(%esp) + movl $-2147483648, 44(%esp) + jne ..B1.38 +..B1.36: + cmpl $-2147483648, 12(%ebp) + jne ..B1.43 +..B1.37: + cmpl $0, 8(%ebp) + jne ..B1.43 +..B1.38: + fnstcw 18(%esp) +..B1.39: + movzwl 18(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.40: + orl $-64768, %edx + movw %dx, 16(%esp) +..B1.41: + fldcw 16(%esp) +..B1.42: + fldcw 18(%esp) +..B1.43: + movl 40(%esp), %eax + movl 44(%esp), %edx + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type llrintl,@function + .size llrintl,.-llrintl + .data +# -- End llrintl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/llround_wmt.S b/external/sgx_libm/ia32/llround_wmt.S new file mode 100644 index 0000000000..a4f36ea8bf --- /dev/null +++ b/external/sgx_libm/ia32/llround_wmt.S @@ -0,0 +1,239 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llround_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin llround + .text + .align 16,0x90 + .globl llround +llround: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movsd %xmm0, 16(%esp) + pextrw $3, %xmm0, %eax + movl $32767, %edx + andl %eax, %edx + cmpl $17200, %edx + jge .L_2TAG_PACKET_0.0.3 + cmpl $16368, %edx + jl .L_2TAG_PACKET_1.0.3 + movapd %xmm0, %xmm5 + movapd 112(%ebx), %xmm4 + pxor %xmm6, %xmm6 + pand %xmm0, %xmm4 + movapd %xmm0, %xmm1 + psrlq $52, %xmm0 + cmpltsd %xmm6, %xmm5 + pand 64(%ebx), %xmm0 + movss 80(%ebx), %xmm2 + movss 96(%ebx), %xmm3 + pcmpeqd %xmm6, %xmm6 + psubd %xmm0, %xmm2 + psubd %xmm0, %xmm3 + psrlq %xmm3, %xmm1 + por 128(%ebx), %xmm4 + pand 144(%ebx), %xmm1 + psrlq %xmm2, %xmm4 + pxor %xmm5, %xmm6 + paddq %xmm1, %xmm4 + pand %xmm4, %xmm5 + pand %xmm4, %xmm6 + psubq %xmm5, %xmm6 + movd %xmm6, %eax + psrlq $32, %xmm6 + movd %xmm6, %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + comisd 16(%ebx), %xmm0 + jc .L_2TAG_PACKET_3.0.3 + comisd (%ebx), %xmm0 + jnc .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_4.0.3: + fldl 16(%esp) + subl $8, %esp + fistpll (%esp) + popl %eax + popl %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + subl $16352, %edx + xorl $32768, %eax + movl $1, %ecx + shrl $31, %edx + shrl $15, %eax + xorl %edx, %ecx + orl %eax, %edx + andl %ecx, %eax + shll $31, %ecx + addl %edx, %eax + movl 20(%esp), %edx + subl $1, %eax + andl %ecx, %edx + sarl $31, %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + jp .L_2TAG_PACKET_5.0.3 + pcmpeqd %xmm1, %xmm1 + pslld $23, %xmm1 + subss %xmm1, %xmm1 + movl $0, (%esp) + movl $-2147483648, 4(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $194, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movl (%esp), %eax + movl 4(%esp), %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_5.0.3: + movl $-2147483648, %edx + movl $0, %eax +.L_2TAG_PACKET_2.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type llround,@function + .size llround,.-llround + .data +# -- End llround + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1138753536 + .long 0 + .long 1138753536 + .long 0 + .long 3286237184 + .long 0 + .long 3286237184 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 2047 + .long 0 + .long 2047 + .long 0 + .long 1075 + .long 1075 + .long 1075 + .long 1075 + .long 1074 + .long 1074 + .long 1074 + .long 1074 + .long 4294967295 + .long 1048575 + .long 0 + .long 0 + .long 0 + .long 1048576 + .long 0 + .long 0 + .long 1 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,160 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/llroundf_wmt.S b/external/sgx_libm/ia32/llroundf_wmt.S new file mode 100644 index 0000000000..a32aa8225e --- /dev/null +++ b/external/sgx_libm/ia32/llroundf_wmt.S @@ -0,0 +1,195 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llroundf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin llroundf + .text + .align 16,0x90 + .globl llroundf +llroundf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movss 128(%esp), %xmm0 + movss %xmm0, 16(%esp) + movl 16(%esp), %eax + movl $2147483647, %edx + andl %eax, %edx + cmpl $1258291200, %edx + jge .L_2TAG_PACKET_0.0.3 + cmpl $1065353216, %edx + jl .L_2TAG_PACKET_1.0.3 + shrl $23, %edx + movl $149, %ecx + subl %edx, %ecx + movl $8388607, %edx + andl %eax, %edx + shrl %cl, %eax + orl $8388608, %edx + andl $1, %eax + shrl %cl, %edx + movl $-2147483648, %ecx + shrl $1, %edx + xorl 16(%esp), %ecx + addl %edx, %eax + movl 16(%esp), %edx + sarl $31, %ecx + sarl $31, %edx + andl %eax, %edx + andl %ecx, %eax + subl %edx, %eax + movl 16(%esp), %edx + sarl $31, %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + cmpl $-553648128, %eax + ja .L_2TAG_PACKET_3.0.3 + cmpl $1593835520, %eax + jge .L_2TAG_PACKET_3.0.3 + flds 16(%esp) + subl $8, %esp + fistpll (%esp) + popl %eax + popl %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + ucomiss %xmm0, %xmm0 + subl $1056964608, %edx + xorl $-2147483648, %eax + movl $1, %ecx + shrl $31, %edx + shrl $31, %eax + xorl %edx, %ecx + orl %eax, %edx + andl %ecx, %eax + addl %edx, %eax + movl $-1, %edx + addl %eax, %edx + subl $1, %eax + sarl $31, %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + comiss %xmm0, %xmm0 + jp .L_2TAG_PACKET_4.0.3 + pcmpeqd %xmm1, %xmm1 + pslld $23, %xmm1 + subss %xmm1, %xmm1 + movl $-2147483648, (%esp) + movl $0, 4(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $194, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movl (%esp), %eax + movl 4(%esp), %edx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + movl $-2147483648, %eax +.L_2TAG_PACKET_2.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type llroundf,@function + .size llroundf,.-llroundf + .data +# -- End llroundf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .type static_const_table,@object + .size static_const_table,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/llroundl.S b/external/sgx_libm/ia32/llroundl.S new file mode 100644 index 0000000000..a414b2823b --- /dev/null +++ b/external/sgx_libm/ia32/llroundl.S @@ -0,0 +1,383 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llroundl.c" + .text +..TXTST0: +# -- Begin llroundl + .text + .align 16,0x90 + .globl llroundl +llroundl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp + movzbl 17(%ebp), %ebx + movzwl 16(%ebp), %eax + andl $128, %ebx + andl $32767, %eax + shrl $7, %ebx + call ..L2 +..L2: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edi), %edi + cmpl $16445, %eax + jge ..B1.17 +..B1.2: + cmpl $16415, %eax + jge ..B1.16 +..B1.3: + cmpl $16414, %eax + jge ..B1.15 +..B1.4: + cmpl $16413, %eax + jge ..B1.14 +..B1.5: + cmpl $16383, %eax + jge ..B1.13 +..B1.6: + cmpl $16382, %eax + jge ..B1.12 +..B1.7: + testl %eax, %eax + jne ..B1.11 +..B1.8: + cmpl $0, 12(%ebp) + jne ..B1.10 +..B1.9: + cmpl $0, 8(%ebp) + je ..B1.11 +..B1.10: + fldl _smallest_value_64@GOTOFF(%edi) + fstpl 8(%esp) +..B1.11: + xorl %eax, %eax + xorl %edx, %edx + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.12: + movl iones@GOTOFF(%edi,%ebx,4), %eax + cltd + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + negl %eax + movl 12(%ebp), %esi + movl %esi, %edi + lea 30(%eax), %ecx + addl $29, %eax + shrl %cl, %edi + movl %eax, %ecx + shrl %cl, %esi + andl $1, %esi + addl %esi, %edi + movl %edi, %eax + negl %eax + testl %ebx, %ebx + jne ..L3 + movl %edi, %eax +..L3: + cltd + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + negl %eax + addl $30, %eax + movl 12(%ebp), %edx + movl %edx, %esi + movl %eax, %ecx + andl $1, %esi + shrl %cl, %edx + xorl %eax, %eax + addl %edx, %esi + xorl %edx, %edx + subl %esi, %eax + sbbl $0, %edx + testl %ebx, %ebx + jne ..L4 + movl %esi, %eax +..L4: + jne ..L5 + movl $0, %edx +..L5: + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + movl 8(%ebp), %ecx + xorl %esi, %esi + shrl $31, %ecx + xorl %eax, %eax + addl 12(%ebp), %ecx + adcl $0, %esi + xorl %edx, %edx + subl %ecx, %eax + sbbl %esi, %edx + testl %ebx, %ebx + jne ..L6 + movl %ecx, %eax +..L6: + jne ..L7 + movl %esi, %edx +..L7: + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + movl %eax, %esi + addl $2, %eax + negl %esi + movl 12(%ebp), %edi + movl %esi, (%esp) + lea 30(%esi), %edx + movl %edi, %esi + movl %edx, %ecx + shrl %cl, %esi + movl %eax, %ecx + shll %cl, %edi + movl %edx, %ecx + movl 8(%ebp), %edx + movl %edx, %eax + shrl %cl, %eax + movl (%esp), %ecx + orl %eax, %edi + addl $29, %ecx + xorl %eax, %eax + shrl %cl, %edx + andl $1, %edx + addl %edx, %edi + adcl $0, %esi + xorl %edx, %edx + subl %edi, %eax + sbbl %esi, %edx + testl %ebx, %ebx + jne ..L8 + movl %edi, %eax +..L8: + jne ..L9 + movl %esi, %edx +..L9: + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + cmpl $16447, %eax + jge ..B1.29 +..B1.18: + movl %ebx, %edx + xorl %esi, %esi + addl $-1, %edx + movl %edx, 20(%esp) + adcl $2147483647, %esi + movl %esi, 16(%esp) + cmpl $16446, %eax + movl 12(%ebp), %edx + movl 8(%ebp), %esi + jge ..B1.21 +..B1.19: + movl %ebx, (%esp) + movl %esi, %ebx + shrl $1, %ebx + movl %edx, %ecx + shll $31, %edx + andl $1, %esi + orl %ebx, %edx + shrl $1, %ecx + addl %edx, %esi + movl %ecx, %edx + movl (%esp), %ebx + adcl $0, %edx +..B1.21: + xorl %ecx, %ecx + subl %esi, %ecx + movl %eax, 28(%esp) + movl $0, %eax + sbbl %edx, %eax + testl %ebx, %ebx + jne ..L10 + movl %esi, %ecx +..L10: + jne ..L11 + movl %edx, %eax +..L11: + movl %ecx, 24(%esp) + subl %esi, %ecx + movl %eax, (%esp) + sbbl %edx, %eax + movl 28(%esp), %eax + jb ..B1.23 +..B1.22: + movl $1, %ebx + jmp ..B1.24 +..B1.23: + xorl %ebx, %ebx +..B1.24: + subl 20(%esp), %esi + sbbl 16(%esp), %edx + jb ..B1.25 +..B1.40: + orl %edx, %esi + jne ..B1.26 +..B1.25: + movl $1, %edx + jmp ..B1.27 +..B1.26: + xorl %edx, %edx +..B1.27: + testl %edx, %ebx + je ..B1.29 +..B1.28: + movl 24(%esp), %eax + movl (%esp), %edx + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + fldl _infs@GOTOFF(%edi) + cmpl $32767, %eax + fmull _zeros@GOTOFF(%edi) + fstpl 8(%esp) + jne ..B1.32 +..B1.30: + cmpl $-2147483648, 12(%ebp) + jne ..B1.37 +..B1.31: + cmpl $0, 8(%ebp) + jne ..B1.37 +..B1.32: + fnstcw 6(%esp) +..B1.33: + movzwl 6(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.37 +..B1.34: + orl $-64768, %edx + movw %dx, 4(%esp) +..B1.35: + fldcw 4(%esp) +..B1.36: + fldcw 6(%esp) +..B1.37: + xorl %eax, %eax + movl $-2147483648, %edx + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type llroundl,@function + .size llroundl,.-llroundl + .data +# -- End llroundl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log10_wmt.S b/external/sgx_libm/ia32/log10_wmt.S new file mode 100644 index 0000000000..741ba00edf --- /dev/null +++ b/external/sgx_libm/ia32/log10_wmt.S @@ -0,0 +1,815 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin log10 + .text + .align 16,0x90 + .globl log10 +log10: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movl $1054736384, %ecx + movd %ecx, %xmm7 + xorpd %xmm3, %xmm3 + movl $30704, %edx + pinsrw $3, %edx, %xmm3 + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm1 + movl $32768, %edx + movd %edx, %xmm4 + movapd 2128(%ebx), %xmm5 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $16352, %ecx + psllq $5, %xmm0 + movsd 2144(%ebx), %xmm2 + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + mulss %xmm7, %xmm0 + orpd %xmm3, %xmm1 + andpd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + subsd %xmm5, %xmm1 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm6, %xmm0 + andl $32752, %eax + subl %ecx, %eax + cvtsi2sdl %eax, %xmm7 + mulpd %xmm0, %xmm5 + mulsd %xmm0, %xmm1 + movsd 2064(%ebx), %xmm6 + movapd 2080(%ebx), %xmm3 + subsd %xmm2, %xmm5 + andl $16711680, %edx + shrl $12, %edx + movapd -1504(%ebx,%edx), %xmm0 + movapd 2096(%ebx), %xmm4 + addsd %xmm5, %xmm1 + movapd 2112(%ebx), %xmm2 + mulsd %xmm7, %xmm6 + pshufd $68, %xmm1, %xmm5 + mulsd 2072(%ebx), %xmm7 + mulsd %xmm1, %xmm3 + addsd %xmm6, %xmm0 + mulpd %xmm5, %xmm4 + movsd 2152(%ebx), %xmm6 + mulpd %xmm5, %xmm5 + addpd %xmm2, %xmm4 + mulpd %xmm5, %xmm3 + pshufd $228, %xmm0, %xmm2 + addsd %xmm1, %xmm0 + mulsd %xmm1, %xmm4 + subsd %xmm0, %xmm2 + mulsd %xmm1, %xmm6 + addsd %xmm2, %xmm1 + pshufd $238, %xmm0, %xmm2 + mulsd %xmm5, %xmm5 + addsd %xmm2, %xmm7 + addsd %xmm6, %xmm1 + addpd %xmm3, %xmm4 + addsd %xmm7, %xmm1 + mulpd %xmm5, %xmm4 + addsd %xmm4, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm1 + addl $16, %eax + cmpl $32768, %eax + jae .L_2TAG_PACKET_3.0.3 + cmpl $16, %eax + jb .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + ja .L_2TAG_PACKET_5.0.3 + cmpl $0, %edx + ja .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_3.0.3: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + addl %ecx, %ecx + cmpl $-2097152, %ecx + jae .L_2TAG_PACKET_6.0.3 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_7.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + movl $9, %edx + mulsd %xmm1, %xmm0 +.L_2TAG_PACKET_9.0.3: + movsd %xmm0, (%esp) + movsd 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_10.0.3 +.L_2TAG_PACKET_8.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + divsd %xmm1, %xmm0 + movl $8, %edx + jmp .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_4.0.3: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_8.0.3 + xorpd %xmm1, %xmm1 + movl $18416, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movapd %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $18416, %ecx + psllq $5, %xmm0 + movsd 2144(%ebx), %xmm2 + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_10.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type log10,@function + .size log10,.-log10 + .data +# -- End log10 + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1352628224 + .long 1070810131 + .long 521319256 + .long 1025503025 + .long 2150839296 + .long 1070801944 + .long 3329350096 + .long 3170190015 + .long 1360613376 + .long 1070793794 + .long 2024059075 + .long 1024991594 + .long 1875350528 + .long 1070785680 + .long 2163882141 + .long 3163564137 + .long 2312126464 + .long 1070777602 + .long 1975711076 + .long 1023674196 + .long 1306336256 + .long 1070769560 + .long 3524899523 + .long 3170508164 + .long 1806334976 + .long 1070761553 + .long 4254777025 + .long 1025238739 + .long 2483193856 + .long 1070753581 + .long 3800671317 + .long 3172916830 + .long 2025350144 + .long 1070745644 + .long 1731514745 + .long 1025501083 + .long 3433285632 + .long 1070737741 + .long 2551857336 + .long 3169662186 + .long 1134317568 + .long 1070729873 + .long 3426297655 + .long 3172637891 + .long 2457152512 + .long 1070722038 + .long 63549415 + .long 1025415416 + .long 1861803008 + .long 1070714237 + .long 1910171636 + .long 1023977580 + .long 2414140416 + .long 1070706469 + .long 4002514337 + .long 3170841618 + .long 2900726784 + .long 1070698734 + .long 3268064083 + .long 1022459609 + .long 2123517952 + .long 1070691032 + .long 1767031218 + .long 1022448156 + .long 3194569728 + .long 1070683362 + .long 3402332618 + .long 3171671160 + .long 650882048 + .long 1070675725 + .long 4146023905 + .long 3171023038 + .long 1928988672 + .long 1070668119 + .long 1438617867 + .long 1016360491 + .long 1594908672 + .long 1070660545 + .long 971389377 + .long 1024763979 + .long 2818746368 + .long 1070653002 + .long 3555925341 + .long 3172434821 + .long 194584576 + .long 1070645491 + .long 943919215 + .long 3172950063 + .long 1215096832 + .long 1070638010 + .long 2283358588 + .long 1022335098 + .long 501519360 + .long 1070630560 + .long 480904295 + .long 1024437959 + .long 1278266368 + .long 1070623140 + .long 2755806066 + .long 3172342012 + .long 2487812096 + .long 1070615750 + .long 2489653202 + .long 3172481099 + .long 3085451264 + .long 1070608390 + .long 3759184951 + .long 3172574892 + .long 2039090176 + .long 1070601060 + .long 1361176676 + .long 3172355319 + .long 953057280 + .long 1070591423 + .long 1176587546 + .long 3166422018 + .long 3370524672 + .long 1070576879 + .long 3669570051 + .long 1025376630 + .long 749742080 + .long 1070562394 + .long 707700964 + .long 3170814058 + .long 4008353792 + .long 1070547965 + .long 3247327652 + .long 1022431400 + .long 2612455424 + .long 1070533594 + .long 2453457344 + .long 3172322969 + .long 3230920704 + .long 1070519279 + .long 1296781801 + .long 1025115335 + .long 3965253632 + .long 1070505020 + .long 373075289 + .long 1017938528 + .long 2593157120 + .long 1070476669 + .long 1068054086 + .long 1021616576 + .long 925962240 + .long 1070448537 + .long 850121213 + .long 1023928989 + .long 1732556800 + .long 1070420620 + .long 1305206740 + .long 3172665570 + .long 3815630848 + .long 1070392915 + .long 192642943 + .long 3172699907 + .long 2001758208 + .long 1070365420 + .long 2820786683 + .long 1024704867 + .long 16746496 + .long 1070338131 + .long 1399573110 + .long 3171372773 + .long 1886492672 + .long 1070311044 + .long 3621428075 + .long 3172974358 + .long 3338196992 + .long 1070284157 + .long 3793882035 + .long 1025124701 + .long 381769728 + .long 1070257468 + .long 3877933342 + .long 3170195490 + .long 2186491904 + .long 1070230972 + .long 1838687089 + .long 1017927292 + .long 1008330752 + .long 1070204668 + .long 2228321664 + .long 1025352196 + .long 2247065600 + .long 1070178552 + .long 1413900906 + .long 3170902532 + .long 2964070400 + .long 1070152622 + .long 3590454629 + .long 1025016844 + .long 465154048 + .long 1070126876 + .long 2079688550 + .long 3172268183 + .long 883615744 + .long 1070101310 + .long 989244452 + .long 3171900485 + .long 1993768960 + .long 1070075922 + .long 1124327841 + .long 3172964992 + .long 1794471936 + .long 1070050710 + .long 1140575046 + .long 1022673726 + .long 2797932544 + .long 1070025671 + .long 1894836933 + .long 3172544059 + .long 3433797632 + .long 1070000803 + .long 3221831166 + .long 3171921685 + .long 2338371584 + .long 1069976104 + .long 3732461053 + .long 3164513518 + .long 2644013056 + .long 1069951571 + .long 2519460462 + .long 3172548740 + .long 3383814144 + .long 1069927202 + .long 2290997657 + .long 1025499649 + .long 3781380096 + .long 1069902995 + .long 380479405 + .long 1025184136 + .long 3245785088 + .long 1069878948 + .long 1096398261 + .long 3169885192 + .long 1366712320 + .long 1069855059 + .long 2218343715 + .long 3170281628 + .long 2204717056 + .long 1069831325 + .long 2668334011 + .long 1025264524 + .long 1401772032 + .long 1069807745 + .long 4103993159 + .long 1022925721 + .long 3356721152 + .long 1069784316 + .long 3573790772 + .long 3172186527 + .long 4041148416 + .long 1069761037 + .long 4027691910 + .long 3171276990 + .long 3880151040 + .long 1069737906 + .long 4087118786 + .long 3172710734 + .long 3453364224 + .long 1069714921 + .long 99014299 + .long 3172003077 + .long 3491092480 + .long 1069692080 + .long 3801836701 + .long 3172989287 + .long 575580160 + .long 1069669382 + .long 1920406012 + .long 3170874125 + .long 22282240 + .long 1069646824 + .long 964193370 + .long 1019363159 + .long 2991429632 + .long 1069624404 + .long 3372589890 + .long 1023425053 + .long 2189645824 + .long 1069602122 + .long 2610503872 + .long 1023652442 + .long 3341467648 + .long 1069579975 + .long 1190292004 + .long 1022425665 + .long 3711293440 + .long 1069557962 + .long 1104795356 + .long 1023625829 + .long 1380401152 + .long 1069524644 + .long 1156998217 + .long 1025100499 + .long 765710336 + .long 1069481144 + .long 1736649113 + .long 1024999439 + .long 849412096 + .long 1069437902 + .long 2618178330 + .long 3170853629 + .long 1433104384 + .long 1069394915 + .long 43477267 + .long 3170378811 + .long 2548596736 + .long 1069352180 + .long 3967367063 + .long 1025246584 + .long 157577216 + .long 1069309695 + .long 100402533 + .long 3172825502 + .long 3326238720 + .long 1069267455 + .long 1176892909 + .long 1025464099 + .long 4155494400 + .long 1069225459 + .long 3713707617 + .long 3172630046 + .long 3545804800 + .long 1069183704 + .long 857007315 + .long 1024965777 + .long 2602520576 + .long 1069142187 + .long 2588758347 + .long 1022463131 + .long 2631196672 + .long 1069100905 + .long 2118424235 + .long 1022490989 + .long 838135808 + .long 1069059856 + .long 4117002727 + .long 1024874520 + .long 3210903552 + .long 1069019036 + .long 650070125 + .long 3172012966 + .long 3039211520 + .long 1068978444 + .long 438055812 + .long 1017743757 + .long 2385633280 + .long 1068938077 + .long 3011990369 + .long 3171312044 + .long 3491618816 + .long 1068897932 + .long 712813818 + .long 3172720400 + .long 183644160 + .long 1068858008 + .long 4287006742 + .long 1022379728 + .long 3639214080 + .long 1068818300 + .long 353762279 + .long 3172980009 + .long 3728416768 + .long 1068778808 + .long 1851367730 + .long 1025486574 + .long 3370094592 + .long 1068739529 + .long 4046594913 + .long 3172567047 + .long 1348407296 + .long 1068700461 + .long 143189675 + .long 1025397632 + .long 899403776 + .long 1068661601 + .long 3753687842 + .long 3170772772 + .long 1117708288 + .long 1068622947 + .long 1857340812 + .long 3170782678 + .long 1248276480 + .long 1068584497 + .long 1289858203 + .long 1025222289 + .long 683237376 + .long 1068546249 + .long 2356679608 + .long 3171629170 + .long 3253764096 + .long 1068508200 + .long 3267136556 + .long 1018554987 + .long 94478336 + .long 1068441756 + .long 1927868814 + .long 3169378180 + .long 3233144832 + .long 1068366445 + .long 2682188854 + .long 1023964004 + .long 2940297216 + .long 1068291522 + .long 275301289 + .long 1023944679 + .long 3677708288 + .long 1068216982 + .long 302658771 + .long 1024465567 + .long 1576968192 + .long 1068142822 + .long 3672035940 + .long 3172254610 + .long 1614069760 + .long 1068069037 + .long 480052905 + .long 3172692062 + .long 424435712 + .long 1067995624 + .long 2207869657 + .long 3170965436 + .long 3477782528 + .long 1067922578 + .long 2980661858 + .long 3164990018 + .long 3598401536 + .long 1067849897 + .long 1974393034 + .long 3171357083 + .long 2435235840 + .long 1067777577 + .long 1385289011 + .long 1024615823 + .long 1867333632 + .long 1067705614 + .long 3442236633 + .long 1025334384 + .long 3999301632 + .long 1067634004 + .long 3506472073 + .long 1025132546 + .long 2566971392 + .long 1067562745 + .long 1425757592 + .long 3172358463 + .long 112943104 + .long 1067491833 + .long 1693407156 + .long 3172426603 + .long 3079929856 + .long 1067392159 + .long 3999942455 + .long 1018549369 + .long 2443837440 + .long 1067251701 + .long 974534460 + .long 1023963412 + .long 359366656 + .long 1067111917 + .long 2204915018 + .long 1013514416 + .long 3564519424 + .long 1066972799 + .long 3977441659 + .long 3170879860 + .long 2011086848 + .long 1066834343 + .long 590145514 + .long 1025390011 + .long 3216982016 + .long 1066696541 + .long 3629120110 + .long 1024330313 + .long 2194128896 + .long 1066559388 + .long 2367098512 + .long 3172260338 + .long 2916220928 + .long 1066422877 + .long 2262431886 + .long 1021229446 + .long 2263941120 + .long 1066172214 + .long 3118507287 + .long 1021484970 + .long 3076292608 + .long 1065901726 + .long 1411737803 + .long 3172957147 + .long 1186136064 + .long 1065632488 + .long 3109349337 + .long 1025397383 + .long 3085303808 + .long 1065364487 + .long 584715031 + .long 3172596519 + .long 1821048832 + .long 1064842211 + .long 2182246895 + .long 3172536214 + .long 697368576 + .long 1064311094 + .long 3157561765 + .long 3172716357 + .long 894042112 + .long 1063260131 + .long 3237958154 + .long 3172587292 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1352628224 + .long 1066615827 + .long 521319256 + .long 1021308721 + .long 3248877870 + .long 1077250164 + .long 1691676429 + .long 3221787401 + .long 945132465 + .long 3223701783 + .long 3700831335 + .long 1073506818 + .long 2141010593 + .long 1075227551 + .long 3698831637 + .long 3220339442 + .long 4160749568 + .long 4294967295 + .long 0 + .long 4294959104 + .long 0 + .long 1071366144 + .long 3207479560 + .long 1062894188 + .type static_const_table,@object + .size static_const_table,2160 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log10f_wmt.S b/external/sgx_libm/ia32/log10f_wmt.S new file mode 100644 index 0000000000..083ec694e1 --- /dev/null +++ b/external/sgx_libm/ia32/log10f_wmt.S @@ -0,0 +1,745 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10f_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin log10f + .text + .align 16,0x90 + .globl log10f +log10f: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl $16384, %ecx + movd %ecx, %xmm4 + movl $-32768, %eax + movd %eax, %xmm2 + xorpd %xmm3, %xmm3 + movl $16368, %edx + pinsrw $3, %edx, %xmm3 + xorpd %xmm5, %xmm5 +.L_2TAG_PACKET_0.0.3: + movd %xmm0, %edx + rcpss %xmm0, %xmm1 + movsd 2080(%ebx), %xmm7 + pshuflw $68, %xmm0, %xmm0 + paddd %xmm4, %xmm1 + subl $8388608, %edx + cmpl $2113929216, %edx + jae .L_2TAG_PACKET_1.0.3 + andps %xmm1, %xmm2 + cvtps2pd %xmm0, %xmm0 + cvtps2pd %xmm2, %xmm1 + movd %xmm2, %eax + andl $-8388608, %edx + subl $1056964608, %edx + cvtsi2sdl %edx, %xmm6 + mulsd %xmm1, %xmm0 + subl $1056964608, %edx + addl %edx, %eax + shrl $12, %eax + movsd (%ebx,%eax), %xmm4 + subsd %xmm3, %xmm0 + movsd 2088(%ebx), %xmm2 + movsd 2096(%ebx), %xmm1 + mulsd %xmm0, %xmm7 + addsd %xmm0, %xmm5 + mulsd %xmm0, %xmm0 + movsd 2104(%ebx), %xmm3 + mulsd %xmm2, %xmm6 + addsd %xmm7, %xmm1 + mulsd %xmm3, %xmm5 + addsd %xmm4, %xmm6 + mulsd %xmm1, %xmm0 + mulsd %xmm3, %xmm0 + addsd %xmm6, %xmm5 + addsd %xmm0, %xmm5 + cvtpd2ps %xmm5, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + addl $8388608, %edx + js .L_2TAG_PACKET_3.0.3 + cmpl $8388608, %edx + jb .L_2TAG_PACKET_4.0.3 + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_5.0.3 + movl $528482304, %eax + movd %eax, %xmm6 + movsd 2064(%ebx), %xmm5 + mulss %xmm6, %xmm0 + jmp .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_5.0.3: + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $-2147483648, %edx + je .L_2TAG_PACKET_6.0.3 + addl %edx, %edx + cmpl $-16777216, %edx + ja .L_2TAG_PACKET_5.0.3 + xorps %xmm0, %xmm0 + divss %xmm0, %xmm0 + movl $11, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $0, %edx + je .L_2TAG_PACKET_6.0.3 + movl $1602224128, %eax + movd %eax, %xmm7 + mulss %xmm7, %xmm0 + movsd 2072(%ebx), %xmm5 + jmp .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_6.0.3: + movl $-1082130432, %eax + movd %eax, %xmm0 + xorps %xmm1, %xmm1 + divss %xmm1, %xmm0 + movl $10, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_2.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type log10f,@function + .size log10f,.-log10f + .data +# -- End log10f + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1352628734 + .long 1070810131 + .long 2987063119 + .long 1070803029 + .long 2814064164 + .long 1070795955 + .long 4212141943 + .long 1070788908 + .long 1980466875 + .long 1070781889 + .long 3813543508 + .long 1070774896 + .long 236279882 + .long 1070767931 + .long 3258536649 + .long 1070760991 + .long 3425300546 + .long 1070754078 + .long 4176272103 + .long 1070747191 + .long 370881335 + .long 1070740331 + .long 4057946465 + .long 1070733495 + .long 1525858624 + .long 1070726686 + .long 547082415 + .long 1070719902 + .long 313247743 + .long 1070713143 + .long 24949840 + .long 1070706409 + .long 3186584478 + .long 1070699699 + .long 426349118 + .long 1070693015 + .long 3855853989 + .long 1070686354 + .long 4120324153 + .long 1070679718 + .long 463247870 + .long 1070673107 + .long 726256111 + .long 1070666519 + .long 4169135061 + .long 1070659954 + .long 1469709924 + .long 1070653414 + .long 493534586 + .long 1070646897 + .long 523975765 + .long 1070640403 + .long 852037507 + .long 1070633932 + .long 776253054 + .long 1070627484 + .long 3897545900 + .long 1070621058 + .long 939256246 + .long 1070614656 + .long 4106776832 + .long 1070608275 + .long 4137779223 + .long 1070601917 + .long 733771778 + .long 1070595068 + .long 1451145848 + .long 1070582440 + .long 534475932 + .long 1070569856 + .long 988918143 + .long 1070557315 + .long 1537935568 + .long 1070544817 + .long 918084032 + .long 1070532362 + .long 2173800955 + .long 1070519949 + .long 4067295355 + .long 1070507578 + .long 1078375409 + .long 1070495250 + .long 584148105 + .long 1070482963 + .long 1384016078 + .long 1070470717 + .long 2289448314 + .long 1070458512 + .long 2123818995 + .long 1070446348 + .long 4017216324 + .long 1070434224 + .long 2521384792 + .long 1070422141 + .long 789441093 + .long 1070410098 + .long 1985788785 + .long 1070398094 + .long 696035438 + .long 1070386130 + .long 106715969 + .long 1070374205 + .long 3415214590 + .long 1070362318 + .long 944721792 + .long 1070350471 + .long 208866570 + .long 1070338662 + .long 141776059 + .long 1070326891 + .long 3982843004 + .long 1070315157 + .long 2096724351 + .long 1070303462 + .long 2037982183 + .long 1070291804 + .long 2781151897 + .long 1070280183 + .long 3310550777 + .long 1070268599 + .long 2620153983 + .long 1070257052 + .long 4008439778 + .long 1070245541 + .long 2193367512 + .long 1070234067 + .long 492128552 + .long 1070222629 + .long 2231095287 + .long 1070211226 + .long 2155771957 + .long 1070199859 + .long 3610551033 + .long 1070188527 + .long 1358732975 + .long 1070177231 + .long 3057253384 + .long 1070165969 + .long 3486771566 + .long 1070154742 + .long 1731433722 + .long 1070143550 + .long 1178768569 + .long 1070132392 + .long 929649969 + .long 1070121268 + .long 93163010 + .long 1070110178 + .long 2081471614 + .long 1070099121 + .long 1724818481 + .long 1070088098 + .long 2451297579 + .long 1070077108 + .long 3401857016 + .long 1070066151 + .long 3725172527 + .long 1070055227 + .long 2577555067 + .long 1070044336 + .long 3417827070 + .long 1070033477 + .long 1122330889 + .long 1070022651 + .long 3459676923 + .long 1070011856 + .long 1025885499 + .long 1070001094 + .long 1604039477 + .long 1069990363 + .long 99428678 + .long 1069979664 + .long 14303095 + .long 1069968996 + .long 562888951 + .long 1069958359 + .long 966275143 + .long 1069947753 + .long 452333559 + .long 1069937178 + .long 2550607841 + .long 1069926633 + .long 2207334103 + .long 1069916119 + .long 2965233831 + .long 1069905635 + .long 4078536805 + .long 1069895181 + .long 512906990 + .long 1069884758 + .long 125238661 + .long 1069874364 + .long 2188747907 + .long 1069863999 + .long 1687868933 + .long 1069853664 + .long 2203085958 + .long 1069843358 + .long 3025962321 + .long 1069833081 + .long 3454039745 + .long 1069822833 + .long 2790771261 + .long 1069812614 + .long 345455060 + .long 1069802424 + .long 4023103876 + .long 1069792261 + .long 259609597 + .long 1069782128 + .long 1266320102 + .long 1069772022 + .long 2080303760 + .long 1069761944 + .long 2039124234 + .long 1069751894 + .long 485812347 + .long 1069741872 + .long 1063773386 + .long 1069731877 + .long 3126793337 + .long 1069721909 + .long 1738980508 + .long 1069711969 + .long 559609852 + .long 1069702056 + .long 3253131575 + .long 1069692169 + .long 604213228 + .long 1069682310 + .long 582455508 + .long 1069672477 + .long 2572533957 + .long 1069662670 + .long 1669112468 + .long 1069652890 + .long 1561692097 + .long 1069643136 + .long 1649656812 + .long 1069633408 + .long 1337189125 + .long 1069623706 + .long 33219107 + .long 1069614030 + .long 1446341380 + .long 1069604379 + .long 699863590 + .long 1069594754 + .long 1511626603 + .long 1069585154 + .long 3309054272 + .long 1069575579 + .long 1229105731 + .long 1069566030 + .long 3298097489 + .long 1069556505 + .long 733771778 + .long 1069546492 + .long 941119219 + .long 1069527542 + .long 1822213925 + .long 1069508641 + .long 2284546201 + .long 1069489789 + .long 1244064507 + .long 1069470986 + .long 1920055672 + .long 1069452231 + .long 3245124337 + .long 1069433524 + .long 4160075380 + .long 1069414865 + .long 3613830132 + .long 1069396254 + .long 563343667 + .long 1069377691 + .long 2563457724 + .long 1069359174 + .long 4291983602 + .long 1069340704 + .long 434524432 + .long 1069322282 + .long 2864265762 + .long 1069303905 + .long 1987192266 + .long 1069285575 + .long 1101749477 + .long 1069267291 + .long 3513866209 + .long 1069249052 + .long 3946945232 + .long 1069230859 + .long 1426691339 + .long 1069212712 + .long 3576005763 + .long 1069194609 + .long 845110406 + .long 1069176552 + .long 871215109 + .long 1069158539 + .long 2708643652 + .long 1069140570 + .long 1123731696 + .long 1069122646 + .long 3774627455 + .long 1069104765 + .long 1146452958 + .long 1069086929 + .long 910975575 + .long 1069069136 + .long 2156738207 + .long 1069051386 + .long 3978928660 + .long 1069033679 + .long 1184347907 + .long 1069016016 + .long 1471215619 + .long 1068998395 + .long 3954270793 + .long 1068980816 + .long 3459676923 + .long 1068963280 + .long 3409862493 + .long 1068945786 + .long 2938558446 + .long 1068928334 + .long 1185705548 + .long 1068910924 + .long 1592362480 + .long 1068893555 + .long 3310712728 + .long 1068876227 + .long 1204006778 + .long 1068858941 + .long 3026374165 + .long 1068841695 + .long 3652963247 + .long 1068824490 + .long 2259754590 + .long 1068807326 + .long 2323505846 + .long 1068790202 + .long 3031762664 + .long 1068773118 + .long 3577772136 + .long 1068756074 + .long 3160429577 + .long 1068739070 + .long 984225922 + .long 1068722106 + .long 554163028 + .long 1068705181 + .long 1085767694 + .long 1068688295 + .long 1800008162 + .long 1068671448 + .long 1923243906 + .long 1068654640 + .long 687176001 + .long 1068637871 + .long 1623765358 + .long 1068621140 + .long 3975249632 + .long 1068604447 + .long 2694095274 + .long 1068587793 + .long 1327852021 + .long 1068571177 + .long 3429171449 + .long 1068554598 + .long 3965826047 + .long 1068538057 + .long 2205565303 + .long 1068521554 + .long 1716070423 + .long 1068505088 + .long 3549949915 + .long 1068478374 + .long 3329575661 + .long 1068445590 + .long 1345699131 + .long 1068412880 + .long 477545290 + .long 1068380243 + .long 3613830132 + .long 1068347678 + .long 767774141 + .long 1068315187 + .long 3436756955 + .long 1068282767 + .long 1652561627 + .long 1068250420 + .long 2635998437 + .long 1068218144 + .long 732052851 + .long 1068185940 + .long 3179609247 + .long 1068153806 + .long 46600657 + .long 1068121744 + .long 2884636118 + .long 1068089751 + .long 1779250255 + .long 1068057829 + .long 4004532339 + .long 1068025976 + .long 3958279445 + .long 1067994193 + .long 341790679 + .long 1067962480 + .long 454760347 + .long 1067930835 + .long 3015335440 + .long 1067899258 + .long 2455010382 + .long 1067867750 + .long 1803457173 + .long 1067836310 + .long 4098519806 + .long 1067804937 + .long 3796209455 + .long 1067773632 + .long 3950504195 + .long 1067742394 + .long 3328378381 + .long 1067711223 + .long 704701956 + .long 1067680119 + .long 3452107772 + .long 1067649080 + .long 1771121268 + .long 1067618108 + .long 3049832979 + .long 1067587201 + .long 1799062323 + .long 1067556360 + .long 1127129613 + .long 1067525584 + .long 4149857684 + .long 1067494872 + .long 1105606892 + .long 1067464226 + .long 3134934760 + .long 1067416919 + .long 166917834 + .long 1067355883 + .long 3892547049 + .long 1067294973 + .long 3436756955 + .long 1067234191 + .long 823651223 + .long 1067173536 + .long 2386449519 + .long 1067113006 + .long 1587501031 + .long 1067052602 + .long 493004867 + .long 1066992323 + .long 1182960573 + .long 1066932168 + .long 1456087142 + .long 1066872137 + .long 3419645072 + .long 1066812229 + .long 604423097 + .long 1066752445 + .long 3734431729 + .long 1066692782 + .long 2072088478 + .long 1066633242 + .long 2072815517 + .long 1066573823 + .long 1615129006 + .long 1066514525 + .long 2885435162 + .long 1066455347 + .long 3281014557 + .long 1066390787 + .long 184567846 + .long 1066272911 + .long 930630719 + .long 1066155272 + .long 1403389293 + .long 1066037870 + .long 1806815988 + .long 1065920704 + .long 2369503088 + .long 1065803773 + .long 3344465584 + .long 1065687076 + .long 713978687 + .long 1065570613 + .long 3369253777 + .long 1065454381 + .long 1795984717 + .long 1065323547 + .long 182837330 + .long 1065092008 + .long 2643543972 + .long 1064860927 + .long 1379209260 + .long 1064630304 + .long 1522032624 + .long 1064400136 + .long 3615182786 + .long 1064036203 + .long 2033862474 + .long 1063577678 + .long 494771387 + .long 1062984042 + .long 1170198564 + .long 1061933680 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 4277811695 + .long 1078341186 + .long 4277811695 + .long 3225824834 + .long 1431655765 + .long 1070945621 + .long 1352628734 + .long 1046692883 + .long 1107282704 + .long 3219128321 + .long 354870542 + .long 1071369083 + .type static_const_table,@object + .size static_const_table,2112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log10l.S b/external/sgx_libm/ia32/log10l.S new file mode 100644 index 0000000000..806e9dc4df --- /dev/null +++ b/external/sgx_libm/ia32/log10l.S @@ -0,0 +1,921 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10l.c" + .text +..TXTST0: +# -- Begin log10l + .text + .align 16,0x90 + .globl log10l +log10l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzbl 17(%ebp), %edi + andl $128, %edi + shrl $7, %edi + movzwl 16(%ebp), %esi + movl %esi, %ebx + movl %edi, %edx + andl $32767, %ebx + shll $15, %edx + movl 12(%ebp), %eax + orl %ebx, %edx + movl %eax, %ecx + shll $16, %edx + shrl $16, %ecx + orl %ecx, %edx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $2147450880, %edx + jae ..B1.30 +..B1.4: + addl $-1073676224, %edx + cmpl $32863, %edx + ja ..B1.13 +..B1.5: + cmpl $16383, %ebx + je ..B1.40 +..B1.6: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.39 +..B1.7: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.8: + fldcw 12(%esp) +..B1.9: + movl $1, %eax +..B1.10: + fldt 8(%ebp) + testl %eax, %eax + fldl _TWO_32H@GOTOFF(%ecx) + fldt 84+_P@GOTOFF(%ecx) + fldt 60+_P@GOTOFF(%ecx) + fldt 36+_P@GOTOFF(%ecx) + fxch %st(4) + faddl 8+_ones@GOTOFF(%ecx) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fld %st(1) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(1) + fsub %st(3), %st + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 72+_P@GOTOFF(%ecx) + fmul %st(5), %st + fldt 48+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt 96+_P@GOTOFF(%ecx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.12 +..B1.11: + fldcw 14(%esp) +..B1.12: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + cmpl $16383, %ebx + jl ..B1.19 +..B1.14: + cmpl $16471, %ebx + jge ..B1.19 +..B1.15: + movl %eax, (%esp) + lea -16383(%ebx), %edi + movl $1431655766, %eax + imull %edi + sarl $31, %edi + subl %edi, %edx + lea (%edx,%edx,2), %edx + movzwl 8+_exact_values@GOTOFF(%ecx,%edx,8), %eax + andl $32767, %eax + cmpl %eax, %ebx + movl (%esp), %eax + jne ..B1.19 +..B1.16: + cmpl 4+_exact_values@GOTOFF(%ecx,%edx,8), %eax + jne ..B1.19 +..B1.17: + movl 8(%ebp), %eax + cmpl _exact_values@GOTOFF(%ecx,%edx,8), %eax + jne ..B1.19 +..B1.18: + fldt 12+_exact_values@GOTOFF(%ecx,%edx,8) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.46 +..B1.20: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.21: + fldcw 12(%esp) +..B1.22: + movzwl 16(%ebp), %esi + movl %esi, %ebx + movl $1, %edx + andl $32767, %ebx +..B1.23: + testl %ebx, %ebx + jne ..B1.26 +..B1.24: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%ecx) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _zeros@GOTOFF(%ecx) + fxch %st(1) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B1.25 + je ..B1.43 +..B1.25: + fstp %st(0) + movzwl 16(%ebp), %esi + movl %esi, %ebx + movl $-16458, %eax + andl $32767, %ebx + jmp ..B1.27 +..B1.26: + movl $-16383, %eax +..B1.27: + fldl _TWO_32H@GOTOFF(%ecx) + andl $-32768, %esi + fldt 84+_P@GOTOFF(%ecx) + orl $-49153, %esi + fldt 60+_P@GOTOFF(%ecx) + addl %eax, %ebx + movw %si, 16(%ebp) + fldt 8(%ebp) + fld %st(0) + movl 12(%ebp), %eax + fadd %st(4), %st + shrl $23, %eax + fsubp %st, %st(4) + movzbl %al, %eax + fsub %st(3), %st + flds __libm_rcp_table_256@GOTOFF(%ecx,%eax,4) + fmul %st, %st(4) + fmulp %st, %st(1) + fxch %st(3) + faddl 8+_ones@GOTOFF(%ecx) + fld %st(0) + movl %ebx, 16(%esp) + fadd %st(4), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + shll $4, %eax + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + testl %edx, %edx + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 36+_P@GOTOFF(%ecx) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 72+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 96+_P@GOTOFF(%ecx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(2) + fildl 16(%esp) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st(1), %st + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl 8+__libm_log10l_table_256@GOTOFF(%ecx,%eax) + faddp %st, %st(2) + faddl __libm_log10l_table_256@GOTOFF(%eax,%ecx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.29 +..B1.28: + fldcw 14(%esp) +..B1.29: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.30: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.55 +..B1.31: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.32: + fldcw 12(%esp) +..B1.33: + movzbl 17(%ebp), %edi + movl $1, %edx + andl $128, %edi + shrl $7, %edi +..B1.34: + testl %edi, %edi + jne ..B1.47 +..B1.35: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ecx) + fstpt (%esp) +..B1.36: + testl %edx, %edx + je ..B1.38 +..B1.37: + fldcw 14(%esp) +..B1.38: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + xorl %eax, %eax + jmp ..B1.10 +..B1.40: + cmpl $-2147483648, %eax + jne ..B1.6 +..B1.41: + cmpl $0, 8(%ebp) + jne ..B1.6 +..B1.42: + fldl _zeros@GOTOFF(%ecx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.43: + fldl 8+_ones@GOTOFF(%ecx) + testl %edx, %edx + fdivp %st, %st(1) + fstpl (%esp) + je ..B1.45 +..B1.44: + fldcw 14(%esp) +..B1.45: + fldl (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + xorl %edx, %edx + jmp ..B1.23 +..B1.47: + movzwl 16(%ebp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.50 +..B1.48: + cmpl $-2147483648, 12(%ebp) + jne ..B1.35 +..B1.49: + cmpl $0, 8(%ebp) + jne ..B1.35 + jmp ..B1.54 +..B1.50: + testl %eax, %eax + jne ..B1.54 +..B1.51: + cmpl $0, 12(%ebp) + jne ..B1.54 +..B1.52: + cmpl $0, 8(%ebp) + jne ..B1.54 +..B1.53: + fldl 8+_ones@GOTOFF(%ecx) + fdivl _zeros@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.36 +..B1.54: + fldl _infs@GOTOFF(%ecx) + fmull _zeros@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.36 +..B1.55: + xorl %edx, %edx + jmp ..B1.34 + .align 16,0x90 + .type log10l,@function + .size log10l,.-log10l + .data +# -- End log10l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xc8,0xd4,0x0e,0xee,0x0c,0x01,0x86,0xd8,0xbf,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x85,0x9a,0x20,0x9a,0xfd,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_P: + .word 23339 + .word 38197 + .word 10353 + .word 43319 + .word 16357 + .word 0 + .word 29077 + .word 14120 + .word 55465 + .word 56923 + .word 49148 + .word 0 + .word 63176 + .word 31258 + .word 15131 + .word 37949 + .word 16380 + .word 0 + .word 29577 + .word 14120 + .word 55465 + .word 56923 + .word 49147 + .word 0 + .word 61319 + .word 34328 + .word 5050 + .word 45539 + .word 16379 + .word 0 + .word 52415 + .word 26390 + .word 15131 + .word 37949 + .word 49147 + .word 0 + .word 16765 + .word 7621 + .word 20590 + .word 65056 + .word 16378 + .word 0 + .word 14162 + .word 11829 + .word 26041 + .word 56924 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 56923 + .word 16381 + .word 0 + .type _P,@object + .size _P,108 + .align 2 +_exact_values: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40000 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50000 + .word 16399 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62500 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39062 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57344 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 8192 + .word 48828 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 10240 + .word 61035 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 63744 + .word 38146 + .word 16416 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 46912 + .word 47683 + .word 16419 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45056 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 42256 + .word 59604 + .word 16422 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 59178 + .word 37252 + .word 16426 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53248 + .word 16386 + .word 0 + .word 0 + .word 32768 + .word 8436 + .word 46566 + .word 16429 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57344 + .word 16386 + .word 0 + .word 0 + .word 40960 + .word 43313 + .word 58207 + .word 16432 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 16386 + .word 0 + .word 0 + .word 1024 + .word 51647 + .word 36379 + .word 16436 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16387 + .word 0 + .word 0 + .word 50432 + .word 48174 + .word 45474 + .word 16439 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16387 + .word 0 + .word 0 + .word 30272 + .word 27450 + .word 56843 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 35304 + .word 8964 + .word 35527 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38912 + .word 16387 + .word 0 + .word 0 + .word 44130 + .word 60357 + .word 44408 + .word 16449 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16387 + .word 0 + .word 32768 + .word 6010 + .word 9911 + .word 55511 + .word 16452 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16387 + .word 0 + .word 36864 + .word 28332 + .word 30770 + .word 34694 + .word 16456 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45056 + .word 16387 + .word 0 + .word 46080 + .word 2647 + .word 5695 + .word 43368 + .word 16459 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47104 + .word 16387 + .word 0 + .word 41216 + .word 52461 + .word 7118 + .word 54210 + .word 16462 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16387 + .word 0 + .word 33952 + .word 16404 + .word 20833 + .word 33881 + .word 16466 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 16387 + .word 0 + .word 42440 + .word 36889 + .word 42425 + .word 42351 + .word 16469 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53248 + .word 16387 + .word 0 + .word 3898 + .word 62496 + .word 36647 + .word 52939 + .word 16472 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 16387 + .word 0 + .type _exact_values,@object + .size _exact_values,720 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_log10l_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log10l_table.S b/external/sgx_libm/ia32/log10l_table.S new file mode 100644 index 0000000000..61b661e651 --- /dev/null +++ b/external/sgx_libm/ia32/log10l_table.S @@ -0,0 +1,560 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10l_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_log10l_table_256 + .globl __libm_log10l_table_256 +__libm_log10l_table_256: + .long 0x45bfc000,0x3f4bd270 + .long 0xeb5a6902,0x3cc024b0 + .long 0x793a4000,0x3f64e84e + .long 0xbdc59429,0x3ccd29dc + .long 0x5ab86000,0x3f717508 + .long 0xf6df9894,0xbc6f70c9 + .long 0x9d914000,0x3f787cff + .long 0xeb029384,0x3cde94f0 + .long 0x72b8c000,0x3f7ea9d3 + .long 0x75a2920a,0xbd001bfa + .long 0x95daa000,0x3f82df9d + .long 0x77634a76,0xbcf3c705 + .long 0x72d64000,0x3f866df1 + .long 0x93609ef4,0xbcf1a833 + .long 0xef5ec000,0x3f898d79 + .long 0x7a519e99,0x3d16f7e1 + .long 0xf3f94000,0x3f8d22ad + .long 0xa10c1504,0x3d079c92 + .long 0x1d30c000,0x3f902423 + .long 0x2dcf9263,0x3cecc021 + .long 0x98898000,0x3f91f23a + .long 0x21ad4280,0xbce5b1e0 + .long 0x7b818000,0x3f93881a + .long 0x9c5111b1,0x3d0f3cbd + .long 0x1e75a000,0x3f951f6e + .long 0xaf539251,0xbcdcad0e + .long 0xe7adc000,0x3f96f2bc + .long 0x7385f0a6,0x3cf6d084 + .long 0x2cdf4000,0x3f988d36 + .long 0x41385083,0xbd04c3af + .long 0xaf014000,0x3f9a292b + .long 0x3724b270,0xbd2b3f0c + .long 0x3117c000,0x3f9bc6a0 + .long 0x667331b5,0x3d25cb86 + .long 0x7de3c000,0x3f9d6596 + .long 0x31612f8e,0xbd14f74b + .long 0x67fc4000,0x3f9f0611 + .long 0x143b6bad,0xbd0c30f3 + .long 0xe4f78000,0x3fa05409 + .long 0x5b985713,0x3ce9bb8e + .long 0x432ea000,0x3fa125d0 + .long 0x68a0dc47,0x3cf06e09 + .long 0x440d2000,0x3fa1f85d + .long 0x507c1dd7,0x3d133627 + .long 0x57496000,0x3fa2ad75 + .long 0x7f319445,0x3ce7c850 + .long 0x2a00e000,0x3fa38177 + .long 0x9d2bb1a5,0x3d080fdc + .long 0xe165a000,0x3fa45643 + .long 0xf742c845,0x3d0c2a9f + .long 0x03446000,0x3fa52bdd + .long 0x5036c404,0x3d25b862 + .long 0x6b7ec000,0x3fa5e396 + .long 0x23196824,0xbd36b572 + .long 0x47c5c000,0x3fa6baaf + .long 0x6d3e4a28,0xbd1b7614 + .long 0xe8c4c000,0x3fa773b3 + .long 0xf794b354,0x3d39e3f5 + .long 0xebee8000,0x3fa84c51 + .long 0x2cb6638b,0x3d1a2aaa + .long 0x786fc000,0x3fa906a6 + .long 0xdfffb059,0x3cecab9f + .long 0xabf00000,0x3fa9c197 + .long 0x3d6e4566,0x3d1badcf + .long 0x71218000,0x3faa9c78 + .long 0xcb03a47d,0x3d21f757 + .long 0x9c8d4000,0x3fab58c0 + .long 0x3b0fe4fe,0x3d31be11 + .long 0xbcdd4000,0x3fac15a8 + .long 0xb6d13ff4,0x3d3dbf2d + .long 0xe2c28000,0x3facd331 + .long 0x77fafd44,0x3d267bed + .long 0xd766c000,0x3fadb11e + .long 0x23c3e44c,0xbd240bcd + .long 0x9346c000,0x3fae7008 + .long 0xd4c5edca,0xbd2619d1 + .long 0xc6754000,0x3faf2f96 + .long 0xb182cded,0x3d15dbd8 + .long 0x8d450000,0x3fafefca + .long 0xcc1beb8a,0x3d2fd5cf + .long 0x83764000,0x3fb05852 + .long 0x779b9fcf,0x3cf77c3e + .long 0xaac7c000,0x3fb0b913 + .long 0xbc7f44a6,0x3d33a6ff + .long 0x4f258000,0x3fb11a29 + .long 0xb8d25b3a,0xbd360a72 + .long 0xa2698000,0x3fb16b51 + .long 0x7904e2d7,0xbd376f39 + .long 0xadacc000,0x3fb1cd03 + .long 0x084a2298,0x3d217bee + .long 0xdd776000,0x3fb22f0b + .long 0xa204f9bf,0xbd3a0ad1 + .long 0xca38e000,0x3fb2916a + .long 0xffeb8381,0xbd2c3074 + .long 0x0df76000,0x3fb2f421 + .long 0x0d443b33,0x3d18f3ef + .long 0xc3c48000,0x3fb346a6 + .long 0x15025ea7,0x3d306599 + .long 0xbc606000,0x3fb3a9fe + .long 0xa7db519f,0xbd27eca8 + .long 0x10a3c000,0x3fb3fd0c + .long 0xb6f7db46,0xbd35abc5 + .long 0xd3540000,0x3fb46107 + .long 0x813a4964,0x3d25039a + .long 0xd1696000,0x3fb4c55d + .long 0x64286476,0x3d1ff9d8 + .long 0x330c0000,0x3fb51940 + .long 0x2c505825,0x3ca5ed92 + .long 0x0ee70000,0x3fb56d62 + .long 0x06e88a06,0x3d315e58 + .long 0xcf260000,0x3fb5d2ab + .long 0xd90fb16b,0x3d378d89 + .long 0xa5dec000,0x3fb6275a + .long 0x405920cd,0xbcdfa0db + .long 0xaf26c000,0x3fb68d4e + .long 0x1d3da9e2,0x3d37ee53 + .long 0x5c54c000,0x3fb6e28c + .long 0x9d9b5afe,0xbd3d72f7 + .long 0x9665c000,0x3fb7380b + .long 0xb00e89cf,0xbd20707b + .long 0xc2790000,0x3fb78dcc + .long 0x9a7343d9,0xbd37a4ff + .long 0x2cf28000,0x3fb7f50c + .long 0xfacefdb0,0xbd45431c + .long 0xd5eb0000,0x3fb84b5f + .long 0x2b4f09ce,0xbd302851 + .long 0xbab2c000,0x3fb8a1f6 + .long 0x11e41a3e,0xbd2bb389 + .long 0x44558000,0x3fb8f8d1 + .long 0xbf96339c,0xbd1083fd + .long 0xdcd64000,0x3fb94fef + .long 0xe07d5241,0xbd4136f4 + .long 0xef314000,0x3fb9a752 + .long 0xa5e3191a,0x3d40a49e + .long 0xe7614000,0x3fb9fefa + .long 0xa1f54e0a,0xbd40902f + .long 0x325f4000,0x3fba56e8 + .long 0xec5e03cc,0x3d3c86ee + .long 0x3e298000,0x3fbaaf1b + .long 0xcb09696b,0xbd1130fe + .long 0x79c34000,0x3fbb0794 + .long 0x628b8546,0x3d495642 + .long 0x553b0000,0x3fbb6054 + .long 0xa20d3394,0x3d32f77b + .long 0x41ab8000,0x3fbbb95b + .long 0x61433066,0xbd418d39 + .long 0xb1400000,0x3fbc12a9 + .long 0xd5882f66,0xbd3f86c6 + .long 0x17380000,0x3fbc6c40 + .long 0x219900ae,0x3d45f518 + .long 0xba424000,0x3fbcb41f + .long 0x6665a718,0x3d443661 + .long 0xce734000,0x3fbd0e38 + .long 0xd0afc15d,0xbd1b04a7 + .long 0x21940000,0x3fbd689b + .long 0x80039681,0xbd2d9a08 + .long 0x2b1d0000,0x3fbdc347 + .long 0xd102c576,0x3d442ff9 + .long 0x300d8000,0x3fbe0c06 + .long 0xe391d6b6,0xbd46ba4d + .long 0x190e4000,0x3fbe6738 + .long 0x23d01c6b,0xbd1ad0ad + .long 0x0d208000,0x3fbec2b5 + .long 0xb6656ff4,0x3d2b355d + .long 0x2b938000,0x3fbf0c1c + .long 0x4980111b,0xbd37d822 + .long 0x6c9cc000,0x3fbf6821 + .long 0xd0891bcc,0x3d1c9a3b + .long 0x38184000,0x3fbfb1f6 + .long 0x16ca77f0,0x3d36f3d3 + .long 0xaf4ce000,0x3fc00742 + .long 0xee8b5696,0x3d27e0ee + .long 0x90650000,0x3fc02c64 + .long 0xe445f2fd,0x3d42d27a + .long 0xe63e2000,0x3fc05af1 + .long 0xa16f7336,0xbd4c4b92 + .long 0xea724000,0x3fc0804b + .long 0xb736f965,0xbd255d7c + .long 0xd6712000,0x3fc0af1f + .long 0x009609f5,0xbd35b214 + .long 0xa8806000,0x3fc0d4b2 + .long 0xc4dfdce2,0xbd2800b0 + .long 0xf136a000,0x3fc0fa5e + .long 0x2043a891,0x3ceb0a92 + .long 0x4fb3e000,0x3fc1299a + .long 0x26f70b35,0x3d182c63 + .long 0x6253c000,0x3fc14f80 + .long 0x44ac2d9f,0x3d1f65c1 + .long 0x5d158000,0x3fc17580 + .long 0x33b79054,0x3d2f04d6 + .long 0x637cc000,0x3fc19b9a + .long 0xe16cee25,0xbd4d6b79 + .long 0xc26ee000,0x3fc1cb5f + .long 0x6b51c369,0xbd0e934a + .long 0xe65f2000,0x3fc1f1b4 + .long 0x70fcf287,0x3d264160 + .long 0x8b5dc000,0x3fc21824 + .long 0xa3811df5,0x3d1f2866 + .long 0xd62ae000,0x3fc23eae + .long 0x75f6e51d,0xbd1c4ef6 + .long 0xebd34000,0x3fc26553 + .long 0xcd48326e,0xbd308652 + .long 0xf1b12000,0x3fc28c13 + .long 0xdfe3a7af,0xbd2c0024 + .long 0x14382000,0x3fc2bcaa + .long 0x21480e44,0xbd38f4c6 + .long 0x40b78000,0x3fc2e3a7 + .long 0x60689912,0x3cbd2885 + .long 0xd8f34000,0x3fc30abf + .long 0x508d5aa5,0xbd3893a6 + .long 0x03984000,0x3fc331f4 + .long 0xe9a3a8db,0x3d409691 + .long 0xe7a60000,0x3fc35943 + .long 0x43d5764a,0x3d2a3e8e + .long 0xac6e8000,0x3fc380af + .long 0x4d90e64e,0xbd1fc4d9 + .long 0x7997c000,0x3fc3a837 + .long 0xab2a4593,0xbd286816 + .long 0x771ca000,0x3fc3cfdb + .long 0x16e57a0f,0xbd2493c7 + .long 0x0d39a000,0x3fc3eda9 + .long 0x2ae78433,0x3d277ad1 + .long 0xc0950000,0x3fc4157e + .long 0xa37f5324,0x3d27333a + .long 0x13fb2000,0x3fc43d71 + .long 0xb82461da,0xbd4b3f09 + .long 0x30ad2000,0x3fc46580 + .long 0x72bdc442,0xbd198b79 + .long 0x40464000,0x3fc48dac + .long 0xc1788616,0xbd2c28bc + .long 0x6cbbc000,0x3fc4b5f5 + .long 0xef1ba41e,0xbd2e5a23 + .long 0xe05e6000,0x3fc4de5b + .long 0x8b90e0a0,0x3d4582b8 + .long 0x07770000,0x3fc4fcbc + .long 0x794dd932,0xbd13d6f8 + .long 0x1e926000,0x3fc52556 + .long 0x9b81384c,0xbd322350 + .long 0xf3198000,0x3fc54e0d + .long 0x2cd70aca,0x3d30ca92 + .long 0x7112c000,0x3fc56cab + .long 0x2a6e4407,0xbd10ed4c + .long 0xba734000,0x3fc59597 + .long 0x187e8930,0x3d4b1553 + .long 0x3a508000,0x3fc5bea2 + .long 0x1e386e4d,0xbd402641 + .long 0x08de4000,0x3fc5dd7e + .long 0x0b3f247b,0xbd2f4535 + .long 0xd3f90000,0x3fc606bd + .long 0x7c6ff8cd,0x3d51aaa0 + .long 0x518a4000,0x3fc6301c + .long 0x4d6761d0,0x3d401ece + .long 0x70618000,0x3fc64f37 + .long 0xa791b8a6,0x3d322b46 + .long 0x14c20000,0x3fc678cc + .long 0x7917b19f,0xbd4d287f + .long 0x05ed4000,0x3fc69810 + .long 0xcb5870e8,0xbd46b8cb + .long 0x5f9bc000,0x3fc6c1db + .long 0x986fe812,0xbd3994b8 + .long 0x8ecd0000,0x3fc6e148 + .long 0x4fa56719,0x3d54407b + .long 0x2e7e4000,0x3fc70b4b + .long 0xc215a307,0x3d0b8ea3 + .long 0x09144000,0x3fc72ae2 + .long 0x8e443b8a,0x3d55fc4a + .long 0x81bd8000,0x3fc7551c + .long 0xaffc42e9,0x3d3b9ef2 + .long 0x76cc4000,0x3fc774dd + .long 0x8d3f5094,0x3d1ded36 + .long 0x5db00000,0x3fc79f50 + .long 0xdd7a0df9,0x3d3d105d + .long 0xde098000,0x3fc7bf3b + .long 0xf47b93c9,0x3d4f301f + .long 0xcac44000,0x3fc7e9e7 + .long 0x64ca2675,0xbd300eff + .long 0x49030000,0x3fc809fe + .long 0xa2382d7a,0xbd57f954 + .long 0x57998000,0x3fc82a27 + .long 0xa5427ebe,0xbd51a131 + .long 0xc6260000,0x3fc85525 + .long 0x18660d2c,0xbd4f67be + .long 0x79834000,0x3fc8757a + .long 0xe73d6696,0xbd53bc75 + .long 0x058d8000,0x3fc895e2 + .long 0x37dbd0a7,0x3d3c0532 + .long 0x37698000,0x3fc8c134 + .long 0x6534d35a,0xbd55670a + .long 0x12ef0000,0x3fc8e1c8 + .long 0x21fe7581,0x3d595f21 + .long 0x11218000,0x3fc9026f + .long 0xaefa5f2f,0x3d47e805 + .long 0x48888000,0x3fc92329 + .long 0xfa5a2c46,0x3d301501 + .long 0x4b834000,0x3fc94eea + .long 0x142e461b,0xbd361a29 + .long 0xb63a0000,0x3fc96fd1 + .long 0xe74e02a0,0xbd1fb7d8 + .long 0xa6620000,0x3fc990cc + .long 0x8c78b1e9,0x3d54d5fa + .long 0x33334000,0x3fc9b1db + .long 0xf104deb4,0x3d3085fd + .long 0x740e4000,0x3fc9d2fd + .long 0x4be3a88f,0x3d530348 + .long 0xeedc8000,0x3fc9ff49 + .long 0xe2bda395,0x3d5aa98b + .long 0x84fc0000,0x3fca209a + .long 0xb83b532a,0xbd580433 + .long 0x1e440000,0x3fca41ff + .long 0xada9a5e4,0xbd3fa98d + .long 0xd2cec000,0x3fca6377 + .long 0xe131e3b9,0xbd564407 + .long 0xbae0c000,0x3fca8504 + .long 0x018eb699,0x3d49f5f5 + .long 0xeeec0000,0x3fcaa6a5 + .long 0x1db03170,0xbd401d1e + .long 0x878d8000,0x3fcac85b + .long 0x09bf0cc9,0xbd2e1c0b + .long 0x9d900000,0x3fcaea25 + .long 0x1d013253,0xbd27d321 + .long 0x49eb4000,0x3fcb0c04 + .long 0x85567deb,0x3d36d506 + .long 0xa5c50000,0x3fcb2df7 + .long 0xe6dd603b,0x3d14c9cc + .long 0xca710000,0x3fcb4fff + .long 0x81ec1ae1,0xbd4b2ea2 + .long 0xd1714000,0x3fcb721c + .long 0xf660b9da,0x3d47e295 + .long 0xd4780000,0x3fcb944e + .long 0xa337b6c0,0xbd558993 + .long 0xed658000,0x3fcbb695 + .long 0x5395b891,0xbd51c199 + .long 0x364ac000,0x3fcbd8f2 + .long 0xa0feae19,0x3d560784 + .long 0xc96a0000,0x3fcbfb63 + .long 0xd6eafbe6,0xbd36014a + .long 0xc134c000,0x3fcc1dea + .long 0x84f72786,0x3d44e96e + .long 0x384f4000,0x3fcc4087 + .long 0x3f7c716e,0x3d3f006e + .long 0x498f0000,0x3fcc6339 + .long 0x93e69cea,0x3d33c317 + .long 0x0ffc0000,0x3fcc8601 + .long 0x7e3ccfb7,0x3d2dae5f + .long 0x065c4000,0x3fcc9d3d + .long 0xa7bafd57,0x3d4b4180 + .long 0x375b8000,0x3fccc029 + .long 0xfa45fc85,0x3d503cf7 + .long 0x6697c000,0x3fcce32b + .long 0xcc5fc3d0,0xbd5a2df8 + .long 0xafd54000,0x3fcd0643 + .long 0xf7c24bc7,0xbd55fdc6 + .long 0x2f0e0000,0x3fcd2972 + .long 0xc812d894,0xbd45bacd + .long 0x00710000,0x3fcd4cb7 + .long 0x2cb52790,0xbd0bc64a + .long 0xab3f8000,0x3fcd6446 + .long 0x8139913c,0x3d392b7b + .long 0xef71c000,0x3fcd87b0 + .long 0x822c4d80,0x3d4b449e + .long 0xd1fe8000,0x3fcdab31 + .long 0x4f09d1d4,0x3d49a698 + .long 0x6fdc8000,0x3fcdcec9 + .long 0x4231d353,0x3d311dde + .long 0x88764000,0x3fcde690 + .long 0x8e8f9b14,0xbd350c11 + .long 0x4a25c000,0x3fce0a4e + .long 0x1868dfd1,0x3d0ffb66 + .long 0x15754000,0x3fce2e23 + .long 0x6ad712e4,0x3d4e32b0 + .long 0x22d18000,0x3fce4613 + .long 0x75f8b410,0xbd4b758b + .long 0x95c78000,0x3fce6a0e + .long 0x94c67dc7,0xbd2e13dc + .long 0x6243c000,0x3fce8e21 + .long 0xf23f1279,0x3d4d600d + .long 0xf26e0000,0x3fcea63a + .long 0x668806d4,0x3cef1bb1 + .long 0xed160000,0x3fceca74 + .long 0xfe665305,0xbd4f489c + .long 0x92ccc000,0x3fceeec6 + .long 0x1d627f70,0x3d4259f1 + .long 0x36b8c000,0x3fcf070a + .long 0x714687e0,0x3d49c0c3 + .long 0x93e34000,0x3fcf2b83 + .long 0x5715356c,0x3d345a59 + .long 0xef53c000,0x3fcf5014 + .long 0xb6f783a8,0xbd5ad2b5 + .long 0x3af18000,0x3fcf6883 + .long 0x4bcc6e04,0x3d58bfdb + .long 0xd9f3c000,0x3fcf8d3c + .long 0xf63ab05d,0x3d58276d + .long 0x1add8000,0x3fcfa5c6 + .long 0x9beccf8d,0x3d43e926 + .long 0x567e8000,0x3fcfcaa8 + .long 0x362fdd81,0x3d5d3cfe + .long 0xc8744000,0x3fcfe34c + .long 0xc008381c,0xbd113e5f + .long 0xfd74e000,0x3fd0042b + .long 0x617c00f4,0x3d551936 + .long 0xf6a18000,0x3fd016bd + .long 0x52b01c58,0x3cd77bf6 + .long 0x2f906000,0x3fd02326 + .long 0x9269b5c5,0x3d53227c + .long 0xed8d4000,0x3fd035cc + .long 0x46d0dd58,0xbd4abd7e + .long 0x0e86a000,0x3fd04243 + .long 0x07af3e66,0xbcb117c1 + .long 0xc842c000,0x3fd04ebe + .long 0xa51b431d,0xbd4a401d + .long 0xe84fc000,0x3fd06182 + .long 0x4e2f0b29,0x3d54abd9 + .long 0xb609c000,0x3fd06e0c + .long 0xcd12a34d,0x3d538308 + .long 0x0bec8000,0x3fd080e6 + .long 0x7faf9c27,0x3d4e24d8 + .long 0x0d896000,0x3fd08d7e + .long 0xf5dd9bd9,0xbd58cad1 + .long 0xc96a2000,0x3fd0a06c + .long 0xb30ebd03,0x3cf56aec + .long 0x1f3b2000,0x3fd0ad13 + .long 0xf6264d3a,0x3d5c5508 + .long 0x71e78000,0x3fd0c017 + .long 0x801d3fff,0xbd440944 + .long 0x3cad8000,0x3fd0cccc + .long 0x8fd76450,0xbd50b4df + .long 0xd91a4000,0x3fd0d986 + .long 0xeca91a49,0xbd46ae31 + .long 0xb8860000,0x3fd0eca9 + .long 0x0cf1281c,0x3d5a2d53 + .long 0xf87fe000,0x3fd0f972 + .long 0x0e3b7b78,0x3d53d583 + .long 0x1cf0e000,0x3fd10642 + .long 0x36cc41d7,0x3d37dcbc + .long 0xebe28000,0x3fd11983 + .long 0x56ee7372,0x3d453935 + .long 0xe35b8000,0x3fd12661 + .long 0xf97392ab,0xbd3e990a + .long 0xd277a000,0x3fd13345 + .long 0xd681ef76,0xbd2625f2 + .long 0xf5974000,0x3fd146a6 + .long 0x4e1038a4,0xbd57c5c5 + .long 0xe81ea000,0x3fd15399 + .long 0xd5972106,0x3d407ab6 + .long 0xe5d3a000,0x3fd16092 + .long 0x74a3a2b7,0x3d434c04 + .long 0xc3b7a000,0x3fd17413 + .long 0xadcb10c6,0x3d46bb42 + .long 0xf629e000,0x3fd1811b + .long 0xc5305a70,0xbd420a8b + .long 0x47b46000,0x3fd18e2a + .long 0x61f0b069,0x3d3a17c8 + .long 0xbe1a4000,0x3fd19b3e + .long 0x9d0c4bc2,0x3d306106 + .long 0x017cc000,0x3fd1aee9 + .long 0xf7f8b601,0xbd475f35 + .long 0xed714000,0x3fd1bc0c + .long 0x4ef21e21,0xbd463c17 + .long 0x12abc000,0x3fd1c937 + .long 0x61c2e7a5,0x3d3ffdc5 + .long 0x77148000,0x3fd1d667 + .long 0xa4cb0170,0xbd260af0 + .long 0xd1286000,0x3fd1ea3b + .long 0xc64da380,0x3d4c38dc + .long 0xed934000,0x3fd1f77b + .long 0x11c5ddf7,0xbd53b3e4 + .long 0x5e1b0000,0x3fd204c2 + .long 0x7b28110e,0x3d28fa35 + .long 0x28ce8000,0x3fd2120f + .long 0x0bc856ad,0xbd564e99 + .long 0x53c4a000,0x3fd21f62 + .long 0xe0bb0bd9,0xbd52ff6c + .long 0xe51d6000,0x3fd22cbb + .long 0x9c33f19c,0x3d0531fc + .long 0x4c976000,0x3fd240ce + .long 0x4672ee85,0xbd4777b4 + .long 0xf8ece000,0x3fd24e37 + .long 0x8e29bedb,0xbd3461fa + .long 0x215b0000,0x3fd25ba8 + .long 0x2d8bf07a,0xbd4007bf + .long 0xcc2a0000,0x3fd2691e + .long 0xd592a8b0,0xbd4f7b1a + .long 0xffab4000,0x3fd2769b + .long 0x75f34cfe,0xbd520002 + .long 0xc2394000,0x3fd2841f + .long 0xf75ce6c1,0x3d52c96f + .long 0x1a384000,0x3fd291aa + .long 0x73fd8960,0x3d42f012 + .long 0x0e154000,0x3fd29f3b + .long 0xa111a5a3,0x3d584ad4 + .long 0xee47a000,0x3fd2b3a0 + .long 0x875f458c,0xbd2044f7 + .long 0x842c0000,0x3fd2c142 + .long 0xb02650df,0x3d43cbc1 + .long 0xccb7c000,0x3fd2ceea + .long 0xb6dc5d61,0xbd249ad3 + .long 0xce830000,0x3fd2dc99 + .long 0xfe13a4e3,0xbd0beb52 + .long 0x902fc000,0x3fd2ea4f + .long 0x4d1def58,0x3d57d999 + .long 0x186a2000,0x3fd2f80c + .long 0xb0baac1f,0x3d37f290 + .long 0x6de7c000,0x3fd305cf + .long 0x4343671c,0xbd4e1284 + .long 0x97684000,0x3fd31399 + .long 0x31df7b15,0xbd28c485 + .long 0x9bb5a000,0x3fd3216a + .long 0xc8a62d99,0xbd1838f8 + .long 0x81a3c000,0x3fd32f42 + .long 0x7ce7627b,0x3d4dfd72 + .long 0x50110000,0x3fd33d21 + .long 0x0c6b638c,0x3d023363 + .type __libm_log10l_table_256,@object + .size __libm_log10l_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log1p_wmt.S b/external/sgx_libm/ia32/log1p_wmt.S new file mode 100644 index 0000000000..1afd321182 --- /dev/null +++ b/external/sgx_libm/ia32/log1p_wmt.S @@ -0,0 +1,847 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log1p_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin log1p + .text + .align 16,0x90 + .globl log1p +log1p: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + xorpd %xmm3, %xmm3 + movl $32768, %ecx + movd %ecx, %xmm4 + movsd 2128(%ebx), %xmm5 + pshufd $68, %xmm0, %xmm7 + movapd %xmm2, %xmm6 + pextrw $3, %xmm0, %ecx + addsd %xmm2, %xmm0 + movapd %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + subsd %xmm0, %xmm6 + orpd %xmm2, %xmm0 + psllq $5, %xmm0 + psrlq $34, %xmm0 + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.3 + addsd %xmm6, %xmm7 + rcpss %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $228, %xmm5, %xmm6 + psrlq $12, %xmm1 + andl $32752, %ecx + cmpl $16256, %ecx + jb .L_2TAG_PACKET_1.0.3 + andl $32752, %eax + movl $32720, %ecx + subl %eax, %ecx + pinsrw $3, %ecx, %xmm3 +.L_2TAG_PACKET_2.0.3: + mulsd %xmm3, %xmm7 + paddd %xmm4, %xmm0 + xorpd %xmm4, %xmm4 + movl $14336, %ecx + pinsrw $3, %ecx, %xmm4 + orpd %xmm2, %xmm1 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm1, %xmm5 + andpd %xmm6, %xmm0 + subsd %xmm5, %xmm1 + paddd %xmm4, %xmm0 + mulsd %xmm0, %xmm5 + movl $16352, %ecx + subl %ecx, %eax + cvtsi2sdl %eax, %xmm4 + mulsd %xmm0, %xmm7 + mulsd %xmm0, %xmm1 + movsd 2064(%ebx), %xmm6 + movapd 2080(%ebx), %xmm3 + subsd %xmm2, %xmm5 + andl $16711680, %edx + shrl $12, %edx + movapd (%ebx,%edx), %xmm0 + movapd 2096(%ebx), %xmm2 + addsd %xmm5, %xmm1 + movapd %xmm1, %xmm5 + addsd %xmm7, %xmm1 + subsd %xmm1, %xmm5 + addsd %xmm5, %xmm7 + mulsd %xmm4, %xmm6 + mulsd 2072(%ebx), %xmm4 + mulsd %xmm1, %xmm3 + pshufd $68, %xmm1, %xmm5 + addsd %xmm6, %xmm0 + mulpd %xmm5, %xmm2 + mulpd %xmm5, %xmm5 + pshufd $228, %xmm0, %xmm6 + addsd %xmm1, %xmm0 + addpd 2112(%ebx), %xmm2 + mulpd %xmm5, %xmm3 + subsd %xmm0, %xmm6 + mulsd %xmm1, %xmm2 + addsd %xmm7, %xmm4 + mulsd %xmm1, %xmm7 + addsd %xmm6, %xmm1 + pshufd $238, %xmm0, %xmm6 + mulsd %xmm5, %xmm5 + addsd %xmm6, %xmm4 + subsd %xmm7, %xmm1 + addpd %xmm3, %xmm2 + addsd %xmm4, %xmm1 + mulpd %xmm5, %xmm2 + addsd %xmm2, %xmm1 + pshufd $238, %xmm2, %xmm5 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_0.0.3: + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm1 + addl $16, %eax + cmpl $32768, %eax + jae .L_2TAG_PACKET_4.0.3 + cmpl $0, %eax + je .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_6.0.3: + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_7.0.3: + ja .L_2TAG_PACKET_6.0.3 + cmpl $0, %edx + ja .L_2TAG_PACKET_6.0.3 + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_4.0.3: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + addl %ecx, %ecx + cmpl $-2097152, %ecx + jae .L_2TAG_PACKET_7.0.3 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_8.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + movl $141, %edx + mulsd %xmm1, %xmm0 +.L_2TAG_PACKET_9.0.3: + movsd %xmm0, (%esp) + movsd 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_10.0.3 +.L_2TAG_PACKET_5.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + divsd %xmm1, %xmm0 + movl $140, %edx + jmp .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_1.0.3: + movsd 112(%esp), %xmm0 + cmpl $15504, %ecx + jb .L_2TAG_PACKET_11.0.3 + movapd 2144(%ebx), %xmm1 + pshufd $68, %xmm0, %xmm0 + movapd 2160(%ebx), %xmm2 + pshufd $68, %xmm0, %xmm4 + movapd 2176(%ebx), %xmm3 + mulpd %xmm0, %xmm1 + xorpd %xmm6, %xmm6 + mulpd %xmm4, %xmm4 + addpd %xmm2, %xmm1 + pshufd $68, %xmm4, %xmm5 + mulpd %xmm0, %xmm4 + movl $49120, %eax + pinsrw $3, %eax, %xmm6 + mulpd %xmm0, %xmm1 + mulsd %xmm4, %xmm4 + addpd %xmm3, %xmm1 + mulsd %xmm6, %xmm5 + mulpd %xmm4, %xmm1 + pshufd $238, %xmm1, %xmm7 + addsd %xmm7, %xmm1 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_11.0.3: + cmpl $16, %ecx + jb .L_2TAG_PACKET_12.0.3 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_12.0.3: + movapd %xmm0, %xmm1 + mulsd %xmm1, %xmm1 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_3.0.3: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_10.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type log1p,@function + .size log1p,.-log1p + .data +# -- End log1p + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4277811200 + .long 1072049730 + .long 2479318832 + .long 1026487127 + .long 2854492160 + .long 1072033410 + .long 215631550 + .long 1025638968 + .long 1547061248 + .long 1072017216 + .long 2886781435 + .long 1026423395 + .long 649825280 + .long 1072001146 + .long 4281533405 + .long 1024038923 + .long 646346752 + .long 1071985198 + .long 1562735921 + .long 1023790276 + .long 2203734016 + .long 1071969370 + .long 1838397691 + .long 3173936209 + .long 1872169984 + .long 1071953661 + .long 3981202460 + .long 1022325013 + .long 669557760 + .long 1071938069 + .long 4182597802 + .long 3173174122 + .long 4076413952 + .long 1071922591 + .long 1209029111 + .long 3170736207 + .long 556125184 + .long 1071907228 + .long 821086028 + .long 3173437049 + .long 204914688 + .long 1071891976 + .long 2097025986 + .long 3171071798 + .long 387545088 + .long 1071876834 + .long 3142936996 + .long 3173092218 + .long 2912783360 + .long 1071861800 + .long 2502420140 + .long 1024505919 + .long 1144260608 + .long 1071846874 + .long 3315658140 + .long 3173469843 + .long 1471209472 + .long 1071832053 + .long 129621009 + .long 3172443877 + .long 1829683200 + .long 1071817336 + .long 3885467693 + .long 1025535275 + .long 288676864 + .long 1071802722 + .long 86139472 + .long 3171639793 + .long 3636378624 + .long 1071788208 + .long 1850238587 + .long 1024654342 + .long 1606817792 + .long 1071773795 + .long 3388899795 + .long 3173675586 + .long 1236164608 + .long 1071759480 + .long 3983599207 + .long 1020046558 + .long 1089616896 + .long 1071745262 + .long 4171974224 + .long 1024773198 + .long 4143093760 + .long 1071731139 + .long 2727587401 + .long 3173965207 + .long 600267776 + .long 1071717112 + .long 3147685042 + .long 3173353031 + .long 2249313280 + .long 1071703177 + .long 125835074 + .long 1025255832 + .long 3805303808 + .long 1071689334 + .long 2289991207 + .long 1025460331 + .long 87278592 + .long 1071675583 + .long 1106114045 + .long 1025933602 + .long 3195405312 + .long 1071661920 + .long 3885316576 + .long 3171206239 + .long 3853649920 + .long 1071648346 + .long 2977069852 + .long 3171236771 + .long 2944026624 + .long 1071625048 + .long 1008093493 + .long 1023444474 + .long 3993180160 + .long 1071598247 + .long 1862355595 + .long 1024642533 + .long 1454641152 + .long 1071571617 + .long 1514603089 + .long 1026500596 + .long 3286085632 + .long 1071545154 + .long 1400028424 + .long 3173279056 + .long 438773760 + .long 1071518858 + .long 120727864 + .long 3172148914 + .long 1212979200 + .long 1071492725 + .long 1625055594 + .long 3172901933 + .long 1189017600 + .long 1071466754 + .long 3920062376 + .long 1025727407 + .long 403064832 + .long 1071440943 + .long 1053271728 + .long 3171391427 + .long 3343210496 + .long 1071415289 + .long 3243395502 + .long 3173627613 + .long 1765777408 + .long 1071389792 + .long 2145968512 + .long 1026354304 + .long 461430784 + .long 1071364449 + .long 4094322285 + .long 1026021467 + .long 71706624 + .long 1071339258 + .long 763632021 + .long 1024496933 + .long 1380503552 + .long 1071314217 + .long 1383547992 + .long 3173088453 + .long 1015732224 + .long 1071289325 + .long 3198646877 + .long 1025390322 + .long 35977216 + .long 1071264580 + .long 2141026805 + .long 1025754693 + .long 3927306240 + .long 1071239979 + .long 282116272 + .long 3173394334 + .long 1125341184 + .long 1071215523 + .long 2768427504 + .long 3172279059 + .long 1666971648 + .long 1071191208 + .long 786837629 + .long 3172427445 + .long 2827694080 + .long 1071167033 + .long 3857122416 + .long 3173014241 + .long 2003683328 + .long 1071142997 + .long 859010954 + .long 1026545007 + .long 1004017664 + .long 1071119098 + .long 3356644970 + .long 3173458064 + .long 1753020416 + .long 1071095334 + .long 788338552 + .long 1026157693 + .long 1992718336 + .long 1071071704 + .long 1239179443 + .long 1026394889 + .long 3870234624 + .long 1071048206 + .long 2082614663 + .long 1024926053 + .long 1050437632 + .long 1071024840 + .long 660007840 + .long 1025548499 + .long 188395520 + .long 1071001603 + .long 3878792704 + .long 3173889571 + .long 3747176448 + .long 1070978493 + .long 144991708 + .long 3171552042 + .long 1405669376 + .long 1070955511 + .long 3999088879 + .long 1025486317 + .long 121151488 + .long 1070932654 + .long 2170865497 + .long 1026473584 + .long 2652319744 + .long 1070909920 + .long 453695652 + .long 3173916809 + .long 3262236672 + .long 1070887309 + .long 157800053 + .long 3173984206 + .long 601221120 + .long 1070864820 + .long 3968917661 + .long 1023992886 + .long 1999843328 + .long 1070842450 + .long 3053895004 + .long 1024998228 + .long 1992167424 + .long 1070820199 + .long 2968614856 + .long 1024552653 + .long 3788726272 + .long 1070798065 + .long 3542170808 + .long 3173573242 + .long 2094829568 + .long 1070776048 + .long 1246758132 + .long 1026202874 + .long 288675840 + .long 1070754146 + .long 3747328950 + .long 1026331585 + .long 1829681152 + .long 1070732357 + .long 3125197546 + .long 1024100318 + .long 1666869248 + .long 1070710681 + .long 1363656119 + .long 1026336493 + .long 3417110528 + .long 1070689116 + .long 4154791553 + .long 1026267853 + .long 2183653376 + .long 1070667662 + .long 1671819292 + .long 3173785870 + .long 1734434816 + .long 1070646317 + .long 373091049 + .long 1025972363 + .long 1615681536 + .long 1070625080 + .long 384650897 + .long 1022926043 + .long 1445382144 + .long 1070603950 + .long 344320330 + .long 3172397196 + .long 1823715328 + .long 1070569756 + .long 3389841200 + .long 1025231852 + .long 3839688704 + .long 1070527917 + .long 1706790417 + .long 3167363349 + .long 4293332992 + .long 1070486286 + .long 1614935088 + .long 1019351591 + .long 2966720512 + .long 1070444861 + .long 4145393717 + .long 3173711658 + .long 4066729984 + .long 1070403639 + .long 1974925028 + .long 3171437182 + .long 3337621504 + .long 1070362619 + .long 3314953170 + .long 3169971314 + .long 943448064 + .long 1070321799 + .long 1498682038 + .long 3173862340 + .long 1465634816 + .long 1070281176 + .long 1319952810 + .long 3171693965 + .long 1015734272 + .long 1070240749 + .long 1347821929 + .long 3173544515 + .long 118001664 + .long 1070200516 + .long 1751482746 + .long 1026134093 + .long 3707174912 + .long 1070160474 + .long 1486946159 + .long 1023930920 + .long 3946381312 + .long 1070120623 + .long 2867408081 + .long 3171368276 + .long 1699848192 + .long 1070080961 + .long 2590187139 + .long 1025379803 + .long 2235846656 + .long 1070041485 + .long 1888568069 + .long 3172754960 + .long 2339729408 + .long 1070002194 + .long 3852214753 + .long 3173323149 + .long 3196850176 + .long 1069963086 + .long 742141560 + .long 1025101707 + .long 1800683520 + .long 1069924160 + .long 3949500444 + .long 3172102179 + .long 3835801600 + .long 1069885413 + .long 3848895943 + .long 1025913832 + .long 2201202688 + .long 1069846845 + .long 1425913464 + .long 1025868665 + .long 2778279936 + .long 1069808453 + .long 2120889677 + .long 3173831128 + .long 2954203136 + .long 1069770236 + .long 592147081 + .long 1019621288 + .long 210141184 + .long 1069732193 + .long 3414275233 + .long 1023647084 + .long 709476352 + .long 1069694321 + .long 2413027164 + .long 1024462115 + .long 2116284416 + .long 1069656619 + .long 1144559924 + .long 1026336654 + .long 2183651328 + .long 1069619086 + .long 3459057650 + .long 1025634168 + .long 3047047168 + .long 1069581720 + .long 1879674924 + .long 3173508573 + .long 970711040 + .long 1069541521 + .long 1335954173 + .long 3173332182 + .long 2198478848 + .long 1069467449 + .long 2951103968 + .long 3173892200 + .long 1669611520 + .long 1069393703 + .long 531044147 + .long 1025149248 + .long 29114368 + .long 1069320280 + .long 3327831251 + .long 1025918673 + .long 2376949760 + .long 1069247176 + .long 737634533 + .long 3172176000 + .long 1085390848 + .long 1069174390 + .long 3108243400 + .long 3171828406 + .long 1566130176 + .long 1069101918 + .long 985483226 + .long 1025708380 + .long 792780800 + .long 1069029758 + .long 4184866295 + .long 1024426204 + .long 183156736 + .long 1068957907 + .long 2845699378 + .long 1022107277 + .long 1301782528 + .long 1068886362 + .long 1012735262 + .long 3173804294 + .long 1562411008 + .long 1068815121 + .long 2197086703 + .long 3170187813 + .long 2815549440 + .long 1068744181 + .long 2782613207 + .long 1026345054 + .long 2756124672 + .long 1068673540 + .long 2929486205 + .long 3173037800 + .long 3511050240 + .long 1068603195 + .long 1443733147 + .long 3173331549 + .long 3047047168 + .long 1068533144 + .long 1879674924 + .long 3172459997 + .long 3221667840 + .long 1068427825 + .long 1338588027 + .long 3171815742 + .long 3453861888 + .long 1068288883 + .long 1205348359 + .long 3172624626 + .long 3506110464 + .long 1068150514 + .long 893105198 + .long 1025571866 + .long 346013696 + .long 1068012714 + .long 3495569021 + .long 3172563349 + .long 4074029056 + .long 1067875476 + .long 3961106338 + .long 3171065595 + .long 3559784448 + .long 1067738798 + .long 1975385384 + .long 3173783155 + .long 797769728 + .long 1067602675 + .long 3760305787 + .long 1026047642 + .long 2313633792 + .long 1067467101 + .long 1559353171 + .long 1023480256 + .long 3960766464 + .long 1067213778 + .long 1067365107 + .long 1025865926 + .long 684261376 + .long 1066944805 + .long 844762164 + .long 3173687482 + .long 630718464 + .long 1066676905 + .long 2458269694 + .long 1024033081 + .long 1486061568 + .long 1066410070 + .long 115537874 + .long 3173243995 + .long 2743664640 + .long 1065886792 + .long 3665098304 + .long 3173471607 + .long 1971912704 + .long 1065357333 + .long 2577214440 + .long 3171993451 + .long 1498939392 + .long 1064306693 + .long 3409036923 + .long 1025599151 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 4277811200 + .long 1067855426 + .long 2479318832 + .long 1022292823 + .long 2454267026 + .long 1069697316 + .long 0 + .long 3218079744 + .long 1030730101 + .long 3217380702 + .long 1431655765 + .long 1070945621 + .long 2576980378 + .long 1070176665 + .long 0 + .long 3219128320 + .long 0 + .long 4294959104 + .long 0 + .long 4294959104 + .long 0 + .long 3217031168 + .long 2576980378 + .long 1070176665 + .long 2454267026 + .long 1069697316 + .long 0 + .long 3218079744 + .long 1431655765 + .long 3217380693 + .long 1431655765 + .long 1070945621 + .type static_const_table,@object + .size static_const_table,2192 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log1pf_wmt.S b/external/sgx_libm/ia32/log1pf_wmt.S new file mode 100644 index 0000000000..d1ebeb33bf --- /dev/null +++ b/external/sgx_libm/ia32/log1pf_wmt.S @@ -0,0 +1,751 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log1pf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin log1pf + .text + .align 16,0x90 + .globl log1pf +log1pf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl $1065353216, %edx + movd %edx, %xmm1 + movl $16384, %ecx + movd %ecx, %xmm4 + movl $-32768, %eax + movd %eax, %xmm2 + xorpd %xmm3, %xmm3 + movl $16368, %edx + pinsrw $3, %edx, %xmm3 + xorpd %xmm5, %xmm5 + addss %xmm0, %xmm1 +.L_2TAG_PACKET_0.0.3: + movd %xmm0, %ecx + movd %xmm1, %edx + rcpss %xmm1, %xmm1 + movsd 2080(%ebx), %xmm7 + pshuflw $68, %xmm0, %xmm0 + paddd %xmm4, %xmm1 + andl $2147483647, %ecx + cmpl $864026624, %ecx + jb .L_2TAG_PACKET_1.0.3 + subl $8388608, %edx + cmpl $2113929216, %edx + jae .L_2TAG_PACKET_2.0.3 + andps %xmm1, %xmm2 + cvtps2pd %xmm0, %xmm0 + cvtps2pd %xmm2, %xmm1 + movd %xmm2, %eax + andl $-8388608, %edx + subl $1056964608, %edx + cvtsi2sdl %edx, %xmm6 + mulsd %xmm1, %xmm0 + subsd %xmm3, %xmm1 + subl $1056964608, %edx + addl %edx, %eax + shrl $12, %eax + movsd (%ebx,%eax), %xmm4 + addsd %xmm1, %xmm0 + movsd 2088(%ebx), %xmm2 + movsd 2096(%ebx), %xmm1 + mulsd %xmm0, %xmm7 + addsd %xmm0, %xmm5 + mulsd %xmm0, %xmm0 + mulsd %xmm2, %xmm6 + addsd %xmm7, %xmm1 + addsd %xmm4, %xmm5 + mulsd %xmm1, %xmm0 + addsd %xmm6, %xmm5 + addsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_2.0.3: + addl $8388608, %edx + js .L_2TAG_PACKET_4.0.3 + cmpl $0, %edx + je .L_2TAG_PACKET_5.0.3 + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_6.0.3 + movl $528482304, %eax + movd %eax, %xmm6 + movsd 2064(%ebx), %xmm5 + mulss %xmm6, %xmm0 + movss %xmm0, %xmm1 + jmp .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_6.0.3: + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $-2147483648, %edx + je .L_2TAG_PACKET_5.0.3 + addl %edx, %edx + cmpl $-16777216, %edx + ja .L_2TAG_PACKET_6.0.3 + xorps %xmm0, %xmm0 + divss %xmm0, %xmm0 + movl $143, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_1.0.3: + cmpl $8388608, %ecx + jb .L_2TAG_PACKET_9.0.3 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_9.0.3: + movss %xmm0, %xmm1 + mulss %xmm1, %xmm1 + jmp .L_2TAG_PACKET_3.0.3 +.L_2TAG_PACKET_5.0.3: + movl $-1082130432, %eax + movd %eax, %xmm0 + xorps %xmm1, %xmm1 + divss %xmm1, %xmm0 + movl $142, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_3.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type log1pf,@function + .size log1pf,.-log1pf + .data +# -- End log1pf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4277811695 + .long 1072049730 + .long 4099377379 + .long 1072041554 + .long 2854492448 + .long 1072033410 + .long 3783013829 + .long 1072025297 + .long 1547061728 + .long 1072017216 + .long 3705668804 + .long 1072009165 + .long 649825382 + .long 1072001146 + .long 4257004898 + .long 1071993156 + .long 646346839 + .long 1071985198 + .long 1718090839 + .long 1071977269 + .long 2203733529 + .long 1071969370 + .long 1140698018 + .long 1071961501 + .long 1872170015 + .long 1071953661 + .long 3457002416 + .long 1071945850 + .long 669557459 + .long 1071938069 + .long 1179420986 + .long 1071930316 + .long 4076413893 + .long 1071922591 + .long 4165410145 + .long 1071914895 + .long 556124819 + .long 1071907228 + .long 957937516 + .long 1071899588 + .long 204914613 + .long 1071891976 + .long 1730507025 + .long 1071884391 + .long 387544807 + .long 1071876834 + .long 3922939863 + .long 1071869303 + .long 2912783494 + .long 1071861800 + .long 826988438 + .long 1071854324 + .long 1144260235 + .long 1071846874 + .long 3057005434 + .long 1071839450 + .long 1471209283 + .long 1071832053 + .long 4186184763 + .long 1071824681 + .long 1829683463 + .long 1071817336 + .long 2217517956 + .long 1071810016 + .long 288676754 + .long 1071802722 + .long 3875016090 + .long 1071795452 + .long 3636378776 + .long 1071788208 + .long 3125257108 + .long 1071780989 + .long 1606817369 + .long 1071773795 + .long 2648729924 + .long 1071766625 + .long 1236164615 + .long 1071759480 + .long 951558972 + .long 1071752359 + .long 1089617062 + .long 1071745262 + .long 952179194 + .long 1071738189 + .long 4143093266 + .long 1071731139 + .long 1388251237 + .long 1071724114 + .long 600267432 + .long 1071717112 + .long 1108583542 + .long 1071710133 + .long 2249313505 + .long 1071703177 + .long 3365155278 + .long 1071696244 + .long 3805304058 + .long 1071689334 + .long 2925366939 + .long 1071682447 + .long 87278952 + .long 1071675583 + .long 3249155078 + .long 1071668740 + .long 3195405229 + .long 1071661920 + .long 3601425396 + .long 1071655122 + .long 3853649835 + .long 1071648346 + .long 2393914686 + .long 1071638513 + .long 2944026756 + .long 1071625048 + .long 3870651933 + .long 1071611626 + .long 3993180461 + .long 1071598247 + .long 2142264402 + .long 1071584911 + .long 1454642149 + .long 1071571617 + .long 783063308 + .long 1071558365 + .long 3286084979 + .long 1071545154 + .long 3543033726 + .long 1071531985 + .long 438773454 + .long 1071518858 + .long 1458540784 + .long 1071505771 + .long 1212978710 + .long 1071492725 + .long 2912845216 + .long 1071479719 + .long 1189018219 + .long 1071466754 + .long 3567208110 + .long 1071453828 + .long 403064643 + .long 1071440943 + .long 3536762435 + .long 1071428096 + .long 3343209673 + .long 1071415289 + .long 3091669954 + .long 1071402521 + .long 1765778334 + .long 1071389792 + .long 2653362897 + .long 1071377101 + .long 461431547 + .long 1071364449 + .long 2790898835 + .long 1071351834 + .long 71706889 + .long 1071339258 + .long 4217424686 + .long 1071326718 + .long 1380502992 + .long 1071314217 + .long 3491778671 + .long 1071301752 + .long 1015732707 + .long 1071289325 + .long 1605095660 + .long 1071276934 + .long 35977849 + .long 1071264580 + .long 3977575844 + .long 1071252261 + .long 3927305531 + .long 1071239979 + .long 3275478714 + .long 1071227733 + .long 1125340846 + .long 1071215523 + .long 882913881 + .long 1071203348 + .long 1666971274 + .long 1071191208 + .long 2603916163 + .long 1071179103 + .long 2827693557 + .long 1071167033 + .long 1479703759 + .long 1071154998 + .long 2003684347 + .long 1071142997 + .long 3555691467 + .long 1071131030 + .long 1004016924 + .long 1071119098 + .long 2108975630 + .long 1071107199 + .long 1753021246 + .long 1071095334 + .long 3415503221 + .long 1071083502 + .long 1992719281 + .long 1071071704 + .long 977707388 + .long 1071059939 + .long 3870234994 + .long 1071048206 + .long 1291822077 + .long 1071036507 + .long 1050438164 + .long 1071024840 + .long 2370625547 + .long 1071013205 + .long 188394569 + .long 1071001603 + .long 2331021804 + .long 1070990032 + .long 3747176240 + .long 1070978493 + .long 3686719393 + .long 1070966986 + .long 1405669883 + .long 1070955511 + .long 461103529 + .long 1070944067 + .long 121152472 + .long 1070932654 + .long 3954874384 + .long 1070921271 + .long 2652318780 + .long 1070909920 + .long 4089234463 + .long 1070898599 + .long 3262235675 + .long 1070887309 + .long 3763576649 + .long 1070876049 + .long 601221319 + .long 1070864820 + .long 1673619518 + .long 1070853620 + .long 1999843716 + .long 1070842450 + .long 899399508 + .long 1070831310 + .long 1992167703 + .long 1070820199 + .long 313445281 + .long 1070809118 + .long 3788725476 + .long 1070798065 + .long 3168871046 + .long 1070787042 + .long 2094830420 + .long 1070776048 + .long 4212681596 + .long 1070765082 + .long 288676754 + .long 1070754146 + .long 2568927817 + .long 1070743237 + .long 1829681364 + .long 1070732357 + .long 1737005556 + .long 1070721505 + .long 1666870165 + .long 1070710681 + .long 1000063738 + .long 1070699885 + .long 3417111411 + .long 1070689116 + .long 4013324163 + .long 1070678375 + .long 2183652476 + .long 1070667662 + .long 1622638721 + .long 1070656976 + .long 1734435555 + .long 1070646317 + .long 1927726804 + .long 1070635685 + .long 1615681634 + .long 1070625080 + .long 215909304 + .long 1070614502 + .long 1445381777 + .long 1070603950 + .long 870975437 + .long 1070590754 + .long 1823716217 + .long 1070569756 + .long 323875369 + .long 1070548811 + .long 3839688678 + .long 1070527917 + .long 2667883253 + .long 1070507076 + .long 4293333010 + .long 1070486286 + .long 3324205749 + .long 1070465548 + .long 2966718784 + .long 1070444861 + .long 2140157205 + .long 1070424225 + .long 4066729595 + .long 1070403639 + .long 3386588242 + .long 1070383104 + .long 3337621361 + .long 1070362619 + .long 2870475188 + .long 1070342184 + .long 943446189 + .long 1070321799 + .long 817374162 + .long 1070301463 + .long 1465634365 + .long 1070281176 + .long 1869032404 + .long 1070260938 + .long 1015732707 + .long 1070240749 + .long 2196155141 + .long 1070220608 + .long 118003300 + .long 1070200516 + .long 2381031992 + .long 1070180471 + .long 3707175295 + .long 1070160474 + .long 3120348377 + .long 1070140525 + .long 3946380940 + .long 1070120623 + .long 928049556 + .long 1070100769 + .long 1699849154 + .long 1070080961 + .long 1018125008 + .long 1070061200 + .long 2235845747 + .long 1070041485 + .long 122671437 + .long 1070021817 + .long 2339728060 + .long 1070002194 + .long 3669742467 + .long 1069982617 + .long 3196851002 + .long 1069963086 + .long 11572342 + .long 1069943601 + .long 1800682930 + .long 1069924160 + .long 3372322013 + .long 1069904764 + .long 3835803021 + .long 1069885413 + .long 2306589128 + .long 1069866107 + .long 2201204065 + .long 1069846845 + .long 2647241692 + .long 1069827627 + .long 2778278092 + .long 1069808453 + .long 1733817001 + .long 1069789323 + .long 2954203158 + .long 1069770236 + .long 1295667077 + .long 1069751193 + .long 210141498 + .long 1069732193 + .long 3155274661 + .long 1069713235 + .long 709476866 + .long 1069694321 + .long 636640577 + .long 1069675449 + .long 2116286250 + .long 1069656619 + .long 38479793 + .long 1069637832 + .long 2183652476 + .long 1069619086 + .long 3452748429 + .long 1069600382 + .long 3047045639 + .long 1069581720 + .long 173141005 + .long 1069563100 + .long 970708326 + .long 1069541521 + .long 2106590683 + .long 1069504444 + .long 2198475040 + .long 1069467449 + .long 3996141691 + .long 1069430535 + .long 1669613218 + .long 1069393703 + .long 2283901796 + .long 1069356951 + .long 29117219 + .long 1069320280 + .long 1990183441 + .long 1069283688 + .long 2376948508 + .long 1069247176 + .long 3998935692 + .long 1069210743 + .long 1085389880 + .long 1069174390 + .long 760030536 + .long 1069138115 + .long 1566132617 + .long 1069101918 + .long 2056379433 + .long 1069065799 + .long 792781808 + .long 1069029758 + .long 641565395 + .long 1068993794 + .long 183156961 + .long 1068957907 + .long 2302040698 + .long 1068922096 + .long 1301778891 + .long 1068886362 + .long 84804484 + .long 1068850704 + .long 1562410668 + .long 1068815121 + .long 64741293 + .long 1068779614 + .long 2815553124 + .long 1068744181 + .long 4162338635 + .long 1068708823 + .long 2756122533 + .long 1068673540 + .long 1551389854 + .long 1068638331 + .long 3511047527 + .long 1068603195 + .long 3016419377 + .long 1068568133 + .long 3047045639 + .long 1068533144 + .long 296456961 + .long 1068497513 + .long 3221665916 + .long 1068427825 + .long 3697798734 + .long 1068358282 + .long 3453858508 + .long 1068288883 + .long 4234736672 + .long 1068219627 + .long 3506114812 + .long 1068150514 + .long 3044269692 + .long 1068081543 + .long 346010435 + .long 1068012714 + .long 1513453498 + .long 1067944025 + .long 4074027864 + .long 1067875476 + .long 1275317999 + .long 1067807068 + .long 3559777258 + .long 1067738798 + .long 4204867691 + .long 1067670667 + .long 797775935 + .long 1067602675 + .long 3825228429 + .long 1067534819 + .long 2313634884 + .long 1067467101 + .long 672386641 + .long 1067348671 + .long 3960777458 + .long 1067213778 + .long 1220920383 + .long 1067079157 + .long 684247743 + .long 1066944805 + .long 2020150230 + .long 1066810721 + .long 630721729 + .long 1066676905 + .long 535440936 + .long 1066543355 + .long 1486051399 + .long 1066410070 + .long 2227658502 + .long 1066152307 + .long 2743640746 + .long 1065886792 + .long 4184355568 + .long 1065621801 + .long 1971904113 + .long 1065357333 + .long 341338964 + .long 1064833554 + .long 1498975029 + .long 1064306693 + .long 1440057502 + .long 1063257089 + .long 0 + .long 0 + .long 0 + .long 0 + .long 4277811695 + .long 1078341186 + .long 4277811695 + .long 3225824834 + .long 1431655765 + .long 1070945621 + .long 4277811695 + .long 1047932482 + .long 1107282704 + .long 3219128321 + .long 4277811695 + .long 1047932482 + .type static_const_table,@object + .size static_const_table,2112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log1pl.S b/external/sgx_libm/ia32/log1pl.S new file mode 100644 index 0000000000..16d16a844d --- /dev/null +++ b/external/sgx_libm/ia32/log1pl.S @@ -0,0 +1,949 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log1pl.c" + .text +..TXTST0: +# -- Begin log1pl + .text + .align 16,0x90 + .globl log1pl +log1pl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %edi + pushl %ebx + subl $56, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + movl %eax, %edx + movzwl 16(%ebp), %edi + shll $15, %edx + andl $32767, %edi + orl %edi, %edx + shll $16, %edx + movzwl 14(%ebp), %ecx + orl %ecx, %edx + movzwl 14(%esp), %ebx + cmpl $32767, %edi + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + je ..B1.78 +..B1.4: + cmpl $-1073774592, %edx + jae ..B1.57 +..B1.5: + cmpl $16379, %edi + jge ..B1.47 +..B1.6: + cmpl $16369, %edi + jge ..B1.40 +..B1.7: + cmpl $16358, %edi + jge ..B1.33 +..B1.8: + cmpl $16345, %edi + jge ..B1.26 +..B1.9: + cmpl $16308, %edi + jge ..B1.19 +..B1.10: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.71 +..B1.11: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.12: + fldcw 12(%esp) +..B1.13: + movzwl 16(%ebp), %edi + movl $1, %edx + andl $32767, %edi +..B1.14: + testl %edi, %edi + jle ..B1.67 +..B1.15: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ecx) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmul %st(1), %st + fxch %st(1) + fmull _ones@GOTOFF(%ecx,%eax,8) + fsubrp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ecx) + fstpt 16(%esp) +..B1.16: + testl %edx, %edx + je ..B1.18 +..B1.17: + fldcw 14(%esp) +..B1.18: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.72 +..B1.20: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.21: + fldcw 12(%esp) +..B1.22: + movl $1, %eax +..B1.23: + fldt 8(%ebp) + testl %eax, %eax + fldt _Q3@GOTOFF(%ecx) + fmul %st(1), %st + fmul %st(1), %st + fadd %st(1), %st + fstpt 16(%esp) + fldl _TWO_75@GOTOFF(%ecx) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%esp) + je ..B1.25 +..B1.24: + fldcw 14(%esp) +..B1.25: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.73 +..B1.27: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.28: + fldcw 12(%esp) +..B1.29: + movl $1, %eax +..B1.30: + fldt 8(%ebp) + testl %eax, %eax + fldt 12+_Q2@GOTOFF(%ecx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.32 +..B1.31: + fldcw 14(%esp) +..B1.32: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.33: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.74 +..B1.34: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.35: + fldcw 12(%esp) +..B1.36: + movl $1, %eax +..B1.37: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%ecx) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%ecx) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.39 +..B1.38: + fldcw 14(%esp) +..B1.39: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.40: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.75 +..B1.41: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.42: + fldcw 12(%esp) +..B1.43: + movl $1, %eax +..B1.44: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fld %st(1) + fld %st(2) + fldl _TWO_52H@GOTOFF(%ecx) + fmul %st(4), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fxch %st(3) + fstpt 32(%esp) + fldt 32(%esp) + fmul %st(0), %st + fadd %st, %st(3) + fldt 156+_Q@GOTOFF(%ecx) + fmul %st(4), %st + fldt 132+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 108+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 84+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 60+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 36+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 12+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 144+_Q@GOTOFF(%ecx) + fmul %st(5), %st + fldt 120+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 96+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 72+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 48+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 24+_Q@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(5) + fld %st(2) + fldt _Q@GOTOFF(%ecx) + faddp %st, %st(6) + fxch %st(5) + fmul %st(6), %st + faddp %st, %st(1) + fldt 180+_Q@GOTOFF(%ecx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(1) + fldt 168+_Q@GOTOFF(%ecx) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(5) + fldt 32(%esp) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.46 +..B1.45: + fldcw 14(%esp) +..B1.46: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.47: + movl %ebx, %edi + andl $768, %edi + cmpl $768, %edi + je ..B1.76 +..B1.48: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.49: + fldcw 12(%esp) +..B1.50: + movzbl 17(%ebp), %eax + movl $1, %ebx + andl $128, %eax + shrl $7, %eax +..B1.51: + cmpl ranges@GOTOFF(%ecx,%eax,4), %edx + jae ..B1.53 +..B1.52: + fldt 8(%ebp) + xorl %edx, %edx + movzwl 16(%ebp), %edi + fld %st(0) + fldl _ones@GOTOFF(%ecx) + andl $32767, %edi + addl $-16415, %edi + fstpt 16(%esp) + setl %dl + fldl _shifters@GOTOFF(%ecx,%edx,8) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + faddl zero_one@GOTOFF(%ecx,%edx,8) + xorl $1, %edx + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + faddl zero_one@GOTOFF(%ecx,%edx,8) + movzwl 24(%esp), %edx + fadd %st, %st(1) + fxch %st(1) + fstpt 8(%ebp) + andl $-32768, %edx + movzwl 16(%ebp), %eax + andl $32767, %eax + movl %eax, %edi + addl $-16383, %eax + negl %edi + addl $-2, %edi + andl $32767, %edi + orl %edi, %edx + movl 12(%ebp), %edi + shrl $23, %edi + andl $255, %edi + movw %dx, 24(%esp) + fldt 16(%esp) + fmuls __libm_rcp_table_256@GOTOFF(%ecx,%edi,4) + jmp ..B1.54 +..B1.53: + fldt 8(%ebp) + fldl _TWO_32H@GOTOFF(%ecx) + fxch %st(1) + faddl zero_one@GOTOFF(%ecx,%eax,8) + fstpt 8(%ebp) + movzwl 16(%ebp), %edx + movl %edx, %eax + andl $-32768, %edx + andl $32767, %eax + orl $-49153, %edx + addl $-16383, %eax + movw %dx, 16(%ebp) + fldt 8(%ebp) + fld %st(0) + movl 12(%ebp), %edi + fadd %st(2), %st + shrl $23, %edi + fsubp %st, %st(2) + andl $255, %edi + fsub %st(1), %st + fxch %st(1) + fstpt 32(%esp) + flds __libm_rcp_table_256@GOTOFF(%ecx,%edi,4) +..B1.54: + fldt 32(%esp) + fmul %st(1), %st + fxch %st(2) + fmulp %st, %st(1) + fxch %st(1) + faddl 8+_ones@GOTOFF(%ecx) + fld %st(0) + movl %eax, 16(%esp) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fildl 16(%esp) + fldt 60+_P@GOTOFF(%ecx) + fmul %st(3), %st + fldt 36+_P@GOTOFF(%ecx) + shll $4, %edi + faddp %st, %st(1) + fmul %st(3), %st + testl %ebx, %ebx + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fmulp %st, %st(2) + fldt 48+_P@GOTOFF(%ecx) + fmul %st(3), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(3), %st + fldt _P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.0@GOTOFF(%ecx) + fmul %st(1), %st + fldt .L_2il0floatpacket.1@GOTOFF(%ecx) + fmulp %st, %st(2) + faddl 8+__libm_logl_table_256@GOTOFF(%ecx,%edi) + faddp %st, %st(3) + faddl __libm_logl_table_256@GOTOFF(%edi,%ecx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%esp) + je ..B1.56 +..B1.55: + fldcw 14(%esp) +..B1.56: + fldt 32(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.57: + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.77 +..B1.58: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.59: + fldcw 12(%esp) +..B1.60: + movl $1, %edx +..B1.61: + fldl 8+_ones@GOTOFF(%ecx) + fstpt 16(%esp) + fldt 16(%esp) + fldl _zeros@GOTOFF(%ecx) + fldt 8(%ebp) + fucomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jp ..B1.62 + je ..B1.63 +..B1.62: + fldl _infs@GOTOFF(%ecx) + fmulp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.64 +..B1.63: + fldt 16(%esp) + fdivp %st, %st(1) + fstpt 16(%esp) +..B1.64: + testl %edx, %edx + je ..B1.66 +..B1.65: + fldcw 14(%esp) +..B1.66: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.67: + cmpl $0, 12(%ebp) + jne ..B1.69 +..B1.68: + cmpl $0, 8(%ebp) + je ..B1.70 +..B1.69: + fldt _small_value_80@GOTOFF(%ecx) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fmul %st(0), %st + fstpt (%esp) + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ecx) + fmul %st(1), %st + fxch %st(1) + fmull _ones@GOTOFF(%ecx,%eax,8) + fsubrp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ecx) + fstpt 16(%esp) + jmp ..B1.16 +..B1.70: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.16 +..B1.71: + xorl %edx, %edx + jmp ..B1.14 +..B1.72: + xorl %eax, %eax + jmp ..B1.23 +..B1.73: + xorl %eax, %eax + jmp ..B1.30 +..B1.74: + xorl %eax, %eax + jmp ..B1.37 +..B1.75: + xorl %eax, %eax + jmp ..B1.44 +..B1.76: + xorl %ebx, %ebx + jmp ..B1.51 +..B1.77: + xorl %edx, %edx + jmp ..B1.61 +..B1.78: + movl %ebx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.90 +..B1.79: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.80: + fldcw 12(%esp) +..B1.81: + movzbl 17(%ebp), %eax + movl $1, %edx + andl $128, %eax + shrl $7, %eax +..B1.82: + testl %eax, %eax + je ..B1.85 +..B1.83: + cmpl $-2147483648, 12(%ebp) + jne ..B1.85 +..B1.84: + cmpl $0, 8(%ebp) + je ..B1.89 +..B1.85: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ecx) + fstpt 16(%esp) +..B1.86: + testl %edx, %edx + je ..B1.88 +..B1.87: + fldcw 14(%esp) +..B1.88: + fldt 16(%esp) + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret +..B1.89: + fldl _infs@GOTOFF(%ecx) + fmull _zeros@GOTOFF(%ecx) + fstpt 16(%esp) + jmp ..B1.86 +..B1.90: + xorl %edx, %edx + jmp ..B1.82 + .align 16,0x90 + .type log1pl,@function + .size log1pl,.-log1pl + .data +# -- End log1pl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 8 +zero_one: + .long 0x00000000,0x00000000 + .long 0x00000000,0x3ff00000 + .type zero_one,@object + .size zero_one,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +ranges: + .long 1078558720 + .long 3221127168 + .type ranges,@object + .size ranges,8 + .align 4 +_shifters: + .long 0 + .long 1098383360 + .long 0 + .long 1123549184 + .type _shifters,@object + .size _shifters,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q3: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 4096 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 53521 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 65509 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 43631 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 43680 + .word 43690 + .word 6 + .word 32768 + .word 49149 + .word 0 + .word 60885 + .word 52536 + .word 52444 + .word 52428 + .word 16380 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 14363 + .word 62279 + .word 27629 + .word 62293 + .word 49080 + .word 0 + .word 44555 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 64968 + .word 65535 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 50395 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 39590 + .word 43714 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 15749 + .word 18782 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 61040 + .word 7204 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 10454 + .word 61175 + .word 14561 + .word 58254 + .word 16379 + .word 0 + .word 57771 + .word 22430 + .word 52985 + .word 52428 + .word 49147 + .word 0 + .word 7036 + .word 15828 + .word 36565 + .word 47662 + .word 16379 + .word 0 + .word 17194 + .word 46991 + .word 54030 + .word 43687 + .word 49147 + .word 0 + .word 63541 + .word 11931 + .word 21910 + .word 40326 + .word 16379 + .word 0 + .word 36457 + .word 1697 + .word 61895 + .word 37932 + .word 49147 + .word 0 + .word 65454 + .word 16107 + .word 6024 + .word 35469 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .type _Q,@object + .size _Q,192 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .type _P,@object + .size _P,72 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log2_wmt.S b/external/sgx_libm/ia32/log2_wmt.S new file mode 100644 index 0000000000..4033738373 --- /dev/null +++ b/external/sgx_libm/ia32/log2_wmt.S @@ -0,0 +1,808 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin log2 + .text + .align 16,0x90 + .globl log2 +log2: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movl $1069088768, %ecx + movd %ecx, %xmm7 + xorpd %xmm3, %xmm3 + movl $30704, %edx + pinsrw $3, %edx, %xmm3 + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm1 + movl $32768, %edx + movd %edx, %xmm4 + movapd 2112(%ebx), %xmm5 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $16352, %ecx + psllq $5, %xmm0 + movsd 2128(%ebx), %xmm2 + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + mulss %xmm7, %xmm0 + orpd %xmm3, %xmm1 + andpd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + subsd %xmm5, %xmm1 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm6, %xmm0 + andl $32752, %eax + subl %ecx, %eax + sarl $4, %eax + cvtsi2sdl %eax, %xmm7 + mulpd %xmm0, %xmm5 + mulsd %xmm0, %xmm1 + movapd 2064(%ebx), %xmm3 + subsd %xmm2, %xmm5 + andl $16711680, %edx + shrl $12, %edx + movapd -912(%ebx,%edx), %xmm0 + movapd 2080(%ebx), %xmm4 + addsd %xmm5, %xmm1 + movapd 2096(%ebx), %xmm2 + movsd 2136(%ebx), %xmm6 + pshufd $68, %xmm1, %xmm5 + mulsd %xmm1, %xmm3 + addsd %xmm7, %xmm0 + mulpd %xmm5, %xmm4 + mulpd %xmm5, %xmm5 + addpd %xmm2, %xmm4 + mulpd %xmm5, %xmm3 + pshufd $228, %xmm0, %xmm7 + addsd %xmm1, %xmm0 + mulsd %xmm1, %xmm4 + subsd %xmm0, %xmm7 + mulsd %xmm1, %xmm6 + addsd %xmm7, %xmm1 + pshufd $238, %xmm0, %xmm2 + mulsd %xmm5, %xmm5 + addsd %xmm6, %xmm1 + addpd %xmm3, %xmm4 + addsd %xmm2, %xmm1 + mulpd %xmm5, %xmm4 + addsd %xmm4, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm1 + addl $16, %eax + cmpl $32768, %eax + jae .L_2TAG_PACKET_3.0.3 + cmpl $16, %eax + jb .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + ja .L_2TAG_PACKET_5.0.3 + cmpl $0, %edx + ja .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_3.0.3: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + addl %ecx, %ecx + cmpl $-2097152, %ecx + jae .L_2TAG_PACKET_6.0.3 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_7.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + movl $171, %edx + mulsd %xmm1, %xmm0 +.L_2TAG_PACKET_9.0.3: + movsd %xmm0, (%esp) + movsd 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_10.0.3 +.L_2TAG_PACKET_8.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + divsd %xmm1, %xmm0 + movl $170, %edx + jmp .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_4.0.3: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_8.0.3 + xorpd %xmm1, %xmm1 + movl $18416, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movapd %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $18416, %ecx + psllq $5, %xmm0 + movsd 2128(%ebx), %xmm2 + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_10.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type log2,@function + .size log2,.-log2 + .data +# -- End log2 + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 3065110528 + .long 1072676937 + .long 969155058 + .long 1027421928 + .long 3789631488 + .long 1072660714 + .long 1061361078 + .long 1026032326 + .long 2461925376 + .long 1072644578 + .long 1624763829 + .long 3175910818 + .long 3729080320 + .long 1072628527 + .long 1845599454 + .long 1028591843 + .long 3710689280 + .long 1072612561 + .long 3776236642 + .long 1025648432 + .long 2882404352 + .long 1072596679 + .long 3683226528 + .long 3174591570 + .long 1779716096 + .long 1072580880 + .long 1916484889 + .long 3173934989 + .long 996708352 + .long 1072565163 + .long 716999656 + .long 3175673444 + .long 1184837632 + .long 1072549527 + .long 1973599317 + .long 3174949482 + .long 3051761664 + .long 1072533971 + .long 1437348984 + .long 1028530411 + .long 3065225216 + .long 1072518495 + .long 1219343899 + .long 1028525753 + .long 2041864192 + .long 1072503098 + .long 388496599 + .long 3175919551 + .long 851140608 + .long 1072487779 + .long 2822909360 + .long 3173772990 + .long 414302208 + .long 1072472537 + .long 1306322068 + .long 1026235748 + .long 1703325696 + .long 1072457371 + .long 1651655805 + .long 3174368281 + .long 1444937728 + .long 1072442281 + .long 1145646243 + .long 3175573309 + .long 709566464 + .long 1072427266 + .long 3608295147 + .long 3168585112 + .long 615415808 + .long 1072412325 + .long 2957847316 + .long 1027961637 + .long 2327523328 + .long 1072397457 + .long 3266875511 + .long 3175163169 + .long 2761863168 + .long 1072382662 + .long 3329930550 + .long 1027790656 + .long 3174416384 + .long 1072367939 + .long 3349298596 + .long 3172501429 + .long 570335232 + .long 1072353288 + .long 905028281 + .long 3175970581 + .long 588005376 + .long 1072338707 + .long 40558280 + .long 1022275054 + .long 318357504 + .long 1072324196 + .long 3000963593 + .long 3175644723 + .long 1188933632 + .long 1072309754 + .long 1152643439 + .long 3171407768 + .long 373186560 + .long 1072295381 + .long 3440409283 + .long 3174861647 + .long 3674587136 + .long 1072281075 + .long 1985407462 + .long 1026124611 + .long 4051050496 + .long 1072266837 + .long 2734481544 + .long 1026856954 + .long 3089022976 + .long 1072252666 + .long 3365453112 + .long 1028135364 + .long 2412838912 + .long 1072238561 + .long 1203709499 + .long 3175656792 + .long 3683999744 + .long 1072224521 + .long 4237943120 + .long 3176014210 + .long 10571776 + .long 1072210547 + .long 1358548904 + .long 3174161579 + .long 1716314112 + .long 1072196636 + .long 1192519078 + .long 3175777045 + .long 1980272640 + .long 1072182789 + .long 1567013979 + .long 3174472130 + .long 2605957120 + .long 1072169005 + .long 1671600287 + .long 1028158963 + .long 1135812608 + .long 1072155284 + .long 1547709291 + .long 3174179085 + .long 3735490560 + .long 1072141624 + .long 2225392115 + .long 1027056729 + .long 3718443008 + .long 1072128026 + .long 3797315894 + .long 3175978381 + .long 3020144640 + .long 1072114489 + .long 569231379 + .long 3176080301 + .long 3607605248 + .long 1072101012 + .long 2931542967 + .long 1028585043 + .long 3183849472 + .long 1072087595 + .long 1779595699 + .long 1025078612 + .long 3777277952 + .long 1072074237 + .long 3836888569 + .long 3176101128 + .long 3151212544 + .long 1072060938 + .long 4204238866 + .long 1027628024 + .long 3393323008 + .long 1072047697 + .long 3590952967 + .long 1024914744 + .long 2325151744 + .long 1072034514 + .long 2081953065 + .long 1024436445 + .long 2091569152 + .long 1072021388 + .long 1869579321 + .long 3176039801 + .long 570331136 + .long 1072008319 + .long 1169272038 + .long 1028145343 + .long 4256530432 + .long 1071995305 + .long 3897289024 + .long 3171837174 + .long 2492289024 + .long 1071982348 + .long 3892405903 + .long 3175484647 + .long 1826058240 + .long 1071969446 + .long 4079999923 + .long 3175326622 + .long 242364416 + .long 1071956599 + .long 850820968 + .long 3175983841 + .long 46260224 + .long 1071943806 + .long 2164938638 + .long 1028426857 + .long 3567947776 + .long 1071931066 + .long 2011723452 + .long 1028083988 + .long 277430272 + .long 1071918381 + .long 2531435800 + .long 3169601318 + .long 1143848960 + .long 1071905748 + .long 294923185 + .long 1023738369 + .long 4275343360 + .long 1071893167 + .long 2459435756 + .long 1028412742 + .long 3508592640 + .long 1071880639 + .long 503755275 + .long 3173140530 + .long 1293312000 + .long 1071868163 + .long 3333822795 + .long 1026993594 + .long 101961728 + .long 1071855738 + .long 2904005851 + .long 1027338469 + .long 2429362176 + .long 1071843363 + .long 1235892196 + .long 3175679811 + .long 2202386432 + .long 1071831039 + .long 2295142960 + .long 1028565357 + .long 1959501824 + .long 1071818765 + .long 254808788 + .long 1028157588 + .long 4260454400 + .long 1071806540 + .long 1281464327 + .long 3173548784 + .long 3096002560 + .long 1071794365 + .long 2126040068 + .long 3168834094 + .long 1067458560 + .long 1071782239 + .long 957416402 + .long 3171516564 + .long 796413952 + .long 1071770161 + .long 3663270514 + .long 1026937343 + .long 629456896 + .long 1071758131 + .long 2081311685 + .long 1026861414 + .long 3227787264 + .long 1071746148 + .long 325239760 + .long 3175812466 + .long 2681995264 + .long 1071734213 + .long 692600417 + .long 1028316258 + .long 1691656192 + .long 1071722325 + .long 2854288619 + .long 3174069820 + .long 2975059968 + .long 1071710483 + .long 2357806657 + .long 3175896595 + .long 1853362176 + .long 1071686938 + .long 182026883 + .long 3174676055 + .long 4247105536 + .long 1071663574 + .long 1264810745 + .long 1026738550 + .long 671424512 + .long 1071636109 + .long 321222784 + .long 1028039985 + .long 4092968960 + .long 1071590092 + .long 3658154599 + .long 3175856095 + .long 193347584 + .long 1071544424 + .long 723354347 + .long 3173824323 + .long 985587712 + .long 1071499097 + .long 2344377442 + .long 1027857554 + .long 1801297920 + .long 1071454107 + .long 2398211919 + .long 3175430015 + .long 2750758912 + .long 1071409449 + .long 223148174 + .long 1028267694 + .long 118882304 + .long 1071365119 + .long 1958423088 + .long 1026816298 + .long 3531350016 + .long 1071321110 + .long 875023512 + .long 1027316085 + .long 1581752320 + .long 1071277420 + .long 345754833 + .long 1027657950 + .long 473587712 + .long 1071234043 + .long 3024467474 + .long 3175496105 + .long 2533163008 + .long 1071190974 + .long 3279280870 + .long 3173991880 + .long 1902854144 + .long 1071148210 + .long 3170372974 + .long 3174359141 + .long 1709547520 + .long 1071105746 + .long 3312617382 + .long 3175326532 + .long 1168744448 + .long 1071063578 + .long 2799128425 + .long 1027228825 + .long 4163903488 + .long 1071021701 + .long 1285964057 + .long 3176060221 + .long 2056257536 + .long 1070980113 + .long 2706516695 + .long 1028650734 + .long 3739770880 + .long 1070938808 + .long 246392277 + .long 3174722093 + .long 1271734272 + .long 1070897784 + .long 3679462403 + .long 3174159366 + .long 4223328256 + .long 1070857035 + .long 2433294629 + .long 1027980203 + .long 1015963648 + .long 1070816560 + .long 4253198713 + .long 1026847814 + .long 1862295552 + .long 1070776353 + .long 1509191037 + .long 3173682029 + .long 103178240 + .long 1070736412 + .long 3582688163 + .long 3173089500 + .long 2264358912 + .long 1070696732 + .long 1779381280 + .long 1025292403 + .long 2278850560 + .long 1070657311 + .long 3240888728 + .long 1027177644 + .long 2954207232 + .long 1070618145 + .long 3564986365 + .long 1024870970 + .long 1865613312 + .long 1070562367 + .long 3892585078 + .long 1027946215 + .long 3434348544 + .long 1070485036 + .long 3011363162 + .long 3175199985 + .long 671449088 + .long 1070408197 + .long 1145012811 + .long 1026506981 + .long 1327038464 + .long 1070331842 + .long 227553652 + .long 1028331265 + .long 766836736 + .long 1070255966 + .long 518075456 + .long 3175312400 + .long 3434479616 + .long 1070180562 + .long 1452680450 + .long 3174267422 + .long 1364688896 + .long 1070105626 + .long 2571031723 + .long 3174222501 + .long 4236263424 + .long 1070031150 + .long 3514507731 + .long 3175326685 + .long 706019328 + .long 1069957131 + .long 2980398698 + .long 1026808442 + .long 1347502080 + .long 1069883561 + .long 1818423398 + .long 3175271900 + .long 4280483840 + .long 1069810435 + .long 3925170731 + .long 3175415416 + .long 3750608896 + .long 1069737749 + .long 710015584 + .long 3170118559 + .long 3004235776 + .long 1069665497 + .long 3823542833 + .long 3174354681 + .long 1393737728 + .long 1069593674 + .long 4238122296 + .long 1028475778 + .long 1621164032 + .long 1069497029 + .long 2232087921 + .long 3175937870 + .long 2762080256 + .long 1069355067 + .long 3580752115 + .long 3175802838 + .long 2914779136 + .long 1069213933 + .long 1251526596 + .long 1028548772 + .long 3808428032 + .long 1069073617 + .long 1491573749 + .long 1025131695 + .long 3589865472 + .long 1068934110 + .long 2320751647 + .long 3175285520 + .long 1102381056 + .long 1068795403 + .long 2369472545 + .long 3174735692 + .long 164790272 + .long 1068657486 + .long 3958705468 + .long 1027545055 + .long 966098944 + .long 1068520350 + .long 91754714 + .long 3174161762 + .long 100794368 + .long 1068269030 + .long 3205869737 + .long 3173509296 + .long 2079653888 + .long 1067997831 + .long 930310477 + .long 1028614386 + .long 3471048704 + .long 1067728143 + .long 1091811766 + .long 1028000848 + .long 1092419584 + .long 1067459950 + .long 629649056 + .long 3175844743 + .long 3079012352 + .long 1066936100 + .long 3939938999 + .long 3172112142 + .long 3666608128 + .long 1066405591 + .long 4185504407 + .long 3175959388 + .long 526647296 + .long 1065354156 + .long 1469727419 + .long 3173760470 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1367832035 + .long 1066403058 + .long 2677381210 + .long 3216320731 + .long 3610762001 + .long 3214607116 + .long 1215221452 + .long 1069835102 + .long 2894285243 + .long 1067936923 + .long 3011779882 + .long 3218479542 + .long 4160749568 + .long 4294967295 + .long 0 + .long 4294959104 + .long 0 + .long 1073160192 + .long 370913857 + .long 3210587105 + .type static_const_table,@object + .size static_const_table,2144 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log2f_wmt.S b/external/sgx_libm/ia32/log2f_wmt.S new file mode 100644 index 0000000000..6d3fbbcf6b --- /dev/null +++ b/external/sgx_libm/ia32/log2f_wmt.S @@ -0,0 +1,745 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2f_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin log2f + .text + .align 16,0x90 + .globl log2f +log2f: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl $16384, %ecx + movd %ecx, %xmm4 + movl $-32768, %eax + movd %eax, %xmm2 + xorpd %xmm3, %xmm3 + movl $16368, %edx + pinsrw $3, %edx, %xmm3 + xorpd %xmm5, %xmm5 +.L_2TAG_PACKET_0.0.3: + movd %xmm0, %edx + rcpss %xmm0, %xmm1 + movsd 2080(%ebx), %xmm7 + pshuflw $68, %xmm0, %xmm0 + paddd %xmm4, %xmm1 + subl $8388608, %edx + cmpl $2113929216, %edx + jae .L_2TAG_PACKET_1.0.3 + andps %xmm1, %xmm2 + cvtps2pd %xmm0, %xmm0 + cvtps2pd %xmm2, %xmm1 + movd %xmm2, %eax + andl $-8388608, %edx + subl $1056964608, %edx + movl %edx, %ecx + sarl $23, %edx + cvtsi2sdl %edx, %xmm6 + mulsd %xmm1, %xmm0 + subl $1056964608, %ecx + addl %ecx, %eax + shrl $12, %eax + movsd (%ebx,%eax), %xmm4 + subsd %xmm3, %xmm0 + movsd 2088(%ebx), %xmm2 + movsd 2096(%ebx), %xmm1 + mulsd %xmm0, %xmm7 + addsd %xmm0, %xmm5 + mulsd %xmm0, %xmm0 + addsd %xmm4, %xmm6 + addsd %xmm7, %xmm1 + mulsd %xmm2, %xmm5 + mulsd %xmm1, %xmm0 + mulsd %xmm2, %xmm0 + addsd %xmm6, %xmm5 + addsd %xmm0, %xmm5 + cvtpd2ps %xmm5, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + addl $8388608, %edx + js .L_2TAG_PACKET_3.0.3 + cmpl $8388608, %edx + jb .L_2TAG_PACKET_4.0.3 + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_5.0.3 + movl $528482304, %eax + movd %eax, %xmm6 + movsd 2064(%ebx), %xmm5 + mulss %xmm6, %xmm0 + jmp .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_5.0.3: + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $-2147483648, %edx + je .L_2TAG_PACKET_6.0.3 + addl %edx, %edx + cmpl $-16777216, %edx + ja .L_2TAG_PACKET_5.0.3 + xorps %xmm0, %xmm0 + divss %xmm0, %xmm0 + movl $173, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $0, %edx + je .L_2TAG_PACKET_6.0.3 + movl $1602224128, %eax + movd %eax, %xmm7 + mulss %xmm7, %xmm0 + movsd 2072(%ebx), %xmm5 + jmp .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_6.0.3: + movl $-1082130432, %eax + movd %eax, %xmm0 + xorps %xmm1, %xmm1 + divss %xmm1, %xmm0 + movl $172, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_2.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type log2f,@function + .size log2f,.-log2f + .data +# -- End log2f + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 1998916263 + .long 1072681452 + .long 3173270495 + .long 1072669702 + .long 2000860199 + .long 1072657998 + .long 1272047984 + .long 1072646339 + .long 3794524037 + .long 1072634724 + .long 3803106495 + .long 1072623154 + .long 4139350621 + .long 1072611628 + .long 3366391848 + .long 1072600146 + .long 63662823 + .long 1072588708 + .long 1416582474 + .long 1072577312 + .long 1741478598 + .long 1072565959 + .long 3960187916 + .long 1072554648 + .long 2419954872 + .long 1072543380 + .long 73073096 + .long 1072532154 + .long 4181694601 + .long 1072520968 + .long 547806622 + .long 1072509825 + .long 757656496 + .long 1072498722 + .long 3526834581 + .long 1072487659 + .long 3290001261 + .long 1072476637 + .long 3085585033 + .long 1072465655 + .long 1670680485 + .long 1072454713 + .long 2110786378 + .long 1072443810 + .long 3189678060 + .long 1072432946 + .long 3704185224 + .long 1072422121 + .long 2464005749 + .long 1072411335 + .long 2586490145 + .long 1072400587 + .long 2906527345 + .long 1072389877 + .long 2271335546 + .long 1072379205 + .long 3835256167 + .long 1072368570 + .long 2174681645 + .long 1072357973 + .long 467757278 + .long 1072347413 + .long 1904282206 + .long 1072336889 + .long 1095613242 + .long 1072326402 + .long 1254375265 + .long 1072315951 + .long 1309403273 + .long 1072305536 + .long 200556308 + .long 1072295157 + .long 1173533989 + .long 1072284813 + .long 3189793736 + .long 1072274504 + .long 926405093 + .long 1072264231 + .long 1955775707 + .long 1072253992 + .long 975706757 + .long 1072243788 + .long 1284091012 + .long 1072233618 + .long 1893874830 + .long 1072223482 + .long 1827891621 + .long 1072213380 + .long 118730237 + .long 1072203312 + .long 103572845 + .long 1072193277 + .long 834133047 + .long 1072183275 + .long 1371497981 + .long 1072173306 + .long 786005198 + .long 1072163370 + .long 2452088827 + .long 1072153466 + .long 1163258553 + .long 1072143595 + .long 311851589 + .long 1072133756 + .long 3298982784 + .long 1072123948 + .long 649529288 + .long 1072114173 + .long 76790007 + .long 1072104429 + .long 712572003 + .long 1072094716 + .long 1697017023 + .long 1072085034 + .long 2178495145 + .long 1072075383 + .long 1313500133 + .long 1072065763 + .long 2561513738 + .long 1072056173 + .long 800002435 + .long 1072046614 + .long 3799154139 + .long 1072037084 + .long 2157008926 + .long 1072027585 + .long 3659100731 + .long 1072018115 + .long 3213591115 + .long 1072008675 + .long 31044775 + .long 1071999265 + .long 1919304603 + .long 1071989883 + .long 3808564412 + .long 1071980530 + .long 636181417 + .long 1071971207 + .long 231490093 + .long 1071961912 + .long 1840879012 + .long 1071952645 + .long 422672785 + .long 1071943407 + .long 3826917183 + .long 1071934196 + .long 2730525283 + .long 1071925014 + .long 701967006 + .long 1071915860 + .long 1316286934 + .long 1071906733 + .long 3860057913 + .long 1071897633 + .long 3331303149 + .long 1071888561 + .long 3324321351 + .long 1071879516 + .long 3144709244 + .long 1071870498 + .long 2104254386 + .long 1071861507 + .long 3815829096 + .long 1071852542 + .long 3308416273 + .long 1071843604 + .long 4206907352 + .long 1071834692 + .long 1552162950 + .long 1071825807 + .long 3275780188 + .long 1071816947 + .long 135253478 + .long 1071808114 + .long 73645744 + .long 1071799306 + .long 2449718467 + .long 1071790523 + .long 2332833768 + .long 1071781766 + .long 3387792013 + .long 1071773034 + .long 694899285 + .long 1071764328 + .long 2224741414 + .long 1071755646 + .long 3068318658 + .long 1071746989 + .long 2616854210 + .long 1071738357 + .long 266767097 + .long 1071729750 + .long 4009547812 + .long 1071721166 + .long 366929114 + .long 1071712608 + .long 1635468980 + .long 1071704073 + .long 2936821143 + .long 1071695562 + .long 3692515865 + .long 1071687075 + .long 3328937712 + .long 1071678612 + .long 1277271392 + .long 1071670173 + .long 1268415641 + .long 1071661757 + .long 2742995963 + .long 1071653364 + .long 851312691 + .long 1071644995 + .long 2971350593 + .long 1071628625 + .long 3905998082 + .long 1071611978 + .long 3424346780 + .long 1071595377 + .long 453058438 + .long 1071578822 + .long 2517515273 + .long 1071562311 + .long 4266887860 + .long 1071545845 + .long 358942687 + .long 1071529425 + .long 2639818283 + .long 1071513048 + .long 1489227762 + .long 1071496716 + .long 180106617 + .long 1071480428 + .long 1993621493 + .long 1071464183 + .long 1629147435 + .long 1071447982 + .long 2384050109 + .long 1071431824 + .long 3268698085 + .long 1071415709 + .long 3301345460 + .long 1071399637 + .long 1508048308 + .long 1071383608 + .long 1217549516 + .long 1071367621 + .long 1471262833 + .long 1071351676 + .long 1318159864 + .long 1071335773 + .long 4109658129 + .long 1071319911 + .long 319673664 + .long 1071304092 + .long 1904282206 + .long 1071288313 + .long 3646937343 + .long 1071272575 + .long 338264500 + .long 1071256879 + .long 3955855899 + .long 1071241222 + .long 714524339 + .long 1071225607 + .long 2605838414 + .long 1071210031 + .long 153410875 + .long 1071194496 + .long 1067533806 + .long 1071179000 + .long 180337971 + .long 1071163544 + .long 920560604 + .long 1071148127 + .long 2428575699 + .long 1071132749 + .long 3851294344 + .long 1071117410 + .long 47131309 + .long 1071102111 + .long 3060776247 + .long 1071086849 + .long 3468423567 + .long 1071071626 + .long 442479858 + .long 1071056442 + .long 1751501034 + .long 1071041295 + .long 2285293781 + .long 1071026186 + .long 1234723448 + .long 1071011115 + .long 2091653508 + .long 1070996081 + .long 4058951182 + .long 1070981084 + .long 2050428397 + .long 1070966125 + .long 3870652645 + .long 1070951202 + .long 150118312 + .long 1070936317 + .long 2999895448 + .long 1070921467 + .long 3061900616 + .long 1070906654 + .long 3868579735 + .long 1070891877 + .long 368016775 + .long 1070877137 + .long 398716067 + .long 1070862432 + .long 3214712303 + .long 1070847762 + .long 3780484976 + .long 1070833128 + .long 1360840737 + .long 1070818530 + .long 3815829096 + .long 1070803966 + .long 1830887666 + .long 1070789438 + .long 3276530156 + .long 1070774944 + .long 3143525540 + .long 1070760485 + .long 722718060 + .long 1070746061 + .long 3899945937 + .long 1070731670 + .long 3386189576 + .long 1070717314 + .long 2782295200 + .long 1070702992 + .long 1399058777 + .long 1070688704 + .long 2847114277 + .long 1070674449 + .long 2151986001 + .long 1070660228 + .long 2933912513 + .long 1070646040 + .long 227932728 + .long 1070631886 + .long 1958678199 + .long 1070617764 + .long 3170525653 + .long 1070603675 + .long 2119878685 + .long 1070583143 + .long 2835758645 + .long 1070555096 + .long 2899780145 + .long 1070527114 + .long 1026954088 + .long 1070499197 + .long 236130878 + .long 1070471344 + .long 3554951635 + .long 1070443554 + .long 1134865757 + .long 1070415829 + .long 315822346 + .long 1070388167 + .long 4151355006 + .long 1070360567 + .long 2818569420 + .long 1070333031 + .long 3682837470 + .long 1070305557 + .long 1232950086 + .long 1070278146 + .long 2850845811 + .long 1070250796 + .long 3041732649 + .long 1070223508 + .long 613883718 + .long 1070196282 + .long 2973531841 + .long 1070169116 + .long 354993871 + .long 1070142012 + .long 180337971 + .long 1070114968 + .long 1289509543 + .long 1070087984 + .long 2530196301 + .long 1070061060 + .long 2757759525 + .long 1070034196 + .long 835166085 + .long 1070007392 + .long 4222855792 + .long 1069980646 + .long 3208871137 + .long 1069953960 + .long 973562605 + .long 1069927333 + .long 704621746 + .long 1069900764 + .long 1302049555 + .long 1069874253 + .long 1673060149 + .long 1069847800 + .long 732017834 + .long 1069821405 + .long 1695342161 + .long 1069795067 + .long 3491511767 + .long 1069768786 + .long 761003473 + .long 1069742563 + .long 1036101224 + .long 1069716396 + .long 3266000023 + .long 1069690285 + .long 2111714268 + .long 1069664231 + .long 830921328 + .long 1069638233 + .long 2687969258 + .long 1069612290 + .long 2363885129 + .long 1069586403 + .long 3136187749 + .long 1069560571 + .long 3692892517 + .long 1069522069 + .long 3570253499 + .long 1069470625 + .long 3908238678 + .long 1069419290 + .long 2723302721 + .long 1069368064 + .long 2339434949 + .long 1069316946 + .long 798118803 + .long 1069265936 + .long 448161615 + .long 1069215033 + .long 3650623571 + .long 1069164236 + .long 4188780490 + .long 1069113546 + .long 152924137 + .long 1069062963 + .long 2530196301 + .long 1069012484 + .long 844750970 + .long 1068962111 + .long 1812361559 + .long 1068911842 + .long 3570519722 + .long 1068861677 + .long 4268273545 + .long 1068811616 + .long 2066132126 + .long 1068761659 + .long 3725905754 + .long 1068711804 + .long 3135775963 + .long 1068662052 + .long 2785039517 + .long 1068612402 + .long 879114973 + .long 1068562854 + .long 4224353950 + .long 1068513406 + .long 621328030 + .long 1068429177 + .long 522185727 + .long 1068330685 + .long 354069551 + .long 1068232393 + .long 930992923 + .long 1068134300 + .long 3088087314 + .long 1068036405 + .long 3386464469 + .long 1067938708 + .long 2702982241 + .long 1067841208 + .long 1935110224 + .long 1067743904 + .long 2000764363 + .long 1067646795 + .long 3838143225 + .long 1067549880 + .long 4110598596 + .long 1067453159 + .long 3297851897 + .long 1067262895 + .long 3492345695 + .long 1067070223 + .long 2250192214 + .long 1066877934 + .long 1645815860 + .long 1066686026 + .long 3792308805 + .long 1066494497 + .long 207414749 + .long 1066204903 + .long 2718921511 + .long 1065823355 + .long 2393819184 + .long 1065442558 + .long 3228205918 + .long 1064771801 + .long 2754502619 + .long 1063721742 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 4277811695 + .long 1078341186 + .long 4277811695 + .long 3225824834 + .long 1431655765 + .long 1070945621 + .long 1697350398 + .long 1073157447 + .long 1107282704 + .long 3219128321 + .long 354870542 + .long 1071369083 + .type static_const_table,@object + .size static_const_table,2112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log2l.S b/external/sgx_libm/ia32/log2l.S new file mode 100644 index 0000000000..978a410236 --- /dev/null +++ b/external/sgx_libm/ia32/log2l.S @@ -0,0 +1,532 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2l.c" + .text +..TXTST0: +# -- Begin log2l + .text + .align 16,0x90 + .globl log2l +log2l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzbl 17(%ebp), %edi + andl $128, %edi + shrl $7, %edi + movzwl 16(%ebp), %edx + movl %edx, %eax + movl %edi, %ebx + andl $32767, %eax + shll $15, %ebx + movl 12(%ebp), %esi + orl %eax, %ebx + movl %esi, %ecx + shll $16, %ebx + shrl $16, %ecx + orl %ecx, %ebx + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + cmpl $2147450880, %ebx + jae ..B1.29 +..B1.4: + addl $-1073676224, %ebx + cmpl $32863, %ebx + ja ..B1.13 +..B1.5: + cmpl $16383, %eax + je ..B1.39 +..B1.6: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.7: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.8: + fldcw 12(%esp) +..B1.9: + movl $1, %eax +..B1.10: + fldt 8(%ebp) + testl %eax, %eax + fldl _TWO_32H@GOTOFF(%ecx) + fldt 84+_P@GOTOFF(%ecx) + fldt 60+_P@GOTOFF(%ecx) + fldt 36+_P@GOTOFF(%ecx) + fxch %st(4) + faddl 8+_ones@GOTOFF(%ecx) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fld %st(1) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(1) + fsub %st(3), %st + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 72+_P@GOTOFF(%ecx) + fmul %st(5), %st + fldt 48+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(5), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt 96+_P@GOTOFF(%ecx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.12 +..B1.11: + fldcw 14(%esp) +..B1.12: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + movzwl 14(%esp), %esi + movl %esi, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.45 +..B1.14: + orl $-64768, %esi + movw %si, 12(%esp) +..B1.15: + fldcw 12(%esp) +..B1.16: + movzwl 16(%ebp), %edx + movl %edx, %eax + movl $1, %esi + andl $32767, %eax +..B1.17: + testl %eax, %eax + jne ..B1.20 +..B1.18: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%ecx) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _zeros@GOTOFF(%ecx) + fxch %st(1) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B1.19 + je ..B1.42 +..B1.19: + fstp %st(0) + movzwl 16(%ebp), %edx + movl %edx, %eax + movl $-16458, %ebx + andl $32767, %eax + jmp ..B1.21 +..B1.20: + movl $-16383, %ebx +..B1.21: + movl 12(%ebp), %edi + cmpl $-2147483648, %edi + jne ..B1.26 +..B1.22: + cmpl $0, 8(%ebp) + jne ..B1.26 +..B1.23: + addl %eax, %ebx + movl %ebx, 16(%esp) + testl %esi, %esi + fildl 16(%esp) + fstpt (%esp) + je ..B1.25 +..B1.24: + fldcw 14(%esp) +..B1.25: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + fldl _TWO_32H@GOTOFF(%ecx) + andl $-32768, %edx + fldt 84+_P@GOTOFF(%ecx) + orl $-49153, %edx + fldt 60+_P@GOTOFF(%ecx) + addl %eax, %ebx + movw %dx, 16(%ebp) + fldt 8(%ebp) + fld %st(0) + shrl $23, %edi + fadd %st(4), %st + andl $255, %edi + fsubp %st, %st(4) + movl %ebx, 16(%esp) + fsub %st(3), %st + flds __libm_rcp_table_256@GOTOFF(%ecx,%edi,4) + fmul %st, %st(4) + fmulp %st, %st(1) + fxch %st(3) + faddl 8+_ones@GOTOFF(%ecx) + fld %st(0) + shll $4, %edi + fadd %st(4), %st + fld %st(0) + testl %esi, %esi + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 36+_P@GOTOFF(%ecx) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fldt 12+_P@GOTOFF(%ecx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 72+_P@GOTOFF(%ecx) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt _P@GOTOFF(%ecx) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 96+_P@GOTOFF(%ecx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(2) + fildl 16(%esp) + fxch %st(1) + faddl 8+__libm_log2l_table_256@GOTOFF(%ecx,%edi) + fxch %st(1) + faddl __libm_log2l_table_256@GOTOFF(%edi,%ecx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.28 +..B1.27: + fldcw 14(%esp) +..B1.28: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.54 +..B1.30: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.31: + fldcw 12(%esp) +..B1.32: + movzbl 17(%ebp), %edi + movl $1, %edx + andl $128, %edi + shrl $7, %edi +..B1.33: + testl %edi, %edi + jne ..B1.46 +..B1.34: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ecx) + fstpt (%esp) +..B1.35: + testl %edx, %edx + je ..B1.37 +..B1.36: + fldcw 14(%esp) +..B1.37: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.38: + xorl %eax, %eax + jmp ..B1.10 +..B1.39: + cmpl $-2147483648, %esi + jne ..B1.6 +..B1.40: + cmpl $0, 8(%ebp) + jne ..B1.6 +..B1.41: + fldl _zeros@GOTOFF(%ecx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.42: + fldl 8+_ones@GOTOFF(%ecx) + testl %esi, %esi + fdivp %st, %st(1) + fstpl (%esp) + je ..B1.44 +..B1.43: + fldcw 14(%esp) +..B1.44: + fldl (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + xorl %esi, %esi + jmp ..B1.17 +..B1.46: + movzwl 16(%ebp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.49 +..B1.47: + cmpl $-2147483648, 12(%ebp) + jne ..B1.34 +..B1.48: + cmpl $0, 8(%ebp) + jne ..B1.34 + jmp ..B1.53 +..B1.49: + testl %eax, %eax + jne ..B1.53 +..B1.50: + cmpl $0, 12(%ebp) + jne ..B1.53 +..B1.51: + cmpl $0, 8(%ebp) + jne ..B1.53 +..B1.52: + fldl 8+_ones@GOTOFF(%ecx) + fdivl _zeros@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.35 +..B1.53: + fldl _infs@GOTOFF(%ecx) + fmull _zeros@GOTOFF(%ecx) + fstpt (%esp) + jmp ..B1.35 +..B1.54: + xorl %edx, %edx + jmp ..B1.33 + .align 16,0x90 + .type log2l,@function + .size log2l,.-log2l + .data +# -- End log2l + .section .rodata, "a" + .align 4 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_P: + .word 17354 + .word 24031 + .word 3064 + .word 38062 + .word 16360 + .word 0 + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 49150 + .word 0 + .word 60493 + .word 53279 + .word 20193 + .word 63032 + .word 16381 + .word 0 + .word 62043 + .word 23575 + .word 15145 + .word 47274 + .word 49149 + .word 0 + .word 33329 + .word 29325 + .word 25223 + .word 37819 + .word 16381 + .word 0 + .word 5068 + .word 45194 + .word 20193 + .word 63032 + .word 49148 + .word 0 + .word 43239 + .word 63403 + .word 6517 + .word 54028 + .word 16380 + .word 0 + .word 25259 + .word 45714 + .word 45135 + .word 47274 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 14848 + .word 47274 + .word 16383 + .word 0 + .type _P,@object + .size _P,108 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_log2l_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log2l_table.S b/external/sgx_libm/ia32/log2l_table.S new file mode 100644 index 0000000000..ccfd504219 --- /dev/null +++ b/external/sgx_libm/ia32/log2l_table.S @@ -0,0 +1,560 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2l_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_log2l_table_256 + .globl __libm_log2l_table_256 +__libm_log2l_table_256: + .long 0xa42e4000,0x3f671b0e + .long 0x1dbbd1a5,0x3cefda26 + .long 0x8eaec000,0x3f815cfe + .long 0xac00d0eb,0x3cf06028 + .long 0x0c5d0000,0x3f8cfee7 + .long 0x6dfa58c3,0xbd0a2394 + .long 0x62192000,0x3f94564a + .long 0x88333d4e,0x3d0068bc + .long 0xace34000,0x3f997723 + .long 0xac9ac44a,0x3d1765d0 + .long 0xc69b8000,0x3f9f5923 + .long 0xcfb08e1d,0xbd25afb7 + .long 0xa085c000,0x3fa2a094 + .long 0xa481e15f,0x3d2692b8 + .long 0x1776a000,0x3fa53894 + .long 0x36a2459e,0x3d201dc0 + .long 0x9b914000,0x3fa8324c + .long 0x2b15e585,0x3d178efe + .long 0xce080000,0x3faacf54 + .long 0x8e2d6a53,0xbd340b58 + .long 0x58dac000,0x3fadced9 + .long 0xd3ddb87a,0x3d2c119c + .long 0xfbca8000,0x3fb0387e + .long 0x16f872eb,0x3d1a7682 + .long 0x06748000,0x3fb18ac6 + .long 0xdff59ce4,0xbd18ff0d + .long 0x3e136000,0x3fb30edd + .long 0x15f8f5c1,0xbd29e679 + .long 0x59364000,0x3fb463c1 + .long 0x07b8e917,0x3d193671 + .long 0x3c3f8000,0x3fb5b9e1 + .long 0x4ce80f25,0x3d410e4a + .long 0x3259c000,0x3fb7113f + .long 0x637425fc,0x3d403cdb + .long 0x8d1b0000,0x3fb869dd + .long 0x3dfca47b,0x3d401a71 + .long 0xa49d0000,0x3fb9c3be + .long 0x8c6c8e73,0x3d4909ed + .long 0xd7960000,0x3fbb1ee4 + .long 0xf4540d3e,0x3d370159 + .long 0x8b70c000,0x3fbc7b52 + .long 0x0d939dcf,0x3d48e27d + .long 0x2c678000,0x3fbdd90a + .long 0x04d3d5b4,0xbd312b9c + .long 0x976c4000,0x3fbf05d4 + .long 0xcd9838ba,0xbd3fd7bc + .long 0xbaee8000,0x3fc032fb + .long 0x7d1edf2f,0xbd429af3 + .long 0xa9f32000,0x3fc0e3b5 + .long 0xeeb39e80,0x3d3094fb + .long 0x5c7d2000,0x3fc19519 + .long 0xa7453897,0xbd3b4aad + .long 0xc2ab2000,0x3fc22dad + .long 0xd23af327,0x3d4496d2 + .long 0x231e0000,0x3fc2e050 + .long 0xa377c7ec,0xbd350520 + .long 0x9c2b2000,0x3fc379f7 + .long 0xa3793dbe,0x3d256aea + .long 0x2ba1c000,0x3fc42ddd + .long 0xac74b87f,0xbd36ad5b + .long 0x9e680000,0x3fc4c89b + .long 0x02de76ad,0x3d2fd2e8 + .long 0x29ffc000,0x3fc563dc + .long 0x78df21ad,0xbd434df3 + .long 0x5f5d8000,0x3fc619a2 + .long 0xaf108e66,0xbd29cc54 + .long 0xbf368000,0x3fc6b5ff + .long 0x175a06f6,0xbd337788 + .long 0xf6610000,0x3fc752e1 + .long 0x902c7d37,0xbd2ca90f + .long 0xe7540000,0x3fc7f049 + .long 0xec326af7,0xbd483153 + .long 0x0abfc000,0x3fc8a898 + .long 0xab240e90,0xbd166ccc + .long 0xcca64000,0x3fc94724 + .long 0x82d7bfe5,0x3d47be4d + .long 0x24970000,0x3fc9e63a + .long 0xca6bec19,0x3d4f45ea + .long 0xfeb20000,0x3fca85d8 + .long 0xd08dc20f,0x3d17b6aa + .long 0x497d8000,0x3fcb2602 + .long 0x90cb67ba,0xbd565d39 + .long 0xf5ee4000,0x3fcbc6b6 + .long 0xcabaa043,0xbd51b254 + .long 0xf770c000,0x3fcc67f7 + .long 0xab00c050,0xbd49821f + .long 0xb2234000,0x3fcceec4 + .long 0xdad67ab8,0x3d3f73bc + .long 0x7ad10000,0x3fcd9109 + .long 0x370c6558,0x3d5cc12e + .long 0x57f3c000,0x3fce33dd + .long 0x4a928ccd,0x3d433481 + .long 0x46bc8000,0x3fced741 + .long 0x984a7cdc,0xbd23bfd7 + .long 0x46ff0000,0x3fcf7b36 + .long 0x48e15c73,0xbd32f9b5 + .long 0xa943e000,0x3fd00223 + .long 0x00388584,0xbd2f3862 + .long 0x74bf0000,0x3fd054a4 + .long 0xf7113597,0x3d4d6efe + .long 0x9b926000,0x3fd0999d + .long 0xa7e48c00,0xbd397bf5 + .long 0x6d3b4000,0x3fd0eca6 + .long 0xcb31a070,0xbd5a7f50 + .long 0x2e85c000,0x3fd13ffa + .long 0xc54ae907,0xbd471577 + .long 0x44fa0000,0x3fd185a4 + .long 0x6fa317ed,0x3d44f66d + .long 0x12f28000,0x3fd1cb83 + .long 0xce4e50d0,0xbd1010cf + .long 0x441ce000,0x3fd21fa1 + .long 0xf89df349,0x3d379e4a + .long 0x26e60000,0x3fd265f5 + .long 0x84a6a593,0x3d2e59ad + .long 0xc34be000,0x3fd2baa0 + .long 0xcd51a1bf,0x3d1ebefe + .long 0x45de2000,0x3fd3016b + .long 0xec0723df,0x3d1ce045 + .long 0x38aa2000,0x3fd3486c + .long 0xaa5dfd69,0x3d434f09 + .long 0xefaa8000,0x3fd38fa3 + .long 0x91962d0f,0x3d2313fc + .long 0xc0816000,0x3fd3e562 + .long 0xfa64765f,0x3d440340 + .long 0x1f53c000,0x3fd42d14 + .long 0x167aead5,0xbd4374da + .long 0x543f2000,0x3fd474fd + .long 0x400ce06e,0x3d216293 + .long 0xb6810000,0x3fd4bd1e + .long 0x8d05e4fa,0xbd5ab857 + .long 0x9e236000,0x3fd50578 + .long 0xbbaffd12,0xbd542eea + .long 0x64004000,0x3fd54e0b + .long 0x92de8d74,0xbd323e74 + .long 0x61c40000,0x3fd596d7 + .long 0xb5eabc35,0xbd6f07ff + .long 0xf1eec000,0x3fd5dfdc + .long 0xd2926f16,0xbd51f1bb + .long 0x6fd94000,0x3fd6291c + .long 0xdc0e627c,0xbd4ac899 + .long 0x37b58000,0x3fd67296 + .long 0xd82f9efc,0x3d541782 + .long 0xa6930000,0x3fd6bc4a + .long 0x46b4eaee,0xbd5f036d + .long 0x1a5fc000,0x3fd7063a + .long 0x0e43a37f,0xbd461b8d + .long 0xf1ed0000,0x3fd75064 + .long 0xec06848a,0x3d3c558f + .long 0x8cf10000,0x3fd79acb + .long 0x9ea019ad,0x3d2c7d46 + .long 0x1e438000,0x3fd7d67c + .long 0x2119c4e9,0x3d672dc9 + .long 0x4068c000,0x3fd8214f + .long 0x8322d649,0xbd505944 + .long 0x36dec000,0x3fd86c5f + .long 0x982b6522,0xbd5c2445 + .long 0x64dd8000,0x3fd8b7ac + .long 0x3c24b943,0xbcf8cd4c + .long 0x7a0c8000,0x3fd8f416 + .long 0x1882631a,0xbd506e0d + .long 0xd5e1c000,0x3fd93fd2 + .long 0x37daf317,0xbd0c6d2c + .long 0x84298000,0x3fd98bcd + .long 0x1c4482c6,0xbd56ba65 + .long 0x33e70000,0x3fd9c8c3 + .long 0x2b947c14,0xbd565ac6 + .long 0x14298000,0x3fda152f + .long 0x0e65d2ce,0x3d1b3d7b + .long 0xd95fc000,0x3fda527f + .long 0xad63ae87,0x3d58ff36 + .long 0x3edec000,0x3fda9f5e + .long 0x112e6c5e,0xbd38668d + .long 0x2b574000,0x3fdadd0b + .long 0x1a609aaa,0x3d55a69a + .long 0x6f520000,0x3fdb2a5d + .long 0xfdf426cf,0xbcff5369 + .long 0x99b00000,0x3fdb6867 + .long 0x84b3fb1a,0x3d47c5c7 + .long 0x1b888000,0x3fdbb62f + .long 0xef0b8928,0xbd29427b + .long 0x9f664000,0x3fdbf497 + .long 0x3da6863a,0x3d63342a + .long 0x6e83c000,0x3fdc332a + .long 0xb6303c0d,0xbd6315fe + .long 0xc2d44000,0x3fdc819d + .long 0x95d8ac46,0x3d5fe438 + .long 0x8e19c000,0x3fdcc090 + .long 0x870d5301,0xbd4085c5 + .long 0x611b0000,0x3fdcffae + .long 0xb8e97d14,0xbd676a4e + .long 0x76d44000,0x3fdd3ef7 + .long 0x378ff59d,0xbcc81e2b + .long 0x02710000,0x3fdd8e50 + .long 0x99a48379,0x3d128679 + .long 0x486cc000,0x3fddcdfb + .long 0x57e20e48,0xbd397d70 + .long 0x94244000,0x3fde0dd2 + .long 0x4e05d479,0x3d5fe3e2 + .long 0x22a28000,0x3fde4dd6 + .long 0x3522eadc,0x3d407f39 + .long 0x31710000,0x3fde8e06 + .long 0xd1f94399,0x3d54efc5 + .long 0xfe9ac000,0x3fdece62 + .long 0x793f3b67,0xbd63755a + .long 0x4a154000,0x3fdf1f16 + .long 0x1e0f6657,0xbd3d990d + .long 0xa9064000,0x3fdf5fd8 + .long 0x0109b0f1,0xbd1cb6f7 + .long 0x937e8000,0x3fdfa0c8 + .long 0xcacac36e,0xbd2515e1 + .long 0x49bb8000,0x3fdfe1e6 + .long 0x293a746b,0xbd5cca93 + .long 0x06416000,0x3fe01199 + .long 0xd8721fec,0xbd594c3a + .long 0x0e91e000,0x3fe03256 + .long 0x3e307cbb,0x3d467783 + .long 0x5ebce000,0x3fe0532a + .long 0xa9a9f37a,0xbd576c46 + .long 0x17f60000,0x3fe07416 + .long 0xbbaf9ab0,0xbd3ebdb1 + .long 0x53f38000,0x3fe08cd6 + .long 0x7d0732d6,0x3d5072ba + .long 0x55c12000,0x3fe0adeb + .long 0x502d528c,0xbd5f89ea + .long 0x1d5d2000,0x3fe0cf18 + .long 0x656576a5,0xbd317e70 + .long 0xcd0ac000,0x3fe0f05c + .long 0xc4d028f0,0x3d5dae75 + .long 0x87578000,0x3fe111b9 + .long 0xfb8eb2af,0x3d51553a + .long 0x6f1bc000,0x3fe1332e + .long 0x1e351573,0x3d5ee62e + .long 0xa77c2000,0x3fe154bb + .long 0x96dcbe61,0x3d1109e5 + .long 0x9bfa2000,0x3fe16df5 + .long 0x0adf6a55,0xbd693ea9 + .long 0xb6e2c000,0x3fe18fad + .long 0x517ae88c,0x3d63c19b + .long 0x849ae000,0x3fe1b17e + .long 0xff1e8ea2,0xbd3ecf4d + .long 0x6a0de000,0x3fe1caeb + .long 0x854dfeca,0x3d5027e9 + .long 0xc8310000,0x3fe1ece7 + .long 0x7a9fc25e,0xbd6136da + .long 0x3dae0000,0x3fe20efd + .long 0xa02e61be,0x3d2df373 + .long 0xe375e000,0x3fe2289d + .long 0xc27a8169,0xbd4bfa6f + .long 0x9b6a8000,0x3fe24adf + .long 0x14538362,0xbd601f94 + .long 0xd1aea000,0x3fe26d3a + .long 0xb5d13c0f,0x3d6cfc3a + .long 0x0c276000,0x3fe28710 + .long 0xcec1b4ea,0x3d61f3e3 + .long 0x3b3c0000,0x3fe2a998 + .long 0xcb3fff52,0x3d6b2840 + .long 0x5c842000,0x3fe2c38f + .long 0xdfa568f7,0x3d10bad7 + .long 0xfac06000,0x3fe2e644 + .long 0xbe206bcc,0xbd60284e + .long 0x5c482000,0x3fe3005e + .long 0x50757c6c,0x3d4411d0 + .long 0xe1d88000,0x3fe32341 + .long 0x4bed16a8,0x3d5370c2 + .long 0xde748000,0x3fe33d7d + .long 0x4a603b86,0xbd57fbb4 + .long 0xc5650000,0x3fe3608f + .long 0x14f8ca8f,0x3d3a63aa + .long 0xb9548000,0x3fe37aee + .long 0xc4484d2e,0xbd52b278 + .long 0x7d9a8000,0x3fe39e2f + .long 0xf9f603ee,0xbd627a85 + .long 0xc68fa000,0x3fe3b8b1 + .long 0x9336b66e,0x3d4bb4b6 + .long 0xe613e000,0x3fe3dc21 + .long 0xe04a7773,0xbd60c6e3 + .long 0xe33ba000,0x3fe3f6c7 + .long 0xfc271317,0x3d325d25 + .long 0x4b1fe000,0x3fe4117d + .long 0xf19c5879,0xbd47fe42 + .long 0xefeec000,0x3fe43531 + .long 0x74b82e7e,0xbd52f11d + .long 0x969d0000,0x3fe4500b + .long 0xbb075298,0x3d65b869 + .long 0xe41a2000,0x3fe46af4 + .long 0x4d994a2a,0xbd182943 + .long 0x19316000,0x3fe48eef + .long 0x3956fa5e,0x3d6990d4 + .long 0x333d4000,0x3fe4a9fd + .long 0xe1bd6277,0x3d67e24a + .long 0x318c0000,0x3fe4c51b + .long 0x2a8a4d7a,0xbd5f91de + .long 0x26d38000,0x3fe4e049 + .long 0xdd409e96,0xbd320665 + .long 0x63f64000,0x3fe5049f + .long 0x7b11231a,0x3d5b76a8 + .long 0xe3022000,0x3fe51ff2 + .long 0xa00b120a,0xbd56879f + .long 0x98572000,0x3fe53b56 + .long 0xfa5c51d1,0x3d673642 + .long 0x973dc000,0x3fe556ca + .long 0x459db47f,0xbd53cd8a + .long 0xf3200000,0x3fe5724e + .long 0x9385d649,0x3d591597 + .long 0x03a5c000,0x3fe59719 + .long 0x449e2590,0xbd31bb71 + .long 0xda198000,0x3fe5b2c3 + .long 0x492bf6ff,0xbd5b8afe + .long 0x4f3e4000,0x3fe5ce7f + .long 0x4f9a9e0c,0x3d76ae3f + .long 0x77184000,0x3fe5ea4b + .long 0x06727b86,0x3d65cd66 + .long 0x65cf0000,0x3fe60628 + .long 0x2f6664db,0x3d5e3c54 + .long 0x2faf4000,0x3fe62216 + .long 0x60c37437,0xbd773ea5 + .long 0xe929c000,0x3fe63e14 + .long 0xcd9d28e6,0x3d346549 + .long 0xa6d5c000,0x3fe65a24 + .long 0xc074b84d,0x3d5de792 + .long 0x7d6f8000,0x3fe67645 + .long 0x3180227e,0x3d45bfa4 + .long 0x81d94000,0x3fe69277 + .long 0x137a3d8c,0xbd5aaf6f + .long 0xc91b8000,0x3fe6aeba + .long 0x459f4910,0xbd2c3a4f + .long 0x6865c000,0x3fe6cb0f + .long 0xdb502403,0x3d51d406 + .long 0x750e8000,0x3fe6e775 + .long 0x54ae8096,0x3d57aac5 + .long 0x0493c000,0x3fe703ed + .long 0xd0d1a7f0,0xbd4c2657 + .long 0x2c9b0000,0x3fe72076 + .long 0xf1ec6bfa,0x3d6cb070 + .long 0x02f2c000,0x3fe73d11 + .long 0x28f88499,0x3d130454 + .long 0x9d914000,0x3fe759bd + .long 0x84b0b58b,0x3d5ed855 + .long 0x12968000,0x3fe7767c + .long 0x12e0b4f3,0xbd46eb96 + .long 0x784b4000,0x3fe7934c + .long 0x9cb23d17,0x3d6f0113 + .long 0xe522c000,0x3fe7b02e + .long 0xa5258bb7,0x3d77f7ed + .long 0x92280000,0x3fe7c37a + .long 0x818d34cf,0xbd6804b7 + .long 0x3d39c000,0x3fe7e07b + .long 0xf457de07,0x3d650290 + .long 0x2c1b4000,0x3fe7fd8e + .long 0xb343a140,0x3d2a15a5 + .long 0x75dc0000,0x3fe81ab3 + .long 0x2ec63274,0x3d584b7a + .long 0x31b7c000,0x3fe837eb + .long 0x22b56634,0x3d6c362e + .long 0x7716c000,0x3fe85535 + .long 0xa24036e1,0xbd7707b5 + .long 0xa808c000,0x3fe868c6 + .long 0xdc0e40d3,0xbd5bd2ae + .long 0x0713c000,0x3fe88630 + .long 0x6f909cf3,0xbd6203b8 + .long 0x2ee78000,0x3fe8a3ac + .long 0xbd315db9,0xbd5c935d + .long 0x3791c000,0x3fe8c13b + .long 0x11e2bd73,0x3d5dffed + .long 0x70e24000,0x3fe8d4fa + .long 0x8994b162,0xbd3b912d + .long 0x2639c000,0x3fe8f2a9 + .long 0x1cc06b22,0xbd677406 + .long 0xfd704000,0x3fe9106a + .long 0x6f31880a,0xbd1b76a4 + .long 0x3a284000,0x3fe9244c + .long 0x7db199c6,0xbd72bd2d + .long 0x2b878000,0x3fe9422e + .long 0x1eceebf4,0x3d607320 + .long 0x81210000,0x3fe96023 + .long 0x2956f019,0x3d6518a1 + .long 0x3737c000,0x3fe97427 + .long 0x71deb637,0x3d61e54d + .long 0x16b18000,0x3fe9923d + .long 0xebd2e82c,0x3d5028ed + .long 0x9e1bc000,0x3fe9b066 + .long 0xc89c6f2d,0xbd210f7a + .long 0x45f2c000,0x3fe9c48d + .long 0xe6a10cca,0xbd55b5da + .long 0xc93fc000,0x3fe9e2d7 + .long 0x6045b96c,0xbd74e31c + .long 0x39988000,0x3fea0136 + .long 0xd9459b34,0x3d3d25cf + .long 0x4e0bc000,0x3fea1580 + .long 0xd0364be2,0x3d744421 + .long 0x2ea54000,0x3fea3400 + .long 0x3388b97b,0x3d5c79a4 + .long 0xa67f8000,0x3fea4860 + .long 0xa2e241fc,0xbd5eddce + .long 0x414dc000,0x3fea6702 + .long 0xcc538261,0xbd43167c + .long 0x4e2e0000,0x3fea7b79 + .long 0xf16ff990,0xbd43cf0f + .long 0xee1c0000,0x3fea9a3c + .long 0xe3084679,0x3cf6c31d + .long 0x1be18000,0x3feab915 + .long 0x2c022617,0xbd672292 + .long 0xb33ac000,0x3feacdb0 + .long 0xb1410c94,0xbd4b23e5 + .long 0x60094000,0x3feaecab + .long 0x0ae3394c,0x3d50556b + .long 0x107c4000,0x3feb015e + .long 0xed2b2eb2,0xbd5d0db1 + .long 0x0cb28000,0x3feb161a + .long 0xd90df0b9,0x3d5353b3 + .long 0x8761c000,0x3feb3545 + .long 0x2b834fe3,0x3d647978 + .long 0xe5b20000,0x3feb4a18 + .long 0x2a855a1a,0x3d402327 + .long 0x9b240000,0x3feb6967 + .long 0x3726f484,0xbd7b3b86 + .long 0x90874000,0x3feb7e52 + .long 0x09b9625e,0x3d2d2152 + .long 0xd0b8c000,0x3feb9dc4 + .long 0x29c44115,0xbd46be4a + .long 0x92ddc000,0x3febb2c7 + .long 0xd690403e,0xbd28b7fc + .long 0xaeddc000,0x3febd25d + .long 0xb0f92e32,0x3d46a10e + .long 0x742ac000,0x3febe778 + .long 0x7ecf463f,0xbd6ad6fb + .long 0xe3b98000,0x3febfc9c + .long 0x1185e784,0xbd42cbe5 + .long 0xbdb50000,0x3fec1c65 + .long 0x6951096d,0x3d3e742a + .long 0x7dd04000,0x3fec31a2 + .long 0xcbdb5d9e,0xbd7a5b21 + .long 0x076cc000,0x3fec46e9 + .long 0x86f88587,0xbd3ddb78 + .long 0x43730000,0x3fec66e5 + .long 0xbaa5a734,0x3d523bf0 + .long 0x6c790000,0x3fec7c44 + .long 0xf67dd7ae,0xbd7c7a0d + .long 0x7ed84000,0x3fec91ad + .long 0x6188e18f,0x3d722f0b + .long 0xc4194000,0x3fecb1dd + .long 0x4bba7e1c,0x3d77b6c1 + .long 0xc6410000,0x3fecc75f + .long 0xb0c280a9,0x3d64f1b9 + .long 0xd2374000,0x3fecdceb + .long 0x391924a7,0xbd49ad57 + .long 0xcb184000,0x3fecfd50 + .long 0x6ab58d83,0xbd6078ca + .long 0x18c18000,0x3fed12f6 + .long 0xeb119dc6,0xbd6fe599 + .long 0x914e4000,0x3fed28a5 + .long 0x26c0de13,0xbd6fb0e6 + .long 0x3e504000,0x3fed3e5f + .long 0x9ace87f7,0xbd506b11 + .long 0xf93fc000,0x3fed5f08 + .long 0x4f2d37b7,0xbd73bb6d + .long 0x539dc000,0x3fed74dc + .long 0xb806844c,0x3d727a5f + .long 0x045b0000,0x3fed8aba + .long 0xf65ddbc9,0x3d2c7a4f + .long 0x15464000,0x3feda0a2 + .long 0x0af75927,0x3d74c8da + .long 0xb896c000,0x3fedc191 + .long 0x5363737e,0xbd6cdb50 + .long 0xe53dc000,0x3fedd793 + .long 0xa1dc7b13,0xbd76ffa3 + .long 0x94d7c000,0x3fededa0 + .long 0x1919aabd,0x3d6747e2 + .long 0xd174c000,0x3fee03b7 + .long 0x2f683f98,0xbd514fc4 + .long 0xa531c000,0x3fee19d9 + .long 0x3a87769f,0x3d7728dc + .long 0x1a3c0000,0x3fee3006 + .long 0x768a06ef,0xbd7a0e7d + .long 0xce9f8000,0x3fee515c + .long 0x518e12cc,0xbd65f71b + .long 0x03cb4000,0x3fee67a4 + .long 0xfaf8e258,0x3d75735c + .long 0xfe538000,0x3fee7df5 + .long 0xf6a2b592,0x3d55669d + .long 0xc8a70000,0x3fee9452 + .long 0xec9f90f7,0x3d60278c + .long 0x6d444000,0x3feeaaba + .long 0x2268e3e2,0x3d799543 + .long 0xf6b98000,0x3feec12c + .long 0x09d2dc10,0xbd468988 + .long 0x6fa38000,0x3feed7aa + .long 0x51433cdb,0xbd7387ac + .long 0xe2aec000,0x3feeee32 + .long 0x4fd75f61,0x3d597da2 + .long 0x3bbf4000,0x3fef1014 + .long 0x68ea48c7,0x3d71983c + .long 0x4f39c000,0x3fef26b8 + .long 0x4efa434d,0xbd72177b + .long 0x82ae0000,0x3fef3d67 + .long 0xf9197819,0x3d6fbc2b + .long 0xe1110000,0x3fef5421 + .long 0xa92b420d,0x3d69402d + .long 0x75670000,0x3fef6ae7 + .long 0x00c52b20,0xbd67cf2e + .long 0x4ac44000,0x3fef81b8 + .long 0x10fed627,0x3d2f2407 + .long 0x6c4e4000,0x3fef9894 + .long 0xd2088b22,0x3d61d346 + .long 0xe53ac000,0x3fefaf7b + .long 0xf5920222,0x3d69b7dc + .long 0xc0d04000,0x3fefc66e + .long 0xdbf33c61,0x3d6314d8 + .long 0x0a660000,0x3fefdd6d + .long 0x088b0624,0x3d603dc6 + .long 0xcd644000,0x3feff476 + .long 0xf02b035e,0x3d6e05d5 + .type __libm_log2l_table_256,@object + .size __libm_log2l_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log_table.S b/external/sgx_libm/ia32/log_table.S new file mode 100644 index 0000000000..8f16b4ac78 --- /dev/null +++ b/external/sgx_libm/ia32/log_table.S @@ -0,0 +1,560 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_log_table_256 + .globl __libm_log_table_256 +__libm_log_table_256: + .long 0x2779c19c,0x3e057562 + .long 0x00000000,0x3f600401 + .long 0x540e0a5d,0x3df4586b + .long 0x00000000,0x3f781212 + .long 0x5df1d574,0x3e3f2d06 + .long 0x00000000,0x3f841929 + .long 0xe0cc0310,0x3e3098eb + .long 0x00000000,0x3f8c3173 + .long 0x861d36aa,0x3e1ac733 + .long 0x00000000,0x3f91a6b9 + .long 0x0e5dc270,0x3e3766b0 + .long 0x00000000,0x3f95ba9a + .long 0xcf80538b,0x3dfd0c97 + .long 0x00000000,0x3f99d2a8 + .long 0x01095e5d,0x3e22cbcc + .long 0x00000000,0x3f9d6b27 + .long 0x5531753a,0x3e5433bf + .long 0x00000000,0x3fa0c58f + .long 0x86a4cae2,0x3e4e32f3 + .long 0x00000000,0x3fa2954c + .long 0x2b382296,0x3e36d4b6 + .long 0x00000000,0x3fa4a94d + .long 0x6b08209f,0x3e5e5a97 + .long 0x00000000,0x3fa67c94 + .long 0x0d02a20b,0x3e56c61e + .long 0x00000000,0x3fa85188 + .long 0xe988d46e,0x3e57ce75 + .long 0x00000000,0x3faa6b8a + .long 0x78fa4c28,0x3e0bdcaa + .long 0x00000000,0x3fac441e + .long 0x069e5bd9,0x3e23606d + .long 0x00000000,0x3fae1e67 + .long 0x008c9838,0x3e21ab93 + .long 0x00000000,0x3faffa69 + .long 0xc0123f2a,0x3e638bb4 + .long 0x00000000,0x3fb0ec13 + .long 0x42c9365e,0x3e590f46 + .long 0x00000000,0x3fb1dbd2 + .long 0xe38bd0cb,0x3e609fcb + .long 0x00000000,0x3fb2cc72 + .long 0xcc85ea5e,0x3e64fa3d + .long 0x00000000,0x3fb3bdf5 + .long 0xb814e378,0x3e5ea804 + .long 0x00000000,0x3fb4b05d + .long 0xc07f6cbe,0x3e5f3ad5 + .long 0x00000000,0x3fb580db + .long 0x4f332994,0x3e6126cb + .long 0x00000000,0x3fb674f0 + .long 0x46bb18e7,0x3e4635ab + .long 0x00000000,0x3fb769ef + .long 0x23f3f334,0x3e43a835 + .long 0x00000000,0x3fb85fd9 + .long 0x622b8758,0x3e575652 + .long 0x00000000,0x3fb9335e + .long 0xfa6531cd,0x3e406472 + .long 0x00000000,0x3fba2b02 + .long 0xd57cb81c,0x3e658350 + .long 0x00000000,0x3fbb0004 + .long 0x843191b0,0x3e5da7f2 + .long 0x00000000,0x3fbbf968 + .long 0x750465fd,0x3e67fdc2 + .long 0x00000000,0x3fbccfed + .long 0xa89401fa,0x3e58e111 + .long 0x00000000,0x3fbda727 + .long 0xde61a8fd,0x3e5ff843 + .long 0x00000000,0x3fbea325 + .long 0xbcbe8b53,0x3e6fdb7f + .long 0x00000000,0x3fbf7be9 + .long 0x7ce635d5,0x3e64bfc9 + .long 0x00000000,0x3fc02ab3 + .long 0x133742da,0x3e65e748 + .long 0x00000000,0x3fc097ce + .long 0x8f7bc671,0x3e7044fc + .long 0x00000000,0x3fc1178e + .long 0xcce888b8,0x3e6f6fb3 + .long 0x00000000,0x3fc18574 + .long 0xa08b164f,0x3e52f92e + .long 0x00000000,0x3fc1f3b9 + .long 0x56b4e87b,0x3e4e6ddf + .long 0x00000000,0x3fc2625d + .long 0x73ad9970,0x3e390d02 + .long 0x00000000,0x3fc2d161 + .long 0x85c23082,0x3e72e822 + .long 0x00000000,0x3fc340c5 + .long 0xaa42e1ae,0x3e69d5fc + .long 0x00000000,0x3fc3b08b + .long 0x06ed14f1,0x3e306f00 + .long 0x00000000,0x3fc40dfb + .long 0xef836a49,0x3e7d194b + .long 0x00000000,0x3fc47e74 + .long 0xbc83d21d,0x3e7ec8cd + .long 0x00000000,0x3fc4ef51 + .long 0xa2c28034,0x3e7c0574 + .long 0x00000000,0x3fc56092 + .long 0x3530a5ba,0x3e65f35d + .long 0x00000000,0x3fc5d238 + .long 0xbb20ab0e,0x3e5b99ae + .long 0x00000000,0x3fc6313a + .long 0x706cb199,0x3e7b577a + .long 0x00000000,0x3fc6a399 + .long 0x8350bc53,0x3e7ba79c + .long 0x00000000,0x3fc70337 + .long 0x274badf2,0x3e428f61 + .long 0x00000000,0x3fc77654 + .long 0x16849fa4,0x3e550581 + .long 0x00000000,0x3fc7e9d8 + .long 0x4baffaa4,0x3e6d67d4 + .long 0x00000000,0x3fc84a6b + .long 0x61fae141,0x3e7abeb4 + .long 0x00000000,0x3fc8ab47 + .long 0x0369cf31,0x3e7212cb + .long 0x00000000,0x3fc91fe4 + .long 0x9d5bb3d2,0x3e60046a + .long 0x00000000,0x3fc98163 + .long 0x904d6866,0x3e2c2259 + .long 0x00000000,0x3fc9f6c4 + .long 0xa19f5411,0x3e549a47 + .long 0x00000000,0x3fca58e7 + .long 0x759a5351,0x3e7862d2 + .long 0x00000000,0x3fcabb55 + .long 0xf400c4b3,0x3e62467b + .long 0x00000000,0x3fcb1e10 + .long 0xf9503717,0x3e727c6c + .long 0x00000000,0x3fcb94ee + .long 0xabdf1b3f,0x3e780cea + .long 0x00000000,0x3fcbf851 + .long 0xe97aab9f,0x3e652fc8 + .long 0x00000000,0x3fcc5c02 + .long 0x8a4a9e8b,0x3e793b67 + .long 0x00000000,0x3fccc000 + .long 0xce7d8064,0x3e73390a + .long 0x00000000,0x3fcd244d + .long 0x2835ff73,0x3e5fd97a + .long 0x00000000,0x3fcd88e9 + .long 0x804954d6,0x3e5bf577 + .long 0x00000000,0x3fcdedd4 + .long 0x024244ec,0x3e7ffce2 + .long 0x00000000,0x3fce530e + .long 0x7137ba40,0x3e4648b9 + .long 0x00000000,0x3fceb89a + .long 0x7bcea6d1,0x3e7f5bf3 + .long 0x00000000,0x3fcf1e75 + .long 0x1abc74cf,0x3e5756be + .long 0x00000000,0x3fcf84a3 + .long 0xe6831bc0,0x3e59f503 + .long 0x00000000,0x3fcfeb22 + .long 0x83851858,0x3e88e06b + .long 0x00000000,0x3fd028f9 + .long 0x6b43c71e,0x3e8c1b2c + .long 0x00000000,0x3fd05c8b + .long 0xf2ea89fa,0x3e81f15c + .long 0x00000000,0x3fd085eb + .long 0x2224e892,0x3e8c65a3 + .long 0x00000000,0x3fd0b9c8 + .long 0x20336a5b,0x3e782de0 + .long 0x00000000,0x3fd0edd0 + .long 0x8fdd9770,0x3e733c01 + .long 0x00000000,0x3fd12202 + .long 0x9a817c85,0x3e824f5d + .long 0x00000000,0x3fd14be2 + .long 0x5be801bd,0x3e81de31 + .long 0x00000000,0x3fd18061 + .long 0xc766b993,0x3e87c5f8 + .long 0x00000000,0x3fd1b50b + .long 0x85a1f823,0x3e88f9e4 + .long 0x00000000,0x3fd1df4c + .long 0x350fbd75,0x3e7b43ae + .long 0x00000000,0x3fd21445 + .long 0x4920ddbb,0x3e8323d7 + .long 0x00000000,0x3fd23ec5 + .long 0x5f6600ba,0x3e83f0e1 + .long 0x00000000,0x3fd2740d + .long 0x4073b3be,0x3e8579bf + .long 0x00000000,0x3fd29ecd + .long 0x72f2232b,0x3e256e67 + .long 0x00000000,0x3fd2d466 + .long 0x3a896d5f,0x3e8609d5 + .long 0x00000000,0x3fd2ff66 + .long 0x8ddf913a,0x3e72cd56 + .long 0x00000000,0x3fd33550 + .long 0xd7253e69,0x3e77b113 + .long 0x00000000,0x3fd36092 + .long 0xce9e941f,0x3e88666f + .long 0x00000000,0x3fd38bf1 + .long 0x60ed52d8,0x3e7dcccc + .long 0x00000000,0x3fd3c252 + .long 0x0f983d68,0x3e78f05a + .long 0x00000000,0x3fd3edf4 + .long 0x6390dbb2,0x3e61eaf4 + .long 0x00000000,0x3fd419b4 + .long 0xe916a76d,0x3e8c0a73 + .long 0x00000000,0x3fd44591 + .long 0x2b59a2e0,0x3e7d6dbc + .long 0x00000000,0x3fd47c91 + .long 0xc24fc7a2,0x3e70554a + .long 0x00000000,0x3fd4a8b3 + .long 0x33faf275,0x3e821120 + .long 0x00000000,0x3fd4d4f3 + .long 0x2cfac6d3,0x3e81b43f + .long 0x00000000,0x3fd50152 + .long 0x3d98a28d,0x3e78d1f5 + .long 0x00000000,0x3fd52dd0 + .long 0x44e3b5b4,0x3e6e3dc5 + .long 0x00000000,0x3fd55a6d + .long 0x2c814b0b,0x3e658895 + .long 0x00000000,0x3fd5925d + .long 0x6c7ee0a5,0x3e7ad50f + .long 0x00000000,0x3fd5bf40 + .long 0xd6e34245,0x3e6eae1a + .long 0x00000000,0x3fd5ec43 + .long 0x83dd4a7f,0x3e89b605 + .long 0x00000000,0x3fd61965 + .long 0xa87b925b,0x3e724d6c + .long 0x00000000,0x3fd646a8 + .long 0xd28ed1d3,0x3e8ba63b + .long 0x00000000,0x3fd6740a + .long 0x18a4a613,0x3e86e94b + .long 0x00000000,0x3fd6a18d + .long 0xb0b244a7,0x3e3619c3 + .long 0x00000000,0x3fd6cf31 + .long 0x173b6f5e,0x3e8d0a5e + .long 0x00000000,0x3fd6f180 + .long 0x3be91c4c,0x3e7c6e25 + .long 0x00000000,0x3fd71f5d + .long 0xab8359ed,0x3e8dfacd + .long 0x00000000,0x3fd74d5a + .long 0x6fb93ec4,0x3e82457a + .long 0x00000000,0x3fd77b79 + .long 0x3c4bbc8b,0x3e8113e3 + .long 0x00000000,0x3fd7a9b9 + .long 0x31fa7741,0x3e2bf5b5 + .long 0x00000000,0x3fd7d81b + .long 0x186f4789,0x3e69c139 + .long 0x00000000,0x3fd8069e + .long 0x7956aae8,0x3e8a7df1 + .long 0x00000000,0x3fd82996 + .long 0xfeab799a,0x3e7ddb72 + .long 0x00000000,0x3fd85855 + .long 0x33b8ef04,0x3e760c9f + .long 0x00000000,0x3fd88736 + .long 0x19dccb10,0x3e82e757 + .long 0x00000000,0x3fd8aa75 + .long 0x9c910289,0x3e8b9104 + .long 0x00000000,0x3fd8d992 + .long 0xa230be1d,0x3e8d4fb2 + .long 0x00000000,0x3fd908d2 + .long 0xcac1703a,0x3e8cf381 + .long 0x00000000,0x3fd92c59 + .long 0xb4a553e7,0x3e743b8f + .long 0x00000000,0x3fd95bd7 + .long 0x5b5274b7,0x3e51a3ee + .long 0x00000000,0x3fd98b78 + .long 0x0d70a52d,0x3e8e67a8 + .long 0x00000000,0x3fd9af47 + .long 0x4f0d2c7f,0x3e483229 + .long 0x00000000,0x3fd9df27 + .long 0xb48f7d3d,0x3e8da29f + .long 0x00000000,0x3fda0325 + .long 0xc6457f9d,0x3e2127d3 + .long 0x00000000,0x3fda3344 + .long 0xe0b95e88,0x3e77a030 + .long 0x00000000,0x3fda5772 + .long 0x991f7846,0x3e565dd1 + .long 0x00000000,0x3fda87d0 + .long 0x256f237b,0x3e7b00fe + .long 0x00000000,0x3fdaac2e + .long 0xa0437713,0x3e7bf7da + .long 0x00000000,0x3fdadccc + .long 0xc8192dd8,0x3e6f58f3 + .long 0x00000000,0x3fdb015b + .long 0xa41f8565,0x3e6d31ac + .long 0x00000000,0x3fdb323a + .long 0x25494b61,0x3e3118a4 + .long 0x00000000,0x3fdb56fa + .long 0x92694e9d,0x3e84cb37 + .long 0x00000000,0x3fdb881a + .long 0x2c99792a,0x3e8de7b6 + .long 0x00000000,0x3fdbad0b + .long 0x85ec7449,0x3e82ef03 + .long 0x00000000,0x3fdbd212 + .long 0x0c4250d7,0x3e6b7844 + .long 0x00000000,0x3fdc0392 + .long 0xfce511d5,0x3e5e4d32 + .long 0x00000000,0x3fdc28cb + .long 0x78348ca5,0x3e8708e4 + .long 0x00000000,0x3fdc4e19 + .long 0x992488fb,0x3e88e8aa + .long 0x00000000,0x3fdc7ff9 + .long 0xc144344b,0x3e793a76 + .long 0x00000000,0x3fdca57b + .long 0x5f7d6efe,0x3e44b9d7 + .long 0x00000000,0x3fdccb13 + .long 0x4de9f3e0,0x3e8a31e6 + .long 0x00000000,0x3fdcf0c0 + .long 0x80488966,0x3e7d6d68 + .long 0x00000000,0x3fdd2320 + .long 0x9add7f4d,0x3e71b7be + .long 0x00000000,0x3fdd4902 + .long 0xb9ac5131,0x3e8231a4 + .long 0x00000000,0x3fdd6efa + .long 0x4bdc3bac,0x3e7c1eb9 + .long 0x00000000,0x3fdd9509 + .long 0xaa85604a,0x3e8fd258 + .long 0x00000000,0x3fddbb2e + .long 0x57753a10,0x3e6a22f2 + .long 0x00000000,0x3fddee2f + .long 0xcd94df8d,0x3e5a2726 + .long 0x00000000,0x3fde148a + .long 0x7ff6aa8c,0x3e4493fe + .long 0x00000000,0x3fde3afc + .long 0xb6cae4c0,0x3e6036a8 + .long 0x00000000,0x3fde6185 + .long 0x546c92af,0x3e7e208f + .long 0x00000000,0x3fde8825 + .long 0x8619d6bd,0x3e67564c + .long 0x00000000,0x3fdeaedd + .long 0xf8b97910,0x3e77d0da + .long 0x00000000,0x3fded5ac + .long 0x5c542068,0x3e6368b5 + .long 0x00000000,0x3fdefc93 + .long 0xbff8880b,0x3e8442ae + .long 0x00000000,0x3fdf2391 + .long 0x259bcade,0x3e8dc063 + .long 0x00000000,0x3fdf4aa7 + .long 0xd802b8c4,0x3e63e185 + .long 0x00000000,0x3fdf71d6 + .long 0xde5f6650,0x3e7b2cec + .long 0x00000000,0x3fdf991c + .long 0x21ff49a1,0x3e8b4d35 + .long 0x00000000,0x3fdfc07a + .long 0xa7c2b8c5,0x3e81d607 + .long 0x00000000,0x3fdfe7f1 + .long 0x0b9d6ee5,0x3e84f140 + .long 0x00000000,0x3fe007c0 + .long 0xd0756a93,0x3e70cc52 + .long 0x00000000,0x3fe01b94 + .long 0x3aad0772,0x3e800319 + .long 0x00000000,0x3fe02f74 + .long 0x759dd00c,0x3e97cec0 + .long 0x00000000,0x3fe04360 + .long 0xc67418f8,0x3e9588ff + .long 0x00000000,0x3fe05759 + .long 0x51e8da67,0x3e6911cf + .long 0x00000000,0x3fe06b5f + .long 0xa048907b,0x3e44cf15 + .long 0x00000000,0x3fe078bf + .long 0xc39803ff,0x3e8a1f9e + .long 0x00000000,0x3fe08cd9 + .long 0x06525ba1,0x3e8d33e4 + .long 0x00000000,0x3fe0a100 + .long 0x3b46098d,0x3e7d11a2 + .long 0x00000000,0x3fe0b534 + .long 0x39b814fa,0x3e991286 + .long 0x00000000,0x3fe0c974 + .long 0x432f7532,0x3e782dcc + .long 0x00000000,0x3fe0ddc2 + .long 0x4618affd,0x3e82ebf2 + .long 0x00000000,0x3fe0eb52 + .long 0x1d77bbef,0x3e8084e9 + .long 0x00000000,0x3fe0ffb5 + .long 0xcfaf1c2c,0x3e7ed4be + .long 0x00000000,0x3fe11425 + .long 0xbfce7a70,0x3e83c766 + .long 0x00000000,0x3fe128a2 + .long 0x1930b4c4,0x3e84afc2 + .long 0x00000000,0x3fe13652 + .long 0x4b441313,0x3e862d2a + .long 0x00000000,0x3fe14ae5 + .long 0xcb6b7c9c,0x3e94338e + .long 0x00000000,0x3fe15f85 + .long 0xfd3aea12,0x3e7c608c + .long 0x00000000,0x3fe16d4d + .long 0x266a0b45,0x3e9841ba + .long 0x00000000,0x3fe18203 + .long 0xe75899eb,0x3e978963 + .long 0x00000000,0x3fe196c7 + .long 0x9e2b1260,0x3e7c5bd1 + .long 0x00000000,0x3fe1a4a7 + .long 0xa79bc2a5,0x3e98192c + .long 0x00000000,0x3fe1b981 + .long 0x0d5eb986,0x3e9d1762 + .long 0x00000000,0x3fe1ce69 + .long 0x28836a17,0x3e93bc0d + .long 0x00000000,0x3fe1dc61 + .long 0xb47416ca,0x3e9455a1 + .long 0x00000000,0x3fe1f160 + .long 0xdf997414,0x3e8dd01c + .long 0x00000000,0x3fe2066d + .long 0x72755e61,0x3e9748f4 + .long 0x00000000,0x3fe2147d + .long 0x586cc870,0x3e978bd7 + .long 0x00000000,0x3fe229a1 + .long 0x05ced5b8,0x3e90834a + .long 0x00000000,0x3fe237c1 + .long 0xb34d2934,0x3e9cdf01 + .long 0x00000000,0x3fe24cfc + .long 0xd891ba01,0x3e857355 + .long 0x00000000,0x3fe25b2c + .long 0x103a61e4,0x3e8357df + .long 0x00000000,0x3fe2707f + .long 0x7071361a,0x3e908594 + .long 0x00000000,0x3fe285e0 + .long 0xdcc2f0a7,0x3e81c22d + .long 0x00000000,0x3fe29429 + .long 0xc30f37c8,0x3e89c2bf + .long 0x00000000,0x3fe2a9a2 + .long 0x604c3ff4,0x3e76468e + .long 0x00000000,0x3fe2b7fb + .long 0x7d42bf88,0x3e88e57d + .long 0x00000000,0x3fe2c65a + .long 0xd0b235f1,0x3e85ec37 + .long 0x00000000,0x3fe2dbf5 + .long 0xca965170,0x3e987f2e + .long 0x00000000,0x3fe2ea64 + .long 0xb996d64e,0x3e71b426 + .long 0x00000000,0x3fe30018 + .long 0xb998ef97,0x3e9d3516 + .long 0x00000000,0x3fe30e97 + .long 0x9d3de3b9,0x3e9d7ba6 + .long 0x00000000,0x3fe32463 + .long 0xcad27856,0x3e78a56b + .long 0x00000000,0x3fe332f4 + .long 0x9f9e227c,0x3e5ce8c9 + .long 0x00000000,0x3fe348d9 + .long 0xadb2d775,0x3e9f1887 + .long 0x00000000,0x3fe35779 + .long 0x53263e64,0x3e92c34d + .long 0x00000000,0x3fe36621 + .long 0xcd4571cb,0x3e93e786 + .long 0x00000000,0x3fe37c29 + .long 0xe748544b,0x3e671976 + .long 0x00000000,0x3fe38ae2 + .long 0xf9cce311,0x3e85e980 + .long 0x00000000,0x3fe399a1 + .long 0x3a222092,0x3e9fcef7 + .long 0x00000000,0x3fe3afcc + .long 0xed5008bd,0x3e840d4c + .long 0x00000000,0x3fe3be9d + .long 0x1452e9ec,0x3e901695 + .long 0x00000000,0x3fe3cd74 + .long 0xb62b2ce8,0x3e7c8c7b + .long 0x00000000,0x3fe3e3c4 + .long 0xd8d571ad,0x3e964fda + .long 0x00000000,0x3fe3f2ac + .long 0x498c3678,0x3e7092e5 + .long 0x00000000,0x3fe4019c + .long 0xc8960bd4,0x3e884e25 + .long 0x00000000,0x3fe41810 + .long 0x5157ce35,0x3e84637d + .long 0x00000000,0x3fe42711 + .long 0xafcc2a6b,0x3e8384ad + .long 0x00000000,0x3fe43619 + .long 0x9a4ffe6d,0x3e875a3a + .long 0x00000000,0x3fe44528 + .long 0x4e8516c0,0x3e819322 + .long 0x00000000,0x3fe45bcc + .long 0xfe3457c8,0x3e70f88b + .long 0x00000000,0x3fe46aed + .long 0x69a4a836,0x3e73f451 + .long 0x00000000,0x3fe47a15 + .long 0x32f98351,0x3e87bfff + .long 0x00000000,0x3fe48944 + .long 0x06a8d925,0x3e9796d3 + .long 0x00000000,0x3fe4a018 + .long 0xaef076e2,0x3e593acb + .long 0x00000000,0x3fe4af5a + .long 0xd0e13620,0x3e94b7b7 + .long 0x00000000,0x3fe4bea2 + .long 0x88cfb12e,0x3e91e215 + .long 0x00000000,0x3fe4cdf2 + .long 0x0b0cb912,0x3e99f328 + .long 0x00000000,0x3fe4dd49 + .long 0xa0e67b10,0x3e8b9929 + .long 0x00000000,0x3fe4eca8 + .long 0xb401f873,0x3e7e6c75 + .long 0x00000000,0x3fe503c4 + .long 0x15ce5326,0x3e8999ff + .long 0x00000000,0x3fe51335 + .long 0x5f3840b2,0x3e4ce28f + .long 0x00000000,0x3fe522ae + .long 0x2b9988ba,0x3e73433c + .long 0x00000000,0x3fe5322e + .long 0x0122cc5c,0x3e9972f3 + .long 0x00000000,0x3fe541b5 + .long 0xac4eb353,0x3e9fb797 + .long 0x00000000,0x3fe55144 + .long 0x78d26225,0x3e988a2a + .long 0x00000000,0x3fe560db + .long 0x333017fe,0x3e735dc6 + .long 0x00000000,0x3fe5707a + .long 0xff9e8c9a,0x3e5dab71 + .long 0x00000000,0x3fe587f6 + .long 0xe623c257,0x3e92ef91 + .long 0x00000000,0x3fe597a7 + .long 0x715f0d98,0x3e9ac697 + .long 0x00000000,0x3fe5a760 + .long 0x21dc5b09,0x3e9a52be + .long 0x00000000,0x3fe5b721 + .long 0xdf20565e,0x3e928863 + .long 0x00000000,0x3fe5c6ea + .long 0x7afa1d46,0x3e717543 + .long 0x00000000,0x3fe5d6bb + .long 0x71f3b726,0x3e90c8ba + .long 0x00000000,0x3fe5e693 + .long 0xda3470be,0x3e98c345 + .long 0x00000000,0x3fe5f673 + .long 0x24c45894,0x3e9d470b + .long 0x00000000,0x3fe6065b + .long 0x0d6b6214,0x3e9f4f98 + .long 0x00000000,0x3fe6164b + .long 0xe85e3147,0x3e9fd9f2 + .long 0x00000000,0x3fe62643 + .type __libm_log_table_256,@object + .size __libm_log_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/log_wmt.S b/external/sgx_libm/ia32/log_wmt.S new file mode 100644 index 0000000000..b43eb8a34a --- /dev/null +++ b/external/sgx_libm/ia32/log_wmt.S @@ -0,0 +1,800 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin log + .text + .align 16,0x90 + .globl log +log: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + xorpd %xmm3, %xmm3 + movl $30704, %edx + pinsrw $3, %edx, %xmm3 + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm1 + movl $32768, %ecx + movd %ecx, %xmm4 + movsd 2128(%ebx), %xmm5 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + psllq $5, %xmm0 + movl $16352, %ecx + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $228, %xmm5, %xmm6 + psrlq $12, %xmm1 + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + paddd %xmm4, %xmm0 + orpd %xmm3, %xmm1 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm1, %xmm5 + andpd %xmm6, %xmm0 + subsd %xmm5, %xmm1 + mulpd %xmm0, %xmm5 + andl $32752, %eax + subl %ecx, %eax + cvtsi2sdl %eax, %xmm7 + mulsd %xmm0, %xmm1 + movsd 2064(%ebx), %xmm6 + movapd 2080(%ebx), %xmm3 + subsd %xmm2, %xmm5 + andl $16711680, %edx + shrl $12, %edx + movapd (%ebx,%edx), %xmm0 + movapd 2096(%ebx), %xmm4 + addsd %xmm5, %xmm1 + movapd 2112(%ebx), %xmm2 + mulsd %xmm7, %xmm6 + pshufd $68, %xmm1, %xmm5 + mulsd 2072(%ebx), %xmm7 + mulsd %xmm1, %xmm3 + addsd %xmm6, %xmm0 + mulpd %xmm5, %xmm4 + mulpd %xmm5, %xmm5 + pshufd $228, %xmm0, %xmm6 + addsd %xmm1, %xmm0 + addpd %xmm2, %xmm4 + mulpd %xmm5, %xmm3 + subsd %xmm0, %xmm6 + mulsd %xmm1, %xmm4 + pshufd $238, %xmm0, %xmm2 + addsd %xmm6, %xmm1 + mulsd %xmm5, %xmm5 + addsd %xmm2, %xmm7 + addpd %xmm3, %xmm4 + addsd %xmm7, %xmm1 + mulpd %xmm5, %xmm4 + addsd %xmm4, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + movsd 112(%esp), %xmm0 + movapd %xmm0, %xmm1 + addl $16, %eax + cmpl $32768, %eax + jae .L_2TAG_PACKET_3.0.3 + cmpl $16, %eax + jb .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + ja .L_2TAG_PACKET_5.0.3 + cmpl $0, %edx + ja .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_3.0.3: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + addl %ecx, %ecx + cmpl $-2097152, %ecx + jae .L_2TAG_PACKET_6.0.3 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_7.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + movl $3, %edx + mulsd %xmm1, %xmm0 +.L_2TAG_PACKET_9.0.3: + movsd %xmm0, (%esp) + movsd 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_10.0.3 +.L_2TAG_PACKET_8.0.3: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + divsd %xmm1, %xmm0 + movl $2, %edx + jmp .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_4.0.3: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_8.0.3 + xorpd %xmm1, %xmm1 + movl $18416, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + movapd %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + psllq $5, %xmm0 + movl $18416, %ecx + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $228, %xmm5, %xmm6 + psrlq $12, %xmm1 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_10.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type log,@function + .size log,.-log + .data +# -- End log + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4277811200 + .long 1072049730 + .long 2479318832 + .long 1026487127 + .long 2854492160 + .long 1072033410 + .long 215631550 + .long 1025638968 + .long 1547061248 + .long 1072017216 + .long 2886781435 + .long 1026423395 + .long 649825280 + .long 1072001146 + .long 4281533405 + .long 1024038923 + .long 646346752 + .long 1071985198 + .long 1562735921 + .long 1023790276 + .long 2203734016 + .long 1071969370 + .long 1838397691 + .long 3173936209 + .long 1872169984 + .long 1071953661 + .long 3981202460 + .long 1022325013 + .long 669557760 + .long 1071938069 + .long 4182597802 + .long 3173174122 + .long 4076413952 + .long 1071922591 + .long 1209029111 + .long 3170736207 + .long 556125184 + .long 1071907228 + .long 821086028 + .long 3173437049 + .long 204914688 + .long 1071891976 + .long 2097025986 + .long 3171071798 + .long 387545088 + .long 1071876834 + .long 3142936996 + .long 3173092218 + .long 2912783360 + .long 1071861800 + .long 2502420140 + .long 1024505919 + .long 1144260608 + .long 1071846874 + .long 3315658140 + .long 3173469843 + .long 1471209472 + .long 1071832053 + .long 129621009 + .long 3172443877 + .long 1829683200 + .long 1071817336 + .long 3885467693 + .long 1025535275 + .long 288676864 + .long 1071802722 + .long 86139472 + .long 3171639793 + .long 3636378624 + .long 1071788208 + .long 1850238587 + .long 1024654342 + .long 1606817792 + .long 1071773795 + .long 3388899795 + .long 3173675586 + .long 1236164608 + .long 1071759480 + .long 3983599207 + .long 1020046558 + .long 1089616896 + .long 1071745262 + .long 4171974224 + .long 1024773198 + .long 4143093760 + .long 1071731139 + .long 2727587401 + .long 3173965207 + .long 600267776 + .long 1071717112 + .long 3147685042 + .long 3173353031 + .long 2249313280 + .long 1071703177 + .long 125835074 + .long 1025255832 + .long 3805303808 + .long 1071689334 + .long 2289991207 + .long 1025460331 + .long 87278592 + .long 1071675583 + .long 1106114045 + .long 1025933602 + .long 3195405312 + .long 1071661920 + .long 3885316576 + .long 3171206239 + .long 3853649920 + .long 1071648346 + .long 2977069852 + .long 3171236771 + .long 2944026624 + .long 1071625048 + .long 1008093493 + .long 1023444474 + .long 3993180160 + .long 1071598247 + .long 1862355595 + .long 1024642533 + .long 1454641152 + .long 1071571617 + .long 1514603089 + .long 1026500596 + .long 3286085632 + .long 1071545154 + .long 1400028424 + .long 3173279056 + .long 438773760 + .long 1071518858 + .long 120727864 + .long 3172148914 + .long 1212979200 + .long 1071492725 + .long 1625055594 + .long 3172901933 + .long 1189017600 + .long 1071466754 + .long 3920062376 + .long 1025727407 + .long 403064832 + .long 1071440943 + .long 1053271728 + .long 3171391427 + .long 3343210496 + .long 1071415289 + .long 3243395502 + .long 3173627613 + .long 1765777408 + .long 1071389792 + .long 2145968512 + .long 1026354304 + .long 461430784 + .long 1071364449 + .long 4094322285 + .long 1026021467 + .long 71706624 + .long 1071339258 + .long 763632021 + .long 1024496933 + .long 1380503552 + .long 1071314217 + .long 1383547992 + .long 3173088453 + .long 1015732224 + .long 1071289325 + .long 3198646877 + .long 1025390322 + .long 35977216 + .long 1071264580 + .long 2141026805 + .long 1025754693 + .long 3927306240 + .long 1071239979 + .long 282116272 + .long 3173394334 + .long 1125341184 + .long 1071215523 + .long 2768427504 + .long 3172279059 + .long 1666971648 + .long 1071191208 + .long 786837629 + .long 3172427445 + .long 2827694080 + .long 1071167033 + .long 3857122416 + .long 3173014241 + .long 2003683328 + .long 1071142997 + .long 859010954 + .long 1026545007 + .long 1004017664 + .long 1071119098 + .long 3356644970 + .long 3173458064 + .long 1753020416 + .long 1071095334 + .long 788338552 + .long 1026157693 + .long 1992718336 + .long 1071071704 + .long 1239179443 + .long 1026394889 + .long 3870234624 + .long 1071048206 + .long 2082614663 + .long 1024926053 + .long 1050437632 + .long 1071024840 + .long 660007840 + .long 1025548499 + .long 188395520 + .long 1071001603 + .long 3878792704 + .long 3173889571 + .long 3747176448 + .long 1070978493 + .long 144991708 + .long 3171552042 + .long 1405669376 + .long 1070955511 + .long 3999088879 + .long 1025486317 + .long 121151488 + .long 1070932654 + .long 2170865497 + .long 1026473584 + .long 2652319744 + .long 1070909920 + .long 453695652 + .long 3173916809 + .long 3262236672 + .long 1070887309 + .long 157800053 + .long 3173984206 + .long 601221120 + .long 1070864820 + .long 3968917661 + .long 1023992886 + .long 1999843328 + .long 1070842450 + .long 3053895004 + .long 1024998228 + .long 1992167424 + .long 1070820199 + .long 2968614856 + .long 1024552653 + .long 3788726272 + .long 1070798065 + .long 3542170808 + .long 3173573242 + .long 2094829568 + .long 1070776048 + .long 1246758132 + .long 1026202874 + .long 288675840 + .long 1070754146 + .long 3747328950 + .long 1026331585 + .long 1829681152 + .long 1070732357 + .long 3125197546 + .long 1024100318 + .long 1666869248 + .long 1070710681 + .long 1363656119 + .long 1026336493 + .long 3417110528 + .long 1070689116 + .long 4154791553 + .long 1026267853 + .long 2183653376 + .long 1070667662 + .long 1671819292 + .long 3173785870 + .long 1734434816 + .long 1070646317 + .long 373091049 + .long 1025972363 + .long 1615681536 + .long 1070625080 + .long 384650897 + .long 1022926043 + .long 1445382144 + .long 1070603950 + .long 344320330 + .long 3172397196 + .long 1823715328 + .long 1070569756 + .long 3389841200 + .long 1025231852 + .long 3839688704 + .long 1070527917 + .long 1706790417 + .long 3167363349 + .long 4293332992 + .long 1070486286 + .long 1614935088 + .long 1019351591 + .long 2966720512 + .long 1070444861 + .long 4145393717 + .long 3173711658 + .long 4066729984 + .long 1070403639 + .long 1974925028 + .long 3171437182 + .long 3337621504 + .long 1070362619 + .long 3314953170 + .long 3169971314 + .long 943448064 + .long 1070321799 + .long 1498682038 + .long 3173862340 + .long 1465634816 + .long 1070281176 + .long 1319952810 + .long 3171693965 + .long 1015734272 + .long 1070240749 + .long 1347821929 + .long 3173544515 + .long 118001664 + .long 1070200516 + .long 1751482746 + .long 1026134093 + .long 3707174912 + .long 1070160474 + .long 1486946159 + .long 1023930920 + .long 3946381312 + .long 1070120623 + .long 2867408081 + .long 3171368276 + .long 1699848192 + .long 1070080961 + .long 2590187139 + .long 1025379803 + .long 2235846656 + .long 1070041485 + .long 1888568069 + .long 3172754960 + .long 2339729408 + .long 1070002194 + .long 3852214753 + .long 3173323149 + .long 3196850176 + .long 1069963086 + .long 742141560 + .long 1025101707 + .long 1800683520 + .long 1069924160 + .long 3949500444 + .long 3172102179 + .long 3835801600 + .long 1069885413 + .long 3848895943 + .long 1025913832 + .long 2201202688 + .long 1069846845 + .long 1425913464 + .long 1025868665 + .long 2778279936 + .long 1069808453 + .long 2120889677 + .long 3173831128 + .long 2954203136 + .long 1069770236 + .long 592147081 + .long 1019621288 + .long 210141184 + .long 1069732193 + .long 3414275233 + .long 1023647084 + .long 709476352 + .long 1069694321 + .long 2413027164 + .long 1024462115 + .long 2116284416 + .long 1069656619 + .long 1144559924 + .long 1026336654 + .long 2183651328 + .long 1069619086 + .long 3459057650 + .long 1025634168 + .long 3047047168 + .long 1069581720 + .long 1879674924 + .long 3173508573 + .long 970711040 + .long 1069541521 + .long 1335954173 + .long 3173332182 + .long 2198478848 + .long 1069467449 + .long 2951103968 + .long 3173892200 + .long 1669611520 + .long 1069393703 + .long 531044147 + .long 1025149248 + .long 29114368 + .long 1069320280 + .long 3327831251 + .long 1025918673 + .long 2376949760 + .long 1069247176 + .long 737634533 + .long 3172176000 + .long 1085390848 + .long 1069174390 + .long 3108243400 + .long 3171828406 + .long 1566130176 + .long 1069101918 + .long 985483226 + .long 1025708380 + .long 792780800 + .long 1069029758 + .long 4184866295 + .long 1024426204 + .long 183156736 + .long 1068957907 + .long 2845699378 + .long 1022107277 + .long 1301782528 + .long 1068886362 + .long 1012735262 + .long 3173804294 + .long 1562411008 + .long 1068815121 + .long 2197086703 + .long 3170187813 + .long 2815549440 + .long 1068744181 + .long 2782613207 + .long 1026345054 + .long 2756124672 + .long 1068673540 + .long 2929486205 + .long 3173037800 + .long 3511050240 + .long 1068603195 + .long 1443733147 + .long 3173331549 + .long 3047047168 + .long 1068533144 + .long 1879674924 + .long 3172459997 + .long 3221667840 + .long 1068427825 + .long 1338588027 + .long 3171815742 + .long 3453861888 + .long 1068288883 + .long 1205348359 + .long 3172624626 + .long 3506110464 + .long 1068150514 + .long 893105198 + .long 1025571866 + .long 346013696 + .long 1068012714 + .long 3495569021 + .long 3172563349 + .long 4074029056 + .long 1067875476 + .long 3961106338 + .long 3171065595 + .long 3559784448 + .long 1067738798 + .long 1975385384 + .long 3173783155 + .long 797769728 + .long 1067602675 + .long 3760305787 + .long 1026047642 + .long 2313633792 + .long 1067467101 + .long 1559353171 + .long 1023480256 + .long 3960766464 + .long 1067213778 + .long 1067365107 + .long 1025865926 + .long 684261376 + .long 1066944805 + .long 844762164 + .long 3173687482 + .long 630718464 + .long 1066676905 + .long 2458269694 + .long 1024033081 + .long 1486061568 + .long 1066410070 + .long 115537874 + .long 3173243995 + .long 2743664640 + .long 1065886792 + .long 3665098304 + .long 3173471607 + .long 1971912704 + .long 1065357333 + .long 2577214440 + .long 3171993451 + .long 1498939392 + .long 1064306693 + .long 3409036923 + .long 1025599151 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 4277811200 + .long 1067855426 + .long 2479318832 + .long 1022292823 + .long 2454267026 + .long 1069697316 + .long 0 + .long 3218079744 + .long 1030730101 + .long 3217380702 + .long 1431655765 + .long 1070945621 + .long 2576980378 + .long 1070176665 + .long 0 + .long 3219128320 + .long 0 + .long 4294959104 + .long 0 + .long 4294959104 + .type static_const_table,@object + .size static_const_table,2144 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/logb_wmt.S b/external/sgx_libm/ia32/logb_wmt.S new file mode 100644 index 0000000000..f5d36ff39e --- /dev/null +++ b/external/sgx_libm/ia32/logb_wmt.S @@ -0,0 +1,171 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logb_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin logb + .text + .align 16,0x90 + .globl logb +logb: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movq %xmm0, 8(%esp) + psrlq $52, %xmm0 + movd %xmm0, %eax + andl $2047, %eax + subl $1, %eax + cmpl $2046, %eax + jae .L_2TAG_PACKET_0.0.3 + subl $1022, %eax + movl %eax, (%esp) + fildl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + movq 8(%esp), %xmm0 + movq 16(%ebx), %xmm1 + pxor %xmm2, %xmm2 + testl %eax, %eax + jg .L_2TAG_PACKET_2.0.3 + comisd %xmm2, %xmm0 + mulsd %xmm1, %xmm0 + je .L_2TAG_PACKET_3.0.3 + psrlq $52, %xmm0 + movd %xmm0, %eax + andl $2047, %eax + subl $1078, %eax + movl %eax, (%esp) + fildl (%esp) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + psrlq $60, %xmm0 + fldl 8(%esp) + movd %xmm0, %eax + andl $8, %eax + fmull (%ebx,%eax) + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movq 8(%ebx), %xmm0 + divsd %xmm2, %xmm0 + movq %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $151, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) +.L_2TAG_PACKET_1.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type logb,@function + .size logb,.-logb + .data +# -- End logb + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .long 0 + .long 1130364928 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/logbf.S b/external/sgx_libm/ia32/logbf.S new file mode 100644 index 0000000000..69539c7124 --- /dev/null +++ b/external/sgx_libm/ia32/logbf.S @@ -0,0 +1,122 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logbf.c" + .text +..TXTST0: +# -- Begin logbf + .text + .align 16,0x90 + .globl logbf +logbf: +# parameter 1: 16 + %esp +..B1.1: +..L1: + + subl $12, %esp + movl 16(%esp), %eax + movl %eax, %edx + andl $2147483647, %edx + addl $-8388608, %edx + cmpl $2130706432, %edx + jb ..B1.7 +..B1.2: + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + testl %edx, %edx + jge ..B1.6 +..B1.3: + cmpl $-8388608, %edx + je ..B1.8 +..B1.4: + flds 16(%esp) + fmuls .L_2il0floatpacket.1@GOTOFF(%ecx) + fstps 16(%esp) + movl 16(%esp), %eax + andl $2147483647, %eax + shrl $23, %eax + addl $-152, %eax + movl %eax, (%esp) + fildl (%esp) +..B1.5: + addl $12, %esp + ret +..B1.6: + flds 16(%esp) + shrl $31, %eax + fmuls _ones@GOTOFF(%ecx,%eax,4) + addl $12, %esp + ret +..B1.7: + shrl $23, %edx + addl $-126, %edx + movl %edx, (%esp) + fildl (%esp) + addl $12, %esp + ret +..B1.8: + fldz + fdivrs .L_2il0floatpacket.0@GOTOFF(%ecx) + addl $12, %esp + ret + .align 16,0x90 + .type logbf,@function + .size logbf,.-logbf + .data +# -- End logbf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/logbl.S b/external/sgx_libm/ia32/logbl.S new file mode 100644 index 0000000000..f7fe85e705 --- /dev/null +++ b/external/sgx_libm/ia32/logbl.S @@ -0,0 +1,161 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logbl.c" + .text +..TXTST0: +# -- Begin logbl + .text + .align 16,0x90 + .globl logbl +logbl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp +..B1.2: + fnstcw 22(%esp) +..B1.3: + movzwl 22(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.18 +..B1.4: + orl $-64768, %edx + movw %dx, 20(%esp) +..B1.5: + fldcw 20(%esp) +..B1.6: + movl $1, %edx +..B1.7: + movzwl 16(%ebp), %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $32767, %ecx + je ..B1.17 +..B1.8: + testl %ecx, %ecx + jne ..B1.12 +..B1.9: + cmpl $0, 12(%ebp) + jne ..B1.11 +..B1.10: + cmpl $0, 8(%ebp) + je ..B1.16 +..B1.11: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%eax) + fstpt 8(%ebp) + movzwl 16(%ebp), %eax + andl $32767, %eax + addl $-16458, %eax + movl %eax, (%esp) + fildl (%esp) + fstpt 8(%esp) + jmp ..B1.13 +..B1.12: + addl $-16383, %ecx + movl %ecx, (%esp) + fildl (%esp) + fstpt 8(%esp) +..B1.13: + testl %edx, %edx + je ..B1.15 +..B1.14: + fldcw 22(%esp) +..B1.15: + fldt 8(%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.16: + fldl 8+_ones@GOTOFF(%eax) + fdivl _zeros@GOTOFF(%eax) + fstpt 8(%esp) + jmp ..B1.13 +..B1.17: + fldt 8(%ebp) + movzbl 17(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + fmull _ones@GOTOFF(%eax,%ecx,8) + fstpt 8(%esp) + jmp ..B1.13 +..B1.18: + xorl %edx, %edx + jmp ..B1.7 + .align 16,0x90 + .type logbl,@function + .size logbl,.-logbl + .data +# -- End logbl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/logf_table.S b/external/sgx_libm/ia32/logf_table.S new file mode 100644 index 0000000000..5cf1f0703d --- /dev/null +++ b/external/sgx_libm/ia32/logf_table.S @@ -0,0 +1,304 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logf_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_logf_table_256 + .globl __libm_logf_table_256 +__libm_logf_table_256: + .long 0x55d5889e,0x3f600401 + .long 0x14586b54,0x3f781212 + .long 0xf96832f0,0x3f841929 + .long 0x84c75f07,0x3f8c3173 + .long 0x1ac73386,0x3f91a6b9 + .long 0x5d9ac03a,0x3f95ba9a + .long 0x074325f4,0x3f99d2a8 + .long 0x25979802,0x3f9d6b27 + .long 0xa19dfaa9,0x3fa0c58f + .long 0x78cbce1b,0x3fa2954c + .long 0x2da96c57,0x3fa4a94d + .long 0xf2d4bb58,0x3fa67c94 + .long 0xb630f068,0x3fa85188 + .long 0xbe73af4c,0x3faa6b8a + .long 0x06f72a9e,0x3fac441e + .long 0x13606d07,0x3fae1e67 + .long 0x11ab9301,0x3faffa69 + .long 0x9c5da601,0x3fb0ec13 + .long 0x643d190b,0x3fb1dbd2 + .long 0x84fe5f1c,0x3fb2cc72 + .long 0xa7d1ee64,0x3fb3bdf5 + .long 0x7aa012e0,0x3fb4b05d + .long 0x7ceb5702,0x3fb580db + .long 0x89365a7a,0x3fb674f0 + .long 0x2c6b568d,0x3fb769ef + .long 0x27506a48,0x3fb85fd9 + .long 0x5d594989,0x3fb9335e + .long 0x20c8e5f5,0x3fba2b02 + .long 0xac1a86ac,0x3fbb0004 + .long 0x769fca11,0x3fbbf968 + .long 0xbfee13a8,0x3fbccfed + .long 0x638446a2,0x3fbda727 + .long 0x7fe10f7a,0x3fbea325 + .long 0xfedbfde6,0x3fbf7be9 + .long 0x52ff25f4,0x3fc02ab3 + .long 0x579d204d,0x3fc097ce + .long 0x8227e47c,0x3fc1178e + .long 0x7dbecf34,0x3fc18574 + .long 0x25f25d41,0x3fc1f3b9 + .long 0x1e6ddf57,0x3fc2625d + .long 0x0c86813a,0x3fc2d161 + .long 0x9741142e,0x3fc340c5 + .long 0x6757f2a9,0x3fc3b08b + .long 0x08378004,0x3fc40dfb + .long 0xe8ca5f7c,0x3fc47e74 + .long 0xf6466de4,0x3fc4ef51 + .long 0xe02ba516,0x3fc56092 + .long 0x57cd74d5,0x3fc5d238 + .long 0x37335d76,0x3fc6313a + .long 0xdabbd383,0x3fc6a399 + .long 0xdd3ce41a,0x3fc70337 + .long 0x128f6127,0x3fc77654 + .long 0x2a0b022d,0x3fc7e9d8 + .long 0x759f512f,0x3fc84a6b + .long 0xd5f5a310,0x3fc8ab47 + .long 0x9096581b,0x3fc91fe4 + .long 0x4011aa76,0x3fc98163 + .long 0x07089664,0x3fc9f6c4 + .long 0x29348f43,0x3fca58e7 + .long 0xc31693ad,0x3fcabb55 + .long 0x4919efd0,0x3fcb1e10 + .long 0x93e367cb,0x3fcb94ee + .long 0xc067555f,0x3fcbf851 + .long 0x54bf23a6,0x3fcc5c02 + .long 0xc9db3c52,0x3fccc000 + .long 0x99c85674,0x3fcd244d + .long 0x3fb2f450,0x3fcd88e9 + .long 0x37eaef01,0x3fcdedd4 + .long 0xffe71012,0x3fce530e + .long 0x1648b971,0x3fceb89a + .long 0xfadf9bde,0x3fcf1e75 + .long 0x2ead7c36,0x3fcf84a3 + .long 0x33ea07cd,0x3fcfeb22 + .long 0xc7035c1c,0x3fd028f9 + .long 0xe0d9635a,0x3fd05c8b + .long 0x8f8ae797,0x3fd085eb + .long 0xe32d1911,0x3fd0b9c8 + .long 0x60b78081,0x3fd0edd0 + .long 0x4cf0063f,0x3fd12202 + .long 0x927aecd4,0x3fd14be2 + .long 0x8ef18adf,0x3fd18061 + .long 0xbe2fc63b,0x3fd1b50b + .long 0xc7cf242d,0x3fd1df4c + .long 0x6d0eb8d4,0x3fd21445 + .long 0x991eba49,0x3fd23ec5 + .long 0x9f870afb,0x3fd2740d + .long 0xabcdfa04,0x3fd29ecd + .long 0x02adccee,0x3fd2d466 + .long 0xb04ea9d4,0x3fd2ff66 + .long 0x4b355a38,0x3fd33550 + .long 0x5ec44f5d,0x3fd36092 + .long 0xc3337e75,0x3fd38bf1 + .long 0x77333184,0x3fd3c252 + .long 0x63c1683e,0x3fd3edf4 + .long 0x23d5e8c7,0x3fd419b4 + .long 0xe0539f49,0x3fd44591 + .long 0x75b6f0ad,0x3fd47c91 + .long 0x41552b09,0x3fd4a8b3 + .long 0x908901a0,0x3fd4d4f3 + .long 0x8da1f968,0x3fd50152 + .long 0x6347d4f6,0x3fd52dd0 + .long 0x3c7b8a8a,0x3fd55a6d + .long 0x2b112a59,0x3fd5925d + .long 0x6b543db2,0x3fd5bf40 + .long 0x3d5c35ae,0x3fd5ec43 + .long 0xcdb02c1f,0x3fd61965 + .long 0x4935b2a2,0x3fd646a8 + .long 0xdd31de95,0x3fd6740a + .long 0xb74a58c5,0x3fd6a18d + .long 0x058670ec,0x3fd6cf31 + .long 0xe852f0ba,0x3fd6f180 + .long 0x71b894f0,0x3fd71f5d + .long 0xefd66d5c,0x3fd74d5a + .long 0x922bd37e,0x3fd77b79 + .long 0x889f19e2,0x3fd7a9b9 + .long 0x037eb6a6,0x3fd7d81b + .long 0x33827231,0x3fd8069e + .long 0xd3ef8bcb,0x3fd82996 + .long 0x776dcbfb,0x3fd85855 + .long 0x58327ccf,0x3fd88736 + .long 0x973ab8cf,0x3fd8aa75 + .long 0xdc8824e5,0x3fd8d992 + .long 0xea7d9512,0x3fd908d2 + .long 0xe79c0e56,0x3fd92c59 + .long 0x50ee3ed3,0x3fd95bd7 + .long 0x11a3ee5b,0x3fd98b78 + .long 0xf33d406c,0x3fd9af47 + .long 0x0c1914a8,0x3fd9df27 + .long 0xed14fda5,0x3fda0325 + .long 0x0224fa79,0x3fda3344 + .long 0x5e80c383,0x3fda5772 + .long 0x165dd199,0x3fda87d0 + .long 0x6c03f896,0x3fdaac2e + .long 0x6fdf6a81,0x3fdadccc + .long 0x3eb1e790,0x3fdb015b + .long 0x3a635948,0x3fdb323a + .long 0x04462909,0x3fdb56fa + .long 0xa659bc93,0x3fdb881a + .long 0xef3db165,0x3fdbad0b + .long 0x97781c2f,0x3fdbd212 + .long 0x36f08819,0x3fdc0392 + .long 0x1e4d32fd,0x3fdc28cb + .long 0xb84723c2,0x3fdc4e19 + .long 0xc74554c9,0x3fdc7ff9 + .long 0x64e9db05,0x3fdca57b + .long 0x0a5cebb0,0x3fdccb13 + .long 0xd18f326f,0x3fdcf0c0 + .long 0x75b5a201,0x3fdd2320 + .long 0x46defa6b,0x3fdd4902 + .long 0x918d25cd,0x3fdd6efa + .long 0x707ae52f,0x3fdd9509 + .long 0xfe92c554,0x3fddbb2e + .long 0x3445e4af,0x3fddee2f + .long 0x1a2726ce,0x3fde148a + .long 0x0a49ff40,0x3fde3afc + .long 0x206d516e,0x3fde6185 + .long 0x78823d52,0x3fde8825 + .long 0x2eac990c,0x3fdeaedd + .long 0x5f436be3,0x3fded5ac + .long 0x26d16ab9,0x3fdefc93 + .long 0xa2157600,0x3fdf2391 + .long 0xee03192d,0x3fdf4aa7 + .long 0x27c30bb0,0x3fdf71d6 + .long 0x6cb3b379,0x3fdf991c + .long 0xda69a910,0x3fdfc07a + .long 0x8eb03d3e,0x3fdfe7f1 + .long 0x53c5002e,0x3fe007c0 + .long 0x2198a5a1,0x3fe01b94 + .long 0x400c64eb,0x3fe02f74 + .long 0xbe7603ad,0x3fe04360 + .long 0xac47fe34,0x3fe05759 + .long 0x1911cf52,0x3fe06b5f + .long 0x0533c568,0x3fe078bf + .long 0x687e7b0e,0x3fe08cd9 + .long 0x74cf9019,0x3fe0a100 + .long 0x3a234477,0x3fe0b534 + .long 0xc89431ce,0x3fe0c974 + .long 0x305b9886,0x3fe0ddc2 + .long 0x4bafc918,0x3fe0eb52 + .long 0x4213a476,0x3fe0ffb5 + .long 0x3da97d9f,0x3fe11425 + .long 0x4f1d9aff,0x3fe128a2 + .long 0x52bf0865,0x3fe13652 + .long 0x58b4a92d,0x3fe14ae5 + .long 0xa19c765b,0x3fe15f85 + .long 0x38c119fa,0x3fe16d4d + .long 0xc20dd133,0x3fe18203 + .long 0xbc4b1f3b,0x3fe196c7 + .long 0x38b7a33c,0x3fe1a4a7 + .long 0xc0c9653d,0x3fe1b981 + .long 0xe8bb106b,0x3fe1ce69 + .long 0x9de06944,0x3fe1dc61 + .long 0xa2ad0da4,0x3fe1f160 + .long 0x7740737e,0x3fe2066d + .long 0xba47a394,0x3fe2147d + .long 0xbc5ebac3,0x3fe229a1 + .long 0x841a502e,0x3fe237c1 + .long 0xe6f80d9a,0x3fe24cfc + .long 0x55cd5762,0x3fe25b2c + .long 0x4d5f7c41,0x3fe2707f + .long 0x842ca384,0x3fe285e0 + .long 0x4708b773,0x3fe29429 + .long 0x670aff0c,0x3fe2a9a2 + .long 0x2c8d1cc1,0x3fe2b7fb + .long 0x6395f5f5,0x3fe2c65a + .long 0x57b0df43,0x3fe2dbf5 + .long 0xc3f97655,0x3fe2ea64 + .long 0x23684d73,0x3fe30018 + .long 0xe9a8b5cd,0x3fe30e97 + .long 0xebdd34ea,0x3fe32463 + .long 0x314ad796,0x3fe332f4 + .long 0x0e7464d0,0x3fe348d9 + .long 0xf8c43d6e,0x3fe35779 + .long 0x961a6a99,0x3fe36621 + .long 0x9f3c366a,0x3fe37c29 + .long 0x171976e7,0x3fe38ae2 + .long 0x57a603e7,0x3fe399a1 + .long 0xfe77b9d1,0x3fe3afcc + .long 0x503533b5,0x3fe3be9d + .long 0x80b4a8a3,0x3fe3cd74 + .long 0x3918f76c,0x3fe3e3c4 + .long 0xb27ed6c7,0x3fe3f2ac + .long 0x2125ca93,0x3fe4019c + .long 0x61389722,0x3fe41810 + .long 0x518df545,0x3fe42711 + .long 0x4e12b6bf,0x3fe43619 + .long 0x5d68ea69,0x3fe44528 + .long 0x464c893a,0x3fe45bcc + .long 0x21f117fc,0x3fe46aed + .long 0x27e8a2d3,0x3fe47a15 + .long 0x5efffccc,0x3fe48944 + .long 0xbcb69835,0x3fe4a018 + .long 0x0c9d65d7,0x3fe4af5a + .long 0xa5bdbe87,0x3fe4bea2 + .long 0x8f10ac47,0x3fe4cdf2 + .long 0xcf994058,0x3fe4dd49 + .long 0x6e64a684,0x3fe4eca8 + .long 0x3cd8eb68,0x3fe503c4 + .long 0x6667fc57,0x3fe51335 + .long 0x0738a3d8,0x3fe522ae + .long 0x26867857,0x3fe5322e + .long 0xcb979809,0x3fe541b5 + .long 0xfdbcbd62,0x3fe55144 + .long 0xc45153c7,0x3fe560db + .long 0x26bb8c66,0x3fe5707a + .long 0x0ed5b900,0x3fe587f6 + .long 0x977c8f31,0x3fe597a7 + .long 0xd634bb8b,0x3fe5a760 + .long 0xd295f10f,0x3fe5b721 + .long 0x94431ef9,0x3fe5c6ea + .long 0x22ea86f6,0x3fe5d6bb + .long 0x8645d390,0x3fe5e693 + .long 0xc61a2ed2,0x3fe5f673 + .long 0xea385926,0x3fe6065b + .long 0xfa7cc06b,0x3fe6164b + .long 0xfecf9743,0x3fe62643 + .type __libm_logf_table_256,@object + .size __libm_logf_table_256,2048 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/logf_wmt.S b/external/sgx_libm/ia32/logf_wmt.S new file mode 100644 index 0000000000..4a00864c73 --- /dev/null +++ b/external/sgx_libm/ia32/logf_wmt.S @@ -0,0 +1,742 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin logf + .text + .align 16,0x90 + .globl logf +logf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl $16384, %ecx + movd %ecx, %xmm4 + movl $-32768, %eax + movd %eax, %xmm2 + xorpd %xmm3, %xmm3 + movl $16368, %edx + pinsrw $3, %edx, %xmm3 + xorpd %xmm5, %xmm5 +.L_2TAG_PACKET_0.0.3: + movd %xmm0, %edx + rcpss %xmm0, %xmm1 + movsd 2080(%ebx), %xmm7 + pshuflw $68, %xmm0, %xmm0 + paddd %xmm4, %xmm1 + subl $8388608, %edx + cmpl $2113929216, %edx + jae .L_2TAG_PACKET_1.0.3 + andps %xmm1, %xmm2 + cvtps2pd %xmm0, %xmm0 + cvtps2pd %xmm2, %xmm1 + movd %xmm2, %eax + andl $-8388608, %edx + subl $1056964608, %edx + cvtsi2sdl %edx, %xmm6 + mulsd %xmm1, %xmm0 + subl $1056964608, %edx + addl %edx, %eax + shrl $12, %eax + movsd (%ebx,%eax), %xmm4 + subsd %xmm3, %xmm0 + movsd 2088(%ebx), %xmm2 + movsd 2096(%ebx), %xmm1 + mulsd %xmm0, %xmm7 + addsd %xmm0, %xmm5 + mulsd %xmm0, %xmm0 + mulsd %xmm2, %xmm6 + addsd %xmm7, %xmm1 + addsd %xmm4, %xmm5 + mulsd %xmm1, %xmm0 + addsd %xmm6, %xmm5 + addsd %xmm0, %xmm5 + cvtpd2ps %xmm5, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + addl $8388608, %edx + js .L_2TAG_PACKET_3.0.3 + cmpl $8388608, %edx + jb .L_2TAG_PACKET_4.0.3 + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_5.0.3 + movl $528482304, %eax + movd %eax, %xmm6 + movsd 2064(%ebx), %xmm5 + mulss %xmm6, %xmm0 + jmp .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_5.0.3: + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $-2147483648, %edx + je .L_2TAG_PACKET_6.0.3 + addl %edx, %edx + cmpl $-16777216, %edx + ja .L_2TAG_PACKET_5.0.3 + xorps %xmm0, %xmm0 + divss %xmm0, %xmm0 + movl $5, %edx +.L_2TAG_PACKET_7.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $0, %edx + je .L_2TAG_PACKET_6.0.3 + movl $1602224128, %eax + movd %eax, %xmm7 + mulss %xmm7, %xmm0 + movsd 2072(%ebx), %xmm5 + jmp .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_6.0.3: + movl $-1082130432, %eax + movd %eax, %xmm0 + xorps %xmm1, %xmm1 + divss %xmm1, %xmm0 + movl $4, %edx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_2.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type logf,@function + .size logf,.-logf + .data +# -- End logf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4277811695 + .long 1072049730 + .long 4099377379 + .long 1072041554 + .long 2854492448 + .long 1072033410 + .long 3783013829 + .long 1072025297 + .long 1547061728 + .long 1072017216 + .long 3705668804 + .long 1072009165 + .long 649825382 + .long 1072001146 + .long 4257004898 + .long 1071993156 + .long 646346839 + .long 1071985198 + .long 1718090839 + .long 1071977269 + .long 2203733529 + .long 1071969370 + .long 1140698018 + .long 1071961501 + .long 1872170015 + .long 1071953661 + .long 3457002416 + .long 1071945850 + .long 669557459 + .long 1071938069 + .long 1179420986 + .long 1071930316 + .long 4076413893 + .long 1071922591 + .long 4165410145 + .long 1071914895 + .long 556124819 + .long 1071907228 + .long 957937516 + .long 1071899588 + .long 204914613 + .long 1071891976 + .long 1730507025 + .long 1071884391 + .long 387544807 + .long 1071876834 + .long 3922939863 + .long 1071869303 + .long 2912783494 + .long 1071861800 + .long 826988438 + .long 1071854324 + .long 1144260235 + .long 1071846874 + .long 3057005434 + .long 1071839450 + .long 1471209283 + .long 1071832053 + .long 4186184763 + .long 1071824681 + .long 1829683463 + .long 1071817336 + .long 2217517956 + .long 1071810016 + .long 288676754 + .long 1071802722 + .long 3875016090 + .long 1071795452 + .long 3636378776 + .long 1071788208 + .long 3125257108 + .long 1071780989 + .long 1606817369 + .long 1071773795 + .long 2648729924 + .long 1071766625 + .long 1236164615 + .long 1071759480 + .long 951558972 + .long 1071752359 + .long 1089617062 + .long 1071745262 + .long 952179194 + .long 1071738189 + .long 4143093266 + .long 1071731139 + .long 1388251237 + .long 1071724114 + .long 600267432 + .long 1071717112 + .long 1108583542 + .long 1071710133 + .long 2249313505 + .long 1071703177 + .long 3365155278 + .long 1071696244 + .long 3805304058 + .long 1071689334 + .long 2925366939 + .long 1071682447 + .long 87278952 + .long 1071675583 + .long 3249155078 + .long 1071668740 + .long 3195405229 + .long 1071661920 + .long 3601425396 + .long 1071655122 + .long 3853649835 + .long 1071648346 + .long 2393914686 + .long 1071638513 + .long 2944026756 + .long 1071625048 + .long 3870651933 + .long 1071611626 + .long 3993180461 + .long 1071598247 + .long 2142264402 + .long 1071584911 + .long 1454642149 + .long 1071571617 + .long 783063308 + .long 1071558365 + .long 3286084979 + .long 1071545154 + .long 3543033726 + .long 1071531985 + .long 438773454 + .long 1071518858 + .long 1458540784 + .long 1071505771 + .long 1212978710 + .long 1071492725 + .long 2912845216 + .long 1071479719 + .long 1189018219 + .long 1071466754 + .long 3567208110 + .long 1071453828 + .long 403064643 + .long 1071440943 + .long 3536762435 + .long 1071428096 + .long 3343209673 + .long 1071415289 + .long 3091669954 + .long 1071402521 + .long 1765778334 + .long 1071389792 + .long 2653362897 + .long 1071377101 + .long 461431547 + .long 1071364449 + .long 2790898835 + .long 1071351834 + .long 71706889 + .long 1071339258 + .long 4217424686 + .long 1071326718 + .long 1380502992 + .long 1071314217 + .long 3491778671 + .long 1071301752 + .long 1015732707 + .long 1071289325 + .long 1605095660 + .long 1071276934 + .long 35977849 + .long 1071264580 + .long 3977575844 + .long 1071252261 + .long 3927305531 + .long 1071239979 + .long 3275478714 + .long 1071227733 + .long 1125340846 + .long 1071215523 + .long 882913881 + .long 1071203348 + .long 1666971274 + .long 1071191208 + .long 2603916163 + .long 1071179103 + .long 2827693557 + .long 1071167033 + .long 1479703759 + .long 1071154998 + .long 2003684347 + .long 1071142997 + .long 3555691467 + .long 1071131030 + .long 1004016924 + .long 1071119098 + .long 2108975630 + .long 1071107199 + .long 1753021246 + .long 1071095334 + .long 3415503221 + .long 1071083502 + .long 1992719281 + .long 1071071704 + .long 977707388 + .long 1071059939 + .long 3870234994 + .long 1071048206 + .long 1291822077 + .long 1071036507 + .long 1050438164 + .long 1071024840 + .long 2370625547 + .long 1071013205 + .long 188394569 + .long 1071001603 + .long 2331021804 + .long 1070990032 + .long 3747176240 + .long 1070978493 + .long 3686719393 + .long 1070966986 + .long 1405669883 + .long 1070955511 + .long 461103529 + .long 1070944067 + .long 121152472 + .long 1070932654 + .long 3954874384 + .long 1070921271 + .long 2652318780 + .long 1070909920 + .long 4089234463 + .long 1070898599 + .long 3262235675 + .long 1070887309 + .long 3763576649 + .long 1070876049 + .long 601221319 + .long 1070864820 + .long 1673619518 + .long 1070853620 + .long 1999843716 + .long 1070842450 + .long 899399508 + .long 1070831310 + .long 1992167703 + .long 1070820199 + .long 313445281 + .long 1070809118 + .long 3788725476 + .long 1070798065 + .long 3168871046 + .long 1070787042 + .long 2094830420 + .long 1070776048 + .long 4212681596 + .long 1070765082 + .long 288676754 + .long 1070754146 + .long 2568927817 + .long 1070743237 + .long 1829681364 + .long 1070732357 + .long 1737005556 + .long 1070721505 + .long 1666870165 + .long 1070710681 + .long 1000063738 + .long 1070699885 + .long 3417111411 + .long 1070689116 + .long 4013324163 + .long 1070678375 + .long 2183652476 + .long 1070667662 + .long 1622638721 + .long 1070656976 + .long 1734435555 + .long 1070646317 + .long 1927726804 + .long 1070635685 + .long 1615681634 + .long 1070625080 + .long 215909304 + .long 1070614502 + .long 1445381777 + .long 1070603950 + .long 870975437 + .long 1070590754 + .long 1823716217 + .long 1070569756 + .long 323875369 + .long 1070548811 + .long 3839688678 + .long 1070527917 + .long 2667883253 + .long 1070507076 + .long 4293333010 + .long 1070486286 + .long 3324205749 + .long 1070465548 + .long 2966718784 + .long 1070444861 + .long 2140157205 + .long 1070424225 + .long 4066729595 + .long 1070403639 + .long 3386588242 + .long 1070383104 + .long 3337621361 + .long 1070362619 + .long 2870475188 + .long 1070342184 + .long 943446189 + .long 1070321799 + .long 817374162 + .long 1070301463 + .long 1465634365 + .long 1070281176 + .long 1869032404 + .long 1070260938 + .long 1015732707 + .long 1070240749 + .long 2196155141 + .long 1070220608 + .long 118003300 + .long 1070200516 + .long 2381031992 + .long 1070180471 + .long 3707175295 + .long 1070160474 + .long 3120348377 + .long 1070140525 + .long 3946380940 + .long 1070120623 + .long 928049556 + .long 1070100769 + .long 1699849154 + .long 1070080961 + .long 1018125008 + .long 1070061200 + .long 2235845747 + .long 1070041485 + .long 122671437 + .long 1070021817 + .long 2339728060 + .long 1070002194 + .long 3669742467 + .long 1069982617 + .long 3196851002 + .long 1069963086 + .long 11572342 + .long 1069943601 + .long 1800682930 + .long 1069924160 + .long 3372322013 + .long 1069904764 + .long 3835803021 + .long 1069885413 + .long 2306589128 + .long 1069866107 + .long 2201204065 + .long 1069846845 + .long 2647241692 + .long 1069827627 + .long 2778278092 + .long 1069808453 + .long 1733817001 + .long 1069789323 + .long 2954203158 + .long 1069770236 + .long 1295667077 + .long 1069751193 + .long 210141498 + .long 1069732193 + .long 3155274661 + .long 1069713235 + .long 709476866 + .long 1069694321 + .long 636640577 + .long 1069675449 + .long 2116286250 + .long 1069656619 + .long 38479793 + .long 1069637832 + .long 2183652476 + .long 1069619086 + .long 3452748429 + .long 1069600382 + .long 3047045639 + .long 1069581720 + .long 173141005 + .long 1069563100 + .long 970708326 + .long 1069541521 + .long 2106590683 + .long 1069504444 + .long 2198475040 + .long 1069467449 + .long 3996141691 + .long 1069430535 + .long 1669613218 + .long 1069393703 + .long 2283901796 + .long 1069356951 + .long 29117219 + .long 1069320280 + .long 1990183441 + .long 1069283688 + .long 2376948508 + .long 1069247176 + .long 3998935692 + .long 1069210743 + .long 1085389880 + .long 1069174390 + .long 760030536 + .long 1069138115 + .long 1566132617 + .long 1069101918 + .long 2056379433 + .long 1069065799 + .long 792781808 + .long 1069029758 + .long 641565395 + .long 1068993794 + .long 183156961 + .long 1068957907 + .long 2302040698 + .long 1068922096 + .long 1301778891 + .long 1068886362 + .long 84804484 + .long 1068850704 + .long 1562410668 + .long 1068815121 + .long 64741293 + .long 1068779614 + .long 2815553124 + .long 1068744181 + .long 4162338635 + .long 1068708823 + .long 2756122533 + .long 1068673540 + .long 1551389854 + .long 1068638331 + .long 3511047527 + .long 1068603195 + .long 3016419377 + .long 1068568133 + .long 3047045639 + .long 1068533144 + .long 296456961 + .long 1068497513 + .long 3221665916 + .long 1068427825 + .long 3697798734 + .long 1068358282 + .long 3453858508 + .long 1068288883 + .long 4234736672 + .long 1068219627 + .long 3506114812 + .long 1068150514 + .long 3044269692 + .long 1068081543 + .long 346010435 + .long 1068012714 + .long 1513453498 + .long 1067944025 + .long 4074027864 + .long 1067875476 + .long 1275317999 + .long 1067807068 + .long 3559777258 + .long 1067738798 + .long 4204867691 + .long 1067670667 + .long 797775935 + .long 1067602675 + .long 3825228429 + .long 1067534819 + .long 2313634884 + .long 1067467101 + .long 672386641 + .long 1067348671 + .long 3960777458 + .long 1067213778 + .long 1220920383 + .long 1067079157 + .long 684247743 + .long 1066944805 + .long 2020150230 + .long 1066810721 + .long 630721729 + .long 1066676905 + .long 535440936 + .long 1066543355 + .long 1486051399 + .long 1066410070 + .long 2227658502 + .long 1066152307 + .long 2743640746 + .long 1065886792 + .long 4184355568 + .long 1065621801 + .long 1971904113 + .long 1065357333 + .long 341338964 + .long 1064833554 + .long 1498975029 + .long 1064306693 + .long 1440057502 + .long 1063257089 + .long 0 + .long 0 + .long 0 + .long 0 + .long 4277811695 + .long 1078341186 + .long 4277811695 + .long 3225824834 + .long 1431655765 + .long 1070945621 + .long 4277811695 + .long 1047932482 + .long 1107282704 + .long 3219128321 + .long 4277811695 + .long 1047932482 + .type static_const_table,@object + .size static_const_table,2112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/logl.S b/external/sgx_libm/ia32/logl.S new file mode 100644 index 0000000000..f22a73fb41 --- /dev/null +++ b/external/sgx_libm/ia32/logl.S @@ -0,0 +1,70 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logl.c" + .text +..TXTST0: +# -- Begin logl + .text + .align 16,0x90 + .hidden logl + .globl logl +logl: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $24, %esp + fldt 32(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fstpt (%esp) + call __libm_logl@PLT +..B1.2: + addl $24, %esp + popl %ebx + ret + .align 16,0x90 + .type logl,@function + .size logl,.-logl + .data +# -- End logl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/logl_table.S b/external/sgx_libm/ia32/logl_table.S new file mode 100644 index 0000000000..8bff76cadb --- /dev/null +++ b/external/sgx_libm/ia32/logl_table.S @@ -0,0 +1,560 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logl_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_logl_table_256 + .globl __libm_logl_table_256 +__libm_logl_table_256: + .long 0x55d5a000,0x3f600401 + .long 0xf98e1114,0xbce76218 + .long 0x14588000,0x3f781212 + .long 0xf5a30364,0xbcf4abf1 + .long 0xf9684000,0x3f841929 + .long 0xa8bfb25e,0xbcfa20e2 + .long 0x84c74000,0x3f8c3173 + .long 0x18823013,0x3d0f0660 + .long 0x1ac72000,0x3f91a6b9 + .long 0x36a9c5bb,0x3d13861d + .long 0x5d9ac000,0x3f95ba9a + .long 0xe08d78ac,0x3cacbb84 + .long 0x07434000,0x3f99d2a8 + .long 0xeb1d2ef8,0xbd1a0c1f + .long 0x2597c000,0x3f9d6b27 + .long 0xa1a37071,0xbd23fef6 + .long 0xa19e0000,0x3fa0c58f + .long 0x58b17913,0xbd0559d1 + .long 0x78cbc000,0x3fa2954c + .long 0x570c1572,0x3d1c3526 + .long 0x2da98000,0x3fa4a94d + .long 0xbad48944,0xbd23a98f + .long 0xf2d4c000,0x3fa67c94 + .long 0xec19afa2,0xbd029efb + .long 0xb6310000,0x3fa85188 + .long 0xdf4d03fb,0xbd1f2fd5 + .long 0xbe73c000,0x3faa6b8a + .long 0x5c8ed1b8,0xbd20b3b9 + .long 0x06f74000,0x3fac441e + .long 0x6cf5e5d5,0xbd2561c1 + .long 0x13608000,0x3fae1e67 + .long 0xa4275f13,0xbd22f961 + .long 0x11ab8000,0x3faffa69 + .long 0x98381a8f,0x3d23008c + .long 0x9c5da000,0x3fb0ec13 + .long 0xe54ebd73,0x3d180247 + .long 0x643d2000,0x3fb1dbd2 + .long 0x9a20edb0,0xbd1bd36c + .long 0x84fe6000,0x3fb2cc72 + .long 0x34cd5d84,0xbcec742f + .long 0xa7d1e000,0x3fb3bdf5 + .long 0xa5db4ed7,0x3d2cc85e + .long 0x7aa00000,0x3fb4b05d + .long 0x8ddf26e3,0x3d32e053 + .long 0x7ceb8000,0x3fb580db + .long 0x26833e56,0xbd447f01 + .long 0x89364000,0x3fb674f0 + .long 0x4c9d3302,0x3d3a7999 + .long 0x2c6b8000,0x3fb769ef + .long 0xe71892b5,0xbd44b944 + .long 0x27508000,0x3fb85fd9 + .long 0x19970c1c,0xbd35b818 + .long 0x5d594000,0x3fb9335e + .long 0x3abd47da,0x3d23115c + .long 0x20c90000,0x3fba2b02 + .long 0x9c652090,0xbd3a0b35 + .long 0xac1a8000,0x3fbb0004 + .long 0x037f2b35,0x3d1aaf97 + .long 0x769fc000,0x3fbbf968 + .long 0x8d824283,0x3d24218c + .long 0xbfee0000,0x3fbccfed + .long 0x2fe71256,0x3d33a823 + .long 0x63844000,0x3fbda727 + .long 0x1fa71733,0x3d1a8940 + .long 0x7fe10000,0x3fbea325 + .long 0x47e4627a,0x3d2ef30d + .long 0xfedc0000,0x3fbf7be9 + .long 0x2b2b3bc6,0xbd00d05d + .long 0x52ff2000,0x3fc02ab3 + .long 0x5d569b2b,0x3d27ce63 + .long 0x579d2000,0x3fc097ce + .long 0xda652881,0x3ce33742 + .long 0x82280000,0x3fc1178e + .long 0xcc74be04,0xbd4b8421 + .long 0x7dbec000,0x3fc18574 + .long 0x45bd9b49,0x3d3e6744 + .long 0x25f26000,0x3fc1f3b9 + .long 0x9b083633,0xbd15f74e + .long 0x1e6de000,0x3fc2625d + .long 0xf09e3d82,0xbcf52962 + .long 0x0c868000,0x3fc2d161 + .long 0xcb81b4a1,0x3d039d6c + .long 0x97412000,0x3fc340c5 + .long 0xf7d9d386,0xbd37a3dc + .long 0x67580000,0x3fc3b08b + .long 0xf29320fb,0xbd3aade8 + .long 0x08378000,0x3fc40dfb + .long 0xc4f7b685,0x3c9bb453 + .long 0xe8ca6000,0x3fc47e74 + .long 0xb7020316,0xbcf07c95 + .long 0xf6466000,0x3fc4ef51 + .long 0x21c8cd53,0x3d3bc83d + .long 0xe02bc000,0x3fc56092 + .long 0xfe5d989a,0xbd4ae9eb + .long 0x57cd4000,0x3fc5d238 + .long 0x4b74dcf5,0x3d5a6a61 + .long 0x37334000,0x3fc6313a + .long 0x561bc2b2,0x3d4d7641 + .long 0xdabc0000,0x3fc6a399 + .long 0x399a856a,0xbd563e4d + .long 0xdd3d0000,0x3fc70337 + .long 0x1d685519,0xbd4be57a + .long 0x128f8000,0x3fc77654 + .long 0x520d9718,0xbd4ed8b4 + .long 0x2a0b4000,0x3fc7e9d8 + .long 0x605bf1b1,0xbd5ee97b + .long 0x759f8000,0x3fc84a6b + .long 0x0ab7e182,0xbd5768a0 + .long 0xd5f5c000,0x3fc8ab47 + .long 0xf5f4572e,0xbd4cf028 + .long 0x90964000,0x3fc91fe4 + .long 0x79850e19,0x3d481b4e + .long 0x4011c000,0x3fc98163 + .long 0x30b7dd0f,0xbd458a91 + .long 0x07088000,0x3fc9f6c4 + .long 0x5a19605e,0x3d466413 + .long 0x29348000,0x3fca58e7 + .long 0x504551b1,0x3d3e867d + .long 0xc3168000,0x3fcabb55 + .long 0x9a875994,0x3d43acd2 + .long 0x491a0000,0x3fcb1e10 + .long 0xed340663,0xbd402ffc + .long 0x93e38000,0x3fcb94ee + .long 0x47492dd7,0xbd48357e + .long 0xc0674000,0x3fcbf851 + .long 0xd9fbd5aa,0x3d455ef8 + .long 0x54bf4000,0x3fcc5c02 + .long 0x5184bd39,0xbd4c5a15 + .long 0xc9db4000,0x3fccc000 + .long 0x5d57aff9,0xbd1d6d58 + .long 0x99c84000,0x3fcd244d + .long 0x032241dc,0x3d4673ec + .long 0x3fb30000,0x3fcd88e9 + .long 0x0234bf51,0xbd375f28 + .long 0x37eb0000,0x3fcdedd4 + .long 0x565353b4,0xbd40ff6d + .long 0xffe70000,0x3fce530e + .long 0x276041f4,0x3d401212 + .long 0x1648c000,0x3fceb89a + .long 0x16fee901,0xbd2a3b21 + .long 0xfadfc000,0x3fcf1e75 + .long 0x64bb07ee,0xbd5210c5 + .long 0x2ead8000,0x3fcf84a3 + .long 0xb3098725,0xbd1e5438 + .long 0x33ea0000,0x3fcfeb22 + .long 0xde00938b,0x3d2f3418 + .long 0xc7036000,0x3fd028f9 + .long 0xe9f33100,0xbd2f1eb9 + .long 0xe0d96000,0x3fd05c8b + .long 0xc77ccb58,0x3d2ad0f1 + .long 0x8f8ae000,0x3fd085eb + .long 0x3f45fe7b,0x3d3e5d51 + .long 0xe32d2000,0x3fd0b9c8 + .long 0xedbee0d8,0xbd3bbb62 + .long 0x60b78000,0x3fd0edd0 + .long 0x2d8435f5,0x3d0019b5 + .long 0x4cf02000,0x3fd12202 + .long 0xa2415097,0xbd59c089 + .long 0x927ae000,0x3fd14be2 + .long 0xc85685e2,0x3d49a817 + .long 0x8ef18000,0x3fd18061 + .long 0x1bc9638d,0x3d45be80 + .long 0xbe2fc000,0x3fd1b50b + .long 0x3263201f,0x3d38ecd7 + .long 0xc7cf2000,0x3fd1df4c + .long 0x0455f7e4,0x3d30b43f + .long 0x6d0ea000,0x3fd21445 + .long 0xf5d235d7,0x3d58d43e + .long 0x991ec000,0x3fd23ec5 + .long 0x48a2e522,0xbd36dbe4 + .long 0x9f872000,0x3fd2740d + .long 0xfa32bfeb,0xbd5504cf + .long 0xabce0000,0x3fd29ecd + .long 0x8847bb7a,0xbd37f189 + .long 0x02ade000,0x3fd2d466 + .long 0xbb9aa833,0xbd5311a1 + .long 0xb04ea000,0x3fd2ff66 + .long 0xd5f0c8e9,0x3d43a896 + .long 0x4b356000,0x3fd33550 + .long 0xec6206db,0xbd372206 + .long 0x5ec44000,0x3fd36092 + .long 0xf344bbd1,0x3d4eb929 + .long 0xc3336000,0x3fd38bf1 + .long 0xa0f4a8b7,0x3d5e74f4 + .long 0x77332000,0x3fd3c252 + .long 0x4b606bd6,0x3d5183b5 + .long 0x63c16000,0x3fd3edf4 + .long 0xeb4069e1,0x3d407cc1 + .long 0x23d5e000,0x3fd419b4 + .long 0x6ec90e0a,0x3d418e43 + .long 0xe053a000,0x3fd44591 + .long 0x92923d88,0xbd06e958 + .long 0x75b6e000,0x3fd47c91 + .long 0x8b804f1b,0x3d50ad66 + .long 0x41554000,0x3fd4a8b3 + .long 0xe1791b98,0xbd54f6c0 + .long 0x90890000,0x3fd4d4f3 + .long 0x3a9f1441,0x3d19fd79 + .long 0x8da1e000,0x3fd50152 + .long 0x3694fa6b,0x3d5967d6 + .long 0x6347e000,0x3fd52dd0 + .long 0xeb98a049,0xbd46133a + .long 0x3c7b8000,0x3fd55a6d + .long 0xd6cf85a4,0x3d45138e + .long 0x2b110000,0x3fd5925d + .long 0x4b0b521a,0x3d652c81 + .long 0x6b544000,0x3fd5bf40 + .long 0xeb68981c,0xbd227023 + .long 0x3d5c4000,0x3fd5ec43 + .long 0xf6eb1741,0xbd44a472 + .long 0xcdb04000,0x3fd61965 + .long 0xac078912,0xbd53e115 + .long 0x4935c000,0x3fd646a8 + .long 0x6d25a6ca,0xbd4abc23 + .long 0xdd320000,0x3fd6740a + .long 0xb8b270ac,0xbd60b5c4 + .long 0xb74a8000,0x3fd6a18d + .long 0x67b50a45,0xbd639d6d + .long 0x05868000,0x3fd6cf31 + .long 0xddac7ab9,0xbd4e27a6 + .long 0xe8530000,0x3fd6f180 + .long 0x0a20af33,0xbd4e8c49 + .long 0x71b88000,0x3fd71f5d + .long 0x712fcc92,0x3d54efa4 + .long 0xefd68000,0x3fd74d5a + .long 0x30990150,0xbd52a3e5 + .long 0x922bc000,0x3fd77b79 + .long 0xf6201124,0x3d537dc9 + .long 0x889f4000,0x3fd7a9b9 + .long 0x0dd20a44,0xbd630ed1 + .long 0x037ec000,0x3fd7d81b + .long 0x622fc2c1,0xbd42b381 + .long 0x33828000,0x3fd8069e + .long 0xe1da7992,0xbd4b9e42 + .long 0xd3ef8000,0x3fd82996 + .long 0xae7d64a2,0x3d47956a + .long 0x776e0000,0x3fd85855 + .long 0x0cccc887,0xbd6a02a9 + .long 0x58328000,0x3fd88736 + .long 0x1f7fc497,0xbd2988e2 + .long 0x973ac000,0x3fd8aa75 + .long 0x9e0af65a,0xbd3cc466 + .long 0xdc884000,0x3fd8d992 + .long 0xebb56b23,0xbd5b1b77 + .long 0xea7d8000,0x3fd908d2 + .long 0xf0e513c0,0x3d551185 + .long 0xe79c0000,0x3fd92c59 + .long 0x039fe987,0x3d4cac17 + .long 0x50ee4000,0x3fd95bd7 + .long 0x0649244f,0xbd12d6ab + .long 0x11a3c000,0x3fd98b78 + .long 0x3a5b6609,0x3d672da9 + .long 0xf33d4000,0x3fd9af47 + .long 0x59d98c86,0x3cfae14a + .long 0x0c190000,0x3fd9df27 + .long 0x963f4336,0x3d54a786 + .long 0xed150000,0x3fda0325 + .long 0xb0d5e095,0xbd22dc20 + .long 0x02250000,0x3fda3344 + .long 0x40314305,0xbd361cdd + .long 0x5e80c000,0x3fda5772 + .long 0xd1062b1b,0x3d2c172b + .long 0x165dc000,0x3fda87d0 + .long 0x7845f58e,0x3d51991f + .long 0x6c040000,0x3fdaac2e + .long 0xc856ee3b,0xbd3da90d + .long 0x6fdf8000,0x3fdadccc + .long 0x23b48979,0xbd557ef2 + .long 0x3eb20000,0x3fdb015b + .long 0xa4504de4,0xbd586fcd + .long 0x3a638000,0x3fdb323a + .long 0x7a9aa342,0xbd635be0 + .long 0x04464000,0x3fdb56fa + .long 0xad27be67,0xbd56f6ad + .long 0xa659c000,0x3fdb881a + .long 0x58ba5c9c,0xbd2b65ac + .long 0xef3d8000,0x3fdbad0b + .long 0xe4a81b98,0x3d68b265 + .long 0x97780000,0x3fdbd212 + .long 0xa247841c,0x3d5c2f63 + .long 0x36f08000,0x3fdc0392 + .long 0x435af523,0x3d403109 + .long 0x1e4d4000,0x3fdc28cb + .long 0xdc568214,0xbd4a0635 + .long 0xb8474000,0x3fdc4e19 + .long 0x9ad9f32c,0xbd5c3e5b + .long 0xc7454000,0x3fdc7ff9 + .long 0x47d5b6ca,0x3d54c924 + .long 0x64e9c000,0x3fdca57b + .long 0xd12a2803,0x3d5b0510 + .long 0x0a5d0000,0x3fdccb13 + .long 0x48811a12,0xbd545041 + .long 0xd18f4000,0x3fdcf0c0 + .long 0xc2008d44,0xbd4b2160 + .long 0x75b58000,0x3fdd2320 + .long 0x12cccc3a,0x3d610091 + .long 0x46df0000,0x3fdd4902 + .long 0x0b2c4c2c,0xbd365228 + .long 0x918d4000,0x3fdd6efa + .long 0x7676c78e,0xbd5a329d + .long 0x707ac000,0x3fdd9509 + .long 0x77579caf,0x3d6297b8 + .long 0xfe92c000,0x3fddbb2e + .long 0x0943c435,0x3d3550ac + .long 0x3445c000,0x3fddee2f + .long 0x3a0f9d04,0x3d625775 + .long 0x1a274000,0x3fde148a + .long 0x20732293,0xbd59326b + .long 0x0a4a0000,0x3fde3afc + .long 0x573921f0,0xbd080095 + .long 0x206d4000,0x3fde6185 + .long 0xc9807dcf,0x3d516d95 + .long 0x78824000,0x3fde8825 + .long 0xaa15d3d9,0xbd25726d + .long 0x2eac8000,0x3fdeaedd + .long 0xad7934b2,0x3d590c33 + .long 0x5f438000,0x3fded5ac + .long 0x1bc1c15c,0xbd541d1a + .long 0x26d14000,0x3fdefc93 + .long 0x206858e7,0x3d655c54 + .long 0xa2154000,0x3fdf2391 + .long 0x202b7ba5,0x3d6affe2 + .long 0xee030000,0x3fdf4aa7 + .long 0x56f014a9,0x3d592cde + .long 0x27c30000,0x3fdf71d6 + .long 0xe30f87ad,0x3d47600a + .long 0x6cb38000,0x3fdf991c + .long 0xcca0cdf3,0x3d69bcbe + .long 0xda698000,0x3fdfc07a + .long 0x2683bdae,0x3d6487fd + .long 0x8eb04000,0x3fdfe7f1 + .long 0xceb37e7a,0xbd260f51 + .long 0x53c50000,0x3fe007c0 + .long 0xc9c065f1,0x3cf73add + .long 0x2198a000,0x3fe01b94 + .long 0x5498efb5,0x3d4683ab + .long 0x400c8000,0x3fe02f74 + .long 0xe23775e2,0xbd6b154b + .long 0xbe760000,0x3fe04360 + .long 0x030d58c4,0x3d3d6774 + .long 0xac480000,0x3fe05759 + .long 0x83c1e850,0xbd2cc5f3 + .long 0x1911e000,0x3fe06b5f + .long 0x2598b50b,0xbd60ae17 + .long 0x0533c000,0x3fe078bf + .long 0x907b7d7f,0x3d45a048 + .long 0x687e8000,0x3fe08cd9 + .long 0xc00a19af,0xbd43c67f + .long 0x74cfa000,0x3fe0a100 + .long 0x22f73f90,0xbd5fcd6d + .long 0x3a234000,0x3fe0b534 + .long 0x4c68a7e5,0x3d41da30 + .long 0xc8942000,0x3fe0c974 + .long 0xa7cdcbb8,0x3d61cdc0 + .long 0x305ba000,0x3fe0ddc2 + .long 0x566f7df8,0xbd4de684 + .long 0x4bafc000,0x3fe0eb52 + .long 0x7feb3411,0x3d5230c5 + .long 0x4213a000,0x3fe0ffb5 + .long 0xbeeae6be,0x3d41d77b + .long 0x3da98000,0x3fe11425 + .long 0x3d4743ea,0xbd33050e + .long 0x4f1da000,0x3fe128a2 + .long 0x5906450d,0xbd440318 + .long 0x52bf0000,0x3fe13652 + .long 0xa621d4be,0x3d50c985 + .long 0x58b4a000,0x3fe14ae5 + .long 0x9895512f,0x3d525a20 + .long 0xa19c6000,0x3fe15f85 + .long 0xe4dca81e,0x3d665b5b + .long 0x38c12000,0x3fe16d4d + .long 0xaf71a89e,0xbd481628 + .long 0xc20de000,0x3fe18203 + .long 0x4bb7b8b9,0xbd5d995f + .long 0xbc4b2000,0x3fe196c7 + .long 0x14cec2c3,0xbd18a766 + .long 0x38b7a000,0x3fe1a4a7 + .long 0x26042793,0x3d39e2b1 + .long 0xc0c96000,0x3fe1b981 + .long 0x549461ed,0x3d44f378 + .long 0xe8bb0000,0x3fe1ce69 + .long 0xcc3339e5,0x3d606af5 + .long 0x9de06000,0x3fe1dc61 + .long 0xa1767071,0x3d528836 + .long 0xa2ad0000,0x3fe1f160 + .long 0x6c9de298,0x3d5b4741 + .long 0x77406000,0x3fe2066d + .long 0xd051f38d,0x3d637e65 + .long 0xba47c000,0x3fe2147d + .long 0x0cf5c8e9,0xbd6c6c55 + .long 0xbc5ec000,0x3fe229a1 + .long 0xf20d6e42,0xbd44f266 + .long 0x841a6000,0x3fe237c1 + .long 0xa47dba85,0xbd5fa312 + .long 0xe6f82000,0x3fe24cfc + .long 0xb65cb7bb,0xbd626596 + .long 0x55cd6000,0x3fe25b2c + .long 0x2ff856c0,0xbd513b72 + .long 0x4d5f8000,0x3fe2707f + .long 0xc37d4cdf,0xbd3df8b3 + .long 0x842ca000,0x3fe285e0 + .long 0x866d5f22,0x3d3c1c4d + .long 0x4708c000,0x3fe29429 + .long 0x7aca88eb,0xbd5119e8 + .long 0x670b0000,0x3fe2a9a2 + .long 0x1c2e5d10,0xbd1e7864 + .long 0x2c8d2000,0x3fe2b7fb + .long 0x00c270dd,0xbd39fb3c + .long 0x63960000,0x3fe2c65a + .long 0x03be9586,0xbd5415ea + .long 0x57b0e000,0x3fe2dbf5 + .long 0x07b9dc11,0xbd17a6e5 + .long 0xc3f96000,0x3fe2ea64 + .long 0x8b7d46fa,0x3d6654b2 + .long 0x23686000,0x3fe30018 + .long 0x5363d25e,0xbd628cd2 + .long 0xe9a8c000,0x3fe30e97 + .long 0x06943683,0xbd546671 + .long 0xebdd4000,0x3fe32463 + .long 0xc46cb528,0xbd562c21 + .long 0x314ae000,0x3fe332f4 + .long 0x1ea74541,0xbd50d4b6 + .long 0x0e746000,0x3fe348d9 + .long 0x44f828b5,0x3d433f3c + .long 0xf8c44000,0x3fe35779 + .long 0x22a46dd6,0xbd34934a + .long 0x961a8000,0x3fe36621 + .long 0x0cdd9d24,0xbd6566ce + .long 0x9f3c2000,0x3fe37c29 + .long 0x8e5820fe,0x3d666a2b + .long 0x17198000,0x3fe38ae2 + .long 0x576aad35,0xbd52316f + .long 0x57a60000,0x3fe399a1 + .long 0x62286d89,0x3d3f399c + .long 0xfe77c000,0x3fe3afcc + .long 0xedc1a56f,0xbd48bbbb + .long 0x50352000,0x3fe3be9d + .long 0x22f47589,0x3d63b540 + .long 0x80b4a000,0x3fe3cd74 + .long 0x9ebf0b71,0x3d51452e + .long 0x39190000,0x3fe3e3c4 + .long 0x4c617cda,0xbd512753 + .long 0xb27ec000,0x3fe3f2ac + .long 0x8d68a543,0x3d66c6ab + .long 0x2125c000,0x3fe4019c + .long 0xd9e1e717,0x3d552630 + .long 0x6138a000,0x3fe41810 + .long 0xa1618e8d,0xbd51bb4f + .long 0x518de000,0x3fe42711 + .long 0x38d47013,0x3d65455f + .long 0x4e12c000,0x3fe43619 + .long 0xaca69593,0xbd52819e + .long 0x5d68e000,0x3fe44528 + .long 0xf367503a,0x3d54d27f + .long 0x464ca000,0x3fe45bcc + .long 0xa4ffdcb2,0xbd66c5eb + .long 0x21f12000,0x3fe46aed + .long 0xa0df038b,0xbd50072e + .long 0x27e8a000,0x3fe47a15 + .long 0x83594fab,0x3d369a4a + .long 0x5f000000,0x3fe48944 + .long 0x95dc2343,0xbd39a0cf + .long 0xbcb6a000,0x3fe4a018 + .long 0xdb5ebf58,0xbd4f2ae4 + .long 0x0c9d6000,0x3fe4af5a + .long 0xedc4bac0,0x3d475de0 + .long 0xa5bdc000,0x3fe4bea2 + .long 0xefe50211,0xbd278f64 + .long 0x8f10c000,0x3fe4cdf2 + .long 0x7690ed86,0xbd63b982 + .long 0xcf994000,0x3fe4dd49 + .long 0x24d59d34,0x3d061972 + .long 0x6e64a000,0x3fe4eca8 + .long 0xb1079278,0x3d4a0e67 + .long 0x3cd90000,0x3fe503c4 + .long 0x0f1a734d,0xbd6497fc + .long 0x6667e000,0x3fe51335 + .long 0x4c9987aa,0x3d6c5739 + .long 0x0738a000,0x3fe522ae + .long 0x8164c759,0x3d3ebe70 + .long 0x26868000,0x3fe5322e + .long 0xba2da8ad,0xbd4ea333 + .long 0xcb978000,0x3fe541b5 + .long 0x62e3a6b9,0x3d680916 + .long 0xfdbcc000,0x3fe55144 + .long 0x2b35ba3e,0xbd34ec53 + .long 0xc4518000,0x3fe560db + .long 0x776b86a6,0xbd761cb6 + .long 0x26bb8000,0x3fe5707a + .long 0x5ff9981f,0x3d58ccc0 + .long 0x0ed5c000,0x3fe587f6 + .long 0xe6cce4c9,0xbd4c00c2 + .long 0x977cc000,0x3fe597a7 + .long 0xf6a33533,0xbd786770 + .long 0xd6348000,0x3fe5a760 + .long 0x365e53d9,0x3d7dc57c + .long 0xd2960000,0x3fe5b721 + .long 0x4f6ab8cd,0xbd5de23a + .long 0x94434000,0x3fe5c6ea + .long 0xa68978ec,0xbd70837e + .long 0x22ea8000,0x3fe5d6bb + .long 0xea2eecbe,0x3d4bd7d0 + .long 0x86460000,0x3fe5e693 + .long 0x23677de5,0xbd763831 + .long 0xc61a4000,0x3fe5f673 + .long 0x7a110a0e,0xbd612e5c + .long 0xea384000,0x3fe6065b + .long 0xc49e2cb9,0x3d692622 + .long 0xfa7cc000,0x3fe6164b + .long 0x27c383a0,0x3d0ad6c4 + .long 0xfecfc000,0x3fe62643 + .long 0x3ae25ed1,0xbd745e87 + .type __libm_logl_table_256,@object + .size __libm_logl_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lrint_wmt.S b/external/sgx_libm/ia32/lrint_wmt.S new file mode 100644 index 0000000000..5be751fc71 --- /dev/null +++ b/external/sgx_libm/ia32/lrint_wmt.S @@ -0,0 +1,188 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lrint_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin lrint + .text + .align 16,0x90 + .globl lrint +lrint: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movsd %xmm0, 16(%esp) + pextrw $3, %xmm0, %ecx + andl $32767, %ecx + cmpl $16863, %ecx + jge .L_2TAG_PACKET_0.0.3 +.L_2TAG_PACKET_1.0.3: + cvtsd2si %xmm0, %eax + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + comisd (%ebx), %xmm0 + jp .L_2TAG_PACKET_3.0.3 + ja .L_2TAG_PACKET_4.0.3 + ucomisd 16(%ebx), %xmm0 + jb .L_2TAG_PACKET_5.0.3 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_5.0.3: + ucomisd 32(%ebx), %xmm0 + ja .L_2TAG_PACKET_6.0.3 + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_4.0.3: + ucomisd 48(%ebx), %xmm0 + jb .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_7.0.3: + movl $-2147483648, %eax + movss 64(%ebx), %xmm1 + subss %xmm1, %xmm1 + movl %eax, 8(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 40(%esp), %eax + movl %eax, 8(%esp) + movl $184, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movl 8(%esp), %eax + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + movl $-2147483648, %eax + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + stmxcsr (%esp) + movl (%esp), %eax + andl $-2, %eax + movl %eax, (%esp) + ldmxcsr (%esp) + cvtsd2si %xmm0, %eax + stmxcsr (%esp) + movl (%esp), %edx + testl $1, %edx + jne .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_2.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type lrint,@function + .size lrint,.-lrint + .data +# -- End lrint + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4290772992 + .long 1105199103 + .long 4290772992 + .long 1105199103 + .long 0 + .long 3252682752 + .long 0 + .long 3252682752 + .long 2097152 + .long 3252682752 + .long 2097152 + .long 3252682752 + .long 0 + .long 1105199104 + .long 0 + .long 1105199104 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .type static_const_table,@object + .size static_const_table,80 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lrintf_wmt.S b/external/sgx_libm/ia32/lrintf_wmt.S new file mode 100644 index 0000000000..9a3925257b --- /dev/null +++ b/external/sgx_libm/ia32/lrintf_wmt.S @@ -0,0 +1,153 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lrintf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin lrintf + .text + .align 16,0x90 + .globl lrintf +lrintf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movss 128(%esp), %xmm0 + movss %xmm0, 16(%esp) + pextrw $1, %xmm0, %ecx + andl $32640, %ecx + cmpl $20224, %ecx + jge .L_2TAG_PACKET_0.0.3 + cvtss2si %xmm0, %eax + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + comiss (%ebx), %xmm0 + jp .L_2TAG_PACKET_2.0.3 + je .L_2TAG_PACKET_3.0.3 + movl $-2147483648, %eax + movss 16(%ebx), %xmm1 + subss %xmm1, %xmm1 + movl %eax, 8(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 40(%esp), %eax + movl %eax, 8(%esp) + movl $185, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movl 8(%esp), %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: +.L_2TAG_PACKET_3.0.3: + movl $-2147483648, %eax +.L_2TAG_PACKET_1.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type lrintf,@function + .size lrintf,.-lrintf + .data +# -- End lrintf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 3472883712 + .long 3472883712 + .long 3472883712 + .long 3472883712 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .type static_const_table,@object + .size static_const_table,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lrintl.S b/external/sgx_libm/ia32/lrintl.S new file mode 100644 index 0000000000..139d84c86c --- /dev/null +++ b/external/sgx_libm/ia32/lrintl.S @@ -0,0 +1,292 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lrintl.c" + .text +..TXTST0: +# -- Begin lrintl + .text + .align 16,0x90 + .globl lrintl +lrintl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + movzbl 17(%ebp), %edi + movzwl 16(%ebp), %ebx + andl $128, %edi + andl $32767, %ebx + shrl $7, %edi + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + cmpl $16413, %ebx + jge ..B1.8 +..B1.2: + testl %ebx, %ebx + jne ..B1.6 +..B1.3: + cmpl $0, 12(%ebp) + jne ..B1.5 +..B1.4: + cmpl $0, 8(%ebp) + je ..B1.6 +..B1.5: + fldl _smallest_value_64@GOTOFF(%esi) + fstpl 16(%esp) +..B1.6: + fldt 8(%ebp) + fistpl 36(%esp) +..B1.7: + movl 36(%esp), %eax + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.8: + cmpl $16415, %ebx + jge ..B1.28 +..B1.9: + lea 2147483647(%edi), %eax + movl %eax, 12(%esp) +..B1.10: + fnstcw 32(%esp) +..B1.11: + movzwl 32(%esp), %eax + andl $3072, %eax + movl %eax, 28(%esp) + cmpl $16414, %ebx + movl 8(%ebp), %eax + movl 12(%ebp), %edx + movl %eax, 24(%esp) + jge ..B1.14 +..B1.12: + cmpl $0, 24(%esp) + movl %edx, %ecx + movl $0, %eax + setne %al + shll $31, %ecx + orl %ecx, %eax + movl %eax, 24(%esp) +..B1.14: + movl %ebx, %ecx + negl %ecx + addl $30, %ecx + shrl %cl, %edx + cmpl $0, 28(%esp) + jne ..B1.16 +..B1.15: + testl $2147483647, %eax + movl %edi, (%esp) + movl %eax, %edi + movl $0, %eax + movl %eax, %ecx + setne %cl + shrl $31, %edi + orl %edx, %ecx + andl %ecx, %edi + xorl %ecx, %ecx + addl %edi, %edx + movl (%esp), %edi + adcl $0, %ecx + jmp ..B1.24 +..B1.16: + cmpl $2048, 28(%esp) + jne ..B1.18 +..B1.17: + testl %edi, %edi + movl $0, %eax + setne %al + movl %eax, (%esp) + jmp ..B1.19 +..B1.18: + movl $0, (%esp) + cmpl $1024, 28(%esp) + je ..B1.20 +..B1.19: + movl $0, 4(%esp) + jmp ..B1.21 +..B1.20: + testl %edi, %edi + movl $0, %eax + sete %al + movl %eax, 4(%esp) +..B1.21: + cmpl $3072, 28(%esp) + movl $0, %eax + sete %al + xorl %ecx, %ecx + orl (%esp), %eax + orl 4(%esp), %eax + jne ..B1.24 +..B1.23: + cmpl $0, 24(%esp) + movl $0, %eax + setne %al + addl %eax, %edx + adcl $0, %ecx +..B1.24: + movl %edx, %eax + subl 12(%esp), %eax + movl %eax, (%esp) + movl $0, %eax + sbbl %eax, %ecx + jb ..B1.25 +..B1.39: + movl (%esp), %eax + orl %ecx, %eax + jne ..B1.28 +..B1.25: + cmpl $0, 24(%esp) + je ..B1.27 +..B1.26: + fldl _ones@GOTOFF(%esi) + movl %edx, 36(%esp) + faddl _small_value_64@GOTOFF(%esi) + fstpl 16(%esp) +..B1.27: + movl %edx, %eax + negl %eax + testl %edi, %edi + jne ..L3 + movl %edx, %eax +..L3: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.28: + fldl _infs@GOTOFF(%esi) + cmpl $32767, %ebx + fmull _zeros@GOTOFF(%esi) + fstpl 16(%esp) + movl $-2147483648, 36(%esp) + jne ..B1.31 +..B1.29: + cmpl $-2147483648, 12(%ebp) + jne ..B1.36 +..B1.30: + cmpl $0, 8(%ebp) + jne ..B1.36 +..B1.31: + fnstcw 10(%esp) +..B1.32: + movzwl 10(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.33: + orl $-64768, %edx + movw %dx, 8(%esp) +..B1.34: + fldcw 8(%esp) +..B1.35: + fldcw 10(%esp) +..B1.36: + movl 36(%esp), %eax + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type lrintl,@function + .size lrintl,.-lrintl + .data +# -- End lrintl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lround_wmt.S b/external/sgx_libm/ia32/lround_wmt.S new file mode 100644 index 0000000000..1b3502a60d --- /dev/null +++ b/external/sgx_libm/ia32/lround_wmt.S @@ -0,0 +1,220 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lround_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin lround + .text + .align 16,0x90 + .globl lround +lround: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movq %xmm0, 16(%esp) + movq 16(%ebx), %xmm4 + movq 64(%ebx), %xmm5 + movq 96(%ebx), %xmm3 + movq (%ebx), %xmm1 + movdqa %xmm4, %xmm2 + pandn %xmm0, %xmm4 + pand %xmm0, %xmm2 + por %xmm5, %xmm2 + pextrw $3, %xmm0, %eax + andl $32752, %eax + subl $16368, %eax + cmpl $480, %eax + jae .L_2TAG_PACKET_0.0.3 + psrlq $52, %xmm4 + psubq %xmm4, %xmm3 + psllq %xmm3, %xmm1 + addsd %xmm2, %xmm0 + pand %xmm1, %xmm0 + cvttsd2si %xmm0, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + js .L_2TAG_PACKET_2.0.3 + movdqa %xmm2, %xmm6 + movq 80(%ebx), %xmm7 + psrlq $63, %xmm6 + paddq %xmm6, %xmm7 + cmpl $512, %eax + jge .L_2TAG_PACKET_3.0.3 + movq 48(%ebx), %xmm2 + addsd %xmm4, %xmm5 + psrlq $52, %xmm4 + psubq %xmm4, %xmm3 + movd %xmm6, %edx + psllq %xmm3, %xmm1 + pand %xmm1, %xmm5 + addsd %xmm2, %xmm5 + por %xmm7, %xmm2 + movd %xmm5, %eax + psubd %xmm5, %xmm2 + pmovmskb %xmm2, %ecx + andl $136, %ecx + jne .L_2TAG_PACKET_3.0.3 + testl %edx, %edx + je .L_2TAG_PACKET_4.0.3 + negl %eax +.L_2TAG_PACKET_4.0.3: + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + addl $16, %eax + js .L_2TAG_PACKET_5.0.3 + addsd %xmm2, %xmm2 + cvttsd2si %xmm2, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_5.0.3: + xorl %eax, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movq 32(%ebx), %xmm1 + movl $-2147483648, %eax + pxor %xmm2, %xmm2 + movd %eax, %xmm7 + mulsd %xmm2, %xmm1 + ucomisd %xmm0, %xmm0 + jc .L_2TAG_PACKET_6.0.3 + movq %xmm7, 8(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 40(%esp), %eax + movl %eax, 8(%esp) + movl $190, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movl 8(%esp), %eax +.L_2TAG_PACKET_6.0.3: +.L_2TAG_PACKET_1.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type lround,@function + .size lround,.-lround + .data +# -- End lround + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 2147483647 + .long 0 + .long 2147483647 + .long 0 + .long 1075 + .long 0 + .long 1075 + .long 0 + .type static_const_table,@object + .size static_const_table,112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lroundf_wmt.S b/external/sgx_libm/ia32/lroundf_wmt.S new file mode 100644 index 0000000000..d8a462096b --- /dev/null +++ b/external/sgx_libm/ia32/lroundf_wmt.S @@ -0,0 +1,228 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lroundf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin lroundf + .text + .align 16,0x90 + .globl lroundf +lroundf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movss 128(%esp), %xmm0 + movss %xmm0, 16(%esp) + movd 16(%ebx), %xmm4 + movd 64(%ebx), %xmm5 + movd 112(%ebx), %xmm3 + movd (%ebx), %xmm1 + movdqa %xmm4, %xmm2 + pandn %xmm0, %xmm4 + pand %xmm0, %xmm2 + por %xmm5, %xmm2 + pextrw $1, %xmm0, %eax + andl $32640, %eax + subl $16256, %eax + cmpl $2944, %eax + jae .L_2TAG_PACKET_0.0.3 + psrld $23, %xmm4 + psubd %xmm4, %xmm3 + pslld %xmm3, %xmm1 + addss %xmm2, %xmm0 + pand %xmm1, %xmm0 + cvttss2si %xmm0, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_0.0.3: + js .L_2TAG_PACKET_2.0.3 + cmpl $3840, %eax + jae .L_2TAG_PACKET_3.0.3 + cvttss2si %xmm0, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + movdqa %xmm2, %xmm6 + movd 32(%ebx), %xmm7 + psrld $31, %xmm6 + paddd %xmm6, %xmm7 + cmpl $4096, %eax + jge .L_2TAG_PACKET_4.0.3 + movd 96(%ebx), %xmm5 + movd 80(%ebx), %xmm2 + psrld $23, %xmm4 + pand %xmm0, %xmm5 + psubd %xmm3, %xmm4 + por %xmm2, %xmm5 + movd %xmm6, %edx + psllq %xmm4, %xmm5 + movd %xmm5, %eax + psubd %xmm5, %xmm7 + pmovmskb %xmm7, %ecx + andl $136, %ecx + jne .L_2TAG_PACKET_4.0.3 + testl %edx, %edx + je .L_2TAG_PACKET_5.0.3 + negl %eax +.L_2TAG_PACKET_5.0.3: + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + addl $128, %eax + js .L_2TAG_PACKET_6.0.3 + addss %xmm2, %xmm2 + cvttss2si %xmm2, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_6.0.3: + xorl %eax, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_4.0.3: + movd 48(%ebx), %xmm1 + movl $-2147483648, %eax + pxor %xmm2, %xmm2 + movd %eax, %xmm7 + mulss %xmm2, %xmm1 + ucomiss %xmm0, %xmm0 + jc .L_2TAG_PACKET_7.0.3 + movq %xmm7, 8(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 128(%esp), %eax + movl %eax, 4(%esp) + lea 40(%esp), %eax + movl %eax, 8(%esp) + movl $191, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movl 8(%esp), %eax +.L_2TAG_PACKET_7.0.3: +.L_2TAG_PACKET_1.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type lroundf,@function + .size lroundf,.-lroundf + .data +# -- End lroundf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 2147483648 + .long 2147483648 + .long 2147483648 + .long 2147483648 + .long 2147483647 + .long 2147483647 + .long 2147483647 + .long 2147483647 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .long 2139095040 + .long 1056964608 + .long 1056964608 + .long 1056964608 + .long 1056964608 + .long 8388608 + .long 8388608 + .long 8388608 + .long 8388608 + .long 8388607 + .long 8388607 + .long 8388607 + .long 8388607 + .long 150 + .long 150 + .long 150 + .long 150 + .type static_const_table,@object + .size static_const_table,128 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/lroundl.S b/external/sgx_libm/ia32/lroundl.S new file mode 100644 index 0000000000..df2caf23a8 --- /dev/null +++ b/external/sgx_libm/ia32/lroundl.S @@ -0,0 +1,253 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lroundl.c" + .text +..TXTST0: +# -- Begin lroundl + .text + .align 16,0x90 + .globl lroundl +lroundl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $20, %esp + movzbl 17(%ebp), %edi + movzwl 16(%ebp), %esi + andl $128, %edi + andl $32767, %esi + shrl $7, %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $16413, %esi + jge ..B1.11 +..B1.2: + cmpl $16383, %esi + jge ..B1.10 +..B1.3: + cmpl $16382, %esi + jge ..B1.9 +..B1.4: + testl %esi, %esi + jne ..B1.8 +..B1.5: + cmpl $0, 12(%ebp) + jne ..B1.7 +..B1.6: + cmpl $0, 8(%ebp) + je ..B1.8 +..B1.7: + fldl _smallest_value_64@GOTOFF(%ebx) + fstpl 8(%esp) +..B1.8: + xorl %eax, %eax + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.9: + movl iones@GOTOFF(%ebx,%edi,4), %eax + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.10: + negl %esi + movl 12(%ebp), %eax + movl %eax, %edx + lea 30(%esi), %ecx + addl $29, %esi + shrl %cl, %edx + movl %esi, %ecx + shrl %cl, %eax + andl $1, %eax + addl %eax, %edx + movl %edx, %eax + negl %eax + testl %edi, %edi + jne ..L3 + movl %edx, %eax +..L3: + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + cmpl $16415, %esi + jge ..B1.17 +..B1.12: + movl %esi, %ecx + lea 2147483647(%edi), %edx + negl %ecx + movl %edx, 4(%esp) + addl $30, %ecx + movl 12(%ebp), %edx + movl %edx, %eax + shrl %cl, %eax + cmpl $16414, %esi + jge ..B1.14 +..B1.13: + andl $1, %edx + addl %eax, %edx + movl $0, %eax + adcl $0, %eax + jmp ..B1.15 +..B1.14: + movl 8(%ebp), %edx + shrl $31, %edx + addl %eax, %edx + movl $0, %eax + adcl $0, %eax +..B1.15: + movl %edx, %ecx + subl 4(%esp), %ecx + movl %ecx, 16(%esp) + movl $0, %ecx + sbbl %ecx, %eax + jb ..B1.16 +..B1.28: + movl 16(%esp), %ecx + orl %eax, %ecx + jne ..B1.17 +..B1.16: + movl %edx, %eax + negl %eax + testl %edi, %edi + jne ..L4 + movl %edx, %eax +..L4: + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + fldl _infs@GOTOFF(%ebx) + cmpl $32767, %esi + fmull _zeros@GOTOFF(%ebx) + fstpl 8(%esp) + jne ..B1.20 +..B1.18: + cmpl $-2147483648, 12(%ebp) + jne ..B1.25 +..B1.19: + cmpl $0, 8(%ebp) + jne ..B1.25 +..B1.20: + fnstcw 2(%esp) +..B1.21: + movzwl 2(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.25 +..B1.22: + orl $-64768, %edx + movw %dx, (%esp) +..B1.23: + fldcw (%esp) +..B1.24: + fldcw 2(%esp) +..B1.25: + movl $-2147483648, %eax + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type lroundl,@function + .size lroundl,.-lroundl + .data +# -- End lroundl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/modf_wmt.S b/external/sgx_libm/ia32/modf_wmt.S new file mode 100644 index 0000000000..ca77aede89 --- /dev/null +++ b/external/sgx_libm/ia32/modf_wmt.S @@ -0,0 +1,150 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "modf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin modf + .text + .align 16,0x90 + .globl modf +modf: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movsd %xmm0, 16(%esp) + movapd %xmm0, %xmm1 + movq (%ebx), %xmm2 + movq 32(%ebx), %xmm5 + movl 136(%esp), %ecx + movdqa %xmm1, %xmm0 + psrlq $52, %xmm1 + pand %xmm0, %xmm5 + movq 16(%ebx), %xmm3 + movd %xmm1, %eax + andl $2047, %eax + subl $1023, %eax + js .L_2TAG_PACKET_0.0.2 + cmpl $52, %eax + jae .L_2TAG_PACKET_1.0.2 + pand %xmm3, %xmm1 + movdqa %xmm0, %xmm4 + psubd %xmm1, %xmm2 + psrlq %xmm2, %xmm4 + psllq %xmm2, %xmm4 + movq %xmm4, (%ecx) + subsd %xmm4, %xmm0 + por %xmm5, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_0.0.2: + movq %xmm5, (%ecx) + fldl 16(%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + ucomisd %xmm0, %xmm0 + jp .L_2TAG_PACKET_3.0.2 + movq %xmm0, (%ecx) + movq %xmm5, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_3.0.2: + mulsd %xmm0, %xmm0 + movq %xmm0, (%ecx) + movq %xmm0, (%esp) + fldl (%esp) +.L_2TAG_PACKET_2.0.2: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type modf,@function + .size modf,.-modf + .data +# -- End modf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1075 + .long 0 + .long 1075 + .long 0 + .long 2047 + .long 0 + .long 2047 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .type static_const_table,@object + .size static_const_table,48 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/modff.S b/external/sgx_libm/ia32/modff.S new file mode 100644 index 0000000000..6cef6fb071 --- /dev/null +++ b/external/sgx_libm/ia32/modff.S @@ -0,0 +1,132 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "modff.c" + .text +..TXTST0: +# -- Begin modff + .text + .align 16,0x90 + .globl modff +modff: +# parameter 1: 12 + %esp +# parameter 2: 16 + %esp +..B1.1: +..L1: + + pushl %ebx + pushl %ebp + movl 12(%esp), %eax + movl %eax, %ecx + andl $2147483647, %ecx + movl 16(%esp), %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea -1065353216(%ecx), %ebp + cmpl $192937984, %ebp + jae ..B1.6 +..B1.2: + shrl $23, %ecx + movl $-1, %ebp + negl %ecx + addl $22, %ecx + shll %cl, %ebp + movl %ebp, %ecx + andl %eax, %ebp + notl %ecx + movl %ebp, (%edx) + testl %ecx, %eax + je ..B1.4 +..B1.3: + flds 12(%esp) + fsubs (%edx) + popl %ebp + popl %ebx + ret +..B1.4: + shrl $31, %eax + flds _zeros@GOTOFF(%ebx,%eax,4) +..B1.5: + popl %ebp + popl %ebx + ret +..B1.6: + movl %eax, %ebp + shrl $31, %ebp + cmpl $2139095040, %ecx + ja ..B1.11 +..B1.7: + cmpl $1065353216, %ecx + jbe ..B1.9 +..B1.8: + flds _zeros@GOTOFF(%ebx,%ebp,4) + movl %eax, (%edx) + popl %ebp + popl %ebx + ret +..B1.9: + flds 12(%esp) + movl _zeros@GOTOFF(%ebx,%ebp,4), %eax + movl %eax, (%edx) +..B1.10: + popl %ebp + popl %ebx + ret +..B1.11: + flds 12(%esp) + fadd %st(0), %st + fsts (%edx) + popl %ebp + popl %ebx + ret + .align 16,0x90 + .type modff,@function + .size modff,.-modff + .data +# -- End modff + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/modfl.S b/external/sgx_libm/ia32/modfl.S new file mode 100644 index 0000000000..fff4efcbc1 --- /dev/null +++ b/external/sgx_libm/ia32/modfl.S @@ -0,0 +1,263 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "modfl.c" + .text +..TXTST0: +# -- Begin modfl + .text + .align 16,0x90 + .globl modfl +modfl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %ebx + subl $24, %esp + movl 20(%ebp), %edx +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $16446, %ecx + jge ..B1.21 +..B1.4: + cmpl $16383, %ecx + jl ..B1.16 +..B1.5: + fldt 8(%ebp) + cmpl $16415, %ecx + fstpt (%esp) + jge ..B1.7 +..B1.6: + negl %ecx + movl $-1, %ebx + addl $30, %ecx + shll %cl, %ebx + movl %ebx, %ecx + notl %ecx + movl 12(%ebp), %esi + andl %esi, %ecx + andl %ebx, %esi + xorl %ebx, %ebx + orl 8(%ebp), %ecx + movl %esi, 12(%ebp) + jmp ..B1.8 +..B1.7: + negl %ecx + movl $-1, %ebx + addl $30, %ecx + shll %cl, %ebx + movl %ebx, %ecx + notl %ecx + movl 8(%ebp), %esi + andl %esi, %ecx + andl %esi, %ebx +..B1.8: + movl %ebx, 8(%ebp) + testl %ecx, %ecx + je ..B1.14 +..B1.9: + movzwl 14(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.23 +..B1.10: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.11: + fldcw 12(%esp) +..B1.12: + fldt 8(%ebp) + fstpt (%edx) + fldt (%edx) + fldt (%esp) + fsubp %st, %st(1) + fstpt (%esp) +..B1.13: + fldcw 14(%esp) + jmp ..B1.15 +..B1.14: + fldt 8(%ebp) + fstpt (%edx) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _zeros@GOTOFF(%eax,%edx,8) + fstpt (%esp) +..B1.15: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + testl %ecx, %ecx + jne ..B1.20 +..B1.17: + cmpl $0, 12(%ebp) + jne ..B1.19 +..B1.18: + cmpl $0, 8(%ebp) + je ..B1.20 +..B1.19: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 16(%esp) +..B1.20: + movzbl 17(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + fldl _zeros@GOTOFF(%eax,%ecx,8) + fstpt (%edx) + fldt 8(%ebp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.21: + cmpl $32767, %ecx + je ..B1.24 +..B1.22: + fldt 8(%ebp) + fstpt (%edx) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _zeros@GOTOFF(%eax,%edx,8) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + fldt 8(%ebp) + fstpt (%edx) + fldt (%edx) + fldt (%esp) + fsubp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.24: + cmpl $-2147483648, 12(%ebp) + jne ..B1.26 +..B1.25: + cmpl $0, 8(%ebp) + je ..B1.22 +..B1.26: + movzwl 14(%esp), %ebx + movl %ebx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.32 +..B1.27: + orl $-64768, %ebx + movw %bx, 12(%esp) +..B1.28: + fldcw 12(%esp) +..B1.29: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) + fldt (%esp) + fstpt (%edx) +..B1.30: + fldcw 14(%esp) +..B1.31: + fldt (%esp) + addl $24, %esp + popl %ebx + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) + fldt (%esp) + fstpt (%edx) + jmp ..B1.31 + .align 16,0x90 + .type modfl,@function + .size modfl,.-modfl + .data +# -- End modfl + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nan.S b/external/sgx_libm/ia32/nan.S new file mode 100644 index 0000000000..a112ca9b8a --- /dev/null +++ b/external/sgx_libm/ia32/nan.S @@ -0,0 +1,120 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nan.c" + .text +..TXTST0: +# -- Begin nanf + .text + .align 16,0x90 + .globl nanf +nanf: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + subl $24, %esp + pushl 28(%esp) + call __libm_conv_strtoull +..B1.2: + andl $4194303, %eax + orl $2143289344, %eax + movl %eax, 16(%esp) + flds 16(%esp) + addl $28, %esp + ret + .align 16,0x90 + .type nanf,@function + .size nanf,.-nanf + .data +# -- End nanf + .text +# -- Begin nan + .text + .align 16,0x90 + .globl nan +nan: +# parameter 1: 32 + %esp +..B2.1: +..L2: + + subl $24, %esp + pushl 28(%esp) + call __libm_conv_strtoull +..B2.2: + andl $524287, %edx + orl $2146959360, %edx + movl %eax, 16(%esp) + movl %edx, 20(%esp) + fldl 16(%esp) + addl $28, %esp + ret + .align 16,0x90 + .type nan,@function + .size nan,.-nan + .data +# -- End nan + .text +# -- Begin nanl + .text + .align 16,0x90 + .globl nanl +nanl: +# parameter 1: 32 + %esp +..B3.1: +..L3: + + subl $24, %esp + pushl 28(%esp) + call __libm_conv_strtoull +..B3.2: + movl %eax, 16(%esp) + orl $-1073741824, %edx + movl $32767, %eax + movl %edx, 20(%esp) + movw %ax, 24(%esp) + fldt 16(%esp) + addl $28, %esp + ret + .align 16,0x90 + .type nanl,@function + .size nanl,.-nanl + .data +# -- End nanl + .data + .hidden __libm_conv_strtoull + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nearbyint_wmt.S b/external/sgx_libm/ia32/nearbyint_wmt.S new file mode 100644 index 0000000000..19391794e1 --- /dev/null +++ b/external/sgx_libm/ia32/nearbyint_wmt.S @@ -0,0 +1,295 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nearbyint_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin nearbyint + .text + .align 16,0x90 + .globl nearbyint +nearbyint: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + pextrw $3, %xmm0, %ecx + movl $32752, %eax + andl %ecx, %eax + cmpl $17200, %eax + jge .L_2TAG_PACKET_0.0.2 + fnstcw 8(%esp) + subl $16368, %eax + jl .L_2TAG_PACKET_1.0.2 + movzwl 8(%esp), %edx + andl $3072, %edx + jne .L_2TAG_PACKET_2.0.2 + movq (%ebx), %xmm1 + movq 16(%ebx), %xmm2 + pand %xmm0, %xmm1 + movq 32(%ebx), %xmm4 + movq 32(%ebx), %xmm3 + psubq 48(%ebx), %xmm1 + pand %xmm0, %xmm2 + psrlq $52, %xmm1 + movapd %xmm0, %xmm5 + psllq %xmm1, %xmm0 + por 48(%ebx), %xmm2 + pand %xmm0, %xmm4 + pand 64(%ebx), %xmm0 + psrlq %xmm1, %xmm3 + por 80(%ebx), %xmm0 + por 48(%ebx), %xmm4 + pandn %xmm5, %xmm3 + cmpeqsd 96(%ebx), %xmm0 + cmpnlesd 96(%ebx), %xmm4 + por %xmm4, %xmm0 + pand %xmm2, %xmm0 + addsd %xmm3, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: + cmpl $3072, %edx + je .L_2TAG_PACKET_4.0.2 + testl $1024, %edx + je .L_2TAG_PACKET_5.0.2 + movq (%ebx), %xmm1 + pand %xmm0, %xmm1 + xorpd %xmm2, %xmm2 + movq 32(%ebx), %xmm3 + psubq 48(%ebx), %xmm1 + movapd %xmm0, %xmm5 + xorpd %xmm4, %xmm4 + psrlq $52, %xmm1 + cmpnlesd %xmm0, %xmm2 + psllq %xmm1, %xmm0 + pand 32(%ebx), %xmm0 + pcmpeqd %xmm4, %xmm0 + psrlq %xmm1, %xmm3 + pshufd $1, %xmm0, %xmm4 + pandn %xmm5, %xmm3 + pand %xmm4, %xmm0 + pandn %xmm2, %xmm0 + pand 48(%ebx), %xmm0 + subsd %xmm0, %xmm3 + movq %xmm3, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_5.0.2: + movq (%ebx), %xmm1 + pand %xmm0, %xmm1 + xorpd %xmm2, %xmm2 + movq 32(%ebx), %xmm3 + psubq 48(%ebx), %xmm1 + movapd %xmm0, %xmm5 + xorpd %xmm4, %xmm4 + psrlq $52, %xmm1 + cmplesd %xmm0, %xmm2 + psllq %xmm1, %xmm0 + pand 32(%ebx), %xmm0 + pcmpeqd %xmm4, %xmm0 + psrlq %xmm1, %xmm3 + pshufd $1, %xmm0, %xmm4 + pandn %xmm5, %xmm3 + pand %xmm4, %xmm0 + pandn %xmm2, %xmm0 + pand 48(%ebx), %xmm0 + addsd %xmm3, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_4.0.2: + movq (%ebx), %xmm1 + pand %xmm0, %xmm1 + movq 32(%ebx), %xmm3 + psubq 48(%ebx), %xmm1 + psrlq $52, %xmm1 + psrlq %xmm1, %xmm3 + pandn %xmm0, %xmm3 + movq %xmm3, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_1.0.2: + movzwl 8(%esp), %edx + andl $3072, %edx + jne .L_2TAG_PACKET_6.0.2 + andpd 112(%ebx), %xmm0 + addl $16, %eax + shrl $14, %ecx + shrl $31, %eax + ucomisd 128(%ebx), %xmm0 + je .L_2TAG_PACKET_7.0.2 + andl $2, %ecx + orl %ecx, %eax + flds 144(%ebx,%eax,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_7.0.2: + shrl $15, %ecx + flds 160(%ebx,%ecx,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_6.0.2: + cmpl $3072, %edx + je .L_2TAG_PACKET_8.0.2 + testl $1024, %edx + je .L_2TAG_PACKET_9.0.2 + pxor %xmm1, %xmm1 + cmpnlesd %xmm0, %xmm1 + movd %xmm1, %eax + shrl $15, %ecx + subl %eax, %ecx + flds 176(%ebx,%ecx,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_9.0.2: + pxor %xmm1, %xmm1 + cmpnltsd %xmm0, %xmm1 + movd %xmm1, %eax + shrl $15, %ecx + subl %ecx, %eax + flds 200(%ebx,%eax,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_8.0.2: + shrl $15, %ecx + flds 208(%ebx,%ecx,4) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + movq %xmm0, (%esp) + fldl (%esp) + fldz + faddp +.L_2TAG_PACKET_3.0.2: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type nearbyint,@function + .size nearbyint,.-nearbyint + .data +# -- End nearbyint + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .long 4294967295 + .long 2097151 + .long 4294967295 + .long 2097151 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 0 + .long 1073217536 + .long 0 + .long 1073217536 + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .long 1065353216 + .long 0 + .long 3212836864 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 3212836864 + .long 0 + .long 2147483648 + .long 0 + .long 1065353216 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,224 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nearbyintf_gen.S b/external/sgx_libm/ia32/nearbyintf_gen.S new file mode 100644 index 0000000000..f36b9a94f0 --- /dev/null +++ b/external/sgx_libm/ia32/nearbyintf_gen.S @@ -0,0 +1,375 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nearbyintf_gen.c" + .text +..TXTST0: +# -- Begin nearbyintf + .text + .align 16,0x90 + .globl nearbyintf +nearbyintf: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + pushl %ebp + subl $16, %esp +..B1.2: + fnstcw 4(%esp) +..B1.3: + movzwl 34(%esp), %eax + andl $32640, %eax + shrl $7, %eax + cmpl $150, %eax + jge ..B1.40 +..B1.4: + movzwl 4(%esp), %ebx + andl $3072, %ebx + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + cmpl $1024, %ebx + je ..B1.31 +..B1.5: + cmpl $2048, %ebx + jne ..B1.15 +..B1.6: + cmpl $127, %eax + jl ..B1.11 +..B1.7: + negl %eax + movl $8388607, %edx + addl $22, %eax + movl 32(%esp), %ebx + movl %ebx, %ebp + movl %eax, %ecx + andl $8388607, %ebp + shll %cl, %edx + andl $-8388608, %ebx + andl %ebp, %edx + orl %edx, %ebx + movl %ebx, %eax + andl $8388607, %eax + movl %ebx, 32(%esp) + testl $-2147483648, %ebx + jne ..B1.10 +..B1.8: + cmpl %ebp, %eax + je ..B1.10 +..B1.9: + fld1 + fadds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.10: + flds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.11: + testl %eax, %eax + jne ..B1.14 +..B1.12: + testl $8388607, 32(%esp) + jne ..B1.14 +..B1.13: + flds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.14: + movzbl 35(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + movl 32(%esp), %eax + movl %eax, (%esp) + flds _pone_nzero@GOTOFF(%edx,%ecx,4) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.15: + cmpl $3072, %ebx + jne ..B1.20 +..B1.16: + cmpl $127, %eax + jl ..B1.18 +..B1.17: + negl %eax + movl $8388607, %edx + addl $22, %eax + movl %eax, %ecx + shll %cl, %edx + movl 32(%esp), %ebx + movl %ebx, %ebp + andl %edx, %ebx + andl $-8388608, %ebp + andl $8388607, %ebx + orl %ebx, %ebp + movl %ebp, 32(%esp) + flds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.18: + movzbl 35(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + movl 32(%esp), %eax + movl %eax, (%esp) + flds _zeros@GOTOFF(%edx,%ecx,4) +..B1.19: + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.20: + cmpl $127, %eax + jl ..B1.27 +..B1.21: + movl 32(%esp), %edi + movl %edi, %ebp + andl $8388607, %ebp + lea 10(%eax), %ecx + negl %eax + movl %ebp, %ebx + addl $22, %eax + andl $-8388608, %edi + shll %cl, %ebx + movl %eax, %ecx + movl $8388607, %eax + shll %cl, %eax + andl %eax, %ebp + orl %ebp, %edi + movl %edi, 32(%esp) + testl %ebx, %ebx + jge ..B1.26 +..B1.22: + cmpl $-2147483648, %ebx + jne ..B1.25 +..B1.23: + movzwl 34(%esp), %ecx + movl $1, %eax + shrl $7, %ecx + negl %ecx + addl $22, %ecx + shll %cl, %eax + testl %eax, 32(%esp) + je ..B1.26 +..B1.24: + flds 32(%esp) + movzbl 35(%esp), %eax + andl $128, %eax + shrl $7, %eax + fadds _ones@GOTOFF(%edx,%eax,4) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.25: + flds 32(%esp) + movzbl 35(%esp), %eax + andl $128, %eax + shrl $7, %eax + fadds _ones@GOTOFF(%edx,%eax,4) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.26: + flds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.27: + cmpl $126, %eax + jle ..B1.29 +..B1.28: + movzbl 35(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _ones@GOTOFF(%edx,%eax,4) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.29: + je ..B1.41 +..B1.30: + movzbl 35(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + movl 32(%esp), %eax + movl %eax, (%esp) + flds _zeros@GOTOFF(%edx,%ecx,4) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.31: + cmpl $127, %eax + jl ..B1.36 +..B1.32: + negl %eax + movl $8388607, %edi + addl $22, %eax + movl 32(%esp), %ebx + movl %ebx, %ebp + movl %eax, %ecx + andl $8388607, %ebp + shll %cl, %edi + andl $-8388608, %ebx + andl %ebp, %edi + orl %edi, %ebx + movl %ebx, %eax + andl $8388607, %eax + movl %ebx, 32(%esp) + testl $-2147483648, %ebx + je ..B1.35 +..B1.33: + cmpl %ebp, %eax + je ..B1.35 +..B1.34: + flds 32(%esp) + fadds .L_2il0floatpacket.0@GOTOFF(%edx) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.35: + flds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.36: + testl %eax, %eax + jne ..B1.39 +..B1.37: + testl $8388607, 32(%esp) + jne ..B1.39 +..B1.38: + flds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.39: + movzbl 35(%esp), %ecx + andl $128, %ecx + shrl $7, %ecx + movl 32(%esp), %eax + movl %eax, (%esp) + flds _pzero_none@GOTOFF(%edx,%ecx,4) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.40: + flds 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.41: + testl $8388607, 32(%esp) + jg ..B1.28 + jmp ..B1.30 + .align 16,0x90 + .type nearbyintf,@function + .size nearbyintf,.-nearbyintf + .data +# -- End nearbyintf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +_pone_nzero: + .long 1065353216 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_pzero_none: + .long 0 + .long 3212836864 + .type _pzero_none,@object + .size _pzero_none,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nearbyintl.S b/external/sgx_libm/ia32/nearbyintl.S new file mode 100644 index 0000000000..d1e1813adf --- /dev/null +++ b/external/sgx_libm/ia32/nearbyintl.S @@ -0,0 +1,663 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nearbyintl.c" + .text +..TXTST0: +# -- Begin nearbyintl + .text + .align 16,0x90 + .globl nearbyintl +nearbyintl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %ebx + andl $32767, %ebx + movzwl 14(%esp), %edx + cmpl $16446, %ebx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + jge ..B1.97 +..B1.4: + movl %edx, %esi + andl $3072, %esi + cmpl $1024, %esi + je ..B1.78 +..B1.5: + cmpl $2048, %esi + jne ..B1.25 +..B1.6: + cmpl $16383, %ebx + jl ..B1.19 +..B1.7: + cmpl $16415, %ebx + jl ..B1.9 +..B1.8: + negl %ebx + movl $-1, %esi + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %esi + movl 8(%ebp), %edi + andl %edi, %esi + movl %esi, 8(%ebp) + xorl %edi, %esi + jmp ..B1.10 +..B1.9: + negl %ebx + movl $-1, %esi + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %esi + movl 12(%ebp), %edi + andl %edi, %esi + movl %esi, 12(%ebp) + xorl %edi, %esi + orl 8(%ebp), %esi + movl $0, 8(%ebp) +..B1.10: + movzbl 17(%ebp), %ecx + testl $128, %ecx + jne ..B1.18 +..B1.11: + testl %esi, %esi + je ..B1.18 +..B1.12: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.103 +..B1.13: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.14: + fldcw 12(%esp) +..B1.15: + fldt 8(%ebp) + faddl _ones@GOTOFF(%eax) + fstpt (%esp) +..B1.16: + fldcw 14(%esp) +..B1.17: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + fldt 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + testl %ebx, %ebx + jne ..B1.24 +..B1.20: + cmpl $0, 12(%ebp) + jne ..B1.23 +..B1.21: + cmpl $0, 8(%ebp) + jne ..B1.23 +..B1.22: + fldt 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 16(%esp) +..B1.24: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _pone_nzero@GOTOFF(%eax,%edx,8) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + cmpl $3072, %esi + jne ..B1.36 +..B1.26: + cmpl $16383, %ebx + jl ..B1.31 +..B1.27: + cmpl $16415, %ebx + jl ..B1.29 +..B1.28: + negl %ebx + movl $-1, %eax + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %eax + andl 8(%ebp), %eax + jmp ..B1.30 +..B1.29: + negl %ebx + movl $-1, %eax + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %eax + andl %eax, 12(%ebp) + xorl %eax, %eax +..B1.30: + movl %eax, 8(%ebp) + fldt 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + testl %ebx, %ebx + jne ..B1.35 +..B1.32: + cmpl $0, 12(%ebp) + jne ..B1.34 +..B1.33: + cmpl $0, 8(%ebp) + je ..B1.35 +..B1.34: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 16(%esp) +..B1.35: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _zeros@GOTOFF(%eax,%edx,8) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.36: + cmpl $16383, %ebx + jl ..B1.70 +..B1.37: + movl 8(%ebp), %edi + cmpl $16414, %ebx + jl ..B1.39 +..B1.38: + movl %edi, %esi + lea 2(%ebx), %ecx + shll %cl, %esi + movl %esi, 4(%esp) + movl $0, (%esp) + jmp ..B1.40 +..B1.39: + movl 12(%ebp), %esi + lea 2(%ebx), %ecx + shll %cl, %esi + movl %esi, 4(%esp) + movl %edi, (%esp) +..B1.40: + cmpl $16415, %ebx + jl ..B1.42 +..B1.41: + movl %ebx, %ecx + movl $-1, %esi + negl %ecx + addl $30, %ecx + shll %cl, %esi + andl %esi, %edi + movl %edi, 8(%ebp) + jmp ..B1.43 +..B1.42: + movl %ebx, %ecx + movl $-1, %esi + negl %ecx + xorl %edi, %edi + addl $30, %ecx + shll %cl, %esi + movl %edi, 8(%ebp) + andl %esi, 12(%ebp) +..B1.43: + cmpl $0, 4(%esp) + jge ..B1.69 +..B1.44: + movl 4(%esp), %esi + andl $2147483647, %esi + orl (%esp), %esi + je ..B1.52 +..B1.45: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.104 +..B1.46: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.47: + fldcw 12(%esp) +..B1.48: + movl $1, %ecx +..B1.49: + fldt 8(%ebp) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + testl %ecx, %ecx + faddl _ones@GOTOFF(%eax,%edx,8) + fstpt (%esp) + je ..B1.51 +..B1.50: + fldcw 14(%esp) +..B1.51: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.52: + cmpl $16415, %ebx + jl ..B1.61 +..B1.53: + negl %ebx + movl $1, %esi + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %esi + testl %esi, %edi + je ..B1.69 +..B1.54: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.105 +..B1.55: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.56: + fldcw 12(%esp) +..B1.57: + movl $1, %ecx +..B1.58: + fldt 8(%ebp) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + testl %ecx, %ecx + faddl _ones@GOTOFF(%eax,%edx,8) + fstpt (%esp) + je ..B1.60 +..B1.59: + fldcw 14(%esp) +..B1.60: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.61: + negl %ebx + movl $1, %esi + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %esi + testl %esi, 12(%ebp) + je ..B1.69 +..B1.62: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.106 +..B1.63: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.64: + fldcw 12(%esp) +..B1.65: + movl $1, %ecx +..B1.66: + fldt 8(%ebp) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + testl %ecx, %ecx + faddl _ones@GOTOFF(%eax,%edx,8) + fstpt (%esp) + je ..B1.68 +..B1.67: + fldcw 14(%esp) +..B1.68: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.69: + fldt 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.70: + cmpl $16382, %ebx + jle ..B1.72 +..B1.71: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _ones@GOTOFF(%eax,%edx,8) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.72: + je ..B1.107 +..B1.73: + testl %ebx, %ebx + jne ..B1.77 +..B1.74: + cmpl $0, 12(%ebp) + jne ..B1.76 +..B1.75: + cmpl $0, 8(%ebp) + je ..B1.77 +..B1.76: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 16(%esp) +..B1.77: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _zeros@GOTOFF(%eax,%edx,8) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.78: + cmpl $16383, %ebx + jl ..B1.91 +..B1.79: + cmpl $16415, %ebx + jl ..B1.81 +..B1.80: + negl %ebx + movl $-1, %edi + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %edi + movl 8(%ebp), %esi + andl %esi, %edi + movl %edi, 8(%ebp) + xorl %edi, %esi + jmp ..B1.82 +..B1.81: + negl %ebx + movl $-1, %edi + addl $30, %ebx + movl %ebx, %ecx + shll %cl, %edi + movl 12(%ebp), %esi + andl %esi, %edi + xorl %edi, %esi + orl 8(%ebp), %esi + movl %edi, 12(%ebp) + movl $0, 8(%ebp) +..B1.82: + movzbl 17(%ebp), %ecx + testl $128, %ecx + je ..B1.90 +..B1.83: + testl %esi, %esi + je ..B1.90 +..B1.84: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.110 +..B1.85: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.86: + fldcw 12(%esp) +..B1.87: + fldt 8(%ebp) + faddl 8+_ones@GOTOFF(%eax) + fstpt (%esp) +..B1.88: + fldcw 14(%esp) +..B1.89: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.90: + fldt 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.91: + testl %ebx, %ebx + jne ..B1.96 +..B1.92: + cmpl $0, 12(%ebp) + jne ..B1.95 +..B1.93: + cmpl $0, 8(%ebp) + jne ..B1.95 +..B1.94: + fldt 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.95: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 16(%esp) +..B1.96: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _pzero_none@GOTOFF(%eax,%edx,8) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.97: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.111 +..B1.98: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.99: + fldcw 12(%esp) +..B1.100: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) +..B1.101: + fldcw 14(%esp) +..B1.102: + fldt (%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.103: + fldt 8(%ebp) + faddl _ones@GOTOFF(%eax) + fstpt (%esp) + jmp ..B1.17 +..B1.104: + xorl %ecx, %ecx + jmp ..B1.49 +..B1.105: + xorl %ecx, %ecx + jmp ..B1.58 +..B1.106: + xorl %ecx, %ecx + jmp ..B1.66 +..B1.107: + movl 12(%ebp), %edx + cmpl $-2147483648, %edx + ja ..B1.71 +..B1.108: + jne ..B1.77 +..B1.109: + cmpl $0, 8(%ebp) + ja ..B1.71 + jmp ..B1.77 +..B1.110: + fldt 8(%ebp) + faddl 8+_ones@GOTOFF(%eax) + fstpt (%esp) + jmp ..B1.89 +..B1.111: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) + jmp ..B1.102 + .align 16,0x90 + .type nearbyintl,@function + .size nearbyintl,.-nearbyintl + .data +# -- End nearbyintl + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_pone_nzero: + .long 0 + .long 1072693248 + .long 0 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_pzero_none: + .long 0 + .long 0 + .long 0 + .long 3220176896 + .type _pzero_none,@object + .size _pzero_none,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nextafter_wmt.S b/external/sgx_libm/ia32/nextafter_wmt.S new file mode 100644 index 0000000000..ecc9282675 --- /dev/null +++ b/external/sgx_libm/ia32/nextafter_wmt.S @@ -0,0 +1,210 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nextafter_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin nextafter + .text + .align 16,0x90 + .globl nextafter +nextafter: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd 120(%esp), %xmm1 + ucomisd %xmm1, %xmm0 + jp .L_2TAG_PACKET_0.0.3 + je .L_2TAG_PACKET_1.0.3 + cmpltsd %xmm0, %xmm1 + comisd (%ebx), %xmm0 + je .L_2TAG_PACKET_2.0.3 + xorpd %xmm0, %xmm1 + paddq 48(%ebx), %xmm0 + psrlq $63, %xmm1 + psllq $1, %xmm1 + psubq %xmm1, %xmm0 + pextrw $3, %xmm0, %eax + andl $32767, %eax + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_3.0.3 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_0.0.3: + movsd %xmm1, (%esp) + fldl (%esp) + movsd %xmm0, (%esp) + faddl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_1.0.3: + movsd %xmm1, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_2.0.3: + movsd 16(%ebx), %xmm0 + andpd 32(%ebx), %xmm1 + orpd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_3.0.3: + testl %eax, %eax + jns .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_5.0.3: + movsd 80(%ebx), %xmm1 + mulsd %xmm1, %xmm1 + movsd %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 120(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $268, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_6.0.3: + movsd 64(%ebx), %xmm1 + mulsd %xmm1, %xmm1 + movsd %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 120(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $154, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_4.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type nextafter,@function + .size nextafter,.-nextafter + .data +# -- End nextafter + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 1 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 1 + .long 0 + .long 0 + .long 2121269248 + .long 1 + .long 0 + .long 0 + .long 24117248 + .long 1 + .long 0 + .type static_const_table,@object + .size static_const_table,96 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nextafterf_wmt.S b/external/sgx_libm/ia32/nextafterf_wmt.S new file mode 100644 index 0000000000..bdcd59ba9d --- /dev/null +++ b/external/sgx_libm/ia32/nextafterf_wmt.S @@ -0,0 +1,200 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nextafterf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin nextafterf + .text + .align 16,0x90 + .globl nextafterf +nextafterf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 36(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movss 116(%esp), %xmm1 + ucomiss %xmm1, %xmm0 + movl 112(%esp), %eax + jp .L_2TAG_PACKET_0.0.3 + movl $2147483647, %edx + je .L_2TAG_PACKET_1.0.3 + andl %eax, %edx + movl 116(%esp), %ecx + movl 112(%esp), %eax + je .L_2TAG_PACKET_2.0.3 + movl 116(%esp), %edx + subl %eax, %ecx + xorl %edx, %eax + orl %eax, %ecx + movl 112(%esp), %eax + sarl $31, %ecx + orl $1, %ecx + movl $2147483647, %edx + addl %ecx, %eax + andl %eax, %edx + subl $8388608, %edx + cmpl $2130706432, %edx + movl %eax, (%esp) + flds (%esp) + jae .L_2TAG_PACKET_3.0.3 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_0.0.3: + movss %xmm1, (%esp) + flds (%esp) + movss %xmm0, (%esp) + fadds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_1.0.3: + movss %xmm1, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_2.0.3: + movl $1, %eax + andl $-2147483648, %ecx + orl %ecx, %eax + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_3.0.3: + fstp %st(0) + testl %edx, %edx + jns .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_5.0.3: + movss (%ebx), %xmm1 + mulss %xmm1, %xmm1 + movl %eax, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 116(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $269, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_6.0.3: + movss 16(%ebx), %xmm1 + mulss %xmm1, %xmm1 + movl %eax, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 116(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl $155, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) +.L_2TAG_PACKET_4.0.3: + movl 36(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type nextafterf,@function + .size nextafterf,.-nextafterf + .data +# -- End nextafterf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 226492416 + .long 226492416 + .long 0 + .long 0 + .long 1904214016 + .long 1904214016 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nextafterl.S b/external/sgx_libm/ia32/nextafterl.S new file mode 100644 index 0000000000..f2a732a4da --- /dev/null +++ b/external/sgx_libm/ia32/nextafterl.S @@ -0,0 +1,371 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nextafterl.c" + .text +..TXTST0: +# -- Begin nextafterl + .text + .align 16,0x90 + .globl nextafterl +nextafterl: +# parameter 1: 48 + %esp +# parameter 2: 60 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + subl $36, %esp +..B1.2: + fnstcw 26(%esp) +..B1.3: + movzwl 56(%esp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.54 +..B1.4: + movzwl 68(%esp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.45 +..B1.5: + fldt 48(%esp) + fldt 60(%esp) + fucom %st(1) + fnstsw %ax + sahf + jp ..B1.6 + je ..B1.56 +..B1.6: + fstp %st(0) + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + testl %ecx, %ecx + jne ..B1.9 +..B1.7: + cmpl $0, 52(%esp) + jne ..B1.9 +..B1.8: + cmpl $0, 48(%esp) + je ..B1.44 +..B1.9: + movzbl 69(%esp), %eax + movzbl 57(%esp), %edi + andl $128, %eax + andl $128, %edi + shrl $7, %eax + shrl $7, %edi + fstpt 12(%esp) + cmpl %edi, %eax + jne ..B1.15 +..B1.10: + cmpl %edx, %ecx + jg ..B1.15 +..B1.11: + jne ..B1.29 +..B1.12: + movl 52(%esp), %eax + movl 64(%esp), %edx + cmpl %edx, %eax + ja ..B1.15 +..B1.13: + jne ..B1.29 +..B1.14: + movl 48(%esp), %eax + cmpl 60(%esp), %eax + jbe ..B1.29 +..B1.15: + movzwl 20(%esp), %ecx + movl %ecx, %edx + movl 12(%esp), %eax + andl $32767, %edx + decl %eax + movl %eax, 12(%esp) + cmpl $-1, %eax + jne ..B1.34 +..B1.16: + movl 16(%esp), %eax + decl %eax + testl %edx, %edx + je ..B1.22 +..B1.17: + cmpl $2147483647, %eax + jne ..B1.21 +..B1.18: + decl %edx + andl $-32768, %ecx + andl $32767, %edx + orl %edx, %ecx + movw %cx, 20(%esp) + testl %edx, %edx + je ..B1.20 +..B1.19: + movl %ecx, %edx + orl $-2147483648, %eax + movl %eax, 16(%esp) + andl $32767, %edx + jmp ..B1.34 +..B1.20: + movl %ecx, %edx + movl %eax, 16(%esp) + andl $32767, %edx + jmp ..B1.34 +..B1.21: + movl %eax, 16(%esp) + jmp ..B1.35 +..B1.22: + movl %eax, 16(%esp) +..B1.23: + movzwl 26(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.24: + orl $-64768, %edx + movw %dx, 24(%esp) +..B1.25: + fldcw 24(%esp) +..B1.26: + fldt _small_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) +..B1.27: + fldcw 26(%esp) +..B1.28: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.29: + movzwl 20(%esp), %eax + movl %eax, %edx + movl 12(%esp), %ecx + andl $32767, %edx + incl %ecx + movl %ecx, 12(%esp) + jne ..B1.33 +..B1.30: + movl $-2147483648, %ecx + testl %edx, %edx + movl 16(%esp), %edi + je ..L3 + movl $0, %ecx +..L3: + incl %edi + cmpl %ecx, %edi + jne ..B1.32 +..B1.31: + incl %edx + andl $-32768, %eax + andl $32767, %edx + orl $-2147483648, %edi + orl %edx, %eax + movl %eax, %edx + movl %edi, 16(%esp) + andl $32767, %edx + movw %ax, 20(%esp) + jmp ..B1.33 +..B1.32: + movl %edi, 16(%esp) +..B1.33: + cmpl $32767, %edx + je ..B1.37 +..B1.34: + testl %edx, %edx + je ..B1.23 +..B1.35: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.36: + fldt _small_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.28 +..B1.37: + movzwl 26(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.38: + orl $-64768, %edx + movw %dx, 24(%esp) +..B1.39: + fldcw 24(%esp) +..B1.40: + fldt _large_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) +..B1.41: + fldcw 26(%esp) +..B1.42: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.43: + fldt _large_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.42 +..B1.44: + fstp %st(0) + movzbl 69(%esp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _smallest_value_80@GOTOFF(%esi,%ecx) + movzwl 8+_smallest_value_80@GOTOFF(%esi,%ecx), %edx + fstpt 12(%esp) + andl $32767, %edx + jmp ..B1.34 +..B1.45: + cmpl $-2147483648, 64(%esp) + jne ..B1.47 +..B1.46: + cmpl $0, 60(%esp) + je ..B1.5 +..B1.47: + movzwl 26(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.53 +..B1.48: + orl $-64768, %edx + movw %dx, 24(%esp) +..B1.49: + fldcw 24(%esp) +..B1.50: + fldt 48(%esp) + fldt 60(%esp) + fmulp %st, %st(1) + fstpt 12(%esp) +..B1.51: + fldcw 26(%esp) +..B1.52: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.53: + fldt 48(%esp) + fldt 60(%esp) + fmulp %st, %st(1) + fstpt 12(%esp) + jmp ..B1.52 +..B1.54: + cmpl $-2147483648, 52(%esp) + jne ..B1.47 +..B1.55: + cmpl $0, 48(%esp) + jne ..B1.47 + jmp ..B1.4 +..B1.56: + fstp %st(1) + addl $36, %esp + popl %edi + popl %esi + ret + .align 16,0x90 + .type nextafterl,@function + .size nextafterl,.-nextafterl + .data +# -- End nextafterl + .section .rodata, "a" + .align 4 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_smallest_value_80: + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .type _smallest_value_80,@object + .size _smallest_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nexttoward_wmt.S b/external/sgx_libm/ia32/nexttoward_wmt.S new file mode 100644 index 0000000000..028c7517c2 --- /dev/null +++ b/external/sgx_libm/ia32/nexttoward_wmt.S @@ -0,0 +1,246 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nexttoward_wmt.c" + .text +..TXTST0: +# -- Begin nexttoward + .text + .align 16,0x90 + .globl nexttoward +nexttoward: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $20, %esp + movzwl 14(%ebp), %eax + andl $32752, %eax + cmpl $32752, %eax + je ..B1.23 +..B1.2: + movzwl 24(%ebp), %ebx + andl $32767, %ebx + cmpl $32767, %ebx + je ..B1.20 +..B1.3: + fldl 8(%ebp) + fldt 16(%ebp) + fucom %st(1) + fnstsw %ax + sahf + jp ..B1.4 + je ..B1.25 +..B1.4: + fstp %st(0) + movl 12(%ebp), %ecx + movl %ecx, %eax + andl $2147483647, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + orl 8(%ebp), %eax + je ..B1.19 +..B1.5: + fstpt 8(%esp) + movzbl 17(%esp), %edi + movzbl 25(%ebp), %esi + andl $128, %edi + andl $128, %esi + shrl $7, %edi + shrl $7, %esi + movl 8(%ebp), %eax + cmpl %edi, %esi + jne ..B1.11 +..B1.6: + movzwl 16(%esp), %esi + andl $32767, %esi + cmpl %ebx, %esi + jg ..B1.11 +..B1.7: + jne ..B1.12 +..B1.8: + movl 12(%esp), %ebx + movl 20(%ebp), %esi + cmpl %esi, %ebx + ja ..B1.11 +..B1.9: + jne ..B1.12 +..B1.10: + movl 8(%esp), %ebx + cmpl 16(%ebp), %ebx + jbe ..B1.12 +..B1.11: + addl $-1, %eax + movl %eax, 8(%esp) + adcl $-1, %ecx + movl %ecx, 12(%esp) + jmp ..B1.13 +..B1.12: + addl $1, %eax + movl %eax, 8(%esp) + adcl $0, %ecx + movl %ecx, 12(%esp) +..B1.13: + movl 12(%esp), %ecx + andl $2147483647, %ecx + lea -1048576(%ecx), %eax + cmpl $2145386496, %eax + jb ..B1.18 +..B1.14: + cmpl $1048576, %ecx + jae ..B1.16 +..B1.15: + fldl _small_value_64@GOTOFF(%edx) + fmul %st(0), %st + fstpl (%esp) + fldl 8(%esp) + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + fldl _large_value_64@GOTOFF(%edx) + fmul %st(0), %st + fstpl (%esp) + fldl 8(%esp) +..B1.17: + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + fldl 8(%esp) + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + fstp %st(0) + movzbl 25(%ebp), %eax + fldl _small_value_64@GOTOFF(%edx) + andl $128, %eax + shrl $7, %eax + fmul %st(0), %st + movl _smallest_value_64@GOTOFF(%edx,%eax,8), %ecx + movl 4+_smallest_value_64@GOTOFF(%edx,%eax,8), %ebx + movl %ecx, 8(%esp) + movl %ebx, 12(%esp) + fstpl (%esp) + jmp ..B1.18 +..B1.20: + cmpl $-2147483648, 20(%ebp) + jne ..B1.22 +..B1.21: + cmpl $0, 16(%ebp) + je ..B1.3 +..B1.22: + fldt 16(%ebp) + fmull 8(%ebp) + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + testl $1048575, 12(%ebp) + jne ..B1.22 +..B1.24: + cmpl $0, 8(%ebp) + jne ..B1.22 + jmp ..B1.2 +..B1.25: + fstp %st(1) + addl $20, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type nexttoward,@function + .size nexttoward,.-nexttoward + .data +# -- End nexttoward + .section .rodata, "a" + .align 4 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nexttowardf_wmt.S b/external/sgx_libm/ia32/nexttowardf_wmt.S new file mode 100644 index 0000000000..43ae5c9911 --- /dev/null +++ b/external/sgx_libm/ia32/nexttowardf_wmt.S @@ -0,0 +1,212 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nexttowardf_wmt.c" + .text +..TXTST0: +# -- Begin nexttowardf + .text + .align 16,0x90 + .globl nexttowardf +nexttowardf: +# parameter 1: 32 + %esp +# parameter 2: 36 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + subl $20, %esp + movzwl 34(%esp), %eax + andl $32640, %eax + cmpl $32640, %eax + je ..B1.23 +..B1.2: + movzwl 44(%esp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.20 +..B1.3: + flds 32(%esp) + fldt 36(%esp) + fucom %st(1) + fnstsw %ax + sahf + jp ..B1.4 + je ..B1.24 +..B1.4: + fstp %st(0) + movl 32(%esp), %eax + testl $2147483647, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + je ..B1.19 +..B1.5: + fstpt (%esp) + movzbl 9(%esp), %edi + movzbl 45(%esp), %ebx + andl $128, %edi + andl $128, %ebx + shrl $7, %edi + shrl $7, %ebx + cmpl %edi, %ebx + jne ..B1.11 +..B1.6: + movzwl 8(%esp), %ebx + andl $32767, %ebx + cmpl %ecx, %ebx + jg ..B1.11 +..B1.7: + jne ..B1.12 +..B1.8: + movl 4(%esp), %ecx + movl 40(%esp), %ebx + cmpl %ebx, %ecx + ja ..B1.11 +..B1.9: + jne ..B1.12 +..B1.10: + movl (%esp), %ecx + cmpl 36(%esp), %ecx + jbe ..B1.12 +..B1.11: + decl %eax + movl %eax, (%esp) + jmp ..B1.13 +..B1.12: + incl %eax + movl %eax, (%esp) +..B1.13: + andl $2147483647, %eax + lea -8388608(%eax), %ecx + cmpl $2130706432, %ecx + jb ..B1.18 +..B1.14: + cmpl $8388608, %eax + jae ..B1.16 +..B1.15: + flds .L_2il0floatpacket.0@GOTOFF(%edx) + fsts 12(%esp) + flds 12(%esp) + fmulp %st, %st(1) + fstps 12(%esp) + flds (%esp) + addl $20, %esp + popl %ebx + popl %edi + ret +..B1.16: + flds .L_2il0floatpacket.1@GOTOFF(%edx) + fsts 12(%esp) + flds 12(%esp) + fmulp %st, %st(1) + fstps 12(%esp) + flds (%esp) +..B1.17: + addl $20, %esp + popl %ebx + popl %edi + ret +..B1.18: + flds (%esp) + addl $20, %esp + popl %ebx + popl %edi + ret +..B1.19: + fstp %st(0) + movzbl 45(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds .L_2il0floatpacket.0@GOTOFF(%edx) + fsts 12(%esp) + flds 12(%esp) + fmulp %st, %st(1) + movl _smallest_value_32@GOTOFF(%edx,%eax,4), %ecx + movl %ecx, (%esp) + fstps 12(%esp) + jmp ..B1.18 +..B1.20: + cmpl $-2147483648, 40(%esp) + jne ..B1.22 +..B1.21: + cmpl $0, 36(%esp) + je ..B1.3 +..B1.22: + fldt 36(%esp) + fmuls 32(%esp) + addl $20, %esp + popl %ebx + popl %edi + ret +..B1.23: + testl $8388607, 32(%esp) + jne ..B1.22 + jmp ..B1.2 +..B1.24: + fstp %st(1) + addl $20, %esp + popl %ebx + popl %edi + ret + .align 16,0x90 + .type nexttowardf,@function + .size nexttowardf,.-nexttowardf + .data +# -- End nexttowardf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x0d800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_smallest_value_32: + .long 1 + .long 2147483649 + .type _smallest_value_32,@object + .size _smallest_value_32,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/nexttowardl.S b/external/sgx_libm/ia32/nexttowardl.S new file mode 100644 index 0000000000..f59a42795b --- /dev/null +++ b/external/sgx_libm/ia32/nexttowardl.S @@ -0,0 +1,371 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nexttowardl.c" + .text +..TXTST0: +# -- Begin nexttowardl + .text + .align 16,0x90 + .globl nexttowardl +nexttowardl: +# parameter 1: 48 + %esp +# parameter 2: 60 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + subl $36, %esp +..B1.2: + fnstcw 26(%esp) +..B1.3: + movzwl 56(%esp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.54 +..B1.4: + movzwl 68(%esp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.45 +..B1.5: + fldt 48(%esp) + fldt 60(%esp) + fucom %st(1) + fnstsw %ax + sahf + jp ..B1.6 + je ..B1.56 +..B1.6: + fstp %st(0) + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + testl %ecx, %ecx + jne ..B1.9 +..B1.7: + cmpl $0, 52(%esp) + jne ..B1.9 +..B1.8: + cmpl $0, 48(%esp) + je ..B1.44 +..B1.9: + movzbl 69(%esp), %eax + movzbl 57(%esp), %edi + andl $128, %eax + andl $128, %edi + shrl $7, %eax + shrl $7, %edi + fstpt 12(%esp) + cmpl %edi, %eax + jne ..B1.15 +..B1.10: + cmpl %edx, %ecx + jg ..B1.15 +..B1.11: + jne ..B1.29 +..B1.12: + movl 52(%esp), %eax + movl 64(%esp), %edx + cmpl %edx, %eax + ja ..B1.15 +..B1.13: + jne ..B1.29 +..B1.14: + movl 48(%esp), %eax + cmpl 60(%esp), %eax + jbe ..B1.29 +..B1.15: + movzwl 20(%esp), %ecx + movl %ecx, %edx + movl 12(%esp), %eax + andl $32767, %edx + decl %eax + movl %eax, 12(%esp) + cmpl $-1, %eax + jne ..B1.34 +..B1.16: + movl 16(%esp), %eax + decl %eax + testl %edx, %edx + je ..B1.22 +..B1.17: + cmpl $2147483647, %eax + jne ..B1.21 +..B1.18: + decl %edx + andl $-32768, %ecx + andl $32767, %edx + orl %edx, %ecx + movw %cx, 20(%esp) + testl %edx, %edx + je ..B1.20 +..B1.19: + movl %ecx, %edx + orl $-2147483648, %eax + movl %eax, 16(%esp) + andl $32767, %edx + jmp ..B1.34 +..B1.20: + movl %ecx, %edx + movl %eax, 16(%esp) + andl $32767, %edx + jmp ..B1.34 +..B1.21: + movl %eax, 16(%esp) + jmp ..B1.35 +..B1.22: + movl %eax, 16(%esp) +..B1.23: + movzwl 26(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.24: + orl $-64768, %edx + movw %dx, 24(%esp) +..B1.25: + fldcw 24(%esp) +..B1.26: + fldt _small_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) +..B1.27: + fldcw 26(%esp) +..B1.28: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.29: + movzwl 20(%esp), %eax + movl %eax, %edx + movl 12(%esp), %ecx + andl $32767, %edx + incl %ecx + movl %ecx, 12(%esp) + jne ..B1.33 +..B1.30: + movl $-2147483648, %ecx + testl %edx, %edx + movl 16(%esp), %edi + je ..L3 + movl $0, %ecx +..L3: + incl %edi + cmpl %ecx, %edi + jne ..B1.32 +..B1.31: + incl %edx + andl $-32768, %eax + andl $32767, %edx + orl $-2147483648, %edi + orl %edx, %eax + movl %eax, %edx + movl %edi, 16(%esp) + andl $32767, %edx + movw %ax, 20(%esp) + jmp ..B1.33 +..B1.32: + movl %edi, 16(%esp) +..B1.33: + cmpl $32767, %edx + je ..B1.37 +..B1.34: + testl %edx, %edx + je ..B1.23 +..B1.35: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.36: + fldt _small_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.28 +..B1.37: + movzwl 26(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.38: + orl $-64768, %edx + movw %dx, 24(%esp) +..B1.39: + fldcw 24(%esp) +..B1.40: + fldt _large_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) +..B1.41: + fldcw 26(%esp) +..B1.42: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.43: + fldt _large_value_80@GOTOFF(%esi) + fmul %st(0), %st + fstpt (%esp) + jmp ..B1.42 +..B1.44: + fstp %st(0) + movzbl 69(%esp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _smallest_value_80@GOTOFF(%esi,%ecx) + movzwl 8+_smallest_value_80@GOTOFF(%esi,%ecx), %edx + fstpt 12(%esp) + andl $32767, %edx + jmp ..B1.34 +..B1.45: + cmpl $-2147483648, 64(%esp) + jne ..B1.47 +..B1.46: + cmpl $0, 60(%esp) + je ..B1.5 +..B1.47: + movzwl 26(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.53 +..B1.48: + orl $-64768, %edx + movw %dx, 24(%esp) +..B1.49: + fldcw 24(%esp) +..B1.50: + fldt 48(%esp) + fldt 60(%esp) + fmulp %st, %st(1) + fstpt 12(%esp) +..B1.51: + fldcw 26(%esp) +..B1.52: + fldt 12(%esp) + addl $36, %esp + popl %edi + popl %esi + ret +..B1.53: + fldt 48(%esp) + fldt 60(%esp) + fmulp %st, %st(1) + fstpt 12(%esp) + jmp ..B1.52 +..B1.54: + cmpl $-2147483648, 52(%esp) + jne ..B1.47 +..B1.55: + cmpl $0, 48(%esp) + jne ..B1.47 + jmp ..B1.4 +..B1.56: + fstp %st(1) + addl $36, %esp + popl %edi + popl %esi + ret + .align 16,0x90 + .type nexttowardl,@function + .size nexttowardl,.-nexttowardl + .data +# -- End nexttowardl + .section .rodata, "a" + .align 4 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_smallest_value_80: + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .type _smallest_value_80,@object + .size _smallest_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/pow_wmt.S b/external/sgx_libm/ia32/pow_wmt.S new file mode 100644 index 0000000000..3f6206c1ae --- /dev/null +++ b/external/sgx_libm/ia32/pow_wmt.S @@ -0,0 +1,4274 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "pow_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin pow + .text + .align 16,0x90 + .globl pow +pow: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movsd 136(%esp), %xmm1 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movl $1069088768, %ecx + movd %ecx, %xmm7 + movsd %xmm1, 16(%esp) + xorpd %xmm1, %xmm1 + movl $30704, %edx + pinsrw $3, %edx, %xmm1 + movsd %xmm0, 8(%esp) + movapd %xmm0, %xmm3 + movl $8192, %edx + movd %edx, %xmm4 + movapd 8240(%ebx), %xmm6 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + psllq $5, %xmm0 + movsd 8256(%ebx), %xmm2 + psrlq $34, %xmm0 + movl %eax, %edx + andl $32752, %edx + subl $16368, %edx + movl %edx, %ecx + sarl $31, %edx + addl %edx, %ecx + xorl %edx, %ecx + rcpss %xmm0, %xmm0 + psllq $12, %xmm3 + addl $16, %ecx + bsr %ecx, %ecx + psrlq $12, %xmm3 + movl %esi, 24(%esp) + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.3 + movl $0, %esi +.L_2TAG_PACKET_1.0.3: + mulss %xmm7, %xmm0 + movl $-1, %edx + subl $4, %ecx + shll %cl, %edx + movd %edx, %xmm5 + orpd %xmm1, %xmm3 + subl $16351, %eax + cmpl $1, %eax + jbe .L_2TAG_PACKET_2.0.3 + paddd %xmm4, %xmm0 + psllq $32, %xmm5 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm3, %xmm5 +.L_2TAG_PACKET_3.0.3: + andpd %xmm6, %xmm0 + subsd %xmm5, %xmm3 + subl $1, %eax + sarl $4, %eax + cvtsi2sdl %eax, %xmm7 + mulpd %xmm0, %xmm5 +.L_2TAG_PACKET_4.0.3: + mulsd %xmm0, %xmm3 + movapd 8272(%ebx), %xmm1 + subsd %xmm2, %xmm5 + movapd 8288(%ebx), %xmm4 + movl %eax, %ecx + sarl $31, %eax + addl %eax, %ecx + xorl %ecx, %eax + addl $1, %eax + bsr %eax, %eax + unpcklpd %xmm3, %xmm5 + movapd 8304(%ebx), %xmm6 + addsd %xmm5, %xmm3 + andl $16760832, %edx + shrl $10, %edx + addpd -3616(%ebx,%edx), %xmm5 + movapd 8320(%ebx), %xmm0 + pshufd $68, %xmm3, %xmm2 + mulsd %xmm3, %xmm3 + mulpd %xmm2, %xmm1 + mulpd %xmm2, %xmm4 + addsd %xmm7, %xmm5 + mulsd %xmm3, %xmm2 + addpd %xmm1, %xmm6 + mulsd %xmm3, %xmm3 + addpd %xmm4, %xmm0 + movsd 16(%esp), %xmm1 + movzwl 22(%esp), %ecx + pshufd $238, %xmm5, %xmm7 + movsd 8368(%ebx), %xmm4 + mulpd %xmm2, %xmm6 + pshufd $68, %xmm3, %xmm3 + mulpd %xmm2, %xmm0 + shll $4, %eax + subl $15872, %eax + andl $32752, %ecx + addl %ecx, %eax + mulpd %xmm6, %xmm3 + cmpl $624, %eax + jae .L_2TAG_PACKET_5.0.3 + xorpd %xmm6, %xmm6 + movl $17080, %edx + pinsrw $3, %edx, %xmm6 + movapd %xmm1, %xmm2 + andpd %xmm1, %xmm4 + subsd %xmm4, %xmm1 + mulsd %xmm5, %xmm4 + addsd %xmm7, %xmm0 + mulsd %xmm5, %xmm1 + movapd %xmm6, %xmm7 + addsd %xmm4, %xmm6 + addpd %xmm0, %xmm3 + movd %xmm6, %edx + subsd %xmm7, %xmm6 + pshufd $238, %xmm3, %xmm0 + subsd %xmm6, %xmm4 + addsd %xmm3, %xmm0 + movl %edx, %ecx + andl $255, %edx + addl %edx, %edx + movapd 8384(%ebx,%edx,8), %xmm5 + addsd %xmm1, %xmm4 + mulsd %xmm0, %xmm2 + movapd 12480(%ebx), %xmm7 + movapd 12496(%ebx), %xmm3 + shll $12, %ecx + xorl %esi, %ecx + andl $-1048576, %ecx + movd %ecx, %xmm6 + addsd %xmm4, %xmm2 + movsd 12512(%ebx), %xmm1 + pshufd $68, %xmm2, %xmm0 + pshufd $68, %xmm2, %xmm4 + mulpd %xmm0, %xmm0 + movl 24(%esp), %esi + mulpd %xmm4, %xmm7 + pshufd $17, %xmm6, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm0, %xmm0 + paddd %xmm6, %xmm5 + addpd %xmm7, %xmm3 + mulsd %xmm5, %xmm1 + pshufd $238, %xmm5, %xmm6 + mulpd %xmm3, %xmm0 + addsd %xmm6, %xmm1 + pshufd $238, %xmm0, %xmm3 + mulsd %xmm5, %xmm0 + mulsd %xmm5, %xmm3 + addsd %xmm1, %xmm0 + addsd %xmm3, %xmm0 + addsd %xmm5, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_7.0.3: + movsd 128(%esp), %xmm0 + movsd 136(%esp), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_0.0.3: + addl $16, %eax + movl $32752, %edx + andl %eax, %edx + cmpl $32752, %edx + je .L_2TAG_PACKET_8.0.3 + testl $32768, %eax + jne .L_2TAG_PACKET_9.0.3 +.L_2TAG_PACKET_10.0.3: + movl 16(%esp), %ecx + xorl %edx, %edx + testl %ecx, %ecx + movl $1, %ecx + cmovne %ecx, %edx + orl 20(%esp), %edx + cmpl $1072693248, %edx + je .L_2TAG_PACKET_7.0.3 + movsd 8(%esp), %xmm0 + movsd 8(%esp), %xmm3 + movd %xmm3, %edx + psrlq $32, %xmm3 + movd %xmm3, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_11.0.3 + xorpd %xmm3, %xmm3 + movl $18416, %eax + pinsrw $3, %eax, %xmm3 + mulsd %xmm3, %xmm0 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movapd %xmm0, %xmm3 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $18416, %ecx + psllq $5, %xmm0 + movsd 8256(%ebx), %xmm2 + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm3 + movapd 8240(%ebx), %xmm6 + psrlq $12, %xmm3 + mulss %xmm7, %xmm0 + movl $-1024, %edx + movd %edx, %xmm5 + orpd %xmm1, %xmm3 + paddd %xmm4, %xmm0 + psllq $32, %xmm5 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm3, %xmm5 + movl $0, %esi + andpd %xmm6, %xmm0 + subsd %xmm5, %xmm3 + andl $32752, %eax + subl $18416, %eax + sarl $4, %eax + cvtsi2sdl %eax, %xmm7 + mulpd %xmm0, %xmm5 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_12.0.3: + movl 16(%esp), %ecx + xorl %edx, %edx + testl %ecx, %ecx + movl $1, %ecx + cmovne %ecx, %edx + orl 20(%esp), %edx + cmpl $1072693248, %edx + je .L_2TAG_PACKET_7.0.3 + movsd 8(%esp), %xmm0 + movsd 8(%esp), %xmm3 + movd %xmm3, %edx + psrlq $32, %xmm3 + movd %xmm3, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_11.0.3 + xorpd %xmm3, %xmm3 + movl $18416, %eax + pinsrw $3, %eax, %xmm3 + mulsd %xmm3, %xmm0 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movapd %xmm0, %xmm3 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $18416, %ecx + psllq $5, %xmm0 + movsd 8256(%ebx), %xmm2 + psrlq $34, %xmm0 + rcpss %xmm0, %xmm0 + psllq $12, %xmm3 + movapd 8240(%ebx), %xmm6 + psrlq $12, %xmm3 + mulss %xmm7, %xmm0 + movl $-1024, %edx + movd %edx, %xmm5 + orpd %xmm1, %xmm3 + paddd %xmm4, %xmm0 + psllq $32, %xmm5 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm3, %xmm5 + movl $-2147483648, %esi + andpd %xmm6, %xmm0 + subsd %xmm5, %xmm3 + andl $32752, %eax + subl $18416, %eax + sarl $4, %eax + cvtsi2sdl %eax, %xmm7 + mulpd %xmm0, %xmm5 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + cmpl $0, %eax + jl .L_2TAG_PACKET_13.0.3 + cmpl $752, %eax + jae .L_2TAG_PACKET_14.0.3 +.L_2TAG_PACKET_15.0.3: + addsd %xmm7, %xmm0 + movsd 12544(%ebx), %xmm2 + addpd %xmm0, %xmm3 + xorpd %xmm6, %xmm6 + movl $17080, %eax + pinsrw $3, %eax, %xmm6 + pshufd $238, %xmm3, %xmm0 + addsd %xmm3, %xmm0 + movapd %xmm5, %xmm3 + addsd %xmm0, %xmm5 + movapd %xmm2, %xmm4 + subsd %xmm5, %xmm3 + movapd %xmm5, %xmm7 + andpd %xmm2, %xmm5 + movapd %xmm1, %xmm2 + andpd %xmm1, %xmm4 + subsd %xmm5, %xmm7 + addsd %xmm3, %xmm0 + subsd %xmm4, %xmm1 + mulsd %xmm5, %xmm4 + addsd %xmm7, %xmm0 + mulsd %xmm0, %xmm2 + movapd %xmm6, %xmm7 + mulsd %xmm5, %xmm1 + addsd %xmm4, %xmm6 + movd %xmm6, %eax + subsd %xmm7, %xmm6 + addsd %xmm1, %xmm2 + movapd 12480(%ebx), %xmm7 + movapd 12496(%ebx), %xmm3 + subsd %xmm6, %xmm4 + pextrw $3, %xmm6, %edx + movl %eax, %ecx + andl $255, %eax + addl %eax, %eax + movapd 8384(%ebx,%eax,8), %xmm5 + addsd %xmm4, %xmm2 + sarl $8, %ecx + movl %ecx, %eax + sarl $1, %ecx + subl %ecx, %eax + shll $20, %ecx + xorl %esi, %ecx + movd %ecx, %xmm6 + movsd 12512(%ebx), %xmm1 + andl $32767, %edx + cmpl $16529, %edx + ja .L_2TAG_PACKET_14.0.3 + pshufd $68, %xmm2, %xmm0 + pshufd $68, %xmm2, %xmm4 + mulpd %xmm0, %xmm0 + mulpd %xmm4, %xmm7 + pshufd $17, %xmm6, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm0, %xmm0 + paddd %xmm6, %xmm5 + addpd %xmm7, %xmm3 + mulsd %xmm5, %xmm1 + pshufd $238, %xmm5, %xmm6 + mulpd %xmm3, %xmm0 + addsd %xmm6, %xmm1 + pshufd $238, %xmm0, %xmm3 + mulsd %xmm5, %xmm0 + mulsd %xmm5, %xmm3 + shll $4, %eax + xorpd %xmm4, %xmm4 + addl $16368, %eax + pinsrw $3, %eax, %xmm4 + addsd %xmm1, %xmm0 + movl 24(%esp), %esi + addsd %xmm3, %xmm0 + movapd %xmm0, %xmm1 + addsd %xmm5, %xmm0 + mulsd %xmm4, %xmm0 + pextrw $3, %xmm0, %eax + andl $32752, %eax + je .L_2TAG_PACKET_16.0.3 + cmpl $32752, %eax + je .L_2TAG_PACKET_17.0.3 +.L_2TAG_PACKET_18.0.3: + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_8.0.3: + movsd 16(%esp), %xmm1 + movsd 8(%esp), %xmm0 + movapd %xmm0, %xmm2 + movd %xmm2, %eax + psrlq $20, %xmm2 + movd %xmm2, %edx + orl %edx, %eax + je .L_2TAG_PACKET_19.0.3 + addsd %xmm0, %xmm0 + movd %xmm1, %eax + psrlq $32, %xmm1 + movd %xmm1, %edx + movl %edx, %ecx + addl %edx, %edx + orl %edx, %eax + je .L_2TAG_PACKET_20.0.3 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_20.0.3: + xorpd %xmm0, %xmm0 + movl $16368, %eax + pinsrw $3, %eax, %xmm0 + movl $29, %edx + jmp .L_2TAG_PACKET_21.0.3 +.L_2TAG_PACKET_22.0.3: + movsd 16(%esp), %xmm0 + addpd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_19.0.3: + movd %xmm1, %eax + movapd %xmm1, %xmm2 + psrlq $32, %xmm1 + movd %xmm1, %edx + movl %edx, %ecx + addl %edx, %edx + orl %edx, %eax + je .L_2TAG_PACKET_23.0.3 + pextrw $3, %xmm2, %eax + andl $32752, %eax + cmpl $32752, %eax + jne .L_2TAG_PACKET_24.0.3 + movd %xmm2, %eax + psrlq $20, %xmm2 + movd %xmm2, %edx + orl %edx, %eax + jne .L_2TAG_PACKET_22.0.3 +.L_2TAG_PACKET_24.0.3: + pextrw $3, %xmm0, %eax + testl $32768, %eax + jne .L_2TAG_PACKET_25.0.3 + testl $-2147483648, %ecx + jne .L_2TAG_PACKET_26.0.3 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_27.0.3: + movsd 16(%esp), %xmm1 + movd %xmm1, %eax + testl $1, %eax + jne .L_2TAG_PACKET_28.0.3 + testl $2, %eax + jne .L_2TAG_PACKET_29.0.3 + jmp .L_2TAG_PACKET_28.0.3 +.L_2TAG_PACKET_25.0.3: + shrl $20, %ecx + andl $2047, %ecx + cmpl $1075, %ecx + ja .L_2TAG_PACKET_28.0.3 + je .L_2TAG_PACKET_30.0.3 + cmpl $1074, %ecx + ja .L_2TAG_PACKET_27.0.3 + cmpl $1023, %ecx + jb .L_2TAG_PACKET_28.0.3 + movsd 16(%esp), %xmm1 + movl $17208, %eax + xorpd %xmm3, %xmm3 + pinsrw $3, %eax, %xmm3 + movapd %xmm3, %xmm4 + addsd %xmm1, %xmm3 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm1 + pextrw $3, %xmm1, %eax + andl $32752, %eax + jne .L_2TAG_PACKET_28.0.3 + movd %xmm3, %eax + andl $1, %eax + je .L_2TAG_PACKET_28.0.3 +.L_2TAG_PACKET_29.0.3: + movsd 16(%esp), %xmm1 + pextrw $3, %xmm1, %eax + andl $32768, %eax + je .L_2TAG_PACKET_18.0.3 + xorpd %xmm0, %xmm0 + movl $32768, %eax + pinsrw $3, %eax, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_28.0.3: + movsd 16(%esp), %xmm1 + pextrw $3, %xmm1, %eax + andl $32768, %eax + jne .L_2TAG_PACKET_26.0.3 +.L_2TAG_PACKET_31.0.3: + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_30.0.3: + movsd 16(%esp), %xmm1 + movd %xmm1, %eax + andl $1, %eax + je .L_2TAG_PACKET_28.0.3 + jmp .L_2TAG_PACKET_29.0.3 +.L_2TAG_PACKET_32.0.3: + movd %xmm1, %eax + psrlq $20, %xmm1 + movd %xmm1, %edx + orl %edx, %eax + je .L_2TAG_PACKET_33.0.3 + movsd 16(%esp), %xmm0 + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_33.0.3: + movsd 8(%esp), %xmm0 + pextrw $3, %xmm0, %eax + cmpl $49136, %eax + jne .L_2TAG_PACKET_34.0.3 + movd %xmm0, %ecx + psrlq $20, %xmm0 + movd %xmm0, %edx + orl %edx, %ecx + jne .L_2TAG_PACKET_34.0.3 + xorpd %xmm0, %xmm0 + movl $16368, %eax + pinsrw $3, %eax, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_34.0.3: + movsd 16(%esp), %xmm1 + andl $32752, %eax + subl $16368, %eax + pextrw $3, %xmm1, %edx + xorpd %xmm0, %xmm0 + xorl %edx, %eax + andl $32768, %eax + jne .L_2TAG_PACKET_18.0.3 + movl $32752, %ecx + pinsrw $3, %ecx, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_35.0.3: + movd %xmm1, %eax + cmpl $17184, %edx + ja .L_2TAG_PACKET_36.0.3 + testl $1, %eax + jne .L_2TAG_PACKET_37.0.3 + testl $2, %eax + je .L_2TAG_PACKET_38.0.3 + jmp .L_2TAG_PACKET_39.0.3 +.L_2TAG_PACKET_36.0.3: + testl $1, %eax + je .L_2TAG_PACKET_38.0.3 + jmp .L_2TAG_PACKET_39.0.3 +.L_2TAG_PACKET_9.0.3: + movsd 8(%esp), %xmm2 + movd %xmm2, %eax + psrlq $31, %xmm2 + movd %xmm2, %ecx + orl %ecx, %eax + je .L_2TAG_PACKET_11.0.3 + movsd 16(%esp), %xmm1 + pextrw $3, %xmm1, %edx + movd %xmm1, %eax + movapd %xmm1, %xmm2 + psrlq $32, %xmm2 + movd %xmm2, %ecx + addl %ecx, %ecx + orl %eax, %ecx + je .L_2TAG_PACKET_40.0.3 + andl $32752, %edx + cmpl $32752, %edx + je .L_2TAG_PACKET_32.0.3 + cmpl $17200, %edx + ja .L_2TAG_PACKET_38.0.3 + cmpl $17184, %edx + jae .L_2TAG_PACKET_35.0.3 + cmpl $16368, %edx + jb .L_2TAG_PACKET_37.0.3 + movl $17208, %eax + xorpd %xmm2, %xmm2 + pinsrw $3, %eax, %xmm2 + movapd %xmm2, %xmm4 + addsd %xmm1, %xmm2 + subsd %xmm2, %xmm4 + addsd %xmm4, %xmm1 + pextrw $3, %xmm1, %eax + andl $32767, %eax + jne .L_2TAG_PACKET_37.0.3 + movd %xmm2, %eax + andl $1, %eax + je .L_2TAG_PACKET_38.0.3 +.L_2TAG_PACKET_39.0.3: + xorpd %xmm1, %xmm1 + movl $30704, %edx + pinsrw $3, %edx, %xmm1 + movsd 8256(%ebx), %xmm2 + movsd 8(%esp), %xmm4 + pextrw $3, %xmm4, %eax + movl $8192, %edx + movd %edx, %xmm4 + andl $32767, %eax + subl $16, %eax + jl .L_2TAG_PACKET_12.0.3 + movl %eax, %edx + andl $32752, %edx + subl $16368, %edx + movl %edx, %ecx + sarl $31, %edx + addl %edx, %ecx + xorl %edx, %ecx + addl $16, %ecx + bsr %ecx, %ecx + movl $-2147483648, %esi + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_37.0.3: + xorpd %xmm1, %xmm1 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + xorpd %xmm0, %xmm0 + mulsd %xmm1, %xmm0 + movl $28, %edx + jmp .L_2TAG_PACKET_21.0.3 +.L_2TAG_PACKET_38.0.3: + xorpd %xmm1, %xmm1 + movl $30704, %edx + pinsrw $3, %edx, %xmm1 + movsd 8256(%ebx), %xmm2 + movsd 8(%esp), %xmm4 + pextrw $3, %xmm4, %eax + movl $8192, %edx + movd %edx, %xmm4 + andl $32767, %eax + subl $16, %eax + jl .L_2TAG_PACKET_10.0.3 + movl %eax, %edx + andl $32752, %edx + subl $16368, %edx + movl %edx, %ecx + sarl $31, %edx + addl %edx, %ecx + xorl %edx, %ecx + addl $16, %ecx + bsr %ecx, %ecx + movl $0, %esi + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_23.0.3: + xorpd %xmm0, %xmm0 + movl $16368, %eax + pinsrw $3, %eax, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_26.0.3: + xorpd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_13.0.3: + addl $384, %eax + cmpl $0, %eax + jl .L_2TAG_PACKET_41.0.3 + mulsd %xmm1, %xmm5 + addsd %xmm7, %xmm0 + shrl $31, %esi + addpd %xmm0, %xmm3 + pshufd $238, %xmm3, %xmm0 + addsd %xmm0, %xmm3 + movsd 12528(%ebx,%esi,8), %xmm4 + mulsd %xmm3, %xmm1 + xorpd %xmm0, %xmm0 + movl $16368, %eax + shll $15, %esi + orl %esi, %eax + pinsrw $3, %eax, %xmm0 + addsd %xmm1, %xmm5 + movl 24(%esp), %esi + mulsd %xmm4, %xmm5 + addsd %xmm5, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_41.0.3: + movl 24(%esp), %esi + xorpd %xmm0, %xmm0 + movl $16368, %eax + pinsrw $3, %eax, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_40.0.3: + xorpd %xmm0, %xmm0 + movl $16368, %eax + pinsrw $3, %eax, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_42.0.3: + xorpd %xmm0, %xmm0 + movl $16368, %eax + pinsrw $3, %eax, %xmm0 + movl $26, %edx + jmp .L_2TAG_PACKET_21.0.3 +.L_2TAG_PACKET_11.0.3: + movsd 16(%esp), %xmm1 + movapd %xmm1, %xmm2 + pextrw $3, %xmm1, %eax + andl $32752, %eax + cmpl $32752, %eax + jne .L_2TAG_PACKET_43.0.3 + movd %xmm2, %eax + psrlq $20, %xmm2 + movd %xmm2, %edx + orl %edx, %eax + jne .L_2TAG_PACKET_22.0.3 +.L_2TAG_PACKET_43.0.3: + movd %xmm1, %eax + psrlq $32, %xmm1 + movd %xmm1, %edx + movl %edx, %ecx + addl %edx, %edx + orl %edx, %eax + je .L_2TAG_PACKET_42.0.3 + shrl $21, %edx + cmpl $1075, %edx + ja .L_2TAG_PACKET_44.0.3 + je .L_2TAG_PACKET_45.0.3 + cmpl $1023, %edx + jb .L_2TAG_PACKET_44.0.3 + movsd 16(%esp), %xmm1 + movl $17208, %eax + xorpd %xmm3, %xmm3 + pinsrw $3, %eax, %xmm3 + movapd %xmm3, %xmm4 + addsd %xmm1, %xmm3 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm1 + pextrw $3, %xmm1, %eax + andl $32752, %eax + jne .L_2TAG_PACKET_44.0.3 + movd %xmm3, %eax + andl $1, %eax + je .L_2TAG_PACKET_44.0.3 +.L_2TAG_PACKET_46.0.3: + movsd 8(%esp), %xmm0 + testl $-2147483648, %ecx + jne .L_2TAG_PACKET_47.0.3 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_45.0.3: + movsd 16(%esp), %xmm1 + movd %xmm1, %eax + testl $1, %eax + jne .L_2TAG_PACKET_46.0.3 +.L_2TAG_PACKET_44.0.3: + testl $-2147483648, %ecx + je .L_2TAG_PACKET_26.0.3 + xorpd %xmm0, %xmm0 +.L_2TAG_PACKET_47.0.3: + movl $16368, %eax + xorpd %xmm1, %xmm1 + pinsrw $3, %eax, %xmm1 + divsd %xmm0, %xmm1 + movapd %xmm1, %xmm0 + movl $27, %edx + jmp .L_2TAG_PACKET_21.0.3 +.L_2TAG_PACKET_14.0.3: + movsd 8(%esp), %xmm2 + movsd 16(%esp), %xmm6 + pextrw $3, %xmm2, %eax + pextrw $3, %xmm6, %edx + movl $32752, %ecx + andl %edx, %ecx + cmpl $32752, %ecx + je .L_2TAG_PACKET_48.0.3 + andl $32752, %eax + subl $16368, %eax + xorl %eax, %edx + testl $32768, %edx + jne .L_2TAG_PACKET_49.0.3 +.L_2TAG_PACKET_50.0.3: + movl $32736, %eax + pinsrw $3, %eax, %xmm0 + shrl $16, %esi + orl %esi, %eax + pinsrw $3, %eax, %xmm1 + movl 24(%esp), %esi + mulsd %xmm1, %xmm0 +.L_2TAG_PACKET_17.0.3: + movl $24, %edx +.L_2TAG_PACKET_21.0.3: + movsd %xmm0, (%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 136(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_49.0.3: + movl $16, %eax + pinsrw $3, %eax, %xmm0 + mulsd %xmm0, %xmm0 + testl $-2147483648, %esi + je .L_2TAG_PACKET_51.0.3 + movsd 12560(%ebx), %xmm2 + xorpd %xmm2, %xmm0 +.L_2TAG_PACKET_51.0.3: + movl 24(%esp), %esi + movl $25, %edx + jmp .L_2TAG_PACKET_21.0.3 +.L_2TAG_PACKET_16.0.3: + pextrw $3, %xmm5, %ecx + pextrw $3, %xmm4, %edx + movl $-1, %eax + andl $32752, %ecx + subl $16368, %ecx + andl $32752, %edx + addl %ecx, %edx + movl $-31, %ecx + sarl $4, %edx + subl %edx, %ecx + jle .L_2TAG_PACKET_52.0.3 + cmpl $20, %ecx + ja .L_2TAG_PACKET_53.0.3 + shll %cl, %eax +.L_2TAG_PACKET_52.0.3: + movd %eax, %xmm0 + psllq $32, %xmm0 + andpd %xmm5, %xmm0 + subsd %xmm0, %xmm5 + addsd %xmm1, %xmm5 + mulsd %xmm4, %xmm0 + mulsd %xmm4, %xmm5 + addsd %xmm5, %xmm0 +.L_2TAG_PACKET_53.0.3: + movl $25, %edx + jmp .L_2TAG_PACKET_21.0.3 +.L_2TAG_PACKET_2.0.3: + movzwl 22(%esp), %ecx + movl $-2147483648, %edx + movd %edx, %xmm1 + xorpd %xmm7, %xmm7 + paddd %xmm4, %xmm0 + psllq $32, %xmm5 + movd %xmm0, %edx + psllq $29, %xmm0 + paddq %xmm3, %xmm1 + andpd %xmm1, %xmm5 + andl $32752, %ecx + cmpl $16560, %ecx + jb .L_2TAG_PACKET_3.0.3 + andpd %xmm6, %xmm0 + subsd %xmm5, %xmm3 + addl $16351, %eax + shrl $4, %eax + subl $1022, %eax + cvtsi2sdl %eax, %xmm7 + mulpd %xmm0, %xmm5 + movsd (%ebx), %xmm4 + mulsd %xmm0, %xmm3 + movsd (%ebx), %xmm6 + subsd %xmm2, %xmm5 + movsd 8(%ebx), %xmm1 + pshufd $68, %xmm3, %xmm2 + unpcklpd %xmm3, %xmm5 + addsd %xmm5, %xmm3 + movsd 8(%ebx), %xmm0 + andl $16760832, %edx + shrl $10, %edx + addpd -3616(%ebx,%edx), %xmm7 + mulsd %xmm5, %xmm4 + mulsd %xmm5, %xmm0 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + movapd %xmm5, %xmm2 + mulsd %xmm5, %xmm4 + addsd %xmm0, %xmm5 + movapd %xmm7, %xmm0 + addsd %xmm3, %xmm2 + addsd %xmm5, %xmm7 + mulsd %xmm2, %xmm6 + subsd %xmm7, %xmm0 + movapd %xmm7, %xmm2 + addsd %xmm4, %xmm7 + addsd %xmm5, %xmm0 + subsd %xmm7, %xmm2 + addsd %xmm2, %xmm4 + pshufd $238, %xmm5, %xmm2 + movapd %xmm7, %xmm5 + addsd %xmm2, %xmm7 + addsd %xmm0, %xmm4 + movapd 8272(%ebx), %xmm0 + subsd %xmm7, %xmm5 + addsd %xmm4, %xmm6 + movapd %xmm7, %xmm4 + addsd %xmm2, %xmm5 + addsd %xmm1, %xmm7 + movapd 8336(%ebx), %xmm2 + subsd %xmm7, %xmm4 + addsd %xmm5, %xmm6 + addsd %xmm1, %xmm4 + pshufd $238, %xmm7, %xmm5 + movapd %xmm7, %xmm1 + addsd %xmm5, %xmm7 + subsd %xmm7, %xmm1 + addsd %xmm5, %xmm1 + movapd 8352(%ebx), %xmm5 + pshufd $68, %xmm3, %xmm3 + addsd %xmm4, %xmm6 + addsd %xmm1, %xmm6 + movapd 8304(%ebx), %xmm1 + mulpd %xmm3, %xmm0 + mulpd %xmm3, %xmm2 + pshufd $68, %xmm3, %xmm4 + mulpd %xmm3, %xmm3 + addpd %xmm1, %xmm0 + addpd %xmm2, %xmm5 + mulsd %xmm3, %xmm4 + movsd 16(%ebx), %xmm2 + mulpd %xmm3, %xmm3 + movsd 16(%esp), %xmm1 + movzwl 22(%esp), %ecx + mulpd %xmm4, %xmm0 + pextrw $3, %xmm7, %eax + mulpd %xmm4, %xmm5 + mulpd %xmm3, %xmm0 + movsd 8376(%ebx), %xmm4 + andpd %xmm7, %xmm2 + addsd %xmm6, %xmm5 + subsd %xmm2, %xmm7 + addpd %xmm0, %xmm5 + andl $32752, %eax + subl $16368, %eax + andl $32752, %ecx + cmpl $32752, %ecx + je .L_2TAG_PACKET_48.0.3 + addl %eax, %ecx + cmpl $16576, %ecx + jae .L_2TAG_PACKET_54.0.3 + pshufd $238, %xmm5, %xmm0 + andpd %xmm1, %xmm4 + movapd %xmm1, %xmm3 + addsd %xmm0, %xmm5 + subsd %xmm4, %xmm1 + xorpd %xmm6, %xmm6 + movl $17080, %edx + pinsrw $3, %edx, %xmm6 + addsd %xmm5, %xmm7 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm1 + movapd %xmm6, %xmm5 + mulsd %xmm7, %xmm3 + addsd %xmm4, %xmm6 + addsd %xmm3, %xmm1 + movapd 12480(%ebx), %xmm7 + movd %xmm6, %edx + subsd %xmm5, %xmm6 + movapd 12496(%ebx), %xmm3 + movsd 12512(%ebx), %xmm2 + subsd %xmm6, %xmm4 + movl %edx, %ecx + andl $255, %edx + addl %edx, %edx + movapd 8384(%ebx,%edx,8), %xmm5 + addsd %xmm1, %xmm4 + pextrw $3, %xmm6, %edx + shrl $8, %ecx + movl %ecx, %eax + shrl $1, %ecx + subl %ecx, %eax + shll $20, %ecx + movd %ecx, %xmm6 + pshufd $68, %xmm4, %xmm0 + pshufd $68, %xmm4, %xmm1 + mulpd %xmm0, %xmm0 + mulpd %xmm1, %xmm7 + pshufd $17, %xmm6, %xmm6 + mulsd %xmm4, %xmm2 + andl $32767, %edx + cmpl $16529, %edx + ja .L_2TAG_PACKET_14.0.3 + mulsd %xmm0, %xmm0 + paddd %xmm6, %xmm5 + addpd %xmm7, %xmm3 + mulsd %xmm5, %xmm2 + pshufd $238, %xmm5, %xmm6 + mulpd %xmm3, %xmm0 + addsd %xmm6, %xmm2 + pshufd $238, %xmm0, %xmm3 + addl $1023, %eax + shll $20, %eax + orl %esi, %eax + movd %eax, %xmm4 + mulsd %xmm5, %xmm0 + mulsd %xmm5, %xmm3 + addsd %xmm2, %xmm0 + psllq $32, %xmm4 + addsd %xmm3, %xmm0 + movapd %xmm0, %xmm1 + addsd %xmm5, %xmm0 + movl 24(%esp), %esi + mulsd %xmm4, %xmm0 + pextrw $3, %xmm0, %eax + andl $32752, %eax + je .L_2TAG_PACKET_16.0.3 + cmpl $32752, %eax + je .L_2TAG_PACKET_17.0.3 +.L_2TAG_PACKET_55.0.3: + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_6.0.3 +.L_2TAG_PACKET_48.0.3: + movl 24(%esp), %esi +.L_2TAG_PACKET_56.0.3: + movsd 8(%esp), %xmm0 + movsd 16(%esp), %xmm1 + addsd %xmm1, %xmm1 + xorpd %xmm2, %xmm2 + movl $49136, %eax + pinsrw $3, %eax, %xmm2 + addsd %xmm0, %xmm2 + pextrw $3, %xmm2, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_18.0.3 + movd %xmm1, %edx + movapd %xmm1, %xmm3 + psrlq $20, %xmm3 + movd %xmm3, %ecx + orl %edx, %ecx + je .L_2TAG_PACKET_57.0.3 + addsd %xmm1, %xmm1 + movapd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_57.0.3: + pextrw $3, %xmm0, %eax + andl $32752, %eax + pextrw $3, %xmm1, %edx + xorpd %xmm0, %xmm0 + subl $16368, %eax + xorl %edx, %eax + testl $32768, %eax + jne .L_2TAG_PACKET_18.0.3 + movl $32752, %edx + pinsrw $3, %edx, %xmm0 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_54.0.3: + pextrw $3, %xmm1, %eax + pextrw $3, %xmm2, %ecx + xorl %ecx, %eax + testl $32768, %eax + je .L_2TAG_PACKET_50.0.3 + jmp .L_2TAG_PACKET_49.0.3 +.L_2TAG_PACKET_6.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type pow,@function + .size pow,.-pow + .data +# -- End pow + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 3218479616 + .long 0 + .long 3210587105 + .long 4160749568 + .long 4294967295 + .long 0 + .long 4294965248 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 536870912 + .long 1072689162 + .long 2523013013 + .long 1046157398 + .long 3758096384 + .long 1072685081 + .long 3851513758 + .long 3190968952 + .long 0 + .long 1072681007 + .long 2241466466 + .long 1046044599 + .long 3221225472 + .long 1072676937 + .long 2990928271 + .long 3193084984 + .long 3758096384 + .long 1072672873 + .long 2905112743 + .long 3192918576 + .long 1610612736 + .long 1072668815 + .long 3370591264 + .long 1046051793 + .long 2147483648 + .long 1072664762 + .long 3272361216 + .long 3193793653 + .long 3758096384 + .long 1072660714 + .long 46546755 + .long 1043206936 + .long 3221225472 + .long 1072656672 + .long 3017067724 + .long 3192177962 + .long 0 + .long 1072652636 + .long 3688436631 + .long 3192814956 + .long 2684354560 + .long 1072648604 + .long 1707461992 + .long 3193056712 + .long 2684354560 + .long 1072644578 + .long 1188114540 + .long 3193603086 + .long 3758096384 + .long 1072640557 + .long 3533180564 + .long 1045459375 + .long 2684354560 + .long 1072636542 + .long 2000337630 + .long 3193475557 + .long 2684354560 + .long 1072632532 + .long 3698062443 + .long 3193752766 + .long 3758096384 + .long 1072628527 + .long 3161606138 + .long 3190532995 + .long 2147483648 + .long 1072624528 + .long 3165265478 + .long 3193158459 + .long 1610612736 + .long 1072620534 + .long 1600940077 + .long 3193226777 + .long 2147483648 + .long 1072616545 + .long 1363272552 + .long 3192614278 + .long 3758096384 + .long 1072612561 + .long 3966209910 + .long 3191249654 + .long 2147483648 + .long 1072608583 + .long 1093672789 + .long 3190637330 + .long 1610612736 + .long 1072604610 + .long 1735239357 + .long 3192753616 + .long 1610612736 + .long 1072600642 + .long 1470665156 + .long 1045559697 + .long 2684354560 + .long 1072596679 + .long 3840624926 + .long 1045928953 + .long 536870912 + .long 1072592722 + .long 4259072556 + .long 3191035622 + .long 3221225472 + .long 1072588769 + .long 3613088753 + .long 3192165681 + .long 2147483648 + .long 1072584822 + .long 3175234446 + .long 1039486948 + .long 1610612736 + .long 1072580880 + .long 856576441 + .long 1045702812 + .long 2147483648 + .long 1072576943 + .long 2253498719 + .long 3193285334 + .long 2684354560 + .long 1072573011 + .long 1587070728 + .long 3190801577 + .long 3758096384 + .long 1072569084 + .long 159986317 + .long 1042519436 + .long 1073741824 + .long 1072565163 + .long 3999541949 + .long 3192020440 + .long 2684354560 + .long 1072561246 + .long 3281310262 + .long 1045586786 + .long 536870912 + .long 1072557335 + .long 3775179406 + .long 1045226055 + .long 3221225472 + .long 1072553428 + .long 643472356 + .long 3193681786 + .long 1073741824 + .long 1072549527 + .long 248169775 + .long 1045068977 + .long 3758096384 + .long 1072545630 + .long 307016632 + .long 1042640932 + .long 2147483648 + .long 1072541739 + .long 3872718526 + .long 3189781486 + .long 536870912 + .long 1072537853 + .long 969711630 + .long 3191724732 + .long 3221225472 + .long 1072533971 + .long 4018820394 + .long 3193189264 + .long 1073741824 + .long 1072530095 + .long 3102233092 + .long 1045510224 + .long 3758096384 + .long 1072526223 + .long 1029307912 + .long 3193812776 + .long 1073741824 + .long 1072522357 + .long 984083153 + .long 1045987403 + .long 3221225472 + .long 1072518495 + .long 4171455401 + .long 3193084080 + .long 0 + .long 1072514639 + .long 2592660757 + .long 1046121691 + .long 1073741824 + .long 1072510787 + .long 2964365712 + .long 1046054453 + .long 2147483648 + .long 1072506940 + .long 3792777877 + .long 3193704729 + .long 2147483648 + .long 1072503098 + .long 2948536104 + .long 3192467100 + .long 1610612736 + .long 1072499261 + .long 3836005619 + .long 1041873166 + .long 536870912 + .long 1072495429 + .long 3124543160 + .long 1044409168 + .long 3221225472 + .long 1072491601 + .long 286227933 + .long 1041065990 + .long 1073741824 + .long 1072487779 + .long 2111296776 + .long 3193604419 + .long 2147483648 + .long 1072483961 + .long 2606822001 + .long 3192940394 + .long 2147483648 + .long 1072480148 + .long 194696800 + .long 1046026063 + .long 1610612736 + .long 1072476340 + .long 8535452 + .long 1046200178 + .long 536870912 + .long 1072472537 + .long 950463625 + .long 3192731897 + .long 2147483648 + .long 1072468738 + .long 973831566 + .long 1045683197 + .long 3221225472 + .long 1072464944 + .long 3330435892 + .long 3190277577 + .long 3221225472 + .long 1072461155 + .long 208692097 + .long 3193517651 + .long 1610612736 + .long 1072457371 + .long 2113097415 + .long 1044781749 + .long 3758096384 + .long 1072453591 + .long 1088808936 + .long 3193716142 + .long 0 + .long 1072449817 + .long 1443002127 + .long 3193250205 + .long 3221225472 + .long 1072446046 + .long 3967357419 + .long 1046109477 + .long 1610612736 + .long 1072442281 + .long 3013517861 + .long 3193159691 + .long 2147483648 + .long 1072438520 + .long 2524586286 + .long 1046121951 + .long 1610612736 + .long 1072434764 + .long 1476892861 + .long 1046434731 + .long 0 + .long 1072431013 + .long 3089640950 + .long 3192305780 + .long 536870912 + .long 1072427266 + .long 3812255529 + .long 1045730879 + .long 0 + .long 1072423524 + .long 995354762 + .long 3191528673 + .long 1610612736 + .long 1072419786 + .long 3260567684 + .long 1046273695 + .long 2147483648 + .long 1072416053 + .long 2738210286 + .long 3191471516 + .long 536870912 + .long 1072412325 + .long 1931849805 + .long 1044560405 + .long 1610612736 + .long 1072408601 + .long 358896655 + .long 1044029237 + .long 1073741824 + .long 1072404882 + .long 2214589842 + .long 3193202126 + .long 2684354560 + .long 1072401167 + .long 3118097363 + .long 3192592906 + .long 2147483648 + .long 1072397457 + .long 1835998884 + .long 1045788247 + .long 0 + .long 1072393752 + .long 1585488319 + .long 1045289910 + .long 0 + .long 1072390051 + .long 480160949 + .long 1046030455 + .long 2684354560 + .long 1072386354 + .long 1832959667 + .long 3193013644 + .long 2684354560 + .long 1072382662 + .long 3611346555 + .long 1044544210 + .long 1073741824 + .long 1072378975 + .long 2749418734 + .long 3193712580 + .long 1073741824 + .long 1072375292 + .long 2390043472 + .long 3191710658 + .long 3221225472 + .long 1072371613 + .long 2828199902 + .long 1042265217 + .long 3221225472 + .long 1072367939 + .long 569209321 + .long 3191230982 + .long 536870912 + .long 1072364270 + .long 236159139 + .long 1046240123 + .long 536870912 + .long 1072360605 + .long 1010656270 + .long 3193813968 + .long 1610612736 + .long 1072356944 + .long 2409080597 + .long 1044025029 + .long 536870912 + .long 1072353288 + .long 598419513 + .long 1043327370 + .long 1073741824 + .long 1072349636 + .long 4105950479 + .long 1045747958 + .long 3758096384 + .long 1072345988 + .long 343243853 + .long 3192420172 + .long 3221225472 + .long 1072342345 + .long 2088439530 + .long 1046172091 + .long 536870912 + .long 1072338707 + .long 4117721107 + .long 1043882496 + .long 3758096384 + .long 1072335072 + .long 3192032958 + .long 3192998645 + .long 3758096384 + .long 1072331442 + .long 2366522518 + .long 1045401957 + .long 1610612736 + .long 1072327817 + .long 3685533141 + .long 3193701947 + .long 536870912 + .long 1072324196 + .long 1058658672 + .long 3193572492 + .long 536870912 + .long 1072320579 + .long 166346347 + .long 1045456348 + .long 2147483648 + .long 1072316966 + .long 2027889772 + .long 1046349302 + .long 1073741824 + .long 1072313358 + .long 1079497888 + .long 1044585259 + .long 1073741824 + .long 1072309754 + .long 2189851573 + .long 1045132990 + .long 2684354560 + .long 1072306154 + .long 2486629386 + .long 3193613625 + .long 536870912 + .long 1072302559 + .long 1263686579 + .long 1044789259 + .long 0 + .long 1072298968 + .long 2412061798 + .long 3191369627 + .long 536870912 + .long 1072295381 + .long 584315716 + .long 3193144135 + .long 1610612736 + .long 1072291798 + .long 449000738 + .long 1046330451 + .long 0 + .long 1072288220 + .long 3938320157 + .long 1044446220 + .long 3758096384 + .long 1072284645 + .long 2949844595 + .long 3193462371 + .long 3758096384 + .long 1072281075 + .long 2771329642 + .long 3192121593 + .long 536870912 + .long 1072277510 + .long 3971508621 + .long 3193002806 + .long 2147483648 + .long 1072273948 + .long 4071942301 + .long 1044952619 + .long 536870912 + .long 1072270391 + .long 2090502395 + .long 1044660556 + .long 0 + .long 1072266838 + .long 3657520961 + .long 3193770938 + .long 3758096384 + .long 1072263288 + .long 1608175110 + .long 1045543239 + .long 0 + .long 1072259744 + .long 2506924180 + .long 1045530501 + .long 1073741824 + .long 1072256203 + .long 18238493 + .long 1046305623 + .long 3221225472 + .long 1072252666 + .long 3862640487 + .long 3192882407 + .long 1073741824 + .long 1072249134 + .long 3850158761 + .long 1043656099 + .long 3758096384 + .long 1072245605 + .long 2356524356 + .long 1045915296 + .long 3221225472 + .long 1072242081 + .long 936497287 + .long 3193842353 + .long 2147483648 + .long 1072238561 + .long 2840845344 + .long 1046454771 + .long 2147483648 + .long 1072235045 + .long 3688100713 + .long 1044895451 + .long 2684354560 + .long 1072231533 + .long 479979913 + .long 3193842442 + .long 2684354560 + .long 1072228025 + .long 1016321898 + .long 1046251032 + .long 3758096384 + .long 1072224521 + .long 562232474 + .long 3191974558 + .long 536870912 + .long 1072221022 + .long 3870512029 + .long 3193113881 + .long 1610612736 + .long 1072217526 + .long 1239780547 + .long 3191583604 + .long 2684354560 + .long 1072214034 + .long 2815421327 + .long 1045873682 + .long 0 + .long 1072210547 + .long 2371009561 + .long 1041508792 + .long 1610612736 + .long 1072207063 + .long 1304636524 + .long 3192414284 + .long 3221225472 + .long 1072203583 + .long 210144854 + .long 3193327333 + .long 0 + .long 1072200108 + .long 1454303272 + .long 1046360024 + .long 1610612736 + .long 1072196636 + .long 2095757548 + .long 1044984677 + .long 3221225472 + .long 1072193168 + .long 2027215580 + .long 3192880933 + .long 0 + .long 1072189705 + .long 214794880 + .long 1043457954 + .long 1073741824 + .long 1072186245 + .long 884624917 + .long 1043497079 + .long 2147483648 + .long 1072182789 + .long 2792396634 + .long 3193171685 + .long 2684354560 + .long 1072179337 + .long 4128995250 + .long 3192103434 + .long 2684354560 + .long 1072175889 + .long 333866043 + .long 1046372325 + .long 3221225472 + .long 1072172445 + .long 2194445544 + .long 3193958905 + .long 2684354560 + .long 1072169005 + .long 2316082269 + .long 3192041703 + .long 1610612736 + .long 1072165569 + .long 581005057 + .long 1046322848 + .long 536870912 + .long 1072162137 + .long 3280786513 + .long 1045457251 + .long 3221225472 + .long 1072158708 + .long 2567093361 + .long 1044710359 + .long 1073741824 + .long 1072155284 + .long 3740443584 + .long 1044224237 + .long 2684354560 + .long 1072151863 + .long 3981028272 + .long 1042596351 + .long 3758096384 + .long 1072148446 + .long 3820011120 + .long 3191915623 + .long 0 + .long 1072145034 + .long 2946439484 + .long 3193831276 + .long 3758096384 + .long 1072141624 + .long 3075274422 + .long 3190132432 + .long 2684354560 + .long 1072138219 + .long 496052167 + .long 1043619760 + .long 1073741824 + .long 1072134818 + .long 271106589 + .long 3192265149 + .long 2684354560 + .long 1072131420 + .long 2091955684 + .long 1044443554 + .long 3758096384 + .long 1072128026 + .long 723240109 + .long 3191007419 + .long 3758096384 + .long 1072124636 + .long 1748629070 + .long 1044510075 + .long 3221225472 + .long 1072121250 + .long 3289522046 + .long 3193095178 + .long 1610612736 + .long 1072117868 + .long 3599052146 + .long 3193720427 + .long 3221225472 + .long 1072114489 + .long 2446758135 + .long 3193436303 + .long 3758096384 + .long 1072111114 + .long 1652171097 + .long 3192137173 + .long 3221225472 + .long 1072107743 + .long 1353007155 + .long 1044523902 + .long 1610612736 + .long 1072104376 + .long 990601105 + .long 1046296663 + .long 3758096384 + .long 1072101012 + .long 2228627618 + .long 3193041040 + .long 0 + .long 1072097653 + .long 812484756 + .long 3191950723 + .long 3758096384 + .long 1072094296 + .long 817833130 + .long 3192279242 + .long 2147483648 + .long 1072090944 + .long 3563228521 + .long 3193810951 + .long 3221225472 + .long 1072087595 + .long 2729108859 + .long 3190936185 + .long 3221225472 + .long 1072084250 + .long 2249121662 + .long 3190639690 + .long 2147483648 + .long 1072080909 + .long 4082471745 + .long 3193929368 + .long 3758096384 + .long 1072077571 + .long 2827323806 + .long 3193708561 + .long 3758096384 + .long 1072074237 + .long 735866167 + .long 1042434690 + .long 2684354560 + .long 1072070907 + .long 3240808889 + .long 3191918422 + .long 0 + .long 1072067581 + .long 466482777 + .long 3186962221 + .long 0 + .long 1072064258 + .long 1576076296 + .long 1045849056 + .long 3221225472 + .long 1072060938 + .long 2751923560 + .long 3191910703 + .long 0 + .long 1072057623 + .long 1908755527 + .long 1046437515 + .long 0 + .long 1072054311 + .long 3175841411 + .long 1044572886 + .long 2684354560 + .long 1072051002 + .long 1633258450 + .long 3192670420 + .long 3221225472 + .long 1072047697 + .long 1867746657 + .long 1045726209 + .long 2684354560 + .long 1072044396 + .long 338968864 + .long 3193084662 + .long 0 + .long 1072041099 + .long 1501742471 + .long 3191742031 + .long 0 + .long 1072037805 + .long 4266775786 + .long 3192686970 + .long 2147483648 + .long 1072034514 + .long 4249283553 + .long 1045769728 + .long 2684354560 + .long 1072031227 + .long 2758366873 + .long 1046402161 + .long 1610612736 + .long 1072027944 + .long 2161186990 + .long 1044736865 + .long 2684354560 + .long 1072024664 + .long 810300171 + .long 1045748777 + .long 2147483648 + .long 1072021388 + .long 183688927 + .long 3191515581 + .long 3758096384 + .long 1072018115 + .long 368874072 + .long 3192363575 + .long 3221225472 + .long 1072014846 + .long 2459092970 + .long 1041794640 + .long 536870912 + .long 1072011581 + .long 867488640 + .long 1046310291 + .long 536870912 + .long 1072008319 + .long 50140871 + .long 1043327329 + .long 2684354560 + .long 1072005060 + .long 1241902518 + .long 3192739252 + .long 2684354560 + .long 1072001805 + .long 1027881659 + .long 3193858388 + .long 0 + .long 1071998554 + .long 38457322 + .long 1045489179 + .long 0 + .long 1071995306 + .long 3432963337 + .long 3190969347 + .long 1610612736 + .long 1071992061 + .long 534931792 + .long 1046302734 + .long 1610612736 + .long 1071988820 + .long 1817895268 + .long 3192551860 + .long 3221225472 + .long 1071985582 + .long 357237383 + .long 3191870833 + .long 2684354560 + .long 1071982348 + .long 108262401 + .long 3193365867 + .long 3758096384 + .long 1071979117 + .long 1964729244 + .long 1042502249 + .long 2684354560 + .long 1071975890 + .long 2088446957 + .long 1038010503 + .long 3221225472 + .long 1071972666 + .long 2947239447 + .long 1046377845 + .long 1610612736 + .long 1071969446 + .long 774932072 + .long 1046064854 + .long 2147483648 + .long 1071966229 + .long 4080937590 + .long 3193041284 + .long 3758096384 + .long 1071963015 + .long 2208251454 + .long 1045945089 + .long 3221225472 + .long 1071959805 + .long 2850924475 + .long 1045650959 + .long 0 + .long 1071956599 + .long 714040997 + .long 1046275153 + .long 3221225472 + .long 1071953395 + .long 85533782 + .long 3192816920 + .long 3221225472 + .long 1071950195 + .long 1252511005 + .long 1044805706 + .long 1073741824 + .long 1071946999 + .long 2384659038 + .long 3193391602 + .long 0 + .long 1071943806 + .long 416481813 + .long 1043730233 + .long 536870912 + .long 1071940616 + .long 1675424499 + .long 1046348030 + .long 3221225472 + .long 1071937429 + .long 1175989513 + .long 3193009113 + .long 2684354560 + .long 1071934246 + .long 2400084650 + .long 3192451713 + .long 3758096384 + .long 1071931066 + .long 1467335692 + .long 3193350868 + .long 1610612736 + .long 1071927890 + .long 266493801 + .long 1044954481 + .long 1073741824 + .long 1071924717 + .long 3919093445 + .long 1046023575 + .long 2147483648 + .long 1071921547 + .long 3017408483 + .long 1044880828 + .long 536870912 + .long 1071918381 + .long 948849966 + .long 3193892224 + .long 3758096384 + .long 1071915217 + .long 1870232600 + .long 1045777228 + .long 536870912 + .long 1071912058 + .long 822381492 + .long 3193639186 + .long 2147483648 + .long 1071908901 + .long 788243705 + .long 1044966343 + .long 1073741824 + .long 1071905748 + .long 1344278809 + .long 1044428545 + .long 1073741824 + .long 1071902598 + .long 172864300 + .long 1045765608 + .long 2684354560 + .long 1071899451 + .long 211555467 + .long 3192963574 + .long 536870912 + .long 1071896308 + .long 3373438023 + .long 1045643168 + .long 0 + .long 1071893168 + .long 2867180960 + .long 3189945998 + .long 536870912 + .long 1071890031 + .long 36724362 + .long 3193240584 + .long 1610612736 + .long 1071886897 + .long 2140176984 + .long 1045945349 + .long 0 + .long 1071883767 + .long 436842360 + .long 1040712587 + .long 3758096384 + .long 1071880639 + .long 1225147329 + .long 3193814594 + .long 3758096384 + .long 1071877515 + .long 1586157348 + .long 3191614322 + .long 536870912 + .long 1071874395 + .long 3329332918 + .long 1041699791 + .long 2684354560 + .long 1071871277 + .long 1635968041 + .long 3191783756 + .long 1073741824 + .long 1071868163 + .long 2876158382 + .long 1046097093 + .long 1073741824 + .long 1071865052 + .long 4267556964 + .long 3193723000 + .long 1073741824 + .long 1071861944 + .long 195475940 + .long 1045520795 + .long 2147483648 + .long 1071858839 + .long 2239193514 + .long 1046478675 + .long 0 + .long 1071855738 + .long 4168275596 + .long 1044926285 + .long 2684354560 + .long 1071852639 + .long 142514114 + .long 1045595182 + .long 2147483648 + .long 1071849544 + .long 1943457984 + .long 3192930015 + .long 2147483648 + .long 1071846452 + .long 202659489 + .long 3193926317 + .long 2684354560 + .long 1071843363 + .long 2208408789 + .long 3193857484 + .long 3758096384 + .long 1071840277 + .long 2237297552 + .long 3192939576 + .long 1073741824 + .long 1071837195 + .long 2726920839 + .long 1044193954 + .long 3758096384 + .long 1071834115 + .long 2337732207 + .long 3193611773 + .long 2147483648 + .long 1071831039 + .long 1390088602 + .long 1044000317 + .long 1610612736 + .long 1071827966 + .long 3806188736 + .long 3193463913 + .long 1073741824 + .long 1071824896 + .long 1795276560 + .long 1043671965 + .long 1073741824 + .long 1071821829 + .long 2960792799 + .long 1046240474 + .long 2147483648 + .long 1071818765 + .long 3350591592 + .long 3193333939 + .long 3221225472 + .long 1071815704 + .long 408870754 + .long 3193322854 + .long 0 + .long 1071812647 + .long 4146717132 + .long 1046063520 + .long 2147483648 + .long 1071809592 + .long 1681114919 + .long 3192114313 + .long 0 + .long 1071806541 + .long 1098393137 + .long 3190846732 + .long 2684354560 + .long 1071803492 + .long 2437484983 + .long 3193448718 + .long 1073741824 + .long 1071800447 + .long 1036809185 + .long 3192023501 + .long 0 + .long 1071797405 + .long 659668848 + .long 3193596312 + .long 3221225472 + .long 1071794365 + .long 1112062459 + .long 3192773376 + .long 2147483648 + .long 1071791329 + .long 4082956335 + .long 1045830513 + .long 1610612736 + .long 1071788296 + .long 2387089965 + .long 1045532601 + .long 1610612736 + .long 1071785266 + .long 1522101980 + .long 3193941957 + .long 1073741824 + .long 1071782239 + .long 2157197585 + .long 3188193305 + .long 1073741824 + .long 1071779215 + .long 946810220 + .long 3193223819 + .long 1073741824 + .long 1071776194 + .long 4069942444 + .long 3193878549 + .long 536870912 + .long 1071773176 + .long 1693463440 + .long 1046360588 + .long 536870912 + .long 1071770161 + .long 1954543254 + .long 1046409381 + .long 1073741824 + .long 1071767149 + .long 1050471249 + .long 3193933095 + .long 536870912 + .long 1071764140 + .long 1256240478 + .long 1046456865 + .long 536870912 + .long 1071761134 + .long 676764254 + .long 1046055503 + .long 536870912 + .long 1071758131 + .long 1421032967 + .long 1044779786 + .long 536870912 + .long 1071755131 + .long 38735992 + .long 3192766355 + .long 0 + .long 1071752134 + .long 2960669690 + .long 1044484680 + .long 3758096384 + .long 1071749139 + .long 788707382 + .long 1045299895 + .long 3221225472 + .long 1071746148 + .long 685689300 + .long 1040778831 + .long 2147483648 + .long 1071743160 + .long 1170994182 + .long 1046159174 + .long 1073741824 + .long 1071740175 + .long 64591436 + .long 1046153849 + .long 0 + .long 1071737193 + .long 2338031659 + .long 3189997702 + .long 2684354560 + .long 1071734213 + .long 1941624568 + .long 3186752676 + .long 536870912 + .long 1071731237 + .long 1401255580 + .long 1046383990 + .long 2684354560 + .long 1071728263 + .long 376888427 + .long 1045896456 + .long 536870912 + .long 1071725293 + .long 2831424639 + .long 3193539109 + .long 1610612736 + .long 1071722325 + .long 3303123696 + .long 1044599415 + .long 2684354560 + .long 1071719360 + .long 1077295329 + .long 3189877372 + .long 3221225472 + .long 1071716398 + .long 1434061099 + .long 3184529771 + .long 3221225472 + .long 1071713439 + .long 2104991590 + .long 1045062074 + .long 3221225472 + .long 1071710483 + .long 722060869 + .long 3193788526 + .long 536870912 + .long 1071704580 + .long 3928796486 + .long 1046129020 + .long 536870912 + .long 1071698688 + .long 588844628 + .long 1045492135 + .long 2684354560 + .long 1071692807 + .long 326739366 + .long 3193004445 + .long 1610612736 + .long 1071686938 + .long 2456436042 + .long 1046278169 + .long 2684354560 + .long 1071681080 + .long 2831303512 + .long 1043670046 + .long 536870912 + .long 1071675234 + .long 607223418 + .long 1045507322 + .long 0 + .long 1071669399 + .long 4254921332 + .long 3193290483 + .long 0 + .long 1071663575 + .long 914994333 + .long 3191263853 + .long 1073741824 + .long 1071657762 + .long 4147050180 + .long 3193228552 + .long 2684354560 + .long 1071651960 + .long 594554157 + .long 3193503935 + .long 0 + .long 1071646170 + .long 1062846796 + .long 1045944331 + .long 1073741824 + .long 1071636109 + .long 2909238893 + .long 3193436884 + .long 1073741824 + .long 1071624572 + .long 1682918119 + .long 1042211899 + .long 1073741824 + .long 1071613057 + .long 2419209426 + .long 1045437062 + .long 1073741824 + .long 1071601564 + .long 2951341321 + .long 3190193214 + .long 0 + .long 1071590093 + .long 3084900875 + .long 3192394907 + .long 1073741824 + .long 1071578643 + .long 999567454 + .long 1046433447 + .long 2147483648 + .long 1071567215 + .long 1570101857 + .long 3193291160 + .long 0 + .long 1071555809 + .long 1080647881 + .long 3185154585 + .long 0 + .long 1071544424 + .long 3526309177 + .long 1044843640 + .long 2147483648 + .long 1071533060 + .long 2213463349 + .long 3191738930 + .long 1073741824 + .long 1071521718 + .long 1039925195 + .long 3192618353 + .long 1073741824 + .long 1071510397 + .long 2115757280 + .long 3193671567 + .long 1073741824 + .long 1071499097 + .long 1188751495 + .long 3191145560 + .long 2147483648 + .long 1071487818 + .long 3983461449 + .long 3193897029 + .long 2147483648 + .long 1071476560 + .long 782141500 + .long 1042879962 + .long 2147483648 + .long 1071465323 + .long 4038904626 + .long 1045063881 + .long 2147483648 + .long 1071454107 + .long 2613036921 + .long 3193217642 + .long 0 + .long 1071442912 + .long 2095723435 + .long 1044629175 + .long 1073741824 + .long 1071431737 + .long 3879795974 + .long 1045767874 + .long 1073741824 + .long 1071420583 + .long 2662198042 + .long 3191434637 + .long 3221225472 + .long 1071409449 + .long 4037605722 + .long 3193703090 + .long 2147483648 + .long 1071398336 + .long 1860331835 + .long 1040814822 + .long 3221225472 + .long 1071387243 + .long 1522972033 + .long 3190305974 + .long 1073741824 + .long 1071376171 + .long 2361534207 + .long 1043699366 + .long 0 + .long 1071365119 + .long 4180309179 + .long 1044142099 + .long 0 + .long 1071354087 + .long 1201038528 + .long 3192968772 + .long 0 + .long 1071343075 + .long 1342478171 + .long 3193251215 + .long 0 + .long 1071332083 + .long 3836883348 + .long 3193472007 + .long 3221225472 + .long 1071321110 + .long 3864874250 + .long 1045593126 + .long 2147483648 + .long 1071310158 + .long 2169494998 + .long 1046045346 + .long 1073741824 + .long 1071299226 + .long 3785165075 + .long 3193319246 + .long 2147483648 + .long 1071288313 + .long 1137692678 + .long 3192716779 + .long 1073741824 + .long 1071277420 + .long 1752107598 + .long 1046366120 + .long 3221225472 + .long 1071266546 + .long 1912656912 + .long 1046352281 + .long 3221225472 + .long 1071255692 + .long 2882676334 + .long 1046406353 + .long 1073741824 + .long 1071244858 + .long 963612460 + .long 1045282811 + .long 0 + .long 1071234043 + .long 3811255773 + .long 1046231636 + .long 1073741824 + .long 1071223247 + .long 1126055989 + .long 3192224037 + .long 2147483648 + .long 1071212470 + .long 2079145427 + .long 1044432413 + .long 0 + .long 1071201713 + .long 3611595621 + .long 1043358745 + .long 2147483648 + .long 1071190974 + .long 390522769 + .long 1045888252 + .long 1073741824 + .long 1071180255 + .long 4087939723 + .long 3192930745 + .long 3221225472 + .long 1071169554 + .long 1451494480 + .long 3190219274 + .long 1073741824 + .long 1071158873 + .long 427176194 + .long 3193042022 + .long 2147483648 + .long 1071148210 + .long 1882381948 + .long 3192727946 + .long 2147483648 + .long 1071137566 + .long 3736313771 + .long 3192087019 + .long 1073741824 + .long 1071126941 + .long 1560398816 + .long 3193185715 + .long 2147483648 + .long 1071116334 + .long 1021942441 + .long 1041526696 + .long 2147483648 + .long 1071105746 + .long 3517080249 + .long 3193576041 + .long 3221225472 + .long 1071095176 + .long 2248589878 + .long 1044527624 + .long 2147483648 + .long 1071084625 + .long 2412896695 + .long 1046112867 + .long 3221225472 + .long 1071074092 + .long 3834725738 + .long 1044562378 + .long 1073741824 + .long 1071063578 + .long 1150920407 + .long 1043768986 + .long 0 + .long 1071053082 + .long 1379393428 + .long 3188690690 + .long 0 + .long 1071042604 + .long 3058183278 + .long 3193617655 + .long 0 + .long 1071032144 + .long 421133665 + .long 3193417186 + .long 0 + .long 1071021702 + .long 2860161357 + .long 3191816125 + .long 0 + .long 1071011278 + .long 1742405964 + .long 1043580240 + .long 0 + .long 1071000872 + .long 2821215927 + .long 3188984273 + .long 3221225472 + .long 1070990483 + .long 510275597 + .long 1045813401 + .long 2147483648 + .long 1070980113 + .long 304266588 + .long 3191193536 + .long 3221225472 + .long 1070969760 + .long 1854784211 + .long 1046302073 + .long 0 + .long 1070959426 + .long 3773082854 + .long 3193008899 + .long 2147483648 + .long 1070949108 + .long 3003572392 + .long 1046404879 + .long 3221225472 + .long 1070938808 + .long 1702149204 + .long 1046407257 + .long 2147483648 + .long 1070928526 + .long 3935314439 + .long 1046438280 + .long 3221225472 + .long 1070918261 + .long 2677087609 + .long 1045501749 + .long 2147483648 + .long 1070908014 + .long 4190598039 + .long 3193640515 + .long 1073741824 + .long 1070897784 + .long 368874072 + .long 1044879927 + .long 2147483648 + .long 1070887571 + .long 3584052697 + .long 3192024662 + .long 3221225472 + .long 1070877375 + .long 3762307829 + .long 1045886918 + .long 1073741824 + .long 1070867197 + .long 495710920 + .long 1046317072 + .long 0 + .long 1070857036 + .long 2292768238 + .long 3190887508 + .long 3221225472 + .long 1070846891 + .long 1044078151 + .long 3193772914 + .long 1073741824 + .long 1070836764 + .long 3266010457 + .long 1043443755 + .long 3221225472 + .long 1070826653 + .long 3571665822 + .long 1045547823 + .long 1073741824 + .long 1070816560 + .long 393348347 + .long 3190525143 + .long 2147483648 + .long 1070806483 + .long 4241722498 + .long 3192084193 + .long 2147483648 + .long 1070796423 + .long 1693797068 + .long 3192807972 + .long 0 + .long 1070786380 + .long 2860086745 + .long 1046331646 + .long 2147483648 + .long 1070776353 + .long 1366141759 + .long 3192979363 + .long 1073741824 + .long 1070766343 + .long 737899283 + .long 1045853346 + .long 3221225472 + .long 1070756349 + .long 88734873 + .long 1043881257 + .long 3221225472 + .long 1070746372 + .long 1438003315 + .long 3192917101 + .long 0 + .long 1070736412 + .long 1066505530 + .long 1043896695 + .long 3221225472 + .long 1070726467 + .long 2706653041 + .long 3191113643 + .long 3221225472 + .long 1070716539 + .long 1321764476 + .long 1039573724 + .long 0 + .long 1070706628 + .long 1126753211 + .long 1044502976 + .long 2147483648 + .long 1070696732 + .long 773642884 + .long 1044110727 + .long 1073741824 + .long 1070686853 + .long 1263743406 + .long 3193115278 + .long 0 + .long 1070676990 + .long 3115237732 + .long 3193089176 + .long 3221225472 + .long 1070667142 + .long 3642626838 + .long 3191146032 + .long 2147483648 + .long 1070657311 + .long 2091696428 + .long 1044337177 + .long 1073741824 + .long 1070647496 + .long 3168958391 + .long 1044197568 + .long 0 + .long 1070637697 + .long 711148669 + .long 3193181047 + .long 2147483648 + .long 1070627913 + .long 4207182773 + .long 3193402092 + .long 3221225472 + .long 1070618145 + .long 918070640 + .long 3192902845 + .long 3221225472 + .long 1070608393 + .long 3135571447 + .long 3192193928 + .long 2147483648 + .long 1070598657 + .long 1043705517 + .long 3193188604 + .long 2147483648 + .long 1070581777 + .long 1886680492 + .long 1043890286 + .long 2147483648 + .long 1070562367 + .long 3373799420 + .long 3191917802 + .long 2147483648 + .long 1070542988 + .long 2919618025 + .long 3192461752 + .long 2147483648 + .long 1070523640 + .long 2926365158 + .long 3193113492 + .long 0 + .long 1070504323 + .long 519978638 + .long 1045918846 + .long 0 + .long 1070485037 + .long 3665353151 + .long 3193546248 + .long 0 + .long 1070465781 + .long 2327718958 + .long 1045050797 + .long 0 + .long 1070446556 + .long 345326861 + .long 3188224716 + .long 2147483648 + .long 1070427361 + .long 2263747488 + .long 3192871328 + .long 0 + .long 1070408197 + .long 3894192264 + .long 1045693123 + .long 0 + .long 1070389063 + .long 994321593 + .long 1046347203 + .long 2147483648 + .long 1070369959 + .long 3540366700 + .long 1042296230 + .long 0 + .long 1070350886 + .long 966420752 + .long 3192400412 + .long 2147483648 + .long 1070331842 + .long 1954511160 + .long 3193467762 + .long 2147483648 + .long 1070312828 + .long 1875003040 + .long 1045485629 + .long 0 + .long 1070293845 + .long 4003372005 + .long 3193714109 + .long 2147483648 + .long 1070274890 + .long 2216083644 + .long 1045720399 + .long 0 + .long 1070255966 + .long 1240985743 + .long 1045879414 + .long 0 + .long 1070237071 + .long 1573064162 + .long 1046427916 + .long 0 + .long 1070218206 + .long 2500166582 + .long 3193848169 + .long 2147483648 + .long 1070199369 + .long 862131539 + .long 1045606065 + .long 0 + .long 1070180563 + .long 3733427622 + .long 3193545988 + .long 0 + .long 1070161785 + .long 124515358 + .long 1045504766 + .long 2147483648 + .long 1070143036 + .long 689228007 + .long 1044238436 + .long 0 + .long 1070124317 + .long 976284835 + .long 3189879978 + .long 2147483648 + .long 1070105626 + .long 2997446224 + .long 3193394244 + .long 2147483648 + .long 1070086964 + .long 594985163 + .long 3190453447 + .long 2147483648 + .long 1070068331 + .long 3634411091 + .long 3193012662 + .long 0 + .long 1070049727 + .long 841316482 + .long 3192551604 + .long 0 + .long 1070031151 + .long 518949849 + .long 3189505693 + .long 2147483648 + .long 1070012603 + .long 207633604 + .long 1043791305 + .long 2147483648 + .long 1069994084 + .long 925415631 + .long 3189658670 + .long 2147483648 + .long 1069975593 + .long 3348775015 + .long 1046231055 + .long 0 + .long 1069957131 + .long 4137593961 + .long 1045760644 + .long 2147483648 + .long 1069938696 + .long 3081207972 + .long 1046319652 + .long 2147483648 + .long 1069920290 + .long 2912811806 + .long 3193250863 + .long 0 + .long 1069901912 + .long 1704663230 + .long 3192651171 + .long 2147483648 + .long 1069883561 + .long 1726887473 + .long 3193427817 + .long 2147483648 + .long 1069865238 + .long 516302873 + .long 1042556919 + .long 2147483648 + .long 1069846943 + .long 3737277289 + .long 3192083505 + .long 0 + .long 1069828676 + .long 2829909067 + .long 3191628520 + .long 0 + .long 1069810436 + .long 3474800299 + .long 3187384991 + .long 2147483648 + .long 1069792223 + .long 2041291754 + .long 3186735048 + .long 2147483648 + .long 1069774038 + .long 3100739290 + .long 3192991951 + .long 2147483648 + .long 1069755880 + .long 2641686866 + .long 1042449846 + .long 0 + .long 1069737750 + .long 1353612457 + .long 3192928544 + .long 2147483648 + .long 1069719646 + .long 1823398190 + .long 3193125156 + .long 0 + .long 1069701570 + .long 2629108558 + .long 3192983089 + .long 2147483648 + .long 1069683520 + .long 314889080 + .long 3193178947 + .long 2147483648 + .long 1069665497 + .long 3426846470 + .long 1046055034 + .long 0 + .long 1069647502 + .long 2451521798 + .long 3193081447 + .long 2147483648 + .long 1069629532 + .long 963200030 + .long 1046315089 + .long 0 + .long 1069611590 + .long 3644976987 + .long 1046450297 + .long 2147483648 + .long 1069593674 + .long 1514045874 + .long 3193337489 + .long 0 + .long 1069575785 + .long 2640752615 + .long 3192734715 + .long 0 + .long 1069557922 + .long 177381730 + .long 3193107348 + .long 0 + .long 1069532650 + .long 546871269 + .long 1045601847 + .long 0 + .long 1069497029 + .long 2220408187 + .long 1045964849 + .long 0 + .long 1069461461 + .long 3101209784 + .long 3192417098 + .long 0 + .long 1069425944 + .long 3768825782 + .long 1046196178 + .long 0 + .long 1069390480 + .long 737308942 + .long 1043872555 + .long 0 + .long 1069355068 + .long 1944808119 + .long 3193362317 + .long 0 + .long 1069319707 + .long 852406261 + .long 3191004250 + .long 0 + .long 1069284398 + .long 3202370743 + .long 3192549796 + .long 0 + .long 1069249140 + .long 900633975 + .long 1043862575 + .long 0 + .long 1069213934 + .long 3417168564 + .long 3193213168 + .long 0 + .long 1069178778 + .long 2513309972 + .long 1046051953 + .long 0 + .long 1069143674 + .long 1836846968 + .long 1044036653 + .long 0 + .long 1069108621 + .long 675391362 + .long 3193334972 + .long 0 + .long 1069073618 + .long 1859398086 + .long 3191668729 + .long 0 + .long 1069038666 + .long 3835994043 + .long 3193252196 + .long 0 + .long 1069003764 + .long 563337246 + .long 3192060530 + .long 0 + .long 1068968912 + .long 3715154210 + .long 1045592716 + .long 0 + .long 1068934111 + .long 51415636 + .long 3192193939 + .long 0 + .long 1068899359 + .long 822049108 + .long 1045846080 + .long 0 + .long 1068864658 + .long 3739043340 + .long 3193184949 + .long 0 + .long 1068830006 + .long 2500828997 + .long 3193115638 + .long 0 + .long 1068795403 + .long 1479335089 + .long 1045458233 + .long 0 + .long 1068760850 + .long 1914098598 + .long 1045079833 + .long 0 + .long 1068726346 + .long 1470374909 + .long 1046125471 + .long 0 + .long 1068691892 + .long 2048101185 + .long 3192960024 + .long 0 + .long 1068657486 + .long 801101802 + .long 1042523454 + .long 0 + .long 1068623129 + .long 412171467 + .long 1044799425 + .long 0 + .long 1068588821 + .long 2124566049 + .long 1040459843 + .long 0 + .long 1068554561 + .long 2087558263 + .long 1046083102 + .long 0 + .long 1068520350 + .long 290389316 + .long 1045220023 + .long 0 + .long 1068473430 + .long 393737815 + .long 1045770085 + .long 0 + .long 1068405202 + .long 3273111658 + .long 3193594336 + .long 0 + .long 1068337068 + .long 3076935419 + .long 3191993934 + .long 0 + .long 1068269030 + .long 1564279721 + .long 1040713632 + .long 0 + .long 1068201088 + .long 1950103787 + .long 3191285473 + .long 0 + .long 1068133240 + .long 111301617 + .long 1046140470 + .long 0 + .long 1068065488 + .long 2740933659 + .long 1046091898 + .long 0 + .long 1067997832 + .long 1267131462 + .long 3192947024 + .long 0 + .long 1067930268 + .long 629787343 + .long 1045599114 + .long 0 + .long 1067862800 + .long 2943029746 + .long 3191100621 + .long 0 + .long 1067795426 + .long 2538631151 + .long 3193953989 + .long 0 + .long 1067728144 + .long 3881795033 + .long 3191377363 + .long 0 + .long 1067660956 + .long 2752747058 + .long 3186250103 + .long 0 + .long 1067593862 + .long 892170014 + .long 3193330390 + .long 0 + .long 1067526860 + .long 2000985783 + .long 3192968647 + .long 0 + .long 1067459950 + .long 1954077304 + .long 1044399908 + .long 0 + .long 1067335900 + .long 4120702847 + .long 3193150730 + .long 0 + .long 1067202448 + .long 353489980 + .long 1045676744 + .long 0 + .long 1067069184 + .long 2609643324 + .long 3192108001 + .long 0 + .long 1066936100 + .long 2904433317 + .long 1044836541 + .long 0 + .long 1066803200 + .long 319656790 + .long 1044863904 + .long 0 + .long 1066670484 + .long 2407987331 + .long 3192995083 + .long 0 + .long 1066537948 + .long 2437746120 + .long 3193127733 + .long 0 + .long 1066405592 + .long 762570215 + .long 3189946997 + .long 0 + .long 1066145040 + .long 3317159694 + .long 1046060125 + .long 0 + .long 1065881056 + .long 2317845886 + .long 3191679176 + .long 0 + .long 1065617424 + .long 3665195816 + .long 1045633853 + .long 0 + .long 1065354160 + .long 2008730355 + .long 3193898211 + .long 0 + .long 1064829264 + .long 3746236192 + .long 1046121471 + .long 0 + .long 1064303680 + .long 885296753 + .long 3191852441 + .long 0 + .long 1063253696 + .long 449976495 + .long 3192682663 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 4294965248 + .long 0 + .long 4294965248 + .long 0 + .long 1073160192 + .long 370913857 + .long 3210587105 + .long 1841914130 + .long 3213059448 + .long 3995341938 + .long 3214607105 + .long 2677381210 + .long 3216320731 + .long 3011779882 + .long 3218479542 + .long 1367832035 + .long 1066403058 + .long 2894285243 + .long 1067936923 + .long 1215221452 + .long 1069835102 + .long 370913857 + .long 3210587105 + .long 2677381210 + .long 3216320731 + .long 4172642429 + .long 1056068382 + .long 1215221451 + .long 1069835102 + .long 1092638156 + .long 3184925618 + .long 0 + .long 4294967288 + .long 0 + .long 4294967295 + .long 0 + .long 1072693248 + .long 0 + .long 997195776 + .long 4200250559 + .long 1072696090 + .long 2808127345 + .long 3162830514 + .long 2851812149 + .long 1072698941 + .long 2595802551 + .long 1016815913 + .long 339411585 + .long 1072701800 + .long 264588982 + .long 3162685233 + .long 1048019041 + .long 1072704666 + .long 1398474845 + .long 3161559171 + .long 772914124 + .long 1072707540 + .long 4004372762 + .long 1013278737 + .long 3899555717 + .long 1072710421 + .long 427280750 + .long 3163595548 + .long 1928746161 + .long 1072713311 + .long 983617676 + .long 1015333753 + .long 3541402996 + .long 1072716208 + .long 2759177317 + .long 1015903202 + .long 238821257 + .long 1072719114 + .long 1469694871 + .long 3163933563 + .long 702412510 + .long 1072722027 + .long 3803266087 + .long 3163328991 + .long 728934454 + .long 1072724948 + .long 1413842688 + .long 1015227188 + .long 410360776 + .long 1072727877 + .long 1269990655 + .long 1013024446 + .long 4133881824 + .long 1072730813 + .long 2148155345 + .long 3163979875 + .long 3402036099 + .long 1072733758 + .long 405889334 + .long 1016154232 + .long 2602514713 + .long 1072736711 + .long 2268929336 + .long 1015402860 + .long 1828292879 + .long 1072739672 + .long 1255956747 + .long 1016636974 + .long 1172597893 + .long 1072742641 + .long 114433263 + .long 1016396169 + .long 728909815 + .long 1072745618 + .long 383930225 + .long 1016078044 + .long 590962156 + .long 1072748603 + .long 3829346666 + .long 3164324173 + .long 852742562 + .long 1072751596 + .long 667253586 + .long 1010842135 + .long 1608493509 + .long 1072754597 + .long 3159622171 + .long 3163856313 + .long 2952712987 + .long 1072757606 + .long 3293494651 + .long 3161168877 + .long 685187902 + .long 1072760624 + .long 378731989 + .long 1015891691 + .long 3490863953 + .long 1072763649 + .long 960797498 + .long 3163997456 + .long 2875075254 + .long 1072766683 + .long 4144233330 + .long 3164382292 + .long 3228316108 + .long 1072769725 + .long 3010241991 + .long 3159471380 + .long 351405227 + .long 1072772776 + .long 3125337328 + .long 3160871055 + .long 2930322912 + .long 1072775834 + .long 2599499422 + .long 3163762623 + .long 2471440686 + .long 1072778901 + .long 968836267 + .long 3163263464 + .long 3366293073 + .long 1072781976 + .long 3119426314 + .long 1015169130 + .long 1416741826 + .long 1072785060 + .long 2196380210 + .long 1012462139 + .long 1014845819 + .long 1072788152 + .long 3117910646 + .long 3162607681 + .long 2257959872 + .long 1072791252 + .long 3802946148 + .long 1014013503 + .long 948735466 + .long 1072794361 + .long 3516338028 + .long 3163623459 + .long 1480023343 + .long 1072797478 + .long 2247196168 + .long 1016376029 + .long 3949972341 + .long 1072800603 + .long 2068408548 + .long 1015962444 + .long 4162030108 + .long 1072803737 + .long 2763428480 + .long 1016577925 + .long 2214878420 + .long 1072806880 + .long 892270087 + .long 3164164998 + .long 2502433899 + .long 1072810031 + .long 2148595913 + .long 1016072567 + .long 828946858 + .long 1072813191 + .long 10642492 + .long 1016988014 + .long 1588871207 + .long 1072816359 + .long 143439582 + .long 3164011992 + .long 586995997 + .long 1072819536 + .long 41662348 + .long 3163676568 + .long 2218315341 + .long 1072822721 + .long 2694295388 + .long 3164337444 + .long 2288159958 + .long 1072825915 + .long 2169144469 + .long 1015924597 + .long 897099801 + .long 1072829118 + .long 754756297 + .long 1016289581 + .long 2440944790 + .long 1072832329 + .long 2492769774 + .long 1015196030 + .long 2725843665 + .long 1072835549 + .long 1433917087 + .long 1015887099 + .long 1853186616 + .long 1072838778 + .long 3066496371 + .long 1016705150 + .long 4219606026 + .long 1072842015 + .long 2434574742 + .long 1015730124 + .long 1337108031 + .long 1072845262 + .long 3203724452 + .long 1015726421 + .long 1897844341 + .long 1072848517 + .long 1254300460 + .long 1016324514 + .long 1709341917 + .long 1072851781 + .long 2571168217 + .long 1015201075 + .long 874372905 + .long 1072855054 + .long 100263788 + .long 1016989308 + .long 3790955393 + .long 1072858335 + .long 2352942462 + .long 3164228666 + .long 1972484976 + .long 1072861626 + .long 675290301 + .long 3162688626 + .long 4112506593 + .long 1072864925 + .long 2947355221 + .long 1015419624 + .long 1724976915 + .long 1072868234 + .long 420909223 + .long 3164165955 + .long 3504003472 + .long 1072871551 + .long 3594001060 + .long 3158379228 + .long 964107055 + .long 1072874878 + .long 2800439588 + .long 3163881797 + .long 2799960843 + .long 1072878213 + .long 1423655381 + .long 1016070727 + .long 526652809 + .long 1072881558 + .long 4223459736 + .long 1016927951 + .long 2839424854 + .long 1072884911 + .long 1171596163 + .long 1014090255 + .long 1253935211 + .long 1072888274 + .long 1395382931 + .long 3160751189 + .long 171030293 + .long 1072891646 + .long 3526460132 + .long 1015477354 + .long 3991843581 + .long 1072895026 + .long 4092853457 + .long 1015634339 + .long 4232894513 + .long 1072898416 + .long 2383938684 + .long 1015717095 + .long 1000925746 + .long 1072901816 + .long 1018491672 + .long 3164358120 + .long 2992903935 + .long 1072905224 + .long 2218154406 + .long 1016276769 + .long 1726216749 + .long 1072908642 + .long 2466808228 + .long 3162724981 + .long 1603444721 + .long 1072912069 + .long 1548633640 + .long 3163249902 + .long 2732492859 + .long 1072915505 + .long 2691479646 + .long 3163304260 + .long 926591435 + .long 1072918951 + .long 3208833762 + .long 3163962090 + .long 589198666 + .long 1072922406 + .long 2664346172 + .long 3164206538 + .long 1829099622 + .long 1072925870 + .long 1016661181 + .long 3164509581 + .long 460407023 + .long 1072929344 + .long 4237175092 + .long 3164187045 + .long 887463927 + .long 1072932827 + .long 3596744163 + .long 3161842742 + .long 3219942644 + .long 1072936319 + .long 3798990616 + .long 1016417382 + .long 3272845541 + .long 1072939821 + .long 928852419 + .long 3164536824 + .long 1156440435 + .long 1072943333 + .long 2351451249 + .long 1015015632 + .long 1276261410 + .long 1072946854 + .long 300981948 + .long 1015732745 + .long 3743175029 + .long 1072950384 + .long 2072812490 + .long 3163223651 + .long 78413852 + .long 1072953925 + .long 4183226867 + .long 3164065827 + .long 3278348324 + .long 1072957474 + .long 3069497416 + .long 1015799288 + .long 569847338 + .long 1072961034 + .long 472945272 + .long 3160339305 + .long 654919306 + .long 1072964603 + .long 3232961757 + .long 3164096045 + .long 3645941911 + .long 1072968181 + .long 3814685081 + .long 3162621917 + .long 1065662932 + .long 1072971770 + .long 2533670915 + .long 1015578814 + .long 1617004845 + .long 1072975368 + .long 82804944 + .long 1011391354 + .long 1118294578 + .long 1072978976 + .long 2197495694 + .long 3160957977 + .long 3978100823 + .long 1072982593 + .long 3513027190 + .long 1016894539 + .long 1720398391 + .long 1072986221 + .long 3980678963 + .long 3164348656 + .long 3049340112 + .long 1072989858 + .long 3062915824 + .long 1014219171 + .long 3784486610 + .long 1072993505 + .long 1581883040 + .long 3162747529 + .long 4040676318 + .long 1072997162 + .long 4090609238 + .long 1016712034 + .long 3933059031 + .long 1073000829 + .long 2133366768 + .long 3162580408 + .long 3577096743 + .long 1073004506 + .long 2951496418 + .long 1014842263 + .long 3088564500 + .long 1073008193 + .long 1762311517 + .long 1016094249 + .long 2583551245 + .long 1073011890 + .long 3161094195 + .long 1016655067 + .long 2178460671 + .long 1073015597 + .long 777878098 + .long 3163891069 + .long 1990012071 + .long 1073019314 + .long 3529070563 + .long 3163861769 + .long 2135241198 + .long 1073023041 + .long 1236747871 + .long 1014637723 + .long 2731501122 + .long 1073026778 + .long 1774031855 + .long 3163518597 + .long 3896463087 + .long 1073030525 + .long 1139797873 + .long 3162282381 + .long 1453150082 + .long 1073034283 + .long 498154669 + .long 3162536638 + .long 4109806887 + .long 1073038050 + .long 422403966 + .long 1015517805 + .long 3395129871 + .long 1073041828 + .long 4025345435 + .long 3163383964 + .long 3723038930 + .long 1073045616 + .long 378465264 + .long 3163618158 + .long 917841882 + .long 1073049415 + .long 18715565 + .long 1016707884 + .long 3689071823 + .long 1073053223 + .long 2321004996 + .long 3163601292 + .long 3566716925 + .long 1073057042 + .long 1536826856 + .long 1015191009 + .long 671025100 + .long 1073060872 + .long 3832014351 + .long 3164070606 + .long 3712504873 + .long 1073064711 + .long 88491949 + .long 1016476236 + .long 4222122499 + .long 1073068561 + .long 1277378074 + .long 3164305313 + .long 2321106615 + .long 1073072422 + .long 2171176610 + .long 1010584347 + .long 2425981843 + .long 1073076293 + .long 2830390851 + .long 3164395175 + .long 363667784 + .long 1073080175 + .long 813753950 + .long 1016833785 + .long 551349105 + .long 1073084067 + .long 3821916050 + .long 3163155165 + .long 3111574537 + .long 1073087969 + .long 2606161479 + .long 3163808322 + .long 3872257780 + .long 1073091882 + .long 1253592103 + .long 1017006910 + .long 2956612997 + .long 1073095806 + .long 2118169751 + .long 3163784129 + .long 488188413 + .long 1073099741 + .long 3199821029 + .long 1016612624 + .long 885834528 + .long 1073103686 + .long 1973258547 + .long 3163310140 + .long 4273770423 + .long 1073107641 + .long 3383180809 + .long 3164267477 + .long 2186617381 + .long 1073111608 + .long 2270764084 + .long 3164321289 + .long 3339203574 + .long 1073115585 + .long 1483497780 + .long 3163457330 + .long 3561793907 + .long 1073119573 + .long 1157054053 + .long 1012938926 + .long 2979960120 + .long 1073123572 + .long 2599109725 + .long 1015547069 + .long 1719614413 + .long 1073127582 + .long 330458198 + .long 3164331316 + .long 4201977662 + .long 1073131602 + .long 748330254 + .long 1014642933 + .long 1963711167 + .long 1073135634 + .long 1744767757 + .long 3161622870 + .long 3721688645 + .long 1073139676 + .long 3069276937 + .long 1016887977 + .long 1013258799 + .long 1073143730 + .long 1748797611 + .long 3161177658 + .long 2555984613 + .long 1073147794 + .long 2652555442 + .long 3163601268 + .long 4182873220 + .long 1073151869 + .long 629542646 + .long 3163044879 + .long 1727278727 + .long 1073155956 + .long 3562710623 + .long 1012520516 + .long 3907805044 + .long 1073160053 + .long 2257091225 + .long 3162598983 + .long 2263535754 + .long 1073164162 + .long 752233586 + .long 3163687584 + .long 1218806132 + .long 1073168282 + .long 1818613052 + .long 3163597017 + .long 903334909 + .long 1073172413 + .long 1636462108 + .long 1016088573 + .long 1447192521 + .long 1073176555 + .long 1462857171 + .long 3163563097 + .long 2980802057 + .long 1073180708 + .long 378619896 + .long 1016821879 + .long 1339972927 + .long 1073184873 + .long 167908909 + .long 1016620728 + .long 950803702 + .long 1073189049 + .long 1655364926 + .long 1016285608 + .long 1944781191 + .long 1073193236 + .long 3993278767 + .long 3162772855 + .long 158781403 + .long 1073197435 + .long 2221464712 + .long 3164335029 + .long 19972402 + .long 1073201645 + .long 3507899862 + .long 1017057868 + .long 1660913392 + .long 1073205866 + .long 4218599604 + .long 1016184283 + .long 919555682 + .long 1073210099 + .long 3121969534 + .long 1013996802 + .long 2224145553 + .long 1073214343 + .long 3482522030 + .long 3162537745 + .long 1413356050 + .long 1073218599 + .long 1651349291 + .long 3163716742 + .long 2916157145 + .long 1073222866 + .long 219487565 + .long 1016357943 + .long 2571947539 + .long 1073227145 + .long 3558159064 + .long 3164425245 + .long 515457527 + .long 1073231436 + .long 836709333 + .long 1016699802 + .long 1176749997 + .long 1073235738 + .long 2738998779 + .long 3163084420 + .long 396319521 + .long 1073240052 + .long 4172420816 + .long 3160123208 + .long 2604962541 + .long 1073244377 + .long 2614425274 + .long 3164587768 + .long 3643909174 + .long 1073248714 + .long 3537586109 + .long 1015403223 + .long 3649726105 + .long 1073253063 + .long 4085036346 + .long 1016698050 + .long 2759350287 + .long 1073257424 + .long 1148526634 + .long 1016943509 + .long 1110089947 + .long 1073261797 + .long 1451641639 + .long 1016523249 + .long 3134592888 + .long 1073266181 + .long 4232266862 + .long 1017039710 + .long 380978316 + .long 1073270578 + .long 854188970 + .long 3161511262 + .long 1577608921 + .long 1073274986 + .long 1875489510 + .long 3164016970 + .long 2568320822 + .long 1073279406 + .long 2732824428 + .long 1015401491 + .long 3492293770 + .long 1073283838 + .long 2248032210 + .long 1016435402 + .long 194117574 + .long 1073288283 + .long 777528612 + .long 3164460665 + .long 1403662306 + .long 1073292739 + .long 2788809599 + .long 3162719583 + .long 2966275557 + .long 1073297207 + .long 2176155324 + .long 3160891335 + .long 727685349 + .long 1073301688 + .long 2038246809 + .long 3163407318 + .long 3418903055 + .long 1073306180 + .long 2527457337 + .long 3161869180 + .long 2591453363 + .long 1073310685 + .long 2132396182 + .long 3160122774 + .long 2682146384 + .long 1073315202 + .long 2082178513 + .long 3164411995 + .long 3833209506 + .long 1073319731 + .long 2722920684 + .long 1014803418 + .long 1892288442 + .long 1073324273 + .long 2446255666 + .long 3163648957 + .long 1297350157 + .long 1073328827 + .long 1308022040 + .long 3164461134 + .long 2191782032 + .long 1073333393 + .long 2960257726 + .long 1014791238 + .long 424392917 + .long 1073337972 + .long 2749202995 + .long 3163887294 + .long 434316067 + .long 1073342563 + .long 2028358766 + .long 1014506698 + .long 2366108318 + .long 1073347166 + .long 2867985102 + .long 3162810830 + .long 2069751141 + .long 1073351782 + .long 1562170675 + .long 3163773257 + .long 3985553595 + .long 1073356410 + .long 4002146062 + .long 1016882712 + .long 3964284211 + .long 1073361051 + .long 2111583915 + .long 1016475740 + .long 2152073944 + .long 1073365705 + .long 1486860576 + .long 3164252032 + .long 2990417245 + .long 1073370371 + .long 3683467745 + .long 3164417902 + .long 2331271250 + .long 1073375050 + .long 812057446 + .long 1013256022 + .long 321958744 + .long 1073379742 + .long 3401933767 + .long 1016843134 + .long 1405169241 + .long 1073384446 + .long 2998539689 + .long 3163879527 + .long 1434058175 + .long 1073389163 + .long 251133233 + .long 1016134345 + .long 557149882 + .long 1073393893 + .long 3672720709 + .long 1015585841 + .long 3218338682 + .long 1073398635 + .long 3404164304 + .long 3163525684 + .long 977020788 + .long 1073403391 + .long 3065100517 + .long 1016590139 + .long 2572866477 + .long 1073408159 + .long 878562433 + .long 1016570317 + .long 3861050111 + .long 1073412940 + .long 254893773 + .long 3163861756 + .long 697153126 + .long 1073417735 + .long 1283515429 + .long 3164331765 + .long 1822067026 + .long 1073422542 + .long 1241994956 + .long 1016388866 + .long 3092190715 + .long 1073427362 + .long 814012168 + .long 3160571998 + .long 364333489 + .long 1073432196 + .long 3923737744 + .long 3162469949 + .long 2380618042 + .long 1073437042 + .long 3149557219 + .long 3164369375 + .long 703710506 + .long 1073441902 + .long 1384660846 + .long 1016244467 + .long 4076559943 + .long 1073446774 + .long 2119478331 + .long 3161806927 + .long 4062661092 + .long 1073451660 + .long 1422616006 + .long 3164303894 + .long 815859274 + .long 1073456560 + .long 240396590 + .long 3164536019 + .long 3080351519 + .long 1073461472 + .long 3379126789 + .long 3158266577 + .long 2420883922 + .long 1073466398 + .long 2049810052 + .long 1015168464 + .long 3287523847 + .long 1073471337 + .long 1625971539 + .long 3158058531 + .long 1540824585 + .long 1073476290 + .long 1064017011 + .long 3164536266 + .long 1631695677 + .long 1073481256 + .long 2717633076 + .long 3163392602 + .long 3716502172 + .long 1073486235 + .long 2303740125 + .long 1015091301 + .long 3657065772 + .long 1073491228 + .long 399025623 + .long 3164005654 + .long 1610600570 + .long 1073496235 + .long 3766732298 + .long 1016808759 + .long 2029714210 + .long 1073501255 + .long 613660079 + .long 1016147719 + .long 777507147 + .long 1073506289 + .long 4282924205 + .long 1016236109 + .long 2307442995 + .long 1073511336 + .long 3190117721 + .long 3163453115 + .long 2483480501 + .long 1073516397 + .long 1216371780 + .long 1014082748 + .long 1464976603 + .long 1073521472 + .long 3507292405 + .long 3163026110 + .long 3706687593 + .long 1073526560 + .long 3521726939 + .long 1014301643 + .long 778901109 + .long 1073531663 + .long 2248183954 + .long 3162317327 + .long 1432208378 + .long 1073536779 + .long 1401068914 + .long 3163412539 + .long 1532734324 + .long 1073541909 + .long 3094216535 + .long 3164211433 + .long 1242007932 + .long 1073547053 + .long 1132034716 + .long 3164388407 + .long 721996136 + .long 1073552211 + .long 563754734 + .long 1016419894 + .long 135105010 + .long 1073557383 + .long 1906148728 + .long 3164424315 + .long 3939148246 + .long 1073562568 + .long 3210352148 + .long 1016322899 + .long 3707479175 + .long 1073567768 + .long 3613079303 + .long 1015213314 + .long 3898795731 + .long 1073572982 + .long 1249994144 + .long 1012918394 + .long 382305176 + .long 1073578211 + .long 2347622376 + .long 3163627201 + .long 1912561781 + .long 1073583453 + .long 3147495102 + .long 1016726829 + .long 64696965 + .long 1073588710 + .long 1768797490 + .long 1016865536 + .long 3594158869 + .long 1073593980 + .long 2456521700 + .long 3164305137 + .long 4076975200 + .long 1073599265 + .long 2029000899 + .long 1016257111 + .long 1679558232 + .long 1073604565 + .long 2390342287 + .long 3164382546 + .long 863738719 + .long 1073609879 + .long 1326992220 + .long 3163661773 + .long 1796832535 + .long 1073615207 + .long 3176955716 + .long 3161634089 + .long 351641897 + .long 1073620550 + .long 2172261526 + .long 3164059175 + .long 991358482 + .long 1073625907 + .long 838715019 + .long 3164206244 + .long 3884662774 + .long 1073631278 + .long 2158611599 + .long 1015258761 + .long 610758006 + .long 1073636665 + .long 1965209397 + .long 3162914808 + .long 4224142467 + .long 1073642065 + .long 3389820386 + .long 1016255778 + .long 2009970496 + .long 1073647481 + .long 2159039665 + .long 3163621524 + .long 2728693978 + .long 1073652911 + .long 396109971 + .long 3164511267 + .long 2256325230 + .long 1073658356 + .long 580117746 + .long 1016365871 + .long 764307441 + .long 1073663816 + .long 3021057420 + .long 3164378099 + .long 2719515920 + .long 1073669290 + .long 2760332941 + .long 1016186509 + .long 3999357479 + .long 1073674779 + .long 2258941616 + .long 1016973300 + .long 481706282 + .long 1073680284 + .long 1696079173 + .long 3163759104 + .long 929806999 + .long 1073685803 + .long 3205336643 + .long 1016308133 + .long 1222472308 + .long 1073691337 + .long 1054357470 + .long 3162069594 + .long 1533953344 + .long 1073696886 + .long 769171851 + .long 1016714209 + .long 2038973688 + .long 1073702450 + .long 892941374 + .long 1017095035 + .long 2912730644 + .long 1073708029 + .long 3490067722 + .long 3164453650 + .long 35929225 + .long 1073713624 + .long 2809788041 + .long 3160485544 + .long 2174652632 + .long 1073719233 + .long 4087714590 + .long 1015498835 + .long 915592468 + .long 1073724858 + .long 352947894 + .long 3162072947 + .long 730821105 + .long 1073730498 + .long 2523232743 + .long 1013115764 + .long 1797923801 + .long 1073736153 + .long 1950547427 + .long 1014277635 + .long 3884607281 + .long 1062590591 + .long 3607404736 + .long 1068264200 + .long 1874480759 + .long 1065595563 + .long 4286760335 + .long 1070514109 + .long 4277811695 + .long 1072049730 + .long 0 + .long 0 + .long 4277811695 + .long 1072049730 + .long 4277811695 + .long 3219533378 + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,12576 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/powf_wmt.S b/external/sgx_libm/ia32/powf_wmt.S new file mode 100644 index 0000000000..fa55a81bba --- /dev/null +++ b/external/sgx_libm/ia32/powf_wmt.S @@ -0,0 +1,986 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "powf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin powf + .text + .align 16,0x90 + .globl powf +powf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 48(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movss 116(%esp), %xmm1 + movl 112(%esp), %eax + movaps %xmm1, %xmm5 + movss %xmm1, 8(%esp) + movsd 1424(%ebx), %xmm1 + movsd 1440(%ebx), %xmm7 + movss %xmm0, 4(%esp) + psllq $29, %xmm0 + movapd 1312(%ebx), %xmm6 + cvtss2sd %xmm5, %xmm5 + movsd 528(%ebx), %xmm2 + orpd %xmm0, %xmm1 + movl $2130706431, %ecx + movl %eax, %edx + subl $8388608, %edx + cmpl %edx, %ecx + jb .L_2TAG_PACKET_0.0.3 + movl $0, %ecx + shrl $16, %eax +.L_2TAG_PACKET_1.0.3: +.L_2TAG_PACKET_2.0.3: + movl $127, %edx + andl %eax, %edx + addl $1, %edx + andl $254, %edx + movsd 528(%ebx,%edx,4), %xmm3 + movsd (%ebx,%edx,4), %xmm0 + addl $65, %eax + sarl $7, %eax + subl $127, %eax + cvtsi2sdl %eax, %xmm4 + andpd %xmm3, %xmm7 + subsd %xmm7, %xmm3 + mulsd %xmm1, %xmm7 + mulsd %xmm3, %xmm1 + movl %eax, %edx + sarl $31, %eax + addl %eax, %edx + xorl %edx, %eax + subsd %xmm2, %xmm7 + movapd 1328(%ebx), %xmm2 + addsd %xmm7, %xmm1 + movsd 1472(%ebx), %xmm3 + pshufd $68, %xmm1, %xmm7 + addsd %xmm1, %xmm0 + bsr %eax, %eax + mulpd %xmm7, %xmm6 + movzwl 10(%esp), %edx + mulpd %xmm7, %xmm7 + addsd %xmm4, %xmm0 + addpd %xmm2, %xmm6 + andl $32752, %edx + shrl $7, %edx + subl $97, %eax + addl %edx, %eax + cmpl $35, %eax + jae .L_2TAG_PACKET_3.0.3 + mulsd %xmm5, %xmm0 + mulsd %xmm7, %xmm7 + movapd %xmm0, %xmm4 + addsd %xmm3, %xmm0 + mulpd %xmm7, %xmm6 + movd %xmm0, %eax + subsd %xmm3, %xmm0 + pshufd $238, %xmm6, %xmm7 + subsd %xmm0, %xmm4 + addsd %xmm7, %xmm6 + movapd 1344(%ebx), %xmm7 + mulsd %xmm6, %xmm5 + movapd 1360(%ebx), %xmm2 + xorpd %xmm6, %xmm6 + addsd %xmm5, %xmm4 + pshufd $68, %xmm4, %xmm1 + movl %eax, %edx + sarl $1, %edx + andl $31, %eax + movsd 1056(%ebx,%eax,8), %xmm3 + orl $16368, %ecx + andl $-16, %edx + addl %edx, %ecx + pinsrw $3, %ecx, %xmm6 + mulpd %xmm1, %xmm7 + mulsd %xmm1, %xmm1 + mulsd %xmm3, %xmm4 + addpd %xmm7, %xmm2 + mulsd %xmm6, %xmm3 + mulsd %xmm6, %xmm4 + mulsd %xmm2, %xmm1 + pshufd $238, %xmm2, %xmm0 + addsd %xmm1, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm0, %xmm3 + cvtpd2ps %xmm3, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_5.0.3: + movss 112(%esp), %xmm0 + movss 116(%esp), %xmm1 + mulss %xmm1, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_0.0.3: + cmpl $1065353216, 8(%esp) + je .L_2TAG_PACKET_5.0.3 + movsd 1392(%ebx), %xmm3 + movd %xmm5, %edx + movapd %xmm5, %xmm0 + movapd %xmm5, %xmm7 + andpd %xmm3, %xmm0 + psrlq $32, %xmm0 + movd %xmm0, %ecx + cmpl $2146435072, %ecx + jae .L_2TAG_PACKET_6.0.3 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.3 + movl 4(%esp), %edx + cmpl $2139095039, %edx + jbe .L_2TAG_PACKET_8.0.3 + psllq $52, %xmm3 + orpd %xmm3, %xmm7 + movl $1011, %ecx + movd %ecx, %xmm3 + psrlq $20, %xmm0 + psubd %xmm3, %xmm0 + pxor %xmm3, %xmm3 + pmaxsw %xmm3, %xmm0 + psllq %xmm0, %xmm7 + pcmpeqd %xmm3, %xmm7 + pmovmskb %xmm7, %ecx + andl $255, %ecx + andl $2147483647, %edx + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_9.0.3 + cmpl $255, %ecx + jne .L_2TAG_PACKET_10.0.3 + movsd 1392(%ebx), %xmm3 + movapd %xmm5, %xmm0 + movapd %xmm5, %xmm7 + andpd %xmm3, %xmm0 + movl $1012, %ecx + movd %ecx, %xmm3 + andpd 1392(%ebx), %xmm0 + psrlq $52, %xmm0 + psubd %xmm3, %xmm0 + movsd 1488(%ebx), %xmm3 + psllq %xmm0, %xmm7 + pcmpeqd %xmm3, %xmm7 + pmovmskb %xmm7, %ecx + andl $255, %ecx + addl $32513, %ecx + andl $32768, %ecx + movsd 1440(%ebx), %xmm7 + cmpl $8388608, %edx + jb .L_2TAG_PACKET_11.0.3 + movl 4(%esp), %eax + shrl $16, %eax + andl $32767, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_6.0.3: + movss 4(%esp), %xmm0 + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + ja .L_2TAG_PACKET_12.0.3 + jmp .L_2TAG_PACKET_13.0.3 +.L_2TAG_PACKET_12.0.3: + movss 4(%esp), %xmm0 + addss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_8.0.3: + movl $0, %ecx +.L_2TAG_PACKET_11.0.3: + xorpd %xmm0, %xmm0 + movl $24448, %edx + pinsrw $1, %edx, %xmm0 + movss 4(%esp), %xmm4 + movsd 1424(%ebx), %xmm1 + mulss %xmm0, %xmm4 + movd %xmm4, %edx + andl $2147483647, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_14.0.3 + pextrw $1, %xmm4, %eax + movaps %xmm4, %xmm0 + andps 1376(%ebx), %xmm4 + psllq $29, %xmm0 + orpd %xmm0, %xmm1 + andl $32767, %eax + subl $8192, %eax + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_15.0.3: + movl 8(%esp), %edx + andl $-2147483648, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_16.0.3 + movss 1536(%ebx), %xmm0 + xorps %xmm4, %xmm4 + divss %xmm4, %xmm0 + movl $33, %edx + jmp .L_2TAG_PACKET_17.0.3 +.L_2TAG_PACKET_14.0.3: + movl 8(%esp), %edx + andl $-2147483648, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_18.0.3 + shll $16, %ecx + movl 4(%esp), %edx + andl %ecx, %edx + orl $2139095040, %edx + movd %edx, %xmm0 + movss 1536(%ebx), %xmm1 + divss %xmm4, %xmm1 + movl $33, %edx + jmp .L_2TAG_PACKET_17.0.3 +.L_2TAG_PACKET_18.0.3: + shll $16, %ecx + movd %xmm4, %edx + andl %ecx, %edx + cmpl $0, %edx + jne .L_2TAG_PACKET_19.0.3 + fldz + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_9.0.3: + movl 4(%esp), %edx + cmpl $2139095040, %edx + je .L_2TAG_PACKET_20.0.3 + andl $2147483647, %edx + cmpl $2139095040, %edx + ja .L_2TAG_PACKET_12.0.3 + cmpl $255, %ecx + jne .L_2TAG_PACKET_21.0.3 + movapd %xmm5, %xmm1 + movapd %xmm5, %xmm2 + movl $1012, %ecx + movd %ecx, %xmm3 + andpd 1392(%ebx), %xmm1 + psrlq $52, %xmm1 + psubd %xmm3, %xmm1 + pxor %xmm3, %xmm3 + psllq %xmm1, %xmm2 + pcmpeqd %xmm3, %xmm2 + pmovmskb %xmm2, %eax + andl $255, %eax + cmpl $255, %eax + je .L_2TAG_PACKET_21.0.3 + pextrw $3, %xmm5, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_22.0.3 +.L_2TAG_PACKET_19.0.3: + flds 1552(%ebx) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_22.0.3: + flds 1520(%ebx) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_21.0.3: + pextrw $3, %xmm5, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_23.0.3 + fldz + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_20.0.3: + pextrw $3, %xmm5, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_23.0.3 + fldz + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_10.0.3: + cmpl $0, %edx + je .L_2TAG_PACKET_15.0.3 + movss 1568(%ebx), %xmm0 + mulss %xmm0, %xmm0 + movl $34, %edx + jmp .L_2TAG_PACKET_17.0.3 +.L_2TAG_PACKET_13.0.3: + movss 4(%esp), %xmm4 + movss 8(%esp), %xmm5 + movl 8(%esp), %eax + movl %eax, %ecx + andl $2147483647, %eax + cmpl $2139095040, %eax + ja .L_2TAG_PACKET_24.0.3 + andl $-2147483648, %ecx + movd %xmm4, %edx + movl $2147483647, %eax + andl %edx, %eax + je .L_2TAG_PACKET_14.0.3 + xorl $-1082130432, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_25.0.3 + cmpl $0, %ecx + je .L_2TAG_PACKET_26.0.3 + movd %xmm4, %eax + andl $2147483647, %eax + cmpl $1065353216, %eax + jae .L_2TAG_PACKET_16.0.3 + jmp .L_2TAG_PACKET_23.0.3 +.L_2TAG_PACKET_16.0.3: + fldz + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_25.0.3: + movss 116(%esp), %xmm1 + xorps %xmm0, %xmm0 + addss %xmm1, %xmm0 + fld1 + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_26.0.3: + pextrw $1, %xmm4, %eax + andl $32640, %eax + cmpl $16256, %eax + jae .L_2TAG_PACKET_23.0.3 + fldz + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_23.0.3: + flds 1504(%ebx) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_24.0.3: + movss 8(%esp), %xmm5 + addss %xmm5, %xmm5 + movss %xmm5, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_7.0.3: + movss 4(%esp), %xmm4 + movss 8(%esp), %xmm5 + movd %xmm4, %eax + movss 1536(%ebx), %xmm0 + movl $32, %edx + cmpl $0, %eax + je .L_2TAG_PACKET_17.0.3 + movd %xmm4, %eax + xorps %xmm2, %xmm2 + addss %xmm2, %xmm4 + movl $35, %edx + andl $2147483647, %eax + cmpl $2139095040, %eax + ja .L_2TAG_PACKET_17.0.3 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_27.0.3: + mulsd %xmm7, %xmm7 + mulpd %xmm7, %xmm6 + pshufd $238, %xmm6, %xmm7 + addsd %xmm7, %xmm0 + mulsd %xmm5, %xmm0 + movapd 1344(%ebx), %xmm7 + mulsd %xmm6, %xmm5 + movapd %xmm0, %xmm4 + addsd %xmm3, %xmm0 + movd %xmm0, %eax + subsd %xmm3, %xmm0 + subsd %xmm0, %xmm4 + movapd 1360(%ebx), %xmm2 + xorpd %xmm6, %xmm6 + addsd %xmm5, %xmm4 + pshufd $68, %xmm4, %xmm1 + movl %eax, %edx + sarl $1, %edx + andl $31, %eax + movsd 1056(%ebx,%eax,8), %xmm3 + orl $16368, %ecx + andl $-16, %edx + addl %edx, %ecx + pinsrw $3, %ecx, %xmm6 + mulpd %xmm1, %xmm7 + mulsd %xmm1, %xmm1 + mulsd %xmm3, %xmm4 + addpd %xmm7, %xmm2 + mulsd %xmm6, %xmm3 + mulsd %xmm6, %xmm4 + mulsd %xmm2, %xmm1 + pshufd $238, %xmm2, %xmm0 + addsd %xmm1, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm3, %xmm0 + cvtpd2ps %xmm0, %xmm0 + pextrw $1, %xmm0, %eax + andl $32767, %eax + movl $30, %edx + cmpl $32640, %eax + jae .L_2TAG_PACKET_17.0.3 + movl $31, %edx + cmpl $16, %eax + jb .L_2TAG_PACKET_17.0.3 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_28.0.3: + movl $30, %edx + orl $32639, %ecx + xorpd %xmm0, %xmm0 + pinsrw $1, %ecx, %xmm0 + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_17.0.3 +.L_2TAG_PACKET_29.0.3: + movl $31, %edx + movl $8388608, %eax + movd %eax, %xmm1 + mulss %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + pinsrw $1, %ecx, %xmm0 +.L_2TAG_PACKET_17.0.3: + movss %xmm0, (%esp) + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 116(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_3.0.3: + movl 4(%esp), %edx + cmpl $1065353216, %edx + je .L_2TAG_PACKET_25.0.3 + movl 8(%esp), %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_13.0.3 + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.3 + cmpl $0, %eax + jl .L_2TAG_PACKET_30.0.3 + cmpl $38, %eax + jb .L_2TAG_PACKET_27.0.3 + movl 4(%esp), %edx + andl $2139095040, %edx + subl $1056964608, %edx + cmpl $8388608, %edx + jbe .L_2TAG_PACKET_31.0.3 +.L_2TAG_PACKET_32.0.3: + movl 4(%esp), %eax + movl 8(%esp), %edx + andl $2139095040, %eax + subl $1065353216, %eax + xorl %edx, %eax + andl $-2147483648, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_28.0.3 + jmp .L_2TAG_PACKET_29.0.3 +.L_2TAG_PACKET_31.0.3: + movss 4(%esp), %xmm4 + movl $1065353216, %eax + movd %eax, %xmm2 + pslld $1, %xmm4 + psrld $1, %xmm4 + subss %xmm4, %xmm2 + movd %xmm2, %edx + andl $2139095040, %edx + je .L_2TAG_PACKET_30.0.3 + movapd %xmm5, %xmm4 + mulsd %xmm0, %xmm4 + pextrw $3, %xmm4, %eax + andl $32752, %eax + cmpl $16496, %eax + jb .L_2TAG_PACKET_27.0.3 + jmp .L_2TAG_PACKET_32.0.3 +.L_2TAG_PACKET_30.0.3: + shll $16, %ecx + orl $1065353216, %ecx + movd %ecx, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_4.0.3: + movl 48(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type powf,@function + .size powf,.-powf + .data +# -- End powf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 2244132864 + .long 1066854294 + .long 1972305920 + .long 1067891411 + .long 2678235136 + .long 1068559160 + .long 4207480832 + .long 1068917750 + .long 1085124608 + .long 1069271106 + .long 2363127808 + .long 1069583448 + .long 3799560192 + .long 1069755113 + .long 972806144 + .long 1069924378 + .long 3492741120 + .long 1070091307 + .long 766832640 + .long 1070255966 + .long 1278367744 + .long 1070418414 + .long 3103942656 + .long 1070578710 + .long 3671264256 + .long 1070666503 + .long 2869823488 + .long 1070744583 + .long 3466906624 + .long 1070821668 + .long 1271733248 + .long 1070897784 + .long 972806144 + .long 1070972954 + .long 3449621504 + .long 1071047201 + .long 1662393344 + .long 1071120549 + .long 2300516352 + .long 1071193018 + .long 176119808 + .long 1071264630 + .long 4147676160 + .long 1071335403 + .long 2905168896 + .long 1071405359 + .long 3761433600 + .long 1071474515 + .long 2716292096 + .long 1071542890 + .long 1758136320 + .long 1071610501 + .long 2341968384 + .long 1071661018 + .long 14039552 + .long 1071694085 + .long 4204914176 + .long 1071726793 + .long 513134592 + .long 1071759153 + .long 3559335936 + .long 1071791169 + .long 1904282624 + .long 3218771961 + .long 714524672 + .long 3218709255 + .long 180337664 + .long 3218647192 + .long 47131648 + .long 3218585759 + .long 1751500800 + .long 3218524943 + .long 4058951680 + .long 3218464732 + .long 2999895040 + .long 3218405115 + .long 398715904 + .long 3218346080 + .long 3815829504 + .long 3218287614 + .long 722717696 + .long 3218229709 + .long 1399058432 + .long 3218172352 + .long 227933184 + .long 3218115534 + .long 2835759104 + .long 3218038744 + .long 3554951168 + .long 3217927202 + .long 2818570240 + .long 3217816679 + .long 3041732608 + .long 3217707156 + .long 180338688 + .long 3217598616 + .long 835166208 + .long 3217491040 + .long 704622592 + .long 3217384412 + .long 1695342592 + .long 3217278715 + .long 3266000896 + .long 3217173933 + .long 2363885568 + .long 3217070051 + .long 3908239360 + .long 3216902938 + .long 448159744 + .long 3216698681 + .long 2530197504 + .long 3216496132 + .long 4268273664 + .long 3216295264 + .long 2785038336 + .long 3216096050 + .long 522182656 + .long 3215814333 + .long 3386466304 + .long 3215422356 + .long 3838140416 + .long 3215033528 + .long 2250194944 + .long 3214361582 + .long 2718924800 + .long 3213307003 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1697350398 + .long 1073157447 + .long 3983912013 + .long 1073134173 + .long 3077571303 + .long 1073111605 + .long 787997771 + .long 1073089711 + .long 2608086797 + .long 1073068460 + .long 4250927815 + .long 1073047825 + .long 4006130247 + .long 1073027780 + .long 2255915958 + .long 1073008300 + .long 1031537321 + .long 1072989361 + .long 3606154084 + .long 1072970940 + .long 1235818328 + .long 1072953018 + .long 2880061438 + .long 1072935573 + .long 525144062 + .long 1072918588 + .long 3251485016 + .long 1072902043 + .long 2604098795 + .long 1072885923 + .long 2408035495 + .long 1072870211 + .long 1357880318 + .long 1072854892 + .long 1394140652 + .long 1072839951 + .long 3210356685 + .long 1072825374 + .long 1774519652 + .long 1072811149 + .long 3338441873 + .long 1072797262 + .long 3804456356 + .long 1072783702 + .long 1462910403 + .long 1072770458 + .long 1149890700 + .long 1072757518 + .long 1234436653 + .long 1072744872 + .long 2089211650 + .long 1072732510 + .long 1684223316 + .long 1072720423 + .long 4072784951 + .long 1072708601 + .long 2114454037 + .long 1072697037 + .long 2012861074 + .long 1072678195 + .long 2037138800 + .long 1072656045 + .long 3417210877 + .long 1072634361 + .long 3694789629 + .long 1072613129 + .long 2992528814 + .long 1072592335 + .long 3882342941 + .long 1072571965 + .long 2671772639 + .long 1072552007 + .long 2172608510 + .long 1072532448 + .long 3001586108 + .long 1072513276 + .long 3477449063 + .long 1072494480 + .long 3818975826 + .long 1072476049 + .long 1758664544 + .long 1072457973 + .long 1046539701 + .long 1072440241 + .long 2778964739 + .long 1072422843 + .long 1026978211 + .long 1072405771 + .long 4238694625 + .long 1072389014 + .long 811117725 + .long 1072372566 + .long 1975098645 + .long 1072356416 + .long 3079413536 + .long 1072340557 + .long 712695513 + .long 1072324982 + .long 1238508315 + .long 1072309682 + .long 3563503614 + .long 1072294650 + .long 3383126459 + .long 1072279880 + .long 1724836050 + .long 1072265365 + .long 608820196 + .long 1072251098 + .long 3005930546 + .long 1072237072 + .long 4207804139 + .long 1072223282 + .long 378851326 + .long 1072209723 + .long 1405092650 + .long 1072196387 + .long 795096448 + .long 1072183270 + .long 1417164049 + .long 1072170366 + .long 2583387630 + .long 1072157670 + .long 20099889 + .long 1072145178 + .long 3019600065 + .long 1072132883 + .long 53601996 + .long 1072120783 + .long 1697350398 + .long 1072108871 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 3541402996 + .long 1072716208 + .long 1828292879 + .long 1072739672 + .long 3490863953 + .long 1072763649 + .long 1014845819 + .long 1072788152 + .long 828946858 + .long 1072813191 + .long 1853186616 + .long 1072838778 + .long 4112506593 + .long 1072864925 + .long 171030293 + .long 1072891646 + .long 926591435 + .long 1072918951 + .long 1276261410 + .long 1072946854 + .long 1617004845 + .long 1072975368 + .long 3577096743 + .long 1073004506 + .long 1453150082 + .long 1073034283 + .long 3712504873 + .long 1073064711 + .long 2956612997 + .long 1073095806 + .long 1719614413 + .long 1073127582 + .long 3907805044 + .long 1073160053 + .long 1944781191 + .long 1073193236 + .long 2571947539 + .long 1073227145 + .long 1110089947 + .long 1073261797 + .long 2966275557 + .long 1073297207 + .long 2191782032 + .long 1073333393 + .long 2990417245 + .long 1073370371 + .long 2572866477 + .long 1073408159 + .long 4076559943 + .long 1073446774 + .long 3716502172 + .long 1073486235 + .long 3706687593 + .long 1073526560 + .long 3707479175 + .long 1073567768 + .long 863738719 + .long 1073609879 + .long 2728693978 + .long 1073652911 + .long 1533953344 + .long 1073696886 + .long 531389993 + .long 1067950900 + .long 4289495988 + .long 1069842387 + .long 2705553552 + .long 3216330822 + .long 4277811695 + .long 3218484802 + .long 1874480759 + .long 1065595563 + .long 4286760334 + .long 1070514109 + .long 3607404735 + .long 1068264200 + .long 4277811695 + .long 1072049730 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 1048575 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 4227858432 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 1077936128 + .long 0 + .long 0 + .long 0 + .long 1122500608 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 2139095040 + .long 0 + .long 0 + .long 0 + .long 4286578688 + .long 0 + .long 0 + .long 0 + .long 1065353216 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2139095041 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,1584 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/powl.S b/external/sgx_libm/ia32/powl.S new file mode 100644 index 0000000000..ff72d76753 --- /dev/null +++ b/external/sgx_libm/ia32/powl.S @@ -0,0 +1,2423 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "powl.c" + .text +..TXTST0: +# -- Begin powl + .text + .align 16,0x90 + .globl powl +powl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $148, %esp +..B1.2: + fnstcw 70(%esp) +..B1.3: + movzbl 17(%ebp), %ecx + shrl $7, %ecx + movzwl 16(%ebp), %eax + shll $15, %ecx + andl $32767, %eax + orl %eax, %ecx + movl 12(%ebp), %ebx + shll $16, %ecx + shrl $16, %ebx + movl %eax, 44(%esp) + orl %ebx, %ecx + movzbl 29(%ebp), %eax + movl %ecx, %edi + shrl $7, %eax + movl %ecx, %edx + movzwl 28(%ebp), %esi + andl $2147483647, %edx + shll $15, %eax + andl $32767, %esi + movl 24(%ebp), %ebx + orl %esi, %eax + shrl $31, %edi + cmpl $1073709056, %edx + movl %edi, 28(%esp) + movl %ebx, %edi + movl %edx, 12(%esp) + movl $0, %edx + movl %esi, 48(%esp) + setb %dl + shll $16, %eax + shrl $16, %edi + orl %edi, %eax + movl %eax, %esi + andl $2147483647, %eax + shrl $31, %esi + xorl %esi, %edx + movl %edx, 124(%esp) + movl %eax, %edx + movl 8(%ebp), %edi + orl %ebx, %edx + movl %edi, 32(%esp) + movl 20(%ebp), %edi + orl %edi, %edx + movl %esi, 56(%esp) + movl %edx, 40(%esp) + movl %ebx, 60(%esp) + movl %edi, 36(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl 12(%ebp), %edx + movl 12(%esp), %esi + je ..B1.5 +..B1.4: + addl $-1073709056, %ecx + lea -2147483648(%edx), %edi + orl %edi, %ecx + movl %edi, 24(%esp) + orl 32(%esp), %ecx + jne ..B1.10 +..B1.5: + cmpl $2147450880, %eax + jae ..B1.8 +..B1.6: + cmpl $2147450880, %esi + jb ..B1.9 +..B1.7: + addl $-2147483648, %edx + orl 32(%esp), %edx + je ..B1.9 +..B1.8: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt 136(%esp) +..B1.9: + fldl _ones@GOTOFF(%ebx) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.10: + lea -1073709056(%eax), %ecx + movl %ecx, 20(%esp) + cmpl $4194304, %ecx + jae ..B1.17 +..B1.11: + movl %eax, %ecx + shrl $16, %ecx + movl %ecx, 52(%esp) + cmpl $1075806208, %eax + ja ..B1.13 +..B1.12: + movl %ebx, 12(%esp) + movl %ecx, %ebx + movl %ebx, %ecx + negl %ecx + addl $30, %ecx + movl 60(%esp), %edi + shrl %cl, %edi + lea 2(%ebx), %ecx + movl %edi, 16(%esp) + movl 60(%esp), %edi + shll %cl, %edi + movl 36(%esp), %ebx + orl %ebx, %edi + cmpl $1075740672, %eax + jbe ..L3 + movl %ebx, %edi +..L3: + movl 12(%esp), %ebx + movl %edi, 40(%esp) + jmp ..B1.14 +..B1.13: + movl %ebx, 12(%esp) + movl %ecx, %ebx + movl %ebx, %ecx + negl %ecx + addl $30, %ecx + movl 36(%esp), %edi + shrl %cl, %edi + lea 2(%ebx), %ecx + movl 36(%esp), %ebx + shll %cl, %ebx + cmpl $1077837824, %eax + movl %edi, 16(%esp) + jb ..L4 + movl $0, %ebx +..L4: + movl %ebx, 40(%esp) + movl 12(%esp), %ebx +..B1.14: + testb $1, 16(%esp) + je ..B1.16 +..B1.15: + movl 28(%esp), %ecx + movl %ecx, 108(%esp) + movl $1, 12(%esp) + jmp ..B1.18 +..B1.16: + xorl %ecx, %ecx + movl %ecx, 12(%esp) + movl %ecx, 108(%esp) + jmp ..B1.18 +..B1.17: + cmpl $1073709056, %eax + movl 40(%esp), %edi + jb ..L5 + movl $0, %edi +..L5: + xorl %ecx, %ecx + movl %ecx, 12(%esp) + movl %ecx, 108(%esp) + movl %edi, 40(%esp) +..B1.18: + cmpl $32767, 44(%esp) + je ..B1.189 +..B1.19: + cmpl $32767, 48(%esp) + je ..B1.156 +..B1.20: + movl %edx, %ecx + andl $2147483647, %ecx + orl 32(%esp), %ecx + jne ..B1.26 +..B1.21: + movl %edx, %ecx + orl %esi, %ecx + jne ..B1.26 +..B1.22: + xorl %edx, %edx + cmpl $0, 40(%esp) + sete %dl + andl %edx, 108(%esp) + cmpl $0, 56(%esp) + jne ..B1.193 +..B1.23: + cmpl $65536, %eax + jae ..B1.25 +..B1.24: + fldl _smallest_value_64@GOTOFF(%ebx) + fstpl 128(%esp) +..B1.25: + movl 108(%esp), %eax + fldl _zeros@GOTOFF(%ebx,%eax,8) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + cmpl $0, 28(%esp) + je ..B1.31 +..B1.27: + cmpl $1077837824, %eax + jae ..B1.29 +..B1.28: + cmpl $0, 40(%esp) + jne ..B1.192 +..B1.29: + lea -1073709056(%esi), %ecx + orl 24(%esp), %ecx + orl 32(%esp), %ecx + jne ..B1.31 +..B1.30: + movl 12(%esp), %eax + fldl _ones@GOTOFF(%ebx,%eax,8) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + lea -65536(%esi), %edi + lea -65536(%eax), %ecx + orl %ecx, %edi + testl $-2147483648, %edi + je ..B1.33 +..B1.32: + fldl _smallest_value_64@GOTOFF(%ebx) + fstpl 128(%esp) +..B1.33: + movl 60(%esp), %ecx + andl $2147483647, %ecx + orl 36(%esp), %ecx + jne ..B1.61 +..B1.34: + cmpl $1073709056, %eax + jne ..B1.43 +..B1.35: + cmpl $0, 56(%esp) + je ..B1.42 +..B1.36: + movzwl 70(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.141 +..B1.37: + orl $-64768, %edx + movw %dx, 68(%esp) +..B1.38: + fldcw 68(%esp) +..B1.39: + fldt 8(%ebp) + fdivrl _ones@GOTOFF(%ebx) + fstpt 24(%esp) +..B1.40: + fldcw 70(%esp) +..B1.41: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.42: + fldt 8(%ebp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.43: + cmpl $1073643520, %eax + jne ..B1.61 +..B1.44: + movzwl 70(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.142 +..B1.45: + orl $-64768, %edx + movw %dx, 68(%esp) +..B1.46: + fldcw 68(%esp) +..B1.47: + movl $1, %esi +..B1.48: + cmpl $0, 56(%esp) + je ..B1.56 +..B1.49: + fldl _ones@GOTOFF(%ebx) + movzbl 17(%ebp), %edi + fld %st(0) + shrl $7, %edi + movzwl 16(%ebp), %eax + shll $15, %edi + andl $32767, %eax + orl %eax, %edi + shll $16, %edi + movzwl 14(%ebp), %edx + orl %edx, %edi + lea -536838144(%edi), %ecx + cmpl $1073741824, %ecx + jbe ..B1.53 +..B1.50: + fstp %st(0) + cmpl $536838144, %edi + jae ..B1.52 +..B1.51: + fldt 8(%ebp) + fldt _invsqrtl_scales@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 12+_invsqrtl_scales@GOTOFF(%ebx) + fldt 8(%ebp) + fxch %st(2) + fxch %st(1) + fxch %st(2) + jmp ..B1.54 +..B1.52: + fldt 8(%ebp) + fldt 24+_invsqrtl_scales@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 36+_invsqrtl_scales@GOTOFF(%ebx) + fldt 8(%ebp) + fxch %st(2) + fxch %st(1) + fxch %st(2) + jmp ..B1.54 +..B1.53: + fldt 8(%ebp) + fld %st(0) +..B1.54: + fldl _TWO_43H@GOTOFF(%ebx) + fld %st(2) + fmul %st(1), %st + fxch %st(3) + fdivr %st, %st(5) + fxch %st(5) + fstpt 12(%esp) + fxch %st(2) + fadd %st, %st(4) + fxch %st(4) + fstpt (%esp) + fldt (%esp) + addl $-16, %esp + fsubp %st, %st(4) + fsub %st(3), %st + lea 28(%esp), %eax + movl %eax, (%esp) + fstpt 28(%eax) + fstpt 12(%eax) + fxch %st(1) + fstpt 44(%eax) + fstpt 60(%eax) + call __sqrtl +..B1.196: + fldt 88(%esp) + fldt 72(%esp) + fldt 56(%esp) + fldt 40(%esp) + addl $16, %esp +..B1.55: + fmul %st(4), %st + fld %st(4) + fadd %st(1), %st + fstpt (%esp) + fld %st(4) + fxch %st(2) + fmul %st(5), %st + fxch %st(5) + fstpt 12(%esp) + fldt 12(%esp) + fldt (%esp) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fld %st(3) + fmul %st(3), %st + faddp %st, %st(6) + fxch %st(1) + fmul %st, %st(5) + fld %st(2) + fxch %st(2) + fmul %st, %st(4) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(6) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddl 8+_ones@GOTOFF(%ebx) + faddp %st, %st(5) + fmulp %st, %st(4) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fmulp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 24(%esp) + jmp ..B1.58 +..B1.56: + addl $-16, %esp + lea 8(%ebp), %eax + movl %eax, (%esp) + call __sqrtl +..B1.197: + addl $16, %esp +..B1.57: + fstpt 24(%esp) +..B1.58: + testl %esi, %esi + je ..B1.60 +..B1.59: + fldcw 70(%esp) +..B1.60: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.61: + movzwl 70(%esp), %edi + movl %edi, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.155 +..B1.62: + orl $-64768, %edi + movw %di, 68(%esp) +..B1.63: + fldcw 68(%esp) +..B1.64: + movl $1, 36(%esp) +..B1.65: + fldt 8(%ebp) + movl 28(%esp), %ecx + cmpl $0, 40(%esp) + fmull _ones@GOTOFF(%ebx,%ecx,8) + fstpt 8(%ebp) + fldt 8(%ebp) + jne ..B1.92 +..B1.66: + cmpl $1048576, 20(%esp) + jae ..B1.92 +..B1.67: + movl %eax, %ecx + shrl $16, %ecx + negl %ecx + addl $30, %ecx + movl 60(%esp), %edi + shrl %cl, %edi + cmpl $46, %edi + movl %edi, 60(%esp) + lea -2(%edi), %ecx + movl 32(%esp), %edi + jb ..L6 + movl $46, %ecx +..L6: + andl 4+_exact_masks@GOTOFF(%ebx,%ecx,8), %edx + andl _exact_masks@GOTOFF(%ebx,%ecx,8), %edi + movl %ecx, 52(%esp) + orl %edi, %edx + jne ..B1.92 +..B1.68: + movl 108(%esp), %eax + cmpl $65535, %esi + fldl _ones@GOTOFF(%ebx,%eax,8) + ja ..B1.70 +..B1.69: + fldl _TWO_75@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 40(%esp) + movzwl 48(%esp), %ecx + movl %ecx, %edx + andl $32767, %edx + addl $-16458, %edx + jmp ..B1.71 +..B1.70: + movzwl 16(%ebp), %edx + fxch %st(1) + fstpt 40(%esp) + andl $32767, %edx + movzwl 48(%esp), %ecx + addl $-16383, %edx +..B1.71: + movl 56(%esp), %eax + andl $-32768, %ecx + orl $-49153, %ecx + movw %cx, 48(%esp) + movl iones@GOTOFF(%ebx,%eax,4), %eax + imull 60(%esp), %eax + imull %edx, %eax + lea 16445(%eax), %ecx + cmpl $32829, %ecx + lea 16383(%eax), %edx + jb ..B1.78 +..B1.72: + movl 108(%esp), %ecx + cmpl $-63, %edx + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %eax + jg ..B1.74 +..B1.73: + fldt _small_value_80@GOTOFF(%eax,%ebx) + fldt _small_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) + jmp ..B1.75 +..B1.74: + fldt _large_value_80@GOTOFF(%eax,%ebx) + fldt _large_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.75: + fstpt 24(%esp) + cmpl $0, 36(%esp) + je ..B1.200 +..B1.76: + fstpt 12(%esp) +..B1.198: + fldcw 70(%esp) + jmp ..B1.77 +..B1.200: + fstp %st(0) +..B1.77: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.78: + fstpt 12(%esp) + testl %edx, %edx + jg ..B1.80 +..B1.79: + addl $16458, %eax + movzwl 20(%esp), %edx + andl $32767, %eax + andl $-32768, %edx + orl %eax, %edx + movw %dx, 20(%esp) + fldt 12(%esp) + fmull 8+_TWO_75@GOTOFF(%ebx) + fstpt 12(%esp) + jmp ..B1.81 +..B1.80: + movzwl 20(%esp), %eax + andl $32767, %edx + andl $-32768, %eax + orl %edx, %eax + movw %ax, 20(%esp) +..B1.81: + cmpl $-2147483648, 44(%esp) + jne ..B1.87 +..B1.82: + cmpl $0, 40(%esp) + jne ..B1.87 +..B1.83: + fldt 12(%esp) + fstpt 24(%esp) +..B1.84: + cmpl $0, 36(%esp) + je ..B1.86 +..B1.85: + fldcw 70(%esp) +..B1.86: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.87: + fldt 40(%esp) + fstpt 24(%esp) + fldt 24(%esp) + fstpt 96(%esp) + fldt 96(%esp) + fldl _ones@GOTOFF(%ebx) + movl $0, 24(%esp) + fstpt 72(%esp) + fldt 72(%esp) + fldt 24(%esp) + movl 60(%esp), %eax + fsubr %st, %st(2) + fldt 72(%esp) + fldl _zeros@GOTOFF(%ebx) + jmp ..B1.88 +..B1.91: + fld %st(2) + fadd %st(5), %st + fld %st(3) + fmul %st(6), %st + fxch %st(4) + fmul %st(0), %st + fstpt 24(%esp) + fldt 24(%esp) + fxch %st(1) + fmulp %st, %st(6) + movl $0, 24(%esp) + fxch %st(5) + faddp %st, %st(3) + fxch %st(4) + fstpt 96(%esp) + fldt 96(%esp) + fldt 24(%esp) + fsubr %st, %st(1) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(3) + fxch %st(2) + fxch %st(4) +..B1.88: + testb $1, %al + je ..B1.90 +..B1.89: + fld %st(4) + fadd %st(3), %st + fmulp %st, %st(1) + fld %st(4) + fmul %st(2), %st + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + fstpt 72(%esp) + fldt 72(%esp) + fstpt 96(%esp) + fldt 96(%esp) + movl $0, 72(%esp) + fldt 72(%esp) + fsubr %st, %st(1) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + fxch %st(1) +..B1.90: + shrl $1, %eax + testl %eax, %eax + je ..B1.143 + jmp ..B1.91 +..B1.92: + lea -1073676224(%esi), %edx + cmpl $32864, %edx + jae ..B1.94 +..B1.93: + fldl 8+_ones@GOTOFF(%ebx) + movl $1, %ecx + faddp %st, %st(1) + fld %st(0) + fld %st(1) + fxch %st(2) + fstpt 40(%esp) + fldt 40(%esp) + fldl _TWO_32H@GOTOFF(%ebx) + fstpt 112(%esp) + fldt 112(%esp) + fmul %st(1), %st + fadd %st, %st(2) + fxch %st(2) + fstpt 84(%esp) + fldt 84(%esp) + fsubp %st, %st(2) + fxch %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fsubr %st, %st(2) + fxch %st(1) + fxch %st(2) + fxch %st(1) + jmp ..B1.98 +..B1.94: + cmpl $65535, %esi + ja ..B1.96 +..B1.95: + fmull _TWO_75@GOTOFF(%ebx) + fstpt 40(%esp) + movzwl 48(%esp), %ecx + movl %ecx, %edx + andl $32767, %edx + addl $-16458, %edx + movl %edx, 52(%esp) + jmp ..B1.97 +..B1.96: + movzwl 16(%ebp), %edx + andl $32767, %edx + fstpt 40(%esp) + addl $-16383, %edx + movl %edx, 52(%esp) + movzwl 48(%esp), %ecx +..B1.97: + fldl _TWO_32H@GOTOFF(%ebx) + andl $-32768, %ecx + orl $-49153, %ecx + movw %cx, 48(%esp) + xorl %ecx, %ecx + movl 44(%esp), %edx + shrl $23, %edx + movzbl %dl, %edx + fstpt 112(%esp) + fldt 112(%esp) + fldt 40(%esp) + fld %st(0) + fmul %st(2), %st + fld %st(1) + fadd %st(1), %st + fstpt 84(%esp) + fldt 84(%esp) + fsubp %st, %st(1) + fsubr %st, %st(1) + flds __libm_rcp_table_256@GOTOFF(%ebx,%edx,4) + fmul %st, %st(1) + fstpt 56(%esp) + fldt 56(%esp) + fmulp %st, %st(2) + faddl 8+_ones@GOTOFF(%ebx) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fstpt 84(%esp) + fstpt 40(%esp) + fldt 40(%esp) + fldt 84(%esp) + fsubp %st, %st(4) + fxch %st(3) + fstpt 24(%esp) + fldt 24(%esp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) +..B1.98: + fldt 112(%esp) + testl %ecx, %ecx + fld %st(0) + fxch %st(2) + fadd %st, %st(4) + fxch %st(3) + fmul %st, %st(4) + fxch %st(3) + fmul %st(0), %st + fld %st(0) + fadd %st(5), %st + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fstpt 84(%esp) + fldt 84(%esp) + fsubp %st, %st(4) + fxch %st(1) + fsub %st(3), %st + faddp %st, %st(5) + fldt 96+_LP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 84+_LP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 72+_LP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_LP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_LP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_LP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_LP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_LP@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 40(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(0) + fmul %st(3), %st + fld %st(1) + fadd %st(1), %st + fstpt 84(%esp) + fldt 84(%esp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(7), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + fmul %st(3), %st + fldt _LP@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(4) + fstpt 96(%esp) + fldt 96(%esp) + fadd %st(1), %st + fstpt 72(%esp) + fldt 72(%esp) + fxch %st(4) + fmulp %st, %st(6) + fxch %st(1) + faddp %st, %st(5) + fldt 96(%esp) + fsub %st(3), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 24(%esp) + fstpt 96(%esp) + fldt 96(%esp) + fadd %st(1), %st + fstpt 24(%esp) + fldt 24(%esp) + fldt 96(%esp) + fsub %st(1), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + je ..B1.100 +..B1.99: + fstpt 40(%esp) + fldt 40(%esp) + jmp ..B1.101 +..B1.100: + fstp %st(0) + fldt 12+_LLN2@GOTOFF(%ebx) + movl %edx, %ecx + fldt _LLN2@GOTOFF(%ebx) + shll $4, %ecx + fldl 8+__libm_logl_table_256@GOTOFF(%ecx,%ebx) + fldl __libm_logl_table_256@GOTOFF(%ecx,%ebx) + fxch %st(1) + fadds _LT2@GOTOFF(%ebx,%edx,4) + movl 52(%esp), %edx + movl %edx, 16(%esp) + fildl 16(%esp) + fmul %st, %st(3) + fxch %st(3) + fstpt 96(%esp) + fldt 96(%esp) + fadd %st(2), %st + fxch %st(3) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt 96(%esp) + fsub %st(2), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fldt 24(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpt 40(%esp) + fldt 40(%esp) + fldt 96(%esp) + fsub %st(1), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) +..B1.101: + fld %st(0) + fadd %st(2), %st + fstpt 56(%esp) + fldt 56(%esp) + movzwl 64(%esp), %ecx + shll $16, %ecx + movzwl 62(%esp), %edx + orl %edx, %ecx + andl $2147483647, %ecx + lea (%eax,%ecx), %edx + lea -1610514432(%ecx,%eax), %eax + cmpl $538050560, %eax + jbe ..B1.113 +..B1.102: + cmpl $-2146402304, %edx + jbe ..B1.109 +..B1.103: + fstp %st(0) + fstp %st(2) + fstp %st(0) + fstp %st(0) + movl 108(%esp), %edx + cmpl $0, 124(%esp) + lea (,%edx,8), %eax + lea (%eax,%edx,4), %eax + je ..B1.105 +..B1.104: + fldt _small_value_80@GOTOFF(%eax,%ebx) + fldt _small_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) + jmp ..B1.106 +..B1.105: + fldt _large_value_80@GOTOFF(%eax,%ebx) + fldt _large_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.106: + fstpt 24(%esp) + cmpl $0, 36(%esp) + je ..B1.108 +..B1.107: + fldcw 70(%esp) +..B1.108: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.109: + cmpl $1610514432, %edx + jae ..B1.113 +..B1.110: + fstp %st(0) + fstp %st(2) + fstp %st(0) + fstp %st(0) + movl 108(%esp), %ecx + movl 124(%esp), %eax + xorl %ecx, %eax + cmpl $0, 36(%esp) + lea (,%eax,8), %esi + lea (%esi,%eax,4), %edx + fldt _small_value_80@GOTOFF(%ebx,%edx) + faddl _ones@GOTOFF(%ebx,%ecx,8) + fstpt 24(%esp) + je ..B1.112 +..B1.111: + fldcw 70(%esp) +..B1.112: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.113: + fldt 56(%esp) + fxch %st(1) + fmulp %st, %st(4) + movl 108(%esp), %eax + fadd %st(3), %st + fxch %st(1) + fstpt 96(%esp) + fstpt 84(%esp) + fldt 84(%esp) + fsubp %st, %st(2) + fxch %st(1) + fstpt 40(%esp) + fldt 40(%esp) + fldt 96(%esp) + fsub %st(1), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + fldt 112(%esp) + fldt 20(%ebp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 84(%esp) + fld %st(0) + fxch %st(1) + fmulp %st, %st(4) + fldt 84(%esp) + fsubp %st, %st(2) + fsub %st(1), %st + fmul %st(2), %st + faddp %st, %st(3) + fld %st(2) + fxch %st(1) + fmulp %st, %st(2) + fadd %st(1), %st + fstpt 56(%esp) + fldt 56(%esp) + fldl _ones@GOTOFF(%ebx,%eax,8) + movzwl 64(%esp), %eax + shll $16, %eax + movzwl 62(%esp), %edx + orl %edx, %eax + andl $2147483647, %eax + cmpl $1072398336, %eax + jae ..B1.120 +..B1.114: + cmpl $1069318144, %eax + jae ..B1.116 +..B1.115: + fstp %st(3) + fmul %st(2), %st + fadd %st(2), %st + fxch %st(2) + jmp ..B1.117 +..B1.116: + fldt 12+_EP1@GOTOFF(%ebx) + fmul %st(2), %st + fldt _EP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + fadd %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fld %st(0) + faddp %st, %st(3) +..B1.117: + fxch %st(2) + fstpt 24(%esp) + cmpl $0, 36(%esp) + je ..B1.201 +..B1.118: + fstpt 40(%esp) + fstpt 12(%esp) +..B1.199: + fldcw 70(%esp) + jmp ..B1.119 +..B1.201: + fstp %st(0) + fstp %st(0) +..B1.119: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.120: + fldl _TWO_63H@GOTOFF(%ebx) + fxch %st(1) + fstpt 12(%esp) + fxch %st(2) + fstpt 40(%esp) + fldt 40(%esp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + movl 124(%esp), %eax + fadd %st(2), %st + fstpt 84(%esp) + fldt 84(%esp) + movl 84(%esp), %ecx + fsubp %st, %st(2) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fldt 96(%esp) + fldt 112(%esp) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fmulp %st, %st(3) + movsbl %cl, %edx + fxch %st(2) + fsubrp %st, %st(3) + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + movl %ecx, 24(%esp) + subl %edx, %ecx + sarl $8, %ecx + fsubr %st(2), %st + movl ESC2_BIAS@GOTOFF(%ebx,%eax,4), %esi + fadd %st(1), %st + fstpt 84(%esp) + lea -1(%esi,%ecx), %edi + fldt 84(%esp) + lea (%esi,%ecx), %eax + cmpl $32766, %edi + fsubp %st, %st(1) + fsubr %st, %st(1) + fldt 96(%esp) + fsubrp %st, %st(2) + jb ..B1.127 +..B1.121: + fstp %st(1) + fstp %st(0) + fstp %st(0) + movl 108(%esp), %ecx + cmpl $1, %eax + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + jg ..B1.123 +..B1.122: + fldt _small_value_80@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) + jmp ..B1.124 +..B1.123: + fldt _large_value_80@GOTOFF(%edx,%ebx) + fldt _large_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.124: + fstpt 24(%esp) + cmpl $0, 36(%esp) + je ..B1.126 +..B1.125: + fldcw 70(%esp) +..B1.126: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.127: + fldt 48+_EP@GOTOFF(%ebx) + andl $32767, %eax + fstpt 96(%esp) + fld %st(0) + shll $4, %edx + fxch %st(2) + faddp %st, %st(3) + movzwl 20(%esp), %esi + fxch %st(1) + fadd %st(2), %st + fld %st(0) + andl $-32768, %esi + fmul %st(1), %st + orl %eax, %esi + fldt 96(%esp) + fmul %st(1), %st + fstpt 96(%esp) + fldt 36+_EP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_EP@GOTOFF(%ebx) + fldt 12+_EP@GOTOFF(%ebx) + movl 24(%esp), %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + addl $4196735, %eax + fmulp %st, %st(3) + cmpl $3070, %eax + fldt 96(%esp) + movw %si, 20(%esp) + faddp %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fmul %st(1), %st + fstpt 96(%esp) + fldt 96(%esp) + fldt _EP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fmulp %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(1) + faddp %st, %st(2) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%ebx) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%ebx) + fld %st(0) + fmul %st(4), %st + fxch %st(3) + fadd %st, %st(4) + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fmul %st, %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fadd %st(1), %st + fldt 96(%esp) + fsub %st(1), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + ja ..B1.130 +..B1.128: + fldt 56(%esp) + fldt _Eexpbut@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jbe ..B1.130 +..B1.129: + fldl _TWO_12H@GOTOFF(%ebx) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fadd %st(2), %st + fmul %st, %st(1) + movl 124(%esp), %eax + fadd %st(1), %st + fstpt 84(%esp) + lea (,%eax,8), %esi + fldt 84(%esp) + lea (%esi,%eax,4), %edx + fsubp %st, %st(1) + fldt 96(%esp) + fsub %st(1), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(2) + fldt 12(%esp) + fmul %st, %st(1) + fmulp %st, %st(2) + fldt _ESC2@GOTOFF(%edx,%ebx) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 24(%esp) + jmp ..B1.131 +..B1.130: + movl 124(%esp), %eax + lea (,%eax,8), %esi + lea (%esi,%eax,4), %edx + fldt _ESC2@GOTOFF(%edx,%ebx) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 12(%esp) + fmulp %st, %st(1) + fstpt 24(%esp) +..B1.131: + movzwl 32(%esp), %eax + shll $16, %eax + movzwl 30(%esp), %edx + orl %edx, %eax + andl $2147483647, %eax + lea -98304(%eax), %ecx + cmpl $2147319808, %ecx + jb ..B1.138 +..B1.132: + movl 108(%esp), %ecx + cmpl $65535, %eax + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + ja ..B1.134 +..B1.133: + fldt _small_value_80@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 136(%esp) + jmp ..B1.135 +..B1.134: + fldt _large_value_80@GOTOFF(%edx,%ebx) + fldt _large_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 24(%esp) +..B1.135: + cmpl $0, 36(%esp) + je ..B1.137 +..B1.136: + fldcw 70(%esp) +..B1.137: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.138: + cmpl $0, 36(%esp) + je ..B1.140 +..B1.139: + fldcw 70(%esp) +..B1.140: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.141: + fldt 8(%ebp) + fdivrl _ones@GOTOFF(%ebx) + fstpt 24(%esp) + jmp ..B1.41 +..B1.142: + xorl %esi, %esi + jmp ..B1.48 +..B1.143: + fstp %st(2) + fstp %st(3) + cmpl $0, 56(%esp) + jne ..B1.145 +..B1.144: + fstp %st(1) + fxch %st(1) + fstpt 40(%esp) + fldt 40(%esp) + fxch %st(1) + jmp ..B1.146 +..B1.145: + fld %st(2) + fadd %st(1), %st + fdivr %st, %st(2) + fxch %st(2) + fstpt 40(%esp) + fldt 40(%esp) + movl $0, 40(%esp) + fstpt 56(%esp) + fldt 56(%esp) + fldt 40(%esp) + fld %st(0) + fsubr %st(2), %st + fmul %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddl 8+_ones@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fsubrp %st, %st(1) +..B1.146: + fldt 12(%esp) + fld %st(2) + fmul %st(1), %st + fld %st(2) + fmul %st(2), %st + faddp %st, %st(1) + fstpt 24(%esp) + movzwl 32(%esp), %eax + shll $16, %eax + movzwl 30(%esp), %edx + orl %edx, %eax + andl $2147483647, %eax + cmpl $65535, %eax + ja ..B1.148 +..B1.147: + fldt 40(%esp) + fmul %st(1), %st + fstpt 40(%esp) + fldt 40(%esp) + fxch %st(3) + fstpt 96(%esp) + fld %st(0) + fdivr %st(3), %st + fldt 96(%esp) + fsub %st(1), %st + fstpt 96(%esp) + fldt 96(%esp) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st, %st(3) + fxch %st(3) + fstpt 24(%esp) + movzwl 32(%esp), %eax + shll $16, %eax + movzwl 30(%esp), %edx + orl %edx, %eax + andl $2147483647, %eax + fxch %st(2) + fxch %st(1) +..B1.148: + fstp %st(1) + fstp %st(1) + fstp %st(0) + lea -98304(%eax), %edx + cmpl $2147319808, %edx + jb ..B1.84 +..B1.149: + movl 108(%esp), %ecx + cmpl $65535, %eax + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %edx + ja ..B1.151 +..B1.150: + fldt _small_value_80@GOTOFF(%edx,%ebx) + fldt _small_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 136(%esp) + jmp ..B1.152 +..B1.151: + fldt _large_value_80@GOTOFF(%edx,%ebx) + fldt _large_value_80@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 24(%esp) +..B1.152: + cmpl $0, 36(%esp) + je ..B1.154 +..B1.153: + fldcw 70(%esp) +..B1.154: + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.155: + movl $0, 36(%esp) + jmp ..B1.65 +..B1.156: + cmpl $-2147483648, 60(%esp) + jne ..B1.158 +..B1.157: + cmpl $0, 36(%esp) + je ..B1.159 +..B1.158: + fldt 8(%ebp) + fldt 20(%ebp) + fmulp %st, %st(1) + fstpt 136(%esp) + fldt 136(%esp) + fstpt 24(%esp) + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.159: + cmpl $32767, 44(%esp) + je ..B1.181 +..B1.160: + cmpl $32767, 48(%esp) + jne ..B1.20 +..B1.161: + cmpl $-2147483648, 60(%esp) + jne ..B1.20 +..B1.162: + cmpl $0, 36(%esp) + jne ..B1.20 +..B1.163: + cmpl $1073709056, %esi + jae ..B1.174 +..B1.164: + movl 32(%esp), %eax + orl %esi, %eax + jne ..B1.168 +..B1.165: + fldl _zeros@GOTOFF(%ebx) + cmpl $0, 56(%esp) + jne ..B1.180 +..B1.167: + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.168: + cmpl $65536, %esi + jae ..B1.170 +..B1.169: + fldl _smallest_value_64@GOTOFF(%ebx) + fstpl 128(%esp) +..B1.170: + cmpl $0, 56(%esp) + je ..B1.172 +..B1.171: + fldl _infs@GOTOFF(%ebx) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.172: + fldl _zeros@GOTOFF(%ebx) +..B1.173: + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.174: + addl $-1073709056, %esi + orl 24(%esp), %esi + orl 32(%esp), %esi + je ..B1.179 +..B1.175: + cmpl $0, 56(%esp) + je ..B1.177 +..B1.176: + fldl _zeros@GOTOFF(%ebx) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.177: + fldl _infs@GOTOFF(%ebx) +..B1.178: + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.179: + movl 12(%esp), %eax + fldl _ones@GOTOFF(%ebx,%eax,8) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.180: + fldl _ones@GOTOFF(%ebx) + fdivp %st, %st(1) + fstpt 24(%esp) + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.181: + cmpl $-2147483648, %edx + jne ..B1.160 +..B1.182: + cmpl $0, 32(%esp) + jne ..B1.160 +..B1.183: + cmpl $65536, %eax + jae ..B1.185 +..B1.184: + fldl _smallest_value_64@GOTOFF(%ebx) + fstpl 128(%esp) +..B1.185: + cmpl $0, 40(%esp) + movl %ecx, %eax + je ..L7 + movl $0, %eax +..L7: + movl %eax, 108(%esp) + cmpl $0, 56(%esp) + je ..B1.187 +..B1.186: + fldl _zeros@GOTOFF(%ebx,%eax,8) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.187: + fldl _infs@GOTOFF(%ebx,%eax,8) +..B1.188: + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.189: + cmpl $-2147483648, %edx + jne ..B1.158 +..B1.190: + cmpl $0, 32(%esp) + jne ..B1.158 +..B1.191: + cmpl $32767, 48(%esp) + je ..B1.156 + jmp ..B1.159 +..B1.192: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpt 24(%esp) + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.193: + movl 108(%esp), %eax + fldl _ones@GOTOFF(%ebx,%eax,8) + fdivl _zeros@GOTOFF(%ebx) + fstpt 24(%esp) + fldt 24(%esp) + addl $148, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type powl,@function + .size powl,.-powl + .data +# -- End powl + .text +# -- Begin __sqrtl + .text + .align 16,0x90 +__sqrtl: +# parameter 1: 4 + %esp +..B2.1: +..L8: + +..B2.2: + movl 4(%esp), %ecx + fldt (%ecx) + fsqrt + ret +..B2.3: + .align 16,0x90 + .type __sqrtl,@function + .size __sqrtl,.-__sqrtl + .data +# -- End __sqrtl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_43H: + .long 0 + .long 1118306304 + .type _TWO_43H,@object + .size _TWO_43H,8 + .align 4 +_exact_masks: + .long 131071 + .long 0 + .long 4294967295 + .long 1 + .long 4294967295 + .long 511 + .long 4294967295 + .long 16383 + .long 4294967295 + .long 131071 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 2097151 + .long 4294967295 + .long 8388607 + .long 4294967295 + .long 16777215 + .long 4294967295 + .long 33554431 + .long 4294967295 + .long 33554431 + .long 4294967295 + .long 67108863 + .long 4294967295 + .long 134217727 + .long 4294967295 + .long 134217727 + .long 4294967295 + .long 134217727 + .long 4294967295 + .long 268435455 + .long 4294967295 + .long 268435455 + .long 4294967295 + .long 268435455 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .type _exact_masks,@object + .size _exact_masks,376 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_LT2: + .long 180342526 + .long 2357584585 + .long 2340989257 + .long 193458247 + .long 2370723239 + .long 2317577053 + .long 2382055315 + .long 232148275 + .long 200972627 + .long 2376530255 + .long 2376860906 + .long 222325808 + .long 228268523 + .long 229816737 + .long 2387925496 + .long 239088248 + .long 235445027 + .long 219576635 + .long 2365457762 + .long 200344795 + .long 2377779510 + .long 2396359259 + .long 256760275 + .long 2390604874 + .long 2403557039 + .long 2397936349 + .long 2387307486 + .long 2389941185 + .long 2375749593 + .long 224865835 + .long 2394232861 + .long 180745560 + .long 231885773 + .long 2352962188 + .long 2306055684 + .long 206875141 + .long 258325764 + .long 2386208973 + .long 231066739 + .long 195513036 + .long 2360327132 + .long 2396045581 + .long 236564318 + .long 2282584976 + .long 2351736009 + .long 236364231 + .long 2384427773 + .long 267355851 + .long 255771104 + .long 265321597 + .long 2384375360 + .long 2399209743 + .long 186438128 + .long 2407131686 + .long 2382793784 + .long 2395218767 + .long 229223248 + .long 256892528 + .long 2394735602 + .long 2385223602 + .long 2372921302 + .long 2398642377 + .long 2399679754 + .long 255686225 + .long 220689523 + .long 2385772978 + .long 209771590 + .long 2396079173 + .long 247531082 + .long 236085121 + .long 264660069 + .long 2357821390 + .long 236486650 + .long 2368138461 + .long 239690108 + .long 2396070228 + .long 196955922 + .long 217533735 + .long 255641653 + .long 249646543 + .long 253232621 + .long 246212714 + .long 2396427575 + .long 261629730 + .long 2364672847 + .long 2403865410 + .long 251273869 + .long 261125380 + .long 2388321036 + .long 2375891827 + .long 2381014317 + .long 2414822930 + .long 2406245053 + .long 2406988902 + .long 2395399973 + .long 213294711 + .long 2401319324 + .long 265450299 + .long 231845893 + .long 260578794 + .long 258934474 + .long 2368795786 + .long 2422506717 + .long 218205033 + .long 258708287 + .long 257044854 + .long 2396281866 + .long 2415975150 + .long 257697283 + .long 2393801226 + .long 2388654986 + .long 262910764 + .long 235638432 + .long 268054962 + .long 271083258 + .long 256780444 + .long 256064350 + .long 252979189 + .long 2420460964 + .long 233178508 + .long 251655134 + .long 2404577473 + .long 2408876374 + .long 2401072099 + .long 228623072 + .long 2421706621 + .long 2353033467 + .long 2411792212 + .long 2345330012 + .long 2397189005 + .long 243110369 + .long 2408213151 + .long 219253901 + .long 246695172 + .long 259288551 + .long 254210780 + .long 261865355 + .long 230359170 + .long 263524551 + .long 2405618542 + .long 2399869921 + .long 233826616 + .long 2362750769 + .long 257576291 + .long 251808114 + .long 2403390977 + .long 253249058 + .long 261065811 + .long 215406974 + .long 2407628993 + .long 258391343 + .long 2394470699 + .long 258495470 + .long 2415771687 + .long 224670583 + .long 263047889 + .long 2389031226 + .long 259453051 + .long 266564569 + .long 2422023012 + .long 264051375 + .long 2409075373 + .long 252244729 + .long 220302768 + .long 254847756 + .long 243124762 + .long 2363519942 + .long 2393496158 + .long 2402135082 + .long 2365706590 + .long 237902971 + .long 262295026 + .long 252689257 + .long 236678680 + .long 255167613 + .long 2406879752 + .long 274254693 + .long 259983961 + .long 245852525 + .long 256459527 + .long 220533989 + .long 245387845 + .long 243835221 + .long 2377853444 + .long 274540751 + .long 229741069 + .long 263626566 + .long 220608387 + .long 226161046 + .long 247301717 + .long 268433686 + .long 222008210 + .long 2414961139 + .long 276137642 + .long 2412197898 + .long 258445918 + .long 2412645341 + .long 260857859 + .long 263113037 + .long 2386484264 + .long 2390742630 + .long 259665290 + .long 2363417497 + .long 2384122046 + .long 263493300 + .long 219472625 + .long 2420433676 + .long 274201285 + .long 2404911312 + .long 257926520 + .long 260332203 + .long 256695016 + .long 218494534 + .long 2420150889 + .long 2414586287 + .long 267006159 + .long 231320206 + .long 2382797064 + .long 2414903062 + .long 263514471 + .long 2406010284 + .long 2410428205 + .long 2414319991 + .long 249083715 + .long 2381171937 + .long 236369629 + .long 2409614279 + .long 2424220710 + .long 2378379154 + .long 218677462 + .long 2382987336 + .long 2377870458 + .long 258155310 + .long 2368239928 + .long 2414896572 + .long 193310867 + .long 256673115 + .long 2406448055 + .long 271719709 + .long 248566852 + .long 229016248 + .long 272541555 + .long 2382115967 + .long 2375311600 + .long 2393766434 + .long 257187362 + .long 277931545 + .long 281038165 + .long 2373962226 + .long 261638946 + .long 255465134 + .long 273460929 + .long 275851296 + .long 2417166241 + .long 2361106656 + .long 278653754 + .type _LT2,@object + .size _LT2,1024 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +ESC2_BIAS: + .long 4095 + .long 28671 + .type ESC2_BIAS,@object + .size ESC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_invsqrtl_scales: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 20479 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 12287 + .word 0 + .type _invsqrtl_scales,@object + .size _invsqrtl_scales,48 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_LP: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49149 + .word 0 + .word 52785 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 44453 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 25655 + .word 14678 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 38741 + .word 53722 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 45676 + .word 59527 + .word 48579 + .word 58254 + .word 16379 + .word 0 + .word 41682 + .word 64796 + .word 25002 + .word 52429 + .word 49147 + .word 0 + .type _LP,@object + .size _LP,108 + .align 2 +_LLN2: + .word 0 + .word 53711 + .word 6135 + .word 45426 + .word 16382 + .word 0 + .word 2022 + .word 26416 + .word 37831 + .word 62295 + .word 16333 + .word 0 + .type _LLN2,@object + .size _LLN2,24 + .align 2 +_EP1: + .word 43691 + .word 10 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 30584 + .word 43703 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _EP1,@object + .size _EP1,24 + .align 2 +_EP: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _EP,@object + .size _EP,60 + .align 2 +_Eexpbut: + .word 60207 + .word 4624 + .word 35943 + .word 45420 + .word 49164 + .word 0 + .type _Eexpbut,@object + .size _Eexpbut,12 + .align 2 +_ESC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 28671 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 4095 + .word 0 + .type _ESC2,@object + .size _ESC2,24 + .data + .hidden __libm_rcp_table_256 + .hidden __libm_logl_table_256 + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/q2l.S b/external/sgx_libm/ia32/q2l.S new file mode 100644 index 0000000000..a9c7852f18 --- /dev/null +++ b/external/sgx_libm/ia32/q2l.S @@ -0,0 +1,353 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "q2l.c" + .text +..TXTST0: +# -- Begin __qtol + .text + .align 16,0x90 + .globl __qtol +__qtol: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp + movl 8(%ebp), %eax + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + movl 12(%eax), %edx + movl 8(%eax), %esi + movl %ecx, 16(%esp) + movl (%eax), %ecx + movl 4(%eax), %ebx + movl %edx, %eax + movl %edx, 12(%esp) + movzwl %dx, %edi + movl %esi, %edx + shrl $17, %edx + shll $15, %edi + orl %edi, %edx + movl %ebx, %edi + shll $15, %esi + shrl $17, %edi + orl %edi, %esi + movl %ecx, %edi + shrl $16, %eax + shrl $17, %edi + shll $15, %ebx + movl %eax, 24(%esp) + andl $32767, %eax + shll $15, %ecx + orl %ebx, %edi + movl %edi, 28(%esp) + cmpl $32767, %eax + jne ..B1.7 +..B1.2: + movl %edi, %eax + orl %esi, %ecx + orl %edx, %eax + orl %eax, %ecx + je ..B1.6 +..B1.3: + movl %edx, %eax + xorl %ecx, %ecx + andl $1073741824, %eax + orl %eax, %ecx + jne ..B1.5 +..B1.4: + movl 16(%esp), %eax + movl p_zero@GOTOFF(%eax), %ecx + fldl (%ecx) + fdiv %st(0), %st + fstpl (%esp) +..B1.5: + orl $-1073741824, %edx +..B1.6: + movl 24(%esp), %eax + orl $-2147483648, %edx + movl %eax, 16(%esp) + movl %esi, 8(%esp) + movl %edx, 12(%esp) + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.7: + testl %eax, %eax + je ..B1.9 +..B1.8: + orl $-2147483648, %edx + jmp ..B1.11 +..B1.9: + movl %esi, %edi + movl %edx, %ebx + orl 28(%esp), %ebx + orl %ecx, %edi + orl %ebx, %edi + je ..B1.22 +..B1.10: + movl 16(%esp), %edi + movl p_tiny@GOTOFF(%edi), %ebx + fldl (%ebx) + movl p_one@GOTOFF(%edi), %ebx + fmull (%ebx) + fstpl (%esp) +..B1.11: + movl %ecx, %ebx + orl 28(%esp), %ebx + je ..B1.21 +..B1.12: + fnstcw 20(%esp) +..B1.13: + movl 20(%esp), %ebx + andl $3072, %ebx + movl %ebx, 8(%esp) + jne ..B1.15 +..B1.14: + xorl %ebx, %ebx + movl 28(%esp), %edi + subl %ebx, %edi + jl ..B1.23 + jmp ..B1.18 +..B1.15: + testl $-2147483648, 12(%esp) + je ..B1.17 +..B1.16: + cmpl $1024, 8(%esp) + je ..B1.23 + jmp ..B1.18 +..B1.17: + cmpl $2048, 8(%esp) + je ..B1.23 +..B1.18: + testl %eax, %eax + jne ..B1.20 +..B1.19: + movl 16(%esp), %eax + movl p_norm@GOTOFF(%eax), %ecx + fldl (%ecx) + fmul %st(0), %st + fstpl (%esp) + jmp ..B1.21 +..B1.20: + movl 16(%esp), %eax + movl p_one@GOTOFF(%eax), %ecx + movl p_norm@GOTOFF(%eax), %ebx + fldl (%ecx) + faddl (%ebx) + fstpl (%esp) +..B1.21: + movl 24(%esp), %eax + movl %eax, 16(%esp) + movl %esi, 8(%esp) + movl %edx, 12(%esp) + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.22: + movl 24(%esp), %eax + xorl %edx, %edx + movl %eax, 16(%esp) + movl %edx, 8(%esp) + movl %edx, 12(%esp) + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + addl $1, %esi + adcl $0, %edx + testl %eax, %eax + je ..B1.32 +..B1.24: + movl %esi, %eax + orl %edx, %eax + jne ..B1.28 +..B1.25: + movl 24(%esp), %eax + xorl %esi, %esi + incl %eax + movl $-2147483648, %edx + movl %eax, 24(%esp) + andl $32767, %eax +..B1.26: + cmpl $32767, %eax + jne ..B1.18 +..B1.27: + movl 16(%esp), %eax + movl p_huge@GOTOFF(%eax), %ecx + fldl (%ecx) + fmul %st(0), %st + fstpl (%esp) + jmp ..B1.21 +..B1.28: + movl $-2147483648, %eax + movl 28(%esp), %ebx + subl %eax, %ebx + orl %ebx, %ecx + jne ..B1.30 +..B1.29: + movl $1, %eax + jmp ..B1.31 +..B1.30: + xorl %eax, %eax +..B1.31: + xorl %ecx, %ecx + cmpl $0, 8(%esp) + sete %cl + andl %ecx, %eax + notl %eax + andl %eax, %esi + movl 16(%esp), %eax + movl p_one@GOTOFF(%eax), %ebx + movl p_norm@GOTOFF(%eax), %eax + fldl (%ebx) + faddl (%eax) + fstpl (%esp) + jmp ..B1.21 +..B1.32: + movl $-2147483648, %eax + movl 28(%esp), %ebx + subl %eax, %ebx + orl %ebx, %ecx + jne ..B1.34 +..B1.33: + movl $1, %ecx + jmp ..B1.35 +..B1.34: + xorl %ecx, %ecx +..B1.35: + xorl %edi, %edi + xorl %eax, %eax + cmpl $0, 8(%esp) + sete %al + andl %eax, %ecx + notl %ecx + andl %ecx, %esi + movl %edx, %ecx + subl %edi, %ecx + jge ..B1.19 +..B1.36: + movl 24(%esp), %eax + incl %eax + movl %eax, 24(%esp) + andl $32767, %eax + jmp ..B1.26 + .align 16,0x90 + .type __qtol,@function + .size __qtol,.-__qtol + .data +# -- End __qtol + .data + .align 4 + .align 4 +p_zero: + .long d_zero + .type p_zero,@object + .size p_zero,4 + .align 4 +p_tiny: + .long d_tiny + .type p_tiny,@object + .size p_tiny,4 + .align 4 +p_one: + .long d_one + .type p_one,@object + .size p_one,4 + .align 4 +p_norm: + .long d_norm + .type p_norm,@object + .size p_norm,4 + .align 4 +p_huge: + .long d_huge + .type p_huge,@object + .size p_huge,4 + .section .rodata, "a" + .align 8 + .align 8 +d_zero: + .long 0x00000000,0x00000000 + .type d_zero,@object + .size d_zero,8 + .align 8 +d_tiny: + .long 0x00000001,0x00000000 + .type d_tiny,@object + .size d_tiny,8 + .align 8 +d_one: + .long 0x00000000,0x3ff00000 + .type d_one,@object + .size d_one,8 + .align 8 +d_norm: + .long 0x00000000,0x00100000 + .type d_norm,@object + .size d_norm,8 + .align 8 +d_huge: + .long 0xffffffff,0x7fefffff + .type d_huge,@object + .size d_huge,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/rcp_table.S b/external/sgx_libm/ia32/rcp_table.S new file mode 100644 index 0000000000..1877177d5a --- /dev/null +++ b/external/sgx_libm/ia32/rcp_table.S @@ -0,0 +1,822 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rcp_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_rcp_table_256 + .globl __libm_rcp_table_256 +__libm_rcp_table_256: + .long 0x3f7f8000 + .long 0x3f7e8000 + .long 0x3f7d8000 + .long 0x3f7c8000 + .long 0x3f7ba000 + .long 0x3f7aa000 + .long 0x3f79a000 + .long 0x3f78c000 + .long 0x3f77c000 + .long 0x3f76e000 + .long 0x3f75e000 + .long 0x3f750000 + .long 0x3f742000 + .long 0x3f732000 + .long 0x3f724000 + .long 0x3f716000 + .long 0x3f708000 + .long 0x3f6fa000 + .long 0x3f6ec000 + .long 0x3f6de000 + .long 0x3f6d0000 + .long 0x3f6c2000 + .long 0x3f6b6000 + .long 0x3f6a8000 + .long 0x3f69a000 + .long 0x3f68c000 + .long 0x3f680000 + .long 0x3f672000 + .long 0x3f666000 + .long 0x3f658000 + .long 0x3f64c000 + .long 0x3f640000 + .long 0x3f632000 + .long 0x3f626000 + .long 0x3f61a000 + .long 0x3f60e000 + .long 0x3f600000 + .long 0x3f5f4000 + .long 0x3f5e8000 + .long 0x3f5dc000 + .long 0x3f5d0000 + .long 0x3f5c4000 + .long 0x3f5b8000 + .long 0x3f5ae000 + .long 0x3f5a2000 + .long 0x3f596000 + .long 0x3f58a000 + .long 0x3f57e000 + .long 0x3f574000 + .long 0x3f568000 + .long 0x3f55e000 + .long 0x3f552000 + .long 0x3f546000 + .long 0x3f53c000 + .long 0x3f532000 + .long 0x3f526000 + .long 0x3f51c000 + .long 0x3f510000 + .long 0x3f506000 + .long 0x3f4fc000 + .long 0x3f4f2000 + .long 0x3f4e6000 + .long 0x3f4dc000 + .long 0x3f4d2000 + .long 0x3f4c8000 + .long 0x3f4be000 + .long 0x3f4b4000 + .long 0x3f4aa000 + .long 0x3f4a0000 + .long 0x3f496000 + .long 0x3f48c000 + .long 0x3f482000 + .long 0x3f478000 + .long 0x3f46e000 + .long 0x3f464000 + .long 0x3f45c000 + .long 0x3f452000 + .long 0x3f448000 + .long 0x3f43e000 + .long 0x3f436000 + .long 0x3f42c000 + .long 0x3f422000 + .long 0x3f41a000 + .long 0x3f410000 + .long 0x3f408000 + .long 0x3f3fe000 + .long 0x3f3f6000 + .long 0x3f3ec000 + .long 0x3f3e4000 + .long 0x3f3da000 + .long 0x3f3d2000 + .long 0x3f3ca000 + .long 0x3f3c0000 + .long 0x3f3b8000 + .long 0x3f3b0000 + .long 0x3f3a8000 + .long 0x3f39e000 + .long 0x3f396000 + .long 0x3f38e000 + .long 0x3f386000 + .long 0x3f37e000 + .long 0x3f376000 + .long 0x3f36c000 + .long 0x3f364000 + .long 0x3f35c000 + .long 0x3f354000 + .long 0x3f34c000 + .long 0x3f344000 + .long 0x3f33c000 + .long 0x3f334000 + .long 0x3f32e000 + .long 0x3f326000 + .long 0x3f31e000 + .long 0x3f316000 + .long 0x3f30e000 + .long 0x3f306000 + .long 0x3f2fe000 + .long 0x3f2f8000 + .long 0x3f2f0000 + .long 0x3f2e8000 + .long 0x3f2e2000 + .long 0x3f2da000 + .long 0x3f2d2000 + .long 0x3f2cc000 + .long 0x3f2c4000 + .long 0x3f2bc000 + .long 0x3f2b6000 + .long 0x3f2ae000 + .long 0x3f2a8000 + .long 0x3f2a0000 + .long 0x3f29a000 + .long 0x3f292000 + .long 0x3f28c000 + .long 0x3f284000 + .long 0x3f27e000 + .long 0x3f276000 + .long 0x3f270000 + .long 0x3f268000 + .long 0x3f262000 + .long 0x3f25c000 + .long 0x3f254000 + .long 0x3f24e000 + .long 0x3f248000 + .long 0x3f240000 + .long 0x3f23a000 + .long 0x3f234000 + .long 0x3f22e000 + .long 0x3f226000 + .long 0x3f220000 + .long 0x3f21a000 + .long 0x3f214000 + .long 0x3f20e000 + .long 0x3f206000 + .long 0x3f200000 + .long 0x3f1fa000 + .long 0x3f1f4000 + .long 0x3f1ee000 + .long 0x3f1e8000 + .long 0x3f1e2000 + .long 0x3f1dc000 + .long 0x3f1d6000 + .long 0x3f1d0000 + .long 0x3f1ca000 + .long 0x3f1c4000 + .long 0x3f1be000 + .long 0x3f1b8000 + .long 0x3f1b2000 + .long 0x3f1ac000 + .long 0x3f1a6000 + .long 0x3f1a0000 + .long 0x3f19a000 + .long 0x3f194000 + .long 0x3f190000 + .long 0x3f18a000 + .long 0x3f184000 + .long 0x3f17e000 + .long 0x3f178000 + .long 0x3f172000 + .long 0x3f16e000 + .long 0x3f168000 + .long 0x3f162000 + .long 0x3f15c000 + .long 0x3f158000 + .long 0x3f152000 + .long 0x3f14c000 + .long 0x3f148000 + .long 0x3f142000 + .long 0x3f13c000 + .long 0x3f138000 + .long 0x3f132000 + .long 0x3f12c000 + .long 0x3f128000 + .long 0x3f122000 + .long 0x3f11c000 + .long 0x3f118000 + .long 0x3f112000 + .long 0x3f10e000 + .long 0x3f108000 + .long 0x3f104000 + .long 0x3f0fe000 + .long 0x3f0f8000 + .long 0x3f0f4000 + .long 0x3f0ee000 + .long 0x3f0ea000 + .long 0x3f0e6000 + .long 0x3f0e0000 + .long 0x3f0dc000 + .long 0x3f0d6000 + .long 0x3f0d2000 + .long 0x3f0cc000 + .long 0x3f0c8000 + .long 0x3f0c2000 + .long 0x3f0be000 + .long 0x3f0ba000 + .long 0x3f0b4000 + .long 0x3f0b0000 + .long 0x3f0ac000 + .long 0x3f0a6000 + .long 0x3f0a2000 + .long 0x3f09e000 + .long 0x3f098000 + .long 0x3f094000 + .long 0x3f090000 + .long 0x3f08a000 + .long 0x3f086000 + .long 0x3f082000 + .long 0x3f07e000 + .long 0x3f078000 + .long 0x3f074000 + .long 0x3f070000 + .long 0x3f06c000 + .long 0x3f066000 + .long 0x3f062000 + .long 0x3f05e000 + .long 0x3f05a000 + .long 0x3f056000 + .long 0x3f052000 + .long 0x3f04c000 + .long 0x3f048000 + .long 0x3f044000 + .long 0x3f040000 + .long 0x3f03c000 + .long 0x3f038000 + .long 0x3f034000 + .long 0x3f030000 + .long 0x3f02a000 + .long 0x3f026000 + .long 0x3f022000 + .long 0x3f01e000 + .long 0x3f01a000 + .long 0x3f016000 + .long 0x3f012000 + .long 0x3f00e000 + .long 0x3f00a000 + .long 0x3f006000 + .long 0x3f002000 + .type __libm_rcp_table_256,@object + .size __libm_rcp_table_256,1024 + .align 16 + .hidden __libm_double_rcp_table_256 + .globl __libm_double_rcp_table_256 +__libm_double_rcp_table_256: + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .type __libm_double_rcp_table_256,@object + .size __libm_double_rcp_table_256,2048 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/remainder.S b/external/sgx_libm/ia32/remainder.S new file mode 100644 index 0000000000..2e9c586a07 --- /dev/null +++ b/external/sgx_libm/ia32/remainder.S @@ -0,0 +1,199 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remainder.c" + .text +..TXTST0: +# -- Begin remainder + .text + .align 16,0x90 + .globl remainder +remainder: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp + movzwl 22(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + testl %ecx, %ecx + jne ..B1.4 +..B1.2: + testl $1048575, 20(%ebp) + jne ..B1.4 +..B1.3: + cmpl $0, 16(%ebp) + je ..B1.9 +..B1.4: + movzwl 14(%ebp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + je ..B1.28 +..B1.5: + cmpl $2047, %ecx + je ..B1.14 +..B1.7: + fldl 16(%ebp) + fldl 8(%ebp) +.L_2TAG_PACKET_0.0.2: + fprem1 + fstsw %ax + sahf + jp .L_2TAG_PACKET_0.0.2 + fstp %st(1) + fstpl (%esp) +..B1.8: + fldl (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.9: + movzwl 14(%ebp), %edx + andl $32752, %edx + cmpl $32752, %edx + je ..B1.11 +..B1.10: + fldl _infs@GOTOFF(%eax) + fmull _zeros@GOTOFF(%eax) + fstl (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.11: + testl $1048575, 12(%ebp) + jne ..B1.13 +..B1.12: + cmpl $0, 8(%ebp) + je ..B1.10 +..B1.13: + fldl 8(%ebp) + faddl 16(%ebp) + fstl (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.14: + testl $1048575, 20(%ebp) + jne ..B1.19 +..B1.15: + cmpl $0, 16(%ebp) + jne ..B1.19 +..B1.16: + cmpl $2047, %edx + je ..B1.25 +..B1.17: + cmpl $2047, %ecx + je ..B1.20 + jmp ..B1.7 +..B1.19: + fldl 8(%ebp) + faddl 16(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.20: + testl $1048575, 20(%ebp) + jne ..B1.7 +..B1.21: + cmpl $0, 16(%ebp) + jne ..B1.7 +..B1.22: + fldl 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.25: + testl $1048575, 12(%ebp) + jne ..B1.17 +..B1.26: + cmpl $0, 8(%ebp) + jne ..B1.17 +..B1.27: + fldl _infs@GOTOFF(%eax) + fmull _zeros@GOTOFF(%eax) + movl %ebp, %esp + popl %ebp + ret +..B1.28: + testl $1048575, 12(%ebp) + jne ..B1.19 +..B1.29: + cmpl $0, 8(%ebp) + jne ..B1.19 +..B1.30: + cmpl $2047, %ecx + je ..B1.14 + jmp ..B1.16 + .align 16,0x90 + .type remainder,@function + .size remainder,.-remainder + .data +# -- End remainder + .section .rodata, "a" + .align 4 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End + + .globl drem + .equ drem, remainder + diff --git a/external/sgx_libm/ia32/remainderf.S b/external/sgx_libm/ia32/remainderf.S new file mode 100644 index 0000000000..c526c49495 --- /dev/null +++ b/external/sgx_libm/ia32/remainderf.S @@ -0,0 +1,161 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remainderf.c" + .text +..TXTST0: +# -- Begin remainderf + .text + .align 16,0x90 + .globl remainderf +remainderf: +# parameter 1: 16 + %esp +# parameter 2: 20 + %esp +..B1.1: +..L1: + + subl $12, %esp + movzwl 22(%esp), %ecx + andl $32640, %ecx + shrl $7, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + testl %ecx, %ecx + jne ..B1.3 +..B1.2: + testl $8388607, 20(%esp) + je ..B1.8 +..B1.3: + movzwl 18(%esp), %edx + andl $32640, %edx + shrl $7, %edx + cmpl $255, %edx + je ..B1.22 +..B1.4: + cmpl $255, %ecx + je ..B1.12 +..B1.6: + flds 20(%esp) + flds 16(%esp) +.L_2TAG_PACKET_0.0.2: + fprem1 + fstsw %ax + sahf + jp .L_2TAG_PACKET_0.0.2 + fstp %st(1) + fstps (%esp) +..B1.7: + flds (%esp) + addl $12, %esp + ret +..B1.8: + movzwl 18(%esp), %edx + andl $32640, %edx + cmpl $32640, %edx + jne ..B1.11 +..B1.9: + testl $8388607, 16(%esp) + je ..B1.11 +..B1.10: + flds 16(%esp) + fadds 20(%esp) + fsts (%esp) + addl $12, %esp + ret +..B1.11: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%eax) + fsts (%esp) + addl $12, %esp + ret +..B1.12: + testl $8388607, 20(%esp) + jne ..B1.16 +..B1.13: + cmpl $255, %edx + je ..B1.20 +..B1.14: + cmpl $255, %ecx + je ..B1.17 + jmp ..B1.6 +..B1.16: + flds 16(%esp) + fadds 20(%esp) + addl $12, %esp + ret +..B1.17: + testl $8388607, 20(%esp) + jne ..B1.6 +..B1.18: + flds 16(%esp) + addl $12, %esp + ret +..B1.20: + testl $8388607, 16(%esp) + jne ..B1.14 +..B1.21: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%eax) + addl $12, %esp + ret +..B1.22: + testl $8388607, 16(%esp) + jne ..B1.16 +..B1.23: + cmpl $255, %ecx + je ..B1.12 + jmp ..B1.13 + .align 16,0x90 + .type remainderf,@function + .size remainderf,.-remainderf + .data +# -- End remainderf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x7f800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .data + .section .note.GNU-stack, "" +# End + + .globl dremf + .equ dremf, remainderf + diff --git a/external/sgx_libm/ia32/remainderl.S b/external/sgx_libm/ia32/remainderl.S new file mode 100644 index 0000000000..168204a7b5 --- /dev/null +++ b/external/sgx_libm/ia32/remainderl.S @@ -0,0 +1,340 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remainderl.c" + .text +..TXTST0: +# -- Begin remainderl + .text + .align 16,0x90 + .globl remainderl +remainderl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + subl $28, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 28(%ebp), %edx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + andl $32767, %edx + jne ..B1.6 +..B1.4: + cmpl $0, 24(%ebp) + jne ..B1.6 +..B1.5: + cmpl $0, 20(%ebp) + je ..B1.45 +..B1.6: + movzwl 16(%ebp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.42 +..B1.7: + cmpl $32767, %edx + je ..B1.17 +..B1.8: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.16 +..B1.9: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.10: + fldcw 12(%esp) +..B1.11: + movl $1, %esi +..B1.12: + addl $-16, %esp + lea 8(%ebp), %eax + movl %eax, (%esp) + call __remainderl +..B1.60: + fstpt 16(%esp) + addl $16, %esp +..B1.13: + testl %esi, %esi + je ..B1.15 +..B1.14: + fldcw 14(%esp) +..B1.15: + fldt (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + xorl %esi, %esi + jmp ..B1.12 +..B1.17: + cmpl $-2147483648, 24(%ebp) + jne ..B1.19 +..B1.18: + cmpl $0, 20(%ebp) + je ..B1.25 +..B1.19: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.31 +..B1.20: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.21: + fldcw 12(%esp) +..B1.22: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt (%esp) +..B1.23: + fldcw 14(%esp) +..B1.24: + fldt (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + cmpl $32767, %ecx + je ..B1.32 +..B1.26: + testl %ecx, %ecx + jne ..B1.30 +..B1.27: + cmpl $0, 12(%ebp) + jne ..B1.29 +..B1.28: + cmpl $0, 8(%ebp) + je ..B1.30 +..B1.29: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl 16(%esp) +..B1.30: + fldt 8(%ebp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt (%esp) + jmp ..B1.24 +..B1.32: + cmpl $-2147483648, 12(%ebp) + jne ..B1.30 +..B1.33: + cmpl $0, 8(%ebp) + jne ..B1.30 +..B1.34: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.41 +..B1.35: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.36: + fldcw 12(%esp) +..B1.37: + movl $1, %edx +..B1.38: + fldl _infs@GOTOFF(%eax) + testl %edx, %edx + fmull _zeros@GOTOFF(%eax) + fstpl (%esp) + je ..B1.40 +..B1.39: + fldcw 14(%esp) +..B1.40: + fldl (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + xorl %edx, %edx + jmp ..B1.38 +..B1.42: + cmpl $-2147483648, 12(%ebp) + jne ..B1.19 +..B1.43: + cmpl $0, 8(%ebp) + jne ..B1.19 +..B1.44: + cmpl $32767, %edx + je ..B1.17 + jmp ..B1.25 +..B1.45: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.57 +..B1.46: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.47: + fldcw 12(%esp) +..B1.48: + movl $1, %ecx +..B1.49: + movzwl 16(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.54 +..B1.50: + fldl _infs@GOTOFF(%eax) + fmull _zeros@GOTOFF(%eax) + fstpt (%esp) +..B1.51: + testl %ecx, %ecx + je ..B1.53 +..B1.52: + fldcw 14(%esp) +..B1.53: + fldt (%esp) + addl $28, %esp + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.54: + cmpl $-2147483648, 12(%ebp) + jne ..B1.56 +..B1.55: + cmpl $0, 8(%ebp) + je ..B1.50 +..B1.56: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) + jmp ..B1.51 +..B1.57: + xorl %ecx, %ecx + jmp ..B1.49 + .align 16,0x90 + .type remainderl,@function + .size remainderl,.-remainderl + .data +# -- End remainderl + .text +# -- Begin __remainderl + .text + .align 16,0x90 +__remainderl: +# parameter 1: 4 + %esp +..B2.1: +..L3: + +..B2.2: + movl 4(%esp), %ecx + fldt 12(%ecx) + fldt (%ecx) +.L_2TAG_PACKET_0.0.2: + fprem1 + fstsw %ax + sahf + jp .L_2TAG_PACKET_0.0.2 + fstp %st(1) + ret +..B2.3: + .align 16,0x90 + .type __remainderl,@function + .size __remainderl,.-__remainderl + .data +# -- End __remainderl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +# End + + .globl dreml + .equ dreml, remainderl + diff --git a/external/sgx_libm/ia32/remquo.S b/external/sgx_libm/ia32/remquo.S new file mode 100644 index 0000000000..d154009af2 --- /dev/null +++ b/external/sgx_libm/ia32/remquo.S @@ -0,0 +1,573 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remquo.c" + .text +..TXTST0: +# -- Begin remquo + .text + .align 16,0x90 + .globl remquo +remquo: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 24 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp + movl 24(%ebp), %ecx + movl %ecx, 56(%esp) + movl 12(%ebp), %ecx + movl %ecx, %edx + movl 20(%ebp), %esi + movl %esi, %eax + andl $-2147483648, %edx + andl $-2147483648, %eax + cmpl %edx, %eax + movl $-1, %eax + movl %edx, 48(%esp) + jne ..L2 + movl $1, %eax +..L2: + andl $2147483647, %ecx + andl $2147483647, %esi + movl %ecx, %edi + movl %esi, %ebx + andl $2146435072, %edi + andl $2146435072, %ebx + movl %eax, 52(%esp) + shrl $20, %edi + movl 8(%ebp), %eax + movl 16(%ebp), %edx + shrl $20, %ebx + movl %eax, 8(%esp) + cmpl $2047, %edi + movl %ecx, 12(%esp) + movl %edx, 68(%esp) + movl %edx, 40(%esp) + movl %esi, 44(%esp) + movl %edi, 60(%esp) + movl %ebx, 64(%esp) + je ..B1.5 +..B1.2: + cmpl $2047, 64(%esp) + je ..B1.5 +..B1.3: + movl %eax, %edx + orl %ecx, %edx + je ..B1.5 +..B1.4: + movl 68(%esp), %edx + orl %esi, %edx + jne ..B1.6 +..B1.5: + movl $1, %edi + jmp ..B1.7 +..B1.6: + xorl %edi, %edi +..B1.7: + fldl 8(%esp) + movl %ecx, %ebx + fldl 40(%esp) + movl %esi, %edx + andl $1048575, %ebx + andl $1048575, %edx + movl %edx, 16(%esp) + testl %edi, %edi + je ..B1.16 +..B1.8: + fstp %st(1) + fstp %st(0) + movl 56(%esp), %edx + movl %ecx, %ebx + movl $0, (%edx) + movl $2146435072, %edx + subl %edx, %ebx + jb ..B1.9 +..B1.86: + orl %eax, %ebx + jne ..B1.10 +..B1.9: + movl %esi, %ebx + subl %edx, %ebx + jb ..B1.11 +..B1.87: + orl 68(%esp), %ebx + je ..B1.11 +..B1.10: + fldl 8(%ebp) + faddl 16(%ebp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.11: + movl 68(%esp), %ebx + orl %esi, %ebx + je ..B1.13 +..B1.12: + subl %edx, %ecx + orl %ecx, %eax + jne ..B1.14 +..B1.13: + fldz + fdiv %st(0), %st + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.14: + fldl 8(%ebp) +..B1.15: + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.16: + movl 68(%esp), %edx + movl %edx, 32(%esp) + movl 60(%esp), %edx + subl 64(%esp), %edx + movl 16(%esp), %edi + cmpl $31, %edx + movl %edi, 36(%esp) + fxch %st(1) + fstpl 24(%esp) + jle ..B1.21 +..B1.17: + cmpl $2016, 64(%esp) + jge ..B1.21 +..B1.18: + movl %eax, 8(%esp) + call ..L3 +..L3: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L3](%eax), %eax + fstl 16(%esp) + movl %ebx, 12(%esp) + fldl .L_2il0floatpacket.0@GOTOFF(%eax) + fmulp %st, %st(1) + fstpl (%esp) +..B1.19: + fldl (%esp) + fldl 24(%esp) +.L_2TAG_PACKET_0.0.2: + fprem + fstsw %ax + sahf + jp .L_2TAG_PACKET_0.0.2 + fstp %st(1) + fstpl 24(%esp) +..B1.20: + fldl 16(%esp) + movl 28(%esp), %ecx + movl %ecx, %ebx + andl $2146435072, %ebx + shrl $20, %ebx + movl 40(%esp), %edx + movl %ebx, 60(%esp) + movl %ecx, %ebx + movl 24(%esp), %eax + andl $1048575, %ebx + movl 44(%esp), %esi + movl %edx, 68(%esp) +..B1.21: + movl %eax, %edi + movl %ecx, %edx + subl 68(%esp), %edi + sbbl %esi, %edx + movl %edx, 16(%esp) + jb ..B1.22 +..B1.88: + orl 16(%esp), %edi + jne ..B1.34 +..B1.22: + subl 68(%esp), %eax + subl %esi, %ecx + orl %ecx, %eax + je ..B1.33 +..B1.23: + fldl 24(%esp) + cmpl $2046, 60(%esp) + je ..B1.29 +..B1.24: + fld %st(0) + fadd %st(1), %st + fcomp %st(2) + fnstsw %ax + sahf + ja ..B1.29 + jp ..B1.29 +..B1.25: + fstp %st(1) + movl 56(%esp), %eax + cmpl $0, 48(%esp) + movl $0, (%eax) + je ..B1.28 +..B1.26: + fchs +..B1.28: + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.29: + movl 56(%esp), %edx + movl 52(%esp), %eax + movl %eax, (%edx) +..B1.30: + cmpl $0, 48(%esp) + fsubp %st, %st(1) + je ..B1.32 +..B1.31: + fchs +..B1.32: + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.33: + fstp %st(0) + fldz + fmull 8(%ebp) + movl 56(%esp), %edx + movl 52(%esp), %eax + movl %eax, (%edx) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.34: + cmpl $0, 60(%esp) + jne ..B1.43 +..B1.35: + movl %eax, %edx + orl %ebx, %edx + je ..B1.43 +..B1.36: + movl %eax, 8(%esp) + testl %ebx, %ebx + movl %ebx, 12(%esp) + je ..B1.38 +..B1.37: + bsr %ebx, %edx + negl %edx + addl $20, %edx + movl %edx, 60(%esp) + jmp ..B1.39 +..B1.38: + bsr 8(%esp), %edx + negl %edx + addl $52, %edx + movl %edx, 60(%esp) +..B1.39: + cmpl $31, 60(%esp) + jbe ..B1.41 +..B1.40: + movl %eax, %ebx + xorl %esi, %esi + movl %edx, %ecx + shll %cl, %ebx +..B1.42: + movl %edx, %eax + negl %eax + incl %eax + movl %eax, 60(%esp) + jmp ..B1.44 +..B1.41: + movl %eax, %esi + movl %edx, %ecx + shldl %cl, %eax, %ebx + shll %cl, %esi + jmp ..B1.42 +..B1.43: + movl %eax, %esi + orl $1048576, %ebx +..B1.44: + movl 36(%esp), %edx + movl 32(%esp), %eax + movl %edx, 20(%esp) + cmpl $0, 64(%esp) + jne ..B1.53 +..B1.45: + movl %eax, %edx + orl 20(%esp), %edx + je ..B1.53 +..B1.46: + cmpl $0, 20(%esp) + je ..B1.48 +..B1.47: + bsr 20(%esp), %edx + negl %edx + addl $20, %edx + movl %edx, 64(%esp) + jmp ..B1.49 +..B1.48: + bsr 32(%esp), %edx + negl %edx + addl $52, %edx + movl %edx, 64(%esp) +..B1.49: + cmpl $31, 64(%esp) + jbe ..B1.51 +..B1.50: + movl %edx, %ecx + shll %cl, %eax + movl $0, 16(%esp) + movl %eax, 20(%esp) +..B1.52: + movl %ecx, %eax + negl %eax + incl %eax + movl %eax, 64(%esp) + jmp ..B1.54 +..B1.51: + movl %edx, %ecx + movl 20(%esp), %edx + shldl %cl, %eax, %edx + shll %cl, %eax + movl %edx, 20(%esp) + movl %eax, 16(%esp) + jmp ..B1.52 +..B1.53: + movl %eax, 16(%esp) + orl $1048576, 20(%esp) +..B1.54: + movl 60(%esp), %eax + xorl %edx, %edx + subl 64(%esp), %eax + xorl %ecx, %ecx + movl %eax, 60(%esp) + cmpl $-1, %eax + je ..B1.60 +..B1.56: + movl %edx, %edi + addl %ecx, %ecx + shrl $31, %edi + addl %edx, %edx + orl %edi, %ecx + movl %esi, %edi + subl 16(%esp), %edi + movl %ebx, %edi + sbbl 20(%esp), %edi + jb ..B1.58 +..B1.57: + subl 16(%esp), %esi + sbbl 20(%esp), %ebx + addl $1, %edx + adcl $0, %ecx +..B1.58: + movl %esi, %edi + addl %ebx, %ebx + shrl $31, %edi + decl %eax + addl %esi, %esi + orl %edi, %ebx + cmpl $-1, %eax + jne ..B1.56 +..B1.60: + movl %esi, %eax + orl %ebx, %eax + je ..B1.83 +..B1.61: + movl %ebx, %eax + shll $31, %eax + shrl $1, %esi + shrl $1, %ebx + orl %esi, %eax + testl %ebx, %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + je ..B1.63 +..B1.62: + bsr %ebx, %ecx + negl %ecx + addl $20, %ecx + jmp ..B1.64 +..B1.63: + bsr 8(%esp), %ecx + negl %ecx + addl $52, %ecx +..B1.64: + cmpl $31, %ecx + jbe ..B1.66 +..B1.65: + movl %eax, %ebx + xorl %eax, %eax + shll %cl, %ebx + jmp ..B1.67 +..B1.66: + shldl %cl, %eax, %ebx + shll %cl, %eax +..B1.67: + movl 64(%esp), %esi + subl %ecx, %esi + movl %esi, 64(%esp) + testl %esi, %esi + jle ..B1.69 +..B1.68: + movl %ebx, %esi + andl $1048575, %esi + jmp ..B1.73 +..B1.69: + movl %esi, %ecx + negl %ecx + incl %ecx + movl %ecx, 64(%esp) + cmpl $31, %ecx + jbe ..B1.71 +..B1.70: + movl %ebx, %eax + xorl %esi, %esi + shrl %cl, %eax + jmp ..B1.72 +..B1.71: + movl %ebx, %esi + shrdl %cl, %ebx, %eax + shrl %cl, %esi +..B1.72: + movl $0, 64(%esp) +..B1.73: + movl 64(%esp), %ecx + shll $20, %ecx + orl %ecx, %esi + movl %eax, 8(%esp) + movl %esi, 12(%esp) + fldl 8(%esp) + fld %st(0) + fadd %st(1), %st + fcom %st(2) + fnstsw %ax + sahf + jb ..B1.89 +..B1.74: + fucomp %st(2) + fnstsw %ax + sahf + jp ..B1.75 + je ..B1.81 +..B1.75: + incl %edx + fsubp %st, %st(1) + jmp ..B1.76 +..B1.89: + fstp %st(2) + fstp %st(1) +..B1.76: + andl $2147483647, %edx + movl 52(%esp), %eax + imull %edx, %eax + movl 56(%esp), %edx + cmpl $0, 48(%esp) + movl %eax, (%edx) + je ..B1.78 +..B1.77: + fchs +..B1.78: + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.81: + fstp %st(1) + movl %edx, %ecx + xorl %eax, %eax + andl $1, %ecx + orl %eax, %ecx + je ..B1.76 +..B1.82: + fchs + incl %edx + jmp ..B1.76 +..B1.83: + fstp %st(0) + fldz + andl $2147483647, %edx + fmull 8(%ebp) + movl 52(%esp), %eax + imull %edx, %eax + movl 56(%esp), %edx + movl %eax, (%edx) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type remquo,@function + .size remquo,.-remquo + .data +# -- End remquo + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xc1e00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/remquof.S b/external/sgx_libm/ia32/remquof.S new file mode 100644 index 0000000000..44803efcac --- /dev/null +++ b/external/sgx_libm/ia32/remquof.S @@ -0,0 +1,75 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remquof.c" + .text +..TXTST0: +# -- Begin remquof + .text + .align 16,0x90 + .globl remquof +remquof: +# parameter 1: 48 + %esp +# parameter 2: 52 + %esp +# parameter 3: 56 + %esp +..B1.1: +..L1: + + pushl %ebx + subl $40, %esp + flds 48(%esp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl 56(%esp), %eax + fstpl (%esp) + flds 52(%esp) + fstpl 8(%esp) + movl %eax, 16(%esp) + call remquo@PLT +..B1.2: + addl $40, %esp + popl %ebx + ret + .align 16,0x90 + .type remquof,@function + .size remquof,.-remquof + .data +# -- End remquof + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/remquol.S b/external/sgx_libm/ia32/remquol.S new file mode 100644 index 0000000000..1421eee78c --- /dev/null +++ b/external/sgx_libm/ia32/remquol.S @@ -0,0 +1,900 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remquol.c" + .text +..TXTST0: +# -- Begin remquol + .text + .align 16,0x90 + .globl remquol +remquol: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 32 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + movl 32(%ebp), %esi +..B1.2: + fnstcw 30(%esp) +..B1.3: + movzwl 28(%ebp), %eax + movl $0, (%esi) + andl $32767, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jne ..B1.6 +..B1.4: + cmpl $0, 24(%ebp) + jne ..B1.6 +..B1.5: + cmpl $0, 20(%ebp) + je ..B1.54 +..B1.6: + movzwl 16(%ebp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.51 +..B1.7: + cmpl $32767, %eax + je ..B1.26 +..B1.8: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + movl %eax, (%esp) + movzwl 30(%esp), %eax + movl %eax, %ecx + movzbl 29(%ebp), %edx + andl $3840, %ecx + andl $128, %edx + shrl $7, %edx + movl %edx, 4(%esp) + cmpl $768, %ecx + je ..B1.25 +..B1.9: + andl $-3841, %eax + orl $-64768, %eax + movw %ax, 28(%esp) +..B1.10: + fldcw 28(%esp) +..B1.11: + movl $1, %edi +..B1.12: + fldt 8(%ebp) + addl $-32, %esp + fstpt (%esp) + fldt 20(%ebp) + fstpt 12(%esp) + movl %esi, 24(%esp) + call __libm_remquol +..B1.69: + addl $32, %esp +..B1.13: + fstpt 16(%esp) + testl %edi, %edi + je ..B1.15 +..B1.14: + fldcw 30(%esp) +..B1.15: + movl (%esi), %edx + testl %edx, %edx + je ..B1.19 +..B1.16: + movl 4(%esp), %eax + imull iones@GOTOFF(%ebx,%eax,4), %edx + cmpl (%esp), %eax + je ..B1.18 +..B1.17: + orl $-2147483648, %edx + movl %edx, (%esi) + jmp ..B1.19 +..B1.18: + andl $2147483647, %edx + movl %edx, (%esi) +..B1.19: + movzwl 24(%esp), %eax + testl $32767, %eax + jne ..B1.24 +..B1.20: + cmpl $0, 20(%esp) + jne ..B1.23 +..B1.21: + cmpl $0, 16(%esp) + jne ..B1.23 +..B1.22: + movl (%esp), %eax + fldl _zeros@GOTOFF(%ebx,%eax,8) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.23: + fldl _small_value_64@GOTOFF(%ebx) + fmul %st(0), %st + fstpl 8(%esp) + fldt 16(%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.24: + fldt 16(%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + xorl %edi, %edi + jmp ..B1.12 +..B1.26: + cmpl $-2147483648, 24(%ebp) + jne ..B1.28 +..B1.27: + cmpl $0, 20(%ebp) + je ..B1.34 +..B1.28: + movzwl 30(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.40 +..B1.29: + orl $-64768, %edx + movw %dx, 28(%esp) +..B1.30: + fldcw 28(%esp) +..B1.31: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt 16(%esp) +..B1.32: + fldcw 30(%esp) +..B1.33: + fldt 16(%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.34: + cmpl $32767, %edx + je ..B1.41 +..B1.35: + testl %edx, %edx + jne ..B1.39 +..B1.36: + cmpl $0, 12(%ebp) + jne ..B1.38 +..B1.37: + cmpl $0, 8(%ebp) + je ..B1.39 +..B1.38: + fldl _smallest_value_64@GOTOFF(%ebx) + fstpl 8(%esp) +..B1.39: + fldt 8(%ebp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.40: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt 16(%esp) + jmp ..B1.33 +..B1.41: + cmpl $-2147483648, 12(%ebp) + jne ..B1.39 +..B1.42: + cmpl $0, 8(%ebp) + jne ..B1.39 +..B1.43: + movzwl 30(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.50 +..B1.44: + orl $-64768, %edx + movw %dx, 28(%esp) +..B1.45: + fldcw 28(%esp) +..B1.46: + movl $1, %eax +..B1.47: + fldl _infs@GOTOFF(%ebx) + testl %eax, %eax + fmull _zeros@GOTOFF(%ebx) + fstpl (%esp) + fldl (%esp) + fstpt 16(%esp) + je ..B1.49 +..B1.48: + fldcw 30(%esp) +..B1.49: + fldt 16(%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.50: + xorl %eax, %eax + jmp ..B1.47 +..B1.51: + cmpl $-2147483648, 12(%ebp) + jne ..B1.28 +..B1.52: + cmpl $0, 8(%ebp) + jne ..B1.28 +..B1.53: + cmpl $32767, %eax + je ..B1.26 + jmp ..B1.34 +..B1.54: + movzwl 30(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.66 +..B1.55: + orl $-64768, %edx + movw %dx, 28(%esp) +..B1.56: + fldcw 28(%esp) +..B1.57: + movl $1, %edx +..B1.58: + movzwl 16(%ebp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.63 +..B1.59: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpl (%esp) + fldl (%esp) + fstpt 16(%esp) +..B1.60: + testl %edx, %edx + je ..B1.62 +..B1.61: + fldcw 30(%esp) +..B1.62: + fldt 16(%esp) + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.63: + cmpl $-2147483648, 12(%ebp) + jne ..B1.65 +..B1.64: + cmpl $0, 8(%ebp) + je ..B1.59 +..B1.65: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx) + fstpt 16(%esp) + jmp ..B1.60 +..B1.66: + xorl %edx, %edx + jmp ..B1.58 + .align 16,0x90 + .type remquol,@function + .size remquol,.-remquol + .data +# -- End remquol + .text +# -- Begin __libm_remquol + .text + .align 16,0x90 +__libm_remquol: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 32 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + fldt 8(%ebp) + call ..L4 +..L4: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%esi), %esi + fstpt 156(%esp) + fldt 156(%esp) + andb $127, 29(%ebp) + fldt 20(%ebp) + movzwl 16(%ebp), %eax + andl $32767, %eax + movzwl 28(%ebp), %edi + andl $32767, %edi + fstpt 168(%esp) + fldt 168(%esp) + cmpl $32703, %eax + fldl _ones@GOTOFF(%esi) + movl 32(%ebp), %ebx + movl $0, 168(%esp) + jl ..B2.5 +..B2.2: + fstp %st(0) + cmpl $32703, %edi + jl ..B2.9 +..B2.3: + fldl 8+_scales@GOTOFF(%esi) + fmul %st, %st(2) + fxch %st(2) + fstpt (%esp) + fmulp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + fstpt 20(%ebp) + movl %ebx, 24(%esp) + call __libm_remquol +..B2.4: + fmull _scales@GOTOFF(%esi) + fstpt 156(%esp) + fldt 156(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.5: + cmpl $64, %edi + jge ..B2.12 +..B2.6: + fstp %st(0) + fldl _scales@GOTOFF(%esi) + fmul %st, %st(1) + fxch %st(1) + fstpt 20(%ebp) + fldt 20(%ebp) + fxch %st(1) + fstpt 32(%esp) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl %ebx, 24(%esp) + call __libm_remquol +..B2.7: + fldt 32(%esp) + fmulp %st, %st(1) + fstpt (%esp) + fldt 20(%ebp) + fstpt 12(%esp) + movl %ebx, 24(%esp) + call __libm_remquol +..B2.8: + fmull 8+_scales@GOTOFF(%esi) + fstpt 156(%esp) + fldt 156(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.9: + fldl 8+_scales@GOTOFF(%esi) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fstpt 12(%esp) + movl %ebx, 24(%esp) + call __libm_remquol +..B2.10: + fldl _scales@GOTOFF(%esi) + fmulp %st, %st(1) + fstpt (%esp) + fldt 20(%ebp) + fstpt 12(%esp) + movl %ebx, 24(%esp) + call __libm_remquol +..B2.11: + fstpt 156(%esp) + fldt 156(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.12: + lea 1(%eax), %edx + cmpl %edx, %edi + jg ..B2.34 +..B2.13: + lea -32(%eax), %edx + cmpl %edx, %edi + jle ..B2.22 +..B2.14: + fstp %st(0) + fldt 168(%esp) + fld %st(2) + fdiv %st(2), %st + fld %st(2) + fsub %st(2), %st + fldl _TWO_63H@GOTOFF(%esi) + fld %st(0) + fadd %st(3), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubp %st, %st(1) + fld %st(0) + movl 32(%esp), %edx + fsubr %st(3), %st + fabs + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + fsubrp %st, %st(6) + fxch %st(1) + fmul %st(3), %st + fsubrp %st, %st(5) + fldl _halfs@GOTOFF(%esi) + fucom %st(1) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jp ..B2.15 + je ..B2.16 +..B2.15: + fstp %st(2) + fstp %st(0) + fstp %st(0) + fstp %st(0) + movl %edx, (%ebx) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.16: + fmul %st(3), %st + fld %st(4) + fabs + fcompp + fnstsw %ax + sahf + jp ..B2.17 + jbe ..B2.21 +..B2.17: + fcompp + fnstsw %ax + sahf + ja ..B2.19 + jp ..B2.19 +..B2.18: + decl %edx + faddp %st, %st(1) + movl %edx, (%ebx) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.19: + incl %edx + fsubrp %st, %st(1) + movl %edx, (%ebx) +..B2.20: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.21: + fstp %st(1) + fstp %st(0) + fstp %st(0) + movl %edx, (%ebx) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.22: + fldt 168(%esp) + subl %edi, %eax + fstpt 56(%esp) + fldt 56(%esp) + fld %st(1) + fdiv %st(3), %st + fld %st(3) + fsubp %st, %st(2) + addl $-31, %eax + movl %eax, 80(%esp) + jle ..B2.35 +..B2.23: + fstpt 96(%esp) + fldt 96(%esp) + movzwl 104(%esp), %edx + fstpt 44(%esp) + fldt 44(%esp) + movl %edx, 144(%esp) + movl 48(%esp), %edx + movzwl 52(%esp), %ecx + fxch %st(2) + fstpt 108(%esp) + movl %edx, 136(%esp) + movzwl 176(%esp), %edx + fstpt 84(%esp) + fldt 84(%esp) + movl %ecx, 140(%esp) + movzwl 116(%esp), %ecx + movl %edx, 128(%esp) + movzwl 92(%esp), %edx + fstpt 32(%esp) + fldt 32(%esp) + fldl _TWO_63H@GOTOFF(%esi) + movl %ecx, 132(%esp) + movl 172(%esp), %ecx + movl %edx, 68(%esp) + movl 36(%esp), %edx + movl %ecx, 124(%esp) + movzwl 40(%esp), %ecx + andl $32767, %ecx + movl %ecx, 148(%esp) + movl %esi, 76(%esp) + movl %edx, 120(%esp) + xorl %edx, %edx + movl %edi, 152(%esp) + movl %ebx, 72(%esp) + movl 68(%esp), %esi + movl %eax, %ecx +..B2.24: + movl 140(%esp), %ebx + andl $-32768, %esi + subl %eax, %ebx + subl %eax, %ecx + movl 144(%esp), %edi + andl $32767, %ebx + andl $-32768, %edi + orl %ebx, %edi + movl 136(%esp), %ebx + movw %di, 104(%esp) + movl %ebx, 100(%esp) + fldt 96(%esp) + movl 128(%esp), %ebx + fmul %st(5), %st + movl %edi, 144(%esp) + addl %eax, %ebx + movl 132(%esp), %edi + andl $32767, %ebx + andl $-32768, %edi + fadd %st(1), %st + orl %ebx, %edi + movl %edi, 132(%esp) + xorl %ebx, %ebx + movw %di, 116(%esp) + movl 124(%esp), %edi + movl %edi, 112(%esp) + movl 148(%esp), %edi + testl %edi, %edi + fstpt 32(%esp) + fldt 32(%esp) + fsub %st(1), %st + fldt 108(%esp) + setne %bl + imull %eax, %ebx + fmul %st(1), %st + addl %edi, %ebx + fsubrp %st, %st(6) + andl $32767, %ebx + orl %ebx, %esi + movl 120(%esp), %ebx + movw %si, 92(%esp) + movl %ebx, 88(%esp) + fldt 84(%esp) + fmulp %st, %st(1) + shll %cl, %edx + cmpl $32, %ecx + movl %eax, %ecx + fsubrp %st, %st(5) + jb ..L5 + movl $0, %edx +..L5: + fxch %st(4) + fstpt 156(%esp) + fldt 156(%esp) + movzwl 164(%esp), %edi + andl $32767, %edi + subl 152(%esp), %edi + movl %edi, %eax + addl 32(%esp), %edx + addl $-31, %eax + fxch %st(4) + jg ..B2.24 +..B2.25: + movl %ecx, 80(%esp) + movl 72(%esp), %ebx + movl 76(%esp), %esi +..B2.26: + fldt 56(%esp) + fld %st(1) + fxch %st(4) + fmul %st(6), %st + movl 80(%esp), %ecx + fadd %st, %st(4) + fxch %st(4) + fstpt 32(%esp) + fldt 32(%esp) + fld %st(3) + shll %cl, %edx + cmpl $32, %ecx + fxch %st(1) + fsub %st(3), %st + jb ..L6 + movl $0, %edx +..L6: + fmul %st, %st(2) + addl 32(%esp), %edx + fxch %st(2) + fsubrp %st, %st(7) + fmul %st(1), %st + fsubrp %st, %st(6) + fld %st(5) + fabs + fldl _halfs@GOTOFF(%esi) + fmul %st(6), %st + fcom %st(1) + fnstsw %ax + sahf + ja ..B2.33 +..B2.27: + fcompp + fnstsw %ax + sahf + jae ..B2.32 + jp ..B2.32 +..B2.28: + fstp %st(1) + fstp %st(1) + movl %edx, (%ebx) + fcompp + fnstsw %ax + sahf + ja ..B2.30 + jp ..B2.30 +..B2.29: + fsubrp %st, %st(1) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.30: + faddp %st, %st(1) +..B2.31: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.32: + fstp %st(0) + fstp %st(2) + fldt 56(%esp) + fxch %st(3) + fdivr %st(4), %st + fadd %st(2), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubp %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + addl 32(%esp), %edx + fxch %st(2) + fsubrp %st, %st(3) + fmulp %st, %st(1) + movl %edx, (%ebx) + fsubrp %st, %st(1) + fstpt 156(%esp) + fldt 156(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.33: + fstp %st(2) + fstp %st(2) + fstp %st(2) + fstp %st(2) + fstp %st(2) + fstp %st(0) + fstp %st(0) + movl %edx, (%ebx) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.34: + fstp %st(0) + fstp %st(0) + movl $0, (%ebx) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.35: + fstp %st(2) + fldl _TWO_63H@GOTOFF(%esi) + xorl %edx, %edx + jmp ..B2.26 + .align 16,0x90 + .type __libm_remquol,@function + .size __libm_remquol,.-__libm_remquol + .data +# -- End __libm_remquol + .section .rodata, "a" + .align 4 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_scales: + .long 0 + .long 1341128704 + .long 0 + .long 804257792 + .type _scales,@object + .size _scales,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_halfs: + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .type _halfs,@object + .size _halfs,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/rint_gen.S b/external/sgx_libm/ia32/rint_gen.S new file mode 100644 index 0000000000..2106963d3e --- /dev/null +++ b/external/sgx_libm/ia32/rint_gen.S @@ -0,0 +1,61 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rint_gen.c" + .text +..TXTST0: +# -- Begin rint + .text + .align 16,0x90 + .globl rint +rint: +# parameter 1: 4 + %esp +..B1.1: +..L1: + +..B1.2: + fldl 4(%esp) + frndint + ret +..B1.3: + .align 16,0x90 + .type rint,@function + .size rint,.-rint + .data +# -- End rint + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/rintf_gen.S b/external/sgx_libm/ia32/rintf_gen.S new file mode 100644 index 0000000000..831ed856b1 --- /dev/null +++ b/external/sgx_libm/ia32/rintf_gen.S @@ -0,0 +1,61 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rintf_gen.c" + .text +..TXTST0: +# -- Begin rintf + .text + .align 16,0x90 + .globl rintf +rintf: +# parameter 1: 4 + %esp +..B1.1: +..L1: + +..B1.2: + flds 4(%esp) + frndint + ret +..B1.3: + .align 16,0x90 + .type rintf,@function + .size rintf,.-rintf + .data +# -- End rintf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/rintl.S b/external/sgx_libm/ia32/rintl.S new file mode 100644 index 0000000000..2849fd3483 --- /dev/null +++ b/external/sgx_libm/ia32/rintl.S @@ -0,0 +1,160 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rintl.c" + .text +..TXTST0: +# -- Begin rintl + .text + .align 16,0x90 + .globl rintl +rintl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzbl 17(%ebp), %edx + movzwl 16(%ebp), %ecx + andl $128, %edx + andl $32767, %ecx + shrl $7, %edx + movzwl 14(%esp), %eax + cmpl $16446, %ecx + jge ..B1.13 +..B1.4: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.20 +..B1.5: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.6: + fldcw 12(%esp) +..B1.7: + movl $1, %eax +..B1.8: + fldt 8(%ebp) + testl %eax, %eax + call ..L2 +..L2: + popl %ecx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ecx), %ecx + fldl _TWO_63@GOTOFF(%ecx,%edx,8) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 8(%ebp) + je ..B1.10 +..B1.9: + fldcw 14(%esp) +..B1.10: + fldt 8(%ebp) + fldl _zeros@GOTOFF(%ecx) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B1.12 + je ..B1.19 +..B1.12: + movl %ebp, %esp + popl %ebp + ret +..B1.13: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.21 +..B1.14: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.15: + fldcw 12(%esp) +..B1.16: + fldt 8(%ebp) + fstpt (%esp) +..B1.17: + fldcw 14(%esp) +..B1.18: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.19: + fstp %st(0) + fldl _zeros@GOTOFF(%ecx,%edx,8) + movl %ebp, %esp + popl %ebp + ret +..B1.20: + xorl %eax, %eax + jmp ..B1.8 +..B1.21: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.18 + .align 16,0x90 + .type rintl,@function + .size rintl,.-rintl + .data +# -- End rintl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63: + .long 0 + .long 1138753536 + .long 0 + .long 3286237184 + .type _TWO_63,@object + .size _TWO_63,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/round_wmt.S b/external/sgx_libm/ia32/round_wmt.S new file mode 100644 index 0000000000..756ba57df5 --- /dev/null +++ b/external/sgx_libm/ia32/round_wmt.S @@ -0,0 +1,147 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "round_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin round + .text + .align 16,0x90 + .globl round +round: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + pextrw $3, %xmm0, %ecx + movl $32752, %eax + andl %ecx, %eax + cmpl $16352, %eax + jl .L_2TAG_PACKET_0.0.2 + cmpl $17200, %eax + jge .L_2TAG_PACKET_1.0.2 + movq 16(%ebx), %xmm1 + andpd %xmm0, %xmm1 + orpd (%ebx), %xmm1 + addsd %xmm1, %xmm0 + movq 24(%ebx), %xmm1 + movq 32(%ebx), %xmm2 + andpd %xmm0, %xmm1 + psubd %xmm1, %xmm2 + psrlq $52, %xmm2 + psrlq %xmm2, %xmm0 + psllq %xmm2, %xmm0 + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_0.0.2: + addsd %xmm0, %xmm0 + testl $32768, %ecx + jne .L_2TAG_PACKET_3.0.2 + fldz + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_3.0.2: + fldl 40(%ebx) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_1.0.2: + cmpl $32752, %eax + je .L_2TAG_PACKET_5.0.2 + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_5.0.2: + fldl 112(%esp) + fldz + faddp + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_2.0.2: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_4.0.2: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type round,@function + .size round,.-round + .data +# -- End round + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 0 + .long 2147483648 + .long 0 + .long 2146435072 + .long 0 + .long 1127219200 + .long 0 + .long 2147483648 + .type static_const_table,@object + .size static_const_table,48 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/roundf_wmt.S b/external/sgx_libm/ia32/roundf_wmt.S new file mode 100644 index 0000000000..99c7f46f0c --- /dev/null +++ b/external/sgx_libm/ia32/roundf_wmt.S @@ -0,0 +1,133 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "roundf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin roundf + .text + .align 16,0x90 + .globl roundf +roundf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %eax + testl %eax, %eax + jl .L_2TAG_PACKET_0.0.2 + cmpl $1056964608, %eax + jl .L_2TAG_PACKET_1.0.2 + cmpl $1258291200, %eax + jge .L_2TAG_PACKET_2.0.2 + cmpl $1065353216, %eax + je .L_2TAG_PACKET_2.0.2 + addss (%ebx), %xmm0 + cvttss2si %xmm0, %eax + movl %eax, 24(%esp) + fildl 24(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_1.0.2: + fldz + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_4.0.2: + flds 4(%ebx) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_0.0.2: + andl $2147483647, %eax + cmpl $1056964608, %eax + jl .L_2TAG_PACKET_4.0.2 + cmpl $1258291200, %eax + jge .L_2TAG_PACKET_2.0.2 + cmpl $1065353216, %eax + je .L_2TAG_PACKET_2.0.2 + subss (%ebx), %xmm0 + cvttss2si %xmm0, %eax + movl %eax, 24(%esp) + fildl 24(%esp) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_3.0.2: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type roundf,@function + .size roundf,.-roundf + .data +# -- End roundf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1056964608 + .long 2147483648 + .type static_const_table,@object + .size static_const_table,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/roundl.S b/external/sgx_libm/ia32/roundl.S new file mode 100644 index 0000000000..ae7e25123d --- /dev/null +++ b/external/sgx_libm/ia32/roundl.S @@ -0,0 +1,248 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "roundl.c" + .text +..TXTST0: +# -- Begin roundl + .text + .align 16,0x90 + .globl roundl +roundl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + subl $24, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + cmpl $16446, %eax + jge ..B1.25 +..B1.4: + cmpl $16383, %eax + jl ..B1.19 +..B1.5: + cmpl $16414, %eax + jge ..B1.7 +..B1.6: + movl 12(%ebp), %edi + lea 2(%eax), %ecx + negl %eax + movl %edi, %edx + addl $30, %eax + shll %cl, %edx + movl %eax, %ecx + shrl %cl, %edi + shll %cl, %edi + movl %edi, 12(%ebp) + movl $0, 8(%ebp) + jmp ..B1.10 +..B1.7: + jle ..B1.9 +..B1.8: + movl 8(%ebp), %edi + lea 2(%eax), %ecx + negl %eax + movl %edi, %edx + addl $30, %eax + shll %cl, %edx + movl %eax, %ecx + shrl %cl, %edi + shll %cl, %edi + movl %edi, 8(%ebp) + jmp ..B1.10 +..B1.9: + movl 8(%ebp), %edx + movl $0, 8(%ebp) +..B1.10: + testl %edx, %edx + jge ..B1.18 +..B1.11: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.31 +..B1.12: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.13: + fldcw 12(%esp) +..B1.14: + movl $1, %edx +..B1.15: + fldt 8(%ebp) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + testl %edx, %edx + faddl _ones@GOTOFF(%esi,%eax,8) + fstpt (%esp) + je ..B1.17 +..B1.16: + fldcw 14(%esp) +..B1.17: + fldt (%esp) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + fldt 8(%ebp) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + cmpl $16382, %eax + je ..B1.33 +..B1.20: + testl %eax, %eax + jne ..B1.24 +..B1.21: + cmpl $0, 12(%ebp) + jne ..B1.23 +..B1.22: + cmpl $0, 8(%ebp) + je ..B1.24 +..B1.23: + fldl _smallest_value_64@GOTOFF(%esi) + fstpl 16(%esp) +..B1.24: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl _zeros@GOTOFF(%esi,%eax,8) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.32 +..B1.26: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.27: + fldcw 12(%esp) +..B1.28: + fldt 8(%ebp) + fmull _ones@GOTOFF(%esi) + fstpt (%esp) +..B1.29: + fldcw 14(%esp) +..B1.30: + fldt (%esp) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.31: + xorl %edx, %edx + jmp ..B1.15 +..B1.32: + fldt 8(%ebp) + fmull _ones@GOTOFF(%esi) + fstpt (%esp) + jmp ..B1.30 +..B1.33: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl _ones@GOTOFF(%esi,%eax,8) + addl $24, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type roundl,@function + .size roundl,.-roundl + .data +# -- End roundl + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalb_wmt.S b/external/sgx_libm/ia32/scalb_wmt.S new file mode 100644 index 0000000000..b4ee579932 --- /dev/null +++ b/external/sgx_libm/ia32/scalb_wmt.S @@ -0,0 +1,328 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalb_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin scalb + .text + .align 16,0x90 + .globl scalb +scalb: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movsd 136(%esp), %xmm1 + movq %xmm0, (%esp) + movq %xmm1, 8(%esp) + pextrw $3, %xmm0, %eax + pextrw $3, %xmm1, %edx + andl $32752, %eax + andl $32752, %edx + subl $16, %eax + subl $16368, %edx + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.3 + cmpl $256, %edx + jae .L_2TAG_PACKET_0.0.3 + movq 144(%ebx), %xmm7 +.L_2TAG_PACKET_1.0.3: + movdqa %xmm1, %xmm2 + addsd %xmm7, %xmm2 + movd %xmm2, %ecx + shll $4, %ecx + addl %ecx, %eax + movdqa %xmm2, %xmm3 + subsd %xmm7, %xmm3 + comisd %xmm1, %xmm3 + jne .L_2TAG_PACKET_2.0.3 + cmpl $32736, %eax + jae .L_2TAG_PACKET_3.0.3 + psllq $52, %xmm2 + paddq %xmm2, %xmm0 +.L_2TAG_PACKET_4.0.3: + movq %xmm0, 16(%esp) + fldl 16(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_6.0.3: + fldl (%esp) + faddl 8(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_2.0.3: + fldl 48(%ebx) + fmull (%ebx) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_7.0.3: + pextrw $3, %xmm1, %ecx + comisd %xmm7, %xmm0 + je .L_2TAG_PACKET_8.0.3 + cmpl $32736, %eax + je .L_2TAG_PACKET_9.0.3 + pextrw $3, %xmm0, %eax + shrl $12, %eax + andl $8, %eax + testl $32768, %ecx + je .L_2TAG_PACKET_10.0.3 + fldl 48(%ebx,%eax) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_9.0.3: + xorl $32768, %ecx +.L_2TAG_PACKET_8.0.3: + testl $32768, %ecx + je .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_11.0.3: + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_12.0.3: + movq 80(%ebx), %xmm7 + movq 96(%ebx), %xmm6 + pandn %xmm1, %xmm7 + comisd %xmm6, %xmm7 + jc .L_2TAG_PACKET_2.0.3 + pextrw $3, %xmm0, %eax + shrl $12, %eax + andl $8, %eax +.L_2TAG_PACKET_10.0.3: + fldl (%ebx,%eax) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_0.0.3: + movl %edx, %ecx + pxor %xmm7, %xmm7 + shrl $4, %ecx + ucomisd %xmm1, %xmm0 + jp .L_2TAG_PACKET_6.0.3 + addl $12, %ecx + cmpl $16384, %edx + je .L_2TAG_PACKET_7.0.3 + movdqa %xmm1, %xmm2 + comisd %xmm7, %xmm1 + je .L_2TAG_PACKET_11.0.3 + movd %ecx, %xmm3 + cmpl $32736, %eax + je .L_2TAG_PACKET_12.0.3 + psllq %xmm3, %xmm2 + testl %edx, %edx + jl .L_2TAG_PACKET_2.0.3 + pcmpeqd %xmm7, %xmm2 + cmpl $832, %edx + jae .L_2TAG_PACKET_13.0.3 + pmovmskb %xmm2, %ecx + cmpl $65535, %ecx + jne .L_2TAG_PACKET_2.0.3 + comisd %xmm7, %xmm0 + je .L_2TAG_PACKET_11.0.3 + cmpl $256, %edx + jae .L_2TAG_PACKET_14.0.3 + mulsd 112(%ebx), %xmm0 + movq 160(%ebx), %xmm7 + pextrw $3, %xmm0, %eax + andl $32752, %eax + subl $16, %eax + jmp .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_3.0.3: + jge .L_2TAG_PACKET_15.0.3 + sarl $4, %eax + cmpl $-53, %eax + jl .L_2TAG_PACKET_16.0.3 + movd 176(%ebx), %xmm3 + movq 128(%ebx), %xmm4 + pxor %xmm7, %xmm7 + pshufd $236, %xmm2, %xmm2 + paddd %xmm3, %xmm2 + psllq $52, %xmm2 + paddq %xmm2, %xmm0 + mulsd %xmm4, %xmm0 + comisd %xmm7, %xmm0 + jne .L_2TAG_PACKET_4.0.3 + movl $53, %ecx + jmp .L_2TAG_PACKET_17.0.3 +.L_2TAG_PACKET_13.0.3: + comisd %xmm7, %xmm0 + je .L_2TAG_PACKET_11.0.3 +.L_2TAG_PACKET_14.0.3: + pextrw $3, %xmm1, %edx + testl $32768, %edx + jne .L_2TAG_PACKET_16.0.3 +.L_2TAG_PACKET_15.0.3: + lea 16(%ebx), %edx + movl $53, %ecx + pxor %xmm1, %xmm1 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_16.0.3: + lea 32(%ebx), %edx + movl $54, %ecx + movq 64(%ebx), %xmm1 + jmp .L_2TAG_PACKET_18.0.3 +.L_2TAG_PACKET_18.0.3: + pxor %xmm7, %xmm7 + pextrw $3, %xmm0, %eax + shrl $12, %eax + andl $8, %eax + addl %edx, %eax + movq (%edx), %xmm0 + mulsd (%eax), %xmm0 + pand %xmm0, %xmm1 + comisd %xmm7, %xmm1 + jne .L_2TAG_PACKET_4.0.3 +.L_2TAG_PACKET_17.0.3: + movq %xmm0, 16(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 136(%esp), %eax + movl %eax, 4(%esp) + lea 48(%esp), %eax + movl %eax, 8(%esp) + movl %ecx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl 16(%esp) +.L_2TAG_PACKET_5.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type scalb,@function + .size scalb,.-scalb + .data +# -- End scalb + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 1 + .long 1048576 + .long 1 + .long 1048576 + .long 0 + .long 1130364928 + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .long 0 + .long 1015021568 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 4294967241 + .long 1127743487 + .long 4294967241 + .long 1127743487 + .long 55 + .long 55 + .long 55 + .long 55 + .type static_const_table,@object + .size static_const_table,192 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalbf.S b/external/sgx_libm/ia32/scalbf.S new file mode 100644 index 0000000000..d6d68d7ec3 --- /dev/null +++ b/external/sgx_libm/ia32/scalbf.S @@ -0,0 +1,410 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbf.c" + .text +..TXTST0: +# -- Begin scalbf + .text + .align 16,0x90 + .globl scalbf +scalbf: +# parameter 1: 32 + %esp +# parameter 2: 36 + %esp +..B1.1: +..L1: + + pushl %esi + pushl %edi + pushl %ebx + pushl %ebp + subl $12, %esp + movzwl 34(%esp), %ebx + movl %ebx, %edx + andl $32640, %edx + movzwl 38(%esp), %edi + andl $32640, %edi + shrl $7, %edx + shrl $7, %edi + call ..L2 +..L2: + popl %ebp + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebp), %ebp + cmpl $255, %edx + je ..B1.48 +..B1.2: + cmpl $255, %edi + je ..B1.31 +..B1.3: + cmpl $127, %edi + jl ..B1.16 +..B1.4: + cmpl $150, %edi + jge ..B1.7 +..B1.5: + movl 36(%esp), %esi + movl %edi, %ecx + andl $8388607, %esi + negl %ecx + movl %esi, %eax + addl $22, %ecx + orl $8388608, %eax + addl $10, %edi + shrl %cl, %eax + movl %edi, %ecx + shll %cl, %esi + testl %esi, %esi + je ..B1.8 +..B1.6: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%ebp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.7: + movl $65536, %eax +..B1.8: + testl %edx, %edx + jne ..B1.11 +..B1.9: + testl $8388607, 32(%esp) + je ..B1.15 +..B1.10: + flds 32(%esp) + fmuls .L_2il0floatpacket.1@GOTOFF(%ebp) + fstps 32(%esp) + movzwl 34(%esp), %ebx + movl %ebx, %edx + andl $32640, %edx + shrl $7, %edx + addl $-25, %edx +..B1.11: + cmpl $65536, %eax + movzbl 39(%esp), %esi + jle ..L3 + movl $65536, %eax +..L3: + movl %eax, %ecx + negl %ecx + testl $128, %esi + jne ..L4 + movl %eax, %ecx +..L4: + lea (%edx,%ecx), %eax + testl %eax, %eax + jle ..B1.26 +..B1.12: + cmpl $255, %eax + jge ..B1.25 +..B1.13: + movzbl %al, %eax + andl $-32641, %ebx + shll $7, %eax + orl %eax, %ebx + movw %bx, 34(%esp) + flds 32(%esp) +..B1.14: + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.15: + flds 32(%esp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.16: + testl %edi, %edi + jne ..B1.19 +..B1.17: + testl $8388607, 36(%esp) + jne ..B1.19 +..B1.18: + flds 32(%esp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.19: + cmpl $255, %edx + jne ..B1.24 +..B1.20: + testl %edi, %edi + jg ..B1.22 +..B1.21: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%ebp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.22: + cmpl $1, %edi + je ..B1.30 +..B1.23: + movzbl 35(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _infs@GOTOFF(%ebp,%eax,4) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.24: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%ebp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.25: + movzbl 35(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _large_value_32@GOTOFF(%ebp,%eax,4) + fmuls .L_2il0floatpacket.2@GOTOFF(%ebp) + fsts (%esp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.26: + cmpl $-23, %eax + jge ..B1.28 +..B1.27: + movzbl 35(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _small_value_32@GOTOFF(%ebp,%eax,4) + fmuls .L_2il0floatpacket.3@GOTOFF(%ebp) + jmp ..B1.29 +..B1.28: + movl 32(%esp), %eax + lea 25(%edx,%ecx), %edx + movl %eax, (%esp) + shrl $16, %eax + movzbl %dl, %edx + andl $-32641, %eax + shll $7, %edx + orl %edx, %eax + movw %ax, 2(%esp) + flds (%esp) + fmuls .L_2il0floatpacket.4@GOTOFF(%ebp) +..B1.29: + fsts (%esp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.30: + testl $8388607, 36(%esp) + jle ..B1.21 + jmp ..B1.23 +..B1.31: + testl $8388607, 36(%esp) + jne ..B1.43 +..B1.32: + testl %edx, %edx + jne ..B1.38 +..B1.33: + testl $8388607, 32(%esp) + jne ..B1.39 +..B1.34: + movzbl 39(%esp), %eax + testl $128, %eax + je ..B1.36 +..B1.35: + flds 32(%esp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.36: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%ebp) +..B1.37: + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.38: + cmpl $255, %edx + je ..B1.44 +..B1.39: + movzbl 35(%esp), %edx + andl $128, %edx + movzbl 39(%esp), %eax + shrl $7, %edx + testl $128, %eax + je ..B1.41 +..B1.40: + flds _zeros@GOTOFF(%ebp,%edx,4) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.41: + flds _infs@GOTOFF(%ebp,%edx,4) +..B1.42: + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.43: + flds 32(%esp) + fadds 36(%esp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.44: + movzbl 39(%esp), %eax + testl $128, %eax + jne ..B1.46 +..B1.45: + flds 32(%esp) + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.46: + fldz + fmuls .L_2il0floatpacket.0@GOTOFF(%ebp) +..B1.47: + addl $12, %esp + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +..B1.48: + testl $8388607, 32(%esp) + jne ..B1.43 +..B1.49: + cmpl $255, %edi + je ..B1.31 + jmp ..B1.16 + .align 16,0x90 + .type scalbf,@function + .size scalbf,.-scalbf + .data +# -- End scalbf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x7f800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x71800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x0d800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +.L_2il0floatpacket.4: + .long 0x33000000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .align 4 +_infs: + .long 2139095040 + .long 4286578688 + .type _infs,@object + .size _infs,8 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalbl.S b/external/sgx_libm/ia32/scalbl.S new file mode 100644 index 0000000000..5779076e12 --- /dev/null +++ b/external/sgx_libm/ia32/scalbl.S @@ -0,0 +1,641 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbl.c" + .text +..TXTST0: +# -- Begin scalbl + .text + .align 16,0x90 + .globl scalbl +scalbl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp +..B1.2: + fnstcw 22(%esp) +..B1.3: + movzwl 16(%ebp), %edi + andl $32767, %edi + movzwl 28(%ebp), %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %esi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi + cmpl $32767, %edi + je ..B1.107 +..B1.4: + cmpl $32767, %ecx + je ..B1.74 +..B1.5: + cmpl $16383, %ecx + jl ..B1.33 +..B1.6: + movzwl 22(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.57 +..B1.7: + orl $-64768, %edx + movw %dx, 20(%esp) +..B1.8: + fldcw 20(%esp) +..B1.9: + movl $1, %ebx +..B1.10: + cmpl $16414, %ecx + jge ..B1.15 +..B1.11: + fldt 20(%ebp) + fldl _TWO_63H@GOTOFF(%esi) + fadd %st(1), %st + fstpt 8(%esp) + fildl 8(%esp) + movl 8(%esp), %edx + fucompp + fnstsw %ax + sahf + jp ..B1.12 + je ..B1.20 +..B1.12: + fldl _infs@GOTOFF(%esi) + testl %ebx, %ebx + fmull _zeros@GOTOFF(%esi) + fstpt 8(%esp) + je ..B1.14 +..B1.13: + fldcw 22(%esp) +..B1.14: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + movzbl 29(%ebp), %eax + andl $128, %eax + shrl $7, %eax + cmpl $16446, %ecx + movl large_integers@GOTOFF(%esi,%eax,4), %edx + jge ..B1.20 +..B1.16: + addl $2, %ecx + movl 20(%ebp), %eax + shll %cl, %eax + testl %eax, %eax + je ..B1.20 +..B1.17: + fldl _infs@GOTOFF(%esi) + testl %ebx, %ebx + fmull _zeros@GOTOFF(%esi) + fstpt 8(%esp) + je ..B1.19 +..B1.18: + fldcw 22(%esp) +..B1.19: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.20: + testl %edi, %edi + jne ..B1.27 +..B1.21: + cmpl $0, 12(%ebp) + jne ..B1.26 +..B1.22: + cmpl $0, 8(%ebp) + jne ..B1.26 +..B1.23: + testl %ebx, %ebx + je ..B1.25 +..B1.24: + fldcw 22(%esp) +..B1.25: + fldt 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%esi) + fstpt 8(%ebp) + movzwl 16(%ebp), %edi + andl $32767, %edi + addl $-75, %edi +..B1.27: + cmpl $65536, %edx + jle ..L3 + movl $65536, %edx +..L3: + cmpl $-65536, %edx + jge ..L4 + movl $-65536, %edx +..L4: + lea (%edi,%edx), %ecx + testl %ecx, %ecx + jle ..B1.51 +..B1.28: + cmpl $32767, %ecx + jge ..B1.50 +..B1.29: + movzwl 16(%ebp), %eax + andl $32767, %ecx + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 16(%ebp) + fldt 8(%ebp) +..B1.30: + fstpt 8(%esp) + testl %ebx, %ebx + je ..B1.32 +..B1.31: + fldcw 22(%esp) +..B1.32: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.33: + testl %ecx, %ecx + jne ..B1.42 +..B1.34: + cmpl $0, 24(%ebp) + jne ..B1.42 +..B1.35: + cmpl $0, 20(%ebp) + jne ..B1.42 +..B1.36: + movzwl 22(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.58 +..B1.37: + orl $-64768, %edx + movw %dx, 20(%esp) +..B1.38: + fldcw 20(%esp) +..B1.39: + fldt 8(%ebp) + fmull _ones@GOTOFF(%esi) + fstpt 8(%esp) +..B1.40: + fldcw 22(%esp) +..B1.41: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.42: + cmpl $32767, %edi + je ..B1.60 +..B1.43: + movzwl 22(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.59 +..B1.44: + orl $-64768, %edx + movw %dx, 20(%esp) +..B1.45: + fldcw 20(%esp) +..B1.46: + movl $1, %eax +..B1.47: + fldl _infs@GOTOFF(%esi) + testl %eax, %eax + fmull _zeros@GOTOFF(%esi) + fstpt 8(%esp) + je ..B1.49 +..B1.48: + fldcw 22(%esp) +..B1.49: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.50: + fldt _large_value_80@GOTOFF(%esi) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%esi,%ecx) + fmulp %st, %st(1) + jmp ..B1.30 +..B1.51: + cmpl $-63, %ecx + jge ..B1.53 +..B1.52: + fldt _small_value_80@GOTOFF(%esi) + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%esi,%ecx) + fmulp %st, %st(1) + jmp ..B1.54 +..B1.53: + fldt 8(%ebp) + lea 75(%edi,%edx), %edx + movzwl 16(%ebp), %eax + andl $32767, %edx + andl $-32768, %eax + fstpt 8(%esp) + orl %edx, %eax + movw %ax, 16(%esp) + fldt 8(%esp) + fmull 8+_TWO_75@GOTOFF(%esi) +..B1.54: + fstpt 8(%esp) + testl %ebx, %ebx + je ..B1.56 +..B1.55: + fldcw 22(%esp) +..B1.56: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.57: + xorl %ebx, %ebx + jmp ..B1.10 +..B1.58: + fldt 8(%ebp) + fmull _ones@GOTOFF(%esi) + fstpt 8(%esp) + jmp ..B1.41 +..B1.59: + xorl %eax, %eax + jmp ..B1.47 +..B1.60: + testl %ecx, %ecx + jg ..B1.68 +..B1.61: + movzwl 22(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.70 +..B1.62: + orl $-64768, %edx + movw %dx, 20(%esp) +..B1.63: + fldcw 20(%esp) +..B1.64: + movl $1, %eax +..B1.65: + fldl _infs@GOTOFF(%esi) + testl %eax, %eax + fmull _zeros@GOTOFF(%esi) + fstpt 8(%esp) + je ..B1.67 +..B1.66: + fldcw 22(%esp) +..B1.67: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.68: + cmpl $1, %ecx + je ..B1.71 +..B1.69: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl _infs@GOTOFF(%esi,%eax,8) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.70: + xorl %eax, %eax + jmp ..B1.65 +..B1.71: + movl 24(%ebp), %eax + cmpl $-2147483648, %eax + jb ..B1.61 +..B1.72: + jne ..B1.69 +..B1.73: + cmpl $0, 20(%ebp) + jbe ..B1.61 + jmp ..B1.69 +..B1.74: + cmpl $-2147483648, 24(%ebp) + jne ..B1.76 +..B1.75: + cmpl $0, 20(%ebp) + je ..B1.82 +..B1.76: + movzwl 22(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.102 +..B1.77: + orl $-64768, %edx + movw %dx, 20(%esp) +..B1.78: + fldcw 20(%esp) +..B1.79: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt 8(%esp) +..B1.80: + fldcw 22(%esp) +..B1.81: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.82: + movzwl 22(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.106 +..B1.83: + orl $-64768, %edx + movw %dx, 20(%esp) +..B1.84: + fldcw 20(%esp) +..B1.85: + movl $1, %eax +..B1.86: + testl %edi, %edi + jne ..B1.94 +..B1.87: + cmpl $0, 12(%ebp) + jne ..B1.89 +..B1.88: + cmpl $0, 8(%ebp) + je ..B1.90 +..B1.112: + cmpl $0, 12(%ebp) +..B1.89: + fldl _smallest_value_64@GOTOFF(%esi) + fstpl (%esp) + jne ..B1.95 +..B1.113: + cmpl $0, 8(%ebp) +..B1.90: + jne ..B1.95 +..B1.91: + movzbl 29(%ebp), %edx + testl $128, %edx + je ..B1.93 +..B1.92: + fldt 8(%ebp) + fstpt 8(%esp) + jmp ..B1.99 +..B1.93: + fldl _infs@GOTOFF(%esi) + fmull _zeros@GOTOFF(%esi) + fstpt 8(%esp) + jmp ..B1.99 +..B1.94: + cmpl $32767, %edi + je ..B1.103 +..B1.95: + movzbl 17(%ebp), %ecx + andl $128, %ecx + movzbl 29(%ebp), %edx + shrl $7, %ecx + testl $128, %edx + je ..B1.97 +..B1.96: + fldl _zeros@GOTOFF(%esi,%ecx,8) + jmp ..B1.98 +..B1.97: + fldl _infs@GOTOFF(%esi,%ecx,8) +..B1.98: + fstpt 8(%esp) +..B1.99: + testl %eax, %eax + je ..B1.101 +..B1.100: + fldcw 22(%esp) +..B1.101: + fldt 8(%esp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.102: + fldt 8(%ebp) + fldt 20(%ebp) + faddp %st, %st(1) + fstpt 8(%esp) + jmp ..B1.81 +..B1.103: + movzbl 29(%ebp), %edx + testl $128, %edx + jne ..B1.105 +..B1.104: + fldt 8(%ebp) + fstpt 8(%esp) + jmp ..B1.99 +..B1.105: + fldl _infs@GOTOFF(%esi) + fmull _zeros@GOTOFF(%esi) + fstpt 8(%esp) + jmp ..B1.99 +..B1.106: + xorl %eax, %eax + jmp ..B1.86 +..B1.107: + cmpl $-2147483648, 12(%ebp) + jne ..B1.76 +..B1.108: + cmpl $0, 8(%ebp) + jne ..B1.76 +..B1.109: + cmpl $32767, %ecx + je ..B1.74 + jmp ..B1.33 + .align 16,0x90 + .type scalbl,@function + .size scalbl,.-scalbl + .data +# -- End scalbl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +large_integers: + .long 65536 + .long -65536 + .type large_integers,@object + .size large_integers,8 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalbln_wmt.S b/external/sgx_libm/ia32/scalbln_wmt.S new file mode 100644 index 0000000000..3b57a2cbd9 --- /dev/null +++ b/external/sgx_libm/ia32/scalbln_wmt.S @@ -0,0 +1,243 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbln_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin scalbln + .text + .align 16,0x90 + .globl scalbln +scalbln: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movq %xmm0, (%esp) + movq 64(%ebx), %xmm4 + movl 136(%esp), %ecx + movl %ecx, 8(%esp) + movl $65536, %eax + movl $-65536, %edx + cmpl %eax, %ecx + cmovg %eax, %ecx + cmpl %edx, %ecx + cmovl %edx, %ecx + andpd %xmm0, %xmm4 + xorpd %xmm4, %xmm0 + ucomisd 128(%ebx), %xmm0 + jp .L_2TAG_PACKET_0.0.3 + je .L_2TAG_PACKET_0.0.3 + comisd 80(%ebx), %xmm0 + jc .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + movapd %xmm0, %xmm2 + movapd (%ebx), %xmm3 + psrlq $52, %xmm2 + movd %ecx, %xmm1 + andpd %xmm3, %xmm2 + paddq %xmm1, %xmm2 + movd %xmm2, %eax + movapd 16(%ebx), %xmm3 + testl %eax, %eax + jle .L_2TAG_PACKET_3.0.3 + cmpl $2047, %eax + jge .L_2TAG_PACKET_4.0.3 + andpd %xmm3, %xmm0 + psllq $52, %xmm2 + xorpd %xmm4, %xmm0 + orpd %xmm2, %xmm0 + movq %xmm0, 16(%esp) + fldl 16(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_0.0.3: + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_1.0.3: + comisd 144(%ebx), %xmm0 + je .L_2TAG_PACKET_0.0.3 + mulsd 96(%ebx), %xmm0 + subl $55, %ecx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $-52, %eax + jl .L_2TAG_PACKET_6.0.3 + xorpd %xmm5, %xmm5 + andpd %xmm3, %xmm0 + shufpd $1, %xmm3, %xmm3 + paddq %xmm3, %xmm2 + xorpd %xmm4, %xmm0 + psllq $52, %xmm2 + orpd %xmm2, %xmm0 + mulsd 112(%ebx), %xmm0 + comisd %xmm5, %xmm0 + je .L_2TAG_PACKET_6.0.3 + movq %xmm0, 16(%esp) + fldl 16(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_4.0.3: + lea 32(%ebx), %edx + movl $203, %ecx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_6.0.3: + lea 48(%ebx), %edx + movl $204, %ecx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_7.0.3: + pextrw $3, %xmm4, %eax + shrl $12, %eax + addl %edx, %eax + movq (%edx), %xmm0 + mulsd (%eax), %xmm0 + movq %xmm0, 16(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 136(%esp), %eax + movl %eax, 4(%esp) + lea 48(%esp), %eax + movl %eax, 8(%esp) + movl %ecx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl 16(%esp) +.L_2TAG_PACKET_5.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type scalbln,@function + .size scalbln,.-scalbln + .data +# -- End scalbln + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 2047 + .long 0 + .long 4294967241 + .long 4294967295 + .long 4294967295 + .long 2148532223 + .long 55 + .long 0 + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 1048576 + .long 0 + .long 1048576 + .long 0 + .long 1130364928 + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .long 0 + .long 1015021568 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,160 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalblnf.S b/external/sgx_libm/ia32/scalblnf.S new file mode 100644 index 0000000000..f26c38a751 --- /dev/null +++ b/external/sgx_libm/ia32/scalblnf.S @@ -0,0 +1,202 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalblnf.c" + .text +..TXTST0: +# -- Begin scalblnf + .text + .align 16,0x90 + .globl scalblnf +scalblnf: +# parameter 1: 16 + %esp +# parameter 2: 20 + %esp +..B1.1: +..L1: + + pushl %ebx + pushl %ebp + pushl %esi + movzwl 18(%esp), %eax + movl %eax, %ecx + andl $32640, %ecx + shrl $7, %ecx + movl 20(%esp), %edx + cmpl $255, %ecx + je ..B1.15 +..B1.2: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + testl %ecx, %ecx + jne ..B1.5 +..B1.3: + testl $8388607, 16(%esp) + je ..B1.9 +..B1.4: + flds 16(%esp) + fmuls .L_2il0floatpacket.0@GOTOFF(%ebx) + fstps 16(%esp) + movzwl 18(%esp), %eax + movl %eax, %ecx + andl $32640, %ecx + shrl $7, %ecx + addl $-25, %ecx +..B1.5: + cmpl $65536, %edx + jle ..L3 + movl $65536, %edx +..L3: + cmpl $-65536, %edx + jg ..L4 + movl $-65536, %edx +..L4: + lea (%ecx,%edx), %ebp + testl %ebp, %ebp + jle ..B1.11 +..B1.6: + cmpl $255, %ebp + jge ..B1.10 +..B1.7: + andl $255, %ebp + andl $-32641, %eax + shll $7, %ebp + orl %ebp, %eax + movw %ax, 18(%esp) + flds 16(%esp) +..B1.8: + popl %ecx + popl %ebp + popl %ebx + ret +..B1.9: + flds 16(%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.10: + movzbl 19(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _large_value_32@GOTOFF(%ebx,%eax,4) + fmuls .L_2il0floatpacket.1@GOTOFF(%ebx) + fsts (%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.11: + cmpl $-23, %ebp + jl ..B1.14 +..B1.12: + movl 16(%esp), %eax + lea 25(%ecx,%edx), %edx + movl %eax, (%esp) + shrl $16, %eax + movzbl %dl, %edx + andl $-32641, %eax + shll $7, %edx + orl %edx, %eax + movw %ax, 2(%esp) + flds (%esp) + fmuls .L_2il0floatpacket.3@GOTOFF(%ebx) + fsts (%esp) +..B1.13: + popl %ecx + popl %ebp + popl %ebx + ret +..B1.14: + movzbl 19(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _small_value_32@GOTOFF(%ebx,%eax,4) + fmuls .L_2il0floatpacket.2@GOTOFF(%ebx) + fsts (%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.15: + flds 16(%esp) + popl %ecx + popl %ebp + popl %ebx + ret + .align 16,0x90 + .type scalblnf,@function + .size scalblnf,.-scalblnf + .data +# -- End scalblnf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x0d800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x33000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalblnl.S b/external/sgx_libm/ia32/scalblnl.S new file mode 100644 index 0000000000..41ae09f3a3 --- /dev/null +++ b/external/sgx_libm/ia32/scalblnl.S @@ -0,0 +1,337 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalblnl.c" + .text +..TXTST0: +# -- Begin scalblnl + .text + .align 16,0x90 + .globl scalblnl +scalblnl: +# parameter 1: 32 + %esp +# parameter 2: 44 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + pushl %ebp + subl $16, %esp + movl 44(%esp), %ebx +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 40(%esp), %eax + movl %eax, %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %ebp + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebp), %ebp + cmpl $32767, %ecx + je ..B1.43 +..B1.4: + testl %ecx, %ecx + jne ..B1.14 +..B1.5: + cmpl $0, 36(%esp) + jne ..B1.8 +..B1.6: + cmpl $0, 32(%esp) + jne ..B1.8 +..B1.7: + fldt 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.8: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.42 +..B1.9: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.10: + fldcw 12(%esp) +..B1.11: + fldt 32(%esp) + fmull _TWO_75@GOTOFF(%ebp) + fstpt 32(%esp) +..B1.12: + fldcw 14(%esp) +..B1.13: + movzwl 40(%esp), %eax + movl %eax, %ecx + andl $32767, %ecx + addl $-75, %ecx +..B1.14: + cmpl $65536, %ebx + jle ..L3 + movl $65536, %ebx +..L3: + cmpl $-65536, %ebx + jg ..L4 + movl $-65536, %ebx +..L4: + lea (%ecx,%ebx), %edi + testl %edi, %edi + jle ..B1.25 +..B1.15: + cmpl $32767, %edi + jge ..B1.17 +..B1.16: + andl $-32768, %eax + andl $32767, %edi + orl %edi, %eax + movw %ax, 40(%esp) + fldt 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.17: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.24 +..B1.18: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.19: + fldcw 12(%esp) +..B1.20: + movl $1, %ebx +..B1.21: + fldt _large_value_80@GOTOFF(%ebp) + movzbl 41(%esp), %edx + andl $128, %edx + shrl $7, %edx + testl %ebx, %ebx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%ebp,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.23 +..B1.22: + fldcw 14(%esp) +..B1.23: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.24: + xorl %ebx, %ebx + jmp ..B1.21 +..B1.25: + movzwl 14(%esp), %edx + cmpl $-63, %edi + jl ..B1.34 +..B1.26: + movl %edx, %edi + andl $768, %edi + cmpl $768, %edi + je ..B1.33 +..B1.27: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.28: + fldcw 12(%esp) +..B1.29: + movzwl 40(%esp), %eax + movl $1, %edi +..B1.30: + fldt 32(%esp) + lea 75(%ecx,%ebx), %edx + andl $-32768, %eax + andl $32767, %edx + fstpt (%esp) + orl %edx, %eax + movw %ax, 8(%esp) + testl %edi, %edi + fldt (%esp) + fmull 8+_TWO_75@GOTOFF(%ebp) + fstpt (%esp) + je ..B1.32 +..B1.31: + fldcw 14(%esp) +..B1.32: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.33: + xorl %edi, %edi + jmp ..B1.30 +..B1.34: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.41 +..B1.35: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.36: + fldcw 12(%esp) +..B1.37: + movl $1, %ebx +..B1.38: + fldt _small_value_80@GOTOFF(%ebp) + movzbl 41(%esp), %edx + andl $128, %edx + shrl $7, %edx + testl %ebx, %ebx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%ebp,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.40 +..B1.39: + fldcw 14(%esp) +..B1.40: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.41: + xorl %ebx, %ebx + jmp ..B1.38 +..B1.42: + fldt 32(%esp) + fmull _TWO_75@GOTOFF(%ebp) + fstpt 32(%esp) + jmp ..B1.13 +..B1.43: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.49 +..B1.44: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.45: + fldcw 12(%esp) +..B1.46: + fldt 32(%esp) + fmull _ones@GOTOFF(%ebp) + fstpt (%esp) +..B1.47: + fldcw 14(%esp) +..B1.48: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.49: + fldt 32(%esp) + fmull _ones@GOTOFF(%ebp) + fstpt (%esp) + jmp ..B1.48 + .align 16,0x90 + .type scalblnl,@function + .size scalblnl,.-scalblnl + .data +# -- End scalblnl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalbn_wmt.S b/external/sgx_libm/ia32/scalbn_wmt.S new file mode 100644 index 0000000000..4e5635c2f4 --- /dev/null +++ b/external/sgx_libm/ia32/scalbn_wmt.S @@ -0,0 +1,243 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbn_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin scalbn + .text + .align 16,0x90 + .globl scalbn +scalbn: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movq %xmm0, (%esp) + movq 64(%ebx), %xmm4 + movl 136(%esp), %ecx + movl %ecx, 8(%esp) + movl $65536, %eax + movl $-65536, %edx + cmpl %eax, %ecx + cmovg %eax, %ecx + cmpl %edx, %ecx + cmovl %edx, %ecx + andpd %xmm0, %xmm4 + xorpd %xmm4, %xmm0 + ucomisd 128(%ebx), %xmm0 + jp .L_2TAG_PACKET_0.0.3 + je .L_2TAG_PACKET_0.0.3 + comisd 80(%ebx), %xmm0 + jc .L_2TAG_PACKET_1.0.3 +.L_2TAG_PACKET_2.0.3: + movapd %xmm0, %xmm2 + movapd (%ebx), %xmm3 + psrlq $52, %xmm2 + movd %ecx, %xmm1 + andpd %xmm3, %xmm2 + paddq %xmm1, %xmm2 + movd %xmm2, %eax + movapd 16(%ebx), %xmm3 + testl %eax, %eax + jle .L_2TAG_PACKET_3.0.3 + cmpl $2047, %eax + jge .L_2TAG_PACKET_4.0.3 + andpd %xmm3, %xmm0 + psllq $52, %xmm2 + xorpd %xmm4, %xmm0 + orpd %xmm2, %xmm0 + movq %xmm0, 16(%esp) + fldl 16(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_0.0.3: + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_1.0.3: + comisd 144(%ebx), %xmm0 + je .L_2TAG_PACKET_0.0.3 + mulsd 96(%ebx), %xmm0 + subl $55, %ecx + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $-52, %eax + jl .L_2TAG_PACKET_6.0.3 + xorpd %xmm5, %xmm5 + andpd %xmm3, %xmm0 + shufpd $1, %xmm3, %xmm3 + paddq %xmm3, %xmm2 + xorpd %xmm4, %xmm0 + psllq $52, %xmm2 + orpd %xmm2, %xmm0 + mulsd 112(%ebx), %xmm0 + comisd %xmm5, %xmm0 + je .L_2TAG_PACKET_6.0.3 + movq %xmm0, 16(%esp) + fldl 16(%esp) + jmp .L_2TAG_PACKET_5.0.3 +.L_2TAG_PACKET_4.0.3: + lea 32(%ebx), %edx + movl $176, %ecx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_6.0.3: + lea 48(%ebx), %edx + movl $177, %ecx + jmp .L_2TAG_PACKET_7.0.3 +.L_2TAG_PACKET_7.0.3: + pextrw $3, %xmm4, %eax + shrl $12, %eax + addl %edx, %eax + movq (%edx), %xmm0 + mulsd (%eax), %xmm0 + movq %xmm0, 16(%esp) + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 136(%esp), %eax + movl %eax, 4(%esp) + lea 48(%esp), %eax + movl %eax, 8(%esp) + movl %ecx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl 16(%esp) +.L_2TAG_PACKET_5.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type scalbn,@function + .size scalbn,.-scalbn + .data +# -- End scalbn + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 2047 + .long 0 + .long 4294967241 + .long 4294967295 + .long 4294967295 + .long 2148532223 + .long 55 + .long 0 + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 1048576 + .long 0 + .long 1048576 + .long 0 + .long 1130364928 + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .long 0 + .long 1015021568 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,160 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalbnf.S b/external/sgx_libm/ia32/scalbnf.S new file mode 100644 index 0000000000..2ff48cc797 --- /dev/null +++ b/external/sgx_libm/ia32/scalbnf.S @@ -0,0 +1,202 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbnf.c" + .text +..TXTST0: +# -- Begin scalbnf + .text + .align 16,0x90 + .globl scalbnf +scalbnf: +# parameter 1: 16 + %esp +# parameter 2: 20 + %esp +..B1.1: +..L1: + + pushl %ebx + pushl %ebp + pushl %esi + movzwl 18(%esp), %eax + movl %eax, %ecx + andl $32640, %ecx + shrl $7, %ecx + movl 20(%esp), %edx + cmpl $255, %ecx + je ..B1.15 +..B1.2: + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + testl %ecx, %ecx + jne ..B1.5 +..B1.3: + testl $8388607, 16(%esp) + je ..B1.9 +..B1.4: + flds 16(%esp) + fmuls .L_2il0floatpacket.0@GOTOFF(%ebx) + fstps 16(%esp) + movzwl 18(%esp), %eax + movl %eax, %ecx + andl $32640, %ecx + shrl $7, %ecx + addl $-25, %ecx +..B1.5: + cmpl $65536, %edx + jle ..L3 + movl $65536, %edx +..L3: + cmpl $-65536, %edx + jg ..L4 + movl $-65536, %edx +..L4: + lea (%ecx,%edx), %ebp + testl %ebp, %ebp + jle ..B1.11 +..B1.6: + cmpl $255, %ebp + jge ..B1.10 +..B1.7: + andl $255, %ebp + andl $-32641, %eax + shll $7, %ebp + orl %ebp, %eax + movw %ax, 18(%esp) + flds 16(%esp) +..B1.8: + popl %ecx + popl %ebp + popl %ebx + ret +..B1.9: + flds 16(%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.10: + movzbl 19(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _large_value_32@GOTOFF(%ebx,%eax,4) + fmuls .L_2il0floatpacket.1@GOTOFF(%ebx) + fsts (%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.11: + cmpl $-23, %ebp + jl ..B1.14 +..B1.12: + movl 16(%esp), %eax + lea 25(%ecx,%edx), %edx + movl %eax, (%esp) + shrl $16, %eax + movzbl %dl, %edx + andl $-32641, %eax + shll $7, %edx + orl %edx, %eax + movw %ax, 2(%esp) + flds (%esp) + fmuls .L_2il0floatpacket.3@GOTOFF(%ebx) + fsts (%esp) +..B1.13: + popl %ecx + popl %ebp + popl %ebx + ret +..B1.14: + movzbl 19(%esp), %eax + andl $128, %eax + shrl $7, %eax + flds _small_value_32@GOTOFF(%ebx,%eax,4) + fmuls .L_2il0floatpacket.2@GOTOFF(%ebx) + fsts (%esp) + popl %ecx + popl %ebp + popl %ebx + ret +..B1.15: + flds 16(%esp) + popl %ecx + popl %ebp + popl %ebx + ret + .align 16,0x90 + .type scalbnf,@function + .size scalbnf,.-scalbnf + .data +# -- End scalbnf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x0d800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x33000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/scalbnl.S b/external/sgx_libm/ia32/scalbnl.S new file mode 100644 index 0000000000..2c7b59580b --- /dev/null +++ b/external/sgx_libm/ia32/scalbnl.S @@ -0,0 +1,337 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbnl.c" + .text +..TXTST0: +# -- Begin scalbnl + .text + .align 16,0x90 + .globl scalbnl +scalbnl: +# parameter 1: 32 + %esp +# parameter 2: 44 + %esp +..B1.1: +..L1: + + pushl %edi + pushl %ebx + pushl %ebp + subl $16, %esp + movl 44(%esp), %ebx +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 40(%esp), %eax + movl %eax, %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %ebp + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebp), %ebp + cmpl $32767, %ecx + je ..B1.43 +..B1.4: + testl %ecx, %ecx + jne ..B1.14 +..B1.5: + cmpl $0, 36(%esp) + jne ..B1.8 +..B1.6: + cmpl $0, 32(%esp) + jne ..B1.8 +..B1.7: + fldt 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.8: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.42 +..B1.9: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.10: + fldcw 12(%esp) +..B1.11: + fldt 32(%esp) + fmull _TWO_75@GOTOFF(%ebp) + fstpt 32(%esp) +..B1.12: + fldcw 14(%esp) +..B1.13: + movzwl 40(%esp), %eax + movl %eax, %ecx + andl $32767, %ecx + addl $-75, %ecx +..B1.14: + cmpl $65536, %ebx + jle ..L3 + movl $65536, %ebx +..L3: + cmpl $-65536, %ebx + jg ..L4 + movl $-65536, %ebx +..L4: + lea (%ecx,%ebx), %edi + testl %edi, %edi + jle ..B1.25 +..B1.15: + cmpl $32767, %edi + jge ..B1.17 +..B1.16: + andl $-32768, %eax + andl $32767, %edi + orl %edi, %eax + movw %ax, 40(%esp) + fldt 32(%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.17: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.24 +..B1.18: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.19: + fldcw 12(%esp) +..B1.20: + movl $1, %ebx +..B1.21: + fldt _large_value_80@GOTOFF(%ebp) + movzbl 41(%esp), %edx + andl $128, %edx + shrl $7, %edx + testl %ebx, %ebx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _large_value_80@GOTOFF(%ebp,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.23 +..B1.22: + fldcw 14(%esp) +..B1.23: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.24: + xorl %ebx, %ebx + jmp ..B1.21 +..B1.25: + movzwl 14(%esp), %edx + cmpl $-63, %edi + jl ..B1.34 +..B1.26: + movl %edx, %edi + andl $768, %edi + cmpl $768, %edi + je ..B1.33 +..B1.27: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.28: + fldcw 12(%esp) +..B1.29: + movzwl 40(%esp), %eax + movl $1, %edi +..B1.30: + fldt 32(%esp) + lea 75(%ecx,%ebx), %edx + andl $-32768, %eax + andl $32767, %edx + fstpt (%esp) + orl %edx, %eax + movw %ax, 8(%esp) + testl %edi, %edi + fldt (%esp) + fmull 8+_TWO_75@GOTOFF(%ebp) + fstpt (%esp) + je ..B1.32 +..B1.31: + fldcw 14(%esp) +..B1.32: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.33: + xorl %edi, %edi + jmp ..B1.30 +..B1.34: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.41 +..B1.35: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.36: + fldcw 12(%esp) +..B1.37: + movl $1, %ebx +..B1.38: + fldt _small_value_80@GOTOFF(%ebp) + movzbl 41(%esp), %edx + andl $128, %edx + shrl $7, %edx + testl %ebx, %ebx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%ebp,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.40 +..B1.39: + fldcw 14(%esp) +..B1.40: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.41: + xorl %ebx, %ebx + jmp ..B1.38 +..B1.42: + fldt 32(%esp) + fmull _TWO_75@GOTOFF(%ebp) + fstpt 32(%esp) + jmp ..B1.13 +..B1.43: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.49 +..B1.44: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.45: + fldcw 12(%esp) +..B1.46: + fldt 32(%esp) + fmull _ones@GOTOFF(%ebp) + fstpt (%esp) +..B1.47: + fldcw 14(%esp) +..B1.48: + fldt (%esp) + addl $16, %esp + popl %ebp + popl %ebx + popl %edi + ret +..B1.49: + fldt 32(%esp) + fmull _ones@GOTOFF(%ebp) + fstpt (%esp) + jmp ..B1.48 + .align 16,0x90 + .type scalbnl,@function + .size scalbnl,.-scalbnl + .data +# -- End scalbnl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/signbit.S b/external/sgx_libm/ia32/signbit.S new file mode 100644 index 0000000000..4e446703ff --- /dev/null +++ b/external/sgx_libm/ia32/signbit.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "signbit.c" + .text +..TXTST0: +# -- Begin __signbitd + .text + .align 16,0x90 + .globl __signbitd +__signbitd: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movl 8(%esp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .type __signbitd,@function + .size __signbitd,.-__signbitd + .data +# -- End __signbitd + .text +# -- Begin signbitd + .text + .align 16,0x90 + .globl signbitd +signbitd: +# parameter 1: 4 + %esp +..B2.1: +..L2: + + movl 8(%esp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .type signbitd,@function + .size signbitd,.-signbitd + .data +# -- End signbitd + .text +# -- Begin __signbit + .text + .align 16,0x90 + .globl __signbit +__signbit: +# parameter 1: 4 + %esp +..B3.1: +..L3: + + movl 8(%esp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .type __signbit,@function + .size __signbit,.-__signbit + .data +# -- End __signbit + .text +# -- Begin signbit + .text + .align 16,0x90 + .globl signbit +signbit: +# parameter 1: 4 + %esp +..B4.1: +..L4: + + movl 8(%esp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .type signbit,@function + .size signbit,.-signbit + .data +# -- End signbit + .text +# -- Begin __signbitf + .text + .align 16,0x90 + .globl __signbitf +__signbitf: +# parameter 1: 4 + %esp +..B5.1: +..L5: + + movl 4(%esp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .type __signbitf,@function + .size __signbitf,.-__signbitf + .data +# -- End __signbitf + .text +# -- Begin signbitf + .text + .align 16,0x90 + .globl signbitf +signbitf: +# parameter 1: 4 + %esp +..B6.1: +..L6: + + movl 4(%esp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .type signbitf,@function + .size signbitf,.-signbitf + .data +# -- End signbitf + .text +# -- Begin __signbitl + .text + .align 16,0x90 + .globl __signbitl +__signbitl: +# parameter 1: 4 + %esp +..B7.1: +..L7: + + movzbl 13(%esp), %eax + shrl $7, %eax + movzwl 12(%esp), %edx + shll $15, %eax + andl $32767, %edx + orl %edx, %eax + shll $16, %eax + movzwl 10(%esp), %ecx + orl %ecx, %eax + shrl $31, %eax + ret + .align 16,0x90 + .type __signbitl,@function + .size __signbitl,.-__signbitl + .data +# -- End __signbitl + .text +# -- Begin signbitl + .text + .align 16,0x90 + .globl signbitl +signbitl: +# parameter 1: 4 + %esp +..B8.1: +..L8: + + movzbl 13(%esp), %eax + shrl $7, %eax + movzwl 12(%esp), %edx + shll $15, %eax + andl $32767, %edx + orl %edx, %eax + shll $16, %eax + movzwl 10(%esp), %ecx + orl %ecx, %eax + shrl $31, %eax + ret + .align 16,0x90 + .type signbitl,@function + .size signbitl,.-signbitl + .data +# -- End signbitl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/significand_wmt.S b/external/sgx_libm/ia32/significand_wmt.S new file mode 100644 index 0000000000..483a3e8850 --- /dev/null +++ b/external/sgx_libm/ia32/significand_wmt.S @@ -0,0 +1,136 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "significand_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin significand + .text + .align 16,0x90 + .globl significand +significand: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + pextrw $3, %xmm0, %eax + movq (%ebx), %xmm1 + andl $32767, %eax + movq 16(%ebx), %xmm2 + subl $16, %eax + js .L_2TAG_PACKET_0.0.2 + cmpl $32736, %eax + jae .L_2TAG_PACKET_1.0.2 + pand %xmm1, %xmm0 + por %xmm2, %xmm0 + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_0.0.2: + pxor %xmm3, %xmm3 + movq 32(%ebx), %xmm4 + comisd %xmm3, %xmm0 + je .L_2TAG_PACKET_3.0.2 + mulsd %xmm4, %xmm0 + pand %xmm1, %xmm0 + por %xmm2, %xmm0 +.L_2TAG_PACKET_3.0.2: + movq %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + fld1 + movsd %xmm0, (%esp) + fmull (%esp) +.L_2TAG_PACKET_2.0.2: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type significand,@function + .size significand,.-significand + .data +# -- End significand + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 4294967295 + .long 2148532223 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 1130364928 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,48 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/significandf.S b/external/sgx_libm/ia32/significandf.S new file mode 100644 index 0000000000..a91b5d2329 --- /dev/null +++ b/external/sgx_libm/ia32/significandf.S @@ -0,0 +1,97 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "significandf.c" + .text +..TXTST0: +# -- Begin significandf + .text + .align 16,0x90 + .globl significandf +significandf: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movl 4(%esp), %ecx + movl %ecx, %edx + andl $2147483647, %edx + lea -8388608(%edx), %eax + cmpl $2130706432, %eax + jb ..B1.6 +..B1.2: + decl %edx + cmpl $2139095039, %edx + jae ..B1.4 +..B1.3: + flds 4(%esp) + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + fmuls .L_2il0floatpacket.0@GOTOFF(%eax) + fstps 4(%esp) + movl 4(%esp), %edx + andl $-2139095041, %edx + orl $1065353216, %edx + movl %edx, 4(%esp) + flds 4(%esp) + ret +..B1.4: + flds 4(%esp) +..B1.5: + ret +..B1.6: + andl $-2139095041, %ecx + orl $1065353216, %ecx + movl %ecx, 4(%esp) + flds 4(%esp) + ret + .align 16,0x90 + .type significandf,@function + .size significandf,.-significandf + .data +# -- End significandf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/significandl.S b/external/sgx_libm/ia32/significandl.S new file mode 100644 index 0000000000..b14ab825d5 --- /dev/null +++ b/external/sgx_libm/ia32/significandl.S @@ -0,0 +1,160 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "significandl.c" + .text +..TXTST0: +# -- Begin significandl + .text + .align 16,0x90 + .globl significandl +significandl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %edx + movl %edx, %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.16 +..B1.4: + testl %eax, %eax + jne ..B1.14 +..B1.5: + cmpl $0, 12(%ebp) + jne ..B1.8 +..B1.6: + cmpl $0, 8(%ebp) + jne ..B1.8 +..B1.7: + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.8: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + je ..B1.15 +..B1.9: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.10: + fldcw 12(%esp) +..B1.11: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%eax) + fstpt 8(%ebp) +..B1.12: + fldcw 14(%esp) +..B1.13: + movzwl 16(%ebp), %eax + andl $-32768, %eax + orl $-49153, %eax + movw %ax, 16(%ebp) + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.14: + andl $-32768, %edx + orl $-49153, %edx + movw %dx, 16(%ebp) + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.15: + fldt 8(%ebp) + fmull _TWO_75@GOTOFF(%eax) + fstpt 8(%ebp) + jmp ..B1.13 +..B1.16: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.22 +..B1.17: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.18: + fldcw 12(%esp) +..B1.19: + fldt 8(%ebp) + fstpt (%esp) +..B1.20: + fldcw 14(%esp) +..B1.21: + fldt (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.22: + fldt 8(%ebp) + fstpt (%esp) + jmp ..B1.21 + .align 16,0x90 + .type significandl,@function + .size significandl,.-significandl + .data +# -- End significandl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sin_wmt.S b/external/sgx_libm/ia32/sin_wmt.S new file mode 100644 index 0000000000..5b38a2f2de --- /dev/null +++ b/external/sgx_libm/ia32/sin_wmt.S @@ -0,0 +1,779 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sin_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin sin + .text + .align 16,0x90 + .globl sin +sin: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 56(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + pextrw $3, %xmm0, %eax + andl $32767, %eax + subl $12336, %eax + cmpl $4293, %eax + ja .L_2TAG_PACKET_0.0.2 + movsd 2160(%ebx), %xmm1 + mulsd %xmm0, %xmm1 + movsd 2272(%ebx), %xmm5 + movapd 2256(%ebx), %xmm4 + andpd %xmm0, %xmm4 + orps %xmm4, %xmm5 + movsd 2128(%ebx), %xmm3 + movapd 2112(%ebx), %xmm2 + addpd %xmm5, %xmm1 + cvttsd2si %xmm1, %edx + cvtsi2sdl %edx, %xmm1 + mulsd %xmm1, %xmm3 + unpcklpd %xmm1, %xmm1 + addl $1865216, %edx + movapd %xmm0, %xmm4 + andl $63, %edx + movapd 2096(%ebx), %xmm5 + lea (%ebx), %eax + shll $5, %edx + addl %edx, %eax + mulpd %xmm1, %xmm2 + subsd %xmm3, %xmm0 + mulsd 2144(%ebx), %xmm1 + subsd %xmm3, %xmm4 + movsd 8(%eax), %xmm7 + unpcklpd %xmm0, %xmm0 + movapd %xmm4, %xmm3 + subsd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + movapd 2064(%ebx), %xmm6 + mulsd %xmm4, %xmm7 + subsd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subsd %xmm2, %xmm3 + movapd (%eax), %xmm2 + subsd %xmm3, %xmm1 + movsd 24(%eax), %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm7 + mulsd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulsd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm0 + addpd 2080(%ebx), %xmm5 + mulsd (%eax), %xmm4 + addpd 2048(%ebx), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, %xmm0 + addsd 8(%eax), %xmm3 + mulpd %xmm7, %xmm1 + movapd %xmm4, %xmm7 + addsd %xmm3, %xmm4 + addpd %xmm5, %xmm6 + movsd 8(%eax), %xmm5 + subsd %xmm3, %xmm5 + subsd %xmm4, %xmm3 + addsd 16(%eax), %xmm1 + mulpd %xmm2, %xmm6 + addsd %xmm0, %xmm5 + addsd %xmm7, %xmm3 + addsd %xmm5, %xmm1 + addsd %xmm3, %xmm1 + addsd %xmm6, %xmm1 + unpckhpd %xmm6, %xmm6 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm4 + movsd %xmm4, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_0.0.2: + jg .L_2TAG_PACKET_2.0.2 + shrl $4, %eax + cmpl $268434685, %eax + jne .L_2TAG_PACKET_3.0.2 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_3.0.2: + movsd 2192(%ebx), %xmm3 + mulsd %xmm0, %xmm3 + subsd %xmm0, %xmm3 + mulsd 2208(%ebx), %xmm3 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + movl 132(%esp), %eax + andl $2146435072, %eax + cmpl $2146435072, %eax + je .L_2TAG_PACKET_4.0.2 + subl $32, %esp + movsd %xmm0, (%esp) + lea 40(%esp), %eax + movl %eax, 8(%esp) + movl $2, %eax + movl %eax, 12(%esp) + call __libm_sincos_huge + addl $32, %esp + fldl 16(%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_4.0.2: + fldl 128(%esp) + fmull 2240(%ebx) +.L_2TAG_PACKET_1.0.2: + movl 56(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type sin,@function + .size sin,.-sin + .data +# -- End sin + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 1072693248 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1071644672 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 1071644672 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1070596096 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 1070596096 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1069547520 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 3217031168 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 3218079744 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 3218079744 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 3219128320 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 3220176896 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3219128320 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 3219128320 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3218079744 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 3218079744 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 1069547520 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 1070596096 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 1070596096 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 1071644672 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 1072693248 + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .long 1413480448 + .long 1069097467 + .long 0 + .long 0 + .long 771977331 + .long 996350346 + .long 0 + .long 0 + .long 1841940611 + .long 1076125488 + .long 0 + .long 0 + .long 0 + .long 1127743488 + .long 0 + .long 0 + .long 0 + .long 1130364928 + .long 0 + .long 0 + .long 0 + .long 1015021568 + .long 0 + .long 0 + .long 4294967295 + .long 1072693247 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .type static_const_table,@object + .size static_const_table,2288 + .data + .hidden __libm_sincos_huge + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sincos_pi4l.S b/external/sgx_libm/ia32/sincos_pi4l.S new file mode 100644 index 0000000000..f3074c36da --- /dev/null +++ b/external/sgx_libm/ia32/sincos_pi4l.S @@ -0,0 +1,3894 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincos_pi4l.c" + .text +..TXTST0: +# -- Begin __libm_sincos_pi4l + .text + .align 16,0x90 + .hidden __libm_sincos_pi4l + .globl __libm_sincos_pi4l +__libm_sincos_pi4l: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 24 + %ebp +# parameter 4: 28 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $52, %esp + fldt 8(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %gs:20, %edx + xorl %esp, %edx + fldt _pzerol_value@GOTOFF(%ebx) + movl %edx, 36(%esp) + fcom %st(1) + fnstsw %ax + movl 28(%ebp), %ecx + sahf + jbe ..B1.3 +..B1.2: + negl %ecx + movl $-1, %esi + fxch %st(1) + fchs + fxch %st(1) + jmp ..B1.4 +..B1.3: + movl $1, %esi +..B1.4: + fldt _pion4@GOTOFF(%ebx) + fcom %st(2) + fnstsw %ax + sahf + jbe ..B1.8 +..B1.5: + fstp %st(1) + testb $1, %cl + je ..B1.7 +..B1.6: + fsubrp %st, %st(1) + jmp ..B1.27 +..B1.7: + fstp %st(0) + jmp ..B1.27 +..B1.8: + fldt _cody_thres_val@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + fldz + sahf + jbe ..B1.10 +..B1.9: + fstp %st(2) + fstp %st(0) + fstp %st(0) + fldt __4onpi@GOTOFF(%ebx) + fmul %st(1), %st + fnstcw (%esp) + movzwl (%esp), %eax + orl $3072, %eax + movl %eax, 8(%esp) + fldcw 8(%esp) + fistpl 16(%esp) + fldcw (%esp) + fldt _PI04@GOTOFF(%ebx) + fldt 12+_PI04@GOTOFF(%ebx) + fldt 24+_PI04@GOTOFF(%ebx) + movl 16(%esp), %eax + addl %eax, %ecx + testb $1, %cl + lea 1(%eax), %edx + jne ..L3 + movl %eax, %edx +..L3: + movl %edx, 24(%esp) + fildl 24(%esp) + fmul %st, %st(3) + fxch %st(3) + fsubrp %st, %st(4) + fxch %st(1) + fmul %st(2), %st + fsubrp %st, %st(3) + fmulp %st, %st(1) + fsubrp %st, %st(1) + jmp ..B1.27 +..B1.10: + fxch %st(3) + fstpt 16(%esp) + movzwl 24(%esp), %eax + movl %ecx, 12(%esp) + movl %eax, %ecx + andl $32767, %ecx + andl $-32768, %eax + lea -62(%ecx), %edx + andl $32767, %edx + lea -16417(%ecx), %edi + orl %edx, %eax + movw %ax, 24(%esp) + movl $-2078209981, %eax + fldt 16(%esp) + imull %edi + sarl $31, %edi + lea -16417(%edx,%ecx), %edx + sarl $4, %edx + subl %edi, %edx + movl %edx, %edi + shll $5, %edi + negl %edi + addl %edx, %edi + fstpt (%esp) + fldt (%esp) + movl $0, (%esp) + fldt (%esp) + lea -16417(%edi,%ecx), %ecx + cmpl $23, %ecx + fsubr %st, %st(1) + movl 12(%esp), %ecx + jl ..B1.12 +..B1.11: + fxch %st(4) + fstpt (%esp) + lea (,%edx,8), %eax + lea (%eax,%edx,4), %edi + incl %edx + fldt _4OPI@GOTOFF(%edi,%ebx) + fmul %st(1), %st + fldt 12+_4OPI@GOTOFF(%edi,%ebx) + fmul %st(5), %st + faddp %st, %st(1) + fstpt 12(%esp) + fldt 12(%esp) + andl $-16777216, 12(%esp) + fldt 12(%esp) + fsubrp %st, %st(1) + jmp ..B1.13 +..B1.12: + fstp %st(4) + fld %st(2) +..B1.13: + fld %st(4) + lea (,%edx,8), %edi + lea (%edi,%edx,4), %eax + fldt 12+_4OPI@GOTOFF(%eax,%ebx) + fmul %st, %st(1) + fmul %st(3), %st + fldt _4OPI@GOTOFF(%eax,%ebx) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fldt 24+_4OPI@GOTOFF(%eax,%ebx) + fmul %st(7), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fadd %st, %st(1) + fstpt 12(%esp) + fldt _ADDING@GOTOFF(%ebx) + fld %st(0) + fadd %st(2), %st + fstpt (%esp) + fldt (%esp) + fsubp %st, %st(1) + movl (%esp), %edi + fcom %st(1) + fnstsw %ax + fxch %st(1) + fstp %st(0) + fldt 24(%esp) + sahf + jbe ..B1.15 +..B1.14: + fldt _nonel_value@GOTOFF(%ebx) + decl %edi + faddp %st, %st(2) +..B1.15: + addl %edi, %ecx + fxch %st(1) + fsubrp %st, %st(2) + testb $1, %cl + je ..B1.18 +..B1.16: + fstp %st(4) + fldt _nonel_value@GOTOFF(%ebx) + fxch %st(4) +..B1.18: + lea 2(%edx), %edi + movl %edi, %eax + fxch %st(1) + faddp %st, %st(4) + negl %eax + faddp %st, %st(3) + addl $532, %eax + cmpl $5, %eax + jbe ..L4 + movl $5, %eax +..L4: + movl %eax, 8(%esp) + cmpl $532, %edi + jge ..B1.25 +..B1.19: + shrl $1, %eax + movl %eax, 12(%esp) + testl %eax, %eax + jbe ..B1.33 +..B1.20: + movl %esi, (%esp) + lea 16(,%edx,8), %eax + movl %ebx, 4(%esp) + lea 8(%eax,%edx,4), %eax + movl 12(%esp), %esi + xorl %edi, %edi + lea _4OPI@GOTOFF(%ebx,%eax), %eax +..B1.21: + jmp ..L5 +..L6: + faddp %st, %st(3) +..L5: + fld %st(3) + lea (%edi,%edi,2), %ebx + fldt 12(%eax,%ebx,8) + incl %edi + fmul %st, %st(1) + cmpl %esi, %edi + fmul %st(2), %st + fldt (%eax,%ebx,8) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fldt 24(%eax,%ebx,8) + fmul %st(5), %st + faddp %st, %st(1) + jb ..L6 + faddp %st, %st(3) +..B1.22: + movl (%esp), %esi + lea 1(%edi,%edi), %edi + movl 4(%esp), %ebx +..B1.23: + lea -1(%edi), %eax + cmpl 8(%esp), %eax + jae ..B1.25 +..B1.24: + lea 1(%edi,%edx), %edx + lea (,%edx,8), %eax + lea (%eax,%edx,4), %edi + fldt _4OPI@GOTOFF(%ebx,%edi) + fmulp %st, %st(1) + fldt 12+_4OPI@GOTOFF(%ebx,%edi) + fmulp %st, %st(4) + fadd %st(3), %st + fadd %st, %st(2) +..B1.25: + fstp %st(3) + fstp %st(2) + fmulp %st, %st(1) +..B1.27: + testb $1, %cl + lea 1(%ecx), %edi + fld %st(0) + jne ..L7 + movl %ecx, %edi +..L7: + andl $7, %edi + movl 24(%ebp), %edx + fmul %st(1), %st + imull ssign@GOTOFF(%ebx,%edi,4), %esi + movl csign@GOTOFF(%ebx,%edi,4), %eax + andl $3, %edi + decl %edi + movl %esi, 24(%esp) + cmpl $1, %edi + fildl 24(%esp) + ja ..B1.29 +..B1.28: + fldt _PC@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PC@GOTOFF(%ebx) + movl 20(%ebp), %ecx + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PC@GOTOFF(%ebx) + movl %eax, 24(%esp) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _ponel_value@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%ecx) + fldt _PS@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fildl 24(%esp) + fmulp %st, %st(1) + fstpt (%edx) + jmp ..B1.30 +..B1.29: + fldt _PS@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PS@GOTOFF(%ebx) + movl 20(%ebp), %ecx + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PS@GOTOFF(%ebx) + movl %eax, 24(%esp) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fildl 24(%esp) + fldt 60+_PS@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 72+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_PS@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fmul %st(4), %st + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(1) + fstpt (%ecx) + fldt _PC@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84+_PC@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt _ponel_value@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%edx) +..B1.30: + movl 36(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.32 +..B1.31: + addl $52, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + call __stack_chk_fail@PLT +..B1.33: + movl $1, %edi + jmp ..B1.23 + .align 16,0x90 + .type __libm_sincos_pi4l,@function + .size __libm_sincos_pi4l,.-__libm_sincos_pi4l + .data +# -- End __libm_sincos_pi4l + .section .rodata, "a" + .align 4 + .align 4 +ssign: + .long 1 + .long 1 + .long 1 + .long 1 + .long -1 + .long -1 + .long -1 + .long -1 + .type ssign,@object + .size ssign,32 + .align 4 +csign: + .long 1 + .long 1 + .long -1 + .long -1 + .long -1 + .long -1 + .long 1 + .long 1 + .type csign,@object + .size csign,32 + .align 2 +_pzerol_value: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _pzerol_value,@object + .size _pzerol_value,12 + .align 2 +_pion4: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16382 + .word 0 + .type _pion4,@object + .size _pion4,12 + .align 2 +_cody_thres_val: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16413 + .word 0 + .type _cody_thres_val,@object + .size _cody_thres_val,12 + .align 2 +__4onpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16383 + .word 0 + .type __4onpi,@object + .size __4onpi,12 + .align 2 +_PI04: + .word 0 + .word 0 + .word 55936 + .word 51471 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 41728 + .word 34949 + .word 16356 + .word 0 + .word 14087 + .word 41696 + .word 12696 + .word 36145 + .word 16328 + .word 0 + .type _PI04,@object + .size _PI04,36 + .align 2 +_4OPI: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33646 + .word 41721 + .word 16445 + .word 0 + .word 0 + .word 0 + .word 10832 + .word 40072 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 44008 + .word 65043 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 28384 + .word 64154 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 38272 + .word 56162 + .word 16317 + .word 0 + .word 0 + .word 0 + .word 7298 + .word 51682 + .word 16290 + .word 0 + .word 0 + .word 0 + .word 45504 + .word 65320 + .word 16254 + .word 0 + .word 0 + .word 0 + .word 61204 + .word 44922 + .word 16227 + .word 0 + .word 0 + .word 0 + .word 18652 + .word 50030 + .word 16196 + .word 0 + .word 0 + .word 0 + .word 14144 + .word 59657 + .word 16163 + .word 0 + .word 0 + .word 0 + .word 37450 + .word 47105 + .word 16135 + .word 0 + .word 0 + .word 0 + .word 14898 + .word 56641 + .word 16104 + .word 0 + .word 0 + .word 0 + .word 34680 + .word 34623 + .word 16071 + .word 0 + .word 0 + .word 0 + .word 4760 + .word 45515 + .word 16041 + .word 0 + .word 0 + .word 0 + .word 41480 + .word 40187 + .word 16011 + .word 0 + .word 0 + .word 0 + .word 47852 + .word 55252 + .word 15979 + .word 0 + .word 0 + .word 0 + .word 54072 + .word 35081 + .word 15948 + .word 0 + .word 0 + .word 0 + .word 26808 + .word 57421 + .word 15916 + .word 0 + .word 0 + .word 0 + .word 20068 + .word 57232 + .word 15887 + .word 0 + .word 0 + .word 0 + .word 49576 + .word 60188 + .word 15854 + .word 0 + .word 0 + .word 0 + .word 10016 + .word 52861 + .word 15823 + .word 0 + .word 0 + .word 0 + .word 30648 + .word 35825 + .word 15792 + .word 0 + .word 0 + .word 0 + .word 60542 + .word 58528 + .word 15763 + .word 0 + .word 0 + .word 0 + .word 65468 + .word 61743 + .word 15732 + .word 0 + .word 0 + .word 0 + .word 64960 + .word 45825 + .word 15696 + .word 0 + .word 0 + .word 0 + .word 50604 + .word 38792 + .word 15670 + .word 0 + .word 0 + .word 0 + .word 18394 + .word 33435 + .word 15639 + .word 0 + .word 0 + .word 0 + .word 55780 + .word 42703 + .word 15608 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 63841 + .word 15576 + .word 0 + .word 0 + .word 0 + .word 63080 + .word 62563 + .word 15545 + .word 0 + .word 0 + .word 0 + .word 20840 + .word 62207 + .word 15514 + .word 0 + .word 0 + .word 0 + .word 30094 + .word 59983 + .word 15484 + .word 0 + .word 0 + .word 0 + .word 61818 + .word 60389 + .word 15453 + .word 0 + .word 0 + .word 0 + .word 40186 + .word 40579 + .word 15422 + .word 0 + .word 0 + .word 0 + .word 42170 + .word 58004 + .word 15391 + .word 0 + .word 0 + .word 0 + .word 55276 + .word 39678 + .word 15359 + .word 0 + .word 0 + .word 0 + .word 44672 + .word 36806 + .word 15326 + .word 0 + .word 0 + .word 0 + .word 13060 + .word 34144 + .word 15297 + .word 0 + .word 0 + .word 0 + .word 28016 + .word 57231 + .word 15264 + .word 0 + .word 0 + .word 0 + .word 16112 + .word 44995 + .word 15235 + .word 0 + .word 0 + .word 0 + .word 53464 + .word 33387 + .word 15203 + .word 0 + .word 0 + .word 0 + .word 7296 + .word 60751 + .word 15170 + .word 0 + .word 0 + .word 0 + .word 29452 + .word 45231 + .word 15142 + .word 0 + .word 0 + .word 0 + .word 26208 + .word 49689 + .word 15111 + .word 0 + .word 0 + .word 0 + .word 37900 + .word 44002 + .word 15080 + .word 0 + .word 0 + .word 0 + .word 57340 + .word 33800 + .word 15049 + .word 0 + .word 0 + .word 0 + .word 27544 + .word 50178 + .word 15018 + .word 0 + .word 0 + .word 0 + .word 6168 + .word 40132 + .word 14987 + .word 0 + .word 0 + .word 0 + .word 21392 + .word 43702 + .word 14954 + .word 0 + .word 0 + .word 0 + .word 45168 + .word 54372 + .word 14926 + .word 0 + .word 0 + .word 0 + .word 8986 + .word 40688 + .word 14895 + .word 0 + .word 0 + .word 0 + .word 1648 + .word 53745 + .word 14863 + .word 0 + .word 0 + .word 0 + .word 30520 + .word 55795 + .word 14831 + .word 0 + .word 0 + .word 0 + .word 43060 + .word 32914 + .word 14801 + .word 0 + .word 0 + .word 0 + .word 46172 + .word 52771 + .word 14770 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 45285 + .word 14738 + .word 0 + .word 0 + .word 0 + .word 53590 + .word 44868 + .word 14709 + .word 0 + .word 0 + .word 0 + .word 40786 + .word 35970 + .word 14678 + .word 0 + .word 0 + .word 0 + .word 33436 + .word 65411 + .word 14646 + .word 0 + .word 0 + .word 0 + .word 32006 + .word 61382 + .word 14616 + .word 0 + .word 0 + .word 0 + .word 37856 + .word 45239 + .word 14583 + .word 0 + .word 0 + .word 0 + .word 60894 + .word 49555 + .word 14554 + .word 0 + .word 0 + .word 0 + .word 48064 + .word 53065 + .word 14519 + .word 0 + .word 0 + .word 0 + .word 48624 + .word 54844 + .word 14492 + .word 0 + .word 0 + .word 0 + .word 7988 + .word 40762 + .word 14461 + .word 0 + .word 0 + .word 0 + .word 16270 + .word 58745 + .word 14430 + .word 0 + .word 0 + .word 0 + .word 37064 + .word 50168 + .word 14398 + .word 0 + .word 0 + .word 0 + .word 18624 + .word 63736 + .word 14364 + .word 0 + .word 0 + .word 0 + .word 60758 + .word 44966 + .word 14337 + .word 0 + .word 0 + .word 0 + .word 33304 + .word 47465 + .word 14306 + .word 0 + .word 0 + .word 0 + .word 6226 + .word 60503 + .word 14275 + .word 0 + .word 0 + .word 0 + .word 26380 + .word 54900 + .word 14243 + .word 0 + .word 0 + .word 0 + .word 44352 + .word 49860 + .word 14213 + .word 0 + .word 0 + .word 0 + .word 11904 + .word 42646 + .word 14182 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 50279 + .word 14145 + .word 0 + .word 0 + .word 0 + .word 15474 + .word 50606 + .word 14120 + .word 0 + .word 0 + .word 0 + .word 45062 + .word 44137 + .word 14089 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 36063 + .word 14055 + .word 0 + .word 0 + .word 0 + .word 40658 + .word 53854 + .word 14027 + .word 0 + .word 0 + .word 0 + .word 28652 + .word 43690 + .word 13996 + .word 0 + .word 0 + .word 0 + .word 24640 + .word 64348 + .word 13963 + .word 0 + .word 0 + .word 0 + .word 30284 + .word 41980 + .word 13933 + .word 0 + .word 0 + .word 0 + .word 45652 + .word 38222 + .word 13902 + .word 0 + .word 0 + .word 0 + .word 15900 + .word 62940 + .word 13871 + .word 0 + .word 0 + .word 0 + .word 31494 + .word 50741 + .word 13841 + .word 0 + .word 0 + .word 0 + .word 43194 + .word 55096 + .word 13810 + .word 0 + .word 0 + .word 0 + .word 1740 + .word 45646 + .word 13778 + .word 0 + .word 0 + .word 0 + .word 28936 + .word 44150 + .word 13748 + .word 0 + .word 0 + .word 0 + .word 8996 + .word 42955 + .word 13717 + .word 0 + .word 0 + .word 0 + .word 44096 + .word 61205 + .word 13684 + .word 0 + .word 0 + .word 0 + .word 44614 + .word 54550 + .word 13655 + .word 0 + .word 0 + .word 0 + .word 24926 + .word 57347 + .word 13624 + .word 0 + .word 0 + .word 0 + .word 3312 + .word 61415 + .word 13590 + .word 0 + .word 0 + .word 0 + .word 64336 + .word 63884 + .word 13562 + .word 0 + .word 0 + .word 0 + .word 2748 + .word 62259 + .word 13530 + .word 0 + .word 0 + .word 0 + .word 56672 + .word 51775 + .word 13498 + .word 0 + .word 0 + .word 0 + .word 32438 + .word 55423 + .word 13469 + .word 0 + .word 0 + .word 0 + .word 17652 + .word 45713 + .word 13438 + .word 0 + .word 0 + .word 0 + .word 65408 + .word 51586 + .word 13403 + .word 0 + .word 0 + .word 0 + .word 40416 + .word 55736 + .word 13376 + .word 0 + .word 0 + .word 0 + .word 52546 + .word 37734 + .word 13345 + .word 0 + .word 0 + .word 0 + .word 48880 + .word 64238 + .word 13314 + .word 0 + .word 0 + .word 0 + .word 56004 + .word 46833 + .word 13282 + .word 0 + .word 0 + .word 0 + .word 61760 + .word 38110 + .word 13250 + .word 0 + .word 0 + .word 0 + .word 41496 + .word 35659 + .word 13219 + .word 0 + .word 0 + .word 0 + .word 25472 + .word 41269 + .word 13187 + .word 0 + .word 0 + .word 0 + .word 45444 + .word 36018 + .word 13159 + .word 0 + .word 0 + .word 0 + .word 6510 + .word 56417 + .word 13128 + .word 0 + .word 0 + .word 0 + .word 3072 + .word 56837 + .word 13097 + .word 0 + .word 0 + .word 0 + .word 61338 + .word 48440 + .word 13066 + .word 0 + .word 0 + .word 0 + .word 49568 + .word 57088 + .word 13034 + .word 0 + .word 0 + .word 0 + .word 4240 + .word 39283 + .word 13002 + .word 0 + .word 0 + .word 0 + .word 18562 + .word 33537 + .word 12973 + .word 0 + .word 0 + .word 0 + .word 31422 + .word 44487 + .word 12942 + .word 0 + .word 0 + .word 0 + .word 31930 + .word 60459 + .word 12911 + .word 0 + .word 0 + .word 0 + .word 42272 + .word 36641 + .word 12878 + .word 0 + .word 0 + .word 0 + .word 28940 + .word 36150 + .word 12849 + .word 0 + .word 0 + .word 0 + .word 21010 + .word 50925 + .word 12818 + .word 0 + .word 0 + .word 0 + .word 29448 + .word 64886 + .word 12786 + .word 0 + .word 0 + .word 0 + .word 20500 + .word 54600 + .word 12756 + .word 0 + .word 0 + .word 0 + .word 54258 + .word 46233 + .word 12725 + .word 0 + .word 0 + .word 0 + .word 32628 + .word 42502 + .word 12693 + .word 0 + .word 0 + .word 0 + .word 61608 + .word 55072 + .word 12663 + .word 0 + .word 0 + .word 0 + .word 6236 + .word 57871 + .word 12631 + .word 0 + .word 0 + .word 0 + .word 42408 + .word 34616 + .word 12601 + .word 0 + .word 0 + .word 0 + .word 56692 + .word 51963 + .word 12569 + .word 0 + .word 0 + .word 0 + .word 39094 + .word 48526 + .word 12539 + .word 0 + .word 0 + .word 0 + .word 59870 + .word 38783 + .word 12508 + .word 0 + .word 0 + .word 0 + .word 26560 + .word 33165 + .word 12477 + .word 0 + .word 0 + .word 0 + .word 58666 + .word 37666 + .word 12446 + .word 0 + .word 0 + .word 0 + .word 58728 + .word 39788 + .word 12414 + .word 0 + .word 0 + .word 0 + .word 9048 + .word 43530 + .word 12383 + .word 0 + .word 0 + .word 0 + .word 58496 + .word 57659 + .word 12350 + .word 0 + .word 0 + .word 0 + .word 12324 + .word 37025 + .word 12322 + .word 0 + .word 0 + .word 0 + .word 38432 + .word 55856 + .word 12290 + .word 0 + .word 0 + .word 0 + .word 35210 + .word 45960 + .word 12260 + .word 0 + .word 0 + .word 0 + .word 45644 + .word 51345 + .word 12229 + .word 0 + .word 0 + .word 0 + .word 32854 + .word 63883 + .word 12198 + .word 0 + .word 0 + .word 0 + .word 29348 + .word 41450 + .word 12166 + .word 0 + .word 0 + .word 0 + .word 27384 + .word 38024 + .word 12134 + .word 0 + .word 0 + .word 0 + .word 57356 + .word 57291 + .word 12105 + .word 0 + .word 0 + .word 0 + .word 61164 + .word 51521 + .word 12073 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 59151 + .word 12041 + .word 0 + .word 0 + .word 0 + .word 36704 + .word 39943 + .word 12010 + .word 0 + .word 0 + .word 0 + .word 45864 + .word 50151 + .word 11981 + .word 0 + .word 0 + .word 0 + .word 37892 + .word 63687 + .word 11949 + .word 0 + .word 0 + .word 0 + .word 14560 + .word 51615 + .word 11918 + .word 0 + .word 0 + .word 0 + .word 38776 + .word 55684 + .word 11886 + .word 0 + .word 0 + .word 0 + .word 59136 + .word 53570 + .word 11855 + .word 0 + .word 0 + .word 0 + .word 55556 + .word 37955 + .word 11826 + .word 0 + .word 0 + .word 0 + .word 54458 + .word 44670 + .word 11795 + .word 0 + .word 0 + .word 0 + .word 36446 + .word 34084 + .word 11764 + .word 0 + .word 0 + .word 0 + .word 46416 + .word 51693 + .word 11731 + .word 0 + .word 0 + .word 0 + .word 21432 + .word 34376 + .word 11702 + .word 0 + .word 0 + .word 0 + .word 56036 + .word 34809 + .word 11671 + .word 0 + .word 0 + .word 0 + .word 10562 + .word 55654 + .word 11640 + .word 0 + .word 0 + .word 0 + .word 20264 + .word 53052 + .word 11608 + .word 0 + .word 0 + .word 0 + .word 64064 + .word 50415 + .word 11574 + .word 0 + .word 0 + .word 0 + .word 17444 + .word 48295 + .word 11546 + .word 0 + .word 0 + .word 0 + .word 11874 + .word 52677 + .word 11516 + .word 0 + .word 0 + .word 0 + .word 60808 + .word 39275 + .word 11485 + .word 0 + .word 0 + .word 0 + .word 31792 + .word 55677 + .word 11451 + .word 0 + .word 0 + .word 0 + .word 60710 + .word 49006 + .word 11423 + .word 0 + .word 0 + .word 0 + .word 10520 + .word 37403 + .word 11391 + .word 0 + .word 0 + .word 0 + .word 20004 + .word 59470 + .word 11360 + .word 0 + .word 0 + .word 0 + .word 28096 + .word 37612 + .word 11330 + .word 0 + .word 0 + .word 0 + .word 20268 + .word 44280 + .word 11298 + .word 0 + .word 0 + .word 0 + .word 50740 + .word 61588 + .word 11267 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 58835 + .word 11235 + .word 0 + .word 0 + .word 0 + .word 8576 + .word 42496 + .word 11200 + .word 0 + .word 0 + .word 0 + .word 33920 + .word 54912 + .word 11169 + .word 0 + .word 0 + .word 0 + .word 35620 + .word 54843 + .word 11143 + .word 0 + .word 0 + .word 0 + .word 736 + .word 43591 + .word 11109 + .word 0 + .word 0 + .word 0 + .word 39632 + .word 61060 + .word 11080 + .word 0 + .word 0 + .word 0 + .word 63452 + .word 63129 + .word 11051 + .word 0 + .word 0 + .word 0 + .word 56798 + .word 58512 + .word 11020 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 46333 + .word 10986 + .word 0 + .word 0 + .word 0 + .word 37300 + .word 36598 + .word 10957 + .word 0 + .word 0 + .word 0 + .word 41952 + .word 41639 + .word 10924 + .word 0 + .word 0 + .word 0 + .word 52452 + .word 33459 + .word 10895 + .word 0 + .word 0 + .word 0 + .word 58558 + .word 33287 + .word 10865 + .word 0 + .word 0 + .word 0 + .word 7570 + .word 43843 + .word 10834 + .word 0 + .word 0 + .word 0 + .word 59416 + .word 63990 + .word 10802 + .word 0 + .word 0 + .word 0 + .word 65298 + .word 47744 + .word 10772 + .word 0 + .word 0 + .word 0 + .word 21076 + .word 34089 + .word 10741 + .word 0 + .word 0 + .word 0 + .word 7048 + .word 57394 + .word 10710 + .word 0 + .word 0 + .word 0 + .word 12872 + .word 55405 + .word 10677 + .word 0 + .word 0 + .word 0 + .word 12608 + .word 51669 + .word 10643 + .word 0 + .word 0 + .word 0 + .word 5350 + .word 48455 + .word 10617 + .word 0 + .word 0 + .word 0 + .word 23568 + .word 58692 + .word 10585 + .word 0 + .word 0 + .word 0 + .word 40784 + .word 37046 + .word 10553 + .word 0 + .word 0 + .word 0 + .word 38992 + .word 43861 + .word 10523 + .word 0 + .word 0 + .word 0 + .word 10064 + .word 40199 + .word 10493 + .word 0 + .word 0 + .word 0 + .word 26368 + .word 35771 + .word 10456 + .word 0 + .word 0 + .word 0 + .word 23994 + .word 60721 + .word 10431 + .word 0 + .word 0 + .word 0 + .word 25052 + .word 34302 + .word 10399 + .word 0 + .word 0 + .word 0 + .word 39842 + .word 54964 + .word 10369 + .word 0 + .word 0 + .word 0 + .word 11568 + .word 58277 + .word 10336 + .word 0 + .word 0 + .word 0 + .word 26160 + .word 46438 + .word 10306 + .word 0 + .word 0 + .word 0 + .word 23252 + .word 43049 + .word 10276 + .word 0 + .word 0 + .word 0 + .word 35288 + .word 58000 + .word 10245 + .word 0 + .word 0 + .word 0 + .word 14614 + .word 50216 + .word 10214 + .word 0 + .word 0 + .word 0 + .word 1168 + .word 48804 + .word 10181 + .word 0 + .word 0 + .word 0 + .word 60934 + .word 33006 + .word 10152 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 62247 + .word 10117 + .word 0 + .word 0 + .word 0 + .word 59968 + .word 43121 + .word 10085 + .word 0 + .word 0 + .word 0 + .word 25560 + .word 39974 + .word 10057 + .word 0 + .word 0 + .word 0 + .word 1978 + .word 49353 + .word 10028 + .word 0 + .word 0 + .word 0 + .word 16290 + .word 38807 + .word 9997 + .word 0 + .word 0 + .word 0 + .word 8646 + .word 65226 + .word 9966 + .word 0 + .word 0 + .word 0 + .word 56896 + .word 34317 + .word 9933 + .word 0 + .word 0 + .word 0 + .word 40136 + .word 39118 + .word 9902 + .word 0 + .word 0 + .word 0 + .word 14200 + .word 41756 + .word 9871 + .word 0 + .word 0 + .word 0 + .word 59256 + .word 63202 + .word 9840 + .word 0 + .word 0 + .word 0 + .word 22968 + .word 63553 + .word 9810 + .word 0 + .word 0 + .word 0 + .word 736 + .word 44292 + .word 9778 + .word 0 + .word 0 + .word 0 + .word 23186 + .word 37760 + .word 9749 + .word 0 + .word 0 + .word 0 + .word 51008 + .word 34950 + .word 9714 + .word 0 + .word 0 + .word 0 + .word 1664 + .word 64248 + .word 9681 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 35199 + .word 9656 + .word 0 + .word 0 + .word 0 + .word 34656 + .word 63747 + .word 9625 + .word 0 + .word 0 + .word 0 + .word 44330 + .word 49864 + .word 9594 + .word 0 + .word 0 + .word 0 + .word 11654 + .word 35567 + .word 9563 + .word 0 + .word 0 + .word 0 + .word 7924 + .word 58919 + .word 9531 + .word 0 + .word 0 + .word 0 + .word 2532 + .word 32800 + .word 9500 + .word 0 + .word 0 + .word 0 + .word 30024 + .word 53799 + .word 9469 + .word 0 + .word 0 + .word 0 + .word 30172 + .word 64347 + .word 9438 + .word 0 + .word 0 + .word 0 + .word 60036 + .word 51382 + .word 9407 + .word 0 + .word 0 + .word 0 + .word 58576 + .word 33093 + .word 9376 + .word 0 + .word 0 + .word 0 + .word 13888 + .word 38760 + .word 9345 + .word 0 + .word 0 + .word 0 + .word 9322 + .word 52460 + .word 9315 + .word 0 + .word 0 + .word 0 + .word 20944 + .word 41077 + .word 9282 + .word 0 + .word 0 + .word 0 + .word 17976 + .word 41861 + .word 9252 + .word 0 + .word 0 + .word 0 + .word 55176 + .word 55158 + .word 9222 + .word 0 + .word 0 + .word 0 + .word 4976 + .word 35223 + .word 9191 + .word 0 + .word 0 + .word 0 + .word 7816 + .word 39783 + .word 9159 + .word 0 + .word 0 + .word 0 + .word 27656 + .word 55669 + .word 9129 + .word 0 + .word 0 + .word 0 + .word 64944 + .word 53184 + .word 9095 + .word 0 + .word 0 + .word 0 + .word 12544 + .word 49190 + .word 9067 + .word 0 + .word 0 + .word 0 + .word 50612 + .word 44644 + .word 9035 + .word 0 + .word 0 + .word 0 + .word 8832 + .word 63111 + .word 9000 + .word 0 + .word 0 + .word 0 + .word 11744 + .word 36870 + .word 8974 + .word 0 + .word 0 + .word 0 + .word 9404 + .word 63025 + .word 8943 + .word 0 + .word 0 + .word 0 + .word 47316 + .word 43381 + .word 8912 + .word 0 + .word 0 + .word 0 + .word 55716 + .word 47433 + .word 8880 + .word 0 + .word 0 + .word 0 + .word 46414 + .word 48441 + .word 8850 + .word 0 + .word 0 + .word 0 + .word 19116 + .word 39506 + .word 8819 + .word 0 + .word 0 + .word 0 + .word 48060 + .word 53381 + .word 8788 + .word 0 + .word 0 + .word 0 + .word 57112 + .word 50739 + .word 8756 + .word 0 + .word 0 + .word 0 + .word 5840 + .word 60581 + .word 8724 + .word 0 + .word 0 + .word 0 + .word 62112 + .word 57199 + .word 8691 + .word 0 + .word 0 + .word 0 + .word 35908 + .word 59499 + .word 8663 + .word 0 + .word 0 + .word 0 + .word 13760 + .word 48116 + .word 8632 + .word 0 + .word 0 + .word 0 + .word 3136 + .word 56059 + .word 8597 + .word 0 + .word 0 + .word 0 + .word 37596 + .word 39221 + .word 8571 + .word 0 + .word 0 + .word 0 + .word 3232 + .word 48550 + .word 8536 + .word 0 + .word 0 + .word 0 + .word 22872 + .word 42749 + .word 8507 + .word 0 + .word 0 + .word 0 + .word 41948 + .word 40319 + .word 8478 + .word 0 + .word 0 + .word 0 + .word 31196 + .word 64693 + .word 8446 + .word 0 + .word 0 + .word 0 + .word 62052 + .word 52923 + .word 8416 + .word 0 + .word 0 + .word 0 + .word 2750 + .word 33544 + .word 8385 + .word 0 + .word 0 + .word 0 + .word 12462 + .word 46179 + .word 8354 + .word 0 + .word 0 + .word 0 + .word 25128 + .word 45120 + .word 8321 + .word 0 + .word 0 + .word 0 + .word 51634 + .word 62523 + .word 8292 + .word 0 + .word 0 + .word 0 + .word 15758 + .word 42163 + .word 8261 + .word 0 + .word 0 + .word 0 + .word 34022 + .word 36267 + .word 8230 + .word 0 + .word 0 + .word 0 + .word 41252 + .word 39796 + .word 8198 + .word 0 + .word 0 + .word 0 + .word 49782 + .word 54423 + .word 8168 + .word 0 + .word 0 + .word 0 + .word 25428 + .word 42086 + .word 8136 + .word 0 + .word 0 + .word 0 + .word 34388 + .word 44810 + .word 8105 + .word 0 + .word 0 + .word 0 + .word 7456 + .word 64092 + .word 8073 + .word 0 + .word 0 + .word 0 + .word 48336 + .word 62448 + .word 8041 + .word 0 + .word 0 + .word 0 + .word 60912 + .word 61622 + .word 8012 + .word 0 + .word 0 + .word 0 + .word 17852 + .word 37250 + .word 7982 + .word 0 + .word 0 + .word 0 + .word 57940 + .word 56453 + .word 7951 + .word 0 + .word 0 + .word 0 + .word 47256 + .word 59825 + .word 7919 + .word 0 + .word 0 + .word 0 + .word 3774 + .word 59120 + .word 7889 + .word 0 + .word 0 + .word 0 + .word 43448 + .word 62852 + .word 7857 + .word 0 + .word 0 + .word 0 + .word 4840 + .word 57195 + .word 7827 + .word 0 + .word 0 + .word 0 + .word 40862 + .word 52565 + .word 7796 + .word 0 + .word 0 + .word 0 + .word 1440 + .word 60474 + .word 7764 + .word 0 + .word 0 + .word 0 + .word 55520 + .word 38648 + .word 7734 + .word 0 + .word 0 + .word 0 + .word 15316 + .word 52422 + .word 7702 + .word 0 + .word 0 + .word 0 + .word 18704 + .word 47227 + .word 7672 + .word 0 + .word 0 + .word 0 + .word 48892 + .word 54283 + .word 7640 + .word 0 + .word 0 + .word 0 + .word 12670 + .word 41990 + .word 7610 + .word 0 + .word 0 + .word 0 + .word 27570 + .word 49842 + .word 7579 + .word 0 + .word 0 + .word 0 + .word 47230 + .word 47992 + .word 7548 + .word 0 + .word 0 + .word 0 + .word 41020 + .word 56253 + .word 7516 + .word 0 + .word 0 + .word 0 + .word 23404 + .word 58312 + .word 7486 + .word 0 + .word 0 + .word 0 + .word 35176 + .word 51854 + .word 7455 + .word 0 + .word 0 + .word 0 + .word 49188 + .word 59051 + .word 7423 + .word 0 + .word 0 + .word 0 + .word 16656 + .word 54507 + .word 7391 + .word 0 + .word 0 + .word 0 + .word 41320 + .word 48565 + .word 7362 + .word 0 + .word 0 + .word 0 + .word 302 + .word 42490 + .word 7331 + .word 0 + .word 0 + .word 0 + .word 26680 + .word 39967 + .word 7299 + .word 0 + .word 0 + .word 0 + .word 41304 + .word 43638 + .word 7269 + .word 0 + .word 0 + .word 0 + .word 2314 + .word 48533 + .word 7238 + .word 0 + .word 0 + .word 0 + .word 63294 + .word 35693 + .word 7207 + .word 0 + .word 0 + .word 0 + .word 24538 + .word 48319 + .word 7176 + .word 0 + .word 0 + .word 0 + .word 56296 + .word 47263 + .word 7145 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 38599 + .word 7113 + .word 0 + .word 0 + .word 0 + .word 6594 + .word 62116 + .word 7083 + .word 0 + .word 0 + .word 0 + .word 47104 + .word 63573 + .word 7043 + .word 0 + .word 0 + .word 0 + .word 34812 + .word 34303 + .word 7021 + .word 0 + .word 0 + .word 0 + .word 5144 + .word 33695 + .word 6990 + .word 0 + .word 0 + .word 0 + .word 24966 + .word 55768 + .word 6959 + .word 0 + .word 0 + .word 0 + .word 62720 + .word 43946 + .word 6923 + .word 0 + .word 0 + .word 0 + .word 31542 + .word 56062 + .word 6897 + .word 0 + .word 0 + .word 0 + .word 62356 + .word 59096 + .word 6865 + .word 0 + .word 0 + .word 0 + .word 28412 + .word 40533 + .word 6835 + .word 0 + .word 0 + .word 0 + .word 24080 + .word 50467 + .word 6803 + .word 0 + .word 0 + .word 0 + .word 33296 + .word 46841 + .word 6770 + .word 0 + .word 0 + .word 0 + .word 39600 + .word 38627 + .word 6742 + .word 0 + .word 0 + .word 0 + .word 14436 + .word 37607 + .word 6710 + .word 0 + .word 0 + .word 0 + .word 39032 + .word 56421 + .word 6678 + .word 0 + .word 0 + .word 0 + .word 64032 + .word 54987 + .word 6649 + .word 0 + .word 0 + .word 0 + .word 27648 + .word 42212 + .word 6613 + .word 0 + .word 0 + .word 0 + .word 43840 + .word 46107 + .word 6584 + .word 0 + .word 0 + .word 0 + .word 17316 + .word 36574 + .word 6556 + .word 0 + .word 0 + .word 0 + .word 8928 + .word 37652 + .word 6522 + .word 0 + .word 0 + .word 0 + .word 24944 + .word 47433 + .word 6493 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 57430 + .word 6461 + .word 0 + .word 0 + .word 0 + .word 39848 + .word 43340 + .word 6430 + .word 0 + .word 0 + .word 0 + .word 64160 + .word 43542 + .word 6400 + .word 0 + .word 0 + .word 0 + .word 35226 + .word 63015 + .word 6370 + .word 0 + .word 0 + .word 0 + .word 40736 + .word 64368 + .word 6338 + .word 0 + .word 0 + .word 0 + .word 42168 + .word 49526 + .word 6307 + .word 0 + .word 0 + .word 0 + .word 45596 + .word 34243 + .word 6277 + .word 0 + .word 0 + .word 0 + .word 20690 + .word 39705 + .word 6246 + .word 0 + .word 0 + .word 0 + .word 54448 + .word 46856 + .word 6213 + .word 0 + .word 0 + .word 0 + .word 64392 + .word 62736 + .word 6182 + .word 0 + .word 0 + .word 0 + .word 12780 + .word 56461 + .word 6152 + .word 0 + .word 0 + .word 0 + .word 15360 + .word 49145 + .word 6122 + .word 0 + .word 0 + .word 0 + .word 20512 + .word 49931 + .word 6087 + .word 0 + .word 0 + .word 0 + .word 54512 + .word 55820 + .word 6057 + .word 0 + .word 0 + .word 0 + .word 8402 + .word 39333 + .word 6029 + .word 0 + .word 0 + .word 0 + .word 34094 + .word 53593 + .word 5998 + .word 0 + .word 0 + .word 0 + .word 31960 + .word 38817 + .word 5966 + .word 0 + .word 0 + .word 0 + .word 16954 + .word 39291 + .word 5936 + .word 0 + .word 0 + .word 0 + .word 49600 + .word 48765 + .word 5901 + .word 0 + .word 0 + .word 0 + .word 59580 + .word 56541 + .word 5874 + .word 0 + .word 0 + .word 0 + .word 35624 + .word 44550 + .word 5843 + .word 0 + .word 0 + .word 0 + .word 4142 + .word 47316 + .word 5812 + .word 0 + .word 0 + .word 0 + .word 43520 + .word 43612 + .word 5780 + .word 0 + .word 0 + .word 0 + .word 20976 + .word 40896 + .word 5747 + .word 0 + .word 0 + .word 0 + .word 63576 + .word 57729 + .word 5719 + .word 0 + .word 0 + .word 0 + .word 37288 + .word 33122 + .word 5688 + .word 0 + .word 0 + .word 0 + .word 24384 + .word 52079 + .word 5654 + .word 0 + .word 0 + .word 0 + .word 47952 + .word 58719 + .word 5624 + .word 0 + .word 0 + .word 0 + .word 44242 + .word 55445 + .word 5595 + .word 0 + .word 0 + .word 0 + .word 61232 + .word 38847 + .word 5561 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 46039 + .word 5528 + .word 0 + .word 0 + .word 0 + .word 13396 + .word 42933 + .word 5502 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 43305 + .word 5467 + .word 0 + .word 0 + .word 0 + .word 40708 + .word 35319 + .word 5440 + .word 0 + .word 0 + .word 0 + .word 44408 + .word 55685 + .word 5409 + .word 0 + .word 0 + .word 0 + .word 42090 + .word 44607 + .word 5378 + .word 0 + .word 0 + .word 0 + .word 25504 + .word 53466 + .word 5345 + .word 0 + .word 0 + .word 0 + .word 24208 + .word 33149 + .word 5315 + .word 0 + .word 0 + .word 0 + .word 5268 + .word 45375 + .word 5285 + .word 0 + .word 0 + .word 0 + .word 144 + .word 40000 + .word 5254 + .word 0 + .word 0 + .word 0 + .word 56688 + .word 52358 + .word 5221 + .word 0 + .word 0 + .word 0 + .word 25848 + .word 56175 + .word 5190 + .word 0 + .word 0 + .word 0 + .word 57900 + .word 44055 + .word 5160 + .word 0 + .word 0 + .word 0 + .word 24800 + .word 43437 + .word 5128 + .word 0 + .word 0 + .word 0 + .word 17984 + .word 54872 + .word 5094 + .word 0 + .word 0 + .word 0 + .word 25744 + .word 41345 + .word 5068 + .word 0 + .word 0 + .word 0 + .word 7668 + .word 43682 + .word 5036 + .word 0 + .word 0 + .word 0 + .word 47434 + .word 36705 + .word 5006 + .word 0 + .word 0 + .word 0 + .word 20888 + .word 40323 + .word 4974 + .word 0 + .word 0 + .word 0 + .word 3962 + .word 43032 + .word 4944 + .word 0 + .word 0 + .word 0 + .word 50270 + .word 49260 + .word 4913 + .word 0 + .word 0 + .word 0 + .word 20160 + .word 64041 + .word 4877 + .word 0 + .word 0 + .word 0 + .word 25624 + .word 36013 + .word 4849 + .word 0 + .word 0 + .word 0 + .word 48328 + .word 59345 + .word 4820 + .word 0 + .word 0 + .word 0 + .word 51508 + .word 63920 + .word 4788 + .word 0 + .word 0 + .word 0 + .word 27872 + .word 39135 + .word 4758 + .word 0 + .word 0 + .word 0 + .word 13590 + .word 58857 + .word 4727 + .word 0 + .word 0 + .word 0 + .word 50880 + .word 61323 + .word 4692 + .word 0 + .word 0 + .word 0 + .word 44802 + .word 37181 + .word 4665 + .word 0 + .word 0 + .word 0 + .word 53808 + .word 57813 + .word 4634 + .word 0 + .word 0 + .word 0 + .word 64424 + .word 49714 + .word 4602 + .word 0 + .word 0 + .word 0 + .word 31652 + .word 44011 + .word 4572 + .word 0 + .word 0 + .word 0 + .word 28252 + .word 50834 + .word 4541 + .word 0 + .word 0 + .word 0 + .word 30370 + .word 38742 + .word 4510 + .word 0 + .word 0 + .word 0 + .word 57728 + .word 58403 + .word 4473 + .word 0 + .word 0 + .word 0 + .word 35900 + .word 37112 + .word 4448 + .word 0 + .word 0 + .word 0 + .word 40764 + .word 40914 + .word 4417 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 46910 + .word 4386 + .word 0 + .word 0 + .word 0 + .word 17854 + .word 35030 + .word 4355 + .word 0 + .word 0 + .word 0 + .word 4378 + .word 35776 + .word 4324 + .word 0 + .word 0 + .word 0 + .word 57962 + .word 55295 + .word 4293 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 56717 + .word 4260 + .word 0 + .word 0 + .word 0 + .word 37744 + .word 49416 + .word 4229 + .word 0 + .word 0 + .word 0 + .word 38484 + .word 35759 + .word 4200 + .word 0 + .word 0 + .word 0 + .word 55020 + .word 54969 + .word 4169 + .word 0 + .word 0 + .word 0 + .word 9188 + .word 55223 + .word 4137 + .word 0 + .word 0 + .word 0 + .word 6822 + .word 43079 + .word 4107 + .word 0 + .word 0 + .word 0 + .word 48870 + .word 40943 + .word 4076 + .word 0 + .word 0 + .word 0 + .word 9936 + .word 42731 + .word 4043 + .word 0 + .word 0 + .word 0 + .word 23430 + .word 43136 + .word 4014 + .word 0 + .word 0 + .word 0 + .word 4700 + .word 55665 + .word 3982 + .word 0 + .word 0 + .word 0 + .word 8056 + .word 40216 + .word 3951 + .word 0 + .word 0 + .word 0 + .word 3716 + .word 45403 + .word 3920 + .word 0 + .word 0 + .word 0 + .word 53440 + .word 49488 + .word 3889 + .word 0 + .word 0 + .word 0 + .word 41776 + .word 50188 + .word 3858 + .word 0 + .word 0 + .word 0 + .word 20994 + .word 64556 + .word 3828 + .word 0 + .word 0 + .word 0 + .word 16252 + .word 60661 + .word 3796 + .word 0 + .word 0 + .word 0 + .word 61252 + .word 65021 + .word 3765 + .word 0 + .word 0 + .word 0 + .word 16236 + .word 43803 + .word 3734 + .word 0 + .word 0 + .word 0 + .word 63064 + .word 35308 + .word 3702 + .word 0 + .word 0 + .word 0 + .word 49096 + .word 39848 + .word 3673 + .word 0 + .word 0 + .word 0 + .word 15680 + .word 48673 + .word 3642 + .word 0 + .word 0 + .word 0 + .word 48068 + .word 50957 + .word 3611 + .word 0 + .word 0 + .word 0 + .word 20824 + .word 56086 + .word 3579 + .word 0 + .word 0 + .word 0 + .word 46504 + .word 43224 + .word 3549 + .word 0 + .word 0 + .word 0 + .word 52428 + .word 46094 + .word 3517 + .word 0 + .word 0 + .word 0 + .word 17548 + .word 52066 + .word 3487 + .word 0 + .word 0 + .word 0 + .word 61738 + .word 35565 + .word 3456 + .word 0 + .word 0 + .word 0 + .word 31184 + .word 50588 + .word 3424 + .word 0 + .word 0 + .word 0 + .word 1716 + .word 52681 + .word 3394 + .word 0 + .word 0 + .word 0 + .word 44656 + .word 43385 + .word 3363 + .word 0 + .word 0 + .word 0 + .word 12668 + .word 43259 + .word 3331 + .word 0 + .word 0 + .word 0 + .word 24544 + .word 35408 + .word 3298 + .word 0 + .word 0 + .word 0 + .word 28854 + .word 65018 + .word 3270 + .word 0 + .word 0 + .word 0 + .word 5696 + .word 40391 + .word 3238 + .word 0 + .word 0 + .word 0 + .word 39580 + .word 56400 + .word 3208 + .word 0 + .word 0 + .word 0 + .word 20428 + .word 39579 + .word 3177 + .word 0 + .word 0 + .word 0 + .word 32328 + .word 36727 + .word 3146 + .word 0 + .word 0 + .word 0 + .word 34020 + .word 54457 + .word 3115 + .word 0 + .word 0 + .word 0 + .word 34016 + .word 48400 + .word 3083 + .word 0 + .word 0 + .word 0 + .word 6922 + .word 51417 + .word 3053 + .word 0 + .word 0 + .word 0 + .word 27208 + .word 64641 + .word 3021 + .word 0 + .word 0 + .word 0 + .word 1802 + .word 48886 + .word 2991 + .word 0 + .word 0 + .word 0 + .word 35440 + .word 61590 + .word 2960 + .word 0 + .word 0 + .word 0 + .word 60610 + .word 51604 + .word 2929 + .word 0 + .word 0 + .word 0 + .word 5440 + .word 38199 + .word 2895 + .word 0 + .word 0 + .word 0 + .word 6914 + .word 43867 + .word 2867 + .word 0 + .word 0 + .word 0 + .word 24000 + .word 45256 + .word 2834 + .word 0 + .word 0 + .word 0 + .word 51496 + .word 57396 + .word 2804 + .word 0 + .word 0 + .word 0 + .word 11538 + .word 46256 + .word 2774 + .word 0 + .word 0 + .word 0 + .word 36802 + .word 48020 + .word 2743 + .word 0 + .word 0 + .word 0 + .word 57910 + .word 57903 + .word 2712 + .word 0 + .word 0 + .word 0 + .word 47484 + .word 48798 + .word 2680 + .word 0 + .word 0 + .word 0 + .word 57766 + .word 57709 + .word 2650 + .word 0 + .word 0 + .word 0 + .word 54064 + .word 47856 + .word 2619 + .word 0 + .word 0 + .word 0 + .word 49340 + .word 48080 + .word 2588 + .word 0 + .word 0 + .word 0 + .word 36454 + .word 56731 + .word 2557 + .word 0 + .word 0 + .word 0 + .word 51548 + .word 63385 + .word 2526 + .word 0 + .word 0 + .word 0 + .word 56000 + .word 48716 + .word 2490 + .word 0 + .word 0 + .word 0 + .word 44992 + .word 50040 + .word 2460 + .word 0 + .word 0 + .word 0 + .word 43136 + .word 58177 + .word 2430 + .word 0 + .word 0 + .word 0 + .word 49730 + .word 33270 + .word 2402 + .word 0 + .word 0 + .word 0 + .word 29808 + .word 51063 + .word 2371 + .word 0 + .word 0 + .word 0 + .word 25276 + .word 46724 + .word 2339 + .word 0 + .word 0 + .word 0 + .word 17324 + .word 35928 + .word 2308 + .word 0 + .word 0 + .word 0 + .word 52284 + .word 63916 + .word 2278 + .word 0 + .word 0 + .word 0 + .word 5414 + .word 46704 + .word 2247 + .word 0 + .word 0 + .word 0 + .word 51710 + .word 57168 + .word 2216 + .word 0 + .word 0 + .word 0 + .word 27366 + .word 49253 + .word 2185 + .word 0 + .word 0 + .word 0 + .word 45332 + .word 53033 + .word 2154 + .word 0 + .word 0 + .word 0 + .word 54152 + .word 37418 + .word 2121 + .word 0 + .word 0 + .word 0 + .word 53076 + .word 47398 + .word 2092 + .word 0 + .word 0 + .word 0 + .word 14374 + .word 59477 + .word 2061 + .word 0 + .word 0 + .word 0 + .word 59336 + .word 33435 + .word 2029 + .word 0 + .word 0 + .word 0 + .word 21612 + .word 43267 + .word 1999 + .word 0 + .word 0 + .word 0 + .word 34664 + .word 39372 + .word 1966 + .word 0 + .word 0 + .word 0 + .word 172 + .word 62761 + .word 1936 + .word 0 + .word 0 + .word 0 + .word 9816 + .word 40715 + .word 1905 + .word 0 + .word 0 + .word 0 + .word 65116 + .word 40481 + .word 1875 + .word 0 + .word 0 + .word 0 + .word 28066 + .word 39184 + .word 1844 + .word 0 + .word 0 + .word 0 + .word 37408 + .word 63923 + .word 1813 + .word 0 + .word 0 + .word 0 + .word 15760 + .word 42305 + .word 1782 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 59340 + .word 1750 + .word 0 + .word 0 + .word 0 + .word 43258 + .word 59402 + .word 1720 + .word 0 + .word 0 + .word 0 + .word 19988 + .word 50087 + .word 1689 + .word 0 + .word 0 + .word 0 + .word 63456 + .word 47833 + .word 1655 + .word 0 + .word 0 + .word 0 + .word 65184 + .word 61426 + .word 1626 + .word 0 + .word 0 + .word 0 + .word 52982 + .word 48456 + .word 1596 + .word 0 + .word 0 + .word 0 + .word 30020 + .word 62809 + .word 1564 + .word 0 + .word 0 + .word 0 + .word 9096 + .word 63061 + .word 1533 + .word 0 + .word 0 + .word 0 + .word 59648 + .word 44374 + .word 1499 + .word 0 + .word 0 + .word 0 + .word 11456 + .word 33847 + .word 1470 + .word 0 + .word 0 + .word 0 + .word 12392 + .word 50500 + .word 1440 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 59196 + .word 1408 + .word 0 + .word 0 + .word 0 + .word 61008 + .word 40265 + .word 1377 + .word 0 + .word 0 + .word 0 + .word 37842 + .word 33270 + .word 1348 + .word 0 + .word 0 + .word 0 + .word 37916 + .word 44543 + .word 1316 + .word 0 + .word 0 + .word 0 + .word 11490 + .word 36421 + .word 1286 + .word 0 + .word 0 + .word 0 + .word 19040 + .word 38397 + .word 1254 + .word 0 + .word 0 + .word 0 + .word 31224 + .word 47162 + .word 1224 + .word 0 + .word 0 + .word 0 + .word 52056 + .word 41461 + .word 1192 + .word 0 + .word 0 + .word 0 + .word 10810 + .word 56374 + .word 1162 + .word 0 + .word 0 + .word 0 + .word 5358 + .word 35086 + .word 1131 + .word 0 + .word 0 + .word 0 + .word 36640 + .word 50226 + .word 1096 + .word 0 + .word 0 + .word 0 + .word 33856 + .word 45597 + .word 1067 + .word 0 + .word 0 + .word 0 + .word 21552 + .word 63128 + .word 1036 + .word 0 + .word 0 + .word 0 + .word 1198 + .word 35616 + .word 1007 + .word 0 + .word 0 + .word 0 + .word 1232 + .word 59506 + .word 976 + .word 0 + .word 0 + .word 0 + .word 51086 + .word 34963 + .word 945 + .word 0 + .word 0 + .word 0 + .word 3960 + .word 39061 + .word 912 + .word 0 + .word 0 + .word 0 + .word 4564 + .word 57134 + .word 882 + .word 0 + .word 0 + .word 0 + .word 59468 + .word 35285 + .word 852 + .word 0 + .word 0 + .word 0 + .word 63422 + .word 35431 + .word 821 + .word 0 + .word 0 + .word 0 + .word 38352 + .word 51462 + .word 790 + .word 0 + .word 0 + .word 0 + .word 25806 + .word 55660 + .word 759 + .word 0 + .word 0 + .word 0 + .word 38842 + .word 41327 + .word 728 + .word 0 + .word 0 + .word 0 + .word 17980 + .word 50458 + .word 697 + .word 0 + .word 0 + .word 0 + .word 61194 + .word 59710 + .word 666 + .word 0 + .word 0 + .word 0 + .word 21098 + .word 42086 + .word 635 + .word 0 + .word 0 + .word 0 + .word 16704 + .word 43341 + .word 602 + .word 0 + .word 0 + .word 0 + .word 46316 + .word 52840 + .word 573 + .word 0 + .word 0 + .word 0 + .word 20386 + .word 33936 + .word 542 + .word 0 + .word 0 + .word 0 + .word 20064 + .word 51864 + .word 509 + .word 0 + .word 0 + .word 0 + .word 2268 + .word 57500 + .word 479 + .word 0 + .word 0 + .word 0 + .word 11152 + .word 51171 + .word 449 + .word 0 + .word 0 + .word 0 + .word 23164 + .word 63727 + .word 417 + .word 0 + .word 0 + .word 0 + .word 20514 + .word 40280 + .word 387 + .word 0 + .word 0 + .word 0 + .word 21818 + .word 57922 + .word 356 + .word 0 + .word 0 + .word 0 + .word 32366 + .word 46413 + .word 325 + .word 0 + .word 0 + .word 0 + .word 53972 + .word 43148 + .word 294 + .word 0 + .word 0 + .word 0 + .word 30134 + .word 65133 + .word 263 + .word 0 + .word 0 + .word 0 + .word 15282 + .word 61516 + .word 232 + .word 0 + .word 0 + .word 0 + .word 49872 + .word 49222 + .word 200 + .word 0 + .word 0 + .word 0 + .word 9484 + .word 63958 + .word 170 + .word 0 + .word 0 + .word 0 + .word 47028 + .word 35341 + .word 139 + .word 0 + .word 0 + .word 0 + .word 6770 + .word 58613 + .word 108 + .word 0 + .word 0 + .word 0 + .word 33372 + .word 43448 + .word 77 + .word 0 + .word 0 + .word 0 + .word 27792 + .word 51629 + .word 43 + .word 0 + .word 0 + .word 0 + .word 19712 + .word 53691 + .word 15 + .word 0 + .type _4OPI,@object + .size _4OPI,6384 + .align 2 +_ADDING: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16446 + .word 0 + .type _ADDING,@object + .size _ADDING,12 + .align 2 +_nonel_value: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .type _nonel_value,@object + .size _nonel_value,12 + .align 2 +_PC: + .word 23996 + .word 61276 + .word 60076 + .word 54715 + .word 16338 + .word 0 + .word 29541 + .word 45883 + .word 23690 + .word 51658 + .word 49114 + .word 0 + .word 41007 + .word 30189 + .word 50933 + .word 36726 + .word 16354 + .word 0 + .word 11013 + .word 35124 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 13032 + .word 3304 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 45630 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .type _PC,@object + .size _PC,96 + .align 2 +_ponel_value: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _ponel_value,@object + .size _ponel_value,12 + .align 2 +_PS: + .word 25 + .word 22807 + .word 53737 + .word 51452 + .word 16334 + .word 0 + .word 54536 + .word 42444 + .word 58524 + .word 55101 + .word 49110 + .word 0 + .word 63911 + .word 27722 + .word 12213 + .word 45202 + .word 16350 + .word 0 + .word 3718 + .word 18986 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 10480 + .word 46680 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 12958 + .word 3329 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 35030 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .type _PS,@object + .size _PS,96 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sincos_wmt.S b/external/sgx_libm/ia32/sincos_wmt.S new file mode 100644 index 0000000000..6807fe1cfa --- /dev/null +++ b/external/sgx_libm/ia32/sincos_wmt.S @@ -0,0 +1,1343 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincos_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin sincos + .text + .align 16,0x90 + .globl sincos +sincos: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 20 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $168, %esp + movl %ebx, 112(%esp) + call static_func + movl %eax, %ebx + movsd 176(%esp), %xmm0 + movl 184(%esp), %eax + movl %eax, 32(%esp) + movl 188(%esp), %eax + movl %eax, 36(%esp) + stmxcsr 64(%esp) + movl 64(%esp), %edx + andl $-24577, %edx + cmpl %edx, 64(%esp) + jne .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + pextrw $3, %xmm0, %eax + andl $32767, %eax + subl $12336, %eax + cmpl $4293, %eax + ja .L_2TAG_PACKET_2.0.2 + unpcklpd %xmm0, %xmm0 + movapd 4160(%ebx), %xmm1 + mulpd %xmm0, %xmm1 + movapd 4176(%ebx), %xmm2 + cvtsd2si %xmm1, %edx + addpd %xmm2, %xmm1 + movapd 4192(%ebx), %xmm3 + subpd %xmm2, %xmm1 + movapd 4208(%ebx), %xmm2 + mulpd %xmm1, %xmm3 + addl $1865216, %edx + movapd %xmm0, %xmm4 + andl $63, %edx + movapd 4144(%ebx), %xmm5 + lea (%ebx), %eax + shll $6, %edx + addl %edx, %eax + mulpd %xmm1, %xmm2 + subpd %xmm3, %xmm0 + mulpd 4224(%ebx), %xmm1 + subpd %xmm3, %xmm4 + movapd 16(%eax), %xmm7 + movapd %xmm4, %xmm3 + subpd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + movapd 4112(%ebx), %xmm6 + mulpd %xmm4, %xmm7 + subpd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subpd %xmm2, %xmm3 + movapd (%eax), %xmm2 + subpd %xmm3, %xmm1 + movapd 48(%eax), %xmm3 + addpd %xmm3, %xmm2 + subpd %xmm2, %xmm7 + mulpd %xmm7, %xmm1 + movapd 16(%eax), %xmm7 + mulpd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulpd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm7 + mulpd %xmm0, %xmm0 + addpd 4128(%ebx), %xmm5 + mulpd (%eax), %xmm4 + addpd 4096(%ebx), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, %xmm0 + addpd 16(%eax), %xmm3 + addpd %xmm5, %xmm6 + movapd %xmm6, %xmm5 + unpckhpd %xmm6, %xmm6 + unpcklpd %xmm5, %xmm5 + mulpd %xmm7, %xmm6 + mulpd %xmm5, %xmm2 + movapd %xmm4, %xmm7 + addpd %xmm3, %xmm4 + movapd 16(%eax), %xmm5 + subpd %xmm3, %xmm5 + subpd %xmm4, %xmm3 + addpd 32(%eax), %xmm1 + addpd %xmm0, %xmm5 + addpd %xmm7, %xmm3 + addpd %xmm5, %xmm1 + addpd %xmm3, %xmm1 + addpd %xmm2, %xmm1 + addpd %xmm6, %xmm1 + movl 64(%esp), %edx + andl $-24577, %edx + cmpl 64(%esp), %edx + je .L_2TAG_PACKET_3.0.2 + stmxcsr 72(%esp) + movl 64(%esp), %edx + andl $24576, %edx + orl %edx, 72(%esp) + ldmxcsr 72(%esp) +.L_2TAG_PACKET_3.0.2: + addpd %xmm4, %xmm1 + movapd %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + movl 32(%esp), %eax + movsd %xmm0, (%eax) + movl 36(%esp), %eax + movsd %xmm1, (%eax) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_2.0.2: + jg .L_2TAG_PACKET_5.0.2 + movapd %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orl $32768, %eax + pinsrw $3, %eax, %xmm1 + movl 64(%esp), %edx + andl $-24577, %edx + cmpl 64(%esp), %edx + je .L_2TAG_PACKET_6.0.2 + stmxcsr 72(%esp) + movl 64(%esp), %edx + andl $24576, %edx + orl %edx, 72(%esp) + ldmxcsr 72(%esp) +.L_2TAG_PACKET_6.0.2: + addsd 4288(%ebx), %xmm1 + cmpl $32784, %eax + jge .L_2TAG_PACKET_7.0.2 + mulsd 4272(%ebx), %xmm0 + movl 32(%esp), %eax + movsd %xmm0, (%eax) + movl 36(%esp), %eax + movsd %xmm1, (%eax) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_7.0.2: + movsd 4240(%ebx), %xmm3 + mulsd %xmm0, %xmm3 + subsd %xmm0, %xmm3 + movsd 4256(%ebx), %xmm0 + mulsd %xmm3, %xmm0 + movl 32(%esp), %eax + movsd %xmm0, (%eax) + movl 36(%esp), %eax + movsd %xmm1, (%eax) + jmp .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_0.0.2: + movl 64(%esp), %edx + andl $-24577, %edx + movl %edx, 72(%esp) + ldmxcsr 72(%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_5.0.2: + subl $32, %esp + movsd %xmm0, (%esp) + lea 80(%esp), %eax + movl %eax, 8(%esp) + movl $3, %eax + movl %eax, 12(%esp) + call __libm_sincos_huge + addl $32, %esp + movq 56(%esp), %xmm0 + movq 48(%esp), %xmm1 + movl 32(%esp), %eax + movl 36(%esp), %edx + movq %xmm0, (%eax) + movq %xmm1, (%edx) +.L_2TAG_PACKET_8.0.2: + movl 64(%esp), %edx + andl $-24577, %edx + cmpl 64(%esp), %edx + je .L_2TAG_PACKET_4.0.2 + stmxcsr 72(%esp) + movl 64(%esp), %edx + andl $24576, %edx + orl %edx, 72(%esp) + ldmxcsr 72(%esp) +.L_2TAG_PACKET_4.0.2: + movl 112(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type sincos,@function + .size sincos,.-sincos + .data +# -- End sincos + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 3217031168 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 3220176896 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 1069547520 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 1071644672 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 1072693248 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 1069547520 + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .long 1841940611 + .long 1076125488 + .long 1841940611 + .long 1076125488 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 1413480448 + .long 1069097467 + .long 1413480448 + .long 1069097467 + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .long 771977331 + .long 996350346 + .long 771977331 + .long 996350346 + .long 0 + .long 1130364928 + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .long 0 + .long 1015021568 + .long 4294967295 + .long 1072693247 + .long 4294967295 + .long 1072693247 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .type static_const_table,@object + .size static_const_table,4304 + .data + .hidden __libm_sincos_huge + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sincosdl_table.S b/external/sgx_libm/ia32/sincosdl_table.S new file mode 100644 index 0000000000..c9ef20a3e4 --- /dev/null +++ b/external/sgx_libm/ia32/sincosdl_table.S @@ -0,0 +1,768 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincosdl_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .hidden __libm_sindl_cosdl_table + .globl __libm_sindl_cosdl_table +__libm_sindl_cosdl_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 730455326 + .long 1066524427 + .long 1746175880 + .long 1010139981 + .long 2549460874 + .long 1072692928 + .long 4286585365 + .long 3162605893 + .long 3388464167 + .long 1067572824 + .long 3405773388 + .long 1011262106 + .long 2025784679 + .long 1072691970 + .long 3458349249 + .long 3162669794 + .long 1223674126 + .long 1068157895 + .long 1350368814 + .long 3158420169 + .long 3977438749 + .long 1072690373 + .long 2138672104 + .long 1015504988 + .long 1835684136 + .long 1068620687 + .long 3698316769 + .long 3158223757 + .long 1903230966 + .long 1072688139 + .long 1549185311 + .long 1015860439 + .long 3099754755 + .long 1068912598 + .long 85775068 + .long 3160181596 + .long 3021477282 + .long 1072685267 + .long 1009168830 + .long 3161309439 + .long 2604423020 + .long 1069204064 + .long 2303648607 + .long 1009017464 + .long 2499307462 + .long 1072681759 + .long 1081812731 + .long 1015750919 + .long 1280271059 + .long 1069494996 + .long 1784430238 + .long 1012342196 + .long 631389835 + .long 1072677616 + .long 319889322 + .long 1015931913 + .long 2525863449 + .long 1069666412 + .long 3319430370 + .long 1012720668 + .long 2838533242 + .long 1072672838 + .long 3931096191 + .long 3163228296 + .long 1739084661 + .long 1069811211 + .long 266127812 + .long 1005440081 + .long 2486166620 + .long 1072667428 + .long 1862034983 + .long 3163124964 + .long 2114679690 + .long 1069955610 + .long 1043937223 + .long 3160884320 + .long 2357271575 + .long 1072661387 + .long 1809738197 + .long 1015448300 + .long 3715523151 + .long 1070099565 + .long 3282620278 + .long 1013092107 + .long 1765324482 + .long 1072654717 + .long 2731192352 + .long 3162086677 + .long 2890029302 + .long 1070243033 + .long 2223107338 + .long 3159965253 + .long 846856320 + .long 1072647420 + .long 116450415 + .long 3163379753 + .long 919455349 + .long 1070385970 + .long 2064618035 + .long 3159935516 + .long 558794511 + .long 1072639498 + .long 1424282741 + .long 3161718678 + .long 4075075869 + .long 1070528331 + .long 3748620424 + .long 3160490968 + .long 2675554853 + .long 1072630953 + .long 3840651826 + .long 3156703495 + .long 3247638160 + .long 1070633085 + .long 3696489768 + .long 1014652612 + .long 1195949845 + .long 1072621789 + .long 1259393923 + .long 3162332067 + .long 3711077929 + .long 1070703626 + .long 3146917124 + .long 1014611084 + .long 3814620032 + .long 1072612007 + .long 3070837564 + .long 3162674392 + .long 3481523655 + .long 1070773815 + .long 2713761655 + .long 1014001377 + .long 1853610783 + .long 1072601612 + .long 3649998803 + .long 1015704482 + .long 925886800 + .long 1070843631 + .long 436010265 + .long 3162460259 + .long 323245311 + .long 1072590606 + .long 3093873492 + .long 1015519453 + .long 3489713627 + .long 1070913051 + .long 528334979 + .long 1014764117 + .long 738112715 + .long 1072578992 + .long 334349375 + .long 3162809522 + .long 1955204085 + .long 1070982056 + .long 1689242582 + .long 1014445850 + .long 1112681756 + .long 1072566774 + .long 1734695380 + .long 3163113281 + .long 533648188 + .long 1071050624 + .long 3960375553 + .long 1012377538 + .long 251639813 + .long 1072553956 + .long 3380683078 + .long 1012638586 + .long 4008023681 + .long 1071118733 + .long 570275026 + .long 1014484594 + .long 2039991128 + .long 1072540541 + .long 1062999797 + .long 3162182390 + .long 580452267 + .long 1071186365 + .long 3449718872 + .long 3161633148 + .long 2553046639 + .long 1072526534 + .long 2419472295 + .long 3163244343 + .long 554048209 + .long 1071253497 + .long 2399772791 + .long 3156410517 + .long 2935979925 + .long 1072511939 + .long 1428602113 + .long 1015064920 + .long 2000132179 + .long 1071320109 + .long 2171125689 + .long 3159852223 + .long 808310631 + .long 1072496761 + .long 4227501583 + .long 1014931887 + .long 3669886408 + .long 1071386181 + .long 3536165134 + .long 1013933230 + .long 3142990026 + .long 1072481003 + .long 4101727212 + .long 3163150444 + .long 725933569 + .long 1071451694 + .long 522349177 + .long 3161311953 + .long 490548333 + .long 1072464672 + .long 2395907389 + .long 3162833649 + .long 1948536952 + .long 1071516626 + .long 320619183 + .long 1014863857 + .long 1332553480 + .long 1072447771 + .long 3321840403 + .long 3163208850 + .long 3991904492 + .long 1071580958 + .long 2374541978 + .long 1014892768 + .long 2010331591 + .long 1072430306 + .long 1428309641 + .long 3163418034 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .long 3898100906 + .long 1072412282 + .long 3501572579 + .long 1015868565 + .long 553508627 + .long 1071676209 + .long 3116078237 + .long 1016033865 + .long 511109854 + .long 1072393706 + .long 3227708102 + .long 3163199948 + .long 1051516202 + .long 1071707417 + .long 2823792103 + .long 1015984420 + .long 3268258117 + .long 1072374581 + .long 893580578 + .long 1013933326 + .long 3614471965 + .long 1071738286 + .long 2346555295 + .long 3158494963 + .long 2829987804 + .long 1072354915 + .long 4086147764 + .long 3161968777 + .long 2215771410 + .long 1071768808 + .long 2812627676 + .long 1015346091 + .long 3450400421 + .long 1072334713 + .long 2241324349 + .long 3163087632 + .long 4168894840 + .long 1071798972 + .long 555969416 + .long 1015775320 + .long 1494583111 + .long 1072313982 + .long 92043893 + .long 3160700658 + .long 74799710 + .long 1071828771 + .long 2770520589 + .long 3160558553 + .long 2610427048 + .long 1072292727 + .long 436010265 + .long 3162460259 + .long 2488647350 + .long 1071858193 + .long 3884027735 + .long 1013773085 + .long 245529108 + .long 1072270956 + .long 3304882442 + .long 1014213155 + .long 2982005049 + .long 1071887231 + .long 3980032926 + .long 3161177863 + .long 1408525265 + .long 1072248674 + .long 1201054953 + .long 1015994881 + .long 2219342526 + .long 1071915876 + .long 3430823751 + .long 3163318748 + .long 890610472 + .long 1072225889 + .long 1982309908 + .long 3162056199 + .long 1379669533 + .long 1071944119 + .long 3329850390 + .long 3162839200 + .long 2731495481 + .long 1072202607 + .long 1347545148 + .long 1014567853 + .long 2167951316 + .long 1071971951 + .long 2070879930 + .long 1013227818 + .long 3030457399 + .long 1072178836 + .long 162525240 + .long 3161624810 + .long 2531396568 + .long 1071999364 + .long 4091857862 + .long 3162202094 + .long 2821963458 + .long 1072154583 + .long 1545337900 + .long 3160735078 + .long 965516331 + .long 1072026350 + .long 156922899 + .long 1014731144 + .long 3771230594 + .long 1072129855 + .long 3521184819 + .long 1014696396 + .long 820015888 + .long 1072052900 + .long 2191736501 + .long 1015202773 + .long 3869592889 + .long 1072104660 + .long 2133682458 + .long 3163440098 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 3869592889 + .long 1072104660 + .long 2133682458 + .long 3163440098 + .long 820015888 + .long 1072052900 + .long 2191736501 + .long 1015202773 + .long 3771230594 + .long 1072129855 + .long 3521184819 + .long 1014696396 + .long 965516331 + .long 1072026350 + .long 156922899 + .long 1014731144 + .long 2821963458 + .long 1072154583 + .long 1545337900 + .long 3160735078 + .long 2531396568 + .long 1071999364 + .long 4091857862 + .long 3162202094 + .long 3030457399 + .long 1072178836 + .long 162525240 + .long 3161624810 + .long 2167951316 + .long 1071971951 + .long 2070879930 + .long 1013227818 + .long 2731495481 + .long 1072202607 + .long 1347545148 + .long 1014567853 + .long 1379669533 + .long 1071944119 + .long 3329850390 + .long 3162839200 + .long 890610472 + .long 1072225889 + .long 1982309908 + .long 3162056199 + .long 2219342526 + .long 1071915876 + .long 3430823751 + .long 3163318748 + .long 1408525265 + .long 1072248674 + .long 1201054953 + .long 1015994881 + .long 2982005049 + .long 1071887231 + .long 3980032926 + .long 3161177863 + .long 245529108 + .long 1072270956 + .long 3304882442 + .long 1014213155 + .long 2488647350 + .long 1071858193 + .long 3884027735 + .long 1013773085 + .long 2610427048 + .long 1072292727 + .long 436010265 + .long 3162460259 + .long 74799710 + .long 1071828771 + .long 2770520589 + .long 3160558553 + .long 1494583111 + .long 1072313982 + .long 92043893 + .long 3160700658 + .long 4168894840 + .long 1071798972 + .long 555969416 + .long 1015775320 + .long 3450400421 + .long 1072334713 + .long 2241324349 + .long 3163087632 + .long 2215771410 + .long 1071768808 + .long 2812627676 + .long 1015346091 + .long 2829987804 + .long 1072354915 + .long 4086147764 + .long 3161968777 + .long 3614471965 + .long 1071738286 + .long 2346555295 + .long 3158494963 + .long 3268258117 + .long 1072374581 + .long 893580578 + .long 1013933326 + .long 1051516202 + .long 1071707417 + .long 2823792103 + .long 1015984420 + .long 511109854 + .long 1072393706 + .long 3227708102 + .long 3163199948 + .long 553508627 + .long 1071676209 + .long 3116078237 + .long 1016033865 + .long 3898100906 + .long 1072412282 + .long 3501572579 + .long 1015868565 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .long 2010331591 + .long 1072430306 + .long 1428309641 + .long 3163418034 + .long 3991904492 + .long 1071580958 + .long 2374541978 + .long 1014892768 + .long 1332553480 + .long 1072447771 + .long 3321840403 + .long 3163208850 + .long 1948536952 + .long 1071516626 + .long 320619183 + .long 1014863857 + .long 490548333 + .long 1072464672 + .long 2395907389 + .long 3162833649 + .long 725933569 + .long 1071451694 + .long 522349177 + .long 3161311953 + .long 3142990026 + .long 1072481003 + .long 4101727212 + .long 3163150444 + .long 3669886408 + .long 1071386181 + .long 3536165134 + .long 1013933230 + .long 808310631 + .long 1072496761 + .long 4227501583 + .long 1014931887 + .long 2000132179 + .long 1071320109 + .long 2171125689 + .long 3159852223 + .long 2935979925 + .long 1072511939 + .long 1428602113 + .long 1015064920 + .long 554048209 + .long 1071253497 + .long 2399772791 + .long 3156410517 + .long 2553046639 + .long 1072526534 + .long 2419472295 + .long 3163244343 + .long 580452267 + .long 1071186365 + .long 3449718872 + .long 3161633148 + .long 2039991128 + .long 1072540541 + .long 1062999797 + .long 3162182390 + .long 4008023681 + .long 1071118733 + .long 570275026 + .long 1014484594 + .long 251639813 + .long 1072553956 + .long 3380683078 + .long 1012638586 + .long 533648188 + .long 1071050624 + .long 3960375553 + .long 1012377538 + .long 1112681756 + .long 1072566774 + .long 1734695380 + .long 3163113281 + .long 1955204085 + .long 1070982056 + .long 1689242582 + .long 1014445850 + .long 738112715 + .long 1072578992 + .long 334349375 + .long 3162809522 + .long 3489713627 + .long 1070913051 + .long 528334979 + .long 1014764117 + .long 323245311 + .long 1072590606 + .long 3093873492 + .long 1015519453 + .long 925886800 + .long 1070843631 + .long 436010265 + .long 3162460259 + .long 1853610783 + .long 1072601612 + .long 3649998803 + .long 1015704482 + .long 3481523655 + .long 1070773815 + .long 2713761655 + .long 1014001377 + .long 3814620032 + .long 1072612007 + .long 3070837564 + .long 3162674392 + .long 3711077929 + .long 1070703626 + .long 3146917124 + .long 1014611084 + .long 1195949845 + .long 1072621789 + .long 1259393923 + .long 3162332067 + .long 3247638160 + .long 1070633085 + .long 3696489768 + .long 1014652612 + .long 2675554853 + .long 1072630953 + .long 3840651826 + .long 3156703495 + .long 4075075869 + .long 1070528331 + .long 3748620424 + .long 3160490968 + .long 558794511 + .long 1072639498 + .long 1424282741 + .long 3161718678 + .long 919455349 + .long 1070385970 + .long 2064618035 + .long 3159935516 + .long 846856320 + .long 1072647420 + .long 116450415 + .long 3163379753 + .long 2890029302 + .long 1070243033 + .long 2223107338 + .long 3159965253 + .long 1765324482 + .long 1072654717 + .long 2731192352 + .long 3162086677 + .long 3715523151 + .long 1070099565 + .long 3282620278 + .long 1013092107 + .long 2357271575 + .long 1072661387 + .long 1809738197 + .long 1015448300 + .long 2114679690 + .long 1069955610 + .long 1043937223 + .long 3160884320 + .long 2486166620 + .long 1072667428 + .long 1862034983 + .long 3163124964 + .long 1739084661 + .long 1069811211 + .long 266127812 + .long 1005440081 + .long 2838533242 + .long 1072672838 + .long 3931096191 + .long 3163228296 + .long 2525863449 + .long 1069666412 + .long 3319430370 + .long 1012720668 + .long 631389835 + .long 1072677616 + .long 319889322 + .long 1015931913 + .long 1280271059 + .long 1069494996 + .long 1784430238 + .long 1012342196 + .long 2499307462 + .long 1072681759 + .long 1081812731 + .long 1015750919 + .long 2604423020 + .long 1069204064 + .long 2303648607 + .long 1009017464 + .long 3021477282 + .long 1072685267 + .long 1009168830 + .long 3161309439 + .long 3099754755 + .long 1068912598 + .long 85775068 + .long 3160181596 + .long 1903230966 + .long 1072688139 + .long 1549185311 + .long 1015860439 + .long 1835684136 + .long 1068620687 + .long 3698316769 + .long 3158223757 + .long 3977438749 + .long 1072690373 + .long 2138672104 + .long 1015504988 + .long 1223674126 + .long 1068157895 + .long 1350368814 + .long 3158420169 + .long 2025784679 + .long 1072691970 + .long 3458349249 + .long 3162669794 + .long 3388464167 + .long 1067572824 + .long 3405773388 + .long 1011262106 + .long 2549460874 + .long 1072692928 + .long 4286585365 + .long 3162605893 + .long 730455326 + .long 1066524427 + .long 1746175880 + .long 1010139981 + .type __libm_sindl_cosdl_table,@object + .size __libm_sindl_cosdl_table,2880 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sincosf_wmt.S b/external/sgx_libm/ia32/sincosf_wmt.S new file mode 100644 index 0000000000..e9e8131d55 --- /dev/null +++ b/external/sgx_libm/ia32/sincosf_wmt.S @@ -0,0 +1,576 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincosf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin sincosf + .text + .align 16,0x90 + .globl sincosf +sincosf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +# parameter 3: 16 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $136, %esp + movl %ebx, 80(%esp) + call static_func + movl %eax, %ebx + movss 144(%esp), %xmm0 + movl 144(%esp), %ecx + movl 148(%esp), %eax + movl %eax, 32(%esp) + movl 152(%esp), %eax + movl %eax, 36(%esp) + movaps %xmm0, %xmm1 + cvtps2pd %xmm1, %xmm1 + movsd 1360(%ebx), %xmm2 + movl $2147483647, %eax + movl $1241513983, %edx + andl %ecx, %eax + subl %eax, %edx + subl $964689920, %eax + orl %eax, %edx + jl .L_2TAG_PACKET_0.0.2 + movsd 1376(%ebx), %xmm4 + mulsd %xmm1, %xmm2 + movsd 1392(%ebx), %xmm3 + movapd %xmm2, %xmm5 + addsd %xmm4, %xmm2 + movd %xmm2, %ecx + subsd %xmm4, %xmm2 + mulsd %xmm3, %xmm1 +.L_2TAG_PACKET_1.0.2: + movl $256, %eax + movapd 1040(%ebx), %xmm4 + subsd %xmm2, %xmm5 + addl %ecx, %ecx + movl %ecx, %edx + shll $24, %ecx + sarl $31, %ecx + andl %edx, %eax + addl %ecx, %edx + xorl %ecx, %edx + addsd %xmm5, %xmm1 + movsd 1440(%ebx), %xmm6 + andl $254, %edx + movapd (%ebx,%edx,8), %xmm3 + pshufd $68, %xmm1, %xmm2 + shrl $4, %eax + movapd 1072(%ebx,%eax), %xmm7 + movapd 1056(%ebx), %xmm5 + mulpd %xmm2, %xmm2 + mulsd %xmm6, %xmm1 + andl $1, %ecx + movd %ecx, %xmm0 + psllq $63, %xmm0 + xorpd %xmm0, %xmm3 + xorpd %xmm7, %xmm3 + mulpd %xmm4, %xmm2 + pshufd $78, %xmm3, %xmm6 + mulsd %xmm1, %xmm3 + addpd %xmm2, %xmm5 + mulsd %xmm1, %xmm6 + mulpd %xmm5, %xmm3 + mulpd %xmm5, %xmm6 + pshufd $238, %xmm3, %xmm0 + pshufd $238, %xmm6, %xmm1 + addsd %xmm3, %xmm0 + subsd %xmm6, %xmm1 + cvtpd2ps %xmm0, %xmm0 + cvtpd2ps %xmm1, %xmm1 + movl 32(%esp), %eax + movss %xmm0, (%eax) + movl 36(%esp), %edx + movss %xmm1, (%edx) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_0.0.2: + andl $2147483647, %ecx + cmpl $1040187392, %ecx + ja .L_2TAG_PACKET_3.0.2 + cvtss2sd %xmm0, %xmm0 + mulsd 1344(%ebx), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movl 32(%esp), %eax + movss %xmm0, (%eax) + movl 36(%esp), %edx + movl $1065353216, %ecx + movl %ecx, (%edx) + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_3.0.2: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_4.0.2 + shrl $23, %ecx + subl $142, %ecx + andl $65528, %ecx + movsd 1104(%ebx,%ecx,2), %xmm3 + movsd 1112(%ebx,%ecx,2), %xmm5 + movsd 1424(%ebx), %xmm2 + xorpd %xmm4, %xmm4 + movl $17208, %eax + pinsrw $3, %eax, %xmm4 + andpd %xmm3, %xmm2 + psllq $40, %xmm3 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + movapd %xmm2, %xmm0 + addsd %xmm3, %xmm2 + movapd %xmm2, %xmm5 + subsd %xmm2, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm0, %xmm3 + movd %xmm2, %ecx + subsd %xmm4, %xmm2 + addsd %xmm3, %xmm1 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_4.0.2: + subss %xmm0, %xmm0 + movl 32(%esp), %eax + movss %xmm0, (%eax) + movl 36(%esp), %edx + movss %xmm0, (%edx) +.L_2TAG_PACKET_2.0.2: + movl 80(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type sincosf,@function + .size sincosf,.-sincosf + .data +# -- End sincosf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1619315981 + .long 1072692616 + .long 4154680958 + .long 1067000149 + .long 3816385918 + .long 1072690721 + .long 4044216340 + .long 1068048229 + .long 2902558778 + .long 1072687565 + .long 2462980598 + .long 1068684576 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 1069094822 + .long 1893834707 + .long 1072677476 + .long 1453945614 + .long 1069504078 + .long 2131272983 + .long 1072670549 + .long 1854824762 + .long 1069729808 + .long 4201728937 + .long 1072662372 + .long 1149976518 + .long 1069933076 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 1070135480 + .long 2892293513 + .long 1072642291 + .long 1786662755 + .long 1070336898 + .long 4220661975 + .long 1072630398 + .long 2065784603 + .long 1070537209 + .long 3882371427 + .long 1072617280 + .long 1655830135 + .long 1070666194 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 1070765062 + .long 3964199186 + .long 1072587400 + .long 2484561409 + .long 1070863196 + .long 83265253 + .long 1072570657 + .long 1974149085 + .long 1070960538 + .long 3066872380 + .long 1072552723 + .long 821708191 + .long 1071057029 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 1071152610 + .long 3511535930 + .long 1072513332 + .long 1135144330 + .long 1071247225 + .long 4097623923 + .long 1072491898 + .long 165764288 + .long 1071340816 + .long 557060597 + .long 1072469323 + .long 2570175582 + .long 1071433326 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 1071524701 + .long 2892993834 + .long 1072420800 + .long 3690502842 + .long 1071614884 + .long 1159294526 + .long 1072394883 + .long 2569207790 + .long 1071674247 + .long 1477771776 + .long 1072367882 + .long 1411074851 + .long 1071718067 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 1071761211 + .long 2688952194 + .long 1072310695 + .long 1289556703 + .long 1071803653 + .long 1207142209 + .long 1072280544 + .long 4242632757 + .long 1071845367 + .long 1234330619 + .long 1072249378 + .long 689983673 + .long 1071886330 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 1071926515 + .long 201299822 + .long 1072184078 + .long 3152274921 + .long 1071965898 + .long 577417135 + .long 1072149983 + .long 881650848 + .long 1072004457 + .long 938475414 + .long 1072114952 + .long 1427975391 + .long 1072042167 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 1072079006 + .long 1427975391 + .long 1072042167 + .long 938475414 + .long 1072114952 + .long 881650848 + .long 1072004457 + .long 577417135 + .long 1072149983 + .long 3152274921 + .long 1071965898 + .long 201299822 + .long 1072184078 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 1072217216 + .long 689983673 + .long 1071886330 + .long 1234330619 + .long 1072249378 + .long 4242632757 + .long 1071845367 + .long 1207142209 + .long 1072280544 + .long 1289556703 + .long 1071803653 + .long 2688952194 + .long 1072310695 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 1072339814 + .long 1411074851 + .long 1071718067 + .long 1477771776 + .long 1072367882 + .long 2569207790 + .long 1071674247 + .long 1159294526 + .long 1072394883 + .long 3690502842 + .long 1071614884 + .long 2892993834 + .long 1072420800 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 1072445618 + .long 2570175582 + .long 1071433326 + .long 557060597 + .long 1072469323 + .long 165764288 + .long 1071340816 + .long 4097623923 + .long 1072491898 + .long 1135144330 + .long 1071247225 + .long 3511535930 + .long 1072513332 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 1072533611 + .long 821708191 + .long 1071057029 + .long 3066872380 + .long 1072552723 + .long 1974149085 + .long 1070960538 + .long 83265253 + .long 1072570657 + .long 2484561409 + .long 1070863196 + .long 3964199186 + .long 1072587400 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 1072602945 + .long 1655830135 + .long 1070666194 + .long 3882371427 + .long 1072617280 + .long 2065784603 + .long 1070537209 + .long 4220661975 + .long 1072630398 + .long 1786662755 + .long 1070336898 + .long 2892293513 + .long 1072642291 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 1072652951 + .long 1149976518 + .long 1069933076 + .long 4201728937 + .long 1072662372 + .long 1854824762 + .long 1069729808 + .long 2131272983 + .long 1072670549 + .long 1453945614 + .long 1069504078 + .long 1893834707 + .long 1072677476 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 1072683149 + .long 2462980598 + .long 1068684576 + .long 2902558778 + .long 1072687565 + .long 4044216340 + .long 1068048229 + .long 3816385918 + .long 1072690721 + .long 4154680958 + .long 1067000149 + .long 1619315981 + .long 1072692616 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 1649608659 + .long 3206173094 + .long 3384690142 + .long 3207839036 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1916669064 + .long 1072155675 + .long 660066805 + .long 1024797180 + .long 3829231700 + .long 1062745828 + .long 2884172442 + .long 1017445907 + .long 540874025 + .long 1055617650 + .long 4198409884 + .long 1011844330 + .long 2839315448 + .long 1046639136 + .long 4204424928 + .long 1000582120 + .long 1329339431 + .long 1038229673 + .long 1295478839 + .long 993391741 + .long 658191860 + .long 1024797180 + .long 3691886121 + .long 979325773 + .long 1966800710 + .long 1020436418 + .long 1882642597 + .long 977095991 + .long 2100977488 + .long 1012908661 + .long 1840335565 + .long 967470816 + .long 4198093645 + .long 1000582120 + .long 3307942521 + .long 957055414 + .long 2839123165 + .long 996851343 + .long 1387472776 + .long 952638316 + .long 2788761024 + .long 988712873 + .long 3005712498 + .long 944467026 + .long 3694676832 + .long 979325773 + .long 1326507024 + .long 934847846 + .long 221775557 + .long 970149340 + .long 1133527550 + .long 924162364 + .long 4286578688 + .long 1072693247 + .long 4286578688 + .long 1072693247 + .long 1845493760 + .long 1078222640 + .long 1845493760 + .long 1078222640 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 2908765579 + .long 3193641918 + .long 2908765579 + .long 3193641918 + .long 2308576600 + .long 1086551075 + .long 1646446368 + .long 1084878895 + .long 4278190080 + .long 4294967295 + .long 0 + .long 0 + .long 1413754136 + .long 1067000315 + .long 1413754136 + .long 1067000315 + .type static_const_table,@object + .size static_const_table,1456 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sincosl.S b/external/sgx_libm/ia32/sincosl.S new file mode 100644 index 0000000000..e5c71ee7ee --- /dev/null +++ b/external/sgx_libm/ia32/sincosl.S @@ -0,0 +1,1173 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincosl.c" + .text +..TXTST0: +# -- Begin sincosl + .text + .align 16,0x90 + .globl sincosl +sincosl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 24 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 144(%esp) + movl 20(%ebp), %edi + movl 24(%ebp), %esi +..B1.2: + fnstcw 62(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + movzwl 62(%esp), %edx + cmpl $16378, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jge ..B1.41 +..B1.4: + cmpl $16372, %eax + jge ..B1.33 +..B1.5: + cmpl $16364, %eax + jge ..B1.25 +..B1.6: + cmpl $16308, %eax + jge ..B1.17 +..B1.7: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.75 +..B1.8: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.9: + fldcw 60(%esp) +..B1.10: + movzwl 16(%ebp), %eax + movl $1, %edx + andl $32767, %eax +..B1.11: + testl %eax, %eax + jle ..B1.71 +..B1.12: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ebx) + fmul %st(1), %st + fsubp %st, %st(1) + fldt _small_value_80@GOTOFF(%ebx) + fsubrl _ones@GOTOFF(%ebx) + fstpt 32(%esp) + fmull 8+_TWO_75@GOTOFF(%ebx) + fstpt 16(%esp) +..B1.13: + testl %edx, %edx + je ..B1.15 +..B1.14: + fldcw 62(%esp) +..B1.15: + fldt 16(%esp) + fstpt (%edi) + fldt 32(%esp) + fstpt (%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.16: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.77 +..B1.18: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.19: + fldcw 60(%esp) +..B1.20: + movl $1, %eax +..B1.21: + fldt 8(%ebp) + testl %eax, %eax + fldt _SP3@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + fadd %st(1), %st + fstpt 16(%esp) + fldt _CP3@GOTOFF(%ebx) + fmul %st(1), %st + fmulp %st, %st(1) + faddl _ones@GOTOFF(%ebx) + fstpt 32(%esp) + je ..B1.23 +..B1.22: + fldcw 62(%esp) +..B1.23: + fldt 16(%esp) + fstpt (%edi) + fldt 32(%esp) + fstpt (%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.24: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.79 +..B1.26: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.27: + fldcw 60(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_SP2@GOTOFF(%ebx) + fmul %st(1), %st + fldt _SP2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 12+_CP2@GOTOFF(%ebx) + fmul %st(1), %st + fldt _CP2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddl _ones@GOTOFF(%ebx) + fstpt 32(%esp) + je ..B1.31 +..B1.30: + fldcw 62(%esp) +..B1.31: + fldt 16(%esp) + fstpt (%edi) + fldt 32(%esp) + fstpt (%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.32: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.33: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.81 +..B1.34: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.35: + fldcw 60(%esp) +..B1.36: + movl $1, %eax +..B1.37: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 36+_SP1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_SP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_SP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _SP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 36+_CP1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_CP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_CP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _CP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddl _ones@GOTOFF(%ebx) + fstpt 16(%esp) + je ..B1.39 +..B1.38: + fldcw 62(%esp) +..B1.39: + fldt 32(%esp) + fstpt (%edi) + fldt 16(%esp) + fstpt (%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.40: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.84 +..B1.42: + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.43: + fldcw 60(%esp) +..B1.44: + movzwl 16(%ebp), %eax + movl $1, 28(%esp) + andl $32767, %eax +..B1.45: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + movl %edx, 44(%esp) + cmpl $16413, %eax + jge ..B1.52 +..B1.46: + fldt 8(%ebp) + fldl _Pi4Inv@GOTOFF(%ebx) + fxch %st(1) + fmull _ones@GOTOFF(%ebx,%edx,8) + fmul %st, %st(1) + fxch %st(1) + fstpt 32(%esp) + movzwl 40(%esp), %ecx + andl $32767, %ecx + cmpl $16383, %ecx + jge ..B1.48 +..B1.47: + fldl _TWO_52H@GOTOFF(%ebx) + xorl %edx, %edx + fmul %st(1), %st + fstpt 16(%esp) + fldt 16(%esp) + fld %st(1) + movl $1, 12(%esp) + fadd %st(1), %st + fsubp %st, %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fld %st(1) + fsubp %st, %st(1) + fxch %st(1) + jmp ..B1.63 +..B1.48: + fldl _TWO_32H@GOTOFF(%ebx) + negl %ecx + addl $30, %ecx + movl 36(%esp), %edx + shrl %cl, %edx + lea 1(%edx), %ecx + movl %ecx, 12(%esp) + andl $-2, %ecx + movl %ecx, 16(%esp) + cmpl $16400, %eax + fildl 16(%esp) + jge ..B1.50 +..B1.49: + fldl _Pi04x3@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x3@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmull 16+_Pi04x3@GOTOFF(%ebx) + fld %st(0) + fsubr %st(2), %st + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(2) + fsubrp %st, %st(1) + faddp %st, %st(1) + jmp ..B1.51 +..B1.50: + fldl _Pi04x5@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x5@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl 24+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + fmull 32+_Pi04x5@GOTOFF(%ebx) + fld %st(0) + fsubr %st(2), %st + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(2) + fsubrp %st, %st(1) + faddp %st, %st(1) +..B1.51: + fldl _TWO_52H@GOTOFF(%ebx) + addl $3, %edx + fldt 16(%esp) + fmul %st, %st(1) + fld %st(1) + movl 12(%esp), %eax + fadd %st(1), %st + shrl $2, %eax + fsubp %st, %st(2) + movl 44(%esp), %ecx + fsub %st(1), %st + xorl %eax, %ecx + fadd %st, %st(2) + shrl $2, %edx + fld %st(1) + andl $1, %ecx + movl %ecx, 44(%esp) + andl $1, %edx + fadd %st(3), %st + fxch %st(2) + fstpt 64(%esp) + fstpt 16(%esp) + jmp ..B1.63 +..B1.52: + cmpl $32767, %eax + jne ..B1.61 +..B1.53: + cmpl $-2147483648, 12(%ebp) + jne ..B1.56 +..B1.54: + cmpl $0, 8(%ebp) + jne ..B1.56 +..B1.55: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpt 16(%esp) + jmp ..B1.57 +..B1.56: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx) + fstpt 16(%esp) +..B1.57: + cmpl $0, 28(%esp) + je ..B1.59 +..B1.58: + fldcw 62(%esp) +..B1.59: + fldt 16(%esp) + fstpt (%edi) + fldt (%edi) + fstpt (%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.60: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.61: + fldt 8(%ebp) + addl $-32, %esp + movl %edx, %eax + lea 160(%esp), %edx + fmull _ones@GOTOFF(%ebx,%eax,8) + fstpt (%esp) + movl $0, 12(%esp) + movl %edx, 16(%esp) + call __libm_reduce_pi04l +..B1.87: + movl %eax, %edx + addl $32, %esp +..B1.62: + fldl 128(%esp) + lea 1(%edx), %eax + fldl _TWO_52H@GOTOFF(%ebx) + addl $3, %edx + fmul %st(1), %st + fld %st(0) + movl %eax, 12(%esp) + fadd %st(2), %st + shrl $2, %eax + fsubp %st, %st(1) + movl 44(%esp), %ecx + fsubr %st, %st(1) + xorl %eax, %ecx + shrl $2, %edx + andl $1, %ecx + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + andl $1, %edx + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fldl 136(%esp) + movl %ecx, 44(%esp) + faddp %st, %st(2) + fadd %st(1), %st +..B1.63: + fldt 64(%esp) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(0), %st + fld %st(0) + fld %st(1) + fxch %st(5) + fstpt 80(%esp) + fldt 80(%esp) + fmul %st(4), %st + movl 44(%esp), %eax + faddp %st, %st(3) + fld %st(2) + fld %st(2) + fmul %st(3), %st + fxch %st(2) + fadd %st(4), %st + fmul %st, %st(1) + fxch %st(4) + fmul %st, %st(6) + testb $2, 12(%esp) + fxch %st(1) + faddp %st, %st(6) + fxch %st(4) + fstpt 96(%esp) + fldt 96+_SP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 84+_SP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_CP@GOTOFF(%ebx) + fmul %st(4), %st + fldt 84+_CP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 72+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 72+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 60+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 60+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fld %st(5) + fldt 120+_SP@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmul %st(2), %st + fldt 120+_CP@GOTOFF(%ebx) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(5) + fxch %st(6) + fstpt 112(%esp) + fld %st(4) + fldt 108+_SP@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 108+_SP@GOTOFF(%ebx) + fmul %st(3), %st + faddp %st, %st(6) + fld %st(5) + fadd %st(1), %st + fldt 108+_CP@GOTOFF(%ebx) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(5) + fxch %st(5) + fmulp %st, %st(3) + fldt 112(%esp) + fmulp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fldl _TWO_53H@GOTOFF(%ebx) + fld %st(0) + fmul %st(6), %st + fadd %st, %st(6) + fsubrp %st, %st(6) + fxch %st(5) + fsubr %st, %st(6) + fxch %st(6) + faddp %st, %st(3) + fmul %st, %st(4) + fadd %st(4), %st + fsubp %st, %st(4) + fld %st(3) + fxch %st(1) + fsub %st(4), %st + faddp %st, %st(3) + fldt 80(%esp) + fmul %st(5), %st + fldt 96(%esp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 64(%esp) + fmul %st, %st(5) + fld %st(0) + fadd %st(6), %st + fstpt 48(%esp) + fldt 48(%esp) + fsubrp %st, %st(1) + faddp %st, %st(5) + fldl _ones@GOTOFF(%ebx) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 80(%esp) + faddp %st, %st(1) + faddp %st, %st(3) + fldl _ones@GOTOFF(%ebx,%eax,8) + fldl _ones@GOTOFF(%ebx,%edx,8) + je ..B1.65 +..B1.64: + fxch %st(1) + fmul %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st, %st(2) + fldt 48(%esp) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%esp) + fstpt 64(%esp) + jmp ..B1.66 +..B1.65: + fldt 48(%esp) + fmul %st(2), %st + fxch %st(2) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fxch %st(2) + fmul %st(3), %st + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fstpt 64(%esp) + fstpt 48(%esp) +..B1.66: + cmpl $0, 28(%esp) + je ..B1.68 +..B1.67: + fldt 16(%esp) + fstpt 32(%esp) +..B1.88: + fldcw 62(%esp) +..B1.68: + fldt 64(%esp) + fstpt (%edi) + fldt 48(%esp) + fstpt (%esi) + movl 144(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.69: + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.70: + call __stack_chk_fail@PLT +..B1.71: + cmpl $0, 12(%ebp) + jne ..B1.73 +..B1.72: + cmpl $0, 8(%ebp) + je ..B1.74 +..B1.73: + fldt _small_value_80@GOTOFF(%ebx) + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ebx) + fmul %st(1), %st + movzbl 17(%ebp), %ecx + fsubp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ebx) + andl $128, %ecx + shrl $7, %ecx + fstpt 16(%esp) + fldl _ones@GOTOFF(%ebx) + fsub %st(1), %st + fstpt 32(%esp) + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %eax + fldt _small_value_80@GOTOFF(%ebx,%eax) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.13 +..B1.74: + fldt 8(%ebp) + fstpt 16(%esp) + fldl _ones@GOTOFF(%ebx) + fstpt 32(%esp) + jmp ..B1.13 +..B1.75: + xorl %edx, %edx + jmp ..B1.11 +..B1.77: + xorl %eax, %eax + jmp ..B1.21 +..B1.79: + xorl %eax, %eax + jmp ..B1.29 +..B1.81: + xorl %eax, %eax + jmp ..B1.37 +..B1.84: + movl $0, 28(%esp) + jmp ..B1.45 + .align 16,0x90 + .type sincosl,@function + .size sincosl,.-sincosl + .data +# -- End sincosl + .section .rodata, "a" + .align 16 + .align 16 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 16 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .space 8, 0x00 # pad + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_SP3: + .word 17476 + .word 43656 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .type _SP3,@object + .size _SP3,12 + .space 4, 0x00 # pad + .align 16 +_CP3: + .word 0 + .word 65450 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .type _CP3,@object + .size _CP3,12 + .space 4, 0x00 # pad + .align 16 +_SP2: + .word 43210 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 1587 + .word 57422 + .word 34932 + .word 34952 + .word 16376 + .word 0 + .type _SP2,@object + .size _SP2,24 + .space 8, 0x00 # pad + .align 16 +_CP2: + .word 63855 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 18238 + .word 17476 + .word 43656 + .word 43690 + .word 16378 + .word 0 + .type _CP2,@object + .size _CP2,24 + .space 8, 0x00 # pad + .align 16 +_SP1: + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 12518 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 43088 + .word 7396 + .word 207 + .word 53261 + .word 49138 + .word 0 + .word 55827 + .word 48618 + .word 3602 + .word 47342 + .word 16364 + .word 0 + .type _SP1,@object + .size _SP1,48 + .align 16 +_CP1: + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 47533 + .word 43689 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 14131 + .word 49466 + .word 24756 + .word 46603 + .word 49141 + .word 0 + .word 37142 + .word 18013 + .word 35855 + .word 53259 + .word 16367 + .word 0 + .type _CP1,@object + .size _CP1,48 + .align 16 +_Pi4Inv: + .long 1841940611 + .long 1072979760 + .type _Pi4Inv,@object + .size _Pi4Inv,8 + .space 8, 0x00 # pad + .align 16 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .space 8, 0x00 # pad + .align 16 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .space 8, 0x00 # pad + .align 16 +_Pi04x3: + .long 1413754112 + .long 1072243195 + .long 2563527040 + .long 1021855384 + .long 3417685868 + .long 3118450936 + .type _Pi04x3,@object + .size _Pi04x3,24 + .space 8, 0x00 # pad + .align 16 +_Pi04x5: + .long 1413480448 + .long 1072243195 + .long 442499072 + .long 1036039265 + .long 771751936 + .long 999496074 + .long 622854144 + .long 963347354 + .long 1396597664 + .long 922906692 + .type _Pi04x5,@object + .size _Pi04x5,40 + .space 8, 0x00 # pad + .align 16 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 16 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 16 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .type _SP,@object + .size _SP,132 + .space 12, 0x00 # pad + .align 16 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .type _CP,@object + .size _CP,132 + .space 12, 0x00 # pad + .align 16 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sindl.S b/external/sgx_libm/ia32/sindl.S new file mode 100644 index 0000000000..2da756f394 --- /dev/null +++ b/external/sgx_libm/ia32/sindl.S @@ -0,0 +1,871 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sindl.c" + .text +..TXTST0: +# -- Begin sindl + .text + .align 16,0x90 + .globl sindl +sindl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp +..B1.2: + fnstcw 30(%esp) +..B1.3: + movzwl 30(%esp), %edx + movl %edx, %eax + andl $3840, %eax + cmpl $768, %eax + je ..B1.53 +..B1.4: + andl $-3841, %edx + orl $-64768, %edx + movw %dx, 28(%esp) +..B1.5: + fldcw 28(%esp) +..B1.6: + movl $1, %edi +..B1.7: + movzbl 17(%ebp), %esi + movzwl 16(%ebp), %ecx + andl $128, %esi + andl $32767, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + shrl $7, %esi + movl %eax, 12(%esp) + cmpl $16446, %ecx + jge ..B1.26 +..B1.8: + cmpl $16318, %ecx + jge ..B1.19 +..B1.9: + fldt 8(%ebp) + movl %eax, %edx + fstpt 16(%esp) + fldt 16(%esp) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fucompp + fnstsw %ax + sahf + jp ..B1.10 + je ..B1.43 +..B1.10: + testl %ecx, %ecx + jle ..B1.16 +..B1.11: + cmpl $6, %ecx + jge ..B1.15 +..B1.12: + fldt 16(%esp) + testl %edi, %edi + movl %edx, %eax + fabs + fldt _TWO5600@GOTOFF(%eax) + fmulp %st, %st(1) + fld %st(0) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_53H@GOTOFF(%eax) + fmul %st(1), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fldl 8+_sindl_mp_poly_coeff@GOTOFF(%eax) + fmulp %st, %st(2) + fldl _sindl_mp_poly_coeff@GOTOFF(%eax) + fmul %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(2) + flds ones@GOTOFF(%eax,%esi,4) + fmul %st, %st(2) + fld %st(2) + fxch %st(2) + fmulp %st, %st(1) + fadd %st, %st(1) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt fBreaker@GOTOFF(%eax) + fmul %st(1), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fsub %st(1), %st + faddp %st, %st(2) + fldt 12+_TWO5600@GOTOFF(%eax) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt (%esp) + fldt _Underflow@GOTOFF(%eax) + fldt .L_2il0floatpacket.5@GOTOFF(%eax) + fmulp %st, %st(1) + fstpt 60(%esp) + je ..B1.14 +..B1.13: + fldcw 30(%esp) +..B1.14: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.15: + je ..B1.40 +..B1.16: + fldt 16(%esp) + testl %edi, %edi + movl %edx, %eax + fabs + fldt _TWO5600@GOTOFF(%eax) + fmulp %st, %st(1) + fld %st(0) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_53H@GOTOFF(%eax) + fmul %st(1), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fldl 8+_sindl_mp_poly_coeff@GOTOFF(%eax) + fmulp %st, %st(2) + fldl _sindl_mp_poly_coeff@GOTOFF(%eax) + fmul %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(2) + flds ones@GOTOFF(%eax,%esi,4) + fmul %st, %st(2) + fld %st(2) + fxch %st(2) + fmulp %st, %st(1) + fadd %st, %st(1) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt fBreaker@GOTOFF(%eax) + fmul %st(1), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fsub %st(1), %st + faddp %st, %st(2) + faddp %st, %st(1) + fldt 12+_TWO5600@GOTOFF(%eax) + fmulp %st, %st(1) + fstpt (%esp) + je ..B1.18 +..B1.17: + fldcw 30(%esp) +..B1.18: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + fldt 8(%ebp) + movl %eax, %ebx + fabs + fstpt 8(%ebp) + fldt 8(%ebp) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fldt _Rcp90@GOTOFF(%ebx) + fmul %st(2), %st + fadd %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + movl 60(%esp), %edx + movl %edx, %ecx + andl $2, %ecx + fsubp %st, %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fmulp %st, %st(1) + shrl $1, %ecx + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + xorl %ecx, %esi + fucomp %st(1) + fnstsw %ax + sahf + jp ..B1.20 + je ..B1.46 +..B1.20: + movl %ebx, %eax + fld %st(0) + fld %st(1) + fld %st(2) + fld %st(3) + testb $1, %dl + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + fmul %st(5), %st + fsub %st, %st(4) + fsubp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fld %st(0) + fxch %st(4) + fsub %st(5), %st + fmul %st, %st(5) + fmul %st(6), %st + faddp %st, %st(5) + fldl _TWO_53H@GOTOFF(%eax) + fmul %st, %st(3) + fld %st(0) + fmul %st(2), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + fxch %st(1) + fsub %st(4), %st + faddp %st, %st(5) + fld %st(5) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + fstpt 48(%esp) + fld %st(4) + fmul %st(5), %st + fld %st(0) + fmul %st(1), %st + flds ones@GOTOFF(%eax,%esi,4) + fstps 12(%esp) + je ..B1.22 +..B1.21: + fstp %st(6) + fstp %st(2) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(1) + fld %st(2) + fmul %st(5), %st + fxch %st(4) + fstpt (%esp) + fldt (%esp) + fld %st(3) + fmul %st(7), %st + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(5) + fld %st(1) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fstpt 16(%esp) + fldt 16(%esp) + fsubrp %st, %st(1) + faddp %st, %st(3) + fldt 84+_cosdl_poly_coeff@GOTOFF(%eax) + fmul %st(5), %st + fldt 60+_cosdl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(5), %st + fldt 36+_cosdl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_cosdl_poly_coeff@GOTOFF(%eax) + fmul %st(6), %st + fldt 48+_cosdl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(6), %st + fldt 24+_cosdl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fldl 24+_cosdl_mp_poly_coeff@GOTOFF(%eax) + fmulp %st, %st(5) + faddp %st, %st(4) + fldl 8+_cosdl_mp_poly_coeff@GOTOFF(%eax) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 16+_cosdl_mp_poly_coeff@GOTOFF(%eax) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldl _cosdl_mp_poly_coeff@GOTOFF(%eax) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt (%esp) + fmulp %st, %st(2) + fld %st(1) + fldt 16(%esp) + fmulp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + flds 12(%esp) + fld %st(0) + fldt .L_2il0floatpacket.4@GOTOFF(%eax) + fld %st(0) + fadd %st(4), %st + fmul %st, %st(2) + fsubrp %st, %st(1) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%esp) + jmp ..B1.23 +..B1.22: + fld %st(6) + fmul %st(2), %st + fstpt 16(%esp) + fld %st(4) + fmul %st(4), %st + fmul %st, %st(3) + fxch %st(6) + fmul %st(7), %st + fxch %st(4) + fstpt (%esp) + fldt 48(%esp) + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fld %st(5) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fldt 96+_sindl_poly_coeff@GOTOFF(%eax) + fmul %st(2), %st + fldt 72+_sindl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_sindl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_sindl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 84+_sindl_poly_coeff@GOTOFF(%eax) + fmul %st(2), %st + fldt 60+_sindl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_sindl_poly_coeff@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 16(%esp) + fmul %st, %st(1) + fldl 24+_sindl_mp_poly_coeff@GOTOFF(%eax) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl 8+_sindl_mp_poly_coeff@GOTOFF(%eax) + fmulp %st, %st(5) + faddp %st, %st(4) + fldl 16+_sindl_mp_poly_coeff@GOTOFF(%eax) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldl _sindl_mp_poly_coeff@GOTOFF(%eax) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldt (%esp) + fmulp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + flds 12(%esp) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%esp) +..B1.23: + testl %edi, %edi + je ..B1.25 +..B1.24: + fldcw 30(%esp) +..B1.25: + fldt 32(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.26: + cmpl $32767, %ecx + je ..B1.52 +..B1.27: + lea -16446(%ecx), %eax + movl %eax, (%esp) + cmpl $14, %eax + jle ..B1.29 +..B1.28: + addl $-16449, %ecx + movl $715827883, %eax + imull %ecx + movl %ecx, %ebx + sarl $1, %edx + sarl $31, %ebx + subl %ebx, %edx + lea (,%edx,8), %ebx + lea (%ebx,%edx,4), %eax + subl %eax, %ecx + lea 3(%ecx), %ecx + movl %ecx, (%esp) +..B1.29: + movl 12(%ebp), %ecx + movl %ecx, %ebx + shll $8, %ebx + movl $381774871, %eax + movl %ebx, %edx + andl $-16777216, %ecx + shrl $3, %edx + mull %edx + shrl $2, %edx + imull $-360, %edx, %eax + movl %ecx, %edx + shrl $19, %ecx + addl %eax, %ebx + movl $381774871, %eax + shrl $16, %edx + movl %edx, 4(%esp) + mull %ecx + shrl $2, %edx + imull $-360, %edx, %ecx + movl 4(%esp), %eax + addl %ecx, %eax + movl 8(%ebp), %ecx + movl %ecx, %edx + shrl $3, %edx + addl %eax, %ebx + movl $381774871, %eax + mull %edx + shrl $2, %edx + imull $-360, %edx, %eax + addl %eax, %ecx + movl $-1240768329, %eax + addl %ecx, %ebx + movl (%esp), %ecx + shll %cl, %ebx + imull %ebx + addl %ebx, %edx + movl %ebx, %ecx + sarl $8, %edx + sarl $31, %ecx + subl %ecx, %edx + imull $-360, %edx, %eax + addl %eax, %ebx + cmpl $180, %ebx + jl ..B1.31 +..B1.30: + addl $-180, %ebx + movl $2, %eax + jmp ..B1.32 +..B1.31: + xorl %eax, %eax +..B1.32: + cmpl $90, %ebx + jl ..B1.34 +..B1.33: + incl %eax + addl $-90, %ebx +..B1.34: + movl %eax, %edx + movl %eax, %ecx + andl $2, %edx + shrl $1, %edx + xorl %edx, %esi + orl %ebx, %ecx + je ..B1.36 +..B1.35: + andl $1, %eax + shll $4, %eax + shll $5, %ebx + addl %ebx, %eax + movl 12(%esp), %edx + fldl __libm_sindl_cosdl_table@GOTOFF(%eax,%edx) + faddl 8+__libm_sindl_cosdl_table@GOTOFF(%edx,%eax) + fmuls ones@GOTOFF(%edx,%esi,4) + fstpt (%esp) + jmp ..B1.37 +..B1.36: + movl 12(%esp), %eax + fldt .L_2il0floatpacket.0@GOTOFF(%eax) + fstpt (%esp) +..B1.37: + testl %edi, %edi + je ..B1.39 +..B1.38: + fldcw 30(%esp) +..B1.39: + fldt (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.40: + movl 12(%ebp), %eax + cmpl $-449912621, %eax + jb ..B1.12 +..B1.41: + jne ..B1.16 +..B1.42: + cmpl $504348098, 8(%ebp) + jbe ..B1.12 + jmp ..B1.16 +..B1.43: + testl %edi, %edi + je ..B1.45 +..B1.44: + fldcw 30(%esp) +..B1.45: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + fstp %st(0) + testb $1, %dl + je ..B1.48 +..B1.47: + movl %ebx, %eax + flds ones@GOTOFF(%eax,%esi,4) + fstps (%esp) + jmp ..B1.49 +..B1.48: + fldz + fstps (%esp) +..B1.49: + testl %edi, %edi + je ..B1.51 +..B1.50: + fldcw 30(%esp) +..B1.51: + flds (%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.52: + fldt 8(%ebp) + fldt .L_2il0floatpacket.0@GOTOFF(%eax) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.37 +..B1.53: + xorl %edi, %edi + jmp ..B1.7 + .align 16,0x90 + .type sindl,@function + .size sindl,.-sindl + .data +# -- End sindl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3e,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb4,0x05,0x40,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 16 +_sindl_mp_poly_coeff: + .long 2723323193 + .long 1066524486 + .long 2863989530 + .long 1008058840 + .long 227815288 + .long 3199056770 + .long 3752327299 + .long 3142458725 + .type _sindl_mp_poly_coeff,@object + .size _sindl_mp_poly_coeff,32 + .align 16 +_Underflow: + .word 1 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _Underflow,@object + .size _Underflow,12 + .space 4, 0x00 # pad + .align 16 +_cosdl_poly_coeff: + .word 52350 + .word 41213 + .word 3800 + .word 40885 + .word 49138 + .word 0 + .word 28613 + .word 7908 + .word 35668 + .word 34008 + .word 16355 + .word 0 + .word 19927 + .word 58728 + .word 49885 + .word 45261 + .word 49106 + .word 0 + .word 32884 + .word 22035 + .word 23267 + .word 64541 + .word 16320 + .word 0 + .word 36401 + .word 51897 + .word 8309 + .word 57265 + .word 49070 + .word 0 + .word 34286 + .word 2728 + .word 41564 + .word 34642 + .word 16284 + .word 0 + .word 63248 + .word 18030 + .word 35596 + .word 60796 + .word 49032 + .word 0 + .word 52149 + .word 21294 + .word 63985 + .word 40123 + .word 16245 + .word 0 + .type _cosdl_poly_coeff,@object + .size _cosdl_poly_coeff,96 + .align 16 +_cosdl_mp_poly_coeff: + .long 3675529145 + .long 3206805153 + .long 2134983071 + .long 3151100167 + .long 1787026573 + .long 1043372817 + .long 205083639 + .long 988746860 + .type _cosdl_mp_poly_coeff,@object + .size _cosdl_mp_poly_coeff,32 + .align 16 +_sindl_poly_coeff: + .word 51374 + .word 38121 + .word 13586 + .word 36602 + .word 16377 + .word 0 + .word 50116 + .word 41339 + .word 4204 + .word 60892 + .word 49130 + .word 0 + .word 33704 + .word 2155 + .word 42839 + .word 60780 + .word 16346 + .word 0 + .word 21250 + .word 19076 + .word 27901 + .word 57780 + .word 49097 + .word 0 + .word 9076 + .word 49244 + .word 613 + .word 64083 + .word 16311 + .word 0 + .word 40572 + .word 30418 + .word 36251 + .word 46520 + .word 49061 + .word 0 + .word 3227 + .word 25505 + .word 5540 + .word 47626 + .word 16274 + .word 0 + .word 60933 + .word 3300 + .word 57416 + .word 36218 + .word 49023 + .word 0 + .word 45811 + .word 42646 + .word 37125 + .word 42185 + .word 16235 + .word 0 + .type _sindl_poly_coeff,@object + .size _sindl_poly_coeff,108 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +fBreaker: + .byte 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x80,0x13,0x40,0x00,0x00 + .type fBreaker,@object + .size fBreaker,12 + .align 2 +_TWO5600: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 21983 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 10783 + .word 0 + .type _TWO5600,@object + .size _TWO5600,24 + .align 2 +_Rcp90: + .word 46603 + .word 2912 + .word 24758 + .word 46603 + .word 16376 + .word 0 + .type _Rcp90,@object + .size _Rcp90,12 + .data + .hidden __libm_sindl_cosdl_table + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sinf_wmt.S b/external/sgx_libm/ia32/sinf_wmt.S new file mode 100644 index 0000000000..ddf67be8a9 --- /dev/null +++ b/external/sgx_libm/ia32/sinf_wmt.S @@ -0,0 +1,585 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin sinf + .text + .align 16,0x90 + .globl sinf +sinf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 36(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movl 112(%esp), %ecx + subl $16, %esp + stmxcsr 4(%esp) + movl 4(%esp), %eax + andl $-24577, %eax + cmpl %eax, 4(%esp) + jne .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + movapd %xmm0, %xmm1 + cvtps2pd %xmm1, %xmm1 + movsd 1296(%ebx), %xmm2 + movl $2147483647, %eax + movl $1241513983, %edx + andl %ecx, %eax + subl %eax, %edx + subl $964689920, %eax + orl %eax, %edx + jl .L_2TAG_PACKET_2.0.2 + movsd 1312(%ebx), %xmm4 + mulsd %xmm1, %xmm2 + movsd 1328(%ebx), %xmm3 + movapd %xmm2, %xmm5 + addsd %xmm4, %xmm2 + movd %xmm2, %ecx + subsd %xmm4, %xmm2 + mulsd %xmm3, %xmm1 +.L_2TAG_PACKET_3.0.2: + movl $384, %eax + movsd 1344(%ebx), %xmm4 + subsd %xmm2, %xmm5 + addl %ecx, %ecx + movl %ecx, %edx + shll $24, %ecx + sarl $31, %ecx + andl %edx, %eax + addl %ecx, %edx + xorl %ecx, %edx + addsd %xmm5, %xmm1 + andl $254, %edx + movsd (%ebx,%edx,8), %xmm3 + movsd 1352(%ebx), %xmm0 + pshufd $68, %xmm1, %xmm2 + mulsd %xmm1, %xmm1 + movsd 8(%ebx,%edx,8), %xmm5 + movl %eax, %ecx + addl $128, %ecx + andl $256, %ecx + shll $23, %ecx + mulsd %xmm2, %xmm3 + movd %ecx, %xmm2 + subsd %xmm1, %xmm0 + andl $256, %eax + shll $23, %eax + subsd %xmm1, %xmm4 + psllq $32, %xmm2 + movd %eax, %xmm1 + xorpd %xmm2, %xmm4 + mulsd %xmm5, %xmm0 + mulsd %xmm4, %xmm3 + psllq $32, %xmm1 + xorpd %xmm1, %xmm0 + addsd %xmm3, %xmm0 + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_4.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_4.0.2: + cvtpd2ps %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_2.0.2: + andl $2147483647, %ecx + cmpl $1040187392, %ecx + ja .L_2TAG_PACKET_6.0.2 + cvtss2sd %xmm0, %xmm0 + mulsd 1280(%ebx), %xmm0 + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_7.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_7.0.2: + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_0.0.2: + movl 4(%esp), %eax + andl $-24577, %eax + movl %eax, 8(%esp) + ldmxcsr 8(%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_6.0.2: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_8.0.2 + shrl $23, %ecx + subl $142, %ecx + andl $65528, %ecx + movsd 1040(%ebx,%ecx,2), %xmm3 + movsd 1048(%ebx,%ecx,2), %xmm5 + movsd 1360(%ebx), %xmm2 + xorpd %xmm4, %xmm4 + movl $17208, %eax + pinsrw $3, %eax, %xmm4 + andpd %xmm3, %xmm2 + psllq $40, %xmm3 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + movapd %xmm2, %xmm0 + addsd %xmm3, %xmm2 + movapd %xmm2, %xmm5 + subsd %xmm2, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm0, %xmm3 + movd %xmm2, %ecx + subsd %xmm4, %xmm2 + addsd %xmm3, %xmm1 + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_8.0.2: + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_9.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_9.0.2: + subss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) +.L_2TAG_PACKET_5.0.2: + addl $16, %esp + movl 36(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type sinf,@function + .size sinf,.-sinf + .data +# -- End sinf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 3861233235 + .long 1053076412 + .long 0 + .long 0 + .long 3836476539 + .long 1053076004 + .long 1466910230 + .long 1054802127 + .long 522802171 + .long 1053074781 + .long 1693671239 + .long 1055850091 + .long 1381230637 + .long 1053072742 + .long 3419039295 + .long 1056390099 + .long 3096463640 + .long 1053069889 + .long 3054827835 + .long 1056896220 + .long 163641427 + .long 1053066225 + .long 3381119115 + .long 1057182863 + .long 2063766514 + .long 1053061750 + .long 544295963 + .long 1057434550 + .long 3193221610 + .long 1053056468 + .long 3297207428 + .long 1057685321 + .long 36665700 + .long 1053050383 + .long 2811721921 + .long 1057935027 + .long 4043704933 + .long 1053043496 + .long 2950925715 + .long 1058098350 + .long 2964703016 + .long 1053035814 + .long 2674059679 + .long 1058221912 + .long 3789723003 + .long 1053027340 + .long 879820317 + .long 1058344717 + .long 2671784286 + .long 1053018080 + .long 1979618421 + .long 1058466690 + .long 2093526290 + .long 1053008039 + .long 3945677176 + .long 1058587758 + .long 2262842797 + .long 1052997223 + .long 2796081240 + .long 1058707849 + .long 1097233945 + .long 1052985639 + .long 1373383079 + .long 1058826890 + .long 2796885356 + .long 1052973293 + .long 941816458 + .long 1058944809 + .long 646746141 + .long 1052960194 + .long 1372808103 + .long 1059061535 + .long 2767093429 + .long 1052946348 + .long 664370609 + .long 1059119379 + .long 2028347177 + .long 1052931765 + .long 1369913724 + .long 1059176444 + .long 1799297257 + .long 1052916453 + .long 3344537919 + .long 1059232808 + .long 3039475318 + .long 1052900421 + .long 2500108843 + .long 1059288438 + .long 4275292648 + .long 1052883679 + .long 944109265 + .long 1059343300 + .long 1575056534 + .long 1052866238 + .long 2771364651 + .long 1059397360 + .long 1407782048 + .long 1052848107 + .long 1264637048 + .long 1059450587 + .long 3436142021 + .long 1052829297 + .long 453708735 + .long 1059502948 + .long 488211833 + .long 1052809821 + .long 2313428161 + .long 1059554411 + .long 2993330 + .long 1052789689 + .long 2550341159 + .long 1059604946 + .long 755484892 + .long 1052767523 + .long 3567792879 + .long 1059654522 + .long 3348027550 + .long 1052724710 + .long 1659779181 + .long 1059703110 + .long 2580634211 + .long 1052680662 + .long 4268074870 + .long 1059750679 + .long 742418353 + .long 1052635405 + .long 4288148241 + .long 1059797202 + .long 3250975870 + .long 1052588965 + .long 1618129506 + .long 1059842651 + .long 1401987205 + .long 1052541372 + .long 3231311734 + .long 1059886997 + .long 2361617751 + .long 1052492653 + .long 1772140623 + .long 1059930215 + .long 3322544997 + .long 1052442838 + .long 1395127179 + .long 1059972278 + .long 17970311 + .long 1052391958 + .long 652328457 + .long 1060013161 + .long 3823857331 + .long 1052340041 + .long 1148832537 + .long 1060052839 + .long 3024934267 + .long 1052287121 + .long 3311502568 + .long 1060091288 + .long 1388494065 + .long 1052233229 + .long 1077921708 + .long 1060119411 + .long 902054988 + .long 1052178397 + .long 115411415 + .long 1060137373 + .long 1689375324 + .long 1052122658 + .long 3838419993 + .long 1060154686 + .long 1925003623 + .long 1052066046 + .long 1813501338 + .long 1060171342 + .long 2042383238 + .long 1052008595 + .long 2490283769 + .long 1060187329 + .long 350661592 + .long 1051950340 + .long 3162654741 + .long 1060202638 + .long 1535093810 + .long 1051891315 + .long 2878576948 + .long 1060217260 + .long 3681356269 + .long 1051831556 + .long 2463945945 + .long 1060231186 + .long 2478530408 + .long 1051771100 + .long 250409509 + .long 1060244408 + .long 3726787968 + .long 1051698237 + .long 687004205 + .long 1060256917 + .long 2082609563 + .long 1051574753 + .long 1475857720 + .long 1060268706 + .long 1666812989 + .long 1051450094 + .long 2181617495 + .long 1060279768 + .long 2865853451 + .long 1051324335 + .long 4249822861 + .long 1060290096 + .long 321119318 + .long 1051197553 + .long 2434209605 + .long 1060299685 + .long 4207787592 + .long 1051069822 + .long 1992674941 + .long 1060308528 + .long 1382541649 + .long 1050941222 + .long 1522351063 + .long 1060316620 + .long 2429158325 + .long 1050811828 + .long 1563320407 + .long 1060323956 + .long 2803392399 + .long 1050681719 + .long 316258674 + .long 1060330532 + .long 3917367244 + .long 1050428795 + .long 2243801771 + .long 1060336343 + .long 1991825541 + .long 1050166188 + .long 900924147 + .long 1060341387 + .long 624330694 + .long 1049902623 + .long 418831766 + .long 1060345660 + .long 3087185898 + .long 1049638258 + .long 2627920248 + .long 1060349159 + .long 3670374716 + .long 1049121932 + .long 2769466396 + .long 1060351883 + .long 3431923622 + .long 1048590963 + .long 2385983684 + .long 1060353830 + .long 918535681 + .long 1047542708 + .long 735532773 + .long 1060354999 + .long 0 + .long 0 + .long 3384690142 + .long 1060355388 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1916669064 + .long 1072155675 + .long 660066805 + .long 1024797180 + .long 3829231700 + .long 1062745828 + .long 2884172442 + .long 1017445907 + .long 540874025 + .long 1055617650 + .long 4198409884 + .long 1011844330 + .long 2839315448 + .long 1046639136 + .long 4204424928 + .long 1000582120 + .long 1329339431 + .long 1038229673 + .long 1295478839 + .long 993391741 + .long 658191860 + .long 1024797180 + .long 3691886121 + .long 979325773 + .long 1966800710 + .long 1020436418 + .long 1882642597 + .long 977095991 + .long 2100977488 + .long 1012908661 + .long 1840335565 + .long 967470816 + .long 4198093645 + .long 1000582120 + .long 3307942521 + .long 957055414 + .long 2839123165 + .long 996851343 + .long 1387472776 + .long 952638316 + .long 2788761024 + .long 988712873 + .long 3005712498 + .long 944467026 + .long 3694676832 + .long 979325773 + .long 1326507024 + .long 934847846 + .long 221775557 + .long 970149340 + .long 1133527550 + .long 924162364 + .long 4286578688 + .long 1072693247 + .long 0 + .long 0 + .long 1845493760 + .long 1078222640 + .long 0 + .long 0 + .long 0 + .long 1127743488 + .long 0 + .long 0 + .long 2908765579 + .long 3193641918 + .long 0 + .long 0 + .long 2308576600 + .long 1086551075 + .long 1646446368 + .long 1084878895 + .long 4278190080 + .long 4294967295 + .long 0 + .long 0 + .type static_const_table,@object + .size static_const_table,1376 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sinh_wmt.S b/external/sgx_libm/ia32/sinh_wmt.S new file mode 100644 index 0000000000..9dbe63d099 --- /dev/null +++ b/external/sgx_libm/ia32/sinh_wmt.S @@ -0,0 +1,1404 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinh_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin sinh + .text + .align 16,0x90 + .globl sinh +sinh: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd 4272(%ebx), %xmm3 + xorpd %xmm4, %xmm4 + movsd 4192(%ebx), %xmm1 + movsd 4200(%ebx), %xmm2 + movl $32768, %eax + pinsrw $3, %eax, %xmm4 + movsd 4096(%ebx), %xmm6 + pextrw $3, %xmm0, %ecx + andpd %xmm0, %xmm3 + andnpd %xmm0, %xmm4 + pshufd $68, %xmm4, %xmm5 + movl $32768, %edx + andl %ecx, %edx + andl $32767, %ecx + subl $16343, %ecx + cmpl $177, %ecx + jae .L_2TAG_PACKET_0.0.3 + subsd %xmm3, %xmm4 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm2 + cvtsd2si %xmm3, %eax + shll $3, %edx + orl %edx, %eax + movapd %xmm3, %xmm7 + addsd %xmm6, %xmm3 + mulsd %xmm4, %xmm1 + xorpd %xmm5, %xmm5 + subsd %xmm6, %xmm3 + movapd 4112(%ebx), %xmm4 + addsd %xmm1, %xmm2 + movapd 4128(%ebx), %xmm6 + subsd %xmm3, %xmm7 + movl $32704, %edx + pinsrw $3, %edx, %xmm5 + movapd 4144(%ebx), %xmm1 + addsd %xmm7, %xmm2 + movl $127, %edx + andl %eax, %edx + addl %edx, %edx + shrl $3, %eax + andl $65520, %eax + addl $16352, %eax + xorpd %xmm0, %xmm0 + cmpl $161, %ecx + jae .L_2TAG_PACKET_1.0.3 + pshufd $68, %xmm5, %xmm5 + pinsrw $3, %eax, %xmm0 + pshufd $68, %xmm0, %xmm0 + psubw %xmm0, %xmm5 + mulpd (%ebx,%edx,8), %xmm0 + mulpd 2048(%ebx,%edx,8), %xmm5 + pshufd $68, %xmm2, %xmm3 + movapd 4160(%ebx), %xmm7 + pshufd $68, %xmm2, %xmm2 + mulpd %xmm3, %xmm3 + mulpd %xmm2, %xmm4 + mulpd %xmm2, %xmm6 + mulpd 4176(%ebx), %xmm2 + mulpd %xmm3, %xmm1 + mulpd %xmm3, %xmm7 + mulpd %xmm3, %xmm4 + mulpd %xmm3, %xmm1 + addpd %xmm7, %xmm6 + movapd %xmm0, %xmm7 + addpd %xmm1, %xmm4 + shufpd $0, %xmm5, %xmm7 + subpd %xmm5, %xmm0 + mulpd %xmm7, %xmm2 + addpd %xmm6, %xmm4 + subsd %xmm0, %xmm7 + mulpd %xmm2, %xmm4 + pshufd $238, %xmm0, %xmm6 + subsd %xmm5, %xmm7 + addpd %xmm2, %xmm4 + addsd %xmm6, %xmm7 + pshufd $238, %xmm4, %xmm2 + addsd %xmm7, %xmm2 + addsd %xmm4, %xmm2 + addsd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + subl $16352, %eax + movl %eax, %ecx + andl $32752, %eax + shrl $1, %eax + andl $65520, %eax + subl %eax, %ecx + addl $16352, %eax + pinsrw $3, %eax, %xmm0 + pshufd $68, %xmm0, %xmm0 + mulpd (%ebx,%edx,8), %xmm0 + pshufd $68, %xmm2, %xmm3 + movsd 4160(%ebx), %xmm7 + mulsd %xmm3, %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm6 + mulsd 4176(%ebx), %xmm2 + mulsd %xmm3, %xmm1 + mulsd %xmm3, %xmm7 + mulsd %xmm3, %xmm4 + addl $16368, %ecx + pinsrw $3, %ecx, %xmm5 + mulsd %xmm3, %xmm1 + addsd %xmm7, %xmm6 + addsd %xmm1, %xmm4 + mulsd %xmm0, %xmm2 + addsd %xmm6, %xmm4 + mulsd %xmm2, %xmm4 + pshufd $238, %xmm0, %xmm6 + addsd %xmm6, %xmm4 + addsd %xmm4, %xmm2 + addsd %xmm2, %xmm0 + mulsd %xmm5, %xmm0 + pextrw $3, %xmm0, %eax + andl $32752, %eax + movl $127, %edx + cmpl $32752, %eax + je .L_2TAG_PACKET_3.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + addl $16343, %ecx + cmpl $16343, %ecx + ja .L_2TAG_PACKET_4.0.3 + cmpl $15856, %ecx + jb .L_2TAG_PACKET_5.0.3 + movapd 4208(%ebx), %xmm1 + pshufd $68, %xmm0, %xmm6 + mulpd %xmm5, %xmm5 + movapd 4224(%ebx), %xmm2 + pshufd $68, %xmm0, %xmm7 + movapd 4240(%ebx), %xmm3 + pshufd $68, %xmm0, %xmm4 + andpd 4256(%ebx), %xmm6 + mulpd %xmm5, %xmm1 + mulsd %xmm5, %xmm2 + subpd %xmm6, %xmm4 + mulpd %xmm5, %xmm7 + addpd %xmm3, %xmm1 + pshufd $68, %xmm6, %xmm3 + mulpd %xmm5, %xmm5 + mulsd %xmm7, %xmm2 + mulpd %xmm7, %xmm1 + pshufd $68, %xmm0, %xmm7 + mulsd %xmm6, %xmm6 + addsd %xmm7, %xmm7 + mulsd %xmm4, %xmm4 + mulpd %xmm5, %xmm1 + addsd %xmm0, %xmm7 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm7 + pshufd $238, %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm2, %xmm3 + pshufd $238, %xmm2, %xmm2 + addsd %xmm4, %xmm7 + movapd %xmm0, %xmm4 + mulsd %xmm2, %xmm6 + mulsd %xmm5, %xmm7 + addsd %xmm6, %xmm0 + mulsd %xmm2, %xmm7 + subsd %xmm0, %xmm4 + addsd %xmm7, %xmm1 + addsd %xmm4, %xmm6 + addsd %xmm3, %xmm1 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_5.0.3: + cmpl $16, %ecx + jae .L_2TAG_PACKET_6.0.3 + movapd %xmm0, %xmm1 + mulsd %xmm1, %xmm1 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + xorpd %xmm2, %xmm2 + movl $17392, %ecx + pinsrw $3, %ecx, %xmm2 + xorpd %xmm3, %xmm3 + movl $15344, %edx + pinsrw $3, %edx, %xmm3 + mulsd %xmm0, %xmm2 + addsd %xmm2, %xmm0 + mulsd %xmm3, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $32752, %ecx + jae .L_2TAG_PACKET_7.0.3 + xorpd %xmm0, %xmm0 + movl $32736, %eax + pinsrw $3, %eax, %xmm0 + orl %edx, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + movl $127, %edx +.L_2TAG_PACKET_3.0.3: + movsd %xmm0, (%esp) + movsd 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + fldl (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_7.0.3: + xorpd %xmm1, %xmm1 + movl $32768, %eax + pinsrw $3, %eax, %xmm1 + andnpd %xmm0, %xmm1 + mulsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_2.0.3: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type sinh,@function + .size sinh,.-sinh + .data +# -- End sinh + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 2851812149 + .long 1072698941 + .long 2595802551 + .long 1016815913 + .long 1048019041 + .long 1072704666 + .long 1398474845 + .long 3161559171 + .long 3899555717 + .long 1072710421 + .long 427280750 + .long 3163595548 + .long 3541402996 + .long 1072716208 + .long 2759177317 + .long 1015903202 + .long 702412510 + .long 1072722027 + .long 3803266087 + .long 3163328991 + .long 410360776 + .long 1072727877 + .long 1269990655 + .long 1013024446 + .long 3402036099 + .long 1072733758 + .long 405889334 + .long 1016154232 + .long 1828292879 + .long 1072739672 + .long 1255956747 + .long 1016636974 + .long 728909815 + .long 1072745618 + .long 383930225 + .long 1016078044 + .long 852742562 + .long 1072751596 + .long 667253586 + .long 1010842135 + .long 2952712987 + .long 1072757606 + .long 3293494651 + .long 3161168877 + .long 3490863953 + .long 1072763649 + .long 960797498 + .long 3163997456 + .long 3228316108 + .long 1072769725 + .long 3010241991 + .long 3159471380 + .long 2930322912 + .long 1072775834 + .long 2599499422 + .long 3163762623 + .long 3366293073 + .long 1072781976 + .long 3119426314 + .long 1015169130 + .long 1014845819 + .long 1072788152 + .long 3117910646 + .long 3162607681 + .long 948735466 + .long 1072794361 + .long 3516338028 + .long 3163623459 + .long 3949972341 + .long 1072800603 + .long 2068408548 + .long 1015962444 + .long 2214878420 + .long 1072806880 + .long 892270087 + .long 3164164998 + .long 828946858 + .long 1072813191 + .long 10642492 + .long 1016988014 + .long 586995997 + .long 1072819536 + .long 41662348 + .long 3163676568 + .long 2288159958 + .long 1072825915 + .long 2169144469 + .long 1015924597 + .long 2440944790 + .long 1072832329 + .long 2492769774 + .long 1015196030 + .long 1853186616 + .long 1072838778 + .long 3066496371 + .long 1016705150 + .long 1337108031 + .long 1072845262 + .long 3203724452 + .long 1015726421 + .long 1709341917 + .long 1072851781 + .long 2571168217 + .long 1015201075 + .long 3790955393 + .long 1072858335 + .long 2352942462 + .long 3164228666 + .long 4112506593 + .long 1072864925 + .long 2947355221 + .long 1015419624 + .long 3504003472 + .long 1072871551 + .long 3594001060 + .long 3158379228 + .long 2799960843 + .long 1072878213 + .long 1423655381 + .long 1016070727 + .long 2839424854 + .long 1072884911 + .long 1171596163 + .long 1014090255 + .long 171030293 + .long 1072891646 + .long 3526460132 + .long 1015477354 + .long 4232894513 + .long 1072898416 + .long 2383938684 + .long 1015717095 + .long 2992903935 + .long 1072905224 + .long 2218154406 + .long 1016276769 + .long 1603444721 + .long 1072912069 + .long 1548633640 + .long 3163249902 + .long 926591435 + .long 1072918951 + .long 3208833762 + .long 3163962090 + .long 1829099622 + .long 1072925870 + .long 1016661181 + .long 3164509581 + .long 887463927 + .long 1072932827 + .long 3596744163 + .long 3161842742 + .long 3272845541 + .long 1072939821 + .long 928852419 + .long 3164536824 + .long 1276261410 + .long 1072946854 + .long 300981948 + .long 1015732745 + .long 78413852 + .long 1072953925 + .long 4183226867 + .long 3164065827 + .long 569847338 + .long 1072961034 + .long 472945272 + .long 3160339305 + .long 3645941911 + .long 1072968181 + .long 3814685081 + .long 3162621917 + .long 1617004845 + .long 1072975368 + .long 82804944 + .long 1011391354 + .long 3978100823 + .long 1072982593 + .long 3513027190 + .long 1016894539 + .long 3049340112 + .long 1072989858 + .long 3062915824 + .long 1014219171 + .long 4040676318 + .long 1072997162 + .long 4090609238 + .long 1016712034 + .long 3577096743 + .long 1073004506 + .long 2951496418 + .long 1014842263 + .long 2583551245 + .long 1073011890 + .long 3161094195 + .long 1016655067 + .long 1990012071 + .long 1073019314 + .long 3529070563 + .long 3163861769 + .long 2731501122 + .long 1073026778 + .long 1774031855 + .long 3163518597 + .long 1453150082 + .long 1073034283 + .long 498154669 + .long 3162536638 + .long 3395129871 + .long 1073041828 + .long 4025345435 + .long 3163383964 + .long 917841882 + .long 1073049415 + .long 18715565 + .long 1016707884 + .long 3566716925 + .long 1073057042 + .long 1536826856 + .long 1015191009 + .long 3712504873 + .long 1073064711 + .long 88491949 + .long 1016476236 + .long 2321106615 + .long 1073072422 + .long 2171176610 + .long 1010584347 + .long 363667784 + .long 1073080175 + .long 813753950 + .long 1016833785 + .long 3111574537 + .long 1073087969 + .long 2606161479 + .long 3163808322 + .long 2956612997 + .long 1073095806 + .long 2118169751 + .long 3163784129 + .long 885834528 + .long 1073103686 + .long 1973258547 + .long 3163310140 + .long 2186617381 + .long 1073111608 + .long 2270764084 + .long 3164321289 + .long 3561793907 + .long 1073119573 + .long 1157054053 + .long 1012938926 + .long 1719614413 + .long 1073127582 + .long 330458198 + .long 3164331316 + .long 1963711167 + .long 1073135634 + .long 1744767757 + .long 3161622870 + .long 1013258799 + .long 1073143730 + .long 1748797611 + .long 3161177658 + .long 4182873220 + .long 1073151869 + .long 629542646 + .long 3163044879 + .long 3907805044 + .long 1073160053 + .long 2257091225 + .long 3162598983 + .long 1218806132 + .long 1073168282 + .long 1818613052 + .long 3163597017 + .long 1447192521 + .long 1073176555 + .long 1462857171 + .long 3163563097 + .long 1339972927 + .long 1073184873 + .long 167908909 + .long 1016620728 + .long 1944781191 + .long 1073193236 + .long 3993278767 + .long 3162772855 + .long 19972402 + .long 1073201645 + .long 3507899862 + .long 1017057868 + .long 919555682 + .long 1073210099 + .long 3121969534 + .long 1013996802 + .long 1413356050 + .long 1073218599 + .long 1651349291 + .long 3163716742 + .long 2571947539 + .long 1073227145 + .long 3558159064 + .long 3164425245 + .long 1176749997 + .long 1073235738 + .long 2738998779 + .long 3163084420 + .long 2604962541 + .long 1073244377 + .long 2614425274 + .long 3164587768 + .long 3649726105 + .long 1073253063 + .long 4085036346 + .long 1016698050 + .long 1110089947 + .long 1073261797 + .long 1451641639 + .long 1016523249 + .long 380978316 + .long 1073270578 + .long 854188970 + .long 3161511262 + .long 2568320822 + .long 1073279406 + .long 2732824428 + .long 1015401491 + .long 194117574 + .long 1073288283 + .long 777528612 + .long 3164460665 + .long 2966275557 + .long 1073297207 + .long 2176155324 + .long 3160891335 + .long 3418903055 + .long 1073306180 + .long 2527457337 + .long 3161869180 + .long 2682146384 + .long 1073315202 + .long 2082178513 + .long 3164411995 + .long 1892288442 + .long 1073324273 + .long 2446255666 + .long 3163648957 + .long 2191782032 + .long 1073333393 + .long 2960257726 + .long 1014791238 + .long 434316067 + .long 1073342563 + .long 2028358766 + .long 1014506698 + .long 2069751141 + .long 1073351782 + .long 1562170675 + .long 3163773257 + .long 3964284211 + .long 1073361051 + .long 2111583915 + .long 1016475740 + .long 2990417245 + .long 1073370371 + .long 3683467745 + .long 3164417902 + .long 321958744 + .long 1073379742 + .long 3401933767 + .long 1016843134 + .long 1434058175 + .long 1073389163 + .long 251133233 + .long 1016134345 + .long 3218338682 + .long 1073398635 + .long 3404164304 + .long 3163525684 + .long 2572866477 + .long 1073408159 + .long 878562433 + .long 1016570317 + .long 697153126 + .long 1073417735 + .long 1283515429 + .long 3164331765 + .long 3092190715 + .long 1073427362 + .long 814012168 + .long 3160571998 + .long 2380618042 + .long 1073437042 + .long 3149557219 + .long 3164369375 + .long 4076559943 + .long 1073446774 + .long 2119478331 + .long 3161806927 + .long 815859274 + .long 1073456560 + .long 240396590 + .long 3164536019 + .long 2420883922 + .long 1073466398 + .long 2049810052 + .long 1015168464 + .long 1540824585 + .long 1073476290 + .long 1064017011 + .long 3164536266 + .long 3716502172 + .long 1073486235 + .long 2303740125 + .long 1015091301 + .long 1610600570 + .long 1073496235 + .long 3766732298 + .long 1016808759 + .long 777507147 + .long 1073506289 + .long 4282924205 + .long 1016236109 + .long 2483480501 + .long 1073516397 + .long 1216371780 + .long 1014082748 + .long 3706687593 + .long 1073526560 + .long 3521726940 + .long 1014301643 + .long 1432208378 + .long 1073536779 + .long 1401068914 + .long 3163412539 + .long 1242007932 + .long 1073547053 + .long 1132034716 + .long 3164388407 + .long 135105010 + .long 1073557383 + .long 1906148728 + .long 3164424315 + .long 3707479175 + .long 1073567768 + .long 3613079303 + .long 1015213314 + .long 382305176 + .long 1073578211 + .long 2347622376 + .long 3163627201 + .long 64696965 + .long 1073588710 + .long 1768797490 + .long 1016865536 + .long 4076975200 + .long 1073599265 + .long 2029000899 + .long 1016257111 + .long 863738719 + .long 1073609879 + .long 1326992220 + .long 3163661773 + .long 351641897 + .long 1073620550 + .long 2172261526 + .long 3164059175 + .long 3884662774 + .long 1073631278 + .long 2158611599 + .long 1015258761 + .long 4224142467 + .long 1073642065 + .long 3389820386 + .long 1016255778 + .long 2728693978 + .long 1073652911 + .long 396109971 + .long 3164511267 + .long 764307441 + .long 1073663816 + .long 3021057420 + .long 3164378099 + .long 3999357479 + .long 1073674779 + .long 2258941616 + .long 1016973300 + .long 929806999 + .long 1073685803 + .long 3205336643 + .long 1016308133 + .long 1533953344 + .long 1073696886 + .long 769171851 + .long 1016714209 + .long 2912730644 + .long 1073708029 + .long 3490067722 + .long 3164453650 + .long 2174652632 + .long 1073719233 + .long 4087714590 + .long 1015498835 + .long 730821105 + .long 1073730498 + .long 2523232743 + .long 1013115764 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 730821105 + .long 1072681922 + .long 2523232743 + .long 1012067188 + .long 2174652632 + .long 1072670657 + .long 4087714590 + .long 1014450259 + .long 2912730644 + .long 1072659453 + .long 3490067722 + .long 3163405074 + .long 1533953344 + .long 1072648310 + .long 769171851 + .long 1015665633 + .long 929806999 + .long 1072637227 + .long 3205336643 + .long 1015259557 + .long 3999357479 + .long 1072626203 + .long 2258941616 + .long 1015924724 + .long 764307441 + .long 1072615240 + .long 3021057420 + .long 3163329523 + .long 2728693978 + .long 1072604335 + .long 396109971 + .long 3163462691 + .long 4224142467 + .long 1072593489 + .long 3389820386 + .long 1015207202 + .long 3884662774 + .long 1072582702 + .long 2158611599 + .long 1014210185 + .long 351641897 + .long 1072571974 + .long 2172261526 + .long 3163010599 + .long 863738719 + .long 1072561303 + .long 1326992220 + .long 3162613197 + .long 4076975200 + .long 1072550689 + .long 2029000899 + .long 1015208535 + .long 64696965 + .long 1072540134 + .long 1768797490 + .long 1015816960 + .long 382305176 + .long 1072529635 + .long 2347622376 + .long 3162578625 + .long 3707479175 + .long 1072519192 + .long 3613079303 + .long 1014164738 + .long 135105010 + .long 1072508807 + .long 1906148728 + .long 3163375739 + .long 1242007932 + .long 1072498477 + .long 1132034716 + .long 3163339831 + .long 1432208378 + .long 1072488203 + .long 1401068914 + .long 3162363963 + .long 3706687593 + .long 1072477984 + .long 3521726940 + .long 1013253067 + .long 2483480501 + .long 1072467821 + .long 1216371780 + .long 1013034172 + .long 777507147 + .long 1072457713 + .long 4282924205 + .long 1015187533 + .long 1610600570 + .long 1072447659 + .long 3766732298 + .long 1015760183 + .long 3716502172 + .long 1072437659 + .long 2303740125 + .long 1014042725 + .long 1540824585 + .long 1072427714 + .long 1064017011 + .long 3163487690 + .long 2420883922 + .long 1072417822 + .long 2049810052 + .long 1014119888 + .long 815859274 + .long 1072407984 + .long 240396590 + .long 3163487443 + .long 4076559943 + .long 1072398198 + .long 2119478331 + .long 3160758351 + .long 2380618042 + .long 1072388466 + .long 3149557219 + .long 3163320799 + .long 3092190715 + .long 1072378786 + .long 814012168 + .long 3159523422 + .long 697153126 + .long 1072369159 + .long 1283515429 + .long 3163283189 + .long 2572866477 + .long 1072359583 + .long 878562433 + .long 1015521741 + .long 3218338682 + .long 1072350059 + .long 3404164304 + .long 3162477108 + .long 1434058175 + .long 1072340587 + .long 251133233 + .long 1015085769 + .long 321958744 + .long 1072331166 + .long 3401933767 + .long 1015794558 + .long 2990417245 + .long 1072321795 + .long 3683467745 + .long 3163369326 + .long 3964284211 + .long 1072312475 + .long 2111583915 + .long 1015427164 + .long 2069751141 + .long 1072303206 + .long 1562170675 + .long 3162724681 + .long 434316067 + .long 1072293987 + .long 2028358766 + .long 1013458122 + .long 2191782032 + .long 1072284817 + .long 2960257726 + .long 1013742662 + .long 1892288442 + .long 1072275697 + .long 2446255666 + .long 3162600381 + .long 2682146384 + .long 1072266626 + .long 2082178513 + .long 3163363419 + .long 3418903055 + .long 1072257604 + .long 2527457337 + .long 3160820604 + .long 2966275557 + .long 1072248631 + .long 2176155324 + .long 3159842759 + .long 194117574 + .long 1072239707 + .long 777528612 + .long 3163412089 + .long 2568320822 + .long 1072230830 + .long 2732824428 + .long 1014352915 + .long 380978316 + .long 1072222002 + .long 854188970 + .long 3160462686 + .long 1110089947 + .long 1072213221 + .long 1451641639 + .long 1015474673 + .long 3649726105 + .long 1072204487 + .long 4085036346 + .long 1015649474 + .long 2604962541 + .long 1072195801 + .long 2614425274 + .long 3163539192 + .long 1176749997 + .long 1072187162 + .long 2738998779 + .long 3162035844 + .long 2571947539 + .long 1072178569 + .long 3558159064 + .long 3163376669 + .long 1413356050 + .long 1072170023 + .long 1651349291 + .long 3162668166 + .long 919555682 + .long 1072161523 + .long 3121969534 + .long 1012948226 + .long 19972402 + .long 1072153069 + .long 3507899862 + .long 1016009292 + .long 1944781191 + .long 1072144660 + .long 3993278767 + .long 3161724279 + .long 1339972927 + .long 1072136297 + .long 167908909 + .long 1015572152 + .long 1447192521 + .long 1072127979 + .long 1462857171 + .long 3162514521 + .long 1218806132 + .long 1072119706 + .long 1818613052 + .long 3162548441 + .long 3907805044 + .long 1072111477 + .long 2257091225 + .long 3161550407 + .long 4182873220 + .long 1072103293 + .long 629542646 + .long 3161996303 + .long 1013258799 + .long 1072095154 + .long 1748797611 + .long 3160129082 + .long 1963711167 + .long 1072087058 + .long 1744767757 + .long 3160574294 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 3561793907 + .long 1072070997 + .long 1157054053 + .long 1011890350 + .long 2186617381 + .long 1072063032 + .long 2270764084 + .long 3163272713 + .long 885834528 + .long 1072055110 + .long 1973258547 + .long 3162261564 + .long 2956612997 + .long 1072047230 + .long 2118169751 + .long 3162735553 + .long 3111574537 + .long 1072039393 + .long 2606161479 + .long 3162759746 + .long 363667784 + .long 1072031599 + .long 813753950 + .long 1015785209 + .long 2321106615 + .long 1072023846 + .long 2171176610 + .long 1009535771 + .long 3712504873 + .long 1072016135 + .long 88491949 + .long 1015427660 + .long 3566716925 + .long 1072008466 + .long 1536826856 + .long 1014142433 + .long 917841882 + .long 1072000839 + .long 18715565 + .long 1015659308 + .long 3395129871 + .long 1071993252 + .long 4025345435 + .long 3162335388 + .long 1453150082 + .long 1071985707 + .long 498154669 + .long 3161488062 + .long 2731501122 + .long 1071978202 + .long 1774031855 + .long 3162470021 + .long 1990012071 + .long 1071970738 + .long 3529070563 + .long 3162813193 + .long 2583551245 + .long 1071963314 + .long 3161094195 + .long 1015606491 + .long 3577096743 + .long 1071955930 + .long 2951496418 + .long 1013793687 + .long 4040676318 + .long 1071948586 + .long 4090609238 + .long 1015663458 + .long 3049340112 + .long 1071941282 + .long 3062915824 + .long 1013170595 + .long 3978100823 + .long 1071934017 + .long 3513027190 + .long 1015845963 + .long 1617004845 + .long 1071926792 + .long 82804944 + .long 1010342778 + .long 3645941911 + .long 1071919605 + .long 3814685081 + .long 3161573341 + .long 569847338 + .long 1071912458 + .long 472945272 + .long 3159290729 + .long 78413852 + .long 1071905349 + .long 4183226867 + .long 3163017251 + .long 1276261410 + .long 1071898278 + .long 300981948 + .long 1014684169 + .long 3272845541 + .long 1071891245 + .long 928852419 + .long 3163488248 + .long 887463927 + .long 1071884251 + .long 3596744163 + .long 3160794166 + .long 1829099622 + .long 1071877294 + .long 1016661181 + .long 3163461005 + .long 926591435 + .long 1071870375 + .long 3208833762 + .long 3162913514 + .long 1603444721 + .long 1071863493 + .long 1548633640 + .long 3162201326 + .long 2992903935 + .long 1071856648 + .long 2218154406 + .long 1015228193 + .long 4232894513 + .long 1071849840 + .long 2383938684 + .long 1014668519 + .long 171030293 + .long 1071843070 + .long 3526460132 + .long 1014428778 + .long 2839424854 + .long 1071836335 + .long 1171596163 + .long 1013041679 + .long 2799960843 + .long 1071829637 + .long 1423655381 + .long 1015022151 + .long 3504003472 + .long 1071822975 + .long 3594001060 + .long 3157330652 + .long 4112506593 + .long 1071816349 + .long 2947355221 + .long 1014371048 + .long 3790955393 + .long 1071809759 + .long 2352942462 + .long 3163180090 + .long 1709341917 + .long 1071803205 + .long 2571168217 + .long 1014152499 + .long 1337108031 + .long 1071796686 + .long 3203724452 + .long 1014677845 + .long 1853186616 + .long 1071790202 + .long 3066496371 + .long 1015656574 + .long 2440944790 + .long 1071783753 + .long 2492769774 + .long 1014147454 + .long 2288159958 + .long 1071777339 + .long 2169144469 + .long 1014876021 + .long 586995997 + .long 1071770960 + .long 41662348 + .long 3162627992 + .long 828946858 + .long 1071764615 + .long 10642492 + .long 1015939438 + .long 2214878420 + .long 1071758304 + .long 892270087 + .long 3163116422 + .long 3949972341 + .long 1071752027 + .long 2068408548 + .long 1014913868 + .long 948735466 + .long 1071745785 + .long 3516338028 + .long 3162574883 + .long 1014845819 + .long 1071739576 + .long 3117910646 + .long 3161559105 + .long 3366293073 + .long 1071733400 + .long 3119426314 + .long 1014120554 + .long 2930322912 + .long 1071727258 + .long 2599499422 + .long 3162714047 + .long 3228316108 + .long 1071721149 + .long 3010241991 + .long 3158422804 + .long 3490863953 + .long 1071715073 + .long 960797498 + .long 3162948880 + .long 2952712987 + .long 1071709030 + .long 3293494651 + .long 3160120301 + .long 852742562 + .long 1071703020 + .long 667253586 + .long 1009793559 + .long 728909815 + .long 1071697042 + .long 383930225 + .long 1015029468 + .long 1828292879 + .long 1071691096 + .long 1255956747 + .long 1015588398 + .long 3402036099 + .long 1071685182 + .long 405889334 + .long 1015105656 + .long 410360776 + .long 1071679301 + .long 1269990655 + .long 1011975870 + .long 702412510 + .long 1071673451 + .long 3803266087 + .long 3162280415 + .long 3541402996 + .long 1071667632 + .long 2759177317 + .long 1014854626 + .long 3899555717 + .long 1071661845 + .long 427280750 + .long 3162546972 + .long 1048019041 + .long 1071656090 + .long 1398474845 + .long 3160510595 + .long 2851812149 + .long 1071650365 + .long 2595802551 + .long 1015767337 + .long 0 + .long 1127743488 + .long 0 + .long 3275227136 + .long 3607404736 + .long 1044146952 + .long 3607404736 + .long 3191630600 + .long 4277811695 + .long 1063661122 + .long 4277811695 + .long 3211144770 + .long 2140175755 + .long 1033864261 + .long 2140175755 + .long 1033864261 + .long 4289495988 + .long 1054113747 + .long 4289495988 + .long 1054113747 + .long 4277811695 + .long 1064709698 + .long 4277811695 + .long 1064709698 + .long 1610612736 + .long 1080497479 + .long 4166901572 + .long 1053077003 + .long 329805064 + .long 1038488134 + .long 2773927730 + .long 1053236707 + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1069897045 + .long 1744127201 + .long 1046144581 + .long 436314137 + .long 1059717536 + .long 0 + .long 4294967280 + .long 0 + .long 4294967280 + .long 4160749568 + .long 2147483647 + .type static_const_table,@object + .size static_const_table,4280 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sinhcosh_wmt.S b/external/sgx_libm/ia32/sinhcosh_wmt.S new file mode 100644 index 0000000000..fd0ad63143 --- /dev/null +++ b/external/sgx_libm/ia32/sinhcosh_wmt.S @@ -0,0 +1,1518 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinhcosh_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin sinhcosh + .text + .align 16,0x90 + .globl sinhcosh +sinhcosh: +# parameter 1: 8 + %ebp +# parameter 2: 16 + %ebp +# parameter 3: 20 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 64(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + movl 136(%esp), %eax + movl %eax, 24(%esp) + movl 140(%esp), %eax + movl %eax, 28(%esp) + movsd %xmm0, 16(%esp) + movsd 4320(%ebx), %xmm3 + xorpd %xmm4, %xmm4 + movsd 4192(%ebx), %xmm1 + movsd 4200(%ebx), %xmm2 + movl $32768, %eax + pinsrw $3, %eax, %xmm4 + movsd 4096(%ebx), %xmm6 + pextrw $3, %xmm0, %ecx + andpd %xmm0, %xmm3 + andnpd %xmm0, %xmm4 + pshufd $68, %xmm4, %xmm5 + movl $32768, %edx + andl %ecx, %edx + andl $32767, %ecx + subl $16343, %ecx + cmpl $177, %ecx + jae .L_2TAG_PACKET_0.0.3 + subsd %xmm3, %xmm4 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm2 + cvtsd2si %xmm3, %eax + shll $3, %edx + orl %edx, %eax + movapd %xmm3, %xmm7 + addsd %xmm6, %xmm3 + mulsd %xmm4, %xmm1 + xorpd %xmm5, %xmm5 + subsd %xmm6, %xmm3 + movapd 4112(%ebx), %xmm4 + addsd %xmm1, %xmm2 + movapd 4128(%ebx), %xmm6 + subsd %xmm3, %xmm7 + movl $32704, %edx + pinsrw $3, %edx, %xmm5 + movapd 4144(%ebx), %xmm1 + addsd %xmm7, %xmm2 + movl $127, %edx + andl %eax, %edx + addl %edx, %edx + shrl $3, %eax + andl $65520, %eax + addl $16352, %eax + xorpd %xmm0, %xmm0 + cmpl $161, %ecx + jae .L_2TAG_PACKET_1.0.3 + pshufd $68, %xmm5, %xmm5 + pinsrw $3, %eax, %xmm0 + pshufd $68, %xmm0, %xmm0 + psubw %xmm0, %xmm5 + mulpd (%ebx,%edx,8), %xmm0 + mulpd 2048(%ebx,%edx,8), %xmm5 + pshufd $68, %xmm2, %xmm3 + movapd 4160(%ebx), %xmm7 + pshufd $68, %xmm2, %xmm2 + mulpd %xmm3, %xmm3 + mulpd %xmm2, %xmm4 + mulpd %xmm2, %xmm6 + mulpd 4176(%ebx), %xmm2 + mulpd %xmm3, %xmm1 + mulpd %xmm3, %xmm7 + mulpd %xmm3, %xmm4 + mulpd %xmm3, %xmm1 + addpd %xmm7, %xmm6 + movapd %xmm0, %xmm7 + addpd %xmm1, %xmm4 + shufpd $0, %xmm5, %xmm7 + mulpd %xmm7, %xmm2 + shufpd $3, %xmm5, %xmm0 + addpd %xmm6, %xmm4 + mulpd %xmm2, %xmm4 + addpd %xmm0, %xmm4 + movapd %xmm7, %xmm1 + addpd %xmm2, %xmm4 + addpd %xmm4, %xmm1 + subpd %xmm1, %xmm7 + movapd %xmm1, %xmm0 + movapd %xmm1, %xmm5 + movapd %xmm1, %xmm6 + addpd %xmm7, %xmm4 + pshufd $238, %xmm1, %xmm2 + movapd %xmm4, %xmm3 + pshufd $238, %xmm4, %xmm7 + addsd %xmm2, %xmm1 + subsd %xmm2, %xmm0 + addsd %xmm7, %xmm4 + subsd %xmm7, %xmm3 + subsd %xmm1, %xmm5 + movsd 4352(%ebx), %xmm7 + subsd %xmm0, %xmm6 + addsd %xmm2, %xmm5 + subsd %xmm2, %xmm6 + addsd %xmm5, %xmm4 + addsd %xmm6, %xmm3 + addsd %xmm4, %xmm1 + addsd %xmm3, %xmm0 + andpd %xmm7, %xmm1 + movl 24(%esp), %eax + movsd %xmm0, (%eax) + movl 28(%esp), %ecx + movsd %xmm1, (%ecx) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + subl $16352, %eax + movl %eax, %ecx + andl $32752, %eax + shrl $1, %eax + andl $65520, %eax + subl %eax, %ecx + addl $16352, %eax + pinsrw $3, %eax, %xmm0 + pshufd $68, %xmm0, %xmm0 + mulpd (%ebx,%edx,8), %xmm0 + pshufd $68, %xmm2, %xmm3 + movsd 4160(%ebx), %xmm7 + mulsd %xmm3, %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm6 + mulsd 4176(%ebx), %xmm2 + mulsd %xmm3, %xmm1 + mulsd %xmm3, %xmm7 + mulsd %xmm3, %xmm4 + addl $16368, %ecx + pinsrw $3, %ecx, %xmm5 + mulsd %xmm3, %xmm1 + addsd %xmm7, %xmm6 + addsd %xmm1, %xmm4 + mulsd %xmm0, %xmm2 + addsd %xmm6, %xmm4 + mulsd %xmm2, %xmm4 + pshufd $238, %xmm0, %xmm6 + addsd %xmm6, %xmm4 + movsd 4352(%ebx), %xmm1 + addsd %xmm4, %xmm2 + addsd %xmm2, %xmm0 + mulsd %xmm5, %xmm0 + pextrw $3, %xmm0, %eax + andpd %xmm0, %xmm1 + andl $32752, %eax + movl $229, %edx + cmpl $32752, %eax + je .L_2TAG_PACKET_3.0.3 + movl 24(%esp), %eax + movsd %xmm0, (%eax) + movl 28(%esp), %eax + movsd %xmm1, (%eax) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + addl $16343, %ecx + cmpl $16343, %ecx + ja .L_2TAG_PACKET_4.0.3 + cmpl $15856, %ecx + jb .L_2TAG_PACKET_5.0.3 + movapd 4208(%ebx), %xmm1 + pshufd $68, %xmm0, %xmm6 + mulpd %xmm5, %xmm5 + movapd 4224(%ebx), %xmm2 + pshufd $68, %xmm0, %xmm7 + movapd 4240(%ebx), %xmm3 + pshufd $68, %xmm0, %xmm4 + andpd 4304(%ebx), %xmm6 + mulpd %xmm5, %xmm1 + mulsd %xmm5, %xmm2 + subpd %xmm6, %xmm4 + mulpd %xmm5, %xmm7 + addpd %xmm3, %xmm1 + pshufd $68, %xmm6, %xmm3 + mulpd %xmm5, %xmm5 + mulsd %xmm7, %xmm2 + mulpd %xmm7, %xmm1 + pshufd $68, %xmm0, %xmm7 + mulsd %xmm6, %xmm6 + addsd %xmm7, %xmm7 + mulsd %xmm4, %xmm4 + mulpd %xmm5, %xmm1 + addsd %xmm0, %xmm7 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm7 + pshufd $238, %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm2, %xmm3 + pshufd $238, %xmm2, %xmm2 + addsd %xmm4, %xmm7 + movapd %xmm0, %xmm4 + mulsd %xmm2, %xmm6 + mulsd %xmm5, %xmm7 + addsd %xmm6, %xmm0 + mulsd %xmm2, %xmm7 + subsd %xmm0, %xmm4 + addsd %xmm7, %xmm1 + addsd %xmm4, %xmm6 + addsd %xmm3, %xmm1 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm0 + movl 24(%esp), %eax + movsd %xmm0, (%eax) + movsd 16(%esp), %xmm5 + pshufd $68, %xmm5, %xmm5 + movapd 4256(%ebx), %xmm1 + mulpd %xmm5, %xmm5 + movapd 4272(%ebx), %xmm2 + xorpd %xmm3, %xmm3 + movsd 4288(%ebx), %xmm7 + movapd %xmm5, %xmm0 + mulpd %xmm5, %xmm1 + movsd 4336(%ebx), %xmm6 + mulpd %xmm5, %xmm5 + movl $16352, %eax + pinsrw $3, %eax, %xmm3 + addpd %xmm2, %xmm1 + mulsd %xmm5, %xmm7 + mulpd %xmm5, %xmm1 + mulsd %xmm5, %xmm7 + pshufd $238, %xmm1, %xmm2 + mulsd %xmm5, %xmm1 + mulsd %xmm5, %xmm7 + mulsd %xmm3, %xmm0 + addsd %xmm2, %xmm1 + addsd %xmm7, %xmm1 + addsd %xmm0, %xmm1 + addsd %xmm6, %xmm1 + movl 28(%esp), %ecx + movsd %xmm1, (%ecx) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_5.0.3: + movsd 4336(%ebx), %xmm1 + cmpl $16, %ecx + jae .L_2TAG_PACKET_6.0.3 + movapd %xmm0, %xmm2 + mulsd %xmm2, %xmm2 + movl 24(%esp), %eax + movsd %xmm0, (%eax) + movl 28(%esp), %ecx + movsd %xmm1, (%ecx) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_6.0.3: + xorpd %xmm2, %xmm2 + movl $17392, %ecx + pinsrw $3, %ecx, %xmm2 + xorpd %xmm3, %xmm3 + movl $15344, %edx + pinsrw $3, %edx, %xmm3 + mulsd %xmm0, %xmm2 + addsd %xmm2, %xmm0 + mulsd %xmm3, %xmm0 + movl 24(%esp), %eax + movsd %xmm0, (%eax) + movl 28(%esp), %ecx + movsd %xmm1, (%ecx) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + cmpl $32752, %ecx + jae .L_2TAG_PACKET_7.0.3 + movsd 4352(%ebx), %xmm3 + xorpd %xmm0, %xmm0 + movl $32736, %eax + pinsrw $3, %eax, %xmm0 + orl %edx, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + movapd %xmm0, %xmm1 + andpd %xmm3, %xmm1 + movl $229, %edx +.L_2TAG_PACKET_3.0.3: + movsd %xmm0, (%esp) + movsd %xmm1, 8(%esp) + movsd 16(%esp), %xmm0 + subl $32, %esp + lea 128(%esp), %eax + movl %eax, (%esp) + lea 136(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + movsd (%esp), %xmm0 + movsd 8(%esp), %xmm1 + movl 24(%esp), %eax + movsd %xmm0, (%eax) + movl 28(%esp), %ecx + movsd %xmm1, (%ecx) + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_7.0.3: + xorpd %xmm1, %xmm1 + movl $32768, %eax + pinsrw $3, %eax, %xmm2 + andnpd %xmm0, %xmm2 + mulsd %xmm2, %xmm0 + movapd %xmm0, %xmm1 + movd %xmm0, %edx + movapd %xmm0, %xmm3 + cmpl $0, %edx + jne .L_2TAG_PACKET_8.0.3 + psrlq $20, %xmm3 + movd %xmm3, %ecx + cmpl $0, %ecx + jne .L_2TAG_PACKET_8.0.3 + movapd %xmm2, %xmm1 +.L_2TAG_PACKET_8.0.3: + movl 24(%esp), %eax + movsd %xmm0, (%eax) + movl 28(%esp), %ecx + movsd %xmm1, (%ecx) +.L_2TAG_PACKET_2.0.3: + movl 64(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type sinhcosh,@function + .size sinhcosh,.-sinhcosh + .data +# -- End sinhcosh + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 2851812149 + .long 1072698941 + .long 2595802551 + .long 1016815913 + .long 1048019041 + .long 1072704666 + .long 1398474845 + .long 3161559171 + .long 3899555717 + .long 1072710421 + .long 427280750 + .long 3163595548 + .long 3541402996 + .long 1072716208 + .long 2759177317 + .long 1015903202 + .long 702412510 + .long 1072722027 + .long 3803266087 + .long 3163328991 + .long 410360776 + .long 1072727877 + .long 1269990655 + .long 1013024446 + .long 3402036099 + .long 1072733758 + .long 405889334 + .long 1016154232 + .long 1828292879 + .long 1072739672 + .long 1255956747 + .long 1016636974 + .long 728909815 + .long 1072745618 + .long 383930225 + .long 1016078044 + .long 852742562 + .long 1072751596 + .long 667253586 + .long 1010842135 + .long 2952712987 + .long 1072757606 + .long 3293494651 + .long 3161168877 + .long 3490863953 + .long 1072763649 + .long 960797498 + .long 3163997456 + .long 3228316108 + .long 1072769725 + .long 3010241991 + .long 3159471380 + .long 2930322912 + .long 1072775834 + .long 2599499422 + .long 3163762623 + .long 3366293073 + .long 1072781976 + .long 3119426314 + .long 1015169130 + .long 1014845819 + .long 1072788152 + .long 3117910646 + .long 3162607681 + .long 948735466 + .long 1072794361 + .long 3516338028 + .long 3163623459 + .long 3949972341 + .long 1072800603 + .long 2068408548 + .long 1015962444 + .long 2214878420 + .long 1072806880 + .long 892270087 + .long 3164164998 + .long 828946858 + .long 1072813191 + .long 10642492 + .long 1016988014 + .long 586995997 + .long 1072819536 + .long 41662348 + .long 3163676568 + .long 2288159958 + .long 1072825915 + .long 2169144469 + .long 1015924597 + .long 2440944790 + .long 1072832329 + .long 2492769774 + .long 1015196030 + .long 1853186616 + .long 1072838778 + .long 3066496371 + .long 1016705150 + .long 1337108031 + .long 1072845262 + .long 3203724452 + .long 1015726421 + .long 1709341917 + .long 1072851781 + .long 2571168217 + .long 1015201075 + .long 3790955393 + .long 1072858335 + .long 2352942462 + .long 3164228666 + .long 4112506593 + .long 1072864925 + .long 2947355221 + .long 1015419624 + .long 3504003472 + .long 1072871551 + .long 3594001060 + .long 3158379228 + .long 2799960843 + .long 1072878213 + .long 1423655381 + .long 1016070727 + .long 2839424854 + .long 1072884911 + .long 1171596163 + .long 1014090255 + .long 171030293 + .long 1072891646 + .long 3526460132 + .long 1015477354 + .long 4232894513 + .long 1072898416 + .long 2383938684 + .long 1015717095 + .long 2992903935 + .long 1072905224 + .long 2218154406 + .long 1016276769 + .long 1603444721 + .long 1072912069 + .long 1548633640 + .long 3163249902 + .long 926591435 + .long 1072918951 + .long 3208833762 + .long 3163962090 + .long 1829099622 + .long 1072925870 + .long 1016661181 + .long 3164509581 + .long 887463927 + .long 1072932827 + .long 3596744163 + .long 3161842742 + .long 3272845541 + .long 1072939821 + .long 928852419 + .long 3164536824 + .long 1276261410 + .long 1072946854 + .long 300981948 + .long 1015732745 + .long 78413852 + .long 1072953925 + .long 4183226867 + .long 3164065827 + .long 569847338 + .long 1072961034 + .long 472945272 + .long 3160339305 + .long 3645941911 + .long 1072968181 + .long 3814685081 + .long 3162621917 + .long 1617004845 + .long 1072975368 + .long 82804944 + .long 1011391354 + .long 3978100823 + .long 1072982593 + .long 3513027190 + .long 1016894539 + .long 3049340112 + .long 1072989858 + .long 3062915824 + .long 1014219171 + .long 4040676318 + .long 1072997162 + .long 4090609238 + .long 1016712034 + .long 3577096743 + .long 1073004506 + .long 2951496418 + .long 1014842263 + .long 2583551245 + .long 1073011890 + .long 3161094195 + .long 1016655067 + .long 1990012071 + .long 1073019314 + .long 3529070563 + .long 3163861769 + .long 2731501122 + .long 1073026778 + .long 1774031855 + .long 3163518597 + .long 1453150082 + .long 1073034283 + .long 498154669 + .long 3162536638 + .long 3395129871 + .long 1073041828 + .long 4025345435 + .long 3163383964 + .long 917841882 + .long 1073049415 + .long 18715565 + .long 1016707884 + .long 3566716925 + .long 1073057042 + .long 1536826856 + .long 1015191009 + .long 3712504873 + .long 1073064711 + .long 88491949 + .long 1016476236 + .long 2321106615 + .long 1073072422 + .long 2171176610 + .long 1010584347 + .long 363667784 + .long 1073080175 + .long 813753950 + .long 1016833785 + .long 3111574537 + .long 1073087969 + .long 2606161479 + .long 3163808322 + .long 2956612997 + .long 1073095806 + .long 2118169751 + .long 3163784129 + .long 885834528 + .long 1073103686 + .long 1973258547 + .long 3163310140 + .long 2186617381 + .long 1073111608 + .long 2270764084 + .long 3164321289 + .long 3561793907 + .long 1073119573 + .long 1157054053 + .long 1012938926 + .long 1719614413 + .long 1073127582 + .long 330458198 + .long 3164331316 + .long 1963711167 + .long 1073135634 + .long 1744767757 + .long 3161622870 + .long 1013258799 + .long 1073143730 + .long 1748797611 + .long 3161177658 + .long 4182873220 + .long 1073151869 + .long 629542646 + .long 3163044879 + .long 3907805044 + .long 1073160053 + .long 2257091225 + .long 3162598983 + .long 1218806132 + .long 1073168282 + .long 1818613052 + .long 3163597017 + .long 1447192521 + .long 1073176555 + .long 1462857171 + .long 3163563097 + .long 1339972927 + .long 1073184873 + .long 167908909 + .long 1016620728 + .long 1944781191 + .long 1073193236 + .long 3993278767 + .long 3162772855 + .long 19972402 + .long 1073201645 + .long 3507899862 + .long 1017057868 + .long 919555682 + .long 1073210099 + .long 3121969534 + .long 1013996802 + .long 1413356050 + .long 1073218599 + .long 1651349291 + .long 3163716742 + .long 2571947539 + .long 1073227145 + .long 3558159064 + .long 3164425245 + .long 1176749997 + .long 1073235738 + .long 2738998779 + .long 3163084420 + .long 2604962541 + .long 1073244377 + .long 2614425274 + .long 3164587768 + .long 3649726105 + .long 1073253063 + .long 4085036346 + .long 1016698050 + .long 1110089947 + .long 1073261797 + .long 1451641639 + .long 1016523249 + .long 380978316 + .long 1073270578 + .long 854188970 + .long 3161511262 + .long 2568320822 + .long 1073279406 + .long 2732824428 + .long 1015401491 + .long 194117574 + .long 1073288283 + .long 777528612 + .long 3164460665 + .long 2966275557 + .long 1073297207 + .long 2176155324 + .long 3160891335 + .long 3418903055 + .long 1073306180 + .long 2527457337 + .long 3161869180 + .long 2682146384 + .long 1073315202 + .long 2082178513 + .long 3164411995 + .long 1892288442 + .long 1073324273 + .long 2446255666 + .long 3163648957 + .long 2191782032 + .long 1073333393 + .long 2960257726 + .long 1014791238 + .long 434316067 + .long 1073342563 + .long 2028358766 + .long 1014506698 + .long 2069751141 + .long 1073351782 + .long 1562170675 + .long 3163773257 + .long 3964284211 + .long 1073361051 + .long 2111583915 + .long 1016475740 + .long 2990417245 + .long 1073370371 + .long 3683467745 + .long 3164417902 + .long 321958744 + .long 1073379742 + .long 3401933767 + .long 1016843134 + .long 1434058175 + .long 1073389163 + .long 251133233 + .long 1016134345 + .long 3218338682 + .long 1073398635 + .long 3404164304 + .long 3163525684 + .long 2572866477 + .long 1073408159 + .long 878562433 + .long 1016570317 + .long 697153126 + .long 1073417735 + .long 1283515429 + .long 3164331765 + .long 3092190715 + .long 1073427362 + .long 814012168 + .long 3160571998 + .long 2380618042 + .long 1073437042 + .long 3149557219 + .long 3164369375 + .long 4076559943 + .long 1073446774 + .long 2119478331 + .long 3161806927 + .long 815859274 + .long 1073456560 + .long 240396590 + .long 3164536019 + .long 2420883922 + .long 1073466398 + .long 2049810052 + .long 1015168464 + .long 1540824585 + .long 1073476290 + .long 1064017011 + .long 3164536266 + .long 3716502172 + .long 1073486235 + .long 2303740125 + .long 1015091301 + .long 1610600570 + .long 1073496235 + .long 3766732298 + .long 1016808759 + .long 777507147 + .long 1073506289 + .long 4282924205 + .long 1016236109 + .long 2483480501 + .long 1073516397 + .long 1216371780 + .long 1014082748 + .long 3706687593 + .long 1073526560 + .long 3521726940 + .long 1014301643 + .long 1432208378 + .long 1073536779 + .long 1401068914 + .long 3163412539 + .long 1242007932 + .long 1073547053 + .long 1132034716 + .long 3164388407 + .long 135105010 + .long 1073557383 + .long 1906148728 + .long 3164424315 + .long 3707479175 + .long 1073567768 + .long 3613079303 + .long 1015213314 + .long 382305176 + .long 1073578211 + .long 2347622376 + .long 3163627201 + .long 64696965 + .long 1073588710 + .long 1768797490 + .long 1016865536 + .long 4076975200 + .long 1073599265 + .long 2029000899 + .long 1016257111 + .long 863738719 + .long 1073609879 + .long 1326992220 + .long 3163661773 + .long 351641897 + .long 1073620550 + .long 2172261526 + .long 3164059175 + .long 3884662774 + .long 1073631278 + .long 2158611599 + .long 1015258761 + .long 4224142467 + .long 1073642065 + .long 3389820386 + .long 1016255778 + .long 2728693978 + .long 1073652911 + .long 396109971 + .long 3164511267 + .long 764307441 + .long 1073663816 + .long 3021057420 + .long 3164378099 + .long 3999357479 + .long 1073674779 + .long 2258941616 + .long 1016973300 + .long 929806999 + .long 1073685803 + .long 3205336643 + .long 1016308133 + .long 1533953344 + .long 1073696886 + .long 769171851 + .long 1016714209 + .long 2912730644 + .long 1073708029 + .long 3490067722 + .long 3164453650 + .long 2174652632 + .long 1073719233 + .long 4087714590 + .long 1015498835 + .long 730821105 + .long 1073730498 + .long 2523232743 + .long 1013115764 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 730821105 + .long 1072681922 + .long 2523232743 + .long 1012067188 + .long 2174652632 + .long 1072670657 + .long 4087714590 + .long 1014450259 + .long 2912730644 + .long 1072659453 + .long 3490067722 + .long 3163405074 + .long 1533953344 + .long 1072648310 + .long 769171851 + .long 1015665633 + .long 929806999 + .long 1072637227 + .long 3205336643 + .long 1015259557 + .long 3999357479 + .long 1072626203 + .long 2258941616 + .long 1015924724 + .long 764307441 + .long 1072615240 + .long 3021057420 + .long 3163329523 + .long 2728693978 + .long 1072604335 + .long 396109971 + .long 3163462691 + .long 4224142467 + .long 1072593489 + .long 3389820386 + .long 1015207202 + .long 3884662774 + .long 1072582702 + .long 2158611599 + .long 1014210185 + .long 351641897 + .long 1072571974 + .long 2172261526 + .long 3163010599 + .long 863738719 + .long 1072561303 + .long 1326992220 + .long 3162613197 + .long 4076975200 + .long 1072550689 + .long 2029000899 + .long 1015208535 + .long 64696965 + .long 1072540134 + .long 1768797490 + .long 1015816960 + .long 382305176 + .long 1072529635 + .long 2347622376 + .long 3162578625 + .long 3707479175 + .long 1072519192 + .long 3613079303 + .long 1014164738 + .long 135105010 + .long 1072508807 + .long 1906148728 + .long 3163375739 + .long 1242007932 + .long 1072498477 + .long 1132034716 + .long 3163339831 + .long 1432208378 + .long 1072488203 + .long 1401068914 + .long 3162363963 + .long 3706687593 + .long 1072477984 + .long 3521726940 + .long 1013253067 + .long 2483480501 + .long 1072467821 + .long 1216371780 + .long 1013034172 + .long 777507147 + .long 1072457713 + .long 4282924205 + .long 1015187533 + .long 1610600570 + .long 1072447659 + .long 3766732298 + .long 1015760183 + .long 3716502172 + .long 1072437659 + .long 2303740125 + .long 1014042725 + .long 1540824585 + .long 1072427714 + .long 1064017011 + .long 3163487690 + .long 2420883922 + .long 1072417822 + .long 2049810052 + .long 1014119888 + .long 815859274 + .long 1072407984 + .long 240396590 + .long 3163487443 + .long 4076559943 + .long 1072398198 + .long 2119478331 + .long 3160758351 + .long 2380618042 + .long 1072388466 + .long 3149557219 + .long 3163320799 + .long 3092190715 + .long 1072378786 + .long 814012168 + .long 3159523422 + .long 697153126 + .long 1072369159 + .long 1283515429 + .long 3163283189 + .long 2572866477 + .long 1072359583 + .long 878562433 + .long 1015521741 + .long 3218338682 + .long 1072350059 + .long 3404164304 + .long 3162477108 + .long 1434058175 + .long 1072340587 + .long 251133233 + .long 1015085769 + .long 321958744 + .long 1072331166 + .long 3401933767 + .long 1015794558 + .long 2990417245 + .long 1072321795 + .long 3683467745 + .long 3163369326 + .long 3964284211 + .long 1072312475 + .long 2111583915 + .long 1015427164 + .long 2069751141 + .long 1072303206 + .long 1562170675 + .long 3162724681 + .long 434316067 + .long 1072293987 + .long 2028358766 + .long 1013458122 + .long 2191782032 + .long 1072284817 + .long 2960257726 + .long 1013742662 + .long 1892288442 + .long 1072275697 + .long 2446255666 + .long 3162600381 + .long 2682146384 + .long 1072266626 + .long 2082178513 + .long 3163363419 + .long 3418903055 + .long 1072257604 + .long 2527457337 + .long 3160820604 + .long 2966275557 + .long 1072248631 + .long 2176155324 + .long 3159842759 + .long 194117574 + .long 1072239707 + .long 777528612 + .long 3163412089 + .long 2568320822 + .long 1072230830 + .long 2732824428 + .long 1014352915 + .long 380978316 + .long 1072222002 + .long 854188970 + .long 3160462686 + .long 1110089947 + .long 1072213221 + .long 1451641639 + .long 1015474673 + .long 3649726105 + .long 1072204487 + .long 4085036346 + .long 1015649474 + .long 2604962541 + .long 1072195801 + .long 2614425274 + .long 3163539192 + .long 1176749997 + .long 1072187162 + .long 2738998779 + .long 3162035844 + .long 2571947539 + .long 1072178569 + .long 3558159064 + .long 3163376669 + .long 1413356050 + .long 1072170023 + .long 1651349291 + .long 3162668166 + .long 919555682 + .long 1072161523 + .long 3121969534 + .long 1012948226 + .long 19972402 + .long 1072153069 + .long 3507899862 + .long 1016009292 + .long 1944781191 + .long 1072144660 + .long 3993278767 + .long 3161724279 + .long 1339972927 + .long 1072136297 + .long 167908909 + .long 1015572152 + .long 1447192521 + .long 1072127979 + .long 1462857171 + .long 3162514521 + .long 1218806132 + .long 1072119706 + .long 1818613052 + .long 3162548441 + .long 3907805044 + .long 1072111477 + .long 2257091225 + .long 3161550407 + .long 4182873220 + .long 1072103293 + .long 629542646 + .long 3161996303 + .long 1013258799 + .long 1072095154 + .long 1748797611 + .long 3160129082 + .long 1963711167 + .long 1072087058 + .long 1744767757 + .long 3160574294 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 3561793907 + .long 1072070997 + .long 1157054053 + .long 1011890350 + .long 2186617381 + .long 1072063032 + .long 2270764084 + .long 3163272713 + .long 885834528 + .long 1072055110 + .long 1973258547 + .long 3162261564 + .long 2956612997 + .long 1072047230 + .long 2118169751 + .long 3162735553 + .long 3111574537 + .long 1072039393 + .long 2606161479 + .long 3162759746 + .long 363667784 + .long 1072031599 + .long 813753950 + .long 1015785209 + .long 2321106615 + .long 1072023846 + .long 2171176610 + .long 1009535771 + .long 3712504873 + .long 1072016135 + .long 88491949 + .long 1015427660 + .long 3566716925 + .long 1072008466 + .long 1536826856 + .long 1014142433 + .long 917841882 + .long 1072000839 + .long 18715565 + .long 1015659308 + .long 3395129871 + .long 1071993252 + .long 4025345435 + .long 3162335388 + .long 1453150082 + .long 1071985707 + .long 498154669 + .long 3161488062 + .long 2731501122 + .long 1071978202 + .long 1774031855 + .long 3162470021 + .long 1990012071 + .long 1071970738 + .long 3529070563 + .long 3162813193 + .long 2583551245 + .long 1071963314 + .long 3161094195 + .long 1015606491 + .long 3577096743 + .long 1071955930 + .long 2951496418 + .long 1013793687 + .long 4040676318 + .long 1071948586 + .long 4090609238 + .long 1015663458 + .long 3049340112 + .long 1071941282 + .long 3062915824 + .long 1013170595 + .long 3978100823 + .long 1071934017 + .long 3513027190 + .long 1015845963 + .long 1617004845 + .long 1071926792 + .long 82804944 + .long 1010342778 + .long 3645941911 + .long 1071919605 + .long 3814685081 + .long 3161573341 + .long 569847338 + .long 1071912458 + .long 472945272 + .long 3159290729 + .long 78413852 + .long 1071905349 + .long 4183226867 + .long 3163017251 + .long 1276261410 + .long 1071898278 + .long 300981948 + .long 1014684169 + .long 3272845541 + .long 1071891245 + .long 928852419 + .long 3163488248 + .long 887463927 + .long 1071884251 + .long 3596744163 + .long 3160794166 + .long 1829099622 + .long 1071877294 + .long 1016661181 + .long 3163461005 + .long 926591435 + .long 1071870375 + .long 3208833762 + .long 3162913514 + .long 1603444721 + .long 1071863493 + .long 1548633640 + .long 3162201326 + .long 2992903935 + .long 1071856648 + .long 2218154406 + .long 1015228193 + .long 4232894513 + .long 1071849840 + .long 2383938684 + .long 1014668519 + .long 171030293 + .long 1071843070 + .long 3526460132 + .long 1014428778 + .long 2839424854 + .long 1071836335 + .long 1171596163 + .long 1013041679 + .long 2799960843 + .long 1071829637 + .long 1423655381 + .long 1015022151 + .long 3504003472 + .long 1071822975 + .long 3594001060 + .long 3157330652 + .long 4112506593 + .long 1071816349 + .long 2947355221 + .long 1014371048 + .long 3790955393 + .long 1071809759 + .long 2352942462 + .long 3163180090 + .long 1709341917 + .long 1071803205 + .long 2571168217 + .long 1014152499 + .long 1337108031 + .long 1071796686 + .long 3203724452 + .long 1014677845 + .long 1853186616 + .long 1071790202 + .long 3066496371 + .long 1015656574 + .long 2440944790 + .long 1071783753 + .long 2492769774 + .long 1014147454 + .long 2288159958 + .long 1071777339 + .long 2169144469 + .long 1014876021 + .long 586995997 + .long 1071770960 + .long 41662348 + .long 3162627992 + .long 828946858 + .long 1071764615 + .long 10642492 + .long 1015939438 + .long 2214878420 + .long 1071758304 + .long 892270087 + .long 3163116422 + .long 3949972341 + .long 1071752027 + .long 2068408548 + .long 1014913868 + .long 948735466 + .long 1071745785 + .long 3516338028 + .long 3162574883 + .long 1014845819 + .long 1071739576 + .long 3117910646 + .long 3161559105 + .long 3366293073 + .long 1071733400 + .long 3119426314 + .long 1014120554 + .long 2930322912 + .long 1071727258 + .long 2599499422 + .long 3162714047 + .long 3228316108 + .long 1071721149 + .long 3010241991 + .long 3158422804 + .long 3490863953 + .long 1071715073 + .long 960797498 + .long 3162948880 + .long 2952712987 + .long 1071709030 + .long 3293494651 + .long 3160120301 + .long 852742562 + .long 1071703020 + .long 667253586 + .long 1009793559 + .long 728909815 + .long 1071697042 + .long 383930225 + .long 1015029468 + .long 1828292879 + .long 1071691096 + .long 1255956747 + .long 1015588398 + .long 3402036099 + .long 1071685182 + .long 405889334 + .long 1015105656 + .long 410360776 + .long 1071679301 + .long 1269990655 + .long 1011975870 + .long 702412510 + .long 1071673451 + .long 3803266087 + .long 3162280415 + .long 3541402996 + .long 1071667632 + .long 2759177317 + .long 1014854626 + .long 3899555717 + .long 1071661845 + .long 427280750 + .long 3162546972 + .long 1048019041 + .long 1071656090 + .long 1398474845 + .long 3160510595 + .long 2851812149 + .long 1071650365 + .long 2595802551 + .long 1015767337 + .long 0 + .long 1127743488 + .long 0 + .long 3275227136 + .long 3607404736 + .long 1044146952 + .long 3607404736 + .long 3191630600 + .long 4277811695 + .long 1063661122 + .long 4277811695 + .long 3211144770 + .long 2140175755 + .long 1033864261 + .long 2140175755 + .long 1033864261 + .long 4289495988 + .long 1054113747 + .long 4289495988 + .long 1054113747 + .long 4277811695 + .long 1064709698 + .long 4277811695 + .long 3212193346 + .long 1610612736 + .long 1080497479 + .long 4166901572 + .long 1053077003 + .long 329805064 + .long 1038488134 + .long 2773927730 + .long 1053236707 + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1069897045 + .long 1744127201 + .long 1046144581 + .long 436314137 + .long 1059717536 + .long 3078135644 + .long 1049787983 + .long 381774870 + .long 1062650220 + .long 436314137 + .long 1056571808 + .long 1431655765 + .long 1067799893 + .long 1835802424 + .long 1042411711 + .long 1431655765 + .long 1067799893 + .long 0 + .long 4294967280 + .long 0 + .long 4294967280 + .long 4160749568 + .long 2147483647 + .long 4160749568 + .long 2147483647 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .type static_const_table,@object + .size static_const_table,4368 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sinhcoshl.S b/external/sgx_libm/ia32/sinhcoshl.S new file mode 100644 index 0000000000..3bfad5c3f1 --- /dev/null +++ b/external/sgx_libm/ia32/sinhcoshl.S @@ -0,0 +1,1273 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinhcoshl.c" + .text +..TXTST0: +# -- Begin sinhcoshl + .text + .align 16,0x90 + .globl sinhcoshl +sinhcoshl: +# parameter 1: 8 + %ebp +# parameter 2: 20 + %ebp +# parameter 3: 24 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $100, %esp + movl 20(%ebp), %esi + movl 24(%ebp), %ebx +..B1.2: + fnstcw 62(%esp) +..B1.3: + movzwl 16(%ebp), %edx + andl $32767, %edx + movl 12(%ebp), %edi + movl %edx, %eax + movl %edi, (%esp) + shll $16, %eax + shrl $16, %edi + movzbl 17(%ebp), %ecx + orl %edi, %eax + andl $128, %ecx + shrl $7, %ecx + cmpl $1073992020, %eax + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + jae ..B1.53 +..B1.4: + movzwl 62(%esp), %edi + cmpl $16382, %edx + movl %edi, (%esp) + jge ..B1.46 +..B1.5: + cmpl $16378, %edx + jge ..B1.39 +..B1.6: + cmpl $16372, %edx + jge ..B1.32 +..B1.7: + cmpl $16365, %edx + jge ..B1.25 +..B1.8: + cmpl $16308, %edx + jge ..B1.18 +..B1.9: + andl $768, %edi + cmpl $768, %edi + je ..B1.76 +..B1.10: + movl (%esp), %edx + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.11: + fldcw 60(%esp) +..B1.12: + movzbl 17(%ebp), %ecx + movl $1, %edi + andl $128, %ecx + movzwl 16(%ebp), %edx + shrl $7, %ecx + andl $32767, %edx +..B1.13: + testl %edx, %edx + jle ..B1.72 +..B1.14: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%eax) + fmul %st(1), %st + fadd %st(1), %st + fmull 8+_TWO_75@GOTOFF(%eax) + fstpt (%esp) +..B1.15: + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + testl %edi, %edi + fxch %st(1) + fmull ones@GOTOFF(%eax,%ecx,8) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.17 +..B1.16: + fldcw 62(%esp) +..B1.17: + fldt (%esp) + fstpt (%esi) + fldt 16(%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + movl %edi, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.77 +..B1.19: + movl %edi, %edx + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.20: + fldcw 60(%esp) +..B1.21: + movl $1, %edx +..B1.22: + fldt 8(%ebp) + testl %edx, %edx + fld %st(0) + fmul %st(1), %st + fldt _PS3@GOTOFF(%eax) + fmul %st(1), %st + fmul %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fldt _PC3@GOTOFF(%eax) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.24 +..B1.23: + fldcw 62(%esp) +..B1.24: + fldt (%esp) + fstpt (%esi) + fldt 16(%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %edi, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.78 +..B1.26: + movl %edi, %edx + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.27: + fldcw 60(%esp) +..B1.28: + movl $1, %edx +..B1.29: + fldt 8(%ebp) + testl %edx, %edx + fld %st(0) + fmul %st(1), %st + fldt 12+_PS2@GOTOFF(%eax) + fmul %st(1), %st + fldt _PS2@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fldt 12+_PC2@GOTOFF(%eax) + fmul %st(1), %st + fldt _PC2@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.31 +..B1.30: + fldcw 62(%esp) +..B1.31: + fldt (%esp) + fstpt (%esi) + fldt 16(%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movl %edi, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.79 +..B1.33: + movl %edi, %edx + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.34: + fldcw 60(%esp) +..B1.35: + movl $1, %edx +..B1.36: + fldt 8(%ebp) + testl %edx, %edx + fld %st(0) + fmul %st(1), %st + fldt 36+_PS1@GOTOFF(%eax) + fmul %st(1), %st + fldt 24+_PS1@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_PS1@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt _PS1@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + fldt 36+_PC1@GOTOFF(%eax) + fmul %st(1), %st + fldt 24+_PC1@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_PC1@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt _PC1@GOTOFF(%eax) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + faddp %st, %st(1) + fstpt (%esp) + je ..B1.38 +..B1.37: + fldcw 62(%esp) +..B1.38: + fldt 16(%esp) + fstpt (%esi) + fldt (%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + movl %edi, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.80 +..B1.40: + movl %edi, %edx + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.41: + fldcw 60(%esp) +..B1.42: + movl $1, %edx +..B1.43: + fldl _TWO_48H@GOTOFF(%eax) + testl %edx, %edx + fld %st(0) + fldt 8(%ebp) + fld %st(0) + fmul %st(1), %st + fstpt 48(%esp) + fldt 48(%esp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%esp) + fldt 32(%esp) + fld %st(2) + fsub %st(1), %st + fldt 84+_PS@GOTOFF(%eax) + fmul %st(3), %st + fldt 72+_PS@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_PS@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_PS@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PS@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_PS@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(3), %st + fldt 12+_PS@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_PC@GOTOFF(%eax) + fmul %st(4), %st + fldt 72+_PC@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(4), %st + fldt 60+_PC@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(4), %st + fldt 48+_PC@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(4), %st + fldt 36+_PC@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(4), %st + fldt 24+_PC@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(4), %st + fldt 12+_PC@GOTOFF(%eax) + faddp %st, %st(1) + fmul %st(4), %st + fstpt 64(%esp) + fld %st(4) + fmul %st(2), %st + fldt _PS@GOTOFF(%eax) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(1) + fld %st(2) + fmul %st(2), %st + faddp %st, %st(4) + fld %st(2) + fmul %st(3), %st + fldt 96+_PS@GOTOFF(%eax) + fld %st(0) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(6) + fld %st(2) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(6) + fxch %st(5) + faddp %st, %st(2) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%esp) + fldt 108+_PC@GOTOFF(%eax) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(4), %st + fldt 64(%esp) + faddp %st, %st(2) + fld %st(3) + fmul %st(1), %st + fxch %st(1) + fmul %st(5), %st + fldt 48(%esp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%esp) + fld %st(0) + fldt 96+_PC@GOTOFF(%eax) + fmul %st, %st(6) + fxch %st(3) + faddp %st, %st(6) + fxch %st(2) + fmulp %st, %st(6) + fldt 80(%esp) + fadd %st, %st(2) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fld %st(2) + fadd %st(1), %st + fldl _TWO_48H@GOTOFF(%eax) + fadd %st, %st(1) + fsubr %st(1), %st + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + je ..B1.90 +..B1.44: + fstpt 80(%esp) +..B1.89: + fldcw 62(%esp) + jmp ..B1.45 +..B1.90: + fstp %st(0) +..B1.45: + fldt (%esp) + fstpt (%esi) + fldt 16(%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + movl %edi, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.81 +..B1.47: + movl %edi, %edx + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.48: + fldcw 60(%esp) +..B1.49: + movzbl 17(%ebp), %ecx + movl $1, %edi + andl $128, %ecx + shrl $7, %ecx +..B1.50: + fldl ones@GOTOFF(%eax,%ecx,8) + fstpt 32(%esp) + fldt 32(%esp) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%eax) + fldt .L_2il0floatpacket.0@GOTOFF(%eax) + fmul %st(2), %st + movl %ebx, 44(%esp) + fadd %st(1), %st + fstpt 80(%esp) + fldt 80(%esp) + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%eax) + fmul %st(1), %st + movl 80(%esp), %edx + fsubrp %st, %st(2) + fld %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%eax) + fmulp %st, %st(2) + movsbl %dl, %ebx + fsub %st(1), %st + fldl _TWO_32P@GOTOFF(%eax) + subl %ebx, %edx + fmul %st(1), %st + fxch %st(1) + fmull _TWO_32@GOTOFF(%eax) + shll $4, %ebx + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + shrl $8, %edx + fxch %st(2) + fsubrp %st, %st(3) + movl %edx, %ecx + negl %edx + shll $23, %ecx + fadd %st(2), %st + fld %st(0) + addl $1056964608, %ecx + fmul %st(1), %st + fldt 48+_PE@GOTOFF(%eax) + fmul %st(1), %st + fldt 36+_PE@GOTOFF(%eax) + fmul %st(2), %st + fldt 24+_PE@GOTOFF(%eax) + shll $23, %edx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + addl $1056964608, %edx + fldt 12+_PE@GOTOFF(%eax) + movl %ecx, 12(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + movl %edx, 28(%esp) + fxch %st(2) + faddp %st, %st(4) + fld %st(3) + fldt _PE@GOTOFF(%eax) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + fadd %st, %st(1) + fsubp %st, %st(3) + fldl 2056+__libm_expl_table_256@GOTOFF(%eax,%ebx) + fldl 2048+__libm_expl_table_256@GOTOFF(%eax,%ebx) + negl %ebx + fstpt 48(%esp) + fldt 48(%esp) + testl %edi, %edi + fadd %st(1), %st + fmulp %st, %st(2) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(2) + fldl 2056+__libm_expl_table_256@GOTOFF(%eax,%ebx) + fld %st(0) + fmul %st(4), %st + fldl 2048+__libm_expl_table_256@GOTOFF(%eax,%ebx) + fld %st(0) + movl 44(%esp), %ebx + fadd %st(3), %st + fmulp %st, %st(7) + fxch %st(1) + fsubrp %st, %st(6) + fxch %st(5) + fstpt 64(%esp) + fldt 48(%esp) + fld %st(0) + fmul %st(5), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + fmul %st(4), %st + fld %st(4) + fsub %st(1), %st + fsubr %st, %st(5) + fxch %st(1) + fsubrp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fldt 64(%esp) + faddp %st, %st(3) + flds 12(%esp) + fmul %st, %st(2) + fld %st(2) + fxch %st(2) + fmulp %st, %st(1) + flds 28(%esp) + fmul %st, %st(5) + fld %st(5) + fadd %st(4), %st + fxch %st(5) + fmulp %st, %st(1) + fxch %st(2) + fsub %st(5), %st + fld %st(0) + fsubr %st(4), %st + fsub %st(6), %st + fld %st(2) + fsub %st(4), %st + faddp %st, %st(1) + fxch %st(4) + fsub %st(5), %st + faddp %st, %st(6) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fldt 32(%esp) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.52 +..B1.51: + fldcw 62(%esp) +..B1.52: + fldt 16(%esp) + fstpt (%esi) + fldt (%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.53: + cmpl $16396, %edx + jge ..B1.61 +..B1.54: + movzwl 62(%esp), %edi + movl %edi, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.82 +..B1.55: + orl $-64768, %edi + movw %di, 60(%esp) +..B1.56: + fldcw 60(%esp) +..B1.57: + movzbl 17(%ebp), %ecx + movl $1, %edi + andl $128, %ecx + shrl $7, %ecx +..B1.58: + fldl ones@GOTOFF(%eax,%ecx,8) + fstpt 48(%esp) + fldt 48(%esp) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt .L_2il0floatpacket.3@GOTOFF(%eax) + fstpt (%esp) + fldl _TWO_63H@GOTOFF(%eax) + fldt .L_2il0floatpacket.0@GOTOFF(%eax) + fmul %st(2), %st + movl %ebx, 44(%esp) + fadd %st(1), %st + fstpt 80(%esp) + fldt 80(%esp) + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%eax) + fmul %st(1), %st + movl 80(%esp), %edx + fsubrp %st, %st(2) + fld %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%eax) + fmulp %st, %st(2) + movsbl %dl, %ebx + fsub %st(1), %st + fldl _TWO_32@GOTOFF(%eax) + subl %ebx, %edx + fldl _TWO_32P@GOTOFF(%eax) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + shll $4, %ebx + fxch %st(2) + fsubrp %st, %st(1) + shrl $8, %edx + fsubr %st, %st(3) + addl $16350, %edx + fxch %st(2) + fsubrp %st, %st(3) + fld %st(1) + andl $32767, %edx + movzwl 8+.L_2il0floatpacket.3@GOTOFF(%eax), %ecx + fadd %st(3), %st + fld %st(0) + andl $-32768, %ecx + fmul %st(1), %st + orl %edx, %ecx + fldt 48+_PE@GOTOFF(%eax) + testl %edi, %edi + fmul %st(1), %st + fldt 36+_PE@GOTOFF(%eax) + fmul %st(2), %st + fldt 24+_PE@GOTOFF(%eax) + movw %cx, 8(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_PE@GOTOFF(%eax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(5) + fldt _PE@GOTOFF(%eax) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 2048+__libm_expl_table_256@GOTOFF(%eax,%ebx) + fld %st(0) + fmul %st(4), %st + fxch %st(3) + fadd %st, %st(4) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(4) + fmull 2056+__libm_expl_table_256@GOTOFF(%eax,%ebx) + faddp %st, %st(3) + fldt (%esp) + fmul %st, %st(4) + fxch %st(2) + fmul %st, %st(4) + fxch %st(1) + faddl 2056+__libm_expl_table_256@GOTOFF(%eax,%ebx) + movl 44(%esp), %ebx + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + fldt 48(%esp) + fld %st(0) + fmul %st(3), %st + fxch %st(2) + fadd %st, %st(3) + fxch %st(3) + fstpt 16(%esp) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 32(%esp) + je ..B1.60 +..B1.59: + fldcw 62(%esp) +..B1.60: + fldt 32(%esp) + fstpt (%esi) + fldt 16(%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.61: + je ..B1.84 +..B1.62: + movzwl 62(%esp), %edi + movl %edi, (%esp) + andl $768, %edi + cmpl $768, %edi + je ..B1.83 +..B1.63: + movl (%esp), %edx + orl $-64768, %edx + movw %dx, 60(%esp) +..B1.64: + fldcw 60(%esp) +..B1.65: + movzbl 17(%ebp), %ecx + movl $1, %edi + andl $128, %ecx + movzwl 16(%ebp), %edx + shrl $7, %ecx + andl $32767, %edx +..B1.66: + cmpl $32767, %edx + jne ..B1.68 +..B1.67: + fldt 8(%ebp) + fstpt 16(%esp) + fldt 16(%esp) + fldl ones@GOTOFF(%eax,%ecx,8) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.69 +..B1.68: + fldt _large_value_80@GOTOFF(%eax) + lea (,%ecx,8), %edx + lea (%edx,%ecx,4), %ecx + fldt _large_value_80@GOTOFF(%eax,%ecx) + fmul %st(1), %st + fstpt 16(%esp) + fmul %st(0), %st + fstpt (%esp) +..B1.69: + testl %edi, %edi + je ..B1.71 +..B1.70: + fldcw 62(%esp) +..B1.71: + fldt 16(%esp) + fstpt (%esi) + fldt (%esp) + fstpt (%ebx) + addl $100, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.72: + cmpl $0, 12(%ebp) + jne ..B1.74 +..B1.73: + cmpl $0, 8(%ebp) + je ..B1.75 +..B1.74: + fldt _small_value_80@GOTOFF(%eax) + lea (,%ecx,8), %edx + fldt 8(%ebp) + lea (%edx,%ecx,4), %edx + fldt _small_value_80@GOTOFF(%eax,%edx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%esp) + fldt 80(%esp) + fadd %st(1), %st + fstpt (%esp) + jmp ..B1.15 +..B1.75: + fldt 8(%ebp) + fstpt (%esp) + fldt (%esp) + jmp ..B1.15 +..B1.76: + xorl %edi, %edi + jmp ..B1.13 +..B1.77: + xorl %edx, %edx + jmp ..B1.22 +..B1.78: + xorl %edx, %edx + jmp ..B1.29 +..B1.79: + xorl %edx, %edx + jmp ..B1.36 +..B1.80: + xorl %edx, %edx + jmp ..B1.43 +..B1.81: + xorl %edi, %edi + jmp ..B1.50 +..B1.82: + xorl %edi, %edi + jmp ..B1.58 +..B1.83: + xorl %edi, %edi + jmp ..B1.66 +..B1.84: + cmpl $-1317741120, (%esp) + jb ..B1.54 +..B1.85: + jne ..B1.62 +..B1.86: + cmpl $833536233, 8(%ebp) + jbe ..B1.54 + jmp ..B1.62 + .align 16,0x90 + .type sinhcoshl,@function + .size sinhcoshl,.-sinhcoshl + .data +# -- End sinhcoshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 2 +_PS3: + .word 21845 + .word 44373 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _PS3,@object + .size _PS3,12 + .align 2 +_PC3: + .word 21845 + .word 213 + .word 0 + .word 32768 + .word 16382 + .word 0 + .type _PC3,@object + .size _PC3,12 + .align 2 +_PS2: + .word 29491 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 1838 + .word 3745 + .word 35050 + .word 34952 + .word 16376 + .word 0 + .type _PS2,@object + .size _PS2,24 + .align 2 +_PC2: + .word 62430 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 22894 + .word 21845 + .word 43733 + .word 43690 + .word 16378 + .word 0 + .type _PC2,@object + .size _PC2,24 + .align 2 +_PS1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 56472 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 6470 + .word 8609 + .word 207 + .word 53261 + .word 16370 + .word 0 + .word 51515 + .word 9159 + .word 10794 + .word 47344 + .word 16364 + .word 0 + .type _PS1,@object + .size _PS1,48 + .align 2 +_PC1: + .word 65531 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 7054 + .word 43693 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 25016 + .word 58228 + .word 24755 + .word 46603 + .word 16373 + .word 0 + .word 57397 + .word 35800 + .word 53031 + .word 53262 + .word 16367 + .word 0 + .type _PC1,@object + .size _PC1,48 + .align 2 +_PS: + .word 43620 + .word 43690 + .word 43690 + .word 43690 + .word 16364 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 52382 + .word 3328 + .word 208 + .word 53261 + .word 16370 + .word 0 + .word 44665 + .word 46658 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 15678 + .word 35942 + .word 11071 + .word 55090 + .word 16357 + .word 0 + .word 10412 + .word 23121 + .word 12507 + .word 45202 + .word 16350 + .word 0 + .word 37213 + .word 41879 + .word 65084 + .word 55102 + .word 16342 + .word 0 + .word 1721 + .word 42148 + .word 19309 + .word 52099 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16380 + .word 0 + .type _PS,@object + .size _PS,108 + .align 2 +_PC: + .word 18360 + .word 43637 + .word 28980 + .word 40373 + .word 49076 + .word 0 + .word 16302 + .word 43691 + .word 43690 + .word 43690 + .word 16362 + .word 0 + .word 46125 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .word 29965 + .word 3335 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 54950 + .word 46751 + .word 32187 + .word 37874 + .word 16361 + .word 0 + .word 30733 + .word 25775 + .word 51110 + .word 36726 + .word 16354 + .word 0 + .word 49850 + .word 450 + .word 9929 + .word 51659 + .word 16346 + .word 0 + .word 2776 + .word 45191 + .word 37201 + .word 55334 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16378 + .word 0 + .type _PC,@object + .size _PC,120 + .align 2 +_PE: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _PE,@object + .size _PE,60 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sinhf_wmt.S b/external/sgx_libm/ia32/sinhf_wmt.S new file mode 100644 index 0000000000..e415ba11e6 --- /dev/null +++ b/external/sgx_libm/ia32/sinhf_wmt.S @@ -0,0 +1,422 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinhf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin sinhf + .text + .align 16,0x90 + .globl sinhf +sinhf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + movsd 608(%ebx), %xmm3 + movsd 576(%ebx), %xmm6 + movd %xmm0, %ecx + movl $-2147483648, %edx + psllq $33, %xmm0 + psrlq $4, %xmm0 + movapd 512(%ebx), %xmm4 + andl %ecx, %edx + andl $2147418112, %ecx + subl $1052246016, %ecx + cmpl $67633152, %ecx + jae .L_2TAG_PACKET_0.0.3 + mulsd %xmm0, %xmm3 + movapd %xmm3, %xmm2 + addsd %xmm6, %xmm3 + xorpd %xmm0, %xmm0 + movd %xmm3, %eax + subsd %xmm6, %xmm3 + movapd 528(%ebx), %xmm1 + xorpd %xmm5, %xmm5 + subsd %xmm3, %xmm2 + shrl $16, %edx + orl $16352, %edx + cmpl $59244544, %ecx + jae .L_2TAG_PACKET_1.0.3 + movl $31, %ecx + andl %eax, %ecx + shrl $1, %eax + addl %ecx, %ecx + andl $65520, %eax + addl %edx, %eax + pinsrw $3, %eax, %xmm0 + movl $32704, %edx + subl %eax, %edx + movapd 544(%ebx), %xmm3 + movapd (%ebx,%ecx,8), %xmm7 + pinsrw $3, %edx, %xmm5 + pshufd $68, %xmm2, %xmm2 + shufpd $0, %xmm5, %xmm0 + movapd 560(%ebx), %xmm6 + mulpd %xmm2, %xmm4 + mulpd %xmm2, %xmm1 + mulpd %xmm2, %xmm3 + mulpd %xmm7, %xmm0 + mulpd %xmm2, %xmm4 + addpd %xmm1, %xmm6 + mulpd %xmm0, %xmm3 + addpd %xmm6, %xmm4 + mulpd %xmm3, %xmm4 + addpd %xmm4, %xmm0 + pshufd $78, %xmm0, %xmm4 + subpd %xmm4, %xmm0 + cvtsd2ss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_0.0.3: + addl $1052246016, %ecx + cmpl $1052246016, %ecx + ja .L_2TAG_PACKET_3.0.3 + cmpl $956301312, %ecx + jae .L_2TAG_PACKET_4.0.3 + cmpl $8388608, %ecx + jae .L_2TAG_PACKET_5.0.3 + movss 112(%esp), %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_5.0.3: + movss 112(%esp), %xmm0 + movl $1283457024, %eax + movd %eax, %xmm1 + movl $847249408, %ecx + movd %ecx, %xmm2 + mulss %xmm0, %xmm1 + addss %xmm1, %xmm0 + mulss %xmm2, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_1.0.3: + movl $31, %ecx + andl %eax, %ecx + shrl $1, %eax + addl %ecx, %ecx + andl $65520, %eax + addl %edx, %eax + pinsrw $3, %eax, %xmm0 + movsd 544(%ebx), %xmm3 + pshufd $68, %xmm2, %xmm2 + mulsd (%ebx,%ecx,8), %xmm0 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm1, %xmm4 + mulsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm3, %xmm4 + mulsd %xmm0, %xmm4 + addsd %xmm4, %xmm0 + cvtsd2ss %xmm0, %xmm0 + pextrw $1, %xmm0, %eax + andl $32640, %eax + movl $128, %edx + cmpl $32640, %eax + je .L_2TAG_PACKET_6.0.3 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_4.0.3: + psrlq $29, %xmm0 + movss 592(%ebx), %xmm7 + movss %xmm0, %xmm5 + mulss %xmm0, %xmm0 + movss 596(%ebx), %xmm2 + movss %xmm0, %xmm1 + mulss %xmm0, %xmm7 + movl $1042983595, %eax + movd %eax, %xmm3 + mulss %xmm0, %xmm0 + addss %xmm2, %xmm7 + movd %edx, %xmm4 + mulss %xmm3, %xmm1 + mulss %xmm7, %xmm0 + addss %xmm1, %xmm0 + orps %xmm4, %xmm5 + mulss %xmm5, %xmm0 + addss %xmm5, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_3.0.3: + cmpl $2139095040, %ecx + jae .L_2TAG_PACKET_7.0.3 + movl $2130706432, %eax + movd %eax, %xmm0 + orl %edx, %eax + movd %eax, %xmm1 + mulss %xmm1, %xmm0 + movl $128, %edx +.L_2TAG_PACKET_6.0.3: + movss %xmm0, (%esp) + movss 112(%esp), %xmm0 + subl $32, %esp + lea 112(%esp), %eax + movl %eax, (%esp) + lea 112(%esp), %eax + movl %eax, 4(%esp) + lea 32(%esp), %eax + movl %eax, 8(%esp) + movl %edx, %eax + movl %eax, 12(%esp) + call __libm_error_support + addl $32, %esp + flds (%esp) + jmp .L_2TAG_PACKET_8.0.3 +.L_2TAG_PACKET_7.0.3: + movss 112(%esp), %xmm0 + movss %xmm0, %xmm1 + pslld $1, %xmm0 + psrld $1, %xmm0 + mulss %xmm1, %xmm0 + jmp .L_2TAG_PACKET_2.0.3 +.L_2TAG_PACKET_2.0.3: + movss %xmm0, 24(%esp) + flds 24(%esp) +.L_2TAG_PACKET_8.0.3: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type sinhf,@function + .size sinhf,.-sinhf + .data +# -- End sinhf + .text +# -- Begin __libm_error_support + .text + .align 16,0x90 +__libm_error_support: +# parameter 1: 4 + %esp +# parameter 2: 8 + %esp +# parameter 3: 12 + %esp +# parameter 4: 16 + %esp +..B3.1: +..L4: + + ret + .align 16,0x90 + .type __libm_error_support,@function + .size __libm_error_support,.-__libm_error_support + .data +# -- End __libm_error_support + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 3541402996 + .long 1072716208 + .long 1533953344 + .long 1072648310 + .long 1828292879 + .long 1072739672 + .long 2728693978 + .long 1072604335 + .long 3490863953 + .long 1072763649 + .long 863738719 + .long 1072561303 + .long 1014845819 + .long 1072788152 + .long 3707479175 + .long 1072519192 + .long 828946858 + .long 1072813191 + .long 3706687593 + .long 1072477984 + .long 1853186616 + .long 1072838778 + .long 3716502172 + .long 1072437659 + .long 4112506593 + .long 1072864925 + .long 4076559943 + .long 1072398198 + .long 171030293 + .long 1072891646 + .long 2572866477 + .long 1072359583 + .long 926591435 + .long 1072918951 + .long 2990417245 + .long 1072321795 + .long 1276261410 + .long 1072946854 + .long 2191782032 + .long 1072284817 + .long 1617004845 + .long 1072975368 + .long 2966275557 + .long 1072248631 + .long 3577096743 + .long 1073004506 + .long 1110089947 + .long 1072213221 + .long 1453150082 + .long 1073034283 + .long 2571947539 + .long 1072178569 + .long 3712504873 + .long 1073064711 + .long 1944781191 + .long 1072144660 + .long 2956612997 + .long 1073095806 + .long 3907805044 + .long 1072111477 + .long 1719614413 + .long 1073127582 + .long 1719614413 + .long 1072079006 + .long 3907805044 + .long 1073160053 + .long 2956612997 + .long 1072047230 + .long 1944781191 + .long 1073193236 + .long 3712504873 + .long 1072016135 + .long 2571947539 + .long 1073227145 + .long 1453150082 + .long 1071985707 + .long 1110089947 + .long 1073261797 + .long 3577096743 + .long 1071955930 + .long 2966275557 + .long 1073297207 + .long 1617004845 + .long 1071926792 + .long 2191782032 + .long 1073333393 + .long 1276261410 + .long 1071898278 + .long 2990417245 + .long 1073370371 + .long 926591435 + .long 1071870375 + .long 2572866477 + .long 1073408159 + .long 171030293 + .long 1071843070 + .long 4076559943 + .long 1073446774 + .long 4112506593 + .long 1071816349 + .long 3716502172 + .long 1073486235 + .long 1853186616 + .long 1071790202 + .long 3706687593 + .long 1073526560 + .long 828946858 + .long 1071764615 + .long 3707479175 + .long 1073567768 + .long 1014845819 + .long 1071739576 + .long 863738719 + .long 1073609879 + .long 3490863953 + .long 1071715073 + .long 2728693978 + .long 1073652911 + .long 1828292879 + .long 1071691096 + .long 1533953344 + .long 1073696886 + .long 3541402996 + .long 1071667632 + .long 4289495988 + .long 1058308051 + .long 4289495988 + .long 1058308051 + .long 4277811695 + .long 1065758274 + .long 4277811695 + .long 3213241922 + .long 4277811695 + .long 1066806850 + .long 4277811695 + .long 3214290498 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 1127743488 + .long 0 + .long 3275227136 + .long 961547521 + .long 1007192201 + .long 1042983595 + .long 0 + .long 1697350398 + .long 2017924423 + .type static_const_table,@object + .size static_const_table,616 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sinhl.S b/external/sgx_libm/ia32/sinhl.S new file mode 100644 index 0000000000..7726807ca0 --- /dev/null +++ b/external/sgx_libm/ia32/sinhl.S @@ -0,0 +1,1005 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinhl.c" + .text +..TXTST0: +# -- Begin sinhl + .text + .align 16,0x90 + .globl sinhl +sinhl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $84, %esp +..B1.2: + fnstcw 46(%esp) +..B1.3: + movzwl 16(%ebp), %ecx + andl $32767, %ecx + movl 12(%ebp), %esi + movl %ecx, %edx + movl %esi, %eax + shll $16, %edx + shrl $16, %eax + movzbl 17(%ebp), %ebx + orl %eax, %edx + andl $128, %ebx + shrl $7, %ebx + cmpl $1073992020, %edx + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + jae ..B1.53 +..B1.4: + movzwl 46(%esp), %eax + cmpl $16382, %ecx + jge ..B1.46 +..B1.5: + cmpl $16378, %ecx + jge ..B1.39 +..B1.6: + cmpl $16373, %ecx + jge ..B1.32 +..B1.7: + cmpl $16366, %ecx + jge ..B1.25 +..B1.8: + cmpl $16308, %ecx + jge ..B1.18 +..B1.9: + movl %eax, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.76 +..B1.10: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.11: + fldcw 44(%esp) +..B1.12: + movzwl 16(%ebp), %ecx + movl $1, %esi + andl $32767, %ecx +..B1.13: + testl %ecx, %ecx + jle ..B1.72 +..B1.14: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%edx) + fmul %st(1), %st + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%edx) + fstpt 16(%esp) +..B1.15: + testl %esi, %esi + je ..B1.17 +..B1.16: + fldcw 46(%esp) +..B1.17: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.77 +..B1.19: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.20: + fldcw 44(%esp) +..B1.21: + movl $1, %eax +..B1.22: + fldt 8(%ebp) + testl %eax, %eax + fldt _Q3@GOTOFF(%edx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.24 +..B1.23: + fldcw 46(%esp) +..B1.24: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.78 +..B1.26: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.27: + fldcw 44(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_Q2@GOTOFF(%edx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.31 +..B1.30: + fldcw 46(%esp) +..B1.31: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.79 +..B1.33: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.34: + fldcw 44(%esp) +..B1.35: + movl $1, %eax +..B1.36: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%edx) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%edx) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.38 +..B1.37: + fldcw 46(%esp) +..B1.38: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.80 +..B1.40: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.41: + fldcw 44(%esp) +..B1.42: + movzbl 17(%ebp), %ebx + movl $1, %eax + andl $128, %ebx + shrl $7, %ebx +..B1.43: + fldl ones@GOTOFF(%edx,%ebx,8) + testl %eax, %eax + fstl 48(%esp) + fldt 8(%ebp) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_48H@GOTOFF(%edx) + fld %st(0) + fadd %st(2), %st + fstpt 32(%esp) + fldt 32(%esp) + fsubp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fldt 84+_Q@GOTOFF(%edx) + fmul %st(5), %st + fldt 72+_Q@GOTOFF(%edx) + fmul %st(6), %st + fldt 60+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(6), %st + fldt 48+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(6), %st + fldt 36+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(6), %st + fldt 24+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(6), %st + fldt 12+_Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(6) + fld %st(2) + fmul %st(3), %st + fldt _Q@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fld %st(1) + fmul %st(1), %st + fld %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fldt 96+_Q@GOTOFF(%edx) + fmul %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(5) + fxch %st(4) + fmulp %st, %st(2) + fld %st(3) + fmul %st(3), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldl 48(%esp) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.45 +..B1.44: + fldt 32(%esp) + fstpt 60(%esp) +..B1.89: + fldcw 46(%esp) +..B1.45: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.81 +..B1.47: + orl $-64768, %eax + movw %ax, 44(%esp) +..B1.48: + fldcw 44(%esp) +..B1.49: + movzbl 17(%ebp), %ebx + movl $1, %edi + andl $128, %ebx + shrl $7, %ebx +..B1.50: + fldt 8(%ebp) + fmull ones@GOTOFF(%edx,%ebx,8) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%edx) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(2), %st + fadd %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmul %st(1), %st + movl 60(%esp), %eax + fsubrp %st, %st(2) + fld %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmulp %st, %st(2) + movsbl %al, %esi + fsub %st(1), %st + fldl _TWO_32P@GOTOFF(%edx) + subl %esi, %eax + fmul %st(1), %st + fxch %st(1) + fmull _TWO_32@GOTOFF(%edx) + shll $4, %esi + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + shrl $8, %eax + fxch %st(2) + fsubrp %st, %st(3) + movl %eax, %ecx + negl %eax + shll $23, %ecx + fadd %st(2), %st + fld %st(0) + addl $1056964608, %ecx + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + shll $23, %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + addl $1056964608, %eax + fldt 12+_P@GOTOFF(%edx) + movl %ecx, 12(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + movl %eax, 28(%esp) + fxch %st(2) + faddp %st, %st(4) + fldt _P@GOTOFF(%edx) + faddp %st, %st(2) + fmulp %st, %st(1) + fld %st(2) + fadd %st(1), %st + fxch %st(3) + fsubrp %st, %st(1) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%esi) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%esi) + negl %esi + fstpt 32(%esp) + fldt 32(%esp) + testl %edi, %edi + fadd %st(1), %st + fmulp %st, %st(4) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(4) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%esi) + fld %st(0) + fmul %st(4), %st + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%esi) + fld %st(0) + fadd %st(3), %st + fmulp %st, %st(5) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(3) + fstpt 48(%esp) + fldt 32(%esp) + fld %st(0) + fmul %st(5), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(5) + faddp %st, %st(2) + fxch %st(2) + fmul %st, %st(3) + fld %st(0) + fsub %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + fsubrp %st, %st(1) + faddp %st, %st(2) + fldt 48(%esp) + faddp %st, %st(2) + flds 12(%esp) + fmull ones@GOTOFF(%edx,%ebx,8) + fmul %st, %st(4) + fld %st(4) + fxch %st(1) + fmul %st, %st(2) + flds 28(%esp) + fmull ones@GOTOFF(%edx,%ebx,8) + fmul %st, %st(5) + fxch %st(2) + fsub %st(5), %st + fsubr %st, %st(6) + fxch %st(5) + fsubrp %st, %st(6) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + je ..B1.91 +..B1.51: + fstps 28(%esp) + fstps 12(%esp) +..B1.90: + fldcw 46(%esp) + jmp ..B1.52 +..B1.91: + fstp %st(0) + fstp %st(0) +..B1.52: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.53: + cmpl $16396, %ecx + jge ..B1.61 +..B1.54: + movzwl 46(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.82 +..B1.55: + orl $-64768, %ecx + movw %cx, 44(%esp) +..B1.56: + fldcw 44(%esp) +..B1.57: + movzbl 17(%ebp), %ebx + movl $1, %esi + andl $128, %ebx + shrl $7, %ebx +..B1.58: + fldl ones@GOTOFF(%edx,%ebx,8) + fstpt 16(%esp) + fldt 16(%esp) + fldt 8(%ebp) + fmulp %st, %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%edx) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fmul %st(2), %st + movzwl 24(%esp), %ecx + fadd %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + andl $-32768, %ecx + movl 60(%esp), %eax + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fmul %st(1), %st + movsbl %al, %ebx + fsubrp %st, %st(2) + fld %st(1) + subl %ebx, %eax + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmulp %st, %st(2) + shll $4, %ebx + fsub %st(1), %st + fldl _TWO_32@GOTOFF(%edx) + fldl _TWO_32P@GOTOFF(%edx) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + shrl $8, %eax + fxch %st(2) + fsubrp %st, %st(1) + fld %st(0) + addl $16350, %eax + andl $32767, %eax + fxch %st(1) + fsubr %st, %st(4) + orl %eax, %ecx + fxch %st(3) + fsubrp %st, %st(4) + movw %cx, 24(%esp) + testl %esi, %esi + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(5) + fldt _P@GOTOFF(%edx) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%ebx) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%ebx) + fld %st(0) + fmul %st(5), %st + fxch %st(4) + fadd %st, %st(5) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldt 16(%esp) + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 32(%esp) + je ..B1.60 +..B1.59: + fldcw 46(%esp) +..B1.60: + fldt 32(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.61: + je ..B1.84 +..B1.62: + movzwl 46(%esp), %ebx + movl %ebx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.83 +..B1.63: + orl $-64768, %ebx + movw %bx, 44(%esp) +..B1.64: + fldcw 44(%esp) +..B1.65: + movzwl 16(%ebp), %ecx + movl $1, %esi + andl $32767, %ecx +..B1.66: + cmpl $32767, %ecx + jne ..B1.68 +..B1.67: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.69 +..B1.68: + fldt _large_value_80@GOTOFF(%edx) + movzbl 17(%ebp), %ecx + andl $128, %ecx + shrl $7, %ecx + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %ebx + fldt _large_value_80@GOTOFF(%edx,%ebx) + fmulp %st, %st(1) + fstpt 16(%esp) +..B1.69: + testl %esi, %esi + je ..B1.71 +..B1.70: + fldcw 46(%esp) +..B1.71: + fldt 16(%esp) + addl $84, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.72: + cmpl $0, 12(%ebp) + jne ..B1.74 +..B1.73: + cmpl $0, 8(%ebp) + je ..B1.75 +..B1.74: + fldt _small_value_80@GOTOFF(%edx) + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%edx) + fmul %st(1), %st + movzbl 17(%ebp), %ecx + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%edx) + andl $128, %ecx + shrl $7, %ecx + fstpt 16(%esp) + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %ebx + fldt _small_value_80@GOTOFF(%edx,%ebx) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.75: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.15 +..B1.76: + xorl %esi, %esi + jmp ..B1.13 +..B1.77: + xorl %eax, %eax + jmp ..B1.22 +..B1.78: + xorl %eax, %eax + jmp ..B1.29 +..B1.79: + xorl %eax, %eax + jmp ..B1.36 +..B1.80: + xorl %eax, %eax + jmp ..B1.43 +..B1.81: + xorl %edi, %edi + jmp ..B1.50 +..B1.82: + xorl %esi, %esi + jmp ..B1.58 +..B1.83: + xorl %esi, %esi + jmp ..B1.66 +..B1.84: + cmpl $-1317741120, %esi + jb ..B1.54 +..B1.85: + jne ..B1.62 +..B1.86: + cmpl $833536233, 8(%ebp) + jbe ..B1.54 + jmp ..B1.62 + .align 16,0x90 + .type sinhl,@function + .size sinhl,.-sinhl + .data +# -- End sinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 2 +_Q3: + .word 21845 + .word 44373 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 29491 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 1838 + .word 3745 + .word 35050 + .word 34952 + .word 16376 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 56472 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 6470 + .word 8609 + .word 207 + .word 53261 + .word 16370 + .word 0 + .word 51515 + .word 9159 + .word 10794 + .word 47344 + .word 16364 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 43620 + .word 43690 + .word 43690 + .word 43690 + .word 16364 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 52382 + .word 3328 + .word 208 + .word 53261 + .word 16370 + .word 0 + .word 44665 + .word 46658 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 15678 + .word 35942 + .word 11071 + .word 55090 + .word 16357 + .word 0 + .word 10412 + .word 23121 + .word 12507 + .word 45202 + .word 16350 + .word 0 + .word 37213 + .word 41879 + .word 65084 + .word 55102 + .word 16342 + .word 0 + .word 1721 + .word 42148 + .word 19309 + .word 52099 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16380 + .word 0 + .type _Q,@object + .size _Q,108 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sinl.S b/external/sgx_libm/ia32/sinl.S new file mode 100644 index 0000000000..62c48998f9 --- /dev/null +++ b/external/sgx_libm/ia32/sinl.S @@ -0,0 +1,1038 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinl.c" + .text +..TXTST0: +# -- Begin sinl + .text + .align 16,0x90 + .globl sinl +sinl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $180, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 152(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + movzwl 14(%esp), %edx + cmpl $16378, %eax + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jge ..B1.41 +..B1.4: + cmpl $16372, %eax + jge ..B1.33 +..B1.5: + cmpl $16364, %eax + jge ..B1.25 +..B1.6: + cmpl $16308, %eax + jge ..B1.17 +..B1.7: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.75 +..B1.8: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movzwl 16(%ebp), %eax + movl $1, %esi + andl $32767, %eax +..B1.11: + testl %eax, %eax + jle ..B1.71 +..B1.12: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ebx) + fmul %st(1), %st + fsubp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ebx) + fstpt 16(%esp) +..B1.13: + testl %esi, %esi + je ..B1.15 +..B1.14: + fldcw 14(%esp) +..B1.15: + movl 152(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.16: + fldt 16(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.77 +..B1.18: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.19: + fldcw 12(%esp) +..B1.20: + movl $1, %eax +..B1.21: + fldt 8(%ebp) + testl %eax, %eax + fldt _SP3@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.23 +..B1.22: + fldcw 14(%esp) +..B1.23: + movl 152(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.24: + fldt 16(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.79 +..B1.26: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.27: + fldcw 12(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_SP2@GOTOFF(%ebx) + fmul %st(1), %st + fldt _SP2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.31 +..B1.30: + fldcw 14(%esp) +..B1.31: + movl 152(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.32: + fldt 16(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.33: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.81 +..B1.34: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.35: + fldcw 12(%esp) +..B1.36: + movl $1, %eax +..B1.37: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_SP1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_SP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_SP1@GOTOFF(%ebx) + fmulp %st, %st(2) + fldt _SP1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.39 +..B1.38: + fldcw 14(%esp) +..B1.39: + movl 152(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.40: + fldt 16(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + movl %edx, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.84 +..B1.42: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.43: + fldcw 12(%esp) +..B1.44: + movzwl 16(%ebp), %eax + movl $1, %edi + andl $32767, %eax +..B1.45: + movzbl 17(%ebp), %esi + andl $128, %esi + shrl $7, %esi + cmpl $16413, %eax + jge ..B1.52 +..B1.46: + fldt 8(%ebp) + fldl _Pi4Inv@GOTOFF(%ebx) + fxch %st(1) + fmull _ones@GOTOFF(%ebx,%esi,8) + fmul %st, %st(1) + fxch %st(1) + fstpt 24(%esp) + movzwl 32(%esp), %ecx + andl $32767, %ecx + cmpl $16383, %ecx + jge ..B1.48 +..B1.47: + fldl _TWO_52H@GOTOFF(%ebx) + movl $1, %edx + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(1) + fsub %st(1), %st + fxch %st(2) + fxch %st(1) + fxch %st(2) + jmp ..B1.63 +..B1.48: + fldl _TWO_32H@GOTOFF(%ebx) + negl %ecx + addl $30, %ecx + movl 28(%esp), %edx + shrl %cl, %edx + incl %edx + movl %edx, %ecx + andl $-2, %ecx + movl %ecx, 16(%esp) + cmpl $16400, %eax + fildl 16(%esp) + jge ..B1.50 +..B1.49: + fldl _Pi04x3@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x3@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_Pi04x3@GOTOFF(%ebx) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + jmp ..B1.51 +..B1.50: + fldl _Pi04x5@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x5@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl 24+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl 32+_Pi04x5@GOTOFF(%ebx) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) +..B1.51: + fldl _TWO_52H@GOTOFF(%ebx) + movl %edx, %eax + fmul %st(1), %st + fld %st(1) + shrl $2, %eax + fadd %st(1), %st + xorl %eax, %esi + fsubp %st, %st(1) + andl $1, %esi + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fxch %st(1) + fxch %st(2) + jmp ..B1.63 +..B1.52: + cmpl $32767, %eax + jne ..B1.61 +..B1.53: + cmpl $-2147483648, 12(%ebp) + jne ..B1.56 +..B1.54: + cmpl $0, 8(%ebp) + jne ..B1.56 +..B1.55: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpt 16(%esp) + jmp ..B1.57 +..B1.56: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx) + fstpt 16(%esp) +..B1.57: + testl %edi, %edi + je ..B1.59 +..B1.58: + fldcw 14(%esp) +..B1.59: + movl 152(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.60: + fldt 16(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.61: + fldt 8(%ebp) + addl $-32, %esp + fmull _ones@GOTOFF(%ebx,%esi,8) + lea 168(%esp), %eax + fstpt (%esp) + movl $0, 12(%esp) + movl %eax, 16(%esp) + call __libm_reduce_pi04l +..B1.87: + movl %eax, %edx + addl $32, %esp +..B1.62: + fldl 136(%esp) + incl %edx + fldl _TWO_52H@GOTOFF(%ebx) + movl %edx, %eax + fmul %st(1), %st + fld %st(0) + shrl $2, %eax + fadd %st(2), %st + xorl %eax, %esi + fsubp %st, %st(1) + fld %st(0) + andl $1, %esi + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddl 144(%esp) + fadd %st, %st(1) +..B1.63: + fld %st(2) + testb $2, %dl + fmul %st(1), %st + fld %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fstpt 56(%esp) + fldt 56(%esp) + fld %st(3) + fmul %st(4), %st + fld %st(0) + fadd %st(2), %st + fstpt 72(%esp) + fldt 72(%esp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 88(%esp) + fldt 88(%esp) + fxch %st(1) + fstpt 104(%esp) + fldt 104(%esp) + fmul %st(0), %st + fld %st(0) + faddp %st, %st(2) + fldl _TWO_53H@GOTOFF(%ebx) + fstpt 40(%esp) + fldl _ones@GOTOFF(%ebx,%esi,8) + fstpl 16(%esp) + je ..B1.65 +..B1.64: + fstp %st(2) + fstp %st(2) + fstp %st(2) + fldt 96+_CP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 84+_CP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 72+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_CP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt _CP@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 72(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 88(%esp) + fldt 56(%esp) + fldt 104(%esp) + fldt 40(%esp) + fldt 120+_CP@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(5) + fldt 108+_CP@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(5) + fld %st(4) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fadd %st(2), %st + fmul %st, %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldl _ones@GOTOFF(%ebx) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fldl 16(%esp) + fmul %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 120(%esp) + jmp ..B1.66 +..B1.65: + fldt 96+_SP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 84+_SP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 72+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 36+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 12+_SP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt _SP@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 72(%esp) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 88(%esp) + fldt 120+_SP@GOTOFF(%ebx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + fldt 108+_SP@GOTOFF(%ebx) + fldt 56(%esp) + fmul %st(1), %st + faddp %st, %st(3) + fldt 104(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fld %st(3) + fldt 40(%esp) + fmul %st(2), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fldl 16(%esp) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 120(%esp) +..B1.66: + testl %edi, %edi + je ..B1.89 +..B1.67: + fstpt 24(%esp) +..B1.88: + fldcw 14(%esp) + jmp ..B1.68 +..B1.89: + fstp %st(0) +..B1.68: + movl 152(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.70 +..B1.69: + fldt 120(%esp) + addl $180, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.70: + call __stack_chk_fail@PLT +..B1.71: + cmpl $0, 12(%ebp) + jne ..B1.73 +..B1.72: + cmpl $0, 8(%ebp) + je ..B1.74 +..B1.73: + fldt _small_value_80@GOTOFF(%ebx) + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ebx) + fmul %st(1), %st + movzbl 17(%ebp), %edx + fsubp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ebx) + andl $128, %edx + shrl $7, %edx + fstpt 16(%esp) + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.13 +..B1.74: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.13 +..B1.75: + xorl %esi, %esi + jmp ..B1.11 +..B1.77: + xorl %eax, %eax + jmp ..B1.21 +..B1.79: + xorl %eax, %eax + jmp ..B1.29 +..B1.81: + xorl %eax, %eax + jmp ..B1.37 +..B1.84: + xorl %edi, %edi + jmp ..B1.45 + .align 16,0x90 + .type sinl,@function + .size sinl,.-sinl + .data +# -- End sinl + .section .rodata, "a" + .align 16 + .align 16 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 16 +_SP3: + .word 17476 + .word 43656 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .type _SP3,@object + .size _SP3,12 + .space 4, 0x00 # pad + .align 16 +_SP2: + .word 43210 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 1587 + .word 57422 + .word 34932 + .word 34952 + .word 16376 + .word 0 + .type _SP2,@object + .size _SP2,24 + .space 8, 0x00 # pad + .align 16 +_SP1: + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 12518 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 43088 + .word 7396 + .word 207 + .word 53261 + .word 49138 + .word 0 + .word 55827 + .word 48618 + .word 3602 + .word 47342 + .word 16364 + .word 0 + .type _SP1,@object + .size _SP1,48 + .align 16 +_Pi4Inv: + .long 1841940611 + .long 1072979760 + .type _Pi4Inv,@object + .size _Pi4Inv,8 + .space 8, 0x00 # pad + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .space 8, 0x00 # pad + .align 16 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .space 8, 0x00 # pad + .align 16 +_Pi04x3: + .long 1413754112 + .long 1072243195 + .long 2563527040 + .long 1021855384 + .long 3417685868 + .long 3118450936 + .type _Pi04x3,@object + .size _Pi04x3,24 + .space 8, 0x00 # pad + .align 16 +_Pi04x5: + .long 1413480448 + .long 1072243195 + .long 442499072 + .long 1036039265 + .long 771751936 + .long 999496074 + .long 622854144 + .long 963347354 + .long 1396597664 + .long 922906692 + .type _Pi04x5,@object + .size _Pi04x5,40 + .space 8, 0x00 # pad + .align 16 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 16 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 16 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .space 8, 0x00 # pad + .align 16 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .type _CP,@object + .size _CP,132 + .space 12, 0x00 # pad + .align 16 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .type _SP,@object + .size _SP,132 + .space 12, 0x00 # pad + .align 16 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sqrt_tab_t.S b/external/sgx_libm/ia32/sqrt_tab_t.S new file mode 100644 index 0000000000..7fb5162aff --- /dev/null +++ b/external/sgx_libm/ia32/sqrt_tab_t.S @@ -0,0 +1,816 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrt_tab_t.c" + .section .rodata, "a" + .align 32 + .align 32 + .hidden __sqrt_t_table + .globl __sqrt_t_table +__sqrt_t_table: + .long 0x400672f9 + .long 0xc060f4f5 + .long 0xba659415,0x40052c06 + .long 0x4003de5a + .long 0xc05e5b2f + .long 0xfe66c797,0x4005170e + .long 0x40015b59 + .long 0xc05bce24 + .long 0x13b32f30,0x40050255 + .long 0x3ffdd2b8 + .long 0xc0594d7e + .long 0xdae79d26,0x4004edd7 + .long 0x3ff90fa1 + .long 0xc056d8e8 + .long 0x13220f7f,0x4004d996 + .long 0x3ff46c51 + .long 0xc0547012 + .long 0xb3fa6a49,0x4004c58e + .long 0x3fefe7bb + .long 0xc05212ae + .long 0xa20bcbc6,0x4004b1c0 + .long 0x3feb80db + .long 0xc04fc070 + .long 0xc76937e4,0x40049e2a + .long 0x3fe736b7 + .long 0xc04d790f + .long 0x1f93d776,0x40048acc + .long 0x3fe30860 + .long 0xc04b3c44 + .long 0xa15ae4b0,0x400477a3 + .long 0x3fdef4f0 + .long 0xc04909cc + .long 0x697f4726,0x400464b0 + .long 0x3fdafb8a + .long 0xc046e163 + .long 0x6403b289,0x400451f1 + .long 0x3fd71b59 + .long 0xc044c2ca + .long 0xb7aecc11,0x40043f65 + .long 0x3fd35392 + .long 0xc042adc3 + .long 0x76dd1156,0x40042d0c + .long 0x3fcfa371 + .long 0xc040a213 + .long 0xd01983f9,0x40041ae4 + .long 0x3fcc0a37 + .long 0xc03e9f7d + .long 0xbecf4a2b,0x400408ed + .long 0x3fc88730 + .long 0xc03ca5ca + .long 0x7b0eeed7,0x4003f726 + .long 0x3fc519ad + .long 0xc03ab4c5 + .long 0x50846ea3,0x4003e58e + .long 0x3fc1c105 + .long 0xc038cc36 + .long 0x3decb5a1,0x4003d424 + .long 0x3fbe7c97 + .long 0xc036ebed + .long 0xb2048812,0x4003c2e7 + .long 0x3fbb4bc6 + .long 0xc03513b5 + .long 0xb29c9700,0x4003b1d7 + .long 0x3fb82dfc + .long 0xc0334360 + .long 0xa89c0a0a,0x4003a0f3 + .long 0x3fb522a8 + .long 0xc0317abe + .long 0xc440fe15,0x4003903a + .long 0x3fb2293e + .long 0xc02fb9a2 + .long 0x596206ff,0x40037fac + .long 0x3faf4138 + .long 0xc02dffe0 + .long 0xb44972f3,0x40036f47 + .long 0x3fac6a14 + .long 0xc02c4d4c + .long 0x1107001d,0x40035f0c + .long 0x3fa9a354 + .long 0xc02aa1be + .long 0xe7c62025,0x40034ef8 + .long 0x3fa6ec80 + .long 0xc028fd0d + .long 0x815ec2da,0x40033f0d + .long 0x3fa44523 + .long 0xc0275f11 + .long 0x2e0b0c0e,0x40032f49 + .long 0x3fa1accc + .long 0xc025c7a5 + .long 0x66b9f8b6,0x40031fab + .long 0x3f9f230f + .long 0xc02436a3 + .long 0x788665c8,0x40031033 + .long 0x3f9ca783 + .long 0xc022abe8 + .long 0xded1e594,0x400300e0 + .long 0x3f9a39c2 + .long 0xc0212751 + .long 0x0842a075,0x4002f1b3 + .long 0x3f97d96b + .long 0xc01fa8bb + .long 0x494fbc25,0x4002e2a9 + .long 0x3f95861f + .long 0xc01e3006 + .long 0x2b018f07,0x4002d3c3 + .long 0x3f933f82 + .long 0xc01cbd11 + .long 0x142c8510,0x4002c500 + .long 0x3f91053c + .long 0xc01b4fbd + .long 0x7f1daa26,0x4002b65f + .long 0x3f8ed6f7 + .long 0xc019e7eb + .long 0xdda5e7e2,0x4002a7e0 + .long 0x3f8cb461 + .long 0xc018857f + .long 0xc9948908,0x40029983 + .long 0x3f8a9d2a + .long 0xc017285b + .long 0xaa59eeeb,0x40028b47 + .long 0x3f889104 + .long 0xc015d062 + .long 0xf2821162,0x40027d2b + .long 0x3f868fa5 + .long 0xc0147d7c + .long 0x669445ed,0x40026f30 + .long 0x3f8498c3 + .long 0xc0132f8a + .long 0x3b85fad8,0x40026154 + .long 0x3f82ac1a + .long 0xc011e676 + .long 0x3e988364,0x40025397 + .long 0x3f80c964 + .long 0xc010a224 + .long 0xcf7601fc,0x400245f8 + .long 0x3f7de0c1 + .long 0xc00f627e + .long 0xaab7acb5,0x40023878 + .long 0x3f7a419f + .long 0xc00e276a + .long 0x36aab17c,0x40022b16 + .long 0x3f76b4e6 + .long 0xc00cf0d1 + .long 0x0f2aa54c,0x40021dd1 + .long 0x3f733a1e + .long 0xc00bbe9d + .long 0xdacdcc1a,0x400210a8 + .long 0x3f6fd0d4 + .long 0xc00a90b8 + .long 0x30e54b08,0x4002039d + .long 0x3f6c7897 + .long 0xc009670b + .long 0x8e05e1b3,0x4001f6ad + .long 0x3f6930fa + .long 0xc0084182 + .long 0xa51b1d74,0x4001e9d9 + .long 0x3f65f994 + .long 0xc0072009 + .long 0x1cf6297b,0x4001dd21 + .long 0x3f62d1fe + .long 0xc006028b + .long 0x8103f9e2,0x4001d083 + .long 0x3f5fb9d5 + .long 0xc004e8f5 + .long 0x7cc51dba,0x4001c400 + .long 0x3f5cb0b7 + .long 0xc003d333 + .long 0xa3e7f161,0x4001b797 + .long 0x3f59b649 + .long 0xc002c134 + .long 0xb4f86544,0x4001ab48 + .long 0x3f56ca2e + .long 0xc001b2e5 + .long 0x4bc09f7e,0x40019f13 + .long 0x3f53ec0f + .long 0xc000a834 + .long 0x04a8d6a9,0x400192f7 + .long 0x3f511b96 + .long 0xbfff4221 + .long 0x9d5a7e63,0x400186f3 + .long 0x3f4e5870 + .long 0xbffd3ad2 + .long 0xb211c804,0x40017b08 + .long 0x3f4ba24c + .long 0xbffb3a5b + .long 0xfc173425,0x40016f35 + .long 0x3f48f8dc + .long 0xbff9409b + .long 0x1e599490,0x4001637b + .long 0x3f465bd5 + .long 0xbff74d73 + .long 0xc880b659,0x400157d7 + .long 0x3f43caeb + .long 0xbff560c5 + .long 0xbd156bcf,0x40014c4b + .long 0x3f4145d7 + .long 0xbff37a71 + .long 0x9283ab1d,0x400140d6 + .long 0x3f3ecc53 + .long 0xbff19a5c + .long 0x19073c6b,0x40013578 + .long 0x3f3c5e1c + .long 0xbfefc069 + .long 0xfd4a0663,0x40012a2f + .long 0x3f39faef + .long 0xbfedec7b + .long 0xede7b908,0x40011efd + .long 0x3f37a28c + .long 0xbfec1e78 + .long 0xb252b4d7,0x400113e1 + .long 0x3f3554b6 + .long 0xbfea5645 + .long 0xf9904832,0x400108da + .long 0x3f33112e + .long 0xbfe893c7 + .long 0x7e150822,0x4000fde9 + .long 0x3f30d7ba + .long 0xbfe6d6e5 + .long 0xfd1a5086,0x4000f30c + .long 0x3f2ea821 + .long 0xbfe51f87 + .long 0x3d632fc4,0x4000e845 + .long 0x3f2c822c + .long 0xbfe36d94 + .long 0xf11c7d33,0x4000dd91 + .long 0x3f2a65a2 + .long 0xbfe1c0f3 + .long 0xd61ea754,0x4000d2f2 + .long 0x3f285250 + .long 0xbfe0198f + .long 0xc0d51627,0x4000c867 + .long 0x3f264803 + .long 0xbfde7750 + .long 0x61244ec6,0x4000bdf0 + .long 0x3f244687 + .long 0xbfdcda1f + .long 0x7a6b2e99,0x4000b38c + .long 0x3f224dad + .long 0xbfdb41e7 + .long 0xd19f4764,0x4000a93b + .long 0x3f205d44 + .long 0xbfd9ae92 + .long 0x2ad2e77d,0x40009efe + .long 0x3f1e751f + .long 0xbfd8200d + .long 0x5dbcaf97,0x400094d3 + .long 0x3f1c9510 + .long 0xbfd69641 + .long 0x14b04d5e,0x40008abb + .long 0x3f1abcec + .long 0xbfd5111c + .long 0x2cda2e67,0x400080b5 + .long 0x3f18ec88 + .long 0xbfd3908a + .long 0x6ab42acc,0x400076c1 + .long 0x3f1723ba + .long 0xbfd21477 + .long 0x8e9d45e3,0x40006cdf + .long 0x3f156259 + .long 0xbfd09cd0 + .long 0x62171386,0x4000630f + .long 0x3f13a83e + .long 0xbfcf2984 + .long 0xbfb6fb6a,0x40005950 + .long 0x3f11f542 + .long 0xbfcdba80 + .long 0x68a7e5f7,0x40004fa3 + .long 0x3f104940 + .long 0xbfcc4fb3 + .long 0x2ef38d27,0x40004607 + .long 0x3f0ea414 + .long 0xbfcae90c + .long 0xe03435f5,0x40003c7b + .long 0x3f0d0598 + .long 0xbfc98678 + .long 0x3b99fee4,0x40003301 + .long 0x3f0b6dab + .long 0xbfc827e9 + .long 0x28d4ef26,0x40002997 + .long 0x3f09dc2b + .long 0xbfc6cd4e + .long 0x6d906b03,0x4000203d + .long 0x3f0850f6 + .long 0xbfc57696 + .long 0xd0880103,0x400016f3 + .long 0x3f06cbec + .long 0xbfc423b3 + .long 0x37509185,0x40000dba + .long 0x3f054cee + .long 0xbfc2d495 + .long 0x66ce8c53,0x40000490 + .long 0x3f03d3dc + .long 0xbfc1892d + .long 0x72279bc0,0x3ffff6ec + .long 0x3f026099 + .long 0xbfc0416c + .long 0xeda5cd81,0x3fffe4d6 + .long 0x3f00f308 + .long 0xbfbefd45 + .long 0x0c012834,0x3fffd2e0 + .long 0x3eff1616 + .long 0xbfbdbca8 + .long 0x52f75b3b,0x3fffc107 + .long 0x3efc510e + .long 0xbfbc7f88 + .long 0x799a7f94,0x3fffaf4c + .long 0x3ef996c2 + .long 0xbfbb45d9 + .long 0x55edcc30,0x3fff9daf + .long 0x3ef6e6fb + .long 0xbfba0f8b + .long 0x537eb099,0x3fff8c2f + .long 0x3ef44186 + .long 0xbfb8dc92 + .long 0x38cd722f,0x3fff7acc + .long 0x3ef1a631 + .long 0xbfb7ace2 + .long 0xc800858f,0x3fff6985 + .long 0x3eef14c9 + .long 0xbfb6806e + .long 0xaed5086e,0x3fff585b + .long 0x3eec8d1e + .long 0xbfb55729 + .long 0x88bfcc7e,0x3fff474d + .long 0x3eea0f02 + .long 0xbfb43109 + .long 0x3db0d3c5,0x3fff365b + .long 0x3ee79a45 + .long 0xbfb30e00 + .long 0x4f3507e4,0x3fff2584 + .long 0x3ee52ebb + .long 0xbfb1ee03 + .long 0x7dab64e4,0x3fff14c8 + .long 0x3ee2cc37 + .long 0xbfb0d107 + .long 0x9247f5f1,0x3fff0427 + .long 0x3ee0728f + .long 0xbfafb700 + .long 0x252987ab,0x3ffef3a1 + .long 0x3ede2198 + .long 0xbfae9fe4 + .long 0x12fb7286,0x3ffee335 + .long 0x3edbd929 + .long 0xbfad8ba8 + .long 0x0e1fbfd6,0x3ffed2e3 + .long 0x3ed9991a + .long 0xbfac7a41 + .long 0xc33c7a14,0x3ffec2aa + .long 0x3ed76144 + .long 0xbfab6ba5 + .long 0xf7968902,0x3ffeb28b + .long 0x3ed53180 + .long 0xbfaa5fca + .long 0x72271f31,0x3ffea286 + .long 0x3ed309a8 + .long 0xbfa956a6 + .long 0xf446dfa2,0x3ffe9299 + .long 0x3ed0e998 + .long 0xbfa8502f + .long 0x31fc7113,0x3ffe82c6 + .long 0x3eced12c + .long 0xbfa74c5a + .long 0xc17a77a1,0x3ffe730a + .long 0x3eccc040 + .long 0xbfa64b20 + .long 0xb683d568,0x3ffe6367 + .long 0x3ecab6b3 + .long 0xbfa54c76 + .long 0x93851ebf,0x3ffe53dc + .long 0x3ec8b462 + .long 0xbfa45054 + .long 0x48e8d2d8,0x3ffe4469 + .long 0x3ec6b92d + .long 0xbfa356b0 + .long 0x72ed724b,0x3ffe350d + .long 0x3ec4c4f3 + .long 0xbfa25f82 + .long 0xf5acec61,0x3ffe25c8 + .long 0x3ec2d795 + .long 0xbfa16ac0 + .long 0x67c5c2c3,0x3ffe169b + .long 0x3ec0f0f5 + .long 0xbfa07864 + .long 0xd8265439,0x3ffe0784 + .long 0x3fbe23c8 + .long 0xc01f118b + .long 0x1ec5a532,0x3ffdf113 + .long 0x3fba7d85 + .long 0xc01d3ac5 + .long 0x0000d4c8,0x3ffdd36c + .long 0x3fb6f02d + .long 0xc01b6d00 + .long 0x57cb9031,0x3ffdb61c + .long 0x3fb37ae5 + .long 0xc019a7fe + .long 0x72ed1c77,0x3ffd9922 + .long 0x3fb01cdd + .long 0xc017eb83 + .long 0x95b0b15c,0x3ffd7c7c + .long 0x3facd54f + .long 0xc0163758 + .long 0x6603fec1,0x3ffd6029 + .long 0x3fa9a37b + .long 0xc0148b45 + .long 0x469777ae,0x3ffd4427 + .long 0x3fa686a9 + .long 0xc012e714 + .long 0xa71adcce,0x3ffd2874 + .long 0x3fa37e28 + .long 0xc0114a91 + .long 0x0c38599d,0x3ffd0d10 + .long 0x3fa08950 + .long 0xc00fb58a + .long 0xfc8f14cb,0x3ffcf1f7 + .long 0x3f9da77d + .long 0xc00e27d0 + .long 0x5027d5b6,0x3ffcd72b + .long 0x3f9ad814 + .long 0xc00ca133 + .long 0x77f69e05,0x3ffcbca8 + .long 0x3f981a7f + .long 0xc00b2187 + .long 0x4e14c785,0x3ffca26e + .long 0x3f956e2d + .long 0xc009a89f + .long 0x67cdb787,0x3ffc887b + .long 0x3f92d292 + .long 0xc0083650 + .long 0x7d1a45e5,0x3ffc6ece + .long 0x3f90472b + .long 0xc006ca73 + .long 0x887296e4,0x3ffc5566 + .long 0x3f8dcb76 + .long 0xc00564de + .long 0x1b6717e3,0x3ffc3c42 + .long 0x3f8b5ef7 + .long 0xc004056b + .long 0x264323b8,0x3ffc2360 + .long 0x3f890138 + .long 0xc002abf5 + .long 0x8c0c1853,0x3ffc0abf + .long 0x3f86b1c6 + .long 0xc0015858 + .long 0x4069b804,0x3ffbf25f + .long 0x3f847032 + .long 0xc0000a6f + .long 0xf2c0f56b,0x3ffbda3d + .long 0x3f823c13 + .long 0xbffd8435 + .long 0xe82b41be,0x3ffbc25a + .long 0x3f801501 + .long 0xbffafe6e + .long 0xd0c8f1c2,0x3ffbaab4 + .long 0x3f7bf536 + .long 0xbff8834b + .long 0xc1a3163f,0x3ffb934a + .long 0x3f77d900 + .long 0xbff6128d + .long 0xc6e21d7e,0x3ffb7c1b + .long 0x3f73d4ab + .long 0xbff3abf8 + .long 0xe60015a5,0x3ffb6526 + .long 0x3f6fe784 + .long 0xbff14f50 + .long 0x21cbd876,0x3ffb4e6b + .long 0x3f6c10e1 + .long 0xbfeefc5d + .long 0x9ee07b4c,0x3ffb37e7 + .long 0x3f68501d + .long 0xbfecb2e7 + .long 0x6d2d48b6,0x3ffb219b + .long 0x3f64a499 + .long 0xbfea72b8 + .long 0xa81c9b61,0x3ffb0b85 + .long 0x3f610dbb + .long 0xbfe83b9d + .long 0x902fdc83,0x3ffaf5a5 + .long 0x3f5d8aee + .long 0xbfe60d61 + .long 0x27f22c44,0x3ffadffa + .long 0x3f5a1ba3 + .long 0xbfe3e7d3 + .long 0xa3884d02,0x3ffaca82 + .long 0x3f56bf51 + .long 0xbfe1cac5 + .long 0x554d369e,0x3ffab53e + .long 0x3f537570 + .long 0xbfdfb606 + .long 0x5450035a,0x3ffaa02c + .long 0x3f503d7f + .long 0xbfdda969 + .long 0xe28ff013,0x3ffa8b4b + .long 0x3f4d1702 + .long 0xbfdba4c2 + .long 0x3ccf3bef,0x3ffa769c + .long 0x3f4a017f + .long 0xbfd9a7e6 + .long 0xadd0d7d8,0x3ffa621c + .long 0x3f46fc82 + .long 0xbfd7b2ab + .long 0x73a23063,0x3ffa4dcc + .long 0x3f440799 + .long 0xbfd5c4e8 + .long 0xd9b8e6fd,0x3ffa39aa + .long 0x3f412258 + .long 0xbfd3de77 + .long 0x47a99575,0x3ffa25b7 + .long 0x3f3e4c53 + .long 0xbfd1ff2e + .long 0xd6d4c329,0x3ffa11f0 + .long 0x3f3b8525 + .long 0xbfd026eb + .long 0x1e725d64,0x3ff9fe57 + .long 0x3f38cc6a + .long 0xbfce5587 + .long 0x4a856a92,0x3ff9eae9 + .long 0x3f3621c3 + .long 0xbfcc8ae0 + .long 0xd3534a3f,0x3ff9d7a6 + .long 0x3f3384d1 + .long 0xbfcac6d1 + .long 0xf6170fe5,0x3ff9c48e + .long 0x3f30f53c + .long 0xbfc9093b + .long 0x43d296cd,0x3ff9b1a1 + .long 0x3f2e72ac + .long 0xbfc751fb + .long 0xfbbf8768,0x3ff99edc + .long 0x3f2bfccb + .long 0xbfc5a0f2 + .long 0xaa7c60ad,0x3ff98c41 + .long 0x3f299349 + .long 0xbfc3f600 + .long 0x9e5e0c30,0x3ff979ce + .long 0x3f2735d5 + .long 0xbfc25106 + .long 0x47a967c7,0x3ff96783 + .long 0x3f24e423 + .long 0xbfc0b1e7 + .long 0x213a91b3,0x3ff9555f + .long 0x3f229de8 + .long 0xbfbf1887 + .long 0xb92f1e71,0x3ff94361 + .long 0x3f2062db + .long 0xbfbd84c7 + .long 0x4e9fbb55,0x3ff9318a + .long 0x3f1e32b7 + .long 0xbfbbf68e + .long 0x8c3e135d,0x3ff91fd8 + .long 0x3f1c0d36 + .long 0xbfba6dc0 + .long 0xe5486399,0x3ff90e4b + .long 0x3f19f217 + .long 0xbfb8ea42 + .long 0xbecd10bc,0x3ff8fce3 + .long 0x3f17e11a + .long 0xbfb76bfc + .long 0xbe525978,0x3ff8eb9f + .long 0x3f15d9ff + .long 0xbfb5f2d3 + .long 0x48293568,0x3ff8da7f + .long 0x3f13dc8c + .long 0xbfb47eb1 + .long 0x05d5e650,0x3ff8c982 + .long 0x3f11e884 + .long 0xbfb30f7c + .long 0x60ba5dac,0x3ff8b8a7 + .long 0x3f0ffdb0 + .long 0xbfb1a51e + .long 0xefd22e82,0x3ff8a7ee + .long 0x3f0e1bd7 + .long 0xbfb03f80 + .long 0x47805b92,0x3ff89758 + .long 0x3f0c42c3 + .long 0xbfaede8a + .long 0xcd57cc04,0x3ff886e2 + .long 0x3f0a7241 + .long 0xbfad8229 + .long 0x46b3d0d8,0x3ff8768e + .long 0x3f08aa1e + .long 0xbfac2a48 + .long 0x4cc7ad59,0x3ff8665a + .long 0x3f06ea27 + .long 0xbfaad6cf + .long 0x3347fcf1,0x3ff85646 + .long 0x3f05322e + .long 0xbfa987ad + .long 0xcc7c68cf,0x3ff84651 + .long 0x3f038204 + .long 0xbfa83ccd + .long 0x95d48bda,0x3ff8367c + .long 0x3f01d97a + .long 0xbfa6f61c + .long 0x40b0d774,0x3ff826c6 + .long 0x3f003866 + .long 0xbfa5b387 + .long 0x521e69ab,0x3ff8172e + .long 0x3efd3d38 + .long 0xbfa474fb + .long 0x64a31380,0x3ff807b4 + .long 0x3efa17e4 + .long 0xbfa33a67 + .long 0x344463f5,0x3ff7f858 + .long 0x3ef70080 + .long 0xbfa203b9 + .long 0x536e309d,0x3ff7e919 + .long 0x3ef3f6bd + .long 0xbfa0d0df + .long 0x51d9db7f,0x3ff7d9f7 + .long 0x3ef0fa4e + .long 0xbf9fa1ca + .long 0x03bdd024,0x3ff7caf2 + .long 0x3eee0ae8 + .long 0xbf9e7667 + .long 0xd06a95a6,0x3ff7bc08 + .long 0x3eeb2842 + .long 0xbf9d4ea8 + .long 0x96a621bf,0x3ff7ad3b + .long 0x3ee85215 + .long 0xbf9c2a7d + .long 0xfac56bba,0x3ff79e89 + .long 0x3ee5881d + .long 0xbf9b09d5 + .long 0x79c2bb58,0x3ff78ff3 + .long 0x3ee2ca16 + .long 0xbf99eca3 + .long 0xfa3e419f,0x3ff78177 + .long 0x3ee017bf + .long 0xbf98d2d7 + .long 0x07c1acb7,0x3ff77317 + .long 0x3edd70d7 + .long 0xbf97bc62 + .long 0x49bbc9e6,0x3ff764d0 + .long 0x3edad522 + .long 0xbf96a937 + .long 0x8367baca,0x3ff756a3 + .long 0x3ed84462 + .long 0xbf959948 + .long 0x6acc6906,0x3ff74890 + .long 0x3ed5be5d + .long 0xbf948c88 + .long 0xbcc0ac8a,0x3ff73a96 + .long 0x3ed342d8 + .long 0xbf9382e7 + .long 0xed77fbb2,0x3ff72cb5 + .long 0x3ed0d19d + .long 0xbf927c5c + .long 0x1262b283,0x3ff71eee + .long 0x3ece6a74 + .long 0xbf9178d7 + .long 0x928b4839,0x3ff7113e + .long 0x3ecc0d29 + .long 0xbf90784d + .long 0x46765494,0x3ff703a7 + .long 0x3ec9b988 + .long 0xbf8f7ab1 + .long 0xd271890f,0x3ff6f627 + .long 0x3ec76f5d + .long 0xbf8e7ff8 + .long 0x1330f37e,0x3ff6e8c0 + .long 0x3ec52e79 + .long 0xbf8d8817 + .long 0xca5f6659,0x3ff6db6f + .long 0x3ec2f6aa + .long 0xbf8c9300 + .long 0x7a3c2c24,0x3ff6ce36 + .long 0x3ec0c7c2 + .long 0xbf8ba0aa + .long 0x18d80162,0x3ff6c114 + .long 0x3ebea193 + .long 0xbf8ab109 + .long 0x4b1eb26b,0x3ff6b408 + .long 0x3ebc83f0 + .long 0xbf89c412 + .long 0xcd29fcba,0x3ff6a712 + .long 0x3eba6eaf + .long 0xbf88d9bb + .long 0x664b0f09,0x3ff69a33 + .long 0x3eb861a4 + .long 0xbf87f1f9 + .long 0xcfa00fd5,0x3ff68d69 + .long 0x3eb65ca6 + .long 0xbf870cc3 + .long 0xe9d2a6b3,0x3ff680b5 + .long 0x3eb45f8c + .long 0xbf862a0e + .long 0x5e7a0e0b,0x3ff67417 + .long 0x3eb26a30 + .long 0xbf8549d1 + .long 0xfe6852bf,0x3ff6678d + .long 0x3eb07c6a + .long 0xbf846c01 + .long 0x6f577b40,0x3ff65b19 + .long 0x3eae9616 + .long 0xbf839096 + .long 0x94beacb4,0x3ff64eb9 + .long 0x3eacb70d + .long 0xbf82b786 + .long 0x2d87a5b4,0x3ff6426e + .long 0x3eaadf2d + .long 0xbf81e0c9 + .long 0x133eca3a,0x3ff63637 + .long 0x3ea90e52 + .long 0xbf810c55 + .long 0xf3b8ca64,0x3ff62a13 + .long 0x3ea74459 + .long 0xbf803a22 + .long 0xb1e928a1,0x3ff61e04 + .long 0x3ea58123 + .long 0xbf7ed44e + .long 0xf9c12cea,0x3ff61208 + .long 0x3ea3c48d + .long 0xbf7d38b8 + .long 0xb0f105b4,0x3ff60620 + .long 0x3ea20e79 + .long 0xbf7ba172 + .long 0x9c747236,0x3ff5fa4b + .long 0x3ea05ec6 + .long 0xbf7a0e6a + .long 0x79454bb5,0x3ff5ee89 + .long 0x3e9eb556 + .long 0xbf787f92 + .long 0x2c804088,0x3ff5e2da + .long 0x3e9d120c + .long 0xbf76f4d9 + .long 0x686ac26d,0x3ff5d73d + .long 0x3e9b74ca + .long 0xbf756e31 + .long 0x1493b001,0x3ff5cbb3 + .long 0x3e99dd75 + .long 0xbf73eb8c + .long 0x048406f4,0x3ff5c03b + .long 0x3e984bef + .long 0xbf726cd9 + .long 0xf4dbeebe,0x3ff5b4d4 + .long 0x3e96c01f + .long 0xbf70f20b + .long 0xbbe3f38a,0x3ff5a980 + .long 0x3e9539e9 + .long 0xbf6f7b14 + .long 0x37ac4b0e,0x3ff59e3e + .long 0x3e93b933 + .long 0xbf6e07e5 + .long 0x294f0c16,0x3ff5930d + .long 0x3e923de4 + .long 0xbf6c9870 + .long 0x5aaed17d,0x3ff587ed + .long 0x3e90c7e3 + .long 0xbf6b2caa + .long 0xc550e64d,0x3ff57cde + .long 0x3e8f5718 + .long 0xbf69c484 + .long 0x1e1a64d6,0x3ff571e1 + .long 0x3e8deb6b + .long 0xbf685ff2 + .long 0x4990847b,0x3ff566f4 + .long 0x3e8c84c4 + .long 0xbf66fee6 + .long 0x0dee1cfa,0x3ff55c18 + .long 0x3e8b230e + .long 0xbf65a155 + .long 0x4a4098f7,0x3ff5514c + .long 0x3e89c631 + .long 0xbf644732 + .long 0xd65fdb98,0x3ff54690 + .long 0x3e886e18 + .long 0xbf62f072 + .long 0x9358f9fc,0x3ff53be5 + .type __sqrt_t_table,@object + .size __sqrt_t_table,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sqrt_wmt.S b/external/sgx_libm/ia32/sqrt_wmt.S new file mode 100644 index 0000000000..7667579e79 --- /dev/null +++ b/external/sgx_libm/ia32/sqrt_wmt.S @@ -0,0 +1,135 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrt_wmt.c" + .text +..TXTST0: +# -- Begin sqrt + .text + .align 16,0x90 + .globl sqrt +sqrt: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp + fldl 8(%ebp) + movl %gs:20, %edx + xorl %esp, %edx + movl 12(%ebp), %ecx + cmpl $2146435072, %ecx + movl %edx, 16(%esp) + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + fstl (%esp) + ja ..B1.5 +..B1.2: + fstpl 8(%esp) + movsd 8(%esp), %xmm0 + sqrtsd %xmm0, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + movl 16(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.4 +..B1.3: + movl %ebp, %esp + popl %ebp + ret +..B1.4: + fstp %st(0) + movl %eax, %ebx + call __stack_chk_fail@PLT +..B1.5: + cmpl $0, (%esp) + movl $0, %edx + setne %dl + orl %edx, %ecx + movl %ecx, %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + ja ..B1.12 +..B1.6: + cmpl $-2147483648, %ecx + je ..B1.8 +..B1.7: + fstp %st(0) + movsd _ConstantTable@GOTOFF(%eax), %xmm0 + mulsd 16+_ConstantTable@GOTOFF(%eax), %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) +..B1.8: + movl 16(%esp), %edx + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.4 + jmp ..B1.3 +..B1.12: + movl 16(%esp), %edx + fadd %st(0), %st + xorl %esp, %edx + cmpl %gs:20, %edx + jne ..B1.4 + jmp ..B1.3 + .align 16,0x90 + .type sqrt,@function + .size sqrt,.-sqrt + .data +# -- End sqrt + .section .rodata, "a" + .align 16 + .align 16 +_ConstantTable: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _ConstantTable,@object + .size _ConstantTable,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sqrtf_wmt.S b/external/sgx_libm/ia32/sqrtf_wmt.S new file mode 100644 index 0000000000..1e9785cc4a --- /dev/null +++ b/external/sgx_libm/ia32/sqrtf_wmt.S @@ -0,0 +1,114 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrtf_wmt.c" + .text +..TXTST0: +# -- Begin sqrtf + .text + .align 16,0x90 + .globl sqrtf +sqrtf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $16, %esp + flds 8(%ebp) + movl 8(%ebp), %edx + cmpl $2139095040, %edx + ja ..B1.3 +..B1.2: + fstps 8(%esp) + movss 8(%esp), %xmm0 + sqrtss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.3: + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.8 +..B1.4: + cmpl $-2147483648, %edx + je ..B1.6 +..B1.5: + fstp %st(0) + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + movss _ConstantTable@GOTOFF(%eax), %xmm0 + mulss 16+_ConstantTable@GOTOFF(%eax), %xmm0 + movss %xmm0, (%esp) + flds (%esp) +..B1.6: + movl %ebp, %esp + popl %ebp + ret +..B1.8: + fadd %st(0), %st + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type sqrtf,@function + .size sqrtf,.-sqrtf + .data +# -- End sqrtf + .section .rodata, "a" + .align 16 + .align 16 +_ConstantTable: + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 2139095040 + .long 4286578688 + .long 0 + .long 0 + .type _ConstantTable,@object + .size _ConstantTable,32 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/sqrtl.S b/external/sgx_libm/ia32/sqrtl.S new file mode 100644 index 0000000000..d0db6b5d4b --- /dev/null +++ b/external/sgx_libm/ia32/sqrtl.S @@ -0,0 +1,200 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrtl.c" + .text +..TXTST0: +# -- Begin sqrtl + .text + .align 16,0x90 + .globl sqrtl +sqrtl: +# parameter 1: 32 + %esp +..B1.1: +..L1: + + subl $28, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 40(%esp), %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $32767, %ecx + je ..B1.26 +..B1.4: + movzbl 41(%esp), %edx + testl $128, %edx + jne ..B1.14 +..B1.5: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.13 +..B1.6: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.7: + fldcw 12(%esp) +..B1.8: + movl $1, %eax +..B1.9: + fldt 32(%esp) + fsqrt + fstpt (%esp) +..B1.10: + testl %eax, %eax + je ..B1.12 +..B1.11: + fldcw 14(%esp) +..B1.12: + fldt (%esp) + addl $28, %esp + ret +..B1.13: + xorl %eax, %eax + jmp ..B1.9 +..B1.14: + testl %ecx, %ecx + jne ..B1.18 +..B1.15: + cmpl $0, 36(%esp) + jne ..B1.18 +..B1.16: + cmpl $0, 32(%esp) + jne ..B1.18 +..B1.17: + fldt 32(%esp) + addl $28, %esp + ret +..B1.18: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.25 +..B1.19: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.20: + fldcw 12(%esp) +..B1.21: + movl $1, %edx +..B1.22: + fldl _infs@GOTOFF(%eax) + testl %edx, %edx + fmull _zeros@GOTOFF(%eax) + fstpt (%esp) + je ..B1.24 +..B1.23: + fldcw 14(%esp) +..B1.24: + fldt (%esp) + addl $28, %esp + ret +..B1.25: + xorl %edx, %edx + jmp ..B1.22 +..B1.26: + cmpl $-2147483648, 36(%esp) + jne ..B1.28 +..B1.27: + cmpl $0, 32(%esp) + je ..B1.4 +..B1.28: + movzwl 14(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.34 +..B1.29: + orl $-64768, %ecx + movw %cx, 12(%esp) +..B1.30: + fldcw 12(%esp) +..B1.31: + fldt 32(%esp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) +..B1.32: + fldcw 14(%esp) +..B1.33: + fldt (%esp) + addl $28, %esp + ret +..B1.34: + fldt 32(%esp) + fmull _ones@GOTOFF(%eax) + fstpt (%esp) + jmp ..B1.33 + .align 16,0x90 + .type sqrtl,@function + .size sqrtl,.-sqrtl + .data +# -- End sqrtl + .section .rodata, "a" + .align 4 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tan_wmt.S b/external/sgx_libm/ia32/tan_wmt.S new file mode 100644 index 0000000000..747378fdf9 --- /dev/null +++ b/external/sgx_libm/ia32/tan_wmt.S @@ -0,0 +1,1713 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tan_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin tan + .text + .align 16,0x90 + .globl tan +tan: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 56(%esp) + call static_func + movl %eax, %ebx + movsd 128(%esp), %xmm0 + pextrw $3, %xmm0, %eax + andl $32767, %eax + subl $14368, %eax + cmpl $2216, %eax + ja .L_2TAG_PACKET_0.0.2 + movapd 5840(%ebx), %xmm5 + movapd 5856(%ebx), %xmm6 + unpcklpd %xmm0, %xmm0 + movapd 5712(%ebx), %xmm4 + andpd %xmm0, %xmm4 + movapd 5632(%ebx), %xmm1 + mulpd %xmm0, %xmm1 + orpd %xmm4, %xmm5 + addpd %xmm5, %xmm1 + movapd %xmm1, %xmm7 + unpckhpd %xmm7, %xmm7 + cvttsd2si %xmm7, %edx + cvttpd2dq %xmm1, %xmm1 + cvtdq2pd %xmm1, %xmm1 + mulpd %xmm6, %xmm1 + movapd 5664(%ebx), %xmm3 + movsd 5728(%ebx), %xmm5 + addl $469248, %edx + movapd 5680(%ebx), %xmm4 + mulpd %xmm1, %xmm3 + andl $31, %edx + mulsd %xmm1, %xmm5 + movl %edx, %ecx + mulpd %xmm1, %xmm4 + shll $1, %ecx + subpd %xmm3, %xmm0 + mulpd 5696(%ebx), %xmm1 + addl %ecx, %edx + shll $2, %ecx + addl %ecx, %edx + addsd %xmm0, %xmm5 + movapd %xmm0, %xmm2 + subpd %xmm4, %xmm0 + movsd 5744(%ebx), %xmm6 + shll $4, %edx + lea (%ebx), %eax + andpd 5776(%ebx), %xmm5 + movapd %xmm0, %xmm3 + addl %edx, %eax + subpd %xmm0, %xmm2 + unpckhpd %xmm0, %xmm0 + divsd %xmm5, %xmm6 + subpd %xmm4, %xmm2 + movapd 16(%eax), %xmm7 + subsd %xmm5, %xmm3 + mulpd %xmm0, %xmm7 + subpd %xmm1, %xmm2 + movapd 48(%eax), %xmm1 + mulpd %xmm0, %xmm1 + movapd 96(%eax), %xmm4 + mulpd %xmm0, %xmm4 + addsd %xmm3, %xmm2 + movapd %xmm0, %xmm3 + mulpd %xmm0, %xmm0 + addpd (%eax), %xmm7 + addpd 32(%eax), %xmm1 + mulpd %xmm0, %xmm1 + addpd 80(%eax), %xmm4 + addpd %xmm1, %xmm7 + movapd 112(%eax), %xmm1 + mulpd %xmm0, %xmm1 + mulpd %xmm0, %xmm0 + addpd %xmm1, %xmm4 + movapd 64(%eax), %xmm1 + mulpd %xmm0, %xmm1 + addpd %xmm1, %xmm7 + movapd %xmm3, %xmm1 + mulpd %xmm0, %xmm3 + mulsd %xmm0, %xmm0 + mulpd 144(%eax), %xmm1 + mulpd %xmm3, %xmm4 + movapd %xmm1, %xmm3 + addpd %xmm4, %xmm7 + movapd %xmm1, %xmm4 + mulsd %xmm7, %xmm0 + unpckhpd %xmm7, %xmm7 + addsd %xmm7, %xmm0 + unpckhpd %xmm1, %xmm1 + addsd %xmm1, %xmm3 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm1 + movapd %xmm2, %xmm4 + movsd 144(%eax), %xmm7 + unpckhpd %xmm2, %xmm2 + addsd 152(%eax), %xmm7 + mulsd %xmm2, %xmm7 + addsd 136(%eax), %xmm7 + addsd %xmm1, %xmm7 + addsd %xmm7, %xmm0 + movsd 5744(%ebx), %xmm7 + mulsd %xmm6, %xmm4 + movsd 168(%eax), %xmm2 + andpd %xmm6, %xmm2 + mulsd %xmm2, %xmm5 + mulsd 160(%eax), %xmm6 + subsd %xmm5, %xmm7 + subsd 128(%eax), %xmm2 + subsd %xmm4, %xmm7 + mulsd %xmm6, %xmm7 + movapd %xmm3, %xmm4 + subsd %xmm2, %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm4 + addsd %xmm4, %xmm0 + subsd %xmm7, %xmm0 + addsd %xmm3, %xmm0 + movsd %xmm0, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_0.0.2: + jg .L_2TAG_PACKET_2.0.2 + shrl $4, %eax + cmpl $268434558, %eax + jne .L_2TAG_PACKET_3.0.2 + movapd %xmm0, %xmm3 + mulsd 5808(%ebx), %xmm3 +.L_2TAG_PACKET_3.0.2: + movsd 5792(%ebx), %xmm3 + mulsd %xmm0, %xmm3 + addsd %xmm0, %xmm3 + mulsd 5808(%ebx), %xmm3 + movsd %xmm3, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + movq 5712(%ebx), %xmm7 + andpd %xmm0, %xmm7 + xorpd %xmm0, %xmm7 + ucomisd 5760(%ebx), %xmm7 + je .L_2TAG_PACKET_4.0.2 + subl $32, %esp + movsd %xmm0, (%esp) + lea 40(%esp), %eax + movl %eax, 8(%esp) + movl $2, %eax + movl %eax, 12(%esp) + call __libm_tancot_huge + addl $32, %esp + fldl 8(%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_4.0.2: + movq %xmm0, (%esp) + fldl (%esp) + fsubl (%esp) +.L_2TAG_PACKET_1.0.2: + movl 56(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type tan,@function + .size tan,.-tan + .data +# -- End tan + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 2284589306 + .long 1066820852 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1441186365 + .long 1065494243 + .long 1431655765 + .long 1070945621 + .long 0 + .long 0 + .long 0 + .long 0 + .long 236289504 + .long 1064135997 + .long 286331153 + .long 1069617425 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1160476131 + .long 1062722102 + .long 463583772 + .long 1068212666 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1313038235 + .long 1066745731 + .long 0 + .long 0 + .long 1013878342 + .long 1067152618 + .long 0 + .long 0 + .long 3663426833 + .long 1065725283 + .long 3693284251 + .long 1069118808 + .long 650852232 + .long 1065882376 + .long 1996245381 + .long 1071000265 + .long 2008746170 + .long 1064664197 + .long 3055842593 + .long 1068578846 + .long 1495406348 + .long 1064652437 + .long 2269530157 + .long 1069711235 + .long 285563696 + .long 1063576465 + .long 1046897440 + .long 1067705865 + .long 233429731 + .long 1063453151 + .long 522045958 + .long 1068476590 + .long 2354785698 + .long 1069102779 + .long 1317599141 + .long 1012432133 + .long 0 + .long 1072693248 + .long 2828230105 + .long 1065606626 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1512545955 + .long 1068119047 + .long 0 + .long 0 + .long 1127048698 + .long 1067909459 + .long 0 + .long 0 + .long 2300200450 + .long 1067254767 + .long 3593250296 + .long 1070233561 + .long 3009365544 + .long 1066902117 + .long 1127373050 + .long 1071173457 + .long 3046103305 + .long 1066371299 + .long 24583402 + .long 1069723988 + .long 4082511758 + .long 1065914199 + .long 3223889699 + .long 1070020367 + .long 548927984 + .long 1065415756 + .long 558065897 + .long 1068949418 + .long 680073315 + .long 1064940726 + .long 388873200 + .long 1068944270 + .long 3763679576 + .long 1070167541 + .long 1497360404 + .long 1009710547 + .long 0 + .long 1072693248 + .long 64931152 + .long 1067729411 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2467582782 + .long 1069256389 + .long 0 + .long 0 + .long 162150096 + .long 1068946420 + .long 0 + .long 0 + .long 3702794237 + .long 1068579152 + .long 3631919291 + .long 1070936926 + .long 3456821413 + .long 1068217218 + .long 2031366438 + .long 1071495745 + .long 1596664020 + .long 1067799281 + .long 1509038701 + .long 1070601643 + .long 583171477 + .long 1067510148 + .long 3785344682 + .long 1070618476 + .long 2402036048 + .long 1067075736 + .long 3233018412 + .long 1069913186 + .long 411280568 + .long 1066710556 + .long 1065584192 + .long 1069747896 + .long 895247324 + .long 1070819848 + .long 500078909 + .long 3161288781 + .long 0 + .long 1072693248 + .long 729983843 + .long 1068994194 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1458794562 + .long 1070398550 + .long 0 + .long 0 + .long 2857777489 + .long 1070137637 + .long 0 + .long 0 + .long 1024359517 + .long 1069876531 + .long 2616040238 + .long 1071582937 + .long 1609024636 + .long 1069675088 + .long 2529240549 + .long 1071836633 + .long 1510128600 + .long 1069440113 + .long 2251697184 + .long 1071253687 + .long 1262761453 + .long 1069142850 + .long 1263091857 + .long 1071190461 + .long 3043383486 + .long 1068885191 + .long 2476932470 + .long 1070842002 + .long 3659995028 + .long 1068669200 + .long 855891755 + .long 1070696894 + .long 2583490354 + .long 1071284857 + .long 3062633575 + .long 1014008623 + .long 0 + .long 1072693248 + .long 2550940471 + .long 1069938201 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3422807297 + .long 1071640847 + .long 0 + .long 0 + .long 1151658053 + .long 1071494715 + .long 0 + .long 0 + .long 929607071 + .long 1071346340 + .long 1037049034 + .long 1072037305 + .long 2786928657 + .long 1071215282 + .long 1447406859 + .long 1072265209 + .long 3490952107 + .long 1071090851 + .long 3205232916 + .long 1071968658 + .long 1297344304 + .long 1070977120 + .long 1066110976 + .long 1071946035 + .long 3803721480 + .long 1070871082 + .long 1496754229 + .long 1071807201 + .long 2982550683 + .long 1070773243 + .long 4014441989 + .long 1071736222 + .long 419968236 + .long 1071717047 + .long 3451266538 + .long 3163444811 + .long 0 + .long 1072693248 + .long 2960267235 + .long 1070745841 + .long 0 + .long 0 + .long 0 + .long 0 + .long 724322768 + .long 1072881308 + .long 0 + .long 0 + .long 643153048 + .long 1072905816 + .long 0 + .long 0 + .long 4285079458 + .long 1072928558 + .long 3912524733 + .long 1072622983 + .long 118362272 + .long 1072952754 + .long 4107767972 + .long 1072827408 + .long 2689502883 + .long 1072976922 + .long 946523347 + .long 1072772766 + .long 573204189 + .long 1073001761 + .long 581531518 + .long 1072826391 + .long 1386236526 + .long 1073026959 + .long 3718905905 + .long 1072832823 + .long 1145558140 + .long 1073052673 + .long 513572637 + .long 1072861969 + .long 716700048 + .long 1071997368 + .long 547126769 + .long 1015523525 + .long 0 + .long 1072693248 + .long 1097907398 + .long 1071420120 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3349892442 + .long 1074290212 + .long 0 + .long 0 + .long 3913197405 + .long 1074501181 + .long 0 + .long 0 + .long 2494034522 + .long 1074739170 + .long 1264738763 + .long 1073084804 + .long 1520293906 + .long 1074899632 + .long 1958936600 + .long 1073411493 + .long 2133649635 + .long 1075052171 + .long 4270740730 + .long 1073574708 + .long 1728930189 + .long 1075224844 + .long 1303998552 + .long 1073799186 + .long 618611933 + .long 1075420255 + .long 1769828046 + .long 1073938542 + .long 2200537986 + .long 1075641421 + .long 433361110 + .long 1074105369 + .long 719595600 + .long 1072317184 + .long 294527206 + .long 3162140088 + .long 0 + .long 1073741824 + .long 3811788216 + .long 3218400550 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1704352102 + .long 1075943001 + .long 0 + .long 0 + .long 2284589306 + .long 1076258036 + .long 0 + .long 0 + .long 2211264291 + .long 1076659010 + .long 0 + .long 1073741824 + .long 1441186365 + .long 1077028579 + .long 1431655765 + .long 1074091349 + .long 876943673 + .long 1077353622 + .long 2863311531 + .long 1074440874 + .long 236289504 + .long 1077767485 + .long 286331153 + .long 1074860305 + .long 2805473311 + .long 1078115278 + .long 95443718 + .long 1075163227 + .long 1160476131 + .long 1078450742 + .long 463583772 + .long 1075552698 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1330165971 + .long 3207850745 + .long 0 + .long 0 + .long 217536623 + .long 1059109098 + .long 0 + .long 0 + .long 3492120849 + .long 3205151475 + .long 602185705 + .long 3215678092 + .long 760422958 + .long 1056312597 + .long 555127889 + .long 1067545266 + .long 3139784124 + .long 3202470837 + .long 3690544014 + .long 3213150171 + .long 95707915 + .long 1053635428 + .long 4003114407 + .long 1064581412 + .long 2034926231 + .long 3199711161 + .long 3759536023 + .long 3210559989 + .long 3826928214 + .long 1050893819 + .long 3837960785 + .long 1061790379 + .long 1526325248 + .long 3217967566 + .long 2356426521 + .long 1025423456 + .long 0 + .long 0 + .long 457728975 + .long 1071088276 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1398462608 + .long 3207303968 + .long 0 + .long 0 + .long 26205983 + .long 1058461213 + .long 0 + .long 0 + .long 56226238 + .long 3204528612 + .long 2754706541 + .long 3215359511 + .long 2187799823 + .long 1055634437 + .long 790323742 + .long 1067402587 + .long 1372385848 + .long 3201651479 + .long 4097292716 + .long 3212856302 + .long 3348210357 + .long 1052830099 + .long 2442796466 + .long 1064337602 + .long 862608142 + .long 3198830754 + .long 170296152 + .long 3210060867 + .long 3755571428 + .long 1049933343 + .long 3614866008 + .long 1061361670 + .long 719978496 + .long 3217669096 + .long 1998842465 + .long 3174703977 + .long 0 + .long 0 + .long 3749156607 + .long 1071048258 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3120498638 + .long 3206749304 + .long 0 + .long 0 + .long 2773578114 + .long 1058009312 + .long 0 + .long 0 + .long 2030783676 + .long 3203817873 + .long 2223654598 + .long 3215071936 + .long 2976134650 + .long 1054987244 + .long 706390066 + .long 1067217386 + .long 4258437615 + .long 3200900378 + .long 1066252975 + .long 3212391267 + .long 815777514 + .long 1051989462 + .long 3202745457 + .long 1064010682 + .long 2493556375 + .long 3198004753 + .long 1046243251 + .long 3209678971 + .long 2593078846 + .long 1049017717 + .long 2763962276 + .long 1060970161 + .long 701480960 + .long 3217377742 + .long 3205862232 + .long 3174660915 + .long 0 + .long 0 + .long 2267016812 + .long 1071015664 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 2107155798 + .long 3206166872 + .long 0 + .long 0 + .long 2642992129 + .long 1057424578 + .long 0 + .long 0 + .long 1936992811 + .long 3203204426 + .long 1485063559 + .long 3214682643 + .long 1432914553 + .long 1054319398 + .long 3996381654 + .long 1067075828 + .long 2833029256 + .long 3200223545 + .long 2866066872 + .long 3211982662 + .long 2432888737 + .long 1051234178 + .long 3669764559 + .long 1063748136 + .long 2458496952 + .long 3197170774 + .long 1948234989 + .long 3209098147 + .long 2843698787 + .long 1048163519 + .long 3398041407 + .long 1060559728 + .long 2829230080 + .long 3217092115 + .long 1034046433 + .long 3174271903 + .long 0 + .long 0 + .long 298675305 + .long 1070989821 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 437603223 + .long 3205589761 + .long 0 + .long 0 + .long 759330352 + .long 1057048511 + .long 0 + .long 0 + .long 3107463368 + .long 3202507988 + .long 3144465176 + .long 3214191500 + .long 2290961810 + .long 1053841035 + .long 1618153340 + .long 1066971547 + .long 3836869393 + .long 3199400272 + .long 584032116 + .long 3211469261 + .long 1245704358 + .long 1050626462 + .long 4247487438 + .long 1063561943 + .long 1669034927 + .long 3196274812 + .long 3844233498 + .long 3208626322 + .long 2706958524 + .long 1047411374 + .long 3857199098 + .long 1060281647 + .long 3593904128 + .long 3216590719 + .long 3267547836 + .long 3172163321 + .long 0 + .long 0 + .long 4076712227 + .long 1070970214 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3290090340 + .long 3204793485 + .long 0 + .long 0 + .long 3685760367 + .long 1056668370 + .long 0 + .long 0 + .long 2655163949 + .long 3201674917 + .long 628750575 + .long 3213566872 + .long 680140505 + .long 1053299777 + .long 2954464709 + .long 1066900026 + .long 803201619 + .long 3198516435 + .long 1466315631 + .long 3210837162 + .long 1611220163 + .long 1049972438 + .long 2766187256 + .long 1063437894 + .long 1804579484 + .long 3195331491 + .long 3695969289 + .long 3207854418 + .long 2617238373 + .long 1046675948 + .long 3095830084 + .long 1060095334 + .long 3789570048 + .long 3216034914 + .long 23826559 + .long 3172048060 + .long 0 + .long 0 + .long 3870939386 + .long 1070956467 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1571758758 + .long 3203672535 + .long 0 + .long 0 + .long 113026373 + .long 1056416381 + .long 0 + .long 0 + .long 1913766298 + .long 3200523326 + .long 2507068734 + .long 3212502004 + .long 4000648818 + .long 1053003803 + .long 2446607349 + .long 1066858259 + .long 912662124 + .long 3197333001 + .long 1349489537 + .long 3209765608 + .long 3412972607 + .long 1049641401 + .long 1721283327 + .long 1063366855 + .long 1466691883 + .long 3194116746 + .long 3852528092 + .long 3206760861 + .long 285443293 + .long 1046158380 + .long 1758739894 + .long 1059895449 + .long 1858781184 + .long 3214984212 + .long 3447575948 + .long 1024675855 + .long 0 + .long 0 + .long 2242038011 + .long 1070948320 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 0 + .long 0 + .long 0 + .long 0 + .long 737611454 + .long 1056336527 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3594790527 + .long 1052911621 + .long 381774871 + .long 1066844524 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3303051618 + .long 1049456050 + .long 3154187623 + .long 1063343722 + .long 0 + .long 0 + .long 0 + .long 0 + .long 528061788 + .long 1045944910 + .long 2469719819 + .long 1059831159 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1431655765 + .long 1070945621 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1571758758 + .long 1056188887 + .long 0 + .long 0 + .long 113026373 + .long 1056416381 + .long 0 + .long 0 + .long 1913766298 + .long 1053039678 + .long 2507068734 + .long 1065018356 + .long 4000648818 + .long 1053003803 + .long 2446607349 + .long 1066858259 + .long 912662124 + .long 1049849353 + .long 1349489537 + .long 1062281960 + .long 3412972607 + .long 1049641401 + .long 1721283327 + .long 1063366855 + .long 1466691883 + .long 1046633098 + .long 3852528092 + .long 1059277213 + .long 285443293 + .long 1046158380 + .long 1758739894 + .long 1059895449 + .long 1858781184 + .long 1067500564 + .long 3447575948 + .long 3172159503 + .long 0 + .long 0 + .long 2242038011 + .long 1070948320 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3290090340 + .long 1057309837 + .long 0 + .long 0 + .long 3685760367 + .long 1056668370 + .long 0 + .long 0 + .long 2655163949 + .long 1054191269 + .long 628750575 + .long 1066083224 + .long 680140505 + .long 1053299777 + .long 2954464709 + .long 1066900026 + .long 803201619 + .long 1051032787 + .long 1466315631 + .long 1063353514 + .long 1611220163 + .long 1049972438 + .long 2766187256 + .long 1063437894 + .long 1804579484 + .long 1047847843 + .long 3695969289 + .long 1060370770 + .long 2617238373 + .long 1046675948 + .long 3095830084 + .long 1060095334 + .long 3789570048 + .long 1068551266 + .long 23826559 + .long 1024564412 + .long 0 + .long 0 + .long 3870939386 + .long 1070956467 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 437603223 + .long 1058106113 + .long 0 + .long 0 + .long 759330352 + .long 1057048511 + .long 0 + .long 0 + .long 3107463368 + .long 1055024340 + .long 3144465176 + .long 1066707852 + .long 2290961810 + .long 1053841035 + .long 1618153340 + .long 1066971547 + .long 3836869393 + .long 1051916624 + .long 584032116 + .long 1063985613 + .long 1245704358 + .long 1050626462 + .long 4247487438 + .long 1063561943 + .long 1669034927 + .long 1048791164 + .long 3844233498 + .long 1061142674 + .long 2706958524 + .long 1047411374 + .long 3857199098 + .long 1060281647 + .long 3593904128 + .long 1069107071 + .long 3267547836 + .long 1024679673 + .long 0 + .long 0 + .long 4076712227 + .long 1070970214 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 2107155798 + .long 1058683224 + .long 0 + .long 0 + .long 2642992129 + .long 1057424578 + .long 0 + .long 0 + .long 1936992811 + .long 1055720778 + .long 1485063559 + .long 1067198995 + .long 1432914553 + .long 1054319398 + .long 3996381654 + .long 1067075828 + .long 2833029256 + .long 1052739897 + .long 2866066872 + .long 1064499014 + .long 2432888737 + .long 1051234178 + .long 3669764559 + .long 1063748136 + .long 2458496952 + .long 1049687126 + .long 1948234989 + .long 1061614499 + .long 2843698787 + .long 1048163519 + .long 3398041407 + .long 1060559728 + .long 2829230080 + .long 1069608467 + .long 1034046433 + .long 1026788255 + .long 0 + .long 0 + .long 298675305 + .long 1070989821 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3120498638 + .long 1059265656 + .long 0 + .long 0 + .long 2773578114 + .long 1058009312 + .long 0 + .long 0 + .long 2030783676 + .long 1056334225 + .long 2223654598 + .long 1067588288 + .long 2976134650 + .long 1054987244 + .long 706390066 + .long 1067217386 + .long 4258437615 + .long 1053416730 + .long 1066252975 + .long 1064907619 + .long 815777514 + .long 1051989462 + .long 3202745457 + .long 1064010682 + .long 2493556375 + .long 1050521105 + .long 1046243251 + .long 1062195323 + .long 2593078846 + .long 1049017717 + .long 2763962276 + .long 1060970161 + .long 701480960 + .long 1069894094 + .long 3205862232 + .long 1027177267 + .long 0 + .long 0 + .long 2267016812 + .long 1071015664 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1398462608 + .long 1059820320 + .long 0 + .long 0 + .long 26205983 + .long 1058461213 + .long 0 + .long 0 + .long 56226238 + .long 1057044964 + .long 2754706541 + .long 1067875863 + .long 2187799823 + .long 1055634437 + .long 790323742 + .long 1067402587 + .long 1372385848 + .long 1054167831 + .long 4097292716 + .long 1065372654 + .long 3348210357 + .long 1052830099 + .long 2442796466 + .long 1064337602 + .long 862608142 + .long 1051347106 + .long 170296152 + .long 1062577219 + .long 3755571428 + .long 1049933343 + .long 3614866008 + .long 1061361670 + .long 719978496 + .long 1070185448 + .long 1998842465 + .long 1027220329 + .long 0 + .long 0 + .long 3749156607 + .long 1071048258 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1330165971 + .long 1060367097 + .long 0 + .long 0 + .long 217536623 + .long 1059109098 + .long 0 + .long 0 + .long 3492120849 + .long 1057667827 + .long 602185705 + .long 1068194444 + .long 760422958 + .long 1056312597 + .long 555127889 + .long 1067545266 + .long 3139784124 + .long 1054987189 + .long 3690544014 + .long 1065666523 + .long 95707915 + .long 1053635428 + .long 4003114407 + .long 1064581412 + .long 2034926231 + .long 1052227513 + .long 3759536023 + .long 1063076341 + .long 3826928214 + .long 1050893819 + .long 3837960785 + .long 1061790379 + .long 1526325248 + .long 1070483918 + .long 2356426521 + .long 3172907104 + .long 0 + .long 0 + .long 457728975 + .long 1071088276 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1704352102 + .long 3223426649 + .long 0 + .long 0 + .long 2284589306 + .long 1076258036 + .long 0 + .long 0 + .long 2211264291 + .long 3224142658 + .long 0 + .long 3221225472 + .long 1441186365 + .long 1077028579 + .long 1431655765 + .long 1074091349 + .long 876943673 + .long 3224837270 + .long 2863311531 + .long 3221924522 + .long 236289504 + .long 1077767485 + .long 286331153 + .long 1074860305 + .long 2805473311 + .long 3225598926 + .long 95443718 + .long 3222646875 + .long 1160476131 + .long 1078450742 + .long 463583772 + .long 1075552698 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3349892442 + .long 3221773860 + .long 0 + .long 0 + .long 3913197405 + .long 1074501181 + .long 0 + .long 0 + .long 2494034522 + .long 3222222818 + .long 1264738763 + .long 3220568452 + .long 1520293906 + .long 1074899632 + .long 1958936600 + .long 1073411493 + .long 2133649635 + .long 3222535819 + .long 4270740730 + .long 3221058356 + .long 1728930189 + .long 1075224844 + .long 1303998552 + .long 1073799186 + .long 618611933 + .long 3222903903 + .long 1769828046 + .long 3221422190 + .long 2200537986 + .long 1075641421 + .long 433361110 + .long 1074105369 + .long 719595600 + .long 3219800832 + .long 294527206 + .long 1014656440 + .long 0 + .long 1073741824 + .long 3811788216 + .long 3218400550 + .long 0 + .long 0 + .long 0 + .long 0 + .long 724322768 + .long 3220364956 + .long 0 + .long 0 + .long 643153048 + .long 1072905816 + .long 0 + .long 0 + .long 4285079458 + .long 3220412206 + .long 3912524733 + .long 3220106631 + .long 118362272 + .long 1072952754 + .long 4107767972 + .long 1072827408 + .long 2689502883 + .long 3220460570 + .long 946523347 + .long 3220256414 + .long 573204189 + .long 1073001761 + .long 581531518 + .long 1072826391 + .long 1386236526 + .long 3220510607 + .long 3718905905 + .long 3220316471 + .long 1145558140 + .long 1073052673 + .long 513572637 + .long 1072861969 + .long 716700048 + .long 3219481016 + .long 547126769 + .long 3163007173 + .long 0 + .long 1072693248 + .long 1097907398 + .long 1071420120 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3422807297 + .long 3219124495 + .long 0 + .long 0 + .long 1151658053 + .long 1071494715 + .long 0 + .long 0 + .long 929607071 + .long 3218829988 + .long 1037049034 + .long 3219520953 + .long 2786928657 + .long 1071215282 + .long 1447406859 + .long 1072265209 + .long 3490952107 + .long 3218574499 + .long 3205232916 + .long 3219452306 + .long 1297344304 + .long 1070977120 + .long 1066110976 + .long 1071946035 + .long 3803721480 + .long 3218354730 + .long 1496754229 + .long 3219290849 + .long 2982550683 + .long 1070773243 + .long 4014441989 + .long 1071736222 + .long 419968236 + .long 3219200695 + .long 3451266538 + .long 1015961163 + .long 0 + .long 1072693248 + .long 2960267235 + .long 1070745841 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1458794562 + .long 3217882198 + .long 0 + .long 0 + .long 2857777489 + .long 1070137637 + .long 0 + .long 0 + .long 1024359517 + .long 3217360179 + .long 2616040238 + .long 3219066585 + .long 1609024636 + .long 1069675088 + .long 2529240549 + .long 1071836633 + .long 1510128600 + .long 3216923761 + .long 2251697184 + .long 3218737335 + .long 1262761453 + .long 1069142850 + .long 1263091857 + .long 1071190461 + .long 3043383486 + .long 3216368839 + .long 2476932470 + .long 3218325650 + .long 3659995028 + .long 1068669200 + .long 855891755 + .long 1070696894 + .long 2583490354 + .long 3218768505 + .long 3062633575 + .long 3161492271 + .long 0 + .long 1072693248 + .long 2550940471 + .long 1069938201 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2467582782 + .long 3216740037 + .long 0 + .long 0 + .long 162150096 + .long 1068946420 + .long 0 + .long 0 + .long 3702794237 + .long 3216062800 + .long 3631919291 + .long 3218420574 + .long 3456821413 + .long 1068217218 + .long 2031366438 + .long 1071495745 + .long 1596664020 + .long 3215282929 + .long 1509038701 + .long 3218085291 + .long 583171477 + .long 1067510148 + .long 3785344682 + .long 1070618476 + .long 2402036048 + .long 3214559384 + .long 3233018412 + .long 3217396834 + .long 411280568 + .long 1066710556 + .long 1065584192 + .long 1069747896 + .long 895247324 + .long 3218303496 + .long 500078909 + .long 1013805133 + .long 0 + .long 1072693248 + .long 729983843 + .long 1068994194 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1512545955 + .long 3215602695 + .long 0 + .long 0 + .long 1127048698 + .long 1067909459 + .long 0 + .long 0 + .long 2300200450 + .long 3214738415 + .long 3593250296 + .long 3217717209 + .long 3009365544 + .long 1066902117 + .long 1127373050 + .long 1071173457 + .long 3046103305 + .long 3213854947 + .long 24583402 + .long 3217207636 + .long 4082511758 + .long 1065914199 + .long 3223889699 + .long 1070020367 + .long 548927984 + .long 3212899404 + .long 558065897 + .long 3216433066 + .long 680073315 + .long 1064940726 + .long 388873200 + .long 1068944270 + .long 3763679576 + .long 3217651189 + .long 1497360404 + .long 3157194195 + .long 0 + .long 1072693248 + .long 64931152 + .long 1067729411 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1313038235 + .long 3214229379 + .long 0 + .long 0 + .long 1013878342 + .long 1067152618 + .long 0 + .long 0 + .long 3663426833 + .long 3213208931 + .long 3693284251 + .long 3216602456 + .long 650852232 + .long 1065882376 + .long 1996245381 + .long 1071000265 + .long 2008746170 + .long 3212147845 + .long 3055842593 + .long 3216062494 + .long 1495406348 + .long 1064652437 + .long 2269530157 + .long 1069711235 + .long 285563696 + .long 3211060113 + .long 1046897440 + .long 3215189513 + .long 233429731 + .long 1063453151 + .long 522045958 + .long 1068476590 + .long 2354785698 + .long 3216586427 + .long 1317599141 + .long 3159915781 + .long 0 + .long 1072693248 + .long 2828230105 + .long 1065606626 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1841940611 + .long 1071931184 + .long 1841940611 + .long 1076125488 + .long 0 + .long 1131937792 + .long 0 + .long 1127743488 + .long 1413758976 + .long 1069097467 + .long 1413742592 + .long 1069097467 + .long 1734819840 + .long 3174229945 + .long 1280049152 + .long 1028033571 + .long 923219018 + .long 984130272 + .long 57701189 + .long 988383790 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 1734816687 + .long 1026746297 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 4294705152 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 1130364928 + .long 0 + .long 0 + .long 0 + .long 1015021568 + .long 0 + .long 0 + .long 0 + .long 1017118720 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 0 + .long 1076887552 + .long 0 + .long 1072693248 + .type static_const_table,@object + .size static_const_table,5872 + .data + .hidden __libm_tancot_huge + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tanf_wmt.S b/external/sgx_libm/ia32/tanf_wmt.S new file mode 100644 index 0000000000..58ae7e0bf7 --- /dev/null +++ b/external/sgx_libm/ia32/tanf_wmt.S @@ -0,0 +1,1045 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin tanf + .text + .align 16,0x90 + .globl tanf +tanf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $120, %esp + movl %ebx, 56(%esp) + call static_func + movl %eax, %ebx + movss 128(%esp), %xmm0 + subl $16, %esp + stmxcsr 4(%esp) + movl 4(%esp), %eax + andl $-24577, %eax + cmpl %eax, 4(%esp) + jne .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + pextrw $1, %xmm0, %eax + andl $32767, %eax + subl $128, %eax + cmpl $18175, %eax + ja .L_2TAG_PACKET_2.0.2 + movsd 2656(%ebx), %xmm1 + mulss %xmm0, %xmm1 + movapd 2544(%ebx), %xmm7 + cvtss2si %xmm1, %edx + andpd %xmm0, %xmm7 + cvtss2sd %xmm0, %xmm0 +.L_2TAG_PACKET_3.0.2: + movsd 2672(%ebx), %xmm4 + addss %xmm1, %xmm4 + addss 2704(%ebx), %xmm1 + subss 2672(%ebx), %xmm4 + subss 2704(%ebx), %xmm1 + movapd %xmm7, %xmm5 + psllq $32, %xmm7 + psllq $29, %xmm5 + xorpd %xmm5, %xmm7 + addl $1865216, %edx + andl $31, %edx + movsd 2608(%ebx), %xmm5 + xorpd %xmm7, %xmm5 + movsd 2576(%ebx), %xmm2 + xorpd %xmm7, %xmm2 + movsd 2592(%ebx), %xmm6 + xorpd %xmm7, %xmm6 + movsd 2560(%ebx), %xmm3 + xorpd %xmm7, %xmm3 + lea (%ebx), %eax + shll $3, %edx + addl %edx, %eax + shll $3, %edx + addl %edx, %eax + psllq $29, %xmm4 + psllq $29, %xmm1 + mulsd %xmm4, %xmm5 + mulsd %xmm1, %xmm2 + mulsd %xmm4, %xmm6 + mulsd %xmm1, %xmm3 + addsd %xmm0, %xmm5 + addsd %xmm0, %xmm2 + addsd %xmm6, %xmm5 + addsd %xmm3, %xmm2 + movsd 2624(%ebx), %xmm7 + divsd %xmm5, %xmm7 + mulsd 64(%eax), %xmm7 + movsd 56(%eax), %xmm3 + mulsd %xmm2, %xmm3 + movsd 24(%eax), %xmm4 + mulsd %xmm2, %xmm4 + movsd 40(%eax), %xmm5 + mulsd %xmm2, %xmm5 + movsd 8(%eax), %xmm6 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm2 + addsd 48(%eax), %xmm3 + addsd 16(%eax), %xmm4 + addsd 32(%eax), %xmm5 + addsd (%eax), %xmm6 + mulsd %xmm2, %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm2 + addsd %xmm5, %xmm3 + addsd %xmm6, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm4, %xmm3 + subsd %xmm7, %xmm3 + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_4.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_4.0.2: + movsd %xmm3, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_2.0.2: + jg .L_2TAG_PACKET_6.0.2 + cvtss2sd %xmm0, %xmm0 + mulsd 2640(%ebx), %xmm0 + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_7.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_7.0.2: + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, (%esp) + flds (%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_0.0.2: + movl 4(%esp), %eax + andl $-24577, %eax + movl %eax, 8(%esp) + ldmxcsr 8(%esp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_6.0.2: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_8.0.2 + pshuflw $68, %xmm0, %xmm1 + movd %xmm0, %ecx + cvtps2pd %xmm1, %xmm1 + andl $2147483647, %ecx + subl $964689920, %ecx + shrl $23, %ecx + subl $27, %ecx + andl $65528, %ecx + movsd 2304(%ebx,%ecx,2), %xmm3 + movsd 2312(%ebx,%ecx,2), %xmm5 + movsd 2736(%ebx), %xmm2 + xorpd %xmm4, %xmm4 + movl $17352, %edx + pinsrw $3, %edx, %xmm4 + andpd %xmm3, %xmm2 + psllq $40, %xmm3 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + movapd %xmm2, %xmm0 + addsd %xmm3, %xmm2 + movapd %xmm2, %xmm5 + subsd %xmm2, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm3, %xmm0 + movsd 2720(%ebx), %xmm6 + subsd %xmm4, %xmm2 + addsd %xmm1, %xmm0 + subsd %xmm2, %xmm5 + movsd %xmm5, %xmm1 + andpd 2768(%ebx), %xmm5 + subsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + movsd %xmm5, %xmm6 + mulsd 2752(%ebx), %xmm5 + mulsd 2760(%ebx), %xmm6 + mulsd 2720(%ebx), %xmm0 + addsd %xmm6, %xmm0 + movsd %xmm5, 8(%esp) + movsd %xmm0, 16(%esp) + cvtpd2ps %xmm5, %xmm2 + movss 2656(%ebx), %xmm1 + mulss %xmm2, %xmm1 + movaps 2544(%ebx), %xmm7 + cvtss2si %xmm1, %edx + andps %xmm2, %xmm7 + movsd 2672(%ebx), %xmm4 + addss %xmm1, %xmm4 + addss 2704(%ebx), %xmm1 + subss 2672(%ebx), %xmm4 + subss 2704(%ebx), %xmm1 + movapd %xmm7, %xmm5 + psllq $32, %xmm7 + psllq $29, %xmm5 + xorpd %xmm5, %xmm7 + addl $1865216, %edx + andl $31, %edx + movsd 2608(%ebx), %xmm5 + xorpd %xmm7, %xmm5 + movsd 2576(%ebx), %xmm2 + xorpd %xmm7, %xmm2 + movsd 2592(%ebx), %xmm6 + xorpd %xmm7, %xmm6 + movsd 2560(%ebx), %xmm3 + xorpd %xmm7, %xmm3 + lea (%ebx), %eax + shll $3, %edx + addl %edx, %eax + shll $3, %edx + addl %edx, %eax + psllq $29, %xmm4 + psllq $29, %xmm1 + mulsd %xmm4, %xmm5 + mulsd %xmm1, %xmm2 + mulsd %xmm4, %xmm6 + mulsd %xmm1, %xmm3 + addsd 8(%esp), %xmm5 + addsd 16(%esp), %xmm5 + addsd 8(%esp), %xmm2 + addsd 16(%esp), %xmm2 + addsd %xmm6, %xmm5 + addsd %xmm3, %xmm2 + movsd 2624(%ebx), %xmm7 + divsd %xmm5, %xmm7 + mulsd 64(%eax), %xmm7 + movsd 56(%eax), %xmm3 + mulsd %xmm2, %xmm3 + movsd 24(%eax), %xmm4 + mulsd %xmm2, %xmm4 + movsd 40(%eax), %xmm5 + mulsd %xmm2, %xmm5 + movsd 8(%eax), %xmm6 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm2 + addsd 48(%eax), %xmm3 + addsd 16(%eax), %xmm4 + addsd 32(%eax), %xmm5 + addsd (%eax), %xmm6 + mulsd %xmm2, %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm2 + addsd %xmm5, %xmm3 + addsd %xmm6, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm4, %xmm3 + subsd %xmm7, %xmm3 + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_9.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_9.0.2: + movsd %xmm3, (%esp) + fldl (%esp) + jmp .L_2TAG_PACKET_5.0.2 +.L_2TAG_PACKET_8.0.2: + movl 4(%esp), %eax + andl $-24577, %eax + cmpl 4(%esp), %eax + je .L_2TAG_PACKET_10.0.2 + stmxcsr 8(%esp) + movl 4(%esp), %eax + andl $24576, %eax + orl %eax, 8(%esp) + ldmxcsr 8(%esp) +.L_2TAG_PACKET_10.0.2: + movss %xmm0, (%esp) + flds (%esp) + fsubs (%esp) +.L_2TAG_PACKET_5.0.2: + addl $16, %esp + movl 56(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type tanf,@function + .size tanf,.-tanf + .data +# -- End tanf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1431655765 + .long 1070945621 + .long 0 + .long 0 + .long 286331153 + .long 1069617425 + .long 0 + .long 0 + .long 463583772 + .long 1068212666 + .long 0 + .long 0 + .long 2354785698 + .long 1069102779 + .long 3310429884 + .long 1072703419 + .long 3693284251 + .long 1069118808 + .long 1996245381 + .long 1071000265 + .long 3055842593 + .long 1068578846 + .long 2269530157 + .long 1069711235 + .long 1046897440 + .long 1067705865 + .long 522045958 + .long 1068476590 + .long 0 + .long 0 + .long 3763679576 + .long 1070167541 + .long 404682282 + .long 1072734736 + .long 3593250296 + .long 1070233561 + .long 1127373050 + .long 1071173457 + .long 24583402 + .long 1069723988 + .long 3223889699 + .long 1070020367 + .long 558065897 + .long 1068949418 + .long 388873200 + .long 1068944270 + .long 0 + .long 0 + .long 895247324 + .long 1070819848 + .long 582494902 + .long 1072789737 + .long 3631919291 + .long 1070936926 + .long 2031366438 + .long 1071495745 + .long 1509038701 + .long 1070601643 + .long 3785344682 + .long 1070618476 + .long 3233018412 + .long 1069913186 + .long 1065584192 + .long 1069747896 + .long 0 + .long 0 + .long 2583490354 + .long 1071284857 + .long 855738471 + .long 1072873155 + .long 2616040238 + .long 1071582937 + .long 2529240549 + .long 1071836633 + .long 2251697184 + .long 1071253687 + .long 1263091857 + .long 1071190461 + .long 2476932470 + .long 1070842002 + .long 855891755 + .long 1070696894 + .long 0 + .long 0 + .long 419968236 + .long 1071717047 + .long 1813808633 + .long 1072992828 + .long 1037049034 + .long 1072037305 + .long 1447406859 + .long 1072265209 + .long 3205232916 + .long 1071968658 + .long 1066110976 + .long 1071946035 + .long 1496754229 + .long 1071807201 + .long 4014441989 + .long 1071736222 + .long 0 + .long 0 + .long 716700048 + .long 1071997368 + .long 274476850 + .long 1073161398 + .long 3912524733 + .long 1072622983 + .long 4107767972 + .long 1072827408 + .long 946523347 + .long 1072772766 + .long 581531518 + .long 1072826391 + .long 3718905905 + .long 1072832823 + .long 513572637 + .long 1072861969 + .long 0 + .long 0 + .long 719595600 + .long 1072317184 + .long 1194536594 + .long 1073399478 + .long 1264738763 + .long 1073084804 + .long 1958936600 + .long 1073411493 + .long 4270740730 + .long 1073574708 + .long 1303998552 + .long 1073799186 + .long 1769828046 + .long 1073938542 + .long 433361110 + .long 1074105369 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 1073741824 + .long 0 + .long 1073741824 + .long 1431655765 + .long 1074091349 + .long 2863311531 + .long 1074440874 + .long 286331153 + .long 1074860305 + .long 95443718 + .long 1075163227 + .long 463583772 + .long 1075552698 + .long 0 + .long 0 + .long 1526324265 + .long 3217967566 + .long 457728975 + .long 1071088276 + .long 602185705 + .long 3215678092 + .long 555127889 + .long 1067545266 + .long 3690544014 + .long 3213150171 + .long 4003114407 + .long 1064581412 + .long 3759536023 + .long 3210559989 + .long 3837960785 + .long 1061790379 + .long 0 + .long 1072693248 + .long 719981842 + .long 3217669096 + .long 3749156607 + .long 1071048258 + .long 2754706541 + .long 3215359511 + .long 790323742 + .long 1067402587 + .long 4097292716 + .long 3212856302 + .long 2442796466 + .long 1064337602 + .long 170296152 + .long 3210060867 + .long 3614866008 + .long 1061361670 + .long 0 + .long 1072693248 + .long 701484222 + .long 3217377742 + .long 2267016812 + .long 1071015664 + .long 2223654598 + .long 3215071936 + .long 706390066 + .long 1067217386 + .long 1066252975 + .long 3212391267 + .long 3202745457 + .long 1064010682 + .long 1046243251 + .long 3209678971 + .long 2763962276 + .long 1060970161 + .long 0 + .long 1072693248 + .long 2829232582 + .long 3217092115 + .long 298675305 + .long 1070989821 + .long 1485063559 + .long 3214682643 + .long 3996381654 + .long 1067075828 + .long 2866066872 + .long 3211982662 + .long 3669764559 + .long 1063748136 + .long 1948234989 + .long 3209098147 + .long 3398041407 + .long 1060559728 + .long 0 + .long 1072693248 + .long 3593905368 + .long 3216590719 + .long 4076712227 + .long 1070970214 + .long 3144465176 + .long 3214191500 + .long 1618153340 + .long 1066971547 + .long 584032116 + .long 3211469261 + .long 4247487438 + .long 1063561943 + .long 3844233498 + .long 3208626322 + .long 3857199098 + .long 1060281647 + .long 0 + .long 1072693248 + .long 3789571175 + .long 3216034914 + .long 3870939386 + .long 1070956467 + .long 628750575 + .long 3213566872 + .long 2954464709 + .long 1066900026 + .long 1466315631 + .long 3210837162 + .long 2766187256 + .long 1063437894 + .long 3695969289 + .long 3207854418 + .long 3095830084 + .long 1060095334 + .long 0 + .long 1072693248 + .long 1858778712 + .long 3214984212 + .long 2242038011 + .long 1070948320 + .long 2507068734 + .long 3212502004 + .long 2446607349 + .long 1066858259 + .long 1349489537 + .long 3209765608 + .long 1721283327 + .long 1063366855 + .long 3852528092 + .long 3206760861 + .long 1758739894 + .long 1059895449 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1431655765 + .long 1070945621 + .long 0 + .long 0 + .long 381774871 + .long 1066844524 + .long 0 + .long 0 + .long 3154187623 + .long 1063343722 + .long 0 + .long 0 + .long 2469719819 + .long 1059831159 + .long 0 + .long 1072693248 + .long 1858778712 + .long 1067500564 + .long 2242038011 + .long 1070948320 + .long 2507068734 + .long 1065018356 + .long 2446607349 + .long 1066858259 + .long 1349489537 + .long 1062281960 + .long 1721283327 + .long 1063366855 + .long 3852528092 + .long 1059277213 + .long 1758739894 + .long 1059895449 + .long 0 + .long 1072693248 + .long 3789571175 + .long 1068551266 + .long 3870939386 + .long 1070956467 + .long 628750575 + .long 1066083224 + .long 2954464709 + .long 1066900026 + .long 1466315631 + .long 1063353514 + .long 2766187256 + .long 1063437894 + .long 3695969289 + .long 1060370770 + .long 3095830084 + .long 1060095334 + .long 0 + .long 1072693248 + .long 3593905368 + .long 1069107071 + .long 4076712227 + .long 1070970214 + .long 3144465176 + .long 1066707852 + .long 1618153340 + .long 1066971547 + .long 584032116 + .long 1063985613 + .long 4247487438 + .long 1063561943 + .long 3844233498 + .long 1061142674 + .long 3857199098 + .long 1060281647 + .long 0 + .long 1072693248 + .long 2829232582 + .long 1069608467 + .long 298675305 + .long 1070989821 + .long 1485063559 + .long 1067198995 + .long 3996381654 + .long 1067075828 + .long 2866066872 + .long 1064499014 + .long 3669764559 + .long 1063748136 + .long 1948234989 + .long 1061614499 + .long 3398041407 + .long 1060559728 + .long 0 + .long 1072693248 + .long 701484222 + .long 1069894094 + .long 2267016812 + .long 1071015664 + .long 2223654598 + .long 1067588288 + .long 706390066 + .long 1067217386 + .long 1066252975 + .long 1064907619 + .long 3202745457 + .long 1064010682 + .long 1046243251 + .long 1062195323 + .long 2763962276 + .long 1060970161 + .long 0 + .long 1072693248 + .long 719981842 + .long 1070185448 + .long 3749156607 + .long 1071048258 + .long 2754706541 + .long 1067875863 + .long 790323742 + .long 1067402587 + .long 4097292716 + .long 1065372654 + .long 2442796466 + .long 1064337602 + .long 170296152 + .long 1062577219 + .long 3614866008 + .long 1061361670 + .long 0 + .long 1072693248 + .long 1526324265 + .long 1070483918 + .long 457728975 + .long 1071088276 + .long 602185705 + .long 1068194444 + .long 555127889 + .long 1067545266 + .long 3690544014 + .long 1065666523 + .long 4003114407 + .long 1064581412 + .long 3759536023 + .long 1063076341 + .long 3837960785 + .long 1061790379 + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .long 0 + .long 1073741824 + .long 0 + .long 3221225472 + .long 1431655765 + .long 1074091349 + .long 2863311531 + .long 3221924522 + .long 286331153 + .long 1074860305 + .long 95443718 + .long 3222646875 + .long 463583772 + .long 1075552698 + .long 0 + .long 0 + .long 719595600 + .long 3219800832 + .long 1194536594 + .long 1073399478 + .long 1264738763 + .long 3220568452 + .long 1958936600 + .long 1073411493 + .long 4270740730 + .long 3221058356 + .long 1303998552 + .long 1073799186 + .long 1769828046 + .long 3221422190 + .long 433361110 + .long 1074105369 + .long 0 + .long 0 + .long 716700048 + .long 3219481016 + .long 274476850 + .long 1073161398 + .long 3912524733 + .long 3220106631 + .long 4107767972 + .long 1072827408 + .long 946523347 + .long 3220256414 + .long 581531518 + .long 1072826391 + .long 3718905905 + .long 3220316471 + .long 513572637 + .long 1072861969 + .long 0 + .long 0 + .long 419968236 + .long 3219200695 + .long 1813808633 + .long 1072992828 + .long 1037049034 + .long 3219520953 + .long 1447406859 + .long 1072265209 + .long 3205232916 + .long 3219452306 + .long 1066110976 + .long 1071946035 + .long 1496754229 + .long 3219290849 + .long 4014441989 + .long 1071736222 + .long 0 + .long 0 + .long 2583490354 + .long 3218768505 + .long 855738471 + .long 1072873155 + .long 2616040238 + .long 3219066585 + .long 2529240549 + .long 1071836633 + .long 2251697184 + .long 3218737335 + .long 1263091857 + .long 1071190461 + .long 2476932470 + .long 3218325650 + .long 855891755 + .long 1070696894 + .long 0 + .long 0 + .long 895247324 + .long 3218303496 + .long 582494902 + .long 1072789737 + .long 3631919291 + .long 3218420574 + .long 2031366438 + .long 1071495745 + .long 1509038701 + .long 3218085291 + .long 3785344682 + .long 1070618476 + .long 3233018412 + .long 3217396834 + .long 1065584192 + .long 1069747896 + .long 0 + .long 0 + .long 3763679576 + .long 3217651189 + .long 404682282 + .long 1072734736 + .long 3593250296 + .long 3217717209 + .long 1127373050 + .long 1071173457 + .long 24583402 + .long 3217207636 + .long 3223889699 + .long 1070020367 + .long 558065897 + .long 3216433066 + .long 388873200 + .long 1068944270 + .long 0 + .long 0 + .long 2354785698 + .long 3216586427 + .long 3310429884 + .long 1072703419 + .long 3693284251 + .long 3216602456 + .long 1996245381 + .long 1071000265 + .long 3055842593 + .long 3216062494 + .long 2269530157 + .long 1069711235 + .long 1046897440 + .long 3215189513 + .long 522045958 + .long 1068476590 + .long 0 + .long 0 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1916669064 + .long 1072155675 + .long 660066805 + .long 1024797180 + .long 3829231700 + .long 1062745828 + .long 2884172442 + .long 1017445907 + .long 540874025 + .long 1055617650 + .long 4198409884 + .long 1011844330 + .long 2839315448 + .long 1046639136 + .long 4204424928 + .long 1000582120 + .long 1329339431 + .long 1038229673 + .long 1295478839 + .long 993391741 + .long 658191860 + .long 1024797180 + .long 3691886121 + .long 979325773 + .long 1966800710 + .long 1020436418 + .long 1882642597 + .long 977095991 + .long 2100977488 + .long 1012908661 + .long 1840335565 + .long 967470816 + .long 4198093645 + .long 1000582120 + .long 3307942521 + .long 957055414 + .long 2839123165 + .long 996851343 + .long 1387472776 + .long 952638316 + .long 2788761024 + .long 988712873 + .long 3005712498 + .long 944467026 + .long 3694676832 + .long 979325773 + .long 1326507024 + .long 934847846 + .long 221775557 + .long 970149340 + .long 1133527550 + .long 924162364 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 3409656221 + .long 1972279101 + .long 0 + .long 0 + .long 1414004736 + .long 4156105211 + .long 0 + .long 0 + .long 1280075305 + .long 4115041315 + .long 0 + .long 0 + .long 1413742592 + .long 4156105211 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 4194304 + .long 1072693248 + .long 0 + .long 0 + .long 1092811139 + .long 0 + .long 0 + .long 0 + .long 1296039936 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 1262485504 + .long 0 + .long 0 + .long 0 + .long 1413754136 + .long 1067000315 + .long 0 + .long 0 + .long 4278190080 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 1067000315 + .long 1175561766 + .long 1043665163 + .long 4290772992 + .long 4294967295 + .long 4290772992 + .long 4294967295 + .type static_const_table,@object + .size static_const_table,2784 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tanh_wmt.S b/external/sgx_libm/ia32/tanh_wmt.S new file mode 100644 index 0000000000..a232a7d3a0 --- /dev/null +++ b/external/sgx_libm/ia32/tanh_wmt.S @@ -0,0 +1,1329 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanh_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin tanh + .text + .align 16,0x90 + .globl tanh +tanh: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movsd 4256(%ebx), %xmm3 + xorpd %xmm4, %xmm4 + movsd 4112(%ebx), %xmm1 + movsd 4120(%ebx), %xmm2 + movl $32768, %eax + pinsrw $3, %eax, %xmm4 + movsd 4096(%ebx), %xmm6 + pextrw $3, %xmm0, %ecx + andpd %xmm0, %xmm3 + andnpd %xmm0, %xmm4 + pshufd $68, %xmm4, %xmm5 + movl $32768, %edx + andl %ecx, %edx + andl $32767, %ecx + subl $16304, %ecx + cmpl $144, %ecx + jae .L_2TAG_PACKET_0.0.2 + subsd %xmm3, %xmm4 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm2 + cvtsd2si %xmm3, %eax + movapd %xmm3, %xmm7 + addsd %xmm6, %xmm3 + mulsd %xmm4, %xmm1 + movsd 4264(%ebx), %xmm4 + subsd %xmm6, %xmm3 + xorpd %xmm0, %xmm0 + addsd %xmm1, %xmm2 + subsd %xmm3, %xmm7 + movapd 4128(%ebx), %xmm6 + addsd %xmm7, %xmm2 + movl $255, %ecx + andl %eax, %ecx + addl %ecx, %ecx + movapd (%ebx,%ecx,8), %xmm5 + shrl $4, %eax + andl $65520, %eax + subl $16368, %eax + negl %eax + pinsrw $3, %eax, %xmm0 + movapd 4144(%ebx), %xmm1 + pshufd $68, %xmm0, %xmm0 + mulpd %xmm5, %xmm0 + movsd 4160(%ebx), %xmm7 + pshufd $68, %xmm2, %xmm2 + movapd %xmm4, %xmm5 + addsd %xmm0, %xmm4 + mulpd %xmm2, %xmm6 + mulsd %xmm2, %xmm7 + mulpd %xmm2, %xmm2 + addpd %xmm6, %xmm1 + mulsd %xmm2, %xmm2 + movsd 4264(%ebx), %xmm3 + mulpd %xmm2, %xmm1 + pshufd $78, %xmm1, %xmm6 + addsd %xmm6, %xmm1 + movapd %xmm1, %xmm6 + addsd %xmm7, %xmm1 + mulsd %xmm0, %xmm1 + addsd %xmm4, %xmm1 + andpd 4224(%ebx), %xmm4 + divsd %xmm1, %xmm5 + subsd %xmm4, %xmm3 + pshufd $238, %xmm0, %xmm1 + addsd %xmm0, %xmm3 + movapd %xmm4, %xmm2 + addsd %xmm1, %xmm3 + mulsd %xmm7, %xmm1 + mulsd %xmm0, %xmm7 + addsd %xmm1, %xmm3 + addsd %xmm7, %xmm4 + movsd 4240(%ebx), %xmm1 + mulsd %xmm0, %xmm6 + andpd 4224(%ebx), %xmm4 + addsd %xmm6, %xmm3 + movapd %xmm4, %xmm6 + subsd %xmm4, %xmm2 + addsd %xmm7, %xmm2 + movsd 4264(%ebx), %xmm7 + andpd %xmm1, %xmm5 + addsd %xmm2, %xmm3 + mulsd %xmm5, %xmm4 + xorpd %xmm2, %xmm2 + mulsd %xmm5, %xmm3 + subsd 4272(%ebx), %xmm6 + subsd %xmm7, %xmm4 + xorl $32768, %edx + pinsrw $3, %edx, %xmm2 + addsd %xmm3, %xmm4 + mulsd %xmm5, %xmm6 + movapd %xmm3, %xmm1 + mulsd %xmm4, %xmm3 + movapd %xmm6, %xmm0 + mulsd %xmm4, %xmm6 + subsd %xmm3, %xmm1 + subsd %xmm6, %xmm1 + addsd %xmm1, %xmm0 + xorpd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_0.0.2: + addl $960, %ecx + cmpl $1104, %ecx + jae .L_2TAG_PACKET_2.0.2 + movapd 4176(%ebx), %xmm2 + pshufd $68, %xmm0, %xmm1 + movapd 4192(%ebx), %xmm3 + mulpd %xmm1, %xmm1 + movapd 4208(%ebx), %xmm4 + mulpd %xmm1, %xmm2 + pshufd $68, %xmm1, %xmm5 + addpd %xmm3, %xmm2 + mulsd %xmm5, %xmm5 + mulpd %xmm1, %xmm2 + mulsd %xmm5, %xmm5 + addpd %xmm4, %xmm2 + mulpd %xmm5, %xmm2 + pshufd $238, %xmm2, %xmm5 + addsd %xmm5, %xmm2 + mulsd %xmm0, %xmm2 + addsd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + addl $15344, %ecx + cmpl $16448, %ecx + jae .L_2TAG_PACKET_3.0.2 + cmpl $16, %ecx + jb .L_2TAG_PACKET_4.0.2 + xorpd %xmm2, %xmm2 + movl $17392, %eax + pinsrw $3, %eax, %xmm2 + mulsd %xmm0, %xmm2 + addsd %xmm0, %xmm2 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_4.0.2: + movapd %xmm0, %xmm2 + mulsd %xmm2, %xmm2 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_3.0.2: + cmpl $32752, %ecx + jae .L_2TAG_PACKET_5.0.2 + xorpd %xmm2, %xmm2 + movl $15344, %ecx + pinsrw $3, %ecx, %xmm2 + movapd %xmm2, %xmm3 + mulsd %xmm2, %xmm2 + addsd %xmm3, %xmm2 +.L_2TAG_PACKET_6.0.2: + xorpd %xmm0, %xmm0 + orl $16368, %edx + pinsrw $3, %edx, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_5.0.2: + movapd %xmm0, %xmm2 + movd %xmm0, %eax + psrlq $20, %xmm2 + movd %xmm2, %ecx + orl %eax, %ecx + cmpl $0, %ecx + je .L_2TAG_PACKET_6.0.2 + addsd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_1.0.2: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_7.0.2: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type tanh,@function + .size tanh,.-tanh + .data +# -- End tanh + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1797923801 + .long 1072687577 + .long 1950547427 + .long 1013229059 + .long 730821105 + .long 1072681922 + .long 2523232743 + .long 1012067188 + .long 915592468 + .long 1072676282 + .long 352947894 + .long 3161024371 + .long 2174652632 + .long 1072670657 + .long 4087714590 + .long 1014450259 + .long 35929225 + .long 1072665048 + .long 2809788041 + .long 3159436968 + .long 2912730644 + .long 1072659453 + .long 3490067722 + .long 3163405074 + .long 2038973688 + .long 1072653874 + .long 892941374 + .long 1016046459 + .long 1533953344 + .long 1072648310 + .long 769171851 + .long 1015665633 + .long 1222472308 + .long 1072642761 + .long 1054357470 + .long 3161021018 + .long 929806999 + .long 1072637227 + .long 3205336643 + .long 1015259557 + .long 481706282 + .long 1072631708 + .long 1696079173 + .long 3162710528 + .long 3999357479 + .long 1072626203 + .long 2258941616 + .long 1015924724 + .long 2719515920 + .long 1072620714 + .long 2760332941 + .long 1015137933 + .long 764307441 + .long 1072615240 + .long 3021057420 + .long 3163329523 + .long 2256325230 + .long 1072609780 + .long 580117746 + .long 1015317295 + .long 2728693978 + .long 1072604335 + .long 396109971 + .long 3163462691 + .long 2009970496 + .long 1072598905 + .long 2159039665 + .long 3162572948 + .long 4224142467 + .long 1072593489 + .long 3389820386 + .long 1015207202 + .long 610758006 + .long 1072588089 + .long 1965209397 + .long 3161866232 + .long 3884662774 + .long 1072582702 + .long 2158611599 + .long 1014210185 + .long 991358482 + .long 1072577331 + .long 838715019 + .long 3163157668 + .long 351641897 + .long 1072571974 + .long 2172261526 + .long 3163010599 + .long 1796832535 + .long 1072566631 + .long 3176955716 + .long 3160585513 + .long 863738719 + .long 1072561303 + .long 1326992220 + .long 3162613197 + .long 1679558232 + .long 1072555989 + .long 2390342287 + .long 3163333970 + .long 4076975200 + .long 1072550689 + .long 2029000899 + .long 1015208535 + .long 3594158869 + .long 1072545404 + .long 2456521700 + .long 3163256561 + .long 64696965 + .long 1072540134 + .long 1768797490 + .long 1015816960 + .long 1912561781 + .long 1072534877 + .long 3147495102 + .long 1015678253 + .long 382305176 + .long 1072529635 + .long 2347622376 + .long 3162578625 + .long 3898795731 + .long 1072524406 + .long 1249994144 + .long 1011869818 + .long 3707479175 + .long 1072519192 + .long 3613079303 + .long 1014164738 + .long 3939148246 + .long 1072513992 + .long 3210352148 + .long 1015274323 + .long 135105010 + .long 1072508807 + .long 1906148728 + .long 3163375739 + .long 721996136 + .long 1072503635 + .long 563754734 + .long 1015371318 + .long 1242007932 + .long 1072498477 + .long 1132034716 + .long 3163339831 + .long 1532734324 + .long 1072493333 + .long 3094216535 + .long 3163162857 + .long 1432208378 + .long 1072488203 + .long 1401068914 + .long 3162363963 + .long 778901109 + .long 1072483087 + .long 2248183955 + .long 3161268751 + .long 3706687593 + .long 1072477984 + .long 3521726940 + .long 1013253067 + .long 1464976603 + .long 1072472896 + .long 3507292405 + .long 3161977534 + .long 2483480501 + .long 1072467821 + .long 1216371780 + .long 1013034172 + .long 2307442995 + .long 1072462760 + .long 3190117721 + .long 3162404539 + .long 777507147 + .long 1072457713 + .long 4282924205 + .long 1015187533 + .long 2029714210 + .long 1072452679 + .long 613660079 + .long 1015099143 + .long 1610600570 + .long 1072447659 + .long 3766732298 + .long 1015760183 + .long 3657065772 + .long 1072442652 + .long 399025623 + .long 3162957078 + .long 3716502172 + .long 1072437659 + .long 2303740125 + .long 1014042725 + .long 1631695677 + .long 1072432680 + .long 2717633076 + .long 3162344026 + .long 1540824585 + .long 1072427714 + .long 1064017011 + .long 3163487690 + .long 3287523847 + .long 1072422761 + .long 1625971539 + .long 3157009955 + .long 2420883922 + .long 1072417822 + .long 2049810052 + .long 1014119888 + .long 3080351519 + .long 1072412896 + .long 3379126788 + .long 3157218001 + .long 815859274 + .long 1072407984 + .long 240396590 + .long 3163487443 + .long 4062661092 + .long 1072403084 + .long 1422616006 + .long 3163255318 + .long 4076559943 + .long 1072398198 + .long 2119478331 + .long 3160758351 + .long 703710506 + .long 1072393326 + .long 1384660846 + .long 1015195891 + .long 2380618042 + .long 1072388466 + .long 3149557219 + .long 3163320799 + .long 364333489 + .long 1072383620 + .long 3923737744 + .long 3161421373 + .long 3092190715 + .long 1072378786 + .long 814012168 + .long 3159523422 + .long 1822067026 + .long 1072373966 + .long 1241994956 + .long 1015340290 + .long 697153126 + .long 1072369159 + .long 1283515429 + .long 3163283189 + .long 3861050111 + .long 1072364364 + .long 254893773 + .long 3162813180 + .long 2572866477 + .long 1072359583 + .long 878562433 + .long 1015521741 + .long 977020788 + .long 1072354815 + .long 3065100517 + .long 1015541563 + .long 3218338682 + .long 1072350059 + .long 3404164304 + .long 3162477108 + .long 557149882 + .long 1072345317 + .long 3672720709 + .long 1014537265 + .long 1434058175 + .long 1072340587 + .long 251133233 + .long 1015085769 + .long 1405169241 + .long 1072335870 + .long 2998539689 + .long 3162830951 + .long 321958744 + .long 1072331166 + .long 3401933767 + .long 1015794558 + .long 2331271250 + .long 1072326474 + .long 812057446 + .long 1012207446 + .long 2990417245 + .long 1072321795 + .long 3683467745 + .long 3163369326 + .long 2152073944 + .long 1072317129 + .long 1486860576 + .long 3163203456 + .long 3964284211 + .long 1072312475 + .long 2111583915 + .long 1015427164 + .long 3985553595 + .long 1072307834 + .long 4002146062 + .long 1015834136 + .long 2069751141 + .long 1072303206 + .long 1562170675 + .long 3162724681 + .long 2366108318 + .long 1072298590 + .long 2867985102 + .long 3161762254 + .long 434316067 + .long 1072293987 + .long 2028358766 + .long 1013458122 + .long 424392917 + .long 1072289396 + .long 2749202995 + .long 3162838718 + .long 2191782032 + .long 1072284817 + .long 2960257726 + .long 1013742662 + .long 1297350157 + .long 1072280251 + .long 1308022040 + .long 3163412558 + .long 1892288442 + .long 1072275697 + .long 2446255666 + .long 3162600381 + .long 3833209506 + .long 1072271155 + .long 2722920684 + .long 1013754842 + .long 2682146384 + .long 1072266626 + .long 2082178513 + .long 3163363419 + .long 2591453363 + .long 1072262109 + .long 2132396182 + .long 3159074198 + .long 3418903055 + .long 1072257604 + .long 2527457337 + .long 3160820604 + .long 727685349 + .long 1072253112 + .long 2038246809 + .long 3162358742 + .long 2966275557 + .long 1072248631 + .long 2176155324 + .long 3159842759 + .long 1403662306 + .long 1072244163 + .long 2788809599 + .long 3161671007 + .long 194117574 + .long 1072239707 + .long 777528612 + .long 3163412089 + .long 3492293770 + .long 1072235262 + .long 2248032210 + .long 1015386826 + .long 2568320822 + .long 1072230830 + .long 2732824428 + .long 1014352915 + .long 1577608921 + .long 1072226410 + .long 1875489510 + .long 3162968394 + .long 380978316 + .long 1072222002 + .long 854188970 + .long 3160462686 + .long 3134592888 + .long 1072217605 + .long 4232266862 + .long 1015991134 + .long 1110089947 + .long 1072213221 + .long 1451641639 + .long 1015474673 + .long 2759350287 + .long 1072208848 + .long 1148526634 + .long 1015894933 + .long 3649726105 + .long 1072204487 + .long 4085036346 + .long 1015649474 + .long 3643909174 + .long 1072200138 + .long 3537586109 + .long 1014354647 + .long 2604962541 + .long 1072195801 + .long 2614425274 + .long 3163539192 + .long 396319521 + .long 1072191476 + .long 4172420816 + .long 3159074632 + .long 1176749997 + .long 1072187162 + .long 2738998779 + .long 3162035844 + .long 515457527 + .long 1072182860 + .long 836709333 + .long 1015651226 + .long 2571947539 + .long 1072178569 + .long 3558159064 + .long 3163376669 + .long 2916157145 + .long 1072174290 + .long 219487565 + .long 1015309367 + .long 1413356050 + .long 1072170023 + .long 1651349291 + .long 3162668166 + .long 2224145553 + .long 1072165767 + .long 3482522030 + .long 3161489169 + .long 919555682 + .long 1072161523 + .long 3121969534 + .long 1012948226 + .long 1660913392 + .long 1072157290 + .long 4218599604 + .long 1015135707 + .long 19972402 + .long 1072153069 + .long 3507899862 + .long 1016009292 + .long 158781403 + .long 1072148859 + .long 2221464712 + .long 3163286453 + .long 1944781191 + .long 1072144660 + .long 3993278767 + .long 3161724279 + .long 950803702 + .long 1072140473 + .long 1655364926 + .long 1015237032 + .long 1339972927 + .long 1072136297 + .long 167908909 + .long 1015572152 + .long 2980802057 + .long 1072132132 + .long 378619896 + .long 1015773303 + .long 1447192521 + .long 1072127979 + .long 1462857171 + .long 3162514521 + .long 903334909 + .long 1072123837 + .long 1636462108 + .long 1015039997 + .long 1218806132 + .long 1072119706 + .long 1818613052 + .long 3162548441 + .long 2263535754 + .long 1072115586 + .long 752233586 + .long 3162639008 + .long 3907805044 + .long 1072111477 + .long 2257091225 + .long 3161550407 + .long 1727278727 + .long 1072107380 + .long 3562710623 + .long 1011471940 + .long 4182873220 + .long 1072103293 + .long 629542646 + .long 3161996303 + .long 2555984613 + .long 1072099218 + .long 2652555442 + .long 3162552692 + .long 1013258799 + .long 1072095154 + .long 1748797611 + .long 3160129082 + .long 3721688645 + .long 1072091100 + .long 3069276937 + .long 1015839401 + .long 1963711167 + .long 1072087058 + .long 1744767757 + .long 3160574294 + .long 4201977662 + .long 1072083026 + .long 748330254 + .long 1013594357 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 2979960120 + .long 1072074996 + .long 2599109725 + .long 1014498493 + .long 3561793907 + .long 1072070997 + .long 1157054053 + .long 1011890350 + .long 3339203574 + .long 1072067009 + .long 1483497780 + .long 3162408754 + .long 2186617381 + .long 1072063032 + .long 2270764084 + .long 3163272713 + .long 4273770423 + .long 1072059065 + .long 3383180809 + .long 3163218901 + .long 885834528 + .long 1072055110 + .long 1973258547 + .long 3162261564 + .long 488188413 + .long 1072051165 + .long 3199821029 + .long 1015564048 + .long 2956612997 + .long 1072047230 + .long 2118169751 + .long 3162735553 + .long 3872257780 + .long 1072043306 + .long 1253592103 + .long 1015958334 + .long 3111574537 + .long 1072039393 + .long 2606161479 + .long 3162759746 + .long 551349105 + .long 1072035491 + .long 3821916050 + .long 3162106589 + .long 363667784 + .long 1072031599 + .long 813753950 + .long 1015785209 + .long 2425981843 + .long 1072027717 + .long 2830390851 + .long 3163346599 + .long 2321106615 + .long 1072023846 + .long 2171176610 + .long 1009535771 + .long 4222122499 + .long 1072019985 + .long 1277378074 + .long 3163256737 + .long 3712504873 + .long 1072016135 + .long 88491949 + .long 1015427660 + .long 671025100 + .long 1072012296 + .long 3832014351 + .long 3163022030 + .long 3566716925 + .long 1072008466 + .long 1536826856 + .long 1014142433 + .long 3689071823 + .long 1072004647 + .long 2321004996 + .long 3162552716 + .long 917841882 + .long 1072000839 + .long 18715565 + .long 1015659308 + .long 3723038930 + .long 1071997040 + .long 378465264 + .long 3162569582 + .long 3395129871 + .long 1071993252 + .long 4025345435 + .long 3162335388 + .long 4109806887 + .long 1071989474 + .long 422403966 + .long 1014469229 + .long 1453150082 + .long 1071985707 + .long 498154669 + .long 3161488062 + .long 3896463087 + .long 1071981949 + .long 1139797873 + .long 3161233805 + .long 2731501122 + .long 1071978202 + .long 1774031855 + .long 3162470021 + .long 2135241198 + .long 1071974465 + .long 1236747871 + .long 1013589147 + .long 1990012071 + .long 1071970738 + .long 3529070563 + .long 3162813193 + .long 2178460671 + .long 1071967021 + .long 777878098 + .long 3162842493 + .long 2583551245 + .long 1071963314 + .long 3161094195 + .long 1015606491 + .long 3088564500 + .long 1071959617 + .long 1762311517 + .long 1015045673 + .long 3577096743 + .long 1071955930 + .long 2951496418 + .long 1013793687 + .long 3933059031 + .long 1071952253 + .long 2133366768 + .long 3161531832 + .long 4040676318 + .long 1071948586 + .long 4090609238 + .long 1015663458 + .long 3784486610 + .long 1071944929 + .long 1581883040 + .long 3161698953 + .long 3049340112 + .long 1071941282 + .long 3062915824 + .long 1013170595 + .long 1720398391 + .long 1071937645 + .long 3980678963 + .long 3163300080 + .long 3978100823 + .long 1071934017 + .long 3513027190 + .long 1015845963 + .long 1118294578 + .long 1071930400 + .long 2197495694 + .long 3159909401 + .long 1617004845 + .long 1071926792 + .long 82804944 + .long 1010342778 + .long 1065662932 + .long 1071923194 + .long 2533670915 + .long 1014530238 + .long 3645941911 + .long 1071919605 + .long 3814685081 + .long 3161573341 + .long 654919306 + .long 1071916027 + .long 3232961757 + .long 3163047469 + .long 569847338 + .long 1071912458 + .long 472945272 + .long 3159290729 + .long 3278348324 + .long 1071908898 + .long 3069497416 + .long 1014750712 + .long 78413852 + .long 1071905349 + .long 4183226867 + .long 3163017251 + .long 3743175029 + .long 1071901808 + .long 2072812490 + .long 3162175075 + .long 1276261410 + .long 1071898278 + .long 300981948 + .long 1014684169 + .long 1156440435 + .long 1071894757 + .long 2351451249 + .long 1013967056 + .long 3272845541 + .long 1071891245 + .long 928852419 + .long 3163488248 + .long 3219942644 + .long 1071887743 + .long 3798990616 + .long 1015368806 + .long 887463927 + .long 1071884251 + .long 3596744163 + .long 3160794166 + .long 460407023 + .long 1071880768 + .long 4237175092 + .long 3163138469 + .long 1829099622 + .long 1071877294 + .long 1016661181 + .long 3163461005 + .long 589198666 + .long 1071873830 + .long 2664346172 + .long 3163157962 + .long 926591435 + .long 1071870375 + .long 3208833762 + .long 3162913514 + .long 2732492859 + .long 1071866929 + .long 2691479646 + .long 3162255684 + .long 1603444721 + .long 1071863493 + .long 1548633640 + .long 3162201326 + .long 1726216749 + .long 1071860066 + .long 2466808228 + .long 3161676405 + .long 2992903935 + .long 1071856648 + .long 2218154406 + .long 1015228193 + .long 1000925746 + .long 1071853240 + .long 1018491672 + .long 3163309544 + .long 4232894513 + .long 1071849840 + .long 2383938684 + .long 1014668519 + .long 3991843581 + .long 1071846450 + .long 4092853457 + .long 1014585763 + .long 171030293 + .long 1071843070 + .long 3526460132 + .long 1014428778 + .long 1253935211 + .long 1071839698 + .long 1395382931 + .long 3159702613 + .long 2839424854 + .long 1071836335 + .long 1171596163 + .long 1013041679 + .long 526652809 + .long 1071832982 + .long 4223459736 + .long 1015879375 + .long 2799960843 + .long 1071829637 + .long 1423655381 + .long 1015022151 + .long 964107055 + .long 1071826302 + .long 2800439588 + .long 3162833221 + .long 3504003472 + .long 1071822975 + .long 3594001060 + .long 3157330652 + .long 1724976915 + .long 1071819658 + .long 420909223 + .long 3163117379 + .long 4112506593 + .long 1071816349 + .long 2947355221 + .long 1014371048 + .long 1972484976 + .long 1071813050 + .long 675290301 + .long 3161640050 + .long 3790955393 + .long 1071809759 + .long 2352942462 + .long 3163180090 + .long 874372905 + .long 1071806478 + .long 100263788 + .long 1015940732 + .long 1709341917 + .long 1071803205 + .long 2571168217 + .long 1014152499 + .long 1897844341 + .long 1071799941 + .long 1254300460 + .long 1015275938 + .long 1337108031 + .long 1071796686 + .long 3203724452 + .long 1014677845 + .long 4219606026 + .long 1071793439 + .long 2434574742 + .long 1014681548 + .long 1853186616 + .long 1071790202 + .long 3066496371 + .long 1015656574 + .long 2725843665 + .long 1071786973 + .long 1433917087 + .long 1014838523 + .long 2440944790 + .long 1071783753 + .long 2492769774 + .long 1014147454 + .long 897099801 + .long 1071780542 + .long 754756297 + .long 1015241005 + .long 2288159958 + .long 1071777339 + .long 2169144469 + .long 1014876021 + .long 2218315341 + .long 1071774145 + .long 2694295388 + .long 3163288868 + .long 586995997 + .long 1071770960 + .long 41662348 + .long 3162627992 + .long 1588871207 + .long 1071767783 + .long 143439582 + .long 3162963416 + .long 828946858 + .long 1071764615 + .long 10642492 + .long 1015939438 + .long 2502433899 + .long 1071761455 + .long 2148595913 + .long 1015023991 + .long 2214878420 + .long 1071758304 + .long 892270087 + .long 3163116422 + .long 4162030108 + .long 1071755161 + .long 2763428480 + .long 1015529349 + .long 3949972341 + .long 1071752027 + .long 2068408548 + .long 1014913868 + .long 1480023343 + .long 1071748902 + .long 2247196168 + .long 1015327453 + .long 948735466 + .long 1071745785 + .long 3516338028 + .long 3162574883 + .long 2257959872 + .long 1071742676 + .long 3802946148 + .long 1012964927 + .long 1014845819 + .long 1071739576 + .long 3117910646 + .long 3161559105 + .long 1416741826 + .long 1071736484 + .long 2196380210 + .long 1011413563 + .long 3366293073 + .long 1071733400 + .long 3119426314 + .long 1014120554 + .long 2471440686 + .long 1071730325 + .long 968836267 + .long 3162214888 + .long 2930322912 + .long 1071727258 + .long 2599499422 + .long 3162714047 + .long 351405227 + .long 1071724200 + .long 3125337328 + .long 3159822479 + .long 3228316108 + .long 1071721149 + .long 3010241991 + .long 3158422804 + .long 2875075254 + .long 1071718107 + .long 4144233330 + .long 3163333716 + .long 3490863953 + .long 1071715073 + .long 960797498 + .long 3162948880 + .long 685187902 + .long 1071712048 + .long 378731989 + .long 1014843115 + .long 2952712987 + .long 1071709030 + .long 3293494651 + .long 3160120301 + .long 1608493509 + .long 1071706021 + .long 3159622171 + .long 3162807737 + .long 852742562 + .long 1071703020 + .long 667253586 + .long 1009793559 + .long 590962156 + .long 1071700027 + .long 3829346666 + .long 3163275597 + .long 728909815 + .long 1071697042 + .long 383930225 + .long 1015029468 + .long 1172597893 + .long 1071694065 + .long 114433263 + .long 1015347593 + .long 1828292879 + .long 1071691096 + .long 1255956747 + .long 1015588398 + .long 2602514713 + .long 1071688135 + .long 2268929336 + .long 1014354284 + .long 3402036099 + .long 1071685182 + .long 405889334 + .long 1015105656 + .long 4133881824 + .long 1071682237 + .long 2148155345 + .long 3162931299 + .long 410360776 + .long 1071679301 + .long 1269990655 + .long 1011975870 + .long 728934454 + .long 1071676372 + .long 1413842688 + .long 1014178612 + .long 702412510 + .long 1071673451 + .long 3803266087 + .long 3162280415 + .long 238821257 + .long 1071670538 + .long 1469694871 + .long 3162884987 + .long 3541402996 + .long 1071667632 + .long 2759177317 + .long 1014854626 + .long 1928746161 + .long 1071664735 + .long 983617676 + .long 1014285177 + .long 3899555717 + .long 1071661845 + .long 427280750 + .long 3162546972 + .long 772914124 + .long 1071658964 + .long 4004372762 + .long 1012230161 + .long 1048019041 + .long 1071656090 + .long 1398474845 + .long 3160510595 + .long 339411585 + .long 1071653224 + .long 264588982 + .long 3161636657 + .long 2851812149 + .long 1071650365 + .long 2595802551 + .long 1015767337 + .long 4200250559 + .long 1071647514 + .long 2808127345 + .long 3161781938 + .long 0 + .long 1127743488 + .long 0 + .long 3275227136 + .long 1610612736 + .long 1082594631 + .long 4166901572 + .long 1055174155 + .long 3884607281 + .long 3168131199 + .long 3607404735 + .long 3190582024 + .long 1874480759 + .long 1032041131 + .long 4286760334 + .long 1053736893 + .long 4277811695 + .long 3211144770 + .long 0 + .long 0 + .long 236289503 + .long 1064135997 + .long 463583772 + .long 3215696314 + .long 1441186365 + .long 3212977891 + .long 286331153 + .long 1069617425 + .long 2284589306 + .long 1066820852 + .long 1431655765 + .long 3218429269 + .long 0 + .long 4294967280 + .long 0 + .long 4294967280 + .long 4294705152 + .long 4294967295 + .long 4294705152 + .long 4294967295 + .long 4160749568 + .long 2147483647 + .long 0 + .long 1072693248 + .long 0 + .long 1073741824 + .type static_const_table,@object + .size static_const_table,4280 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tanhf_wmt.S b/external/sgx_libm/ia32/tanhf_wmt.S new file mode 100644 index 0000000000..b26daf3fdd --- /dev/null +++ b/external/sgx_libm/ia32/tanhf_wmt.S @@ -0,0 +1,291 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanhf_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin tanhf + .text + .align 16,0x90 + .globl tanhf +tanhf: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movss 112(%esp), %xmm0 + xorpd %xmm1, %xmm1 + movsd 304(%ebx), %xmm3 + movl $14336, %eax + pinsrw $3, %eax, %xmm1 + movsd 288(%ebx), %xmm6 + pextrw $1, %xmm0, %ecx + psllq $33, %xmm0 + psrlq $4, %xmm0 + paddw %xmm0, %xmm1 + movapd 256(%ebx), %xmm4 + movl $32768, %edx + andl %ecx, %edx + andl $32767, %ecx + subl $15744, %ecx + cmpl $1056, %ecx + jae .L_2TAG_PACKET_0.0.2 + mulsd %xmm1, %xmm3 + cvtsd2si %xmm3, %eax + movapd %xmm3, %xmm2 + addsd %xmm6, %xmm3 + xorpd %xmm0, %xmm0 + subsd %xmm6, %xmm3 + movapd 272(%ebx), %xmm1 + subsd %xmm3, %xmm2 + movl $31, %ecx + andl %eax, %ecx + movsd (%ebx,%ecx,8), %xmm5 + shrl $1, %eax + andl $65520, %eax + subl $16368, %eax + negl %eax + pshufd $68, %xmm2, %xmm2 + pinsrw $3, %eax, %xmm0 + mulpd %xmm2, %xmm4 + mulpd %xmm2, %xmm1 + movsd 312(%ebx), %xmm7 + xorpd %xmm3, %xmm3 + mulpd %xmm2, %xmm4 + mulpd %xmm2, %xmm2 + mulsd %xmm5, %xmm0 + addpd %xmm4, %xmm1 + pinsrw $3, %edx, %xmm3 + mulsd %xmm2, %xmm1 + movapd %xmm7, %xmm6 + pshufd $238, %xmm1, %xmm2 + addsd %xmm0, %xmm7 + addsd %xmm2, %xmm1 + subsd %xmm0, %xmm6 + mulsd %xmm1, %xmm0 + addsd %xmm0, %xmm7 + subsd %xmm0, %xmm6 + xorpd %xmm3, %xmm7 + divsd %xmm7, %xmm6 + cvtsd2ss %xmm6, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_0.0.2: + addl $1152, %ecx + cmpl $1152, %ecx + jae .L_2TAG_PACKET_2.0.2 + movl $-1117975087, %eax + movd %eax, %xmm1 + movss 112(%esp), %xmm0 + movl $-1096111445, %ecx + movd %ecx, %xmm3 + movl $1040746633, %edx + movd %edx, %xmm2 + pshufd $68, %xmm0, %xmm4 + mulss %xmm0, %xmm0 + mulss %xmm0, %xmm1 + mulss %xmm0, %xmm3 + mulss %xmm0, %xmm0 + addss %xmm2, %xmm1 + mulss %xmm1, %xmm0 + addss %xmm3, %xmm0 + mulss %xmm4, %xmm0 + addss %xmm4, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + addl $14592, %ecx + cmpl $15744, %ecx + jae .L_2TAG_PACKET_3.0.2 + movss 112(%esp), %xmm0 + cmpl $128, %ecx + jb .L_2TAG_PACKET_4.0.2 + movl $1333788672, %eax + movd %eax, %xmm2 + mulss %xmm0, %xmm2 + addss %xmm0, %xmm2 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_4.0.2: + movss %xmm0, %xmm2 + mulss %xmm2, %xmm2 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_3.0.2: + cmpl $32640, %ecx + jae .L_2TAG_PACKET_5.0.2 + movl $796917760, %eax + movd %eax, %xmm2 + movss %xmm2, %xmm3 + mulss %xmm2, %xmm2 + addss %xmm3, %xmm2 +.L_2TAG_PACKET_6.0.2: + xorps %xmm0, %xmm0 + orl $16256, %edx + pinsrw $1, %edx, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_5.0.2: + movl 112(%esp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_6.0.2 + movss 112(%esp), %xmm0 + addss %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_1.0.2: + movss %xmm0, 24(%esp) + flds 24(%esp) + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type tanhf,@function + .size tanhf,.-tanhf + .data +# -- End tanhf + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 0 + .long 1072693248 + .long 1533953344 + .long 1072648310 + .long 2728693978 + .long 1072604335 + .long 863738719 + .long 1072561303 + .long 3707479175 + .long 1072519192 + .long 3706687593 + .long 1072477984 + .long 3716502172 + .long 1072437659 + .long 4076559943 + .long 1072398198 + .long 2572866477 + .long 1072359583 + .long 2990417245 + .long 1072321795 + .long 2191782032 + .long 1072284817 + .long 2966275557 + .long 1072248631 + .long 1110089947 + .long 1072213221 + .long 2571947539 + .long 1072178569 + .long 1944781191 + .long 1072144660 + .long 3907805044 + .long 1072111477 + .long 1719614413 + .long 1072079006 + .long 2956612997 + .long 1072047230 + .long 3712504873 + .long 1072016135 + .long 1453150082 + .long 1071985707 + .long 3577096743 + .long 1071955930 + .long 1617004845 + .long 1071926792 + .long 1276261410 + .long 1071898278 + .long 926591435 + .long 1071870375 + .long 171030293 + .long 1071843070 + .long 4112506593 + .long 1071816349 + .long 1853186616 + .long 1071790202 + .long 828946858 + .long 1071764615 + .long 1014845819 + .long 1071739576 + .long 3490863953 + .long 1071715073 + .long 1828292879 + .long 1071691096 + .long 3541402996 + .long 1071667632 + .long 1874480759 + .long 1044624043 + .long 4286760334 + .long 1060028349 + .long 3607404735 + .long 3200019208 + .long 4277811695 + .long 3214290498 + .long 0 + .long 1127743488 + .long 0 + .long 3275227136 + .long 1697350398 + .long 1079448903 + .long 0 + .long 1072693248 + .type static_const_table,@object + .size static_const_table,320 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tanhl.S b/external/sgx_libm/ia32/tanhl.S new file mode 100644 index 0000000000..71411db054 --- /dev/null +++ b/external/sgx_libm/ia32/tanhl.S @@ -0,0 +1,992 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanhl.c" + .text +..TXTST0: +# -- Begin tanhl + .text + .align 16,0x90 + .globl tanhl +tanhl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $68, %esp +..B1.2: + fnstcw 54(%esp) +..B1.3: + movzwl 16(%ebp), %eax + andl $32767, %eax + movzwl 54(%esp), %ecx + cmpl $16388, %eax + call ..L2 +..L2: + popl %edx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx + jge ..B1.56 +..B1.4: + cmpl $16382, %eax + jge ..B1.46 +..B1.5: + cmpl $16376, %eax + jge ..B1.39 +..B1.6: + cmpl $16371, %eax + jge ..B1.32 +..B1.7: + cmpl $16365, %eax + jge ..B1.25 +..B1.8: + cmpl $16308, %eax + jge ..B1.18 +..B1.9: + movl %ecx, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.69 +..B1.10: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.11: + fldcw 52(%esp) +..B1.12: + movzwl 16(%ebp), %eax + movl $1, %esi + andl $32767, %eax +..B1.13: + testl %eax, %eax + jle ..B1.65 +..B1.14: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%edx) + fmul %st(1), %st + fsubp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%edx) + fstpt 16(%esp) +..B1.15: + testl %esi, %esi + je ..B1.17 +..B1.16: + fldcw 54(%esp) +..B1.17: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.70 +..B1.19: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.20: + fldcw 52(%esp) +..B1.21: + movl $1, %eax +..B1.22: + fldt 8(%ebp) + testl %eax, %eax + fldt _Q3@GOTOFF(%edx) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.24 +..B1.23: + fldcw 54(%esp) +..B1.24: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.71 +..B1.26: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.27: + fldcw 52(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_Q2@GOTOFF(%edx) + fmul %st(1), %st + fldt _Q2@GOTOFF(%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.31 +..B1.30: + fldcw 54(%esp) +..B1.31: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.32: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.72 +..B1.33: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.34: + fldcw 52(%esp) +..B1.35: + movl $1, %eax +..B1.36: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_Q1@GOTOFF(%edx) + fmul %st(1), %st + fldt 12+_Q1@GOTOFF(%edx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_Q1@GOTOFF(%edx) + fmulp %st, %st(2) + fldt _Q1@GOTOFF(%edx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.38 +..B1.37: + fldcw 54(%esp) +..B1.38: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.39: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.73 +..B1.40: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.41: + fldcw 52(%esp) +..B1.42: + movl $1, %ecx +..B1.43: + fldt 8(%ebp) + fldl _TWO_52H@GOTOFF(%edx) + fldt 180+_Q@GOTOFF(%edx) + fldt 168+_Q@GOTOFF(%edx) + fldt 156+_Q@GOTOFF(%edx) + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + testl %ecx, %ecx + fxch %st(4) + fmull ones@GOTOFF(%edx,%eax,8) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(6) + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fxch %st(2) + fmul %st(5), %st + fxch %st(1) + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(5) + fld %st(4) + fsubr %st(1), %st + fxch %st(5) + fstpt 16(%esp) + fldt 16(%esp) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 144+_Q@GOTOFF(%edx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(6), %st + fldt 132+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 120+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 108+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 96+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 84+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 72+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 60+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 48+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 36+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 24+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 12+_Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(6) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fmul %st(0), %st + fldt _Q@GOTOFF(%edx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + faddp %st, %st(6) + fld %st(4) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fld %st(2) + fmul %st(3), %st + fldt 204+_Q@GOTOFF(%edx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(7) + fmulp %st, %st(1) + fldt 192+_Q@GOTOFF(%edx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(4) + fld %st(2) + fldl _TWO_48H@GOTOFF(%edx) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fmul %st, %st(2) + fsubr %st, %st(3) + fxch %st(6) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt 16(%esp) + fmul %st, %st(3) + faddp %st, %st(3) + fxch %st(1) + fmull ones@GOTOFF(%edx,%eax,8) + fxch %st(2) + fmull ones@GOTOFF(%edx,%eax,8) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + je ..B1.83 +..B1.44: + fstpt 28(%esp) +..B1.82: + fldcw 54(%esp) + jmp ..B1.45 +..B1.83: + fstp %st(0) +..B1.45: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.46: + movl %ecx, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.74 +..B1.47: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.48: + fldcw 52(%esp) +..B1.49: + movzwl 16(%ebp), %eax + movl $1, %ebx +..B1.50: + fldt 8(%ebp) + fldl _TWO_63H@GOTOFF(%edx) + fldt .L_2il0floatpacket.0@GOTOFF(%edx) + fldt .L_2il0floatpacket.1@GOTOFF(%edx) + fldl _TWO_32@GOTOFF(%edx) + movzbl 17(%ebp), %esi + andl $128, %esi + shrl $7, %esi + fstl 56(%esp) + shll $16, %eax + fldl twos@GOTOFF(%edx,%esi,8) + fmul %st, %st(5) + fxch %st(3) + fmul %st(5), %st + fadd %st(4), %st + fstpt 28(%esp) + fldt 28(%esp) + fsubp %st, %st(4) + fxch %st(1) + fmul %st(3), %st + movl 28(%esp), %ecx + fsubrp %st, %st(4) + fld %st(3) + fldt .L_2il0floatpacket.2@GOTOFF(%edx) + fmulp %st, %st(4) + movsbl %cl, %edi + fsub %st(3), %st + fldl _TWO_32P@GOTOFF(%edx) + subl %edi, %ecx + fmul %st(1), %st + fxch %st(2) + fmulp %st, %st(1) + shll $4, %edi + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + shrl $8, %ecx + fxch %st(3) + fsubrp %st, %st(4) + shll $23, %ecx + fadd %st(3), %st + fld %st(0) + addl $1065353216, %ecx + fmul %st(1), %st + fldt 48+_P@GOTOFF(%edx) + fmul %st(1), %st + fldt 36+_P@GOTOFF(%edx) + fmul %st(2), %st + fldt 24+_P@GOTOFF(%edx) + movl %ecx, 12(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 12+_P@GOTOFF(%edx) + movzwl 14(%ebp), %ecx + orl %ecx, %eax + andl $2147483647, %eax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + cmpl $1073845862, %eax + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(5) + fldt _P@GOTOFF(%edx) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 2056+__libm_expl_table_256@GOTOFF(%edx,%edi) + fldl 2048+__libm_expl_table_256@GOTOFF(%edx,%edi) + fld %st(0) + fmul %st(5), %st + fxch %st(4) + fadd %st, %st(5) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fxch %st(3) + fstpt 16(%esp) + fmul %st(2), %st + flds 12(%esp) + fldt .L_2il0floatpacket.3@GOTOFF(%edx) + jae ..B1.52 +..B1.51: + fldl 56(%esp) + fld %st(5) + fadd %st(4), %st + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fmul %st, %st(1) + fxch %st(1) + fadd %st(3), %st + fld %st(0) + fldt 16(%esp) + faddp %st, %st(6) + fxch %st(5) + fmulp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fdivr %st(4), %st + fmul %st, %st(2) + fldl _TWO_32H@GOTOFF(%edx) + fld %st(0) + fadd %st(2), %st + fstpt 28(%esp) + fldt 28(%esp) + fsubp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fmul %st, %st(7) + fxch %st(4) + faddp %st, %st(7) + fmul %st, %st(2) + fxch %st(5) + fsubrp %st, %st(2) + fxch %st(5) + faddp %st, %st(1) + fmulp %st, %st(4) + fsubp %st, %st(3) + fmul %st, %st(1) + fmulp %st, %st(2) + fsubrl ones@GOTOFF(%edx,%esi,8) + fsubp %st, %st(1) + fstpt 40(%esp) + jmp ..B1.53 +..B1.52: + fldt 16(%esp) + faddp %st, %st(6) + fxch %st(2) + faddp %st, %st(5) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fdivrp %st, %st(1) + fsubrl ones@GOTOFF(%edx,%esi,8) + fstpt 40(%esp) +..B1.53: + testl %ebx, %ebx + je ..B1.55 +..B1.54: + fldcw 54(%esp) +..B1.55: + fldt 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.56: + movl %ecx, %ebx + andl $768, %ebx + cmpl $768, %ebx + je ..B1.79 +..B1.57: + orl $-64768, %ecx + movw %cx, 52(%esp) +..B1.58: + fldcw 52(%esp) +..B1.59: + movzwl 16(%ebp), %eax + movl $1, %ecx + andl $32767, %eax +..B1.60: + cmpl $32767, %eax + je ..B1.75 +..B1.61: + movzbl 17(%ebp), %esi + andl $128, %esi + shrl $7, %esi + lea (,%esi,8), %eax + lea (%eax,%esi,4), %ebx + fldt _small_value_80@GOTOFF(%edx,%ebx) + fsubrl ones@GOTOFF(%edx,%esi,8) + fstpt 16(%esp) +..B1.62: + testl %ecx, %ecx + je ..B1.64 +..B1.63: + fldcw 54(%esp) +..B1.64: + fldt 16(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.65: + cmpl $0, 12(%ebp) + jne ..B1.67 +..B1.66: + cmpl $0, 8(%ebp) + je ..B1.68 +..B1.67: + fldt _small_value_80@GOTOFF(%edx) + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%edx) + fmul %st(1), %st + movzbl 17(%ebp), %ecx + fsubp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%edx) + andl $128, %ecx + shrl $7, %ecx + fstpt 16(%esp) + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %ebx + fldt _small_value_80@GOTOFF(%edx,%ebx) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.15 +..B1.68: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.15 +..B1.69: + xorl %esi, %esi + jmp ..B1.13 +..B1.70: + xorl %eax, %eax + jmp ..B1.22 +..B1.71: + xorl %eax, %eax + jmp ..B1.29 +..B1.72: + xorl %eax, %eax + jmp ..B1.36 +..B1.73: + xorl %ecx, %ecx + jmp ..B1.43 +..B1.74: + xorl %ebx, %ebx + jmp ..B1.50 +..B1.75: + cmpl $-2147483648, 12(%ebp) + jne ..B1.78 +..B1.76: + cmpl $0, 8(%ebp) + jne ..B1.78 +..B1.77: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl ones@GOTOFF(%edx,%eax,8) + fstpt 16(%esp) + jmp ..B1.62 +..B1.78: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.62 +..B1.79: + xorl %ecx, %ecx + jmp ..B1.60 + .align 16,0x90 + .type tanhl,@function + .size tanhl,.-tanhl + .data +# -- End tanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +twos: + .long 0x00000000,0x40000000 + .long 0x00000000,0xc0000000 + .type twos,@object + .size twos,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_Q3: + .word 21845 + .word 42325 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .type _Q3,@object + .size _Q3,12 + .align 2 +_Q2: + .word 36147 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 55638 + .word 59918 + .word 34848 + .word 34952 + .word 16380 + .word 0 + .type _Q2,@object + .size _Q2,24 + .align 2 +_Q1: + .word 43688 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 48627 + .word 34947 + .word 34952 + .word 34952 + .word 16380 + .word 0 + .word 23872 + .word 38674 + .word 53460 + .word 56589 + .word 49146 + .word 0 + .word 33152 + .word 13396 + .word 6324 + .word 45860 + .word 16377 + .word 0 + .type _Q1,@object + .size _Q1,48 + .align 2 +_Q: + .word 43505 + .word 43690 + .word 43690 + .word 43690 + .word 49137 + .word 0 + .word 51768 + .word 34951 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 53715 + .word 3536 + .word 53469 + .word 56589 + .word 49146 + .word 0 + .word 37274 + .word 24708 + .word 42049 + .word 45863 + .word 16377 + .word 0 + .word 51222 + .word 13677 + .word 6831 + .word 37175 + .word 49144 + .word 0 + .word 45961 + .word 31945 + .word 59504 + .word 60265 + .word 16374 + .word 0 + .word 5972 + .word 17449 + .word 45604 + .word 48849 + .word 49141 + .word 0 + .word 32816 + .word 2946 + .word 4564 + .word 39596 + .word 16372 + .word 0 + .word 14786 + .word 2112 + .word 44465 + .word 64190 + .word 49138 + .word 0 + .word 3031 + .word 16844 + .word 22916 + .word 52030 + .word 16369 + .word 0 + .word 47485 + .word 32270 + .word 51436 + .word 42167 + .word 49136 + .word 0 + .word 3071 + .word 14344 + .word 30185 + .word 34131 + .word 16367 + .word 0 + .word 24996 + .word 54454 + .word 53234 + .word 54781 + .word 49133 + .word 0 + .word 39193 + .word 24581 + .word 37984 + .word 42131 + .word 16364 + .word 0 + .word 5913 + .word 28127 + .word 47865 + .word 55395 + .word 49130 + .word 0 + .word 25952 + .word 54950 + .word 21582 + .word 44803 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34944 + .word 16380 + .word 0 + .type _Q,@object + .size _Q,216 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .type _P,@object + .size _P,60 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .data + .hidden __libm_expl_table_256 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tanl.S b/external/sgx_libm/ia32/tanl.S new file mode 100644 index 0000000000..f26955b9ac --- /dev/null +++ b/external/sgx_libm/ia32/tanl.S @@ -0,0 +1,1683 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanl.c" + .text +..TXTST0: +# -- Begin tanl + .text + .align 16,0x90 + .globl tanl +tanl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 88(%esp) +..B1.2: + fnstcw 14(%esp) +..B1.3: + movzwl 16(%ebp), %edi + andl $32767, %edi + movzwl 14(%esp), %eax + cmpl $16373, %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + jge ..B1.41 +..B1.4: + cmpl $16371, %edi + jge ..B1.33 +..B1.5: + cmpl $16364, %edi + jge ..B1.25 +..B1.6: + cmpl $16308, %edi + jge ..B1.17 +..B1.7: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.87 +..B1.8: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.9: + fldcw 12(%esp) +..B1.10: + movzwl 16(%ebp), %edi + movl $1, %esi + andl $32767, %edi +..B1.11: + testl %edi, %edi + jle ..B1.83 +..B1.12: + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ebx) + fstpt 16(%esp) +..B1.13: + testl %esi, %esi + je ..B1.15 +..B1.14: + fldcw 14(%esp) +..B1.15: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.16: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.17: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.89 +..B1.18: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.19: + fldcw 12(%esp) +..B1.20: + movl $1, %eax +..B1.21: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt _P3@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.23 +..B1.22: + fldcw 14(%esp) +..B1.23: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.24: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.25: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.91 +..B1.26: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.27: + fldcw 12(%esp) +..B1.28: + movl $1, %eax +..B1.29: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fldt 12+_P2@GOTOFF(%ebx) + fmul %st(1), %st + fldt _P2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.31 +..B1.30: + fldcw 14(%esp) +..B1.31: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.32: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.33: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.93 +..B1.34: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.35: + fldcw 12(%esp) +..B1.36: + movl $1, %eax +..B1.37: + fldt 8(%ebp) + testl %eax, %eax + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt 36+_P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_P1@GOTOFF(%ebx) + fmulp %st, %st(2) + fldt _P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.39 +..B1.38: + fldcw 14(%esp) +..B1.39: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.40: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.99 +..B1.42: + orl $-64768, %eax + movw %ax, 12(%esp) +..B1.43: + fldcw 12(%esp) +..B1.44: + movzwl 16(%ebp), %edi + movl $1, %esi + andl $32767, %edi +..B1.45: + movzbl 17(%ebp), %eax + andl $128, %eax + shrl $7, %eax + cmpl $16413, %edi + jge ..B1.52 +..B1.46: + fldt 8(%ebp) + fldl _Pi4Inv@GOTOFF(%ebx) + fldl _ones@GOTOFF(%ebx,%eax,8) + fld %st(0) + fmul %st(3), %st + fmul %st, %st(2) + fxch %st(2) + fstpt 60(%esp) + movzwl 68(%esp), %ecx + andl $32767, %ecx + cmpl $16383, %ecx + jge ..B1.48 +..B1.47: + fstp %st(0) + fstp %st(0) + fldl _TWO_48H@GOTOFF(%ebx) + fld %st(1) + fmul %st(1), %st + fld %st(2) + movl $1, %edx + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(2) + fsub %st(1), %st + fldt _KPi04@GOTOFF(%ebx) + fmul %st(4), %st + fstpt 60(%esp) + fxch %st(3) + jmp ..B1.63 +..B1.48: + fstp %st(2) + fldl _TWO_32H@GOTOFF(%ebx) + negl %ecx + addl $30, %ecx + movl 64(%esp), %edx + shrl %cl, %edx + incl %edx + movl %edx, %eax + andl $-2, %eax + movl %eax, 16(%esp) + cmpl $16400, %edi + fildl 16(%esp) + jge ..B1.50 +..B1.49: + fldl _Pi04x3@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x3@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_Pi04x3@GOTOFF(%ebx) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + jmp ..B1.51 +..B1.50: + fldl _Pi04x5@GOTOFF(%ebx) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl 8+_Pi04x5@GOTOFF(%ebx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl 16+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fldl 24+_Pi04x5@GOTOFF(%ebx) + fmul %st(2), %st + fld %st(0) + fsubr %st(4), %st + fsubr %st, %st(4) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fldl 32+_Pi04x5@GOTOFF(%ebx) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) +..B1.51: + fldl _TWO_48H@GOTOFF(%ebx) + fld %st(1) + fmul %st(1), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fxch %st(3) + fmulp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fstpt 8(%ebp) + fldt 8(%ebp) + fldt _KPi04@GOTOFF(%ebx) + fmul %st(1), %st + fstpt 60(%esp) + jmp ..B1.63 +..B1.52: + cmpl $32767, %edi + jne ..B1.61 +..B1.53: + cmpl $-2147483648, 12(%ebp) + jne ..B1.56 +..B1.54: + cmpl $0, 8(%ebp) + jne ..B1.56 +..B1.55: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + fstpt 16(%esp) + jmp ..B1.57 +..B1.56: + fldt 8(%ebp) + fmull _ones@GOTOFF(%ebx) + fstpt 16(%esp) +..B1.57: + testl %esi, %esi + je ..B1.59 +..B1.58: + fldcw 14(%esp) +..B1.59: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.60: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.61: + fldl _ones@GOTOFF(%ebx,%eax,8) + fstl 16(%esp) + addl $-32, %esp + fldt 8(%ebp) + lea 104(%esp), %eax + fmulp %st, %st(1) + fstpt (%esp) + movl $0, 12(%esp) + movl %eax, 16(%esp) + call __libm_reduce_pi04l +..B1.102: + movl %eax, %edx + addl $32, %esp +..B1.62: + fldl 72(%esp) + incl %edx + fld %st(0) + fldl 16(%esp) + fldl _TWO_48H@GOTOFF(%ebx) + fmul %st, %st(2) + fld %st(2) + fadd %st(4), %st + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + fmul %st(1), %st + fld %st(0) + fxch %st(4) + faddl 80(%esp) + fmulp %st, %st(2) + fxch %st(1) + fadd %st, %st(3) + fxch %st(3) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt _KPi04@GOTOFF(%ebx) + fmul %st(1), %st + fstpt 60(%esp) +..B1.63: + movzwl 68(%esp), %ecx + andl $32767, %ecx + cmpl $16383, %ecx + jge ..B1.73 +..B1.64: + testb $2, %dl + je ..B1.69 +..B1.65: + fldl 8+_ones@GOTOFF(%ebx) + testl %esi, %esi + fdiv %st(1), %st + fmul %st, %st(3) + fld %st(2) + fmul %st(5), %st + fxch %st(5) + fstpt 32(%esp) + fldt 32(%esp) + fmul %st(2), %st + faddp %st, %st(5) + fxch %st(2) + fstpt 48(%esp) + fldt 48(%esp) + fmul %st(0), %st + faddp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fldt 60+_PG@GOTOFF(%ebx) + fmul %st(1), %st + fldt 48+_PG@GOTOFF(%ebx) + fmul %st(2), %st + fldt 36+_PG@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_PG@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fld %st(3) + fadd %st(5), %st + fsub %st(5), %st + fldt 12+_PG@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(6) + fldt _PG@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fld %st(3) + fsub %st(2), %st + fxch %st(6) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 48(%esp) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmul %st(2), %st + fldt 32(%esp) + fmul %st(5), %st + faddp %st, %st(2) + faddl _ones@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + je ..B1.107 +..B1.66: + fstpt 60(%esp) +..B1.103: + fldcw 14(%esp) + jmp ..B1.67 +..B1.107: + fstp %st(0) +..B1.67: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.68: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.69: + fldt 60+_PT@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + testl %esi, %esi + fxch %st(3) + fstpt 48(%esp) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(1) + fldt 48+_PT@GOTOFF(%ebx) + fmul %st(1), %st + fldt 36+_PT@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 24+_PT@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 12+_PT@GOTOFF(%ebx) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt _PT@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fsub %st(2), %st + fmulp %st, %st(1) + fld %st(2) + fmul %st(2), %st + faddp %st, %st(1) + faddp %st, %st(2) + fldt 48(%esp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 16(%esp) + je ..B1.108 +..B1.70: + fstpt 60(%esp) +..B1.104: + fldcw 14(%esp) + jmp ..B1.71 +..B1.108: + fstp %st(0) +..B1.71: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.72: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.73: + fstp %st(0) + fldl .L_2il0floatpacket.0@GOTOFF(%ebx) + negl %ecx + fldl .L_2il0floatpacket.1@GOTOFF(%ebx) + addl $30, %ecx + movl 64(%esp), %eax + shrl %cl, %eax + movl %eax, %ecx + movzbl 17(%ebp), %edi + negl %ecx + testl $128, %edi + jne ..L3 + movl %eax, %ecx +..L3: + movl %ecx, 16(%esp) + testb $2, %dl + fildl 16(%esp) + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fld %st(2) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fsubrp %st, %st(4) + fadd %st(3), %st + je ..B1.78 +..B1.74: + fld %st(1) + fmul %st(4), %st + fld %st(4) + fmul %st(2), %st + shll $4, %ecx + faddp %st, %st(1) + fld %st(2) + testl %esi, %esi + fmul %st(3), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(4) + fstpt 32(%esp) + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fldt 60+_PT@GOTOFF(%ebx) + fmul %st(4), %st + fldt 48+_PT@GOTOFF(%ebx) + fmul %st(5), %st + fldt 36+_PT@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 24+_PT@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt 12+_PT@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(1) + fmul %st, %st(4) + fldt _PT@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fldl 272+_TG@GOTOFF(%ecx,%ebx) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fld %st(0) + fxch %st(5) + faddl 280+_TT@GOTOFF(%ecx,%ebx) + fxch %st(3) + fmull 280+_TG@GOTOFF(%ecx,%ebx) + faddp %st, %st(2) + fxch %st(1) + fadd %st, %st(4) + fldt 32(%esp) + fadd %st, %st(5) + fsubr %st, %st(5) + fxch %st(2) + fsub %st(5), %st + fstpt 48(%esp) + fldt 48(%esp) + faddp %st, %st(1) + fxch %st(3) + faddl 272+_TT@GOTOFF(%ecx,%ebx) + fld %st(0) + fadd %st(3), %st + fdivrl _ones@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(0) + fsub %st(3), %st + fld %st(0) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fxch %st(2) + fmul %st(3), %st + fld %st(3) + fmul %st(6), %st + fxch %st(6) + fadd %st(7), %st + fxch %st(7) + fmulp %st, %st(4) + faddl 8+_ones@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fsubp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + faddl 272+_GG@GOTOFF(%ecx,%ebx) + fxch %st(1) + faddl 280+_GG@GOTOFF(%ecx,%ebx) + faddp %st, %st(1) + fstpt 16(%esp) + fldt 48(%esp) + je ..B1.109 +..B1.75: + fstpt 60(%esp) +..B1.105: + fldcw 14(%esp) + jmp ..B1.76 +..B1.109: + fstp %st(0) +..B1.76: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.77: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.78: + fldt 48+_PT@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(4) + fstpt 48(%esp) + fldt 60+_PT@GOTOFF(%ebx) + fmul %st(4), %st + fldt 36+_PT@GOTOFF(%ebx) + shll $4, %ecx + faddp %st, %st(1) + fmul %st(4), %st + testl %esi, %esi + fldt 24+_PT@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt 12+_PT@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(4) + fldt _PT@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fmul %st(3), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fld %st(3) + fmul %st(1), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt 48(%esp) + fmul %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fstpt 8(%ebp) + fldt 8(%ebp) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(1), %st + fldl 272+_TG@GOTOFF(%ecx,%ebx) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(5), %st + fxch %st(3) + faddl 280+_GG@GOTOFF(%ecx,%ebx) + fxch %st(5) + faddl 272+_GG@GOTOFF(%ecx,%ebx) + fxch %st(2) + fmull 280+_TG@GOTOFF(%ecx,%ebx) + faddp %st, %st(1) + fld %st(1) + fadd %st(5), %st + fdivrl 8+_ones@GOTOFF(%ebx) + fmul %st, %st(4) + fld %st(0) + fadd %st(5), %st + fsubp %st, %st(5) + fld %st(0) + fsub %st(5), %st + fld %st(0) + fmul %st(4), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(2) + fxch %st(3) + fmul %st(5), %st + fld %st(5) + fmul %st(3), %st + fxch %st(3) + fadd %st(5), %st + fxch %st(5) + fmulp %st, %st(6) + faddl _ones@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(0) + fldl 272+_TT@GOTOFF(%ecx,%ebx) + fadd %st, %st(1) + fsubr %st(1), %st + fsubr %st(2), %st + fxch %st(3) + faddl 280+_TT@GOTOFF(%ecx,%ebx) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%esp) + je ..B1.110 +..B1.79: + fstpt 60(%esp) +..B1.106: + fldcw 14(%esp) + jmp ..B1.80 +..B1.110: + fstp %st(0) +..B1.80: + movl 88(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.82 +..B1.81: + fldt 16(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.82: + call __stack_chk_fail@PLT +..B1.83: + cmpl $0, 12(%ebp) + jne ..B1.85 +..B1.84: + cmpl $0, 8(%ebp) + je ..B1.86 +..B1.85: + fldt _small_value_80@GOTOFF(%ebx) + fldt 8(%ebp) + fldl _TWO_75@GOTOFF(%ebx) + fmul %st(1), %st + movzbl 17(%ebp), %edx + faddp %st, %st(1) + fmull 8+_TWO_75@GOTOFF(%ebx) + andl $128, %edx + shrl $7, %edx + fstpt 16(%esp) + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt (%esp) + jmp ..B1.13 +..B1.86: + fldt 8(%ebp) + fstpt 16(%esp) + jmp ..B1.13 +..B1.87: + xorl %esi, %esi + jmp ..B1.11 +..B1.89: + xorl %eax, %eax + jmp ..B1.21 +..B1.91: + xorl %eax, %eax + jmp ..B1.29 +..B1.93: + xorl %eax, %eax + jmp ..B1.37 +..B1.99: + xorl %esi, %esi + jmp ..B1.45 + .align 16,0x90 + .type tanl,@function + .size tanl,.-tanl + .data +# -- End tanl + .section .rodata, "a" + .align 16 + .align 16 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 16 +_P3: + .word 13380 + .word 43827 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .type _P3,@object + .size _P3,12 + .space 4, 0x00 # pad + .align 16 +_P2: + .word 42806 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 23834 + .word 52331 + .word 35007 + .word 34952 + .word 16380 + .word 0 + .type _P2,@object + .size _P2,24 + .space 8, 0x00 # pad + .align 16 +_P1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16380 + .word 0 + .word 31445 + .word 3491 + .word 53469 + .word 56589 + .word 16378 + .word 0 + .word 16733 + .word 58542 + .word 44372 + .word 45863 + .word 16377 + .word 0 + .type _P1,@object + .size _P1,48 + .align 16 +_Pi4Inv: + .long 1841940611 + .long 1072979760 + .type _Pi4Inv,@object + .size _Pi4Inv,8 + .space 8, 0x00 # pad + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .space 8, 0x00 # pad + .align 16 +_KPi04: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16387 + .word 0 + .type _KPi04,@object + .size _KPi04,12 + .space 4, 0x00 # pad + .align 16 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .space 8, 0x00 # pad + .align 16 +_Pi04x3: + .long 1413754112 + .long 1072243195 + .long 2563527040 + .long 1021855384 + .long 3417685868 + .long 3118450936 + .type _Pi04x3,@object + .size _Pi04x3,24 + .space 8, 0x00 # pad + .align 16 +_Pi04x5: + .long 1413480448 + .long 1072243195 + .long 442499072 + .long 1036039265 + .long 771751936 + .long 999496074 + .long 622854144 + .long 963347354 + .long 1396597664 + .long 922906692 + .type _Pi04x5,@object + .size _Pi04x5,40 + .space 8, 0x00 # pad + .align 16 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 16 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 16 +_PG: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 46604 + .word 2912 + .word 24758 + .word 46603 + .word 16377 + .word 0 + .word 64867 + .word 2218 + .word 21984 + .word 35507 + .word 16374 + .word 0 + .word 37428 + .word 49066 + .word 48281 + .word 56811 + .word 16370 + .word 0 + .word 28819 + .word 40692 + .word 30466 + .word 45908 + .word 16367 + .word 0 + .word 58229 + .word 57025 + .word 27882 + .word 37211 + .word 16364 + .word 0 + .type _PG,@object + .size _PG,72 + .space 8, 0x00 # pad + .align 16 +_PT: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 35260 + .word 34952 + .word 34952 + .word 34952 + .word 16380 + .word 0 + .word 59431 + .word 3445 + .word 53469 + .word 56589 + .word 16378 + .word 0 + .word 60805 + .word 19035 + .word 42054 + .word 45863 + .word 16377 + .word 0 + .word 32963 + .word 17667 + .word 64505 + .word 37174 + .word 16376 + .word 0 + .word 33271 + .word 14204 + .word 52730 + .word 60442 + .word 16374 + .word 0 + .type _PT,@object + .size _PT,72 + .space 8, 0x00 # pad + .align 16 +_TG: + .long 2684354560 + .long 3221230545 + .long 1980244105 + .long 1046278452 + .long 0 + .long 3221225472 + .long 0 + .long 0 + .long 2684354560 + .long 3221230545 + .long 1980244105 + .long 1046278452 + .long 3758096384 + .long 3221246014 + .long 1513286675 + .long 1048381067 + .long 0 + .long 3221272655 + .long 4057975187 + .long 3193921290 + .long 2147483648 + .long 3221311866 + .long 2902494488 + .long 1046516509 + .long 3221225472 + .long 3221365863 + .long 1948335328 + .long 3196126810 + .long 2684354560 + .long 3221438007 + .long 3744091947 + .long 3192783219 + .long 2684354560 + .long 3221533379 + .long 3860423252 + .long 1047335024 + .long 2147483648 + .long 3221659806 + .long 862942416 + .long 1049198788 + .long 0 + .long 3221829776 + .long 543592927 + .long 3195468420 + .long 0 + .long 3222064283 + .long 2814267453 + .long 1048596082 + .long 536870912 + .long 3222337673 + .long 2980891112 + .long 3196362141 + .long 2684354560 + .long 3222595502 + .long 141458722 + .long 1049458206 + .long 3221225472 + .long 3223031588 + .long 2120823910 + .long 1049591613 + .long 3221225472 + .long 3223617753 + .long 663882580 + .long 3198186420 + .long 2147483648 + .long 3224659859 + .long 3051968734 + .long 3194791707 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1077176211 + .long 3051968734 + .long 1047308059 + .long 3221225472 + .long 1076134105 + .long 663882580 + .long 1050702772 + .long 3221225472 + .long 1075547940 + .long 2120823910 + .long 3197075261 + .long 2684354560 + .long 1075111854 + .long 141458722 + .long 3196941854 + .long 536870912 + .long 1074854025 + .long 2980891112 + .long 1048878493 + .long 0 + .long 1074580635 + .long 2814267453 + .long 3196079730 + .long 0 + .long 1074346128 + .long 543592927 + .long 1047984772 + .long 2147483648 + .long 1074176158 + .long 862942416 + .long 3196682436 + .long 2684354560 + .long 1074049731 + .long 3860423252 + .long 3194818672 + .long 2684354560 + .long 1073954359 + .long 3744091947 + .long 1045299571 + .long 3221225472 + .long 1073882215 + .long 1948335328 + .long 1048643162 + .long 2147483648 + .long 1073828218 + .long 2902494488 + .long 3194000157 + .long 0 + .long 1073789007 + .long 4057975187 + .long 1046437642 + .long 3758096384 + .long 1073762366 + .long 1513286675 + .long 3195864715 + .long 2684354560 + .long 1073746897 + .long 1980244105 + .long 3193762100 + .long 0 + .long 1073741824 + .long 0 + .long 0 + .long 2684354560 + .long 1073746897 + .long 1980244105 + .long 3193762100 + .type _TG,@object + .size _TG,560 + .align 16 +_TT: + .long 1610612736 + .long 3220285245 + .long 1765132704 + .long 1046851815 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 3221225472 + .long 3219980491 + .long 3100042604 + .long 3192709428 + .long 1073741824 + .long 3219800832 + .long 2956254064 + .long 1046813655 + .long 0 + .long 3219635098 + .long 829070670 + .long 1046664815 + .long 0 + .long 3219481016 + .long 3358544266 + .long 3195362300 + .long 2147483648 + .long 3219336728 + .long 4185368031 + .long 3193047295 + .long 536870912 + .long 3219200695 + .long 1373988029 + .long 1045159724 + .long 0 + .long 3219014926 + .long 4104169752 + .long 3192540796 + .long 2147483648 + .long 3218768505 + .long 843197631 + .long 3193568495 + .long 0 + .long 3218531914 + .long 1839318447 + .long 1044402419 + .long 1073741824 + .long 3218303496 + .long 1215676724 + .long 1044727608 + .long 1610612736 + .long 3218081786 + .long 2922073518 + .long 3193275942 + .long 0 + .long 3217651190 + .long 2818065035 + .long 1045408462 + .long 2147483648 + .long 3217226924 + .long 2142552361 + .long 1043903475 + .long 2147483648 + .long 3216586427 + .long 1153689642 + .long 3190339163 + .long 2147483648 + .long 3215533863 + .long 3288774277 + .long 3189012002 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1068050215 + .long 3288774277 + .long 1041528354 + .long 2147483648 + .long 1069102779 + .long 1153689642 + .long 1042855515 + .long 2147483648 + .long 1069743276 + .long 2142552361 + .long 3191387123 + .long 0 + .long 1070167542 + .long 2818065035 + .long 3192892110 + .long 1610612736 + .long 1070598138 + .long 2922073518 + .long 1045792294 + .long 1073741824 + .long 1070819848 + .long 1215676724 + .long 3192211256 + .long 0 + .long 1071048266 + .long 1839318447 + .long 3191886067 + .long 2147483648 + .long 1071284857 + .long 843197631 + .long 1046084847 + .long 0 + .long 1071531278 + .long 4104169752 + .long 1045057148 + .long 536870912 + .long 1071717047 + .long 1373988029 + .long 3192643372 + .long 2147483648 + .long 1071853080 + .long 4185368031 + .long 1045563647 + .long 0 + .long 1071997368 + .long 3358544266 + .long 1047878652 + .long 0 + .long 1072151450 + .long 829070670 + .long 3194148463 + .long 1073741824 + .long 1072317184 + .long 2956254064 + .long 3194297303 + .long 3221225472 + .long 1072496843 + .long 3100042604 + .long 1045225780 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1610612736 + .long 1072801597 + .long 1765132704 + .long 3194335463 + .type _TT,@object + .size _TT,560 + .align 16 +_GG: + .long 3221225472 + .long 1072496843 + .long 3100042604 + .long 1045225780 + .long 0 + .long 1072693248 + .long 2680413623 + .long 2803148914 + .long 1610612736 + .long 1072801597 + .long 1765132704 + .long 3194335463 + .long 2147483648 + .long 1072922365 + .long 4224648010 + .long 1047203520 + .long 0 + .long 1073058513 + .long 1429029132 + .long 1047610106 + .long 0 + .long 1073213977 + .long 2662307862 + .long 3195905419 + .long 2147483648 + .long 1073394115 + .long 2332932060 + .long 3196140229 + .long 3221225472 + .long 1073606419 + .long 4089189126 + .long 3194062807 + .long 3758096384 + .long 1073801761 + .long 295749197 + .long 3195130376 + .long 1073741824 + .long 1073958991 + .long 862942416 + .long 3195633860 + .long 0 + .long 1074158535 + .long 1551453531 + .long 3197746903 + .long 0 + .long 1074421594 + .long 590804010 + .long 3196516863 + .long 0 + .long 1074786323 + .long 1872593098 + .long 1046983523 + .long 3758096384 + .long 1075059710 + .long 2286165020 + .long 1046614587 + .long 2147483648 + .long 1075509055 + .long 2023416727 + .long 3198791271 + .long 1610612736 + .long 1076121196 + .long 3469402705 + .long 3196752904 + .long 0 + .long 1077172992 + .long 2869016295 + .long 3199393764 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3224656640 + .long 2869016295 + .long 1051910116 + .long 1610612736 + .long 3223604844 + .long 3469402705 + .long 1049269256 + .long 2147483648 + .long 3222992703 + .long 2023416727 + .long 1051307623 + .long 3758096384 + .long 3222543358 + .long 2286165020 + .long 3194098235 + .long 0 + .long 3222269971 + .long 1872593098 + .long 3194467171 + .long 0 + .long 3221905242 + .long 590804010 + .long 1049033215 + .long 0 + .long 3221642183 + .long 1551453531 + .long 1050263255 + .long 1073741824 + .long 3221442639 + .long 862942416 + .long 1048150212 + .long 3758096384 + .long 3221285409 + .long 295749197 + .long 1047646728 + .long 3221225472 + .long 3221090067 + .long 4089189126 + .long 1046579159 + .long 2147483648 + .long 3220877763 + .long 2332932060 + .long 1048656581 + .long 0 + .long 3220697625 + .long 2662307862 + .long 1048421771 + .long 0 + .long 3220542161 + .long 1429029132 + .long 3195093754 + .long 2147483648 + .long 3220406013 + .long 4224648010 + .long 3194687168 + .long 1610612736 + .long 3220285245 + .long 1765132704 + .long 1046851815 + .long 0 + .long 3220176896 + .long 2680413623 + .long 655665266 + .long 3221225472 + .long 3219980491 + .long 3100042604 + .long 3192709428 + .type _GG,@object + .size _GG,560 + .align 16 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 8 +.L_2il0floatpacket.0: + .long 0x54400000,0x3fa921fb + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x1a626331,0x3d80b461 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .data + .hidden __libm_reduce_pi04l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tgamma.S b/external/sgx_libm/ia32/tgamma.S new file mode 100644 index 0000000000..eab73c8522 --- /dev/null +++ b/external/sgx_libm/ia32/tgamma.S @@ -0,0 +1,3035 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tgamma.c" + .text +..TXTST0: +# -- Begin tgamma + .text + .align 16,0x90 + .globl tgamma +tgamma: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $68, %esp + fldl 8(%ebp) + call ..L2 +..L2: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edi), %edi + fstpl 16(%esp) + fldl _zeros@GOTOFF(%edi) + fstpl 40(%esp) +..B1.2: + fnstcw 54(%esp) +..B1.3: + movzwl 54(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.125 +..B1.4: + orl $-64768, %edx + movw %dx, 52(%esp) +..B1.5: + fldcw 52(%esp) +..B1.6: + movl $1, %ebx +..B1.7: + call fegetround +..B1.128: + movl %eax, 48(%esp) +..B1.8: + cmpl $0, 48(%esp) + jne ..B1.10 +..B1.9: + xorl %ecx, %ecx + jmp ..B1.12 +..B1.10: + addl $-16, %esp + movl $0, (%esp) + call fesetround +..B1.129: + addl $16, %esp +..B1.11: + movl $1, %ecx +..B1.12: + movzwl 14(%ebp), %eax + andl $32752, %eax + shrl $4, %eax + movl 12(%ebp), %esi + shrl $31, %esi + movl %eax, 4(%esp) + cmpl $2047, %eax + je ..B1.114 +..B1.13: + fldl 8(%ebp) + fldl _zeros@GOTOFF(%edi) + movl 16(%esp), %eax + movl %eax, (%esp) + fucom %st(1) + fnstsw %ax + movl 20(%esp), %edx + andl $2147483647, %edx + movl %edx, 20(%esp) + sahf + jp ..B1.14 + je ..B1.109 +..B1.14: + cmpl $262144, %edx + jl ..B1.104 +..B1.15: + je ..B1.103 +..B1.16: + testl %esi, %esi + je ..B1.145 +..B1.17: + cmpl $1075, 4(%esp) + jge ..B1.93 +..B1.18: + fldl 16(%esp) + fld %st(0) + fldl _TWO_52H@GOTOFF(%edi) + fadd %st, %st(1) + fxch %st(1) + fstpl 32(%esp) + fldl 32(%esp) + movl 32(%esp), %edx + fsubp %st, %st(1) + movl %edx, (%esp) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B1.20 +..B1.19: + incl (%esp) + fsubl _ones@GOTOFF(%edi) +..B1.20: + fucompp + fnstsw %ax + sahf + jp ..B1.21 + je ..B1.88 +..B1.21: + fstp %st(0) + fldl .L_2il0floatpacket.0@GOTOFF(%edi) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.27 +..B1.22: + fstp %st(0) + testl %ecx, %ecx + je ..B1.24 +..B1.23: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.130: + addl $16, %esp +..B1.24: + movl (%esp), %eax + notl %eax + andl $1, %eax + testl %ebx, %ebx + fldl _small_value_64@GOTOFF(%edi,%eax,8) + fmull _small_value_64@GOTOFF(%edi) + fstpl 40(%esp) + je ..B1.26 +..B1.25: + fldcw 54(%esp) +..B1.26: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.145: + fstp %st(0) +..B1.27: + fcompl _overflow_boundary@GOTOFF(%edi) + fnstsw %ax + sahf + jae ..B1.98 +..B1.28: + testl %esi, %esi + je ..B1.30 +..B1.29: + fldl 16(%esp) + fld %st(0) + fldl _TWO_52H@GOTOFF(%edi) + fadd %st, %st(1) + fxch %st(1) + fstpl 32(%esp) + fldl 32(%esp) + fsub %st(1), %st + fsubr %st(2), %st + fstpl 24(%esp) + fldt 108+_tgamma_sin_table@GOTOFF(%edi) + fldt 96+_tgamma_sin_table@GOTOFF(%edi) + fldt 84+_tgamma_sin_table@GOTOFF(%edi) + fldt 72+_tgamma_sin_table@GOTOFF(%edi) + andl $2147483647, 28(%esp) + fldl 24(%esp) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 60+_tgamma_sin_table@GOTOFF(%edi) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 48+_tgamma_sin_table@GOTOFF(%edi) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 36+_tgamma_sin_table@GOTOFF(%edi) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 24+_tgamma_sin_table@GOTOFF(%edi) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 12+_tgamma_sin_table@GOTOFF(%edi) + faddp %st, %st(3) + fmul %st, %st(2) + fmul %st(1), %st + fldt _tgamma_sin_table@GOTOFF(%edi) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + jmp ..B1.31 +..B1.30: + fldl 16(%esp) + fldz + fldl _TWO_52H@GOTOFF(%edi) +..B1.31: + fldl _ones@GOTOFF(%edi) + fxch %st(1) + fadd %st(3), %st + fstpl 32(%esp) + fldl 32(%esp) + movl 32(%esp), %edx + fsubl _TWO_52H@GOTOFF(%edi) + fcom %st(3) + fnstsw %ax + sahf + jbe ..B1.33 +..B1.32: + decl %edx + fsub %st(1), %st +..B1.33: + lea 1(%edx), %eax + andl $1, %eax + movl %eax, 12(%esp) + fxch %st(3) + fcoml .L_2il0floatpacket.1@GOTOFF(%edi) + fnstsw %ax + sahf + jb ..B1.56 +..B1.34: + movl %esi, 4(%esp) + movl %edx, %esi + andl $15, %esi + movl %edx, %eax + andl $-16, %eax + cmpl $16, %edx + movl %ebx, 8(%esp) + movl %eax, %edx + fsub %st, %st(3) + fld %st(3) + lea -2(%esi), %ebx + jl ..L3 + movl %esi, %ebx +..L3: + sarl $2, %edx + movl %eax, %esi + sarl $3, %esi + addl %eax, %edx + sarl $4, %eax + addl %eax, %esi + addl %esi, %edx + fmul %st(4), %st + testl %ebx, %ebx + movl %ebx, (%esp) + lea (,%edx,8), %eax + movl 8(%esp), %ebx + lea (%eax,%edx,4), %edx + fldt 264+_tgamma_A_table@GOTOFF(%edi,%edx) + fldt _tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(6), %st + movl 4(%esp), %esi + fadd %st(2), %st + fldt 132+_tgamma_A_table@GOTOFF(%edi,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 144+_tgamma_A_table@GOTOFF(%edi,%edx) + fldt 12+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(7), %st + fadd %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 24+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(6), %st + fadd %st(2), %st + fldt 156+_tgamma_A_table@GOTOFF(%edi,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 168+_tgamma_A_table@GOTOFF(%edi,%edx) + fldt 36+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(7), %st + fadd %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 48+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(6), %st + fadd %st(2), %st + fldt 180+_tgamma_A_table@GOTOFF(%edi,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 192+_tgamma_A_table@GOTOFF(%edi,%edx) + fldt 60+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(7), %st + fadd %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 72+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(6), %st + fadd %st(2), %st + fldt 204+_tgamma_A_table@GOTOFF(%edi,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 216+_tgamma_A_table@GOTOFF(%edi,%edx) + fldt 84+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(7), %st + fadd %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 96+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(6), %st + fadd %st(2), %st + fldt 228+_tgamma_A_table@GOTOFF(%edi,%edx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 240+_tgamma_A_table@GOTOFF(%edi,%edx) + fldt 108+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(7), %st + fadd %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 120+_tgamma_A_table@GOTOFF(%edi,%edx) + fmul %st(6), %st + faddp %st, %st(2) + fldt 252+_tgamma_A_table@GOTOFF(%edi,%edx) + faddp %st, %st(2) + fmulp %st, %st(1) + fld %st(2) + je ..B1.39 +..B1.35: + jle ..B1.39 +..B1.36: + movl (%esp), %edx + movl $1, %eax +..B1.37: + movl %eax, (%esp) + incl %eax + fildl (%esp) + cmpl %edx, %eax + fsubr %st(3), %st + fmulp %st, %st(1) + jle ..B1.37 +..B1.39: + testl %esi, %esi + je ..B1.50 +..B1.40: + fxch %st(4) + fmulp %st, %st(2) + fmulp %st, %st(1) + fmulp %st, %st(2) + fdivp %st, %st(1) + fldl .L_2il0floatpacket.2@GOTOFF(%edi) + fcompl 8(%ebp) + fnstsw %ax + sahf + fxch %st(1) + jbe ..B1.48 +..B1.41: + cmpl $0, 12(%esp) + je ..B1.43 +..B1.42: + fxch %st(1) + fchs + fxch %st(1) +..B1.43: + testl %ecx, %ecx + je ..B1.46 +..B1.44: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpl 32(%esp) + fstpt 16(%esp) + call fesetround +..B1.131: + fldt 16(%esp) + fldl 32(%esp) + addl $16, %esp +..B1.45: + xorl %ecx, %ecx +..B1.46: + fldt _tgamma_A176_inv@GOTOFF(%edi) + fmulp %st, %st(2) + cmpl $0, 12(%esp) + je ..B1.48 +..B1.47: + fxch %st(1) + fchs + fxch %st(1) +..B1.48: + movl 12(%esp), %eax + fxch %st(1) + fstpl 40(%esp) + shll $31, %eax + xorl %eax, 44(%esp) + testl %ecx, %ecx + je ..B1.53 +..B1.49: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpl 32(%esp) + call fesetround +..B1.132: + fldl 32(%esp) + addl $16, %esp + jmp ..B1.53 +..B1.50: + fstp %st(3) + fstp %st(3) + fstp %st(0) + fmulp %st, %st(1) + testl %ecx, %ecx + je ..B1.52 +..B1.51: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpl 32(%esp) + call fesetround +..B1.133: + fldl 32(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.52: + fstpl 40(%esp) +..B1.53: + testl %ebx, %ebx + je ..B1.146 +..B1.54: + fstpl 24(%esp) +..B1.134: + fldcw 54(%esp) + jmp ..B1.55 +..B1.146: + fstp %st(0) +..B1.55: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.56: + fstp %st(3) + fcom %st(2) + fnstsw %ax + sahf + jbe ..B1.58 +..B1.57: + fld %st(2) + fadd %st(1), %st + jmp ..B1.59 +..B1.58: + fld %st(2) +..B1.59: + fldt .L_2il0floatpacket.3@GOTOFF(%edi) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.61 + jp ..B1.61 +..B1.60: + fsub %st(1), %st + fstpl 24(%esp) + lea _tgamma_A150_table@GOTOFF(%edi), %eax + jmp ..B1.66 +..B1.61: + fldt .L_2il0floatpacket.4@GOTOFF(%edi) + fcom %st(1) + fnstsw %ax + sahf + ja ..B1.63 + jp ..B1.63 +..B1.62: + fstp %st(0) + fldt _local_minimum_l@GOTOFF(%edi) + lea _tgamma_A125_table@GOTOFF(%edi), %eax + fsubrp %st, %st(1) + fstpl 24(%esp) + jmp ..B1.66 +..B1.63: + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.65 +..B1.64: + fsub %st(1), %st + fstpl 24(%esp) + lea _tgamma_A100_table@GOTOFF(%edi), %eax + jmp ..B1.66 +..B1.65: + fstp %st(0) +..B1.66: + fldt (%eax) + cmpl $0, 4(%esp) + je ..B1.69 +..B1.67: + fldl 24(%esp) + fldt 180(%eax) + fmul %st(1), %st + fldt 168(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 156(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 144(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 132(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 120(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 108(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24(%eax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12(%eax) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) +..B1.69: + fxch %st(1) + fcom %st(3) + fnstsw %ax + sahf + jbe ..B1.78 +..B1.70: + testl %esi, %esi + je ..B1.74 +..B1.71: + fstp %st(3) + fmulp %st, %st(1) + testl %ecx, %ecx + fdivrp %st, %st(1) + fchs + je ..B1.73 +..B1.72: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B1.135: + fldt 16(%esp) + addl $16, %esp +..B1.73: + movl 12(%esp), %eax + fchs + fstpl 40(%esp) + shll $31, %eax + xorl %eax, 44(%esp) + jmp ..B1.85 +..B1.74: + fstp %st(0) + fstp %st(1) + testl %ecx, %ecx + fxch %st(1) + je ..B1.77 +..B1.75: + fstp %st(0) + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B1.136: + fldt 16(%esp) + addl $16, %esp +..B1.76: + fldl 16(%esp) +..B1.77: + fdivrp %st, %st(1) + fstpl 40(%esp) + jmp ..B1.85 +..B1.78: + testl %esi, %esi + je ..B1.82 +..B1.79: + fxch %st(3) + fmulp %st, %st(2) + testl %ecx, %ecx + fmulp %st, %st(1) + fdivrp %st, %st(1) + je ..B1.81 +..B1.80: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B1.137: + fldt 16(%esp) + addl $16, %esp +..B1.81: + fstpl 40(%esp) + jmp ..B1.85 +..B1.82: + fstp %st(0) + fstp %st(1) + fstp %st(1) + testl %ecx, %ecx + je ..B1.84 +..B1.83: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + call fesetround +..B1.138: + fldt 16(%esp) + addl $16, %esp +..B1.84: + fstpl 40(%esp) +..B1.85: + testl %ebx, %ebx + je ..B1.87 +..B1.86: + fldcw 54(%esp) +..B1.87: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.88: + fstp %st(1) + testl %ecx, %ecx + je ..B1.90 +..B1.89: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpl 16(%esp) + call fesetround +..B1.139: + fldl 16(%esp) + addl $16, %esp +..B1.90: + fdiv %st(0), %st + testl %ebx, %ebx + fstpl 40(%esp) + je ..B1.92 +..B1.91: + fldcw 54(%esp) +..B1.92: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.93: + fstp %st(1) + testl %ecx, %ecx + je ..B1.95 +..B1.94: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpl 16(%esp) + call fesetround +..B1.140: + fldl 16(%esp) + addl $16, %esp +..B1.95: + fdiv %st(0), %st + testl %ebx, %ebx + fstpl 40(%esp) + je ..B1.97 +..B1.96: + fldcw 54(%esp) +..B1.97: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.98: + testl %ecx, %ecx + je ..B1.100 +..B1.99: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.141: + addl $16, %esp +..B1.100: + fldl _large_value_64@GOTOFF(%edi) + testl %ebx, %ebx + fmul %st(0), %st + fstpl 40(%esp) + je ..B1.102 +..B1.101: + fldcw 54(%esp) +..B1.102: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.103: + cmpl $0, (%esp) + jne ..B1.16 +..B1.104: + fstp %st(0) + fstp %st(0) + testl %ecx, %ecx + je ..B1.106 +..B1.105: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.142: + addl $16, %esp +..B1.106: + fldl _large_value_64@GOTOFF(%edi,%esi,8) + testl %ebx, %ebx + fmull _large_value_64@GOTOFF(%edi) + fstpl 40(%esp) + je ..B1.108 +..B1.107: + fldcw 54(%esp) +..B1.108: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.109: + fstp %st(1) + testl %ecx, %ecx + je ..B1.111 +..B1.110: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + fstpl 16(%esp) + call fesetround +..B1.143: + fldl 16(%esp) + addl $16, %esp +..B1.111: + fldl _ones@GOTOFF(%edi,%esi,8) + testl %ebx, %ebx + fdivp %st, %st(1) + fstpl 40(%esp) + je ..B1.113 +..B1.112: + fldcw 54(%esp) +..B1.113: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.114: + testl %ecx, %ecx + je ..B1.116 +..B1.115: + addl $-16, %esp + movl 64(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.144: + addl $16, %esp +..B1.116: + testl %esi, %esi + je ..B1.119 +..B1.117: + testl $1048575, 12(%ebp) + jne ..B1.119 +..B1.118: + cmpl $0, 8(%ebp) + je ..B1.122 +..B1.119: + fldl 8(%ebp) + testl %ebx, %ebx + fmull _ones@GOTOFF(%edi) + fstpl 40(%esp) + je ..B1.121 +..B1.120: + fldcw 54(%esp) +..B1.121: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.122: + fldl 8+_zeros@GOTOFF(%edi) + testl %ebx, %ebx + fdivl _zeros@GOTOFF(%edi) + fstpl 40(%esp) + je ..B1.124 +..B1.123: + fldcw 54(%esp) +..B1.124: + fldl 40(%esp) + addl $68, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.125: + xorl %ebx, %ebx + jmp ..B1.7 + .align 16,0x90 + .type tgamma,@function + .size tgamma,.-tgamma + .data +# -- End tgamma + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xc0672000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0xc0660000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_overflow_boundary: + .long 3848402504 + .long 1080390650 + .type _overflow_boundary,@object + .size _overflow_boundary,8 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 2 +_tgamma_sin_table: + .word 39192 + .word 38974 + .word 13074 + .word 53901 + .word 49151 + .word 0 + .word 25233 + .word 24099 + .word 23041 + .word 53198 + .word 16382 + .word 0 + .word 14010 + .word 1755 + .word 29241 + .word 50004 + .word 49148 + .word 0 + .word 12661 + .word 39557 + .word 743 + .word 54836 + .word 16377 + .word 0 + .word 23329 + .word 12349 + .word 46418 + .word 39360 + .word 49142 + .word 0 + .word 43549 + .word 22984 + .word 36093 + .word 39843 + .word 16370 + .word 0 + .word 50635 + .word 59140 + .word 19560 + .word 59922 + .word 49133 + .word 0 + .word 39826 + .word 40176 + .word 51583 + .word 34788 + .word 16361 + .word 0 + .word 63061 + .word 25910 + .word 60600 + .word 64252 + .word 49123 + .word 0 + .word 21154 + .word 4399 + .word 17218 + .word 48316 + .word 16350 + .word 0 + .type _tgamma_sin_table,@object + .size _tgamma_sin_table,120 + .align 2 +_tgamma_A_table: + .word 44002 + .word 44608 + .word 34249 + .word 61198 + .word 16384 + .word 0 + .word 28120 + .word 46089 + .word 18909 + .word 51744 + .word 16384 + .word 0 + .word 6796 + .word 56365 + .word 948 + .word 39330 + .word 16384 + .word 0 + .word 21872 + .word 3113 + .word 40348 + .word 48989 + .word 16383 + .word 0 + .word 15275 + .word 60291 + .word 893 + .word 59613 + .word 16381 + .word 0 + .word 41018 + .word 41834 + .word 14754 + .word 46766 + .word 49150 + .word 0 + .word 10107 + .word 10320 + .word 24796 + .word 32841 + .word 49152 + .word 0 + .word 40832 + .word 16832 + .word 38712 + .word 55795 + .word 49152 + .word 0 + .word 8761 + .word 28554 + .word 35431 + .word 39961 + .word 49153 + .word 0 + .word 12838 + .word 702 + .word 32174 + .word 51595 + .word 49153 + .word 0 + .word 442 + .word 50835 + .word 62234 + .word 59850 + .word 49153 + .word 0 + .word 53618 + .word 2208 + .word 54662 + .word 64445 + .word 16384 + .word 0 + .word 33537 + .word 7687 + .word 12653 + .word 64976 + .word 16384 + .word 0 + .word 5604 + .word 18060 + .word 46944 + .word 34352 + .word 16385 + .word 0 + .word 5422 + .word 18393 + .word 57870 + .word 37869 + .word 16385 + .word 0 + .word 27417 + .word 51069 + .word 14904 + .word 43119 + .word 16385 + .word 0 + .word 16515 + .word 36952 + .word 46206 + .word 50255 + .word 16385 + .word 0 + .word 22913 + .word 57796 + .word 61047 + .word 59491 + .word 16385 + .word 0 + .word 55054 + .word 14521 + .word 23522 + .word 35521 + .word 16386 + .word 0 + .word 3828 + .word 37429 + .word 19301 + .word 42457 + .word 16386 + .word 0 + .word 18611 + .word 8353 + .word 56126 + .word 50041 + .word 16386 + .word 0 + .word 63177 + .word 14708 + .word 18871 + .word 56010 + .word 16386 + .word 0 + .word 51349 + .word 6910 + .word 18794 + .word 33038 + .word 16353 + .word 0 + .word 59411 + .word 13918 + .word 30079 + .word 63615 + .word 16384 + .word 0 + .word 40356 + .word 37493 + .word 20410 + .word 60584 + .word 16384 + .word 0 + .word 59667 + .word 1960 + .word 42334 + .word 54496 + .word 16384 + .word 0 + .word 24443 + .word 19594 + .word 17897 + .word 45291 + .word 16384 + .word 0 + .word 24957 + .word 63432 + .word 54964 + .word 32848 + .word 16384 + .word 0 + .word 7770 + .word 43625 + .word 45329 + .word 33905 + .word 16383 + .word 0 + .word 34249 + .word 63845 + .word 17962 + .word 44463 + .word 49148 + .word 0 + .word 49963 + .word 34728 + .word 51109 + .word 54055 + .word 49151 + .word 0 + .word 57585 + .word 19701 + .word 6443 + .word 57077 + .word 49152 + .word 0 + .word 61186 + .word 8282 + .word 25787 + .word 47837 + .word 49153 + .word 0 + .word 26720 + .word 42621 + .word 41546 + .word 37680 + .word 49154 + .word 0 + .word 18366 + .word 28044 + .word 60147 + .word 62846 + .word 16384 + .word 0 + .word 6968 + .word 10789 + .word 37601 + .word 32880 + .word 16385 + .word 0 + .word 60700 + .word 57063 + .word 36736 + .word 35909 + .word 16385 + .word 0 + .word 61862 + .word 56439 + .word 50993 + .word 40752 + .word 16385 + .word 0 + .word 41843 + .word 39363 + .word 59360 + .word 47812 + .word 16385 + .word 0 + .word 63511 + .word 43763 + .word 855 + .word 57724 + .word 16385 + .word 0 + .word 64510 + .word 20731 + .word 32839 + .word 35752 + .word 16386 + .word 0 + .word 60398 + .word 46667 + .word 43836 + .word 45454 + .word 16386 + .word 0 + .word 49807 + .word 23281 + .word 46849 + .word 59658 + .word 16386 + .word 0 + .word 37270 + .word 40485 + .word 38862 + .word 41131 + .word 16387 + .word 0 + .word 55072 + .word 194 + .word 57504 + .word 62944 + .word 16387 + .word 0 + .word 6484 + .word 60537 + .word 3975 + .word 55679 + .word 16389 + .word 0 + .word 11759 + .word 24340 + .word 39489 + .word 49925 + .word 16384 + .word 0 + .word 22650 + .word 18020 + .word 56002 + .word 47553 + .word 16384 + .word 0 + .word 65458 + .word 2450 + .word 7569 + .word 42768 + .word 16384 + .word 0 + .word 2740 + .word 58538 + .word 8888 + .word 35477 + .word 16384 + .word 0 + .word 24012 + .word 19369 + .word 10014 + .word 51050 + .word 16383 + .word 0 + .word 32754 + .word 14555 + .word 56874 + .word 50646 + .word 16382 + .word 0 + .word 6322 + .word 39288 + .word 8326 + .word 56228 + .word 49148 + .word 0 + .word 51606 + .word 9409 + .word 56084 + .word 47341 + .word 49151 + .word 0 + .word 19293 + .word 17746 + .word 29435 + .word 49011 + .word 49152 + .word 0 + .word 22538 + .word 37169 + .word 56949 + .word 41021 + .word 49153 + .word 0 + .word 65507 + .word 8897 + .word 64576 + .word 64934 + .word 49153 + .word 0 + .word 21309 + .word 38834 + .word 44023 + .word 38745 + .word 16384 + .word 0 + .word 52933 + .word 53016 + .word 24774 + .word 40865 + .word 16384 + .word 0 + .word 4045 + .word 21262 + .word 61923 + .word 45295 + .word 16384 + .word 0 + .word 26065 + .word 18177 + .word 3420 + .word 52438 + .word 16384 + .word 0 + .word 45505 + .word 1968 + .word 16227 + .word 62949 + .word 16384 + .word 0 + .word 1037 + .word 13974 + .word 10559 + .word 38924 + .word 16385 + .word 0 + .word 39502 + .word 38026 + .word 65467 + .word 49371 + .word 16385 + .word 0 + .word 34978 + .word 59813 + .word 17957 + .word 64181 + .word 16385 + .word 0 + .word 4031 + .word 54789 + .word 33142 + .word 42976 + .word 16386 + .word 0 + .word 2719 + .word 21031 + .word 60489 + .word 60330 + .word 16386 + .word 0 + .word 20734 + .word 53765 + .word 40154 + .word 46919 + .word 16387 + .word 0 + .word 63028 + .word 7231 + .word 17811 + .word 43725 + .word 16468 + .word 0 + .word 32606 + .word 48355 + .word 22399 + .word 43710 + .word 16384 + .word 0 + .word 29042 + .word 46559 + .word 51950 + .word 41588 + .word 16384 + .word 0 + .word 47396 + .word 18113 + .word 2918 + .word 37305 + .word 16384 + .word 0 + .word 22233 + .word 40098 + .word 6225 + .word 61543 + .word 16383 + .word 0 + .word 611 + .word 49379 + .word 57729 + .word 43678 + .word 16383 + .word 0 + .word 10450 + .word 9675 + .word 56147 + .word 41083 + .word 16382 + .word 0 + .word 37401 + .word 8271 + .word 47219 + .word 34504 + .word 49149 + .word 0 + .word 34774 + .word 15943 + .word 11357 + .word 45081 + .word 49151 + .word 0 + .word 6639 + .word 15692 + .word 42534 + .word 45536 + .word 49152 + .word 0 + .word 51630 + .word 6378 + .word 12961 + .word 37818 + .word 49153 + .word 0 + .word 59527 + .word 55742 + .word 41884 + .word 59714 + .word 49153 + .word 0 + .word 15629 + .word 31501 + .word 45205 + .word 59448 + .word 16383 + .word 0 + .word 53044 + .word 1871 + .word 3840 + .word 62990 + .word 16383 + .word 0 + .word 49829 + .word 44544 + .word 39222 + .word 35206 + .word 16384 + .word 0 + .word 8319 + .word 42513 + .word 20106 + .word 41214 + .word 16384 + .word 0 + .word 56062 + .word 65309 + .word 8860 + .word 50097 + .word 16384 + .word 0 + .word 39637 + .word 65 + .word 3840 + .word 62744 + .word 16384 + .word 0 + .word 8819 + .word 49083 + .word 32007 + .word 40272 + .word 16385 + .word 0 + .word 33763 + .word 5027 + .word 16250 + .word 52917 + .word 16385 + .word 0 + .word 4751 + .word 2633 + .word 61342 + .word 35759 + .word 16386 + .word 0 + .word 8844 + .word 54174 + .word 63762 + .word 50574 + .word 16386 + .word 0 + .word 8334 + .word 8890 + .word 4484 + .word 39560 + .word 16387 + .word 0 + .word 4811 + .word 30700 + .word 3620 + .word 48492 + .word 16556 + .word 0 + .word 24963 + .word 23772 + .word 56823 + .word 39936 + .word 16384 + .word 0 + .word 33598 + .word 3946 + .word 44700 + .word 37958 + .word 16384 + .word 0 + .word 46964 + .word 13072 + .word 50440 + .word 33963 + .word 16384 + .word 0 + .word 60803 + .word 30641 + .word 14857 + .word 55738 + .word 16383 + .word 0 + .word 54016 + .word 37905 + .word 6345 + .word 39067 + .word 16383 + .word 0 + .word 52847 + .word 8984 + .word 26176 + .word 34926 + .word 16382 + .word 0 + .word 36664 + .word 26865 + .word 35876 + .word 39170 + .word 49149 + .word 0 + .word 52449 + .word 52544 + .word 53629 + .word 43890 + .word 49151 + .word 0 + .word 12025 + .word 58412 + .word 44187 + .word 43481 + .word 49152 + .word 0 + .word 31442 + .word 43543 + .word 55683 + .word 35857 + .word 49153 + .word 0 + .word 3846 + .word 7199 + .word 40600 + .word 56439 + .word 49153 + .word 0 + .word 59606 + .word 22885 + .word 19144 + .word 49661 + .word 16383 + .word 0 + .word 40642 + .word 40248 + .word 11664 + .word 52797 + .word 16383 + .word 0 + .word 62936 + .word 44294 + .word 39296 + .word 59383 + .word 16383 + .word 0 + .word 2909 + .word 51304 + .word 40819 + .word 35037 + .word 16384 + .word 0 + .word 28573 + .word 45780 + .word 52012 + .word 42966 + .word 16384 + .word 0 + .word 18650 + .word 49015 + .word 44104 + .word 54288 + .word 16384 + .word 0 + .word 55601 + .word 45035 + .word 39824 + .word 35129 + .word 16385 + .word 0 + .word 34144 + .word 30699 + .word 57231 + .word 46486 + .word 16385 + .word 0 + .word 46246 + .word 1151 + .word 17498 + .word 63193 + .word 16385 + .word 0 + .word 4951 + .word 25890 + .word 61661 + .word 44882 + .word 16386 + .word 0 + .word 6537 + .word 64648 + .word 46171 + .word 35209 + .word 16387 + .word 0 + .word 3418 + .word 59105 + .word 44678 + .word 47100 + .word 16651 + .word 0 + .word 12496 + .word 39220 + .word 65358 + .word 37319 + .word 16384 + .word 0 + .word 42985 + .word 15941 + .word 31416 + .word 35438 + .word 16384 + .word 0 + .word 48809 + .word 58407 + .word 25474 + .word 63277 + .word 16383 + .word 0 + .word 16086 + .word 46002 + .word 58617 + .word 51682 + .word 16383 + .word 0 + .word 55157 + .word 44549 + .word 61270 + .word 35823 + .word 16383 + .word 0 + .word 21856 + .word 27160 + .word 26283 + .word 61078 + .word 16381 + .word 0 + .word 57421 + .word 61358 + .word 44892 + .word 42671 + .word 49149 + .word 0 + .word 51328 + .word 61945 + .word 60158 + .word 43127 + .word 49151 + .word 0 + .word 51733 + .word 1166 + .word 54323 + .word 42075 + .word 49152 + .word 0 + .word 52270 + .word 46964 + .word 5686 + .word 34493 + .word 49153 + .word 0 + .word 2083 + .word 1761 + .word 7136 + .word 54130 + .word 49153 + .word 0 + .word 16904 + .word 37253 + .word 64186 + .word 43390 + .word 16383 + .word 0 + .word 30519 + .word 46073 + .word 2795 + .word 46255 + .word 16383 + .word 0 + .word 6923 + .word 13957 + .word 9241 + .word 52280 + .word 16383 + .word 0 + .word 60036 + .word 4102 + .word 42534 + .word 62082 + .word 16383 + .word 0 + .word 23471 + .word 7124 + .word 59867 + .word 38328 + .word 16384 + .word 0 + .word 43652 + .word 58293 + .word 38720 + .word 48757 + .word 16384 + .word 0 + .word 30217 + .word 2002 + .word 31515 + .word 63491 + .word 16384 + .word 0 + .word 32079 + .word 61591 + .word 63175 + .word 42230 + .word 16385 + .word 0 + .word 708 + .word 13247 + .word 38402 + .word 57649 + .word 16385 + .word 0 + .word 48098 + .word 14626 + .word 62525 + .word 41069 + .word 16386 + .word 0 + .word 41824 + .word 29269 + .word 27314 + .word 64550 + .word 16386 + .word 0 + .word 61231 + .word 60847 + .word 45074 + .word 55796 + .word 16751 + .word 0 + .word 41222 + .word 6965 + .word 41751 + .word 35359 + .word 16384 + .word 0 + .word 3873 + .word 17289 + .word 23432 + .word 33549 + .word 16384 + .word 0 + .word 31267 + .word 5735 + .word 3862 + .word 59787 + .word 16383 + .word 0 + .word 54508 + .word 24423 + .word 13439 + .word 48632 + .word 16383 + .word 0 + .word 1373 + .word 13548 + .word 5598 + .word 33375 + .word 16383 + .word 0 + .word 51134 + .word 47274 + .word 24966 + .word 54404 + .word 16381 + .word 0 + .word 6577 + .word 45385 + .word 2362 + .word 45409 + .word 49149 + .word 0 + .word 3828 + .word 42112 + .word 22766 + .word 42583 + .word 49151 + .word 0 + .word 12956 + .word 14074 + .word 46709 + .word 41030 + .word 49152 + .word 0 + .word 36968 + .word 52126 + .word 60443 + .word 33467 + .word 49153 + .word 0 + .word 6923 + .word 15273 + .word 58034 + .word 52381 + .word 49153 + .word 0 + .word 32660 + .word 35575 + .word 5652 + .word 38971 + .word 16383 + .word 0 + .word 58845 + .word 37118 + .word 55534 + .word 41636 + .word 16383 + .word 0 + .word 18460 + .word 14335 + .word 18170 + .word 47252 + .word 16383 + .word 0 + .word 64257 + .word 33925 + .word 29284 + .word 56405 + .word 16383 + .word 0 + .word 4762 + .word 47478 + .word 23933 + .word 35021 + .word 16384 + .word 0 + .word 60070 + .word 43233 + .word 33997 + .word 44796 + .word 16384 + .word 0 + .word 15498 + .word 56159 + .word 37136 + .word 58624 + .word 16384 + .word 0 + .word 45618 + .word 14567 + .word 62599 + .word 39157 + .word 16385 + .word 0 + .word 56427 + .word 8703 + .word 58958 + .word 53630 + .word 16385 + .word 0 + .word 17868 + .word 58209 + .word 63399 + .word 38294 + .word 16386 + .word 0 + .word 23727 + .word 3602 + .word 56293 + .word 60260 + .word 16386 + .word 0 + .word 11566 + .word 31203 + .word 21261 + .word 41104 + .word 16856 + .word 0 + .word 50659 + .word 54826 + .word 2447 + .word 33815 + .word 16384 + .word 0 + .word 40123 + .word 27511 + .word 38472 + .word 64120 + .word 16383 + .word 0 + .word 60369 + .word 44894 + .word 35604 + .word 57033 + .word 16383 + .word 0 + .word 46499 + .word 27632 + .word 5436 + .word 46222 + .word 16383 + .word 0 + .word 30082 + .word 48277 + .word 45112 + .word 62871 + .word 16382 + .word 0 + .word 22164 + .word 19009 + .word 61576 + .word 49094 + .word 16381 + .word 0 + .word 46565 + .word 37565 + .word 23059 + .word 47623 + .word 49149 + .word 0 + .word 32180 + .word 46156 + .word 40449 + .word 42167 + .word 49151 + .word 0 + .word 43791 + .word 4543 + .word 64119 + .word 40210 + .word 49152 + .word 0 + .word 35508 + .word 36368 + .word 50300 + .word 65316 + .word 49152 + .word 0 + .word 24682 + .word 25954 + .word 24264 + .word 50994 + .word 49153 + .word 0 + .word 2360 + .word 57697 + .word 56537 + .word 35655 + .word 16383 + .word 0 + .word 35000 + .word 46863 + .word 45329 + .word 38168 + .word 16383 + .word 0 + .word 34434 + .word 1782 + .word 6514 + .word 43468 + .word 16383 + .word 0 + .word 42662 + .word 49367 + .word 10572 + .word 52120 + .word 16383 + .word 0 + .word 20865 + .word 43286 + .word 18750 + .word 65033 + .word 16383 + .word 0 + .word 9813 + .word 41323 + .word 59938 + .word 41786 + .word 16384 + .word 0 + .word 37980 + .word 55255 + .word 47419 + .word 54914 + .word 16384 + .word 0 + .word 3267 + .word 59107 + .word 21702 + .word 36808 + .word 16385 + .word 0 + .word 56442 + .word 35583 + .word 19842 + .word 50549 + .word 16385 + .word 0 + .word 14786 + .word 14705 + .word 8555 + .word 36161 + .word 16386 + .word 0 + .word 5861 + .word 33921 + .word 55110 + .word 56952 + .word 16386 + .word 0 + .word 12507 + .word 56326 + .word 38818 + .word 47266 + .word 16964 + .word 0 + .word 3472 + .word 16935 + .word 53300 + .word 65107 + .word 16383 + .word 0 + .word 37860 + .word 60441 + .word 22458 + .word 61688 + .word 16383 + .word 0 + .word 12243 + .word 56252 + .word 28016 + .word 54783 + .word 16383 + .word 0 + .word 4212 + .word 39051 + .word 42484 + .word 44250 + .word 16383 + .word 0 + .word 23380 + .word 35543 + .word 1695 + .word 59694 + .word 16382 + .word 0 + .word 16948 + .word 23513 + .word 25700 + .word 44731 + .word 16381 + .word 0 + .word 46140 + .word 40761 + .word 17956 + .word 49463 + .word 49149 + .word 0 + .word 31263 + .word 46633 + .word 29941 + .word 41835 + .word 49151 + .word 0 + .word 63205 + .word 61824 + .word 34317 + .word 39543 + .word 49152 + .word 0 + .word 2572 + .word 33857 + .word 17789 + .word 63992 + .word 49152 + .word 0 + .word 34199 + .word 18923 + .word 17606 + .word 49855 + .word 49153 + .word 0 + .word 56334 + .word 35260 + .word 24180 + .word 33058 + .word 16383 + .word 0 + .word 60689 + .word 52750 + .word 35337 + .word 35448 + .word 16383 + .word 0 + .word 55452 + .word 53681 + .word 28550 + .word 40494 + .word 16383 + .word 0 + .word 52405 + .word 7414 + .word 26290 + .word 48744 + .word 16383 + .word 0 + .word 27310 + .word 49480 + .word 17006 + .word 61076 + .word 16383 + .word 0 + .word 58002 + .word 7573 + .word 241 + .word 39403 + .word 16384 + .word 0 + .word 30618 + .word 4587 + .word 23737 + .word 51968 + .word 16384 + .word 0 + .word 41850 + .word 57331 + .word 43567 + .word 34937 + .word 16385 + .word 0 + .word 44076 + .word 54284 + .word 21386 + .word 48090 + .word 16385 + .word 0 + .word 47582 + .word 54033 + .word 55369 + .word 34454 + .word 16386 + .word 0 + .word 6559 + .word 5249 + .word 7172 + .word 54302 + .word 16386 + .word 0 + .word 25070 + .word 13550 + .word 42045 + .word 60321 + .word 17075 + .word 0 + .word 25751 + .word 29482 + .word 15881 + .word 62993 + .word 16383 + .word 0 + .word 20424 + .word 12720 + .word 54361 + .word 59648 + .word 16383 + .word 0 + .word 47709 + .word 29790 + .word 54671 + .word 52895 + .word 16383 + .word 0 + .word 19590 + .word 27782 + .word 43363 + .word 42595 + .word 16383 + .word 0 + .word 58921 + .word 35180 + .word 21269 + .word 57023 + .word 16382 + .word 0 + .word 30519 + .word 24253 + .word 59969 + .word 41055 + .word 16381 + .word 0 + .word 16433 + .word 48540 + .word 61714 + .word 51024 + .word 49149 + .word 0 + .word 28524 + .word 50460 + .word 14901 + .word 41561 + .word 49151 + .word 0 + .word 3212 + .word 32692 + .word 57818 + .word 38984 + .word 49152 + .word 0 + .word 39499 + .word 42357 + .word 61063 + .word 62879 + .word 49152 + .word 0 + .word 23069 + .word 2532 + .word 8249 + .word 48896 + .word 49153 + .word 0 + .word 10213 + .word 8193 + .word 57687 + .word 61912 + .word 16382 + .word 0 + .word 54407 + .word 51976 + .word 21399 + .word 33245 + .word 16383 + .word 0 + .word 30319 + .word 6795 + .word 56359 + .word 38081 + .word 16383 + .word 0 + .word 56783 + .word 23918 + .word 44955 + .word 45999 + .word 16383 + .word 0 + .word 48670 + .word 51841 + .word 19543 + .word 57851 + .word 16383 + .word 0 + .word 40765 + .word 30890 + .word 33317 + .word 37455 + .word 16384 + .word 0 + .word 26976 + .word 54195 + .word 64249 + .word 49555 + .word 16384 + .word 0 + .word 53450 + .word 46734 + .word 58278 + .word 33402 + .word 16385 + .word 0 + .word 16139 + .word 61138 + .word 10791 + .word 46069 + .word 16385 + .word 0 + .word 19833 + .word 46025 + .word 1951 + .word 33050 + .word 16386 + .word 0 + .word 63698 + .word 28854 + .word 16724 + .word 52116 + .word 16386 + .word 0 + .word 51628 + .word 52030 + .word 9741 + .word 32928 + .word 17190 + .word 0 + .word 12285 + .word 10951 + .word 58642 + .word 61183 + .word 16383 + .word 0 + .word 21683 + .word 21165 + .word 28859 + .word 57903 + .word 16383 + .word 0 + .word 16106 + .word 65177 + .word 61473 + .word 51279 + .word 16383 + .word 0 + .word 10066 + .word 60251 + .word 8712 + .word 41178 + .word 16383 + .word 0 + .word 11765 + .word 63661 + .word 54012 + .word 54733 + .word 16382 + .word 0 + .word 6745 + .word 52609 + .word 60525 + .word 37899 + .word 16381 + .word 0 + .word 48001 + .word 64846 + .word 20212 + .word 52373 + .word 49149 + .word 0 + .word 17748 + .word 43200 + .word 11817 + .word 41329 + .word 49151 + .word 0 + .word 21018 + .word 45635 + .word 21983 + .word 38507 + .word 49152 + .word 0 + .word 3148 + .word 52957 + .word 41657 + .word 61926 + .word 49152 + .word 0 + .word 4827 + .word 784 + .word 31692 + .word 48072 + .word 49153 + .word 0 + .word 34179 + .word 53889 + .word 29926 + .word 58425 + .word 16382 + .word 0 + .word 50615 + .word 27492 + .word 10833 + .word 62832 + .word 16382 + .word 0 + .word 38001 + .word 13025 + .word 51995 + .word 36075 + .word 16383 + .word 0 + .word 57519 + .word 47991 + .word 3845 + .word 43713 + .word 16383 + .word 0 + .word 52312 + .word 45573 + .word 61386 + .word 55158 + .word 16383 + .word 0 + .word 13085 + .word 59531 + .word 16529 + .word 35826 + .word 16384 + .word 0 + .word 20993 + .word 34790 + .word 57361 + .word 47533 + .word 16384 + .word 0 + .word 9726 + .word 28278 + .word 20623 + .word 64228 + .word 16384 + .word 0 + .word 29543 + .word 44397 + .word 26216 + .word 44369 + .word 16385 + .word 0 + .word 63031 + .word 4436 + .word 65303 + .word 63733 + .word 16385 + .word 0 + .word 3202 + .word 26777 + .word 12818 + .word 50273 + .word 16386 + .word 0 + .word 59134 + .word 17584 + .word 37875 + .word 50102 + .word 17306 + .word 0 + .word 7773 + .word 6529 + .word 24897 + .word 59610 + .word 16383 + .word 0 + .word 9176 + .word 34994 + .word 24066 + .word 56385 + .word 16383 + .word 0 + .word 38670 + .word 17644 + .word 9278 + .word 49874 + .word 16383 + .word 0 + .word 31722 + .word 46384 + .word 26212 + .word 39944 + .word 16383 + .word 0 + .word 4438 + .word 35654 + .word 55200 + .word 52739 + .word 16382 + .word 0 + .word 27356 + .word 43702 + .word 58298 + .word 35147 + .word 16381 + .word 0 + .word 11597 + .word 6768 + .word 60887 + .word 53553 + .word 49149 + .word 0 + .word 2200 + .word 56289 + .word 1997 + .word 41129 + .word 49151 + .word 0 + .word 51208 + .word 51045 + .word 15577 + .word 38092 + .word 49152 + .word 0 + .word 64525 + .word 30741 + .word 24355 + .word 61096 + .word 49152 + .word 0 + .word 16273 + .word 9188 + .word 1200 + .word 47354 + .word 49153 + .word 0 + .word 32505 + .word 64701 + .word 51161 + .word 55474 + .word 16382 + .word 0 + .word 58255 + .word 43751 + .word 28307 + .word 59734 + .word 16382 + .word 0 + .word 597 + .word 44015 + .word 59274 + .word 34374 + .word 16383 + .word 0 + .word 17221 + .word 11824 + .word 60854 + .word 41770 + .word 16383 + .word 0 + .word 32240 + .word 33006 + .word 58370 + .word 52867 + .word 16383 + .word 0 + .word 22765 + .word 17058 + .word 17899 + .word 34437 + .word 16384 + .word 0 + .word 3694 + .word 59578 + .word 1196 + .word 45807 + .word 16384 + .word 0 + .word 37424 + .word 8934 + .word 53804 + .word 62023 + .word 16384 + .word 0 + .word 6800 + .word 58264 + .word 43923 + .word 42913 + .word 16385 + .word 0 + .word 27007 + .word 15916 + .word 20851 + .word 61705 + .word 16385 + .word 0 + .word 33570 + .word 44306 + .word 22975 + .word 48691 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _tgamma_A_table,@object + .size _tgamma_A_table,3312 + .align 2 +_tgamma_A176_inv: + .word 38655 + .word 8470 + .word 22633 + .word 47709 + .word 15340 + .word 0 + .type _tgamma_A176_inv,@object + .size _tgamma_A176_inv,12 + .align 2 +_tgamma_A150_table: + .word 61060 + .word 8155 + .word 61816 + .word 65535 + .word 16382 + .word 0 + .word 47752 + .word 30749 + .word 4057 + .word 37827 + .word 49150 + .word 0 + .word 24760 + .word 16820 + .word 52631 + .word 64803 + .word 16382 + .word 0 + .word 36324 + .word 24890 + .word 11532 + .word 59368 + .word 49150 + .word 0 + .word 63381 + .word 49585 + .word 20519 + .word 63827 + .word 16382 + .word 0 + .word 54086 + .word 22318 + .word 4776 + .word 62483 + .word 49150 + .word 0 + .word 24236 + .word 16506 + .word 21666 + .word 59746 + .word 16382 + .word 0 + .word 44402 + .word 44414 + .word 37650 + .word 53079 + .word 49150 + .word 0 + .word 34766 + .word 8695 + .word 24359 + .word 42592 + .word 16382 + .word 0 + .word 30542 + .word 64415 + .word 14059 + .word 59378 + .word 49149 + .word 0 + .word 36037 + .word 62568 + .word 21045 + .word 34628 + .word 16381 + .word 0 + .word 39650 + .word 28877 + .word 62299 + .word 64900 + .word 49147 + .word 0 + .word 43413 + .word 4175 + .word 59877 + .word 46549 + .word 16378 + .word 0 + .word 13603 + .word 64648 + .word 43425 + .word 47701 + .word 49144 + .word 0 + .word 48047 + .word 22044 + .word 23868 + .word 61943 + .word 16373 + .word 0 + .word 17548 + .word 29243 + .word 63955 + .word 38195 + .word 49138 + .word 0 + .type _tgamma_A150_table,@object + .size _tgamma_A150_table,192 + .align 2 +_local_minimum_l: + .word 64512 + .word 46577 + .word 49946 + .word 47894 + .word 16383 + .word 0 + .type _local_minimum_l,@object + .size _local_minimum_l,12 + .align 2 +_tgamma_A125_table: + .word 29804 + .word 14935 + .word 58389 + .word 58038 + .word 16382 + .word 0 + .word 54039 + .word 49353 + .word 64455 + .word 62712 + .word 16326 + .word 0 + .word 7246 + .word 48092 + .word 40889 + .word 56162 + .word 16381 + .word 0 + .word 5238 + .word 25576 + .word 20384 + .word 34263 + .word 49148 + .word 0 + .word 38009 + .word 2645 + .word 35759 + .word 42176 + .word 16380 + .word 0 + .word 32410 + .word 34387 + .word 48471 + .word 48379 + .word 49147 + .word 0 + .word 9060 + .word 33571 + .word 56968 + .word 36683 + .word 16379 + .word 0 + .word 26873 + .word 9749 + .word 59107 + .word 49208 + .word 49146 + .word 0 + .word 61297 + .word 63742 + .word 25286 + .word 34210 + .word 16378 + .word 0 + .word 6011 + .word 50033 + .word 7349 + .word 46841 + .word 49145 + .word 0 + .word 30597 + .word 45929 + .word 271 + .word 64276 + .word 16376 + .word 0 + .word 60120 + .word 8046 + .word 54753 + .word 44175 + .word 49144 + .word 0 + .word 32461 + .word 45691 + .word 56111 + .word 58214 + .word 16375 + .word 0 + .word 38908 + .word 23877 + .word 33636 + .word 50495 + .word 49143 + .word 0 + .word 35983 + .word 59115 + .word 59685 + .word 60013 + .word 16371 + .word 0 + .word 38519 + .word 97 + .word 2340 + .word 53304 + .word 49143 + .word 0 + .type _tgamma_A125_table,@object + .size _tgamma_A125_table,192 + .align 2 +_tgamma_A100_table: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 50486 + .word 32176 + .word 26595 + .word 37828 + .word 49150 + .word 0 + .word 33232 + .word 55464 + .word 50705 + .word 64818 + .word 16382 + .word 0 + .word 56000 + .word 37024 + .word 35961 + .word 59472 + .word 49150 + .word 0 + .word 6308 + .word 2395 + .word 34858 + .word 64338 + .word 16382 + .word 0 + .word 22779 + .word 60710 + .word 1868 + .word 64356 + .word 49150 + .word 0 + .word 33054 + .word 60854 + .word 741 + .word 65087 + .word 16382 + .word 0 + .word 46387 + .word 11445 + .word 51950 + .word 65273 + .word 49150 + .word 0 + .word 6735 + .word 17127 + .word 21437 + .word 65409 + .word 16382 + .word 0 + .word 40596 + .word 22792 + .word 61241 + .word 65445 + .word 49150 + .word 0 + .word 7521 + .word 26365 + .word 15230 + .word 65303 + .word 16382 + .word 0 + .word 33891 + .word 37638 + .word 54039 + .word 64371 + .word 49150 + .word 0 + .word 37411 + .word 53884 + .word 56799 + .word 60663 + .word 16382 + .word 0 + .word 30408 + .word 30767 + .word 55068 + .word 50398 + .word 49150 + .word 0 + .word 49794 + .word 38369 + .word 16703 + .word 62901 + .word 16381 + .word 0 + .word 52540 + .word 1662 + .word 21259 + .word 41989 + .word 49148 + .word 0 + .type _tgamma_A100_table,@object + .size _tgamma_A100_table,192 + .data + .hidden fesetround + .hidden fegetround + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tgammaf.S b/external/sgx_libm/ia32/tgammaf.S new file mode 100644 index 0000000000..e057b83ee4 --- /dev/null +++ b/external/sgx_libm/ia32/tgammaf.S @@ -0,0 +1,1018 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tgammaf.c" + .text +..TXTST0: +# -- Begin tgammaf + .text + .align 16,0x90 + .globl tgammaf +tgammaf: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $36, %esp + movl 8(%ebp), %edi + call fegetround +..B1.96: + movl %eax, 32(%esp) +..B1.2: + cmpl $0, 32(%esp) + jne ..B1.4 +..B1.3: + xorl %ecx, %ecx + jmp ..B1.6 +..B1.4: + addl $4, %esp + pushl $0 + call fesetround +..B1.5: + movl $1, %ecx +..B1.6: + movzwl 10(%ebp), %edx + andl $32640, %edx + shrl $7, %edx + movl 8(%ebp), %esi + shrl $31, %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $255, %edx + je ..B1.88 +..B1.7: + flds 8(%ebp) + fldz + andl $2147483647, %edi + fucom %st(1) + fnstsw %ax + movl %edi, 20(%esp) + sahf + jp ..B1.8 + je ..B1.85 +..B1.8: + cmpl $2097152, %edi + jle ..B1.82 +..B1.9: + testl %esi, %esi + je ..B1.18 +..B1.10: + cmpl $150, %edx + jge ..B1.76 +..B1.11: + flds .L_2il0floatpacket.2@GOTOFF(%ebx) + flds 20(%esp) + fld %st(0) + fadd %st(2), %st + fstps 24(%esp) + flds 24(%esp) + movl 24(%esp), %edi + fsubp %st, %st(2) + movl %edi, 16(%esp) + fcom %st(1) + fnstsw %ax + sahf + jae ..B1.13 + jp ..B1.13 +..B1.12: + fld1 + incl 16(%esp) + fsubrp %st, %st(2) +..B1.13: + fucompp + fnstsw %ax + sahf + jp ..B1.14 + je ..B1.73 +..B1.14: + flds .L_2il0floatpacket.3@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B1.18 +..B1.15: + fstp %st(0) + fstp %st(0) + testl %ecx, %ecx + je ..B1.17 +..B1.16: + addl $4, %esp + pushl 28(%esp) + call fesetround +..B1.17: + movl 16(%esp), %eax + notl %eax + andl $1, %eax + flds _small_value_32@GOTOFF(%ebx,%eax,4) + fmuls .L_2il0floatpacket.5@GOTOFF(%ebx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + fxch %st(1) + fcompl _overflow_boundary@GOTOFF(%ebx) + fnstsw %ax + sahf + jae ..B1.79 +..B1.19: + flds .L_2il0floatpacket.2@GOTOFF(%ebx) + testl %esi, %esi + je ..B1.21 +..B1.20: + fstp %st(1) + flds 20(%esp) + fld %st(1) + fadd %st(1), %st + fstps 24(%esp) + flds 24(%esp) + fsub %st(2), %st + fsubr %st(1), %st + fabs + fld %st(0) + fmul %st(1), %st + fldl 8+_tgamma_sin_table@GOTOFF(%ebx) + fmul %st(1), %st + fldl 24+_tgamma_sin_table@GOTOFF(%ebx) + fadd %st(2), %st + fmul %st(2), %st + fxch %st(1) + faddl _tgamma_sin_table@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 16+_tgamma_sin_table@GOTOFF(%ebx) + fmulp %st, %st(1) + fldl 40+_tgamma_sin_table@GOTOFF(%ebx) + fadd %st(2), %st + fmul %st(2), %st + fldl 56+_tgamma_sin_table@GOTOFF(%ebx) + fadd %st(3), %st + fmulp %st, %st(3) + faddl 32+_tgamma_sin_table@GOTOFF(%ebx) + fmulp %st, %st(1) + fxch %st(1) + faddl 48+_tgamma_sin_table@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(1), %st + fadd %st(1), %st + fxch %st(3) + fxch %st(2) + fxch %st(1) + jmp ..B1.22 +..B1.21: + flds 20(%esp) + fld %st(2) +..B1.22: + fld %st(1) + fxch %st(2) + fadd %st(3), %st + fstps 24(%esp) + flds 24(%esp) + movl 24(%esp), %edi + fsubp %st, %st(3) + andl $1048575, %edi + fxch %st(2) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B1.97 +..B1.23: + fld1 + decl %edi + fsubr %st, %st(1) +..B1.24: + lea 1(%edi), %eax + andl $1, %eax + movl %eax, 28(%esp) + fxch %st(2) + fcoms .L_2il0floatpacket.4@GOTOFF(%ebx) + fnstsw %ax + sahf + jb ..B1.41 +..B1.25: + fstp %st(3) + movl %edi, %eax + fsubr %st(2), %st + movl %esi, 16(%esp) + andl $-8, %eax + movl %edi, %esi + fld %st(0) + andl $7, %esi + cmpl $8, %edi + movl %eax, %edi + fmul %st(1), %st + lea -2(%esi), %edx + jl ..L3 + movl %esi, %edx +..L3: + sarl $1, %edi + addl %eax, %edi + sarl $3, %eax + addl %eax, %edi + movl 16(%esp), %esi + testl %edx, %edx + fldl _tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmul %st(2), %st + fadd %st(1), %st + fldl 8+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmul %st(3), %st + fadd %st(2), %st + fldl 16+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmul %st(4), %st + fadd %st(3), %st + fxch %st(2) + faddl 48+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fxch %st(1) + faddl 56+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fxch %st(2) + faddl 64+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fxch %st(1) + fmull 96+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmulp %st, %st(2) + fmulp %st, %st(1) + fldl 32+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmul %st(3), %st + fadd %st(2), %st + fldl 24+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmul %st(4), %st + fadd %st(3), %st + fxch %st(1) + faddl 80+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fxch %st(1) + faddl 72+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmulp %st, %st(2) + fmulp %st, %st(1) + fldl 40+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddl 88+_tgamma_A_table@GOTOFF(%ebx,%edi,8) + fmulp %st, %st(1) + je ..B1.30 +..B1.26: + fld %st(1) + jle ..B1.31 +..B1.27: + movl $1, %eax +..B1.28: + movl %eax, 16(%esp) + incl %eax + fildl 16(%esp) + cmpl %edx, %eax + fsubr %st(4), %st + fmulp %st, %st(1) + jle ..B1.28 + jmp ..B1.31 +..B1.30: + fld %st(1) +..B1.31: + testl %esi, %esi + je ..B1.38 +..B1.32: + fxch %st(4) + fmulp %st, %st(3) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fdivrp %st, %st(1) + flds .L_2il0floatpacket.7@GOTOFF(%ebx) + fcomps 8(%ebp) + fnstsw %ax + sahf + jbe ..B1.34 +..B1.33: + fldt _tgamma_A40_inv@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.34: + testl %ecx, %ecx + je ..B1.36 +..B1.35: + addl $4, %esp + pushl 28(%esp) + fstpl 16(%esp) + call fesetround +..B1.103: + fldl 16(%esp) +..B1.36: + cmpl $0, 28(%esp) + je ..B1.40 +..B1.37: + fchs + jmp ..B1.40 +..B1.38: + fstp %st(4) + fstp %st(2) + fstp %st(0) + testl %ecx, %ecx + fmulp %st, %st(1) + je ..B1.40 +..B1.39: + addl $4, %esp + pushl 28(%esp) + fstpl 16(%esp) + call fesetround +..B1.102: + fldl 16(%esp) +..B1.40: + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.41: + fstp %st(1) + fcom %st(1) + fnstsw %ax + sahf + jae ..B1.43 + jp ..B1.43 +..B1.42: + fld %st(0) + fadd %st(2), %st + jmp ..B1.44 +..B1.43: + fld %st(0) +..B1.44: + fcoml .L_2il0floatpacket.6@GOTOFF(%ebx) + fnstsw %ax + sahf + jb ..B1.46 +..B1.45: + fstp %st(3) + lea _tgamma_A175_table@GOTOFF(%ebx), %eax + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + jmp ..B1.53 +..B1.46: + fcoml .L_2il0floatpacket.8@GOTOFF(%ebx) + fnstsw %ax + sahf + jb ..B1.48 +..B1.47: + fstp %st(3) + lea _tgamma_A150_table@GOTOFF(%ebx), %eax + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + jmp ..B1.53 +..B1.48: + fldl .L_2il0floatpacket.9@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + ja ..B1.50 + jp ..B1.50 +..B1.49: + fstp %st(0) + fstp %st(3) + fld %st(1) + lea _tgamma_A125_table@GOTOFF(%ebx), %eax + faddl _local_minimum@GOTOFF(%ebx) + fsubrp %st, %st(3) + jmp ..B1.53 +..B1.50: + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.52 +..B1.51: + fstp %st(3) + lea _tgamma_A100_table@GOTOFF(%ebx), %eax + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + jmp ..B1.53 +..B1.52: + fstp %st(0) +..B1.53: + fldl (%eax) + testl %edx, %edx + je ..B1.55 +..B1.54: + fldl 56(%eax) + fmul %st(4), %st + faddl 48(%eax) + fmul %st(4), %st + faddl 40(%eax) + fmul %st(4), %st + faddl 32(%eax) + fmul %st(4), %st + faddl 24(%eax) + fmul %st(4), %st + faddl 16(%eax) + fmul %st(4), %st + faddl 8(%eax) + fmulp %st, %st(4) + faddp %st, %st(3) + jmp ..B1.56 +..B1.55: + fstp %st(3) +..B1.56: + fcom %st(1) + fnstsw %ax + sahf + jae ..B1.65 + jp ..B1.65 +..B1.57: + testl %esi, %esi + je ..B1.62 +..B1.58: + fstp %st(0) + fxch %st(1) + fmulp %st, %st(2) + fdivp %st, %st(1) + testl %ecx, %ecx + je ..B1.60 +..B1.59: + addl $4, %esp + pushl 28(%esp) + fstpl 16(%esp) + call fesetround +..B1.101: + fldl 16(%esp) +..B1.60: + cmpl $0, 28(%esp) + je ..B1.72 +..B1.61: + fchs + jmp ..B1.72 +..B1.62: + fstp %st(3) + fstp %st(0) + fdivp %st, %st(1) + testl %ecx, %ecx + jne ..B1.70 + jmp ..B1.72 +..B1.65: + testl %esi, %esi + je ..B1.69 +..B1.66: + fmulp %st, %st(3) + testl %ecx, %ecx + fxch %st(1) + fmulp %st, %st(2) + fdivp %st, %st(1) + jne ..B1.70 + jmp ..B1.72 +..B1.69: + fstp %st(3) + fstp %st(2) + fstp %st(1) + testl %ecx, %ecx + je ..B1.72 +..B1.70: + addl $4, %esp + pushl 28(%esp) + fstpl 16(%esp) + call fesetround +..B1.98: + fldl 16(%esp) +..B1.72: + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.73: + fstp %st(1) + testl %ecx, %ecx + je ..B1.75 +..B1.74: + addl $4, %esp + pushl 28(%esp) + fstpl 16(%esp) + call fesetround +..B1.106: + fldl 16(%esp) +..B1.75: + fdiv %st(0), %st + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.76: + fstp %st(1) + testl %ecx, %ecx + je ..B1.78 +..B1.77: + addl $4, %esp + pushl 28(%esp) + fstpl 16(%esp) + call fesetround +..B1.105: + fldl 16(%esp) +..B1.78: + fdiv %st(0), %st + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.79: + fstp %st(0) + testl %ecx, %ecx + je ..B1.81 +..B1.80: + addl $4, %esp + pushl 28(%esp) + call fesetround +..B1.81: + flds .L_2il0floatpacket.0@GOTOFF(%ebx) + fmul %st(0), %st + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.82: + fstp %st(0) + fstp %st(0) + testl %ecx, %ecx + je ..B1.84 +..B1.83: + addl $4, %esp + pushl 28(%esp) + call fesetround +..B1.84: + flds _large_value_32@GOTOFF(%ebx,%esi,4) + fmuls .L_2il0floatpacket.0@GOTOFF(%ebx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.85: + fstp %st(1) + testl %ecx, %ecx + je ..B1.87 +..B1.86: + addl $4, %esp + pushl 28(%esp) + fstpl 16(%esp) + call fesetround +..B1.104: + fldl 16(%esp) +..B1.87: + fdivrs _ones@GOTOFF(%ebx,%esi,4) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.88: + testl %ecx, %ecx + je ..B1.90 +..B1.89: + addl $4, %esp + pushl 28(%esp) + call fesetround +..B1.90: + testl %esi, %esi + je ..B1.92 +..B1.91: + testl $8388607, 8(%ebp) + je ..B1.93 +..B1.92: + flds 8(%ebp) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.93: + fldz + fdivrs .L_2il0floatpacket.1@GOTOFF(%ebx) + addl $36, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.97: + fld1 + jmp ..B1.24 + .align 16,0x90 + .type tgammaf,@function + .size tgammaf,.-tgammaf + .data +# -- End tgammaf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.6: + .long 0x00000000,0x3ffc0000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3ff80000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3ff40000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x71800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x80000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x4b400000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0xc22c0000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +.L_2il0floatpacket.4: + .long 0x40000000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .align 4 +.L_2il0floatpacket.5: + .long 0x0d800000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,4 + .align 4 +.L_2il0floatpacket.7: + .long 0xc2200000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_overflow_boundary: + .long 0 + .long 1078035746 + .type _overflow_boundary,@object + .size _overflow_boundary,8 + .align 4 +_tgamma_sin_table: + .long 1980114658 + .long 3200337074 + .long 804494867 + .long 1049689241 + .long 2884431818 + .long 1079329239 + .long 930502348 + .long 3223780109 + .long 1245824743 + .long 1080878479 + .long 2510431012 + .long 1073721695 + .long 1661126174 + .long 1078219640 + .long 1205599443 + .long 3223573914 + .type _tgamma_sin_table,@object + .size _tgamma_sin_table,64 + .align 4 +_tgamma_A_table: + .long 3121394612 + .long 1074393041 + .long 2029996066 + .long 1073722195 + .long 4137005464 + .long 1071238760 + .long 3372276227 + .long 3220751114 + .long 68401302 + .long 3222286887 + .long 1275947047 + .long 3223263002 + .long 4031994882 + .long 1074665426 + .long 1089993416 + .long 1074817170 + .long 427005612 + .long 1075089294 + .long 1508975772 + .long 1075601433 + .long 2111623053 + .long 1076192020 + .long 75538972 + .long 1077100653 + .long 2171869559 + .long 1055005400 + .long 2919987515 + .long 1074143787 + .long 860307162 + .long 1073890599 + .long 2407232453 + .long 1073038722 + .long 1468490975 + .long 3216757264 + .long 846192051 + .long 3221294835 + .long 402234383 + .long 3222573752 + .long 2566208764 + .long 1073763360 + .long 162360449 + .long 1073949715 + .long 1512348533 + .long 1074371728 + .long 2920174397 + .long 1074968946 + .long 3785085665 + .long 1075671857 + .long 1922428759 + .long 1076496000 + .long 2446382284 + .long 1072101083 + .long 42366358 + .long 1073746704 + .long 3587290866 + .long 1073390434 + .long 1169958761 + .long 1072607731 + .long 3891474799 + .long 3217275878 + .long 1452792685 + .long 3221010072 + .long 1006385979 + .long 3222363118 + .long 3663632771 + .long 1072778759 + .long 3212960448 + .long 1073036150 + .long 2202365811 + .long 1073636095 + .long 2023822532 + .long 1074258740 + .long 40477660 + .long 1075053854 + .long 658935515 + .long 1076010306 + .long 932572503 + .long 1105834679 + .long 1233355998 + .long 1073412029 + .long 3033646034 + .long 1073097432 + .long 3149182759 + .long 1072206908 + .long 1726027606 + .long 3217766868 + .long 3439348786 + .long 3220880557 + .long 2080997065 + .long 3222253033 + .long 843307201 + .long 1072200111 + .long 3138702878 + .long 1072613342 + .long 3610734718 + .long 1073142430 + .long 2651617324 + .long 1073914526 + .long 2611481547 + .long 1074796471 + .long 3284459136 + .long 1075745821 + .long 1365755587 + .long 1144167771 + .long 2699624028 + .long 1073212595 + .long 2232824171 + .long 1072922970 + .long 3659224963 + .long 1071959670 + .long 3026238542 + .long 3218100813 + .long 4240441539 + .long 3220810712 + .long 1772362075 + .long 3222132889 + .long 3742687744 + .long 1071863890 + .long 56227394 + .long 1072220001 + .long 969667939 + .long 1072882737 + .long 880059910 + .long 1073714908 + .long 247554419 + .long 1074515829 + .long 48918556 + .long 1075495246 + .long 2601377264 + .long 1185936586 + .long 3625529495 + .long 1073077476 + .long 3298250746 + .long 1072804056 + .long 2971501690 + .long 1071788510 + .long 2950162741 + .long 3218231788 + .long 26528490 + .long 3220765509 + .long 3761284804 + .long 3222050392 + .long 3800626879 + .long 1071658634 + .long 1108715276 + .long 1071977390 + .long 286829382 + .long 1072720005 + .long 3141975933 + .long 1073477575 + .long 4145290123 + .long 1074329952 + .long 2167683451 + .long 1075329952 + .long 0 + .long 1072693248 + .type _tgamma_A_table,@object + .size _tgamma_A_table,624 + .align 4 +_tgamma_A175_table: + .long 1682645026 + .long 1072688670 + .long 3753006229 + .long 3219243438 + .long 177700005 + .long 1072453288 + .long 3289039035 + .long 3219374666 + .long 2492560830 + .long 1071326765 + .long 123078934 + .long 3217486055 + .long 3499570675 + .long 1068068407 + .long 1362583934 + .long 3212265128 + .type _tgamma_A175_table,@object + .size _tgamma_A175_table,64 + .align 4 +_tgamma_A150_table: + .long 988281800 + .long 1072692321 + .long 502740408 + .long 3219277207 + .long 2058512241 + .long 1072588117 + .long 2109547492 + .long 3219675970 + .long 3371209031 + .long 1071892748 + .long 3191518250 + .long 3218447665 + .long 3816909947 + .long 1069498883 + .long 1366906983 + .long 3214177035 + .type _tgamma_A150_table,@object + .size _tgamma_A150_table,64 + .align 4 +_tgamma_A125_table: + .long 2191760034 + .long 1072453340 + .long 2642694891 + .long 3186525859 + .long 1706815263 + .long 1071344724 + .long 1896485049 + .long 3217079006 + .long 441733475 + .long 1069848224 + .long 978611902 + .long 3216500728 + .long 351495825 + .long 1068442485 + .long 1680249708 + .long 3216253219 + .type _tgamma_A125_table,@object + .size _tgamma_A125_table,64 + .align 4 +_local_minimum: + .long 2371549438 + .long 1071483745 + .type _local_minimum,@object + .size _local_minimum,8 + .align 4 +_tgamma_A100_table: + .long 4293468318 + .long 1072693247 + .long 3444857508 + .long 3219290252 + .long 3510931740 + .long 1072670280 + .long 3644082616 + .long 3219982336 + .long 2685454907 + .long 1072646231 + .long 4151446349 + .long 3220059936 + .long 4004008463 + .long 1072263166 + .long 1217534056 + .long 3218706582 + .type _tgamma_A100_table,@object + .size _tgamma_A100_table,64 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 2 +_tgamma_A40_inv: + .word 64725 + .word 58913 + .word 22381 + .word 51879 + .word 16232 + .word 0 + .type _tgamma_A40_inv,@object + .size _tgamma_A40_inv,12 + .data + .hidden fesetround + .hidden fegetround + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/tgammal.S b/external/sgx_libm/ia32/tgammal.S new file mode 100644 index 0000000000..11cb8a5ab1 --- /dev/null +++ b/external/sgx_libm/ia32/tgammal.S @@ -0,0 +1,3738 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tgammal.c" + .text +..TXTST0: +# -- Begin tgammal + .text + .align 16,0x90 + .globl tgammal +tgammal: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $308, %esp + fldt 8(%ebp) + movl %gs:20, %eax + xorl %esp, %eax + movl %eax, 248(%esp) + fstpt 212(%esp) +..B1.2: + fnstcw 150(%esp) +..B1.3: + movzwl 150(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.195 +..B1.4: + orl $-64768, %edx + movw %dx, 148(%esp) +..B1.5: + fldcw 148(%esp) +..B1.6: + movl $1, %esi +..B1.7: + call fegetround +..B1.198: + movl %eax, 116(%esp) +..B1.8: + cmpl $0, 116(%esp) + jne ..B1.10 +..B1.9: + xorl %edi, %edi + jmp ..B1.12 +..B1.10: + addl $-16, %esp + movl $0, (%esp) + call fesetround +..B1.199: + addl $16, %esp +..B1.11: + movl $1, %edi +..B1.12: + movl 16(%ebp), %eax + movzwl 16(%ebp), %ecx + shrl $15, %eax + andl $32767, %ecx + andl $1, %eax + movl %eax, 132(%esp) + cmpl $32767, %ecx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + je ..B1.180 +..B1.13: + fldt 8(%ebp) + andl $32767, 220(%esp) + fldl _zeros@GOTOFF(%ebx) + fucom %st(1) + fnstsw %ax + sahf + jp ..B1.14 + je ..B1.173 +..B1.14: + cmpl $0, 132(%esp) + je ..B1.27 +..B1.15: + cmpl $16446, %ecx + jge ..B1.143 +..B1.16: + fldt 212(%esp) + fld %st(0) + fldl _TWO_63H@GOTOFF(%ebx) + fadd %st, %st(1) + fxch %st(1) + fstpt 92(%esp) + fldt 92(%esp) + fsubp %st, %st(1) + movl 92(%esp), %edx + fcom %st(1) + fnstsw %ax + movl %edx, 36(%esp) + sahf + jbe ..B1.18 +..B1.17: + incl 36(%esp) + fsubl _ones@GOTOFF(%ebx) +..B1.18: + fucompp + fnstsw %ax + sahf + jp ..B1.19 + je ..B1.136 +..B1.19: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B1.27 +..B1.20: + fstp %st(0) + fstp %st(0) + testl %edi, %edi + je ..B1.22 +..B1.21: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.200: + addl $16, %esp +..B1.22: + fldt _small_value_80@GOTOFF(%ebx) + movl 36(%esp), %edx + notl %edx + andl $1, %edx + testl %esi, %esi + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fldt _small_value_80@GOTOFF(%ebx,%ecx) + fmulp %st, %st(1) + fstpt 64(%esp) + je ..B1.24 +..B1.23: + fldcw 150(%esp) +..B1.24: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.25: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.27: + fldt _POS_OVERFLOW@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + fxch %st(1) + fstp %st(0) + sahf + jp ..B1.28 + jb ..B1.166 +..B1.28: + testl %ecx, %ecx + je ..B1.156 +..B1.29: + fldt 212(%esp) + fld %st(1) + fxch %st(1) + fstpt 152(%esp) + fldt 152(%esp) + fstpt 168(%esp) + fldt 168(%esp) + fxch %st(2) + fstpt 136(%esp) + fldt 136(%esp) + cmpl $0, 132(%esp) + je ..B1.33 +..B1.30: + fldl _TWO_63H@GOTOFF(%ebx) + cmpl $16299, %ecx + jle ..B1.32 +..B1.31: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fxch %st(3) + fstpt 24(%esp) + fld %st(3) + fadd %st(1), %st + fsub %st(1), %st + fsubr %st(4), %st + fstpt 52(%esp) + andl $32767, 60(%esp) + fstpt 40(%esp) + fstpt 80(%esp) + fxch %st(1) + fstpt 64(%esp) + fldt 64(%esp) + fldt 52(%esp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + fchs + fsubrp %st, %st(3) + fld %st(2) + fld %st(1) + fsub %st(4), %st + fmul %st, %st(1) + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(4) + fmul %st(5), %st + fxch %st(3) + fstpt (%esp) + fld %st(2) + fldl _TWO_53H@GOTOFF(%ebx) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fld %st(4) + fmul %st(1), %st + fld %st(5) + fadd %st(1), %st + fsubp %st, %st(1) + fstpt 152(%esp) + fldt 152(%esp) + fsubrp %st, %st(5) + fxch %st(4) + fstpt 136(%esp) + fldt 72+_tgammal_S@GOTOFF(%ebx) + fmul %st(1), %st + fldt 60+_tgammal_S@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_tgammal_S@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 36+_tgammal_S@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 24+_tgammal_S@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 12+_tgammal_S@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt _tgammal_S@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldl _tgammal_S2@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + faddl 8+_tgammal_S2@GOTOFF(%ebx) + fld %st(0) + fmul %st(4), %st + faddp %st, %st(3) + fmul %st(4), %st + faddp %st, %st(2) + fldl 8+_tgammal_S1@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldl _tgammal_S1@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(4) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fmul %st(3), %st + fld %st(2) + fmul %st(5), %st + fxch %st(4) + fmulp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(2) + fldl _ones@GOTOFF(%ebx) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fmul %st(7), %st + fmul %st, %st(6) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fmul %st, %st(4) + fldt (%esp) + fld %st(0) + fmulp %st, %st(2) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(3) + fld %st(2) + fxch %st(2) + fstpt 184(%esp) + fldt 184(%esp) + fxch %st(3) + fstpt 200(%esp) + fldt 200(%esp) + fldt 152(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpt 104(%esp) + fmulp %st, %st(1) + fldt 136(%esp) + fmul %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 120(%esp) + fldt 80(%esp) + fldt 24(%esp) + fldt 40(%esp) + fldt 64(%esp) + fxch %st(3) + fxch %st(1) + jmp ..B1.34 +..B1.32: + fldt 168(%esp) + fstpt 184(%esp) + fxch %st(1) + fstpt 104(%esp) + fldt 104(%esp) + fxch %st(2) + fstpt 200(%esp) + fld %st(1) + fxch %st(2) + fstpt 120(%esp) + fldt 120(%esp) + fxch %st(1) + jmp ..B1.34 +..B1.33: + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + fstpt 120(%esp) + fldt 120(%esp) + fstpt 104(%esp) + fldt 104(%esp) + fstpt 200(%esp) + fldt 200(%esp) + fstpt 184(%esp) + fldl _TWO_63H@GOTOFF(%ebx) +..B1.34: + fldt .L_2il0floatpacket.3@GOTOFF(%ebx) + fcomp %st(4) + fnstsw %ax + sahf + jp ..B1.35 + jbe ..B1.96 +..B1.35: + fld %st(3) + fadd %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fsubp %st, %st(1) + movl 92(%esp), %edx + fcom %st(3) + fnstsw %ax + sahf + jbe ..B1.37 +..B1.36: + decl %edx + fsubl _ones@GOTOFF(%ebx) +..B1.37: + cmpl $2, %edx + lea 1(%edx), %eax + movl %eax, 76(%esp) + jl ..B1.42 +..B1.38: + testb $1, %dl + je ..B1.40 +..B1.39: + fldl _ones@GOTOFF(%ebx) + lea -1(%edx), %eax + movl %eax, (%esp) + fsubr %st, %st(4) + fxch %st(4) + fstpt 168(%esp) + fsubp %st, %st(3) + jmp ..B1.41 +..B1.40: + fstp %st(3) + movl %edx, (%esp) +..B1.41: + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + movl (%esp), %eax + faddp %st, %st(3) + fldt 168(%esp) + addl $-2, %eax + sarl $1, %eax + movl %edi, 40(%esp) + fsubp %st, %st(3) + imull $180, %eax, %edi + lea (%eax,%eax,2), %eax + shll $5, %eax + lea _tgammal_T2@GOTOFF(%ebx,%edi), %edi + movl %edi, 36(%esp) + movl 40(%esp), %edi + lea _tgammal_A2@GOTOFF(%ebx,%eax), %eax + jmp ..B1.56 +..B1.42: + fstp %st(0) + fldt .L_2il0floatpacket.5@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B1.44 +..B1.43: + movl $3, (%esp) + jmp ..B1.55 +..B1.44: + fldt .L_2il0floatpacket.7@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B1.46 +..B1.45: + movl $0, (%esp) + jmp ..B1.55 +..B1.46: + fldt .L_2il0floatpacket.8@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B1.48 +..B1.47: + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + movl $1, (%esp) + fsubrp %st, %st(3) + jmp ..B1.55 +..B1.48: + fldt .L_2il0floatpacket.9@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B1.50 +..B1.49: + movl $2, (%esp) + fxch %st(2) + fsubrl _ones@GOTOFF(%ebx) + fxch %st(2) + jmp ..B1.55 +..B1.50: + fldt .L_2il0floatpacket.10@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B1.52 +..B1.51: + movl $0, (%esp) + fxch %st(2) + fsubl _ones@GOTOFF(%ebx) + fxch %st(2) + jmp ..B1.55 +..B1.52: + fldt .L_2il0floatpacket.11@GOTOFF(%ebx) + fcomp %st(3) + fnstsw %ax + sahf + jbe ..B1.54 +..B1.53: + fldt .L_2il0floatpacket.12@GOTOFF(%ebx) + movl $1, (%esp) + fsubrp %st, %st(3) + jmp ..B1.55 +..B1.54: + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + movl $2, (%esp) + fsubp %st, %st(3) +..B1.55: + movl (%esp), %eax + fldz + movl %edi, 40(%esp) + imull $180, %eax, %edi + fstpt 168(%esp) + lea (%eax,%eax,2), %eax + shll $5, %eax + lea _tgammal_T1@GOTOFF(%ebx,%edi), %edi + movl %edi, 36(%esp) + movl 40(%esp), %edi + lea _tgammal_A1@GOTOFF(%ebx,%eax), %eax +..B1.56: + cmpl $16299, %ecx + jle ..B1.62 +..B1.57: + fstp %st(1) + movl %edi, 40(%esp) + testb $1, %dl + movl 36(%esp), %edi + fstpt 80(%esp) + fldt 168(%edi) + fmul %st(1), %st + fldt 156(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 144(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 132(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 120(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 108(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 84(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 72(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 60(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48(%edi) + faddp %st, %st(1) + fmul %st(1), %st + fld %st(1) + fldt 36(%edi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24(%edi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 12(%edi) + faddp %st, %st(1) + fmul %st(2), %st + fld %st(2) + fldt (%edi) + movl 40(%esp), %edi + faddp %st, %st(2) + fld %st(3) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fmul %st, %st(4) + fxch %st(2) + fadd %st(4), %st + fsubp %st, %st(4) + fsub %st(3), %st + fld %st(0) + fld %st(2) + fmul %st(4), %st + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fsubr %st, %st(5) + fxch %st(2) + fmul %st(5), %st + fxch %st(5) + fmul %st(6), %st + faddp %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(4) + fxch %st(2) + fstpt (%esp) + fldt (%esp) + fldl 88(%eax) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + fld %st(4) + fadd %st(4), %st + fsubr %st, %st(4) + fxch %st(5) + faddp %st, %st(4) + faddp %st, %st(3) + fldl 80(%eax) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(4), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fld %st(1) + fmul %st(5), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fld %st(1) + fmul %st(4), %st + fld %st(3) + fmul %st(6), %st + fxch %st(5) + fmul %st(6), %st + faddp %st, %st(1) + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldl 72(%eax) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + faddp %st, %st(4) + fldl 64(%eax) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(4) + fld %st(3) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fld %st(1) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(5) + faddp %st, %st(3) + fld %st(3) + fmul %st(3), %st + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fldl 56(%eax) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(4), %st + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fldl 48(%eax) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fld %st(0) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(3) + fmul %st(2), %st + fld %st(3) + fmul %st(6), %st + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(1) + fxch %st(3) + fmul %st(4), %st + faddp %st, %st(3) + fldl 40(%eax) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fldl 32(%eax) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fld %st(1) + fmul %st(4), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fld %st(4) + fmul %st(4), %st + fxch %st(4) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(3) + fldl 24(%eax) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fldl 16(%eax) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fmul %st, %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsub %st, %st(1) + fld %st(1) + fmul %st(6), %st + fxch %st(2) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(3) + fmul %st, %st(5) + fld %st(4) + fmulp %st, %st(1) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 8(%eax) + fld %st(0) + fadd %st(4), %st + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(4) + fxch %st(1) + fadd %st, %st(4) + fsubrp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fldl (%eax) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt 80(%esp) + je ..B1.60 +..B1.58: + cmpl $1, %edx + jle ..B1.60 +..B1.59: + fstp %st(0) + fstp %st(0) + fldt (%esp) + fld %st(1) + fmul %st(1), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fld %st(1) + fldt 168(%esp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fstpt 92(%esp) + fldt 92(%esp) + fsubp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(3) + fld %st(4) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + jmp ..B1.64 +..B1.60: + fxch %st(1) + fstpt 92(%esp) + fxch %st(1) + jmp ..B1.63 +..B1.62: + fldl _ones@GOTOFF(%ebx) +..B1.63: + testl %edx, %edx + jle ..B1.77 +..B1.225: + fstp %st(1) +..B1.64: + cmpl $0, 132(%esp) + jne ..B1.71 +..B1.65: + testl %edi, %edi + je ..B1.67 +..B1.66: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 40(%esp) + fstpt 80(%esp) + call fesetround +..B1.201: + fldt 80(%esp) + fldt 40(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.67: + testl %esi, %esi + faddp %st, %st(1) + fstpt 64(%esp) + je ..B1.226 +..B1.68: + fstpt 52(%esp) +..B1.202: + fldcw 150(%esp) + jmp ..B1.69 +..B1.226: + fstp %st(0) +..B1.69: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.70: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.71: + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fld %st(1) + fldt 104(%esp) + testl %edi, %edi + fld %st(0) + fmul %st(3), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fldt 120(%esp) + faddp %st, %st(2) + fld %st(4) + fmul %st(4), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fmul %st(1), %st + fxch %st(3) + fsubr %st, %st(5) + fxch %st(5) + faddp %st, %st(6) + fld %st(5) + fmul %st(2), %st + fxch %st(1) + fmulp %st, %st(6) + faddp %st, %st(5) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fld %st(1) + fld %st(3) + fxch %st(2) + fdivrl _ones@GOTOFF(%ebx) + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(2) + fsub %st(1), %st + fld %st(3) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(5) + faddp %st, %st(4) + fld %st(1) + fmul %st(4), %st + fld %st(1) + fmul %st(6), %st + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(1) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + fld %st(0) + fsub %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + fsubp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fstpt 224(%esp) + fldt 224(%esp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(4) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(4) + fld %st(5) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fxch %st(3) + fstpt 236(%esp) + fxch %st(2) + fxch %st(1) + je ..B1.73 +..B1.72: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 40(%esp) + fstpt 56(%esp) + fstpt 80(%esp) + call fesetround +..B1.203: + fldt 80(%esp) + fldt 56(%esp) + fldt 40(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.73: + movl 76(%esp), %eax + faddp %st, %st(1) + andl $1, %eax + fstpt 64(%esp) + shll $15, %eax + xorl %eax, 72(%esp) + testl %esi, %esi + je ..B1.227 +..B1.74: + fxch %st(1) + fstpt 52(%esp) + fstpt 92(%esp) +..B1.204: + fldcw 150(%esp) + jmp ..B1.75 +..B1.227: + fstp %st(0) + fstp %st(0) +..B1.75: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.76: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.77: + fldl _ones@GOTOFF(%ebx) + cmpl $0, 132(%esp) + jne ..B1.87 +..B1.78: + fldt 152(%esp) + cmpl $100, %ecx + fldt 136(%esp) + faddp %st, %st(1) + jge ..B1.80 +..B1.79: + fstp %st(4) + fdivp %st, %st(3) + fmulp %st, %st(2) + fxch %st(2) + jmp ..B1.81 +..B1.80: + fstp %st(3) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fld %st(0) + fxch %st(4) + fdivrp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(4) + fsub %st(3), %st + fxch %st(5) + fstpt 64(%esp) + fxch %st(3) + fstpt 24(%esp) + fldt 152(%esp) + fld %st(0) + fmul %st(4), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fld %st(5) + fldt 136(%esp) + faddp %st, %st(3) + fmul %st(2), %st + fld %st(4) + fmul %st(2), %st + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(1) + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(1) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + fld %st(0) + fsub %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + fsubrp %st, %st(1) + fsubp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(5) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 224(%esp) + fldt 224(%esp) + fld %st(4) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(4) + fld %st(6) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(3) + fld %st(1) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(4) + fld %st(2) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(5) + fstpt 236(%esp) + fld %st(0) + fadd %st(4), %st + fstpt 92(%esp) + fldt 92(%esp) + fsubp %st, %st(4) + fsub %st(3), %st + faddp %st, %st(2) + fldt 24(%esp) + faddp %st, %st(1) + fld %st(0) + fmul %st(2), %st + fld %st(4) + fmul %st(4), %st + fxch %st(3) + fmulp %st, %st(5) + faddp %st, %st(4) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 64(%esp) +..B1.81: + testl %edi, %edi + fxch %st(1) + je ..B1.83 +..B1.82: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 80(%esp) + fstpt 96(%esp) + call fesetround +..B1.205: + fldt 96(%esp) + fldt 80(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.83: + testl %esi, %esi + faddp %st, %st(2) + fxch %st(1) + fstpt 64(%esp) + je ..B1.228 +..B1.84: + fstpt 52(%esp) +..B1.206: + fldcw 150(%esp) + jmp ..B1.85 +..B1.228: + fstp %st(0) +..B1.85: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.86: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.87: + cmpl $100, %ecx + jge ..B1.89 +..B1.88: + fldt 184(%esp) + fmulp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fdivrp %st, %st(2) + fxch %st(2) + jmp ..B1.90 +..B1.89: + fstp %st(2) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fld %st(1) + fxch %st(5) + fstpt 64(%esp) + fld %st(1) + fmul %st(1), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + fxch %st(1) + fsub %st(4), %st + faddp %st, %st(3) + fldt 184(%esp) + fld %st(0) + fmul %st(2), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fld %st(5) + fmul %st(1), %st + fxch %st(1) + fmul %st(5), %st + fldt 200(%esp) + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(6) + fmulp %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + faddp %st, %st(3) + fld %st(2) + fadd %st(4), %st + fdivrp %st, %st(2) + fld %st(0) + fmul %st(2), %st + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(1) + fld %st(0) + fsubrp %st, %st(3) + fld %st(1) + fmul %st(5), %st + fld %st(5) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fld %st(2) + fmul %st(4), %st + fld %st(1) + fmul %st(6), %st + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(1) + fxch %st(3) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(3) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + fld %st(0) + fsub %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(4) + fsubrp %st, %st(1) + fadd %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fxch %st(1) + fsub %st(3), %st + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fld %st(5) + fxch %st(2) + fsubrp %st, %st(1) + fmul %st, %st(5) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmul %st(2), %st + fld %st(3) + fmul %st(2), %st + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + fstpt 236(%esp) + fxch %st(1) + fstpt 224(%esp) + fldt 64(%esp) +..B1.90: + testl %edi, %edi + fxch %st(1) + je ..B1.92 +..B1.91: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 80(%esp) + fstpt 96(%esp) + call fesetround +..B1.207: + fldt 96(%esp) + fldt 80(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.92: + movl 76(%esp), %eax + faddp %st, %st(2) + andl $1, %eax + fxch %st(1) + fstpt 64(%esp) + shll $15, %eax + xorl %eax, 72(%esp) + testl %esi, %esi + je ..B1.229 +..B1.93: + fstpt 52(%esp) +..B1.208: + fldcw 150(%esp) + jmp ..B1.94 +..B1.229: + fstp %st(0) +..B1.94: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.95: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.96: + fstp %st(2) + fldl _ones@GOTOFF(%ebx) + fstl 56(%esp) + fld %st(3) + fdivrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt (%esp) + addl $-32, %esp + lea 208(%esp), %eax + fxch %st(3) + fstpt (%esp) + fstpt 12(%esp) + movl %eax, 24(%esp) + fxch %st(1) + fstpt 56(%esp) + fstpt 72(%esp) + call __libm_logl_k80 +..B1.209: + fstp %st(0) + fldt 72(%esp) + fldt 56(%esp) + addl $32, %esp +..B1.97: + fldl 56+_tgammal_B@GOTOFF(%ebx) + fxch %st(2) + fstpt 40(%esp) + fldt (%esp) + fmul %st, %st(2) + fldt _tgammal_B0@GOTOFF(%ebx) + fldt .L_2il0floatpacket.4@GOTOFF(%ebx) + cmpl $0, 132(%esp) + fxch %st(4) + faddl 48+_tgammal_B@GOTOFF(%ebx) + fmul %st(2), %st + faddl 40+_tgammal_B@GOTOFF(%ebx) + fmul %st(2), %st + faddl 32+_tgammal_B@GOTOFF(%ebx) + fmul %st(2), %st + faddl 24+_tgammal_B@GOTOFF(%ebx) + fmul %st(2), %st + faddl 16+_tgammal_B@GOTOFF(%ebx) + fmul %st(2), %st + faddl 8+_tgammal_B@GOTOFF(%ebx) + fmul %st(2), %st + faddl _tgammal_B@GOTOFF(%ebx) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 212(%esp) + fsub %st, %st(2) + fld %st(2) + fxch %st(1) + fchs + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fldt 176(%esp) + fld %st(0) + fmulp %st, %st(4) + fld %st(0) + fadd %st(4), %st + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(4) + fxch %st(3) + fstpt 176(%esp) + fldt 176(%esp) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(4) + fldt 188(%esp) + faddp %st, %st(5) + fxch %st(2) + fmul %st(4), %st + fld %st(6) + fmul %st(5), %st + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fadd %st(6), %st + fsub %st, %st(6) + fxch %st(6) + fchs + fadd %st(1), %st + fxch %st(4) + fstpt 188(%esp) + fsubrp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(2) + fadd %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fadd %st, %st(1) + fxch %st(1) + fsub %st, %st(4) + fxch %st(4) + fchs + fadd %st(1), %st + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldl 8+_tgammal_C@GOTOFF(%ebx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldl _tgammal_C@GOTOFF(%ebx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.2@GOTOFF(%ebx) + fldt 40(%esp) + jne ..B1.109 +..B1.98: + fstp %st(1) + fxch %st(1) + fstpt 236(%esp) + lea 224(%esp), %edx + addl $-16, %esp + fxch %st(1) + fstpt (%edx) + lea 168(%esp), %eax + movl %eax, (%esp) + movl %edx, 4(%esp) + fstpt -112(%eax) + call __libm_expl_k80 +..B1.210: + fldt 56(%esp) + addl $16, %esp +..B1.99: + testl %edi, %edi + fxch %st(1) + je ..B1.102 +..B1.100: + fstpt (%esp) + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 56(%esp) + call fesetround +..B1.211: + fldt 56(%esp) + addl $16, %esp +..B1.101: + fldt (%esp) +..B1.102: + fldt 152(%esp) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%esp) + fldt 164(%esp) + movl (%esp), %edx + cmpl $16383, %edx + faddp %st, %st(1) + fldl 56(%esp) + fstpt (%esp) + jg ..B1.104 +..B1.103: + addl $16383, %edx + movzwl 8(%esp), %eax + andl $32767, %edx + andl $-32768, %eax + orl %edx, %eax + movw %ax, 8(%esp) + fldt (%esp) + fmulp %st, %st(1) + jmp ..B1.105 +..B1.104: + fldt _TWO_POW_16383@GOTOFF(%ebx) + andl $32767, %edx + fmulp %st, %st(1) + movzwl 8(%esp), %eax + andl $-32768, %eax + orl %edx, %eax + movw %ax, 8(%esp) + fldt (%esp) + fmulp %st, %st(1) +..B1.105: + fstpt 64(%esp) + testl %esi, %esi + je ..B1.107 +..B1.106: + fldt 24(%esp) + fstpt 92(%esp) +..B1.212: + fldcw 150(%esp) +..B1.107: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.108: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.109: + fxch %st(2) + fchs + lea 224(%esp), %edx + incl 36(%esp) + fstpt 12(%edx) + addl $-16, %esp + fxch %st(2) + fchs + lea 168(%esp), %eax + fstpt (%edx) + movl %eax, (%esp) + movl %edx, 4(%esp) + fxch %st(1) + fstpt 16(%esp) + fstpt -112(%eax) + call __libm_expl_k80 +..B1.213: + fldt 56(%esp) + fxch %st(1) + fstpt 40(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.110: + fldt 104(%esp) + fld %st(0) + fld %st(2) + fld %st(2) + fldt 120(%esp) + fadd %st, %st(3) + fxch %st(3) + fdivrl 56(%esp) + fmul %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(3) + fsub %st(2), %st + fld %st(4) + fmul %st(6), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fld %st(3) + fmul %st(1), %st + fld %st(3) + fmul %st(3), %st + fxch %st(3) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt .L_2il0floatpacket.6@GOTOFF(%ebx) + fld %st(0) + fsub %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + fsubrp %st, %st(1) + fsubp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(4) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fstpt 224(%esp) + fldt 224(%esp) + fld %st(4) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(4) + fld %st(3) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fstpt 236(%esp) + fld %st(2) + fxch %st(1) + fmul %st, %st(3) + fldt 152(%esp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fstpt 152(%esp) + fldt 152(%esp) + fld %st(1) + fadd %st(5), %st + fsub %st, %st(5) + fxch %st(2) + fsub %st(5), %st + faddp %st, %st(4) + fld %st(3) + fxch %st(1) + fsubr %st, %st(3) + fmul %st, %st(4) + fldt 164(%esp) + faddp %st, %st(4) + fxch %st(1) + fmul %st(3), %st + fld %st(5) + fmulp %st, %st(2) + fxch %st(3) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fstpt 64(%esp) + fldt 64(%esp) + movzwl 72(%esp), %ecx + andl $32767, %ecx + fxch %st(4) + fstpt 164(%esp) + fldt 24(%esp) + faddp %st, %st(5) + fxch %st(4) + fstpt (%esp) + movl (%esp), %edx + lea (%edx,%ecx), %eax + lea -1(%edx,%ecx), %ecx + cmpl $32765, %ecx + ja ..B1.116 +..B1.111: + fstp %st(1) + fstp %st(0) + fldl 56(%esp) + lea 16382(%edx), %eax + fstpt (%esp) + cmpl $32765, %eax + ja ..B1.113 +..B1.112: + addl $16383, %edx + movzwl 8(%esp), %eax + andl $32767, %edx + andl $-32768, %eax + orl %edx, %eax + movw %ax, 8(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.129 +..B1.113: + cmpl $16383, %edx + jle ..B1.115 +..B1.114: + fldt _TWO_POW_16383@GOTOFF(%ebx) + andl $32767, %edx + fmulp %st, %st(1) + movzwl 8(%esp), %eax + andl $-32768, %eax + orl %edx, %eax + movw %ax, 8(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.129 +..B1.115: + fldt _TWO_POW_M16382@GOTOFF(%ebx) + addl $32765, %edx + fmulp %st, %st(1) + andl $32767, %edx + movzwl 8(%esp), %eax + andl $-32768, %eax + orl %edx, %eax + movw %ax, 8(%esp) + fldt (%esp) + fmulp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.129 +..B1.116: + fstp %st(2) + cmpl $32766, %eax + jle ..B1.118 +..B1.117: + fstp %st(0) + fstp %st(0) + fldt _TWO_POW_16383@GOTOFF(%ebx) + fmul %st(0), %st + fstpt 64(%esp) + jmp ..B1.129 +..B1.118: + cmpl $-65, %eax + jg ..B1.120 +..B1.119: + fstp %st(0) + fstp %st(0) + fldt _TWO_POW_M16382@GOTOFF(%ebx) + fmul %st(0), %st + fstpt 64(%esp) + jmp ..B1.129 +..B1.120: + fldl 56(%esp) + cmpl $-16382, %edx + fstpt (%esp) + jl ..B1.125 +..B1.121: + fstp %st(2) + fldl _TWO_53H@GOTOFF(%ebx) + addl $16383, %edx + fmul %st(2), %st + fld %st(2) + movzwl 8(%esp), %eax + andl $32767, %edx + andl $-32768, %eax + fsubr %st(1), %st + orl %edx, %eax + fsubr %st, %st(1) + movw %ax, 8(%esp) + testl %edi, %edi + fxch %st(1) + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(2) + fldt (%esp) + fmul %st, %st(3) + fxch %st(3) + fstpt 24(%esp) + fxch %st(2) + fmulp %st, %st(1) + je ..B1.124 +..B1.122: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 56(%esp) + call fesetround +..B1.214: + fldt 56(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.123: + xorl %edi, %edi +..B1.124: + fldt 24(%esp) + faddp %st, %st(1) + fstpt 64(%esp) + jmp ..B1.129 +..B1.125: + fldl _TWO_32HP@GOTOFF(%ebx) + negl %edx + fldt _TWO_POW_M16000@GOTOFF(%ebx) + addl $-15999, %edx + fmul %st, %st(2) + andl $32767, %edx + fld %st(2) + fxch %st(1) + fmulp %st, %st(4) + movzwl 8(%esp), %eax + fadd %st(3), %st + fldt _small_value_80@GOTOFF(%ebx) + andl $-32768, %eax + orl %edx, %eax + movw %ax, 8(%esp) + testl %edi, %edi + fmul %st(0), %st + fstpt 12(%esp) + fldt (%esp) + fadd %st, %st(1) + fxch %st(1) + fmul %st, %st(2) + fmull _TWO_32H@GOTOFF(%ebx) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 24(%esp) + fldt 24(%esp) + fsubp %st, %st(1) + fsubrp %st, %st(1) + faddp %st, %st(1) + je ..B1.128 +..B1.126: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 16(%esp) + fstpt 56(%esp) + call fesetround +..B1.215: + fldt 56(%esp) + fldt 16(%esp) + addl $16, %esp +..B1.127: + xorl %edi, %edi +..B1.128: + fldt 24(%esp) + faddp %st, %st(1) + fstpt 64(%esp) + movzwl 72(%esp), %eax + andl $-32768, %eax + andl $2147483647, 68(%esp) + movw %ax, 72(%esp) +..B1.129: + movl 36(%esp), %eax + andl $1, %eax + shll $15, %eax + xorl %eax, 72(%esp) + testl %edi, %edi + je ..B1.131 +..B1.130: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 56(%esp) + call fesetround +..B1.216: + fldt 56(%esp) + addl $16, %esp +..B1.131: + testl %esi, %esi + je ..B1.230 +..B1.132: + fstpt 92(%esp) +..B1.217: + fldcw 150(%esp) + jmp ..B1.133 +..B1.230: + fstp %st(0) +..B1.133: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.134: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.135: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.136: + fstp %st(1) + testl %edi, %edi + je ..B1.138 +..B1.137: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 96(%esp) + call fesetround +..B1.218: + fldt 96(%esp) + addl $16, %esp +..B1.138: + fdiv %st(0), %st + testl %esi, %esi + fstpt 64(%esp) + je ..B1.140 +..B1.139: + fldcw 150(%esp) +..B1.140: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 + jmp ..B1.25 +..B1.143: + fstp %st(1) + testl %edi, %edi + je ..B1.145 +..B1.144: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 96(%esp) + call fesetround +..B1.219: + fldt 96(%esp) + addl $16, %esp +..B1.145: + fdiv %st(0), %st + testl %esi, %esi + fstpt 64(%esp) + je ..B1.147 +..B1.146: + fldcw 150(%esp) +..B1.147: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 + jmp ..B1.25 +..B1.156: + movl 12(%ebp), %eax + cmpl $536870912, %eax + jb ..B1.159 +..B1.157: + jne ..B1.29 +..B1.158: + cmpl $0, 8(%ebp) + jne ..B1.29 +..B1.159: + fstp %st(0) + testl %edi, %edi + je ..B1.161 +..B1.160: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.220: + addl $16, %esp +..B1.161: + fldt _large_value_80@GOTOFF(%ebx) + movl 132(%esp), %ecx + lea (,%ecx,8), %eax + lea (%eax,%ecx,4), %edx + shll $15, %ecx + fldt _large_value_80@GOTOFF(%ebx,%edx) + fmulp %st, %st(1) + fstpt 64(%esp) + orl %ecx, 72(%esp) + testl %esi, %esi + je ..B1.163 +..B1.162: + fldcw 150(%esp) +..B1.163: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 + jmp ..B1.25 +..B1.166: + fstp %st(0) + testl %edi, %edi + je ..B1.168 +..B1.167: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.221: + addl $16, %esp +..B1.168: + fldt _large_value_80@GOTOFF(%ebx) + testl %esi, %esi + fmul %st(0), %st + fstpt 64(%esp) + je ..B1.170 +..B1.169: + fldcw 150(%esp) +..B1.170: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 + jmp ..B1.25 +..B1.173: + fstp %st(1) + testl %edi, %edi + je ..B1.175 +..B1.174: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + fstpt 96(%esp) + call fesetround +..B1.222: + fldt 96(%esp) + addl $16, %esp +..B1.175: + movl 132(%esp), %eax + testl %esi, %esi + fldl _ones@GOTOFF(%ebx,%eax,8) + fdivp %st, %st(1) + fstpt 64(%esp) + je ..B1.177 +..B1.176: + fldcw 150(%esp) +..B1.177: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 + jmp ..B1.25 +..B1.180: + cmpl $0, 132(%esp) + je ..B1.183 +..B1.181: + cmpl $-2147483648, 12(%ebp) + jne ..B1.183 +..B1.182: + cmpl $0, 8(%ebp) + je ..B1.189 +..B1.183: + fldt 8(%ebp) + testl %esi, %esi + fmull _ones@GOTOFF(%ebx) + fstpt 64(%esp) + je ..B1.185 +..B1.184: + fldcw 150(%esp) +..B1.185: + testl %edi, %edi + je ..B1.187 +..B1.186: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.223: + addl $16, %esp +..B1.187: + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 +..B1.188: + addl $308, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.189: + testl %edi, %edi + je ..B1.191 +..B1.190: + addl $-16, %esp + movl 132(%esp), %eax + movl %eax, (%esp) + call fesetround +..B1.224: + addl $16, %esp +..B1.191: + fldl 8+_zeros@GOTOFF(%ebx) + fdivl _zeros@GOTOFF(%ebx) + fstpt 64(%esp) + fldt 64(%esp) + movl 248(%esp), %eax + xorl %esp, %eax + cmpl %gs:20, %eax + jne ..B1.135 + jmp ..B1.25 +..B1.195: + xorl %esi, %esi + jmp ..B1.7 + .align 16,0x90 + .type tgammal,@function + .size tgammal,.-tgammal + .data +# -- End tgammal + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xdc,0x09,0xc0,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x02,0x40,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfc,0x3f,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xfe,0x3f,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.12: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x3f,0x00,0x00 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,12 + .space 4, 0x00 # pad + .align 16 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_tgammal_S2: + .long 1076610156 + .long 1072298443 + .long 2174450924 + .long 1012377779 + .type _tgammal_S2,@object + .size _tgammal_S2,16 + .align 4 +_tgammal_S1: + .long 1649608659 + .long 3220853158 + .long 544854255 + .long 3162597952 + .type _tgammal_S1,@object + .size _tgammal_S1,16 + .align 4 +_tgammal_A2: + .long 1833415567 + .long 1073038586 + .long 2552883231 + .long 1018148522 + .long 1595568275 + .long 1072556376 + .long 458238143 + .long 1015211580 + .long 3568820252 + .long 1071968804 + .long 1244365593 + .long 1010337025 + .long 799339768 + .long 1070612333 + .long 3666663601 + .long 1014637144 + .long 2303274075 + .long 1069290379 + .long 1349342802 + .long 1013375288 + .long 3297989586 + .long 1067256475 + .long 254004781 + .long 1007721194 + .long 3884346469 + .long 1076314993 + .long 442477728 + .long 1020223370 + .long 318512670 + .long 1076897708 + .long 471158811 + .long 1020359281 + .long 2510778168 + .long 1076450444 + .long 1901825555 + .long 1020381374 + .long 1635478559 + .long 1075598710 + .long 824259222 + .long 1018719588 + .long 1081324001 + .long 1074338163 + .long 3447625061 + .long 1017363587 + .long 3947156014 + .long 1072861090 + .long 1379190805 + .long 1015115048 + .long 420607958 + .long 1081212458 + .long 3477976495 + .long 1025491940 + .long 3806068795 + .long 1082138936 + .long 4217379562 + .long 1025598832 + .long 3604563515 + .long 1082026571 + .long 2373575058 + .long 1026208390 + .long 2007420787 + .long 1081336307 + .long 1677630540 + .long 1025930127 + .long 1505609351 + .long 1080304853 + .long 3680187356 + .long 1024342399 + .long 1798798240 + .long 1079036631 + .long 724429118 + .long 1022004699 + .long 573661072 + .long 1087072564 + .long 1175535566 + .long 1031320119 + .long 3742832273 + .long 1088193077 + .long 2163102943 + .long 1030481607 + .long 1347160184 + .long 1088323961 + .long 872134502 + .long 1032553403 + .long 3527047012 + .long 1087786342 + .long 974187100 + .long 1028831099 + .long 1718309677 + .long 1086914107 + .long 744179587 + .long 1031128181 + .long 2775103229 + .long 1085724862 + .long 1153587355 + .long 1029745229 + .long 1670522313 + .long 1093749470 + .long 3603089619 + .long 1038783597 + .long 2795800948 + .long 1094969738 + .long 1113103030 + .long 1039749901 + .long 3483985892 + .long 1095195750 + .long 707212107 + .long 1037942235 + .long 3634938287 + .long 1094882573 + .long 3822913920 + .long 1039689416 + .long 1233016495 + .long 1094091821 + .long 3838048750 + .long 1037461559 + .long 817468048 + .long 1093018536 + .long 360059332 + .long 1037856380 + .long 3404619429 + .long 1101025312 + .long 2324006265 + .long 1046266629 + .long 1757595371 + .long 1102333247 + .long 3317464771 + .long 1041601336 + .long 2951620935 + .long 1102677785 + .long 2114793479 + .long 1046829217 + .long 1356962213 + .long 1102426961 + .long 3236647680 + .long 1046257529 + .long 378361594 + .long 1101790815 + .long 2326245451 + .long 1045004339 + .long 704627613 + .long 1100821691 + .long 771850637 + .long 1043974839 + .type _tgammal_A2,@object + .size _tgammal_A2,576 + .align 4 +_tgammal_A1: + .long 4294967295 + .long 1072693247 + .long 4294254158 + .long 1017118719 + .long 4235179544 + .long 3219290252 + .long 1647137719 + .long 3164508998 + .long 3258652024 + .long 1072670296 + .long 2787078119 + .long 1015928435 + .long 2402437986 + .long 3219982865 + .long 3119239167 + .long 3164440263 + .long 89167536 + .long 1072654929 + .long 3734368228 + .long 1015667286 + .long 3963139337 + .long 3220139136 + .long 2050876349 + .long 3162686202 + .long 2444554090 + .long 1072454648 + .long 2100370444 + .long 1016394631 + .long 2397397425 + .long 1067486888 + .long 3603318790 + .long 1011860326 + .long 3126988118 + .long 1071287373 + .long 3410508918 + .long 1015153675 + .long 480439205 + .long 3216734124 + .long 3426889025 + .long 3160197739 + .long 927904425 + .long 1069712317 + .long 1130465219 + .long 1014845612 + .long 4266680347 + .long 3216234636 + .long 1626218864 + .long 3161277677 + .long 0 + .long 1072693248 + .long 1528870101 + .long 964807786 + .long 119575502 + .long 3218804454 + .long 1881625935 + .long 3159804816 + .long 2341912255 + .long 1071274903 + .long 3500227044 + .long 1010193322 + .long 2554745004 + .long 3216302649 + .long 3304224511 + .long 3156439793 + .long 2968672914 + .long 1068696059 + .long 4206584367 + .long 1012030447 + .long 1090398824 + .long 1060208439 + .long 842313838 + .long 1004803849 + .long 4294967295 + .long 1072693247 + .long 4294967295 + .long 1017118719 + .long 4235179544 + .long 3219290252 + .long 4177388891 + .long 3164508998 + .long 3258652024 + .long 1072670296 + .long 1161858311 + .long 1015929131 + .long 2402437986 + .long 3219982865 + .long 3056812941 + .long 3164521903 + .long 89167541 + .long 1072654929 + .long 2427235615 + .long 1014999039 + .long 3963139706 + .long 3220139136 + .long 3024603167 + .long 3163626566 + .type _tgammal_A1,@object + .size _tgammal_A1,384 + .align 4 +_tgammal_B: + .long 381774871 + .long 3211182444 + .long 436314138 + .long 1061814688 + .long 327235604 + .long 3208872248 + .long 723058467 + .long 1061917982 + .long 3650698365 + .long 3210701488 + .long 440509466 + .long 1064976804 + .long 3406779288 + .long 3214819974 + .long 941491840 + .long 1070005910 + .type _tgammal_B,@object + .size _tgammal_B,64 + .align 4 +_tgammal_C: + .long 3362045620 + .long 1072523249 + .long 4064281872 + .long 1016386130 + .type _tgammal_C,@object + .size _tgammal_C,16 + .align 4 +_TWO_32HP: + .long 1048576 + .long 1106771968 + .type _TWO_32HP,@object + .size _TWO_32HP,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .type _small_value_80,@object + .size _small_value_80,24 + .align 2 +_POS_OVERFLOW: + .word 11809 + .word 27445 + .word 35846 + .word 56177 + .word 16393 + .word 0 + .type _POS_OVERFLOW,@object + .size _POS_OVERFLOW,12 + .align 2 +_tgammal_S: + .word 24210 + .word 1753 + .word 29241 + .word 50004 + .word 49148 + .word 0 + .word 51350 + .word 39166 + .word 743 + .word 54836 + .word 16377 + .word 0 + .word 3640 + .word 30975 + .word 46417 + .word 39360 + .word 49142 + .word 0 + .word 53672 + .word 10841 + .word 35989 + .word 39843 + .word 16370 + .word 0 + .word 36569 + .word 52859 + .word 829 + .word 59922 + .word 49133 + .word 0 + .word 48029 + .word 59092 + .word 17416 + .word 34773 + .word 16361 + .word 0 + .word 51219 + .word 52454 + .word 61951 + .word 62382 + .word 49123 + .word 0 + .type _tgammal_S,@object + .size _tgammal_S,84 + .align 2 +_tgammal_T2: + .word 46722 + .word 54455 + .word 58933 + .word 43588 + .word 16376 + .word 0 + .word 11656 + .word 9670 + .word 26887 + .word 53935 + .word 16373 + .word 0 + .word 37336 + .word 10857 + .word 59094 + .word 50631 + .word 16372 + .word 0 + .word 42778 + .word 63737 + .word 45056 + .word 33859 + .word 16365 + .word 0 + .word 26755 + .word 45167 + .word 18275 + .word 32926 + .word 16369 + .word 0 + .word 44721 + .word 19678 + .word 48085 + .word 54982 + .word 49134 + .word 0 + .word 51053 + .word 39319 + .word 36729 + .word 62310 + .word 16365 + .word 0 + .word 45874 + .word 5043 + .word 3955 + .word 43983 + .word 49132 + .word 0 + .word 10698 + .word 13153 + .word 62730 + .word 37178 + .word 16363 + .word 0 + .word 47802 + .word 34638 + .word 48577 + .word 58524 + .word 49129 + .word 0 + .word 5552 + .word 49084 + .word 18209 + .word 47263 + .word 16360 + .word 0 + .word 27946 + .word 40146 + .word 45659 + .word 36839 + .word 49127 + .word 0 + .word 43027 + .word 63179 + .word 35272 + .word 58163 + .word 16357 + .word 0 + .word 51497 + .word 52569 + .word 40730 + .word 59709 + .word 49124 + .word 0 + .word 50075 + .word 12939 + .word 25687 + .word 50566 + .word 16355 + .word 0 + .word 50229 + .word 1163 + .word 49491 + .word 48597 + .word 16381 + .word 0 + .word 65107 + .word 33673 + .word 57229 + .word 54934 + .word 16379 + .word 0 + .word 40234 + .word 4993 + .word 58268 + .word 55864 + .word 16377 + .word 0 + .word 37170 + .word 65173 + .word 7022 + .word 51747 + .word 16375 + .word 0 + .word 26509 + .word 26471 + .word 6311 + .word 44116 + .word 16373 + .word 0 + .word 19430 + .word 24800 + .word 9769 + .word 34884 + .word 16371 + .word 0 + .word 11267 + .word 5159 + .word 36913 + .word 51530 + .word 16368 + .word 0 + .word 64725 + .word 57237 + .word 10436 + .word 35732 + .word 16366 + .word 0 + .word 9979 + .word 17874 + .word 14609 + .word 46771 + .word 16363 + .word 0 + .word 48661 + .word 14142 + .word 37902 + .word 57970 + .word 16360 + .word 0 + .word 44331 + .word 229 + .word 33140 + .word 34177 + .word 16358 + .word 0 + .word 18505 + .word 49699 + .word 39129 + .word 38384 + .word 16355 + .word 0 + .word 55009 + .word 45387 + .word 16863 + .word 41316 + .word 16352 + .word 0 + .word 32472 + .word 62749 + .word 3488 + .word 43302 + .word 16349 + .word 0 + .word 38507 + .word 49300 + .word 64329 + .word 42149 + .word 16346 + .word 0 + .word 54685 + .word 59022 + .word 19355 + .word 48977 + .word 16387 + .word 0 + .word 11322 + .word 9818 + .word 14110 + .word 61121 + .word 16385 + .word 0 + .word 35672 + .word 18289 + .word 56841 + .word 34043 + .word 16384 + .word 0 + .word 40623 + .word 27826 + .word 27872 + .word 34330 + .word 16382 + .word 0 + .word 23588 + .word 8736 + .word 44949 + .word 63368 + .word 16379 + .word 0 + .word 65458 + .word 32180 + .word 45318 + .word 53999 + .word 16377 + .word 0 + .word 7083 + .word 36157 + .word 35044 + .word 42795 + .word 16375 + .word 0 + .word 41937 + .word 53706 + .word 63704 + .word 63466 + .word 16372 + .word 0 + .word 56782 + .word 14002 + .word 58756 + .word 44258 + .word 16370 + .word 0 + .word 50000 + .word 929 + .word 21531 + .word 58307 + .word 16367 + .word 0 + .word 29164 + .word 41738 + .word 63210 + .word 36416 + .word 16365 + .word 0 + .word 22318 + .word 7527 + .word 19550 + .word 43267 + .word 16362 + .word 0 + .word 36459 + .word 32677 + .word 20918 + .word 49089 + .word 16359 + .word 0 + .word 54142 + .word 37469 + .word 39035 + .word 54353 + .word 16356 + .word 0 + .word 43987 + .word 37066 + .word 46591 + .word 55009 + .word 16353 + .word 0 + .word 23593 + .word 355 + .word 54000 + .word 36277 + .word 16394 + .word 0 + .word 38981 + .word 26613 + .word 65277 + .word 49004 + .word 16392 + .word 0 + .word 37709 + .word 48898 + .word 35761 + .word 58794 + .word 16390 + .word 0 + .word 20062 + .word 54760 + .word 43546 + .word 63578 + .word 16388 + .word 0 + .word 4376 + .word 65424 + .word 42405 + .word 62684 + .word 16386 + .word 0 + .word 53174 + .word 32360 + .word 45557 + .word 56872 + .word 16384 + .word 0 + .word 50961 + .word 21643 + .word 2055 + .word 47845 + .word 16382 + .word 0 + .word 44504 + .word 53228 + .word 208 + .word 37559 + .word 16380 + .word 0 + .word 22458 + .word 24129 + .word 6745 + .word 55322 + .word 16377 + .word 0 + .word 45571 + .word 12909 + .word 9586 + .word 38400 + .word 16375 + .word 0 + .word 63967 + .word 2945 + .word 37284 + .word 50443 + .word 16372 + .word 0 + .word 40100 + .word 52281 + .word 37909 + .word 62907 + .word 16369 + .word 0 + .word 14124 + .word 37910 + .word 18802 + .word 37402 + .word 16367 + .word 0 + .word 28370 + .word 35717 + .word 42940 + .word 43396 + .word 16364 + .word 0 + .word 57898 + .word 23307 + .word 6391 + .word 45620 + .word 16361 + .word 0 + .word 46932 + .word 12112 + .word 28768 + .word 37645 + .word 16401 + .word 0 + .word 4289 + .word 37433 + .word 59606 + .word 54245 + .word 16399 + .word 0 + .word 64482 + .word 38480 + .word 36982 + .word 34595 + .word 16398 + .word 0 + .word 60245 + .word 51970 + .word 24673 + .word 39653 + .word 16396 + .word 0 + .word 5116 + .word 50868 + .word 49618 + .word 41328 + .word 16394 + .word 0 + .word 41766 + .word 46400 + .word 3930 + .word 39543 + .word 16392 + .word 0 + .word 10780 + .word 29057 + .word 64174 + .word 35004 + .word 16390 + .word 0 + .word 53671 + .word 48824 + .word 23962 + .word 57716 + .word 16387 + .word 0 + .word 53678 + .word 31584 + .word 52783 + .word 44557 + .word 16385 + .word 0 + .word 6190 + .word 44351 + .word 42084 + .word 64733 + .word 16382 + .word 0 + .word 38744 + .word 53501 + .word 23462 + .word 44426 + .word 16380 + .word 0 + .word 5624 + .word 56691 + .word 10270 + .word 57805 + .word 16377 + .word 0 + .word 37833 + .word 48670 + .word 48257 + .word 35818 + .word 16375 + .word 0 + .word 2793 + .word 44149 + .word 23652 + .word 43316 + .word 16372 + .word 0 + .word 36532 + .word 60099 + .word 3358 + .word 47101 + .word 16369 + .word 0 + .word 26210 + .word 6795 + .word 18267 + .word 52540 + .word 16408 + .word 0 + .word 4852 + .word 29729 + .word 14912 + .word 39944 + .word 16407 + .word 0 + .word 5407 + .word 41984 + .word 60375 + .word 53635 + .word 16405 + .word 0 + .word 50093 + .word 12566 + .word 13387 + .word 64582 + .word 16403 + .word 0 + .word 49147 + .word 13632 + .word 405 + .word 35287 + .word 16402 + .word 0 + .word 19308 + .word 51191 + .word 49444 + .word 35336 + .word 16400 + .word 0 + .word 42358 + .word 64331 + .word 14656 + .word 65374 + .word 16397 + .word 0 + .word 20975 + .word 39047 + .word 28983 + .word 56232 + .word 16395 + .word 0 + .word 29936 + .word 14466 + .word 41903 + .word 45232 + .word 16393 + .word 0 + .word 29960 + .word 52783 + .word 56228 + .word 34190 + .word 16391 + .word 0 + .word 35121 + .word 10599 + .word 28021 + .word 48776 + .word 16388 + .word 0 + .word 24922 + .word 26565 + .word 63850 + .word 32942 + .word 16386 + .word 0 + .word 35914 + .word 31178 + .word 25984 + .word 42348 + .word 16383 + .word 0 + .word 32787 + .word 34531 + .word 38943 + .word 53136 + .word 16380 + .word 0 + .word 12957 + .word 55078 + .word 57592 + .word 59546 + .word 16377 + .word 0 + .type _tgammal_T2,@object + .size _tgammal_T2,1080 + .align 2 +_tgammal_T1: + .word 33333 + .word 22332 + .word 1335 + .word 65087 + .word 16382 + .word 0 + .word 47908 + .word 35098 + .word 63659 + .word 65273 + .word 49150 + .word 0 + .word 46380 + .word 12569 + .word 56008 + .word 65411 + .word 16382 + .word 0 + .word 48850 + .word 62280 + .word 7688 + .word 65472 + .word 49150 + .word 0 + .word 39250 + .word 51171 + .word 14264 + .word 65504 + .word 16382 + .word 0 + .word 1152 + .word 29364 + .word 36762 + .word 65519 + .word 49150 + .word 0 + .word 3017 + .word 25231 + .word 24799 + .word 65523 + .word 16382 + .word 0 + .word 25322 + .word 65334 + .word 59366 + .word 65496 + .word 49150 + .word 0 + .word 56776 + .word 58800 + .word 13007 + .word 65323 + .word 16382 + .word 0 + .word 19307 + .word 43631 + .word 60167 + .word 64530 + .word 49150 + .word 0 + .word 36275 + .word 49480 + .word 28369 + .word 61762 + .word 16382 + .word 0 + .word 21913 + .word 46254 + .word 26555 + .word 54444 + .word 49150 + .word 0 + .word 35908 + .word 6208 + .word 45367 + .word 40294 + .word 16382 + .word 0 + .word 27036 + .word 5944 + .word 26542 + .word 42848 + .word 49149 + .word 0 + .word 29582 + .word 26316 + .word 64938 + .word 47331 + .word 16379 + .word 0 + .word 2023 + .word 42870 + .word 23457 + .word 61457 + .word 16378 + .word 0 + .word 65015 + .word 19522 + .word 60134 + .word 39847 + .word 49146 + .word 0 + .word 37347 + .word 35810 + .word 25431 + .word 54185 + .word 16377 + .word 0 + .word 59586 + .word 38885 + .word 5307 + .word 36118 + .word 49145 + .word 0 + .word 55581 + .word 26604 + .word 61099 + .word 48328 + .word 16376 + .word 0 + .word 26530 + .word 8530 + .word 11497 + .word 64510 + .word 49143 + .word 0 + .word 5884 + .word 49309 + .word 23213 + .word 43047 + .word 16375 + .word 0 + .word 39008 + .word 7698 + .word 42498 + .word 57424 + .word 49142 + .word 0 + .word 52706 + .word 42552 + .word 1743 + .word 38295 + .word 16374 + .word 0 + .word 36375 + .word 51085 + .word 41378 + .word 51088 + .word 49141 + .word 0 + .word 45665 + .word 51480 + .word 46902 + .word 34067 + .word 16373 + .word 0 + .word 45474 + .word 25613 + .word 9050 + .word 44941 + .word 49140 + .word 0 + .word 10137 + .word 18971 + .word 38654 + .word 59779 + .word 16371 + .word 0 + .word 53562 + .word 56969 + .word 3619 + .word 46768 + .word 49139 + .word 0 + .word 12931 + .word 40754 + .word 53864 + .word 63282 + .word 16370 + .word 0 + .word 16582 + .word 62753 + .word 30052 + .word 46783 + .word 16376 + .word 0 + .word 41763 + .word 18743 + .word 29826 + .word 47859 + .word 16374 + .word 0 + .word 61445 + .word 12179 + .word 9444 + .word 35298 + .word 16374 + .word 0 + .word 19195 + .word 47291 + .word 36415 + .word 61711 + .word 16372 + .word 0 + .word 13845 + .word 40089 + .word 27018 + .word 32909 + .word 16372 + .word 0 + .word 12017 + .word 58217 + .word 13416 + .word 64677 + .word 16370 + .word 0 + .word 35895 + .word 43222 + .word 31657 + .word 65323 + .word 16369 + .word 0 + .word 20613 + .word 26232 + .word 50069 + .word 65270 + .word 16368 + .word 0 + .word 35252 + .word 65344 + .word 3340 + .word 65456 + .word 16367 + .word 0 + .word 10600 + .word 13283 + .word 40541 + .word 64928 + .word 16366 + .word 0 + .word 11880 + .word 32674 + .word 50280 + .word 34435 + .word 16366 + .word 0 + .word 63446 + .word 286 + .word 54268 + .word 48349 + .word 16364 + .word 0 + .word 8548 + .word 23982 + .word 1825 + .word 63713 + .word 16364 + .word 0 + .word 34666 + .word 29375 + .word 64038 + .word 41244 + .word 49131 + .word 0 + .word 59811 + .word 4152 + .word 44775 + .word 65267 + .word 16363 + .word 0 + .word 18717 + .word 22920 + .word 1335 + .word 65087 + .word 16382 + .word 0 + .word 45811 + .word 56269 + .word 63659 + .word 65273 + .word 49150 + .word 0 + .word 65298 + .word 48931 + .word 56016 + .word 65411 + .word 16382 + .word 0 + .word 32491 + .word 12018 + .word 7860 + .word 65472 + .word 49150 + .word 0 + .word 14368 + .word 44485 + .word 16906 + .word 65504 + .word 16382 + .word 0 + .word 41970 + .word 59715 + .word 3074 + .word 65520 + .word 49150 + .word 0 + .word 4801 + .word 21592 + .word 65211 + .word 65527 + .word 16382 + .word 0 + .word 62592 + .word 41973 + .word 39337 + .word 65531 + .word 49150 + .word 0 + .word 13381 + .word 40677 + .word 15011 + .word 65529 + .word 16382 + .word 0 + .word 46580 + .word 36519 + .word 54875 + .word 65490 + .word 49150 + .word 0 + .word 37477 + .word 29387 + .word 41414 + .word 65216 + .word 16382 + .word 0 + .word 16797 + .word 56146 + .word 15453 + .word 63766 + .word 49150 + .word 0 + .word 40859 + .word 15091 + .word 60713 + .word 58161 + .word 16382 + .word 0 + .word 1004 + .word 12255 + .word 49061 + .word 43226 + .word 49150 + .word 0 + .word 52096 + .word 41479 + .word 59455 + .word 37399 + .word 16381 + .word 0 + .type _tgammal_T1,@object + .size _tgammal_T1,720 + .align 2 +_tgammal_B0: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16379 + .word 0 + .type _tgammal_B0,@object + .size _tgammal_B0,12 + .align 2 +_TWO_POW_16383: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .type _TWO_POW_16383,@object + .size _TWO_POW_16383,12 + .align 2 +_TWO_POW_M16382: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .type _TWO_POW_M16382,@object + .size _TWO_POW_M16382,12 + .align 2 +_TWO_POW_M16000: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 383 + .word 0 + .type _TWO_POW_M16000,@object + .size _TWO_POW_M16000,12 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .type _large_value_80,@object + .size _large_value_80,24 + .data + .hidden __libm_expl_k80 + .hidden __libm_logl_k80 + .hidden fesetround + .hidden fegetround + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/trig_pi_bits.S b/external/sgx_libm/ia32/trig_pi_bits.S new file mode 100644 index 0000000000..380eaacb6c --- /dev/null +++ b/external/sgx_libm/ia32/trig_pi_bits.S @@ -0,0 +1,311 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "trig_pi_bits.c" + .section .rodata, "a" + .align 32 + .align 32 + .hidden __four_over_pi + .globl __four_over_pi +__four_over_pi: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0xdb939105,0x0028be60 + .long 0xf47d4d37,0x4a7f09d5 + .long 0x664f10e4,0x7036d8a5 + .long 0xeaf7aef1,0x107f9458 + .long 0x8e909374,0x586dc91b + .long 0xba827464,0xb801924b + .long 0xc72c4a69,0x873f877a + .long 0x7d4baed1,0xcfba208d + .long 0x09ad17df,0x213a671c + .long 0x8e60d4ce,0x904e6475 + .long 0xe2ef7e4a,0x7d272117 + .long 0xfff78166,0x0ec7fe25 + .long 0x62d6829b,0x03fbcbc4 + .long 0xb3c9f2c2,0x47db4d9f + .long 0xd9a797fa,0x6dd3d18f + .long 0xb1faf97c,0x8b5d49ee + .long 0x7de294a4,0x5ecf41ce + .long 0xec47e357,0xba9afed7 + .long 0x11bf1eda,0x421580cc + .long 0x0826bd0d,0xeafc33ef + .long 0x5857b986,0x876a78e4 + .long 0x57c5281a,0xc2196661 + .long 0x20135cc9,0x10237ff6 + .long 0x55b29cea,0xcc418185 + .long 0xf0231ad1,0x3258389e + .long 0xf3773a02,0xf10670d9 + .long 0x1da2e587,0x4aa0d671 + .long 0x3455c641,0x29b76bd1 + .long 0xc14fdf8c,0x4fa97fc1 + .long 0x93e60c9f,0xfa0cb0b7 + .long 0xbbdac797,0x6ef0cf49 + .long 0xcd72bc9f,0xbe27ce87 + .long 0x641f1f09,0xc761fc48 + .long 0x5dcb4c10,0x1abe9bb5 + .long 0x2d674670,0xcec57185 + .long 0x534b1740,0xf0b12b50 + .long 0x8b5c78e6,0x03119f61 + .long 0x8cdf34ad,0xb1a6c018 + .long 0x554dfd8f,0x25e9ed35 + .long 0xff1d934a,0xb5c60428 + .long 0xdc3e1f18,0xa7592af5 + .long 0xc545d592,0xd5ec1eb9 + .long 0xce2129f2,0x7036758e + .long 0xb588d516,0xc8c91de2 + .long 0xc2bc77f3,0xae47c006 + .long 0xda879998,0x867fcc67 + .long 0xeb361fdf,0x55e651fe + .long 0x7a0c982f,0xadd948a2 + .long 0xc24d9b35,0xf9b3713b + .long 0x85b78ed6,0x0fd775f7 + .long 0x08b4ba21,0x24a6f78a + .long 0x8cb2b185,0x8a135638 + .long 0x78143005,0xb8c232df + .long 0xf8060d04,0xe9c77cd6 + .long 0xc05220d6,0xcb9884a0 + .long 0x2b7cba47,0xe3bd5fec + .long 0xd9c43637,0x90d29234 + .long 0xb3985aa9,0x6a9097eb + .long 0x74fca981,0x0a02ad26 + .long 0xf0a8e20f,0x9fddd720 + .long 0x96a32bef,0x185e1ce2 + .long 0x8b72effd,0x75dbd8e9 + .long 0xf0499172,0x3be06359 + .long 0xb4aa0a23,0x954db672 + .long 0x44850981,0x58709df2 + .long 0x16711131,0x26d184b1 + .long 0x7cc5c02b,0x72246c93 + .long 0x4a44357f,0x50f53952 + .long 0x2507bbb3,0x7f2f8033 + .long 0xe03c7b30,0x9c3d4f84 + .long 0x31e50164,0xf9ecca3e + .long 0xc24bbcd1,0xcf9c706c + .long 0x1ec82ae7,0x42e704a2 + .long 0x91cbcc9e,0xed4bb0a4 + .long 0x29dc87f9,0xdb554324 + .long 0x52859e78,0xdae5b2cc + .long 0xfd25e53a,0x9e506277 + .long 0xcc665afb,0x2139b8a5 + .long 0xc3bf6eed,0x620d97d7 + .long 0x19d09c9c,0x26921b29 + .long 0x0567c279,0x4c97636e + .long 0x4e5d3dc7,0x6f094c63 + .long 0x035a0212,0x014c0043 + .long 0x2a91c0b9,0xd63b8b24 + .long 0x699f7ddc,0xdd0935af + .long 0xa7e9a523,0x921bbbc5 + .long 0x54f47c82,0xbda46d14 + .long 0x1f92fd5a,0xb3cce608 + .long 0xb740d750,0x18ec97cf + .long 0x54957019,0x1fe2614a + .long 0x4c920c9d,0x0dc4361b + .long 0x539b9511,0x5316f51c + .long 0x7d4ab559,0x704242da + .long 0xd4011776,0x852741c9 + .long 0xba85fe61,0xceed315d + .long 0x89c74a5a,0xdf5ad26e + .long 0x95052b5a,0x65ab3331 + .long 0x62141c8b,0xb8a42276 + .long 0x01dddc0c,0x2fa90125 + .long 0x2a1c7a92,0x3cc9ff00 + .long 0x1920f765,0x70998f78 + .long 0x6510e321,0xe5cfe8ff + .long 0x674e64a3,0x8377904c + .long 0xc5cef7c2,0x1c3779ed + .long 0x201724e0,0x0acdc568 + .long 0x363a03eb,0x16a48444 + .long 0xf6c3e40e,0xe01b12ff + .long 0x6958aef2,0x1d861645 + .long 0xef500401,0xd86e6271 + .long 0x527dadba,0x3cb489dd + .long 0x85028bc9,0xeec8b6ea + .long 0x0ccec246,0xa25da0d9 + .long 0x9470a8c7,0xa503aa8e + .long 0x89971370,0x6bbb6bc4 + .long 0x65d5b020,0x9b671e8b + .long 0x0263100a,0xcfc0fdbc + .long 0xed0e4548,0xe64c5b41 + .long 0x3124bd52,0x0316f0f6 + .long 0x93b34de9,0xeb71a972 + .long 0x24aada10,0xcdaa79a5 + .long 0x7be31d94,0xb77798c6 + .long 0xff2ae86b,0xa2da0df6 + .long 0x6b8036be,0x8c4577e8 + .long 0x2dc17b4c,0xc3199359 + .long 0x95cebfd1,0x194a6fd5 + .long 0xef9d77e4,0xee7e5abc + .long 0xfda31985,0xca0c202a + .long 0xbe877936,0x72c10188 + .long 0xc6d5c273,0x692ccf63 + .long 0xa92f84ed,0x4dba5093 + .long 0xbc2a1953,0x48ccc6aa + .long 0xcfc2f35e,0xe9707483 + .long 0xc122dedc,0x16ddbe48 + .long 0xb1b89b9b,0x85e254e9 + .long 0x12a6edf6,0xc03afbd6 + .long 0xb3f3dd87,0xb12e99aa + .long 0x6c706663,0x40b44b7c + .long 0x9221a817,0x1deb70f6 + .long 0x8bfc2b26,0x7dfd2031 + .long 0x0fdb77b4,0xbb376f17 + .long 0xb6ca8e89,0x07f1e42d + .long 0x24d4eb41,0x68e6abc0 + .long 0x4a5fa012,0x15edad0b + .long 0xaa9da856,0xe9c1f683 + .long 0x8b6df73f,0x5eca8485 + .long 0xe27f6fa2,0x797ebfb6 + .long 0x2a419c20,0x5b1db93f + .long 0x7fe1ff41,0x0f855ba1 + .long 0xd861860a,0xcf8a0cd9 + .long 0xf9ecdb9b,0xbaaf536b + .long 0x56efcc52,0x63ce59e5 + .long 0xcc10cb71,0x35e105b7 + .long 0x9c326e32,0xcd584973 + .long 0xe8802939,0xcc3f5b2f + .long 0x5691dbc8,0x1b016837 + .long 0x172e5258,0x748498a1 + .long 0xc054a64d,0x5c38159a + .long 0x47b13c4c,0xd5542df5 + .long 0x0c176a4b,0xd7db84f9 + .long 0x4d8ca869,0xa170ec87 + .long 0x7a887dc5,0x2dc2352c + .long 0xffc9e000,0xb91a63dd + .long 0x683353e6,0xc30b5023 + .long 0xacc2974b,0x694834e8 + .long 0xf684742f,0xd0be6d32 + .long 0xef45eae0,0x9f7076e6 + .long 0x8205d54b,0x68b2971a + .long 0x051fe181,0x954009fc + .long 0x235065b7,0xf85902c5 + .long 0x76ad895a,0xafa1cabf + .long 0xbcc167af,0xcd225eff + .long 0x2a0a9296,0xee53da9a + .long 0x0b6616b5,0xb113ef3e + .long 0x5343698e,0xe571fd23 + .long 0x2c4fc525,0x8817d5e9 + .long 0x3321b75c,0x4e200048 + .long 0x582fc459,0x6db7b27d + .long 0x6b2c2334,0x535ac1c0 + .long 0x5443bec7,0x302c9215 + .long 0xc1a8cd50,0xb0dca54e + .long 0xb311783e,0x301ef701 + .long 0xb5907cfa,0x8a53b232 + .long 0x1926cc6f,0x37991f36 + .long 0x35161df1,0xb670e5e9 + .long 0xbc0f0eae,0x78da44f6 + .long 0xdd557d6f,0x91861197 + .long 0x974bab3b,0x74b1a49b + .long 0x8721f118,0x5103908f + .long 0xf5b9f29f,0x7a7f4a7c + .long 0xf1780223,0x088d645b + .long 0x9bb1bf6c,0x75fff89a + .long 0x175f2cab,0x304224dd + .long 0x5edc8f9a,0x5ae75bb3 + .long 0xfdf7dcca,0x8471aa73 + .long 0x402dc36c,0x6eb26d54 + .long 0x181f7962,0xb8892e9d + .long 0x43430620,0xb61d0b05 + .long 0x8a405d9e,0x65199f85 + .long 0x7bd1558d,0xa7efbf7f + .long 0x7b2e6ea2,0x9fb644f6 + .long 0xea0c70db,0xff25f109 + .long 0x15aa362d,0xbc4db165 + .long 0x33cb6244,0x6a2d03b3 + .long 0x558b38f3,0x8d15dbe2 + .long 0xaa979ae7,0xa66e4835 + .long 0xc45282ff,0x0a8fb317 + .long 0x4ee38b21,0x7efd385b + .long 0x6a6d3f34,0xb8a1353a + .long 0x4b984e4b,0x7bbbf24d + .long 0x3646c2bf,0xd1084e32 + .long 0xf6070be1,0x205a92be + .long 0x53b30895,0x2d14e326 + .long 0xb1b02586,0x37154ab5 + .long 0x99255a58,0x42ee1c06 + .long 0x8fc3c45f,0x1689bb94 + .long 0x72ff0b6f,0xc46d7d3d + .long 0x33177a18,0x0d3baf0d + .long 0x99fbcce4,0x17b766e3 + .long 0xd6186f15,0xae05f266 + .long 0x440fb612,0xf871a0d4 + .long 0x0b68462b,0x1c777747 + .long 0xfcd6661e,0xd18b0875 + .long 0xbea193ff,0xb6701527 + .long 0x794d88a2,0x0195ab9e + .long 0x24d9eaba,0x48ab4e37 + .long 0xa6f9f2a9,0x154e09a0 + .long 0xe643b5ea,0x03546c4c + .long 0x2c9969e2,0x52015a7c + .long 0x0db47e6c,0x1fe5d322 + .long 0x9ec873e6,0xe48852a0 + .long 0x51f70e9d,0x3727d015 + .long 0xf7e77f97,0x3850bad9 + .long 0xdedeab2e,0xf517a919 + .long 0xe20ad56e,0xa8bd9548 + .long 0x618a8860,0x90421b96 + .long 0xe27527b9,0xd1ce79b8 + .long 0x55bff283,0x503ed27a + .long 0x4afea531,0xc7229671 + .long 0x43eb96b6,0x7074f3f1 + .long 0x90e14ee1,0xe1b151d8 + .long 0x21d8441e,0x88651e4b + .long 0x2004afd0,0xd30a868b + .long 0x4f1e3931,0xe409a222 + .long 0x708eb13a,0x2a1ef6f9 + .long 0xfdefe483,0xbd09a299 + .long 0x64cf42df,0x4ae8d96c + .long 0x18f749f7,0x2f771469 + .long 0x26a54a6a,0x785a4665 + .long 0x3b424827,0x0a339a2d + .long 0x98e09c08,0xd132a613 + .long 0x43e3bd69,0xdf1f8cae + .long 0x3c484aa7,0xf9d58502 + .long 0xd446696a,0x6d535f9b + .long 0xe0987765,0xfe6d75b7 + .long 0xceb12868,0x808d85a7 + .long 0x9ea34e6a,0xa0db7b5c + .long 0x9ad6c9d1,0x6e20970c + .long 0xc034957d,0xbb4d001d + .long 0x601c7838,0x3f135640 + .long 0x7cd92a3c,0x4fe26ca5 + .long 0x3f133aac,0x6ba9d2ce + .type __four_over_pi,@object + .size __four_over_pi,2104 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/trunc_wmt.S b/external/sgx_libm/ia32/trunc_wmt.S new file mode 100644 index 0000000000..b239f42b52 --- /dev/null +++ b/external/sgx_libm/ia32/trunc_wmt.S @@ -0,0 +1,130 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "trunc_wmt.c" + .text +..TXTST0: +# -- Begin static_func + .text + .align 16,0x90 +static_func: +..B1.1: +..L1: + + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + lea static_const_table@GOTOFF(%eax), %eax + ret + .align 16,0x90 + .type static_func,@function + .size static_func,.-static_func + .data +# -- End static_func + .text +# -- Begin trunc + .text + .align 16,0x90 + .globl trunc +trunc: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + +..B2.2: + pushl %ebp + movl %esp, %ebp + subl $104, %esp + movl %ebx, 40(%esp) + call static_func + movl %eax, %ebx + movsd 112(%esp), %xmm0 + movq (%ebx), %xmm2 + movdqa %xmm0, %xmm1 + psrlq $52, %xmm1 + movq 8(%ebx), %xmm3 + movd %xmm1, %eax + andl $2047, %eax + subl $1023, %eax + js .L_2TAG_PACKET_0.0.2 + cmpl $52, %eax + jae .L_2TAG_PACKET_1.0.2 + pand %xmm3, %xmm1 + psubd %xmm1, %xmm2 + psrlq %xmm2, %xmm0 + psllq %xmm2, %xmm0 + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_0.0.2: + movsd 112(%esp), %xmm0 + movq 16(%ebx), %xmm1 + pand %xmm1, %xmm0 + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_1.0.2: + fldl 112(%esp) + fld1 + fxch %st(1) + fmulp %st, %st(1) + jmp .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_2.0.2: + movsd %xmm0, 24(%esp) + fldl 24(%esp) +.L_2TAG_PACKET_3.0.2: + movl 40(%esp), %ebx + movl %ebp, %esp + popl %ebp + ret +..B2.3: + .align 16,0x90 + .type trunc,@function + .size trunc,.-trunc + .data +# -- End trunc + .section .rodata, "a" + .align 16 + .align 16 +static_const_table: + .long 1075 + .long 0 + .long 2047 + .long 0 + .long 0 + .long 2147483648 + .type static_const_table,@object + .size static_const_table,24 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/truncf.S b/external/sgx_libm/ia32/truncf.S new file mode 100644 index 0000000000..69e5b3da83 --- /dev/null +++ b/external/sgx_libm/ia32/truncf.S @@ -0,0 +1,84 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "truncf.c" + .text +..TXTST0: +# -- Begin truncf + .text + .align 16,0x90 + .globl truncf +truncf: +# parameter 1: 4 + %esp +..B1.1: +..L1: + + movl 4(%esp), %eax + movl %eax, %ecx + andl $2147483647, %ecx + addl $-1065353216, %ecx + cmpl $192937984, %ecx + jb ..B1.5 +..B1.2: + testl %ecx, %ecx + jl ..B1.6 +..B1.3: + flds 4(%esp) +..B1.4: + ret +..B1.5: + shrl $23, %ecx + movl $-1, %edx + negl %ecx + addl $23, %ecx + shll %cl, %edx + andl %edx, %eax + movl %eax, 4(%esp) + flds 4(%esp) + ret +..B1.6: + andl $-2147483648, %eax + movl %eax, 4(%esp) + flds 4(%esp) + ret + .align 16,0x90 + .type truncf,@function + .size truncf,.-truncf + .data +# -- End truncf + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/truncl.S b/external/sgx_libm/ia32/truncl.S new file mode 100644 index 0000000000..54f1c680ca --- /dev/null +++ b/external/sgx_libm/ia32/truncl.S @@ -0,0 +1,171 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "truncl.c" + .text +..TXTST0: +# -- Begin truncl + .text + .align 16,0x90 + .globl truncl +truncl: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + subl $32, %esp +..B1.2: + fnstcw 22(%esp) +..B1.3: + movzwl 16(%ebp), %ecx + andl $32767, %ecx + call ..L2 +..L2: + popl %eax + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax + cmpl $16446, %ecx + jge ..B1.14 +..B1.4: + cmpl $16383, %ecx + jl ..B1.9 +..B1.5: + cmpl $16415, %ecx + jge ..B1.7 +..B1.6: + negl %ecx + addl $30, %ecx + movl 12(%ebp), %eax + shrl %cl, %eax + shll %cl, %eax + movl %eax, 12(%ebp) + xorl %eax, %eax + jmp ..B1.8 +..B1.7: + negl %ecx + addl $30, %ecx + movl 8(%ebp), %eax + shrl %cl, %eax + shll %cl, %eax +..B1.8: + movl %eax, 8(%ebp) + fldt 8(%ebp) + movl %ebp, %esp + popl %ebp + ret +..B1.9: + testl %ecx, %ecx + jne ..B1.13 +..B1.10: + cmpl $0, 12(%ebp) + jne ..B1.12 +..B1.11: + cmpl $0, 8(%ebp) + je ..B1.13 +..B1.12: + fldl _smallest_value_64@GOTOFF(%eax) + fstpl (%esp) +..B1.13: + movzbl 17(%ebp), %edx + andl $128, %edx + shrl $7, %edx + fldl _zeros@GOTOFF(%eax,%edx,8) + movl %ebp, %esp + popl %ebp + ret +..B1.14: + movzwl 22(%esp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.15: + orl $-64768, %ecx + movw %cx, 20(%esp) +..B1.16: + fldcw 20(%esp) +..B1.17: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt 8(%esp) +..B1.18: + fldcw 22(%esp) +..B1.19: + fldt 8(%esp) + movl %ebp, %esp + popl %ebp + ret +..B1.20: + fldt 8(%ebp) + fmull _ones@GOTOFF(%eax) + fstpt 8(%esp) + jmp ..B1.19 + .align 16,0x90 + .type truncl,@function + .size truncl,.-truncl + .data +# -- End truncl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/y0.S b/external/sgx_libm/ia32/y0.S new file mode 100644 index 0000000000..168c36b27d --- /dev/null +++ b/external/sgx_libm/ia32/y0.S @@ -0,0 +1,3324 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y0.c" + .text +..TXTST0: +# -- Begin y0 + .text + .align 16,0x90 + .globl y0 +y0: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + subl $56, %esp +..B1.2: + fnstcw 14(%esp) +..B1.3: + movl 12(%ebp), %edx + movl %edx, %esi + andl $2147483647, %esi + call ..L2 +..L2: + popl %edi + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edi), %edi + cmpl $2146435072, %esi + jge ..B1.13 +..B1.4: + xorl %eax, %eax + movl 8(%ebp), %ecx + subl %eax, %edx + jl ..B1.20 +..B1.26: + orl %ecx, %edx + je ..B1.20 +..B1.5: + movzwl 14(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.19 +..B1.6: + orl $-64768, %edx + movw %dx, 12(%esp) +..B1.7: + fldcw 12(%esp) +..B1.8: + movl $1, %esi +..B1.9: + fldl 8(%ebp) + addl $-16, %esp + fstpt (%esp) + call __y0l. +..B1.27: + fstpt 16(%esp) + addl $16, %esp +..B1.10: + testl %esi, %esi + je ..B1.12 +..B1.11: + fldcw 14(%esp) +..B1.12: + fldt (%esp) + addl $56, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.13: + andl $-2146435073, %esi + orl 8(%ebp), %esi + jne ..B1.18 +..B1.14: + fldl _zeros@GOTOFF(%edi) + testl $-2147483648, %edx + je ..B1.17 +..B1.16: + fldl _infs@GOTOFF(%edi) + fmulp %st, %st(1) +..B1.17: + addl $56, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.18: + fldl 8(%ebp) + addl $56, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.19: + xorl %esi, %esi + jmp ..B1.9 +..B1.20: + fldl _zeros@GOTOFF(%edi) + orl %ecx, %esi + je ..B1.22 +..B1.21: + fldl _infs@GOTOFF(%edi) + fmulp %st, %st(1) + addl $56, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.22: + fldl 8+_ones@GOTOFF(%edi) + fdivp %st, %st(1) +..B1.23: + addl $56, %esp + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type y0,@function + .size y0,.-y0 + .data +# -- End y0 + .text +# -- Begin __y0l + .text + .align 16,0x90 + .hidden __y0l + .globl __y0l +__y0l: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + + .hidden __y0l. + .globl __y0l. +__y0l.: + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $120, %esp + fldt 8(%ebp) + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + fldt 132+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B2.22 +..B2.2: + fldt _val_0_6L@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B2.20 +..B2.3: + fldt _val_1_2L@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.5 +..B2.4: + fstp %st(0) + fldt _Z@GOTOFF(%ebx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt _P11@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P11@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt _Q11@GOTOFF(%ebx) + fmul %st(4), %st + fldt 12+_Q11@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 72+_P11@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 84+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 96+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 108+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_Q11@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt 120+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 132+_P11@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 144+_P11@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 156+_P11@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 36+_Q11@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 168+_P11@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fxch %st(1) + fdivrl _ones@GOTOFF(%ebx) + fldt 180+_P11@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fldt 192+_P11@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 204+_P11@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B2.27 +..B2.5: + fldt _S@GOTOFF(%ebx) + fcomp %st(2) + fnstsw %ax + sahf + jbe ..B2.7 +..B2.6: + fldt _P12@GOTOFF(%ebx) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fstpt 92(%esp) + fldt 92(%esp) + fldt 12+_P12@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 36+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 48+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 60+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 72+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 84+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 96+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 108+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 120+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 132+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 144+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 156+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 168+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 180+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 192+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 204+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 216+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 228+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 240+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 252+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 264+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 276+_P12@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 288+_P12@GOTOFF(%ebx) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt 300+_P12@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 312+_P12@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.7: + fstp %st(0) + fldt _val_3_0L@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.9 +..B2.8: + fldt 24+_P20@GOTOFF(%ebx) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt _P20@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(2) + fmul %st, %st(1) + fldt 12+_P20@GOTOFF(%ebx) + fmul %st(1), %st + fldt 36+_P20@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48+_P20@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 60+_P20@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 72+_P20@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 84+_P20@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 96+_P20@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 108+_P20@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 120+_P20@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 132+_P20@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 144+_P20@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 156+_P20@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 168+_P20@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 180+_P20@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt 192+_P20@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 204+_P20@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.9: + fstp %st(0) + fldt _val_3_875L@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B2.11 +..B2.10: + fldt _P21@GOTOFF(%ebx) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fstpt 92(%esp) + fldt 92(%esp) + fldt 12+_P21@GOTOFF(%ebx) + fmul %st(1), %st + fldt 24+_P21@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt 36+_P21@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 48+_P21@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 60+_P21@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 72+_P21@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 84+_P21@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 96+_P21@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 108+_P21@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 120+_P21@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 132+_P21@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 144+_P21@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 156+_P21@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt 168+_P21@GOTOFF(%ebx) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt 180+_P21@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 192+_P21@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.11: + fstp %st(0) + fldt 12+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B2.13 +..B2.12: + fldt 12+_Z@GOTOFF(%ebx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt _P22@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P22@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 168+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 180+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 192+_P22@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 204+_P22@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 216+_P22@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.13: + fldt 24+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B2.15 +..B2.14: + fldt 24+_Z@GOTOFF(%ebx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt _P3@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P3@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 168+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 180+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 192+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 204+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 216+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 228+_P3@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 240+_P3@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 252+_P3@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.15: + movl $3, %edx +..B2.16: + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %ecx + fldt _S@GOTOFF(%ebx,%ecx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B2.19 + jp ..B2.19 +..B2.17: + incl %edx + cmpl $11, %edx + jl ..B2.16 +..B2.18: + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx +..B2.19: + fldt _Z@GOTOFF(%ecx,%ebx) + movl %edx, %eax + fsubrp %st, %st(1) + shll $4, %eax + fld %st(0) + subl %edx, %eax + shll $4, %eax + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt -720+_P@GOTOFF(%eax,%ebx) + fmul %st(1), %st + fldt -708+_P@GOTOFF(%eax,%ebx) + fmul %st(2), %st + fldt -696+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -684+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -672+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -660+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -648+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -636+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -624+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -612+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -600+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -588+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -576+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -564+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -552+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -540+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -528+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -516+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -504+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -492+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.20: + fldt _P0@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(2) + fstpt 64(%esp) + fldt 64(%esp) + fxch %st(3) + fstpt 92(%esp) + fldt 92(%esp) + fxch %st(1) + fstpt (%esp) + fldt 12+_P0@GOTOFF(%ebx) + fmul %st(3), %st + fldt 24+_P0@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 36+_P0@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 48+_P0@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 60+_P0@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fldt 72+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt 84+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 32(%esp) + call __j0l@PLT +..B2.31: + fldt 8(%ebp) + fxch %st(1) + fstpt 48(%esp) + fldt 32(%esp) +..B2.21: + fxch %st(1) + fstpt (%esp) + fstpt 32(%esp) + call logl@PLT +..B2.32: + fldt 32(%esp) + fldt 48(%esp) + fldt _tonpi@GOTOFF(%ebx) + fmulp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + jmp ..B2.27 +..B2.22: + fldl _ones@GOTOFF(%ebx) + lea 92(%esp), %eax + fdiv %st(1), %st + lea 64(%esp), %edx + fxch %st(1) + fxch %st(1) + fstpt -60(%eax) + fldt -60(%eax) + fxch %st(1) + fstpt (%esp) + fldt _val_36_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt (%eax) + fldt (%eax) + movl %eax, 12(%esp) + movl %edx, 16(%esp) + movl $-1, 20(%esp) + fxch %st(1) + fstpt -28(%eax) + fldt -28(%eax) + fldt _PP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _QP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 96+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 108+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt -44(%eax) + fldt 108+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt -12(%eax) + call __libm_sincos_pi4l +..B2.23: + fldt 8(%ebp) + fldt 80(%esp) + fldt 48(%esp) + fldt 92(%esp) + fmulp %st, %st(1) + fldt 64(%esp) + fmulp %st, %st(2) + fadd %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt _val_0_03L@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B2.25 + jp ..B2.25 +..B2.24: + fstp %st(1) + fldt _tonpi@GOTOFF(%ebx) + fldt 32(%esp) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + jmp ..B2.27 +..B2.25: + fstp %st(0) + lea 32(%esp), %edi + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B2.34: + addl $-32, %esp + movl (%edi), %ecx + lea 80(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%edi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __y0q@PLT +..B2.33: + addl $28, %esp +..B2.26: + movl 48(%esp), %eax + movl %eax, (%edi) + movl 52(%esp), %edx + movl 56(%esp), %ecx + movl 60(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B2.27: + addl $120, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __y0l,@function + .size __y0l,.-__y0l + .data +# -- End __y0l + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_S: + .word 5921 + .word 65426 + .word 63142 + .word 35997 + .word 16384 + .word 0 + .word 29632 + .word 15745 + .word 62068 + .word 44479 + .word 16385 + .word 0 + .word 41288 + .word 2893 + .word 15731 + .word 35209 + .word 16386 + .word 0 + .word 12322 + .word 41360 + .word 35270 + .word 48124 + .word 16386 + .word 0 + .word 21828 + .word 62500 + .word 60486 + .word 61019 + .word 16386 + .word 0 + .word 54460 + .word 63729 + .word 58186 + .word 36952 + .word 16387 + .word 0 + .word 27250 + .word 3142 + .word 10825 + .word 43393 + .word 16387 + .word 0 + .word 20649 + .word 49414 + .word 53633 + .word 49831 + .word 16387 + .word 0 + .word 59160 + .word 26587 + .word 26484 + .word 56269 + .word 16387 + .word 0 + .word 57283 + .word 10561 + .word 16432 + .word 62706 + .word 16387 + .word 0 + .word 44243 + .word 51162 + .word 18495 + .word 34571 + .word 16388 + .word 0 + .word 63781 + .word 54231 + .word 15770 + .word 37789 + .word 16388 + .word 0 + .type _S,@object + .size _S,144 + .align 2 +_val_0_6L: + .word 39322 + .word 39321 + .word 39321 + .word 39321 + .word 16382 + .word 0 + .type _val_0_6L,@object + .size _val_0_6L,12 + .align 2 +_val_1_2L: + .word 39322 + .word 39321 + .word 39321 + .word 39321 + .word 16383 + .word 0 + .type _val_1_2L,@object + .size _val_1_2L,12 + .align 2 +_Z: + .word 20971 + .word 41151 + .word 30150 + .word 58561 + .word 16382 + .word 0 + .word 56848 + .word 49844 + .word 39532 + .word 64842 + .word 16384 + .word 0 + .word 5940 + .word 14600 + .word 60967 + .word 58048 + .word 16385 + .word 0 + .word 48233 + .word 9194 + .word 47533 + .word 41870 + .word 16386 + .word 0 + .word 19716 + .word 3898 + .word 3621 + .word 54727 + .word 16386 + .word 0 + .word 41547 + .word 400 + .word 58272 + .word 33793 + .word 16387 + .word 0 + .word 46312 + .word 65374 + .word 26362 + .word 40225 + .word 16387 + .word 0 + .word 15253 + .word 48480 + .word 38891 + .word 46657 + .word 16387 + .word 0 + .word 12158 + .word 16394 + .word 14239 + .word 53090 + .word 16387 + .word 0 + .word 31253 + .word 2914 + .word 8779 + .word 59523 + .word 16387 + .word 0 + .word 29606 + .word 9567 + .word 8455 + .word 32978 + .word 16388 + .word 0 + .word 51148 + .word 41491 + .word 50276 + .word 36194 + .word 16388 + .word 0 + .type _Z,@object + .size _Z,144 + .align 2 +_P11: + .word 21672 + .word 14168 + .word 38767 + .word 33539 + .word 49130 + .word 0 + .word 41169 + .word 50619 + .word 21849 + .word 37014 + .word 16364 + .word 0 + .word 55003 + .word 42793 + .word 44721 + .word 50737 + .word 49133 + .word 0 + .word 1169 + .word 13656 + .word 30890 + .word 57268 + .word 16366 + .word 0 + .word 2761 + .word 22275 + .word 55697 + .word 58639 + .word 49135 + .word 0 + .word 63624 + .word 9235 + .word 64995 + .word 56818 + .word 16368 + .word 0 + .word 62376 + .word 14952 + .word 24232 + .word 50456 + .word 49137 + .word 0 + .word 35764 + .word 14862 + .word 11423 + .word 44812 + .word 16370 + .word 0 + .word 799 + .word 749 + .word 44421 + .word 44099 + .word 49140 + .word 0 + .word 57800 + .word 45157 + .word 3532 + .word 40524 + .word 16373 + .word 0 + .word 54824 + .word 35595 + .word 46140 + .word 46550 + .word 16376 + .word 0 + .word 57927 + .word 14014 + .word 38764 + .word 61194 + .word 49142 + .word 0 + .word 31025 + .word 58986 + .word 13056 + .word 57752 + .word 49148 + .word 0 + .word 25304 + .word 41780 + .word 21387 + .word 41754 + .word 49148 + .word 0 + .word 38881 + .word 54183 + .word 37931 + .word 34827 + .word 16383 + .word 0 + .word 19650 + .word 12565 + .word 569 + .word 58514 + .word 16383 + .word 0 + .word 23916 + .word 27820 + .word 49726 + .word 50434 + .word 16382 + .word 0 + .word 37686 + .word 17141 + .word 5720 + .word 38948 + .word 16317 + .word 0 + .type _P11,@object + .size _P11,216 + .align 2 +_Q11: + .word 14194 + .word 21345 + .word 52686 + .word 49437 + .word 16382 + .word 0 + .word 16969 + .word 59638 + .word 1826 + .word 39310 + .word 16384 + .word 0 + .word 28926 + .word 48282 + .word 1364 + .word 41291 + .word 16384 + .word 0 + .word 13574 + .word 15497 + .word 63728 + .word 57349 + .word 16382 + .word 0 + .type _Q11,@object + .size _Q11,48 + .align 2 +_P12: + .word 59330 + .word 22263 + .word 34178 + .word 51006 + .word 49126 + .word 0 + .word 16861 + .word 21193 + .word 35273 + .word 46715 + .word 16362 + .word 0 + .word 2103 + .word 12628 + .word 1838 + .word 41114 + .word 49133 + .word 0 + .word 46148 + .word 53581 + .word 46203 + .word 46468 + .word 16367 + .word 0 + .word 19710 + .word 1268 + .word 64842 + .word 38086 + .word 49137 + .word 0 + .word 10276 + .word 59226 + .word 39596 + .word 48586 + .word 16370 + .word 0 + .word 31029 + .word 64049 + .word 23137 + .word 50693 + .word 49139 + .word 0 + .word 22014 + .word 1854 + .word 56980 + .word 45052 + .word 16372 + .word 0 + .word 12740 + .word 38047 + .word 44756 + .word 35383 + .word 49141 + .word 0 + .word 9689 + .word 42893 + .word 35756 + .word 50848 + .word 16373 + .word 0 + .word 16570 + .word 20820 + .word 51546 + .word 34499 + .word 49142 + .word 0 + .word 49962 + .word 36228 + .word 57995 + .word 45370 + .word 16374 + .word 0 + .word 32489 + .word 35981 + .word 43312 + .word 58898 + .word 49142 + .word 0 + .word 10311 + .word 12657 + .word 16405 + .word 38148 + .word 16375 + .word 0 + .word 32504 + .word 29604 + .word 49577 + .word 49580 + .word 49143 + .word 0 + .word 65322 + .word 54336 + .word 27403 + .word 64825 + .word 16375 + .word 0 + .word 33227 + .word 51353 + .word 11288 + .word 42704 + .word 49144 + .word 0 + .word 30209 + .word 39595 + .word 16790 + .word 56786 + .word 16376 + .word 0 + .word 17645 + .word 4926 + .word 40100 + .word 38165 + .word 49145 + .word 0 + .word 6983 + .word 2488 + .word 5292 + .word 51990 + .word 16377 + .word 0 + .word 4652 + .word 21592 + .word 9570 + .word 36478 + .word 49146 + .word 0 + .word 53361 + .word 14763 + .word 26464 + .word 52381 + .word 16378 + .word 0 + .word 50485 + .word 35307 + .word 30503 + .word 59794 + .word 49146 + .word 0 + .word 18614 + .word 21402 + .word 49824 + .word 37715 + .word 16379 + .word 0 + .word 55547 + .word 61092 + .word 564 + .word 48870 + .word 49149 + .word 0 + .word 9082 + .word 24716 + .word 52021 + .word 40706 + .word 16382 + .word 0 + .word 17305 + .word 30912 + .word 47308 + .word 59790 + .word 16380 + .word 0 + .type _P12,@object + .size _P12,324 + .align 2 +_val_3_0L: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .type _val_3_0L,@object + .size _val_3_0L,12 + .align 2 +_P20: + .word 37654 + .word 4018 + .word 25149 + .word 64448 + .word 16354 + .word 0 + .word 19189 + .word 12397 + .word 54733 + .word 33028 + .word 16357 + .word 0 + .word 22349 + .word 41220 + .word 13172 + .word 45200 + .word 16358 + .word 0 + .word 43891 + .word 61784 + .word 34756 + .word 53833 + .word 16358 + .word 0 + .word 23592 + .word 62506 + .word 40671 + .word 50152 + .word 16359 + .word 0 + .word 27771 + .word 49376 + .word 49653 + .word 53593 + .word 49126 + .word 0 + .word 29892 + .word 65375 + .word 48818 + .word 47355 + .word 16361 + .word 0 + .word 33664 + .word 20071 + .word 46988 + .word 35237 + .word 49131 + .word 0 + .word 40179 + .word 47562 + .word 27113 + .word 46088 + .word 16364 + .word 0 + .word 39977 + .word 33568 + .word 2856 + .word 39237 + .word 49134 + .word 0 + .word 22462 + .word 11227 + .word 63692 + .word 48552 + .word 16369 + .word 0 + .word 9895 + .word 49985 + .word 29445 + .word 35598 + .word 49139 + .word 0 + .word 41034 + .word 13031 + .word 20740 + .word 35245 + .word 49142 + .word 0 + .word 32927 + .word 48253 + .word 43 + .word 37376 + .word 16375 + .word 0 + .word 5109 + .word 58801 + .word 31733 + .word 33042 + .word 16379 + .word 0 + .word 34717 + .word 51477 + .word 15888 + .word 35209 + .word 49148 + .word 0 + .word 4166 + .word 43043 + .word 47592 + .word 42555 + .word 49149 + .word 0 + .word 20077 + .word 289 + .word 31753 + .word 49394 + .word 16381 + .word 0 + .type _P20,@object + .size _P20,216 + .align 2 +_val_3_875L: + .word 0 + .word 0 + .word 0 + .word 63488 + .word 16384 + .word 0 + .type _val_3_875L,@object + .size _val_3_875L,12 + .align 2 +_P21: + .word 27895 + .word 14185 + .word 11256 + .word 61473 + .word 49117 + .word 0 + .word 55110 + .word 27090 + .word 21413 + .word 51858 + .word 49119 + .word 0 + .word 47481 + .word 51958 + .word 45685 + .word 44708 + .word 49121 + .word 0 + .word 53606 + .word 43192 + .word 10601 + .word 36675 + .word 49120 + .word 0 + .word 9703 + .word 39697 + .word 3773 + .word 54687 + .word 49123 + .word 0 + .word 39016 + .word 46259 + .word 57439 + .word 47927 + .word 16357 + .word 0 + .word 18601 + .word 64800 + .word 43294 + .word 45654 + .word 49126 + .word 0 + .word 11755 + .word 20846 + .word 12691 + .word 36847 + .word 49129 + .word 0 + .word 34925 + .word 21969 + .word 12496 + .word 40232 + .word 49133 + .word 0 + .word 33074 + .word 22131 + .word 45345 + .word 58077 + .word 16368 + .word 0 + .word 28402 + .word 30562 + .word 17788 + .word 44258 + .word 16370 + .word 0 + .word 64431 + .word 22682 + .word 21098 + .word 38133 + .word 49142 + .word 0 + .word 38064 + .word 47115 + .word 9737 + .word 49752 + .word 49143 + .word 0 + .word 32940 + .word 23551 + .word 17164 + .word 63584 + .word 16378 + .word 0 + .word 20289 + .word 55054 + .word 36724 + .word 37823 + .word 16378 + .word 0 + .word 46434 + .word 29308 + .word 2375 + .word 53705 + .word 49149 + .word 0 + .word 16931 + .word 9593 + .word 51956 + .word 35227 + .word 16378 + .word 0 + .type _P21,@object + .size _P21,204 + .align 2 +_P22: + .word 40244 + .word 7737 + .word 8636 + .word 43048 + .word 49106 + .word 0 + .word 47822 + .word 28463 + .word 39991 + .word 46660 + .word 16342 + .word 0 + .word 52293 + .word 15799 + .word 45377 + .word 51162 + .word 49113 + .word 0 + .word 37860 + .word 10494 + .word 27911 + .word 39108 + .word 16348 + .word 0 + .word 1970 + .word 24596 + .word 57275 + .word 48105 + .word 49118 + .word 0 + .word 64547 + .word 28877 + .word 41771 + .word 52711 + .word 16352 + .word 0 + .word 63459 + .word 4647 + .word 40018 + .word 64048 + .word 49122 + .word 0 + .word 38817 + .word 50313 + .word 34514 + .word 41599 + .word 16357 + .word 0 + .word 6873 + .word 59727 + .word 11575 + .word 48044 + .word 49125 + .word 0 + .word 29515 + .word 62000 + .word 64058 + .word 40336 + .word 49129 + .word 0 + .word 47818 + .word 19180 + .word 47066 + .word 42033 + .word 49133 + .word 0 + .word 35527 + .word 6093 + .word 4081 + .word 54678 + .word 16368 + .word 0 + .word 16787 + .word 50723 + .word 15144 + .word 52417 + .word 16370 + .word 0 + .word 27442 + .word 31785 + .word 24103 + .word 36633 + .word 49142 + .word 0 + .word 6233 + .word 52232 + .word 32482 + .word 57483 + .word 49143 + .word 0 + .word 59606 + .word 43125 + .word 44255 + .word 61366 + .word 16378 + .word 0 + .word 29998 + .word 6975 + .word 18760 + .word 53326 + .word 16378 + .word 0 + .word 24786 + .word 2384 + .word 4789 + .word 52762 + .word 49149 + .word 0 + .word 34816 + .word 30902 + .word 22802 + .word 44066 + .word 49086 + .word 0 + .type _P22,@object + .size _P22,228 + .align 2 +_P3: + .word 38373 + .word 25081 + .word 52784 + .word 41269 + .word 16319 + .word 0 + .word 2433 + .word 58494 + .word 34093 + .word 49310 + .word 49089 + .word 0 + .word 20384 + .word 14386 + .word 32743 + .word 56565 + .word 16322 + .word 0 + .word 12279 + .word 3882 + .word 34299 + .word 37877 + .word 49096 + .word 0 + .word 57529 + .word 46240 + .word 60154 + .word 40126 + .word 16332 + .word 0 + .word 46223 + .word 16522 + .word 54101 + .word 39334 + .word 16335 + .word 0 + .word 17152 + .word 52627 + .word 55415 + .word 33597 + .word 49108 + .word 0 + .word 46957 + .word 15713 + .word 64890 + .word 47269 + .word 49111 + .word 0 + .word 63416 + .word 7921 + .word 11783 + .word 63655 + .word 16347 + .word 0 + .word 22182 + .word 52374 + .word 10257 + .word 64822 + .word 16350 + .word 0 + .word 20533 + .word 18718 + .word 7837 + .word 41493 + .word 49123 + .word 0 + .word 34870 + .word 43221 + .word 2667 + .word 34068 + .word 49126 + .word 0 + .word 62446 + .word 64657 + .word 15033 + .word 39509 + .word 16362 + .word 0 + .word 31017 + .word 38768 + .word 5018 + .word 46409 + .word 16364 + .word 0 + .word 37858 + .word 10529 + .word 62079 + .word 49339 + .word 49136 + .word 0 + .word 60794 + .word 51427 + .word 47345 + .word 37742 + .word 49138 + .word 0 + .word 8999 + .word 61205 + .word 62511 + .word 36506 + .word 16374 + .word 0 + .word 22683 + .word 43326 + .word 42314 + .word 55672 + .word 16374 + .word 0 + .word 37536 + .word 24482 + .word 58150 + .word 50356 + .word 49146 + .word 0 + .word 47735 + .word 57962 + .word 45199 + .word 44407 + .word 49145 + .word 0 + .word 54502 + .word 19410 + .word 25859 + .word 39334 + .word 16381 + .word 0 + .word 1861 + .word 57822 + .word 27975 + .word 42824 + .word 49086 + .word 0 + .type _P3,@object + .size _P3,264 + .align 2 +_P: + .word 6710 + .word 46975 + .word 45541 + .word 45018 + .word 16323 + .word 0 + .word 47994 + .word 32334 + .word 52627 + .word 65214 + .word 16326 + .word 0 + .word 25829 + .word 961 + .word 45314 + .word 63623 + .word 49099 + .word 0 + .word 56740 + .word 896 + .word 13408 + .word 40400 + .word 49103 + .word 0 + .word 60385 + .word 50719 + .word 53670 + .word 35961 + .word 16340 + .word 0 + .word 18363 + .word 40724 + .word 30788 + .word 37641 + .word 16343 + .word 0 + .word 54199 + .word 26560 + .word 1100 + .word 63052 + .word 49115 + .word 0 + .word 31112 + .word 47384 + .word 24910 + .word 52460 + .word 49118 + .word 0 + .word 62051 + .word 62630 + .word 7457 + .word 41285 + .word 16355 + .word 0 + .word 41021 + .word 16553 + .word 53133 + .word 51701 + .word 16357 + .word 0 + .word 43336 + .word 19494 + .word 20322 + .word 38261 + .word 49130 + .word 0 + .word 44128 + .word 40851 + .word 40287 + .word 33282 + .word 49132 + .word 0 + .word 15978 + .word 61692 + .word 60093 + .word 46462 + .word 16368 + .word 0 + .word 34924 + .word 34591 + .word 27618 + .word 49090 + .word 16369 + .word 0 + .word 22325 + .word 56457 + .word 51367 + .word 65297 + .word 49141 + .word 0 + .word 21258 + .word 62600 + .word 63264 + .word 33170 + .word 49142 + .word 0 + .word 31459 + .word 43701 + .word 15672 + .word 42803 + .word 16378 + .word 0 + .word 10392 + .word 64190 + .word 8847 + .word 51227 + .word 16376 + .word 0 + .word 34244 + .word 38351 + .word 44643 + .word 65457 + .word 49148 + .word 0 + .word 24705 + .word 53181 + .word 1549 + .word 55232 + .word 16319 + .word 0 + .word 24274 + .word 2157 + .word 59872 + .word 44641 + .word 49091 + .word 0 + .word 44404 + .word 52032 + .word 31206 + .word 56185 + .word 49094 + .word 0 + .word 42376 + .word 53700 + .word 44782 + .word 63474 + .word 16331 + .word 0 + .word 55880 + .word 43379 + .word 3093 + .word 34064 + .word 16335 + .word 0 + .word 62288 + .word 61979 + .word 24976 + .word 35576 + .word 49108 + .word 0 + .word 30673 + .word 34148 + .word 2010 + .word 61956 + .word 49110 + .word 0 + .word 45192 + .word 28065 + .word 60055 + .word 61722 + .word 16347 + .word 0 + .word 24582 + .word 59932 + .word 774 + .word 41831 + .word 16350 + .word 0 + .word 39741 + .word 15639 + .word 29541 + .word 39821 + .word 49123 + .word 0 + .word 32965 + .word 53765 + .word 3652 + .word 39681 + .word 49125 + .word 0 + .word 55274 + .word 5931 + .word 14729 + .word 36200 + .word 16362 + .word 0 + .word 4659 + .word 41741 + .word 5124 + .word 48783 + .word 16363 + .word 0 + .word 61896 + .word 13936 + .word 31722 + .word 42885 + .word 49136 + .word 0 + .word 29587 + .word 13947 + .word 35938 + .word 34351 + .word 49137 + .word 0 + .word 30548 + .word 42185 + .word 15217 + .word 58709 + .word 16373 + .word 0 + .word 32944 + .word 45803 + .word 62008 + .word 44929 + .word 16373 + .word 0 + .word 15543 + .word 17819 + .word 22981 + .word 37733 + .word 49146 + .word 0 + .word 40787 + .word 12944 + .word 27687 + .word 34273 + .word 49144 + .word 0 + .word 14474 + .word 51712 + .word 20794 + .word 57241 + .word 16380 + .word 0 + .word 31505 + .word 44115 + .word 25843 + .word 56405 + .word 49084 + .word 0 + .word 29537 + .word 33343 + .word 23367 + .word 43948 + .word 16323 + .word 0 + .word 15837 + .word 34931 + .word 8097 + .word 48214 + .word 16326 + .word 0 + .word 1126 + .word 23018 + .word 59367 + .word 62418 + .word 49099 + .word 0 + .word 50591 + .word 16203 + .word 45917 + .word 57446 + .word 49102 + .word 0 + .word 6095 + .word 44294 + .word 16725 + .word 34699 + .word 16340 + .word 0 + .word 2346 + .word 25530 + .word 14073 + .word 51139 + .word 16342 + .word 0 + .word 48724 + .word 10078 + .word 7882 + .word 59578 + .word 49115 + .word 0 + .word 3077 + .word 7734 + .word 24746 + .word 33688 + .word 49118 + .word 0 + .word 52085 + .word 9505 + .word 49832 + .word 37954 + .word 16355 + .word 0 + .word 41663 + .word 47247 + .word 238 + .word 62191 + .word 16356 + .word 0 + .word 48361 + .word 39255 + .word 14492 + .word 33999 + .word 49130 + .word 0 + .word 35816 + .word 34414 + .word 54424 + .word 37185 + .word 49131 + .word 0 + .word 20077 + .word 189 + .word 48758 + .word 39656 + .word 16368 + .word 0 + .word 35728 + .word 48114 + .word 41225 + .word 51144 + .word 16368 + .word 0 + .word 10943 + .word 64308 + .word 2314 + .word 53541 + .word 49141 + .word 0 + .word 32154 + .word 56468 + .word 40039 + .word 32925 + .word 49141 + .word 0 + .word 4941 + .word 52917 + .word 35073 + .word 34082 + .word 16378 + .word 0 + .word 61194 + .word 15048 + .word 42139 + .word 49938 + .word 16375 + .word 0 + .word 19128 + .word 18289 + .word 6860 + .word 51502 + .word 49148 + .word 0 + .word 49300 + .word 58708 + .word 59005 + .word 55071 + .word 16319 + .word 0 + .word 26502 + .word 47642 + .word 36933 + .word 42964 + .word 49091 + .word 0 + .word 30051 + .word 60756 + .word 30625 + .word 41460 + .word 49094 + .word 0 + .word 61015 + .word 15762 + .word 48007 + .word 60846 + .word 16331 + .word 0 + .word 21975 + .word 20753 + .word 22643 + .word 48677 + .word 16334 + .word 0 + .word 54246 + .word 4624 + .word 38600 + .word 33572 + .word 49108 + .word 0 + .word 59379 + .word 53723 + .word 32353 + .word 42607 + .word 49110 + .word 0 + .word 40791 + .word 16038 + .word 57576 + .word 57139 + .word 16347 + .word 0 + .word 25939 + .word 3603 + .word 54023 + .word 55128 + .word 16349 + .word 0 + .word 7176 + .word 58381 + .word 25669 + .word 36047 + .word 49123 + .word 0 + .word 23057 + .word 6107 + .word 22526 + .word 49962 + .word 49124 + .word 0 + .word 19351 + .word 39386 + .word 35003 + .word 63923 + .word 16361 + .word 0 + .word 45293 + .word 12882 + .word 9948 + .word 58748 + .word 16362 + .word 0 + .word 20001 + .word 20829 + .word 53529 + .word 36918 + .word 49136 + .word 0 + .word 21919 + .word 49831 + .word 37577 + .word 39856 + .word 49136 + .word 0 + .word 47026 + .word 46471 + .word 55318 + .word 49443 + .word 16373 + .word 0 + .word 61519 + .word 51459 + .word 6950 + .word 50870 + .word 16372 + .word 0 + .word 1555 + .word 2971 + .word 23597 + .word 62610 + .word 49145 + .word 0 + .word 45926 + .word 36681 + .word 39043 + .word 38451 + .word 49143 + .word 0 + .word 64160 + .word 21923 + .word 31542 + .word 47202 + .word 16380 + .word 0 + .word 36569 + .word 36429 + .word 41036 + .word 40257 + .word 49085 + .word 0 + .word 63272 + .word 57206 + .word 4215 + .word 41813 + .word 16323 + .word 0 + .word 38880 + .word 42175 + .word 14999 + .word 35837 + .word 16326 + .word 0 + .word 42787 + .word 9806 + .word 63168 + .word 59020 + .word 49099 + .word 0 + .word 31095 + .word 14929 + .word 48209 + .word 41580 + .word 49102 + .word 0 + .word 36413 + .word 27679 + .word 45695 + .word 64718 + .word 16339 + .word 0 + .word 24761 + .word 31380 + .word 27544 + .word 35930 + .word 16342 + .word 0 + .word 11221 + .word 62995 + .word 50975 + .word 54692 + .word 49115 + .word 0 + .word 29668 + .word 1933 + .word 17144 + .word 45888 + .word 49117 + .word 0 + .word 30810 + .word 24149 + .word 32113 + .word 34254 + .word 16355 + .word 0 + .word 34856 + .word 24408 + .word 21475 + .word 41075 + .word 16356 + .word 0 + .word 33943 + .word 23810 + .word 62559 + .word 60314 + .word 49129 + .word 0 + .word 3305 + .word 24934 + .word 37437 + .word 47776 + .word 49130 + .word 0 + .word 54895 + .word 55211 + .word 32000 + .word 34613 + .word 16368 + .word 0 + .word 35009 + .word 47065 + .word 21660 + .word 64281 + .word 16367 + .word 0 + .word 9852 + .word 9156 + .word 55656 + .word 46121 + .word 49141 + .word 0 + .word 36442 + .word 41210 + .word 20060 + .word 40802 + .word 49140 + .word 0 + .word 21758 + .word 47322 + .word 2788 + .word 58210 + .word 16377 + .word 0 + .word 52348 + .word 9004 + .word 18276 + .word 61559 + .word 16374 + .word 0 + .word 54786 + .word 7147 + .word 27070 + .word 43826 + .word 49148 + .word 0 + .word 34268 + .word 15768 + .word 2480 + .word 60089 + .word 49085 + .word 0 + .word 1157 + .word 52048 + .word 20458 + .word 40588 + .word 49091 + .word 0 + .word 51540 + .word 48806 + .word 47292 + .word 62380 + .word 49093 + .word 0 + .word 19999 + .word 57758 + .word 46120 + .word 57112 + .word 16331 + .word 0 + .word 21459 + .word 54484 + .word 23863 + .word 35854 + .word 16334 + .word 0 + .word 28754 + .word 5362 + .word 55327 + .word 62303 + .word 49107 + .word 0 + .word 45243 + .word 6687 + .word 17114 + .word 61365 + .word 49109 + .word 0 + .word 32048 + .word 1009 + .word 39781 + .word 52368 + .word 16347 + .word 0 + .word 64584 + .word 3308 + .word 26412 + .word 38818 + .word 16349 + .word 0 + .word 23088 + .word 38547 + .word 22659 + .word 65247 + .word 49122 + .word 0 + .word 14061 + .word 22418 + .word 61292 + .word 34447 + .word 49124 + .word 0 + .word 57848 + .word 26921 + .word 61797 + .word 57155 + .word 16361 + .word 0 + .word 1597 + .word 31414 + .word 38572 + .word 39774 + .word 16362 + .word 0 + .word 30034 + .word 27108 + .word 16687 + .word 65316 + .word 49135 + .word 0 + .word 32265 + .word 44536 + .word 9779 + .word 53216 + .word 49135 + .word 0 + .word 550 + .word 16407 + .word 19715 + .word 43369 + .word 16373 + .word 0 + .word 7132 + .word 1973 + .word 39654 + .word 33659 + .word 16372 + .word 0 + .word 19090 + .word 42384 + .word 19608 + .word 54616 + .word 49145 + .word 0 + .word 29916 + .word 8899 + .word 53582 + .word 50715 + .word 49142 + .word 0 + .word 63987 + .word 34002 + .word 32751 + .word 41084 + .word 16380 + .word 0 + .word 31930 + .word 50610 + .word 35321 + .word 40669 + .word 49085 + .word 0 + .word 64556 + .word 32042 + .word 47688 + .word 39353 + .word 16323 + .word 0 + .word 22761 + .word 33268 + .word 25802 + .word 54704 + .word 16325 + .word 0 + .word 48596 + .word 35082 + .word 36228 + .word 55222 + .word 49099 + .word 0 + .word 62834 + .word 26257 + .word 62649 + .word 62428 + .word 49101 + .word 0 + .word 22216 + .word 57771 + .word 11637 + .word 59993 + .word 16339 + .word 0 + .word 32841 + .word 24077 + .word 25618 + .word 53031 + .word 16341 + .word 0 + .word 7134 + .word 15474 + .word 25724 + .word 50216 + .word 49115 + .word 0 + .word 679 + .word 61058 + .word 8963 + .word 33314 + .word 49117 + .word 0 + .word 30607 + .word 23707 + .word 50236 + .word 62315 + .word 16354 + .word 0 + .word 57112 + .word 44811 + .word 22996 + .word 58760 + .word 16355 + .word 0 + .word 7925 + .word 14145 + .word 19419 + .word 54389 + .word 49129 + .word 0 + .word 15063 + .word 11101 + .word 53306 + .word 33747 + .word 49130 + .word 0 + .word 17212 + .word 63840 + .word 49608 + .word 61962 + .word 16367 + .word 0 + .word 64221 + .word 2367 + .word 56115 + .word 44976 + .word 16367 + .word 0 + .word 25958 + .word 42476 + .word 21228 + .word 41045 + .word 49141 + .word 0 + .word 39160 + .word 29939 + .word 20970 + .word 56757 + .word 49139 + .word 0 + .word 34212 + .word 35958 + .word 8729 + .word 51611 + .word 16377 + .word 0 + .word 47817 + .word 56326 + .word 46415 + .word 42719 + .word 16374 + .word 0 + .word 14697 + .word 51278 + .word 14116 + .word 38800 + .word 49148 + .word 0 + .word 42056 + .word 1202 + .word 6817 + .word 52251 + .word 16319 + .word 0 + .word 9811 + .word 3897 + .word 54180 + .word 38147 + .word 49091 + .word 0 + .word 22279 + .word 36400 + .word 23268 + .word 48339 + .word 49093 + .word 0 + .word 3604 + .word 63501 + .word 23839 + .word 53404 + .word 16331 + .word 0 + .word 1179 + .word 37183 + .word 50892 + .word 54850 + .word 16333 + .word 0 + .word 59751 + .word 27404 + .word 14795 + .word 57826 + .word 49107 + .word 0 + .word 14718 + .word 11779 + .word 34360 + .word 46330 + .word 49109 + .word 0 + .word 59705 + .word 41619 + .word 32041 + .word 48245 + .word 16347 + .word 0 + .word 23030 + .word 54615 + .word 27535 + .word 57905 + .word 16348 + .word 0 + .word 39169 + .word 62610 + .word 58529 + .word 59687 + .word 49122 + .word 0 + .word 51398 + .word 44311 + .word 12717 + .word 50833 + .word 49123 + .word 0 + .word 27431 + .word 2954 + .word 22657 + .word 51954 + .word 16361 + .word 0 + .word 58296 + .word 29685 + .word 27243 + .word 58169 + .word 16361 + .word 0 + .word 51216 + .word 48206 + .word 42318 + .word 59054 + .word 49135 + .word 0 + .word 56132 + .word 37000 + .word 55250 + .word 38652 + .word 49135 + .word 0 + .word 33362 + .word 39562 + .word 49329 + .word 39051 + .word 16373 + .word 0 + .word 45334 + .word 5673 + .word 58520 + .word 48690 + .word 16371 + .word 0 + .word 35653 + .word 20625 + .word 33642 + .word 49050 + .word 49145 + .word 0 + .word 58051 + .word 8993 + .word 6809 + .word 36624 + .word 49142 + .word 0 + .word 52356 + .word 59873 + .word 62958 + .word 36858 + .word 16380 + .word 0 + .word 32142 + .word 25405 + .word 33867 + .word 33307 + .word 16319 + .word 0 + .word 49519 + .word 13151 + .word 56037 + .word 36991 + .word 16323 + .word 0 + .word 44868 + .word 63207 + .word 24006 + .word 43028 + .word 16325 + .word 0 + .word 8083 + .word 45145 + .word 39702 + .word 51683 + .word 49099 + .word 0 + .word 45111 + .word 52725 + .word 38011 + .word 48603 + .word 49101 + .word 0 + .word 60521 + .word 20244 + .word 23464 + .word 55814 + .word 16339 + .word 0 + .word 20556 + .word 16261 + .word 38082 + .word 40872 + .word 16341 + .word 0 + .word 25337 + .word 58099 + .word 56911 + .word 46447 + .word 49115 + .word 0 + .word 37285 + .word 19168 + .word 56812 + .word 50878 + .word 49116 + .word 0 + .word 15949 + .word 20065 + .word 40118 + .word 57328 + .word 16354 + .word 0 + .word 40507 + .word 40248 + .word 14830 + .word 44509 + .word 16355 + .word 0 + .word 5104 + .word 24529 + .word 29756 + .word 49797 + .word 49129 + .word 0 + .word 46472 + .word 25780 + .word 5432 + .word 50788 + .word 49129 + .word 0 + .word 15446 + .word 10547 + .word 15373 + .word 56506 + .word 16367 + .word 0 + .word 3213 + .word 104 + .word 59551 + .word 33676 + .word 16367 + .word 0 + .word 34009 + .word 54843 + .word 32265 + .word 37318 + .word 49141 + .word 0 + .word 45472 + .word 58672 + .word 64591 + .word 42366 + .word 49139 + .word 0 + .word 32200 + .word 21528 + .word 8481 + .word 46835 + .word 16377 + .word 0 + .word 49716 + .word 3176 + .word 29068 + .word 63703 + .word 16373 + .word 0 + .word 39156 + .word 24341 + .word 43754 + .word 35182 + .word 49148 + .word 0 + .word 61730 + .word 30329 + .word 55010 + .word 38388 + .word 16320 + .word 0 + .type _P,@object + .size _P,2160 + .align 2 +_P0: + .word 46060 + .word 21479 + .word 19707 + .word 37102 + .word 16345 + .word 0 + .word 35676 + .word 11242 + .word 15120 + .word 54134 + .word 49120 + .word 0 + .word 34641 + .word 49003 + .word 21090 + .word 56946 + .word 16359 + .word 0 + .word 36501 + .word 52298 + .word 48288 + .word 40780 + .word 49134 + .word 0 + .word 2947 + .word 56486 + .word 859 + .word 36145 + .word 16372 + .word 0 + .word 6106 + .word 41115 + .word 36319 + .word 33709 + .word 49145 + .word 0 + .word 13230 + .word 6676 + .word 23048 + .word 46558 + .word 16380 + .word 0 + .word 62532 + .word 24192 + .word 46286 + .word 38694 + .word 49147 + .word 0 + .type _P0,@object + .size _P0,96 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .type _tonpi,@object + .size _tonpi,12 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,12 + .align 2 +_PP: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP,@object + .size _PP,120 + .align 2 +_QP: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .type _QP,@object + .size _QP,120 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,12 + .data + .hidden __libm_sincos_pi4l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/y0f.S b/external/sgx_libm/ia32/y0f.S new file mode 100644 index 0000000000..0a7690f452 --- /dev/null +++ b/external/sgx_libm/ia32/y0f.S @@ -0,0 +1,805 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y0f.c" + .text +..TXTST0: +# -- Begin y0f + .text + .align 16,0x90 + .globl y0f +y0f: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %ebx + subl $124, %esp + movl 8(%ebp), %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea -1(%edx), %eax + cmpl $2139095039, %eax + jae ..B1.21 +..B1.2: + cmpl $1099978979, %edx + jae ..B1.19 +..B1.3: + cmpl $1094450314, %edx + jae ..B1.15 +..B1.4: + cmpl $1085128690, %edx + jae ..B1.11 +..B1.5: + cmpl $1074568695, %edx + jae ..B1.10 +..B1.6: + cmpl $1058642330, %edx + jae ..B1.9 +..B1.7: + flds 8(%ebp) + fstl (%esp) + fstpl 32(%esp) + call __libm_log_k32 +..B1.31: + fldl 32(%esp) +..B1.8: + fldl _tonpi@GOTOFF(%ebx) + fmulp %st, %st(2) + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fldl 32+_Q1@GOTOFF(%ebx) + fmul %st(1), %st + fldl 24+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 16+_Q1@GOTOFF(%ebx) + fmul %st(2), %st + fxch %st(1) + faddl 8+_Q1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl _Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fldl 24+_Q2@GOTOFF(%ebx) + fmul %st(2), %st + fldl 16+_Q2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 8+_Q2@GOTOFF(%ebx) + fmulp %st, %st(3) + faddl _Q2@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.9: + flds 8(%ebp) + fldl 160+_P1@GOTOFF(%ebx) + fldl 144+_P1@GOTOFF(%ebx) + fldl 152+_P1@GOTOFF(%ebx) + fldl 136+_P1@GOTOFF(%ebx) + fxch %st(4) + fsubl 168+_P1@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 128+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 112+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 96+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 80+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 64+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 48+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 32+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 16+_P1@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 120+_P1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(5) + faddl 104+_P1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(5) + faddl 88+_P1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(5) + faddl 72+_P1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(5) + faddl 56+_P1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(3) + faddl _P1@GOTOFF(%ebx) + fxch %st(5) + faddl 40+_P1@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(2) + faddl 24+_P1@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(1), %st + fxch %st(2) + faddl 8+_P1@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.10: + flds 8(%ebp) + fldl 136+_P2@GOTOFF(%ebx) + fldl 120+_P2@GOTOFF(%ebx) + fldl 128+_P2@GOTOFF(%ebx) + fldl 112+_P2@GOTOFF(%ebx) + fxch %st(4) + fsubl 144+_P2@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 104+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 88+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 72+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 56+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 40+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 24+_P2@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(2), %st + fxch %st(4) + faddl 8+_P2@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + faddl 96+_P2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 80+_P2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 64+_P2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 48+_P2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 32+_P2@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(3) + faddl 16+_P2@GOTOFF(%ebx) + fmulp %st, %st(1) + fxch %st(1) + faddl _P2@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.11: + cmpl $1091143997, %edx + jae ..B1.13 +..B1.12: + lea _P3@GOTOFF(%ebx), %eax + jmp ..B1.14 +..B1.13: + lea _P4@GOTOFF(%ebx), %eax +..B1.14: + flds 8(%ebp) + fldl 104(%eax) + fldl 88(%eax) + fldl 96(%eax) + fldl 80(%eax) + fxch %st(4) + fsubl 112(%eax) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 72(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 56(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 40(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 24(%eax) + fmul %st(1), %st + fmul %st(2), %st + fxch %st(4) + faddl 8(%eax) + fmulp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + faddl 64(%eax) + fmul %st(3), %st + fxch %st(4) + faddl 48(%eax) + fmul %st(3), %st + fxch %st(4) + faddl 32(%eax) + fmulp %st, %st(3) + fxch %st(3) + faddl 16(%eax) + fmulp %st, %st(1) + fxch %st(1) + faddl (%eax) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.15: + cmpl $1097751532, %edx + jae ..B1.17 +..B1.16: + lea _P5@GOTOFF(%ebx), %eax + jmp ..B1.18 +..B1.17: + lea _P6@GOTOFF(%ebx), %eax +..B1.18: + flds 8(%ebp) + fldl 80(%eax) + fldl 96(%eax) + fldl 88(%eax) + fldl 72(%eax) + fxch %st(4) + fsubl 104(%eax) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(3) + fmul %st, %st(4) + fmul %st, %st(6) + fxch %st(5) + faddl 48(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 64(%eax) + fmul %st(5), %st + fxch %st(4) + faddl 16(%eax) + fmul %st(1), %st + fxch %st(4) + faddl 32(%eax) + fmul %st(5), %st + fxch %st(4) + faddl (%eax) + faddp %st, %st(4) + fxch %st(2) + faddl 56(%eax) + fmul %st(4), %st + fxch %st(5) + faddl 40(%eax) + fmulp %st, %st(4) + fxch %st(4) + faddl 24(%eax) + fmulp %st, %st(1) + fmul %st(3), %st + fxch %st(2) + faddl 8(%eax) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.19: + flds 8(%ebp) + lea 32(%esp), %eax + fld1 + fdiv %st(1), %st + lea 40(%esp), %edx + fstl 16(%eax) + fldl _val_16_0@GOTOFF(%ebx) + fmulp %st, %st(1) + fstl 24(%eax) + fmul %st(0), %st + fstl 32(%eax) + fmul %st(0), %st + fxch %st(1) + fstpl (%esp) + movl %eax, 8(%esp) + movl %edx, 12(%esp) + movl $-1, 16(%esp) + fstpl 40(%eax) + call __libm_sincos_k32 +..B1.20: + fldl 72(%esp) + fldl 64(%esp) + fldl _tonpi@GOTOFF(%ebx) + fmull 48(%esp) + fsqrt + fldl 40+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fldl 32+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 24+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 16+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 8+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl _PP@GOTOFF(%ebx) + faddp %st, %st(1) + fldl 40+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + fmull 32(%esp) + fxch %st(1) + faddl 24+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fldl 32+_QP@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(1) + faddl 8+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + faddl 16+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + faddl _QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmull 56(%esp) + fmull 40(%esp) + faddp %st, %st(2) + fmulp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.21: + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.27 +..B1.22: + testl %eax, %eax + je ..B1.28 +..B1.23: + fldz + testl $-2147483648, %edx + je ..B1.26 +..B1.25: + flds .L_2il0floatpacket.1@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.26: + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.27: + flds 8(%ebp) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.28: + fldz + fdivrs .L_2il0floatpacket.0@GOTOFF(%ebx) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type y0f,@function + .size y0f,.-y0f + .data +# -- End y0f + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x7f800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_Q1: + .long 2580172613 + .long 3216172246 + .long 1084453148 + .long 1069988811 + .long 2056290550 + .long 3213915569 + .long 1236657422 + .long 1061266913 + .long 2321867150 + .long 3202594720 + .type _Q1,@object + .size _Q1,40 + .align 4 +_Q2: + .long 4294648676 + .long 3218079743 + .long 3841535415 + .long 1066401791 + .long 664070481 + .long 3208409496 + .long 1981210199 + .long 1054621065 + .type _Q2,@object + .size _Q2,32 + .align 4 +_P1: + .long 4195291908 + .long 3162175307 + .long 406986291 + .long 1072440375 + .long 2776221165 + .long 3219095096 + .long 1133938471 + .long 1070349075 + .long 2954828429 + .long 3217879437 + .long 2763399148 + .long 1070335612 + .long 808830809 + .long 3217701246 + .long 1570268664 + .long 1070154462 + .long 3296077481 + .long 3217609508 + .long 420330990 + .long 1070118798 + .long 773510171 + .long 3217614074 + .long 4056659129 + .long 1070174592 + .long 3219431954 + .long 3217750970 + .long 3785879815 + .long 1070358232 + .long 574751405 + .long 3217779900 + .long 4260549547 + .long 1069957964 + .long 2938320462 + .long 3216782740 + .long 3378329138 + .long 1068120728 + .long 1915664650 + .long 3213929269 + .long 3426344990 + .long 1063895342 + .long 349103460 + .long 3207738231 + .long 3100907498 + .long 1072470062 + .type _P1,@object + .size _P1,176 + .align 4 +_P2: + .long 1454683265 + .long 3163093641 + .long 1453379447 + .long 3218719554 + .long 687601567 + .long 1068108233 + .long 2612704149 + .long 1068365525 + .long 3658933664 + .long 3212579183 + .long 2932711330 + .long 3210863403 + .long 1642366143 + .long 1059690534 + .long 3271323791 + .long 1057665714 + .long 1907282597 + .long 3201598976 + .long 379771377 + .long 3197347542 + .long 4245487245 + .long 3193415108 + .long 3608497393 + .long 1045674492 + .long 2931231697 + .long 3190739602 + .long 990015633 + .long 1041359383 + .long 1316300206 + .long 3186258158 + .long 3640313785 + .long 3183477336 + .long 2399178872 + .long 3182342144 + .long 1279629276 + .long 1034489495 + .long 1301829276 + .long 1074768211 + .type _P2,@object + .size _P2,152 + .align 4 +_P3: + .long 2564005090 + .long 1014927793 + .long 2691273771 + .long 1070806220 + .long 300870104 + .long 3214257910 + .long 1691761700 + .long 3215496860 + .long 2795355208 + .long 1063989012 + .long 2286168356 + .long 1063375710 + .long 3010782666 + .long 3206704598 + .long 629642940 + .long 3204978559 + .long 4085313989 + .long 1053206786 + .long 1695842824 + .long 1050888907 + .long 399213285 + .long 3194002865 + .long 3012936744 + .long 3191097259 + .long 3874678520 + .long 1039019405 + .long 2821019721 + .long 1035940102 + .long 3303481603 + .long 1075599389 + .type _P3,@object + .size _P3,120 + .align 4 +_P4: + .long 3357785889 + .long 3165432791 + .long 3430075659 + .long 3218077237 + .long 1374220014 + .long 1065943908 + .long 2803440381 + .long 1067771495 + .long 3788987270 + .long 3210752606 + .long 378839180 + .long 3210732089 + .long 3385429871 + .long 1058535500 + .long 2609792408 + .long 1057402845 + .long 2316098656 + .long 3200270393 + .long 2785606124 + .long 3198332594 + .long 1489685130 + .long 1046034133 + .long 973177683 + .long 1043605688 + .long 113866720 + .long 3186126026 + .long 1355313597 + .long 3183357512 + .long 899972440 + .long 1076130263 + .type _P4,@object + .size _P4,120 + .align 4 +_P5: + .long 1219042543 + .long 1017436670 + .long 659497129 + .long 1070330666 + .long 2213395954 + .long 3212885037 + .long 920472610 + .long 3215092907 + .long 483400048 + .long 1062596670 + .long 3012498212 + .long 1063037606 + .long 1375970636 + .long 3205547500 + .long 3836089736 + .long 3204771982 + .long 199192965 + .long 1052233910 + .long 194857414 + .long 1050781561 + .long 2407988550 + .long 3193126966 + .long 3806101946 + .long 3190982557 + .long 3164279536 + .long 1038193510 + .long 3298944842 + .long 1076541665 + .type _P5,@object + .size _P5,112 + .align 4 +_P6: + .long 4139807906 + .long 1017960487 + .long 1501500641 + .long 3217630659 + .long 2447579003 + .long 1064854100 + .long 511348540 + .long 1067492433 + .long 1810619958 + .long 3209696179 + .long 1806624601 + .long 3210355872 + .long 4035698547 + .long 1057552651 + .long 467530437 + .long 1057185016 + .long 2985801821 + .long 3199346510 + .long 2460583618 + .long 3198194818 + .long 4117830692 + .long 1045310355 + .long 1133672721 + .long 1043441078 + .long 2717688296 + .long 3185336108 + .long 1946169876 + .long 1076920380 + .type _P6,@object + .size _P6,112 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_PP: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP,@object + .size _PP,48 + .align 4 +_QP: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP,@object + .size _QP,48 + .data + .hidden __libm_sincos_k32 + .hidden __libm_log_k32 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/y0l.S b/external/sgx_libm/ia32/y0l.S new file mode 100644 index 0000000000..7e1c5ca464 --- /dev/null +++ b/external/sgx_libm/ia32/y0l.S @@ -0,0 +1,106 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y0l.c" + .text +..TXTST0: +# -- Begin y0l + .text + .align 16,0x90 + .globl y0l +y0l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $56, %esp + fldt 8(%ebp) + lea 16(%esp), %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.6: + addl $-32, %esp + movl (%edi), %ecx + lea 64(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%edi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __y0q@PLT +..B1.5: + addl $28, %esp +..B1.2: + movl 32(%esp), %eax + movl %eax, (%edi) + movl 36(%esp), %edx + movl 40(%esp), %ecx + movl 44(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B1.7: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type y0l,@function + .size y0l,.-y0l + .data +# -- End y0l + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/y1.S b/external/sgx_libm/ia32/y1.S new file mode 100644 index 0000000000..2db65d362f --- /dev/null +++ b/external/sgx_libm/ia32/y1.S @@ -0,0 +1,3196 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y1.c" + .text +..TXTST0: +# -- Begin __y1l + .text + .align 16,0x90 + .hidden __y1l + .globl __y1l +__y1l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $120, %esp + fldt 8(%ebp) + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + fldt 132+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B1.14 +..B1.2: + fldt _val_1_77L@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.12 +..B1.3: + fldt _S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.5 +..B1.4: + fldt _Z@GOTOFF(%ebx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt _P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt _Q1@GOTOFF(%ebx) + fmul %st(4), %st + fldt 12+_Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_Q1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt 72+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 36+_Q1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_Q1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt 120+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 132+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 60+_Q1@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 144+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fxch %st(1) + fdivrl _ones@GOTOFF(%ebx) + fldt 156+_P1@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fldt 168+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 180+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B1.19 +..B1.5: + fldt 12+_S@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.7 +..B1.6: + fldt 12+_Z@GOTOFF(%ebx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt _P2@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P2@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt _Q2@GOTOFF(%ebx) + fmul %st(4), %st + fldt 12+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 48+_P2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 60+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 24+_Q2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt 72+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_P2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 36+_Q2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 96+_P2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 108+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_Q2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt 120+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 132+_P2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt 60+_Q2@GOTOFF(%ebx) + faddp %st, %st(2) + fldt 144+_P2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fxch %st(1) + fdivrl _ones@GOTOFF(%ebx) + fldt 156+_P2@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fldt 168+_P2@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 180+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B1.19 +..B1.7: + movl $2, %edx +..B1.8: + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %ecx + fldt _S@GOTOFF(%ebx,%ecx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.11 + jp ..B1.11 +..B1.9: + incl %edx + cmpl $11, %edx + jl ..B1.8 +..B1.10: + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx +..B1.11: + fldt _Z@GOTOFF(%ecx,%ebx) + movl %edx, %eax + fsubrp %st, %st(1) + shll $4, %eax + fld %st(0) + subl %edx, %eax + shll $4, %eax + fmul %st(1), %st + fstpt 92(%esp) + fldt 92(%esp) + fldt -480+_P@GOTOFF(%eax,%ebx) + fmul %st(1), %st + fldt -468+_P@GOTOFF(%eax,%ebx) + fmul %st(2), %st + fldt -456+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -444+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -432+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -420+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -408+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -396+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -384+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -372+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -360+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -348+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -336+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -324+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -312+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -300+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -288+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -276+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -264+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -252+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B1.19 +..B1.12: + fldt _P0@GOTOFF(%ebx) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(2) + fstpt 64(%esp) + fldt 64(%esp) + fxch %st(3) + fstpt 92(%esp) + fldt 92(%esp) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fldt 12+_P0@GOTOFF(%ebx) + fmul %st(4), %st + fldt 24+_P0@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 36+_P0@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 48+_P0@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 60+_P0@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 72+_P0@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 84+_P0@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(4) + fldt 96+_P0@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + fldt 108+_P0@GOTOFF(%ebx) + faddp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 32(%esp) + call __j1l@PLT +..B1.23: + fldt 8(%ebp) + fldt 32(%esp) +..B1.13: + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fstp %st(0) + fxch %st(1) + fstpt 48(%esp) + fstpt 32(%esp) + call logl@PLT +..B1.24: + fldt 8(%ebp) + fldt 32(%esp) + fldt 48(%esp) + fmulp %st, %st(3) + fldt _tonpi@GOTOFF(%ebx) + fldt _val_N1_0L@GOTOFF(%ebx) + fdivp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + jmp ..B1.19 +..B1.14: + fldl _ones@GOTOFF(%ebx) + lea 92(%esp), %eax + fdiv %st(1), %st + lea 64(%esp), %edx + fxch %st(1) + fxch %st(1) + fstpt -60(%eax) + fldt -60(%eax) + fxch %st(1) + fstpt (%esp) + fldt _val_36_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt -28(%eax) + fldt -28(%eax) + movl %eax, 12(%esp) + movl %edx, 16(%esp) + movl $-3, 20(%esp) + fxch %st(1) + fstpt (%eax) + fldt (%eax) + fldt _PP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _QP@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 96+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt 108+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt -44(%eax) + fldt 108+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt -12(%eax) + call __libm_sincos_pi4l +..B1.15: + fldt 8(%ebp) + fldt 80(%esp) + fldt 48(%esp) + fldt 92(%esp) + fmulp %st, %st(1) + fldt 64(%esp) + fmulp %st, %st(2) + fadd %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt _val_0_03L@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B1.17 + jp ..B1.17 +..B1.16: + fstp %st(1) + fldt _tonpi@GOTOFF(%ebx) + fldt 32(%esp) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + jmp ..B1.19 +..B1.17: + fstp %st(0) + lea 32(%esp), %edi + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.26: + addl $-32, %esp + movl (%edi), %ecx + lea 80(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%edi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __y1q@PLT +..B1.25: + addl $28, %esp +..B1.18: + movl 48(%esp), %eax + movl %eax, (%edi) + movl 52(%esp), %edx + movl 56(%esp), %ecx + movl 60(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B1.19: + addl $120, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type __y1l,@function + .size __y1l,.-__y1l + .data +# -- End __y1l + .text +# -- Begin y1 + .text + .align 16,0x90 + .globl y1 +y1: +# parameter 1: 8 + %ebp +..B2.1: +..L3: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $116, %esp +..B2.2: + fnstcw 46(%esp) +..B2.3: + movl 12(%ebp), %edx + movl %edx, %esi + andl $2147483647, %esi + call ..L4 +..L4: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L4](%ebx), %ebx + cmpl $2146435072, %esi + jge ..B2.30 +..B2.4: + xorl %eax, %eax + movl 8(%ebp), %ecx + subl %eax, %edx + jl ..B2.37 +..B2.44: + orl %ecx, %edx + je ..B2.37 +..B2.5: + movzwl 46(%esp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.36 +..B2.6: + orl $-64768, %edx + movw %dx, 44(%esp) +..B2.7: + fldcw 44(%esp) +..B2.8: + movl $1, %edi +..B2.9: + fldl 8(%ebp) + fstpt 72(%esp) + fldt 72(%esp) + fldt 132+_S@GOTOFF(%ebx) + fcompp + fnstsw %ax + sahf + jb ..B2.22 +..B2.10: + fldt _val_1_77L@GOTOFF(%ebx) + fldt 72(%esp) + fcompp + fnstsw %ax + sahf + jp ..B2.11 + jb ..B2.20 +..B2.11: + fldt _S@GOTOFF(%ebx) + fldt 72(%esp) + fcompp + fnstsw %ax + sahf + jae ..B2.13 + jp ..B2.13 +..B2.12: + fldt _Z@GOTOFF(%ebx) + fldt 72(%esp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + fldt _P1@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P1@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 168+_P1@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 180+_P1@GOTOFF(%ebx) + faddp %st, %st(2) + fldt _Q1@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 60+_Q1@GOTOFF(%ebx) + faddp %st, %st(1) + fdivrl _ones@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 72(%esp) + jmp ..B2.27 +..B2.13: + fldt 12+_S@GOTOFF(%ebx) + fldt 72(%esp) + fcompp + fnstsw %ax + sahf + jae ..B2.15 + jp ..B2.15 +..B2.14: + fldt 12+_Z@GOTOFF(%ebx) + fldt 72(%esp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + fldt _P2@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_P2@GOTOFF(%ebx) + fmul %st(2), %st + fldt 24+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 72+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 108+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 120+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 132+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 156+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 168+_P2@GOTOFF(%ebx) + faddp %st, %st(1) + fldt 180+_P2@GOTOFF(%ebx) + faddp %st, %st(2) + fldt _Q2@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 60+_Q2@GOTOFF(%ebx) + faddp %st, %st(1) + fdivrl _ones@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 72(%esp) + jmp ..B2.27 +..B2.15: + fldt 72(%esp) + movl $2, %edx +..B2.16: + lea (,%edx,8), %ecx + lea (%ecx,%edx,4), %ecx + fldt _S@GOTOFF(%ebx,%ecx) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B2.35 + jp ..B2.35 +..B2.17: + incl %edx + cmpl $11, %edx + jl ..B2.16 +..B2.18: + lea (,%edx,8), %eax + lea (%eax,%edx,4), %ecx + fstp %st(0) +..B2.19: + fldt _Z@GOTOFF(%ecx,%ebx) + movl %edx, %eax + fldt 72(%esp) + shll $4, %eax + fsubp %st, %st(1) + subl %edx, %eax + fld %st(0) + shll $4, %eax + fmul %st(1), %st + fstpt 60(%esp) + fldt 60(%esp) + fldt -480+_P@GOTOFF(%eax,%ebx) + fmul %st(1), %st + fldt -468+_P@GOTOFF(%eax,%ebx) + fmul %st(2), %st + fldt -456+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -444+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -432+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -420+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -408+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -396+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -384+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -372+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -360+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -348+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -336+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -324+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -312+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -300+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -288+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -276+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -264+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -252+_P@GOTOFF(%eax,%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 72(%esp) + jmp ..B2.27 +..B2.20: + fldt 72(%esp) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + fstpt 60(%esp) + fldt 60(%esp) + fldt _P0@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_P0@GOTOFF(%ebx) + fmul %st(3), %st + fldt 24+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 36+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 72+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt 96+_P0@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 108+_P0@GOTOFF(%ebx) + faddp %st, %st(2) + faddp %st, %st(1) + fmul %st(1), %st + fstpt (%esp) + addl $-16, %esp + fstpt (%esp) + call __j1l@PLT +..B2.45: + fstpt 32(%esp) +..B2.21: + fldt 88(%esp) + fstpt (%esp) + call logl@PLT +..B2.46: + fldt _tonpi@GOTOFF(%ebx) + addl $16, %esp + fldt 16(%esp) + fmulp %st, %st(2) + fldt 72(%esp) + fldt (%esp) + fldt _val_N1_0L@GOTOFF(%ebx) + fdivp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 72(%esp) + jmp ..B2.27 +..B2.22: + fldl _ones@GOTOFF(%ebx) + fldt 72(%esp) + fdivr %st, %st(1) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fldt _val_36_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 32(%esp) + fldt 32(%esp) + fxch %st(1) + fstpt 60(%esp) + fldt 60(%esp) + addl $-32, %esp + lea 92(%esp), %eax + lea 64(%esp), %edx + fxch %st(2) + fstpt (%esp) + fldt _PP@GOTOFF(%ebx) + fmul %st(1), %st + fldt 12+_PP@GOTOFF(%ebx) + movl %eax, 12(%esp) + faddp %st, %st(1) + fmul %st(1), %st + fldt _QP@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_QP@GOTOFF(%ebx) + movl %edx, 16(%esp) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PP@GOTOFF(%ebx) + movl $-3, 20(%esp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 24+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 36+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 36+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 60+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 60+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 72+_PP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 84+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 84+_QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 108+_PP@GOTOFF(%ebx) + faddp %st, %st(1) + fstpt -44(%eax) + fldt 108+_QP@GOTOFF(%ebx) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -12(%eax) + call __libm_sincos_pi4l +..B2.47: + fldt 80(%esp) + fldt 48(%esp) + addl $32, %esp +..B2.23: + fldt 60(%esp) + fmulp %st, %st(1) + fldt 32(%esp) + fmulp %st, %st(2) + fadd %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt _val_0_03L@GOTOFF(%ebx) + fmulp %st, %st(1) + fcompp + fnstsw %ax + sahf + jae ..B2.25 + jp ..B2.25 +..B2.24: + fldt _tonpi@GOTOFF(%ebx) + fldt (%esp) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + fstpt 72(%esp) + jmp ..B2.27 +..B2.25: + fstp %st(0) + addl $-16, %esp + lea 16(%esp), %esi + movl %esi, (%esp) + fldt 72(%esi) + fstpt 4(%esp) + call __ltoq@PLT +..B2.49: + addl $-16, %esp + movl (%esi), %ecx + lea 48(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%esi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%esi), %ecx + movl 12(%esi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __y1q@PLT +..B2.48: + addl $28, %esp +..B2.26: + movl 16(%esp), %eax + movl %eax, (%esi) + movl 20(%esp), %edx + movl 24(%esp), %ecx + movl 28(%esp), %eax + addl $-16, %esp + movl %edx, 4(%esi) + movl %ecx, 8(%esi) + movl %eax, 12(%esi) + movl %esi, (%esp) + call __qtol@PLT +..B2.50: + fstpt 88(%esp) + addl $16, %esp +..B2.27: + testl %edi, %edi + je ..B2.29 +..B2.28: + fldcw 46(%esp) +..B2.29: + fldt 72(%esp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.30: + andl $-2146435073, %esi + orl 8(%ebp), %esi + jne ..B2.34 +..B2.31: + testl $-2147483648, %edx + jne ..B2.41 +..B2.32: + shrl $31, %edx + fldl _zeros@GOTOFF(%ebx,%edx,8) +..B2.33: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.34: + fldl 8(%ebp) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.35: + fstp %st(0) + jmp ..B2.19 +..B2.36: + xorl %edi, %edi + jmp ..B2.9 +..B2.37: + fldl _zeros@GOTOFF(%ebx) + orl %ecx, %esi + je ..B2.39 +..B2.38: + fldl _infs@GOTOFF(%ebx) + fmulp %st, %st(1) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.39: + fldl 8+_ones@GOTOFF(%ebx) + fdivp %st, %st(1) +..B2.40: + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B2.41: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + addl $116, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type y1,@function + .size y1,.-y1 + .data +# -- End y1 + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_S: + .word 56848 + .word 49844 + .word 39532 + .word 64842 + .word 16384 + .word 0 + .word 5940 + .word 14600 + .word 60967 + .word 58048 + .word 16385 + .word 0 + .word 48233 + .word 9194 + .word 47533 + .word 41870 + .word 16386 + .word 0 + .word 19716 + .word 3898 + .word 3621 + .word 54727 + .word 16386 + .word 0 + .word 41547 + .word 400 + .word 58272 + .word 33793 + .word 16387 + .word 0 + .word 46312 + .word 65374 + .word 26362 + .word 40225 + .word 16387 + .word 0 + .word 15253 + .word 48480 + .word 38891 + .word 46657 + .word 16387 + .word 0 + .word 12158 + .word 16394 + .word 14239 + .word 53090 + .word 16387 + .word 0 + .word 31253 + .word 2914 + .word 8779 + .word 59523 + .word 16387 + .word 0 + .word 29606 + .word 9567 + .word 8455 + .word 32978 + .word 16388 + .word 0 + .word 51148 + .word 41491 + .word 50276 + .word 36194 + .word 16388 + .word 0 + .word 1224 + .word 58769 + .word 30330 + .word 39411 + .word 16388 + .word 0 + .type _S,@object + .size _S,144 + .align 2 +_val_1_77L: + .word 36700 + .word 62914 + .word 23592 + .word 57999 + .word 16383 + .word 0 + .type _val_1_77L,@object + .size _val_1_77L,12 + .align 2 +_Z: + .word 5921 + .word 65426 + .word 63142 + .word 35997 + .word 16384 + .word 0 + .word 29632 + .word 15745 + .word 62068 + .word 44479 + .word 16385 + .word 0 + .word 41288 + .word 2893 + .word 15731 + .word 35209 + .word 16386 + .word 0 + .word 12322 + .word 41360 + .word 35270 + .word 48124 + .word 16386 + .word 0 + .word 21828 + .word 62500 + .word 60486 + .word 61019 + .word 16386 + .word 0 + .word 54460 + .word 63729 + .word 58186 + .word 36952 + .word 16387 + .word 0 + .word 27250 + .word 3142 + .word 10825 + .word 43393 + .word 16387 + .word 0 + .word 20649 + .word 49414 + .word 53633 + .word 49831 + .word 16387 + .word 0 + .word 59160 + .word 26587 + .word 26484 + .word 56269 + .word 16387 + .word 0 + .word 57283 + .word 10561 + .word 16432 + .word 62706 + .word 16387 + .word 0 + .word 44243 + .word 51162 + .word 18495 + .word 34571 + .word 16388 + .word 0 + .word 63781 + .word 54231 + .word 15770 + .word 37789 + .word 16388 + .word 0 + .type _Z,@object + .size _Z,144 + .align 2 +_P1: + .word 21770 + .word 62666 + .word 46899 + .word 35378 + .word 16344 + .word 0 + .word 28454 + .word 23396 + .word 41885 + .word 48017 + .word 49112 + .word 0 + .word 61344 + .word 9332 + .word 29378 + .word 47284 + .word 49120 + .word 0 + .word 60127 + .word 25512 + .word 35054 + .word 43181 + .word 16353 + .word 0 + .word 25808 + .word 25324 + .word 9989 + .word 53047 + .word 16359 + .word 0 + .word 46582 + .word 21062 + .word 5476 + .word 44690 + .word 49126 + .word 0 + .word 61332 + .word 1419 + .word 18476 + .word 34785 + .word 49134 + .word 0 + .word 51513 + .word 63307 + .word 40855 + .word 38307 + .word 49134 + .word 0 + .word 22560 + .word 55588 + .word 5655 + .word 48627 + .word 16371 + .word 0 + .word 56966 + .word 1018 + .word 54245 + .word 62436 + .word 16372 + .word 0 + .word 17453 + .word 15035 + .word 65421 + .word 57312 + .word 49143 + .word 0 + .word 53367 + .word 52143 + .word 3664 + .word 58921 + .word 49145 + .word 0 + .word 16321 + .word 41163 + .word 52734 + .word 35978 + .word 16377 + .word 0 + .word 15288 + .word 52738 + .word 13594 + .word 53174 + .word 16380 + .word 0 + .word 42685 + .word 25071 + .word 48779 + .word 62301 + .word 16380 + .word 0 + .word 7354 + .word 8216 + .word 60720 + .word 54923 + .word 49085 + .word 0 + .type _P1,@object + .size _P1,192 + .align 2 +_Q1: + .word 64227 + .word 6706 + .word 76 + .word 58690 + .word 16369 + .word 0 + .word 8371 + .word 16695 + .word 56692 + .word 45251 + .word 16372 + .word 0 + .word 9179 + .word 20845 + .word 29706 + .word 43997 + .word 16377 + .word 0 + .word 44943 + .word 15045 + .word 18794 + .word 45614 + .word 16380 + .word 0 + .word 10671 + .word 41768 + .word 56247 + .word 64663 + .word 16381 + .word 0 + .word 25530 + .word 4231 + .word 4140 + .word 59815 + .word 16381 + .word 0 + .type _Q1,@object + .size _Q1,72 + .align 2 +_P2: + .word 42420 + .word 39002 + .word 59647 + .word 60050 + .word 16339 + .word 0 + .word 9209 + .word 30875 + .word 32003 + .word 38109 + .word 49111 + .word 0 + .word 63337 + .word 29381 + .word 46828 + .word 35859 + .word 49116 + .word 0 + .word 25340 + .word 63034 + .word 61574 + .word 39960 + .word 16351 + .word 0 + .word 21587 + .word 1531 + .word 17186 + .word 56230 + .word 16355 + .word 0 + .word 35654 + .word 56865 + .word 61897 + .word 49746 + .word 49126 + .word 0 + .word 6701 + .word 41291 + .word 18798 + .word 55141 + .word 49130 + .word 0 + .word 35596 + .word 2936 + .word 34861 + .word 35797 + .word 16365 + .word 0 + .word 59382 + .word 44988 + .word 46794 + .word 33373 + .word 16369 + .word 0 + .word 39208 + .word 51898 + .word 38063 + .word 56363 + .word 49138 + .word 0 + .word 34426 + .word 35681 + .word 546 + .word 45071 + .word 49142 + .word 0 + .word 27055 + .word 35919 + .word 19182 + .word 39238 + .word 16375 + .word 0 + .word 11379 + .word 16934 + .word 10723 + .word 57120 + .word 16378 + .word 0 + .word 30778 + .word 48366 + .word 51582 + .word 60462 + .word 49145 + .word 0 + .word 38504 + .word 65531 + .word 34807 + .word 43722 + .word 49149 + .word 0 + .word 52867 + .word 16075 + .word 29885 + .word 33161 + .word 49086 + .word 0 + .type _P2,@object + .size _P2,192 + .align 2 +_Q2: + .word 24596 + .word 8363 + .word 28671 + .word 51312 + .word 16360 + .word 0 + .word 22889 + .word 23763 + .word 37225 + .word 46345 + .word 16361 + .word 0 + .word 24119 + .word 47441 + .word 54379 + .word 48688 + .word 16372 + .word 0 + .word 1240 + .word 59184 + .word 48701 + .word 46748 + .word 16374 + .word 0 + .word 22888 + .word 65215 + .word 58633 + .word 45869 + .word 16380 + .word 0 + .word 31023 + .word 50278 + .word 49158 + .word 64237 + .word 16382 + .word 0 + .type _Q2,@object + .size _Q2,72 + .align 2 +_P: + .word 61722 + .word 43505 + .word 23994 + .word 37346 + .word 49091 + .word 0 + .word 30291 + .word 24028 + .word 22863 + .word 34750 + .word 49095 + .word 0 + .word 1126 + .word 901 + .word 35659 + .word 64778 + .word 16331 + .word 0 + .word 24961 + .word 30514 + .word 59096 + .word 39096 + .word 16335 + .word 0 + .word 35564 + .word 61687 + .word 10716 + .word 35707 + .word 49108 + .word 0 + .word 46848 + .word 13986 + .word 10777 + .word 37699 + .word 49111 + .word 0 + .word 25983 + .word 4211 + .word 22533 + .word 63008 + .word 16347 + .word 0 + .word 41622 + .word 55080 + .word 16927 + .word 53017 + .word 16350 + .word 0 + .word 59504 + .word 42891 + .word 54413 + .word 41203 + .word 49123 + .word 0 + .word 12571 + .word 13616 + .word 30559 + .word 53698 + .word 49125 + .word 0 + .word 24504 + .word 22188 + .word 22875 + .word 38390 + .word 16362 + .word 0 + .word 45455 + .word 51567 + .word 14687 + .word 35767 + .word 16364 + .word 0 + .word 2489 + .word 10124 + .word 54664 + .word 47037 + .word 49136 + .word 0 + .word 18722 + .word 39166 + .word 48910 + .word 55942 + .word 49137 + .word 0 + .word 52167 + .word 5 + .word 15467 + .word 33747 + .word 16374 + .word 0 + .word 64650 + .word 13451 + .word 38167 + .word 40566 + .word 16374 + .word 0 + .word 40279 + .word 20454 + .word 61426 + .word 45514 + .word 49146 + .word 0 + .word 34995 + .word 30989 + .word 51614 + .word 33113 + .word 49145 + .word 0 + .word 57629 + .word 30042 + .word 51710 + .word 35580 + .word 16381 + .word 0 + .word 22801 + .word 35092 + .word 8589 + .word 55177 + .word 16319 + .word 0 + .word 18213 + .word 9889 + .word 16490 + .word 42684 + .word 16323 + .word 0 + .word 35117 + .word 3709 + .word 30056 + .word 56315 + .word 16326 + .word 0 + .word 23979 + .word 26668 + .word 51699 + .word 63315 + .word 49099 + .word 0 + .word 37328 + .word 63574 + .word 8303 + .word 34466 + .word 49103 + .word 0 + .word 46391 + .word 17329 + .word 18036 + .word 35570 + .word 16340 + .word 0 + .word 30054 + .word 21312 + .word 25061 + .word 63482 + .word 16342 + .word 0 + .word 2570 + .word 34880 + .word 30954 + .word 61846 + .word 49115 + .word 0 + .word 48934 + .word 61799 + .word 17650 + .word 43599 + .word 49118 + .word 0 + .word 9996 + .word 54252 + .word 12364 + .word 40067 + .word 16355 + .word 0 + .word 26028 + .word 41231 + .word 49512 + .word 42301 + .word 16357 + .word 0 + .word 36582 + .word 15370 + .word 8472 + .word 36675 + .word 49130 + .word 0 + .word 63654 + .word 5080 + .word 49106 + .word 53579 + .word 49131 + .word 0 + .word 31057 + .word 54537 + .word 2640 + .word 43916 + .word 16368 + .word 0 + .word 21142 + .word 46896 + .word 24614 + .word 39087 + .word 16369 + .word 0 + .word 3964 + .word 40668 + .word 52365 + .word 60967 + .word 49141 + .word 0 + .word 39332 + .word 9457 + .word 22878 + .word 52919 + .word 49141 + .word 0 + .word 54210 + .word 18213 + .word 48816 + .word 39742 + .word 16378 + .word 0 + .word 59971 + .word 56061 + .word 65402 + .word 41492 + .word 16376 + .word 0 + .word 50867 + .word 29775 + .word 29962 + .word 60938 + .word 49148 + .word 0 + .word 39008 + .word 10804 + .word 60432 + .word 53771 + .word 49083 + .word 0 + .word 8797 + .word 29964 + .word 61128 + .word 42619 + .word 49091 + .word 0 + .word 49667 + .word 64253 + .word 56687 + .word 49119 + .word 49094 + .word 0 + .word 12708 + .word 20574 + .word 59517 + .word 62457 + .word 16331 + .word 0 + .word 61123 + .word 30114 + .word 53775 + .word 59072 + .word 16334 + .word 0 + .word 12480 + .word 24376 + .word 40478 + .word 34829 + .word 49108 + .word 0 + .word 31610 + .word 2541 + .word 29797 + .word 53230 + .word 49110 + .word 0 + .word 57351 + .word 51530 + .word 20151 + .word 60005 + .word 16347 + .word 0 + .word 27929 + .word 50140 + .word 46261 + .word 35597 + .word 16350 + .word 0 + .word 13266 + .word 42539 + .word 17988 + .word 38413 + .word 49123 + .word 0 + .word 60482 + .word 30188 + .word 54757 + .word 33461 + .word 49125 + .word 0 + .word 28412 + .word 55589 + .word 45206 + .word 34637 + .word 16362 + .word 0 + .word 32067 + .word 62816 + .word 60815 + .word 40858 + .word 16363 + .word 0 + .word 5401 + .word 9100 + .word 50782 + .word 40732 + .word 49136 + .word 0 + .word 54621 + .word 58390 + .word 59249 + .word 57428 + .word 49136 + .word 0 + .word 35825 + .word 1375 + .word 322 + .word 55483 + .word 16373 + .word 0 + .word 16432 + .word 16110 + .word 8852 + .word 37720 + .word 16373 + .word 0 + .word 5000 + .word 34131 + .word 51425 + .word 35608 + .word 49146 + .word 0 + .word 53929 + .word 6276 + .word 23388 + .word 58152 + .word 49143 + .word 0 + .word 51579 + .word 17004 + .word 5616 + .word 54145 + .word 16380 + .word 0 + .word 7103 + .word 16103 + .word 63732 + .word 61608 + .word 16316 + .word 0 + .word 53540 + .word 14563 + .word 28490 + .word 42103 + .word 16323 + .word 0 + .word 50538 + .word 7801 + .word 54621 + .word 42667 + .word 16326 + .word 0 + .word 21289 + .word 53272 + .word 50234 + .word 61084 + .word 49099 + .word 0 + .word 53615 + .word 53374 + .word 57363 + .word 50528 + .word 49102 + .word 0 + .word 54514 + .word 9539 + .word 36475 + .word 33817 + .word 16340 + .word 0 + .word 31658 + .word 4746 + .word 1163 + .word 44700 + .word 16342 + .word 0 + .word 52867 + .word 45166 + .word 52684 + .word 57761 + .word 49115 + .word 0 + .word 48341 + .word 5188 + .word 19803 + .word 58551 + .word 49117 + .word 0 + .word 18455 + .word 50865 + .word 10646 + .word 36603 + .word 16355 + .word 0 + .word 16819 + .word 38651 + .word 15489 + .word 53797 + .word 16356 + .word 0 + .word 57587 + .word 29612 + .word 6330 + .word 65256 + .word 49129 + .word 0 + .word 60926 + .word 53369 + .word 5356 + .word 64182 + .word 49130 + .word 0 + .word 26295 + .word 42515 + .word 37715 + .word 37910 + .word 16368 + .word 0 + .word 26848 + .word 34589 + .word 11687 + .word 44170 + .word 16368 + .word 0 + .word 52547 + .word 41404 + .word 29188 + .word 51071 + .word 49141 + .word 0 + .word 59720 + .word 37814 + .word 50864 + .word 57112 + .word 49140 + .word 0 + .word 63754 + .word 1059 + .word 28610 + .word 65011 + .word 16377 + .word 0 + .word 48135 + .word 53252 + .word 54091 + .word 43638 + .word 16375 + .word 0 + .word 14971 + .word 8471 + .word 3609 + .word 49212 + .word 49148 + .word 0 + .word 4052 + .word 57147 + .word 31484 + .word 54446 + .word 16318 + .word 0 + .word 11824 + .word 2112 + .word 5588 + .word 41288 + .word 49091 + .word 0 + .word 30937 + .word 56824 + .word 10791 + .word 37103 + .word 49094 + .word 0 + .word 13479 + .word 25038 + .word 44704 + .word 59408 + .word 16331 + .word 0 + .word 6837 + .word 41457 + .word 42451 + .word 43375 + .word 16334 + .word 0 + .word 53800 + .word 46435 + .word 51001 + .word 65352 + .word 49107 + .word 0 + .word 15811 + .word 55852 + .word 5902 + .word 37814 + .word 49110 + .word 0 + .word 19663 + .word 64639 + .word 1883 + .word 55408 + .word 16347 + .word 0 + .word 5332 + .word 44968 + .word 15414 + .word 48765 + .word 16349 + .word 0 + .word 24635 + .word 46043 + .word 59114 + .word 34832 + .word 49123 + .word 0 + .word 15088 + .word 55241 + .word 15044 + .word 44102 + .word 49124 + .word 0 + .word 6405 + .word 38383 + .word 37570 + .word 61587 + .word 16361 + .word 0 + .word 22931 + .word 45450 + .word 10147 + .word 51835 + .word 16362 + .word 0 + .word 64299 + .word 50831 + .word 27180 + .word 35495 + .word 49136 + .word 0 + .word 23200 + .word 7806 + .word 1364 + .word 35222 + .word 49136 + .word 0 + .word 45807 + .word 4679 + .word 55327 + .word 47491 + .word 16373 + .word 0 + .word 30764 + .word 65323 + .word 55387 + .word 45120 + .word 16372 + .word 0 + .word 15039 + .word 21256 + .word 11217 + .word 60156 + .word 49145 + .word 0 + .word 57173 + .word 14361 + .word 2624 + .word 34299 + .word 49143 + .word 0 + .word 56410 + .word 62508 + .word 42699 + .word 45420 + .word 16380 + .word 0 + .word 50446 + .word 42024 + .word 63781 + .word 38435 + .word 49087 + .word 0 + .word 10333 + .word 60348 + .word 17128 + .word 40300 + .word 16323 + .word 0 + .word 43838 + .word 25371 + .word 62467 + .word 64794 + .word 16325 + .word 0 + .word 26845 + .word 6377 + .word 43437 + .word 57595 + .word 49099 + .word 0 + .word 7442 + .word 5283 + .word 26036 + .word 37481 + .word 49102 + .word 0 + .word 15454 + .word 29184 + .word 54291 + .word 63010 + .word 16339 + .word 0 + .word 5297 + .word 38874 + .word 4456 + .word 64615 + .word 16341 + .word 0 + .word 12966 + .word 61910 + .word 53167 + .word 53110 + .word 49115 + .word 0 + .word 20395 + .word 4102 + .word 12283 + .word 41188 + .word 49117 + .word 0 + .word 19094 + .word 29300 + .word 12828 + .word 33187 + .word 16355 + .word 0 + .word 28120 + .word 22694 + .word 2680 + .word 36839 + .word 16356 + .word 0 + .word 25698 + .word 43431 + .word 60429 + .word 58329 + .word 49129 + .word 0 + .word 59006 + .word 57475 + .word 62067 + .word 42866 + .word 49130 + .word 0 + .word 60088 + .word 17714 + .word 44332 + .word 33435 + .word 16368 + .word 0 + .word 3844 + .word 12917 + .word 11965 + .word 57777 + .word 16367 + .word 0 + .word 17310 + .word 43236 + .word 29566 + .word 44535 + .word 49141 + .word 0 + .word 38891 + .word 11594 + .word 35001 + .word 36788 + .word 49140 + .word 0 + .word 62784 + .word 19866 + .word 27725 + .word 56232 + .word 16377 + .word 0 + .word 26552 + .word 62874 + .word 50518 + .word 55747 + .word 16374 + .word 0 + .word 41449 + .word 54733 + .word 7288 + .word 42389 + .word 49148 + .word 0 + .word 25436 + .word 16965 + .word 21076 + .word 40960 + .word 16320 + .word 0 + .word 39083 + .word 3258 + .word 61438 + .word 39229 + .word 49091 + .word 0 + .word 62602 + .word 12963 + .word 51303 + .word 56904 + .word 49093 + .word 0 + .word 41532 + .word 46799 + .word 27449 + .word 55757 + .word 16331 + .word 0 + .word 25508 + .word 35836 + .word 14539 + .word 65290 + .word 16333 + .word 0 + .word 34796 + .word 56106 + .word 58112 + .word 60724 + .word 49107 + .word 0 + .word 52331 + .word 50671 + .word 56071 + .word 55789 + .word 49109 + .word 0 + .word 50430 + .word 49256 + .word 15625 + .word 50948 + .word 16347 + .word 0 + .word 15753 + .word 56169 + .word 3376 + .word 35261 + .word 16349 + .word 0 + .word 47489 + .word 43658 + .word 29070 + .word 63380 + .word 49122 + .word 0 + .word 14447 + .word 45157 + .word 5 + .word 62576 + .word 49123 + .word 0 + .word 14392 + .word 17120 + .word 59854 + .word 55457 + .word 16361 + .word 0 + .word 2389 + .word 54610 + .word 7938 + .word 36154 + .word 16362 + .word 0 + .word 24225 + .word 54966 + .word 22944 + .word 63335 + .word 49135 + .word 0 + .word 6246 + .word 36346 + .word 2616 + .word 48455 + .word 49135 + .word 0 + .word 61678 + .word 13662 + .word 7713 + .word 42050 + .word 16373 + .word 0 + .word 4329 + .word 54820 + .word 31411 + .word 61458 + .word 16371 + .word 0 + .word 48026 + .word 57812 + .word 53661 + .word 52979 + .word 49145 + .word 0 + .word 47545 + .word 24071 + .word 10224 + .word 46463 + .word 49142 + .word 0 + .word 51405 + .word 19517 + .word 26454 + .word 39893 + .word 16380 + .word 0 + .word 2714 + .word 52847 + .word 64285 + .word 36922 + .word 49088 + .word 0 + .word 51895 + .word 36793 + .word 33802 + .word 38136 + .word 16323 + .word 0 + .word 2488 + .word 31490 + .word 30800 + .word 50300 + .word 16325 + .word 0 + .word 13623 + .word 29920 + .word 59063 + .word 53960 + .word 49099 + .word 0 + .word 4071 + .word 44015 + .word 56417 + .word 57333 + .word 49101 + .word 0 + .word 57861 + .word 52773 + .word 20389 + .word 58553 + .word 16339 + .word 0 + .word 64934 + .word 37948 + .word 51829 + .word 48662 + .word 16341 + .word 0 + .word 56954 + .word 19807 + .word 167 + .word 48948 + .word 49115 + .word 0 + .word 28104 + .word 12997 + .word 51038 + .word 61119 + .word 49116 + .word 0 + .word 3409 + .word 4305 + .word 3650 + .word 60679 + .word 16354 + .word 0 + .word 43193 + .word 24597 + .word 44129 + .word 53916 + .word 16355 + .word 0 + .word 17521 + .word 14667 + .word 10096 + .word 52923 + .word 49129 + .word 0 + .word 55445 + .word 18677 + .word 32228 + .word 61988 + .word 49129 + .word 0 + .word 19057 + .word 4855 + .word 59096 + .word 60271 + .word 16367 + .word 0 + .word 13479 + .word 55645 + .word 42570 + .word 41372 + .word 16367 + .word 0 + .word 1282 + .word 28535 + .word 31957 + .word 39927 + .word 49141 + .word 0 + .word 572 + .word 61602 + .word 36341 + .word 52326 + .word 49139 + .word 0 + .word 28923 + .word 3577 + .word 27552 + .word 50228 + .word 16377 + .word 0 + .word 55167 + .word 15365 + .word 46318 + .word 39497 + .word 16374 + .word 0 + .word 19602 + .word 36437 + .word 16591 + .word 37792 + .word 49148 + .word 0 + .word 46605 + .word 39778 + .word 56315 + .word 52295 + .word 16316 + .word 0 + .word 30298 + .word 45364 + .word 48554 + .word 37056 + .word 49091 + .word 0 + .word 36916 + .word 47157 + .word 55353 + .word 44757 + .word 49093 + .word 0 + .word 36754 + .word 52515 + .word 12207 + .word 52242 + .word 16331 + .word 0 + .word 22625 + .word 1809 + .word 14640 + .word 50749 + .word 16333 + .word 0 + .word 16563 + .word 52625 + .word 13365 + .word 56520 + .word 49107 + .word 0 + .word 27329 + .word 9102 + .word 21835 + .word 42848 + .word 49109 + .word 0 + .word 25313 + .word 26147 + .word 37973 + .word 47112 + .word 16347 + .word 0 + .word 62093 + .word 47762 + .word 2878 + .word 53553 + .word 16348 + .word 0 + .word 45304 + .word 46632 + .word 22697 + .word 58245 + .word 49122 + .word 0 + .word 52304 + .word 22429 + .word 48300 + .word 47033 + .word 49123 + .word 0 + .word 1240 + .word 8778 + .word 3434 + .word 50676 + .word 16361 + .word 0 + .word 64382 + .word 35832 + .word 24068 + .word 53872 + .word 16361 + .word 0 + .word 9372 + .word 49794 + .word 11542 + .word 57592 + .word 49135 + .word 0 + .word 29118 + .word 43193 + .word 8003 + .word 35849 + .word 49135 + .word 0 + .word 3582 + .word 16932 + .word 42429 + .word 38089 + .word 16373 + .word 0 + .word 26846 + .word 61869 + .word 11277 + .word 45246 + .word 16371 + .word 0 + .word 12490 + .word 64508 + .word 30037 + .word 47862 + .word 49145 + .word 0 + .word 36625 + .word 65383 + .word 13633 + .word 34114 + .word 49142 + .word 0 + .word 6011 + .word 54183 + .word 37651 + .word 35991 + .word 16380 + .word 0 + .word 43024 + .word 51442 + .word 35220 + .word 35244 + .word 16321 + .word 0 + .word 2338 + .word 9974 + .word 58099 + .word 36011 + .word 16323 + .word 0 + .word 54231 + .word 56678 + .word 56840 + .word 40082 + .word 16325 + .word 0 + .word 47406 + .word 57592 + .word 65286 + .word 50617 + .word 49099 + .word 0 + .word 15992 + .word 46142 + .word 20381 + .word 45257 + .word 49101 + .word 0 + .word 17722 + .word 6937 + .word 55940 + .word 54630 + .word 16339 + .word 0 + .word 44953 + .word 7303 + .word 1203 + .word 38053 + .word 16341 + .word 0 + .word 9155 + .word 41724 + .word 2745 + .word 45433 + .word 49115 + .word 0 + .word 23208 + .word 13836 + .word 51920 + .word 47377 + .word 49116 + .word 0 + .word 46053 + .word 58453 + .word 7516 + .word 56049 + .word 16354 + .word 0 + .word 51100 + .word 31216 + .word 1872 + .word 41469 + .word 16355 + .word 0 + .word 24653 + .word 32384 + .word 37643 + .word 48672 + .word 49129 + .word 0 + .word 61101 + .word 35176 + .word 37213 + .word 47362 + .word 49129 + .word 0 + .word 62301 + .word 22066 + .word 41591 + .word 55226 + .word 16367 + .word 0 + .word 37791 + .word 15476 + .word 41140 + .word 62892 + .word 16366 + .word 0 + .word 18919 + .word 33505 + .word 35758 + .word 36479 + .word 49141 + .word 0 + .word 58610 + .word 16753 + .word 52674 + .word 39626 + .word 49139 + .word 0 + .word 19653 + .word 21667 + .word 11428 + .word 45800 + .word 16377 + .word 0 + .word 51212 + .word 10491 + .word 15737 + .word 59703 + .word 16373 + .word 0 + .word 54759 + .word 31668 + .word 63308 + .word 34425 + .word 49148 + .word 0 + .word 62523 + .word 11996 + .word 50486 + .word 33912 + .word 49089 + .word 0 + .type _P,@object + .size _P,2400 + .align 2 +_P0: + .word 10891 + .word 2847 + .word 4043 + .word 50135 + .word 16324 + .word 0 + .word 8878 + .word 10523 + .word 36094 + .word 35357 + .word 49101 + .word 0 + .word 12191 + .word 2098 + .word 38631 + .word 38182 + .word 16341 + .word 0 + .word 58416 + .word 39431 + .word 6152 + .word 63591 + .word 49116 + .word 0 + .word 18600 + .word 1852 + .word 53867 + .word 39282 + .word 16356 + .word 0 + .word 37377 + .word 45824 + .word 1379 + .word 34108 + .word 49131 + .word 0 + .word 58815 + .word 28468 + .word 57342 + .word 38462 + .word 16369 + .word 0 + .word 35703 + .word 42482 + .word 52164 + .word 49581 + .word 49142 + .word 0 + .word 14326 + .word 44453 + .word 47843 + .word 56988 + .word 16378 + .word 0 + .word 21045 + .word 58852 + .word 12449 + .word 51395 + .word 49148 + .word 0 + .type _P0,@object + .size _P0,120 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .type _tonpi,@object + .size _tonpi,12 + .align 2 +_val_N1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .type _val_N1_0L,@object + .size _val_N1_0L,12 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,12 + .align 2 +_PP: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP,@object + .size _PP,120 + .align 2 +_QP: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .type _QP,@object + .size _QP,120 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,12 + .data + .hidden __libm_sincos_pi4l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/y1f.S b/external/sgx_libm/ia32/y1f.S new file mode 100644 index 0000000000..cd84d78990 --- /dev/null +++ b/external/sgx_libm/ia32/y1f.S @@ -0,0 +1,880 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y1f.c" + .text +..TXTST0: +# -- Begin y1f + .text + .align 16,0x90 + .globl y1f +y1f: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %ebx + subl $124, %esp + movl 8(%ebp), %edx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea -1(%edx), %eax + cmpl $2139095039, %eax + jae ..B1.19 +..B1.2: + cmpl $1100816743, %edx + jae ..B1.17 +..B1.3: + cmpl $1099170276, %edx + jae ..B1.16 +..B1.4: + cmpl $1096140558, %edx + jae ..B1.15 +..B1.5: + cmpl $1092849338, %edx + jae ..B1.14 +..B1.6: + cmpl $1088602350, %edx + jae ..B1.13 +..B1.7: + cmpl $1081952922, %edx + jae ..B1.12 +..B1.8: + cmpl $1071812444, %edx + jae ..B1.11 +..B1.9: + flds 8(%ebp) + fstl (%esp) + fstps 32(%esp) + call __libm_log_k32 +..B1.29: + flds 32(%esp) +..B1.10: + fldl _tonpi@GOTOFF(%ebx) + fmul %st, %st(2) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fdiv %st(3), %st + fldl 40+_Q1@GOTOFF(%ebx) + fmul %st(3), %st + fldl 32+_Q1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 24+_Q1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 16+_Q1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 8+_Q1@GOTOFF(%ebx) + fmul %st(3), %st + fmul %st(5), %st + fxch %st(1) + faddl _Q1@GOTOFF(%ebx) + fmul %st(5), %st + faddp %st, %st(1) + fldl 40+_Q2@GOTOFF(%ebx) + fmul %st(4), %st + fldl 32+_Q2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(1) + faddl 24+_Q2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(1) + faddl 16+_Q2@GOTOFF(%ebx) + fmulp %st, %st(5) + faddl 8+_Q2@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fxch %st(3) + faddl _Q2@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(1) + fsubrp %st, %st(2) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.11: + flds 8(%ebp) + fldl 120+_P1@GOTOFF(%ebx) + fldl 104+_P1@GOTOFF(%ebx) + fldl 112+_P1@GOTOFF(%ebx) + fldl 96+_P1@GOTOFF(%ebx) + fxch %st(4) + fsubl 128+_P1@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 88+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 72+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 56+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 40+_P1@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 24+_P1@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(2), %st + fxch %st(4) + faddl 8+_P1@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(4) + faddl 64+_P1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 80+_P1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 32+_P1@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 48+_P1@GOTOFF(%ebx) + fmulp %st, %st(3) + faddl _P1@GOTOFF(%ebx) + fxch %st(2) + faddl 16+_P1@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.12: + flds 8(%ebp) + fldl 104+_P2@GOTOFF(%ebx) + fldl 88+_P2@GOTOFF(%ebx) + fldl 96+_P2@GOTOFF(%ebx) + fldl 80+_P2@GOTOFF(%ebx) + fxch %st(4) + fsubl 112+_P2@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 72+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 56+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 40+_P2@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 24+_P2@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(2), %st + fxch %st(4) + faddl 8+_P2@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + faddl 64+_P2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 48+_P2@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 32+_P2@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(3) + faddl 16+_P2@GOTOFF(%ebx) + fmulp %st, %st(1) + fxch %st(1) + faddl _P2@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.13: + flds 8(%ebp) + fldl 96+_P3@GOTOFF(%ebx) + fldl 80+_P3@GOTOFF(%ebx) + fldl 88+_P3@GOTOFF(%ebx) + fldl 72+_P3@GOTOFF(%ebx) + fxch %st(4) + fsubl 104+_P3@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 64+_P3@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 48+_P3@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 32+_P3@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 16+_P3@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 56+_P3@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(3) + faddl _P3@GOTOFF(%ebx) + fxch %st(5) + faddl 40+_P3@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(2) + faddl 24+_P3@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(1), %st + fxch %st(2) + faddl 8+_P3@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.14: + flds 8(%ebp) + fldl 104+_P4@GOTOFF(%ebx) + fldl 88+_P4@GOTOFF(%ebx) + fldl 96+_P4@GOTOFF(%ebx) + fldl 80+_P4@GOTOFF(%ebx) + fxch %st(4) + fsubl 112+_P4@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 72+_P4@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 56+_P4@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 40+_P4@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 24+_P4@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(2), %st + fxch %st(4) + faddl 8+_P4@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + faddl 64+_P4@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 48+_P4@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 32+_P4@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(3) + faddl 16+_P4@GOTOFF(%ebx) + fmulp %st, %st(1) + fxch %st(1) + faddl _P4@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.15: + flds 8(%ebp) + fldl 96+_P5@GOTOFF(%ebx) + fldl 80+_P5@GOTOFF(%ebx) + fldl 88+_P5@GOTOFF(%ebx) + fldl 72+_P5@GOTOFF(%ebx) + fxch %st(4) + fsubl 104+_P5@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 64+_P5@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 48+_P5@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 32+_P5@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 16+_P5@GOTOFF(%ebx) + fmul %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 56+_P5@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(3) + faddl _P5@GOTOFF(%ebx) + fxch %st(5) + faddl 40+_P5@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(2) + faddl 24+_P5@GOTOFF(%ebx) + fmulp %st, %st(1) + fmul %st(1), %st + fxch %st(2) + faddl 8+_P5@GOTOFF(%ebx) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.16: + flds 8(%ebp) + fldl 104+_P6@GOTOFF(%ebx) + fldl 88+_P6@GOTOFF(%ebx) + fldl 96+_P6@GOTOFF(%ebx) + fldl 80+_P6@GOTOFF(%ebx) + fxch %st(4) + fsubl 112+_P6@GOTOFF(%ebx) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fmul %st, %st(4) + fmul %st, %st(3) + fmul %st, %st(6) + fxch %st(5) + faddl 72+_P6@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 56+_P6@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 40+_P6@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(4) + faddl 24+_P6@GOTOFF(%ebx) + fmul %st(1), %st + fmul %st(2), %st + fxch %st(4) + faddl 8+_P6@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + faddl 64+_P6@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 48+_P6@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(4) + faddl 32+_P6@GOTOFF(%ebx) + fmulp %st, %st(3) + fxch %st(3) + faddl 16+_P6@GOTOFF(%ebx) + fmulp %st, %st(1) + fxch %st(1) + faddl _P6@GOTOFF(%ebx) + faddp %st, %st(1) + faddp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.17: + flds 8(%ebp) + lea 32(%esp), %eax + fld1 + fdiv %st(1), %st + lea 40(%esp), %edx + fstl 16(%eax) + fldl _val_16_0@GOTOFF(%ebx) + fmulp %st, %st(1) + fstl 24(%eax) + fmul %st(0), %st + fstl 32(%eax) + fmul %st(0), %st + fxch %st(1) + fstpl (%esp) + movl %eax, 8(%esp) + movl %edx, 12(%esp) + movl $-3, 16(%esp) + fstpl 40(%eax) + call __libm_sincos_k32 +..B1.18: + fldl 72(%esp) + fldl 64(%esp) + fldl _tonpi@GOTOFF(%ebx) + fmull 48(%esp) + fsqrt + fldl 40+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fldl 32+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 24+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 16+_PP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + faddl 8+_PP@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl _PP@GOTOFF(%ebx) + faddp %st, %st(1) + fldl 40+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(1) + fmull 32(%esp) + fxch %st(1) + faddl 24+_QP@GOTOFF(%ebx) + fmul %st(4), %st + fldl 32+_QP@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(1) + faddl 8+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + faddl 16+_QP@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + faddl _QP@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmull 56(%esp) + fmull 40(%esp) + faddp %st, %st(2) + fmulp %st, %st(1) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.19: + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.25 +..B1.20: + testl %eax, %eax + je ..B1.26 +..B1.21: + fldz + testl $-2147483648, %edx + je ..B1.24 +..B1.23: + flds .L_2il0floatpacket.1@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.24: + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.25: + flds 8(%ebp) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret +..B1.26: + fldz + fdivrs .L_2il0floatpacket.0@GOTOFF(%ebx) + addl $124, %esp + popl %ebx + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type y1f,@function + .size y1f,.-y1f + .data +# -- End y1f + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x7f800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_Q1: + .long 330682653 + .long 3217627238 + .long 1311559603 + .long 1068225431 + .long 1711886415 + .long 3211277751 + .long 3301707240 + .long 1058195349 + .long 1381458166 + .long 3199245881 + .long 361785213 + .long 1044511851 + .type _Q1,@object + .size _Q1,48 + .align 4 +_Q2: + .long 4294700894 + .long 1071644671 + .long 4245872852 + .long 3215982591 + .long 2793978972 + .long 1063605588 + .long 1731774639 + .long 3205263755 + .long 824990963 + .long 1051113520 + .long 1573521749 + .long 3191272273 + .type _Q2,@object + .size _Q2,48 + .align 4 +_P1: + .long 3588334709 + .long 1014823416 + .long 1143617537 + .long 1071688264 + .long 543393268 + .long 3216922360 + .long 1079832790 + .long 3214987951 + .long 1415988155 + .long 3212027618 + .long 2493495630 + .long 1065248537 + .long 1666720954 + .long 3211084359 + .long 543676354 + .long 1062304274 + .long 4191589146 + .long 3208689738 + .long 2170605073 + .long 1060053158 + .long 3542706363 + .long 3206309752 + .long 3704389215 + .long 1057513307 + .long 2063423420 + .long 3203511534 + .long 3202091398 + .long 1054023270 + .long 2674374220 + .long 3198818668 + .long 2780141937 + .long 1047561374 + .long 3571446339 + .long 1073845182 + .type _P1,@object + .size _P1,136 + .align 4 +_P2: + .long 2989758108 + .long 1017408064 + .long 1458640109 + .long 3218458565 + .long 2240523794 + .long 1067453343 + .long 773815536 + .long 1068111321 + .long 2743923681 + .long 3211856434 + .long 3232814431 + .long 3210853997 + .long 2451601872 + .long 1059272649 + .long 1805313442 + .long 1057512342 + .long 1838988672 + .long 3200779931 + .long 3139341808 + .long 3198309937 + .long 844655003 + .long 1046186753 + .long 3216852589 + .long 1043859826 + .long 2659303056 + .long 3187506951 + .long 2880143704 + .long 1034033463 + .long 1317515310 + .long 1075165182 + .type _P2,@object + .size _P2,120 + .align 4 +_P3: + .long 280256326 + .long 3163962304 + .long 1070207352 + .long 1070686105 + .long 878012560 + .long 3213896505 + .long 4238571140 + .long 3215341917 + .long 3113338666 + .long 1063505618 + .long 910161668 + .long 1063287399 + .long 1478416875 + .long 3206238429 + .long 3015160168 + .long 3204904859 + .long 3974776004 + .long 1052866426 + .long 579855125 + .long 1050851686 + .long 261378128 + .long 3193590641 + .long 798233178 + .long 3191027115 + .long 1498363474 + .long 1038832298 + .long 2925619636 + .long 1075917095 + .type _P3,@object + .size _P3,112 + .align 4 +_P4: + .long 738390343 + .long 1012897491 + .long 2706267969 + .long 3217932622 + .long 4014538048 + .long 1065632415 + .long 3590329970 + .long 1067673559 + .long 671215353 + .long 3210335979 + .long 2374781669 + .long 3210593529 + .long 1890699418 + .long 1058215403 + .long 1890155166 + .long 1057321344 + .long 1713507622 + .long 3199871308 + .long 2862637523 + .long 3198281783 + .long 1122846306 + .long 1045733660 + .long 622299794 + .long 1043564297 + .long 2771483851 + .long 3185854918 + .long 1632198108 + .long 3183235242 + .long 953430534 + .long 1076330385 + .type _P4,@object + .size _P4,120 + .align 4 +_P5: + .long 342107947 + .long 1017254688 + .long 3187585117 + .long 1070231586 + .long 1823227594 + .long 3212600587 + .long 444207028 + .long 3215024921 + .long 1802122913 + .long 1062365956 + .long 1966738039 + .long 1062934367 + .long 3649894624 + .long 3205237410 + .long 1726294277 + .long 3204703097 + .long 1880085380 + .long 1051980794 + .long 1949762981 + .long 1050731607 + .long 2695921962 + .long 3192939649 + .long 1096030507 + .long 3190939319 + .long 3356663664 + .long 1038219909 + .long 2296284299 + .long 1076743037 + .type _P5,@object + .size _P5,112 + .align 4 +_P6: + .long 1104511903 + .long 3165887820 + .long 3273918356 + .long 3217557377 + .long 1767833442 + .long 1064652506 + .long 4164235278 + .long 1067433581 + .long 3499046825 + .long 3209421592 + .long 1038038689 + .long 3210276846 + .long 3702826228 + .long 1057329476 + .long 3651609877 + .long 1057129169 + .long 1779967631 + .long 3199161987 + .long 3308825176 + .long 3198147781 + .long 897891533 + .long 1045052198 + .long 2444111938 + .long 1043454098 + .long 144575532 + .long 3185257015 + .long 1701846534 + .long 3183129264 + .long 1767841339 + .long 1077021468 + .type _P6,@object + .size _P6,120 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_PP: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP,@object + .size _PP,48 + .align 4 +_QP: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP,@object + .size _QP,48 + .data + .hidden __libm_sincos_k32 + .hidden __libm_log_k32 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/y1l.S b/external/sgx_libm/ia32/y1l.S new file mode 100644 index 0000000000..74cf8a4144 --- /dev/null +++ b/external/sgx_libm/ia32/y1l.S @@ -0,0 +1,106 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y1l.c" + .text +..TXTST0: +# -- Begin y1l + .text + .align 16,0x90 + .globl y1l +y1l: +# parameter 1: 8 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $56, %esp + fldt 8(%ebp) + lea 16(%esp), %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.6: + addl $-32, %esp + movl (%edi), %ecx + lea 64(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl 4(%edi), %edx + movl %ecx, (%eax) + movl %edx, 4(%eax) + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl %ecx, 8(%eax) + movl %edx, 12(%eax) + call __y1q@PLT +..B1.5: + addl $28, %esp +..B1.2: + movl 32(%esp), %eax + movl %eax, (%edi) + movl 36(%esp), %edx + movl 40(%esp), %ecx + movl 44(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B1.7: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type y1l,@function + .size y1l,.-y1l + .data +# -- End y1l + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/yn.S b/external/sgx_libm/ia32/yn.S new file mode 100644 index 0000000000..c5c9742f6e --- /dev/null +++ b/external/sgx_libm/ia32/yn.S @@ -0,0 +1,1341 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "yn.c" + .text +..TXTST0: +# -- Begin yn + .text + .align 16,0x90 + .globl yn +yn: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + movl 8(%ebp), %edx +..B1.2: + fnstcw 70(%esp) +..B1.3: + movzwl 18(%ebp), %ecx + andl $32752, %ecx + shrl $4, %ecx + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + cmpl $2047, %ecx + je ..B1.69 +..B1.4: + fldl 12(%ebp) + fldl _zeros@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jb ..B1.8 +..B1.5: + fxch %st(1) + fucomp %st(1) + fnstsw %ax + sahf + jp ..B1.6 + je ..B1.44 +..B1.6: + fldl _infs@GOTOFF(%ebx) + fmulp %st, %st(1) +..B1.7: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.8: + fstp %st(0) + testl %edx, %edx + je ..B1.43 +..B1.9: + jl ..B1.11 +..B1.10: + movl $1, %edi + jmp ..B1.12 +..B1.11: + negl %edx + movl %edx, %eax + notl %eax + andl $1, %eax + lea -1(%eax,%eax), %edi +..B1.12: + cmpl $1, %edx + je ..B1.58 +..B1.13: + movl %edx, %eax + sarl $5, %eax + cmpl $160, %eax + jg ..B1.15 +..B1.14: + fldl XINF@GOTOFF(%ebx,%eax,8) + jmp ..B1.16 +..B1.15: + lea -640(,%eax,4), %eax + lea (,%eax,8), %ecx + subl %eax, %ecx + movl %ecx, (%esp) + fildl (%esp) + faddl .L_2il0floatpacket.0@GOTOFF(%ebx) +..B1.16: + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.42 +..B1.17: + movzwl 70(%esp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.57 +..B1.18: + fstp %st(0) + orl $-64768, %ecx + movw %cx, 68(%esp) +..B1.19: + fldcw 68(%esp) +..B1.20: + fldl 12(%ebp) + movl $1, %esi +..B1.21: + fldt _val_20_0L@GOTOFF(%ebx) + fldt _val_1000_0L@GOTOFF(%ebx) + movl %edx, (%esp) + fildl (%esp) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fcomp %st(2) + fnstsw %ax + sahf + ja ..B1.46 +..B1.22: + fldt _val_4_0L@GOTOFF(%ebx) + movl $-1, %eax + fstpt 144(%esp) + fldt 144(%esp) + fld %st(1) + fmulp %st, %st(1) + xorl %ecx, %ecx + fmulp %st, %st(1) + movl %ebx, 28(%esp) + fstpt 192(%esp) + fldt 192(%esp) + fxch %st(1) + fstl 104(%esp) + fldt _val_8_0L@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpt 176(%esp) + fldt 176(%esp) + fldt _val_p1_0L@GOTOFF(%ebx) + fstpt (%esp) + fldt (%esp) + fstpt 112(%esp) + fldt _val_n1_0L@GOTOFF(%ebx) + faddp %st, %st(2) + fdivrp %st, %st(1) + fstpt 72(%esp) + fldt 72(%esp) + fldt _val_2_0L@GOTOFF(%ebx) + fstpt 48(%esp) + fldt 48(%esp) + fstpt 160(%esp) + fldt _val_3_0L@GOTOFF(%ebx) + fstpt 32(%esp) + fldt 32(%esp) + fstpt 128(%esp) + fldt _val_5_0L@GOTOFF(%ebx) + fstpt 16(%esp) + fldt _val_0_0L@GOTOFF(%ebx) + movl %eax, %ebx + fstpt 88(%esp) + fldt 16(%esp) + fldt 128(%esp) + fldt 32(%esp) + fldt 48(%esp) + fldt (%esp) +..B1.23: + fldt 192(%esp) + fld %st(4) + fmul %st(5), %st + testl %ebx, %ebx + fsubr %st(1), %st + fxch %st(5) + fstpt 128(%esp) + fxch %st(2) + fstpt 48(%esp) + fldt 48(%esp) + fxch %st(1) + fstpt 16(%esp) + fldt 16(%esp) + fstpt 32(%esp) + fldt 32(%esp) + fldt 176(%esp) + fmul %st, %st(2) + fxch %st(2) + fdivrp %st, %st(5) + fxch %st(6) + fmulp %st, %st(4) + fld %st(4) + fmul %st(5), %st + fsubrp %st, %st(2) + fmul %st(2), %st + fdivrp %st, %st(1) + fmul %st(2), %st + fldt 128(%esp) + fldt 48(%esp) + jle ..B1.25 +..B1.24: + fldt 72(%esp) + fadd %st(3), %st + fstpt 72(%esp) + fxch %st(4) + faddp %st, %st(6) + jmp ..B1.26 +..B1.25: + fldt 72(%esp) + fsub %st(3), %st + fstpt 72(%esp) + fxch %st(4) + fsubrp %st, %st(6) +..B1.26: + fldt 160(%esp) + fadd %st, %st(4) + faddp %st, %st(3) + fld %st(1) + fdiv %st(6), %st + fldt 144(%esp) + fadd %st, %st(2) + faddp %st, %st(6) + fldt 88(%esp) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.29 +..B1.27: + fchs +..B1.29: + fldt 112(%esp) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.31 +..B1.30: + fstpt 112(%esp) + movl $1, %ecx + jmp ..B1.32 +..B1.31: + fstp %st(0) + testl %ecx, %ecx + jne ..B1.45 +..B1.32: + fldt 16(%esp) + negl %ebx + fucomp %st(6) + fnstsw %ax + sahf + fxch %st(3) + fxch %st(1) + fxch %st(5) + jne ..B1.23 + jp ..B1.23 +..B1.33: + fstp %st(2) + fstp %st(3) + fstp %st(2) + fstp %st(0) + fldt 32(%esp) + movl 28(%esp), %ebx + fstpt 12(%esp) + fstpt (%esp) + fstpt 56(%esp) + fldl 104(%esp) +..B1.34: + addl $-32, %esp + addl %edx, %edx + negl %edx + lea 44(%esp), %eax + decl %edx + lea 88(%esp), %ecx + fstpt (%esp) + fldt (%esp) + movl %eax, 12(%esp) + movl %ecx, 16(%esp) + movl %edx, 20(%esp) + fstpl 92(%eax) + call __libm_sincos_pi4l +..B1.78: + fldl 136(%esp) + addl $32, %esp +..B1.35: + fldt _tonpi@GOTOFF(%ebx) + fdivp %st, %st(1) + fsqrt + fldt 12(%esp) + fldt (%esp) + fmulp %st, %st(1) + fldt 56(%esp) + fldt 72(%esp) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 12(%esp) +..B1.36: + testl %esi, %esi + je ..B1.38 +..B1.37: + fldcw 70(%esp) +..B1.38: + fldt 12(%esp) + testl %edi, %edi + jge ..B1.41 +..B1.40: + fchs +..B1.41: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.42: + fstp %st(0) + movzbl 19(%ebp), %eax + andl $128, %eax + shrl $7, %eax + fldl _large_value_64@GOTOFF(%ebx,%eax,8) + fmull _large_value_64@GOTOFF(%ebx) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.43: + addl $-16, %esp + fstpl (%esp) + call y0@PLT +..B1.79: + addl $260, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.44: + fldl 8+_ones@GOTOFF(%ebx) + fdivp %st, %st(1) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.45: + fstp %st(2) + fstp %st(3) + fstp %st(1) + fstp %st(0) + fldt 32(%esp) + movl 28(%esp), %ebx + fstpt 12(%esp) + fxch %st(1) + fstpt (%esp) + fstpt 56(%esp) + fldl 104(%esp) + jmp ..B1.34 +..B1.46: + fstp %st(0) + fldt _val_36_0L@GOTOFF(%ebx) + fcom %st(1) + fnstsw %ax + sahf + jbe ..B1.50 +..B1.47: + fstp %st(0) + addl $-16, %esp + fstpt (%esp) + fldt (%esp) + fstpl 120(%esp) + movl %edx, 52(%esp) + call __y0l@PLT +..B1.80: + fldl 120(%esp) + movl 52(%esp), %edx + addl $16, %esp +..B1.48: + fxch %st(1) + fstpt 56(%esp) + addl $-16, %esp + fstpt (%esp) + fldt (%esp) + fstpl 120(%esp) + movl %edx, 52(%esp) + call __y1l@PLT +..B1.81: + fldl 120(%esp) + movl 52(%esp), %edx + addl $16, %esp +..B1.49: + fxch %st(1) + jmp ..B1.52 +..B1.50: + fldl _ones@GOTOFF(%ebx) + fdiv %st(2), %st + fmul %st, %st(1) + fld %st(1) + fmul %st(2), %st + fstpt 12(%esp) + fldt 12(%esp) + fxch %st(1) + fstpt 24(%esp) + fxch %st(1) + fstpt (%esp) + fldt (%esp) + fldt _PP0@GOTOFF(%ebx) + fmul %st(2), %st + fldt 12+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(2), %st + fldt _PP1@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 24+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 36+_PP0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 48+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 60+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 48+_PP1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 60+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 72+_PP0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 84+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 96+_PP0@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 84+_PP1@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt 96+_PP1@GOTOFF(%ebx) + faddp %st, %st(1) + fmul %st(3), %st + fldt 108+_PP0@GOTOFF(%ebx) + faddp %st, %st(2) + fxch %st(1) + fstpt 40(%esp) + addl $-32, %esp + lea 32(%esp), %eax + lea 44(%esp), %ecx + fxch %st(3) + fstpt (%esp) + fldt (%esp) + fldt 108+_PP1@GOTOFF(%ebx) + movl %eax, 12(%esp) + faddp %st, %st(4) + fldt _QP0@GOTOFF(%ebx) + fmul %st(3), %st + fldt 12+_QP0@GOTOFF(%ebx) + movl %ecx, 16(%esp) + faddp %st, %st(1) + fmul %st(3), %st + fldt _QP1@GOTOFF(%ebx) + fmul %st(4), %st + fldt 12+_QP1@GOTOFF(%ebx) + movl $-1, 20(%esp) + faddp %st, %st(1) + fmul %st(4), %st + fxch %st(5) + fstpt 88(%eax) + fxch %st(1) + fstpl 104(%eax) + fldt 24+_QP0@GOTOFF(%ebx) + movl %edx, 36(%eax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 24+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fldt 36+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 48+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 60+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 72+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 84+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fmul %st, %st(3) + fldt 96+_QP1@GOTOFF(%ebx) + faddp %st, %st(4) + fldt 36+_QP0@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 48+_QP0@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 60+_QP0@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 72+_QP0@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 84+_QP0@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt 96+_QP0@GOTOFF(%ebx) + faddp %st, %st(3) + fmul %st, %st(2) + fmulp %st, %st(3) + fldt 108+_QP0@GOTOFF(%ebx) + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fstpt 56(%eax) + fldt 108+_QP1@GOTOFF(%ebx) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 72(%eax) + call __libm_sincos_pi4l +..B1.82: + fldl 136(%esp) + fldt 120(%esp) + fldt 104(%esp) + fldt 88(%esp) + movl 68(%esp), %edx + addl $32, %esp +..B1.51: + fldt _tonpi@GOTOFF(%ebx) + fldt 24(%esp) + fmulp %st, %st(1) + fsqrt + fldt (%esp) + fldt 12(%esp) + fmul %st, %st(3) + fmulp %st, %st(5) + fldt 40(%esp) + fmul %st(1), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fstpt 56(%esp) + fmulp %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fmulp %st, %st(1) +..B1.52: + fldt _val_2_0L@GOTOFF(%ebx) + cmpl $1, %edx + fld %st(0) + jle ..B1.56 +..B1.53: + fldt 56(%esp) + decl %edx + xorl %eax, %eax +..B1.54: + fld %st(1) + incl %eax + fdiv %st(5), %st + cmpl %edx, %eax + fmul %st(4), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(2) + fsubp %st, %st(1) + fld %st(3) + jae ..B1.55 +..B1.84: + fstp %st(4) + fxch %st(3) + jmp ..B1.54 +..B1.55: + fstp %st(5) + fstp %st(4) + fstp %st(0) + fstp %st(0) + fxch %st(1) + fstpt 12(%esp) + fstpt 56(%esp) + jmp ..B1.36 +..B1.56: + fstp %st(3) + fstp %st(2) + fstp %st(1) + fstpt 12(%esp) + jmp ..B1.36 +..B1.57: + xorl %esi, %esi + jmp ..B1.21 +..B1.58: + testl %ecx, %ecx + jne ..B1.65 +..B1.59: + testl $1048575, 16(%ebp) + jne ..B1.65 +..B1.60: + cmpl $1, 12(%ebp) + jne ..B1.65 +..B1.61: + fstp %st(0) + fldl _large_value_64@GOTOFF(%ebx) + testl %edi, %edi + jl ..B1.63 +..B1.62: + fldl 8+_large_value_64@GOTOFF(%ebx) + fmulp %st, %st(1) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.63: + fld %st(0) + fmulp %st, %st(1) +..B1.64: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.65: + addl $-16, %esp + fstpl (%esp) + call y1@PLT +..B1.83: + addl $16, %esp + testl %edi, %edi + jge ..B1.68 +..B1.67: + fchs +..B1.68: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.69: + testl $1048575, 16(%ebp) + jne ..B1.74 +..B1.70: + cmpl $0, 12(%ebp) + jne ..B1.74 +..B1.71: + movzbl 19(%ebp), %eax + testl $128, %eax + jne ..B1.75 +..B1.72: + movl %edx, %eax + shrl $31, %eax + andl %edx, %eax + fldl _zeros@GOTOFF(%ebx,%eax,8) +..B1.73: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.74: + fldl 12(%ebp) + fmull _ones@GOTOFF(%ebx) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.75: + fldl _infs@GOTOFF(%ebx) + fmull _zeros@GOTOFF(%ebx) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type yn,@function + .size yn,.-yn + .data +# -- End yn + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40adc000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +XINF: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x33333333,0x3fd33333 + .long 0xcccccccd,0x3ff4cccc + .long 0x33333333,0x400b3333 + .long 0x33333333,0x401b3333 + .long 0x33333333,0x40273333 + .long 0xcccccccd,0x4031cccc + .long 0x66666666,0x40396666 + .long 0x9999999a,0x40411999 + .long 0x9999999a,0x40461999 + .long 0x66666666,0x404ba666 + .long 0x9999999a,0x4050d999 + .long 0x00000000,0x40542000 + .long 0x33333333,0x40579333 + .long 0x9999999a,0x405b3999 + .long 0x00000000,0x405f0000 + .long 0x00000000,0x40618000 + .long 0x00000000,0x40638000 + .long 0x00000000,0x4065a000 + .long 0x00000000,0x4067e000 + .long 0x00000000,0x406a2000 + .long 0x00000000,0x406c8000 + .long 0x00000000,0x406ee000 + .long 0x00000000,0x4070a000 + .long 0x00000000,0x4071e000 + .long 0x00000000,0x40732000 + .long 0x00000000,0x40746000 + .long 0x00000000,0x4075b000 + .long 0x00000000,0x40770000 + .long 0x00000000,0x40785000 + .long 0x00000000,0x4079a000 + .long 0x00000000,0x407b0000 + .long 0x00000000,0x407c6000 + .long 0x00000000,0x407dc000 + .long 0x00000000,0x407f3000 + .long 0x00000000,0x40804800 + .long 0x00000000,0x40810000 + .long 0x00000000,0x4081b800 + .long 0x00000000,0x40827000 + .long 0x00000000,0x40832800 + .long 0x00000000,0x4083e000 + .long 0x00000000,0x4084a000 + .long 0x00000000,0x40856000 + .long 0x00000000,0x40861800 + .long 0x00000000,0x4086d800 + .long 0x00000000,0x4087a000 + .long 0x00000000,0x40886000 + .long 0x00000000,0x40892000 + .long 0x00000000,0x4089e800 + .long 0x00000000,0x408aa800 + .long 0x00000000,0x408b7000 + .long 0x00000000,0x408c3000 + .long 0x00000000,0x408cf800 + .long 0x00000000,0x408dc000 + .long 0x00000000,0x408e8800 + .long 0x00000000,0x408f5800 + .long 0x00000000,0x40901000 + .long 0x00000000,0x40907400 + .long 0x00000000,0x4090d800 + .long 0x00000000,0x40914000 + .long 0x00000000,0x4091a800 + .long 0x00000000,0x40920c00 + .long 0x00000000,0x40927400 + .long 0x00000000,0x4092dc00 + .long 0x00000000,0x40934400 + .long 0x00000000,0x4093a800 + .long 0x00000000,0x40941000 + .long 0x00000000,0x40947800 + .long 0x00000000,0x4094e400 + .long 0x00000000,0x40954c00 + .long 0x00000000,0x4095b400 + .long 0x00000000,0x40961c00 + .long 0x00000000,0x40968800 + .long 0x00000000,0x4096f000 + .long 0x00000000,0x40975c00 + .long 0x00000000,0x4097c400 + .long 0x00000000,0x40983000 + .long 0x00000000,0x40989800 + .long 0x00000000,0x40990400 + .long 0x00000000,0x40997000 + .long 0x00000000,0x4099d800 + .long 0x00000000,0x409a4400 + .long 0x00000000,0x409ab000 + .long 0x00000000,0x409b1c00 + .long 0x00000000,0x409b8800 + .long 0x00000000,0x409bf400 + .long 0x00000000,0x409c6000 + .long 0x00000000,0x409ccc00 + .long 0x00000000,0x409d3800 + .long 0x00000000,0x409da400 + .long 0x00000000,0x409e1000 + .long 0x00000000,0x409e8000 + .long 0x00000000,0x409eec00 + .long 0x00000000,0x409f5800 + .long 0x00000000,0x409fc800 + .long 0x00000000,0x40a01a00 + .long 0x00000000,0x40a05000 + .long 0x00000000,0x40a08800 + .long 0x00000000,0x40a0be00 + .long 0x00000000,0x40a0f600 + .long 0x00000000,0x40a12c00 + .long 0x00000000,0x40a16400 + .long 0x00000000,0x40a19a00 + .long 0x00000000,0x40a1d200 + .long 0x00000000,0x40a20a00 + .long 0x00000000,0x40a24000 + .long 0x00000000,0x40a27800 + .long 0x00000000,0x40a2b000 + .long 0x00000000,0x40a2e800 + .long 0x00000000,0x40a31e00 + .long 0x00000000,0x40a35600 + .long 0x00000000,0x40a38e00 + .long 0x00000000,0x40a3c600 + .long 0x00000000,0x40a3fe00 + .long 0x00000000,0x40a43600 + .long 0x00000000,0x40a46e00 + .long 0x00000000,0x40a4a600 + .long 0x00000000,0x40a4de00 + .long 0x00000000,0x40a51600 + .long 0x00000000,0x40a54e00 + .long 0x00000000,0x40a58600 + .long 0x00000000,0x40a5be00 + .long 0x00000000,0x40a5f600 + .long 0x00000000,0x40a62e00 + .long 0x00000000,0x40a66600 + .long 0x00000000,0x40a6a000 + .long 0x00000000,0x40a6d800 + .long 0x00000000,0x40a71000 + .long 0x00000000,0x40a74800 + .long 0x00000000,0x40a78200 + .long 0x00000000,0x40a7ba00 + .long 0x00000000,0x40a7f200 + .long 0x00000000,0x40a82c00 + .long 0x00000000,0x40a86400 + .long 0x00000000,0x40a89c00 + .long 0x00000000,0x40a8d600 + .long 0x00000000,0x40a90e00 + .long 0x00000000,0x40a94600 + .long 0x00000000,0x40a98000 + .long 0x00000000,0x40a9b800 + .long 0x00000000,0x40a9f200 + .long 0x00000000,0x40aa2a00 + .long 0x00000000,0x40aa6400 + .long 0x00000000,0x40aa9c00 + .long 0x00000000,0x40aad600 + .long 0x00000000,0x40ab1000 + .long 0x00000000,0x40ab4800 + .long 0x00000000,0x40ab8200 + .long 0x00000000,0x40abba00 + .long 0x00000000,0x40abf400 + .long 0x00000000,0x40ac2e00 + .long 0x00000000,0x40ac6600 + .long 0x00000000,0x40aca000 + .long 0x00000000,0x40acda00 + .long 0x00000000,0x40ad1200 + .long 0x00000000,0x40ad4c00 + .long 0x00000000,0x40ad8600 + .long 0x00000000,0x40adc000 + .type XINF,@object + .size XINF,1288 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_val_20_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16387 + .word 0 + .type _val_20_0L,@object + .size _val_20_0L,12 + .align 2 +_val_1000_0L: + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .type _val_1000_0L,@object + .size _val_1000_0L,12 + .align 2 +_val_4_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16385 + .word 0 + .type _val_4_0L,@object + .size _val_4_0L,12 + .align 2 +_val_8_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16386 + .word 0 + .type _val_8_0L,@object + .size _val_8_0L,12 + .align 2 +_val_p1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _val_p1_0L,@object + .size _val_p1_0L,12 + .align 2 +_val_n1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .type _val_n1_0L,@object + .size _val_n1_0L,12 + .align 2 +_val_2_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .type _val_2_0L,@object + .size _val_2_0L,12 + .align 2 +_val_3_0L: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .type _val_3_0L,@object + .size _val_3_0L,12 + .align 2 +_val_5_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16385 + .word 0 + .type _val_5_0L,@object + .size _val_5_0L,12 + .align 2 +_val_0_0L: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _val_0_0L,@object + .size _val_0_0L,12 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .type _tonpi,@object + .size _tonpi,12 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,12 + .align 2 +_PP0: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP0,@object + .size _PP0,120 + .align 2 +_PP1: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .type _PP1,@object + .size _PP1,120 + .align 2 +_QP0: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .type _QP0,@object + .size _QP0,120 + .align 2 +_QP1: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .type _QP1,@object + .size _QP1,120 + .data + .hidden __libm_sincos_pi4l + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ynf.S b/external/sgx_libm/ia32/ynf.S new file mode 100644 index 0000000000..1aae4059b3 --- /dev/null +++ b/external/sgx_libm/ia32/ynf.S @@ -0,0 +1,1442 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ynf.c" + .text +..TXTST0: +# -- Begin ynf + .text + .align 16,0x90 + .globl ynf +ynf: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %esi + pushl %edi + pushl %ebx + subl $244, %esp + fldz + movl 12(%ebp), %ecx + movl 8(%ebp), %esi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + lea -1(%ecx), %edx + cmpl $2139095039, %edx + jae ..B1.51 +..B1.2: + testl %esi, %esi + je ..B1.66 +..B1.3: + movl %ecx, %edi + movl %esi, %eax + xorl %esi, %edi + cltd + shrl $31, %edi + andl %esi, %edi + xorl %edx, %esi + subl %edx, %esi + cmpl $1, %esi + je ..B1.61 +..B1.4: + movl %esi, %eax + sarl $3, %eax + cmpl $320, %eax + jg ..B1.6 +..B1.5: + flds function_zeros@GOTOFF(%ebx,%eax,4) + jmp ..B1.7 +..B1.6: + fldt .L_2il0floatpacket.0@GOTOFF(%ebx) + lea -320(%eax), %edx + lea -2560(,%eax,8), %eax + subl %edx, %eax + movl %eax, 192(%esp) + fildl 192(%esp) + fstps 192(%esp) + flds 192(%esp) + faddp %st, %st(1) + fstps 192(%esp) + flds 192(%esp) +..B1.7: + flds 12(%ebp) + fxch %st(1) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.50 +..B1.8: + cmpl $6, %esi + jge ..B1.23 +..B1.9: + fldl _val_0_6@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jb ..B1.24 +..B1.10: + fldl _val_2_0@GOTOFF(%ebx) + fld %st(1) + fdiv %st(1), %st + testl %esi, %esi + fstpl 200(%esp) + fdiv %st(1), %st + fldl 200(%esp) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + flds _ones@GOTOFF(%ebx) + fstpt 32(%esp) + fldt 32(%esp) + fld %st(0) + fxch %st(1) + fstpt 96(%esp) + fldt 96(%esp) + fld %st(0) + flds _zeros@GOTOFF(%ebx) + jle ..B1.57 +..B1.11: + fstp %st(7) + fxch %st(4) + fstpt 112(%esp) + xorl %edx, %edx + fxch %st(2) + fstpt 48(%esp) + fxch %st(3) + fstps 44(%esp) + fldt 96(%esp) + fldt 32(%esp) +..B1.12: + fldt 112(%esp) + incl %edx + fmulp %st, %st(5) + cmpl %esi, %edx + fxch %st(4) + fstpl 200(%esp) + fld %st(3) + fxch %st(3) + fmul %st, %st(4) + fldl 200(%esp) + fldt 48(%esp) + fmulp %st, %st(3) + fxch %st(2) + fstpl 200(%esp) + fld %st(2) + fdiv %st(1), %st + faddp %st, %st(6) + fadd %st(2), %st + fldl 200(%esp) + fxch %st(5) + fstpl 200(%esp) + fldl 200(%esp) + fxch %st(6) + fstpl 200(%esp) + fldl 200(%esp) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + jae ..B1.13 +..B1.77: + fstp %st(4) + fxch %st(5) + fxch %st(4) + fxch %st(1) + fxch %st(4) + jmp ..B1.12 +..B1.13: + fstp %st(0) + flds 44(%esp) + fxch %st(5) + fstpt 96(%esp) + fxch %st(5) + fstpt 32(%esp) + fldt 112(%esp) + fxch %st(3) + fxch %st(5) + fxch %st(2) +..B1.14: + fldl _TWO_19H@GOTOFF(%ebx) + fld %st(3) + fxch %st(5) + fmul %st(0), %st + xorl %ecx, %ecx + fchs + movl %esi, %edx + fstpl 200(%esp) + fxch %st(1) + fstl 168(%esp) + fxch %st(3) + fstl 184(%esp) + fxch %st(2) + fstpt 48(%esp) + fxch %st(4) + fstps 44(%esp) + fldl 200(%esp) +..B1.15: + incl %ecx + incl %edx + movl %ecx, %eax + imull %edx, %eax + movl %eax, 192(%esp) + lea (%esi,%ecx,2), %eax + fildl 192(%esp) + fstps 192(%esp) + flds 192(%esp) + fdivrs _ones@GOTOFF(%ebx) + movl %eax, 192(%esp) + fstpl 200(%esp) + fldl 200(%esp) + fildl 192(%esp) + fstpl 200(%esp) + fldl 200(%esp) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(4) + fstpl 200(%esp) + fldl 200(%esp) + fldl 168(%esp) + fmul %st(2), %st + fmulp %st, %st(5) + fxch %st(4) + fstpl 200(%esp) + fldl 200(%esp) + fstl 168(%esp) + fadd %st, %st(3) + fxch %st(3) + fstpl 200(%esp) + fxch %st(2) + fmul %st(3), %st + fldl 200(%esp) + fxch %st(1) + faddl 184(%esp) + fstpl 200(%esp) + fldl 200(%esp) + fld %st(0) + fmul %st(6), %st + fstpl 200(%esp) + fstl 184(%esp) + fldl 200(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpl 176(%esp) + fldl 176(%esp) + fsubp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fucom %st(2) + fnstsw %ax + fxch %st(2) + fstp %st(0) + sahf + fxch %st(2) + jne ..B1.15 + jp ..B1.15 +..B1.16: + fstp %st(1) + fstp %st(3) + fstp %st(1) + fldt 48(%esp) + flds 44(%esp) + fldt 32(%esp) + fdivrp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fmul %st, %st(2) + fxch %st(2) + fstpl 200(%esp) + fxch %st(1) + fstpl 168(%esp) + fldl 200(%esp) + fldl _eulon2@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpl (%esp) + fxch %st(1) + fstpt 112(%esp) + fstpt 64(%esp) + fstpt 80(%esp) + call __libm_log_k32 +..B1.72: + fldt 80(%esp) + fldt 64(%esp) + fldt 112(%esp) +..B1.17: + fldl _oonpi@GOTOFF(%ebx) + fxch %st(1) + fchs + fldl _tonpi@GOTOFF(%ebx) + cmpl $1, %esi + fmulp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + fldl 184(%esp) + fmul %st(1), %st + fmull 168(%esp) + fsubrp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + jle ..B1.78 +..B1.18: + movl $1, %ecx + lea -1(%esi), %edx + fld %st(2) + .align 16,0x90 +..B1.19: + movl %ecx, %ebx + incl %ecx + imull %edx, %ebx + decl %edx + fmul %st(4), %st + movl %ebx, 192(%esp) + cmpl %esi, %ecx + fildl 192(%esp) + fstpl 200(%esp) + fldl 200(%esp) + fdivrp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fadd %st, %st(3) + fxch %st(3) + fstpl 200(%esp) + fldl 200(%esp) + fxch %st(3) + jl ..B1.19 +..B1.20: + fstp %st(0) + fstp %st(3) +..B1.21: + fldt 96(%esp) + fxch %st(2) + fmulp %st, %st(1) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) + jmp ..B1.46 +..B1.23: + cmpl $80, %esi + jge ..B1.35 +..B1.24: + fxch %st(1) + fstpl 184(%esp) +..B1.25: + fldl _val_18_0@GOTOFF(%ebx) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.29 +..B1.26: + fstl (%esp) + fstps 44(%esp) + call y0@PLT +..B1.73: + flds 44(%esp) +..B1.27: + fstl (%esp) + fxch %st(1) + fstpl 168(%esp) + fstps 44(%esp) + call y1@PLT +..B1.74: + flds 44(%esp) +..B1.28: + fxch %st(1) + jmp ..B1.31 +..B1.29: + flds _ones@GOTOFF(%ebx) + lea 96(%esp), %edx + fdiv %st(1), %st + lea 104(%esp), %ecx + fstpl 104(%edx) + fldl 104(%edx) + fstpt -64(%edx) + fldt -64(%edx) + fldl _val_16_0@GOTOFF(%ebx) + fmulp %st, %st(1) + fstpl 104(%edx) + fldl 104(%edx) + fld %st(0) + fmul %st(1), %st + fstpl 104(%edx) + fldl 104(%edx) + fld %st(0) + fmul %st(1), %st + fstpl 104(%edx) + fldl 104(%edx) + fxch %st(3) + fstl (%esp) + movl %edx, 8(%esp) + movl %ecx, 12(%esp) + movl $-1, 16(%esp) + fxch %st(1) + fstpt -48(%edx) + fxch %st(2) + fstpt -32(%edx) + fstpt -16(%edx) + fstps -52(%edx) + call __libm_sincos_k32 +..B1.30: + flds 44(%esp) + fldt 80(%esp) + fldt 64(%esp) + fldt 48(%esp) + fldl 40+_PP0@GOTOFF(%ebx) + fmul %st(2), %st + fldl 32+_PP0@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 24+_PP0@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 16+_PP0@GOTOFF(%ebx) + fmul %st(3), %st + fxch %st(1) + faddl 8+_PP0@GOTOFF(%ebx) + fmul %st(2), %st + fstpl 200(%esp) + fldl 200(%esp) + fldl 32+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl _PP0@GOTOFF(%ebx) + fstpl 200(%esp) + fldl 200(%esp) + faddp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fldl 40+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl 16+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl 24+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fxch %st(2) + faddl _PP1@GOTOFF(%ebx) + fldl 32+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl 8+_PP1@GOTOFF(%ebx) + fmul %st(4), %st + fstpl 200(%esp) + fldl 200(%esp) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + faddp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fldl 40+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl 16+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl 24+_QP0@GOTOFF(%ebx) + fmul %st(5), %st + fxch %st(3) + faddl _QP0@GOTOFF(%ebx) + fmul %st(6), %st + fxch %st(3) + faddl 8+_QP0@GOTOFF(%ebx) + fmul %st(4), %st + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fstpl 200(%esp) + fldl 200(%esp) + fldl 40+_QP1@GOTOFF(%ebx) + fmul %st(5), %st + faddl 24+_QP1@GOTOFF(%ebx) + fmul %st(5), %st + faddl 8+_QP1@GOTOFF(%ebx) + fmulp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fldl 32+_QP1@GOTOFF(%ebx) + fmul %st(5), %st + faddl 16+_QP1@GOTOFF(%ebx) + fmulp %st, %st(5) + fldl _tonpi@GOTOFF(%ebx) + fxch %st(5) + faddl _QP1@GOTOFF(%ebx) + fmulp %st, %st(6) + faddp %st, %st(5) + fxch %st(4) + fstpl 200(%esp) + fldl 200(%esp) + fldt 32(%esp) + fmulp %st, %st(4) + fxch %st(3) + fstpl 200(%esp) + fldl 200(%esp) + fsqrt + fstpl 200(%esp) + fldl 200(%esp) + fldl 96(%esp) + fmul %st, %st(5) + fmulp %st, %st(4) + fldl 104(%esp) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fmul %st, %st(4) + fxch %st(4) + fstpl 168(%esp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fmulp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) +..B1.31: + fldl _val_2_0@GOTOFF(%ebx) + cmpl $1, %esi + fdivp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + jle ..B1.79 +..B1.32: + fldl 168(%esp) + movl $1, %edx +..B1.33: + movl %edx, 192(%esp) + incl %edx + fildl 192(%esp) + fstpl 200(%esp) + fld %st(2) + fldl 200(%esp) + cmpl %esi, %edx + fmul %st(3), %st + fmulp %st, %st(4) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(2) + fstpl 200(%esp) + fldl 200(%esp) + fxch %st(2) + jl ..B1.33 +..B1.34: + fstp %st(0) + fstp %st(0) + jmp ..B1.46 +..B1.35: + lea 5000(%esi,%esi,4), %edx + movl %edx, 192(%esp) + fildl 192(%esp) + fstpl 200(%esp) + fldl 200(%esp) + fcomp %st(1) + fnstsw %ax + sahf + ja ..B1.24 +..B1.36: + fstp %st(1) + fldl _val_4_0@GOTOFF(%ebx) + movl $-1, %ecx + movl %esi, 192(%esp) + xorl %edx, %edx + fstl 160(%esp) + fxch %st(1) + fsts 44(%esp) + fildl 192(%esp) + fstpl 200(%esp) + fldl 200(%esp) + fld %st(0) + fmulp %st, %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fstpt 128(%esp) + fldt 128(%esp) + fldl _val_8_0@GOTOFF(%ebx) + fmulp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fstpt 112(%esp) + fldt 112(%esp) + flds _ones@GOTOFF(%ebx) + fstl 152(%esp) + fstpt 80(%esp) + fldt 80(%esp) + flds 4+_ones@GOTOFF(%ebx) + faddp %st, %st(3) + fxch %st(1) + fdivrp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fstpt 64(%esp) + fldt 64(%esp) + fstpl 168(%esp) + fldl _val_2_0@GOTOFF(%ebx) + fstl 144(%esp) + fldl _val_3_0@GOTOFF(%ebx) + fstpt 48(%esp) + fldt 48(%esp) + fldl _val_5_0@GOTOFF(%ebx) + fstpt 32(%esp) + fld %st(2) + fdiv %st(3), %st + fstpl 200(%esp) + fldl 200(%esp) + fstpt 96(%esp) + fldt 80(%esp) + fldt 32(%esp) + fldt 48(%esp) +..B1.37: + fldt 112(%esp) + fld %st(5) + fmul %st(1), %st + testl %ecx, %ecx + fxch %st(1) + fmul %st(5), %st + fxch %st(7) + fstpl 184(%esp) + fld %st(1) + fmul %st(2), %st + fxch %st(4) + fstpt 80(%esp) + fldt 128(%esp) + fsub %st, %st(4) + fxch %st(1) + fdivrp %st, %st(4) + fld %st(2) + fmul %st(3), %st + fsubrp %st, %st(1) + fdivp %st, %st(6) + fxch %st(2) + fmull 168(%esp) + fstpl 200(%esp) + fldl 200(%esp) + fxch %st(5) + fstpl 200(%esp) + fldl 200(%esp) + fmul %st(5), %st + fstpl 200(%esp) + fldl 200(%esp) + fldt 80(%esp) + jle ..B1.59 +..B1.38: + faddp %st, %st(6) + fxch %st(5) + fstpl 200(%esp) + fldl 200(%esp) + fldt 64(%esp) + fadd %st(6), %st + fstpl 200(%esp) + fldl 200(%esp) + fstpt 64(%esp) +..B1.39: + fldl 144(%esp) + fadd %st, %st(5) + fxch %st(5) + fstpl 200(%esp) + fxch %st(4) + faddp %st, %st(3) + fxch %st(4) + fstl 168(%esp) + fldl 200(%esp) + fxch %st(3) + fstpl 200(%esp) + fldl 200(%esp) + fldl 160(%esp) + fadd %st, %st(3) + fxch %st(3) + fstpl 200(%esp) + fxch %st(2) + faddp %st, %st(5) + fldl 200(%esp) + fxch %st(5) + fstpl 200(%esp) + fldl 200(%esp) + fldt 96(%esp) + fmulp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fabs + fldl 152(%esp) + fcomp %st(1) + fnstsw %ax + sahf + jbe ..B1.41 +..B1.40: + fstpl 152(%esp) + movl $1, %edx + jmp ..B1.42 +..B1.41: + fstp %st(0) + testl %edx, %edx + jne ..B1.58 +..B1.42: + fldl _TWO_19H@GOTOFF(%ebx) + negl %ecx + fmul %st(4), %st + fstpl 200(%esp) + fld %st(3) + fldl 200(%esp) + fadd %st, %st(1) + fxch %st(1) + fstpl 176(%esp) + fldl 176(%esp) + fsubp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fldl 184(%esp) + fucomp %st(1) + fnstsw %ax + sahf + fxch %st(5) + fxch %st(2) + fxch %st(3) + fxch %st(4) + fxch %st(2) + jne ..B1.37 + jp ..B1.37 +..B1.43: + fstp %st(5) + fstp %st(4) + fstp %st(3) + fstp %st(0) + fstp %st(0) + fstpt 80(%esp) + flds 44(%esp) +..B1.44: + addl %esi, %esi + lea 184(%esp), %edx + negl %esi + lea 168(%esp), %ecx + fstl (%esp) + decl %esi + movl %edx, 8(%esp) + movl %ecx, 12(%esp) + movl %esi, 16(%esp) + fstps -124(%ecx) + call __libm_sincos_k32 +..B1.45: + flds 44(%esp) + fldt 80(%esp) + fmull 184(%esp) + fldt 64(%esp) + fmull 168(%esp) + faddp %st, %st(1) + fldl _tonpi@GOTOFF(%ebx) + fdivp %st, %st(2) + fxch %st(1) + fstpl 200(%esp) + fldl 200(%esp) + fsqrt + fstpl 200(%esp) + fldl 200(%esp) + fmulp %st, %st(1) + fstpl 200(%esp) + fldl 200(%esp) +..B1.46: + testl %edi, %edi + je ..B1.49 +..B1.47: + fchs +..B1.49: + fstps 192(%esp) + flds 192(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.50: + fstp %st(1) + fstp %st(0) + fldt .L_2il0floatpacket.1@GOTOFF(%ebx) + shrl $31, %ecx + fmuls _large_value_32@GOTOFF(%ebx,%ecx,4) + fstps 192(%esp) + flds 192(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.51: + fstp %st(0) + movl %ecx, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + ja ..B1.56 +..B1.52: + testl %edx, %edx + je ..B1.69 +..B1.53: + testl $-2147483648, %ecx + jne ..B1.68 +..B1.54: + movl %esi, %edx + shrl $31, %edx + andl %esi, %edx + flds _zeros@GOTOFF(%ebx,%edx,4) +..B1.55: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.56: + flds 12(%ebp) + fmuls _ones@GOTOFF(%ebx) + fstps 192(%esp) + flds 192(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.57: + fstp %st(1) + fstp %st(3) + jmp ..B1.14 +..B1.58: + fstp %st(4) + fstp %st(3) + fstp %st(2) + fstp %st(1) + fstpt 80(%esp) + flds 44(%esp) + jmp ..B1.44 +..B1.59: + fsubp %st, %st(6) + fxch %st(5) + fstpl 200(%esp) + fldl 200(%esp) + fldt 64(%esp) + fsub %st(6), %st + fstpl 200(%esp) + fldl 200(%esp) + fstpt 64(%esp) + jmp ..B1.39 +..B1.61: + fstpl 184(%esp) + addl $4, %esp + pushl 12(%ebp) + call y1f@PLT +..B1.62: + testl %edi, %edi + je ..B1.65 +..B1.63: + fchs +..B1.65: + fstps 192(%esp) + flds 192(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.66: + fstpl 184(%esp) + addl $4, %esp + pushl 12(%ebp) + call y0f@PLT +..B1.67: + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.68: + flds _zeros@GOTOFF(%ebx) + fmuls _infs@GOTOFF(%ebx) + fstps 192(%esp) + flds 192(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.69: + flds 4+_ones@GOTOFF(%ebx) + fdivs _zeros@GOTOFF(%ebx) + fstps 192(%esp) + flds 192(%esp) + addl $244, %esp + popl %ebx + popl %edi + popl %esi + movl %ebp, %esp + popl %ebp + ret +..B1.78: + fstp %st(3) + jmp ..B1.21 +..B1.79: + fstp %st(0) + jmp ..B1.46 + .align 16,0x90 + .type ynf,@function + .size ynf,.-ynf + .data +# -- End ynf + .data + .align 4 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_infs: + .long 2139095040 + .long 4286578688 + .type _infs,@object + .size _infs,8 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x8e,0x0a,0x40,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,12 + .space 4, 0x00 # pad + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x63,0x40,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,12 + .align 4 +function_zeros: + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x3ecccccd + .long 0x3fa66666 + .long 0x40400000 + .long 0x40a9999a + .long 0x4101999a + .long 0x41366666 + .long 0x4171999a + .long 0x4198cccd + .long 0x41ba6666 + .long 0x41df3333 + .long 0x42026666 + .long 0x42160000 + .long 0x422a0000 + .long 0x423f3333 + .long 0x42546666 + .long 0x426a0000 + .long 0x42803333 + .long 0x428b999a + .long 0x42970000 + .long 0x42a2999a + .long 0x42ae6666 + .long 0x42ba6666 + .long 0x42c66666 + .long 0x42d2999a + .long 0x42decccd + .long 0x42eb3333 + .long 0x42f7999a + .long 0x4302199a + .long 0x43086666 + .long 0x430ecccd + .long 0x43153333 + .long 0x431b999a + .long 0x4322199a + .long 0x4328999a + .long 0x432f199a + .long 0x4335b333 + .long 0x433c3333 + .long 0x4342e666 + .long 0x43498000 + .long 0x43503333 + .long 0x4356e666 + .long 0x435d999a + .long 0x43644ccd + .long 0x436b0000 + .long 0x4371cccd + .long 0x4378999a + .long 0x437f6666 + .long 0x4383199a + .long 0x43868ccd + .long 0x4389f333 + .long 0x438d6666 + .long 0x4390d99a + .long 0x43944ccd + .long 0x4397c000 + .long 0x439b3333 + .long 0x439eb333 + .long 0x43a23333 + .long 0x43a5a666 + .long 0x43a92666 + .long 0x43aca666 + .long 0x43b02666 + .long 0x43b3a666 + .long 0x43b73333 + .long 0x43bab333 + .long 0x43be4000 + .long 0x43c1c000 + .long 0x43c54ccd + .long 0x43c8d99a + .long 0x43cc6666 + .long 0x43cff333 + .long 0x43d38000 + .long 0x43d70ccd + .long 0x43da999a + .long 0x43de2666 + .long 0x43e1c000 + .long 0x43e54ccd + .long 0x43e8e666 + .long 0x43ec8000 + .long 0x43f00ccd + .long 0x43f3a666 + .long 0x43f74000 + .long 0x43fad99a + .long 0x43fe7333 + .long 0x44010666 + .long 0x4402d333 + .long 0x4404a000 + .long 0x44067333 + .long 0x44084000 + .long 0x440a0ccd + .long 0x440be000 + .long 0x440daccd + .long 0x440f8000 + .long 0x44114ccd + .long 0x44132000 + .long 0x4414f333 + .long 0x4416c666 + .long 0x4418999a + .long 0x441a6666 + .long 0x441c399a + .long 0x441e0ccd + .long 0x441fe000 + .long 0x4421b333 + .long 0x44238ccd + .long 0x44256000 + .long 0x44273333 + .long 0x44290666 + .long 0x442ae000 + .long 0x442cb333 + .long 0x442e8666 + .long 0x44306000 + .long 0x44323333 + .long 0x44340ccd + .long 0x4435e000 + .long 0x4437b99a + .long 0x44398ccd + .long 0x443b6666 + .long 0x443d4000 + .long 0x443f199a + .long 0x4440eccd + .long 0x4442c666 + .long 0x4444a000 + .long 0x4446799a + .long 0x44485333 + .long 0x444a2ccd + .long 0x444c0666 + .long 0x444de000 + .long 0x444fb99a + .long 0x44519333 + .long 0x44536ccd + .long 0x44554666 + .long 0x44572000 + .long 0x44590000 + .long 0x445ad99a + .long 0x445cb333 + .long 0x445e9333 + .long 0x44606ccd + .long 0x44624666 + .long 0x44642666 + .long 0x44660000 + .long 0x4467d99a + .long 0x4469b99a + .long 0x446b9333 + .long 0x446d7333 + .long 0x446f5333 + .long 0x44712ccd + .long 0x44730ccd + .long 0x4474e666 + .long 0x4476c666 + .long 0x4478a666 + .long 0x447a8000 + .long 0x447c6000 + .long 0x447e4000 + .long 0x44801000 + .long 0x4480fccd + .long 0x4481eccd + .long 0x4482dccd + .long 0x4483cccd + .long 0x4484bccd + .long 0x4485accd + .long 0x44869ccd + .long 0x44878ccd + .long 0x44887ccd + .long 0x44896ccd + .long 0x448a5ccd + .long 0x448b4ccd + .long 0x448c3ccd + .long 0x448d2ccd + .long 0x448e1ccd + .long 0x448f0ccd + .long 0x448ffccd + .long 0x4490eccd + .long 0x4491e000 + .long 0x4492d000 + .long 0x4493c000 + .long 0x4494b000 + .long 0x4495a333 + .long 0x44969333 + .long 0x44978333 + .long 0x44987333 + .long 0x44996666 + .long 0x449a5666 + .long 0x449b499a + .long 0x449c399a + .long 0x449d299a + .long 0x449e1ccd + .long 0x449f0ccd + .long 0x44a00000 + .long 0x44a0f000 + .long 0x44a1e333 + .long 0x44a2d333 + .long 0x44a3c666 + .long 0x44a4b666 + .long 0x44a5a99a + .long 0x44a6999a + .long 0x44a78ccd + .long 0x44a87ccd + .long 0x44a97000 + .long 0x44aa6333 + .long 0x44ab5333 + .long 0x44ac4666 + .long 0x44ad399a + .long 0x44ae299a + .long 0x44af1ccd + .long 0x44b01000 + .long 0x44b10333 + .long 0x44b1f333 + .long 0x44b2e666 + .long 0x44b3d99a + .long 0x44b4cccd + .long 0x44b5bccd + .long 0x44b6b000 + .long 0x44b7a333 + .long 0x44b89666 + .long 0x44b9899a + .long 0x44ba7ccd + .long 0x44bb6ccd + .long 0x44bc6000 + .long 0x44bd5333 + .long 0x44be4666 + .long 0x44bf399a + .long 0x44c02ccd + .long 0x44c12000 + .long 0x44c21333 + .long 0x44c30666 + .long 0x44c3f99a + .long 0x44c4eccd + .long 0x44c5e000 + .long 0x44c6d333 + .long 0x44c7c666 + .long 0x44c8b99a + .long 0x44c9accd + .long 0x44caa000 + .long 0x44cb9333 + .long 0x44cc899a + .long 0x44cd7ccd + .long 0x44ce7000 + .long 0x44cf6333 + .long 0x44d05666 + .long 0x44d1499a + .long 0x44d23ccd + .long 0x44d33333 + .long 0x44d42666 + .long 0x44d5199a + .long 0x44d60ccd + .long 0x44d70000 + .long 0x44d7f666 + .long 0x44d8e99a + .long 0x44d9dccd + .long 0x44dad000 + .long 0x44dbc666 + .long 0x44dcb99a + .long 0x44ddaccd + .long 0x44dea333 + .long 0x44df9666 + .long 0x44e0899a + .long 0x44e18000 + .long 0x44e27333 + .long 0x44e36666 + .long 0x44e45ccd + .long 0x44e55000 + .long 0x44e64333 + .long 0x44e7399a + .long 0x44e82ccd + .long 0x44e92333 + .long 0x44ea1666 + .long 0x44eb099a + .long 0x44ec0000 + .long 0x44ecf333 + .long 0x44ede99a + .long 0x44eedccd + .long 0x44efd333 + .long 0x44f0c666 + .long 0x44f1bccd + .long 0x44f2b000 + .long 0x44f3a666 + .long 0x44f4999a + .long 0x44f59000 + .long 0x44f68333 + .long 0x44f7799a + .long 0x44f86ccd + .long 0x44f96333 + .long 0x44fa599a + .long 0x44fb4ccd + .long 0x44fc4333 + .long 0x44fd3666 + .long 0x44fe2ccd + .long 0x44ff2000 + .long 0x45000b33 + .long 0x45008666 + .long 0x45010000 + .long 0x45017000 + .long 0x4501f000 + .long 0x45027000 + .long 0x4502e000 + .long 0x45036000 + .long 0x4503e000 + .long 0x45045000 + .long 0x4504d000 + .long 0x45055000 + .long 0x4505c000 + .long 0x45064000 + .long 0x4506c000 + .long 0x45073000 + .long 0x4507b000 + .long 0x45083000 + .long 0x4508a000 + .long 0x45092000 + .long 0x4509a000 + .long 0x450a1000 + .long 0x450a9000 + .long 0x450b1000 + .long 0x450b8000 + .long 0x450c0000 + .long 0x450c8000 + .long 0x450cf000 + .long 0x450d7000 + .long 0x450df000 + .long 0x450e6000 + .type function_zeros,@object + .size function_zeros,1284 + .align 4 +_val_0_6: + .long 858993459 + .long 1071854387 + .type _val_0_6,@object + .size _val_0_6,8 + .align 4 +_val_2_0: + .long 0 + .long 1073741824 + .type _val_2_0,@object + .size _val_2_0,8 + .align 4 +_TWO_19H: + .long 0 + .long 1093140480 + .type _TWO_19H,@object + .size _TWO_19H,8 + .align 4 +_eulon2: + .long 3400611180 + .long 1072463685 + .type _eulon2,@object + .size _eulon2,8 + .align 4 +_oonpi: + .long 1841940611 + .long 1070882608 + .type _oonpi,@object + .size _oonpi,8 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_val_18_0: + .long 0 + .long 1077018624 + .type _val_18_0,@object + .size _val_18_0,8 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_PP0: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP0,@object + .size _PP0,48 + .align 4 +_PP1: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP1,@object + .size _PP1,48 + .align 4 +_QP0: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP0,@object + .size _QP0,48 + .align 4 +_QP1: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP1,@object + .size _QP1,48 + .align 4 +_val_4_0: + .long 0 + .long 1074790400 + .type _val_4_0,@object + .size _val_4_0,8 + .align 4 +_val_8_0: + .long 0 + .long 1075838976 + .type _val_8_0,@object + .size _val_8_0,8 + .align 4 +_val_3_0: + .long 0 + .long 1074266112 + .type _val_3_0,@object + .size _val_3_0,8 + .align 4 +_val_5_0: + .long 0 + .long 1075052544 + .type _val_5_0,@object + .size _val_5_0,8 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .data + .hidden __libm_sincos_k32 + .hidden __libm_log_k32 + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/ia32/ynl.S b/external/sgx_libm/ia32/ynl.S new file mode 100644 index 0000000000..db3a032599 --- /dev/null +++ b/external/sgx_libm/ia32/ynl.S @@ -0,0 +1,109 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ynl.c" + .text +..TXTST0: +# -- Begin ynl + .text + .align 16,0x90 + .globl ynl +ynl: +# parameter 1: 8 + %ebp +# parameter 2: 12 + %ebp +..B1.1: +..L1: + + pushl %ebp + movl %esp, %ebp + andl $-64, %esp + pushl %edi + pushl %ebx + subl $56, %esp + fldt 12(%ebp) + lea 16(%esp), %edi + call ..L2 +..L2: + popl %ebx + lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%ebx), %ebx + movl %edi, (%esp) + fstpt 4(%esp) + call __ltoq@PLT +..B1.6: + addl $-32, %esp + movl 8(%ebp), %ecx + lea 64(%esp), %edx + movl %edx, (%esp) + lea 16(%esp), %eax + movl %ecx, 4(%esp) + movl (%edi), %edx + movl 4(%edi), %ecx + movl %edx, (%eax) + movl %ecx, 4(%eax) + movl 8(%edi), %edx + movl 12(%edi), %ecx + movl %edx, 8(%eax) + movl %ecx, 12(%eax) + call __ynq@PLT +..B1.5: + addl $28, %esp +..B1.2: + movl 32(%esp), %eax + movl %eax, (%edi) + movl 36(%esp), %edx + movl 40(%esp), %ecx + movl 44(%esp), %eax + addl $4, %esp + pushl %edi + movl %edx, 4(%edi) + movl %ecx, 8(%edi) + movl %eax, 12(%edi) + call __qtol@PLT +..B1.7: + addl $56, %esp + popl %ebx + popl %edi + movl %ebp, %esp + popl %ebp + ret + .align 16,0x90 + .type ynl,@function + .size ynl,.-ynl + .data +# -- End ynl + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/acos.S b/external/sgx_libm/intel64/acos.S new file mode 100644 index 0000000000..9f611cbebd --- /dev/null +++ b/external/sgx_libm/intel64/acos.S @@ -0,0 +1,1912 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acos.c" + .text +..TXTST0: +# -- Begin acos + .text + .align 16,0x90 + .globl acos +acos: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_acos.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + movsd ABSVALMASK(%rip), %xmm4 + movsd ONEMASK(%rip), %xmm3 + xorpd %xmm5, %xmm5 + movsd TMASK(%rip), %xmm2 + movq %xmm0, %xmm1 + psrlq $44, %xmm0 + movd %xmm0, %edx + movq %xmm1, %xmm7 + movl $8192, %ecx + pinsrw $2, %ecx, %xmm5 + movq %xmm1, %xmm0 + movl $524287, %eax + andl %edx, %eax + subl $260864, %eax + cmpl $955, %eax + jae .L_2TAG_PACKET_0.0.2 + mulsd %xmm1, %xmm1 + andl $65535, %edx + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + andpd %xmm7, %xmm2 + andl $-4, %edx + subl $64256, %edx + lea T_table(%rip), %r8 + movsd (%r8,%rdx,2), %xmm1 + orpd %xmm5, %xmm2 + lea Tbl_addr(%rip), %r8 + movapd (%r8,%rdx,4), %xmm4 + movq %xmm7, %xmm6 + addsd %xmm2, %xmm7 + subsd %xmm2, %xmm0 + mulsd %xmm0, %xmm7 + mulsd %xmm1, %xmm6 + mulsd %xmm2, %xmm3 + movq %xmm6, %xmm1 + addsd %xmm3, %xmm6 + divsd %xmm6, %xmm7 + movsd 24+cv(%rip), %xmm0 + movsd 8+cv(%rip), %xmm5 + subsd %xmm3, %xmm1 + psrlq $63, %xmm2 + movq %xmm1, %xmm3 + psllq $63, %xmm2 + mulsd %xmm1, %xmm1 + pshufd $68, %xmm2, %xmm2 + movsd 16+cv(%rip), %xmm6 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm0 + xorpd %xmm2, %xmm4 + mulsd %xmm3, %xmm5 + subpd PI_BY_2(%rip), %xmm4 + mulsd %xmm1, %xmm3 + addsd %xmm6, %xmm0 + mulsd %xmm3, %xmm0 + subsd %xmm4, %xmm5 + pshufd $238, %xmm4, %xmm4 + addsd %xmm5, %xmm0 + subsd %xmm7, %xmm0 + subsd %xmm4, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + subl $955, %eax + cmpl $65, %eax + jae .L_2TAG_PACKET_1.0.2 + psrlq $38, %xmm7 + psllq $38, %xmm7 + pmovmskb %xmm0, %eax + andnpd %xmm0, %xmm4 + subsd %xmm7, %xmm1 + movq %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + addsd %xmm6, %xmm0 + orpd %xmm4, %xmm5 + subsd %xmm7, %xmm3 + mulsd %xmm1, %xmm0 + movq %xmm3, %xmm4 + subsd %xmm0, %xmm3 + sqrtsd %xmm3, %xmm3 + andl $128, %eax + shrl $7, %eax + negl %eax + movq %xmm3, %xmm7 + andpd %xmm3, %xmm2 + psllq $2, %xmm3 + pextrw $3, %xmm3, %edx + orpd %xmm5, %xmm2 + movd %eax, %xmm3 + pshufd $0, %xmm3, %xmm3 + subl $65216, %edx + addl %edx, %edx + lea T_table(%rip), %r8 + mulsd (%r8,%rdx,4), %xmm7 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + subsd %xmm7, %xmm6 + andpd NEG_PI(%rip), %xmm3 + addsd %xmm1, %xmm6 + subsd %xmm2, %xmm4 + addsd %xmm7, %xmm7 + movsd 8+cv(%rip), %xmm5 + subsd %xmm0, %xmm4 + addsd %xmm6, %xmm7 + movsd 24+cv(%rip), %xmm0 + divsd %xmm7, %xmm4 + movsd 16+cv(%rip), %xmm2 + lea Tbl_addr(%rip), %r8 + addpd (%r8,%rdx,8), %xmm3 + movq %xmm6, %xmm1 + mulsd %xmm6, %xmm6 + mulsd %xmm6, %xmm0 + mulsd %xmm6, %xmm1 + mulsd %xmm1, %xmm5 + mulsd %xmm6, %xmm1 + addsd %xmm2, %xmm0 + pxor %xmm6, %xmm6 + mulsd %xmm1, %xmm0 + addsd %xmm3, %xmm5 + addsd %xmm5, %xmm0 + andl $32768, %eax + pinsrw $3, %eax, %xmm6 + movq %xmm4, %xmm5 + pshufd $238, %xmm3, %xmm3 + addsd %xmm3, %xmm4 + subsd %xmm4, %xmm3 + addsd %xmm3, %xmm5 + addsd %xmm5, %xmm0 + addsd %xmm4, %xmm0 + xorpd %xmm6, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_1.0.2: + addl $15291, %eax + cmpl $14336, %eax + jae .L_2TAG_PACKET_2.0.2 + unpcklpd %xmm0, %xmm0 + movapd cv2(%rip), %xmm6 + unpcklpd %xmm0, %xmm1 + movapd 16+cv2(%rip), %xmm2 + movapd 32+cv2(%rip), %xmm4 + mulpd %xmm0, %xmm0 + movapd PI_BY_2(%rip), %xmm5 + mulpd %xmm0, %xmm1 + mulpd %xmm0, %xmm6 + mulpd %xmm0, %xmm0 + movq %xmm1, %xmm3 + mulsd %xmm1, %xmm1 + addpd %xmm2, %xmm6 + mulpd %xmm0, %xmm4 + mulsd %xmm3, %xmm1 + addpd %xmm4, %xmm6 + pshufd $238, %xmm5, %xmm0 + mulpd %xmm6, %xmm1 + pshufd $238, %xmm5, %xmm6 + subsd %xmm7, %xmm0 + pshufd $238, %xmm1, %xmm2 + subsd %xmm1, %xmm5 + subsd %xmm0, %xmm6 + subsd %xmm2, %xmm5 + subsd %xmm6, %xmm7 + subsd %xmm7, %xmm5 + addsd %xmm5, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_2.0.2: + subl $15356, %eax + cmpl $4, %eax + jae .L_2TAG_PACKET_3.0.2 + xorpd %xmm6, %xmm6 + andpd ABSVALMASK(%rip), %xmm7 + movsd ONE_BY_2(%rip), %xmm4 + movapd cv2(%rip), %xmm1 + mulsd %xmm4, %xmm7 + movapd 16+cv2(%rip), %xmm2 + subsd %xmm7, %xmm4 + movapd 32+cv2(%rip), %xmm3 + pshufd $68, %xmm4, %xmm7 + sqrtsd %xmm4, %xmm4 + mulpd %xmm7, %xmm1 + pshufd $68, %xmm7, %xmm5 + pextrw $3, %xmm0, %eax + mulpd %xmm7, %xmm7 + addpd %xmm1, %xmm2 + movsd HALFMASK(%rip), %xmm1 + mulpd %xmm7, %xmm3 + cmpsd $1, %xmm6, %xmm0 + mulsd %xmm5, %xmm7 + addpd %xmm3, %xmm2 + pshufd $68, %xmm0, %xmm0 + mulsd %xmm7, %xmm2 + andpd NEG_PI(%rip), %xmm0 + mulpd %xmm5, %xmm2 + andpd %xmm4, %xmm1 + pshufd $68, %xmm4, %xmm3 + subsd %xmm1, %xmm4 + addsd %xmm3, %xmm3 + mulsd %xmm1, %xmm1 + subsd %xmm4, %xmm3 + subsd %xmm1, %xmm5 + mulsd %xmm3, %xmm4 + pshufd $238, %xmm3, %xmm3 + subsd %xmm4, %xmm5 + divsd %xmm3, %xmm5 + addpd %xmm3, %xmm3 + mulpd %xmm3, %xmm2 + pshufd $238, %xmm2, %xmm4 + addsd %xmm0, %xmm2 + andl $32768, %eax + pinsrw $3, %eax, %xmm6 + pshufd $238, %xmm0, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm5, %xmm2 + addsd %xmm3, %xmm2 + addsd %xmm2, %xmm0 + xorpd %xmm6, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_3.0.2: + addl $261884, %eax + cmpl $261888, %eax + jb .L_2TAG_PACKET_4.0.2 + movd %xmm7, %ecx + psrlq $32, %xmm7 + movd %xmm7, %edx + andl $2147483647, %edx + movl $1072693248, %eax + subl %edx, %eax + orl %ecx, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_5.0.2 + movsd (%rsp), %xmm2 + movd %xmm2, %edx + psrlq $32, %xmm2 + movd %xmm2, %ecx + andl $2147483647, %ecx + subl $1, %edx + sbbl $2146435072, %ecx + cmpl $0, %ecx + jge .L_2TAG_PACKET_6.0.2 + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %edx + pinsrw $3, %edx, %xmm1 + mulsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_7.0.2 +.L_2TAG_PACKET_5.0.2: + pextrw $1, %xmm7, %edx + shrl $15, %edx + negl %edx + movd %edx, %xmm7 + pshufd $0, %xmm7, %xmm7 + movsd PI(%rip), %xmm2 + movsd 8+PI(%rip), %xmm0 + andpd %xmm7, %xmm2 + andpd %xmm7, %xmm0 + addsd %xmm2, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_4.0.2: + movsd PI_BY_2(%rip), %xmm2 + movsd 8+PI_BY_2(%rip), %xmm0 + addsd %xmm2, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_6.0.2: + xorpd %xmm6, %xmm6 + addsd %xmm6, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_7.0.2: + movq %xmm0, 8(%rsp) +..B1.3: + movq 8(%rsp), %xmm0 +.L_2TAG_PACKET_8.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type acos,@function + .size acos,.-acos + .data +# -- End acos + .section .rodata, "a" + .align 16 + .align 16 +ABSVALMASK: + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .type ABSVALMASK,@object + .size ABSVALMASK,16 + .align 16 +T_table: + .long 2642784509 + .long 1072689083 + .long 1514442531 + .long 1072688953 + .long 333108933 + .long 1072688821 + .long 3392112024 + .long 1072688686 + .long 2099852862 + .long 1072688550 + .long 749609004 + .long 1072688412 + .long 3634632596 + .long 1072688271 + .long 2163248461 + .long 1072688129 + .long 628657846 + .long 1072687985 + .long 3324036511 + .long 1072687838 + .long 1657632815 + .long 1072687690 + .long 4217538760 + .long 1072687539 + .long 2411951597 + .long 1072687387 + .long 533944872 + .long 1072687233 + .long 2876566508 + .long 1072687076 + .long 847936891 + .long 1072686918 + .long 3036019913 + .long 1072686757 + .long 848884575 + .long 1072686595 + .long 2874443326 + .long 1072686430 + .long 520713666 + .long 1072686264 + .long 2375556481 + .long 1072686095 + .long 4141904948 + .long 1072685924 + .long 1522666382 + .long 1072685752 + .long 3105624104 + .long 1072685577 + .long 298666327 + .long 1072685401 + .long 1689524500 + .long 1072685222 + .long 2981002200 + .long 1072685041 + .long 4170844284 + .long 1072684858 + .long 961802263 + .long 1072684674 + .long 1941503454 + .long 1072684487 + .long 2812647170 + .long 1072684298 + .long 3572873869 + .long 1072684107 + .long 4219797823 + .long 1072683914 + .long 456039788 + .long 1072683720 + .long 869096151 + .long 1072683523 + .long 1161535119 + .long 1072683324 + .long 1330865866 + .long 1072683123 + .long 1374571204 + .long 1072682920 + .long 1290107538 + .long 1072682715 + .long 1074904836 + .long 1072682508 + .long 726366587 + .long 1072682299 + .long 241869763 + .long 1072682088 + .long 3913732079 + .long 1072681874 + .long 3149342765 + .long 1072681659 + .long 2240966306 + .long 1072681442 + .long 1185873216 + .long 1072681223 + .long 4276274591 + .long 1072681001 + .long 2919452883 + .long 1072680778 + .long 1407565635 + .long 1072680553 + .long 4032743551 + .long 1072680325 + .long 2202188565 + .long 1072680096 + .long 207977577 + .long 1072679865 + .long 2342160518 + .long 1072679631 + .long 11858423 + .long 1072679396 + .long 1804034453 + .long 1072679158 + .long 3420722787 + .long 1072678918 + .long 563930456 + .long 1072678677 + .long 1820539192 + .long 1072678433 + .long 2892501606 + .long 1072678187 + .long 3776710320 + .long 1072677939 + .long 175063337 + .long 1072677690 + .long 674333171 + .long 1072677438 + .long 976363026 + .long 1072677184 + .long 1077935934 + .long 1072676928 + .long 1921075490 + .long 1072676540 + .long 881493302 + .long 1072676016 + .long 3275752439 + .long 1072675483 + .long 486855588 + .long 1072674943 + .long 1077229111 + .long 1072674394 + .long 723950308 + .long 1072673837 + .long 3693582199 + .long 1072673271 + .long 1367335316 + .long 1072672698 + .long 2305837020 + .long 1072672116 + .long 2184358641 + .long 1072671526 + .long 972682840 + .long 1072670928 + .long 2935101762 + .long 1072670321 + .long 3745513263 + .long 1072669706 + .long 3372320886 + .long 1072669083 + .long 1783464620 + .long 1072668452 + .long 3241386215 + .long 1072667812 + .long 3418125284 + .long 1072667164 + .long 2280219148 + .long 1072666508 + .long 4088700758 + .long 1072665843 + .long 219227400 + .long 1072665171 + .long 3521816918 + .long 1072664489 + .long 1076205279 + .long 1072663800 + .long 1436484616 + .long 1072663102 + .long 271362610 + .long 1072662396 + .long 1838996688 + .long 1072661681 + .long 1807122518 + .long 1072660958 + .long 137953542 + .long 1072660227 + .long 1088178584 + .long 1072659487 + .long 324057537 + .long 1072658739 + .long 2101288076 + .long 1072657982 + .long 2085133974 + .long 1072657217 + .long 235324451 + .long 1072656444 + .long 806051592 + .long 1072655662 + .long 3756033140 + .long 1072654871 + .long 453542543 + .long 1072654073 + .long 3741177327 + .long 1072653265 + .long 691216109 + .long 1072652450 + .long 4145223372 + .long 1072651625 + .long 1174439091 + .long 1072650793 + .long 324416139 + .long 1072649952 + .long 1550246310 + .long 1072649102 + .long 511524674 + .long 1072648244 + .long 1457248482 + .long 1072647377 + .long 45944955 + .long 1072646502 + .long 525537397 + .long 1072645618 + .long 2848440188 + .long 1072644725 + .long 2671555633 + .long 1072643824 + .long 4241172637 + .long 1072642914 + .long 3213094278 + .long 1072641996 + .long 3832503688 + .long 1072641069 + .long 1754091534 + .long 1072640134 + .long 1221921804 + .long 1072639190 + .long 2184526489 + .long 1072638237 + .long 294902089 + .long 1072637276 + .long 4090375270 + .long 1072636305 + .long 632860906 + .long 1072635327 + .long 2753498702 + .long 1072634339 + .long 1808009252 + .long 1072633343 + .long 2036428672 + .long 1072632338 + .long 3383235626 + .long 1072631324 + .long 1497347484 + .long 1072630302 + .long 617018317 + .long 1072629271 + .long 684933058 + .long 1072628231 + .long 1643170798 + .long 1072627182 + .long 3011066360 + .long 1072625592 + .long 957158713 + .long 1072623442 + .long 1390907941 + .long 1072621256 + .long 3819155270 + .long 1072619034 + .long 3443571196 + .long 1072616777 + .long 4045412458 + .long 1072614484 + .long 805503923 + .long 1072612156 + .long 1778922015 + .long 1072609791 + .long 2125033665 + .long 1072607390 + .long 1287203863 + .long 1072604953 + .long 2992629568 + .long 1072602479 + .long 2367267127 + .long 1072599969 + .long 3115526047 + .long 1072597422 + .long 340219539 + .long 1072594839 + .long 2017215719 + .long 1072592218 + .long 3225443424 + .long 1072589560 + .long 3326565673 + .long 1072586865 + .long 1669811211 + .long 1072584133 + .long 1886735022 + .long 1072581363 + .long 3301071171 + .long 1072578555 + .long 928514283 + .long 1072575710 + .long 2656364059 + .long 1072572826 + .long 3473490507 + .long 1072569904 + .long 2649965606 + .long 1072566944 + .long 3736819052 + .long 1072563945 + .long 1680885175 + .long 1072560908 + .long 4413771 + .long 1072557832 + .long 2214869753 + .long 1072554716 + .long 3214725184 + .long 1072551561 + .long 2186079903 + .long 1072548367 + .long 2590372131 + .long 1072545133 + .long 3578146079 + .long 1072541859 + .long 4283712755 + .long 1072538545 + .long 3824834510 + .long 1072535191 + .long 1302400298 + .long 1072531797 + .long 95058636 + .long 1072528362 + .long 3563906063 + .long 1072524885 + .long 2167230730 + .long 1072521368 + .long 3524918334 + .long 1072517809 + .long 2353304918 + .long 1072514209 + .long 1939625839 + .long 1072510567 + .long 1256714581 + .long 1072506883 + .long 3552525848 + .long 1072503156 + .long 3464809522 + .long 1072499387 + .long 4200542593 + .long 1072495575 + .long 355609124 + .long 1072491721 + .long 3684139099 + .long 1072487822 + .long 148355918 + .long 1072483881 + .long 1457689242 + .long 1072479895 + .long 2118591596 + .long 1072475865 + .long 908848089 + .long 1072471791 + .long 877032689 + .long 1072467672 + .long 752012304 + .long 1072463508 + .long 3532301749 + .long 1072459298 + .long 3600563221 + .long 1072455043 + .long 3902857084 + .long 1072450742 + .long 3063101036 + .long 1072446395 + .long 3972344374 + .long 1072442001 + .long 903183549 + .long 1072437561 + .long 983892938 + .long 1072433073 + .long 2722858568 + .long 1072428537 + .long 302790515 + .long 1072423954 + .long 759811057 + .long 1072419322 + .long 2507809922 + .long 1072414641 + .long 2388408813 + .long 1072407528 + .long 2084492942 + .long 1072397870 + .long 2435703301 + .long 1072388010 + .long 1935433360 + .long 1072377945 + .long 2742047290 + .long 1072367671 + .long 2053284205 + .long 1072357185 + .long 657783367 + .long 1072346483 + .long 2893664841 + .long 1072335560 + .long 3718906405 + .long 1072324413 + .long 1547896303 + .long 1072313038 + .long 2494058440 + .long 1072301429 + .long 3133238742 + .long 1072289582 + .long 3327000086 + .long 1072277492 + .long 1860667274 + .long 1072265154 + .long 665340747 + .long 1072252562 + .long 443347841 + .long 1072239710 + .long 581282618 + .long 1072226592 + .long 3349780465 + .long 1072213201 + .long 914217606 + .long 1072199532 + .long 989797661 + .long 1072185576 + .long 945436416 + .long 1072171326 + .long 549291300 + .long 1072156774 + .long 1814636389 + .long 1072141911 + .long 239092858 + .long 1072126729 + .long 1794680724 + .long 1072111217 + .long 1241534678 + .long 1072095366 + .long 3366566214 + .long 1072079164 + .long 1244090828 + .long 1072062601 + .long 1708448120 + .long 1072045663 + .long 3544260650 + .long 1072028337 + .long 1402741403 + .long 1072010610 + .long 2551936888 + .long 1071992465 + .long 617669739 + .long 1071973887 + .long 794002186 + .long 1071954857 + .long 2021237693 + .long 1071935356 + .long 540450384 + .long 1071915364 + .long 1920555537 + .long 1071894857 + .long 2879585206 + .long 1071873811 + .long 3000237455 + .long 1071852199 + .long 3352974346 + .long 1071829991 + .long 569629937 + .long 1071807155 + .long 2077237208 + .long 1071783653 + .long 2284891805 + .long 1071759446 + .long 1226651784 + .long 1071734489 + .long 1102047405 + .long 1071708731 + .long 2009896384 + .long 1071682115 + .long 927419082 + .long 1071654577 + .long 85010366 + .long 1071607413 + .long 696431025 + .long 1071548180 + .long 2611410541 + .long 1071486585 + .long 2612593658 + .long 1071422396 + .long 3548155306 + .long 1071355336 + .long 3887997484 + .long 1071285073 + .long 244854763 + .long 1071211202 + .long 4214445648 + .long 1071133216 + .long 2303966727 + .long 1071050478 + .long 3991040013 + .long 1070962152 + .long 3126952278 + .long 1070867118 + .long 1817448378 + .long 1070763804 + .long 1793814864 + .long 1070649884 + .long 3507224072 + .long 1070447193 + .long 4027609105 + .long 1070148772 + .long 577507993 + .long 1069779414 + .long 2310232419 + .long 1068931829 + .type T_table,@object + .size T_table,2048 + .align 16 +Tbl_addr: + .long 3822952792 + .long 1021639372 + .long 182792448 + .long 1068507836 + .long 2264213271 + .long 1019558908 + .long 649052928 + .long 1068524253 + .long 1797139609 + .long 1022295143 + .long 1243095296 + .long 1068540671 + .long 1415938756 + .long 1021439537 + .long 2033294592 + .long 1068557090 + .long 2356809978 + .long 1021777916 + .long 3088063744 + .long 1068573510 + .long 2669055318 + .long 1022124482 + .long 180888576 + .long 1068589932 + .long 3566445325 + .long 1021358712 + .long 1970196992 + .long 1068606354 + .long 896980323 + .long 1021319659 + .long 4229555456 + .long 1068622777 + .long 436049712 + .long 1021319758 + .long 2732572160 + .long 1068639202 + .long 583123209 + .long 1020797960 + .long 1842831872 + .long 1068655628 + .long 1370449804 + .long 1021429270 + .long 1628994560 + .long 1068672055 + .long 2411391464 + .long 1021057980 + .long 2159763712 + .long 1068688483 + .long 1208692749 + .long 1021943903 + .long 3503886336 + .long 1068704912 + .long 538793309 + .long 1019744063 + .long 1435187200 + .long 1068721343 + .long 4085087612 + .long 1020608419 + .long 317469952 + .long 1068737775 + .long 144386942 + .long 1021440732 + .long 219617280 + .long 1068754208 + .long 2940088361 + .long 1019981122 + .long 1210558208 + .long 1068770642 + .long 2176850347 + .long 1018373705 + .long 3359268352 + .long 1068787077 + .long 2395611454 + .long 1021889042 + .long 2439803648 + .long 1068803514 + .long 1650705253 + .long 1020227966 + .long 2816203520 + .long 1068819952 + .long 3702166386 + .long 1019379914 + .long 262620672 + .long 1068836392 + .long 1855649370 + .long 1020453124 + .long 3438159616 + .long 1068852832 + .long 923063860 + .long 1019273834 + .long 3822105856 + .long 1068869274 + .long 4289947947 + .long 1019434249 + .long 1483729920 + .long 1068885718 + .long 787455814 + .long 1020738379 + .long 787321088 + .long 1068902163 + .long 3321653337 + .long 1021842569 + .long 1802253312 + .long 1068918609 + .long 2653633526 + .long 1021821525 + .long 302985984 + .long 1068935057 + .long 161272028 + .long 1021655149 + .long 653966080 + .long 1068951506 + .long 2566098667 + .long 1020066219 + .long 2924727296 + .long 1068967956 + .long 3646493722 + .long 1014292285 + .long 2889890304 + .long 1068984408 + .long 1081009196 + .long 1022189620 + .long 619098112 + .long 1069000862 + .long 4011643355 + .long 1021773297 + .long 477017600 + .long 1069017317 + .long 4030305534 + .long 1021292252 + .long 2533403904 + .long 1069033773 + .long 2645187591 + .long 1019527099 + .long 2563102208 + .long 1069050231 + .long 3857293792 + .long 1022311697 + .long 635982336 + .long 1069066691 + .long 3625936637 + .long 1017511744 + .long 1116940800 + .long 1069083152 + .long 3653872993 + .long 1022016631 + .long 4075964160 + .long 1069099614 + .long 2468900271 + .long 1021769532 + .long 993165568 + .long 1069116079 + .long 1358104224 + .long 1021199776 + .long 528586752 + .long 1069132545 + .long 2200950332 + .long 1022024872 + .long 2752395776 + .long 1069149012 + .long 3197072454 + .long 1017751319 + .long 3439855616 + .long 1069165481 + .long 1651081806 + .long 1020809338 + .long 2661257728 + .long 1069181952 + .long 539032752 + .long 1021728805 + .long 486957312 + .long 1069198425 + .long 3136045149 + .long 1016888671 + .long 1282340352 + .long 1069214899 + .long 2593963259 + .long 1018956103 + .long 822921728 + .long 1069231375 + .long 2146032737 + .long 1022306465 + .long 3474216192 + .long 1069247852 + .long 3976811625 + .long 1021350207 + .long 716902656 + .long 1069264332 + .long 718267222 + .long 1018624727 + .long 1211594496 + .long 1069280813 + .long 1485641389 + .long 1018447451 + .long 734070272 + .long 1069297296 + .long 354455128 + .long 1021341291 + .long 3650110720 + .long 1069313780 + .long 682185947 + .long 1021651853 + .long 1440663040 + .long 1069330267 + .long 3558574550 + .long 1021615110 + .long 2766612224 + .long 1069346755 + .long 874607978 + .long 1017746872 + .long 3404011008 + .long 1069363245 + .long 4154988502 + .long 1021439906 + .long 3423949056 + .long 1069379737 + .long 2263202309 + .long 1021479615 + .long 2897587712 + .long 1069396231 + .long 2562065031 + .long 1022090363 + .long 1896159232 + .long 1069412727 + .long 3836237663 + .long 1019867288 + .long 490968576 + .long 1069429225 + .long 3322056743 + .long 1006752762 + .long 3048360192 + .long 1069445724 + .long 1152314833 + .long 1013122252 + .long 1049850624 + .long 1069462226 + .long 3601590727 + .long 1022214610 + .long 3156899584 + .long 1069478729 + .long 1855169970 + .long 1019487271 + .long 851173376 + .long 1069495235 + .long 312649594 + .long 1020868604 + .long 2794281728 + .long 1069511742 + .long 1093490181 + .long 1020777577 + .long 468042496 + .long 1069528252 + .long 1152540679 + .long 1021403732 + .long 2534219264 + .long 1069544763 + .long 2292126035 + .long 1021872430 + .long 1376146432 + .long 1069558527 + .long 3293753641 + .long 1020500454 + .long 4175442432 + .long 1069575044 + .long 3626347564 + .long 1021610969 + .long 3523113472 + .long 1069591566 + .long 339956500 + .long 1021119039 + .long 4003350528 + .long 1069608092 + .long 3429333082 + .long 1022813542 + .long 1611067392 + .long 1069624623 + .long 2298017544 + .long 1021977587 + .long 931782144 + .long 1069641158 + .long 2164684743 + .long 1021250988 + .long 2256725504 + .long 1069657697 + .long 1138762335 + .long 1021443776 + .long 1582853120 + .long 1069674241 + .long 1084010382 + .long 1022994693 + .long 3497758720 + .long 1069690789 + .long 406366244 + .long 1022713586 + .long 3999816960 + .long 1069707342 + .long 1488723042 + .long 1023381290 + .long 3383096064 + .long 1069723900 + .long 2541558953 + .long 1019137887 + .long 1942403584 + .long 1069740463 + .long 1879620343 + .long 1022653642 + .long 4268263680 + .long 1069757030 + .long 3039077047 + .long 1022252545 + .long 2067062272 + .long 1069773603 + .long 4190670677 + .long 1020725863 + .long 4225828096 + .long 1069790180 + .long 1998567321 + .long 1022014385 + .long 2452507136 + .long 1069806763 + .long 1511628873 + .long 1021900300 + .long 1340746240 + .long 1069823351 + .long 788367341 + .long 1022726208 + .long 1190035456 + .long 1069839944 + .long 3856337230 + .long 1021834118 + .long 2300688384 + .long 1069856542 + .long 3211396579 + .long 1022621365 + .long 678886400 + .long 1069873146 + .long 4001011887 + .long 1022042646 + .long 921594112 + .long 1069889755 + .long 557811968 + .long 1023065533 + .long 3331668992 + .long 1069906369 + .long 1877060679 + .long 1022419742 + .long 3917875200 + .long 1069922989 + .long 1181055171 + .long 1022752712 + .long 2984829696 + .long 1069939615 + .long 4294526932 + .long 1021499988 + .long 838049024 + .long 1069956247 + .long 3658081878 + .long 1022957952 + .long 2078928384 + .long 1069972884 + .long 820353701 + .long 1019391107 + .long 2719854336 + .long 1069989527 + .long 1644022489 + .long 1023378240 + .long 3069117696 + .long 1070006176 + .long 2771393702 + .long 1019319954 + .long 3435962368 + .long 1070022831 + .long 3876394145 + .long 1023024433 + .long 4130595328 + .long 1070039492 + .long 1630447748 + .long 1021465882 + .long 1169236224 + .long 1070056160 + .long 2828355997 + .long 1020458120 + .long 3453997312 + .long 1070072833 + .long 164091641 + .long 1020388279 + .long 2708127744 + .long 1070089513 + .long 3036550223 + .long 1023328684 + .long 3540797696 + .long 1070106199 + .long 3710949463 + .long 1022568805 + .long 1972276736 + .long 1070122892 + .long 3885277950 + .long 1019761674 + .long 2613815552 + .long 1070139591 + .long 2764165077 + .long 1022921023 + .long 1487791616 + .long 1070156297 + .long 1330644769 + .long 1023162679 + .long 3207593472 + .long 1070173009 + .long 3911007221 + .long 1022993496 + .long 3797764608 + .long 1070189728 + .long 979712598 + .long 1022554580 + .long 3578920448 + .long 1070206454 + .long 2825738223 + .long 1020223708 + .long 2872795648 + .long 1070223187 + .long 392451124 + .long 1022666279 + .long 2002258432 + .long 1070239927 + .long 3730407632 + .long 1023148291 + .long 1291326464 + .long 1070256674 + .long 3723802980 + .long 1022514089 + .long 1065180928 + .long 1070273428 + .long 2635617463 + .long 1022654470 + .long 1650181632 + .long 1070290189 + .long 2061982883 + .long 1022853411 + .long 3373882880 + .long 1070306957 + .long 319732785 + .long 1022017175 + .long 2270081280 + .long 1070323733 + .long 2237757411 + .long 1023064087 + .long 2963732736 + .long 1070340516 + .long 468839165 + .long 1023293774 + .long 1491099904 + .long 1070357307 + .long 1502657946 + .long 1021533479 + .long 2479636480 + .long 1070374105 + .long 482913562 + .long 1021986286 + .long 1968133632 + .long 1070390911 + .long 3281474337 + .long 1022646400 + .long 291639040 + .long 1070407725 + .long 2453320259 + .long 1022812423 + .long 2081472512 + .long 1070424546 + .long 2939989570 + .long 1023091888 + .long 3380340480 + .long 1070441375 + .long 2850707499 + .long 1021921109 + .long 232287488 + .long 1070458213 + .long 3674625342 + .long 1020725130 + .long 1567614208 + .long 1070475058 + .long 9347334 + .long 1022024009 + .long 3433091072 + .long 1070491911 + .long 282524999 + .long 1021433523 + .long 1876877312 + .long 1070508773 + .long 3470449440 + .long 1019309721 + .long 1538472192 + .long 1070525643 + .long 2089486825 + .long 1019698916 + .long 2763830784 + .long 1070542521 + .long 443498115 + .long 1020505194 + .long 1605381632 + .long 1070559408 + .long 3018871601 + .long 1022869913 + .long 2706946048 + .long 1070576303 + .long 3936260892 + .long 1023175875 + .long 2123887360 + .long 1070593207 + .long 2994220655 + .long 1022825948 + .long 104015104 + .long 1070603108 + .long 335054493 + .long 1023441853 + .long 2904568832 + .long 1070615800 + .long 1451215633 + .long 1023853857 + .long 3456197120 + .long 1070632739 + .long 436334733 + .long 1024026432 + .long 252452352 + .long 1070649697 + .long 34596167 + .long 1024031396 + .long 3328018432 + .long 1070666672 + .long 2644547073 + .long 1024296758 + .long 1255829248 + .long 1070683667 + .long 552832586 + .long 1023763122 + .long 4097058560 + .long 1070700680 + .long 1955640623 + .long 1021394654 + .long 451770112 + .long 1070717714 + .long 3428903777 + .long 1022941142 + .long 408920832 + .long 1070734767 + .long 165503263 + .long 1023894958 + .long 1186960640 + .long 1070751840 + .long 435826450 + .long 1024026134 + .long 19078656 + .long 1070768934 + .long 1834169749 + .long 1022899284 + .long 2743490304 + .long 1070786048 + .long 494581074 + .long 1018818479 + .long 2328961024 + .long 1070803184 + .long 2987908834 + .long 1022581110 + .long 350011392 + .long 1070820342 + .long 240771184 + .long 1024143083 + .long 2692326912 + .long 1070837521 + .long 666056837 + .long 1022394776 + .long 2373274368 + .long 1070854723 + .long 2484337770 + .long 1024228156 + .long 1017131520 + .long 1070871948 + .long 3285648279 + .long 1024025789 + .long 265558272 + .long 1070889196 + .long 392241896 + .long 1024252809 + .long 1778008064 + .long 1070906467 + .long 1536107943 + .long 1023949300 + .long 2937184768 + .long 1070923762 + .long 3541062251 + .long 1019448646 + .long 1144442880 + .long 1070941082 + .long 3691683781 + .long 1022123948 + .long 2410165504 + .long 1070958426 + .long 1804181960 + .long 1023945221 + .long 4174350848 + .long 1070975795 + .long 2016094861 + .long 1021716585 + .long 3897012480 + .long 1070993190 + .long 175294410 + .long 1023703404 + .long 3353623040 + .long 1071010611 + .long 167973242 + .long 1023240839 + .long 45671168 + .long 1071028059 + .long 2166856113 + .long 1021565413 + .long 86063872 + .long 1071045533 + .long 2676254727 + .long 1023985299 + .long 1019772672 + .long 1071063034 + .long 989043593 + .long 1021549587 + .long 414297344 + .long 1071080563 + .long 3960972046 + .long 1024307251 + .long 155173120 + .long 1071098120 + .long 1830919291 + .long 1021592251 + .long 2151562240 + .long 1071115705 + .long 405408666 + .long 1023423128 + .long 4041854720 + .long 1071133319 + .long 2043497827 + .long 1024411503 + .long 3489224192 + .long 1071150963 + .long 3072215864 + .long 1022698635 + .long 2477196288 + .long 1071168637 + .long 1812195139 + .long 1022689192 + .long 3015298816 + .long 1071186341 + .long 764841969 + .long 1021027331 + .long 2844731136 + .long 1071204076 + .long 2878117321 + .long 1019116513 + .long 4028950528 + .long 1071221842 + .long 698911452 + .long 1023265602 + .long 69441536 + .long 1071239641 + .long 3253467847 + .long 1020795075 + .long 1676209920 + .long 1071257471 + .long 4272431167 + .long 1022873982 + .long 2408752384 + .long 1071275334 + .long 648519100 + .long 1024385717 + .long 151623680 + .long 1071293231 + .long 345257017 + .long 1019561408 + .long 1410154240 + .long 1071311161 + .long 197863993 + .long 1023224207 + .long 4131351552 + .long 1071329125 + .long 2620801789 + .long 1024411169 + .long 1999664384 + .long 1071347125 + .long 3952692616 + .long 1024168086 + .long 1617668864 + .long 1071365160 + .long 3019889809 + .long 1021907692 + .long 1032074240 + .long 1071383231 + .long 59469899 + .long 1023656194 + .long 2619492096 + .long 1071401338 + .long 1417526820 + .long 1021457783 + .long 202429440 + .long 1071419483 + .long 2927667935 + .long 1019175447 + .long 525044224 + .long 1071437665 + .long 38166811 + .long 1023981879 + .long 1779258880 + .long 1071455885 + .long 481252500 + .long 1023310234 + .long 2195673600 + .long 1071474144 + .long 3962395981 + .long 1021339088 + .long 44573696 + .long 1071492443 + .long 3936281395 + .long 1023014829 + .long 2226905344 + .long 1071510781 + .long 1515320476 + .long 1024320623 + .long 2800512512 + .long 1071529160 + .long 1225403697 + .long 1021081846 + .long 161113600 + .long 1071547581 + .long 3064809733 + .long 1024173917 + .long 1338410240 + .long 1071566043 + .long 2027604973 + .long 1024362526 + .long 522433280 + .long 1071584548 + .long 2055171723 + .long 1023858825 + .long 539595776 + .long 1071603096 + .long 3868820135 + .long 1022936424 + .long 4264017664 + .long 1071621687 + .long 3228065145 + .long 1023479578 + .long 1733924096 + .long 1071640324 + .long 3511934475 + .long 1022496355 + .long 108880384 + .long 1071651839 + .long 615880967 + .long 1023519706 + .long 3517856512 + .long 1071661202 + .long 3113108559 + .long 1025190289 + .long 4043153152 + .long 1071670589 + .long 1571836218 + .long 1023106116 + .long 3251299072 + .long 1071680000 + .long 3444076102 + .long 1022187841 + .long 2736921600 + .long 1071689435 + .long 272771483 + .long 1025095280 + .long 3897698560 + .long 1071703633 + .long 2075390188 + .long 1022489022 + .long 3209485056 + .long 1071722652 + .long 1438094065 + .long 1021844944 + .long 3781432064 + .long 1071741774 + .long 1675017145 + .long 1024143828 + .long 2684184064 + .long 1071761003 + .long 2259963753 + .long 1024731393 + .long 1840489728 + .long 1071780342 + .long 3372883597 + .long 1023431408 + .long 3764087808 + .long 1071799794 + .long 3307523102 + .long 1024485788 + .long 3006232320 + .long 1071819364 + .long 3088971966 + .long 1025213251 + .long 3374881280 + .long 1071839055 + .long 834437749 + .long 1025236452 + .long 797284864 + .long 1071858872 + .long 3122663941 + .long 1025320473 + .long 545765120 + .long 1071878818 + .long 826539625 + .long 1022450955 + .long 107562240 + .long 1071898898 + .long 339584600 + .long 1022481255 + .long 2123649024 + .long 1071919116 + .long 3912959833 + .long 1024321009 + .long 1562385664 + .long 1071939478 + .long 2846067230 + .long 1023343981 + .long 2963085824 + .long 1071959988 + .long 954548627 + .long 1021475211 + .long 3325550592 + .long 1071980652 + .long 3459651155 + .long 1025305573 + .long 775752448 + .long 1072001476 + .long 3582746667 + .long 1023859460 + .long 3238590720 + .long 1072022464 + .long 634636162 + .long 1024472353 + .long 2758801920 + .long 1072043624 + .long 3078216319 + .long 1025304516 + .long 1370319104 + .long 1072064962 + .long 2570569078 + .long 1025099442 + .long 2615805184 + .long 1072086484 + .long 3729933412 + .long 1024605112 + .long 3077336576 + .long 1072108198 + .long 1948916066 + .long 1024781603 + .long 1099528192 + .long 1072130112 + .long 3139143157 + .long 1023729360 + .long 1231903232 + .long 1072152233 + .long 1349513477 + .long 1024737515 + .long 1507504128 + .long 1072174570 + .long 3484516322 + .long 1024000959 + .long 2214659840 + .long 1072197132 + .long 2563820917 + .long 1025225535 + .long 1804739840 + .long 1072219929 + .long 760038746 + .long 1024482855 + .long 1413746688 + .long 1072242971 + .long 3401734714 + .long 1025129838 + .long 821409536 + .long 1072266269 + .long 3729772551 + .long 1025484796 + .long 3031825664 + .long 1072289834 + .long 122256749 + .long 1024752594 + .long 1710784256 + .long 1072313680 + .long 1518205483 + .long 1024724809 + .long 3025265152 + .long 1072337819 + .long 409951989 + .long 1022835555 + .long 287769088 + .long 1072362267 + .long 800355594 + .long 1022484850 + .long 198179840 + .long 1072387038 + .long 3502926213 + .long 1024209373 + .long 1909130496 + .long 1072412149 + .long 3064694319 + .long 1025380823 + .long 1941732096 + .long 1072437619 + .long 4112930390 + .long 1024294679 + .long 3492010496 + .long 1072463467 + .long 2684918107 + .long 1023220233 + .long 81959680 + .long 1072489716 + .long 220021366 + .long 1020635131 + .long 2297837056 + .long 1072516387 + .long 4027683826 + .long 1021041185 + .long 270404096 + .long 1072543508 + .long 2012766065 + .long 1021780753 + .long 3667376896 + .long 1072571105 + .long 2727981522 + .long 1023009874 + .long 330400256 + .long 1072599212 + .long 2940017003 + .long 1025393439 + .long 1119293952 + .long 1072627861 + .long 1608550416 + .long 1022675612 + .long 3536155904 + .long 1072657091 + .long 349665778 + .long 1025156751 + .long 3078046720 + .long 1072686946 + .long 2016159996 + .long 1022193169 + .long 455228416 + .long 1072705361 + .long 1908539328 + .long 1026126332 + .long 1871505664 + .long 1072720988 + .long 2784700894 + .long 1025922277 + .long 1630994432 + .long 1072737010 + .long 361107678 + .long 1022887244 + .long 2084558336 + .long 1072753462 + .type Tbl_addr,@object + .size Tbl_addr,3840 + .space 768, 0x00 # pad + .align 16 +cv: + .long 0 + .long 0 + .long 1431655765 + .long 3217380693 + .long 858993459 + .long 3216192307 + .long 3067833783 + .long 3215383405 + .type cv,@object + .size cv,32 + .align 16 +PI_BY_2: + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1073291771 + .type PI_BY_2,@object + .size PI_BY_2,16 + .align 16 +NEG_PI: + .long 856972295 + .long 3164710438 + .long 1413754136 + .long 3221823995 + .type NEG_PI,@object + .size NEG_PI,16 + .align 16 +cv2: + .long 780903145 + .long 1066854586 + .long 858993459 + .long 1068708659 + .long 3340530119 + .long 1067392113 + .long 1431655765 + .long 1069897045 + .long 1321528399 + .long 1066517740 + .long 3067833783 + .long 1067899757 + .long 2021159460 + .long 1065855096 + .long 2576980378 + .long 1066178969 + .type cv2,@object + .size cv2,64 + .align 16 +HALFMASK: + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .type HALFMASK,@object + .size HALFMASK,16 + .align 16 +PI: + .long 856972295 + .long 1017226790 + .long 1413754136 + .long 1074340347 + .type PI,@object + .size PI,16 + .align 4 +ONEMASK: + .long 0 + .long 1072693248 + .type ONEMASK,@object + .size ONEMASK,8 + .align 4 +TMASK: + .long 0 + .long 4294950912 + .type TMASK,@object + .size TMASK,8 + .align 4 +ONE_BY_2: + .long 0 + .long 1071644672 + .type ONE_BY_2,@object + .size ONE_BY_2,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/acosf_gen.S b/external/sgx_libm/intel64/acosf_gen.S new file mode 100644 index 0000000000..9a81f29fb2 --- /dev/null +++ b/external/sgx_libm/intel64/acosf_gen.S @@ -0,0 +1,291 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acosf_gen.c" + .text +..TXTST0: +# -- Begin acosf + .text + .align 16,0x90 + .globl acosf +acosf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_acosf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + movl %edx, %eax + andl $2147483647, %eax + cmpl $1065353216, %eax + jae ..B1.10 +..B1.2: + cmpl $1056964608, %eax + jae ..B1.6 +..B1.3: + cmpl $838860800, %eax + jae ..B1.5 +..B1.4: + cvtss2sd %xmm0, %xmm0 + movsd .L_2il0floatpacket.8(%rip), %xmm1 + subsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movaps %xmm1, %xmm0 + ret +..B1.5: + pxor %xmm5, %xmm5 + cvtss2sd -8(%rsp), %xmm5 + movaps %xmm5, %xmm1 + mulsd %xmm5, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.0(%rip), %xmm4 + movsd .L_2il0floatpacket.4(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.1(%rip), %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.2(%rip), %xmm4 + addsd .L_2il0floatpacket.6(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.3(%rip), %xmm4 + addsd .L_2il0floatpacket.7(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + movsd .L_2il0floatpacket.8(%rip), %xmm3 + addsd %xmm2, %xmm4 + subsd %xmm5, %xmm3 + mulsd %xmm4, %xmm5 + subsd %xmm5, %xmm3 + jmp ..B1.9 +..B1.6: + pxor %xmm3, %xmm3 + testl $-2147483648, %edx + cvtss2sd -8(%rsp), %xmm3 + movsd .L_2il0floatpacket.1(%rip), %xmm6 + movsd .L_2il0floatpacket.2(%rip), %xmm9 + movsd .L_2il0floatpacket.3(%rip), %xmm10 + movsd .L_2il0floatpacket.5(%rip), %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm1 + movsd .L_2il0floatpacket.7(%rip), %xmm2 + je ..B1.8 +..B1.7: + movsd .L_2il0floatpacket.13(%rip), %xmm5 + pxor %xmm8, %xmm8 + movsd .L_2il0floatpacket.0(%rip), %xmm7 + addsd %xmm3, %xmm5 + mulsd .L_2il0floatpacket.9(%rip), %xmm5 + movaps %xmm5, %xmm4 + mulsd %xmm5, %xmm4 + sqrtsd %xmm5, %xmm8 + mulsd %xmm4, %xmm7 + mulsd .L_2il0floatpacket.10(%rip), %xmm8 + addsd %xmm6, %xmm7 + movsd .L_2il0floatpacket.4(%rip), %xmm6 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm7 + addsd %xmm0, %xmm6 + addsd %xmm9, %xmm7 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm7 + addsd %xmm1, %xmm6 + addsd %xmm10, %xmm7 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm7 + addsd %xmm2, %xmm6 + mulsd %xmm5, %xmm6 + movsd .L_2il0floatpacket.11(%rip), %xmm3 + addsd %xmm6, %xmm7 + subsd %xmm8, %xmm3 + mulsd %xmm7, %xmm8 + subsd %xmm8, %xmm3 + jmp ..B1.9 +..B1.8: + movsd .L_2il0floatpacket.13(%rip), %xmm5 + movsd .L_2il0floatpacket.0(%rip), %xmm7 + subsd %xmm3, %xmm5 + mulsd .L_2il0floatpacket.9(%rip), %xmm5 + pxor %xmm3, %xmm3 + movaps %xmm5, %xmm4 + mulsd %xmm5, %xmm4 + sqrtsd %xmm5, %xmm3 + mulsd %xmm4, %xmm7 + mulsd .L_2il0floatpacket.10(%rip), %xmm3 + addsd %xmm6, %xmm7 + movsd .L_2il0floatpacket.4(%rip), %xmm6 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm7 + addsd %xmm0, %xmm6 + addsd %xmm9, %xmm7 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm7 + addsd %xmm1, %xmm6 + addsd %xmm10, %xmm7 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm7 + addsd %xmm2, %xmm6 + mulsd %xmm5, %xmm6 + addsd %xmm6, %xmm7 + mulsd %xmm3, %xmm7 + addsd %xmm7, %xmm3 +..B1.9: + cvtsd2ss %xmm3, %xmm3 + movaps %xmm3, %xmm0 + ret +..B1.10: + cmpl $2139095040, %eax + ja ..B1.16 +..B1.11: + cmpl $1065353216, %eax + jne ..B1.17 +..B1.12: + testl $-2147483648, %edx + je ..B1.14 +..B1.13: + lea _small_value_64(%rip), %rax + movsd .L_2il0floatpacket.11(%rip), %xmm0 + addsd (%rax), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.14: + pxor %xmm0, %xmm0 +..B1.15: + ret +..B1.16: + movss -8(%rsp), %xmm0 + ret +..B1.17: + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.12(%rip), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type acosf,@function + .size acosf,.-acosf + .data +# -- End acosf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0xa6220783,0x3f9e3be5 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0xb5dc5888,0x3f93d64d + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x5290ac8c,0x3f9f20d0 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x4fa3bc7b,0x3fb33333 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xa9336e0b,0x3f758206 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0xecc3fecb,0x3f96a6f2 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x9e7be0cc,0x3fa6db5b + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x554dfea4,0x3fc55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x54442d18,0x3ff921fb + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x54442d18,0x400921fb + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 4 +.L_2il0floatpacket.12: + .long 0x7f800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/acosh_gen.S b/external/sgx_libm/intel64/acosh_gen.S new file mode 100644 index 0000000000..d7ac4c73a2 --- /dev/null +++ b/external/sgx_libm/intel64/acosh_gen.S @@ -0,0 +1,384 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acosh_gen.c" + .text +..TXTST0: +# -- Begin acosh + .text + .align 16,0x90 + .globl acosh +acosh: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_acosh.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + lea -1072693248(%rax), %edx + cmpl $1073741824, %edx + jae ..B1.14 +..B1.2: + cmpl $6144, %edx + jae ..B1.6 +..B1.3: + movl -8(%rsp), %eax + orl %eax, %edx + jne ..B1.5 +..B1.4: + lea _zeros(%rip), %rax + movsd (%rax), %xmm0 + ret +..B1.5: + lea 8+_ones(%rip), %rax + pxor %xmm3, %xmm3 + movsd -8(%rsp), %xmm5 + xorl %r9d, %r9d + movsd .L_2il0floatpacket.0(%rip), %xmm4 + lea 32+_PA(%rip), %rdx + lea 16+_PA(%rip), %rcx + lea 24+_PA(%rip), %rdi + lea _PA(%rip), %rsi + addsd (%rax), %xmm5 + mulsd %xmm5, %xmm4 + movaps %xmm5, %xmm6 + mulsd %xmm5, %xmm6 + sqrtsd %xmm4, %xmm3 + movsd %xmm3, -16(%rsp) + movaps %xmm3, %xmm0 + movl %r9d, -16(%rsp) + lea 8+_PA(%rip), %r8 + movsd -16(%rsp), %xmm11 + movaps %xmm11, %xmm1 + movaps %xmm11, %xmm2 + movsd (%rdx), %xmm8 + subsd %xmm11, %xmm0 + mulsd %xmm11, %xmm1 + mulsd %xmm6, %xmm8 + mulsd %xmm0, %xmm2 + subsd %xmm1, %xmm4 + addsd (%rcx), %xmm8 + subsd %xmm2, %xmm4 + mulsd %xmm6, %xmm8 + divsd %xmm3, %xmm4 + movsd (%rdi), %xmm7 + addsd %xmm4, %xmm0 + mulsd %xmm6, %xmm7 + addsd (%rsi), %xmm8 + mulsd .L_2il0floatpacket.1(%rip), %xmm0 + addsd (%r8), %xmm7 + mulsd %xmm5, %xmm8 + mulsd %xmm6, %xmm7 + addsd %xmm7, %xmm8 + movsd %xmm8, -24(%rsp) + movaps %xmm8, %xmm9 + movl %r9d, -24(%rsp) + movsd -24(%rsp), %xmm10 + mulsd %xmm0, %xmm8 + subsd %xmm10, %xmm9 + mulsd %xmm11, %xmm10 + mulsd %xmm11, %xmm9 + movsd %xmm10, -24(%rsp) + addsd %xmm8, %xmm9 + addsd %xmm9, %xmm0 + addsd %xmm10, %xmm0 + addsd %xmm11, %xmm0 + ret +..B1.6: + cmpl $29360128, %edx + jae ..B1.11 +..B1.7: + movsd -8(%rsp), %xmm7 + cmpl $2293760, %edx + jae ..B1.9 +..B1.8: + xorl %edx, %edx + movaps %xmm7, %xmm1 + movl %edx, -8(%rsp) + lea 8+_ones(%rip), %rax + movsd -8(%rsp), %xmm8 + movaps %xmm8, %xmm4 + subsd %xmm8, %xmm1 + mulsd %xmm8, %xmm4 + addsd %xmm8, %xmm7 + mulsd %xmm1, %xmm7 + addsd (%rax), %xmm4 + movaps %xmm4, %xmm0 + addsd %xmm7, %xmm0 + sqrtsd %xmm0, %xmm0 + movsd %xmm0, -16(%rsp) + movl %edx, -16(%rsp) + movsd -16(%rsp), %xmm6 + movaps %xmm6, %xmm2 + movaps %xmm6, %xmm3 + mulsd %xmm6, %xmm2 + subsd %xmm6, %xmm0 + addsd %xmm6, %xmm8 + mulsd %xmm0, %xmm3 + subsd %xmm2, %xmm4 + movaps %xmm6, %xmm5 + subsd %xmm3, %xmm4 + addsd %xmm0, %xmm5 + addsd %xmm4, %xmm7 + divsd %xmm5, %xmm7 + addsd %xmm7, %xmm0 + mulsd .L_2il0floatpacket.1(%rip), %xmm0 + addsd %xmm0, %xmm1 + jmp ..B1.10 +..B1.9: + movaps %xmm7, %xmm0 + lea 8+_ones(%rip), %rax + movsd .L_2il0floatpacket.0(%rip), %xmm2 + mulsd %xmm7, %xmm0 + movsd (%rax), %xmm1 + addsd %xmm1, %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm7, %xmm0 + mulsd %xmm2, %xmm7 + divsd %xmm0, %xmm1 + movsd %xmm7, -8(%rsp) + movl $0, -8(%rsp) + movsd -8(%rsp), %xmm8 + subsd %xmm8, %xmm7 + addsd %xmm7, %xmm1 +..B1.10: + movaps %xmm1, %xmm0 + movq $0x3ff0000000000000, %rax + addsd %xmm8, %xmm0 + movsd %xmm0, -8(%rsp) + movl $0, -8(%rsp) + movsd -8(%rsp), %xmm7 + movzwl -2(%rsp), %ecx + subsd %xmm7, %xmm8 + andl $32752, %ecx + addsd %xmm8, %xmm1 + shrl $4, %ecx + addl $-1023, %ecx + movslq %ecx, %rdx + negq %rdx + shlq $52, %rdx + addq %rax, %rdx + movq %rdx, -24(%rsp) + movsd -24(%rsp), %xmm2 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm7 + movaps %xmm1, %xmm3 + addsd %xmm7, %xmm3 + movsd %xmm3, -16(%rsp) + movl -12(%rsp), %esi + shrl $12, %esi + movzbl %sil, %edx + jmp ..B1.12 +..B1.11: + movzwl -2(%rsp), %eax + movl %eax, %ecx + andl $-32753, %eax + andl $32752, %ecx + orl $-49168, %eax + movw %ax, -2(%rsp) + movsd -8(%rsp), %xmm1 + movl $0, -8(%rsp) + movl -4(%rsp), %edx + movsd -8(%rsp), %xmm7 + shrl $4, %ecx + subsd %xmm7, %xmm1 + shrl $12, %edx + addl $-1022, %ecx + movzbl %dl, %edx +..B1.12: + movq __libm_rcp_table_256@GOTPCREL(%rip), %rsi + pxor %xmm0, %xmm0 + lea _ones(%rip), %rdi + lea 32+_PL(%rip), %r8 + lea 24+_PL(%rip), %r11 + lea 16+_PL(%rip), %r9 + lea _PL(%rip), %r10 + pxor %xmm6, %xmm6 + movq __libm_log_table_256@GOTPCREL(%rip), %rax + movsd (%r8), %xmm5 + movsd (%r11), %xmm4 + cvtss2sd (%rsi,%rdx,4), %xmm0 + cvtsi2sd %ecx, %xmm6 + mulsd %xmm0, %xmm7 + mulsd %xmm0, %xmm1 + subsd (%rdi), %xmm7 + movaps %xmm7, %xmm3 + lea _LN2(%rip), %rcx + lea 8+_PL(%rip), %rsi + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm4 + addsd (%r9), %xmm5 + addsd (%rsi), %xmm4 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm4 + addsd (%r10), %xmm5 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm5 + movsd (%rcx), %xmm0 + addsd %xmm4, %xmm5 + mulsd %xmm6, %xmm0 + addsd %xmm5, %xmm1 + shlq $4, %rdx + lea 8+_LN2(%rip), %rcx + movsd %xmm3, -16(%rsp) + addsd (%rax,%rdx), %xmm0 + addsd %xmm1, %xmm0 + movsd (%rcx), %xmm1 + mulsd %xmm1, %xmm6 + addsd 8(%rax,%rdx), %xmm6 + movsd %xmm6, -24(%rsp) + addsd %xmm6, %xmm7 + movsd %xmm7, -8(%rsp) + addsd %xmm7, %xmm0 +..B1.13: + ret +..B1.14: + movl %eax, %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + jbe ..B1.16 +..B1.15: + movsd -8(%rsp), %xmm0 + addsd %xmm0, %xmm0 + ret +..B1.16: + cmpl $2146435072, %eax + jne ..B1.18 +..B1.17: + cmpl $0, -8(%rsp) + je ..B1.15 +..B1.18: + cmpl $2146435072, %edx + jne ..B1.20 +..B1.19: + cmpl $0, -8(%rsp) + jne ..B1.15 +..B1.20: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type acosh,@function + .size acosh,.-acosh + .data +# -- End acosh + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_PA: + .long 1431655760 + .long 3216332117 + .long 858954823 + .long 1066611507 + .long 2956777430 + .long 3212237677 + .long 4158004615 + .long 1063197775 + .long 2173429939 + .long 3209085130 + .type _PA,@object + .size _PA,40 + .align 4 +_PL: + .long 0 + .long 3219128320 + .long 1431621855 + .long 1070945621 + .long 4294842013 + .long 3218079743 + .long 1289448124 + .long 1070176674 + .long 2077359316 + .long 3217380703 + .type _PL,@object + .size _PL,40 + .align 4 +_LN2: + .long 897137782 + .long 1038760431 + .long 4276092928 + .long 1072049730 + .type _LN2,@object + .size _LN2,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/acoshf_gen.S b/external/sgx_libm/intel64/acoshf_gen.S new file mode 100644 index 0000000000..c7ac5ad419 --- /dev/null +++ b/external/sgx_libm/intel64/acoshf_gen.S @@ -0,0 +1,248 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acoshf_gen.c" + .text +..TXTST0: +# -- Begin acoshf + .text + .align 16,0x90 + .globl acoshf +acoshf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_acoshf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -16(%rsp) + lea -1065353216(%rdx), %eax + cmpl $1073741824, %eax + jae ..B1.11 +..B1.2: + cmpl $4194304, %eax + jae ..B1.6 +..B1.3: + testl %eax, %eax + jne ..B1.5 +..B1.4: + pxor %xmm0, %xmm0 + ret +..B1.5: + pxor %xmm3, %xmm3 + cvtss2sd -16(%rsp), %xmm3 + movsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd %xmm3, -24(%rsp) + addsd %xmm0, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + movsd .L_2il0floatpacket.2(%rip), %xmm5 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.3(%rip), %xmm5 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.4(%rip), %xmm5 + addsd .L_2il0floatpacket.8(%rip), %xmm4 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm5 + addsd .L_2il0floatpacket.9(%rip), %xmm4 + mulsd %xmm2, %xmm5 + mulsd %xmm3, %xmm4 + movsd .L_2il0floatpacket.1(%rip), %xmm1 + addsd %xmm4, %xmm5 + mulsd %xmm3, %xmm1 + sqrtsd %xmm1, %xmm1 + mulsd %xmm1, %xmm5 + addsd %xmm1, %xmm5 + jmp ..B1.10 +..B1.6: + pxor %xmm1, %xmm1 + cmpl $134217728, %eax + cvtss2sd -16(%rsp), %xmm1 + jae ..B1.8 +..B1.7: + movaps %xmm1, %xmm0 + movl $-1023, %edi + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.0(%rip), %xmm2 + addsd %xmm2, %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm0, %xmm1 + movsd %xmm1, -24(%rsp) + jmp ..B1.9 +..B1.8: + movsd %xmm1, -24(%rsp) + movl $-1022, %edi + movsd .L_2il0floatpacket.0(%rip), %xmm2 +..B1.9: + movzwl -18(%rsp), %edx + movl %edx, %eax + andl $-32753, %edx + pxor %xmm0, %xmm0 + orl $-49168, %edx + andl $32752, %eax + movw %dx, -18(%rsp) + pxor %xmm1, %xmm1 + movq __libm_rcp_table_256@GOTPCREL(%rip), %rsi + movl -20(%rsp), %ecx + andl $1048575, %ecx + shrl $12, %ecx + cvtss2sd (%rsi,%rcx,4), %xmm0 + mulsd -24(%rsp), %xmm0 + movsd .L_2il0floatpacket.11(%rip), %xmm5 + addsd %xmm2, %xmm0 + mulsd %xmm0, %xmm5 + shrl $4, %eax + addsd .L_2il0floatpacket.12(%rip), %xmm5 + addl %eax, %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm5 + mulsd .L_2il0floatpacket.13(%rip), %xmm1 + mulsd %xmm0, %xmm5 + movq __libm_logf_table_256@GOTPCREL(%rip), %r8 + addsd %xmm0, %xmm5 + addsd (%r8,%rcx,8), %xmm1 + movsd %xmm0, -24(%rsp) + addsd %xmm1, %xmm5 +..B1.10: + cvtsd2ss %xmm5, %xmm5 + movaps %xmm5, %xmm0 + ret +..B1.11: + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.14 +..B1.12: + cmpl $2139095040, %edx + je ..B1.14 +..B1.13: + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.10(%rip), %xmm0 + ret +..B1.14: + movss -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type acoshf,@function + .size acoshf,.-acoshf + .data +# -- End acoshf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0xd28ee596,0x3ef3cb17 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x9b9f611c,0x3f31287a + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xac0cf195,0x3f5f1aa4 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x1236cb49,0x3f933333 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xd27f5e7d,0xbf174400 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x4197b1a0,0xbf46d307 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0xdacdeace,0xbf76db62 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x552ea1bd,0xbfb55555 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x6890dd10,0x3fd5555a + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0xe7362feb,0xbfe00001 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0xfefa39ef,0x3fe62e42 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 4 +.L_2il0floatpacket.10: + .long 0x7f800000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/acoshl.S b/external/sgx_libm/intel64/acoshl.S new file mode 100644 index 0000000000..7d9a3aab0b --- /dev/null +++ b/external/sgx_libm/intel64/acoshl.S @@ -0,0 +1,947 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acoshl.c" + .text +..TXTST0: +# -- Begin acoshl + .text + .align 16,0x90 + .globl acoshl +acoshl: +# parameter 1: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_acoshl.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + xorb %cl, %cl +..B1.2: + fnstcw 50(%rsp) +..B1.3: + movzwl 72(%rsp), %edi + movl %edi, %edx + movzbl 73(%rsp), %esi + andl $32767, %edx + shrl $7, %esi + shll $15, %esi + orl %edx, %esi + shll $16, %esi + movzwl 70(%rsp), %eax + orl %eax, %esi + addl $-1073709056, %esi + cmpl $1073741824, %esi + jae ..B1.40 +..B1.4: + cmpl $8192, %esi + jae ..B1.21 +..B1.5: + cmpl $64, %esi + jae ..B1.14 +..B1.6: + cmpl $16383, %edx + je ..B1.38 +..B1.7: + movzwl 50(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.11 +..B1.8: + orl $-64768, %edx + movw %dx, 48(%rsp) +..B1.9: + fldcw 48(%rsp) +..B1.10: + movb $1, %cl +..B1.11: + fldt 64(%rsp) + lea 8+_ones(%rip), %rax + lea _TWO_52H(%rip), %rdx + lea 80+_Q1(%rip), %rsi + lea 48+_Q1(%rip), %rdi + lea 16+_Q1(%rip), %r8 + lea 64+_Q1(%rip), %r9 + lea 32+_Q1(%rip), %r10 + lea _Q1(%rip), %r11 + testb %cl, %cl + fldl (%rdx) + fld %st(0) + fxch %st(2) + faddl (%rax) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(0) + fmul %st(1), %st + fld %st(1) + fsub %st(4), %st + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rsi) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%r11) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + fmul %st, %st(2) + fld %st(2) + fxch %st(1) + fmulp %st, %st(5) + fadd %st(4), %st + fsqrt + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fld %st(4) + fmul %st(5), %st + fsubrp %st, %st(6) + fld %st(4) + fmul %st(1), %st + fsubrp %st, %st(6) + fxch %st(3) + faddp %st, %st(5) + fdivrp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(2) + fadd %st(1), %st + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.13 +..B1.12: + fldcw 50(%rsp) +..B1.13: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.14: + movzwl 50(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.18 +..B1.15: + orl $-64768, %edx + movw %dx, 48(%rsp) +..B1.16: + fldcw 48(%rsp) +..B1.17: + movb $1, %cl +..B1.18: + fldt 64(%rsp) + lea 8+_ones(%rip), %rax + lea _TWO_52H(%rip), %rdx + lea 208+_Q(%rip), %rsi + lea 176+_Q(%rip), %rdi + lea 144+_Q(%rip), %r8 + lea 112+_Q(%rip), %r9 + lea 80+_Q(%rip), %r10 + lea 48+_Q(%rip), %r11 + testb %cl, %cl + fldl (%rdx) + lea 192+_Q(%rip), %rdx + fstpt 16(%rsp) + fldt 16(%rsp) + fldt (%rdi) + lea 128+_Q(%rip), %rdi + fldt (%r8) + lea 96+_Q(%rip), %r8 + fxch %st(3) + faddl (%rax) + lea 16+_Q(%rip), %rax + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fld %st(1) + fsub %st(4), %st + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fxch %st(5) + fstpt 32(%rsp) + fldt 32(%rsp) + fmul %st(0), %st + fadd %st, %st(5) + fxch %st(3) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rsi) + lea 160+_Q(%rip), %rsi + fmul %st(6), %st + faddp %st, %st(5) + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(6) + fxch %st(4) + fmul %st, %st(5) + fldt (%r9) + lea 64+_Q(%rip), %r9 + faddp %st, %st(6) + fmul %st, %st(5) + fldt (%r10) + lea 32+_Q(%rip), %r10 + faddp %st, %st(6) + fmul %st, %st(5) + fldt (%r11) + lea _Q(%rip), %r11 + faddp %st, %st(6) + fmul %st, %st(5) + fldt (%rax) + lea 240+_Q(%rip), %rax + faddp %st, %st(6) + fmul %st, %st(5) + fldt (%rdx) + lea 224+_Q(%rip), %rdx + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(4) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fmulp %st, %st(1) + fldt (%rdx) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(4) + fldt 32(%rsp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + fld %st(0) + fadd %st(3), %st + fsub %st(1), %st + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fldt .L_2il0floatpacket.0(%rip) + fmul %st, %st(4) + fld %st(4) + fxch %st(1) + fmulp %st, %st(3) + fadd %st(2), %st + fsqrt + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fsubrp %st, %st(3) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(1), %st + fsubrp %st, %st(4) + fxch %st(5) + faddp %st, %st(3) + fdivrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fld %st(0) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(4) + fadd %st(3), %st + fmulp %st, %st(4) + fld %st(1) + fmul %st(3), %st + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fmul %st(2), %st + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.20 +..B1.19: + fldcw 50(%rsp) +..B1.20: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.21: + movzwl 50(%rsp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.25 +..B1.22: + orl $-64768, %esi + movw %si, 48(%rsp) +..B1.23: + fldcw 48(%rsp) +..B1.24: + movzwl 72(%rsp), %edi + movl %edi, %edx + movb $1, %cl + andl $32767, %edx +..B1.25: + cmpl $16417, %edx + jge ..B1.34 +..B1.26: + fldt 64(%rsp) + cmpl $16388, %edx + jge ..B1.28 +..B1.27: + lea _TWO_52H(%rip), %rax + fld %st(0) + fld %st(1) + lea 8+_ones(%rip), %r8 + lea _ones(%rip), %rdx + fldl (%rax) + fld %st(0) + fxch %st(1) + fadd %st, %st(3) + fsubr %st, %st(3) + fld %st(3) + fxch %st(3) + fsub %st(4), %st + fmul %st, %st(3) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(3) + fld %st(3) + fmul %st(4), %st + faddl (%r8) + fld %st(0) + fadd %st(4), %st + fsqrt + fadd %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fsubrp %st, %st(1) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fdivrp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl (%rdx) + jmp ..B1.33 +..B1.28: + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_32H(%rip), %rax + fmul %st(1), %st + lea _ones(%rip), %rsi + fld %st(0) + lea 8+_ones(%rip), %r8 + fldl (%rax) + cmpl $16394, %edx + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubr %st(1), %st + fldl (%rsi) + fldl (%r8) + jge ..B1.30 +..B1.29: + fstp %st(3) + fld %st(3) + fadd %st(3), %st + fld %st(4) + fadd %st(2), %st + fmulp %st, %st(1) + fsqrt + faddp %st, %st(4) + fxch %st(3) + fdivrp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + jmp ..B1.33 +..B1.30: + fstp %st(4) + cmpl $16401, %edx + jge ..B1.32 +..B1.31: + fld %st(3) + fdiv %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fdivrp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.33 +..B1.32: + fxch %st(2) + fdivrp %st, %st(3) + faddp %st, %st(2) +..B1.33: + fldt 16(%rsp) + fld %st(0) + fadd %st(3), %st + fstpt 64(%rsp) + movzwl 72(%rsp), %edx + andl $32767, %edx + movl %edx, %eax + addl $-16383, %edx + negl %eax + fxch %st(1) + fstpt (%rsp) + addl $-2, %eax + movzwl 8(%rsp), %esi + andl $32767, %eax + andl $-32768, %esi + orl %eax, %esi + movw %si, 8(%rsp) + fldt (%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fmulp %st, %st(1) + jmp ..B1.35 +..B1.34: + lea _TWO_52H(%rip), %rax + andl $-32768, %edi + orl $-49153, %edi + addl $-16382, %edx + movw %di, 72(%rsp) + lea 8+_ones(%rip), %r8 + fldt 64(%rsp) + fld %st(0) + fldl (%rax) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) +..B1.35: + fldt 16(%rsp) + lea 16+_P(%rip), %r9 + movl 68(%rsp), %esi + lea 64+_P(%rip), %r10 + shrl $23, %esi + lea 32+_P(%rip), %r11 + movzbl %sil, %eax + fldt (%r9) + movq __libm_rcp_table_256@GOTPCREL(%rip), %rdi + movl %edx, 32(%rsp) + lea 80+_P(%rip), %rdx + fildl 32(%rsp) + flds (%rdi,%rax,4) + fmul %st, %st(3) + fmulp %st, %st(4) + fxch %st(2) + faddl (%r8) + fld %st(0) + lea 48+_P(%rip), %r8 + shlq $4, %rax + fadd %st(4), %st + fld %st(0) + testb %cl, %cl + fmul %st(1), %st + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea _P(%rip), %rdx + fmul %st(2), %st + fldt (%r8) + movq __libm_logl_table_256@GOTPCREL(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + fmulp %st, %st(3) + fldt (%r10) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(2), %st + fldt .L_2il0floatpacket.3(%rip) + fmulp %st, %st(3) + faddl 8(%rsi,%rax) + faddp %st, %st(3) + fxch %st(1) + faddl (%rax,%rsi) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.37 +..B1.36: + fldcw 50(%rsp) +..B1.37: + fldt 16(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.38: + movq $0x8000000000000000, %rax + cmpq 64(%rsp), %rax + jne ..B1.7 +..B1.39: + lea _zeros(%rip), %rax + fldl (%rax) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.40: + movzwl 50(%rsp), %esi + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.44 +..B1.41: + orl $-64768, %esi + movw %si, 48(%rsp) +..B1.42: + fldcw 48(%rsp) +..B1.43: + movzwl 72(%rsp), %edx + movb $1, %cl + andl $32767, %edx +..B1.44: + cmpl $32767, %edx + jne ..B1.47 +..B1.45: + movq $0x8000000000000000, %rax + cmpq 64(%rsp), %rax + je ..B1.51 +..B1.46: + fldt 64(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) + jmp ..B1.48 +..B1.47: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt (%rsp) +..B1.48: + testb %cl, %cl + je ..B1.50 +..B1.49: + fldcw 50(%rsp) +..B1.50: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.51: + testb $-128, 73(%rsp) + je ..B1.46 + jmp ..B1.47 + .align 16,0x90 + .cfi_endproc + .type acoshl,@function + .size acoshl,.-acoshl + .data +# -- End acoshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 37372 + .word 39321 + .word 39321 + .word 39321 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 18586 + .word 55971 + .word 28086 + .word 46811 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 15813 + .word 59837 + .word 36396 + .word 63715 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 53727 + .word 45078 + .word 40330 + .word 46917 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 48396 + .word 8155 + .word 33124 + .word 36271 + .word 16371 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,96 + .align 2 +_Q: + .word 48098 + .word 43690 + .word 43690 + .word 43690 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 20923 + .word 52462 + .word 52428 + .word 52428 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 38527 + .word 56172 + .word 28086 + .word 46811 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 47050 + .word 58060 + .word 36408 + .word 63715 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 28121 + .word 12720 + .word 53620 + .word 46917 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 5738 + .word 23392 + .word 25199 + .word 36391 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 9822 + .word 24561 + .word 52037 + .word 58572 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 32045 + .word 31633 + .word 41878 + .word 48451 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 16262 + .word 24754 + .word 13643 + .word 40941 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 36557 + .word 45689 + .word 21168 + .word 35169 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 29793 + .word 40103 + .word 23573 + .word 60969 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 51189 + .word 17117 + .word 14297 + .word 51855 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 6461 + .word 12463 + .word 55551 + .word 38957 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 34939 + .word 19802 + .word 20012 + .word 37205 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43696 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,256 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,96 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/acosl.S b/external/sgx_libm/intel64/acosl.S new file mode 100644 index 0000000000..417a3ff052 --- /dev/null +++ b/external/sgx_libm/intel64/acosl.S @@ -0,0 +1,1366 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "acosl.c" + .text +..TXTST0: +# -- Begin acosl + .text + .align 16,0x90 + .globl acosl +acosl: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_acosl.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %cl, %cl +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movb 105(%rsp), %dl + movzwl 104(%rsp), %edi + andb $-128, %dl + andl $32767, %edi + shrb $7, %dl + movzwl 82(%rsp), %eax + cmpl $16383, %edi + jge ..B1.60 +..B1.4: + cmpl $16382, %edi + jge ..B1.47 +..B1.5: + cmpl $16376, %edi + jge ..B1.37 +..B1.6: + cmpl $16371, %edi + jge ..B1.30 +..B1.7: + cmpl $16365, %edi + jge ..B1.23 +..B1.8: + cmpl $16308, %edi + jge ..B1.16 +..B1.9: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.13 +..B1.10: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.11: + fldcw 80(%rsp) +..B1.12: + movb $1, %cl +..B1.13: + fldt 96(%rsp) + lea 16+_pi_02(%rip), %rax + lea _pi_02(%rip), %rdx + testb %cl, %cl + fldt (%rax) + fsubp %st, %st(1) + fldt (%rdx) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.15 +..B1.14: + fldcw 82(%rsp) +..B1.15: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.16: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.17: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.18: + fldcw 80(%rsp) +..B1.19: + movb $1, %cl +..B1.20: + fldt 96(%rsp) + lea _P4(%rip), %rax + lea 16+_pi_02(%rip), %rdx + lea _pi_02(%rip), %rsi + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fldt (%rdx) + fsubp %st, %st(1) + fldt (%rsi) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.22 +..B1.21: + fldcw 82(%rsp) +..B1.22: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.23: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.27 +..B1.24: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.25: + fldcw 80(%rsp) +..B1.26: + movb $1, %cl +..B1.27: + fldt 96(%rsp) + lea 16+_P3(%rip), %rax + fld %st(0) + lea _P3(%rip), %rdx + fmul %st(1), %st + lea 16+_pi_02(%rip), %rsi + fldt (%rax) + lea _pi_02(%rip), %rdi + fmul %st(1), %st + testb %cl, %cl + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fldt (%rsi) + fsubp %st, %st(1) + fldt (%rdi) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.29 +..B1.28: + fldcw 82(%rsp) +..B1.29: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.30: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.34 +..B1.31: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.32: + fldcw 80(%rsp) +..B1.33: + movb $1, %cl +..B1.34: + fldt 96(%rsp) + lea _TWO_32H(%rip), %rax + fld %st(0) + lea 48+_P2(%rip), %rdx + fmul %st(1), %st + lea 16+_P2(%rip), %rsi + fld %st(0) + lea 32+_P2(%rip), %rdi + fmul %st(1), %st + fld %st(2) + lea _P2(%rip), %r8 + fld %st(3) + fldl (%rax) + lea 16+_pi_02(%rip), %r9 + fmul %st(5), %st + lea _pi_02(%rip), %r10 + testb %cl, %cl + fadd %st, %st(2) + fsubrp %st, %st(2) + fsub %st(1), %st + fldt (%rdx) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + fmulp %st, %st(4) + fldt (%r8) + faddp %st, %st(4) + fxch %st(4) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt (%r9) + fsubp %st, %st(1) + fldt (%r10) + fsubp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.36 +..B1.35: + fldcw 82(%rsp) +..B1.36: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.37: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.41 +..B1.38: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.39: + fldcw 80(%rsp) +..B1.40: + movzwl 104(%rsp), %edi + movb $1, %cl + andl $32767, %edi +..B1.41: + fldt 96(%rsp) + lea _TWO_52H(%rip), %rax + fld %st(0) + cmpl $16381, %edi + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fldl (%rax) + fmul %st, %st(2) + fstpt 32(%rsp) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fld %st(1) + fsub %st(3), %st + fmul %st, %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fld %st(3) + fmul %st(4), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fld %st(2) + fmul %st(2), %st + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fld %st(1) + fmul %st(2), %st + fadd %st, %st(1) + fxch %st(3) + fstpt 16(%rsp) + jge ..B1.43 +..B1.42: + fstp %st(2) + lea 176+_P1(%rip), %rax + lea 144+_P1(%rip), %rdx + lea 112+_P1(%rip), %rsi + lea 80+_P1(%rip), %rdi + lea 160+_P1(%rip), %r10 + lea 48+_P1(%rip), %r8 + lea 128+_P1(%rip), %r11 + lea 16+_P1(%rip), %r9 + fldt (%rax) + lea 96+_P1(%rip), %rax + fmul %st(2), %st + fldt (%rdx) + lea 64+_P1(%rip), %rdx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 32+_P1(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + lea _P1(%rip), %rdi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + lea 192+_P1(%rip), %r8 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%rdi) + faddp %st, %st(3) + fldt 64(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 16(%rsp) + fldt (%r8) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + fxch %st(1) + jmp ..B1.44 +..B1.43: + lea 272+_P(%rip), %rax + lea 240+_P(%rip), %rdx + lea 208+_P(%rip), %rsi + lea 176+_P(%rip), %rdi + lea 144+_P(%rip), %r8 + lea 112+_P(%rip), %r9 + lea 80+_P(%rip), %r10 + lea 48+_P(%rip), %r11 + fldt (%rax) + lea 16+_P(%rip), %rax + fmul %st(1), %st + fldt (%rdx) + lea 256+_P(%rip), %rdx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + lea 224+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea 192+_P(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea 160+_P(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + lea 128+_P(%rip), %r9 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + lea 96+_P(%rip), %r10 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + lea 64+_P(%rip), %r11 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + lea 32+_P(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx) + lea _P(%rip), %rdx + fmul %st(2), %st + fldt (%rsi) + lea 304+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 288+_P(%rip), %rdi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rdx) + faddp %st, %st(2) + fldt 64(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 48(%rsp) + fldt 16(%rsp) + fldt (%rsi) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(4) + fldt (%rdi) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fld %st(3) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 32(%rsp) + fmul %st(3), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) +..B1.44: + fldt (%rsp) + lea _pi_02(%rip), %rax + fmulp %st, %st(1) + fld %st(2) + fmul %st(2), %st + lea 16+_pi_02(%rip), %rdx + testb %cl, %cl + faddp %st, %st(1) + faddp %st, %st(2) + fmul %st(2), %st + faddp %st, %st(2) + fldt (%rax) + fld %st(0) + fsubr %st(3), %st + fchs + fsub %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fldt (%rdx) + fsubp %st, %st(2) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.46 +..B1.45: + fldcw 82(%rsp) +..B1.46: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.47: + movl %eax, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.51 +..B1.48: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.49: + fldcw 80(%rsp) +..B1.50: + movb $1, %cl +..B1.51: + fldt 96(%rsp) + lea _ones(%rip), %rsi + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_32H(%rip), %rdi + movzbl %dl, %eax + lea _TWO_52H(%rip), %r8 + fldl (%rdi) + fxch %st(2) + fmull (%rsi,%rax,8) + fldl (%r8) + fstpt 16(%rsp) + fldt 16(%rsp) + fxch %st(1) + fsubrl (%rsi) + fmul %st(2), %st + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsubp %st, %st(4) + fld %st(3) + fxch %st(1) + fsub %st(4), %st + fadd %st, %st(1) + fxch %st(1) + fsqrt + fmul %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fsubr %st, %st(5) + fld %st(3) + fxch %st(2) + fsub %st(4), %st + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(6) + fxch %st(2) + faddp %st, %st(5) + fld %st(2) + fadd %st(1), %st + fdivrp %st, %st(5) + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fld %st(0) + fmul %st(3), %st + fld %st(2) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(5), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fld %st(1) + fmul %st(6), %st + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(1) + fstpt (%rsp) + fld %st(4) + fmul %st(5), %st + fadd %st, %st(1) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fcomip %st(1), %st + fstp %st(0) + jbe ..B1.53 +..B1.52: + fstp %st(1) + lea 176+_P1(%rip), %rax + lea 144+_P1(%rip), %rsi + lea 112+_P1(%rip), %rdi + lea 80+_P1(%rip), %r8 + lea 160+_P1(%rip), %r11 + lea 48+_P1(%rip), %r9 + lea 16+_P1(%rip), %r10 + fldt (%rax) + lea 128+_P1(%rip), %rax + fmul %st(1), %st + fldt (%rsi) + lea 96+_P1(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea 64+_P1(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea 32+_P1(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + lea _P1(%rip), %r9 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + lea 192+_P1(%rip), %r10 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r9) + faddp %st, %st(2) + fldt 48(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt (%rsp) + fldt (%r10) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(4) + fxch %st(3) + jmp ..B1.54 +..B1.53: + lea 272+_P(%rip), %rax + lea 240+_P(%rip), %rsi + lea 208+_P(%rip), %rdi + lea 176+_P(%rip), %r8 + lea 144+_P(%rip), %r9 + lea 112+_P(%rip), %r10 + lea 80+_P(%rip), %r11 + fldt (%rax) + lea 48+_P(%rip), %rax + fmul %st(1), %st + fldt (%rsi) + lea 16+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea 256+_P(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea 224+_P(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + lea 192+_P(%rip), %r9 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + lea 160+_P(%rip), %r10 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + lea 128+_P(%rip), %r11 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + lea 96+_P(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + lea 64+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea 32+_P(%rip), %rdi + fmul %st(2), %st + fldt (%r8) + lea _P(%rip), %r8 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + lea 304+_P(%rip), %r9 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + lea 288+_P(%rip), %r10 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r8) + faddp %st, %st(2) + fldt 48(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 32(%rsp) + fldt (%rsp) + fldt (%r9) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(3) + fldt (%r10) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fld %st(0) + fldt 16(%rsp) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(4) +..B1.54: + fldt 64(%rsp) + testb %dl, %dl + fmulp %st, %st(4) + fld %st(2) + fmul %st(1), %st + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + je ..B1.56 +..B1.55: + fstp %st(3) + fstp %st(0) + fldt .L_2il0floatpacket.2(%rip) + lea _pi_00(%rip), %rax + lea 16+_pi_00(%rip), %rdx + fmul %st, %st(2) + fmulp %st, %st(1) + fldt (%rax) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fldt (%rdx) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + jmp ..B1.57 +..B1.56: + fldt .L_2il0floatpacket.3(%rip) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.57: + testb %cl, %cl + je ..B1.59 +..B1.58: + fldcw 82(%rsp) +..B1.59: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.60: + movl %eax, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.64 +..B1.61: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.62: + fldcw 80(%rsp) +..B1.63: + movzwl 104(%rsp), %edi + movb $1, %cl + andl $32767, %edi +..B1.64: + cmpl $32767, %edi + jne ..B1.68 +..B1.65: + cmpl $-2147483648, 100(%rsp) + jne ..B1.67 +..B1.66: + cmpl $0, 96(%rsp) + je ..B1.74 +..B1.67: + fldt 96(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) + jmp ..B1.75 +..B1.68: + cmpl $16383, %edi + jne ..B1.74 +..B1.69: + cmpl $-2147483648, 100(%rsp) + jne ..B1.74 +..B1.70: + cmpl $0, 96(%rsp) + jne ..B1.74 +..B1.71: + testb %dl, %dl + je ..B1.73 +..B1.72: + lea _pi_0l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rax) + fldt (%rdx) + fsubrp %st, %st(1) + fstpt 8(%rsp) + jmp ..B1.75 +..B1.73: + lea _zeros(%rip), %rax + fldl (%rax) + fstpt 8(%rsp) + jmp ..B1.75 +..B1.74: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 8(%rsp) +..B1.75: + testb %cl, %cl + je ..B1.77 +..B1.76: + fldcw 82(%rsp) +..B1.77: + fldt 8(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type acosl,@function + .size acosl,.-acosl + .data +# -- End acosl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_pi_02: + .word 0 + .word 0 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 35374 + .word 4889 + .word 2259 + .word 34211 + .word 16349 + .word 0 + .word 0 + .word 0 + .type _pi_02,@object + .size _pi_02,32 + .align 2 +_P4: + .word 43691 + .word 44938 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P4,@object + .size _P4,16 + .align 2 +_P3: + .word 36763 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 40704 + .word 58046 + .word 39460 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _P3,@object + .size _P3,32 + .align 2 +_P2: + .word 43688 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 20771 + .word 39331 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 23807 + .word 53798 + .word 28073 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 35198 + .word 7516 + .word 54204 + .word 63722 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _P2,@object + .size _P2,64 + .align 2 +_P1: + .word 43589 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 39364 + .word 39321 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 17602 + .word 56173 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 47501 + .word 58414 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 27078 + .word 6583 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 39781 + .word 21053 + .word 25224 + .word 36391 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 46568 + .word 6235 + .word 50749 + .word 58572 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 41318 + .word 51558 + .word 37628 + .word 48452 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 55026 + .word 7893 + .word 43866 + .word 40925 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 43387 + .word 19951 + .word 2911 + .word 35445 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 32572 + .word 59281 + .word 11243 + .word 56666 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 49800 + .word 50337 + .word 42707 + .word 39184 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,208 + .align 2 +_P: + .word 42691 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 4317 + .word 52400 + .word 52428 + .word 52428 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 26206 + .word 56172 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 36130 + .word 58514 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 21592 + .word 8113 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 3093 + .word 49950 + .word 25215 + .word 36391 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 21499 + .word 24428 + .word 51889 + .word 58572 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 54828 + .word 41264 + .word 61120 + .word 48451 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 10243 + .word 1489 + .word 39717 + .word 40940 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 51433 + .word 46039 + .word 63564 + .word 35220 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 60402 + .word 39286 + .word 25675 + .word 60826 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 34219 + .word 36833 + .word 44839 + .word 57547 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 13013 + .word 26091 + .word 19721 + .word 60832 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 22353 + .word 41544 + .word 55443 + .word 55735 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 14948 + .word 7038 + .word 38091 + .word 38339 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 61727 + .word 61480 + .word 15906 + .word 51927 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 13386 + .word 23084 + .word 64443 + .word 55906 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 17499 + .word 23573 + .word 43947 + .word 42761 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,320 + .align 2 +_pi_00: + .word 0 + .word 0 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 35374 + .word 4889 + .word 2259 + .word 34211 + .word 16350 + .word 0 + .word 0 + .word 0 + .type _pi_00,@object + .size _pi_00,32 + .align 2 +_pi_0l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49152 + .word 0 + .word 0 + .word 0 + .type _pi_0l,@object + .size _pi_0l,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/asin.S b/external/sgx_libm/intel64/asin.S new file mode 100644 index 0000000000..1de85746a3 --- /dev/null +++ b/external/sgx_libm/intel64/asin.S @@ -0,0 +1,1998 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asin.c" + .text +..TXTST0: +# -- Begin asin + .text + .align 16,0x90 + .globl asin +asin: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_asin.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + stmxcsr 16(%rsp) + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + jne .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + movsd ABSVALMASK(%rip), %xmm4 + movsd ONEMASK(%rip), %xmm3 + xorpd %xmm5, %xmm5 + movsd TMASK(%rip), %xmm2 + movl $8192, %ecx + pinsrw $2, %ecx, %xmm5 + movq %xmm0, %xmm1 + psrlq $44, %xmm0 + movd %xmm0, %edx + movq %xmm1, %xmm7 + movl $8192, %ecx + pinsrw $2, %ecx, %xmm5 + movq %xmm1, %xmm0 + movl $524287, %eax + andl %edx, %eax + subl $260864, %eax + cmpl $955, %eax + jae .L_2TAG_PACKET_2.0.2 + mulsd %xmm1, %xmm1 + andl $65535, %edx + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + andpd %xmm7, %xmm2 + andl $-4, %edx + subl $64256, %edx + lea T_table(%rip), %r8 + movsd (%r8,%rdx,2), %xmm1 + orpd %xmm5, %xmm2 + lea Tbl_addr(%rip), %r8 + movapd (%r8,%rdx,4), %xmm4 + movq %xmm7, %xmm6 + addsd %xmm2, %xmm7 + subsd %xmm2, %xmm0 + mulsd %xmm7, %xmm0 + mulsd %xmm1, %xmm6 + mulsd %xmm2, %xmm3 + movq %xmm6, %xmm1 + addsd %xmm3, %xmm6 + divsd %xmm6, %xmm0 + movsd 16+cv(%rip), %xmm7 + movsd cv(%rip), %xmm5 + subsd %xmm3, %xmm1 + andpd SIGNMASK(%rip), %xmm2 + movq %xmm1, %xmm3 + mulsd %xmm1, %xmm1 + movsd 8+cv(%rip), %xmm6 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm7 + mulsd %xmm3, %xmm5 + xorpd %xmm2, %xmm4 + mulsd %xmm1, %xmm3 + addsd %xmm7, %xmm6 + mulsd %xmm3, %xmm6 + addsd %xmm4, %xmm5 + pshufd $238, %xmm4, %xmm4 + addsd %xmm5, %xmm6 + orpd %xmm2, %xmm4 + addsd %xmm6, %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_3.0.2 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_3.0.2: + addsd %xmm4, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_2.0.2: + subl $955, %eax + cmpl $67, %eax + jae .L_2TAG_PACKET_4.0.2 + mulsd %xmm1, %xmm1 + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + movl %edx, %eax + andpd ABSVALMASK(%rip), %xmm0 + andpd HALFMASK2(%rip), %xmm7 + movq %xmm0, %xmm1 + movsd ONEMASK(%rip), %xmm4 + movq %xmm7, %xmm6 + subsd %xmm7, %xmm1 + mulsd %xmm7, %xmm7 + addsd %xmm6, %xmm0 + subsd %xmm7, %xmm4 + mulsd %xmm1, %xmm0 + movq %xmm3, %xmm7 + andpd %xmm3, %xmm2 + psllq $2, %xmm3 + pextrw $3, %xmm3, %edx + orpd %xmm5, %xmm2 + subl $65216, %edx + addl %edx, %edx + lea T_table(%rip), %r8 + mulsd (%r8,%rdx,4), %xmm7 + mulsd %xmm2, %xmm6 + movapd PI_BY_2(%rip), %xmm3 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + subsd %xmm7, %xmm6 + addsd %xmm1, %xmm6 + subsd %xmm2, %xmm4 + addsd %xmm7, %xmm7 + movsd cv(%rip), %xmm5 + subsd %xmm0, %xmm4 + addsd %xmm6, %xmm7 + movsd 16+cv(%rip), %xmm0 + divsd %xmm7, %xmm4 + movsd 8+cv(%rip), %xmm2 + lea Tbl_addr(%rip), %r8 + subpd (%r8,%rdx,8), %xmm3 + movq %xmm6, %xmm1 + mulsd %xmm6, %xmm6 + andl $524288, %eax + shrl $4, %eax + mulsd %xmm6, %xmm0 + mulsd %xmm6, %xmm1 + mulsd %xmm1, %xmm5 + mulsd %xmm6, %xmm1 + addsd %xmm2, %xmm0 + pxor %xmm6, %xmm6 + mulsd %xmm1, %xmm0 + addsd %xmm3, %xmm5 + pinsrw $3, %eax, %xmm6 + addsd %xmm5, %xmm0 + movq %xmm4, %xmm5 + pshufd $238, %xmm3, %xmm3 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm3 + subsd %xmm3, %xmm5 + subsd %xmm5, %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_5.0.2 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_5.0.2: + xorpd %xmm6, %xmm0 + xorpd %xmm6, %xmm4 + subsd %xmm4, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_4.0.2: + addl $15291, %eax + cmpl $14336, %eax + jae .L_2TAG_PACKET_6.0.2 + unpcklpd %xmm7, %xmm7 + movapd cv2(%rip), %xmm1 + movapd %xmm7, %xmm6 + movapd 16+cv2(%rip), %xmm2 + movapd 32+cv2(%rip), %xmm4 + mulpd %xmm7, %xmm7 + mulpd %xmm7, %xmm6 + mulpd %xmm7, %xmm1 + mulpd %xmm7, %xmm7 + movq %xmm6, %xmm3 + mulsd %xmm6, %xmm6 + addpd %xmm2, %xmm1 + mulpd %xmm7, %xmm4 + mulsd %xmm3, %xmm6 + addpd %xmm4, %xmm1 + mulpd %xmm6, %xmm1 + pshufd $238, %xmm1, %xmm2 + addsd %xmm2, %xmm1 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_7.0.2 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_7.0.2: + addsd %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_6.0.2: + subl $15358, %eax + cmpl $2, %eax + jae .L_2TAG_PACKET_8.0.2 + mulsd %xmm1, %xmm1 + subsd %xmm1, %xmm3 + sqrtsd %xmm3, %xmm3 + movl %edx, %eax + andpd HALFMASK(%rip), %xmm7 + pshufd $68, %xmm3, %xmm5 + andpd HALFMASK(%rip), %xmm3 + movq %xmm7, %xmm1 + movsd ONEMASK(%rip), %xmm4 + movq %xmm7, %xmm6 + subsd %xmm7, %xmm0 + mulsd %xmm7, %xmm7 + addsd %xmm1, %xmm1 + mulsd %xmm0, %xmm1 + subsd %xmm7, %xmm4 + movq %xmm3, %xmm6 + mulsd %xmm3, %xmm3 + mulsd %xmm0, %xmm0 + subsd %xmm1, %xmm4 + subsd %xmm5, %xmm6 + addsd %xmm5, %xmm5 + subsd %xmm3, %xmm4 + movapd cv2(%rip), %xmm2 + pshufd $238, %xmm5, %xmm3 + subsd %xmm0, %xmm4 + addsd %xmm6, %xmm5 + pshufd $238, %xmm3, %xmm7 + addsd %xmm3, %xmm3 + mulsd %xmm6, %xmm5 + addsd %xmm5, %xmm4 + pshufd $238, %xmm7, %xmm6 + divsd %xmm3, %xmm4 + movapd 48+cv2(%rip), %xmm1 + movapd 16+cv2(%rip), %xmm5 + movapd 32+cv2(%rip), %xmm0 + mulpd %xmm7, %xmm7 + movq %xmm6, %xmm3 + mulpd %xmm7, %xmm2 + mulpd %xmm7, %xmm6 + shrl $4, %eax + andl $32768, %eax + mulsd %xmm7, %xmm1 + mulpd %xmm7, %xmm7 + addpd %xmm2, %xmm5 + movapd %xmm6, %xmm2 + mulsd %xmm6, %xmm6 + mulpd %xmm0, %xmm7 + movapd PI_BY_2(%rip), %xmm0 + mulsd %xmm6, %xmm2 + addpd %xmm5, %xmm7 + pshufd $238, %xmm1, %xmm5 + mulsd %xmm2, %xmm6 + mulpd %xmm2, %xmm7 + addsd %xmm5, %xmm1 + xorpd %xmm5, %xmm5 + pshufd $238, %xmm7, %xmm2 + mulsd %xmm6, %xmm1 + pshufd $238, %xmm0, %xmm6 + addsd %xmm2, %xmm7 + movq %xmm3, %xmm2 + pinsrw $3, %eax, %xmm5 + subsd %xmm6, %xmm3 + addsd %xmm1, %xmm0 + addsd %xmm3, %xmm6 + addsd %xmm4, %xmm7 + subsd %xmm6, %xmm2 + subsd %xmm7, %xmm0 + subsd %xmm2, %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_9.0.2 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_9.0.2: + xorpd %xmm5, %xmm0 + xorpd %xmm5, %xmm3 + subsd %xmm3, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_8.0.2: + addl $261886, %eax + cmpl $261888, %eax + jb .L_2TAG_PACKET_10.0.2 + movd %xmm0, %ecx + psrlq $32, %xmm0 + movd %xmm0, %edx + andl $2147483647, %edx + movl $1072693248, %eax + subl %edx, %eax + orl %ecx, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_11.0.2 + movsd (%rsp), %xmm2 + movd %xmm2, %edx + psrlq $32, %xmm2 + movd %xmm2, %ecx + andl $2147483647, %ecx + subl $1, %edx + sbbl $2146435072, %ecx + cmpl $0, %ecx + jge .L_2TAG_PACKET_10.0.2 + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %edx + pinsrw $3, %edx, %xmm1 + mulsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_12.0.2 +.L_2TAG_PACKET_11.0.2: + movsd ABSVALMASK(%rip), %xmm1 + movsd PI_BY_2(%rip), %xmm2 + movsd 8+PI_BY_2(%rip), %xmm0 + addsd %xmm2, %xmm0 + andnpd %xmm7, %xmm1 + orpd %xmm1, %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_13.0.2 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_13.0.2: + jmp ..B1.5 +.L_2TAG_PACKET_10.0.2: + movsd (%rsp), %xmm0 + xorpd %xmm6, %xmm6 + movq %xmm0, %xmm7 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_14.0.2 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_14.0.2: + pextrw $3, %xmm0, %edx + andl $32752, %edx + subl $16, %edx + cmpl $32736, %edx + jb .L_2TAG_PACKET_15.0.2 + addsd %xmm0, %xmm6 + orpd %xmm6, %xmm0 + mulsd %xmm0, %xmm7 +.L_2TAG_PACKET_15.0.2: + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + movl %eax, 20(%rsp) + ldmxcsr 20(%rsp) + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_12.0.2: + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_16.0.2 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_16.0.2: + movq %xmm0, 8(%rsp) +..B1.3: + movq 8(%rsp), %xmm0 +.L_2TAG_PACKET_17.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type asin,@function + .size asin,.-asin + .data +# -- End asin + .section .rodata, "a" + .align 16 + .align 16 +ABSVALMASK: + .long 4294967295 + .long 2147483647 + .long 0 + .long 0 + .type ABSVALMASK,@object + .size ABSVALMASK,16 + .align 16 +T_table: + .long 2642784509 + .long 1072689083 + .long 1514442531 + .long 1072688953 + .long 333108933 + .long 1072688821 + .long 3392112024 + .long 1072688686 + .long 2099852862 + .long 1072688550 + .long 749609004 + .long 1072688412 + .long 3634632596 + .long 1072688271 + .long 2163248461 + .long 1072688129 + .long 628657846 + .long 1072687985 + .long 3324036511 + .long 1072687838 + .long 1657632815 + .long 1072687690 + .long 4217538760 + .long 1072687539 + .long 2411951597 + .long 1072687387 + .long 533944872 + .long 1072687233 + .long 2876566508 + .long 1072687076 + .long 847936891 + .long 1072686918 + .long 3036019913 + .long 1072686757 + .long 848884575 + .long 1072686595 + .long 2874443326 + .long 1072686430 + .long 520713666 + .long 1072686264 + .long 2375556481 + .long 1072686095 + .long 4141904948 + .long 1072685924 + .long 1522666382 + .long 1072685752 + .long 3105624104 + .long 1072685577 + .long 298666327 + .long 1072685401 + .long 1689524500 + .long 1072685222 + .long 2981002200 + .long 1072685041 + .long 4170844284 + .long 1072684858 + .long 961802263 + .long 1072684674 + .long 1941503454 + .long 1072684487 + .long 2812647170 + .long 1072684298 + .long 3572873869 + .long 1072684107 + .long 4219797823 + .long 1072683914 + .long 456039788 + .long 1072683720 + .long 869096151 + .long 1072683523 + .long 1161535119 + .long 1072683324 + .long 1330865866 + .long 1072683123 + .long 1374571204 + .long 1072682920 + .long 1290107538 + .long 1072682715 + .long 1074904836 + .long 1072682508 + .long 726366587 + .long 1072682299 + .long 241869763 + .long 1072682088 + .long 3913732079 + .long 1072681874 + .long 3149342765 + .long 1072681659 + .long 2240966306 + .long 1072681442 + .long 1185873216 + .long 1072681223 + .long 4276274591 + .long 1072681001 + .long 2919452883 + .long 1072680778 + .long 1407565635 + .long 1072680553 + .long 4032743551 + .long 1072680325 + .long 2202188565 + .long 1072680096 + .long 207977577 + .long 1072679865 + .long 2342160518 + .long 1072679631 + .long 11858423 + .long 1072679396 + .long 1804034453 + .long 1072679158 + .long 3420722787 + .long 1072678918 + .long 563930456 + .long 1072678677 + .long 1820539192 + .long 1072678433 + .long 2892501606 + .long 1072678187 + .long 3776710320 + .long 1072677939 + .long 175063337 + .long 1072677690 + .long 674333171 + .long 1072677438 + .long 976363026 + .long 1072677184 + .long 1077935934 + .long 1072676928 + .long 1921075490 + .long 1072676540 + .long 881493302 + .long 1072676016 + .long 3275752439 + .long 1072675483 + .long 486855588 + .long 1072674943 + .long 1077229111 + .long 1072674394 + .long 723950308 + .long 1072673837 + .long 3693582199 + .long 1072673271 + .long 1367335316 + .long 1072672698 + .long 2305837020 + .long 1072672116 + .long 2184358641 + .long 1072671526 + .long 972682840 + .long 1072670928 + .long 2935101762 + .long 1072670321 + .long 3745513263 + .long 1072669706 + .long 3372320886 + .long 1072669083 + .long 1783464620 + .long 1072668452 + .long 3241386215 + .long 1072667812 + .long 3418125284 + .long 1072667164 + .long 2280219148 + .long 1072666508 + .long 4088700758 + .long 1072665843 + .long 219227400 + .long 1072665171 + .long 3521816918 + .long 1072664489 + .long 1076205279 + .long 1072663800 + .long 1436484616 + .long 1072663102 + .long 271362610 + .long 1072662396 + .long 1838996688 + .long 1072661681 + .long 1807122518 + .long 1072660958 + .long 137953542 + .long 1072660227 + .long 1088178584 + .long 1072659487 + .long 324057537 + .long 1072658739 + .long 2101288076 + .long 1072657982 + .long 2085133974 + .long 1072657217 + .long 235324451 + .long 1072656444 + .long 806051592 + .long 1072655662 + .long 3756033140 + .long 1072654871 + .long 453542543 + .long 1072654073 + .long 3741177327 + .long 1072653265 + .long 691216109 + .long 1072652450 + .long 4145223372 + .long 1072651625 + .long 1174439091 + .long 1072650793 + .long 324416139 + .long 1072649952 + .long 1550246310 + .long 1072649102 + .long 511524674 + .long 1072648244 + .long 1457248482 + .long 1072647377 + .long 45944955 + .long 1072646502 + .long 525537397 + .long 1072645618 + .long 2848440188 + .long 1072644725 + .long 2671555633 + .long 1072643824 + .long 4241172637 + .long 1072642914 + .long 3213094278 + .long 1072641996 + .long 3832503688 + .long 1072641069 + .long 1754091534 + .long 1072640134 + .long 1221921804 + .long 1072639190 + .long 2184526489 + .long 1072638237 + .long 294902089 + .long 1072637276 + .long 4090375270 + .long 1072636305 + .long 632860906 + .long 1072635327 + .long 2753498702 + .long 1072634339 + .long 1808009252 + .long 1072633343 + .long 2036428672 + .long 1072632338 + .long 3383235626 + .long 1072631324 + .long 1497347484 + .long 1072630302 + .long 617018317 + .long 1072629271 + .long 684933058 + .long 1072628231 + .long 1643170798 + .long 1072627182 + .long 3011066360 + .long 1072625592 + .long 957158713 + .long 1072623442 + .long 1390907941 + .long 1072621256 + .long 3819155270 + .long 1072619034 + .long 3443571196 + .long 1072616777 + .long 4045412458 + .long 1072614484 + .long 805503923 + .long 1072612156 + .long 1778922015 + .long 1072609791 + .long 2125033665 + .long 1072607390 + .long 1287203863 + .long 1072604953 + .long 2992629568 + .long 1072602479 + .long 2367267127 + .long 1072599969 + .long 3115526047 + .long 1072597422 + .long 340219539 + .long 1072594839 + .long 2017215719 + .long 1072592218 + .long 3225443424 + .long 1072589560 + .long 3326565673 + .long 1072586865 + .long 1669811211 + .long 1072584133 + .long 1886735022 + .long 1072581363 + .long 3301071171 + .long 1072578555 + .long 928514283 + .long 1072575710 + .long 2656364059 + .long 1072572826 + .long 3473490507 + .long 1072569904 + .long 2649965606 + .long 1072566944 + .long 3736819052 + .long 1072563945 + .long 1680885175 + .long 1072560908 + .long 4413771 + .long 1072557832 + .long 2214869753 + .long 1072554716 + .long 3214725184 + .long 1072551561 + .long 2186079903 + .long 1072548367 + .long 2590372131 + .long 1072545133 + .long 3578146079 + .long 1072541859 + .long 4283712755 + .long 1072538545 + .long 3824834510 + .long 1072535191 + .long 1302400298 + .long 1072531797 + .long 95058636 + .long 1072528362 + .long 3563906063 + .long 1072524885 + .long 2167230730 + .long 1072521368 + .long 3524918334 + .long 1072517809 + .long 2353304918 + .long 1072514209 + .long 1939625839 + .long 1072510567 + .long 1256714581 + .long 1072506883 + .long 3552525848 + .long 1072503156 + .long 3464809522 + .long 1072499387 + .long 4200542593 + .long 1072495575 + .long 355609124 + .long 1072491721 + .long 3684139099 + .long 1072487822 + .long 148355918 + .long 1072483881 + .long 1457689242 + .long 1072479895 + .long 2118591596 + .long 1072475865 + .long 908848089 + .long 1072471791 + .long 877032689 + .long 1072467672 + .long 752012304 + .long 1072463508 + .long 3532301749 + .long 1072459298 + .long 3600563221 + .long 1072455043 + .long 3902857084 + .long 1072450742 + .long 3063101036 + .long 1072446395 + .long 3972344374 + .long 1072442001 + .long 903183549 + .long 1072437561 + .long 983892938 + .long 1072433073 + .long 2722858568 + .long 1072428537 + .long 302790515 + .long 1072423954 + .long 759811057 + .long 1072419322 + .long 2507809922 + .long 1072414641 + .long 2388408813 + .long 1072407528 + .long 2084492942 + .long 1072397870 + .long 2435703301 + .long 1072388010 + .long 1935433360 + .long 1072377945 + .long 2742047290 + .long 1072367671 + .long 2053284205 + .long 1072357185 + .long 657783367 + .long 1072346483 + .long 2893664841 + .long 1072335560 + .long 3718906405 + .long 1072324413 + .long 1547896303 + .long 1072313038 + .long 2494058440 + .long 1072301429 + .long 3133238742 + .long 1072289582 + .long 3327000086 + .long 1072277492 + .long 1860667274 + .long 1072265154 + .long 665340747 + .long 1072252562 + .long 443347841 + .long 1072239710 + .long 581282618 + .long 1072226592 + .long 3349780465 + .long 1072213201 + .long 914217606 + .long 1072199532 + .long 989797661 + .long 1072185576 + .long 945436416 + .long 1072171326 + .long 549291300 + .long 1072156774 + .long 1814636389 + .long 1072141911 + .long 239092858 + .long 1072126729 + .long 1794680724 + .long 1072111217 + .long 1241534678 + .long 1072095366 + .long 3366566214 + .long 1072079164 + .long 1244090828 + .long 1072062601 + .long 1708448120 + .long 1072045663 + .long 3544260650 + .long 1072028337 + .long 1402741403 + .long 1072010610 + .long 2551936888 + .long 1071992465 + .long 617669739 + .long 1071973887 + .long 794002186 + .long 1071954857 + .long 2021237693 + .long 1071935356 + .long 540450384 + .long 1071915364 + .long 1920555537 + .long 1071894857 + .long 2879585206 + .long 1071873811 + .long 3000237455 + .long 1071852199 + .long 3352974346 + .long 1071829991 + .long 569629937 + .long 1071807155 + .long 2077237208 + .long 1071783653 + .long 2284891805 + .long 1071759446 + .long 1226651784 + .long 1071734489 + .long 1102047405 + .long 1071708731 + .long 2009896384 + .long 1071682115 + .long 927419082 + .long 1071654577 + .long 85010366 + .long 1071607413 + .long 696431025 + .long 1071548180 + .long 2611410541 + .long 1071486585 + .long 2612593658 + .long 1071422396 + .long 3548155306 + .long 1071355336 + .long 3887997484 + .long 1071285073 + .long 244854763 + .long 1071211202 + .long 4214445648 + .long 1071133216 + .long 2303966727 + .long 1071050478 + .long 3991040013 + .long 1070962152 + .long 3126952278 + .long 1070867118 + .long 1817448378 + .long 1070763804 + .long 1793814864 + .long 1070649884 + .long 3507224072 + .long 1070447193 + .long 4027609105 + .long 1070148772 + .long 577507993 + .long 1069779414 + .long 2310232419 + .long 1068931829 + .type T_table,@object + .size T_table,2048 + .align 16 +Tbl_addr: + .long 3822952792 + .long 1021639372 + .long 182792448 + .long 1068507836 + .long 2264213271 + .long 1019558908 + .long 649052928 + .long 1068524253 + .long 1797139609 + .long 1022295143 + .long 1243095296 + .long 1068540671 + .long 1415938756 + .long 1021439537 + .long 2033294592 + .long 1068557090 + .long 2356809978 + .long 1021777916 + .long 3088063744 + .long 1068573510 + .long 2669055318 + .long 1022124482 + .long 180888576 + .long 1068589932 + .long 3566445325 + .long 1021358712 + .long 1970196992 + .long 1068606354 + .long 896980323 + .long 1021319659 + .long 4229555456 + .long 1068622777 + .long 436049712 + .long 1021319758 + .long 2732572160 + .long 1068639202 + .long 583123209 + .long 1020797960 + .long 1842831872 + .long 1068655628 + .long 1370449804 + .long 1021429270 + .long 1628994560 + .long 1068672055 + .long 2411391464 + .long 1021057980 + .long 2159763712 + .long 1068688483 + .long 1208692749 + .long 1021943903 + .long 3503886336 + .long 1068704912 + .long 538793309 + .long 1019744063 + .long 1435187200 + .long 1068721343 + .long 4085087612 + .long 1020608419 + .long 317469952 + .long 1068737775 + .long 144386942 + .long 1021440732 + .long 219617280 + .long 1068754208 + .long 2940088361 + .long 1019981122 + .long 1210558208 + .long 1068770642 + .long 2176850347 + .long 1018373705 + .long 3359268352 + .long 1068787077 + .long 2395611454 + .long 1021889042 + .long 2439803648 + .long 1068803514 + .long 1650705253 + .long 1020227966 + .long 2816203520 + .long 1068819952 + .long 3702166386 + .long 1019379914 + .long 262620672 + .long 1068836392 + .long 1855649370 + .long 1020453124 + .long 3438159616 + .long 1068852832 + .long 923063860 + .long 1019273834 + .long 3822105856 + .long 1068869274 + .long 4289947947 + .long 1019434249 + .long 1483729920 + .long 1068885718 + .long 787455814 + .long 1020738379 + .long 787321088 + .long 1068902163 + .long 3321653337 + .long 1021842569 + .long 1802253312 + .long 1068918609 + .long 2653633526 + .long 1021821525 + .long 302985984 + .long 1068935057 + .long 161272028 + .long 1021655149 + .long 653966080 + .long 1068951506 + .long 2566098667 + .long 1020066219 + .long 2924727296 + .long 1068967956 + .long 3646493722 + .long 1014292285 + .long 2889890304 + .long 1068984408 + .long 1081009196 + .long 1022189620 + .long 619098112 + .long 1069000862 + .long 4011643355 + .long 1021773297 + .long 477017600 + .long 1069017317 + .long 4030305534 + .long 1021292252 + .long 2533403904 + .long 1069033773 + .long 2645187591 + .long 1019527099 + .long 2563102208 + .long 1069050231 + .long 3857293792 + .long 1022311697 + .long 635982336 + .long 1069066691 + .long 3625936637 + .long 1017511744 + .long 1116940800 + .long 1069083152 + .long 3653872993 + .long 1022016631 + .long 4075964160 + .long 1069099614 + .long 2468900271 + .long 1021769532 + .long 993165568 + .long 1069116079 + .long 1358104224 + .long 1021199776 + .long 528586752 + .long 1069132545 + .long 2200950332 + .long 1022024872 + .long 2752395776 + .long 1069149012 + .long 3197072454 + .long 1017751319 + .long 3439855616 + .long 1069165481 + .long 1651081806 + .long 1020809338 + .long 2661257728 + .long 1069181952 + .long 539032752 + .long 1021728805 + .long 486957312 + .long 1069198425 + .long 3136045149 + .long 1016888671 + .long 1282340352 + .long 1069214899 + .long 2593963259 + .long 1018956103 + .long 822921728 + .long 1069231375 + .long 2146032737 + .long 1022306465 + .long 3474216192 + .long 1069247852 + .long 3976811625 + .long 1021350207 + .long 716902656 + .long 1069264332 + .long 718267222 + .long 1018624727 + .long 1211594496 + .long 1069280813 + .long 1485641389 + .long 1018447451 + .long 734070272 + .long 1069297296 + .long 354455128 + .long 1021341291 + .long 3650110720 + .long 1069313780 + .long 682185947 + .long 1021651853 + .long 1440663040 + .long 1069330267 + .long 3558574550 + .long 1021615110 + .long 2766612224 + .long 1069346755 + .long 874607978 + .long 1017746872 + .long 3404011008 + .long 1069363245 + .long 4154988502 + .long 1021439906 + .long 3423949056 + .long 1069379737 + .long 2263202309 + .long 1021479615 + .long 2897587712 + .long 1069396231 + .long 2562065031 + .long 1022090363 + .long 1896159232 + .long 1069412727 + .long 3836237663 + .long 1019867288 + .long 490968576 + .long 1069429225 + .long 3322056743 + .long 1006752762 + .long 3048360192 + .long 1069445724 + .long 1152314833 + .long 1013122252 + .long 1049850624 + .long 1069462226 + .long 3601590727 + .long 1022214610 + .long 3156899584 + .long 1069478729 + .long 1855169970 + .long 1019487271 + .long 851173376 + .long 1069495235 + .long 312649594 + .long 1020868604 + .long 2794281728 + .long 1069511742 + .long 1093490181 + .long 1020777577 + .long 468042496 + .long 1069528252 + .long 1152540679 + .long 1021403732 + .long 2534219264 + .long 1069544763 + .long 2292126035 + .long 1021872430 + .long 1376146432 + .long 1069558527 + .long 3293753641 + .long 1020500454 + .long 4175442432 + .long 1069575044 + .long 3626347564 + .long 1021610969 + .long 3523113472 + .long 1069591566 + .long 339956500 + .long 1021119039 + .long 4003350528 + .long 1069608092 + .long 3429333082 + .long 1022813542 + .long 1611067392 + .long 1069624623 + .long 2298017544 + .long 1021977587 + .long 931782144 + .long 1069641158 + .long 2164684743 + .long 1021250988 + .long 2256725504 + .long 1069657697 + .long 1138762335 + .long 1021443776 + .long 1582853120 + .long 1069674241 + .long 1084010382 + .long 1022994693 + .long 3497758720 + .long 1069690789 + .long 406366244 + .long 1022713586 + .long 3999816960 + .long 1069707342 + .long 1488723042 + .long 1023381290 + .long 3383096064 + .long 1069723900 + .long 2541558953 + .long 1019137887 + .long 1942403584 + .long 1069740463 + .long 1879620343 + .long 1022653642 + .long 4268263680 + .long 1069757030 + .long 3039077047 + .long 1022252545 + .long 2067062272 + .long 1069773603 + .long 4190670677 + .long 1020725863 + .long 4225828096 + .long 1069790180 + .long 1998567321 + .long 1022014385 + .long 2452507136 + .long 1069806763 + .long 1511628873 + .long 1021900300 + .long 1340746240 + .long 1069823351 + .long 788367341 + .long 1022726208 + .long 1190035456 + .long 1069839944 + .long 3856337230 + .long 1021834118 + .long 2300688384 + .long 1069856542 + .long 3211396579 + .long 1022621365 + .long 678886400 + .long 1069873146 + .long 4001011887 + .long 1022042646 + .long 921594112 + .long 1069889755 + .long 557811968 + .long 1023065533 + .long 3331668992 + .long 1069906369 + .long 1877060679 + .long 1022419742 + .long 3917875200 + .long 1069922989 + .long 1181055171 + .long 1022752712 + .long 2984829696 + .long 1069939615 + .long 4294526932 + .long 1021499988 + .long 838049024 + .long 1069956247 + .long 3658081878 + .long 1022957952 + .long 2078928384 + .long 1069972884 + .long 820353701 + .long 1019391107 + .long 2719854336 + .long 1069989527 + .long 1644022489 + .long 1023378240 + .long 3069117696 + .long 1070006176 + .long 2771393702 + .long 1019319954 + .long 3435962368 + .long 1070022831 + .long 3876394145 + .long 1023024433 + .long 4130595328 + .long 1070039492 + .long 1630447748 + .long 1021465882 + .long 1169236224 + .long 1070056160 + .long 2828355997 + .long 1020458120 + .long 3453997312 + .long 1070072833 + .long 164091641 + .long 1020388279 + .long 2708127744 + .long 1070089513 + .long 3036550223 + .long 1023328684 + .long 3540797696 + .long 1070106199 + .long 3710949463 + .long 1022568805 + .long 1972276736 + .long 1070122892 + .long 3885277950 + .long 1019761674 + .long 2613815552 + .long 1070139591 + .long 2764165077 + .long 1022921023 + .long 1487791616 + .long 1070156297 + .long 1330644769 + .long 1023162679 + .long 3207593472 + .long 1070173009 + .long 3911007221 + .long 1022993496 + .long 3797764608 + .long 1070189728 + .long 979712598 + .long 1022554580 + .long 3578920448 + .long 1070206454 + .long 2825738223 + .long 1020223708 + .long 2872795648 + .long 1070223187 + .long 392451124 + .long 1022666279 + .long 2002258432 + .long 1070239927 + .long 3730407632 + .long 1023148291 + .long 1291326464 + .long 1070256674 + .long 3723802980 + .long 1022514089 + .long 1065180928 + .long 1070273428 + .long 2635617463 + .long 1022654470 + .long 1650181632 + .long 1070290189 + .long 2061982883 + .long 1022853411 + .long 3373882880 + .long 1070306957 + .long 319732785 + .long 1022017175 + .long 2270081280 + .long 1070323733 + .long 2237757411 + .long 1023064087 + .long 2963732736 + .long 1070340516 + .long 468839165 + .long 1023293774 + .long 1491099904 + .long 1070357307 + .long 1502657946 + .long 1021533479 + .long 2479636480 + .long 1070374105 + .long 482913562 + .long 1021986286 + .long 1968133632 + .long 1070390911 + .long 3281474337 + .long 1022646400 + .long 291639040 + .long 1070407725 + .long 2453320259 + .long 1022812423 + .long 2081472512 + .long 1070424546 + .long 2939989570 + .long 1023091888 + .long 3380340480 + .long 1070441375 + .long 2850707499 + .long 1021921109 + .long 232287488 + .long 1070458213 + .long 3674625342 + .long 1020725130 + .long 1567614208 + .long 1070475058 + .long 9347334 + .long 1022024009 + .long 3433091072 + .long 1070491911 + .long 282524999 + .long 1021433523 + .long 1876877312 + .long 1070508773 + .long 3470449440 + .long 1019309721 + .long 1538472192 + .long 1070525643 + .long 2089486825 + .long 1019698916 + .long 2763830784 + .long 1070542521 + .long 443498115 + .long 1020505194 + .long 1605381632 + .long 1070559408 + .long 3018871601 + .long 1022869913 + .long 2706946048 + .long 1070576303 + .long 3936260892 + .long 1023175875 + .long 2123887360 + .long 1070593207 + .long 2994220655 + .long 1022825948 + .long 104015104 + .long 1070603108 + .long 335054493 + .long 1023441853 + .long 2904568832 + .long 1070615800 + .long 1451215633 + .long 1023853857 + .long 3456197120 + .long 1070632739 + .long 436334733 + .long 1024026432 + .long 252452352 + .long 1070649697 + .long 34596167 + .long 1024031396 + .long 3328018432 + .long 1070666672 + .long 2644547073 + .long 1024296758 + .long 1255829248 + .long 1070683667 + .long 552832586 + .long 1023763122 + .long 4097058560 + .long 1070700680 + .long 1955640623 + .long 1021394654 + .long 451770112 + .long 1070717714 + .long 3428903777 + .long 1022941142 + .long 408920832 + .long 1070734767 + .long 165503263 + .long 1023894958 + .long 1186960640 + .long 1070751840 + .long 435826450 + .long 1024026134 + .long 19078656 + .long 1070768934 + .long 1834169749 + .long 1022899284 + .long 2743490304 + .long 1070786048 + .long 494581074 + .long 1018818479 + .long 2328961024 + .long 1070803184 + .long 2987908834 + .long 1022581110 + .long 350011392 + .long 1070820342 + .long 240771184 + .long 1024143083 + .long 2692326912 + .long 1070837521 + .long 666056837 + .long 1022394776 + .long 2373274368 + .long 1070854723 + .long 2484337770 + .long 1024228156 + .long 1017131520 + .long 1070871948 + .long 3285648279 + .long 1024025789 + .long 265558272 + .long 1070889196 + .long 392241896 + .long 1024252809 + .long 1778008064 + .long 1070906467 + .long 1536107943 + .long 1023949300 + .long 2937184768 + .long 1070923762 + .long 3541062251 + .long 1019448646 + .long 1144442880 + .long 1070941082 + .long 3691683781 + .long 1022123948 + .long 2410165504 + .long 1070958426 + .long 1804181960 + .long 1023945221 + .long 4174350848 + .long 1070975795 + .long 2016094861 + .long 1021716585 + .long 3897012480 + .long 1070993190 + .long 175294410 + .long 1023703404 + .long 3353623040 + .long 1071010611 + .long 167973242 + .long 1023240839 + .long 45671168 + .long 1071028059 + .long 2166856113 + .long 1021565413 + .long 86063872 + .long 1071045533 + .long 2676254727 + .long 1023985299 + .long 1019772672 + .long 1071063034 + .long 989043593 + .long 1021549587 + .long 414297344 + .long 1071080563 + .long 3960972046 + .long 1024307251 + .long 155173120 + .long 1071098120 + .long 1830919291 + .long 1021592251 + .long 2151562240 + .long 1071115705 + .long 405408666 + .long 1023423128 + .long 4041854720 + .long 1071133319 + .long 2043497827 + .long 1024411503 + .long 3489224192 + .long 1071150963 + .long 3072215864 + .long 1022698635 + .long 2477196288 + .long 1071168637 + .long 1812195139 + .long 1022689192 + .long 3015298816 + .long 1071186341 + .long 764841969 + .long 1021027331 + .long 2844731136 + .long 1071204076 + .long 2878117321 + .long 1019116513 + .long 4028950528 + .long 1071221842 + .long 698911452 + .long 1023265602 + .long 69441536 + .long 1071239641 + .long 3253467847 + .long 1020795075 + .long 1676209920 + .long 1071257471 + .long 4272431167 + .long 1022873982 + .long 2408752384 + .long 1071275334 + .long 648519100 + .long 1024385717 + .long 151623680 + .long 1071293231 + .long 345257017 + .long 1019561408 + .long 1410154240 + .long 1071311161 + .long 197863993 + .long 1023224207 + .long 4131351552 + .long 1071329125 + .long 2620801789 + .long 1024411169 + .long 1999664384 + .long 1071347125 + .long 3952692616 + .long 1024168086 + .long 1617668864 + .long 1071365160 + .long 3019889809 + .long 1021907692 + .long 1032074240 + .long 1071383231 + .long 59469899 + .long 1023656194 + .long 2619492096 + .long 1071401338 + .long 1417526820 + .long 1021457783 + .long 202429440 + .long 1071419483 + .long 2927667935 + .long 1019175447 + .long 525044224 + .long 1071437665 + .long 38166811 + .long 1023981879 + .long 1779258880 + .long 1071455885 + .long 481252500 + .long 1023310234 + .long 2195673600 + .long 1071474144 + .long 3962395981 + .long 1021339088 + .long 44573696 + .long 1071492443 + .long 3936281395 + .long 1023014829 + .long 2226905344 + .long 1071510781 + .long 1515320476 + .long 1024320623 + .long 2800512512 + .long 1071529160 + .long 1225403697 + .long 1021081846 + .long 161113600 + .long 1071547581 + .long 3064809733 + .long 1024173917 + .long 1338410240 + .long 1071566043 + .long 2027604973 + .long 1024362526 + .long 522433280 + .long 1071584548 + .long 2055171723 + .long 1023858825 + .long 539595776 + .long 1071603096 + .long 3868820135 + .long 1022936424 + .long 4264017664 + .long 1071621687 + .long 3228065145 + .long 1023479578 + .long 1733924096 + .long 1071640324 + .long 3511934475 + .long 1022496355 + .long 108880384 + .long 1071651839 + .long 615880967 + .long 1023519706 + .long 3517856512 + .long 1071661202 + .long 3113108559 + .long 1025190289 + .long 4043153152 + .long 1071670589 + .long 1571836218 + .long 1023106116 + .long 3251299072 + .long 1071680000 + .long 3444076102 + .long 1022187841 + .long 2736921600 + .long 1071689435 + .long 272771483 + .long 1025095280 + .long 3897698560 + .long 1071703633 + .long 2075390188 + .long 1022489022 + .long 3209485056 + .long 1071722652 + .long 1438094065 + .long 1021844944 + .long 3781432064 + .long 1071741774 + .long 1675017145 + .long 1024143828 + .long 2684184064 + .long 1071761003 + .long 2259963753 + .long 1024731393 + .long 1840489728 + .long 1071780342 + .long 3372883597 + .long 1023431408 + .long 3764087808 + .long 1071799794 + .long 3307523102 + .long 1024485788 + .long 3006232320 + .long 1071819364 + .long 3088971966 + .long 1025213251 + .long 3374881280 + .long 1071839055 + .long 834437749 + .long 1025236452 + .long 797284864 + .long 1071858872 + .long 3122663941 + .long 1025320473 + .long 545765120 + .long 1071878818 + .long 826539625 + .long 1022450955 + .long 107562240 + .long 1071898898 + .long 339584600 + .long 1022481255 + .long 2123649024 + .long 1071919116 + .long 3912959833 + .long 1024321009 + .long 1562385664 + .long 1071939478 + .long 2846067230 + .long 1023343981 + .long 2963085824 + .long 1071959988 + .long 954548627 + .long 1021475211 + .long 3325550592 + .long 1071980652 + .long 3459651155 + .long 1025305573 + .long 775752448 + .long 1072001476 + .long 3582746667 + .long 1023859460 + .long 3238590720 + .long 1072022464 + .long 634636162 + .long 1024472353 + .long 2758801920 + .long 1072043624 + .long 3078216319 + .long 1025304516 + .long 1370319104 + .long 1072064962 + .long 2570569078 + .long 1025099442 + .long 2615805184 + .long 1072086484 + .long 3729933412 + .long 1024605112 + .long 3077336576 + .long 1072108198 + .long 1948916066 + .long 1024781603 + .long 1099528192 + .long 1072130112 + .long 3139143157 + .long 1023729360 + .long 1231903232 + .long 1072152233 + .long 1349513477 + .long 1024737515 + .long 1507504128 + .long 1072174570 + .long 3484516322 + .long 1024000959 + .long 2214659840 + .long 1072197132 + .long 2563820917 + .long 1025225535 + .long 1804739840 + .long 1072219929 + .long 760038746 + .long 1024482855 + .long 1413746688 + .long 1072242971 + .long 3401734714 + .long 1025129838 + .long 821409536 + .long 1072266269 + .long 3729772551 + .long 1025484796 + .long 3031825664 + .long 1072289834 + .long 122256749 + .long 1024752594 + .long 1710784256 + .long 1072313680 + .long 1518205483 + .long 1024724809 + .long 3025265152 + .long 1072337819 + .long 409951989 + .long 1022835555 + .long 287769088 + .long 1072362267 + .long 800355594 + .long 1022484850 + .long 198179840 + .long 1072387038 + .long 3502926213 + .long 1024209373 + .long 1909130496 + .long 1072412149 + .long 3064694319 + .long 1025380823 + .long 1941732096 + .long 1072437619 + .long 4112930390 + .long 1024294679 + .long 3492010496 + .long 1072463467 + .long 2684918107 + .long 1023220233 + .long 81959680 + .long 1072489716 + .long 220021366 + .long 1020635131 + .long 2297837056 + .long 1072516387 + .long 4027683826 + .long 1021041185 + .long 270404096 + .long 1072543508 + .long 2012766065 + .long 1021780753 + .long 3667376896 + .long 1072571105 + .long 2727981522 + .long 1023009874 + .long 330400256 + .long 1072599212 + .long 2940017003 + .long 1025393439 + .long 1119293952 + .long 1072627861 + .long 1608550416 + .long 1022675612 + .long 3536155904 + .long 1072657091 + .long 349665778 + .long 1025156751 + .long 3078046720 + .long 1072686946 + .long 2016159996 + .long 1022193169 + .long 455228416 + .long 1072705361 + .long 1908539328 + .long 1026126332 + .long 1871505664 + .long 1072720988 + .long 2784700894 + .long 1025922277 + .long 1630994432 + .long 1072737010 + .long 361107678 + .long 1022887244 + .long 2084558336 + .long 1072753462 + .type Tbl_addr,@object + .size Tbl_addr,3840 + .space 768, 0x00 # pad + .align 16 +SIGNMASK: + .long 0 + .long 2147483648 + .long 0 + .long 0 + .type SIGNMASK,@object + .size SIGNMASK,16 + .align 16 +HALFMASK2: + .long 0 + .long 2147483584 + .long 0 + .long 0 + .type HALFMASK2,@object + .size HALFMASK2,16 + .align 16 +PI_BY_2: + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1073291771 + .type PI_BY_2,@object + .size PI_BY_2,16 + .align 16 +cv2: + .long 780903145 + .long 1066854586 + .long 858993459 + .long 1068708659 + .long 3340530119 + .long 1067392113 + .long 1431655765 + .long 1069897045 + .long 1321528399 + .long 1066517740 + .long 3067833783 + .long 1067899757 + .long 2021159460 + .long 1065855096 + .long 2576980378 + .long 1066178969 + .type cv2,@object + .size cv2,64 + .align 16 +HALFMASK: + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .type HALFMASK,@object + .size HALFMASK,16 + .align 4 +ONEMASK: + .long 0 + .long 1072693248 + .type ONEMASK,@object + .size ONEMASK,8 + .align 4 +TMASK: + .long 0 + .long 4294950912 + .type TMASK,@object + .size TMASK,8 + .align 4 +cv: + .long 1431655765 + .long 1069897045 + .long 858993459 + .long 1068708659 + .long 3067833783 + .long 1067899757 + .type cv,@object + .size cv,24 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/asinf_gen.S b/external/sgx_libm/intel64/asinf_gen.S new file mode 100644 index 0000000000..3773399cbc --- /dev/null +++ b/external/sgx_libm/intel64/asinf_gen.S @@ -0,0 +1,394 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinf_gen.c" + .text +..TXTST0: +# -- Begin asinf + .text + .align 16,0x90 + .globl asinf +asinf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_asinf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -16(%rsp) + movl %edx, %eax + andl $2147483647, %eax + cmpl $1065353216, %eax + jae ..B1.14 +..B1.2: + pxor %xmm5, %xmm5 + cmpl $1056964608, %eax + cvtss2sd %xmm0, %xmm5 + jae ..B1.11 +..B1.3: + cmpl $947912704, %eax + jae ..B1.10 +..B1.4: + shrl $31, %edx + cmpl $8388608, %eax + jb ..B1.6 +..B1.5: + movl %edx, %edx + lea _small_value_32(%rip), %rax + movss (%rax,%rdx,4), %xmm1 + mulss .L_2il0floatpacket.26(%rip), %xmm1 + addss %xmm1, %xmm0 + ret +..B1.6: + testl %eax, %eax + je ..B1.9 +..B1.7: + lea _small_value_32(%rip), %rax + pxor %xmm2, %xmm2 + pxor %xmm1, %xmm1 + cvtss2sd -16(%rsp), %xmm2 + movss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.26(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm1 + addsd %xmm2, %xmm0 + movss %xmm1, -24(%rsp) + cvtsd2ss %xmm0, %xmm0 +..B1.9: + ret +..B1.10: + movaps %xmm5, %xmm1 + mulsd %xmm5, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.0(%rip), %xmm3 + movsd .L_2il0floatpacket.4(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.1(%rip), %xmm3 + addsd .L_2il0floatpacket.5(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.2(%rip), %xmm3 + addsd .L_2il0floatpacket.6(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.3(%rip), %xmm3 + addsd .L_2il0floatpacket.7(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm1, %xmm2 + pxor %xmm0, %xmm0 + addsd %xmm2, %xmm3 + mulsd %xmm5, %xmm3 + addsd %xmm3, %xmm5 + cvtsd2ss %xmm5, %xmm0 + ret +..B1.11: + cmpl $1061997772, %eax + jb ..B1.13 +..B1.12: + andps .L_2il0floatpacket.28(%rip), %xmm5 + pxor %xmm4, %xmm4 + movsd .L_2il0floatpacket.27(%rip), %xmm1 + testl %edx, %edx + movsd .L_2il0floatpacket.0(%rip), %xmm3 + subsd %xmm5, %xmm1 + mulsd .L_2il0floatpacket.22(%rip), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + sqrtsd %xmm1, %xmm4 + mulsd %xmm0, %xmm3 + movsd .L_2il0floatpacket.4(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.1(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.5(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.2(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.6(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.3(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.7(%rip), %xmm2 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm3 + mulsd %xmm4, %xmm3 + addsd %xmm3, %xmm4 + mulsd .L_2il0floatpacket.24(%rip), %xmm4 + addsd .L_2il0floatpacket.23(%rip), %xmm4 + movaps %xmm4, %xmm0 + xorps .L_2il0floatpacket.29(%rip), %xmm0 + jl ..L3 + movaps %xmm4, %xmm0 +..L3: + cvtsd2ss %xmm0, %xmm0 + ret +..B1.13: + movaps %xmm5, %xmm1 + mulsd %xmm5, %xmm1 + movsd .L_2il0floatpacket.9(%rip), %xmm4 + movsd .L_2il0floatpacket.15(%rip), %xmm3 + addsd .L_2il0floatpacket.8(%rip), %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.10(%rip), %xmm4 + addsd .L_2il0floatpacket.16(%rip), %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.11(%rip), %xmm4 + addsd .L_2il0floatpacket.17(%rip), %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.12(%rip), %xmm4 + addsd .L_2il0floatpacket.18(%rip), %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.13(%rip), %xmm4 + addsd .L_2il0floatpacket.19(%rip), %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.14(%rip), %xmm4 + addsd .L_2il0floatpacket.20(%rip), %xmm3 + mulsd %xmm1, %xmm4 + addsd %xmm3, %xmm4 + addsd .L_2il0floatpacket.21(%rip), %xmm4 + mulsd %xmm5, %xmm4 + addsd %xmm4, %xmm5 + cvtsd2ss %xmm5, %xmm5 + movaps %xmm5, %xmm0 + ret +..B1.14: + cmpl $2139095040, %eax + ja ..B1.18 +..B1.15: + cmpl $1065353216, %eax + jne ..B1.19 +..B1.16: + lea pi_2f(%rip), %rax + lea _small_value_32(%rip), %rcx + shrl $31, %edx + movss (%rax,%rdx,4), %xmm0 + subss (%rcx,%rdx,4), %xmm0 +..B1.17: + ret +..B1.18: + movss -16(%rsp), %xmm0 + ret +..B1.19: + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.25(%rip), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type asinf,@function + .size asinf,.-asinf + .data +# -- End asinf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.28: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.28,@object + .size .L_2il0floatpacket.28,16 + .align 16 +.L_2il0floatpacket.29: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.29,@object + .size .L_2il0floatpacket.29,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x32950b15,0x3fa10044 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x0f078e5a,0x3f9547bd + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x282596ea,0x3f9f2932 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x3b07aed0,0x3fb33334 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x15b528b3,0x3f5b565b + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x1acf0c57,0x3f965bd0 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x8a6efcbd,0x3fa6db1b + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x541021e2,0x3fc55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0xbfd00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x7c6f097b,0x4014f3d9 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x617c2eba,0x4018ed42 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0xb9e8c253,0x3fea66bf + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x7e9f31d2,0x3fb9a89d + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x74fb38bf,0x3fb8e90d + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0xe950ab19,0x3fcb8550 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 8 +.L_2il0floatpacket.15: + .long 0x8c8953a2,0xc0202794 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,8 + .align 8 +.L_2il0floatpacket.16: + .long 0x94b6927c,0xc0047249 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,8 + .align 8 +.L_2il0floatpacket.17: + .long 0x3a6dbb00,0xbfa654a1 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,8 + .align 8 +.L_2il0floatpacket.18: + .long 0x020f8f24,0x3fb60e1d + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,8 + .align 8 +.L_2il0floatpacket.19: + .long 0x726ca18f,0x3fbff1ac + .type .L_2il0floatpacket.19,@object + .size .L_2il0floatpacket.19,8 + .align 8 +.L_2il0floatpacket.20: + .long 0xc94e1724,0x3f352382 + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,8 + .align 8 +.L_2il0floatpacket.21: + .long 0x00000000,0x3fa80000 + .type .L_2il0floatpacket.21,@object + .size .L_2il0floatpacket.21,8 + .align 8 +.L_2il0floatpacket.22: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.22,@object + .size .L_2il0floatpacket.22,8 + .align 8 +.L_2il0floatpacket.23: + .long 0x54442d18,0x3ff921fb + .type .L_2il0floatpacket.23,@object + .size .L_2il0floatpacket.23,8 + .align 8 +.L_2il0floatpacket.24: + .long 0x00000000,0xc0000000 + .type .L_2il0floatpacket.24,@object + .size .L_2il0floatpacket.24,8 + .align 8 +.L_2il0floatpacket.27: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.27,@object + .size .L_2il0floatpacket.27,8 + .align 4 +.L_2il0floatpacket.25: + .long 0x7f800000 + .type .L_2il0floatpacket.25,@object + .size .L_2il0floatpacket.25,4 + .align 4 +.L_2il0floatpacket.26: + .long 0x0d800000 + .type .L_2il0floatpacket.26,@object + .size .L_2il0floatpacket.26,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +pi_2f: + .long 0x3fc90fdb + .long 0xbfc90fdb + .type pi_2f,@object + .size pi_2f,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/asinh_gen.S b/external/sgx_libm/intel64/asinh_gen.S new file mode 100644 index 0000000000..7356a28bb8 --- /dev/null +++ b/external/sgx_libm/intel64/asinh_gen.S @@ -0,0 +1,382 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinh_gen.c" + .text +..TXTST0: +# -- Begin asinh + .text + .align 16,0x90 + .globl asinh +asinh: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_asinh.1: +..L2: + + movsd %xmm0, -16(%rsp) + movl -12(%rsp), %esi + movl %esi, %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + jae ..B1.18 +..B1.2: + cmpl $1102053376, %edx + jae ..B1.16 +..B1.3: + cmpl $1074987008, %edx + jae ..B1.14 +..B1.4: + cmpl $1068498944, %edx + jae ..B1.13 +..B1.5: + cmpl $1012924416, %edx + jae ..B1.12 +..B1.6: + shrl $31, %esi + cmpl $1048576, %edx + jb ..B1.8 +..B1.7: + lea _SCALE(%rip), %rax + lea _MINNORM(%rip), %rdx + movl %esi, %esi + lea 8+_SCALE(%rip), %rcx + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + subsd (%rdx,%rsi,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.8: + movl -16(%rsp), %eax + orl %eax, %edx + je ..B1.10 +..B1.9: + lea _small_value_64(%rip), %rax + movsd -16(%rsp), %xmm0 + movsd (%rax,%rsi,8), %xmm1 + mulsd (%rax), %xmm1 + movsd %xmm1, -40(%rsp) + subsd %xmm1, %xmm0 + ret +..B1.10: + movsd -16(%rsp), %xmm0 +..B1.11: + ret +..B1.12: + movsd -16(%rsp), %xmm0 + lea 32+_PA(%rip), %rax + movaps %xmm0, %xmm4 + lea 24+_PA(%rip), %rcx + mulsd %xmm0, %xmm4 + lea 16+_PA(%rip), %rdx + movaps %xmm4, %xmm1 + lea 8+_PA(%rip), %rsi + mulsd %xmm4, %xmm1 + lea _PA(%rip), %rdi + movsd (%rax), %xmm3 + movsd (%rcx), %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm2 + addsd (%rdx), %xmm3 + addsd (%rsi), %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm4, %xmm2 + mulsd %xmm0, %xmm4 + addsd %xmm2, %xmm3 + addsd (%rdi), %xmm3 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm0 + ret +..B1.13: + movsd -16(%rsp), %xmm5 + xorl %eax, %eax + andps .L_2il0floatpacket.2(%rip), %xmm5 + movsd %xmm5, -16(%rsp) + movaps %xmm5, %xmm1 + movl %eax, -16(%rsp) + movsd -16(%rsp), %xmm9 + movaps %xmm9, %xmm7 + subsd %xmm9, %xmm1 + mulsd %xmm9, %xmm7 + addsd %xmm9, %xmm5 + movsd .L_2il0floatpacket.3(%rip), %xmm0 + mulsd %xmm1, %xmm5 + addsd %xmm0, %xmm7 + movaps %xmm7, %xmm2 + addsd %xmm5, %xmm2 + sqrtsd %xmm2, %xmm2 + movsd %xmm2, -24(%rsp) + movl %eax, -24(%rsp) + movsd -24(%rsp), %xmm8 + movaps %xmm8, %xmm3 + movaps %xmm8, %xmm4 + mulsd %xmm8, %xmm3 + subsd %xmm8, %xmm2 + addsd %xmm8, %xmm9 + mulsd %xmm2, %xmm4 + subsd %xmm3, %xmm7 + movaps %xmm8, %xmm6 + subsd %xmm4, %xmm7 + addsd %xmm2, %xmm6 + addsd %xmm5, %xmm7 + divsd %xmm6, %xmm7 + addsd %xmm7, %xmm2 + mulsd .L_2il0floatpacket.1(%rip), %xmm2 + addsd %xmm2, %xmm1 + jmp ..B1.15 +..B1.14: + movsd -16(%rsp), %xmm1 + andps .L_2il0floatpacket.2(%rip), %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + movsd .L_2il0floatpacket.3(%rip), %xmm0 + movaps %xmm0, %xmm4 + addsd %xmm0, %xmm2 + sqrtsd %xmm2, %xmm2 + movsd .L_2il0floatpacket.0(%rip), %xmm3 + addsd %xmm1, %xmm2 + mulsd %xmm3, %xmm1 + divsd %xmm2, %xmm4 + movsd %xmm1, -16(%rsp) + movl $0, -16(%rsp) + movsd -16(%rsp), %xmm9 + subsd %xmm9, %xmm1 + addsd %xmm4, %xmm1 +..B1.15: + movaps %xmm1, %xmm2 + movq $0x3ff0000000000000, %rax + addsd %xmm9, %xmm2 + movsd %xmm2, -16(%rsp) + movl $0, -16(%rsp) + movsd -16(%rsp), %xmm8 + movzwl -10(%rsp), %ecx + subsd %xmm8, %xmm9 + andl $32752, %ecx + addsd %xmm9, %xmm1 + shrl $4, %ecx + addl $-1023, %ecx + movslq %ecx, %rdx + negq %rdx + shlq $52, %rdx + addq %rax, %rdx + movq %rdx, -32(%rsp) + movsd -32(%rsp), %xmm3 + mulsd %xmm3, %xmm1 + mulsd %xmm3, %xmm8 + movaps %xmm1, %xmm4 + addsd %xmm8, %xmm4 + movsd %xmm4, -24(%rsp) + movl -20(%rsp), %edi + shrl $12, %edi + movzbl %dil, %edx + jmp ..B1.17 +..B1.16: + movsd -16(%rsp), %xmm0 + andps .L_2il0floatpacket.2(%rip), %xmm0 + movsd %xmm0, -16(%rsp) + movzwl -10(%rsp), %eax + movl %eax, %ecx + andl $-32753, %eax + andl $32752, %ecx + orl $-49168, %eax + movw %ax, -10(%rsp) + movsd -16(%rsp), %xmm1 + movl $0, -16(%rsp) + movl -12(%rsp), %edx + movsd -16(%rsp), %xmm8 + shrl $4, %ecx + subsd %xmm8, %xmm1 + shrl $12, %edx + addl $-1022, %ecx + movzbl %dl, %edx + movsd .L_2il0floatpacket.3(%rip), %xmm0 +..B1.17: + movq __libm_rcp_table_256@GOTPCREL(%rip), %rdi + pxor %xmm2, %xmm2 + lea 32+_PL(%rip), %r8 + lea 16+_PL(%rip), %r9 + lea 24+_PL(%rip), %r11 + lea _PL(%rip), %r10 + cvtss2sd (%rdi,%rdx,4), %xmm2 + mulsd %xmm2, %xmm8 + lea 8+_PL(%rip), %rdi + mulsd %xmm2, %xmm1 + subsd %xmm0, %xmm8 + movaps %xmm8, %xmm3 + movsd (%r8), %xmm5 + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm0 + mulsd %xmm3, %xmm0 + mulsd %xmm0, %xmm5 + movsd (%r11), %xmm4 + mulsd %xmm0, %xmm4 + addsd (%r9), %xmm5 + mulsd %xmm0, %xmm5 + addsd (%rdi), %xmm4 + mulsd %xmm0, %xmm4 + addsd (%r10), %xmm5 + mulsd %xmm0, %xmm5 + pxor %xmm0, %xmm0 + cvtsi2sd %ecx, %xmm0 + mulsd %xmm3, %xmm4 + lea _LN2(%rip), %rcx + addsd %xmm4, %xmm5 + movsd (%rcx), %xmm6 + lea 8+_LN2(%rip), %rcx + mulsd %xmm0, %xmm6 + addsd %xmm5, %xmm1 + movsd (%rcx), %xmm7 + mulsd %xmm7, %xmm0 + shlq $4, %rdx + movq __libm_log_table_256@GOTPCREL(%rip), %rax + shrl $31, %esi + addsd (%rax,%rdx), %xmm6 + addsd 8(%rax,%rdx), %xmm0 + addsd %xmm6, %xmm1 + addsd %xmm8, %xmm0 + lea ones(%rip), %rdx + movsd %xmm0, -16(%rsp) + movsd (%rdx,%rsi,8), %xmm8 + mulsd %xmm8, %xmm0 + mulsd %xmm8, %xmm1 + movsd %xmm8, -24(%rsp) + addsd %xmm1, %xmm0 + ret +..B1.18: + movsd -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type asinh,@function + .size asinh,.-asinh + .data +# -- End asinh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.2: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +_SCALE: + .long 0 + .long 1177550848 + .long 0 + .long 967835648 + .type _SCALE,@object + .size _SCALE,16 + .align 16 +_MINNORM: + .long 0 + .long 1048576 + .long 0 + .long 2148532224 + .type _MINNORM,@object + .size _MINNORM,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_PA: + .long 1431655746 + .long 3217380693 + .long 858875226 + .long 1068708659 + .long 2809361764 + .long 3215383405 + .long 1241898124 + .long 1067392054 + .long 966918340 + .long 3214324669 + .type _PA,@object + .size _PA,40 + .align 4 +_PL: + .long 0 + .long 3219128320 + .long 1431621855 + .long 1070945621 + .long 4294842013 + .long 3218079743 + .long 1289448124 + .long 1070176674 + .long 2077359316 + .long 3217380703 + .type _PL,@object + .size _PL,40 + .align 4 +_LN2: + .long 897137782 + .long 1038760431 + .long 4276092928 + .long 1072049730 + .type _LN2,@object + .size _LN2,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/asinhf_gen.S b/external/sgx_libm/intel64/asinhf_gen.S new file mode 100644 index 0000000000..9f16b5ca90 --- /dev/null +++ b/external/sgx_libm/intel64/asinhf_gen.S @@ -0,0 +1,295 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinhf_gen.c" + .text +..TXTST0: +# -- Begin asinhf + .text + .align 16,0x90 + .globl asinhf +asinhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_asinhf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + jge ..B1.15 +..B1.2: + cmpl $1056964608, %eax + jge ..B1.11 +..B1.3: + cmpl $838860800, %eax + jge ..B1.10 +..B1.4: + shrl $31, %edx + cmpl $8388608, %eax + jl ..B1.6 +..B1.5: + movss .L_2il0floatpacket.8(%rip), %xmm1 + lea _MINNORM(%rip), %rax + mulss %xmm1, %xmm0 + movl %edx, %edx + subss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.9(%rip), %xmm0 + ret +..B1.6: + testl %eax, %eax + je ..B1.8 +..B1.7: + lea _small_value_32(%rip), %rax + pxor %xmm2, %xmm2 + pxor %xmm1, %xmm1 + cvtss2sd -8(%rsp), %xmm2 + movss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.9(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm1 + subsd %xmm0, %xmm2 + pxor %xmm0, %xmm0 + movss %xmm1, -24(%rsp) + cvtsd2ss %xmm2, %xmm0 + ret +..B1.8: + movss -8(%rsp), %xmm0 +..B1.9: + ret +..B1.10: + pxor %xmm3, %xmm3 + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.0(%rip), %xmm4 + movsd .L_2il0floatpacket.4(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.1(%rip), %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.2(%rip), %xmm4 + addsd .L_2il0floatpacket.6(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.3(%rip), %xmm4 + addsd .L_2il0floatpacket.7(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + movsd %xmm3, -16(%rsp) + addsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm3, %xmm4 + cvtsd2ss %xmm4, %xmm4 + movaps %xmm4, %xmm0 + ret +..B1.11: + pxor %xmm1, %xmm1 + cmpl $1199570944, %eax + cvtss2sd -8(%rsp), %xmm1 + andps .L_2il0floatpacket.15(%rip), %xmm1 + jge ..B1.13 +..B1.12: + movaps %xmm1, %xmm0 + movl $-1023, %r8d + mulsd %xmm1, %xmm0 + addsd .L_2il0floatpacket.14(%rip), %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm0, %xmm1 + movsd %xmm1, -16(%rsp) + jmp ..B1.14 +..B1.13: + movsd %xmm1, -16(%rsp) + movl $-1022, %r8d +..B1.14: + movzwl -10(%rsp), %ecx + movl %ecx, %eax + andl $-32753, %ecx + pxor %xmm0, %xmm0 + orl $-49168, %ecx + andl $32752, %eax + movw %cx, -10(%rsp) + pxor %xmm1, %xmm1 + movq __libm_rcp_table_256@GOTPCREL(%rip), %rdi + movl -12(%rsp), %esi + andl $1048575, %esi + shrl $12, %esi + cvtss2sd (%rdi,%rsi,4), %xmm0 + mulsd -16(%rsp), %xmm0 + movsd .L_2il0floatpacket.11(%rip), %xmm2 + shrl $4, %eax + addsd .L_2il0floatpacket.10(%rip), %xmm0 + mulsd %xmm0, %xmm2 + addl %eax, %r8d + cvtsi2sd %r8d, %xmm1 + addsd .L_2il0floatpacket.12(%rip), %xmm2 + mulsd .L_2il0floatpacket.13(%rip), %xmm1 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm2 + testl $-2147483648, %edx + movq __libm_logf_table_256@GOTPCREL(%rip), %r9 + addsd %xmm0, %xmm2 + addsd (%r9,%rsi,8), %xmm1 + addsd %xmm1, %xmm2 + movaps %xmm2, %xmm0 + xorps .L_2il0floatpacket.16(%rip), %xmm0 + jne ..L3 + movaps %xmm2, %xmm0 +..L3: + cvtsd2ss %xmm0, %xmm0 + ret +..B1.15: + movss -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type asinhf,@function + .size asinhf,.-asinhf + .data +# -- End asinhf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.15: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.16: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,16 + .align 8 +.L_2il0floatpacket.0: + .long 0xd28ee596,0x3f73cb17 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x9b9f611c,0x3f91287a + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0xac0cf195,0x3f9f1aa4 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x1236cb49,0x3fb33333 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xd27f5e7d,0xbf874400 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x4197b1a0,0xbf96d307 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xdacdeace,0xbfa6db62 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x552ea1bd,0xbfc55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x6890dd10,0x3fd5555a + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0xe7362feb,0xbfe00001 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0xfefa39ef,0x3fe62e42 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 4 +.L_2il0floatpacket.8: + .long 0x71800000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .align 4 +.L_2il0floatpacket.9: + .long 0x0d800000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,4 + .align 4 +_MINNORM: + .long 8388608 + .long 2155872256 + .type _MINNORM,@object + .size _MINNORM,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/asinhl.S b/external/sgx_libm/intel64/asinhl.S new file mode 100644 index 0000000000..b1c8f734b1 --- /dev/null +++ b/external/sgx_libm/intel64/asinhl.S @@ -0,0 +1,1088 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinhl.c" + .text +..TXTST0: +# -- Begin asinhl + .text + .align 16,0x90 + .globl asinhl +asinhl: +# parameter 1: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_asinhl.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + xorb %cl, %cl +..B1.2: + fnstcw 50(%rsp) +..B1.3: + movzwl 72(%rsp), %esi + andl $32767, %esi + movzwl 50(%rsp), %eax + cmpl $32767, %esi + je ..B1.67 +..B1.4: + cmpl $16382, %esi + jge ..B1.46 +..B1.5: + cmpl $16376, %esi + jge ..B1.39 +..B1.6: + cmpl $16371, %esi + jge ..B1.32 +..B1.7: + cmpl $16365, %esi + jge ..B1.25 +..B1.8: + cmpl $16308, %esi + jge ..B1.18 +..B1.9: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.13 +..B1.10: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.11: + fldcw 48(%rsp) +..B1.12: + movzwl 72(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.13: + testl %esi, %esi + jle ..B1.63 +..B1.14: + fldt 64(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rdx + fldl (%rax) + fmul %st(1), %st + fsubp %st, %st(1) + fmull (%rdx) + fstpt (%rsp) +..B1.15: + testb %cl, %cl + je ..B1.17 +..B1.16: + fldcw 50(%rsp) +..B1.17: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.18: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.22 +..B1.19: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.20: + fldcw 48(%rsp) +..B1.21: + movb $1, %cl +..B1.22: + fldt 64(%rsp) + lea _Q3(%rip), %rax + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 50(%rsp) +..B1.24: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.25: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.29 +..B1.26: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.27: + fldcw 48(%rsp) +..B1.28: + movb $1, %cl +..B1.29: + fldt 64(%rsp) + lea 16+_Q2(%rip), %rax + fld %st(0) + lea _Q2(%rip), %rdx + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.31 +..B1.30: + fldcw 50(%rsp) +..B1.31: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.32: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.36 +..B1.33: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.34: + fldcw 48(%rsp) +..B1.35: + movb $1, %cl +..B1.36: + fldt 64(%rsp) + lea 48+_Q1(%rip), %rax + fld %st(0) + lea 32+_Q1(%rip), %rsi + fmul %st(1), %st + lea 16+_Q1(%rip), %rdx + fld %st(0) + lea _Q1(%rip), %rdi + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.38 +..B1.37: + fldcw 50(%rsp) +..B1.38: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.39: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.43 +..B1.40: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.41: + fldcw 48(%rsp) +..B1.42: + movb $1, %cl +..B1.43: + fldt 64(%rsp) + lea _TWO_53H(%rip), %rax + fld %st(0) + fld %st(1) + lea 304+_Q(%rip), %rdx + lea 272+_Q(%rip), %rsi + lea 240+_Q(%rip), %rdi + lea 208+_Q(%rip), %r8 + fldl (%rax) + lea 176+_Q(%rip), %r9 + fmul %st(3), %st + lea 144+_Q(%rip), %r10 + lea 112+_Q(%rip), %r11 + lea 80+_Q(%rip), %rax + testb %cl, %cl + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + fmul %st(0), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fadd %st, %st(2) + fld %st(2) + fmul %st(2), %st + fxch %st(4) + fstpt 16(%rsp) + fld %st(1) + fmul %st(1), %st + faddp %st, %st(4) + fld %st(3) + fxch %st(1) + fmul %st(0), %st + fadd %st, %st(1) + fldt (%rdx) + fmul %st(2), %st + lea 48+_Q(%rip), %rdx + fldt (%rsi) + lea 16+_Q(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 288+_Q(%rip), %rdi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + lea 256+_Q(%rip), %r8 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + lea 224+_Q(%rip), %r9 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + lea 192+_Q(%rip), %r10 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + lea 160+_Q(%rip), %r11 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_Q(%rip), %rax + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 96+_Q(%rip), %rdx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 64+_Q(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 32+_Q(%rip), %rdi + fmul %st(3), %st + fldt (%r8) + lea _Q(%rip), %r8 + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r9) + lea 336+_Q(%rip), %r9 + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r10) + lea 320+_Q(%rip), %r10 + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r11) + lea _TWO_48H(%rip), %r11 + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%r8) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt (%r9) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fmulp %st, %st(3) + fldt (%r10) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 32(%rsp) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + fld %st(0) + fldl (%r11) + fld %st(0) + fadd %st(5), %st + fsubp %st, %st(1) + fmul %st, %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fldt 64(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt (%rsp) + fmul %st, %st(2) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.45 +..B1.44: + fldcw 50(%rsp) +..B1.45: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.46: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.50 +..B1.47: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.48: + fldcw 48(%rsp) +..B1.49: + movb $1, %cl +..B1.50: + fldt 64(%rsp) + lea ones(%rip), %rdx + movb 73(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %esi + fldl (%rdx,%rsi,8) + fmul %st, %st(1) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + movzwl 72(%rsp), %eax + movl %eax, %edx + andl $32767, %edx + cmpl $16421, %edx + jge ..B1.59 +..B1.51: + cmpl $16388, %edx + jge ..B1.53 +..B1.52: + lea _TWO_52H(%rip), %rax + fld %st(0) + fld %st(1) + fldl (%rax) + fld %st(0) + fxch %st(1) + fadd %st, %st(3) + fsubr %st, %st(3) + fld %st(3) + fld %st(4) + fmul %st(5), %st + fxch %st(4) + fsub %st(5), %st + fmul %st, %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fsqrt + fadd %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fsubrp %st, %st(4) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fdivrp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + fxch %st(1) + jmp ..B1.58 +..B1.53: + fldt .L_2il0floatpacket.2(%rip) + lea _TWO_32H(%rip), %rax + fmul %st(1), %st + cmpl $16394, %edx + fld %st(0) + fldl (%rax) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubr %st(1), %st + fldt .L_2il0floatpacket.0(%rip) + jge ..B1.55 +..B1.54: + fstp %st(2) + fld %st(2) + fmul %st(3), %st + fadd %st(2), %st + fsqrt + faddp %st, %st(3) + fxch %st(1) + fdiv %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + jmp ..B1.58 +..B1.55: + fstp %st(3) + cmpl $16401, %edx + jge ..B1.57 +..B1.56: + fld %st(2) + fdiv %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fdivr %st(2), %st + faddp %st, %st(1) + jmp ..B1.58 +..B1.57: + fxch %st(1) + fdivr %st(2), %st + faddp %st, %st(1) +..B1.58: + fldt 16(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 64(%rsp) + movzwl 72(%rsp), %edx + andl $32767, %edx + movl %edx, %eax + addl $-16383, %edx + negl %eax + fxch %st(2) + fstpt (%rsp) + addl $-2, %eax + movzwl 8(%rsp), %esi + andl $32767, %eax + andl $-32768, %esi + orl %eax, %esi + movw %si, 8(%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 16(%rsp) + fmulp %st, %st(1) + jmp ..B1.60 +..B1.59: + fstp %st(0) + andl $-32768, %eax + addl $-16382, %edx + orl $-49153, %eax + movw %ax, 72(%rsp) + lea _TWO_52H(%rip), %rax + fldt 64(%rsp) + fld %st(0) + fldl (%rax) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) +..B1.60: + fldt 16(%rsp) + lea 48+_P(%rip), %r8 + fldt .L_2il0floatpacket.3(%rip) + lea 16+_P(%rip), %r9 + movl 68(%rsp), %esi + lea 64+_P(%rip), %r10 + shrl $23, %esi + lea 32+_P(%rip), %r11 + fldt (%r8) + movzbl %sil, %eax + movq __libm_rcp_table_256@GOTPCREL(%rip), %rdi + movl %edx, (%rsp) + lea 80+_P(%rip), %rdx + movq __libm_logl_table_256@GOTPCREL(%rip), %rsi + flds (%rdi,%rax,4) + fmul %st, %st(3) + shlq $4, %rax + fxch %st(2) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(1) + fld %st(1) + testb %cl, %cl + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fildl (%rsp) + fldt (%rdx) + lea _P(%rip), %rdx + fmul %st(3), %st + faddp %st, %st(6) + fxch %st(2) + fmul %st, %st(5) + fldt (%r9) + faddp %st, %st(6) + fmul %st, %st(5) + fxch %st(1) + fmulp %st, %st(5) + fldt (%r10) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fldt .L_2il0floatpacket.4(%rip) + fmul %st(3), %st + fldt .L_2il0floatpacket.5(%rip) + fmulp %st, %st(4) + faddl 8(%rsi,%rax) + faddp %st, %st(1) + fxch %st(2) + faddl (%rax,%rsi) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%rsp) + je ..B1.62 +..B1.61: + fldcw 50(%rsp) +..B1.62: + fldt 16(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.63: + cmpl $0, 68(%rsp) + jne ..B1.65 +..B1.64: + cmpl $0, 64(%rsp) + je ..B1.66 +..B1.65: + fldt 64(%rsp) + lea _small_value_80(%rip), %rsi + movb 73(%rsp), %al + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %edx + shlq $4, %rdx + fldt (%rsi,%rdx) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.66: + fldt 64(%rsp) + fstpt (%rsp) + jmp ..B1.15 +..B1.67: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.73 +..B1.68: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.69: + fldcw 48(%rsp) +..B1.70: + fldt 64(%rsp) + fstpt (%rsp) +..B1.71: + fldcw 50(%rsp) +..B1.72: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.73: + fldt 64(%rsp) + fstpt (%rsp) + jmp ..B1.72 + .align 16,0x90 + .cfi_endproc + .type asinhl,@function + .size asinhl,.-asinhl + .data +# -- End asinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_Q3: + .word 6991 + .word 42216 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 33268 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 9764 + .word 39322 + .word 39161 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 43682 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 14144 + .word 39303 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 10686 + .word 40209 + .word 28068 + .word 46811 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 6376 + .word 25459 + .word 13370 + .word 63707 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 42228 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 4505 + .word 52442 + .word 52428 + .word 52428 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 31967 + .word 56173 + .word 28086 + .word 46811 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 26124 + .word 58234 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 22137 + .word 23222 + .word 53620 + .word 46917 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 45395 + .word 61656 + .word 25205 + .word 36391 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 28077 + .word 15147 + .word 52421 + .word 58572 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 19650 + .word 2873 + .word 50009 + .word 48451 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 47538 + .word 64725 + .word 9133 + .word 40943 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 42460 + .word 64288 + .word 29314 + .word 35191 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 54924 + .word 18085 + .word 19628 + .word 61339 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 8359 + .word 63244 + .word 48955 + .word 54066 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 13301 + .word 22367 + .word 28967 + .word 48066 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 47487 + .word 41074 + .word 54143 + .word 42870 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 18176 + .word 28317 + .word 25378 + .word 37849 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 2947 + .word 59345 + .word 39582 + .word 64148 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 7071 + .word 46945 + .word 60101 + .word 49232 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 33184 + .word 23492 + .word 18153 + .word 62298 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 44779 + .word 60944 + .word 30881 + .word 55868 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 22870 + .word 51718 + .word 28591 + .word 51709 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,352 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,96 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/asinl.S b/external/sgx_libm/intel64/asinl.S new file mode 100644 index 0000000000..36b558921e --- /dev/null +++ b/external/sgx_libm/intel64/asinl.S @@ -0,0 +1,1320 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "asinl.c" + .text +..TXTST0: +# -- Begin asinl + .text + .align 16,0x90 + .globl asinl +asinl: +# parameter 1: 112 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_asinl.1: +..L2: + + subq $104, %rsp + .cfi_def_cfa_offset 112 + xorb %dl, %dl +..B1.2: + fnstcw 90(%rsp) +..B1.3: + movb 121(%rsp), %dil + movzwl 120(%rsp), %esi + andb $-128, %dil + andl $32767, %esi + shrb $7, %dil + movzwl 90(%rsp), %eax + cmpl $16383, %esi + jge ..B1.59 +..B1.4: + cmpl $16382, %esi + jge ..B1.49 +..B1.5: + cmpl $16376, %esi + jge ..B1.39 +..B1.6: + cmpl $16371, %esi + jge ..B1.32 +..B1.7: + cmpl $16365, %esi + jge ..B1.25 +..B1.8: + cmpl $16308, %esi + jge ..B1.18 +..B1.9: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.13 +..B1.10: + orl $-64768, %eax + movw %ax, 88(%rsp) +..B1.11: + fldcw 88(%rsp) +..B1.12: + movzwl 120(%rsp), %esi + movb $1, %dl + andl $32767, %esi +..B1.13: + testl %esi, %esi + jle ..B1.75 +..B1.14: + fldt 112(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rcx + fldl (%rax) + fmul %st(1), %st + faddp %st, %st(1) + fmull (%rcx) + fstpt (%rsp) +..B1.15: + testb %dl, %dl + je ..B1.17 +..B1.16: + fldcw 90(%rsp) +..B1.17: + fldt (%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.18: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.22 +..B1.19: + orl $-64768, %eax + movw %ax, 88(%rsp) +..B1.20: + fldcw 88(%rsp) +..B1.21: + movb $1, %dl +..B1.22: + fldt 112(%rsp) + lea _P4(%rip), %rax + testb %dl, %dl + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 90(%rsp) +..B1.24: + fldt (%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.25: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.29 +..B1.26: + orl $-64768, %eax + movw %ax, 88(%rsp) +..B1.27: + fldcw 88(%rsp) +..B1.28: + movb $1, %dl +..B1.29: + fldt 112(%rsp) + lea 16+_P3(%rip), %rax + fld %st(0) + lea _P3(%rip), %rcx + fmul %st(1), %st + testb %dl, %dl + fldt (%rax) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.31 +..B1.30: + fldcw 90(%rsp) +..B1.31: + fldt (%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.32: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.36 +..B1.33: + orl $-64768, %eax + movw %ax, 88(%rsp) +..B1.34: + fldcw 88(%rsp) +..B1.35: + movb $1, %dl +..B1.36: + fldt 112(%rsp) + lea 48+_P2(%rip), %rax + fld %st(0) + lea 32+_P2(%rip), %rsi + fmul %st(1), %st + lea 16+_P2(%rip), %rcx + fld %st(0) + lea _P2(%rip), %rdi + fmul %st(1), %st + testb %dl, %dl + fldt (%rax) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.38 +..B1.37: + fldcw 90(%rsp) +..B1.38: + fldt (%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.39: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.43 +..B1.40: + orl $-64768, %eax + movw %ax, 88(%rsp) +..B1.41: + fldcw 88(%rsp) +..B1.42: + movzwl 120(%rsp), %esi + movb $1, %dl + andl $32767, %esi +..B1.43: + fldt 112(%rsp) + lea _TWO_52H(%rip), %rax + fld %st(0) + cmpl $16381, %esi + fldl (%rax) + fmul %st, %st(1) + fld %st(1) + fadd %st(3), %st + fsubp %st, %st(2) + fld %st(1) + fxch %st(1) + fstpt 16(%rsp) + fld %st(1) + fsubr %st(3), %st + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fld %st(0) + fadd %st(3), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fld %st(1) + fmul %st(4), %st + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + fld %st(2) + fmul %st(3), %st + fld %st(0) + faddp %st, %st(2) + jge ..B1.45 +..B1.44: + fstp %st(0) + lea 176+_P1(%rip), %rax + lea 144+_P1(%rip), %rcx + lea 112+_P1(%rip), %rsi + lea 80+_P1(%rip), %rdi + lea 160+_P1(%rip), %r10 + lea 48+_P1(%rip), %r8 + lea 128+_P1(%rip), %r11 + lea 16+_P1(%rip), %r9 + fldt (%rax) + lea 96+_P1(%rip), %rax + fmul %st(1), %st + fldt (%rcx) + lea 64+_P1(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + lea 32+_P1(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea _P1(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea 192+_P1(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fldt 48(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt (%rsp) + fldt (%r8) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + jmp ..B1.46 +..B1.45: + lea 272+_P(%rip), %rax + lea 240+_P(%rip), %rcx + lea 208+_P(%rip), %rsi + lea 176+_P(%rip), %rdi + lea 144+_P(%rip), %r8 + lea 112+_P(%rip), %r9 + lea 80+_P(%rip), %r10 + lea 48+_P(%rip), %r11 + fldt (%rax) + lea 16+_P(%rip), %rax + fmul %st(2), %st + fldt (%rcx) + lea 256+_P(%rip), %rcx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 224+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 192+_P(%rip), %rdi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + lea 160+_P(%rip), %r8 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + lea 128+_P(%rip), %r9 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + lea 96+_P(%rip), %r10 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + lea 64+_P(%rip), %r11 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + lea 32+_P(%rip), %rax + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + lea _P(%rip), %rcx + fmul %st(3), %st + fldt (%rsi) + lea 304+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + lea 288+_P(%rip), %rdi + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%rcx) + faddp %st, %st(3) + fldt 48(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 32(%rsp) + fldt (%rsp) + fldt (%rsi) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rdi) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fld %st(1) + fxch %st(5) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + fmul %st(1), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fsub %st(3), %st + faddp %st, %st(1) +..B1.46: + fldt 64(%rsp) + fld %st(2) + fmul %st(4), %st + testb %dl, %dl + fxch %st(5) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 64(%rsp) + je ..B1.48 +..B1.47: + fldcw 90(%rsp) +..B1.48: + fldt 64(%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.49: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.53 +..B1.50: + orl $-64768, %eax + movw %ax, 88(%rsp) +..B1.51: + fldcw 88(%rsp) +..B1.52: + movb $1, %dl +..B1.53: + fldt 112(%rsp) + lea _ones(%rip), %rcx + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_32H(%rip), %rsi + movzbl %dil, %eax + lea _TWO_52H(%rip), %rdi + fldl (%rsi) + fldl (%rcx,%rax,8) + fmul %st, %st(3) + fstpl 80(%rsp) + fxch %st(2) + fsubrl (%rcx) + fmul %st(1), %st + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fxch %st(1) + fsub %st(3), %st + fadd %st, %st(1) + fxch %st(1) + fsqrt + fldl (%rdi) + fstpt 32(%rsp) + fldt 32(%rsp) + fmul %st(1), %st + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fsubr %st, %st(5) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fsubrp %st, %st(6) + fxch %st(3) + faddp %st, %st(5) + fld %st(0) + fadd %st(2), %st + fdivrp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fmulp %st, %st(2) + fld %st(1) + fld %st(3) + fadd %st(3), %st + fmul %st, %st(1) + fld %st(4) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(2) + fadd %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fld %st(2) + fmul %st(3), %st + fld %st(0) + faddp %st, %st(2) + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + fstpt 112(%rsp) + fldt 112(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fcomip %st(1), %st + fstp %st(0) + jbe ..B1.55 +..B1.54: + fstp %st(1) + lea 176+_P1(%rip), %rax + lea 144+_P1(%rip), %rcx + lea 112+_P1(%rip), %rsi + lea 80+_P1(%rip), %rdi + lea 160+_P1(%rip), %r10 + lea 48+_P1(%rip), %r8 + lea 128+_P1(%rip), %r11 + lea 16+_P1(%rip), %r9 + fldt (%rax) + lea 96+_P1(%rip), %rax + fmul %st(1), %st + fldt (%rcx) + lea 64+_P1(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + lea 32+_P1(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea _P1(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea 192+_P1(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fldt 64(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 16(%rsp) + fldt (%r8) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(2) + fxch %st(1) + jmp ..B1.56 +..B1.55: + lea 272+_P(%rip), %rax + lea 240+_P(%rip), %rcx + lea 208+_P(%rip), %rsi + lea 176+_P(%rip), %rdi + lea 144+_P(%rip), %r8 + lea 112+_P(%rip), %r9 + lea 80+_P(%rip), %r10 + lea 48+_P(%rip), %r11 + fldt (%rax) + lea 16+_P(%rip), %rax + fmul %st(1), %st + fldt (%rcx) + lea 256+_P(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + lea 224+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea 192+_P(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea 160+_P(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + lea 128+_P(%rip), %r9 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + lea 96+_P(%rip), %r10 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + lea 64+_P(%rip), %r11 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + lea 32+_P(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea _P(%rip), %rcx + fmul %st(2), %st + fldt (%rsi) + lea 304+_P(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 288+_P(%rip), %rdi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rcx) + faddp %st, %st(2) + fldt 64(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 48(%rsp) + fldt 16(%rsp) + fldt (%rsi) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(3) + fldt (%rdi) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fldt 32(%rsp) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) +..B1.56: + fldt (%rsp) + lea _pi_02(%rip), %rax + fmulp %st, %st(2) + fld %st(2) + fmul %st(1), %st + lea 16+_pi_02(%rip), %rcx + testb %dl, %dl + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st(2), %st + faddp %st, %st(2) + fldt .L_2il0floatpacket.2(%rip) + fmul %st, %st(1) + fmulp %st, %st(2) + fldt (%rax) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fmull 80(%rsp) + fstpt 16(%rsp) + je ..B1.58 +..B1.57: + fldcw 90(%rsp) +..B1.58: + fldt 16(%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.59: + movl %eax, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.63 +..B1.60: + orl $-64768, %eax + movw %ax, 88(%rsp) +..B1.61: + fldcw 88(%rsp) +..B1.62: + movzwl 120(%rsp), %esi + movb $1, %dl + andl $32767, %esi +..B1.63: + cmpl $32767, %esi + jne ..B1.67 +..B1.64: + cmpl $-2147483648, 116(%rsp) + jne ..B1.66 +..B1.65: + cmpl $0, 112(%rsp) + je ..B1.71 +..B1.66: + fldt 112(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) + jmp ..B1.72 +..B1.67: + cmpl $16383, %esi + jne ..B1.71 +..B1.68: + cmpl $-2147483648, 116(%rsp) + jne ..B1.71 +..B1.69: + cmpl $0, 112(%rsp) + jne ..B1.71 +..B1.70: + movzbl %dil, %ecx + lea _pi_2l(%rip), %rax + shlq $4, %rcx + lea _small_value_80(%rip), %rsi + fldt (%rcx,%rax) + fldt (%rcx,%rsi) + faddp %st, %st(1) + fstpt 8(%rsp) + jmp ..B1.72 +..B1.71: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 8(%rsp) +..B1.72: + testb %dl, %dl + je ..B1.74 +..B1.73: + fldcw 90(%rsp) +..B1.74: + fldt 8(%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.75: + cmpl $0, 116(%rsp) + jne ..B1.77 +..B1.76: + cmpl $0, 112(%rsp) + je ..B1.78 +..B1.77: + fldt 112(%rsp) + lea _small_value_80(%rip), %rcx + movzbl %dil, %eax + shlq $4, %rax + fldt (%rcx) + fldt (%rcx,%rax) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.78: + fldt 112(%rsp) + fstpt (%rsp) + jmp ..B1.15 + .align 16,0x90 + .cfi_endproc + .type asinl,@function + .size asinl,.-asinl + .data +# -- End asinl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_P4: + .word 43691 + .word 44938 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P4,@object + .size _P4,16 + .align 2 +_P3: + .word 36763 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 40704 + .word 58046 + .word 39460 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _P3,@object + .size _P3,32 + .align 2 +_P2: + .word 43688 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 20771 + .word 39331 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 23807 + .word 53798 + .word 28073 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 35198 + .word 7516 + .word 54204 + .word 63722 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _P2,@object + .size _P2,64 + .align 2 +_P1: + .word 43589 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 39364 + .word 39321 + .word 39321 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 17602 + .word 56173 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 47501 + .word 58414 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 27078 + .word 6583 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 39781 + .word 21053 + .word 25224 + .word 36391 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 46568 + .word 6235 + .word 50749 + .word 58572 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 41318 + .word 51558 + .word 37628 + .word 48452 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 55026 + .word 7893 + .word 43866 + .word 40925 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 43387 + .word 19951 + .word 2911 + .word 35445 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 32572 + .word 59281 + .word 11243 + .word 56666 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 49800 + .word 50337 + .word 42707 + .word 39184 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,208 + .align 2 +_P: + .word 42691 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 4317 + .word 52400 + .word 52428 + .word 52428 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 26206 + .word 56172 + .word 28086 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 36130 + .word 58514 + .word 36408 + .word 63715 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 21592 + .word 8113 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 3093 + .word 49950 + .word 25215 + .word 36391 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 21499 + .word 24428 + .word 51889 + .word 58572 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 54828 + .word 41264 + .word 61120 + .word 48451 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 10243 + .word 1489 + .word 39717 + .word 40940 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 51433 + .word 46039 + .word 63564 + .word 35220 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 60402 + .word 39286 + .word 25675 + .word 60826 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 34219 + .word 36833 + .word 44839 + .word 57547 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 13013 + .word 26091 + .word 19721 + .word 60832 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 22353 + .word 41544 + .word 55443 + .word 55735 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 14948 + .word 7038 + .word 38091 + .word 38339 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 61727 + .word 61480 + .word 15906 + .word 51927 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 13386 + .word 23084 + .word 64443 + .word 55906 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 17499 + .word 23573 + .word 43947 + .word 42761 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39328 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,320 + .align 2 +_pi_02: + .word 0 + .word 0 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 35374 + .word 4889 + .word 2259 + .word 34211 + .word 16349 + .word 0 + .word 0 + .word 0 + .type _pi_02,@object + .size _pi_02,32 + .align 2 +_pi_2l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _pi_2l,@object + .size _pi_2l,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atan2.S b/external/sgx_libm/intel64/atan2.S new file mode 100644 index 0000000000..023bababa2 --- /dev/null +++ b/external/sgx_libm/intel64/atan2.S @@ -0,0 +1,1197 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2.c" + .text +..TXTST0: +# -- Begin atan2 + .text + .align 16,0x90 + .globl atan2 +atan2: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_atan2.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) + movsd %xmm1, 8(%rsp) +..B1.2: + pextrw $3, %xmm0, %eax + andl $32752, %eax + subl $14448, %eax + cmpl $3840, %eax + ja .L_2TAG_PACKET_0.0.2 + pextrw $3, %xmm1, %eax + andl $32752, %eax + subl $14448, %eax + cmpl $3840, %eax + ja .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + unpcklpd %xmm1, %xmm0 + xorpd %xmm5, %xmm5 + xorpd %xmm3, %xmm3 + movl $2048, %eax + pinsrw $3, %eax, %xmm5 + paddw %xmm1, %xmm5 + psrlq $29, %xmm5 + rcpss %xmm5, %xmm3 + xorpd %xmm4, %xmm4 + movl $14336, %ecx + pinsrw $3, %ecx, %xmm4 + psllq $29, %xmm3 + paddw %xmm4, %xmm3 + mulsd %xmm0, %xmm3 + xorpd %xmm2, %xmm2 + xorpd %xmm6, %xmm6 + xorpd %xmm7, %xmm7 + movl $32768, %eax + pinsrw $2, %eax, %xmm6 + movl $32767, %ecx + pinsrw $3, %ecx, %xmm7 + paddd %xmm6, %xmm3 + andpd %xmm7, %xmm3 + movq %xmm3, %xmm5 + pextrw $3, %xmm3, %eax + movl $16448, %ecx + pinsrw $3, %ecx, %xmm2 + minsd %xmm2, %xmm3 + movmskpd %xmm0, %edx + psllq $1, %xmm0 + psrlq $1, %xmm0 + cmpsd $2, %xmm2, %xmm5 + psllq $1, %xmm1 + psrlq $1, %xmm1 + movq %xmm1, %xmm6 + movq %xmm1, %xmm7 + movq %xmm0, %xmm2 + movl $0, %ecx + pinsrw $0, %ecx, %xmm6 + subsd %xmm6, %xmm7 + movq %xmm0, %xmm4 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm4 + mulsd %xmm3, %xmm7 + andpd %xmm5, %xmm0 + subsd %xmm6, %xmm0 + andpd %xmm5, %xmm1 + addsd %xmm1, %xmm4 + subsd %xmm7, %xmm0 + andl $32752, %eax + subl $16286, %eax + cmpl $1121, %eax + ja .L_2TAG_PACKET_3.0.2 + divsd %xmm4, %xmm0 + pextrw $3, %xmm3, %ecx + movsd a2(%rip), %xmm2 + movsd b2(%rip), %xmm3 + pextrw $0, %xmm5, %eax + addl %edx, %edx + lea P_TBL(%rip), %r8 + movapd (%r8,%rdx,8), %xmm6 + lea SGN_TBL(%rip), %r8 + movapd (%r8,%rdx,8), %xmm1 + subl $16286, %ecx + notl %eax + andl $1, %eax + addl %eax, %ecx + addl %ecx, %ecx + lea ATAN_TBL(%rip), %r8 + movapd (%r8,%rcx,8), %xmm5 + xorpd %xmm1, %xmm5 + addpd %xmm6, %xmm5 + movq %xmm5, %xmm6 + unpckhpd %xmm5, %xmm5 + xorpd %xmm0, %xmm1 + movq %xmm1, %xmm4 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm2 + addsd %xmm0, %xmm3 + addsd %xmm6, %xmm1 + subsd %xmm1, %xmm6 + addsd %xmm4, %xmm6 + addsd 8+a2(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm4, %xmm0 + addsd %xmm5, %xmm6 + mulsd %xmm2, %xmm0 + addsd 8+b2(%rip), %xmm3 + mulsd %xmm3, %xmm0 + addsd %xmm6, %xmm0 + addsd %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_3.0.2: + addl $942, %eax + cmpl $942, %eax + ja .L_2TAG_PACKET_4.0.2 + xorpd %xmm4, %xmm4 + movl $16368, %ecx + pinsrw $3, %ecx, %xmm4 + divsd %xmm1, %xmm4 + addl %edx, %edx + lea SGN_TBL(%rip), %r8 + movapd (%r8,%rdx,8), %xmm6 + unpcklpd %xmm3, %xmm3 + xorpd %xmm6, %xmm0 + xorpd %xmm6, %xmm2 + xorpd %xmm6, %xmm3 + lea P_TBL2(%rip), %r8 + movapd (%r8,%rdx,8), %xmm7 + movsd a2(%rip), %xmm1 + movsd b2(%rip), %xmm5 + lea SELECT_B(%rip), %r8 + andpd (%r8,%rdx,8), %xmm3 + mulsd %xmm4, %xmm2 + mulsd %xmm4, %xmm0 + movq %xmm2, %xmm6 + mulsd %xmm2, %xmm2 + mulsd %xmm2, %xmm1 + addsd %xmm2, %xmm5 + mulsd %xmm2, %xmm6 + addsd 8+a2(%rip), %xmm1 + mulsd %xmm2, %xmm5 + addsd %xmm0, %xmm7 + addpd %xmm3, %xmm7 + mulsd %xmm6, %xmm1 + addsd 8+b2(%rip), %xmm5 + mulsd %xmm1, %xmm5 + addsd %xmm7, %xmm5 + pshufd $238, %xmm7, %xmm0 + addsd %xmm5, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_4.0.2: + movsd 8(%rsp), %xmm1 + movsd (%rsp), %xmm0 + pextrw $3, %xmm1, %eax + andl $32752, %eax + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl %eax, %ecx + jg .L_2TAG_PACKET_5.0.2 + pextrw $3, %xmm1, %ecx + cmpl $32767, %ecx + jg .L_2TAG_PACKET_6.0.2 + divsd %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_6.0.2: + andpd SGNMASK(%rip), %xmm0 + movsd pi_table(%rip), %xmm2 + xorpd %xmm2, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_5.0.2: + andpd SGNMASK(%rip), %xmm0 + movsd pi2_table(%rip), %xmm2 + xorpd %xmm2, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: +.L_2TAG_PACKET_1.0.2: + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + pextrw $3, %xmm1, %eax + andl $32752, %eax + cmpl $32752, %ecx + je .L_2TAG_PACKET_7.0.2 + cmpl $32752, %eax + je .L_2TAG_PACKET_8.0.2 + movsd POW55(%rip), %xmm3 + movl $1024, %edx + movsd INVEXPMASK(%rip), %xmm4 + xorpd %xmm6, %xmm6 + movsd EXPMASK(%rip), %xmm7 + cmpl $0, %ecx + je .L_2TAG_PACKET_9.0.2 +.L_2TAG_PACKET_10.0.2: + cmpl $0, %eax + je .L_2TAG_PACKET_11.0.2 +.L_2TAG_PACKET_12.0.2: + addl %ecx, %edx + subl %eax, %edx + cmpl $2048, %edx + ja .L_2TAG_PACKET_4.0.2 + addl $15344, %edx + pinsrw $3, %edx, %xmm6 + andpd %xmm4, %xmm0 + andpd %xmm4, %xmm1 + orpd %xmm6, %xmm0 + orpd %xmm7, %xmm1 + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_9.0.2: + subl $880, %edx + mulsd %xmm3, %xmm0 + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl $0, %ecx + je .L_2TAG_PACKET_13.0.2 + jmp .L_2TAG_PACKET_10.0.2 +.L_2TAG_PACKET_11.0.2: + addl $880, %edx + mulsd %xmm3, %xmm1 + pextrw $3, %xmm1, %eax + andl $32752, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_14.0.2 + jmp .L_2TAG_PACKET_12.0.2 +.L_2TAG_PACKET_7.0.2: + movd %xmm0, %edx + movq %xmm0, %xmm2 + psrlq $32, %xmm2 + movd %xmm2, %ecx + andl $1048575, %ecx + orl %edx, %ecx + cmpl $0, %ecx + jne .L_2TAG_PACKET_15.0.2 + psrlq $63, %xmm0 + psllq $63, %xmm0 + cmpl $32752, %eax + jae .L_2TAG_PACKET_16.0.2 + movapd pi2_table(%rip), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_15.0.2: + addsd %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_16.0.2: + movd %xmm1, %eax + movq %xmm1, %xmm2 + psrlq $32, %xmm2 + movd %xmm2, %ecx + movl $-2147483648, %edx + andl %ecx, %edx + andl $1048575, %ecx + orl %eax, %ecx + cmpl $0, %ecx + jne .L_2TAG_PACKET_17.0.2 + cmpl $0, %edx + jne .L_2TAG_PACKET_18.0.2 + movapd pi4_table(%rip), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_17.0.2: + movq %xmm1, %xmm0 + addsd %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_18.0.2: + movapd pi4_table(%rip), %xmm5 + movapd pi2_table(%rip), %xmm6 + addpd %xmm6, %xmm5 + pshufd $238, %xmm5, %xmm6 + addpd %xmm6, %xmm5 + orpd %xmm5, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_8.0.2: + movd %xmm1, %eax + movq %xmm1, %xmm2 + psrlq $32, %xmm2 + movd %xmm2, %ecx + movl $-2147483648, %edx + andl %ecx, %edx + andl $1048575, %ecx + orl %eax, %ecx + cmpl $0, %ecx + jne .L_2TAG_PACKET_17.0.2 + psrlq $63, %xmm0 + psllq $63, %xmm0 + cmpl $0, %edx + jne .L_2TAG_PACKET_19.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_19.0.2: + movapd pi_table(%rip), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_13.0.2: + pextrw $3, %xmm1, %edx + andl $32768, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_20.0.2 + movapd pi_table(%rip), %xmm5 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + comisd %xmm0, %xmm1 + orpd %xmm5, %xmm0 + je .L_2TAG_PACKET_21.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_20.0.2: + comisd %xmm0, %xmm1 + je .L_2TAG_PACKET_21.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_14.0.2: + movapd pi2_table(%rip), %xmm5 + psrlq $63, %xmm0 + psllq $63, %xmm0 + pshufd $238, %xmm5, %xmm4 + addsd %xmm4, %xmm5 + orpd %xmm5, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_21.0.2: + movq %xmm0, 16(%rsp) +..B1.3: + movq 16(%rsp), %xmm0 +.L_2TAG_PACKET_22.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type atan2,@function + .size atan2,.-atan2 + .data +# -- End atan2 + .section .rodata, "a" + .align 16 + .align 16 +a2: + .long 2006262985 + .long 1069310863 + .long 2358449471 + .long 3217342131 + .type a2,@object + .size a2,16 + .align 16 +b2: + .long 3845454352 + .long 1069952297 + .long 2829679149 + .long 1073771565 + .type b2,@object + .size b2,16 + .align 16 +P_TBL: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1413754136 + .long 1074340347 + .long 856972295 + .long 1017226790 + .long 1413754136 + .long 3221823995 + .long 856972295 + .long 3164710438 + .type P_TBL,@object + .size P_TBL,64 + .align 16 +SGN_TBL: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 0 + .type SGN_TBL,@object + .size SGN_TBL,64 + .align 16 +ATAN_TBL: + .long 3390881280 + .long 1067318733 + .long 1411116779 + .long 1018950063 + .long 2985987840 + .long 1067384211 + .long 2088903695 + .long 1018086027 + .long 3148445184 + .long 1067449685 + .long 2044163806 + .long 1017271335 + .long 3667629184 + .long 1067515494 + .long 2353092775 + .long 1019967309 + .long 1546568832 + .long 1067580954 + .long 611991315 + .long 1017602584 + .long 3815996800 + .long 1067646404 + .long 466038598 + .long 1019686426 + .long 4050241920 + .long 1067711845 + .long 3265026328 + .long 1019626952 + .long 120454912 + .long 1067777277 + .long 1542207696 + .long 1020155608 + .long 2784639744 + .long 1067842697 + .long 3883834623 + .long 1018602870 + .long 1328010624 + .long 1067908107 + .long 1791097456 + .long 1019053126 + .long 2217794048 + .long 1067973505 + .long 551619938 + .long 1018494194 + .long 3333520000 + .long 1068038891 + .long 2390331823 + .long 1019033022 + .long 2557052032 + .long 1068104265 + .long 2423976108 + .long 1019728674 + .long 2067649536 + .long 1068169626 + .long 3757397745 + .long 1018672362 + .long 4047094784 + .long 1068234973 + .long 481613184 + .long 1019275104 + .long 2089853184 + .long 1068300307 + .long 1733914374 + .long 1020124677 + .long 2678003840 + .long 1068365626 + .long 1373600282 + .long 1013935474 + .long 3706496128 + .long 1068430930 + .long 1000610902 + .long 1019673285 + .long 3073179008 + .long 1068496219 + .long 1497143008 + .long 1019900342 + .long 2803716736 + .long 1068562846 + .long 1476677416 + .long 1019444094 + .long 3204984128 + .long 1068628077 + .long 1192335905 + .long 1018748628 + .long 831146624 + .long 1068693273 + .long 2733586224 + .long 1018823295 + .long 243029376 + .long 1068758431 + .long 950106081 + .long 1019046675 + .long 1735561920 + .long 1068823549 + .long 3546440856 + .long 1020104712 + .long 1339217792 + .long 1068888626 + .long 3028812387 + .long 1019818321 + .long 3706342144 + .long 1068953659 + .long 3814564029 + .long 1017763871 + .long 637726976 + .long 1069018648 + .long 3584007699 + .long 1017976868 + .long 1148779264 + .long 1069083589 + .long 2282532133 + .long 1019483954 + .long 1406131392 + .long 1069148481 + .long 1547359113 + .long 1019786342 + .long 1908875904 + .long 1069213322 + .long 1315508410 + .long 1020009473 + .long 3194947520 + .long 1069278110 + .long 3845393201 + .long 1015803761 + .long 1547487744 + .long 1069342844 + .long 3863107865 + .long 1019810104 + .long 1881061952 + .long 1069407521 + .long 4288343548 + .long 1019687581 + .long 563086336 + .long 1069472140 + .long 2582230241 + .long 1020099350 + .long 2594975552 + .long 1069536698 + .long 2306443764 + .long 1019667244 + .long 3438545024 + .long 1069606573 + .long 957455549 + .long 1015587735 + .long 4211357472 + .long 1069670906 + .long 2611778754 + .long 1017877214 + .long 3002835424 + .long 1069735101 + .long 235580458 + .long 1020211685 + .long 3905315424 + .long 1069799150 + .long 3630647617 + .long 1018736849 + .long 2849656576 + .long 1069863047 + .long 2412165062 + .long 1019693004 + .long 507429472 + .long 1069926785 + .long 1397750723 + .long 1018412717 + .long 2307470272 + .long 1069990356 + .long 1796470904 + .long 1019796181 + .long 1271814912 + .long 1070053755 + .long 189761565 + .long 1016149115 + .long 3800538144 + .long 1070116974 + .long 2524871582 + .long 1018263353 + .long 3916203552 + .long 1070180008 + .long 127848658 + .long 1017672664 + .long 457192032 + .long 1070242851 + .long 4020400938 + .long 1019823010 + .long 1385324704 + .long 1070305495 + .long 564511179 + .long 1016079094 + .long 2322869856 + .long 1070367935 + .long 2347103319 + .long 1018927760 + .long 3743438624 + .long 1070430165 + .long 877973862 + .long 1019638162 + .long 2392255552 + .long 1070492180 + .long 2432782267 + .long 1018872629 + .long 4180443328 + .long 1070553973 + .long 3102990015 + .long 1020093101 + .long 2547540832 + .long 1070636485 + .long 3877738253 + .long 1017300424 + .long 2735468912 + .long 1070697461 + .long 2446470256 + .long 1019235378 + .long 542633792 + .long 1070757943 + .long 583606328 + .long 1018624131 + .long 923265984 + .long 1070817911 + .long 1793926708 + .long 1019714161 + .long 918728448 + .long 1070877348 + .long 3726463586 + .long 1019433296 + .long 2572275008 + .long 1070936237 + .long 1845354238 + .long 1019459238 + .long 50974688 + .long 1070994564 + .long 983808064 + .long 1016685418 + .long 1105518320 + .long 1071052313 + .long 2357496692 + .long 1015139882 + .long 1264825328 + .long 1071109472 + .long 2244129354 + .long 1019046344 + .long 961157920 + .long 1071166029 + .long 3124185339 + .long 1018541776 + .long 1162701584 + .long 1071221973 + .long 1279780948 + .long 1019268918 + .long 3284935664 + .long 1071277294 + .long 2670033472 + .long 1019833744 + .long 497441888 + .long 1071331985 + .long 1032737410 + .long 1019795212 + .long 3377383904 + .long 1071386036 + .long 2356897182 + .long 1020205553 + .long 1126962000 + .long 1071439443 + .long 3723724586 + .long 1015212418 + .long 90291008 + .long 1071492199 + .long 4178672431 + .long 1020186971 + .long 190059536 + .long 1071595741 + .long 1763589807 + .long 1019162163 + .long 2497392840 + .long 1071670654 + .long 3036997041 + .long 1020204325 + .long 2616971944 + .long 1071719773 + .long 300151069 + .long 1017041957 + .long 2883518128 + .long 1071767563 + .long 2203981414 + .long 1019190108 + .long 1496354352 + .long 1071814030 + .long 332287966 + .long 1016846435 + .long 483276728 + .long 1071859184 + .long 653845024 + .long 1018830914 + .long 3097401072 + .long 1071903039 + .long 1514746408 + .long 1019278972 + .long 2737217248 + .long 1071945615 + .long 1358845067 + .long 1017268275 + .long 2072577560 + .long 1071986933 + .long 3041024735 + .long 1019929672 + .long 2266405656 + .long 1072027017 + .long 1271261130 + .long 1012925070 + .long 958652544 + .long 1072065894 + .long 2158017058 + .long 1019955372 + .long 3312993840 + .long 1072103591 + .long 765809169 + .long 1019114443 + .long 3177001304 + .long 1072140139 + .long 144180084 + .long 1019822186 + .long 3071642184 + .long 1072175568 + .long 4004602424 + .long 1019420740 + .long 4283953648 + .long 1072209909 + .long 1511950430 + .long 1020176966 + .long 1413754136 + .long 1072243195 + .long 856972295 + .long 1015129638 + .long 4073202944 + .long 1072306725 + .long 4068194804 + .long 1019714860 + .long 946117760 + .long 1072366415 + .long 694980733 + .long 1020150135 + .long 3980632032 + .long 1072422512 + .long 1313251280 + .long 1019948709 + .long 1468297112 + .long 1072475260 + .long 330111143 + .long 1019809198 + .long 3478063816 + .long 1072524887 + .long 2930067044 + .long 1017784081 + .long 1153979856 + .long 1072571613 + .long 2225786102 + .long 1017634481 + .long 2089828808 + .long 1072615641 + .long 474621367 + .long 1017043414 + .long 3531732632 + .long 1072657163 + .long 2276396220 + .long 1018757240 + .long 775214612 + .long 1072694803 + .long 3209744818 + .long 1019963015 + .long 662307284 + .long 1072713319 + .long 1381696763 + .long 1019763781 + .long 1192776652 + .long 1072730830 + .long 3017932994 + .long 1015179769 + .long 744202396 + .long 1072747407 + .long 2073854034 + .long 1019512292 + .long 8337908 + .long 1072763115 + .long 16004448 + .long 1019599514 + .long 3589868768 + .long 1072778013 + .long 1374369804 + .long 1018019237 + .long 121647320 + .long 1072792159 + .long 128481634 + .long 1018115438 + .long 2464923204 + .long 1072805601 + .long 1787331214 + .long 1016798022 + .long 4093304372 + .long 1072830562 + .long 3306868969 + .long 1019384078 + .long 1436891684 + .long 1072853231 + .long 676347266 + .long 1017302183 + .long 1104571840 + .long 1072873890 + .long 2870400285 + .long 1019938149 + .long 2037009832 + .long 1072892781 + .long 2956702105 + .long 1016472908 + .long 3139037960 + .long 1072910111 + .long 916057147 + .long 1018364335 + .long 1826698064 + .long 1072926058 + .long 2171961098 + .long 1019669816 + .long 1353941060 + .long 1072940774 + .long 1722928782 + .long 1019926215 + .long 1803191644 + .long 1072954391 + .long 1547878639 + .long 1020259262 + .long 1092591296 + .long 1072967024 + .long 3070107923 + .long 1018320401 + .long 2205372832 + .long 1072978772 + .long 787328196 + .long 1014621351 + .long 1291577100 + .long 1072989723 + .long 2964757301 + .long 1020242528 + .long 4234512804 + .long 1072999952 + .long 3136030038 + .long 1017522144 + .long 3248069132 + .long 1073009528 + .long 1506192355 + .long 1018050472 + .long 3932628500 + .long 1073018509 + .long 1045823554 + .long 1019946655 + .long 4195697848 + .long 1073026948 + .long 233443322 + .long 1018917447 + .long 2501811452 + .long 1073034892 + .long 901427976 + .long 1017333852 + .long 866379428 + .long 1073049455 + .long 2437443742 + .long 1019678792 + .long 1376865888 + .long 1073062480 + .long 3365790232 + .long 1014547152 + .long 3290094268 + .long 1073074195 + .long 3898947415 + .long 1018683566 + .long 354764884 + .long 1073084787 + .long 3854322404 + .long 1019662058 + .long 3332975496 + .long 1073094406 + .long 3171701655 + .long 1017830922 + .long 1141460088 + .long 1073103181 + .long 3946082701 + .long 1020032019 + .long 745761284 + .long 1073111216 + .long 1347210591 + .long 1019106121 + .long 1673304508 + .long 1073118600 + .long 1760606642 + .long 1017324577 + .long 983388240 + .long 1073125409 + .long 3740651204 + .long 1019514104 + .long 3895509100 + .long 1073131706 + .long 2409629983 + .long 1020069322 + .long 2128523668 + .long 1073137548 + .long 3045605368 + .long 1018579174 + .long 2075485692 + .long 1073142981 + .long 3720571789 + .long 1017557436 + .long 121855976 + .long 1073148047 + .long 2391744767 + .long 1020160645 + .long 4181733780 + .long 1073152780 + .long 995028816 + .long 1019681295 + .long 2887813280 + .long 1073157214 + .long 218733247 + .long 1020003509 + .long 2862180896 + .long 1073161375 + .long 2043806490 + .long 1018602288 + .long 3909375184 + .long 1073168973 + .long 1559903412 + .long 1020103444 + .long 3533966292 + .long 1073175738 + .long 734884149 + .long 1018462962 + .long 3815044608 + .long 1073181799 + .long 3630523428 + .long 1017250093 + .long 739639376 + .long 1073187261 + .long 4167476661 + .long 1020008277 + .long 1068309648 + .long 1073192207 + .long 2110061437 + .long 1019295858 + .long 2350566352 + .long 1073196707 + .long 582596516 + .long 1018568821 + .long 2529520024 + .long 1073200819 + .long 745552787 + .long 1019053165 + .long 1841667508 + .long 1073204591 + .long 3982568700 + .long 1016503327 + .long 2242261080 + .long 1073208063 + .long 3433582258 + .long 1016196763 + .long 715134328 + .long 1073211270 + .long 355901358 + .long 1020087916 + .long 2700735876 + .long 1073214240 + .long 3640957736 + .long 1019780205 + .long 141607580 + .long 1073217000 + .long 2488245051 + .long 1020262395 + .long 287934404 + .long 1073219570 + .long 2392691085 + .long 1019883292 + .long 2363373988 + .long 1073221969 + .long 4194561737 + .long 1019237447 + .long 3829340424 + .long 1073224214 + .long 429455526 + .long 1019490975 + .long 1988805928 + .long 1073226320 + .long 3029848706 + .long 1018104889 + .long 1647572320 + .long 1073230161 + .long 10289938 + .long 1017394880 + .long 3988000624 + .long 1073233576 + .long 1957559169 + .long 1019434816 + .long 4263843944 + .long 1073236633 + .long 204710264 + .long 1019908761 + .long 663197724 + .long 1073239386 + .long 1921757578 + .long 1019778948 + .long 3560800700 + .long 1073241876 + .long 3994348896 + .long 1019230192 + .long 2441785656 + .long 1073244141 + .long 871468611 + .long 1014800505 + .long 3277400272 + .long 1073246209 + .long 4092218139 + .long 1020040842 + .long 3951990120 + .long 1073248105 + .long 4276546478 + .long 1019763677 + .long 2737338540 + .long 1073249850 + .long 252776012 + .long 1018794951 + .long 1511361316 + .long 1073251461 + .long 3119653999 + .long 1018514803 + .long 3969162516 + .long 1073252952 + .long 1037069016 + .long 1016792900 + .long 413985240 + .long 1073254338 + .long 4110171432 + .long 1020001345 + .long 3681283576 + .long 1073255627 + .long 1463092818 + .long 1020260354 + .long 3146455488 + .long 1073256831 + .long 1031209123 + .long 1016554799 + .long 95214512 + .long 1073257958 + .long 1373808632 + .long 1019493031 + .long 4250240828 + .long 1073259013 + .long 3891047882 + .long 1020108730 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .type ATAN_TBL,@object + .size ATAN_TBL,2624 + .align 16 +P_TBL2: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 856972295 + .long 1017226790 + .long 1413754136 + .long 1074340347 + .long 856972295 + .long 3164710438 + .long 1413754136 + .long 3221823995 + .type P_TBL2,@object + .size P_TBL2,64 + .align 16 +SELECT_B: + .long 0 + .long 0 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .type SELECT_B,@object + .size SELECT_B,64 + .align 16 +SGNMASK: + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .type SGNMASK,@object + .size SGNMASK,16 + .align 16 +pi_table: + .long 1413754136 + .long 1074340347 + .long 856972295 + .long 1017226790 + .type pi_table,@object + .size pi_table,16 + .align 16 +pi2_table: + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .type pi2_table,@object + .size pi2_table,16 + .align 16 +pi4_table: + .long 1413754136 + .long 1072243195 + .long 856972295 + .long 1015129638 + .type pi4_table,@object + .size pi4_table,16 + .align 4 +POW55: + .long 0 + .long 1130364928 + .type POW55,@object + .size POW55,8 + .align 4 +INVEXPMASK: + .long 4294967295 + .long 2148532223 + .type INVEXPMASK,@object + .size INVEXPMASK,8 + .align 4 +EXPMASK: + .long 0 + .long 1072693248 + .type EXPMASK,@object + .size EXPMASK,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atan2dl.S b/external/sgx_libm/intel64/atan2dl.S new file mode 100644 index 0000000000..84cc078f5d --- /dev/null +++ b/external/sgx_libm/intel64/atan2dl.S @@ -0,0 +1,1433 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2dl.c" + .text +..TXTST0: +# -- Begin atand2l + .text + .align 16,0x90 + .globl atand2l +atand2l: +# parameter 1: 8 + %rsp +# parameter 2: 24 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_atand2l.1: +..L2: + + fldt 8(%rsp) + fldt 24(%rsp) + fstpt 24(%rsp) + fstpt 8(%rsp) + jmp atan2dl@PLT + .align 16,0x90 + .cfi_endproc + .type atand2l,@function + .size atand2l,.-atand2l + .data +# -- End atand2l + .text +# -- Begin atan2dl + .text + .align 16,0x90 + .globl atan2dl +atan2dl: +# parameter 1: 96 + %rsp +# parameter 2: 112 + %rsp +..B2.1: + .cfi_startproc +..___tag_value_atan2dl.4: +..L5: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %dl, %dl +..B2.2: + fnstcw 74(%rsp) +..B2.3: + movzbl 105(%rsp), %r8d + andl $128, %r8d + movzbl 121(%rsp), %eax + movzwl 104(%rsp), %esi + andl $128, %eax + andl $32767, %esi + shrl $7, %r8d + movzwl 120(%rsp), %edi + movl %r8d, %r9d + shrl $7, %eax + andl $32767, %edi + cmpl $32767, %esi + je ..B2.105 +..B2.4: + cmpl $32767, %edi + je ..B2.88 +..B2.5: + testl %esi, %esi + jne ..B2.7 +..B2.6: + cmpq $0, 96(%rsp) + je ..B2.11 +..B2.7: + testl %edi, %edi + jne ..B2.23 +..B2.8: + cmpq $0, 112(%rsp) + jne ..B2.23 +..B2.9: + testl %esi, %esi + jne ..B2.22 +..B2.10: + cmpq $0, 96(%rsp) + jne ..B2.18 +..B2.11: + testl %edi, %edi + jne ..B2.14 +..B2.12: + cmpq $0, 112(%rsp) + je ..B2.83 +..B2.13: + lea _smallest_value_64(%rip), %rdx + movq (%rdx), %rcx + movq %rcx, 48(%rsp) +..B2.14: + testl %eax, %eax + je ..B2.16 +..B2.15: + lea c180(%rip), %rax + fldl (%rax,%r9,8) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.16: + lea _zeros(%rip), %rax + fldl (%rax,%r9,8) +..B2.17: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.18: + testl %edi, %edi + jne ..B2.23 +..B2.19: + cmpq $0, 112(%rsp) + jne ..B2.23 +..B2.20: + testl %esi, %esi + jne ..B2.22 +..B2.21: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 48(%rsp) +..B2.22: + lea c90(%rip), %rax + fldl (%rax,%r9,8) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.23: + cmpl %esi, %edi + jne ..B2.29 +..B2.24: + movl 116(%rsp), %ecx + cmpl 100(%rsp), %ecx + jne ..B2.29 +..B2.25: + movl 112(%rsp), %ecx + cmpl 96(%rsp), %ecx + jne ..B2.29 +..B2.26: + orl %esi, %edi + jne ..B2.28 +..B2.27: + lea _smallest_value_64(%rip), %rdx + movq (%rdx), %rcx + movq %rcx, 48(%rsp) +..B2.28: + movl %eax, %eax + lea exact(%rip), %rdx + lea (%r9,%rax,2), %rcx + fldl (%rdx,%rcx,8) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.29: + movzwl 74(%rsp), %r10d + movl %r10d, %ecx + andl $3840, %ecx + cmpl $768, %ecx + je ..B2.33 +..B2.30: + andl $-3841, %r10d + orl $-64768, %r10d + movw %r10w, 72(%rsp) +..B2.31: + fldcw 72(%rsp) +..B2.32: + movb $1, %dl +..B2.33: + cmpl $8191, %edi + jg ..B2.37 +..B2.34: + cmpl $8191, %esi + jg ..B2.36 +..B2.35: + fldt 112(%rsp) + lea _TWO_8192(%rip), %rcx + fldt 96(%rsp) + fldt (%rcx) + fmul %st, %st(2) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + movzwl 120(%rsp), %edi + movzwl 104(%rsp), %esi + andl $32767, %edi + andl $32767, %esi + jmp ..B2.38 +..B2.36: + fldt 112(%rsp) + fldt 96(%rsp) + jmp ..B2.41 +..B2.37: + fldt 112(%rsp) + fldt 96(%rsp) +..B2.38: + cmpl $24575, %edi + jl ..B2.41 +..B2.39: + cmpl $24575, %esi + jl ..B2.41 +..B2.40: + lea 16+_TWO_8192(%rip), %rcx + fldt (%rcx) + fmul %st, %st(2) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + movzwl 120(%rsp), %edi + movzwl 104(%rsp), %esi + andl $32767, %edi + andl $32767, %esi +..B2.41: + lea _ones(%rip), %rcx + fldl (%rcx,%rax,8) + fmulp %st, %st(2) + fld %st(0) + fldl (%rcx,%r9,8) + fmul %st, %st(1) + fxch %st(3) + fcomi %st(1), %st + jbe ..B2.69 +..B2.42: + lea 12(%rsi), %r10d + cmpl %r10d, %edi + jle ..B2.65 +..B2.43: + lea 75(%rsi), %r10d + cmpl %r10d, %edi + jle ..B2.62 +..B2.44: + fstp %st(0) + fstp %st(0) + fstp %st(1) + testl %eax, %eax + je ..B2.46 +..B2.45: + fstp %st(0) + movq %r9, %rcx + lea _small_value_80(%rip), %rax + shlq $4, %rcx + lea c180(%rip), %rsi + fldt (%rax,%rcx) + fsubrl (%rsi,%r9,8) + fstpt 56(%rsp) + jmp ..B2.80 +..B2.46: + testl %esi, %esi + jle ..B2.87 +..B2.47: + fstp %st(0) + xorl %esi, %esi +..B2.48: + shll $15, %eax + orl $-49153, %eax + movw %ax, 120(%rsp) + lea _TWO_32H(%rip), %rax + fldt 112(%rsp) + fld %st(0) + fld %st(1) + fld %st(2) + fxch %st(3) + fstpt 32(%rsp) + fldt 32(%rsp) + fldl (%rax) + fmul %st, %st(3) + shll $15, %r8d + fxch %st(2) + fsubr %st(3), %st + movzwl 104(%rsp), %r9d + orl $-49153, %r8d + movw %r8w, 104(%rsp) + lea 8+_C180byPi(%rip), %r8 + andl $32767, %r9d + fsubrp %st, %st(3) + subl %r9d, %edi + fxch %st(2) + fsubr %st, %st(3) + fld %st(1) + cmpl $16382, %edi + fldl (%rcx) + lea _C180byPi(%rip), %rcx + fld %st(0) + fdivp %st, %st(5) + fxch %st(1) + fmul %st(4), %st + fld %st(0) + fsub %st(5), %st + fsubrp %st, %st(1) + fld %st(0) + fsubr %st(5), %st + fld %st(3) + fmul %st(1), %st + fxch %st(6) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(6) + fxch %st(1) + fmul %st, %st(3) + fxch %st(2) + fsub %st, %st(3) + fxch %st(5) + fsubrp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fldl (%rcx) + fmul %st, %st(1) + fmulp %st, %st(2) + fldl (%r8) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fldt 96(%rsp) + fld %st(0) + fmul %st(3), %st + fld %st(1) + fsubr %st(1), %st + fsubrp %st, %st(1) + fxch %st(3) + fmul %st(5), %st + fld %st(0) + fsub %st(6), %st + fsubrp %st, %st(1) + fsubr %st, %st(5) + fxch %st(2) + faddp %st, %st(5) + fmul %st, %st(4) + fld %st(0) + fsub %st(3), %st + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(5) + faddp %st, %st(3) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(5), %st + fsubr %st, %st(1) + fxch %st(1) + fchs + fsubrp %st, %st(1) + fstpt 56(%rsp) + fldt 56(%rsp) + fsubrp %st, %st(4) + fxch %st(3) + fstpt 16(%rsp) + fldt 16(%rsp) + faddp %st, %st(1) + jl ..B2.52 +..B2.49: + fldt 56(%rsp) + lea _small(%rip), %rax + addl $-16318, %edi + cmpl $16382, %edi + fldt (%rax) + fmul %st, %st(1) + fxch %st(1) + fstpt 56(%rsp) + fmul %st, %st(1) + jl ..B2.51 +..B2.50: + fldt 56(%rsp) + addl $-16318, %edi + fmul %st(1), %st + fstpt 56(%rsp) + fldt 56(%rsp) + fstpt (%rsp) + fmulp %st, %st(1) + jmp ..B2.53 +..B2.51: + fstp %st(0) + fldt 56(%rsp) + fstpt (%rsp) + jmp ..B2.53 +..B2.52: + fldt 56(%rsp) + fstpt (%rsp) +..B2.53: + movl %edi, %eax + negl %eax + addl $16383, %eax + fxch %st(1) + fstpt 16(%rsp) + testl %esi, %esi + movw %ax, 24(%rsp) + je ..B2.55 +..B2.54: + fldt 16(%rsp) + lea 8+_two64(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) + fldt 16(%rsp) + jmp ..B2.56 +..B2.55: + fldt 16(%rsp) +..B2.56: + movzwl 8(%rsp), %eax + andl $32767, %eax + subl %esi, %eax + subl %edi, %eax + cmpl $-9, %eax + jl ..B2.59 +..B2.57: + testl %eax, %eax + jg ..B2.59 +..B2.58: + fldt 56(%rsp) + fmul %st(1), %st + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 56(%rsp) + jmp ..B2.60 +..B2.59: + fldt 56(%rsp) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 56(%rsp) +..B2.60: + fldt 56(%rsp) + lea _zeros(%rip), %rax + fldl (%rax) + fxch %st(1) + fucomip %st(1), %st + jp ..B2.113 + je ..B2.61 +..B2.113: + fstp %st(0) + fstp %st(0) + jmp ..B2.80 +..B2.61: + fldt 32(%rsp) + fdivrp %st, %st(2) + fmulp %st, %st(1) + fstpt 56(%rsp) + jmp ..B2.80 +..B2.62: + fstp %st(2) + testl %eax, %eax + je ..B2.64 +..B2.63: + fdivp %st, %st(1) + lea _TWO_32H(%rip), %rax + lea _C180byPi(%rip), %rcx + lea 8+_C180byPi(%rip), %rsi + lea 48+_P(%rip), %rdi + lea 16+_P(%rip), %r8 + lea 32+_P(%rip), %r9 + lea _P(%rip), %r10 + movq __libm_atandl_table_128@GOTPCREL(%rip), %r11 + fstpt 112(%rsp) + fldt 112(%rsp) + fldl (%rax) + fmul %st(1), %st + fld %st(0) + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fld %st(2) + fmul %st(3), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl (%rcx) + fmul %st, %st(4) + fmulp %st, %st(3) + fldl (%rsi) + fmul %st(5), %st + faddp %st, %st(3) + fldt (%rdi) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + fmulp %st, %st(3) + fldt (%r10) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fsubrl 8200(%r11) + faddl 8192(%r11) + fmulp %st, %st(1) + fstpt 56(%rsp) + jmp ..B2.80 +..B2.64: + fld %st(0) + lea 48+_P(%rip), %rax + lea 16+_P(%rip), %rsi + lea 32+_P(%rip), %rdi + lea _P(%rip), %r8 + lea _TWO_32H(%rip), %r9 + lea _C180byPi(%rip), %r10 + lea 8+_C180byPi(%rip), %r11 + fdiv %st(2), %st + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(5) + fstpl 32(%rsp) + fldt (%rax) + fmul %st(5), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rdi) + fmulp %st, %st(6) + fldt (%r8) + faddp %st, %st(6) + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fmulp %st, %st(3) + fxch %st(2) + fstpt (%rsp) + fld %st(0) + fld %st(2) + fld %st(2) + fld %st(4) + fldl (%r9) + fmul %st, %st(4) + fxch %st(2) + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(3) + fsubr %st, %st(4) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(4) + fsub %st(3), %st + fld %st(2) + fxch %st(6) + fmull (%r11) + fldl (%r10) + fmul %st, %st(5) + fxch %st(5) + fmul %st, %st(7) + fxch %st(5) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(4) + fadd %st(2), %st + fld %st(4) + fadd %st(7), %st + fsubp %st, %st(7) + fxch %st(4) + fsub %st(6), %st + faddp %st, %st(1) + fxch %st(3) + fdivrl (%rcx) + fmul %st, %st(2) + lea 8+_ones(%rip), %rcx + fld %st(2) + fadd %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fld %st(2) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(2) + fxch %st(2) + fmul %st(3), %st + fldt (%rsp) + fxch %st(1) + faddl (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + fsubrp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fxch %st(3) + fadd %st(5), %st + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmull 32(%rsp) + fstpt 56(%rsp) + jmp ..B2.80 +..B2.65: + fstp %st(2) + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %rsi + fmul %st(1), %st + lea _TWO_48H(%rip), %rdi + fdiv %st(2), %st + fld %st(1) + fxch %st(4) + fstpl 32(%rsp) + fld %st(2) + fldl (%rsi) + lea _C180byPi(%rip), %r8 + lea 8+_C180byPi(%rip), %r9 + lea 48+_P(%rip), %r10 + lea 16+_P(%rip), %r11 + fadd %st, %st(2) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(2) + fld %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(3) + fld %st(3) + fldl (%rdi) + lea _P(%rip), %rdi + fmul %st, %st(7) + movl 16(%rsp), %esi + fxch %st(1) + fadd %st(7), %st + addl %esi, %esi + fsubp %st, %st(7) + testl %eax, %eax + fxch %st(4) + fsub %st(6), %st + fld %st(0) + fmul %st(4), %st + fxch %st(3) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(5) + fxch %st(2) + fadd %st(5), %st + fld %st(6) + fmul %st(4), %st + fadd %st(3), %st + fxch %st(4) + fmul %st, %st(6) + fxch %st(6) + fsubrp %st, %st(2) + fld %st(3) + fadd %st(1), %st + fxch %st(3) + fmulp %st, %st(6) + fxch %st(5) + fsubrp %st, %st(6) + fld %st(2) + fxch %st(2) + fdivrl (%rcx) + fmul %st, %st(4) + lea 8+_ones(%rip), %rcx + fld %st(4) + fadd %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(5) + fld %st(4) + fsubr %st(1), %st + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(3) + fxch %st(3) + fmul %st(4), %st + faddl (%rcx) + lea 32+_P(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + fsubrp %st, %st(1) + fld %st(1) + fmul %st(3), %st + fxch %st(3) + fadd %st(4), %st + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fld %st(2) + fxch %st(4) + fmulp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fadd %st(2), %st + fmul %st, %st(4) + fld %st(3) + fmul %st(3), %st + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fxch %st(4) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl (%r8) + fmul %st, %st(3) + fmulp %st, %st(4) + fldl (%r9) + fmul %st(5), %st + faddp %st, %st(4) + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + fmulp %st, %st(3) + fldt (%rdi) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldl 32(%rsp) + je ..B2.67 +..B2.66: + negl %esi + fld %st(2) + movslq %esi, %rsi + movq __libm_atandl_table_128@GOTPCREL(%rip), %rax + fldl 8192(%rax,%rsi,8) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fldl 8200(%rax,%rsi,8) + fsubp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 56(%rsp) + jmp ..B2.68 +..B2.67: + movslq %esi, %rsi + fld %st(2) + movq __libm_atandl_table_128@GOTPCREL(%rip), %rax + fldl (%rax,%rsi,8) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 8(%rax,%rsi,8) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 56(%rsp) +..B2.68: + fldt 56(%rsp) + fmulp %st, %st(1) + fstpt 56(%rsp) + jmp ..B2.80 +..B2.69: + fstp %st(2) + lea 12(%rdi), %r8d + cmpl %r8d, %esi + jle ..B2.76 +..B2.70: + addl $75, %edi + cmpl %edi, %esi + jle ..B2.72 +..B2.71: + fstp %st(1) + fstp %st(0) + fstp %st(0) + movq %r9, %rcx + lea _small_value_80(%rip), %rax + shlq $4, %rcx + lea c90(%rip), %rsi + fldt (%rax,%rcx) + fsubrl (%rsi,%r9,8) + fstpt 56(%rsp) + jmp ..B2.80 +..B2.72: + fdivrp %st, %st(1) + lea _TWO_32H(%rip), %rcx + lea _C180byPi(%rip), %rsi + lea 8+_C180byPi(%rip), %rdi + lea 48+_P(%rip), %r8 + lea 16+_P(%rip), %r9 + lea 32+_P(%rip), %r10 + lea _P(%rip), %r11 + fstpt 112(%rsp) + fldt 112(%rsp) + testl %eax, %eax + fldl (%rcx) + fmul %st(1), %st + fld %st(0) + movq __libm_atandl_table_128@GOTPCREL(%rip), %rcx + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fld %st(2) + fmul %st(3), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl (%rsi) + fmul %st, %st(4) + fmulp %st, %st(3) + fldl (%rdi) + fmul %st(5), %st + faddp %st, %st(3) + fldt (%r8) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + fmulp %st, %st(3) + fldt (%r11) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldl 4096(%rcx) + fstpt 56(%rsp) + fldl 4104(%rcx) + je ..B2.74 +..B2.73: + fldt 56(%rsp) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 56(%rsp) + jmp ..B2.75 +..B2.74: + fldt 56(%rsp) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 56(%rsp) +..B2.75: + fldt 56(%rsp) + fmulp %st, %st(1) + fstpt 56(%rsp) + jmp ..B2.80 +..B2.76: + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %rsi + fmul %st(2), %st + lea _TWO_48H(%rip), %rdi + fdiv %st(1), %st + fld %st(2) + fxch %st(4) + fstpl 32(%rsp) + fld %st(1) + fldl (%rsi) + lea _C180byPi(%rip), %r8 + lea 8+_C180byPi(%rip), %r9 + lea 48+_P(%rip), %r10 + lea 16+_P(%rip), %r11 + fadd %st, %st(2) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(2) + fld %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(3) + fld %st(3) + fldl (%rdi) + lea _P(%rip), %rdi + fmul %st, %st(7) + movl 16(%rsp), %esi + fxch %st(2) + fadd %st(7), %st + addl %esi, %esi + fsubp %st, %st(7) + fld %st(6) + testl %eax, %eax + fmul %st(4), %st + fxch %st(6) + fsub %st(7), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(1) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fld %st(1) + fmul %st(4), %st + fadd %st(5), %st + fxch %st(4) + fmul %st, %st(5) + fxch %st(5) + fsubrp %st, %st(2) + fmul %st, %st(4) + fxch %st(4) + fsubrp %st, %st(6) + fxch %st(3) + faddp %st, %st(4) + fld %st(3) + fadd %st(2), %st + fld %st(4) + fxch %st(1) + fdivrl (%rcx) + lea 8+_ones(%rip), %rcx + fmul %st, %st(2) + fld %st(2) + fadd %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddl (%rcx) + lea 32+_P(%rip), %rcx + faddp %st, %st(1) + fmulp %st, %st(2) + fsubp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fxch %st(2) + fadd %st(4), %st + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fld %st(1) + fxch %st(4) + fmulp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fadd %st(3), %st + fmul %st, %st(4) + fld %st(2) + fmul %st(4), %st + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fxch %st(4) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl (%r8) + fmul %st, %st(4) + fmulp %st, %st(3) + fldl (%r9) + fmul %st(5), %st + faddp %st, %st(3) + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + fmulp %st, %st(3) + fldt (%rdi) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fldl 32(%rsp) + je ..B2.78 +..B2.77: + movslq %esi, %rsi + fld %st(1) + movq __libm_atandl_table_128@GOTPCREL(%rip), %rax + fldl 4096(%rax,%rsi,8) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(3) + faddl 4104(%rax,%rsi,8) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 56(%rsp) + jmp ..B2.79 +..B2.78: + negl %esi + fld %st(1) + movslq %esi, %rsi + movq __libm_atandl_table_128@GOTPCREL(%rip), %rax + fldl 4096(%rax,%rsi,8) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(3) + fldl 4104(%rax,%rsi,8) + fsubp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 56(%rsp) +..B2.79: + fldt 56(%rsp) + fmulp %st, %st(1) + fstpt 56(%rsp) +..B2.80: + testb %dl, %dl + je ..B2.82 +..B2.81: + fldcw 74(%rsp) +..B2.82: + fldt 56(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.83: + testl %eax, %eax + je ..B2.85 +..B2.84: + lea c180(%rip), %rax + fldl (%rax,%r9,8) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.85: + lea _zeros(%rip), %rax + fldl (%rax,%r9,8) +..B2.86: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.87: + lea _two64(%rip), %rsi + fldl (%rsi) + movl $64, %esi + fmulp %st, %st(1) + fstpt 96(%rsp) + jmp ..B2.48 +..B2.88: + movq $0x8000000000000000, %rdx + cmpq 112(%rsp), %rdx + je ..B2.90 +..B2.89: + fldt 112(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.90: + testl %esi, %esi + jne ..B2.96 +..B2.91: + cmpl $0, 100(%rsp) + jne ..B2.93 +..B2.92: + cmpl $0, 96(%rsp) + je ..B2.97 +..B2.93: + lea _smallest_value_64(%rip), %rdx + movq (%rdx), %rcx + movq %rcx, 48(%rsp) +..B2.94: + cmpl $32767, %edi + je ..B2.96 +..B2.95: + lea c90(%rip), %rax + fldl (%rax,%r9,8) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.96: + cmpl $32767, %esi + je ..B2.101 +..B2.97: + testl %eax, %eax + je ..B2.99 +..B2.98: + lea c180(%rip), %rax + fldl (%rax,%r9,8) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.99: + lea _zeros(%rip), %rax + fldl (%rax,%r9,8) +..B2.100: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.101: + testl %eax, %eax + je ..B2.103 +..B2.102: + lea c135(%rip), %rax + fldl (%rax,%r9,8) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.103: + lea c45(%rip), %rax + fldl (%rax,%r9,8) +..B2.104: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.105: + movq $0x8000000000000000, %rdx + cmpq 96(%rsp), %rdx + jne ..B2.89 +..B2.106: + cmpl $32767, %edi + je ..B2.88 +..B2.107: + testl %edi, %edi + jne ..B2.94 +..B2.108: + cmpl $0, 116(%rsp) + jne ..B2.93 +..B2.109: + cmpl $0, 112(%rsp) + jne ..B2.93 + jmp ..B2.95 + .align 16,0x90 + .cfi_endproc + .type atan2dl,@function + .size atan2dl,.-atan2dl + .data +# -- End atan2dl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x80,0x13,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 16 +_TWO_8192: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .type _TWO_8192,@object + .size _TWO_8192,32 + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 16 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .space 8, 0x00 # pad + .align 16 +_C180byPi: + .long 442499072 + .long 1078765020 + .long 3272251219 + .long 1042157501 + .type _C180byPi,@object + .size _C180byPi,16 + .align 16 +_small: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 65 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32769 + .word 0 + .word 0 + .word 0 + .type _small,@object + .size _small,32 + .align 16 +_two64: + .long 0 + .long 1139802112 + .long 0 + .long 1005584384 + .type _two64,@object + .size _two64,16 + .align 16 +_P: + .word 54228 + .word 26975 + .word 60215 + .word 39113 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 30637 + .word 6142 + .word 46044 + .word 46936 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 47408 + .word 26349 + .word 14153 + .word 33526 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 53934 + .word 32714 + .word 35699 + .word 52145 + .word 16385 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,64 + .align 16 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .space 8, 0x00 # pad + .align 16 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 8 +c180: + .long 0x00000000,0x40668000 + .long 0x00000000,0xc0668000 + .type c180,@object + .size c180,16 + .align 8 +c90: + .long 0x00000000,0x40568000 + .long 0x00000000,0xc0568000 + .type c90,@object + .size c90,16 + .align 8 +exact: + .long 0x00000000,0x40468000 + .long 0x00000000,0xc0468000 + .long 0x00000000,0x4060e000 + .long 0x00000000,0xc060e000 + .type exact,@object + .size exact,32 + .align 8 +c135: + .long 0x00000000,0x4060e000 + .long 0x00000000,0xc060e000 + .type c135,@object + .size c135,16 + .align 8 +c45: + .long 0x00000000,0x40468000 + .long 0x00000000,0xc0468000 + .type c45,@object + .size c45,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atan2f_gen.S b/external/sgx_libm/intel64/atan2f_gen.S new file mode 100644 index 0000000000..72d4155595 --- /dev/null +++ b/external/sgx_libm/intel64/atan2f_gen.S @@ -0,0 +1,556 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2f_gen.c" + .text +..TXTST0: +# -- Begin atan2f + .text + .align 16,0x90 + .globl atan2f +atan2f: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_atan2f.1: +..L2: + + movd %xmm0, %esi + movd %xmm1, %ecx + movss %xmm0, -16(%rsp) + movss %xmm1, -8(%rsp) + movl %esi, %edi + movl %esi, %eax + movl %ecx, %edx + movl %ecx, %r8d + andl $2147483647, %edi + andl $2147483647, %r8d + shrl $31, %eax + shrl $31, %edx + movl %ecx, -24(%rsp) + cmpl $2139095040, %edi + movl %esi, -24(%rsp) + jl ..B1.3 +..B1.2: + jg ..B1.16 +..B1.52: + cmpl $2139095040, %r8d + jg ..B1.16 + jmp ..B1.5 +..B1.3: + cmpl $2139095040, %r8d + jl ..B1.17 +..B1.4: + jg ..B1.16 +..B1.5: + jl ..B1.15 +..B1.6: + movl %eax, %eax + cmpl $2139095040, %edi + jge ..B1.11 +..B1.7: + testl %edx, %edx + je ..B1.9 +..B1.8: + lea pi(%rip), %rdx + lea _small_value_64(%rip), %rcx + movsd (%rdx,%rax,8), %xmm0 + addsd (%rcx,%rax,8), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.9: + lea _zeros(%rip), %rdx + movss (%rdx,%rax,4), %xmm0 +..B1.10: + ret +..B1.11: + lea _small_value_64(%rip), %rcx + testl %edx, %edx + movsd (%rcx,%rax,8), %xmm1 + je ..B1.13 +..B1.12: + lea pi34(%rip), %rdx + movsd (%rdx,%rax,8), %xmm0 + addsd %xmm1, %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.13: + lea pi4(%rip), %rdx + movsd (%rdx,%rax,8), %xmm0 + addsd %xmm1, %xmm0 + cvtsd2ss %xmm0, %xmm0 +..B1.14: + ret +..B1.15: + movl %eax, %eax + lea pi2(%rip), %rdx + lea _small_value_64(%rip), %rcx + movsd (%rdx,%rax,8), %xmm0 + addsd (%rcx,%rax,8), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.16: + movss -8(%rsp), %xmm0 + mulss -16(%rsp), %xmm0 + ret +..B1.17: + testl %r8d, %edi + jne ..B1.25 +..B1.18: + testl %edi, %edi + jne ..B1.24 +..B1.19: + movl %eax, %eax + testl %r8d, %r8d + je ..B1.45 +..B1.20: + testl %edx, %edx + je ..B1.22 +..B1.21: + lea pi(%rip), %rdx + lea _small_value_64(%rip), %rcx + movsd (%rdx,%rax,8), %xmm0 + addsd (%rcx,%rax,8), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.22: + lea _zeros(%rip), %rdx + movss (%rdx,%rax,4), %xmm0 +..B1.23: + ret +..B1.24: + testl %r8d, %r8d + je ..B1.49 +..B1.25: + pxor %xmm0, %xmm0 + pxor %xmm5, %xmm5 + cvtss2sd -16(%rsp), %xmm0 + cvtss2sd -8(%rsp), %xmm5 + movsd %xmm0, -40(%rsp) + movsd %xmm5, -32(%rsp) + movl -36(%rsp), %edi + movl -28(%rsp), %esi + andl $2147483647, %edi + andl $2147483647, %esi + cmpl %esi, %edi + jl ..B1.32 +..B1.26: + lea 1048576(%rsi), %ecx + cmpl %ecx, %edi + jle ..B1.31 +..B1.27: + movl %eax, %eax + lea pi2(%rip), %rdx + addl $33554432, %esi + cmpl %esi, %edi + movsd (%rdx,%rax,8), %xmm4 + jle ..B1.29 +..B1.28: + divsd %xmm0, %xmm5 + subsd %xmm5, %xmm4 + cvtsd2ss %xmm4, %xmm4 + jmp ..B1.30 +..B1.29: + divsd %xmm0, %xmm5 + movaps %xmm5, %xmm1 + subsd %xmm5, %xmm4 + mulsd %xmm5, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm3 + movsd .L_2il0floatpacket.10(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.7(%rip), %xmm3 + addsd .L_2il0floatpacket.11(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.8(%rip), %xmm3 + addsd .L_2il0floatpacket.12(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.9(%rip), %xmm3 + addsd .L_2il0floatpacket.13(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm3 + mulsd %xmm3, %xmm5 + subsd %xmm5, %xmm4 + cvtsd2ss %xmm4, %xmm4 +..B1.30: + movaps %xmm4, %xmm0 + ret +..B1.31: + movl %eax, %eax + lea _ones(%rip), %rcx + movl %edx, %edx + pxor %xmm1, %xmm1 + pxor %xmm2, %xmm2 + lea pi4n(%rip), %rsi + movsd .L_2il0floatpacket.3(%rip), %xmm4 + cmpl %eax, %edx + cvtss2sd (%rcx,%rax,4), %xmm1 + cvtss2sd (%rcx,%rdx,4), %xmm2 + mulsd %xmm1, %xmm0 + mulsd %xmm2, %xmm5 + movaps %xmm0, %xmm6 + addsd %xmm5, %xmm0 + subsd %xmm5, %xmm6 + divsd %xmm0, %xmm6 + movaps %xmm6, %xmm0 + mulsd %xmm6, %xmm0 + movaps %xmm0, %xmm3 + mulsd %xmm0, %xmm3 + movsd .L_2il0floatpacket.0(%rip), %xmm5 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm4 + addsd .L_2il0floatpacket.1(%rip), %xmm5 + addsd .L_2il0floatpacket.4(%rip), %xmm4 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm4 + addsd .L_2il0floatpacket.2(%rip), %xmm5 + addsd .L_2il0floatpacket.5(%rip), %xmm4 + mulsd %xmm0, %xmm5 + addsd %xmm4, %xmm5 + mulsd %xmm5, %xmm6 + addsd (%rsi,%rdx,8), %xmm6 + movaps %xmm6, %xmm0 + xorps .L_2il0floatpacket.15(%rip), %xmm0 + jne ..L3 + movaps %xmm6, %xmm0 +..L3: + cvtsd2ss %xmm0, %xmm0 + ret +..B1.32: + lea 1048576(%rdi), %ecx + cmpl %ecx, %esi + jle ..B1.44 +..B1.33: + addl $33554432, %edi + cmpl %edi, %esi + jle ..B1.40 +..B1.34: + testl %edx, %edx + jne ..B1.39 +..B1.35: + divsd %xmm5, %xmm0 + lea _minnormf(%rip), %rax + movaps %xmm0, %xmm2 + andps .L_2il0floatpacket.16(%rip), %xmm2 + movsd (%rax), %xmm1 + comisd %xmm2, %xmm1 + jbe ..B1.37 +..B1.36: + movss .L_2il0floatpacket.14(%rip), %xmm1 + mulss %xmm1, %xmm1 + movss %xmm1, -24(%rsp) + jmp ..B1.38 +..B1.37: + movl $1065353216, -24(%rsp) +..B1.38: + cvtsd2ss %xmm0, %xmm0 + ret +..B1.39: + divsd %xmm5, %xmm0 + movl %eax, %eax + lea pi(%rip), %rdx + addsd (%rdx,%rax,8), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.40: + divsd %xmm5, %xmm0 + movaps %xmm0, %xmm2 + testl %edx, %edx + mulsd %xmm0, %xmm2 + movaps %xmm2, %xmm1 + mulsd %xmm2, %xmm1 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movsd .L_2il0floatpacket.10(%rip), %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm1, %xmm3 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + addsd .L_2il0floatpacket.11(%rip), %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm1, %xmm3 + addsd .L_2il0floatpacket.8(%rip), %xmm4 + addsd .L_2il0floatpacket.12(%rip), %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm1, %xmm3 + addsd .L_2il0floatpacket.9(%rip), %xmm4 + addsd .L_2il0floatpacket.13(%rip), %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm3, %xmm4 + mulsd %xmm0, %xmm4 + addsd %xmm4, %xmm0 + je ..B1.42 +..B1.41: + movl %eax, %eax + lea pi(%rip), %rdx + movsd (%rdx,%rax,8), %xmm1 + addsd %xmm1, %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.42: + cvtsd2ss %xmm0, %xmm0 +..B1.43: + ret +..B1.44: + movl %eax, %eax + lea _ones(%rip), %rcx + pxor %xmm1, %xmm1 + pxor %xmm2, %xmm2 + lea pi4n(%rip), %rsi + movsd .L_2il0floatpacket.0(%rip), %xmm4 + cmpl %eax, %edx + cvtss2sd (%rcx,%rax,4), %xmm1 + cvtss2sd (%rcx,%rdx,4), %xmm2 + mulsd %xmm1, %xmm0 + mulsd %xmm2, %xmm5 + movaps %xmm0, %xmm6 + addsd %xmm5, %xmm0 + subsd %xmm5, %xmm6 + xorps .L_2il0floatpacket.15(%rip), %xmm6 + divsd %xmm0, %xmm6 + movaps %xmm6, %xmm0 + mulsd %xmm6, %xmm0 + movaps %xmm0, %xmm5 + mulsd %xmm0, %xmm5 + mulsd %xmm5, %xmm4 + movsd .L_2il0floatpacket.3(%rip), %xmm3 + mulsd %xmm5, %xmm3 + addsd .L_2il0floatpacket.1(%rip), %xmm4 + mulsd %xmm5, %xmm4 + addsd .L_2il0floatpacket.4(%rip), %xmm3 + mulsd %xmm5, %xmm3 + addsd .L_2il0floatpacket.2(%rip), %xmm4 + mulsd %xmm0, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm3 + movsd (%rsi,%rdx,8), %xmm7 + addsd %xmm3, %xmm4 + mulsd %xmm4, %xmm6 + subsd %xmm6, %xmm7 + movaps %xmm7, %xmm0 + xorps .L_2il0floatpacket.15(%rip), %xmm0 + jne ..L4 + movaps %xmm7, %xmm0 +..L4: + cvtsd2ss %xmm0, %xmm0 + ret +..B1.45: + testl %edx, %edx + je ..B1.47 +..B1.46: + lea pi(%rip), %rdx + lea _small_value_64(%rip), %rcx + movsd (%rdx,%rax,8), %xmm0 + addsd (%rcx,%rax,8), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.47: + lea _zeros(%rip), %rdx + movss (%rdx,%rax,4), %xmm0 +..B1.48: + ret +..B1.49: + lea pi2(%rip), %rdx + lea _small_value_64(%rip), %rcx + movsd (%rdx,%rax,8), %xmm0 + addsd (%rcx,%rax,8), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type atan2f,@function + .size atan2f,.-atan2f + .data +# -- End atan2f + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.15: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.16: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,16 + .align 8 +.L_2il0floatpacket.0: + .long 0xd9d9aa33,0xbfb1c1c0 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x04ba093e,0xbfc24485 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x312dd43c,0xbfd55555 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x947e6edc,0x3fbbcbeb + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x700fa0b3,0x3fc9997b + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0xfff8f7db,0x3fefffff + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xa1fbc9d9,0x3f9a8eb6 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x713e98d0,0x3fb32474 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0xa367efd7,0x3fbc70d3 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x8eac5238,0x3fc99999 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x95b6793b,0xbfac6c73 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x306ebb4b,0xbfb73640 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0xe2eb2ece,0xbfc24920 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x5552abff,0xbfd55555 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +pi: + .long 0x54442d18,0x400921fb + .long 0x54442d18,0xc00921fb + .type pi,@object + .size pi,16 + .align 8 +pi34: + .long 0x7f3321d2,0x4002d97c + .long 0x7f3321d2,0xc002d97c + .type pi34,@object + .size pi34,16 + .align 8 +pi4: + .long 0x54442d18,0x3fe921fb + .long 0x54442d18,0xbfe921fb + .type pi4,@object + .size pi4,16 + .align 8 +pi2: + .long 0x54442d18,0x3ff921fb + .long 0x54442d18,0xbff921fb + .type pi2,@object + .size pi2,16 + .align 8 +pi4n: + .long 0x54442d18,0x3fe921fb + .long 0x7f3321d2,0xc002d97c + .type pi4n,@object + .size pi4n,16 + .align 4 +.L_2il0floatpacket.14: + .long 0x0d800000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,4 + .align 4 +.L_2il0floatpacket.17: + .long 0x3f800000 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,4 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_minnormf: + .long 0 + .long 940572672 + .type _minnormf,@object + .size _minnormf,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atan2l.S b/external/sgx_libm/intel64/atan2l.S new file mode 100644 index 0000000000..f49cbdbfec --- /dev/null +++ b/external/sgx_libm/intel64/atan2l.S @@ -0,0 +1,1202 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan2l.c" + .text +..TXTST0: +# -- Begin atan2l + .text + .align 16,0x90 + .globl atan2l +atan2l: +# parameter 1: 80 + %rsp +# parameter 2: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_atan2l.1: +..L2: + + subq $72, %rsp + .cfi_def_cfa_offset 80 + xorb %r8b, %r8b +..B1.2: + fnstcw 66(%rsp) +..B1.3: + movb 89(%rsp), %al + andb $-128, %al + shrb $7, %al + movb 105(%rsp), %dil + movzbl %al, %esi + andb $-128, %dil + movzwl 88(%rsp), %eax + andl $32767, %eax + movzwl 104(%rsp), %ecx + shrb $7, %dil + andl $32767, %ecx + cmpl $32767, %eax + je ..B1.80 +..B1.4: + cmpl $32767, %ecx + je ..B1.80 +..B1.5: + testl %eax, %eax + jne ..B1.7 +..B1.6: + cmpq $0, 80(%rsp) + je ..B1.9 +..B1.7: + testl %ecx, %ecx + jne ..B1.26 +..B1.8: + cmpq $0, 96(%rsp) + jne ..B1.26 +..B1.9: + movzwl 66(%rsp), %r9d + movl %r9d, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.13 +..B1.10: + orl $-64768, %r9d + movw %r9w, 64(%rsp) +..B1.11: + fldcw 64(%rsp) +..B1.12: + movb $1, %r8b +..B1.13: + testl %eax, %eax + jne ..B1.22 +..B1.14: + cmpq $0, 80(%rsp) + jne ..B1.21 +..B1.15: + testl %ecx, %ecx + jne ..B1.18 +..B1.16: + cmpq $0, 96(%rsp) + je ..B1.77 +..B1.17: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 56(%rsp) +..B1.18: + testb %dil, %dil + je ..B1.20 +..B1.19: + shlq $4, %rsi + lea _pi_00l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.23 +..B1.20: + lea _zeros(%rip), %rax + fldl (%rax,%rsi,8) + fstpt (%rsp) + jmp ..B1.23 +..B1.21: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 56(%rsp) +..B1.22: + shlq $4, %rsi + lea _pi_02l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) +..B1.23: + testb %r8b, %r8b + je ..B1.25 +..B1.24: + fldcw 66(%rsp) +..B1.25: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.26: + movzwl 66(%rsp), %r9d + movl %r9d, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.30 +..B1.27: + orl $-64768, %r9d + movw %r9w, 64(%rsp) +..B1.28: + fldcw 64(%rsp) +..B1.29: + movb $1, %r8b +..B1.30: + cmpl $8191, %ecx + jg ..B1.34 +..B1.31: + cmpl $8191, %eax + jg ..B1.33 +..B1.32: + fldt 96(%rsp) + lea _TWO_8192(%rip), %rax + fldt 80(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + movzwl 104(%rsp), %ecx + movzwl 88(%rsp), %eax + andl $32767, %ecx + fstpt (%rsp) + andl $32767, %eax + jmp ..B1.35 +..B1.33: + fldt 96(%rsp) + fldt 80(%rsp) + fstpt (%rsp) + jmp ..B1.38 +..B1.34: + fldt 96(%rsp) + fldt 80(%rsp) + fstpt (%rsp) +..B1.35: + cmpl $24575, %ecx + jl ..B1.38 +..B1.36: + cmpl $24575, %eax + jl ..B1.38 +..B1.37: + fldt (%rsp) + lea 16+_TWO_8192(%rip), %rax + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + movzwl 104(%rsp), %ecx + movzwl 88(%rsp), %eax + andl $32767, %ecx + fstpt (%rsp) + andl $32767, %eax +..B1.38: + fldt (%rsp) + lea _ones(%rip), %rdx + movzbl %dil, %r9d + fldl (%rdx,%rsi,8) + fmul %st, %st(1) + fldl (%rdx,%r9,8) + fmul %st(3), %st + fcomi %st(2), %st + jbe ..B1.60 +..B1.39: + lea 12(%rax), %r9d + cmpl %r9d, %ecx + jle ..B1.54 +..B1.40: + addl $75, %eax + cmpl %eax, %ecx + jle ..B1.47 +..B1.41: + fstp %st(2) + fstp %st(1) + fstp %st(0) + testb %dil, %dil + je ..B1.43 +..B1.42: + fstp %st(0) + shlq $4, %rsi + lea _pi_00l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.44 +..B1.43: + fldt (%rsp) + fdivp %st, %st(1) + fstpt (%rsp) +..B1.44: + testb %r8b, %r8b + je ..B1.46 +..B1.45: + fldcw 66(%rsp) +..B1.46: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.47: + fstp %st(3) + testb %dil, %dil + je ..B1.51 +..B1.48: + fxch %st(2) + fdivrp %st, %st(1) + lea 48+_P(%rip), %rax + fld %st(0) + lea 32+_P(%rip), %rcx + fmul %st(1), %st + lea 16+_P(%rip), %rdx + fld %st(0) + lea _P(%rip), %rsi + fmul %st(1), %st + testb %r8b, %r8b + movq __libm_atanl_table_128@GOTPCREL(%rip), %rdi + fxch %st(2) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rax) + fmul %st(3), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + fmulp %st, %st(4) + fldt (%rsi) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fmul %st, %st(1) + faddp %st, %st(1) + fsubrl 8200(%rdi) + faddl 8192(%rdi) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.50 +..B1.49: + fldcw 66(%rsp) +..B1.50: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.51: + fld %st(1) + lea 48+_P(%rip), %rax + fdiv %st(3), %st + lea 16+_P(%rip), %rcx + fld %st(0) + lea 32+_P(%rip), %rsi + fmul %st(1), %st + lea _P(%rip), %rdi + fxch %st(2) + fstpl 48(%rsp) + fld %st(1) + fmul %st(2), %st + lea _TWO_32H(%rip), %r9 + fldt (%rax) + testb %r8b, %r8b + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fld %st(4) + fldt (%rdi) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 32(%rsp) + fld %st(2) + fld %st(3) + fld %st(3) + fldl (%r9) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(5) + fld %st(5) + fadd %st(1), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(3) + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(3) + fsubr %st, %st(4) + fld %st(3) + fxch %st(2) + fdivrl (%rdx) + fmul %st, %st(3) + lea 8+_ones(%rip), %rdx + fld %st(3) + fadd %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(3) + fxch %st(3) + fmul %st, %st(4) + fld %st(5) + fmul %st(1), %st + fxch %st(2) + fadd %st, %st(6) + fmulp %st, %st(1) + fxch %st(4) + faddl (%rdx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + fsubrp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 32(%rsp) + faddp %st, %st(2) + faddp %st, %st(1) + fmull 48(%rsp) + fstpt (%rsp) + je ..B1.53 +..B1.52: + fldt 16(%rsp) + fstpt 32(%rsp) +..B1.110: + fldcw 66(%rsp) +..B1.53: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.54: + fstp %st(3) + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %rax + fmul %st(2), %st + lea _TWO_48H(%rip), %rcx + fdiv %st(3), %st + fld %st(2) + fxch %st(2) + fstpl 48(%rsp) + fld %st(2) + fld %st(4) + fld %st(5) + fldl (%rax) + lea 48+_P(%rip), %rsi + lea 16+_P(%rip), %r9 + lea 32+_P(%rip), %r10 + lea _P(%rip), %r11 + fadd %st, %st(4) + fxch %st(4) + fstpt 32(%rsp) + fldt 32(%rsp) + fsubp %st, %st(4) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(4) + fldl (%rcx) + fmul %st, %st(3) + movslq 32(%rsp), %rax + fxch %st(3) + fadd %st, %st(5) + shlq $4, %rax + fsubrp %st, %st(5) + fld %st(4) + testb %dil, %dil + fmul %st(4), %st + fxch %st(5) + fsubr %st, %st(6) + fxch %st(2) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(6) + fld %st(5) + fmul %st(4), %st + fadd %st(7), %st + fxch %st(4) + fmul %st, %st(7) + fxch %st(7) + fsubrp %st, %st(6) + fmul %st, %st(6) + fxch %st(6) + fsubrp %st, %st(1) + fxch %st(5) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fdivrl (%rdx) + lea 8+_ones(%rip), %rdx + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt (%rsp) + fldt (%rsp) + fsubp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(4) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(2) + fmul %st, %st(4) + fld %st(0) + fmul %st(6), %st + fxch %st(6) + fadd %st(7), %st + fxch %st(7) + fmulp %st, %st(1) + fxch %st(4) + faddl (%rdx) + faddp %st, %st(1) + fmulp %st, %st(2) + fsubp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 96(%rsp) + fldt 96(%rsp) + fld %st(1) + fmul %st(3), %st + fld %st(2) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(3) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rsi) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + fmulp %st, %st(3) + fldt (%r11) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl 48(%rsp) + je ..B1.56 +..B1.55: + negq %rax + fld %st(2) + movq __libm_atanl_table_128@GOTPCREL(%rip), %rdx + fldl 8192(%rdx,%rax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fldl 8200(%rdx,%rax) + fsubp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.57 +..B1.56: + movq __libm_atanl_table_128@GOTPCREL(%rip), %rdx + fld %st(2) + fldl (%rax,%rdx) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 8(%rax,%rdx) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%rsp) +..B1.57: + testb %r8b, %r8b + je ..B1.59 +..B1.58: + fldt (%rsp) + fstpt 32(%rsp) +..B1.111: + fldcw 66(%rsp) +..B1.59: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.60: + fstp %st(3) + lea 12(%rcx), %r9d + cmpl %r9d, %eax + jle ..B1.71 +..B1.61: + addl $75, %ecx + cmpl %ecx, %eax + jle ..B1.65 +..B1.62: + fstp %st(1) + fstp %st(1) + fstp %st(0) + shlq $4, %rsi + lea _pi_02l(%rip), %rax + lea _small_value_80(%rip), %rdx + testb %r8b, %r8b + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) + je ..B1.64 +..B1.63: + fldcw 66(%rsp) +..B1.64: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.65: + fxch %st(1) + fdivrp %st, %st(2) + lea 48+_P(%rip), %rax + fld %st(1) + lea 32+_P(%rip), %rcx + fmul %st(2), %st + lea 16+_P(%rip), %rdx + fld %st(0) + lea _P(%rip), %rsi + fmul %st(1), %st + testb %dil, %dil + movq __libm_atanl_table_128@GOTPCREL(%rip), %r9 + fxch %st(3) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rax) + fmul %st(4), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rcx) + fmulp %st, %st(5) + fldt (%rsi) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fmul %st, %st(2) + faddp %st, %st(2) + fldl 4096(%r9) + fstpt (%rsp) + fldl 4104(%r9) + je ..B1.67 +..B1.66: + faddp %st, %st(2) + fldt (%rsp) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.68 +..B1.67: + fsubp %st, %st(2) + fldt (%rsp) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.68: + testb %r8b, %r8b + je ..B1.70 +..B1.69: + fldcw 66(%rsp) +..B1.70: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.71: + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %rax + fmul %st(3), %st + lea _TWO_48H(%rip), %rcx + fdiv %st(2), %st + fld %st(3) + fxch %st(2) + fstpl 48(%rsp) + fld %st(2) + fld %st(3) + lea 48+_P(%rip), %rsi + fldl (%rax) + lea 16+_P(%rip), %r9 + lea 32+_P(%rip), %r10 + lea _P(%rip), %r11 + fadd %st, %st(3) + fxch %st(3) + fstpt 32(%rsp) + fldt 32(%rsp) + fsubp %st, %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(3) + fld %st(5) + fldl (%rcx) + fmul %st, %st(5) + movslq 32(%rsp), %rax + fxch %st(1) + fadd %st(5), %st + shlq $4, %rax + fsubp %st, %st(5) + testb %dil, %dil + fxch %st(4) + fsubr %st, %st(6) + fld %st(6) + fmul %st(4), %st + fxch %st(3) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(5) + fxch %st(2) + fadd %st(5), %st + fld %st(1) + fmul %st(4), %st + fadd %st(3), %st + fxch %st(4) + fmul %st, %st(6) + fxch %st(6) + fsubrp %st, %st(7) + fxch %st(2) + fmulp %st, %st(5) + fsubp %st, %st(4) + fld %st(1) + fadd %st(1), %st + fdivrl (%rdx) + lea 8+_ones(%rip), %rdx + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fstpt (%rsp) + fldt (%rsp) + fsubp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fld %st(3) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + fmul %st(4), %st + fld %st(4) + fmul %st(7), %st + fxch %st(6) + fadd %st, %st(7) + fmulp %st, %st(5) + faddl (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 96(%rsp) + fldt 96(%rsp) + fld %st(1) + fmul %st(3), %st + fld %st(2) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(3) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rsi) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + fmulp %st, %st(3) + fldt (%r11) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl 48(%rsp) + je ..B1.73 +..B1.72: + movq __libm_atanl_table_128@GOTPCREL(%rip), %rdx + fld %st(2) + fldl 4096(%rdx,%rax) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(2) + faddl 4104(%rdx,%rax) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.74 +..B1.73: + negq %rax + fld %st(2) + movq __libm_atanl_table_128@GOTPCREL(%rip), %rdx + fldl 4096(%rdx,%rax) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fldl 4104(%rdx,%rax) + fsubp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + fstpt 16(%rsp) +..B1.74: + testb %r8b, %r8b + je ..B1.76 +..B1.75: + fldt (%rsp) + fstpt 32(%rsp) +..B1.112: + fldcw 66(%rsp) +..B1.76: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.77: + testb %dil, %dil + je ..B1.79 +..B1.78: + shlq $4, %rsi + lea _pi_00l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.23 +..B1.79: + lea _zeros(%rip), %rax + fldl (%rax,%rsi,8) + fstpt (%rsp) + jmp ..B1.23 +..B1.80: + movzwl 66(%rsp), %r9d + movl %r9d, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.84 +..B1.81: + orl $-64768, %r9d + movw %r9w, 64(%rsp) +..B1.82: + fldcw 64(%rsp) +..B1.83: + movb $1, %r8b +..B1.84: + cmpl $32767, %eax + je ..B1.107 +..B1.85: + cmpl $32767, %ecx + je ..B1.105 +..B1.86: + testl %eax, %eax + jne ..B1.89 +..B1.87: + cmpl $0, 84(%rsp) + jne ..B1.92 +..B1.88: + cmpl $0, 80(%rsp) + jne ..B1.92 +..B1.89: + testl %ecx, %ecx + jne ..B1.93 +..B1.90: + cmpl $0, 100(%rsp) + jne ..B1.92 +..B1.91: + cmpl $0, 96(%rsp) + je ..B1.94 +..B1.92: + lea _smallest_value_64(%rip), %rdx + movq (%rdx), %r9 + movq %r9, 56(%rsp) +..B1.93: + cmpl $32767, %ecx + je ..B1.98 +..B1.94: + shlq $4, %rsi + lea _pi_02l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) +..B1.95: + testb %r8b, %r8b + je ..B1.97 +..B1.96: + fldcw 66(%rsp) +..B1.97: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.98: + cmpl $32767, %eax + je ..B1.102 +..B1.99: + testb %dil, %dil + je ..B1.101 +..B1.100: + shlq $4, %rsi + lea _pi_00l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.95 +..B1.101: + lea _zeros(%rip), %rax + fldl (%rax,%rsi,8) + fstpt (%rsp) + jmp ..B1.95 +..B1.102: + shlq $4, %rsi + testb %dil, %dil + je ..B1.104 +..B1.103: + lea _pi_34l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.95 +..B1.104: + lea _pi_04l(%rip), %rax + lea _small_value_80(%rip), %rdx + fldt (%rsi,%rax) + fldt (%rsi,%rdx) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.95 +..B1.105: + movq $0x8000000000000000, %rdx + cmpq 96(%rsp), %rdx + je ..B1.86 +..B1.106: + fldt 96(%rsp) + fldt 80(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.95 +..B1.107: + movq $0x8000000000000000, %rdx + cmpq 80(%rsp), %rdx + jne ..B1.106 + jmp ..B1.85 + .align 16,0x90 + .cfi_endproc + .type atan2l,@function + .size atan2l,.-atan2l + .data +# -- End atan2l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 2 +_pi_00l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49152 + .word 0 + .word 0 + .word 0 + .type _pi_00l,@object + .size _pi_00l,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_pi_02l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _pi_02l,@object + .size _pi_02l,32 + .align 2 +_TWO_8192: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .type _TWO_8192,@object + .size _TWO_8192,32 + .align 2 +_P: + .word 43664 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 43235 + .word 52379 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59507 + .word 38278 + .word 9340 + .word 37449 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 9132 + .word 55602 + .word 8665 + .word 58245 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,64 + .align 2 +_pi_34l: + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 49152 + .word 0 + .word 0 + .word 0 + .type _pi_34l,@object + .size _pi_34l,32 + .align 2 +_pi_04l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49150 + .word 0 + .word 0 + .word 0 + .type _pi_04l,@object + .size _pi_04l,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atan_gen.S b/external/sgx_libm/intel64/atan_gen.S new file mode 100644 index 0000000000..9e80c811c4 --- /dev/null +++ b/external/sgx_libm/intel64/atan_gen.S @@ -0,0 +1,887 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atan_gen.c" + .text +..TXTST0: +# -- Begin atan + .text + .align 16,0x90 + .globl atan +atan: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_atan.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + movsd %xmm0, (%rsp) +..B1.2: + movlpd BMASK1(%rip), %xmm3 + xorpd %xmm2, %xmm2 + movlpd BMASK2(%rip), %xmm6 + movlpd SGNMASK(%rip), %xmm7 + pextrw $3, %xmm0, %edx + movl %edx, %eax + andl $32767, %edx + movl $16448, %ecx + pinsrw $3, %ecx, %xmm2 + andpd %xmm7, %xmm0 + xorpd %xmm7, %xmm7 + movq %xmm0, %xmm1 + andpd %xmm0, %xmm3 + pinsrw $3, %ecx, %xmm7 + orpd %xmm6, %xmm3 + movlpd ONEMASK(%rip), %xmm5 + subl $16288, %edx + cmpl $1119, %edx + ja .L_2TAG_PACKET_0.0.1 + cmpsd $6, %xmm0, %xmm2 + minsd %xmm7, %xmm3 + andpd %xmm2, %xmm5 + andpd %xmm2, %xmm0 + mulsd %xmm3, %xmm1 + subsd %xmm3, %xmm0 + addsd %xmm5, %xmm1 + divsd %xmm1, %xmm0 + pextrw $3, %xmm3, %edx + subl $16287, %edx + movlpd a2(%rip), %xmm2 + movlpd b2(%rip), %xmm4 + andl $32768, %eax + pinsrw $3, %eax, %xmm7 + addl %edx, %edx + lea atan_tbl(%rip), %r8 + movlpd (%r8,%rdx,8), %xmm6 + addl $1, %edx + movlpd (%r8,%rdx,8), %xmm5 + xorpd %xmm7, %xmm5 + xorpd %xmm7, %xmm6 + movq %xmm0, %xmm1 + xorpd %xmm7, %xmm1 + movq %xmm1, %xmm3 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm2 + addsd %xmm0, %xmm4 + addsd %xmm6, %xmm1 + subsd %xmm1, %xmm6 + addsd %xmm3, %xmm6 + addsd 8+a2(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm3, %xmm0 + addsd %xmm5, %xmm6 + mulsd %xmm2, %xmm0 + addsd 8+b2(%rip), %xmm4 + mulsd %xmm4, %xmm0 + addsd %xmm6, %xmm0 + addsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_0.0.1: + addl $944, %edx + cmpl $2063, %edx + ja .L_2TAG_PACKET_2.0.1 + movlpd a2(%rip), %xmm4 + movlpd b2(%rip), %xmm7 + movlpd (%rsp), %xmm0 + mulsd %xmm1, %xmm1 + movlpd 8+a2(%rip), %xmm2 + movlpd 8+b2(%rip), %xmm5 + mulsd %xmm1, %xmm4 + addsd %xmm1, %xmm7 + movq %xmm1, %xmm6 + mulsd %xmm0, %xmm1 + addsd %xmm4, %xmm2 + mulsd %xmm6, %xmm7 + mulsd %xmm1, %xmm2 + addsd %xmm5, %xmm7 + mulsd %xmm7, %xmm2 + addsd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_2.0.1: + addl $15344, %edx + cmpl $17392, %edx + jae .L_2TAG_PACKET_3.0.1 + movlpd (%rsp), %xmm0 + movlpd (%rsp), %xmm1 + cmpl $16, %edx + jae .L_2TAG_PACKET_1.0.1 + mulsd %xmm0, %xmm1 + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_3.0.1: + movlpd (%rsp), %xmm4 + movlpd SGNMASK(%rip), %xmm0 + movlpd pi_table(%rip), %xmm2 + movlpd 8+pi_table(%rip), %xmm3 + movd %xmm1, %eax + psrlq $32, %xmm1 + movd %xmm1, %edx + cmpl $2146435072, %edx + jae .L_2TAG_PACKET_4.0.1 +.L_2TAG_PACKET_5.0.1: + andnpd %xmm4, %xmm0 + orpd %xmm0, %xmm2 + orpd %xmm3, %xmm0 + addsd %xmm2, %xmm0 + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_4.0.1: + subl $2146435072, %edx + orl %edx, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_5.0.1 + movq %xmm4, %xmm0 + addsd %xmm0, %xmm0 +.L_2TAG_PACKET_1.0.1: +..B1.3: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type atan,@function + .size atan,.-atan + .data +# -- End atan + .section .rodata, "a" + .align 4 + .align 4 +BMASK1: + .long 0 + .long 4294901760 + .type BMASK1,@object + .size BMASK1,8 + .align 4 +BMASK2: + .long 0 + .long 32768 + .type BMASK2,@object + .size BMASK2,8 + .align 4 +SGNMASK: + .long 4294967295 + .long 2147483647 + .type SGNMASK,@object + .size SGNMASK,8 + .align 4 +ONEMASK: + .long 0 + .long 1072693248 + .type ONEMASK,@object + .size ONEMASK,8 + .align 4 +a2: + .long 2006262985 + .long 1069310863 + .long 2358449471 + .long 3217342131 + .type a2,@object + .size a2,16 + .align 4 +b2: + .long 3845454352 + .long 1069952297 + .long 2829679149 + .long 1073771565 + .type b2,@object + .size b2,16 + .align 4 +atan_tbl: + .long 0 + .long 0 + .long 0 + .long 0 + .long 3819695742 + .long 1067482761 + .long 2398680355 + .long 3155462074 + .long 2998791009 + .long 1067548225 + .long 3868465248 + .long 3157182472 + .long 3339424991 + .long 1067613680 + .long 3296670360 + .long 1010752543 + .long 2710002256 + .long 1067679126 + .long 3403896007 + .long 1010910768 + .long 3275701428 + .long 1067744562 + .long 119959933 + .long 1011482843 + .long 2908636881 + .long 1067809988 + .long 2464489612 + .long 1011545526 + .long 3777889398 + .long 1067875403 + .long 3262682165 + .long 1009703919 + .long 3759667419 + .long 1067940807 + .long 1838130851 + .long 3157373556 + .long 732369940 + .long 1068006200 + .long 1203428313 + .long 1010055371 + .long 1166616461 + .long 1068071580 + .long 2901274051 + .long 3158549977 + .long 2945472892 + .long 1068136947 + .long 3726120658 + .long 1009762715 + .long 3954480976 + .long 1068202301 + .long 1289173457 + .long 1009429861 + .long 2081752829 + .long 1068267642 + .long 1836909874 + .long 1006212095 + .long 3807999788 + .long 1068332968 + .long 2172459940 + .long 3156162078 + .long 2731789884 + .long 1068398280 + .long 3450718392 + .long 3159216547 + .long 1044477961 + .long 1068463577 + .long 2230553229 + .long 1011424339 + .long 1486930287 + .long 1068530218 + .long 2861547474 + .long 1012041376 + .long 2293016881 + .long 1068595466 + .long 136843272 + .long 1012684797 + .long 201518157 + .long 1068660680 + .long 63231984 + .long 1012427198 + .long 4054234584 + .long 1068725856 + .long 3927006960 + .long 1011878955 + .long 1246477213 + .long 1068790995 + .long 1494265652 + .long 3155219350 + .long 678186699 + .long 1068856093 + .long 1264361424 + .long 3159256693 + .long 2690594995 + .long 1068921148 + .long 3906996379 + .long 1009288267 + .long 3362611517 + .long 1068986159 + .long 1650970041 + .long 3158331771 + .long 3102162111 + .long 1069051124 + .long 365917035 + .long 3160264153 + .long 2352611067 + .long 1069116041 + .long 4008970190 + .long 3159478182 + .long 1594134794 + .long 1069180908 + .long 466690178 + .long 1012526501 + .long 1345079306 + .long 1069245723 + .long 2268273568 + .long 3160164092 + .long 2163300970 + .long 1069310484 + .long 2750834800 + .long 3158113482 + .long 352522716 + .long 1069375190 + .long 1750411372 + .long 1011790845 + .long 848541647 + .long 1069439838 + .long 2164207573 + .long 1011698350 + .long 40647312 + .long 1069504427 + .long 2949165434 + .long 3159107267 + .long 2216766270 + .long 1069574357 + .long 2197920765 + .long 3161055954 + .long 1090914384 + .long 1069638757 + .long 2330454674 + .long 1013365998 + .long 387601244 + .long 1069703022 + .long 3185681168 + .long 1013434071 + .long 3991640484 + .long 1069767144 + .long 1313211590 + .long 3161087959 + .long 3322489502 + .long 1069831118 + .long 3013977995 + .long 1013053011 + .long 3121698570 + .long 1069894936 + .long 4069015667 + .long 1013023362 + .long 4289964660 + .long 1069958591 + .long 1736191156 + .long 3158266731 + .long 3903312386 + .long 1070022077 + .long 1833592413 + .long 3159731471 + .long 3818449864 + .long 1070085387 + .long 851036429 + .long 3159730451 + .long 2097480306 + .long 1070148515 + .long 3506390884 + .long 3160462302 + .long 1611694502 + .long 1070211454 + .long 2785735540 + .long 3160465144 + .long 1464694796 + .long 1070274198 + .long 4229277299 + .long 3159907000 + .long 1299612775 + .long 1070336741 + .long 4116653788 + .long 3160427739 + .long 1310544789 + .long 1070399077 + .long 1064430331 + .long 1013218202 + .long 2253168030 + .long 1070461200 + .long 1405044609 + .long 3157623179 + .long 1159567373 + .long 1070523105 + .long 2353445521 + .long 3159992176 + .long 1359373750 + .long 1070605818 + .long 1748171336 + .long 3161879263 + .long 908341706 + .long 1070667034 + .long 3372710815 + .long 3161775245 + .long 1743027350 + .long 1070727765 + .long 687089934 + .long 3160507171 + .long 2055355646 + .long 1070787992 + .long 2392855242 + .long 1013682469 + .long 690426164 + .long 1070847697 + .long 1103926666 + .long 1014052810 + .long 1483247847 + .long 1070906862 + .long 2082645847 + .long 3161345479 + .long 392040270 + .long 1070965472 + .long 2407720023 + .long 1014053754 + .long 2673846014 + .long 1071023511 + .long 1293605532 + .long 3158464385 + .long 1384215810 + .long 1071080967 + .long 2446095872 + .long 3159216407 + .long 3101660631 + .long 1071137826 + .long 698040758 + .long 1014855328 + .long 2094057058 + .long 1071194078 + .long 2282048339 + .long 1014040385 + .long 1712750594 + .long 1071249712 + .long 1204372378 + .long 3162276464 + .long 1411515787 + .long 1071304719 + .long 949080808 + .long 1015006403 + .long 931538085 + .long 1071359091 + .long 3027127039 + .long 1014307233 + .long 179139065 + .long 1071412821 + .long 4285547492 + .long 3161934731 + .long 3387721259 + .long 1071465902 + .long 373225773 + .long 1013486625 + .long 2132236852 + .long 1071544299 + .long 3250533429 + .long 1014031677 + .long 1942070284 + .long 1071645596 + .long 1237964179 + .long 3163239113 + .long 1532707802 + .long 1071695380 + .long 330645583 + .long 1012495610 + .long 2294184979 + .long 1071743834 + .long 3959472897 + .long 1015833116 + .long 3805060714 + .long 1071790961 + .long 2671256142 + .long 1013727772 + .long 2215037898 + .long 1071836770 + .long 2683359117 + .long 1015831902 + .long 483661594 + .long 1071881273 + .long 836288326 + .long 3162648643 + .long 1534679894 + .long 1071924486 + .long 373258696 + .long 3162470096 + .long 1538714628 + .long 1071966430 + .long 3199433068 + .long 1015325501 + .long 527642555 + .long 1072007128 + .long 3636832592 + .long 3161843145 + .long 291339150 + .long 1072046605 + .long 890169537 + .long 3160586117 + .long 2450210201 + .long 1072084888 + .long 1636353294 + .long 3163193400 + .long 2411367951 + .long 1072122007 + .long 374899873 + .long 1011331750 + .long 681549971 + .long 1072157992 + .long 506411689 + .long 1015373954 + .long 1466745541 + .long 1072192873 + .long 2143860931 + .long 1013364334 + .long 2845622366 + .long 1072226682 + .long 2869178209 + .long 3162423682 + .long 2838871438 + .long 1072275456 + .long 3742223599 + .long 1014338577 + .long 4200275274 + .long 1072337034 + .long 1566539915 + .long 3161839550 + .long 3034733530 + .long 1072394897 + .long 652621408 + .long 3162261964 + .long 3207412993 + .long 1072449290 + .long 3206124665 + .long 1014408733 + .long 624461478 + .long 1072500450 + .long 932437485 + .long 1015204343 + .long 767665908 + .long 1072548600 + .long 1037911952 + .long 3163527627 + .long 1110773639 + .long 1072593952 + .long 2371517912 + .long 3160465741 + .long 1940828530 + .long 1072636704 + .long 2731408428 + .long 3162895795 + .long 1911329388 + .long 1072677041 + .long 1773089615 + .long 3159569267 + .long 1764715788 + .long 1072704191 + .long 691346949 + .long 3164069946 + .long 3332979233 + .long 1072722195 + .long 3550733983 + .long 1014770628 + .long 1321870254 + .long 1072739231 + .long 1415315820 + .long 1016224052 + .long 3657429030 + .long 1072755365 + .long 3910539033 + .long 1015966402 + .long 4197624557 + .long 1072770661 + .long 2333399254 + .long 3164546480 + .long 1512059493 + .long 1072785177 + .long 2701510318 + .long 1016178092 + .long 453379037 + .long 1072798965 + .long 4046344253 + .long 3162814364 + .long 1942345162 + .long 1072818388 + .long 621134147 + .long 1016335195 + .long 4210176273 + .long 1072842164 + .long 2701013387 + .long 3164326619 + .long 4185644010 + .long 1072863795 + .long 4163699341 + .long 1016203112 + .long 679688788 + .long 1072883543 + .long 4147276762 + .long 1014066750 + .long 29432865 + .long 1072901630 + .long 970415797 + .long 1016902063 + .long 4070721092 + .long 1072918247 + .long 2539004411 + .long 3163736096 + .long 2252468843 + .long 1072933561 + .long 3424082887 + .long 3163407177 + .long 2929724825 + .long 1072947712 + .long 3661482235 + .long 3163846989 + .long 1377513368 + .long 1072960824 + .long 3987926680 + .long 1013647908 + .long 1031632908 + .long 1072973003 + .long 3672217151 + .long 1016614619 + .long 2516508130 + .long 1072984342 + .long 545855020 + .long 3162728930 + .long 3792452178 + .long 1072994923 + .long 3420119467 + .long 1016471430 + .long 3147791459 + .long 1073004818 + .long 1342204979 + .long 1013937254 + .long 999189752 + .long 1073014090 + .long 1006335472 + .long 3162850919 + .long 711011011 + .long 1073022794 + .long 4633488 + .long 3162966895 + .long 15640363 + .long 1073030980 + .long 1686389560 + .long 3164376226 + .long 1218463589 + .long 1073042382 + .long 1526837110 + .long 3163533985 + .long 2538470555 + .long 1073056144 + .long 2273304406 + .long 3163784996 + .long 1229720947 + .long 1073068489 + .long 2971628206 + .long 3162356540 + .long 3115427016 + .long 1073079621 + .long 4215132957 + .long 3164282762 + .long 4030612557 + .long 1073089709 + .long 1913251691 + .long 3163671292 + .long 2728521257 + .long 1073098892 + .long 2861089500 + .long 1015454459 + .long 1118696283 + .long 1073107285 + .long 1628948053 + .long 1016179658 + .long 2682711255 + .long 1073114984 + .long 2906306266 + .long 1014142643 + .long 2073898081 + .long 1073122072 + .long 1322740454 + .long 3164497217 + .long 1403700297 + .long 1073128618 + .long 416137895 + .long 3162781466 + .long 2502685617 + .long 1073134681 + .long 3242008732 + .long 1014593495 + .long 1531926851 + .long 1073140313 + .long 1362708094 + .long 1016517604 + .long 3572814411 + .long 1073145557 + .long 3709790527 + .long 1012646874 + .long 1695536111 + .long 1073150453 + .long 3980346340 + .long 1016705136 + .long 2363057203 + .long 1073155033 + .long 2551194792 + .long 1012569695 + .long 2873365682 + .long 1073159327 + .long 3181154748 + .long 1017041450 + .long 1053384691 + .long 1073165288 + .long 3074536879 + .long 1016965660 + .long 3270542712 + .long 1073172451 + .long 2535319415 + .long 3163051778 + .long 1353631484 + .long 1073178850 + .long 1173833755 + .long 1015534537 + .long 3511218460 + .long 1073184599 + .long 1243608109 + .long 3161592122 + .long 4121259284 + .long 1073189793 + .long 398584912 + .long 3163829923 + .long 1193862106 + .long 1073194509 + .long 1873745539 + .long 3163802819 + .long 3861949790 + .long 1073198808 + .long 3841261147 + .long 1015587248 + .long 1486904578 + .long 1073202745 + .long 1634726776 + .long 3163847886 + .long 2879153715 + .long 1073206362 + .long 200456242 + .long 3164138657 + .long 385353253 + .long 1073209698 + .long 1186355517 + .long 1014887155 + .long 1125865839 + .long 1073212783 + .long 203561262 + .long 3161244927 + .long 1221361475 + .long 1073215645 + .long 3382476563 + .long 1014936138 + .long 2077323573 + .long 1073218307 + .long 1005121005 + .long 3164430752 + .long 215611373 + .long 1073220790 + .long 353198764 + .long 3164485137 + .long 2347419265 + .long 1073223110 + .long 1103143360 + .long 1016542137 + .long 1379112765 + .long 1073225284 + .long 381583533 + .long 3162870833 + .long 3891198463 + .long 1073228298 + .long 1771275754 + .long 1014654681 + .long 3395914051 + .long 1073231917 + .long 2350900914 + .long 3164013978 + .long 2799919478 + .long 1073235146 + .long 2893950164 + .long 3163260901 + .long 1138673476 + .long 1073238045 + .long 2622204785 + .long 3164174388 + .long 3408855940 + .long 1073240661 + .long 2800881650 + .long 1016008624 + .long 2044858738 + .long 1073243035 + .long 604544785 + .long 1017022901 + .long 2578795176 + .long 1073245198 + .long 2557332925 + .long 1016135165 + .long 4196285314 + .long 1073247177 + .long 2032365307 + .long 1016194735 + .long 224877747 + .long 1073248996 + .long 497926916 + .long 1016947111 + .long 3271386490 + .long 1073250671 + .long 2689994846 + .long 1016631513 + .long 813635989 + .long 1073252221 + .long 747035277 + .long 3164530136 + .long 369829519 + .long 1073253658 + .long 2182033858 + .long 3163190340 + .long 1187679052 + .long 1073254994 + .long 673954443 + .long 1016149821 + .long 4232586098 + .long 1073256239 + .long 497775200 + .long 3162179015 + .long 426690558 + .long 1073257404 + .long 3063343247 + .long 1016865578 + .long 1624065902 + .long 1073258494 + .long 1354224996 + .long 3163503778 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .type atan_tbl,@object + .size atan_tbl,2592 + .align 4 +pi_table: + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .type pi_table,@object + .size pi_table,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atandl_table.S b/external/sgx_libm/intel64/atandl_table.S new file mode 100644 index 0000000000..534f96c90f --- /dev/null +++ b/external/sgx_libm/intel64/atandl_table.S @@ -0,0 +1,2099 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atandl_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .globl __libm_atandl_table_128 +__libm_atandl_table_128: + .long 0 + .long 0 + .long 0 + .long 0 + .long 3896508416 + .long 1071424949 + .long 2497855885 + .long 1035107781 + .long 1447034880 + .long 1072473411 + .long 1733066939 + .long 3185173141 + .long 1421869056 + .long 1073052515 + .long 1368774744 + .long 1038726731 + .long 1314914304 + .long 1073521529 + .long 3636885973 + .long 3186244272 + .long 1199570944 + .long 1073866069 + .long 2275810035 + .long 3185989885 + .long 476053504 + .long 1074100319 + .long 3721769433 + .long 3184582046 + .long 3514826752 + .long 1074334397 + .long 1919096566 + .long 3184722268 + .long 845152256 + .long 1074568277 + .long 2005889037 + .long 1036405998 + .long 2545942528 + .long 1074796164 + .long 4215566178 + .long 1040782263 + .long 4057989120 + .long 1074912862 + .long 2215314489 + .long 1040552811 + .long 3430940672 + .long 1075029419 + .long 314220031 + .long 3187779646 + .long 1717567488 + .long 1075145821 + .long 2152308088 + .long 1040271717 + .long 455081984 + .long 1075262054 + .long 1186928436 + .long 1040902706 + .long 1694498816 + .long 1075378104 + .long 4227739998 + .long 1040491905 + .long 3747610624 + .long 1075493958 + .long 535382953 + .long 1040666985 + .long 1226833920 + .long 1075609604 + .long 1790336138 + .long 1040185867 + .long 2260729856 + .long 1075725027 + .long 3899937368 + .long 3188375434 + .long 3525312512 + .long 1075839595 + .long 4053544535 + .long 3185741100 + .long 3957325824 + .long 1075897065 + .long 4030890856 + .long 1040553080 + .long 3248488448 + .long 1075954405 + .long 1333464106 + .long 3189137055 + .long 452984832 + .long 1076011609 + .long 3448918206 + .long 3189528508 + .long 3615490048 + .long 1076068669 + .long 608092114 + .long 1041523725 + .long 4020240384 + .long 1076125581 + .long 1336102440 + .long 3188870826 + .long 1960837120 + .long 1076182339 + .long 2391933274 + .long 3189275321 + .long 2470445056 + .long 1076238936 + .long 4283795024 + .long 1041937846 + .long 2451570688 + .long 1076295367 + .long 4217000778 + .long 1039765656 + .long 3560964096 + .long 1076351626 + .long 3936906987 + .long 3182578922 + .long 3640655872 + .long 1076407708 + .long 1439536878 + .long 1040659594 + .long 1023410176 + .long 1076463608 + .long 2552585681 + .long 3189615238 + .long 3122659328 + .long 1076519319 + .long 31715936 + .long 1042073699 + .long 689963008 + .long 1076574838 + .long 3139108801 + .long 1040611849 + .long 2164260864 + .long 1076630158 + .long 1139819401 + .long 3187965768 + .long 3623878656 + .long 1076685275 + .long 3513262155 + .long 1039670426 + .long 1679818752 + .long 1076740185 + .long 728891110 + .long 1041952788 + .long 2069889024 + .long 1076794882 + .long 3614319306 + .long 1039599785 + .long 2480930816 + .long 1076849362 + .long 1879438446 + .long 3188546042 + .long 2720006144 + .long 1076895586 + .long 4246516390 + .long 1042916956 + .long 574619648 + .long 1076922603 + .long 3568262924 + .long 1040145602 + .long 3061841920 + .long 1076949504 + .long 290418758 + .long 3187677511 + .long 1539309568 + .long 1076976289 + .long 635731916 + .long 1042641148 + .long 532676608 + .long 1077002955 + .long 4225033962 + .long 3189573420 + .long 545259520 + .long 1077029500 + .long 2007583995 + .long 1042491810 + .long 2369781760 + .long 1077055922 + .long 2061076001 + .long 3190167169 + .long 2774532096 + .long 1077082220 + .long 2608380742 + .long 1042446121 + .long 3112173568 + .long 1077108392 + .long 2901961231 + .long 1042075808 + .long 715128832 + .long 1077134437 + .long 3828632392 + .long 3189418038 + .long 1782579200 + .long 1077160352 + .long 519110621 + .long 1041924126 + .long 4206886912 + .long 1077186136 + .long 2078221814 + .long 1039357043 + .long 1858076672 + .long 1077211789 + .long 2404314454 + .long 3190701797 + .long 1763704832 + .long 1077237308 + .long 1129624783 + .long 3189333294 + .long 2638217216 + .long 1077262692 + .long 1872508293 + .long 3187027668 + .long 3464495104 + .long 1077287940 + .long 2518581518 + .long 1039154339 + .long 3493855232 + .long 1077313051 + .long 2874645533 + .long 3188678970 + .long 2241855488 + .long 1077338024 + .long 182480744 + .long 3187988055 + .long 3783262208 + .long 1077362857 + .long 41710967 + .long 3189176765 + .long 3860856832 + .long 1077387550 + .long 3921914980 + .long 1040188295 + .long 2770337792 + .long 1077412102 + .long 2195237132 + .long 1043018421 + .long 1061158912 + .long 1077436512 + .long 1866130671 + .long 1042885968 + .long 3825205248 + .long 1077460778 + .long 2099274145 + .long 1043277518 + .long 3519021056 + .long 1077484901 + .long 2434136291 + .long 3190760305 + .long 1423966208 + .long 1077508880 + .long 786043090 + .long 3189674834 + .long 3361734656 + .long 1077532713 + .long 1735814367 + .long 1041228653 + .long 2501902336 + .long 1077556401 + .long 2532076405 + .long 1041674477 + .long 832569344 + .long 1077579943 + .long 1067893357 + .long 1041790735 + .long 568328192 + .long 1077603338 + .long 42353869 + .long 1040967961 + .long 4143972352 + .long 1077626585 + .long 3035382168 + .long 1043228732 + .long 1329594368 + .long 1077649686 + .long 2622169537 + .long 1042608561 + .long 3579838464 + .long 1077672638 + .long 3279279360 + .long 1039969098 + .long 1082130432 + .long 1077695443 + .long 152088799 + .long 1042154031 + .long 1409286144 + .long 1077718099 + .long 1577179566 + .long 1043010748 + .long 3743416320 + .long 1077740606 + .long 164745699 + .long 3187116092 + .long 3162505216 + .long 1077762965 + .long 3525309094 + .long 3189988831 + .long 3525312512 + .long 1077785175 + .long 790013831 + .long 3189219565 + .long 287309824 + .long 1077807237 + .long 3014793090 + .long 3190791112 + .long 1965031424 + .long 1077829149 + .long 2967000185 + .long 3189805146 + .long 73400320 + .long 1077850913 + .long 923692587 + .long 1033248306 + .long 3477078016 + .long 1077872527 + .long 797568562 + .long 1037083943 + .long 4024434688 + .long 1077893993 + .long 1829946853 + .long 1043203029 + .long 2319450112 + .long 1077915311 + .long 1559006781 + .long 3189221910 + .long 1704984576 + .long 1077936304 + .long 2364400925 + .long 3186972503 + .long 4104126464 + .long 1077946814 + .long 2278278095 + .long 3191749589 + .long 2438987776 + .long 1077957251 + .long 3465285131 + .long 1042435970 + .long 1606418432 + .long 1077967614 + .long 1692530062 + .long 1043648146 + .long 2273312768 + .long 1077977903 + .long 4155795398 + .long 1043918312 + .long 878706688 + .long 1077988119 + .long 1476207680 + .long 1043900034 + .long 2516582400 + .long 1077998261 + .long 2925970384 + .long 1039575776 + .long 3751804928 + .long 1078008330 + .long 2856171667 + .long 3191395954 + .long 1207959552 + .long 1078018327 + .long 2148760563 + .long 1039453383 + .long 161480704 + .long 1078028251 + .long 3632513556 + .long 3191302868 + .long 1642070016 + .long 1078038102 + .long 3240138768 + .long 1043718443 + .long 2447376384 + .long 1078047881 + .long 3100705142 + .long 3191740341 + .long 3709861888 + .long 1078057588 + .long 1674862667 + .long 1041748151 + .long 2325741568 + .long 1078067224 + .long 4255018693 + .long 1044226144 + .long 3827302400 + .long 1078076788 + .long 4142119676 + .long 3191232448 + .long 899678208 + .long 1078086282 + .long 700553623 + .long 1043581423 + .long 3462397952 + .long 1078095704 + .long 1067893357 + .long 3190322959 + .long 4286578688 + .long 1078105056 + .long 3385731218 + .long 1043691060 + .long 486539264 + .long 1078114339 + .long 2289432889 + .long 1035999008 + .long 2092957696 + .long 1078123551 + .long 653388941 + .long 3186809946 + .long 1996488704 + .long 1078132694 + .long 3139143286 + .long 3191209215 + .long 1709178880 + .long 1078141768 + .long 643854101 + .long 3190510369 + .long 2778726400 + .long 1078150773 + .long 2948057503 + .long 3191040876 + .long 2485125120 + .long 1078159710 + .long 172509481 + .long 1044304413 + .long 2438987776 + .long 1078168579 + .long 1352848207 + .long 1043175137 + .long 4271898624 + .long 1078177380 + .long 2864918449 + .long 1043427968 + .long 1054867456 + .long 1078186115 + .long 1735520057 + .long 1044098886 + .long 3063939072 + .long 1078194782 + .long 2894826982 + .long 1043616305 + .long 3418357760 + .long 1078203383 + .long 442938097 + .long 3191392387 + .long 3844079616 + .long 1078211918 + .long 4004776912 + .long 1043962348 + .long 1801453568 + .long 1078220388 + .long 2102624066 + .long 1044353828 + .long 3355443200 + .long 1078228792 + .long 1225643377 + .long 3190452555 + .long 1700790272 + .long 1078237132 + .long 2531804346 + .long 3191195152 + .long 2936012800 + .long 1078245407 + .long 928991542 + .long 1043548181 + .long 293601280 + .long 1078253619 + .long 3229203938 + .long 1042779359 + .long 4194304000 + .long 1078261766 + .long 1071139240 + .long 1044201053 + .long 3600809984 + .long 1078269851 + .long 3018208080 + .long 1043941200 + .long 371195904 + .long 1078277874 + .long 2039162957 + .long 3189903110 + .long 666894336 + .long 1078285834 + .long 1431034507 + .long 3190628953 + .long 2071986176 + .long 1078293732 + .long 3412027605 + .long 3191381190 + .long 2176843776 + .long 1078301569 + .long 183216755 + .long 3188772215 + .long 2877292544 + .long 1078309345 + .long 3207515339 + .long 3189828782 + .long 1778384896 + .long 1078317061 + .long 847503884 + .long 3191075565 + .long 784334848 + .long 1078324717 + .long 2952309205 + .long 1043794080 + .long 1809842176 + .long 1078332313 + .long 467544888 + .long 1042040199 + .long 2472542208 + .long 1078339850 + .long 3311174937 + .long 1039371295 + .long 396361728 + .long 1078347329 + .long 676857836 + .long 3191368341 + .long 1795162112 + .long 1078354749 + .long 2052116880 + .long 3191818486 + .long 0 + .long 1078362112 + .long 0 + .long 0 + .long 2499805184 + .long 1078369474 + .long 2052116880 + .long 1044334838 + .long 3898605568 + .long 1078376894 + .long 676857836 + .long 1043884693 + .long 1822425088 + .long 1078384373 + .long 3311174937 + .long 3186854943 + .long 2485125120 + .long 1078391910 + .long 467544888 + .long 3189523847 + .long 3510632448 + .long 1078399506 + .long 2952309205 + .long 3191277728 + .long 2516582400 + .long 1078407162 + .long 847503884 + .long 1043591917 + .long 1417674752 + .long 1078414878 + .long 3207515339 + .long 1042345134 + .long 2118123520 + .long 1078422654 + .long 183216755 + .long 1041288567 + .long 2222981120 + .long 1078430491 + .long 3412027605 + .long 1043897542 + .long 3628072960 + .long 1078438389 + .long 1431034507 + .long 1043145305 + .long 3923771392 + .long 1078446349 + .long 2039162957 + .long 1042419462 + .long 694157312 + .long 1078454372 + .long 3018208080 + .long 3191424848 + .long 100663296 + .long 1078462457 + .long 1071139240 + .long 3191684701 + .long 4001366016 + .long 1078470604 + .long 3229203938 + .long 3190263007 + .long 1358954496 + .long 1078478816 + .long 928991542 + .long 3191031829 + .long 2594177024 + .long 1078487091 + .long 2531804346 + .long 1043711504 + .long 939524096 + .long 1078495431 + .long 1225643377 + .long 1042968907 + .long 2493513728 + .long 1078503835 + .long 2102624066 + .long 3191837476 + .long 450887680 + .long 1078512305 + .long 4004776912 + .long 3191445996 + .long 876609536 + .long 1078520840 + .long 442938097 + .long 1043908739 + .long 1231028224 + .long 1078529441 + .long 2894826982 + .long 3191099953 + .long 3240099840 + .long 1078538108 + .long 1735520057 + .long 3191582534 + .long 23068672 + .long 1078546843 + .long 2864918449 + .long 3190911616 + .long 1855979520 + .long 1078555644 + .long 1352848207 + .long 3190658785 + .long 1809842176 + .long 1078564513 + .long 172509481 + .long 3191788061 + .long 1516240896 + .long 1078573450 + .long 2948057503 + .long 1043557228 + .long 2585788416 + .long 1078582455 + .long 643854101 + .long 1043026721 + .long 2298478592 + .long 1078591529 + .long 3139143286 + .long 1043725567 + .long 2202009600 + .long 1078600672 + .long 653388941 + .long 1039326298 + .long 3808428032 + .long 1078609884 + .long 2289432889 + .long 3183482656 + .long 8388608 + .long 1078619167 + .long 3385731218 + .long 3191174708 + .long 832569344 + .long 1078628519 + .long 1067893357 + .long 1042839311 + .long 3395289088 + .long 1078637941 + .long 700553623 + .long 3191065071 + .long 467664896 + .long 1078647435 + .long 4142119676 + .long 1043748800 + .long 1969225728 + .long 1078656999 + .long 4255018693 + .long 3191709792 + .long 585105408 + .long 1078666635 + .long 1674862667 + .long 3189231799 + .long 1847590912 + .long 1078676342 + .long 3100705142 + .long 1044256693 + .long 2652897280 + .long 1078686121 + .long 3240138768 + .long 3191202091 + .long 4133486592 + .long 1078695972 + .long 3632513556 + .long 1043819220 + .long 3087007744 + .long 1078705896 + .long 2148760563 + .long 3186937031 + .long 543162368 + .long 1078715893 + .long 2856171667 + .long 1043912306 + .long 1778384896 + .long 1078725962 + .long 2925970384 + .long 3187059424 + .long 3416260608 + .long 1078736104 + .long 1476207680 + .long 3191383682 + .long 2021654528 + .long 1078746320 + .long 4155795398 + .long 3191401960 + .long 2688548864 + .long 1078756609 + .long 1692530062 + .long 3191131794 + .long 1855979520 + .long 1078766972 + .long 3465285131 + .long 3189919618 + .long 190840832 + .long 1078777409 + .long 2278278095 + .long 1044265941 + .long 2589982720 + .long 1078787919 + .long 2364400925 + .long 1039488855 + .long 987758592 + .long 1078798504 + .long 1559006781 + .long 1041738262 + .long 134217728 + .long 1078809163 + .long 1232510221 + .long 1043398165 + .long 408944640 + .long 1078819896 + .long 797568562 + .long 3184567591 + .long 2109734912 + .long 1078830703 + .long 1936866404 + .long 1044380280 + .long 1166016512 + .long 1078841585 + .long 2811467203 + .long 3191322578 + .long 2004877312 + .long 1078852541 + .long 2787570751 + .long 3190829595 + .long 385875968 + .long 1078863572 + .long 3023722014 + .long 3191478212 + .long 566231040 + .long 1078874677 + .long 3525309094 + .long 1042505183 + .long 2424307712 + .long 1078885856 + .long 1063445218 + .long 3191768956 + .long 1442840576 + .long 1078897110 + .long 1577179566 + .long 3190494396 + .long 1606418432 + .long 1078908438 + .long 152088799 + .long 3189637679 + .long 2503999488 + .long 1078919840 + .long 1405657776 + .long 1044264267 + .long 3630170112 + .long 1078931316 + .long 2622169537 + .long 3190092209 + .long 75497472 + .long 1078942867 + .long 3035382168 + .long 3190712380 + .long 4009754624 + .long 1078954490 + .long 3752802150 + .long 1044153052 + .long 1730150400 + .long 1078966188 + .long 806768485 + .long 1043980860 + .long 895483904 + .long 1078977959 + .long 2588206371 + .long 1044009924 + .long 2380267520 + .long 1078987253 + .long 1393635940 + .long 1044120466 + .long 3938451456 + .long 1078993211 + .long 1171997210 + .long 1044632170 + .long 2342518784 + .long 1078999206 + .long 2612691399 + .long 3192403747 + .long 1191182336 + .long 1079005237 + .long 2099274145 + .long 3190761166 + .long 4028628992 + .long 1079011303 + .long 3828434628 + .long 1045017771 + .long 1455423488 + .long 1079017406 + .long 1622551107 + .long 3192310957 + .long 1182793728 + .long 1079023544 + .long 2124167878 + .long 3191930936 + .long 2275409920 + .long 1079029717 + .long 41710967 + .long 1041693117 + .long 3735027712 + .long 1079035925 + .long 514060819 + .long 3191694645 + .long 201326592 + .long 1079042169 + .long 1430947390 + .long 3192785388 + .long 3428843520 + .long 1079048446 + .long 2518581518 + .long 3186637987 + .long 3636461568 + .long 1079054758 + .long 1552096852 + .long 3192868489 + .long 3854565376 + .long 1079061104 + .long 1865077452 + .long 3191449780 + .long 2757754880 + .long 1079067484 + .long 2620146859 + .long 3192418374 + .long 3242196992 + .long 1079073897 + .long 1679886032 + .long 1045390684 + .long 3848273920 + .long 1079080343 + .long 1008852996 + .long 1045213180 + .long 3042967552 + .long 1079086822 + .long 1190325550 + .long 3191428594 + .long 3516923904 + .long 1079093333 + .long 2901961231 + .long 3189559456 + .long 3600809984 + .long 1079099876 + .long 843293277 + .long 1043776619 + .long 1556086784 + .long 1079106451 + .long 2705956472 + .long 3192552031 + .long 4158652416 + .long 1079113056 + .long 2007583995 + .long 3189975458 + .long 941621248 + .long 1079119693 + .long 1619354403 + .long 3192676122 + .long 2835349504 + .long 1079126359 + .long 4136034317 + .long 1045078976 + .long 3529506816 + .long 1079133055 + .long 290418758 + .long 1040193863 + .long 929038336 + .long 1079139781 + .long 3915023624 + .long 1045366041 + .long 1468006400 + .long 1079146535 + .long 1061629098 + .long 3192285591 + .long 2910846976 + .long 1079153317 + .long 1308671630 + .long 1043573567 + .long 2963275776 + .long 1079160127 + .long 1320907030 + .long 3192436805 + .long 3548381184 + .long 1079166964 + .long 182222777 + .long 3191258117 + .long 2231369728 + .long 1079173828 + .long 3513262155 + .long 3187154074 + .long 803209216 + .long 1079180718 + .long 1139819401 + .long 1040482120 + .long 987758592 + .long 1079187633 + .long 929259512 + .long 3191000897 + .long 146800640 + .long 1079194573 + .long 3229154456 + .long 3191288344 + .long 4167041024 + .long 1079201536 + .long 2552585681 + .long 1042131590 + .long 1692401664 + .long 1079208524 + .long 1439536878 + .long 3188143242 + .long 2776629248 + .long 1079215534 + .long 353720209 + .long 3191860659 + .long 230686720 + .long 1079222567 + .long 2411046197 + .long 3190921481 + .long 3986685952 + .long 1079229620 + .long 3756699850 + .long 3192084150 + .long 2438987776 + .long 1079236695 + .long 1671725142 + .long 1043734190 + .long 1107296256 + .long 1079243790 + .long 1240754629 + .long 1045055957 + .long 1157627904 + .long 1079250904 + .long 1534601222 + .long 1045263230 + .long 3701473280 + .long 1079258036 + .long 3448918206 + .long 1042044860 + .long 1203765248 + .long 1079265187 + .long 3924779397 + .long 1045089235 + .long 3263168512 + .long 1079272354 + .long 3287244582 + .long 1042979553 + .long 2243952640 + .long 1079279538 + .long 820395291 + .long 3190740781 + .long 3349151744 + .long 1079286737 + .long 1366866651 + .long 3192280071 + .long 3143630848 + .long 1079293951 + .long 2762624284 + .long 1045102639 + .long 2449473536 + .long 1079301179 + .long 1845586757 + .long 1044548329 + .long 2040528896 + .long 1079308420 + .long 3762298090 + .long 1045345703 + .long 2654994432 + .long 1079315673 + .long 3683913357 + .long 1045057884 + .long 698351616 + .long 1079322938 + .long 2953393071 + .long 3191482668 + .long 1128267776 + .long 1079330213 + .long 1034464320 + .long 3191720696 + .long 283115520 + .long 1079337498 + .long 1039826403 + .long 1041577546 + .long 3061841920 + .long 1079344791 + .long 19850279 + .long 1042922258 + .long 1449132032 + .long 1079352093 + .long 294154384 + .long 1045031347 + .long 293601280 + .long 1079359402 + .long 1192966610 + .long 3192379901 + .long 119537664 + .long 1079366717 + .long 152130161 + .long 3190257939 + .long 1438646272 + .long 1079374037 + .long 3963433176 + .long 1043378887 + .long 448790528 + .long 1079381362 + .long 2261136335 + .long 1044042197 + .long 1923088384 + .long 1079388690 + .long 3535382687 + .long 1045010726 + .long 2036334592 + .long 1079396021 + .long 3576784639 + .long 3192441914 + .long 1243611136 + .long 1079403354 + .long 3804918049 + .long 3191900478 + .long 0 + .long 1079410688 + .long 0 + .long 0 + .long 3051356160 + .long 1079418021 + .long 3804918049 + .long 1044416830 + .long 2258632704 + .long 1079425354 + .long 3576784639 + .long 1044958266 + .long 2371878912 + .long 1079432685 + .long 3535382687 + .long 3192494374 + .long 3846176768 + .long 1079440013 + .long 2261136335 + .long 3191525845 + .long 2856321024 + .long 1079447338 + .long 3963433176 + .long 3190862535 + .long 4175429632 + .long 1079454658 + .long 152130161 + .long 1042774291 + .long 4001366016 + .long 1079461973 + .long 1192966610 + .long 1044896253 + .long 2845835264 + .long 1079469282 + .long 294154384 + .long 3192514995 + .long 1233125376 + .long 1079476584 + .long 19850279 + .long 3190405906 + .long 4011851776 + .long 1079483877 + .long 1039826403 + .long 3189061194 + .long 3166699520 + .long 1079491162 + .long 1034464320 + .long 1044237048 + .long 3596615680 + .long 1079498437 + .long 2953393071 + .long 1043999020 + .long 1639972864 + .long 1079505702 + .long 3683913357 + .long 3192541532 + .long 2254438400 + .long 1079512955 + .long 3762298090 + .long 3192829351 + .long 1845493760 + .long 1079520196 + .long 1845586757 + .long 3192031977 + .long 1151336448 + .long 1079527424 + .long 2762624284 + .long 3192586287 + .long 945815552 + .long 1079534638 + .long 1366866651 + .long 1044796423 + .long 2051014656 + .long 1079541837 + .long 820395291 + .long 1043257133 + .long 1031798784 + .long 1079549021 + .long 3287244582 + .long 3190463201 + .long 3091202048 + .long 1079556188 + .long 3924779397 + .long 3192572883 + .long 593494016 + .long 1079563339 + .long 3448918206 + .long 3189528508 + .long 3137339392 + .long 1079570471 + .long 1534601222 + .long 3192746878 + .long 3187671040 + .long 1079577585 + .long 1240754629 + .long 3192539605 + .long 1855979520 + .long 1079584680 + .long 1671725142 + .long 3191217838 + .long 308281344 + .long 1079591755 + .long 3756699850 + .long 1044600502 + .long 4064280576 + .long 1079598808 + .long 2411046197 + .long 1043437833 + .long 1518338048 + .long 1079605841 + .long 353720209 + .long 1044377011 + .long 2602565632 + .long 1079612851 + .long 1439536878 + .long 1040659594 + .long 127926272 + .long 1079619839 + .long 2552585681 + .long 3189615238 + .long 4148166656 + .long 1079626802 + .long 3229154456 + .long 1043804696 + .long 3307208704 + .long 1079633742 + .long 929259512 + .long 1043517249 + .long 3491758080 + .long 1079640657 + .long 1139819401 + .long 3187965768 + .long 2063597568 + .long 1079647547 + .long 3513262155 + .long 1039670426 + .long 746586112 + .long 1079654411 + .long 182222777 + .long 1043774469 + .long 1331691520 + .long 1079661248 + .long 1320907030 + .long 1044953157 + .long 1384120320 + .long 1079668058 + .long 1308671630 + .long 3191057215 + .long 2826960896 + .long 1079674840 + .long 1061629098 + .long 1044801943 + .long 3365928960 + .long 1079681594 + .long 3915023624 + .long 3192849689 + .long 765460480 + .long 1079688320 + .long 290418758 + .long 3187677511 + .long 1459617792 + .long 1079695016 + .long 4136034317 + .long 3192562624 + .long 3353346048 + .long 1079701682 + .long 1619354403 + .long 1045192474 + .long 136314880 + .long 1079708319 + .long 2007583995 + .long 1042491810 + .long 2738880512 + .long 1079714924 + .long 2705956472 + .long 1045068383 + .long 694157312 + .long 1079721499 + .long 843293277 + .long 3191260267 + .long 778043392 + .long 1079728042 + .long 2901961231 + .long 1042075808 + .long 1251999744 + .long 1079734553 + .long 1190325550 + .long 1043944946 + .long 446693376 + .long 1079741032 + .long 1008852996 + .long 3192696828 + .long 1052770304 + .long 1079747478 + .long 1679886032 + .long 3192874332 + .long 1537212416 + .long 1079753891 + .long 2620146859 + .long 1044934726 + .long 440401920 + .long 1079760271 + .long 1865077452 + .long 1043966132 + .long 658505728 + .long 1079766617 + .long 1552096852 + .long 1045384841 + .long 866123776 + .long 1079772929 + .long 2518581518 + .long 1039154339 + .long 4093640704 + .long 1079779206 + .long 1430947390 + .long 1045301740 + .long 559939584 + .long 1079785450 + .long 514060819 + .long 1044210997 + .long 2019557376 + .long 1079791658 + .long 41710967 + .long 3189176765 + .long 3112173568 + .long 1079797831 + .long 2124167878 + .long 1044447288 + .long 2839543808 + .long 1079803969 + .long 1622551107 + .long 1044827309 + .long 266338304 + .long 1079810072 + .long 3828434628 + .long 3192501419 + .long 3103784960 + .long 1079816138 + .long 2099274145 + .long 1043277518 + .long 1952448512 + .long 1079822169 + .long 2612691399 + .long 1044920099 + .long 356515840 + .long 1079828164 + .long 1171997210 + .long 3192115818 + .long 1914699776 + .long 1079834122 + .long 1393635940 + .long 3191604114 + .long 1698693120 + .long 1079840044 + .long 3000864111 + .long 1044567581 + .long 3428843520 + .long 1079845929 + .long 3891583054 + .long 1044582113 + .long 2290089984 + .long 1079851778 + .long 3752802150 + .long 3191636700 + .long 2109734912 + .long 1079857590 + .long 3035382168 + .long 1043228732 + .long 2480930816 + .long 1079863365 + .long 2565683088 + .long 3192570771 + .long 3042967552 + .long 1079869103 + .long 1405657776 + .long 3191747915 + .long 3491758080 + .long 1079874804 + .long 152088799 + .long 1042154031 + .long 3573547008 + .long 1079880468 + .long 1577179566 + .long 1043010748 + .long 3082813440 + .long 1079886095 + .long 1063445218 + .long 1044285308 + .long 1864368128 + .long 1079891685 + .long 3525309094 + .long 3189988831 + .long 4102029312 + .long 1079897237 + .long 3023722014 + .long 1043994564 + .long 1145044992 + .long 1079902753 + .long 2787570751 + .long 1043345947 + .long 1564475392 + .long 1079908231 + .long 2811467203 + .long 1043838930 + .long 1092616192 + .long 1079913672 + .long 1936866404 + .long 3191863928 + .long 4091543552 + .long 1079919075 + .long 2980113444 + .long 3192905397 + .long 2080374784 + .long 1079924442 + .long 1232510221 + .long 3190881813 + .long 3800039424 + .long 1079929771 + .long 878865976 + .long 1045236413 + .long 851443712 + .long 1079935064 + .long 1134072023 + .long 1045386565 + .long 2051014656 + .long 1079940319 + .long 1008344600 + .long 1044439573 + .long 3368026112 + .long 1079945537 + .long 1281162365 + .long 3192613919 + .long 803209216 + .long 1079950719 + .long 1692530062 + .long 1043648146 + .long 3284140032 + .long 1079955863 + .long 4155795398 + .long 1043918312 + .long 2587885568 + .long 1079960971 + .long 3556863456 + .long 3192106174 + .long 3405774848 + .long 1079966042 + .long 2925970384 + .long 1039575776 + .long 1874853888 + .long 1079971077 + .long 2866881462 + .long 1044616390 + .long 2751463424 + .long 1079976075 + .long 2148760563 + .long 1039453383 + .long 2227175424 + .long 1079981037 + .long 2478710518 + .long 1044662933 + .long 822083584 + .long 1079985963 + .long 527414264 + .long 3192196970 + .long 3370123264 + .long 1079990852 + .long 597131077 + .long 1044444197 + .long 1855979520 + .long 1079995706 + .long 327513079 + .long 3192718825 + .long 1163919360 + .long 1080000524 + .long 2167457950 + .long 3191943119 + .long 1912602624 + .long 1080005306 + .long 2223907458 + .long 1044698143 + .long 450887680 + .long 1080010053 + .long 1797206836 + .long 3192265480 + .long 1730150400 + .long 1080014764 + .long 806768485 + .long 1045029436 + .long 2143289344 + .long 1080019440 + .long 3385731218 + .long 1043691060 + .long 2390753280 + .long 1080024081 + .long 2289432889 + .long 1035999008 + .long 3193962496 + .long 1080028687 + .long 653388941 + .long 3186809946 + .long 998244352 + .long 1080033259 + .long 3139143286 + .long 3191209215 + .long 427819008 + .long 1080035538 + .long 617352675 + .long 3193137764 + .long 1767899136 + .long 1080037789 + .long 2820938545 + .long 1044793929 + .long 2768240640 + .long 1080040023 + .long 1116869194 + .long 1045935239 + .long 3831496704 + .long 1080042240 + .long 2883013420 + .long 3192429127 + .long 1067450368 + .long 1080044441 + .long 716229612 + .long 1045716128 + .long 3485466624 + .long 1080046624 + .long 3427207267 + .long 3192006748 + .long 2912944128 + .long 1080048791 + .long 1797448570 + .long 1045763212 + .long 4074766336 + .long 1080050941 + .long 963007300 + .long 1046072799 + .long 3107979264 + .long 1080053075 + .long 1001194228 + .long 1045849723 + .long 450887680 + .long 1080055193 + .long 3243655263 + .long 3191879277 + .long 838860800 + .long 1080057294 + .long 1225643377 + .long 3190452555 + .long 425721856 + .long 1080059379 + .long 632951086 + .long 3193270660 + .long 3955228672 + .long 1080061447 + .long 928991542 + .long 1043548181 + .long 3294625792 + .long 1080063500 + .long 3229203938 + .long 1042779359 + .long 3196059648 + .long 1080065537 + .long 1071139240 + .long 1044201053 + .long 4120903680 + .long 1080067558 + .long 754552020 + .long 1045844436 + .long 2239758336 + .long 1080069564 + .long 1637692909 + .long 1045134398 + .long 2313158656 + .long 1080071554 + .long 3579217071 + .long 1046240180 + .long 517996544 + .long 1080073529 + .long 3412027605 + .long 3191381190 + .long 1616904192 + .long 1080075488 + .long 2404468057 + .long 1046410024 + .long 1793064960 + .long 1080077432 + .long 3207515339 + .long 3189828782 + .long 1518338048 + .long 1080079361 + .long 847503884 + .long 3191075565 + .long 1270874112 + .long 1080081275 + .long 3556889995 + .long 3193585111 + .long 1526726656 + .long 1080083174 + .long 478427801 + .long 3192682319 + .long 2766143488 + .long 1080085058 + .long 30743511 + .long 3192873887 + .long 1172307968 + .long 1080086928 + .long 1809054730 + .long 1044630197 + .long 1522532352 + .long 1080088783 + .long 2052116880 + .long 3191818486 + .long 0 + .long 1080090624 + .long 0 + .long 0 + .long 2772434944 + .long 1080092464 + .long 2052116880 + .long 1044334838 + .long 3122659328 + .long 1080094319 + .long 1809054730 + .long 3192113845 + .long 1528823808 + .long 1080096189 + .long 30743511 + .long 1045390239 + .long 2768240640 + .long 1080098073 + .long 478427801 + .long 1045198671 + .long 3024093184 + .long 1080099972 + .long 3556889995 + .long 1046101463 + .long 2776629248 + .long 1080101886 + .long 847503884 + .long 1043591917 + .long 2501902336 + .long 1080103815 + .long 3207515339 + .long 1042345134 + .long 2678063104 + .long 1080105759 + .long 2404468057 + .long 3193893672 + .long 3776970752 + .long 1080107718 + .long 3412027605 + .long 1043897542 + .long 1981808640 + .long 1080109693 + .long 3579217071 + .long 3193723828 + .long 2055208960 + .long 1080111683 + .long 1637692909 + .long 3192618046 + .long 174063616 + .long 1080113689 + .long 754552020 + .long 3193328084 + .long 1098907648 + .long 1080115710 + .long 1071139240 + .long 3191684701 + .long 1000341504 + .long 1080117747 + .long 3229203938 + .long 3190263007 + .long 339738624 + .long 1080119800 + .long 928991542 + .long 3191031829 + .long 3869245440 + .long 1080121868 + .long 632951086 + .long 1045787012 + .long 3456106496 + .long 1080123953 + .long 1225643377 + .long 1042968907 + .long 3844079616 + .long 1080126054 + .long 3243655263 + .long 1044395629 + .long 1186988032 + .long 1080128172 + .long 1001194228 + .long 3193333371 + .long 220200960 + .long 1080130306 + .long 963007300 + .long 3193556447 + .long 1382023168 + .long 1080132456 + .long 1797448570 + .long 3193246860 + .long 809500672 + .long 1080134623 + .long 3427207267 + .long 1044523100 + .long 3227516928 + .long 1080136806 + .long 716229612 + .long 3193199776 + .long 463470592 + .long 1080139007 + .long 2883013420 + .long 1044945479 + .long 1526726656 + .long 1080141224 + .long 1116869194 + .long 3193418887 + .long 2527068160 + .long 1080143458 + .long 2820938545 + .long 3192277577 + .long 3867148288 + .long 1080145709 + .long 617352675 + .long 1045654116 + .long 1648361472 + .long 1080147978 + .long 3139143286 + .long 1043725567 + .long 551550976 + .long 1080150264 + .long 2539927630 + .long 3193943182 + .long 952107008 + .long 1080152567 + .long 2289432889 + .long 3183482656 + .long 3223322624 + .long 1080154887 + .long 3385731218 + .long 3191174708 + .long 3428843520 + .long 1080157225 + .long 3891583054 + .long 1045630689 + .long 1923088384 + .long 1080159581 + .long 3396363878 + .long 3193238139 + .long 3338665984 + .long 1080161954 + .long 2223907458 + .long 3192181791 + .long 3714056192 + .long 1080164345 + .long 1063754673 + .long 3193399320 + .long 3368026112 + .long 1080166754 + .long 1983727109 + .long 3193011467 + .long 2608857088 + .long 1080169181 + .long 1848918109 + .long 1045923309 + .long 1736441856 + .long 1080171626 + .long 527414264 + .long 1044713322 + .long 1033895936 + .long 1080174089 + .long 2478710518 + .long 3192146581 + .long 771751936 + .long 1080176570 + .long 2148760563 + .long 3186937031 + .long 1210056704 + .long 1080179069 + .long 2866881462 + .long 3192100038 + .long 2592079872 + .long 1080181586 + .long 2925970384 + .long 3187059424 + .long 853540864 + .long 1080184122 + .long 3556863456 + .long 1044622526 + .long 505413632 + .long 1080186676 + .long 4155795398 + .long 3191401960 + .long 1744830464 + .long 1080189248 + .long 1724351133 + .long 1046137947 + .long 463470592 + .long 1080191839 + .long 1281162365 + .long 1045130271 + .long 1121976320 + .long 1080194448 + .long 1008344600 + .long 3191923221 + .long 3869245440 + .long 1080197075 + .long 1134072023 + .long 3192870213 + .long 247463936 + .long 1080199722 + .long 878865976 + .long 3192720061 + .long 3254779904 + .long 1080202386 + .long 1232510221 + .long 1043398165 + .long 102760448 + .long 1080205070 + .long 657426926 + .long 3192918181 + .long 3749707776 + .long 1080207771 + .long 3810750695 + .long 3193438561 + .long 1365245952 + .long 1080210492 + .long 2811467203 + .long 3191322578 + .long 1574961152 + .long 1080213231 + .long 2787570751 + .long 3190829595 + .long 96468992 + .long 1080215989 + .long 3023722014 + .long 3191478212 + .long 1216348160 + .long 1080218765 + .long 96207275 + .long 3193803844 + .long 606076928 + .long 1080221560 + .long 1063445218 + .long 3191768956 + .long 2508193792 + .long 1080224373 + .long 1577179566 + .long 3190494396 + .long 2548039680 + .long 1080227205 + .long 258929906 + .long 1046355933 + .long 627048448 + .long 1080230056 + .long 722327380 + .long 3193467565 + .long 908066816 + .long 1080232925 + .long 864642104 + .long 3193085494 + .long 3240099840 + .long 1080235812 + .long 3035382168 + .long 3190712380 + .long 3149922304 + .long 1080238718 + .long 3752802150 + .long 1044153052 + .long 432013312 + .long 1080241643 + .long 201692121 + .long 1045854351 + .long 3445620736 + .long 1080244585 + .long 3000864111 + .long 3192051229 + .long 3338665984 + .long 1080247546 + .long 1799074663 + .long 3193503515 + .long 4116709376 + .long 1080250525 + .long 1171997210 + .long 1044632170 + .long 1170210816 + .long 1080253523 + .long 841137948 + .long 1045685358 + .long 2743074816 + .long 1080256538 + .long 2099274145 + .long 3190761166 + .long 4162846720 + .long 1080259571 + .long 233266334 + .long 3193120170 + .long 727711744 + .long 1080262623 + .long 1622551107 + .long 3192310957 + .long 591396864 + .long 1080265692 + .long 2124167878 + .long 3191930936 + .long 3286237184 + .long 1080268778 + .long 802699433 + .long 3193868388 + .long 4013948928 + .long 1080271882 + .long 3092710267 + .long 1045997234 + .long 2248146944 + .long 1080275004 + .long 1430947390 + .long 3192785388 + .long 1713373184 + .long 1080278143 + .long 1906804220 + .long 1046462221 + .long 1818230784 + .long 1080281299 + .long 1552096852 + .long 3192868489 + .long 1927282688 + .long 1080284472 + .long 1865077452 + .long 3191449780 + .long 1377828864 + .long 1080287662 + .long 2984893867 + .long 1045678044 + .long 3768582144 + .long 1080290868 + .long 1679886032 + .long 1045390684 + .long 4072669184 + .long 1080294091 + .long 3790540798 + .long 3193022465 + .long 1520435200 + .long 1080297331 + .long 1849902261 + .long 1046063747 + .long 3904897024 + .long 1080300586 + .long 4113594719 + .long 1046360821 + .long 1801453568 + .long 1080303858 + .long 862918505 + .long 3193589477 + .long 2925527040 + .long 1080307145 + .long 2705956472 + .long 3192552031 + .long 2078277632 + .long 1080310448 + .long 2970277473 + .long 1046321867 + .long 2617245696 + .long 1080313766 + .long 3485290095 + .long 1045549170 + .long 3565158400 + .long 1080317099 + .long 4136034317 + .long 1045078976 + .long 3913285632 + .long 1080320447 + .long 3346367614 + .long 3193929525 + .long 2613051392 + .long 1080323810 + .long 189971836 + .long 3192946035 + .long 2881486848 + .long 1080327187 + .long 1061629098 + .long 3192285591 + .long 3602907136 + .long 1080330578 + .long 1308671630 + .long 1043573567 + .long 3628072960 + .long 1080333983 + .long 1487030133 + .long 1045668829 + .long 1774190592 + .long 1080337402 + .long 182222777 + .long 3191258117 + .long 1115684864 + .long 1080340834 + .long 3513262155 + .long 3187154074 + .long 402653184 + .long 1080344279 + .long 3185606116 + .long 3193920517 + .long 2640314368 + .long 1080347736 + .long 2988910594 + .long 1046170671 + .long 2220883968 + .long 1080351206 + .long 3229154456 + .long 3191288344 + .long 2084569088 + .long 1080354688 + .long 2524817955 + .long 3193840983 + .long 845152256 + .long 1080358182 + .long 2907804489 + .long 1046431323 + .long 1388314624 + .long 1080361687 + .long 353720209 + .long 3191860659 + .long 2262827008 + .long 1080365203 + .long 2411046197 + .long 3190921481 + .long 1992294400 + .long 1080368730 + .long 2416617371 + .long 1045845156 + .long 3368026112 + .long 1080372267 + .long 1729552362 + .long 3193600084 + .long 553648128 + .long 1080375815 + .long 1240754629 + .long 1045055957 + .long 578813952 + .long 1080379372 + .long 1534601222 + .long 1045263230 + .long 1851785216 + .long 1080382938 + .long 858184436 + .long 3193846404 + .long 2749366272 + .long 1080386513 + .long 3924779397 + .long 1045089235 + .long 1631584256 + .long 1080390097 + .long 3287244582 + .long 1042979553 + .long 1121976320 + .long 1080393689 + .long 820395291 + .long 3190740781 + .long 3821010944 + .long 1080397288 + .long 1464050323 + .long 1045747196 + .long 3720347648 + .long 1080400895 + .long 766171506 + .long 3193077736 + .long 3372220416 + .long 1080404509 + .long 1845586757 + .long 1044548329 + .long 1021313024 + .long 1080408130 + .long 266334603 + .long 3192956204 + .long 3474980864 + .long 1080411756 + .long 3683913357 + .long 1045057884 + .long 348127232 + .long 1080415389 + .long 3556619028 + .long 1046050228 + .long 2711617536 + .long 1080419026 + .long 1034464320 + .long 3191720696 + .long 142606336 + .long 1080422669 + .long 1545623586 + .long 3193875611 + .long 3678404608 + .long 1080426315 + .long 19850279 + .long 1042922258 + .long 2873098240 + .long 1080429966 + .long 2000406456 + .long 3193113382 + .long 146800640 + .long 1080433621 + .long 1192966610 + .long 3192379901 + .long 2206203904 + .long 1080437278 + .long 2665338290 + .long 1046286557 + .long 2866806784 + .long 1080440938 + .long 3963433176 + .long 1043378887 + .long 224395264 + .long 1080444601 + .long 2261136335 + .long 1044042197 + .long 962592768 + .long 1080448265 + .long 2527275953 + .long 3193123692 + .long 3164602368 + .long 1080451930 + .long 2506574977 + .long 1045666274 + .long 620756992 + .long 1080455597 + .long 2392508272 + .long 1045936992 + .long 0 + .long 1080459264 + .long 0 + .long 0 + .type __libm_atandl_table_128,@object + .size __libm_atandl_table_128,8208 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/atanf_gen.S b/external/sgx_libm/intel64/atanf_gen.S new file mode 100644 index 0000000000..2a715bf18b --- /dev/null +++ b/external/sgx_libm/intel64/atanf_gen.S @@ -0,0 +1,338 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanf_gen.c" + .text +..TXTST0: +# -- Begin atanf + .text + .align 16,0x90 + .globl atanf +atanf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_atanf.1: +..L2: + + pxor %xmm5, %xmm5 + movd %xmm0, %edx + cvtss2sd %xmm0, %xmm5 + movl %edx, %eax + andl $2147483647, %eax + cmpl $1300234240, %eax + jae ..B1.14 +..B1.2: + cmpl $1073741824, %eax + jae ..B1.13 +..B1.3: + cmpl $1056964608, %eax + jae ..B1.12 +..B1.4: + cmpl $964689920, %eax + jae ..B1.11 +..B1.5: + shrl $31, %edx + cmpl $8388608, %eax + jb ..B1.7 +..B1.6: + movl %edx, %edx + lea _small_value_32(%rip), %rax + movss (%rax,%rdx,4), %xmm1 + mulss .L_2il0floatpacket.17(%rip), %xmm1 + subss %xmm1, %xmm0 + ret +..B1.7: + testl %eax, %eax + je ..B1.10 +..B1.8: + lea _small_value_32(%rip), %rax + pxor %xmm1, %xmm1 + movss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.17(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm1 + subsd %xmm0, %xmm5 + pxor %xmm0, %xmm0 + movss %xmm1, -8(%rsp) + cvtsd2ss %xmm5, %xmm0 +..B1.10: + ret +..B1.11: + movaps %xmm5, %xmm1 + mulsd %xmm5, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.4(%rip), %xmm2 + mulsd %xmm0, %xmm2 + movsd .L_2il0floatpacket.0(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.5(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.1(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.6(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.2(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.7(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.3(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.8(%rip), %xmm2 + mulsd %xmm1, %xmm2 + pxor %xmm0, %xmm0 + addsd %xmm2, %xmm3 + mulsd %xmm5, %xmm3 + subsd %xmm3, %xmm5 + cvtsd2ss %xmm5, %xmm0 + ret +..B1.12: + andps .L_2il0floatpacket.19(%rip), %xmm5 + testl $-2147483648, %edx + movsd .L_2il0floatpacket.9(%rip), %xmm4 + movsd .L_2il0floatpacket.18(%rip), %xmm1 + addsd %xmm5, %xmm4 + addsd %xmm1, %xmm5 + divsd %xmm5, %xmm4 + movaps %xmm4, %xmm0 + mulsd %xmm4, %xmm0 + movaps %xmm0, %xmm2 + mulsd %xmm0, %xmm2 + movsd .L_2il0floatpacket.10(%rip), %xmm5 + mulsd %xmm2, %xmm5 + movsd .L_2il0floatpacket.13(%rip), %xmm3 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.11(%rip), %xmm5 + mulsd %xmm2, %xmm5 + addsd .L_2il0floatpacket.14(%rip), %xmm3 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.12(%rip), %xmm5 + mulsd %xmm0, %xmm5 + addsd .L_2il0floatpacket.15(%rip), %xmm3 + addsd %xmm3, %xmm5 + mulsd %xmm4, %xmm5 + addsd .L_2il0floatpacket.16(%rip), %xmm5 + movaps %xmm5, %xmm0 + xorps .L_2il0floatpacket.20(%rip), %xmm0 + jne ..L3 + movaps %xmm5, %xmm0 +..L3: + cvtsd2ss %xmm0, %xmm0 + ret +..B1.13: + movsd .L_2il0floatpacket.18(%rip), %xmm2 + lea pi_2d(%rip), %rax + divsd %xmm5, %xmm2 + movaps %xmm2, %xmm0 + mulsd %xmm2, %xmm0 + movaps %xmm0, %xmm5 + mulsd %xmm0, %xmm5 + movsd .L_2il0floatpacket.4(%rip), %xmm1 + mulsd %xmm5, %xmm1 + movsd .L_2il0floatpacket.0(%rip), %xmm3 + mulsd %xmm5, %xmm3 + addsd .L_2il0floatpacket.5(%rip), %xmm1 + mulsd %xmm5, %xmm1 + addsd .L_2il0floatpacket.1(%rip), %xmm3 + mulsd %xmm5, %xmm3 + addsd .L_2il0floatpacket.6(%rip), %xmm1 + mulsd %xmm5, %xmm1 + addsd .L_2il0floatpacket.2(%rip), %xmm3 + mulsd %xmm5, %xmm3 + addsd .L_2il0floatpacket.7(%rip), %xmm1 + mulsd %xmm5, %xmm1 + addsd .L_2il0floatpacket.3(%rip), %xmm3 + mulsd %xmm5, %xmm3 + addsd .L_2il0floatpacket.8(%rip), %xmm1 + mulsd %xmm0, %xmm1 + shrl $31, %edx + addsd %xmm1, %xmm3 + movsd (%rax,%rdx,8), %xmm0 + mulsd %xmm2, %xmm3 + subsd %xmm2, %xmm0 + addsd %xmm3, %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.14: + cmpl $2139095040, %eax + ja ..B1.17 +..B1.15: + lea pi_2f(%rip), %rax + lea _small_value_32(%rip), %rcx + shrl $31, %edx + movss (%rax,%rdx,4), %xmm0 + subss (%rcx,%rdx,4), %xmm0 +..B1.17: + ret + .align 16,0x90 + .cfi_endproc + .type atanf,@function + .size atanf,.-atanf + .data +# -- End atanf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.19: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.19,@object + .size .L_2il0floatpacket.19,16 + .align 16 +.L_2il0floatpacket.20: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,16 + .align 8 +.L_2il0floatpacket.0: + .long 0xd091d944,0xbf9ca14d + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x12effb80,0xbfb28de9 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0xcda40e6e,0xbfbc6a7e + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x1185f36d,0xbfc99997 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x3cb73089,0x3f7fa335 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x44053df6,0x3faac31f + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x1cf194fa,0x3fb70b87 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0xb177868e,0x3fc248e0 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x509fdfb1,0x3fd55555 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0xd9d9aa33,0xbfb1c1c0 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x04ba093e,0xbfc24485 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x312dd43c,0xbfd55555 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x947e6edc,0x3fbbcbeb + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0x700fa0b3,0x3fc9997b + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 8 +.L_2il0floatpacket.15: + .long 0xfff8f7db,0x3fefffff + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,8 + .align 8 +.L_2il0floatpacket.16: + .long 0x54442d18,0x3fe921fb + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,8 + .align 8 +.L_2il0floatpacket.18: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,8 + .align 8 +pi_2d: + .long 0x54442d18,0x3ff921fb + .long 0x54442d18,0xbff921fb + .type pi_2d,@object + .size pi_2d,16 + .align 4 +.L_2il0floatpacket.17: + .long 0x0d800000 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +pi_2f: + .long 0x3fc90fdb + .long 0xbfc90fdb + .type pi_2f,@object + .size pi_2f,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atanh_gen.S b/external/sgx_libm/intel64/atanh_gen.S new file mode 100644 index 0000000000..e0be35a646 --- /dev/null +++ b/external/sgx_libm/intel64/atanh_gen.S @@ -0,0 +1,360 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanh_gen.c" + .text +..TXTST0: +# -- Begin atanh + .text + .align 16,0x90 + .globl atanh +atanh: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_atanh.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %esi + movl %esi, %edx + andl $2147483647, %edx + cmpl $1072693248, %edx + jae ..B1.12 +..B1.2: + cmpl $1068498944, %edx + jae ..B1.11 +..B1.3: + cmpl $1012924416, %edx + jae ..B1.10 +..B1.4: + shrl $31, %esi + cmpl $1048576, %edx + jb ..B1.6 +..B1.5: + lea _ones(%rip), %rax + movsd (%rax), %xmm1 + addsd %xmm0, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm2 + mulsd %xmm2, %xmm0 + ret +..B1.6: + movl -8(%rsp), %eax + orl %eax, %edx + je ..B1.8 +..B1.7: + lea _small_value_64(%rip), %rax + movsd -8(%rsp), %xmm0 + movsd (%rax,%rsi,8), %xmm1 + mulsd (%rax), %xmm1 + movsd %xmm1, -40(%rsp) + addsd %xmm1, %xmm0 + ret +..B1.8: + movsd -8(%rsp), %xmm0 +..B1.9: + ret +..B1.10: + movsd -8(%rsp), %xmm4 + lea 40+_PA(%rip), %rax + movaps %xmm4, %xmm3 + lea 32+_PA(%rip), %rsi + mulsd %xmm4, %xmm3 + lea 24+_PA(%rip), %rdx + movaps %xmm3, %xmm1 + lea 16+_PA(%rip), %rdi + mulsd %xmm3, %xmm1 + lea 8+_PA(%rip), %rcx + movsd (%rax), %xmm0 + lea _PA(%rip), %r8 + mulsd %xmm1, %xmm0 + movsd (%rsi), %xmm2 + mulsd %xmm1, %xmm2 + addsd (%rdx), %xmm0 + mulsd %xmm1, %xmm0 + addsd (%rdi), %xmm2 + mulsd %xmm1, %xmm2 + addsd (%rcx), %xmm0 + mulsd %xmm3, %xmm0 + addsd (%r8), %xmm2 + addsd %xmm2, %xmm0 + mulsd %xmm4, %xmm0 + mulsd %xmm3, %xmm0 + addsd %xmm4, %xmm0 + ret +..B1.11: + movsd -8(%rsp), %xmm9 + lea 8+_ones(%rip), %rdi + andps .L_2il0floatpacket.0(%rip), %xmm9 + lea _ones(%rip), %r8 + movsd %xmm9, -8(%rsp) + movq $0x3ff0000000000000, %r10 + andl $-268435456, -8(%rsp) + pxor %xmm15, %xmm15 + movsd -8(%rsp), %xmm12 + movsd (%rdi), %xmm0 + movaps %xmm12, %xmm6 + movaps %xmm0, %xmm8 + lea 32+_PL(%rip), %rdi + movsd (%r8), %xmm4 + lea 16+_PL(%rip), %r8 + movq __libm_rcp_table_256@GOTPCREL(%rip), %rax + addsd %xmm0, %xmm6 + subsd %xmm12, %xmm9 + addsd %xmm4, %xmm12 + movaps %xmm6, %xmm2 + movaps %xmm6, %xmm5 + movaps %xmm9, %xmm3 + movaps %xmm12, %xmm1 + shrl $31, %esi + addsd %xmm9, %xmm2 + divsd %xmm2, %xmm8 + movsd %xmm8, -32(%rsp) + pxor %xmm2, %xmm2 + andl $-268435456, -32(%rsp) + movsd -32(%rsp), %xmm10 + movaps %xmm10, %xmm7 + subsd %xmm10, %xmm8 + mulsd %xmm10, %xmm6 + mulsd %xmm10, %xmm12 + mulsd %xmm8, %xmm5 + addsd %xmm8, %xmm7 + addsd %xmm4, %xmm6 + mulsd %xmm7, %xmm3 + addsd %xmm3, %xmm5 + addsd %xmm5, %xmm6 + mulsd %xmm6, %xmm7 + addsd %xmm7, %xmm8 + mulsd %xmm8, %xmm1 + addsd %xmm10, %xmm8 + mulsd %xmm8, %xmm9 + addsd %xmm9, %xmm1 + movaps %xmm1, %xmm11 + addsd %xmm12, %xmm11 + movsd %xmm11, -8(%rsp) + movl $0, -8(%rsp) + movsd -8(%rsp), %xmm3 + movl -4(%rsp), %ecx + subsd %xmm3, %xmm12 + sarl $20, %ecx + addsd %xmm12, %xmm1 + addl $-1023, %ecx + movslq %ecx, %r9 + shlq $52, %r9 + subq %r9, %r10 + lea _PL(%rip), %r9 + movq %r10, -24(%rsp) + lea 24+_PL(%rip), %r10 + movsd -24(%rsp), %xmm13 + mulsd %xmm13, %xmm1 + cvtsi2sd %ecx, %xmm2 + mulsd %xmm13, %xmm3 + movaps %xmm1, %xmm14 + lea _LN2(%rip), %rcx + movsd (%r10), %xmm13 + addsd %xmm3, %xmm14 + movsd %xmm14, -16(%rsp) + movl -12(%rsp), %r11d + shrl $12, %r11d + movzbl %r11b, %edx + lea 8+_PL(%rip), %r11 + movsd (%rdi), %xmm14 + cvtss2sd (%rax,%rdx,4), %xmm15 + mulsd %xmm15, %xmm3 + mulsd %xmm15, %xmm1 + addsd %xmm0, %xmm3 + movaps %xmm3, %xmm12 + shlq $4, %rdx + addsd %xmm1, %xmm12 + movaps %xmm12, %xmm0 + mulsd %xmm12, %xmm0 + mulsd %xmm0, %xmm14 + mulsd %xmm0, %xmm13 + addsd (%r8), %xmm14 + addsd (%r11), %xmm13 + mulsd %xmm0, %xmm14 + mulsd %xmm0, %xmm13 + addsd (%r9), %xmm14 + mulsd %xmm12, %xmm13 + mulsd %xmm0, %xmm14 + movsd (%rcx), %xmm0 + lea halfs(%rip), %rcx + mulsd %xmm2, %xmm0 + addsd %xmm13, %xmm14 + movq __libm_log_table_256@GOTPCREL(%rip), %rax + addsd %xmm14, %xmm1 + addsd (%rax,%rdx), %xmm0 + movsd (%rcx,%rsi,8), %xmm4 + lea 8+_LN2(%rip), %rcx + movsd %xmm4, -16(%rsp) + addsd %xmm1, %xmm0 + movsd (%rcx), %xmm1 + mulsd %xmm1, %xmm2 + addsd 8(%rax,%rdx), %xmm2 + movsd %xmm2, -32(%rsp) + addsd %xmm2, %xmm3 + movsd %xmm3, -8(%rsp) + addsd %xmm3, %xmm0 + mulsd %xmm4, %xmm0 + ret +..B1.12: + jne ..B1.15 +..B1.13: + cmpl $0, -8(%rsp) + je ..B1.19 +..B1.14: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + ret +..B1.15: + cmpl $2146435072, %edx + jb ..B1.14 +..B1.16: + jne ..B1.18 +..B1.17: + cmpl $0, -8(%rsp) + je ..B1.14 +..B1.18: + lea _ones(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + ret +..B1.19: + lea _ones(%rip), %rax + lea _zeros(%rip), %rdx + shrl $31, %esi + movsd (%rax,%rsi,8), %xmm0 + divsd (%rdx), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type atanh,@function + .size atanh,.-atanh + .data +# -- End atanh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 8 +halfs: + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbfe00000 + .type halfs,@object + .size halfs,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_PA: + .long 1431655765 + .long 1070945621 + .long 2576980801 + .long 1070176665 + .long 2453616913 + .long 1069697316 + .long 1427436931 + .long 1069314503 + .long 2129349532 + .long 1068975486 + .long 1629438381 + .long 1068756329 + .type _PA,@object + .size _PA,48 + .align 4 +_PL: + .long 0 + .long 3219128320 + .long 1431621855 + .long 1070945621 + .long 4294842013 + .long 3218079743 + .long 1289448124 + .long 1070176674 + .long 2077359316 + .long 3217380703 + .type _PL,@object + .size _PL,40 + .align 4 +_LN2: + .long 897137782 + .long 1038760431 + .long 4276092928 + .long 1072049730 + .type _LN2,@object + .size _LN2,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atanhf_gen.S b/external/sgx_libm/intel64/atanhf_gen.S new file mode 100644 index 0000000000..1ea90340e4 --- /dev/null +++ b/external/sgx_libm/intel64/atanhf_gen.S @@ -0,0 +1,324 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanhf_gen.c" + .text +..TXTST0: +# -- Begin atanhf + .text + .align 16,0x90 + .globl atanhf +atanhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_atanhf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -16(%rsp) + movl %edx, %eax + andl $2147483647, %eax + cmpl $1065353216, %eax + jae ..B1.12 +..B1.2: + cmpl $1056964608, %eax + jae ..B1.11 +..B1.3: + cmpl $838860800, %eax + jae ..B1.10 +..B1.4: + shrl $31, %edx + cmpl $8388608, %eax + jb ..B1.6 +..B1.5: + movss .L_2il0floatpacket.15(%rip), %xmm1 + addss %xmm0, %xmm1 + mulss %xmm1, %xmm0 + ret +..B1.6: + testl %eax, %eax + je ..B1.8 +..B1.7: + lea _small_value_32(%rip), %rax + pxor %xmm2, %xmm2 + pxor %xmm1, %xmm1 + cvtss2sd -16(%rsp), %xmm2 + movss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.14(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm1 + addsd %xmm0, %xmm2 + pxor %xmm0, %xmm0 + movss %xmm1, -40(%rsp) + cvtsd2ss %xmm2, %xmm0 + ret +..B1.8: + movss -16(%rsp), %xmm0 +..B1.9: + ret +..B1.10: + pxor %xmm3, %xmm3 + cvtss2sd -16(%rsp), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.5(%rip), %xmm4 + movsd .L_2il0floatpacket.9(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.6(%rip), %xmm4 + addsd .L_2il0floatpacket.10(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + addsd .L_2il0floatpacket.11(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.8(%rip), %xmm4 + addsd .L_2il0floatpacket.12(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm3, %xmm4 + cvtsd2ss %xmm4, %xmm4 + movaps %xmm4, %xmm0 + ret +..B1.11: + pxor %xmm1, %xmm1 + pxor %xmm4, %xmm4 + cvtss2sd -16(%rsp), %xmm1 + movsd .L_2il0floatpacket.16(%rip), %xmm2 + pxor %xmm6, %xmm6 + movaps %xmm2, %xmm0 + pxor %xmm8, %xmm8 + movq __libm_rcp_table_256@GOTPCREL(%rip), %r9 + addsd %xmm1, %xmm0 + subsd %xmm1, %xmm2 + movsd %xmm0, -32(%rsp) + movsd %xmm2, -24(%rsp) + movzwl -26(%rsp), %ecx + movl %ecx, %eax + movzwl -18(%rsp), %esi + movl %esi, %edx + andl $-32753, %ecx + andl $-32753, %esi + orl $-49168, %ecx + orl $-49168, %esi + movw %cx, -26(%rsp) + andl $32752, %eax + movw %si, -18(%rsp) + andl $32752, %edx + movl -28(%rsp), %edi + movl -20(%rsp), %r8d + andl $1048575, %edi + andl $1048575, %r8d + shrl $12, %edi + shrl $12, %r8d + cvtss2sd (%r9,%rdi,4), %xmm4 + cvtss2sd (%r9,%r8,4), %xmm6 + mulsd -32(%rsp), %xmm4 + mulsd -24(%rsp), %xmm6 + movsd .L_2il0floatpacket.0(%rip), %xmm3 + movsd .L_2il0floatpacket.1(%rip), %xmm7 + addsd %xmm3, %xmm4 + addsd %xmm3, %xmm6 + movaps %xmm7, %xmm0 + mulsd %xmm4, %xmm0 + mulsd %xmm6, %xmm7 + movsd .L_2il0floatpacket.2(%rip), %xmm5 + shrl $4, %eax + addsd %xmm5, %xmm0 + addsd %xmm5, %xmm7 + mulsd %xmm4, %xmm0 + mulsd %xmm6, %xmm7 + mulsd %xmm4, %xmm0 + mulsd %xmm6, %xmm7 + addsd %xmm4, %xmm0 + addsd %xmm6, %xmm7 + shrl $4, %edx + addl $-1023, %eax + addl $-1023, %edx + subsd %xmm7, %xmm0 + subl %edx, %eax + cvtsi2sd %eax, %xmm8 + movq __libm_logf_table_256@GOTPCREL(%rip), %r10 + mulsd .L_2il0floatpacket.3(%rip), %xmm8 + movsd (%r10,%rdi,8), %xmm9 + movsd %xmm4, -32(%rsp) + movsd %xmm6, -24(%rsp) + subsd (%r10,%r8,8), %xmm9 + addsd %xmm8, %xmm9 + addsd %xmm9, %xmm0 + mulsd .L_2il0floatpacket.4(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.12: + cmpl $2139095040, %eax + ja ..B1.17 +..B1.13: + cmpl $1065353216, %eax + jne ..B1.15 +..B1.14: + lea _ones(%rip), %rax + shrl $31, %edx + pxor %xmm1, %xmm1 + movss (%rax,%rdx,4), %xmm0 + divss %xmm1, %xmm0 + ret +..B1.15: + movss .L_2il0floatpacket.13(%rip), %xmm1 + pxor %xmm0, %xmm0 + mulss %xmm1, %xmm0 +..B1.16: + ret +..B1.17: + movss -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type atanhf,@function + .size atanhf,.-atanhf + .data +# -- End atanhf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x6890dd10,0x3fd5555a + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0xe7362feb,0xbfe00001 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0xfefa39ef,0x3fe62e42 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x1c66784b,0x3fc717fd + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xdc2b5888,0x3fb8b0df + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x5a00faf0,0x3fbc8408 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x9016c8e5,0x3fc9999c + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x10091234,0xbf68c8ed + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x64e392ec,0x3fb67c91 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0xb0fd5c67,0x3fc248ae + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x51abeffb,0x3fd55555 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.16: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,8 + .align 4 +.L_2il0floatpacket.13: + .long 0x7f800000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,4 + .align 4 +.L_2il0floatpacket.14: + .long 0x0d800000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,4 + .align 4 +.L_2il0floatpacket.15: + .long 0x3f800000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atanhl.S b/external/sgx_libm/intel64/atanhl.S new file mode 100644 index 0000000000..c8b2dea87b --- /dev/null +++ b/external/sgx_libm/intel64/atanhl.S @@ -0,0 +1,966 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanhl.c" + .text +..TXTST0: +# -- Begin atanhl + .text + .align 16,0x90 + .globl atanhl +atanhl: +# parameter 1: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_atanhl.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + xorb %cl, %cl +..B1.2: + fnstcw 50(%rsp) +..B1.3: + movzwl 72(%rsp), %esi + andl $32767, %esi + movzwl 50(%rsp), %eax + cmpl $16383, %esi + jge ..B1.53 +..B1.4: + cmpl $16381, %esi + jge ..B1.46 +..B1.5: + cmpl $16376, %esi + jge ..B1.39 +..B1.6: + cmpl $16371, %esi + jge ..B1.32 +..B1.7: + cmpl $16365, %esi + jge ..B1.25 +..B1.8: + cmpl $16308, %esi + jge ..B1.18 +..B1.9: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.13 +..B1.10: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.11: + fldcw 48(%rsp) +..B1.12: + movzwl 72(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.13: + testl %esi, %esi + jle ..B1.64 +..B1.14: + fldt 64(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rdx + fldl (%rax) + fmul %st(1), %st + faddp %st, %st(1) + fmull (%rdx) + fstpt (%rsp) +..B1.15: + testb %cl, %cl + je ..B1.17 +..B1.16: + fldcw 50(%rsp) +..B1.17: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.18: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.22 +..B1.19: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.20: + fldcw 48(%rsp) +..B1.21: + movb $1, %cl +..B1.22: + fldt 64(%rsp) + lea _Q3(%rip), %rax + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 50(%rsp) +..B1.24: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.25: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.29 +..B1.26: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.27: + fldcw 48(%rsp) +..B1.28: + movb $1, %cl +..B1.29: + fldt 64(%rsp) + lea 16+_Q2(%rip), %rax + fld %st(0) + lea _Q2(%rip), %rdx + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.31 +..B1.30: + fldcw 50(%rsp) +..B1.31: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.32: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.36 +..B1.33: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.34: + fldcw 48(%rsp) +..B1.35: + movb $1, %cl +..B1.36: + fldt 64(%rsp) + lea 48+_Q1(%rip), %rax + fld %st(0) + lea 32+_Q1(%rip), %rsi + fmul %st(1), %st + lea 16+_Q1(%rip), %rdx + fld %st(0) + lea _Q1(%rip), %rdi + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.38 +..B1.37: + fldcw 50(%rsp) +..B1.38: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.39: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.43 +..B1.40: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.41: + fldcw 48(%rsp) +..B1.42: + movb $1, %cl +..B1.43: + fldt 64(%rsp) + lea _TWO_52H(%rip), %rax + lea 176+_Q(%rip), %rdx + lea 144+_Q(%rip), %rsi + lea 112+_Q(%rip), %rdi + lea 80+_Q(%rip), %r8 + lea 48+_Q(%rip), %r9 + lea 160+_Q(%rip), %r11 + fldl (%rax) + lea 16+_Q(%rip), %r10 + fmul %st(1), %st + lea 128+_Q(%rip), %rax + fld %st(0) + testb %cl, %cl + fadd %st(2), %st + fsubp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(1) + fmul %st(1), %st + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fmul %st(0), %st + fld %st(0) + fadd %st(3), %st + fmul %st, %st(2) + fld %st(1) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + fmul %st(0), %st + fld %st(0) + fadd %st(3), %st + fldt (%rdx) + fmul %st(1), %st + lea 96+_Q(%rip), %rdx + fldt (%rsi) + lea 64+_Q(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + lea 32+_Q(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea _Q(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + lea 208+_Q(%rip), %r9 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + lea 192+_Q(%rip), %r10 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + lea _TWO_48H(%rip), %r11 + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r8) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt (%r9) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(2) + fldt (%r10) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 32(%rsp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fldt 16(%rsp) + fld %st(0) + fldl (%r11) + fadd %st, %st(3) + fsubrp %st, %st(3) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fldt 64(%rsp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(2) + fldt (%rsp) + fmul %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.45 +..B1.44: + fldcw 50(%rsp) +..B1.45: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.46: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.50 +..B1.47: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.48: + fldcw 48(%rsp) +..B1.49: + movb $1, %cl +..B1.50: + fldt 64(%rsp) + lea _ones(%rip), %rdi + movb 73(%rsp), %sil + lea _TWO_48H(%rip), %r8 + andb $-128, %sil + shrb $7, %sil + fldl (%rdi) + fld %st(0) + fld %st(1) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fldl (%r8) + movzbl %sil, %edx + lea 48+_P(%rip), %r8 + movzwl 24(%rsp), %r10d + andl $-32768, %r10d + fxch %st(4) + fmull (%rdi,%rdx,8) + lea 80+_P(%rip), %rdi + fsubr %st, %st(2) + fld %st(2) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fsubr %st(2), %st + fsub %st(1), %st + fld %st(3) + fadd %st(1), %st + fxch %st(2) + fadd %st, %st(5) + fld %st(5) + fmul %st(7), %st + fadd %st, %st(6) + fsubrp %st, %st(6) + fxch %st(5) + fstpt (%rsp) + fldt (%rsp) + fsubr %st(3), %st + faddp %st, %st(5) + fld %st(1) + fdivr %st(3), %st + fmul %st, %st(6) + fld %st(0) + fadd %st(7), %st + fsubp %st, %st(7) + fxch %st(1) + fmul %st(6), %st + fld %st(1) + fsub %st(7), %st + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(4) + fmul %st(6), %st + fsubrp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fldt (%rsp) + fadd %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 64(%rsp) + fldt (%rdi) + lea 32+_P(%rip), %rdi + fldt (%r8) + lea _P(%rip), %r8 + movzwl 72(%rsp), %esi + andl $32767, %esi + movl %esi, %r9d + addl $-16383, %esi + negl %r9d + addl $-2, %r9d + andl $32767, %r9d + orl %r9d, %r10d + movw %r10w, 24(%rsp) + lea 8+_ones(%rip), %r10 + fldt 16(%rsp) + movl 68(%rsp), %r11d + shrl $23, %r11d + fmul %st, %st(3) + fmulp %st, %st(4) + movzbl %r11b, %eax + lea 16+_P(%rip), %r11 + movq __libm_rcp_table_256@GOTPCREL(%rip), %r9 + movl %esi, 32(%rsp) + lea 64+_P(%rip), %rsi + fildl 32(%rsp) + fxch %st(3) + fmuls (%r9,%rax,4) + fxch %st(4) + fmuls (%r9,%rax,4) + fxch %st(4) + faddl (%r10) + fld %st(0) + shlq $4, %rax + fadd %st(5), %st + fld %st(0) + testb %cl, %cl + fmul %st(1), %st + fmul %st, %st(4) + movq __libm_logl_table_256@GOTPCREL(%rip), %r9 + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%r11) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fldt (%rsi) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.0(%rip) + fmul %st(2), %st + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(3) + faddl 8(%r9,%rax) + faddp %st, %st(3) + fxch %st(1) + faddl (%rax,%r9) + lea halfs(%rip), %rax + faddp %st, %st(1) + faddp %st, %st(1) + fmull (%rax,%rdx,8) + fstpt (%rsp) + je ..B1.52 +..B1.51: + fldcw 50(%rsp) +..B1.52: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.53: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.57 +..B1.54: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.55: + fldcw 48(%rsp) +..B1.56: + movzwl 72(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.57: + cmpl $32767, %esi + jl ..B1.68 +..B1.58: + cmpl $-2147483648, 68(%rsp) + jne ..B1.60 +..B1.59: + cmpl $0, 64(%rsp) + je ..B1.68 +..B1.60: + fldt 64(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.61: + testb %cl, %cl + je ..B1.63 +..B1.62: + fldcw 50(%rsp) +..B1.63: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.64: + cmpl $0, 68(%rsp) + jne ..B1.66 +..B1.65: + cmpl $0, 64(%rsp) + je ..B1.67 +..B1.66: + fldt 64(%rsp) + lea _small_value_80(%rip), %rsi + movb 73(%rsp), %al + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %edx + shlq $4, %rdx + fldt (%rsi,%rdx) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.67: + fldt 64(%rsp) + fstpt (%rsp) + jmp ..B1.15 +..B1.68: + cmpl $16383, %esi + jne ..B1.72 +..B1.69: + cmpl $-2147483648, 68(%rsp) + jne ..B1.72 +..B1.70: + cmpl $0, 64(%rsp) + jne ..B1.72 +..B1.71: + movb 73(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + lea _zeros(%rip), %rdi + shrb $7, %al + movzbl %al, %esi + movsd (%rdx,%rsi,8), %xmm0 + divsd (%rdi), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt (%rsp) + jmp ..B1.61 +..B1.72: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt (%rsp) + jmp ..B1.61 + .align 16,0x90 + .cfi_endproc + .type atanhl,@function + .size atanhl,.-atanhl + .data +# -- End atanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +halfs: + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbfe00000 + .type halfs,@object + .size halfs,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q3: + .word 43691 + .word 45330 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 33124 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58478 + .word 29023 + .word 52648 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 43686 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 5258 + .word 52447 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 10439 + .word 34405 + .word 9349 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 25253 + .word 49895 + .word 32943 + .word 58261 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 43101 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 4657 + .word 52441 + .word 52428 + .word 52428 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 42633 + .word 18723 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 11223 + .word 36719 + .word 14563 + .word 58254 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 64465 + .word 27664 + .word 35746 + .word 47662 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 6969 + .word 8211 + .word 55486 + .word 40329 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 15522 + .word 40807 + .word 33480 + .word 34952 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 44124 + .word 7207 + .word 21918 + .word 61682 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 13236 + .word 62073 + .word 35694 + .word 55158 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 859 + .word 55468 + .word 55479 + .word 50356 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 19186 + .word 33607 + .word 822 + .word 41715 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 51623 + .word 9477 + .word 49456 + .word 61855 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52416 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,224 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,96 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atanl.S b/external/sgx_libm/intel64/atanl.S new file mode 100644 index 0000000000..8ea00fdc5a --- /dev/null +++ b/external/sgx_libm/intel64/atanl.S @@ -0,0 +1,745 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanl.c" + .text +..TXTST0: +# -- Begin atanl + .text + .align 16,0x90 + .globl atanl +atanl: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_atanl.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %cl, %cl +..B1.2: + fnstcw 74(%rsp) +..B1.3: + movzbl 105(%rsp), %edx + movzwl 104(%rsp), %edi + andl $128, %edx + andl $32767, %edi + shrl $7, %edx + movzwl 74(%rsp), %eax + cmpl $16394, %edi + jge ..B1.48 +..B1.4: + cmpl $16376, %edi + jge ..B1.38 +..B1.5: + cmpl $16371, %edi + jge ..B1.31 +..B1.6: + cmpl $16365, %edi + jge ..B1.24 +..B1.7: + cmpl $16308, %edi + jge ..B1.17 +..B1.8: + movl %eax, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.12 +..B1.9: + orl $-64768, %eax + movw %ax, 72(%rsp) +..B1.10: + fldcw 72(%rsp) +..B1.11: + movzwl 104(%rsp), %edi + movb $1, %cl + andl $32767, %edi +..B1.12: + testl %edi, %edi + jle ..B1.64 +..B1.13: + fldt 96(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rdx + fldl (%rax) + fmul %st(1), %st + fsubp %st, %st(1) + fmull (%rdx) + fstpt (%rsp) +..B1.14: + testb %cl, %cl + je ..B1.16 +..B1.15: + fldcw 74(%rsp) +..B1.16: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.17: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.21 +..B1.18: + orl $-64768, %eax + movw %ax, 72(%rsp) +..B1.19: + fldcw 72(%rsp) +..B1.20: + movb $1, %cl +..B1.21: + fldt 96(%rsp) + lea _P2(%rip), %rax + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.23 +..B1.22: + fldcw 74(%rsp) +..B1.23: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.24: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.28 +..B1.25: + orl $-64768, %eax + movw %ax, 72(%rsp) +..B1.26: + fldcw 72(%rsp) +..B1.27: + movb $1, %cl +..B1.28: + fldt 96(%rsp) + lea 16+_P1(%rip), %rax + fld %st(0) + lea _P1(%rip), %rdx + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.30 +..B1.29: + fldcw 74(%rsp) +..B1.30: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.31: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.35 +..B1.32: + orl $-64768, %eax + movw %ax, 72(%rsp) +..B1.33: + fldcw 72(%rsp) +..B1.34: + movb $1, %cl +..B1.35: + fldt 96(%rsp) + lea 48+_P(%rip), %rax + fld %st(0) + lea 32+_P(%rip), %rsi + fmul %st(1), %st + lea 16+_P(%rip), %rdx + fld %st(0) + lea _P(%rip), %rdi + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.37 +..B1.36: + fldcw 74(%rsp) +..B1.37: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.38: + movl %eax, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.42 +..B1.39: + orl $-64768, %eax + movw %ax, 72(%rsp) +..B1.40: + fldcw 72(%rsp) +..B1.41: + movb $1, %cl +..B1.42: + fldt 96(%rsp) + lea ones(%rip), %rax + movl %edx, %edx + lea _TWO_63H(%rip), %rsi + fldl (%rax,%rdx,8) + fmul %st, %st(1) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + movzwl 104(%rsp), %edi + andl $32767, %edi + fxch %st(1) + fstpl 64(%rsp) + cmpl $16383, %edi + fldl (%rsi) + jge ..B1.44 +..B1.43: + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_48H(%rip), %rax + fmul %st(2), %st + fadd %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(2) + fld %st(3) + fld %st(4) + movl 16(%rsp), %edx + fxch %st(4) + fsubrp %st, %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + fldl (%rax) + fmul %st, %st(2) + fxch %st(2) + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(2) + fmul %st, %st(4) + fld %st(1) + fmul %st(4), %st + fxch %st(1) + fmulp %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.2(%rip) + fadd %st, %st(3) + fldt .L_2il0floatpacket.3(%rip) + fstpt (%rsp) + jmp ..B1.45 +..B1.44: + fldt .L_2il0floatpacket.2(%rip) + fld %st(2) + fdivrp %st, %st(1) + lea _TWO_48H(%rip), %rax + fld %st(2) + fldt .L_2il0floatpacket.0(%rip) + fmulp %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(2) + fld %st(2) + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(3) + fldl (%rax) + fmul %st, %st(2) + movl 16(%rsp), %edx + fxch %st(1) + fadd %st(2), %st + negl %edx + fsubp %st, %st(2) + fld %st(1) + addl $256, %edx + fmul %st(3), %st + fld %st(2) + fadd %st(4), %st + fxch %st(3) + fsubr %st, %st(5) + fld %st(5) + fmul %st(5), %st + fldt .L_2il0floatpacket.3(%rip) + fstpt (%rsp) + fldt (%rsp) + faddp %st, %st(3) + fld %st(3) + fmul %st(5), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + fxch %st(1) + fsubr %st(4), %st + fsubrp %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fldt .L_2il0floatpacket.2(%rip) +..B1.45: + fld %st(3) + lea 48+_P(%rip), %rax + lea 32+_P(%rip), %rdi + lea 16+_P(%rip), %rsi + lea _P(%rip), %r8 + lea _TWO_32H(%rip), %r9 + movslq %edx, %rdx + fadd %st(6), %st + fdivrp %st, %st(1) + fmul %st, %st(2) + fld %st(2) + shlq $4, %rdx + fadd %st(1), %st + movq __libm_atanl_table_128@GOTPCREL(%rip), %r10 + testb %cl, %cl + fsubp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fld %st(4) + fmul %st(4), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(5) + fxch %st(7) + faddp %st, %st(5) + fxch %st(3) + fstpt 48(%rsp) + fldt (%rsp) + faddp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fmul %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fldt 48(%rsp) + fmulp %st, %st(2) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt (%rax) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + fmulp %st, %st(4) + fldt (%r8) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fldl (%r10,%rdx) + fld %st(0) + fadd %st(2), %st + fldl (%r9) + fmul %st(1), %st + fadd %st, %st(1) + fsubr %st(1), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + faddl 8(%r10,%rdx) + faddp %st, %st(1) + faddp %st, %st(1) + fmull 64(%rsp) + fstpt 32(%rsp) + je ..B1.74 +..B1.46: + fstpt 16(%rsp) +..B1.73: + fldcw 74(%rsp) + jmp ..B1.47 +..B1.74: + fstp %st(0) +..B1.47: + fldt 32(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.48: + movl %eax, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.52 +..B1.49: + orl $-64768, %eax + movw %ax, 72(%rsp) +..B1.50: + fldcw 72(%rsp) +..B1.51: + movzwl 104(%rsp), %edi + movb $1, %cl + andl $32767, %edi +..B1.52: + cmpl $32767, %edi + je ..B1.68 +..B1.53: + cmpl $16448, %edi + jge ..B1.60 +..B1.54: + fldt 96(%rsp) + xorl %esi, %esi + testl %edx, %edx + lea ones(%rip), %rdi + sete %sil + fdivrl (%rdi,%rsi,8) + fstpt 96(%rsp) + fldt 96(%rsp) + movzwl 104(%rsp), %eax + andl $32767, %eax + fstpt (%rsp) + cmpl $16398, %eax + jge ..B1.56 +..B1.55: + fldt (%rsp) + lea 16+_P1(%rip), %rax + fld %st(0) + lea _P1(%rip), %rsi + fmul %st(1), %st + fldt (%rax) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + jmp ..B1.59 +..B1.56: + cmpl $16408, %eax + jge ..B1.59 +..B1.57: + fldt (%rsp) + lea _P2(%rip), %rax + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) +..B1.59: + fldt .L_2il0floatpacket.4(%rip) + fldt (%rsp) + movl %edx, %edx + faddp %st, %st(1) + fldt .L_2il0floatpacket.5(%rip) + faddp %st, %st(1) + fmull (%rdi,%rdx,8) + fstpt (%rsp) + jmp ..B1.61 +..B1.60: + movl %edx, %edx + lea _pi_2l(%rip), %rax + shlq $4, %rdx + lea _small_value_80(%rip), %rsi + fldt (%rdx,%rax) + fldt (%rdx,%rsi) + fsubrp %st, %st(1) + fstpt (%rsp) +..B1.61: + testb %cl, %cl + je ..B1.63 +..B1.62: + fldcw 74(%rsp) +..B1.63: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.64: + cmpl $0, 100(%rsp) + jne ..B1.66 +..B1.65: + cmpl $0, 96(%rsp) + je ..B1.67 +..B1.66: + fldt 96(%rsp) + lea _small_value_80(%rip), %rax + shlq $4, %rdx + fldt (%rax) + fldt (%rax,%rdx) + fmulp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.14 +..B1.67: + fldt 96(%rsp) + fstpt (%rsp) + jmp ..B1.14 +..B1.68: + cmpl $-2147483648, 100(%rsp) + jne ..B1.70 +..B1.69: + cmpl $0, 96(%rsp) + je ..B1.53 +..B1.70: + fldt 96(%rsp) + fstpt (%rsp) + jmp ..B1.61 + .align 16,0x90 + .cfi_endproc + .type atanl,@function + .size atanl,.-atanl + .data +# -- End atanl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x88,0x19,0x13,0xd3,0x08,0xa3,0x85,0xdd,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0xa2,0xda,0x0f,0xc9,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_P2: + .word 43691 + .word 41642 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .type _P2,@object + .size _P2,16 + .align 2 +_P1: + .word 23723 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 22830 + .word 33705 + .word 52154 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,32 + .align 2 +_P: + .word 43664 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 43235 + .word 52379 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59507 + .word 38278 + .word 9340 + .word 37449 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 9132 + .word 55602 + .word 8665 + .word 58245 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,64 + .align 2 +_pi_2l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _pi_2l,@object + .size _pi_2l,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/atanl_table.S b/external/sgx_libm/intel64/atanl_table.S new file mode 100644 index 0000000000..5127afbea7 --- /dev/null +++ b/external/sgx_libm/intel64/atanl_table.S @@ -0,0 +1,1073 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "atanl_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_atanl_table_128 +__libm_atanl_table_128: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x55c00000,0x3f7fffd5 + .long 0x4bfcee57,0xbd5115a3 + .long 0x5bc00000,0x3f8fff55 + .long 0x220c39d5,0xbd623595 + .long 0x18800000,0x3f97fee0 + .long 0x286313f8,0xbdaad1e5 + .long 0xbb800000,0x3f9ffd55 + .long 0x542779d7,0x3da4bb12 + .long 0xf1600000,0x3fa3fd65 + .long 0x2e4614e3,0x3d9393b2 + .long 0x84400000,0x3fa7fb81 + .long 0x0c377c7c,0xbd9e4bac + .long 0xf1400000,0x3fabf8dd + .long 0x89fe34b3,0xbd88eef1 + .long 0xb7400000,0x3faff55b + .long 0x39269b0e,0xbda30216 + .long 0xbf000000,0x3fb1f86d + .long 0xbda88e23,0x3da05ab1 + .long 0x0e800000,0x3fb3f59f + .long 0xa7663af4,0xbd8d5314 + .long 0x4fc00000,0x3fb5f232 + .long 0x62a36910,0x3db2d7b2 + .long 0x26000000,0x3fb7ee18 + .long 0x6093567e,0x3d878874 + .long 0x53c00000,0x3fb9e941 + .long 0xd19970eb,0x3dafb9e2 + .long 0xbe400000,0x3fbbe39e + .long 0xbef71e53,0x3dc783e1 + .long 0x70400000,0x3fbddd21 + .long 0xcd620065,0xbdc0a2c8 + .long 0x9ac00000,0x3fbfd5ba + .long 0x39a6ed0d,0xbdb3d092 + .long 0xcce00000,0x3fc0e6ad + .long 0x8a397391,0x3dc40881 + .long 0xfb000000,0x3fc1e1fa + .long 0x92de9bad,0x3da0dc9b + .long 0xb3000000,0x3fc2dcbd + .long 0x386bc7d5,0xbda17803 + .long 0xe8c00000,0x3fc3d6ee + .long 0x61a3b0cf,0x3da989b1 + .long 0xa9c00000,0x3fc4d087 + .long 0x47cc8fc7,0x3dca4f17 + .long 0x1e400000,0x3fc5c981 + .long 0x0a956580,0xbd83d962 + .long 0x89800000,0x3fc6c1d4 + .long 0xb5aad628,0x3db267b1 + .long 0x4c000000,0x3fc7b97b + .long 0xecb84f4b,0xbdd8d27e + .long 0xe2800000,0x3fc8b06e + .long 0xee732cfd,0x3dae70a2 + .long 0xe9400000,0x3fc9a6a8 + .long 0x0e7b00f4,0x3dd64313 + .long 0x1b400000,0x3fca9c23 + .long 0xd177d13a,0x3d593ca1 + .long 0x52c00000,0x3fcb90d7 + .long 0xfdd09de6,0xbdd6cfae + .long 0x8a800000,0x3fcc84bf + .long 0x656f741a,0xbdb7a324 + .long 0xdf400000,0x3fcd77d5 + .long 0x8e6dcbab,0xbdcfa8c9 + .long 0x8e800000,0x3fce6a14 + .long 0x619ac881,0x3dc6ec4d + .long 0xf9400000,0x3fcf5b75 + .long 0x9d52470c,0xbdc37f22 + .long 0x51200000,0x3fd025fa + .long 0x59cb7da1,0xbdd99a4a + .long 0x97c00000,0x3fd09dc5 + .long 0x58b91ce4,0x3dd86362 + .long 0x36200000,0x3fd1151a + .long 0xb2372370,0x3db0c726 + .long 0xa3200000,0x3fd18bf5 + .long 0xd9e6b717,0xbdd40e87 + .long 0x67e00000,0x3fd20255 + .long 0x73e6e6b8,0x3db1f257 + .long 0x20400000,0x3fd27837 + .long 0xbe20c8b2,0x3dd7ef45 + .long 0x7a800000,0x3fd2ed98 + .long 0xb91258ea,0x3da1e7f1 + .long 0x37000000,0x3fd36277 + .long 0x34e2d5da,0x3dbfaf2f + .long 0x29400000,0x3fd3d6d1 + .long 0xbb20d6f9,0xbdd8eecb + .long 0x36c00000,0x3fd44aa4 + .long 0x45437875,0x3da5784d + .long 0x58600000,0x3fd4bdee + .long 0x86c8e20f,0x3dc121cd + .long 0x99400000,0x3fd530ad + .long 0xdb5336ff,0x3dd1cd49 + .long 0x17400000,0x3fd5a2e0 + .long 0x44edea3e,0x3dde0f4e + .long 0x03000000,0x3fd61484 + .long 0x2c6d4754,0x3dc39fc3 + .long 0x9f400000,0x3fd68597 + .long 0xf6d43f59,0x3ddfa6fd + .long 0x41c00000,0x3fd6f619 + .long 0x4738aa32,0x3de26f78 + .long 0x52800000,0x3fd76607 + .long 0x11774372,0x3d97501f + .long 0x4b400000,0x3fd7d560 + .long 0xad3910b8,0x3de1d9fb + .long 0xb9000000,0x3fd84422 + .long 0x4512bfad,0xbde03514 + .long 0x39400000,0x3fd8b24d + .long 0xdb685d1c,0x3dc4364a + .long 0x7cc00000,0x3fd91fde + .long 0x441d0620,0x3dd0c662 + .long 0x45400000,0x3fd98cd5 + .long 0xcf364c48,0x3dcad630 + .long 0x66000000,0x3fd9f930 + .long 0x8df63ee1,0x3dd68001 + .long 0xc3c00000,0x3fda64ee + .long 0x6d909f25,0x3dc847f9 + .long 0x54400000,0x3fdad00f + .long 0x80ecf31e,0xbdddfa74 + .long 0x1dc00000,0x3fdb3a91 + .long 0x9479e139,0xbdd9a393 + .long 0x37800000,0x3fdba473 + .long 0x519a1b47,0x3db89295 + .long 0xc9400000,0x3fdc0db4 + .long 0x19f18c7b,0x3dcd93df + .long 0x0ac00000,0x3fdc7655 + .long 0x5d2e2ffe,0xbdd28e07 + .long 0x43000000,0x3fdcde53 + .long 0x4ba60b78,0x3de609a8 + .long 0xca000000,0x3fdd45ae + .long 0xced7bdd4,0xbdd379d4 + .long 0x05800000,0x3fddac67 + .long 0x97520377,0xbdde44b0 + .long 0x6b000000,0x3fde127b + .long 0xb53d9e72,0x3dbd12bf + .long 0x7f400000,0x3fde77eb + .long 0xde35847d,0xbde452e5 + .long 0xd4400000,0x3fdedcb6 + .long 0xf25d8cc2,0xbd7ef2c7 + .long 0x0b800000,0x3fdf40dd + .long 0x1a3992dc,0xbde5f5f4 + .long 0xd3400000,0x3fdfa45d + .long 0xb94ac7b8,0xbdeeb6d3 + .long 0x73e00000,0x3fe0039c + .long 0x6ccb2527,0xbdee5bf4 + .long 0x09400000,0x3fe034b7 + .long 0xce0c98e5,0xbdeafb77 + .long 0x94e00000,0x3fe0657e + .long 0xeada4afb,0xbdc33cc0 + .long 0x08600000,0x3fe095f3 + .long 0xdbc9bebd,0x3daa58fd + .long 0x5b600000,0x3fe0c614 + .long 0xcd160bd9,0xbdc2f097 + .long 0x8b600000,0x3fe0f5e2 + .long 0x004c46c6,0x3dcf8a54 + .long 0x9be00000,0x3fe1255d + .long 0xf6a1288f,0x3debd2a8 + .long 0x96400000,0x3fe15485 + .long 0xa5d3e2a4,0xbdd1372c + .long 0x88c00000,0x3fe1835a + .long 0xe778c500,0xbda83ec8 + .long 0x87800000,0x3fe1b1dc + .long 0xede17375,0x3de04284 + .long 0xabe00000,0x3fe1e00b + .long 0xc946f944,0xbda014c0 + .long 0x13e00000,0x3fe20de8 + .long 0x43714561,0x3dd04763 + .long 0xe2c00000,0x3fe23b71 + .long 0x3884393e,0x3dd93cd4 + .long 0x40800000,0x3fe268a9 + .long 0xf1765bb0,0xbde69259 + .long 0x59400000,0x3fe2958e + .long 0x4279cec3,0xbddee39e + .long 0x5e000000,0x3fe2c221 + .long 0xd68fde4c,0x3db2232f + .long 0x84000000,0x3fe2ee62 + .long 0xc5d5e9ff,0x3dcb2f29 + .long 0x04a00000,0x3fe31a52 + .long 0xafcd51e1,0xbde78b41 + .long 0x1ce00000,0x3fe345f0 + .long 0xbbf7bb21,0xbde1c844 + .long 0x0e000000,0x3fe3713d + .long 0x14f789e0,0xbdd275f8 + .long 0x1ce00000,0x3fe39c39 + .long 0x9182198f,0xbdd7d1cc + .long 0x91c00000,0x3fe3c6e4 + .long 0x1ebaf6b0,0x3dce3712 + .long 0xb8a00000,0x3fe3f13f + .long 0x260e96db,0xbda690bc + .long 0xe0800000,0x3fe41b4a + .long 0xec29f5ad,0xbde015be + .long 0x5b800000,0x3fe44506 + .long 0xfbb680b2,0xbdca92a8 + .long 0x7f000000,0x3fe46e72 + .long 0x39b9b1b8,0xbdab8ea1 + .long 0xa3200000,0x3fe4978f + .long 0x920cd440,0x3dca7b84 + .long 0x22e00000,0x3fe4c05e + .long 0x02b07c28,0xbda6b1b7 + .long 0x5ba00000,0x3fe4e8de + .long 0x528cf6fb,0x3de6ec04 + .long 0xadc00000,0x3fe51110 + .long 0x91ee6b42,0x3dc7b604 + .long 0x7b800000,0x3fe538f5 + .long 0x72245aa1,0x3dd20c3d + .long 0x29c00000,0x3fe5608d + .long 0x9939cf0e,0x3dcc30d1 + .long 0x1f800000,0x3fe587d8 + .long 0x57972763,0xbdd9a08a + .long 0xc5800000,0x3fe5aed6 + .long 0x5cc4bdc5,0x3de09517 + .long 0x87000000,0x3fe5d589 + .long 0x10028e4c,0x3de69b18 + .long 0xd0c00000,0x3fe5fbf0 + .long 0xf2598180,0x3de5cc49 + .long 0x11400000,0x3fe6220d + .long 0xed487acb,0x3ded7b8d + .long 0xb8c00000,0x3fe647de + .long 0xf84d7eff,0x3df105c7 + .long 0x39400000,0x3fe66d66 + .long 0x2dd4dfd8,0xbdec1f79 + .long 0x05400000,0x3fe692a4 + .long 0x7652e56a,0x3de6fb6a + .long 0x92000000,0x3fe6b798 + .long 0x2bfe3cf4,0x3dd67b31 + .long 0x55000000,0x3fe6dc44 + .long 0xf203bce5,0x3de553ae + .long 0xc5800000,0x3fe700a7 + .long 0xc61a692d,0xbdcee730 + .long 0x5b400000,0x3fe724c3 + .long 0x1948b32e,0x3ddf5cf6 + .long 0x8f800000,0x3fe74897 + .long 0x82f654c3,0x3dfd4707 + .long 0xdcc00000,0x3fe76c24 + .long 0x1952551b,0x3dcb1b01 + .long 0xbd400000,0x3fe78f6b + .long 0x501a8226,0x3ded315e + .long 0xad400000,0x3fe7b26c + .long 0x73a037cc,0xbde1af02 + .long 0x28c00000,0x3fe7d528 + .long 0x553efbc4,0xbdf02fb6 + .long 0xacc00000,0x3fe7f79e + .long 0x02a357f1,0xbdca1d9e + .long 0xb7400000,0x3fe819d0 + .long 0x9bf7622a,0xbdf53ad9 + .long 0xc6000000,0x3fe83bbe + .long 0xf677c77e,0xbdf908ee + .long 0x57800000,0x3fe85d69 + .long 0xe9499180,0xbde33d3a + .long 0xeb000000,0x3fe87ed0 + .long 0xef50a527,0xbdf1d2ea + .long 0xff800000,0x3fe89ff5 + .long 0x2ab734bc,0xbdf40704 + .long 0x14400000,0x3fe8c0d9 + .long 0x6fa901db,0x3decf49d + .long 0xa9800000,0x3fe8e17a + .long 0xc27cfaaa,0x3decc05d + .long 0x3ec00000,0x3fe901db + .long 0xad0ccbcb,0x3df778c3 + .long 0x54400000,0x3fe921fb + .long 0x1a626331,0x3dc0b461 + .long 0x69800000,0x3fe9421b + .long 0x33179a03,0x3de968a9 + .long 0xff000000,0x3fe9627b + .long 0x354bc911,0xbde4662d + .long 0x94400000,0x3fe9831d + .long 0xe277d043,0xbde49a6c + .long 0xa9000000,0x3fe9a400 + .long 0x714fcd89,0x3df8341c + .long 0xbdc00000,0x3fe9c525 + .long 0x942d841a,0xbde3fff9 + .long 0x51000000,0x3fe9e68d + .long 0x767ac319,0x3deb976b + .long 0xe2c00000,0x3fea0837 + .long 0x177cfdb1,0xbdc64fc6 + .long 0xf1800000,0x3fea2a25 + .long 0x75c01427,0xbdda6038 + .long 0xfbc00000,0x3fea4c57 + .long 0x1bb40f2a,0x3dddc330 + .long 0x80000000,0x3fea6ece + .long 0xc850d6e0,0xbde74662 + .long 0xfb400000,0x3fea9189 + .long 0x00d16965,0x3dea0933 + .long 0xeb000000,0x3feab48a + .long 0x1e8b57b9,0x3df59469 + .long 0xcbc00000,0x3fead7d1 + .long 0x6dc9c51f,0x3da93704 + .long 0x18c00000,0x3feafb5f + .long 0x0e891026,0x3ddb9843 + .long 0x4d400000,0x3feb1f33 + .long 0xfdcc9ff9,0xbdcd5129 + .long 0xe3400000,0x3feb434e + .long 0xa0a41a0e,0xbdf7f601 + .long 0x53800000,0x3feb67b2 + .long 0xc9a51699,0xbdd9f2fc + .long 0x16800000,0x3feb8c5e + .long 0x466f670a,0xbdb71b40 + .long 0xa3400000,0x3febb152 + .long 0xd24367a3,0xbddd4273 + .long 0x6f800000,0x3febd690 + .long 0x44f9ee90,0xbdeb8656 + .long 0xef800000,0x3febfc17 + .long 0x4e4b19cd,0x3df32750 + .long 0x97400000,0x3fec21e9 + .long 0x60174932,0xbde5215d + .long 0xd7c00000,0x3fec4805 + .long 0xca509fcf,0xbddae432 + .long 0x21800000,0x3fec6e6d + .long 0x05a2b966,0xbddc81cf + .long 0xe2c00000,0x3fec951f + .long 0x983639ea,0x3dfbe28c + .long 0x89000000,0x3fecbc1e + .long 0xb8fcc54a,0x3de52a75 + .long 0x7ec00000,0x3fece369 + .long 0x6e2bdd53,0x3da4dfc2 + .long 0x2d000000,0x3fed0b01 + .long 0x7c1f76fe,0xbd957dc5 + .long 0xfac00000,0x3fed32e5 + .long 0x45acb642,0x3db3657b + .long 0x4cc00000,0x3fed5b18 + .long 0x3aa43a9e,0x3de16e2c + .long 0x85c00000,0x3fed8398 + .long 0x02a3c6a5,0xbde63ab4 + .long 0x05800000,0x3fedac67 + .long 0x97520377,0xbdee44b0 + .long 0x29800000,0x3fedd584 + .long 0x41999968,0x3dd42635 + .long 0x4d000000,0x3fedfef0 + .long 0x983da38a,0x3dddfdb5 + .long 0xc8400000,0x3fee28ab + .long 0x43526c5d,0xbdf3c808 + .long 0xf0000000,0x3fee52b6 + .long 0xb06de4fa,0xbde63cc3 + .long 0x16c00000,0x3fee7d12 + .long 0xb04e7d93,0x3d998d80 + .long 0x8b800000,0x3feea7bd + .long 0x6af91f30,0x3dfa218b + .long 0x9a800000,0x3feed2b9 + .long 0x97acf689,0x3de1952c + .long 0x8bc00000,0x3feefe06 + .long 0xdb5c4d1a,0xbdc7762a + .long 0xa4000000,0x3fef29a4 + .long 0x017c85fc,0xbd6a8dc3 + .long 0x24800000,0x3fef5594 + .long 0xbbbb718e,0x3da8e661 + .long 0x4a800000,0x3fef81d5 + .long 0x497cd73d,0x3dc8572a + .long 0x4f400000,0x3fefae68 + .long 0xae6e18fa,0x3de7cbff + .long 0x68000000,0x3fefdb4d + .long 0x7ea78d48,0x3deeec8a + .long 0x62e00000,0x3ff00442 + .long 0x3c43ac1a,0xbdc110e6 + .long 0x4a400000,0x3ff01b07 + .long 0x75bc4774,0x3df01b3f + .long 0x7e400000,0x3ff031f5 + .long 0x4ce2d096,0x3df4adbe + .long 0x10800000,0x3ff0490d + .long 0x82c10772,0xbdcfa151 + .long 0x0fe00000,0x3ff0604e + .long 0x37517bd1,0x3dd3bc3a + .long 0x89200000,0x3ff077b8 + .long 0xe01b22eb,0x3de0f5c6 + .long 0x86600000,0x3ff08f4c + .long 0x34b7fb7b,0xbdf9bc3c + .long 0x0e800000,0x3ff0a70a + .long 0xc68f0ff4,0x3df03bcd + .long 0x26800000,0x3ff0bef1 + .long 0x403b5a47,0x3df68b2b + .long 0xd0000000,0x3ff0d701 + .long 0x57ba4ad6,0x3df35a50 + .long 0x09e00000,0x3ff0ef3c + .long 0x38183ba9,0xbde2d69f + .long 0xcfc00000,0x3ff1079f + .long 0xa4c23582,0xbdecaa57 + .long 0x1a600000,0x3ff1202d + .long 0xe7f15aff,0x3dcad893 + .long 0xdf800000,0x3ff138e3 + .long 0x19efe544,0x3dcc4411 + .long 0x11600000,0x3ff151c4 + .long 0xa76ac475,0x3dee5024 + .long 0x9f200000,0x3ff16acd + .long 0x0e8af659,0x3df44c0b + .long 0x74800000,0x3ff18400 + .long 0xa4ca4f57,0xbdba974c + .long 0x79800000,0x3ff19d5c + .long 0x5a25f72a,0x3dc2df62 + .long 0x92e00000,0x3ff1b6e1 + .long 0xd8da3354,0x3de77c88 + .long 0xa1c00000,0x3ff1d08f + .long 0xf49d1082,0x3de2171a + .long 0x83800000,0x3ff1ea66 + .long 0x7ce9b3be,0xbddb5eef + .long 0x11800000,0x3ff20466 + .long 0x1de424cc,0x3df8d09a + .long 0x22000000,0x3ff21e8e + .long 0x394b3186,0xbdef0ac7 + .long 0x86600000,0x3ff238de + .long 0x8bf7b8bf,0x3dc51f77 + .long 0x0cc00000,0x3ff25357 + .long 0x2bb7111b,0x3dfa95fd + .long 0x7f400000,0x3ff26df7 + .long 0x64b0a9b1,0xbdd1512a + .long 0xa3400000,0x3ff288bf + .long 0x18e684e8,0x3df12419 + .long 0x3ac00000,0x3ff2a3af + .long 0xce4f6ebe,0xbdb72e81 + .long 0x03000000,0x3ff2bec6 + .long 0xa69c6179,0xbdee5b5b + .long 0xb5000000,0x3ff2da03 + .long 0x6b22ae89,0x3deff6ff + .long 0x06000000,0x3ff2f568 + .long 0x29a8e5ae,0xbdecb362 + .long 0xa6000000,0x3ff310f2 + .long 0xd243f145,0x3de88f44 + .long 0x41600000,0x3ff32ca3 + .long 0xdff820e0,0x3de68034 + .long 0x7fa00000,0x3ff34879 + .long 0x5295ddf4,0x3dce7ebe + .long 0x03c00000,0x3ff36475 + .long 0x45f88767,0x3de5eab8 + .long 0x6c600000,0x3ff38095 + .long 0x91c711ec,0x3de886b1 + .long 0x53800000,0x3ff39cda + .long 0x10aefe1c,0x3dbb91fe + .long 0x4e800000,0x3ff3b943 + .long 0x4aa2e1c3,0xbdf356bb + .long 0xee000000,0x3ff3d5cf + .long 0x303c34f3,0xbdf0463a + .long 0xbe200000,0x3ff3f27f + .long 0x2b7ef915,0x3de411bd + .long 0x46a00000,0x3ff40f52 + .long 0x472305ef,0xbde8fd54 + .long 0x09e00000,0x3ff42c47 + .long 0x3560ce8b,0x3dfa68cb + .long 0x86a00000,0x3ff4495d + .long 0xacb59491,0xbdfdcdda + .long 0x35a00000,0x3ff46695 + .long 0xc6803028,0x3dcceec5 + .long 0x8c200000,0x3ff483ed + .long 0xae20cd3f,0x3dec628d + .long 0xfa600000,0x3ff4a165 + .long 0x30a5d59f,0xbdf4f20d + .long 0xeb800000,0x3ff4befd + .long 0xd1246921,0x3db30ba3 + .long 0xc6c00000,0x3ff4dcb4 + .long 0x922b65ab,0xbdd37d68 + .long 0xee400000,0x3ff4fa89 + .long 0x60d4a327,0x3dec287f + .long 0xc0000000,0x3ff5187c + .long 0xe85bc1a4,0x3dc49d56 + .long 0x95200000,0x3ff5368c + .long 0x5bd1e523,0xbdb63036 + .long 0xc2600000,0x3ff554b8 + .long 0x9a653fbc,0x3df14f8e + .long 0x98800000,0x3ff57300 + .long 0x8799adbe,0xbdffddce + .long 0x62c00000,0x3ff59163 + .long 0x4677c807,0x3e0ad3a5 + .long 0x6a000000,0x3ff5afe0 + .long 0xf3e67f75,0xbdec3df7 + .long 0xf0c00000,0x3ff5ce76 + .long 0x1e243ad8,0x3dfc26c9 + .long 0x37000000,0x3ff5ed26 + .long 0x82f9d88f,0x3df69c53 + .long 0x78000000,0x3ff60bed + .long 0xa1b60137,0xbde98cd9 + .long 0xeac00000,0x3ff62acb + .long 0x038d593e,0x3de4c370 + .long 0xc3400000,0x3ff649c0 + .long 0x6a610a4b,0xbe067cb1 + .long 0x30800000,0x3ff668cb + .long 0xaa91e345,0xbdcd59a7 + .long 0x5f000000,0x3ff687ea + .long 0xbb3e0da7,0x3de1c66a + .long 0x77400000,0x3ff6a71d + .long 0x447484ba,0xbdf49f35 + .long 0x9e000000,0x3ff6c663 + .long 0x9fa408f5,0xbdfb4727 + .long 0xf5000000,0x3ff6e5bb + .long 0x95fe5c11,0xbdfc59cc + .long 0x9a800000,0x3ff70525 + .long 0x0aa8b52d,0x3e02d604 + .long 0xaac00000,0x3ff7249f + .long 0x4ae67c31,0xbe034aef + .long 0x3d400000,0x3ff74429 + .long 0x0226c6c8,0x3dc20b8b + .long 0x68800000,0x3ff763c1 + .long 0xf8a3257f,0xbe0161b1 + .long 0x3f000000,0x3ff78367 + .long 0xc02f3514,0x3ddcbd24 + .long 0xd2000000,0x3ff7a319 + .long 0xa2288de1,0xbdfc01f8 + .long 0x2f400000,0x3ff7c2d8 + .long 0x81b988ed,0x3ddbfe74 + .long 0x63800000,0x3ff7e2a1 + .long 0xc80c4d5f,0xbe01cc20 + .long 0x78400000,0x3ff80274 + .long 0xb8ab545b,0x3df3aa42 + .long 0x76800000,0x3ff82250 + .long 0xf0c39b49,0x3de58a51 + .long 0x64c00000,0x3ff84234 + .long 0x594dab29,0xbdd68427 + .long 0x48000000,0x3ff8621f + .long 0x7b64bb5f,0x3e015323 + .long 0x24c00000,0x3ff88210 + .long 0x0881fe1d,0xbddc84da + .long 0xfd400000,0x3ff8a205 + .long 0xb3f75cfe,0x3df5873f + .long 0xd4000000,0x3ff8c1ff + .long 0x90244e94,0xbdfcfc58 + .long 0xa9800000,0x3ff8e1fc + .long 0x22533dd2,0x3de96c66 + .long 0x7ec00000,0x3ff901fb + .long 0xd7b5cc04,0x3e0738ae + .long 0x54400000,0x3ff921fb + .long 0x1a626331,0x3dd0b461 + .long 0x29800000,0x3ff941fb + .long 0xddc59991,0x3df9e8d2 + .long 0xff000000,0x3ff961f9 + .long 0x0fe1b542,0xbdd1700a + .long 0xd4c00000,0x3ff981f6 + .long 0xe2aa7fd3,0xbdfaa976 + .long 0xab400000,0x3ff9a1f0 + .long 0x4d8c56ca,0xbdea5a1e + .long 0x83c00000,0x3ff9c1e6 + .long 0x1ea36240,0x3deef6ce + .long 0x60800000,0x3ff9e1d7 + .long 0x69984526,0xbdfa4c16 + .long 0x43c00000,0x3ffa01c2 + .long 0xc70938c6,0x3debf674 + .long 0x32000000,0x3ffa21a6 + .long 0x5984e061,0xbdc357c3 + .long 0x30400000,0x3ffa4182 + .long 0x56f44585,0xbde6a024 + .long 0x45000000,0x3ffa6155 + .long 0x0ea4e62b,0x3e05f939 + .long 0x79400000,0x3ffa811e + .long 0xcc2cf5d5,0x3db5a936 + .long 0xd6c00000,0x3ffaa0dc + .long 0xd0a64087,0xbdfba3d6 + .long 0x69800000,0x3ffac08f + .long 0xd256453b,0x3db2ae75 + .long 0x40000000,0x3ffae035 + .long 0x3f3bbe4b,0x3e058eca + .long 0x6b400000,0x3ffaffcd + .long 0xb3b162ff,0x3dd862fc + .long 0xfe000000,0x3ffb1f56 + .long 0xdd01d604,0xbdf10ff0 + .long 0x0e000000,0x3ffb3ed1 + .long 0x882038c2,0xbdfd51d7 + .long 0xb3c00000,0x3ffb5e3a + .long 0xdcd07256,0xbdfb4c02 + .long 0x0ac00000,0x3ffb7d93 + .long 0xd32ac572,0xbdfc5ea7 + .long 0x31400000,0x3ffb9cd9 + .long 0xd1a5b653,0x3dfcf965 + .long 0x49800000,0x3ffbbc0c + .long 0x0dbaa75b,0xbda1209a + .long 0x78000000,0x3ffbdb2b + .long 0x0506dc03,0x3de80acb + .long 0xe5800000,0x3ffbfa35 + .long 0x3c1973a2,0xbde558d9 + .long 0xbdc00000,0x3ffc192a + .long 0xa4abd834,0xbdc03c3b + .long 0x30c00000,0x3ffc3809 + .long 0x50f9e6e6,0xbe056fb1 + .long 0x71800000,0x3ffc56d0 + .long 0xeb914ded,0xbdec8445 + .long 0xb7c00000,0x3ffc757f + .long 0x90f3093f,0xbdf3cc98 + .long 0x3e800000,0x3ffc9416 + .long 0x87247153,0x3df6792c + .long 0x45800000,0x3ffcb293 + .long 0x0041a18b,0x3df2b2e6 + .long 0x10000000,0x3ffcd0f6 + .long 0x8a656fab,0x3e041bff + .long 0xe6000000,0x3ffcef3d + .long 0xf2cbf1dc,0x3df70aa1 + .long 0x13400000,0x3ffd0d6a + .long 0xf97727f5,0x3e04de99 + .long 0xe8800000,0x3ffd2b79 + .long 0xc096e590,0x3dd71a16 + .long 0xba400000,0x3ffd496c + .long 0x8ce47feb,0xbdd6e83c + .long 0xe2000000,0x3ffd6741 + .long 0xa721fa7e,0xbe09633a + .long 0xbd000000,0x3ffd84f8 + .long 0x407bac1a,0x3ddca5d9 + .long 0xae400000,0x3ffda290 + .long 0x1147c641,0xbdc59e12 + .long 0x1c400000,0x3ffdc009 + .long 0xb620caf9,0x3dfa28e9 + .long 0x73000000,0x3ffddd61 + .long 0x2b9ed46c,0xbdfb43a8 + .long 0x22400000,0x3ffdfa99 + .long 0x630c9ceb,0xbe0cebfa + .long 0x9e800000,0x3ffe17af + .long 0xafa0c61c,0x3debe2ca + .long 0x61c00000,0x3ffe34a4 + .long 0x58615a48,0x3e0a6c6d + .long 0xea400000,0x3ffe5176 + .long 0xf771b50e,0x3dfe5151 + .long 0xba800000,0x3ffe6e26 + .long 0xbd6d668c,0x3df8a06a + .long 0x5a000000,0x3ffe8ab3 + .long 0xd7d4135c,0x3dfbb0eb + .long 0x55000000,0x3ffea71c + .long 0xb09906dc,0x3dda8442 + .long 0x3c000000,0x3ffec361 + .long 0xc44da8a3,0x3dfc16d7 + .long 0xa4c00000,0x3ffedf81 + .long 0xae5890d5,0xbdc4d95c + .long 0x29000000,0x3ffefb7d + .long 0x3d218a26,0xbdfb75a7 + .long 0x67400000,0x3fff1753 + .long 0xf1656f6c,0xbe0172f4 + .long 0x02800000,0x3fff3304 + .long 0xdf863851,0xbdcf6b8e + .long 0xa2800000,0x3fff4e8e + .long 0xa205a470,0x3df6b3e1 + .long 0xf3800000,0x3fff69f2 + .long 0xa18096af,0xbdde853c + .long 0xa5800000,0x3fff8530 + .long 0x607f6255,0x3df787de + .long 0x6dc00000,0x3fffa047 + .long 0x542c5109,0x3de39a31 + .long 0x05400000,0x3fffbb37 + .long 0x176aa69e,0xbde193d1 + .long 0x29400000,0x3fffd5ff + .long 0x4cbab80a,0x3de95cf6 + .long 0x9bc00000,0x3ffff09f + .long 0x9e85df82,0xbdf23bcc + .long 0x11200000,0x4000058c + .long 0x644dc57f,0xbdfa49be + .long 0x43400000,0x400012b4 + .long 0x29d6ca5c,0x3df7df94 + .long 0x4b800000,0x40001fc8 + .long 0x90b2f333,0xbdf07669 + .long 0x12800000,0x40002cc8 + .long 0xd8d73d10,0x3dee63d8 + .long 0x83600000,0x400039b3 + .long 0xa3aad512,0xbda62b9d + .long 0x8ac00000,0x4000468a + .long 0x20c417ef,0x3dfc9bec + .long 0x17800000,0x4000534d + .long 0x07b1cace,0x3dd7f911 + .long 0x1a000000,0x40005ffb + .long 0xaefbad1c,0x3de4074a + .long 0x84a00000,0x40006c94 + .long 0x7ea63b40,0x3df40e25 + .long 0x4b800000,0x40007919 + .long 0x397bcf5e,0x3df9321e + .long 0x64800000,0x40008589 + .long 0xa7ccd3c1,0x3dd346b9 + .long 0xc7200000,0x400091e4 + .long 0xefccf9c7,0xbdfb00e1 + .long 0x6c800000,0x40009e2b + .long 0xd036d9d3,0xbe04a851 + .long 0x4f600000,0x4000aa5d + .long 0xad856126,0xbdec74ff + .long 0x6c400000,0x4000b67a + .long 0x9512327c,0xbde6003f + .long 0xc1000000,0x4000c282 + .long 0x6614515e,0xbdec61f5 + .long 0x4d000000,0x4000ce76 + .long 0xe577796c,0xbddf8674 + .long 0x11200000,0x4000da55 + .long 0x0f49689f,0x3dc0b366 + .long 0x0fa00000,0x4000e61f + .long 0x1d23a023,0x3dffdf4d + .long 0x4c600000,0x4000f1d4 + .long 0x00a32d5c,0xbdfc94de + .long 0xcc000000,0x4000fd74 + .long 0x7b12a50e,0x3de89cb5 + .long 0x95200000,0x40010900 + .long 0x7f633dfc,0xbde8a71b + .long 0xaf200000,0x40011477 + .long 0xa22c576e,0xbddf043b + .long 0x22e00000,0x40011fda + .long 0xab4658e4,0xbdf583b2 + .long 0xfa400000,0x40012b27 + .long 0xc88a542e,0xbddc7052 + .long 0x40600000,0x40013661 + .long 0xb5fa251c,0x3dfc7430 + .long 0x01a00000,0x40014186 + .long 0x10065ac4,0x3dd53d2d + .long 0x4b200000,0x40014c96 + .long 0xfd4d5831,0x3dde4bf5 + .long 0x2b400000,0x40015792 + .long 0xdd63dfb7,0x3de0ceee + .long 0xb1400000,0x40016279 + .long 0xf44e5d9e,0x3e05a47a + .long 0xeda00000,0x40016d4c + .long 0xa9526aef,0xbd9c196f + .long 0xf1600000,0x4001780b + .long 0xddc7ed97,0xbdf1c75a + .long 0xce800000,0x400182b6 + .long 0x4537fbd1,0x3e03f9fd + .long 0x98600000,0x40018d4d + .long 0xcd4bedf5,0xbe0643b6 + .long 0x62400000,0x400197d0 + .long 0x7be31051,0xbdceee39 + .long 0x41000000,0x4001a23f + .long 0xe43916c2,0x3dab5864 + .long 0x49e00000,0x4001ac9a + .long 0xe65659f4,0x3dca8519 + .long 0x92e00000,0x4001b6e1 + .long 0xd8da3354,0x3df77c88 + .long 0x32e00000,0x4001c115 + .long 0xe2f9d62a,0xbde910ea + .long 0x41200000,0x4001cb35 + .long 0xc81075db,0xbe002e72 + .long 0xd5a00000,0x4001d541 + .long 0x272999cb,0xbdf8dc27 + .long 0x09000000,0x4001df3b + .long 0x46435ee9,0x3de1604f + .long 0xf4a00000,0x4001e920 + .long 0x86402d52,0xbdf84ccd + .long 0xb2000000,0x4001f2f3 + .long 0x7a698864,0xbdc1d852 + .long 0x5b800000,0x4001fcb3 + .long 0xe9f5ef5e,0x3de8ef47 + .long 0x0be00000,0x40020660 + .long 0x9d33bfe4,0x3deef548 + .long 0xde400000,0x40020ff9 + .long 0x9fe2acc6,0x3e07899e + .long 0xee800000,0x40021980 + .long 0x8586539c,0xbdea2a41 + .long 0x58600000,0x400222f5 + .long 0x8233d068,0xbde59a3f + .long 0x38600000,0x40022c57 + .long 0xafae28e0,0x3df61d5b + .long 0xab600000,0x400235a6 + .long 0xc0e105c1,0x3e07d566 + .long 0xcea00000,0x40023ee3 + .long 0x23305012,0x3de397c9 + .long 0xbf600000,0x4002480e + .long 0x7f34ee7e,0x3dedaddf + .long 0x9b800000,0x40025127 + .long 0x7552e9aa,0x3d940c8b + .long 0x80e00000,0x40025a2e + .long 0xe67562cc,0x3e06022a + .long 0x8e200000,0x40026323 + .long 0x36711271,0xbdfe8be0 + .long 0xe1400000,0x40026c06 + .long 0x34e171b8,0x3e03c83c + .long 0x99800000,0x400274d8 + .long 0x22b44c41,0xbdea7471 + .long 0xd5600000,0x40027d98 + .long 0x0cc87ce6,0x3dfb5597 + .long 0xb4400000,0x40028647 + .long 0xf1599d09,0x3df3fd61 + .long 0x55400000,0x40028ee5 + .long 0x432216e7,0x3e0074b2 + .long 0xd7e00000,0x40029771 + .long 0x55426d45,0x3dede47d + .long 0x5b800000,0x40029fed + .long 0xa81068a7,0x3e059214 + .long 0x00000000,0x4002a858 + .long 0xb830bfcf,0xbdd5c614 + .long 0xe4c00000,0x4002b0b1 + .long 0xaba3f9d3,0x3e092d16 + .long 0x2a000000,0x4002b8fb + .long 0xc83d37e0,0xbdefb3d7 + .long 0xef200000,0x4002c133 + .long 0x7f368cdd,0x3e0953b3 + .long 0x54800000,0x4002c95c + .long 0x27d71621,0x3df28d47 + .long 0x79e00000,0x4002d174 + .long 0x316a6da4,0xbdd16890 + .long 0x7f400000,0x4002d97c + .long 0x961b1ace,0xbdf9bc5b + .long 0x84800000,0x4002e184 + .long 0xe02465ce,0x3df0e16c + .long 0xa9e00000,0x4002e99c + .long 0x50352ef1,0xbdd817f9 + .long 0x0f400000,0x4002f1c5 + .long 0x1551a7ab,0xbe03100f + .long 0xd4800000,0x4002f9fd + .long 0xa40bccd6,0xbe01cf65 + .long 0x19800000,0x40030247 + .long 0x7c81d6bf,0x3dfa2d1b + .long 0xfe600000,0x40030aa0 + .long 0x01d5fa59,0x3df1f8ce + .long 0xa2c00000,0x4003130b + .long 0xc1d47c8b,0x3e00b18f + .long 0x26800000,0x40031b87 + .long 0xb6bb61ec,0xbdc357ae + .long 0xa9200000,0x40032413 + .long 0xb27a6369,0xbdf4621b + .long 0x4a200000,0x40032cb1 + .long 0x763f4a8f,0xbdddd864 + .long 0x29000000,0x40033560 + .long 0x71fd6503,0xbded9c9c + .long 0x64e00000,0x40033e20 + .long 0x6523f086,0x3df9c181 + .long 0x1d200000,0x400346f2 + .long 0x95f9190b,0xbdfb092f + .long 0x70600000,0x40034fd5 + .long 0xf5c5232a,0xbdf4ecd6 + .long 0x7d800000,0x400358ca + .long 0xf920fb33,0xbdff7d0c + .long 0x62e00000,0x400361d1 + .long 0x4be8fd7d,0x3de86e2d + .long 0x3f000000,0x40036aea + .long 0x5e8566d0,0xbdc27d37 + .long 0x2fc00000,0x40037415 + .long 0x118d12de,0x3dc5db22 + .long 0x53000000,0x40037d52 + .long 0x56fc208e,0xbe0191c2 + .long 0xc5e00000,0x400386a1 + .long 0x920dd0c2,0x3e0b34f6 + .long 0xa6200000,0x40039003 + .long 0xb58e26b3,0xbe0455cb + .long 0x10000000,0x40039978 + .long 0x34b985e6,0xbe0331cb + .long 0x20200000,0x4003a2ff + .long 0x35fdc794,0xbe0145fa + .long 0xf2800000,0x4003ac98 + .long 0xd680ac6a,0xbdc79adb + .long 0xa2e00000,0x4003b645 + .long 0x9da56c1b,0x3d6f49bd + .long 0x4c600000,0x4003c005 + .long 0x462df6e3,0x3ded84a6 + .long 0x09e00000,0x4003c9d8 + .long 0xa5f60849,0xbdfb2be9 + .long 0xf5600000,0x4003d3bd + .long 0x8540d783,0x3dceb909 + .long 0x28c00000,0x4003ddb7 + .long 0xfd79b218,0x3e02b1b7 + .long 0xbd400000,0x4003e7c3 + .long 0x31f55b0e,0x3e067217 + .long 0xcb800000,0x4003f1e3 + .long 0x4546b57a,0x3df90fbe + .long 0x6b600000,0x4003fc17 + .long 0xfd77cb88,0x3e0a855f + .long 0xb4800000,0x4004065e + .long 0x2dfdfe4d,0x3de26d4b + .long 0xbd600000,0x400410b9 + .long 0x5950035e,0x3de7590b + .long 0x9c200000,0x40041b28 + .long 0x03462c6f,0x3df06510 + .long 0x66200000,0x400425ab + .long 0x467966c2,0xbddbc526 + .long 0x2fe00000,0x40043042 + .long 0xb6a62d3d,0xbdfb6cb1 + .long 0x0d200000,0x40043aed + .long 0x27372402,0xbe00d8ae + .long 0x10c00000,0x400445ac + .long 0x24de2821,0x3de9ef5d + .long 0x4d200000,0x4004507f + .long 0x14d2f0d7,0xbdfec1ad + .long 0xd3200000,0x40045b66 + .long 0x945f6a25,0x3dd07f45 + .long 0xb3400000,0x40046662 + .long 0x51d9d163,0x3dd3d12d + .long 0xfcc00000,0x40047172 + .long 0x3f20ced0,0x3ddcdff6 + .long 0xbe000000,0x40047c97 + .long 0xc460b56d,0xbdefd9cf + .long 0x04200000,0x400487d1 + .long 0x85ec5f71,0x3df3a35d + .long 0xdba00000,0x4004931e + .long 0x80efdcb7,0xbdfdf504 + .long 0x4f400000,0x40049e81 + .long 0xbc54e040,0x3df44857 + .long 0x69400000,0x4004a9f8 + .long 0x937b6963,0x3df8dad6 + .long 0x32600000,0x4004b584 + .long 0x203bef0d,0x3d8c770b + .long 0xb2000000,0x4004c124 + .long 0x6a367be0,0x3e048e13 + .long 0xeec00000,0x4004ccd9 + .long 0x4959d5be,0xbdf35804 + .long 0xed400000,0x4004d8a3 + .long 0x23c13aa2,0x3de4e1b8 + .long 0xb1600000,0x4004e482 + .long 0x0d27a8c0,0x3df468e6 + .long 0x3d600000,0x4004f076 + .long 0x86d3f314,0x3dfab843 + .long 0x92200000,0x4004fc7e + .long 0x9e52e3a3,0x3df78768 + .long 0xaf200000,0x4005089b + .long 0xaab9c284,0xbe029f1b + .long 0x92000000,0x400514cd + .long 0x179103ea,0xbde45027 + .long 0x37400000,0x40052114 + .long 0x61cb6216,0x3e03c415 + .long 0x99e00000,0x40052d6f + .long 0xa75a55d3,0x3dded669 + .long 0xb2e00000,0x400539df + .long 0xcb6409f3,0xbde955aa + .long 0x79c00000,0x40054664 + .long 0xab71c36a,0xbdde1b72 + .long 0xe4600000,0x400552fd + .long 0xe25f9eb7,0x3dc41d1b + .long 0xe6c00000,0x40055fab + .long 0x247755ec,0x3e11a241 + .long 0x73800000,0x40056c6e + .long 0x5982d93b,0x3e07f5ae + .long 0x7b000000,0x40057945 + .long 0x81ce421b,0x3dea714b + .long 0xec000000,0x40058630 + .long 0xe6287509,0xbe10aaa8 + .long 0xb3000000,0x40059330 + .long 0xcdc1a134,0xbe018126 + .long 0xbb000000,0x4005a044 + .long 0x54f98005,0x3e0a53da + .long 0xed800000,0x4005ad6c + .long 0x31fa1c07,0xbe164bbe + .long 0x30800000,0x4005baa9 + .long 0x724fa9e7,0x3dfec315 + .long 0x69c00000,0x4005c7f9 + .long 0x49c8cff7,0xbd839929 + .long 0x7c000000,0x4005d55d + .long 0xa8203893,0xbe1aabb3 + .long 0x47800000,0x4005e2d5 + .long 0x4d9d0f03,0x3dc5d181 + .long 0xab800000,0x4005f060 + .long 0x39a53408,0x3e0a7fb5 + .long 0x84c00000,0x4005fdff + .long 0x01eb07f8,0xbe05ebb4 + .long 0xad400000,0x40060bb1 + .long 0x338ef683,0xbe128b26 + .long 0xfd400000,0x40061976 + .long 0xa822b748,0xbe07c5a2 + .long 0x4ac00000,0x4006274f + .long 0x5b4a549e,0x3e07b699 + .long 0x6a000000,0x4006353a + .long 0xef14ab75,0xbdf8030f + .long 0x2c000000,0x40064338 + .long 0xd329b8ff,0x3dee44e8 + .long 0x60800000,0x40065148 + .long 0xbc20f78f,0xbe13e3e3 + .long 0xd3c00000,0x40065f6a + .long 0x09e8e22c,0x3e11798e + .long 0x51400000,0x40066d9f + .long 0x7dfadb85,0x3e086b2e + .long 0xa1000000,0x40067be5 + .long 0x0b2e31ec,0x3e09f36f + .long 0x89400000,0x40068a3d + .long 0x23a7eaa9,0xbdf1ca09 + .long 0xcd800000,0x400698a6 + .long 0xee7c7516,0xbe0428c8 + .long 0x2f000000,0x4006a721 + .long 0xbdfcb3ab,0x3e0f4af1 + .long 0x6d400000,0x4006b5ac + .long 0x6678c10f,0x3e1197cf + .long 0x45000000,0x4006c448 + .long 0x0097612f,0xbdf8350f + .long 0x70400000,0x4006d2f4 + .long 0xc4ae0128,0xbdeb4341 + .long 0xa7400000,0x4006e1b0 + .long 0x2be5865a,0x3dee7616 + .long 0xa0000000,0x4006f07c + .long 0xbe2a9051,0xbe0d5116 + .long 0x0d800000,0x4006ff58 + .long 0xbe4813cb,0xbda6483b + .long 0xa1400000,0x40070e42 + .long 0xf702ea60,0x3df24157 + .long 0x0a000000,0x40071d3c + .long 0xc8e90440,0x3e11b030 + .long 0xf4800000,0x40072c43 + .long 0x3836de9f,0x3e18b285 + .long 0x0b400000,0x40073b5a + .long 0x707eec44,0x3e0abe53 + .long 0xf6400000,0x40074a7d + .long 0xdf7f7587,0x3e0227a4 + .long 0x5b800000,0x400759af + .long 0x69c4146d,0x3e0cea31 + .long 0xdf000000,0x400768ed + .long 0x2652ac89,0x3e0b070e + .long 0x22800000,0x40077839 + .long 0xb25e69d2,0x3e0029f0 + .long 0xc5800000,0x40078790 + .long 0xf2649c57,0x3e16b25a + .long 0x66400000,0x400796f4 + .long 0x229099f4,0xbe122655 + .long 0x9f800000,0x4007a663 + .long 0x90be8ad7,0x3ded1da0 + .long 0x0b800000,0x4007b5de + .long 0x5c75a10e,0x3e15cced + .long 0x42400000,0x4007c563 + .long 0xd4519719,0x3e102078 + .long 0xd9800000,0x4007d4f2 + .long 0x690de7e8,0x3e134413 + .long 0x65c00000,0x4007e48c + .long 0xfddbebee,0xbdf0721c + .long 0x79000000,0x4007f42f + .long 0x537a47ec,0x3e0472f8 + .long 0xa4800000,0x400803db + .long 0xd84d1e5e,0x3e03e9a5 + .long 0x77800000,0x40081390 + .long 0xa415fcda,0xbdf626df + .long 0x7f800000,0x4008234d + .long 0x279a2fcb,0xbe013463 + .long 0x48c00000,0x40083312 + .long 0x9b75c695,0x3dd9ba26 + .long 0x5e400000,0x400842de + .long 0x2aa926e7,0x3e00b4da + .long 0x49c00000,0x400852b1 + .long 0x44adccf7,0xbe0a51cf + .long 0x93400000,0x4008628a + .long 0x16e3fd45,0xbe15f538 + .long 0xc1c00000,0x40087269 + .long 0xce0df60f,0x3de6596a + .long 0x5c000000,0x4008824e + .long 0x5260007c,0xbe17daca + .long 0xe6400000,0x40089237 + .long 0xff43ed28,0x3df7d75a + .long 0xe5800000,0x4008a225 + .long 0x6082ccc7,0xbe0886df + .long 0xdc800000,0x4008b217 + .long 0xfbad1fdf,0xbdb73f18 + .long 0x4e400000,0x4008c20d + .long 0xc29df075,0xbdf92ca0 + .long 0xbc800000,0x4008d205 + .long 0xdc3f35d7,0xbdc7a0f1 + .long 0xa8c00000,0x4008e200 + .long 0xfa8ff5ca,0x3df9b457 + .long 0x94400000,0x4008f1fd + .long 0x1262ed72,0xbe1633d0 + .long 0xff000000,0x400901fb + .long 0x541ee425,0xbe078e5a + .long 0x69800000,0x400911fb + .long 0xfb02186a,0x3e094f3a + .long 0x54400000,0x400921fb + .long 0x1a626331,0x3de0b461 + .type __libm_atanl_table_128,@object + .size __libm_atanl_table_128,8208 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/cabs.S b/external/sgx_libm/intel64/cabs.S new file mode 100644 index 0000000000..4b3e945ec7 --- /dev/null +++ b/external/sgx_libm/intel64/cabs.S @@ -0,0 +1,73 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cabs.c" + .text +..TXTST0: +# -- Begin cabs + .text + .align 16,0x90 + .globl cabs +cabs: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cabs.1: +..L2: + + movaps %xmm0, %xmm2 + pushq %rsi + .cfi_def_cfa_offset 16 + movaps %xmm1, %xmm0 + movaps %xmm2, %xmm1 + call hypot@PLT +..B1.4: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cabs,@function + .size cabs,.-cabs + .data +# -- End cabs + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cabsf.S b/external/sgx_libm/intel64/cabsf.S new file mode 100644 index 0000000000..c6252af3d6 --- /dev/null +++ b/external/sgx_libm/intel64/cabsf.S @@ -0,0 +1,76 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cabsf.c" + .text +..TXTST0: +# -- Begin cabsf + .text + .align 16,0x90 + .globl cabsf +cabsf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cabsf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + pxor %xmm1, %xmm1 + movsd %xmm0, (%rsp) + pxor %xmm0, %xmm0 + cvtss2sd 4(%rsp), %xmm0 + cvtss2sd (%rsp), %xmm1 + call hypot@PLT +..B1.4: + cvtsd2ss %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cabsf,@function + .size cabsf,.-cabsf + .data +# -- End cabsf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cabsl.S b/external/sgx_libm/intel64/cabsl.S new file mode 100644 index 0000000000..e1c51f4639 --- /dev/null +++ b/external/sgx_libm/intel64/cabsl.S @@ -0,0 +1,74 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cabsl.c" + .text +..TXTST0: +# -- Begin cabsl + .text + .align 16,0x90 + .globl cabsl +cabsl: +# parameter 1: 16 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cabsl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + fldt 64(%rsp) + fstpt (%rsp) + fldt 48(%rsp) + fstpt 16(%rsp) + call hypotl@PLT +..B1.4: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cabsl,@function + .size cabsl,.-cabsl + .data +# -- End cabsl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cacos.S b/external/sgx_libm/intel64/cacos.S new file mode 100644 index 0000000000..8f29e29b03 --- /dev/null +++ b/external/sgx_libm/intel64/cacos.S @@ -0,0 +1,743 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacos.c" + .text +..TXTST0: +# -- Begin cacosf + .text + .align 16,0x90 + .globl cacosf +cacosf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cacosf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_cacosf.4: + call cacos@PLT +..___tag_value_cacosf.5: +..B1.10: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + movsd %xmm0, 4(%rsp) + movzwl 6(%rsp), %eax + testl $32640, %eax + jne ..B1.4 +..B1.3: + testl $8388607, 4(%rsp) + jne ..B1.6 +..B1.4: + movzwl 10(%rsp), %eax + testl $32640, %eax + jne ..B1.7 +..B1.5: + testl $8388607, 8(%rsp) + je ..B1.7 +..B1.6: + movss .L_2il0floatpacket.12(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) + movsd 4(%rsp), %xmm0 +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cacosf,@function + .size cacosf,.-cacosf + .data +# -- End cacosf + .text +# -- Begin cacos + .text + .align 16,0x90 + .globl cacos +cacos: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_cacos.8: +..L9: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + xorb %r12b, %r12b + subq $152, %rsp + .cfi_def_cfa_offset 176 + movsd %xmm0, 32(%rsp) + movsd %xmm1, 40(%rsp) +..B2.2: + fnstcw 138(%rsp) +..B2.3: + movzwl 38(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + jge ..B2.36 +..B2.4: + testl %edx, %edx + jle ..B2.57 +..B2.5: + movzwl 46(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2047, %eax + jge ..B2.36 +..B2.6: + testl %eax, %eax + jle ..B2.55 +..B2.7: + movzwl 138(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.11 +..B2.8: + orl $-64768, %edx + movw %dx, 136(%rsp) +..B2.9: + fldcw 136(%rsp) +..B2.10: + movb $1, %r12b +..B2.11: + fldt .L_2il0floatpacket.14(%rip) + lea BcrossA(%rip), %rax + movsd 32(%rsp), %xmm0 + fld %st(0) + fldt .L_2il0floatpacket.15(%rip) + movsd %xmm0, 120(%rsp) + fldt (%rax) + andps .L_2il0floatpacket.18(%rip), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + movsd 40(%rsp), %xmm1 + fadd %st, %st(3) + movsd %xmm1, 128(%rsp) + andps .L_2il0floatpacket.18(%rip), %xmm1 + movsd %xmm1, (%rsp) + fxch %st(3) + fstpt 104(%rsp) + fldt 104(%rsp) + fxch %st(3) + fsubr %st, %st(4) + fxch %st(4) + fstpt 88(%rsp) + fldt 88(%rsp) + fxch %st(3) + fmul %st(0), %st + fxch %st(3) + fmul %st(0), %st + fldl (%rsp) + fld %st(0) + fmul %st(1), %st + fadd %st, %st(5) + fxch %st(5) + fsqrt + fld %st(0) + fxch %st(3) + fadd %st(6), %st + fsqrt + fstpt 72(%rsp) + fldt 72(%rsp) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + fld %st(5) + fdiv %st(2), %st + fxch %st(3) + fcomip %st(3), %st + jbe ..B2.13 +..B2.12: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fxch %st(1) + fstpt (%rsp) + fxch %st(3) + fstpl 80(%rsp) + fstpt 16(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + call acosl@PLT +..B2.78: + fldt 48(%rsp) + fldt 32(%rsp) + fldt 16(%rsp) + fldl 80(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + jmp ..B2.16 +..B2.13: + fstp %st(2) + fldt .L_2il0floatpacket.14(%rip) + fcomip %st(5), %st + jb ..B2.15 +..B2.14: + fstp %st(1) + fldt .L_2il0floatpacket.15(%rip) + addq $-32, %rsp + .cfi_def_cfa_offset 208 + fld %st(2) + fld %st(2) + fadd %st(6), %st + fmulp %st, %st(2) + fldt 136(%rsp) + faddp %st, %st(1) + fdivr %st(4), %st + fldt 104(%rsp) + fldt 120(%rsp) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fsqrt + fstpt (%rsp) + fxch %st(3) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpl 96(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + fstpt 64(%rsp) + call atan2l@PLT + jmp ..B2.80 + .cfi_def_cfa_offset 176 +..B2.15: + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 208 + fld %st(2) + fadd %st(5), %st + fldt 136(%rsp) + faddp %st, %st(2) + fdiv %st, %st(1) + fldt 104(%rsp) + fldt 120(%rsp) + fsubrp %st, %st(1) + fdivrp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.15(%rip) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + fstpt (%rsp) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpl 96(%rsp) + fstpt 48(%rsp) + fstpt 64(%rsp) + fldt 32(%rsp) + fstpt 32(%rsp) + call atan2l@PLT +..B2.80: + fldt 64(%rsp) + fldt 48(%rsp) + fldt 32(%rsp) + fldl 96(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 176 +..B2.16: + lea AcrossA(%rip), %rax + fldt (%rax) + fcomip %st(4), %st + jb ..B2.21 +..B2.17: + fldt 104(%rsp) + faddp %st, %st(2) + fldt .L_2il0floatpacket.14(%rip) + fcomip %st(1), %st + fstp %st(0) + jbe ..B2.19 +..B2.18: + fldt 72(%rsp) + fxch %st(1) + fdivr %st(2), %st + fldt 88(%rsp) + faddp %st, %st(2) + fxch %st(1) + fdivrp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.15(%rip) + fmulp %st, %st(1) + jmp ..B2.20 +..B2.19: + fldt 88(%rsp) + fxch %st(1) + fdivrp %st, %st(2) + fldt 72(%rsp) + fsubp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.15(%rip) + fmulp %st, %st(1) +..B2.20: + fldt .L_2il0floatpacket.14(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call log1pl@PLT + jmp ..B2.82 + .cfi_def_cfa_offset 176 +..B2.21: + fstp %st(1) + fstp %st(1) + fstp %st(0) + fldt .L_2il0floatpacket.14(%rip) + fld %st(1) + fmul %st(2), %st + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fsubp %st, %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call logl@PLT +..B2.82: + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 +..B2.22: + lea ZEROA(%rip), %rax + movsd (%rax), %xmm1 + comisd 120(%rsp), %xmm1 + jbe ..B2.24 +..B2.23: + fldt .L_2il0floatpacket.16(%rip) + lea PIBY2HIA(%rip), %rax + lea PIBY2LOA(%rip), %rdx + fldl (%rax) + faddl (%rdx) + fmulp %st, %st(1) + fsubp %st, %st(1) +..B2.24: + movsd 128(%rsp), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B2.26 +..B2.25: + fldt .L_2il0floatpacket.17(%rip) + fmulp %st, %st(2) +..B2.26: + fstpl 16(%rsp) + movzwl 22(%rsp), %eax + testl $32752, %eax + fstpl 24(%rsp) + jne ..B2.29 +..B2.27: + testl $1048575, 20(%rsp) + jne ..B2.32 +..B2.28: + cmpl $0, 16(%rsp) + jne ..B2.32 +..B2.29: + movzwl 30(%rsp), %eax + testl $32752, %eax + jne ..B2.33 +..B2.30: + testl $1048575, 28(%rsp) + jne ..B2.32 +..B2.31: + cmpl $0, 24(%rsp) + je ..B2.33 +..B2.32: + lea _LDB_MIN_NORMAL(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 48(%rsp) +..B2.33: + testb %r12b, %r12b + je ..B2.35 +..B2.34: + fldcw 138(%rsp) +..B2.35: + movsd 16(%rsp), %xmm0 + movsd 24(%rsp), %xmm1 + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B2.36: + testl %edx, %edx + jne ..B2.40 +..B2.37: + testl $1048575, 36(%rsp) + jne ..B2.40 +..B2.38: + cmpl $0, 32(%rsp) + jne ..B2.40 +..B2.39: + movsd 40(%rsp), %xmm0 + movq $0x3ff921fb54442d18, %rax + movq %rax, 16(%rsp) + call asinh@PLT +..B2.83: + xorps .L_2il0floatpacket.19(%rip), %xmm0 + movsd %xmm0, 24(%rsp) + movsd 16(%rsp), %xmm0 + movhpd 24(%rsp), %xmm0 + jmp ..B2.54 +..B2.40: + movzwl 46(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2047, %eax + je ..B2.72 +..B2.89: + cmpl $2047, %edx +..B2.41: + je ..B2.62 +..B2.42: + cmpl $2047, %eax + je ..B2.59 +..B2.43: + testl %eax, %eax + jne ..B2.50 +..B2.44: + testl $1048575, 44(%rsp) + jne ..B2.50 +..B2.45: + cmpl $0, 40(%rsp) + jne ..B2.50 +..B2.46: + movsd 32(%rsp), %xmm0 + cmpl $1023, %edx + jl ..B2.48 +..B2.47: + movb 39(%rsp), %r12b + andb $-128, %r12b + shrb $7, %r12b + movzbl %r12b, %eax + lea ones(%rip), %r12 + movsd (%r12,%rax,8), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm1, (%rsp) + call acosh@PLT +..B2.85: + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + call acos@PLT +..B2.84: + movsd %xmm0, 16(%rsp) + jmp ..B2.49 +..B2.48: + pxor %xmm1, %xmm1 + movsd %xmm1, 8(%rsp) + call acos@PLT +..B2.86: + movsd %xmm0, 16(%rsp) + lea ones(%rip), %r12 +..B2.49: + movb 47(%rsp), %al + andb $-128, %al + shrb $7, %al + movsd 8(%rsp), %xmm0 + xorb $1, %al + movzbl %al, %edx + mulsd (%r12,%rdx,8), %xmm0 + movsd %xmm0, 24(%rsp) + movsd 16(%rsp), %xmm0 + movhpd 24(%rsp), %xmm0 + jmp ..B2.54 +..B2.50: + movsd 40(%rsp), %xmm0 + cmpl $2047, %eax + movsd 32(%rsp), %xmm1 + je ..B2.52 +..B2.51: + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + jmp ..B2.53 +..B2.52: + movaps %xmm0, %xmm2 + mulsd %xmm0, %xmm2 +..B2.53: + movb 47(%rsp), %r13b + andb $-128, %r13b + shrb $7, %r13b + movb %r13b, %r12b + xorb $1, %r12b + movzbl %r12b, %eax + lea ones(%rip), %r12 + mulsd (%r12,%rax,8), %xmm2 + movsd %xmm2, 24(%rsp) + call atan2@PLT +..B2.87: + movzbl %r13b, %eax + mulsd (%r12,%rax,8), %xmm0 + movsd %xmm0, 16(%rsp) + movhpd 24(%rsp), %xmm0 +..B2.54: + movaps %xmm0, %xmm1 + unpckhpd %xmm0, %xmm1 + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B2.55: + testl $1048575, 44(%rsp) + jne ..B2.7 +..B2.56: + cmpl $0, 40(%rsp) + jne ..B2.7 + jmp ..B2.36 +..B2.57: + testl $1048575, 36(%rsp) + jne ..B2.5 +..B2.58: + cmpl $0, 32(%rsp) + jne ..B2.5 + jmp ..B2.36 +..B2.59: + testl $1048575, 44(%rsp) + jne ..B2.61 +..B2.60: + cmpl $0, 40(%rsp) + je ..B2.50 +..B2.61: + movsd 32(%rsp), %xmm1 + movsd 40(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + unpcklpd %xmm1, %xmm0 + movsd %xmm0, 16(%rsp) + movhpd %xmm0, 24(%rsp) + jmp ..B2.54 +..B2.62: + testl $1048575, 36(%rsp) + jne ..B2.64 +..B2.63: + cmpl $0, 32(%rsp) + je ..B2.66 +..B2.64: + cmpl $2047, %eax + jge ..B2.66 +..B2.65: + movsd 32(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm0 + movsd %xmm0, 16(%rsp) + movhpd %xmm0, 24(%rsp) + jmp ..B2.54 +..B2.66: + testl $1048575, 36(%rsp) + jne ..B2.68 +..B2.67: + cmpl $0, 32(%rsp) + je ..B2.42 +..B2.68: + cmpl $2047, %eax + jne ..B2.43 +..B2.69: + testl $1048575, 44(%rsp) + jne ..B2.71 +..B2.70: + cmpl $0, 40(%rsp) + je ..B2.59 +..B2.71: + movsd 32(%rsp), %xmm0 + movsd 40(%rsp), %xmm1 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + unpcklpd %xmm1, %xmm0 + movsd %xmm0, 16(%rsp) + movhpd %xmm0, 24(%rsp) + jmp ..B2.54 +..B2.72: + testl $1048575, 44(%rsp) + jne ..B2.74 +..B2.73: + cmpl $0, 40(%rsp) + je ..B2.88 +..B2.74: + cmpl $2047, %edx + jge ..B2.41 +..B2.75: + movsd 40(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm0 + movsd %xmm0, 16(%rsp) + movhpd %xmm0, 24(%rsp) + jmp ..B2.54 +..B2.88: + cmpl $2047, %edx + je ..B2.62 + jmp ..B2.42 + .align 16,0x90 + .cfi_endproc + .type cacos,@function + .size cacos,.-cacos + .data +# -- End cacos + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.14: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,16 + .align 16 +.L_2il0floatpacket.15: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.16: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,16 + .align 16 +.L_2il0floatpacket.17: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,16 + .align 16 +.L_2il0floatpacket.18: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,16 + .align 16 +.L_2il0floatpacket.19: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.19,@object + .size .L_2il0floatpacket.19,16 + .align 16 +BcrossA: + .long 3621516424 + .long 2756080513 + .long 16382 + .long 0 + .type BcrossA,@object + .size BcrossA,16 + .align 16 +AcrossA: + .long 0 + .long 3221225472 + .long 16383 + .long 0 + .type AcrossA,@object + .size AcrossA,16 + .align 16 +ZEROA: + .long 0 + .long 0 + .type ZEROA,@object + .size ZEROA,8 + .space 8, 0x00 # pad + .align 16 +PIBY2HIA: + .long 1413754136 + .long 1073291771 + .type PIBY2HIA,@object + .size PIBY2HIA,8 + .space 8, 0x00 # pad + .align 16 +PIBY2LOA: + .long 856972295 + .long 1016178214 + .type PIBY2LOA,@object + .size PIBY2LOA,8 + .space 8, 0x00 # pad + .align 16 +_LDB_MIN_NORMAL: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _LDB_MIN_NORMAL,@object + .size _LDB_MIN_NORMAL,16 + .align 8 +.L_2il0floatpacket.13: + .long 0x54442d18,0x3ff921fb + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +.L_2il0floatpacket.12: + .long 0x00800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cacosh.S b/external/sgx_libm/intel64/cacosh.S new file mode 100644 index 0000000000..d3232ca863 --- /dev/null +++ b/external/sgx_libm/intel64/cacosh.S @@ -0,0 +1,739 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacosh.c" + .text +..TXTST0: +# -- Begin cacoshf + .text + .align 16,0x90 + .globl cacoshf +cacoshf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cacoshf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_cacoshf.4: + call cacosh@PLT +..___tag_value_cacoshf.5: +..B1.10: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + movsd %xmm0, 4(%rsp) + movzwl 6(%rsp), %eax + testl $32640, %eax + jne ..B1.4 +..B1.3: + testl $8388607, 4(%rsp) + jne ..B1.6 +..B1.4: + movzwl 10(%rsp), %eax + testl $32640, %eax + jne ..B1.7 +..B1.5: + testl $8388607, 8(%rsp) + je ..B1.7 +..B1.6: + movss .L_2il0floatpacket.12(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) + movsd 4(%rsp), %xmm0 +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cacoshf,@function + .size cacoshf,.-cacoshf + .data +# -- End cacoshf + .text +# -- Begin cacosh + .text + .align 16,0x90 + .globl cacosh +cacosh: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_cacosh.8: +..L9: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + xorb %r13b, %r13b + subq $160, %rsp + .cfi_def_cfa_offset 176 + movsd %xmm0, 136(%rsp) + movsd %xmm1, 144(%rsp) +..B2.2: + fnstcw 154(%rsp) +..B2.3: + movzwl 142(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + jge ..B2.36 +..B2.4: + testl %edx, %edx + jle ..B2.62 +..B2.5: + movzwl 150(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2047, %eax + jge ..B2.37 +..B2.6: + testl %eax, %eax + jle ..B2.60 +..B2.7: + movzwl 154(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.11 +..B2.8: + orl $-64768, %edx + movw %dx, 152(%rsp) +..B2.9: + fldcw 152(%rsp) +..B2.10: + movb $1, %r13b +..B2.11: + fldt .L_2il0floatpacket.13(%rip) + lea BcrossA(%rip), %rax + movsd 136(%rsp), %xmm0 + fld %st(0) + fldt .L_2il0floatpacket.14(%rip) + movsd %xmm0, 128(%rsp) + fldt (%rax) + andps .L_2il0floatpacket.17(%rip), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + movsd 144(%rsp), %xmm1 + fadd %st, %st(3) + movsd %xmm1, 120(%rsp) + andps .L_2il0floatpacket.17(%rip), %xmm1 + movsd %xmm1, (%rsp) + fxch %st(3) + fstpt 104(%rsp) + fldt 104(%rsp) + fxch %st(3) + fsubr %st, %st(4) + fxch %st(4) + fstpt 88(%rsp) + fldt 88(%rsp) + fxch %st(3) + fmul %st(0), %st + fxch %st(3) + fmul %st(0), %st + fldl (%rsp) + fld %st(0) + fmul %st(1), %st + fadd %st, %st(5) + fxch %st(5) + fsqrt + fld %st(0) + fxch %st(3) + fadd %st(6), %st + fsqrt + fstpt 72(%rsp) + fldt 72(%rsp) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + fld %st(5) + fdiv %st(2), %st + fxch %st(3) + fcomip %st(3), %st + jbe ..B2.13 +..B2.12: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fxch %st(1) + fstpt (%rsp) + fxch %st(3) + fstpl 80(%rsp) + fstpt 16(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + call acosl@PLT +..B2.84: + fldt 48(%rsp) + fldt 32(%rsp) + fldt 16(%rsp) + fldl 80(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + jmp ..B2.16 +..B2.13: + fstp %st(2) + fldt .L_2il0floatpacket.13(%rip) + fcomip %st(5), %st + jb ..B2.15 +..B2.14: + fstp %st(1) + fldt .L_2il0floatpacket.14(%rip) + addq $-32, %rsp + .cfi_def_cfa_offset 208 + fld %st(2) + fld %st(2) + fadd %st(6), %st + fmulp %st, %st(2) + fldt 136(%rsp) + faddp %st, %st(1) + fdivr %st(4), %st + fldt 104(%rsp) + fldt 120(%rsp) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fsqrt + fstpt (%rsp) + fxch %st(3) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpl 96(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + fstpt 64(%rsp) + call atan2l@PLT + jmp ..B2.86 + .cfi_def_cfa_offset 176 +..B2.15: + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 208 + fld %st(2) + fadd %st(5), %st + fldt 136(%rsp) + faddp %st, %st(2) + fdiv %st, %st(1) + fldt 104(%rsp) + fldt 120(%rsp) + fsubrp %st, %st(1) + fdivrp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.14(%rip) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + fstpt (%rsp) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpl 96(%rsp) + fstpt 48(%rsp) + fstpt 64(%rsp) + fldt 32(%rsp) + fstpt 32(%rsp) + call atan2l@PLT +..B2.86: + fldt 64(%rsp) + fldt 48(%rsp) + fldt 32(%rsp) + fldl 96(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 176 +..B2.16: + lea AcrossA(%rip), %rax + fldt (%rax) + fcomip %st(4), %st + jb ..B2.21 +..B2.17: + fldt 104(%rsp) + faddp %st, %st(2) + fldt .L_2il0floatpacket.13(%rip) + fcomip %st(1), %st + fstp %st(0) + jbe ..B2.19 +..B2.18: + fldt 72(%rsp) + fxch %st(1) + fdivr %st(2), %st + fldt 88(%rsp) + faddp %st, %st(2) + fxch %st(1) + fdivrp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.14(%rip) + fmulp %st, %st(1) + jmp ..B2.20 +..B2.19: + fldt 88(%rsp) + fxch %st(1) + fdivrp %st, %st(2) + fldt 72(%rsp) + fsubp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.14(%rip) + fmulp %st, %st(1) +..B2.20: + fldt .L_2il0floatpacket.13(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call log1pl@PLT + jmp ..B2.88 + .cfi_def_cfa_offset 176 +..B2.21: + fstp %st(1) + fstp %st(1) + fstp %st(0) + fldt .L_2il0floatpacket.13(%rip) + fld %st(1) + fmul %st(2), %st + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fsubp %st, %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call logl@PLT +..B2.88: + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 +..B2.22: + lea ZEROA(%rip), %rax + movsd (%rax), %xmm0 + comisd 128(%rsp), %xmm0 + jbe ..B2.24 +..B2.23: + fldt .L_2il0floatpacket.15(%rip) + lea PIBY2HIA(%rip), %rax + lea PIBY2LOA(%rip), %rdx + fldl (%rax) + faddl (%rdx) + fmulp %st, %st(1) + fsubp %st, %st(1) +..B2.24: + comisd 120(%rsp), %xmm0 + jbe ..B2.26 +..B2.25: + fldt .L_2il0floatpacket.16(%rip) + fmulp %st, %st(1) +..B2.26: + movb 151(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + fxch %st(1) + fstpl (%rsp) + movsd (%rsp), %xmm0 + fstpl (%rsp) + movsd (%rsp), %xmm1 + andps .L_2il0floatpacket.17(%rip), %xmm1 + andps .L_2il0floatpacket.17(%rip), %xmm0 + movsd %xmm0, 16(%rsp) + movzbl %al, %ecx + movzwl 22(%rsp), %esi + testl $32752, %esi + mulsd (%rdx,%rcx,8), %xmm1 + movsd %xmm1, 24(%rsp) + jne ..B2.29 +..B2.27: + testl $1048575, 20(%rsp) + jne ..B2.32 +..B2.28: + cmpl $0, 16(%rsp) + jne ..B2.32 +..B2.29: + movzwl 30(%rsp), %eax + testl $32752, %eax + jne ..B2.33 +..B2.30: + testl $1048575, 28(%rsp) + jne ..B2.32 +..B2.31: + cmpl $0, 24(%rsp) + je ..B2.33 +..B2.32: + lea _LDB_MIN_NORMAL(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 48(%rsp) +..B2.33: + testb %r13b, %r13b + je ..B2.35 +..B2.34: + fldcw 154(%rsp) +..B2.35: + movsd 16(%rsp), %xmm0 + movsd 24(%rsp), %xmm1 + addq $160, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 13, -16 +..B2.36: + movzwl 150(%rsp), %eax + andl $32752, %eax + shrl $4, %eax +..B2.37: + testl %eax, %eax + jne ..B2.47 +..B2.38: + testl $1048575, 148(%rsp) + jne ..B2.47 +..B2.39: + cmpl $0, 144(%rsp) + jne ..B2.47 +..B2.40: + cmpl $2047, %edx + jl ..B2.43 +..B2.41: + testl $1048575, 140(%rsp) + jne ..B2.47 +..B2.42: + cmpl $0, 136(%rsp) + jne ..B2.47 +..B2.43: + cmpl $1023, %edx + jl ..B2.45 +..B2.44: + movb 143(%rsp), %r13b + andb $-128, %r13b + shrb $7, %r13b + movsd 136(%rsp), %xmm0 + movzbl %r13b, %eax + lea ones(%rip), %r13 + movsd (%r13,%rax,8), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm1, (%rsp) + call acosh@PLT +..B2.90: + movsd %xmm0, 16(%rsp) + movsd (%rsp), %xmm0 + call acos@PLT +..B2.89: + lea 24(%rsp), %rcx + jmp ..B2.46 +..B2.45: + movsd 136(%rsp), %xmm0 + movq $0, 16(%rsp) + call acos@PLT +..B2.91: + lea ones(%rip), %r13 + lea 24(%rsp), %rcx +..B2.46: + movb 151(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + mulsd (%r13,%rdx,8), %xmm0 + movsd %xmm0, (%rcx) + movsd 16(%rsp), %xmm0 + movhpd 24(%rsp), %xmm0 + jmp ..B2.59 +..B2.47: + testl %edx, %edx + jne ..B2.54 +..B2.48: + testl $1048575, 140(%rsp) + jne ..B2.55 +..B2.49: + cmpl $0, 136(%rsp) + jne ..B2.55 +..B2.50: + cmpl $2047, %eax + jl ..B2.53 +..B2.51: + testl $1048575, 148(%rsp) + jne ..B2.55 +..B2.52: + cmpl $0, 144(%rsp) + jne ..B2.55 +..B2.53: + movb 151(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movsd 144(%rsp), %xmm1 + movsd %xmm1, (%rsp) + movzbl %al, %ecx + movsd (%rdx,%rcx,8), %xmm0 + mulsd %xmm1, %xmm0 + call asinh@PLT +..B2.93: + movsd %xmm0, 16(%rsp) + movsd 136(%rsp), %xmm1 + movsd (%rsp), %xmm0 + call atan2@PLT + jmp ..B2.94 +..B2.54: + cmpl $2047, %edx + je ..B2.72 +..B2.55: + cmpl $2047, %eax + je ..B2.68 +..B2.96: + cmpl $2047, %edx +..B2.56: + je ..B2.65 +..B2.57: + movsd 144(%rsp), %xmm0 + movaps %xmm0, %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, 16(%rsp) + movsd 136(%rsp), %xmm1 +..B2.58: + call atan2@PLT +..B2.94: + movsd %xmm0, 24(%rsp) + movsd 16(%rsp), %xmm0 + movhpd 24(%rsp), %xmm0 +..B2.59: + movaps %xmm0, %xmm1 + unpckhpd %xmm0, %xmm1 + addq $160, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 13, -16 +..B2.60: + testl $1048575, 148(%rsp) + jne ..B2.7 +..B2.61: + cmpl $0, 144(%rsp) + jne ..B2.7 + jmp ..B2.37 +..B2.62: + testl $1048575, 140(%rsp) + jne ..B2.5 +..B2.63: + cmpl $0, 136(%rsp) + jne ..B2.5 + jmp ..B2.36 +..B2.65: + testl $1048575, 140(%rsp) + jne ..B2.57 +..B2.66: + cmpl $0, 136(%rsp) + jne ..B2.57 +..B2.67: + movsd 136(%rsp), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, 16(%rsp) + movsd 144(%rsp), %xmm0 + jmp ..B2.58 +..B2.68: + testl $1048575, 148(%rsp) + jne ..B2.70 +..B2.69: + cmpl $0, 144(%rsp) + je ..B2.95 +..B2.70: + cmpl $2047, %edx + jge ..B2.56 +..B2.71: + movsd 144(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm0 + movsd %xmm0, 16(%rsp) + movhpd %xmm0, 24(%rsp) + jmp ..B2.59 +..B2.72: + testl $1048575, 140(%rsp) + jne ..B2.74 +..B2.73: + cmpl $0, 136(%rsp) + je ..B2.75 +..B2.74: + cmpl $2047, %eax + je ..B2.79 +..B2.75: + testl $1048575, 140(%rsp) + jne ..B2.77 +..B2.76: + cmpl $0, 136(%rsp) + je ..B2.55 +..B2.77: + cmpl $2047, %eax + jge ..B2.55 +..B2.78: + movsd 136(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm0 + movsd %xmm0, 16(%rsp) + movhpd %xmm0, 24(%rsp) + jmp ..B2.59 +..B2.79: + testl $1048575, 148(%rsp) + jne ..B2.81 +..B2.80: + cmpl $0, 144(%rsp) + je ..B2.75 +..B2.81: + movsd 144(%rsp), %xmm1 + movsd 136(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + unpcklpd %xmm1, %xmm0 + movsd %xmm0, 16(%rsp) + movhpd %xmm0, 24(%rsp) + jmp ..B2.59 +..B2.95: + cmpl $2047, %edx + je ..B2.65 + jmp ..B2.57 + .align 16,0x90 + .cfi_endproc + .type cacosh,@function + .size cacosh,.-cacosh + .data +# -- End cacosh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 16 +.L_2il0floatpacket.14: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,16 + .align 16 +.L_2il0floatpacket.15: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.16: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,16 + .align 16 +.L_2il0floatpacket.17: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,16 + .align 16 +BcrossA: + .long 3621516424 + .long 2756080513 + .long 16382 + .long 0 + .type BcrossA,@object + .size BcrossA,16 + .align 16 +AcrossA: + .long 0 + .long 3221225472 + .long 16383 + .long 0 + .type AcrossA,@object + .size AcrossA,16 + .align 16 +ZEROA: + .long 0 + .long 0 + .type ZEROA,@object + .size ZEROA,8 + .space 8, 0x00 # pad + .align 16 +PIBY2HIA: + .long 1413754136 + .long 1073291771 + .type PIBY2HIA,@object + .size PIBY2HIA,8 + .space 8, 0x00 # pad + .align 16 +PIBY2LOA: + .long 856972295 + .long 1016178214 + .type PIBY2LOA,@object + .size PIBY2LOA,8 + .space 8, 0x00 # pad + .align 16 +_LDB_MIN_NORMAL: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _LDB_MIN_NORMAL,@object + .size _LDB_MIN_NORMAL,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +.L_2il0floatpacket.12: + .long 0x00800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cacoshl.S b/external/sgx_libm/intel64/cacoshl.S new file mode 100644 index 0000000000..4a014c1174 --- /dev/null +++ b/external/sgx_libm/intel64/cacoshl.S @@ -0,0 +1,483 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacoshl.c" + .text +..TXTST0: +# -- Begin cacoshl + .text + .align 16,0x90 + .globl cacoshl +cacoshl: +# parameter 1: 512 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cacoshl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $464, %rsp + .cfi_def_cfa_offset 512 + xorb %bpl, %bpl + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 448(%rsp) + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.5: + fldcw 16(%rsp) +..B1.6: + movb $1, %bpl +..B1.7: + movzwl 520(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + jge ..B1.15 +..B1.8: + testl %esi, %esi + jle ..B1.39 +..B1.9: + movzwl 536(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jge ..B1.15 +..B1.10: + testl %eax, %eax + jle ..B1.37 +..B1.11: + lea 32(%rsp), %rbx + lea 80(%rsp), %r12 + lea 176(%rsp), %r15 + lea 128(%rsp), %r14 + pushq %rbx + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r14 + .cfi_def_cfa_offset 536 + pushq %r15 + .cfi_def_cfa_offset 544 + lea 544(%rsp), %rdi + lea 560(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_cacoshl.18: + call __libm_carctrigprepare_k80@PLT +..___tag_value_cacoshl.19: +..B1.61: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.12: + pushq %rbx + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r14 + .cfi_def_cfa_offset 536 + pushq %r15 + .cfi_def_cfa_offset 544 + lea 544(%rsp), %rdi + lea 560(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_cacoshl.25: + call __libm_recacoshl_k80@PLT +..___tag_value_cacoshl.26: +..B1.62: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.13: + fstpt 416(%rsp) + pushq %rbx + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r14 + .cfi_def_cfa_offset 536 + pushq %r15 + .cfi_def_cfa_offset 544 + lea 544(%rsp), %rdi + lea 560(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_cacoshl.32: + call __libm_recacosl_k80@PLT +..___tag_value_cacoshl.33: +..B1.63: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.14: + movb 537(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fmulp %st, %st(1) + fstpt 432(%rsp) + jmp ..B1.32 +..B1.15: + movq 528(%rsp), %rdx + testq %rdx, %rdx + jne ..B1.22 +..B1.16: + cmpl $32767, %esi + jge ..B1.21 +..B1.17: + cmpl $16383, %esi + jl ..B1.19 +..B1.18: + fldt 512(%rsp) + movb 521(%rsp), %bl + andb $-128, %bl + shrb $7, %bl + movzbl %bl, %eax + lea ones(%rip), %rbx + fldl (%rbx,%rax,8) + fstl (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fmulp %st, %st(1) + fstpt (%rsp) + call acoshl@PLT +..B1.65: + addq $16, %rsp + .cfi_def_cfa_offset 512 + fstpt 416(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fldl 16(%rsp) + fstpt (%rsp) + call acosl@PLT +..B1.64: + addq $16, %rsp + .cfi_def_cfa_offset 512 + lea 432(%rsp), %rcx + jmp ..B1.20 +..B1.19: + fldt .L_2il0floatpacket.8(%rip) + fstpt 416(%rsp) + fldt 512(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fstpt (%rsp) + call acosl@PLT +..B1.66: + addq $16, %rsp + .cfi_def_cfa_offset 512 + lea ones(%rip), %rbx + lea 432(%rsp), %rcx +..B1.20: + movb 537(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + fldl (%rbx,%rdx,8) + fmulp %st, %st(1) + fstpt (%rcx) + jmp ..B1.32 +..B1.21: + movq $0x8000000000000000, %rax + movq 512(%rsp), %rbx + cmpq %rax, %rbx + je ..B1.17 + jmp ..B1.23 +..B1.22: + movq 512(%rsp), %rbx +..B1.23: + movzwl 536(%rsp), %ecx + andl $32767, %ecx + testq %rbx, %rbx + jne ..B1.27 +..B1.24: + cmpl $32767, %ecx + jge ..B1.26 +..B1.25: + fldt 528(%rsp) + lea ones(%rip), %rdx + fstpt (%rsp) + fldt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 528 + movb 553(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fmulp %st, %st(1) + fstpt (%rsp) + call asinhl@PLT +..B1.68: + addq $16, %rsp + .cfi_def_cfa_offset 512 + fstpt 416(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 544 + fldt 32(%rsp) + fstpt (%rsp) + fldt 544(%rsp) + fstpt 16(%rsp) + call atan2l@PLT + jmp ..B1.69 + .cfi_def_cfa_offset 512 +..B1.26: + movq $0x8000000000000000, %rax + cmpq %rax, %rdx + je ..B1.25 +..B1.27: + cmpl $32767, %esi + je ..B1.49 +..B1.73: + cmpl $32767, %ecx +..B1.28: + je ..B1.45 +..B1.71: + cmpl $32767, %esi +..B1.29: + je ..B1.43 +..B1.30: + fldt 528(%rsp) + fld %st(0) + fmul %st(1), %st + fstpt 416(%rsp) + fldt 512(%rsp) + fxch %st(1) +..B1.31: + addq $-32, %rsp + .cfi_def_cfa_offset 544 + fstpt (%rsp) + fstpt 16(%rsp) + call atan2l@PLT +..B1.69: + addq $32, %rsp + .cfi_def_cfa_offset 512 + fstpt 432(%rsp) +..B1.32: + testb %bpl, %bpl + je ..B1.34 +..B1.33: + fldcw 18(%rsp) +..B1.34: + movq 448(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.42 +..B1.35: + fldt 416(%rsp) + fldt 432(%rsp) + movq 448(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.41 +..B1.36: + addq $464, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 512 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.37: + cmpl $0, 532(%rsp) + jne ..B1.11 +..B1.38: + cmpl $0, 528(%rsp) + jne ..B1.11 + jmp ..B1.15 +..B1.39: + cmpl $0, 516(%rsp) + jne ..B1.9 +..B1.40: + cmpl $0, 512(%rsp) + jne ..B1.9 + jmp ..B1.15 +..B1.41: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.42: + call __stack_chk_fail@PLT +..B1.43: + movq $0x8000000000000000, %rax + cmpq %rax, %rbx + jne ..B1.30 +..B1.44: + fldt 512(%rsp) + fld %st(0) + fmul %st(1), %st + fstpt 416(%rsp) + fldt 528(%rsp) + jmp ..B1.31 +..B1.45: + cmpl $-2147483648, 532(%rsp) + jne ..B1.47 +..B1.46: + cmpl $0, 528(%rsp) + je ..B1.70 +..B1.47: + cmpl $32767, %esi + jge ..B1.29 +..B1.48: + fldt 528(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) + jmp ..B1.32 +..B1.49: + cmpl $-2147483648, 516(%rsp) + jne ..B1.51 +..B1.50: + cmpl $0, 512(%rsp) + je ..B1.52 +..B1.51: + cmpl $32767, %ecx + je ..B1.56 +..B1.52: + cmpl $-2147483648, 516(%rsp) + jne ..B1.54 +..B1.53: + cmpl $0, 512(%rsp) + je ..B1.72 +..B1.54: + cmpl $32767, %ecx + jge ..B1.28 +..B1.55: + fldt 512(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) + jmp ..B1.32 +..B1.56: + cmpl $-2147483648, 532(%rsp) + jne ..B1.58 +..B1.57: + cmpl $0, 528(%rsp) + je ..B1.52 +..B1.58: + fldt 512(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 528(%rsp) + fmul %st(0), %st + fstpt 432(%rsp) + jmp ..B1.32 +..B1.70: + cmpl $32767, %esi + je ..B1.43 + jmp ..B1.30 +..B1.72: + cmpl $32767, %ecx + je ..B1.45 + jmp ..B1.71 + .align 16,0x90 + .cfi_endproc + .type cacoshl,@function + .size cacoshl,.-cacoshl + .data +# -- End cacoshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cacosl.S b/external/sgx_libm/intel64/cacosl.S new file mode 100644 index 0000000000..529708962c --- /dev/null +++ b/external/sgx_libm/intel64/cacosl.S @@ -0,0 +1,476 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cacosl.c" + .text +..TXTST0: +# -- Begin cacosl + .text + .align 16,0x90 + .globl cacosl +cacosl: +# parameter 1: 512 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cacosl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $464, %rsp + .cfi_def_cfa_offset 512 + xorb %bl, %bl + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 448(%rsp) + fstpt 8(%rsp) + fldt 8(%rsp) + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.5: + fldcw 24(%rsp) +..B1.6: + movb $1, %bl +..B1.7: + movzwl 520(%rsp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.15 +..B1.8: + testl %edx, %edx + jle ..B1.36 +..B1.9: + movzwl 536(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jge ..B1.15 +..B1.10: + testl %eax, %eax + jle ..B1.34 +..B1.11: + lea 32(%rsp), %rbp + lea 80(%rsp), %r12 + lea 176(%rsp), %r14 + lea 128(%rsp), %r13 + pushq %rbp + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r13 + .cfi_def_cfa_offset 536 + pushq %r14 + .cfi_def_cfa_offset 544 + lea 544(%rsp), %rdi + lea 560(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_cacosl.18: + call __libm_carctrigprepare_k80@PLT +..___tag_value_cacosl.19: +..B1.59: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.12: + pushq %rbp + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r13 + .cfi_def_cfa_offset 536 + pushq %r14 + .cfi_def_cfa_offset 544 + lea 544(%rsp), %rdi + lea 560(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_cacosl.25: + call __libm_recacosl_k80@PLT +..___tag_value_cacosl.26: +..B1.60: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.13: + fstpt 416(%rsp) + pushq %rbp + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r13 + .cfi_def_cfa_offset 536 + pushq %r14 + .cfi_def_cfa_offset 544 + lea 544(%rsp), %rdi + lea 560(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_cacosl.32: + call __libm_recacoshl_k80@PLT +..___tag_value_cacosl.33: +..B1.61: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.14: + movb 537(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + xorb $1, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fmulp %st, %st(1) + fstpt 432(%rsp) + jmp ..B1.29 +..B1.15: + cmpq $0, 512(%rsp) + jne ..B1.17 +..B1.16: + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fldt 24(%rsp) + fstpt (%rsp) + call acosl@PLT +..B1.63: + addq $16, %rsp + .cfi_def_cfa_offset 512 + fstpt 416(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fldt 544(%rsp) + fstpt (%rsp) + call asinhl@PLT +..B1.62: + fldt .L_2il0floatpacket.9(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 512 + fmulp %st, %st(1) + fstpt 432(%rsp) + jmp ..B1.29 +..B1.17: + movzwl 536(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.53 +..B1.69: + cmpl $32767, %edx +..B1.18: + je ..B1.43 +..B1.19: + cmpl $32767, %eax + je ..B1.40 +..B1.20: + cmpq $0, 528(%rsp) + jne ..B1.25 +..B1.21: + fldt 512(%rsp) + cmpl $16383, %edx + jl ..B1.23 +..B1.22: + movb 521(%rsp), %al + lea ones(%rip), %rbp + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + fldl (%rbp,%rdx,8) + fstl (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fmulp %st, %st(1) + fstpt (%rsp) + call acoshl@PLT +..B1.65: + fstpt 24(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + call acosl@PLT +..B1.64: + addq $16, %rsp + .cfi_def_cfa_offset 512 + fstpt 416(%rsp) + jmp ..B1.24 +..B1.23: + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fstpt (%rsp) + call acosl@PLT +..B1.66: + addq $16, %rsp + .cfi_def_cfa_offset 512 + lea ones(%rip), %rbp + fstpt 416(%rsp) +..B1.24: + fldt 8(%rsp) + movb 537(%rsp), %al + andb $-128, %al + shrb $7, %al + xorb $1, %al + movzbl %al, %edx + fmull (%rbp,%rdx,8) + fstpt 432(%rsp) + jmp ..B1.29 +..B1.25: + fldt 528(%rsp) + cmpl $32767, %eax + fldt 512(%rsp) + je ..B1.27 +..B1.26: + fld %st(0) + fmul %st(1), %st + jmp ..B1.28 +..B1.27: + fld %st(1) + fmul %st(2), %st +..B1.28: + movb 537(%rsp), %bpl + lea ones(%rip), %r12 + andb $-128, %bpl + shrb $7, %bpl + movb %bpl, %al + xorb $1, %al + movzbl %al, %edx + fldl (%r12,%rdx,8) + fmulp %st, %st(1) + fstpt 432(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 544 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2l@PLT +..B1.67: + movzbl %bpl, %eax + addq $32, %rsp + .cfi_def_cfa_offset 512 + fmull (%r12,%rax,8) + fstpt 416(%rsp) +..B1.29: + testb %bl, %bl + je ..B1.31 +..B1.30: + fldcw 26(%rsp) +..B1.31: + movq 448(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.39 +..B1.32: + fldt 416(%rsp) + fldt 432(%rsp) + movq 448(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.33: + addq $464, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 512 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.34: + cmpl $0, 532(%rsp) + jne ..B1.11 +..B1.35: + cmpl $0, 528(%rsp) + jne ..B1.11 + jmp ..B1.15 +..B1.36: + cmpl $0, 516(%rsp) + jne ..B1.9 +..B1.37: + cmpl $0, 512(%rsp) + jne ..B1.9 + jmp ..B1.15 +..B1.38: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.39: + call __stack_chk_fail@PLT +..B1.40: + cmpl $-2147483648, 532(%rsp) + jne ..B1.42 +..B1.41: + cmpl $0, 528(%rsp) + je ..B1.20 +..B1.42: + fldt 528(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 512(%rsp) + fmul %st(0), %st + fstpt 432(%rsp) + jmp ..B1.29 +..B1.43: + cmpl $-2147483648, 516(%rsp) + jne ..B1.45 +..B1.44: + cmpl $0, 512(%rsp) + je ..B1.47 +..B1.45: + cmpl $32767, %eax + jge ..B1.47 +..B1.46: + fldt 512(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) + jmp ..B1.29 +..B1.47: + cmpl $-2147483648, 516(%rsp) + jne ..B1.49 +..B1.48: + cmpl $0, 512(%rsp) + je ..B1.19 +..B1.49: + cmpl $32767, %eax + jne ..B1.20 +..B1.50: + cmpl $-2147483648, 532(%rsp) + jne ..B1.52 +..B1.51: + cmpl $0, 528(%rsp) + je ..B1.40 +..B1.52: + fldt 512(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 528(%rsp) + fmul %st(0), %st + fstpt 432(%rsp) + jmp ..B1.29 +..B1.53: + cmpl $-2147483648, 532(%rsp) + jne ..B1.55 +..B1.54: + cmpl $0, 528(%rsp) + je ..B1.68 +..B1.55: + cmpl $32767, %edx + jge ..B1.18 +..B1.56: + fldt 528(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) + jmp ..B1.29 +..B1.68: + cmpl $32767, %edx + je ..B1.43 + jmp ..B1.19 + .align 16,0x90 + .cfi_endproc + .type cacosl,@function + .size cacosl,.-cacosl + .data +# -- End cacosl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/carg.S b/external/sgx_libm/intel64/carg.S new file mode 100644 index 0000000000..457e309c1f --- /dev/null +++ b/external/sgx_libm/intel64/carg.S @@ -0,0 +1,73 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "carg.c" + .text +..TXTST0: +# -- Begin carg + .text + .align 16,0x90 + .globl carg +carg: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_carg.1: +..L2: + + movaps %xmm0, %xmm2 + pushq %rsi + .cfi_def_cfa_offset 16 + movaps %xmm1, %xmm0 + movaps %xmm2, %xmm1 + call atan2@PLT +..B1.4: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type carg,@function + .size carg,.-carg + .data +# -- End carg + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cargf.S b/external/sgx_libm/intel64/cargf.S new file mode 100644 index 0000000000..4ed957a6eb --- /dev/null +++ b/external/sgx_libm/intel64/cargf.S @@ -0,0 +1,76 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cargf.c" + .text +..TXTST0: +# -- Begin cargf + .text + .align 16,0x90 + .globl cargf +cargf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cargf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + pxor %xmm1, %xmm1 + movsd %xmm0, (%rsp) + pxor %xmm0, %xmm0 + cvtss2sd 4(%rsp), %xmm0 + cvtss2sd (%rsp), %xmm1 + call atan2@PLT +..B1.4: + cvtsd2ss %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cargf,@function + .size cargf,.-cargf + .data +# -- End cargf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cargl.S b/external/sgx_libm/intel64/cargl.S new file mode 100644 index 0000000000..8292dc4946 --- /dev/null +++ b/external/sgx_libm/intel64/cargl.S @@ -0,0 +1,74 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cargl.c" + .text +..TXTST0: +# -- Begin cargl + .text + .align 16,0x90 + .globl cargl +cargl: +# parameter 1: 16 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cargl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + fldt 64(%rsp) + fstpt (%rsp) + fldt 48(%rsp) + fstpt 16(%rsp) + call atan2l@PLT +..B1.4: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cargl,@function + .size cargl,.-cargl + .data +# -- End cargl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/casin.S b/external/sgx_libm/intel64/casin.S new file mode 100644 index 0000000000..bdd370cc0a --- /dev/null +++ b/external/sgx_libm/intel64/casin.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casin.c" + .text +..TXTST0: +# -- Begin casin + .text + .align 16,0x90 + .globl casin +casin: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_casin.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movsd %xmm1, 24(%rsp) + movzwl 30(%rsp), %eax + andl $32752, %eax + movsd %xmm0, 16(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.5 +..B1.3: + testl $1048575, 28(%rsp) + jne ..B1.7 +..B1.4: + cmpl $0, 24(%rsp) + jne ..B1.7 +..B1.5: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.6: + movb 31(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm1 + movhpd 8(%rsp), %xmm1 +..B1.7: + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + call casinh@PLT +..B1.16: + movsd %xmm0, 16(%rsp) + movzwl 22(%rsp), %eax + andl $32752, %eax + movsd %xmm1, 24(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.11 +..B1.9: + testl $1048575, 20(%rsp) + jne ..B1.13 +..B1.10: + cmpl $0, 16(%rsp) + jne ..B1.13 +..B1.11: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.12: + movb 23(%rsp), %al + notb %al + movb 15(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movsd (%rsp), %xmm1 + movb %dl, 15(%rsp) + movhpd 8(%rsp), %xmm1 +..B1.13: + movaps %xmm1, %xmm2 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm2 + movaps %xmm2, %xmm1 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type casin,@function + .size casin,.-casin + .data +# -- End casin + .text +# -- Begin casinf + .text + .align 16,0x90 + .globl casinf +casinf: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_casinf.6: +..L7: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) + movzwl 14(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.4 +..B2.3: + testl $8388607, 12(%rsp) + jne ..B2.6 +..B2.4: + movsd %xmm0, (%rsp) +..B2.5: + movb 15(%rsp), %al + notb %al + movb 3(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 3(%rsp) + movsd (%rsp), %xmm0 +..B2.6: + call casinhf@PLT +..B2.14: + movsd %xmm0, 8(%rsp) + movzwl 10(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.9 +..B2.8: + testl $8388607, 8(%rsp) + jne ..B2.11 +..B2.9: + movsd %xmm0, (%rsp) +..B2.10: + movb 11(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm0 +..B2.11: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type casinf,@function + .size casinf,.-casinf + .data +# -- End casinf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/casinh.S b/external/sgx_libm/intel64/casinh.S new file mode 100644 index 0000000000..1f39178807 --- /dev/null +++ b/external/sgx_libm/intel64/casinh.S @@ -0,0 +1,699 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casinh.c" + .text +..TXTST0: +# -- Begin casinhf + .text + .align 16,0x90 + .globl casinhf +casinhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_casinhf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_casinhf.4: + call casinh@PLT +..___tag_value_casinhf.5: +..B1.10: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + movsd %xmm0, 4(%rsp) + movzwl 6(%rsp), %eax + testl $32640, %eax + jne ..B1.4 +..B1.3: + testl $8388607, 4(%rsp) + jne ..B1.6 +..B1.4: + movzwl 10(%rsp), %eax + testl $32640, %eax + jne ..B1.7 +..B1.5: + testl $8388607, 8(%rsp) + je ..B1.7 +..B1.6: + movss .L_2il0floatpacket.12(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) + movsd 4(%rsp), %xmm0 +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type casinhf,@function + .size casinhf,.-casinhf + .data +# -- End casinhf + .text +# -- Begin casinh + .text + .align 16,0x90 + .globl casinh +casinh: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_casinh.8: +..L9: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + xorb %r14b, %r14b + subq $176, %rsp + .cfi_def_cfa_offset 192 + movsd %xmm0, 16(%rsp) + movsd %xmm1, 24(%rsp) +..B2.2: + fnstcw 162(%rsp) +..B2.3: + movzwl 22(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + jge ..B2.38 +..B2.4: + testl %edx, %edx + jle ..B2.61 +..B2.5: + movzwl 30(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2047, %eax + jge ..B2.39 +..B2.6: + testl %eax, %eax + jle ..B2.59 +..B2.7: + movzwl 162(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.11 +..B2.8: + orl $-64768, %edx + movw %dx, 160(%rsp) +..B2.9: + fldcw 160(%rsp) +..B2.10: + movb $1, %r14b +..B2.11: + fldt .L_2il0floatpacket.13(%rip) + lea BcrossA(%rip), %rax + movsd 24(%rsp), %xmm0 + fld %st(0) + fldt .L_2il0floatpacket.14(%rip) + movsd %xmm0, 136(%rsp) + fldt (%rax) + andps .L_2il0floatpacket.15(%rip), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + movsd 16(%rsp), %xmm1 + fadd %st, %st(4) + movsd %xmm1, 128(%rsp) + xorps .L_2il0floatpacket.16(%rip), %xmm1 + andps .L_2il0floatpacket.15(%rip), %xmm1 + movsd %xmm1, (%rsp) + fxch %st(4) + fstpt 72(%rsp) + fldt 72(%rsp) + fxch %st(3) + fsubr %st(4), %st + fstpt 104(%rsp) + fldt 104(%rsp) + fxch %st(3) + fmul %st(0), %st + fxch %st(3) + fmul %st(0), %st + fldl (%rsp) + fld %st(0) + fmul %st(1), %st + fadd %st, %st(5) + fxch %st(5) + fsqrt + fld %st(0) + fxch %st(3) + fadd %st(6), %st + fsqrt + fstpt 88(%rsp) + fldt 88(%rsp) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + fld %st(5) + fdiv %st(2), %st + fxch %st(3) + fcomip %st(3), %st + jb ..B2.13 +..B2.12: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 208 + fxch %st(1) + fstpt (%rsp) + fxch %st(3) + fstpl 136(%rsp) + fstpt 16(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + call asinl@PLT + jmp ..B2.85 + .cfi_def_cfa_offset 192 +..B2.13: + fstp %st(2) + fldt .L_2il0floatpacket.13(%rip) + fcomip %st(5), %st + jb ..B2.15 +..B2.14: + fstp %st(1) + addq $-16, %rsp + .cfi_def_cfa_offset 208 + fld %st(0) + lea halfs(%rip), %rax + fadd %st(4), %st + fmull (%rax) + fldt 88(%rsp) + fldt 104(%rsp) + fxch %st(1) + fadd %st(4), %st + fdivr %st(5), %st + fldt 120(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fsqrt + fld1 + fdivp %st, %st(1) + fmul %st(4), %st + fstpt (%rsp) + fxch %st(3) + fstpl 136(%rsp) + fstpt 16(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + call atanl@PLT + jmp ..B2.85 + .cfi_def_cfa_offset 192 +..B2.15: + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 208 + fld %st(2) + fadd %st(5), %st + fldt 88(%rsp) + faddp %st, %st(2) + fdiv %st, %st(1) + fldt 120(%rsp) + fldt 104(%rsp) + faddp %st, %st(1) + fdivrp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.14(%rip) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + fdivr %st(3), %st + fstpt (%rsp) + fxch %st(2) + fstpl 136(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + fldt 16(%rsp) + fstpt 16(%rsp) + call atanl@PLT +..B2.85: + fldt 48(%rsp) + fxch %st(1) + fchs + fldt 32(%rsp) + fldt 16(%rsp) + fldl 136(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 192 + fxch %st(3) + fstpl 64(%rsp) +..B2.16: + lea AcrossA(%rip), %rax + fldt (%rax) + fcomip %st(4), %st + jb ..B2.21 +..B2.17: + fldt 72(%rsp) + faddp %st, %st(1) + fldt .L_2il0floatpacket.13(%rip) + fcomip %st(3), %st + fxch %st(2) + fstp %st(0) + jbe ..B2.19 +..B2.18: + fldt 88(%rsp) + fxch %st(1) + fdiv %st, %st(2) + fldt 104(%rsp) + fsubrp %st, %st(2) + fdivp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.14(%rip) + fmulp %st, %st(1) + jmp ..B2.20 +..B2.19: + fldt 88(%rsp) + fxch %st(2) + fdivrp %st, %st(1) + fldt 104(%rsp) + faddp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.14(%rip) + fmulp %st, %st(1) +..B2.20: + fldt .L_2il0floatpacket.13(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 208 + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%rsp) + call log1pl@PLT + jmp ..B2.87 + .cfi_def_cfa_offset 192 +..B2.21: + fstp %st(0) + fstp %st(0) + fstp %st(0) + fldt .L_2il0floatpacket.13(%rip) + fld %st(1) + fmul %st(2), %st + addq $-16, %rsp + .cfi_def_cfa_offset 208 + fsubp %st, %st(1) + fsqrt + faddp %st, %st(1) + fstpt (%rsp) + call logl@PLT +..B2.87: + addq $16, %rsp + .cfi_def_cfa_offset 192 + fstpl (%rsp) + movsd (%rsp), %xmm2 +..B2.22: + lea ZEROA(%rip), %rax + movsd 136(%rsp), %xmm0 + movsd (%rax), %xmm1 + comisd %xmm1, %xmm0 + jbe ..B2.24 +..B2.23: + movsd 64(%rsp), %xmm0 + xorps .L_2il0floatpacket.16(%rip), %xmm0 + movsd %xmm0, 152(%rsp) + jmp ..B2.25 +..B2.24: + movsd 64(%rsp), %xmm0 + movsd %xmm0, 152(%rsp) +..B2.25: + comisd 128(%rsp), %xmm1 + jbe ..B2.27 +..B2.26: + xorps .L_2il0floatpacket.16(%rip), %xmm2 + movsd %xmm2, 144(%rsp) + jmp ..B2.28 +..B2.27: + movsd %xmm2, 144(%rsp) +..B2.28: + movzwl 150(%rsp), %eax + testl $32752, %eax + jne ..B2.31 +..B2.29: + testl $1048575, 148(%rsp) + jne ..B2.34 +..B2.30: + cmpl $0, 144(%rsp) + jne ..B2.34 +..B2.31: + movzwl 158(%rsp), %eax + testl $32752, %eax + jne ..B2.35 +..B2.32: + testl $1048575, 156(%rsp) + jne ..B2.34 +..B2.33: + cmpl $0, 152(%rsp) + je ..B2.35 +..B2.34: + lea _LDB_MIN_NORMAL(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 48(%rsp) +..B2.35: + testb %r14b, %r14b + je ..B2.37 +..B2.36: + fldcw 162(%rsp) +..B2.37: + movsd 144(%rsp), %xmm0 + movsd 152(%rsp), %xmm1 + addq $176, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 14, -16 +..B2.38: + movzwl 30(%rsp), %eax + andl $32752, %eax + shrl $4, %eax +..B2.39: + testl %eax, %eax + jne ..B2.43 +..B2.40: + testl $1048575, 28(%rsp) + jne ..B2.43 +..B2.41: + cmpl $0, 24(%rsp) + jne ..B2.43 +..B2.42: + movsd 16(%rsp), %xmm0 + call asinh@PLT +..B2.88: + movhpd 24(%rsp), %xmm0 + movsd %xmm0, 144(%rsp) + movhpd %xmm0, 152(%rsp) + jmp ..B2.58 +..B2.43: + testl %edx, %edx + jne ..B2.53 +..B2.44: + testl $1048575, 20(%rsp) + jne ..B2.54 +..B2.45: + cmpl $0, 16(%rsp) + jne ..B2.54 +..B2.46: + cmpl $2047, %eax + jl ..B2.49 +..B2.47: + testl $1048575, 28(%rsp) + jne ..B2.54 +..B2.48: + cmpl $0, 24(%rsp) + jne ..B2.54 +..B2.49: + movsd 24(%rsp), %xmm0 + cmpl $1023, %eax + jl ..B2.51 +..B2.50: + movb 31(%rsp), %r14b + andb $-128, %r14b + shrb $7, %r14b + movzbl %r14b, %eax + lea ones(%rip), %r14 + movsd (%r14,%rax,8), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm1, (%rsp) + call acosh@PLT +..B2.90: + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + call asin@PLT + jmp ..B2.52 +..B2.51: + pxor %xmm1, %xmm1 + movsd %xmm1, 8(%rsp) + call asin@PLT +..B2.91: + lea ones(%rip), %r14 +..B2.52: + movb 23(%rsp), %al + andb $-128, %al + shrb $7, %al + movsd %xmm0, 152(%rsp) + movsd 8(%rsp), %xmm0 + movzbl %al, %edx + mulsd (%r14,%rdx,8), %xmm0 + movsd %xmm0, 144(%rsp) + movhpd 152(%rsp), %xmm0 + jmp ..B2.58 +..B2.53: + cmpl $2047, %edx + je ..B2.71 +..B2.54: + cmpl $2047, %eax + je ..B2.67 +..B2.94: + cmpl $2047, %edx +..B2.55: + je ..B2.64 +..B2.56: + movsd 24(%rsp), %xmm0 + movaps %xmm0, %xmm3 + movsd 16(%rsp), %xmm2 + mulsd %xmm0, %xmm3 +..B2.57: + movb 23(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movsd (%rdx,%rcx,8), %xmm1 + mulsd %xmm1, %xmm3 + mulsd %xmm2, %xmm1 + movsd %xmm3, 144(%rsp) + call atan2@PLT +..B2.92: + movsd %xmm0, 152(%rsp) + movsd 144(%rsp), %xmm0 + movhpd 152(%rsp), %xmm0 +..B2.58: + movaps %xmm0, %xmm1 + unpckhpd %xmm0, %xmm1 + addq $176, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 14, -16 +..B2.59: + testl $1048575, 28(%rsp) + jne ..B2.7 +..B2.60: + cmpl $0, 24(%rsp) + jne ..B2.7 + jmp ..B2.39 +..B2.61: + testl $1048575, 20(%rsp) + jne ..B2.5 +..B2.62: + cmpl $0, 16(%rsp) + jne ..B2.5 + jmp ..B2.38 +..B2.64: + testl $1048575, 20(%rsp) + jne ..B2.56 +..B2.65: + cmpl $0, 16(%rsp) + jne ..B2.56 +..B2.66: + movsd 16(%rsp), %xmm2 + movaps %xmm2, %xmm3 + movsd 24(%rsp), %xmm0 + mulsd %xmm2, %xmm3 + jmp ..B2.57 +..B2.67: + testl $1048575, 28(%rsp) + jne ..B2.69 +..B2.68: + cmpl $0, 24(%rsp) + je ..B2.93 +..B2.69: + cmpl $2047, %edx + jge ..B2.55 +..B2.70: + movsd 24(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm0 + movsd %xmm0, 144(%rsp) + movhpd %xmm0, 152(%rsp) + jmp ..B2.58 +..B2.71: + testl $1048575, 20(%rsp) + jne ..B2.73 +..B2.72: + cmpl $0, 16(%rsp) + je ..B2.74 +..B2.73: + cmpl $2047, %eax + je ..B2.78 +..B2.74: + testl $1048575, 20(%rsp) + jne ..B2.76 +..B2.75: + cmpl $0, 16(%rsp) + je ..B2.54 +..B2.76: + cmpl $2047, %eax + jge ..B2.54 +..B2.77: + movsd 16(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + unpcklpd %xmm0, %xmm0 + movsd %xmm0, 144(%rsp) + movhpd %xmm0, 152(%rsp) + jmp ..B2.58 +..B2.78: + testl $1048575, 28(%rsp) + jne ..B2.80 +..B2.79: + cmpl $0, 24(%rsp) + je ..B2.74 +..B2.80: + movsd 24(%rsp), %xmm1 + movsd 16(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + unpcklpd %xmm1, %xmm0 + movsd %xmm0, 144(%rsp) + movhpd %xmm0, 152(%rsp) + jmp ..B2.58 +..B2.93: + cmpl $2047, %edx + je ..B2.64 + jmp ..B2.56 + .align 16,0x90 + .cfi_endproc + .type casinh,@function + .size casinh,.-casinh + .data +# -- End casinh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 16 +.L_2il0floatpacket.14: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,16 + .align 16 +.L_2il0floatpacket.15: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.16: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,16 + .align 16 +BcrossA: + .long 1717986918 + .long 3865470566 + .long 16382 + .long 0 + .type BcrossA,@object + .size BcrossA,16 + .align 16 +AcrossA: + .long 0 + .long 3221225472 + .long 16383 + .long 0 + .type AcrossA,@object + .size AcrossA,16 + .align 16 +ZEROA: + .long 0 + .long 0 + .type ZEROA,@object + .size ZEROA,8 + .space 8, 0x00 # pad + .align 16 +_LDB_MIN_NORMAL: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _LDB_MIN_NORMAL,@object + .size _LDB_MIN_NORMAL,16 + .align 8 +halfs: + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbfe00000 + .type halfs,@object + .size halfs,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +.L_2il0floatpacket.12: + .long 0x00800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/casinhl.S b/external/sgx_libm/intel64/casinhl.S new file mode 100644 index 0000000000..62d9e31076 --- /dev/null +++ b/external/sgx_libm/intel64/casinhl.S @@ -0,0 +1,463 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casinhl.c" + .text +..TXTST0: +# -- Begin casinhl + .text + .align 16,0x90 + .globl casinhl +casinhl: +# parameter 1: 512 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_casinhl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $464, %rsp + .cfi_def_cfa_offset 512 + xorb %r15b, %r15b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 448(%rsp) + fstpt 8(%rsp) + fldt 8(%rsp) + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.5: + fldcw 24(%rsp) +..B1.6: + movb $1, %r15b +..B1.7: + movzwl 520(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + jge ..B1.15 +..B1.8: + testl %esi, %esi + jle ..B1.36 +..B1.9: + movzwl 536(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jge ..B1.15 +..B1.10: + testl %eax, %eax + jle ..B1.34 +..B1.11: + lea 32(%rsp), %rbp + lea 80(%rsp), %r12 + lea 176(%rsp), %r14 + lea 128(%rsp), %r13 + pushq %rbp + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r13 + .cfi_def_cfa_offset 536 + pushq %r14 + .cfi_def_cfa_offset 544 + lea 560(%rsp), %rdi + lea 544(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_casinhl.18: + call __libm_carctrigprepare_k80@PLT +..___tag_value_casinhl.19: +..B1.58: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.12: + pushq %rbp + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r13 + .cfi_def_cfa_offset 536 + pushq %r14 + .cfi_def_cfa_offset 544 + lea 560(%rsp), %rdi + lea 544(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_casinhl.25: + call __libm_recacoshl_k80@PLT +..___tag_value_casinhl.26: +..B1.59: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.13: + movb 521(%rsp), %al + lea ones(%rip), %r10 + andb $-128, %al + shrb $7, %al + movzbl %al, %r11d + fldl (%r10,%r11,8) + fmulp %st, %st(1) + fstpt 416(%rsp) + pushq %rbp + .cfi_def_cfa_offset 520 + pushq %r12 + .cfi_def_cfa_offset 528 + pushq %r13 + .cfi_def_cfa_offset 536 + pushq %r14 + .cfi_def_cfa_offset 544 + lea 560(%rsp), %rdi + lea 544(%rsp), %rsi + lea 400(%rsp), %rdx + lea 352(%rsp), %rcx + lea 304(%rsp), %r8 + lea 256(%rsp), %r9 +..___tag_value_casinhl.32: + call __libm_recasinl_k80@PLT +..___tag_value_casinhl.33: +..B1.60: + addq $32, %rsp + .cfi_def_cfa_offset 512 +..B1.14: + fstpt 432(%rsp) + jmp ..B1.29 +..B1.15: + movq 528(%rsp), %rax + testq %rax, %rax + jne ..B1.17 +..B1.16: + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fldt 528(%rsp) + fstpt (%rsp) + call asinhl@PLT +..B1.61: + addq $16, %rsp + .cfi_def_cfa_offset 512 + fldt 528(%rsp) + fstpt 432(%rsp) + fstpt 416(%rsp) + jmp ..B1.29 +..B1.17: + movzwl 536(%rsp), %ecx + movq 512(%rsp), %rbp + andl $32767, %ecx + testq %rbp, %rbp + jne ..B1.24 +..B1.18: + cmpl $32767, %ecx + jge ..B1.23 +..B1.19: + fldt 528(%rsp) + cmpl $16383, %ecx + jl ..B1.21 +..B1.20: + movb 537(%rsp), %al + lea ones(%rip), %rbp + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + fldl (%rbp,%rdx,8) + fstl (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fmulp %st, %st(1) + fstpt (%rsp) + call acoshl@PLT +..B1.63: + fstpt 24(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + call asinl@PLT +..B1.62: + addq $16, %rsp + .cfi_def_cfa_offset 512 + fstpt 432(%rsp) + jmp ..B1.22 +..B1.21: + addq $-16, %rsp + .cfi_def_cfa_offset 528 + fstpt (%rsp) + call asinl@PLT +..B1.64: + addq $16, %rsp + .cfi_def_cfa_offset 512 + lea ones(%rip), %rbp + fstpt 432(%rsp) +..B1.22: + fldt 8(%rsp) + movb 521(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + fmull (%rbp,%rdx,8) + fstpt 416(%rsp) + jmp ..B1.29 +..B1.23: + movq $0x8000000000000000, %rdx + cmpq %rdx, %rax + je ..B1.19 +..B1.24: + cmpl $32767, %esi + je ..B1.46 +..B1.69: + cmpl $32767, %ecx +..B1.25: + je ..B1.42 +..B1.67: + cmpl $32767, %esi +..B1.26: + je ..B1.40 +..B1.27: + fldt 528(%rsp) + fld %st(0) + fmul %st(1), %st + fldt 512(%rsp) + fxch %st(2) +..B1.28: + movb 521(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fmul %st, %st(2) + fxch %st(2) + fstpt 416(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 544 + fxch %st(2) + fmulp %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2l@PLT +..B1.65: + addq $32, %rsp + .cfi_def_cfa_offset 512 + fstpt 432(%rsp) +..B1.29: + testb %r15b, %r15b + je ..B1.31 +..B1.30: + fldcw 26(%rsp) +..B1.31: + movq 448(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.39 +..B1.32: + fldt 416(%rsp) + fldt 432(%rsp) + movq 448(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.33: + addq $464, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 512 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.34: + cmpl $0, 532(%rsp) + jne ..B1.11 +..B1.35: + cmpl $0, 528(%rsp) + jne ..B1.11 + jmp ..B1.15 +..B1.36: + cmpl $0, 516(%rsp) + jne ..B1.9 +..B1.37: + cmpl $0, 512(%rsp) + jne ..B1.9 + jmp ..B1.15 +..B1.38: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.39: + call __stack_chk_fail@PLT +..B1.40: + movq $0x8000000000000000, %rax + cmpq %rax, %rbp + jne ..B1.27 +..B1.41: + fldt 512(%rsp) + fld %st(0) + fmul %st(1), %st + fldt 528(%rsp) + jmp ..B1.28 +..B1.42: + cmpl $-2147483648, 532(%rsp) + jne ..B1.44 +..B1.43: + cmpl $0, 528(%rsp) + je ..B1.66 +..B1.44: + cmpl $32767, %esi + jge ..B1.26 +..B1.45: + fldt 528(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) + jmp ..B1.29 +..B1.46: + cmpl $-2147483648, 516(%rsp) + jne ..B1.48 +..B1.47: + cmpl $0, 512(%rsp) + je ..B1.49 +..B1.48: + cmpl $32767, %ecx + je ..B1.53 +..B1.49: + cmpl $-2147483648, 516(%rsp) + jne ..B1.51 +..B1.50: + cmpl $0, 512(%rsp) + je ..B1.68 +..B1.51: + cmpl $32767, %ecx + jge ..B1.25 +..B1.52: + fldt 512(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fstpt 432(%rsp) + jmp ..B1.29 +..B1.53: + cmpl $-2147483648, 532(%rsp) + jne ..B1.55 +..B1.54: + cmpl $0, 528(%rsp) + je ..B1.49 +..B1.55: + fldt 512(%rsp) + fmul %st(0), %st + fstpt 416(%rsp) + fldt 528(%rsp) + fmul %st(0), %st + fstpt 432(%rsp) + jmp ..B1.29 +..B1.66: + cmpl $32767, %esi + je ..B1.40 + jmp ..B1.27 +..B1.68: + cmpl $32767, %ecx + je ..B1.42 + jmp ..B1.67 + .align 16,0x90 + .cfi_endproc + .type casinhl,@function + .size casinhl,.-casinhl + .data +# -- End casinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/casinl.S b/external/sgx_libm/intel64/casinl.S new file mode 100644 index 0000000000..1e144dea73 --- /dev/null +++ b/external/sgx_libm/intel64/casinl.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "casinl.c" + .text +..TXTST0: +# -- Begin casinl + .text + .align 16,0x90 + .globl casinl +casinl: +# parameter 1: 144 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_casinl.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + subq $128, %rsp + .cfi_def_cfa_offset 144 + xorb %r13b, %r13b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 112(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 96(%rsp) +..B1.2: + fnstcw 2(%rsp) +..B1.3: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.5: + fldcw (%rsp) +..B1.6: + movb $1, %r13b +..B1.7: + fldt 160(%rsp) + movzwl 168(%rsp), %eax + andl $32767, %eax + fstpt 80(%rsp) + cmpl $32767, %eax + fldt 144(%rsp) + fstpt 96(%rsp) + jl ..B1.9 +..B1.8: + movq $0x8000000000000000, %rax + cmpq 160(%rsp), %rax + jne ..B1.10 +..B1.9: + movb 169(%rsp), %al + notb %al + movb 89(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 89(%rsp) +..B1.10: + addq $-32, %rsp + .cfi_def_cfa_offset 176 + movq %rsp, %rdi + movq 112(%rsp), %rax + movq 120(%rsp), %rdx + movq 128(%rsp), %rcx + movq 136(%rsp), %rsi + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + movq %rcx, 16(%rdi) + movq %rsi, 24(%rdi) + call casinhl@PLT +..B1.22: + fxch %st(1) + addq $32, %rsp + .cfi_def_cfa_offset 144 + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 24(%rsp), %eax + andl $32767, %eax + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + cmpl $32767, %eax + fstpt 48(%rsp) + fstpt 64(%rsp) + jl ..B1.12 +..B1.11: + movq $0x8000000000000000, %rax + cmpq 16(%rsp), %rax + jne ..B1.13 +..B1.12: + movb 25(%rsp), %al + notb %al + movb 73(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 73(%rsp) +..B1.13: + testb %r13b, %r13b + je ..B1.15 +..B1.14: + fldcw 2(%rsp) +..B1.15: + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.19 +..B1.16: + fldt 48(%rsp) + fldt 64(%rsp) + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.18 +..B1.17: + addq $128, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 144 + .cfi_offset 13, -16 +..B1.18: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.19: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type casinl,@function + .size casinl,.-casinl + .data +# -- End casinl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/catan.S b/external/sgx_libm/intel64/catan.S new file mode 100644 index 0000000000..dcb5372f0f --- /dev/null +++ b/external/sgx_libm/intel64/catan.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catan.c" + .text +..TXTST0: +# -- Begin catan + .text + .align 16,0x90 + .globl catan +catan: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_catan.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movsd %xmm1, 24(%rsp) + movzwl 30(%rsp), %eax + andl $32752, %eax + movsd %xmm0, 16(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.5 +..B1.3: + testl $1048575, 28(%rsp) + jne ..B1.7 +..B1.4: + cmpl $0, 24(%rsp) + jne ..B1.7 +..B1.5: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.6: + movb 31(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm1 + movhpd 8(%rsp), %xmm1 +..B1.7: + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + call catanh@PLT +..B1.16: + movsd %xmm0, 16(%rsp) + movzwl 22(%rsp), %eax + andl $32752, %eax + movsd %xmm1, 24(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.11 +..B1.9: + testl $1048575, 20(%rsp) + jne ..B1.13 +..B1.10: + cmpl $0, 16(%rsp) + jne ..B1.13 +..B1.11: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.12: + movb 23(%rsp), %al + notb %al + movb 15(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movsd (%rsp), %xmm1 + movb %dl, 15(%rsp) + movhpd 8(%rsp), %xmm1 +..B1.13: + movaps %xmm1, %xmm2 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm2 + movaps %xmm2, %xmm1 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type catan,@function + .size catan,.-catan + .data +# -- End catan + .text +# -- Begin catanf + .text + .align 16,0x90 + .globl catanf +catanf: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_catanf.6: +..L7: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) + movzwl 14(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.4 +..B2.3: + testl $8388607, 12(%rsp) + jne ..B2.6 +..B2.4: + movsd %xmm0, (%rsp) +..B2.5: + movb 15(%rsp), %al + notb %al + movb 3(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 3(%rsp) + movsd (%rsp), %xmm0 +..B2.6: + call catanhf@PLT +..B2.14: + movsd %xmm0, 8(%rsp) + movzwl 10(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.9 +..B2.8: + testl $8388607, 8(%rsp) + jne ..B2.11 +..B2.9: + movsd %xmm0, (%rsp) +..B2.10: + movb 11(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm0 +..B2.11: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type catanf,@function + .size catanf,.-catanf + .data +# -- End catanf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/catanh.S b/external/sgx_libm/intel64/catanh.S new file mode 100644 index 0000000000..5bf3d15489 --- /dev/null +++ b/external/sgx_libm/intel64/catanh.S @@ -0,0 +1,713 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catanh.c" + .text +..TXTST0: +# -- Begin catanhf + .text + .align 16,0x90 + .globl catanhf +catanhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_catanhf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_catanhf.4: + call catanh@PLT +..___tag_value_catanhf.5: +..B1.10: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + movsd %xmm0, 4(%rsp) + movzwl 6(%rsp), %eax + testl $32640, %eax + jne ..B1.4 +..B1.3: + testl $8388607, 4(%rsp) + jne ..B1.6 +..B1.4: + movzwl 10(%rsp), %eax + testl $32640, %eax + jne ..B1.7 +..B1.5: + testl $8388607, 8(%rsp) + je ..B1.7 +..B1.6: + movss .L_2il0floatpacket.12(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) + movsd 4(%rsp), %xmm0 +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type catanhf,@function + .size catanhf,.-catanhf + .data +# -- End catanhf + .text +# -- Begin catanh + .text + .align 16,0x90 + .globl catanh +catanh: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_catanh.8: +..L9: + + pushq %r15 + .cfi_def_cfa_offset 16 + .cfi_offset 15, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + xorb %r15b, %r15b + subq $200, %rsp + .cfi_def_cfa_offset 224 + movsd %xmm0, (%rsp) + movsd %xmm1, 8(%rsp) +..B2.2: + fnstcw 186(%rsp) +..B2.3: + movzwl 6(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2047, %eax + jge ..B2.26 +..B2.4: + testl %eax, %eax + jle ..B2.54 +..B2.5: + movzwl 14(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $2047, %edx + jge ..B2.27 +..B2.6: + testl %edx, %edx + jle ..B2.52 +..B2.7: + movzwl 186(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.11 +..B2.8: + orl $-64768, %edx + movw %dx, 184(%rsp) +..B2.9: + fldcw 184(%rsp) +..B2.10: + movb $1, %r15b +..B2.11: + fldl (%rsp) + fstl 160(%rsp) + fmul %st(0), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fldl 8(%rsp) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt .L_2il0floatpacket.13(%rip) + fldt pc_thresh(%rip) + fxch %st(4) + fsubrp %st, %st(1) + fsubp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fabs + fcomip %st(2), %st + fxch %st(1) + fstp %st(0) + jae ..B2.13 + jp ..B2.13 +..B2.12: + fldt .L_2il0floatpacket.13(%rip) + faddl 160(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 256 + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fxch %st(1) + fstpt 16(%rsp) + fstpt 32(%rsp) + call atan2l@PLT +..B2.79: + fldt 32(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 224 + fchs + fxch %st(1) + fstpt 112(%rsp) + fldt .L_2il0floatpacket.13(%rip) + fsubl 160(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 256 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 48(%rsp) + call atan2l@PLT +..B2.78: + fldt 48(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 224 + fldt .L_2il0floatpacket.14(%rip) + fxch %st(2) + fstpt 128(%rsp) + fldt 112(%rsp) + fldt 128(%rsp) + fsubrp %st, %st(1) + fmul %st(2), %st + fstpl 176(%rsp) + jmp ..B2.14 +..B2.13: + fldt 96(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 256 + fldt .L_2il0floatpacket.15(%rip) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2l@PLT +..B2.80: + fldt .L_2il0floatpacket.14(%rip) + addq $32, %rsp + .cfi_def_cfa_offset 224 + fldt .L_2il0floatpacket.13(%rip) + fld %st(0) + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + fstpl 176(%rsp) + fldl 160(%rsp) + fadd %st, %st(2) + fxch %st(2) + fstpt 80(%rsp) + fsubp %st, %st(1) +..B2.14: + fldt 80(%rsp) + lea ones(%rip), %rdx + fstpt 112(%rsp) + fchs + fldt 112(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt 64(%rsp) + fadd %st, %st(1) + fxch %st(1) + fstpt 144(%rsp) + fxch %st(1) + fstpt 128(%rsp) + fldt 128(%rsp) + fldt 128(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 96(%rsp) + fldt 144(%rsp) + fldt 96(%rsp) + fdivrp %st, %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fldt .L_2il0floatpacket.13(%rip) + fldt pc_thresh(%rip) + movb 121(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fxch %st(2) + fmull (%rdx,%rcx,8) + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(1) + fabs + fcomip %st(1), %st + fstp %st(0) + jbe ..B2.16 +..B2.15: + fstp %st(0) + fldt 112(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 240 + fstpt (%rsp) + call logl@PLT +..B2.81: + fldt .L_2il0floatpacket.16(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 224 + fmulp %st, %st(1) + fstpl 168(%rsp) + jmp ..B2.17 +..B2.16: + fldt 48(%rsp) + fldt 64(%rsp) + faddp %st, %st(1) + fldt .L_2il0floatpacket.13(%rip) + faddp %st, %st(1) + fstpt 96(%rsp) + fldt .L_2il0floatpacket.15(%rip) + fmull 160(%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + fldt 96(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 240 + fdivrp %st, %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atanhl@PLT +..B2.82: + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 224 + fmulp %st, %st(1) + fstpl 168(%rsp) +..B2.17: + movzwl 174(%rsp), %eax + testl $32752, %eax + jne ..B2.20 +..B2.18: + testl $1048575, 172(%rsp) + jne ..B2.23 +..B2.19: + cmpl $0, 168(%rsp) + jne ..B2.23 +..B2.20: + movzwl 182(%rsp), %eax + testl $32752, %eax + jne ..B2.24 +..B2.21: + testl $1048575, 180(%rsp) + jne ..B2.23 +..B2.22: + cmpl $0, 176(%rsp) + je ..B2.24 +..B2.23: + lea _LDB_MIN_NORMAL(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 32(%rsp) +..B2.24: + testb %r15b, %r15b + je ..B2.51 +..B2.25: + fldcw 186(%rsp) + jmp ..B2.51 +..B2.26: + movzwl 14(%rsp), %edx + andl $32752, %edx + shrl $4, %edx +..B2.27: + cmpl $2047, %eax + je ..B2.68 +..B2.28: + cmpl $2047, %edx + je ..B2.61 +..B2.29: + cmpl $2047, %edx + jge ..B2.50 +..B2.30: + testl %eax, %eax + jle ..B2.59 +..B2.31: + cmpl $1023, %eax + jge ..B2.33 +..B2.32: + movsd (%rsp), %xmm0 + call atanh@PLT +..B2.83: + movb 15(%rsp), %dl + lea zeros(%rip), %rax + andb $-128, %dl + lea ones(%rip), %rcx + movsd %xmm0, 168(%rsp) + shrb $7, %dl + movsd (%rax), %xmm1 + movzbl %dl, %ebx + mulsd (%rcx,%rbx,8), %xmm1 + movsd %xmm1, 176(%rsp) + jmp ..B2.51 +..B2.33: + je ..B2.57 +..B2.34: + cmpl $2047, %eax + jge ..B2.49 +..B2.35: + movzwl 186(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.39 +..B2.36: + orl $-64768, %edx + movw %dx, 184(%rsp) +..B2.37: + fldcw 184(%rsp) +..B2.38: + movb $1, %r15b +..B2.39: + fldl (%rsp) + fld %st(0) + fmul %st(1), %st + fldl 8(%rsp) + fmul %st(0), %st + fldt .L_2il0floatpacket.13(%rip) + fld %st(0) + fadd %st(4), %st + fstpt 112(%rsp) + fld %st(0) + fsub %st(4), %st + fchs + fldt 112(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fadd %st(3), %st + fstpt 144(%rsp) + fstpt 128(%rsp) + fldt 128(%rsp) + fldt 128(%rsp) + fmulp %st, %st(1) + fadd %st(2), %st + fstpt 96(%rsp) + fldt 144(%rsp) + fldt 96(%rsp) + fdivrp %st, %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fldt pc_thresh(%rip) + movb 121(%rsp), %bl + andb $-128, %bl + shrb $7, %bl + movzbl %bl, %eax + lea ones(%rip), %rbx + fxch %st(1) + fmull (%rbx,%rax,8) + fstpt 112(%rsp) + fldt 112(%rsp) + fsub %st(2), %st + fabs + fcomip %st(1), %st + fstp %st(0) + jbe ..B2.41 +..B2.40: + fstp %st(0) + fstp %st(0) + fstp %st(0) + fstp %st(0) + fldt 112(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 240 + fstpt (%rsp) + call logl@PLT +..B2.84: + fldt .L_2il0floatpacket.16(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 224 + fmulp %st, %st(1) + fstpl 168(%rsp) + jmp ..B2.42 +..B2.41: + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 96(%rsp) + fldt .L_2il0floatpacket.15(%rip) + fmulp %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + fldt 96(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 240 + fdivrp %st, %st(1) + fstpt (%rsp) + call atanhl@PLT +..B2.85: + fldt .L_2il0floatpacket.14(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 224 + fmulp %st, %st(1) + fstpl 168(%rsp) +..B2.42: + movzwl 174(%rsp), %eax + testl $32752, %eax + jne ..B2.46 +..B2.43: + testl $1048575, 172(%rsp) + jne ..B2.45 +..B2.44: + cmpl $0, 168(%rsp) + je ..B2.46 +..B2.45: + lea _LDB_MIN_NORMAL(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 32(%rsp) +..B2.46: + testb %r15b, %r15b + je ..B2.48 +..B2.47: + fldcw 186(%rsp) +..B2.48: + movb 15(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rbx,%rdx,8), %xmm0 + call asin@PLT + jmp ..B2.88 +..B2.49: + movb 7(%rsp), %al + lea ones(%rip), %rbx + andb $-128, %al + shrb $7, %al + pxor %xmm0, %xmm0 + movb 15(%rsp), %cl + andb $-128, %cl + shrb $7, %cl + movzbl %al, %edx + movzbl %cl, %esi + mulsd (%rbx,%rdx,8), %xmm0 + movsd %xmm0, 168(%rsp) + movsd (%rbx,%rsi,8), %xmm0 + call asin@PLT + jmp ..B2.88 +..B2.50: + movb 7(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + pxor %xmm0, %xmm0 + movzbl %al, %ecx + mulsd (%rdx,%rcx,8), %xmm0 + movsd %xmm0, 168(%rsp) + movsd 8(%rsp), %xmm0 + call atan@PLT +..B2.88: + movsd %xmm0, 176(%rsp) +..B2.51: + movsd 168(%rsp), %xmm0 + movsd 176(%rsp), %xmm1 + addq $200, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 224 + .cfi_offset 3, -24 + .cfi_offset 15, -16 +..B2.52: + testl $1048575, 12(%rsp) + jne ..B2.7 +..B2.53: + cmpl $0, 8(%rsp) + jne ..B2.7 + jmp ..B2.27 +..B2.54: + testl $1048575, 4(%rsp) + jne ..B2.5 +..B2.55: + cmpl $0, (%rsp) + jne ..B2.5 + jmp ..B2.26 +..B2.57: + testl $1048575, 4(%rsp) + jne ..B2.34 +..B2.58: + cmpl $0, (%rsp) + je ..B2.32 + jmp ..B2.34 +..B2.59: + testl $1048575, 4(%rsp) + jne ..B2.31 +..B2.60: + cmpl $0, (%rsp) + jne ..B2.31 + jmp ..B2.50 +..B2.61: + testl $1048575, 12(%rsp) + jne ..B2.63 +..B2.62: + cmpl $0, 8(%rsp) + je ..B2.29 +..B2.63: + cmpl $2047, %eax + jge ..B2.29 +..B2.64: + testl %eax, %eax + jle ..B2.66 +..B2.65: + movsd 8(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 168(%rsp) + movsd %xmm0, 176(%rsp) + jmp ..B2.51 +..B2.66: + testl $1048575, 4(%rsp) + jne ..B2.65 +..B2.67: + cmpl $0, (%rsp) + jne ..B2.65 + jmp ..B2.29 +..B2.68: + testl $1048575, 4(%rsp) + jne ..B2.70 +..B2.69: + cmpl $0, (%rsp) + je ..B2.28 +..B2.70: + cmpl $2047, %edx + jge ..B2.72 +..B2.71: + movsd (%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 168(%rsp) + movsd %xmm0, 176(%rsp) + jmp ..B2.51 +..B2.72: + testl $1048575, 12(%rsp) + jne ..B2.75 +..B2.73: + cmpl $0, 8(%rsp) + jne ..B2.75 +..B2.74: + movsd (%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, (%rsp) + movsd 8(%rsp), %xmm0 + movq $0, 168(%rsp) + call atan@PLT + jmp ..B2.88 +..B2.75: + movsd 8(%rsp), %xmm1 + movsd (%rsp), %xmm0 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + movsd %xmm0, 168(%rsp) + movsd %xmm1, 176(%rsp) + jmp ..B2.51 + .align 16,0x90 + .cfi_endproc + .type catanh,@function + .size catanh,.-catanh + .data +# -- End catanh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 16 +.L_2il0floatpacket.14: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,16 + .align 16 +.L_2il0floatpacket.15: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.16: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,16 + .align 16 +pc_thresh: + .byte 0x00,0xc0,0xf5,0x28,0x5c,0x8f,0xc2,0xf5,0xf9,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type pc_thresh,@object + .size pc_thresh,16 + .align 16 +_LDB_MIN_NORMAL: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _LDB_MIN_NORMAL,@object + .size _LDB_MIN_NORMAL,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +zeros: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .type zeros,@object + .size zeros,16 + .align 4 +.L_2il0floatpacket.12: + .long 0x00800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/catanhl.S b/external/sgx_libm/intel64/catanhl.S new file mode 100644 index 0000000000..b30a49259c --- /dev/null +++ b/external/sgx_libm/intel64/catanhl.S @@ -0,0 +1,2753 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catanhl.c" + .text +..TXTST0: +# -- Begin catanhl + .text + .align 16,0x90 + .globl catanhl +catanhl: +# parameter 1: 80 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_catanhl.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + subq $64, %rsp + .cfi_def_cfa_offset 80 + xorb %bpl, %bpl + fldt .L_2il0floatpacket.17(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 48(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) +..B1.2: + fnstcw 2(%rsp) +..B1.3: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.5: + fldcw (%rsp) +..B1.6: + movb $1, %bpl +..B1.7: + movzwl 88(%rsp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.14 +..B1.8: + testl %edx, %edx + jle ..B1.35 +..B1.9: + movzwl 104(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jge ..B1.15 +..B1.10: + testl %eax, %eax + jle ..B1.33 +..B1.11: + addq $-32, %rsp + .cfi_def_cfa_offset 112 + fldt 112(%rsp) + fstpt (%rsp) + fldt 128(%rsp) + fstpt 16(%rsp) +..___tag_value_catanhl.7: + call recatanhl +..___tag_value_catanhl.8: +..B1.56: + addq $32, %rsp + .cfi_def_cfa_offset 80 +..B1.12: + fstpt 16(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 112 + fldt 112(%rsp) + fstpt (%rsp) + fldt 128(%rsp) + fstpt 16(%rsp) +..___tag_value_catanhl.11: + call imcatanhl +..___tag_value_catanhl.12: +..B1.57: + addq $32, %rsp + .cfi_def_cfa_offset 80 +..B1.13: + fstpt 32(%rsp) + jmp ..B1.28 +..B1.14: + movzwl 104(%rsp), %eax + andl $32767, %eax +..B1.15: + cmpl $32767, %edx + je ..B1.47 +..B1.16: + cmpl $32767, %eax + je ..B1.41 +..B1.17: + cmpl $32767, %eax + jge ..B1.27 +..B1.18: + cmpl $0, 84(%rsp) + jne ..B1.20 +..B1.19: + cmpl $0, 80(%rsp) + je ..B1.27 +..B1.20: + cmpl $16383, %edx + jge ..B1.22 +..B1.21: + addq $-16, %rsp + .cfi_def_cfa_offset 96 + fldt 96(%rsp) + fstpt (%rsp) + call atanhl@PLT +..B1.58: + addq $16, %rsp + .cfi_def_cfa_offset 80 + lea 64+_CONSTANTS(%rip), %rax + movb 105(%rsp), %dl + lea _CONSTANTS(%rip), %rcx + andb $-128, %dl + fstpt 16(%rsp) + fldt (%rax) + shrb $7, %dl + movzbl %dl, %esi + shlq $4, %rsi + fldt (%rcx,%rsi) + fmulp %st, %st(1) + fstpt 32(%rsp) + jmp ..B1.28 +..B1.22: + je ..B1.38 +..B1.23: + cmpl $32767, %edx + jl ..B1.25 +..B1.24: + movb 89(%rsp), %dl + lea 64+_CONSTANTS(%rip), %rax + andb $-128, %dl + lea _CONSTANTS(%rip), %rdi + shrb $7, %dl + fldt (%rax) + movzbl %dl, %ecx + shlq $4, %rcx + fldt (%rdi,%rcx) + fmulp %st, %st(1) + fstpt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 96 + movb 121(%rsp), %sil + andb $-128, %sil + shrb $7, %sil + movzbl %sil, %r8d + shlq $4, %r8 + fldt (%rdi,%r8) + fstpt (%rsp) + call asinl@PLT + jmp ..B1.62 + .cfi_def_cfa_offset 80 +..B1.25: + addq $-32, %rsp + .cfi_def_cfa_offset 112 + fldt 112(%rsp) + fstpt (%rsp) + fldt 128(%rsp) + fstpt 16(%rsp) +..___tag_value_catanhl.19: + call recatanhl +..___tag_value_catanhl.20: +..B1.60: + addq $32, %rsp + .cfi_def_cfa_offset 80 +..B1.26: + fstpt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 96 + movb 121(%rsp), %al + lea _CONSTANTS(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + shlq $4, %rcx + fldt (%rdx,%rcx) + fstpt (%rsp) + call asinl@PLT + jmp ..B1.62 + .cfi_def_cfa_offset 80 +..B1.27: + movb 89(%rsp), %dl + lea 64+_CONSTANTS(%rip), %rax + andb $-128, %dl + lea _CONSTANTS(%rip), %rcx + shrb $7, %dl + fldt (%rax) + movzbl %dl, %esi + shlq $4, %rsi + fldt (%rcx,%rsi) + fmulp %st, %st(1) + fstpt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 96 + fldt 112(%rsp) + fstpt (%rsp) + call atanl@PLT +..B1.62: + addq $16, %rsp + .cfi_def_cfa_offset 80 + fstpt 32(%rsp) +..B1.28: + testb %bpl, %bpl + je ..B1.30 +..B1.29: + fldcw 2(%rsp) +..B1.30: + movq 48(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.40 +..B1.31: + fldt 16(%rsp) + fldt 32(%rsp) + movq 48(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.39 +..B1.32: + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 80 + .cfi_offset 6, -16 +..B1.33: + cmpl $0, 100(%rsp) + jne ..B1.11 +..B1.34: + cmpl $0, 96(%rsp) + jne ..B1.11 + jmp ..B1.15 +..B1.35: + cmpl $0, 84(%rsp) + jne ..B1.9 +..B1.36: + cmpl $0, 80(%rsp) + jne ..B1.9 + jmp ..B1.14 +..B1.38: + movq $0x8000000000000000, %rax + cmpq 80(%rsp), %rax + je ..B1.21 + jmp ..B1.23 +..B1.39: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.40: + call __stack_chk_fail@PLT +..B1.41: + cmpl $-2147483648, 100(%rsp) + jne ..B1.43 +..B1.42: + cmpl $0, 96(%rsp) + je ..B1.17 +..B1.43: + cmpl $32767, %edx + jge ..B1.17 +..B1.44: + cmpl $0, 84(%rsp) + jne ..B1.46 +..B1.45: + cmpl $0, 80(%rsp) + je ..B1.17 +..B1.46: + fldt 96(%rsp) + fmul %st(0), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) + jmp ..B1.28 +..B1.47: + cmpl $-2147483648, 84(%rsp) + jne ..B1.49 +..B1.48: + cmpl $0, 80(%rsp) + je ..B1.16 +..B1.49: + cmpl $32767, %eax + jge ..B1.51 +..B1.50: + fldt 80(%rsp) + fmul %st(0), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) + jmp ..B1.28 +..B1.51: + fldt 80(%rsp) + movq $0x8000000000000000, %rax + cmpq 96(%rsp), %rax + je ..B1.53 +..B1.52: + fmul %st(0), %st + fstpt 16(%rsp) + fldt 96(%rsp) + fmul %st(0), %st + fstpt 32(%rsp) + jmp ..B1.28 +..B1.53: + fmul %st(0), %st + lea 64+_CONSTANTS(%rip), %rax + fstpt 80(%rsp) + fldt (%rax) + fstpt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 96 + fldt 112(%rsp) + fstpt (%rsp) + call atanl@PLT + jmp ..B1.62 + .align 16,0x90 + .cfi_endproc + .type catanhl,@function + .size catanhl,.-catanhl + .data +# -- End catanhl + .text +# -- Begin recatanhl + .text + .align 16,0x90 +recatanhl: +# parameter 1: 576 + %rsp +# parameter 2: 592 + %rsp +..B2.1: + .cfi_startproc +..___tag_value_recatanhl.33: +..L34: + + subq $568, %rsp + .cfi_def_cfa_offset 576 + lea 64+_CONSTANTS(%rip), %rdx + fldt 576(%rsp) + lea 128(%rsp), %rdi + movq %fs:40, %rax + xorq %rsp, %rax + fldt (%rdx) + movq %rax, 432(%rdi) + movl $0, 32(%rdi) + fstpt (%rsp) + fldt (%rsp) + fxch %st(1) + fstpt (%rdi) + fstpt 16(%rdi) +..___tag_value_recatanhl.36: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.37: +..B2.2: + fldt 592(%rsp) + lea 176(%rsp), %rdi + movl $0, 32(%rdi) + fstpt (%rdi) + fldt (%rsp) + fstpt 16(%rdi) +..___tag_value_recatanhl.38: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.39: +..B2.3: + fldt (%rsp) + lea _CONSTANTS(%rip), %rax + movzwl 136(%rsp), %edx + movl %edx, %esi + andl $32767, %esi + xorl %r9d, %r9d + movl $0, 256(%rsp) + cmpl $8383, %esi + fstpt 240(%rsp) + fldt (%rax) + fstpt 224(%rsp) + jl ..B2.7 +..B2.4: + cmpl $24383, %esi + jg ..B2.7 +..B2.5: + movzwl 232(%rsp), %r8d + movl %r8d, %ecx + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B2.7 +..B2.6: + cmpl $24383, %ecx + jle ..B2.10 +..B2.7: + lea 128(%rsp), %rdi +..___tag_value_recatanhl.40: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.41: +..B2.8: + lea 224(%rsp), %rdi +..___tag_value_recatanhl.42: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.43: +..B2.9: + movzwl 136(%rsp), %edx + movl %edx, %esi + movzwl 232(%rsp), %r8d + movl %r8d, %ecx + movl 256(%rsp), %r9d + andl $32767, %esi + andl $32767, %ecx +..B2.10: + movl 160(%rsp), %edi + lea -134(%r9,%rcx), %r10d + lea (%rsi,%rdi), %eax + cmpl %r10d, %eax + jle ..B2.27 +..B2.11: + movl 132(%rsp), %r11d + lea 134(%r9,%rcx), %r10d + cmpl %r10d, %eax + jge ..B2.28 +..B2.12: + testl %r11d, %r11d + jne ..B2.14 +..B2.13: + cmpl $0, 128(%rsp) + je ..B2.29 +..B2.14: + cmpl $0, 228(%rsp) + jne ..B2.16 +..B2.15: + cmpl $0, 224(%rsp) + je ..B2.28 +..B2.16: + cmpl %r9d, %edi + je ..B2.18 +..B2.17: + fldt 128(%rsp) + subl %r9d, %edi + fldt 144(%rsp) + addl $16383, %edi + andb $127, 9(%rsp) + andl $32767, %edi + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r9d, 160(%rsp) + fxch %st(2) + fstpt 128(%rsp) + fldt 128(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + movzwl 136(%rsp), %edx + jmp ..B2.19 +..B2.18: + fldt 128(%rsp) + fldt 144(%rsp) +..B2.19: + fldt 224(%rsp) + andl $32767, %edx + andl $32767, %r8d + fld %st(2) + movl %r9d, 304(%rsp) + cmpl %r8d, %edx + fadd %st(1), %st + jg ..B2.24 +..B2.20: + jne ..B2.25 +..B2.21: + movl 132(%rsp), %eax + movl 228(%rsp), %edx + cmpl %edx, %eax + ja ..B2.24 +..B2.22: + jne ..B2.25 +..B2.23: + movl 128(%rsp), %eax + cmpl 224(%rsp), %eax + jbe ..B2.25 +..B2.24: + fldt 240(%rsp) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + jmp ..B2.26 +..B2.25: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 240(%rsp) + faddp %st, %st(2) +..B2.26: + fld %st(1) + fadd %st(1), %st + fstpt 272(%rsp) + fldt 272(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 288(%rsp) + jmp ..B2.33 +..B2.27: + movl 132(%rsp), %r11d +..B2.28: + testl %r11d, %r11d + jne ..B2.30 +..B2.162: + cmpl $0, 128(%rsp) +..B2.29: + je ..B2.31 +..B2.30: + lea -16517(%r9,%rcx), %eax + lea -16383(%rdi,%rsi), %edx + cmpl %edx, %eax + jl ..B2.32 +..B2.31: + movaps 224(%rsp), %xmm0 + movaps 240(%rsp), %xmm1 + movaps 256(%rsp), %xmm2 + movaps %xmm0, 272(%rsp) + movaps %xmm1, 288(%rsp) + movaps %xmm2, 304(%rsp) + jmp ..B2.33 +..B2.32: + movaps 128(%rsp), %xmm0 + movaps 144(%rsp), %xmm1 + movaps 160(%rsp), %xmm2 + movaps %xmm0, 272(%rsp) + movaps %xmm1, 288(%rsp) + movaps %xmm2, 304(%rsp) +..B2.33: + movzwl 280(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.35 +..B2.34: + cmpl $24383, %eax + jle ..B2.37 +..B2.35: + lea 272(%rsp), %rdi +..___tag_value_recatanhl.44: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.45: +..B2.36: + lea 272(%rsp), %rdi +..___tag_value_recatanhl.46: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.47: +..B2.37: + fldt 272(%rsp) + lea 80+_CONSTANTS(%rip), %rdx + fld %st(0) + fld %st(1) + fld %st(2) + fldt 288(%rsp) + fmulp %st, %st(4) + movl 304(%rsp), %eax + fxch %st(3) + fadd %st(0), %st + fldt (%rdx) + addl %eax, %eax + fmul %st, %st(3) + movl %eax, 352(%rsp) + fxch %st(2) + fsub %st(3), %st + movzwl 184(%rsp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(4) + fmul %st(4), %st + cmpl $8383, %eax + fadd %st(0), %st + fxch %st(2) + fstpt 16(%rsp) + fxch %st(3) + fmul %st(0), %st + fld %st(1) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 320(%rsp) + fldt 320(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 336(%rsp) + jl ..B2.39 +..B2.38: + cmpl $24383, %eax + jle ..B2.41 +..B2.39: + lea 176(%rsp), %rdi +..___tag_value_recatanhl.48: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.49: +..B2.40: + lea 176(%rsp), %rdi +..___tag_value_recatanhl.50: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.51: +..B2.41: + fldt 176(%rsp) + fld %st(0) + fld %st(1) + fldt 16(%rsp) + fldt 192(%rsp) + fmul %st(4), %st + movzwl 328(%rsp), %edx + movl %edx, %esi + andl $32767, %esi + fadd %st(0), %st + fxch %st(4) + fmulp %st, %st(1) + movl 208(%rsp), %r9d + fsubr %st, %st(2) + addl %r9d, %r9d + faddp %st, %st(2) + fld %st(1) + cmpl $8383, %esi + fmul %st(2), %st + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(2) + movl %r9d, 400(%rsp) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsub %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(1) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 368(%rsp) + fldt 368(%rsp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 384(%rsp) + fstpt 32(%rsp) + jl ..B2.45 +..B2.42: + cmpl $24383, %esi + jg ..B2.45 +..B2.43: + movzwl 376(%rsp), %r8d + movl %r8d, %ecx + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B2.45 +..B2.44: + cmpl $24383, %ecx + jle ..B2.48 +..B2.45: + lea 320(%rsp), %rdi +..___tag_value_recatanhl.52: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.53: +..B2.46: + lea 368(%rsp), %rdi +..___tag_value_recatanhl.54: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.55: +..B2.47: + movzwl 328(%rsp), %edx + movl %edx, %esi + movzwl 376(%rsp), %r8d + movl %r8d, %ecx + movl 400(%rsp), %r9d + andl $32767, %esi + andl $32767, %ecx +..B2.48: + movl 352(%rsp), %edi + lea -134(%r9,%rcx), %r10d + lea (%rsi,%rdi), %eax + cmpl %r10d, %eax + jle ..B2.65 +..B2.49: + movl 324(%rsp), %r11d + lea 134(%r9,%rcx), %r10d + cmpl %r10d, %eax + jge ..B2.66 +..B2.50: + testl %r11d, %r11d + jne ..B2.52 +..B2.51: + cmpl $0, 320(%rsp) + je ..B2.67 +..B2.52: + cmpl $0, 372(%rsp) + jne ..B2.54 +..B2.53: + cmpl $0, 368(%rsp) + je ..B2.66 +..B2.54: + cmpl %r9d, %edi + je ..B2.56 +..B2.55: + fldt 32(%rsp) + subl %r9d, %edi + fstpt (%rsp) + addl $16383, %edi + fldt 320(%rsp) + andl $32767, %edi + fldt 336(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r9d, 352(%rsp) + fxch %st(2) + fstpt 320(%rsp) + fldt 320(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 336(%rsp) + fldt 336(%rsp) + fxch %st(1) + fstpt 32(%rsp) + movzwl 328(%rsp), %edx + jmp ..B2.57 +..B2.56: + fldt 320(%rsp) + fstpt 32(%rsp) + fldt 336(%rsp) +..B2.57: + fldt 368(%rsp) + andl $32767, %edx + fldt 32(%rsp) + andl $32767, %r8d + movl %r9d, 448(%rsp) + cmpl %r8d, %edx + fadd %st(1), %st + jg ..B2.62 +..B2.58: + jne ..B2.63 +..B2.59: + movl 324(%rsp), %eax + movl 372(%rsp), %edx + cmpl %edx, %eax + ja ..B2.62 +..B2.60: + jne ..B2.63 +..B2.61: + movl 320(%rsp), %eax + cmpl 368(%rsp), %eax + jbe ..B2.63 +..B2.62: + fldt 32(%rsp) + fsub %st(1), %st + faddp %st, %st(2) + fldt 384(%rsp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B2.64 +..B2.63: + fldt 32(%rsp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 384(%rsp) + faddp %st, %st(1) + fstpt 32(%rsp) +..B2.64: + fldt 32(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 432(%rsp) + jmp ..B2.71 +..B2.65: + movl 324(%rsp), %r11d +..B2.66: + testl %r11d, %r11d + jne ..B2.68 +..B2.164: + cmpl $0, 320(%rsp) +..B2.67: + je ..B2.69 +..B2.68: + lea -16517(%r9,%rcx), %eax + lea -16383(%rdi,%rsi), %edx + cmpl %edx, %eax + jl ..B2.70 +..B2.69: + movaps 368(%rsp), %xmm0 + movaps 384(%rsp), %xmm1 + movaps 400(%rsp), %xmm2 + movaps %xmm0, 416(%rsp) + movaps %xmm1, 432(%rsp) + movaps %xmm2, 448(%rsp) + jmp ..B2.71 +..B2.70: + movaps 320(%rsp), %xmm0 + movaps 336(%rsp), %xmm1 + movaps 352(%rsp), %xmm2 + movaps %xmm0, 416(%rsp) + movaps %xmm1, 432(%rsp) + movaps %xmm2, 448(%rsp) +..B2.71: + movzwl 136(%rsp), %edx + movl %edx, %esi + andl $32767, %esi + cmpl $8383, %esi + jl ..B2.75 +..B2.72: + cmpl $24383, %esi + jg ..B2.75 +..B2.73: + movzwl 232(%rsp), %r9d + movl %r9d, %ecx + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B2.75 +..B2.74: + cmpl $24383, %ecx + jle ..B2.78 +..B2.75: + lea 128(%rsp), %rdi +..___tag_value_recatanhl.56: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.57: +..B2.76: + lea 224(%rsp), %rdi +..___tag_value_recatanhl.58: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.59: +..B2.77: + movzwl 136(%rsp), %edx + movl %edx, %esi + movzwl 232(%rsp), %r9d + movl %r9d, %ecx + andl $32767, %esi + andl $32767, %ecx +..B2.78: + movl 160(%rsp), %edi + movl 256(%rsp), %r8d + lea (%rsi,%rdi), %eax + lea -134(%r8,%rcx), %r10d + cmpl %r10d, %eax + jle ..B2.95 +..B2.79: + movl 132(%rsp), %r11d + lea 134(%r8,%rcx), %r10d + cmpl %r10d, %eax + jge ..B2.96 +..B2.80: + testl %r11d, %r11d + jne ..B2.82 +..B2.81: + cmpl $0, 128(%rsp) + je ..B2.97 +..B2.82: + cmpl $0, 228(%rsp) + jne ..B2.84 +..B2.83: + cmpl $0, 224(%rsp) + je ..B2.96 +..B2.84: + cmpl %r8d, %edi + je ..B2.86 +..B2.85: + fldt 32(%rsp) + subl %r8d, %edi + fstpt (%rsp) + addl $16383, %edi + fldt 128(%rsp) + andl $32767, %edi + fldt 144(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r8d, 160(%rsp) + fxch %st(2) + fstpt 128(%rsp) + fldt 128(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + movzwl 136(%rsp), %edx + jmp ..B2.87 +..B2.86: + fldt 128(%rsp) + fldt 144(%rsp) +..B2.87: + fldt 224(%rsp) + andl $32767, %edx + andl $32767, %r9d + fld %st(2) + movl %r8d, 304(%rsp) + cmpl %r9d, %edx + fsub %st(1), %st + jg ..B2.92 +..B2.88: + jne ..B2.93 +..B2.89: + movl 132(%rsp), %eax + movl 228(%rsp), %edx + cmpl %edx, %eax + ja ..B2.92 +..B2.90: + jne ..B2.93 +..B2.91: + movl 128(%rsp), %eax + cmpl 224(%rsp), %eax + jbe ..B2.93 +..B2.92: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 240(%rsp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + jmp ..B2.94 +..B2.93: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 240(%rsp) + fsubrp %st, %st(2) +..B2.94: + fld %st(1) + fadd %st(1), %st + fstpt 272(%rsp) + fldt 272(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 288(%rsp) + jmp ..B2.101 +..B2.95: + movl 132(%rsp), %r11d +..B2.96: + testl %r11d, %r11d + jne ..B2.98 +..B2.161: + cmpl $0, 128(%rsp) +..B2.97: + je ..B2.99 +..B2.98: + lea -16517(%r8,%rcx), %eax + lea -16383(%rdi,%rsi), %edx + cmpl %edx, %eax + jl ..B2.100 +..B2.99: + fldt 224(%rsp) + fchs + movl %r8d, 304(%rsp) + fstpt 272(%rsp) + fldt 240(%rsp) + fchs + fstpt 288(%rsp) + jmp ..B2.101 +..B2.100: + movaps 128(%rsp), %xmm0 + movaps 144(%rsp), %xmm1 + movaps 160(%rsp), %xmm2 + movaps %xmm0, 272(%rsp) + movaps %xmm1, 288(%rsp) + movaps %xmm2, 304(%rsp) +..B2.101: + movzwl 280(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.103 +..B2.102: + cmpl $24383, %eax + jle ..B2.105 +..B2.103: + lea 272(%rsp), %rdi +..___tag_value_recatanhl.60: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.61: +..B2.104: + lea 272(%rsp), %rdi +..___tag_value_recatanhl.62: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.63: +..B2.105: + fldt 272(%rsp) + fld %st(0) + fld %st(1) + fldt 16(%rsp) + fldt 288(%rsp) + fxch %st(1) + fmul %st(4), %st + movl 304(%rsp), %edi + fsubr %st, %st(3) + addl %edi, %edi + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(3) + movl %edi, 352(%rsp) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(1) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 320(%rsp) + fldt 320(%rsp) + fsubrp %st, %st(2) + movzwl 328(%rsp), %edx + movl %edx, %esi + andl $32767, %esi + fadd %st, %st(1) + fxch %st(1) + fstpt 336(%rsp) + cmpl $8383, %esi + fstpt 32(%rsp) + jl ..B2.109 +..B2.106: + cmpl $24383, %esi + jg ..B2.109 +..B2.107: + movzwl 376(%rsp), %r9d + movl %r9d, %ecx + andl $32767, %ecx + cmpl $8383, %ecx + jl ..B2.109 +..B2.108: + cmpl $24383, %ecx + jle ..B2.112 +..B2.109: + lea 320(%rsp), %rdi +..___tag_value_recatanhl.64: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.65: +..B2.110: + lea 368(%rsp), %rdi +..___tag_value_recatanhl.66: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.67: +..B2.111: + movzwl 328(%rsp), %edx + movl %edx, %esi + movzwl 376(%rsp), %r9d + movl %r9d, %ecx + movl 352(%rsp), %edi + andl $32767, %esi + andl $32767, %ecx +..B2.112: + movl 400(%rsp), %r8d + lea (%rdi,%rsi), %eax + lea -134(%r8,%rcx), %r10d + cmpl %r10d, %eax + jle ..B2.129 +..B2.113: + movl 324(%rsp), %r11d + lea 134(%r8,%rcx), %r10d + cmpl %r10d, %eax + jge ..B2.130 +..B2.114: + testl %r11d, %r11d + jne ..B2.116 +..B2.115: + cmpl $0, 320(%rsp) + je ..B2.131 +..B2.116: + cmpl $0, 372(%rsp) + jne ..B2.118 +..B2.117: + cmpl $0, 368(%rsp) + je ..B2.130 +..B2.118: + cmpl %r8d, %edi + je ..B2.120 +..B2.119: + fldt 32(%rsp) + subl %r8d, %edi + fstpt (%rsp) + addl $16383, %edi + fldt 320(%rsp) + andl $32767, %edi + fldt 336(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r8d, 352(%rsp) + fxch %st(2) + fstpt 320(%rsp) + fldt 320(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 336(%rsp) + fldt 336(%rsp) + movzwl 328(%rsp), %edx + jmp ..B2.121 +..B2.120: + fldt 320(%rsp) + fldt 336(%rsp) +..B2.121: + fldt 368(%rsp) + andl $32767, %edx + andl $32767, %r9d + fld %st(2) + movl %r8d, 496(%rsp) + cmpl %r9d, %edx + fadd %st(1), %st + jg ..B2.126 +..B2.122: + jne ..B2.127 +..B2.123: + movl 324(%rsp), %eax + movl 372(%rsp), %edx + cmpl %edx, %eax + ja ..B2.126 +..B2.124: + jne ..B2.127 +..B2.125: + movl 320(%rsp), %eax + cmpl 368(%rsp), %eax + jbe ..B2.127 +..B2.126: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 384(%rsp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.128 +..B2.127: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 384(%rsp) + faddp %st, %st(1) +..B2.128: + fld %st(0) + fadd %st(2), %st + fstpt 464(%rsp) + fldt 464(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 480(%rsp) + jmp ..B2.135 +..B2.129: + movl 324(%rsp), %r11d +..B2.130: + testl %r11d, %r11d + jne ..B2.132 +..B2.163: + cmpl $0, 320(%rsp) +..B2.131: + je ..B2.133 +..B2.132: + lea -16517(%r8,%rcx), %eax + lea -16383(%rdi,%rsi), %edx + cmpl %edx, %eax + jl ..B2.134 +..B2.133: + movaps 368(%rsp), %xmm0 + movaps 384(%rsp), %xmm1 + movaps 400(%rsp), %xmm2 + movaps %xmm0, 464(%rsp) + movaps %xmm1, 480(%rsp) + movaps %xmm2, 496(%rsp) + jmp ..B2.135 +..B2.134: + movaps 320(%rsp), %xmm0 + movaps 336(%rsp), %xmm1 + movaps 352(%rsp), %xmm2 + movl 352(%rsp), %r8d + movaps %xmm0, 464(%rsp) + movaps %xmm1, 480(%rsp) + movaps %xmm2, 496(%rsp) +..B2.135: + movzwl 424(%rsp), %ecx + movzwl 472(%rsp), %edi + andl $32767, %ecx + andl $32767, %edi + movl 448(%rsp), %esi + lea (%rsi,%rcx), %edx + lea (%r8,%rdi), %eax + subl %eax, %edx + cmpl $-1, %edx + jge ..B2.145 +..B2.136: + cmpl $8383, %ecx + jl ..B2.140 +..B2.137: + cmpl $24383, %ecx + jg ..B2.140 +..B2.138: + cmpl $8383, %edi + jl ..B2.140 +..B2.139: + cmpl $24383, %edi + jle ..B2.143 +..B2.140: + lea 416(%rsp), %rdi +..___tag_value_recatanhl.68: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.69: +..B2.141: + lea 464(%rsp), %rdi +..___tag_value_recatanhl.70: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.71: +..B2.142: + movl 448(%rsp), %esi + movl 496(%rsp), %r8d +..B2.143: + fldt 464(%rsp) + subl %r8d, %esi + fld %st(0) + fld %st(1) + fldt 416(%rsp) + lea 512(%rsp), %rdi + fld %st(0) + fdiv %st(4), %st + fldt 16(%rsp) + fld %st(0) + fmul %st(2), %st + fld %st(0) + movl %esi, 64(%rsp) + lea 32(%rsp), %rsi + fsubr %st(3), %st + faddp %st, %st(1) + fld %st(0) + fsubr %st(3), %st + fxch %st(2) + fmul %st(7), %st + fsubr %st, %st(6) + faddp %st, %st(6) + fxch %st(4) + fsub %st(5), %st + fld %st(4) + fmul %st(6), %st + fxch %st(2) + fmul %st, %st(6) + fxch %st(1) + fmul %st, %st(5) + fxch %st(6) + faddp %st, %st(5) + fld %st(4) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fsubp %st, %st(1) + fldt 400(%rsi) + faddp %st, %st(1) + fldt 448(%rsi) + fmul %st(2), %st + fsubrp %st, %st(1) + fdivp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt (%rsi) + fldt (%rsi) + fsubrp %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + faddp %st, %st(1) + fstpt 16(%rsi) +..___tag_value_recatanhl.72: + call __libm_log_k80@PLT +..___tag_value_recatanhl.73: + jmp ..B2.153 +..B2.145: + movzwl 136(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.149 +..B2.146: + cmpl $24383, %eax + jg ..B2.149 +..B2.147: + cmpl $8383, %edi + jl ..B2.149 +..B2.148: + cmpl $24383, %edi + jle ..B2.152 +..B2.149: + lea 128(%rsp), %rdi +..___tag_value_recatanhl.74: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.75: +..B2.150: + lea 464(%rsp), %rdi +..___tag_value_recatanhl.76: + call __libm_normalizel_k80@PLT +..___tag_value_recatanhl.77: +..B2.151: + movl 496(%rsp), %r8d +..B2.152: + fldt 128(%rsp) + lea 512(%rsp), %rdi + fld %st(0) + lea 80(%rsp), %rsi + fldt 384(%rsi) + fdivr %st, %st(1) + fld %st(0) + fld %st(1) + fldt -64(%rsi) + fld %st(0) + fmul %st(5), %st + fld %st(0) + movl 80(%rsi), %eax + fsubr %st(6), %st + subl %r8d, %eax + faddp %st, %st(1) + fld %st(0) + addl $2, %eax + movl %eax, 32(%rsi) + fsubr %st(6), %st + fxch %st(2) + fmul %st(5), %st + fsubr %st, %st(4) + faddp %st, %st(4) + fxch %st(2) + fsub %st(3), %st + fld %st(2) + fmul %st(4), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fsubrp %st, %st(3) + fldt 64(%rsi) + faddp %st, %st(3) + fldt 400(%rsi) + fmul %st(2), %st + fsubrp %st, %st(3) + fdivrp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt (%rsi) + fldt (%rsi) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 16(%rsi) + fstpt (%rsp) +..___tag_value_recatanhl.78: + call __libm_log1p_k80@PLT +..___tag_value_recatanhl.79: +..B2.153: + movl 544(%rsp), %edi + addl $-2, %edi + movl %edi, 544(%rsp) +..B2.154: + addq $-32, %rsp + .cfi_def_cfa_offset 608 + fldt 544(%rsp) + fstpt (%rsp) + fldt 560(%rsp) + fstpt 16(%rsp) +..___tag_value_recatanhl.81: + call __libm_scalbl_k80@PLT +..___tag_value_recatanhl.82: +..B2.160: + addq $32, %rsp + .cfi_def_cfa_offset 576 +..B2.155: + movq 560(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.157 +..B2.156: + addq $568, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 576 +..B2.157: + fstp %st(0) + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type recatanhl,@function + .size recatanhl,.-recatanhl + .data +# -- End recatanhl + .text +# -- Begin imcatanhl + .text + .align 16,0x90 +imcatanhl: +# parameter 1: 656 + %rsp +# parameter 2: 672 + %rsp +..B3.1: + .cfi_startproc +..___tag_value_imcatanhl.87: +..L88: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + subq $632, %rsp + .cfi_def_cfa_offset 656 + lea _CONSTANTS(%rip), %rbx + fldt 656(%rsp) + lea 64+_CONSTANTS(%rip), %r9 + movb 665(%rsp), %sil + lea 288(%rsp), %rdi + andb $-128, %sil + shrb $7, %sil + fldt (%r9) + movb 681(%rsp), %dl + andb $-128, %dl + shrb $7, %dl + movzbl %sil, %r8d + shlq $4, %r8 + movzbl %dl, %ecx + shlq $4, %rcx + movq %fs:40, %rax + fldt (%rbx,%r8) + xorq %rsp, %rax + fmulp %st, %st(2) + fldt 32(%rbx,%rcx) + movq %rax, 336(%rdi) + fstpt 16(%rsp) + movl $0, 32(%rdi) + fxch %st(1) + fstpt (%rdi) + fstpt (%rsp) + fldt (%rsp) + fstpt 16(%rdi) +..___tag_value_imcatanhl.94: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.95: +..B3.2: + fldt 672(%rsp) + lea 336(%rsp), %rdi + fldt (%rsp) + movb 681(%rsp), %al + andb $-128, %al + shrb $7, %al + fstpt 16(%rdi) + movzbl %al, %edx + shlq $4, %rdx + movl $0, 32(%rdi) + fldt (%rbx,%rdx) + fmulp %st, %st(1) + fstpt (%rdi) +..___tag_value_imcatanhl.96: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.97: +..B3.3: + fldt (%rbx) + movzwl 296(%rsp), %eax + andl $32767, %eax + movl $0, 416(%rsp) + cmpl $8383, %eax + fstpt 384(%rsp) + fldt (%rsp) + fstpt 400(%rsp) + jl ..B3.5 +..B3.4: + cmpl $24383, %eax + jle ..B3.7 +..B3.5: + lea 288(%rsp), %rdi +..___tag_value_imcatanhl.98: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.99: +..B3.6: + lea 288(%rsp), %rdi +..___tag_value_imcatanhl.100: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.101: +..B3.7: + fldt 288(%rsp) + lea 80+_CONSTANTS(%rip), %rdx + fld %st(0) + fld %st(1) + fld %st(2) + fld %st(3) + movl 320(%rsp), %eax + fldt (%rdx) + addl %eax, %eax + fmul %st, %st(4) + movl %eax, 464(%rsp) + fxch %st(3) + fsubr %st(4), %st + fld %st(0) + fchs + movzwl 344(%rsp), %eax + fadd %st(5), %st + fld %st(0) + andl $32767, %eax + fxch %st(5) + fstpt (%rsp) + cmpl $8383, %eax + fxch %st(1) + fsubrp %st, %st(5) + fxch %st(3) + fmul %st(4), %st + fxch %st(2) + fsub %st(3), %st + fxch %st(1) + fsub %st(4), %st + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 304(%rsp) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 432(%rsp) + fldt 432(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 448(%rsp) + jl ..B3.9 +..B3.8: + cmpl $24383, %eax + jle ..B3.11 +..B3.9: + lea 336(%rsp), %rdi +..___tag_value_imcatanhl.102: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.103: +..B3.10: + lea 336(%rsp), %rdi +..___tag_value_imcatanhl.104: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.105: +..B3.11: + fldt 336(%rsp) + fld %st(0) + fld %st(1) + fldt (%rsp) + fmul %st(3), %st + movzwl 392(%rsp), %esi + movl %esi, %r10d + andl $32767, %r10d + fsubr %st, %st(2) + movl 368(%rsp), %eax + faddp %st, %st(2) + fld %st(1) + addl %eax, %eax + fmul %st(2), %st + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(2) + cmpl $8383, %r10d + movl %eax, 512(%rsp) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fldt 352(%rsp) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 480(%rsp) + fldt 480(%rsp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 496(%rsp) + fstpt 32(%rsp) + jl ..B3.15 +..B3.12: + cmpl $24383, %r10d + jg ..B3.15 +..B3.13: + movzwl 440(%rsp), %edi + movl %edi, %r9d + andl $32767, %r9d + cmpl $8383, %r9d + jl ..B3.15 +..B3.14: + cmpl $24383, %r9d + jle ..B3.18 +..B3.15: + lea 384(%rsp), %rdi +..___tag_value_imcatanhl.106: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.107: +..B3.16: + lea 432(%rsp), %rdi +..___tag_value_imcatanhl.108: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.109: +..B3.17: + movzwl 392(%rsp), %esi + movl %esi, %r10d + movzwl 440(%rsp), %edi + movl %edi, %r9d + andl $32767, %r10d + andl $32767, %r9d +..B3.18: + movl 416(%rsp), %eax + movl 464(%rsp), %edx + lea (%r10,%rax), %ebx + lea -134(%rdx,%r9), %ecx + cmpl %ecx, %ebx + jle ..B3.35 +..B3.19: + movl 388(%rsp), %r8d + lea 134(%rdx,%r9), %ecx + cmpl %ecx, %ebx + jge ..B3.36 +..B3.20: + testl %r8d, %r8d + jne ..B3.22 +..B3.21: + cmpl $0, 384(%rsp) + je ..B3.37 +..B3.22: + cmpl $0, 436(%rsp) + jne ..B3.24 +..B3.23: + cmpl $0, 432(%rsp) + je ..B3.36 +..B3.24: + cmpl %edx, %eax + je ..B3.26 +..B3.25: + fldt 32(%rsp) + subl %edx, %eax + fstpt (%rsp) + addl $16383, %eax + fldt 384(%rsp) + andl $32767, %eax + fldt 400(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + movw %cx, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 416(%rsp) + fxch %st(2) + fstpt 384(%rsp) + fldt 384(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 400(%rsp) + fldt 400(%rsp) + fxch %st(1) + fstpt 32(%rsp) + movzwl 392(%rsp), %esi + jmp ..B3.27 +..B3.26: + fldt 384(%rsp) + fstpt 32(%rsp) + fldt 400(%rsp) +..B3.27: + fldt 432(%rsp) + andl $32767, %esi + fldt 32(%rsp) + andl $32767, %edi + movl %edx, 560(%rsp) + cmpl %edi, %esi + fsub %st(1), %st + jg ..B3.32 +..B3.28: + jne ..B3.33 +..B3.29: + movl 388(%rsp), %eax + movl 436(%rsp), %edx + cmpl %edx, %eax + ja ..B3.32 +..B3.30: + jne ..B3.33 +..B3.31: + movl 384(%rsp), %eax + cmpl 432(%rsp), %eax + jbe ..B3.33 +..B3.32: + fldt 32(%rsp) + fsub %st(1), %st + fsubp %st, %st(2) + fldt 448(%rsp) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B3.34 +..B3.33: + fldt 32(%rsp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fldt 448(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) +..B3.34: + fldt 32(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 528(%rsp) + fldt 528(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 544(%rsp) + jmp ..B3.41 +..B3.35: + movl 388(%rsp), %r8d +..B3.36: + testl %r8d, %r8d + jne ..B3.38 +..B3.179: + cmpl $0, 384(%rsp) +..B3.37: + je ..B3.39 +..B3.38: + lea -16517(%rdx,%r9), %ecx + lea -16383(%rax,%r10), %eax + cmpl %eax, %ecx + jl ..B3.40 +..B3.39: + fldt 432(%rsp) + fchs + movl %edx, 560(%rsp) + fstpt 528(%rsp) + fldt 448(%rsp) + fchs + fstpt 544(%rsp) + jmp ..B3.41 +..B3.40: + movaps 384(%rsp), %xmm0 + movaps 400(%rsp), %xmm1 + movaps 416(%rsp), %xmm2 + movaps %xmm0, 528(%rsp) + movaps %xmm1, 544(%rsp) + movaps %xmm2, 560(%rsp) +..B3.41: + movzwl 536(%rsp), %esi + movl %esi, %r10d + andl $32767, %r10d + cmpl $8383, %r10d + jl ..B3.45 +..B3.42: + cmpl $24383, %r10d + jg ..B3.45 +..B3.43: + movzwl 488(%rsp), %edi + movl %edi, %r9d + andl $32767, %r9d + cmpl $8383, %r9d + jl ..B3.45 +..B3.44: + cmpl $24383, %r9d + jle ..B3.48 +..B3.45: + lea 528(%rsp), %rdi +..___tag_value_imcatanhl.110: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.111: +..B3.46: + lea 480(%rsp), %rdi +..___tag_value_imcatanhl.112: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.113: +..B3.47: + movzwl 536(%rsp), %esi + movl %esi, %r10d + movzwl 488(%rsp), %edi + movl %edi, %r9d + andl $32767, %r10d + andl $32767, %r9d +..B3.48: + movl 512(%rsp), %edx + movl 560(%rsp), %eax + lea -134(%rdx,%r9), %ecx + lea (%r10,%rax), %ebx + cmpl %ecx, %ebx + jle ..B3.65 +..B3.49: + movl 532(%rsp), %r8d + lea 134(%rdx,%r9), %ecx + cmpl %ecx, %ebx + jge ..B3.66 +..B3.50: + testl %r8d, %r8d + jne ..B3.52 +..B3.51: + cmpl $0, 528(%rsp) + je ..B3.67 +..B3.52: + cmpl $0, 484(%rsp) + jne ..B3.54 +..B3.53: + cmpl $0, 480(%rsp) + je ..B3.66 +..B3.54: + cmpl %edx, %eax + je ..B3.56 +..B3.55: + fldt 32(%rsp) + subl %edx, %eax + fstpt (%rsp) + addl $16383, %eax + fldt 528(%rsp) + andl $32767, %eax + fldt 544(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + movw %cx, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 560(%rsp) + fxch %st(2) + fstpt 528(%rsp) + fldt 528(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 544(%rsp) + fldt 544(%rsp) + fstpt 32(%rsp) + movzwl 536(%rsp), %esi + jmp ..B3.57 +..B3.56: + fldt 528(%rsp) + fldt 544(%rsp) + fstpt 32(%rsp) +..B3.57: + fldt 480(%rsp) + andl $32767, %esi + andl $32767, %edi + fld %st(1) + movl %edx, 608(%rsp) + cmpl %edi, %esi + fsub %st(1), %st + jg ..B3.62 +..B3.58: + jne ..B3.63 +..B3.59: + movl 532(%rsp), %eax + movl 484(%rsp), %ecx + cmpl %ecx, %eax + ja ..B3.62 +..B3.60: + jne ..B3.63 +..B3.61: + movl 528(%rsp), %eax + cmpl 480(%rsp), %eax + jbe ..B3.63 +..B3.62: + fldt 32(%rsp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fldt 496(%rsp) + fsubrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) + jmp ..B3.64 +..B3.63: + fldt 496(%rsp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fldt 32(%rsp) + faddp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) +..B3.64: + fldt 32(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 576(%rsp) + fldt 576(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 592(%rsp) + jmp ..B3.71 +..B3.65: + movl 532(%rsp), %r8d +..B3.66: + testl %r8d, %r8d + jne ..B3.68 +..B3.180: + cmpl $0, 528(%rsp) +..B3.67: + je ..B3.69 +..B3.68: + lea -16517(%rdx,%r9), %ecx + lea -16383(%rax,%r10), %ebx + cmpl %ebx, %ecx + jl ..B3.70 +..B3.69: + fldt 480(%rsp) + fchs + movl %edx, 608(%rsp) + fstpt 576(%rsp) + fldt 496(%rsp) + fchs + fstpt 592(%rsp) + jmp ..B3.71 +..B3.70: + movaps 528(%rsp), %xmm0 + movl %eax, %edx + movaps 544(%rsp), %xmm1 + movaps 560(%rsp), %xmm2 + movaps %xmm0, 576(%rsp) + movaps %xmm1, 592(%rsp) + movaps %xmm2, 608(%rsp) +..B3.71: + movzwl 584(%rsp), %eax + andl $32767, %eax + lea -16383(%rdx,%rax), %edx + cmpl $-6, %edx + jge ..B3.164 +..B3.72: + movzwl 392(%rsp), %eax + movl %eax, %edx + andl $32767, %edx + cmpl $8383, %edx + jl ..B3.76 +..B3.73: + cmpl $24383, %edx + jg ..B3.76 +..B3.74: + movzwl 296(%rsp), %ecx + movl %ecx, %r9d + andl $32767, %r9d + cmpl $8383, %r9d + jl ..B3.76 +..B3.75: + cmpl $24383, %r9d + jle ..B3.79 +..B3.76: + lea 384(%rsp), %rdi +..___tag_value_imcatanhl.114: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.115: +..B3.77: + lea 288(%rsp), %rdi +..___tag_value_imcatanhl.116: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.117: +..B3.78: + movzwl 296(%rsp), %ecx + movl %ecx, %r9d + movzwl 392(%rsp), %eax + movl %eax, %edx + andl $32767, %r9d + andl $32767, %edx +..B3.79: + movl 320(%rsp), %r8d + movl 416(%rsp), %edi + lea -134(%r8,%r9), %ebx + lea (%rdx,%rdi), %r10d + cmpl %r10d, %ebx + lea (%r9,%r8), %esi + jge ..B3.96 +..B3.80: + movl 388(%rsp), %r13d + lea 134(%r8,%r9), %r11d + cmpl %r11d, %r10d + jge ..B3.97 +..B3.81: + testl %r13d, %r13d + jne ..B3.83 +..B3.82: + cmpl $0, 384(%rsp) + je ..B3.98 +..B3.83: + cmpl $0, 292(%rsp) + jne ..B3.85 +..B3.84: + cmpl $0, 288(%rsp) + je ..B3.97 +..B3.85: + cmpl %r8d, %edi + je ..B3.87 +..B3.86: + fldt 32(%rsp) + subl %r8d, %edi + fstpt (%rsp) + addl $16383, %edi + fldt 384(%rsp) + andl $32767, %edi + fldt 400(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edi, %eax + movl %r8d, %edi + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 384(%rsp) + fldt 384(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 392(%rsp), %eax + movl %eax, %edx + andl $32767, %edx + movl %r8d, 416(%rsp) + movl %edx, %r10d + fstpt 400(%rsp) + fldt 400(%rsp) + jmp ..B3.88 +..B3.87: + fldt 384(%rsp) + movl %eax, %r10d + fldt 400(%rsp) + andl $32767, %r10d +..B3.88: + fldt 288(%rsp) + movl %ecx, %r11d + andl $32767, %r11d + fld %st(2) + movl %r8d, 80(%rsp) + cmpl %r11d, %r10d + fadd %st(1), %st + jg ..B3.93 +..B3.89: + jne ..B3.94 +..B3.90: + movl 388(%rsp), %r10d + movl 292(%rsp), %r11d + cmpl %r11d, %r10d + ja ..B3.93 +..B3.91: + jne ..B3.94 +..B3.92: + movl 384(%rsp), %r10d + cmpl 288(%rsp), %r10d + jbe ..B3.94 +..B3.93: + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 304(%rsp) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B3.95 +..B3.94: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 304(%rsp) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) +..B3.95: + fldt 32(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 64(%rsp) + jmp ..B3.102 +..B3.96: + movl 388(%rsp), %r13d +..B3.97: + testl %r13d, %r13d + jne ..B3.99 +..B3.178: + cmpl $0, 384(%rsp) +..B3.98: + je ..B3.100 +..B3.99: + lea -16517(%r8,%r9), %r10d + lea -16383(%rdi,%rdx), %r11d + cmpl %r11d, %r10d + jl ..B3.101 +..B3.100: + movaps 288(%rsp), %xmm0 + movaps 304(%rsp), %xmm1 + movaps 320(%rsp), %xmm2 + movaps %xmm0, 48(%rsp) + movaps %xmm1, 64(%rsp) + movaps %xmm2, 80(%rsp) + jmp ..B3.102 +..B3.101: + movaps 384(%rsp), %xmm0 + movaps 400(%rsp), %xmm1 + movaps 416(%rsp), %xmm2 + movaps %xmm0, 48(%rsp) + movaps %xmm1, 64(%rsp) + movaps %xmm2, 80(%rsp) +..B3.102: + cmpl $8383, %edx + jl ..B3.106 +..B3.103: + cmpl $24383, %edx + jg ..B3.106 +..B3.104: + cmpl $8383, %r9d + jl ..B3.106 +..B3.105: + cmpl $24383, %r9d + jle ..B3.109 +..B3.106: + lea 384(%rsp), %rdi +..___tag_value_imcatanhl.118: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.119: +..B3.107: + lea 288(%rsp), %rdi +..___tag_value_imcatanhl.120: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.121: +..B3.108: + movzwl 296(%rsp), %ecx + movl %ecx, %eax + andl $32767, %eax + movl 320(%rsp), %r8d + movl 416(%rsp), %edi + lea (%r8,%rax), %esi + lea -134(%r8,%rax), %ebx + movzwl 392(%rsp), %eax + movl %eax, %edx + andl $32767, %edx +..B3.109: + lea (%rdi,%rdx), %r9d + cmpl %r9d, %ebx + jge ..B3.126 +..B3.110: + movl 388(%rsp), %r10d + lea 134(%rsi), %ebx + cmpl %ebx, %r9d + jge ..B3.127 +..B3.111: + testl %r10d, %r10d + jne ..B3.113 +..B3.112: + cmpl $0, 384(%rsp) + je ..B3.128 +..B3.113: + cmpl $0, 292(%rsp) + jne ..B3.115 +..B3.114: + cmpl $0, 288(%rsp) + je ..B3.127 +..B3.115: + cmpl %r8d, %edi + je ..B3.117 +..B3.116: + fldt 32(%rsp) + subl %r8d, %edi + fstpt (%rsp) + addl $16383, %edi + fldt 384(%rsp) + andl $32767, %edi + fldt 400(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edi, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r8d, 416(%rsp) + fxch %st(2) + fstpt 384(%rsp) + fldt 384(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 400(%rsp) + fldt 400(%rsp) + fxch %st(1) + fstpt 32(%rsp) + movzwl 392(%rsp), %eax + jmp ..B3.118 +..B3.117: + fldt 384(%rsp) + fstpt 32(%rsp) + fldt 400(%rsp) +..B3.118: + fldt 288(%rsp) + andl $32767, %eax + fldt 32(%rsp) + andl $32767, %ecx + movl %r8d, 128(%rsp) + cmpl %ecx, %eax + fsub %st(1), %st + jg ..B3.123 +..B3.119: + jne ..B3.124 +..B3.120: + movl 388(%rsp), %eax + movl 292(%rsp), %edx + cmpl %edx, %eax + ja ..B3.123 +..B3.121: + jne ..B3.124 +..B3.122: + movl 384(%rsp), %eax + cmpl 288(%rsp), %eax + jbe ..B3.124 +..B3.123: + fldt 32(%rsp) + fsub %st(1), %st + fsubp %st, %st(2) + fldt 304(%rsp) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B3.125 +..B3.124: + fldt 32(%rsp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fldt 304(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) +..B3.125: + fldt 32(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 96(%rsp) + fldt 96(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 112(%rsp) + jmp ..B3.132 +..B3.126: + movl 388(%rsp), %r10d +..B3.127: + testl %r10d, %r10d + jne ..B3.129 +..B3.177: + cmpl $0, 384(%rsp) +..B3.128: + je ..B3.130 +..B3.129: + addl $-16517, %esi + lea -16383(%rdi,%rdx), %eax + cmpl %eax, %esi + jl ..B3.131 +..B3.130: + fldt 288(%rsp) + fchs + movl %r8d, 128(%rsp) + fstpt 96(%rsp) + fldt 304(%rsp) + fchs + fstpt 112(%rsp) + jmp ..B3.132 +..B3.131: + movaps 384(%rsp), %xmm0 + movaps 400(%rsp), %xmm1 + movaps 416(%rsp), %xmm2 + movaps %xmm0, 96(%rsp) + movaps %xmm1, 112(%rsp) + movaps %xmm2, 128(%rsp) +..B3.132: + lea 144(%rsp), %rdi + lea 336(%rsp), %rsi + lea 48(%rsp), %rdx +..___tag_value_imcatanhl.122: + call __libm_atan2l_k80@PLT +..___tag_value_imcatanhl.123: +..B3.133: + lea 192(%rsp), %rdi + lea 336(%rsp), %rsi + lea 96(%rsp), %rdx +..___tag_value_imcatanhl.124: + call __libm_atan2l_k80@PLT +..___tag_value_imcatanhl.125: +..B3.134: + movzwl 152(%rsp), %ebx + movl %ebx, %r10d + andl $32767, %r10d + cmpl $8383, %r10d + jl ..B3.138 +..B3.135: + cmpl $24383, %r10d + jg ..B3.138 +..B3.136: + movzwl 200(%rsp), %esi + movl %esi, %r9d + andl $32767, %r9d + cmpl $8383, %r9d + jl ..B3.138 +..B3.137: + cmpl $24383, %r9d + jle ..B3.141 +..B3.138: + lea 144(%rsp), %rdi +..___tag_value_imcatanhl.126: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.127: +..B3.139: + lea 192(%rsp), %rdi +..___tag_value_imcatanhl.128: + call __libm_normalizel_k80@PLT +..___tag_value_imcatanhl.129: +..B3.140: + movzwl 152(%rsp), %ebx + movl %ebx, %r10d + movzwl 200(%rsp), %esi + movl %esi, %r9d + andl $32767, %r10d + andl $32767, %r9d +..B3.141: + movl 224(%rsp), %edi + movl 176(%rsp), %eax + lea -134(%rdi,%r9), %edx + lea (%r10,%rax), %ecx + cmpl %edx, %ecx + jle ..B3.158 +..B3.142: + movl 148(%rsp), %r8d + lea 134(%rdi,%r9), %edx + cmpl %edx, %ecx + jge ..B3.159 +..B3.143: + testl %r8d, %r8d + jne ..B3.145 +..B3.144: + cmpl $0, 144(%rsp) + je ..B3.160 +..B3.145: + cmpl $0, 196(%rsp) + jne ..B3.147 +..B3.146: + cmpl $0, 192(%rsp) + je ..B3.159 +..B3.147: + cmpl %edi, %eax + je ..B3.149 +..B3.148: + fldt 32(%rsp) + subl %edi, %eax + fstpt (%rsp) + addl $16383, %eax + fldt 144(%rsp) + andl $32767, %eax + fldt 160(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edi, 176(%rsp) + fxch %st(2) + fstpt 144(%rsp) + fldt 144(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + movzwl 152(%rsp), %ebx + jmp ..B3.150 +..B3.149: + fldt 144(%rsp) + fldt 160(%rsp) +..B3.150: + fldt 192(%rsp) + andl $32767, %ebx + andl $32767, %esi + fld %st(2) + movl %edi, 272(%rsp) + cmpl %esi, %ebx + fadd %st(1), %st + jg ..B3.155 +..B3.151: + jne ..B3.156 +..B3.152: + movl 148(%rsp), %eax + movl 196(%rsp), %edx + cmpl %edx, %eax + ja ..B3.155 +..B3.153: + jne ..B3.156 +..B3.154: + movl 144(%rsp), %eax + cmpl 192(%rsp), %eax + jbe ..B3.156 +..B3.155: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 208(%rsp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B3.157 +..B3.156: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 208(%rsp) + faddp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) +..B3.157: + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + jmp ..B3.167 +..B3.158: + movl 148(%rsp), %r8d +..B3.159: + testl %r8d, %r8d + jne ..B3.161 +..B3.181: + cmpl $0, 144(%rsp) +..B3.160: + je ..B3.162 +..B3.161: + lea -16517(%rdi,%r9), %edx + lea -16383(%rax,%r10), %ecx + cmpl %ecx, %edx + jl ..B3.163 +..B3.162: + fldt 192(%rsp) + fldt 208(%rsp) + movaps 192(%rsp), %xmm0 + movaps 208(%rsp), %xmm1 + movaps 224(%rsp), %xmm2 + movaps %xmm0, 240(%rsp) + movaps %xmm1, 256(%rsp) + movaps %xmm2, 272(%rsp) + jmp ..B3.167 +..B3.163: + fldt 144(%rsp) + movl %eax, %edi + fldt 160(%rsp) + movaps 144(%rsp), %xmm0 + movaps 160(%rsp), %xmm1 + movaps 176(%rsp), %xmm2 + movaps %xmm0, 240(%rsp) + movaps %xmm1, 256(%rsp) + movaps %xmm2, 272(%rsp) + jmp ..B3.167 +..B3.164: + je ..B3.171 +..B3.165: + incl 368(%rsp) + lea 240(%rsp), %rdi + lea 336(%rsp), %rsi + lea 576(%rsp), %rdx +..___tag_value_imcatanhl.130: + call __libm_atan2l_k80@PLT +..___tag_value_imcatanhl.131: +..B3.166: + fldt 240(%rsp) + fldt 256(%rsp) + movl 272(%rsp), %edi +..B3.167: + fldt 16(%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 240(%rsp) + fldt 240(%rsp) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 256(%rsp) + fldt 256(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 688 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_imcatanhl.133: + call __libm_scalbl_k80@PLT +..___tag_value_imcatanhl.134: +..B3.176: + addq $32, %rsp + .cfi_def_cfa_offset 656 +..B3.168: + movq 624(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B3.170 +..B3.169: + addq $632, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 656 + .cfi_offset 3, -24 + .cfi_offset 13, -16 +..B3.170: + fstp %st(0) + call __stack_chk_fail@PLT +..B3.171: + lea 96+_CONSTANTS(%rip), %rdx + movl 532(%rsp), %eax + cmpl 4(%rdx), %eax + jb ..B3.72 +..B3.172: + jne ..B3.165 +..B3.173: + movl 528(%rsp), %eax + cmpl (%rdx), %eax + jb ..B3.72 + jmp ..B3.165 + .align 16,0x90 + .cfi_endproc + .type imcatanhl,@function + .size imcatanhl,.-imcatanhl + .data +# -- End imcatanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.17: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,16 + .align 16 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 32768 + .word 16415 + .word 0 + .word 0 + .word 0 + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,112 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/catanl.S b/external/sgx_libm/intel64/catanl.S new file mode 100644 index 0000000000..aa1e9a3b48 --- /dev/null +++ b/external/sgx_libm/intel64/catanl.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "catanl.c" + .text +..TXTST0: +# -- Begin catanl + .text + .align 16,0x90 + .globl catanl +catanl: +# parameter 1: 144 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_catanl.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + subq $128, %rsp + .cfi_def_cfa_offset 144 + xorb %r13b, %r13b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 112(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 96(%rsp) +..B1.2: + fnstcw 2(%rsp) +..B1.3: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.5: + fldcw (%rsp) +..B1.6: + movb $1, %r13b +..B1.7: + fldt 160(%rsp) + movzwl 168(%rsp), %eax + andl $32767, %eax + fstpt 80(%rsp) + cmpl $32767, %eax + fldt 144(%rsp) + fstpt 96(%rsp) + jl ..B1.9 +..B1.8: + movq $0x8000000000000000, %rax + cmpq 160(%rsp), %rax + jne ..B1.10 +..B1.9: + movb 169(%rsp), %al + notb %al + movb 89(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 89(%rsp) +..B1.10: + addq $-32, %rsp + .cfi_def_cfa_offset 176 + movq %rsp, %rdi + movq 112(%rsp), %rax + movq 120(%rsp), %rdx + movq 128(%rsp), %rcx + movq 136(%rsp), %rsi + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + movq %rcx, 16(%rdi) + movq %rsi, 24(%rdi) + call catanhl@PLT +..B1.22: + fxch %st(1) + addq $32, %rsp + .cfi_def_cfa_offset 144 + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 24(%rsp), %eax + andl $32767, %eax + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + cmpl $32767, %eax + fstpt 48(%rsp) + fstpt 64(%rsp) + jl ..B1.12 +..B1.11: + movq $0x8000000000000000, %rax + cmpq 16(%rsp), %rax + jne ..B1.13 +..B1.12: + movb 25(%rsp), %al + notb %al + movb 73(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 73(%rsp) +..B1.13: + testb %r13b, %r13b + je ..B1.15 +..B1.14: + fldcw 2(%rsp) +..B1.15: + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.19 +..B1.16: + fldt 48(%rsp) + fldt 64(%rsp) + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.18 +..B1.17: + addq $128, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 144 + .cfi_offset 13, -16 +..B1.18: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.19: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type catanl,@function + .size catanl,.-catanl + .data +# -- End catanl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cbrt_gen.S b/external/sgx_libm/intel64/cbrt_gen.S new file mode 100644 index 0000000000..d562bb378f --- /dev/null +++ b/external/sgx_libm/intel64/cbrt_gen.S @@ -0,0 +1,737 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrt_gen.c" + .text +..TXTST0: +# -- Begin cbrt + .text + .align 16,0x90 + .globl cbrt +cbrt: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cbrt.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + movq %xmm0, %xmm7 + movl $524032, %edx + movsd EXP_MSK3(%rip), %xmm5 + movsd EXP_MSK2(%rip), %xmm3 + psrlq $44, %xmm7 + pextrw $0, %xmm7, %ecx + movd %xmm7, %eax + movsd EXP_MASK(%rip), %xmm1 + movsd SIG_MASK(%rip), %xmm2 + andl $248, %ecx + lea rcp_table(%rip), %r8 + movsd (%rcx,%r8), %xmm4 + movq %rax, %r9 + andl %eax, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_0.0.1 + cmpl $524032, %edx + je .L_2TAG_PACKET_1.0.1 + shrl $8, %edx + shrq $8, %r9 + andpd %xmm0, %xmm2 + andpd %xmm5, %xmm0 + orpd %xmm2, %xmm3 + orpd %xmm0, %xmm1 + movapd coeff_table(%rip), %xmm5 + movl $5462, %eax + movapd 16+coeff_table(%rip), %xmm6 + mull %edx + movq %r9, %rdx + andq $2047, %r9 + shrl $14, %eax + andl $2048, %edx + subq %rax, %r9 + subq %rax, %r9 + subq %rax, %r9 + shlq $8, %r9 + addl $682, %eax + orl %edx, %eax + movd %eax, %xmm7 + addq %r9, %rcx + psllq $52, %xmm7 +.L_2TAG_PACKET_2.0.1: + movapd 32+coeff_table(%rip), %xmm2 + movapd 48+coeff_table(%rip), %xmm0 + subsd %xmm3, %xmm1 + movq %xmm7, %xmm3 + lea cbrt_table(%rip), %r8 + mulsd (%rcx,%r8), %xmm7 + mulsd %xmm4, %xmm1 + lea D_table(%rip), %r8 + mulsd (%rcx,%r8), %xmm3 + movapd %xmm1, %xmm4 + unpcklpd %xmm1, %xmm1 + mulpd %xmm1, %xmm5 + mulpd %xmm1, %xmm6 + mulpd %xmm1, %xmm1 + addpd %xmm5, %xmm2 + addpd %xmm6, %xmm0 + mulpd %xmm1, %xmm2 + mulpd %xmm1, %xmm1 + mulsd %xmm7, %xmm4 + addpd %xmm2, %xmm0 + mulsd %xmm0, %xmm1 + unpckhpd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm3, %xmm0 + addsd %xmm7, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_0.0.1: + mulsd SCALE63(%rip), %xmm0 + movq %xmm0, %xmm7 + movl $524032, %edx + psrlq $44, %xmm7 + pextrw $0, %xmm7, %ecx + movd %xmm7, %eax + andl $248, %ecx + lea rcp_table(%rip), %r8 + movsd (%rcx,%r8), %xmm4 + movq %rax, %r9 + andl %eax, %edx + shrl $8, %edx + shrq $8, %r9 + cmpl $0, %edx + je .L_2TAG_PACKET_3.0.1 + andpd %xmm0, %xmm2 + andpd %xmm5, %xmm0 + orpd %xmm2, %xmm3 + orpd %xmm0, %xmm1 + movapd coeff_table(%rip), %xmm5 + movl $5462, %eax + movapd 16+coeff_table(%rip), %xmm6 + mull %edx + movq %r9, %rdx + andq $2047, %r9 + shrl $14, %eax + andl $2048, %edx + subq %rax, %r9 + subq %rax, %r9 + subq %rax, %r9 + shlq $8, %r9 + addl $661, %eax + orl %edx, %eax + movd %eax, %xmm7 + addq %r9, %rcx + psllq $52, %xmm7 + jmp .L_2TAG_PACKET_2.0.1 +.L_2TAG_PACKET_3.0.1: + cmpq $0, %r9 + jne .L_2TAG_PACKET_4.0.1 + xorpd %xmm0, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_4.0.1: + movsd ZERON(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_1.0.1: + movl 4(%rsp), %eax + movl (%rsp), %edx + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $2146435072, %ecx + ja .L_2TAG_PACKET_5.0.1 + cmpl $0, %edx + jne .L_2TAG_PACKET_5.0.1 + cmpl $2146435072, %eax + jne .L_2TAG_PACKET_6.0.1 + movsd INF(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_6.0.1: + movsd NEG_INF(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_5.0.1: + movsd (%rsp), %xmm0 + addsd %xmm0, %xmm0 + movq %xmm0, 8(%rsp) +.L_2TAG_PACKET_7.0.1: +..B1.4: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cbrt,@function + .size cbrt,.-cbrt + .data +# -- End cbrt + .section .rodata, "a" + .align 16 + .align 16 +coeff_table: + .long 1553778919 + .long 3213899486 + .long 3534952507 + .long 3215266280 + .long 1646371399 + .long 3214412045 + .long 477218588 + .long 3216798151 + .long 3582521621 + .long 1066628362 + .long 1007461464 + .long 1068473053 + .long 889629714 + .long 1067378449 + .long 1431655765 + .long 1070945621 + .type coeff_table,@object + .size coeff_table,64 + .align 4 +EXP_MSK3: + .long 4294967295 + .long 1048575 + .type EXP_MSK3,@object + .size EXP_MSK3,8 + .align 4 +EXP_MSK2: + .long 0 + .long 3220193280 + .type EXP_MSK2,@object + .size EXP_MSK2,8 + .align 4 +EXP_MASK: + .long 0 + .long 3220176896 + .type EXP_MASK,@object + .size EXP_MASK,8 + .align 4 +SIG_MASK: + .long 0 + .long 1032192 + .type SIG_MASK,@object + .size SIG_MASK,8 + .align 4 +rcp_table: + .long 528611360 + .long 3220144632 + .long 2884679527 + .long 3220082993 + .long 1991868891 + .long 3220024928 + .long 2298714891 + .long 3219970134 + .long 58835168 + .long 3219918343 + .long 3035110223 + .long 3219869313 + .long 1617585086 + .long 3219822831 + .long 2500867033 + .long 3219778702 + .long 4241943008 + .long 3219736752 + .long 258732970 + .long 3219696825 + .long 404232216 + .long 3219658776 + .long 2172167368 + .long 3219622476 + .long 1544257904 + .long 3219587808 + .long 377579543 + .long 3219554664 + .long 1616385542 + .long 3219522945 + .long 813783277 + .long 3219492562 + .long 3940743189 + .long 3219463431 + .long 2689777499 + .long 3219435478 + .long 1700977147 + .long 3219408632 + .long 3169102082 + .long 3219382828 + .long 327235604 + .long 3219358008 + .long 1244336319 + .long 3219334115 + .long 1300311200 + .long 3219311099 + .long 3095471925 + .long 3219288912 + .long 2166487928 + .long 3219267511 + .long 2913108253 + .long 3219246854 + .long 293672978 + .long 3219226904 + .long 288737297 + .long 3219207624 + .long 1810275472 + .long 3219188981 + .long 174592167 + .long 3219170945 + .long 3539053052 + .long 3219153485 + .long 2164392968 + .long 3219136576 + .type rcp_table,@object + .size rcp_table,256 + .align 4 +cbrt_table: + .long 572345495 + .long 1072698681 + .long 1998204467 + .long 1072709382 + .long 3861501553 + .long 1072719872 + .long 2268192434 + .long 1072730162 + .long 2981979308 + .long 1072740260 + .long 270859143 + .long 1072750176 + .long 2958651392 + .long 1072759916 + .long 313113243 + .long 1072769490 + .long 919449400 + .long 1072778903 + .long 2809328903 + .long 1072788162 + .long 2222981587 + .long 1072797274 + .long 2352530781 + .long 1072806244 + .long 594152517 + .long 1072815078 + .long 1555767199 + .long 1072823780 + .long 4282421314 + .long 1072832355 + .long 2355578597 + .long 1072840809 + .long 1162590619 + .long 1072849145 + .long 797864051 + .long 1072857367 + .long 431273680 + .long 1072865479 + .long 2669831148 + .long 1072873484 + .long 733477752 + .long 1072881387 + .long 4280220604 + .long 1072889189 + .long 801961634 + .long 1072896896 + .long 2915370760 + .long 1072904508 + .long 1159613482 + .long 1072912030 + .long 2689944798 + .long 1072919463 + .long 1248687822 + .long 1072926811 + .long 2967951030 + .long 1072934075 + .long 630170432 + .long 1072941259 + .long 3760898254 + .long 1072948363 + .long 0 + .long 1072955392 + .long 2370273294 + .long 1072962345 + .long 1261754802 + .long 1072972640 + .long 546334065 + .long 1072986123 + .long 1054893830 + .long 1072999340 + .long 1571187597 + .long 1073012304 + .long 1107975175 + .long 1073025027 + .long 3606909377 + .long 1073037519 + .long 1113616747 + .long 1073049792 + .long 4154744632 + .long 1073061853 + .long 3358931423 + .long 1073073713 + .long 4060702372 + .long 1073085379 + .long 747576176 + .long 1073096860 + .long 3023138255 + .long 1073108161 + .long 1419988548 + .long 1073119291 + .long 1914185305 + .long 1073130255 + .long 294389948 + .long 1073141060 + .long 3761802570 + .long 1073151710 + .long 978281566 + .long 1073162213 + .long 823148820 + .long 1073172572 + .long 2420954441 + .long 1073182792 + .long 3815449908 + .long 1073192878 + .long 2046058587 + .long 1073202835 + .long 1807524753 + .long 1073212666 + .long 2628681401 + .long 1073222375 + .long 3225667357 + .long 1073231966 + .long 1555307421 + .long 1073241443 + .long 3454043099 + .long 1073250808 + .long 1208137896 + .long 1073260066 + .long 3659916772 + .long 1073269218 + .long 1886261264 + .long 1073278269 + .long 3593647839 + .long 1073287220 + .long 3086012205 + .long 1073296075 + .long 2769796922 + .long 1073304836 + .long 888716057 + .long 1073317807 + .long 2201465623 + .long 1073334794 + .long 164369365 + .long 1073351447 + .long 3462666733 + .long 1073367780 + .long 2773905457 + .long 1073383810 + .long 1342879088 + .long 1073399550 + .long 2543933975 + .long 1073415012 + .long 1684477781 + .long 1073430209 + .long 3532178543 + .long 1073445151 + .long 1147747300 + .long 1073459850 + .long 1928031793 + .long 1073474314 + .long 2079717015 + .long 1073488553 + .long 4016765315 + .long 1073502575 + .long 3670431139 + .long 1073516389 + .long 3549227225 + .long 1073530002 + .long 11637607 + .long 1073543422 + .long 588220169 + .long 1073556654 + .long 2635407503 + .long 1073569705 + .long 2042029317 + .long 1073582582 + .long 1925128962 + .long 1073595290 + .long 4136375664 + .long 1073607834 + .long 759964600 + .long 1073620221 + .long 4257606771 + .long 1073632453 + .long 297278907 + .long 1073644538 + .long 3655053093 + .long 1073656477 + .long 2442253172 + .long 1073668277 + .long 1111876799 + .long 1073679941 + .long 3330973139 + .long 1073691472 + .long 3438879452 + .long 1073702875 + .long 3671565478 + .long 1073714153 + .long 1317849547 + .long 1073725310 + .long 1642364115 + .long 1073736348 + .type cbrt_table,@object + .size cbrt_table,768 + .align 4 +D_table: + .long 4050900474 + .long 1014427190 + .long 1157977860 + .long 1016444461 + .long 1374568199 + .long 1017271387 + .long 2809163288 + .long 1016882676 + .long 3742377377 + .long 1013168191 + .long 3101606597 + .long 1017541672 + .long 65224358 + .long 1017217597 + .long 2691591250 + .long 1017266643 + .long 4020758549 + .long 1017689313 + .long 1316310992 + .long 1018030788 + .long 1031537856 + .long 1014090882 + .long 3261395239 + .long 1016413641 + .long 886424999 + .long 1016313335 + .long 3114776834 + .long 1014195875 + .long 1681120620 + .long 1017825416 + .long 1329600273 + .long 1016625740 + .long 465474623 + .long 1017097119 + .long 4251633980 + .long 1017169077 + .long 1986990133 + .long 1017710645 + .long 752958613 + .long 1017159641 + .long 2216216792 + .long 1018020163 + .long 4282860129 + .long 1015924861 + .long 1557627859 + .long 1016039538 + .long 3889219754 + .long 1018086237 + .long 3684996408 + .long 1017353275 + .long 723532103 + .long 1017717141 + .long 2951149676 + .long 1012528470 + .long 831890937 + .long 1017830553 + .long 1031212645 + .long 1017387331 + .long 2741737450 + .long 1017604974 + .long 2863311531 + .long 1003776682 + .long 4276736099 + .long 1013153088 + .long 4111778382 + .long 1015673686 + .long 1728065769 + .long 1016413986 + .long 2708718031 + .long 1018078833 + .long 1069335005 + .long 1015291224 + .long 700037144 + .long 1016482032 + .long 2904566452 + .long 1017226861 + .long 4074156649 + .long 1017622651 + .long 25019565 + .long 1015245366 + .long 3601952608 + .long 1015771755 + .long 3267129373 + .long 1017904664 + .long 503203103 + .long 1014921629 + .long 2122011730 + .long 1018027866 + .long 3927295461 + .long 1014189456 + .long 2790625147 + .long 1016024251 + .long 1330460186 + .long 1016940346 + .long 4033568463 + .long 1015538390 + .long 3695818227 + .long 1017509621 + .long 257573361 + .long 1017208868 + .long 3227697852 + .long 1017337964 + .long 234118548 + .long 1017169577 + .long 4009025803 + .long 1017278524 + .long 1948343394 + .long 1017749310 + .long 678398162 + .long 1018144239 + .long 3083864863 + .long 1016669086 + .long 2415453452 + .long 1017890370 + .long 175467344 + .long 1017330033 + .long 3197359580 + .long 1010339928 + .long 2071276951 + .long 1015941358 + .long 268372543 + .long 1016737773 + .long 938132959 + .long 1017389108 + .long 1816750559 + .long 1017337448 + .long 4119203749 + .long 1017152174 + .long 2578653878 + .long 1013108497 + .long 2470331096 + .long 1014678606 + .long 123855735 + .long 1016553320 + .long 1265650889 + .long 1014782687 + .long 3414398172 + .long 1017182638 + .long 1040773369 + .long 1016158401 + .long 3483628886 + .long 1016886550 + .long 4140499405 + .long 1016191425 + .long 3893477850 + .long 1016964495 + .long 3935319771 + .long 1009634717 + .long 2978982660 + .long 1015027112 + .long 2452709923 + .long 1017990229 + .long 3190365712 + .long 1015835149 + .long 4237588139 + .long 1015832925 + .long 2610678389 + .long 1017962711 + .long 2127316774 + .long 1017405770 + .long 824267502 + .long 1017959463 + .long 2165924042 + .long 1017912225 + .long 2774007076 + .long 1013257418 + .long 4123916326 + .long 1017582284 + .long 1976417958 + .long 1016959909 + .long 4092806412 + .long 1017711279 + .long 119251817 + .long 1015363631 + .long 3475418768 + .long 1017675415 + .long 1972580503 + .long 1015470684 + .long 815541017 + .long 1017517969 + .long 2429917451 + .long 1017397776 + .long 4062888482 + .long 1016749897 + .long 68284153 + .long 1017925678 + .long 2207779246 + .long 1016320298 + .long 1183466520 + .long 1017408657 + .long 143326427 + .long 1017060403 + .type D_table,@object + .size D_table,768 + .align 4 +SCALE63: + .long 0 + .long 1138753536 + .type SCALE63,@object + .size SCALE63,8 + .align 4 +ZERON: + .long 0 + .long 2147483648 + .type ZERON,@object + .size ZERON,8 + .align 4 +INF: + .long 0 + .long 2146435072 + .type INF,@object + .size INF,8 + .align 4 +NEG_INF: + .long 0 + .long 4293918720 + .type NEG_INF,@object + .size NEG_INF,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cbrtf_gen.S b/external/sgx_libm/intel64/cbrtf_gen.S new file mode 100644 index 0000000000..773a6cb2ea --- /dev/null +++ b/external/sgx_libm/intel64/cbrtf_gen.S @@ -0,0 +1,494 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrtf_gen.c" + .text +..TXTST0: +# -- Begin cbrtf + .text + .align 16,0x90 + .globl cbrtf +cbrtf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cbrtf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movss %xmm0, 8(%rsp) +..B1.2: + movl $8388607, %edx + movd %edx, %xmm5 + movl $-1081999360, %eax + movd %eax, %xmm3 + movl $-1082130432, %eax + movd %eax, %xmm1 + movl $8257536, %edx + movd %edx, %xmm2 + pextrw $1, %xmm0, %ecx + movl %ecx, %eax + andl $124, %ecx + lea rcp_table(%rip), %r8 + movss (%rcx,%r8), %xmm4 + shrl $7, %eax + movl $255, %edx + andl %eax, %edx + movq %rax, %r9 + cmpl $0, %edx + je .L_2TAG_PACKET_0.0.1 + cmpl $255, %edx + je .L_2TAG_PACKET_1.0.1 + andps %xmm0, %xmm2 + andps %xmm5, %xmm0 + orps %xmm2, %xmm3 + orps %xmm0, %xmm1 + movss coeff_table(%rip), %xmm5 + movss 4+coeff_table(%rip), %xmm6 + movl %edx, %eax + addl %eax, %eax + addl %eax, %eax + addl %edx, %eax + movl %eax, %edx + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %edx + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %edx, %eax + movq %r9, %rdx + andq $255, %r9 + subq $1, %r9 + shrl $12, %eax + andl $256, %edx + subq %rax, %r9 + subq %rax, %r9 + subq %rax, %r9 + shlq $7, %r9 + addl $85, %eax + orl %edx, %eax + movd %eax, %xmm7 + addq %r9, %rcx + psllq $23, %xmm7 +.L_2TAG_PACKET_2.0.1: + movss 8+coeff_table(%rip), %xmm2 + movss 12+coeff_table(%rip), %xmm0 + subss %xmm3, %xmm1 + movaps %xmm7, %xmm3 + lea cbrtf_table(%rip), %r8 + mulss (%rcx,%r8), %xmm7 + mulss %xmm4, %xmm1 + lea D_table(%rip), %r8 + mulss (%rcx,%r8), %xmm3 + movss %xmm1, %xmm4 + mulss %xmm1, %xmm5 + mulss %xmm1, %xmm6 + mulss %xmm1, %xmm1 + addss %xmm5, %xmm2 + addss %xmm6, %xmm0 + mulss %xmm1, %xmm2 + mulss %xmm7, %xmm4 + addss %xmm2, %xmm0 + mulss %xmm4, %xmm0 + addss %xmm3, %xmm0 + addss %xmm7, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_0.0.1: + movq %xmm0, %xmm7 + movd %xmm0, %eax + movq %rax, %r9 + shll $9, %eax + movl $23, %ecx + shrq $23, %r9 +.L_2TAG_PACKET_3.0.1: + cmpl $-2147483648, %eax + jae .L_2TAG_PACKET_4.0.1 + shll $1, %eax + addl $1, %edx + loop .L_2TAG_PACKET_3.0.1 + cmpl $0, %eax + je .L_2TAG_PACKET_5.0.1 +.L_2TAG_PACKET_4.0.1: + movl %edx, %ecx + incl %ecx + movd %ecx, %xmm7 + orq %rdx, %r9 + psllq %xmm7, %xmm0 + shrl $24, %eax + andl $124, %eax + lea rcp_table(%rip), %r8 + movsd (%r8,%rax), %xmm4 + movl %eax, %ecx + andps %xmm0, %xmm2 + andps %xmm5, %xmm0 + orps %xmm2, %xmm3 + orps %xmm0, %xmm1 + movss coeff_table(%rip), %xmm5 + movl $1366, %eax + movss 4+coeff_table(%rip), %xmm6 + mull %edx + movq %r9, %rdx + andq $255, %r9 + addq $1, %r9 + shrl $12, %eax + andl $256, %edx + subq %rax, %r9 + subq %rax, %r9 + subq %rax, %r9 + cmpq $0, %r9 + je .L_2TAG_PACKET_6.0.1 + incl %eax + subq $3, %r9 + negq %r9 +.L_2TAG_PACKET_6.0.1: + shlq $7, %r9 + addq %r9, %rcx + movq $85, %r9 + subq %rax, %r9 + orq %r9, %rdx + movd %edx, %xmm7 + psllq $23, %xmm7 + jmp .L_2TAG_PACKET_2.0.1 +.L_2TAG_PACKET_5.0.1: + cmpq $0, %r9 + jne .L_2TAG_PACKET_7.0.1 + xorps %xmm0, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_7.0.1: + movss 4+ZERON(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_1.0.1: + movl 8(%rsp), %eax + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $2139095040, %ecx + ja .L_2TAG_PACKET_8.0.1 + cmpl $2139095040, %eax + jne .L_2TAG_PACKET_9.0.1 + movss INFS(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_9.0.1: + movss NEG_INFS(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_8.0.1: + movss 8(%rsp), %xmm0 + addss %xmm0, %xmm0 + movss %xmm0, (%rsp) +.L_2TAG_PACKET_10.0.1: +..B1.4: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cbrtf,@function + .size cbrtf,.-cbrtf + .data +# -- End cbrtf + .section .rodata, "a" + .align 4 + .align 4 +rcp_table: + .long 3212578753 + .long 3212085645 + .long 3211621124 + .long 3211182772 + .long 3210768440 + .long 3210376206 + .long 3210004347 + .long 3209651317 + .long 3209315720 + .long 3208996296 + .long 3208691905 + .long 3208401508 + .long 3208124163 + .long 3207859009 + .long 3207605259 + .long 3207362194 + .long 3207129151 + .long 3206905525 + .long 3206690755 + .long 3206484326 + .long 3206285761 + .long 3206094618 + .long 3205910490 + .long 3205732998 + .long 3205561788 + .long 3205396533 + .long 3205236929 + .long 3205082689 + .long 3204933547 + .long 3204789256 + .long 3204649583 + .long 3204514308 + .type rcp_table,@object + .size rcp_table,128 + .align 4 +coeff_table: + .long 3173551943 + .long 3185806905 + .long 1031591658 + .long 1051372203 + .type coeff_table,@object + .size coeff_table,16 + .align 4 +cbrtf_table: + .long 1065396681 + .long 1065482291 + .long 1065566215 + .long 1065648532 + .long 1065729317 + .long 1065808640 + .long 1065886565 + .long 1065963152 + .long 1066038457 + .long 1066112533 + .long 1066185428 + .long 1066257188 + .long 1066327857 + .long 1066397474 + .long 1066466079 + .long 1066533708 + .long 1066600394 + .long 1066666169 + .long 1066731064 + .long 1066795108 + .long 1066858329 + .long 1066920751 + .long 1066982401 + .long 1067043301 + .long 1067103474 + .long 1067162941 + .long 1067221722 + .long 1067279837 + .long 1067337305 + .long 1067394143 + .long 1067450368 + .long 1067505996 + .long 1067588354 + .long 1067696217 + .long 1067801953 + .long 1067905666 + .long 1068007450 + .long 1068107390 + .long 1068205570 + .long 1068302063 + .long 1068396942 + .long 1068490271 + .long 1068582113 + .long 1068672525 + .long 1068761562 + .long 1068849275 + .long 1068935712 + .long 1069020919 + .long 1069104937 + .long 1069187809 + .long 1069269572 + .long 1069350263 + .long 1069429915 + .long 1069508563 + .long 1069586236 + .long 1069662966 + .long 1069738778 + .long 1069813702 + .long 1069887762 + .long 1069960982 + .long 1070033387 + .long 1070104998 + .long 1070175837 + .long 1070245925 + .long 1070349689 + .long 1070485588 + .long 1070618808 + .long 1070749478 + .long 1070877717 + .long 1071003634 + .long 1071127332 + .long 1071248907 + .long 1071368446 + .long 1071486034 + .long 1071601747 + .long 1071715659 + .long 1071827839 + .long 1071938350 + .long 1072047254 + .long 1072154608 + .long 1072260465 + .long 1072364876 + .long 1072467891 + .long 1072569555 + .long 1072669911 + .long 1072769001 + .long 1072866863 + .long 1072963536 + .long 1073059054 + .long 1073153452 + .long 1073246762 + .long 1073339014 + .long 1073430238 + .long 1073520462 + .long 1073609714 + .long 1073698019 + .type cbrtf_table,@object + .size cbrtf_table,384 + .align 4 +D_table: + .long 839340838 + .long 867750258 + .long 851786446 + .long 853949398 + .long 864938789 + .long 864102364 + .long 864209792 + .long 865422805 + .long 867593594 + .long 854482593 + .long 848298042 + .long 860064854 + .long 844792593 + .long 870701309 + .long 872023170 + .long 860255342 + .long 849966899 + .long 863561479 + .long 869115319 + .long 871961375 + .long 859537336 + .long 871954398 + .long 863817578 + .long 861687921 + .long 849594757 + .long 816486846 + .long 858183533 + .long 864500406 + .long 850523240 + .long 808125243 + .long 514020693 + .long 861173761 + .long 859000219 + .long 823158129 + .long 871826232 + .long 871183196 + .long 839030530 + .long 867690638 + .long 840440923 + .long 868033274 + .long 855856030 + .long 865094453 + .long 860418487 + .long 866225006 + .long 866458226 + .long 865124659 + .long 864837702 + .long 811742505 + .long 869432099 + .long 864584201 + .long 864183978 + .long 844810573 + .long 869245699 + .long 859556409 + .long 870675446 + .long 814190139 + .long 870686941 + .long 861800510 + .long 855649163 + .long 869347119 + .long 864252033 + .long 867276215 + .long 868189817 + .long 849541095 + .long 866633177 + .long 843967686 + .long 857522493 + .long 862339487 + .long 850054662 + .long 864048556 + .long 868027089 + .long 848093931 + .long 865355299 + .long 848111485 + .long 865557362 + .long 870297525 + .long 863416216 + .long 869675693 + .long 865888071 + .long 825332584 + .long 843309506 + .long 870885636 + .long 869119784 + .long 865466648 + .long 867459244 + .long 861192764 + .long 871247716 + .long 864927982 + .long 869195129 + .long 864849564 + .long 840005936 + .long 852579258 + .long 860852782 + .long 869711141 + .long 862506141 + .long 837959274 + .type D_table,@object + .size D_table,384 + .align 4 +ZERON: + .long 0 + .long 2147483648 + .type ZERON,@object + .size ZERON,8 + .align 4 +INFS: + .long 2139095040 + .type INFS,@object + .size INFS,4 + .align 4 +NEG_INFS: + .long 4286578688 + .type NEG_INFS,@object + .size NEG_INFS,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cbrtl.S b/external/sgx_libm/intel64/cbrtl.S new file mode 100644 index 0000000000..73ebac73a9 --- /dev/null +++ b/external/sgx_libm/intel64/cbrtl.S @@ -0,0 +1,379 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrtl.c" + .text +..TXTST0: +# -- Begin cbrtl + .text + .align 16,0x90 + .globl cbrtl +cbrtl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cbrtl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %r8b, %r8b +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 56(%rsp), %ecx + movl %ecx, %edi + andl $32767, %edi + movzwl 34(%rsp), %r9d + cmpl $32767, %edi + je ..B1.20 +..B1.4: + movb 57(%rsp), %al + movl %r9d, %edx + andb $-128, %al + andl $768, %edx + shrb $7, %al + xorl %esi, %esi + movzbl %al, %eax + cmpl $768, %edx + je ..B1.8 +..B1.5: + orl $-64768, %r9d + movw %r9w, 32(%rsp) +..B1.6: + fldcw 32(%rsp) +..B1.7: + movzwl 56(%rsp), %ecx + movl %ecx, %edi + movb $1, %r8b + andl $32767, %edi +..B1.8: + testl %edi, %edi + jne ..B1.14 +..B1.9: + cmpq $0, 48(%rsp) + jne ..B1.13 +..B1.10: + lea _zeros(%rip), %rdx + testb %r8b, %r8b + movsd (%rdx,%rax,8), %xmm0 + je ..B1.12 +..B1.11: + fldcw 34(%rsp) +..B1.12: + movsd %xmm0, (%rsp) + fldl (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.13: + fldt 48(%rsp) + movl $-25, %esi + lea _TWO_75(%rip), %rdx + fmull (%rdx) + fstpt 48(%rsp) + movzwl 56(%rsp), %ecx + movl %ecx, %edi + andl $32767, %edi +..B1.14: + fldt .L_2il0floatpacket.0(%rip) + lea ones(%rip), %r9 + andl $-32768, %ecx + orl $-49153, %ecx + movw %cx, 56(%rsp) + fldl (%r9,%rax,8) + lea 96+_P(%rip), %r9 + movl 52(%rsp), %ecx + shrl $23, %ecx + movzbl %cl, %eax + lea _TWO_32H(%rip), %rcx + movq __libm_rcp_table_256@GOTPCREL(%rip), %r11 + imull $21845, %edi, %edx + fstpt 16(%rsp) + fldt 16(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + flds (%r11,%rax,4) + addl $21845, %edx + fld %st(0) + lea 32+_P(%rip), %r11 + fldl (%rcx) + lea 80+_P(%rip), %rcx + fld %st(0) + shrl $16, %edx + fadd %st(4), %st + shlq $4, %rax + lea (%rdx,%rdx), %r10d + subl %r10d, %edi + lea 64+_P(%rip), %r10 + fsubp %st, %st(1) + fmul %st, %st(1) + lea 10922(%rsi,%rdx), %esi + fxch %st(1) + fsub %st(4), %st + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%r9) + lea 48+_P(%rip), %r9 + fmul %st(2), %st + fldt (%r10) + lea 16+_P(%rip), %r10 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + lea _P(%rip), %r11 + faddp %st, %st(1) + fmul %st(2), %st + fmul %st(1), %st + fldt (%rcx) + fmul %st(3), %st + fldt (%r9) + movzwl 24(%rsp), %ecx + faddp %st, %st(1) + fmul %st(3), %st + andl $-32768, %ecx + fldt (%r10) + orl %esi, %ecx + movw %cx, 24(%rsp) + subl %edx, %edi + movq __libm_cbrtl_table_256@GOTPCREL(%rip), %rdx + faddp %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt (%r11) + fmulp %st, %st(1) + faddp %st, %st(1) + fadd %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fldl 8(%rdx,%rax) + fldl (%rdx,%rax) + fldt 16(%rsp) + jne ..B1.16 +..B1.15: + fldt (%rsp) + fmulp %st, %st(3) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.17 +..B1.16: + fldt (%rsp) + lea SH(%rip), %rax + movslq %edi, %rdi + fxch %st(3) + fmull -8(%rax,%rdi,8) + fldl 24(%rax,%rdi,8) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(1) + fmull 8(%rax,%rdi,8) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.17: + testb %r8b, %r8b + je ..B1.19 +..B1.18: + fldcw 34(%rsp) +..B1.19: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.20: + movl %r9d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.26 +..B1.21: + orl $-64768, %r9d + movw %r9w, 32(%rsp) +..B1.22: + fldcw 32(%rsp) +..B1.23: + fldt 48(%rsp) + fstpt (%rsp) +..B1.24: + fldcw 34(%rsp) +..B1.25: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.26: + fldt 48(%rsp) + fstpt (%rsp) + jmp ..B1.25 + .align 16,0x90 + .cfi_endproc + .type cbrtl,@function + .size cbrtl,.-cbrtl + .data +# -- End cbrtl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +SH: + .long 0xf98d728b,0x3ff428a2 + .long 0xa53d6e3d,0x3ff965fe + .long 0xf8000000,0x3ff428a2 + .long 0xa4000000,0x3ff965fe + .long 0xae223ddb,0x3e38d728 + .long 0xc82b059a,0x3e33d6e3 + .type SH,@object + .size SH,48 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_P: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58320 + .word 36408 + .word 14563 + .word 58254 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 50474 + .word 25890 + .word 59872 + .word 64726 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 45217 + .word 37017 + .word 18069 + .word 43151 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 45059 + .word 7616 + .word 35240 + .word 63288 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 54522 + .word 17175 + .word 48475 + .word 49224 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 568 + .word 55426 + .word 44619 + .word 39848 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,112 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cbrtl_table.S b/external/sgx_libm/intel64/cbrtl_table.S new file mode 100644 index 0000000000..a5fa423338 --- /dev/null +++ b/external/sgx_libm/intel64/cbrtl_table.S @@ -0,0 +1,559 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cbrtl_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_cbrtl_table_256 +__libm_cbrtl_table_256: + .long 0x8e000000,0x3ff002ab + .long 0x20d8688c,0x3e2230dd + .long 0x08000000,0x3ff00808 + .long 0xeff25f12,0x3e3610f3 + .long 0xba000000,0x3ff00d6b + .long 0x3efe3543,0xbe0b4bfa + .long 0xb2000000,0x3ff012d6 + .long 0x2c9e7759,0xbe32d173 + .long 0x4e000000,0x3ff0179a + .long 0x013f2daf,0x3e1eca95 + .long 0x1a000000,0x3ff01d13 + .long 0x1a1a641f,0xbe35afd8 + .long 0x5a000000,0x3ff02293 + .long 0xa40f870c,0x3e3acf85 + .long 0xc6000000,0x3ff02769 + .long 0x8b30b2ed,0xbe1bd4a4 + .long 0x3c000000,0x3ff02cf8 + .long 0xc2b35d57,0xbe10fe10 + .long 0x2e000000,0x3ff031db + .long 0x9aefd6bc,0x3e1dc088 + .long 0x1a000000,0x3ff03778 + .long 0x26cf8b86,0xbe3983d8 + .long 0xcc000000,0x3ff03c67 + .long 0xa0938ea4,0x3e33f7ce + .long 0x8a000000,0x3ff0415d + .long 0x1f4527e6,0x3e1271e1 + .long 0x1e000000,0x3ff04710 + .long 0xe014332a,0x3e2e39c2 + .long 0xf4000000,0x3ff04c12 + .long 0x4801f107,0x3e28aa39 + .long 0xfc000000,0x3ff0511b + .long 0x5e2d9f07,0x3dbd36bd + .long 0x42000000,0x3ff0562b + .long 0xc47ab24f,0x3df8a6e2 + .long 0xd4000000,0x3ff05b40 + .long 0x24da1d13,0x3e249ec6 + .long 0xc2000000,0x3ff0605c + .long 0x31b189b7,0xbe227295 + .long 0x16000000,0x3ff0657f + .long 0x7872e1cd,0x3e17f761 + .long 0xe2000000,0x3ff06aa7 + .long 0xc4a6c979,0xbe18ff8e + .long 0x32000000,0x3ff06fd7 + .long 0x37586fc9,0xbe22bc1f + .long 0x1e000000,0x3ff0744e + .long 0xda6466ae,0x3e213213 + .long 0xb0000000,0x3ff07989 + .long 0xd1b04779,0xbe181829 + .long 0xf0000000,0x3ff07ecb + .long 0x52cf55c8,0xbe2d5de3 + .long 0xea000000,0x3ff08414 + .long 0xa790ab31,0x3e3e5ef6 + .long 0x0a000000,0x3ff088a2 + .long 0x7bee6b1f,0xbe33c01d + .long 0xb2000000,0x3ff08df7 + .long 0xed26e53e,0x3e0b930b + .long 0xc4000000,0x3ff0928f + .long 0x35afee34,0xbe2f72c3 + .long 0x4e000000,0x3ff097f2 + .long 0x1166e9a4,0x3e256094 + .long 0x82000000,0x3ff09c95 + .long 0x5ae9d19c,0xbe01eed4 + .long 0xe8000000,0x3ff0a13d + .long 0x82f9b502,0x3e22e1bc + .long 0xac000000,0x3ff0a6b3 + .long 0xdecb71aa,0xbe13744b + .long 0x7c000000,0x3ff0ab67 + .long 0x79520489,0xbe34918f + .long 0x9e000000,0x3ff0b020 + .long 0xf330a139,0x3df882be + .long 0x20000000,0x3ff0b4df + .long 0xc3236255,0x3e1c8694 + .long 0xe6000000,0x3ff0ba6e + .long 0x119c7384,0xbdd954af + .long 0x30000000,0x3ff0bf39 + .long 0x17946a4f,0x3e17e600 + .long 0xfc000000,0x3ff0c408 + .long 0xa96efefe,0x3dfcfd4a + .long 0x54000000,0x3ff0c8de + .long 0xc29018c1,0x3e137bfa + .long 0x44000000,0x3ff0cdb9 + .long 0x6b55ea13,0x3e075409 + .long 0xd8000000,0x3ff0d299 + .long 0x17222364,0xbe2c80ba + .long 0x1a000000,0x3ff0d780 + .long 0xf030bcdb,0xbe36c2d9 + .long 0xae000000,0x3ff0db99 + .long 0x583eb4fd,0x3e23f39e + .long 0x7a000000,0x3ff0e08a + .long 0x1bc25b4a,0xbe2ee94c + .long 0x14000000,0x3ff0e581 + .long 0x2f4f4e2c,0xbe2785bf + .long 0x88000000,0x3ff0ea7d + .long 0xd8bcbdfc,0x3e3525a2 + .long 0xe6000000,0x3ff0ef7f + .long 0xed67b448,0x3e359433 + .long 0x16000000,0x3ff0f3b1 + .long 0xc931fbd5,0x3e2bf870 + .long 0x6a000000,0x3ff0f8be + .long 0xe78cbbad,0xbe32480c + .long 0xca000000,0x3ff0fcf8 + .long 0x795e6dd9,0x3e1f7d67 + .long 0x3a000000,0x3ff10211 + .long 0xfbf1714f,0x3e239cff + .long 0xce000000,0x3ff1072f + .long 0x55d6f69a,0xbe272643 + .long 0xac000000,0x3ff10b78 + .long 0xfdfa2d3b,0xbe286878 + .long 0xdc000000,0x3ff10fc5 + .long 0xd49627b5,0x3e1c95db + .long 0x0c000000,0x3ff114f5 + .long 0xf6a23fbe,0xbe2e06fe + .long 0xda000000,0x3ff1194b + .long 0x8f075abc,0x3e34ceb2 + .long 0xac000000,0x3ff11e86 + .long 0x90dc17c3,0x3e066bd5 + .long 0x40000000,0x3ff122e7 + .long 0xc04b5d49,0x3e359eb9 + .long 0x54000000,0x3ff1274c + .long 0xaf65cf99,0x3df316d4 + .long 0xec000000,0x3ff12bb5 + .long 0x7163f782,0x3e1b91b5 + .long 0x74000000,0x3ff13107 + .long 0xb1d8a38e,0xbe171e82 + .long 0x1c000000,0x3ff1357b + .long 0x142a679f,0xbe1645ad + .long 0x64000000,0x3ff139f3 + .long 0x03011ac3,0xbe119734 + .long 0x54000000,0x3ff13e70 + .long 0xceefd26a,0x3e12c753 + .long 0xf6000000,0x3ff142f1 + .long 0x1ae3077b,0xbdff336e + .long 0x50000000,0x3ff14778 + .long 0xa313efdd,0x3e3167c3 + .long 0x6e000000,0x3ff14c03 + .long 0xe0d315a6,0x3e23d347 + .long 0x56000000,0x3ff15093 + .long 0x8ec79515,0x3e34284e + .long 0x14000000,0x3ff15528 + .long 0x6ca0e852,0xbdfd2648 + .long 0xae000000,0x3ff159c1 + .long 0x33a7b5b1,0xbe21074d + .long 0x2c000000,0x3ff15e60 + .long 0x6aaf8c8a,0x3e311566 + .long 0x9c000000,0x3ff16303 + .long 0xdfa56cef,0xbe04190c + .long 0x02000000,0x3ff167ac + .long 0x96f8f747,0x3e30bf5f + .long 0x6c000000,0x3ff16c59 + .long 0x67e1e977,0x3dddd97d + .long 0xfc000000,0x3ff1701a + .long 0xf643cd8e,0xbe32877d + .long 0x80000000,0x3ff174d1 + .long 0x618d0ab4,0xbe318a71 + .long 0x1e000000,0x3ff1798d + .long 0xe66a5be3,0x3e373f3e + .long 0xe6000000,0x3ff17e4d + .long 0xca1da90a,0x3e0c534f + .long 0x0e000000,0x3ff1821f + .long 0xe06a8431,0xbe0ec5e5 + .long 0x32000000,0x3ff186e9 + .long 0xbb5373b7,0x3e06cc6a + .long 0x98000000,0x3ff18bb8 + .long 0x80c817c3,0x3e23ddc1 + .long 0x88000000,0x3ff18f95 + .long 0x70817aed,0xbe25cef4 + .long 0x7e000000,0x3ff1946e + .long 0x71612988,0x3e0b7bf2 + .long 0x22000000,0x3ff19853 + .long 0xdad7b32a,0xbe3008d5 + .long 0xc8000000,0x3ff19d35 + .long 0x558f59ee,0x3e3d2925 + .long 0x3c000000,0x3ff1a122 + .long 0x97916e24,0xbe112012 + .long 0xba000000,0x3ff1a60e + .long 0xf6235d3b,0xbe361be1 + .long 0x14000000,0x3ff1aa03 + .long 0xefaa3b2e,0x3e33a9bc + .long 0x8a000000,0x3ff1aef9 + .long 0x95d61bf1,0xbe3045d7 + .long 0xec000000,0x3ff1b2f5 + .long 0xe5b6bd1c,0x3e1a939c + .long 0xea000000,0x3ff1b6f5 + .long 0x00756ed3,0x3e118b3c + .long 0x02000000,0x3ff1bbfb + .long 0x34057364,0xbe20e5cf + .long 0x30000000,0x3ff1c003 + .long 0x701907b3,0xbe0e1837 + .long 0x0c000000,0x3ff1c40f + .long 0x7c6221b9,0xbe282207 + .long 0x9a000000,0x3ff1c81e + .long 0x71d8c073,0xbe09f360 + .long 0x4a000000,0x3ff1cd37 + .long 0x436616b2,0xbe3261a0 + .long 0x40000000,0x3ff1d14f + .long 0xc7c5e4df,0x3df7af5c + .long 0xfe000000,0x3ff1d56a + .long 0x5ae36062,0xbdfc61a1 + .long 0x88000000,0x3ff1d98a + .long 0xed667c98,0x3e167fd8 + .long 0xe6000000,0x3ff1ddad + .long 0xa010e825,0xbe16ada9 + .long 0x1c000000,0x3ff1e1d5 + .long 0x012f4beb,0xbdbb777c + .long 0x92000000,0x3ff1e70b + .long 0xe05d5c18,0x3e275a5a + .long 0x88000000,0x3ff1eb3b + .long 0x87963143,0x3e1f6ec9 + .long 0x6c000000,0x3ff1ef6f + .long 0xc77f5502,0xbdf400a5 + .long 0x44000000,0x3ff1f3a7 + .long 0x83209a84,0xbe2057a6 + .long 0x14000000,0x3ff1f7e3 + .long 0xcdb4bd2e,0x3e3b8696 + .long 0xea000000,0x3ff1fc22 + .long 0x7dac9b38,0xbe29872a + .long 0xc4000000,0x3ff20066 + .long 0x7e34701c,0x3e22a9a1 + .long 0xae000000,0x3ff204ae + .long 0xae177d59,0x3e2257cd + .long 0x4c000000,0x3ff207e7 + .long 0x6fe6d0dd,0xbe119fb7 + .long 0x60000000,0x3ff20c36 + .long 0x22ab7e20,0xbe18a6a1 + .long 0x94000000,0x3ff21089 + .long 0xca9c3288,0x3e2c8440 + .long 0xf2000000,0x3ff214e0 + .long 0x8575ebf1,0x3e200f9a + .long 0x80000000,0x3ff2193c + .long 0x219c164a,0xbe2140a7 + .long 0x44000000,0x3ff21d9c + .long 0x2238e180,0xbe326ebd + .long 0x44000000,0x3ff22200 + .long 0x0f5fa626,0xbe084ae9 + .long 0x10000000,0x3ff2254e + .long 0x20e924cc,0x3e34737d + .long 0x90000000,0x3ff229b9 + .long 0x7241c459,0xbe233bae + .long 0x60000000,0x3ff22e29 + .long 0xecaa31e6,0xbe2cc059 + .long 0x14000000,0x3ff23180 + .long 0x7a5a0dea,0x3e2bcde5 + .long 0x84000000,0x3ff235f7 + .long 0x52b90575,0x3e333da0 + .long 0x5a000000,0x3ff23a73 + .long 0x1b60c92e,0x3e3a7d2b + .long 0x24000000,0x3ff23dd3 + .long 0xb235ec84,0x3df512e9 + .long 0xc0000000,0x3ff24256 + .long 0x1f3855f6,0xbe1a9d64 + .long 0xd6000000,0x3ff246de + .long 0xfe758c34,0x3e12b491 + .long 0xde000000,0x3ff24a47 + .long 0x607a2edb,0xbe320de4 + .long 0xde000000,0x3ff24ed7 + .long 0xbc58ecd4,0x3dd8f375 + .long 0xde000000,0x3ff25246 + .long 0xda99c7ed,0xbe1ee42e + .long 0xe2000000,0x3ff256de + .long 0x88f4f655,0xbe220405 + .long 0xec000000,0x3ff25a53 + .long 0xc2b1fe7f,0x3e0eec7d + .long 0x0c000000,0x3ff25ef4 + .long 0xb6841168,0xbe1523a2 + .long 0x34000000,0x3ff2626f + .long 0x7056af50,0x3e200ef9 + .long 0x8a000000,0x3ff26717 + .long 0x8197860c,0xbe3643a3 + .long 0xe2000000,0x3ff26a98 + .long 0x52183874,0x3e204b1a + .long 0x84000000,0x3ff26f49 + .long 0x89899f96,0x3e2ce41f + .long 0x22000000,0x3ff272d1 + .long 0x2eba11d7,0x3e33edcf + .long 0x2e000000,0x3ff2778a + .long 0x9b69a0ac,0xbdd15cbf + .long 0x26000000,0x3ff27b18 + .long 0x4c9cfc18,0xbe384c83 + .long 0xd8000000,0x3ff27ea8 + .long 0x00ebd8b6,0x3e32abcc + .long 0x16000000,0x3ff2836e + .long 0xf0c27bf5,0xbe334f0d + .long 0x3e000000,0x3ff28705 + .long 0x2c84c19b,0x3e19ba08 + .long 0x34000000,0x3ff28a9f + .long 0x765ba98f,0xbe351348 + .long 0xd6000000,0x3ff28f70 + .long 0x0bb50259,0x3e25fd61 + .long 0x5c000000,0x3ff29311 + .long 0x1f0ba391,0x3e36468e + .long 0xbc000000,0x3ff296b4 + .long 0x5eb0d555,0xbe1b4b50 + .long 0xf4000000,0x3ff29a5a + .long 0x1684aafd,0x3e322e1b + .long 0x10000000,0x3ff29f3d + .long 0x7f3902f7,0xbe1143a0 + .long 0x04000000,0x3ff2a2ea + .long 0x9d87f711,0xbe296bf0 + .long 0xe0000000,0x3ff2a699 + .long 0xd317cd41,0xbe267680 + .long 0xa8000000,0x3ff2aa4c + .long 0x895632cb,0x3de71246 + .long 0x60000000,0x3ff2ae02 + .long 0x70ae3e69,0x3e383f37 + .long 0x48000000,0x3ff2b2f9 + .long 0x183dd905,0x3e019525 + .long 0xee000000,0x3ff2b6b5 + .long 0xb11ed34f,0xbde2956c + .long 0x92000000,0x3ff2ba75 + .long 0xebcee2d4,0x3e139d57 + .long 0x3a000000,0x3ff2be38 + .long 0x25efe1d2,0xbe24080b + .long 0xe8000000,0x3ff2c1fd + .long 0xca843d11,0xbe22f3d1 + .long 0xa0000000,0x3ff2c5c6 + .long 0x27157d0b,0x3e25d6d0 + .long 0x6a000000,0x3ff2c992 + .long 0x47c03cbd,0xbe1f901f + .long 0x46000000,0x3ff2cd61 + .long 0xc7d41505,0x3e0c9c6b + .long 0x3a000000,0x3ff2d133 + .long 0x4c9cbf49,0x3e335b1a + .long 0x4e000000,0x3ff2d508 + .long 0xf0d67754,0xbe31f5cc + .long 0x80000000,0x3ff2d8e0 + .long 0x08d6ec2a,0xbe14dddd + .long 0xd8000000,0x3ff2dcbb + .long 0xd1a31600,0x3df4f684 + .long 0x5a000000,0x3ff2e09a + .long 0xe7cb28ec,0x3e23d67d + .long 0x0c000000,0x3ff2e47c + .long 0x64fad19f,0xbe0416e4 + .long 0xf0000000,0x3ff2e860 + .long 0xc1845328,0x3e15f191 + .long 0x0e000000,0x3ff2ec49 + .long 0x0e8212a2,0xbe3407e4 + .long 0x66000000,0x3ff2f034 + .long 0xa6af14fb,0xbe119cdf + .long 0x00000000,0x3ff2f423 + .long 0xdd2ff4b2,0xbdd785b8 + .long 0xe0000000,0x3ff2f814 + .long 0x3c8bc168,0x3e0f9d26 + .long 0x0c000000,0x3ff2fc0a + .long 0x7f285f7f,0xbe25e721 + .long 0x54000000,0x3ff2feaf + .long 0xe4707431,0xbde3d3dc + .long 0x06000000,0x3ff302aa + .long 0x54e59df9,0x3e1b2c8a + .long 0x12000000,0x3ff306a8 + .long 0x5bf8bf35,0xbe35f560 + .long 0x78000000,0x3ff30aa9 + .long 0x1bf7ce44,0xbe201d62 + .long 0x40000000,0x3ff30eae + .long 0x268d3880,0xbda201ac + .long 0x6e000000,0x3ff312b6 + .long 0x78463451,0x3e323ba0 + .long 0x74000000,0x3ff31568 + .long 0x431ff6b5,0x3e27f197 + .long 0x5c000000,0x3ff31976 + .long 0x1d86063e,0xbe3cd285 + .long 0xb4000000,0x3ff31d87 + .long 0xde58cb2b,0xbe038490 + .long 0x86000000,0x3ff3219c + .long 0x0d0ecee4,0x3e2b6d7a + .long 0x04000000,0x3ff32457 + .long 0x67a045ac,0x3e081609 + .long 0xae000000,0x3ff32871 + .long 0x218aae81,0xbe2e422a + .long 0xde000000,0x3ff32c8f + .long 0x77d29102,0xbe27b381 + .long 0xa0000000,0x3ff32f50 + .long 0x1b3eff6b,0x3e21691f + .long 0xbe000000,0x3ff33374 + .long 0xd026a2c6,0x3e04f8ad + .long 0x72000000,0x3ff3379c + .long 0x4d48535f,0xbe22ae68 + .long 0x94000000,0x3ff33a63 + .long 0x1f2825ca,0x3df10fe6 + .long 0x4c000000,0x3ff33e91 + .long 0x0279faec,0x3e2a71d3 + .long 0xaa000000,0x3ff342c2 + .long 0x78d2f376,0xbe04bba3 + .long 0x46000000,0x3ff34590 + .long 0x998a41e9,0xbe03e672 + .long 0xc0000000,0x3ff349c7 + .long 0x36ef8407,0x3e3019b2 + .long 0xee000000,0x3ff34e02 + .long 0x645bac29,0x3e35fca4 + .long 0x20000000,0x3ff350d7 + .long 0x07bfe20f,0xbe25ac45 + .long 0x86000000,0x3ff35518 + .long 0x5aa1ebf5,0xbe2e6547 + .long 0xe0000000,0x3ff357f0 + .long 0xee89ceb5,0xbe287b40 + .long 0x8c000000,0x3ff35c38 + .long 0xa4e8d2ef,0x3e17e02f + .long 0x1c000000,0x3ff35f15 + .long 0xd982cb35,0xbe1b64a3 + .long 0x22000000,0x3ff36363 + .long 0x51a0e2b8,0xbe398839 + .long 0xfc000000,0x3ff367b4 + .long 0x5db6b242,0xbe243ecf + .long 0x5c000000,0x3ff36a98 + .long 0x04aa635d,0x3e2322a4 + .long 0xaa000000,0x3ff36ef0 + .long 0xdffe6c15,0xbe09399e + .long 0x5e000000,0x3ff371d8 + .long 0x25a11d1c,0xbe330e55 + .long 0xce000000,0x3ff374c1 + .long 0x3129afdf,0xbe268d7b + .long 0x3e000000,0x3ff37923 + .long 0xb97189dc,0xbe26657a + .long 0x10000000,0x3ff37c11 + .long 0xea29a16b,0xbe1fb083 + .long 0x1c000000,0x3ff38079 + .long 0x95fa7d47,0xbe340007 + .long 0x5a000000,0x3ff3836b + .long 0x5dc9ac54,0x3e10d40e + .long 0x12000000,0x3ff387da + .long 0x5012ad99,0x3e10b74e + .long 0xca000000,0x3ff38ad0 + .long 0xf7bd2128,0x3e2b0108 + .long 0x40000000,0x3ff38f46 + .long 0x9cc0ea9d,0x3e35e485 + .long 0x7e000000,0x3ff39241 + .long 0x770980a5,0x3e2ea300 + .long 0x90000000,0x3ff3953e + .long 0xd4c7a782,0xbe344ce9 + .long 0x96000000,0x3ff399bd + .long 0x940f9584,0xbe33e2fe + .long 0x3a000000,0x3ff39cbf + .long 0x24087e1a,0x3e2194f5 + .long 0xba000000,0x3ff39fc2 + .long 0x89c83cca,0xbe231d00 + .long 0x72000000,0x3ff3a44b + .long 0x3f2ced31,0x3e307ed8 + .long 0x98000000,0x3ff3a753 + .long 0x3dad14f7,0x3e34644c + .long 0xa0000000,0x3ff3aa5d + .long 0x44bf6650,0xbe198a0f + .long 0x32000000,0x3ff3aef0 + .long 0x83ce161a,0xbe13523e + .long 0xf2000000,0x3ff3b1fe + .long 0x3e4fb0ba,0xbe2b016e + .long 0x98000000,0x3ff3b50f + .long 0x5a266eb9,0xbe00c90d + .long 0x28000000,0x3ff3b9ac + .long 0x5d6435a9,0x3df6946b + .long 0x9a000000,0x3ff3bcc1 + .long 0xb51ea777,0x3deb71b8 + .long 0xfa000000,0x3ff3bfd8 + .long 0xddbd1e72,0x3e23310e + .long 0x4c000000,0x3ff3c2f2 + .long 0x3b61a362,0xbe036033 + .long 0xee000000,0x3ff3c79b + .long 0xfc551ad6,0xbe125411 + .long 0x22000000,0x3ff3caba + .long 0xf4f97f1b,0x3df6c6c6 + .long 0x4e000000,0x3ff3cdda + .long 0x34b9c5a5,0x3e265154 + .long 0x76000000,0x3ff3d0fc + .long 0x63686af4,0xbe11e3d1 + .long 0x6a000000,0x3ff3d5b3 + .long 0x41549461,0x3e22cde8 + .long 0x8e000000,0x3ff3d8da + .long 0x77ad6645,0xbe270a08 + .long 0xb2000000,0x3ff3dc03 + .long 0x15410840,0x3e008be3 + .long 0xdc000000,0x3ff3df2e + .long 0xcbeff11b,0xbe23e35d + .long 0x0c000000,0x3ff3e25c + .long 0x4f6d956b,0xbe26e298 + .long 0x44000000,0x3ff3e58b + .long 0xccfac644,0x3dfe9b4c + .long 0xee000000,0x3ff3ea55 + .long 0x67939d69,0x3e31da2e + .long 0x48000000,0x3ff3ed8a + .long 0x801a7764,0x3e1351ce + .long 0xb4000000,0x3ff3f0c0 + .long 0x501a20c7,0xbe3857a0 + .long 0x30000000,0x3ff3f3f9 + .long 0x57940f51,0xbdd234a1 + .long 0xc4000000,0x3ff3f733 + .long 0x3f2233b4,0xbe2ac2d6 + .long 0x6e000000,0x3ff3fa70 + .long 0xedca8a34,0x3e18e528 + .long 0x34000000,0x3ff3fdaf + .long 0x08b5b935,0x3de3efe5 + .long 0x16000000,0x3ff400f0 + .long 0x3ba01202,0x3e204ec9 + .long 0x64000000,0x3ff405d5 + .long 0x619a3fdd,0x3e3888e9 + .long 0x9c000000,0x3ff4091b + .long 0x5d7bbc67,0xbe35c660 + .long 0xf4000000,0x3ff40c63 + .long 0x371a5b37,0x3e312962 + .long 0x78000000,0x3ff40fae + .long 0xfd4427e8,0xbe266865 + .long 0x24000000,0x3ff412fb + .long 0xe4fe1e06,0xbe095508 + .long 0xfe000000,0x3ff41649 + .long 0x7f425eed,0xbe2d87f6 + .long 0x04000000,0x3ff4199b + .long 0xed161ccb,0x3e3a37a5 + .long 0x40000000,0x3ff41cee + .long 0xf32e9c13,0x3dd0ac84 + .long 0xb0000000,0x3ff42043 + .long 0x6f5637aa,0xbe33e54f + .long 0x56000000,0x3ff4239b + .long 0xb5063313,0xbe393f2e + .long 0x34000000,0x3ff426f5 + .long 0xbfa6486b,0xbe1a1603 + .type __libm_cbrtl_table_256,@object + .size __libm_cbrtl_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/ccos.S b/external/sgx_libm/intel64/ccos.S new file mode 100644 index 0000000000..ad95ef6f5c --- /dev/null +++ b/external/sgx_libm/intel64/ccos.S @@ -0,0 +1,147 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccos.c" + .text +..TXTST0: +# -- Begin ccos + .text + .align 16,0x90 + .globl ccos +ccos: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ccos.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movsd %xmm1, 24(%rsp) + movzwl 30(%rsp), %eax + andl $32752, %eax + movsd %xmm0, 16(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.5 +..B1.3: + testl $1048575, 28(%rsp) + jne ..B1.7 +..B1.4: + cmpl $0, 24(%rsp) + jne ..B1.7 +..B1.5: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.6: + movb 31(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm1 + movhpd 8(%rsp), %xmm1 +..B1.7: + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + call ccosh@PLT +..B1.10: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ccos,@function + .size ccos,.-ccos + .data +# -- End ccos + .text +# -- Begin ccosf + .text + .align 16,0x90 + .globl ccosf +ccosf: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_ccosf.6: +..L7: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) + movzwl 14(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.4 +..B2.3: + testl $8388607, 12(%rsp) + jne ..B2.6 +..B2.4: + movsd %xmm0, (%rsp) +..B2.5: + movb 15(%rsp), %al + notb %al + movb 3(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 3(%rsp) + movsd (%rsp), %xmm0 +..B2.6: + call ccoshf@PLT +..B2.9: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ccosf,@function + .size ccosf,.-ccosf + .data +# -- End ccosf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ccosh.S b/external/sgx_libm/intel64/ccosh.S new file mode 100644 index 0000000000..1cede1de9a --- /dev/null +++ b/external/sgx_libm/intel64/ccosh.S @@ -0,0 +1,566 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccosh.c" + .text +..TXTST0: +# -- Begin ccoshf + .text + .align 16,0x90 + .globl ccoshf +ccoshf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ccoshf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_ccoshf.4: + call ccosh@PLT +..___tag_value_ccoshf.5: +..B1.10: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + movsd %xmm0, 4(%rsp) + movzwl 6(%rsp), %eax + testl $32640, %eax + jne ..B1.4 +..B1.3: + testl $8388607, 4(%rsp) + jne ..B1.6 +..B1.4: + movzwl 10(%rsp), %eax + testl $32640, %eax + jne ..B1.7 +..B1.5: + testl $8388607, 8(%rsp) + je ..B1.7 +..B1.6: + movl $8388608, (%rsp) + movss (%rsp), %xmm1 + movss (%rsp), %xmm0 + mulss %xmm0, %xmm1 + movsd 4(%rsp), %xmm0 + movss %xmm1, (%rsp) +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ccoshf,@function + .size ccoshf,.-ccoshf + .data +# -- End ccoshf + .text +# -- Begin ccosh + .text + .align 16,0x90 + .globl ccosh +ccosh: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_ccosh.8: +..L9: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %rbp + .cfi_def_cfa_offset 32 + .cfi_offset 6, -32 + movq %fs:40, %rax + subq $112, %rsp + .cfi_def_cfa_offset 144 + movsd %xmm0, 48(%rsp) + xorq %rsp, %rax + movzwl 54(%rsp), %r12d + andl $32752, %r12d + shrl $4, %r12d + movsd %xmm1, 56(%rsp) + cmpl $2047, %r12d + movq %rax, 96(%rsp) + jge ..B2.23 +..B2.2: + testl %r12d, %r12d + jle ..B2.46 +..B2.3: + movzwl 62(%rsp), %ebp + andl $32752, %ebp + shrl $4, %ebp + cmpl $2047, %ebp + jge ..B2.24 +..B2.4: + testl %ebp, %ebp + jle ..B2.44 +..B2.5: + cmpl $1034, %r12d + jl ..B2.11 +..B2.6: + lea _CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 24(%rsp) + movsd 56(%rsp), %xmm0 + movsd %xmm0, 16(%rsp) + call __libm_sse2_sincos@PLT +..B2.59: + movaps %xmm0, %xmm2 + testl %ebp, %ebp + movsd 24(%rsp), %xmm0 + mulsd %xmm0, %xmm1 + mulsd 48(%rsp), %xmm0 + movsd %xmm0, 24(%rsp) + movsd %xmm1, (%rsp) + movsd %xmm0, 8(%rsp) + jle ..B2.8 +..B2.7: + mulsd %xmm2, %xmm0 + movsd %xmm0, 24(%rsp) + jmp ..B2.9 +..B2.8: + movsd 8(%rsp), %xmm0 + mulsd 16(%rsp), %xmm0 + movsd %xmm0, 24(%rsp) +..B2.9: + movsd %xmm0, 8(%rsp) + movq 96(%rsp), %rax + xorq %rsp, %rax + movsd (%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.43 +..B2.10: + movsd 24(%rsp), %xmm1 + addq $112, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 6, -32 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B2.11: + movsd 48(%rsp), %xmm0 + lea 64(%rsp), %rdi +..___tag_value_ccosh.28: + call __libm_cosh_k64@PLT +..___tag_value_ccosh.29: +..B2.60: + movl %eax, %r13d +..B2.12: + movsd 64(%rsp), %xmm0 + movsd 72(%rsp), %xmm4 + movaps %xmm0, %xmm5 + movsd .L_2il0floatpacket.13(%rip), %xmm3 + addsd %xmm4, %xmm5 + mulsd %xmm5, %xmm3 + movaps %xmm5, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm3, %xmm2 + subsd %xmm1, %xmm4 + subsd %xmm5, %xmm2 + movzwl 54(%rsp), %eax + subsd %xmm2, %xmm3 + andl $32752, %eax + subsd %xmm3, %xmm5 + movsd %xmm3, 64(%rsp) + cmpl $13168, %eax + addsd %xmm4, %xmm5 + movsd %xmm5, 72(%rsp) + jge ..B2.14 +..B2.13: + lea 16+_CONSTANTS(%rip), %r12 + lea 40(%rsp), %rdx + movsd 8(%rdx), %xmm0 + pxor %xmm5, %xmm5 + mulsd (%r12), %xmm0 + movsd %xmm0, -8(%rdx) + movzwl -2(%rdx), %eax + movl %eax, %r12d + andl $32752, %r12d + andl $-32753, %eax + shrl $4, %r12d + orl $-49168, %eax + movw %ax, -2(%rdx) + addl $-1279, %r12d + jmp ..B2.16 +..B2.14: + movsd 48(%rsp), %xmm0 + lea 32(%rsp), %rdi +..___tag_value_ccosh.30: + call __libm_sinh_k64@PLT +..___tag_value_ccosh.31: +..B2.61: + movl %eax, %r12d +..B2.15: + lea 40(%rsp), %rdx + movsd (%rdx), %xmm5 +..B2.16: + movsd 32(%rsp), %xmm0 + movaps %xmm5, %xmm4 + movsd .L_2il0floatpacket.13(%rip), %xmm3 + lea 16(%rsp), %rdi + addsd %xmm0, %xmm4 + mulsd %xmm4, %xmm3 + movaps %xmm4, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm3, %xmm2 + lea 80(%rsp), %rsi + movsd -24(%rsi), %xmm0 + subsd %xmm4, %xmm2 + subsd %xmm1, %xmm5 + subsd %xmm2, %xmm3 + movsd %xmm3, -48(%rsi) + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + movsd %xmm5, (%rdx) +..___tag_value_ccosh.32: + call __libm_sincos_k64@PLT +..___tag_value_ccosh.33: +..B2.17: + movsd 80(%rsp), %xmm0 + lea 8+_CONSTANTS(%rip), %rax + movsd 88(%rsp), %xmm4 + movaps %xmm0, %xmm3 + movsd .L_2il0floatpacket.13(%rip), %xmm6 + addsd %xmm4, %xmm3 + mulsd %xmm3, %xmm6 + movaps %xmm3, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm6, %xmm2 + subsd %xmm1, %xmm4 + subsd %xmm3, %xmm2 + movsd (%rax), %xmm5 + subsd %xmm2, %xmm6 + movzwl 62(%rsp), %edx + subsd %xmm6, %xmm3 + addsd %xmm5, %xmm6 + addsd %xmm3, %xmm4 + andl $32752, %edx + movsd %xmm4, 88(%rsp) + cmpl $13168, %edx + movsd %xmm6, 80(%rsp) + jl ..B2.19 +..B2.18: + xorl %ebp, %ebp + lea 24(%rsp), %rdx + movsd (%rdx), %xmm5 + jmp ..B2.20 +..B2.19: + lea 16+_CONSTANTS(%rip), %rbp + lea 24(%rsp), %rdx + movsd 32(%rdx), %xmm0 + pxor %xmm5, %xmm5 + mulsd (%rbp), %xmm0 + movsd %xmm0, -8(%rdx) + movzwl -2(%rdx), %eax + movl %eax, %ebp + andl $32752, %ebp + andl $-32753, %eax + shrl $4, %ebp + orl $-49168, %eax + movw %ax, -2(%rdx) + addl $-1279, %ebp +..B2.20: + movsd 16(%rsp), %xmm0 + movaps %xmm5, %xmm4 + movsd .L_2il0floatpacket.13(%rip), %xmm3 + lea 64(%rsp), %rsi + movl %r13d, %edi + lea (%rsp), %rcx + addsd %xmm0, %xmm4 + mulsd %xmm4, %xmm3 + movaps %xmm4, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm3, %xmm2 + subsd %xmm1, %xmm5 + subsd %xmm4, %xmm2 + subsd %xmm2, %xmm3 + movsd %xmm3, 16(%rcx) + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + movsd %xmm5, (%rdx) + lea 80(%rsp), %rdx +..___tag_value_ccosh.34: + call __libm_mul_k64@PLT +..___tag_value_ccosh.35: +..B2.21: + addl %r12d, %ebp + lea 32(%rsp), %rsi + movl %ebp, %edi + lea 16(%rsp), %rdx + lea 8(%rsp), %rcx +..___tag_value_ccosh.36: + call __libm_mul_k64@PLT +..___tag_value_ccosh.37: +..B2.22: + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.41 +..B2.23: + movzwl 62(%rsp), %ebp + andl $32752, %ebp + shrl $4, %ebp +..B2.24: + testl %ebp, %ebp + jne ..B2.33 +..B2.25: + testl $1048575, 60(%rsp) + jne ..B2.33 +..B2.26: + cmpl $0, 56(%rsp) + jne ..B2.33 +..B2.27: + movsd 48(%rsp), %xmm0 + call cosh@PLT +..B2.62: + cmpl $2047, %r12d + movhpd 56(%rsp), %xmm0 + jl ..B2.31 +..B2.29: + testl $1048575, 52(%rsp) + jne ..B2.41 +..B2.30: + cmpl $0, 48(%rsp) + jne ..B2.41 +..B2.31: + movsd %xmm0, (%rsp) + movhpd %xmm0, 8(%rsp) +..B2.32: + movb 15(%rsp), %dl + movb %dl, %cl + movb 55(%rsp), %al + andb $127, %cl + shrb $7, %dl + shrb $7, %al + movsd (%rsp), %xmm0 + xorb %al, %dl + shlb $7, %dl + orb %dl, %cl + movb %cl, 15(%rsp) + movhpd 8(%rsp), %xmm0 + jmp ..B2.41 +..B2.33: + cmpl $2047, %ebp + jge ..B2.36 +..B2.34: + movsd 48(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) + call cosh@PLT +..B2.64: + movsd %xmm0, 40(%rsp) + movsd 56(%rsp), %xmm0 + movsd %xmm0, 16(%rsp) + call __libm_sse2_sincos@PLT +..B2.63: + movsd %xmm0, 24(%rsp) + testl %ebp, %ebp + movsd 40(%rsp), %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, (%rsp) + jle ..B2.49 +..B2.35: + movsd 32(%rsp), %xmm0 + call sinh@PLT +..B2.65: + mulsd 24(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.41 +..B2.36: + cmpl $2047, %r12d + jge ..B2.38 +..B2.37: + movsd 56(%rsp), %xmm0 + call cos@PLT + jmp ..B2.67 +..B2.38: + movsd 48(%rsp), %xmm0 + call cosh@PLT +..B2.67: + movsd %xmm0, (%rsp) +..B2.39: + testl %r12d, %r12d + jle ..B2.51 +..B2.40: + movsd 56(%rsp), %xmm0 + call sin@PLT +..B2.68: + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 +..B2.41: + movq 96(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.43 +..B2.42: + movaps %xmm0, %xmm1 + unpckhpd %xmm0, %xmm1 + addq $112, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 6, -32 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B2.43: + call __stack_chk_fail@PLT +..B2.44: + testl $1048575, 60(%rsp) + jne ..B2.5 +..B2.45: + cmpl $0, 56(%rsp) + jne ..B2.5 + jmp ..B2.24 +..B2.46: + testl $1048575, 52(%rsp) + jne ..B2.3 +..B2.47: + cmpl $0, 48(%rsp) + jne ..B2.3 + jmp ..B2.23 +..B2.49: + movsd 32(%rsp), %xmm0 + call sinh@PLT +..B2.69: + mulsd 16(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.41 +..B2.51: + testl $1048575, 52(%rsp) + jne ..B2.40 +..B2.52: + cmpl $0, 48(%rsp) + jne ..B2.40 +..B2.53: + testl $1048575, 60(%rsp) + jne ..B2.56 +..B2.54: + cmpl $0, 56(%rsp) + jne ..B2.56 +..B2.55: + movb 55(%rsp), %dl + lea ones(%rip), %rcx + movb 63(%rsp), %al + andb $-128, %dl + andb $-128, %al + pxor %xmm0, %xmm0 + shrb $7, %dl + shrb $7, %al + xorb %al, %dl + movzbl %dl, %ebp + mulsd (%rcx,%rbp,8), %xmm0 + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.41 +..B2.56: + movq $0, 8(%rsp) + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.41 + .align 16,0x90 + .cfi_endproc + .type ccosh,@function + .size ccosh,.-ccosh + .data +# -- End ccosh + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.13: + .long 0x02000000,0x41a00000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +.L_2il0floatpacket.12: + .long 0x00800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .align 4 +_CONSTANTS: + .long 0 + .long 2145386496 + .long 0 + .long 1048576 + .long 0 + .long 1341128704 + .type _CONSTANTS,@object + .size _CONSTANTS,24 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ccoshl.S b/external/sgx_libm/intel64/ccoshl.S new file mode 100644 index 0000000000..811a47f254 --- /dev/null +++ b/external/sgx_libm/intel64/ccoshl.S @@ -0,0 +1,742 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccoshl.c" + .text +..TXTST0: +# -- Begin ccoshl + .text + .align 16,0x90 + .globl ccoshl +ccoshl: +# parameter 1: 336 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_ccoshl.1: +..L2: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + pushq %rbp + .cfi_def_cfa_offset 40 + .cfi_offset 6, -40 + subq $296, %rsp + .cfi_def_cfa_offset 336 + xorb %bl, %bl + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 288(%rsp) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 256(%rsp) + fldt 256(%rsp) + fstpt 272(%rsp) +..B1.2: + fnstcw 114(%rsp) +..B1.3: + movzwl 114(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 112(%rsp) +..B1.5: + fldcw 112(%rsp) +..B1.6: + movb $1, %bl +..B1.7: + movzwl 344(%rsp), %ebp + andl $32767, %ebp + cmpl $32767, %ebp + jge ..B1.33 +..B1.8: + testl %ebp, %ebp + jle ..B1.57 +..B1.9: + movzwl 360(%rsp), %r14d + andl $32767, %r14d + cmpl $32767, %r14d + jge ..B1.33 +..B1.10: + testl %r14d, %r14d + jle ..B1.55 +..B1.11: + cmpl $16398, %ebp + jl ..B1.20 +..B1.12: + fldt 352(%rsp) + lea _CONSTANTS(%rip), %rax + fstpt (%rsp) + fldt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstpt (%rsp) + fldt (%rax) + fmul %st(0), %st + fstpt 32(%rsp) + call cosl@PLT +..B1.65: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 + fmul %st, %st(1) + testl %r14d, %r14d + fxch %st(1) + fstpt 256(%rsp) + fldt 336(%rsp) + fmulp %st, %st(1) + jle ..B1.14 +..B1.13: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 16(%rsp) + fstpt (%rsp) + fstpt 32(%rsp) + call sinl@PLT +..B1.66: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 + fmulp %st, %st(1) + jmp ..B1.15 +..B1.14: + fldt (%rsp) + fmulp %st, %st(1) +..B1.15: + fstpt 272(%rsp) + testb %bl, %bl + je ..B1.17 +..B1.16: + fldcw 114(%rsp) +..B1.17: + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.54 +..B1.18: + fldt 256(%rsp) + fldt 272(%rsp) + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.53 +..B1.19: + addq $296, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.20: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + lea 176(%rsp), %rdi + fstpt (%rsp) +..___tag_value_ccoshl.31: + call __libm_coshl_k80@PLT +..___tag_value_ccoshl.32: +..B1.67: + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.21: + fldt 176(%rsp) + lea 48+_CONSTANTS(%rip), %r15 + fldt .L_2il0floatpacket.9(%rip) + movzwl 344(%rsp), %eax + andl $32767, %eax + fldt (%r15) + cmpl $16183, %eax + fadd %st, %st(3) + fxch %st(3) + fstpt (%rsp) + fldt 160(%rsp) + fld %st(0) + movl (%rsp), %r15d + fadd %st(3), %st + fmul %st, %st(2) + fld %st(0) + fsubr %st(3), %st + fsubrp %st, %st(3) + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(1) + fsubr %st(2), %st + fsubrp %st, %st(3) + fsubrp %st, %st(1) + faddp %st, %st(1) + jge ..B1.23 +..B1.22: + fstp %st(1) + fldt 336(%rsp) + lea 32+_CONSTANTS(%rip), %r14 + fldt 96(%rsp) + lea 208(%rsp), %rdx + fstpt (%rdx) + fldt (%r14) + fmulp %st, %st(1) + fstpt -16(%rdx) + movzwl -8(%rdx), %eax + movl %eax, %r14d + andl $-32768, %eax + andl $32767, %r14d + orl $-49153, %eax + addl $-16639, %r14d + movw %ax, -8(%rdx) + jmp ..B1.25 +..B1.23: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + lea 208(%rsp), %rdi + fstpt (%rsp) + fxch %st(1) + fstpt 16(%rsp) + fstpt -128(%rdi) +..___tag_value_ccoshl.35: + call __libm_sinhl_k80@PLT +..___tag_value_ccoshl.36: +..B1.68: + fldt 80(%rsp) + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.24: + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + lea 208(%rsp), %rdx + movl (%rsp), %r14d +..B1.25: + fldt 192(%rsp) + fld %st(0) + fldt (%rdx) + fadd %st, %st(1) + fld %st(1) + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.9(%rip) + fmul %st(3), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt 368(%rsp) + fstpt (%rsp) + lea 240(%rsp), %rdi + fxch %st(1) + fstpt 80(%rsp) + fstpt 96(%rsp) +..___tag_value_ccoshl.39: + call __libm_cosl_k80@PLT +..___tag_value_ccoshl.40: +..B1.69: + fldt 96(%rsp) + fldt 80(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.26: + fldt 224(%rsp) + lea 16+_CONSTANTS(%rip), %rax + fld %st(0) + fldt 240(%rsp) + movzwl 360(%rsp), %edx + fadd %st, %st(1) + fld %st(1) + andl $32767, %edx + cmpl $16183, %edx + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.9(%rip) + fmul %st(3), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st(4), %st + fxch %st(1) + fmulp %st, %st(4) + fldt (%rax) + faddp %st, %st(1) + jge ..B1.28 +..B1.27: + fldt 352(%rsp) + lea 32+_CONSTANTS(%rip), %rbp + fldt 96(%rsp) + fstpt 144(%rsp) + fldt (%rbp) + fmulp %st, %st(1) + fstpt 128(%rsp) + movzwl 136(%rsp), %eax + movl %eax, %ebp + andl $-32768, %eax + andl $32767, %ebp + orl $-49153, %eax + addl $-16639, %ebp + movw %ax, 136(%rsp) + fldt 128(%rsp) + jmp ..B1.30 +..B1.28: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 368(%rsp) + lea 144(%rsp), %rdi + fstpt (%rsp) + fxch %st(3) + fstpt 16(%rsp) + fstpt -64(%rdi) + fxch %st(1) + fstpt -112(%rdi) + fstpt -48(%rdi) +..___tag_value_ccoshl.43: + call __libm_sinl_k80@PLT +..___tag_value_ccoshl.44: +..B1.70: + fldt 96(%rsp) + fldt 32(%rsp) + fldt 80(%rsp) + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.29: + fldt 128(%rsp) + xorl %ebp, %ebp + fmul %st(5), %st + fstpt 128(%rsp) + fldt 128(%rsp) + fldt 144(%rsp) + fmulp %st, %st(6) + fxch %st(5) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 144(%rsp) + fxch %st(4) + fxch %st(1) + fxch %st(2) + fxch %st(1) +..B1.30: + fldt 96(%rsp) + fld %st(1) + movl %r15d, %edi + fadd %st(1), %st + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.9(%rip) + fmul %st(3), %st + fsub %st, %st(1) + fsubp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(5), %st + fldt 32(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + fld %st(0) + fmul %st(4), %st + fstpt (%rsp) + fmulp %st, %st(6) + faddp %st, %st(5) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + fstpt 16(%rsp) + fxch %st(1) + fstpt 48(%rsp) + fstpt 112(%rsp) +..___tag_value_ccoshl.47: + call __libm_scalbl_k80@PLT +..___tag_value_ccoshl.48: +..B1.71: + fldt 112(%rsp) + fldt 48(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B1.31: + fldt (%rsp) + fld %st(2) + fmul %st(2), %st + addl %ebp, %r14d + fxch %st(4) + fstpt 256(%rsp) + movl %r14d, %edi + fldt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + fld %st(0) + fmul %st(2), %st + fstpt (%rsp) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsp) +..___tag_value_ccoshl.51: + call __libm_scalbl_k80@PLT +..___tag_value_ccoshl.52: +..B1.72: + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B1.32: + fstpt 272(%rsp) + jmp ..B1.48 +..B1.33: + movq 352(%rsp), %r14 + testq %r14, %r14 + jne ..B1.37 +..B1.34: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + fstpt (%rsp) + call coshl@PLT +..B1.73: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt 352(%rsp) + cmpl $32767, %ebp + fstpt 272(%rsp) + fstpt 256(%rsp) + jl ..B1.36 +..B1.35: + movq $0x8000000000000000, %rax + cmpq 336(%rsp), %rax + jne ..B1.48 +..B1.36: + movb 281(%rsp), %dl + movb %dl, %cl + movb 345(%rsp), %al + andb $127, %cl + shrb $7, %dl + shrb $7, %al + xorb %al, %dl + shlb $7, %dl + orb %dl, %cl + movb %cl, 281(%rsp) + jmp ..B1.48 +..B1.37: + movzwl 360(%rsp), %r15d + andl $32767, %r15d + cmpl $32767, %r15d + jge ..B1.40 +..B1.38: + fldt 336(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstpt (%rsp) + call coshl@PLT +..B1.75: + fstpt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt 352(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstpt (%rsp) + call cosl@PLT +..B1.74: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt (%rsp) + testl %r15d, %r15d + fmulp %st, %st(1) + fstpt 256(%rsp) + jle ..B1.59 +..B1.39: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 48(%rsp) + fstpt (%rsp) + call sinhl@PLT +..B1.77: + fstpt 16(%rsp) + fldt 32(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.76: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt (%rsp) + fmulp %st, %st(1) + fstpt 272(%rsp) + jmp ..B1.48 +..B1.40: + cmpl $32767, %ebp + jge ..B1.42 +..B1.41: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 368(%rsp) + fstpt (%rsp) + call cosl@PLT + jmp ..B1.79 + .cfi_def_cfa_offset 336 +..B1.42: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + fstpt (%rsp) + call coshl@PLT +..B1.79: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fstpt 256(%rsp) +..B1.43: + cmpl $0, 340(%rsp) + jne ..B1.45 +..B1.44: + cmpl $0, 336(%rsp) + je ..B1.46 +..B1.45: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 368(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.80: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fstpt 272(%rsp) + jmp ..B1.48 +..B1.46: + movq $0x8000000000000000, %rax + cmpq %rax, %r14 + je ..B1.62 +..B1.47: + fldt 96(%rsp) + fstpt 272(%rsp) +..B1.48: + testb %bl, %bl + je ..B1.50 +..B1.49: + fldcw 114(%rsp) +..B1.50: + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.54 +..B1.51: + fldt 256(%rsp) + fldt 272(%rsp) + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.53 +..B1.52: + addq $296, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.53: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.54: + call __stack_chk_fail@PLT +..B1.55: + cmpl $0, 356(%rsp) + jne ..B1.11 +..B1.56: + cmpl $0, 352(%rsp) + jne ..B1.11 + jmp ..B1.33 +..B1.57: + cmpl $0, 340(%rsp) + jne ..B1.9 +..B1.58: + cmpl $0, 336(%rsp) + jne ..B1.9 + jmp ..B1.33 +..B1.59: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 48(%rsp) + fstpt (%rsp) + call sinhl@PLT +..B1.81: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt 16(%rsp) + fmulp %st, %st(1) + fstpt 272(%rsp) + jmp ..B1.48 +..B1.62: + movb 345(%rsp), %dl + lea ones(%rip), %rcx + movb 361(%rsp), %al + andb $-128, %dl + andb $-128, %al + pxor %xmm0, %xmm0 + shrb $7, %dl + shrb $7, %al + xorb %al, %dl + movzbl %dl, %ebp + mulsd (%rcx,%rbp,8), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 272(%rsp) + jmp ..B1.48 + .align 16,0x90 + .cfi_endproc + .type ccoshl,@function + .size ccoshl,.-ccoshl + .data +# -- End ccoshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,64 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ccosl.S b/external/sgx_libm/intel64/ccosl.S new file mode 100644 index 0000000000..7d2f5dc8c0 --- /dev/null +++ b/external/sgx_libm/intel64/ccosl.S @@ -0,0 +1,175 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ccosl.c" + .text +..TXTST0: +# -- Begin ccosl + .text + .align 16,0x90 + .globl ccosl +ccosl: +# parameter 1: 112 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_ccosl.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $96, %rsp + .cfi_def_cfa_offset 112 + xorb %bl, %bl + fldt .L_2il0floatpacket.5(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 80(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 64(%rsp) +..B1.2: + fnstcw 2(%rsp) +..B1.3: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.5: + fldcw (%rsp) +..B1.6: + movb $1, %bl +..B1.7: + fldt 112(%rsp) + movzwl 136(%rsp), %eax + andl $32767, %eax + fstpt 64(%rsp) + cmpl $32767, %eax + fldt 128(%rsp) + fstpt 48(%rsp) + jl ..B1.9 +..B1.8: + movq $0x8000000000000000, %rax + cmpq 128(%rsp), %rax + jne ..B1.10 +..B1.9: + movb 137(%rsp), %al + notb %al + movb 57(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 57(%rsp) +..B1.10: + addq $-32, %rsp + .cfi_def_cfa_offset 144 + movq %rsp, %rdi + movq 80(%rsp), %rax + movq 88(%rsp), %rdx + movq 96(%rsp), %rcx + movq 104(%rsp), %rsi + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + movq %rcx, 16(%rdi) + movq %rsi, 24(%rdi) + call ccoshl@PLT +..B1.19: + fxch %st(1) + addq $32, %rsp + .cfi_def_cfa_offset 112 + fxch %st(1) + fstpt 16(%rsp) + testb %bl, %bl + fstpt 32(%rsp) + je ..B1.12 +..B1.11: + fldcw 2(%rsp) +..B1.12: + movq 80(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.16 +..B1.13: + fldt 16(%rsp) + fldt 32(%rsp) + movq 80(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.15 +..B1.14: + addq $96, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 112 + .cfi_offset 3, -16 +..B1.15: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.16: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type ccosl,@function + .size ccosl,.-ccosl + .data +# -- End ccosl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ceil_gen.S b/external/sgx_libm/intel64/ceil_gen.S new file mode 100644 index 0000000000..83fec73e5e --- /dev/null +++ b/external/sgx_libm/intel64/ceil_gen.S @@ -0,0 +1,167 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ceil_gen.c" + .text +..TXTST0: +# -- Begin ceil + .text + .align 16,0x90 + .globl ceil +ceil: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ceil.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + movl %eax, %edi + andl $2147483647, %edi + lea -1072693248(%rdi), %edx + cmpl $54525952, %edx + jae ..B1.12 +..B1.2: + movl %edi, %ecx + shrl $20, %ecx + cmpl $22020096, %edx + jae ..B1.8 +..B1.3: + negl %ecx + movl $-1, %esi + addl $19, %ecx + shll %cl, %esi + movl %esi, %edx + andl %esi, %eax + notl %edx + andl %edx, %edi + orl -8(%rsp), %edi + movl $0, -8(%rsp) + testl $-2147483648, %eax + jne ..B1.6 +..B1.4: + testl %edi, %edi + je ..B1.6 +..B1.5: + subl %esi, %eax + movl %eax, -4(%rsp) + jmp ..B1.11 +..B1.6: + movl %eax, -4(%rsp) + jmp ..B1.11 +..B1.8: + negl %ecx + movl $-1, %esi + addl $19, %ecx + shll %cl, %esi + movl %esi, %ecx + notl %ecx + movl -8(%rsp), %edx + andl %edx, %ecx + andl %esi, %edx + movl %edx, -8(%rsp) + testl $-2147483648, %eax + jne ..B1.11 +..B1.9: + testl %ecx, %ecx + je ..B1.11 +..B1.10: + movl -4(%rsp), %eax + shlq $32, %rax + movslq %esi, %rsi + orq %rdx, %rax + subq %rsi, %rax + movq %rax, -8(%rsp) +..B1.11: + movsd -8(%rsp), %xmm0 + ret +..B1.12: + testl $-2147483648, %edx + je ..B1.17 +..B1.13: + movl -8(%rsp), %edx + orl %edx, %edi + jne ..B1.15 +..B1.14: + movsd -8(%rsp), %xmm0 + ret +..B1.15: + lea _pone_nzero(%rip), %rdx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm0 +..B1.16: + ret +..B1.17: + movsd -8(%rsp), %xmm0 + cmpl $1073741824, %edx + jb ..B1.20 +..B1.19: + lea _ones(%rip), %rax + mulsd (%rax), %xmm0 +..B1.20: + ret + .align 16,0x90 + .cfi_endproc + .type ceil,@function + .size ceil,.-ceil + .data +# -- End ceil + .section .rodata, "a" + .align 4 + .align 4 +_pone_nzero: + .long 0 + .long 1072693248 + .long 0 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ceilf_gen.S b/external/sgx_libm/intel64/ceilf_gen.S new file mode 100644 index 0000000000..e513e9c8d8 --- /dev/null +++ b/external/sgx_libm/intel64/ceilf_gen.S @@ -0,0 +1,141 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ceilf_gen.c" + .text +..TXTST0: +# -- Begin ceilf + .text + .align 16,0x90 + .globl ceilf +ceilf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ceilf.1: +..L2: + + movaps %xmm0, %xmm2 + movss %xmm2, -16(%rsp) + movzwl -14(%rsp), %eax + andl $32640, %eax + shrl $7, %eax + cmpl $149, %eax + jge ..B1.8 +..B1.2: + cmpl $127, %eax + jl ..B1.4 +..B1.3: + movss .L_2il0floatpacket.0(%rip), %xmm1 + movaps %xmm1, %xmm0 + addss %xmm2, %xmm0 + movss %xmm0, -24(%rsp) + movss -24(%rsp), %xmm3 + movss .L_2il0floatpacket.2(%rip), %xmm0 + subss %xmm1, %xmm3 + comiss %xmm3, %xmm2 + addss %xmm3, %xmm0 + ja ..L3 + movaps %xmm3, %xmm0 +..L3: + ret +..B1.4: + testl %eax, %eax + jne ..B1.7 +..B1.5: + testl $8388607, -16(%rsp) + jne ..B1.7 +..B1.6: + movss -16(%rsp), %xmm0 + ret +..B1.7: + movb -13(%rsp), %dl + lea _pone_nzero(%rip), %rcx + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + movl -16(%rsp), %eax + movl %eax, -24(%rsp) + movss (%rcx,%rsi,4), %xmm0 + ret +..B1.8: + cmpl $150, %eax + jge ..B1.6 +..B1.9: + movss -16(%rsp), %xmm1 + movss .L_2il0floatpacket.1(%rip), %xmm0 + testb $1, -16(%rsp) + addss %xmm1, %xmm0 + jne ..L4 + movaps %xmm1, %xmm0 +..L4: + ret + .align 16,0x90 + .cfi_endproc + .type ceilf,@function + .size ceilf,.-ceilf + .data +# -- End ceilf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4b400000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x3f000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x3f800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +_pone_nzero: + .long 1065353216 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ceill.S b/external/sgx_libm/intel64/ceill.S new file mode 100644 index 0000000000..2de08c36ec --- /dev/null +++ b/external/sgx_libm/intel64/ceill.S @@ -0,0 +1,257 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ceill.c" + .text +..TXTST0: +# -- Begin ceill + .text + .align 16,0x90 + .globl ceill +ceill: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_ceill.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %cl, %cl +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 56(%rsp), %eax + andl $32767, %eax + cmpl $16445, %eax + jge ..B1.20 +..B1.4: + cmpl $16383, %eax + jl ..B1.15 +..B1.5: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.7: + fldcw 24(%rsp) +..B1.8: + movb $1, %cl +..B1.9: + fldt 48(%rsp) + lea _TWO_63H(%rip), %rax + fld %st(0) + fldl (%rax) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 8(%rsp) + fldt 8(%rsp) + fcomip %st(1), %st + fstp %st(0) + jae ..B1.12 + jp ..B1.12 +..B1.10: + fldt 8(%rsp) + lea _ones(%rip), %rax + faddl (%rax) + fstpt 8(%rsp) +..B1.12: + testb %cl, %cl + je ..B1.14 +..B1.13: + fldcw 26(%rsp) +..B1.14: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.15: + testl %eax, %eax + jne ..B1.19 +..B1.16: + cmpq $0, 48(%rsp) + jne ..B1.18 +..B1.17: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.18: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, (%rsp) +..B1.19: + movb 57(%rsp), %al + lea _pone_nzero(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.20: + cmpl $16446, %eax + jge ..B1.29 +..B1.21: + testb $1, 48(%rsp) + je ..B1.28 +..B1.22: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.35 +..B1.23: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.24: + fldcw 24(%rsp) +..B1.25: + fldt 48(%rsp) + lea _halfs(%rip), %rax + faddl (%rax) + fstpt 8(%rsp) +..B1.26: + fldcw 26(%rsp) +..B1.27: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.28: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.29: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.30: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.31: + fldcw 24(%rsp) +..B1.32: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) +..B1.33: + fldcw 26(%rsp) +..B1.34: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.35: + fldt 48(%rsp) + lea _halfs(%rip), %rax + faddl (%rax) + fstpt 8(%rsp) + jmp ..B1.27 +..B1.36: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) + jmp ..B1.34 + .align 16,0x90 + .cfi_endproc + .type ceill,@function + .size ceill,.-ceill + .data +# -- End ceill + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_pone_nzero: + .long 0 + .long 1072693248 + .long 0 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,16 + .align 4 +_halfs: + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .type _halfs,@object + .size _halfs,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cexp.S b/external/sgx_libm/intel64/cexp.S new file mode 100644 index 0000000000..136caab307 --- /dev/null +++ b/external/sgx_libm/intel64/cexp.S @@ -0,0 +1,2052 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cexp.c" + .text +..TXTST0: +# -- Begin cexp + .text + .align 16,0x90 + .globl cexp +cexp: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cexp.1: +..L2: + +..B1.2: + movq %rsp, %rax + subq $280, %rsp + .cfi_def_cfa_offset 288 + movq %rax, 184(%rsp) + movq %xmm0, 160(%rsp) + movq %xmm1, 168(%rsp) + movq %rbx, 192(%rsp) + movq 160(%rsp), %xmm0 + movq 168(%rsp), %xmm5 + movdqa %xmm0, %xmm7 + lea cexp_table(%rip), %r8 + movdqa (%r8), %xmm1 + shufps $85, %xmm5, %xmm7 + movdqa 16(%r8), %xmm2 + pand %xmm1, %xmm7 + pcmpgtd %xmm7, %xmm2 + movmskps %xmm2, %edx + cmpl $5, %edx + unpcklpd %xmm0, %xmm0 + jne .L_2TAG_PACKET_0.0.1 +.L_2TAG_PACKET_1.0.1: + movapd 32(%r8), %xmm1 + movapd 48(%r8), %xmm6 + movapd 64(%r8), %xmm2 + movapd 80(%r8), %xmm3 + mulpd %xmm0, %xmm1 + unpcklpd %xmm5, %xmm5 + addpd %xmm6, %xmm1 + movapd 96(%r8), %xmm7 + movd %xmm1, %edx + subpd %xmm6, %xmm1 + movq $63, %rax + mulpd %xmm5, %xmm7 + mulpd %xmm1, %xmm2 + movapd 112(%r8), %xmm4 + andq %rdx, %rax + mulpd %xmm1, %xmm3 + movapd 128(%r8), %xmm1 + subpd %xmm2, %xmm0 + cvtsd2si %xmm7, %ecx + lea (,%rax,8), %rax + subpd %xmm3, %xmm0 + addpd %xmm6, %xmm7 + movapd 4512(%r8,%rax,2), %xmm2 + mulpd %xmm0, %xmm4 + addl $1865216, %ecx + movapd %xmm0, %xmm3 + subpd %xmm6, %xmm7 + mulpd %xmm0, %xmm0 + movapd 144(%r8), %xmm6 + andq $63, %rcx + addpd %xmm4, %xmm1 + mulsd %xmm0, %xmm0 + movapd 160(%r8), %xmm4 + addsd %xmm2, %xmm3 + lea (,%rcx,8), %rcx + unpckhpd %xmm2, %xmm2 + mulpd %xmm1, %xmm0 + movapd %xmm5, %xmm1 + lea 416(%r8,%rcx,8), %rcx + addsd %xmm0, %xmm3 + mulpd %xmm7, %xmm4 + unpckhpd %xmm0, %xmm0 + mulpd %xmm7, %xmm6 + subpd %xmm4, %xmm5 + mulpd 176(%r8), %xmm7 + subpd %xmm4, %xmm1 + addsd %xmm3, %xmm0 + movapd 192(%r8), %xmm3 + unpcklpd %xmm0, %xmm0 + movapd %xmm1, %xmm4 + subpd %xmm6, %xmm1 + mulpd %xmm2, %xmm0 + mulpd %xmm5, %xmm3 + movapd %xmm2, (%rsp) + movapd %xmm0, 16(%rsp) + movapd 16(%rcx), %xmm0 + subpd %xmm6, %xmm5 + movapd 208(%r8), %xmm2 + subpd %xmm1, %xmm4 + mulpd %xmm5, %xmm3 + mulpd %xmm5, %xmm5 + subpd %xmm6, %xmm4 + mulpd %xmm1, %xmm0 + movapd (%rcx), %xmm6 + subpd %xmm4, %xmm7 + movapd 48(%rcx), %xmm4 + addpd %xmm4, %xmm6 + subpd %xmm6, %xmm0 + mulpd %xmm0, %xmm7 + movapd 16(%rcx), %xmm0 + mulpd %xmm1, %xmm6 + mulpd %xmm5, %xmm2 + mulpd %xmm1, %xmm4 + mulpd %xmm5, %xmm6 + mulpd %xmm5, %xmm0 + mulpd %xmm5, %xmm5 + addpd 224(%r8), %xmm3 + mulpd (%rcx), %xmm1 + addpd 240(%r8), %xmm2 + mulpd %xmm5, %xmm3 + movapd %xmm4, %xmm5 + addpd 16(%rcx), %xmm4 + addpd %xmm3, %xmm2 + movsd %xmm2, %xmm3 + unpckhpd %xmm2, %xmm2 + andl $-64, %edx + unpcklpd %xmm3, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm3, %xmm6 + movapd %xmm1, %xmm0 + addpd %xmm4, %xmm1 + movapd 16(%rcx), %xmm3 + subpd %xmm4, %xmm3 + subpd %xmm1, %xmm4 + addpd 32(%rcx), %xmm7 + addpd %xmm5, %xmm3 + movapd (%rsp), %xmm5 + addpd %xmm0, %xmm4 + addpd %xmm3, %xmm7 + movapd 16(%rsp), %xmm3 + movd %edx, %xmm0 + addpd %xmm4, %xmm7 + movapd %xmm1, %xmm4 + addpd %xmm6, %xmm7 + movapd 256(%r8), %xmm6 + pshufd $17, %xmm0, %xmm0 + addpd %xmm2, %xmm7 +.L_2TAG_PACKET_2.0.1: + movapd %xmm5, %xmm2 + addpd %xmm3, %xmm5 + addpd %xmm7, %xmm1 + andpd %xmm6, %xmm5 + andpd %xmm1, %xmm6 + pand 272(%r8), %xmm1 + subpd %xmm5, %xmm2 + subpd %xmm6, %xmm4 + addpd %xmm3, %xmm2 + movdqa 288(%r8), %xmm3 + addpd %xmm7, %xmm4 + por 304(%r8), %xmm6 + psubd %xmm1, %xmm3 + movapd 320(%r8), %xmm7 + psrld $14, %xmm1 + mulpd %xmm3, %xmm4 + paddd %xmm1, %xmm0 + paddd %xmm0, %xmm7 + movapd %xmm2, %xmm1 + pcmpgtd 320(%r8), %xmm7 + mulpd %xmm4, %xmm2 + movmskps %xmm7, %eax + cmpl $10, %eax + jne .L_2TAG_PACKET_3.0.1 + mulpd %xmm5, %xmm4 + pslld $14, %xmm0 + mulpd %xmm6, %xmm1 + addpd %xmm4, %xmm2 + mulpd %xmm5, %xmm6 + addpd %xmm1, %xmm2 + addpd %xmm6, %xmm2 + mulpd %xmm2, %xmm0 + movq %xmm0, %xmm1 + pshufd $14, %xmm0, %xmm0 + movq 192(%rsp), %rbx + movq 184(%rsp), %rsp + ret +.L_2TAG_PACKET_3.0.1: + psrad $6, %xmm0 + psubd 336(%r8), %xmm0 + pshufd $245, %xmm0, %xmm2 + psrad $32, %xmm0 + pand 400(%r8), %xmm0 + pand 384(%r8), %xmm2 + por %xmm2, %xmm0 + movdqa %xmm0, 64(%rsp) + movq %xmm5, 112(%rsp) + movq %xmm1, 120(%rsp) + movhpd %xmm6, 128(%rsp) + movhpd %xmm4, 136(%rsp) + movq %xmm6, 144(%rsp) + movq %xmm4, 152(%rsp) + movq 72(%rsp), %rdi + lea 128(%rsp), %rsi + lea 112(%rsp), %rdx + lea 96(%rsp), %rcx + call __libm_mul_k64@PLT + movq 64(%rsp), %rdi + lea 144(%rsp), %rsi + lea 112(%rsp), %rdx + lea 104(%rsp), %rcx + call __libm_mul_k64@PLT + movq 96(%rsp), %xmm0 + movq 104(%rsp), %xmm1 + movq 192(%rsp), %rbx + movq 184(%rsp), %rsp + ret +.L_2TAG_PACKET_0.0.1: + pextrw $1, %xmm7, %eax + testl $3, %edx + jne .L_2TAG_PACKET_4.0.1 + movapd 352(%r8), %xmm1 + cmpl $32752, %eax + jae .L_2TAG_PACKET_5.0.1 + cmpltpd %xmm0, %xmm1 + movmskpd %xmm1, %edx + cmpl $1, %edx + jne .L_2TAG_PACKET_5.0.1 + jmp .L_2TAG_PACKET_6.0.1 +.L_2TAG_PACKET_4.0.1: + testl $2, %edx + je .L_2TAG_PACKET_6.0.1 + xorpd %xmm0, %xmm0 +.L_2TAG_PACKET_6.0.1: + movdqa %xmm5, %xmm1 + testl $12, %edx + psllq $1, %xmm1 + je .L_2TAG_PACKET_5.0.1 + pxor %xmm2, %xmm2 + pextrw $3, %xmm5, %ecx + testl $8, %edx + pcmpeqd %xmm2, %xmm1 + je .L_2TAG_PACKET_1.0.1 + movmskps %xmm1, %eax + xorl %edx, %edx + movapd 368(%r8), %xmm6 + andl $3, %eax + movapd 304(%r8), %xmm4 + andl $32752, %ecx + cmpl $864, %ecx + jl .L_2TAG_PACKET_5.0.1 + testl $32752, %ecx + jne .L_2TAG_PACKET_7.0.1 + cmpl $3, %eax + je .L_2TAG_PACKET_5.0.1 + andpd %xmm5, %xmm6 + orpd %xmm4, %xmm5 + orpd %xmm4, %xmm6 + movl $-65408, %edx + subsd %xmm6, %xmm5 +.L_2TAG_PACKET_7.0.1: + movsd %xmm5, %xmm4 + movapd 32(%r8), %xmm3 + movapd 48(%r8), %xmm6 + movapd 64(%r8), %xmm5 + movapd 80(%r8), %xmm1 + mulpd %xmm0, %xmm3 + addpd %xmm6, %xmm3 + movd %xmm3, %ecx + subpd %xmm6, %xmm3 + movq $63, %rax + mulpd %xmm3, %xmm5 + movd %edx, %xmm6 + movapd 112(%r8), %xmm7 + andq %rcx, %rax + mulpd %xmm3, %xmm1 + movapd 128(%r8), %xmm3 + subpd %xmm5, %xmm0 + lea (,%rax,8), %rax + subpd %xmm1, %xmm0 + movapd 4512(%r8,%rax,2), %xmm5 + mulpd %xmm0, %xmm7 + movapd %xmm0, %xmm1 + mulpd %xmm0, %xmm0 + andl $-64, %ecx + addpd %xmm7, %xmm3 + pshufd $243, %xmm6, %xmm6 + mulsd %xmm0, %xmm0 + addsd %xmm5, %xmm1 + unpckhpd %xmm5, %xmm5 + mulpd %xmm0, %xmm3 + xorpd %xmm7, %xmm7 + addsd %xmm3, %xmm1 + movd %ecx, %xmm0 + unpckhpd %xmm3, %xmm3 + addsd %xmm1, %xmm3 + pshufd $17, %xmm0, %xmm0 + unpcklpd %xmm3, %xmm3 + paddd %xmm6, %xmm0 + mulpd %xmm5, %xmm3 + movapd 256(%r8), %xmm6 + movapd %xmm4, %xmm1 + jmp .L_2TAG_PACKET_2.0.1 +.L_2TAG_PACKET_5.0.1: + movq 160(%rsp), %xmm0 + movq 168(%rsp), %xmm1 + call __libm_internal_cexp + movq 192(%rsp), %rbx + movq 184(%rsp), %rsp + ret + .cfi_def_cfa_offset 8 +..B1.3: + .align 16,0x90 + .cfi_endproc + .type cexp,@function + .size cexp,.-cexp + .data +# -- End cexp + .text +# -- Begin __libm_internal_cexp + .text + .align 16,0x90 +__libm_internal_cexp: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value___libm_internal_cexp.6: +..L7: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + movq %fs:40, %rax + subq $120, %rsp + .cfi_def_cfa_offset 144 + movsd %xmm0, 40(%rsp) + xorq %rsp, %rax + movzwl 46(%rsp), %ebp + andl $32752, %ebp + shrl $4, %ebp + movsd %xmm1, 48(%rsp) + cmpl $2047, %ebp + movq %rax, 112(%rsp) + jge ..B2.13 +..B2.2: + testl %ebp, %ebp + jle ..B2.41 +..B2.3: + movzwl 54(%rsp), %ebx + andl $32752, %ebx + shrl $4, %ebx + cmpl $2047, %ebx + jge ..B2.14 +..B2.4: + testl %ebx, %ebx + jle ..B2.39 +..B2.5: + cmpl $1034, %ebp + jl ..B2.8 +..B2.6: + movb 47(%rsp), %al + lea _CONSTANTS(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movq (%rdx,%rcx,8), %rbx + movq %rbx, 56(%rsp) + movsd 56(%rsp), %xmm0 + movsd 56(%rsp), %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, 56(%rsp) + movsd 56(%rsp), %xmm2 + movsd 48(%rsp), %xmm0 + movsd %xmm2, (%rsp) + call cos@PLT +..B2.51: + movsd (%rsp), %xmm1 + mulsd %xmm0, %xmm1 + movzwl 54(%rsp), %eax + testl $32752, %eax + movsd %xmm1, 24(%rsp) + jle ..B2.38 +..B2.7: + movsd 56(%rsp), %xmm0 + movsd %xmm0, (%rsp) + movsd 48(%rsp), %xmm0 + call sin@PLT +..B2.52: + movsd (%rsp), %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, 32(%rsp) + jmp ..B2.29 +..B2.8: + movsd 40(%rsp), %xmm0 + lea 16(%rsp), %rdi + lea 64(%rsp), %rsi +..___tag_value___libm_internal_cexp.13: + call __libm_exp_k64@PLT +..___tag_value___libm_internal_cexp.14: +..B2.9: + movsd 48(%rsp), %xmm0 + lea 96(%rsp), %rdi + lea 80(%rsp), %rsi +..___tag_value___libm_internal_cexp.15: + call __libm_sincos_k64@PLT +..___tag_value___libm_internal_cexp.16: +..B2.10: + movl 16(%rsp), %edi + lea 64(%rsp), %rsi + lea 80(%rsp), %rdx + lea (%rsp), %rcx +..___tag_value___libm_internal_cexp.17: + call __libm_mul_k64@PLT +..___tag_value___libm_internal_cexp.18: +..B2.11: + movq (%rsp), %rax + lea 64(%rsp), %rsi + movl -48(%rsi), %edi + lea 96(%rsp), %rdx + movq %rax, -72(%rdx) + lea 8(%rsp), %rcx +..___tag_value___libm_internal_cexp.19: + call __libm_mul_k64@PLT +..___tag_value___libm_internal_cexp.20: +..B2.12: + movq 8(%rsp), %rax + movq %rax, 32(%rsp) + jmp ..B2.29 +..B2.13: + movzwl 54(%rsp), %ebx + andl $32752, %ebx + shrl $4, %ebx +..B2.14: + testl %ebx, %ebx + jne ..B2.18 +..B2.15: + testl $1048575, 52(%rsp) + jne ..B2.18 +..B2.16: + cmpl $0, 48(%rsp) + jne ..B2.18 +..B2.17: + movsd 40(%rsp), %xmm0 + call exp@PLT +..B2.53: + movq 48(%rsp), %rax + movsd %xmm0, 24(%rsp) + movq %rax, 32(%rsp) + jmp ..B2.29 +..B2.18: + cmpl $2047, %ebx + jge ..B2.21 +..B2.19: + movsd 40(%rsp), %xmm0 + call exp@PLT +..B2.55: + movsd %xmm0, 8(%rsp) + movsd 48(%rsp), %xmm0 + movsd %xmm0, (%rsp) + call __libm_sse2_sincos@PLT +..B2.54: + mulsd 8(%rsp), %xmm1 + movaps %xmm0, %xmm2 + movsd %xmm1, 24(%rsp) + testl %ebx, %ebx + jle ..B2.44 +..B2.20: + movsd 8(%rsp), %xmm0 + mulsd %xmm2, %xmm0 + movsd %xmm0, 32(%rsp) + jmp ..B2.29 +..B2.21: + cmpl $2047, %ebp + jge ..B2.23 +..B2.22: + movsd 48(%rsp), %xmm0 + call sin@PLT +..B2.56: + movsd %xmm0, 24(%rsp) + movsd %xmm0, 32(%rsp) + jmp ..B2.29 +..B2.23: + testl $1048575, 44(%rsp) + jne ..B2.25 +..B2.24: + cmpl $0, 40(%rsp) + je ..B2.26 +..B2.25: + movsd 40(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd 48(%rsp), %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm0, 24(%rsp) + movsd %xmm1, 32(%rsp) + jmp ..B2.29 +..B2.26: + testb $-128, 47(%rsp) + je ..B2.28 +..B2.27: + movsd 48(%rsp), %xmm0 + lea zeros(%rip), %rax + mulsd %xmm0, %xmm0 + movq (%rax), %rdx + movsd %xmm0, 48(%rsp) + movq %rdx, 24(%rsp) + movq %rdx, 32(%rsp) + jmp ..B2.29 +..B2.28: + movsd 40(%rsp), %xmm0 + call exp@PLT +..B2.58: + movsd %xmm0, 24(%rsp) + movsd 48(%rsp), %xmm0 + call sin@PLT +..B2.57: + movsd %xmm0, 32(%rsp) +..B2.29: + movzwl 30(%rsp), %eax + testl $32752, %eax + jne ..B2.32 +..B2.30: + testl $1048575, 28(%rsp) + jne ..B2.35 +..B2.31: + cmpl $0, 24(%rsp) + jne ..B2.35 +..B2.32: + movzwl 38(%rsp), %eax + testl $32752, %eax + jne ..B2.36 +..B2.33: + testl $1048575, 36(%rsp) + jne ..B2.35 +..B2.34: + cmpl $0, 32(%rsp) + je ..B2.36 +..B2.35: + lea _DBL_MIN_NORMAL(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 56(%rsp) +..B2.36: + movq 112(%rsp), %rax + xorq %rsp, %rax + movsd 24(%rsp), %xmm0 + movsd 32(%rsp), %xmm1 + cmpq %fs:40, %rax + jne ..B2.48 +..B2.37: + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B2.38: + movsd 56(%rsp), %xmm0 + mulsd 48(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) + jmp ..B2.29 +..B2.39: + testl $1048575, 52(%rsp) + jne ..B2.5 +..B2.40: + cmpl $0, 48(%rsp) + jne ..B2.5 + jmp ..B2.14 +..B2.41: + testl $1048575, 44(%rsp) + jne ..B2.3 +..B2.42: + cmpl $0, 40(%rsp) + jne ..B2.3 + jmp ..B2.13 +..B2.44: + testl %ebp, %ebp + jne ..B2.47 +..B2.45: + testl $1048575, 44(%rsp) + jne ..B2.47 +..B2.46: + cmpl $0, 40(%rsp) + je ..B2.20 +..B2.47: + movsd (%rsp), %xmm0 + mulsd 8(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) + jmp ..B2.29 +..B2.48: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __libm_internal_cexp,@function + .size __libm_internal_cexp,.-__libm_internal_cexp + .data +# -- End __libm_internal_cexp + .section .rodata, "a" + .align 16 + .align 16 +cexp_table: + .long 2147483647 + .long 2147483647 + .long 2147483647 + .long 2147483647 + .long 1082607888 + .long 810549248 + .long 1089863680 + .long 808452095 + .long 1697350398 + .long 1079448903 + .long 1697350398 + .long 1079448903 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 4277796864 + .long 1065758274 + .long 4277796864 + .long 1065758274 + .long 3164486458 + .long 1025308570 + .long 3164486458 + .long 1025308570 + .long 1841940611 + .long 1076125488 + .long 1841940611 + .long 1076125488 + .long 2983266533 + .long 1065422964 + .long 1432790106 + .long 1069897045 + .long 653061504 + .long 1067799895 + .long 4294959483 + .long 1071644671 + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .long 1413480448 + .long 1069097467 + .long 1413480448 + .long 1069097467 + .long 771977331 + .long 996350346 + .long 771977331 + .long 996350346 + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 0 + .long 2145386496 + .long 0 + .long 2145386496 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 2147352640 + .long 0 + .long 2147352640 + .long 0 + .long 1023 + .long 0 + .long 1023 + .long 3576508498 + .long 3230091536 + .long 565433817 + .long 1083619556 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 4294967295 + .long 0 + .long 4294967295 + .long 0 + .long 0 + .long 4294967295 + .long 0 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 3217031168 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 3220176896 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 1069547520 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 1071644672 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 1072693248 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 1069547520 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 235107661 + .long 1018002367 + .long 1048019040 + .long 1072704666 + .long 896005651 + .long 1015861842 + .long 3541402996 + .long 1072716208 + .long 1642514529 + .long 1012987726 + .long 410360776 + .long 1072727877 + .long 1568897900 + .long 1016568486 + .long 1828292879 + .long 1072739672 + .long 1882168529 + .long 1010744893 + .long 852742562 + .long 1072751596 + .long 509852888 + .long 1017336174 + .long 3490863952 + .long 1072763649 + .long 653277307 + .long 1017431380 + .long 2930322911 + .long 1072775834 + .long 1649557430 + .long 1017729363 + .long 1014845818 + .long 1072788152 + .long 1058231231 + .long 1015777676 + .long 3949972341 + .long 1072800603 + .long 1044000607 + .long 1016786167 + .long 828946858 + .long 1072813191 + .long 1151779725 + .long 1015705409 + .long 2288159958 + .long 1072825915 + .long 3819481236 + .long 1016499965 + .long 1853186616 + .long 1072838778 + .long 2552227826 + .long 1015039787 + .long 1709341917 + .long 1072851781 + .long 1829350193 + .long 1015216097 + .long 4112506593 + .long 1072864925 + .long 1913391795 + .long 1015756674 + .long 2799960843 + .long 1072878213 + .long 1303423926 + .long 1015238005 + .long 171030293 + .long 1072891646 + .long 1574172746 + .long 1016061241 + .long 2992903935 + .long 1072905224 + .long 3424156969 + .long 1017196428 + .long 926591434 + .long 1072918951 + .long 1938513547 + .long 1017631273 + .long 887463926 + .long 1072932827 + .long 2804567149 + .long 1015390024 + .long 1276261410 + .long 1072946854 + .long 631083525 + .long 1017690182 + .long 569847337 + .long 1072961034 + .long 1623370770 + .long 1011049453 + .long 1617004845 + .long 1072975368 + .long 3667985273 + .long 1013894369 + .long 3049340112 + .long 1072989858 + .long 3145379760 + .long 1014403278 + .long 3577096743 + .long 1073004506 + .long 2603100681 + .long 1017152460 + .long 1990012070 + .long 1073019314 + .long 3249202951 + .long 1017448880 + .long 1453150081 + .long 1073034283 + .long 419288974 + .long 1016280325 + .long 917841882 + .long 1073049415 + .long 3793507337 + .long 1016095713 + .long 3712504873 + .long 1073064711 + .long 728023093 + .long 1016345318 + .long 363667784 + .long 1073080175 + .long 2582678538 + .long 1017123460 + .long 2956612996 + .long 1073095806 + .long 7592966 + .long 1016721543 + .long 2186617380 + .long 1073111608 + .long 228611441 + .long 1016696141 + .long 1719614412 + .long 1073127582 + .long 2261665670 + .long 1017457593 + .long 1013258798 + .long 1073143730 + .long 544148907 + .long 1017323666 + .long 3907805043 + .long 1073160053 + .long 2383914918 + .long 1017143586 + .long 1447192520 + .long 1073176555 + .long 1176412038 + .long 1017267372 + .long 1944781190 + .long 1073193236 + .long 2882956373 + .long 1013312481 + .long 919555682 + .long 1073210099 + .long 3154077648 + .long 1016528543 + .long 2571947538 + .long 1073227145 + .long 348651999 + .long 1016405780 + .long 2604962540 + .long 1073244377 + .long 3253791412 + .long 1015920431 + .long 1110089947 + .long 1073261797 + .long 1509121860 + .long 1014756995 + .long 2568320822 + .long 1073279406 + .long 2617649212 + .long 1017340090 + .long 2966275556 + .long 1073297207 + .long 553214634 + .long 1016457425 + .long 2682146383 + .long 1073315202 + .long 730975783 + .long 1014083580 + .long 2191782032 + .long 1073333393 + .long 1486499517 + .long 1016818996 + .long 2069751140 + .long 1073351782 + .long 2595788928 + .long 1016407932 + .long 2990417244 + .long 1073370371 + .long 1853053619 + .long 1015310724 + .long 1434058175 + .long 1073389163 + .long 2462790535 + .long 1015814775 + .long 2572866477 + .long 1073408159 + .long 3693944214 + .long 1017259110 + .long 3092190714 + .long 1073427362 + .long 2979333550 + .long 1017188654 + .long 4076559942 + .long 1073446774 + .long 174054861 + .long 1014300631 + .long 2420883922 + .long 1073466398 + .long 816778419 + .long 1014197934 + .long 3716502172 + .long 1073486235 + .long 3507050924 + .long 1015341199 + .long 777507147 + .long 1073506289 + .long 1821514088 + .long 1013410604 + .long 3706687593 + .long 1073526560 + .long 920623539 + .long 1016295433 + .long 1242007931 + .long 1073547053 + .long 2789017511 + .long 1014276997 + .long 3707479175 + .long 1073567768 + .long 3586233004 + .long 1015962192 + .long 64696965 + .long 1073588710 + .long 474650514 + .long 1016642419 + .long 863738718 + .long 1073609879 + .long 1614448851 + .long 1014281732 + .long 3884662774 + .long 1073631278 + .long 2450082086 + .long 1016164135 + .long 2728693977 + .long 1073652911 + .long 1101668360 + .long 1015989180 + .long 3999357479 + .long 1073674779 + .long 835814894 + .long 1015702697 + .long 1533953344 + .long 1073696886 + .long 1301400989 + .long 1014466875 + .long 2174652632 + .long 1073719233 + .type cexp_table,@object + .size cexp_table,5536 + .align 16 +_CONSTANTS: + .long 0 + .long 2145386496 + .long 0 + .long 1048576 + .type _CONSTANTS,@object + .size _CONSTANTS,16 + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .align 8 +zeros: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .type zeros,@object + .size zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cexpf.S b/external/sgx_libm/intel64/cexpf.S new file mode 100644 index 0000000000..91d33bc631 --- /dev/null +++ b/external/sgx_libm/intel64/cexpf.S @@ -0,0 +1,1892 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cexpf.c" + .text +..TXTST0: +# -- Begin cexpf + .text + .align 16,0x90 + .globl cexpf +cexpf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cexpf.1: +..L2: + +..B1.2: + movq %rsp, %rax + subq $216, %rsp + .cfi_def_cfa_offset 224 + movq %rax, 120(%rsp) + movss %xmm0, 96(%rsp) + pshufd $1, %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + movq %rbx, 128(%rsp) + cvtss2sd 104(%rsp), %xmm0 + cvtss2sd 96(%rsp), %xmm7 + lea cexpf_table(%rip), %r8 + movl 104(%rsp), %ecx + andl $2147483647, %ecx + subl $1, %ecx + cmpl $1202716671, %ecx + movl 96(%rsp), %eax + jae .L_2TAG_PACKET_0.0.1 + movq %xmm7, 72(%rsp) + mulsd 5136(%r8), %xmm7 + andl $2147483647, %eax + unpcklpd %xmm0, %xmm0 + movapd 5280(%r8), %xmm1 + cmpl $1132462080, %eax + addsd 5120(%r8), %xmm7 + jg .L_2TAG_PACKET_1.0.1 + mulpd %xmm0, %xmm1 + cvtsd2si %xmm1, %edx + addpd 5296(%r8), %xmm1 + movapd 5312(%r8), %xmm3 + subpd 5296(%r8), %xmm1 + movd %xmm7, %ecx + movq %xmm7, %xmm4 + movapd 5328(%r8), %xmm2 + andq $127, %rcx + movq (%r8,%rcx,8), %xmm5 + mulpd %xmm1, %xmm3 + addl $1865216, %edx + andq $63, %rdx + lea 1024(%r8), %rax + shlq $6, %rdx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + paddd 5200(%r8), %xmm4 + subpd %xmm3, %xmm0 + psllq $45, %xmm4 + mulpd 5344(%r8), %xmm1 + pand 5216(%r8), %xmm4 + movapd %xmm0, %xmm3 + subpd %xmm2, %xmm0 + movapd 5248(%r8), %xmm6 + orpd %xmm5, %xmm4 + movapd 16(%rax), %xmm5 + subpd %xmm0, %xmm3 + movapd %xmm0, 48(%rsp) + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subpd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subpd %xmm3, %xmm1 + movq %xmm4, 64(%rsp) + subsd 5120(%r8), %xmm7 + movapd 48(%rax), %xmm3 + addpd %xmm3, %xmm2 + subpd %xmm2, %xmm5 + mulpd %xmm5, %xmm1 + movapd 16(%rax), %xmm5 + mulpd 48(%rsp), %xmm2 + movq 72(%rsp), %xmm4 + mulsd 5152(%r8), %xmm7 + mulpd %xmm0, %xmm6 + mulpd 48(%rsp), %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm5 + subsd %xmm7, %xmm4 + movq 5168(%r8), %xmm7 + mulpd %xmm0, %xmm0 + movapd %xmm5, 16(%rsp) + movapd 5264(%r8), %xmm5 + mulsd %xmm4, %xmm7 + addpd 5232(%r8), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, 32(%rsp) + addpd 16(%rax), %xmm3 + addsd 5184(%r8), %xmm7 + addpd %xmm5, %xmm6 + movapd (%rax), %xmm0 + movsd %xmm6, %xmm5 + unpckhpd %xmm6, %xmm6 + unpcklpd %xmm5, %xmm5 + mulsd %xmm4, %xmm7 + mulpd 16(%rsp), %xmm6 + mulpd 48(%rsp), %xmm0 + mulpd %xmm5, %xmm2 + mulsd %xmm4, %xmm7 + movapd %xmm0, (%rsp) + addpd %xmm3, %xmm0 + movapd 16(%rax), %xmm5 + addsd %xmm4, %xmm7 + subpd %xmm3, %xmm5 + subpd %xmm0, %xmm3 + addpd 32(%rax), %xmm1 + mulsd 64(%rsp), %xmm7 + addpd 32(%rsp), %xmm5 + addpd (%rsp), %xmm3 + addpd %xmm5, %xmm1 + addpd %xmm3, %xmm1 + addsd 64(%rsp), %xmm7 + addpd %xmm2, %xmm1 + addpd %xmm6, %xmm1 + addpd %xmm0, %xmm1 + movsd %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + mulsd %xmm7, %xmm0 + mulsd %xmm7, %xmm1 + cvtsd2ss %xmm0, %xmm0 + cvtsd2ss %xmm1, %xmm1 + movd %xmm0, %edx + movd %xmm1, %eax + movd %xmm0, %ecx + andl $2139095040, %ecx + je .L_2TAG_PACKET_2.0.1 + movd %xmm1, %ecx + andl $2139095040, %ecx + je .L_2TAG_PACKET_2.0.1 + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_2.0.1: + movss _FLT_MIN_NORMAL(%rip), %xmm0 + mulss %xmm0, %xmm0 + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_0.0.1: + cmpl $-1, %ecx + je .L_2TAG_PACKET_3.0.1 + cmpl $2139095039, %ecx + jg .L_2TAG_PACKET_4.0.1 + je .L_2TAG_PACKET_5.0.1 + cvtss2sd 104(%rsp), %xmm0 + lea 80(%rsp), %rdi + lea 88(%rsp), %rsi + call sincos@PLT + cvtss2sd 96(%rsp), %xmm0 + call exp@PLT + movq %xmm0, %xmm1 + mulsd 88(%rsp), %xmm0 + mulsd 80(%rsp), %xmm1 + cvtsd2ss %xmm0, %xmm0 + cvtsd2ss %xmm1, %xmm1 + movd %xmm0, %eax + movd %xmm1, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_5.0.1: + movl $2147483647, %ecx + movss 104(%rsp), %xmm1 + movss 96(%rsp), %xmm0 + andl %eax, %ecx + cmpl $2139095040, %ecx + jg .L_2TAG_PACKET_6.0.1 + je .L_2TAG_PACKET_7.0.1 + subss %xmm1, %xmm1 + movd %xmm1, %edx + movl %edx, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_7.0.1: + cmpl $2139095040, %eax + je .L_2TAG_PACKET_8.0.1 + movl $0, %eax + movl $0, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_8.0.1: + subss %xmm1, %xmm1 + movl $2139095040, %eax + movd %xmm1, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_6.0.1: + mulss %xmm0, %xmm0 + movd %xmm0, %eax + movl %eax, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_4.0.1: + movl $2147483647, %ecx + movss 104(%rsp), %xmm1 + andl %eax, %ecx + movss 96(%rsp), %xmm0 + cmpl $2139095040, %ecx + mulss %xmm1, %xmm1 + jg .L_2TAG_PACKET_9.0.1 + je .L_2TAG_PACKET_10.0.1 + movd %xmm1, %eax + movl %eax, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_10.0.1: + cmpl $2139095040, %eax + je .L_2TAG_PACKET_11.0.1 + movl $0, %eax + movl $0, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_11.0.1: + movl $2139095040, %eax + movd %xmm1, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_9.0.1: + mulss %xmm0, %xmm0 + movd %xmm0, %eax + movd %xmm1, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_3.0.1: + movl $2147483647, %ecx + andl %eax, %ecx + je .L_2TAG_PACKET_12.0.1 + cmpl $2139095040, %ecx + jg .L_2TAG_PACKET_13.0.1 + je .L_2TAG_PACKET_14.0.1 + cmpl $1124073472, %ecx + jg .L_2TAG_PACKET_15.0.1 + movq %xmm7, %xmm0 + mulsd 5136(%r8), %xmm7 + addsd 5120(%r8), %xmm7 + movd %xmm7, %ecx + movq %xmm7, %xmm4 + andq $127, %rcx + movq (%r8,%rcx,8), %xmm5 + paddd 5200(%r8), %xmm4 + subsd 5120(%r8), %xmm7 + mulsd 5152(%r8), %xmm7 + subsd %xmm7, %xmm0 + movq 5168(%r8), %xmm7 + mulsd %xmm0, %xmm7 + addsd 5184(%r8), %xmm7 + psllq $45, %xmm4 + mulsd %xmm0, %xmm7 + pand 5216(%r8), %xmm4 + mulsd %xmm0, %xmm7 + orpd %xmm5, %xmm4 + addsd %xmm0, %xmm7 + mulsd %xmm4, %xmm7 + addsd %xmm4, %xmm7 + cvtsd2ss %xmm7, %xmm7 + movd %xmm7, %eax + movl 104(%rsp), %edx + andl $-2147483648, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_12.0.1: + movl 104(%rsp), %edx + movl $1065353216, %eax + andl $-2147483648, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_15.0.1: + movl $2139095039, %ecx + testl $-2147483648, %eax + movl $8388608, %eax + cmovz %ecx, %eax + movl 104(%rsp), %edx + andl $2147483647, %eax + andl $-2147483648, %edx + movd %eax, %xmm0 + mulss %xmm0, %xmm0 + movd %xmm0, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_14.0.1: + movl $2139095040, %ecx + andl $-2147483648, %eax + movl 104(%rsp), %edx + cmovz %ecx, %eax + andl $-2147483648, %edx + andl $2147483647, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_13.0.1: + movss 96(%rsp), %xmm0 + movl 104(%rsp), %edx + addss %xmm0, %xmm0 + movd %xmm0, %eax + andl $-2147483648, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_1.0.1: + cmpl $2139095040, %eax + movl 96(%rsp), %ecx + jg .L_2TAG_PACKET_16.0.1 + movl $8388608, %eax + movl $2139095039, %edx + testl $-2147483648, %ecx + cmovz %edx, %eax + movl $0, %edx + cmpl $-8388608, %ecx + cmove %edx, %eax + cmpl $2139095040, %ecx + cmove %ecx, %eax + movd %eax, %xmm7 + mulss %xmm7, %xmm7 + mulpd %xmm0, %xmm1 + cvtsd2si %xmm1, %edx + addpd 5296(%r8), %xmm1 + movapd 5312(%r8), %xmm3 + subpd 5296(%r8), %xmm1 + movapd 5328(%r8), %xmm2 + mulpd %xmm1, %xmm3 + addl $1865216, %edx + andq $63, %rdx + lea 1024(%r8), %rax + shlq $6, %rdx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subpd %xmm3, %xmm0 + mulpd 5344(%r8), %xmm1 + movapd %xmm0, %xmm3 + subpd %xmm2, %xmm0 + movapd 5248(%r8), %xmm6 + movapd 16(%rax), %xmm5 + subpd %xmm0, %xmm3 + movapd %xmm0, 48(%rsp) + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subpd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subpd %xmm3, %xmm1 + movapd 48(%rax), %xmm3 + addpd %xmm3, %xmm2 + subpd %xmm2, %xmm5 + mulpd %xmm5, %xmm1 + movapd 16(%rax), %xmm5 + mulpd 48(%rsp), %xmm2 + mulpd %xmm0, %xmm6 + mulpd 48(%rsp), %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + movapd %xmm5, 16(%rsp) + movapd 5264(%r8), %xmm5 + addpd 5232(%r8), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, 32(%rsp) + addpd 16(%rax), %xmm3 + addpd %xmm5, %xmm6 + movapd (%rax), %xmm0 + movsd %xmm6, %xmm5 + unpckhpd %xmm6, %xmm6 + unpcklpd %xmm5, %xmm5 + mulpd 16(%rsp), %xmm6 + mulpd 48(%rsp), %xmm0 + mulpd %xmm5, %xmm2 + movapd %xmm0, (%rsp) + addpd %xmm3, %xmm0 + movapd 16(%rax), %xmm5 + subpd %xmm3, %xmm5 + subpd %xmm0, %xmm3 + addpd 32(%rax), %xmm1 + addpd 32(%rsp), %xmm5 + addpd (%rsp), %xmm3 + addpd %xmm5, %xmm1 + addpd %xmm3, %xmm1 + addpd %xmm2, %xmm1 + addpd %xmm6, %xmm1 + addpd %xmm0, %xmm1 + movsd %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + cvtsd2ss %xmm0, %xmm0 + cvtsd2ss %xmm1, %xmm1 + mulss %xmm7, %xmm0 + mulss %xmm7, %xmm1 + movd %xmm0, %edx + movd %xmm1, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret +.L_2TAG_PACKET_16.0.1: + movss 96(%rsp), %xmm0 + mulss %xmm0, %xmm0 + movd %xmm0, %eax + movl %eax, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 128(%rsp), %rbx + movq 120(%rsp), %rsp + ret + .cfi_def_cfa_offset 8 +..B1.3: + .align 16,0x90 + .cfi_endproc + .type cexpf,@function + .size cexpf,.-cexpf + .data +# -- End cexpf + .section .rodata, "a" + .align 16 + .align 16 +cexpf_table: + .long 0 + .long 0 + .long 2851812149 + .long 5693 + .long 1048019041 + .long 11418 + .long 3899555717 + .long 17173 + .long 3541402996 + .long 22960 + .long 702412510 + .long 28779 + .long 410360776 + .long 34629 + .long 3402036099 + .long 40510 + .long 1828292879 + .long 46424 + .long 728909815 + .long 52370 + .long 852742562 + .long 58348 + .long 2952712987 + .long 64358 + .long 3490863953 + .long 70401 + .long 3228316108 + .long 76477 + .long 2930322912 + .long 82586 + .long 3366293073 + .long 88728 + .long 1014845819 + .long 94904 + .long 948735466 + .long 101113 + .long 3949972341 + .long 107355 + .long 2214878420 + .long 113632 + .long 828946858 + .long 119943 + .long 586995997 + .long 126288 + .long 2288159958 + .long 132667 + .long 2440944790 + .long 139081 + .long 1853186616 + .long 145530 + .long 1337108031 + .long 152014 + .long 1709341917 + .long 158533 + .long 3790955393 + .long 165087 + .long 4112506593 + .long 171677 + .long 3504003472 + .long 178303 + .long 2799960843 + .long 184965 + .long 2839424854 + .long 191663 + .long 171030293 + .long 198398 + .long 4232894513 + .long 205168 + .long 2992903935 + .long 211976 + .long 1603444721 + .long 218821 + .long 926591435 + .long 225703 + .long 1829099622 + .long 232622 + .long 887463927 + .long 239579 + .long 3272845541 + .long 246573 + .long 1276261410 + .long 253606 + .long 78413852 + .long 260677 + .long 569847338 + .long 267786 + .long 3645941911 + .long 274933 + .long 1617004845 + .long 282120 + .long 3978100823 + .long 289345 + .long 3049340112 + .long 296610 + .long 4040676318 + .long 303914 + .long 3577096743 + .long 311258 + .long 2583551245 + .long 318642 + .long 1990012071 + .long 326066 + .long 2731501122 + .long 333530 + .long 1453150082 + .long 341035 + .long 3395129871 + .long 348580 + .long 917841882 + .long 356167 + .long 3566716925 + .long 363794 + .long 3712504873 + .long 371463 + .long 2321106615 + .long 379174 + .long 363667784 + .long 386927 + .long 3111574537 + .long 394721 + .long 2956612997 + .long 402558 + .long 885834528 + .long 410438 + .long 2186617381 + .long 418360 + .long 3561793907 + .long 426325 + .long 1719614413 + .long 434334 + .long 1963711167 + .long 442386 + .long 1013258799 + .long 450482 + .long 4182873220 + .long 458621 + .long 3907805044 + .long 466805 + .long 1218806132 + .long 475034 + .long 1447192521 + .long 483307 + .long 1339972927 + .long 491625 + .long 1944781191 + .long 499988 + .long 19972402 + .long 508397 + .long 919555682 + .long 516851 + .long 1413356050 + .long 525351 + .long 2571947539 + .long 533897 + .long 1176749997 + .long 542490 + .long 2604962541 + .long 551129 + .long 3649726105 + .long 559815 + .long 1110089947 + .long 568549 + .long 380978316 + .long 577330 + .long 2568320822 + .long 586158 + .long 194117574 + .long 595035 + .long 2966275557 + .long 603959 + .long 3418903055 + .long 612932 + .long 2682146384 + .long 621954 + .long 1892288442 + .long 631025 + .long 2191782032 + .long 640145 + .long 434316067 + .long 649315 + .long 2069751141 + .long 658534 + .long 3964284211 + .long 667803 + .long 2990417245 + .long 677123 + .long 321958744 + .long 686494 + .long 1434058175 + .long 695915 + .long 3218338682 + .long 705387 + .long 2572866477 + .long 714911 + .long 697153126 + .long 724487 + .long 3092190715 + .long 734114 + .long 2380618042 + .long 743794 + .long 4076559943 + .long 753526 + .long 815859274 + .long 763312 + .long 2420883922 + .long 773150 + .long 1540824585 + .long 783042 + .long 3716502172 + .long 792987 + .long 1610600570 + .long 802987 + .long 777507147 + .long 813041 + .long 2483480501 + .long 823149 + .long 3706687593 + .long 833312 + .long 1432208378 + .long 843531 + .long 1242007932 + .long 853805 + .long 135105010 + .long 864135 + .long 3707479175 + .long 874520 + .long 382305176 + .long 884963 + .long 64696965 + .long 895462 + .long 4076975200 + .long 906017 + .long 863738719 + .long 916631 + .long 351641897 + .long 927302 + .long 3884662774 + .long 938030 + .long 4224142467 + .long 948817 + .long 2728693978 + .long 959663 + .long 764307441 + .long 970568 + .long 3999357479 + .long 981531 + .long 929806999 + .long 992555 + .long 1533953344 + .long 1003638 + .long 2912730644 + .long 1014781 + .long 2174652632 + .long 1025985 + .long 730821105 + .long 1037250 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 3217031168 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 3220176896 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 1069547520 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 1071644672 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 1072693248 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 1069547520 + .long 0 + .long 1127743488 + .long 0 + .long 0 + .long 1697350398 + .long 1080497479 + .long 0 + .long 0 + .long 4277811695 + .long 1064709698 + .long 0 + .long 0 + .long 3082479990 + .long 1069897045 + .long 0 + .long 0 + .long 4294966960 + .long 1071644671 + .long 0 + .long 0 + .long 130944 + .long 0 + .long 130944 + .long 0 + .long 0 + .long 2146435072 + .long 0 + .long 2146435072 + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .long 1841940611 + .long 1076125488 + .long 1841940611 + .long 1076125488 + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .long 1413480448 + .long 1069097467 + .long 1413480448 + .long 1069097467 + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .long 771977331 + .long 996350346 + .long 771977331 + .long 996350346 + .type cexpf_table,@object + .size cexpf_table,5360 + .align 16 +_FLT_MIN_NORMAL: + .long 8388608 + .long 8388608 + .type _FLT_MIN_NORMAL,@object + .size _FLT_MIN_NORMAL,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cexpl.S b/external/sgx_libm/intel64/cexpl.S new file mode 100644 index 0000000000..c27329832d --- /dev/null +++ b/external/sgx_libm/intel64/cexpl.S @@ -0,0 +1,649 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cexpl.c" + .text +..TXTST0: +# -- Begin cexpl + .text + .align 16,0x90 + .globl cexpl +cexpl: +# parameter 1: 320 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cexpl.1: +..L2: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + subq $288, %rsp + .cfi_def_cfa_offset 320 + xorb %r15b, %r15b + fldt .L_2il0floatpacket.7(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 272(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 240(%rsp) + fldt 240(%rsp) + fstpt 256(%rsp) +..B1.2: + fnstcw 98(%rsp) +..B1.3: + movzwl 98(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 96(%rsp) +..B1.5: + fldcw 96(%rsp) +..B1.6: + movb $1, %r15b +..B1.7: + movzwl 328(%rsp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.31 +..B1.8: + testl %edx, %edx + jle ..B1.54 +..B1.9: + movzwl 344(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jge ..B1.31 +..B1.10: + testl %eax, %eax + jle ..B1.52 +..B1.11: + fldt 320(%rsp) + lea 176(%rsp), %rdi + fstpt 32(%rdi) + lea 208(%rsp), %rsi + fldt -128(%rsi) + fstpt 16(%rsi) +..___tag_value_cexpl.10: + call __libm_expl_k80@PLT +..___tag_value_cexpl.11: +..B1.62: + fstpt 64(%rsp) +..B1.12: + movzwl 184(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.51 +..B1.13: + testl %eax, %eax + je ..B1.22 +..B1.14: + fldt 64(%rsp) + lea 48+_CONSTANTS(%rip), %rax + fldt 176(%rsp) + fldt 192(%rsp) + fldt .L_2il0floatpacket.8(%rip) + fldt (%rax) + faddp %st, %st(4) + fxch %st(3) + fstpt (%rsp) + fld %st(1) + movl (%rsp), %r14d + fadd %st(1), %st + fld %st(0) + fmulp %st, %st(4) + fld %st(3) + fsub %st(1), %st + fsubrp %st, %st(4) + fxch %st(3) + fstpt 32(%rsp) + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fxch %st(2) + fsubr %st(3), %st + fsubrp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt 352(%rsp) + fstpt (%rsp) + lea 160(%rsp), %rdi + fstpt -96(%rdi) +..___tag_value_cexpl.13: + call __libm_cosl_k80@PLT +..___tag_value_cexpl.14: +..B1.63: + fldt 64(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 320 +..B1.15: + fldt 144(%rsp) + lea 16+_CONSTANTS(%rip), %rax + fld %st(0) + fldt 160(%rsp) + movzwl 344(%rsp), %edx + fadd %st, %st(1) + andl $32767, %edx + fxch %st(1) + fsub %st, %st(2) + cmpl $16183, %edx + fxch %st(2) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.8(%rip) + fldt (%rax) + fxch %st(1) + fmul %st(3), %st + fld %st(0) + fsub %st(4), %st + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(3) + jge ..B1.17 +..B1.16: + fldt 336(%rsp) + lea 32+_CONSTANTS(%rip), %rbx + fldt 80(%rsp) + fstpt 128(%rsp) + fldt (%rbx) + fmulp %st, %st(1) + fstpt 112(%rsp) + movzwl 120(%rsp), %eax + movl %eax, %ebx + andl $-32768, %eax + andl $32767, %ebx + orl $-49153, %eax + addl $-16639, %ebx + movw %ax, 120(%rsp) + fldt 112(%rsp) + jmp ..B1.19 +..B1.17: + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fldt 352(%rsp) + lea 128(%rsp), %rdi + fstpt (%rsp) + fxch %st(2) + fstpt 16(%rsp) + fxch %st(1) + fstpt -96(%rdi) + fstpt -64(%rdi) +..___tag_value_cexpl.17: + call __libm_sinl_k80@PLT +..___tag_value_cexpl.18: +..B1.64: + fldt 64(%rsp) + fldt 32(%rsp) + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 320 +..B1.18: + fldt 112(%rsp) + xorl %ebx, %ebx + fmul %st(4), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fldt 128(%rsp) + fmulp %st, %st(5) + fxch %st(4) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 128(%rsp) + fxch %st(3) +..B1.19: + fldt 80(%rsp) + fld %st(1) + movl %r14d, %edi + fadd %st(1), %st + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fldt 32(%rsp) + fldt .L_2il0floatpacket.8(%rip) + addq $-32, %rsp + .cfi_def_cfa_offset 352 + fmul %st(3), %st + fld %st(0) + fsub %st(4), %st + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(4) + fmul %st(6), %st + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fxch %st(3) + fmul %st, %st(5) + fxch %st(5) + fstpt (%rsp) + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + fstpt 80(%rsp) +..___tag_value_cexpl.21: + call __libm_scalbl_k80@PLT +..___tag_value_cexpl.22: +..B1.65: + fldt 80(%rsp) + fldt 48(%rsp) + fldt 32(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 320 +..B1.20: + fxch %st(3) + fstpt 240(%rsp) + fld %st(1) + fmul %st(3), %st + addl %ebx, %r14d + fxch %st(1) + fmul %st, %st(2) + fldt 32(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 352 + fld %st(0) + movl %r14d, %edi + fmulp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) +..___tag_value_cexpl.25: + call __libm_scalbl_k80@PLT +..___tag_value_cexpl.26: +..B1.66: + addq $32, %rsp + .cfi_def_cfa_offset 320 +..B1.21: + fstpt 256(%rsp) + jmp ..B1.44 +..B1.22: + lea 16+_CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) +..B1.23: + fldt 16(%rsp) + fstpt 176(%rsp) + fldt 336(%rsp) + fstpt (%rsp) + fldt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fstpt (%rsp) + call cosl@PLT +..B1.67: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fldt 16(%rsp) + fmulp %st, %st(1) + movzwl 344(%rsp), %eax + testl $32767, %eax + fstpt 240(%rsp) + jle ..B1.25 +..B1.24: + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fldt 16(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.68: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fldt 16(%rsp) + fmulp %st, %st(1) + fstpt 256(%rsp) + jmp ..B1.26 +..B1.25: + fldt (%rsp) + fldt 16(%rsp) + fmulp %st, %st(1) + fstpt 256(%rsp) +..B1.26: + testb %r15b, %r15b + je ..B1.28 +..B1.27: + fldt 64(%rsp) + fstpt (%rsp) +..B1.69: + fldcw 98(%rsp) +..B1.28: + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.50 +..B1.29: + fldt 240(%rsp) + fldt 256(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.49 +..B1.30: + addq $288, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 320 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.31: + cmpq $0, 336(%rsp) + jne ..B1.33 +..B1.32: + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fldt 336(%rsp) + fstpt (%rsp) + call expl@PLT +..B1.70: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fldt 336(%rsp) + fstpt 256(%rsp) + fstpt 240(%rsp) + jmp ..B1.44 +..B1.33: + movzwl 344(%rsp), %ebx + andl $32767, %ebx + cmpl $32767, %ebx + jge ..B1.36 +..B1.34: + fldt 320(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fstpt (%rsp) + call expl@PLT +..B1.72: + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 320 + fldt 336(%rsp) + fstpt (%rsp) + fldt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fstpt (%rsp) + call cosl@PLT +..B1.71: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fldt 16(%rsp) + testl %ebx, %ebx + fmulp %st, %st(1) + fstpt 240(%rsp) + jle ..B1.56 +..B1.35: + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fldt 16(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.73: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fldt 16(%rsp) + fmulp %st, %st(1) + fstpt 256(%rsp) + jmp ..B1.44 +..B1.36: + cmpl $32767, %edx + jge ..B1.38 +..B1.37: + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fldt 352(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.74: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fstpt 240(%rsp) + fldt 240(%rsp) + fstpt 256(%rsp) + jmp ..B1.44 +..B1.38: + cmpl $-2147483648, 324(%rsp) + jne ..B1.40 +..B1.39: + cmpl $0, 320(%rsp) + je ..B1.41 +..B1.40: + fldt 320(%rsp) + fmul %st(0), %st + fstpt 240(%rsp) + fldt 240(%rsp) + fldt 336(%rsp) + fmulp %st, %st(1) + fstpt 256(%rsp) + jmp ..B1.44 +..B1.41: + testb $-128, 329(%rsp) + je ..B1.43 +..B1.42: + fldt 336(%rsp) + fmul %st(0), %st + fstpt 336(%rsp) + fldt 80(%rsp) + fstpt 240(%rsp) + fldt 240(%rsp) + fstpt 256(%rsp) + jmp ..B1.44 +..B1.43: + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fldt 336(%rsp) + fstpt (%rsp) + call expl@PLT +..B1.76: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fstpt 240(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 336 + fldt 352(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.75: + addq $16, %rsp + .cfi_def_cfa_offset 320 + fstpt 256(%rsp) +..B1.44: + testb %r15b, %r15b + je ..B1.46 +..B1.45: + fldcw 98(%rsp) +..B1.46: + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.50 +..B1.47: + fldt 240(%rsp) + fldt 256(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.49 +..B1.48: + addq $288, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 320 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.49: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.50: + call __stack_chk_fail@PLT +..B1.51: + lea _CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) + jmp ..B1.23 +..B1.52: + cmpl $0, 340(%rsp) + jne ..B1.11 +..B1.53: + cmpl $0, 336(%rsp) + jne ..B1.11 + jmp ..B1.31 +..B1.54: + cmpl $0, 324(%rsp) + jne ..B1.9 +..B1.55: + cmpl $0, 320(%rsp) + jne ..B1.9 + jmp ..B1.31 +..B1.56: + cmpq $0, 320(%rsp) + je ..B1.35 +..B1.57: + fldt (%rsp) + fldt 16(%rsp) + fmulp %st, %st(1) + fstpt 256(%rsp) + jmp ..B1.44 + .align 16,0x90 + .cfi_endproc + .type cexpl,@function + .size cexpl,.-cexpl + .data +# -- End cexpl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,64 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cimag.S b/external/sgx_libm/intel64/cimag.S new file mode 100644 index 0000000000..ba2d45e4e8 --- /dev/null +++ b/external/sgx_libm/intel64/cimag.S @@ -0,0 +1,65 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cimag.c" + .text +..TXTST0: +# -- Begin cimag + .text + .align 16,0x90 + .globl cimag +cimag: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cimag.1: +..L2: + + movaps %xmm1, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type cimag,@function + .size cimag,.-cimag + .data +# -- End cimag + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cimagf.S b/external/sgx_libm/intel64/cimagf.S new file mode 100644 index 0000000000..ea0a8cb710 --- /dev/null +++ b/external/sgx_libm/intel64/cimagf.S @@ -0,0 +1,66 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cimagf.c" + .text +..TXTST0: +# -- Begin cimagf + .text + .align 16,0x90 + .globl cimagf +cimagf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cimagf.1: +..L2: + + movsd %xmm0, -8(%rsp) + movss -4(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type cimagf,@function + .size cimagf,.-cimagf + .data +# -- End cimagf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cimagl.S b/external/sgx_libm/intel64/cimagl.S new file mode 100644 index 0000000000..9a42707a5b --- /dev/null +++ b/external/sgx_libm/intel64/cimagl.S @@ -0,0 +1,65 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cimagl.c" + .text +..TXTST0: +# -- Begin cimagl + .text + .align 16,0x90 + .globl cimagl +cimagl: +# parameter 1: 8 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cimagl.1: +..L2: + + fldt 24(%rsp) + ret + .align 16,0x90 + .cfi_endproc + .type cimagl,@function + .size cimagl,.-cimagl + .data +# -- End cimagl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/clog.S b/external/sgx_libm/intel64/clog.S new file mode 100644 index 0000000000..6d06c0a0c6 --- /dev/null +++ b/external/sgx_libm/intel64/clog.S @@ -0,0 +1,615 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clog.c" + .text +..TXTST0: +# -- Begin clog + .text + .align 16,0x90 + .globl clog +clog: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_clog.1: +..L2: + + movq %fs:40, %rax + subq $120, %rsp + .cfi_def_cfa_offset 128 + movsd %xmm0, 40(%rsp) + xorq %rsp, %rax + movsd %xmm1, 48(%rsp) + movzwl 46(%rsp), %edx + andl $32752, %edx + movq %rax, 104(%rsp) + movzwl 54(%rsp), %eax + andl $32752, %eax + shrl $4, %edx + shrl $4, %eax + cmpl $2047, %edx + jge ..B1.26 +..B1.2: + cmpl $2047, %eax + jge ..B1.62 +..B1.3: + movsd 40(%rsp), %xmm14 + movaps %xmm14, %xmm7 + pxor %xmm2, %xmm2 + movsd 48(%rsp), %xmm1 + andps .L_2il0floatpacket.10(%rip), %xmm7 + movaps %xmm1, %xmm6 + andps .L_2il0floatpacket.10(%rip), %xmm6 + ucomisd %xmm2, %xmm7 + jp ..B1.4 + je ..B1.40 +..B1.4: + comisd %xmm7, %xmm6 + jbe ..B1.6 +..B1.5: + movaps %xmm7, %xmm2 + movsd %xmm7, 32(%rsp) + movaps %xmm6, %xmm7 + movsd %xmm6, (%rsp) + movaps %xmm2, %xmm6 + movsd %xmm2, 8(%rsp) + jmp ..B1.7 +..B1.6: + movsd %xmm6, 8(%rsp) + movsd %xmm7, (%rsp) +..B1.7: + lea 8+_CONSTANTS(%rip), %rax + comisd (%rax), %xmm7 + jb ..B1.19 +..B1.8: + lea 16+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm2 + comisd %xmm7, %xmm2 + jb ..B1.19 +..B1.9: + lea 40+_CONSTANTS(%rip), %rdx + lea _CONSTANTS(%rip), %rax + movaps %xmm7, %xmm5 + mulsd %xmm7, %xmm5 + comisd (%rdx), %xmm6 + movsd .L_2il0floatpacket.11(%rip), %xmm2 + movsd (%rax), %xmm4 + jbe ..B1.12 +..B1.10: + movaps %xmm6, %xmm3 + mulsd %xmm6, %xmm3 + addsd %xmm3, %xmm5 + subsd %xmm2, %xmm5 + andps .L_2il0floatpacket.10(%rip), %xmm5 + comisd %xmm5, %xmm4 + ja ..B1.13 + jmp ..B1.18 +..B1.12: + subsd %xmm2, %xmm5 + andps .L_2il0floatpacket.10(%rip), %xmm5 + comisd %xmm5, %xmm4 + jbe ..B1.18 +..B1.13: + movzwl 14(%rsp), %eax + andl $32752, %eax + cmpl $14608, %eax + jl ..B1.15 +..B1.14: + movsd .L_2il0floatpacket.8(%rip), %xmm13 + lea 56+_Q1(%rip), %rax + movsd .L_2il0floatpacket.8(%rip), %xmm10 + lea 48+_Q1(%rip), %rdx + movsd (%rsp), %xmm11 + lea 40+_Q1(%rip), %rcx + movsd .L_2il0floatpacket.9(%rip), %xmm4 + lea 32+_Q1(%rip), %rsi + movsd (%rax), %xmm6 + lea 24+_Q1(%rip), %rdi + lea 16+_Q1(%rip), %r8 + lea 8+_Q1(%rip), %r9 + lea _Q1(%rip), %r10 + mulsd %xmm7, %xmm13 + movaps %xmm13, %xmm15 + subsd %xmm7, %xmm15 + movsd %xmm15, 16(%rsp) + movsd 16(%rsp), %xmm12 + subsd %xmm12, %xmm13 + movsd 8(%rsp), %xmm12 + mulsd %xmm12, %xmm10 + subsd %xmm13, %xmm11 + movaps %xmm10, %xmm9 + movaps %xmm13, %xmm5 + mulsd %xmm13, %xmm5 + subsd %xmm12, %xmm9 + mulsd %xmm4, %xmm13 + movsd %xmm9, 16(%rsp) + movaps %xmm5, %xmm7 + movsd 16(%rsp), %xmm9 + mulsd %xmm11, %xmm13 + subsd %xmm9, %xmm10 + mulsd %xmm11, %xmm11 + subsd %xmm10, %xmm12 + movaps %xmm10, %xmm9 + mulsd %xmm10, %xmm9 + mulsd %xmm4, %xmm10 + addsd %xmm9, %xmm7 + mulsd %xmm12, %xmm10 + mulsd %xmm12, %xmm12 + movaps %xmm7, %xmm4 + subsd %xmm2, %xmm7 + subsd %xmm5, %xmm4 + movsd %xmm4, 16(%rsp) + movaps %xmm7, %xmm8 + movsd 16(%rsp), %xmm4 + subsd %xmm4, %xmm9 + addsd %xmm9, %xmm8 + movaps %xmm8, %xmm4 + movaps %xmm8, %xmm2 + movaps %xmm8, %xmm5 + subsd %xmm7, %xmm4 + addsd %xmm13, %xmm2 + movsd %xmm4, 16(%rsp) + movaps %xmm2, %xmm3 + movsd 16(%rsp), %xmm4 + movaps %xmm2, %xmm15 + subsd %xmm4, %xmm5 + addsd %xmm10, %xmm3 + subsd %xmm8, %xmm15 + movsd %xmm5, 24(%rsp) + subsd %xmm15, %xmm13 + movsd 16(%rsp), %xmm4 + subsd %xmm4, %xmm9 + movsd 24(%rsp), %xmm4 + subsd %xmm4, %xmm7 + movaps %xmm3, %xmm4 + addsd %xmm7, %xmm9 + addsd %xmm11, %xmm4 + movaps %xmm4, %xmm5 + addsd %xmm12, %xmm5 + mulsd %xmm5, %xmm6 + movaps %xmm5, %xmm7 + mulsd %xmm5, %xmm7 + addsd (%rdx), %xmm6 + mulsd %xmm5, %xmm6 + addsd (%rcx), %xmm6 + mulsd %xmm5, %xmm6 + addsd (%rsi), %xmm6 + mulsd %xmm5, %xmm6 + addsd (%rdi), %xmm6 + mulsd %xmm5, %xmm6 + addsd (%r8), %xmm6 + mulsd %xmm5, %xmm6 + addsd (%r9), %xmm6 + mulsd %xmm5, %xmm6 + addsd (%r10), %xmm6 + mulsd %xmm7, %xmm6 + movaps %xmm2, %xmm7 + subsd %xmm15, %xmm7 + movsd %xmm7, 16(%rsp) + movsd 16(%rsp), %xmm7 + subsd %xmm7, %xmm8 + movaps %xmm3, %xmm7 + addsd %xmm8, %xmm13 + movaps %xmm3, %xmm8 + subsd %xmm2, %xmm8 + addsd %xmm13, %xmm9 + subsd %xmm8, %xmm7 + subsd %xmm8, %xmm10 + movsd %xmm7, 16(%rsp) + movsd 16(%rsp), %xmm7 + subsd %xmm7, %xmm2 + movaps %xmm4, %xmm7 + subsd %xmm3, %xmm7 + addsd %xmm2, %xmm10 + subsd %xmm7, %xmm11 + addsd %xmm10, %xmm9 + movaps %xmm4, %xmm2 + subsd %xmm7, %xmm2 + movsd %xmm2, 16(%rsp) + movsd 16(%rsp), %xmm2 + subsd %xmm2, %xmm3 + movaps %xmm5, %xmm2 + addsd %xmm3, %xmm11 + movaps %xmm5, %xmm3 + subsd %xmm4, %xmm3 + addsd %xmm11, %xmm9 + subsd %xmm3, %xmm2 + subsd %xmm3, %xmm12 + movsd %xmm2, 16(%rsp) + movsd 16(%rsp), %xmm2 + subsd %xmm2, %xmm4 + addsd %xmm4, %xmm12 + addsd %xmm12, %xmm9 + addsd %xmm6, %xmm9 + addsd %xmm9, %xmm5 + mulsd .L_2il0floatpacket.7(%rip), %xmm5 + movsd %xmm5, 32(%rsp) + movsd %xmm5, 56(%rsp) + jmp ..B1.22 +..B1.15: + movzwl 6(%rsp), %eax + andl $32752, %eax + cmpl $16368, %eax + je ..B1.31 +..B1.16: + movsd %xmm5, 32(%rsp) +..B1.17: + movsd .L_2il0floatpacket.8(%rip), %xmm5 + lea 56+_Q1(%rip), %rax + movsd (%rsp), %xmm11 + lea 48+_Q1(%rip), %rdx + lea 40+_Q1(%rip), %rcx + lea 32+_Q1(%rip), %rsi + lea 24+_Q1(%rip), %rdi + lea 16+_Q1(%rip), %r8 + movsd (%rax), %xmm13 + lea 8+_Q1(%rip), %r9 + lea _Q1(%rip), %r10 + mulsd %xmm7, %xmm5 + movaps %xmm5, %xmm3 + subsd %xmm7, %xmm3 + movsd %xmm3, 16(%rsp) + movsd 16(%rsp), %xmm4 + subsd %xmm4, %xmm5 + movaps %xmm5, %xmm8 + subsd %xmm5, %xmm11 + mulsd %xmm5, %xmm8 + subsd %xmm2, %xmm8 + movsd .L_2il0floatpacket.9(%rip), %xmm2 + mulsd %xmm5, %xmm2 + mulsd %xmm11, %xmm2 + movaps %xmm8, %xmm15 + mulsd %xmm11, %xmm11 + movaps %xmm2, %xmm3 + addsd %xmm11, %xmm3 + movaps %xmm3, %xmm6 + addsd %xmm3, %xmm15 + subsd %xmm2, %xmm6 + mulsd %xmm15, %xmm13 + movaps %xmm15, %xmm9 + movaps %xmm15, %xmm12 + movsd %xmm6, 16(%rsp) + subsd %xmm8, %xmm9 + mulsd %xmm15, %xmm12 + addsd (%rdx), %xmm13 + mulsd %xmm15, %xmm13 + movsd 16(%rsp), %xmm7 + movsd %xmm9, 16(%rsp) + subsd %xmm7, %xmm11 + addsd (%rcx), %xmm13 + mulsd %xmm15, %xmm13 + movsd 16(%rsp), %xmm10 + addsd (%rsi), %xmm13 + subsd %xmm10, %xmm3 + mulsd %xmm15, %xmm13 + addsd %xmm11, %xmm3 + addsd (%rdi), %xmm13 + mulsd %xmm15, %xmm13 + addsd (%r8), %xmm13 + mulsd %xmm15, %xmm13 + addsd (%r9), %xmm13 + mulsd %xmm15, %xmm13 + addsd (%r10), %xmm13 + mulsd %xmm12, %xmm13 + addsd %xmm13, %xmm3 + addsd %xmm15, %xmm3 + mulsd .L_2il0floatpacket.7(%rip), %xmm3 + movsd %xmm3, 56(%rsp) + jmp ..B1.22 +..B1.18: + movsd %xmm5, 32(%rsp) +..B1.19: + movaps %xmm14, %xmm0 + lea 72(%rsp), %rdi +..___tag_value_clog.4: + call __libm_hypot2_k64@PLT +..___tag_value_clog.5: +..B1.20: + lea 24+_CONSTANTS(%rip), %rax + lea 32+_CONSTANTS(%rip), %rdx + lea 88(%rsp), %rdi + movsd (%rax), %xmm1 + mulsd %xmm0, %xmm1 + movsd (%rdx), %xmm2 + mulsd %xmm0, %xmm2 + movsd %xmm1, -80(%rdi) + movsd -16(%rdi), %xmm0 + movsd -8(%rdi), %xmm1 + movsd %xmm2, (%rsp) +..___tag_value_clog.6: + call __libm_log_k64@PLT +..___tag_value_clog.7: +..B1.21: + movsd .L_2il0floatpacket.7(%rip), %xmm0 + movsd 88(%rsp), %xmm5 + mulsd %xmm0, %xmm5 + movsd 8(%rsp), %xmm1 + movaps %xmm1, %xmm6 + movsd 96(%rsp), %xmm4 + addsd %xmm5, %xmm6 + mulsd %xmm0, %xmm4 + movaps %xmm6, %xmm2 + movsd 40(%rsp), %xmm14 + subsd %xmm1, %xmm2 + movsd %xmm2, 16(%rsp) + movsd 16(%rsp), %xmm3 + movsd 48(%rsp), %xmm1 + subsd %xmm3, %xmm5 + addsd %xmm4, %xmm5 + addsd (%rsp), %xmm5 + addsd %xmm5, %xmm6 + movsd %xmm6, 32(%rsp) + movsd %xmm6, 56(%rsp) +..B1.22: + movaps %xmm1, %xmm0 + movaps %xmm14, %xmm1 + call atan2@PLT +..B1.60: + movsd %xmm0, 64(%rsp) + movzwl 70(%rsp), %eax + testl $32752, %eax + jne ..B1.29 +..B1.23: + testl $1048575, 68(%rsp) + jne ..B1.25 +..B1.24: + cmpl $0, 64(%rsp) + je ..B1.29 +..B1.25: + lea 56+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 16(%rsp) + movsd 16(%rsp), %xmm1 + addsd 64(%rsp), %xmm1 + movsd %xmm1, 64(%rsp) + jmp ..B1.29 +..B1.26: + je ..B1.50 +..B1.27: + cmpl $2047, %eax + je ..B1.43 +..B1.28: + lea 48+_CONSTANTS(%rip), %rax + movsd 48(%rsp), %xmm0 + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm1 + movsd %xmm1, 56(%rsp) + movsd 40(%rsp), %xmm1 + call atan2@PLT +..B1.61: + movsd %xmm0, 64(%rsp) +..B1.29: + movq 104(%rsp), %rax + xorq %rsp, %rax + movsd 56(%rsp), %xmm0 + movsd 64(%rsp), %xmm1 + cmpq %fs:40, %rax + jne ..B1.42 +..B1.30: + addq $120, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 128 +..B1.31: + testl $1048575, 4(%rsp) + jne ..B1.16 +..B1.33: + cmpl $0, (%rsp) + jne ..B1.16 +..B1.35: + movsd .L_2il0floatpacket.7(%rip), %xmm2 + mulsd %xmm6, %xmm2 + mulsd %xmm2, %xmm6 + movsd %xmm6, 32(%rsp) + movzwl 38(%rsp), %eax + testl $32752, %eax + jne ..B1.39 +..B1.36: + testl $1048575, 36(%rsp) + jne ..B1.38 +..B1.37: + cmpl $0, 32(%rsp) + je ..B1.39 +..B1.38: + lea 56+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm2 + mulsd %xmm2, %xmm2 + movsd %xmm2, 16(%rsp) + movsd 16(%rsp), %xmm6 + addsd 32(%rsp), %xmm6 + movsd %xmm6, 32(%rsp) +..B1.39: + movsd %xmm6, 56(%rsp) + jmp ..B1.22 +..B1.40: + ucomisd %xmm2, %xmm6 + jne ..B1.4 + jp ..B1.4 +..B1.41: + movsd .L_2il0floatpacket.6(%rip), %xmm3 + divsd %xmm2, %xmm3 + movsd %xmm6, 8(%rsp) + movsd %xmm7, (%rsp) + movsd %xmm3, 56(%rsp) + jmp ..B1.22 +..B1.42: + call __stack_chk_fail@PLT +..B1.43: + testl $1048575, 52(%rsp) + jne ..B1.45 +..B1.44: + cmpl $0, 48(%rsp) + je ..B1.28 +..B1.45: + movsd 48(%rsp), %xmm0 + cmpl $2047, %edx + mulsd %xmm0, %xmm0 + movsd %xmm0, 64(%rsp) + je ..B1.47 +..B1.46: + movsd %xmm0, 56(%rsp) + jmp ..B1.29 +..B1.47: + testl $1048575, 44(%rsp) + jne ..B1.46 +..B1.48: + cmpl $0, 40(%rsp) + jne ..B1.46 +..B1.49: + movsd 40(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 56(%rsp) + jmp ..B1.29 +..B1.50: + testl $1048575, 44(%rsp) + jne ..B1.52 +..B1.51: + cmpl $0, 40(%rsp) + je ..B1.27 +..B1.52: + movsd 40(%rsp), %xmm1 + cmpl $2047, %eax + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, 64(%rsp) + je ..B1.54 +..B1.53: + movsd 48(%rsp), %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, 56(%rsp) + jmp ..B1.29 +..B1.54: + testl $1048575, 52(%rsp) + jne ..B1.53 +..B1.55: + cmpl $0, 48(%rsp) + jne ..B1.53 +..B1.56: + movsd 48(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 56(%rsp) + jmp ..B1.29 +..B1.62: + cmpl $2047, %edx + je ..B1.50 + jmp ..B1.27 + .align 16,0x90 + .cfi_endproc + .type clog,@function + .size clog,.-clog + .data +# -- End clog + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.10: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,16 + .align 16 +_CONSTANTS: + .long 0 + .long 1065353216 + .long 1818952144 + .long 1072073202 + .long 133565931 + .long 1072697336 + .long 4277796864 + .long 1071001154 + .long 3164486458 + .long 1030551450 + .long 0 + .long 592445440 + .long 0 + .long 2146435072 + .long 0 + .long 1048576 + .type _CONSTANTS,@object + .size _CONSTANTS,64 + .align 16 +_Q1: + .long 0 + .long 3219128320 + .long 1431655765 + .long 1070945621 + .long 193 + .long 3218079744 + .long 2576980913 + .long 1070176665 + .long 1408920289 + .long 3217380693 + .long 2428535925 + .long 1069697316 + .long 1830244366 + .long 3217031283 + .long 3038314627 + .long 1069314732 + .type _Q1,@object + .size _Q1,64 + .align 8 +.L_2il0floatpacket.6: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x02000000,0x41a00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/clog10.S b/external/sgx_libm/intel64/clog10.S new file mode 100644 index 0000000000..a8ed1a4402 --- /dev/null +++ b/external/sgx_libm/intel64/clog10.S @@ -0,0 +1,789 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clog10.c" + .text +..TXTST0: +# -- Begin clog10f + .text + .align 16,0x90 + .globl clog10f +clog10f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_clog10f.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_clog10f.4: + call clog10@PLT +..___tag_value_clog10f.5: +..B1.5: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type clog10f,@function + .size clog10f,.-clog10f + .data +# -- End clog10f + .text +# -- Begin clog10 + .text + .align 16,0x90 + .globl clog10 +clog10: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_clog10.8: +..L9: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + movq %fs:40, %rax + subq $128, %rsp + .cfi_def_cfa_offset 160 + movsd %xmm0, 16(%rsp) + xorq %rsp, %rax + movsd %xmm1, 24(%rsp) + movzwl 22(%rsp), %edx + andl $32752, %edx + movq %rax, 112(%rsp) + movzwl 30(%rsp), %eax + andl $32752, %eax + shrl $4, %edx + shrl $4, %eax + cmpl $2047, %edx + jge ..B2.26 +..B2.2: + cmpl $2047, %eax + jge ..B2.62 +..B2.3: + testl %edx, %edx + jne ..B2.9 +..B2.4: + testl $1048575, 20(%rsp) + jne ..B2.9 +..B2.5: + cmpl $0, 16(%rsp) + jne ..B2.9 +..B2.6: + testl %eax, %eax + jne ..B2.9 +..B2.7: + testl $1048575, 28(%rsp) + jne ..B2.9 +..B2.8: + cmpl $0, 24(%rsp) + je ..B2.25 +..B2.9: + movsd 16(%rsp), %xmm0 + lea 24(%rsp), %r15 + movsd (%r15), %xmm1 + movaps %xmm0, %xmm12 + movaps %xmm1, %xmm11 + andps .L_2il0floatpacket.10(%rip), %xmm11 + andps .L_2il0floatpacket.10(%rip), %xmm12 + movaps %xmm11, %xmm6 + movaps %xmm12, %xmm7 + movaps %xmm6, %xmm2 + comisd %xmm12, %xmm11 + jbe ..B2.11 +..B2.10: + movaps %xmm7, %xmm6 + movaps %xmm2, %xmm12 + movaps %xmm11, %xmm7 + movaps %xmm6, %xmm11 +..B2.11: + lea 8+_CONSTANTS(%rip), %rax + comisd (%rax), %xmm12 + jb ..B2.22 +..B2.12: + lea 16+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm2 + comisd %xmm12, %xmm2 + jb ..B2.22 +..B2.13: + lea 24+_CONSTANTS(%rip), %rdx + lea _CONSTANTS(%rip), %rax + movaps %xmm12, %xmm5 + mulsd %xmm12, %xmm5 + comisd (%rdx), %xmm11 + movsd .L_2il0floatpacket.11(%rip), %xmm2 + movsd (%rax), %xmm4 + jbe ..B2.16 +..B2.14: + movaps %xmm11, %xmm3 + mulsd %xmm11, %xmm3 + addsd %xmm3, %xmm5 + subsd %xmm2, %xmm5 + andps .L_2il0floatpacket.10(%rip), %xmm5 + comisd %xmm5, %xmm4 + ja ..B2.17 + jmp ..B2.22 +..B2.16: + subsd %xmm2, %xmm5 + andps .L_2il0floatpacket.10(%rip), %xmm5 + comisd %xmm5, %xmm4 + jbe ..B2.22 +..B2.17: + movsd %xmm6, 8(%rsp) +..B2.18: + movzwl 14(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + cmpl $913, %edx + jl ..B2.20 +..B2.19: + movsd .L_2il0floatpacket.7(%rip), %xmm9 + movaps %xmm12, %xmm10 + mulsd %xmm9, %xmm10 + movaps %xmm11, %xmm8 + mulsd %xmm9, %xmm8 + movaps %xmm10, %xmm13 + movaps %xmm8, %xmm14 + movsd .L_2il0floatpacket.9(%rip), %xmm15 + lea 32+_Q1(%rip), %rbx + lea 56+_Q1(%rip), %rax + subsd %xmm12, %xmm13 + subsd %xmm11, %xmm14 + subsd %xmm13, %xmm10 + subsd %xmm14, %xmm8 + subsd %xmm10, %xmm12 + subsd %xmm8, %xmm11 + movaps %xmm10, %xmm4 + movaps %xmm8, %xmm7 + mulsd %xmm10, %xmm4 + lea 48+_Q1(%rip), %rdx + mulsd %xmm8, %xmm7 + mulsd %xmm15, %xmm10 + mulsd %xmm15, %xmm8 + mulsd %xmm12, %xmm10 + mulsd %xmm11, %xmm8 + mulsd %xmm12, %xmm12 + mulsd %xmm11, %xmm11 + movaps %xmm4, %xmm1 + lea 88(%rsp), %r14 + lea 40+_Q1(%rip), %rcx + addsd %xmm7, %xmm1 + movaps %xmm1, %xmm5 + subsd %xmm2, %xmm1 + subsd %xmm4, %xmm5 + movaps %xmm1, %xmm6 + subsd %xmm5, %xmm7 + movsd (%rax), %xmm5 + addsd %xmm7, %xmm6 + movaps %xmm6, %xmm3 + movaps %xmm6, %xmm2 + lea 24+_Q1(%rip), %rsi + subsd %xmm1, %xmm3 + lea 16+_Q1(%rip), %rdi + subsd %xmm3, %xmm2 + subsd %xmm3, %xmm7 + subsd %xmm2, %xmm1 + lea 8+_Q1(%rip), %r8 + addsd %xmm1, %xmm7 + movaps %xmm6, %xmm1 + lea _Q1(%rip), %r9 + lea 48+_CONSTANTS(%rip), %r10 + addsd %xmm10, %xmm1 + movaps %xmm1, %xmm2 + movaps %xmm1, %xmm14 + lea 56+_CONSTANTS(%rip), %r11 + addsd %xmm8, %xmm2 + subsd %xmm6, %xmm14 + movaps %xmm2, %xmm3 + subsd %xmm14, %xmm10 + addsd %xmm12, %xmm3 + movaps %xmm3, %xmm4 + addsd %xmm11, %xmm4 + mulsd %xmm4, %xmm5 + movaps %xmm4, %xmm13 + mulsd %xmm4, %xmm13 + mulsd %xmm4, %xmm9 + addsd (%rdx), %xmm5 + mulsd %xmm4, %xmm5 + addsd (%rcx), %xmm5 + mulsd %xmm4, %xmm5 + addsd (%rbx), %xmm5 + mulsd %xmm4, %xmm5 + lea 104(%rsp), %rbx + addsd (%rsi), %xmm5 + mulsd %xmm4, %xmm5 + addsd (%rdi), %xmm5 + mulsd %xmm4, %xmm5 + addsd (%r8), %xmm5 + mulsd %xmm4, %xmm5 + addsd (%r9), %xmm5 + mulsd %xmm13, %xmm5 + movaps %xmm1, %xmm13 + subsd %xmm14, %xmm13 + subsd %xmm13, %xmm6 + addsd %xmm6, %xmm10 + movaps %xmm2, %xmm6 + subsd %xmm1, %xmm6 + addsd %xmm10, %xmm7 + subsd %xmm6, %xmm8 + movaps %xmm2, %xmm10 + subsd %xmm6, %xmm10 + subsd %xmm10, %xmm1 + addsd %xmm1, %xmm8 + movaps %xmm3, %xmm1 + addsd %xmm8, %xmm7 + movaps %xmm3, %xmm8 + subsd %xmm2, %xmm8 + subsd %xmm8, %xmm1 + subsd %xmm8, %xmm12 + subsd %xmm1, %xmm2 + movaps %xmm4, %xmm1 + addsd %xmm2, %xmm12 + addsd %xmm12, %xmm7 + movaps %xmm4, %xmm12 + subsd %xmm3, %xmm12 + subsd %xmm12, %xmm1 + subsd %xmm12, %xmm11 + subsd %xmm1, %xmm3 + movsd (%r10), %xmm1 + addsd %xmm3, %xmm11 + movaps %xmm1, %xmm3 + addsd %xmm11, %xmm7 + movaps %xmm9, %xmm11 + addsd %xmm7, %xmm5 + subsd %xmm4, %xmm11 + subsd %xmm11, %xmm9 + mulsd %xmm9, %xmm3 + subsd %xmm9, %xmm4 + addsd %xmm5, %xmm4 + movsd (%r11), %xmm5 + mulsd %xmm5, %xmm9 + movaps %xmm5, %xmm2 + mulsd %xmm4, %xmm2 + mulsd %xmm1, %xmm4 + addsd %xmm9, %xmm2 + pxor %xmm1, %xmm1 + addsd %xmm4, %xmm2 + addsd %xmm2, %xmm3 + mulsd .L_2il0floatpacket.6(%rip), %xmm3 + movsd %xmm3, -72(%rbx) + jmp ..B2.29 +..B2.20: + movsd %xmm7, (%rsp) + movzwl 6(%rsp), %eax + andl $32752, %eax + cmpl $16368, %eax + je ..B2.35 +..B2.21: + movsd .L_2il0floatpacket.7(%rip), %xmm8 + movaps %xmm12, %xmm3 + mulsd %xmm8, %xmm3 + lea 56+_Q1(%rip), %rax + movaps %xmm3, %xmm1 + lea 32+_Q1(%rip), %rbx + movsd (%rax), %xmm7 + lea 88(%rsp), %r14 + lea 48+_Q1(%rip), %rdx + subsd %xmm12, %xmm1 + lea 40+_Q1(%rip), %rcx + subsd %xmm1, %xmm3 + movaps %xmm3, %xmm5 + subsd %xmm3, %xmm12 + mulsd %xmm3, %xmm5 + lea 24+_Q1(%rip), %rsi + subsd %xmm2, %xmm5 + movsd .L_2il0floatpacket.9(%rip), %xmm2 + movaps %xmm5, %xmm14 + mulsd %xmm3, %xmm2 + lea 16+_Q1(%rip), %rdi + mulsd %xmm12, %xmm2 + lea 8+_Q1(%rip), %r8 + mulsd %xmm12, %xmm12 + movaps %xmm2, %xmm10 + lea _Q1(%rip), %r9 + lea 48+_CONSTANTS(%rip), %r10 + addsd %xmm12, %xmm10 + movaps %xmm10, %xmm4 + addsd %xmm10, %xmm14 + subsd %xmm2, %xmm4 + mulsd %xmm14, %xmm7 + subsd %xmm4, %xmm12 + mulsd %xmm14, %xmm8 + addsd (%rdx), %xmm7 + mulsd %xmm14, %xmm7 + movaps %xmm14, %xmm6 + subsd %xmm5, %xmm6 + addsd (%rcx), %xmm7 + subsd %xmm6, %xmm10 + mulsd %xmm14, %xmm7 + addsd %xmm12, %xmm10 + addsd (%rbx), %xmm7 + mulsd %xmm14, %xmm7 + movaps %xmm14, %xmm12 + mulsd %xmm14, %xmm12 + addsd (%rsi), %xmm7 + mulsd %xmm14, %xmm7 + movaps %xmm8, %xmm9 + subsd %xmm14, %xmm9 + addsd (%rdi), %xmm7 + subsd %xmm9, %xmm8 + mulsd %xmm14, %xmm7 + lea 56+_CONSTANTS(%rip), %r11 + addsd (%r8), %xmm7 + mulsd %xmm14, %xmm7 + subsd %xmm8, %xmm14 + movsd (%r10), %xmm13 + lea 104(%rsp), %rbx + movsd (%r11), %xmm11 + movaps %xmm13, %xmm1 + movaps %xmm11, %xmm15 + addsd (%r9), %xmm7 + mulsd %xmm8, %xmm1 + mulsd %xmm11, %xmm8 + mulsd %xmm12, %xmm7 + addsd %xmm7, %xmm10 + addsd %xmm10, %xmm14 + mulsd %xmm14, %xmm15 + mulsd %xmm13, %xmm14 + addsd %xmm8, %xmm15 + addsd %xmm14, %xmm15 + addsd %xmm15, %xmm1 + mulsd .L_2il0floatpacket.6(%rip), %xmm1 + movsd %xmm1, -72(%rbx) + pxor %xmm1, %xmm1 + jmp ..B2.29 +..B2.22: + lea 48(%rsp), %rdi +..___tag_value_clog10.17: + call __libm_hypot2_k64@PLT +..___tag_value_clog10.18: +..B2.23: + lea 72+_CONSTANTS(%rip), %rax + lea 80+_CONSTANTS(%rip), %rdx + mulsd .L_2il0floatpacket.6(%rip), %xmm0 + lea 64(%rsp), %rdi + movsd (%rax), %xmm1 + mulsd %xmm0, %xmm1 + movsd (%rdx), %xmm2 + mulsd %xmm0, %xmm2 + movsd %xmm1, -56(%rdi) + movsd -16(%rdi), %xmm0 + movsd -8(%rdi), %xmm1 + movsd %xmm2, (%rsp) +..___tag_value_clog10.19: + call __libm_log_k64@PLT +..___tag_value_clog10.20: +..B2.24: + movsd 64(%rsp), %xmm6 + lea 88(%rsp), %r14 + movsd .L_2il0floatpacket.6(%rip), %xmm0 + lea 104(%rsp), %rbx + mulsd %xmm0, %xmm6 + lea 48+_CONSTANTS(%rip), %rax + movsd .L_2il0floatpacket.7(%rip), %xmm4 + lea 56+_CONSTANTS(%rip), %rdx + movsd -32(%rbx), %xmm2 + movsd (%rax), %xmm5 + movsd -96(%rbx), %xmm9 + mulsd %xmm6, %xmm4 + movaps %xmm9, %xmm10 + mulsd %xmm0, %xmm2 + movaps %xmm4, %xmm1 + movsd (%rdx), %xmm3 + subsd %xmm6, %xmm1 + movaps %xmm3, %xmm8 + subsd %xmm1, %xmm4 + movaps %xmm4, %xmm7 + pxor %xmm1, %xmm1 + mulsd %xmm5, %xmm7 + subsd %xmm4, %xmm6 + mulsd %xmm3, %xmm4 + addsd %xmm2, %xmm6 + addsd %xmm7, %xmm10 + mulsd %xmm6, %xmm8 + subsd %xmm10, %xmm9 + mulsd %xmm5, %xmm6 + addsd %xmm4, %xmm8 + addsd %xmm7, %xmm9 + addsd %xmm6, %xmm8 + movsd -88(%rbx), %xmm0 + addsd %xmm8, %xmm9 + addsd (%rsp), %xmm9 + addsd %xmm9, %xmm10 + movsd %xmm10, -72(%rbx) + jmp ..B2.29 +..B2.25: + movsd .L_2il0floatpacket.8(%rip), %xmm0 + lea 24(%rsp), %r15 + pxor %xmm1, %xmm1 + lea 88(%rsp), %r14 + divsd %xmm1, %xmm0 + movsd %xmm0, -56(%r14) + lea 104(%rsp), %rbx + movsd -88(%rbx), %xmm0 + jmp ..B2.29 +..B2.26: + je ..B2.51 +..B2.27: + cmpl $2047, %eax + je ..B2.44 +..B2.28: + lea 32+_CONSTANTS(%rip), %rax + lea 24(%rsp), %r15 + pxor %xmm1, %xmm1 + lea 88(%rsp), %r14 + lea 104(%rsp), %rbx + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -72(%rbx) + movsd -88(%rbx), %xmm0 +..B2.29: + movq (%r15), %rax + lea (%rsp), %rdi + movq %rax, 80(%rdi) + lea 80(%rsp), %rsi + movsd %xmm1, (%r14) + lea 96(%rsp), %rdx + movsd %xmm0, (%rdx) + movsd %xmm1, (%rbx) +..___tag_value_clog10.21: + call __libm_atan2_k64@PLT +..___tag_value_clog10.22: +..B2.61: + movl %eax, %edi +..B2.30: + movzwl 6(%rsp), %eax + andl $32752, %eax + cmpl $32752, %eax + jl ..B2.32 +..B2.31: + movq (%rsp), %rax + movq %rax, 40(%rsp) + jmp ..B2.33 +..B2.32: + movsd (%rsp), %xmm2 + lea 48+_CONSTANTS(%rip), %rax + movsd .L_2il0floatpacket.7(%rip), %xmm1 + lea 56+_CONSTANTS(%rip), %rcx + mulsd %xmm2, %xmm1 + movaps %xmm1, %xmm0 + movq (%rax), %rdx + subsd %xmm2, %xmm0 + movq (%rcx), %rsi + lea 40(%rsp), %rcx + movq %rdx, 56(%rcx) + lea 96(%rsp), %rdx + movq %rsi, (%rbx) + lea 80(%rsp), %rsi + subsd %xmm0, %xmm1 + movsd %xmm1, -16(%rdx) + subsd %xmm1, %xmm2 + addsd -88(%rdx), %xmm2 + movsd %xmm2, (%r14) +..___tag_value_clog10.23: + call __libm_mul_k64@PLT +..___tag_value_clog10.24: +..B2.33: + movq 112(%rsp), %rax + xorq %rsp, %rax + movsd 32(%rsp), %xmm0 + movsd 40(%rsp), %xmm1 + cmpq %fs:40, %rax + jne ..B2.43 +..B2.34: + addq $128, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B2.35: + testl $1048575, 4(%rsp) + jne ..B2.21 +..B2.36: + cmpl $0, (%rsp) + jne ..B2.21 +..B2.37: + testl %edx, %edx + jne ..B2.41 +..B2.38: + testl $1048575, 12(%rsp) + jne ..B2.41 +..B2.39: + cmpl $0, 8(%rsp) + jne ..B2.41 +..B2.40: + lea 88(%rsp), %r14 + pxor %xmm1, %xmm1 + lea 104(%rsp), %rbx + movsd %xmm1, -72(%rbx) + jmp ..B2.29 +..B2.41: + lea 64+_CONSTANTS(%rip), %r14 + lea 48+_CONSTANTS(%rip), %r8 + movsd .L_2il0floatpacket.7(%rip), %xmm5 + lea 56+_CONSTANTS(%rip), %r10 + movaps %xmm5, %xmm2 + lea 80(%rsp), %rsi + lea 96(%rsp), %rdx + mulsd (%r14), %xmm11 + lea 88(%rsp), %r14 + movsd %xmm11, -88(%rdx) + lea 32(%rsp), %rcx + movzwl -82(%rdx), %eax + movl %eax, %ebx + andl $-32753, %eax + andl $32752, %ebx + orl $-49168, %eax + movw %ax, -82(%rdx) + movsd -88(%rdx), %xmm1 + mulsd %xmm1, %xmm2 + movaps %xmm2, %xmm0 + shrl $4, %ebx + subsd %xmm1, %xmm0 + movq (%r8), %r9 + lea -2447(%rbx,%rbx), %edi + movq (%r10), %r11 + lea 104(%rsp), %rbx + movq %r9, (%rdx) + subsd %xmm0, %xmm2 + movaps %xmm2, %xmm6 + subsd %xmm2, %xmm1 + mulsd %xmm2, %xmm6 + mulsd %xmm1, %xmm2 + mulsd %xmm6, %xmm5 + mulsd .L_2il0floatpacket.9(%rip), %xmm2 + movaps %xmm5, %xmm3 + movaps %xmm1, %xmm4 + mulsd %xmm1, %xmm4 + subsd %xmm6, %xmm3 + movq %r11, (%rbx) + subsd %xmm3, %xmm5 + addsd %xmm2, %xmm4 + subsd %xmm5, %xmm6 + movsd %xmm5, -16(%rdx) + addsd %xmm4, %xmm6 + movsd %xmm6, (%r14) +..___tag_value_clog10.36: + call __libm_mul_k64@PLT +..___tag_value_clog10.37: +..B2.42: + movsd 16(%rsp), %xmm0 + pxor %xmm1, %xmm1 + jmp ..B2.29 +..B2.43: + call __stack_chk_fail@PLT +..B2.44: + testl $1048575, 28(%rsp) + jne ..B2.46 +..B2.45: + cmpl $0, 24(%rsp) + je ..B2.28 +..B2.46: + cmpl $2047, %edx + jne ..B2.57 +..B2.48: + testl $1048575, 20(%rsp) + jne ..B2.57 +..B2.49: + cmpl $0, 16(%rsp) + jne ..B2.57 +..B2.50: + movsd 16(%rsp), %xmm0 + lea 24(%rsp), %r15 + movaps %xmm0, %xmm1 + lea 88(%rsp), %r14 + mulsd %xmm0, %xmm1 + lea 104(%rsp), %rbx + movsd %xmm1, -72(%rbx) + pxor %xmm1, %xmm1 + jmp ..B2.29 +..B2.51: + testl $1048575, 20(%rsp) + jne ..B2.53 +..B2.52: + cmpl $0, 16(%rsp) + je ..B2.27 +..B2.53: + cmpl $2047, %eax + je ..B2.55 +..B2.54: + movsd 16(%rsp), %xmm0 + lea 24(%rsp), %r15 + movsd (%r15), %xmm1 + lea 88(%rsp), %r14 + mulsd %xmm0, %xmm1 + lea 104(%rsp), %rbx + movsd %xmm1, -72(%rbx) + pxor %xmm1, %xmm1 + jmp ..B2.29 +..B2.55: + testl $1048575, 28(%rsp) + jne ..B2.54 +..B2.56: + cmpl $0, 24(%rsp) + jne ..B2.54 +..B2.57: + lea 24(%rsp), %r15 + movsd (%r15), %xmm0 + lea 88(%rsp), %r14 + mulsd %xmm0, %xmm0 + pxor %xmm1, %xmm1 + movsd %xmm0, -56(%r14) + lea 104(%rsp), %rbx + movsd -88(%rbx), %xmm0 + jmp ..B2.29 +..B2.62: + cmpl $2047, %edx + je ..B2.51 + jmp ..B2.27 + .align 16,0x90 + .cfi_endproc + .type clog10,@function + .size clog10,.-clog10 + .data +# -- End clog10 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.10: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,16 + .align 16 +_CONSTANTS: + .long 0 + .long 1065353216 + .long 1818952144 + .long 1072073202 + .long 133565931 + .long 1072697336 + .long 0 + .long 592445440 + .long 0 + .long 2146435072 + .long 0 + .long 1048576 + .long 402653184 + .long 1071369083 + .long 2389363364 + .long 3190212823 + .long 0 + .long 1282408448 + .long 1342177280 + .long 1070810131 + .long 3730980389 + .long 1040445247 + .type _CONSTANTS,@object + .size _CONSTANTS,88 + .space 8, 0x00 # pad + .align 16 +_Q1: + .long 0 + .long 3219128320 + .long 1431655765 + .long 1070945621 + .long 193 + .long 3218079744 + .long 2576980913 + .long 1070176665 + .long 1408920289 + .long 3217380693 + .long 2428535925 + .long 1069697316 + .long 1830244366 + .long 3217031283 + .long 3038314627 + .long 1069314732 + .type _Q1,@object + .size _Q1,64 + .align 8 +.L_2il0floatpacket.6: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x02000000,0x41a00000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/clog10l.S b/external/sgx_libm/intel64/clog10l.S new file mode 100644 index 0000000000..0b9d3a6fe5 --- /dev/null +++ b/external/sgx_libm/intel64/clog10l.S @@ -0,0 +1,1000 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clog10l.c" + .text +..TXTST0: +# -- Begin clog10l + .text + .align 16,0x90 + .globl clog10l +clog10l: +# parameter 1: 352 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_clog10l.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + subq $312, %rsp + .cfi_def_cfa_offset 352 + xorb %r12b, %r12b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 304(%rsp) + fstpt 272(%rsp) + fldt 272(%rsp) + fstpt 288(%rsp) +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movzwl 82(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.5: + fldcw 80(%rsp) +..B1.6: + movb $1, %r12b +..B1.7: + movzwl 360(%rsp), %edx + andl $32767, %edx + movzwl 376(%rsp), %eax + andl $32767, %eax + cmpl $32767, %edx + jge ..B1.46 +..B1.8: + cmpl $32767, %eax + jge ..B1.82 +..B1.9: + testl %edx, %edx + jne ..B1.15 +..B1.10: + cmpl $0, 356(%rsp) + jne ..B1.15 +..B1.11: + cmpl $0, 352(%rsp) + jne ..B1.15 +..B1.12: + testl %eax, %eax + jne ..B1.15 +..B1.13: + cmpl $0, 372(%rsp) + jne ..B1.15 +..B1.14: + cmpl $0, 368(%rsp) + je ..B1.45 +..B1.15: + fldt 352(%rsp) + lea 368(%rsp), %rbx + fld %st(0) + fabs + fstpt 16(%rsp) + fldt 16(%rsp) + fldt (%rbx) + fld %st(0) + fabs + fstpt (%rsp) + fldt (%rsp) + movzwl 24(%rsp), %eax + movzwl 8(%rsp), %edx + andl $32767, %eax + andl $32767, %edx + cmpl %edx, %eax + jl ..B1.20 +..B1.16: + jne ..B1.21 +..B1.17: + movl 20(%rsp), %edx + movl 4(%rsp), %ecx + cmpl %ecx, %edx + jb ..B1.20 +..B1.18: + jne ..B1.21 +..B1.19: + movl 16(%rsp), %edx + cmpl (%rsp), %edx + jae ..B1.21 +..B1.20: + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 24(%rsp), %eax + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + andl $32767, %eax +..B1.21: + cmpl $16382, %eax + jg ..B1.26 +..B1.22: + jne ..B1.42 +..B1.23: + lea 16+_CONSTANTS(%rip), %rcx + movl 20(%rsp), %edx + cmpl 4(%rcx), %edx + ja ..B1.26 +..B1.24: + jne ..B1.42 +..B1.25: + movl (%rcx), %edx + cmpl 16(%rsp), %edx + ja ..B1.42 +..B1.26: + cmpl $16383, %eax + jl ..B1.31 +..B1.27: + jne ..B1.42 +..B1.28: + lea 32+_CONSTANTS(%rip), %rcx + movl 20(%rsp), %edx + cmpl 4(%rcx), %edx + jb ..B1.31 +..B1.29: + jne ..B1.42 +..B1.30: + movl 16(%rsp), %edx + cmpl (%rcx), %edx + ja ..B1.42 +..B1.31: + movzwl 8(%rsp), %esi + andl $32767, %esi + cmpl $8256, %esi + jg ..B1.36 +..B1.32: + jne ..B1.37 +..B1.33: + lea 48+_CONSTANTS(%rip), %rcx + movl 4(%rsp), %edx + cmpl 4(%rcx), %edx + ja ..B1.36 +..B1.34: + jne ..B1.37 +..B1.35: + movl (%rsp), %edx + cmpl (%rcx), %edx + jbe ..B1.37 +..B1.36: + fld %st(2) + lea _CONSTANTS(%rip), %rdx + fmul %st(3), %st + fld %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fldt .L_2il0floatpacket.10(%rip) + fsubr %st, %st(1) + fxch %st(1) + fabs + fldt (%rdx) + fcomip %st(1), %st + fstp %st(0) + ja ..B1.38 + jmp ..B1.83 +..B1.37: + fldt .L_2il0floatpacket.10(%rip) + fld %st(3) + fmul %st(4), %st + lea _CONSTANTS(%rip), %rdx + fsub %st(1), %st + fabs + fldt (%rdx) + fcomip %st(1), %st + fstp %st(0) + jbe ..B1.83 +..B1.38: + fstp %st(2) + cmpl $16183, %esi + jl ..B1.40 +..B1.39: + fldt .L_2il0floatpacket.9(%rip) + fld %st(3) + fmul %st(1), %st + lea 16+_Q1(%rip), %rax + fxch %st(5) + fstpt (%rsp) + fld %st(3) + lea _Q1(%rip), %rdx + fsubr %st(5), %st + lea 96+_CONSTANTS(%rip), %r15 + fsubrp %st, %st(5) + fld %st(4) + lea 112+_CONSTANTS(%rip), %r13 + fmul %st(5), %st + fld %st(2) + fmulp %st, %st(2) + fxch %st(4) + fsub %st(5), %st + fld %st(2) + fsubr %st(2), %st + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.13(%rip) + fmul %st, %st(1) + fxch %st(1) + fmul %st(4), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(4) + fmul %st(0), %st + fstpt 48(%rsp) + fld %st(5) + fadd %st(3), %st + fsub %st, %st(6) + fxch %st(6) + fsubrp %st, %st(3) + fmulp %st, %st(6) + fmul %st, %st(5) + fxch %st(3) + fsubrp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fld %st(0) + fsub %st(5), %st + fsubr %st, %st(2) + fld %st(1) + fsubp %st, %st(1) + fsubrp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fadd %st(5), %st + fld %st(0) + faddp %st, %st(3) + fld %st(2) + fxch %st(4) + fmul %st(0), %st + fstpt 16(%rsp) + fldt 16(%rsp) + faddp %st, %st(4) + fxch %st(3) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + faddp %st, %st(1) + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fmulp %st, %st(1) + fld %st(4) + fsub %st(6), %st + fsubr %st, %st(7) + fsubr %st(5), %st + fsubrp %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fld %st(1) + fsub %st(3), %st + fldt 32(%rsp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(3), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fld %st(3) + fldt 64(%rsp) + fld %st(0) + fsub %st(3), %st + fldt 16(%rsp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(2), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(4) + fsub %st(2), %st + fldt 48(%rsp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(6), %st + fsubrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.9(%rip) + fld %st(0) + fmul %st(4), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt (%r15) + fld %st(0) + fmul %st(3), %st + fldt (%r13) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.11(%rip) + fmulp %st, %st(2) + fxch %st(1) + fstpt 272(%rsp) + fldt (%rsp) + jmp ..B1.49 +..B1.40: + cmpl $16383, %eax + je ..B1.56 +..B1.41: + fstp %st(0) + fldt .L_2il0floatpacket.9(%rip) + fld %st(2) + fmul %st(1), %st + fld %st(3) + lea 16+_Q1(%rip), %rax + fsubr %st(1), %st + lea _Q1(%rip), %rdx + fsubrp %st, %st(1) + fld %st(0) + lea 96+_CONSTANTS(%rip), %r15 + lea 112+_CONSTANTS(%rip), %r13 + fmul %st(1), %st + fsubp %st, %st(3) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.13(%rip) + fmulp %st, %st(1) + fmul %st(3), %st + fld %st(0) + fld %st(3) + fxch %st(5) + fmul %st(0), %st + fadd %st, %st(1) + fxch %st(1) + fadd %st, %st(5) + fxch %st(4) + fsubr %st(5), %st + fxch %st(2) + fsubr %st(4), %st + fsubrp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + faddp %st, %st(2) + fld %st(2) + fmul %st(3), %st + fldt (%rax) + fmul %st(4), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(0) + fmul %st(3), %st + fld %st(3) + fsubr %st(1), %st + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt (%r15) + fld %st(0) + fmul %st(3), %st + fldt (%r13) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.11(%rip) + fmulp %st, %st(2) + fxch %st(1) + fstpt 272(%rsp) + fxch %st(1) + jmp ..B1.49 +..B1.42: + fstp %st(0) + fstp %st(1) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + lea 64(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_clog10l.13: + call __libm_hypot2l_k80@PLT +..___tag_value_clog10l.14: +..B1.78: + addq $32, %rsp + .cfi_def_cfa_offset 352 +..B1.43: + fldt .L_2il0floatpacket.11(%rip) + lea 160+_CONSTANTS(%rip), %rax + lea 176+_CONSTANTS(%rip), %rdx + fmulp %st, %st(1) + fldt (%rax) + fmul %st(1), %st + fstpt 16(%rsp) + fldt (%rdx) + fmulp %st, %st(1) + fstpt (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fldt 64(%rsp) + lea 128(%rsp), %rdi + fstpt (%rsp) + fldt -48(%rdi) + fstpt 16(%rsp) +..___tag_value_clog10l.17: + call __libm_logl_k80@PLT +..___tag_value_clog10l.18: +..B1.79: + addq $32, %rsp + .cfi_def_cfa_offset 352 +..B1.44: + fldt .L_2il0floatpacket.11(%rip) + lea 96+_CONSTANTS(%rip), %r15 + fldt 96(%rsp) + lea 112+_CONSTANTS(%rip), %r13 + fxch %st(2) + fmulp %st, %st(1) + fmul %st, %st(1) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.9(%rip) + fld %st(0) + fmul %st(3), %st + fld %st(0) + fsub %st(4), %st + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt (%r15) + fld %st(0) + fmul %st(3), %st + fldt (%r13) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 16(%rsp) + fld %st(0) + fadd %st(4), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldt (%rsp) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 272(%rsp) + fldt 352(%rsp) + jmp ..B1.49 +..B1.45: + fldt .L_2il0floatpacket.9(%rip) + lea 368(%rsp), %rbx + movsd .L_2il0floatpacket.12(%rip), %xmm1 + pxor %xmm0, %xmm0 + divsd %xmm0, %xmm1 + movsd %xmm1, (%rsp) + lea 96+_CONSTANTS(%rip), %r15 + fldl (%rsp) + lea 112+_CONSTANTS(%rip), %r13 + fstpt 272(%rsp) + fldt -16(%rbx) + jmp ..B1.49 +..B1.46: + je ..B1.70 +..B1.47: + cmpl $32767, %eax + je ..B1.64 +..B1.48: + fldt .L_2il0floatpacket.9(%rip) + lea 368(%rsp), %rbx + lea 64+_CONSTANTS(%rip), %rax + lea 96+_CONSTANTS(%rip), %r15 + lea 112+_CONSTANTS(%rip), %r13 + fldt (%rax) + fmul %st(0), %st + fstpt 272(%rsp) + fldt -16(%rbx) +..B1.49: + fldt .L_2il0floatpacket.8(%rip) + lea 224(%rsp), %rdi + xorl %eax, %eax + lea 176(%rsp), %rsi + movl %eax, -16(%rsi) + lea 128(%rsp), %rdx + fstpt 16(%rdx) + fldt 16(%rdx) + fxch %st(1) + fstpt (%rdx) + movl %eax, 80(%rdx) + fstpt 64(%rdx) + fstpt -112(%rdx) + fldt (%rbx) + fstpt 48(%rdx) +..___tag_value_clog10l.20: + call __libm_atan2l_k80@PLT +..___tag_value_clog10l.21: +..B1.50: + fldt 16(%rsp) + fldt 224(%rsp) + fmul %st, %st(1) + fld %st(0) + movl 256(%rsp), %edi + fsubr %st(2), %st + fsubrp %st, %st(2) + fsub %st(1), %st + fldt 240(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + faddp %st, %st(1) + fldt (%r15) + fld %st(0) + fmul %st(3), %st + fstpt (%rsp) + fldt (%r13) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsp) +..___tag_value_clog10l.23: + call __libm_scalbl_k80@PLT +..___tag_value_clog10l.24: +..B1.80: + addq $32, %rsp + .cfi_def_cfa_offset 352 +..B1.51: + fstpt 288(%rsp) + testb %r12b, %r12b + je ..B1.53 +..B1.52: + fldcw 82(%rsp) +..B1.53: + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.63 +..B1.54: + fldt 272(%rsp) + fldt 288(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.62 +..B1.55: + addq $312, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 352 + .cfi_offset 3, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 15, -32 +..B1.56: + cmpl $-2147483648, 20(%rsp) + jne ..B1.41 +..B1.57: + cmpl $0, 16(%rsp) + jne ..B1.41 +..B1.58: + fstp %st(2) + fstp %st(0) + cmpq $0, (%rsp) + jne ..B1.60 +..B1.59: + fstp %st(0) + fldt .L_2il0floatpacket.8(%rip) + lea 96+_CONSTANTS(%rip), %r15 + fstpt 272(%rsp) + lea 112+_CONSTANTS(%rip), %r13 + fldt .L_2il0floatpacket.9(%rip) + fxch %st(1) + jmp ..B1.49 +..B1.60: + fstp %st(1) + fldt .L_2il0floatpacket.13(%rip) + lea 144+_CONSTANTS(%rip), %r13 + fldt (%r13) + lea 112+_CONSTANTS(%rip), %r13 + fmulp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt .L_2il0floatpacket.9(%rip) + movzwl 8(%rsp), %eax + movl %eax, %r15d + andl $-32768, %eax + fld %st(0) + orl $-49153, %eax + fld %st(1) + movw %ax, 8(%rsp) + andl $32767, %r15d + fldt (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fmul %st, %st(2) + fld %st(0) + fsubr %st(3), %st + fsubrp %st, %st(3) + fld %st(2) + lea -33167(%r15,%r15), %edi + fmul %st(3), %st + lea 96+_CONSTANTS(%rip), %r15 + fmul %st, %st(2) + fld %st(2) + fsub %st(1), %st + fsubrp %st, %st(3) + fsub %st(2), %st + fxch %st(1) + fsub %st(3), %st + fmul %st, %st(3) + fxch %st(5) + fmulp %st, %st(3) + fld %st(4) + fmulp %st, %st(5) + fxch %st(2) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fldt (%r15) + fld %st(0) + fmul %st(4), %st + fstpt (%rsp) + fldt (%r13) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 48(%rsp) +..___tag_value_clog10l.41: + call __libm_scalbl_k80@PLT +..___tag_value_clog10l.42: +..B1.81: + fldt 48(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 352 +..B1.61: + fxch %st(1) + fstpt 272(%rsp) + fldt 352(%rsp) + jmp ..B1.49 +..B1.62: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.63: + call __stack_chk_fail@PLT +..B1.64: + cmpl $-2147483648, 372(%rsp) + jne ..B1.66 +..B1.65: + cmpl $0, 368(%rsp) + je ..B1.48 +..B1.66: + cmpl $32767, %edx + je ..B1.68 +..B1.67: + fldt .L_2il0floatpacket.9(%rip) + lea 368(%rsp), %rbx + fldt (%rbx) + lea 96+_CONSTANTS(%rip), %r15 + fmul %st(0), %st + lea 112+_CONSTANTS(%rip), %r13 + fstpt 272(%rsp) + fldt -16(%rbx) + jmp ..B1.49 +..B1.68: + movq $0x8000000000000000, %rax + cmpq 352(%rsp), %rax + jne ..B1.67 +..B1.69: + fldt 352(%rsp) + lea 368(%rsp), %rbx + fld %st(0) + lea 96+_CONSTANTS(%rip), %r15 + fmul %st(1), %st + lea 112+_CONSTANTS(%rip), %r13 + fstpt 272(%rsp) + fldt .L_2il0floatpacket.9(%rip) + fxch %st(1) + jmp ..B1.49 +..B1.70: + cmpl $-2147483648, 356(%rsp) + jne ..B1.72 +..B1.71: + cmpl $0, 352(%rsp) + je ..B1.47 +..B1.72: + cmpl $32767, %eax + je ..B1.74 +..B1.73: + fldt 352(%rsp) + lea 368(%rsp), %rbx + fldt (%rbx) + lea 96+_CONSTANTS(%rip), %r15 + fmul %st(1), %st + lea 112+_CONSTANTS(%rip), %r13 + fstpt 272(%rsp) + fldt .L_2il0floatpacket.9(%rip) + fxch %st(1) + jmp ..B1.49 +..B1.74: + movq $0x8000000000000000, %rax + cmpq 368(%rsp), %rax + jne ..B1.73 +..B1.75: + fldt .L_2il0floatpacket.9(%rip) + lea 368(%rsp), %rbx + fldt (%rbx) + lea 96+_CONSTANTS(%rip), %r15 + fmul %st(0), %st + lea 112+_CONSTANTS(%rip), %r13 + fstpt 272(%rsp) + fldt -16(%rbx) + jmp ..B1.49 +..B1.82: + cmpl $32767, %edx + je ..B1.70 + jmp ..B1.47 +..B1.83: + fstp %st(0) + jmp ..B1.42 + .align 16,0x90 + .cfi_endproc + .type clog10l,@function + .size clog10l,.-clog10l + .data +# -- End clog10l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,16 + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,16 + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 8 +.L_2il0floatpacket.12: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 37342 + .word 47265 + .word 62214 + .word 46340 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 65535 + .word 31 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8256 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55465 + .word 56923 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 43711 + .word 54638 + .word 50772 + .word 56481 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16583 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39557 + .word 39456 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 51839 + .word 3796 + .word 3310 + .word 34305 + .word 49112 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,192 + .align 2 +_Q1: + .word 3134 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 49331 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/clogf.S b/external/sgx_libm/intel64/clogf.S new file mode 100644 index 0000000000..70d2a0e0c4 --- /dev/null +++ b/external/sgx_libm/intel64/clogf.S @@ -0,0 +1,2614 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clogf.c" + .text +..TXTST0: +# -- Begin clogf + .text + .align 16,0x90 + .globl clogf +clogf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_clogf.1: +..L2: + +..B1.2: + movq %rsp, %rax + subq $168, %rsp + .cfi_def_cfa_offset 176 + movq %rax, 72(%rsp) + movss %xmm0, 48(%rsp) + pshufd $1, %xmm0, %xmm1 + movss %xmm1, 56(%rsp) + movq %rbx, 80(%rsp) + lea clogf_table(%rip), %r8 + movl 56(%rsp), %edx + movl 48(%rsp), %ecx + movl $-2147483648, %eax + andl %edx, %eax + andl $2139095040, %edx + subl $8388608, %edx + cvtss2sd 56(%rsp), %xmm0 + cvtss2sd 48(%rsp), %xmm1 + cmpl $2130706432, %edx + jae .L_2TAG_PACKET_0.0.1 + movl %ecx, %edx + andl $-2147483648, %ecx + andl $2139095040, %edx + subl $8388608, %edx + movsd %xmm0, 40(%rsp) + movsd %xmm1, 32(%rsp) + cmpl $2130706432, %edx + jae .L_2TAG_PACKET_1.0.1 + movapd %xmm0, %xmm3 + divsd %xmm1, %xmm0 + movsd 6656(%r8), %xmm2 + mulsd %xmm1, %xmm1 + mulsd %xmm3, %xmm3 + addsd %xmm3, %xmm1 + movsd %xmm1, 16(%rsp) + andpd %xmm1, %xmm2 + pextrw $3, %xmm1, %edx + subsd 6784(%r8), %xmm1 + andpd 6672(%r8), %xmm1 + cmpltsd 6576(%r8), %xmm1 + movmskpd %xmm1, %ebx + orpd 6784(%r8), %xmm2 + andpd 6672(%r8), %xmm0 + testl $1, %ebx + jne .L_2TAG_PACKET_2.0.1 +.L_2TAG_PACKET_3.0.1: + xorl %ecx, %eax + movl 20(%rsp), %ebx + sarl $4, %edx + andq $1044480, %rbx + movsd 6800(%r8), %xmm3 + xorpd %xmm4, %xmm4 + subl $1023, %edx + xorpd %xmm7, %xmm7 + sarl $31, %ecx + movl %edx, (%rsp) + movd %ecx, %xmm6 + pshufd $0, %xmm6, %xmm6 + andpd 6832(%r8), %xmm6 + andpd %xmm0, %xmm3 + pextrw $3, %xmm0, %edx + shrq $9, %rbx + movsd %xmm0, %xmm1 + subl $16288, %edx + cmpl $1119, %edx + ja .L_2TAG_PACKET_4.0.1 + movl $16464, %ecx + pinsrw $3, %ecx, %xmm4 + shrl $16, %eax + orpd 6816(%r8), %xmm3 + movsd %xmm4, %xmm7 + mulsd (%r8,%rbx), %xmm2 + cmpsd $6, %xmm3, %xmm4 + movsd 6784(%r8), %xmm5 + minsd %xmm7, %xmm3 + andpd %xmm4, %xmm0 + mulsd %xmm3, %xmm1 + andpd %xmm4, %xmm5 + subsd %xmm3, %xmm0 + subsd 6784(%r8), %xmm2 + addsd %xmm5, %xmm1 + movq 6704(%r8), %xmm5 + divsd %xmm1, %xmm0 + cvtsi2sd (%rsp), %xmm1 + movl $176, %ecx + cmpl $176, %edx + cmova %ecx, %edx + addl $1, %edx + andq $-1, %rdx + movsd 6944(%r8), %xmm4 + pinsrw $3, %eax, %xmm7 + addsd 5152(%r8,%rdx,8), %xmm6 + xorpd %xmm7, %xmm6 + mulsd %xmm2, %xmm5 + addsd 6696(%r8), %xmm5 + mulsd %xmm2, %xmm5 + addsd 6688(%r8), %xmm5 + mulsd %xmm2, %xmm5 + xorpd %xmm0, %xmm7 + mulsd 6664(%r8), %xmm1 + mulsd %xmm0, %xmm0 + mulsd %xmm7, %xmm4 + addsd %xmm6, %xmm7 + mulsd %xmm4, %xmm0 + addsd 2048(%r8,%rbx), %xmm1 + addsd %xmm7, %xmm0 + addsd %xmm1, %xmm5 + mulsd 6960(%r8), %xmm5 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm5, %xmm5 + movd %xmm0, %edx + movd %xmm5, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_4.0.1: + addl $944, %edx + cmpl $2063, %edx + ja .L_2TAG_PACKET_5.0.1 + movq 6848(%r8), %xmm3 + shrl $16, %eax + movsd 6856(%r8), %xmm4 + mulsd (%r8,%rbx), %xmm2 + pinsrw $3, %eax, %xmm7 + mulsd %xmm1, %xmm1 + subsd 6784(%r8), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm3 + movsd %xmm1, %xmm5 + mulsd %xmm1, %xmm1 + addsd %xmm6, %xmm0 + cvtsi2sd (%rsp), %xmm6 + mulsd %xmm5, %xmm4 + mulsd %xmm3, %xmm1 + movq 6704(%r8), %xmm3 + mulsd %xmm2, %xmm3 + addsd 6696(%r8), %xmm3 + mulsd %xmm2, %xmm3 + mulsd 6664(%r8), %xmm6 + addsd 6688(%r8), %xmm3 + addsd 2048(%r8,%rbx), %xmm6 + mulsd %xmm2, %xmm3 + addsd %xmm4, %xmm1 + addsd %xmm6, %xmm3 + addsd %xmm1, %xmm0 + xorpd %xmm7, %xmm0 + mulsd 6960(%r8), %xmm3 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_5.0.1: + addl $15344, %edx + cmpl $17392, %edx + mulsd (%r8,%rbx), %xmm2 + subsd 6784(%r8), %xmm2 + jae .L_2TAG_PACKET_6.0.1 + shrl $16, %eax + pinsrw $3, %eax, %xmm7 + addsd %xmm6, %xmm0 + cvtsi2sd (%rsp), %xmm6 + movq 6704(%r8), %xmm3 + mulsd %xmm2, %xmm3 + pextrw $3, %xmm0, %edx + addsd 6696(%r8), %xmm3 + xorpd %xmm7, %xmm0 + andl $32752, %edx + mulsd %xmm2, %xmm3 + mulsd 6664(%r8), %xmm6 + addsd 6688(%r8), %xmm3 + movl $1065353217, %eax + movl $8388608, %ecx + addsd 2048(%r8,%rbx), %xmm6 + mulsd %xmm2, %xmm3 + cmpl $14352, %edx + cmovb %ecx, %eax + movd %eax, %xmm1 + addsd %xmm6, %xmm3 + mulss %xmm1, %xmm1 + mulsd 6960(%r8), %xmm3 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_6.0.1: + movss 6912(%r8), %xmm4 + movss 6916(%r8), %xmm1 + cvtsi2sd (%rsp), %xmm6 + shrl $16, %eax + andl $32768, %ecx + movq 6704(%r8), %xmm3 + mulsd %xmm2, %xmm3 + addsd 6696(%r8), %xmm3 + xorl %ecx, %eax + mulsd %xmm2, %xmm3 + xorps %xmm0, %xmm0 + mulsd 6664(%r8), %xmm6 + addsd 6688(%r8), %xmm3 + pinsrw $1, %eax, %xmm0 + addsd 2048(%r8,%rbx), %xmm6 + mulsd %xmm2, %xmm3 + orps %xmm0, %xmm4 + addsd %xmm6, %xmm3 + orps %xmm1, %xmm0 + mulsd 6960(%r8), %xmm3 + cvtsd2ss %xmm3, %xmm3 + addss %xmm4, %xmm0 + movd %xmm0, %edx + movd %xmm3, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_2.0.1: + movsd 32(%rsp), %xmm5 + mulsd %xmm5, %xmm5 + movq 16(%rsp), %xmm1 + movq 16(%rsp), %xmm6 + movq 16(%rsp), %xmm2 + subsd %xmm5, %xmm1 + subsd %xmm1, %xmm6 + subsd %xmm1, %xmm3 + subsd %xmm6, %xmm5 + addsd %xmm3, %xmm5 + xorl %ecx, %eax + movsd 6800(%r8), %xmm3 + xorpd %xmm4, %xmm4 + xorpd %xmm7, %xmm7 + sarl $31, %ecx + movd %ecx, %xmm6 + pshufd $0, %xmm6, %xmm6 + andpd 6832(%r8), %xmm6 + subsd 6784(%r8), %xmm2 + andpd %xmm0, %xmm3 + pextrw $3, %xmm0, %edx + movsd %xmm0, %xmm1 + addsd %xmm5, %xmm2 + subl $16288, %edx + cmpl $1119, %edx + ja .L_2TAG_PACKET_7.0.1 + movl $16464, %ecx + pinsrw $3, %ecx, %xmm4 + shrl $16, %eax + orpd 6816(%r8), %xmm3 + movsd %xmm4, %xmm7 + cmpsd $6, %xmm3, %xmm4 + movsd 6784(%r8), %xmm5 + minsd %xmm7, %xmm3 + andpd %xmm4, %xmm0 + mulsd %xmm3, %xmm1 + andpd %xmm4, %xmm5 + subsd %xmm3, %xmm0 + movq 6752(%r8), %xmm3 + addsd %xmm5, %xmm1 + divsd %xmm1, %xmm0 + mulsd %xmm2, %xmm3 + movl $176, %ecx + cmpl $176, %edx + cmova %ecx, %edx + addl $1, %edx + andl $-1, %edx + movsd 6944(%r8), %xmm4 + addsd 6744(%r8), %xmm3 + pinsrw $3, %eax, %xmm7 + addsd 5152(%r8,%rdx,8), %xmm6 + mulsd %xmm2, %xmm3 + xorpd %xmm7, %xmm6 + addsd 6736(%r8), %xmm3 + xorpd %xmm0, %xmm7 + mulsd %xmm2, %xmm3 + mulsd %xmm0, %xmm0 + addsd 6728(%r8), %xmm3 + mulsd %xmm7, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm6, %xmm7 + addsd 6720(%r8), %xmm3 + mulsd %xmm4, %xmm0 + mulsd %xmm2, %xmm3 + addsd %xmm7, %xmm0 + cvtsd2ss %xmm3, %xmm3 + cvtpd2ps %xmm0, %xmm0 + movd %xmm3, %eax + movd %xmm0, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_7.0.1: + addl $944, %edx + cmpl $2063, %edx + ja .L_2TAG_PACKET_8.0.1 + movq 6848(%r8), %xmm3 + shrl $16, %eax + movsd 6856(%r8), %xmm4 + pinsrw $3, %eax, %xmm7 + mulsd %xmm1, %xmm1 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm3 + movsd %xmm1, %xmm5 + mulsd %xmm1, %xmm1 + addsd %xmm6, %xmm0 + movq 6752(%r8), %xmm6 + mulsd %xmm2, %xmm6 + addsd 6744(%r8), %xmm6 + mulsd %xmm5, %xmm4 + mulsd %xmm2, %xmm6 + addsd 6736(%r8), %xmm6 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm6 + addsd 6728(%r8), %xmm6 + addsd %xmm4, %xmm1 + mulsd %xmm2, %xmm6 + addsd %xmm1, %xmm0 + addsd 6720(%r8), %xmm6 + xorpd %xmm7, %xmm0 + mulsd %xmm2, %xmm6 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm6, %xmm6 + movd %xmm0, %edx + movd %xmm6, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_8.0.1: + addl $15344, %edx + cmpl $17392, %edx + jae .L_2TAG_PACKET_9.0.1 + movq 6752(%r8), %xmm3 + mulsd %xmm2, %xmm3 + shrl $16, %eax + addsd 6744(%r8), %xmm3 + pinsrw $3, %eax, %xmm7 + mulsd %xmm2, %xmm3 + addsd %xmm6, %xmm0 + addsd 6736(%r8), %xmm3 + pextrw $3, %xmm0, %edx + mulsd %xmm2, %xmm3 + xorpd %xmm7, %xmm0 + addsd 6728(%r8), %xmm3 + andl $32752, %edx + movl $1065353217, %eax + movl $8388608, %ecx + mulsd %xmm2, %xmm3 + cmpl $14352, %edx + cmovb %ecx, %eax + movd %eax, %xmm1 + addsd 6720(%r8), %xmm3 + mulss %xmm1, %xmm1 + mulsd %xmm2, %xmm3 + cvtpd2ps %xmm0, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_9.0.1: + movss 6912(%r8), %xmm4 + movq 6752(%r8), %xmm3 + mulsd %xmm2, %xmm3 + movss 6916(%r8), %xmm1 + addsd 6744(%r8), %xmm3 + shrl $16, %eax + mulsd %xmm2, %xmm3 + andl $32768, %ecx + addsd 6736(%r8), %xmm3 + xorl %ecx, %eax + mulsd %xmm2, %xmm3 + xorps %xmm0, %xmm0 + addsd 6728(%r8), %xmm3 + pinsrw $1, %eax, %xmm0 + mulsd %xmm2, %xmm3 + orps %xmm0, %xmm4 + addsd 6720(%r8), %xmm3 + orps %xmm1, %xmm0 + mulsd %xmm2, %xmm3 + addss %xmm4, %xmm0 + cvtsd2ss %xmm3, %xmm3 + movd %xmm0, %edx + movd %xmm3, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_0.0.1: + andl $-2147483648, %ecx +.L_2TAG_PACKET_1.0.1: + movsd %xmm0, 40(%rsp) + movsd %xmm1, 32(%rsp) + movl 56(%rsp), %edx + andl $2147483647, %edx + je .L_2TAG_PACKET_10.0.1 + andl $2139095040, %edx + jne .L_2TAG_PACKET_10.0.1 + movss 56(%rsp), %xmm0 + orps 6864(%r8), %xmm0 + cvtss2sd %xmm0, %xmm0 + movsd 6896(%r8), %xmm2 + andpd %xmm0, %xmm2 + orpd 6880(%r8), %xmm2 + subsd %xmm2, %xmm0 + movsd %xmm0, 40(%rsp) +.L_2TAG_PACKET_10.0.1: + movl 48(%rsp), %edx + andl $2147483647, %edx + je .L_2TAG_PACKET_11.0.1 + andl $2139095040, %edx + jne .L_2TAG_PACKET_11.0.1 + movss 48(%rsp), %xmm1 + orps 6864(%r8), %xmm1 + cvtss2sd %xmm1, %xmm1 + movsd 6896(%r8), %xmm2 + andpd %xmm1, %xmm2 + orpd 6880(%r8), %xmm2 + subsd %xmm2, %xmm1 + movsd %xmm1, 32(%rsp) +.L_2TAG_PACKET_11.0.1: + movsd 40(%rsp), %xmm0 + movsd 32(%rsp), %xmm1 + pextrw $3, %xmm0, %edx + andl $32752, %edx + subl $16, %edx + cmpl $32736, %edx + jae .L_2TAG_PACKET_12.0.1 + pextrw $3, %xmm1, %edx + andl $32752, %edx + subl $16, %edx + cmpl $32736, %edx + jae .L_2TAG_PACKET_13.0.1 + movq %xmm0, %xmm3 + divsd %xmm1, %xmm0 + movq 6656(%r8), %xmm2 + mulsd %xmm1, %xmm1 + mulsd %xmm3, %xmm3 + addsd %xmm3, %xmm1 + movq %xmm1, 16(%rsp) + pand %xmm1, %xmm2 + pextrw $3, %xmm1, %edx + subsd 6784(%r8), %xmm1 + pand 6672(%r8), %xmm1 + cmpltsd 6576(%r8), %xmm1 + movmskpd %xmm1, %ebx + por 6784(%r8), %xmm2 + testl $1, %ebx + psllq $1, %xmm0 + psrlq $1, %xmm0 + jne .L_2TAG_PACKET_2.0.1 + jmp .L_2TAG_PACKET_3.0.1 +.L_2TAG_PACKET_12.0.1: + addl $16, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_14.0.1 + movsd %xmm0, %xmm2 + psllq $12, %xmm2 + xorpd %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + je .L_2TAG_PACKET_15.0.1 + movss 56(%rsp), %xmm0 + movl 48(%rsp), %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + mulss %xmm0, %xmm0 + jg .L_2TAG_PACKET_16.0.1 + je .L_2TAG_PACKET_17.0.1 + movd %xmm0, %edx + movd %xmm0, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_17.0.1: + movd %xmm0, %edx + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_16.0.1: + movss 48(%rsp), %xmm1 + mulss %xmm0, %xmm0 + mulss %xmm1, %xmm1 + movd %xmm0, %edx + movd %xmm1, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_14.0.1: + pextrw $3, %xmm1, %edx + andl $32752, %edx + cmpl $32752, %edx + jne .L_2TAG_PACKET_18.0.1 + movsd %xmm1, %xmm2 + psllq $12, %xmm2 + xorpd %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + jne .L_2TAG_PACKET_19.0.1 +.L_2TAG_PACKET_18.0.1: + cmpl $0, %ecx + jne .L_2TAG_PACKET_20.0.1 + movl %eax, %edx + movl 48(%rsp), %eax + cmpl $0, %eax + je .L_2TAG_PACKET_21.0.1 + cmpl $2139095040, %eax + je .L_2TAG_PACKET_22.0.1 + movl 48(%rsp), %eax + movl %edx, 8(%rsp) + andl $2147483647, %eax + movl %eax, 4(%rsp) + jmp .L_2TAG_PACKET_23.0.1 +.L_2TAG_PACKET_20.0.1: + movss 6920(%r8), %xmm2 + movss 6924(%r8), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl 48(%rsp), %eax + cmpl $-2147483648, %eax + je .L_2TAG_PACKET_21.0.1 + cmpl $-8388608, %eax + je .L_2TAG_PACKET_22.0.1 + movl 48(%rsp), %eax + movl %edx, 8(%rsp) + andl $2147483647, %eax + movl %eax, 4(%rsp) + jmp .L_2TAG_PACKET_23.0.1 +.L_2TAG_PACKET_21.0.1: + pxor %xmm1, %xmm1 + movss 6648(%r8), %xmm0 + divss %xmm1, %xmm0 + movl $-8388608, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_22.0.1: + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_15.0.1: + pextrw $3, %xmm1, %edx + andl $32752, %edx + cmpl $32752, %edx + je .L_2TAG_PACKET_24.0.1 + movss 6912(%r8), %xmm2 + movss 6916(%r8), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_24.0.1: + movsd %xmm1, %xmm2 + psllq $12, %xmm2 + xorpd %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + jne .L_2TAG_PACKET_25.0.1 + cmpl $0, %ecx + je .L_2TAG_PACKET_26.0.1 + movss 6912(%r8), %xmm2 + movss 6916(%r8), %xmm3 + movss 6928(%r8), %xmm4 + movss 6932(%r8), %xmm5 + addss %xmm3, %xmm2 + addss %xmm5, %xmm4 + addss %xmm4, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_26.0.1: + movss 6928(%r8), %xmm4 + movss 6932(%r8), %xmm5 + addss %xmm5, %xmm4 + movd %xmm4, %edx + orl %eax, %edx + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_13.0.1: + addl $16, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_27.0.1 + movsd %xmm1, %xmm2 + psllq $12, %xmm2 + xorps %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm2 + psrlq $16, %xmm2 + movd %xmm2, %edx + cmpl $-1, %edx + jne .L_2TAG_PACKET_19.0.1 + cmpl $0, %ecx + jne .L_2TAG_PACKET_28.0.1 + movl %eax, %edx + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_28.0.1: + movss 6920(%r8), %xmm2 + movss 6924(%r8), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_27.0.1: + movss 6912(%r8), %xmm2 + movss 6916(%r8), %xmm3 + addss %xmm3, %xmm2 + movd %xmm2, %edx + orl %eax, %edx + movl 56(%rsp), %eax + movl %edx, 8(%rsp) + andl $2147483647, %eax + movl %eax, 4(%rsp) + jmp .L_2TAG_PACKET_23.0.1 +.L_2TAG_PACKET_19.0.1: + addsd %xmm1, %xmm1 + cvtpd2ps %xmm1, %xmm0 + movd %xmm0, %edx + movl %edx, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_25.0.1: + addsd %xmm1, %xmm1 + cvtpd2ps %xmm1, %xmm0 + movd %xmm0, %edx + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_23.0.1: + movss 4(%rsp), %xmm0 + movsd 6624(%r8), %xmm1 + movsd 6632(%r8), %xmm3 + pextrw $1, %xmm0, %eax + movaps %xmm0, %xmm4 + psllq $29, %xmm0 + andpd %xmm0, %xmm1 + orpd %xmm3, %xmm1 + movsd 6592(%r8), %xmm5 + movsd 6600(%r8), %xmm6 + movsd 6608(%r8), %xmm2 + movl %eax, %edx + movl $32639, %ecx + subl %edx, %ecx + subl $128, %edx + orl %ecx, %edx + cmpl $32768, %edx + jae .L_2TAG_PACKET_29.0.1 + movl $16191, %ecx +.L_2TAG_PACKET_30.0.1: + movd %ecx, %xmm0 + movsd 4624(%r8), %xmm3 + andl $127, %eax + addl $1, %eax + andq $254, %rax + addq %rax, %rax + addq %rax, %rax + movsd 4624(%r8,%rax), %xmm7 + psrlq $16, %xmm4 + psubd %xmm0, %xmm4 + psrad $7, %xmm4 + cvtdq2pd %xmm4, %xmm4 + movsd 4096(%r8,%rax), %xmm0 + mulsd %xmm7, %xmm1 + subsd %xmm3, %xmm1 + movsd %xmm1, %xmm7 + mulsd %xmm1, %xmm5 + movsd %xmm1, %xmm3 + mulsd %xmm1, %xmm1 + addsd %xmm6, %xmm5 + mulsd 6664(%r8), %xmm4 + mulsd %xmm1, %xmm7 + mulsd %xmm1, %xmm2 + addsd %xmm3, %xmm2 + mulsd %xmm5, %xmm7 + addsd %xmm4, %xmm0 + addsd %xmm7, %xmm2 + addsd %xmm2, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movd %xmm0, %eax + movl 8(%rsp), %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 80(%rsp), %rbx + movq 72(%rsp), %rsp + ret +.L_2TAG_PACKET_29.0.1: + movl 4(%rsp), %edx + mulss 6640(%r8), %xmm4 + movsd 6624(%r8), %xmm1 + pextrw $1, %xmm4, %eax + cvtps2pd %xmm4, %xmm0 + andpd %xmm0, %xmm1 + orpd %xmm3, %xmm1 + movl $24383, %ecx + jmp .L_2TAG_PACKET_30.0.1 + .cfi_def_cfa_offset 8 +..B1.3: + .align 16,0x90 + .cfi_endproc + .type clogf,@function + .size clogf,.-clogf + .data +# -- End clogf + .section .rodata, "a" + .align 16 + .align 16 +clogf_table: + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .long 1440057502 + .long 1063257089 + .long 341338964 + .long 1064833554 + .long 4184355568 + .long 1065621801 + .long 2227658503 + .long 1066152307 + .long 449262470 + .long 1066510009 + .long 1570422842 + .long 1066777242 + .long 121841140 + .long 1067045544 + .long 630691842 + .long 1067281191 + .long 2711485097 + .long 1067500943 + .long 2026622491 + .long 1067619660 + .long 766078039 + .long 1067755853 + .long 4074027864 + .long 1067875476 + .long 3056660584 + .long 1067995528 + .long 3195252556 + .long 1068133258 + .long 116861598 + .long 1068254238 + .long 325086471 + .long 1068375655 + .long 296456961 + .long 1068497513 + .long 2623383041 + .long 1068559379 + .long 1681725707 + .long 1068620754 + .long 2231263004 + .long 1068682354 + .long 2815553124 + .long 1068744181 + .long 2057310944 + .long 1068806237 + .long 2095798018 + .long 1068859611 + .long 2302040698 + .long 1068922096 + .long 745232013 + .long 1068984815 + .long 659581512 + .long 1069047769 + .long 1566132617 + .long 1069101918 + .long 550036981 + .long 1069165314 + .long 2887419564 + .long 1069219844 + .long 1990183441 + .long 1069283688 + .long 3220050856 + .long 1069338605 + .long 1669613218 + .long 1069393703 + .long 2145455994 + .long 1069458213 + .long 4275830246 + .long 1069513705 + .long 1392453108 + .long 1069558451 + .long 1469915213 + .long 1069586382 + .long 2183652476 + .long 1069619086 + .long 2109656884 + .long 1069647220 + .long 636640577 + .long 1069675449 + .long 510517079 + .long 1069703773 + .long 210141498 + .long 1069732193 + .long 2537624622 + .long 1069760709 + .long 1733817001 + .long 1069789323 + .long 137854980 + .long 1069813243 + .long 3905576828 + .long 1069842036 + .long 4131810788 + .long 1069870929 + .long 3760956694 + .long 1069899922 + .long 1473082581 + .long 1069929016 + .long 926113142 + .long 1069953338 + .long 3669742467 + .long 1069982617 + .long 3711755290 + .long 1070007095 + .long 311386407 + .long 1070036564 + .long 705364525 + .long 1070066136 + .long 1973375279 + .long 1070090859 + .long 3589645072 + .long 1070115655 + .long 2425772059 + .long 1070145508 + .long 1074899574 + .long 1070170467 + .long 118003300 + .long 1070200516 + .long 691310403 + .long 1070225639 + .long 3273036717 + .long 1070250837 + .long 1226436560 + .long 1070276112 + .long 2481153995 + .long 1070306542 + .long 3227997535 + .long 1070331985 + .long 1421812646 + .long 1070357506 + .long 3386588242 + .long 1070383104 + .long 2580043380 + .long 1070408781 + .long 1068692560 + .long 1070434537 + .long 938143489 + .long 1070460372 + .long 4293333010 + .long 1070486286 + .long 373864817 + .long 1070512282 + .long 4208958430 + .long 1070538357 + .long 783121462 + .long 1070564515 + .long 870975437 + .long 1070590754 + .long 3338886172 + .long 1070606585 + .long 3772343130 + .long 1070619787 + .long 2408245143 + .long 1070630379 + .long 3811383569 + .long 1070643656 + .long 1622638721 + .long 1070656976 + .long 1290798655 + .long 1070670338 + .long 2457529556 + .long 1070681058 + .long 2398194399 + .long 1070694497 + .long 3190801979 + .long 1070707979 + .long 3352241197 + .long 1070718796 + .long 1829681364 + .long 1070732357 + .long 2568927817 + .long 1070743237 + .long 2676427515 + .long 1070756877 + .long 2882402820 + .long 1070767821 + .long 44944622 + .long 1070781542 + .long 2957945300 + .long 1070792550 + .long 1261787704 + .long 1070806352 + .long 1589923677 + .long 1070817426 + .long 3274931829 + .long 1070828529 + .long 1999843716 + .long 1070842450 + .long 1673619518 + .long 1070853620 + .long 601221319 + .long 1070864820 + .long 3763576649 + .long 1070876049 + .long 1974923437 + .long 1070890129 + .long 1096100617 + .long 1070901427 + .long 2424897952 + .long 1070912755 + .long 2376202600 + .long 1070924114 + .long 1665651958 + .long 1070935504 + .long 1014729354 + .long 1070946925 + .long 722545241 + .long 1070961245 + .long 1800682930 + .long 1070972736 + .long 1029453230 + .long 1070984259 + .long 3450874911 + .long 1070995813 + .long 1228255906 + .long 1071007400 + .long 3711032981 + .long 1071019018 + .long 3075102917 + .long 1071030669 + .long 92696812 + .long 1071042353 + .long 3897749690 + .long 1071051136 + .long 1907922160 + .long 1071062877 + .long 4023807324 + .long 1071074650 + .long 2452345726 + .long 1071086457 + .long 2292128226 + .long 1071098297 + .long 58635942 + .long 1071110171 + .long 864186929 + .long 1071122078 + .long 3555691467 + .long 1071131030 + .long 2003684347 + .long 1071142997 + .long 1479703759 + .long 1071154998 + .long 2537208015 + .long 1071164021 + .long 3699909861 + .long 1071176082 + .long 3934098706 + .long 1071188178 + .long 3885764182 + .long 1071197273 + .long 1357790931 + .long 1071209431 + .long 295956059 + .long 1071221624 + .long 4080877676 + .long 1071230791 + .long 202970280 + .long 1071243047 + .long 3977575845 + .long 1071252261 + .long 35977849 + .long 1071264580 + .long 1585496963 + .long 1071273842 + .long 375247257 + .long 1071286224 + .long 1812199574 + .long 1071295534 + .long 1876912769 + .long 1071307980 + .long 1051846544 + .long 1071317339 + .long 979589448 + .long 1071329850 + .long 71706889 + .long 1071339258 + .long 2790898835 + .long 1071351834 + .long 4013797733 + .long 1071361291 + .long 2541231151 + .long 1071370770 + .long 921733145 + .long 1071383442 + .long 508375805 + .long 1071392971 + .long 3091669954 + .long 1071402521 + .long 3343209673 + .long 1071415289 + .long 1693047557 + .long 1071424891 + .long 173861808 + .long 1071434515 + .long 3515822703 + .long 1071444160 + .long 1974837761 + .long 1071457056 + .long 1189018219 + .long 1071466754 + .long 2441946573 + .long 1071476474 + .long 1887102255 + .long 1071486217 + .long 4271031636 + .long 1071495982 + .long 876995759 + .long 1071509039 + .long 438773454 + .long 1071518858 + .long 172621632 + .long 1071528700 + .long 544035182 + .long 1071538565 + .long 2021801298 + .long 1071548453 + .long 783063308 + .long 1071558365 + .long 1598254051 + .long 1071568300 + .long 651258553 + .long 1071578259 + .long 2719315456 + .long 1071588241 + .long 3993180461 + .long 1071598247 + .long 667093936 + .long 1071608278 + .long 1823716217 + .long 1071618332 + .long 3664357648 + .long 1071628410 + .long 2393914686 + .long 1071638513 + .long 1405419566 + .long 1071646656 + .long 563652001 + .long 1071651732 + .long 1074554091 + .long 1071656820 + .long 3195405229 + .long 1071661920 + .long 2890399284 + .long 1071667033 + .long 420597586 + .long 1071672159 + .long 87278952 + .long 1071675583 + .long 1753119502 + .long 1071680729 + .long 1959759897 + .long 1071685888 + .long 975389815 + .long 1071691060 + .long 3365155278 + .long 1071696244 + .long 811309190 + .long 1071701442 + .long 1269811480 + .long 1071704914 + .long 1108583542 + .long 1071710133 + .long 1034517919 + .long 1071715365 + .long 1327340287 + .long 1071720610 + .long 1388251237 + .long 1071724114 + .long 1488234797 + .long 1071729381 + .long 2711385691 + .long 1071734661 + .long 952179194 + .long 1071738189 + .long 3255685427 + .long 1071743491 + .long 3159039803 + .long 1071748807 + .long 951558972 + .long 1071752359 + .long 3234424125 + .long 1071757697 + .long 3904573547 + .long 1071763049 + .long 2648729924 + .long 1071766625 + .long 2729250212 + .long 1071772000 + .long 2000712574 + .long 1071777389 + .long 3125257108 + .long 1071780989 + .long 3160324803 + .long 1071786401 + .long 2216316974 + .long 1071790017 + .long 3875016090 + .long 1071795452 + .long 1439520610 + .long 1071799084 + .long 1298103361 + .long 1071804543 + .long 2217517956 + .long 1071810016 + .long 1191753587 + .long 1071813673 + .long 1728773900 + .long 1071819170 + .long 747445441 + .long 1071822843 + .long 1670772213 + .long 1071826522 + .long 1471209283 + .long 1071832053 + .long 3287905877 + .long 1071835748 + .long 594038131 + .long 1071841304 + .long 3920147917 + .long 1071845015 + .long 3957142762 + .long 1071850595 + .long 826988438 + .long 1071854324 + .long 242509008 + .long 1071859929 + .long 4173610350 + .long 1071863673 + .long 2518313625 + .long 1071867425 + .long 2671523434 + .long 1071873065 + .long 387544807 + .long 1071876834 + .long 1470497767 + .long 1071880609 + .long 4269259217 + .long 1071886284 + .long 1345663925 + .long 1071890077 + .long 2159323299 + .long 1071893876 + .long 957937516 + .long 1071899588 + .long 2994656967 + .long 1071903404 + .long 556124819 + .long 1071907228 + .long 1631098658 + .long 1071912976 + .long 1368257861 + .long 1071916817 + .long 1309849279 + .long 1071920665 + .long 1567156841 + .long 1071924520 + .long 1179420986 + .long 1071930316 + .long 569448444 + .long 1071934189 + .long 669557459 + .long 1071938069 + .long 1593834700 + .long 1071941956 + .long 3166083125 + .long 1071947800 + .long 211641815 + .long 1071951706 + .long 2780675719 + .long 1071955618 + .long 2400234567 + .long 1071959538 + .long 3482927192 + .long 1071963465 + .long 1852089988 + .long 1071967400 + .long 1020849000 + .long 1071973316 + .long 1718090839 + .long 1071977269 + .long 121152472 + .long 1071981230 + .long 646346839 + .long 1071985198 + .long 3415709705 + .long 1071989173 + .long 4257004898 + .long 1071993156 + .long 3293664199 + .long 1071997147 + .long 649825382 + .long 1072001146 + .long 248887552 + .long 1072007158 + .long 2541522737 + .long 1072011175 + .long 3593780107 + .long 1072015200 + .long 3533041935 + .long 1072019233 + .long 2487426809 + .long 1072023274 + .long 585795318 + .long 1072027323 + .long 2252723088 + .long 1072031379 + .long 3323604690 + .long 1072035443 + .long 3929561382 + .long 1072039515 + .long 4202479723 + .long 1072043595 + .long 4275017539 + .long 1072047683 + .long 0 + .long 0 + .long 2969299638 + .long 1066385576 + .long 242759278 + .long 1067418267 + .long 4130528649 + .long 1067938904 + .long 3222363743 + .long 1068436016 + .long 2518406343 + .long 1068712407 + .long 2330290349 + .long 1068953810 + .long 977983493 + .long 1069191789 + .long 1848308976 + .long 1069426439 + .long 2094042057 + .long 1069602686 + .long 4162844547 + .long 1069716818 + .long 1825274911 + .long 1069829419 + .long 1890030541 + .long 1069940528 + .long 34658761 + .long 1070050185 + .long 2633258952 + .long 1070158426 + .long 1317059912 + .long 1070265289 + .long 3348798148 + .long 1070370807 + .long 1848308976 + .long 1070475015 + .long 1834892534 + .long 1070577944 + .long 3799224489 + .long 1070637860 + .long 2880153273 + .long 1070688092 + .long 4224678190 + .long 1070737729 + .long 3135315492 + .long 1070786786 + .long 1432962655 + .long 1070835276 + .long 3256639515 + .long 1070883211 + .long 2267936667 + .long 1070930605 + .long 3210218142 + .long 1070977469 + .long 513480033 + .long 1071023816 + .long 4139503392 + .long 1071069655 + .long 998420681 + .long 1071115000 + .long 2260812359 + .long 1071159859 + .long 471930696 + .long 1071204244 + .long 288677044 + .long 3218237794 + .long 1666870396 + .long 3218194329 + .long 2183652263 + .long 3218151310 + .long 1615681869 + .long 3218108728 + .long 1823715893 + .long 3218053404 + .long 4293333700 + .long 3217969934 + .long 4066729029 + .long 3217887287 + .long 943445964 + .long 3217805447 + .long 1015733272 + .long 3217724397 + .long 3707174790 + .long 3217644122 + .long 1699848676 + .long 3217564609 + .long 2339728692 + .long 3217485842 + .long 1800683248 + .long 3217407808 + .long 2201203741 + .long 3217330493 + .long 2954203727 + .long 3217253884 + .long 709476838 + .long 3217177969 + .long 2183652973 + .long 3217102734 + .long 970708496 + .long 3217025169 + .long 1669614391 + .long 3216877351 + .long 2376949106 + .long 3216730824 + .long 1566133827 + .long 3216585566 + .long 183157569 + .long 3216441555 + .long 1562411141 + .long 3216298769 + .long 2756121236 + .long 3216157188 + .long 3047046473 + .long 3216016792 + .long 3453858674 + .long 3215772531 + .long 346008798 + .long 3215496362 + .long 3559775130 + .long 3215222446 + .long 2313636156 + .long 3214950749 + .long 684243850 + .long 3214428453 + .long 1486053291 + .long 3213893718 + .long 1971906393 + .long 3212840981 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 528611360 + .long 1072660984 + .long 4034666248 + .long 1072629697 + .long 2884679527 + .long 1072599345 + .long 505290270 + .long 1072569886 + .long 1991868891 + .long 1072541280 + .long 490853405 + .long 1072513492 + .long 2298714891 + .long 1072486486 + .long 477218588 + .long 1072460231 + .long 58835168 + .long 1072434695 + .long 348240592 + .long 1072409849 + .long 3035110223 + .long 1072385665 + .long 3164712744 + .long 1072362118 + .long 1617585086 + .long 1072339183 + .long 440509466 + .long 1072316836 + .long 2500867033 + .long 1072295054 + .long 2576980378 + .long 1072273817 + .long 4241943008 + .long 1072253104 + .long 2409371898 + .long 1072232897 + .long 258732970 + .long 1072213177 + .long 409044504 + .long 1072193926 + .long 404232216 + .long 1072175128 + .long 1098712564 + .long 1072156767 + .long 2172167368 + .long 1072138828 + .long 1952257862 + .long 1072121297 + .long 1544257904 + .long 1072104160 + .long 381774871 + .long 1072087404 + .long 377579543 + .long 1072071016 + .long 1493901668 + .long 1072054984 + .long 1616385542 + .long 1072039297 + .long 731058263 + .long 1072023944 + .long 813783277 + .long 1072008914 + .long 1431655765 + .long 1071994197 + .long 3940743189 + .long 1071979783 + .long 2804876601 + .long 1071965664 + .long 2689777499 + .long 1071951830 + .long 1202590843 + .long 1071938273 + .long 1700977147 + .long 1071924984 + .long 336860180 + .long 1071911956 + .long 3169102082 + .long 1071899180 + .long 330382100 + .long 1071886651 + .long 327235604 + .long 1071874360 + .long 4213930177 + .long 1071862300 + .long 1244336319 + .long 1071850467 + .long 3181457256 + .long 1071838852 + .long 1300311200 + .long 1071827451 + .long 702812830 + .long 1071816257 + .long 3095471925 + .long 1071805264 + .long 2454267026 + .long 1071794468 + .long 2166487928 + .long 1071783863 + .long 2109808496 + .long 1071773444 + .long 2913108253 + .long 1071763206 + .long 1629125526 + .long 1071753145 + .long 293672978 + .long 1071743256 + .long 1601513229 + .long 1071733534 + .long 288737297 + .long 1071723976 + .long 286331153 + .long 1071714577 + .long 1810275472 + .long 1071705333 + .long 1337776699 + .long 1071696241 + .long 174592167 + .long 1071687297 + .long 138547332 + .long 1071678497 + .long 3539053052 + .long 1071669837 + .long 272696336 + .long 1071661316 + .long 2164392968 + .long 1071652928 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3819695742 + .long 1067482761 + .long 2998791009 + .long 1067548225 + .long 3339424991 + .long 1067613680 + .long 2710002256 + .long 1067679126 + .long 3275701428 + .long 1067744562 + .long 2908636881 + .long 1067809988 + .long 3777889398 + .long 1067875403 + .long 3759667419 + .long 1067940807 + .long 732369940 + .long 1068006200 + .long 1166616461 + .long 1068071580 + .long 2945472892 + .long 1068136947 + .long 3954480976 + .long 1068202301 + .long 2081752829 + .long 1068267642 + .long 3807999788 + .long 1068332968 + .long 2731789884 + .long 1068398280 + .long 1044477961 + .long 1068463577 + .long 1486930287 + .long 1068530218 + .long 2293016881 + .long 1068595466 + .long 201518157 + .long 1068660680 + .long 4054234584 + .long 1068725856 + .long 1246477213 + .long 1068790995 + .long 678186699 + .long 1068856093 + .long 2690594995 + .long 1068921148 + .long 3362611517 + .long 1068986159 + .long 3102162111 + .long 1069051124 + .long 2352611067 + .long 1069116041 + .long 1594134794 + .long 1069180908 + .long 1345079306 + .long 1069245723 + .long 2163300970 + .long 1069310484 + .long 352522716 + .long 1069375190 + .long 848541647 + .long 1069439838 + .long 40647312 + .long 1069504427 + .long 2216766270 + .long 1069574357 + .long 1090914384 + .long 1069638757 + .long 387601244 + .long 1069703022 + .long 3991640484 + .long 1069767144 + .long 3322489502 + .long 1069831118 + .long 3121698570 + .long 1069894936 + .long 4289964660 + .long 1069958591 + .long 3903312386 + .long 1070022077 + .long 3818449864 + .long 1070085387 + .long 2097480306 + .long 1070148515 + .long 1611694502 + .long 1070211454 + .long 1464694796 + .long 1070274198 + .long 1299612775 + .long 1070336741 + .long 1310544789 + .long 1070399077 + .long 2253168030 + .long 1070461200 + .long 1159567373 + .long 1070523105 + .long 1359373750 + .long 1070605818 + .long 908341706 + .long 1070667034 + .long 1743027350 + .long 1070727765 + .long 2055355646 + .long 1070787992 + .long 690426164 + .long 1070847697 + .long 1483247847 + .long 1070906862 + .long 392040270 + .long 1070965472 + .long 2673846014 + .long 1071023511 + .long 1384215810 + .long 1071080967 + .long 3101660631 + .long 1071137826 + .long 2094057058 + .long 1071194078 + .long 1712750594 + .long 1071249712 + .long 1411515787 + .long 1071304719 + .long 931538085 + .long 1071359091 + .long 179139065 + .long 1071412821 + .long 3387721259 + .long 1071465902 + .long 2132236852 + .long 1071544299 + .long 1942070284 + .long 1071645596 + .long 1532707802 + .long 1071695380 + .long 2294184979 + .long 1071743834 + .long 3805060714 + .long 1071790961 + .long 2215037898 + .long 1071836770 + .long 483661594 + .long 1071881273 + .long 1534679894 + .long 1071924486 + .long 1538714628 + .long 1071966430 + .long 527642555 + .long 1072007128 + .long 291339150 + .long 1072046605 + .long 2450210201 + .long 1072084888 + .long 2411367951 + .long 1072122007 + .long 681549971 + .long 1072157992 + .long 1466745541 + .long 1072192873 + .long 2845622366 + .long 1072226682 + .long 2838871438 + .long 1072275456 + .long 4200275274 + .long 1072337034 + .long 3034733530 + .long 1072394897 + .long 3207412993 + .long 1072449290 + .long 624461478 + .long 1072500450 + .long 767665908 + .long 1072548600 + .long 1110773639 + .long 1072593952 + .long 1940828530 + .long 1072636704 + .long 1911329388 + .long 1072677041 + .long 1764715788 + .long 1072704191 + .long 3332979233 + .long 1072722195 + .long 1321870254 + .long 1072739231 + .long 3657429030 + .long 1072755365 + .long 4197624557 + .long 1072770661 + .long 1512059493 + .long 1072785177 + .long 453379037 + .long 1072798965 + .long 1942345162 + .long 1072818388 + .long 4210176273 + .long 1072842164 + .long 4185644010 + .long 1072863795 + .long 679688788 + .long 1072883543 + .long 29432865 + .long 1072901630 + .long 4070721092 + .long 1072918247 + .long 2252468843 + .long 1072933561 + .long 2929724825 + .long 1072947712 + .long 1377513368 + .long 1072960824 + .long 1031632908 + .long 1072973003 + .long 2516508130 + .long 1072984342 + .long 3792452178 + .long 1072994923 + .long 3147791459 + .long 1073004818 + .long 999189752 + .long 1073014090 + .long 711011011 + .long 1073022794 + .long 15640363 + .long 1073030980 + .long 1218463589 + .long 1073042382 + .long 2538470555 + .long 1073056144 + .long 1229720947 + .long 1073068489 + .long 3115427016 + .long 1073079621 + .long 4030612557 + .long 1073089709 + .long 2728521257 + .long 1073098892 + .long 1118696283 + .long 1073107285 + .long 2682711255 + .long 1073114984 + .long 2073898081 + .long 1073122072 + .long 1403700297 + .long 1073128618 + .long 2502685617 + .long 1073134681 + .long 1531926851 + .long 1073140313 + .long 3572814411 + .long 1073145557 + .long 1695536111 + .long 1073150453 + .long 2363057203 + .long 1073155033 + .long 2873365682 + .long 1073159327 + .long 1053384691 + .long 1073165288 + .long 3270542712 + .long 1073172451 + .long 1353631484 + .long 1073178850 + .long 3511218460 + .long 1073184599 + .long 4121259284 + .long 1073189793 + .long 1193862106 + .long 1073194509 + .long 3861949790 + .long 1073198808 + .long 1486904578 + .long 1073202745 + .long 2879153715 + .long 1073206362 + .long 385353253 + .long 1073209698 + .long 1125865839 + .long 1073212783 + .long 1221361475 + .long 1073215645 + .long 2077323573 + .long 1073218307 + .long 215611373 + .long 1073220790 + .long 2347419265 + .long 1073223110 + .long 1379112765 + .long 1073225284 + .long 3891198463 + .long 1073228298 + .long 3395914051 + .long 1073231917 + .long 2799919478 + .long 1073235146 + .long 1138673476 + .long 1073238045 + .long 3408855940 + .long 1073240661 + .long 2044858738 + .long 1073243035 + .long 2578795176 + .long 1073245198 + .long 4196285314 + .long 1073247177 + .long 224877747 + .long 1073248996 + .long 3271386490 + .long 1073250671 + .long 813635989 + .long 1073252221 + .long 369829519 + .long 1073253658 + .long 1187679052 + .long 1073254994 + .long 4232586098 + .long 1073256239 + .long 426690558 + .long 1073257404 + .long 1624065902 + .long 1073258494 + .long 84029729 + .long 1073260006 + .long 700437654 + .long 1073261820 + .long 1437260555 + .long 1073263438 + .long 2813372195 + .long 1073264890 + .long 1607849324 + .long 1073266201 + .long 1011572952 + .long 1073267390 + .long 2039290225 + .long 1073268473 + .long 2435855138 + .long 1073269464 + .long 3389310384 + .long 1073270374 + .long 2790682322 + .long 1073271213 + .long 960266323 + .long 1073271989 + .long 1766929455 + .long 1073272708 + .long 627058932 + .long 1073273377 + .long 2388650377 + .long 1073274000 + .long 422252385 + .long 1073274583 + .long 2848853896 + .long 1073275128 + .long 1413754136 + .long 1073291771 + .long 3951369912 + .long 1067366481 + .long 3951369912 + .long 3214850129 + .long 0 + .long 3218079744 + .long 1431655765 + .long 1070945621 + .long 0 + .long 3219128320 + .long 0 + .long 0 + .long 4294967295 + .long 1048575 + .long 0 + .long 1072693248 + .long 1602224128 + .long 1602224128 + .long 1065353216 + .long 1065353216 + .long 4294967295 + .long 1048575 + .long 4277811695 + .long 1072049730 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 0 + .long 1072693248 + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .long 0 + .long 0 + .long 12982 + .long 1071644672 + .long 3503368358 + .long 3218079743 + .long 300625100 + .long 1069897045 + .long 3513684914 + .long 3217031970 + .long 1735899863 + .long 1069129695 + .long 0 + .long 0 + .long 2147483647 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 2147418112 + .long 0 + .long 2147418112 + .long 0 + .long 32768 + .long 0 + .long 32768 + .long 1413754136 + .long 3221823995 + .long 0 + .long 0 + .long 2576980378 + .long 1070176665 + .long 1431655765 + .long 3218429269 + .long 8388608 + .long 0 + .long 0 + .long 0 + .long 0 + .long 940572672 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 1070141402 + .long 866263400 + .long 1078530010 + .long 874652008 + .long 1061752794 + .long 857874792 + .long 0 + .long 0 + .long 1431655765 + .long 3218429269 + .long 0 + .long 0 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .type clogf_table,@object + .size clogf_table,6976 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/clogl.S b/external/sgx_libm/intel64/clogl.S new file mode 100644 index 0000000000..8f4023dcf6 --- /dev/null +++ b/external/sgx_libm/intel64/clogl.S @@ -0,0 +1,783 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "clogl.c" + .text +..TXTST0: +# -- Begin clogl + .text + .align 16,0x90 + .globl clogl +clogl: +# parameter 1: 192 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_clogl.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + subq $176, %rsp + .cfi_def_cfa_offset 192 + xorb %r13b, %r13b + fldt .L_2il0floatpacket.6(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 160(%rsp) + fstpt 128(%rsp) + fldt 128(%rsp) + fstpt 144(%rsp) +..B1.2: + fnstcw 114(%rsp) +..B1.3: + movzwl 114(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 112(%rsp) +..B1.5: + fldcw 112(%rsp) +..B1.6: + movb $1, %r13b +..B1.7: + movzwl 200(%rsp), %edx + andl $32767, %edx + movzwl 216(%rsp), %eax + andl $32767, %eax + cmpl $32767, %edx + jge ..B1.47 +..B1.8: + cmpl $32767, %eax + jge ..B1.88 +..B1.9: + testl %edx, %edx + jne ..B1.15 +..B1.10: + cmpl $0, 196(%rsp) + jne ..B1.15 +..B1.11: + cmpl $0, 192(%rsp) + jne ..B1.15 +..B1.12: + testl %eax, %eax + jne ..B1.15 +..B1.13: + cmpl $0, 212(%rsp) + jne ..B1.15 +..B1.14: + cmpl $0, 208(%rsp) + je ..B1.46 +..B1.15: + fldt 192(%rsp) + fld %st(0) + fabs + fstpt (%rsp) + fldt (%rsp) + fldt 208(%rsp) + fld %st(0) + fabs + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 8(%rsp), %eax + movzwl 24(%rsp), %edx + andl $32767, %eax + andl $32767, %edx + cmpl %edx, %eax + jl ..B1.20 +..B1.16: + jne ..B1.21 +..B1.17: + movl 4(%rsp), %edx + movl 20(%rsp), %ecx + cmpl %ecx, %edx + jb ..B1.20 +..B1.18: + jne ..B1.21 +..B1.19: + movl (%rsp), %edx + cmpl 16(%rsp), %edx + jae ..B1.21 +..B1.20: + fstpt (%rsp) + fldt (%rsp) + movzwl 8(%rsp), %eax + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + andl $32767, %eax +..B1.21: + cmpl $16382, %eax + jg ..B1.26 +..B1.22: + jne ..B1.43 +..B1.23: + lea 16+_CONSTANTS(%rip), %rcx + movl 4(%rsp), %edx + cmpl 4(%rcx), %edx + ja ..B1.26 +..B1.24: + jne ..B1.43 +..B1.25: + movl (%rcx), %edx + cmpl (%rsp), %edx + ja ..B1.43 +..B1.26: + cmpl $16383, %eax + jl ..B1.31 +..B1.27: + jne ..B1.43 +..B1.28: + lea 32+_CONSTANTS(%rip), %rcx + movl 4(%rsp), %edx + cmpl 4(%rcx), %edx + jb ..B1.31 +..B1.29: + jne ..B1.43 +..B1.30: + movl (%rsp), %edx + cmpl (%rcx), %edx + ja ..B1.43 +..B1.31: + movzwl 24(%rsp), %esi + andl $32767, %esi + cmpl $8256, %esi + jg ..B1.36 +..B1.32: + jne ..B1.37 +..B1.33: + lea 80+_CONSTANTS(%rip), %rcx + movl 20(%rsp), %edx + cmpl 4(%rcx), %edx + ja ..B1.36 +..B1.34: + jne ..B1.37 +..B1.35: + movl 16(%rsp), %edx + cmpl (%rcx), %edx + jbe ..B1.37 +..B1.36: + fld %st(2) + lea _CONSTANTS(%rip), %rdx + fmul %st(3), %st + fld %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fldt .L_2il0floatpacket.7(%rip) + fsubr %st, %st(1) + fxch %st(1) + fabs + fldt (%rdx) + fcomip %st(1), %st + ja ..B1.38 + jmp ..B1.89 +..B1.37: + fldt .L_2il0floatpacket.7(%rip) + fld %st(3) + fmul %st(4), %st + lea _CONSTANTS(%rip), %rdx + fsub %st(1), %st + fabs + fldt (%rdx) + fcomip %st(1), %st + jbe ..B1.89 +..B1.38: + cmpl $16183, %esi + jl ..B1.40 +..B1.39: + fstp %st(0) + fldt .L_2il0floatpacket.11(%rip) + fld %st(4) + fxch %st(6) + fstpt 16(%rsp) + lea 16+_Q1(%rip), %rax + fxch %st(3) + fstpt (%rsp) + lea _Q1(%rip), %rdx + fldt .L_2il0floatpacket.10(%rip) + fmul %st(4), %st + fsub %st, %st(5) + fsubp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fld %st(2) + fxch %st(5) + fsub %st(6), %st + fxch %st(4) + fmul %st, %st(6) + fxch %st(4) + fmul %st, %st(6) + fmul %st(0), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fldt .L_2il0floatpacket.10(%rip) + fmul %st(4), %st + fsub %st, %st(6) + fsubp %st, %st(6) + fld %st(5) + fmul %st(6), %st + fxch %st(4) + fsub %st(6), %st + fxch %st(5) + fmulp %st, %st(6) + fxch %st(4) + fmul %st, %st(5) + fxch %st(5) + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(5) + fmul %st(0), %st + fstpt 64(%rsp) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fld %st(0) + fsub %st(2), %st + fsubr %st, %st(3) + fld %st(1) + fsubp %st, %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(5), %st + fld %st(0) + faddp %st, %st(5) + fld %st(4) + faddp %st, %st(4) + fxch %st(3) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt 64(%rsp) + faddp %st, %st(1) + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fmulp %st, %st(1) + fld %st(4) + fsub %st(3), %st + fsubr %st, %st(7) + fsubr %st(5), %st + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(6) + fxch %st(5) + faddp %st, %st(2) + fld %st(3) + fsub %st(3), %st + fldt 48(%rsp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(5), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 80(%rsp) + fld %st(0) + fsub %st(4), %st + fldt 32(%rsp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(2), %st + fsubrp %st, %st(5) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fld %st(3) + fsub %st(3), %st + fldt 64(%rsp) + fsub %st(1), %st + fxch %st(1) + fsubr %st(5), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.9(%rip) + fmulp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 128(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + fldt 32(%rsp) + fstpt (%rsp) + fldt 48(%rsp) + fstpt 16(%rsp) + call atan2l@PLT + jmp ..B1.86 + .cfi_def_cfa_offset 192 +..B1.40: + cmpl $16383, %eax + je ..B1.55 +..B1.41: + fstp %st(2) + fxch %st(1) + fstpt 96(%rsp) +..B1.42: + fldt .L_2il0floatpacket.10(%rip) + lea 16+_Q1(%rip), %rax + fmul %st(3), %st + fld %st(3) + lea _Q1(%rip), %rdx + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fsubp %st, %st(2) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.11(%rip) + fmulp %st, %st(1) + fmul %st(3), %st + fld %st(0) + fxch %st(4) + fmul %st(0), %st + fadd %st, %st(4) + fxch %st(1) + fsubr %st(4), %st + fsubrp %st, %st(1) + fld %st(1) + fadd %st(4), %st + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(4) + faddp %st, %st(3) + fld %st(0) + fmul %st(1), %st + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fldt .L_2il0floatpacket.9(%rip) + fmulp %st, %st(2) + fxch %st(1) + fstpt 128(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + fstpt 16(%rsp) + call atan2l@PLT + jmp ..B1.86 + .cfi_def_cfa_offset 192 +..B1.43: + fstp %st(2) + fstp %st(1) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + lea 64(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_clogl.11: + call __libm_hypot2l_k80@PLT +..___tag_value_clogl.12: +..B1.82: + addq $32, %rsp + .cfi_def_cfa_offset 192 +..B1.44: + lea 48+_CONSTANTS(%rip), %rax + lea 64+_CONSTANTS(%rip), %rdx + fldt (%rax) + fmul %st(1), %st + fstpt 16(%rsp) + fldt (%rdx) + fmulp %st, %st(1) + fstpt (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + fldt 64(%rsp) + lea 96(%rsp), %rdi + fstpt (%rsp) + fldt -16(%rdi) + fstpt 16(%rsp) +..___tag_value_clogl.15: + call __libm_logl_k80@PLT +..___tag_value_clogl.16: +..B1.83: + addq $32, %rsp + .cfi_def_cfa_offset 192 +..B1.45: + fldt .L_2il0floatpacket.9(%rip) + fmulp %st, %st(1) + fldt 64(%rsp) + fmul %st(1), %st + fldt 80(%rsp) + fmulp %st, %st(2) + fldt 16(%rsp) + fld %st(0) + fadd %st(2), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt (%rsp) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 128(%rsp) + fldt 208(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + fldt 224(%rsp) + fstpt 16(%rsp) + call atan2l@PLT + jmp ..B1.86 + .cfi_def_cfa_offset 192 +..B1.46: + fldt 208(%rsp) + movsd .L_2il0floatpacket.8(%rip), %xmm1 + pxor %xmm0, %xmm0 + divsd %xmm0, %xmm1 + movsd %xmm1, (%rsp) + fldl (%rsp) + fstpt 128(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + fldt 224(%rsp) + fstpt 16(%rsp) + call atan2l@PLT + jmp ..B1.86 + .cfi_def_cfa_offset 192 +..B1.47: + je ..B1.72 +..B1.48: + cmpl $32767, %eax + je ..B1.66 +..B1.49: + fldt 208(%rsp) + lea 96+_CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 128(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + fldt 224(%rsp) + fstpt 16(%rsp) + call atan2l@PLT +..B1.86: + addq $32, %rsp + .cfi_def_cfa_offset 192 + fstpt 144(%rsp) +..B1.50: + testb %r13b, %r13b + je ..B1.52 +..B1.51: + fldcw 114(%rsp) +..B1.52: + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.65 +..B1.53: + fldt 128(%rsp) + fldt 144(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.64 +..B1.54: + addq $176, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 192 + .cfi_offset 13, -16 +..B1.55: + cmpl $-2147483648, 4(%rsp) + jne ..B1.41 +..B1.57: + cmpl $0, (%rsp) + jne ..B1.41 +..B1.59: + fstp %st(0) + fstp %st(0) + fstp %st(2) + fldt .L_2il0floatpacket.9(%rip) + fmul %st(2), %st + fmulp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + movzwl 104(%rsp), %eax + testl $32767, %eax + jne ..B1.63 +..B1.60: + cmpl $0, 100(%rsp) + jne ..B1.62 +..B1.61: + cmpl $0, 96(%rsp) + je ..B1.63 +..B1.62: + lea 112+_CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st(0), %st + faddp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) +..B1.63: + fstpt 128(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + fstpt 16(%rsp) + call atan2l@PLT + jmp ..B1.86 + .cfi_def_cfa_offset 192 +..B1.64: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.65: + call __stack_chk_fail@PLT +..B1.66: + cmpl $-2147483648, 212(%rsp) + jne ..B1.68 +..B1.67: + cmpl $0, 208(%rsp) + je ..B1.49 +..B1.68: + fldt 208(%rsp) + cmpl $32767, %edx + fmul %st(0), %st + fstpt 144(%rsp) + fldt 144(%rsp) + je ..B1.70 +..B1.69: + fstpt 128(%rsp) + jmp ..B1.50 +..B1.70: + movq $0x8000000000000000, %rax + cmpq 192(%rsp), %rax + jne ..B1.69 +..B1.71: + fstp %st(0) + fldt 192(%rsp) + fmul %st(0), %st + fstpt 128(%rsp) + jmp ..B1.50 +..B1.72: + cmpl $-2147483648, 196(%rsp) + jne ..B1.74 +..B1.73: + cmpl $0, 192(%rsp) + je ..B1.48 +..B1.74: + fldt 192(%rsp) + cmpl $32767, %eax + fld %st(0) + fmul %st(1), %st + fstpt 144(%rsp) + je ..B1.76 +..B1.75: + fldt 208(%rsp) + fmulp %st, %st(1) + fstpt 128(%rsp) + jmp ..B1.50 +..B1.76: + movq $0x8000000000000000, %rax + cmpq 208(%rsp), %rax + jne ..B1.75 +..B1.77: + fstp %st(0) + fldt 208(%rsp) + fmul %st(0), %st + fstpt 128(%rsp) + jmp ..B1.50 +..B1.88: + cmpl $32767, %edx + je ..B1.72 + jmp ..B1.48 +..B1.89: + fstp %st(0) + fstp %st(0) + jmp ..B1.43 + .align 16,0x90 + .cfi_endproc + .type clogl,@function + .size clogl,.-clogl + .data +# -- End clogl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,16 + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,16 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 37342 + .word 47265 + .word 62214 + .word 46340 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 65535 + .word 31 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53710 + .word 6135 + .word 45426 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 505 + .word 55756 + .word 58609 + .word 48341 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8256 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,128 + .align 2 +_Q1: + .word 3134 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 49331 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/complex_real.S b/external/sgx_libm/intel64/complex_real.S new file mode 100644 index 0000000000..b6eb61712d --- /dev/null +++ b/external/sgx_libm/intel64/complex_real.S @@ -0,0 +1,322 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "complex_real.c" + .text +..TXTST0: +# -- Begin __libm_internal_isinf + .text + .align 16,0x90 + .globl __libm_internal_isinf +__libm_internal_isinf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___libm_internal_isinf.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + jne ..B1.4 +..B1.2: + cmpl $0, -8(%rsp) + jne ..B1.4 +..B1.3: + movl $1, %eax + ret +..B1.4: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_isinf,@function + .size __libm_internal_isinf,.-__libm_internal_isinf + .data +# -- End __libm_internal_isinf + .text +# -- Begin __libm_internal_ispinf + .text + .align 16,0x90 + .globl __libm_internal_ispinf +__libm_internal_ispinf: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value___libm_internal_ispinf.4: +..L5: + + movsd %xmm0, -8(%rsp) + cmpl $2146435072, -4(%rsp) + jne ..B2.4 +..B2.2: + cmpl $0, -8(%rsp) + jne ..B2.4 +..B2.3: + movl $1, %eax + ret +..B2.4: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_ispinf,@function + .size __libm_internal_ispinf,.-__libm_internal_ispinf + .data +# -- End __libm_internal_ispinf + .text +# -- Begin __libm_internal_isninf + .text + .align 16,0x90 + .globl __libm_internal_isninf +__libm_internal_isninf: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___libm_internal_isninf.7: +..L8: + + movsd %xmm0, -8(%rsp) + cmpl $-1048576, -4(%rsp) + jne ..B3.4 +..B3.2: + cmpl $0, -8(%rsp) + jne ..B3.4 +..B3.3: + movl $1, %eax + ret +..B3.4: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_isninf,@function + .size __libm_internal_isninf,.-__libm_internal_isninf + .data +# -- End __libm_internal_isninf + .text +# -- Begin __libm_internal_isnan + .text + .align 16,0x90 + .globl __libm_internal_isnan +__libm_internal_isnan: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value___libm_internal_isnan.10: +..L11: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + movl %edx, %eax + andl $2146435072, %eax + cmpl $2146435072, %eax + jne ..B4.5 +..B4.2: + testl $1048575, %edx + jne ..B4.4 +..B4.3: + cmpl $0, -8(%rsp) + je ..B4.5 +..B4.4: + movl $1, %eax + ret +..B4.5: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_isnan,@function + .size __libm_internal_isnan,.-__libm_internal_isnan + .data +# -- End __libm_internal_isnan + .text +# -- Begin __libm_internal_isposzero + .text + .align 16,0x90 + .globl __libm_internal_isposzero +__libm_internal_isposzero: +# parameter 1: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value___libm_internal_isposzero.13: +..L14: + + movsd %xmm0, -8(%rsp) + cmpl $0, -4(%rsp) + jne ..B5.4 +..B5.2: + cmpl $0, -8(%rsp) + jne ..B5.4 +..B5.3: + movl $1, %eax + ret +..B5.4: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_isposzero,@function + .size __libm_internal_isposzero,.-__libm_internal_isposzero + .data +# -- End __libm_internal_isposzero + .text +# -- Begin __libm_internal_iszero + .text + .align 16,0x90 + .globl __libm_internal_iszero +__libm_internal_iszero: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value___libm_internal_iszero.16: +..L17: + + movsd %xmm0, -8(%rsp) + testl $2147483647, -4(%rsp) + jne ..B6.4 +..B6.2: + cmpl $0, -8(%rsp) + jne ..B6.4 +..B6.3: + movl $1, %eax + ret +..B6.4: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_iszero,@function + .size __libm_internal_iszero,.-__libm_internal_iszero + .data +# -- End __libm_internal_iszero + .text +# -- Begin __libm_internal_isnegzero + .text + .align 16,0x90 + .globl __libm_internal_isnegzero +__libm_internal_isnegzero: +# parameter 1: %xmm0 +..B7.1: + .cfi_startproc +..___tag_value___libm_internal_isnegzero.19: +..L20: + + movsd %xmm0, -8(%rsp) + cmpl $-2147483648, -4(%rsp) + jne ..B7.4 +..B7.2: + cmpl $0, -8(%rsp) + jne ..B7.4 +..B7.3: + movl $1, %eax + ret +..B7.4: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_isnegzero,@function + .size __libm_internal_isnegzero,.-__libm_internal_isnegzero + .data +# -- End __libm_internal_isnegzero + .text +# -- Begin __libm_internal_isnzfinite + .text + .align 16,0x90 + .globl __libm_internal_isnzfinite +__libm_internal_isnzfinite: +# parameter 1: %xmm0 +..B8.1: + .cfi_startproc +..___tag_value___libm_internal_isnzfinite.22: +..L23: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + movl %edx, %eax + andl $2146435072, %eax + cmpl $2146435072, %eax + jae ..B8.4 +..B8.2: + andl $2147483647, %edx + orl -8(%rsp), %edx + je ..B8.4 +..B8.3: + movl $1, %eax + ret +..B8.4: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_isnzfinite,@function + .size __libm_internal_isnzfinite,.-__libm_internal_isnzfinite + .data +# -- End __libm_internal_isnzfinite + .text +# -- Begin __libm_internal_isfinite + .text + .align 16,0x90 + .globl __libm_internal_isfinite +__libm_internal_isfinite: +# parameter 1: %xmm0 +..B9.1: + .cfi_startproc +..___tag_value___libm_internal_isfinite.25: +..L26: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2146435072, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __libm_internal_isfinite,@function + .size __libm_internal_isfinite,.-__libm_internal_isfinite + .data +# -- End __libm_internal_isfinite + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/conj.S b/external/sgx_libm/intel64/conj.S new file mode 100644 index 0000000000..91bc92551e --- /dev/null +++ b/external/sgx_libm/intel64/conj.S @@ -0,0 +1,72 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "conj.c" + .text +..TXTST0: +# -- Begin conj + .text + .align 16,0x90 + .globl conj +conj: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_conj.1: +..L2: + + xorps .L_2il0floatpacket.0(%rip), %xmm1 + ret + .align 16,0x90 + .cfi_endproc + .type conj,@function + .size conj,.-conj + .data +# -- End conj + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/conjf.S b/external/sgx_libm/intel64/conjf.S new file mode 100644 index 0000000000..eb0710b0fc --- /dev/null +++ b/external/sgx_libm/intel64/conjf.S @@ -0,0 +1,78 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "conjf.c" + .text +..TXTST0: +# -- Begin conjf + .text + .align 16,0x90 + .globl conjf +conjf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_conjf.1: +..L2: + + movsd %xmm0, -8(%rsp) + pxor %xmm2, %xmm2 + movss -4(%rsp), %xmm1 + xorps .L_2il0floatpacket.0(%rip), %xmm1 + movss -8(%rsp), %xmm0 + movss %xmm1, %xmm2 + unpcklps %xmm2, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type conjf,@function + .size conjf,.-conjf + .data +# -- End conjf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .long 0x80000000,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/conjl.S b/external/sgx_libm/intel64/conjl.S new file mode 100644 index 0000000000..a5a6ee7cdc --- /dev/null +++ b/external/sgx_libm/intel64/conjl.S @@ -0,0 +1,97 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "conjl.c" + .text +..TXTST0: +# -- Begin conjl + .text + .align 16,0x90 + .globl conjl +conjl: +# parameter 1: 16 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_conjl.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + fldt 16(%rsp) + fldt 32(%rsp) + movq %fs:40, %rax + fchs + xorq %rsp, %rax + movq %rax, (%rsp) + fxch %st(1) + movq (%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B1.4 +..B1.2: + movq (%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.4 +..B1.3: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B1.4: + fstp %st(0) + fstp %st(0) + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type conjl,@function + .size conjl,.-conjl + .data +# -- End conjl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/copysign_gen.S b/external/sgx_libm/intel64/copysign_gen.S new file mode 100644 index 0000000000..c3a9c73236 --- /dev/null +++ b/external/sgx_libm/intel64/copysign_gen.S @@ -0,0 +1,89 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "copysign_gen.c" + .text +..TXTST0: +# -- Begin copysign + .text + .align 16,0x90 + .globl copysign +copysign: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_copysign.1: +..L2: + + lea _ones(%rip), %rax + movsd %xmm1, -24(%rsp) + movl -20(%rsp), %edx + andl $-2147483648, %edx + mulsd (%rax), %xmm0 + movsd (%rax), %xmm2 + mulsd %xmm2, %xmm1 + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %ecx + andl $2147483647, %ecx + orl %edx, %ecx + movl %ecx, -4(%rsp) + movsd %xmm1, -16(%rsp) + movsd -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type copysign,@function + .size copysign,.-copysign + .data +# -- End copysign + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/copysignf_gen.S b/external/sgx_libm/intel64/copysignf_gen.S new file mode 100644 index 0000000000..7626c5bb8e --- /dev/null +++ b/external/sgx_libm/intel64/copysignf_gen.S @@ -0,0 +1,73 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "copysignf_gen.c" + .text +..TXTST0: +# -- Begin copysignf + .text + .align 16,0x90 + .globl copysignf +copysignf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_copysignf.1: +..L2: + + movd %xmm1, %eax + movd %xmm0, %edx + movl %eax, -8(%rsp) + andl $2147483647, %edx + andl $-2147483648, %eax + orl %eax, %edx + movl %edx, -4(%rsp) + movss -4(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type copysignf,@function + .size copysignf,.-copysignf + .data +# -- End copysignf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/copysignl.S b/external/sgx_libm/intel64/copysignl.S new file mode 100644 index 0000000000..74375e80b6 --- /dev/null +++ b/external/sgx_libm/intel64/copysignl.S @@ -0,0 +1,119 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "copysignl.c" + .text +..TXTST0: +# -- Begin copysignl + .text + .align 16,0x90 + .globl copysignl +copysignl: +# parameter 1: 64 + %rsp +# parameter 2: 80 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_copysignl.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + xorb %sil, %sil + fldt 64(%rsp) + fstpt (%rsp) +..B1.2: + fnstcw 50(%rsp) +..B1.3: + movzwl 50(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 48(%rsp) +..B1.5: + fldcw 48(%rsp) +..B1.6: + movb $1, %sil +..B1.7: + fldt 80(%rsp) + lea _ones(%rip), %rax + fldt (%rsp) + movb 89(%rsp), %dl + andb $-128, %dl + fldl (%rax) + fmul %st, %st(1) + fxch %st(1) + fstpt 32(%rsp) + fmulp %st, %st(1) + movb 41(%rsp), %cl + andb $127, %cl + orb %dl, %cl + fstpt 16(%rsp) + testb %sil, %sil + movb %cl, 41(%rsp) + je ..B1.9 +..B1.8: + fldcw 50(%rsp) +..B1.9: + fldt 32(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type copysignl,@function + .size copysignl,.-copysignl + .data +# -- End copysignl + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cos_gen.S b/external/sgx_libm/intel64/cos_gen.S new file mode 100644 index 0000000000..80d3955cf1 --- /dev/null +++ b/external/sgx_libm/intel64/cos_gen.S @@ -0,0 +1,1132 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cos_gen.c" + .text +..TXTST0: +# -- Begin cos + .text + .align 16,0x90 + .globl cos +cos: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cos.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) +..B1.2: + pextrw $3, %xmm0, %eax + andw $32767, %ax + subw $12336, %ax + cmpw $4293, %ax + ja .L_2TAG_PACKET_0.0.1 + movsd PI32INV(%rip), %xmm1 + mulsd %xmm0, %xmm1 + movapd ONEHALF(%rip), %xmm5 + movsd SIGN_MASK(%rip), %xmm4 + andpd %xmm0, %xmm4 + orps %xmm4, %xmm5 + addpd %xmm5, %xmm1 + cvttsd2si %xmm1, %edx + cvtsi2sd %edx, %xmm1 + movapd P_2(%rip), %xmm2 + movsd P_1(%rip), %xmm3 + mulsd %xmm1, %xmm3 + unpcklpd %xmm1, %xmm1 + addq $1865232, %rdx + movsd %xmm0, %xmm4 + andq $63, %rdx + movapd SC_4(%rip), %xmm5 + lea Ctable(%rip), %rax + shlq $5, %rdx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subsd %xmm3, %xmm0 + mulsd P_3(%rip), %xmm1 + subsd %xmm3, %xmm4 + movsd 8(%rax), %xmm7 + unpcklpd %xmm0, %xmm0 + movsd %xmm4, %xmm3 + subsd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + movapd SC_2(%rip), %xmm6 + mulsd %xmm4, %xmm7 + subsd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subsd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subsd %xmm3, %xmm1 + movsd 24(%rax), %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm7 + mulsd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulsd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulsd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movsd %xmm3, %xmm0 + addsd 8(%rax), %xmm3 + mulpd %xmm7, %xmm1 + movsd %xmm4, %xmm7 + addsd %xmm3, %xmm4 + addpd %xmm5, %xmm6 + movsd 8(%rax), %xmm5 + subsd %xmm3, %xmm5 + subsd %xmm4, %xmm3 + addsd 16(%rax), %xmm1 + mulpd %xmm2, %xmm6 + addsd %xmm5, %xmm0 + addsd %xmm7, %xmm3 + addsd %xmm1, %xmm0 + addsd %xmm3, %xmm0 + addsd %xmm6, %xmm0 + unpckhpd %xmm6, %xmm6 + addsd %xmm6, %xmm0 + addsd %xmm4, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_0.0.1: + jg .L_2TAG_PACKET_1.0.1 + pextrw $3, %xmm0, %eax + andw $32767, %ax + pinsrw $3, %eax, %xmm0 + movsd ONE(%rip), %xmm1 + subsd %xmm0, %xmm1 + movsd %xmm1, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_1.0.1: + pextrw $3, %xmm0, %eax + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_2.0.1 + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + subl $16224, %ecx + shrl $7, %ecx + andl $65532, %ecx + lea PI_INV_TABLE(%rip), %r11 + addq %r11, %rcx + movd %xmm0, %rax + movl 20(%rcx), %r10d + movl 24(%rcx), %r8d + movl %eax, %edx + shrq $21, %rax + orl $-2147483648, %eax + shrl $11, %eax + movl %r10d, %r9d + imulq %rdx, %r10 + imulq %rax, %r9 + imulq %rax, %r8 + movl 16(%rcx), %esi + movl 12(%rcx), %edi + movl %r10d, %r11d + shrq $32, %r10 + addq %r10, %r9 + addq %r8, %r11 + movl %r11d, %r8d + shrq $32, %r11 + addq %r11, %r9 + movl %esi, %r10d + imulq %rdx, %rsi + imulq %rax, %r10 + movl %edi, %r11d + imulq %rdx, %rdi + movl %esi, %ebx + shrq $32, %rsi + addq %rbx, %r9 + movl %r9d, %ebx + shrq $32, %r9 + addq %rsi, %r10 + addq %r9, %r10 + shlq $32, %rbx + orq %rbx, %r8 + imulq %rax, %r11 + movl 8(%rcx), %r9d + movl 4(%rcx), %esi + movl %edi, %ebx + shrq $32, %rdi + addq %rbx, %r10 + movl %r10d, %ebx + shrq $32, %r10 + addq %rdi, %r11 + addq %r10, %r11 + movq %r9, %rdi + imulq %rdx, %r9 + imulq %rax, %rdi + movl %r9d, %r10d + shrq $32, %r9 + addq %r10, %r11 + movl %r11d, %r10d + shrq $32, %r11 + addq %r9, %rdi + addq %r11, %rdi + movq %rsi, %r9 + imulq %rdx, %rsi + imulq %rax, %r9 + shlq $32, %r10 + orq %rbx, %r10 + movl (%rcx), %eax + movl %esi, %r11d + shrq $32, %rsi + addq %r11, %rdi + movl %edi, %r11d + shrq $32, %rdi + addq %rsi, %r9 + addq %rdi, %r9 + imulq %rax, %rdx + pextrw $3, %xmm0, %ebx + lea PI_INV_TABLE(%rip), %rdi + subq %rdi, %rcx + addl %ecx, %ecx + addl %ecx, %ecx + addl %ecx, %ecx + addl $19, %ecx + movl $32768, %esi + andl %ebx, %esi + shrl $4, %ebx + andl $2047, %ebx + subl $1023, %ebx + subl %ebx, %ecx + addq %rdx, %r9 + movl %ecx, %edx + addl $32, %edx + cmpl $1, %ecx + jl .L_2TAG_PACKET_3.0.1 + negl %ecx + addl $29, %ecx + shll %cl, %r9d + movl %r9d, %edi + andl $536870911, %r9d + testl $268435456, %r9d + jne .L_2TAG_PACKET_4.0.1 + shrl %cl, %r9d + movl $0, %ebx + shlq $32, %r9 + orq %r11, %r9 +.L_2TAG_PACKET_5.0.1: +.L_2TAG_PACKET_6.0.1: + cmpq $0, %r9 + je .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_8.0.1: + bsr %r9, %r11 + movl $29, %ecx + subl %r11d, %ecx + jle .L_2TAG_PACKET_9.0.1 + shlq %cl, %r9 + movq %r10, %rax + shlq %cl, %r10 + addl %ecx, %edx + negl %ecx + addl $64, %ecx + shrq %cl, %rax + shrq %cl, %r8 + orq %rax, %r9 + orq %r8, %r10 +.L_2TAG_PACKET_10.0.1: + cvtsi2sdq %r9, %xmm0 + shrq $1, %r10 + cvtsi2sdq %r10, %xmm3 + xorpd %xmm4, %xmm4 + shll $4, %edx + negl %edx + addl $16368, %edx + orl %esi, %edx + xorl %ebx, %edx + pinsrw $3, %edx, %xmm4 + movsd PI_4(%rip), %xmm2 + movsd 8+PI_4(%rip), %xmm6 + xorpd %xmm5, %xmm5 + subl $1008, %edx + pinsrw $3, %edx, %xmm5 + mulsd %xmm4, %xmm0 + shll $16, %esi + sarl $31, %esi + mulsd %xmm5, %xmm3 + movsd %xmm0, %xmm1 + mulsd %xmm2, %xmm0 + shrl $29, %edi + addsd %xmm3, %xmm1 + mulsd %xmm2, %xmm3 + addl %esi, %edi + xorl %esi, %edi + mulsd %xmm1, %xmm6 + movl %edi, %eax + addsd %xmm3, %xmm6 + movsd %xmm0, %xmm2 + addsd %xmm6, %xmm0 + subsd %xmm0, %xmm2 + addsd %xmm2, %xmm6 +.L_2TAG_PACKET_11.0.1: + movsd PI32INV(%rip), %xmm1 + mulsd %xmm0, %xmm1 + movq ONEHALF(%rip), %xmm5 + movq SIGN_MASK(%rip), %xmm4 + andpd %xmm0, %xmm4 + orps %xmm4, %xmm5 + addpd %xmm5, %xmm1 + cvttsd2si %xmm1, %rdx + cvtsi2sdq %rdx, %xmm1 + movsd P_1(%rip), %xmm3 + movapd P_2(%rip), %xmm2 + mulsd %xmm1, %xmm3 + unpcklpd %xmm1, %xmm1 + shll $3, %eax + addl $1865232, %edx + movsd %xmm0, %xmm4 + addl %eax, %edx + andl $63, %edx + movapd SC_4(%rip), %xmm5 + lea Ctable(%rip), %rax + shll $5, %edx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subsd %xmm3, %xmm0 + mulsd P_3(%rip), %xmm1 + subsd %xmm3, %xmm4 + movsd 8(%rax), %xmm7 + unpcklpd %xmm0, %xmm0 + movsd %xmm4, %xmm3 + subsd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + mulsd %xmm4, %xmm7 + subsd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subsd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subsd %xmm3, %xmm1 + movsd 24(%rax), %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm7 + subsd %xmm6, %xmm1 + movapd SC_2(%rip), %xmm6 + mulsd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulsd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulsd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movsd %xmm3, %xmm0 + addsd 8(%rax), %xmm3 + mulpd %xmm7, %xmm1 + movsd %xmm4, %xmm7 + addsd %xmm3, %xmm4 + addpd %xmm5, %xmm6 + movsd 8(%rax), %xmm5 + subsd %xmm3, %xmm5 + subsd %xmm4, %xmm3 + addsd 16(%rax), %xmm1 + mulpd %xmm2, %xmm6 + addsd %xmm0, %xmm5 + addsd %xmm7, %xmm3 + addsd %xmm5, %xmm1 + addsd %xmm3, %xmm1 + addsd %xmm6, %xmm1 + unpckhpd %xmm6, %xmm6 + movsd %xmm4, %xmm0 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_7.0.1: + addl $64, %edx + movq %r10, %r9 + movq %r8, %r10 + movq $0, %r8 + cmpq $0, %r9 + jne .L_2TAG_PACKET_8.0.1 + addl $64, %edx + movq %r10, %r9 + movq %r8, %r10 + cmpq $0, %r9 + jne .L_2TAG_PACKET_8.0.1 + xorpd %xmm0, %xmm0 + xorpd %xmm6, %xmm6 + jmp .L_2TAG_PACKET_11.0.1 +.L_2TAG_PACKET_9.0.1: + je .L_2TAG_PACKET_10.0.1 + negl %ecx + shrq %cl, %r10 + movq %r9, %rax + shrq %cl, %r9 + subl %ecx, %edx + negl %ecx + addl $64, %ecx + shlq %cl, %rax + orq %rax, %r10 + jmp .L_2TAG_PACKET_10.0.1 +.L_2TAG_PACKET_3.0.1: + negl %ecx + shlq $32, %r9 + orq %r11, %r9 + shlq %cl, %r9 + movq %r9, %rdi + testl $-2147483648, %r9d + jne .L_2TAG_PACKET_12.0.1 + shrl %cl, %r9d + movl $0, %ebx + shrq $3, %rdi + jmp .L_2TAG_PACKET_6.0.1 +.L_2TAG_PACKET_4.0.1: + shrl %cl, %r9d + movl $536870912, %ebx + shrl %cl, %ebx + shlq $32, %r9 + orq %r11, %r9 + shlq $32, %rbx + addl $536870912, %edi + movq $0, %rcx + movq $0, %r11 + subq %r8, %rcx + sbbq %r10, %r11 + sbbq %r9, %rbx + movq %rcx, %r8 + movq %r11, %r10 + movq %rbx, %r9 + movl $32768, %ebx + jmp .L_2TAG_PACKET_5.0.1 +.L_2TAG_PACKET_12.0.1: + shrl %cl, %r9d + movq $0x100000000, %rbx + shrq %cl, %rbx + movq $0, %rcx + movq $0, %r11 + subq %r8, %rcx + sbbq %r10, %r11 + sbbq %r9, %rbx + movq %rcx, %r8 + movq %r11, %r10 + movq %rbx, %r9 + movl $32768, %ebx + shrq $3, %rdi + addl $536870912, %edi + jmp .L_2TAG_PACKET_6.0.1 +.L_2TAG_PACKET_2.0.1: + movsd 8(%rsp), %xmm0 + mulsd NEG_ZERO(%rip), %xmm0 + movsd %xmm0, (%rsp) +.L_2TAG_PACKET_13.0.1: +..B1.4: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cos,@function + .size cos,.-cos + .data +# -- End cos + .section .rodata, "a" + .align 16 + .align 16 +ONEHALF: + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .type ONEHALF,@object + .size ONEHALF,16 + .align 16 +P_2: + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .type P_2,@object + .size P_2,16 + .align 16 +SC_4: + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .type SC_4,@object + .size SC_4,16 + .align 16 +Ctable: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 1072693248 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1071644672 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 1071644672 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1070596096 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 1070596096 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1069547520 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 3217031168 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 3218079744 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 3218079744 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 3219128320 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 3220176896 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3219128320 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 3219128320 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3218079744 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 3218079744 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 1069547520 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 1070596096 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 1070596096 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 1071644672 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 1072693248 + .type Ctable,@object + .size Ctable,2048 + .align 16 +SC_2: + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .type SC_2,@object + .size SC_2,16 + .align 16 +SC_3: + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .type SC_3,@object + .size SC_3,16 + .align 16 +SC_1: + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .type SC_1,@object + .size SC_1,16 + .align 16 +PI_INV_TABLE: + .long 0 + .long 0 + .long 2734261102 + .long 1313084713 + .long 4230436817 + .long 4113882560 + .long 3680671129 + .long 1011060801 + .long 4266746795 + .long 3736847713 + .long 3072618042 + .long 1112396512 + .long 105459434 + .long 164729372 + .long 4263373596 + .long 2972297022 + .long 3900847605 + .long 784024708 + .long 3919343654 + .long 3026157121 + .long 965858873 + .long 2203269620 + .long 2625920907 + .long 3187222587 + .long 536385535 + .long 3724908559 + .long 4012839307 + .long 1510632735 + .long 1832287951 + .long 667617719 + .long 1330003814 + .long 2657085997 + .long 1965537991 + .long 3957715323 + .long 1023883767 + .long 2320667370 + .long 1811636145 + .long 529358088 + .long 1443049542 + .long 4235946923 + .long 4040145953 + .type PI_INV_TABLE,@object + .size PI_INV_TABLE,164 + .space 12, 0x00 # pad + .align 16 +PI_4: + .long 1073741824 + .long 1072243195 + .long 407279769 + .long 1046758445 + .type PI_4,@object + .size PI_4,16 + .align 8 +PI32INV: + .long 1841940611 + .long 1076125488 + .type PI32INV,@object + .size PI32INV,8 + .align 8 +SIGN_MASK: + .long 0 + .long 2147483648 + .type SIGN_MASK,@object + .size SIGN_MASK,8 + .align 8 +P_1: + .long 1413480448 + .long 1069097467 + .type P_1,@object + .size P_1,8 + .align 8 +P_3: + .long 771977331 + .long 996350346 + .type P_3,@object + .size P_3,8 + .align 8 +ONE: + .long 0 + .long 1072693248 + .type ONE,@object + .size ONE,8 + .align 8 +NEG_ZERO: + .long 0 + .long 2147483648 + .type NEG_ZERO,@object + .size NEG_ZERO,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cosdl.S b/external/sgx_libm/intel64/cosdl.S new file mode 100644 index 0000000000..2c71db4d52 --- /dev/null +++ b/external/sgx_libm/intel64/cosdl.S @@ -0,0 +1,692 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosdl.c" + .text +..TXTST0: +# -- Begin cosdl + .text + .align 16,0x90 + .globl cosdl +cosdl: +# parameter 1: 144 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cosdl.1: +..L2: + + subq $136, %rsp + .cfi_def_cfa_offset 144 + xorb %r8b, %r8b +..B1.2: + fnstcw 122(%rsp) +..B1.3: + movzwl 122(%rsp), %edx + movl %edx, %eax + andl $3840, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + andl $-3841, %edx + orl $-64768, %edx + movw %dx, 120(%rsp) +..B1.5: + fldcw 120(%rsp) +..B1.6: + movb $1, %r8b +..B1.7: + fldt 144(%rsp) + lea ones(%rip), %rdi + movzwl 152(%rsp), %eax + movl %eax, %esi + shrl $15, %eax + andl $32767, %esi + cmpl $32767, %esi + fmuls (%rdi,%rax,4) + fstpt 144(%rsp) + fldt 144(%rsp) + je ..B1.26 +..B1.8: + fldt .L_2il0floatpacket.0(%rip) + fucomip %st(1), %st + jp ..B1.9 + je ..B1.25 +..B1.9: + cmpl $10783, %esi + jge ..B1.11 +..B1.10: + fldt .L_2il0floatpacket.1(%rip) + fsubp %st, %st(1) + fstpt 104(%rsp) + jmp ..B1.21 +..B1.11: + cmpl $16446, %esi + jge ..B1.16 +..B1.12: + fldt .L_2il0floatpacket.2(%rip) + lea _Rcp90(%rip), %rax + fldt .L_2il0floatpacket.3(%rip) + fldt .L_2il0floatpacket.0(%rip) + fldt (%rax) + fmulp %st, %st(4) + fxch %st(2) + fadd %st, %st(3) + fxch %st(3) + fstpt 80(%rsp) + fldt 80(%rsp) + movl 80(%rsp), %ecx + fsubp %st, %st(3) + fmulp %st, %st(2) + incl %ecx + fldt 144(%rsp) + movl %ecx, %edx + andl $2, %edx + fsubp %st, %st(2) + shrl $1, %edx + movss (%rdi,%rdx,4), %xmm0 + fucomip %st(1), %st + jp ..B1.13 + je ..B1.24 +..B1.13: + fldt .L_2il0floatpacket.4(%rip) + lea _TWO_53H(%rip), %rax + fmul %st(1), %st + fld %st(1) + movss %xmm0, (%rsp) + testb $1, %cl + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(2) + fsub %st(2), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(3) + fld %st(1) + fld %st(4) + fldl (%rax) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fxch %st(1) + fmul %st, %st(2) + fld %st(5) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + fstpt 64(%rsp) + fld %st(4) + fmul %st(5), %st + fld %st(0) + fmul %st(1), %st + flds (%rsp) + fstps 96(%rsp) + je ..B1.15 +..B1.14: + fstp %st(6) + fstp %st(2) + fld %st(2) + lea 112+_cosdl_poly_coeff(%rip), %rax + fmul %st(3), %st + lea 80+_cosdl_poly_coeff(%rip), %rdx + fmul %st, %st(1) + fld %st(2) + fmul %st(5), %st + fxch %st(4) + fstpt (%rsp) + fldt (%rsp) + fld %st(3) + lea 96+_cosdl_poly_coeff(%rip), %rsi + lea 48+_cosdl_poly_coeff(%rip), %rcx + lea 64+_cosdl_poly_coeff(%rip), %rdi + lea 32+_cosdl_poly_coeff(%rip), %r9 + lea 24+_cosdl_mp_poly_coeff(%rip), %r10 + lea 8+_cosdl_mp_poly_coeff(%rip), %r11 + fmul %st(7), %st + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(5) + fld %st(1) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(3) + fldt (%rax) + fmul %st(5), %st + fldt (%rdx) + lea 16+_cosdl_mp_poly_coeff(%rip), %rax + lea _cosdl_mp_poly_coeff(%rip), %rdx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + fmul %st(6), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r9) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fldl (%r10) + fmulp %st, %st(5) + faddp %st, %st(4) + fldl (%r11) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl (%rax) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldl (%rdx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt (%rsp) + fmulp %st, %st(2) + fld %st(1) + fldt 16(%rsp) + fmulp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + flds 96(%rsp) + fld %st(0) + fldt .L_2il0floatpacket.1(%rip) + fadd %st(4), %st + fmul %st, %st(1) + fldt .L_2il0floatpacket.1(%rip) + fsubp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 104(%rsp) + jmp ..B1.21 +..B1.15: + fld %st(6) + lea 128+_sindl_poly_coeff(%rip), %rax + fmul %st(2), %st + lea 96+_sindl_poly_coeff(%rip), %rdx + fstpt 32(%rsp) + fld %st(4) + fmul %st(4), %st + lea 64+_sindl_poly_coeff(%rip), %rcx + fmul %st, %st(3) + lea 32+_sindl_poly_coeff(%rip), %rsi + fxch %st(6) + fmul %st(7), %st + fxch %st(2) + fstpt 16(%rsp) + lea 112+_sindl_poly_coeff(%rip), %rdi + fxch %st(3) + fstpt (%rsp) + lea 80+_sindl_poly_coeff(%rip), %r9 + fldt 64(%rsp) + lea 48+_sindl_poly_coeff(%rip), %r10 + lea 24+_sindl_mp_poly_coeff(%rip), %r11 + fmul %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fld %st(4) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fsubrp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + lea 8+_sindl_mp_poly_coeff(%rip), %rax + lea 16+_sindl_mp_poly_coeff(%rip), %rdx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea _sindl_mp_poly_coeff(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fldt 16(%rsp) + fmulp %st, %st(1) + fldt (%rdi) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 32(%rsp) + fmul %st, %st(1) + fldl (%r11) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl (%rax) + fmulp %st, %st(4) + faddp %st, %st(3) + fldl (%rdx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldl (%rcx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt (%rsp) + fmulp %st, %st(2) + fld %st(1) + fldt 48(%rsp) + fmulp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + flds 96(%rsp) + fld %st(0) + fmulp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 104(%rsp) + jmp ..B1.21 +..B1.16: + fstp %st(0) + lea -16446(%rsi), %ecx + cmpl $14, %ecx + jle ..B1.18 +..B1.17: + addl $-16449, %esi + movl $715827883, %eax + imull %esi + movl %esi, %ecx + sarl $1, %edx + sarl $31, %ecx + subl %ecx, %edx + lea (,%rdx,8), %r9d + lea (%r9,%rdx,4), %r10d + subl %r10d, %esi + lea 3(%rsi), %ecx +..B1.18: + movl 148(%rsp), %r11d + movl %r11d, %esi + shll $8, %esi + movl $381774871, %eax + movl %esi, %r9d + andl $-16777216, %r11d + shrl $3, %r9d + movl %r11d, %r10d + mull %r9d + shrl $19, %r11d + shrl $2, %edx + imull $-360, %edx, %eax + addl %eax, %esi + movl $381774871, %eax + mull %r11d + shrl $16, %r10d + movl $381774871, %eax + shrl $2, %edx + imull $-360, %edx, %r11d + addl %r11d, %r10d + movl 144(%rsp), %r9d + addl %r10d, %esi + movl %r9d, %r10d + shrl $3, %r10d + mull %r10d + shrl $2, %edx + imull $-360, %edx, %eax + addl %eax, %r9d + movl $-1240768329, %eax + addl %r9d, %esi + shll %cl, %esi + imull %esi + movl %esi, %ecx + addl %esi, %edx + sarl $8, %edx + sarl $31, %ecx + subl %ecx, %edx + movl $1, %ecx + imull $-360, %edx, %eax + lea (%rsi,%rax), %edx + cmpl $179, %edx + lea -180(%rsi,%rax), %eax + movl $3, %esi + cmovg %eax, %edx + cmovg %esi, %ecx + cmpl $89, %edx + jle ..B1.20 +..B1.19: + incl %ecx + addl $-90, %edx +..B1.20: + movl %ecx, %eax + andl $2, %ecx + andl $1, %eax + addl %eax, %eax + movq __libm_sindl_cosdl_table@GOTPCREL(%rip), %rsi + shrl $1, %ecx + lea (%rax,%rdx,4), %edx + movslq %edx, %rdx + fldl (%rsi,%rdx,8) + faddl 8(%rsi,%rdx,8) + fmuls (%rdi,%rcx,4) + fstpt 104(%rsp) +..B1.21: + testb %r8b, %r8b + je ..B1.23 +..B1.22: + fldcw 122(%rsp) +..B1.23: + fldt 104(%rsp) + addq $136, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 +..B1.24: + fstp %st(0) + fldt .L_2il0floatpacket.0(%rip) + testb $1, %cl + movss %xmm0, (%rsp) + flds (%rsp) + fcmove %st(1), %st + fstp %st(1) + fstpt 104(%rsp) + jmp ..B1.21 +..B1.25: + fstp %st(0) + fldt .L_2il0floatpacket.1(%rip) + fstpt 104(%rsp) + jmp ..B1.21 +..B1.26: + fldt .L_2il0floatpacket.0(%rip) + fmulp %st, %st(1) + fstpt 104(%rsp) + jmp ..B1.21 + .align 16,0x90 + .cfi_endproc + .type cosdl,@function + .size cosdl,.-cosdl + .data +# -- End cosdl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3e,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb4,0x05,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +_cosdl_poly_coeff: + .word 52350 + .word 41213 + .word 3800 + .word 40885 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 28613 + .word 7908 + .word 35668 + .word 34008 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 19927 + .word 58728 + .word 49885 + .word 45261 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 32884 + .word 22035 + .word 23267 + .word 64541 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 36401 + .word 51897 + .word 8309 + .word 57265 + .word 49070 + .word 0 + .word 0 + .word 0 + .word 34286 + .word 2728 + .word 41564 + .word 34642 + .word 16284 + .word 0 + .word 0 + .word 0 + .word 63248 + .word 18030 + .word 35596 + .word 60796 + .word 49032 + .word 0 + .word 0 + .word 0 + .word 52149 + .word 21294 + .word 63985 + .word 40123 + .word 16245 + .word 0 + .word 0 + .word 0 + .type _cosdl_poly_coeff,@object + .size _cosdl_poly_coeff,128 + .align 16 +_cosdl_mp_poly_coeff: + .long 3675529145 + .long 3206805153 + .long 2134983071 + .long 3151100167 + .long 1787026573 + .long 1043372817 + .long 205083639 + .long 988746860 + .type _cosdl_mp_poly_coeff,@object + .size _cosdl_mp_poly_coeff,32 + .align 16 +_sindl_poly_coeff: + .word 51374 + .word 38121 + .word 13586 + .word 36602 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 50116 + .word 41339 + .word 4204 + .word 60892 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 33704 + .word 2155 + .word 42839 + .word 60780 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 21250 + .word 19076 + .word 27901 + .word 57780 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 9076 + .word 49244 + .word 613 + .word 64083 + .word 16311 + .word 0 + .word 0 + .word 0 + .word 40572 + .word 30418 + .word 36251 + .word 46520 + .word 49061 + .word 0 + .word 0 + .word 0 + .word 3227 + .word 25505 + .word 5540 + .word 47626 + .word 16274 + .word 0 + .word 0 + .word 0 + .word 60933 + .word 3300 + .word 57416 + .word 36218 + .word 49023 + .word 0 + .word 0 + .word 0 + .word 45811 + .word 42646 + .word 37125 + .word 42185 + .word 16235 + .word 0 + .word 0 + .word 0 + .type _sindl_poly_coeff,@object + .size _sindl_poly_coeff,144 + .align 16 +_sindl_mp_poly_coeff: + .long 2723323193 + .long 1066524486 + .long 2863989530 + .long 1008058840 + .long 227815288 + .long 3199056770 + .long 3752327299 + .long 3142458725 + .type _sindl_mp_poly_coeff,@object + .size _sindl_mp_poly_coeff,32 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 2 +_Rcp90: + .word 46603 + .word 2912 + .word 24758 + .word 46603 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _Rcp90,@object + .size _Rcp90,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cosf_gen.S b/external/sgx_libm/intel64/cosf_gen.S new file mode 100644 index 0000000000..5e2789015c --- /dev/null +++ b/external/sgx_libm/intel64/cosf_gen.S @@ -0,0 +1,543 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosf_gen.c" + .text +..TXTST0: +# -- Begin cosf + .text + .align 16,0x90 + .globl cosf +cosf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cosf.1: +..L2: + +..B1.2: + subq $32, %rsp + .cfi_def_cfa_offset 40 + stmxcsr 8(%rsp) + cmpl $-24577, 8(%rsp) + jne .L_2TAG_PACKET_0.0.1 +.L_2TAG_PACKET_1.0.1: + pshuflw $68, %xmm0, %xmm1 + movd %xmm0, %ecx + cvtps2pd %xmm1, %xmm1 + movq $0x40445f306e000000, %rax + movd %rax, %xmm2 + movl $2147483647, %r10d + movl $1241513983, %r8d + andl %ecx, %r10d + subl %r10d, %r8d + subl $964689920, %r10d + orl %r10d, %r8d + jl .L_2TAG_PACKET_2.0.1 + movq $0x4338000000000000, %r11 + movd %r11, %xmm4 + mulsd %xmm1, %xmm2 + movq $0xbe5b1bbead603d8b, %rdx + movd %rdx, %xmm3 + movapd %xmm2, %xmm5 + addsd %xmm4, %xmm2 + movd %xmm2, %r9d + subsd %xmm4, %xmm2 + mulsd %xmm3, %xmm1 +.L_2TAG_PACKET_3.0.1: + lea Ctable(%rip), %r10 + movl $384, %eax + movq $0x40c37423899a1558, %rdx + movd %rdx, %xmm4 + subsd %xmm2, %xmm5 + addl %r9d, %r9d + movl %r9d, %r8d + sarb $7, %r9b + andl %r8d, %eax + addb %r9b, %r8b + xorb %r9b, %r8b + addsd %xmm5, %xmm1 + andl $254, %r8d + movsd (%r10,%r8,8), %xmm3 + movq $0x40a9f02f6222c720, %r11 + movd %r11, %xmm0 + movapd %xmm1, %xmm2 + unpcklpd %xmm1, %xmm2 + mulsd %xmm1, %xmm1 + movsd 8(%r10,%r8,8), %xmm5 + movl %eax, %r9d + andl $256, %r9d + shlq $55, %r9 + mulsd %xmm2, %xmm3 + movd %r9, %xmm2 + subsd %xmm1, %xmm0 + addl $128, %eax + andl $256, %eax + shlq $55, %rax + subsd %xmm1, %xmm4 + movd %rax, %xmm1 + xorpd %xmm2, %xmm4 + mulsd %xmm5, %xmm0 + mulsd %xmm4, %xmm3 + xorpd %xmm1, %xmm0 + addsd %xmm3, %xmm0 + movl 8(%rsp), %eax + andl $-24577, %eax + cmpl 8(%rsp), %eax + je .L_2TAG_PACKET_4.0.1 + stmxcsr 16(%rsp) + movl 8(%rsp), %eax + andl $24576, %eax + orl %eax, 16(%rsp) + ldmxcsr 16(%rsp) +.L_2TAG_PACKET_4.0.1: + cvtpd2ps %xmm0, %xmm0 + addq $32, %rsp + ret +.L_2TAG_PACKET_2.0.1: + andl $2147483647, %ecx + cmpl $1040187392, %ecx + ja .L_2TAG_PACKET_5.0.1 + movl $1065353216, %eax + movd %rax, %xmm0 + cmpl $0, %ecx + je .L_2TAG_PACKET_6.0.1 + movl $805306368, %eax + movd %rax, %xmm1 + subss %xmm1, %xmm0 +.L_2TAG_PACKET_6.0.1: + movl 8(%rsp), %eax + andl $-24577, %eax + cmpl 8(%rsp), %eax + jne .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_8.0.1: + addq $32, %rsp + ret +.L_2TAG_PACKET_5.0.1: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_9.0.1 + shrl $23, %r10d + subl $27, %r10d + andl $65528, %r10d + lea Pitable(%rip), %rax + movsd (%rax,%r10,2), %xmm3 + movsd 8(%rax,%r10,2), %xmm5 + movq $0xffffffffff000000, %r9 + movd %r9, %xmm2 + movq $0x4338000000000000, %r11 + movd %r11, %xmm4 + andpd %xmm3, %xmm2 + psllq $40, %xmm3 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + movapd %xmm2, %xmm0 + addsd %xmm3, %xmm2 + movapd %xmm2, %xmm5 + subsd %xmm2, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm0, %xmm3 + movd %xmm2, %r9d + subsd %xmm4, %xmm2 + addsd %xmm3, %xmm1 + jmp .L_2TAG_PACKET_3.0.1 +.L_2TAG_PACKET_9.0.1: + subss %xmm0, %xmm0 + movl 8(%rsp), %eax + andl $-24577, %eax + cmpl 8(%rsp), %eax + jne .L_2TAG_PACKET_7.0.1 + jmp .L_2TAG_PACKET_8.0.1 +.L_2TAG_PACKET_0.0.1: + movl 8(%rsp), %eax + andl $-24577, %eax + movl %eax, 16(%rsp) + ldmxcsr 16(%rsp) + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_7.0.1: + stmxcsr 16(%rsp) + movl 8(%rsp), %eax + andl $24576, %eax + orl %eax, 16(%rsp) + ldmxcsr 16(%rsp) + jmp .L_2TAG_PACKET_8.0.1 + .cfi_def_cfa_offset 8 +..B1.3: + .align 16,0x90 + .cfi_endproc + .type cosf,@function + .size cosf,.-cosf + .data +# -- End cosf + .section .rodata, "a" + .align 16 + .align 16 +Ctable: + .long 0 + .long 0 + .long 3384690142 + .long 1060355388 + .long 918535681 + .long 3195026356 + .long 735532773 + .long 1060354999 + .long 3431923622 + .long 3196074611 + .long 2385983684 + .long 1060353830 + .long 3670374716 + .long 3196605580 + .long 2769466396 + .long 1060351883 + .long 3087185898 + .long 3197121906 + .long 2627920248 + .long 1060349159 + .long 624330694 + .long 3197386271 + .long 418831766 + .long 1060345660 + .long 1991825541 + .long 3197649836 + .long 900924147 + .long 1060341387 + .long 3917367244 + .long 3197912443 + .long 2243801771 + .long 1060336343 + .long 2803392399 + .long 3198165367 + .long 316258674 + .long 1060330532 + .long 2429158325 + .long 3198295476 + .long 1563320407 + .long 1060323956 + .long 1382541649 + .long 3198424870 + .long 1522351063 + .long 1060316620 + .long 4207787592 + .long 3198553470 + .long 1992674941 + .long 1060308528 + .long 321119318 + .long 3198681201 + .long 2434209605 + .long 1060299685 + .long 2865853451 + .long 3198807983 + .long 4249822861 + .long 1060290096 + .long 1666812989 + .long 3198933742 + .long 2181617495 + .long 1060279768 + .long 2082609563 + .long 3199058401 + .long 1475857720 + .long 1060268706 + .long 3726787968 + .long 3199181885 + .long 687004205 + .long 1060256917 + .long 2478530408 + .long 3199254748 + .long 250409509 + .long 1060244408 + .long 3681356269 + .long 3199315204 + .long 2463945945 + .long 1060231186 + .long 1535093810 + .long 3199374963 + .long 2878576948 + .long 1060217260 + .long 350661592 + .long 3199433988 + .long 3162654741 + .long 1060202638 + .long 2042383238 + .long 3199492243 + .long 2490283769 + .long 1060187329 + .long 1925003623 + .long 3199549694 + .long 1813501338 + .long 1060171342 + .long 1689375324 + .long 3199606306 + .long 3838419993 + .long 1060154686 + .long 902054988 + .long 3199662045 + .long 115411415 + .long 1060137373 + .long 1388494065 + .long 3199716877 + .long 1077921708 + .long 1060119411 + .long 3024934267 + .long 3199770769 + .long 3311502568 + .long 1060091288 + .long 3823857331 + .long 3199823689 + .long 1148832537 + .long 1060052839 + .long 17970311 + .long 3199875606 + .long 652328457 + .long 1060013161 + .long 3322544997 + .long 3199926486 + .long 1395127179 + .long 1059972278 + .long 2361617751 + .long 3199976301 + .long 1772140623 + .long 1059930215 + .long 1401987205 + .long 3200025020 + .long 3231311734 + .long 1059886997 + .long 3250975870 + .long 3200072613 + .long 1618129506 + .long 1059842651 + .long 742418353 + .long 3200119053 + .long 4288148241 + .long 1059797202 + .long 2580634211 + .long 3200164310 + .long 4268074870 + .long 1059750679 + .long 3348027550 + .long 3200208358 + .long 1659779181 + .long 1059703110 + .long 755484892 + .long 3200251171 + .long 3567792879 + .long 1059654522 + .long 2993330 + .long 3200273337 + .long 2550341159 + .long 1059604946 + .long 488211833 + .long 3200293469 + .long 2313428161 + .long 1059554411 + .long 3436142021 + .long 3200312945 + .long 453708735 + .long 1059502948 + .long 1407782048 + .long 3200331755 + .long 1264637048 + .long 1059450587 + .long 1575056534 + .long 3200349886 + .long 2771364651 + .long 1059397360 + .long 4275292648 + .long 3200367327 + .long 944109265 + .long 1059343300 + .long 3039475318 + .long 3200384069 + .long 2500108843 + .long 1059288438 + .long 1799297257 + .long 3200400101 + .long 3344537919 + .long 1059232808 + .long 2028347177 + .long 3200415413 + .long 1369913724 + .long 1059176444 + .long 2767093429 + .long 3200429996 + .long 664370609 + .long 1059119379 + .long 646746141 + .long 3200443842 + .long 1372808103 + .long 1059061535 + .long 2796885356 + .long 3200456941 + .long 941816458 + .long 1058944809 + .long 1097233945 + .long 3200469287 + .long 1373383079 + .long 1058826890 + .long 2262842797 + .long 3200480871 + .long 2796081240 + .long 1058707849 + .long 2093526290 + .long 3200491687 + .long 3945677176 + .long 1058587758 + .long 2671784286 + .long 3200501728 + .long 1979618421 + .long 1058466690 + .long 3789723003 + .long 3200510988 + .long 879820317 + .long 1058344717 + .long 2964703016 + .long 3200519462 + .long 2674059679 + .long 1058221912 + .long 4043704933 + .long 3200527144 + .long 2950925715 + .long 1058098350 + .long 36665700 + .long 3200534031 + .long 2811721921 + .long 1057935027 + .long 3193221610 + .long 3200540116 + .long 3297207428 + .long 1057685321 + .long 2063766514 + .long 3200545398 + .long 544295963 + .long 1057434550 + .long 163641427 + .long 3200549873 + .long 3381119115 + .long 1057182863 + .long 3096463640 + .long 3200553537 + .long 3054827835 + .long 1056896220 + .long 1381230637 + .long 3200556390 + .long 3419039295 + .long 1056390099 + .long 522802171 + .long 3200558429 + .long 1693671239 + .long 1055850091 + .long 3836476539 + .long 3200559652 + .long 1466910230 + .long 1054802127 + .long 3861233235 + .long 3200560060 + .long 0 + .long 0 + .type Ctable,@object + .size Ctable,1040 + .align 16 +Pitable: + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1916669064 + .long 1072155675 + .long 660066805 + .long 1024797180 + .long 3829231700 + .long 1062745828 + .long 2884172442 + .long 1017445907 + .long 540874025 + .long 1055617650 + .long 4198409884 + .long 1011844330 + .long 2839315448 + .long 1046639136 + .long 4204424928 + .long 1000582120 + .long 1329339431 + .long 1038229673 + .long 1295478839 + .long 993391741 + .long 658191860 + .long 1024797180 + .long 3691886121 + .long 979325773 + .long 1966800710 + .long 1020436418 + .long 1882642597 + .long 977095991 + .long 2100977488 + .long 1012908661 + .long 1840335565 + .long 967470816 + .long 4198093645 + .long 1000582120 + .long 3307942521 + .long 957055414 + .long 2839123165 + .long 996851343 + .long 1387472776 + .long 952638316 + .long 2788761024 + .long 988712873 + .long 3005712498 + .long 944467026 + .long 3694676832 + .long 979325773 + .long 1326507024 + .long 934847846 + .long 221775557 + .long 970149340 + .long 1133527550 + .long 924162364 + .type Pitable,@object + .size Pitable,240 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cosh_gen.S b/external/sgx_libm/intel64/cosh_gen.S new file mode 100644 index 0000000000..f9fc5f4384 --- /dev/null +++ b/external/sgx_libm/intel64/cosh_gen.S @@ -0,0 +1,409 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosh_gen.c" + .text +..TXTST0: +# -- Begin cosh + .text + .align 16,0x90 + .globl cosh +cosh: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cosh.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + andl $2147483647, %eax + cmpl $1077338037, %eax + jae ..B1.8 +..B1.2: + cmpl $1065646817, %eax + jae ..B1.7 +..B1.3: + movsd .L_2il0floatpacket.12(%rip), %xmm4 + cmpl $1012924416, %eax + jae ..B1.5 +..B1.4: + andps .L_2il0floatpacket.11(%rip), %xmm0 + addsd %xmm4, %xmm0 + movsd %xmm0, -24(%rsp) + ret +..B1.5: + movsd -8(%rsp), %xmm1 + mulsd %xmm1, %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + movsd .L_2il0floatpacket.9(%rip), %xmm0 + mulsd %xmm2, %xmm0 + movsd .L_2il0floatpacket.10(%rip), %xmm3 + mulsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.8(%rip), %xmm0 + mulsd %xmm1, %xmm0 + addsd %xmm3, %xmm0 + addsd %xmm4, %xmm0 +..B1.6: + ret +..B1.7: + movsd -8(%rsp), %xmm1 + lea _TWO_52(%rip), %rax + andps .L_2il0floatpacket.11(%rip), %xmm1 + lea _ptwo_32p1(%rip), %rcx + movsd .L_2il0floatpacket.0(%rip), %xmm2 + lea _ntwo_32p1(%rip), %rsi + mulsd %xmm1, %xmm2 + lea _two_32(%rip), %rdi + movsd .L_2il0floatpacket.1(%rip), %xmm3 + movsd %xmm1, -8(%rsp) + movsd .L_2il0floatpacket.2(%rip), %xmm4 + movsd (%rcx), %xmm6 + movsd (%rsi), %xmm7 + movsd .L_2il0floatpacket.4(%rip), %xmm13 + movsd .L_2il0floatpacket.6(%rip), %xmm14 + movsd .L_2il0floatpacket.3(%rip), %xmm8 + movsd .L_2il0floatpacket.3(%rip), %xmm9 + movq __libm_exp_table_128@GOTPCREL(%rip), %r10 + addsd (%rax), %xmm2 + movsd %xmm2, -24(%rsp) + movsd -24(%rsp), %xmm5 + movl -24(%rsp), %r9d + movl %r9d, %edx + shll $25, %edx + subsd (%rax), %xmm5 + mulsd %xmm5, %xmm3 + mulsd %xmm4, %xmm5 + subsd %xmm3, %xmm1 + movaps %xmm1, %xmm10 + sarl $25, %edx + subsd %xmm5, %xmm10 + movaps %xmm10, %xmm11 + movaps %xmm10, %xmm15 + movslq %edx, %rdx + subsd %xmm10, %xmm1 + addsd %xmm10, %xmm6 + subsd %xmm10, %xmm7 + subsd %xmm5, %xmm1 + movsd %xmm6, -40(%rsp) + subl %edx, %r9d + movsd %xmm7, -32(%rsp) + pxor %xmm5, %xmm5 + movsd -40(%rsp), %xmm2 + addsd %xmm1, %xmm11 + subsd (%rdi), %xmm2 + movaps %xmm11, %xmm12 + addsd %xmm2, %xmm8 + mulsd %xmm11, %xmm12 + subsd %xmm8, %xmm15 + mulsd %xmm12, %xmm13 + mulsd %xmm12, %xmm14 + addsd %xmm1, %xmm15 + addsd .L_2il0floatpacket.5(%rip), %xmm13 + addsd .L_2il0floatpacket.7(%rip), %xmm14 + mulsd %xmm12, %xmm13 + mulsd %xmm12, %xmm14 + mulsd %xmm11, %xmm13 + addsd .L_2il0floatpacket.8(%rip), %xmm14 + addsd %xmm13, %xmm15 + mulsd %xmm12, %xmm14 + movsd -32(%rsp), %xmm0 + addsd %xmm14, %xmm15 + addsd (%rdi), %xmm0 + shlq $4, %rdx + addsd %xmm0, %xmm9 + movsd 1032(%r10,%rdx), %xmm8 + addsd %xmm9, %xmm10 + movaps %xmm8, %xmm4 + addsd %xmm10, %xmm1 + mulsd %xmm15, %xmm4 + addsd %xmm2, %xmm15 + mulsd %xmm8, %xmm2 + mulsd 1024(%r10,%rdx), %xmm15 + xorps .L_2il0floatpacket.13(%rip), %xmm1 + negq %rdx + shrl $7, %r9d + subsd %xmm13, %xmm1 + addsd %xmm15, %xmm4 + addsd %xmm14, %xmm1 + movsd 1032(%r10,%rdx), %xmm15 + movaps %xmm15, %xmm3 + mulsd %xmm1, %xmm3 + addsd %xmm0, %xmm1 + mulsd %xmm15, %xmm0 + mulsd 1024(%r10,%rdx), %xmm1 + shll $23, %r9d + addsd %xmm1, %xmm3 + pxor %xmm1, %xmm1 + lea 1056964608(%r9), %r8d + negl %r9d + addl $1056964608, %r9d + movl %r9d, -12(%rsp) + movl %r8d, -16(%rsp) + cvtss2sd -12(%rsp), %xmm5 + cvtss2sd -16(%rsp), %xmm1 + mulsd %xmm5, %xmm3 + mulsd %xmm0, %xmm5 + mulsd %xmm1, %xmm4 + mulsd %xmm2, %xmm1 + addsd %xmm3, %xmm4 + movaps %xmm5, %xmm0 + addsd %xmm1, %xmm0 + subsd %xmm0, %xmm1 + addsd %xmm1, %xmm5 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm0 + ret +..B1.8: + cmpl $1082536910, %eax + jb ..B1.14 +..B1.9: + jne ..B1.11 +..B1.10: + cmpl $-1883637635, -8(%rsp) + jbe ..B1.14 +..B1.11: + cmpl $2146435072, %eax + jb ..B1.15 +..B1.12: + movsd -8(%rsp), %xmm0 + mulsd %xmm0, %xmm0 +..B1.13: + ret +..B1.14: + movsd -8(%rsp), %xmm12 + lea _TWO_52(%rip), %rax + andps .L_2il0floatpacket.11(%rip), %xmm12 + lea _ptwo_32p1(%rip), %rdx + movsd .L_2il0floatpacket.0(%rip), %xmm0 + lea _two_32(%rip), %rcx + mulsd %xmm12, %xmm0 + lea _TWO_512(%rip), %r9 + movsd .L_2il0floatpacket.1(%rip), %xmm1 + movsd %xmm12, -8(%rsp) + movsd .L_2il0floatpacket.2(%rip), %xmm2 + movsd .L_2il0floatpacket.6(%rip), %xmm11 + movsd .L_2il0floatpacket.4(%rip), %xmm8 + movsd (%rdx), %xmm4 + movsd .L_2il0floatpacket.3(%rip), %xmm5 + movsd .L_2il0floatpacket.8(%rip), %xmm10 + movq __libm_exp_table_128@GOTPCREL(%rip), %r8 + movl $0, -16(%rsp) + addsd (%rax), %xmm0 + movsd %xmm0, -24(%rsp) + movsd -24(%rsp), %xmm3 + movl -24(%rsp), %esi + movl %esi, %edi + shll $25, %edi + subsd (%rax), %xmm3 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm3 + subsd %xmm1, %xmm12 + movaps %xmm12, %xmm6 + sarl $25, %edi + subsd %xmm3, %xmm6 + movaps %xmm6, %xmm7 + subl %edi, %esi + movslq %edi, %rdi + subsd %xmm6, %xmm12 + addsd %xmm6, %xmm4 + subsd %xmm3, %xmm12 + movsd %xmm4, -24(%rsp) + addsd %xmm12, %xmm7 + movaps %xmm7, %xmm9 + mulsd %xmm7, %xmm9 + mulsd %xmm9, %xmm11 + mulsd %xmm9, %xmm8 + mulsd %xmm9, %xmm10 + addsd .L_2il0floatpacket.7(%rip), %xmm11 + addsd .L_2il0floatpacket.5(%rip), %xmm8 + mulsd %xmm9, %xmm11 + mulsd %xmm7, %xmm8 + movsd -24(%rsp), %xmm0 + addsd %xmm8, %xmm11 + subsd (%rcx), %xmm0 + mulsd %xmm9, %xmm11 + addsd %xmm0, %xmm5 + addsd %xmm10, %xmm11 + subsd %xmm5, %xmm6 + shlq $4, %rdi + addsd %xmm6, %xmm12 + movsd 1032(%r8,%rdi), %xmm13 + addsd %xmm11, %xmm12 + movaps %xmm13, %xmm14 + mulsd %xmm12, %xmm14 + addsd %xmm0, %xmm12 + mulsd %xmm13, %xmm0 + mulsd 1024(%r8,%rdi), %xmm12 + shrl $7, %esi + addsd %xmm12, %xmm14 + shll $20, %esi + addsd %xmm14, %xmm0 + addl $534773760, %esi + movl %esi, -12(%rsp) + mulsd -16(%rsp), %xmm0 + mulsd (%r9), %xmm0 + ret +..B1.15: + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type cosh,@function + .size cosh,.-cosh + .data +# -- End cosh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.11: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,16 + .align 16 +.L_2il0floatpacket.13: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x6a3d464e,0x3f56c171 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x5554a6cf,0x3fa55555 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 4 +_TWO_52: + .long 0 + .long 1127219200 + .type _TWO_52,@object + .size _TWO_52,8 + .align 4 +_ptwo_32p1: + .long 1048576 + .long 1106247680 + .type _ptwo_32p1,@object + .size _ptwo_32p1,8 + .align 4 +_ntwo_32p1: + .long 4292870144 + .long 3253731327 + .type _ntwo_32p1,@object + .size _ntwo_32p1,8 + .align 4 +_two_32: + .long 0 + .long 1106247680 + .type _two_32,@object + .size _two_32,8 + .align 4 +_TWO_512: + .long 0 + .long 1609564160 + .type _TWO_512,@object + .size _TWO_512,8 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/coshf_gen.S b/external/sgx_libm/intel64/coshf_gen.S new file mode 100644 index 0000000000..3b0a1333f8 --- /dev/null +++ b/external/sgx_libm/intel64/coshf_gen.S @@ -0,0 +1,323 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "coshf_gen.c" + .text +..TXTST0: +# -- Begin coshf + .text + .align 16,0x90 + .globl coshf +coshf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_coshf.1: +..L2: + + movd %xmm0, %eax + movss %xmm0, -8(%rsp) + andl $2147483647, %eax + cmpl $1107296256, %eax + jae ..B1.10 +..B1.2: + cmpl $1056964608, %eax + jae ..B1.9 +..B1.3: + cmpl $1031798784, %eax + jae ..B1.8 +..B1.4: + cmpl $838860800, %eax + jae ..B1.6 +..B1.5: + andps .L_2il0floatpacket.15(%rip), %xmm0 + addss .L_2il0floatpacket.16(%rip), %xmm0 + movss %xmm0, -16(%rsp) + ret +..B1.6: + pxor %xmm0, %xmm0 + cvtss2sd -8(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd .L_2il0floatpacket.13(%rip), %xmm1 + mulsd %xmm0, %xmm1 + addsd .L_2il0floatpacket.14(%rip), %xmm1 + mulsd %xmm0, %xmm1 + pxor %xmm0, %xmm0 + addsd .L_2il0floatpacket.17(%rip), %xmm1 + cvtsd2ss %xmm1, %xmm0 +..B1.7: + ret +..B1.8: + pxor %xmm1, %xmm1 + cvtss2sd -8(%rsp), %xmm1 + mulsd %xmm1, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.8(%rip), %xmm3 + movsd .L_2il0floatpacket.10(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.9(%rip), %xmm3 + addsd .L_2il0floatpacket.11(%rip), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.17(%rip), %xmm3 + cvtsd2ss %xmm3, %xmm3 + movaps %xmm3, %xmm0 + ret +..B1.9: + pxor %xmm3, %xmm3 + pxor %xmm4, %xmm4 + cvtss2sd -8(%rsp), %xmm3 + andps .L_2il0floatpacket.18(%rip), %xmm3 + pxor %xmm6, %xmm6 + movsd .L_2il0floatpacket.0(%rip), %xmm0 + mulsd %xmm3, %xmm0 + movsd .L_2il0floatpacket.4(%rip), %xmm7 + movsd .L_2il0floatpacket.6(%rip), %xmm5 + movq __libm_expf_table_64@GOTPCREL(%rip), %rsi + addsd .L_2il0floatpacket.1(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm1 + movl -16(%rsp), %ecx + movl %ecx, %eax + shll $26, %eax + subss .L_2il0floatpacket.2(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + sarl $26, %eax + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm7 + mulsd %xmm2, %xmm5 + addsd .L_2il0floatpacket.5(%rip), %xmm7 + addsd .L_2il0floatpacket.7(%rip), %xmm5 + mulsd %xmm2, %xmm7 + mulsd %xmm3, %xmm5 + addsd .L_2il0floatpacket.17(%rip), %xmm7 + movslq %eax, %rax + movaps %xmm7, %xmm0 + subl %eax, %ecx + addsd %xmm5, %xmm0 + subsd %xmm5, %xmm7 + shrl $6, %ecx + shlq $3, %rax + shll $23, %ecx + mulsd 256(%rsi,%rax), %xmm0 + negq %rax + mulsd 256(%rsi,%rax), %xmm7 + lea 1056964608(%rcx), %edx + negl %ecx + addl $1056964608, %ecx + movl %edx, -24(%rsp) + movl %ecx, -20(%rsp) + cvtss2sd -24(%rsp), %xmm4 + cvtss2sd -20(%rsp), %xmm6 + mulsd %xmm4, %xmm0 + mulsd %xmm6, %xmm7 + addsd %xmm7, %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.10: + cmpl $1119016188, %eax + jbe ..B1.14 +..B1.11: + cmpl $2139095040, %eax + jb ..B1.15 +..B1.12: + movss -8(%rsp), %xmm0 + mulss %xmm0, %xmm0 +..B1.13: + ret +..B1.14: + pxor %xmm3, %xmm3 + cvtss2sd -8(%rsp), %xmm3 + andps .L_2il0floatpacket.18(%rip), %xmm3 + movsd .L_2il0floatpacket.0(%rip), %xmm0 + mulsd %xmm3, %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movq __libm_expf_table_64@GOTPCREL(%rip), %rcx + movl $0, -24(%rsp) + addsd .L_2il0floatpacket.1(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm0 + movl -16(%rsp), %eax + movl %eax, %edx + shll $26, %edx + subss .L_2il0floatpacket.2(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + sarl $26, %edx + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + subl %edx, %eax + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm3, %xmm4 + movslq %edx, %rdx + addsd %xmm4, %xmm0 + shrl $6, %eax + addsd .L_2il0floatpacket.17(%rip), %xmm0 + mulsd 256(%rcx,%rdx,8), %xmm0 + shll $20, %eax + addl $1071644672, %eax + movl %eax, -20(%rsp) + mulsd -24(%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.15: + movss .L_2il0floatpacket.12(%rip), %xmm0 + mulss %xmm0, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type coshf,@function + .size coshf,.-coshf + .data +# -- End coshf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.15: + .long 0x7fffffff,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.18: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40571547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x41680000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.3: + .long 0xfefa39ef,0xbf862e42 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xeb78fa85,0x3fa56420 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x008d6118,0x3fe00000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xda752d4f,0x3fc55550 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0xffffe7c6,0x3fefffff + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0xdcf5905b,0x3efa3001 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x72601504,0x3fa55555 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x7543543e,0x3f56c143 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0xffe2f097,0x3fdfffff + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x6e6d0908,0x3fa55666 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0xf3327c54,0x3fdfffff + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 8 +.L_2il0floatpacket.17: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,8 + .align 4 +.L_2il0floatpacket.2: + .long 0x4b400000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.12: + .long 0x71800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .align 4 +.L_2il0floatpacket.16: + .long 0x3f800000 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/coshl.S b/external/sgx_libm/intel64/coshl.S new file mode 100644 index 0000000000..7876f73447 --- /dev/null +++ b/external/sgx_libm/intel64/coshl.S @@ -0,0 +1,897 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "coshl.c" + .text +..TXTST0: +# -- Begin coshl + .text + .align 16,0x90 + .globl coshl +coshl: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_coshl.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %cl, %cl +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movzwl 104(%rsp), %esi + andl $32767, %esi + cmpl $16396, %esi + jge ..B1.52 +..B1.4: + cmpl $16382, %esi + jge ..B1.39 +..B1.5: + movzwl 82(%rsp), %edx + cmpl $16378, %esi + jge ..B1.32 +..B1.6: + cmpl $16372, %esi + jge ..B1.25 +..B1.7: + cmpl $16365, %esi + jge ..B1.18 +..B1.8: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.12 +..B1.9: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.10: + fldcw 80(%rsp) +..B1.11: + movzwl 104(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.12: + fldt 96(%rsp) + cmpl $16308, %esi + fstpt (%rsp) + jge ..B1.14 +..B1.13: + fldt .L_2il0floatpacket.0(%rip) + fldt (%rsp) + faddp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.14: + fldt (%rsp) + lea _Q3(%rip), %rax + fldt .L_2il0floatpacket.0(%rip) + fldt (%rax) + fmul %st(2), %st + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) +..B1.15: + testb %cl, %cl + je ..B1.17 +..B1.16: + fldcw 82(%rsp) +..B1.17: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.18: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.22 +..B1.19: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.20: + fldcw 80(%rsp) +..B1.21: + movb $1, %cl +..B1.22: + fldt 96(%rsp) + lea 16+_Q2(%rip), %rax + fmul %st(0), %st + lea _Q2(%rip), %rdx + fldt (%rax) + testb %cl, %cl + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 82(%rsp) +..B1.24: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.25: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.26: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.27: + fldcw 80(%rsp) +..B1.28: + movb $1, %cl +..B1.29: + fldt 96(%rsp) + lea 48+_Q1(%rip), %rax + fmul %st(0), %st + lea 32+_Q1(%rip), %rsi + fld %st(0) + lea 16+_Q1(%rip), %rdx + fmul %st(1), %st + lea _Q1(%rip), %rdi + fldt (%rax) + testb %cl, %cl + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.31 +..B1.30: + fldcw 82(%rsp) +..B1.31: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.32: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.33: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.34: + fldcw 80(%rsp) +..B1.35: + movb $1, %cl +..B1.36: + fldt 96(%rsp) + lea _TWO_48H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea 96+_Q(%rip), %rdx + fmul %st(3), %st + lea 64+_Q(%rip), %rsi + fld %st(0) + lea 112+_Q(%rip), %r8 + fmul %st(1), %st + lea 32+_Q(%rip), %rdi + fldl (%rax) + lea 80+_Q(%rip), %r9 + lea 48+_Q(%rip), %r10 + lea 16+_Q(%rip), %r11 + lea 144+_Q(%rip), %rax + testb %cl, %cl + fadd %st, %st(4) + fsubr %st, %st(4) + fld %st(4) + fxch %st(4) + fsub %st(5), %st + fmul %st, %st(4) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + fldt (%rdx) + lea 128+_Q(%rip), %rdx + fmul %st(4), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r8) + fmul %st(5), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt (%r11) + faddp %st, %st(5) + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fld %st(2) + fldt (%rax) + fld %st(0) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(5) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(4) + fmul %st, %st(1) + fldt (%rdx) + fmul %st, %st(1) + fld %st(1) + fadd %st(3), %st + fadd %st(6), %st + fsub %st, %st(6) + fxch %st(2) + fsub %st(6), %st + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + je ..B1.75 +..B1.37: + fstpt 16(%rsp) +..B1.73: + fldcw 82(%rsp) + jmp ..B1.38 +..B1.75: + fstp %st(0) +..B1.38: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.39: + movzwl 82(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.40: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.41: + fldcw 80(%rsp) +..B1.42: + movb $1, %cl +..B1.43: + fldt 96(%rsp) + lea ones(%rip), %rax + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %rdi + movb 105(%rsp), %dl + lea _TWO_32(%rip), %r8 + andb $-128, %dl + lea _TWO_32P(%rip), %r9 + shrb $7, %dl + lea 64+_P(%rip), %r10 + fstpt 64(%rsp) + fldl (%rdi) + fldt .L_2il0floatpacket.1(%rip) + fldt .L_2il0floatpacket.2(%rip) + fldt .L_2il0floatpacket.3(%rip) + fldl (%r9) + movzbl %dl, %esi + lea 32+_P(%rip), %r11 + lea 48+_P(%rip), %rdi + fxch %st(5) + fmull (%rax,%rsi,8) + lea _P(%rip), %rsi + fmul %st, %st(3) + fxch %st(3) + fadd %st(4), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(4) + fxch %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fsubp %st, %st(1) + fld %st(0) + movl 16(%rsp), %edx + fsub %st(2), %st + fmul %st, %st(3) + fldl (%r8) + lea 16+_P(%rip), %r8 + fmul %st, %st(1) + movsbq %dl, %rax + fxch %st(1) + fsubrp %st, %st(4) + movzwl 104(%rsp), %r9d + subl %eax, %edx + andl $32767, %r9d + fxch %st(1) + fsub %st(3), %st + shrl $8, %edx + fsubp %st, %st(2) + fld %st(2) + cmpl $16387, %r9d + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fldt (%r10) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + jle ..B1.47 +..B1.44: + addl $16350, %edx + faddp %st, %st(2) + movzwl 72(%rsp), %esi + andl $32767, %edx + andl $-32768, %esi + shlq $4, %rax + orl %edx, %esi + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + testb %cl, %cl + movw %si, 72(%rsp) + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(5), %st + fmul %st(2), %st + faddp %st, %st(4) + fmul %st, %st(4) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fldt 64(%rsp) + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.46 +..B1.45: + fldt .L_2il0floatpacket.0(%rip) + fstpt 48(%rsp) +..B1.74: + fldcw 82(%rsp) +..B1.46: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.47: + je ..B1.63 +..B1.48: + fstp %st(1) + fldt .L_2il0floatpacket.0(%rip) + fstpt 48(%rsp) +..B1.49: + movzwl 56(%rsp), %r8d + lea 16382(%rdx), %esi + negl %edx + andl $-32768, %r8d + addl $16382, %edx + fld %st(0) + andl $32767, %edx + andl $32767, %esi + shlq $4, %rax + orl %edx, %r8d + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + fadd %st(2), %st + fxch %st(2) + fsubrp %st, %st(1) + fld %st(2) + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + negq %rax + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 72(%rsp), %edi + fadd %st(1), %st + fmulp %st, %st(4) + fld %st(4) + fmul %st(1), %st + andl $-32768, %edi + faddp %st, %st(4) + fldl 2056(%rdx,%rax) + orl %esi, %edi + fldl 2048(%rdx,%rax) + testb %cl, %cl + fld %st(0) + movw %di, 72(%rsp) + fadd %st(2), %st + fmulp %st, %st(5) + fld %st(6) + fmul %st(2), %st + movw %r8w, 56(%rsp) + fsubrp %st, %st(5) + fxch %st(4) + fstpt 32(%rsp) + fxch %st(3) + fmul %st, %st(5) + fldt 16(%rsp) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fsub %st(5), %st + fsubr %st, %st(4) + fxch %st(5) + fsubrp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 32(%rsp) + faddp %st, %st(2) + fldt 64(%rsp) + fmul %st, %st(1) + fmulp %st, %st(3) + fldt 48(%rsp) + fmul %st, %st(4) + fld %st(4) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.51 +..B1.50: + fldcw 82(%rsp) +..B1.51: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.52: + je ..B1.68 +..B1.53: + movzwl 82(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.57 +..B1.54: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.55: + fldcw 80(%rsp) +..B1.56: + movzwl 104(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.57: + cmpl $32767, %esi + jne ..B1.59 +..B1.58: + fldt 96(%rsp) + lea ones(%rip), %rdx + movb 105(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %esi + fmull (%rdx,%rsi,8) + fstpt (%rsp) + jmp ..B1.60 +..B1.59: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) +..B1.60: + testb %cl, %cl + je ..B1.62 +..B1.61: + fldcw 82(%rsp) +..B1.62: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.63: + movl 100(%rsp), %esi + cmpl $-782985146, %esi + ja ..B1.44 +..B1.64: + jne ..B1.67 +..B1.65: + cmpl $1501741449, 96(%rsp) + ja ..B1.44 +..B1.66: + fstp %st(1) + fldt .L_2il0floatpacket.0(%rip) + fstpt 48(%rsp) + jmp ..B1.49 +..B1.67: + fstp %st(1) + fldt .L_2il0floatpacket.0(%rip) + fstpt 48(%rsp) + jmp ..B1.49 +..B1.68: + movl 100(%rsp), %eax + cmpl $-1317741120, %eax + jb ..B1.4 +..B1.69: + jne ..B1.53 +..B1.70: + cmpl $833536233, 96(%rsp) + jbe ..B1.4 + jmp ..B1.53 + .align 16,0x90 + .cfi_endproc + .type coshl,@function + .size coshl,.-coshl + .data +# -- End coshl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 2 +_Q3: + .word 21845 + .word 213 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 62430 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 22894 + .word 21845 + .word 43733 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 65531 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 7054 + .word 43693 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 25016 + .word 58228 + .word 24755 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 57397 + .word 35800 + .word 53031 + .word 53262 + .word 16367 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 18360 + .word 43637 + .word 28980 + .word 40373 + .word 49076 + .word 0 + .word 0 + .word 0 + .word 16302 + .word 43691 + .word 43690 + .word 43690 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 46125 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 29965 + .word 3335 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 54950 + .word 46751 + .word 32187 + .word 37874 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 30733 + .word 25775 + .word 51110 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 49850 + .word 450 + .word 9929 + .word 51659 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 2776 + .word 45191 + .word 37201 + .word 55334 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,160 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cosl.S b/external/sgx_libm/intel64/cosl.S new file mode 100644 index 0000000000..98af90ff8f --- /dev/null +++ b/external/sgx_libm/intel64/cosl.S @@ -0,0 +1,1008 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cosl.c" + .text +..TXTST0: +# -- Begin cosl + .text + .align 16,0x90 + .globl cosl +cosl: +# parameter 1: 176 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cosl.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + subq $152, %rsp + .cfi_def_cfa_offset 176 + xorb %bpl, %bpl + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 136(%rsp) +..B1.2: + fnstcw 114(%rsp) +..B1.3: + movzwl 184(%rsp), %edx + andl $32767, %edx + movzwl 114(%rsp), %ecx + cmpl $32767, %edx + je ..B1.72 +..B1.4: + cmpl $16378, %edx + jge ..B1.48 +..B1.5: + cmpl $16372, %edx + jge ..B1.40 +..B1.6: + cmpl $16364, %edx + jge ..B1.32 +..B1.7: + cmpl $16308, %edx + jge ..B1.24 +..B1.8: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.12 +..B1.9: + orl $-64768, %ecx + movw %cx, 112(%rsp) +..B1.10: + fldcw 112(%rsp) +..B1.11: + movzwl 184(%rsp), %edx + movb $1, %bpl + andl $32767, %edx +..B1.12: + testl %edx, %edx + jne ..B1.18 +..B1.13: + cmpl $0, 180(%rsp) + jne ..B1.15 +..B1.14: + cmpl $0, 176(%rsp) + je ..B1.19 +..B1.88: + cmpl $0, 180(%rsp) +..B1.15: + jne ..B1.17 +..B1.16: + cmpl $0, 176(%rsp) + je ..B1.18 +..B1.17: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, (%rsp) +..B1.18: + lea _small_value_80(%rip), %rax + lea _ones(%rip), %rdx + fldt (%rax) + fsubrl (%rdx) + fstpt 8(%rsp) + jmp ..B1.20 +..B1.19: + lea _ones(%rip), %rax + fldl (%rax) + fstpt 8(%rsp) +..B1.20: + testb %bpl, %bpl + je ..B1.22 +..B1.21: + fldcw 114(%rsp) +..B1.22: + movq 136(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.64 +..B1.23: + fldt 8(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.24: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.28 +..B1.25: + orl $-64768, %ecx + movw %cx, 112(%rsp) +..B1.26: + fldcw 112(%rsp) +..B1.27: + movb $1, %bpl +..B1.28: + fldt 176(%rsp) + lea _CP3(%rip), %rax + lea _ones(%rip), %rdx + testb %bpl, %bpl + fldt (%rax) + fmul %st(1), %st + fmulp %st, %st(1) + faddl (%rdx) + fstpt 8(%rsp) + je ..B1.30 +..B1.29: + fldcw 114(%rsp) +..B1.30: + movq 136(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.64 +..B1.31: + fldt 8(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.32: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.33: + orl $-64768, %ecx + movw %cx, 112(%rsp) +..B1.34: + fldcw 112(%rsp) +..B1.35: + movb $1, %bpl +..B1.36: + fldt 176(%rsp) + lea 16+_CP2(%rip), %rax + fmul %st(0), %st + lea _CP2(%rip), %rdx + fldt (%rax) + lea _ones(%rip), %rcx + fmul %st(1), %st + testb %bpl, %bpl + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddl (%rcx) + fstpt 8(%rsp) + je ..B1.38 +..B1.37: + fldcw 114(%rsp) +..B1.38: + movq 136(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.64 +..B1.39: + fldt 8(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.40: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.44 +..B1.41: + orl $-64768, %ecx + movw %cx, 112(%rsp) +..B1.42: + fldcw 112(%rsp) +..B1.43: + movb $1, %bpl +..B1.44: + fldt 176(%rsp) + lea 48+_CP1(%rip), %rax + fmul %st(0), %st + lea 32+_CP1(%rip), %rcx + fld %st(0) + lea 16+_CP1(%rip), %rdx + fmul %st(1), %st + lea _CP1(%rip), %rbx + fldt (%rax) + lea _ones(%rip), %rsi + fmul %st(1), %st + testb %bpl, %bpl + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + fmulp %st, %st(2) + fldt (%rbx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddl (%rsi) + fstpt 8(%rsp) + je ..B1.46 +..B1.45: + fldcw 114(%rsp) +..B1.46: + movq 136(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.64 +..B1.47: + fldt 8(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.48: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.52 +..B1.49: + orl $-64768, %ecx + movw %cx, 112(%rsp) +..B1.50: + fldcw 112(%rsp) +..B1.51: + movzwl 184(%rsp), %edx + movb $1, %bpl + andl $32767, %edx +..B1.52: + cmpl $16382, %edx + jge ..B1.54 +..B1.53: + fldt 176(%rsp) + xorl %ecx, %ecx + movb 185(%rsp), %bl + xorl %esi, %esi + andb $-128, %bl + lea _TWO_52H(%rip), %rdx + shrb $7, %bl + fldl (%rdx) + movzbl %bl, %eax + lea _ones(%rip), %rbx + fxch %st(1) + fmull (%rbx,%rax,8) + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fxch %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + fxch %st(1) + fxch %st(2) + fxch %st(1) + jmp ..B1.57 +..B1.54: + je ..B1.69 +..B1.55: + fldt 176(%rsp) + xorl %edi, %edi + movb 185(%rsp), %bl + andb $-128, %bl + shrb $7, %bl + movzbl %bl, %eax + lea _ones(%rip), %rbx + fmull (%rbx,%rax,8) + fstpt 176(%rsp) + fldt 176(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + lea 136(%rsp), %rsi + fstpt (%rsp) +..___tag_value_cosl.41: + call __libm_reduce_pi04l@PLT +..___tag_value_cosl.42: +..B1.87: + movl %eax, %esi + addq $16, %rsp + .cfi_def_cfa_offset 176 +..B1.56: + fldl 120(%rsp) + lea 3(%rsi), %ecx + lea _TWO_52H(%rip), %rax + fld %st(0) + movsd 120(%rsp), %xmm0 + shrl $2, %ecx + andl $1, %ecx + mulsd (%rax), %xmm0 + movsd %xmm0, 24(%rsp) + fldl 24(%rsp) + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fldl 128(%rsp) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st +..B1.57: + fld %st(1) + lea _TWO_53H(%rip), %rax + fmul %st(3), %st + fld %st(3) + fmul %st(2), %st + incl %esi + faddp %st, %st(1) + fstpt 88(%rsp) + fldt 88(%rsp) + fld %st(2) + fmul %st(3), %st + testl $2, %esi + fld %st(0) + fadd %st(2), %st + fstpt 40(%rsp) + fldt 40(%rsp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 72(%rsp) + fldt 72(%rsp) + fld %st(1) + fmul %st(2), %st + fld %st(0) + faddp %st, %st(2) + fldl (%rax) + fstpt 56(%rsp) + fldl (%rbx,%rcx,8) + fstpl 104(%rsp) + je ..B1.59 +..B1.58: + lea 112+_SP(%rip), %rax + lea 80+_SP(%rip), %rdx + lea 48+_SP(%rip), %rcx + lea 128+_SP(%rip), %rsi + fxch %st(4) + fstpt 8(%rsp) + lea 16+_SP(%rip), %rbx + lea 96+_SP(%rip), %rdi + lea 64+_SP(%rip), %r8 + fldt (%rax) + lea 32+_SP(%rip), %r9 + lea _SP(%rip), %r10 + lea 160+_SP(%rip), %r11 + lea 144+_SP(%rip), %rax + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r10) + faddp %st, %st(2) + fldt 40(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 72(%rsp) + fldt 88(%rsp) + fldt (%r11) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(5) + fldt (%rax) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fld %st(4) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fadd %st, %st(1) + fld %st(4) + fldt 56(%rsp) + fmul %st(3), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt 8(%rsp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldl 104(%rsp) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 24(%rsp) + jmp ..B1.60 +..B1.59: + fstp %st(3) + fstp %st(4) + fstp %st(2) + lea 112+_CP(%rip), %rax + lea 80+_CP(%rip), %rdx + lea 128+_CP(%rip), %rdi + lea 96+_CP(%rip), %r8 + lea 48+_CP(%rip), %rcx + lea 64+_CP(%rip), %r9 + lea 16+_CP(%rip), %rsi + lea 32+_CP(%rip), %r10 + fldt (%rax) + lea _CP(%rip), %r11 + lea 160+_CP(%rip), %rax + fmul %st(3), %st + fldt (%rdx) + lea 144+_CP(%rip), %rdx + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + fmul %st(4), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt (%r11) + faddp %st, %st(4) + fldt 40(%rsp) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt 72(%rsp) + fldt 88(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rdx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(1) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fldt 56(%rsp) + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldl (%rbx) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldl 104(%rsp) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 24(%rsp) +..B1.60: + testb %bpl, %bpl + je ..B1.62 +..B1.61: + fldcw 114(%rsp) +..B1.62: + movq 136(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.64 +..B1.63: + fldt 24(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.64: + call __stack_chk_fail@PLT +..B1.69: + movl 180(%rsp), %eax + cmpl $-921707870, %eax + jb ..B1.53 +..B1.70: + jne ..B1.55 +..B1.71: + cmpl $560513589, 176(%rsp) + jbe ..B1.53 + jmp ..B1.55 +..B1.72: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.76 +..B1.73: + orl $-64768, %ecx + movw %cx, 112(%rsp) +..B1.74: + fldcw 112(%rsp) +..B1.75: + movb $1, %bpl +..B1.76: + cmpl $-2147483648, 180(%rsp) + jne ..B1.79 +..B1.77: + cmpl $0, 176(%rsp) + jne ..B1.79 +..B1.78: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 24(%rsp) + fldl 24(%rsp) + fstpt 8(%rsp) + jmp ..B1.80 +..B1.79: + fldt 176(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) +..B1.80: + testb %bpl, %bpl + je ..B1.82 +..B1.81: + fldcw 114(%rsp) +..B1.82: + movq 136(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.64 +..B1.83: + fldt 8(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cosl,@function + .size cosl,.-cosl + .data +# -- End cosl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_CP3: + .word 0 + .word 65450 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .type _CP3,@object + .size _CP3,16 + .align 2 +_CP2: + .word 63855 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 18238 + .word 17476 + .word 43656 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP2,@object + .size _CP2,32 + .align 2 +_CP1: + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 47533 + .word 43689 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 14131 + .word 49466 + .word 24756 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 37142 + .word 18013 + .word 35855 + .word 53259 + .word 16367 + .word 0 + .word 0 + .word 0 + .type _CP1,@object + .size _CP1,64 + .align 2 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP,@object + .size _SP,176 + .align 2 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 0 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 0 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP,@object + .size _CP,176 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cpow.S b/external/sgx_libm/intel64/cpow.S new file mode 100644 index 0000000000..80151b7eaa --- /dev/null +++ b/external/sgx_libm/intel64/cpow.S @@ -0,0 +1,931 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cpow.c" + .text +..TXTST0: +# -- Begin cpowf + .text + .align 16,0x90 + .globl cpowf +cpowf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_cpowf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + movaps %xmm1, %xmm3 + cvtps2pd %xmm0, %xmm1 + cvtps2pd %xmm3, %xmm3 + movaps %xmm1, %xmm0 + movaps %xmm3, %xmm2 + unpckhpd %xmm1, %xmm1 + unpckhpd %xmm3, %xmm3 +..___tag_value_cpowf.4: + call cpow@PLT +..___tag_value_cpowf.5: +..B1.5: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type cpowf,@function + .size cpowf,.-cpowf + .data +# -- End cpowf + .text +# -- Begin cpow + .text + .align 16,0x90 + .globl cpow +cpow: +# parameter 1: %xmm0 +# parameter 2: %xmm2 +..B2.1: + .cfi_startproc +..___tag_value_cpow.8: +..L9: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + xorb %r14b, %r14b + subq $328, %rsp + .cfi_def_cfa_offset 352 + movsd %xmm1, 312(%rsp) + movsd %xmm0, 304(%rsp) + movsd %xmm2, 288(%rsp) + movsd %xmm3, 296(%rsp) +..B2.2: + fnstcw 10(%rsp) +..B2.3: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.7 +..B2.4: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B2.5: + fldcw 8(%rsp) +..B2.6: + movb $1, %r14b +..B2.7: + movsd 304(%rsp), %xmm0 +..___tag_value_cpow.15: + call __libm_internal_isnzfinite@PLT +..___tag_value_cpow.16: +..B2.8: + testl %eax, %eax + jne ..B2.29 +..B2.9: + lea ZEROA(%rip), %r13 + movsd 312(%rsp), %xmm3 + movsd (%r13), %xmm2 + ucomisd %xmm2, %xmm3 + jp ..B2.10 + je ..B2.25 +..B2.10: + movsd 288(%rsp), %xmm1 + ucomisd %xmm2, %xmm1 + jp ..B2.11 + je ..B2.23 +..B2.11: + ucomisd %xmm2, %xmm3 + jp ..B2.12 + je ..B2.18 +..B2.12: + movsd 296(%rsp), %xmm0 + ucomisd %xmm2, %xmm0 + jp ..B2.13 + je ..B2.17 +..B2.13: + fldl 304(%rsp) + fstpt 48(%rsp) + fldl 312(%rsp) + fstpt 64(%rsp) + fldt 48(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fldt 64(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fstpt (%rsp) + call logl@PLT +..B2.46: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 160(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2dl@PLT +..B2.45: + fldt .L_2il0floatpacket.2(%rip) + addq $32, %rsp + .cfi_def_cfa_offset 352 + fxch %st(1) + fstpt 80(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%rsp) + call expl@PLT +..B2.44: + addq $16, %rsp + .cfi_def_cfa_offset 352 + lea _LD_PI_DIV_180(%rip), %rax + fstpt 208(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) + call expl@PLT +..B2.43: + fldt .L_2il0floatpacket.2(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 352 + fxch %st(1) + fstpt 224(%rsp) + fldt 208(%rsp) + fldt 224(%rsp) + fdivrp %st, %st(1) + fstpt 96(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%rsp) + call cosl@PLT +..B2.42: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 176(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call cosdl@PLT +..B2.41: + fldt .L_2il0floatpacket.2(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 352 + fxch %st(1) + fstpt 112(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fxch %st(1) + fmull 312(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sinl@PLT +..B2.40: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 192(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sindl@PLT +..B2.39: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 128(%rsp) + fldt 176(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt 192(%rsp) + fldt 128(%rsp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt 240(%rsp) + fldt 192(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt 128(%rsp) + fldt 176(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 256(%rsp) + fldt 240(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 272(%rsp) + fldt 256(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 280(%rsp) +..B2.14: + testb %r14b, %r14b + je ..B2.16 +..B2.15: + fldcw 10(%rsp) +..B2.16: + movsd 272(%rsp), %xmm0 + movsd 280(%rsp), %xmm1 + addq $328, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 352 + .cfi_offset 13, -16 + .cfi_offset 14, -24 +..B2.17: + fldl 304(%rsp) + fstpt 48(%rsp) + fldl 312(%rsp) + fstpt 64(%rsp) + fldt 48(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fldt 64(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + movsd .L_2il0floatpacket.1(%rip), %xmm0 + faddp %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + mulsd 320(%rsp), %xmm0 + fstpt (%rsp) + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt 16(%rsp) + call powl@PLT +..B2.50: + addq $32, %rsp + .cfi_def_cfa_offset 352 + fstpt 96(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2dl@PLT +..B2.49: + addq $32, %rsp + .cfi_def_cfa_offset 352 + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call cosdl@PLT +..B2.48: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 176(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sindl@PLT +..B2.47: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 192(%rsp) + fldt 96(%rsp) + fldt 176(%rsp) + fmulp %st, %st(1) + fstpl 272(%rsp) + fldt 96(%rsp) + fldt 192(%rsp) + fmulp %st, %st(1) + fstpl 280(%rsp) + jmp ..B2.14 +..B2.18: + movsd 304(%rsp), %xmm0 + comisd %xmm2, %xmm0 + jbe ..B2.20 +..B2.19: + addq $-32, %rsp + .cfi_def_cfa_offset 384 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt (%rsp) + movsd %xmm1, 32(%rsp) + fldl 32(%rsp) + fstpt 16(%rsp) + call powl@PLT +..B2.54: + addq $32, %rsp + .cfi_def_cfa_offset 352 + fstpt 96(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 320(%rsp) + fstpt (%rsp) + call logl@PLT +..B2.53: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 32(%rsp) + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call cosl@PLT +..B2.52: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 176(%rsp) + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sinl@PLT +..B2.51: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 192(%rsp) + fldt 176(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 272(%rsp) + fldt 192(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 280(%rsp) + jmp ..B2.14 +..B2.20: + comisd %xmm0, %xmm2 + jbe ..B2.22 +..B2.21: + fldl 312(%rsp) + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fchs + fstpt 16(%rsp) + fstpt 64(%rsp) + fldt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fstpt (%rsp) + call logl@PLT +..B2.62: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 160(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2dl@PLT +..B2.61: + addq $32, %rsp + .cfi_def_cfa_offset 352 + fstpt 80(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call expl@PLT +..B2.60: + addq $16, %rsp + .cfi_def_cfa_offset 352 + lea _LD_PI_DIV_180(%rip), %rax + fstpt 208(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) + call expl@PLT +..B2.59: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 224(%rsp) + fldt 208(%rsp) + fldt 224(%rsp) + fdivrp %st, %st(1) + fstpt 96(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call cosl@PLT +..B2.58: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 176(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call cosdl@PLT +..B2.57: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 112(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sinl@PLT +..B2.56: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 192(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sindl@PLT +..B2.55: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 128(%rsp) + fldt 176(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt 192(%rsp) + fldt 128(%rsp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt 240(%rsp) + fldt 192(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt 128(%rsp) + fldt 176(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 256(%rsp) + fldt 240(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 272(%rsp) + fldt 256(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 280(%rsp) + jmp ..B2.14 +..B2.22: + movq 304(%rsp), %rax + movq 312(%rsp), %rdx + movq %rax, 272(%rsp) + movq %rdx, 280(%rsp) + jmp ..B2.14 +..B2.23: + movsd 296(%rsp), %xmm0 + ucomisd %xmm2, %xmm0 + jne ..B2.11 + jp ..B2.11 +..B2.24: + fldl 304(%rsp) + fstpt 48(%rsp) + fldl 312(%rsp) + fstpt 64(%rsp) + fldt 48(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fldt 64(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fstpt (%rsp) + call logl@PLT +..B2.65: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 160(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2l@PLT +..B2.64: + addq $32, %rsp + .cfi_def_cfa_offset 352 + fstpt 80(%rsp) + fldt 160(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + faddp %st, %st(1) + fstpt (%rsp) + call sinl@PLT +..B2.63: + addq $16, %rsp + .cfi_def_cfa_offset 352 + movq $0x3ff0000000000000, %rax + fstpl (%rsp) + movsd (%rsp), %xmm1 + movsd (%r13), %xmm0 + movsd .L_2il0floatpacket.0(%rip), %xmm2 + andps %xmm2, %xmm1 + andnps %xmm0, %xmm2 + orps %xmm1, %xmm2 + movq %rax, 272(%rsp) + movsd %xmm2, 280(%rsp) + jmp ..B2.14 +..B2.25: + movsd 296(%rsp), %xmm0 + ucomisd %xmm2, %xmm0 + jne ..B2.10 + jp ..B2.10 +..B2.26: + movsd 304(%rsp), %xmm0 + comisd %xmm0, %xmm2 + jbe ..B2.28 +..B2.27: + fldl 312(%rsp) + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fchs + fstpt 16(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2dl@PLT +..B2.69: + addq $32, %rsp + .cfi_def_cfa_offset 352 + fstpt 80(%rsp) + fldt 16(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fstpt (%rsp) + fldl 320(%rsp) + fstpt 16(%rsp) + call powl@PLT +..B2.68: + addq $32, %rsp + .cfi_def_cfa_offset 352 + fstpt 96(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call cosdl@PLT +..B2.67: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 112(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sindl@PLT +..B2.66: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 128(%rsp) + fldt 96(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fstpl 272(%rsp) + fldt 96(%rsp) + fldt 128(%rsp) + fmulp %st, %st(1) + fstpl 280(%rsp) + jmp ..B2.14 +..B2.28: + movsd 288(%rsp), %xmm1 + movsd %xmm3, (%rsp) + call pow@PLT +..B2.70: + movsd (%rsp), %xmm3 + movsd %xmm0, 272(%rsp) + movsd %xmm3, 280(%rsp) + jmp ..B2.14 +..B2.29: + movsd 312(%rsp), %xmm0 +..___tag_value_cpow.87: + call __libm_internal_isnzfinite@PLT +..___tag_value_cpow.88: +..B2.30: + testl %eax, %eax + je ..B2.9 +..B2.31: + movsd 288(%rsp), %xmm0 +..___tag_value_cpow.89: + call __libm_internal_isnzfinite@PLT +..___tag_value_cpow.90: +..B2.32: + testl %eax, %eax + je ..B2.9 +..B2.33: + movsd 296(%rsp), %xmm0 +..___tag_value_cpow.91: + call __libm_internal_isnzfinite@PLT +..___tag_value_cpow.92: +..B2.34: + testl %eax, %eax + je ..B2.9 +..B2.35: + fldl 304(%rsp) + fstpt 48(%rsp) + fldl 312(%rsp) + fstpt 64(%rsp) + fldt 48(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fldt 64(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fstpt (%rsp) + call logl@PLT +..B2.81: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 160(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 384 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) + call atan2dl@PLT +..B2.80: + fldt .L_2il0floatpacket.2(%rip) + addq $32, %rsp + .cfi_def_cfa_offset 352 + fxch %st(1) + fstpt 80(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%rsp) + call expl@PLT +..B2.79: + addq $16, %rsp + .cfi_def_cfa_offset 352 + lea _LD_PI_DIV_180(%rip), %rax + fstpt 208(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) + call expl@PLT +..B2.78: + fldt .L_2il0floatpacket.2(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 352 + fxch %st(1) + fstpt 224(%rsp) + fldt 208(%rsp) + fldt 224(%rsp) + fdivrp %st, %st(1) + fstpt 96(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 312(%rsp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt (%rsp) + call cosl@PLT +..B2.77: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 176(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call cosdl@PLT +..B2.76: + fldt .L_2il0floatpacket.2(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 352 + fxch %st(1) + fstpt 112(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fxch %st(1) + fmull 312(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sinl@PLT +..B2.75: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 192(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 368 + fldl 304(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + call sindl@PLT +..B2.74: + addq $16, %rsp + .cfi_def_cfa_offset 352 + fstpt 128(%rsp) + fldt 176(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt 192(%rsp) + fldt 128(%rsp) + fmulp %st, %st(1) + fsubrp %st, %st(1) + fstpt 240(%rsp) + fldt 192(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fldt 128(%rsp) + fldt 176(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 256(%rsp) + fldt 240(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 272(%rsp) + fldt 256(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpl 280(%rsp) + jmp ..B2.14 + .align 16,0x90 + .cfi_endproc + .type cpow,@function + .size cpow,.-cpow + .data +# -- End cpow + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +ZEROA: + .long 0 + .long 0 + .type ZEROA,@object + .size ZEROA,8 + .space 8, 0x00 # pad + .align 16 +_LD_PI_DIV_180: + .word 51374 + .word 38121 + .word 13586 + .word 36602 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _LD_PI_DIV_180,@object + .size _LD_PI_DIV_180,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x80000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cpowl.S b/external/sgx_libm/intel64/cpowl.S new file mode 100644 index 0000000000..875f0ba939 --- /dev/null +++ b/external/sgx_libm/intel64/cpowl.S @@ -0,0 +1,137 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cpowl.c" + .text +..TXTST0: +# -- Begin cpowl + .text + .align 16,0x90 + .globl cpowl +cpowl: +# parameter 1: 48 + %rsp +# parameter 2: 80 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cpowl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 32(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 80 + movq %rsp, %r8 + movq 80(%rsp), %rdx + movq 88(%rsp), %rcx + movq 96(%rsp), %rsi + movq 104(%rsp), %rdi + movq %rdx, (%r8) + movq %rcx, 8(%r8) + movq %rsi, 16(%r8) + movq %rdi, 24(%r8) + call clogl@PLT +..B1.9: + fxch %st(1) + fxch %st(1) + addq $32, %rsp + .cfi_def_cfa_offset 48 + fldt 80(%rsp) + fld %st(0) + fmul %st(2), %st + fxch %st(1) + fmul %st(3), %st + fldt 96(%rsp) + fld %st(0) + fmulp %st, %st(5) + fxch %st(4) + fsubrp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 80 + movq %rsp, %rdi + movq 32(%rsp), %rax + movq 40(%rsp), %rdx + movq 48(%rsp), %rcx + movq 56(%rsp), %rsi + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + movq %rcx, 16(%rdi) + movq %rsi, 24(%rdi) + call cexpl@PLT +..B1.8: + fxch %st(1) + addq $32, %rsp + .cfi_def_cfa_offset 48 + movq 32(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.4 +..B1.2: + movq 32(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.4 +..B1.3: + addq $40, %rsp + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 48 +..B1.4: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type cpowl,@function + .size cpowl,.-cpowl + .data +# -- End cpowl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cproj.S b/external/sgx_libm/intel64/cproj.S new file mode 100644 index 0000000000..f2fe33a5fe --- /dev/null +++ b/external/sgx_libm/intel64/cproj.S @@ -0,0 +1,132 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cproj.c" + .text +..TXTST0: +# -- Begin cproj + .text + .align 16,0x90 + .globl cproj +cproj: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cproj.1: +..L2: + + movsd %xmm0, -24(%rsp) + movzwl -18(%rsp), %eax + andl $32752, %eax + movsd %xmm1, -16(%rsp) + cmpl $32752, %eax + je ..B1.10 +..B1.2: + movzwl -10(%rsp), %eax + andl $32752, %eax + cmpl $32752, %eax + jne ..B1.9 +..B1.3: + testl $1048575, -12(%rsp) + jne ..B1.9 +..B1.4: + cmpl $0, -16(%rsp) + jne ..B1.9 +..B1.5: + lea DBL_PINFA(%rip), %rax + testb $-128, -9(%rsp) + movq (%rax), %rdx + movq %rdx, -40(%rsp) + je ..B1.7 +..B1.6: + lea DBL_NZEROA(%rip), %rax + movq (%rax), %rdx + movq %rdx, -32(%rsp) + jmp ..B1.8 +..B1.7: + lea DBL_PZEROA(%rip), %rax + movq (%rax), %rdx + movq %rdx, -32(%rsp) +..B1.8: + movsd -40(%rsp), %xmm0 + movsd -32(%rsp), %xmm1 + ret +..B1.9: + movsd -24(%rsp), %xmm0 + movsd -16(%rsp), %xmm1 + ret +..B1.10: + testl $1048575, -20(%rsp) + jne ..B1.2 +..B1.11: + cmpl $0, -24(%rsp) + je ..B1.5 + jmp ..B1.2 + .align 16,0x90 + .cfi_endproc + .type cproj,@function + .size cproj,.-cproj + .data +# -- End cproj + .section .rodata, "a" + .align 16 + .align 16 +DBL_PINFA: + .long 0 + .long 2146435072 + .type DBL_PINFA,@object + .size DBL_PINFA,8 + .space 8, 0x00 # pad + .align 16 +DBL_NZEROA: + .long 0 + .long 2147483648 + .type DBL_NZEROA,@object + .size DBL_NZEROA,8 + .space 8, 0x00 # pad + .align 16 +DBL_PZEROA: + .long 0 + .long 0 + .type DBL_PZEROA,@object + .size DBL_PZEROA,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cprojf.S b/external/sgx_libm/intel64/cprojf.S new file mode 100644 index 0000000000..734fbc8cce --- /dev/null +++ b/external/sgx_libm/intel64/cprojf.S @@ -0,0 +1,107 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cprojf.c" + .text +..TXTST0: +# -- Begin cprojf + .text + .align 16,0x90 + .globl cprojf +cprojf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_cprojf.1: +..L2: + + movsd %xmm0, -16(%rsp) + movzwl -14(%rsp), %eax + andl $32640, %eax + cmpl $32640, %eax + je ..B1.9 +..B1.2: + movzwl -10(%rsp), %eax + andl $32640, %eax + cmpl $32640, %eax + jne ..B1.8 +..B1.3: + testl $8388607, -12(%rsp) + jne ..B1.8 +..B1.4: + movl $2139095040, -24(%rsp) + testb $-128, -9(%rsp) + je ..B1.6 +..B1.5: + movl $-2147483648, -20(%rsp) + jmp ..B1.7 +..B1.6: + movl $0, -20(%rsp) +..B1.7: + movsd -24(%rsp), %xmm0 + ret +..B1.8: + movsd -16(%rsp), %xmm0 + ret +..B1.9: + testl $8388607, -16(%rsp) + je ..B1.4 + jmp ..B1.2 + .align 16,0x90 + .cfi_endproc + .type cprojf,@function + .size cprojf,.-cprojf + .data +# -- End cprojf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.5: + .long 0x7f800000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,4 + .align 4 +.L_2il0floatpacket.6: + .long 0x80000000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/cprojl.S b/external/sgx_libm/intel64/cprojl.S new file mode 100644 index 0000000000..a212664b1b --- /dev/null +++ b/external/sgx_libm/intel64/cprojl.S @@ -0,0 +1,152 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "cprojl.c" + .text +..TXTST0: +# -- Begin cprojl + .text + .align 16,0x90 + .globl cprojl +cprojl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_cprojl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movzwl 56(%rsp), %edx + andl $32767, %edx + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 32(%rsp) + cmpl $32767, %edx + je ..B1.12 +..B1.2: + movzwl 72(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.9 +..B1.3: + fldt 48(%rsp) + fstpt (%rsp) + fldt 64(%rsp) + fstpt 16(%rsp) +..B1.4: + movq 32(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.8 +..B1.5: + fldt (%rsp) + fldt 16(%rsp) + movq 32(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.7 +..B1.6: + addq $40, %rsp + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 48 +..B1.7: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.8: + call __stack_chk_fail@PLT +..B1.9: + movq $0x8000000000000000, %rax + cmpq 64(%rsp), %rax + jne ..B1.3 +..B1.10: + fldt .L_2il0floatpacket.7(%rip) + fstpt 16(%rsp) + fldt .L_2il0floatpacket.7(%rip) + fstpt (%rsp) +..B1.11: + fldt .L_2il0floatpacket.8(%rip) + movb 9+.L_2il0floatpacket.7(%rip), %cl + movb 73(%rsp), %dl + andb $127, %cl + andb $-128, %dl + movzwl 8+.L_2il0floatpacket.8(%rip), %eax + orb %dl, %cl + fstpt (%rsp) + orl $-32769, %eax + fldt .L_2il0floatpacket.7(%rip) + fstpt 16(%rsp) + movw %ax, 8(%rsp) + movb %cl, 25(%rsp) + jmp ..B1.4 +..B1.12: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.2 +..B1.13: + fldt .L_2il0floatpacket.7(%rip) + fstpt 16(%rsp) + fldt .L_2il0floatpacket.7(%rip) + fstpt (%rsp) + jmp ..B1.11 + .align 16,0x90 + .cfi_endproc + .type cprojl,@function + .size cprojl,.-cprojl + .data +# -- End cprojl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/creal.S b/external/sgx_libm/intel64/creal.S new file mode 100644 index 0000000000..fd45e1b9c9 --- /dev/null +++ b/external/sgx_libm/intel64/creal.S @@ -0,0 +1,64 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "creal.c" + .text +..TXTST0: +# -- Begin creal + .text + .align 16,0x90 + .globl creal +creal: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_creal.1: +..L2: + + ret + .align 16,0x90 + .cfi_endproc + .type creal,@function + .size creal,.-creal + .data +# -- End creal + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/crealf.S b/external/sgx_libm/intel64/crealf.S new file mode 100644 index 0000000000..96dd08ff3f --- /dev/null +++ b/external/sgx_libm/intel64/crealf.S @@ -0,0 +1,66 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "crealf.c" + .text +..TXTST0: +# -- Begin crealf + .text + .align 16,0x90 + .globl crealf +crealf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_crealf.1: +..L2: + + movsd %xmm0, -8(%rsp) + movss -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type crealf,@function + .size crealf,.-crealf + .data +# -- End crealf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/creall.S b/external/sgx_libm/intel64/creall.S new file mode 100644 index 0000000000..7ae974ad56 --- /dev/null +++ b/external/sgx_libm/intel64/creall.S @@ -0,0 +1,65 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "creall.c" + .text +..TXTST0: +# -- Begin creall + .text + .align 16,0x90 + .globl creall +creall: +# parameter 1: 8 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_creall.1: +..L2: + + fldt 8(%rsp) + ret + .align 16,0x90 + .cfi_endproc + .type creall,@function + .size creall,.-creall + .data +# -- End creall + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/csin.S b/external/sgx_libm/intel64/csin.S new file mode 100644 index 0000000000..78cd00ed8d --- /dev/null +++ b/external/sgx_libm/intel64/csin.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csin.c" + .text +..TXTST0: +# -- Begin csin + .text + .align 16,0x90 + .globl csin +csin: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_csin.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movsd %xmm1, 24(%rsp) + movzwl 30(%rsp), %eax + andl $32752, %eax + movsd %xmm0, 16(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.5 +..B1.3: + testl $1048575, 28(%rsp) + jne ..B1.7 +..B1.4: + cmpl $0, 24(%rsp) + jne ..B1.7 +..B1.5: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.6: + movb 31(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm1 + movhpd 8(%rsp), %xmm1 +..B1.7: + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + call csinh@PLT +..B1.16: + movsd %xmm0, 16(%rsp) + movzwl 22(%rsp), %eax + andl $32752, %eax + movsd %xmm1, 24(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.11 +..B1.9: + testl $1048575, 20(%rsp) + jne ..B1.13 +..B1.10: + cmpl $0, 16(%rsp) + jne ..B1.13 +..B1.11: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.12: + movb 23(%rsp), %al + notb %al + movb 15(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movsd (%rsp), %xmm1 + movb %dl, 15(%rsp) + movhpd 8(%rsp), %xmm1 +..B1.13: + movaps %xmm1, %xmm2 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm2 + movaps %xmm2, %xmm1 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type csin,@function + .size csin,.-csin + .data +# -- End csin + .text +# -- Begin csinf + .text + .align 16,0x90 + .globl csinf +csinf: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_csinf.6: +..L7: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) + movzwl 14(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.4 +..B2.3: + testl $8388607, 12(%rsp) + jne ..B2.6 +..B2.4: + movsd %xmm0, (%rsp) +..B2.5: + movb 15(%rsp), %al + notb %al + movb 3(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 3(%rsp) + movsd (%rsp), %xmm0 +..B2.6: + call csinhf@PLT +..B2.14: + movsd %xmm0, 8(%rsp) + movzwl 10(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.9 +..B2.8: + testl $8388607, 8(%rsp) + jne ..B2.11 +..B2.9: + movsd %xmm0, (%rsp) +..B2.10: + movb 11(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm0 +..B2.11: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type csinf,@function + .size csinf,.-csinf + .data +# -- End csinf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/csinh.S b/external/sgx_libm/intel64/csinh.S new file mode 100644 index 0000000000..0c5a8e4b5a --- /dev/null +++ b/external/sgx_libm/intel64/csinh.S @@ -0,0 +1,522 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csinh.c" + .text +..TXTST0: +# -- Begin csinhf + .text + .align 16,0x90 + .globl csinhf +csinhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_csinhf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_csinhf.4: + call csinh@PLT +..___tag_value_csinhf.5: +..B1.10: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + movsd %xmm0, 4(%rsp) + movzwl 6(%rsp), %eax + testl $32640, %eax + jne ..B1.4 +..B1.3: + testl $8388607, 4(%rsp) + jne ..B1.6 +..B1.4: + movzwl 10(%rsp), %eax + testl $32640, %eax + jne ..B1.7 +..B1.5: + testl $8388607, 8(%rsp) + je ..B1.7 +..B1.6: + movl $8388608, (%rsp) + movss (%rsp), %xmm1 + movss (%rsp), %xmm0 + mulss %xmm0, %xmm1 + movsd 4(%rsp), %xmm0 + movss %xmm1, (%rsp) +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type csinhf,@function + .size csinhf,.-csinhf + .data +# -- End csinhf + .text +# -- Begin csinh + .text + .align 16,0x90 + .globl csinh +csinh: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_csinh.8: +..L9: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + movq %fs:40, %rax + subq $112, %rsp + .cfi_def_cfa_offset 144 + movsd %xmm0, 48(%rsp) + xorq %rsp, %rax + movzwl 54(%rsp), %r14d + andl $32752, %r14d + shrl $4, %r14d + movsd %xmm1, 56(%rsp) + cmpl $2047, %r14d + movq %rax, 96(%rsp) + jge ..B2.23 +..B2.2: + testl %r14d, %r14d + jle ..B2.42 +..B2.3: + movzwl 62(%rsp), %r13d + andl $32752, %r13d + shrl $4, %r13d + cmpl $2047, %r13d + jge ..B2.24 +..B2.4: + testl %r13d, %r13d + jle ..B2.40 +..B2.5: + cmpl $1034, %r14d + jl ..B2.11 +..B2.6: + lea _CONSTANTS(%rip), %rax + movsd 48(%rsp), %xmm1 + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm1 + movsd %xmm0, 32(%rsp) + movsd 56(%rsp), %xmm0 + movsd %xmm1, 24(%rsp) + movsd %xmm0, 16(%rsp) + call __libm_sse2_sincos@PLT +..B2.52: + movaps %xmm0, %xmm2 + testl %r13d, %r13d + movsd 24(%rsp), %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, (%rsp) + jle ..B2.8 +..B2.7: + movsd 32(%rsp), %xmm0 + mulsd %xmm2, %xmm0 + movsd %xmm0, 32(%rsp) + jmp ..B2.9 +..B2.8: + movsd 32(%rsp), %xmm0 + mulsd 16(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) +..B2.9: + movsd %xmm0, 8(%rsp) + movq 96(%rsp), %rax + xorq %rsp, %rax + movsd (%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.39 +..B2.10: + movsd 32(%rsp), %xmm1 + addq $112, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B2.11: + movsd 48(%rsp), %xmm0 + lea 64(%rsp), %rdi +..___tag_value_csinh.28: + call __libm_cosh_k64@PLT +..___tag_value_csinh.29: +..B2.53: + movl %eax, %r15d +..B2.12: + movsd 64(%rsp), %xmm0 + movsd 72(%rsp), %xmm4 + movaps %xmm0, %xmm5 + movsd .L_2il0floatpacket.11(%rip), %xmm3 + addsd %xmm4, %xmm5 + mulsd %xmm5, %xmm3 + movaps %xmm5, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm3, %xmm2 + subsd %xmm1, %xmm4 + subsd %xmm5, %xmm2 + movzwl 54(%rsp), %eax + subsd %xmm2, %xmm3 + andl $32752, %eax + subsd %xmm3, %xmm5 + movsd %xmm3, 64(%rsp) + cmpl $13168, %eax + addsd %xmm4, %xmm5 + movsd %xmm5, 72(%rsp) + jge ..B2.14 +..B2.13: + lea 16+_CONSTANTS(%rip), %r14 + lea 40(%rsp), %rdx + movsd 8(%rdx), %xmm0 + pxor %xmm5, %xmm5 + mulsd (%r14), %xmm0 + movsd %xmm0, -8(%rdx) + movzwl -2(%rdx), %eax + movl %eax, %r14d + andl $32752, %r14d + andl $-32753, %eax + shrl $4, %r14d + orl $-49168, %eax + movw %ax, -2(%rdx) + addl $-1279, %r14d + jmp ..B2.16 +..B2.14: + movsd 48(%rsp), %xmm0 + lea 32(%rsp), %rdi +..___tag_value_csinh.30: + call __libm_sinh_k64@PLT +..___tag_value_csinh.31: +..B2.54: + movl %eax, %r14d +..B2.15: + lea 40(%rsp), %rdx + movsd (%rdx), %xmm5 +..B2.16: + movsd 32(%rsp), %xmm0 + movaps %xmm5, %xmm4 + movsd .L_2il0floatpacket.11(%rip), %xmm3 + lea 16(%rsp), %rdi + addsd %xmm0, %xmm4 + mulsd %xmm4, %xmm3 + movaps %xmm4, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm3, %xmm2 + lea 80(%rsp), %rsi + movsd -24(%rsi), %xmm0 + subsd %xmm4, %xmm2 + subsd %xmm1, %xmm5 + subsd %xmm2, %xmm3 + movsd %xmm3, -48(%rsi) + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + movsd %xmm5, (%rdx) +..___tag_value_csinh.32: + call __libm_sincos_k64@PLT +..___tag_value_csinh.33: +..B2.17: + movsd 80(%rsp), %xmm0 + lea 8+_CONSTANTS(%rip), %rax + movsd 88(%rsp), %xmm4 + movaps %xmm0, %xmm3 + movsd .L_2il0floatpacket.11(%rip), %xmm6 + addsd %xmm4, %xmm3 + mulsd %xmm3, %xmm6 + movaps %xmm3, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm6, %xmm2 + subsd %xmm1, %xmm4 + subsd %xmm3, %xmm2 + movsd (%rax), %xmm5 + subsd %xmm2, %xmm6 + movzwl 62(%rsp), %edx + subsd %xmm6, %xmm3 + addsd %xmm5, %xmm6 + addsd %xmm3, %xmm4 + andl $32752, %edx + movsd %xmm4, 88(%rsp) + cmpl $13168, %edx + movsd %xmm6, 80(%rsp) + jl ..B2.19 +..B2.18: + xorl %r13d, %r13d + lea 24(%rsp), %rdx + movsd (%rdx), %xmm5 + jmp ..B2.20 +..B2.19: + lea 16+_CONSTANTS(%rip), %r13 + lea 24(%rsp), %rdx + movsd 32(%rdx), %xmm0 + pxor %xmm5, %xmm5 + mulsd (%r13), %xmm0 + movsd %xmm0, -8(%rdx) + movzwl -2(%rdx), %eax + movl %eax, %r13d + andl $32752, %r13d + andl $-32753, %eax + shrl $4, %r13d + orl $-49168, %eax + movw %ax, -2(%rdx) + addl $-1279, %r13d +..B2.20: + movsd 16(%rsp), %xmm0 + movaps %xmm5, %xmm4 + movsd .L_2il0floatpacket.11(%rip), %xmm3 + lea 32(%rsp), %rsi + movl %r14d, %edi + lea (%rsp), %rcx + addsd %xmm0, %xmm4 + mulsd %xmm4, %xmm3 + movaps %xmm4, %xmm1 + subsd %xmm0, %xmm1 + movaps %xmm3, %xmm2 + subsd %xmm1, %xmm5 + subsd %xmm4, %xmm2 + subsd %xmm2, %xmm3 + movsd %xmm3, 16(%rcx) + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + movsd %xmm5, (%rdx) + lea 80(%rsp), %rdx +..___tag_value_csinh.34: + call __libm_mul_k64@PLT +..___tag_value_csinh.35: +..B2.21: + addl %r15d, %r13d + lea 64(%rsp), %rsi + movl %r13d, %edi + lea 16(%rsp), %rdx + lea 8(%rsp), %rcx +..___tag_value_csinh.36: + call __libm_mul_k64@PLT +..___tag_value_csinh.37: +..B2.22: + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.37 +..B2.23: + movzwl 62(%rsp), %r13d + andl $32752, %r13d + shrl $4, %r13d +..B2.24: + testl %r13d, %r13d + jne ..B2.28 +..B2.25: + testl $1048575, 60(%rsp) + jne ..B2.28 +..B2.26: + cmpl $0, 56(%rsp) + jne ..B2.28 +..B2.27: + movsd 48(%rsp), %xmm0 + call sinh@PLT +..B2.55: + movhpd 56(%rsp), %xmm0 + movsd %xmm0, (%rsp) + movhpd %xmm0, 8(%rsp) + jmp ..B2.37 +..B2.28: + cmpl $2047, %r13d + jge ..B2.31 +..B2.29: + movsd 48(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) + call sinh@PLT +..B2.57: + movsd %xmm0, 40(%rsp) + movsd 56(%rsp), %xmm0 + movsd %xmm0, 16(%rsp) + call __libm_sse2_sincos@PLT +..B2.56: + movsd %xmm0, 24(%rsp) + testl %r13d, %r13d + movsd 40(%rsp), %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, (%rsp) + jle ..B2.45 +..B2.30: + movsd 32(%rsp), %xmm0 + call cosh@PLT +..B2.58: + mulsd 24(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.37 +..B2.31: + movsd 56(%rsp), %xmm0 + call sin@PLT +..B2.59: + movsd %xmm0, 8(%rsp) + cmpl $2047, %r14d + je ..B2.35 +..B2.32: + testl %r14d, %r14d + jne ..B2.36 +..B2.33: + testl $1048575, 52(%rsp) + jne ..B2.36 +..B2.34: + cmpl $0, 48(%rsp) + jne ..B2.36 +..B2.35: + movsd 48(%rsp), %xmm0 + call sinh@PLT +..B2.60: + movsd %xmm0, (%rsp) + movhpd 8(%rsp), %xmm0 + jmp ..B2.37 +..B2.36: + movsd 48(%rsp), %xmm2 + mulsd %xmm0, %xmm2 + movaps %xmm2, %xmm0 + movhpd 8(%rsp), %xmm0 + movsd %xmm2, (%rsp) +..B2.37: + movq 96(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.39 +..B2.38: + movaps %xmm0, %xmm1 + unpckhpd %xmm0, %xmm1 + addq $112, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B2.39: + call __stack_chk_fail@PLT +..B2.40: + testl $1048575, 60(%rsp) + jne ..B2.5 +..B2.41: + cmpl $0, 56(%rsp) + jne ..B2.5 + jmp ..B2.24 +..B2.42: + testl $1048575, 52(%rsp) + jne ..B2.3 +..B2.43: + cmpl $0, 48(%rsp) + jne ..B2.3 + jmp ..B2.23 +..B2.45: + testl %r14d, %r14d + jne ..B2.48 +..B2.46: + testl $1048575, 52(%rsp) + jne ..B2.48 +..B2.47: + cmpl $0, 48(%rsp) + je ..B2.30 +..B2.48: + movsd 32(%rsp), %xmm0 + call cosh@PLT +..B2.61: + mulsd 16(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + movsd (%rsp), %xmm0 + movhpd 8(%rsp), %xmm0 + jmp ..B2.37 + .align 16,0x90 + .cfi_endproc + .type csinh,@function + .size csinh,.-csinh + .data +# -- End csinh + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.11: + .long 0x02000000,0x41a00000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 4 +.L_2il0floatpacket.10: + .long 0x00800000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .align 4 +_CONSTANTS: + .long 0 + .long 2145386496 + .long 0 + .long 1048576 + .long 0 + .long 1341128704 + .type _CONSTANTS,@object + .size _CONSTANTS,24 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/csinhl.S b/external/sgx_libm/intel64/csinhl.S new file mode 100644 index 0000000000..0dd65ade4a --- /dev/null +++ b/external/sgx_libm/intel64/csinhl.S @@ -0,0 +1,694 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csinhl.c" + .text +..TXTST0: +# -- Begin csinhl + .text + .align 16,0x90 + .globl csinhl +csinhl: +# parameter 1: 336 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_csinhl.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + subq $296, %rsp + .cfi_def_cfa_offset 336 + xorb %r15b, %r15b + fldt .L_2il0floatpacket.6(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 288(%rsp) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 256(%rsp) + fldt 256(%rsp) + fstpt 272(%rsp) +..B1.2: + fnstcw 114(%rsp) +..B1.3: + movzwl 114(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 112(%rsp) +..B1.5: + fldcw 112(%rsp) +..B1.6: + movb $1, %r15b +..B1.7: + movzwl 344(%rsp), %r13d + andl $32767, %r13d + cmpl $32767, %r13d + jge ..B1.33 +..B1.8: + testl %r13d, %r13d + jle ..B1.51 +..B1.9: + movzwl 360(%rsp), %ebx + andl $32767, %ebx + cmpl $32767, %ebx + jge ..B1.33 +..B1.10: + testl %ebx, %ebx + jle ..B1.49 +..B1.11: + cmpl $16398, %r13d + jl ..B1.20 +..B1.12: + fldt 336(%rsp) + lea _CONSTANTS(%rip), %rax + fldt 352(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fldt (%rax) + fmul %st(0), %st + fmul %st, %st(2) + fxch %st(2) + fstpt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstpt (%rsp) + fstpt 48(%rsp) + call cosl@PLT +..B1.59: + fldt 48(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt (%rsp) + testl %ebx, %ebx + fmulp %st, %st(2) + fxch %st(1) + fstpt 256(%rsp) + jle ..B1.14 +..B1.13: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 48(%rsp) + call sinl@PLT +..B1.60: + fldt 48(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 + fmulp %st, %st(1) + jmp ..B1.15 +..B1.14: + fldt 16(%rsp) + fmulp %st, %st(1) +..B1.15: + fstpt 272(%rsp) + testb %r15b, %r15b + je ..B1.17 +..B1.16: + fldcw 114(%rsp) +..B1.17: + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.48 +..B1.18: + fldt 256(%rsp) + fldt 272(%rsp) + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.47 +..B1.19: + addq $296, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.20: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + lea 176(%rsp), %rdi + fstpt (%rsp) +..___tag_value_csinhl.31: + call __libm_coshl_k80@PLT +..___tag_value_csinhl.32: +..B1.61: + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.21: + fldt 176(%rsp) + lea 48+_CONSTANTS(%rip), %r14 + fldt .L_2il0floatpacket.7(%rip) + movzwl 344(%rsp), %eax + andl $32767, %eax + fldt (%r14) + cmpl $16183, %eax + fadd %st, %st(3) + fxch %st(3) + fstpt (%rsp) + fldt 160(%rsp) + fld %st(0) + movl (%rsp), %r14d + fadd %st(3), %st + fmul %st, %st(2) + fld %st(0) + fsubr %st(3), %st + fsubrp %st, %st(3) + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(1) + fsubr %st(2), %st + fsubrp %st, %st(3) + fsubrp %st, %st(1) + faddp %st, %st(1) + jge ..B1.23 +..B1.22: + fstp %st(1) + fldt 336(%rsp) + lea 32+_CONSTANTS(%rip), %r13 + fldt 96(%rsp) + lea 208(%rsp), %rdx + fstpt (%rdx) + fldt (%r13) + fmulp %st, %st(1) + fstpt -16(%rdx) + movzwl -8(%rdx), %eax + movl %eax, %r13d + andl $-32768, %eax + andl $32767, %r13d + orl $-49153, %eax + addl $-16639, %r13d + movw %ax, -8(%rdx) + jmp ..B1.25 +..B1.23: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + lea 208(%rsp), %rdi + fstpt (%rsp) + fxch %st(1) + fstpt 16(%rsp) + fstpt 64(%rsp) +..___tag_value_csinhl.35: + call __libm_sinhl_k80@PLT +..___tag_value_csinhl.36: +..B1.62: + fldt 64(%rsp) + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.24: + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + lea 208(%rsp), %rdx + movl (%rsp), %r13d +..B1.25: + fldt 192(%rsp) + fld %st(0) + fldt (%rdx) + fadd %st, %st(1) + fld %st(1) + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.7(%rip) + fmul %st(3), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt 368(%rsp) + fstpt (%rsp) + lea 240(%rsp), %rdi + fstpt 96(%rsp) + fstpt 64(%rsp) +..___tag_value_csinhl.39: + call __libm_cosl_k80@PLT +..___tag_value_csinhl.40: +..B1.63: + fldt 64(%rsp) + fldt 96(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.26: + fldt 224(%rsp) + lea 16+_CONSTANTS(%rip), %rax + fld %st(0) + fldt 240(%rsp) + movzwl 360(%rsp), %edx + fadd %st, %st(1) + fld %st(1) + andl $32767, %edx + cmpl $16183, %edx + fxch %st(2) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(1) + fldt .L_2il0floatpacket.7(%rip) + fmul %st(3), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmul %st(4), %st + fxch %st(1) + fmulp %st, %st(4) + fldt (%rax) + faddp %st, %st(1) + jge ..B1.28 +..B1.27: + fldt 352(%rsp) + lea 32+_CONSTANTS(%rip), %rbx + fldt 96(%rsp) + fstpt 144(%rsp) + fldt (%rbx) + fmulp %st, %st(1) + fstpt 128(%rsp) + movzwl 136(%rsp), %eax + movl %eax, %ebx + andl $-32768, %eax + andl $32767, %ebx + orl $-49153, %eax + addl $-16639, %ebx + movw %ax, 136(%rsp) + fldt 128(%rsp) + jmp ..B1.30 +..B1.28: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 368(%rsp) + lea 144(%rsp), %rdi + fstpt (%rsp) + fxch %st(3) + fstpt 16(%rsp) + fstpt -48(%rdi) + fxch %st(1) + fstpt -112(%rdi) + fstpt -80(%rdi) +..___tag_value_csinhl.43: + call __libm_sinl_k80@PLT +..___tag_value_csinhl.44: +..B1.64: + fldt 64(%rsp) + fldt 32(%rsp) + fldt 96(%rsp) + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B1.29: + fldt 128(%rsp) + xorl %ebx, %ebx + fmul %st(5), %st + fstpt 128(%rsp) + fldt 128(%rsp) + fldt 144(%rsp) + fmulp %st, %st(6) + fxch %st(5) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 144(%rsp) + fxch %st(4) + fxch %st(2) + fxch %st(1) + fxch %st(2) +..B1.30: + fldt 96(%rsp) + fld %st(1) + movl %r13d, %edi + fadd %st(1), %st + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.7(%rip) + fmul %st(3), %st + fsub %st, %st(1) + fsubp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(5), %st + fldt 64(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + fld %st(0) + fmul %st(4), %st + fstpt (%rsp) + fmulp %st, %st(6) + faddp %st, %st(5) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + fstpt 16(%rsp) + fxch %st(1) + fstpt 48(%rsp) + fstpt 80(%rsp) +..___tag_value_csinhl.47: + call __libm_scalbl_k80@PLT +..___tag_value_csinhl.48: +..B1.65: + fldt 80(%rsp) + fldt 48(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B1.31: + fldt (%rsp) + fld %st(2) + fmul %st(2), %st + addl %ebx, %r14d + fxch %st(4) + fstpt 256(%rsp) + movl %r14d, %edi + fldt 32(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + fld %st(0) + fmul %st(2), %st + fstpt (%rsp) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsp) +..___tag_value_csinhl.51: + call __libm_scalbl_k80@PLT +..___tag_value_csinhl.52: +..B1.66: + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B1.32: + fstpt 272(%rsp) + jmp ..B1.42 +..B1.33: + cmpq $0, 352(%rsp) + jne ..B1.35 +..B1.34: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + fstpt (%rsp) + call sinhl@PLT +..B1.67: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt 352(%rsp) + fstpt 272(%rsp) + fstpt 256(%rsp) + jmp ..B1.42 +..B1.35: + movzwl 360(%rsp), %ebx + andl $32767, %ebx + cmpl $32767, %ebx + jge ..B1.38 +..B1.36: + fldt 336(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstpt (%rsp) + call sinhl@PLT +..B1.69: + fstpt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt 352(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstpt (%rsp) + call cosl@PLT +..B1.68: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt (%rsp) + testl %ebx, %ebx + fmulp %st, %st(1) + fstpt 256(%rsp) + jle ..B1.53 +..B1.37: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 48(%rsp) + fstpt (%rsp) + call coshl@PLT +..B1.71: + fstpt 16(%rsp) + fldt 32(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.70: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt (%rsp) + fmulp %st, %st(1) + fstpt 272(%rsp) + jmp ..B1.42 +..B1.38: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 368(%rsp) + fstpt (%rsp) + call sinl@PLT +..B1.72: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fstpt 272(%rsp) + fldt 272(%rsp) + cmpl $32767, %r13d + je ..B1.40 +..B1.39: + cmpq $0, 336(%rsp) + jne ..B1.41 +..B1.40: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 352(%rsp) + fstpt (%rsp) + call sinhl@PLT +..B1.73: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fstpt 256(%rsp) + jmp ..B1.42 +..B1.41: + fldt 336(%rsp) + fmulp %st, %st(1) + fstpt 256(%rsp) +..B1.42: + testb %r15b, %r15b + je ..B1.44 +..B1.43: + fldcw 114(%rsp) +..B1.44: + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.48 +..B1.45: + fldt 256(%rsp) + fldt 272(%rsp) + movq 288(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.47 +..B1.46: + addq $296, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.47: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.48: + call __stack_chk_fail@PLT +..B1.49: + cmpl $0, 356(%rsp) + jne ..B1.11 +..B1.50: + cmpl $0, 352(%rsp) + jne ..B1.11 + jmp ..B1.33 +..B1.51: + cmpl $0, 340(%rsp) + jne ..B1.9 +..B1.52: + cmpl $0, 336(%rsp) + jne ..B1.9 + jmp ..B1.33 +..B1.53: + cmpq $0, 336(%rsp) + je ..B1.37 +..B1.54: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fldt 48(%rsp) + fstpt (%rsp) + call coshl@PLT +..B1.74: + addq $16, %rsp + .cfi_def_cfa_offset 336 + fldt 16(%rsp) + fmulp %st, %st(1) + fstpt 272(%rsp) + jmp ..B1.42 + .align 16,0x90 + .cfi_endproc + .type csinhl,@function + .size csinhl,.-csinhl + .data +# -- End csinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,64 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/csinl.S b/external/sgx_libm/intel64/csinl.S new file mode 100644 index 0000000000..0df60bdf60 --- /dev/null +++ b/external/sgx_libm/intel64/csinl.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csinl.c" + .text +..TXTST0: +# -- Begin csinl + .text + .align 16,0x90 + .globl csinl +csinl: +# parameter 1: 144 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_csinl.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + subq $128, %rsp + .cfi_def_cfa_offset 144 + xorb %r13b, %r13b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 112(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 96(%rsp) +..B1.2: + fnstcw 2(%rsp) +..B1.3: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.5: + fldcw (%rsp) +..B1.6: + movb $1, %r13b +..B1.7: + fldt 160(%rsp) + movzwl 168(%rsp), %eax + andl $32767, %eax + fstpt 80(%rsp) + cmpl $32767, %eax + fldt 144(%rsp) + fstpt 96(%rsp) + jl ..B1.9 +..B1.8: + movq $0x8000000000000000, %rax + cmpq 160(%rsp), %rax + jne ..B1.10 +..B1.9: + movb 169(%rsp), %al + notb %al + movb 89(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 89(%rsp) +..B1.10: + addq $-32, %rsp + .cfi_def_cfa_offset 176 + movq %rsp, %rdi + movq 112(%rsp), %rax + movq 120(%rsp), %rdx + movq 128(%rsp), %rcx + movq 136(%rsp), %rsi + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + movq %rcx, 16(%rdi) + movq %rsi, 24(%rdi) + call csinhl@PLT +..B1.22: + fxch %st(1) + addq $32, %rsp + .cfi_def_cfa_offset 144 + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 24(%rsp), %eax + andl $32767, %eax + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + cmpl $32767, %eax + fstpt 48(%rsp) + fstpt 64(%rsp) + jl ..B1.12 +..B1.11: + movq $0x8000000000000000, %rax + cmpq 16(%rsp), %rax + jne ..B1.13 +..B1.12: + movb 25(%rsp), %al + notb %al + movb 73(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 73(%rsp) +..B1.13: + testb %r13b, %r13b + je ..B1.15 +..B1.14: + fldcw 2(%rsp) +..B1.15: + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.19 +..B1.16: + fldt 48(%rsp) + fldt 64(%rsp) + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.18 +..B1.17: + addq $128, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 144 + .cfi_offset 13, -16 +..B1.18: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.19: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type csinl,@function + .size csinl,.-csinl + .data +# -- End csinl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/csqrt.S b/external/sgx_libm/intel64/csqrt.S new file mode 100644 index 0000000000..f1a247a36f --- /dev/null +++ b/external/sgx_libm/intel64/csqrt.S @@ -0,0 +1,696 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csqrt.c" + .text +..TXTST0: +# -- Begin csqrt + .text + .align 16,0x90 + .globl csqrt +csqrt: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_csqrt.1: +..L2: + +..B1.2: + movq %rsp, %rax + subq $152, %rsp + .cfi_def_cfa_offset 160 + movq %rax, 56(%rsp) + movq %xmm0, 32(%rsp) + movq %xmm1, 40(%rsp) + movq %rbx, 64(%rsp) + movq 32(%rsp), %xmm0 + movq 40(%rsp), %xmm1 + lea csqrt_table(%rip), %r8 + movq (%r8), %xmm2 + movq (%r8), %xmm3 + movq 144(%r8), %xmm7 + pand %xmm0, %xmm2 + pand %xmm1, %xmm3 + pand 16(%r8), %xmm0 + pand 16(%r8), %xmm1 + movq %xmm2, %xmm4 + movq %xmm3, %xmm5 + movl 36(%rsp), %eax + movl 44(%rsp), %ebx + andl $2147483647, %eax + andl $2147483647, %ebx + subl $591396864, %eax + movq %xmm0, 8(%rsp) + subl $591396864, %ebx + cmpl $1017118720, %eax + movq %xmm1, 16(%rsp) + jae .L_2TAG_PACKET_0.0.1 + cmpl $1017118720, %ebx + jae .L_2TAG_PACKET_0.0.1 + addl $591396864, %eax + addl $591396864, %ebx + movl %eax, %edx + subl %ebx, %edx + cmpl $60817408, %edx + jg .L_2TAG_PACKET_1.0.1 + cmpl $-60817408, %edx + jl .L_2TAG_PACKET_2.0.1 +.L_2TAG_PACKET_3.0.1: + subsd %xmm2, %xmm0 + subsd %xmm3, %xmm1 + mulsd %xmm2, %xmm2 + mulsd %xmm3, %xmm3 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm5 + movq %xmm2, %xmm6 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + movq %xmm7, 24(%rsp) + movq %xmm2, %xmm7 + addsd %xmm3, %xmm2 + addsd %xmm4, %xmm0 + subsd %xmm2, %xmm7 + addsd %xmm5, %xmm1 + movq %xmm2, (%rsp) + addsd %xmm7, %xmm2 + addsd %xmm7, %xmm3 + movq (%rsp), %xmm7 + addsd %xmm4, %xmm0 + subsd %xmm2, %xmm6 + addsd %xmm5, %xmm1 + movq (%rsp), %xmm5 + movq %xmm0, %xmm2 + movq %xmm0, %xmm4 + addsd %xmm3, %xmm6 + addsd %xmm1, %xmm0 + subsd %xmm0, %xmm2 + movq %xmm0, %xmm3 + addsd %xmm2, %xmm0 + addsd %xmm2, %xmm1 + pshufd $221, %xmm7, %xmm2 + subsd %xmm0, %xmm4 + movq 32(%r8), %xmm0 + addsd %xmm4, %xmm1 + pand %xmm7, %xmm0 + addsd %xmm3, %xmm7 + addsd %xmm6, %xmm1 + subsd %xmm7, %xmm5 + subsd %xmm0, %xmm7 + movq %xmm0, %xmm4 + addsd %xmm5, %xmm3 + movq %xmm0, %xmm5 + addsd %xmm7, %xmm1 + movq %xmm0, %xmm7 + psrlq $29, %xmm0 + addsd %xmm3, %xmm1 + pand 48(%r8), %xmm0 + movq 152(%r8), %xmm3 + pxor 64(%r8), %xmm0 + addsd %xmm1, %xmm4 + paddd 80(%r8), %xmm0 + psubd 96(%r8), %xmm2 + rsqrtss %xmm0, %xmm0 + pand 112(%r8), %xmm2 + psrld $3, %xmm0 + psrld $1, %xmm2 + paddd 128(%r8), %xmm0 + psubd %xmm2, %xmm0 + psllq $32, %xmm0 + movq %xmm0, %xmm2 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm7 + mulsd %xmm1, %xmm0 + subsd 144(%r8), %xmm7 + addsd %xmm0, %xmm7 + movq 160(%r8), %xmm0 + movq %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm0 + addsd 168(%r8), %xmm3 + addsd 176(%r8), %xmm0 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm0 + addsd 184(%r8), %xmm3 + mulsd %xmm6, %xmm3 + addsd %xmm0, %xmm3 + movq 8(%rsp), %xmm0 + mulsd %xmm2, %xmm3 + mulsd %xmm4, %xmm3 + movq 8(%rsp), %xmm4 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + movq %xmm5, %xmm2 + addsd 8(%rsp), %xmm5 + movq 32(%r8), %xmm7 + addsd %xmm3, %xmm1 + subsd %xmm5, %xmm4 + movq %xmm5, %xmm3 + addsd %xmm4, %xmm5 + addsd %xmm2, %xmm4 + subsd %xmm5, %xmm0 + addsd %xmm0, %xmm4 + movq 208(%r8), %xmm0 + addsd %xmm1, %xmm4 + movq %xmm3, %xmm1 + movq %xmm3, %xmm2 + addsd %xmm4, %xmm3 + subsd %xmm3, %xmm1 + mulsd %xmm3, %xmm0 + pand %xmm0, %xmm7 + addsd %xmm1, %xmm3 + addsd %xmm4, %xmm1 + movq %xmm7, %xmm4 + subsd %xmm2, %xmm3 + movq %xmm7, %xmm5 + pshufd $221, %xmm0, %xmm2 + subsd %xmm7, %xmm0 + subsd %xmm3, %xmm1 + mulsd 208(%r8), %xmm1 + addsd %xmm0, %xmm1 + movq %xmm7, %xmm0 + psrlq $29, %xmm7 + movq 152(%r8), %xmm3 + pand 48(%r8), %xmm7 + psubd 96(%r8), %xmm2 + pxor 64(%r8), %xmm7 + addsd %xmm1, %xmm4 + paddd 80(%r8), %xmm7 + rsqrtss %xmm7, %xmm7 + psrld $3, %xmm7 + pand 112(%r8), %xmm2 + psrld $1, %xmm2 + paddd 128(%r8), %xmm7 + psubd %xmm2, %xmm7 + psllq $32, %xmm7 + movq %xmm7, %xmm2 + mulsd %xmm7, %xmm7 + mulsd %xmm7, %xmm0 + mulsd %xmm1, %xmm7 + subsd 144(%r8), %xmm0 + addsd %xmm7, %xmm0 + movq 160(%r8), %xmm7 + movq %xmm0, %xmm6 + mulsd %xmm0, %xmm0 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm7 + addsd 168(%r8), %xmm3 + addsd 176(%r8), %xmm7 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm7 + addsd 184(%r8), %xmm3 + mulsd %xmm6, %xmm3 + movq 16(%rsp), %xmm6 + addsd %xmm7, %xmm3 + mulsd 208(%r8), %xmm6 + mulsd %xmm2, %xmm3 + mulsd %xmm3, %xmm4 + pxor %xmm7, %xmm7 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + cmpnlesd 32(%rsp), %xmm7 + addsd %xmm4, %xmm1 + movq 32(%r8), %xmm4 + pand %xmm6, %xmm4 + subsd %xmm4, %xmm6 + addsd %xmm5, %xmm1 + movq %xmm2, %xmm5 + mulsd %xmm4, %xmm2 + mulsd %xmm3, %xmm4 + movq %xmm1, %xmm0 + pand %xmm7, %xmm0 + mulsd %xmm6, %xmm3 + mulsd %xmm5, %xmm6 + movq 40(%rsp), %xmm5 + addsd %xmm4, %xmm3 + addsd %xmm3, %xmm6 + addsd %xmm6, %xmm2 + movq %xmm7, %xmm6 + pandn %xmm2, %xmm6 + pand %xmm7, %xmm2 + pandn %xmm1, %xmm7 + pand 192(%r8), %xmm5 + por %xmm0, %xmm6 + por %xmm7, %xmm2 + por %xmm5, %xmm6 + movq 24(%rsp), %xmm0 + movq 24(%rsp), %xmm1 + mulsd %xmm2, %xmm0 + mulsd %xmm6, %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_0.0.1: + addl $591396864, %eax + addl $591396864, %ebx + cmpl $2146435072, %eax + jge .L_2TAG_PACKET_4.0.1 + cmpl $2146435072, %ebx + jge .L_2TAG_PACKET_5.0.1 + movl 32(%rsp), %edx + orl %eax, %edx + movl 40(%rsp), %edx + je .L_2TAG_PACKET_6.0.1 + orl %ebx, %edx + je .L_2TAG_PACKET_7.0.1 + movl %eax, %edx + subl %ebx, %edx + cmpl $60817408, %edx + jg .L_2TAG_PACKET_1.0.1 + cmpl $-60817408, %edx + jl .L_2TAG_PACKET_2.0.1 + cmpl $1072693248, %eax + jl .L_2TAG_PACKET_8.0.1 + mulsd 216(%r8), %xmm0 + mulsd 216(%r8), %xmm1 + movq 224(%r8), %xmm7 + movq 32(%r8), %xmm2 + movq 32(%r8), %xmm3 + pand %xmm0, %xmm2 + pand %xmm1, %xmm3 + movq %xmm2, %xmm4 + movq %xmm3, %xmm5 + movq %xmm0, 8(%rsp) + movq %xmm1, 16(%rsp) + jmp .L_2TAG_PACKET_3.0.1 +.L_2TAG_PACKET_8.0.1: + mulsd 232(%r8), %xmm0 + mulsd 232(%r8), %xmm1 + movq 240(%r8), %xmm7 + movq 32(%r8), %xmm2 + movq 32(%r8), %xmm3 + pand %xmm0, %xmm2 + pand %xmm1, %xmm3 + movq %xmm2, %xmm4 + movq %xmm3, %xmm5 + movq %xmm0, 8(%rsp) + movq %xmm1, 16(%rsp) + jmp .L_2TAG_PACKET_3.0.1 +.L_2TAG_PACKET_2.0.1: +.L_2TAG_PACKET_6.0.1: + cmpl $2097152, %ebx + jl .L_2TAG_PACKET_9.0.1 + mulsd 208(%r8), %xmm1 + sqrtsd %xmm1, %xmm0 + movsd 40(%rsp), %xmm1 + pand 192(%r8), %xmm1 + por %xmm0, %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_9.0.1: + mulsd 248(%r8), %xmm1 + sqrtsd %xmm1, %xmm0 + movsd 40(%rsp), %xmm1 + pand 192(%r8), %xmm1 + mulsd 256(%r8), %xmm0 + por %xmm0, %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_7.0.1: + sqrtsd %xmm0, %xmm0 + movl 36(%rsp), %eax + cmpl $0, %eax + jl .L_2TAG_PACKET_10.0.1 + movsd 40(%rsp), %xmm1 + pand 192(%r8), %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_10.0.1: + movsd 40(%rsp), %xmm1 + pand 192(%r8), %xmm1 + por %xmm0, %xmm1 + pxor %xmm0, %xmm0 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_1.0.1: + cmpl $57671680, %ebx + movsd %xmm0, %xmm4 + subsd %xmm2, %xmm0 + movq %xmm2, %xmm5 + movq %xmm2, %xmm7 + pshufd $221, %xmm2, %xmm1 + jl .L_2TAG_PACKET_11.0.1 + mulsd 288(%r8), %xmm2 + mulsd 288(%r8), %xmm0 + mulsd 288(%r8), %xmm4 + movsd %xmm2, %xmm5 + movsd %xmm2, %xmm7 + pshufd $221, %xmm2, %xmm1 + shrl $21, %eax + shrl $20, %ebx + psrlq $29, %xmm2 + pand 48(%r8), %xmm2 + pxor 64(%r8), %xmm2 + paddd 80(%r8), %xmm2 + rsqrtss %xmm2, %xmm2 + subl $511, %eax + subl $1023, %ebx + psubd 96(%r8), %xmm1 + psrld $3, %xmm2 + pand 112(%r8), %xmm1 + psrld $1, %xmm1 + paddd 128(%r8), %xmm2 + psubd %xmm1, %xmm2 + subl %eax, %ebx + psllq $32, %xmm2 + movq %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + mulsd %xmm2, %xmm7 + mulsd %xmm0, %xmm2 + subsd 144(%r8), %xmm7 + cmpl $-1020, %ebx + addsd %xmm2, %xmm7 + movq %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + movq 152(%r8), %xmm3 + movq 160(%r8), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 168(%r8), %xmm3 + addsd 176(%r8), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 184(%r8), %xmm3 + mulsd %xmm6, %xmm3 + addsd %xmm2, %xmm3 + mulsd %xmm1, %xmm3 + mulsd %xmm3, %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + addsd %xmm4, %xmm0 + mulsd 304(%r8), %xmm5 + mulsd 304(%r8), %xmm0 + mulsd 296(%r8), %xmm1 + mulsd 296(%r8), %xmm3 + jl .L_2TAG_PACKET_12.0.1 + movsd 16(%rsp), %xmm2 + addsd %xmm5, %xmm0 + mulsd 208(%r8), %xmm1 + mulsd 208(%r8), %xmm3 + movq 32(%r8), %xmm4 + pand %xmm2, %xmm4 + subsd %xmm4, %xmm2 + movq %xmm1, %xmm5 + mulsd %xmm4, %xmm1 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm3 + mulsd %xmm5, %xmm2 + addsd %xmm4, %xmm3 + addsd %xmm3, %xmm2 + addsd %xmm2, %xmm1 +.L_2TAG_PACKET_13.0.1: + movsd 40(%rsp), %xmm3 + pand 192(%r8), %xmm3 + movl 36(%rsp), %eax + cmpl $0, %eax + jl .L_2TAG_PACKET_14.0.1 + por %xmm3, %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_14.0.1: + por %xmm0, %xmm3 + movq %xmm1, %xmm0 + movq %xmm3, %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_11.0.1: + psrlq $29, %xmm2 + pand 48(%r8), %xmm2 + pxor 64(%r8), %xmm2 + paddd 80(%r8), %xmm2 + rsqrtss %xmm2, %xmm2 + psubd 96(%r8), %xmm1 + psrld $3, %xmm2 + pand 112(%r8), %xmm1 + psrld $1, %xmm1 + paddd 128(%r8), %xmm2 + psubd %xmm1, %xmm2 + psllq $32, %xmm2 + movq %xmm2, %xmm1 + mulsd %xmm2, %xmm2 + mulsd %xmm2, %xmm7 + mulsd %xmm0, %xmm2 + subsd 144(%r8), %xmm7 + addsd %xmm2, %xmm7 + movq %xmm7, %xmm6 + mulsd %xmm7, %xmm7 + movq 152(%r8), %xmm3 + movq 160(%r8), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 168(%r8), %xmm3 + addsd 176(%r8), %xmm2 + mulsd %xmm7, %xmm3 + mulsd %xmm7, %xmm2 + addsd 184(%r8), %xmm3 + mulsd %xmm6, %xmm3 + addsd %xmm2, %xmm3 + mulsd %xmm1, %xmm3 + mulsd %xmm3, %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + addsd %xmm4, %xmm0 +.L_2TAG_PACKET_12.0.1: + addsd %xmm5, %xmm0 + movq 16(%rsp), %xmm2 + mulsd 264(%r8), %xmm2 + mulsd 248(%r8), %xmm2 + movq 32(%r8), %xmm4 + pand %xmm2, %xmm4 + subsd %xmm4, %xmm2 + movq %xmm1, %xmm5 + mulsd %xmm4, %xmm1 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm3 + mulsd %xmm5, %xmm2 + addsd %xmm4, %xmm3 + addsd %xmm3, %xmm2 + movq %xmm1, %xmm3 + addsd %xmm2, %xmm1 + pextrw $3, %xmm1, %eax + mulsd 272(%r8), %xmm1 + mulsd 280(%r8), %xmm1 + cmpl $19216, %eax + jge .L_2TAG_PACKET_13.0.1 + movq 272(%r8), %xmm5 + mulsd %xmm5, %xmm5 + cmpl $19056, %eax + jle .L_2TAG_PACKET_13.0.1 + movq 32(%r8), %xmm1 + pand %xmm3, %xmm1 + subsd %xmm1, %xmm3 + addsd %xmm3, %xmm2 + mulsd 272(%r8), %xmm1 + mulsd 272(%r8), %xmm2 + mulsd 280(%r8), %xmm1 + mulsd 280(%r8), %xmm2 + addsd %xmm2, %xmm1 + jmp .L_2TAG_PACKET_13.0.1 +.L_2TAG_PACKET_5.0.1: +.L_2TAG_PACKET_15.0.1: + movq 144(%r8), %xmm0 + addsd 40(%rsp), %xmm0 + movq %xmm0, %xmm1 + mulsd %xmm0, %xmm0 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_4.0.1: + movsd 32(%rsp), %xmm1 + mulsd %xmm1, %xmm1 + cmpl $2146435072, %ebx + jl .L_2TAG_PACKET_16.0.1 + movl 40(%rsp), %ebx + jg .L_2TAG_PACKET_17.0.1 + andl %ebx, %ebx + jne .L_2TAG_PACKET_17.0.1 + jmp .L_2TAG_PACKET_15.0.1 +.L_2TAG_PACKET_17.0.1: + movq 144(%r8), %xmm0 + addsd 40(%rsp), %xmm0 + cmpl $2146435072, %eax + movl 32(%rsp), %ebx + jg .L_2TAG_PACKET_18.0.1 + andl %ebx, %ebx + movl 36(%rsp), %ebx + jne .L_2TAG_PACKET_18.0.1 + cmpl $2146435072, %ebx + je .L_2TAG_PACKET_19.0.1 + mulsd %xmm1, %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_18.0.1: +.L_2TAG_PACKET_19.0.1: + movq 32(%rsp), %xmm0 + movq 40(%rsp), %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_16.0.1: + cmpl $2146435072, %eax + movl 32(%rsp), %eax + jg .L_2TAG_PACKET_20.0.1 + andl %eax, %eax + jne .L_2TAG_PACKET_20.0.1 + pxor %xmm2, %xmm2 + movl 36(%rsp), %eax + movq 40(%rsp), %xmm3 + testl $-2147483648, %eax + pand 192(%r8), %xmm3 + jne .L_2TAG_PACKET_21.0.1 + por %xmm3, %xmm2 + movq %xmm1, %xmm0 + movq %xmm2, %xmm1 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_21.0.1: + por %xmm3, %xmm1 + movq %xmm2, %xmm0 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret +.L_2TAG_PACKET_20.0.1: + movq %xmm1, %xmm0 + movq 64(%rsp), %rbx + movq 56(%rsp), %rsp + ret + .cfi_def_cfa_offset 8 +..B1.3: + .align 16,0x90 + .cfi_endproc + .type csqrt,@function + .size csqrt,.-csqrt + .data +# -- End csqrt + .section .rodata, "a" + .align 16 + .align 16 +csqrt_table: + .long 4160749568 + .long 2147483647 + .long 4160749568 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4160749568 + .long 4294967295 + .long 4160749568 + .long 4294967295 + .long 16777215 + .long 16777215 + .long 16777215 + .long 16777215 + .long 8388608 + .long 8388608 + .long 8388608 + .long 8388608 + .long 1065353216 + .long 1065353216 + .long 1065353216 + .long 1065353216 + .long 1048576 + .long 1048576 + .long 1048576 + .long 1048576 + .long 4292870144 + .long 4292870144 + .long 4292870144 + .long 4292870144 + .long 1475346432 + .long 1475346432 + .long 1475346432 + .long 1475346432 + .long 0 + .long 1072693248 + .long 0 + .long 3218046976 + .long 0 + .long 1070694400 + .long 0 + .long 3218341888 + .long 0 + .long 1071120384 + .long 0 + .long 3219128320 + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .long 0 + .long 1071644672 + .long 0 + .long 533725184 + .long 0 + .long 1342177280 + .long 0 + .long 1722810368 + .long 0 + .long 747634688 + .long 0 + .long 1281359872 + .long 0 + .long 967835648 + .long 0 + .long 2121269248 + .long 0 + .long 24117248 + .long 0 + .long 862978048 + .long 0 + .long 1062207488 + .long 0 + .long 1067450368 + .long 0 + .long 1077936128 + .type csqrt_table,@object + .size csqrt_table,312 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/csqrtf.S b/external/sgx_libm/intel64/csqrtf.S new file mode 100644 index 0000000000..150d2044d7 --- /dev/null +++ b/external/sgx_libm/intel64/csqrtf.S @@ -0,0 +1,386 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csqrtf.c" + .text +..TXTST0: +# -- Begin csqrtf + .text + .align 16,0x90 + .globl csqrtf +csqrtf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_csqrtf.1: +..L2: + +..B1.2: + movq %rsp, %rax + subq $120, %rsp + .cfi_def_cfa_offset 128 + movq %rax, 24(%rsp) + movss %xmm0, (%rsp) + pshufd $1, %xmm0, %xmm1 + movss %xmm1, 8(%rsp) + movq %rbx, 32(%rsp) + movd (%rsp), %xmm0 + movd 8(%rsp), %xmm1 + movl (%rsp), %eax + movl 8(%rsp), %ecx + unpcklps %xmm1, %xmm0 + movl %ecx, %edx + lea csqrtf_table(%rip), %r8 + andl $2139095040, %eax + andl $2139095040, %ecx + subl $8388608, %eax + subl $8388608, %ecx + andl $2139095040, %eax + andl $2139095040, %ecx + subl $2130706432, %eax + subl $2130706432, %ecx + testl %ecx, %eax + jns .L_2TAG_PACKET_0.0.1 + cvtps2pd %xmm0, %xmm0 + pxor %xmm4, %xmm4 + movl $16, %eax + movapd %xmm0, %xmm1 + unpckhpd %xmm1, %xmm1 + movapd %xmm0, %xmm7 + mulsd %xmm0, %xmm0 + movapd %xmm7, %xmm6 + mulsd %xmm1, %xmm1 + pinsrw $3, %eax, %xmm4 + addsd %xmm1, %xmm0 + andpd (%r8), %xmm7 + sqrtsd %xmm0, %xmm0 + addsd %xmm7, %xmm0 + psubd %xmm4, %xmm0 + movsd %xmm0, %xmm7 + movdqa %xmm0, %xmm1 + pand 16(%r8), %xmm0 + movdqa %xmm1, %xmm2 + paddd 32(%r8), %xmm0 + psrld $1, %xmm1 + psrlq $29, %xmm0 + pand 48(%r8), %xmm1 + rsqrtss %xmm0, %xmm0 + psubd 64(%r8), %xmm1 + psllq $29, %xmm0 + movapd 80(%r8), %xmm3 + psubd %xmm1, %xmm0 + movapd 96(%r8), %xmm1 + mulsd %xmm0, %xmm2 + movapd 48(%r8), %xmm4 + mulsd %xmm0, %xmm2 + subsd %xmm4, %xmm2 + mulsd %xmm2, %xmm3 + addsd %xmm1, %xmm3 + mulsd %xmm2, %xmm3 + mulsd %xmm0, %xmm3 + addsd %xmm3, %xmm0 + mulpd 112(%r8), %xmm7 + unpcklpd %xmm0, %xmm0 +.L_2TAG_PACKET_1.0.1: + pextrw $3, %xmm6, %eax + mulpd %xmm7, %xmm0 + andl $-2147483648, %edx + cvtpd2ps %xmm0, %xmm1 + testl $32768, %eax + pshufd $17, %xmm1, %xmm2 + je .L_2TAG_PACKET_2.0.1 + movd %xmm1, %ecx + movd %xmm2, %eax + orl %ecx, %edx + testl $2139095040, %eax + jmp .L_2TAG_PACKET_3.0.1 +.L_2TAG_PACKET_2.0.1: + movd %xmm2, %ecx + movd %xmm1, %eax + orl %ecx, %edx + testl $2139095040, %ecx +.L_2TAG_PACKET_3.0.1: + je .L_2TAG_PACKET_4.0.1 + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_4.0.1: + testl $2147483647, 8(%rsp) + jne .L_2TAG_PACKET_5.0.1 + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_5.0.1: + pshufd $14, %xmm0, %xmm0 + mulsd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm0 + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_0.0.1: + movdqa %xmm0, %xmm2 + movdqa 128(%r8), %xmm4 + pshufd $80, %xmm0, %xmm0 + pxor %xmm5, %xmm5 + movdqa %xmm2, %xmm3 + pand 144(%r8), %xmm0 + pshufd $115, %xmm2, %xmm2 + pcmpeqd %xmm4, %xmm0 + movdqa %xmm2, %xmm6 + movmskps %xmm0, %eax + pand %xmm2, %xmm4 + testl %eax, %eax + jne .L_2TAG_PACKET_6.0.1 + pxor %xmm0, %xmm0 +.L_2TAG_PACKET_7.0.1: + pand (%r8), %xmm2 + pcmpeqd %xmm5, %xmm4 + movdqa %xmm4, %xmm3 + pand 160(%r8), %xmm4 + psrlq $3, %xmm2 + pand 176(%r8), %xmm3 + por %xmm4, %xmm2 + paddd 192(%r8), %xmm3 + subpd %xmm4, %xmm2 + paddd %xmm3, %xmm2 + pandn %xmm2, %xmm0 + pxor %xmm4, %xmm4 + movl $16, %eax + movapd %xmm0, %xmm1 + unpckhpd %xmm1, %xmm1 + movapd %xmm0, %xmm7 + mulsd %xmm0, %xmm0 + mulsd %xmm1, %xmm1 + pinsrw $3, %eax, %xmm4 + addsd %xmm1, %xmm0 + sqrtsd %xmm0, %xmm0 + addsd %xmm7, %xmm0 + psubd %xmm4, %xmm0 + movsd %xmm0, %xmm7 + sqrtsd %xmm0, %xmm1 + movapd 48(%r8), %xmm0 + divsd %xmm1, %xmm0 + mulpd 112(%r8), %xmm7 + unpcklpd %xmm0, %xmm0 + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_6.0.1: + cmpl $5, %eax + je .L_2TAG_PACKET_8.0.1 + testl $10, %eax + jne .L_2TAG_PACKET_9.0.1 + pshufd $160, %xmm0, %xmm0 + jmp .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_8.0.1: + xorl %eax, %eax + andl $-2147483648, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_9.0.1: + movl %edx, %ecx + andl $2147483647, %ecx + movd %xmm3, %eax + cmpl $2139095040, %ecx + je .L_2TAG_PACKET_10.0.1 + ja .L_2TAG_PACKET_11.0.1 + andl $-2147483648, %edx + cmpl $-8388608, %eax + je .L_2TAG_PACKET_12.0.1 + cmpl $2139095040, %eax + jne .L_2TAG_PACKET_13.0.1 + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_12.0.1: + xorl %eax, %eax + orl $2139095040, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_11.0.1: + cmpl $2139095040, %eax + je .L_2TAG_PACKET_14.0.1 + cmpl $-8388608, %eax + je .L_2TAG_PACKET_15.0.1 +.L_2TAG_PACKET_13.0.1: + mulss %xmm3, %xmm1 + movss (%rsp), %xmm0 + mulss 8(%rsp), %xmm0 + movd %xmm1, %eax + movl %eax, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_14.0.1: + movss 8(%rsp), %xmm0 + mulss %xmm0, %xmm0 + orl $4194304, %edx + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_15.0.1: + movss 8(%rsp), %xmm0 + mulss %xmm0, %xmm0 + movl %edx, %eax + movl $2139095040, %edx + orl $4194304, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret +.L_2TAG_PACKET_10.0.1: + movss (%rsp), %xmm0 + mulss 208(%r8), %xmm0 + movl $2139095040, %eax + shlq $32, %rdx + orq %rdx, %rax + shrq $32, %rdx + movd %rax, %xmm0 + movq 32(%rsp), %rbx + movq 24(%rsp), %rsp + ret + .cfi_def_cfa_offset 8 +..B1.3: + .align 16,0x90 + .cfi_endproc + .type csqrtf,@function + .size csqrtf,.-csqrtf + .data +# -- End csqrtf + .section .rodata, "a" + .align 16 + .align 16 +csqrtf_table: + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2097151 + .long 4294967295 + .long 2097151 + .long 0 + .long 132120576 + .long 0 + .long 132120576 + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .long 0 + .long 1475346432 + .long 0 + .long 1475346432 + .long 2148429837 + .long 1071120401 + .long 2148429837 + .long 1071120401 + .long 195330 + .long 3219128325 + .long 195330 + .long 3219128325 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 0 + .long 2139095040 + .long 0 + .long 2139095040 + .long 2147483647 + .long 2139095040 + .long 2147483647 + .long 2139095040 + .long 0 + .long 133169152 + .long 0 + .long 133169152 + .long 0 + .long 4162846720 + .long 0 + .long 4162846720 + .long 0 + .long 939524096 + .long 0 + .long 939524096 + .long 1065353216 + .long 1065353216 + .long 1065353216 + .long 1065353216 + .type csqrtf_table,@object + .size csqrtf_table,224 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/csqrtl.S b/external/sgx_libm/intel64/csqrtl.S new file mode 100644 index 0000000000..1f9e0675d8 --- /dev/null +++ b/external/sgx_libm/intel64/csqrtl.S @@ -0,0 +1,714 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "csqrtl.c" + .text +..TXTST0: +# -- Begin csqrtl + .text + .align 16,0x90 + .globl csqrtl +csqrtl: +# parameter 1: 288 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_csqrtl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + pushq %rbp + .cfi_def_cfa_offset 32 + .cfi_offset 6, -32 + subq $256, %rsp + .cfi_def_cfa_offset 288 + xorb %r12b, %r12b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 240(%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 208(%rsp) + fldt 208(%rsp) + fstpt 224(%rsp) +..B1.2: + fnstcw 66(%rsp) +..B1.3: + movzwl 66(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 64(%rsp) +..B1.5: + fldcw 64(%rsp) +..B1.6: + movb $1, %r12b +..B1.7: + movzwl 296(%rsp), %eax + movl %eax, %ebp + andl $32767, %ebp + cmpl $32767, %ebp + jge ..B1.30 +..B1.8: + cmpl $0, 292(%rsp) + jne ..B1.10 +..B1.9: + cmpl $0, 288(%rsp) + je ..B1.30 +..B1.10: + movzwl 312(%rsp), %edx + movl %edx, %ebx + andl $32767, %ebx + cmpl $32767, %ebx + jge ..B1.46 +..B1.11: + cmpl $0, 308(%rsp) + jne ..B1.13 +..B1.12: + cmpl $0, 304(%rsp) + je ..B1.32 +..B1.13: + fldt 288(%rsp) + testl %ebp, %ebp + jle ..B1.55 +..B1.14: + andl $-32768, %eax + addl $-16383, %ebp + fstpt 176(%rsp) + fldt 176(%rsp) + orl $-49153, %eax + movw %ax, 184(%rsp) +..B1.15: + fldt 304(%rsp) + testl %ebx, %ebx + movb $63, 185(%rsp) + jle ..B1.54 +..B1.16: + andl $-32768, %edx + addl $-16383, %ebx + fstpt 80(%rsp) + fldt 80(%rsp) + orl $-49153, %edx + movw %dx, 88(%rsp) +..B1.17: + fldt 48(%rsp) + movb $63, 89(%rsp) + fstpt 96(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 320 + lea 144(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_csqrtl.11: + call __libm_hypot2l_k80@PLT +..___tag_value_csqrtl.12: +..B1.69: + addq $32, %rsp + .cfi_def_cfa_offset 288 +..B1.18: + fldt 128(%rsp) + lea 32+_CONSTANTS(%rip), %rax + lea t32(%rip), %rdx + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fldt 112(%rsp) + fld %st(0) + fsqrt + fldt (%rdx) + fstpt (%rsp) + fldt (%rsp) + fmul %st(1), %st + fld %st(0) + movl 16(%rsp), %esi + fsubr %st(2), %st + sarl $1, %esi + faddp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fld %st(2) + fxch %st(2) + fsubrp %st, %st(4) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt .L_2il0floatpacket.9(%rip) + fmulp %st, %st(2) + fdivr %st, %st(1) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 144(%rsp) + fldt 144(%rsp) + fsubr %st, %st(1) + movzwl 152(%rsp), %eax + fxch %st(1) + faddp %st, %st(2) + andl $32767, %eax + fxch %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + lea -16464(%rax,%rsi), %ecx + cmpl %ecx, %ebp + jle ..B1.22 +..B1.19: + lea -16302(%rax,%rsi), %eax + cmpl %eax, %ebp + jge ..B1.21 +..B1.20: + subl %esi, %ebp + fld %st(1) + addl $16383, %ebp + fld %st(2) + movzwl 184(%rsp), %eax + andl $32767, %ebp + andl $-32768, %eax + orl %ebp, %eax + movl %esi, %ebp + movw %ax, 184(%rsp) + fldt 176(%rsp) + fadd %st, %st(2) + fld %st(2) + fxch %st(2) + fsubr %st(3), %st + fsubr %st, %st(2) + fxch %st(2) + fsubrp %st, %st(5) + fsubp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%rsp) + jmp ..B1.23 +..B1.21: + fstp %st(0) + fstp %st(0) + fldt 176(%rsp) + jmp ..B1.23 +..B1.22: + fstpt 48(%rsp) + movl %esi, %ebp +..B1.23: + fldt 48(%rsp) + lea 1(%rbp), %eax + fldt (%rsp) + andl $1, %eax + subl %eax, %ebp + lea onetwo(%rip), %rdx + shlq $4, %rax + decl %ebp + sarl $1, %ebp + movl %ebp, %edi + fldt (%rax,%rdx) + fmul %st, %st(3) + fld %st(3) + fsqrt + fmul %st, %st(2) + fld %st(2) + fsubr %st(1), %st + faddp %st, %st(3) + fld %st(2) + fsubr %st(1), %st + fxch %st(2) + fmulp %st, %st(4) + fld %st(2) + fmul %st(3), %st + fld %st(1) + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(4) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(3) + fsubrp %st, %st(5) + fxch %st(2) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldt .L_2il0floatpacket.9(%rip) + fmulp %st, %st(3) + fdivr %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 320 + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fstpt (%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 64(%rsp) +..___tag_value_csqrtl.15: + call __libm_scalbl_k80@PLT +..___tag_value_csqrtl.16: +..B1.70: + fldt 64(%rsp) + fxch %st(1) + fstpt 80(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 288 +..B1.24: + fldt 80(%rsp) + subl %ebp, %ebx + fldt 16(%rsp) + movl %ebx, %edi + fld %st(0) + fdivr %st(2), %st + fmul %st, %st(3) + fld %st(1) + fldt (%rsp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + fsubr %st(4), %st + faddp %st, %st(1) + fld %st(0) + fsubr %st(4), %st + fxch %st(2) + fmul %st(5), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fmul %st(2), %st + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fld %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + fsubrp %st, %st(3) + fldt 96(%rsp) + faddp %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fldt 16(%rsp) + fdivrp %st, %st(2) + addq $-32, %rsp + .cfi_def_cfa_offset 320 + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.9(%rip) + fmul %st, %st(2) + fxch %st(2) + fstpt (%rsp) + fmulp %st, %st(1) + fstpt 16(%rsp) +..___tag_value_csqrtl.19: + call __libm_scalbl_k80@PLT +..___tag_value_csqrtl.20: +..B1.71: + addq $32, %rsp + .cfi_def_cfa_offset 288 +..B1.25: + testb $-128, 297(%rsp) + jne ..B1.27 +..B1.26: + fldt 48(%rsp) + lea 224(%rsp), %rbx + fstpt -16(%rbx) + jmp ..B1.28 +..B1.27: + fldt 48(%rsp) + lea 224(%rsp), %rbx + fxch %st(1) + fstpt -16(%rbx) +..B1.28: + movb 313(%rsp), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fmulp %st, %st(1) + fstpt (%rbx) + jmp ..B1.49 +..B1.30: + movzwl 312(%rsp), %ebx + andl $32767, %ebx +..B1.31: + cmpl $32767, %ebx + jge ..B1.46 +..B1.32: + movq 288(%rsp), %rax + testq %rax, %rax + jne ..B1.39 +..B1.33: + cmpl $0, 308(%rsp) + jne ..B1.35 +..B1.34: + cmpl $0, 304(%rsp) + je ..B1.39 +..B1.35: + fldt 304(%rsp) + lea ones(%rip), %rdx + movb 313(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + cmpl $2, %ebx + fldl (%rdx,%rcx,8) + jl ..B1.37 +..B1.36: + lea halfs(%rip), %rax + fldl (%rax,%rcx,8) + fmulp %st, %st(2) + fxch %st(1) + fsqrt + jmp ..B1.38 +..B1.37: + lea _CONSTANTS(%rip), %rax + lea 64+_CONSTANTS(%rip), %rdx + fldt (%rax) + fmulp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fsqrt + fldt (%rdx) + fmulp %st, %st(1) +..B1.38: + fstpt 208(%rsp) + fldt 208(%rsp) + fmulp %st, %st(1) + fstpt 224(%rsp) + jmp ..B1.49 +..B1.39: + cmpl $32767, %ebp + jge ..B1.44 +..B1.40: + fldt 288(%rsp) + lea ones(%rip), %rcx + movb 297(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + fmull (%rcx,%rdx,8) + fstpt 176(%rsp) + fldt 176(%rsp) + fsqrt + jne ..B1.42 +..B1.41: + fstpt 208(%rsp) + lea 224(%rsp), %rbx + jmp ..B1.43 +..B1.42: + fldt 48(%rsp) + lea 224(%rsp), %rbx + fstpt -16(%rbx) + fstpt 48(%rsp) +..B1.43: + fldt 48(%rsp) + movb 313(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + fmull (%rcx,%rdx,8) + fstpt (%rbx) + jmp ..B1.49 +..B1.44: + movq $0x8000000000000000, %rdx + cmpq %rdx, %rax + je ..B1.40 +..B1.45: + fldt 288(%rsp) + fmul %st(0), %st + fstpt 208(%rsp) + fldt 208(%rsp) + fstpt 224(%rsp) + jmp ..B1.49 +..B1.46: + je ..B1.62 +..B1.47: + cmpl $32767, %ebp + je ..B1.58 +..B1.48: + fldt 288(%rsp) + fld %st(0) + fldt 304(%rsp) + fmul %st, %st(1) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fstpt 208(%rsp) + fmulp %st, %st(1) + fstpt 224(%rsp) +..B1.49: + testb %r12b, %r12b + je ..B1.51 +..B1.50: + fldcw 66(%rsp) +..B1.51: + movq 240(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.57 +..B1.52: + fldt 208(%rsp) + fldt 224(%rsp) + movq 240(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.56 +..B1.53: + addq $256, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 288 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 12, -16 +..B1.54: + lea 16+_CONSTANTS(%rip), %rbx + fldt (%rbx) + fmul %st(1), %st + fstpt 80(%rsp) + movzwl 88(%rsp), %eax + movl %eax, %ebx + andl $-32768, %eax + andl $32767, %ebx + orl $-49153, %eax + addl $-16639, %ebx + movw %ax, 88(%rsp) + jmp ..B1.17 +..B1.55: + lea 16+_CONSTANTS(%rip), %rbp + fldt (%rbp) + fmul %st(1), %st + fstpt 176(%rsp) + movzwl 184(%rsp), %eax + movl %eax, %ebp + andl $-32768, %eax + andl $32767, %ebp + orl $-49153, %eax + addl $-16639, %ebp + movw %ax, 184(%rsp) + jmp ..B1.15 +..B1.56: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.57: + call __stack_chk_fail@PLT +..B1.58: + movq $0x8000000000000000, %rax + cmpq 288(%rsp), %rax + jne ..B1.48 +..B1.59: + fldt 288(%rsp) + fmul %st(0), %st + fldt 304(%rsp) + fmul %st(0), %st + testb $-128, 297(%rsp) + jne ..B1.61 +..B1.60: + fxch %st(1) + fstpt 208(%rsp) + fstpt 224(%rsp) + jmp ..B1.49 +..B1.61: + fstpt 208(%rsp) + fstpt 224(%rsp) + jmp ..B1.49 +..B1.62: + movq $0x8000000000000000, %rax + cmpq 304(%rsp), %rax + jne ..B1.47 +..B1.63: + fldt 304(%rsp) + lea ones(%rip), %rdx + movb 313(%rsp), %al + andb $-128, %al + shrb $7, %al + fmul %st(0), %st + fstpt 208(%rsp) + fldt 208(%rsp) + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fmulp %st, %st(1) + fstpt 224(%rsp) + jmp ..B1.49 + .align 16,0x90 + .cfi_endproc + .type csqrtl,@function + .size csqrtl,.-csqrtl + .data +# -- End csqrtl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 16 +t32: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type t32,@object + .size t32,32 + .align 16 +onetwo: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type onetwo,@object + .size onetwo,32 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +halfs: + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbfe00000 + .type halfs,@object + .size halfs,16 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16127 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,80 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ctan.S b/external/sgx_libm/intel64/ctan.S new file mode 100644 index 0000000000..aa3748e947 --- /dev/null +++ b/external/sgx_libm/intel64/ctan.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctan.c" + .text +..TXTST0: +# -- Begin ctan + .text + .align 16,0x90 + .globl ctan +ctan: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ctan.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movsd %xmm1, 24(%rsp) + movzwl 30(%rsp), %eax + andl $32752, %eax + movsd %xmm0, 16(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.5 +..B1.3: + testl $1048575, 28(%rsp) + jne ..B1.7 +..B1.4: + cmpl $0, 24(%rsp) + jne ..B1.7 +..B1.5: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.6: + movb 31(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm1 + movhpd 8(%rsp), %xmm1 +..B1.7: + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + call ctanh@PLT +..B1.16: + movsd %xmm0, 16(%rsp) + movzwl 22(%rsp), %eax + andl $32752, %eax + movsd %xmm1, 24(%rsp) + cmpl $32752, %eax + unpcklpd %xmm0, %xmm1 + jl ..B1.11 +..B1.9: + testl $1048575, 20(%rsp) + jne ..B1.13 +..B1.10: + cmpl $0, 16(%rsp) + jne ..B1.13 +..B1.11: + movsd %xmm1, (%rsp) + movhpd %xmm1, 8(%rsp) +..B1.12: + movb 23(%rsp), %al + notb %al + movb 15(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movsd (%rsp), %xmm1 + movb %dl, 15(%rsp) + movhpd 8(%rsp), %xmm1 +..B1.13: + movaps %xmm1, %xmm2 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm2 + movaps %xmm2, %xmm1 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ctan,@function + .size ctan,.-ctan + .data +# -- End ctan + .text +# -- Begin ctanf + .text + .align 16,0x90 + .globl ctanf +ctanf: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_ctanf.6: +..L7: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) + movzwl 14(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.4 +..B2.3: + testl $8388607, 12(%rsp) + jne ..B2.6 +..B2.4: + movsd %xmm0, (%rsp) +..B2.5: + movb 15(%rsp), %al + notb %al + movb 3(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 3(%rsp) + movsd (%rsp), %xmm0 +..B2.6: + call ctanhf@PLT +..B2.14: + movsd %xmm0, 8(%rsp) + movzwl 10(%rsp), %eax + andl $32640, %eax + movss 12(%rsp), %xmm0 + cmpl $32640, %eax + movss 8(%rsp), %xmm1 + unpcklps %xmm1, %xmm0 + jl ..B2.9 +..B2.8: + testl $8388607, 8(%rsp) + jne ..B2.11 +..B2.9: + movsd %xmm0, (%rsp) +..B2.10: + movb 11(%rsp), %al + notb %al + movb 7(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 7(%rsp) + movsd (%rsp), %xmm0 +..B2.11: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ctanf,@function + .size ctanf,.-ctanf + .data +# -- End ctanf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ctanh.S b/external/sgx_libm/intel64/ctanh.S new file mode 100644 index 0000000000..091b6f0793 --- /dev/null +++ b/external/sgx_libm/intel64/ctanh.S @@ -0,0 +1,771 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctanh.c" + .text +..TXTST0: +# -- Begin ctanhf + .text + .align 16,0x90 + .globl ctanhf +ctanhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ctanhf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + cvtps2pd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 +..___tag_value_ctanhf.4: + call ctanh@PLT +..___tag_value_ctanhf.5: +..B1.10: + unpcklpd %xmm1, %xmm0 +..B1.2: + cvtpd2ps %xmm0, %xmm0 + movsd %xmm0, 4(%rsp) + movzwl 6(%rsp), %eax + testl $32640, %eax + jne ..B1.4 +..B1.3: + testl $8388607, 4(%rsp) + jne ..B1.6 +..B1.4: + movzwl 10(%rsp), %eax + testl $32640, %eax + jne ..B1.7 +..B1.5: + testl $8388607, 8(%rsp) + je ..B1.7 +..B1.6: + movl $8388608, (%rsp) + movss (%rsp), %xmm1 + movss (%rsp), %xmm0 + mulss %xmm0, %xmm1 + movsd 4(%rsp), %xmm0 + movss %xmm1, (%rsp) +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ctanhf,@function + .size ctanhf,.-ctanhf + .data +# -- End ctanhf + .text +# -- Begin ctanh + .text + .align 16,0x90 + .globl ctanh +ctanh: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_ctanh.8: +..L9: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + movq %fs:40, %rax + subq $160, %rsp + .cfi_def_cfa_offset 192 + movsd %xmm0, 40(%rsp) + xorq %rsp, %rax + movzwl 46(%rsp), %r12d + andl $32752, %r12d + shrl $4, %r12d + movsd %xmm1, 48(%rsp) + cmpl $2047, %r12d + movq %rax, 152(%rsp) + jge ..B2.33 +..B2.2: + testl %r12d, %r12d + jle ..B2.61 +..B2.3: + movzwl 54(%rsp), %edi + movl %edi, %ebx + andl $32752, %ebx + shrl $4, %ebx + cmpl $2047, %ebx + jge ..B2.34 +..B2.4: + cmpl $1032, %r12d + jl ..B2.8 +..B2.5: + movb 47(%rsp), %dl + lea _DBL_MIN_NORMAL(%rip), %rax + andb $-128, %dl + lea ones(%rip), %rcx + shrb $7, %dl + movsd (%rax), %xmm1 + movzbl %dl, %esi + testl %ebx, %ebx + movsd (%rcx,%rsi,8), %xmm0 + subsd %xmm1, %xmm0 + movsd %xmm0, 24(%rsp) + jle ..B2.57 +..B2.6: + movsd %xmm1, 16(%rsp) + testl $32752, %edi + movsd 16(%rsp), %xmm1 + movsd 16(%rsp), %xmm0 + mulsd %xmm0, %xmm1 + movsd %xmm1, 16(%rsp) + movsd 16(%rsp), %xmm0 + jle ..B2.56 +..B2.7: + movsd 48(%rsp), %xmm0 + call tan@PLT +..B2.71: + lea 32(%rsp), %rax + pxor %xmm1, %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, (%rax) + movsd -8(%rax), %xmm0 + movhpd (%rax), %xmm0 + jmp ..B2.54 +..B2.8: + movsd 40(%rsp), %xmm0 + lea 104(%rsp), %rdi +..___tag_value_ctanh.17: + call __libm_cosh_k64@PLT +..___tag_value_ctanh.18: +..B2.72: + movl %eax, %ebx +..B2.9: + movsd 104(%rsp), %xmm2 + movsd 112(%rsp), %xmm3 + movaps %xmm2, %xmm4 + movzwl 46(%rsp), %eax + addsd %xmm3, %xmm4 + movaps %xmm4, %xmm1 + andl $32752, %eax + cmpl $13168, %eax + subsd %xmm4, %xmm2 + addsd %xmm3, %xmm2 + movsd .L_2il0floatpacket.13(%rip), %xmm3 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + subsd %xmm4, %xmm0 + subsd %xmm0, %xmm1 + movsd %xmm1, 104(%rsp) + subsd %xmm1, %xmm4 + addsd %xmm2, %xmm4 + movsd %xmm4, 112(%rsp) + jge ..B2.11 +..B2.10: + lea 16+_CONSTANTS(%rip), %r12 + lea 80(%rsp), %r14 + movsd -40(%r14), %xmm0 + mulsd (%r12), %xmm0 + movsd %xmm0, -8(%r14) + movzwl -2(%r14), %eax + movl %eax, %r12d + andl $32752, %r12d + andl $-32753, %eax + shrl $4, %r12d + orl $-49168, %eax + movw %ax, -2(%r14) + addl $-1279, %r12d + pxor %xmm0, %xmm0 + jmp ..B2.13 +..B2.11: + movsd 40(%rsp), %xmm0 + lea 72(%rsp), %rdi +..___tag_value_ctanh.19: + call __libm_sinh_k64@PLT +..___tag_value_ctanh.20: +..B2.73: + movsd .L_2il0floatpacket.13(%rip), %xmm3 + movl %eax, %r12d +..B2.12: + lea 80(%rsp), %r14 + movsd (%r14), %xmm0 +..B2.13: + movsd 72(%rsp), %xmm4 + movaps %xmm0, %xmm5 + movaps %xmm3, %xmm2 + lea 56(%rsp), %rdi + addsd %xmm4, %xmm5 + mulsd %xmm5, %xmm2 + subsd %xmm5, %xmm4 + movaps %xmm2, %xmm1 + lea 88(%rsp), %rsi + subsd %xmm5, %xmm1 + addsd %xmm0, %xmm4 + subsd %xmm1, %xmm2 + movsd -40(%rsi), %xmm0 + subsd %xmm2, %xmm5 + movsd %xmm2, -16(%rsi) + addsd %xmm4, %xmm5 + movsd %xmm5, (%r14) +..___tag_value_ctanh.21: + call __libm_sincos_k64@PLT +..___tag_value_ctanh.22: +..B2.14: + movsd 88(%rsp), %xmm4 + lea 8+_CONSTANTS(%rip), %rax + movsd 96(%rsp), %xmm2 + movaps %xmm4, %xmm1 + movsd .L_2il0floatpacket.13(%rip), %xmm3 + addl %r12d, %ebx + movsd 112(%rsp), %xmm6 + movaps %xmm3, %xmm10 + movsd (%r14), %xmm13 + movaps %xmm6, %xmm11 + mulsd %xmm13, %xmm11 + addsd %xmm2, %xmm1 + movsd 104(%rsp), %xmm7 + lea (%r12,%r12), %r14d + movaps %xmm7, %xmm8 + subsd %xmm1, %xmm4 + mulsd %xmm13, %xmm7 + addsd %xmm2, %xmm4 + movaps %xmm3, %xmm2 + mulsd %xmm1, %xmm2 + movaps %xmm2, %xmm0 + movsd (%rax), %xmm5 + subsd %xmm1, %xmm0 + movsd %xmm5, 8(%rsp) + subsd %xmm0, %xmm2 + movsd 72(%rsp), %xmm0 + subsd %xmm2, %xmm1 + mulsd %xmm0, %xmm6 + addsd %xmm5, %xmm2 + mulsd %xmm0, %xmm8 + addsd %xmm4, %xmm1 + addsd %xmm6, %xmm11 + movaps %xmm8, %xmm12 + movaps %xmm0, %xmm5 + mulsd %xmm0, %xmm5 + addsd %xmm7, %xmm11 + mulsd %xmm13, %xmm0 + mulsd %xmm13, %xmm13 + addsd %xmm11, %xmm12 + addsd %xmm0, %xmm0 + mulsd %xmm12, %xmm10 + subsd %xmm12, %xmm8 + addsd %xmm13, %xmm0 + addsd %xmm8, %xmm11 + movaps %xmm10, %xmm9 + movaps %xmm2, %xmm6 + movsd %xmm5, 120(%rsp) + subsd %xmm12, %xmm9 + mulsd %xmm2, %xmm6 + subsd %xmm9, %xmm10 + movzwl 126(%rsp), %edx + subsd %xmm10, %xmm12 + andl $32752, %edx + addsd %xmm11, %xmm12 + shrl $4, %edx + movsd %xmm2, 88(%rsp) + mulsd %xmm1, %xmm2 + movsd %xmm6, 24(%rsp) + lea (%rdx,%r12,2), %eax + movzwl 30(%rsp), %edx + addsd %xmm2, %xmm2 + andl $32752, %edx + shrl $4, %edx + movsd %xmm1, 96(%rsp) + mulsd %xmm1, %xmm1 + movsd %xmm10, 136(%rsp) + lea -112(%rdx), %ecx + movsd %xmm12, 144(%rsp) + cmpl %ecx, %eax + movsd %xmm0, 128(%rsp) + addsd %xmm1, %xmm2 + jg ..B2.16 +..B2.15: + movsd %xmm2, 32(%rsp) + xorl %r14d, %r14d + jmp ..B2.22 +..B2.16: + addl $112, %edx + cmpl %edx, %eax + jge ..B2.21 +..B2.17: + movl %r14d, %eax + negl %eax + movsd .L_2il0floatpacket.14(%rip), %xmm1 + addl $1023, %eax + movsd %xmm1, (%rsp) + andl $2047, %eax + movzwl 6(%rsp), %edx + movaps %xmm5, %xmm1 + shll $4, %eax + andl $-32753, %edx + orl %eax, %edx + movw %dx, 6(%rsp) + movsd (%rsp), %xmm4 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm2 + comisd %xmm6, %xmm5 + addsd %xmm6, %xmm1 + movsd %xmm6, 24(%rsp) + movsd %xmm2, 32(%rsp) + jbe ..B2.19 +..B2.18: + subsd %xmm1, %xmm5 + addsd %xmm6, %xmm5 + addsd %xmm2, %xmm5 + addsd %xmm0, %xmm5 + jmp ..B2.20 +..B2.19: + subsd %xmm1, %xmm6 + addsd %xmm5, %xmm6 + addsd %xmm0, %xmm6 + addsd %xmm2, %xmm6 + movaps %xmm6, %xmm5 +..B2.20: + movaps %xmm5, %xmm6 + addsd %xmm1, %xmm6 + subsd %xmm6, %xmm1 + addsd %xmm1, %xmm5 + movaps %xmm5, %xmm2 + jmp ..B2.22 +..B2.21: + movsd %xmm2, 32(%rsp) + movaps %xmm5, %xmm6 + movaps %xmm0, %xmm2 +..B2.22: + movaps %xmm6, %xmm0 + movaps %xmm3, %xmm5 + movsd .L_2il0floatpacket.14(%rip), %xmm1 + movaps %xmm3, %xmm7 + movsd .L_2il0floatpacket.14(%rip), %xmm8 + negl %r14d + addl %r14d, %ebx + lea 136(%rsp), %rsi + movl %ebx, %edi + lea 120(%rsp), %rdx + addsd %xmm2, %xmm0 + mulsd %xmm0, %xmm5 + subsd %xmm0, %xmm6 + addsd %xmm2, %xmm6 + movaps %xmm5, %xmm2 + subsd %xmm0, %xmm2 + subsd %xmm2, %xmm5 + divsd %xmm5, %xmm1 + mulsd %xmm1, %xmm7 + subsd %xmm5, %xmm0 + movaps %xmm7, %xmm4 + lea 24(%rsp), %rcx + subsd %xmm1, %xmm4 + addsd %xmm0, %xmm6 + subsd %xmm4, %xmm7 + mulsd %xmm7, %xmm5 + mulsd %xmm7, %xmm6 + subsd %xmm5, %xmm8 + movsd %xmm7, (%rdx) + subsd %xmm6, %xmm8 + movsd .L_2il0floatpacket.14(%rip), %xmm6 + addsd %xmm8, %xmm6 + mulsd %xmm6, %xmm8 + mulsd %xmm7, %xmm8 + movsd %xmm8, 8(%rdx) +..___tag_value_ctanh.23: + call __libm_mul_k64@PLT +..___tag_value_ctanh.24: +..B2.23: + movzwl 54(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + movsd .L_2il0floatpacket.13(%rip), %xmm3 + testl %eax, %eax + jne ..B2.28 +..B2.24: + testl $1048575, 52(%rsp) + jne ..B2.28 +..B2.25: + cmpl $0, 48(%rsp) + jne ..B2.28 +..B2.26: + movq 48(%rsp), %rax + movq %rax, 32(%rsp) + movq 152(%rsp), %rdx + xorq %rsp, %rdx + movsd 48(%rsp), %xmm1 + movsd 24(%rsp), %xmm0 + cmpq %fs:40, %rdx + jne ..B2.60 +..B2.27: + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -32 + .cfi_offset 12, -16 + .cfi_offset 14, -24 +..B2.28: + cmpl $823, %eax + jl ..B2.30 +..B2.29: + xorl %ecx, %ecx + lea 64(%rsp), %rax + movsd (%rax), %xmm0 + jmp ..B2.31 +..B2.30: + lea 16+_CONSTANTS(%rip), %rax + movsd 48(%rsp), %xmm0 + mulsd (%rax), %xmm0 + lea 64(%rsp), %rax + movsd %xmm0, -8(%rax) + movzwl -2(%rax), %edx + movl %edx, %ecx + andl $32752, %ecx + andl $-32753, %edx + shrl $4, %ecx + orl $-49168, %edx + movw %dx, -2(%rax) + addl $-1279, %ecx + pxor %xmm0, %xmm0 +..B2.31: + movsd 56(%rsp), %xmm1 + movaps %xmm0, %xmm6 + movaps %xmm3, %xmm2 + addl %ecx, %r14d + movsd 8(%rsp), %xmm4 + lea 136(%rsp), %rsi + movsd -40(%rsi), %xmm5 + lea 120(%rsp), %rdx + movsd -32(%rdx), %xmm7 + lea 32(%rsp), %rcx + movl %r14d, %edi + addsd %xmm1, %xmm6 + mulsd %xmm6, %xmm2 + subsd %xmm6, %xmm1 + addsd %xmm0, %xmm1 + movaps %xmm2, %xmm0 + subsd %xmm6, %xmm0 + subsd %xmm0, %xmm2 + subsd %xmm2, %xmm6 + addsd %xmm2, %xmm4 + addsd %xmm1, %xmm6 + movaps %xmm6, %xmm8 + movaps %xmm4, %xmm10 + mulsd %xmm5, %xmm8 + mulsd %xmm4, %xmm5 + mulsd %xmm7, %xmm10 + mulsd %xmm6, %xmm7 + addsd %xmm5, %xmm8 + movaps %xmm10, %xmm11 + addsd %xmm7, %xmm8 + movsd %xmm6, (%rax) + addsd %xmm8, %xmm11 + mulsd %xmm11, %xmm3 + subsd %xmm11, %xmm10 + movaps %xmm3, %xmm9 + addsd %xmm8, %xmm10 + subsd %xmm11, %xmm9 + movsd %xmm4, -64(%rdx) + subsd %xmm9, %xmm3 + movsd %xmm3, 16(%rdx) + subsd %xmm3, %xmm11 + addsd %xmm10, %xmm11 + movsd %xmm11, 24(%rdx) +..___tag_value_ctanh.36: + call __libm_mul_k64@PLT +..___tag_value_ctanh.37: +..B2.32: + movsd 24(%rsp), %xmm0 + movhpd 32(%rsp), %xmm0 + jmp ..B2.54 +..B2.33: + movzwl 54(%rsp), %ebx + andl $32752, %ebx + shrl $4, %ebx +..B2.34: + testl %ebx, %ebx + jne ..B2.37 +..B2.35: + testl $1048575, 52(%rsp) + jne ..B2.37 +..B2.36: + cmpl $0, 48(%rsp) + je ..B2.39 +..B2.37: + cmpl $2047, %ebx + jge ..B2.45 +..B2.38: + cmpl $2047, %r12d + je ..B2.65 +..B2.39: + movsd 40(%rsp), %xmm0 + call tanh@PLT +..B2.74: + movsd %xmm0, 24(%rsp) + testl %r12d, %r12d + jne ..B2.42 +..B2.40: + testl $1048575, 44(%rsp) + jne ..B2.42 +..B2.41: + cmpl $0, 40(%rsp) + je ..B2.44 +..B2.42: + testl %ebx, %ebx + jle ..B2.64 +..B2.43: + movsd 48(%rsp), %xmm0 + call tan@PLT +..B2.75: + pxor %xmm1, %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, 32(%rsp) + movsd 24(%rsp), %xmm0 + movhpd 32(%rsp), %xmm0 + jmp ..B2.54 +..B2.44: + movsd 48(%rsp), %xmm0 + call tan@PLT +..B2.76: + movsd %xmm0, 32(%rsp) + movsd 24(%rsp), %xmm0 + movhpd 32(%rsp), %xmm0 + jmp ..B2.54 +..B2.45: + cmpl $2047, %r12d + jge ..B2.47 +..B2.46: + movsd 48(%rsp), %xmm0 + call tan@PLT +..B2.77: + movsd %xmm0, 32(%rsp) + movsd %xmm0, 24(%rsp) + movhpd 32(%rsp), %xmm0 + jmp ..B2.54 +..B2.47: + testl $1048575, 44(%rsp) + jne ..B2.49 +..B2.48: + cmpl $0, 40(%rsp) + je ..B2.50 +..B2.49: + movsd 40(%rsp), %xmm0 + call tanh@PLT +..B2.78: + movsd 48(%rsp), %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, 32(%rsp) + movsd %xmm0, 24(%rsp) + movhpd 32(%rsp), %xmm0 + jmp ..B2.54 +..B2.50: + testl $1048575, 52(%rsp) + jne ..B2.52 +..B2.51: + cmpl $0, 48(%rsp) + je ..B2.53 +..B2.52: + movsd 48(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 48(%rsp) + movsd 40(%rsp), %xmm0 + call tanh@PLT +..B2.79: + lea zeros(%rip), %rax + movhpd (%rax), %xmm0 + movsd %xmm0, 24(%rsp) + movhpd %xmm0, 32(%rsp) + jmp ..B2.54 +..B2.53: + movsd 40(%rsp), %xmm0 + call tanh@PLT +..B2.80: + movb 55(%rsp), %dl + lea zeros(%rip), %rax + andb $-128, %dl + lea ones(%rip), %rcx + shrb $7, %dl + movsd (%rax), %xmm1 + movzbl %dl, %ebx + mulsd (%rcx,%rbx,8), %xmm1 + unpcklpd %xmm1, %xmm0 + movsd %xmm0, 24(%rsp) + movhpd %xmm0, 32(%rsp) +..B2.54: + movq 152(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.60 +..B2.55: + movaps %xmm0, %xmm1 + unpckhpd %xmm0, %xmm1 + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -32 + .cfi_offset 12, -16 + .cfi_offset 14, -24 +..B2.56: + movb 55(%rsp), %dl + lea 32(%rsp), %rax + movsd %xmm0, (%rax) + andb $-128, %dl + movb 7(%rax), %cl + andb $127, %cl + orb %dl, %cl + movsd -8(%rax), %xmm0 + movb %cl, 7(%rax) + movhpd (%rax), %xmm0 + jmp ..B2.54 +..B2.57: + testl $1048575, 52(%rsp) + jne ..B2.6 +..B2.58: + cmpl $0, 48(%rsp) + jne ..B2.6 +..B2.59: + pxor %xmm0, %xmm0 + jmp ..B2.56 +..B2.60: + call __stack_chk_fail@PLT +..B2.61: + testl $1048575, 44(%rsp) + jne ..B2.3 +..B2.62: + cmpl $0, 40(%rsp) + jne ..B2.3 + jmp ..B2.33 +..B2.64: + pxor %xmm0, %xmm0 + mulsd 48(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) + movsd 24(%rsp), %xmm0 + movhpd 32(%rsp), %xmm0 + jmp ..B2.54 +..B2.65: + testl $1048575, 44(%rsp) + jne ..B2.45 +..B2.66: + cmpl $0, 40(%rsp) + jne ..B2.45 +..B2.67: + movsd 40(%rsp), %xmm0 + call tanh@PLT +..B2.81: + movsd %xmm0, 24(%rsp) + jmp ..B2.42 + .align 16,0x90 + .cfi_endproc + .type ctanh,@function + .size ctanh,.-ctanh + .data +# -- End ctanh + .section .rodata, "a" + .align 16 + .align 16 +_DBL_MIN_NORMAL: + .long 0 + .long 1048576 + .type _DBL_MIN_NORMAL,@object + .size _DBL_MIN_NORMAL,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x02000000,0x41a00000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +zeros: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .type zeros,@object + .size zeros,16 + .align 4 +.L_2il0floatpacket.12: + .long 0x00800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .align 4 +_CONSTANTS: + .long 0 + .long 2145386496 + .long 0 + .long 1048576 + .long 0 + .long 1341128704 + .type _CONSTANTS,@object + .size _CONSTANTS,24 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ctanhl.S b/external/sgx_libm/intel64/ctanhl.S new file mode 100644 index 0000000000..ae3c9322f2 --- /dev/null +++ b/external/sgx_libm/intel64/ctanhl.S @@ -0,0 +1,1012 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctanhl.c" + .text +..TXTST0: +# -- Begin ctanhl + .text + .align 16,0x90 + .globl ctanhl +ctanhl: +# parameter 1: 448 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_ctanhl.1: +..L2: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + pushq %rbp + .cfi_def_cfa_offset 40 + .cfi_offset 6, -40 + subq $408, %rsp + .cfi_def_cfa_offset 448 + xorb %r15b, %r15b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 400(%rsp) + fstpt 208(%rsp) + fldt 208(%rsp) + fstpt 368(%rsp) + fldt 368(%rsp) + fstpt 384(%rsp) +..B1.2: + fnstcw 226(%rsp) +..B1.3: + movzwl 226(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 224(%rsp) +..B1.5: + fldcw 224(%rsp) +..B1.6: + movb $1, %r15b +..B1.7: + movzwl 456(%rsp), %edx + andl $32767, %edx + cmpl $32767, %edx + jge ..B1.52 +..B1.8: + movzwl 472(%rsp), %ebp + andl $32767, %ebp + cmpl $32767, %ebp + jge ..B1.52 +..B1.9: + cmpl $0, 452(%rsp) + jne ..B1.11 +..B1.10: + cmpl $0, 448(%rsp) + je ..B1.52 +..B1.11: + cmpl $16396, %edx + jl ..B1.23 +..B1.12: + movb 457(%rsp), %dl + lea _CONSTANTS(%rip), %rax + andb $-128, %dl + lea ones(%rip), %rcx + shrb $7, %dl + fldt (%rax) + movzbl %dl, %ebx + cmpl $0, 468(%rsp) + fldl (%rcx,%rbx,8) + fsub %st(1), %st + fstpt 368(%rsp) + jne ..B1.14 +..B1.13: + cmpl $0, 464(%rsp) + je ..B1.15 +..B1.14: + fmul %st(0), %st + fstpt 384(%rsp) + jmp ..B1.16 +..B1.15: + fstp %st(0) + fldt 208(%rsp) + fstpt 384(%rsp) +..B1.16: + testl %ebp, %ebp + jle ..B1.76 +..B1.17: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 480(%rsp) + fstpt (%rsp) + call tanl@PLT +..B1.85: + addq $16, %rsp + .cfi_def_cfa_offset 448 + fstpt 192(%rsp) + movb 393(%rsp), %dl + movb 201(%rsp), %al + andb $127, %dl + andb $-128, %al + orb %al, %dl +..B1.18: + movb %dl, 393(%rsp) + testb %r15b, %r15b + je ..B1.20 +..B1.19: + fldcw 226(%rsp) +..B1.20: + movq 400(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.75 +..B1.21: + fldt 368(%rsp) + fldt 384(%rsp) + movq 400(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.74 +..B1.22: + addq $408, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 448 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.23: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 464(%rsp) + lea 288(%rsp), %rdi + fstpt (%rsp) +..___tag_value_ctanhl.29: + call __libm_coshl_k80@PLT +..___tag_value_ctanhl.30: +..B1.86: + addq $16, %rsp + .cfi_def_cfa_offset 448 +..B1.24: + fldt 288(%rsp) + lea 32+_CONSTANTS(%rip), %r14 + movzwl 456(%rsp), %eax + andl $32767, %eax + cmpl $16183, %eax + fldt (%r14) + fstpt 32(%rsp) + fldt 32(%rsp) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt 272(%rsp) + fld %st(0) + movl (%rsp), %r14d + fadd %st(2), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + jge ..B1.26 +..B1.25: + fldt 448(%rsp) + lea 16+_CONSTANTS(%rip), %rbp + fldt 208(%rsp) + lea 256(%rsp), %rdx + fstpt (%rdx) + fldt (%rbp) + fmulp %st, %st(1) + fstpt -16(%rdx) + movzwl -8(%rdx), %eax + movl %eax, %ebp + andl $-32768, %eax + andl $32767, %ebp + orl $-49153, %eax + addl $-16639, %ebp + movw %ax, -8(%rdx) + jmp ..B1.28 +..B1.26: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 464(%rsp) + lea 256(%rsp), %rdi + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value_ctanhl.33: + call __libm_sinhl_k80@PLT +..___tag_value_ctanhl.34: +..B1.87: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 448 +..B1.27: + fldt 32(%rsp) + lea 256(%rsp), %rdx + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + movl (%rsp), %ebp +..B1.28: + fldt 240(%rsp) + fld %st(0) + fldt (%rdx) + fadd %st, %st(1) + fxch %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fsubp %st, %st(2) + fsubp %st, %st(1) + fldt 480(%rsp) + fstpt (%rsp) + lea 320(%rsp), %rdi + fxch %st(1) + fstpt 32(%rsp) + fstpt 112(%rsp) +..___tag_value_ctanhl.37: + call __libm_cosl_k80@PLT +..___tag_value_ctanhl.38: +..B1.88: + fldt 112(%rsp) + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 448 +..B1.29: + fldt 304(%rsp) + lea _CONSTANTS(%rip), %rax + fld %st(0) + lea t33(%rip), %rdx + fldt 320(%rsp) + addl %ebp, %r14d + fadd %st, %st(1) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fxch %st(1) + fmul %st(4), %st + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + fstpt 128(%rsp) + fldt 128(%rsp) + fldt (%rax) + movzwl 168(%rsp), %eax + faddp %st, %st(4) + fxch %st(3) + fstpt 112(%rsp) + fldt 112(%rsp) + andl $32767, %eax + fstpt 144(%rsp) + fld %st(0) + fldt 160(%rsp) + addl %ebp, %eax + fld %st(0) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fldt (%rdx) + fmul %st, %st(3) + fld %st(0) + fmul %st(2), %st + movzwl 152(%rsp), %edx + fsub %st, %st(3) + andl $32767, %edx + fsubp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + fadd %st(5), %st + fxch %st(1) + fstpt (%rsp) + fld %st(3) + lea 64(%rdx), %ecx + cmpl %ecx, %eax + fsubr %st(3), %st + fsubrp %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + fldt 80(%rsp) + faddp %st, %st(4) + fld %st(3) + fmul %st(3), %st + fld %st(2) + fmul %st(2), %st + fxch %st(2) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fsubp %st, %st(2) + fsubp %st, %st(1) + fstpt 64(%rsp) + fldt 112(%rsp) + jge ..B1.35 +..B1.30: + addl $-64, %edx + cmpl %edx, %eax + jle ..B1.34 +..B1.31: + fstpt 112(%rsp) + lea (%rbp,%rbp), %ebx + movzwl 120(%rsp), %eax + movl %eax, %edx + movzwl 136(%rsp), %ecx + subl %ebp, %eax + andl $32767, %ecx + andl $-32768, %edx + andl $32767, %eax + subl %ebp, %ecx + orl %eax, %edx + fxch %st(1) + fstpt 160(%rsp) + testl %ecx, %ecx + movw %dx, 120(%rsp) + jle ..B1.33 +..B1.32: + fldt 112(%rsp) + movzwl 168(%rsp), %eax + movl %eax, %edx + subl %ebp, %eax + andl $-32768, %edx + andl $32767, %eax + orl %eax, %edx + movw %dx, 168(%rsp) + jmp ..B1.38 +..B1.33: + fldt 112(%rsp) + jmp ..B1.38 +..B1.34: + fstp %st(1) + fldt 208(%rsp) + fstpt 112(%rsp) + fldt 112(%rsp) + fstpt 160(%rsp) +..B1.36: + fldt .L_2il0floatpacket.8(%rip) + fxch %st(1) + fstpt 16(%rsp) + xorl %ebx, %ebx + jmp ..B1.38 +..B1.35: + fldt 208(%rsp) + fstpt 112(%rsp) + fldt 112(%rsp) + fstpt 160(%rsp) + fldt 160(%rsp) + jl ..B1.100 +..B1.37: + fstp %st(3) + fstp %st(0) + lea (%rbp,%rbp), %ebx + fxch %st(1) +..B1.38: + addq $-32, %rsp + .cfi_def_cfa_offset 480 + fldt 48(%rsp) + lea 368(%rsp), %rdi + fstpt (%rsp) + fstpt 16(%rsp) + fstpt 128(%rsp) +..___tag_value_ctanhl.41: + call __libm_hypot2l_k80@PLT +..___tag_value_ctanhl.42: +..B1.89: + fldt 128(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 448 +..B1.39: + fldt 32(%rsp) + lea t32(%rip), %rbp + movzwl 8+.L_2il0floatpacket.9(%rip), %eax + movl %eax, %ecx + andl $-32768, %ecx + subl %ebx, %r14d + movl %r14d, %edi + faddp %st, %st(2) + fxch %st(1) + fstpt 176(%rsp) + fldt .L_2il0floatpacket.9(%rip) + movl 176(%rsp), %edx + addl %eax, %edx + andl $32767, %edx + fstpt 192(%rsp) + orl %edx, %ecx + fldt 336(%rsp) + fldt 352(%rsp) + fldt 16(%rsp) + fldt 160(%rsp) + fldt .L_2il0floatpacket.10(%rip) + fmul %st, %st(2) + fxch %st(5) + fmulp %st, %st(2) + fldt 112(%rsp) + movw %cx, 200(%rsp) + fmulp %st, %st(5) + fmulp %st, %st(4) + fldt 192(%rsp) + fmul %st, %st(3) + fld %st(3) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fstpt 352(%rsp) + fldt 352(%rsp) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 336(%rsp) + fldt 336(%rsp) + fldt 48(%rsp) + fld %st(0) + fdiv %st(2), %st + fmul %st, %st(3) + fldt (%rbp) + fld %st(0) + fmul %st(2), %st + fld %st(0) + fsubr %st(3), %st + faddp %st, %st(1) + fld %st(0) + fsubr %st(3), %st + fxch %st(2) + fstpt 80(%rsp) + fldt 80(%rsp) + fmul %st(5), %st + fsubr %st, %st(7) + faddp %st, %st(7) + fld %st(6) + fsubrp %st, %st(5) + fld %st(0) + fmul %st(7), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st(5), %st + faddp %st, %st(7) + fld %st(6) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(7) + faddp %st, %st(2) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(4) + fsubrp %st, %st(1) + fsubp %st, %st(1) + fldt 64(%rsp) + faddp %st, %st(1) + fsubp %st, %st(1) + fld %st(1) + fldt 96(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 480 + fdivrp %st, %st(2) + fadd %st(1), %st + fstpt (%rsp) + fldt (%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) +..___tag_value_ctanhl.45: + call __libm_scalbl_k80@PLT +..___tag_value_ctanhl.46: +..B1.90: + addq $32, %rsp + .cfi_def_cfa_offset 448 +..B1.40: + fstpt 368(%rsp) + cmpq $0, 464(%rsp) + jne ..B1.46 +..B1.41: + fldt 464(%rsp) + testb %r15b, %r15b + fstpt 384(%rsp) + je ..B1.43 +..B1.42: + fldcw 226(%rsp) +..B1.43: + movq 400(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.75 +..B1.44: + fldt 368(%rsp) + fldt 384(%rsp) + movq 400(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.74 +..B1.45: + addq $408, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 448 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.46: + movzwl 472(%rsp), %eax + andl $32767, %eax + cmpl $16183, %eax + jge ..B1.48 +..B1.47: + fldt 464(%rsp) + lea 16+_CONSTANTS(%rip), %rax + fldt 208(%rsp) + fstpt 32(%rsp) + fldt (%rax) + fmulp %st, %st(1) + fstpt 16(%rsp) + movzwl 24(%rsp), %edx + movl %edx, %edi + andl $-32768, %edx + andl $32767, %edi + orl $-49153, %edx + addl $-16639, %edi + movw %dx, 24(%rsp) + fldt 16(%rsp) + jmp ..B1.50 +..B1.48: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 480(%rsp) + lea 32(%rsp), %rdi + fstpt (%rsp) +..___tag_value_ctanhl.63: + call __libm_sinl_k80@PLT +..___tag_value_ctanhl.64: +..B1.91: + addq $16, %rsp + .cfi_def_cfa_offset 448 +..B1.49: + fldt 16(%rsp) + xorl %edi, %edi + fmul %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fldt 32(%rsp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 208(%rsp) + fldt 208(%rsp) + fstpt 32(%rsp) +..B1.50: + fldt 208(%rsp) + fld %st(1) + subl %ebx, %edi + fadd %st(1), %st + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fldt (%rsp) + fld %st(0) + fmul %st(4), %st + fsub %st, %st(2) + fsubp %st, %st(2) + fld %st(1) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fldt 144(%rsp) + fmul %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fsubrp %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fsubr %st, %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fldt 128(%rsp) + faddp %st, %st(2) + fld %st(1) + fmul %st(5), %st + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsub %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + fstpt 160(%rsp) + fldt 336(%rsp) + fld %st(0) + fdivr %st(2), %st + fld %st(1) + fldt 80(%rsp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + fsubr %st(4), %st + faddp %st, %st(1) + fld %st(0) + fsubr %st(4), %st + fxch %st(2) + fmul %st(5), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fsubr %st, %st(4) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fmul %st(2), %st + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fsubrp %st, %st(3) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt 352(%rsp) + fmul %st(3), %st + fsubrp %st, %st(2) + fldt 336(%rsp) + fdivrp %st, %st(2) + addq $-32, %rsp + .cfi_def_cfa_offset 480 + fadd %st(1), %st + fstpt (%rsp) + fldt (%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) +..___tag_value_ctanhl.67: + call __libm_scalbl_k80@PLT +..___tag_value_ctanhl.68: +..B1.92: + addq $32, %rsp + .cfi_def_cfa_offset 448 +..B1.51: + fstpt 384(%rsp) + jmp ..B1.69 +..B1.52: + cmpq $0, 464(%rsp) + jne ..B1.54 +..B1.53: + movq 448(%rsp), %rbx + jmp ..B1.56 +..B1.54: + movzwl 472(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jge ..B1.60 +..B1.55: + movq 448(%rsp), %rbx + cmpl $32767, %edx + je ..B1.80 +..B1.56: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 464(%rsp) + fstpt (%rsp) + call tanhl@PLT +..B1.93: + addq $16, %rsp + .cfi_def_cfa_offset 448 + fstpt 368(%rsp) + testq %rbx, %rbx + jne ..B1.58 +..B1.57: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 480(%rsp) + fstpt (%rsp) + call tanl@PLT +..B1.94: + addq $16, %rsp + .cfi_def_cfa_offset 448 + fstpt 384(%rsp) + jmp ..B1.69 +..B1.58: + movzwl 472(%rsp), %eax + testl $32767, %eax + jle ..B1.79 +..B1.59: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 480(%rsp) + fstpt (%rsp) + call tanl@PLT +..B1.95: + addq $16, %rsp + .cfi_def_cfa_offset 448 + fldt 208(%rsp) + fmulp %st, %st(1) + fstpt 384(%rsp) + jmp ..B1.69 +..B1.60: + cmpl $32767, %edx + jge ..B1.62 +..B1.61: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 480(%rsp) + fstpt (%rsp) + call tanl@PLT +..B1.96: + addq $16, %rsp + .cfi_def_cfa_offset 448 + fstpt 368(%rsp) + fldt 368(%rsp) + fstpt 384(%rsp) + jmp ..B1.69 +..B1.62: + cmpl $-2147483648, 452(%rsp) + jne ..B1.64 +..B1.63: + cmpl $0, 448(%rsp) + je ..B1.65 +..B1.64: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 464(%rsp) + fstpt (%rsp) + call tanhl@PLT +..B1.97: + addq $16, %rsp + .cfi_def_cfa_offset 448 + fldt 464(%rsp) + fmul %st(1), %st + fstpt 384(%rsp) + fstpt 368(%rsp) + jmp ..B1.69 +..B1.65: + cmpl $-2147483648, 468(%rsp) + jne ..B1.67 +..B1.66: + cmpl $0, 464(%rsp) + je ..B1.68 +..B1.67: + fldt 464(%rsp) + fmul %st(0), %st + fstpt 464(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 464(%rsp) + fstpt (%rsp) + call tanhl@PLT +..B1.98: + addq $16, %rsp + .cfi_def_cfa_offset 448 + fldt 208(%rsp) + fstpt 384(%rsp) + fstpt 368(%rsp) + jmp ..B1.69 +..B1.68: + addq $-16, %rsp + .cfi_def_cfa_offset 464 + fldt 464(%rsp) + fstpt (%rsp) + call tanhl@PLT +..B1.99: + addq $16, %rsp + .cfi_def_cfa_offset 448 + lea ones(%rip), %rdx + movb 473(%rsp), %al + pxor %xmm0, %xmm0 + andb $-128, %al + fstpt 368(%rsp) + shrb $7, %al + movzbl %al, %ecx + mulsd (%rdx,%rcx,8), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 384(%rsp) +..B1.69: + testb %r15b, %r15b + je ..B1.71 +..B1.70: + fldcw 226(%rsp) +..B1.71: + movq 400(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.75 +..B1.72: + fldt 368(%rsp) + fldt 384(%rsp) + movq 400(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.74 +..B1.73: + addq $408, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 448 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.74: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.75: + call __stack_chk_fail@PLT +..B1.76: + movb 393(%rsp), %dl + movb 473(%rsp), %al + andb $127, %dl + andb $-128, %al + orb %al, %dl + jmp ..B1.18 +..B1.79: + fldt 464(%rsp) + fldt 208(%rsp) + fmulp %st, %st(1) + fstpt 384(%rsp) + jmp ..B1.69 +..B1.80: + movq $0x8000000000000000, %rax + cmpq %rax, %rbx + je ..B1.56 + jmp ..B1.60 +..B1.100: + fstp %st(0) + fstp %st(1) + jmp ..B1.36 + .align 16,0x90 + .cfi_endproc + .type ctanhl,@function + .size ctanhl,.-ctanhl + .data +# -- End ctanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,16 + .align 16 +t33: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type t33,@object + .size t33,32 + .align 16 +t32: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type t32,@object + .size t32,32 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ctanl.S b/external/sgx_libm/intel64/ctanl.S new file mode 100644 index 0000000000..d8053d5b13 --- /dev/null +++ b/external/sgx_libm/intel64/ctanl.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ctanl.c" + .text +..TXTST0: +# -- Begin ctanl + .text + .align 16,0x90 + .globl ctanl +ctanl: +# parameter 1: 144 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_ctanl.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + subq $128, %rsp + .cfi_def_cfa_offset 144 + xorb %r13b, %r13b + fldt .L_2il0floatpacket.8(%rip) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 112(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 96(%rsp) +..B1.2: + fnstcw 2(%rsp) +..B1.3: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.5: + fldcw (%rsp) +..B1.6: + movb $1, %r13b +..B1.7: + fldt 160(%rsp) + movzwl 168(%rsp), %eax + andl $32767, %eax + fstpt 80(%rsp) + cmpl $32767, %eax + fldt 144(%rsp) + fstpt 96(%rsp) + jl ..B1.9 +..B1.8: + movq $0x8000000000000000, %rax + cmpq 160(%rsp), %rax + jne ..B1.10 +..B1.9: + movb 169(%rsp), %al + notb %al + movb 89(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 89(%rsp) +..B1.10: + addq $-32, %rsp + .cfi_def_cfa_offset 176 + movq %rsp, %rdi + movq 112(%rsp), %rax + movq 120(%rsp), %rdx + movq 128(%rsp), %rcx + movq 136(%rsp), %rsi + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + movq %rcx, 16(%rdi) + movq %rsi, 24(%rdi) + call ctanhl@PLT +..B1.22: + fxch %st(1) + addq $32, %rsp + .cfi_def_cfa_offset 144 + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 24(%rsp), %eax + andl $32767, %eax + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + cmpl $32767, %eax + fstpt 48(%rsp) + fstpt 64(%rsp) + jl ..B1.12 +..B1.11: + movq $0x8000000000000000, %rax + cmpq 16(%rsp), %rax + jne ..B1.13 +..B1.12: + movb 25(%rsp), %al + notb %al + movb 73(%rsp), %dl + andb $-128, %al + andb $127, %dl + orb %al, %dl + movb %dl, 73(%rsp) +..B1.13: + testb %r13b, %r13b + je ..B1.15 +..B1.14: + fldcw 2(%rsp) +..B1.15: + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.19 +..B1.16: + fldt 48(%rsp) + fldt 64(%rsp) + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.18 +..B1.17: + addq $128, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + fxch %st(1) + ret + .cfi_def_cfa_offset 144 + .cfi_offset 13, -16 +..B1.18: + fstp %st(1) + fstp %st(0) + call __stack_chk_fail@PLT +..B1.19: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type ctanl,@function + .size ctanl,.-ctanl + .data +# -- End ctanl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/dpml_ux_bessel.S b/external/sgx_libm/intel64/dpml_ux_bessel.S new file mode 100644 index 0000000000..8720bdd8d5 --- /dev/null +++ b/external/sgx_libm/intel64/dpml_ux_bessel.S @@ -0,0 +1,8227 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_bessel.c" + .text +..TXTST0: +# -- Begin __dpml_ux_bessel__ + .text + .align 16,0x90 +__dpml_ux_bessel__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B1.1: + .cfi_startproc +..___tag_value___dpml_ux_bessel__.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $136, %rsp + .cfi_def_cfa_offset 192 + movq %rsi, %r13 + movq %fs:40, %rax + movq %rcx, %r14 + xorq %rsp, %rax + movq %rdx, %r15 + movq %rax, 120(%rsp) + movq %rdi, %rbp + cmpq $2, %r13 + jge ..B1.53 +..B1.2: + lea __bessel_x_table(%rip), %r10 + lea (%r13,%r15), %rbx + lea (%rbx,%rbx,2), %r11 + movl 4(%rbp), %ecx + cmpl $5, %ecx + movq 8(%rbp), %rax + jg ..B1.8 +..B1.3: + je ..B1.50 +..B1.4: + movq %r10, %rbx + addq 19552(%r10,%r11,8), %rbx + testl %ecx, %ecx + jl ..B1.23 +..B1.5: + negl %ecx + addl $5, %ecx + shrq %cl, %rax + jmp ..B1.6 +..B1.7: + movq 8(%rbx), %r10 + sarq $32, %r10 + andq $1023, %r10 + addq %r10, %rbx +..B1.6: + cmpq (%rbx), %rax + jbe ..B1.23 + jmp ..B1.7 +..B1.8: + xorl %edi, %edi + movq %rbp, %rsi + movl $2, %edx + lea 96(%rsp), %rcx +..___tag_value___dpml_ux_bessel__.16: + call __dpml_divide__@PLT +..___tag_value___dpml_ux_bessel__.17: +..B1.9: + testq %r13, %r13 + jne ..B1.11 +..B1.10: + movl $10, %ebx + lea 18168+__bessel_x_table(%rip), %rsi + lea 18504+__bessel_x_table(%rip), %r12 + jmp ..B1.12 +..B1.11: + movl $9, %ebx + lea 18872+__bessel_x_table(%rip), %rsi + lea 19208+__bessel_x_table(%rip), %r12 +..B1.12: + movl $9, %edx + lea 96(%rsp), %rdi + movq $0x1000000000000044, %rcx + lea (%rsp), %r8 +..___tag_value___dpml_ux_bessel__.18: + call __dpml_evaluate_rational__@PLT +..___tag_value___dpml_ux_bessel__.19: +..B1.13: + movq %r12, %rsi + lea 96(%rsp), %rdi + movq %rbx, %rdx + movl $70, %ecx + lea 24(%rsp), %r8 +..___tag_value___dpml_ux_bessel__.20: + call __dpml_evaluate_rational__@PLT +..___tag_value___dpml_ux_bessel__.21: +..B1.14: + movq %rbp, %rdi + lea (%r13,%r13), %rsi + negq %rsi + movl $3, %edx + incq %rsi + lea 48(%rsp), %rcx + subq %r15, %rsi +..___tag_value___dpml_ux_bessel__.22: + call __dpml_ux_sincos@PLT +..___tag_value___dpml_ux_bessel__.23: +..B1.15: + lea (%rsp), %rdi + movq %rdi, %rdx + lea 48(%rsp), %rsi +..___tag_value___dpml_ux_bessel__.24: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_bessel__.25: +..B1.16: + lea 24(%rsp), %rdi + movq %rdi, %rdx + lea 72(%rsp), %rsi +..___tag_value___dpml_ux_bessel__.26: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_bessel__.27: +..B1.17: + xorl %edx, %edx + movl $1, %eax + testq %r13, %r13 + lea (%rsp), %rdi + cmove %rax, %rdx + lea 24(%rsp), %rsi + movq %rdi, %rcx +..___tag_value___dpml_ux_bessel__.28: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_bessel__.29: +..B1.18: + movl $1, %esi + lea 96(%rsp), %rdi + lea 24(%rsp), %rdx +..___tag_value___dpml_ux_bessel__.30: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___dpml_ux_bessel__.31: +..B1.19: + movq %r14, %rdx + lea (%rsp), %rdi + lea 24(%rsp), %rsi +..___tag_value___dpml_ux_bessel__.32: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_bessel__.33: +..B1.20: + movq 120(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.47 +..B1.21: + addq $136, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.23: + movq 8(%rbx), %r12 + testq $8388608, %r12 + jne ..B1.25 +..B1.24: + movq %rbp, %r15 + jmp ..B1.28 +..B1.25: + movq 16(%rbx), %rax + movq %rbp, %rdi + movq %rax, 32(%rsp) + lea 24(%rsp), %rsi + movq 24(%rbx), %r10 + movl $1, %edx + movq %r10, 16(%rsi) + lea (%rsp), %rcx + movl $0, 24(%rcx) + movl 40(%rbx), %r15d + andl $7, %r15d + movl %r15d, 28(%rcx) +..___tag_value___dpml_ux_bessel__.54: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_bessel__.55: +..B1.26: + movq 32(%rbx), %rax + lea (%rsp), %rdi + movq %rax, 32(%rdi) + lea 24(%rsp), %rsi + movq 40(%rbx), %r10 + movl $1, %edx + movq %rdi, %rcx + addl $-128, %r15d + movq %r10, 16(%rsi) + movl %r15d, 4(%rsi) +..___tag_value___dpml_ux_bessel__.56: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_bessel__.57: +..B1.27: + lea (%rsp), %r15 +..B1.28: + movq %r12, %rdx + addq $48, %rbx + sarq $14, %rdx + andq $127, %rdx + testq $16777216, %r12 + je ..B1.30 +..B1.29: + movq %r12, %rcx + movl $1, %eax + shrq $7, %rcx + movq %r12, %r8 + andq $127, %r8 + movq %r15, %rdi + shlq %cl, %rax + movq %rdx, %rsi + decq %rax + movq %rbx, %rdx + movq %rax, %rcx + movq %r14, %r9 +..___tag_value___dpml_ux_bessel__.58: + call __dpml_evaluate_packed_poly__@PLT +..___tag_value___dpml_ux_bessel__.59: + jmp ..B1.31 +..B1.30: + movq %r15, %rdi + movq %rbx, %rsi + movq %r12, %rcx + movq %r14, %r8 +..___tag_value___dpml_ux_bessel__.60: + call __dpml_evaluate_rational__@PLT +..___tag_value___dpml_ux_bessel__.61: +..B1.31: + movq %r12, %rdx + sarq $11, %rdx + andq $3, %rdx + je ..B1.33 +..B1.32: + decq %rdx + lea 24(%r14), %rsi + movq %r14, %rdi + movq %r14, %rcx +..___tag_value___dpml_ux_bessel__.62: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_bessel__.63: +..B1.33: + testq $4194304, %r12 + je ..B1.35 +..B1.34: + movq %r15, %rdi + movq %r14, %rsi + movq %r14, %rdx +..___tag_value___dpml_ux_bessel__.64: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_bessel__.65: +..B1.35: + testq $8192, %r12 + je ..B1.37 +..B1.36: + movslq (%r14), %rax + btcq $31, %rax + movl %eax, (%r14) +..B1.37: + testq $2097152, %r12 + je ..B1.45 +..B1.38: + cmpq %rbp, %r15 + jne ..B1.40 +..B1.39: + sarq $58, %r12 + subl %r12d, 4(%rbp) +..B1.40: + cmpq $1, %r13 + je ..B1.48 +..B1.41: + movq %rbp, %rdi + lea 19664+__bessel_x_table(%rip), %rsi + lea (%rsp), %rdx +..___tag_value___dpml_ux_bessel__.66: + call __dpml_ux_log__@PLT +..___tag_value___dpml_ux_bessel__.67: +..B1.42: + movq %rbp, %rdi + movq %r13, %rsi + xorl %edx, %edx + lea 24(%rsp), %rcx +..___tag_value___dpml_ux_bessel__.68: + call __dpml_ux_bessel__ +..___tag_value___dpml_ux_bessel__.69: +..B1.43: + lea (%rsp), %rsi + movq %rsi, %rdx + lea 24(%rsp), %rdi +..___tag_value___dpml_ux_bessel__.70: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_bessel__.71: +..B1.44: + movq %r14, %rsi + lea (%rsp), %rdi + movl $1, %edx + movq %r14, %rcx +..___tag_value___dpml_ux_bessel__.72: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_bessel__.73: +..B1.45: + movq 120(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + je ..B1.21 +..B1.47: + call __stack_chk_fail@PLT +..B1.48: + lea 19640+__bessel_x_table(%rip), %rdi + movq %rbp, %rsi + movl $2, %edx + lea 24(%rsp), %rcx +..___tag_value___dpml_ux_bessel__.74: + call __dpml_divide__@PLT +..___tag_value___dpml_ux_bessel__.75: +..B1.49: + movq %r14, %rdi + lea 24(%rsp), %rsi + xorl %edx, %edx + movq %r14, %rcx +..___tag_value___dpml_ux_bessel__.76: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_bessel__.77: + jmp ..B1.41 +..B1.50: + cmpq 19544(%r10,%r11,8), %rax + ja ..B1.8 +..B1.51: + movq %r10, %rbx + addq 19552(%r10,%r11,8), %rbx + jmp ..B1.5 +..B1.53: + movq %rbp, %rdi + movq %r13, %rsi + movq %r15, %rdx + movq %r14, %rcx +..___tag_value___dpml_ux_bessel__.78: + call __dpml_ux_large_order_bessel__ +..___tag_value___dpml_ux_bessel__.79: +..B1.54: + movq 120(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.47 + jmp ..B1.21 + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_bessel__,@function + .size __dpml_ux_bessel__,.-__dpml_ux_bessel__ + .data +# -- End __dpml_ux_bessel__ + .text +# -- Begin __dpml_ux_large_order_bessel__ + .text + .align 16,0x90 +__dpml_ux_large_order_bessel__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B2.1: + .cfi_startproc +..___tag_value___dpml_ux_large_order_bessel__.81: +..L82: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $184, %rsp + .cfi_def_cfa_offset 240 + movq %rdi, %r13 + movq %rcx, %rbx + movq %rdx, %r15 + movq %rsi, %rbp + xorl %edi, %edi + movq %r13, %rsi + movl $2, %edx + movq %fs:40, %rax + lea 120(%rsp), %rcx + xorq %rsp, %rax + movq %rax, 48(%rcx) +..___tag_value___dpml_ux_large_order_bessel__.96: + call __dpml_divide__@PLT +..___tag_value___dpml_ux_large_order_bessel__.97: +..B2.2: + movl $2, %esi + lea 48(%rsp), %rax + movq %rax, %rdi + lea 72(%rsp), %r14 + movq %rax, -8(%rax) + lea 96(%rsp), %r12 + movq %rbp, 8(%rax) +..___tag_value___dpml_ux_large_order_bessel__.98: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_large_order_bessel__.99: +..B2.57: + movq %rax, %rcx +..B2.3: + movl 4(%r13), %r10d + negq %rcx + movslq %r10d, %r8 + addq $64, %rcx + negq %r8 + pxor %xmm0, %xmm0 + addq %rcx, %r8 + pxor %xmm1, %xmm1 + cvtsi2sdq %r8, %xmm0 + cvtsi2sdq %rcx, %xmm1 + subsd .L_2il0floatpacket.97(%rip), %xmm0 + subsd .L_2il0floatpacket.98(%rip), %xmm1 + pxor %xmm2, %xmm2 + movq %rcx, %rax + cvtsi2sdq %rbp, %xmm2 + mulsd .L_2il0floatpacket.96(%rip), %xmm1 + mulsd %xmm0, %xmm2 + negq %rax + subsd %xmm1, %xmm2 + incq %rax + pxor %xmm1, %xmm1 + cvtsi2sdq %rax, %xmm1 + cmpq $2, %r15 + subsd %xmm2, %xmm1 + je ..B2.53 +..B2.4: + movsd .L_2il0floatpacket.100(%rip), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B2.8 +..B2.5: + movl $-65536, %edx + xorl %eax, %eax +..B2.6: + movl %eax, (%rbx) + movq $0x8000000000000000, %rax + movl %edx, 4(%rbx) + movq %rax, 8(%rbx) + movq $0, 16(%rbx) + movq 168(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B2.32 +..B2.7: + addq $184, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 240 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.8: + negq %rcx + movq 8(%r13), %r9 + movq %r9, %rax + shrq %cl, %rax + testq %r8, %r8 + jle ..B2.38 +..B2.9: + shrq $1, %r9 + pxor %xmm0, %xmm0 + cvtsi2ssq %r9, %xmm0 + movss %xmm0, 32(%rsp) + pxor %xmm0, %xmm0 + cvtsi2ssq %rbp, %xmm0 + movss %xmm0, 16(%rsp) + movl %r10d, (%rsp) +..___tag_value___dpml_ux_large_order_bessel__.120: + call log2f@PLT +..___tag_value___dpml_ux_large_order_bessel__.121: +..B2.58: + movl (%rsp), %r10d + movss %xmm0, 8(%rsp) +..B2.10: + movss .L_2il0floatpacket.101(%rip), %xmm0 + mulss 8(%rsp), %xmm0 + movss .L_2il0floatpacket.108(%rip), %xmm1 + movl %r10d, (%rsp) + addss .L_2il0floatpacket.102(%rip), %xmm0 + addss 16(%rsp), %xmm1 + addss %xmm0, %xmm1 + movss 32(%rsp), %xmm0 + movss %xmm1, 24(%rsp) +..___tag_value___dpml_ux_large_order_bessel__.122: + call log2f@PLT +..___tag_value___dpml_ux_large_order_bessel__.123: +..B2.59: + movl (%rsp), %r10d + movss %xmm0, 32(%rsp) +..B2.11: + addl $-64, %r10d + pxor %xmm0, %xmm0 + cvtsi2ss %r10d, %xmm0 + movss 32(%rsp), %xmm3 + pxor %xmm1, %xmm1 + pxor %xmm4, %xmm4 + addss %xmm0, %xmm3 + cvtss2sd 16(%rsp), %xmm4 + addss .L_2il0floatpacket.103(%rip), %xmm3 + movss %xmm3, 32(%rsp) + cvtss2sd %xmm3, %xmm1 + subss 8(%rsp), %xmm3 + movsd .L_2il0floatpacket.96(%rip), %xmm2 + cvtss2sd %xmm3, %xmm3 + mulsd %xmm2, %xmm1 + addsd %xmm2, %xmm4 + movsd .L_2il0floatpacket.104(%rip), %xmm5 + mulsd %xmm3, %xmm4 + subsd %xmm1, %xmm5 + movss 24(%rsp), %xmm0 + subsd %xmm4, %xmm5 + cvtsd2ss %xmm5, %xmm5 + movss %xmm5, (%rsp) +..___tag_value___dpml_ux_large_order_bessel__.124: + call log2f@PLT +..___tag_value___dpml_ux_large_order_bessel__.125: +..B2.12: + pxor %xmm2, %xmm2 + pxor %xmm1, %xmm1 + cvtss2sd %xmm0, %xmm2 + cvtss2sd (%rsp), %xmm1 + subss 32(%rsp), %xmm0 + mulsd .L_2il0floatpacket.105(%rip), %xmm2 + cvtss2sd %xmm0, %xmm0 + addsd %xmm1, %xmm2 + divsd %xmm0, %xmm2 + cvtsd2ss %xmm2, %xmm2 + movss 24(%rsp), %xmm0 + movsd %xmm1, 16(%rsp) + addss %xmm2, %xmm0 + cvtss2sd %xmm0, %xmm0 + mulsd .L_2il0floatpacket.96(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 8(%rsp) +..___tag_value___dpml_ux_large_order_bessel__.126: + call log2f@PLT +..___tag_value___dpml_ux_large_order_bessel__.127: +..B2.61: + movsd 16(%rsp), %xmm1 +..B2.13: + pxor %xmm2, %xmm2 + cvtss2sd %xmm0, %xmm2 + subss 32(%rsp), %xmm0 + mulsd .L_2il0floatpacket.105(%rip), %xmm2 + cvtss2sd %xmm0, %xmm0 + addsd %xmm1, %xmm2 + divsd %xmm0, %xmm2 + cvtsd2ss %xmm2, %xmm2 + movss 8(%rsp), %xmm0 + movsd %xmm1, 16(%rsp) + addss %xmm2, %xmm0 + cvtss2sd %xmm0, %xmm0 + mulsd .L_2il0floatpacket.96(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, (%rsp) +..___tag_value___dpml_ux_large_order_bessel__.128: + call log2f@PLT +..___tag_value___dpml_ux_large_order_bessel__.129: +..B2.62: + movsd 16(%rsp), %xmm1 + movaps %xmm0, %xmm3 +..B2.14: + pxor %xmm2, %xmm2 + movq $0x8000000000000000, %r13 + cvtss2sd %xmm3, %xmm2 + subss 32(%rsp), %xmm3 + movsd .L_2il0floatpacket.105(%rip), %xmm0 + xorl %r8d, %r8d + mulsd %xmm2, %xmm0 + xorl %r9d, %r9d + cvtss2sd %xmm3, %xmm3 + addsd %xmm0, %xmm1 + divsd %xmm3, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss (%rsp), %xmm4 + movsd .L_2il0floatpacket.96(%rip), %xmm5 + addss %xmm1, %xmm4 + cvtss2sd %xmm4, %xmm4 + mulsd %xmm4, %xmm5 + cvtsd2ss %xmm5, %xmm5 + cvtss2sd %xmm5, %xmm5 + movsd .L_2il0floatpacket.109(%rip), %xmm7 + movaps %xmm7, %xmm6 + addsd .L_2il0floatpacket.106(%rip), %xmm5 + comisd %xmm7, %xmm5 + cmplesd %xmm5, %xmm6 + movaps %xmm5, %xmm8 + movd %xmm6, %r15 + subsd %xmm7, %xmm8 + jae ..L130 + movaps %xmm5, %xmm8 +..L130: + cvttsd2si %xmm8, %rax + andq %r13, %r15 + addq %r15, %rax + lea 1(%rbp), %r15 + cmpq %r15, %rax + movl %r8d, 48(%rsp) + cmova %rax, %r15 + movl $-262144, 52(%rsp) + testq $1, %r15 + movq %r9, 56(%rsp) + movq %r9, 64(%rsp) + movl %r8d, 72(%rsp) + movl $1, 76(%rsp) + movq %r13, 80(%rsp) + movq %r9, 88(%rsp) + movl %r8d, 8(%rsp) + je ..B2.16 +..B2.15: + movl $-262144, 12(%rsp) + movq %r9, 16(%rsp) + movq %r9, 24(%rsp) + jmp ..B2.17 +..B2.16: + movl $1, 12(%rsp) + movq %r13, 16(%rsp) + movq $0, 24(%rsp) +..B2.17: + movl $2, %esi + lea 144(%rsp), %rdi + lea (%r15,%r15), %rax + movq %rax, 8(%rdi) +..___tag_value___dpml_ux_large_order_bessel__.131: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_large_order_bessel__.132: +..B2.18: + movl 148(%rsp), %ecx + movq %r13, %rax + addl $62, %ecx + shrq %cl, %rax + movq %rbp, (%rsp) + movq %rax, %r13 + movq 40(%rsp), %rbp +..B2.19: + movq %r12, %rdx + lea 120(%rsp), %rdi + lea 144(%rsp), %rsi +..___tag_value___dpml_ux_large_order_bessel__.133: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_large_order_bessel__.134: +..B2.20: + movq %r14, %rdi + movq %r12, %rsi + movq %r12, %rdx +..___tag_value___dpml_ux_large_order_bessel__.135: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_large_order_bessel__.136: +..B2.21: + movq %r12, %rdi + xorl %esi, %esi +..___tag_value___dpml_ux_large_order_bessel__.137: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_large_order_bessel__.138: +..B2.22: + movq %rbp, %rdi + xorl %esi, %esi +..___tag_value___dpml_ux_large_order_bessel__.139: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_large_order_bessel__.140: +..B2.23: + movq %r12, %rdi + movq %rbp, %rsi + movl $1, %edx + movq %r12, %rcx +..___tag_value___dpml_ux_large_order_bessel__.141: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_large_order_bessel__.142: +..B2.24: + decq %r15 + je ..B2.33 +..B2.25: + cmpq (%rsp), %r15 + jne ..B2.27 +..B2.26: + movl (%r12), %r8d + movl 4(%r12), %r9d + movq 8(%r12), %r10 + movq 16(%r12), %r11 + movl %r8d, (%rbx) + movl %r9d, 4(%rbx) + movq %r10, 8(%rbx) + movq %r11, 16(%rbx) +..B2.27: + testq $1, %r15 + jne ..B2.29 +..B2.28: + movq %r12, %rsi + lea 8(%rsp), %rdi + xorl %edx, %edx + movq %rdi, %rcx +..___tag_value___dpml_ux_large_order_bessel__.143: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_large_order_bessel__.144: +..B2.29: + movq %rbp, %r8 + movq %r14, %rbp + movq %r12, %r14 + movq %r8, %r12 + movq 152(%rsp), %r8 + movq $0x8000000000000000, %r9 + subq %r13, %r8 + cmpq %r9, %r8 + jae ..B2.31 +..B2.30: + decl 148(%rsp) + addq %r8, %r8 + addq %r13, %r13 +..B2.31: + movq %r8, 152(%rsp) + jmp ..B2.19 +..B2.32: + call __stack_chk_fail@PLT +..B2.33: + movq %r12, %rdi + lea 8(%rsp), %rsi + xorl %edx, %edx + movq %rsi, %rcx + incl 4(%rsi) +..___tag_value___dpml_ux_large_order_bessel__.145: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_large_order_bessel__.146: +..B2.34: + movq %rbx, %rdi + lea 8(%rsp), %rsi + movl $2, %edx + movq %rbx, %rcx +..___tag_value___dpml_ux_large_order_bessel__.147: + call __dpml_divide__@PLT +..___tag_value___dpml_ux_large_order_bessel__.148: +..B2.35: + movq 168(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.32 + jmp ..B2.7 +..B2.38: + jne ..B2.40 +..B2.39: + cmpq %rbp, %rax + jb ..B2.9 +..B2.40: + movq %r13, %rdi + xorl %esi, %esi + movq %r15, %rdx + lea 48(%rsp), %rcx +..___tag_value___dpml_ux_large_order_bessel__.149: + call __dpml_ux_bessel__ +..___tag_value___dpml_ux_large_order_bessel__.150: +..B2.41: + movq %r13, %rdi + movl $1, %esi + movq %r15, %rdx + movq %r14, %rcx +..___tag_value___dpml_ux_large_order_bessel__.151: + call __dpml_ux_bessel__ +..___tag_value___dpml_ux_large_order_bessel__.152: +..B2.42: + movq $0x8000000000000000, %r15 + decq %rbp + movq %rbx, (%rsp) + movq %r15, %r13 + movl $0, 144(%rsp) + movl $2, 148(%rsp) + movq %r15, 152(%rsp) + movq $0, 160(%rsp) + movq 40(%rsp), %rbx +..B2.43: + movq %r12, %rdx + lea 120(%rsp), %rdi + lea 144(%rsp), %rsi +..___tag_value___dpml_ux_large_order_bessel__.153: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_large_order_bessel__.154: +..B2.44: + movq %r14, %rdi + movq %r12, %rsi + movq %r12, %rdx +..___tag_value___dpml_ux_large_order_bessel__.155: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_large_order_bessel__.156: +..B2.45: + movq %r12, %rdi + movq %rbx, %rsi + movl $1, %edx + movq %r12, %rcx +..___tag_value___dpml_ux_large_order_bessel__.157: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_large_order_bessel__.158: +..B2.46: + decq %rbp + testq %rbp, %rbp + jle ..B2.50 +..B2.47: + movq %rbx, %rax + movq %r14, %rbx + movq %r12, %r14 + movq %rax, %r12 + movq 152(%rsp), %rax + addq %r13, %rax + cmpq %r13, %rax + jae ..B2.49 +..B2.48: + shrq $1, %rax + incl 148(%rsp) + addq %r15, %rax + shrq $1, %r13 +..B2.49: + movq %rax, 152(%rsp) + jmp ..B2.43 +..B2.50: + movq (%rsp), %rbx + movl (%r12), %eax + movl 4(%r12), %ebp + movq 8(%r12), %r8 + movq 16(%r12), %rdx + movl %eax, (%rbx) + movl %ebp, 4(%rbx) + movq %r8, 8(%rbx) + movq %rdx, 16(%rbx) + movq 168(%rsp), %rcx + xorq %rsp, %rcx + cmpq %fs:40, %rcx + jne ..B2.32 + jmp ..B2.7 +..B2.53: + comisd .L_2il0floatpacket.99(%rip), %xmm2 + jbe ..B2.40 +..B2.54: + movl $65536, %edx + movq $0x080000000, %rax + jmp ..B2.6 + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_large_order_bessel__,@function + .size __dpml_ux_large_order_bessel__,.-__dpml_ux_large_order_bessel__ + .data +# -- End __dpml_ux_large_order_bessel__ + .text +# -- Begin __j0q + .text + .align 16,0x90 + .globl __j0q +__j0q: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___j0q.160: +..L161: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + subq $368, %rsp + .cfi_def_cfa_offset 400 + xorl %esi, %esi + lea __bessel_x_table(%rip), %rcx + lea 48(%rsp), %rdi + movq %fs:40, %rax + lea 304(%rsp), %rdx + xorq %rsp, %rax + lea 336(%rsp), %r8 + movaps %xmm0, (%rdi) + lea (%rsp), %r9 + movq %rax, 48(%rdx) + movq $1, -40(%rdi) + movq $0, (%r9) +..___tag_value___j0q.169: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___j0q.170: +..B3.2: + testq %rax, %rax + jl ..B3.20 +..B3.4: + movl 308(%rsp), %ecx + lea 19544+__bessel_x_table(%rip), %rdi + movq 312(%rsp), %rax + cmpl $5, %ecx + movl $0, 304(%rsp) + jg ..B3.10 +..B3.5: + je ..B3.44 +..B3.6: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + testl %ecx, %ecx + jl ..B3.23 +..B3.7: + negl %ecx + addl $5, %ecx + shrq %cl, %rax + jmp ..B3.8 +..B3.9: + movq 8(%rbx), %rcx + sarq $32, %rcx + andq $1023, %rcx + addq %rcx, %rbx +..B3.8: + cmpq (%rbx), %rax + jbe ..B3.23 + jmp ..B3.9 +..B3.10: + xorl %edi, %edi + lea 304(%rsp), %rsi + movl $2, %edx + lea 160(%rsp), %rcx +..___tag_value___j0q.171: + call __dpml_divide__@PLT +..___tag_value___j0q.172: +..B3.11: + lea 18168+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $9, %edx + movq $0x1000000000000044, %rcx + lea 64(%rsp), %r8 +..___tag_value___j0q.173: + call __dpml_evaluate_rational__@PLT +..___tag_value___j0q.174: +..B3.12: + lea 18504+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $10, %edx + movl $70, %ecx + lea 88(%rsp), %r8 +..___tag_value___j0q.175: + call __dpml_evaluate_rational__@PLT +..___tag_value___j0q.176: +..B3.13: + movl $1, %esi + lea 304(%rsp), %rdi + movl $3, %edx + lea 112(%rsp), %rcx +..___tag_value___j0q.177: + call __dpml_ux_sincos@PLT +..___tag_value___j0q.178: +..B3.14: + lea 64(%rsp), %rdi + movq %rdi, %rdx + lea 112(%rsp), %rsi +..___tag_value___j0q.179: + call __dpml_multiply__@PLT +..___tag_value___j0q.180: +..B3.15: + lea 88(%rsp), %rdi + movq %rdi, %rdx + lea 136(%rsp), %rsi +..___tag_value___j0q.181: + call __dpml_multiply__@PLT +..___tag_value___j0q.182: +..B3.16: + movl $1, %edx + lea 64(%rsp), %rdi + movq %rdi, %rcx + lea 88(%rsp), %rsi +..___tag_value___j0q.183: + call __dpml_addsub__@PLT +..___tag_value___j0q.184: +..B3.17: + movl $1, %esi + lea 160(%rsp), %rdi + lea 88(%rsp), %rdx +..___tag_value___j0q.185: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___j0q.186: +..B3.18: + lea 64(%rsp), %rdi + lea 88(%rsp), %rsi + lea 256(%rsp), %rdx +..___tag_value___j0q.187: + call __dpml_multiply__@PLT +..___tag_value___j0q.188: +..B3.19: + xorl %edx, %edx + lea 256(%rsp), %rdi + xorl %ecx, %ecx + lea 336(%rsp), %rsi + lea (%rsp), %r8 +..___tag_value___j0q.189: + call __dpml_pack__@PLT +..___tag_value___j0q.190: +..B3.20: + movq 352(%rsp), %rax + xorq %rsp, %rax + movaps 336(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B3.46 +..B3.21: + addq $368, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 400 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B3.23: + movq 8(%rbx), %r14 + testq $8388608, %r14 + jne ..B3.25 +..B3.24: + lea 304(%rsp), %r15 + jmp ..B3.28 +..B3.25: + movq 16(%rbx), %rax + lea 304(%rsp), %rdi + movq %rax, -88(%rdi) + lea 208(%rsp), %rsi + movq 24(%rbx), %r8 + movl $1, %edx + movq %r8, 16(%rsi) + lea 184(%rsp), %rcx + movl $0, 24(%rcx) + movl 40(%rbx), %r15d + andl $7, %r15d + movl %r15d, 28(%rcx) +..___tag_value___j0q.202: + call __dpml_addsub__@PLT +..___tag_value___j0q.203: +..B3.26: + movq 32(%rbx), %rax + lea 184(%rsp), %rdi + movq %rax, 32(%rdi) + lea 208(%rsp), %rsi + movq 40(%rbx), %r8 + movl $1, %edx + movq %rdi, %rcx + addl $-128, %r15d + movq %r8, 16(%rsi) + movl %r15d, 4(%rsi) +..___tag_value___j0q.204: + call __dpml_addsub__@PLT +..___tag_value___j0q.205: +..B3.27: + lea 184(%rsp), %r15 +..B3.28: + movq %r14, %rdx + addq $48, %rbx + sarq $14, %rdx + andq $127, %rdx + testq $16777216, %r14 + je ..B3.30 +..B3.29: + movq %r14, %rcx + movl $1, %eax + shrq $7, %rcx + movq %r14, %r8 + andq $127, %r8 + movq %r15, %rdi + shlq %cl, %rax + movq %rdx, %rsi + decq %rax + movq %rbx, %rdx + movq %rax, %rcx + lea 256(%rsp), %r9 +..___tag_value___j0q.206: + call __dpml_evaluate_packed_poly__@PLT +..___tag_value___j0q.207: + jmp ..B3.31 +..B3.30: + movq %r15, %rdi + movq %rbx, %rsi + movq %r14, %rcx + lea 256(%rsp), %r8 +..___tag_value___j0q.208: + call __dpml_evaluate_rational__@PLT +..___tag_value___j0q.209: +..B3.31: + movq %r14, %rdx + sarq $11, %rdx + andq $3, %rdx + je ..B3.33 +..B3.32: + decq %rdx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 280(%rsp), %rsi +..___tag_value___j0q.210: + call __dpml_addsub__@PLT +..___tag_value___j0q.211: +..B3.33: + testq $4194304, %r14 + je ..B3.35 +..B3.34: + movq %r15, %rdi + lea 256(%rsp), %rsi + movq %rsi, %rdx +..___tag_value___j0q.212: + call __dpml_multiply__@PLT +..___tag_value___j0q.213: +..B3.35: + testq $8192, %r14 + je ..B3.37 +..B3.36: + movslq 256(%rsp), %rax + btcq $31, %rax + movl %eax, 256(%rsp) +..B3.37: + testq $2097152, %r14 + je ..B3.19 +..B3.38: + lea 304(%rsp), %rax + cmpq %rax, %r15 + jne ..B3.40 +..B3.39: + sarq $58, %r14 + subl %r14d, 308(%rsp) +..B3.40: + lea 19664+__bessel_x_table(%rip), %rsi + lea 304(%rsp), %rdi + lea 184(%rsp), %rdx +..___tag_value___j0q.214: + call __dpml_ux_log__@PLT +..___tag_value___j0q.215: +..B3.41: + xorl %esi, %esi + lea 304(%rsp), %rdi + xorl %edx, %edx + lea 208(%rsp), %rcx +..___tag_value___j0q.216: + call __dpml_ux_bessel__ +..___tag_value___j0q.217: +..B3.42: + lea 184(%rsp), %rsi + movq %rsi, %rdx + lea 208(%rsp), %rdi +..___tag_value___j0q.218: + call __dpml_multiply__@PLT +..___tag_value___j0q.219: +..B3.43: + movl $1, %edx + lea 256(%rsp), %rsi + movq %rsi, %rcx + lea 184(%rsp), %rdi +..___tag_value___j0q.220: + call __dpml_addsub__@PLT +..___tag_value___j0q.221: + jmp ..B3.19 +..B3.44: + cmpq (%rdi), %rax + ja ..B3.10 +..B3.45: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + jmp ..B3.7 +..B3.46: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __j0q,@function + .size __j0q,.-__j0q + .data +# -- End __j0q + .text +# -- Begin __j1q + .text + .align 16,0x90 + .globl __j1q +__j1q: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value___j1q.223: +..L224: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + pushq %rbp + .cfi_def_cfa_offset 40 + .cfi_offset 6, -40 + subq $360, %rsp + .cfi_def_cfa_offset 400 + xorl %esi, %esi + movaps %xmm0, 48(%rsp) + lea 48(%rsp), %rdi + movq 8(%rdi), %rbp + lea 304(%rsp), %rdx + shrq $32, %rbp + lea 8+__bessel_x_table(%rip), %rcx + movq %fs:40, %rax + lea 336(%rsp), %r8 + xorq %rsp, %rax + lea (%rsp), %r9 + movq %rax, 48(%rdx) + andl $-2147483648, %ebp + movq $1, -40(%rdi) + movq $0, (%r9) +..___tag_value___j1q.234: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___j1q.235: +..B4.2: + testq %rax, %rax + jge ..B4.4 +..B4.3: + movq $0x7fff000000000000, %rax + movslq %ebp, %rbp + movq %rax, %rdx + movq 344(%rsp), %rcx + andq %rcx, %rdx + shlq $32, %rbp + orq %rcx, %rbp + cmpq %rdx, %rax + cmovne %rbp, %rcx + movq %rcx, 344(%rsp) + jmp ..B4.20 +..B4.4: + movl 308(%rsp), %ecx + lea 19568+__bessel_x_table(%rip), %rdi + movq 312(%rsp), %rax + cmpl $5, %ecx + movl $0, 304(%rsp) + jg ..B4.10 +..B4.5: + je ..B4.46 +..B4.6: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + testl %ecx, %ecx + jl ..B4.23 +..B4.7: + negl %ecx + addl $5, %ecx + shrq %cl, %rax + jmp ..B4.8 +..B4.9: + movq 8(%rbx), %rcx + sarq $32, %rcx + andq $1023, %rcx + addq %rcx, %rbx +..B4.8: + cmpq (%rbx), %rax + jbe ..B4.23 + jmp ..B4.9 +..B4.10: + xorl %edi, %edi + lea 304(%rsp), %rsi + movl $2, %edx + lea 160(%rsp), %rcx +..___tag_value___j1q.236: + call __dpml_divide__@PLT +..___tag_value___j1q.237: +..B4.11: + lea 18872+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $9, %edx + movq $0x1000000000000044, %rcx + lea 64(%rsp), %r8 +..___tag_value___j1q.238: + call __dpml_evaluate_rational__@PLT +..___tag_value___j1q.239: +..B4.12: + lea 19208+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $9, %edx + movl $70, %ecx + lea 88(%rsp), %r8 +..___tag_value___j1q.240: + call __dpml_evaluate_rational__@PLT +..___tag_value___j1q.241: +..B4.13: + movq $-1, %rsi + lea 304(%rsp), %rdi + movl $3, %edx + lea 112(%rsp), %rcx +..___tag_value___j1q.242: + call __dpml_ux_sincos@PLT +..___tag_value___j1q.243: +..B4.14: + lea 64(%rsp), %rdi + movq %rdi, %rdx + lea 112(%rsp), %rsi +..___tag_value___j1q.244: + call __dpml_multiply__@PLT +..___tag_value___j1q.245: +..B4.15: + lea 88(%rsp), %rdi + movq %rdi, %rdx + lea 136(%rsp), %rsi +..___tag_value___j1q.246: + call __dpml_multiply__@PLT +..___tag_value___j1q.247: +..B4.16: + xorl %edx, %edx + lea 64(%rsp), %rdi + movq %rdi, %rcx + lea 88(%rsp), %rsi +..___tag_value___j1q.248: + call __dpml_addsub__@PLT +..___tag_value___j1q.249: +..B4.17: + movl $1, %esi + lea 160(%rsp), %rdi + lea 88(%rsp), %rdx +..___tag_value___j1q.250: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___j1q.251: +..B4.18: + lea 64(%rsp), %rdi + lea 88(%rsp), %rsi + lea 256(%rsp), %rdx +..___tag_value___j1q.252: + call __dpml_multiply__@PLT +..___tag_value___j1q.253: +..B4.19: + movl $8, %eax + xorl %ecx, %ecx + xorl %ebp, 256(%rsp) + cmovne %eax, %ecx + movl $513, %ebx + lea __bessel_error_codes(%rip), %r8 + shrq %cl, %rbx + lea 256(%rsp), %rdi + movzbl %bl, %ebp + lea 336(%rsp), %rsi + movq (%r8), %rcx + movq (%r8,%rbp,8), %rdx + lea (%rsp), %r8 +..___tag_value___j1q.254: + call __dpml_pack__@PLT +..___tag_value___j1q.255: +..B4.20: + movq 352(%rsp), %rax + xorq %rsp, %rax + movaps 336(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B4.48 +..B4.21: + addq $360, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 400 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 15, -24 +..B4.23: + movq 8(%rbx), %r12 + testq $8388608, %r12 + jne ..B4.25 +..B4.24: + lea 304(%rsp), %r15 + jmp ..B4.28 +..B4.25: + movq 16(%rbx), %rax + lea 304(%rsp), %rdi + movq %rax, -88(%rdi) + lea 208(%rsp), %rsi + movq 24(%rbx), %r8 + movl $1, %edx + movq %r8, 16(%rsi) + lea 184(%rsp), %rcx + movl $0, 24(%rcx) + movl 40(%rbx), %r15d + andl $7, %r15d + movl %r15d, 28(%rcx) +..___tag_value___j1q.270: + call __dpml_addsub__@PLT +..___tag_value___j1q.271: +..B4.26: + movq 32(%rbx), %rax + lea 184(%rsp), %rdi + movq %rax, 32(%rdi) + lea 208(%rsp), %rsi + movq 40(%rbx), %r8 + movl $1, %edx + movq %rdi, %rcx + addl $-128, %r15d + movq %r8, 16(%rsi) + movl %r15d, 4(%rsi) +..___tag_value___j1q.272: + call __dpml_addsub__@PLT +..___tag_value___j1q.273: +..B4.27: + lea 184(%rsp), %r15 +..B4.28: + movq %r12, %rdx + addq $48, %rbx + sarq $14, %rdx + andq $127, %rdx + testq $16777216, %r12 + je ..B4.30 +..B4.29: + movq %r12, %rcx + movl $1, %eax + shrq $7, %rcx + movq %r12, %r8 + andq $127, %r8 + movq %r15, %rdi + shlq %cl, %rax + movq %rdx, %rsi + decq %rax + movq %rbx, %rdx + movq %rax, %rcx + lea 256(%rsp), %r9 +..___tag_value___j1q.274: + call __dpml_evaluate_packed_poly__@PLT +..___tag_value___j1q.275: + jmp ..B4.31 +..B4.30: + movq %r15, %rdi + movq %rbx, %rsi + movq %r12, %rcx + lea 256(%rsp), %r8 +..___tag_value___j1q.276: + call __dpml_evaluate_rational__@PLT +..___tag_value___j1q.277: +..B4.31: + movq %r12, %rdx + sarq $11, %rdx + andq $3, %rdx + je ..B4.33 +..B4.32: + decq %rdx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 280(%rsp), %rsi +..___tag_value___j1q.278: + call __dpml_addsub__@PLT +..___tag_value___j1q.279: +..B4.33: + testq $4194304, %r12 + je ..B4.35 +..B4.34: + movq %r15, %rdi + lea 256(%rsp), %rsi + movq %rsi, %rdx +..___tag_value___j1q.280: + call __dpml_multiply__@PLT +..___tag_value___j1q.281: +..B4.35: + testq $8192, %r12 + je ..B4.37 +..B4.36: + movslq 256(%rsp), %rax + btcq $31, %rax + movl %eax, 256(%rsp) +..B4.37: + testq $2097152, %r12 + je ..B4.19 +..B4.38: + lea 304(%rsp), %rax + cmpq %rax, %r15 + jne ..B4.40 +..B4.39: + sarq $58, %r12 + subl %r12d, 308(%rsp) +..B4.40: + lea 19640+__bessel_x_table(%rip), %rdi + lea 304(%rsp), %rsi + movl $2, %edx + lea 208(%rsp), %rcx +..___tag_value___j1q.282: + call __dpml_divide__@PLT +..___tag_value___j1q.283: +..B4.41: + xorl %edx, %edx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 208(%rsp), %rsi +..___tag_value___j1q.284: + call __dpml_addsub__@PLT +..___tag_value___j1q.285: +..B4.42: + lea 19664+__bessel_x_table(%rip), %rsi + lea 304(%rsp), %rdi + lea 184(%rsp), %rdx +..___tag_value___j1q.286: + call __dpml_ux_log__@PLT +..___tag_value___j1q.287: +..B4.43: + movl $1, %esi + lea 304(%rsp), %rdi + xorl %edx, %edx + lea 208(%rsp), %rcx +..___tag_value___j1q.288: + call __dpml_ux_bessel__ +..___tag_value___j1q.289: +..B4.44: + lea 184(%rsp), %rsi + movq %rsi, %rdx + lea 208(%rsp), %rdi +..___tag_value___j1q.290: + call __dpml_multiply__@PLT +..___tag_value___j1q.291: +..B4.45: + movl $1, %edx + lea 256(%rsp), %rsi + movq %rsi, %rcx + lea 184(%rsp), %rdi +..___tag_value___j1q.292: + call __dpml_addsub__@PLT +..___tag_value___j1q.293: + jmp ..B4.19 +..B4.46: + cmpq (%rdi), %rax + ja ..B4.10 +..B4.47: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + jmp ..B4.7 +..B4.48: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __j1q,@function + .size __j1q,.-__j1q + .data +# -- End __j1q + .text +# -- Begin __jnq + .text + .align 16,0x90 + .globl __jnq +__jnq: +# parameter 1: %edi +# parameter 2: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value___jnq.295: +..L296: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $368, %rsp + .cfi_def_cfa_offset 416 + movq $0x8000000000000000, %rbp + movaps %xmm0, 48(%rsp) + andq 56(%rsp), %rbp + movslq %edi, %r13 + shrq $32, %rbp + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 352(%rsp) + testq %r13, %r13 + movq $1, 8(%rsp) + movq $0, (%rsp) + jge ..B5.3 +..B5.2: + negq %r13 + xorl $-2147483648, %ebp +..B5.3: + xorl %r12d, %r12d + testq $1, %r13 + lea 48(%rsp), %rdi + cmove %r12d, %ebp + movl $2, %eax + cmpq $2, %r13 + lea __bessel_x_table(%rip), %r12 + cmovle %r13, %rax + xorl %esi, %esi + lea 304(%rsp), %rdx + andl $-2147483648, %ebp + lea 336(%rsp), %r8 + lea (%rsp), %r9 + lea (%r12,%rax,8), %rcx +..___tag_value___jnq.308: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___jnq.309: +..B5.4: + testq %rax, %rax + jge ..B5.6 +..B5.5: + movq $0x7fff000000000000, %rax + movslq %ebp, %rbp + movq %rax, %rdx + movq 344(%rsp), %rcx + andq %rcx, %rdx + shlq $32, %rbp + orq %rcx, %rbp + cmpq %rdx, %rax + cmovne %rbp, %rcx + movq %rcx, 344(%rsp) + jmp ..B5.26 +..B5.6: + movl $0, 304(%rsp) + cmpq $2, %r13 + jge ..B5.56 +..B5.7: + movl 308(%rsp), %ecx + lea (%r13,%r13,2), %r8 + movq 312(%rsp), %rax + cmpl $5, %ecx + jg ..B5.13 +..B5.8: + je ..B5.53 +..B5.9: + movq %r12, %rbx + addq 19552(%r12,%r8,8), %rbx + testl %ecx, %ecx + jl ..B5.29 +..B5.10: + negl %ecx + addl $5, %ecx + shrq %cl, %rax + jmp ..B5.11 +..B5.12: + movq 8(%rbx), %rcx + sarq $32, %rcx + andq $1023, %rcx + addq %rcx, %rbx +..B5.11: + cmpq (%rbx), %rax + jbe ..B5.29 + jmp ..B5.12 +..B5.13: + xorl %edi, %edi + lea 304(%rsp), %rsi + movl $2, %edx + lea 160(%rsp), %rcx +..___tag_value___jnq.310: + call __dpml_divide__@PLT +..___tag_value___jnq.311: +..B5.14: + testq %r13, %r13 + jne ..B5.16 +..B5.15: + movl $10, %r12d + lea 18168+__bessel_x_table(%rip), %rsi + lea 18504+__bessel_x_table(%rip), %rbx + jmp ..B5.17 +..B5.16: + movl $9, %r12d + lea 18872+__bessel_x_table(%rip), %rsi + lea 19208+__bessel_x_table(%rip), %rbx +..B5.17: + movl $9, %edx + lea 160(%rsp), %rdi + movq $0x1000000000000044, %rcx + lea 64(%rsp), %r8 +..___tag_value___jnq.312: + call __dpml_evaluate_rational__@PLT +..___tag_value___jnq.313: +..B5.18: + movq %rbx, %rsi + lea 160(%rsp), %rdi + movq %r12, %rdx + movl $70, %ecx + lea 88(%rsp), %r8 +..___tag_value___jnq.314: + call __dpml_evaluate_rational__@PLT +..___tag_value___jnq.315: +..B5.19: + movl $3, %edx + lea (%r13,%r13), %rsi + negq %rsi + lea 304(%rsp), %rdi + incq %rsi + lea 112(%rsp), %rcx +..___tag_value___jnq.316: + call __dpml_ux_sincos@PLT +..___tag_value___jnq.317: +..B5.20: + lea 64(%rsp), %rdi + movq %rdi, %rdx + lea 112(%rsp), %rsi +..___tag_value___jnq.318: + call __dpml_multiply__@PLT +..___tag_value___jnq.319: +..B5.21: + lea 88(%rsp), %rdi + movq %rdi, %rdx + lea 136(%rsp), %rsi +..___tag_value___jnq.320: + call __dpml_multiply__@PLT +..___tag_value___jnq.321: +..B5.22: + movl $1, %eax + xorl %edx, %edx + testq %r13, %r13 + lea 64(%rsp), %rdi + cmove %rax, %rdx + lea 88(%rsp), %rsi + movq %rdi, %rcx +..___tag_value___jnq.322: + call __dpml_addsub__@PLT +..___tag_value___jnq.323: +..B5.23: + movl $1, %esi + lea 160(%rsp), %rdi + lea 88(%rsp), %rdx +..___tag_value___jnq.324: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___jnq.325: +..B5.24: + lea 64(%rsp), %rdi + lea 88(%rsp), %rsi + lea 256(%rsp), %rdx +..___tag_value___jnq.326: + call __dpml_multiply__@PLT +..___tag_value___jnq.327: +..B5.25: + xorl %ecx, %ecx + movl $8, %eax + xorl %ebp, 256(%rsp) + cmovne %eax, %ecx + movl $1027, %ebx + lea __bessel_error_codes(%rip), %r8 + shrq %cl, %rbx + lea 256(%rsp), %rdi + movzbl %bl, %ebp + lea 336(%rsp), %rsi + movq (%r8), %rcx + movq (%r8,%rbp,8), %rdx + lea (%rsp), %r8 +..___tag_value___jnq.328: + call __dpml_pack__@PLT +..___tag_value___jnq.329: +..B5.26: + movq 352(%rsp), %rax + xorq %rsp, %rax + movaps 336(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B5.55 +..B5.27: + addq $368, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 416 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 15, -32 +..B5.29: + movq 8(%rbx), %r12 + testq $8388608, %r12 + jne ..B5.31 +..B5.30: + lea 304(%rsp), %r15 + jmp ..B5.34 +..B5.31: + movq 16(%rbx), %rax + lea 304(%rsp), %rdi + movq %rax, -88(%rdi) + lea 208(%rsp), %rsi + movq 24(%rbx), %r8 + movl $1, %edx + movq %r8, 16(%rsi) + lea 184(%rsp), %rcx + movl $0, 24(%rcx) + movl 40(%rbx), %r15d + andl $7, %r15d + movl %r15d, 28(%rcx) +..___tag_value___jnq.347: + call __dpml_addsub__@PLT +..___tag_value___jnq.348: +..B5.32: + movq 32(%rbx), %rax + lea 184(%rsp), %rdi + movq %rax, 32(%rdi) + lea 208(%rsp), %rsi + movq 40(%rbx), %r8 + movl $1, %edx + movq %rdi, %rcx + addl $-128, %r15d + movq %r8, 16(%rsi) + movl %r15d, 4(%rsi) +..___tag_value___jnq.349: + call __dpml_addsub__@PLT +..___tag_value___jnq.350: +..B5.33: + lea 184(%rsp), %r15 +..B5.34: + movq %r12, %rdx + addq $48, %rbx + sarq $14, %rdx + andq $127, %rdx + testq $16777216, %r12 + je ..B5.36 +..B5.35: + movq %r12, %rcx + movl $1, %eax + shrq $7, %rcx + movq %r12, %r8 + andq $127, %r8 + movq %r15, %rdi + shlq %cl, %rax + movq %rdx, %rsi + decq %rax + movq %rbx, %rdx + movq %rax, %rcx + lea 256(%rsp), %r9 +..___tag_value___jnq.351: + call __dpml_evaluate_packed_poly__@PLT +..___tag_value___jnq.352: + jmp ..B5.37 +..B5.36: + movq %r15, %rdi + movq %rbx, %rsi + movq %r12, %rcx + lea 256(%rsp), %r8 +..___tag_value___jnq.353: + call __dpml_evaluate_rational__@PLT +..___tag_value___jnq.354: +..B5.37: + movq %r12, %rdx + sarq $11, %rdx + andq $3, %rdx + je ..B5.39 +..B5.38: + decq %rdx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 280(%rsp), %rsi +..___tag_value___jnq.355: + call __dpml_addsub__@PLT +..___tag_value___jnq.356: +..B5.39: + testq $4194304, %r12 + je ..B5.41 +..B5.40: + movq %r15, %rdi + lea 256(%rsp), %rsi + movq %rsi, %rdx +..___tag_value___jnq.357: + call __dpml_multiply__@PLT +..___tag_value___jnq.358: +..B5.41: + testq $8192, %r12 + je ..B5.43 +..B5.42: + movslq 256(%rsp), %rax + btcq $31, %rax + movl %eax, 256(%rsp) +..B5.43: + testq $2097152, %r12 + je ..B5.25 +..B5.44: + lea 304(%rsp), %rax + cmpq %rax, %r15 + jne ..B5.46 +..B5.45: + sarq $58, %r12 + subl %r12d, 308(%rsp) +..B5.46: + cmpq $1, %r13 + je ..B5.51 +..B5.47: + lea 19664+__bessel_x_table(%rip), %rsi + lea 304(%rsp), %rdi + lea 184(%rsp), %rdx +..___tag_value___jnq.359: + call __dpml_ux_log__@PLT +..___tag_value___jnq.360: +..B5.48: + movq %r13, %rsi + lea 304(%rsp), %rdi + xorl %edx, %edx + lea 208(%rsp), %rcx +..___tag_value___jnq.361: + call __dpml_ux_bessel__ +..___tag_value___jnq.362: +..B5.49: + lea 184(%rsp), %rsi + movq %rsi, %rdx + lea 208(%rsp), %rdi +..___tag_value___jnq.363: + call __dpml_multiply__@PLT +..___tag_value___jnq.364: +..B5.50: + movl $1, %edx + lea 256(%rsp), %rsi + movq %rsi, %rcx + lea 184(%rsp), %rdi +..___tag_value___jnq.365: + call __dpml_addsub__@PLT +..___tag_value___jnq.366: + jmp ..B5.25 +..B5.51: + lea 19640+__bessel_x_table(%rip), %rdi + lea 304(%rsp), %rsi + movl $2, %edx + lea 208(%rsp), %rcx +..___tag_value___jnq.367: + call __dpml_divide__@PLT +..___tag_value___jnq.368: +..B5.52: + xorl %edx, %edx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 208(%rsp), %rsi +..___tag_value___jnq.369: + call __dpml_addsub__@PLT +..___tag_value___jnq.370: + jmp ..B5.47 +..B5.53: + cmpq 19544(%r12,%r8,8), %rax + ja ..B5.13 +..B5.54: + movq %r12, %rbx + addq 19552(%r12,%r8,8), %rbx + jmp ..B5.10 +..B5.55: + call __stack_chk_fail@PLT +..B5.56: + movq %r13, %rsi + lea 304(%rsp), %rdi + xorl %edx, %edx + lea 256(%rsp), %rcx +..___tag_value___jnq.371: + call __dpml_ux_large_order_bessel__ +..___tag_value___jnq.372: + jmp ..B5.25 + .align 16,0x90 + .cfi_endproc + .type __jnq,@function + .size __jnq,.-__jnq + .data +# -- End __jnq + .text +# -- Begin __y0q + .text + .align 16,0x90 + .globl __y0q +__y0q: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value___y0q.374: +..L375: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + subq $368, %rsp + .cfi_def_cfa_offset 400 + xorl %esi, %esi + lea 40+__bessel_x_table(%rip), %rcx + lea 48(%rsp), %rdi + movq %fs:40, %rax + lea 304(%rsp), %rdx + xorq %rsp, %rax + lea 336(%rsp), %r8 + movaps %xmm0, (%rdi) + lea (%rsp), %r9 + movq %rax, 48(%rdx) + movq $1, -40(%rdi) + movq $0, (%r9) +..___tag_value___y0q.383: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___y0q.384: +..B6.2: + testq %rax, %rax + jl ..B6.20 +..B6.4: + movl 308(%rsp), %ecx + lea 19592+__bessel_x_table(%rip), %rdi + movq 312(%rsp), %rax + cmpl $5, %ecx + movl $0, 304(%rsp) + jg ..B6.10 +..B6.5: + je ..B6.44 +..B6.6: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + testl %ecx, %ecx + jl ..B6.23 +..B6.7: + negl %ecx + addl $5, %ecx + shrq %cl, %rax + jmp ..B6.8 +..B6.9: + movq 8(%rbx), %rcx + sarq $32, %rcx + andq $1023, %rcx + addq %rcx, %rbx +..B6.8: + cmpq (%rbx), %rax + jbe ..B6.23 + jmp ..B6.9 +..B6.10: + xorl %edi, %edi + lea 304(%rsp), %rsi + movl $2, %edx + lea 160(%rsp), %rcx +..___tag_value___y0q.385: + call __dpml_divide__@PLT +..___tag_value___y0q.386: +..B6.11: + lea 18168+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $9, %edx + movq $0x1000000000000044, %rcx + lea 64(%rsp), %r8 +..___tag_value___y0q.387: + call __dpml_evaluate_rational__@PLT +..___tag_value___y0q.388: +..B6.12: + lea 18504+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $10, %edx + movl $70, %ecx + lea 88(%rsp), %r8 +..___tag_value___y0q.389: + call __dpml_evaluate_rational__@PLT +..___tag_value___y0q.390: +..B6.13: + movq $-1, %rsi + lea 304(%rsp), %rdi + movl $3, %edx + lea 112(%rsp), %rcx +..___tag_value___y0q.391: + call __dpml_ux_sincos@PLT +..___tag_value___y0q.392: +..B6.14: + lea 64(%rsp), %rdi + movq %rdi, %rdx + lea 112(%rsp), %rsi +..___tag_value___y0q.393: + call __dpml_multiply__@PLT +..___tag_value___y0q.394: +..B6.15: + lea 88(%rsp), %rdi + movq %rdi, %rdx + lea 136(%rsp), %rsi +..___tag_value___y0q.395: + call __dpml_multiply__@PLT +..___tag_value___y0q.396: +..B6.16: + movl $1, %edx + lea 64(%rsp), %rdi + movq %rdi, %rcx + lea 88(%rsp), %rsi +..___tag_value___y0q.397: + call __dpml_addsub__@PLT +..___tag_value___y0q.398: +..B6.17: + movl $1, %esi + lea 160(%rsp), %rdi + lea 88(%rsp), %rdx +..___tag_value___y0q.399: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___y0q.400: +..B6.18: + lea 64(%rsp), %rdi + lea 88(%rsp), %rsi + lea 256(%rsp), %rdx +..___tag_value___y0q.401: + call __dpml_multiply__@PLT +..___tag_value___y0q.402: +..B6.19: + xorl %edx, %edx + lea 256(%rsp), %rdi + xorl %ecx, %ecx + lea 336(%rsp), %rsi + lea (%rsp), %r8 +..___tag_value___y0q.403: + call __dpml_pack__@PLT +..___tag_value___y0q.404: +..B6.20: + movq 352(%rsp), %rax + xorq %rsp, %rax + movaps 336(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B6.46 +..B6.21: + addq $368, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 400 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B6.23: + movq 8(%rbx), %r14 + testq $8388608, %r14 + jne ..B6.25 +..B6.24: + lea 304(%rsp), %r15 + jmp ..B6.28 +..B6.25: + movq 16(%rbx), %rax + lea 304(%rsp), %rdi + movq %rax, -88(%rdi) + lea 208(%rsp), %rsi + movq 24(%rbx), %r8 + movl $1, %edx + movq %r8, 16(%rsi) + lea 184(%rsp), %rcx + movl $0, 24(%rcx) + movl 40(%rbx), %r15d + andl $7, %r15d + movl %r15d, 28(%rcx) +..___tag_value___y0q.416: + call __dpml_addsub__@PLT +..___tag_value___y0q.417: +..B6.26: + movq 32(%rbx), %rax + lea 184(%rsp), %rdi + movq %rax, 32(%rdi) + lea 208(%rsp), %rsi + movq 40(%rbx), %r8 + movl $1, %edx + movq %rdi, %rcx + addl $-128, %r15d + movq %r8, 16(%rsi) + movl %r15d, 4(%rsi) +..___tag_value___y0q.418: + call __dpml_addsub__@PLT +..___tag_value___y0q.419: +..B6.27: + lea 184(%rsp), %r15 +..B6.28: + movq %r14, %rdx + addq $48, %rbx + sarq $14, %rdx + andq $127, %rdx + testq $16777216, %r14 + je ..B6.30 +..B6.29: + movq %r14, %rcx + movl $1, %eax + shrq $7, %rcx + movq %r14, %r8 + andq $127, %r8 + movq %r15, %rdi + shlq %cl, %rax + movq %rdx, %rsi + decq %rax + movq %rbx, %rdx + movq %rax, %rcx + lea 256(%rsp), %r9 +..___tag_value___y0q.420: + call __dpml_evaluate_packed_poly__@PLT +..___tag_value___y0q.421: + jmp ..B6.31 +..B6.30: + movq %r15, %rdi + movq %rbx, %rsi + movq %r14, %rcx + lea 256(%rsp), %r8 +..___tag_value___y0q.422: + call __dpml_evaluate_rational__@PLT +..___tag_value___y0q.423: +..B6.31: + movq %r14, %rdx + sarq $11, %rdx + andq $3, %rdx + je ..B6.33 +..B6.32: + decq %rdx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 280(%rsp), %rsi +..___tag_value___y0q.424: + call __dpml_addsub__@PLT +..___tag_value___y0q.425: +..B6.33: + testq $4194304, %r14 + je ..B6.35 +..B6.34: + movq %r15, %rdi + lea 256(%rsp), %rsi + movq %rsi, %rdx +..___tag_value___y0q.426: + call __dpml_multiply__@PLT +..___tag_value___y0q.427: +..B6.35: + testq $8192, %r14 + je ..B6.37 +..B6.36: + movslq 256(%rsp), %rax + btcq $31, %rax + movl %eax, 256(%rsp) +..B6.37: + testq $2097152, %r14 + je ..B6.19 +..B6.38: + lea 304(%rsp), %rax + cmpq %rax, %r15 + jne ..B6.40 +..B6.39: + sarq $58, %r14 + subl %r14d, 308(%rsp) +..B6.40: + lea 19664+__bessel_x_table(%rip), %rsi + lea 304(%rsp), %rdi + lea 184(%rsp), %rdx +..___tag_value___y0q.428: + call __dpml_ux_log__@PLT +..___tag_value___y0q.429: +..B6.41: + xorl %esi, %esi + lea 304(%rsp), %rdi + xorl %edx, %edx + lea 208(%rsp), %rcx +..___tag_value___y0q.430: + call __dpml_ux_bessel__ +..___tag_value___y0q.431: +..B6.42: + lea 184(%rsp), %rsi + movq %rsi, %rdx + lea 208(%rsp), %rdi +..___tag_value___y0q.432: + call __dpml_multiply__@PLT +..___tag_value___y0q.433: +..B6.43: + movl $1, %edx + lea 256(%rsp), %rsi + movq %rsi, %rcx + lea 184(%rsp), %rdi +..___tag_value___y0q.434: + call __dpml_addsub__@PLT +..___tag_value___y0q.435: + jmp ..B6.19 +..B6.44: + cmpq (%rdi), %rax + ja ..B6.10 +..B6.45: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + jmp ..B6.7 +..B6.46: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __y0q,@function + .size __y0q,.-__y0q + .data +# -- End __y0q + .text +# -- Begin __y1q + .text + .align 16,0x90 + .globl __y1q +__y1q: +# parameter 1: %xmm0 +..B7.1: + .cfi_startproc +..___tag_value___y1q.437: +..L438: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + pushq %rbp + .cfi_def_cfa_offset 40 + .cfi_offset 6, -40 + subq $360, %rsp + .cfi_def_cfa_offset 400 + xorl %esi, %esi + movaps %xmm0, 48(%rsp) + lea 48(%rsp), %rdi + movq 8(%rdi), %rbp + lea 304(%rsp), %rdx + shrq $32, %rbp + lea 48+__bessel_x_table(%rip), %rcx + movq %fs:40, %rax + lea 336(%rsp), %r8 + xorq %rsp, %rax + lea (%rsp), %r9 + movq %rax, 48(%rdx) + andl $-2147483648, %ebp + movq $1, -40(%rdi) + movq $0, (%r9) +..___tag_value___y1q.448: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___y1q.449: +..B7.2: + testq %rax, %rax + jge ..B7.4 +..B7.3: + movq $0x7fff000000000000, %rax + movslq %ebp, %rbp + movq %rax, %rdx + movq 344(%rsp), %rcx + andq %rcx, %rdx + shlq $32, %rbp + orq %rcx, %rbp + cmpq %rdx, %rax + cmovne %rbp, %rcx + movq %rcx, 344(%rsp) + jmp ..B7.20 +..B7.4: + movl 308(%rsp), %ecx + lea 19616+__bessel_x_table(%rip), %rdi + movq 312(%rsp), %rax + cmpl $5, %ecx + movl $0, 304(%rsp) + jg ..B7.10 +..B7.5: + je ..B7.46 +..B7.6: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + testl %ecx, %ecx + jl ..B7.23 +..B7.7: + negl %ecx + addl $5, %ecx + shrq %cl, %rax + jmp ..B7.8 +..B7.9: + movq 8(%rbx), %rcx + sarq $32, %rcx + andq $1023, %rcx + addq %rcx, %rbx +..B7.8: + cmpq (%rbx), %rax + jbe ..B7.23 + jmp ..B7.9 +..B7.10: + xorl %edi, %edi + lea 304(%rsp), %rsi + movl $2, %edx + lea 160(%rsp), %rcx +..___tag_value___y1q.450: + call __dpml_divide__@PLT +..___tag_value___y1q.451: +..B7.11: + lea 18872+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $9, %edx + movq $0x1000000000000044, %rcx + lea 64(%rsp), %r8 +..___tag_value___y1q.452: + call __dpml_evaluate_rational__@PLT +..___tag_value___y1q.453: +..B7.12: + lea 19208+__bessel_x_table(%rip), %rsi + lea 160(%rsp), %rdi + movl $9, %edx + movl $70, %ecx + lea 88(%rsp), %r8 +..___tag_value___y1q.454: + call __dpml_evaluate_rational__@PLT +..___tag_value___y1q.455: +..B7.13: + movq $-3, %rsi + lea 304(%rsp), %rdi + movl $3, %edx + lea 112(%rsp), %rcx +..___tag_value___y1q.456: + call __dpml_ux_sincos@PLT +..___tag_value___y1q.457: +..B7.14: + lea 64(%rsp), %rdi + movq %rdi, %rdx + lea 112(%rsp), %rsi +..___tag_value___y1q.458: + call __dpml_multiply__@PLT +..___tag_value___y1q.459: +..B7.15: + lea 88(%rsp), %rdi + movq %rdi, %rdx + lea 136(%rsp), %rsi +..___tag_value___y1q.460: + call __dpml_multiply__@PLT +..___tag_value___y1q.461: +..B7.16: + xorl %edx, %edx + lea 64(%rsp), %rdi + movq %rdi, %rcx + lea 88(%rsp), %rsi +..___tag_value___y1q.462: + call __dpml_addsub__@PLT +..___tag_value___y1q.463: +..B7.17: + movl $1, %esi + lea 160(%rsp), %rdi + lea 88(%rsp), %rdx +..___tag_value___y1q.464: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___y1q.465: +..B7.18: + lea 64(%rsp), %rdi + lea 88(%rsp), %rsi + lea 256(%rsp), %rdx +..___tag_value___y1q.466: + call __dpml_multiply__@PLT +..___tag_value___y1q.467: +..B7.19: + movl $24, %eax + movl $16, %ecx + xorl %ebp, 256(%rsp) + cmovne %eax, %ecx + movl $83886080, %ebx + lea __bessel_error_codes(%rip), %rbp + shrq %cl, %rbx + lea 256(%rsp), %rdi + movzbl %bl, %r8d + lea 336(%rsp), %rsi + movq (%rbp), %rdx + movq (%rbp,%r8,8), %rcx + lea (%rsp), %r8 +..___tag_value___y1q.468: + call __dpml_pack__@PLT +..___tag_value___y1q.469: +..B7.20: + movq 352(%rsp), %rax + xorq %rsp, %rax + movaps 336(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B7.48 +..B7.21: + addq $360, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 400 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 15, -24 +..B7.23: + movq 8(%rbx), %r12 + testq $8388608, %r12 + jne ..B7.25 +..B7.24: + lea 304(%rsp), %r15 + jmp ..B7.28 +..B7.25: + movq 16(%rbx), %rax + lea 304(%rsp), %rdi + movq %rax, -88(%rdi) + lea 208(%rsp), %rsi + movq 24(%rbx), %r8 + movl $1, %edx + movq %r8, 16(%rsi) + lea 184(%rsp), %rcx + movl $0, 24(%rcx) + movl 40(%rbx), %r15d + andl $7, %r15d + movl %r15d, 28(%rcx) +..___tag_value___y1q.484: + call __dpml_addsub__@PLT +..___tag_value___y1q.485: +..B7.26: + movq 32(%rbx), %rax + lea 184(%rsp), %rdi + movq %rax, 32(%rdi) + lea 208(%rsp), %rsi + movq 40(%rbx), %r8 + movl $1, %edx + movq %rdi, %rcx + addl $-128, %r15d + movq %r8, 16(%rsi) + movl %r15d, 4(%rsi) +..___tag_value___y1q.486: + call __dpml_addsub__@PLT +..___tag_value___y1q.487: +..B7.27: + lea 184(%rsp), %r15 +..B7.28: + movq %r12, %rdx + addq $48, %rbx + sarq $14, %rdx + andq $127, %rdx + testq $16777216, %r12 + je ..B7.30 +..B7.29: + movq %r12, %rcx + movl $1, %eax + shrq $7, %rcx + movq %r12, %r8 + andq $127, %r8 + movq %r15, %rdi + shlq %cl, %rax + movq %rdx, %rsi + decq %rax + movq %rbx, %rdx + movq %rax, %rcx + lea 256(%rsp), %r9 +..___tag_value___y1q.488: + call __dpml_evaluate_packed_poly__@PLT +..___tag_value___y1q.489: + jmp ..B7.31 +..B7.30: + movq %r15, %rdi + movq %rbx, %rsi + movq %r12, %rcx + lea 256(%rsp), %r8 +..___tag_value___y1q.490: + call __dpml_evaluate_rational__@PLT +..___tag_value___y1q.491: +..B7.31: + movq %r12, %rdx + sarq $11, %rdx + andq $3, %rdx + je ..B7.33 +..B7.32: + decq %rdx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 280(%rsp), %rsi +..___tag_value___y1q.492: + call __dpml_addsub__@PLT +..___tag_value___y1q.493: +..B7.33: + testq $4194304, %r12 + je ..B7.35 +..B7.34: + movq %r15, %rdi + lea 256(%rsp), %rsi + movq %rsi, %rdx +..___tag_value___y1q.494: + call __dpml_multiply__@PLT +..___tag_value___y1q.495: +..B7.35: + testq $8192, %r12 + je ..B7.37 +..B7.36: + movslq 256(%rsp), %rax + btcq $31, %rax + movl %eax, 256(%rsp) +..B7.37: + testq $2097152, %r12 + je ..B7.19 +..B7.38: + lea 304(%rsp), %rax + cmpq %rax, %r15 + jne ..B7.40 +..B7.39: + sarq $58, %r12 + subl %r12d, 308(%rsp) +..B7.40: + lea 19640+__bessel_x_table(%rip), %rdi + lea 304(%rsp), %rsi + movl $2, %edx + lea 208(%rsp), %rcx +..___tag_value___y1q.496: + call __dpml_divide__@PLT +..___tag_value___y1q.497: +..B7.41: + xorl %edx, %edx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 208(%rsp), %rsi +..___tag_value___y1q.498: + call __dpml_addsub__@PLT +..___tag_value___y1q.499: +..B7.42: + lea 19664+__bessel_x_table(%rip), %rsi + lea 304(%rsp), %rdi + lea 184(%rsp), %rdx +..___tag_value___y1q.500: + call __dpml_ux_log__@PLT +..___tag_value___y1q.501: +..B7.43: + movl $1, %esi + lea 304(%rsp), %rdi + xorl %edx, %edx + lea 208(%rsp), %rcx +..___tag_value___y1q.502: + call __dpml_ux_bessel__ +..___tag_value___y1q.503: +..B7.44: + lea 184(%rsp), %rsi + movq %rsi, %rdx + lea 208(%rsp), %rdi +..___tag_value___y1q.504: + call __dpml_multiply__@PLT +..___tag_value___y1q.505: +..B7.45: + movl $1, %edx + lea 256(%rsp), %rsi + movq %rsi, %rcx + lea 184(%rsp), %rdi +..___tag_value___y1q.506: + call __dpml_addsub__@PLT +..___tag_value___y1q.507: + jmp ..B7.19 +..B7.46: + cmpq (%rdi), %rax + ja ..B7.10 +..B7.47: + lea __bessel_x_table(%rip), %rbx + addq 8(%rdi), %rbx + jmp ..B7.7 +..B7.48: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __y1q,@function + .size __y1q,.-__y1q + .data +# -- End __y1q + .text +# -- Begin __ynq + .text + .align 16,0x90 + .globl __ynq +__ynq: +# parameter 1: %edi +# parameter 2: %xmm0 +..B8.1: + .cfi_startproc +..___tag_value___ynq.509: +..L510: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $368, %rsp + .cfi_def_cfa_offset 416 + movq $0x8000000000000000, %rdx + movaps %xmm0, 48(%rsp) + andq 56(%rsp), %rdx + movslq %edi, %r14 + shrq $32, %rdx + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 352(%rsp) + lea 40+__bessel_x_table(%rip), %rax + testq %r14, %r14 + movq $1, 8(%rsp) + movq $0, (%rsp) + jge ..B8.3 +..B8.2: + negq %r14 + xorl $-2147483648, %edx +..B8.3: + xorl %ebp, %ebp + testq $1, %r14 + lea 48(%rsp), %rdi + cmovne %edx, %ebp + movl $2, %ebx + cmpq $2, %r14 + lea 304(%rsp), %rdx + cmovle %r14, %rbx + xorl %esi, %esi + lea 336(%rsp), %r8 + andl $-2147483648, %ebp + lea (%rsp), %r9 + lea (%rax,%rbx,8), %rcx +..___tag_value___ynq.522: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___ynq.523: +..B8.4: + testq %rax, %rax + jge ..B8.6 +..B8.5: + movq $0x7fff000000000000, %rax + movslq %ebp, %rbp + movq %rax, %rdx + movq 344(%rsp), %rcx + andq %rcx, %rdx + shlq $32, %rbp + orq %rcx, %rbp + cmpq %rdx, %rax + cmovne %rbp, %rcx + movq %rcx, 344(%rsp) + jmp ..B8.26 +..B8.6: + movl $0, 304(%rsp) + cmpq $2, %r14 + jge ..B8.56 +..B8.7: + movl 308(%rsp), %ecx + lea (%r14,%r14,2), %r9 + movq 312(%rsp), %rax + lea __bessel_x_table(%rip), %r8 + cmpl $5, %ecx + jg ..B8.13 +..B8.8: + je ..B8.53 +..B8.9: + movq %r8, %rbx + addq 19600(%r8,%r9,8), %rbx + testl %ecx, %ecx + jl ..B8.29 +..B8.10: + negl %ecx + addl $5, %ecx + shrq %cl, %rax + jmp ..B8.11 +..B8.12: + movq 8(%rbx), %rcx + sarq $32, %rcx + andq $1023, %rcx + addq %rcx, %rbx +..B8.11: + cmpq (%rbx), %rax + jbe ..B8.29 + jmp ..B8.12 +..B8.13: + xorl %edi, %edi + lea 304(%rsp), %rsi + movl $2, %edx + lea 160(%rsp), %rcx +..___tag_value___ynq.524: + call __dpml_divide__@PLT +..___tag_value___ynq.525: +..B8.14: + testq %r14, %r14 + jne ..B8.16 +..B8.15: + movl $10, %r13d + lea 18168+__bessel_x_table(%rip), %rsi + lea 18504+__bessel_x_table(%rip), %rbx + jmp ..B8.17 +..B8.16: + movl $9, %r13d + lea 18872+__bessel_x_table(%rip), %rsi + lea 19208+__bessel_x_table(%rip), %rbx +..B8.17: + movl $9, %edx + lea 160(%rsp), %rdi + movq $0x1000000000000044, %rcx + lea 64(%rsp), %r8 +..___tag_value___ynq.526: + call __dpml_evaluate_rational__@PLT +..___tag_value___ynq.527: +..B8.18: + movq %rbx, %rsi + lea 160(%rsp), %rdi + movq %r13, %rdx + movl $70, %ecx + lea 88(%rsp), %r8 +..___tag_value___ynq.528: + call __dpml_evaluate_rational__@PLT +..___tag_value___ynq.529: +..B8.19: + movl $3, %edx + lea (%r14,%r14), %rsi + negq %rsi + lea 304(%rsp), %rdi + decq %rsi + lea 112(%rsp), %rcx +..___tag_value___ynq.530: + call __dpml_ux_sincos@PLT +..___tag_value___ynq.531: +..B8.20: + lea 64(%rsp), %rdi + movq %rdi, %rdx + lea 112(%rsp), %rsi +..___tag_value___ynq.532: + call __dpml_multiply__@PLT +..___tag_value___ynq.533: +..B8.21: + lea 88(%rsp), %rdi + movq %rdi, %rdx + lea 136(%rsp), %rsi +..___tag_value___ynq.534: + call __dpml_multiply__@PLT +..___tag_value___ynq.535: +..B8.22: + movl $1, %eax + xorl %edx, %edx + testq %r14, %r14 + lea 64(%rsp), %rdi + cmove %rax, %rdx + lea 88(%rsp), %rsi + movq %rdi, %rcx +..___tag_value___ynq.536: + call __dpml_addsub__@PLT +..___tag_value___ynq.537: +..B8.23: + movl $1, %esi + lea 160(%rsp), %rdi + lea 88(%rsp), %rdx +..___tag_value___ynq.538: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___ynq.539: +..B8.24: + lea 64(%rsp), %rdi + lea 88(%rsp), %rsi + lea 256(%rsp), %rdx +..___tag_value___ynq.540: + call __dpml_multiply__@PLT +..___tag_value___ynq.541: +..B8.25: + movl $24, %eax + movl $16, %ecx + xorl %ebp, 256(%rsp) + cmovne %eax, %ecx + movl $117833728, %ebx + lea __bessel_error_codes(%rip), %rbp + shrq %cl, %rbx + lea 256(%rsp), %rdi + movzbl %bl, %r8d + lea 336(%rsp), %rsi + movq (%rbp), %rdx + movq (%rbp,%r8,8), %rcx + lea (%rsp), %r8 +..___tag_value___ynq.542: + call __dpml_pack__@PLT +..___tag_value___ynq.543: +..B8.26: + movq 352(%rsp), %rax + xorq %rsp, %rax + movaps 336(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B8.55 +..B8.27: + addq $368, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 416 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B8.29: + movq 8(%rbx), %r13 + testq $8388608, %r13 + jne ..B8.31 +..B8.30: + lea 304(%rsp), %r15 + jmp ..B8.34 +..B8.31: + movq 16(%rbx), %rax + lea 304(%rsp), %rdi + movq %rax, -88(%rdi) + lea 208(%rsp), %rsi + movq 24(%rbx), %r8 + movl $1, %edx + movq %r8, 16(%rsi) + lea 184(%rsp), %rcx + movl $0, 24(%rcx) + movl 40(%rbx), %r15d + andl $7, %r15d + movl %r15d, 28(%rcx) +..___tag_value___ynq.561: + call __dpml_addsub__@PLT +..___tag_value___ynq.562: +..B8.32: + movq 32(%rbx), %rax + lea 184(%rsp), %rdi + movq %rax, 32(%rdi) + lea 208(%rsp), %rsi + movq 40(%rbx), %r8 + movl $1, %edx + movq %rdi, %rcx + addl $-128, %r15d + movq %r8, 16(%rsi) + movl %r15d, 4(%rsi) +..___tag_value___ynq.563: + call __dpml_addsub__@PLT +..___tag_value___ynq.564: +..B8.33: + lea 184(%rsp), %r15 +..B8.34: + movq %r13, %rdx + addq $48, %rbx + sarq $14, %rdx + andq $127, %rdx + testq $16777216, %r13 + je ..B8.36 +..B8.35: + movq %r13, %rcx + movl $1, %eax + shrq $7, %rcx + movq %r13, %r8 + andq $127, %r8 + movq %r15, %rdi + shlq %cl, %rax + movq %rdx, %rsi + decq %rax + movq %rbx, %rdx + movq %rax, %rcx + lea 256(%rsp), %r9 +..___tag_value___ynq.565: + call __dpml_evaluate_packed_poly__@PLT +..___tag_value___ynq.566: + jmp ..B8.37 +..B8.36: + movq %r15, %rdi + movq %rbx, %rsi + movq %r13, %rcx + lea 256(%rsp), %r8 +..___tag_value___ynq.567: + call __dpml_evaluate_rational__@PLT +..___tag_value___ynq.568: +..B8.37: + movq %r13, %rdx + sarq $11, %rdx + andq $3, %rdx + je ..B8.39 +..B8.38: + decq %rdx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 280(%rsp), %rsi +..___tag_value___ynq.569: + call __dpml_addsub__@PLT +..___tag_value___ynq.570: +..B8.39: + testq $4194304, %r13 + je ..B8.41 +..B8.40: + movq %r15, %rdi + lea 256(%rsp), %rsi + movq %rsi, %rdx +..___tag_value___ynq.571: + call __dpml_multiply__@PLT +..___tag_value___ynq.572: +..B8.41: + testq $8192, %r13 + je ..B8.43 +..B8.42: + movslq 256(%rsp), %rax + btcq $31, %rax + movl %eax, 256(%rsp) +..B8.43: + testq $2097152, %r13 + je ..B8.25 +..B8.44: + lea 304(%rsp), %rax + cmpq %rax, %r15 + jne ..B8.46 +..B8.45: + sarq $58, %r13 + subl %r13d, 308(%rsp) +..B8.46: + cmpq $1, %r14 + je ..B8.51 +..B8.47: + lea 19664+__bessel_x_table(%rip), %rsi + lea 304(%rsp), %rdi + lea 184(%rsp), %rdx +..___tag_value___ynq.573: + call __dpml_ux_log__@PLT +..___tag_value___ynq.574: +..B8.48: + movq %r14, %rsi + lea 304(%rsp), %rdi + xorl %edx, %edx + lea 208(%rsp), %rcx +..___tag_value___ynq.575: + call __dpml_ux_bessel__ +..___tag_value___ynq.576: +..B8.49: + lea 184(%rsp), %rsi + movq %rsi, %rdx + lea 208(%rsp), %rdi +..___tag_value___ynq.577: + call __dpml_multiply__@PLT +..___tag_value___ynq.578: +..B8.50: + movl $1, %edx + lea 256(%rsp), %rsi + movq %rsi, %rcx + lea 184(%rsp), %rdi +..___tag_value___ynq.579: + call __dpml_addsub__@PLT +..___tag_value___ynq.580: + jmp ..B8.25 +..B8.51: + lea 19640+__bessel_x_table(%rip), %rdi + lea 304(%rsp), %rsi + movl $2, %edx + lea 208(%rsp), %rcx +..___tag_value___ynq.581: + call __dpml_divide__@PLT +..___tag_value___ynq.582: +..B8.52: + xorl %edx, %edx + lea 256(%rsp), %rdi + movq %rdi, %rcx + lea 208(%rsp), %rsi +..___tag_value___ynq.583: + call __dpml_addsub__@PLT +..___tag_value___ynq.584: + jmp ..B8.47 +..B8.53: + cmpq 19592(%r8,%r9,8), %rax + ja ..B8.13 +..B8.54: + movq %r8, %rbx + addq 19600(%r8,%r9,8), %rbx + jmp ..B8.10 +..B8.55: + call __stack_chk_fail@PLT +..B8.56: + movq %r14, %rsi + lea 304(%rsp), %rdi + movl $2, %edx + lea 256(%rsp), %rcx +..___tag_value___ynq.585: + call __dpml_ux_large_order_bessel__ +..___tag_value___ynq.586: + jmp ..B8.25 + .align 16,0x90 + .cfi_endproc + .type __ynq,@function + .size __ynq,.-__ynq + .data +# -- End __ynq + .section .rodata, "a" + .align 16 + .align 16 +__bessel_x_table: + .long 4527112 + .long 882002208 + .long 4527112 + .long 609222656 + .long 4527112 + .long 340787200 + .long 0 + .long 0 + .long 2 + .long 0 + .long 2162758664 + .long 1056696334 + .long 15799304 + .long 796782607 + .long 2163807240 + .long 536868879 + .long 0 + .long 0 + .long 136 + .long 0 + .long 137 + .long 0 + .long 138 + .long 0 + .long 139 + .long 0 + .long 141 + .long 0 + .long 142 + .long 0 + .long 2943289511 + .long 514282869 + .long 12841452 + .long 4160750144 + .long 3101294049 + .long 2582161780 + .long 1312087176 + .long 1489306811 + .long 19644348 + .long 45583118 + .long 2057404378 + .long 3169098683 + .long 3035415578 + .long 893843444 + .long 337 + .long 0 + .long 1783633315 + .long 1777532950 + .long 15440 + .long 0 + .long 1098024042 + .long 3019602458 + .long 814258 + .long 0 + .long 225592541 + .long 3983311110 + .long 37212291 + .long 0 + .long 2852953733 + .long 2839658485 + .long 1458597808 + .long 0 + .long 4135355606 + .long 2153351721 + .long 1172250754 + .long 11 + .long 1418543880 + .long 1134849789 + .long 691229967 + .long 312 + .long 221999422 + .long 2942275987 + .long 892175906 + .long 7082 + .long 183528404 + .long 1091137495 + .long 33669418 + .long 128779 + .long 2062842702 + .long 3593466159 + .long 2350547321 + .long 1825862 + .long 3242024385 + .long 1732973365 + .long 1193716022 + .long 19485117 + .long 1037993584 + .long 3230003709 + .long 1091314384 + .long 149320065 + .long 865418991 + .long 2685299556 + .long 265703573 + .long 769292094 + .long 699915261 + .long 300027119 + .long 1754654657 + .long 2412548808 + .long 1339780591 + .long 830077839 + .long 3026944889 + .long 3889644321 + .long 4103150545 + .long 428322165 + .long 2828272473 + .long 2229721522 + .long 2 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 367384380 + .long 4326353 + .long 2148 + .long 0 + .long 3463681883 + .long 689773508 + .long 115915 + .long 0 + .long 1865635225 + .long 1707083401 + .long 5659280 + .long 0 + .long 57566505 + .long 2904667094 + .long 238211523 + .long 0 + .long 2506436672 + .long 4038967033 + .long 4242689712 + .long 1 + .long 900230770 + .long 2061385255 + .long 3485051853 + .long 59 + .long 3028033191 + .long 3312441247 + .long 2225862006 + .long 1485 + .long 2615755381 + .long 2826778077 + .long 1673380806 + .long 29835 + .long 355106258 + .long 2404984212 + .long 1016211595 + .long 472327 + .long 1503440334 + .long 2187913929 + .long 749248049 + .long 5704462 + .long 3147631426 + .long 2675016444 + .long 3447985920 + .long 50328354 + .long 3866449770 + .long 2131485908 + .long 579515915 + .long 305317757 + .long 1140039843 + .long 2720631446 + .long 456203296 + .long 1162742504 + .long 3233022265 + .long 2052397230 + .long 3523447208 + .long 2379802096 + .long 4168515076 + .long 4109278998 + .long 173166154 + .long 1854372776 + .long 2 + .long 0 + .long 1759813577 + .long 941616103 + .long 12816876 + .long 4227858976 + .long 1634871482 + .long 2963569369 + .long 683137648 + .long 2191944453 + .long 1580116130 + .long 3956925442 + .long 2076563715 + .long 714524096 + .long 1425042529 + .long 556010 + .long 0 + .long 0 + .long 2705967279 + .long 111702325 + .long 0 + .long 0 + .long 3713308765 + .long 3252247564 + .long 4 + .long 0 + .long 2100681787 + .long 1255672466 + .long 747 + .long 0 + .long 3619987580 + .long 2926178414 + .long 99420 + .long 0 + .long 2512861058 + .long 4217543322 + .long 11034432 + .long 0 + .long 2336326559 + .long 4282922616 + .long 1003296232 + .long 0 + .long 961767164 + .long 880412311 + .long 74952366 + .long 17 + .long 651638352 + .long 3978983768 + .long 3866178891 + .long 965 + .long 1596163871 + .long 1924711161 + .long 2529806704 + .long 41195 + .long 4143448985 + .long 965000726 + .long 2579935101 + .long 1257069 + .long 3252814079 + .long 2428688082 + .long 440599394 + .long 25575240 + .long 2037391762 + .long 3718324471 + .long 2593618161 + .long 310260222 + .long 3513168611 + .long 3970741434 + .long 128123702 + .long 1820672813 + .long 3402733470 + .long 3892867495 + .long 1270945360 + .long 2922852432 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1986947947 + .long 53265381 + .long 0 + .long 0 + .long 3270284272 + .long 1932314788 + .long 2 + .long 0 + .long 4084347788 + .long 3083682757 + .long 409 + .long 0 + .long 2552809164 + .long 4060325593 + .long 58254 + .long 0 + .long 3829133869 + .long 1310009699 + .long 6940915 + .long 0 + .long 3083277873 + .long 3078742755 + .long 680947971 + .long 0 + .long 3385783917 + .long 3611832980 + .long 2295622592 + .long 12 + .long 3171596108 + .long 2891115348 + .long 838843771 + .long 777 + .long 3771422218 + .long 1148182025 + .long 434950258 + .long 36482 + .long 393135174 + .long 80483983 + .long 3817092537 + .long 1235511 + .long 594123027 + .long 65162621 + .long 1218473398 + .long 28145623 + .long 3536617861 + .long 375824456 + .long 425129817 + .long 385237492 + .long 633237591 + .long 649365651 + .long 313906709 + .long 2545942344 + .long 873029334 + .long 423671385 + .long 1111949612 + .long 4235958077 + .long 4294967293 + .long 0 + .long 4159743234 + .long 1365459778 + .long 12825068 + .long 4227858976 + .long 1727418030 + .long 2322967398 + .long 1034782148 + .long 1761143608 + .long 748103118 + .long 681764742 + .long 1945985884 + .long 1037518188 + .long 2731139269 + .long 559058 + .long 0 + .long 0 + .long 3638286185 + .long 115784543 + .long 0 + .long 0 + .long 484918398 + .long 4013875548 + .long 4 + .long 0 + .long 868380236 + .long 106340102 + .long 775 + .long 0 + .long 3771022282 + .long 1666157217 + .long 103048 + .long 0 + .long 470645992 + .long 2100027425 + .long 11422638 + .long 0 + .long 1279250702 + .long 1788924811 + .long 1036227271 + .long 0 + .long 3067063928 + .long 3886781995 + .long 2181909072 + .long 17 + .long 103786080 + .long 119465851 + .long 1602069376 + .long 987 + .long 314091048 + .long 4120514941 + .long 1703984391 + .long 41665 + .long 3153492716 + .long 1769936992 + .long 3277791366 + .long 1248908 + .long 2480865882 + .long 357555572 + .long 1426486202 + .long 24641724 + .long 925215435 + .long 3875415602 + .long 2242310174 + .long 283170307 + .long 1206749920 + .long 1745236754 + .long 421850802 + .long 1512988987 + .long 554528472 + .long 4124376878 + .long 999726568 + .long 2331757501 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 844883384 + .long 48877615 + .long 0 + .long 0 + .long 613626429 + .long 1016694622 + .long 2 + .long 0 + .long 733791182 + .long 4037492605 + .long 370 + .long 0 + .long 2511602797 + .long 962949943 + .long 52209 + .long 0 + .long 2469661725 + .long 4226370589 + .long 6143972 + .long 0 + .long 2060721069 + .long 3581658067 + .long 593539814 + .long 0 + .long 2839602819 + .long 4222464368 + .long 3064291281 + .long 10 + .long 592311022 + .long 275206449 + .long 2221002398 + .long 647 + .long 3453980290 + .long 1100410175 + .long 2256369516 + .long 29367 + .long 965726650 + .long 341239821 + .long 1020304938 + .long 947922 + .long 2152956293 + .long 1358966229 + .long 796742083 + .long 20128900 + .long 2203770174 + .long 4010517667 + .long 1001215390 + .long 247246889 + .long 118635824 + .long 336180557 + .long 907042493 + .long 1379503488 + .long 1731363265 + .long 2376282645 + .long 3253758107 + .long 2155609720 + .long 4294967293 + .long 0 + .long 1133938837 + .long 1788275660 + .long 12816876 + .long 4227858976 + .long 328577348 + .long 3165265924 + .long 1527252342 + .long 1339392541 + .long 2394531985 + .long 243403399 + .long 1651082908 + .long 3768234999 + .long 1764410062 + .long 1127868 + .long 0 + .long 0 + .long 380965293 + .long 236501030 + .long 0 + .long 0 + .long 4057780011 + .long 296466121 + .long 10 + .long 0 + .long 1915520970 + .long 2413700929 + .long 1578 + .long 0 + .long 2515416277 + .long 1400529095 + .long 209346 + .long 0 + .long 1507502659 + .long 119133009 + .long 23121417 + .long 0 + .long 822245729 + .long 2123535665 + .long 2086838594 + .long 0 + .long 2761614169 + .long 2187408238 + .long 28089432 + .long 35 + .long 552668793 + .long 2572470762 + .long 825632309 + .long 1954 + .long 1089676525 + .long 4007660420 + .long 2284740089 + .long 81273 + .long 3790860620 + .long 4250011568 + .long 3911718864 + .long 2386138 + .long 1569325755 + .long 1413720016 + .long 751491568 + .long 45731817 + .long 955105128 + .long 1250521740 + .long 2097840313 + .long 506337017 + .long 1624392615 + .long 4258574603 + .long 3379569620 + .long 2624122564 + .long 4107144163 + .long 2368467334 + .long 1634973330 + .long 3993629493 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 818934838 + .long 89458952 + .long 0 + .long 0 + .long 1917175450 + .long 275918876 + .long 4 + .long 0 + .long 745599157 + .long 3172395316 + .long 667 + .long 0 + .long 2952822384 + .long 492051402 + .long 92937 + .long 0 + .long 2206545778 + .long 108664272 + .long 10789849 + .long 0 + .long 3593487476 + .long 2223761325 + .long 1025213015 + .long 0 + .long 4186460497 + .long 2115107000 + .long 546575231 + .long 18 + .long 4222869425 + .long 1697786641 + .long 1644425336 + .long 1067 + .long 2279245768 + .long 3297743944 + .long 144043411 + .long 46814 + .long 528690514 + .long 2305832912 + .long 3885610801 + .long 1446642 + .long 3948180674 + .long 1400240622 + .long 2848238597 + .long 29038477 + .long 365799999 + .long 3493109055 + .long 720503959 + .long 333431672 + .long 4157886487 + .long 4286999543 + .long 464978815 + .long 1767352013 + .long 3339500879 + .long 5789261 + .long 740497786 + .long 2709489262 + .long 4294967292 + .long 0 + .long 675685466 + .long 2210650544 + .long 12825068 + .long 4227858976 + .long 2475592912 + .long 4007987703 + .long 795233231 + .long 3544111414 + .long 3119445785 + .long 4019086602 + .long 1815298636 + .long 3651400695 + .long 250417896 + .long 1132895 + .long 0 + .long 0 + .long 1599660003 + .long 238893558 + .long 0 + .long 0 + .long 4178878964 + .long 640014589 + .long 10 + .long 0 + .long 3652653430 + .long 1664916825 + .long 1586 + .long 0 + .long 506609104 + .long 279824532 + .long 209578 + .long 0 + .long 3394823516 + .long 2710891899 + .long 23032181 + .long 0 + .long 1068742364 + .long 3396859346 + .long 2065409978 + .long 0 + .long 1532264156 + .long 1783373111 + .long 1537162281 + .long 34 + .long 3404313527 + .long 645034109 + .long 1238696626 + .long 1897 + .long 2815751506 + .long 1216048877 + .long 2381163022 + .long 77819 + .long 681356606 + .long 1742374831 + .long 1470157118 + .long 2245756 + .long 3583839604 + .long 3430133311 + .long 3428750273 + .long 42198880 + .long 2624104293 + .long 3836925937 + .long 2616934709 + .long 458497922 + .long 4091889117 + .long 2154475757 + .long 1334377092 + .long 2344404304 + .long 3811467832 + .long 4225344580 + .long 3014131639 + .long 3548440700 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2101683395 + .long 163038220 + .long 0 + .long 0 + .long 1150331703 + .long 1497034637 + .long 7 + .long 0 + .long 1295008257 + .long 2962522183 + .long 1195 + .long 0 + .long 193789761 + .long 1257830278 + .long 164530 + .long 0 + .long 3810960890 + .long 1878269909 + .long 18845080 + .long 0 + .long 2863024615 + .long 258783337 + .long 1761897164 + .long 0 + .long 2435461135 + .long 4254653612 + .long 2378780257 + .long 30 + .long 3635296493 + .long 4161741958 + .long 2074908190 + .long 1757 + .long 3250897880 + .long 2210089015 + .long 2132559608 + .long 74948 + .long 2166588251 + .long 3427170173 + .long 756319997 + .long 2241223 + .long 107629526 + .long 2814783011 + .long 580266263 + .long 43402774 + .long 2488417593 + .long 4037868436 + .long 2684236844 + .long 482393505 + .long 1636043988 + .long 2549915956 + .long 1055410979 + .long 2500896928 + .long 2063349270 + .long 3231350804 + .long 4156853657 + .long 3802515847 + .long 4294967291 + .long 0 + .long 191176124 + .long 2632795962 + .long 12816876 + .long 4227858976 + .long 1355787731 + .long 2425457148 + .long 539364904 + .long 1079897623 + .long 897043330 + .long 2066037045 + .long 1494461853 + .long 2159441332 + .long 2366379069 + .long 1131867 + .long 0 + .long 0 + .long 161545432 + .long 239220328 + .long 0 + .long 0 + .long 762722372 + .long 576200370 + .long 10 + .long 0 + .long 3468035492 + .long 1642011913 + .long 1578 + .long 0 + .long 4253764606 + .long 2733292311 + .long 207600 + .long 0 + .long 2811470101 + .long 3269311219 + .long 22691285 + .long 0 + .long 1825255966 + .long 1189284970 + .long 2021353589 + .long 0 + .long 717526141 + .long 2244953537 + .long 1522450794 + .long 33 + .long 693565287 + .long 2333767130 + .long 715945548 + .long 1824 + .long 2985180089 + .long 935432992 + .long 3298648348 + .long 73985 + .long 1392357808 + .long 2627674694 + .long 3107871798 + .long 2108973 + .long 3903806984 + .long 3473675411 + .long 4215247699 + .long 39146099 + .long 2236383345 + .long 2775867013 + .long 1051360344 + .long 420899965 + .long 715332657 + .long 3204539120 + .long 3177676604 + .long 2136936117 + .long 1567224951 + .long 2092241552 + .long 1304170706 + .long 3225156278 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3855812151 + .long 148081926 + .long 0 + .long 0 + .long 1028065361 + .long 2668697612 + .long 6 + .long 0 + .long 728439685 + .long 892227407 + .long 1067 + .long 0 + .long 615906957 + .long 1950415562 + .long 145255 + .long 0 + .long 3284206690 + .long 4202823521 + .long 16428718 + .long 0 + .long 1576659798 + .long 3860187404 + .long 1513740564 + .long 0 + .long 1223428711 + .long 1000755308 + .long 3492805977 + .long 25 + .long 1363712775 + .long 563079876 + .long 2891886022 + .long 1456 + .long 1912616499 + .long 4019273916 + .long 1170042322 + .long 60815 + .long 2578791056 + .long 3763338518 + .long 4013988507 + .long 1778302 + .long 596369036 + .long 4167829437 + .long 495223280 + .long 33706721 + .long 3069656582 + .long 1025646758 + .long 2029385299 + .long 368055588 + .long 4229256156 + .long 252497843 + .long 655863054 + .long 1886199584 + .long 3468886839 + .long 4222796798 + .long 2935312587 + .long 2855531945 + .long 4294967291 + .long 0 + .long 2797952740 + .long 3054806814 + .long 12825068 + .long 4227858976 + .long 2679935261 + .long 2846977675 + .long 1518593598 + .long 771365947 + .long 2901840529 + .long 102047653 + .long 404923885 + .long 709259131 + .long 475240934 + .long 1125214 + .long 0 + .long 0 + .long 1836195777 + .long 237921320 + .long 0 + .long 0 + .long 620715017 + .long 203920416 + .long 10 + .long 0 + .long 2730396855 + .long 4074598327 + .long 1558 + .long 0 + .long 149951721 + .long 1542475780 + .long 204126 + .long 0 + .long 895086698 + .long 26046181 + .long 22194201 + .long 0 + .long 1052098554 + .long 3499556639 + .long 1964976743 + .long 0 + .long 3912081837 + .long 3256319751 + .long 845978380 + .long 32 + .long 2103533506 + .long 1288917748 + .long 344362072 + .long 1747 + .long 586607141 + .long 2789855780 + .long 789521480 + .long 70264 + .long 1029756229 + .long 2597195099 + .long 1036923741 + .long 1985929 + .long 570319344 + .long 1441637551 + .long 3714173380 + .long 36574571 + .long 1955754200 + .long 3807195269 + .long 90410504 + .long 390763661 + .long 2874958444 + .long 3633243115 + .long 2931863300 + .long 1975635819 + .long 32243731 + .long 2591757144 + .long 3895319176 + .long 2976685396 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3502958424 + .long 134252990 + .long 0 + .long 0 + .long 2150545646 + .long 4111632521 + .long 5 + .long 0 + .long 2999463670 + .long 3120574364 + .long 951 + .long 0 + .long 681502082 + .long 4195687681 + .long 128253 + .long 0 + .long 442998991 + .long 979480158 + .long 14344565 + .long 0 + .long 151969242 + .long 4070078334 + .long 1305331397 + .long 0 + .long 1826390155 + .long 1249420678 + .long 4104872299 + .long 21 + .long 1355768955 + .long 3758834208 + .long 3412700795 + .long 1220 + .long 1644384830 + .long 2135273975 + .long 2887874099 + .long 50190 + .long 1150050798 + .long 2243957583 + .long 2798432622 + .long 1445747 + .long 3460890697 + .long 2393108922 + .long 2317365582 + .long 27037249 + .long 135336093 + .long 93459488 + .long 4047224670 + .long 292116325 + .long 2632066877 + .long 2478679361 + .long 3592211274 + .long 1486901023 + .long 4259160346 + .long 2383522946 + .long 1229950112 + .long 2245322564 + .long 4294967291 + .long 0 + .long 4131724546 + .long 247119503 + .long 229390 + .long 4227858728 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1920268374 + .long 676671 + .long 0 + .long 0 + .long 2648589321 + .long 145893005 + .long 0 + .long 0 + .long 86363579 + .long 792199897 + .long 6 + .long 0 + .long 3569661012 + .long 3338031321 + .long 964 + .long 0 + .long 3537357668 + .long 2546852361 + .long 127350 + .long 0 + .long 1674639321 + .long 989707703 + .long 14008565 + .long 0 + .long 633069455 + .long 3178427980 + .long 1260770870 + .long 0 + .long 2929308222 + .long 1214878390 + .long 581189477 + .long 21 + .long 3037977477 + .long 3608983388 + .long 2481839655 + .long 1183 + .long 1571270935 + .long 1253493999 + .long 1158050441 + .long 49710 + .long 2588063047 + .long 3245086386 + .long 381774870 + .long 1491308 + .long 2638540175 + .long 477218587 + .long 3340530119 + .long 29826161 + .long 1326835123 + .long 1431655765 + .long 1431655765 + .long 357913941 + .long 4293747565 + .long 4294967295 + .long 4294967295 + .long 2147483647 + .long 4294964933 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 0 + .long 0 + .long 105434711 + .long 715574136 + .long 12825068 + .long 4227858976 + .long 2071479615 + .long 4114262957 + .long 3040350773 + .long 3578447305 + .long 1647168078 + .long 978698920 + .long 1144287138 + .long 3827795094 + .long 3787403973 + .long 562609 + .long 0 + .long 0 + .long 1649578671 + .long 117913179 + .long 0 + .long 0 + .long 3082368152 + .long 40122077 + .long 5 + .long 0 + .long 602895375 + .long 3952322020 + .long 783 + .long 0 + .long 3838465116 + .long 2181233212 + .long 103846 + .long 0 + .long 851468155 + .long 4001763569 + .long 11469451 + .long 0 + .long 3659498813 + .long 523695164 + .long 1037041443 + .long 0 + .long 2978199351 + .long 773277203 + .long 2051066178 + .long 17 + .long 4092624060 + .long 3930860161 + .long 3294762475 + .long 984 + .long 1105652893 + .long 1066438988 + .long 3642064414 + .long 41652 + .long 2196971596 + .long 2146191353 + .long 3442355222 + .long 1259557 + .long 3918894073 + .long 188553237 + .long 818155667 + .long 25403502 + .long 852571760 + .long 3121326526 + .long 2509267963 + .long 306918409 + .long 2896427178 + .long 2552665716 + .long 2229539464 + .long 1835168886 + .long 1453277625 + .long 518768794 + .long 1711011538 + .long 3459676865 + .long 0 + .long 0 + .long 2062472710 + .long 69166 + .long 0 + .long 0 + .long 673615662 + .long 23833985 + .long 0 + .long 0 + .long 630248642 + .long 363685088 + .long 1 + .long 0 + .long 288759411 + .long 2697305718 + .long 181 + .long 0 + .long 2130785052 + .long 823708847 + .long 25870 + .long 0 + .long 1430316470 + .long 3023974030 + .long 3089586 + .long 0 + .long 3827036731 + .long 3302510044 + .long 304068797 + .long 0 + .long 3738696708 + .long 3274114857 + .long 2670490624 + .long 5 + .long 287265850 + .long 4109473262 + .long 3360573366 + .long 350 + .long 38249035 + .long 2812769293 + .long 2052670485 + .long 16622 + .long 3926290357 + .long 206759826 + .long 2443135158 + .long 571444 + .long 1809246839 + .long 3759763742 + .long 1694050886 + .long 13356266 + .long 1847069514 + .long 3357213528 + .long 2594247192 + .long 192045418 + .long 1427481913 + .long 3504276391 + .long 3430325004 + .long 1423790384 + .long 900295939 + .long 3843660490 + .long 2372410664 + .long 3611630842 + .long 4294967294 + .long 0 + .long 774013863 + .long 1145724988 + .long 12816876 + .long 4227858976 + .long 2744287014 + .long 3766464413 + .long 1053213460 + .long 3969062622 + .long 1083456455 + .long 3049621789 + .long 3365086587 + .long 561540346 + .long 2996396832 + .long 575091 + .long 0 + .long 0 + .long 42660608 + .long 117761546 + .long 0 + .long 0 + .long 3056183536 + .long 25400137 + .long 5 + .long 0 + .long 3539354956 + .long 964064098 + .long 784 + .long 0 + .long 1133846550 + .long 3354628177 + .long 103987 + .long 0 + .long 837408368 + .long 1875825334 + .long 11493772 + .long 0 + .long 4020356818 + .long 15105701 + .long 1039623118 + .long 0 + .long 2432213228 + .long 4116600081 + .long 2213395342 + .long 17 + .long 346536517 + .long 2329406249 + .long 1562759336 + .long 985 + .long 1904777685 + .long 777730941 + .long 3468653957 + .long 41521 + .long 2565172885 + .long 3392131685 + .long 216627896 + .long 1245806 + .long 777484384 + .long 1373172746 + .long 529073424 + .long 24734325 + .long 1189796029 + .long 1140288371 + .long 1770133260 + .long 289389693 + .long 2194668596 + .long 3631308278 + .long 3147219318 + .long 1613893367 + .long 344927104 + .long 1168140252 + .long 980702046 + .long 2577974684 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1881749350 + .long 46062706 + .long 0 + .long 0 + .long 2009952654 + .long 475434148 + .long 2 + .long 0 + .long 3595153284 + .long 3894518978 + .long 350 + .long 0 + .long 1401741016 + .long 800557075 + .long 49546 + .long 0 + .long 1250374609 + .long 1417939249 + .long 5854570 + .long 0 + .long 3066837935 + .long 3745800702 + .long 568662855 + .long 0 + .long 4187727968 + .long 1730013373 + .long 1461665574 + .long 10 + .long 3341641980 + .long 2588791038 + .long 1829968615 + .long 631 + .long 888818201 + .long 3523374130 + .long 852659386 + .long 29067 + .long 3905449900 + .long 720793762 + .long 1836357526 + .long 959598 + .long 711023215 + .long 2187868163 + .long 363719992 + .long 21124528 + .long 3782390642 + .long 1386816912 + .long 3690959132 + .long 275994811 + .long 3562870039 + .long 2887822114 + .long 2407074109 + .long 1720896075 + .long 723327461 + .long 1298307143 + .long 454424891 + .long 2939711024 + .long 4294967293 + .long 0 + .long 4220957082 + .long 1571153381 + .long 12825068 + .long 4227858976 + .long 4024519172 + .long 2730919557 + .long 1456036120 + .long 3256132268 + .long 2931624203 + .long 1339507405 + .long 1357793012 + .long 1094045067 + .long 1129712150 + .long 1138961 + .long 0 + .long 0 + .long 2372829177 + .long 237557530 + .long 0 + .long 0 + .long 534122416 + .long 423932365 + .long 10 + .long 0 + .long 4247263216 + .long 4283734547 + .long 1580 + .long 0 + .long 2387955306 + .long 607897802 + .long 209396 + .long 0 + .long 2812500241 + .long 994269493 + .long 23101510 + .long 0 + .long 3000333735 + .long 388858992 + .long 2083539857 + .long 0 + .long 1161363350 + .long 3153424268 + .long 4076649817 + .long 34 + .long 1819801357 + .long 1812729011 + .long 330148996 + .long 1953 + .long 3163500019 + .long 3864465446 + .long 4064814974 + .long 81467 + .long 3858761013 + .long 3692736596 + .long 1902533809 + .long 2406436 + .long 3293643408 + .long 375345917 + .long 2826147377 + .long 46631566 + .long 4164807482 + .long 4162856869 + .long 2610851470 + .long 525451848 + .long 2048614181 + .long 1569367797 + .long 3543942876 + .long 2777034414 + .long 3312093651 + .long 708453697 + .long 1978042629 + .long 4289897122 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2071065822 + .long 86614531 + .long 0 + .long 0 + .long 2391713785 + .long 4060239028 + .long 3 + .long 0 + .long 4029056008 + .long 1846783416 + .long 650 + .long 0 + .long 161647879 + .long 3413412248 + .long 90917 + .long 0 + .long 436274283 + .long 2466277660 + .long 10613189 + .long 0 + .long 671943584 + .long 553150431 + .long 1015563947 + .long 0 + .long 1753238306 + .long 1517906611 + .long 532738342 + .long 18 + .long 618689867 + .long 596492050 + .long 2460930076 + .long 1080 + .long 414131426 + .long 1367052230 + .long 3308909536 + .long 48209 + .long 4126473295 + .long 3381931776 + .long 1805298000 + .long 1525871 + .long 636148702 + .long 2186154781 + .long 2942928489 + .long 31683165 + .long 999999630 + .long 4126401816 + .long 259460410 + .long 380946890 + .long 231980038 + .long 363549591 + .long 883055596 + .long 2118559672 + .long 3622330114 + .long 1609129610 + .long 63100786 + .long 3373399958 + .long 4294967292 + .long 0 + .long 1588683414 + .long 1994957096 + .long 12816876 + .long 4227858976 + .long 2267877675 + .long 3576551320 + .long 1765045200 + .long 3464483214 + .long 1351689592 + .long 3801296041 + .long 352384788 + .long 331703635 + .long 605298272 + .long 1136492 + .long 0 + .long 0 + .long 2681104739 + .long 238950871 + .long 0 + .long 0 + .long 3149807504 + .long 621710226 + .long 10 + .long 0 + .long 2595166296 + .long 121246070 + .long 1585 + .long 0 + .long 2215012362 + .long 2482367452 + .long 209363 + .long 0 + .long 470943915 + .long 668008525 + .long 23014074 + .long 0 + .long 3763658407 + .long 3343124614 + .long 2065508072 + .long 0 + .long 249623666 + .long 2390602642 + .long 1795904366 + .long 34 + .long 1346725057 + .long 2927659279 + .long 1029310809 + .long 1906 + .long 3831989490 + .long 3024162362 + .long 457912312 + .long 78555 + .long 1623643704 + .long 979247650 + .long 4029398248 + .long 2282874 + .long 2791098952 + .long 2391841680 + .long 2696257895 + .long 43306505 + .long 262637107 + .long 3763159487 + .long 2938992385 + .long 475778611 + .long 3299175406 + .long 3677201670 + .long 2349553020 + .long 2458659840 + .long 206020084 + .long 2363120772 + .long 2638136209 + .long 3751386051 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3034634732 + .long 80259059 + .long 0 + .long 0 + .long 2987375659 + .long 2703374687 + .long 3 + .long 0 + .long 1215607278 + .long 4163686255 + .long 592 + .long 0 + .long 781938720 + .long 2086477677 + .long 82005 + .long 0 + .long 3556471813 + .long 3031971904 + .long 9451560 + .long 0 + .long 2005655437 + .long 2494233436 + .long 890598760 + .long 0 + .long 1167836918 + .long 114850616 + .long 2568442225 + .long 15 + .long 2351511177 + .long 1547877599 + .long 2724662709 + .long 908 + .long 1583056039 + .long 1830443712 + .long 1719394286 + .long 39382 + .long 1124627201 + .long 674092017 + .long 1868383046 + .long 1202161 + .long 4262245498 + .long 1815295967 + .long 3756878985 + .long 23872494 + .long 1013133814 + .long 1390137141 + .long 1845508344 + .long 272711216 + .long 2632746813 + .long 493954138 + .long 4257964097 + .long 1450886530 + .long 1659393003 + .long 4235627183 + .long 3605632322 + .long 2252460395 + .long 4294967292 + .long 0 + .long 1932081087 + .long 2418003218 + .long 12825068 + .long 4227858976 + .long 675685466 + .long 2210650544 + .long 2635457388 + .long 3001216681 + .long 2383987892 + .long 1958452314 + .long 200318573 + .long 1670080688 + .long 1772035109 + .long 1132935 + .long 0 + .long 0 + .long 2224132738 + .long 239067824 + .long 0 + .long 0 + .long 2504702558 + .long 548466910 + .long 10 + .long 0 + .long 120798343 + .long 3554901277 + .long 1577 + .long 0 + .long 2434954499 + .long 1660365081 + .long 207659 + .long 0 + .long 2744534538 + .long 1767005024 + .long 22722744 + .long 0 + .long 1354085614 + .long 573653951 + .long 2027648348 + .long 0 + .long 2302238895 + .long 940817979 + .long 2333007942 + .long 33 + .long 4044378246 + .long 2424318367 + .long 54614345 + .long 1841 + .long 3277428544 + .long 937510890 + .long 2353849014 + .long 75024 + .long 4005612974 + .long 1580435742 + .long 1601652905 + .long 2151432 + .long 3782038889 + .long 2892349902 + .long 3709353570 + .long 40211969 + .long 2209533886 + .long 1632935844 + .long 1972351296 + .long 435469920 + .long 2489865929 + .long 3249608891 + .long 2176055770 + .long 2225282526 + .long 4163770951 + .long 1426482641 + .long 75146285 + .long 3375249381 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2220915002 + .long 147504303 + .long 0 + .long 0 + .long 3383683424 + .long 2662024159 + .long 6 + .long 0 + .long 4203741875 + .long 3065385408 + .long 1071 + .long 0 + .long 94574798 + .long 3694012699 + .long 146649 + .long 0 + .long 548197575 + .long 3705365680 + .long 16693691 + .long 0 + .long 2971661595 + .long 3995690294 + .long 1550219778 + .long 0 + .long 3364157924 + .long 536970539 + .long 2951498969 + .long 26 + .long 3606982515 + .long 2998613798 + .long 1572386296 + .long 1523 + .long 54159713 + .long 2382254602 + .long 1960159626 + .long 64476 + .long 164299812 + .long 2501105432 + .long 2657580848 + .long 1915496 + .long 4191466314 + .long 1475491836 + .long 409725690 + .long 36942237 + .long 2000214888 + .long 3808326374 + .long 4191271566 + .long 410491162 + .long 3021924263 + .long 3759042010 + .long 567945948 + .long 2137524835 + .long 2922089864 + .long 3203830329 + .long 752382353 + .long 3278805360 + .long 4294967291 + .long 0 + .long 223335381 + .long 2840633637 + .long 12816876 + .long 4227858976 + .long 191176124 + .long 2632795962 + .long 792829484 + .long 4194095148 + .long 1561179743 + .long 586327156 + .long 2807878837 + .long 3545818423 + .long 1415596998 + .long 1125924 + .long 0 + .long 0 + .long 2335397241 + .long 237899312 + .long 0 + .long 0 + .long 898966976 + .long 220219689 + .long 10 + .long 0 + .long 3140042207 + .long 3171383055 + .long 1560 + .long 0 + .long 2021920923 + .long 1061467961 + .long 204590 + .long 0 + .long 1780915469 + .long 3394528573 + .long 22279398 + .long 0 + .long 2938289575 + .long 3726010345 + .long 1976658045 + .long 0 + .long 1742882295 + .long 3191343047 + .long 2047550512 + .long 32 + .long 3647296052 + .long 2253947992 + .long 1300129447 + .long 1768 + .long 2864334604 + .long 1571083743 + .long 2473956825 + .long 71411 + .long 902177211 + .long 1309134586 + .long 1494319522 + .long 2027873 + .long 1978202312 + .long 2898857432 + .long 1838265108 + .long 37534288 + .long 440015974 + .long 4230775195 + .long 1255344562 + .long 402981746 + .long 1205443830 + .long 4140044432 + .long 3282462476 + .long 2046231097 + .long 2809323527 + .long 1074462473 + .long 1051546203 + .long 3093465233 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1994591040 + .long 134874738 + .long 0 + .long 0 + .long 1154796671 + .long 33466848 + .long 6 + .long 0 + .long 944609558 + .long 611410016 + .long 964 + .long 0 + .long 3394269576 + .long 3253723903 + .long 130617 + .long 0 + .long 1604599336 + .long 2571734283 + .long 14700043 + .long 0 + .long 2720136884 + .long 1760790051 + .long 1347449133 + .long 0 + .long 3340661604 + .long 3195040324 + .long 3680379603 + .long 22 + .long 3451695816 + .long 2081337828 + .long 1427065647 + .long 1283 + .long 2755833528 + .long 3578899323 + .long 1127406403 + .long 53342 + .long 2103438216 + .long 2925829331 + .long 133275521 + .long 1554875 + .long 3003940918 + .long 1302060887 + .long 2008749614 + .long 29436400 + .long 4279932662 + .long 1473928468 + .long 533396292 + .long 321840330 + .long 3248261436 + .long 2035472962 + .long 372258839 + .long 1655927148 + .long 3127294521 + .long 3128066919 + .long 2865156314 + .long 2523236171 + .long 4294967291 + .long 0 + .long 1890690921 + .long 3263011055 + .long 12825068 + .long 4227858976 + .long 2797952740 + .long 3054806814 + .long 1894667006 + .long 214237447 + .long 1296756846 + .long 4060330468 + .long 1098085821 + .long 3604642180 + .long 1726893371 + .long 1115219 + .long 0 + .long 0 + .long 494710856 + .long 235638241 + .long 0 + .long 0 + .long 1193585816 + .long 3981686648 + .long 9 + .long 0 + .long 143797405 + .long 762868814 + .long 1536 + .long 0 + .long 898881458 + .long 2220674218 + .long 200569 + .long 0 + .long 271788931 + .long 1836576498 + .long 21741122 + .long 0 + .long 3732597210 + .long 2567748600 + .long 1918751890 + .long 0 + .long 3683010637 + .long 2674911154 + .long 1453366689 + .long 31 + .long 3314792629 + .long 3590832641 + .long 792084225 + .long 1695 + .long 710884882 + .long 1421882797 + .long 453673326 + .long 67984 + .long 4289998525 + .long 1545801705 + .long 2082770245 + .long 1917055 + .long 1427259630 + .long 3087470940 + .long 1747456958 + .long 35251400 + .long 2597591904 + .long 3049486553 + .long 2056710479 + .long 376393410 + .long 2213091204 + .long 2641098163 + .long 3971809407 + .long 1903717223 + .long 3244722564 + .long 177715146 + .long 3090222263 + .long 2872209565 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 4193727727 + .long 246007177 + .long 0 + .long 0 + .long 768822418 + .long 3782320021 + .long 10 + .long 0 + .long 2196079823 + .long 201893182 + .long 1732 + .long 0 + .long 1661061158 + .long 4260475543 + .long 232537 + .long 0 + .long 3959757821 + .long 1648015928 + .long 25908825 + .long 0 + .long 2136418328 + .long 2790862444 + .long 2348699355 + .long 0 + .long 14984150 + .long 3359899422 + .long 1557173094 + .long 39 + .long 2579163115 + .long 4209094591 + .long 2975956643 + .long 2181 + .long 809874233 + .long 1287653529 + .long 1784169535 + .long 89477 + .long 836980350 + .long 209256478 + .long 3015626027 + .long 2573945 + .long 2016221741 + .long 1745099515 + .long 1018088912 + .long 48139690 + .long 3329474215 + .long 1010710723 + .long 642962579 + .long 521003091 + .long 801578433 + .long 3224757113 + .long 3341503980 + .long 2660978634 + .long 2199935228 + .long 4052003304 + .long 2221814426 + .long 4038241008 + .long 4294967290 + .long 0 + .long 3178730751 + .long 116147812 + .long 14854636 + .long 416 + .long 416371481 + .long 2823641499 + .long 2506915568 + .long 4124207639 + .long 950494682 + .long 256731865 + .long 619428904 + .long 3037288495 + .long 4208811624 + .long 884105690 + .long 0 + .long 0 + .long 3410106176 + .long 4245208708 + .long 126 + .long 0 + .long 3116091236 + .long 3070791485 + .long 44137 + .long 0 + .long 1379902983 + .long 2256834745 + .long 12232777 + .long 0 + .long 2097914520 + .long 545273602 + .long 2619411277 + .long 0 + .long 215423817 + .long 3507318412 + .long 256238311 + .long 97 + .long 3668117219 + .long 4022295396 + .long 2420542464 + .long 10890 + .long 3822143167 + .long 3930114069 + .long 1325150521 + .long 798528 + .long 3699121161 + .long 791807715 + .long 67391017 + .long 33958538 + .long 3257898816 + .long 678025854 + .long 1894699409 + .long 674718922 + .long 1201340557 + .long 2594901103 + .long 3933905415 + .long 3704843775 + .long 4294967294 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 982743186 + .long 1840382683 + .long 8 + .long 0 + .long 2770471380 + .long 1232287742 + .long 3186 + .long 0 + .long 2689925901 + .long 4291161637 + .long 993651 + .long 0 + .long 1865452386 + .long 278667130 + .long 243198017 + .long 0 + .long 941914362 + .long 1579381843 + .long 2208801237 + .long 10 + .long 4030005343 + .long 1439537596 + .long 2913266490 + .long 1415 + .long 897709932 + .long 2611261457 + .long 3831192043 + .long 129715 + .long 2599986828 + .long 562288571 + .long 873738186 + .long 7347842 + .long 1676792497 + .long 2643238970 + .long 1059645264 + .long 218261805 + .long 3968061936 + .long 1814410518 + .long 4215318874 + .long 2360677848 + .long 4294967294 + .long 0 + .long 1965065697 + .long 125333813 + .long 29671681 + .long 368 + .long 2696892906 + .long 3837883846 + .long 4163818448 + .long 2636579655 + .long 352076257 + .long 2995873374 + .long 2356022824 + .long 2864685933 + .long 507647155 + .long 87534215 + .long 364999993 + .long 2297262027 + .long 3804603314 + .long 421232362 + .long 623004025 + .long 2436698064 + .long 857209363 + .long 4104727312 + .long 1300779075 + .long 2300222395 + .long 3549420260 + .long 815695431 + .long 3490474032 + .long 2175015012 + .long 273829883 + .long 837019448 + .long 1150859439 + .long 4129001094 + .long 166114890 + .long 262582295 + .long 2200440235 + .long 3934411649 + .long 4260765987 + .long 1496016656 + .long 613554758 + .long 3765455772 + .long 1537995402 + .long 3112915065 + .long 3831973801 + .long 3621881222 + .long 371259347 + .long 563988192 + .long 2577068580 + .long 3504039397 + .long 3892719810 + .long 2774136061 + .long 761863973 + .long 3413069278 + .long 932429307 + .long 3533847854 + .long 670352073 + .long 3351189942 + .long 332608650 + .long 3102655069 + .long 2958547113 + .long 3322177573 + .long 146996155 + .long 3411645617 + .long 2215850181 + .long 3332037184 + .long 590982538 + .long 2197714658 + .long 1764878165 + .long 3390200984 + .long 952267699 + .long 417090737 + .long 3487943763 + .long 3519763458 + .long 1338819266 + .long 2605877443 + .long 347561299 + .long 3761505334 + .long 3379093939 + .long 2405540353 + .long 1506019226 + .long 3884741458 + .long 2785505456 + .long 3086386584 + .long 2046080941 + .long 3789068741 + .long 1518238185 + .long 1088338119 + .long 1804079185 + .long 4226925859 + .long 2303172266 + .long 2741263628 + .long 633622237 + .long 3777083586 + .long 3757196004 + .long 294895316 + .long 27640459 + .long 432 + .long 2828420652 + .long 3361833042 + .long 1412248364 + .long 2211183849 + .long 0 + .long 3547577142 + .long 1 + .long 0 + .long 2851890648 + .long 450899591 + .long 287024625 + .long 4159553752 + .long 3788600515 + .long 2561792324 + .long 3962766183 + .long 3512577319 + .long 2861699545 + .long 2196522185 + .long 1554209519 + .long 4198958626 + .long 3194489346 + .long 2786967510 + .long 3304318871 + .long 3344542374 + .long 4105608152 + .long 867728568 + .long 2708443992 + .long 3505223656 + .long 1032912387 + .long 3711167273 + .long 1214238009 + .long 2611213035 + .long 3368625691 + .long 5584441 + .long 2611408711 + .long 2384597091 + .long 1152098306 + .long 3591611965 + .long 2962228819 + .long 3281323244 + .long 3071980506 + .long 3920864562 + .long 3855393805 + .long 2582452787 + .long 3343479107 + .long 1168797990 + .long 3053975971 + .long 3222544278 + .long 3909139483 + .long 1083468961 + .long 2101774947 + .long 2160722632 + .long 2110801092 + .long 4019214560 + .long 1350065479 + .long 2376260138 + .long 42240602 + .long 3769900699 + .long 2854857645 + .long 2686999005 + .long 4198697477 + .long 4081736268 + .long 2846299562 + .long 2478988733 + .long 427675101 + .long 2445602520 + .long 4233423029 + .long 2355264427 + .long 1558515652 + .long 2279564152 + .long 62666641 + .long 3298296210 + .long 1417642332 + .long 61859471 + .long 2115062510 + .long 2696409612 + .long 326492679 + .long 2534854374 + .long 1679925266 + .long 2160906787 + .long 3251033635 + .long 2671487866 + .long 2862247032 + .long 3574405396 + .long 3009660033 + .long 339349497 + .long 3007548001 + .long 2840034127 + .long 2252903388 + .long 1330394071 + .long 2157393054 + .long 2200692478 + .long 621144332 + .long 3987984878 + .long 1728372573 + .long 3841939891 + .long 2649374871 + .long 2008708732 + .long 1354882191 + .long 2904204888 + .long 3398077461 + .long 3906455313 + .long 2501808239 + .long 2340852904 + .long 257973487 + .long 728759453 + .long 30163463 + .long 848 + .long 3266633231 + .long 4249524844 + .long 2065907802 + .long 2501410748 + .long 2077120351 + .long 1559182036 + .long 2148606178 + .long 4119882265 + .long 315045067 + .long 14812806 + .long 1274331647 + .long 3156365682 + .long 238086315 + .long 2517423111 + .long 2041601736 + .long 2711078025 + .long 3652406632 + .long 753691269 + .long 2734041400 + .long 3820625006 + .long 2380832782 + .long 158270193 + .long 2340065183 + .long 2273321385 + .long 393890025 + .long 2894667190 + .long 1573700686 + .long 4092887025 + .long 464562897 + .long 303515614 + .long 3848216904 + .long 3328255744 + .long 1036006886 + .long 2121885428 + .long 3704818897 + .long 3211297370 + .long 1325824312 + .long 3493125121 + .long 3338748802 + .long 3232443331 + .long 3112594497 + .long 3307298736 + .long 2809691794 + .long 3731360010 + .long 3573632495 + .long 2312925567 + .long 629450595 + .long 3622381915 + .long 989010185 + .long 3398558103 + .long 4153621291 + .long 3607201927 + .long 2629100272 + .long 1953994464 + .long 1943384301 + .long 2759420002 + .long 2305022315 + .long 2391039855 + .long 612094863 + .long 3951603967 + .long 1340433416 + .long 3334026995 + .long 1491763737 + .long 4186248678 + .long 4198464715 + .long 87224683 + .long 4220145159 + .long 3881216024 + .long 2007772778 + .long 1722917095 + .long 2388984076 + .long 3799859053 + .long 732951595 + .long 3919415462 + .long 528829945 + .long 3610037081 + .long 3992395594 + .long 4037851002 + .long 1844118200 + .long 3714769074 + .long 3432638667 + .long 3108186388 + .long 746542694 + .long 3818486016 + .long 557823754 + .long 2427510280 + .long 3516120961 + .long 3892142094 + .long 1703329579 + .long 996501429 + .long 4081661750 + .long 3974028169 + .long 480847786 + .long 3006112619 + .long 1403431905 + .long 4065364793 + .long 1900483787 + .long 2649330773 + .long 651669812 + .long 4162988739 + .long 1619173352 + .long 1864819711 + .long 1131374484 + .long 4267744761 + .long 1834860043 + .long 2423625113 + .long 288099716 + .long 2190363742 + .long 2708503338 + .long 4126097102 + .long 3654529011 + .long 2251412339 + .long 3753107947 + .long 3496449780 + .long 2610603179 + .long 2317533940 + .long 3862344650 + .long 1030964414 + .long 451338797 + .long 2389337002 + .long 2524196363 + .long 569491811 + .long 2946926522 + .long 2467527406 + .long 196512138 + .long 497579000 + .long 2195809742 + .long 2552928386 + .long 1662952651 + .long 780129586 + .long 2880189481 + .long 2646511583 + .long 1545658730 + .long 789982365 + .long 191310475 + .long 2749424166 + .long 1470909419 + .long 1234100077 + .long 2044585165 + .long 2862876216 + .long 928663178 + .long 2102054363 + .long 3690288476 + .long 2988326180 + .long 2216922123 + .long 2305139484 + .long 4174545259 + .long 3130608048 + .long 1755153610 + .long 918723953 + .long 2738745609 + .long 3294047809 + .long 721728203 + .long 1773737866 + .long 4101484425 + .long 3433511350 + .long 1857351114 + .long 2879235855 + .long 1363799643 + .long 3536910801 + .long 4061718601 + .long 908917583 + .long 3005712244 + .long 4215915540 + .long 243897838 + .long 7660553 + .long 2731769662 + .long 2727825412 + .long 1695068807 + .long 2615038300 + .long 234665196 + .long 3149409338 + .long 2025012071 + .long 1264893574 + .long 1155162898 + .long 2643506208 + .long 3781832745 + .long 2126832235 + .long 1395780981 + .long 2754722035 + .long 4274723882 + .long 199777100 + .long 1853759306 + .long 3583381494 + .long 3072425958 + .long 993425135 + .long 3004341385 + .long 3435215656 + .long 3198694093 + .long 620059688 + .long 2085750463 + .long 2400804391 + .long 1026440073 + .long 2116228661 + .long 3422860059 + .long 3767238370 + .long 376557070 + .long 669608662 + .long 2826299222 + .long 4021726431 + .long 97861608 + .long 623049618 + .long 457143492 + .long 3494791496 + .long 647336461 + .long 20390326 + .long 156262610 + .long 3457815221 + .long 2242302115 + .long 1153736377 + .long 29917573 + .long 608 + .long 956831540 + .long 3804294695 + .long 1233656524 + .long 1169011973 + .long 3512247603 + .long 731707668 + .long 3804813427 + .long 3532496868 + .long 3861713254 + .long 3920998321 + .long 3249242362 + .long 2983748142 + .long 4254521127 + .long 3419828215 + .long 3612752470 + .long 3427243214 + .long 1865130836 + .long 1528519591 + .long 3104638828 + .long 2778394947 + .long 2428343797 + .long 2183879732 + .long 1050296790 + .long 3773933110 + .long 3652345540 + .long 2906583603 + .long 1426288469 + .long 3900013225 + .long 3885984869 + .long 2566242072 + .long 2597085889 + .long 3387828672 + .long 3402407620 + .long 2004411987 + .long 1378225957 + .long 3062031935 + .long 3648787989 + .long 92338370 + .long 4236899602 + .long 2817389734 + .long 1952242004 + .long 2304097414 + .long 127945474 + .long 2582972800 + .long 4281889637 + .long 2697225196 + .long 2199799063 + .long 2368525439 + .long 2882311446 + .long 2124741744 + .long 2454581530 + .long 2175676414 + .long 1363442533 + .long 235950345 + .long 3278607019 + .long 3991475143 + .long 2338347060 + .long 892652237 + .long 3886541672 + .long 3654822706 + .long 2206999749 + .long 359442761 + .long 1344250324 + .long 3448127457 + .long 2316542980 + .long 3829127353 + .long 220674587 + .long 3338303659 + .long 280815351 + .long 3269930602 + .long 4246425196 + .long 2475208849 + .long 3336161088 + .long 2206265573 + .long 1212344344 + .long 2473891454 + .long 491190659 + .long 2156317952 + .long 2981239741 + .long 2515194909 + .long 3609278228 + .long 1234146757 + .long 1026744012 + .long 2624029530 + .long 2704274272 + .long 1975162568 + .long 3276945619 + .long 2578639571 + .long 1034382165 + .long 2590969465 + .long 713762072 + .long 2201806508 + .long 4228198051 + .long 3980119693 + .long 4056525840 + .long 3097891989 + .long 2284336932 + .long 1932639591 + .long 1092540108 + .long 4171705026 + .long 1025654624 + .long 2806138305 + .long 3009647326 + .long 4248184906 + .long 1890367717 + .long 2289438980 + .long 2899757860 + .long 2719293081 + .long 2021534083 + .long 143536689 + .long 3592569555 + .long 2232683115 + .long 1092535430 + .long 1236892532 + .long 4153044331 + .long 2589276857 + .long 3416977538 + .long 1252322112 + .long 2546684106 + .long 3041465242 + .long 1082461383 + .long 209063033 + .long 689512483 + .long 3233542783 + .long 2486702483 + .long 195380297 + .long 3370408231 + .long 2473507057 + .long 2649928714 + .long 3477888857 + .long 4011137876 + .long 2392519727 + .long 735960098 + .long 892635115 + .long 2839435691 + .long 3648562506 + .long 4276128797 + .long 1399354710 + .long 1604489874 + .long 3300188966 + .long 3618086195 + .long 2363035047 + .long 3798645379 + .long 2910302351 + .long 2872403096 + .long 1995870309 + .long 1272108261 + .long 2577818883 + .long 1355290640 + .long 1576944867 + .long 29835783 + .long 528 + .long 602586217 + .long 2744039853 + .long 1836018387 + .long 1812008391 + .long 2257334696 + .long 1529386301 + .long 1071982020 + .long 1483132946 + .long 4031485769 + .long 2132222880 + .long 3196630878 + .long 2436179952 + .long 499786504 + .long 1744292863 + .long 2290711216 + .long 2504292584 + .long 1896329063 + .long 3237324739 + .long 2330780121 + .long 3744707929 + .long 1734827082 + .long 3296507779 + .long 823995655 + .long 3906271181 + .long 1416288288 + .long 2226659999 + .long 3321781362 + .long 3715853563 + .long 2544842791 + .long 504837419 + .long 2958966103 + .long 2231720942 + .long 750175301 + .long 4084077163 + .long 2549224941 + .long 3250807824 + .long 1369606438 + .long 3223323496 + .long 2083589876 + .long 3384767572 + .long 4248382916 + .long 4144081438 + .long 3229998485 + .long 3165770641 + .long 3223334087 + .long 2485373121 + .long 3818931504 + .long 3388848075 + .long 1252536709 + .long 1652370242 + .long 2624409840 + .long 2964694704 + .long 823791654 + .long 1167018965 + .long 2939238153 + .long 2953436515 + .long 884228550 + .long 292276865 + .long 734484637 + .long 2205305082 + .long 1913113287 + .long 3765099297 + .long 3745471985 + .long 4167966771 + .long 2931697765 + .long 3673300473 + .long 2182221826 + .long 2649024091 + .long 1975627272 + .long 3727134676 + .long 3712743943 + .long 2356773214 + .long 1995177638 + .long 1132588444 + .long 1959425557 + .long 2466886350 + .long 1844669961 + .long 3530525712 + .long 760398624 + .long 4132176514 + .long 1979460773 + .long 796554174 + .long 3170959411 + .long 3438043671 + .long 1989653354 + .long 84033345 + .long 407935807 + .long 2705661215 + .long 1743925380 + .long 3102969454 + .long 3987162576 + .long 3388329870 + .long 1765097355 + .long 2209606903 + .long 1187505799 + .long 2507493218 + .long 161532103 + .long 2079767141 + .long 2713931831 + .long 2181209439 + .long 3726577836 + .long 2678974047 + .long 4042300458 + .long 3044993725 + .long 569618662 + .long 2942019385 + .long 2267421895 + .long 3217189858 + .long 2072134893 + .long 690975306 + .long 3699981379 + .long 4279355559 + .long 3941553639 + .long 955448001 + .long 4102577460 + .long 2173892384 + .long 1871059570 + .long 2340022155 + .long 2864020166 + .long 2805153080 + .long 3271562790 + .long 928990650 + .long 4206766333 + .long 3357221519 + .long 685259147 + .long 3780305127 + .long 2513405378 + .long 4289834595 + .long 2048010913 + .long 1999500835 + .long 12816876 + .long 4227858976 + .long 255479044 + .long 3586592293 + .long 3058876998 + .long 264515361 + .long 3124897887 + .long 2490659405 + .long 1648870444 + .long 499533912 + .long 41235212 + .long 1135645 + .long 0 + .long 0 + .long 1870875844 + .long 237807939 + .long 0 + .long 0 + .long 1220251845 + .long 534075739 + .long 10 + .long 0 + .long 1566916386 + .long 2806728368 + .long 1584 + .long 0 + .long 359612094 + .long 1988210364 + .long 209791 + .long 0 + .long 4018390684 + .long 3143652161 + .long 23114812 + .long 0 + .long 1385310342 + .long 3191552623 + .long 2079730388 + .long 0 + .long 391712962 + .long 3496232483 + .long 3188676879 + .long 34 + .long 712670475 + .long 2384468018 + .long 3612170541 + .long 1928 + .long 2944407817 + .long 162857838 + .long 3871824152 + .long 79642 + .long 1897150183 + .long 2209645725 + .long 1648691441 + .long 2316814 + .long 4189666301 + .long 2103634775 + .long 2832836870 + .long 43914735 + .long 100148761 + .long 3544145710 + .long 882453749 + .long 480946030 + .long 743895637 + .long 1440146064 + .long 1167801510 + .long 2472892869 + .long 2527288726 + .long 3429197137 + .long 3389012105 + .long 3751366970 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3328931461 + .long 85211143 + .long 0 + .long 0 + .long 1806098240 + .long 3730920547 + .long 3 + .long 0 + .long 1452363271 + .long 241457122 + .long 632 + .long 0 + .long 2408523024 + .long 2523801313 + .long 87488 + .long 0 + .long 2245774023 + .long 1447128763 + .long 10087333 + .long 0 + .long 741575833 + .long 1516712297 + .long 950654827 + .long 0 + .long 188657751 + .long 2834063720 + .long 2756671478 + .long 16 + .long 1878890455 + .long 1600190830 + .long 298103694 + .long 968 + .long 2704961479 + .long 3096990934 + .long 62735862 + .long 41831 + .long 4224033960 + .long 872206772 + .long 3368762420 + .long 1269793 + .long 1493275548 + .long 4226875193 + .long 156115358 + .long 24976936 + .long 3675413693 + .long 3939858976 + .long 1188049005 + .long 281407884 + .long 4246420658 + .long 2584806369 + .long 1500891563 + .long 1472264476 + .long 3550606718 + .long 2355970614 + .long 848338822 + .long 2246143015 + .long 4294967292 + .long 0 + .long 4176598204 + .long 2421744458 + .long 12825068 + .long 4227858976 + .long 26255947 + .long 2214716320 + .long 3008850950 + .long 1148166722 + .long 3688411584 + .long 3263035913 + .long 28940749 + .long 823708345 + .long 2778463383 + .long 1133123 + .long 0 + .long 0 + .long 3375994644 + .long 239287696 + .long 0 + .long 0 + .long 1307882943 + .long 652616536 + .long 10 + .long 0 + .long 1617272991 + .long 332362201 + .long 1584 + .long 0 + .long 1120342694 + .long 786793736 + .long 208818 + .long 0 + .long 1754116211 + .long 4140995168 + .long 22886713 + .long 0 + .long 1065416575 + .long 2365212708 + .long 2045489262 + .long 0 + .long 4094841 + .long 1336050951 + .long 3805124179 + .long 33 + .long 2857461896 + .long 1181810454 + .long 3505581240 + .long 1861 + .long 317401726 + .long 1588400515 + .long 2236524720 + .long 75909 + .long 1498310037 + .long 3569634182 + .long 656796315 + .long 2175950 + .long 1147851401 + .long 3112077225 + .long 3624068591 + .long 40608505 + .long 3302439284 + .long 1412013598 + .long 1600554036 + .long 438608161 + .long 1138396370 + .long 2245711018 + .long 3467973442 + .long 2233633025 + .long 867533488 + .long 947112014 + .long 1198607031 + .long 3375241932 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1112979214 + .long 155431282 + .long 0 + .long 0 + .long 751906521 + .long 4198567473 + .long 6 + .long 0 + .long 1613582890 + .long 3858662071 + .long 1129 + .long 0 + .long 750469660 + .long 730914801 + .long 154615 + .long 0 + .long 3704035494 + .long 424802513 + .long 17595297 + .long 0 + .long 3547752153 + .long 653012047 + .long 1632696395 + .long 0 + .long 3895749118 + .long 1312132433 + .long 283540480 + .long 28 + .long 69337464 + .long 2039495909 + .long 480366968 + .long 1598 + .long 3999973752 + .long 512131576 + .long 3264765906 + .long 67376 + .long 1470627556 + .long 3527817596 + .long 506357093 + .long 1990112 + .long 1150644769 + .long 1706533685 + .long 1646793404 + .long 38078290 + .long 2272838918 + .long 315551185 + .long 931114118 + .long 418976801 + .long 799519248 + .long 833405850 + .long 3700723307 + .long 2157812839 + .long 1885423178 + .long 2894024424 + .long 986247108 + .long 3272778907 + .long 4294967291 + .long 0 + .long 205941362 + .long 2843814473 + .long 12816876 + .long 4227858976 + .long 4284396776 + .long 2636211962 + .long 2729248679 + .long 228940808 + .long 2721630221 + .long 4033427380 + .long 3518215373 + .long 3318265016 + .long 1583232401 + .long 1129188 + .long 0 + .long 0 + .long 2240090200 + .long 238747566 + .long 0 + .long 0 + .long 2182354368 + .long 422793662 + .long 10 + .long 0 + .long 2344384525 + .long 3611967473 + .long 1569 + .long 0 + .long 2363261376 + .long 55742926 + .long 206011 + .long 0 + .long 2169713945 + .long 2081106389 + .long 22457193 + .long 0 + .long 808249952 + .long 3928968053 + .long 1994189663 + .long 0 + .long 2498399120 + .long 610170797 + .long 3374767919 + .long 32 + .long 2499128949 + .long 806866088 + .long 2667994898 + .long 1785 + .long 1293127093 + .long 1533235693 + .long 3364558966 + .long 72094 + .long 3484449920 + .long 4142457389 + .long 393414345 + .long 2045553 + .long 1815566734 + .long 3205349654 + .long 1699048752 + .long 37804868 + .long 885836718 + .long 797019709 + .long 3601921623 + .long 405043970 + .long 1414187968 + .long 4238799387 + .long 2244838147 + .long 2051616278 + .long 2091776204 + .long 3735546130 + .long 1436809887 + .long 3093461814 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 194035164 + .long 141017056 + .long 0 + .long 0 + .long 3307569967 + .long 1206991859 + .long 6 + .long 0 + .long 3663448937 + .long 3391377880 + .long 1007 + .long 0 + .long 4126701083 + .long 2994857527 + .long 136467 + .long 0 + .long 1667733955 + .long 4058943102 + .long 15345719 + .long 0 + .long 2611265876 + .long 3831769830 + .long 1404776386 + .long 0 + .long 209321266 + .long 573187068 + .long 3359330694 + .long 23 + .long 1677262110 + .long 637572110 + .long 2122511782 + .long 1331 + .long 3496561941 + .long 3652813901 + .long 3559168047 + .long 55128 + .long 1750715127 + .long 4228815409 + .long 1050316 + .long 1598795 + .long 1840387030 + .long 2463042611 + .long 3094434052 + .long 30079053 + .long 2629602118 + .long 2049759618 + .long 945167723 + .long 326505049 + .long 3298129216 + .long 3410065465 + .long 1686243051 + .long 1666911635 + .long 3383305094 + .long 1693255217 + .long 2403972032 + .long 2519963779 + .long 4294967291 + .long 0 + .long 3238416553 + .long 3265778049 + .long 12825068 + .long 4227858976 + .long 3177200532 + .long 3057752043 + .long 1963397648 + .long 3926923754 + .long 1015831100 + .long 3054277238 + .long 214260357 + .long 3388682645 + .long 329260597 + .long 1120080 + .long 0 + .long 0 + .long 1129382972 + .long 236791308 + .long 0 + .long 0 + .long 200550114 + .long 4225205647 + .long 9 + .long 0 + .long 3987740840 + .long 662463985 + .long 1546 + .long 0 + .long 3625695977 + .long 942803776 + .long 202014 + .long 0 + .long 4082097994 + .long 2934588234 + .long 21910543 + .long 0 + .long 2081364333 + .long 826431917 + .long 1934499234 + .long 0 + .long 1761358361 + .long 1915853684 + .long 2581201468 + .long 31 + .long 1458338458 + .long 480335293 + .long 641318311 + .long 1709 + .long 2934587087 + .long 1935466844 + .long 4209158963 + .long 68508 + .long 2290297886 + .long 2520183995 + .long 2347470795 + .long 1930078 + .long 1214972608 + .long 3678131539 + .long 56536087 + .long 35444212 + .long 1624218450 + .long 2947499939 + .long 75007111 + .long 377830189 + .long 794554122 + .long 1484978356 + .long 1550658172 + .long 1907426674 + .long 1950966402 + .long 3741059307 + .long 468440577 + .long 2872207806 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2513119405 + .long 255601926 + .long 0 + .long 0 + .long 1340053149 + .long 1293535308 + .long 11 + .long 0 + .long 2520596056 + .long 243966073 + .long 1798 + .long 0 + .long 1240269441 + .long 1692289976 + .long 241208 + .long 0 + .long 486505533 + .long 4176826391 + .long 26843964 + .long 0 + .long 1085031321 + .long 2229862700 + .long 2429583838 + .long 0 + .long 3607912919 + .long 1284443184 + .long 2708483256 + .long 40 + .long 4286170020 + .long 2109173108 + .long 2872722597 + .long 2245 + .long 3765965368 + .long 2873757161 + .long 2280026745 + .long 91776 + .long 975034122 + .long 907445528 + .long 4183785771 + .long 2628820 + .long 2401876752 + .long 1790794470 + .long 4120636181 + .long 48923208 + .long 3456079977 + .long 3312351896 + .long 2533182876 + .long 526592659 + .long 300202939 + .long 3214183676 + .long 2700781633 + .long 2674019932 + .long 3409370037 + .long 142796896 + .long 590138558 + .long 4034348900 + .long 4294967290 + .long 0 + .long 2441521498 + .long 242594037 + .long 2326542 + .long 4227858728 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 292802143 + .long 2930268 + .long 0 + .long 0 + .long 535415153 + .long 618901269 + .long 0 + .long 0 + .long 1086559041 + .long 2797303288 + .long 25 + .long 0 + .long 4140762130 + .long 803311064 + .long 3903 + .long 0 + .long 3260682281 + .long 805348165 + .long 501094 + .long 0 + .long 946699523 + .long 2655018074 + .long 53417808 + .long 0 + .long 3184188054 + .long 357148693 + .long 343191017 + .long 1 + .long 2991785955 + .long 1885266767 + .long 2475080337 + .long 74 + .long 3202232014 + .long 1390745085 + .long 1906741299 + .long 3974 + .long 2460394114 + .long 145617371 + .long 1237048646 + .long 157131 + .long 2499420999 + .long 890518540 + .long 2984098479 + .long 4365826 + .long 4044160094 + .long 3502963765 + .long 4084883256 + .long 78771967 + .long 1855836510 + .long 1773383726 + .long 696038818 + .long 812348145 + .long 1371130586 + .long 4224739114 + .long 2913286396 + .long 3734813411 + .long 3022964429 + .long 4251306649 + .long 3856945722 + .long 3368235169 + .long 4294967295 + .long 0 + .long 3259021111 + .long 321006842 + .long 29835651 + .long 528 + .long 4287764257 + .long 2359162534 + .long 538435925 + .long 1893177075 + .long 2620595140 + .long 1125567552 + .long 2991073306 + .long 2159239491 + .long 623213113 + .long 2440954329 + .long 3454983919 + .long 2690441248 + .long 1981777827 + .long 3070641374 + .long 600396448 + .long 3989904562 + .long 503111015 + .long 2398913263 + .long 3729609173 + .long 2560895207 + .long 4264522276 + .long 1827510236 + .long 1453587439 + .long 2856034995 + .long 3530335573 + .long 2910390539 + .long 3830755809 + .long 3395214488 + .long 581887236 + .long 170861812 + .long 3783767784 + .long 3801720292 + .long 3874334995 + .long 3776894534 + .long 3941576344 + .long 4151651145 + .long 672178724 + .long 1876155966 + .long 2300153670 + .long 2280168405 + .long 2930820789 + .long 310363638 + .long 2337608734 + .long 2504022121 + .long 679615860 + .long 1866145491 + .long 925134179 + .long 2749395452 + .long 4164495461 + .long 1691717726 + .long 3504269286 + .long 3018609133 + .long 4091749652 + .long 2913918638 + .long 75440378 + .long 3313861766 + .long 2260863989 + .long 1783565696 + .long 3478989690 + .long 3637556251 + .long 386210930 + .long 165743778 + .long 2898550894 + .long 3992273458 + .long 138300613 + .long 2474605972 + .long 1444508693 + .long 2190379430 + .long 3716173044 + .long 211495398 + .long 2076026756 + .long 2402948622 + .long 884026613 + .long 3273453185 + .long 2774793032 + .long 2635331838 + .long 862601524 + .long 3461868441 + .long 1569319307 + .long 2889017487 + .long 2379289701 + .long 4014175908 + .long 4105967090 + .long 3165345439 + .long 4280005796 + .long 3658970897 + .long 1734788832 + .long 3465258574 + .long 1142155173 + .long 2128929843 + .long 1454912392 + .long 3791483352 + .long 1572825138 + .long 4100167805 + .long 2209491991 + .long 4149468636 + .long 1302034421 + .long 2240019943 + .long 2903825538 + .long 2241250238 + .long 1470684676 + .long 2909933371 + .long 1614391894 + .long 2346034557 + .long 3663942245 + .long 150553254 + .long 581996432 + .long 2853498413 + .long 2851485478 + .long 1062112106 + .long 2360862824 + .long 4080591848 + .long 3037166561 + .long 3942859811 + .long 2491765597 + .long 2637624859 + .long 3670749589 + .long 1175994297 + .long 2568760650 + .long 2257943156 + .long 4233645441 + .long 2769385451 + .long 3183971100 + .long 4072128784 + .long 1432427446 + .long 3380851706 + .long 2013943478 + .long 2236760609 + .long 4221662466 + .long 494326959 + .long 27640328 + .long 432 + .long 4152930537 + .long 3261335210 + .long 1647304022 + .long 2421513631 + .long 0 + .long 2182303040 + .long 2 + .long 0 + .long 2440707372 + .long 2648025301 + .long 1920343642 + .long 4033309261 + .long 228472035 + .long 951557190 + .long 1587559315 + .long 2974493459 + .long 2596925677 + .long 961292909 + .long 2340517507 + .long 4069972126 + .long 3800775586 + .long 2435894136 + .long 1723862257 + .long 2750240234 + .long 1983413582 + .long 438211295 + .long 1298530652 + .long 3389699362 + .long 2457352961 + .long 2834143237 + .long 3251433817 + .long 4162244914 + .long 2624345295 + .long 2198133979 + .long 1723202388 + .long 2299670239 + .long 3808420354 + .long 1821904843 + .long 3390094422 + .long 2531701946 + .long 1851152974 + .long 2701629785 + .long 1724191120 + .long 2482272915 + .long 648872229 + .long 865545185 + .long 2559674717 + .long 2406027884 + .long 910915727 + .long 2144582723 + .long 1642929274 + .long 4137212570 + .long 2336042754 + .long 239465408 + .long 3865561517 + .long 3439416156 + .long 2422534192 + .long 3569472253 + .long 2978472155 + .long 2559905612 + .long 2875291331 + .long 4046158321 + .long 3949085588 + .long 3503570860 + .long 2128927569 + .long 1225899162 + .long 2147335523 + .long 2230618794 + .long 2283389284 + .long 1333752198 + .long 1465231956 + .long 2336128911 + .long 2753251442 + .long 2966939997 + .long 2922138241 + .long 2536578790 + .long 2666112773 + .long 3385813147 + .long 623901210 + .long 3462131994 + .long 668414005 + .long 3701008851 + .long 3126176950 + .long 3345113301 + .long 358440900 + .long 3717742396 + .long 3947881290 + .long 3263003015 + .long 2610140914 + .long 3090322344 + .long 447998310 + .long 4170300383 + .long 397141160 + .long 2942373728 + .long 3824192808 + .long 2641349034 + .long 2658982609 + .long 4233303079 + .long 2524818000 + .long 3312990274 + .long 228893295 + .long 2515147602 + .long 3476745001 + .long 2698739548 + .long 2970265182 + .long 931672352 + .long 30032391 + .long 720 + .long 1031893951 + .long 2915037812 + .long 3514686481 + .long 3480585297 + .long 183393903 + .long 2624056858 + .long 28546027 + .long 1683875686 + .long 92539635 + .long 470440642 + .long 3104544566 + .long 2542111380 + .long 2423082850 + .long 4223302981 + .long 1880783390 + .long 3172707188 + .long 2733291596 + .long 4028584963 + .long 3133521808 + .long 2155982074 + .long 1545518760 + .long 2360167907 + .long 1514977624 + .long 3361750727 + .long 1775829359 + .long 1268098089 + .long 293245362 + .long 2922889930 + .long 4260567272 + .long 2130738070 + .long 78442230 + .long 3811451694 + .long 3185114409 + .long 1528069252 + .long 1469017227 + .long 3009687218 + .long 817620842 + .long 541098266 + .long 3429120157 + .long 3247469802 + .long 1386496969 + .long 2684347079 + .long 284179228 + .long 4184596161 + .long 3638765322 + .long 371021313 + .long 2606681771 + .long 2672602875 + .long 1153440841 + .long 681666828 + .long 2588485140 + .long 3667250000 + .long 2323000426 + .long 796579017 + .long 4170606170 + .long 2503045697 + .long 3134166249 + .long 3700272898 + .long 3134839549 + .long 3388945252 + .long 703661802 + .long 1462722757 + .long 1341451622 + .long 2296227379 + .long 443948971 + .long 1838486354 + .long 1829780795 + .long 3113397699 + .long 3423557800 + .long 3677683794 + .long 2988390605 + .long 4220311422 + .long 2364782699 + .long 377168398 + .long 988912816 + .long 2859792771 + .long 2272449576 + .long 2425114493 + .long 3394168911 + .long 3875037301 + .long 2614813611 + .long 1136311064 + .long 3219605340 + .long 2624778863 + .long 2109052744 + .long 2469309985 + .long 1975730813 + .long 3554907757 + .long 1295201579 + .long 391105893 + .long 1554957189 + .long 2406549547 + .long 576394664 + .long 1543244524 + .long 1882413337 + .long 3257006239 + .long 1017054059 + .long 1977139902 + .long 2097363325 + .long 2203699043 + .long 1908366122 + .long 67963273 + .long 641406479 + .long 2982177629 + .long 3746196521 + .long 1016392834 + .long 2077695946 + .long 4016838075 + .long 2069372298 + .long 3280381472 + .long 2122130600 + .long 2685921991 + .long 1883255817 + .long 3264982359 + .long 4098768927 + .long 3758603957 + .long 3506210954 + .long 1836307129 + .long 2822017765 + .long 2764063917 + .long 2012804049 + .long 1836928984 + .long 1054120456 + .long 2619585574 + .long 1055724672 + .long 2194227394 + .long 2447214543 + .long 2687690031 + .long 1327427687 + .long 1655178620 + .long 3028234167 + .long 3556180690 + .long 2927424394 + .long 229520228 + .long 65594667 + .long 3227047264 + .long 1689555076 + .long 4247943379 + .long 172770419 + .long 3675678736 + .long 657796043 + .long 288113065 + .long 2256116365 + .long 2460956283 + .long 2381283399 + .long 3352776929 + .long 3687288864 + .long 3224422563 + .long 672976042 + .long 857803139 + .long 2956970725 + .long 3269238901 + .long 2326138918 + .long 3946484787 + .long 3349422960 + .long 2579382025 + .long 3310332749 + .long 822582390 + .long 2446752418 + .long 2381540812 + .long 4287345289 + .long 449373617 + .long 1629474989 + .long 2287047921 + .long 3156879118 + .long 2932312680 + .long 4059116599 + .long 3501115759 + .long 2653478600 + .long 1047527497 + .long 2387670671 + .long 2153577515 + .long 4278907533 + .long 1522300626 + .long 2248985742 + .long 2923309751 + .long 2050095503 + .long 1358740372 + .long 29884806 + .long 576 + .long 189636935 + .long 2307472755 + .long 73850715 + .long 2629855449 + .long 3883672823 + .long 618265067 + .long 3875053116 + .long 3917969758 + .long 1449807750 + .long 2492768441 + .long 781111022 + .long 3190435238 + .long 1482976409 + .long 3746699123 + .long 673296220 + .long 2543135664 + .long 1097012132 + .long 2731166546 + .long 2691838079 + .long 3591085575 + .long 4108503415 + .long 2072634685 + .long 3936623385 + .long 2185856579 + .long 1923690262 + .long 3646023575 + .long 4216469600 + .long 2465929342 + .long 431460727 + .long 596938224 + .long 2153081083 + .long 2604407262 + .long 2280668022 + .long 3134357508 + .long 2589033740 + .long 2773504679 + .long 2807242375 + .long 2817121462 + .long 2773778968 + .long 2997091783 + .long 1733040470 + .long 818736373 + .long 2513276750 + .long 3273702286 + .long 3677662487 + .long 322072717 + .long 1865747051 + .long 3233516951 + .long 2915555540 + .long 937584400 + .long 659945040 + .long 2820584615 + .long 2133192181 + .long 2691571362 + .long 4196086611 + .long 2727659532 + .long 896759672 + .long 1769906504 + .long 3035342266 + .long 2750209132 + .long 1576632880 + .long 1478621509 + .long 1238707153 + .long 3507491969 + .long 126298229 + .long 3524093915 + .long 2681332129 + .long 2656870434 + .long 2282193125 + .long 2123250942 + .long 2537777848 + .long 2313555892 + .long 2236573588 + .long 3014805274 + .long 1599407648 + .long 4251279069 + .long 1359728578 + .long 2438133930 + .long 1558056398 + .long 2562927734 + .long 3023480919 + .long 1448378982 + .long 1701562892 + .long 2340149056 + .long 1506041285 + .long 779806113 + .long 4234929211 + .long 2470659521 + .long 3801687606 + .long 3749889093 + .long 4112153792 + .long 4129315601 + .long 3087235106 + .long 3558690450 + .long 4001893244 + .long 3474539130 + .long 508945001 + .long 2957303106 + .long 3788800591 + .long 2700334225 + .long 1697795651 + .long 4047812965 + .long 4036703836 + .long 3519182687 + .long 4240516712 + .long 1475971627 + .long 1575184661 + .long 2515949915 + .long 1673437412 + .long 2377231640 + .long 3395057130 + .long 2344040799 + .long 1065264411 + .long 1317525997 + .long 664446688 + .long 3082671496 + .long 1521403251 + .long 50174553 + .long 2566979079 + .long 3666263822 + .long 3888565980 + .long 425393181 + .long 383974 + .long 2211658859 + .long 3190477332 + .long 1452652764 + .long 881590408 + .long 2658571543 + .long 2768922591 + .long 607349007 + .long 1340513656 + .long 2982866930 + .long 2042743989 + .long 2907958666 + .long 2030930082 + .long 2170145182 + .long 1493033626 + .long 3329402172 + .long 1968890141 + .long 2331822590 + .long 2408886146 + .long 1783184274 + .long 12825068 + .long 4227858976 + .long 2710581281 + .long 3153889734 + .long 3238022506 + .long 4176533952 + .long 1531340198 + .long 4025201404 + .long 2485789300 + .long 650490227 + .long 2321085797 + .long 625172 + .long 0 + .long 0 + .long 1069281709 + .long 251624587 + .long 0 + .long 0 + .long 4197074614 + .long 91585281 + .long 10 + .long 0 + .long 2135656897 + .long 267376913 + .long 1588 + .long 0 + .long 3403656332 + .long 967418652 + .long 209472 + .long 0 + .long 463318414 + .long 1993660658 + .long 23089564 + .long 0 + .long 1930917064 + .long 2053446879 + .long 2077215423 + .long 0 + .long 657157488 + .long 2477268698 + .long 3166180846 + .long 34 + .long 1532275274 + .long 3903843069 + .long 3017665745 + .long 1932 + .long 3296114418 + .long 3153699036 + .long 1621212020 + .long 80134 + .long 1258014930 + .long 2176092298 + .long 1175504463 + .long 2347208 + .long 1382073311 + .long 570037013 + .long 1129603108 + .long 44970025 + .long 2202866424 + .long 1579426883 + .long 3017508354 + .long 499448209 + .long 4088025423 + .long 891205158 + .long 1193661411 + .long 2604580528 + .long 2532457727 + .long 3946349630 + .long 1951385266 + .long 3993662730 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2589520468 + .long 104644116 + .long 0 + .long 0 + .long 3884787564 + .long 2761065855 + .long 3 + .long 0 + .long 3187602994 + .long 4135562377 + .long 626 + .long 0 + .long 1724989792 + .long 1713856870 + .long 86304 + .long 0 + .long 2484708115 + .long 4089533751 + .long 10036248 + .long 0 + .long 275209371 + .long 2697520380 + .long 952228456 + .long 0 + .long 3236472558 + .long 1226316501 + .long 3598685087 + .long 16 + .long 3284813591 + .long 1063192554 + .long 3944393543 + .long 991 + .long 1278466978 + .long 2628971736 + .long 1168074903 + .long 43599 + .long 848711725 + .long 2087159795 + .long 759297680 + .long 1353656 + .long 1425592604 + .long 1129358307 + .long 2754552431 + .long 27432831 + .long 3204498819 + .long 300826889 + .long 3605445756 + .long 320203780 + .long 1698536723 + .long 3065896691 + .long 309908814 + .long 1734061231 + .long 3912468499 + .long 396401915 + .long 3674073704 + .long 2719285114 + .long 4294967292 + .long 0 + .long 3981914375 + .long 2206547233 + .long 12816876 + .long 4227858976 + .long 4096021827 + .long 3999001670 + .long 1063371522 + .long 3989528078 + .long 874562813 + .long 2447814409 + .long 1858302676 + .long 4162682718 + .long 1605953959 + .long 1135435 + .long 0 + .long 0 + .long 2549031326 + .long 239160205 + .long 0 + .long 0 + .long 454697744 + .long 620180210 + .long 10 + .long 0 + .long 2436299213 + .long 3355768607 + .long 1582 + .long 0 + .long 351390256 + .long 799610387 + .long 208707 + .long 0 + .long 25800287 + .long 698915934 + .long 22891066 + .long 0 + .long 4130988338 + .long 676217935 + .long 2048657779 + .long 0 + .long 2657270905 + .long 3829767903 + .long 59128891 + .long 34 + .long 1037582638 + .long 2935003680 + .long 713523288 + .long 1875 + .long 901580945 + .long 1268517119 + .long 2358220346 + .long 76826 + .long 1912766477 + .long 222206216 + .long 632792841 + .long 2216812 + .long 4065471431 + .long 1410808044 + .long 2022595908 + .long 41710361 + .long 438075994 + .long 598703158 + .long 1085011105 + .long 454516776 + .long 604410846 + .long 4058435110 + .long 2236814241 + .long 2333657313 + .long 2448294355 + .long 2704068860 + .long 1114425723 + .long 3548452336 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3769919769 + .long 153956907 + .long 0 + .long 0 + .long 646070119 + .long 4028818701 + .long 6 + .long 0 + .long 2588679469 + .long 1052177761 + .long 1128 + .long 0 + .long 2209274989 + .long 523514771 + .long 155204 + .long 0 + .long 2126396778 + .long 3565792859 + .long 17775584 + .long 0 + .long 2013180833 + .long 1908602229 + .long 1662519428 + .long 0 + .long 3793993839 + .long 1441646378 + .long 3693455390 + .long 28 + .long 3379423244 + .long 3965194379 + .long 1988414356 + .long 1663 + .long 1712981619 + .long 805217952 + .long 1789525478 + .long 71195 + .long 1327601011 + .long 2853644807 + .long 2041759317 + .long 2141557 + .long 944030315 + .long 2463564559 + .long 1071870408 + .long 41839542 + .long 3377497270 + .long 1387686562 + .long 1015294515 + .long 470457582 + .long 3802633795 + .long 4019363939 + .long 1055805497 + .long 2472026772 + .long 1903142729 + .long 1756051618 + .long 411357926 + .long 3811072860 + .long 4294967291 + .long 0 + .long 2342180209 + .long 2629357739 + .long 12825068 + .long 4227858976 + .long 4176598204 + .long 2421744458 + .long 608412369 + .long 593975024 + .long 2402997778 + .long 853372562 + .long 4106233885 + .long 999432807 + .long 1956711771 + .long 1129902 + .long 0 + .long 0 + .long 3668311682 + .long 238634701 + .long 0 + .long 0 + .long 1969498866 + .long 413457374 + .long 10 + .long 0 + .long 2816017558 + .long 1616523229 + .long 1570 + .long 0 + .long 3757647515 + .long 3035182130 + .long 206269 + .long 0 + .long 2187487164 + .long 1784472528 + .long 22516356 + .long 0 + .long 559031239 + .long 1740008181 + .long 2003371129 + .long 0 + .long 661394403 + .long 1757559962 + .long 108872688 + .long 33 + .long 2108184885 + .long 2675738113 + .long 243072689 + .long 1805 + .long 1896660970 + .long 944386947 + .long 1395829566 + .long 73206 + .long 2645692570 + .long 1073605584 + .long 391090218 + .long 2088195 + .long 3576186609 + .long 249080280 + .long 1318613440 + .long 38820429 + .long 1698387538 + .long 1714182690 + .long 2486672428 + .long 418377280 + .long 786186663 + .long 550325920 + .long 34733209 + .long 2130294753 + .long 123703415 + .long 1830333669 + .long 555170427 + .long 3225161241 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 372615672 + .long 141112893 + .long 0 + .long 0 + .long 3315900643 + .long 1327290262 + .long 6 + .long 0 + .long 3811139837 + .long 3724885846 + .long 1016 + .long 0 + .long 989130504 + .long 3252199933 + .long 138436 + .long 0 + .long 1221640456 + .long 1442402103 + .long 15666709 + .long 0 + .long 4152936768 + .long 1813348380 + .long 1445091735 + .long 0 + .long 4193896088 + .long 3387134533 + .long 2948009907 + .long 24 + .long 2262704738 + .long 1989650954 + .long 3803792063 + .long 1396 + .long 2783464578 + .long 434957745 + .long 1316597970 + .long 58551 + .long 1368551733 + .long 528983851 + .long 2424303193 + .long 1721511 + .long 2488297655 + .long 3464245304 + .long 3652031881 + .long 32861225 + .long 3506409524 + .long 3965838759 + .long 4041530878 + .long 361842100 + .long 1191665382 + .long 3299555859 + .long 1239122770 + .long 1871471448 + .long 3889602930 + .long 4175372373 + .long 3489971328 + .long 2859914059 + .long 4294967291 + .long 0 + .long 4097644266 + .long 3051847358 + .long 12816876 + .long 4227858976 + .long 205941362 + .long 2843814473 + .long 1373054629 + .long 908624394 + .long 572230967 + .long 3772158671 + .long 2295107357 + .long 875890232 + .long 1676909203 + .long 1121011 + .long 0 + .long 0 + .long 3140758008 + .long 236890113 + .long 0 + .long 0 + .long 78883718 + .long 4270561461 + .long 9 + .long 0 + .long 653004353 + .long 1003106748 + .long 1549 + .long 0 + .long 1997655276 + .long 2810156938 + .long 202673 + .long 0 + .long 816790074 + .long 126500350 + .long 22018895 + .long 0 + .long 483718758 + .long 1693602023 + .long 1948244742 + .long 0 + .long 1719888843 + .long 3024114415 + .long 3912173698 + .long 31 + .long 857585795 + .long 2024050081 + .long 2152155389 + .long 1731 + .long 2161391665 + .long 4153338473 + .long 3453597175 + .long 69665 + .long 690916841 + .long 3408680089 + .long 1481878010 + .long 1970802 + .long 4244781337 + .long 1956485181 + .long 3004849658 + .long 36347304 + .long 3508046261 + .long 2375922782 + .long 3796433011 + .long 389053187 + .long 1871421647 + .long 319248902 + .long 2844007792 + .long 1971197416 + .long 814256252 + .long 534724998 + .long 4096580698 + .long 2976687819 + .long 4294967295 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1862921762 + .long 128829141 + .long 0 + .long 0 + .long 2226943868 + .long 3083060057 + .long 5 + .long 0 + .long 3790004556 + .long 3473372331 + .long 913 + .long 0 + .long 1912405170 + .long 4207391429 + .long 123223 + .long 0 + .long 2818206388 + .long 546560525 + .long 13795947 + .long 0 + .long 926024359 + .long 466562391 + .long 1257280106 + .long 0 + .long 3443963035 + .long 4102181261 + .long 824629355 + .long 21 + .long 1095781235 + .long 2590304783 + .long 3003378070 + .long 1181 + .long 3706684271 + .long 2607807817 + .long 1026954074 + .long 48765 + .long 2542600140 + .long 2410120938 + .long 1491060906 + .long 1411271 + .long 1675138874 + .long 3651173547 + .long 1198416212 + .long 26539599 + .long 842200953 + .long 401492709 + .long 2211503215 + .long 288538794 + .long 1943642431 + .long 940486719 + .long 4288006473 + .long 1478519853 + .long 2666730960 + .long 3798148012 + .long 941219805 + .long 2247821888 + .long 4294967291 + .long 0 + .long 3590128009 + .long 612654688 + .long 716769122 + .long 2 + .long 1828204245 + .long 1775926740 + .long 862431319 + .long 1672 + .long 437955120 + .long 677313132 + .long 3681074436 + .long 185717 + .long 2884200252 + .long 2090641138 + .long 3992138721 + .long 6428191 + .long 3221531446 + .long 2371910721 + .long 4237081542 + .long 91796659 + .long 3709028830 + .long 1986863955 + .long 2283696654 + .long 618613015 + .long 1322699753 + .long 485003501 + .long 4170891366 + .long 2092077992 + .long 1956040154 + .long 1117518145 + .long 962574367 + .long 3571830532 + .long 3307700780 + .long 4011234461 + .long 1774218710 + .long 2881343143 + .long 391584861 + .long 529954976 + .long 2825691418 + .long 856722023 + .long 0 + .long 0 + .long 3298396499 + .long 2495110602 + .long 2303999958 + .long 1 + .long 2542348583 + .long 3627482097 + .long 3224340298 + .long 1074 + .long 967783320 + .long 1406672934 + .long 4087851085 + .long 117404 + .long 4177416572 + .long 3106181469 + .long 261241013 + .long 4043478 + .long 202539330 + .long 3294545774 + .long 2496277142 + .long 57629426 + .long 720582238 + .long 1814713548 + .long 3091376339 + .long 388014697 + .long 146526450 + .long 4271301162 + .long 2338306966 + .long 1311627297 + .long 2070656804 + .long 1921999658 + .long 2258254113 + .long 2238807899 + .long 242296837 + .long 3253310178 + .long 207686852 + .long 1805761504 + .long 0 + .long 0 + .long 0 + .long 536870912 + .long 3 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3266800725 + .long 2413762801 + .long 3330613244 + .long 98 + .long 1201359419 + .long 2714872150 + .long 3208385380 + .long 20210 + .long 1956238602 + .long 4223228119 + .long 2784422263 + .long 1028397 + .long 3439473030 + .long 2410851869 + .long 3292470576 + .long 20253447 + .long 1686397776 + .long 592553810 + .long 969547707 + .long 185741930 + .long 3468583933 + .long 1250725515 + .long 2117116206 + .long 869064170 + .long 3909100790 + .long 1843251452 + .long 3871208694 + .long 2155104570 + .long 4148130288 + .long 2464912491 + .long 1300300682 + .long 2809133898 + .long 4014582188 + .long 344247779 + .long 2796123058 + .long 1784697576 + .long 195792426 + .long 264977488 + .long 3560329357 + .long 428361011 + .long 4294967290 + .long 0 + .long 258978617 + .long 1401350217 + .long 414758348 + .long 0 + .long 3858563520 + .long 693344438 + .long 929988021 + .long 164 + .long 3412169140 + .long 2002911005 + .long 1900957617 + .long 27838 + .long 201299732 + .long 2653786175 + .long 836100553 + .long 1342443 + .long 112595646 + .long 24843945 + .long 2773043450 + .long 25894040 + .long 839565763 + .long 2401088019 + .long 1862800896 + .long 235227666 + .long 241900887 + .long 2111181527 + .long 559246656 + .long 1095314964 + .long 1679323588 + .long 170716610 + .long 3844392689 + .long 2709031418 + .long 2888224069 + .long 91827283 + .long 2484028115 + .long 3525834755 + .long 3046356865 + .long 465368430 + .long 2789327597 + .long 2238015503 + .long 0 + .long 0 + .long 0 + .long 536870912 + .long 3 + .long 0 + .long 1629800756 + .long 211083125 + .long 74954925 + .long 0 + .long 1545370875 + .long 1864504884 + .long 4276848488 + .long 99 + .long 535444102 + .long 452832597 + .long 341934841 + .long 25395 + .long 995111971 + .long 3604718273 + .long 313159131 + .long 1483348 + .long 467529526 + .long 927033629 + .long 3631579950 + .long 30995691 + .long 2550211567 + .long 3003753623 + .long 1495846756 + .long 281435025 + .long 1095077789 + .long 2892497672 + .long 2221613791 + .long 1215372727 + .long 1191801615 + .long 1667552124 + .long 2428434537 + .long 2551716115 + .long 1201465291 + .long 1874197394 + .long 578557072 + .long 2461680298 + .long 391584923 + .long 529954976 + .long 2825691418 + .long 856722023 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 677405811 + .long 113109491 + .long 129649144 + .long 114 + .long 3825428504 + .long 3691782001 + .long 3484121609 + .long 31057 + .long 2790365057 + .long 1503600960 + .long 2128362517 + .long 1842108 + .long 1815120706 + .long 3864377339 + .long 1520525307 + .long 38689413 + .long 2352056310 + .long 3376817110 + .long 3997253088 + .long 352036787 + .long 1198120374 + .long 2050750776 + .long 3970142361 + .long 1521787235 + .long 3363842978 + .long 1133863107 + .long 832963017 + .long 3196692150 + .long 3821983599 + .long 1263968260 + .long 873004851 + .long 3084767199 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 2 + .long 0 + .long 2651322308 + .long 3386393833 + .long 2831116449 + .long 5 + .long 4289850283 + .long 2368640529 + .long 3021143330 + .long 3284 + .long 1866387201 + .long 153493322 + .long 2018528397 + .long 295326 + .long 712913332 + .long 628654228 + .long 3881360594 + .long 8668773 + .long 2507640802 + .long 239249479 + .long 2566710297 + .long 108181087 + .long 2758175823 + .long 567857163 + .long 2134567225 + .long 650389544 + .long 3640757112 + .long 2804269303 + .long 645858985 + .long 1991928169 + .long 804414238 + .long 2280600022 + .long 3914463340 + .long 3114948090 + .long 1937917503 + .long 2252804771 + .long 1940556944 + .long 2322010631 + .long 293688586 + .long 2544949880 + .long 3193010387 + .long 642541517 + .long 4294967291 + .long 0 + .long 453133727 + .long 877370797 + .long 1558279443 + .long 6 + .long 2547899573 + .long 3360184680 + .long 1178296802 + .long 2954 + .long 1755214995 + .long 2061159704 + .long 3531983056 + .long 253712 + .long 543505238 + .long 128612626 + .long 629116815 + .long 7334610 + .long 100838038 + .long 3022980312 + .long 2298747174 + .long 90954203 + .long 3014766307 + .long 96539771 + .long 3590315363 + .long 545180116 + .long 2964798914 + .long 2705356255 + .long 3013291713 + .long 1667101568 + .long 3407956254 + .long 2146783552 + .long 2206958848 + .long 2604739160 + .long 1922050233 + .long 3165283613 + .long 2563978608 + .long 1940712607 + .long 0 + .long 0 + .long 0 + .long 536870912 + .long 3 + .long 0 + .long 2797952740 + .long 3054806814 + .long 120 + .long 0 + .long 18168 + .long 0 + .long 1890690921 + .long 3263011055 + .long 3960 + .long 0 + .long 18872 + .long 0 + .long 3238416553 + .long 3265778049 + .long 8064 + .long 0 + .long 18168 + .long 0 + .long 4097644266 + .long 3051847358 + .long 13440 + .long 0 + .long 18872 + .long 0 + .long 0 + .long 0 + .long 1313084713 + .long 2734261102 + .long 4113882560 + .long 4230436817 + .long 0 + .long 4294967295 + .long 4105493977 + .long 3790490747 + .long 2885543867 + .long 1813033052 + .long 0 + .long 0 + .type __bessel_x_table,@object + .size __bessel_x_table,19696 + .align 8 +.L_2il0floatpacket.96: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.96,@object + .size .L_2il0floatpacket.96,8 + .align 8 +.L_2il0floatpacket.97: + .long 0x5a31a4be,0x3ff71547 + .type .L_2il0floatpacket.97,@object + .size .L_2il0floatpacket.97,8 + .align 8 +.L_2il0floatpacket.98: + .long 0x9a49f2dc,0x400d3643 + .type .L_2il0floatpacket.98,@object + .size .L_2il0floatpacket.98,8 + .align 8 +.L_2il0floatpacket.99: + .long 0x00000000,0x40d00000 + .type .L_2il0floatpacket.99,@object + .size .L_2il0floatpacket.99,8 + .align 8 +.L_2il0floatpacket.100: + .long 0x00000000,0xc0d01b80 + .type .L_2il0floatpacket.100,@object + .size .L_2il0floatpacket.100,8 + .align 8 +.L_2il0floatpacket.104: + .long 0x20000000,0x405cdc55 + .type .L_2il0floatpacket.104,@object + .size .L_2il0floatpacket.104,8 + .align 8 +.L_2il0floatpacket.105: + .long 0x00000000,0x40140000 + .type .L_2il0floatpacket.105,@object + .size .L_2il0floatpacket.105,8 + .align 8 +.L_2il0floatpacket.106: + .long 0xe0000000,0x3fefffff + .type .L_2il0floatpacket.106,@object + .size .L_2il0floatpacket.106,8 + .align 8 +.L_2il0floatpacket.109: + .long 0x00000000,0x43e00000 + .type .L_2il0floatpacket.109,@object + .size .L_2il0floatpacket.109,8 + .align 8 +__bessel_error_codes: + .long 0x00000000,0x00000000 + .long 0x00000081,0x00000000 + .long 0x00000082,0x00000000 + .long 0x00000083,0x00000000 + .long 0x00000084,0x00000000 + .long 0x0000008c,0x00000000 + .long 0x00000090,0x00000000 + .long 0x0000008f,0x00000000 + .type __bessel_error_codes,@object + .size __bessel_error_codes,64 + .align 4 +.L_2il0floatpacket.101: + .long 0x410f95e2 + .type .L_2il0floatpacket.101,@object + .size .L_2il0floatpacket.101,4 + .align 4 +.L_2il0floatpacket.102: + .long 0x41a3dd91 + .type .L_2il0floatpacket.102,@object + .size .L_2il0floatpacket.102,4 + .align 4 +.L_2il0floatpacket.103: + .long 0x3fb8aa3b + .type .L_2il0floatpacket.103,@object + .size .L_2il0floatpacket.103,4 + .align 4 +.L_2il0floatpacket.107: + .long 0x5f000000 + .type .L_2il0floatpacket.107,@object + .size .L_2il0floatpacket.107,4 + .align 4 +.L_2il0floatpacket.108: + .long 0x3f800000 + .type .L_2il0floatpacket.108,@object + .size .L_2il0floatpacket.108,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/dpml_ux_log.S b/external/sgx_libm/intel64/dpml_ux_log.S new file mode 100644 index 0000000000..52001a5598 --- /dev/null +++ b/external/sgx_libm/intel64/dpml_ux_log.S @@ -0,0 +1,356 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_log.c" + .text +..TXTST0: +# -- Begin __dpml_ux_log_poly__ + .text + .align 16,0x90 + .globl __dpml_ux_log_poly__ +__dpml_ux_log_poly__: +# parameter 1: %rdi +# parameter 2: %rsi +..B1.1: + .cfi_startproc +..___tag_value___dpml_ux_log_poly__.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + movq %rsi, %r13 + lea 128+__log_x_table(%rip), %rsi + movl $17, %edx + movl $6, %ecx + movq %r13, %r8 +..___tag_value___dpml_ux_log_poly__.5: + call __dpml_evaluate_rational__@PLT +..___tag_value___dpml_ux_log_poly__.6: +..B1.2: + movq %r13, %rdi + lea 472+__log_x_table(%rip), %rsi + movq %r13, %rdx + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + jmp __dpml_multiply__@PLT + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_log_poly__,@function + .size __dpml_ux_log_poly__,.-__dpml_ux_log_poly__ + .data +# -- End __dpml_ux_log_poly__ + .text +# -- Begin __dpml_ux_log__ + .text + .align 16,0x90 + .globl __dpml_ux_log__ +__dpml_ux_log__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B2.1: + .cfi_startproc +..___tag_value___dpml_ux_log__.10: +..L11: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + subq $56, %rsp + .cfi_def_cfa_offset 96 + movq %rdi, %r13 + lea 112+__log_x_table(%rip), %r8 + movq %rdx, %r15 + movq %rsi, %r14 + lea 424+__log_x_table(%rip), %rsi + movl $6, %edx + lea (%rsp), %rcx + movl 4(%r13), %r10d + movq (%r8), %r9 + cmpq 8(%r13), %r9 + movq %fs:40, %rax + lea -1(%r10), %ebx + adcl $0, %ebx + xorq %rsp, %rax + movq %rax, 48(%rcx) + subl %ebx, %r10d + movl %r10d, 4(%r13) +..___tag_value___dpml_ux_log__.21: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_log__.22: +..B2.2: + movl $2, %edx + lea 24(%rsp), %rdi + movq %r15, %rcx + lea (%rsp), %rsi + addl %ebx, 4(%r13) +..___tag_value___dpml_ux_log__.23: + call __dpml_divide__@PLT +..___tag_value___dpml_ux_log__.24: +..B2.3: + movq %r15, %rdi + lea 128+__log_x_table(%rip), %rsi + movl $17, %edx + movl $6, %ecx + lea (%rsp), %r8 +..___tag_value___dpml_ux_log__.25: + call __dpml_evaluate_rational__@PLT +..___tag_value___dpml_ux_log__.26: +..B2.4: + movq %r15, %rdi + movl $1, %esi + movslq %ebx, %rbx + movq %rbx, 8(%r15) +..___tag_value___dpml_ux_log__.27: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_log__.28: +..B2.5: + movq %r15, %rdi + lea (%rsp), %rsi + movl $8, %edx + movq %r15, %rcx +..___tag_value___dpml_ux_log__.29: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_log__.30: +..B2.6: + testq %r14, %r14 + je ..B2.8 +..B2.7: + movq %r15, %rdi + movq %r14, %rsi + movq %r15, %rdx +..___tag_value___dpml_ux_log__.31: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_log__.32: +..B2.8: + xorl %edx, %edx + movl $1, %eax + xorl %ecx, %ecx + cmpl $-262144, 28(%rsp) + movq 48(%rsp), %rbx + cmovne %eax, %ecx + testq %r14, %r14 + cmovne %eax, %edx + xorq %rsp, %rbx + orl %edx, %ecx + cmpq %fs:40, %rbx + jne ..B2.10 +..B2.9: + movq %rcx, %rax + addq $56, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B2.10: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_log__,@function + .size __dpml_ux_log__,.-__dpml_ux_log__ + .data +# -- End __dpml_ux_log__ + .section .rodata, "a" + .align 16 + .align 16 +__log_x_table: + .long 1088750600 + .long 519758862 + .long 58 + .long 0 + .long 59 + .long 0 + .long 60 + .long 0 + .long 1088750600 + .long 519758862 + .long 61 + .long 0 + .long 62 + .long 0 + .long 63 + .long 0 + .long 1088750600 + .long 519758862 + .long 64 + .long 0 + .long 65 + .long 0 + .long 66 + .long 0 + .long 15008776 + .long 336609536 + .long 58 + .long 0 + .long 4192101508 + .long 3037000499 + .long 4243534402 + .long 1518500249 + .long 1261892956 + .long 1305769775 + .long 706307789 + .long 114052365 + .long 2125978754 + .long 1401519948 + .long 2628436525 + .long 90640697 + .long 1075745124 + .long 4046945230 + .long 850547722 + .long 100185346 + .long 3858047057 + .long 2069326047 + .long 3415016796 + .long 106820841 + .long 196219186 + .long 3461778520 + .long 1283971156 + .long 114747264 + .long 133398994 + .long 3894487089 + .long 1548005786 + .long 123926548 + .long 4002430868 + .long 3905024888 + .long 1104860464 + .long 134702783 + .long 1396868873 + .long 2152947579 + .long 2102985887 + .long 147531619 + .long 361329122 + .long 2531697111 + .long 2794113080 + .long 163061263 + .long 2117398987 + .long 2352680084 + .long 3122626672 + .long 182244941 + .long 299366278 + .long 2801833386 + .long 1248329477 + .long 206544267 + .long 99864504 + .long 1693623838 + .long 1770762254 + .long 238320308 + .long 959885721 + .long 1462617677 + .long 2483170600 + .long 281651273 + .long 2353710846 + .long 1786830293 + .long 2080549112 + .long 344240445 + .long 2781107612 + .long 1683788319 + .long 2061424959 + .long 442594858 + .long 2924123738 + .long 1498310185 + .long 3744988402 + .long 619632801 + .long 2019498699 + .long 1065527877 + .long 1946680041 + .long 1032721336 + .long 1763524233 + .long 3196583632 + .long 1545072827 + .long 3098164009 + .long 2 + .long 0 + .long 0 + .long 1 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3520035243 + .long 2977044471 + .long 66254511 + .long 3387143064 + .long 0 + .long 4294967295 + .long 4224710552 + .long 2585827972 + .long 192713080 + .long 2408143276 + .long 0 + .long 0 + .type __log_x_table,@object + .size __log_x_table,528 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/dpml_ux_ops.S b/external/sgx_libm/intel64/dpml_ux_ops.S new file mode 100644 index 0000000000..378c5da3fc --- /dev/null +++ b/external/sgx_libm/intel64/dpml_ux_ops.S @@ -0,0 +1,1405 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_ops.c" + .text +..TXTST0: +# -- Begin __dpml_unpack2__ + .text + .align 16,0x90 + .globl __dpml_unpack2__ +__dpml_unpack2__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +# parameter 7: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value___dpml_unpack2__.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + pushq %rsi + .cfi_def_cfa_offset 64 + movq %r9, %r12 + movq %r8, %r13 + movq %rcx, %rbp + movq %rsi, %r14 + xorl %esi, %esi + movq %r13, %rcx + movq %r12, %r8 + movq 64(%rsp), %r9 + movq %rdi, %r15 +..___tag_value___dpml_unpack2__.16: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___dpml_unpack2__.17: +..B1.10: + movq %rax, %rbx +..B1.2: + testq %rbx, %rbx + jl ..B1.4 +..B1.3: + testq %r14, %r14 + jne ..B1.5 +..B1.4: + movq %rbx, %rax + popq %rcx + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.5: + movq 8(%r13), %r10 + lea (,%rbx,4), %rcx + movq %r15, %rdi + movq %r14, %rsi + sarq %cl, %r10 + movq %rbp, %rdx + andq $15, %r10 + movq %r12, %r8 + movq 64(%rsp), %r9 + lea (%r13,%r10,8), %rcx +..___tag_value___dpml_unpack2__.38: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___dpml_unpack2__.39: +..B1.6: + shlq $4, %rbx + orq %rax, %rbx + movq %rbx, %rax + popq %rcx + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __dpml_unpack2__,@function + .size __dpml_unpack2__,.-__dpml_unpack2__ + .data +# -- End __dpml_unpack2__ + .text +# -- Begin __dpml_unpack_x_or_y__ + .text + .align 16,0x90 + .globl __dpml_unpack_x_or_y__ +__dpml_unpack_x_or_y__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +..B2.1: + .cfi_startproc +..___tag_value___dpml_unpack_x_or_y__.54: +..L55: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $104, %rsp + .cfi_def_cfa_offset 160 + movq %rsi, %r12 + movl $1, %r10d + xorl %r13d, %r13d + testq %r12, %r12 + movq %r8, %rbp + cmovne %r10d, %r13d + movq %rdi, %r8 + movq %rcx, %rbx + testq %r13, %r13 + movq $0x8000000000000000, %r11 + movq %fs:40, %rax + jne ..L69 + movq %r8, %rsi +..L69: + xorq %rsp, %rax + movq %rax, 96(%rsp) + movq 8(%rsi), %rax + movq %rax, %r10 + andq %rax, %r11 + shlq $15, %r10 + btsq $63, %r10 + movq (%rsi), %r14 + movq %r14, %rcx + movq %rsi, 24(%r9,%r13,8) + movq %r14, %r15 + shrq $49, %rcx + shrq $32, %r11 + lea (%r10,%r10), %rsi + orq %r14, %rsi + movq $0x1000000000000, %r14 + orq %rcx, %r10 + movq $0xffff000000000000, %rcx + movl %r11d, (%rdx) + movq %rax, %r11 + shrq $48, %r11 + andq $32767, %r11 + lea (%r14,%rax), %rdi + movq %rax, %r14 + addq %rax, %rcx + addq $-16382, %r11 + shlq $15, %r15 + shrq $63, %r14 + movq %r15, 16(%rdx) + movl $4, %r15d + xorq %rcx, %rdi + jl ..B2.33 +..B2.2: + movq %r10, 8(%rdx) + movl %r11d, 4(%rdx) +..B2.3: + addq %r14, %r15 + movl $1, %r10d + movl %r15d, %ecx + shll %cl, %r10d + movq (%r9), %rdx + shlq $10, %rdx + movslq %r10d, %r10 + orq %r10, %rdx + movq %rdx, (%r9) + testq %r15, %r15 + jne ..B2.5 +..B2.4: + movl $2139095040, 28(%rsp) + movss 28(%rsp), %xmm1 + movss 28(%rsp), %xmm0 + subss %xmm0, %xmm1 + movss %xmm1, 28(%rsp) +..B2.5: + movq (%rbx), %r11 + lea (%r15,%r15,2), %rcx + addq %rcx, %rcx + movq %r11, %rdi + sarq $60, %r11 + sarq %cl, %rdi + movq %rdi, %rdx + sarq $3, %rdi + andq $7, %rdx + andq $7, %rdi + je ..B2.26 +..B2.6: + movl %r10d, %esi + andl $240, %esi + cmpq %r13, %rdx + jg ..B2.8 +..B2.7: + testq %rdx, %rdx + movl %esi, %ebx + cmove %r8, %r12 + jmp ..B2.9 +..B2.8: + andq $15, %r11 + addq %rdx, %r11 + movq -8(%rbx,%r11,8), %rdx + movl $1, %ebx + movl %edx, %ecx + movq %rdx, %r12 + shlq $4, %r12 + shll %cl, %ebx + addq __x_constants__@GOTPCREL(%rip), %r12 + andl $240, %ebx +..B2.9: + cmpq $7, %rdi + je ..B2.30 +..B2.10: + cmpq $0, 8(%r9) + je ..B2.13 +..B2.11: + orl %esi, %ebx + je ..B2.13 +..B2.12: + movl $1182793727, 24(%rsp) + movss 24(%rsp), %xmm1 + movss 24(%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss %xmm1, 24(%rsp) +..B2.13: + movq 8(%r12), %rbx + cmpq $1, %rdi + je ..B2.29 +..B2.14: + cmpq $3, %rdi + je ..B2.19 +..B2.15: + cmpq $4, %rdi + jne ..B2.17 +..B2.16: + movq $0x7fffffffffffffff, %rcx + andq %rcx, %rbx + jmp ..B2.20 +..B2.17: + cmpq $5, %rdi + jne ..B2.20 +..B2.18: + movq $0x7fffffffffffffff, %rcx + andq %rbx, %rcx + movq $0x8000000000000000, %rbx + andq 8(%r8), %rbx + orq %rcx, %rbx + jmp ..B2.20 +..B2.19: + movq $0x8000000000000000, %rcx + xorq %rcx, %rbx +..B2.20: + movq %rbx, 8(%rbp) + testl $192, %r10d + movq (%r12), %rcx + movq %rcx, (%rbp) + je ..B2.24 +..B2.21: + cmpq %r13, %rdx + jg ..B2.24 +..B2.22: + cmpq $0, 8(%r9) + je ..B2.24 +..B2.23: + movl $8388608, 20(%rsp) + movss 20(%rsp), %xmm0 + cvtss2sd %xmm0, %xmm0 + mulsd .L_2il0floatpacket.7(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 20(%rsp) +..B2.24: + movq 96(%rsp), %rcx + movq $0x8000000000000000, %rdx + xorq %rsp, %rcx + orq %rdx, %r15 + cmpq %fs:40, %rcx + jne ..B2.28 +..B2.25: + movq %r15, %rax + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.26: + movq 96(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B2.28 +..B2.27: + movq %r15, %rax + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.28: + call __stack_chk_fail@PLT +..B2.29: + movq $0x800000000000, %rcx + orq %rcx, %rbx + jmp ..B2.20 +..B2.30: + andq $-2013265921, %rdx + lea 32(%rsp), %rdi + movq (%rbp), %rcx + orq $268435456, %rdx + movq 8(%rbp), %rbx + movq %rcx, 32(%rdi) + movq %rbx, 40(%rdi) + movq %rdx, (%rdi) +..___tag_value___dpml_unpack_x_or_y__.110: + call __dpml_exception@PLT +..___tag_value___dpml_unpack_x_or_y__.111: +..B2.31: + movq (%rax), %rdx + movq %rdx, (%rbp) + movq 8(%rax), %rcx + movq %rcx, 8(%rbp) + jmp ..B2.24 +..B2.33: + xorq %rax, %rcx + jl ..B2.35 +..B2.34: + shrq $47, %rax + xorl %r15d, %r15d + andq $1, %rax + testq %rsi, %rsi + movq %r10, 8(%rdx) + movl %r11d, 4(%rdx) + movl $2, %edx + cmove %rdx, %r15 + cmovne %rax, %r14 + jmp ..B2.3 +..B2.35: + testq %rsi, %rsi + jne ..B2.37 +..B2.36: + movq %r10, 8(%rdx) + movl $8, %r15d + movl %r11d, 4(%rdx) + jmp ..B2.3 +..B2.37: + movq $0x8000000000000000, %rax + movq %rdx, %rdi + xorl %esi, %esi + addq %rax, %r10 + incl %r11d + movq %r10, 8(%rdx) + movl %r11d, 4(%rdx) + movq %r8, (%rsp) + movq %r9, 8(%rsp) +..___tag_value___dpml_unpack_x_or_y__.112: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_unpack_x_or_y__.113: +..B2.38: + movl $2048, 16(%rsp) + movl $6, %r15d + movss 16(%rsp), %xmm1 + movss 16(%rsp), %xmm0 + movq 8(%rsp), %r9 + addss %xmm0, %xmm1 + movq (%rsp), %r8 + movss %xmm1, 16(%rsp) + jmp ..B2.3 + .align 16,0x90 + .cfi_endproc + .type __dpml_unpack_x_or_y__,@function + .size __dpml_unpack_x_or_y__,.-__dpml_unpack_x_or_y__ + .data +# -- End __dpml_unpack_x_or_y__ + .text +# -- Begin __dpml_pack__ + .text + .align 16,0x90 + .globl __dpml_pack__ +__dpml_pack__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +..B3.1: + .cfi_startproc +..___tag_value___dpml_pack__.115: +..L116: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $120, %rsp + .cfi_def_cfa_offset 176 + movq %rsi, %r14 + xorl %esi, %esi + movq %r8, %r15 + movq %fs:40, %rax + movq %rcx, %r13 + xorq %rsp, %rax + movq %rdx, %r12 + movq %rax, 104(%rsp) + movq %rdi, %rbp +..___tag_value___dpml_pack__.130: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_pack__.131: +..B3.2: + movslq 4(%rbp), %rax + cmpq $-262144, %rax + je ..B3.28 +..B3.3: + movq %rax, %rdx + negq %rdx + movq %rdx, %rbx + addq $-16381, %rbx + jle ..B3.9 +..B3.4: + movl (%rbp), %r9d + lea -16381(%rax,%rdx), %rax + movq %rbp, %rsi + lea 80(%rsp), %rdi + xorl %edx, %edx + movq %rbp, %rcx + movq $0x8000000000000000, %r8 + movq %r8, 8(%rdi) + movq $0, 16(%rdi) + movl %eax, 4(%rdi) + movl %r9d, (%rdi) +..___tag_value___dpml_pack__.132: + call __dpml_addsub__@PLT +..___tag_value___dpml_pack__.133: +..B3.5: + movq $-16382, %rax + cmpq $113, %rbx + jle ..B3.9 +..B3.6: + cmpq $245763, %rbx + je ..B3.8 +..B3.7: + movq $-16383, %rax + cmpq $49155, %rbx + jle ..B3.9 +..B3.8: + decq %rax +..B3.9: + movq 16(%rbp), %r8 + xorl %edx, %edx + addq $16384, %r8 + xorl %r9d, %r9d + cmpq $16384, %r8 + lea 1(%rax), %r10 + movq 8(%rbp), %rcx + movq $0x1000000000000, %r11 + setb %dl + addq %rdx, %rcx + cmpq %rdx, %rcx + movq %rcx, %rbx + setb %r9b + shrq $15, %rcx + testl %r9d, %r9d + cmovne %r10, %rax + cmovne %r11, %rcx + shrq $15, %r8 + shlq $49, %rbx + orq %rbx, %r8 + movq %r8, (%r14) + lea 16381(%rax), %rdx + movq %rdx, %rbx + shlq $48, %rbx + addq %rcx, %rbx + movslq (%rbp), %rcx + shlq $32, %rcx + orq %rcx, %rbx + cmpq $32766, %rdx + jae ..B3.14 +..B3.10: + movq %rbx, 8(%r14) + cmpq $0, 8(%r15) + je ..B3.12 +..B3.11: + movl $1182793727, (%rsp) + movss (%rsp), %xmm1 + movss (%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss %xmm1, (%rsp) +..B3.12: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B3.24 +..B3.13: + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.14: + testq %rax, %rax + cmovl %r12, %r13 + addq $16382, %rax + testl %eax, %eax + jg ..B3.20 +..B3.15: + jl ..B3.26 +..B3.16: + movq %rbx, 8(%r14) + cmpq $0, 8(%r15) + jne ..B3.19 +..B3.17: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B3.24 +..B3.18: + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.19: + movq $0x8000000000000000, %rax + orq %rax, %r13 + jmp ..B3.21 +..B3.20: + movq %rbx, 8(%r14) +..B3.21: + andq $-2013265921, %r13 + lea 16(%rsp), %rdi + movq (%r14), %rax + orq $268435456, %r13 + movq 8(%r14), %rdx + movq %rax, 32(%rdi) + movq %rdx, 40(%rdi) + movq %r13, (%rdi) +..___tag_value___dpml_pack__.174: + call __dpml_exception@PLT +..___tag_value___dpml_pack__.175: +..B3.33: + movq %rax, %rdx +..B3.22: + movq (%rdx), %rax + movq %rax, (%r14) + movq 8(%rdx), %rdx + movq %rdx, 8(%r14) + movq 104(%rsp), %rcx + xorq %rsp, %rcx + cmpq %fs:40, %rcx + jne ..B3.24 +..B3.23: + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.24: + call __stack_chk_fail@PLT +..B3.26: + movq %rcx, 8(%r14) + jmp ..B3.21 +..B3.28: + movslq (%rbp), %rax + shlq $32, %rax + movq $0, (%r14) + movq %rax, 8(%r14) + movq 104(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B3.24 + jmp ..B3.13 + .align 16,0x90 + .cfi_endproc + .type __dpml_pack__,@function + .size __dpml_pack__,.-__dpml_pack__ + .data +# -- End __dpml_pack__ + .text +# -- Begin __dpml_evaluate_packed_poly__ + .text + .align 16,0x90 + .globl __dpml_evaluate_packed_poly__ +__dpml_evaluate_packed_poly__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +..B4.1: + .cfi_startproc +..___tag_value___dpml_evaluate_packed_poly__.197: +..L198: + + subq $104, %rsp + .cfi_def_cfa_offset 112 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 88(%rsp) + movq %rcx, %rax + movq 8(%rdx), %r11 + notq %rax + movq (%rdx), %r10 + movq %r11, 8(%r9) + movq %r10, %r11 + andq %rax, %r11 + movq %r11, 16(%r9) + movq %r10, %r11 + shrq $1, %r10 + andq $1, %r11 + andq %rcx, %r10 + shlq $31, %r11 + subq %r8, %r10 + movl %r11d, (%r9) + decq %rsi + movl %r10d, 4(%r9) + js ..B4.8 +..B4.2: + xorl %r10d, %r10d + movl %r10d, 68(%rsp) + movl %r10d, 64(%rsp) + movq %rdi, 56(%rsp) + movq %rcx, 48(%rsp) + movq %r12, 40(%rsp) + .cfi_offset 12, -72 + movq %r9, %r12 + movq %r13, 32(%rsp) + .cfi_offset 13, -80 + movq %rax, %r13 + movq %r14, 24(%rsp) + .cfi_offset 14, -88 + movq %r8, %r14 + movq %r15, 16(%rsp) + .cfi_offset 15, -96 + movq %rdx, %r15 + movq %rbx, 8(%rsp) + movq %rbp, (%rsp) + .cfi_offset 3, -104 + .cfi_offset 6, -112 + movq %rsi, %rbp +..B4.3: + movq %r12, %rsi + movq %r12, %rdx + movq 56(%rsp), %rdi +..___tag_value___dpml_evaluate_packed_poly__.206: + call __dpml_multiply__@PLT +..___tag_value___dpml_evaluate_packed_poly__.207: +..B4.4: + movq %r12, %rdi + xorl %esi, %esi +..___tag_value___dpml_evaluate_packed_poly__.208: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_evaluate_packed_poly__.209: +..B4.5: + addq $16, %r15 + movq %r13, %r10 + movq %r12, %rdi + lea 64(%rsp), %rsi + movq %r12, %rcx + movq 8(%r15), %rbx + movq %rbx, 8(%rsi) + movq (%r15), %rbx + andq %rbx, %r10 + movq %rbx, %rdx + shrq $1, %rbx + andq $1, %rdx + andq -16(%rsi), %rbx + subq %r14, %rbx + movq %r10, 16(%rsi) +..___tag_value___dpml_evaluate_packed_poly__.210: + call __dpml_addsub__@PLT +..___tag_value___dpml_evaluate_packed_poly__.211: +..B4.6: + addl %ebx, 4(%r12) + decq %rbp + jns ..B4.3 +..B4.7: + movq 40(%rsp), %r12 + .cfi_restore 12 + movq 32(%rsp), %r13 + .cfi_restore 13 + movq 24(%rsp), %r14 + .cfi_restore 14 + movq 16(%rsp), %r15 + .cfi_restore 15 + movq 8(%rsp), %rbx + .cfi_restore 3 + movq (%rsp), %rbp + .cfi_restore 6 +..B4.8: + movq 88(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B4.10 +..B4.9: + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B4.10: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __dpml_evaluate_packed_poly__,@function + .size __dpml_evaluate_packed_poly__,.-__dpml_evaluate_packed_poly__ + .data +# -- End __dpml_evaluate_packed_poly__ + .text +# -- Begin __dpml_addsub__ + .text + .align 16,0x90 + .globl __dpml_addsub__ +__dpml_addsub__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B5.1: + .cfi_startproc +..___tag_value___dpml_addsub__.221: +..L222: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + pushq %rbp + .cfi_def_cfa_offset 40 + .cfi_offset 6, -40 + subq $40, %rsp + .cfi_def_cfa_offset 80 + movq %rdi, %r9 + movq %rdx, %r15 + movq %rsi, %rax + movq %r15, %rbx + movq %rcx, %r8 + movq %r15, %rcx + xorl %ebp, %ebp + movl (%r9), %edx + andq $4, %rcx + movslq %edx, %rdi + movslq (%rax), %r11 + cmovne %ebp, %edx + shlq $31, %rbx + xorq %rbx, %rdi + xorq %r11, %rdi + testq %rcx, %rcx + movl 4(%r9), %esi + cmovne %rbx, %rdi + movslq %esi, %rbx + sarq $31, %rdi + movq %rbx, %rcx + movq %fs:40, %r10 + andq $1, %rdi + xorq %rsp, %r10 + movq %r10, 32(%rsp) + movslq 4(%rax), %r10 + subq %r10, %rcx + jge ..B5.3 +..B5.2: + negq %rcx + movq %r9, %rbp + addq %rcx, %rbx + movq %rax, %r9 + movl %ebx, %esi + movq %rdi, %rbx + shlq $31, %rbx + movq %rbp, %rax + movslq %edx, %rdx + movl $-2147483648, %ebp + xorq %rbx, %rdx +..B5.3: + movq 16(%rax), %rbx + movl $2, %r11d + movq 8(%rax), %rax +..B5.4: + movq %rcx, %r10 + negq %r10 + addq $64, %r10 + testq %r10, %r10 + jg ..B5.11 +..B5.5: + movq %r10, %rcx + movq %rax, %rbx + negq %rcx + xorl %eax, %eax + decq %r11 + jne ..B5.4 +..B5.6: + movq 8(%r9), %rcx + testq $2, %r15 + movq %rcx, 8(%r8) + movl 4(%r9), %eax + movq 16(%r9), %rbx + movl %eax, 4(%r8) + movq %rbx, 16(%r8) + movl %edx, (%r8) + je ..B5.8 +..B5.7: + movq 8(%r9), %rcx + xorl %ebp, %edx + movq %rcx, 32(%r8) + movl 4(%r9), %eax + movq 16(%r9), %rbx + movl %eax, 28(%r8) + movq %rbx, 40(%r8) + movl %edx, 24(%r8) +..B5.8: + movq 32(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B5.10 +..B5.9: + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B5.10: + call __stack_chk_fail@PLT +..B5.11: + testq %rcx, %rcx + je ..B5.13 +..B5.12: + movl %ecx, %r11d + movl %r11d, %ecx + shrq %cl, %rbx + movl %r10d, %ecx + movq %rax, %r10 + shlq %cl, %r10 + movl %r11d, %ecx + shrq %cl, %rax + orq %r10, %rbx +..B5.13: + movq %r8, %r14 + movq %r12, 8(%rsp) + .cfi_offset 12, -72 + movq %rdi, %r12 + movq %r13, (%rsp) + .cfi_offset 13, -80 + movq %r9, %r13 + jmp ..B5.14 +..B5.22: + negq %r12 + xorq $2, %r15 + movl 4(%r13), %esi + incq %r12 + addq $24, %r14 + xorl %ebp, %edx +..B5.14: + movq 16(%r13), %r11 + testq %r12, %r12 + movq 8(%r13), %rdi + jne ..B5.17 +..B5.15: + xorl %ecx, %ecx + lea (%r11,%rbx), %r10 + cmpq %r11, %r10 + movl %ecx, %r11d + setb %r11b + xorl %r9d, %r9d + andq $15, %r15 + movl %r11d, %r8d + lea (%rax,%r8), %r11 + cmpq %r8, %r11 + setb %r9b + addq %rdi, %r11 + cmpq %rdi, %r11 + setb %cl + addl %ecx, %r9d + je ..B5.19 +..B5.16: + movq %r11, %rcx + incl %esi + shrq $1, %r10 + shlq $63, %rcx + shrq $1, %r11 + orq %rcx, %r10 + btsq $63, %r11 + jmp ..B5.19 +..B5.17: + xorl %ecx, %ecx + xorl %r10d, %r10d + cmpq %r11, %rbx + seta %r10b + xorl %r9d, %r9d + addq $-8, %r15 + movl %r10d, %r8d + movq %r11, %r10 + subq %rbx, %r10 + lea (%rax,%r8), %r11 + cmpq %r8, %r11 + setb %r9b + negq %r11 + addq %rdi, %r11 + cmpq %r11, %rdi + setb %cl + addl %ecx, %r9d + je ..B5.19 +..B5.18: + movq $-1, %rcx + xorl %edi, %edi + negq %r10 + movslq %edx, %rdx + cmovne %rcx, %rdi + btcq $31, %rdx + negq %r11 + movl $-2147483648, %ebp + addq %rdi, %r11 +..B5.19: + movq %r11, 8(%r14) + testq $16, %r15 + movq %r10, 16(%r14) + movl %esi, 4(%r14) + movl %edx, (%r14) + je ..B5.21 +..B5.20: + movq %r14, %rdi + xorl %esi, %esi + movl %edx, 16(%rsp) + movq %rax, 24(%rsp) +..___tag_value___dpml_addsub__.248: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_addsub__.249: +..B5.28: + movq 24(%rsp), %rax + movl 16(%rsp), %edx +..B5.21: + testq $2, %r15 + jne ..B5.22 +..B5.23: + movq 32(%rsp), %rax + xorq %rsp, %rax + movq 8(%rsp), %r12 + .cfi_restore 12 + movq (%rsp), %r13 + .cfi_restore 13 + cmpq %fs:40, %rax + jne ..B5.10 + jmp ..B5.9 + .align 16,0x90 + .cfi_endproc + .type __dpml_addsub__,@function + .size __dpml_addsub__,.-__dpml_addsub__ + .data +# -- End __dpml_addsub__ + .text +# -- Begin __dpml_ffs_and_shift__ + .text + .align 16,0x90 + .globl __dpml_ffs_and_shift__ +__dpml_ffs_and_shift__: +# parameter 1: %rdi +# parameter 2: %rsi +..B6.1: + .cfi_startproc +..___tag_value___dpml_ffs_and_shift__.253: +..L254: + + pushq %rsi + .cfi_def_cfa_offset 16 + movq %rdi, %r9 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, (%rsp) + testq %rsi, %rsi + movq 8(%r9), %r8 + jne ..B6.4 +..B6.2: + movslq 4(%r9), %rdi + testq %r8, %r8 + jl ..B6.12 +..B6.3: + movq 16(%r9), %rsi + jmp ..B6.7 +..B6.4: + xorl %ecx, %ecx + movl $64, %edi + cmpq $1, %rsi + jne ..B6.6 +..B6.5: + movq %r8, %rdx + movl $-2147483648, %eax + negq %rdx + testq %r8, %r8 + cmovl %eax, %ecx + cmovl %rdx, %r8 +..B6.6: + movq %r8, 8(%r9) + xorl %esi, %esi + movq $0, 16(%r9) + movl %ecx, (%r9) +..B6.7: + movl $2, %edx + xorl %eax, %eax +..B6.8: + testq %r8, %r8 + jne ..B6.16 +..B6.9: + addq $64, %rax + movq %rsi, %r8 + xorl %esi, %esi + decq %rdx + jne ..B6.8 +..B6.10: + movl $-262144, 4(%r9) + movq (%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B6.14 +..B6.11: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B6.12: + movq (%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B6.14 +..B6.13: + xorl %eax, %eax + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B6.14: + call __stack_chk_fail@PLT +..B6.16: + jl ..B6.21 +..B6.17: + movq %r8, %rcx + shrq $58, %rcx + andq $30, %rcx + je ..B6.19 +..B6.18: + movl $21932, %edx + shrl %cl, %edx + andl $3, %edx + incq %rdx + jmp ..B6.20 +..B6.19: + movq %r8, %rdx + pxor %xmm0, %xmm0 + andq $-256, %rdx + cmove %r8, %rdx + cvtsi2sdq %rdx, %xmm0 + testq %rdx, %rdx + jge ..B6.26 +..B6.27: + movq %rdx, %rcx + pxor %xmm0, %xmm0 + shrq $1, %rdx + andq $1, %rcx + orq %rdx, %rcx + cvtsi2sdq %rcx, %xmm0 + addsd %xmm0, %xmm0 +..B6.26: + movd %xmm0, %rdx + sarq $52, %rdx + negq %rdx + addq $1086, %rdx +..B6.20: + movl %edx, %ecx + movq %rsi, %r10 + shlq %cl, %r8 + movq %rdx, %rcx + negq %rcx + addq %rdx, %rax + shrq %cl, %r10 + movl %edx, %ecx + orq %r10, %r8 + shlq %cl, %rsi +..B6.21: + subq %rax, %rdi + movq %r8, 8(%r9) + movq %rsi, 16(%r9) + movl %edi, 4(%r9) + movq (%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B6.14 + jmp ..B6.11 + .align 16,0x90 + .cfi_endproc + .type __dpml_ffs_and_shift__,@function + .size __dpml_ffs_and_shift__,.-__dpml_ffs_and_shift__ + .data +# -- End __dpml_ffs_and_shift__ + .section .rodata, "a" + .align 16 + .align 16 + .globl __x_constants__ +__x_constants__: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1073610752 + .long 0 + .long 0 + .long 0 + .long 1073676288 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 3306619320 + .long 2221509004 + .long 3041149649 + .long 1073648159 + .long 3306619320 + .long 2221509004 + .long 3041149649 + .long 1073779231 + .long 2479964490 + .long 592389929 + .long 3354604061 + .long 1073753495 + .long 3306619320 + .long 2221509004 + .long 3041149649 + .long 1073713695 + .long 0 + .long 0 + .long 0 + .long 1074030592 + .long 0 + .long 0 + .long 0 + .long 1074096128 + .long 0 + .long 0 + .long 0 + .long 1074138624 + .long 0 + .long 0 + .long 0 + .long 1074161664 + .long 0 + .long 0 + .long 0 + .long 2147418112 + .type __x_constants__,@object + .size __x_constants__,208 + .align 8 +.L_2il0floatpacket.7: + .long 0x00000000,0x3e600000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/dpml_ux_ops_64.S b/external/sgx_libm/intel64/dpml_ux_ops_64.S new file mode 100644 index 0000000000..60b2b7994d --- /dev/null +++ b/external/sgx_libm/intel64/dpml_ux_ops_64.S @@ -0,0 +1,1964 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_ops_64.c" + .text +..TXTST0: +# -- Begin __dpml_extended_multiply__ + .text + .align 16,0x90 + .globl __dpml_extended_multiply__ +__dpml_extended_multiply__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B1.1: + .cfi_startproc +..___tag_value___dpml_extended_multiply__.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + movq %rdi, %r15 + movq 16(%rsi), %r14 + movq %r14, %r10 + movl %r14d, %r9d + movq %rcx, %r8 + movq %r9, %r13 + movq 16(%r15), %rax + movq %rax, %rbp + movl %eax, %ebx + movq %rax, %rdi + shrq $32, %rbp + imulq %rbx, %r13 + imulq %r14, %rdi + movq %r9, -8(%rsp) + imulq %rbp, %r9 + shrq $32, %r13 + shrq $32, %r10 + addq %r9, %r13 + movq %rbx, %r9 + imulq %r10, %r9 + addq %r13, %r9 + movq %r9, %rcx + cmpq %r13, %r9 + movq %rbp, %r9 + movl $0, %r13d + movq 8(%r15), %r12 + setb %r13b + imulq %r10, %r9 + imulq %r12, %r14 + movq 8(%rsi), %r11 + imulq %r11, %rax + shrq $32, %rcx + shlq $32, %r13 + addq %r13, %rcx + addq %r9, %rcx + movl (%r15), %r9d + addq %r14, %rcx + movq %rdi, 16(%r8) + xorl (%rsi), %r9d + cmpq %r14, %rcx + movl 4(%rsi), %esi + movq %r12, %r14 + movl 4(%r15), %edi + movl %r9d, (%rdx) + movl %r9d, (%r8) + movl $0, %r9d + setb %r9b + addq %rax, %rcx + movq %rcx, 8(%r8) + cmpq %rax, %rcx + movl %r11d, %ecx + lea (%rdi,%rsi), %r13d + movl %r13d, 4(%rdx) + lea -128(%rdi,%rsi), %r15d + movl %r15d, 4(%r8) + movq %rcx, %r15 + movq %rcx, %r13 + movl $0, %eax + setb %al + imulq %rbx, %r15 + imulq %r11, %r14 + imulq %rbp, %r13 + shrq $32, %r11 + imulq %r11, %rbx + imulq %r11, %rbp + shrq $32, %r15 + addq %r13, %r15 + addq %r15, %rbx + cmpq %r15, %rbx + movq %rbx, %r8 + movl $0, %ebx + setb %bl + shrq $32, %r8 + shlq $32, %rbx + addq %rbx, %r8 + addq %rbp, %r8 + movq -8(%rsp), %rbp + movq %rbp, %rdi + movl %r12d, %r15d + shrq $32, %r12 + movq %r15, %rsi + imulq %r15, %rdi + imulq %r12, %rbp + imulq %r10, %rsi + imulq %r12, %r10 + addq %rax, %r9 + xorl %eax, %eax + shrq $32, %rdi + addq %r14, %r9 + addq %rbp, %rdi + cmpq %r14, %r9 + movl $0, %r14d + setb %r14b + addq %rdi, %rsi + cmpq %rdi, %rsi + movq %rsi, %r13 + setb %al + addq %r8, %r9 + shrq $32, %r13 + shlq $32, %rax + addq %rax, %r13 + movq %rcx, %rax + imulq %r15, %rax + imulq %r12, %rcx + imulq %r11, %r15 + imulq %r11, %r12 + shrq $32, %rax + addq %r10, %r13 + addq %rcx, %rax + xorl %r10d, %r10d + cmpq %r8, %r9 + setb %r10b + xorl %r11d, %r11d + addq %rax, %r15 + cmpq %rax, %r15 + movq %r15, %rcx + movl $0, %r15d + setb %r15b + addq %r13, %r9 + cmpq %r13, %r9 + setb %r11b + shrq $32, %rcx + addq %r10, %r14 + shlq $32, %r15 + addq %r15, %rcx + addq %r12, %rcx + addq %r11, %r14 + addq %r14, %rcx + movq %r9, 16(%rdx) + movq %rcx, 8(%rdx) + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __dpml_extended_multiply__,@function + .size __dpml_extended_multiply__,.-__dpml_extended_multiply__ + .data +# -- End __dpml_extended_multiply__ + .text +# -- Begin __dpml_evaluate_rational__ + .text + .align 16,0x90 + .globl __dpml_evaluate_rational__ +__dpml_evaluate_rational__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +..B2.1: + .cfi_startproc +..___tag_value___dpml_evaluate_rational__.28: +..L29: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $88, %rsp + .cfi_def_cfa_offset 144 + movq %rdi, %r13 + movq %rcx, %rbx + movq %r8, %r14 + movq %rbx, %r9 + movq %rsi, %r15 + movq %rdx, 32(%rsp) + movq %rbx, %rbp + sarq $58, %r9 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 72(%rsp) + addl %r9d, 4(%r13) + testq $68, %rbx + jne ..B2.3 +..B2.2: + movl $136, %eax + xorl %ebp, %ebp + cmpl $0, (%r13) + movq %r13, %r12 + cmovne %rax, %rbp + xorq %rbx, %rbp + jmp ..B2.4 +..B2.3: + movq %r13, %rdi + lea 48(%rsp), %r12 + movq %r13, %rsi + movq %r12, %rdx +..___tag_value___dpml_evaluate_rational__.43: + call __dpml_multiply__@PLT +..___tag_value___dpml_evaluate_rational__.44: +..B2.4: + movq %r12, %rdi + xorl %esi, %esi +..___tag_value___dpml_evaluate_rational__.45: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_evaluate_rational__.46: +..B2.5: + movq 32(%rsp), %r9 + movq %r9, %r8 + negq %r8 + movslq 4(%r12), %rax + imulq %rax, %r8 + shlq $4, %r9 + movq %r8, 24(%rsp) + testq $512, %rbx + movq %r9, 40(%rsp) + je ..B2.7 +..B2.6: + testq $1024, %rbx + je ..B2.8 +..B2.7: + xorl %eax, %eax + jmp ..B2.9 +..B2.8: + movl $1, %eax +..B2.9: + testq $15, %rbx + lea (%rax,%rax,2), %rax + lea (,%rax,8), %r9 + lea (%r14,%rax,8), %r8 + je ..B2.16 +..B2.10: + testq $8, %rbp + lea __eval_neg_poly(%rip), %r11 + lea __eval_pos_poly(%rip), %r10 + movq %rbx, %rax + cmovne %r11, %r10 + negq %r9 + andq $240, %rax + cmove %r14, %r8 + addq %r14, %r9 + addq $24, %r9 + cmpq %r11, %r10 + jne ..B2.12 +..B2.11: + movq %r12, %rdi + movq %r15, %rdx + movq 24(%rsp), %rsi + movq 32(%rsp), %rcx + movq %r8, (%rsp) + movq %rax, 8(%rsp) + movq %r9, 16(%rsp) +..___tag_value___dpml_evaluate_rational__.47: + call __eval_neg_poly +..___tag_value___dpml_evaluate_rational__.48: + jmp ..B2.36 +..B2.12: + movq %r12, %rdi + movq %r15, %rdx + movq 24(%rsp), %rsi + movq 32(%rsp), %rcx + movq %r8, (%rsp) + movq %rax, 8(%rsp) + movq %r9, 16(%rsp) +..___tag_value___dpml_evaluate_rational__.49: + call __eval_pos_poly +..___tag_value___dpml_evaluate_rational__.50: +..B2.36: + movq 16(%rsp), %r9 + movq 8(%rsp), %rax + movq (%rsp), %r8 +..B2.13: + testq $2, %rbx + je ..B2.15 +..B2.14: + movq %r13, %rdi + movq %r8, %rsi + movq %r8, %rdx + movq %r8, (%rsp) + movq %rax, 8(%rsp) + movq %r9, 16(%rsp) +..___tag_value___dpml_evaluate_rational__.51: + call __dpml_multiply__@PLT +..___tag_value___dpml_evaluate_rational__.52: +..B2.35: + movq 16(%rsp), %r9 + movq 8(%rsp), %rax + movq (%rsp), %r8 +..B2.15: + movq 40(%rsp), %r10 + lea 24(%r15,%r10), %r15 + movl -8(%r15), %r11d + addl %r11d, 4(%r8) + jmp ..B2.17 +..B2.16: + movq 40(%rsp), %r10 + orq $256, %rbx + testq $1024, %rbx + movq %rbx, %rax + movq %r14, %r9 + lea 24(%r15,%r10), %r11 + cmovne %r11, %r15 + andq $240, %rax +..B2.17: + testq %rax, %rax + je ..B2.26 +..B2.18: + testq $128, %rbp + lea __eval_neg_poly(%rip), %rbp + lea __eval_pos_poly(%rip), %rax + cmovne %rbp, %rax + cmpq %rbp, %rax + jne ..B2.20 +..B2.19: + movq %r12, %rdi + movq %r15, %rdx + movq %r9, %r8 + movq 24(%rsp), %rsi + movq 32(%rsp), %rcx + movq %r9, 16(%rsp) +..___tag_value___dpml_evaluate_rational__.53: + call __eval_neg_poly +..___tag_value___dpml_evaluate_rational__.54: + jmp ..B2.39 +..B2.20: + movq %r12, %rdi + movq %r15, %rdx + movq %r9, %r8 + movq 24(%rsp), %rsi + movq 32(%rsp), %rcx + movq %r9, 16(%rsp) +..___tag_value___dpml_evaluate_rational__.55: + call __eval_pos_poly +..___tag_value___dpml_evaluate_rational__.56: +..B2.39: + movq 16(%rsp), %r9 +..B2.21: + testq $32, %rbx + je ..B2.23 +..B2.22: + movq %r13, %rdi + movq %r9, %rsi + movq %r9, %rdx + movq %r9, 16(%rsp) +..___tag_value___dpml_evaluate_rational__.57: + call __dpml_multiply__@PLT +..___tag_value___dpml_evaluate_rational__.58: +..B2.38: + movq 16(%rsp), %r9 +..B2.23: + movq 40(%rsp), %rax + movl 16(%rax,%r15), %ebp + addl %ebp, 4(%r9) + testq $1024, %rbx + je ..B2.27 +..B2.24: + movq 72(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.31 +..B2.25: + addq $88, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.26: + orq $256, %rbx +..B2.27: + testq $256, %rbx + jne ..B2.29 +..B2.28: + movq %r14, %rdi + lea 24(%r14), %rsi + movl $2, %edx + movq %r14, %rcx +..___tag_value___dpml_evaluate_rational__.79: + call __dpml_divide__@PLT +..___tag_value___dpml_evaluate_rational__.80: +..B2.29: + movq 72(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.31 +..B2.30: + addq $88, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.31: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __dpml_evaluate_rational__,@function + .size __dpml_evaluate_rational__,.-__dpml_evaluate_rational__ + .data +# -- End __dpml_evaluate_rational__ + .text +# -- Begin __eval_neg_poly + .text + .align 16,0x90 +__eval_neg_poly: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +..B3.1: + .cfi_startproc +..___tag_value___eval_neg_poly.102: +..L103: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + movq %rsi, %r12 + xorl %r10d, %r10d + cmpq $128, %r12 + movq %rcx, %rax + movl $1, %ecx + movslq 4(%rdi), %r11 + movq %rdx, %r13 + movq 8(%rdi), %r14 + movq 16(%rdi), %rdx + movq %r11, %rdi + cmovl %ecx, %r10d + xorl %ebx, %ebx + negq %rdi + xorl %r9d, %r9d + testl %r10d, %r10d + jne ..B3.5 +..B3.3: + addq %r11, %r12 + addq $16, %r13 + decq %rax + cmpq $128, %r12 + jge ..B3.3 +..B3.5: + xorl %ebp, %ebp + cmpq $64, %r12 + cmovge %ebp, %ecx + testl %ecx, %ecx + jne ..B3.12 +..B3.7: + movl %r12d, %ecx + decq %rax + addq %r11, %r12 + movq 8(%r13), %r9 + addq $16, %r13 + shrq %cl, %r9 + cmpq $64, %r12 + jl ..B3.12 +..B3.8: + testq %r9, %r9 + je ..B3.7 +..B3.9: + movq %r14, %rbp + xorl %r15d, %r15d + movl %r14d, %esi + shrq $32, %rbp + movq %r8, -72(%rsp) +..B3.10: + movl %r9d, %r10d + movq %rsi, %r8 + imulq %r10, %r8 + imulq %rbp, %r10 + shrq $32, %r9 + movq %rsi, %rcx + imulq %r9, %rcx + imulq %rbp, %r9 + shrq $32, %r8 + decq %rax + addq %r10, %r8 + addq %r8, %rcx + cmpq %r8, %rcx + movl %r15d, %r8d + movq %rcx, %r10 + movl %r12d, %ecx + setb %r8b + addq %r11, %r12 + shrq $32, %r10 + shlq $32, %r8 + addq %r8, %r10 + addq %r9, %r10 + movq 8(%r13), %r9 + addq $16, %r13 + shrq %cl, %r9 + subq %r10, %r9 + cmpq $64, %r12 + jge ..B3.10 +..B3.11: + movq -72(%rsp), %r8 +..B3.12: + movq %r12, %r10 + negq %r10 + testq %r12, %r12 + je ..B3.19 +..B3.13: + movq %r14, %rsi + movl %r14d, %ebp + shrq $32, %rsi + movq %r14, -16(%rsp) + xorl %r14d, %r14d + movq %r8, -72(%rsp) +..B3.14: + movl %r9d, %ebx + movq %rbp, %rcx + imulq %rbx, %rcx + imulq %rsi, %rbx + shrq $32, %r9 + movq %rbp, %r15 + imulq %r9, %r15 + imulq %rsi, %r9 + shrq $32, %rcx + decq %rax + addq %rbx, %rcx + movl %r14d, %ebx + addq %rcx, %r15 + cmpq %rcx, %r15 + movq %r15, %r8 + movl %r12d, %ecx + setb %bl + shrq $32, %r8 + shlq $32, %rbx + addq %rbx, %r8 + movq 8(%r13), %rbx + addq %r9, %r8 + movq (%r13), %r15 + movq %rbx, %r9 + shrq %cl, %r15 + movl %r10d, %ecx + shlq %cl, %r9 + movl %r12d, %ecx + orq %r9, %r15 + addq %rdi, %r10 + movq %r15, %r9 + addq $16, %r13 + subq %r8, %r9 + movl %r14d, %r8d + cmpq %r15, %r9 + seta %r8b + shrq %cl, %rbx + subq %r8, %rbx + addq %r11, %r12 + je ..B3.24 +..B3.15: + testq %rbx, %rbx + je ..B3.14 +..B3.16: + movq %rdx, %rcx + movl %edx, %r15d + shrq $32, %rcx + movq %rdx, -8(%rsp) + movq %rcx, -48(%rsp) + movq %r15, -40(%rsp) + movq %rsi, -32(%rsp) + movq %rdi, -56(%rsp) + movq %r11, -64(%rsp) +..B3.17: + movl %r12d, %ecx + decq %rax + movq 8(%r13), %r14 + movq %r14, %r11 + movq (%r13), %rdx + addq $16, %r13 + shrq %cl, %rdx + movl %r10d, %ecx + shlq %cl, %r11 + movl %r12d, %ecx + orq %r11, %rdx + movq -40(%rsp), %r11 + movq %r11, %r8 + movl %ebx, %esi + movq -48(%rsp), %r15 + shrq %cl, %r14 + movq %r15, %rcx + imulq %rsi, %r8 + imulq %rsi, %rcx + shrq $32, %r8 + movq -16(%rsp), %rdi + addq %rcx, %r8 + imulq %rbx, %rdi + shrq $32, %rbx + movq %r11, %rcx + imulq %rbx, %rcx + imulq %rbx, %r15 + addq %r8, %rcx + negq %rdi + cmpq %r8, %rcx + movl $0, %r8d + movq %rcx, %r11 + movl %r8d, %ecx + setb %cl + addq %rdx, %rdi + cmpq %rdx, %rdi + movq %rax, -24(%rsp) + movl %r8d, %edx + movl %r9d, %eax + seta %dl + shrq $32, %r11 + shlq $32, %rcx + addq %rcx, %r11 + addq %r15, %r11 + movq %rbp, %r15 + imulq %rax, %r15 + movq -32(%rsp), %rcx + negq %r11 + imulq %rcx, %rax + shrq $32, %r15 + addq %rdi, %r11 + shrq $32, %r9 + addq %rax, %r15 + movq %rbp, %rax + imulq %r9, %rax + imulq %rcx, %r9 + addq %r15, %rax + cmpq %r15, %rax + movl %r8d, %r15d + setb %r15b + subq %rdx, %r14 + movq %rax, %rdx + shrq $32, %rdx + shlq $32, %r15 + addq %r15, %rdx + xorl %r15d, %r15d + addq %r9, %rdx + xorl %r9d, %r9d + cmpq %rdi, %r11 + movq %rbp, %rdi + seta %r9b + imulq %rsi, %rdi + imulq %rcx, %rsi + shrq $32, %rdi + addq %rsi, %rdi + movq %rbp, %rsi + imulq %rbx, %rsi + imulq %rcx, %rbx + addq %rdi, %rsi + subq %r9, %r14 + movq %r11, %r9 + cmpq %rdi, %rsi + movq %rsi, %rax + setb %r15b + subq %rdx, %r9 + cmpq %r11, %r9 + seta %r8b + shrq $32, %rax + shlq $32, %r15 + addq %r15, %rax + subq %r8, %r14 + addq %rbx, %rax + movq %r14, %rbx + addq -56(%rsp), %r10 + subq %rax, %rbx + movq -24(%rsp), %rax + addq -64(%rsp), %r12 + jne ..B3.17 +..B3.18: + movq -8(%rsp), %rdx + movq -16(%rsp), %r14 + movq -72(%rsp), %r8 +..B3.19: + testq %rax, %rax + js ..B3.23 +..B3.20: + movl %edx, %r12d + movq %r14, %r10 + shrq $32, %rdx + movl %r14d, %r11d + shrq $32, %r10 + movq %rdx, -8(%rsp) + movq %r14, -16(%rsp) + movq %r8, -72(%rsp) +..B3.21: + movl %ebx, %ecx + movq %r12, %r8 + movq -8(%rsp), %r15 + movq %r15, %rdi + imulq %rcx, %r8 + imulq %rcx, %rdi + movq -16(%rsp), %rdx + movq %r12, %rbp + imulq %rbx, %rdx + shrq $32, %rbx + negq %rdx + imulq %rbx, %rbp + imulq %rbx, %r15 + shrq $32, %r8 + addq %rdi, %r8 + addq %r8, %rbp + movq %rbp, %rdi + cmpq %r8, %rbp + movl $0, %ebp + movl %ebp, %r8d + setb %r8b + movq (%r13), %r14 + addq %r14, %rdx + shrq $32, %rdi + shlq $32, %r8 + addq %r8, %rdi + xorl %r8d, %r8d + cmpq %r14, %rdx + movq %r11, %r14 + seta %r8b + addq %r15, %rdi + movl %r9d, %r15d + negq %rdi + addq %rdx, %rdi + imulq %r15, %r14 + imulq %r10, %r15 + movq 8(%r13), %rsi + addq $16, %r13 + shrq $32, %r9 + subq %r8, %rsi + movq %r11, %r8 + imulq %r9, %r8 + imulq %r10, %r9 + shrq $32, %r14 + addq %r15, %r14 + addq %r14, %r8 + cmpq %r14, %r8 + movl %ebp, %r14d + movq %r8, %r15 + setb %r14b + shrq $32, %r15 + shlq $32, %r14 + addq %r14, %r15 + xorl %r14d, %r14d + addq %r9, %r15 + xorl %r9d, %r9d + cmpq %rdx, %rdi + movq %r11, %rdx + seta %r9b + imulq %rcx, %rdx + imulq %r10, %rcx + shrq $32, %rdx + addq %rcx, %rdx + movq %r11, %rcx + imulq %rbx, %rcx + imulq %r10, %rbx + addq %rdx, %rcx + subq %r9, %rsi + movq %rdi, %r9 + cmpq %rdx, %rcx + movq %rcx, %r8 + setb %r14b + subq %r15, %r9 + cmpq %rdi, %r9 + seta %bpl + shrq $32, %r8 + shlq $32, %r14 + addq %r14, %r8 + subq %rbp, %rsi + addq %rbx, %r8 + movq %rsi, %rbx + subq %r8, %rbx + decq %rax + jns ..B3.21 +..B3.22: + movq -72(%rsp), %r8 +..B3.23: + xorl %eax, %eax + movq %rbx, 8(%r8) + movq %r9, 16(%r8) + movl %eax, 4(%r8) + movl %eax, (%r8) + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 56 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.24: + movq -16(%rsp), %r14 + movq -72(%rsp), %r8 + jmp ..B3.19 + .align 16,0x90 + .cfi_endproc + .type __eval_neg_poly,@function + .size __eval_neg_poly,.-__eval_neg_poly + .data +# -- End __eval_neg_poly + .text +# -- Begin __dpml_divide__ + .text + .align 16,0x90 + .globl __dpml_divide__ +__dpml_divide__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B4.1: + .cfi_startproc +..___tag_value___dpml_divide__.136: +..L137: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $56, %rsp + .cfi_def_cfa_offset 112 + movq %rsi, %rbp + testq %rbp, %rbp + lea __ux_one__(%rip), %r8 + movq %rdi, %rbx + movq %rcx, %r15 + jne ..L151 + movq %r8, %rbp +..L151: + testq %rbx, %rbx + movq %rdx, %r12 + movq %fs:40, %rax + jne ..L152 + movq %r8, %rbx +..L152: + xorq %rsp, %rax + movq %rax, 48(%rsp) + cmpq %r8, %rbp + movq 8(%rbp), %r13 + movq 16(%rbp), %r14 + je ..B4.12 +..B4.2: + testq %r13, %r13 + jl ..B4.5 +..B4.3: + movq %rbp, %rdi + xorl %esi, %esi +..___tag_value___dpml_divide__.153: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_divide__.154: +..B4.4: + movq 8(%rbp), %r13 + movq 16(%rbp), %r14 +..B4.5: + lea 16(%rsp), %rdi +..___tag_value___dpml_divide__.155: + call fegetenv@PLT +..___tag_value___dpml_divide__.156: +..B4.6: + movq %r13, %rcx + pxor %xmm0, %xmm0 + shrq $1, %rcx + movq $0x3fffffffff, %rax + cvtsi2sdq %rcx, %xmm0 + movsd .L_2il0floatpacket.0(%rip), %xmm3 + movq %r13, %r9 + divsd %xmm0, %xmm3 + andq %rax, %r9 + movq %r14, %r8 + shlq $15, %r9 + movq $0xffffffc000000000, %rdx + shrq $49, %r8 + movq %r13, %rsi + movl (%rbx), %r10d + orq %r8, %r9 + movl 4(%rbx), %r8d + andq %rdx, %rsi + xorl (%rbp), %r10d + pxor %xmm1, %xmm1 + subl 4(%rbp), %r8d + pxor %xmm2, %xmm2 + cvttsd2si %xmm3, %rbp + cvtsi2sdq %r9, %xmm2 + shrq $1, %rsi + addq $-1280, %rbp + cvtsi2sdq %rsi, %xmm1 + movq 8(%rbx), %rsi + pxor %xmm7, %xmm7 + movq 16(%rbx), %rcx + movq $0xfffffff000000000, %rbx + andq %rbx, %rbp + andq %rsi, %rax + cvtsi2sdq %rbp, %xmm7 + movsd .L_2il0floatpacket.1(%rip), %xmm5 + movq %rcx, %r11 + mulsd %xmm5, %xmm2 + pxor %xmm6, %xmm6 + mulsd %xmm7, %xmm1 + mulsd %xmm7, %xmm2 + movsd .L_2il0floatpacket.0(%rip), %xmm0 + movq %rsi, %rdi + shlq $15, %rax + andq %rsi, %rdx + shrq $49, %r11 + pxor %xmm8, %xmm8 + orq %r11, %rax + pxor %xmm9, %xmm9 + cvtsi2sdq %rax, %xmm6 + subsd %xmm1, %xmm0 + mulsd %xmm6, %xmm5 + subsd %xmm2, %xmm0 + movsd .L_2il0floatpacket.2(%rip), %xmm4 + mulsd %xmm3, %xmm4 + shrq $11, %rdi + shlq $10, %rdi + shrq $1, %rdx + cvtsi2sdq %rdi, %xmm8 + cvtsi2sdq %rdx, %xmm9 + mulsd %xmm4, %xmm0 + movsd .L_2il0floatpacket.3(%rip), %xmm10 + xorl %edi, %edi + mulsd %xmm7, %xmm10 + mulsd %xmm0, %xmm8 + mulsd %xmm10, %xmm9 + mulsd %xmm5, %xmm10 + mulsd .L_2il0floatpacket.4(%rip), %xmm9 + addsd %xmm8, %xmm10 + cvttsd2si %xmm9, %rdx + cvttsd2si %xmm10, %rbx + movq %rdx, %rax + lea (%rbx,%rdx,4), %rdx + cmpq %rbx, %rdx + movl %r10d, (%r15) + setb %dil + xorl %ebx, %ebx + shrq $62, %rax + addq %rdi, %rax + cmpq $1, %r12 + je ..B4.8 +..B4.7: + movsd .L_2il0floatpacket.5(%rip), %xmm1 + movq %r14, %r9 + mulsd %xmm0, %xmm1 + xorl %r11d, %r11d + movq %r15, (%rsp) + movq %rax, %r12 + cvttsd2si %xmm1, %r15 + movl %edx, %ebx + lea (%r15,%rbp,4), %r15 + testq %r15, %r15 + movq %rbx, %rdi + movl %r8d, 8(%rsp) + movq $-1, %r8 + movl %r14d, %ebp + cmove %r8, %r15 + shrq $32, %r9 + movq %rdx, %r8 + imulq %rbp, %rdi + movq %rbx, %r10 + negq %r12 + shrq $32, %r8 + andq %r12, %r14 + imulq %r9, %r10 + imulq %r8, %rbp + imulq %r8, %r9 + shrq $32, %rdi + andq %r13, %r12 + addq %r10, %rdi + addq %rdi, %rbp + cmpq %rdi, %rbp + movq %rbp, %r10 + movl %r13d, %ebp + movq %rbx, %rdi + setb %r11b + shrq $32, %r10 + shlq $32, %r11 + addq %r11, %r10 + movq %r13, %r11 + addq %r9, %r10 + movq %r13, %r9 + shrq $32, %r9 + addq %r10, %r14 + imulq %rbp, %rdi + imulq %r9, %rbx + imulq %r8, %rbp + imulq %rdx, %r11 + imulq %r8, %r9 + shrq $32, %rdi + xorl %r8d, %r8d + addq %rbx, %rdi + addq %rdi, %rbp + cmpq %rdi, %rbp + movq %rbp, %rbx + movl $0, %ebp + setb %bpl + cmpq %r10, %r14 + setb %r8b + xorl %r10d, %r10d + addq %r11, %r14 + shrq $32, %rbx + shlq $32, %rbp + addq %rbp, %rbx + xorl %ebp, %ebp + addq %r9, %rbx + xorl %r9d, %r9d + cmpq %r11, %r14 + setb %r9b + xorl %r11d, %r11d + addq %rbx, %r12 + cmpq %rbx, %r12 + setb %r11b + xorl %ebx, %ebx + addq %r9, %r8 + addq %r8, %r12 + xorl %r9d, %r9d + cmpq %r8, %r12 + setb %bl + cmpq %r14, %rcx + setb %r10b + addq %rbx, %r11 + xorl %ebx, %ebx + cmpq %r12, %rsi + setb %bl + negq %r12 + addq %rsi, %r12 + negq %r11 + cmpq %r10, %r12 + setb %bpl + subq %rbx, %r11 + movl $1, %ebx + cmpq %r12, %r10 + movl $0, %r12d + cmovne %ebx, %r12d + subq %rbp, %r11 + orq %r11, %r12 + cmove %r13, %r11 + negq %r14 + addq %rcx, %r14 + xorq %r11, %r13 + subq %r13, %r14 + movl %r15d, %r13d + movl %r14d, %edi + movq %r13, %r8 + shrq $32, %r14 + imulq %rdi, %r8 + imulq %r14, %r13 + shrq $32, %r15 + imulq %r15, %rdi + imulq %r15, %r14 + shrq $32, %r8 + addq %r13, %r8 + addq %r8, %rdi + cmpq %r8, %rdi + movq %rdi, %r13 + movl 8(%rsp), %r8d + setb %r9b + orq %rcx, %rsi + movl $0, %ecx + cmove %ecx, %ebx + xorl %esi, %esi + shrq $32, %r13 + shlq $32, %r9 + addq %r9, %r13 + addq %r14, %r13 + movq %r13, %r14 + shrq $63, %r14 + addq %r14, %r12 + addq %r12, %rdx + cmpq %r12, %rdx + setb %sil + sarq $63, %r12 + addq %r12, %rax + movq (%rsp), %r15 + lea (%rbx,%r13,2), %rbx + addq %rsi, %rax +..B4.8: + movq %rax, %rsi + movl %eax, %ecx + movq %rdx, %rbp + andq %rax, %rdx + shrq %cl, %rbp + movl %eax, %ecx + shlq $63, %rsi + lea 16(%rsp), %rdi + shlq $63, %rdx + orq %rbp, %rsi + shrq %cl, %rbx + movslq %r8d, %r8 + orq %rbx, %rdx + addq %rax, %r8 + movq %rsi, 8(%r15) + movq %rdx, 16(%r15) + movl %r8d, 4(%r15) +..___tag_value___dpml_divide__.157: + call fesetenv@PLT +..___tag_value___dpml_divide__.158: +..B4.9: + movq 48(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B4.11 +..B4.10: + addq $56, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B4.11: + call __stack_chk_fail@PLT +..B4.12: + movq 8(%rbx), %rcx + movq %rcx, 8(%r15) + movl (%rbx), %eax + movl 4(%rbx), %edx + movq 16(%rbx), %rbx + movl %eax, (%r15) + movl %edx, 4(%r15) + movq %rbx, 16(%r15) + movq 48(%rsp), %rbp + xorq %rsp, %rbp + cmpq %fs:40, %rbp + jne ..B4.11 + jmp ..B4.10 + .align 16,0x90 + .cfi_endproc + .type __dpml_divide__,@function + .size __dpml_divide__,.-__dpml_divide__ + .data +# -- End __dpml_divide__ + .text +# -- Begin __dpml_multiply__ + .text + .align 16,0x90 + .globl __dpml_multiply__ +__dpml_multiply__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B5.1: + .cfi_startproc +..___tag_value___dpml_multiply__.180: +..L181: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + movq %rdi, %r15 + movq 8(%rsi), %r9 + movq %rdx, %r11 + movl %r9d, %ecx + movq %rcx, %r13 + movq %rcx, %rax + movq 16(%r15), %rdi + movl %edi, %r14d + movq 8(%r15), %r8 + movq %r8, %r10 + shrq $32, %rdi + imulq %r14, %r13 + imulq %r9, %r10 + imulq %rdi, %rax + shrq $32, %r9 + imulq %r9, %r14 + imulq %r9, %rdi + shrq $32, %r13 + addq %rax, %r13 + addq %r13, %r14 + cmpq %r13, %r14 + movq %r14, %rax + movl $0, %r14d + setb %r14b + shrq $32, %rax + shlq $32, %r14 + addq %r14, %rax + addq %rdi, %rax + movl (%r15), %edi + addq %rax, %r10 + movq 16(%rsi), %rdx + xorl (%rsi), %edi + movl 4(%r15), %r15d + movl %edx, %r13d + movl %edi, (%r11) + movq %r13, %rdi + addl 4(%rsi), %r15d + movl %r8d, %esi + shrq $32, %r8 + movq %rsi, %r14 + imulq %rsi, %rdi + imulq %r8, %r13 + shrq $32, %rdx + imulq %rdx, %r14 + imulq %r8, %rdx + shrq $32, %rdi + addq %r13, %rdi + xorl %r13d, %r13d + addq %rdi, %r14 + cmpq %rdi, %r14 + movl %r15d, 4(%r11) + movq %r14, %r15 + setb %r13b + xorl %r14d, %r14d + cmpq %rax, %r10 + setb %r14b + shrq $32, %r15 + shlq $32, %r13 + addq %r13, %r15 + addq %rdx, %r15 + movq %rcx, %rdx + imulq %rsi, %rdx + imulq %r8, %rcx + imulq %r9, %rsi + imulq %r9, %r8 + shrq $32, %rdx + addq %r15, %r10 + addq %rcx, %rdx + xorl %ecx, %ecx + addq %rdx, %rsi + cmpq %rdx, %rsi + movq %rsi, %r13 + setb %cl + shrq $32, %r13 + shlq $32, %rcx + addq %rcx, %r13 + addq %r8, %r13 + xorl %r8d, %r8d + cmpq %r15, %r10 + setb %r8b + addq %r14, %r8 + addq %r8, %r13 + movq %r10, 16(%r11) + movq %r13, 8(%r11) + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __dpml_multiply__,@function + .size __dpml_multiply__,.-__dpml_multiply__ + .data +# -- End __dpml_multiply__ + .text +# -- Begin __eval_pos_poly + .text + .align 16,0x90 +__eval_pos_poly: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +..B6.1: + .cfi_startproc +..___tag_value___eval_pos_poly.195: +..L196: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + movq %rsi, %r11 + movq 16(%rdi), %r9 + cmpq $128, %r11 + movq %r9, -32(%rsp) + movl $0, %r9d + movq %rcx, %rax + movl $1, %ecx + movslq 4(%rdi), %rbp + cmovl %ecx, %r9d + xorl %ebx, %ebx + xorl %esi, %esi + movq %rbp, -64(%rsp) + negq %rbp + movq 8(%rdi), %r10 + testl %r9d, %r9d + jne ..B6.5 +..B6.2: + movq -64(%rsp), %rdi +..B6.3: + addq %rdi, %r11 + addq $16, %rdx + decq %rax + cmpq $128, %r11 + jge ..B6.3 +..B6.5: + xorl %edi, %edi + cmpq $64, %r11 + cmovge %edi, %ecx + testl %ecx, %ecx + jne ..B6.12 +..B6.6: + movq -64(%rsp), %rdi +..B6.7: + movl %r11d, %ecx + decq %rax + addq %rdi, %r11 + movq 8(%rdx), %rsi + addq $16, %rdx + shrq %cl, %rsi + cmpq $64, %r11 + jl ..B6.12 +..B6.8: + testq %rsi, %rsi + je ..B6.7 +..B6.9: + movq %r10, %r9 + xorl %r12d, %r12d + movl %r10d, %ebx + shrq $32, %r9 + movq -64(%rsp), %r13 +..B6.10: + movl %esi, %edi + movq %rbx, %r15 + imulq %rdi, %r15 + imulq %r9, %rdi + shrq $32, %rsi + movq %rbx, %r14 + imulq %rsi, %r14 + imulq %r9, %rsi + shrq $32, %r15 + movl %r12d, %ecx + addq %rdi, %r15 + decq %rax + addq %r15, %r14 + cmpq %r15, %r14 + movq %r14, %rdi + setb %cl + shrq $32, %rdi + shlq $32, %rcx + addq %rcx, %rdi + movl %r11d, %ecx + addq %rsi, %rdi + addq %r13, %r11 + movq 8(%rdx), %rsi + addq $16, %rdx + shrq %cl, %rsi + addq %rdi, %rsi + cmpq $64, %r11 + jge ..B6.10 +..B6.11: + xorl %ebx, %ebx + cmpq %rdi, %rsi + setb %bl +..B6.12: + movq %r11, %r9 + xorl %edi, %edi + negq %r9 + testq %r11, %r11 + je ..B6.38 +..B6.13: + testq %rbx, %rbx + jne ..B6.18 +..B6.14: + movq %r10, %rbx + xorl %r13d, %r13d + movq %r8, -56(%rsp) + movl %r10d, %r15d + shrq $32, %rbx + movq %r10, -40(%rsp) + movq -64(%rsp), %r8 +..B6.15: + movl %esi, %r12d + movq %r15, %r14 + imulq %r12, %r14 + imulq %rbx, %r12 + shrq $32, %rsi + movq %r15, %rcx + imulq %rsi, %rcx + imulq %rbx, %rsi + shrq $32, %r14 + decq %rax + addq %r12, %r14 + movl %r13d, %r12d + addq %r14, %rcx + cmpq %r14, %rcx + movq %rcx, %r10 + movl %r11d, %ecx + setb %r12b + shrq $32, %r10 + shlq $32, %r12 + addq %r12, %r10 + movq 8(%rdx), %r12 + addq %rsi, %r10 + movq (%rdx), %rsi + movq %r12, %r14 + shrq %cl, %rsi + movl %r9d, %ecx + shlq %cl, %r14 + movl %r11d, %ecx + orq %r14, %rsi + addq %rbp, %r9 + addq %r10, %rsi + addq $16, %rdx + cmpq %r10, %rsi + movl %r13d, %r10d + setb %r10b + shrq %cl, %r12 + addq %r10, %r12 + addq %r8, %r11 + je ..B6.32 +..B6.16: + testq %r12, %r12 + je ..B6.15 +..B6.17: + movq -40(%rsp), %r10 + movq %r12, %rbx + movq -56(%rsp), %r8 +..B6.18: + testq %rax, %rax + jge ..B6.33 +..B6.19: + movq %rbx, 8(%r8) + movq %rsi, 16(%r8) + movl %edi, 4(%r8) + movl $0, (%r8) + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 56 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B6.38: + movl %edi, -48(%rsp) + movq %r10, -40(%rsp) + movq %r8, -56(%rsp) +..B6.21: + testq %rax, %rax + jl ..B6.30 +..B6.22: + movl %ebx, %edi + decq %rax + movq -32(%rsp), %rcx + movq %rdi, %r15 + movl %ecx, %r13d + movq %rdi, %r11 + movq -40(%rsp), %rbp + movq %rbp, %r9 + shrq $32, %rcx + imulq %r13, %r15 + imulq %rbx, %r9 + imulq %rcx, %r11 + shrq $32, %rbx + movq %r13, -24(%rsp) + imulq %rbx, %r13 + shrq $32, %r15 + addq %r11, %r15 + xorl %r11d, %r11d + addq %r15, %r13 + xorl %r14d, %r14d + movq %r13, %r8 + cmpq %r15, %r13 + movq %rcx, %r13 + setb %r14b + imulq %rbx, %r13 + shrq $32, %r8 + shlq $32, %r14 + movq (%rdx), %r12 + addq %r14, %r8 + movq %rax, -16(%rsp) + addq %r9, %r12 + movl %esi, %eax + addq %r13, %r8 + xorl %r13d, %r13d + cmpq %r9, %r12 + movq %rax, %r14 + movl %ebp, %r9d + setb %r13b + addq %r8, %r12 + shrq $32, %rbp + imulq %r9, %r14 + imulq %rbp, %rax + shrq $32, %r14 + shrq $32, %rsi + addq %rax, %r14 + movq %r9, %rax + imulq %rsi, %rax + imulq %rbp, %rsi + addq %r14, %rax + cmpq %r14, %rax + movl %r11d, %r14d + movq %rax, %r15 + setb %r14b + shrq $32, %r15 + shlq $32, %r14 + addq %r14, %r15 + xorl %r14d, %r14d + addq %rsi, %r15 + xorl %esi, %esi + cmpq %r8, %r12 + movq %rdi, %r8 + setb %sil + imulq %r9, %r8 + imulq %rbp, %rdi + shrq $32, %r8 + addq %rdi, %r8 + movq %r9, %rdi + imulq %rbx, %rdi + imulq %rbp, %rbx + addq %r8, %rdi + cmpq %r8, %rdi + movq %rdi, %rax + setb %r14b + xorl %edi, %edi + shrq $32, %rax + addq %rsi, %r13 + shlq $32, %r14 + lea (%r12,%r15), %rsi + addq %r14, %rax + addq %rbx, %rax + xorl %ebx, %ebx + cmpq %r15, %rsi + setb %bl + addq %r13, %rbx + movq 8(%rdx), %r10 + addq $16, %rdx + addq %rbx, %r10 + cmpq %rbx, %r10 + setb %dil + lea (%r10,%rax), %rbx + cmpq %rax, %rbx + movq -16(%rsp), %rax + setb %r11b + addl %r11d, %edi + je ..B6.21 +..B6.23: + movq %rbx, %rdi + movl $1, %r11d + shrq $1, %rsi + shlq $63, %rdi + shrq $1, %rbx + orq %rdi, %rsi + incl -48(%rsp) + btsq $63, %rbx + testq %rax, %rax + js ..B6.30 +..B6.39: + movq %rcx, -72(%rsp) +..B6.26: + movl %r11d, %ecx + decq %rax + movq (%rdx), %r15 + shrq %cl, %r15 + movq %r11, %rcx + negq %rcx + movq 8(%rdx), %r12 + movq %r12, %r13 + movq -72(%rsp), %r10 + movq %r10, %r8 + shlq %cl, %r13 + addq $16, %rdx + movl %r11d, %ecx + orq %r13, %r15 + shrq %cl, %r12 + movq -24(%rsp), %rcx + movq %rcx, %r14 + movl %ebx, %r13d + imulq %r13, %r14 + imulq %r13, %r8 + movq -40(%rsp), %rdi + imulq %rbx, %rdi + shrq $32, %rbx + addq %rdi, %r15 + imulq %rbx, %rcx + imulq %rbx, %r10 + shrq $32, %r14 + addq %r8, %r14 + addq %r14, %rcx + cmpq %r14, %rcx + movl $0, %r14d + movq %rcx, %r8 + movl %r14d, %ecx + setb %cl + shrq $32, %r8 + shlq $32, %rcx + addq %rcx, %r8 + movq %rax, -16(%rsp) + addq %r10, %r8 + movl %esi, %eax + xorl %r10d, %r10d + cmpq %rdi, %r15 + movq %r9, %rdi + setb %r10b + addq %r8, %r15 + imulq %rax, %rdi + imulq %rbp, %rax + shrq $32, %rdi + shrq $32, %rsi + addq %rax, %rdi + movq %r9, %rax + imulq %rsi, %rax + imulq %rbp, %rsi + addq %rdi, %rax + cmpq %rdi, %rax + movl %r14d, %edi + movq %rax, %rcx + setb %dil + shrq $32, %rcx + shlq $32, %rdi + addq %rdi, %rcx + movq %r9, %rdi + imulq %r13, %rdi + imulq %rbp, %r13 + shrq $32, %rdi + addq %rsi, %rcx + addq %r13, %rdi + movq %r9, %r13 + imulq %rbx, %r13 + imulq %rbp, %rbx + xorl %esi, %esi + cmpq %r8, %r15 + setb %sil + xorl %r8d, %r8d + addq %rdi, %r13 + cmpq %rdi, %r13 + movq %r13, %rax + setb %r8b + shrq $32, %rax + addq %rsi, %r10 + shlq $32, %r8 + lea (%r15,%rcx), %rsi + addq %r8, %rax + xorl %r15d, %r15d + addq %rbx, %rax + xorl %ebx, %ebx + cmpq %rcx, %rsi + setb %bl + addq %r10, %rbx + addq %rbx, %r12 + cmpq %rbx, %r12 + setb %r15b + addq -64(%rsp), %r11 + lea (%r12,%rax), %rbx + cmpq %rax, %rbx + movq -16(%rsp), %rax + setb %r14b + addl %r14d, %r15d + je ..B6.28 +..B6.27: + movq %rbx, %rcx + incq %r11 + shrq $1, %rsi + shlq $63, %rcx + shrq $1, %rbx + orq %rcx, %rsi + incl -48(%rsp) + btsq $63, %rbx +..B6.28: + testq %r11, %r11 + je ..B6.21 +..B6.29: + testq %rax, %rax + jns ..B6.26 +..B6.30: + movl -48(%rsp), %edi + movq -56(%rsp), %r8 + jmp ..B6.19 +..B6.32: + movq -40(%rsp), %r10 + movq %r12, %rbx + movq -56(%rsp), %r8 + jmp ..B6.38 +..B6.33: + movq -32(%rsp), %rcx + movq %r10, %rbp + movl %ecx, %r15d + movl %r10d, %r9d + shrq $32, %rbp + shrq $32, %rcx + movq %r15, -24(%rsp) + movl %edi, -48(%rsp) + movq %r10, -40(%rsp) + movq %r8, -56(%rsp) + jmp ..B6.39 + .align 16,0x90 + .cfi_endproc + .type __eval_pos_poly,@function + .size __eval_pos_poly,.-__eval_pos_poly + .data +# -- End __eval_pos_poly + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x47b00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3ef00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x34700000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x3c300000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0x3fd00000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x00000000,0x43d00000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +__ux_one__: + .long 0 + .long 1 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .type __ux_one__,@object + .size __ux_one__,24 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/dpml_ux_sqrt.S b/external/sgx_libm/intel64/dpml_ux_sqrt.S new file mode 100644 index 0000000000..7ad9063da0 --- /dev/null +++ b/external/sgx_libm/intel64/dpml_ux_sqrt.S @@ -0,0 +1,686 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_sqrt.c" + .text +..TXTST0: +# -- Begin __dpml_ux_sqrt_evaluation__ + .text + .align 16,0x90 + .globl __dpml_ux_sqrt_evaluation__ +__dpml_ux_sqrt_evaluation__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B1.1: + .cfi_startproc +..___tag_value___dpml_ux_sqrt_evaluation__.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $104, %rsp + .cfi_def_cfa_offset 160 + movq %rdi, %rbx + movq %fs:40, %rax + lea (%rsp), %rdi + xorq %rsp, %rax + movq %rdx, %r12 + movq %rax, 88(%rdi) + movq %rsi, %rbp +..___tag_value___dpml_ux_sqrt_evaluation__.16: + call fegetenv@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.17: +..B1.2: + movq 8(%rbx), %r8 + movq %r8, %r10 + shrq $11, %r10 + movq $0x3fd0000000000000, %r9 + movl 4(%rbx), %eax + addq %r9, %r10 + movl %eax, %r9d + movq %r8, %r13 + andl $1, %r9d + movq %r8, %r15 + addl %r9d, %eax + pxor %xmm2, %xmm2 + shrq $56, %r8 + pxor %xmm4, %xmm4 + movq %r10, 80(%rsp) + pxor %xmm7, %xmm7 + movq __sqrt_t_table@GOTPCREL(%rip), %r10 + lea 40(%r9), %r14d + shll $7, %r9d + movl %r14d, %ecx + xorq %r9, %r8 + negl %ecx + shlq $4, %r8 + pxor %xmm6, %xmm6 + shlq %cl, %r13 + movl %r14d, %ecx + movsd 80(%rsp), %xmm1 + lea 56(%rsp), %rdx + movq 16(%rbx), %r11 + movaps %xmm1, %xmm0 + cvtss2sd 4(%r10,%r8), %xmm2 + cvtss2sd (%r10,%r8), %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm2 + mulsd %xmm0, %xmm4 + addsd 8(%r10,%r8), %xmm2 + shrq %cl, %r11 + movl %r14d, %ecx + shrq %cl, %r15 + orq %r11, %r13 + shrq $11, %r13 + lea 128+__sqrt_x_table(%rip), %r11 + cvtsi2sdq %r15, %xmm7 + cvtsi2sdq %r13, %xmm6 + addsd %xmm2, %xmm4 + mulsd (%r11), %xmm7 + lea 136+__sqrt_x_table(%rip), %r13 + lea 96+__sqrt_x_table(%rip), %r8 + movaps %xmm7, %xmm8 + lea 152+__sqrt_x_table(%rip), %r15 + lea 104+__sqrt_x_table(%rip), %r14 + lea 32(%rsp), %rdi + movsd .L_2il0floatpacket.21(%rip), %xmm12 + movq %rbx, %rsi + mulsd (%r13), %xmm6 + mulsd (%r8), %xmm4 + addsd %xmm6, %xmm8 + movaps %xmm8, %xmm3 + lea 144+__sqrt_x_table(%rip), %r8 + mulsd %xmm4, %xmm3 + cvtsd2ss %xmm4, %xmm4 + cvtsd2ss %xmm3, %xmm3 + cvtss2sd %xmm4, %xmm4 + cvtss2sd %xmm3, %xmm3 + mulsd %xmm4, %xmm7 + mulsd %xmm4, %xmm6 + subsd %xmm3, %xmm7 + movsd (%r15), %xmm10 + movaps %xmm4, %xmm9 + mulsd %xmm8, %xmm10 + movaps %xmm3, %xmm5 + addsd %xmm6, %xmm7 + mulsd %xmm4, %xmm9 + mulsd %xmm4, %xmm5 + mulsd %xmm4, %xmm7 + mulsd %xmm9, %xmm10 + movsd (%r14), %xmm11 + movsd (%r8), %xmm15 + lea 112+__sqrt_x_table(%rip), %r8 + sarl $1, %eax + subsd %xmm5, %xmm11 + subsd %xmm10, %xmm15 + subsd %xmm7, %xmm11 + mulsd %xmm4, %xmm15 + movsd (%r8), %xmm13 + lea 120+__sqrt_x_table(%rip), %r8 + mulsd %xmm4, %xmm13 + negl %eax + mulsd %xmm11, %xmm15 + comisd %xmm12, %xmm13 + mulsd (%r8), %xmm15 + movaps %xmm13, %xmm14 + cvttsd2si %xmm15, %r9 + subsd %xmm12, %xmm14 + jae ..L18 + movaps %xmm13, %xmm14 +..L18: + cvttsd2si %xmm14, %r10 + movq %r9, %r8 + incl %eax + shlq $39, %r10 + sarq $12, %r8 + sarq $11, %r9 + addq %r8, %r10 + andq $1, %r9 + movq $0x4000000000000000, %r8 + addq %r9, %r10 + andq %r10, %r8 + testq %r10, %r10 + movl $0, -24(%rdx) + movl %eax, -20(%rdx) + movq $0, -8(%rdx) + lea -1(,%r8,2), %r8 + cmovns %r8, %r10 + movq %r10, -16(%rdx) +..___tag_value___dpml_ux_sqrt_evaluation__.19: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.20: +..B1.3: + movq %r12, %rdx + lea 32(%rsp), %rdi + lea 56(%rsp), %rsi +..___tag_value___dpml_ux_sqrt_evaluation__.21: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.22: +..B1.4: + lea 160+__sqrt_x_table(%rip), %rdi + movq %r12, %rsi + movl $9, %edx + movq %r12, %rcx +..___tag_value___dpml_ux_sqrt_evaluation__.23: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.24: +..B1.5: + testq $1, %rbp + lea 32(%rsp), %rsi + movq %r12, %rdi + lea 56(%rsp), %rax + cmovne %rax, %rsi + movq %r12, %rdx +..___tag_value___dpml_ux_sqrt_evaluation__.25: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.26: +..B1.6: + decl 4(%r12) + lea (%rsp), %rdi +..___tag_value___dpml_ux_sqrt_evaluation__.27: + call fesetenv@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.28: +..B1.7: + xorl %r15d, %r15d + testq $2, %rbp + jne ..B1.11 +..B1.8: + movq 88(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B1.10 +..B1.9: + movq %r15, %rax + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.10: + call __stack_chk_fail@PLT +..B1.11: + movq %r12, %rdi + xorl %esi, %esi +..___tag_value___dpml_ux_sqrt_evaluation__.49: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.50: +..B1.12: + movq 16(%r12), %r14 + lea 8(%r14), %r8 + testq $16368, %r8 + jne ..B1.8 +..B1.13: + andq $-32768, %r14 + movq %r12, %rdi + movq %r12, %rsi + lea 56(%rsp), %rdx + lea 32(%rsp), %rcx + lea 16384(%r14), %r13 + movq %r13, 16(%r12) +..___tag_value___dpml_ux_sqrt_evaluation__.51: + call __dpml_extended_multiply__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.52: +..B1.14: + movq %rbx, %rdi + lea 56(%rsp), %rsi + movl $1, %edx + movq %rsi, %rcx +..___tag_value___dpml_ux_sqrt_evaluation__.53: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.54: +..B1.15: + movl $1, %edx + lea 56(%rsp), %rdi + movq %rdi, %rcx + lea 32(%rsp), %rsi +..___tag_value___dpml_ux_sqrt_evaluation__.55: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.56: +..B1.16: + movl 56(%rsp), %r8d + testl %r8d, %r8d + cmove %r13, %r14 + testq $4, %rbp + movq %r14, 16(%r12) + je ..B1.8 +..B1.17: + movl 4(%r12), %ebx + xorl %edx, %edx + addl $-113, %ebx + lea 56(%rsp), %rdi + subl %ebx, 4(%rdi) + movl $1, %ebx + testl %r8d, %r8d + movq %r12, %rsi + cmove %ebx, %edx + movq %rdi, %rcx + orl $8, %edx +..___tag_value___dpml_ux_sqrt_evaluation__.57: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_sqrt_evaluation__.58: +..B1.18: + xorl %r15d, %r15d + cmpq $8192, 72(%rsp) + cmove %ebx, %r15d + jmp ..B1.8 + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_sqrt_evaluation__,@function + .size __dpml_ux_sqrt_evaluation__,.-__dpml_ux_sqrt_evaluation__ + .data +# -- End __dpml_ux_sqrt_evaluation__ + .text +# -- Begin __sqrtq + .text + .align 16,0x90 + .globl __sqrtq +__sqrtq: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value___sqrtq.60: +..L61: + + subq $136, %rsp + .cfi_def_cfa_offset 144 + xorl %esi, %esi + lea __sqrt_x_table(%rip), %rcx + lea 48(%rsp), %rdi + movq %fs:40, %rax + lea 88(%rsp), %rdx + xorq %rsp, %rax + lea 112(%rsp), %r8 + movaps %xmm0, -40(%rdx) + lea (%rsp), %r9 + movq %rax, 40(%rdx) + movq $1, -80(%rdx) + movq $0, (%r9) +..___tag_value___sqrtq.63: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___sqrtq.64: +..B2.2: + testq %rax, %rax + jl ..B2.5 +..B2.3: + movl $7, %esi + lea 88(%rsp), %rdi + lea 64(%rsp), %rdx +..___tag_value___sqrtq.65: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___sqrtq.66: +..B2.4: + movl $1, %edx + xorl %ecx, %ecx + testq %rax, %rax + lea 64(%rsp), %rdi + cmove %edx, %ecx + xorl %edx, %edx + lea 112(%rsp), %rsi + movq %rcx, -104(%rsi) + xorl %ecx, %ecx + lea (%rsp), %r8 +..___tag_value___sqrtq.67: + call __dpml_pack__@PLT +..___tag_value___sqrtq.68: +..B2.5: + movq 128(%rsp), %rax + xorq %rsp, %rax + movaps 112(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.7 +..B2.6: + addq $136, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 +..B2.7: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __sqrtq,@function + .size __sqrtq,.-__sqrtq + .data +# -- End __sqrtq + .text +# -- Begin __rsqrtq + .text + .align 16,0x90 + .globl __rsqrtq +__rsqrtq: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___rsqrtq.72: +..L73: + + subq $136, %rsp + .cfi_def_cfa_offset 144 + xorl %esi, %esi + lea 8+__sqrt_x_table(%rip), %rcx + lea 48(%rsp), %rdi + movq %fs:40, %rax + lea 88(%rsp), %rdx + xorq %rsp, %rax + lea 112(%rsp), %r8 + movaps %xmm0, -40(%rdx) + lea (%rsp), %r9 + movq %rax, 40(%rdx) + movq $1, -80(%rdx) + movq $0, (%r9) +..___tag_value___rsqrtq.75: + call __dpml_unpack_x_or_y__@PLT +..___tag_value___rsqrtq.76: +..B3.2: + testq %rax, %rax + jl ..B3.5 +..B3.3: + xorl %esi, %esi + lea 88(%rsp), %rdi + lea 64(%rsp), %rdx +..___tag_value___rsqrtq.77: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___rsqrtq.78: +..B3.4: + movl $1, %edx + xorl %ecx, %ecx + testq %rax, %rax + lea 64(%rsp), %rdi + cmove %edx, %ecx + xorl %edx, %edx + lea 112(%rsp), %rsi + movq %rcx, -104(%rsi) + xorl %ecx, %ecx + lea (%rsp), %r8 +..___tag_value___rsqrtq.79: + call __dpml_pack__@PLT +..___tag_value___rsqrtq.80: +..B3.5: + movq 128(%rsp), %rax + xorq %rsp, %rax + movaps 112(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B3.7 +..B3.6: + addq $136, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 +..B3.7: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __rsqrtq,@function + .size __rsqrtq,.-__rsqrtq + .data +# -- End __rsqrtq + .text +# -- Begin __dpml_ux_hypot__ + .text + .align 16,0x90 + .globl __dpml_ux_hypot__ +__dpml_ux_hypot__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B4.1: + .cfi_startproc +..___tag_value___dpml_ux_hypot__.84: +..L85: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + subq $88, %rsp + .cfi_def_cfa_offset 112 + movq %rdx, %r12 + movq %rsi, %rbp + movq %rdi, %rsi + movq %fs:40, %rax + lea (%rsp), %rdx + xorq %rsp, %rax + movq %rax, 72(%rdx) +..___tag_value___dpml_ux_hypot__.91: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_hypot__.92: +..B4.2: + movq %rbp, %rdi + movq %rbp, %rsi + lea 24(%rsp), %rdx +..___tag_value___dpml_ux_hypot__.93: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_hypot__.94: +..B4.3: + xorl %edx, %edx + lea (%rsp), %rdi + lea 24(%rsp), %rsi + lea 48(%rsp), %rcx +..___tag_value___dpml_ux_hypot__.95: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_hypot__.96: +..B4.4: + xorl %esi, %esi + lea 48(%rsp), %rdi +..___tag_value___dpml_ux_hypot__.97: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_hypot__.98: +..B4.5: + movl $7, %esi + lea 48(%rsp), %rdi + movq %r12, %rdx +..___tag_value___dpml_ux_hypot__.99: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___dpml_ux_hypot__.100: +..B4.6: + testq %rax, %rax + je ..B4.18 +..B4.7: + movl 4(%rsp), %ecx + lea (%rsp), %rbp + subl 28(%rbp), %ecx + movslq %ecx, %rcx + testq %rcx, %rcx + jns ..B4.9 +..B4.8: + negq %rcx + lea 24(%rsp), %rbp +..B4.9: + cmpq $128, %rcx + jle ..B4.11 +..B4.10: + xorl %eax, %eax + jmp ..B4.18 +..B4.11: + movl $1, %edx +..B4.12: + movq 8(%rbp,%rdx,8), %rax + testq %rax, %rax + jne ..B4.10 +..B4.13: + cmpq $64, %rcx + jl ..B4.16 +..B4.14: + addq $-64, %rcx + decq %rdx + jns ..B4.12 +..B4.16: + movq %rax, %rdx + movl $1, %ebp + shrq %cl, %rdx + xorl %esi, %esi + shlq %cl, %rdx + cmpq %rdx, %rax + cmove %ebp, %esi + movl %esi, %eax +..B4.18: + movq 72(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B4.20 +..B4.19: + addq $88, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 + .cfi_offset 6, -24 + .cfi_offset 12, -16 +..B4.20: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_hypot__,@function + .size __dpml_ux_hypot__,.-__dpml_ux_hypot__ + .data +# -- End __dpml_ux_hypot__ + .section .rodata, "a" + .align 16 + .align 16 +__sqrt_x_table: + .long 1088750600 + .long 605086734 + .long 1088766984 + .long 519758862 + .long 112 + .long 0 + .long 113 + .long 0 + .long 114 + .long 0 + .long 0 + .long 0 + .long 0 + .long 268435456 + .long 858997845 + .long 34 + .long 1636176969 + .long 409044504 + .long 1099306057 + .long 404751376 + .long 545392672 + .long 404783624 + .long 142938632 + .long 302522498 + .long 1719614413 + .long 1073127582 + .long 0 + .long 1072693248 + .long 0 + .long 1097859072 + .long 0 + .long 1151336448 + .long 0 + .long 1047527424 + .long 0 + .long 991952896 + .long 0 + .long 1072431104 + .long 0 + .long 1071120384 + .long 0 + .long 2 + .long 0 + .long 3221225472 + .long 0 + .long 0 + .long 0 + .long 0 + .type __sqrt_x_table,@object + .size __sqrt_x_table,192 + .align 8 +.L_2il0floatpacket.21: + .long 0x00000000,0x43e00000 + .type .L_2il0floatpacket.21,@object + .size .L_2il0floatpacket.21,8 + .align 4 +.L_2il0floatpacket.20: + .long 0x5f000000 + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/dpml_ux_trig.S b/external/sgx_libm/intel64/dpml_ux_trig.S new file mode 100644 index 0000000000..6871597d29 --- /dev/null +++ b/external/sgx_libm/intel64/dpml_ux_trig.S @@ -0,0 +1,2192 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "dpml_ux_trig.c" + .text +..TXTST0: +# -- Begin __dpml_ux_radian_reduce__ + .text + .align 16,0x90 +__dpml_ux_radian_reduce__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B1.1: + .cfi_startproc +..___tag_value___dpml_ux_radian_reduce__.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $120, %rsp + .cfi_def_cfa_offset 176 + movq 8(%rdi), %rax + movq 16(%rdi), %rcx + movl (%rdi), %r8d + movq %rdx, 48(%rsp) + movq %rsi, %rdx + movslq 4(%rdi), %rsi + testq %rsi, %rsi + movq %rax, 80(%rsp) + movq %rcx, 104(%rsp) + movl %r8d, 40(%rsp) + jl ..B1.21 +..B1.2: + addq $8, %rsi + movq %rsi, %rbx + sarq $6, %rbx + movq __four_over_pi@GOTPCREL(%rip), %rax + movq %rbx, 56(%rsp) + lea (%rax,%rbx,8), %rbp + movq 32(%rbp), %rcx + movq (%rbp), %rbx + movq 8(%rbp), %r11 + movq 16(%rbp), %rdi + movq 24(%rbp), %rax + addq $40, %rbp + movq %rcx, 8(%rsp) + andq $63, %rsi + movq %rbp, (%rsp) + je ..B1.4 +..B1.3: + movq %rsi, %rbp + movl %esi, %ecx + negq %rbp + movq %r11, %r8 + movq %rbp, 56(%rsp) + movq %rdi, %r9 + shlq %cl, %rbx + movl %ebp, %ecx + shrq %cl, %r8 + movl %esi, %ecx + shlq %cl, %r11 + movl %ebp, %ecx + shrq %cl, %r9 + movl %esi, %ecx + shlq %cl, %rdi + movl %ebp, %ecx + movq %rax, %r10 + orq %r8, %rbx + shrq %cl, %r10 + movl %esi, %ecx + shlq %cl, %rax + movl %ebp, %ecx + movq 8(%rsp), %r12 + orq %r9, %r11 + shrq %cl, %r12 + orq %r10, %rdi + orq %r12, %rax +..B1.4: + movq %rdx, 32(%rsp) + xorl %r13d, %r13d + movl %eax, %edx + movq 104(%rsp), %r10 + movq %r10, %r8 + movl %r10d, %ebp + movq %rdx, %r15 + movq %rbx, 24(%rsp) + movq %rax, %rbx + shrq $32, %r8 + movq %rdx, %r12 + imulq %rbp, %r15 + imulq %r8, %r12 + shrq $32, %rbx + movq %rbp, %r9 + imulq %rbx, %r9 + movq %rsi, 112(%rsp) + movq %r10, %rsi + imulq %rax, %rsi + shrq $32, %r15 + movq %r8, %r14 + addq %r12, %r15 + addq %r15, %r9 + cmpq %r15, %r9 + movq %r9, %r12 + movq 80(%rsp), %r9 + setb %r13b + shrq $32, %r12 + shlq $32, %r13 + movq %rsi, 16(%rsp) + addq %r13, %r12 + movl %r9d, %ecx + movq %r9, %rsi + movq %rdx, %r13 + movq %rcx, %r15 + shrq $32, %rsi + imulq %rcx, %r13 + imulq %rsi, %rdx + imulq %rbx, %r15 + imulq %rbx, %r14 + imulq %r9, %rax + imulq %rsi, %rbx + shrq $32, %r13 + addq %r14, %r12 + addq %rdx, %r13 + addq %rax, %r12 + addq %r13, %r15 + cmpq %r13, %r15 + movq %r15, %rdx + movl $0, %r15d + setb %r15b + cmpq %rax, %r12 + movl $0, %eax + setb %al + shrq $32, %rdx + shlq $32, %r15 + addq %r15, %rdx + movq %r10, %r15 + addq %rbx, %rdx + addq %rax, %rdx + movq %rdi, %rbx + movl %edi, %eax + movq %rax, %r14 + movq %rax, %r13 + imulq %rbp, %r14 + imulq %r8, %r13 + imulq %rdi, %r15 + imulq %r9, %rdi + shrq $32, %rbx + addq %r15, %r12 + movq %rbp, 88(%rsp) + imulq %rbx, %rbp + shrq $32, %r14 + addq %r13, %r14 + addq %r14, %rbp + cmpq %r14, %rbp + movl $0, %r14d + movq %rbp, %r13 + movq %r8, %rbp + setb %r14b + cmpq %r15, %r12 + movl $0, %r15d + movq %rcx, 64(%rsp) + setb %r15b + imulq %rbx, %rbp + shrq $32, %r13 + shlq $32, %r14 + addq %r14, %r13 + movq %rax, %r14 + imulq %rcx, %r14 + imulq %rsi, %rax + imulq %rbx, %rcx + imulq %rsi, %rbx + addq %rbp, %r13 + addq %r15, %rdx + xorl %ebp, %ebp + cmpq %r15, %rdx + movq %rsi, 72(%rsp) + setb %bpl + xorl %esi, %esi + addq %r13, %rdx + cmpq %r13, %rdx + movl $0, %r13d + setb %r13b + addq %rdi, %rdx + shrq $32, %r14 + addq %rax, %r14 + addq %r14, %rcx + addq %r13, %rbp + xorl %r13d, %r13d + cmpq %r14, %rcx + movq %rcx, %r15 + setb %r13b + cmpq %rdi, %rdx + movl $0, %edi + setb %dil + movq %r10, %r14 + shrq $32, %r15 + shlq $32, %r13 + addq %r13, %r15 + movq %r11, %r13 + addq %rbx, %r15 + addq %rdi, %r15 + addq %rbp, %r15 + movl %r11d, %ebp + movq %rbp, %rbx + movq 88(%rsp), %rax + imulq %rax, %rbx + imulq %r8, %rbp + imulq %r11, %r14 + imulq %r9, %r11 + shrq $32, %r13 + addq %r14, %rdx + imulq %r13, %rax + imulq %r8, %r13 + shrq $32, %rbx + addq %r15, %r11 + addq %rbp, %rbx + xorl %ebp, %ebp + addq %rbx, %rax + cmpq %rbx, %rax + movq %rax, %rdi + movq 32(%rsp), %rbx + movq %rbx, %rcx + setb %sil + cmpq %r14, %rdx + setb %bpl + negq %rcx + shrq $32, %rdi + shlq $32, %rsi + addq %rsi, %rdi + addq %r13, %rdi + addq %rdi, %rbp + addq %r11, %rbp + movq 24(%rsp), %r11 + imulq %r10, %r11 + cmpl $0, 40(%rsp) + movq %r8, 96(%rsp) + cmovne %rcx, %rbx + addq %r11, %rbp + shlq $61, %rbx + addq %rbx, %rbp + movq 16(%rsp), %r8 + xorl %ebx, %ebx + movq (%rsp), %r10 + movq 8(%rsp), %r11 + jmp ..B1.5 +..B1.9: + movq $0xe000000000000000, %rsi + addq $64, %rbx + andq %rbp, %rsi + movq $0x1fffffffffffffff, %rbp + andq %rdx, %rbp + movq %r12, %rdx + orq %rsi, %rbp + movq %r8, %r12 + movq %rcx, %r8 +..B1.5: + movq $0x40000000000000, %rcx + movq $0x3f80000000000000, %rdi + lea (%rcx,%rbp), %rsi + testq %rdi, %rsi + jne ..B1.10 +..B1.6: + movq %r11, %r9 + movq 112(%rsp), %rsi + movl %esi, %ecx + movq %r9, %r14 + movq (%r10), %r11 + movq %r11, %rdi + shlq %cl, %r14 + addq $8, %r10 + movq 56(%rsp), %rcx + movq 88(%rsp), %rax + movq %rax, %r15 + shrq %cl, %rdi + orq %rdi, %r14 + testq %rsi, %rsi + movq 96(%rsp), %r13 + cmovne %r14, %r9 + movq %r13, %r14 + movl %r9d, %esi + movq %r9, %rdi + imulq %rsi, %r15 + imulq %rsi, %r14 + shrq $32, %rdi + imulq %rdi, %rax + imulq %rdi, %r13 + shrq $32, %r15 + addq %r14, %r15 + addq %r15, %rax + cmpq %r15, %rax + movl $0, %r15d + movq %rax, %r14 + setb %r15b + shrq $32, %r14 + shlq $32, %r15 + addq %r15, %r14 + addq %r13, %r14 + movq 64(%rsp), %r13 + movq %r13, %rax + imulq %rsi, %rax + movq 72(%rsp), %r15 + addq %r14, %r8 + imulq %r15, %rsi + shrq $32, %rax + cmpq %r14, %r8 + movq 104(%rsp), %rcx + movl $0, %r14d + setb %r14b + addq %rsi, %rax + movq %r13, %rsi + imulq %rdi, %rsi + imulq %r9, %rcx + imulq 80(%rsp), %r9 + imulq %r15, %rdi + addq %rax, %rsi + addq %r14, %r12 + movq %rsi, %r13 + cmpq %r14, %r12 + movl $0, %r14d + setb %r14b + cmpq %rax, %rsi + movl $0, %esi + setb %sil + addq %r9, %r8 + cmpq %r9, %r8 + movl $0, %r9d + setb %r9b + shrq $32, %r13 + shlq $32, %rsi + addq %rsi, %r13 + addq %r9, %r12 + addq %rdi, %r13 + xorl %esi, %esi + cmpq %r9, %r12 + setb %sil + addq %r13, %r12 + cmpq %r13, %r12 + movl $0, %r13d + setb %r13b + addl %r14d, %esi + addl %r13d, %esi + je ..B1.8 +..B1.7: + incq %rdx + lea 1(%rbp), %rsi + cmove %rsi, %rbp +..B1.8: + movq %rdx, %r9 + movq %rbp, %rsi + shrq $55, %r9 + shlq $9, %rsi + orq %rsi, %r9 + movq %r9, %rdi + sarq $63, %rdi + cmpq %r9, %rdi + je ..B1.9 +..B1.10: + movq %r8, 16(%rsp) +..B1.11: + lea (,%rbp,4), %rcx + sarq $2, %rcx + movq %rcx, %rsi + subq %rcx, %rbp + sarq $63, %rsi + movq %rcx, %rdi + cmpq %rsi, %rcx + jne ..B1.13 +..B1.12: + movq %rdx, %rcx + movq %r12, %rdx + movq %r8, %r12 + addq $64, %rbx +..B1.13: + movl $-2147483648, %r10d + xorl %esi, %esi + testq %rdi, %rdi + cmovge %esi, %r10d + testl %r10d, %r10d + je ..B1.15 +..B1.14: + notq %r12 + movl $1, %edi + incq %r12 + notq %rdx + cmove %edi, %esi + xorl %r8d, %r8d + notq %rcx + addq %rsi, %rdx + cmove %edi, %r8d + addq %r8, %rcx +..B1.15: + movq %rbp, %r8 + xorl %esi, %esi + movq 48(%rsp), %rdi + negq %r8 + movl 40(%rsp), %r9d + testl %r9d, %r9d + movl $3, 4(%rdi) + cmovne %r8, %rbp + xorl %r9d, %r10d + movl %r10d, (%rdi) + movq %rcx, 8(%rdi) + movq %rdx, 16(%rdi) +..___tag_value___dpml_ux_radian_reduce__.16: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_radian_reduce__.17: +..B1.16: + movq 48(%rsp), %rdx + movslq 4(%rdx), %rsi + movq %rsi, %rcx + addq $-3, %rcx + je ..B1.18 +..B1.17: + shrq %cl, %r12 + orq %r12, 16(%rdx) +..B1.18: + movq %rdx, %rdi + subq %rbx, %rsi + movq %rdi, %rdx + movl %esi, 4(%rdi) + lea 1008+__trig_x_table(%rip), %rsi +..___tag_value___dpml_ux_radian_reduce__.18: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_radian_reduce__.19: +..B1.19: + shrq $62, %rbp + movq %rbp, %rax + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.21: + movl %r8d, %ecx + sarl $31, %ecx + movslq %ecx, %rcx + addq %rdx, %rcx + movq %rcx, %rbx + andq $1, %rbx + addq %rbx, %rcx + movq %rcx, %rbx + sarq $1, %rbx + subq %rcx, %rdx + je ..B1.23 +..B1.22: + shrq $63, %rdx + lea 1008+__trig_x_table(%rip), %rsi + movq 48(%rsp), %rcx +..___tag_value___dpml_ux_radian_reduce__.40: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_radian_reduce__.41: + jmp ..B1.24 +..B1.23: + movq 48(%rsp), %rcx + movl %r8d, %edx + movl %esi, 4(%rcx) + movq %rax, %rsi + movq %rsi, 8(%rcx) + movq 16(%rdi), %rdi + movl %edx, (%rcx) + movq %rdi, 16(%rcx) +..B1.24: + movq %rbx, %rax + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_radian_reduce__,@function + .size __dpml_ux_radian_reduce__,.-__dpml_ux_radian_reduce__ + .data +# -- End __dpml_ux_radian_reduce__ + .text +# -- Begin __dpml_ux_degree_reduce__ + .text + .align 16,0x90 +__dpml_ux_degree_reduce__: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B2.1: + .cfi_startproc +..___tag_value___dpml_ux_degree_reduce__.56: +..L57: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $48, %rsp + .cfi_def_cfa_offset 96 + movq %rdi, %rbp + movq %rdx, %r13 + movq %rsi, %rbx + movl 4(%rbp), %r14d + cmpl $142, %r14d + movl (%rbp), %r15d + jle ..B2.3 +..B2.2: + lea 264+__trig_x_table(%rip), %rax + movslq %r14d, %r8 + addq $32641, %r8 + movl %r8d, %ecx + movq (%rax), %r9 + movq %rcx, %r10 + movl %r9d, %esi + shrq $32, %r9 + imulq %rsi, %r10 + imulq %r9, %rcx + shrq $32, %r8 + imulq %r8, %rsi + imulq %r8, %r9 + shrq $32, %r10 + addq %rcx, %r10 + addq %rsi, %r10 + shrq $32, %r10 + addq %r9, %r10 + lea (,%r10,8), %r11d + lea (%r11,%r10,4), %eax + negl %eax + lea 32772(%r14,%rax), %r14d + movl %r14d, 4(%rbp) +..B2.3: + cmpl $16, %r14d + jl ..B2.25 +..B2.4: + movslq %r14d, %r14 + xorl %r8d, %r8d + lea -15(%r14), %rsi + movq %rsi, %rcx + andq $63, %rcx + sarq $6, %rsi + subq %rcx, %r14 + testq %rcx, %rcx + je ..B2.6 +..B2.5: + movq 16(%rbp), %rax + movq %rax, %r8 + movq %rcx, %r9 + shlq %cl, %r8 + negq %r9 + movq %r8, 16(%rbp) + movq 8(%rbp), %r8 + movq %r8, %r10 + shlq %cl, %r10 + movl %r9d, %ecx + shrq %cl, %rax + movl %r9d, %ecx + orq %rax, %r10 + movq %r10, 8(%rbp) + shrq %cl, %r8 +..B2.6: + movq %r8, (%rbp) + lea (%rbp,%rsi,8), %rdi + movq 8(%rdi), %rcx + movq %rcx, %r9 + shrq $52, %r9 + xorl %r11d, %r11d + testq %rsi, %rsi + jl ..B2.19 +..B2.7: + xorl %eax, %eax + lea 1(%rsi), %rdx + movq %rdx, %rcx + movl $1, %r8d + shrq $63, %rcx + xorl %r10d, %r10d + lea 1(%rsi,%rcx), %rcx + sarq $1, %rcx + testq %rcx, %rcx + jbe ..B2.15 +..B2.8: + movq (%rbp,%rsi,8), %r8 + movq %r8, (%rsp) + movq $0xfffffffffffffff, %r8 + movq $0, 8(%rsp) + movl %r15d, 32(%rsp) + movq %r13, 16(%rsp) + movq %rbp, 24(%rsp) + movq %rcx, %rbp + movq %r12, 40(%rsp) + .cfi_offset 12, -56 + movq (%rsp), %r15 + movq 8(%rsp), %r13 +..B2.9: + movq %r8, %r12 + andq %r15, %r12 + shrq $60, %r15 + addq %r15, %r12 + addq %r9, %r12 + movq $0, (%rdi,%r13) + addq $4, %r11 + movq -8(%rdi,%r13), %r15 + je ..B2.11 +..B2.10: + movl %r11d, %ecx + movq %r15, %r9 + negq %r11 + addq $12, %r11 + shlq %cl, %r9 + movl %r11d, %ecx + andq $4095, %r9 + negq %r11 + shrq %cl, %r15 + addq %r9, %r12 +..B2.11: + movq %r8, %r9 + incq %rax + andq %r15, %r9 + addq $4, %r11 + shrq $60, %r15 + addq $-16, %r10 + addq %r15, %r9 + addq %r12, %r9 + movq $0, -8(%rdi,%r13) + cmpq %rbp, %rax + jae ..B2.14 +..B2.12: + movq (%r10,%rdi), %r15 + movq %r10, %r13 + testq %r11, %r11 + je ..B2.9 +..B2.13: + movl %r11d, %ecx + movq %r15, %r12 + negq %r11 + addq $12, %r11 + shlq %cl, %r12 + movl %r11d, %ecx + andq $4095, %r12 + negq %r11 + shrq %cl, %r15 + addq %r12, %r9 + jmp ..B2.9 +..B2.14: + movl 32(%rsp), %r15d + lea 1(,%rax,2), %r8 + movq 24(%rsp), %rbp + movq 16(%rsp), %r13 + movq 40(%rsp), %r12 + .cfi_restore 12 +..B2.15: + lea -1(%r8), %rax + cmpq %rax, %rdx + jbe ..B2.45 +..B2.16: + subq %r8, %rsi + testq %r11, %r11 + movq 8(%rbp,%rsi,8), %rax + je ..B2.18 +..B2.17: + movl %r11d, %ecx + movq %rax, %r8 + negq %r11 + addq $12, %r11 + shlq %cl, %r8 + movl %r11d, %ecx + andq $4095, %r8 + shrq %cl, %rax + addq %r8, %r9 +..B2.18: + movq $0xfffffffffffffff, %rcx + andq %rax, %rcx + shrq $60, %rax + movq $0, 8(%rbp,%rsi,8) + addq %rax, %rcx + addq %rcx, %r9 + movq 8(%rdi), %rcx +..B2.19: + movq %r9, %rax + shrq $12, %rax + testq %rax, %rax + je ..B2.23 +..B2.21: + andq $4095, %r9 + addq %rax, %r9 + movq %r9, %rax + shrq $12, %rax + testq %rax, %rax + jne ..B2.21 +..B2.23: + movq $0xfffffffffffff, %rax + xorl %esi, %esi + shlq $52, %r9 + andq %rcx, %rax + orq %r9, %rax + movq %rax, 8(%rdi) + movq %rbp, %rdi + movl %r14d, 4(%rbp) +..___tag_value___dpml_ux_degree_reduce__.71: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_degree_reduce__.72: +..B2.24: + subq %rax, %r14 +..B2.25: + movslq %r14d, %r14 + movl $0, (%rbp) + addq $-5, %r14 + movq 8(%rbp), %r8 + jle ..B2.27 +..B2.26: + lea 256+__trig_x_table(%rip), %rsi + movq %r8, %rax + movl %r8d, %ecx + xorl %r11d, %r11d + movq %rcx, %r10 + shrq $32, %rax + movq (%rsi), %rdx + movl %edx, %r9d + shrq $32, %rdx + imulq %r9, %r10 + imulq %rdx, %rcx + imulq %rax, %r9 + imulq %rax, %rdx + shrq $32, %r10 + addq %rcx, %r10 + addq %r10, %r9 + cmpq %r10, %r9 + movq %r9, %rsi + setb %r11b + shrq $32, %rsi + shlq $32, %r11 + addq %r11, %rsi + addq %rdx, %rsi + jmp ..B2.28 +..B2.27: + movl $1, %r14d + xorl %esi, %esi +..B2.28: + negq %r14 + movq %rbx, %rax + andq $1, %rax + incq %rax + shrq $1, %rbx + lea 63(%r14), %rcx + shlq %cl, %rax + addq %rsi, %rax + movl %r14d, %ecx + movl $1, %esi + shlq %cl, %rsi + movl %r14d, %ecx + decq %rsi + notq %rsi + andq %rsi, %rax + movq %r8, %rsi + movq %rax, %r10 + andq $3, %r8 + shrq %cl, %r10 + movq $0x0b4000000, %rcx + movl %eax, %r11d + movq %r10, %r9 + imulq %rcx, %r11 + shrq $32, %rax + negq %r9 + imulq %rax, %rcx + shrq $2, %rsi + testl %r15d, %r15d + cmovne %r9, %r10 + shrq $32, %r11 + addq %r10, %rbx + subq %r11, %rsi + subq %rcx, %rsi + lea (,%rsi,4), %rax + orq %rax, %r8 + testq %rsi, %rsi + jns ..B2.30 +..B2.29: + movq 16(%rbp), %rax + movl $1, %ecx + xorl %esi, %esi + testq %rax, %rax + cmovne %ecx, %esi + movq %rax, %r9 + movslq %r15d, %r15 + negq %r9 + btcq $31, %r15 + addq %rsi, %r8 + movq %r9, 16(%rbp) + negq %r8 +..B2.30: + movq %rbp, %rdi + xorl %esi, %esi + movq %r8, 8(%rbp) +..___tag_value___dpml_ux_degree_reduce__.73: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_degree_reduce__.74: +..B2.31: + shlq $3, %rbx + movq 8(%rbp), %rsi + shrl $3, %ebx + movl 4(%rbp), %ecx + testq %rsi, %rsi + jne ..B2.34 +..B2.32: + movq $0x2000000000000000, %rcx + orq %rcx, %rbx + testq $2, %rbx + je ..B2.43 +..B2.33: + movslq (%rbp), %rcx + btcq $31, %rcx + movl %ecx, (%rbp) + jmp ..B2.43 +..B2.34: + cmpl $5, %ecx + jl ..B2.42 +..B2.35: + cmpq $0, 16(%rbp) + jne ..B2.42 +..B2.36: + negl %ecx + movq %rsi, %r9 + shrq %cl, %r9 + movq %r9, %r8 + shlq %cl, %r8 + cmpq %r8, %rsi + jne ..B2.42 +..B2.37: + cmpq $30, %r9 + jne ..B2.41 +..B2.38: + testq $1, %rbx + jne ..B2.42 +..B2.39: + movq $0x4000000000000000, %rcx + xorl %r15d, (%rbp) + orq %rcx, %rbx + jmp ..B2.43 +..B2.41: + movq $0x8000000000000000, %rcx + orq %rbx, %rcx + cmpq $45, %r9 + cmove %rcx, %rbx +..B2.42: + xorl %r15d, (%rbp) +..B2.43: + movq %rbp, %rdi + lea 216+__trig_x_table(%rip), %rsi + movq %r13, %rdx +..___tag_value___dpml_ux_degree_reduce__.75: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_degree_reduce__.76: +..B2.44: + movq %rbx, %rax + addq $48, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B2.45: + movq 8(%rdi), %rcx + jmp ..B2.19 + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_degree_reduce__,@function + .size __dpml_ux_degree_reduce__,.-__dpml_ux_degree_reduce__ + .data +# -- End __dpml_ux_degree_reduce__ + .text +# -- Begin __dpml_ux_sincos + .text + .align 16,0x90 + .globl __dpml_ux_sincos +__dpml_ux_sincos: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B3.1: + .cfi_startproc +..___tag_value___dpml_ux_sincos.95: +..L96: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $136, %rsp + .cfi_def_cfa_offset 192 + movq %rdx, %r15 + testq $16, %r15 + lea __dpml_ux_degree_reduce__(%rip), %r10 + lea __dpml_ux_radian_reduce__(%rip), %r9 + movq %rcx, %r12 + cmovne %r10, %r9 + movq %rsi, %rbp + movq %fs:40, %rax + movq %rdi, %r13 + xorq %rsp, %rax + movq %rax, 128(%rsp) + cmpq %r10, %r9 + jne ..B3.54 +..B3.2: + movl 4(%r13), %ebx + cmpl $142, %ebx + movl (%r13), %r14d + jle ..B3.4 +..B3.3: + lea 264+__trig_x_table(%rip), %rax + movslq %ebx, %r9 + addq $32641, %r9 + movl %r9d, %ecx + movq (%rax), %r10 + movq %rcx, %r11 + movl %r10d, %esi + shrq $32, %r10 + imulq %rsi, %r11 + imulq %r10, %rcx + shrq $32, %r9 + imulq %r9, %rsi + imulq %r9, %r10 + shrq $32, %r11 + addq %rcx, %r11 + addq %rsi, %r11 + shrq $32, %r11 + addq %r10, %r11 + lea (,%r11,8), %eax + lea (%rax,%r11,4), %eax + negl %eax + lea 32772(%rbx,%rax), %ebx + movl %ebx, 4(%r13) +..B3.4: + cmpl $16, %ebx + jl ..B3.26 +..B3.5: + movslq %ebx, %rbx + xorl %r9d, %r9d + lea -15(%rbx), %rax + movq %rax, %rcx + andq $63, %rcx + sarq $6, %rax + subq %rcx, %rbx + testq %rcx, %rcx + je ..B3.7 +..B3.6: + movq 16(%r13), %rsi + movq %rsi, %r9 + movq %rcx, %r10 + shlq %cl, %r9 + negq %r10 + movq %r9, 16(%r13) + movq 8(%r13), %r9 + movq %r9, %r11 + shlq %cl, %r11 + movl %r10d, %ecx + shrq %cl, %rsi + movl %r10d, %ecx + orq %rsi, %r11 + movq %r11, 8(%r13) + shrq %cl, %r9 +..B3.7: + movq %r9, (%r13) + lea (%r13,%rax,8), %r8 + movq 8(%r8), %rcx + movq %rcx, %rsi + shrq $52, %rsi + xorl %edx, %edx + testq %rax, %rax + jl ..B3.20 +..B3.8: + xorl %r10d, %r10d + lea 1(%rax), %rdi + movq %rdi, %rcx + movl $1, %r9d + shrq $63, %rcx + xorl %r11d, %r11d + lea 1(%rax,%rcx), %rcx + sarq $1, %rcx + testq %rcx, %rcx + jbe ..B3.16 +..B3.9: + movq (%r13,%rax,8), %r9 + movq %r9, (%rsp) + movq $0xfffffffffffffff, %r9 + movq $0, 8(%rsp) + movl %r14d, 24(%rsp) + movq %r13, 32(%rsp) + movq %rbx, 16(%rsp) + movq %rcx, %rbx + movq %r12, 40(%rsp) + movq (%rsp), %r14 + movq 8(%rsp), %r13 +..B3.10: + movq %r9, %r12 + andq %r14, %r12 + shrq $60, %r14 + addq %r14, %r12 + addq %rsi, %r12 + movq $0, (%r8,%r13) + addq $4, %rdx + movq -8(%r8,%r13), %r14 + je ..B3.12 +..B3.11: + movl %edx, %ecx + movq %r14, %rsi + negq %rdx + addq $12, %rdx + shlq %cl, %rsi + movl %edx, %ecx + andq $4095, %rsi + negq %rdx + shrq %cl, %r14 + addq %rsi, %r12 +..B3.12: + movq %r9, %rsi + incq %r10 + andq %r14, %rsi + addq $4, %rdx + shrq $60, %r14 + addq $-16, %r11 + addq %r14, %rsi + addq %r12, %rsi + movq $0, -8(%r8,%r13) + cmpq %rbx, %r10 + jae ..B3.15 +..B3.13: + movq (%r11,%r8), %r14 + movq %r11, %r13 + testq %rdx, %rdx + je ..B3.10 +..B3.14: + movl %edx, %ecx + movq %r14, %r12 + negq %rdx + addq $12, %rdx + shlq %cl, %r12 + movl %edx, %ecx + andq $4095, %r12 + negq %rdx + shrq %cl, %r14 + addq %r12, %rsi + jmp ..B3.10 +..B3.15: + movq 16(%rsp), %rbx + lea 1(,%r10,2), %r9 + movl 24(%rsp), %r14d + movq 32(%rsp), %r13 + movq 40(%rsp), %r12 +..B3.16: + lea -1(%r9), %rcx + cmpq %rcx, %rdi + jbe ..B3.69 +..B3.17: + subq %r9, %rax + testq %rdx, %rdx + movq 8(%r13,%rax,8), %r9 + je ..B3.19 +..B3.18: + movl %edx, %ecx + movq %r9, %r10 + negq %rdx + addq $12, %rdx + shlq %cl, %r10 + movl %edx, %ecx + andq $4095, %r10 + shrq %cl, %r9 + addq %r10, %rsi +..B3.19: + movq $0xfffffffffffffff, %rcx + andq %r9, %rcx + shrq $60, %r9 + movq $0, 8(%r13,%rax,8) + addq %r9, %rcx + addq %rcx, %rsi + movq 8(%r8), %rcx +..B3.20: + movq %rsi, %rax + shrq $12, %rax + testq %rax, %rax + je ..B3.24 +..B3.22: + andq $4095, %rsi + addq %rax, %rsi + movq %rsi, %rax + shrq $12, %rax + testq %rax, %rax + jne ..B3.22 +..B3.24: + movq $0xfffffffffffff, %rax + movq %r13, %rdi + shlq $52, %rsi + andq %rcx, %rax + orq %rsi, %rax + xorl %esi, %esi + movq %rax, 8(%r8) + movl %ebx, 4(%r13) +..___tag_value___dpml_ux_sincos.110: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_sincos.111: +..B3.25: + subq %rax, %rbx +..B3.26: + movslq %ebx, %rbx + movl $0, (%r13) + addq $-5, %rbx + movq 8(%r13), %r9 + jle ..B3.28 +..B3.27: + lea 256+__trig_x_table(%rip), %rsi + movq %r9, %rax + movl %r9d, %ecx + movq %rcx, %r11 + shrq $32, %rax + movq (%rsi), %rdx + movl %edx, %r10d + shrq $32, %rdx + imulq %r10, %r11 + imulq %rdx, %rcx + imulq %rax, %r10 + imulq %rax, %rdx + shrq $32, %r11 + addq %rcx, %r11 + xorl %ecx, %ecx + addq %r11, %r10 + cmpq %r11, %r10 + movq %r10, %rsi + setb %cl + shrq $32, %rsi + shlq $32, %rcx + addq %rcx, %rsi + addq %rdx, %rsi + jmp ..B3.29 +..B3.28: + movl $1, %ebx + xorl %esi, %esi +..B3.29: + negq %rbx + movq %rbp, %rax + andq $1, %rax + incq %rax + shrq $1, %rbp + lea 63(%rbx), %rcx + shlq %cl, %rax + addq %rsi, %rax + movl %ebx, %ecx + movl $1, %esi + shlq %cl, %rsi + movl %ebx, %ecx + decq %rsi + notq %rsi + andq %rsi, %rax + movq $0x0b4000000, %rsi + movq %rax, %r11 + shrq %cl, %r11 + movl %eax, %ecx + movq %r11, %r10 + imulq %rsi, %rcx + shrq $32, %rax + negq %r10 + imulq %rax, %rsi + testl %r14d, %r14d + cmovne %r10, %r11 + movq %r9, %r10 + shrq $2, %r10 + andq $3, %r9 + shrq $32, %rcx + addq %r11, %rbp + subq %rcx, %r10 + subq %rsi, %r10 + lea (,%r10,4), %rax + orq %rax, %r9 + testq %r10, %r10 + jns ..B3.31 +..B3.30: + movq 16(%r13), %rax + movl $1, %ecx + xorl %esi, %esi + testq %rax, %rax + cmovne %ecx, %esi + movq %rax, %r10 + movslq %r14d, %r14 + negq %r10 + btcq $31, %r14 + addq %rsi, %r9 + movq %r10, 16(%r13) + negq %r9 +..B3.31: + movq %r13, %rdi + xorl %esi, %esi + movq %r9, 8(%r13) +..___tag_value___dpml_ux_sincos.112: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_sincos.113: +..B3.32: + shlq $3, %rbp + movq 8(%r13), %rax + shrl $3, %ebp + movl 4(%r13), %ecx + movl %ebp, %ebx + testq %rax, %rax + jne ..B3.35 +..B3.33: + movq $0x2000000000000000, %rax + orq %rax, %rbx + testq $2, %rbx + je ..B3.44 +..B3.34: + movslq (%r13), %rax + btcq $31, %rax + movl %eax, (%r13) + jmp ..B3.44 +..B3.35: + cmpl $5, %ecx + jl ..B3.43 +..B3.36: + cmpq $0, 16(%r13) + jne ..B3.43 +..B3.37: + negl %ecx + movq %rax, %rsi + shrq %cl, %rsi + movq %rsi, %rdx + shlq %cl, %rdx + cmpq %rdx, %rax + jne ..B3.43 +..B3.38: + cmpq $30, %rsi + jne ..B3.42 +..B3.39: + testq $1, %rbx + jne ..B3.43 +..B3.40: + movq $0x4000000000000000, %rax + xorl %r14d, (%r13) + orq %rax, %rbx + jmp ..B3.44 +..B3.42: + movq $0x8000000000000000, %rax + orq %rbx, %rax + cmpq $45, %rsi + cmove %rax, %rbx +..B3.43: + xorl %r14d, (%r13) +..B3.44: + movq %r13, %rdi + lea 216+__trig_x_table(%rip), %rsi + lea (%rsp), %rdx +..___tag_value___dpml_ux_sincos.114: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_sincos.115: +..B3.46: + andq $-17, %r15 + movl $3, %ecx + movl $1, %eax + cmpq $3, %r15 + movq %rbx, %rdx + cmove %rax, %rcx + xorl %r13d, %r13d + movl $1, %esi + sarq $61, %rdx + testq %rcx, %rdx + movq %rbx, %rcx + cmove %esi, %r13d + andq $1, %rcx + cmpq $3, %r15 + je ..B3.68 +..B3.47: + movl $1216, %edx + testq %rcx, %rcx + movl $1038, %ecx + cmovne %rdx, %rcx +..B3.48: + lea 272+__trig_x_table(%rip), %rsi + lea (%rsp), %rdi + movl $13, %edx + movq %r12, %r8 +..___tag_value___dpml_ux_sincos.116: + call __dpml_evaluate_rational__@PLT +..___tag_value___dpml_ux_sincos.117: +..B3.49: + testq $2, %rbx + je ..B3.51 +..B3.50: + movslq (%r12), %rdx + btcq $31, %rdx + movl %edx, (%r12) +..B3.51: + cmpq $3, %r15 + je ..B3.64 +..B3.52: + movq 128(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B3.63 +..B3.53: + movq %r13, %rax + addq $136, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.54: + movq 8(%r13), %r11 + movq 16(%r13), %rax + movl (%r13), %ecx + movq %r11, 88(%rsp) + movslq 4(%r13), %r11 + testq %r11, %r11 + movq %rax, 112(%rsp) + movl %ecx, 56(%rsp) + jl ..B3.81 +..B3.55: + addq $8, %r11 + movq %r11, %rsi + sarq $6, %rsi + movq __four_over_pi@GOTPCREL(%rip), %rax + movq %rsi, 64(%rsp) + lea (%rax,%rsi,8), %r10 + movq 32(%r10), %rcx + movq (%r10), %r9 + movq 8(%r10), %rsi + movq 16(%r10), %rax + movq 24(%r10), %rdi + addq $40, %r10 + movq %rcx, 8(%rsp) + andq $63, %r11 + movq %r10, (%rsp) + je ..B3.57 +..B3.56: + movq %r11, %r10 + movl %r11d, %ecx + negq %r10 + movq %rsi, %r13 + movq %r10, 64(%rsp) + movq %rax, %r14 + shlq %cl, %r9 + movl %r10d, %ecx + shrq %cl, %r13 + movl %r11d, %ecx + shlq %cl, %rsi + movl %r10d, %ecx + shrq %cl, %r14 + movl %r11d, %ecx + shlq %cl, %rax + orq %r13, %r9 + movl %r10d, %ecx + movq %rdi, %r13 + shrq %cl, %r13 + movl %r11d, %ecx + shlq %cl, %rdi + movl %r10d, %ecx + orq %r13, %rax + orq %r14, %rsi + movq 8(%rsp), %r13 + shrq %cl, %r13 + orq %r13, %rdi +..B3.57: + movl %edi, %edx + movq %r11, 120(%rsp) + movq %rdx, %r13 + movq 112(%rsp), %r11 + movq %r11, %r8 + movq %r9, 24(%rsp) + movq %r11, %r9 + movq %r15, 16(%rsp) + movq %rdx, %r15 + movl %r11d, %ebx + movq %rbp, 32(%rsp) + movq %rdi, %rbp + shrq $32, %r9 + movq %rbx, %r10 + imulq %rbx, %r15 + imulq %r9, %r13 + imulq %rdi, %r8 + shrq $32, %rbp + movq %r9, %r14 + imulq %rbp, %r10 + imulq %rbp, %r14 + shrq $32, %r15 + addq %r13, %r15 + addq %r15, %r10 + cmpq %r15, %r10 + movq %r10, %r13 + movq %r12, 40(%rsp) + movl $0, %r12d + setb %r12b + shrq $32, %r13 + shlq $32, %r12 + movq 88(%rsp), %r10 + addq %r12, %r13 + movq %r8, 48(%rsp) + movq %r10, %r8 + movl %r10d, %ecx + movq %rdx, %r12 + shrq $32, %r8 + movq %rcx, %r15 + imulq %rcx, %r12 + imulq %r8, %rdx + imulq %rbp, %r15 + imulq %r10, %rdi + imulq %r8, %rbp + shrq $32, %r12 + addq %r14, %r13 + addq %rdx, %r12 + addq %rdi, %r13 + addq %r12, %r15 + cmpq %r12, %r15 + movq %r15, %rdx + movl $0, %r15d + setb %r15b + cmpq %rdi, %r13 + movl $0, %edi + setb %dil + shrq $32, %rdx + shlq $32, %r15 + addq %r15, %rdx + movq %r11, %r15 + addq %rbp, %rdx + addq %rdi, %rdx + movq %rax, %rbp + movl %eax, %edi + movq %rdi, %r14 + movq %rdi, %r12 + imulq %rbx, %r14 + imulq %r9, %r12 + imulq %rax, %r15 + imulq %r10, %rax + shrq $32, %rbp + addq %r15, %r13 + movq %rbx, 96(%rsp) + imulq %rbp, %rbx + shrq $32, %r14 + addq %r12, %r14 + addq %r14, %rbx + cmpq %r14, %rbx + movl $0, %r14d + movq %rbx, %r12 + movq %r9, %rbx + setb %r14b + cmpq %r15, %r13 + movl $0, %r15d + movq %rcx, 72(%rsp) + setb %r15b + imulq %rbp, %rbx + shrq $32, %r12 + shlq $32, %r14 + addq %r14, %r12 + movq %rdi, %r14 + imulq %rcx, %r14 + imulq %r8, %rdi + imulq %rbp, %rcx + imulq %r8, %rbp + addq %rbx, %r12 + addq %r15, %rdx + xorl %ebx, %ebx + cmpq %r15, %rdx + movq %r9, 104(%rsp) + setb %bl + addq %r12, %rdx + cmpq %r12, %rdx + movl $0, %r12d + setb %r12b + addq %rax, %rdx + shrq $32, %r14 + addq %rdi, %r14 + xorl %edi, %edi + addq %r14, %rcx + addq %r12, %rbx + xorl %r12d, %r12d + cmpq %r14, %rcx + movq %rcx, %r15 + setb %r12b + cmpq %rax, %rdx + movl $0, %eax + setb %al + movq %r11, %r14 + shrq $32, %r15 + shlq $32, %r12 + addq %r12, %r15 + movq %rsi, %r12 + addq %rbp, %r15 + addq %rax, %r15 + addq %rbx, %r15 + movl %esi, %ebx + movq %rbx, %rbp + movq 96(%rsp), %rcx + imulq %rcx, %rbp + imulq %r9, %rbx + imulq %rsi, %r14 + imulq %r10, %rsi + shrq $32, %r12 + addq %r14, %rdx + imulq %r12, %rcx + imulq %r9, %r12 + shrq $32, %rbp + addq %r15, %rsi + addq %rbx, %rbp + xorl %ebx, %ebx + addq %rbp, %rcx + cmpq %rbp, %rcx + movq %rcx, %rax + movq 32(%rsp), %rcx + setb %dil + cmpq %r14, %rdx + setb %bl + xorl %r14d, %r14d + shrq $32, %rax + shlq $32, %rdi + addq %rdi, %rax + addq %r12, %rax + addq %rax, %rbx + movq %rcx, %rax + addq %rsi, %rbx + negq %rax + movq 24(%rsp), %rsi + imulq %r11, %rsi + cmpl $0, 56(%rsp) + movq %r8, 80(%rsp) + cmovne %rax, %rcx + addq %rsi, %rbx + shlq $61, %rcx + movq 120(%rsp), %r11 + addq %rcx, %rbx + movq 48(%rsp), %r10 + movq (%rsp), %r8 + movq 8(%rsp), %r9 + jmp ..B3.58 +..B3.62: + movq $0xe000000000000000, %rax + addq $64, %r14 + andq %rbx, %rax + movq $0x1fffffffffffffff, %rbx + andq %rdx, %rbx + movq %r13, %rdx + orq %rax, %rbx + movq %r10, %r13 + movq %rcx, %r10 +..B3.58: + movq $0x40000000000000, %rax + movq $0x3f80000000000000, %rsi + lea (%rax,%rbx), %rcx + testq %rsi, %rcx + jne ..B3.70 +..B3.59: + movq %r9, %rdi + movq 120(%rsp), %rax + movl %eax, %ecx + movq %rdi, %r12 + movq (%r8), %r9 + movq %r9, %rsi + shlq %cl, %r12 + addq $8, %r8 + movq 64(%rsp), %rcx + movq 96(%rsp), %rbp + movq %rbp, %r15 + shrq %cl, %rsi + orq %rsi, %r12 + testq %rax, %rax + movq 104(%rsp), %r11 + cmovne %r12, %rdi + movq %r11, %r12 + movl %edi, %eax + movq %rdi, %rsi + imulq %rax, %r15 + imulq %rax, %r12 + shrq $32, %rsi + imulq %rsi, %rbp + imulq %rsi, %r11 + shrq $32, %r15 + addq %r12, %r15 + addq %r15, %rbp + cmpq %r15, %rbp + movl $0, %r15d + movq %rbp, %r12 + setb %r15b + shrq $32, %r12 + shlq $32, %r15 + addq %r15, %r12 + addq %r11, %r12 + movq 72(%rsp), %r11 + movq %r11, %rbp + imulq %rax, %rbp + movq 80(%rsp), %r15 + addq %r12, %r10 + imulq %r15, %rax + shrq $32, %rbp + cmpq %r12, %r10 + movq 112(%rsp), %rcx + movl $0, %r12d + setb %r12b + addq %rax, %rbp + movq %r11, %rax + imulq %rsi, %rax + imulq %rdi, %rcx + imulq 88(%rsp), %rdi + imulq %r15, %rsi + addq %rbp, %rax + addq %r12, %r13 + movq %rax, %r11 + cmpq %r12, %r13 + movl $0, %r12d + setb %r12b + cmpq %rbp, %rax + movl $0, %eax + setb %al + addq %rdi, %r10 + cmpq %rdi, %r10 + movl $0, %edi + setb %dil + shrq $32, %r11 + shlq $32, %rax + addq %rax, %r11 + addq %rdi, %r13 + addq %rsi, %r11 + xorl %eax, %eax + cmpq %rdi, %r13 + setb %al + addq %r11, %r13 + cmpq %r11, %r13 + movl $0, %r11d + setb %r11b + addl %r12d, %eax + addl %r11d, %eax + je ..B3.61 +..B3.60: + incq %rdx + lea 1(%rbx), %rax + cmove %rax, %rbx +..B3.61: + movq %rdx, %rdi + movq %rbx, %rax + shrq $55, %rdi + shlq $9, %rax + orq %rax, %rdi + movq %rdi, %rsi + sarq $63, %rsi + cmpq %rdi, %rsi + jne ..B3.70 + jmp ..B3.62 +..B3.63: + call __stack_chk_fail@PLT +..B3.64: + cmpq $0, 32(%r12) + jne ..B3.66 +..B3.65: + movl $0, 24(%r12) + jmp ..B3.52 +..B3.66: + incq %rbx + testq $2, %rbx + je ..B3.52 +..B3.67: + movslq 24(%r12), %rdx + btcq $31, %rdx + movl %edx, 24(%r12) + jmp ..B3.52 +..B3.68: + shlq $9, %rcx + orq $462, %rcx + jmp ..B3.48 +..B3.69: + movq 8(%r8), %rcx + jmp ..B3.20 +..B3.70: + movq 16(%rsp), %r15 + movq 40(%rsp), %r12 +..B3.71: + lea (,%rbx,4), %rcx + sarq $2, %rcx + movq %rcx, %rax + subq %rcx, %rbx + sarq $63, %rax + movq %rcx, %rsi + cmpq %rax, %rcx + jne ..B3.73 +..B3.72: + movq %rdx, %rcx + movq %r13, %rdx + movq %r10, %r13 + addq $64, %r14 +..B3.73: + movl $-2147483648, %eax + testq %rsi, %rsi + movl $0, %esi + cmovge %esi, %eax + testl %eax, %eax + je ..B3.75 +..B3.74: + notq %r13 + movl $1, %edi + incq %r13 + notq %rdx + cmove %edi, %esi + xorl %r9d, %r9d + notq %rcx + addq %rsi, %rdx + cmove %edi, %r9d + addq %r9, %rcx +..B3.75: + movq %rbx, %r9 + lea (%rsp), %rdi + movl 56(%rdi), %r10d + negq %r9 + testl %r10d, %r10d + movl $3, 4(%rdi) + movq %rcx, 8(%rdi) + cmovne %r9, %rbx + xorl %esi, %esi + xorl %r10d, %eax + movl %eax, (%rdi) + movq %rdx, 16(%rdi) +..___tag_value___dpml_ux_sincos.138: + call __dpml_ffs_and_shift__@PLT +..___tag_value___dpml_ux_sincos.139: +..B3.76: + movslq 4(%rsp), %rax + movq %rax, %rcx + addq $-3, %rcx + je ..B3.78 +..B3.77: + shrq %cl, %r13 + orq %r13, 16(%rsp) +..B3.78: + lea 1008+__trig_x_table(%rip), %rsi + lea (%rsp), %rdi + movq %rdi, %rdx + subq %r14, %rax + movl %eax, 4(%rdi) +..___tag_value___dpml_ux_sincos.140: + call __dpml_multiply__@PLT +..___tag_value___dpml_ux_sincos.141: +..B3.79: + shrq $62, %rbx + jmp ..B3.46 +..B3.81: + movl %ecx, %eax + sarl $31, %eax + movslq %eax, %rax + addq %rbp, %rax + movq %rax, %rcx + andq $1, %rcx + addq %rcx, %rax + movq %rax, %rbx + sarq $1, %rbx + subq %rax, %rbp + je ..B3.83 +..B3.82: + shrq $63, %rbp + movq %r13, %rdi + lea 1008+__trig_x_table(%rip), %rsi + movq %rbp, %rdx + lea (%rsp), %rcx +..___tag_value___dpml_ux_sincos.142: + call __dpml_addsub__@PLT +..___tag_value___dpml_ux_sincos.143: + jmp ..B3.46 +..B3.83: + movl 56(%rsp), %eax + movq 88(%rsp), %rdx + movq 112(%rsp), %rcx + movl %eax, (%rsp) + movl %r11d, 4(%rsp) + movq %rdx, 8(%rsp) + movq %rcx, 16(%rsp) + jmp ..B3.46 + .align 16,0x90 + .cfi_endproc + .type __dpml_ux_sincos,@function + .size __dpml_ux_sincos,.-__dpml_ux_sincos + .data +# -- End __dpml_ux_sincos + .section .rodata, "a" + .align 16 + .align 16 +__trig_x_table: + .long 15442952 + .long 1678786816 + .long 15709192 + .long 1414612240 + .long 15975432 + .long 1141915904 + .long 16241672 + .long 873463808 + .long 16507912 + .long 609305872 + .long 16774152 + .long 336592896 + .long 2 + .long 0 + .long 103 + .long 0 + .long 22 + .long 0 + .long 104 + .long 0 + .long 107 + .long 0 + .long 23 + .long 0 + .long 105 + .long 0 + .long 15176712 + .long 336609536 + .long 115 + .long 0 + .long 15176712 + .long 336592896 + .long 118 + .long 0 + .long 15176712 + .long 519700480 + .long 28 + .long 0 + .long 29 + .long 0 + .long 30 + .long 0 + .long 15176712 + .long 528281504 + .long 34 + .long 0 + .long 32 + .long 0 + .long 33 + .long 0 + .long 35 + .long 0 + .long 36 + .long 0 + .long 0 + .long 4294967291 + .long 2498349230 + .long 2398762258 + .long 2491794649 + .long 247854702 + .long 0 + .long 0 + .long 0 + .long 1073676288 + .long 95443718 + .long 1527099483 + .long 1431655766 + .long 357913941 + .long 2657305954 + .long 3 + .long 0 + .long 0 + .long 3705764381 + .long 2553 + .long 0 + .long 0 + .long 138031221 + .long 1532340 + .long 0 + .long 0 + .long 2983678984 + .long 775364077 + .long 0 + .long 0 + .long 20739419 + .long 3530365445 + .long 75 + .long 0 + .long 674366505 + .long 499172021 + .long 25931 + .long 0 + .long 1191312077 + .long 2630803580 + .long 7053263 + .long 0 + .long 2382099329 + .long 2712937970 + .long 1481185358 + .long 0 + .long 2412211635 + .long 2311528398 + .long 3431649258 + .long 53 + .long 3364759590 + .long 865053377 + .long 3819263687 + .long 5917 + .long 1745256079 + .long 2154301056 + .long 109078534 + .long 426088 + .long 286331142 + .long 286331153 + .long 286331153 + .long 17895697 + .long 1431655765 + .long 1431655765 + .long 1431655765 + .long 357913941 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 2851833826 + .long 97 + .long 0 + .long 0 + .long 1768459388 + .long 63846 + .long 0 + .long 0 + .long 2009193996 + .long 35243820 + .long 0 + .long 0 + .long 1368406537 + .long 3397743743 + .long 3 + .long 0 + .long 3946395699 + .long 2652434014 + .long 1440 + .long 0 + .long 2553743692 + .long 4190957063 + .long 440828 + .long 0 + .long 595011843 + .long 807348040 + .long 105798954 + .long 0 + .long 883371940 + .long 908455249 + .long 2075540478 + .long 4 + .long 761938407 + .long 3951975904 + .long 3388403475 + .long 591 + .long 217841633 + .long 3490513104 + .long 13634816 + .long 53261 + .long 3626846480 + .long 2195205506 + .long 763549741 + .long 2982616 + .long 1431655403 + .long 1431655765 + .long 1431655765 + .long 89478485 + .long 4294967292 + .long 4294967295 + .long 4294967295 + .long 1073741823 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2877741414 + .long 48456580 + .long 4555740 + .long 0 + .long 3312728015 + .long 4268104823 + .long 3744444631 + .long 1 + .long 6483522 + .long 3858350617 + .long 1187701358 + .long 879 + .long 3780777519 + .long 2626127639 + .long 2801410624 + .long 158172 + .long 3864078256 + .long 3316933375 + .long 1275824684 + .long 11667904 + .long 1744149096 + .long 2725495384 + .long 3617949641 + .long 318163395 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 3422290646 + .long 426546810 + .long 43450 + .long 0 + .long 3479121894 + .long 3493673009 + .long 236644653 + .long 0 + .long 4247003031 + .long 1084451344 + .long 1285072157 + .long 46 + .long 1927283714 + .long 2972340862 + .long 2243521359 + .long 13184 + .long 739625925 + .long 4125699428 + .long 1446479475 + .long 1522115 + .long 2250255868 + .long 2030226330 + .long 3149913922 + .long 70000510 + .long 312493331 + .long 1293839619 + .long 2186293876 + .long 1033991278 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 0 + .long 0 + .long 560513588 + .long 3373259426 + .long 2161908945 + .long 3301335691 + .long 0 + .long 0 + .type __trig_x_table,@object + .size __trig_x_table,1040 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/erf.S b/external/sgx_libm/intel64/erf.S new file mode 100644 index 0000000000..029f5b98ec --- /dev/null +++ b/external/sgx_libm/intel64/erf.S @@ -0,0 +1,1390 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erf.c" + .text +..TXTST0: +# -- Begin erf + .text + .align 16,0x90 + .globl erf +erf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_erf.1: +..L2: + + movsd %xmm0, -8(%rsp) + movb -1(%rsp), %cl + movb %cl, %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + lea _vmldErfHATab(%rip), %rax + movzwl -2(%rsp), %esi + andl $32752, %esi + shrl $4, %esi + movsd 3632(%rax,%rdx,8), %xmm5 + cmpl $2047, %esi + je ..B1.17 +..B1.2: + movsd %xmm0, -8(%rsp) + andb $127, %cl + movb %cl, -1(%rsp) + cmpl $983, %esi + movsd -8(%rsp), %xmm4 + jl ..B1.9 +..B1.3: + lea 3664+_vmldErfHATab(%rip), %rdx + comisd (%rdx), %xmm4 + jb ..B1.8 +..B1.4: + lea 3672+_vmldErfHATab(%rip), %rdx + movsd (%rdx), %xmm0 + comisd %xmm4, %xmm0 + jbe ..B1.6 +..B1.5: + movl -4(%rsp), %edx + shll $20, %esi + andl $1048575, %edx + orl %edx, %esi + addl $-1069547520, %esi + sarl $18, %esi + lea (%rsi,%rsi,4), %ecx + lea 3616+_vmldErfHATab(%rip), %rsi + shll $2, %ecx + movslq %ecx, %rcx + movsd (%rsi), %xmm1 + movaps %xmm1, %xmm6 + movsd (%rax,%rcx,8), %xmm3 + mulsd %xmm3, %xmm4 + movsd 152(%rax,%rcx,8), %xmm2 + movsd 48(%rax,%rcx,8), %xmm11 + movsd 56(%rax,%rcx,8), %xmm12 + addsd 8(%rax,%rcx,8), %xmm4 + mulsd %xmm4, %xmm2 + mulsd %xmm4, %xmm6 + addsd 144(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + movsd %xmm6, -24(%rsp) + movsd -24(%rsp), %xmm7 + movsd 32(%rax,%rcx,8), %xmm6 + subsd %xmm4, %xmm7 + addsd 136(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + movsd %xmm7, -16(%rsp) + movsd -24(%rsp), %xmm9 + movsd -16(%rsp), %xmm8 + addsd 128(%rax,%rcx,8), %xmm2 + subsd %xmm8, %xmm9 + mulsd %xmm4, %xmm2 + movsd %xmm9, -24(%rsp) + movsd -24(%rsp), %xmm10 + addsd 120(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + addsd 112(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + addsd 104(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + addsd 96(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + addsd 88(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + addsd 80(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + addsd 72(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + addsd 64(%rax,%rcx,8), %xmm2 + mulsd %xmm4, %xmm2 + mulsd %xmm4, %xmm2 + mulsd %xmm4, %xmm2 + subsd %xmm10, %xmm4 + movsd %xmm4, -16(%rsp) + movsd -24(%rsp), %xmm4 + movsd -16(%rsp), %xmm0 + movaps %xmm4, %xmm3 + movaps %xmm0, %xmm13 + mulsd %xmm11, %xmm3 + mulsd %xmm12, %xmm13 + mulsd %xmm0, %xmm11 + mulsd %xmm4, %xmm12 + addsd %xmm11, %xmm13 + movaps %xmm3, %xmm14 + addsd %xmm12, %xmm13 + addsd %xmm6, %xmm14 + movsd %xmm13, -24(%rsp) + movsd -24(%rsp), %xmm7 + movsd %xmm14, -24(%rsp) + movsd -24(%rsp), %xmm15 + subsd %xmm15, %xmm6 + addsd %xmm3, %xmm6 + movsd %xmm6, -16(%rsp) + movsd -24(%rsp), %xmm11 + mulsd %xmm11, %xmm1 + movsd -16(%rsp), %xmm14 + movsd %xmm1, -24(%rsp) + addsd %xmm7, %xmm14 + movsd -24(%rsp), %xmm1 + subsd %xmm11, %xmm1 + addsd 40(%rax,%rcx,8), %xmm14 + movsd %xmm1, -16(%rsp) + movaps %xmm0, %xmm1 + movsd -24(%rsp), %xmm9 + movsd -16(%rsp), %xmm8 + subsd %xmm8, %xmm9 + movsd %xmm9, -24(%rsp) + movsd -24(%rsp), %xmm10 + subsd %xmm10, %xmm11 + movsd %xmm11, -16(%rsp) + movsd -24(%rsp), %xmm13 + movsd -16(%rsp), %xmm12 + movaps %xmm13, %xmm3 + mulsd %xmm0, %xmm13 + addsd %xmm12, %xmm14 + mulsd %xmm4, %xmm3 + mulsd %xmm14, %xmm1 + mulsd %xmm14, %xmm4 + addsd %xmm13, %xmm1 + movaps %xmm3, %xmm0 + addsd %xmm4, %xmm1 + movsd %xmm1, -24(%rsp) + movsd 16(%rax,%rcx,8), %xmm1 + movsd -24(%rsp), %xmm15 + addsd %xmm1, %xmm0 + movsd %xmm0, -24(%rsp) + movsd -24(%rsp), %xmm4 + subsd %xmm4, %xmm1 + addsd %xmm3, %xmm1 + movsd %xmm1, -16(%rsp) + movsd -24(%rsp), %xmm1 + movsd -16(%rsp), %xmm0 + addsd %xmm15, %xmm0 + addsd 24(%rax,%rcx,8), %xmm0 + addsd %xmm0, %xmm2 + movsd %xmm2, -24(%rsp) + movsd -24(%rsp), %xmm0 + addsd %xmm1, %xmm0 + mulsd %xmm5, %xmm0 + ret +..B1.6: + lea 3632+_vmldErfHATab(%rip), %rax + lea 3608+_vmldErfHATab(%rip), %rdx + movsd (%rax), %xmm0 + addsd (%rdx), %xmm0 + mulsd %xmm5, %xmm0 +..B1.7: + ret +..B1.8: + movaps %xmm4, %xmm6 + lea 3592+_vmldErfHATab(%rip), %rax + mulsd %xmm4, %xmm6 + lea 3584+_vmldErfHATab(%rip), %rdx + movsd (%rax), %xmm3 + lea 3576+_vmldErfHATab(%rip), %rcx + mulsd %xmm6, %xmm3 + movaps %xmm4, %xmm12 + mulsd %xmm6, %xmm12 + addsd (%rdx), %xmm3 + mulsd %xmm6, %xmm3 + lea 3616+_vmldErfHATab(%rip), %r10 + lea 3568+_vmldErfHATab(%rip), %rsi + lea 3560+_vmldErfHATab(%rip), %rdi + movsd (%r10), %xmm7 + lea 3544+_vmldErfHATab(%rip), %r8 + mulsd %xmm12, %xmm7 + addsd (%rcx), %xmm3 + mulsd %xmm6, %xmm3 + lea 3552+_vmldErfHATab(%rip), %r9 + movsd %xmm7, -24(%rsp) + lea 3528+_vmldErfHATab(%rip), %r11 + movsd -24(%rsp), %xmm8 + lea 3536+_vmldErfHATab(%rip), %rax + movsd (%r8), %xmm14 + subsd %xmm12, %xmm8 + addsd (%rsi), %xmm3 + mulsd %xmm6, %xmm3 + movaps %xmm14, %xmm2 + movsd %xmm8, -16(%rsp) + movsd -24(%rsp), %xmm10 + movsd -16(%rsp), %xmm9 + movsd (%r9), %xmm15 + subsd %xmm9, %xmm10 + addsd (%rdi), %xmm3 + mulsd %xmm6, %xmm3 + movaps %xmm4, %xmm6 + mulsd (%r10), %xmm6 + mulsd %xmm12, %xmm3 + movsd %xmm10, -24(%rsp) + movsd -24(%rsp), %xmm11 + subsd %xmm11, %xmm12 + movsd %xmm12, -16(%rsp) + movsd -24(%rsp), %xmm0 + movsd -16(%rsp), %xmm13 + movaps %xmm13, %xmm1 + mulsd %xmm15, %xmm1 + mulsd %xmm13, %xmm14 + mulsd %xmm0, %xmm2 + mulsd %xmm15, %xmm0 + addsd %xmm14, %xmm1 + addsd %xmm0, %xmm1 + movsd %xmm1, -24(%rsp) + movsd -24(%rsp), %xmm1 + movsd %xmm6, -24(%rsp) + movsd -24(%rsp), %xmm7 + movsd (%r11), %xmm6 + movaps %xmm6, %xmm0 + subsd -8(%rsp), %xmm7 + movsd %xmm7, -16(%rsp) + movsd -24(%rsp), %xmm9 + movsd -16(%rsp), %xmm8 + movsd (%rax), %xmm7 + subsd %xmm8, %xmm9 + movsd %xmm9, -24(%rsp) + movsd -24(%rsp), %xmm10 + subsd %xmm10, %xmm4 + movaps %xmm2, %xmm10 + addsd %xmm3, %xmm10 + movsd %xmm4, -16(%rsp) + movsd -24(%rsp), %xmm8 + movsd -16(%rsp), %xmm4 + movaps %xmm4, %xmm9 + mulsd %xmm7, %xmm9 + mulsd %xmm4, %xmm6 + mulsd %xmm8, %xmm0 + mulsd %xmm7, %xmm8 + addsd %xmm6, %xmm9 + addsd %xmm8, %xmm9 + movsd %xmm9, -24(%rsp) + movsd -24(%rsp), %xmm12 + movsd %xmm10, -24(%rsp) + movsd -24(%rsp), %xmm4 + subsd %xmm4, %xmm2 + addsd %xmm3, %xmm2 + movsd %xmm2, -16(%rsp) + movsd -24(%rsp), %xmm3 + movsd -16(%rsp), %xmm11 + addsd %xmm1, %xmm11 + movaps %xmm0, %xmm1 + addsd %xmm3, %xmm1 + addsd %xmm11, %xmm12 + movsd %xmm1, -24(%rsp) + movsd -24(%rsp), %xmm2 + subsd %xmm2, %xmm0 + addsd %xmm3, %xmm0 + movsd %xmm0, -16(%rsp) + movsd -24(%rsp), %xmm0 + movsd -16(%rsp), %xmm13 + addsd %xmm12, %xmm13 + addsd %xmm13, %xmm0 + mulsd %xmm5, %xmm0 + ret +..B1.9: + lea 3624+_vmldErfHATab(%rip), %rax + ucomisd (%rax), %xmm4 + jp ..B1.10 + je ..B1.7 +..B1.10: + testl %esi, %esi + jne ..B1.16 +..B1.11: + lea 3656+_vmldErfHATab(%rip), %rax + comisd (%rax), %xmm4 + jae ..B1.16 +..B1.12: + lea 3600+_vmldErfHATab(%rip), %rax + lea 3648+_vmldErfHATab(%rip), %rdx + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + comisd (%rdx), %xmm4 + jb ..B1.14 +..B1.13: + lea 3616+_vmldErfHATab(%rip), %rax + movaps %xmm0, %xmm1 + lea 3536+_vmldErfHATab(%rip), %rcx + lea 3528+_vmldErfHATab(%rip), %rdx + lea 3608+_vmldErfHATab(%rip), %rsi + movsd (%rax), %xmm10 + movsd (%rdx), %xmm8 + mulsd %xmm10, %xmm1 + movsd %xmm1, -24(%rsp) + movsd -24(%rsp), %xmm2 + subsd %xmm0, %xmm2 + movsd %xmm2, -16(%rsp) + movsd -24(%rsp), %xmm4 + movsd -16(%rsp), %xmm3 + subsd %xmm3, %xmm4 + movsd %xmm4, -24(%rsp) + movsd -24(%rsp), %xmm5 + subsd %xmm5, %xmm0 + movsd %xmm0, -16(%rsp) + movsd -24(%rsp), %xmm6 + movsd -16(%rsp), %xmm7 + movaps %xmm6, %xmm15 + movsd (%rcx), %xmm0 + movaps %xmm7, %xmm9 + mulsd %xmm0, %xmm9 + mulsd %xmm0, %xmm6 + mulsd %xmm8, %xmm15 + mulsd %xmm7, %xmm8 + addsd %xmm6, %xmm9 + mulsd %xmm15, %xmm10 + addsd %xmm8, %xmm9 + movsd %xmm9, -24(%rsp) + movsd -24(%rsp), %xmm0 + movsd %xmm10, -24(%rsp) + movsd -24(%rsp), %xmm11 + subsd %xmm15, %xmm11 + movsd %xmm11, -16(%rsp) + movsd -24(%rsp), %xmm13 + movsd -16(%rsp), %xmm12 + subsd %xmm12, %xmm13 + movsd %xmm13, -24(%rsp) + movsd -24(%rsp), %xmm14 + subsd %xmm14, %xmm15 + movsd %xmm15, -16(%rsp) + movsd -24(%rsp), %xmm11 + movsd -16(%rsp), %xmm10 + mulsd (%rsi), %xmm11 + addsd %xmm10, %xmm0 + mulsd (%rsi), %xmm0 + movsd %xmm11, -24(%rsp) + movsd %xmm0, -16(%rsp) + movsd -24(%rsp), %xmm2 + movsd -16(%rsp), %xmm1 + addsd %xmm1, %xmm2 + jmp ..B1.15 +..B1.14: + lea 3520+_vmldErfHATab(%rip), %rax + lea 3608+_vmldErfHATab(%rip), %rdx + movsd (%rax), %xmm2 + mulsd %xmm0, %xmm2 + mulsd (%rdx), %xmm2 +..B1.15: + movaps %xmm2, %xmm0 + ret +..B1.16: + lea 3600+_vmldErfHATab(%rip), %rax + lea 3616+_vmldErfHATab(%rip), %rdx + lea 3528+_vmldErfHATab(%rip), %rcx + lea 3536+_vmldErfHATab(%rip), %rsi + lea 3608+_vmldErfHATab(%rip), %rdi + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd (%rdx), %xmm2 + mulsd %xmm0, %xmm2 + movsd %xmm2, -24(%rsp) + movsd -24(%rsp), %xmm3 + movsd (%rcx), %xmm10 + subsd %xmm0, %xmm3 + movsd %xmm3, -16(%rsp) + movsd -24(%rsp), %xmm5 + movsd -16(%rsp), %xmm4 + movsd (%rsi), %xmm7 + subsd %xmm4, %xmm5 + movsd %xmm5, -24(%rsp) + movsd -24(%rsp), %xmm6 + subsd %xmm6, %xmm0 + movsd %xmm0, -16(%rsp) + movaps %xmm10, %xmm0 + movsd -24(%rsp), %xmm8 + movsd -16(%rsp), %xmm9 + movaps %xmm9, %xmm11 + mulsd %xmm8, %xmm0 + mulsd %xmm7, %xmm11 + mulsd %xmm7, %xmm8 + mulsd %xmm9, %xmm10 + addsd %xmm8, %xmm11 + addsd %xmm10, %xmm11 + movsd %xmm11, -24(%rsp) + movsd -24(%rsp), %xmm12 + addsd %xmm12, %xmm0 + mulsd (%rdi), %xmm0 + ret +..B1.17: + testl $1048575, -4(%rsp) + jne ..B1.20 +..B1.18: + cmpl $0, -8(%rsp) + jne ..B1.20 +..B1.19: + lea 3632+_vmldErfHATab(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm5, %xmm0 + ret +..B1.20: + movsd -8(%rsp), %xmm0 + addsd %xmm0, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type erf,@function + .size erf,.-erf + .data +# -- End erf + .section .rodata, "a" + .align 8 + .align 8 +_vmldErfHATab: + .long 0 + .long 1077936128 + .long 0 + .long 3222405120 + .long 3270920536 + .long 1069821311 + .long 1057270100 + .long 1014821379 + .long 337483220 + .long 1067561815 + .long 2929153520 + .long 1012421262 + .long 4026531840 + .long 3206801857 + .long 1030462481 + .long 3179971874 + .long 1486349066 + .long 3202788052 + .long 134277178 + .long 1047766669 + .long 1212351331 + .long 1042946157 + .long 1104268445 + .long 3183073920 + .long 2950952656 + .long 3177697379 + .long 1025949206 + .long 1022984782 + .long 1815731286 + .long 1017231760 + .long 3033581736 + .long 3157533247 + .long 2954897717 + .long 3151375491 + .long 1303182986 + .long 996834239 + .long 795652555 + .long 990371394 + .long 2343572077 + .long 3130906588 + .long 0 + .long 1077936128 + .long 0 + .long 3222667264 + .long 266066941 + .long 1070109953 + .long 2023669004 + .long 1013041695 + .long 3705654820 + .long 1067550541 + .long 3566009421 + .long 1011293070 + .long 134217728 + .long 3207076363 + .long 3355205190 + .long 3180252909 + .long 2219056158 + .long 3202743700 + .long 3264865953 + .long 1048027271 + .long 3807428681 + .long 1042858920 + .long 3066569234 + .long 3183403162 + .long 1059612996 + .long 3177583001 + .long 1631410288 + .long 1023296102 + .long 1209224421 + .long 1017119299 + .long 3957039910 + .long 3157768207 + .long 2748118263 + .long 3151198590 + .long 1787505922 + .long 997129044 + .long 167794763 + .long 990139564 + .long 2444798020 + .long 3131135431 + .long 0 + .long 1077936128 + .long 0 + .long 3222929408 + .long 3508744758 + .long 1070395510 + .long 3777053507 + .long 1014792775 + .long 2239870848 + .long 1067537158 + .long 80412370 + .long 1012585610 + .long 2550136832 + .long 3207341802 + .long 731471944 + .long 3177077062 + .long 620528720 + .long 3202691430 + .long 3841836855 + .long 1048273069 + .long 190893310 + .long 1042756870 + .long 3560172648 + .long 3183591033 + .long 3053707503 + .long 3177450205 + .long 2206487565 + .long 1023491751 + .long 3218422968 + .long 1016860737 + .long 598928797 + .long 3157970519 + .long 2475988840 + .long 3150996363 + .long 1159941103 + .long 997284625 + .long 3398924683 + .long 989876643 + .long 798935564 + .long 3131261061 + .long 0 + .long 1077936128 + .long 0 + .long 3223191552 + .long 1770174791 + .long 1070636781 + .long 4205036945 + .long 1015375813 + .long 2413196824 + .long 1067521741 + .long 2601975064 + .long 1005834579 + .long 2952790016 + .long 3207595360 + .long 3658041887 + .long 3181077562 + .long 4169926782 + .long 3202631738 + .long 2555230105 + .long 1048501852 + .long 2080004756 + .long 1042641364 + .long 4228979116 + .long 3183726688 + .long 3050753797 + .long 3177301266 + .long 157144205 + .long 1023611097 + .long 477563032 + .long 1016572798 + .long 1180941066 + .long 3158136250 + .long 103748847 + .long 3150576732 + .long 855028858 + .long 997378869 + .long 3717241463 + .long 989324501 + .long 2285599851 + .long 3131350893 + .long 0 + .long 1076887552 + .long 0 + .long 3222405120 + .long 2340732634 + .long 1070844330 + .long 1402414124 + .long 1012108932 + .long 4199089954 + .long 1068543572 + .long 2559319735 + .long 1013022575 + .long 2550136832 + .long 3209872415 + .long 1842851526 + .long 3180929664 + .long 3057689090 + .long 3205675264 + .long 4009292523 + .long 1052886727 + .long 2015516814 + .long 1047689133 + .long 520582071 + .long 3190189211 + .long 3416096878 + .long 3184261095 + .long 1113028140 + .long 1032138739 + .long 3929660173 + .long 1025537235 + .long 1947345592 + .long 3168795649 + .long 1874355335 + .long 3161325647 + .long 790309391 + .long 1010046575 + .long 3732702576 + .long 1001648133 + .long 3279395584 + .long 3146093738 + .long 0 + .long 1076887552 + .long 0 + .long 3222667264 + .long 1155126243 + .long 1071112537 + .long 4058417554 + .long 1015654408 + .long 4091643817 + .long 1068501692 + .long 992009585 + .long 1011189456 + .long 3355443200 + .long 3210088131 + .long 577555187 + .long 3183302762 + .long 3137228493 + .long 3205518745 + .long 1652609564 + .long 1053053423 + .long 3828684380 + .long 1047267014 + .long 859309674 + .long 3190350551 + .long 1723732682 + .long 3183536714 + .long 3655321812 + .long 1032243418 + .long 1849688920 + .long 1023985400 + .long 3853991388 + .long 3168837843 + .long 3217410018 + .long 1007305761 + .long 15852099 + .long 1010050248 + .long 1197806868 + .long 3148971557 + .long 1066481688 + .long 3146043461 + .long 0 + .long 1076887552 + .long 0 + .long 3222929408 + .long 3259520439 + .long 1071369470 + .long 2827660931 + .long 1015400118 + .long 2387383117 + .long 1068408154 + .long 3928547609 + .long 1012504486 + .long 2415919104 + .long 3210272729 + .long 2041761256 + .long 3182227901 + .long 2378546067 + .long 3205191821 + .long 2022373860 + .long 1053172536 + .long 1539712272 + .long 1046637816 + .long 2866781005 + .long 3190430666 + .long 1973204487 + .long 3181753511 + .long 471306766 + .long 1032252941 + .long 3917954587 + .long 3170909470 + .long 1575996247 + .long 3168793506 + .long 2080089276 + .long 1013809777 + .long 3478556236 + .long 1009933722 + .long 556567750 + .long 3150565473 + .long 3617504985 + .long 3145850711 + .long 0 + .long 1076887552 + .long 0 + .long 3223191552 + .long 2839711645 + .long 1071613690 + .long 2970658322 + .long 1014602120 + .long 3815538168 + .long 1068301377 + .long 1215242252 + .long 1012502501 + .long 3221225472 + .long 3210423421 + .long 1694424286 + .long 3182745304 + .long 2482618577 + .long 3204819422 + .long 1490180077 + .long 1053241721 + .long 716537363 + .long 1045509088 + .long 3220326238 + .long 3190429019 + .long 1649943177 + .long 1034362954 + .long 149820908 + .long 1032171009 + .long 2913777793 + .long 3172667222 + .long 2916685335 + .long 3168553958 + .long 3423621657 + .long 1014717380 + .long 3520470914 + .long 1009649189 + .long 1724012134 + .long 3151216830 + .long 973445297 + .long 3145359701 + .long 0 + .long 1075838976 + .long 0 + .long 3222405120 + .long 2293685631 + .long 1071799178 + .long 995883061 + .long 1015632714 + .long 3793057312 + .long 1069174900 + .long 303272667 + .long 1011854732 + .long 2013265920 + .long 3212679811 + .long 2434603502 + .long 3185139859 + .long 492809813 + .long 3207185437 + .long 3249638684 + .long 1057446891 + .long 3644008036 + .long 3197518090 + .long 2427527080 + .long 3196575624 + .long 382948573 + .long 1043637576 + .long 3944285033 + .long 1040289590 + .long 3216947186 + .long 3183007329 + .long 3738834740 + .long 3178455694 + .long 3578811002 + .long 1026832616 + .long 2077607461 + .long 1021301705 + .long 1329130827 + .long 3165226306 + .long 2937198399 + .long 3158390279 + .long 0 + .long 1075838976 + .long 0 + .long 3222667264 + .long 1026243227 + .long 1071999268 + .long 19842292 + .long 1014558455 + .long 615820035 + .long 1068925439 + .long 3077235950 + .long 1013851225 + .long 3489660928 + .long 3212767934 + .long 727482074 + .long 3183723353 + .long 1434284591 + .long 3204072020 + .long 1546025314 + .long 1057305153 + .long 3311043419 + .long 3199555764 + .long 1534557980 + .long 3196172205 + .long 1003545269 + .long 1044455453 + .long 982041524 + .long 1039309150 + .long 1046902208 + .long 3183487308 + .long 1293621534 + .long 3176225124 + .long 3225792447 + .long 1026964909 + .long 3923689281 + .long 3166944983 + .long 2903296563 + .long 3165127275 + .long 3175926173 + .long 1011691029 + .long 0 + .long 1075838976 + .long 0 + .long 3222929408 + .long 4209868920 + .long 1072167835 + .long 1271589702 + .long 1014394097 + .long 3991103290 + .long 1068673244 + .long 1964927110 + .long 1013592604 + .long 0 + .long 3212726887 + .long 4238629777 + .long 3183774781 + .long 1807339610 + .long 1059053689 + .long 35311788 + .long 1057028643 + .long 3165087585 + .long 3200229918 + .long 3586452917 + .long 3195213126 + .long 1777317359 + .long 1044610644 + .long 1848687836 + .long 1033934742 + .long 31916095 + .long 3183379115 + .long 185553482 + .long 1029904423 + .long 882484870 + .long 1026631250 + .long 3164391940 + .long 3169115287 + .long 3325423896 + .long 3164355775 + .long 3234707527 + .long 1012695165 + .long 0 + .long 1075838976 + .long 0 + .long 3223191552 + .long 2708123311 + .long 1072305489 + .long 1189046596 + .long 1013601674 + .long 1868283783 + .long 1068367010 + .long 1099775820 + .long 1012435153 + .long 1207959552 + .long 3212582104 + .long 3523250270 + .long 3180953827 + .long 1977223559 + .long 1059998873 + .long 469007091 + .long 1056393187 + .long 17425450 + .long 3200373232 + .long 391965510 + .long 3192157780 + .long 3314858537 + .long 1044490263 + .long 3600399866 + .long 3186407596 + .long 3215068466 + .long 3182787442 + .long 3697861179 + .long 1030898835 + .long 2771081374 + .long 1025463657 + .long 4146920243 + .long 3169520105 + .long 3077194481 + .long 3160459915 + .long 1463264555 + .long 1012730022 + .long 0 + .long 1074790400 + .long 0 + .long 3222405120 + .long 673836129 + .long 1072459181 + .long 1403851199 + .long 1016899858 + .long 3166402837 + .long 1068785305 + .long 375843704 + .long 1012382807 + .long 4026531840 + .long 3214338668 + .long 3760928269 + .long 3186707360 + .long 4037675931 + .long 1063570236 + .long 828875333 + .long 1058841864 + .long 1595734612 + .long 3205457361 + .long 3240025461 + .long 1053807046 + .long 2217213834 + .long 1050913991 + .long 1140208334 + .long 3195581500 + .long 1536578125 + .long 3189218053 + .long 1785608939 + .long 1041425703 + .long 3818468589 + .long 3183948101 + .long 4224809191 + .long 3181546992 + .long 1254902324 + .long 1030336836 + .long 2610385435 + .long 1025933392 + .long 0 + .long 1074790400 + .long 0 + .long 3222667264 + .long 3283395580 + .long 1072584552 + .long 1619691918 + .long 1013495334 + .long 1548049162 + .long 1067830873 + .long 1866614584 + .long 1009528830 + .long 3623878656 + .long 3213753274 + .long 3080383738 + .long 3186326900 + .long 2195737703 + .long 1063532365 + .long 1389581926 + .long 3206495117 + .long 1284275250 + .long 3204405036 + .long 1388678495 + .long 1054257519 + .long 2607787780 + .long 3195486202 + .long 1954028197 + .long 3195106308 + .long 1000142209 + .long 1043978813 + .long 4289390618 + .long 1039480054 + .long 1829994710 + .long 3184933148 + .long 1801900516 + .long 1031672376 + .long 994367613 + .long 1030081754 + .long 1886321575 + .long 3173571539 + .long 0 + .long 1074790400 + .long 0 + .long 3222929408 + .long 996654454 + .long 1072648041 + .long 2055905835 + .long 1016797060 + .long 2025629493 + .long 1066703316 + .long 3207138551 + .long 1007886082 + .long 2684354560 + .long 3212885244 + .long 3640404479 + .long 3184577086 + .long 3785526942 + .long 1063085617 + .long 914780829 + .long 3207165120 + .long 198538566 + .long 3200351555 + .long 743164606 + .long 1053656447 + .long 257739447 + .long 3197719723 + .long 4013344053 + .long 3192054846 + .long 2448984831 + .long 1043799255 + .long 301239699 + .long 3187102807 + .long 4198692195 + .long 3183507635 + .long 252775780 + .long 1033310081 + .long 3936202859 + .long 3174119617 + .long 2832995703 + .long 3173394688 + .long 0 + .long 1074790400 + .long 0 + .long 3223191552 + .long 4009021290 + .long 1072676449 + .long 2313960863 + .long 1015111149 + .long 939498435 + .long 1065430251 + .long 2354454115 + .long 1009400884 + .long 2147483648 + .long 3211794972 + .long 482970327 + .long 3184656008 + .long 3337941139 + .long 1062290385 + .long 1376485817 + .long 3206914838 + .long 3849340321 + .long 1055357361 + .long 3350371102 + .long 1051775129 + .long 2861188266 + .long 3197382603 + .long 2109605468 + .long 1045917685 + .long 3237589551 + .long 1041743271 + .long 485240880 + .long 3187249602 + .long 3692998039 + .long 1035162550 + .long 2284233074 + .long 1031989748 + .long 2141078118 + .long 3176508222 + .long 2775821538 + .long 1021961626 + .long 0 + .long 1073741824 + .long 0 + .long 3222405120 + .long 1979914676 + .long 1072690180 + .long 3909090605 + .long 1014961349 + .long 2850023777 + .long 1064124739 + .long 2716929087 + .long 1007836215 + .long 134217728 + .long 3211818166 + .long 661707185 + .long 3185457101 + .long 511854090 + .long 1063665398 + .long 846761866 + .long 3209923224 + .long 2075885217 + .long 1060492209 + .long 3563065698 + .long 3204958944 + .long 791923268 + .long 3201693745 + .long 905515084 + .long 1053843502 + .long 2412959807 + .long 3198694704 + .long 3378187023 + .long 3192392758 + .long 389556620 + .long 1046549597 + .long 4094604040 + .long 3191327001 + .long 2261901381 + .long 3186206862 + .long 3040498429 + .long 1038898667 + .long 0 + .long 1073741824 + .long 0 + .long 3222667264 + .long 4211364825 + .long 1072693036 + .long 2280492610 + .long 1015654639 + .long 3441679161 + .long 1060320780 + .long 631077559 + .long 1005402779 + .long 2550136832 + .long 3208276561 + .long 952708928 + .long 3179317867 + .long 1724702579 + .long 1060543732 + .long 1940663234 + .long 3207246018 + .long 1617314154 + .long 1058444121 + .long 3218201639 + .long 3204130645 + .long 1677675407 + .long 1054157666 + .long 983365761 + .long 3197588855 + .long 3697581654 + .long 3196234675 + .long 2384146406 + .long 1047319959 + .long 271521235 + .long 3191905541 + .long 1276705943 + .long 3186754722 + .long 2179097654 + .long 1039567487 + .long 301655052 + .long 3184379693 + .long 0 + .long 1073741824 + .long 0 + .long 3222929408 + .long 4193680981 + .long 1072693238 + .long 4060240663 + .long 1015946834 + .long 2365640378 + .long 1055824734 + .long 3526748952 + .long 995134091 + .long 3489660928 + .long 3203980860 + .long 2590051195 + .long 3175384383 + .long 2654771569 + .long 1056549448 + .long 4010094511 + .long 3203581909 + .long 3526856597 + .long 1055166628 + .long 1319720904 + .long 3201385798 + .long 499971761 + .long 1052133367 + .long 2524150070 + .long 3197462343 + .long 3595721810 + .long 1047211062 + .long 32165415 + .long 3189999948 + .long 131183479 + .long 3189246514 + .long 3500428453 + .long 1040184954 + .long 4217742894 + .long 3184647883 + .long 1659999320 + .long 3176152785 + .long 0 + .long 1073741824 + .long 0 + .long 3223191552 + .long 3270603235 + .long 1072693247 + .long 789463291 + .long 1015570140 + .long 3808393842 + .long 1050514289 + .long 2326429486 + .long 994919830 + .long 3221225472 + .long 3198925370 + .long 1345776679 + .long 3171106320 + .long 2968647484 + .long 1051768487 + .long 2248759888 + .long 3199010549 + .long 3387299329 + .long 1050887019 + .long 1430298481 + .long 3197384059 + .long 1348250416 + .long 1048645854 + .long 4055449617 + .long 3194443371 + .long 1237453215 + .long 1045012312 + .long 3542750561 + .long 3190150798 + .long 2477123228 + .long 1039795927 + .long 1515061420 + .long 3182966354 + .long 468112447 + .long 3181397693 + .long 3085255916 + .long 1032264152 + .long 0 + .long 1072693248 + .long 0 + .long 3222405120 + .long 4293196336 + .long 1072693247 + .long 2846765772 + .long 1013778335 + .long 708045282 + .long 1042226741 + .long 3617872673 + .long 984839576 + .long 3758096384 + .long 3191963901 + .long 3393404685 + .long 3164431480 + .long 678234459 + .long 1046059910 + .long 3154637626 + .long 3194706316 + .long 2318517263 + .long 1047966141 + .long 3341209390 + .long 3195954445 + .long 800124789 + .long 1048630880 + .long 2824228362 + .long 3196018487 + .long 785851381 + .long 1048106191 + .long 4129204204 + .long 3195061111 + .long 3370612561 + .long 1046690463 + .long 1422845730 + .long 3193098259 + .long 1920503482 + .long 1044382253 + .long 2798351277 + .long 3189961775 + .long 2515384124 + .long 1072782465 + .long 4217971979 + .long 3222778785 + .long 4294967193 + .long 1072693247 + .long 1248116507 + .long 1015814019 + .long 955504597 + .long 1027630151 + .long 942964606 + .long 972301410 + .long 268435456 + .long 3177488267 + .long 3130289062 + .long 3150952764 + .long 4292327811 + .long 1031864837 + .long 2929831361 + .long 3180636976 + .long 1961758009 + .long 1034139815 + .long 5545144 + .long 3182345703 + .long 485665603 + .long 1035212938 + .long 2600921430 + .long 3182853574 + .long 3983926904 + .long 1035334367 + .long 3203204633 + .long 3182602207 + .long 3287855196 + .long 1034606778 + .long 3286302033 + .long 3181514701 + .long 1856488612 + .long 1033626459 + .long 4001991753 + .long 3180127602 + .long 1346542445 + .long 1072827863 + .long 1342177280 + .long 1072827863 + .long 1147899556 + .long 1041278683 + .long 1744830464 + .long 3218608756 + .long 902814497 + .long 3190299599 + .long 436480833 + .long 1069343474 + .long 824474678 + .long 3214639822 + .long 3302084921 + .long 1064658364 + .long 3780041965 + .long 3209429686 + .long 3655817560 + .long 1059021901 + .long 0 + .long 1282408448 + .long 0 + .long 862978048 + .long 33554432 + .long 1101004800 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .long 0 + .long 256 + .long 1222277045 + .long 929276 + .long 0 + .long 1069547520 + .long 2378786344 + .long 1075294132 + .type _vmldErfHATab,@object + .size _vmldErfHATab,3680 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/erfc.S b/external/sgx_libm/intel64/erfc.S new file mode 100644 index 0000000000..1169a8ac3d --- /dev/null +++ b/external/sgx_libm/intel64/erfc.S @@ -0,0 +1,2064 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfc.c" + .text +..TXTST0: +# -- Begin erfc + .text + .align 16,0x90 + .globl erfc +erfc: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_erfc.1: +..L2: + + movaps %xmm0, %xmm1 + movsd %xmm1, -8(%rsp) + movzwl -2(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2047, %eax + je ..B1.18 +..B1.2: + cmpl $953, %eax + jl ..B1.16 +..B1.3: + lea 5016+_vmldErfcHATab(%rip), %rax + movb -1(%rsp), %dil + comisd (%rax), %xmm1 + jbe ..B1.15 +..B1.4: + lea 4992+_vmldErfcHATab(%rip), %rax + movsd (%rax), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B1.25 +..B1.5: + lea 4968+_vmldErfcHATab(%rip), %rcx + movb %dil, %sil + movsd %xmm1, -48(%rsp) + andb $127, %sil + movb %sil, -41(%rsp) + movsd -48(%rsp), %xmm3 + movsd (%rcx), %xmm2 + movaps %xmm3, %xmm7 + addsd %xmm2, %xmm7 + mulsd %xmm7, %xmm7 + mulsd %xmm7, %xmm7 + movsd %xmm7, -16(%rsp) + movzwl -10(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + lea -1023(%rdx), %esi + lea -3069(%rdx,%rdx,2), %ecx + lea _vmldErfcHATab(%rip), %rdx + lea (,%rcx,8), %eax + lea 1(,%rcx,8), %r9d + lea 23(,%rcx,8), %r10d + movsd (%rdx,%rax,8), %xmm12 + lea 22(,%rcx,8), %r11d + mulsd %xmm3, %xmm12 + lea 21(,%rcx,8), %eax + movsd (%rdx,%r9,8), %xmm4 + movaps %xmm12, %xmm6 + addsd %xmm12, %xmm4 + movsd %xmm4, -40(%rsp) + movsd -40(%rsp), %xmm5 + subsd %xmm5, %xmm6 + movsd %xmm6, -32(%rsp) + movsd -40(%rsp), %xmm9 + movsd -32(%rsp), %xmm8 + addsd %xmm8, %xmm9 + movsd %xmm9, -24(%rsp) + movsd -32(%rsp), %xmm10 + addsd (%rdx,%r9,8), %xmm10 + movsd %xmm10, -32(%rsp) + lea 20(,%rcx,8), %r9d + movsd -24(%rsp), %xmm11 + subsd %xmm11, %xmm12 + movsd (%rdx,%r10,8), %xmm11 + movsd %xmm12, -24(%rsp) + lea 19(,%rcx,8), %r10d + movsd -32(%rsp), %xmm14 + movsd -24(%rsp), %xmm13 + addsd %xmm13, %xmm14 + movsd %xmm14, -24(%rsp) + movsd -40(%rsp), %xmm5 + mulsd %xmm5, %xmm11 + movaps %xmm5, %xmm0 + movaps %xmm5, %xmm15 + addsd (%rdx,%r11,8), %xmm11 + mulsd %xmm5, %xmm15 + mulsd %xmm5, %xmm11 + mulsd %xmm15, %xmm15 + addsd (%rdx,%rax,8), %xmm11 + mulsd %xmm5, %xmm11 + lea 18(,%rcx,8), %eax + movsd -24(%rsp), %xmm6 + lea 16(,%rcx,8), %r11d + movsd %xmm15, -16(%rsp) + addsd (%rdx,%r9,8), %xmm11 + mulsd %xmm5, %xmm11 + lea 17(,%rcx,8), %r9d + addsd (%rdx,%r10,8), %xmm11 + mulsd %xmm5, %xmm11 + lea 12(,%rcx,8), %r10d + movsd (%rdx,%r10,8), %xmm10 + lea 8(,%rcx,8), %r10d + movaps %xmm10, %xmm8 + addsd (%rdx,%rax,8), %xmm11 + mulsd %xmm5, %xmm11 + lea 15(,%rcx,8), %eax + addsd (%rdx,%r9,8), %xmm11 + mulsd %xmm5, %xmm11 + lea 14(,%rcx,8), %r9d + addsd (%rdx,%r11,8), %xmm11 + mulsd %xmm5, %xmm11 + lea 10(,%rcx,8), %r11d + addsd (%rdx,%rax,8), %xmm11 + lea 4944+_vmldErfcHATab(%rip), %rax + movsd (%rax), %xmm7 + mulsd %xmm7, %xmm0 + mulsd %xmm5, %xmm11 + movsd %xmm0, -40(%rsp) + movsd -40(%rsp), %xmm1 + subsd %xmm5, %xmm1 + addsd (%rdx,%r9,8), %xmm11 + movsd %xmm1, -32(%rsp) + lea 13(,%rcx,8), %r9d + movsd -40(%rsp), %xmm3 + movsd -32(%rsp), %xmm15 + mulsd %xmm5, %xmm11 + subsd %xmm15, %xmm3 + movsd %xmm3, -40(%rsp) + addsd %xmm11, %xmm8 + movsd -40(%rsp), %xmm4 + movsd (%rdx,%r11,8), %xmm15 + lea 6(,%rcx,8), %r11d + subsd %xmm4, %xmm5 + movsd %xmm5, -32(%rsp) + movsd -40(%rsp), %xmm0 + movsd -32(%rsp), %xmm1 + movsd %xmm8, -40(%rsp) + addsd %xmm6, %xmm1 + movsd -40(%rsp), %xmm9 + subsd %xmm9, %xmm10 + addsd %xmm10, %xmm11 + movsd %xmm11, -32(%rsp) + movsd -40(%rsp), %xmm3 + movaps %xmm3, %xmm12 + mulsd %xmm7, %xmm12 + movsd -32(%rsp), %xmm4 + movsd %xmm12, -40(%rsp) + movsd -40(%rsp), %xmm13 + subsd %xmm3, %xmm13 + addsd (%rdx,%r9,8), %xmm4 + movsd %xmm13, -32(%rsp) + lea 11(,%rcx,8), %r9d + movsd -40(%rsp), %xmm12 + movsd -32(%rsp), %xmm14 + subsd %xmm14, %xmm12 + movsd %xmm12, -40(%rsp) + movsd -40(%rsp), %xmm13 + subsd %xmm13, %xmm3 + movsd %xmm3, -32(%rsp) + movsd -40(%rsp), %xmm5 + movsd -32(%rsp), %xmm6 + movaps %xmm5, %xmm11 + mulsd %xmm1, %xmm5 + addsd %xmm4, %xmm6 + mulsd %xmm0, %xmm11 + movaps %xmm6, %xmm8 + movaps %xmm11, %xmm9 + mulsd %xmm1, %xmm8 + addsd %xmm15, %xmm9 + mulsd %xmm0, %xmm6 + addsd %xmm5, %xmm8 + addsd %xmm6, %xmm8 + movsd %xmm8, -40(%rsp) + movsd -40(%rsp), %xmm14 + movsd %xmm9, -40(%rsp) + movsd -40(%rsp), %xmm10 + subsd %xmm10, %xmm15 + addsd %xmm11, %xmm15 + movsd %xmm15, -32(%rsp) + movsd -40(%rsp), %xmm8 + movaps %xmm8, %xmm3 + mulsd %xmm7, %xmm3 + movsd -32(%rsp), %xmm11 + movsd %xmm3, -40(%rsp) + movaps %xmm0, %xmm3 + movsd -40(%rsp), %xmm4 + addsd %xmm14, %xmm11 + subsd %xmm8, %xmm4 + addsd (%rdx,%r9,8), %xmm11 + movsd %xmm4, -32(%rsp) + lea 9(,%rcx,8), %r9d + movsd -40(%rsp), %xmm5 + movsd -32(%rsp), %xmm14 + movsd (%rdx,%r10,8), %xmm4 + lea 4(,%rcx,8), %r10d + subsd %xmm14, %xmm5 + movsd %xmm5, -40(%rsp) + movsd -40(%rsp), %xmm6 + subsd %xmm6, %xmm8 + movsd %xmm8, -32(%rsp) + movsd -40(%rsp), %xmm10 + movsd -32(%rsp), %xmm9 + mulsd %xmm10, %xmm3 + addsd %xmm9, %xmm11 + mulsd %xmm1, %xmm10 + movaps %xmm11, %xmm12 + movaps %xmm3, %xmm13 + mulsd %xmm1, %xmm12 + addsd %xmm4, %xmm13 + mulsd %xmm0, %xmm11 + addsd %xmm10, %xmm12 + addsd %xmm11, %xmm12 + movsd %xmm12, -40(%rsp) + movsd -40(%rsp), %xmm5 + movsd %xmm13, -40(%rsp) + movsd -40(%rsp), %xmm15 + subsd %xmm15, %xmm4 + addsd %xmm3, %xmm4 + movsd %xmm4, -32(%rsp) + movsd -40(%rsp), %xmm12 + movaps %xmm12, %xmm6 + mulsd %xmm7, %xmm6 + movsd -32(%rsp), %xmm3 + movsd %xmm6, -40(%rsp) + movaps %xmm0, %xmm6 + movsd -40(%rsp), %xmm8 + addsd %xmm5, %xmm3 + subsd %xmm12, %xmm8 + addsd (%rdx,%r9,8), %xmm3 + movsd %xmm8, -32(%rsp) + lea 7(,%rcx,8), %r9d + movsd -40(%rsp), %xmm10 + movsd -32(%rsp), %xmm9 + movsd (%rdx,%r11,8), %xmm8 + lea 2(,%rcx,8), %r11d + subsd %xmm9, %xmm10 + movsd %xmm10, -40(%rsp) + movsd -40(%rsp), %xmm11 + subsd %xmm11, %xmm12 + movsd %xmm12, -32(%rsp) + movsd -40(%rsp), %xmm14 + movsd -32(%rsp), %xmm13 + mulsd %xmm14, %xmm6 + addsd %xmm13, %xmm3 + mulsd %xmm1, %xmm14 + movaps %xmm3, %xmm4 + movaps %xmm6, %xmm5 + mulsd %xmm1, %xmm4 + addsd %xmm8, %xmm5 + mulsd %xmm0, %xmm3 + addsd %xmm14, %xmm4 + addsd %xmm3, %xmm4 + movsd %xmm4, -40(%rsp) + movsd -40(%rsp), %xmm3 + movsd %xmm5, -40(%rsp) + movsd -40(%rsp), %xmm15 + subsd %xmm15, %xmm8 + addsd %xmm6, %xmm8 + movsd %xmm8, -32(%rsp) + movaps %xmm0, %xmm8 + movsd -40(%rsp), %xmm12 + movaps %xmm12, %xmm9 + mulsd %xmm7, %xmm9 + movsd -32(%rsp), %xmm6 + movsd %xmm9, -40(%rsp) + addsd %xmm3, %xmm6 + movsd -40(%rsp), %xmm10 + movsd (%rdx,%r10,8), %xmm9 + subsd %xmm12, %xmm10 + addsd (%rdx,%r9,8), %xmm6 + movsd %xmm10, -32(%rsp) + lea 5(,%rcx,8), %r9d + movsd -40(%rsp), %xmm11 + movsd -32(%rsp), %xmm4 + subsd %xmm4, %xmm11 + movsd %xmm11, -40(%rsp) + movsd -40(%rsp), %xmm5 + subsd %xmm5, %xmm12 + movsd %xmm12, -32(%rsp) + movsd -40(%rsp), %xmm3 + movsd -32(%rsp), %xmm13 + mulsd %xmm3, %xmm8 + addsd %xmm13, %xmm6 + mulsd %xmm1, %xmm3 + movaps %xmm6, %xmm4 + movaps %xmm8, %xmm5 + mulsd %xmm1, %xmm4 + addsd %xmm9, %xmm5 + mulsd %xmm0, %xmm6 + addsd %xmm3, %xmm4 + addsd %xmm6, %xmm4 + movsd %xmm4, -40(%rsp) + movsd -40(%rsp), %xmm15 + movsd %xmm5, -40(%rsp) + movsd -40(%rsp), %xmm14 + subsd %xmm14, %xmm9 + addsd %xmm8, %xmm9 + movsd %xmm9, -32(%rsp) + movsd -40(%rsp), %xmm4 + movaps %xmm4, %xmm10 + mulsd %xmm7, %xmm10 + movsd -32(%rsp), %xmm8 + movsd %xmm10, -40(%rsp) + movaps %xmm0, %xmm10 + movsd -40(%rsp), %xmm11 + addsd %xmm15, %xmm8 + subsd %xmm4, %xmm11 + addsd (%rdx,%r9,8), %xmm8 + movsd %xmm11, -32(%rsp) + movsd -40(%rsp), %xmm12 + movsd -32(%rsp), %xmm15 + subsd %xmm15, %xmm12 + movsd %xmm12, -40(%rsp) + movsd -40(%rsp), %xmm3 + subsd %xmm3, %xmm4 + movsd (%rdx,%r11,8), %xmm3 + movsd %xmm4, -32(%rsp) + movsd -40(%rsp), %xmm6 + movsd -32(%rsp), %xmm5 + mulsd %xmm6, %xmm10 + addsd %xmm5, %xmm8 + movaps %xmm8, %xmm9 + mulsd %xmm1, %xmm9 + mulsd %xmm6, %xmm1 + mulsd %xmm8, %xmm0 + addsd %xmm1, %xmm9 + addsd %xmm0, %xmm9 + movaps %xmm10, %xmm0 + addsd %xmm3, %xmm0 + movsd %xmm9, -40(%rsp) + movsd -40(%rsp), %xmm4 + movsd %xmm0, -40(%rsp) + movsd -40(%rsp), %xmm1 + subsd %xmm1, %xmm3 + addsd %xmm10, %xmm3 + movsd %xmm3, -32(%rsp) + movsd -40(%rsp), %xmm6 + movsd -32(%rsp), %xmm5 + addsd %xmm4, %xmm5 +..B1.28: + movaps %xmm6, %xmm1 + lea 3(,%rcx,8), %ecx + movsd (%rdx,%rcx,8), %xmm0 + cmpl $6, %esi + addsd %xmm0, %xmm5 + addsd %xmm5, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm3 + subsd %xmm3, %xmm6 + addsd %xmm5, %xmm6 + movsd %xmm6, -32(%rsp) + movsd -40(%rsp), %xmm1 + movsd -32(%rsp), %xmm0 + jae ..B1.7 +..B1.6: + movsd %xmm2, -48(%rsp) + jmp ..B1.8 +..B1.7: + movaps %xmm7, %xmm8 + lea 4976+_vmldErfcHATab(%rip), %r8 + mulsd %xmm1, %xmm8 + lea 4920+_vmldErfcHATab(%rip), %rcx + movsd %xmm8, -40(%rsp) + lea 4936+_vmldErfcHATab(%rip), %rsi + movsd -40(%rsp), %xmm9 + lea 4904+_vmldErfcHATab(%rip), %r9 + movsd -8(%rsp), %xmm4 + lea 4912+_vmldErfcHATab(%rip), %r10 + movaps %xmm4, %xmm14 + lea 3872+_vmldErfcHATab(%rip), %r11 + mulsd (%rax), %xmm14 + subsd %xmm1, %xmm9 + movsd %xmm9, -32(%rsp) + movsd -40(%rsp), %xmm11 + movsd -32(%rsp), %xmm10 + subsd %xmm10, %xmm11 + movsd %xmm11, -40(%rsp) + movsd -40(%rsp), %xmm12 + movsd (%rcx), %xmm11 + lea 3864+_vmldErfcHATab(%rip), %rcx + subsd %xmm12, %xmm1 + movsd (%r9), %xmm12 + movsd %xmm1, -32(%rsp) + lea 3848+_vmldErfcHATab(%rip), %r9 + movsd -40(%rsp), %xmm6 + movsd -32(%rsp), %xmm13 + movsd %xmm14, -40(%rsp) + addsd %xmm13, %xmm0 + movsd -40(%rsp), %xmm15 + subsd -8(%rsp), %xmm15 + movsd %xmm15, -32(%rsp) + movsd -40(%rsp), %xmm1 + movsd -32(%rsp), %xmm2 + subsd %xmm2, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm3 + subsd %xmm3, %xmm4 + movsd %xmm4, -32(%rsp) + movsd -40(%rsp), %xmm8 + movaps %xmm8, %xmm5 + mulsd %xmm8, %xmm5 + movsd -32(%rsp), %xmm9 + mulsd %xmm9, %xmm8 + mulsd %xmm9, %xmm9 + movsd (%r8), %xmm4 + addsd %xmm8, %xmm9 + mulsd %xmm4, %xmm5 + addsd %xmm8, %xmm9 + mulsd %xmm5, %xmm11 + movsd %xmm9, -40(%rsp) + movsd -40(%rsp), %xmm10 + mulsd %xmm10, %xmm4 + addsd (%rsi), %xmm11 + movsd %xmm11, -56(%rsp) + movsd -56(%rsp), %xmm3 + movl -56(%rsp), %r8d + movl %r8d, %eax + andl $63, %eax + subsd (%rsi), %xmm3 + mulsd %xmm3, %xmm12 + lea 3856+_vmldErfcHATab(%rip), %rsi + xorps .L_2il0floatpacket.166(%rip), %xmm3 + subsd %xmm12, %xmm5 + mulsd (%r10), %xmm3 + movaps %xmm5, %xmm13 + movaps %xmm5, %xmm2 + lea 3840+_vmldErfcHATab(%rip), %r10 + addsd %xmm3, %xmm13 + movsd %xmm13, -40(%rsp) + movsd -40(%rsp), %xmm14 + shrl $6, %r8d + subsd %xmm14, %xmm2 + movsd %xmm2, -32(%rsp) + addl $1023, %r8d + movsd -40(%rsp), %xmm1 + movsd -32(%rsp), %xmm15 + addsd %xmm15, %xmm1 + movsd %xmm1, -24(%rsp) + movsd -32(%rsp), %xmm2 + addsd %xmm2, %xmm3 + movsd %xmm3, -32(%rsp) + movsd -24(%rsp), %xmm8 + subsd %xmm8, %xmm5 + movsd %xmm5, -24(%rsp) + movsd -32(%rsp), %xmm2 + movsd -24(%rsp), %xmm5 + addsd %xmm5, %xmm2 + movsd %xmm2, -24(%rsp) + movsd -40(%rsp), %xmm12 + movaps %xmm12, %xmm1 + movaps %xmm12, %xmm8 + movsd -24(%rsp), %xmm3 + addsd %xmm4, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm5 + subsd %xmm5, %xmm8 + movsd (%r11), %xmm5 + movsd %xmm8, -32(%rsp) + movaps %xmm7, %xmm8 + movsd -40(%rsp), %xmm10 + lea 485(%rax,%rax), %r11d + movsd -32(%rsp), %xmm9 + lea 486(%rax,%rax), %eax + addsd %xmm9, %xmm10 + movsd %xmm10, -24(%rsp) + movsd -32(%rsp), %xmm11 + addsd %xmm11, %xmm4 + movsd %xmm4, -32(%rsp) + movsd -24(%rsp), %xmm4 + subsd %xmm4, %xmm12 + movsd %xmm12, -24(%rsp) + movsd -32(%rsp), %xmm14 + movsd -24(%rsp), %xmm13 + addsd %xmm13, %xmm14 + movsd %xmm14, -24(%rsp) + movsd -40(%rsp), %xmm4 + mulsd %xmm4, %xmm5 + movaps %xmm4, %xmm2 + movsd -24(%rsp), %xmm15 + addsd (%rcx), %xmm5 + movl %r8d, %ecx + addsd %xmm15, %xmm3 + mulsd %xmm4, %xmm5 + andl $2047, %ecx + addsd (%rsi), %xmm5 + mulsd %xmm4, %xmm5 + shll $4, %ecx + addsd (%r9), %xmm5 + mulsd %xmm4, %xmm5 + addsd (%r10), %xmm5 + mulsd %xmm4, %xmm5 + mulsd %xmm4, %xmm5 + addsd %xmm5, %xmm2 + movsd %xmm2, -32(%rsp) + movsd -32(%rsp), %xmm1 + subsd %xmm1, %xmm5 + addsd %xmm4, %xmm5 + movsd %xmm5, -24(%rsp) + movsd -32(%rsp), %xmm13 + mulsd %xmm13, %xmm8 + movsd -24(%rsp), %xmm1 + movsd %xmm8, -40(%rsp) + movsd -40(%rsp), %xmm9 + movsd (%rdx,%r11,8), %xmm5 + subsd %xmm13, %xmm9 + movsd %xmm9, -32(%rsp) + movsd -40(%rsp), %xmm11 + movsd -32(%rsp), %xmm10 + subsd %xmm10, %xmm11 + movsd %xmm11, -40(%rsp) + movsd -40(%rsp), %xmm12 + subsd %xmm12, %xmm13 + movaps %xmm5, %xmm12 + movsd %xmm13, -32(%rsp) + movsd -40(%rsp), %xmm2 + movsd -32(%rsp), %xmm14 + mulsd %xmm2, %xmm12 + addsd %xmm14, %xmm1 + movaps %xmm12, %xmm8 + addsd %xmm3, %xmm1 + movsd (%rdx,%rax,8), %xmm3 + movaps %xmm3, %xmm4 + mulsd %xmm1, %xmm4 + mulsd %xmm5, %xmm1 + addsd %xmm12, %xmm5 + mulsd %xmm3, %xmm2 + addsd %xmm1, %xmm4 + addsd %xmm2, %xmm4 + movsd %xmm4, -40(%rsp) + movsd -40(%rsp), %xmm2 + movsd %xmm5, -40(%rsp) + movsd -40(%rsp), %xmm1 + subsd %xmm1, %xmm8 + movaps %xmm7, %xmm1 + movsd %xmm8, -32(%rsp) + movsd -40(%rsp), %xmm9 + movsd -32(%rsp), %xmm3 + addsd %xmm3, %xmm9 + movsd %xmm9, -24(%rsp) + movsd -32(%rsp), %xmm10 + addsd (%rdx,%r11,8), %xmm10 + movsd %xmm10, -32(%rsp) + movsd -24(%rsp), %xmm11 + subsd %xmm11, %xmm12 + movsd %xmm12, -24(%rsp) + movsd -32(%rsp), %xmm14 + movsd -24(%rsp), %xmm13 + addsd %xmm13, %xmm14 + movsd %xmm14, -24(%rsp) + movsd -40(%rsp), %xmm8 + mulsd %xmm8, %xmm1 + movsd -24(%rsp), %xmm15 + movsd %xmm1, -40(%rsp) + movaps %xmm6, %xmm1 + movsd -40(%rsp), %xmm3 + subsd %xmm8, %xmm3 + addsd (%rdx,%rax,8), %xmm15 + movsd %xmm3, -32(%rsp) + addsd %xmm15, %xmm2 + movsd -40(%rsp), %xmm4 + lea 4952+_vmldErfcHATab(%rip), %rdx + movsd -32(%rsp), %xmm15 + subsd %xmm15, %xmm4 + movsd %xmm4, -40(%rsp) + movsd -40(%rsp), %xmm5 + movq (%rdx), %rax + subsd %xmm5, %xmm8 + movsd %xmm8, -32(%rsp) + movsd -40(%rsp), %xmm10 + movsd -32(%rsp), %xmm9 + mulsd %xmm10, %xmm1 + addsd %xmm9, %xmm2 + mulsd %xmm0, %xmm10 + movaps %xmm2, %xmm11 + mulsd %xmm0, %xmm11 + mulsd %xmm6, %xmm2 + movq %rax, -48(%rsp) + addsd %xmm2, %xmm11 + shrq $48, %rax + addsd %xmm10, %xmm11 + andl $-32753, %eax + movsd %xmm11, -40(%rsp) + orl %ecx, %eax + movsd -40(%rsp), %xmm0 + movw %ax, -42(%rsp) +..B1.8: + andb $-128, %dil + cmpb $-128, %dil + je ..B1.17 +..B1.9: + lea 5008+_vmldErfcHATab(%rip), %rax + movsd -8(%rsp), %xmm3 + movsd (%rax), %xmm2 + comisd %xmm3, %xmm2 + jbe ..B1.11 +..B1.10: + addsd %xmm1, %xmm0 + mulsd -48(%rsp), %xmm0 + ret +..B1.11: + lea 4952+_vmldErfcHATab(%rip), %rax + addl $200, %r8d + andl $2047, %r8d + lea 5000+_vmldErfcHATab(%rip), %rcx + shll $4, %r8d + movq (%rax), %rdx + movq %rdx, -48(%rsp) + shrq $48, %rdx + andl $-32753, %edx + orl %r8d, %edx + movw %dx, -42(%rsp) + movsd -48(%rsp), %xmm2 + mulsd %xmm2, %xmm1 + comisd (%rcx), %xmm3 + mulsd %xmm2, %xmm0 + jbe ..B1.13 +..B1.12: + lea 4928+_vmldErfcHATab(%rip), %rax + addsd %xmm1, %xmm0 + mulsd (%rax), %xmm0 + movaps %xmm0, %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm2 + addsd %xmm2, %xmm0 + ret +..B1.13: + movaps %xmm0, %xmm2 + lea 4928+_vmldErfcHATab(%rip), %rax + addsd %xmm1, %xmm2 + movsd %xmm2, -40(%rsp) + movsd -40(%rsp), %xmm3 + subsd %xmm3, %xmm1 + addsd %xmm0, %xmm1 + movsd %xmm1, -32(%rsp) + movsd -40(%rsp), %xmm5 + mulsd %xmm5, %xmm7 + movsd -32(%rsp), %xmm9 + movsd %xmm7, -40(%rsp) + movsd -40(%rsp), %xmm0 + subsd %xmm5, %xmm0 + movsd %xmm0, -32(%rsp) + movsd -40(%rsp), %xmm1 + movsd -32(%rsp), %xmm7 + subsd %xmm7, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm4 + subsd %xmm4, %xmm5 + movsd %xmm5, -32(%rsp) + movsd -40(%rsp), %xmm8 + movsd -32(%rsp), %xmm6 + mulsd (%rax), %xmm8 + addsd %xmm6, %xmm9 + mulsd (%rax), %xmm9 + movsd %xmm8, -40(%rsp) + movsd %xmm9, -32(%rsp) + movsd -40(%rsp), %xmm0 + movsd -32(%rsp), %xmm10 + addsd %xmm10, %xmm0 +..B1.14: + ret +..B1.15: + lea 4984+_vmldErfcHATab(%rip), %rax + lea 4928+_vmldErfcHATab(%rip), %rdx + movsd (%rax), %xmm0 + subsd (%rdx), %xmm0 + ret +..B1.16: + lea 4968+_vmldErfcHATab(%rip), %rax + movsd (%rax), %xmm0 + addsd -8(%rsp), %xmm0 + ret +..B1.17: + movsd -48(%rsp), %xmm2 + lea 4984+_vmldErfcHATab(%rip), %rax + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm0 + movsd (%rax), %xmm5 + xorps .L_2il0floatpacket.166(%rip), %xmm1 + movaps %xmm5, %xmm3 + xorps .L_2il0floatpacket.166(%rip), %xmm0 + addsd %xmm1, %xmm3 + movsd %xmm3, -40(%rsp) + movsd -40(%rsp), %xmm4 + subsd %xmm4, %xmm5 + addsd %xmm1, %xmm5 + movsd %xmm5, -32(%rsp) + movsd -40(%rsp), %xmm11 + movaps %xmm11, %xmm1 + movaps %xmm11, %xmm7 + movsd -32(%rsp), %xmm14 + addsd %xmm0, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm6 + subsd %xmm6, %xmm7 + movsd %xmm7, -32(%rsp) + movsd -40(%rsp), %xmm9 + movsd -32(%rsp), %xmm8 + addsd %xmm8, %xmm9 + movsd %xmm9, -24(%rsp) + movsd -32(%rsp), %xmm10 + addsd %xmm10, %xmm0 + movsd %xmm0, -32(%rsp) + movsd -24(%rsp), %xmm0 + subsd %xmm0, %xmm11 + movsd %xmm11, -24(%rsp) + movsd -32(%rsp), %xmm13 + movsd -24(%rsp), %xmm12 + addsd %xmm12, %xmm13 + movsd %xmm13, -24(%rsp) + movsd -40(%rsp), %xmm15 + movsd -24(%rsp), %xmm0 + addsd %xmm14, %xmm0 + addsd %xmm15, %xmm0 + ret +..B1.18: + testl $1048575, -4(%rsp) + jne ..B1.23 +..B1.19: + cmpl $0, -8(%rsp) + jne ..B1.23 +..B1.20: + movb -1(%rsp), %al + andb $-128, %al + cmpb $-128, %al + je ..B1.24 +..B1.21: + lea 4952+_vmldErfcHATab(%rip), %rax + movsd (%rax), %xmm0 +..B1.22: + ret +..B1.23: + movsd -8(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + ret +..B1.24: + lea 4984+_vmldErfcHATab(%rip), %rax + movsd (%rax), %xmm0 + ret +..B1.25: + lea 4960+_vmldErfcHATab(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type erfc,@function + .size erfc,.-erfc + .data +# -- End erfc + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.166: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.166,@object + .size .L_2il0floatpacket.166,16 + .align 8 +_vmldErfcHATab: + .long 0 + .long 1074790400 + .long 0 + .long 3219128320 + .long 2536042781 + .long 1072398983 + .long 1399772821 + .long 1016356498 + .long 2716363190 + .long 3218196015 + .long 2515012741 + .long 3161253520 + .long 2716363190 + .long 1065469487 + .long 2240747611 + .long 1008526987 + .long 3687592758 + .long 1064760658 + .long 803907102 + .long 1004882786 + .long 3448634865 + .long 3207698121 + .long 750050903 + .long 3152352039 + .long 601957364 + .long 3206196134 + .long 1555639211 + .long 3149699171 + .long 1774552010 + .long 1054291178 + .long 3884532135 + .long 1052283480 + .long 3233761315 + .long 3195467393 + .long 1379327181 + .long 3193076019 + .long 242623580 + .long 1041378609 + .long 2275269623 + .long 1038572401 + .long 254615366 + .long 3181902490 + .long 2447494219 + .long 3178851847 + .long 604424981 + .long 1027296749 + .long 50341065 + .long 1024134801 + .long 0 + .long 1073741824 + .long 0 + .long 3219390464 + .long 1599080160 + .long 1071977136 + .long 688395245 + .long 1016124311 + .long 3971924631 + .long 3219152851 + .long 3564228032 + .long 3163583509 + .long 3891163965 + .long 1068791752 + .long 3480798202 + .long 1012474408 + .long 1621928818 + .long 1067553147 + .long 4020082186 + .long 1012007724 + .long 685042962 + .long 3213042343 + .long 3489060295 + .long 3153732341 + .long 2848795668 + .long 3210759248 + .long 3762448119 + .long 3156070926 + .long 1324211555 + .long 1061670518 + .long 1476477459 + .long 1058441900 + .long 2515812913 + .long 3204852392 + .long 3304760842 + .long 3200696323 + .long 716797578 + .long 1052801360 + .long 2283992921 + .long 1047370885 + .long 2268754290 + .long 3195296397 + .long 1012519479 + .long 3185657836 + .long 944669356 + .long 1042638534 + .long 1931303816 + .long 3183131001 + .long 0 + .long 1072693248 + .long 0 + .long 3219390464 + .long 1180573078 + .long 1071127762 + .long 4113175178 + .long 1014965748 + .long 2484292509 + .long 3219680918 + .long 959898156 + .long 3163955503 + .long 957881989 + .long 1071548988 + .long 442195505 + .long 1012747532 + .long 35029730 + .long 1068269829 + .long 976783580 + .long 1012161104 + .long 2319046290 + .long 3217462844 + .long 10747389 + .long 3161497233 + .long 3758081287 + .long 1067192898 + .long 1126055042 + .long 1009745370 + .long 1760060230 + .long 1067789094 + .long 3251266701 + .long 3213655257 + .long 2806967453 + .long 3212534516 + .long 1864685761 + .long 1064158132 + .long 3738348856 + .long 1061687624 + .long 790737257 + .long 3209050005 + .long 1943644508 + .long 3204796481 + .long 2914584687 + .long 1058674792 + .long 2574038108 + .long 3201168805 + .long 1252008665 + .long 3203024355 + .long 0 + .long 1071644672 + .long 0 + .long 3219390464 + .long 866709712 + .long 1068743889 + .long 2877058776 + .long 1013060082 + .long 4210332368 + .long 3219015250 + .long 1459199107 + .long 3163298467 + .long 3688727889 + .long 1072884723 + .long 2792291460 + .long 1014241070 + .long 855534605 + .long 3220533712 + .long 759913640 + .long 3163946628 + .long 2131284961 + .long 1069103746 + .long 2597396527 + .long 1013374934 + .long 989201780 + .long 1073227786 + .long 3318708226 + .long 1013855758 + .long 699280746 + .long 3220558000 + .long 993015799 + .long 3218982987 + .long 1559561232 + .long 1073166816 + .long 680189340 + .long 3219046342 + .long 3200850606 + .long 3220010182 + .long 1492278808 + .long 1071125031 + .long 4108347350 + .long 3218518333 + .long 2186414716 + .long 3220448795 + .long 2803204773 + .long 3219471098 + .long 1021304598 + .long 3216041452 + .long 0 + .long 1072693248 + .long 0 + .long 3220701184 + .long 2395493008 + .long 1067539114 + .long 2347713276 + .long 1010696759 + .long 649597580 + .long 3216929335 + .long 3715599898 + .long 3160841752 + .long 1561014649 + .long 1069995433 + .long 3047088181 + .long 1014230941 + .long 735510274 + .long 3217146528 + .long 1352249772 + .long 3161795800 + .long 1629994682 + .long 1067898281 + .long 867814168 + .long 1012540688 + .long 3242132826 + .long 1066299959 + .long 1473115860 + .long 1010684527 + .long 1350993397 + .long 3214133819 + .long 212467593 + .long 1064529314 + .long 1581296174 + .long 1063476333 + .long 1019617056 + .long 3210475870 + .long 326531339 + .long 1058667915 + .long 2560102974 + .long 1060207995 + .long 1059830545 + .long 3205421344 + .long 73331091 + .long 1053435953 + .long 3519680827 + .long 1056963274 + .long 287235298 + .long 1054771565 + .long 0 + .long 1072693248 + .long 0 + .long 3220701184 + .long 2395492868 + .long 1067539114 + .long 3682704431 + .long 1012674156 + .long 649602216 + .long 3216929335 + .long 3411089016 + .long 3161142609 + .long 1560943486 + .long 1069995433 + .long 373233254 + .long 1014373936 + .long 736848572 + .long 3217146528 + .long 1866442275 + .long 3160326248 + .long 1560943474 + .long 1067898281 + .long 3576330307 + .long 1009307384 + .long 649623715 + .long 1066299959 + .long 725533065 + .long 1006865126 + .long 1925526991 + .long 3214133821 + .long 2782059224 + .long 1064529267 + .long 3902564706 + .long 1063475940 + .long 2706862450 + .long 3210478464 + .long 1817950372 + .long 1058560819 + .long 1279984267 + .long 1060154640 + .long 1456324877 + .long 3205782300 + .long 3219859931 + .long 3203609651 + .long 1354896425 + .long 1055916872 + .long 153053737 + .long 3200605489 + .long 0 + .long 1070596096 + .long 0 + .long 3219390464 + .long 4088869944 + .long 1070267315 + .long 2176293176 + .long 1014815941 + .long 2130816332 + .long 3218278509 + .long 1120272801 + .long 3163324298 + .long 2812844367 + .long 1071221080 + .long 3953643227 + .long 1013638927 + .long 1988706352 + .long 3219153696 + .long 4268394231 + .long 3159871631 + .long 1288160248 + .long 1071920576 + .long 2922427679 + .long 1016153595 + .long 2977979581 + .long 3219655118 + .long 3750808263 + .long 3157405326 + .long 985562119 + .long 1072408739 + .long 2519169024 + .long 3220102519 + .long 68429100 + .long 1072741226 + .long 3577866702 + .long 3220290005 + .long 2564607388 + .long 1072813459 + .long 2939200104 + .long 3220467302 + .long 4218579581 + .long 1071794210 + .long 1377164546 + .long 3221614222 + .long 2324734477 + .long 3221337613 + .long 1839603542 + .long 3222378369 + .long 0 + .long 1071644672 + .long 0 + .long 3220701184 + .long 2099420460 + .long 1070000514 + .long 2802853043 + .long 1014611496 + .long 1293201774 + .long 3216758446 + .long 754100791 + .long 3161260779 + .long 446218444 + .long 1068516350 + .long 4119686598 + .long 1008896294 + .long 464017249 + .long 3215087878 + .long 960597079 + .long 3159504610 + .long 785622302 + .long 1066666444 + .long 3339954945 + .long 1008950591 + .long 2636124640 + .long 3213180396 + .long 2995891561 + .long 3157221870 + .long 742584182 + .long 1064691513 + .long 2101069570 + .long 3211133521 + .long 2181624698 + .long 1062573543 + .long 880779555 + .long 3208950245 + .long 3229614298 + .long 1060332156 + .long 2776250631 + .long 3206681158 + .long 1726624674 + .long 1057845172 + .long 2932756839 + .long 3204700218 + .long 968482455 + .long 3200538336 + .long 839487434 + .long 3203407115 + .long 0 + .long 1071644672 + .long 0 + .long 3220701184 + .long 2099420460 + .long 1070000514 + .long 3971839787 + .long 1014611494 + .long 1293201774 + .long 3216758446 + .long 1164040504 + .long 3161242013 + .long 446218443 + .long 1068516350 + .long 752423430 + .long 1013624741 + .long 464016831 + .long 3215087878 + .long 1037460728 + .long 3159893622 + .long 785625671 + .long 1066666444 + .long 2777520670 + .long 1010462846 + .long 2633474472 + .long 3213180396 + .long 224500896 + .long 3158129422 + .long 768707698 + .long 1064691513 + .long 3292721506 + .long 3211133520 + .long 578140564 + .long 1062573549 + .long 2030948072 + .long 3208950024 + .long 703221627 + .long 1060333354 + .long 3302679767 + .long 3206661604 + .long 1902201635 + .long 1057974954 + .long 4048348141 + .long 3204024333 + .long 436255103 + .long 1054912980 + .long 2856127569 + .long 3199800416 + .long 0 + .long 1069547520 + .long 0 + .long 3219390464 + .long 2660514860 + .long 1069307683 + .long 3910050887 + .long 1010798723 + .long 1232972210 + .long 3217414211 + .long 3319476861 + .long 3162069233 + .long 728349866 + .long 1070632184 + .long 2957516014 + .long 1014996223 + .long 2614894425 + .long 3218648001 + .long 3908389506 + .long 3161696982 + .long 2191212410 + .long 1071782386 + .long 2431020086 + .long 1016759180 + .long 3218723210 + .long 3219794568 + .long 3000611168 + .long 3164060285 + .long 3635880648 + .long 1072866249 + .long 536114836 + .long 3220846078 + .long 772319782 + .long 1073876386 + .long 455323837 + .long 3221871435 + .long 2867783196 + .long 1074413781 + .long 2591697711 + .long 3223680483 + .long 3707131585 + .long 3224082365 + .long 1191412344 + .long 3226597368 + .long 26961465 + .long 3227158611 + .long 3399174677 + .long 3227576866 + .long 0 + .long 1070596096 + .long 0 + .long 3220701184 + .long 2223626006 + .long 1069006900 + .long 1459366060 + .long 1012973801 + .long 1839010552 + .long 3215906806 + .long 2068820260 + .long 3160057563 + .long 1249919926 + .long 1067698038 + .long 962503917 + .long 1012536115 + .long 2100991944 + .long 3214479466 + .long 3825857555 + .long 3158728160 + .long 2359368913 + .long 1066362061 + .long 743880428 + .long 1009085061 + .long 1096261871 + .long 3213062353 + .long 3975107283 + .long 3156829710 + .long 3079668469 + .long 1064816845 + .long 1037052812 + .long 3211583355 + .long 3759245614 + .long 1063340491 + .long 3200735738 + .long 3210008934 + .long 4161299971 + .long 1061559762 + .long 2934206128 + .long 3208900975 + .long 3971101203 + .long 3206549768 + .long 353687358 + .long 3209069242 + .long 3047695518 + .long 3208432442 + .long 3851119497 + .long 3207872727 + .long 0 + .long 1070596096 + .long 0 + .long 3220701184 + .long 2223626017 + .long 1069006900 + .long 1388676355 + .long 1012705760 + .long 1839008253 + .long 3215906806 + .long 815236617 + .long 3160082992 + .long 1250030689 + .long 1067698038 + .long 1288166708 + .long 1012882161 + .long 2094505532 + .long 3214479466 + .long 311037013 + .long 3156914212 + .long 2617751546 + .long 1066362061 + .long 2536920761 + .long 1010241475 + .long 1679260317 + .long 3213062352 + .long 3392965897 + .long 3157018830 + .long 1054244789 + .long 1064816864 + .long 3966408696 + .long 3211583052 + .long 1854848819 + .long 1063342388 + .long 3813743082 + .long 3209990587 + .long 395181184 + .long 1061696008 + .long 2456810233 + .long 3208392808 + .long 4089464644 + .long 1060125482 + .long 3698050549 + .long 3206684252 + .long 1112347086 + .long 1058131030 + .long 218099662 + .long 3203798608 + .long 0 + .long 1068498944 + .long 0 + .long 3219390464 + .long 525966855 + .long 1068285571 + .long 2606587153 + .long 1012297682 + .long 2443413391 + .long 3216426332 + .long 691043050 + .long 3159699549 + .long 1829248673 + .long 1069675485 + .long 797308607 + .long 1013894531 + .long 2897861001 + .long 3217829064 + .long 3729653017 + .long 3162035037 + .long 3517114205 + .long 1070988945 + .long 2096268315 + .long 1015157641 + .long 733746641 + .long 3219206769 + .long 2776288224 + .long 3161354348 + .long 312049674 + .long 1072253264 + .long 1779010374 + .long 3220866352 + .long 3398525311 + .long 3220286121 + .long 3932053403 + .long 3224771363 + .long 2526572080 + .long 3226863609 + .long 1052531014 + .long 3228950632 + .long 1237705257 + .long 3230476352 + .long 1818683855 + .long 3231504084 + .long 2771211543 + .long 3231812491 + .long 1784201120 + .long 3231087810 + .long 0 + .long 1069547520 + .long 0 + .long 3220701184 + .long 3317774106 + .long 1067973958 + .long 2923167300 + .long 1012645752 + .long 3241173892 + .long 3214918775 + .long 39491139 + .long 3156995939 + .long 285395131 + .long 1066727038 + .long 2541426776 + .long 1010932663 + .long 1226100891 + .long 3213595410 + .long 1495613600 + .long 3157951728 + .long 3870275689 + .long 1065488829 + .long 965710822 + .long 1009822465 + .long 3492316846 + .long 3212293408 + .long 2517483522 + .long 3156957513 + .long 1374076994 + .long 1064156941 + .long 372497316 + .long 3211297712 + .long 3813845480 + .long 3208055775 + .long 3900585526 + .long 3212419165 + .long 1960133516 + .long 3213181643 + .long 148017317 + .long 3214056684 + .long 3471465381 + .long 3214242476 + .long 65590178 + .long 3214048451 + .long 3138884841 + .long 3213067513 + .long 2557226666 + .long 3211122744 + .long 0 + .long 1069547520 + .long 0 + .long 3220701184 + .long 3319825997 + .long 1067973958 + .long 153387004 + .long 1010340046 + .long 3027068505 + .long 3214918775 + .long 2440895001 + .long 3158659807 + .long 1195164920 + .long 1066727039 + .long 1739223825 + .long 1010932951 + .long 3681176633 + .long 3213595373 + .long 2468586085 + .long 3156977493 + .long 2873291842 + .long 1065489208 + .long 1357898154 + .long 1010449195 + .long 449207067 + .long 3212287634 + .long 1843054170 + .long 3156472137 + .long 1688975421 + .long 1064223666 + .long 2606145257 + .long 3210999965 + .long 2843228885 + .long 1062852799 + .long 3218505005 + .long 3209735220 + .long 2000171025 + .long 1061515619 + .long 2480760959 + .long 3208347934 + .long 1915328357 + .long 1060202094 + .long 619623839 + .long 3207101805 + .long 3877388623 + .long 1057814602 + .long 1403207699 + .long 3206847388 + .long 0 + .long 1069547520 + .long 0 + .long 3220701184 + .long 3319825996 + .long 1067973958 + .long 2025830981 + .long 1009198696 + .long 3027068262 + .long 3214918775 + .long 462574407 + .long 3158874537 + .long 1195152753 + .long 1066727039 + .long 2026642833 + .long 1010473176 + .long 3680441114 + .long 3213595373 + .long 1280116659 + .long 3154901898 + .long 2858263562 + .long 1065489208 + .long 3653419668 + .long 1010119659 + .long 8491235 + .long 3212287634 + .long 2006410862 + .long 3152308929 + .long 669193667 + .long 1064223664 + .long 261358851 + .long 3210999947 + .long 3798337047 + .long 1062852562 + .long 3252853818 + .long 3209734051 + .long 2986380320 + .long 1061506613 + .long 2271475836 + .long 3208293716 + .long 4121652893 + .long 1060072878 + .long 1033391529 + .long 3206544683 + .long 472144880 + .long 1057491226 + .long 2996742642 + .long 3202556481 + .long 0 + .long 1067450368 + .long 0 + .long 3219390464 + .long 2310440956 + .long 1067243964 + .long 1910839802 + .long 1011085066 + .long 3231655782 + .long 3215394280 + .long 67697416 + .long 3158533143 + .long 747798972 + .long 1068652953 + .long 3842674820 + .long 1013874752 + .long 2960203073 + .long 3216848639 + .long 2643975567 + .long 3156914699 + .long 3514791177 + .long 1070021174 + .long 3133960404 + .long 1013937886 + .long 2900718461 + .long 3218240252 + .long 1762535320 + .long 3161495508 + .long 3933388189 + .long 1071460247 + .long 1623401109 + .long 3219631106 + .long 2243580782 + .long 1072656900 + .long 3113530625 + .long 3221833507 + .long 4278270359 + .long 3222733868 + .long 4152511010 + .long 3225895261 + .long 1448809675 + .long 3227655974 + .long 2046900051 + .long 3229157102 + .long 4134264961 + .long 3229841799 + .long 2742521525 + .long 3229722239 + .long 0 + .long 1068498944 + .long 0 + .long 3220701184 + .long 2295541704 + .long 1066929438 + .long 3837869256 + .long 1002512271 + .long 2403525199 + .long 3213885862 + .long 3057254264 + .long 3152556454 + .long 1273180940 + .long 1065699684 + .long 307148135 + .long 1007267775 + .long 4108180605 + .long 3212593363 + .long 867507169 + .long 3154906335 + .long 2406587489 + .long 1064486498 + .long 3600962311 + .long 1007048784 + .long 641070000 + .long 3211323670 + .long 942137894 + .long 3155422437 + .long 471088535 + .long 1063286275 + .long 3784803533 + .long 3210106468 + .long 2056014570 + .long 1061725436 + .long 975828111 + .long 3209750570 + .long 3879370210 + .long 3209336425 + .long 2803950026 + .long 3211135338 + .long 606260247 + .long 3211577897 + .long 1881144158 + .long 3211825519 + .long 670638336 + .long 3211103480 + .long 2138776162 + .long 3209709388 + .long 0 + .long 1068498944 + .long 0 + .long 3220701184 + .long 2295580191 + .long 1066929438 + .long 3681200523 + .long 1011869447 + .long 2400932937 + .long 3213885862 + .long 1282261590 + .long 3155177332 + .long 1435460813 + .long 1065699684 + .long 338806164 + .long 1009895735 + .long 2137816334 + .long 3212593362 + .long 2795067653 + .long 3156177866 + .long 4261873090 + .long 1064486517 + .long 3264144757 + .long 1007933656 + .long 2173718924 + .long 3211323291 + .long 3810711629 + .long 3155704795 + .long 2446322575 + .long 1063289064 + .long 2077064354 + .long 3210074792 + .long 504970137 + .long 1062005301 + .long 3765139549 + .long 3208846522 + .long 2079001974 + .long 1060716176 + .long 875759584 + .long 3207637152 + .long 4108525622 + .long 1059452531 + .long 4049318739 + .long 3206336314 + .long 3770858801 + .long 1058237468 + .long 2722340464 + .long 3205374723 + .long 0 + .long 1068498944 + .long 0 + .long 3220701184 + .long 2295580191 + .long 1066929438 + .long 2149023882 + .long 1011305144 + .long 2400932909 + .long 3213885862 + .long 1064137805 + .long 3156227957 + .long 1435458098 + .long 1065699684 + .long 4263810407 + .long 1007587847 + .long 2137652297 + .long 3212593362 + .long 1479815673 + .long 3155856170 + .long 4258425849 + .long 1064486517 + .long 3605379165 + .long 1009762642 + .long 2066788283 + .long 3211323291 + .long 3198576201 + .long 3153399561 + .long 1179383574 + .long 1063289064 + .long 140008546 + .long 3210074787 + .long 2930072161 + .long 1062005221 + .long 1129148062 + .long 3208846064 + .long 3175174977 + .long 1060711976 + .long 382350984 + .long 3207621985 + .long 3891461581 + .long 1059368087 + .long 1514607567 + .long 3205983602 + .long 292029317 + .long 1057267187 + .long 906505364 + .long 3202625257 + .long 0 + .long 1071644672 + .long 1431652600 + .long 1069897045 + .long 1431670732 + .long 1067799893 + .long 984555731 + .long 1065423122 + .long 472530941 + .long 1062650218 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 939524096 + .long 1072704666 + .long 2209988083 + .long 1046076929 + .long 3489660928 + .long 1072716208 + .long 2715237930 + .long 1044950059 + .long 402653184 + .long 1072727877 + .long 36755401 + .long 1042114290 + .long 1744830464 + .long 1072739672 + .long 1032479461 + .long 1045685796 + .long 805306368 + .long 1072751596 + .long 269498903 + .long 1044815501 + .long 3489660928 + .long 1072763649 + .long 2766913307 + .long 1039293264 + .long 2818572288 + .long 1072775834 + .long 2127365126 + .long 1046127799 + .long 939524096 + .long 1072788152 + .long 3950214642 + .long 1045558597 + .long 3892314112 + .long 1072800603 + .long 2850403528 + .long 1045134939 + .long 805306368 + .long 1072813191 + .long 2810207104 + .long 1043762074 + .long 2281701376 + .long 1072825915 + .long 2397289153 + .long 1041802037 + .long 1744830464 + .long 1072838778 + .long 3785033707 + .long 1046074760 + .long 1610612736 + .long 1072851781 + .long 1955981725 + .long 1045924339 + .long 4026531840 + .long 1072864925 + .long 2226165573 + .long 1045725051 + .long 2684354560 + .long 1072878213 + .long 754984053 + .long 1046188044 + .long 134217728 + .long 1072891646 + .long 2842642093 + .long 1044483512 + .long 2952790016 + .long 1072905224 + .long 4200916017 + .long 1044586679 + .long 805306368 + .long 1072918951 + .long 714887508 + .long 1046276775 + .long 805306368 + .long 1072932827 + .long 3685248805 + .long 1045665407 + .long 1207959552 + .long 1072946854 + .long 2295779401 + .long 1045448912 + .long 536870912 + .long 1072961034 + .long 2676240988 + .long 1044345570 + .long 1610612736 + .long 1072975368 + .long 1086643152 + .long 1041785419 + .long 2952790016 + .long 1072989858 + .long 1078920847 + .long 1045890291 + .long 3489660928 + .long 1073004506 + .long 2624917087 + .long 1045747880 + .long 1879048192 + .long 1073019314 + .long 2595540835 + .long 1046115506 + .long 1342177280 + .long 1073034283 + .long 125577743 + .long 1046115646 + .long 805306368 + .long 1073049415 + .long 1771811520 + .long 1046140063 + .long 3623878656 + .long 1073064711 + .long 2774738112 + .long 1045766480 + .long 268435456 + .long 1073080175 + .long 565866387 + .long 1045869701 + .long 2952790016 + .long 1073095806 + .long 1492679939 + .long 1041050306 + .long 2147483648 + .long 1073111608 + .long 612974287 + .long 1044556049 + .long 1610612736 + .long 1073127582 + .long 843197631 + .long 1046084847 + .long 939524096 + .long 1073143730 + .long 3150480267 + .long 1045533800 + .long 3892314112 + .long 1073160053 + .long 2074373662 + .long 1043172334 + .long 1342177280 + .long 1073176555 + .long 587053675 + .long 1046022559 + .long 1879048192 + .long 1073193236 + .long 918464641 + .long 1045387276 + .long 805306368 + .long 1073210099 + .long 2285990923 + .long 1046166841 + .long 2550136832 + .long 1073227145 + .long 682424459 + .long 1043647713 + .long 2550136832 + .long 1073244377 + .long 1678188781 + .long 1045046423 + .long 1073741824 + .long 1073261797 + .long 3671932459 + .long 1044468998 + .long 2550136832 + .long 1073279406 + .long 1656324724 + .long 1043421043 + .long 2952790016 + .long 1073297207 + .long 2659845000 + .long 1042921660 + .long 2550136832 + .long 1073315202 + .long 1043233352 + .long 1046444345 + .long 2147483648 + .long 1073333393 + .long 2162418230 + .long 1044717444 + .long 2013265920 + .long 1073351782 + .long 630511316 + .long 1045098283 + .long 2952790016 + .long 1073370371 + .long 3831108133 + .long 1044508970 + .long 1342177280 + .long 1073389163 + .long 4245662865 + .long 1045817334 + .long 2550136832 + .long 1073408159 + .long 3588780877 + .long 1043705146 + .long 3087007744 + .long 1073427362 + .long 3182425146 + .long 1041483134 + .long 4026531840 + .long 1073446774 + .long 928333188 + .long 1044896498 + .long 2415919104 + .long 1073466398 + .long 2300504125 + .long 1041428596 + .long 3623878656 + .long 1073486235 + .long 1887994668 + .long 1045828938 + .long 671088640 + .long 1073506289 + .long 757630176 + .long 1046044485 + .long 3623878656 + .long 1073526560 + .long 2756972335 + .long 1045675585 + .long 1207959552 + .long 1073547053 + .long 3697834264 + .long 1044397131 + .long 3623878656 + .long 1073567768 + .long 479684631 + .long 1045687954 + .long 0 + .long 1073588710 + .long 730095629 + .long 1045354900 + .long 805306368 + .long 1073609879 + .long 4123739734 + .long 1045159130 + .long 3758096384 + .long 1073631278 + .long 3634164812 + .long 1046359295 + .long 2684354560 + .long 1073652911 + .long 3425467293 + .long 1044718726 + .long 3892314112 + .long 1073674779 + .long 2648473416 + .long 1046054248 + .long 1476395008 + .long 1073696886 + .long 54164518 + .long 1045131818 + .long 2147483648 + .long 1073719233 + .long 2196310654 + .long 1043982605 + .long 4277796864 + .long 1065758274 + .long 3164486458 + .long 1025308570 + .long 1697350398 + .long 1079448903 + .long 0 + .long 862978048 + .long 0 + .long 1127743488 + .long 33554432 + .long 1101004800 + .long 0 + .long 0 + .long 1 + .long 1048576 + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .long 0 + .long 1073741824 + .long 1105497085 + .long 1077623260 + .long 261899793 + .long 1077588746 + .long 4235085970 + .long 1077578514 + .long 2406803786 + .long 3222762575 + .type _vmldErfcHATab,@object + .size _vmldErfcHATab,5024 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/erfcf.S b/external/sgx_libm/intel64/erfcf.S new file mode 100644 index 0000000000..b6655001b7 --- /dev/null +++ b/external/sgx_libm/intel64/erfcf.S @@ -0,0 +1,705 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfcf.c" + .text +..TXTST0: +# -- Begin erfcf + .text + .align 16,0x90 + .globl erfcf +erfcf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_erfcf.1: +..L2: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + subq $32, %rsp + .cfi_def_cfa_offset 48 + movd %xmm0, %r14d + movss %xmm0, 16(%rsp) + movl %r14d, %ecx + andl $2147483647, %ecx + shrl $31, %r14d + cmpl $2139095040, %ecx + jae ..B1.24 +..B1.2: + movl %r14d, %eax + lea range(%rip), %rdx + cmpl (%rdx,%rax,4), %ecx + jae ..B1.21 +..B1.3: + cmpl $1081081856, %ecx + jae ..B1.15 +..B1.4: + cmpl $1073741824, %ecx + jae ..B1.11 +..B1.5: + cmpl $1056964608, %ecx + jae ..B1.10 +..B1.6: + cmpl $847249408, %ecx + jae ..B1.8 +..B1.7: + movss .L_2il0floatpacket.3(%rip), %xmm4 + subss %xmm0, %xmm4 + jmp ..B1.9 +..B1.8: + cvtss2sd %xmm0, %xmm0 + movaps %xmm0, %xmm1 + lea 40+_A(%rip), %rax + lea 48+_A(%rip), %rsi + lea 24+_A(%rip), %rdx + lea 32+_A(%rip), %rdi + lea 8+_A(%rip), %rcx + lea 16+_A(%rip), %r8 + lea _A(%rip), %r9 + movsd (%rax), %xmm4 + movsd (%rsi), %xmm3 + mulsd %xmm0, %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd (%rdx), %xmm4 + addsd (%rdi), %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm3 + addsd (%rcx), %xmm4 + addsd (%r8), %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm2, %xmm3 + mulsd %xmm0, %xmm4 + addsd (%r9), %xmm3 + addsd .L_2il0floatpacket.4(%rip), %xmm4 + mulsd %xmm0, %xmm3 + addsd %xmm3, %xmm4 + cvtsd2ss %xmm4, %xmm4 +..B1.9: + movaps %xmm4, %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.10: + pxor %xmm1, %xmm1 + lea 48+_AP(%rip), %rdx + cvtss2sd 16(%rsp), %xmm1 + andps .L_2il0floatpacket.5(%rip), %xmm1 + lea 32+_AP(%rip), %rcx + movsd (%rdx), %xmm6 + lea 16+_AP(%rip), %rsi + lea _AP(%rip), %rdi + lea 56+_AP(%rip), %r8 + lea 48+_AQ(%rip), %r14 + lea 40+_AP(%rip), %r9 + lea 32+_AQ(%rip), %rdx + lea 24+_AP(%rip), %r10 + lea 8+_AP(%rip), %r11 + pxor %xmm5, %xmm5 + movsd (%r8), %xmm2 + lea 40+_AQ(%rip), %r8 + movsd (%r14), %xmm4 + lea _erfc1(%rip), %r14 + subsd .L_2il0floatpacket.4(%rip), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + mulsd %xmm0, %xmm6 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm4 + addsd (%rcx), %xmm6 + addsd (%r9), %xmm2 + addsd (%rdx), %xmm4 + mulsd %xmm0, %xmm6 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm4 + addsd (%rsi), %xmm6 + addsd (%r10), %xmm2 + mulsd %xmm0, %xmm6 + mulsd %xmm0, %xmm2 + addsd (%rdi), %xmm6 + addsd (%r11), %xmm2 + lea 56+_AQ(%rip), %rdi + lea 24+_AQ(%rip), %r9 + lea 16+_AQ(%rip), %rcx + lea 8+_AQ(%rip), %r10 + lea _AQ(%rip), %rsi + lea _ones(%rip), %r11 + mulsd %xmm1, %xmm2 + addsd (%rcx), %xmm4 + cvtss2sd (%r11,%rax,4), %xmm5 + addsd %xmm2, %xmm6 + mulsd %xmm0, %xmm4 + movsd (%rdi), %xmm3 + mulsd %xmm0, %xmm3 + addsd (%rsi), %xmm4 + addsd (%r8), %xmm3 + mulsd %xmm0, %xmm3 + addsd (%r9), %xmm3 + mulsd %xmm0, %xmm3 + addsd (%r10), %xmm3 + mulsd %xmm1, %xmm3 + addsd %xmm3, %xmm4 + divsd %xmm4, %xmm6 + mulsd %xmm5, %xmm6 + addsd (%r14,%rax,8), %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.11: + pxor %xmm1, %xmm1 + testl %r14d, %r14d + cvtss2sd 16(%rsp), %xmm1 + andps .L_2il0floatpacket.5(%rip), %xmm1 + addsd .L_2il0floatpacket.2(%rip), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + je ..B1.13 +..B1.12: + lea 48+_BP1(%rip), %rdx + lea 32+_BP1(%rip), %rcx + lea 16+_BP1(%rip), %rsi + lea 40+_BP1(%rip), %r8 + lea 48+_BQ1(%rip), %r11 + lea 32+_BQ1(%rip), %r14 + lea _BP1(%rip), %rdi + lea 24+_BP1(%rip), %r9 + movsd (%rdx), %xmm5 + lea 16+_BQ1(%rip), %rdx + movsd (%r8), %xmm2 + lea 8+_BP1(%rip), %r10 + movsd (%r11), %xmm4 + lea 8+_BQ1(%rip), %r8 + mulsd %xmm0, %xmm5 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd (%rcx), %xmm5 + addsd (%r14), %xmm4 + addsd (%r9), %xmm2 + mulsd %xmm0, %xmm5 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd (%rsi), %xmm5 + addsd (%rdx), %xmm4 + addsd (%r10), %xmm2 + mulsd %xmm0, %xmm5 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + addsd (%rdi), %xmm5 + lea 40+_BQ1(%rip), %rsi + lea 24+_BQ1(%rip), %rdi + lea _BQ1(%rip), %rcx + movsd (%rsi), %xmm3 + mulsd %xmm0, %xmm3 + addsd (%rcx), %xmm4 + addsd (%rdi), %xmm3 + mulsd %xmm0, %xmm3 + addsd (%r8), %xmm3 + mulsd %xmm1, %xmm3 + jmp ..B1.14 +..B1.13: + lea 80+_BP2(%rip), %rdx + lea 64+_BP2(%rip), %rcx + lea 88+_BP2(%rip), %r10 + lea 48+_BP2(%rip), %rsi + lea 72+_BP2(%rip), %r11 + lea 32+_BP2(%rip), %rdi + lea 56+_BP2(%rip), %r14 + lea 16+_BP2(%rip), %r8 + movsd (%rdx), %xmm5 + lea 40+_BP2(%rip), %rdx + mulsd %xmm0, %xmm5 + lea _BP2(%rip), %r9 + movsd (%r10), %xmm2 + lea 16+_BQ2(%rip), %r10 + mulsd %xmm0, %xmm2 + addsd (%rcx), %xmm5 + mulsd %xmm0, %xmm5 + addsd (%r11), %xmm2 + mulsd %xmm0, %xmm2 + addsd (%rsi), %xmm5 + mulsd %xmm0, %xmm5 + addsd (%r14), %xmm2 + lea 56+_BQ2(%rip), %r14 + addsd (%rdi), %xmm5 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm5 + addsd (%rdx), %xmm2 + addsd (%r8), %xmm5 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm5 + lea 64+_BQ2(%rip), %rdi + lea 48+_BQ2(%rip), %r8 + movsd (%r14), %xmm3 + lea 40+_BQ2(%rip), %rdx + lea 24+_BP2(%rip), %rcx + lea 8+_BP2(%rip), %rsi + mulsd %xmm0, %xmm3 + addsd (%r9), %xmm5 + addsd (%rcx), %xmm2 + addsd (%rdx), %xmm3 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm3 + addsd (%rsi), %xmm2 + movsd (%rdi), %xmm4 + lea 32+_BQ2(%rip), %r9 + lea 24+_BQ2(%rip), %rcx + lea 8+_BQ2(%rip), %rsi + lea _BQ2(%rip), %r11 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + addsd (%rcx), %xmm3 + addsd (%r8), %xmm4 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm4 + addsd (%rsi), %xmm3 + addsd (%r9), %xmm4 + mulsd %xmm1, %xmm3 + mulsd %xmm0, %xmm4 + addsd (%r10), %xmm4 + mulsd %xmm0, %xmm4 + addsd (%r11), %xmm4 +..B1.14: + lea _ones(%rip), %rdx + pxor %xmm0, %xmm0 + lea _erfc4(%rip), %rcx + addsd %xmm2, %xmm5 + addsd %xmm3, %xmm4 + cvtss2sd (%rdx,%rax,4), %xmm0 + divsd %xmm4, %xmm5 + mulsd %xmm0, %xmm5 + addsd (%rcx,%rax,8), %xmm5 + cvtsd2ss %xmm5, %xmm5 + movaps %xmm5, %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.15: + pxor %xmm0, %xmm0 + cvtss2sd 16(%rsp), %xmm0 + andps .L_2il0floatpacket.5(%rip), %xmm0 + movsd .L_2il0floatpacket.4(%rip), %xmm1 + divsd %xmm0, %xmm1 + mulsd %xmm0, %xmm0 + xorps .L_2il0floatpacket.6(%rip), %xmm0 + movsd %xmm1, 8(%rsp) +..___tag_value_erfcf.21: + call __libm_exp_k32@PLT +..___tag_value_erfcf.22: +..B1.32: + movaps %xmm0, %xmm4 +..B1.16: + movsd 8(%rsp), %xmm0 + lea 56+__R1(%rip), %rax + mulsd %xmm0, %xmm4 + lea 48+__R1(%rip), %rdi + mulsd %xmm0, %xmm0 + movaps %xmm0, %xmm1 + lea 40+__R1(%rip), %rdx + mulsd %xmm0, %xmm1 + lea 32+__R1(%rip), %r8 + movsd (%rax), %xmm3 + lea 24+__R1(%rip), %rcx + mulsd %xmm1, %xmm3 + lea 16+__R1(%rip), %r9 + movsd (%rdi), %xmm2 + lea 8+__R1(%rip), %rsi + mulsd %xmm1, %xmm2 + addsd (%rdx), %xmm3 + mulsd %xmm1, %xmm3 + addsd (%r8), %xmm2 + mulsd %xmm1, %xmm2 + addsd (%rcx), %xmm3 + mulsd %xmm1, %xmm3 + addsd (%r9), %xmm2 + mulsd %xmm1, %xmm2 + addsd (%rsi), %xmm3 + lea __R1(%rip), %r10 + testl %r14d, %r14d + mulsd %xmm0, %xmm3 + addsd (%r10), %xmm2 + addsd %xmm2, %xmm3 + mulsd %xmm3, %xmm4 + cvtsd2ss %xmm4, %xmm4 + jne ..B1.20 +..B1.17: + movd %xmm4, %eax + movss %xmm4, 4(%rsp) + cmpl $8388608, %eax + jl ..B1.28 +..B1.19: + movaps %xmm4, %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.20: + movss .L_2il0floatpacket.0(%rip), %xmm0 + subss %xmm4, %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.21: + testl %r14d, %r14d + je ..B1.29 +..B1.22: + movss .L_2il0floatpacket.0(%rip), %xmm0 +..B1.23: + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.24: + jne ..B1.26 +..B1.25: + lea zero_two(%rip), %rax + movss (%rax,%r14,4), %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.26: + movss 16(%rsp), %xmm0 +..B1.27: + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 14, -16 +..B1.28: + movss .L_2il0floatpacket.1(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) + movss 4(%rsp), %xmm4 + jmp ..B1.19 +..B1.29: + movss .L_2il0floatpacket.1(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, 4(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type erfcf,@function + .size erfcf,.-erfcf + .data +# -- End erfcf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.5: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 16 +.L_2il0floatpacket.6: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0xc0000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x40000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x0d800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x3f800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +range: + .long 1092825907 + .long 1081791557 + .type range,@object + .size range,8 + .align 4 +_A: + .long 1346541978 + .long 3220311511 + .long 1794662342 + .long 1071125108 + .long 250944106 + .long 3216827122 + .long 215131671 + .long 1067156170 + .long 548330146 + .long 3212141823 + .long 76350191 + .long 1061937114 + .long 2772654316 + .long 3206307213 + .type _A,@object + .size _A,56 + .align 4 +_AP: + .long 4064916629 + .long 3190878451 + .long 2877165718 + .long 3218164236 + .long 2764139057 + .long 1068232842 + .long 168293639 + .long 3215329394 + .long 881203975 + .long 3215292554 + .long 342818617 + .long 1065638313 + .long 817546319 + .long 3212004140 + .long 1510911299 + .long 3202390104 + .type _AP,@object + .size _AP,64 + .align 4 +_AQ: + .long 1883560946 + .long 1071960885 + .long 853592313 + .long 1071685196 + .long 191605458 + .long 1071250674 + .long 2183121159 + .long 1070390698 + .long 3347411101 + .long 1068928985 + .long 273856425 + .long 1067608207 + .long 671820230 + .long 1065177551 + .long 2414119437 + .long 1063328696 + .type _AQ,@object + .size _AQ,64 + .align 4 +_erfc1: + .long 1879048192 + .long 1069818465 + .long 3523215360 + .long 1073576883 + .type _erfc1,@object + .size _erfc1,16 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_BP1: + .long 4019088381 + .long 1060143686 + .long 4231883845 + .long 3209038463 + .long 1510730124 + .long 1061755778 + .long 2929202078 + .long 3208591153 + .long 1409179897 + .long 1059475758 + .long 439372548 + .long 3204538649 + .long 3357266387 + .long 1053229132 + .type _BP1,@object + .size _BP1,56 + .align 4 +_BQ1: + .long 3444570556 + .long 1068208773 + .long 4145425017 + .long 1069029647 + .long 1145740212 + .long 1069192522 + .long 2413502193 + .long 1068797491 + .long 2712383784 + .long 1068007659 + .long 3941762314 + .long 1066743858 + .long 3272105283 + .long 1065447630 + .type _BQ1,@object + .size _BQ1,56 + .align 4 +_BP2: + .long 3138848853 + .long 1062211012 + .long 544119287 + .long 3211644465 + .long 2662071917 + .long 1064935492 + .long 2106254088 + .long 3212505578 + .long 377059754 + .long 1064517936 + .long 3523110848 + .long 3210978388 + .long 64932799 + .long 1062023575 + .long 2232373525 + .long 3207568747 + .long 3004568351 + .long 1057518327 + .long 1553969795 + .long 3201939481 + .long 865068135 + .long 1050709866 + .long 348213498 + .long 3193161330 + .type _BP2,@object + .size _BP2,96 + .align 4 +_BQ2: + .long 2220299070 + .long 1070256111 + .long 1607355279 + .long 1069737707 + .long 3222185356 + .long 1069664669 + .long 1988590515 + .long 1068489586 + .long 2612211906 + .long 1067468794 + .long 3802943557 + .long 1065572613 + .long 4286646379 + .long 1063895282 + .long 45248763 + .long 1061257684 + .long 3494068347 + .long 1058887001 + .type _BQ2,@object + .size _BQ2,72 + .align 4 +_erfc4: + .long 0 + .long 1045463040 + .long 4225761280 + .long 1073741823 + .type _erfc4,@object + .size _erfc4,16 + .align 4 +__R1: + .long 1340517714 + .long 1071779287 + .long 1760660317 + .long 3218214358 + .long 3277598851 + .long 1071322187 + .long 1776282588 + .long 3220235438 + .long 2229586924 + .long 1074588991 + .long 2042215417 + .long 3224150558 + .long 1374528972 + .long 1078534706 + .long 1825320511 + .long 3227067102 + .type __R1,@object + .size __R1,64 + .align 4 +zero_two: + .long 0x00000000 + .long 0x40000000 + .type zero_two,@object + .size zero_two,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/erfcl.S b/external/sgx_libm/intel64/erfcl.S new file mode 100644 index 0000000000..c744e4c648 --- /dev/null +++ b/external/sgx_libm/intel64/erfcl.S @@ -0,0 +1,4944 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfcl.c" + .text +..TXTST0: +# -- Begin erfcl + .text + .align 16,0x90 + .globl erfcl +erfcl: +# parameter 1: 208 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_erfcl.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + subq $168, %rsp + .cfi_def_cfa_offset 208 + xorb %r15b, %r15b + fldt 208(%rsp) + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 160(%rsp) + fstpt 64(%rsp) +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movzwl 82(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.5: + fldcw 80(%rsp) +..B1.6: + movb $1, %r15b +..B1.7: + movl 216(%rsp), %eax + movl %eax, %r14d + shrl $15, %r14d + andl $32767, %eax + andl $1, %r14d + cmpl $32767, %eax + je ..B1.56 +..B1.8: + fldt 208(%rsp) + lea _zeros(%rip), %rax + fldl (%rax) + fucomip %st(1), %st + jp ..B1.9 + je ..B1.51 +..B1.9: + lea _erfcl_RT1(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + ja ..B1.15 + jp ..B1.15 +..B1.10: + lea 16+_erfcl_RT1(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + jb ..B1.15 +..B1.11: + fstp %st(0) + lea _Epsilon(%rip), %rax + lea _ones(%rip), %rdx + testb %r15b, %r15b + fldt (%rax) + fsubrl (%rdx) + fstpt 16(%rsp) + je ..B1.13 +..B1.12: + fldcw 82(%rsp) +..B1.13: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.14: + addq $168, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.15: + lea 8+_erfcl_ASYMPT(%rip), %rax + fldl (%rax) + fcomip %st(1), %st + jb ..B1.46 +..B1.16: + lea _erfcl_ASYMPT(%rip), %rax + fldl (%rax) + fcomip %st(1), %st + fstp %st(0) + jp ..B1.17 + jbe ..B1.21 +..B1.17: + fldt .L_2il0floatpacket.0(%rip) + lea _Epsilon(%rip), %rax + testb %r15b, %r15b + fldt (%rax) + fsubrp %st, %st(1) + fstpt 16(%rsp) + je ..B1.19 +..B1.18: + fldcw 82(%rsp) +..B1.19: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.20: + addq $168, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.21: + fldt .L_2il0floatpacket.1(%rip) + lea _ones(%rip), %r13 + andl $32767, 72(%rsp) + lea 128(%rsp), %rdi + fldt -64(%rdi) + lea 96(%rsp), %rsi + fmul %st, %st(1) + fld %st(0) + fld %st(1) + fsub %st(3), %st + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fchs + fstpt (%rsi) + fld %st(1) + fsub %st(3), %st + fmul %st, %st(3) + fxch %st(3) + fchs + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + fstpt 16(%rsi) + fldl (%r13) + fstpt -80(%rsi) + fldt -80(%rsi) + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fstpt -64(%rsi) + movl -56(%rsi), %r13d + andl $32767, %r13d + addq $-16383, %r13 + movl %r13d, %ebx + shll $4, %ebx + movslq %ebx, %rbx + shlq $4, %rbx +..___tag_value_erfcl.40: + call __libm_expl_k80@PLT +..___tag_value_erfcl.41: +..B1.78: + fldt 16(%rsp) +..B1.22: + lea _TWO_63H(%rip), %rax + fldl (%rax) + faddp %st, %st(2) + fxch %st(1) + fstpt 48(%rsp) + movl 48(%rsp), %edx + cmpl $-16300, %edx + fstpt 48(%rsp) + fldt 48(%rsp) + jle ..B1.24 +..B1.23: + fldt 128(%rsp) + addl $16383, %edx + movzwl 56(%rsp), %eax + andl $32767, %edx + andl $-32768, %eax + orl %edx, %eax + movw %ax, 56(%rsp) + lea 144(%rsp), %rax + fldt (%rax) + jmp ..B1.25 +..B1.24: + fldt 128(%rsp) + lea _TWO_POW_M400(%rip), %rsi + movzwl 56(%rsp), %eax + movl %eax, %ecx + andl $-32768, %ecx + fldl (%rsi) + lea 400(%rax,%rdx), %edx + andl $32767, %edx + lea 144(%rsp), %rax + orl %edx, %ecx + movw %cx, -88(%rax) + fmul %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) +..B1.25: + fldt .L_2il0floatpacket.1(%rip) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt (%rax) + fldt (%rax) + lea _erfcl_CHDX(%rip), %rax + fxch %st(1) + fstpt 128(%rsp) + fldt 64(%rsp) + fldt (%rax) + fcomip %st(1), %st + jbe ..B1.27 +..B1.26: + lea _erfcl_DX(%rip), %rax + fld %st(0) + fldl (%rax) + fadd %st, %st(1) + fsub %st(1), %st + fadd %st(2), %st + jmp ..B1.28 +..B1.27: + lea 8+_erfcl_DX(%rip), %rax + fld %st(0) + fld %st(1) + fldl (%rax) + fadd %st, %st(2) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(1) +..B1.28: + fldt .L_2il0floatpacket.1(%rip) + fld %st(2) + shlq $4, %r13 + lea _erfcl_C(%rip), %rax + lea _erfcl_Q(%rip), %rdx + lea _erfcl_S(%rip), %rcx + testl %r14d, %r14d + fadd %st(2), %st + fdivr %st(6), %st + fmul %st, %st(1) + fxch %st(5) + fstpt 32(%rsp) + fld %st(0) + fadd %st(5), %st + fsubp %st, %st(1) + fsubr %st, %st(4) + fld %st(2) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(4), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(4) + fmul %st(2), %st + fld %st(1) + fmul %st(4), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(3) + fldt .L_2il0floatpacket.0(%rip) + fsub %st(1), %st + fldt .L_2il0floatpacket.0(%rip) + fsub %st(1), %st + fsubp %st, %st(2) + fxch %st(3) + fsubrp %st, %st(1) + fld %st(2) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(4), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(4) + fmul %st(1), %st + fld %st(2) + fmul %st(4), %st + fxch %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(4) + faddp %st, %st(3) + fld %st(0) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldt (%r13,%rax) + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fldt 224(%rdx,%rbx) + fmul %st(1), %st + fldt 192(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 160(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 128(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 64(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 32(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx,%rbx) + faddp %st, %st(1) + fldt 240(%rdx,%rbx) + fmul %st(2), %st + fldt 208(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 176(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 144(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 112(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 80(%rdx,%rbx) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48(%rdx,%rbx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 16(%rdx,%rbx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(3) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fldt .L_2il0floatpacket.1(%rip) + fldt (%r13,%rcx) + fmul %st, %st(3) + fxch %st(1) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(3) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(2) + faddp %st, %st(4) + fldt 16(%rsp) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(5), %st + fldt 32(%rsp) + fmul %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(2) + fld %st(3) + fld %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(6), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(5) + fxch %st(5) + faddp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fxch %st(3) + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 48(%rsp) + je ..B1.30 +..B1.29: + fldt .L_2il0floatpacket.0(%rip) + fxch %st(1) + fmul %st, %st(2) + fmulp %st, %st(3) + fldt .L_2il0floatpacket.0(%rip) + fsub %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + fsub %st(2), %st + fsub %st(3), %st + faddp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + jmp ..B1.33 +..B1.30: + fld %st(1) + fadd %st(3), %st + fmul %st(1), %st + fstpt 16(%rsp) + movzwl 24(%rsp), %eax + testl $32767, %eax + jne ..B1.33 +..B1.31: + movzwl 22(%rsp), %eax + testl %eax, %eax + jbe ..B1.33 +..B1.32: + fldt .L_2il0floatpacket.1(%rip) + fmul %st(2), %st + fld %st(2) + fsubr %st(1), %st + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + fadd %st(3), %st + fmul %st(1), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 16(%rsp) +..B1.33: + fstp %st(0) + fstp %st(1) + fstp %st(0) + fldt 208(%rsp) + lea _erfcl_UNDERFLOW_INT(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + fstp %st(0) + jp ..B1.34 + jbe ..B1.41 +..B1.34: + testb %r15b, %r15b + je ..B1.36 +..B1.35: + fldcw 82(%rsp) +..B1.36: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.37: + addq $168, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.38: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.41: + lea _small_value_80(%rip), %rax + testb %r15b, %r15b + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + je ..B1.43 +..B1.42: + fldcw 82(%rsp) +..B1.43: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 + jmp ..B1.14 +..B1.46: + fstp %st(0) + lea _Epsilon(%rip), %rax + testb %r15b, %r15b + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) + je ..B1.48 +..B1.47: + fldcw 82(%rsp) +..B1.48: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 + jmp ..B1.14 +..B1.51: + fstp %st(0) + lea _ones(%rip), %rax + testb %r15b, %r15b + fldl (%rax) + fstpt 16(%rsp) + je ..B1.53 +..B1.52: + fldcw 82(%rsp) +..B1.53: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 + jmp ..B1.14 +..B1.56: + movl 212(%rsp), %eax + testl %r14d, %r14d + jne ..B1.63 +..B1.57: + cmpl $-2147483648, %eax + jne ..B1.69 +..B1.58: + cmpl $0, 208(%rsp) + jne ..B1.69 +..B1.59: + lea _zeros(%rip), %rax + testb %r15b, %r15b + fldl (%rax) + fstpt 16(%rsp) + je ..B1.61 +..B1.60: + fldcw 82(%rsp) +..B1.61: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.62: + addq $168, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.63: + cmpl $-2147483648, %eax + jne ..B1.69 +..B1.64: + cmpl $0, 208(%rsp) + jne ..B1.69 +..B1.65: + fldt .L_2il0floatpacket.0(%rip) + testb %r15b, %r15b + fstpt 16(%rsp) + je ..B1.67 +..B1.66: + fldcw 82(%rsp) +..B1.67: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.68: + addq $168, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -40 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.69: + fldt 208(%rsp) + lea _ones(%rip), %rax + testb %r15b, %r15b + fmull (%rax) + fstpt 16(%rsp) + je ..B1.71 +..B1.70: + fldcw 82(%rsp) +..B1.71: + fldt 16(%rsp) + movq 160(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.38 +..B1.72: + addq $168, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type erfcl,@function + .size erfcl,.-erfcl + .data +# -- End erfcl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_erfcl_ASYMPT: + .long 0 + .long 3222929408 + .long 0 + .long 1079689216 + .type _erfcl_ASYMPT,@object + .size _erfcl_ASYMPT,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_POW_M400: + .long 0 + .long 653262848 + .type _TWO_POW_M400,@object + .size _TWO_POW_M400,8 + .align 4 +_erfcl_DX: + .long 0 + .long 1072431104 + .long 0 + .long 1071906816 + .type _erfcl_DX,@object + .size _erfcl_DX,16 + .align 2 +_erfcl_RT1: + .word 21820 + .word 42875 + .word 50317 + .word 58079 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 21820 + .word 42875 + .word 50317 + .word 58079 + .word 16317 + .word 0 + .word 0 + .word 0 + .type _erfcl_RT1,@object + .size _erfcl_RT1,32 + .align 2 +_Epsilon: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _Epsilon,@object + .size _Epsilon,16 + .align 2 +_erfcl_CHDX: + .word 54762 + .word 44346 + .word 63893 + .word 44681 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _erfcl_CHDX,@object + .size _erfcl_CHDX,16 + .align 2 +_erfcl_C: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50944 + .word 39545 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61184 + .word 35913 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 55108 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 38967 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58112 + .word 52540 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 34340 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 43938 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 55351 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 34462 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 42532 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 52130 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 63543 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 38558 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 46628 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 56226 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63488 + .word 33819 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 40606 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 48676 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 58274 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63488 + .word 34843 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 41630 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 49700 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 59298 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63488 + .word 35355 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 42142 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 50212 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32256 + .word 54690 + .word 16389 + .word 0 + .word 0 + .word 0 + .type _erfcl_C,@object + .size _erfcl_C,448 + .align 2 +_erfcl_Q: + .word 13465 + .word 63964 + .word 23888 + .word 38962 + .word 49066 + .word 0 + .word 0 + .word 0 + .word 56793 + .word 9364 + .word 2074 + .word 60725 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 38094 + .word 52495 + .word 21659 + .word 37955 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 56255 + .word 60659 + .word 19352 + .word 51197 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 38745 + .word 34996 + .word 58130 + .word 47148 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 27061 + .word 31727 + .word 37700 + .word 35458 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 30316 + .word 60982 + .word 15920 + .word 46457 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 52759 + .word 48094 + .word 27926 + .word 54790 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 31704 + .word 15513 + .word 33742 + .word 59335 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 10280 + .word 12123 + .word 40636 + .word 59798 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 55231 + .word 62106 + .word 54809 + .word 56625 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 36666 + .word 22902 + .word 8427 + .word 50746 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 46592 + .word 43726 + .word 50753 + .word 43230 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 64491 + .word 43284 + .word 59259 + .word 34800 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 61229 + .word 19548 + .word 49801 + .word 49926 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 1687 + .word 39069 + .word 16746 + .word 48555 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 55359 + .word 55853 + .word 34963 + .word 33408 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 24851 + .word 44488 + .word 55772 + .word 44700 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 44447 + .word 58130 + .word 38723 + .word 40258 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 1500 + .word 15080 + .word 64595 + .word 34359 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 52078 + .word 14763 + .word 48694 + .word 63117 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 4694 + .word 53159 + .word 65475 + .word 45416 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 37430 + .word 32424 + .word 1930 + .word 56261 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 33679 + .word 45771 + .word 8173 + .word 62515 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 49757 + .word 3681 + .word 5948 + .word 63753 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 9193 + .word 10955 + .word 22026 + .word 60547 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 55541 + .word 20458 + .word 54828 + .word 54096 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 47142 + .word 16345 + .word 20299 + .word 45812 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 29126 + .word 37494 + .word 48225 + .word 36984 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 15107 + .word 34726 + .word 44130 + .word 57191 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 57806 + .word 26620 + .word 53230 + .word 42777 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 45097 + .word 47803 + .word 25447 + .word 61330 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 40016 + .word 15109 + .word 58793 + .word 33461 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 6456 + .word 21547 + .word 27586 + .word 56453 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 5294 + .word 26959 + .word 24309 + .word 57122 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 9256 + .word 20178 + .word 27285 + .word 56054 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 11974 + .word 6713 + .word 58610 + .word 53898 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 56155 + .word 5104 + .word 43351 + .word 37953 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 31236 + .word 18492 + .word 31580 + .word 45205 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 20337 + .word 4737 + .word 24808 + .word 48018 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 43780 + .word 34731 + .word 45426 + .word 46730 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 61467 + .word 48142 + .word 38368 + .word 42346 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 39936 + .word 34435 + .word 51154 + .word 36121 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 41171 + .word 26385 + .word 45942 + .word 58461 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 31471 + .word 18426 + .word 18937 + .word 45145 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 23734 + .word 23053 + .word 7429 + .word 33424 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 28624 + .word 21549 + .word 30360 + .word 48021 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 9108 + .word 57175 + .word 16609 + .word 33031 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 44968 + .word 30293 + .word 53704 + .word 38182 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 63279 + .word 65139 + .word 8683 + .word 42110 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 43283 + .word 52727 + .word 26719 + .word 56933 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 18528 + .word 63869 + .word 40120 + .word 60712 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 28913 + .word 42968 + .word 213 + .word 43569 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 2240 + .word 11347 + .word 26371 + .word 51717 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 7147 + .word 20723 + .word 31050 + .word 54241 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 49648 + .word 51324 + .word 11444 + .word 51872 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 8690 + .word 5809 + .word 9903 + .word 46065 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 1296 + .word 54160 + .word 11620 + .word 38443 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 251 + .word 19098 + .word 34161 + .word 60807 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 46412 + .word 5592 + .word 55877 + .word 45861 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 5959 + .word 21591 + .word 50019 + .word 33145 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 2025 + .word 457 + .word 9244 + .word 46095 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 54038 + .word 55252 + .word 55370 + .word 62518 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 47036 + .word 16304 + .word 12880 + .word 40628 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 18241 + .word 19196 + .word 21406 + .word 57530 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 21199 + .word 5012 + .word 49009 + .word 34179 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 54990 + .word 53386 + .word 65270 + .word 33668 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 28726 + .word 33993 + .word 32251 + .word 45542 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 13837 + .word 35230 + .word 52966 + .word 64362 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 39173 + .word 47380 + .word 34462 + .word 36139 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 39489 + .word 64902 + .word 49120 + .word 35472 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 21714 + .word 58783 + .word 27254 + .word 63315 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 7367 + .word 49518 + .word 65112 + .word 52470 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 43556 + .word 37199 + .word 28377 + .word 40908 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 37864 + .word 51941 + .word 23210 + .word 60543 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 51520 + .word 41236 + .word 58920 + .word 42796 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 27066 + .word 4055 + .word 50549 + .word 58076 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 8077 + .word 7791 + .word 5643 + .word 37977 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 56642 + .word 7120 + .word 1392 + .word 48650 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 33215 + .word 4176 + .word 55081 + .word 59653 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 38962 + .word 43845 + .word 18883 + .word 41782 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 9405 + .word 19610 + .word 41716 + .word 40526 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 22463 + .word 33011 + .word 2834 + .word 59404 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 23962 + .word 42196 + .word 52880 + .word 56044 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 56651 + .word 1819 + .word 25970 + .word 41984 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 36494 + .word 8013 + .word 55275 + .word 45183 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 29601 + .word 10973 + .word 29140 + .word 41460 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 33142 + .word 6988 + .word 53485 + .word 34321 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 42305 + .word 46215 + .word 46985 + .word 52653 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 32750 + .word 12648 + .word 9511 + .word 38000 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 28037 + .word 7223 + .word 39341 + .word 52115 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 43511 + .word 40096 + .word 33119 + .word 34189 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 41081 + .word 59110 + .word 54072 + .word 43128 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 52022 + .word 40239 + .word 12039 + .word 52524 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 9970 + .word 11940 + .word 19019 + .word 62959 + .word 49128 + .word 0 + .word 0 + .word 0 + .word 8444 + .word 14648 + .word 8577 + .word 36069 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 47055 + .word 6244 + .word 23935 + .word 45569 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 17962 + .word 25012 + .word 42920 + .word 38222 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 32361 + .word 55573 + .word 62116 + .word 40518 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 23469 + .word 12285 + .word 11074 + .word 41169 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 29710 + .word 22026 + .word 53610 + .word 45713 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 19101 + .word 51375 + .word 37915 + .word 49464 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 1487 + .word 25012 + .word 26269 + .word 42849 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 24702 + .word 7300 + .word 26639 + .word 32851 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 5625 + .word 62032 + .word 62646 + .word 46360 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 16670 + .word 28857 + .word 9900 + .word 61429 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 46530 + .word 36341 + .word 10884 + .word 38667 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 26979 + .word 7608 + .word 53990 + .word 46612 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 13306 + .word 33772 + .word 42194 + .word 54094 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 5215 + .word 26849 + .word 40637 + .word 60704 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 22157 + .word 10775 + .word 9954 + .word 33697 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 62485 + .word 60905 + .word 33942 + .word 35703 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 47033 + .word 9473 + .word 12114 + .word 36373 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 18718 + .word 57887 + .word 63790 + .word 64802 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 60436 + .word 32137 + .word 16772 + .word 44812 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 22870 + .word 68 + .word 14788 + .word 47045 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 13858 + .word 11038 + .word 51083 + .word 33832 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 24411 + .word 53664 + .word 52423 + .word 44992 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 23130 + .word 50537 + .word 29298 + .word 38364 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 59445 + .word 25072 + .word 42634 + .word 55036 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 27750 + .word 60051 + .word 51021 + .word 35697 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 41673 + .word 42346 + .word 29154 + .word 43180 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 24646 + .word 17588 + .word 60780 + .word 49501 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 30636 + .word 48402 + .word 41439 + .word 54315 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 53530 + .word 51574 + .word 33266 + .word 57402 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 24832 + .word 32214 + .word 6566 + .word 58730 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 57338 + .word 52017 + .word 53845 + .word 59748 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 1236 + .word 12983 + .word 25321 + .word 57902 + .word 16352 + .word 0 + .word 0 + .word 0 + .word 42696 + .word 11590 + .word 13704 + .word 47288 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 20112 + .word 35255 + .word 63039 + .word 51665 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 20272 + .word 45351 + .word 26440 + .word 36407 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 23351 + .word 42139 + .word 19582 + .word 38935 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 65431 + .word 27369 + .word 16464 + .word 36140 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 53584 + .word 5561 + .word 32961 + .word 55717 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 39374 + .word 7231 + .word 45599 + .word 56117 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 1294 + .word 6051 + .word 44462 + .word 39418 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 34729 + .word 52585 + .word 9627 + .word 47645 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 17858 + .word 59905 + .word 65371 + .word 52695 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 43933 + .word 27878 + .word 22295 + .word 54792 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 57164 + .word 8466 + .word 41536 + .word 54342 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 62613 + .word 13809 + .word 4914 + .word 51847 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 51382 + .word 5505 + .word 45058 + .word 47893 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 20574 + .word 54447 + .word 25989 + .word 44189 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 20867 + .word 50041 + .word 5177 + .word 38746 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 51710 + .word 33997 + .word 26466 + .word 39335 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 35180 + .word 39426 + .word 44580 + .word 39632 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 39102 + .word 49560 + .word 46254 + .word 52105 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 49858 + .word 3610 + .word 18403 + .word 60348 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 63577 + .word 52764 + .word 23423 + .word 53731 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 17746 + .word 20210 + .word 17254 + .word 46087 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 57780 + .word 38655 + .word 62917 + .word 51922 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 56818 + .word 27103 + .word 46800 + .word 44610 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 42772 + .word 47939 + .word 39429 + .word 53363 + .word 49128 + .word 0 + .word 0 + .word 0 + .word 7127 + .word 43872 + .word 47188 + .word 55109 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 35603 + .word 15923 + .word 26337 + .word 52288 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 15540 + .word 23148 + .word 44469 + .word 46826 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 38573 + .word 44351 + .word 49528 + .word 40134 + .word 49120 + .word 0 + .word 0 + .word 0 + .word 46922 + .word 10206 + .word 58026 + .word 33232 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 48893 + .word 37264 + .word 47364 + .word 55135 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 34563 + .word 54412 + .word 19025 + .word 43320 + .word 16345 + .word 0 + .word 0 + .word 0 + .word 50485 + .word 58441 + .word 18478 + .word 53939 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 57295 + .word 1543 + .word 39725 + .word 59283 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 61902 + .word 50672 + .word 60234 + .word 34832 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 47445 + .word 686 + .word 22678 + .word 38214 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 38808 + .word 16930 + .word 17219 + .word 37683 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 15851 + .word 55325 + .word 43407 + .word 60214 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 1143 + .word 605 + .word 3834 + .word 44087 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 37926 + .word 51721 + .word 32650 + .word 51423 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 719 + .word 37404 + .word 19156 + .word 44137 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 35866 + .word 56877 + .word 40751 + .word 46818 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 17240 + .word 30023 + .word 36586 + .word 42015 + .word 49121 + .word 0 + .word 0 + .word 0 + .word 54230 + .word 7254 + .word 30602 + .word 34461 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 8012 + .word 12609 + .word 22719 + .word 53286 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 30585 + .word 22802 + .word 38382 + .word 39498 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 49910 + .word 61459 + .word 13066 + .word 58648 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 4234 + .word 29117 + .word 43487 + .word 41014 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 15283 + .word 31 + .word 53183 + .word 37265 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 38704 + .word 430 + .word 57551 + .word 43591 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 53647 + .word 31489 + .word 59377 + .word 44715 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 58843 + .word 40196 + .word 27184 + .word 44045 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 21712 + .word 17792 + .word 22495 + .word 41091 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 4064 + .word 22340 + .word 38581 + .word 35349 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 24218 + .word 42337 + .word 60128 + .word 52640 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 20378 + .word 19984 + .word 2299 + .word 54122 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 31249 + .word 59274 + .word 16273 + .word 55107 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 52834 + .word 54517 + .word 12431 + .word 49909 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 54832 + .word 24393 + .word 30353 + .word 51256 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 65180 + .word 60129 + .word 24669 + .word 41244 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 6591 + .word 13357 + .word 31681 + .word 59287 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 26454 + .word 14700 + .word 42966 + .word 39875 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 2956 + .word 33652 + .word 3414 + .word 53265 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 52370 + .word 22181 + .word 28024 + .word 33144 + .word 16337 + .word 0 + .word 0 + .word 0 + .word 13170 + .word 827 + .word 21750 + .word 47190 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 46086 + .word 34614 + .word 16391 + .word 63371 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 23901 + .word 55438 + .word 56964 + .word 55951 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 6825 + .word 37234 + .word 16184 + .word 48173 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 100 + .word 15349 + .word 44285 + .word 40213 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 46705 + .word 62401 + .word 15619 + .word 64493 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 5832 + .word 45818 + .word 5603 + .word 48870 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 26154 + .word 11509 + .word 12905 + .word 33853 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 57899 + .word 64916 + .word 17522 + .word 39399 + .word 16352 + .word 0 + .word 0 + .word 0 + .word 11797 + .word 62659 + .word 15787 + .word 52982 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 4387 + .word 49305 + .word 27685 + .word 41688 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 8893 + .word 53993 + .word 6961 + .word 62732 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 6561 + .word 49840 + .word 37854 + .word 49392 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 22913 + .word 52496 + .word 16836 + .word 64532 + .word 16337 + .word 0 + .word 0 + .word 0 + .word 61478 + .word 12903 + .word 22917 + .word 40137 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 20254 + .word 5653 + .word 41280 + .word 45163 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 9250 + .word 21583 + .word 29887 + .word 42398 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 21296 + .word 56033 + .word 20302 + .word 45697 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 2595 + .word 14223 + .word 9373 + .word 34428 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 43880 + .word 13192 + .word 17465 + .word 51046 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 10750 + .word 52386 + .word 15061 + .word 37140 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 43380 + .word 26688 + .word 4603 + .word 52842 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 57923 + .word 50589 + .word 40806 + .word 36546 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 41550 + .word 43340 + .word 52700 + .word 48703 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 2829 + .word 50954 + .word 33981 + .word 61546 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 53540 + .word 53334 + .word 26985 + .word 35726 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 1383 + .word 41626 + .word 39002 + .word 35204 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 4988 + .word 17152 + .word 47624 + .word 42298 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 13081 + .word 59676 + .word 51281 + .word 43278 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 20576 + .word 9083 + .word 44900 + .word 60572 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 5241 + .word 64752 + .word 26216 + .word 43285 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 54740 + .word 4493 + .word 22744 + .word 47855 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 40170 + .word 38190 + .word 50840 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 64000 + .word 51124 + .word 38392 + .word 32771 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 6193 + .word 27449 + .word 18043 + .word 41906 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 55083 + .word 10857 + .word 24850 + .word 53024 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 39204 + .word 24043 + .word 43883 + .word 33151 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 16615 + .word 33399 + .word 37109 + .word 40897 + .word 49128 + .word 0 + .word 0 + .word 0 + .word 45005 + .word 13768 + .word 23576 + .word 49662 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 19875 + .word 47904 + .word 27295 + .word 59169 + .word 49120 + .word 0 + .word 0 + .word 0 + .word 50767 + .word 38341 + .word 26349 + .word 34421 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 61460 + .word 9200 + .word 49063 + .word 38824 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 17698 + .word 13464 + .word 19312 + .word 41938 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 14145 + .word 49711 + .word 41841 + .word 42410 + .word 49105 + .word 0 + .word 0 + .word 0 + .word 52259 + .word 38890 + .word 11861 + .word 38197 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 37928 + .word 15208 + .word 58116 + .word 52459 + .word 49096 + .word 0 + .word 0 + .word 0 + .word 32955 + .word 48671 + .word 55988 + .word 42873 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 10284 + .word 13591 + .word 10015 + .word 45425 + .word 16321 + .word 0 + .word 0 + .word 0 + .word 60165 + .word 7231 + .word 29309 + .word 47020 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 2826 + .word 34241 + .word 10052 + .word 46822 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 38150 + .word 11520 + .word 57874 + .word 50634 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 13154 + .word 32010 + .word 59285 + .word 54374 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 3630 + .word 36258 + .word 15737 + .word 57945 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 33484 + .word 32040 + .word 11194 + .word 61229 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 29890 + .word 19177 + .word 6587 + .word 64088 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 47912 + .word 33375 + .word 45262 + .word 33179 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 35727 + .word 49010 + .word 4249 + .word 33927 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 48287 + .word 11774 + .word 34966 + .word 34177 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 59219 + .word 12218 + .word 14591 + .word 33807 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 45587 + .word 38263 + .word 60150 + .word 65351 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 64248 + .word 19753 + .word 11467 + .word 61248 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 8987 + .word 4417 + .word 35296 + .word 54967 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 58348 + .word 59855 + .word 58179 + .word 46574 + .word 16322 + .word 0 + .word 0 + .word 0 + .word 838 + .word 40288 + .word 16803 + .word 34203 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 19985 + .word 64792 + .word 35689 + .word 34160 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 63242 + .word 24737 + .word 37564 + .word 33357 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 21080 + .word 30395 + .word 32053 + .word 60879 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 31967 + .word 27284 + .word 22818 + .word 55292 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 25886 + .word 29922 + .word 20917 + .word 49964 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 16415 + .word 22145 + .word 37135 + .word 44903 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 60061 + .word 56529 + .word 59607 + .word 40115 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 61716 + .word 63444 + .word 60667 + .word 35604 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 44658 + .word 58531 + .word 9530 + .word 62744 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 62260 + .word 39586 + .word 42345 + .word 54833 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 28253 + .word 12485 + .word 44364 + .word 47473 + .word 16336 + .word 0 + .word 0 + .word 0 + .word 12640 + .word 24607 + .word 1626 + .word 40656 + .word 49100 + .word 0 + .word 0 + .word 0 + .word 34428 + .word 36370 + .word 1024 + .word 34362 + .word 16328 + .word 0 + .word 0 + .word 0 + .word 29040 + .word 20316 + .word 63988 + .word 57186 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 56625 + .word 35023 + .word 4494 + .word 47694 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 12074 + .word 64589 + .word 55447 + .word 37930 + .word 49083 + .word 0 + .word 0 + .word 0 + .word 50967 + .word 1382 + .word 5204 + .word 52101 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 3284 + .word 33134 + .word 2262 + .word 47439 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 46363 + .word 11691 + .word 13356 + .word 36476 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 3419 + .word 29155 + .word 56063 + .word 55913 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 46070 + .word 27060 + .word 45787 + .word 42709 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 48455 + .word 49617 + .word 63339 + .word 65012 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 11309 + .word 38321 + .word 50476 + .word 49291 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 63177 + .word 54179 + .word 19446 + .word 37218 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 17008 + .word 20702 + .word 63396 + .word 55953 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 58916 + .word 21526 + .word 44533 + .word 41856 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 4054 + .word 60910 + .word 64524 + .word 62288 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 572 + .word 56463 + .word 6651 + .word 46074 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 294 + .word 32916 + .word 12940 + .word 33845 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 61241 + .word 23461 + .word 12133 + .word 49362 + .word 49088 + .word 0 + .word 0 + .word 0 + .word 43813 + .word 54697 + .word 47595 + .word 36628 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 7023 + .word 63196 + .word 1211 + .word 52552 + .word 49079 + .word 0 + .word 0 + .word 0 + .word 49710 + .word 23216 + .word 57316 + .word 57937 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 16917 + .word 54685 + .word 15559 + .word 33684 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 19402 + .word 20755 + .word 35177 + .word 43607 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 18988 + .word 7708 + .word 26373 + .word 56330 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 31678 + .word 36048 + .word 15370 + .word 36299 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 62053 + .word 9463 + .word 59420 + .word 46669 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 43189 + .word 37083 + .word 47017 + .word 59851 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 56431 + .word 23594 + .word 54456 + .word 38275 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 57207 + .word 5358 + .word 61057 + .word 48816 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 55955 + .word 61547 + .word 7096 + .word 62073 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 38324 + .word 43297 + .word 2038 + .word 39337 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 48019 + .word 63539 + .word 58854 + .word 49683 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 38415 + .word 45891 + .word 48038 + .word 62495 + .word 16321 + .word 0 + .word 0 + .word 0 + .word 6285 + .word 58141 + .word 38062 + .word 39153 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 8535 + .word 47970 + .word 20521 + .word 50223 + .word 16312 + .word 0 + .word 0 + .word 0 + .word 3599 + .word 31205 + .word 53376 + .word 62523 + .word 49075 + .word 0 + .word 0 + .word 0 + .word 53390 + .word 39428 + .word 31508 + .word 33365 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 24907 + .word 1998 + .word 17203 + .word 47787 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 65154 + .word 44054 + .word 55771 + .word 52050 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 59345 + .word 56252 + .word 17241 + .word 56609 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 21068 + .word 33081 + .word 36502 + .word 61470 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 5838 + .word 32265 + .word 27141 + .word 33320 + .word 49121 + .word 0 + .word 0 + .word 0 + .word 13157 + .word 36097 + .word 56398 + .word 36061 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 34641 + .word 3406 + .word 61161 + .word 38959 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 36822 + .word 2107 + .word 7812 + .word 42013 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 57689 + .word 7026 + .word 46609 + .word 45217 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 65442 + .word 46672 + .word 32230 + .word 48567 + .word 16328 + .word 0 + .word 0 + .word 0 + .word 38794 + .word 56166 + .word 59740 + .word 52052 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 7020 + .word 42539 + .word 58408 + .word 55641 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 5792 + .word 16154 + .word 40642 + .word 59348 + .word 49081 + .word 0 + .word 0 + .word 0 + .word 45758 + .word 39239 + .word 10684 + .word 64996 + .word 16308 + .word 0 + .word 0 + .word 0 + .word 17135 + .word 25280 + .word 14240 + .word 34593 + .word 49072 + .word 0 + .word 0 + .word 0 + .word 22956 + .word 27174 + .word 6236 + .word 35739 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 41448 + .word 9608 + .word 15061 + .word 33872 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 35041 + .word 22115 + .word 31787 + .word 62060 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 47943 + .word 57954 + .word 5630 + .word 56794 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 12256 + .word 51468 + .word 48243 + .word 51918 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 16861 + .word 555 + .word 19712 + .word 47409 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 14521 + .word 28998 + .word 64476 + .word 43241 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 42742 + .word 52364 + .word 18112 + .word 39394 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 11937 + .word 57143 + .word 59317 + .word 35844 + .word 16336 + .word 0 + .word 0 + .word 0 + .word 54775 + .word 41142 + .word 37066 + .word 65147 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 52047 + .word 20166 + .word 2989 + .word 59124 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 63890 + .word 14576 + .word 19973 + .word 53583 + .word 49088 + .word 0 + .word 0 + .word 0 + .word 51017 + .word 21644 + .word 32682 + .word 48474 + .word 16315 + .word 0 + .word 0 + .word 0 + .word 14951 + .word 9527 + .word 54932 + .word 43797 + .word 49078 + .word 0 + .word 0 + .word 0 + .word 19956 + .word 63323 + .word 21590 + .word 40697 + .word 16305 + .word 0 + .word 0 + .word 0 + .word 13287 + .word 59412 + .word 52293 + .word 36781 + .word 49068 + .word 0 + .word 0 + .word 0 + .word 20654 + .word 3963 + .word 37243 + .word 46202 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 14259 + .word 41161 + .word 56379 + .word 47991 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 29552 + .word 20159 + .word 19967 + .word 36969 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 36671 + .word 37033 + .word 31146 + .word 56915 + .word 49128 + .word 0 + .word 0 + .word 0 + .word 40096 + .word 16159 + .word 8745 + .word 43779 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 31426 + .word 40251 + .word 6629 + .word 33649 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 62460 + .word 14572 + .word 46922 + .word 51685 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 21330 + .word 50824 + .word 20752 + .word 39663 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 59043 + .word 6300 + .word 36178 + .word 60824 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 11117 + .word 55297 + .word 15596 + .word 46598 + .word 49096 + .word 0 + .word 0 + .word 0 + .word 52972 + .word 24185 + .word 7857 + .word 35668 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 48165 + .word 35957 + .word 4973 + .word 54554 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 40559 + .word 40135 + .word 50657 + .word 41665 + .word 16312 + .word 0 + .word 0 + .word 0 + .word 22209 + .word 12399 + .word 38770 + .word 63599 + .word 49074 + .word 0 + .word 0 + .word 0 + .word 21134 + .word 56966 + .word 28654 + .word 49967 + .word 16301 + .word 0 + .word 0 + .word 0 + .word 55252 + .word 38724 + .word 60696 + .word 38196 + .word 49064 + .word 0 + .word 0 + .word 0 + .word 50324 + .word 38050 + .word 41691 + .word 52128 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 57576 + .word 19017 + .word 35093 + .word 33984 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 45261 + .word 53464 + .word 26203 + .word 44021 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 59506 + .word 58350 + .word 50456 + .word 56993 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 39656 + .word 29013 + .word 30706 + .word 36875 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 15950 + .word 25278 + .word 29858 + .word 47692 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 44951 + .word 52254 + .word 26639 + .word 61649 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 14884 + .word 15288 + .word 36355 + .word 39823 + .word 49105 + .word 0 + .word 0 + .word 0 + .word 33589 + .word 37339 + .word 42662 + .word 51420 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 59837 + .word 52901 + .word 27833 + .word 33178 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 23530 + .word 8792 + .word 46326 + .word 42790 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 22918 + .word 41993 + .word 30280 + .word 55154 + .word 49082 + .word 0 + .word 0 + .word 0 + .word 22935 + .word 40180 + .word 10208 + .word 35510 + .word 16309 + .word 0 + .word 0 + .word 0 + .word 24655 + .word 6092 + .word 5569 + .word 45708 + .word 49071 + .word 0 + .word 0 + .word 0 + .word 1836 + .word 9946 + .word 17030 + .word 60600 + .word 16297 + .word 0 + .word 0 + .word 0 + .word 58034 + .word 64044 + .word 12732 + .word 39095 + .word 49060 + .word 0 + .word 0 + .word 0 + .word 54043 + .word 4884 + .word 4993 + .word 50896 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 52175 + .word 36282 + .word 1403 + .word 48115 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 8979 + .word 278 + .word 60581 + .word 52397 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 62427 + .word 36042 + .word 64958 + .word 57041 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 22617 + .word 56486 + .word 29933 + .word 62075 + .word 16352 + .word 0 + .word 0 + .word 0 + .word 6668 + .word 34800 + .word 16726 + .word 33764 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 58438 + .word 34332 + .word 45904 + .word 36716 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 64514 + .word 12491 + .word 17770 + .word 39912 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 38781 + .word 4147 + .word 20350 + .word 43369 + .word 16329 + .word 0 + .word 0 + .word 0 + .word 11653 + .word 23288 + .word 23101 + .word 47107 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 24538 + .word 52112 + .word 19258 + .word 51147 + .word 16317 + .word 0 + .word 0 + .word 0 + .word 55081 + .word 11864 + .word 2795 + .word 55511 + .word 49079 + .word 0 + .word 0 + .word 0 + .word 30359 + .word 7516 + .word 42523 + .word 60199 + .word 16305 + .word 0 + .word 0 + .word 0 + .word 51632 + .word 54516 + .word 60788 + .word 65273 + .word 49067 + .word 0 + .word 0 + .word 0 + .word 8259 + .word 26817 + .word 16640 + .word 36463 + .word 16294 + .word 0 + .word 0 + .word 0 + .word 25358 + .word 21633 + .word 63088 + .word 39650 + .word 49056 + .word 0 + .word 0 + .word 0 + .word 37940 + .word 45084 + .word 22741 + .word 53976 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 56905 + .word 35663 + .word 13071 + .word 34053 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 6338 + .word 45524 + .word 29128 + .word 62353 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 53870 + .word 55231 + .word 26051 + .word 57072 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 25356 + .word 27338 + .word 39402 + .word 52225 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 53832 + .word 61470 + .word 21273 + .word 47778 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 58577 + .word 63695 + .word 35460 + .word 43698 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 4520 + .word 44723 + .word 47409 + .word 39956 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 1812 + .word 29018 + .word 42821 + .word 36525 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 59061 + .word 29228 + .word 16191 + .word 33380 + .word 49089 + .word 0 + .word 0 + .word 0 + .word 39396 + .word 18010 + .word 60638 + .word 60994 + .word 16314 + .word 0 + .word 0 + .word 0 + .word 49088 + .word 9900 + .word 51011 + .word 55711 + .word 49076 + .word 0 + .word 0 + .word 0 + .word 37150 + .word 50516 + .word 56492 + .word 50852 + .word 16302 + .word 0 + .word 0 + .word 0 + .word 28484 + .word 40361 + .word 52896 + .word 46416 + .word 49064 + .word 0 + .word 0 + .word 0 + .word 62255 + .word 31126 + .word 18737 + .word 43665 + .word 16290 + .word 0 + .word 0 + .word 0 + .word 12057 + .word 58357 + .word 2287 + .word 39984 + .word 49052 + .word 0 + .word 0 + .word 0 + .word 10303 + .word 34822 + .word 30753 + .word 42638 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 35383 + .word 38620 + .word 16953 + .word 48193 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 33393 + .word 6703 + .word 23267 + .word 37093 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 15343 + .word 55882 + .word 8818 + .word 57090 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 43704 + .word 64267 + .word 56511 + .word 43925 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 4607 + .word 47760 + .word 9543 + .word 33791 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 56389 + .word 24814 + .word 13621 + .word 51980 + .word 16337 + .word 0 + .word 0 + .word 0 + .word 53957 + .word 28278 + .word 52920 + .word 39972 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 44558 + .word 56829 + .word 64035 + .word 61466 + .word 16324 + .word 0 + .word 0 + .word 0 + .word 38720 + .word 53021 + .word 48635 + .word 47250 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 44746 + .word 16730 + .word 48948 + .word 36315 + .word 16312 + .word 0 + .word 0 + .word 0 + .word 35899 + .word 1861 + .word 5901 + .word 55812 + .word 49073 + .word 0 + .word 0 + .word 0 + .word 22074 + .word 38313 + .word 14608 + .word 42863 + .word 16299 + .word 0 + .word 0 + .word 0 + .word 55515 + .word 23576 + .word 64018 + .word 32920 + .word 49061 + .word 0 + .word 0 + .word 0 + .word 12839 + .word 2194 + .word 19804 + .word 52126 + .word 16286 + .word 0 + .word 0 + .word 0 + .word 11439 + .word 41150 + .word 15351 + .word 40172 + .word 49048 + .word 0 + .word 0 + .word 0 + .word 29431 + .word 9874 + .word 45662 + .word 49530 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 65266 + .word 58931 + .word 1289 + .word 34097 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 37900 + .word 52013 + .word 19533 + .word 44126 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 56648 + .word 29183 + .word 44293 + .word 57098 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 6159 + .word 2813 + .word 55364 + .word 36937 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 43479 + .word 31839 + .word 13895 + .word 47785 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 5187 + .word 20139 + .word 24873 + .word 61810 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 122 + .word 12763 + .word 63612 + .word 39970 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 44050 + .word 14658 + .word 36451 + .word 51689 + .word 16322 + .word 0 + .word 0 + .word 0 + .word 25644 + .word 4873 + .word 38936 + .word 33417 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 47798 + .word 57836 + .word 54492 + .word 43203 + .word 16309 + .word 0 + .word 0 + .word 0 + .word 13594 + .word 52300 + .word 36178 + .word 55848 + .word 49070 + .word 0 + .word 0 + .word 0 + .word 62324 + .word 37045 + .word 44215 + .word 36078 + .word 16296 + .word 0 + .word 0 + .word 0 + .word 9408 + .word 55695 + .word 35369 + .word 46620 + .word 49057 + .word 0 + .word 0 + .word 0 + .word 55933 + .word 58459 + .word 63135 + .word 62102 + .word 16282 + .word 0 + .word 0 + .word 0 + .word 9035 + .word 28599 + .word 9663 + .word 40267 + .word 49044 + .word 0 + .word 0 + .word 0 + .word 64440 + .word 9942 + .word 11459 + .word 51063 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 54621 + .word 1381 + .word 54593 + .word 57593 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 57672 + .word 22144 + .word 48770 + .word 34240 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 41335 + .word 40315 + .word 35384 + .word 40709 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 44154 + .word 2667 + .word 29983 + .word 48395 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 11933 + .word 28752 + .word 33333 + .word 57526 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 28038 + .word 64578 + .word 40018 + .word 34186 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 37517 + .word 65009 + .word 17291 + .word 40628 + .word 49096 + .word 0 + .word 0 + .word 0 + .word 55118 + .word 35846 + .word 36301 + .word 48278 + .word 16321 + .word 0 + .word 0 + .word 0 + .word 8485 + .word 24440 + .word 14912 + .word 57363 + .word 49082 + .word 0 + .word 0 + .word 0 + .word 32377 + .word 28880 + .word 65211 + .word 34074 + .word 16308 + .word 0 + .word 0 + .word 0 + .word 34616 + .word 16831 + .word 8616 + .word 40478 + .word 49069 + .word 0 + .word 0 + .word 0 + .word 8999 + .word 50919 + .word 12017 + .word 48079 + .word 16294 + .word 0 + .word 0 + .word 0 + .word 35787 + .word 61739 + .word 12812 + .word 57101 + .word 49055 + .word 0 + .word 0 + .word 0 + .word 44504 + .word 58876 + .word 42861 + .word 33904 + .word 16281 + .word 0 + .word 0 + .word 0 + .word 47876 + .word 27247 + .word 49503 + .word 40257 + .word 49042 + .word 0 + .word 0 + .word 0 + .type _erfcl_Q,@object + .size _erfcl_Q,7168 + .align 2 +_erfcl_S: + .word 0 + .word 0 + .word 0 + .word 57344 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56559 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55197 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45662 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45290 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44607 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43781 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42924 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42104 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41357 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40696 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40122 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39629 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39210 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38855 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38556 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38304 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38091 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37913 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37763 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37637 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37531 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37442 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37368 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37305 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37252 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37208 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37189 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _erfcl_S,@object + .size _erfcl_S,448 + .align 2 +_erfcl_UNDERFLOW_INT: + .word 42217 + .word 46880 + .word 24677 + .word 54546 + .word 16389 + .word 0 + .word 0 + .word 0 + .type _erfcl_UNDERFLOW_INT,@object + .size _erfcl_UNDERFLOW_INT,16 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/erff.S b/external/sgx_libm/intel64/erff.S new file mode 100644 index 0000000000..07752ac1c5 --- /dev/null +++ b/external/sgx_libm/intel64/erff.S @@ -0,0 +1,254 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erff.c" + .text +..TXTST0: +# -- Begin erff + .text + .align 16,0x90 + .globl erff +erff: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_erff.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -16(%rsp) + movl %edx, %eax + andl $2147483647, %edx + andl $-2147483648, %eax + orl $1065353216, %eax + movl %eax, -24(%rsp) + cmpl $2139095040, %edx + movss -24(%rsp), %xmm0 + jge ..B1.8 +..B1.2: + cmpl $1081791744, %edx + jge ..B1.7 +..B1.3: + cmpl $1065353216, %edx + jl ..B1.5 +..B1.4: + movl %edx, %eax + andl $8388607, %edx + orl $1065353216, %edx + pxor %xmm4, %xmm4 + movl %edx, -24(%rsp) + lea _dbA(%rip), %rsi + shrl $23, %eax + cvtss2sd -24(%rsp), %xmm4 + cvtss2sd %xmm0, %xmm0 + subsd .L_2il0floatpacket.0(%rip), %xmm4 + movaps %xmm4, %xmm3 + lea -1016(,%rax,8), %edx + mulsd %xmm4, %xmm3 + lea -508(%rdx,%rax,4), %ecx + movslq %ecx, %rcx + movaps %xmm3, %xmm7 + mulsd %xmm3, %xmm7 + movsd 152(%rsi,%rcx,8), %xmm6 + mulsd %xmm4, %xmm6 + movsd 120(%rsi,%rcx,8), %xmm8 + mulsd %xmm4, %xmm8 + addsd 144(%rsi,%rcx,8), %xmm6 + movsd 136(%rsi,%rcx,8), %xmm5 + mulsd %xmm3, %xmm6 + addsd 112(%rsi,%rcx,8), %xmm8 + mulsd %xmm4, %xmm5 + mulsd %xmm3, %xmm8 + addsd %xmm5, %xmm6 + movsd 88(%rsi,%rcx,8), %xmm9 + movsd 104(%rsi,%rcx,8), %xmm2 + mulsd %xmm4, %xmm9 + addsd 128(%rsi,%rcx,8), %xmm6 + mulsd %xmm4, %xmm2 + mulsd %xmm7, %xmm6 + addsd 80(%rsi,%rcx,8), %xmm9 + addsd %xmm2, %xmm8 + mulsd %xmm3, %xmm9 + addsd 96(%rsi,%rcx,8), %xmm8 + movsd 72(%rsi,%rcx,8), %xmm1 + addsd %xmm6, %xmm8 + mulsd %xmm4, %xmm1 + mulsd %xmm7, %xmm8 + addsd %xmm1, %xmm9 + addsd 64(%rsi,%rcx,8), %xmm9 + addsd %xmm8, %xmm9 + mulsd %xmm0, %xmm9 + cvtsd2ss %xmm9, %xmm9 + jmp ..B1.6 +..B1.5: + pxor %xmm3, %xmm3 + lea 56+_dbA(%rip), %rdi + lea 48+_dbA(%rip), %rax + lea 40+_dbA(%rip), %r8 + lea 32+_dbA(%rip), %rdx + lea 24+_dbA(%rip), %r9 + lea 16+_dbA(%rip), %rcx + lea 8+_dbA(%rip), %r10 + movsd (%rdi), %xmm2 + lea _dbA(%rip), %rsi + movsd (%rax), %xmm9 + cvtss2sd -16(%rsp), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm9 + addsd (%r8), %xmm2 + addsd (%rdx), %xmm9 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm9 + addsd (%r9), %xmm2 + addsd (%rcx), %xmm9 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm9 + addsd (%r10), %xmm2 + addsd (%rsi), %xmm9 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm9 + mulsd %xmm3, %xmm9 + cvtsd2ss %xmm9, %xmm9 +..B1.6: + movaps %xmm9, %xmm0 + ret +..B1.7: + cvtss2sd %xmm0, %xmm0 + lea 256+_dbA(%rip), %rax + mulsd (%rax), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.8: + movss -16(%rsp), %xmm1 + addss %xmm1, %xmm1 + je ..L3 + movaps %xmm1, %xmm0 +..L3: + ret + .align 16,0x90 + .cfi_endproc + .type erff,@function + .size erff,.-erff + .data +# -- End erff + .section .rodata, "a" + .align 16 + .align 16 +_dbA: + .long 1346373606 + .long 1072827863 + .long 1710987328 + .long 3218608756 + .long 2039146822 + .long 1069343472 + .long 2052989911 + .long 3214639770 + .long 3741021613 + .long 1064657550 + .long 2828932584 + .long 3209415657 + .long 556515485 + .long 1058898537 + .long 1493771156 + .long 3202627648 + .long 1460823802 + .long 1072622165 + .long 647757120 + .long 1069445687 + .long 1478820123 + .long 3217479081 + .long 827266439 + .long 1069662880 + .long 4153551678 + .long 3215381932 + .long 3249389370 + .long 3213783616 + .long 3875823656 + .long 1066650297 + .long 2479749796 + .long 3212012677 + .long 4079794357 + .long 3210967401 + .long 3292960271 + .long 1062989018 + .long 1338933997 + .long 3204757561 + .long 4209598023 + .long 3207545998 + .long 2886434981 + .long 1072693201 + .long 1721637260 + .long 1060257935 + .long 960688093 + .long 3210436681 + .long 1128797080 + .long 1064950642 + .long 798939459 + .long 3213958757 + .long 937205111 + .long 1067493282 + .long 3504975339 + .long 3215465534 + .long 3388113641 + .long 1068080152 + .long 9542307 + .long 3215088353 + .long 1310184383 + .long 1065080747 + .long 3264801679 + .long 1066837484 + .long 3394984936 + .long 3214223095 + .long 4294967295 + .long 1072693247 + .type _dbA,@object + .size _dbA,264 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3ff80000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/erfl.S b/external/sgx_libm/intel64/erfl.S new file mode 100644 index 0000000000..22d826349b --- /dev/null +++ b/external/sgx_libm/intel64/erfl.S @@ -0,0 +1,2357 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "erfl.c" + .text +..TXTST0: +# -- Begin erfl + .text + .align 16,0x90 + .globl erfl +erfl: +# parameter 1: 80 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_erfl.1: +..L2: + + subq $72, %rsp + .cfi_def_cfa_offset 80 + xorb %dl, %dl +..B1.2: + fnstcw 58(%rsp) +..B1.3: + movzwl 58(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %ecx + movw %cx, 56(%rsp) +..B1.5: + fldcw 56(%rsp) +..B1.6: + movb $1, %dl +..B1.7: + movb 89(%rsp), %cl + lea ones(%rip), %rsi + andb $-128, %cl + shrb $7, %cl + movzbl %cl, %edi + movzwl 88(%rsp), %eax + andl $32767, %eax + movzwl 86(%rsp), %r8d + movss (%rsi,%rdi,4), %xmm0 + movl %eax, %esi + shll $16, %esi + orl %r8d, %esi + cmpl $32767, %eax + je ..B1.32 +..B1.8: + cmpl $1073860832, %esi + jge ..B1.26 +..B1.9: + fldt 80(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fldt .L_2il0floatpacket.0(%rip) + fucomip %st(1), %st + fstp %st(0) + jp ..B1.10 + je ..B1.29 +..B1.10: + cmpl $16343, %eax + jle ..B1.18 +..B1.11: + cmpl $16380, %eax + jge ..B1.15 +..B1.12: + fldt 32(%rsp) + lea 128+_ldbA(%rip), %rcx + fld %st(0) + lea 112+_ldbA(%rip), %rsi + fmul %st(1), %st + lea _TWO_32H(%rip), %rax + lea 96+_ldbA(%rip), %rdi + fld %st(1) + lea 80+_ldbA(%rip), %r8 + lea 64+_ldbA(%rip), %r9 + lea 48+_ldbA(%rip), %r10 + lea 32+_ldbA(%rip), %r11 + fld %st(2) + testb %dl, %dl + fldl (%rax) + lea 16+_ldbA(%rip), %rax + fmul %st(4), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fsub %st(1), %st + fldt (%rcx) + fmul %st(3), %st + fldt (%rsi) + lea _ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%rax) + fmul %st(4), %st + fxch %st(3) + fmulp %st, %st(4) + fldt (%rcx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + je ..B1.14 +..B1.13: + fldcw 58(%rsp) +..B1.14: + fldt 32(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.15: + fldt 32(%rsp) + lea -1073793024(%rsi), %eax + shrl $16, %esi + movl $6, %ecx + movss %xmm0, 48(%rsp) + lea erfRRTable(%rip), %r8 + fmuls 48(%rsp) + addq $-16380, %rsi + cmpl $47103, %eax + lea _ldbA(%rip), %r11 + lea _TWO_32H(%rip), %r10 + cmovbe %rcx, %rsi + movq %rsi, %r9 + movl %esi, %edi + shlq $4, %r9 + shll $5, %edi + subl %esi, %edi + subl %esi, %edi + fmull (%r9,%r8) + movslq %edi, %rdi + faddl 8(%r8,%r9) + shlq $4, %rdi + fstpt 32(%rsp) + fldt 32(%rsp) + testb %dl, %dl + fldt 608(%r11,%rdi) + fmul %st(1), %st + fldt 592(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 576(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 560(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 544(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 528(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 512(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 496(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 480(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 464(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 448(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 432(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 416(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 400(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 384(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 368(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 352(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt 336(%r11,%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fld %st(1) + fldt 320(%r11,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 304(%r11,%rdi) + faddp %st, %st(1) + fmul %st(2), %st + fldt 288(%r11,%rdi) + faddp %st, %st(1) + fmul %st(2), %st + fld %st(2) + fldt 272(%r11,%rdi) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldl (%r10) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fld %st(0) + fxch %st(3) + fsub %st(4), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(6), %st + fmul %st(2), %st + faddp %st, %st(3) + fld %st(3) + fmul %st(1), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + fsub %st(4), %st + faddp %st, %st(2) + fldt 176(%r11,%rdi) + fld %st(0) + fmul %st(6), %st + fstpt 16(%rsp) + fmul %st(1), %st + fldt 192(%r11,%rdi) + fmul %st(7), %st + faddp %st, %st(1) + fldt 240(%r11,%rdi) + fmul %st, %st(6) + fmulp %st, %st(2) + fldt 256(%r11,%rdi) + fmulp %st, %st(7) + fxch %st(6) + faddp %st, %st(1) + fldt 208(%r11,%rdi) + fld %st(0) + fadd %st(6), %st + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(6) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 224(%r11,%rdi) + faddp %st, %st(1) + fld %st(4) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fmul %st(4), %st + fxch %st(3) + fsubr %st, %st(5) + fxch %st(1) + faddp %st, %st(5) + fxch %st(3) + fmul %st(4), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 144(%r11,%rdi) + fld %st(0) + fldt 16(%rsp) + fadd %st, %st(1) + fld %st(1) + fadd %st(5), %st + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(5) + faddp %st, %st(2) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fldt 32(%rsp) + fld %st(0) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fldt (%rsp) + fmulp %st, %st(1) + fldt 160(%r11,%rdi) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fmuls 48(%rsp) + fstpt (%rsp) + je ..B1.17 +..B1.16: + fldcw 58(%rsp) +..B1.17: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.18: + fldt 32(%rsp) + lea _TWO5600(%rip), %rcx + lea _TWO_32H(%rip), %rdi + lea _ldbA(%rip), %r8 + lea 16+_ldbA(%rip), %r9 + testl %eax, %eax + fldt (%rcx) + fmul %st, %st(1) + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%rdi) + fld %st(0) + fmul %st(2), %st + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(1) + fld %st(0) + fsubr %st(3), %st + fldt (%r8) + fmul %st, %st(2) + fmulp %st, %st(1) + fldt (%r9) + fmulp %st, %st(4) + faddp %st, %st(3) + jne ..B1.22 +..B1.19: + testl $65520, %esi + je ..B1.22 +..B1.20: + fldt 32(%rsp) + lea _DenoBND(%rip), %rax + movss %xmm0, 48(%rsp) + flds 48(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fmul %st(5), %st + fcomip %st(1), %st + fstp %st(0) + jbe ..B1.22 +..B1.21: + fstp %st(3) + fld %st(2) + lea 16+_TWO5600(%rip), %rax + fadd %st(2), %st + fmul %st, %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fldt (%rax) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + jmp ..B1.23 +..B1.22: + fstp %st(1) + fstp %st(2) + lea 16+_TWO5600(%rip), %rax + faddp %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.23: + testb %dl, %dl + je ..B1.25 +..B1.24: + fldcw 58(%rsp) +..B1.25: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.26: + lea _Epsilon(%rip), %rax + testb %dl, %dl + movss %xmm0, 48(%rsp) + flds 48(%rsp) + fldt (%rax) + fmul %st(1), %st + fsubrp %st, %st(1) + fstpt (%rsp) + je ..B1.28 +..B1.27: + fldcw 58(%rsp) +..B1.28: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.29: + testb %dl, %dl + je ..B1.31 +..B1.30: + fldcw 58(%rsp) + fldt 80(%rsp) + fstpt 32(%rsp) +..B1.31: + fldt 32(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.32: + fldt 80(%rsp) + movq $0x8000000000000000, %rax + movss %xmm0, 48(%rsp) + fadd %st(0), %st + flds 48(%rsp) + cmpq 80(%rsp), %rax + fcmovne %st(1), %st + fstp %st(1) + fstpt (%rsp) + testb %dl, %dl + je ..B1.34 +..B1.33: + fldcw 58(%rsp) +..B1.34: + fldt (%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type erfl,@function + .size erfl,.-erfl + .data +# -- End erfl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +_ldbA: + .word 0 + .word 0 + .word 47746 + .word 36974 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 30720 + .word 36515 + .word 17515 + .word 42715 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 13842 + .word 7119 + .word 41816 + .word 49299 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 3215 + .word 8543 + .word 37072 + .word 59159 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 33545 + .word 17489 + .word 29065 + .word 56342 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 23161 + .word 4543 + .word 59015 + .word 43821 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 15198 + .word 65095 + .word 55656 + .word 57366 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 11319 + .word 61676 + .word 11803 + .word 64720 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 23735 + .word 16978 + .word 56014 + .word 63664 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61888 + .word 54818 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 10044 + .word 28505 + .word 55013 + .word 60780 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27524 + .word 35697 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 61965 + .word 13477 + .word 25391 + .word 40556 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8518 + .word 53546 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 60180 + .word 52984 + .word 38086 + .word 60834 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60744 + .word 44249 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 63138 + .word 9916 + .word 20408 + .word 61684 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 50506 + .word 17424 + .word 9343 + .word 52291 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 50365 + .word 34444 + .word 5016 + .word 49178 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 17941 + .word 44182 + .word 56946 + .word 34035 + .word 49128 + .word 0 + .word 0 + .word 0 + .word 41364 + .word 35872 + .word 36905 + .word 43189 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 47342 + .word 2906 + .word 40861 + .word 33222 + .word 16352 + .word 0 + .word 0 + .word 0 + .word 48408 + .word 44394 + .word 43316 + .word 61646 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 52639 + .word 32949 + .word 29686 + .word 51873 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 13354 + .word 8312 + .word 46883 + .word 36813 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 10783 + .word 42642 + .word 20549 + .word 33739 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 42435 + .word 44080 + .word 27835 + .word 37640 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 55413 + .word 51626 + .word 37570 + .word 37609 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 62471 + .word 35756 + .word 61962 + .word 33520 + .word 49089 + .word 0 + .word 0 + .word 0 + .word 40388 + .word 48302 + .word 32466 + .word 36673 + .word 16317 + .word 0 + .word 0 + .word 0 + .word 21782 + .word 37556 + .word 26897 + .word 52597 + .word 16311 + .word 0 + .word 0 + .word 0 + .word 35272 + .word 16771 + .word 34830 + .word 63430 + .word 49075 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26972 + .word 52968 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 34629 + .word 50944 + .word 29785 + .word 56844 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26328 + .word 64248 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 5285 + .word 428 + .word 53188 + .word 60110 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19746 + .word 48186 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 3964 + .word 321 + .word 7123 + .word 45083 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25230 + .word 61571 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 57803 + .word 48946 + .word 59164 + .word 36732 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 46948 + .word 32819 + .word 54758 + .word 43668 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 16614 + .word 63709 + .word 23635 + .word 47684 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 5734 + .word 50071 + .word 41702 + .word 52540 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 1767 + .word 50346 + .word 34241 + .word 45792 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 21673 + .word 57712 + .word 23306 + .word 47181 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 30917 + .word 34592 + .word 23220 + .word 33297 + .word 16352 + .word 0 + .word 0 + .word 0 + .word 55246 + .word 63001 + .word 17535 + .word 33707 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 5457 + .word 35457 + .word 53300 + .word 62645 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 9460 + .word 62267 + .word 29700 + .word 39878 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 54791 + .word 30369 + .word 50586 + .word 36074 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 2078 + .word 44475 + .word 65531 + .word 40136 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 65081 + .word 909 + .word 65384 + .word 51785 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 42502 + .word 52825 + .word 47801 + .word 35033 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 56809 + .word 22568 + .word 24289 + .word 58056 + .word 49096 + .word 0 + .word 0 + .word 0 + .word 53182 + .word 10272 + .word 7761 + .word 53779 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 48071 + .word 2665 + .word 17237 + .word 54209 + .word 16321 + .word 0 + .word 0 + .word 0 + .word 49513 + .word 25795 + .word 55780 + .word 36409 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19372 + .word 46606 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 22905 + .word 34398 + .word 64354 + .word 59506 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8556 + .word 42135 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 15826 + .word 39989 + .word 27742 + .word 58791 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45602 + .word 63202 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 61021 + .word 62759 + .word 37190 + .word 44093 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11408 + .word 56180 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 10545 + .word 4814 + .word 18495 + .word 39194 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 49818 + .word 2604 + .word 44885 + .word 39501 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 35457 + .word 26400 + .word 3144 + .word 55829 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 1168 + .word 22940 + .word 48307 + .word 56355 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 60825 + .word 56496 + .word 32133 + .word 38661 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 41837 + .word 62246 + .word 39292 + .word 38617 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 61718 + .word 27283 + .word 11883 + .word 33288 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 51738 + .word 39830 + .word 42849 + .word 49937 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 45393 + .word 52381 + .word 54757 + .word 41874 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 45169 + .word 44591 + .word 30009 + .word 57007 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 11552 + .word 4380 + .word 40671 + .word 40665 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 28211 + .word 31057 + .word 64947 + .word 47497 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 61755 + .word 33819 + .word 30246 + .word 61557 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 57599 + .word 65445 + .word 31608 + .word 55873 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 21063 + .word 33239 + .word 23242 + .word 34595 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 24566 + .word 16137 + .word 47167 + .word 52509 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 20857 + .word 62758 + .word 44126 + .word 43729 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 26678 + .word 64201 + .word 37761 + .word 41436 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 15315 + .word 3435 + .word 56025 + .word 62814 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 19814 + .word 59948 + .word 14740 + .word 56311 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 36977 + .word 22840 + .word 9289 + .word 39778 + .word 49096 + .word 0 + .word 0 + .word 0 + .word 62085 + .word 64048 + .word 54574 + .word 65118 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 28752 + .word 34202 + .word 22833 + .word 38817 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43704 + .word 63314 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 17048 + .word 17271 + .word 64911 + .word 39894 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47414 + .word 62353 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 53119 + .word 3173 + .word 58504 + .word 64362 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19176 + .word 46765 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 36591 + .word 64385 + .word 59980 + .word 41399 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 352 + .word 36373 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 63217 + .word 55085 + .word 16723 + .word 42154 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 62758 + .word 20699 + .word 19176 + .word 46765 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 18142 + .word 49445 + .word 47413 + .word 62353 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 54343 + .word 9201 + .word 60310 + .word 40529 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 62797 + .word 60885 + .word 40240 + .word 39787 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 7512 + .word 45008 + .word 10012 + .word 39639 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 20359 + .word 48234 + .word 1564 + .word 57372 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 11764 + .word 26683 + .word 64145 + .word 49882 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 32393 + .word 50330 + .word 31801 + .word 34151 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 5247 + .word 4806 + .word 33577 + .word 41709 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 43823 + .word 34097 + .word 44124 + .word 38558 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 65526 + .word 14942 + .word 25531 + .word 60526 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 38557 + .word 7794 + .word 42920 + .word 40918 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 31363 + .word 35665 + .word 11710 + .word 52655 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 33312 + .word 35439 + .word 34687 + .word 46194 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 21144 + .word 58026 + .word 60687 + .word 57306 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 20701 + .word 12315 + .word 12846 + .word 54836 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 45362 + .word 30760 + .word 28723 + .word 42182 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 16353 + .word 46602 + .word 41748 + .word 42697 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 20735 + .word 3347 + .word 26735 + .word 62816 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 13205 + .word 16964 + .word 38504 + .word 48289 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 28004 + .word 15789 + .word 31604 + .word 37913 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 17923 + .word 56666 + .word 63953 + .word 36481 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36194 + .word 65534 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 12232 + .word 62525 + .word 48597 + .word 39676 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29918 + .word 37380 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 48638 + .word 64479 + .word 2811 + .word 58988 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44876 + .word 56070 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 64093 + .word 3811 + .word 8439 + .word 45892 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42382 + .word 52955 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 7924 + .word 29399 + .word 61525 + .word 36582 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 46606 + .word 18426 + .word 11663 + .word 35044 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 15382 + .word 23178 + .word 43683 + .word 34109 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 6438 + .word 10314 + .word 6872 + .word 49529 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 64583 + .word 11206 + .word 41955 + .word 52421 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 13495 + .word 31464 + .word 61723 + .word 36178 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 28427 + .word 18799 + .word 40522 + .word 59729 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 47510 + .word 26829 + .word 39947 + .word 33535 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 64666 + .word 11700 + .word 15653 + .word 46358 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 6475 + .word 64324 + .word 16618 + .word 52067 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 31765 + .word 32664 + .word 9436 + .word 33916 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 38078 + .word 37286 + .word 55507 + .word 62195 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 16438 + .word 19728 + .word 54394 + .word 45557 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 34868 + .word 45266 + .word 60847 + .word 41133 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 6929 + .word 9316 + .word 56077 + .word 32933 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 60039 + .word 42217 + .word 20756 + .word 52409 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 38571 + .word 57934 + .word 18985 + .word 61369 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 44492 + .word 40353 + .word 2663 + .word 35859 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 54254 + .word 26892 + .word 54523 + .word 56697 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 63636 + .word 38694 + .word 30824 + .word 51163 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 56107 + .word 41638 + .word 48577 + .word 57632 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 13301 + .word 46198 + .word 34221 + .word 52080 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 6730 + .word 19704 + .word 41453 + .word 49062 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 32541 + .word 25746 + .word 20185 + .word 50811 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40118 + .word 38623 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 63899 + .word 60569 + .word 18971 + .word 35021 + .word 49068 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35006 + .word 57940 + .word 49105 + .word 0 + .word 0 + .word 0 + .word 31190 + .word 18012 + .word 64261 + .word 44050 + .word 16305 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44288 + .word 57137 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 30741 + .word 21478 + .word 2085 + .word 43126 + .word 49077 + .word 0 + .word 0 + .word 0 + .word 43184 + .word 28511 + .word 48193 + .word 41628 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 38069 + .word 12322 + .word 59848 + .word 47812 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 14423 + .word 51984 + .word 32740 + .word 45128 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 4208 + .word 46602 + .word 27709 + .word 35782 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 36873 + .word 25112 + .word 30428 + .word 48402 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 10843 + .word 45056 + .word 322 + .word 58525 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 34740 + .word 5397 + .word 19459 + .word 63343 + .word 49128 + .word 0 + .word 0 + .word 0 + .word 43258 + .word 62838 + .word 12965 + .word 52557 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 52181 + .word 57107 + .word 24596 + .word 44275 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 8033 + .word 61170 + .word 58452 + .word 55638 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 18754 + .word 55045 + .word 40463 + .word 41822 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 31326 + .word 56708 + .word 50347 + .word 42397 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 54840 + .word 45764 + .word 11355 + .word 33431 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 56285 + .word 35328 + .word 49599 + .word 58875 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 42904 + .word 46324 + .word 60880 + .word 56231 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 42754 + .word 64912 + .word 63809 + .word 36632 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 28983 + .word 59630 + .word 18663 + .word 33292 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 56135 + .word 38086 + .word 60740 + .word 37575 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 11769 + .word 21615 + .word 56585 + .word 54481 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 64055 + .word 1299 + .word 36942 + .word 50744 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 6073 + .word 42872 + .word 14757 + .word 53598 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 7021 + .word 43375 + .word 58781 + .word 46458 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64268 + .word 65535 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 36579 + .word 26545 + .word 24435 + .word 50138 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14458 + .word 38069 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 15998 + .word 59065 + .word 36918 + .word 41001 + .word 16328 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15150 + .word 34500 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 33246 + .word 7128 + .word 23211 + .word 39186 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36820 + .word 40101 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 45920 + .word 25716 + .word 39121 + .word 51060 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 52724 + .word 56956 + .word 1384 + .word 33467 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 16783 + .word 11603 + .word 62021 + .word 42511 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 34064 + .word 49622 + .word 4121 + .word 42444 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 14084 + .word 4161 + .word 1985 + .word 33838 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 65189 + .word 58247 + .word 7682 + .word 43141 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 15983 + .word 3226 + .word 43602 + .word 43186 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 7235 + .word 9522 + .word 4836 + .word 63885 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 33104 + .word 49991 + .word 48728 + .word 55353 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 10837 + .word 43216 + .word 47090 + .word 42202 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 11340 + .word 13469 + .word 16673 + .word 42993 + .word 49128 + .word 0 + .word 0 + .word 0 + .word 19848 + .word 42271 + .word 35005 + .word 38963 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 38280 + .word 23060 + .word 26803 + .word 65491 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 3155 + .word 63825 + .word 24453 + .word 53521 + .word 49121 + .word 0 + .word 0 + .word 0 + .word 8736 + .word 25576 + .word 59728 + .word 40305 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 21836 + .word 54867 + .word 10689 + .word 53743 + .word 49120 + .word 0 + .word 0 + .word 0 + .word 35590 + .word 40641 + .word 40511 + .word 35834 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 42959 + .word 52506 + .word 48660 + .word 55474 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 62734 + .word 58818 + .word 9020 + .word 51302 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 59117 + .word 1762 + .word 19420 + .word 58690 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 54865 + .word 3647 + .word 6267 + .word 65292 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 35287 + .word 43939 + .word 50577 + .word 38705 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 78 + .word 46283 + .word 25201 + .word 34088 + .word 16338 + .word 0 + .word 0 + .word 0 + .type _ldbA,@object + .size _ldbA,3504 + .align 16 +erfRRTable: + .long 0x00000000,0x40200000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x40100000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x40000000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3fe00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3fd00000 + .long 0x00000000,0xbff80000 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xc00d0000 + .type erfRRTable,@object + .size erfRRTable,112 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_TWO5600: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 21983 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 10783 + .word 0 + .word 0 + .word 0 + .type _TWO5600,@object + .size _TWO5600,32 + .align 2 +_DenoBND: + .word 43678 + .word 54205 + .word 57926 + .word 29039 + .word 0 + .word 0 + .word 0 + .word 0 + .type _DenoBND,@object + .size _DenoBND,16 + .align 2 +_Epsilon: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16313 + .word 0 + .word 0 + .word 0 + .type _Epsilon,@object + .size _Epsilon,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/exp10_gen.S b/external/sgx_libm/intel64/exp10_gen.S new file mode 100644 index 0000000000..9f149e5cf6 --- /dev/null +++ b/external/sgx_libm/intel64/exp10_gen.S @@ -0,0 +1,427 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp10_gen.c" + .text +..TXTST0: +# -- Begin exp10 + .text + .align 16,0x90 + .globl exp10 +exp10: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_exp10.1: +..L2: + + movsd %xmm0, -40(%rsp) + movl -36(%rsp), %esi + movl %esi, %edi + movl %esi, %edx + andl $2147483647, %edi + shrl $31, %edx + cmpl $1012924416, %edi + jb ..B1.24 +..B1.2: + lea _range(%rip), %rcx + cmpl 4(%rcx,%rdx,8), %edi + jb ..B1.5 +..B1.3: + jne ..B1.16 +..B1.4: + movl -40(%rsp), %eax + cmpl (%rcx,%rdx,8), %eax + ja ..B1.16 +..B1.5: + addl $-1072693248, %esi + cmpl $4587520, %esi + ja ..B1.8 +..B1.6: + lea _TWO_52H(%rip), %rax + movsd -40(%rsp), %xmm0 + movaps %xmm0, %xmm1 + movsd (%rax), %xmm2 + addsd (%rax), %xmm1 + movsd %xmm1, -32(%rsp) + movsd -32(%rsp), %xmm1 + movslq -32(%rsp), %rcx + subsd %xmm2, %xmm1 + ucomisd %xmm0, %xmm1 + jp ..B1.7 + je ..B1.26 +..B1.7: + movsd %xmm1, -24(%rsp) + jmp ..B1.9 +..B1.8: + lea _TWO_52H(%rip), %rax + movsd -40(%rsp), %xmm0 + movsd (%rax), %xmm2 +..B1.9: + movaps %xmm0, %xmm1 + lea _TWO_32H(%rip), %rcx + mulsd .L_2il0floatpacket.0(%rip), %xmm1 + lea SC2_BIAS(%rip), %rdi + movsd .L_2il0floatpacket.2(%rip), %xmm3 + addsd %xmm2, %xmm1 + movsd %xmm1, -32(%rsp) + movsd -32(%rsp), %xmm6 + movsd (%rcx), %xmm5 + subsd %xmm2, %xmm6 + movsd .L_2il0floatpacket.1(%rip), %xmm2 + mulsd %xmm6, %xmm2 + mulsd %xmm3, %xmm6 + subsd %xmm2, %xmm0 + movaps %xmm0, %xmm4 + movl -32(%rsp), %eax + movl %eax, %r9d + movsd .L_2il0floatpacket.4(%rip), %xmm12 + movl %eax, %esi + movsd .L_2il0floatpacket.8(%rip), %xmm2 + subsd %xmm6, %xmm4 + movsd .L_2il0floatpacket.3(%rip), %xmm8 + addsd %xmm5, %xmm4 + movsd %xmm4, -32(%rsp) + movsd -32(%rsp), %xmm9 + movsd .L_2il0floatpacket.12(%rip), %xmm7 + subsd %xmm5, %xmm9 + shll $25, %r9d + subsd %xmm9, %xmm0 + sarl $25, %r9d + subsd %xmm6, %xmm0 + movaps %xmm0, %xmm11 + subl %r9d, %esi + mulsd %xmm8, %xmm0 + addsd %xmm9, %xmm11 + mulsd %xmm8, %xmm9 + movaps %xmm11, %xmm10 + addsd %xmm9, %xmm7 + mulsd %xmm11, %xmm10 + mulsd %xmm10, %xmm12 + mulsd %xmm10, %xmm2 + addsd .L_2il0floatpacket.5(%rip), %xmm12 + addsd .L_2il0floatpacket.9(%rip), %xmm2 + mulsd %xmm10, %xmm12 + mulsd %xmm10, %xmm2 + addsd .L_2il0floatpacket.6(%rip), %xmm12 + addsd .L_2il0floatpacket.10(%rip), %xmm2 + mulsd %xmm10, %xmm12 + mulsd %xmm10, %xmm2 + addsd %xmm0, %xmm12 + addsd .L_2il0floatpacket.11(%rip), %xmm2 + movsd %xmm7, -24(%rsp) + movl $0, -24(%rsp) + movsd -24(%rsp), %xmm1 + movsd .L_2il0floatpacket.7(%rip), %xmm0 + mulsd %xmm11, %xmm2 + addsd %xmm1, %xmm0 + movslq %r9d, %r9 + subsd %xmm0, %xmm9 + shlq $4, %r9 + addsd %xmm9, %xmm12 + movq __libm_exp_table_128@GOTPCREL(%rip), %r10 + addsd %xmm12, %xmm2 + shrl $7, %esi + movsd 1032(%r10,%r9), %xmm4 + movslq (%rdi,%rdx,4), %r8 + movaps %xmm4, %xmm0 + addq %rsi, %r8 + shlq $52, %r8 + movq %r8, -16(%rsp) + cmpl $-130815, %eax + movsd 1024(%r10,%r9), %xmm3 + mulsd %xmm2, %xmm0 + mulsd %xmm1, %xmm4 + jle ..B1.11 +..B1.10: + lea _SC2(%rip), %rax + addsd %xmm1, %xmm2 + mulsd %xmm2, %xmm3 + addsd %xmm3, %xmm0 + addsd %xmm4, %xmm0 + mulsd -16(%rsp), %xmm0 + mulsd (%rax,%rdx,8), %xmm0 + movsd %xmm0, -40(%rsp) + ret +..B1.11: + lea _SC2(%rip), %rax + addsd %xmm1, %xmm2 + mulsd %xmm2, %xmm3 + movaps %xmm4, %xmm1 + movsd (%rax,%rdx,8), %xmm2 + addsd %xmm3, %xmm0 + addsd %xmm0, %xmm1 + movsd %xmm1, -24(%rsp) + movl $0, -24(%rsp) + movsd -24(%rsp), %xmm3 + movsd -16(%rsp), %xmm1 + subsd %xmm3, %xmm4 + addsd %xmm0, %xmm4 + movaps %xmm3, %xmm0 + addsd %xmm4, %xmm0 + mulsd %xmm1, %xmm0 + mulsd %xmm2, %xmm0 + movsd %xmm0, -40(%rsp) + movl -36(%rsp), %eax + cmpl $1048576, %eax + jge ..B1.15 +..B1.12: + testl %eax, %eax + jle ..B1.14 +..B1.13: + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm2, %xmm3 + mulsd %xmm2, %xmm4 + addsd %xmm4, %xmm3 + movsd %xmm3, -40(%rsp) +..B1.14: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -32(%rsp) + movsd -40(%rsp), %xmm0 +..B1.15: + ret +..B1.16: + cmpl $2146435072, %edi + jae ..B1.20 +..B1.17: + testl $-2147483648, %esi + je ..B1.25 +..B1.18: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -40(%rsp) +..B1.19: + ret +..B1.20: + addl $-2146435072, %edi + orl -40(%rsp), %edi + jne ..B1.22 +..B1.21: + lea _inf_zero(%rip), %rax + movsd (%rax,%rdx,8), %xmm0 + ret +..B1.22: + movsd -40(%rsp), %xmm0 + addsd %xmm0, %xmm0 +..B1.23: + ret +..B1.24: + movsd .L_2il0floatpacket.12(%rip), %xmm0 + addsd -40(%rsp), %xmm0 + ret +..B1.25: + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -40(%rsp) + ret +..B1.26: + lea exact_values(%rip), %rax + movsd (%rax,%rcx,8), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type exp10,@function + .size exp10,.-exp10 + .data +# -- End exp10 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x0979a371,0x407a934f + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f634413 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x7fbcc47c,0x3e0427de + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x40026bb1 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xd9d41e9c,0x3fca7ed8 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x09fd8b95,0x3ff2bd76 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xc73cea69,0x40053524 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x25f8c2cc,0x3fb16e4f + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0xfd1d41fe,0x3fe1429f + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x91de2ca4,0x40004705 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0xa2b05ba9,0x3eb776aa + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +exact_values: + .long 0x00000000,0x00000000 + .long 0x00000000,0x40240000 + .long 0x00000000,0x40590000 + .long 0x00000000,0x408f4000 + .long 0x00000000,0x40c38800 + .long 0x00000000,0x40f86a00 + .long 0x00000000,0x412e8480 + .long 0x00000000,0x416312d0 + .long 0x00000000,0x4197d784 + .long 0x00000000,0x41cdcd65 + .long 0x20000000,0x4202a05f + .long 0xe8000000,0x42374876 + .long 0xa2000000,0x426d1a94 + .long 0xe5400000,0x42a2309c + .long 0x1e900000,0x42d6bcc4 + .long 0x26340000,0x430c6bf5 + .long 0x37e08000,0x4341c379 + .long 0x85d8a000,0x43763457 + .long 0x674ec800,0x43abc16d + .long 0x60913d00,0x43e158e4 + .long 0x78b58c40,0x4415af1d + .long 0xd6e2ef50,0x444b1ae4 + .long 0x064dd592,0x4480f0cf + .type exact_values,@object + .size exact_values,184 + .align 4 +_range: + .long 1352628734 + .long 1081295891 + .long 1189309266 + .long 1081358775 + .type _range,@object + .size _range,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +SC2_BIAS: + .long 511 + .long 1535 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_SC2: + .long 0 + .long 1609564160 + .long 0 + .long 535822336 + .type _SC2,@object + .size _SC2,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_inf_zero: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zero,@object + .size _inf_zero,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End + + .globl pow10 + .equ pow10, exp10 + diff --git a/external/sgx_libm/intel64/exp10f_gen.S b/external/sgx_libm/intel64/exp10f_gen.S new file mode 100644 index 0000000000..d1a435e2c7 --- /dev/null +++ b/external/sgx_libm/intel64/exp10f_gen.S @@ -0,0 +1,260 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp10f_gen.c" + .text +..TXTST0: +# -- Begin exp10f + .text + .align 16,0x90 + .globl exp10f +exp10f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_exp10f.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + movl %edx, %esi + movl %edx, %ecx + andl $2147483647, %esi + shrl $31, %ecx + cmpl $8388608, %esi + jb ..B1.17 +..B1.2: + movl %ecx, %edi + lea range(%rip), %rax + cmpl (%rax,%rdi,4), %esi + ja ..B1.8 +..B1.3: + movss .L_2il0floatpacket.0(%rip), %xmm1 + cmpl $1065353216, %edx + jl ..B1.7 +..B1.4: + movl %esi, %ecx + shrl $23, %ecx + addl $10, %ecx + shll %cl, %esi + testl %esi, %esi + jne ..B1.7 +..B1.5: + addss %xmm1, %xmm0 + movss %xmm0, -16(%rsp) + movl -16(%rsp), %eax + shll $10, %eax + sarl $10, %eax + cmpl $10, %eax + jg ..B1.7 +..B1.6: + movslq %eax, %rax + lea exact_values(%rip), %rdx + movss (%rdx,%rax,4), %xmm0 + ret +..B1.7: + pxor %xmm3, %xmm3 + movq $0x3ff0000000000000, %rcx + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm0 + mulsd .L_2il0floatpacket.1(%rip), %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movq __libm_expf_table_64@GOTPCREL(%rip), %rsi + addsd .L_2il0floatpacket.2(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm2 + movsd .L_2il0floatpacket.4(%rip), %xmm0 + subss %xmm1, %xmm2 + cvtss2sd %xmm2, %xmm2 + mulsd .L_2il0floatpacket.3(%rip), %xmm2 + movl -16(%rsp), %edx + addsd %xmm2, %xmm3 + movaps %xmm3, %xmm1 + andl $4194303, %edx + mulsd %xmm3, %xmm1 + movl %edx, %eax + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm3, %xmm4 + shll $26, %eax + addsd %xmm4, %xmm0 + sarl $26, %eax + movslq %eax, %rax + subl %eax, %edx + shrl $6, %edx + movsd 256(%rsi,%rax,8), %xmm5 + mulsd %xmm5, %xmm0 + shlq $52, %rdx + addsd %xmm5, %xmm0 + addq %rcx, %rdx + movq %rdx, -24(%rsp) + mulsd -24(%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.8: + cmpl $2139095040, %esi + jae ..B1.13 +..B1.9: + testl %ecx, %ecx + je ..B1.11 +..B1.10: + movss .L_2il0floatpacket.8(%rip), %xmm0 + mulss %xmm0, %xmm0 + ret +..B1.11: + movss .L_2il0floatpacket.9(%rip), %xmm0 + mulss %xmm0, %xmm0 +..B1.12: + ret +..B1.13: + jne ..B1.15 +..B1.14: + lea _inf_zero(%rip), %rax + movss (%rax,%rdi,4), %xmm0 + ret +..B1.15: + movss -8(%rsp), %xmm0 +..B1.16: + ret +..B1.17: + movss .L_2il0floatpacket.10(%rip), %xmm0 + addss -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type exp10f,@function + .size exp10f,.-exp10f + .data +# -- End exp10f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.1: + .long 0x0979a371,0x406a934f + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x41680000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x509f79ff,0xbf734413 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xe2724acf,0x3ff2d784 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0xcd26a2f3,0x40053524 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xd3f4b8ec,0x400046f7 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0xbbb47127,0x40026bb1 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x4b400000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.8: + .long 0x0d800000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .align 4 +.L_2il0floatpacket.9: + .long 0x71800000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,4 + .align 4 +.L_2il0floatpacket.10: + .long 0x3f800000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .align 4 +range: + .long 1109008539 + .long 1110823542 + .type range,@object + .size range,8 + .align 4 +exact_values: + .long 0x00000000 + .long 0x41200000 + .long 0x42c80000 + .long 0x447a0000 + .long 0x461c4000 + .long 0x47c35000 + .long 0x49742400 + .long 0x4b189680 + .long 0x4cbebc20 + .long 0x4e6e6b28 + .long 0x501502f9 + .type exact_values,@object + .size exact_values,44 + .align 4 +_inf_zero: + .long 2139095040 + .long 0 + .type _inf_zero,@object + .size _inf_zero,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End + + .globl pow10f + .equ pow10f, exp10f + diff --git a/external/sgx_libm/intel64/exp10l.S b/external/sgx_libm/intel64/exp10l.S new file mode 100644 index 0000000000..5b3c4075ef --- /dev/null +++ b/external/sgx_libm/intel64/exp10l.S @@ -0,0 +1,1282 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp10l.c" + .text +..TXTST0: +# -- Begin exp10l + .text + .align 16,0x90 + .globl exp10l +exp10l: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_exp10l.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %dil, %dil +..B1.2: + fnstcw 86(%rsp) +..B1.3: + movzwl 104(%rsp), %esi + movl %esi, %eax + movzbl 105(%rsp), %ecx + andl $32767, %eax + shrl $7, %ecx + shll $15, %ecx + orl %eax, %ecx + shll $16, %ecx + movzwl 102(%rsp), %edx + orl %edx, %ecx + addl $-1073709056, %ecx + cmpl $284672, %ecx + ja ..B1.6 +..B1.4: + fldt 96(%rsp) + lea _TWO_23H(%rip), %rax + fld %st(0) + fldl (%rax) + fadd %st, %st(1) + fxch %st(1) + fstps 80(%rsp) + movss 80(%rsp), %xmm0 + movss %xmm0, 16(%rsp) + flds 16(%rsp) + fsubp %st, %st(1) + fucomip %st(1), %st + fstp %st(0) + jp ..B1.5 + je ..B1.79 +..B1.5: + movl %esi, %eax + andl $32767, %eax +..B1.6: + cmpl $16388, %eax + jge ..B1.45 +..B1.7: + movzwl 86(%rsp), %edx + cmpl $16375, %eax + jge ..B1.38 +..B1.8: + cmpl $16368, %eax + jge ..B1.31 +..B1.9: + cmpl $16357, %eax + jge ..B1.24 +..B1.10: + cmpl $16316, %eax + jge ..B1.17 +..B1.11: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.73 +..B1.12: + orl $-64768, %edx + movw %dx, 84(%rsp) +..B1.13: + fldcw 84(%rsp) +..B1.14: + fldt .L_2il0floatpacket.3(%rip) + fldt 96(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.15: + fldcw 86(%rsp) +..B1.16: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.17: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.21 +..B1.18: + orl $-64768, %edx + movw %dx, 84(%rsp) +..B1.19: + fldcw 84(%rsp) +..B1.20: + movb $1, %dil +..B1.21: + fldt 96(%rsp) + lea 16+_Q2(%rip), %rax + fldt .L_2il0floatpacket.3(%rip) + lea _Q2(%rip), %rdx + testb %dil, %dil + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.23 +..B1.22: + fldcw 86(%rsp) +..B1.23: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.24: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.28 +..B1.25: + orl $-64768, %edx + movw %dx, 84(%rsp) +..B1.26: + fldcw 84(%rsp) +..B1.27: + movb $1, %dil +..B1.28: + fldt 96(%rsp) + lea 48+_Q1(%rip), %rax + fld %st(0) + lea 32+_Q1(%rip), %rdx + fmul %st(1), %st + lea 16+_Q1(%rip), %rcx + fldt (%rax) + lea _Q1(%rip), %rsi + fmul %st(1), %st + testb %dil, %dil + fldt (%rdx) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.3(%rip) + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.30 +..B1.29: + fldcw 86(%rsp) +..B1.30: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.31: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.35 +..B1.32: + orl $-64768, %edx + movw %dx, 84(%rsp) +..B1.33: + fldcw 84(%rsp) +..B1.34: + movb $1, %dil +..B1.35: + fldt 96(%rsp) + lea 112+_Q0(%rip), %rdx + fld %st(0) + lea 96+_Q0(%rip), %rcx + fmul %st(1), %st + lea 80+_Q0(%rip), %rsi + lea 64+_Q0(%rip), %r8 + lea 48+_Q0(%rip), %r9 + lea 32+_Q0(%rip), %r10 + lea _TWO_48H(%rip), %rax + lea 16+_Q0(%rip), %r11 + fld %st(1) + fld %st(2) + testb %dil, %dil + fldt (%rdx) + lea 128+_Q0(%rip), %rdx + fmul %st(3), %st + fldl (%rax) + lea _Q0(%rip), %rax + fadd %st, %st(3) + fsubr %st(3), %st + fsubr %st, %st(2) + fldt (%rcx) + fmul %st(5), %st + fldt (%rsi) + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + fldt (%r8) + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + fldt (%r9) + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + fldt (%r10) + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + fldt (%r11) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(5) + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fldt (%rdx) + fmul %st, %st(4) + fmulp %st, %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.3(%rip) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + je ..B1.85 +..B1.36: + fstpt 48(%rsp) +..B1.82: + fldcw 86(%rsp) + jmp ..B1.37 +..B1.85: + fstp %st(0) +..B1.37: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.38: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.42 +..B1.39: + orl $-64768, %edx + movw %dx, 84(%rsp) +..B1.40: + fldcw 84(%rsp) +..B1.41: + movb $1, %dil +..B1.42: + fldt 96(%rsp) + lea _TWO_63H(%rip), %rdx + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_48H(%rip), %rcx + fmul %st(1), %st + lea 80+_P(%rip), %r8 + fldl (%rdx) + lea 48+_P(%rip), %r10 + lea 64+_P(%rip), %r9 + lea 32+_P(%rip), %r11 + lea 16+_P(%rip), %rdx + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(1), %st + movl 48(%rsp), %esi + fsubrp %st, %st(2) + fld %st(1) + fldt .L_2il0floatpacket.2(%rip) + fmulp %st, %st(2) + movsbq %sil, %rax + fsub %st(1), %st + fldl (%rcx) + lea _P(%rip), %rcx + subl %eax, %esi + fadd %st, %st(1) + shrl $8, %esi + fsubr %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + shll $23, %esi + fxch %st(3) + fsubrp %st, %st(4) + addl $1065353216, %esi + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fldt (%r8) + fmul %st(1), %st + fldt (%r9) + fmul %st(2), %st + fldt (%r10) + movl %esi, 32(%rsp) + lea 96+_P(%rip), %rsi + shlq $4, %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + testb %dil, %dil + fldt (%r11) + movq __libm_expl_table_256@GOTPCREL(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt (%rsi) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(2) + fldl 2056(%r8,%rax) + fldl 2048(%r8,%rax) + fld %st(0) + fmul %st(5), %st + fxch %st(4) + fadd %st, %st(5) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fmul %st(3), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmuls 32(%rsp) + fstpt 16(%rsp) + je ..B1.86 +..B1.43: + fstpt 48(%rsp) +..B1.83: + fldcw 86(%rsp) + jmp ..B1.44 +..B1.86: + fstp %st(0) +..B1.44: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.45: + movb 105(%rsp), %dl + lea _ranges(%rip), %r8 + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + movq %rsi, %rcx + shlq $4, %rcx + movzwl 8(%rcx,%r8), %edx + andl $32767, %edx + cmpl %edx, %eax + jl ..B1.50 +..B1.46: + jne ..B1.62 +..B1.47: + movl 100(%rsp), %edx + cmpl 4(%rcx,%r8), %edx + jb ..B1.50 +..B1.48: + jne ..B1.62 +..B1.49: + movl 96(%rsp), %edx + cmpl (%rcx,%r8), %edx + jae ..B1.62 +..B1.50: + movzwl 86(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.54 +..B1.51: + orl $-64768, %edx + movw %dx, 84(%rsp) +..B1.52: + fldcw 84(%rsp) +..B1.53: + movb $1, %dil +..B1.54: + fldt .L_2il0floatpacket.3(%rip) + lea _TWO_63H(%rip), %r8 + fstpt 64(%rsp) + lea _TWO_48H(%rip), %r9 + fldt 96(%rsp) + lea SC2_BIAS(%rip), %r10 + fldt .L_2il0floatpacket.0(%rip) + fmul %st(1), %st + fldl (%r8) + movzwl 8+.L_2il0floatpacket.3(%rip), %r8d + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + andl $-32768, %r8d + movl 48(%rsp), %edx + fsubp %st, %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(1), %st + movsbq %dl, %rax + fsubr %st(2), %st + fld %st(0) + movl %eax, %r11d + fldt .L_2il0floatpacket.2(%rip) + negl %r11d + fmulp %st, %st(3) + addl %edx, %r11d + shrl $8, %r11d + addl $4196735, %edx + addl (%r10,%rsi,4), %r11d + lea 80+_P(%rip), %rsi + andl $32767, %r11d + lea 16+_P(%rip), %r10 + orl %r11d, %r8d + lea _P(%rip), %r11 + movw %r8w, 72(%rsp) + lea 48+_P(%rip), %r8 + shlq $4, %rax + fsub %st(2), %st + fldl (%r9) + lea 32+_P(%rip), %r9 + cmpl $3070, %edx + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + fsubrp %st, %st(2) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt (%rsi) + lea 64+_P(%rip), %rsi + fmul %st(1), %st + fldt (%rsi) + lea 96+_P(%rip), %rsi + fmul %st(2), %st + fldt (%r8) + movq __libm_expl_table_256@GOTPCREL(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fldt (%r11) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt (%rsi) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(2) + fldl 2048(%r8,%rax) + fld %st(0) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(1) + fmul %st, %st(3) + faddp %st, %st(3) + fmull 2056(%r8,%rax) + faddp %st, %st(1) + faddl 2056(%r8,%rax) + ja ..B1.57 +..B1.55: + lea _exp10but(%rip), %rax + fldt (%rax) + fcomip %st(3), %st + jbe ..B1.57 +..B1.56: + fstp %st(2) + fld %st(0) + lea _TWO_12H(%rip), %rax + lea _SC2(%rip), %rdx + fadd %st(2), %st + fldl (%rax) + fmul %st(1), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt (%rcx,%rdx) + fldt 64(%rsp) + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B1.58 +..B1.57: + fstp %st(2) + fldt 64(%rsp) + fxch %st(2) + faddp %st, %st(1) + lea _SC2(%rip), %rax + fmulp %st, %st(1) + fldt (%rcx,%rax) + fmulp %st, %st(1) + fstpt 32(%rsp) +..B1.58: + fldt 32(%rsp) + lea _minnorm(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + fstp %st(0) + ja ..B1.74 +..B1.59: + testb %dil, %dil + je ..B1.61 +..B1.60: + fldt 16(%rsp) + fstpt 48(%rsp) +..B1.84: + fldcw 86(%rsp) +..B1.61: + fldt 32(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.62: + movzwl 86(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.66 +..B1.63: + orl $-64768, %ecx + movw %cx, 84(%rsp) +..B1.64: + fldcw 84(%rsp) +..B1.65: + movzwl 104(%rsp), %eax + movb $1, %dil + andl $32767, %eax +..B1.66: + cmpl $32767, %eax + je ..B1.75 +..B1.67: + testq %rsi, %rsi + je ..B1.69 +..B1.68: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) + jmp ..B1.70 +..B1.69: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) +..B1.70: + testb %dil, %dil + je ..B1.72 +..B1.71: + fldcw 86(%rsp) +..B1.72: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.73: + fldt .L_2il0floatpacket.3(%rip) + fldt 96(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.16 +..B1.74: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.59 +..B1.75: + cmpl $-2147483648, 100(%rsp) + jne ..B1.78 +..B1.76: + cmpl $0, 96(%rsp) + jne ..B1.78 +..B1.77: + lea _inf_zeros(%rip), %rax + fldl (%rax,%rsi,8) + fstpt 16(%rsp) + jmp ..B1.70 +..B1.78: + fldt 96(%rsp) + fstpt 16(%rsp) + jmp ..B1.70 +..B1.79: + movl 80(%rsp), %eax + lea _exact_values(%rip), %rdx + andl $4194303, %eax + shlq $4, %rax + fldt -16(%rdx,%rax) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type exp10l,@function + .size exp10l,.-exp10l + .data +# -- End exp10l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x88,0x1b,0xcd,0x4b,0x78,0x9a,0xd4,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x85,0x9a,0x20,0x9a,0xf5,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0xc8,0xd4,0x0e,0xee,0x0c,0x01,0x86,0xd0,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 4 +_TWO_23H: + .long 0 + .long 1097334784 + .type _TWO_23H,@object + .size _TWO_23H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +SC2_BIAS: + .long 8191 + .long 24575 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_inf_zeros: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zeros,@object + .size _inf_zeros,16 + .align 2 +_Q2: + .word 45097 + .word 43688 + .word 36317 + .word 37725 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 18666 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 44055 + .word 43688 + .word 36317 + .word 37725 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 17466 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 8942 + .word 31610 + .word 11407 + .word 33336 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 11423 + .word 35775 + .word 45136 + .word 38379 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q0: + .word 11092 + .word 42962 + .word 43694 + .word 58436 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 17467 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 8985 + .word 61797 + .word 11406 + .word 33336 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 8830 + .word 60614 + .word 45135 + .word 38379 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 62265 + .word 59600 + .word 65512 + .word 35348 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 36045 + .word 15298 + .word 47170 + .word 54262 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 33342 + .word 6003 + .word 33899 + .word 35698 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 20958 + .word 58269 + .word 28628 + .word 41099 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37726 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _Q0,@object + .size _Q0,144 + .align 2 +_P: + .word 405 + .word 44055 + .word 43688 + .word 36317 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 17467 + .word 59219 + .word 9785 + .word 43433 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 7929 + .word 61789 + .word 11406 + .word 33336 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 36964 + .word 60605 + .word 45135 + .word 38379 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 55739 + .word 36897 + .word 684 + .word 35349 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 13923 + .word 51509 + .word 48217 + .word 54262 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37725 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,112 + .align 2 +_ranges: + .word 63385 + .word 64463 + .word 39556 + .word 39456 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 55376 + .word 5815 + .word 21149 + .word 39608 + .word 16395 + .word 0 + .word 0 + .word 0 + .type _ranges,@object + .size _ranges,32 + .align 2 +_exp10but: + .word 6424 + .word 10152 + .word 51584 + .word 39451 + .word 49163 + .word 0 + .word 0 + .word 0 + .type _exp10but,@object + .size _exp10but,16 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .type _SC2,@object + .size _SC2,32 + .align 2 +_minnorm: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _minnorm,@object + .size _minnorm,16 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_exact_values: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40000 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50000 + .word 16399 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62500 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39062 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8192 + .word 48828 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10240 + .word 61035 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63744 + .word 38146 + .word 16416 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46912 + .word 47683 + .word 16419 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42256 + .word 59604 + .word 16422 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59178 + .word 37252 + .word 16426 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8436 + .word 46566 + .word 16429 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 43313 + .word 58207 + .word 16432 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1024 + .word 51647 + .word 36379 + .word 16436 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50432 + .word 48174 + .word 45474 + .word 16439 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30272 + .word 27450 + .word 56843 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35304 + .word 8964 + .word 35527 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44130 + .word 60357 + .word 44408 + .word 16449 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6010 + .word 9911 + .word 55511 + .word 16452 + .word 0 + .word 0 + .word 0 + .word 36864 + .word 28332 + .word 30770 + .word 34694 + .word 16456 + .word 0 + .word 0 + .word 0 + .word 46080 + .word 2647 + .word 5695 + .word 43368 + .word 16459 + .word 0 + .word 0 + .word 0 + .word 41216 + .word 52461 + .word 7118 + .word 54210 + .word 16462 + .word 0 + .word 0 + .word 0 + .word 33952 + .word 16404 + .word 20833 + .word 33881 + .word 16466 + .word 0 + .word 0 + .word 0 + .word 42440 + .word 36889 + .word 42425 + .word 42351 + .word 16469 + .word 0 + .word 0 + .word 0 + .word 3898 + .word 62496 + .word 36647 + .word 52939 + .word 16472 + .word 0 + .word 0 + .word 0 + .type _exact_values,@object + .size _exact_values,432 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End + + .globl pow10l + .equ pow10l, exp10l + diff --git a/external/sgx_libm/intel64/exp2_gen.S b/external/sgx_libm/intel64/exp2_gen.S new file mode 100644 index 0000000000..17707759ca --- /dev/null +++ b/external/sgx_libm/intel64/exp2_gen.S @@ -0,0 +1,517 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp2_gen.c" + .text +..TXTST0: +# -- Begin exp2 + .text + .align 16,0x90 + .globl exp2 +exp2: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_exp2.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + xorb %sil, %sil + movsd %xmm0, 40(%rsp) +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movl 44(%rsp), %edx + movl %edx, %eax + andl $2147483647, %eax + lea -1072693248(%rax), %ecx + cmpl $10483712, %ecx + ja ..B1.9 +..B1.4: + movl %eax, %ecx + movl $1048575, %edi + shrl $20, %ecx + incl %ecx + shrl %cl, %edi + andl %eax, %edi + orl 40(%rsp), %edi + jne ..B1.9 +..B1.5: + lea _TWO_52H(%rip), %rcx + movsd 40(%rsp), %xmm0 + addsd (%rcx), %xmm0 + movsd %xmm0, 16(%rsp) + movl 16(%rsp), %ecx + cmpl $-1074, %ecx + jl ..B1.9 +..B1.6: + lea 1023(%rcx), %eax + testl %eax, %eax + jle ..B1.37 +..B1.7: + movslq %eax, %rax + shlq $52, %rax + movq %rax, 8(%rsp) +..B1.8: + movsd 8(%rsp), %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.9: + cmpl $1079984128, %eax + jae ..B1.14 +..B1.10: + cmpl $1012924416, %eax + jae ..B1.12 +..B1.11: + movsd .L_2il0floatpacket.11(%rip), %xmm0 + addsd 40(%rsp), %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + movsd 40(%rsp), %xmm0 + pxor %xmm13, %xmm13 + lea _TWO_52H(%rip), %rax + lea _two_32p1(%rip), %rdx + movsd .L_2il0floatpacket.4(%rip), %xmm9 + lea _two_32(%rip), %rcx + movsd .L_2il0floatpacket.7(%rip), %xmm10 + movsd .L_2il0floatpacket.2(%rip), %xmm4 + movsd (%rax), %xmm1 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd (%rdx), %xmm2 + addsd %xmm1, %xmm0 + movsd %xmm0, 16(%rsp) + movsd 16(%rsp), %xmm8 + movl 16(%rsp), %esi + movl %esi, %edi + movsd .L_2il0floatpacket.3(%rip), %xmm3 + subsd %xmm1, %xmm8 + mulsd .L_2il0floatpacket.1(%rip), %xmm8 + shll $25, %edi + addsd 40(%rsp), %xmm8 + movaps %xmm8, %xmm7 + movaps %xmm8, %xmm5 + mulsd %xmm8, %xmm7 + mulsd %xmm7, %xmm9 + mulsd %xmm7, %xmm10 + addsd .L_2il0floatpacket.5(%rip), %xmm9 + addsd .L_2il0floatpacket.8(%rip), %xmm10 + mulsd %xmm7, %xmm9 + mulsd %xmm7, %xmm10 + addsd .L_2il0floatpacket.6(%rip), %xmm9 + addsd .L_2il0floatpacket.9(%rip), %xmm10 + mulsd %xmm7, %xmm9 + mulsd %xmm7, %xmm10 + movsd %xmm8, (%rsp) + movl $0, (%rsp) + movsd (%rsp), %xmm6 + sarl $25, %edi + subsd %xmm6, %xmm5 + mulsd %xmm4, %xmm6 + addsd .L_2il0floatpacket.10(%rip), %xmm10 + mulsd %xmm4, %xmm5 + addsd %xmm6, %xmm2 + mulsd %xmm8, %xmm10 + addsd %xmm5, %xmm9 + movsd %xmm2, 16(%rsp) + subl %edi, %esi + movsd 16(%rsp), %xmm11 + movslq %edi, %rdi + subsd (%rcx), %xmm11 + shlq $4, %rdi + addsd %xmm11, %xmm3 + movq __libm_exp_table_128@GOTPCREL(%rip), %r8 + subsd %xmm3, %xmm6 + movsd 1032(%r8,%rdi), %xmm12 + addsd %xmm6, %xmm9 + movaps %xmm12, %xmm0 + addsd %xmm9, %xmm10 + mulsd %xmm11, %xmm12 + mulsd %xmm10, %xmm0 + addsd %xmm11, %xmm10 + mulsd 1024(%r8,%rdi), %xmm10 + shrl $7, %esi + addsd %xmm10, %xmm0 + shll $23, %esi + addsd %xmm12, %xmm0 + addl $1065353216, %esi + movl %esi, 24(%rsp) + cvtss2sd 24(%rsp), %xmm13 + mulsd %xmm13, %xmm0 + movsd %xmm11, (%rsp) + movsd %xmm0, 8(%rsp) +..B1.13: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.14: + lea _range(%rip), %r8 + movl %edx, %ecx + shrl $31, %ecx + cmpl 4(%r8,%rcx,8), %eax + jb ..B1.17 +..B1.15: + jne ..B1.28 +..B1.16: + movl 40(%rsp), %edi + cmpl (%r8,%rcx,8), %edi + ja ..B1.28 +..B1.17: + movsd 40(%rsp), %xmm0 + lea _TWO_52H(%rip), %rdi + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + lea _two_32p1(%rip), %r9 + movsd (%rdi), %xmm1 + lea _two_32(%rip), %r10 + movsd .L_2il0floatpacket.4(%rip), %xmm9 + lea SC2_BIAS(%rip), %r11 + movsd .L_2il0floatpacket.2(%rip), %xmm4 + addsd %xmm1, %xmm0 + movsd %xmm0, 16(%rsp) + movsd 16(%rsp), %xmm8 + movsd (%r9), %xmm2 + subsd %xmm1, %xmm8 + mulsd .L_2il0floatpacket.1(%rip), %xmm8 + movsd .L_2il0floatpacket.7(%rip), %xmm1 + movl 16(%rsp), %edx + movl %edx, %eax + movsd .L_2il0floatpacket.3(%rip), %xmm3 + movl %edx, %r8d + shll $25, %eax + addsd 40(%rsp), %xmm8 + movaps %xmm8, %xmm7 + movaps %xmm8, %xmm5 + mulsd %xmm8, %xmm7 + mulsd %xmm7, %xmm9 + mulsd %xmm7, %xmm1 + addsd .L_2il0floatpacket.5(%rip), %xmm9 + addsd .L_2il0floatpacket.8(%rip), %xmm1 + mulsd %xmm7, %xmm9 + mulsd %xmm7, %xmm1 + addsd .L_2il0floatpacket.6(%rip), %xmm9 + addsd .L_2il0floatpacket.9(%rip), %xmm1 + mulsd %xmm7, %xmm9 + mulsd %xmm7, %xmm1 + movsd %xmm8, (%rsp) + movl $0, (%rsp) + movsd (%rsp), %xmm6 + sarl $25, %eax + subsd %xmm6, %xmm5 + mulsd %xmm4, %xmm6 + addsd .L_2il0floatpacket.10(%rip), %xmm1 + mulsd %xmm4, %xmm5 + addsd %xmm6, %xmm2 + mulsd %xmm8, %xmm1 + addsd %xmm5, %xmm9 + movsd %xmm2, 16(%rsp) + subl %eax, %r8d + movsd 16(%rsp), %xmm11 + movsd %xmm6, (%rsp) + movslq %eax, %rax + subsd (%r10), %xmm11 + shlq $4, %rax + addsd %xmm11, %xmm3 + movq __libm_exp_table_128@GOTPCREL(%rip), %r9 + subsd %xmm3, %xmm6 + movsd 1032(%r9,%rax), %xmm2 + addsd %xmm6, %xmm9 + shrl $7, %r8d + addsd %xmm9, %xmm1 + movaps %xmm1, %xmm10 + mulsd %xmm2, %xmm1 + addsd %xmm11, %xmm10 + mulsd %xmm11, %xmm2 + mulsd 1024(%r9,%rax), %xmm10 + movslq (%r11,%rcx,4), %rdi + addsd %xmm10, %xmm1 + addq %r8, %rdi + movaps %xmm1, %xmm0 + shlq $52, %rdi + addsd %xmm2, %xmm0 + movq %rdi, 24(%rsp) + cmpl $-130815, %edx + jg ..B1.26 +..B1.18: + movsd %xmm0, (%rsp) + andl $-4096, (%rsp) + movsd (%rsp), %xmm0 + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + subsd %xmm0, %xmm2 + cmpl $768, %eax + addsd %xmm1, %xmm2 + je ..B1.22 +..B1.19: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.20: + fldcw 32(%rsp) +..B1.21: + movsd (%rsp), %xmm0 + movb $1, %sil +..B1.22: + fldl 24(%rsp) + lea _SC2(%rip), %rax + movsd %xmm0, (%rsp) + testb %sil, %sil + fldl (%rsp) + movsd %xmm2, (%rsp) + fldl (%rsp) + faddp %st, %st(1) + fmulp %st, %st(1) + fmull (%rax,%rcx,8) + fstpl 8(%rsp) + je ..B1.24 +..B1.23: + fldcw 34(%rsp) +..B1.24: + cmpl $1048576, 12(%rsp) + jl ..B1.8 +..B1.25: + movsd 8(%rsp), %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.26: + movsd 24(%rsp), %xmm1 + lea _SC2(%rip), %rax + mulsd %xmm1, %xmm0 + mulsd (%rax,%rcx,8), %xmm0 + movsd %xmm0, 8(%rsp) +..B1.27: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.28: + cmpl $2146435072, %eax + jae ..B1.33 +..B1.29: + testl $-2147483648, %edx + je ..B1.31 +..B1.30: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, 8(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.31: + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, 8(%rsp) +..B1.32: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.33: + addl $-2146435072, %eax + orl 40(%rsp), %eax + jne ..B1.35 +..B1.34: + lea _inf_zero(%rip), %rax + movsd (%rax,%rcx,8), %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.35: + movsd 40(%rsp), %xmm0 + addsd %xmm0, %xmm0 +..B1.36: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.37: + addl $1074, %ecx + movl $1, %eax + shlq %cl, %rax + movq %rax, 8(%rsp) + jmp ..B1.8 + .align 16,0x90 + .cfi_endproc + .type exp2,@function + .size exp2,.-exp2 + .data +# -- End exp2 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40600000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0xbf800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3fe62e42 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xac59a345,0x3f24308c + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x6fba31d1,0x3f83b2ab + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xff82c58f,0x3fcebfbd + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x00cb0678,0x3ef0097a + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0xe87ed439,0x3f55d87f + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0xd704a0c3,0x3fac6b08 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x3de6af28,0x3e9fdf47 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_two_32p1: + .long 1048576 + .long 1106247680 + .type _two_32p1,@object + .size _two_32p1,8 + .align 4 +_two_32: + .long 0 + .long 1106247680 + .type _two_32,@object + .size _two_32,8 + .align 4 +_range: + .long 4294967295 + .long 1083179007 + .long 4294967295 + .long 1083232255 + .type _range,@object + .size _range,16 + .align 4 +SC2_BIAS: + .long 511 + .long 1535 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_SC2: + .long 0 + .long 1609564160 + .long 0 + .long 535822336 + .type _SC2,@object + .size _SC2,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_inf_zero: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zero,@object + .size _inf_zero,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/exp2f_gen.S b/external/sgx_libm/intel64/exp2f_gen.S new file mode 100644 index 0000000000..a33b058d9f --- /dev/null +++ b/external/sgx_libm/intel64/exp2f_gen.S @@ -0,0 +1,306 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp2f_gen.c" + .text +..TXTST0: +# -- Begin exp2f + .text + .align 16,0x90 + .globl exp2f +exp2f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_exp2f.1: +..L2: + + movaps %xmm0, %xmm1 + movd %xmm1, %esi + movss %xmm1, -8(%rsp) + andl $2147483647, %esi + lea -1065353216(%rsi), %eax + cmpl $58589184, %eax + ja ..B1.7 +..B1.2: + movl %esi, %ecx + movl %esi, %eax + shrl $23, %ecx + addl $10, %ecx + shll %cl, %eax + testl %eax, %eax + jne ..B1.7 +..B1.3: + movss .L_2il0floatpacket.0(%rip), %xmm0 + addss %xmm0, %xmm1 + movss %xmm1, -12(%rsp) + movl -12(%rsp), %ecx + shll $10, %ecx + sarl $10, %ecx + cmpl $-149, %ecx + jl ..B1.7 +..B1.4: + movl %ecx, %eax + addl $127, %eax + jle ..B1.23 +..B1.5: + shll $23, %eax + movl %eax, -16(%rsp) +..B1.6: + movss -16(%rsp), %xmm0 + ret +..B1.7: + cmpl $1123680256, %esi + jae ..B1.12 +..B1.8: + cmpl $830472192, %esi + jae ..B1.10 +..B1.9: + movss .L_2il0floatpacket.10(%rip), %xmm0 + addss -8(%rsp), %xmm0 + movss %xmm0, -12(%rsp) + ret +..B1.10: + pxor %xmm3, %xmm3 + pxor %xmm6, %xmm6 + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm0 + mulsd .L_2il0floatpacket.1(%rip), %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movq __libm_expf_table_64@GOTPCREL(%rip), %rcx + addsd .L_2il0floatpacket.2(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -12(%rsp) + movss -12(%rsp), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm0 + movl -12(%rsp), %edx + movl %edx, %eax + shll $26, %eax + subss .L_2il0floatpacket.0(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + sarl $26, %eax + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm3, %xmm4 + movslq %eax, %rax + addsd %xmm4, %xmm0 + movsd 256(%rcx,%rax,8), %xmm5 + subl %eax, %edx + mulsd %xmm5, %xmm0 + shrl $6, %edx + addsd %xmm5, %xmm0 + shll $23, %edx + addl $1065353216, %edx + movl %edx, -24(%rsp) + cvtss2sd -24(%rsp), %xmm6 + mulsd %xmm6, %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) +..B1.11: + ret +..B1.12: + lea range(%rip), %rdx + movl -8(%rsp), %eax + shrl $31, %eax + cmpl (%rdx,%rax,4), %esi + ja ..B1.14 +..B1.13: + pxor %xmm3, %xmm3 + movq $0x3ff0000000000000, %rcx + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm0 + mulsd .L_2il0floatpacket.1(%rip), %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movq __libm_expf_table_64@GOTPCREL(%rip), %rsi + addsd .L_2il0floatpacket.2(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -12(%rsp) + movss -12(%rsp), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm0 + movl -12(%rsp), %edx + andl $4194303, %edx + subss .L_2il0floatpacket.0(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + movl %edx, %eax + shll $26, %eax + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm3, %xmm4 + sarl $26, %eax + addsd %xmm4, %xmm0 + movslq %eax, %rax + subl %eax, %edx + shrl $6, %edx + movsd 256(%rsi,%rax,8), %xmm5 + mulsd %xmm5, %xmm0 + shlq $52, %rdx + addsd %xmm5, %xmm0 + addq %rcx, %rdx + movq %rdx, -24(%rsp) + mulsd -24(%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + ret +..B1.14: + cmpl $2139095040, %esi + jae ..B1.19 +..B1.15: + testq %rax, %rax + je ..B1.17 +..B1.16: + movss .L_2il0floatpacket.8(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + ret +..B1.17: + movss .L_2il0floatpacket.9(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) +..B1.18: + ret +..B1.19: + jne ..B1.21 +..B1.20: + lea _inf_zero(%rip), %rdx + movss (%rdx,%rax,4), %xmm0 + ret +..B1.21: + movss -8(%rsp), %xmm0 + addss %xmm0, %xmm0 +..B1.22: + ret +..B1.23: + addl $149, %ecx + movl $1, %eax + shll %cl, %eax + movl %eax, -16(%rsp) + jmp ..B1.6 + .align 16,0x90 + .cfi_endproc + .type exp2f,@function + .size exp2f,.-exp2f + .data +# -- End exp2f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x40500000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x41680000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbf900000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x3e46f43a,0x3f83ce0f + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x081585e7,0x3fcebfbe + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xd93cf576,0x3fac6af0 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0xfef9277b,0x3fe62e42 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x4b400000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.8: + .long 0x0d800000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .align 4 +.L_2il0floatpacket.9: + .long 0x71800000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,4 + .align 4 +.L_2il0floatpacket.10: + .long 0x3f800000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,4 + .align 4 +range: + .long 1124073471 + .long 1126039552 + .type range,@object + .size range,8 + .align 4 +_inf_zero: + .long 2139095040 + .long 0 + .type _inf_zero,@object + .size _inf_zero,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/exp2l.S b/external/sgx_libm/intel64/exp2l.S new file mode 100644 index 0000000000..4bd828bf77 --- /dev/null +++ b/external/sgx_libm/intel64/exp2l.S @@ -0,0 +1,683 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp2l.c" + .text +..TXTST0: +# -- Begin exp2l + .text + .align 16,0x90 + .globl exp2l +exp2l: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_exp2l.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %r8b, %r8b +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movb 105(%rsp), %cl + lea _ranges(%rip), %rdx + andb $-128, %cl + shrb $7, %cl + movzbl %cl, %edi + movq %rdi, %rsi + shlq $4, %rsi + movzwl 104(%rsp), %ecx + andl $32767, %ecx + movzwl 8(%rsi,%rdx), %eax + andl $32767, %eax + cmpl %eax, %ecx + jl ..B1.8 +..B1.4: + jne ..B1.39 +..B1.5: + movl 100(%rsp), %eax + cmpl 4(%rsi,%rdx), %eax + jb ..B1.8 +..B1.6: + jne ..B1.39 +..B1.7: + movl 96(%rsp), %eax + cmpl (%rsi,%rdx), %eax + jae ..B1.39 +..B1.8: + movzwl 82(%rsp), %edx + cmpl $16369, %ecx + jge ..B1.19 +..B1.9: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.13 +..B1.10: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.11: + fldcw 80(%rsp) +..B1.12: + movzwl 104(%rsp), %ecx + movb $1, %r8b + andl $32767, %ecx +..B1.13: + fldt 96(%rsp) + cmpl $16316, %ecx + fstpt 16(%rsp) + jge ..B1.15 +..B1.14: + fldt .L_2il0floatpacket.0(%rip) + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.16 +..B1.15: + fldt 16(%rsp) + lea 48+_P1(%rip), %rax + fld %st(0) + lea 32+_P1(%rip), %rcx + lea 16+_P1(%rip), %rdx + lea _P1(%rip), %rsi + fmul %st(1), %st + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + fmulp %st, %st(2) + fldt (%rsi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.16: + testb %r8b, %r8b + je ..B1.18 +..B1.17: + fldcw 82(%rsp) +..B1.18: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.19: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.23 +..B1.20: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.21: + fldcw 80(%rsp) +..B1.22: + movzwl 104(%rsp), %ecx + movb $1, %r8b + andl $32767, %ecx +..B1.23: + fldt .L_2il0floatpacket.0(%rip) + cmpl $16383, %ecx + fstpt 64(%rsp) + jl ..B1.30 +..B1.24: + fldt 96(%rsp) + lea _TWO_63H(%rip), %rax + cmpl $0, 96(%rsp) + fldl (%rax) + jne ..B1.31 +..B1.25: + negl %ecx + movl $-1, %eax + addl $30, %ecx + shll %cl, %eax + testl %eax, 100(%rsp) + jne ..B1.31 +..B1.26: + fld %st(1) + fadd %st(1), %st + fstpt 48(%rsp) + movl 48(%rsp), %eax + cmpl $-16382, %eax + jl ..B1.31 +..B1.27: + fstp %st(0) + fstp %st(0) + addl $16383, %eax + movzwl 8+.L_2il0floatpacket.0(%rip), %edx + andl $32767, %eax + andl $-32768, %edx + orl %eax, %edx + movw %dx, 72(%rsp) + testb %r8b, %r8b + je ..B1.29 +..B1.28: + fldcw 82(%rsp) +..B1.29: + fldt 64(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.30: + fldt 96(%rsp) + lea _TWO_63H(%rip), %rax + fldl (%rax) +..B1.31: + fldt .L_2il0floatpacket.1(%rip) + lea _TWO_48H(%rip), %rcx + fmul %st(2), %st + lea SC2_BIAS(%rip), %r9 + movzwl 72(%rsp), %r11d + fadd %st(1), %st + fstpt 48(%rsp) + fldt 48(%rsp) + andl $-32768, %r11d + movl 48(%rsp), %edx + fsubp %st, %st(1) + fldt .L_2il0floatpacket.2(%rip) + fmulp %st, %st(1) + movsbq %dl, %rax + fsubr %st(1), %st + fldl (%rcx) + movl %eax, %r10d + fld %st(0) + negl %r10d + addl %edx, %r10d + lea 48+_P(%rip), %rcx + shrl $8, %r10d + addl $4196735, %edx + addl (%r9,%rdi,4), %r10d + lea 80+_P(%rip), %rdi + lea 64+_P(%rip), %r9 + andl $32767, %r10d + orl %r10d, %r11d + lea 32+_P(%rip), %r10 + movw %r11w, 72(%rsp) + lea _P(%rip), %r11 + shlq $4, %rax + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + cmpl $3070, %edx + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fldt (%rdi) + lea 16+_P(%rip), %rdi + fmul %st(1), %st + fldt (%rcx) + lea 96+_P(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + movq __libm_expl_table_256@GOTPCREL(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r11) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt (%rcx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(1) + fldl 2048(%rdi,%rax) + fld %st(0) + fmul %st(3), %st + fxch %st(2) + fadd %st, %st(3) + fmul %st(1), %st + faddp %st, %st(1) + fxch %st(2) + fmull 2056(%rdi,%rax) + faddp %st, %st(1) + faddl 2056(%rdi,%rax) + ja ..B1.34 +..B1.32: + lea _exp2but(%rip), %rax + fldt (%rax) + fcomip %st(3), %st + jbe ..B1.34 +..B1.33: + fstp %st(2) + fld %st(0) + lea _TWO_12H(%rip), %rax + lea _SC2(%rip), %rdx + fadd %st(2), %st + fldl (%rax) + fmul %st(1), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt (%rsi,%rdx) + fldt 64(%rsp) + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B1.35 +..B1.34: + fstp %st(2) + fldt 64(%rsp) + fxch %st(2) + faddp %st, %st(1) + lea _SC2(%rip), %rax + fmulp %st, %st(1) + fldt (%rsi,%rax) + fmulp %st, %st(1) + fstpt 32(%rsp) +..B1.35: + fldt 32(%rsp) + lea _minnorm(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + fstp %st(0) + ja ..B1.48 +..B1.36: + testb %r8b, %r8b + je ..B1.38 +..B1.37: + fldt 16(%rsp) + fstpt 48(%rsp) +..B1.58: + fldcw 82(%rsp) +..B1.38: + fldt 32(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.39: + movzwl 82(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.40: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.41: + fldcw 80(%rsp) +..B1.42: + movzwl 104(%rsp), %ecx + movb $1, %r8b + andl $32767, %ecx +..B1.43: + cmpl $32767, %ecx + je ..B1.49 +..B1.44: + testq %rdi, %rdi + je ..B1.46 +..B1.45: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.46: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st +..B1.47: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.48: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.36 +..B1.49: + cmpl $-2147483648, 100(%rsp) + jne ..B1.52 +..B1.50: + cmpl $0, 96(%rsp) + jne ..B1.52 +..B1.51: + lea _inf_zeros(%rip), %rax + fldl (%rax,%rdi,8) + fstpt 16(%rsp) + jmp ..B1.53 +..B1.52: + fldt 96(%rsp) + fstpt 16(%rsp) +..B1.53: + testb %r8b, %r8b + je ..B1.55 +..B1.54: + fldcw 82(%rsp) +..B1.55: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type exp2l,@function + .size exp2l,.-exp2l + .data +# -- End exp2l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf7,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +SC2_BIAS: + .long 8191 + .long 24575 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_inf_zeros: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zeros,@object + .size _inf_zeros,16 + .align 2 +_ranges: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16397 + .word 0 + .word 0 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 32894 + .word 16397 + .word 0 + .word 0 + .word 0 + .type _ranges,@object + .size _ranges,32 + .align 2 +_P1: + .word 31148 + .word 53711 + .word 6135 + .word 45426 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30019 + .word 5676 + .word 61436 + .word 62973 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 31705 + .word 37440 + .word 18104 + .word 58200 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 59309 + .word 6415 + .word 23422 + .word 40341 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,64 + .align 2 +_P: + .word 12039 + .word 52575 + .word 36475 + .word 49086 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 30020 + .word 5676 + .word 61436 + .word 62973 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 64966 + .word 9463 + .word 18104 + .word 58200 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 46891 + .word 53866 + .word 23421 + .word 40341 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 12114 + .word 63546 + .word 699 + .word 44740 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 63250 + .word 29232 + .word 35994 + .word 41348 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45426 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,112 + .align 2 +_exp2but: + .word 0 + .word 0 + .word 0 + .word 65528 + .word 49164 + .word 0 + .word 0 + .word 0 + .type _exp2but,@object + .size _exp2but,16 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .type _SC2,@object + .size _SC2,32 + .align 2 +_minnorm: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _minnorm,@object + .size _minnorm,16 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/exp_gen.S b/external/sgx_libm/intel64/exp_gen.S new file mode 100644 index 0000000000..f79846d22c --- /dev/null +++ b/external/sgx_libm/intel64/exp_gen.S @@ -0,0 +1,604 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp_gen.c" + .text +..TXTST0: +# -- Begin exp + .text + .align 16,0x90 + .globl exp +exp: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_exp.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) +..B1.2: + unpcklpd %xmm0, %xmm0 + movapd cv(%rip), %xmm1 + movapd Shifter(%rip), %xmm6 + movapd 16+cv(%rip), %xmm2 + movapd 32+cv(%rip), %xmm3 + pextrw $3, %xmm0, %eax + andl $32767, %eax + movl $16527, %edx + subl %eax, %edx + subl $15504, %eax + orl %eax, %edx + cmpl $-2147483648, %edx + jae .L_2TAG_PACKET_0.0.2 + lea Tbl_addr(%rip), %r8 + mulpd %xmm0, %xmm1 + addpd %xmm6, %xmm1 + movapd %xmm1, %xmm7 + subpd %xmm6, %xmm1 + mulpd %xmm1, %xmm2 + movapd 64+cv(%rip), %xmm4 + mulpd %xmm1, %xmm3 + movapd 80+cv(%rip), %xmm5 + subpd %xmm2, %xmm0 + movd %xmm7, %eax + movl %eax, %ecx + andl $63, %ecx + shll $4, %ecx + sarl $6, %eax + movl %eax, %edx + movdqa mmask(%rip), %xmm6 + pand %xmm6, %xmm7 + movdqa bias(%rip), %xmm6 + paddq %xmm6, %xmm7 + psllq $46, %xmm7 + subpd %xmm3, %xmm0 + movapd (%rcx,%r8), %xmm2 + mulpd %xmm0, %xmm4 + movapd %xmm0, %xmm6 + movapd %xmm0, %xmm1 + mulpd %xmm6, %xmm6 + mulpd %xmm6, %xmm0 + addpd %xmm4, %xmm5 + mulsd %xmm6, %xmm0 + mulpd 48+cv(%rip), %xmm6 + addsd %xmm2, %xmm1 + unpckhpd %xmm2, %xmm2 + mulpd %xmm5, %xmm0 + addsd %xmm0, %xmm1 + orpd %xmm7, %xmm2 + unpckhpd %xmm0, %xmm0 + addsd %xmm1, %xmm0 + addsd %xmm6, %xmm0 + addl $894, %edx + cmpl $1916, %edx + ja .L_2TAG_PACKET_1.0.2 + mulsd %xmm2, %xmm0 + addsd %xmm2, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_1.0.2: + xorpd %xmm3, %xmm3 + movapd ALLONES(%rip), %xmm4 + movl $-1022, %edx + subl %eax, %edx + movd %edx, %xmm5 + psllq %xmm5, %xmm4 + movl %eax, %ecx + sarl $1, %eax + pinsrw $3, %eax, %xmm3 + movapd ebias(%rip), %xmm6 + psllq $4, %xmm3 + psubd %xmm3, %xmm2 + mulsd %xmm2, %xmm0 + cmpl $52, %edx + jg .L_2TAG_PACKET_2.0.2 + andpd %xmm2, %xmm4 + paddd %xmm6, %xmm3 + subsd %xmm4, %xmm2 + addsd %xmm2, %xmm0 + cmpl $1023, %ecx + jge .L_2TAG_PACKET_3.0.2 + pextrw $3, %xmm0, %ecx + andl $32768, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_4.0.2 + movapd %xmm0, %xmm6 + addsd %xmm4, %xmm0 + mulsd %xmm3, %xmm0 + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl $0, %ecx + je .L_2TAG_PACKET_5.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_5.0.2: + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm4 + movsd %xmm6, %xmm0 + pxor %xmm4, %xmm6 + psrad $31, %xmm6 + pshufd $85, %xmm6, %xmm6 + psllq $1, %xmm0 + psrlq $1, %xmm0 + pxor %xmm6, %xmm0 + psrlq $63, %xmm6 + paddq %xmm6, %xmm0 + paddq %xmm4, %xmm0 + movl $15, (%rsp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_4.0.2: + addsd %xmm4, %xmm0 + mulsd %xmm3, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_3.0.2: + addsd %xmm4, %xmm0 + mulsd %xmm3, %xmm0 + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + cmpl $32752, %ecx + jnb .L_2TAG_PACKET_7.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_2.0.2: + paddd %xmm6, %xmm3 + addpd %xmm2, %xmm0 + mulsd %xmm3, %xmm0 + movl $15, (%rsp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_8.0.2: + cmpl $2146435072, %eax + jae .L_2TAG_PACKET_9.0.2 + movl 12(%rsp), %eax + cmpl $-2147483648, %eax + jae .L_2TAG_PACKET_10.0.2 + movsd XMAX(%rip), %xmm0 + mulsd %xmm0, %xmm0 +.L_2TAG_PACKET_7.0.2: + movl $14, (%rsp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_10.0.2: + movsd XMIN(%rip), %xmm0 + mulsd %xmm0, %xmm0 + movl $15, (%rsp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_9.0.2: + movl 8(%rsp), %edx + cmpl $2146435072, %eax + ja .L_2TAG_PACKET_11.0.2 + cmpl $0, %edx + jne .L_2TAG_PACKET_11.0.2 + movl 12(%rsp), %eax + cmpl $2146435072, %eax + jne .L_2TAG_PACKET_12.0.2 + movsd INF(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_12.0.2: + movsd ZERO(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_11.0.2: + movsd 8(%rsp), %xmm0 + addsd %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + movl 12(%rsp), %eax + andl $2147483647, %eax + cmpl $1083179008, %eax + jae .L_2TAG_PACKET_8.0.2 + movsd 8(%rsp), %xmm0 + addsd ONE_val(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_6.0.2: + movsd %xmm0, 16(%rsp) +..B1.3: + movq 16(%rsp), %xmm0 +.L_2TAG_PACKET_13.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type exp,@function + .size exp,.-exp + .data +# -- End exp + .section .rodata, "a" + .align 16 + .align 16 +cv: + .long 1697350398 + .long 1079448903 + .long 1697350398 + .long 1079448903 + .long 4277796864 + .long 1065758274 + .long 4277796864 + .long 1065758274 + .long 3164486458 + .long 1025308570 + .long 3164486458 + .long 1025308570 + .long 4294967294 + .long 1071644671 + .long 4294967294 + .long 1071644671 + .long 3811088480 + .long 1062650204 + .long 1432067621 + .long 1067799893 + .long 3230715663 + .long 1065423125 + .long 1431604129 + .long 1069897045 + .type cv,@object + .size cv,96 + .align 16 +Shifter: + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .type Shifter,@object + .size Shifter,16 + .align 16 +Tbl_addr: + .long 0 + .long 0 + .long 0 + .long 0 + .long 235107661 + .long 1018002367 + .long 1048019040 + .long 11418 + .long 896005651 + .long 1015861842 + .long 3541402996 + .long 22960 + .long 1642514529 + .long 1012987726 + .long 410360776 + .long 34629 + .long 1568897900 + .long 1016568486 + .long 1828292879 + .long 46424 + .long 1882168529 + .long 1010744893 + .long 852742562 + .long 58348 + .long 509852888 + .long 1017336174 + .long 3490863952 + .long 70401 + .long 653277307 + .long 1017431380 + .long 2930322911 + .long 82586 + .long 1649557430 + .long 1017729363 + .long 1014845818 + .long 94904 + .long 1058231231 + .long 1015777676 + .long 3949972341 + .long 107355 + .long 1044000607 + .long 1016786167 + .long 828946858 + .long 119943 + .long 1151779725 + .long 1015705409 + .long 2288159958 + .long 132667 + .long 3819481236 + .long 1016499965 + .long 1853186616 + .long 145530 + .long 2552227826 + .long 1015039787 + .long 1709341917 + .long 158533 + .long 1829350193 + .long 1015216097 + .long 4112506593 + .long 171677 + .long 1913391795 + .long 1015756674 + .long 2799960843 + .long 184965 + .long 1303423926 + .long 1015238005 + .long 171030293 + .long 198398 + .long 1574172746 + .long 1016061241 + .long 2992903935 + .long 211976 + .long 3424156969 + .long 1017196428 + .long 926591434 + .long 225703 + .long 1938513547 + .long 1017631273 + .long 887463926 + .long 239579 + .long 2804567149 + .long 1015390024 + .long 1276261410 + .long 253606 + .long 631083525 + .long 1017690182 + .long 569847337 + .long 267786 + .long 1623370770 + .long 1011049453 + .long 1617004845 + .long 282120 + .long 3667985273 + .long 1013894369 + .long 3049340112 + .long 296610 + .long 3145379760 + .long 1014403278 + .long 3577096743 + .long 311258 + .long 2603100681 + .long 1017152460 + .long 1990012070 + .long 326066 + .long 3249202951 + .long 1017448880 + .long 1453150081 + .long 341035 + .long 419288974 + .long 1016280325 + .long 917841882 + .long 356167 + .long 3793507337 + .long 1016095713 + .long 3712504873 + .long 371463 + .long 728023093 + .long 1016345318 + .long 363667784 + .long 386927 + .long 2582678538 + .long 1017123460 + .long 2956612996 + .long 402558 + .long 7592966 + .long 1016721543 + .long 2186617380 + .long 418360 + .long 228611441 + .long 1016696141 + .long 1719614412 + .long 434334 + .long 2261665670 + .long 1017457593 + .long 1013258798 + .long 450482 + .long 544148907 + .long 1017323666 + .long 3907805043 + .long 466805 + .long 2383914918 + .long 1017143586 + .long 1447192520 + .long 483307 + .long 1176412038 + .long 1017267372 + .long 1944781190 + .long 499988 + .long 2882956373 + .long 1013312481 + .long 919555682 + .long 516851 + .long 3154077648 + .long 1016528543 + .long 2571947538 + .long 533897 + .long 348651999 + .long 1016405780 + .long 2604962540 + .long 551129 + .long 3253791412 + .long 1015920431 + .long 1110089947 + .long 568549 + .long 1509121860 + .long 1014756995 + .long 2568320822 + .long 586158 + .long 2617649212 + .long 1017340090 + .long 2966275556 + .long 603959 + .long 553214634 + .long 1016457425 + .long 2682146383 + .long 621954 + .long 730975783 + .long 1014083580 + .long 2191782032 + .long 640145 + .long 1486499517 + .long 1016818996 + .long 2069751140 + .long 658534 + .long 2595788928 + .long 1016407932 + .long 2990417244 + .long 677123 + .long 1853053619 + .long 1015310724 + .long 1434058175 + .long 695915 + .long 2462790535 + .long 1015814775 + .long 2572866477 + .long 714911 + .long 3693944214 + .long 1017259110 + .long 3092190714 + .long 734114 + .long 2979333550 + .long 1017188654 + .long 4076559942 + .long 753526 + .long 174054861 + .long 1014300631 + .long 2420883922 + .long 773150 + .long 816778419 + .long 1014197934 + .long 3716502172 + .long 792987 + .long 3507050924 + .long 1015341199 + .long 777507147 + .long 813041 + .long 1821514088 + .long 1013410604 + .long 3706687593 + .long 833312 + .long 920623539 + .long 1016295433 + .long 1242007931 + .long 853805 + .long 2789017511 + .long 1014276997 + .long 3707479175 + .long 874520 + .long 3586233004 + .long 1015962192 + .long 64696965 + .long 895462 + .long 474650514 + .long 1016642419 + .long 863738718 + .long 916631 + .long 1614448851 + .long 1014281732 + .long 3884662774 + .long 938030 + .long 2450082086 + .long 1016164135 + .long 2728693977 + .long 959663 + .long 1101668360 + .long 1015989180 + .long 3999357479 + .long 981531 + .long 835814894 + .long 1015702697 + .long 1533953344 + .long 1003638 + .long 1301400989 + .long 1014466875 + .long 2174652632 + .long 1025985 + .type Tbl_addr,@object + .size Tbl_addr,1024 + .align 16 +mmask: + .long 4294967232 + .long 0 + .long 4294967232 + .long 0 + .type mmask,@object + .size mmask,16 + .align 16 +bias: + .long 65472 + .long 0 + .long 65472 + .long 0 + .type bias,@object + .size bias,16 + .align 16 +ALLONES: + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .type ALLONES,@object + .size ALLONES,16 + .align 16 +ebias: + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .type ebias,@object + .size ebias,16 + .align 4 +XMAX: + .long 4294967295 + .long 2146435071 + .type XMAX,@object + .size XMAX,8 + .align 4 +XMIN: + .long 0 + .long 1048576 + .type XMIN,@object + .size XMIN,8 + .align 4 +INF: + .long 0 + .long 2146435072 + .type INF,@object + .size INF,8 + .align 4 +ZERO: + .long 0 + .long 0 + .type ZERO,@object + .size ZERO,8 + .align 4 +ONE_val: + .long 0 + .long 1072693248 + .type ONE_val,@object + .size ONE_val,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/exp_table.S b/external/sgx_libm/intel64/exp_table.S new file mode 100644 index 0000000000..54de6cac65 --- /dev/null +++ b/external/sgx_libm/intel64/exp_table.S @@ -0,0 +1,515 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "exp_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_exp_hi_table_64 +__libm_exp_hi_table_64: + .long 0x667f3c00,0x3fe6a09e + .long 0x3c651a40,0x3fe6dfb2 + .long 0xe8ec5f80,0x3fe71f75 + .long 0x56426800,0x3fe75feb + .long 0x73eb01c0,0x3fe7a114 + .long 0x36cf4e80,0x3fe7e2f3 + .long 0x994cce20,0x3fe82589 + .long 0x9b449300,0x3fe868d9 + .long 0x422aa0e0,0x3fe8ace5 + .long 0x99157740,0x3fe8f1ae + .long 0xb0cdc600,0x3fe93737 + .long 0x9fde4e60,0x3fe97d82 + .long 0x82a3f0a0,0x3fe9c491 + .long 0x7b5de580,0x3fea0c66 + .long 0xb23e2560,0x3fea5503 + .long 0x5579fdc0,0x3fea9e6b + .long 0x995ad3c0,0x3feae89f + .long 0xb84f1600,0x3feb33a2 + .long 0xf2fb5e60,0x3feb7f76 + .long 0x904bc1e0,0x3febcc1e + .long 0xdd8552a0,0x3fec199b + .long 0x2e57d150,0x3fec67f1 + .long 0xdcef9070,0x3fecb720 + .long 0x4a078980,0x3fed072d + .long 0xdcfba490,0x3fed5818 + .long 0x03db3290,0x3feda9e6 + .long 0x337b9b60,0x3fedfc97 + .long 0xe78b3ff8,0x3fee502e + .long 0xa2a490e0,0x3feea4af + .long 0xee615a28,0x3feefa1b + .long 0x5b6e4544,0x3fef5076 + .long 0x819e90da,0x3fefa7c1 + .long 0x00000000,0x3ff00000 + .long 0x3e778060,0x3ff02c9a + .long 0xd3158574,0x3ff059b0 + .long 0x18759bc8,0x3ff08745 + .long 0x6cf9890c,0x3ff0b558 + .long 0x32d3d1a0,0x3ff0e3ec + .long 0xd0125b50,0x3ff11301 + .long 0xaea92dd8,0x3ff1429a + .long 0x3c7d5178,0x3ff172b8 + .long 0xeb6fcb70,0x3ff1a35b + .long 0x3168b9a8,0x3ff1d487 + .long 0x88628cd0,0x3ff2063b + .long 0x6e756230,0x3ff2387a + .long 0x65e27cd0,0x3ff26b45 + .long 0xf51fdee0,0x3ff29e9d + .long 0xa6e40300,0x3ff2d285 + .long 0x0a31b710,0x3ff306fe + .long 0xb26416f0,0x3ff33c08 + .long 0x373aa9c0,0x3ff371a7 + .long 0x34e59ff0,0x3ff3a7db + .long 0x4c123420,0x3ff3dea6 + .long 0x21f72e20,0x3ff4160a + .long 0x60618920,0x3ff44e08 + .long 0xb5c13cc0,0x3ff486a2 + .long 0xd5362a20,0x3ff4bfda + .long 0x769d2ca0,0x3ff4f9b2 + .long 0x569d4f80,0x3ff5342b + .long 0x36b527c0,0x3ff56f47 + .long 0xdd485420,0x3ff5ab07 + .long 0x15ad2140,0x3ff5e76f + .long 0xb03a5580,0x3ff6247e + .long 0x82552220,0x3ff66238 + .long 0x667f3bc0,0x3ff6a09e + .type __libm_exp_hi_table_64,@object + .size __libm_exp_hi_table_64,520 + .align 8 + .globl __libm_exp_mi_table_64 +__libm_exp_mi_table_64: + .long 0x33018800,0xbfd2bec3 + .long 0x8735cb80,0xbfd2409b + .long 0x2e274100,0xbfd1c114 + .long 0x537b3000,0xbfd14029 + .long 0x1829fc80,0xbfd0bdd7 + .long 0x92616300,0xbfd03a19 + .long 0x9accc780,0xbfcf69d9 + .long 0x92edb400,0xbfce5c99 + .long 0xf7557c80,0xbfcd4c6a + .long 0x9baa2300,0xbfcc3945 + .long 0x3cc8e800,0xbfcb2321 + .long 0x8086c680,0xbfca09f5 + .long 0xf5703d80,0xbfc8edb9 + .long 0x12886a00,0xbfc7ce66 + .long 0x37076a80,0xbfc6abf1 + .long 0xaa180900,0xbfc58652 + .long 0x9a94b100,0xbfc45d81 + .long 0x1ec3a800,0xbfc33175 + .long 0x34128680,0xbfc20224 + .long 0xbed0f880,0xbfc0cf85 + .long 0x13d56b00,0xbfbf3321 + .long 0x8d417580,0xbfbcc076 + .long 0x18837c80,0xbfba46f9 + .long 0xafc3b400,0xbfb7c695 + .long 0x1822db80,0xbfb53f39 + .long 0xe1266b80,0xbfb2b0cf + .long 0x64232500,0xbfb01b46 + .long 0x874c0080,0xbfaafd11 + .long 0xd5b6f200,0xbfa5b505 + .long 0x19ea5d80,0xbfa05e41 + .long 0x92375780,0xbf95f134 + .long 0x985bc980,0xbf860f9f + .long 0x00000000,0x00000000 + .long 0x3bc03000,0x3f864d1f + .long 0xc5615d00,0x3f966c34 + .long 0x0eb37900,0x3fa0e8a3 + .long 0x9f312180,0x3fa6ab0d + .long 0x5a7a3400,0x3fac7d86 + .long 0x0125b500,0x3fb1301d + .long 0xea92dd80,0x3fb429aa + .long 0xc7d51780,0x3fb72b83 + .long 0xb6fcb700,0x3fba35be + .long 0x168b9a80,0x3fbd4873 + .long 0x43146680,0x3fc031dc + .long 0x73ab1180,0x3fc1c3d3 + .long 0x2f13e680,0x3fc35a2b + .long 0xa8fef700,0x3fc4f4ef + .long 0x37201800,0x3fc6942d + .long 0x518db880,0x3fc837f0 + .long 0x9320b780,0x3fc9e045 + .long 0xb9d54e00,0x3fcb8d39 + .long 0xa72cff80,0x3fcd3ed9 + .long 0x6091a100,0x3fcef532 + .long 0x87dcb880,0x3fd05828 + .long 0x81862480,0x3fd13821 + .long 0xd704f300,0x3fd21a8a + .long 0x54d8a880,0x3fd2ff6b + .long 0xda74b280,0x3fd3e6c9 + .long 0x5a753e00,0x3fd4d0ad + .long 0xdad49f00,0x3fd5bd1c + .long 0x75215080,0x3fd6ac1f + .long 0x56b48500,0x3fd79dbc + .long 0xc0e95600,0x3fd891fa + .long 0x09548880,0x3fd988e2 + .long 0x99fcef00,0x3fda8279 + .type __libm_exp_mi_table_64,@object + .size __libm_exp_mi_table_64,520 + .align 8 + .globl __libm_exp_lo_table_64 +__libm_exp_lo_table_64: + .long 0x682764c9,0xbcf9b7ba + .long 0x1d341e44,0xbce10ddf + .long 0x1e1a21ea,0xbcd845b9 + .long 0xb2ae62dc,0xbcfba048 + .long 0x77ee0499,0xbcfc9415 + .long 0xfd45ea87,0xbcedefa2 + .long 0xeea0a997,0xbcdaea60 + .long 0xe26f53db,0xbce37f1b + .long 0xea979b4e,0xbcc29160 + .long 0xb17471a2,0xbcd3a8cf + .long 0xe3c0dabf,0xbceb0baf + .long 0x6df06e17,0xbce07461 + .long 0x729f1c1b,0xbcdfc707 + .long 0x25747355,0xbceb4d65 + .long 0xdb71a83c,0xbcbba5ed + .long 0x78840167,0xbc97829b + .long 0xcb2e88ce,0xbce2a178 + .long 0xbc6109ae,0xbcc42500 + .long 0x4f7e54ac,0xbce91558 + .long 0xbe174986,0xbcdbb708 + .long 0xa76afb72,0xbcbeeef9 + .long 0x200b7c35,0xbcc2d77b + .long 0xd0b85ad9,0xbccbabf0 + .long 0x743797aa,0xbcc1cbc3 + .long 0xf4a29324,0xbcd1b44b + .long 0xfcb49256,0xbcd51ee7 + .long 0x53c612d7,0xbca46973 + .long 0xcfeac66e,0xbcad8c2e + .long 0x3179c289,0xbcc9e9c2 + .long 0xbcada4a8,0xbc911c05 + .long 0xda44ebcf,0xbcbcc583 + .long 0x818b4d9c,0xbcad16f5 + .long 0x00000000,0x00000000 + .long 0x95949ef4,0x3cadcdef + .long 0xa475b465,0x3c8d73e2 + .long 0x4bb284ff,0x3c6186be + .long 0xc95b8c21,0x3ccb14c5 + .long 0x1727c57b,0x3cc0103a + .long 0xe35db263,0x3ca49d77 + .long 0x0650ec96,0x3cdecd04 + .long 0xe4628759,0x3cc6e6fb + .long 0x63da4b47,0x3cd4f2da + .long 0xc0144c88,0x3cc3c02d + .long 0xac0a5425,0x3cd8ee3b + .long 0xf5b6382c,0x3ce0cd83 + .long 0xce6503a7,0x3cea4af4 + .long 0x15f5a24b,0x3cb2c25d + .long 0x3aa6da0f,0x3ce68012 + .long 0x56918c17,0x3cd4b7a3 + .long 0x0c21b2cd,0x3cee9939 + .long 0xaa05e8a9,0x3ce54e28 + .long 0x24a67828,0x3cdba86f + .long 0x911f09ec,0x3cc1ada0 + .long 0x4b71e7b7,0x3ce3f086 + .long 0xde813be0,0x3cea0626 + .long 0xa3b69063,0x3cf013c1 + .long 0x5ebfb10c,0x3cdc750e + .long 0x62da6a82,0x3cdab4cf + .long 0x3c49d86a,0x3cbdf0a8 + .long 0xb004764f,0x3cfa66ec + .long 0x602a323d,0x3ce2b192 + .long 0xc9840733,0x3ce0dd37 + .long 0xe81bf4b7,0x3cd2c7c3 + .long 0x678a6e3d,0x3cd2449f + .long 0x5f626cdd,0x3ce92116 + .type __libm_exp_lo_table_64,@object + .size __libm_exp_lo_table_64,520 + .align 8 + .globl __libm_exp_table_128 +__libm_exp_table_128: + .long 0x908b2fb1,0x3def3bcc + .long 0x66600000,0x3fe6a09e + .long 0xdaed5330,0x3dd7b57d + .long 0x75000000,0x3fe6c012 + .long 0xc8838b30,0x3dc468bb + .long 0x3c600000,0x3fe6dfb2 + .long 0xcf87e1b5,0x3de19483 + .long 0xf9400000,0x3fe6ff7d + .long 0xba46e1e6,0x3dd8bee7 + .long 0xe8e00000,0x3fe71f75 + .long 0xf572693a,0x3dc605ce + .long 0x48a00000,0x3fe73f9a + .long 0xfb74d51a,0x3db33e45 + .long 0x56400000,0x3fe75feb + .long 0x619ae028,0x3dee5d3f + .long 0x4fc00000,0x3fe78069 + .long 0xafaa2048,0x3dd6030d + .long 0x73e00000,0x3fe7a114 + .long 0x7c493344,0x3de0c132 + .long 0x01200000,0x3fe7c1ed + .long 0x20ba0574,0x3dde9cc4 + .long 0x36c00000,0x3fe7e2f3 + .long 0xb60de676,0x3dee1a11 + .long 0x54200000,0x3fe80427 + .long 0x159f115f,0x3dd99c25 + .long 0x99400000,0x3fe82589 + .long 0x7297b5cc,0x3dbe3d66 + .long 0x46200000,0x3fe8471a + .long 0x03907643,0x3dc24bb2 + .long 0x9b400000,0x3fe868d9 + .long 0xcca6179c,0x3dd4cd32 + .long 0xd9800000,0x3fe88ac7 + .long 0xb74f8ab4,0x3dd541b6 + .long 0x42200000,0x3fe8ace5 + .long 0xef2aa1cd,0x3de5448b + .long 0x16a00000,0x3fe8cf32 + .long 0x2b982746,0x3de57736 + .long 0x99000000,0x3fe8f1ae + .long 0x88a61b47,0x3de1ffc5 + .long 0x0b800000,0x3fe9145b + .long 0xe8a0387e,0x3ddb8bc9 + .long 0xb0c00000,0x3fe93737 + .long 0xd36906d3,0x3dd0a41d + .long 0xcbc00000,0x3fe95a44 + .long 0x8b9e9210,0x3dee4e4f + .long 0x9fc00000,0x3fe97d82 + .long 0x74621372,0x3dd40f73 + .long 0x70c00000,0x3fe9a0f1 + .long 0xe3e23584,0x3dbf8480 + .long 0x82a00000,0x3fe9c491 + .long 0xc12653c7,0x3db91918 + .long 0x19e00000,0x3fe9e863 + .long 0xb29ada8c,0x3dede564 + .long 0x7b400000,0x3fea0c66 + .long 0xb182e3ef,0x3dd45a66 + .long 0xec400000,0x3fea309b + .long 0x8b424492,0x3dee255c + .long 0xb2200000,0x3fea5503 + .long 0x6f2dfb2b,0x3de0b358 + .long 0x13200000,0x3fea799e + .long 0x43eb243c,0x3de9fdbf + .long 0x55600000,0x3fea9e6b + .long 0xc0db966a,0x3de3f379 + .long 0xbfc00000,0x3feac36b + .long 0x5e8734d1,0x3dead3ad + .long 0x99400000,0x3feae89f + .long 0x2108559c,0x3ddb6ccb + .long 0x29800000,0x3feb0e07 + .long 0xed7fa1cf,0x3dde2bf5 + .long 0xb8400000,0x3feb33a2 + .long 0x38e20444,0x3dc564e6 + .long 0x8de00000,0x3feb5972 + .long 0xeaa7b082,0x3deb5e46 + .long 0xf2e00000,0x3feb7f76 + .long 0x40cb3c6b,0x3da06498 + .long 0x30a00000,0x3feba5b0 + .long 0x48f741e9,0x3dd783a4 + .long 0x90400000,0x3febcc1e + .long 0x8408d702,0x3de71e08 + .long 0x5bc00000,0x3febf2c2 + .long 0x88832c4b,0x3dc54a70 + .long 0xdd800000,0x3fec199b + .long 0x6d14df82,0x3defd07a + .long 0x5fe00000,0x3fec40ab + .long 0x4a2137fd,0x3de7d14b + .long 0x2e400000,0x3fec67f1 + .long 0x46b2f122,0x3dcb9ed4 + .long 0x94000000,0x3fec8f6d + .long 0x2a0797a4,0x3ddf20d2 + .long 0xdce00000,0x3fecb720 + .long 0xc44f8959,0x3dedc3f9 + .long 0x55400000,0x3fecdf0b + .long 0x343c8bc8,0x3dce25ee + .long 0x4a000000,0x3fed072d + .long 0x15bc2473,0x3ddb13e3 + .long 0x08000000,0x3fed2f87 + .long 0x25da05af,0x3deba487 + .long 0xdce00000,0x3fed5818 + .long 0x7709f3a1,0x3dd3072f + .long 0x16c00000,0x3fed80e3 + .long 0x708c01a6,0x3deb3285 + .long 0x03c00000,0x3feda9e6 + .long 0xb695de3c,0x3dab4604 + .long 0xf3000000,0x3fedd321 + .long 0xb968cac4,0x3deb9b5e + .long 0x33600000,0x3fedfc97 + .long 0xa12761fa,0x3de5a128 + .long 0x14e00000,0x3fee2646 + .long 0x4e7a2603,0x3dd67fec + .long 0xe7800000,0x3fee502e + .long 0x2d522ca1,0x3dcd320d + .long 0xfbc00000,0x3fee7a51 + .long 0x163dce86,0x3dc24366 + .long 0xa2a00000,0x3feea4af + .long 0x1b60625f,0x3ddccfe1 + .long 0x2d800000,0x3feecf48 + .long 0x71fd21a9,0x3da5a277 + .long 0xee600000,0x3feefa1b + .long 0x9d0d2df8,0x3dd7752e + .long 0x37600000,0x3fef252b + .long 0xce9f096f,0x3ddc8a80 + .long 0x5b600000,0x3fef5076 + .long 0x8913b4c0,0x3decbe13 + .long 0xad800000,0x3fef7bfd + .long 0x2e90a7e7,0x3dee90d8 + .long 0x81800000,0x3fefa7c1 + .long 0x12eb7496,0x3ddee3e2 + .long 0x2b800000,0x3fefd3c2 + .long 0x00000000,0x00000000 + .long 0x00000000,0x3ff00000 + .long 0x6d84a66b,0x3dfb3335 + .long 0xa9e00000,0x3ff0163d + .long 0xee6f7cad,0x3df78060 + .long 0x3e600000,0x3ff02c9a + .long 0x7ae71f34,0x3decff09 + .long 0xe8600000,0x3ff04315 + .long 0x3ae7c549,0x3df58574 + .long 0xd3000000,0x3ff059b0 + .long 0xc6dc403b,0x3dfdf6dd + .long 0x29c00000,0x3ff0706b + .long 0x08c35f26,0x3df59bc8 + .long 0x18600000,0x3ff08745 + .long 0x14878183,0x3ddbce0d + .long 0xcac00000,0x3ff09e3e + .long 0x6298b92b,0x3df9890f + .long 0x6ce00000,0x3ff0b558 + .long 0x407b705c,0x3df247f7 + .long 0x2b600000,0x3ff0cc92 + .long 0x020742e5,0x3df3d1a2 + .long 0x32c00000,0x3ff0e3ec + .long 0xf232091e,0x3dfed31a + .long 0xafe00000,0x3ff0fb66 + .long 0xa4ebbf1b,0x3df25b50 + .long 0xd0000000,0x3ff11301 + .long 0xf72575a6,0x3de86397 + .long 0xc0600000,0x3ff12abd + .long 0x66820328,0x3de25bbf + .long 0xaea00000,0x3ff1429a + .long 0x920355cf,0x3dd63944 + .long 0xc8a00000,0x3ff15a98 + .long 0xdcdf7c8c,0x3dfd517a + .long 0x3c600000,0x3ff172b8 + .long 0x777ee173,0x3de91bd3 + .long 0x38800000,0x3ff18af9 + .long 0x796d31ed,0x3def96ea + .long 0xeb600000,0x3ff1a35b + .long 0x6ac79cad,0x3dd1734e + .long 0x84000000,0x3ff1bbe0 + .long 0xf00b7005,0x3de17354 + .long 0x31600000,0x3ff1d487 + .long 0xb8819ff6,0x3dfcd91c + .long 0x22e00000,0x3ff1ed50 + .long 0xdc775815,0x3dc466b1 + .long 0x88600000,0x3ff2063b + .long 0x2552fd29,0x3dfddc96 + .long 0x91600000,0x3ff21f49 + .long 0x66c1fadb,0x3df56238 + .long 0x6e600000,0x3ff2387a + .long 0x3582ab7e,0x3df2a63f + .long 0x4fa00000,0x3ff251ce + .long 0x2bd33994,0x3dc3e6e9 + .long 0x65e00000,0x3ff26b45 + .long 0x96cf15cf,0x3df56380 + .long 0xe1e00000,0x3ff284df + .long 0x2c25d15f,0x3dffdee1 + .long 0xf5000000,0x3ff29e9d + .long 0xfddea465,0x3dfad98f + .long 0xd0c00000,0x3ff2b87f + .long 0x0024754e,0x3dd00c2d + .long 0xa6e00000,0x3ff2d285 + .long 0x11ca0f46,0x3dfe2f56 + .long 0xa9200000,0x3ff2ecaf + .long 0x2de8d5a4,0x3df1b715 + .long 0x0a200000,0x3ff306fe + .long 0x6a739e38,0x3de9b062 + .long 0xfc400000,0x3ff32170 + .long 0x32721843,0x3dd05bfd + .long 0xb2600000,0x3ff33c08 + .long 0xc9462347,0x3df29ff0 + .long 0x5f800000,0x3ff356c5 + .long 0xa7145503,0x3dfaa9ca + .long 0x37200000,0x3ff371a7 + .long 0x16a72c36,0x3dd76196 + .long 0x6d000000,0x3ff38cae + .long 0xa86f24a6,0x3dd67fdb + .long 0x34e00000,0x3ff3a7db + .long 0x84001f23,0x3df3a8e4 + .long 0xc3000000,0x3ff3c32d + .long 0x35b41224,0x3df23422 + .long 0x4c000000,0x3ff3dea6 + .long 0x417ee035,0x3de90037 + .long 0x04a00000,0x3ff3fa45 + .long 0xf84325b9,0x3df72e29 + .long 0x21e00000,0x3ff4160a + .long 0xdc704439,0x3df0a896 + .long 0xd9400000,0x3ff431f5 + .long 0x3136f40a,0x3db892d0 + .long 0x60600000,0x3ff44e08 + .long 0x72512f46,0x3dfd0057 + .long 0xed000000,0x3ff46a41 + .long 0x3c1a3b69,0x3db3cd01 + .long 0xb5c00000,0x3ff486a2 + .long 0x672d8bcf,0x3df7d3de + .long 0xf0c00000,0x3ff4a32a + .long 0x1d4397b0,0x3df62a27 + .long 0xd5200000,0x3ff4bfda + .long 0x63b36ef2,0x3dfddd0d + .long 0x99e00000,0x3ff4dcb2 + .long 0xad33d8b7,0x3dfd2ca6 + .long 0x76800000,0x3ff4f9b2 + .long 0x8225ea59,0x3deecc83 + .long 0xa2c00000,0x3ff516da + .long 0xdf0a83c5,0x3dfd4f81 + .long 0x56800000,0x3ff5342b + .long 0xc52ec620,0x3dfd920e + .long 0xca400000,0x3ff551a4 + .long 0x66ecb004,0x3df527da + .long 0x36a00000,0x3ff56f47 + .long 0x252bc2b7,0x3df7c7fd + .long 0xd4800000,0x3ff58d12 + .long 0xb192602a,0x3de0a852 + .long 0xdd400000,0x3ff5ab07 + .long 0x01c4b1b8,0x3df946b7 + .long 0x8a400000,0x3ff5c926 + .long 0xdd37c984,0x3dea4290 + .long 0x15a00000,0x3ff5e76f + .long 0xb076f593,0x3df6dc08 + .long 0xb9600000,0x3ff605e1 + .long 0xb1f0fa07,0x3dfa5584 + .long 0xb0200000,0x3ff6247e + .long 0x8edf0e2a,0x3de9863f + .long 0x34c00000,0x3ff64346 + .long 0x9127d9e3,0x3df52224 + .long 0x82400000,0x3ff66238 + .long 0x1038ae45,0x3de952e6 + .long 0xd4400000,0x3ff68155 + .long 0x908b2fb1,0x3dff3bcc + .long 0x66600000,0x3ff6a09e + .type __libm_exp_table_128,@object + .size __libm_exp_table_128,2064 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/expf_gen.S b/external/sgx_libm/intel64/expf_gen.S new file mode 100644 index 0000000000..cad669ec94 --- /dev/null +++ b/external/sgx_libm/intel64/expf_gen.S @@ -0,0 +1,721 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expf_gen.c" + .text +..TXTST0: +# -- Begin expf + .text + .align 16,0x90 + .globl expf +expf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_expf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 +..B1.2: + movss LOW_FLOAT_MASK(%rip), %xmm1 + movq log2e(%rip), %xmm3 + movq $0x4338000000000000, %rax + movd %rax, %xmm4 + andps %xmm0, %xmm1 + movd %xmm0, %ecx + cvtps2pd %xmm1, %xmm1 + andl $2147483647, %ecx + subl $830472192, %ecx + cmpl $288180587, %ecx + jae .L_2TAG_PACKET_0.0.2 + movq c2(%rip), %xmm6 + mulsd %xmm1, %xmm3 + movq %xmm4, %xmm2 + addsd %xmm3, %xmm4 + movq 8+c2(%rip), %xmm5 + movd %xmm4, %eax + subsd %xmm4, %xmm2 + movq $0x3ff0000000000000, %rdx + movd %rdx, %xmm1 + lea Th(%rip), %r11 + xorpd %xmm7, %xmm7 + movl %eax, %ecx + andl $255, %eax + movq (%r11,%rax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm7 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm7, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + addl $830472192, %ecx + cmpl $830472192, %ecx + jb .L_2TAG_PACKET_1.0.2 + cmpl $1124073472, %ecx + jae .L_2TAG_PACKET_2.0.2 + movq c2(%rip), %xmm6 + mulsd %xmm1, %xmm3 + movq %xmm4, %xmm2 + xorpd %xmm1, %xmm1 + addsd %xmm3, %xmm4 + movq 8+c2(%rip), %xmm5 + movd %xmm4, %eax + subsd %xmm4, %xmm2 + movl $16368, %edx + pinsrw $3, %edx, %xmm1 + lea Th(%rip), %r11 + xorpd %xmm7, %xmm7 + movl %eax, %ecx + andl $255, %eax + movq (%r11,%rax,8), %xmm0 + addsd %xmm2, %xmm3 + sarl $4, %ecx + andl $-16, %ecx + pinsrw $3, %ecx, %xmm7 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm1, %xmm5 + paddd %xmm7, %xmm0 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm0 + cvtpd2ps %xmm0, %xmm0 + movd %xmm0, %eax + cmpl $8388608, %eax + jb .L_2TAG_PACKET_3.0.2 + cmpl $2139095040, %eax + je .L_2TAG_PACKET_4.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_2.0.2: + movd %xmm0, %edx + cmpl $2139095040, %ecx + jae .L_2TAG_PACKET_5.0.2 + testl $-2147483648, %edx + je .L_2TAG_PACKET_4.0.2 + movl $8388608, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 +.L_2TAG_PACKET_3.0.2: + movl $17, (%rsp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_4.0.2: + movl $2130706432, %eax + movd %eax, %xmm0 + mulss %xmm0, %xmm0 + movl $16, (%rsp) + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_1.0.2: + movl $1065353216, %eax + movd %eax, %xmm1 + addss %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_5.0.2: + cmpl $-8388608, %edx + je .L_2TAG_PACKET_7.0.2 + addss %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_7.0.2: + xorps %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_6.0.2: + movss %xmm0, 4(%rsp) +..B1.3: + movss 4(%rsp), %xmm0 +.L_2TAG_PACKET_8.0.2: +..B1.5: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type expf,@function + .size expf,.-expf + .data +# -- End expf + .section .rodata, "a" + .align 16 + .align 16 +LOW_FLOAT_MASK: + .long 4294967295 + .type LOW_FLOAT_MASK,@object + .size LOW_FLOAT_MASK,4 + .space 4, 0x00 # pad + .align 8 +log2e: + .long 1697350398 + .long 1081546055 + .type log2e,@object + .size log2e,8 + .align 8 +c2: + .long 4286760334 + .long 1053736893 + .long 4277826245 + .long 1063661122 + .type c2,@object + .size c2,16 + .align 8 +Th: + .long 0 + .long 1072693248 + .long 4200250559 + .long 1072696090 + .long 2851812149 + .long 1072698941 + .long 339411585 + .long 1072701800 + .long 1048019041 + .long 1072704666 + .long 772914124 + .long 1072707540 + .long 3899555717 + .long 1072710421 + .long 1928746161 + .long 1072713311 + .long 3541402996 + .long 1072716208 + .long 238821257 + .long 1072719114 + .long 702412510 + .long 1072722027 + .long 728934454 + .long 1072724948 + .long 410360776 + .long 1072727877 + .long 4133881824 + .long 1072730813 + .long 3402036099 + .long 1072733758 + .long 2602514713 + .long 1072736711 + .long 1828292879 + .long 1072739672 + .long 1172597893 + .long 1072742641 + .long 728909815 + .long 1072745618 + .long 590962156 + .long 1072748603 + .long 852742562 + .long 1072751596 + .long 1608493509 + .long 1072754597 + .long 2952712987 + .long 1072757606 + .long 685187902 + .long 1072760624 + .long 3490863953 + .long 1072763649 + .long 2875075254 + .long 1072766683 + .long 3228316108 + .long 1072769725 + .long 351405227 + .long 1072772776 + .long 2930322912 + .long 1072775834 + .long 2471440686 + .long 1072778901 + .long 3366293073 + .long 1072781976 + .long 1416741826 + .long 1072785060 + .long 1014845819 + .long 1072788152 + .long 2257959872 + .long 1072791252 + .long 948735466 + .long 1072794361 + .long 1480023343 + .long 1072797478 + .long 3949972341 + .long 1072800603 + .long 4162030108 + .long 1072803737 + .long 2214878420 + .long 1072806880 + .long 2502433899 + .long 1072810031 + .long 828946858 + .long 1072813191 + .long 1588871207 + .long 1072816359 + .long 586995997 + .long 1072819536 + .long 2218315341 + .long 1072822721 + .long 2288159958 + .long 1072825915 + .long 897099801 + .long 1072829118 + .long 2440944790 + .long 1072832329 + .long 2725843665 + .long 1072835549 + .long 1853186616 + .long 1072838778 + .long 4219606026 + .long 1072842015 + .long 1337108031 + .long 1072845262 + .long 1897844341 + .long 1072848517 + .long 1709341917 + .long 1072851781 + .long 874372905 + .long 1072855054 + .long 3790955393 + .long 1072858335 + .long 1972484976 + .long 1072861626 + .long 4112506593 + .long 1072864925 + .long 1724976915 + .long 1072868234 + .long 3504003472 + .long 1072871551 + .long 964107055 + .long 1072874878 + .long 2799960843 + .long 1072878213 + .long 526652809 + .long 1072881558 + .long 2839424854 + .long 1072884911 + .long 1253935211 + .long 1072888274 + .long 171030293 + .long 1072891646 + .long 3991843581 + .long 1072895026 + .long 4232894513 + .long 1072898416 + .long 1000925746 + .long 1072901816 + .long 2992903935 + .long 1072905224 + .long 1726216749 + .long 1072908642 + .long 1603444721 + .long 1072912069 + .long 2732492859 + .long 1072915505 + .long 926591435 + .long 1072918951 + .long 589198666 + .long 1072922406 + .long 1829099622 + .long 1072925870 + .long 460407023 + .long 1072929344 + .long 887463927 + .long 1072932827 + .long 3219942644 + .long 1072936319 + .long 3272845541 + .long 1072939821 + .long 1156440435 + .long 1072943333 + .long 1276261410 + .long 1072946854 + .long 3743175029 + .long 1072950384 + .long 78413852 + .long 1072953925 + .long 3278348324 + .long 1072957474 + .long 569847338 + .long 1072961034 + .long 654919306 + .long 1072964603 + .long 3645941911 + .long 1072968181 + .long 1065662932 + .long 1072971770 + .long 1617004845 + .long 1072975368 + .long 1118294578 + .long 1072978976 + .long 3978100823 + .long 1072982593 + .long 1720398391 + .long 1072986221 + .long 3049340112 + .long 1072989858 + .long 3784486610 + .long 1072993505 + .long 4040676318 + .long 1072997162 + .long 3933059031 + .long 1073000829 + .long 3577096743 + .long 1073004506 + .long 3088564500 + .long 1073008193 + .long 2583551245 + .long 1073011890 + .long 2178460671 + .long 1073015597 + .long 1990012071 + .long 1073019314 + .long 2135241198 + .long 1073023041 + .long 2731501122 + .long 1073026778 + .long 3896463087 + .long 1073030525 + .long 1453150082 + .long 1073034283 + .long 4109806887 + .long 1073038050 + .long 3395129871 + .long 1073041828 + .long 3723038930 + .long 1073045616 + .long 917841882 + .long 1073049415 + .long 3689071823 + .long 1073053223 + .long 3566716925 + .long 1073057042 + .long 671025100 + .long 1073060872 + .long 3712504873 + .long 1073064711 + .long 4222122499 + .long 1073068561 + .long 2321106615 + .long 1073072422 + .long 2425981843 + .long 1073076293 + .long 363667784 + .long 1073080175 + .long 551349105 + .long 1073084067 + .long 3111574537 + .long 1073087969 + .long 3872257780 + .long 1073091882 + .long 2956612997 + .long 1073095806 + .long 488188413 + .long 1073099741 + .long 885834528 + .long 1073103686 + .long 4273770423 + .long 1073107641 + .long 2186617381 + .long 1073111608 + .long 3339203574 + .long 1073115585 + .long 3561793907 + .long 1073119573 + .long 2979960120 + .long 1073123572 + .long 1719614413 + .long 1073127582 + .long 4201977662 + .long 1073131602 + .long 1963711167 + .long 1073135634 + .long 3721688645 + .long 1073139676 + .long 1013258799 + .long 1073143730 + .long 2555984613 + .long 1073147794 + .long 4182873220 + .long 1073151869 + .long 1727278727 + .long 1073155956 + .long 3907805044 + .long 1073160053 + .long 2263535754 + .long 1073164162 + .long 1218806132 + .long 1073168282 + .long 903334909 + .long 1073172413 + .long 1447192521 + .long 1073176555 + .long 2980802057 + .long 1073180708 + .long 1339972927 + .long 1073184873 + .long 950803702 + .long 1073189049 + .long 1944781191 + .long 1073193236 + .long 158781403 + .long 1073197435 + .long 19972402 + .long 1073201645 + .long 1660913392 + .long 1073205866 + .long 919555682 + .long 1073210099 + .long 2224145553 + .long 1073214343 + .long 1413356050 + .long 1073218599 + .long 2916157145 + .long 1073222866 + .long 2571947539 + .long 1073227145 + .long 515457527 + .long 1073231436 + .long 1176749997 + .long 1073235738 + .long 396319521 + .long 1073240052 + .long 2604962541 + .long 1073244377 + .long 3643909174 + .long 1073248714 + .long 3649726105 + .long 1073253063 + .long 2759350287 + .long 1073257424 + .long 1110089947 + .long 1073261797 + .long 3134592888 + .long 1073266181 + .long 380978316 + .long 1073270578 + .long 1577608921 + .long 1073274986 + .long 2568320822 + .long 1073279406 + .long 3492293770 + .long 1073283838 + .long 194117574 + .long 1073288283 + .long 1403662306 + .long 1073292739 + .long 2966275557 + .long 1073297207 + .long 727685349 + .long 1073301688 + .long 3418903055 + .long 1073306180 + .long 2591453363 + .long 1073310685 + .long 2682146384 + .long 1073315202 + .long 3833209506 + .long 1073319731 + .long 1892288442 + .long 1073324273 + .long 1297350157 + .long 1073328827 + .long 2191782032 + .long 1073333393 + .long 424392917 + .long 1073337972 + .long 434316067 + .long 1073342563 + .long 2366108318 + .long 1073347166 + .long 2069751141 + .long 1073351782 + .long 3985553595 + .long 1073356410 + .long 3964284211 + .long 1073361051 + .long 2152073944 + .long 1073365705 + .long 2990417245 + .long 1073370371 + .long 2331271250 + .long 1073375050 + .long 321958744 + .long 1073379742 + .long 1405169241 + .long 1073384446 + .long 1434058175 + .long 1073389163 + .long 557149882 + .long 1073393893 + .long 3218338682 + .long 1073398635 + .long 977020788 + .long 1073403391 + .long 2572866477 + .long 1073408159 + .long 3861050111 + .long 1073412940 + .long 697153126 + .long 1073417735 + .long 1822067026 + .long 1073422542 + .long 3092190715 + .long 1073427362 + .long 364333489 + .long 1073432196 + .long 2380618042 + .long 1073437042 + .long 703710506 + .long 1073441902 + .long 4076559943 + .long 1073446774 + .long 4062661092 + .long 1073451660 + .long 815859274 + .long 1073456560 + .long 3080351519 + .long 1073461472 + .long 2420883922 + .long 1073466398 + .long 3287523847 + .long 1073471337 + .long 1540824585 + .long 1073476290 + .long 1631695677 + .long 1073481256 + .long 3716502172 + .long 1073486235 + .long 3657065772 + .long 1073491228 + .long 1610600570 + .long 1073496235 + .long 2029714210 + .long 1073501255 + .long 777507147 + .long 1073506289 + .long 2307442995 + .long 1073511336 + .long 2483480501 + .long 1073516397 + .long 1464976603 + .long 1073521472 + .long 3706687593 + .long 1073526560 + .long 778901109 + .long 1073531663 + .long 1432208378 + .long 1073536779 + .long 1532734324 + .long 1073541909 + .long 1242007932 + .long 1073547053 + .long 721996136 + .long 1073552211 + .long 135105010 + .long 1073557383 + .long 3939148246 + .long 1073562568 + .long 3707479175 + .long 1073567768 + .long 3898795731 + .long 1073572982 + .long 382305176 + .long 1073578211 + .long 1912561781 + .long 1073583453 + .long 64696965 + .long 1073588710 + .long 3594158869 + .long 1073593980 + .long 4076975200 + .long 1073599265 + .long 1679558232 + .long 1073604565 + .long 863738719 + .long 1073609879 + .long 1796832535 + .long 1073615207 + .long 351641897 + .long 1073620550 + .long 991358482 + .long 1073625907 + .long 3884662774 + .long 1073631278 + .long 610758006 + .long 1073636665 + .long 4224142467 + .long 1073642065 + .long 2009970496 + .long 1073647481 + .long 2728693978 + .long 1073652911 + .long 2256325230 + .long 1073658356 + .long 764307441 + .long 1073663816 + .long 2719515920 + .long 1073669290 + .long 3999357479 + .long 1073674779 + .long 481706282 + .long 1073680284 + .long 929806999 + .long 1073685803 + .long 1222472308 + .long 1073691337 + .long 1533953344 + .long 1073696886 + .long 2038973688 + .long 1073702450 + .long 2912730644 + .long 1073708029 + .long 35929225 + .long 1073713624 + .long 2174652632 + .long 1073719233 + .long 915592468 + .long 1073724858 + .long 730821105 + .long 1073730498 + .long 1797923801 + .long 1073736153 + .type Th,@object + .size Th,2048 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/expf_table.S b/external/sgx_libm/intel64/expf_table.S new file mode 100644 index 0000000000..dc6538a147 --- /dev/null +++ b/external/sgx_libm/intel64/expf_table.S @@ -0,0 +1,112 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expf_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_expf_table_64 +__libm_expf_table_64: + .long 0x667f3bcd,0x3fe6a09e + .long 0x3c651a2f,0x3fe6dfb2 + .long 0xe8ec5f74,0x3fe71f75 + .long 0x564267c9,0x3fe75feb + .long 0x73eb0187,0x3fe7a114 + .long 0x36cf4e62,0x3fe7e2f3 + .long 0x994cce13,0x3fe82589 + .long 0x9b4492ed,0x3fe868d9 + .long 0x422aa0db,0x3fe8ace5 + .long 0x99157736,0x3fe8f1ae + .long 0xb0cdc5e5,0x3fe93737 + .long 0x9fde4e50,0x3fe97d82 + .long 0x82a3f090,0x3fe9c491 + .long 0x7b5de565,0x3fea0c66 + .long 0xb23e255d,0x3fea5503 + .long 0x5579fdbf,0x3fea9e6b + .long 0x995ad3ad,0x3feae89f + .long 0xb84f15fb,0x3feb33a2 + .long 0xf2fb5e47,0x3feb7f76 + .long 0x904bc1d2,0x3febcc1e + .long 0xdd85529c,0x3fec199b + .long 0x2e57d14b,0x3fec67f1 + .long 0xdcef9069,0x3fecb720 + .long 0x4a07897c,0x3fed072d + .long 0xdcfba487,0x3fed5818 + .long 0x03db3285,0x3feda9e6 + .long 0x337b9b5f,0x3fedfc97 + .long 0xe78b3ff6,0x3fee502e + .long 0xa2a490da,0x3feea4af + .long 0xee615a27,0x3feefa1b + .long 0x5b6e4540,0x3fef5076 + .long 0x819e90d8,0x3fefa7c1 + .long 0x00000000,0x3ff00000 + .long 0x3e778061,0x3ff02c9a + .long 0xd3158574,0x3ff059b0 + .long 0x18759bc8,0x3ff08745 + .long 0x6cf9890f,0x3ff0b558 + .long 0x32d3d1a2,0x3ff0e3ec + .long 0xd0125b51,0x3ff11301 + .long 0xaea92de0,0x3ff1429a + .long 0x3c7d517b,0x3ff172b8 + .long 0xeb6fcb75,0x3ff1a35b + .long 0x3168b9aa,0x3ff1d487 + .long 0x88628cd6,0x3ff2063b + .long 0x6e756238,0x3ff2387a + .long 0x65e27cdd,0x3ff26b45 + .long 0xf51fdee1,0x3ff29e9d + .long 0xa6e4030b,0x3ff2d285 + .long 0x0a31b715,0x3ff306fe + .long 0xb26416ff,0x3ff33c08 + .long 0x373aa9cb,0x3ff371a7 + .long 0x34e59ff7,0x3ff3a7db + .long 0x4c123422,0x3ff3dea6 + .long 0x21f72e2a,0x3ff4160a + .long 0x6061892d,0x3ff44e08 + .long 0xb5c13cd0,0x3ff486a2 + .long 0xd5362a27,0x3ff4bfda + .long 0x769d2ca7,0x3ff4f9b2 + .long 0x569d4f82,0x3ff5342b + .long 0x36b527da,0x3ff56f47 + .long 0xdd485429,0x3ff5ab07 + .long 0x15ad2148,0x3ff5e76f + .long 0xb03a5585,0x3ff6247e + .long 0x82552225,0x3ff66238 + .long 0x667f3bcd,0x3ff6a09e + .type __libm_expf_table_64,@object + .size __libm_expf_table_64,520 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/expl.S b/external/sgx_libm/intel64/expl.S new file mode 100644 index 0000000000..fbd0ff76a7 --- /dev/null +++ b/external/sgx_libm/intel64/expl.S @@ -0,0 +1,599 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expl.c" + .text +..TXTST0: +# -- Begin expl + .text + .align 16,0x90 + .globl expl +expl: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_expl.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %dil, %dil +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movb 105(%rsp), %al + lea _ranges(%rip), %r8 + andb $-128, %al + shrb $7, %al + movzbl %al, %esi + movq %rsi, %rcx + shlq $4, %rcx + movzwl 104(%rsp), %eax + andl $32767, %eax + movzwl 8(%rcx,%r8), %edx + andl $32767, %edx + cmpl %edx, %eax + jl ..B1.8 +..B1.4: + jne ..B1.31 +..B1.5: + movl 100(%rsp), %edx + cmpl 4(%rcx,%r8), %edx + jb ..B1.8 +..B1.6: + jne ..B1.31 +..B1.7: + movl 96(%rsp), %edx + cmpl (%rcx,%r8), %edx + jae ..B1.31 +..B1.8: + movzwl 82(%rsp), %r8d + cmpl $16363, %eax + jge ..B1.19 +..B1.9: + movl %r8d, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.13 +..B1.10: + orl $-64768, %r8d + movw %r8w, 80(%rsp) +..B1.11: + fldcw 80(%rsp) +..B1.12: + movzwl 104(%rsp), %eax + movb $1, %dil + andl $32767, %eax +..B1.13: + fldt 96(%rsp) + cmpl $16316, %eax + fstpt 16(%rsp) + jge ..B1.15 +..B1.14: + fldt .L_2il0floatpacket.0(%rip) + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.16 +..B1.15: + fldt 16(%rsp) + lea 16+_P1(%rip), %rax + fldt .L_2il0floatpacket.0(%rip) + lea _P1(%rip), %rdx + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(2), %st + fmul %st(2), %st + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.16: + testb %dil, %dil + je ..B1.18 +..B1.17: + fldcw 82(%rsp) +..B1.18: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.19: + movl %r8d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.23 +..B1.20: + orl $-64768, %r8d + movw %r8w, 80(%rsp) +..B1.21: + fldcw 80(%rsp) +..B1.22: + movb $1, %dil +..B1.23: + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %r8 + fstpt 48(%rsp) + lea _TWO_32H(%rip), %r9 + fldt 96(%rsp) + lea SC2_BIAS(%rip), %r10 + fldt .L_2il0floatpacket.1(%rip) + fmul %st(1), %st + fldl (%r8) + movzwl 8+.L_2il0floatpacket.0(%rip), %r8d + fadd %st, %st(1) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + andl $-32768, %r8d + movl 64(%rsp), %edx + fsubp %st, %st(1) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(1), %st + movsbq %dl, %rax + fsubr %st(2), %st + fld %st(0) + movl %eax, %r11d + fldt .L_2il0floatpacket.3(%rip) + negl %r11d + fmulp %st, %st(3) + addl %edx, %r11d + shrl $8, %r11d + addl $4196735, %edx + addl (%r10,%rsi,4), %r11d + lea 64+_P(%rip), %rsi + andl $32767, %r11d + lea 16+_P(%rip), %r10 + orl %r11d, %r8d + fsub %st(2), %st + fldl (%r9) + lea 48+_P(%rip), %r9 + movw %r8w, 56(%rsp) + lea _P(%rip), %r8 + shlq $4, %rax + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + cmpl $3070, %edx + movq __libm_expl_table_256@GOTPCREL(%rip), %r11 + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt (%rsi) + lea 32+_P(%rip), %rsi + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fldl 2048(%r11,%rax) + fld %st(0) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fxch %st(1) + fmull 2056(%r11,%rax) + faddp %st, %st(2) + faddl 2056(%r11,%rax) + faddp %st, %st(1) + ja ..B1.26 +..B1.24: + lea _expbut(%rip), %rax + fldt (%rax) + fcomip %st(3), %st + jbe ..B1.26 +..B1.25: + fstp %st(2) + fld %st(0) + lea _TWO_12H(%rip), %rax + lea _SC2(%rip), %rdx + fadd %st(2), %st + fldl (%rax) + fmul %st(1), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fldt (%rcx,%rdx) + fldt 48(%rsp) + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B1.27 +..B1.26: + fstp %st(2) + lea _SC2(%rip), %rax + faddp %st, %st(1) + fldt 48(%rsp) + fmulp %st, %st(1) + fldt (%rcx,%rax) + fmulp %st, %st(1) + fstpt 32(%rsp) +..B1.27: + fldt 32(%rsp) + lea _minnorm(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + fstp %st(0) + ja ..B1.42 +..B1.28: + testb %dil, %dil + je ..B1.30 +..B1.29: + fldt 16(%rsp) + fstpt 64(%rsp) +..B1.49: + fldcw 82(%rsp) +..B1.30: + fldt 32(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.31: + movzwl 82(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.35 +..B1.32: + orl $-64768, %ecx + movw %cx, 80(%rsp) +..B1.33: + fldcw 80(%rsp) +..B1.34: + movzwl 104(%rsp), %eax + movb $1, %dil + andl $32767, %eax +..B1.35: + cmpl $32767, %eax + je ..B1.43 +..B1.36: + testq %rsi, %rsi + je ..B1.38 +..B1.37: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) + jmp ..B1.39 +..B1.38: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) +..B1.39: + testb %dil, %dil + je ..B1.41 +..B1.40: + fldcw 82(%rsp) +..B1.41: + fldt 16(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.42: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.28 +..B1.43: + cmpl $-2147483648, 100(%rsp) + jne ..B1.46 +..B1.44: + cmpl $0, 96(%rsp) + jne ..B1.46 +..B1.45: + lea _inf_zeros(%rip), %rax + fldl (%rax,%rsi,8) + fstpt 16(%rsp) + jmp ..B1.39 +..B1.46: + fldt 96(%rsp) + fstpt 16(%rsp) + jmp ..B1.39 + .align 16,0x90 + .cfi_endproc + .type expl,@function + .size expl,.-expl + .data +# -- End expl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +SC2_BIAS: + .long 8191 + .long 24575 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_inf_zeros: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zeros,@object + .size _inf_zeros,16 + .align 2 +_ranges: + .word 31148 + .word 53711 + .word 6135 + .word 45426 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 488 + .word 27074 + .word 50247 + .word 45600 + .word 16396 + .word 0 + .word 0 + .word 0 + .type _ranges,@object + .size _ranges,32 + .align 2 +_P1: + .word 43691 + .word 10 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30584 + .word 43703 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,32 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_expbut: + .word 60207 + .word 4624 + .word 35943 + .word 45420 + .word 49164 + .word 0 + .word 0 + .word 0 + .type _expbut,@object + .size _expbut,16 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .type _SC2,@object + .size _SC2,32 + .align 2 +_minnorm: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _minnorm,@object + .size _minnorm,16 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/expl_table.S b/external/sgx_libm/intel64/expl_table.S new file mode 100644 index 0000000000..e01307b984 --- /dev/null +++ b/external/sgx_libm/intel64/expl_table.S @@ -0,0 +1,561 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expl_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_expl_table_256 +__libm_expl_table_256: + .long 0x66800000,0x3fe6a09e + .long 0xee9a09d9,0xbd98866d + .long 0xfa800000,0x3fe6b052 + .long 0xcb8e15a7,0xbdd5d183 + .long 0x75000000,0x3fe6c012 + .long 0xdaed5330,0x3dd7b57d + .long 0xde000000,0x3fe6cfdc + .long 0x470aac92,0xbdf5c4dd + .long 0x3c400000,0x3fe6dfb2 + .long 0x79107166,0x3df28d17 + .long 0x98400000,0x3fe6ef92 + .long 0xbd1a2d88,0x3de93ae4 + .long 0xf9400000,0x3fe6ff7d + .long 0xcf87e1b5,0x3de19483 + .long 0x67000000,0x3fe70f74 + .long 0xf314dd96,0xbdd7a2f1 + .long 0xe9000000,0x3fe71f75 + .long 0x22dc8f0d,0xbde3a08c + .long 0x87000000,0x3fe72f82 + .long 0x482a80b3,0xbde52f76 + .long 0x48c00000,0x3fe73f9a + .long 0x42a365b2,0xbdea7e8c + .long 0x35c00000,0x3fe74fbd + .long 0x411ff586,0x3de7cbfd + .long 0x56400000,0x3fe75feb + .long 0xfb74d51a,0x3db33e45 + .long 0xb1c00000,0x3fe77024 + .long 0x921e23a6,0xbde491f6 + .long 0x4fc00000,0x3fe78069 + .long 0x619ae028,0x3dee5d3f + .long 0x38c00000,0x3fe790b9 + .long 0xb2d95e75,0xbde3e309 + .long 0x74000000,0x3fe7a114 + .long 0x282aefdc,0xbde4fe79 + .long 0x09800000,0x3fe7b17b + .long 0xdf5dac23,0xbdd2604a + .long 0x01000000,0x3fe7c1ed + .long 0x3e2499a2,0x3df86099 + .long 0x63000000,0x3fe7d26a + .long 0x4224048d,0xbd8e43ee + .long 0x36c00000,0x3fe7e2f3 + .long 0x20ba0574,0x3dde9cc4 + .long 0x84800000,0x3fe7f387 + .long 0xdf01dc61,0x3de1c490 + .long 0x54400000,0x3fe80427 + .long 0x9f21989b,0xbdae5ee4 + .long 0xae000000,0x3fe814d2 + .long 0x573791e6,0xbdf77c93 + .long 0x99400000,0x3fe82589 + .long 0x159f115f,0x3dd99c25 + .long 0x1e800000,0x3fe8364c + .long 0xb3373464,0x3dfca0fb + .long 0x46400000,0x3fe8471a + .long 0x31ad0947,0xbdec3853 + .long 0x17800000,0x3fe857f4 + .long 0xf9162dc2,0x3def5b20 + .long 0x9b400000,0x3fe868d9 + .long 0x03907643,0x3dc24bb2 + .long 0xd9400000,0x3fe879ca + .long 0xa8b4a0b5,0xbddcb793 + .long 0xd9800000,0x3fe88ac7 + .long 0xcca6179c,0x3dd4cd32 + .long 0xa4800000,0x3fe89bd0 + .long 0x2ac6abb9,0xbdce9fc2 + .long 0x42400000,0x3fe8ace5 + .long 0xa4583aa6,0xbde55f24 + .long 0xbac00000,0x3fe8be05 + .long 0x7b2d7bf1,0x3de61778 + .long 0x16c00000,0x3fe8cf32 + .long 0x21aabc66,0xbdd576e8 + .long 0x5e400000,0x3fe8e06a + .long 0xae2294e0,0xbdfbcc93 + .long 0x99000000,0x3fe8f1ae + .long 0x2b982746,0x3de57736 + .long 0xd0000000,0x3fe902fe + .long 0x2b25950c,0x3df41645 + .long 0x0b800000,0x3fe9145b + .long 0x88a61b47,0x3de1ffc5 + .long 0x53800000,0x3fe925c3 + .long 0xecbaa05a,0x3df517f0 + .long 0xb0c00000,0x3fe93737 + .long 0xe8a0387e,0x3ddb8bc9 + .long 0x2b400000,0x3fe948b8 + .long 0xc478530d,0x3def98e4 + .long 0xcbc00000,0x3fe95a44 + .long 0xd36906d3,0x3dd0a41d + .long 0x9a400000,0x3fe96bdd + .long 0x7c8b4d30,0x3dfb3859 + .long 0x9fc00000,0x3fe97d82 + .long 0x8b9e9210,0x3dee4e4f + .long 0xe4800000,0x3fe98f33 + .long 0x8d509577,0xbdc77577 + .long 0x70c00000,0x3fe9a0f1 + .long 0x74621372,0x3dd40f73 + .long 0x4d400000,0x3fe9b2bb + .long 0x889ec6c8,0x3de3fe0c + .long 0x82800000,0x3fe9c491 + .long 0x0e3e2358,0x3df1f848 + .long 0x19400000,0x3fe9d674 + .long 0x574a0ae1,0x3dd771a9 + .long 0x19c00000,0x3fe9e863 + .long 0x8c12653c,0x3df19191 + .long 0x8d000000,0x3fe9fa5e + .long 0x5ab18aa8,0x3dcfca77 + .long 0x7b400000,0x3fea0c66 + .long 0xb29ada8c,0x3dede564 + .long 0xed800000,0x3fea1e7a + .long 0xe330c774,0x3ddd7176 + .long 0xec400000,0x3fea309b + .long 0xb182e3ef,0x3dd45a66 + .long 0x80400000,0x3fea42c9 + .long 0x5587fa76,0x3dc82b5e + .long 0xb2400000,0x3fea5503 + .long 0x4bdbb6e3,0xbdadaa37 + .long 0x8b000000,0x3fea674a + .long 0xeaf0a9d0,0xbdd73f5b + .long 0x13400000,0x3fea799e + .long 0x21a409aa,0xbdde994f + .long 0x53c00000,0x3fea8bfe + .long 0xc1e61351,0x3da2e58a + .long 0x55400000,0x3fea9e6b + .long 0xa1f5921e,0x3dfcfedf + .long 0x21400000,0x3feab0e5 + .long 0x9d8f3894,0xbdd5228b + .long 0xbfc00000,0x3feac36b + .long 0xc0db966a,0x3de3f379 + .long 0x3a400000,0x3fead5ff + .long 0x0218892a,0xbdbec45d + .long 0x99800000,0x3feae89f + .long 0x50bc6597,0xbdf29629 + .long 0xe6400000,0x3feafb4c + .long 0x52cbf03d,0xbded0d01 + .long 0x29800000,0x3feb0e07 + .long 0x2108559c,0x3ddb6ccb + .long 0x6c800000,0x3feb20ce + .long 0x53740928,0x3dea8952 + .long 0xb8800000,0x3feb33a2 + .long 0x84a0178c,0xbdf87502 + .long 0x15c00000,0x3feb4684 + .long 0x3eec7bd4,0xbdd16c9e + .long 0x8e000000,0x3feb5972 + .long 0x71c77eef,0xbdeaa6c6 + .long 0x2a000000,0x3feb6c6e + .long 0x6ab8656c,0xbddc75ab + .long 0xf3000000,0x3feb7f76 + .long 0x55613df9,0xbdc286e4 + .long 0xf2400000,0x3feb928c + .long 0x6dc85953,0xbde8b61c + .long 0x30c00000,0x3feba5b0 + .long 0x7bf34c39,0xbdeef9b6 + .long 0xb7c00000,0x3febb8e0 + .long 0x80fa968e,0xbdf2c870 + .long 0x90400000,0x3febcc1e + .long 0x48f741e9,0x3dd783a4 + .long 0xc4000000,0x3febdf69 + .long 0x0384c46c,0xbdd8bbf2 + .long 0x5c000000,0x3febf2c2 + .long 0xbdfb947f,0xbdf470fb + .long 0x61400000,0x3fec0628 + .long 0x4eb4abc1,0x3dab33cc + .long 0xdd800000,0x3fec199b + .long 0x88832c4b,0x3dc54a70 + .long 0xd9c00000,0x3fec2d1c + .long 0xd235d3d0,0x3dfd3295 + .long 0x60000000,0x3fec40ab + .long 0x75903ef8,0xbd77c2c9 + .long 0x79000000,0x3fec5447 + .long 0xed0f8db7,0xbdc41376 + .long 0x2e400000,0x3fec67f1 + .long 0x4a2137fd,0x3de7d14b + .long 0x89c00000,0x3fec7ba8 + .long 0x9e76bbbe,0xbdfb9b66 + .long 0x94000000,0x3fec8f6d + .long 0x46b2f122,0x3dcb9ed4 + .long 0x57400000,0x3feca340 + .long 0xd01a825e,0x3de1c4da + .long 0xdd000000,0x3fecb720 + .long 0xeafc342e,0xbde06f96 + .long 0x2e800000,0x3feccb0f + .long 0x1d220f86,0xbde2e98b + .long 0x55400000,0x3fecdf0b + .long 0xc44f8959,0x3dedc3f9 + .long 0x5b800000,0x3fecf315 + .long 0x3411d371,0xbdf22a46 + .long 0x4a000000,0x3fed072d + .long 0x343c8bc8,0x3dce25ee + .long 0x2b000000,0x3fed1b53 + .long 0xaab1b10d,0x3dd192d0 + .long 0x08000000,0x3fed2f87 + .long 0x15bc2473,0x3ddb13e3 + .long 0xeac00000,0x3fed43c8 + .long 0x9eda9dfb,0x3dd543ac + .long 0xdd000000,0x3fed5818 + .long 0x6897e945,0xbdc16de3 + .long 0xe8400000,0x3fed6c76 + .long 0x83fd0f49,0x3df17369 + .long 0x16c00000,0x3fed80e3 + .long 0x7709f3a1,0x3dd3072f + .long 0x72000000,0x3fed955d + .long 0xfd692233,0xbd93f152 + .long 0x04000000,0x3feda9e6 + .long 0x47b9ff2d,0xbdf266bd + .long 0xd6400000,0x3fedbe7c + .long 0xb76f1927,0xbdc5f3ad + .long 0xf3000000,0x3fedd321 + .long 0xb695de3c,0x3dab4604 + .long 0x64000000,0x3fede7d5 + .long 0x8d6ab5c6,0x3dec0657 + .long 0x33800000,0x3fedfc97 + .long 0x1a5cd4f2,0xbdc19285 + .long 0x6b000000,0x3fee1167 + .long 0xed4ad643,0x3de97d16 + .long 0x15000000,0x3fee2646 + .long 0xbdb13c0c,0xbdd4bdae + .long 0x3b000000,0x3fee3b33 + .long 0x982d6f38,0x3de6ee11 + .long 0xe7c00000,0x3fee502e + .long 0xec61767f,0xbdfa6004 + .long 0x24800000,0x3fee6539 + .long 0x2c7ff0ea,0xbde8928a + .long 0xfbc00000,0x3fee7a51 + .long 0x2d522ca1,0x3dcd320d + .long 0x77c00000,0x3fee8f79 + .long 0x77bb5bfa,0x3ddb6e7f + .long 0xa2c00000,0x3feea4af + .long 0x7a708c5e,0xbdeb6f26 + .long 0x86800000,0x3feeb9f4 + .long 0x6f9a1bae,0xbdb9ac8d + .long 0x2d800000,0x3feecf48 + .long 0x1b60625f,0x3ddccfe1 + .long 0xa2000000,0x3feee4aa + .long 0x471a3692,0x3de88510 + .long 0xee400000,0x3feefa1b + .long 0xbb8fe90d,0x3df0ad13 + .long 0x1cc00000,0x3fef0f9c + .long 0x99100329,0xbdd37dac + .long 0x37800000,0x3fef252b + .long 0xb1796904,0xbde44568 + .long 0x48c00000,0x3fef3ac9 + .long 0xe6a5a5c1,0x3ded7273 + .long 0x5b800000,0x3fef5076 + .long 0x98b07b49,0xbde1babf + .long 0x79800000,0x3fef6632 + .long 0xfd1bd9aa,0x3dd089f0 + .long 0xadc00000,0x3fef7bfd + .long 0x3b7625a0,0xbdf1a0f6 + .long 0x02400000,0x3fef91d8 + .long 0x08975454,0xbdebc377 + .long 0x81c00000,0x3fefa7c1 + .long 0xe8b7ac0c,0xbdf0b793 + .long 0x36800000,0x3fefbdba + .long 0xe6988ceb,0x3de2d513 + .long 0x2b800000,0x3fefd3c2 + .long 0x12eb7496,0x3ddee3e2 + .long 0x6b400000,0x3fefe9d9 + .long 0xeb59fc8c,0xbde5dc26 + .long 0x00000000,0x3ff00000 + .long 0x00000000,0x00000000 + .long 0xfa600000,0x3ff00b1a + .long 0xa7b5953b,0xbdd50d04 + .long 0xaa000000,0x3ff0163d + .long 0x49ed6654,0xbdd3332a + .long 0x14400000,0x3ff02168 + .long 0x95f9887e,0xbdd3f5fc + .long 0x3e800000,0x3ff02c9a + .long 0x232106a7,0xbde0ff3e + .long 0x2e200000,0x3ff037d4 + .long 0xea97ee11,0xbdec8867 + .long 0xe8800000,0x3ff04315 + .long 0x428c7066,0xbdf1807b + .long 0x73000000,0x3ff04e5f + .long 0xacf21b15,0xbde3569d + .long 0xd3200000,0x3ff059b0 + .long 0x8a30756e,0xbde4f517 + .long 0x0e400000,0x3ff0650a + .long 0xb96f6af3,0xbdcf03ba + .long 0x29e00000,0x3ff0706b + .long 0xc91dfe2b,0xbdc04911 + .long 0x2b800000,0x3ff07bd4 + .long 0xb3732eaf,0xbdeaaf93 + .long 0x18800000,0x3ff08745 + .long 0xee7941b4,0xbde4c86f + .long 0xf6600000,0x3ff092bd + .long 0x97f9c7ff,0x3dd81f7e + .long 0xcac00000,0x3ff09e3e + .long 0x14878183,0x3ddbce0d + .long 0x9b200000,0x3ff0a9c7 + .long 0x8ba4de31,0xbda8dcda + .long 0x6d000000,0x3ff0b558 + .long 0x759d1b52,0xbdd9dbc2 + .long 0x45e00000,0x3ff0c0f1 + .long 0x4f98906d,0x3dd1b215 + .long 0x2b600000,0x3ff0cc92 + .long 0x407b705c,0x3df247f7 + .long 0x23400000,0x3ff0d83b + .long 0xbc14de44,0xbdda8851 + .long 0x32e00000,0x3ff0e3ec + .long 0xfbf17a36,0xbde85cbb + .long 0x5fe00000,0x3ff0efa5 + .long 0x9db9bc54,0xbd958ed4 + .long 0xb0000000,0x3ff0fb66 + .long 0xdcdf6e22,0xbdb2ce50 + .long 0x28c00000,0x3ff10730 + .long 0x3a8dd62d,0x3df7233e + .long 0xd0200000,0x3ff11301 + .long 0xb62881ca,0xbdeb495e + .long 0xab600000,0x3ff11edb + .long 0x29153dc1,0xbdbd54a7 + .long 0xc0600000,0x3ff12abd + .long 0xf72575a6,0x3de86397 + .long 0x14e00000,0x3ff136a8 + .long 0xf477b823,0x3df204aa + .long 0xaea00000,0x3ff1429a + .long 0x66820328,0x3de25bbf + .long 0x93600000,0x3ff14e95 + .long 0x3723d073,0xbdf0ced2 + .long 0xc8a00000,0x3ff15a98 + .long 0x920355cf,0x3dd63944 + .long 0x54600000,0x3ff166a4 + .long 0x063c8ee1,0x3df1c3c2 + .long 0x3c800000,0x3ff172b8 + .long 0x19041b9d,0xbdc57429 + .long 0x86a00000,0x3ff17ed4 + .long 0xdec3803b,0xbde4887f + .long 0x38800000,0x3ff18af9 + .long 0x777ee173,0x3de91bd3 + .long 0x58400000,0x3ff19726 + .long 0x5aa913d0,0xbde145a1 + .long 0xeb600000,0x3ff1a35b + .long 0x796d31ed,0x3def96ea + .long 0xf8200000,0x3ff1af99 + .long 0x4203d2da,0xbde8ebc7 + .long 0x84000000,0x3ff1bbe0 + .long 0x6ac79cad,0x3dd1734e + .long 0x95200000,0x3ff1c82f + .long 0x804bbc01,0x3de038d6 + .long 0x31800000,0x3ff1d487 + .long 0x87fa47fd,0xbdf74655 + .long 0x5ec00000,0x3ff1e0e7 + .long 0xb7eec044,0xbde77fb2 + .long 0x23000000,0x3ff1ed50 + .long 0x3bf3004f,0xbdc9371a + .long 0x84400000,0x3ff1f9c1 + .long 0xbf524a09,0xbddcc6cd + .long 0x88600000,0x3ff2063b + .long 0xdc775815,0x3dc466b1 + .long 0x35600000,0x3ff212be + .long 0x4d64b4b4,0x3df8a819 + .long 0x91800000,0x3ff21f49 + .long 0xd56816b7,0xbdc11b4e + .long 0xa2800000,0x3ff22bdd + .long 0x16582554,0xbddbb4bb + .long 0x6e800000,0x3ff2387a + .long 0x327c0a4a,0xbde53b8f + .long 0xfba00000,0x3ff2451f + .long 0xca6066de,0xbdfdebf5 + .long 0x4fc00000,0x3ff251ce + .long 0x94faa904,0xbdeab381 + .long 0x71200000,0x3ff25e85 + .long 0x07976d4f,0xbdb318ab + .long 0x65e00000,0x3ff26b45 + .long 0x2bd33994,0x3dc3e6e9 + .long 0x34200000,0x3ff2780e + .long 0x3f307f41,0xbdc106b4 + .long 0xe1e00000,0x3ff284df + .long 0x96cf15cf,0x3df56380 + .long 0x75800000,0x3ff291ba + .long 0xda671baf,0x3df1bb6f + .long 0xf5200000,0x3ff29e9d + .long 0xed175053,0xbd808f69 + .long 0x66c00000,0x3ff2ab8a + .long 0x9aa2f39c,0x3df10f12 + .long 0xd0e00000,0x3ff2b87f + .long 0x08856e6b,0xbdd499c0 + .long 0x39600000,0x3ff2c57e + .long 0xabfae964,0x3df71b2e + .long 0xa7000000,0x3ff2d285 + .long 0xbff6e2ad,0xbdfbfcf4 + .long 0x1f600000,0x3ff2df96 + .long 0xd16cffbc,0x3dd05625 + .long 0xa9400000,0x3ff2ecaf + .long 0xe35f0ba3,0xbdbd0a9e + .long 0x4ac00000,0x3ff2f9d2 + .long 0x54f1554d,0xbdc3bca8 + .long 0x0a200000,0x3ff306fe + .long 0x2de8d5a4,0x3df1b715 + .long 0xee000000,0x3ff31432 + .long 0xcd4cb818,0xbdf14d02 + .long 0xfc400000,0x3ff32170 + .long 0x6a739e38,0x3de9b062 + .long 0x3ba00000,0x3ff32eb8 + .long 0x1dd0be1a,0x3de1d463 + .long 0xb2600000,0x3ff33c08 + .long 0x32721843,0x3dd05bfd + .long 0x66e00000,0x3ff34962 + .long 0xca58a6cf,0x3dcfd166 + .long 0x5fa00000,0x3ff356c5 + .long 0x6d73b971,0xbdeac01e + .long 0xa2e00000,0x3ff36431 + .long 0x8628940e,0xbdb77c53 + .long 0x37400000,0x3ff371a7 + .long 0x63aeabf4,0xbdd558d5 + .long 0x23200000,0x3ff37f26 + .long 0x7d72a7b4,0xbdb8ab66 + .long 0x6d000000,0x3ff38cae + .long 0x16a72c36,0x3dd76196 + .long 0x1b800000,0x3ff39a40 + .long 0xcd4d2fe4,0xbded7e22 + .long 0x34e00000,0x3ff3a7db + .long 0xa86f24a6,0x3dd67fdb + .long 0xc0000000,0x3ff3b57f + .long 0xaace6476,0xbdf3930b + .long 0xc3200000,0x3ff3c32d + .long 0xf7ffc1bb,0xbde8ae36 + .long 0x44e00000,0x3ff3d0e5 + .long 0x3fd1a118,0x3debc2e6 + .long 0x4c200000,0x3ff3dea6 + .long 0x9497dbb8,0xbdeb97bb + .long 0xdf200000,0x3ff3ec70 + .long 0xaf6637b9,0xbdcd7459 + .long 0x04a00000,0x3ff3fa45 + .long 0x417ee035,0x3de90037 + .long 0xc3600000,0x3ff40822 + .long 0xdeefc5b8,0x3dde8090 + .long 0x22000000,0x3ff4160a + .long 0x0f79b48e,0xbde1a3ac + .long 0x27000000,0x3ff423fb + .long 0x3dce91fa,0x3de28d13 + .long 0xd9600000,0x3ff431f5 + .long 0x471f778d,0xbdeeaed2 + .long 0x3f800000,0x3ff43ffa + .long 0xc405f4b8,0x3dd2e750 + .long 0x60600000,0x3ff44e08 + .long 0x3136f40a,0x3db892d0 + .long 0x42a00000,0x3ff45c20 + .long 0xcf37ccfa,0x3ddf48c7 + .long 0xed200000,0x3ff46a41 + .long 0x6d7685d3,0xbdc7fd44 + .long 0x66800000,0x3ff4786d + .long 0x1ef87896,0x3de6646d + .long 0xb5c00000,0x3ff486a2 + .long 0x3c1a3b69,0x3db3cd01 + .long 0xe1a00000,0x3ff494e1 + .long 0x4eca2579,0xbdeaa25c + .long 0xf0e00000,0x3ff4a32a + .long 0x31a4e861,0xbde05843 + .long 0xea800000,0x3ff4b17d + .long 0x224b70fe,0xbdf24829 + .long 0xd5400000,0x3ff4bfda + .long 0xc578d0a0,0xbde3abb1 + .long 0xb8000000,0x3ff4ce41 + .long 0x4178a5a4,0x3df7c114 + .long 0x9a000000,0x3ff4dcb2 + .long 0xe2648873,0xbdc11794 + .long 0x81e00000,0x3ff4eb2d + .long 0x5257d2e6,0xbddd5005 + .long 0x76a00000,0x3ff4f9b2 + .long 0x96613a4b,0xbdc69aca + .long 0x7f400000,0x3ff50841 + .long 0x68926d27,0x3dd4c7b8 + .long 0xa2c00000,0x3ff516da + .long 0x8225ea59,0x3deecc83 + .long 0xe8400000,0x3ff5257d + .long 0x9331a87e,0xbda62223 + .long 0x56a00000,0x3ff5342b + .long 0x07abe1db,0xbdc583f1 + .long 0xf4e00000,0x3ff542e2 + .long 0x2f24da32,0x3df6ad27 + .long 0xca600000,0x3ff551a4 + .long 0xd689ceff,0xbdc36f89 + .long 0xde000000,0x3ff56070 + .long 0x43edb85a,0xbdf6ef2e + .long 0x36800000,0x3ff56f47 + .long 0x33765802,0x3e0a93ed + .long 0xdbc00000,0x3ff57e27 + .long 0x5e8ce6eb,0x3e016267 + .long 0xd4800000,0x3ff58d12 + .long 0x252bc2b7,0x3df7c7fd + .long 0x28000000,0x3ff59c08 + .long 0xf1677234,0xbdaf068b + .long 0xdd400000,0x3ff5ab07 + .long 0xb192602a,0x3de0a852 + .long 0xfb800000,0x3ff5ba11 + .long 0x4910bd68,0x3e043d01 + .long 0x8a400000,0x3ff5c926 + .long 0x01c4b1b8,0x3df946b7 + .long 0x90800000,0x3ff5d845 + .long 0x8ca5615d,0x3df98b92 + .long 0x15800000,0x3ff5e76f + .long 0x374df261,0x3e0690a4 + .long 0x20c00000,0x3ff5f6a3 + .long 0xcc2a4438,0x3dfceb70 + .long 0xb9800000,0x3ff605e1 + .long 0x9f1214db,0xbde247ee + .long 0xe6c00000,0x3ff6152a + .long 0xf259f256,0x3debede8 + .long 0xb0400000,0x3ff6247e + .long 0x383c17e4,0xbdd6a9ed + .long 0x1d000000,0x3ff633dd + .long 0x611c42fb,0x3df929fd + .long 0x34c00000,0x3ff64346 + .long 0x8edf0e2a,0x3de9863f + .long 0xfec00000,0x3ff652b9 + .long 0x5c7ab935,0xbdcb824b + .long 0x82400000,0x3ff66238 + .long 0x9127d9e3,0x3df52224 + .long 0xc7000000,0x3ff671c1 + .long 0x85e3369e,0x3de067eb + .long 0xd4400000,0x3ff68155 + .long 0x1038ae45,0x3de952e6 + .long 0xb1c00000,0x3ff690f4 + .long 0xe7fb4265,0xbe00b563 + .long 0x66800000,0x3ff6a09e + .long 0xee9a09d9,0xbda8866d + .type __libm_expl_table_256,@object + .size __libm_expl_table_256,4112 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/expm1_gen.S b/external/sgx_libm/intel64/expm1_gen.S new file mode 100644 index 0000000000..bc4160aadc --- /dev/null +++ b/external/sgx_libm/intel64/expm1_gen.S @@ -0,0 +1,387 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expm1_gen.c" + .text +..TXTST0: +# -- Begin expm1 + .text + .align 16,0x90 + .globl expm1 +expm1: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_expm1.1: +..L2: + + lea _range(%rip), %rsi + movsd %xmm0, -24(%rsp) + movl -20(%rsp), %edx + movl %edx, %eax + shrl $31, %edx + andl $2147483647, %eax + cmpl 4(%rsi,%rdx,8), %eax + jb ..B1.4 +..B1.2: + jne ..B1.20 +..B1.3: + movl -24(%rsp), %ecx + cmpl (%rsi,%rdx,8), %ecx + ja ..B1.20 +..B1.4: + cmpl $1064304640, %eax + jae ..B1.13 +..B1.5: + cmpl $1012924416, %eax + jae ..B1.12 +..B1.6: + cmpl $1048576, %eax + jb ..B1.8 +..B1.7: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + addsd -24(%rsp), %xmm0 + ret +..B1.8: + movl -24(%rsp), %edx + orl %edx, %eax + je ..B1.10 +..B1.9: + lea _small_value_64(%rip), %rax + movsd -24(%rsp), %xmm0 + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm1 + movsd %xmm1, -16(%rsp) + addsd %xmm1, %xmm0 + ret +..B1.10: + movsd -24(%rsp), %xmm0 +..B1.11: + ret +..B1.12: + movsd -24(%rsp), %xmm0 + movaps %xmm0, %xmm3 + mulsd %xmm0, %xmm3 + movsd .L_2il0floatpacket.4(%rip), %xmm4 + movsd .L_2il0floatpacket.6(%rip), %xmm1 + mulsd %xmm3, %xmm4 + mulsd %xmm3, %xmm1 + addsd .L_2il0floatpacket.5(%rip), %xmm4 + addsd .L_2il0floatpacket.7(%rip), %xmm1 + mulsd %xmm3, %xmm4 + mulsd %xmm0, %xmm1 + movsd .L_2il0floatpacket.8(%rip), %xmm2 + addsd %xmm1, %xmm4 + movsd %xmm3, -8(%rsp) + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm3, %xmm4 + addsd %xmm4, %xmm0 + ret +..B1.13: + movsd -24(%rsp), %xmm1 + lea _TWO_52H(%rip), %rcx + movaps %xmm1, %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd (%rcx), %xmm2 + movsd .L_2il0floatpacket.1(%rip), %xmm3 + addsd %xmm2, %xmm0 + movsd %xmm0, -16(%rsp) + movsd -16(%rsp), %xmm5 + movsd .L_2il0floatpacket.2(%rip), %xmm4 + subsd %xmm2, %xmm5 + mulsd %xmm5, %xmm3 + mulsd %xmm4, %xmm5 + subsd %xmm3, %xmm1 + movaps %xmm1, %xmm8 + movsd .L_2il0floatpacket.9(%rip), %xmm6 + subsd %xmm5, %xmm8 + movsd .L_2il0floatpacket.3(%rip), %xmm7 + movaps %xmm8, %xmm9 + movl -16(%rsp), %esi + movl %esi, %edi + shll $25, %edi + addsd %xmm8, %xmm6 + subsd %xmm8, %xmm1 + movsd %xmm6, -8(%rsp) + subsd %xmm5, %xmm1 + movl $0, -8(%rsp) + addsd %xmm1, %xmm9 + movsd -8(%rsp), %xmm6 + sarl $25, %edi + addsd %xmm6, %xmm7 + subl %edi, %esi + subsd %xmm7, %xmm8 + movslq %edi, %rdi + addsd %xmm8, %xmm1 + shrl $7, %esi + shlq $4, %rdi + movq __libm_exp_table_128@GOTPCREL(%rip), %r8 + cmpl $1078204908, -20(%rsp) + jle ..B1.15 +..B1.14: + movaps %xmm9, %xmm3 + lea SC2_BIAS(%rip), %rax + movsd .L_2il0floatpacket.4(%rip), %xmm4 + movsd .L_2il0floatpacket.6(%rip), %xmm0 + movsd .L_2il0floatpacket.8(%rip), %xmm2 + mulsd %xmm9, %xmm3 + mulsd %xmm3, %xmm4 + mulsd %xmm3, %xmm0 + addsd .L_2il0floatpacket.5(%rip), %xmm4 + addsd .L_2il0floatpacket.7(%rip), %xmm0 + mulsd %xmm3, %xmm4 + mulsd %xmm9, %xmm0 + movsd 1032(%r8,%rdi), %xmm5 + addsd %xmm0, %xmm4 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm3 + movslq (%rax,%rdx,4), %rcx + addsd %xmm3, %xmm4 + addq %rsi, %rcx + addsd %xmm4, %xmm1 + movaps %xmm1, %xmm0 + addsd %xmm6, %xmm1 + mulsd %xmm5, %xmm0 + mulsd %xmm6, %xmm5 + mulsd 1024(%r8,%rdi), %xmm1 + shlq $52, %rcx + addsd %xmm1, %xmm0 + movq %rcx, -24(%rsp) + addsd %xmm5, %xmm0 + mulsd -24(%rsp), %xmm0 + lea _SC2(%rip), %rsi + mulsd (%rsi,%rdx,8), %xmm0 + ret +..B1.15: + movaps %xmm9, %xmm3 + movq $0x3ff0000000000000, %rdx + mulsd %xmm9, %xmm3 + addl $-1078081678, %eax + movsd .L_2il0floatpacket.4(%rip), %xmm4 + movsd .L_2il0floatpacket.6(%rip), %xmm0 + mulsd %xmm3, %xmm4 + mulsd %xmm3, %xmm0 + addsd .L_2il0floatpacket.5(%rip), %xmm4 + addsd .L_2il0floatpacket.7(%rip), %xmm0 + mulsd %xmm3, %xmm4 + mulsd %xmm9, %xmm0 + movsd .L_2il0floatpacket.8(%rip), %xmm2 + addsd %xmm0, %xmm4 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm3 + movsd 1032(%r8,%rdi), %xmm5 + addsd %xmm3, %xmm4 + shlq $52, %rsi + addsd %xmm4, %xmm1 + movaps %xmm1, %xmm0 + addq %rdx, %rsi + mulsd %xmm5, %xmm0 + addsd %xmm6, %xmm1 + mulsd %xmm6, %xmm5 + mulsd 1024(%r8,%rdi), %xmm1 + movq %rsi, -24(%rsp) + cmpl $216675, %eax + addsd %xmm1, %xmm0 + movsd -24(%rsp), %xmm1 + mulsd %xmm1, %xmm5 + mulsd %xmm1, %xmm0 + ja ..B1.17 +..B1.16: + movsd .L_2il0floatpacket.9(%rip), %xmm1 + subsd %xmm1, %xmm0 + jmp ..B1.18 +..B1.17: + movsd .L_2il0floatpacket.9(%rip), %xmm1 + movaps %xmm5, %xmm2 + movaps %xmm1, %xmm3 + subsd %xmm1, %xmm5 + movsd %xmm5, -8(%rsp) + addsd %xmm5, %xmm3 + subsd %xmm2, %xmm3 + subsd %xmm3, %xmm0 +..B1.18: + addsd %xmm5, %xmm0 +..B1.19: + ret +..B1.20: + cmpl $2146435072, %eax + jae ..B1.24 +..B1.21: + testq %rdx, %rdx + je ..B1.28 +..B1.22: + lea _small_value_64(%rip), %rax + movsd .L_2il0floatpacket.3(%rip), %xmm0 + addsd (%rax), %xmm0 +..B1.23: + ret +..B1.24: + addl $-2146435072, %eax + orl -24(%rsp), %eax + jne ..B1.26 +..B1.25: + lea _inf_none(%rip), %rax + movsd (%rax,%rdx,8), %xmm0 + ret +..B1.26: + movsd -24(%rsp), %xmm0 +..B1.27: + ret +..B1.28: + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type expm1,@function + .size expm1,.-expm1 + .data +# -- End expm1 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 4 +_range: + .long 4277811695 + .long 1082535490 + .long 2669343409 + .long 1078159482 + .type _range,@object + .size _range,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +SC2_BIAS: + .long 511 + .long 1535 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_SC2: + .long 0 + .long 1609564160 + .long 0 + .long 535822336 + .type _SC2,@object + .size _SC2,16 + .align 4 +_inf_none: + .long 0 + .long 2146435072 + .long 0 + .long 3220176896 + .type _inf_none,@object + .size _inf_none,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/expm1f_gen.S b/external/sgx_libm/intel64/expm1f_gen.S new file mode 100644 index 0000000000..dabc16b0b7 --- /dev/null +++ b/external/sgx_libm/intel64/expm1f_gen.S @@ -0,0 +1,348 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expm1f_gen.c" + .text +..TXTST0: +# -- Begin expm1f + .text + .align 16,0x90 + .globl expm1f +expm1f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_expm1f.1: +..L2: + + movd %xmm0, %eax + movss %xmm0, -8(%rsp) + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $1118652779, %ecx + jae ..B1.12 +..B1.2: + cmpl $1040187392, %ecx + jae ..B1.11 +..B1.3: + cmpl $838860800, %ecx + jae ..B1.10 +..B1.4: + cmpl $8388608, %ecx + jb ..B1.6 +..B1.5: + movss .L_2il0floatpacket.15(%rip), %xmm1 + mulss %xmm1, %xmm1 + addss %xmm1, %xmm0 + ret +..B1.6: + testl %ecx, %ecx + je ..B1.8 +..B1.7: + movss .L_2il0floatpacket.15(%rip), %xmm0 + pxor %xmm2, %xmm2 + mulss %xmm0, %xmm0 + pxor %xmm1, %xmm1 + cvtss2sd -8(%rsp), %xmm2 + cvtss2sd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm1 + addsd %xmm0, %xmm2 + pxor %xmm0, %xmm0 + movss %xmm1, -16(%rsp) + cvtsd2ss %xmm2, %xmm0 + ret +..B1.8: + movss -8(%rsp), %xmm0 +..B1.9: + ret +..B1.10: + movss -8(%rsp), %xmm1 + movaps %xmm1, %xmm0 + mulss %xmm1, %xmm0 + cvtss2sd %xmm1, %xmm1 + cvtss2sd %xmm0, %xmm0 + movsd .L_2il0floatpacket.9(%rip), %xmm3 + mulsd %xmm0, %xmm3 + movsd .L_2il0floatpacket.12(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.10(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.13(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.11(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd .L_2il0floatpacket.14(%rip), %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm0, %xmm2 + addsd %xmm2, %xmm3 + addsd %xmm1, %xmm3 + cvtsd2ss %xmm3, %xmm3 + movaps %xmm3, %xmm0 + ret +..B1.11: + pxor %xmm3, %xmm3 + pxor %xmm6, %xmm6 + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movq __libm_expf_table_64@GOTPCREL(%rip), %rcx + addsd .L_2il0floatpacket.1(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm0 + movl -16(%rsp), %edx + movl %edx, %eax + shll $26, %eax + subss .L_2il0floatpacket.2(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + sarl $26, %eax + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm3, %xmm4 + movslq %eax, %rax + addsd %xmm4, %xmm0 + movsd 256(%rcx,%rax,8), %xmm5 + subl %eax, %edx + mulsd %xmm5, %xmm0 + shrl $6, %edx + addsd %xmm5, %xmm0 + shll $23, %edx + addl $1065353216, %edx + movl %edx, -24(%rsp) + cvtss2sd -24(%rsp), %xmm6 + mulsd %xmm6, %xmm0 + addsd .L_2il0floatpacket.8(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.12: + lea range(%rip), %rdx + shrl $31, %eax + cmpl (%rdx,%rax,4), %ecx + jb ..B1.21 +..B1.13: + cmpl $2139095040, %ecx + jae ..B1.17 +..B1.14: + testq %rax, %rax + je ..B1.22 +..B1.15: + movss .L_2il0floatpacket.16(%rip), %xmm0 +..B1.16: + ret +..B1.17: + jne ..B1.19 +..B1.18: + lea _inf_none(%rip), %rdx + movss (%rdx,%rax,4), %xmm0 + ret +..B1.19: + movss -8(%rsp), %xmm0 +..B1.20: + ret +..B1.21: + pxor %xmm3, %xmm3 + movq $0x3ff0000000000000, %rcx + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movq __libm_expf_table_64@GOTPCREL(%rip), %rsi + addsd .L_2il0floatpacket.1(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm0 + movl -16(%rsp), %edx + andl $4194303, %edx + subss .L_2il0floatpacket.2(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + movl %edx, %eax + shll $26, %eax + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm3, %xmm4 + sarl $26, %eax + addsd %xmm4, %xmm0 + movslq %eax, %rax + subl %eax, %edx + shrl $6, %edx + movsd 256(%rsi,%rax,8), %xmm5 + mulsd %xmm5, %xmm0 + shlq $52, %rdx + addsd %xmm5, %xmm0 + addq %rcx, %rdx + movq %rdx, -24(%rsp) + mulsd -24(%rsp), %xmm0 + addsd .L_2il0floatpacket.8(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.22: + movss .L_2il0floatpacket.17(%rip), %xmm0 + mulss %xmm0, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type expm1f,@function + .size expm1f,.-expm1f + .data +# -- End expm1f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40571547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x41680000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.3: + .long 0xfefa39ef,0xbf862e42 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xeb78fa85,0x3fa56420 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x008d6118,0x3fe00000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xda752d4f,0x3fc55550 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0xffffe7c6,0x3fefffff + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0xd2809cf8,0x3f2a04e1 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0xeb5ecfe9,0x3f811110 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x55579a3a,0x3fc55555 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x9843cb2c,0x3f56c445 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x27a9b288,0x3fa55555 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0x00016df6,0x3fe00000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 4 +.L_2il0floatpacket.2: + .long 0x4b400000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.15: + .long 0x0d800000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,4 + .align 4 +.L_2il0floatpacket.16: + .long 0xbf800000 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,4 + .align 4 +.L_2il0floatpacket.17: + .long 0x71800000 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,4 + .align 4 +range: + .long 1118925336 + .long 1107296256 + .type range,@object + .size range,8 + .align 4 +_inf_none: + .long 2139095040 + .long 3212836864 + .type _inf_none,@object + .size _inf_none,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/expm1l.S b/external/sgx_libm/intel64/expm1l.S new file mode 100644 index 0000000000..c56ed2c280 --- /dev/null +++ b/external/sgx_libm/intel64/expm1l.S @@ -0,0 +1,1156 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "expm1l.c" + .text +..TXTST0: +# -- Begin expm1l + .text + .align 16,0x90 + .globl expm1l +expm1l: +# parameter 1: 160 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_expm1l.1: +..L2: + + subq $152, %rsp + .cfi_def_cfa_offset 160 + xorb %dil, %dil +..B1.2: + fnstcw 146(%rsp) +..B1.3: + movb 169(%rsp), %cl + lea _ranges(%rip), %r8 + andb $-128, %cl + shrb $7, %cl + movzbl %cl, %esi + movq %rsi, %rdx + shlq $4, %rdx + movzwl 168(%rsp), %ecx + andl $32767, %ecx + movzwl 8(%rdx,%r8), %eax + andl $32767, %eax + cmpl %eax, %ecx + jl ..B1.8 +..B1.4: + jne ..B1.63 +..B1.5: + movl 164(%rsp), %eax + cmpl 4(%rdx,%r8), %eax + jb ..B1.8 +..B1.6: + jne ..B1.63 +..B1.7: + movl 160(%rsp), %eax + cmpl (%rdx,%r8), %eax + jae ..B1.63 +..B1.8: + cmpl $16381, %ecx + jge ..B1.49 +..B1.9: + movzwl 146(%rsp), %edx + cmpl $16370, %ecx + jge ..B1.42 +..B1.10: + cmpl $16359, %ecx + jge ..B1.35 +..B1.11: + cmpl $16345, %ecx + jge ..B1.28 +..B1.12: + cmpl $16308, %ecx + jge ..B1.22 +..B1.13: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.17 +..B1.14: + orl $-64768, %edx + movw %dx, 144(%rsp) +..B1.15: + fldcw 144(%rsp) +..B1.16: + movzwl 168(%rsp), %ecx + movb $1, %dil + andl $32767, %ecx +..B1.17: + testl %ecx, %ecx + jle ..B1.73 +..B1.18: + fldt 160(%rsp) + lea _TWO_75(%rip), %rax + lea ones(%rip), %rdx + lea 8+_TWO_75(%rip), %rcx + fldl (%rax) + fmul %st(1), %st + fxch %st(1) + fmull (%rdx,%rsi,8) + faddp %st, %st(1) + fmull (%rcx) + fstpt 16(%rsp) +..B1.19: + testb %dil, %dil + je ..B1.21 +..B1.20: + fldcw 146(%rsp) +..B1.21: + fldt 16(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.22: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.77 +..B1.23: + orl $-64768, %edx + movw %dx, 144(%rsp) +..B1.24: + fldcw 144(%rsp) +..B1.25: + fldt 160(%rsp) + lea _Q3(%rip), %rax + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.26: + fldcw 146(%rsp) +..B1.27: + fldt 16(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.28: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.32 +..B1.29: + orl $-64768, %edx + movw %dx, 144(%rsp) +..B1.30: + fldcw 144(%rsp) +..B1.31: + movb $1, %dil +..B1.32: + fldt 160(%rsp) + lea 16+_Q2(%rip), %rax + lea _Q2(%rip), %rdx + testb %dil, %dil + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fldt (%rdx) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.34 +..B1.33: + fldcw 146(%rsp) +..B1.34: + fldt 16(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.35: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.39 +..B1.36: + orl $-64768, %edx + movw %dx, 144(%rsp) +..B1.37: + fldcw 144(%rsp) +..B1.38: + movb $1, %dil +..B1.39: + fldt 160(%rsp) + lea 48+_Q1(%rip), %rax + fld %st(0) + lea 32+_Q1(%rip), %rcx + fmul %st(1), %st + lea 16+_Q1(%rip), %rdx + fldt (%rax) + lea _Q1(%rip), %rsi + fmul %st(1), %st + testb %dil, %dil + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + fmulp %st, %st(2) + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.41 +..B1.40: + fldcw 146(%rsp) +..B1.41: + fldt 16(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.42: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.46 +..B1.43: + orl $-64768, %edx + movw %dx, 144(%rsp) +..B1.44: + fldcw 144(%rsp) +..B1.45: + movb $1, %dil +..B1.46: + fldt 160(%rsp) + lea _TWO_54H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea 208+_Q(%rip), %r8 + lea 240+_Q(%rip), %rcx + lea 176+_Q(%rip), %r9 + fld %st(3) + lea 224+_Q(%rip), %rsi + fldl (%rax) + lea 144+_Q(%rip), %r10 + fmul %st(5), %st + lea 112+_Q(%rip), %r11 + lea 80+_Q(%rip), %rax + lea 256+_Q(%rip), %rdx + testb %dil, %dil + fadd %st, %st(4) + fxch %st(4) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(4) + fld %st(3) + fld %st(4) + fmul %st(5), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(4) + fsub %st(5), %st + fmul %st, %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fadd %st(4), %st + fxch %st(5) + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fstpt 96(%rsp) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt (%rdx) + lea 48+_Q(%rip), %rdx + fmul %st, %st(2) + fldt (%rcx) + lea 16+_Q(%rip), %rcx + fstpt 112(%rsp) + fldt (%rsi) + lea 192+_Q(%rip), %rsi + fstpt 128(%rsp) + fldt (%r8) + lea 160+_Q(%rip), %r8 + fmul %st(4), %st + fldt (%r9) + lea 128+_Q(%rip), %r9 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r10) + lea 96+_Q(%rip), %r10 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r11) + lea 64+_Q(%rip), %r11 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rax) + lea 32+_Q(%rip), %rax + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rdx) + lea _Q(%rip), %rdx + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rsi) + fmul %st(5), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt (%rdx) + faddp %st, %st(5) + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldt 112(%rsp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldt 128(%rsp) + fld %st(0) + fldt 64(%rsp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(5) + fxch %st(4) + fmul %st(5), %st + fldt 96(%rsp) + fmulp %st, %st(4) + fldt 80(%rsp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt 48(%rsp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmul %st(2), %st + fxch %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(3) + fxch %st(3) + fstpt 160(%rsp) + fldt 160(%rsp) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + je ..B1.48 +..B1.47: + fldt 16(%rsp) + fstpt 48(%rsp) +..B1.85: + fldcw 146(%rsp) +..B1.48: + fldt 32(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.49: + movzwl 146(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.53 +..B1.50: + orl $-64768, %edx + movw %dx, 144(%rsp) +..B1.51: + fldcw 144(%rsp) +..B1.52: + movzwl 168(%rsp), %ecx + movb $1, %dil + andl $32767, %ecx +..B1.53: + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %rax + fstpt 32(%rsp) + lea _TWO_32H(%rip), %r8 + fldt 160(%rsp) + cmpl $16396, %ecx + fldt .L_2il0floatpacket.1(%rip) + fmul %st(1), %st + fldl (%rax) + movzwl 8+.L_2il0floatpacket.0(%rip), %r9d + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fsubp %st, %st(1) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(1), %st + movl 48(%rsp), %eax + fsubrp %st, %st(2) + fld %st(1) + fldt .L_2il0floatpacket.3(%rip) + fmulp %st, %st(2) + movsbq %al, %rdx + fsub %st(1), %st + fldl (%r8) + fadd %st, %st(1) + fsubr %st(1), %st + fsubr %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + jge ..B1.60 +..B1.54: + fld %st(1) + subl %edx, %eax + shrl $8, %eax + andl $-32768, %r9d + addl $16383, %eax + lea 32+_P(%rip), %r8 + andl $32767, %eax + lea 48+_P(%rip), %r10 + orl %eax, %r9d + lea 64+_P(%rip), %rax + movw %r9w, 40(%rsp) + lea _P(%rip), %r9 + lea 16+_P(%rip), %r11 + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fldt (%rax) + fmul %st(1), %st + fldt (%r8) + shlq $4, %rdx + faddp %st, %st(1) + fmul %st(1), %st + testq %rsi, %rsi + fldt (%r9) + movq __libm_expl_table_256@GOTPCREL(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(3) + fldl 2048(%rax,%rdx) + fld %st(0) + fmul %st(4), %st + fxch %st(3) + fadd %st, %st(4) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(4) + fmull 2056(%rax,%rdx) + faddp %st, %st(3) + fldt 32(%rsp) + fmul %st, %st(4) + fxch %st(1) + faddl 2056(%rax,%rdx) + faddp %st, %st(3) + fmulp %st, %st(2) + je ..B1.56 +..B1.55: + fldt .L_2il0floatpacket.4(%rip) + fadd %st(3), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fldt .L_2il0floatpacket.0(%rip) + faddp %st, %st(1) + fsubp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + jmp ..B1.57 +..B1.56: + movzbl 169(%rsp), %edx + xorl %esi, %esi + shrl $7, %edx + lea zero_one(%rip), %r8 + shll $15, %edx + orl %ecx, %edx + shll $16, %edx + movzwl 166(%rsp), %eax + orl %eax, %edx + cmpl $1074049228, %edx + setb %sil + fldl (%r8,%rsi,8) + xorl $1, %esi + fsubrp %st, %st(3) + fxch %st(2) + fstpt 16(%rsp) + fsubl (%r8,%rsi,8) +..B1.57: + fldt 16(%rsp) + testb %dil, %dil + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.88 +..B1.58: + fstpt 48(%rsp) +..B1.86: + fldcw 146(%rsp) + jmp ..B1.59 +..B1.88: + fstp %st(0) +..B1.59: + fldt 16(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.60: + fld %st(1) + subl %edx, %eax + shrl $8, %eax + lea 32+_P(%rip), %rsi + addl $8191, %eax + lea _P(%rip), %r8 + movzwl 40(%rsp), %ecx + andl $32767, %eax + andl $-32768, %ecx + lea 48+_P(%rip), %r9 + orl %eax, %ecx + lea 64+_P(%rip), %rax + lea 16+_P(%rip), %r10 + fadd %st(3), %st + fld %st(0) + fmul %st(1), %st + fldt (%rax) + lea _SC2(%rip), %rax + fmul %st(1), %st + fldt (%rsi) + shlq $4, %rdx + faddp %st, %st(1) + fmul %st(1), %st + testb %dil, %dil + fldt (%r8) + movq __libm_expl_table_256@GOTPCREL(%rip), %r11 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + fmul %st(2), %st + fldt (%r10) + movw %cx, 40(%rsp) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(3) + fldl 2056(%r11,%rdx) + fldl 2048(%r11,%rdx) + fld %st(0) + fmul %st(5), %st + fxch %st(4) + fadd %st, %st(5) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) + fstpt 16(%rsp) + je ..B1.89 +..B1.61: + fstpt 48(%rsp) +..B1.87: + fldcw 146(%rsp) + jmp ..B1.62 +..B1.89: + fstp %st(0) +..B1.62: + fldt 16(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.63: + movzwl 146(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.67 +..B1.64: + orl $-64768, %edx + movw %dx, 144(%rsp) +..B1.65: + fldcw 144(%rsp) +..B1.66: + movzwl 168(%rsp), %ecx + movb $1, %dil + andl $32767, %ecx +..B1.67: + cmpl $32767, %ecx + je ..B1.79 +..B1.68: + testq %rsi, %rsi + je ..B1.78 +..B1.69: + fldt .L_2il0floatpacket.4(%rip) + lea _small_value_80(%rip), %rax + fldt (%rax) + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.70: + testb %dil, %dil + je ..B1.72 +..B1.71: + fldcw 146(%rsp) +..B1.72: + fldt 16(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 +..B1.73: + cmpl $0, 164(%rsp) + jne ..B1.75 +..B1.74: + cmpl $0, 160(%rsp) + je ..B1.76 +..B1.75: + fldt 160(%rsp) + lea _TWO_75(%rip), %rdx + lea ones(%rip), %rcx + lea _small_value_80(%rip), %rax + fldl (%rdx) + fmul %st(1), %st + fxch %st(1) + fmull (%rcx,%rsi,8) + lea 8+_TWO_75(%rip), %rsi + faddp %st, %st(1) + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + fmull (%rsi) + fstpt 16(%rsp) + jmp ..B1.19 +..B1.76: + fldt 160(%rsp) + fstpt 16(%rsp) + jmp ..B1.19 +..B1.77: + fldt 160(%rsp) + lea _Q3(%rip), %rax + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.27 +..B1.78: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 16(%rsp) + jmp ..B1.70 +..B1.79: + cmpl $-2147483648, 164(%rsp) + jne ..B1.82 +..B1.80: + cmpl $0, 160(%rsp) + jne ..B1.82 +..B1.81: + lea _inf_none(%rip), %rax + fldl (%rax,%rsi,8) + fstpt 16(%rsp) + jmp ..B1.70 +..B1.82: + fldt 160(%rsp) + fstpt 16(%rsp) + jmp ..B1.70 + .align 16,0x90 + .cfi_endproc + .type expm1l,@function + .size expm1l,.-expm1l + .data +# -- End expm1l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +zero_one: + .long 0x00000000,0x00000000 + .long 0x00000000,0x3ff00000 + .type zero_one,@object + .size zero_one,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_54H: + .long 0 + .long 1129840640 + .type _TWO_54H,@object + .size _TWO_54H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_inf_none: + .long 0 + .long 2146435072 + .long 0 + .long 3220176896 + .type _inf_none,@object + .size _inf_none,16 + .align 2 +_ranges: + .word 31148 + .word 53711 + .word 6135 + .word 45426 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16389 + .word 0 + .word 0 + .word 0 + .type _ranges,@object + .size _ranges,32 + .align 2 +_Q3: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 2731 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 46967 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 65530 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 43687 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 52365 + .word 52428 + .word 43692 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56491 + .word 10318 + .word 34954 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 39683 + .word 36691 + .word 42743 + .word 55145 + .word 16297 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 43690 + .word 43690 + .word 43690 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 46686 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 53372 + .word 3328 + .word 208 + .word 53261 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 5395 + .word 3321 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 7401 + .word 46642 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 52768 + .word 7506 + .word 32188 + .word 37874 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 23003 + .word 12485 + .word 11072 + .word 55090 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 3702 + .word 18929 + .word 50035 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 2630 + .word 23096 + .word 11140 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 46660 + .word 62794 + .word 49270 + .word 51706 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 61237 + .word 7998 + .word 19059 + .word 55154 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43648 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43648 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,272 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_SC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .type _SC2,@object + .size _SC2,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fabs.S b/external/sgx_libm/intel64/fabs.S new file mode 100644 index 0000000000..e285d5fceb --- /dev/null +++ b/external/sgx_libm/intel64/fabs.S @@ -0,0 +1,85 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fabs.c" + .text +..TXTST0: +# -- Begin fabs + .text + .align 16,0x90 + .globl fabs +fabs: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_fabs.1: +..L2: + +..B1.2: + movq MASK(%rip), %xmm1 + movq ONE(%rip), %xmm2 + andpd %xmm1, %xmm0 + mulsd %xmm2, %xmm0 + ret +..B1.3: + .align 16,0x90 + .cfi_endproc + .type fabs,@function + .size fabs,.-fabs + .data +# -- End fabs + .section .rodata, "a" + .align 16 + .align 16 +MASK: + .long 4294967295 + .long 2147483647 + .type MASK,@object + .size MASK,8 + .space 8, 0x00 # pad + .align 16 +ONE: + .long 0 + .long 1072693248 + .type ONE,@object + .size ONE,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fabsf.S b/external/sgx_libm/intel64/fabsf.S new file mode 100644 index 0000000000..9c6b491937 --- /dev/null +++ b/external/sgx_libm/intel64/fabsf.S @@ -0,0 +1,82 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fabsf.c" + .text +..TXTST0: +# -- Begin fabsf + .text + .align 16,0x90 + .globl fabsf +fabsf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_fabsf.1: +..L2: + +..B1.2: + movd MASK(%rip), %xmm1 + movd ONE(%rip), %xmm2 + andps %xmm1, %xmm0 + mulss %xmm2, %xmm0 + ret +..B1.3: + .align 16,0x90 + .cfi_endproc + .type fabsf,@function + .size fabsf,.-fabsf + .data +# -- End fabsf + .section .rodata, "a" + .align 16 + .align 16 +MASK: + .long 2147483647 + .type MASK,@object + .size MASK,4 + .align 4 +ONE: + .long 1065353216 + .type ONE,@object + .size ONE,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fabsl.S b/external/sgx_libm/intel64/fabsl.S new file mode 100644 index 0000000000..4a4614c636 --- /dev/null +++ b/external/sgx_libm/intel64/fabsl.S @@ -0,0 +1,127 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fabsl.c" + .text +..TXTST0: +# -- Begin fabsl + .text + .align 16,0x90 + .globl fabsl +fabsl: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_fabsl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + xorb %sil, %sil +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.5: + fldcw 16(%rsp) +..B1.6: + movb $1, %sil +..B1.7: + movzwl 40(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.12 +..B1.8: + fldt 32(%rsp) + lea ones(%rip), %rdx + movb 41(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fmull (%rdx,%rcx,8) + fstpt (%rsp) +..B1.9: + testb %sil, %sil + je ..B1.11 +..B1.10: + fldcw 18(%rsp) +..B1.11: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.12: + cmpl $-2147483648, 36(%rsp) + jne ..B1.14 +..B1.13: + cmpl $0, 32(%rsp) + je ..B1.8 +..B1.14: + fldt 32(%rsp) + movb 41(%rsp), %al + fstpt (%rsp) + andb $127, %al + movb %al, 9(%rsp) + jmp ..B1.9 + .align 16,0x90 + .cfi_endproc + .type fabsl,@function + .size fabsl,.-fabsl + .data +# -- End fabsl + .section .rodata, "a" + .align 8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fdim_gen.S b/external/sgx_libm/intel64/fdim_gen.S new file mode 100644 index 0000000000..edab127872 --- /dev/null +++ b/external/sgx_libm/intel64/fdim_gen.S @@ -0,0 +1,148 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fdim_gen.c" + .text +..TXTST0: +# -- Begin fdim + .text + .align 16,0x90 + .globl fdim +fdim: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fdim.1: +..L2: + + movsd %xmm0, -16(%rsp) + movsd %xmm1, -8(%rsp) + movzwl -10(%rsp), %edx + andl $32752, %edx + movzwl -2(%rsp), %eax + andl $32752, %eax + shrl $4, %edx + shrl $4, %eax + cmpl $2047, %edx + je ..B1.14 +..B1.2: + cmpl $2047, %eax + je ..B1.11 +..B1.3: + movsd -16(%rsp), %xmm0 + movsd -8(%rsp), %xmm2 + comisd %xmm2, %xmm0 + jbe ..B1.10 +..B1.4: + cmpl $2047, %edx + je ..B1.8 +..B1.5: + cmpl $2047, %eax + je ..B1.8 +..B1.6: + cmpl $2046, %edx + je ..B1.9 +..B1.7: + cmpl $2046, %eax + je ..B1.9 +..B1.8: + subsd %xmm2, %xmm0 + ret +..B1.9: + movsd .L_2il0floatpacket.0(%rip), %xmm1 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm2 + subsd %xmm2, %xmm0 + movsd %xmm0, -24(%rsp) + movsd -24(%rsp), %xmm0 + mulsd .L_2il0floatpacket.1(%rip), %xmm0 + ret +..B1.10: + lea _zeros(%rip), %rax + movsd (%rax), %xmm0 + ret +..B1.11: + testl $1048575, -4(%rsp) + jne ..B1.13 +..B1.12: + cmpl $0, -8(%rsp) + je ..B1.3 +..B1.13: + movsd -8(%rsp), %xmm0 + ret +..B1.14: + testl $1048575, -12(%rsp) + jne ..B1.16 +..B1.15: + cmpl $0, -16(%rsp) + je ..B1.2 +..B1.16: + movsd -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type fdim,@function + .size fdim,.-fdim + .data +# -- End fdim + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fdimf_gen.S b/external/sgx_libm/intel64/fdimf_gen.S new file mode 100644 index 0000000000..f352c8467e --- /dev/null +++ b/external/sgx_libm/intel64/fdimf_gen.S @@ -0,0 +1,133 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fdimf_gen.c" + .text +..TXTST0: +# -- Begin fdimf + .text + .align 16,0x90 + .globl fdimf +fdimf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fdimf.1: +..L2: + + movss %xmm0, -16(%rsp) + movss %xmm1, -8(%rsp) + movzwl -14(%rsp), %edx + andl $32640, %edx + movzwl -6(%rsp), %eax + andl $32640, %eax + shrl $7, %edx + shrl $7, %eax + cmpl $255, %edx + je ..B1.13 +..B1.2: + cmpl $255, %eax + je ..B1.11 +..B1.3: + movss -16(%rsp), %xmm0 + movss -8(%rsp), %xmm2 + comiss %xmm2, %xmm0 + jbe ..B1.10 +..B1.4: + cmpl $255, %edx + je ..B1.8 +..B1.5: + cmpl $255, %eax + je ..B1.8 +..B1.6: + cmpl $254, %edx + je ..B1.9 +..B1.7: + cmpl $254, %eax + je ..B1.9 +..B1.8: + subss %xmm2, %xmm0 + ret +..B1.9: + movss .L_2il0floatpacket.0(%rip), %xmm1 + mulss %xmm1, %xmm0 + mulss %xmm1, %xmm2 + subss %xmm2, %xmm0 + movss %xmm0, -24(%rsp) + movss -24(%rsp), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + ret +..B1.10: + pxor %xmm0, %xmm0 + ret +..B1.11: + testl $8388607, -8(%rsp) + je ..B1.3 +..B1.12: + movss -8(%rsp), %xmm0 + ret +..B1.13: + testl $8388607, -16(%rsp) + je ..B1.2 +..B1.14: + movss -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type fdimf,@function + .size fdimf,.-fdimf + .data +# -- End fdimf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x3f000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x40000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fdiml.S b/external/sgx_libm/intel64/fdiml.S new file mode 100644 index 0000000000..da480d2d04 --- /dev/null +++ b/external/sgx_libm/intel64/fdiml.S @@ -0,0 +1,291 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fdiml.c" + .text +..TXTST0: +# -- Begin fdiml + .text + .align 16,0x90 + .globl fdiml +fdiml: +# parameter 1: 32 + %rsp +# parameter 2: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_fdiml.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + xorb %al, %al +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 40(%rsp), %edi + andl $32767, %edi + movzwl 56(%rsp), %esi + andl $32767, %esi + cmpl $32767, %edi + je ..B1.38 +..B1.4: + cmpl $32767, %esi + je ..B1.29 +..B1.5: + movzwl 18(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.9 +..B1.6: + orl $-64768, %ecx + movw %cx, 16(%rsp) +..B1.7: + fldcw 16(%rsp) +..B1.8: + movb $1, %al +..B1.9: + fldt 48(%rsp) + lea _zeros(%rip), %rdx + fldl (%rdx) + fstpt (%rsp) + fldt 32(%rsp) + fcomi %st(1), %st + jbe ..B1.42 +..B1.10: + cmpl $32767, %edi + je ..B1.14 +..B1.11: + cmpl $32767, %esi + je ..B1.14 +..B1.12: + cmpl $32766, %edi + je ..B1.26 +..B1.13: + cmpl $32766, %esi + je ..B1.18 +..B1.14: + fsubp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.42: + fstp %st(0) + fstp %st(0) +..B1.15: + testb %al, %al + je ..B1.17 +..B1.16: + fldcw 18(%rsp) +..B1.17: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.18: + testl %edi, %edi + jne ..B1.22 +..B1.19: + cmpl $0, 36(%rsp) + jne ..B1.21 +..B1.20: + cmpl $0, 32(%rsp) + je ..B1.22 +..B1.21: + lea _ranges(%rip), %rdx + fsubp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rdx) + fucomip %st(1), %st + fstp %st(0) + jne ..B1.15 + jp ..B1.15 + jmp ..B1.24 +..B1.22: + fldt .L_2il0floatpacket.0(%rip) + lea 16+_ranges(%rip), %rdx + fmul %st, %st(1) + fmulp %st, %st(2) + fsubp %st, %st(1) + fldt (%rdx) + fcomip %st(1), %st + jp ..B1.23 + jbe ..B1.25 +..B1.23: + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.24: + lea _large_value_80(%rip), %rdx + fldt (%rdx) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.15 +..B1.25: + fstp %st(0) + lea _large_value_80(%rip), %rdx + fldt (%rdx) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.15 +..B1.26: + testl %esi, %esi + jne ..B1.22 +..B1.27: + cmpl $0, 52(%rsp) + jne ..B1.21 +..B1.28: + cmpl $0, 48(%rsp) + jne ..B1.21 + jmp ..B1.22 +..B1.29: + cmpl $-2147483648, 52(%rsp) + jne ..B1.31 +..B1.30: + cmpl $0, 48(%rsp) + je ..B1.5 +..B1.31: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.37 +..B1.32: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.33: + fldcw 16(%rsp) +..B1.34: + fldt 32(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.35: + fldcw 18(%rsp) +..B1.36: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.37: + fldt 32(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.36 +..B1.38: + cmpl $-2147483648, 36(%rsp) + jne ..B1.31 +..B1.39: + cmpl $0, 32(%rsp) + je ..B1.4 + jmp ..B1.31 + .align 16,0x90 + .cfi_endproc + .type fdiml,@function + .size fdiml,.-fdiml + .data +# -- End fdiml + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_ranges: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .type _ranges,@object + .size _ranges,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/feclearexcept.S b/external/sgx_libm/intel64/feclearexcept.S new file mode 100644 index 0000000000..4d8dec30e9 --- /dev/null +++ b/external/sgx_libm/intel64/feclearexcept.S @@ -0,0 +1,98 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feclearexcept.c" + .text +..TXTST0: +# -- Begin feclearexcept + .text + .align 16,0x90 + .globl feclearexcept +feclearexcept: +# parameter 1: %edi +..B1.1: + .cfi_startproc +..___tag_value_feclearexcept.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 40(%rsp) + andl $63, %edi + je ..B1.9 +..B1.2: + stmxcsr (%rsp) +..B1.3: + notl %edi + andl %edi, (%rsp) +..B1.4: + ldmxcsr (%rsp) +..B1.5: + fnstenv 4(%rsp) +..B1.6: + andw %di, 8(%rsp) +..B1.7: + fnclex +..B1.8: + fldenv 4(%rsp) +..B1.9: + movq 40(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.11 +..B1.10: + xorl %eax, %eax + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.11: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type feclearexcept,@function + .size feclearexcept,.-feclearexcept + .data +# -- End feclearexcept + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fedisableexcept.S b/external/sgx_libm/intel64/fedisableexcept.S new file mode 100644 index 0000000000..90d6b05291 --- /dev/null +++ b/external/sgx_libm/intel64/fedisableexcept.S @@ -0,0 +1,105 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fedisableexcept.c" + .text +..TXTST0: +# -- Begin fedisableexcept + .text + .align 16,0x90 + .globl fedisableexcept +fedisableexcept: +# parameter 1: %edi +..B1.1: + .cfi_startproc +..___tag_value_fedisableexcept.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + andl $63, %edi + xorq %rsp, %rax + movq %rax, 40(%rsp) +..B1.2: + stmxcsr 4(%rsp) +..B1.3: + testl %edi, %edi + je ..B1.10 +..B1.4: + movl %edi, %eax + shll $7, %eax + orl 4(%rsp), %eax + movl %eax, (%rsp) +..B1.5: + fnstenv 8(%rsp) +..B1.6: + orw %di, 8(%rsp) +..B1.7: + fnclex +..B1.8: + fldenv 8(%rsp) +..B1.9: + ldmxcsr (%rsp) +..B1.10: + movl 4(%rsp), %eax + shrl $7, %eax + movq 40(%rsp), %rdx + notl %eax + xorq %rsp, %rdx + andl $63, %eax + cmpq %fs:40, %rdx + jne ..B1.12 +..B1.11: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type fedisableexcept,@function + .size fedisableexcept,.-fedisableexcept + .data +# -- End fedisableexcept + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/feenableexcept.S b/external/sgx_libm/intel64/feenableexcept.S new file mode 100644 index 0000000000..54e7fa2572 --- /dev/null +++ b/external/sgx_libm/intel64/feenableexcept.S @@ -0,0 +1,107 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feenableexcept.c" + .text +..TXTST0: +# -- Begin feenableexcept + .text + .align 16,0x90 + .globl feenableexcept +feenableexcept: +# parameter 1: %edi +..B1.1: + .cfi_startproc +..___tag_value_feenableexcept.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + andl $63, %edi + xorq %rsp, %rax + movq %rax, 40(%rsp) +..B1.2: + stmxcsr 4(%rsp) +..B1.3: + testl %edi, %edi + je ..B1.10 +..B1.4: + movl %edi, %eax + shll $7, %eax + notl %eax + andl 4(%rsp), %eax + movl %eax, (%rsp) +..B1.5: + fnstenv 8(%rsp) +..B1.6: + notl %edi + andw %di, 8(%rsp) +..B1.7: + fnclex +..B1.8: + fldenv 8(%rsp) +..B1.9: + ldmxcsr (%rsp) +..B1.10: + movl 4(%rsp), %eax + shrl $7, %eax + movq 40(%rsp), %rdx + notl %eax + xorq %rsp, %rdx + andl $63, %eax + cmpq %fs:40, %rdx + jne ..B1.12 +..B1.11: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type feenableexcept,@function + .size feenableexcept,.-feenableexcept + .data +# -- End feenableexcept + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fegetexcept.S b/external/sgx_libm/intel64/fegetexcept.S new file mode 100644 index 0000000000..3fa4440273 --- /dev/null +++ b/external/sgx_libm/intel64/fegetexcept.S @@ -0,0 +1,74 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fegetexcept.c" + .text +..TXTST0: +# -- Begin fegetexcept + .text + .align 16,0x90 + .globl fegetexcept +fegetexcept: +..B1.1: + .cfi_startproc +..___tag_value_fegetexcept.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 +..B1.2: + stmxcsr (%rsp) +..B1.3: + movl (%rsp), %eax + shrl $7, %eax + notl %eax + andl $63, %eax + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fegetexcept,@function + .size fegetexcept,.-fegetexcept + .data +# -- End fegetexcept + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fegetexceptflag.S b/external/sgx_libm/intel64/fegetexceptflag.S new file mode 100644 index 0000000000..d5d2bae756 --- /dev/null +++ b/external/sgx_libm/intel64/fegetexceptflag.S @@ -0,0 +1,81 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fegetexceptflag.c" + .text +..TXTST0: +# -- Begin fegetexceptflag + .text + .align 16,0x90 + .globl fegetexceptflag +fegetexceptflag: +# parameter 1: %rdi +# parameter 2: %esi +..B1.1: + .cfi_startproc +..___tag_value_fegetexceptflag.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + andl $63, %esi +..B1.2: + stmxcsr (%rsp) +..B1.3: + fnstsw 4(%rsp) +..B1.4: + movzwl 4(%rsp), %eax + orl (%rsp), %eax + andl %eax, %esi + movl %eax, (%rsp) + xorl %eax, %eax + movw %si, (%rdi) + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fegetexceptflag,@function + .size fegetexceptflag,.-fegetexceptflag + .data +# -- End fegetexceptflag + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fegetround.S b/external/sgx_libm/intel64/fegetround.S new file mode 100644 index 0000000000..8a77f3d6a4 --- /dev/null +++ b/external/sgx_libm/intel64/fegetround.S @@ -0,0 +1,73 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fegetround.c" + .text +..TXTST0: +# -- Begin fegetround + .text + .align 16,0x90 + .globl fegetround +fegetround: +..B1.1: + .cfi_startproc +..___tag_value_fegetround.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 +..B1.2: + stmxcsr (%rsp) +..B1.3: + movl (%rsp), %eax + shrl $3, %eax + andl $3072, %eax + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fegetround,@function + .size fegetround,.-fegetround + .data +# -- End fegetround + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/feholdexcept.S b/external/sgx_libm/intel64/feholdexcept.S new file mode 100644 index 0000000000..0075d09749 --- /dev/null +++ b/external/sgx_libm/intel64/feholdexcept.S @@ -0,0 +1,110 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feholdexcept.c" + .text +..TXTST0: +# -- Begin feholdexcept + .text + .align 16,0x90 + .globl feholdexcept +feholdexcept: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value_feholdexcept.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 40(%rsp) +..B1.2: + fnstenv 4(%rsp) +..B1.3: + movzwl 8(%rsp), %eax + movzwl 4(%rsp), %edx + movw %ax, 4(%rdi) + movw %dx, (%rdi) +..B1.4: + stmxcsr (%rsp) +..B1.5: + movl (%rsp), %eax + movzwl 8(%rsp), %edx + movzwl 4(%rsp), %ecx + andl $-64, %edx + orl $63, %ecx + movl %eax, 28(%rdi) + movw %dx, 8(%rsp) + movw %cx, 4(%rsp) +..B1.6: + fnclex +..B1.7: + fldenv 4(%rsp) +..B1.8: + movl (%rsp), %eax + andl $-64, %eax + orl $8064, %eax + movl %eax, (%rsp) +..B1.9: + ldmxcsr (%rsp) +..B1.10: + movq 40(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.12 +..B1.11: + xorl %eax, %eax + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type feholdexcept,@function + .size feholdexcept,.-feholdexcept + .data +# -- End feholdexcept + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/feraiseexcept.S b/external/sgx_libm/intel64/feraiseexcept.S new file mode 100644 index 0000000000..adc7c2b293 --- /dev/null +++ b/external/sgx_libm/intel64/feraiseexcept.S @@ -0,0 +1,159 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feraiseexcept.c" + .text +..TXTST0: +# -- Begin feraiseexcept + .text + .align 16,0x90 + .globl feraiseexcept +feraiseexcept: +# parameter 1: %edi +..B1.1: + .cfi_startproc +..___tag_value_feraiseexcept.1: +..L2: + + testl $1, %edi + je ..B1.3 +..B1.2: + lea d_zero(%rip), %rax + movsd (%rax), %xmm0 + divsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) +..B1.3: + testl $4, %edi + je ..B1.5 +..B1.4: + movq p_one(%rip), %rax + movq p_zero(%rip), %rdx + movsd (%rax), %xmm0 + divsd (%rdx), %xmm0 + movsd %xmm0, -8(%rsp) +..B1.5: + testl $2, %edi + je ..B1.7 +..B1.6: + lea d_tiny(%rip), %rax + movsd (%rax), %xmm0 + addsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) +..B1.7: + testl $8, %edi + je ..B1.9 +..B1.8: + lea d_huge(%rip), %rax + movsd (%rax), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) +..B1.9: + testl $16, %edi + je ..B1.11 +..B1.10: + lea d_norm(%rip), %rax + movsd (%rax), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) +..B1.11: + testl $32, %edi + je ..B1.13 +..B1.12: + movq p_one(%rip), %rax + movq p_norm(%rip), %rdx + movsd (%rax), %xmm0 + addsd (%rdx), %xmm0 + movsd %xmm0, -8(%rsp) +..B1.13: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type feraiseexcept,@function + .size feraiseexcept,.-feraiseexcept + .data +# -- End feraiseexcept + .section .rodata, "a" + .align 8 + .align 8 +d_zero: + .long 0x00000000,0x00000000 + .type d_zero,@object + .size d_zero,8 + .align 8 +d_one: + .long 0x00000000,0x3ff00000 + .type d_one,@object + .size d_one,8 + .align 8 +d_tiny: + .long 0xffffffff,0x000fffff + .type d_tiny,@object + .size d_tiny,8 + .align 8 +d_huge: + .long 0xffffffff,0x7fefffff + .type d_huge,@object + .size d_huge,8 + .align 8 +d_norm: + .long 0x00000000,0x00100000 + .type d_norm,@object + .size d_norm,8 + .section .data.rel.ro.local, "aw",@progbits + .align 8 + .align 8 +p_one: + .quad d_one + .type p_one,@object + .size p_one,8 + .align 8 +p_zero: + .quad d_zero + .type p_zero,@object + .size p_zero,8 + .align 8 +p_norm: + .quad d_norm + .type p_norm,@object + .size p_norm,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fesetenv.S b/external/sgx_libm/intel64/fesetenv.S new file mode 100644 index 0000000000..34d7de7f65 --- /dev/null +++ b/external/sgx_libm/intel64/fesetenv.S @@ -0,0 +1,119 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fesetenv.c" + .text +..TXTST0: +# -- Begin fesetenv + .text + .align 16,0x90 + .globl fesetenv +fesetenv: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value_fesetenv.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 40(%rsp) +..B1.2: + fnstenv 4(%rsp) +..B1.3: + movzwl 4(%rsp), %eax + movzwl 8(%rsp), %edx + andl $-3136, %eax + andl $-64, %edx + movw %ax, 4(%rsp) + movw %dx, 8(%rsp) +..B1.4: + stmxcsr (%rsp) +..B1.5: + movl (%rsp), %eax + andl $-32704, %eax + cmpq $-1, %rdi + je ..B1.13 +..B1.6: + movzwl (%rdi), %edx + movzwl 4(%rdi), %ecx + andl $3135, %edx + movl 28(%rdi), %eax + andl $63, %ecx + movl %eax, (%rsp) + orw %dx, 4(%rsp) + orw %cx, 8(%rsp) +..B1.7: + fnclex +..B1.8: + fldenv 4(%rsp) +..B1.9: + ldmxcsr (%rsp) +..B1.10: + movq 40(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.12 +..B1.11: + xorl %eax, %eax + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + call __stack_chk_fail@PLT +..B1.13: + orl $8064, %eax + movl %eax, (%rsp) + movzwl 4(%rsp), %eax + orl $63, %eax + movw %ax, 4(%rsp) + jmp ..B1.7 + .align 16,0x90 + .cfi_endproc + .type fesetenv,@function + .size fesetenv,.-fesetenv + .data +# -- End fesetenv + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fesetexceptflag.S b/external/sgx_libm/intel64/fesetexceptflag.S new file mode 100644 index 0000000000..2c49d08b29 --- /dev/null +++ b/external/sgx_libm/intel64/fesetexceptflag.S @@ -0,0 +1,110 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fesetexceptflag.c" + .text +..TXTST0: +# -- Begin fesetexceptflag + .text + .align 16,0x90 + .globl fesetexceptflag +fesetexceptflag: +# parameter 1: %rdi +# parameter 2: %esi +..B1.1: + .cfi_startproc +..___tag_value_fesetexceptflag.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 40(%rsp) + andl $63, %esi + je ..B1.9 +..B1.2: + stmxcsr (%rsp) +..B1.3: + movl %esi, %ecx + notl %ecx + movl (%rsp), %edx + movzwl (%rdi), %eax + andl %ecx, %edx + andl %esi, %eax + orl %eax, %edx + movl %edx, (%rsp) +..B1.4: + ldmxcsr (%rsp) +..B1.5: + fnstenv 4(%rsp) +..B1.6: + movzwl 8(%rsp), %eax + andl %ecx, %eax + movzwl (%rdi), %ecx + andl %esi, %ecx + orl %ecx, %eax + movw %ax, 8(%rsp) +..B1.7: + fnclex +..B1.8: + fldenv 4(%rsp) +..B1.9: + movq 40(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.11 +..B1.10: + xorl %eax, %eax + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.11: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type fesetexceptflag,@function + .size fesetexceptflag,.-fesetexceptflag + .data +# -- End fesetexceptflag + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fesetround.S b/external/sgx_libm/intel64/fesetround.S new file mode 100644 index 0000000000..4e0665258c --- /dev/null +++ b/external/sgx_libm/intel64/fesetround.S @@ -0,0 +1,115 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fesetround.c" + .text +..TXTST0: +# -- Begin fesetround + .text + .align 16,0x90 + .globl fesetround +fesetround: +# parameter 1: %edi +..B1.1: + .cfi_startproc +..___tag_value_fesetround.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 40(%rsp) + testl $-3073, %edi + jne ..B1.11 +..B1.2: + stmxcsr (%rsp) +..B1.3: + movl (%rsp), %edx + lea (,%rdi,8), %eax + andl $-24577, %edx + orl %eax, %edx + movl %edx, (%rsp) +..B1.4: + ldmxcsr (%rsp) +..B1.5: + fnstenv 4(%rsp) +..B1.6: + movzwl 4(%rsp), %eax + andl $-3073, %eax + orl %edi, %eax + movw %ax, 4(%rsp) +..B1.7: + fnclex +..B1.8: + fldenv 4(%rsp) +..B1.9: + movq 40(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.13 +..B1.10: + xorl %eax, %eax + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.11: + movq 40(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.13 +..B1.12: + movl $1, %eax + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.13: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type fesetround,@function + .size fesetround,.-fesetround + .data +# -- End fesetround + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fetestexcept.S b/external/sgx_libm/intel64/fetestexcept.S new file mode 100644 index 0000000000..37631aa293 --- /dev/null +++ b/external/sgx_libm/intel64/fetestexcept.S @@ -0,0 +1,85 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fetestexcept.c" + .text +..TXTST0: +# -- Begin fetestexcept + .text + .align 16,0x90 + .globl fetestexcept +fetestexcept: +# parameter 1: %edi +..B1.1: + .cfi_startproc +..___tag_value_fetestexcept.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + andl $63, %edi + je ..B1.5 +..B1.2: + stmxcsr (%rsp) +..B1.3: + fnstsw 4(%rsp) +..B1.4: + movzwl 4(%rsp), %eax + orl (%rsp), %eax + movl %eax, (%rsp) + andl %edi, %eax + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B1.5: + xorl %eax, %eax + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fetestexcept,@function + .size fetestexcept,.-fetestexcept + .data +# -- End fetestexcept + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/feupdateenv.S b/external/sgx_libm/intel64/feupdateenv.S new file mode 100644 index 0000000000..6d0471e58c --- /dev/null +++ b/external/sgx_libm/intel64/feupdateenv.S @@ -0,0 +1,99 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "feupdateenv.c" + .text +..TXTST0: +# -- Begin feupdateenv + .text + .align 16,0x90 + .globl feupdateenv +feupdateenv: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value_feupdateenv.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %rsi + .cfi_def_cfa_offset 32 + movq %rdi, %r12 + movl $63, %edi +..___tag_value_feupdateenv.8: + call fetestexcept@PLT +..___tag_value_feupdateenv.9: +..B1.7: + movl %eax, %r13d +..B1.2: + movq %r12, %rdi +..___tag_value_feupdateenv.10: + call fesetenv@PLT +..___tag_value_feupdateenv.11: +..B1.3: + movl %r13d, %edi +..___tag_value_feupdateenv.12: + call feraiseexcept@PLT +..___tag_value_feupdateenv.13: +..B1.4: + xorl %eax, %eax + popq %rcx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type feupdateenv,@function + .size feupdateenv,.-feupdateenv + .data +# -- End feupdateenv + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/floor_gen.S b/external/sgx_libm/intel64/floor_gen.S new file mode 100644 index 0000000000..daa3faa589 --- /dev/null +++ b/external/sgx_libm/intel64/floor_gen.S @@ -0,0 +1,167 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "floor_gen.c" + .text +..TXTST0: +# -- Begin floor + .text + .align 16,0x90 + .globl floor +floor: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_floor.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + movl %eax, %edi + andl $2147483647, %edi + lea -1072693248(%rdi), %edx + cmpl $54525952, %edx + jae ..B1.12 +..B1.2: + movl %edi, %ecx + shrl $20, %ecx + cmpl $22020096, %edx + jae ..B1.8 +..B1.3: + negl %ecx + movl $-1, %esi + addl $19, %ecx + shll %cl, %esi + movl %esi, %edx + andl %esi, %eax + notl %edx + andl %edx, %edi + orl -8(%rsp), %edi + movl $0, -8(%rsp) + testl $-2147483648, %eax + je ..B1.6 +..B1.4: + testl %edi, %edi + je ..B1.6 +..B1.5: + subl %esi, %eax + movl %eax, -4(%rsp) + jmp ..B1.11 +..B1.6: + movl %eax, -4(%rsp) + jmp ..B1.11 +..B1.8: + negl %ecx + movl $-1, %esi + addl $19, %ecx + shll %cl, %esi + movl %esi, %ecx + notl %ecx + movl -8(%rsp), %edx + andl %edx, %ecx + andl %esi, %edx + movl %edx, -8(%rsp) + testl $-2147483648, %eax + je ..B1.11 +..B1.9: + testl %ecx, %ecx + je ..B1.11 +..B1.10: + movl -4(%rsp), %eax + shlq $32, %rax + movslq %esi, %rsi + orq %rdx, %rax + subq %rsi, %rax + movq %rax, -8(%rsp) +..B1.11: + movsd -8(%rsp), %xmm0 + ret +..B1.12: + testl $-2147483648, %edx + je ..B1.17 +..B1.13: + movl -8(%rsp), %edx + orl %edx, %edi + jne ..B1.15 +..B1.14: + movsd -8(%rsp), %xmm0 + ret +..B1.15: + lea _pzero_none(%rip), %rdx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm0 +..B1.16: + ret +..B1.17: + movsd -8(%rsp), %xmm0 + cmpl $1073741824, %edx + jb ..B1.20 +..B1.19: + lea _ones(%rip), %rax + mulsd (%rax), %xmm0 +..B1.20: + ret + .align 16,0x90 + .cfi_endproc + .type floor,@function + .size floor,.-floor + .data +# -- End floor + .section .rodata, "a" + .align 4 + .align 4 +_pzero_none: + .long 0 + .long 0 + .long 0 + .long 3220176896 + .type _pzero_none,@object + .size _pzero_none,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/floorf_gen.S b/external/sgx_libm/intel64/floorf_gen.S new file mode 100644 index 0000000000..1a7ad62bab --- /dev/null +++ b/external/sgx_libm/intel64/floorf_gen.S @@ -0,0 +1,141 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "floorf_gen.c" + .text +..TXTST0: +# -- Begin floorf + .text + .align 16,0x90 + .globl floorf +floorf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_floorf.1: +..L2: + + movaps %xmm0, %xmm2 + movss %xmm2, -16(%rsp) + movzwl -14(%rsp), %eax + andl $32640, %eax + shrl $7, %eax + cmpl $149, %eax + jge ..B1.8 +..B1.2: + cmpl $127, %eax + jl ..B1.4 +..B1.3: + movss .L_2il0floatpacket.0(%rip), %xmm1 + movaps %xmm1, %xmm0 + addss %xmm2, %xmm0 + movss %xmm0, -24(%rsp) + movss -24(%rsp), %xmm3 + movss .L_2il0floatpacket.1(%rip), %xmm0 + subss %xmm1, %xmm3 + comiss %xmm2, %xmm3 + addss %xmm3, %xmm0 + ja ..L3 + movaps %xmm3, %xmm0 +..L3: + ret +..B1.4: + testl %eax, %eax + jne ..B1.7 +..B1.5: + testl $8388607, -16(%rsp) + jne ..B1.7 +..B1.6: + movss -16(%rsp), %xmm0 + ret +..B1.7: + movb -13(%rsp), %dl + lea _pzero_none(%rip), %rcx + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + movl -16(%rsp), %eax + movl %eax, -24(%rsp) + movss (%rcx,%rsi,4), %xmm0 + ret +..B1.8: + cmpl $150, %eax + jge ..B1.6 +..B1.9: + movss -16(%rsp), %xmm1 + movss .L_2il0floatpacket.2(%rip), %xmm0 + testb $1, -16(%rsp) + addss %xmm1, %xmm0 + jne ..L4 + movaps %xmm1, %xmm0 +..L4: + ret + .align 16,0x90 + .cfi_endproc + .type floorf,@function + .size floorf,.-floorf + .data +# -- End floorf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4b400000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0xbf800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0xbf000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +_pzero_none: + .long 0 + .long 3212836864 + .type _pzero_none,@object + .size _pzero_none,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/floorl.S b/external/sgx_libm/intel64/floorl.S new file mode 100644 index 0000000000..5f739d46df --- /dev/null +++ b/external/sgx_libm/intel64/floorl.S @@ -0,0 +1,256 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "floorl.c" + .text +..TXTST0: +# -- Begin floorl + .text + .align 16,0x90 + .globl floorl +floorl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_floorl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %cl, %cl +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 56(%rsp), %eax + andl $32767, %eax + cmpl $16445, %eax + jge ..B1.20 +..B1.4: + cmpl $16383, %eax + jl ..B1.15 +..B1.5: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.7: + fldcw 24(%rsp) +..B1.8: + movb $1, %cl +..B1.9: + fldt 48(%rsp) + lea _TWO_63H(%rip), %rax + fld %st(0) + fldl (%rax) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 8(%rsp) + fldt 8(%rsp) + fcomip %st(1), %st + fstp %st(0) + jbe ..B1.12 +..B1.10: + fldt 8(%rsp) + lea 8+_ones(%rip), %rax + faddl (%rax) + fstpt 8(%rsp) +..B1.12: + testb %cl, %cl + je ..B1.14 +..B1.13: + fldcw 26(%rsp) +..B1.14: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.15: + testl %eax, %eax + jne ..B1.19 +..B1.16: + cmpq $0, 48(%rsp) + jne ..B1.18 +..B1.17: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.18: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, (%rsp) +..B1.19: + movb 57(%rsp), %al + lea _pzero_none(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.20: + cmpl $16446, %eax + jge ..B1.29 +..B1.21: + testb $1, 48(%rsp) + je ..B1.28 +..B1.22: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.35 +..B1.23: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.24: + fldcw 24(%rsp) +..B1.25: + fldt 48(%rsp) + lea 8+_halfs(%rip), %rax + faddl (%rax) + fstpt 8(%rsp) +..B1.26: + fldcw 26(%rsp) +..B1.27: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.28: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.29: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.30: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.31: + fldcw 24(%rsp) +..B1.32: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) +..B1.33: + fldcw 26(%rsp) +..B1.34: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.35: + fldt 48(%rsp) + lea 8+_halfs(%rip), %rax + faddl (%rax) + fstpt 8(%rsp) + jmp ..B1.27 +..B1.36: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) + jmp ..B1.34 + .align 16,0x90 + .cfi_endproc + .type floorl,@function + .size floorl,.-floorl + .data +# -- End floorl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_pzero_none: + .long 0 + .long 0 + .long 0 + .long 3220176896 + .type _pzero_none,@object + .size _pzero_none,16 + .align 4 +_halfs: + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .type _halfs,@object + .size _halfs,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fma_gen.S b/external/sgx_libm/intel64/fma_gen.S new file mode 100644 index 0000000000..51110ae806 --- /dev/null +++ b/external/sgx_libm/intel64/fma_gen.S @@ -0,0 +1,1644 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fma_gen.c" + .text +..TXTST0: +# -- Begin fma + .text + + .globl fma +fma: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +# parameter 3: %xmm2 +..B1.1: + .cfi_startproc +..___tag_value_fma.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_def_cfa 6, 16 + .cfi_offset 6, -16 + subq $272, %rsp + movsd %xmm0, -80(%rbp) + movsd %xmm1, -72(%rbp) + movsd %xmm2, -64(%rbp) +..B1.2: + stmxcsr -272(%rbp) +..B1.3: + movl -272(%rbp), %eax + andl $24576, %eax + movl %eax, -268(%rbp) + lea -80(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $2147483647, %eax + movl %eax, -264(%rbp) + lea -80(%rbp), %rax + movl (%rax), %eax + movl %eax, -260(%rbp) + lea -72(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $2147483647, %eax + movl %eax, -256(%rbp) + lea -72(%rbp), %rax + movl (%rax), %eax + movl %eax, -252(%rbp) + lea -64(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $2147483647, %eax + movl %eax, -248(%rbp) + lea -64(%rbp), %rax + movl (%rax), %eax + movl %eax, -244(%rbp) + movl -260(%rbp), %eax + orl -264(%rbp), %eax + je ..B1.11 +..B1.4: + movl -264(%rbp), %eax + cmpl $2146435072, %eax + jae ..B1.11 +..B1.5: + movl $-1072693248, %eax + addl -264(%rbp), %eax + orl -260(%rbp), %eax + je ..B1.11 +..B1.6: + movl -252(%rbp), %eax + orl -256(%rbp), %eax + je ..B1.11 +..B1.7: + movl -256(%rbp), %eax + cmpl $2146435072, %eax + jae ..B1.11 +..B1.8: + movl $-1072693248, %eax + addl -256(%rbp), %eax + orl -252(%rbp), %eax + je ..B1.11 +..B1.9: + movl -244(%rbp), %eax + orl -248(%rbp), %eax + je ..B1.11 +..B1.10: + movl -248(%rbp), %eax + cmpl $2146435072, %eax + jb ..B1.28 +..B1.11: + movl -264(%rbp), %eax + cmpl $2146435072, %eax + ja ..B1.14 +..B1.12: + movl -264(%rbp), %eax + cmpl $2146435072, %eax + jne ..B1.15 +..B1.13: + movl -260(%rbp), %eax + testl %eax, %eax + je ..B1.15 +..B1.14: + movsd -80(%rbp), %xmm0 + lea _ones(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.15: + movl -256(%rbp), %eax + cmpl $2146435072, %eax + ja ..B1.18 +..B1.16: + movl -256(%rbp), %eax + cmpl $2146435072, %eax + jne ..B1.19 +..B1.17: + movl -252(%rbp), %eax + testl %eax, %eax + je ..B1.19 +..B1.18: + movsd -72(%rbp), %xmm0 + lea _ones(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.19: + movl -248(%rbp), %eax + cmpl $2146435072, %eax + ja ..B1.22 +..B1.20: + movl -248(%rbp), %eax + cmpl $2146435072, %eax + jne ..B1.23 +..B1.21: + movl -244(%rbp), %eax + testl %eax, %eax + je ..B1.23 +..B1.22: + movsd -64(%rbp), %xmm0 + lea _ones(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.23: + movl -264(%rbp), %eax + cmpl $2146435072, %eax + jae ..B1.27 +..B1.24: + movl -256(%rbp), %eax + cmpl $2146435072, %eax + jae ..B1.27 +..B1.25: + movl -248(%rbp), %eax + cmpl $2146435072, %eax + jb ..B1.27 +..B1.26: + movsd -64(%rbp), %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.27: + movsd -80(%rbp), %xmm0 + movsd -72(%rbp), %xmm1 + mulsd %xmm1, %xmm0 + movsd -64(%rbp), %xmm1 + addsd %xmm1, %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.28: + movl -264(%rbp), %eax + cmpl $1048576, %eax + jae ..B1.30 +..B1.29: + lea -80(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + shrl $31, %eax + movl %eax, -240(%rbp) + lea -80(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + orl $1072693248, %eax + lea -80(%rbp), %rdx + addq $4, %rdx + movl %eax, (%rdx) + movl -240(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _ones(%rip), %rdx + addq %rax, %rdx + movsd -80(%rbp), %xmm0 + movsd (%rdx), %xmm1 + subsd %xmm1, %xmm0 + movsd %xmm0, -80(%rbp) + lea -80(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $2147483647, %eax + movl %eax, -264(%rbp) + lea -80(%rbp), %rax + movl (%rax), %eax + movl %eax, -260(%rbp) + movl -264(%rbp), %eax + shrl $20, %eax + addl $-1022, %eax + movl %eax, -236(%rbp) + jmp ..B1.31 +..B1.30: + movl -264(%rbp), %eax + shrl $20, %eax + movl %eax, -236(%rbp) +..B1.31: + movl -256(%rbp), %eax + cmpl $1048576, %eax + jae ..B1.33 +..B1.32: + lea -72(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + shrl $31, %eax + movl %eax, -232(%rbp) + lea -72(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + orl $1072693248, %eax + lea -72(%rbp), %rdx + addq $4, %rdx + movl %eax, (%rdx) + movl -232(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _ones(%rip), %rdx + addq %rax, %rdx + movsd -72(%rbp), %xmm0 + movsd (%rdx), %xmm1 + subsd %xmm1, %xmm0 + movsd %xmm0, -72(%rbp) + lea -72(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $2147483647, %eax + movl %eax, -256(%rbp) + lea -72(%rbp), %rax + movl (%rax), %eax + movl %eax, -252(%rbp) + movl -256(%rbp), %eax + shrl $20, %eax + addl $-1022, %eax + movl %eax, -228(%rbp) + jmp ..B1.34 +..B1.33: + movl -256(%rbp), %eax + shrl $20, %eax + movl %eax, -228(%rbp) +..B1.34: + movl -248(%rbp), %eax + cmpl $1048576, %eax + jae ..B1.36 +..B1.35: + lea -64(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + shrl $31, %eax + movl %eax, -224(%rbp) + lea -64(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + orl $1072693248, %eax + lea -64(%rbp), %rdx + addq $4, %rdx + movl %eax, (%rdx) + movl -224(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _ones(%rip), %rdx + addq %rax, %rdx + movsd -64(%rbp), %xmm0 + movsd (%rdx), %xmm1 + subsd %xmm1, %xmm0 + movsd %xmm0, -64(%rbp) + lea -64(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $2147483647, %eax + movl %eax, -248(%rbp) + lea -64(%rbp), %rax + movl (%rax), %eax + movl %eax, -244(%rbp) + movl -248(%rbp), %eax + shrl $20, %eax + addl $-1022, %eax + movl %eax, -220(%rbp) + jmp ..B1.37 +..B1.36: + movl -248(%rbp), %eax + shrl $20, %eax + movl %eax, -220(%rbp) +..B1.37: + movl -264(%rbp), %eax + andl $1048575, %eax + orl $1048576, %eax + movl %eax, -216(%rbp) + movl -256(%rbp), %eax + andl $1048575, %eax + orl $1048576, %eax + movl %eax, -212(%rbp) + movl -248(%rbp), %eax + andl $1048575, %eax + orl $1048576, %eax + movl %eax, -208(%rbp) + lea -80(%rbp), %rax + addq $4, %rax + lea -72(%rbp), %rdx + addq $4, %rdx + movl (%rdx), %edx + xorl (%rax), %edx + andl $-2147483648, %edx + movl %edx, -204(%rbp) + movl -228(%rbp), %eax + addl -236(%rbp), %eax + addl $-1023, %eax + movl %eax, -200(%rbp) + movl -252(%rbp), %eax + movl -260(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -56(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -196(%rbp) + movl -56(%rbp), %eax + movl %eax, -192(%rbp) + movl -252(%rbp), %eax + movl -216(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -48(%rbp) + movq -48(%rbp), %rax + shrq $32, %rax + movl %eax, -188(%rbp) + movl -48(%rbp), %eax + movl %eax, -184(%rbp) + movl -212(%rbp), %eax + movl -260(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -40(%rbp) + movq -40(%rbp), %rax + shrq $32, %rax + movl %eax, -180(%rbp) + movl -40(%rbp), %eax + movl %eax, -176(%rbp) + movl -212(%rbp), %eax + movl -216(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -32(%rbp) + movq -32(%rbp), %rax + shrq $32, %rax + movl %eax, -172(%rbp) + movl -32(%rbp), %eax + movl %eax, -168(%rbp) + movl -192(%rbp), %eax + movl %eax, -164(%rbp) + movl -196(%rbp), %eax + movq %rax, -24(%rbp) + movl -184(%rbp), %eax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -176(%rbp), %eax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -24(%rbp), %eax + movl %eax, -160(%rbp) + movq -24(%rbp), %rax + shrq $32, %rax + movl %eax, -156(%rbp) + movl -168(%rbp), %eax + movq %rax, -24(%rbp) + movl -188(%rbp), %eax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -180(%rbp), %eax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -156(%rbp), %eax + movslq %eax, %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -24(%rbp), %eax + movl %eax, -152(%rbp) + movq -24(%rbp), %rax + shrq $32, %rax + movl %eax, -156(%rbp) + movl -156(%rbp), %eax + addl -172(%rbp), %eax + movl %eax, -148(%rbp) + movl -148(%rbp), %eax + testl $512, %eax + je ..B1.39 +..B1.38: + movl -148(%rbp), %eax + shll $11, %eax + movl -152(%rbp), %edx + shrl $21, %edx + orl %edx, %eax + movl %eax, -148(%rbp) + movl -152(%rbp), %eax + shll $11, %eax + movl -160(%rbp), %edx + shrl $21, %edx + orl %edx, %eax + movl %eax, -152(%rbp) + movl -160(%rbp), %eax + shll $11, %eax + movl -164(%rbp), %edx + shrl $21, %edx + orl %edx, %eax + movl %eax, -160(%rbp) + shll $11, -164(%rbp) + movl $1, %eax + addl -200(%rbp), %eax + movl %eax, -200(%rbp) + jmp ..B1.40 +..B1.39: + movl -148(%rbp), %eax + shll $12, %eax + movl -152(%rbp), %edx + shrl $20, %edx + orl %edx, %eax + movl %eax, -148(%rbp) + movl -152(%rbp), %eax + shll $12, %eax + movl -160(%rbp), %edx + shrl $20, %edx + orl %edx, %eax + movl %eax, -152(%rbp) + movl -160(%rbp), %eax + shll $12, %eax + movl -164(%rbp), %edx + shrl $20, %edx + orl %edx, %eax + movl %eax, -160(%rbp) + shll $12, -164(%rbp) +..B1.40: + movl -200(%rbp), %eax + movl -220(%rbp), %edx + cmpl %edx, %eax + jg ..B1.45 +..B1.41: + movl -200(%rbp), %eax + movl -220(%rbp), %edx + cmpl %edx, %eax + jne ..B1.46 +..B1.42: + movl -148(%rbp), %eax + movl -208(%rbp), %edx + cmpl %edx, %eax + ja ..B1.45 +..B1.43: + movl -148(%rbp), %eax + movl -208(%rbp), %edx + cmpl %edx, %eax + jne ..B1.46 +..B1.44: + movl -152(%rbp), %eax + movl -244(%rbp), %edx + cmpl %edx, %eax + jb ..B1.46 +..B1.45: + movl -220(%rbp), %eax + negl %eax + addl -200(%rbp), %eax + movl %eax, -144(%rbp) + movl -208(%rbp), %eax + movl %eax, -140(%rbp) + movl -244(%rbp), %eax + movl %eax, -136(%rbp) + movl $0, %eax + movl %eax, -132(%rbp) + movl %eax, -128(%rbp) + lea -64(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $-2147483648, %eax + movl %eax, -224(%rbp) + jmp ..B1.47 +..B1.46: + movl -200(%rbp), %eax + negl %eax + addl -220(%rbp), %eax + movl %eax, -144(%rbp) + movl -220(%rbp), %eax + movl %eax, -200(%rbp) + movl -148(%rbp), %eax + movl %eax, -140(%rbp) + movl -152(%rbp), %eax + movl %eax, -136(%rbp) + movl -160(%rbp), %eax + movl %eax, -128(%rbp) + movl -164(%rbp), %eax + movl %eax, -132(%rbp) + movl -208(%rbp), %eax + movl %eax, -148(%rbp) + movl -244(%rbp), %eax + movl %eax, -152(%rbp) + movl $0, %eax + movl %eax, -164(%rbp) + movl %eax, -160(%rbp) + movl -204(%rbp), %eax + movl %eax, -224(%rbp) + lea -64(%rbp), %rax + addq $4, %rax + movl (%rax), %eax + andl $-2147483648, %eax + movl %eax, -204(%rbp) +..B1.47: + movl $0, -124(%rbp) + movl -144(%rbp), %eax + testl %eax, %eax + je ..B1.57 +..B1.48: + movl -144(%rbp), %eax + cmpl $32, %eax + jge ..B1.50 +..B1.49: + movl -144(%rbp), %eax + negl %eax + addl $32, %eax + movl %eax, -120(%rbp) + movl -144(%rbp), %eax + movl %eax, -116(%rbp) + movl $-1, %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -112(%rbp) + movl -132(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl %eax, -124(%rbp) + movl -128(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -132(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -132(%rbp) + movl -136(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -128(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -128(%rbp) + movl -140(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -136(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -136(%rbp) + movl -116(%rbp), %eax + movl %eax, %ecx + shrl %cl, -140(%rbp) + jmp ..B1.57 +..B1.50: + movl -144(%rbp), %eax + cmpl $64, %eax + jge ..B1.52 +..B1.51: + movl -144(%rbp), %eax + negl %eax + addl $64, %eax + movl %eax, -120(%rbp) + movl $-32, %eax + addl -144(%rbp), %eax + movl %eax, -116(%rbp) + movl $-1, %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -112(%rbp) + movl -128(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -132(%rbp), %edx + movl $1, %ecx + testl %edx, %edx + cmovne %ecx, %edx + orl %edx, %eax + movl %eax, -124(%rbp) + movl -136(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -128(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -132(%rbp) + movl -140(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -136(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -128(%rbp) + movl -140(%rbp), %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -136(%rbp) + movl $0, -140(%rbp) + jmp ..B1.57 +..B1.52: + movl -144(%rbp), %eax + cmpl $96, %eax + jge ..B1.54 +..B1.53: + movl -144(%rbp), %eax + negl %eax + addl $96, %eax + movl %eax, -120(%rbp) + movl $-64, %eax + addl -144(%rbp), %eax + movl %eax, -116(%rbp) + movl $-1, %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -112(%rbp) + movl -136(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -132(%rbp), %edx + orl -128(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -124(%rbp) + movl -140(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -136(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -132(%rbp) + movl -140(%rbp), %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -128(%rbp) + movl $0, %eax + movl %eax, -136(%rbp) + movl %eax, -140(%rbp) + jmp ..B1.57 +..B1.54: + movl -144(%rbp), %eax + cmpl $128, %eax + jge ..B1.56 +..B1.55: + movl -144(%rbp), %eax + negl %eax + addl $128, %eax + movl %eax, -120(%rbp) + movl $-96, %eax + addl -144(%rbp), %eax + movl %eax, -116(%rbp) + movl $-1, %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -112(%rbp) + movl -140(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -128(%rbp), %edx + orl -136(%rbp), %edx + orl -132(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -124(%rbp) + movl -140(%rbp), %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -132(%rbp) + movl $0, -128(%rbp) + movl $0, %eax + movl %eax, -136(%rbp) + movl %eax, -140(%rbp) + jmp ..B1.57 +..B1.56: + movl -136(%rbp), %eax + orl -140(%rbp), %eax + orl -128(%rbp), %eax + orl -132(%rbp), %eax + movl $1, %eax + movl $0, %edx + cmovne %eax, %edx + movl %edx, -124(%rbp) + movl $0, -132(%rbp) + movl $0, -128(%rbp) + movl $0, %eax + movl %eax, -136(%rbp) + movl %eax, -140(%rbp) +..B1.57: + movl -204(%rbp), %eax + movl -224(%rbp), %edx + cmpl %edx, %eax + jne ..B1.64 +..B1.58: + movl -164(%rbp), %eax + movl %eax, -108(%rbp) + movl -132(%rbp), %eax + addl -164(%rbp), %eax + movl %eax, -164(%rbp) + movl -164(%rbp), %eax + movl -108(%rbp), %edx + cmpl %edx, %eax + jb ..B1.60 +..B1.59: + movl $0, -156(%rbp) + jmp ..B1.61 +..B1.60: + movl $1, -156(%rbp) +..B1.61: + movl -160(%rbp), %eax + movq %rax, -24(%rbp) + movl -128(%rbp), %eax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -156(%rbp), %eax + movslq %eax, %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -24(%rbp), %eax + movl %eax, -160(%rbp) + movq -24(%rbp), %rax + shrq $32, %rax + movl %eax, -156(%rbp) + movl -152(%rbp), %eax + movq %rax, -24(%rbp) + movl -136(%rbp), %eax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -156(%rbp), %eax + movslq %eax, %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -24(%rbp), %eax + movl %eax, -152(%rbp) + movq -24(%rbp), %rax + shrq $32, %rax + movl %eax, -156(%rbp) + movl -140(%rbp), %eax + addl -148(%rbp), %eax + movl %eax, -148(%rbp) + movl -156(%rbp), %eax + addl -148(%rbp), %eax + movl %eax, -148(%rbp) + movl -148(%rbp), %eax + testl $2097152, %eax + je ..B1.63 +..B1.62: + movl -152(%rbp), %eax + shll $31, %eax + movl -164(%rbp), %edx + orl -160(%rbp), %edx + orl -124(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -124(%rbp) + movl -148(%rbp), %eax + shll $31, %eax + movl -152(%rbp), %edx + shrl $1, %edx + orl %edx, %eax + movl %eax, -100(%rbp) + movl -148(%rbp), %eax + shrl $1, %eax + andl $1048575, %eax + movl %eax, -96(%rbp) + movl $1, %eax + addl -200(%rbp), %eax + movl %eax, -200(%rbp) + jmp ..B1.90 +..B1.63: + movl -160(%rbp), %eax + movl -124(%rbp), %edx + orl -164(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -124(%rbp) + movl -152(%rbp), %eax + movl %eax, -100(%rbp) + movl -148(%rbp), %eax + andl $1048575, %eax + movl %eax, -96(%rbp) + jmp ..B1.90 +..B1.64: + movl -124(%rbp), %eax + negl %eax + movl %eax, -124(%rbp) + movl -124(%rbp), %eax + testl %eax, %eax + jne ..B1.66 +..B1.65: + movl $0, -104(%rbp) + jmp ..B1.67 +..B1.66: + movl $1, -104(%rbp) +..B1.67: + movl -164(%rbp), %eax + movq %rax, -24(%rbp) + movl -132(%rbp), %eax + negq %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -104(%rbp), %eax + movslq %eax, %rax + negq %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -24(%rbp), %eax + movl %eax, -164(%rbp) + movq -24(%rbp), %rax + shrq $32, %rax + movl %eax, -104(%rbp) + movl -160(%rbp), %eax + movq %rax, -24(%rbp) + movl -128(%rbp), %eax + negq %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -104(%rbp), %eax + movslq %eax, %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -24(%rbp), %eax + movl %eax, -160(%rbp) + movq -24(%rbp), %rax + shrq $32, %rax + movl %eax, -104(%rbp) + movl -152(%rbp), %eax + movq %rax, -24(%rbp) + movl -136(%rbp), %eax + negq %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -104(%rbp), %eax + movslq %eax, %rax + addq -24(%rbp), %rax + movq %rax, -24(%rbp) + movl -24(%rbp), %eax + movl %eax, -152(%rbp) + movq -24(%rbp), %rax + shrq $32, %rax + movl %eax, -104(%rbp) + movl -140(%rbp), %eax + negl %eax + addl -148(%rbp), %eax + movl %eax, -148(%rbp) + movl -104(%rbp), %eax + addl -148(%rbp), %eax + movl %eax, -148(%rbp) + movl -148(%rbp), %eax + testl %eax, %eax + je ..B1.69 +..B1.68: + movl -148(%rbp), %eax + shll $11, %eax + movl %eax, -108(%rbp) + movl $0, -144(%rbp) + jmp ..B1.78 +..B1.69: + movl -152(%rbp), %eax + testl %eax, %eax + je ..B1.71 +..B1.70: + movl -152(%rbp), %eax + movl %eax, -108(%rbp) + movl $21, -144(%rbp) + jmp ..B1.78 +..B1.71: + movl -160(%rbp), %eax + testl %eax, %eax + je ..B1.73 +..B1.72: + movl -160(%rbp), %eax + movl %eax, -108(%rbp) + movl $53, -144(%rbp) + jmp ..B1.78 +..B1.73: + movl -164(%rbp), %eax + testl %eax, %eax + je ..B1.75 +..B1.74: + movl -164(%rbp), %eax + movl %eax, -108(%rbp) + movl $85, -144(%rbp) + jmp ..B1.78 +..B1.75: + movl -124(%rbp), %eax + testl %eax, %eax + je ..B1.77 +..B1.76: + movl -124(%rbp), %eax + movl %eax, -108(%rbp) + movl $117, -144(%rbp) + jmp ..B1.78 +..B1.77: + movl -268(%rbp), %eax + movl $1, %edx + movl $0, %ecx + cmpl $8192, %eax + cmove %edx, %ecx + movslq %ecx, %rcx + shlq $3, %rcx + lea _zeros(%rip), %rax + addq %rcx, %rax + movsd (%rax), %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.78: + movl -108(%rbp), %eax + testl $-2147483648, %eax + jne ..B1.80 +..B1.79: + shll $1, -108(%rbp) + movl $1, %eax + addl -144(%rbp), %eax + movl %eax, -144(%rbp) + jmp ..B1.78 +..B1.80: + movl -144(%rbp), %eax + cmpl $32, %eax + jge ..B1.82 +..B1.81: + movl -144(%rbp), %eax + movl %eax, -120(%rbp) + movl -144(%rbp), %eax + negl %eax + addl $32, %eax + movl %eax, -116(%rbp) + movl $1, %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -92(%rbp) + movl -160(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -124(%rbp), %edx + orl -164(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -124(%rbp) + movl -152(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -160(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + andl -92(%rbp), %edx + orl %edx, %eax + movl %eax, -100(%rbp) + movl -148(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -152(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + andl -92(%rbp), %edx + orl %edx, %eax + andl $1048575, %eax + movl %eax, -96(%rbp) + jmp ..B1.89 +..B1.82: + movl -144(%rbp), %eax + cmpl $64, %eax + jge ..B1.84 +..B1.83: + movl $-32, %eax + addl -144(%rbp), %eax + movl %eax, -120(%rbp) + movl -144(%rbp), %eax + negl %eax + addl $64, %eax + movl %eax, -116(%rbp) + movl $1, %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -92(%rbp) + movl -164(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -124(%rbp), %edx + movl $1, %ecx + testl %edx, %edx + cmovne %ecx, %edx + orl %edx, %eax + movl %eax, -124(%rbp) + movl -160(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -164(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + andl -92(%rbp), %edx + orl %edx, %eax + movl %eax, -100(%rbp) + movl -152(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -160(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + andl -92(%rbp), %edx + orl %edx, %eax + andl $1048575, %eax + movl %eax, -96(%rbp) + jmp ..B1.89 +..B1.84: + movl -144(%rbp), %eax + cmpl $96, %eax + jge ..B1.86 +..B1.85: + movl $-64, %eax + addl -144(%rbp), %eax + movl %eax, -120(%rbp) + movl -144(%rbp), %eax + negl %eax + addl $96, %eax + movl %eax, -116(%rbp) + movl $1, %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -92(%rbp) + movl -120(%rbp), %eax + movl %eax, %ecx + shll %cl, -124(%rbp) + movl -164(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -124(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + andl -92(%rbp), %edx + orl %edx, %eax + movl %eax, -100(%rbp) + movl -160(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -164(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + andl -92(%rbp), %edx + orl %edx, %eax + andl $1048575, %eax + movl %eax, -96(%rbp) + jmp ..B1.89 +..B1.86: + movl -144(%rbp), %eax + cmpl $128, %eax + jge ..B1.88 +..B1.87: + movl $-96, %eax + addl -144(%rbp), %eax + movl %eax, -120(%rbp) + movl -144(%rbp), %eax + negl %eax + addl $128, %eax + movl %eax, -116(%rbp) + movl $1, %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -92(%rbp) + movl $0, -124(%rbp) + movl -124(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl %eax, -100(%rbp) + movl -164(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -124(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + andl -92(%rbp), %edx + orl %edx, %eax + andl $1048575, %eax + movl %eax, -96(%rbp) + jmp ..B1.89 +..B1.88: + movl $-128, %eax + addl -144(%rbp), %eax + movl %eax, -120(%rbp) + movl $0, %eax + movl %eax, -100(%rbp) + movl %eax, -124(%rbp) + movl -124(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl $1048575, %eax + movl %eax, -96(%rbp) +..B1.89: + movl -144(%rbp), %eax + negl %eax + addl -200(%rbp), %eax + movl %eax, -200(%rbp) +..B1.90: + movl $-1, %eax + addl -200(%rbp), %eax + cmpl $2046, %eax + jb ..B1.98 +..B1.91: + movl -200(%rbp), %eax + cmpl $2047, %eax + jl ..B1.93 +..B1.92: + shrl $31, -204(%rbp) + movl -204(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _large_value_64(%rip), %rdx + addq %rax, %rdx + movsd (%rdx), %xmm0 + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) + movsd %xmm0, -8(%rbp) + movsd -8(%rbp), %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.93: + orl $1048576, -96(%rbp) + movl -200(%rbp), %eax + negl %eax + incl %eax + movl %eax, -144(%rbp) + movl -144(%rbp), %eax + cmpl $32, %eax + jge ..B1.95 +..B1.94: + movl -144(%rbp), %eax + negl %eax + addl $32, %eax + movl %eax, -120(%rbp) + movl -144(%rbp), %eax + movl %eax, -116(%rbp) + movl $-1, %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -112(%rbp) + movl -100(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -124(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl -124(%rbp), %edx + movl -120(%rbp), %ecx + shll %cl, %edx + movl -112(%rbp), %ecx + testl %ecx, %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -124(%rbp) + movl -96(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -100(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -100(%rbp) + movl -116(%rbp), %eax + movl %eax, %ecx + shrl %cl, -96(%rbp) + jmp ..B1.99 +..B1.95: + movl -144(%rbp), %eax + cmpl $53, %eax + jg ..B1.97 +..B1.96: + movl -144(%rbp), %eax + negl %eax + addl $64, %eax + movl %eax, -120(%rbp) + movl $-32, %eax + addl -144(%rbp), %eax + movl %eax, -116(%rbp) + movl $-1, %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -112(%rbp) + movl -96(%rbp), %eax + movl -120(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -112(%rbp), %eax + movl -100(%rbp), %edx + movl -116(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl -100(%rbp), %edx + movl -120(%rbp), %ecx + shll %cl, %edx + andl -112(%rbp), %edx + orl -124(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -124(%rbp) + movl -96(%rbp), %eax + movl -116(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -100(%rbp) + movl $0, -96(%rbp) + jmp ..B1.99 +..B1.97: + movl $1, -124(%rbp) + movl $0, %eax + movl %eax, -100(%rbp) + movl %eax, -96(%rbp) + jmp ..B1.99 +..B1.98: + movl -200(%rbp), %eax + shll $20, %eax + orl -96(%rbp), %eax + movl %eax, -96(%rbp) +..B1.99: + movl -124(%rbp), %eax + testl %eax, %eax + je ..B1.136 +..B1.100: + lea _ones(%rip), %rax + lea _small_value_64(%rip), %rdx + movsd (%rax), %xmm0 + movsd (%rdx), %xmm1 + addsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) + movl -268(%rbp), %eax + movl %eax, -88(%rbp) + testl %eax, %eax + je ..B1.104 +..B1.101: + movl -88(%rbp), %eax + cmpl $24576, %eax + je ..B1.108 +..B1.102: + movl -88(%rbp), %eax + cmpl $16384, %eax + je ..B1.112 +..B1.103: + movl -88(%rbp), %eax + cmpl $8192, %eax + je ..B1.124 + jmp ..B1.136 +..B1.104: + movl -124(%rbp), %eax + testl $-2147483648, %eax + je ..B1.108 +..B1.105: + movl -100(%rbp), %eax + andl $1, %eax + movl -124(%rbp), %edx + andl $2147483647, %edx + orl %edx, %eax + je ..B1.108 +..B1.106: + movl $1, %eax + addl -100(%rbp), %eax + movl %eax, -100(%rbp) + movl $1, %eax + movl $0, %edx + cmove %eax, %edx + addl -96(%rbp), %edx + movl %edx, -96(%rbp) + movl -96(%rbp), %eax + cmpl $2146435072, %eax + jb ..B1.108 +..B1.107: + shrl $31, -204(%rbp) + movl -204(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _large_value_64(%rip), %rdx + addq %rax, %rdx + movsd (%rdx), %xmm0 + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) + movsd %xmm0, -8(%rbp) + movsd -8(%rbp), %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.108: + movl -96(%rbp), %eax + cmpl $1048576, %eax + jb ..B1.111 +..B1.109: + movl $-1048576, %eax + addl -96(%rbp), %eax + orl -100(%rbp), %eax + jne ..B1.136 +..B1.110: + movl -124(%rbp), %eax + cmpl $-2147483648, %eax + jne ..B1.136 +..B1.111: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) + jmp ..B1.136 +..B1.112: + movl -204(%rbp), %eax + testl %eax, %eax + je ..B1.114 +..B1.113: + movl -96(%rbp), %eax + cmpl $1048576, %eax + jb ..B1.120 +..B1.114: + movl -204(%rbp), %eax + testl %eax, %eax + jne ..B1.121 +..B1.115: + movl -96(%rbp), %eax + cmpl $1048575, %eax + jb ..B1.120 +..B1.116: + movl -96(%rbp), %eax + cmpl $1048575, %eax + jne ..B1.121 +..B1.117: + movl -100(%rbp), %eax + cmpl $-1, %eax + jb ..B1.120 +..B1.118: + movl -100(%rbp), %eax + cmpl $-1, %eax + jne ..B1.121 +..B1.119: + movl -124(%rbp), %eax + cmpl $-2147483648, %eax + jae ..B1.121 +..B1.120: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) +..B1.121: + movl -204(%rbp), %eax + testl %eax, %eax + jne ..B1.136 +..B1.122: + movl $1, %eax + addl -100(%rbp), %eax + movl %eax, -100(%rbp) + movl $1, %eax + movl $0, %edx + cmove %eax, %edx + addl -96(%rbp), %edx + movl %edx, -96(%rbp) + movl -96(%rbp), %eax + cmpl $2146435072, %eax + jb ..B1.136 +..B1.123: + shrl $31, -204(%rbp) + movl -204(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _large_value_64(%rip), %rdx + addq %rax, %rdx + movsd (%rdx), %xmm0 + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) + movsd %xmm0, -8(%rbp) + movsd -8(%rbp), %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.124: + movl -204(%rbp), %eax + testl %eax, %eax + jne ..B1.126 +..B1.125: + movl -96(%rbp), %eax + cmpl $1048576, %eax + jb ..B1.132 +..B1.126: + movl -204(%rbp), %eax + testl %eax, %eax + je ..B1.133 +..B1.127: + movl -96(%rbp), %eax + cmpl $1048575, %eax + jb ..B1.132 +..B1.128: + movl -96(%rbp), %eax + cmpl $1048575, %eax + jne ..B1.133 +..B1.129: + movl -100(%rbp), %eax + cmpl $-1, %eax + jb ..B1.132 +..B1.130: + movl -100(%rbp), %eax + cmpl $-1, %eax + jne ..B1.133 +..B1.131: + movl -124(%rbp), %eax + cmpl $-2147483648, %eax + jae ..B1.133 +..B1.132: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) +..B1.133: + movl -204(%rbp), %eax + testl %eax, %eax + je ..B1.136 +..B1.134: + movl $1, %eax + addl -100(%rbp), %eax + movl %eax, -100(%rbp) + movl $1, %eax + movl $0, %edx + cmove %eax, %edx + addl -96(%rbp), %edx + movl %edx, -96(%rbp) + movl -96(%rbp), %eax + cmpl $2146435072, %eax + jb ..B1.136 +..B1.135: + shrl $31, -204(%rbp) + movl -204(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _large_value_64(%rip), %rdx + addq %rax, %rdx + movsd (%rdx), %xmm0 + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, -16(%rbp) + movsd %xmm0, -8(%rbp) + movsd -8(%rbp), %xmm0 + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.136: + movl -96(%rbp), %eax + orl -204(%rbp), %eax + lea -8(%rbp), %rdx + addq $4, %rdx + movl %eax, (%rdx) + lea -8(%rbp), %rax + movl -100(%rbp), %edx + movl %edx, (%rax) + movsd -8(%rbp), %xmm0 + leave + .cfi_restore 6 + ret + .cfi_endproc + .type fma,@function + .size fma,.-fma + .data +# -- End fma + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmaf_gen.S b/external/sgx_libm/intel64/fmaf_gen.S new file mode 100644 index 0000000000..a51bcef8cb --- /dev/null +++ b/external/sgx_libm/intel64/fmaf_gen.S @@ -0,0 +1,683 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmaf_gen.c" + .text +..TXTST0: +# -- Begin fmaf + .text + .align 16,0x90 + .globl fmaf +fmaf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +# parameter 3: %xmm2 +..B1.1: + .cfi_startproc +..___tag_value_fmaf.1: +..L2: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + pushq %rbp + .cfi_def_cfa_offset 40 + .cfi_offset 6, -40 + subq $40, %rsp + .cfi_def_cfa_offset 80 + movss %xmm0, 8(%rsp) + movss %xmm1, 16(%rsp) + movss %xmm2, 24(%rsp) +..B1.2: + stmxcsr 12(%rsp) +..B1.3: + movl 16(%rsp), %r8d + movl %r8d, %ebp + movl 24(%rsp), %r11d + movl %r11d, %r10d + movl 8(%rsp), %esi + movl %esi, %ebx + movzwl 12(%rsp), %edi + andl $2147483647, %ebp + andl $24576, %edi + andl $2147483647, %r10d + andl $2147483647, %ebx + je ..B1.86 +..B1.4: + cmpl $2139095040, %ebx + jae ..B1.86 +..B1.5: + cmpl $1065353216, %ebx + je ..B1.86 +..B1.6: + testl %ebp, %ebp + je ..B1.86 +..B1.7: + cmpl $2139095040, %ebp + jae ..B1.86 +..B1.8: + cmpl $1065353216, %ebp + je ..B1.86 +..B1.9: + testl %r10d, %r10d + je ..B1.86 +..B1.10: + cmpl $2139095040, %r10d + jae ..B1.86 +..B1.11: + cmpl $8388608, %ebx + jae ..B1.13 +..B1.12: + movl %esi, %eax + orl $1065353216, %esi + movl %esi, 8(%rsp) + lea _ones(%rip), %rsi + shrl $31, %eax + movss 8(%rsp), %xmm0 + subss (%rsi,%rax,4), %xmm0 + movd %xmm0, %esi + movss %xmm0, 8(%rsp) + movl %esi, %ebx + andl $2147483647, %ebx + movl %ebx, %ecx + shrl $23, %ecx + addl $-126, %ecx + jmp ..B1.14 +..B1.13: + movl %ebx, %ecx + shrl $23, %ecx +..B1.14: + cmpl $8388608, %ebp + jae ..B1.16 +..B1.15: + movl %r8d, %eax + orl $1065353216, %r8d + movl %r8d, 16(%rsp) + lea _ones(%rip), %r8 + shrl $31, %eax + movss 16(%rsp), %xmm0 + subss (%r8,%rax,4), %xmm0 + movd %xmm0, %r8d + movss %xmm0, 16(%rsp) + movl %r8d, %ebp + andl $2147483647, %ebp + movl %ebp, %edx + shrl $23, %edx + addl $-126, %edx + jmp ..B1.17 +..B1.16: + movl %ebp, %edx + shrl $23, %edx +..B1.17: + cmpl $8388608, %r10d + jae ..B1.19 +..B1.18: + movl %r11d, %eax + orl $1065353216, %r11d + movl %r11d, 24(%rsp) + lea _ones(%rip), %r11 + shrl $31, %eax + movss 24(%rsp), %xmm0 + subss (%r11,%rax,4), %xmm0 + movd %xmm0, %r11d + movss %xmm0, 24(%rsp) + movl %r11d, %r10d + andl $2147483647, %r10d + movl %r10d, %eax + shrl $23, %eax + addl $-126, %eax + jmp ..B1.20 +..B1.19: + movl %r10d, %eax + shrl $23, %eax +..B1.20: + lea -127(%rcx,%rdx), %r9d + andq $8388607, %rbx + andq $8388607, %rbp + orq $8388608, %rbx + orq $8388608, %rbp + andl $8388607, %r10d + imulq %rbp, %rbx + movq %rbx, %rdx + xorl %r8d, %esi + shrq $32, %rdx + orl $8388608, %r10d + andl $-2147483648, %esi + movl %ebx, %ebp + testl $32768, %edx + je ..B1.22 +..B1.21: + shrq $24, %rbx + incl %r9d + shll $8, %ebp + jmp ..B1.23 +..B1.22: + shrq $23, %rbx + shll $9, %ebp +..B1.23: + cmpl %eax, %r9d + jg ..B1.26 +..B1.24: + jne ..B1.27 +..B1.25: + cmpl %r10d, %ebx + jb ..B1.27 +..B1.26: + movl %r9d, %r8d + xorl %edx, %edx + subl %eax, %r8d + movl %r10d, %eax + movl %r11d, %r10d + andl $-2147483648, %r10d + jmp ..B1.28 +..B1.27: + movl %eax, %r8d + movl %ebp, %edx + subl %r9d, %r8d + movl %eax, %r9d + movl %ebx, %eax + movl %r10d, %ebx + movl %esi, %r10d + movl %r11d, %esi + xorl %ebp, %ebp + andl $-2147483648, %esi +..B1.28: + xorl %r14d, %r14d + testl %r8d, %r8d + je ..B1.95 +..B1.29: + cmpl $32, %r8d + jge ..B1.31 +..B1.30: + movl %r8d, %r15d + movl %r8d, %ecx + negl %r15d + movl $-1, %r11d + shrl %cl, %r11d + movl %r15d, %ecx + movl %edx, %r14d + notl %r11d + shll %cl, %r14d + movl %r15d, %ecx + movl %eax, %r15d + shll %cl, %r15d + movl %r8d, %ecx + shrl %cl, %edx + andl %r11d, %r15d + movl %r8d, %ecx + orl %r15d, %edx + shrl %cl, %eax + movl $1, %r11d + jmp ..B1.34 +..B1.31: + cmpl $64, %r8d + jge ..B1.33 +..B1.32: + movl %r8d, %r14d + movl %r8d, %ecx + negl %r14d + movl $-1, %r11d + shrl %cl, %r11d + movl %r14d, %ecx + movl %eax, %r14d + notl %r11d + shll %cl, %r14d + movl %r8d, %ecx + andl %r11d, %r14d + movl $1, %r11d + testl %edx, %edx + cmovne %r11d, %edx + orl %edx, %r14d + movl %eax, %edx + shrl %cl, %edx + xorl %eax, %eax + jmp ..B1.34 +..B1.33: + movl $1, %r11d + orl %eax, %edx + cmovne %r11d, %r14d + xorl %edx, %edx + xorl %eax, %eax + jmp ..B1.34 +..B1.95: + movl $1, %r11d +..B1.34: + cmpl %r10d, %esi + jne ..B1.38 +..B1.35: + addl %ebp, %edx + addl %eax, %ebx + cmpl %ebp, %edx + movl $0, %ebp + setb %bpl + addl %ebp, %ebx + testl $16777216, %ebx + je ..B1.37 +..B1.36: + orl %r14d, %edx + movl %ebx, %eax + movl $0, %edx + cmovne %r11d, %edx + incl %r9d + shll $31, %eax + shrl $1, %ebx + orl %edx, %eax + andl $8388607, %ebx + jmp ..B1.54 +..B1.37: + testl %r14d, %r14d + movl %edx, %eax + cmovne %r11d, %r14d + andl $8388607, %ebx + orl %r14d, %eax + jmp ..B1.54 +..B1.38: + xorl %r8d, %r8d + negl %r14d + cmovne %r11d, %r8d + negl %edx + addl %ebp, %edx + subl %eax, %ebx + subl %r8d, %edx + cmpl %ebp, %edx + movl $0, %ebp + seta %bpl + subl %ebp, %ebx + je ..B1.40 +..B1.39: + movl %ebx, %eax + xorl %ebp, %ebp + shll $8, %eax + jmp ..B1.44 +..B1.40: + testl %edx, %edx + je ..B1.42 +..B1.41: + movl %edx, %eax + movl $24, %ebp + jmp ..B1.44 +..B1.42: + testl %r14d, %r14d + je ..B1.85 +..B1.43: + movl %r14d, %eax + movl $56, %ebp +..B1.44: + testl $-2147483648, %eax + jne ..B1.48 +..B1.46: + addl %eax, %eax + incl %ebp + testl $-2147483648, %eax + je ..B1.46 +..B1.48: + cmpl $32, %ebp + jge ..B1.50 +..B1.49: + movl %ebp, %eax + movl %ebp, %ecx + negl %eax + movl %edx, %r10d + shll %cl, %ebx + movl %eax, %ecx + shrl %cl, %r10d + movl %ebp, %ecx + movl %r11d, %r8d + testl %r14d, %r14d + cmovne %r11d, %r14d + shll %cl, %r8d + movl %ebp, %ecx + decl %r8d + shll %cl, %edx + andl %r8d, %r10d + orl %r10d, %ebx + movl %edx, %eax + andl $8388607, %ebx + orl %r14d, %eax + jmp ..B1.53 +..B1.50: + cmpl $64, %ebp + jge ..B1.52 +..B1.51: + movl %ebp, %eax + movl %ebp, %ecx + negl %eax + movl %r14d, %r8d + shll %cl, %edx + movl %eax, %ecx + shrl %cl, %r8d + movl %ebp, %ecx + movl %r11d, %ebx + movl %r14d, %eax + shll %cl, %ebx + movl %ebp, %ecx + decl %ebx + andl %ebx, %r8d + orl %r8d, %edx + movl %edx, %ebx + shll %cl, %eax + andl $8388607, %ebx + jmp ..B1.53 +..B1.52: + movl %ebp, %ecx + xorl %eax, %eax + shll %cl, %r14d + movl %r14d, %ebx + andl $8388607, %ebx +..B1.53: + subl %ebp, %r9d +..B1.54: + lea -1(%r9), %edx + cmpl $254, %edx + jb ..B1.60 +..B1.55: + cmpl $255, %r9d + jge ..B1.90 +..B1.56: + negl %r9d + incl %r9d + cmpl $24, %r9d + jg ..B1.58 +..B1.57: + movl %r9d, %edx + movl %r9d, %ecx + negl %edx + movl $-1, %ebp + orl $8388608, %ebx + testl %eax, %eax + movl %ebx, %r8d + cmovne %r11d, %eax + shrl %cl, %ebp + movl %edx, %ecx + shll %cl, %r8d + notl %ebp + andl %ebp, %r8d + movl %r9d, %ecx + shrl %cl, %ebx + orl %r8d, %eax + jmp ..B1.61 +..B1.58: + movl %r11d, %eax + xorl %ebx, %ebx + jmp ..B1.62 +..B1.60: + shll $23, %r9d + orl %r9d, %ebx +..B1.61: + testl %eax, %eax + je ..B1.84 +..B1.62: + movl $1065353216, (%rsp) + testl %edi, %edi + je ..B1.87 +..B1.63: + cmpl $24576, %edi + je ..B1.80 +..B1.64: + cmpl $16384, %edi + jne ..B1.72 +..B1.65: + testl %esi, %esi + je ..B1.67 +..B1.66: + cmpl $8388608, %ebx + jb ..B1.70 + jmp ..B1.84 +..B1.67: + cmpl $8388607, %ebx + jb ..B1.70 +..B1.68: + jne ..B1.71 +..B1.69: + cmpl $-2147483648, %eax + jae ..B1.71 +..B1.70: + movss .L_2il0floatpacket.1(%rip), %xmm0 + testl %esi, %esi + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) + jne ..B1.84 +..B1.71: + incl %ebx + cmpl $2139095040, %ebx + jae ..B1.90 + jmp ..B1.84 +..B1.72: + cmpl $8192, %edi + jne ..B1.84 +..B1.73: + testl %esi, %esi + jne ..B1.75 +..B1.74: + cmpl $8388608, %ebx + jb ..B1.78 + jmp ..B1.84 +..B1.75: + cmpl $8388607, %ebx + jb ..B1.78 +..B1.76: + jne ..B1.79 +..B1.77: + cmpl $-2147483648, %eax + jae ..B1.79 +..B1.78: + movss .L_2il0floatpacket.1(%rip), %xmm0 + testl %esi, %esi + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) + je ..B1.84 +..B1.79: + incl %ebx + cmpl $2139095040, %ebx + jae ..B1.90 + jmp ..B1.84 +..B1.80: + cmpl $8388608, %ebx + jb ..B1.83 +..B1.81: + jne ..B1.84 +..B1.82: + cmpl $-2147483648, %eax + jne ..B1.84 +..B1.83: + movss .L_2il0floatpacket.1(%rip), %xmm0 + mulss %xmm0, %xmm0 + movss %xmm0, (%rsp) +..B1.84: + orl %ebx, %esi + movl %esi, 4(%rsp) + movss 4(%rsp), %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.85: + xorl %edx, %edx + cmpl $8192, %edi + lea _zeros(%rip), %rcx + sete %dl + movss (%rcx,%rdx,4), %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.86: + movss 8(%rsp), %xmm0 + mulss 16(%rsp), %xmm0 + addss 24(%rsp), %xmm0 + movss %xmm0, 4(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.87: + testl $-2147483648, %eax + je ..B1.80 +..B1.88: + movl %ebx, %ecx + movl %eax, %edx + andl $1, %ecx + andl $2147483647, %edx + orl %edx, %ecx + je ..B1.80 +..B1.89: + incl %ebx + cmpl $2139095040, %ebx + jb ..B1.80 +..B1.90: + lea _large_value_32(%rip), %rax + shrl $31, %esi + movss (%rax,%rsi,4), %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, (%rsp) + movss %xmm0, 4(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fmaf,@function + .size fmaf,.-fmaf + .data +# -- End fmaf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x71800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x0d800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x3f800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmal.S b/external/sgx_libm/intel64/fmal.S new file mode 100644 index 0000000000..6f18fb06bb --- /dev/null +++ b/external/sgx_libm/intel64/fmal.S @@ -0,0 +1,2062 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmal.c" + .text +..TXTST0: +# -- Begin fmal + .text + + .globl fmal +fmal: +# parameter 1: 16 + %rbp +# parameter 2: 32 + %rbp +# parameter 3: 48 + %rbp +..B1.1: + .cfi_startproc +..___tag_value_fmal.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_def_cfa 6, 16 + .cfi_offset 6, -16 + subq $336, %rsp + lea 16(%rbp), %rax + movq %rax, -128(%rbp) + lea 32(%rbp), %rax + movq %rax, -120(%rbp) + lea 48(%rbp), %rax + movq %rax, -112(%rbp) + lea -32(%rbp), %rax + movq %rax, -104(%rbp) + movl $0, -328(%rbp) +..B1.2: + fnstcw -336(%rbp) +..B1.3: + fnstcw -334(%rbp) +..B1.4: + movzwl -334(%rbp), %eax + movzwl %ax, %eax + andl $3072, %eax + movl %eax, -324(%rbp) + movq -128(%rbp), %rax + movzbl 9(%rax), %eax + movzbl %al, %eax + andl $128, %eax + shrl $7, %eax + movl %eax, -320(%rbp) + movq -128(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $32767, %eax + movl %eax, -316(%rbp) + movq -120(%rbp), %rax + movzbl 9(%rax), %eax + movzbl %al, %eax + andl $128, %eax + shrl $7, %eax + movl %eax, -312(%rbp) + movq -120(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $32767, %eax + movl %eax, -308(%rbp) + movq -112(%rbp), %rax + movzbl 9(%rax), %eax + movzbl %al, %eax + andl $128, %eax + shrl $7, %eax + movl %eax, -304(%rbp) + movq -112(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $32767, %eax + movl %eax, -300(%rbp) + movl -316(%rbp), %eax + cmpl $32767, %eax + je ..B1.22 +..B1.5: + movl -316(%rbp), %eax + testl %eax, %eax + jne ..B1.8 +..B1.6: + movq -128(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.8 +..B1.7: + movq -128(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.22 +..B1.8: + movl -316(%rbp), %eax + cmpl $16383, %eax + jne ..B1.11 +..B1.9: + movq -128(%rbp), %rax + movl 4(%rax), %eax + cmpl $-2147483648, %eax + jne ..B1.11 +..B1.10: + movq -128(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.22 +..B1.11: + movl -308(%rbp), %eax + cmpl $32767, %eax + je ..B1.22 +..B1.12: + movl -308(%rbp), %eax + testl %eax, %eax + jne ..B1.15 +..B1.13: + movq -120(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.15 +..B1.14: + movq -120(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.22 +..B1.15: + movl -308(%rbp), %eax + cmpl $16383, %eax + jne ..B1.18 +..B1.16: + movq -120(%rbp), %rax + movl 4(%rax), %eax + cmpl $-2147483648, %eax + jne ..B1.18 +..B1.17: + movq -120(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.22 +..B1.18: + movl -300(%rbp), %eax + cmpl $32767, %eax + je ..B1.22 +..B1.19: + movl -300(%rbp), %eax + testl %eax, %eax + jne ..B1.87 +..B1.20: + movq -112(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.87 +..B1.21: + movq -112(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + jne ..B1.87 +..B1.22: + movl -316(%rbp), %eax + testl %eax, %eax + jne ..B1.25 +..B1.23: + movq -128(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.31 +..B1.24: + movq -128(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + jne ..B1.31 +..B1.25: + movl -308(%rbp), %eax + testl %eax, %eax + jne ..B1.28 +..B1.26: + movq -120(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.31 +..B1.27: + movq -120(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + jne ..B1.31 +..B1.28: + movl -300(%rbp), %eax + testl %eax, %eax + jne ..B1.32 +..B1.29: + movq -112(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.31 +..B1.30: + movq -112(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.32 +..B1.31: + lea _smallest_value_64(%rip), %rax + movsd (%rax), %xmm0 + movsd %xmm0, -96(%rbp) +..B1.32: + movl -316(%rbp), %eax + cmpl $32767, %eax + jne ..B1.43 +..B1.33: + movq -128(%rbp), %rax + movl 4(%rax), %eax + cmpl $-2147483648, %eax + jne ..B1.35 +..B1.34: + movq -128(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.43 +..B1.35: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.39 +..B1.36: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $-769, %eax + orl $768, %eax + movw %ax, -332(%rbp) +..B1.37: + fldcw -332(%rbp) +..B1.38: + movl $1, -328(%rbp) +..B1.39: + fldt 16(%rbp) + fldt 32(%rbp) + fmulp %st, %st(1) + fstpt -32(%rbp) + fldt -32(%rbp) + fldt 48(%rbp) + fmulp %st, %st(1) + fstpt -32(%rbp) + movl -328(%rbp), %eax + testl %eax, %eax + je ..B1.42 +..B1.40: + fldcw -336(%rbp) +..B1.41: + movl $0, -328(%rbp) +..B1.42: + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.43: + movl -308(%rbp), %eax + cmpl $32767, %eax + jne ..B1.54 +..B1.44: + movq -120(%rbp), %rax + movl 4(%rax), %eax + cmpl $-2147483648, %eax + jne ..B1.46 +..B1.45: + movq -120(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.54 +..B1.46: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.50 +..B1.47: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $-769, %eax + orl $768, %eax + movw %ax, -332(%rbp) +..B1.48: + fldcw -332(%rbp) +..B1.49: + movl $1, -328(%rbp) +..B1.50: + fldt 32(%rbp) + fldt 48(%rbp) + fmulp %st, %st(1) + fstpt -32(%rbp) + fldt -32(%rbp) + fldt 16(%rbp) + fmulp %st, %st(1) + fstpt -32(%rbp) + movl -328(%rbp), %eax + testl %eax, %eax + je ..B1.53 +..B1.51: + fldcw -336(%rbp) +..B1.52: + movl $0, -328(%rbp) +..B1.53: + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.54: + movl -300(%rbp), %eax + cmpl $32767, %eax + jne ..B1.65 +..B1.55: + movq -112(%rbp), %rax + movl 4(%rax), %eax + cmpl $-2147483648, %eax + jne ..B1.57 +..B1.56: + movq -112(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.65 +..B1.57: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.61 +..B1.58: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $-769, %eax + orl $768, %eax + movw %ax, -332(%rbp) +..B1.59: + fldcw -332(%rbp) +..B1.60: + movl $1, -328(%rbp) +..B1.61: + fldt 48(%rbp) + fldt 16(%rbp) + fmulp %st, %st(1) + fstpt -32(%rbp) + fldt -32(%rbp) + fldt 32(%rbp) + fmulp %st, %st(1) + fstpt -32(%rbp) + movl -328(%rbp), %eax + testl %eax, %eax + je ..B1.64 +..B1.62: + fldcw -336(%rbp) +..B1.63: + movl $0, -328(%rbp) +..B1.64: + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.65: + movl -316(%rbp), %eax + cmpl $32767, %eax + jge ..B1.69 +..B1.66: + movl -308(%rbp), %eax + cmpl $32767, %eax + jge ..B1.69 +..B1.67: + movl -300(%rbp), %eax + cmpl $32767, %eax + jne ..B1.69 +..B1.68: + fldt 48(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.69: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.73 +..B1.70: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $-769, %eax + orl $768, %eax + movw %ax, -332(%rbp) +..B1.71: + fldcw -332(%rbp) +..B1.72: + movl $1, -328(%rbp) +..B1.73: + fldt 16(%rbp) + fldt 32(%rbp) + fmulp %st, %st(1) + fstpt -32(%rbp) + movq -128(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + jne ..B1.76 +..B1.74: + movq -128(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.76 +..B1.75: + movq -128(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.82 +..B1.76: + movq -120(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + jne ..B1.79 +..B1.77: + movq -120(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.79 +..B1.78: + movq -120(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.82 +..B1.79: + movq -104(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + jne ..B1.82 +..B1.80: + movq -104(%rbp), %rax + movl 4(%rax), %eax + testl %eax, %eax + jne ..B1.82 +..B1.81: + movq -104(%rbp), %rax + movl (%rax), %eax + testl %eax, %eax + je ..B1.83 +..B1.82: + fldt -32(%rbp) + fldt 48(%rbp) + faddp %st, %st(1) + fstpt -32(%rbp) +..B1.83: + movl -328(%rbp), %eax + testl %eax, %eax + je ..B1.86 +..B1.84: + fldcw -336(%rbp) +..B1.85: + movl $0, -328(%rbp) +..B1.86: + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.87: + movq -128(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + je ..B1.90 +..B1.88: + movq -120(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + je ..B1.90 +..B1.89: + movq -112(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + jne ..B1.103 +..B1.90: + lea _smallest_value_64(%rip), %rax + movsd (%rax), %xmm0 + movsd %xmm0, -96(%rbp) + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.94 +..B1.91: + movzwl -336(%rbp), %eax + movzwl %ax, %eax + andl $-769, %eax + orl $768, %eax + movw %ax, -332(%rbp) +..B1.92: + fldcw -332(%rbp) +..B1.93: + movl $1, -328(%rbp) +..B1.94: + movq -128(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + jne ..B1.96 +..B1.95: + movq -128(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $-32768, %eax + orl $16383, %eax + movq -128(%rbp), %rdx + movw %ax, 8(%rdx) + movq -128(%rbp), %rax + movl 4(%rax), %eax + orl $-2147483648, %eax + movq -128(%rbp), %rdx + movl %eax, 4(%rdx) + movl -320(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _ones(%rip), %rdx + addq %rax, %rdx + movsd (%rdx), %xmm0 + movsd %xmm0, -48(%rbp) + fldl -48(%rbp) + fldt 16(%rbp) + fsubp %st, %st(1) + fstpt 16(%rbp) + movq -128(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $32767, %eax + addl $-16382, %eax + movl %eax, -316(%rbp) +..B1.96: + movq -120(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + jne ..B1.98 +..B1.97: + movq -120(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $-32768, %eax + orl $16383, %eax + movq -120(%rbp), %rdx + movw %ax, 8(%rdx) + movq -120(%rbp), %rax + movl 4(%rax), %eax + orl $-2147483648, %eax + movq -120(%rbp), %rdx + movl %eax, 4(%rdx) + movl -312(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _ones(%rip), %rdx + addq %rax, %rdx + movsd (%rdx), %xmm0 + movsd %xmm0, -48(%rbp) + fldl -48(%rbp) + fldt 32(%rbp) + fsubp %st, %st(1) + fstpt 32(%rbp) + movq -120(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $32767, %eax + addl $-16382, %eax + movl %eax, -308(%rbp) +..B1.98: + movq -112(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + testl $32767, %eax + jne ..B1.100 +..B1.99: + movq -112(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $-32768, %eax + orl $16383, %eax + movq -112(%rbp), %rdx + movw %ax, 8(%rdx) + movq -112(%rbp), %rax + movl 4(%rax), %eax + orl $-2147483648, %eax + movq -112(%rbp), %rdx + movl %eax, 4(%rdx) + movl -304(%rbp), %eax + movslq %eax, %rax + shlq $3, %rax + lea _ones(%rip), %rdx + addq %rax, %rdx + movsd (%rdx), %xmm0 + movsd %xmm0, -48(%rbp) + fldl -48(%rbp) + fldt 48(%rbp) + fsubp %st, %st(1) + fstpt 48(%rbp) + movq -112(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $32767, %eax + addl $-16382, %eax + movl %eax, -300(%rbp) +..B1.100: + movl -328(%rbp), %eax + testl %eax, %eax + je ..B1.103 +..B1.101: + fldcw -336(%rbp) +..B1.102: + movl $0, -328(%rbp) +..B1.103: + movq -128(%rbp), %rax + movl 4(%rax), %eax + movl %eax, -296(%rbp) + movq -128(%rbp), %rax + movl (%rax), %eax + movl %eax, -292(%rbp) + movq -120(%rbp), %rax + movl 4(%rax), %eax + movl %eax, -288(%rbp) + movq -120(%rbp), %rax + movl (%rax), %eax + movl %eax, -284(%rbp) + movq -112(%rbp), %rax + movl 4(%rax), %eax + movl %eax, -280(%rbp) + movq -112(%rbp), %rax + movl (%rax), %eax + movl %eax, -276(%rbp) + movl -312(%rbp), %eax + xorl -320(%rbp), %eax + movl %eax, -272(%rbp) + movl -308(%rbp), %eax + addl -316(%rbp), %eax + addl $-16383, %eax + movl %eax, -268(%rbp) + movl -284(%rbp), %eax + movl -292(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -88(%rbp) + movq -88(%rbp), %rax + shrq $32, %rax + movl %eax, -264(%rbp) + movl -88(%rbp), %eax + movl %eax, -260(%rbp) + movl -284(%rbp), %eax + movl -296(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -80(%rbp) + movq -80(%rbp), %rax + shrq $32, %rax + movl %eax, -256(%rbp) + movl -80(%rbp), %eax + movl %eax, -252(%rbp) + movl -288(%rbp), %eax + movl -292(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -72(%rbp) + movq -72(%rbp), %rax + shrq $32, %rax + movl %eax, -248(%rbp) + movl -72(%rbp), %eax + movl %eax, -244(%rbp) + movl -288(%rbp), %eax + movl -296(%rbp), %edx + imulq %rax, %rdx + movq %rdx, -64(%rbp) + movq -64(%rbp), %rax + shrq $32, %rax + movl %eax, -240(%rbp) + movl -64(%rbp), %eax + movl %eax, -236(%rbp) + movl -260(%rbp), %eax + movl %eax, -232(%rbp) + movl -264(%rbp), %eax + movq %rax, -56(%rbp) + movl -252(%rbp), %eax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -244(%rbp), %eax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -228(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -224(%rbp) + movl -236(%rbp), %eax + movq %rax, -56(%rbp) + movl -256(%rbp), %eax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -248(%rbp), %eax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -224(%rbp), %eax + movslq %eax, %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -220(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -224(%rbp) + movl -224(%rbp), %eax + addl -240(%rbp), %eax + movl %eax, -216(%rbp) + movl -216(%rbp), %eax + testl $-2147483648, %eax + je ..B1.105 +..B1.104: + movl $1, %eax + addl -268(%rbp), %eax + movl %eax, -268(%rbp) + jmp ..B1.106 +..B1.105: + movl -216(%rbp), %eax + shll $1, %eax + movl -220(%rbp), %edx + shrl $31, %edx + orl %edx, %eax + movl %eax, -216(%rbp) + movl -220(%rbp), %eax + shll $1, %eax + movl -228(%rbp), %edx + shrl $31, %edx + orl %edx, %eax + movl %eax, -220(%rbp) + movl -228(%rbp), %eax + shll $1, %eax + movl -232(%rbp), %edx + shrl $31, %edx + orl %edx, %eax + movl %eax, -228(%rbp) + shll $1, -232(%rbp) +..B1.106: + movl -268(%rbp), %eax + movl -300(%rbp), %edx + cmpl %edx, %eax + jg ..B1.111 +..B1.107: + movl -268(%rbp), %eax + movl -300(%rbp), %edx + cmpl %edx, %eax + jne ..B1.112 +..B1.108: + movl -216(%rbp), %eax + movl -280(%rbp), %edx + cmpl %edx, %eax + ja ..B1.111 +..B1.109: + movl -216(%rbp), %eax + movl -280(%rbp), %edx + cmpl %edx, %eax + jne ..B1.112 +..B1.110: + movl -220(%rbp), %eax + movl -276(%rbp), %edx + cmpl %edx, %eax + jb ..B1.112 +..B1.111: + movl -300(%rbp), %eax + negl %eax + addl -268(%rbp), %eax + movl %eax, -212(%rbp) + movl -280(%rbp), %eax + movl %eax, -208(%rbp) + movl -276(%rbp), %eax + movl %eax, -204(%rbp) + movl $0, %eax + movl %eax, -200(%rbp) + movl %eax, -196(%rbp) + jmp ..B1.113 +..B1.112: + movl -268(%rbp), %eax + negl %eax + addl -300(%rbp), %eax + movl %eax, -212(%rbp) + movl -300(%rbp), %eax + movl %eax, -268(%rbp) + movl -216(%rbp), %eax + movl %eax, -208(%rbp) + movl -220(%rbp), %eax + movl %eax, -204(%rbp) + movl -228(%rbp), %eax + movl %eax, -196(%rbp) + movl -232(%rbp), %eax + movl %eax, -200(%rbp) + movl -280(%rbp), %eax + movl %eax, -216(%rbp) + movl -276(%rbp), %eax + movl %eax, -220(%rbp) + movl $0, %eax + movl %eax, -232(%rbp) + movl %eax, -228(%rbp) + movl -272(%rbp), %eax + movl %eax, -304(%rbp) + movq -112(%rbp), %rax + movzbl 9(%rax), %eax + movzbl %al, %eax + andl $128, %eax + shrl $7, %eax + movl %eax, -272(%rbp) +..B1.113: + movl $0, -192(%rbp) + movl -212(%rbp), %eax + testl %eax, %eax + je ..B1.123 +..B1.114: + movl -212(%rbp), %eax + cmpl $32, %eax + jge ..B1.116 +..B1.115: + movl -212(%rbp), %eax + negl %eax + addl $32, %eax + movl %eax, -188(%rbp) + movl -212(%rbp), %eax + movl %eax, -184(%rbp) + movl $-1, %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -180(%rbp) + movl -200(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl %eax, -192(%rbp) + movl -196(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -200(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -200(%rbp) + movl -204(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -196(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -196(%rbp) + movl -208(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -204(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -204(%rbp) + movl -184(%rbp), %eax + movl %eax, %ecx + shrl %cl, -208(%rbp) + jmp ..B1.123 +..B1.116: + movl -212(%rbp), %eax + cmpl $64, %eax + jge ..B1.118 +..B1.117: + movl -212(%rbp), %eax + negl %eax + addl $64, %eax + movl %eax, -188(%rbp) + movl $-32, %eax + addl -212(%rbp), %eax + movl %eax, -184(%rbp) + movl $-1, %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -180(%rbp) + movl -196(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -200(%rbp), %edx + movl $1, %ecx + testl %edx, %edx + cmovne %ecx, %edx + orl %edx, %eax + movl %eax, -192(%rbp) + movl -204(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -196(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -200(%rbp) + movl -208(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -204(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -196(%rbp) + movl -208(%rbp), %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -204(%rbp) + movl $0, -208(%rbp) + jmp ..B1.123 +..B1.118: + movl -212(%rbp), %eax + cmpl $96, %eax + jge ..B1.120 +..B1.119: + movl -212(%rbp), %eax + negl %eax + addl $96, %eax + movl %eax, -188(%rbp) + movl $-64, %eax + addl -212(%rbp), %eax + movl %eax, -184(%rbp) + movl $-1, %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -180(%rbp) + movl -204(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -200(%rbp), %edx + orl -196(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -192(%rbp) + movl -208(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -204(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -200(%rbp) + movl -208(%rbp), %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -196(%rbp) + movl $0, %eax + movl %eax, -204(%rbp) + movl %eax, -208(%rbp) + jmp ..B1.123 +..B1.120: + movl -212(%rbp), %eax + cmpl $128, %eax + jge ..B1.122 +..B1.121: + movl -212(%rbp), %eax + negl %eax + addl $128, %eax + movl %eax, -188(%rbp) + movl $-96, %eax + addl -212(%rbp), %eax + movl %eax, -184(%rbp) + movl $-1, %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -180(%rbp) + movl -208(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -196(%rbp), %edx + orl -204(%rbp), %edx + orl -200(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -192(%rbp) + movl -208(%rbp), %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -200(%rbp) + movl $0, -196(%rbp) + movl $0, %eax + movl %eax, -204(%rbp) + movl %eax, -208(%rbp) + jmp ..B1.123 +..B1.122: + movl -204(%rbp), %eax + orl -208(%rbp), %eax + orl -196(%rbp), %eax + orl -200(%rbp), %eax + movl $1, %eax + movl $0, %edx + cmovne %eax, %edx + movl %edx, -192(%rbp) + movl $0, -200(%rbp) + movl $0, -196(%rbp) + movl $0, %eax + movl %eax, -204(%rbp) + movl %eax, -208(%rbp) +..B1.123: + movl -272(%rbp), %eax + movl -304(%rbp), %edx + cmpl %edx, %eax + jne ..B1.130 +..B1.124: + movl -232(%rbp), %eax + movl %eax, -176(%rbp) + movl -200(%rbp), %eax + addl -232(%rbp), %eax + movl %eax, -232(%rbp) + movl -232(%rbp), %eax + movl -176(%rbp), %edx + cmpl %edx, %eax + jb ..B1.126 +..B1.125: + movl $0, -224(%rbp) + jmp ..B1.127 +..B1.126: + movl $1, -224(%rbp) +..B1.127: + movl -228(%rbp), %eax + movq %rax, -56(%rbp) + movl -196(%rbp), %eax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -224(%rbp), %eax + movslq %eax, %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -228(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -224(%rbp) + movl -220(%rbp), %eax + movq %rax, -56(%rbp) + movl -204(%rbp), %eax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -224(%rbp), %eax + movslq %eax, %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -220(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -224(%rbp) + movl -216(%rbp), %eax + movq %rax, -56(%rbp) + movl -208(%rbp), %eax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -224(%rbp), %eax + movslq %eax, %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -216(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -224(%rbp) + movl -224(%rbp), %eax + testl %eax, %eax + je ..B1.129 +..B1.128: + movl -220(%rbp), %eax + shll $31, %eax + movl -232(%rbp), %edx + orl -228(%rbp), %edx + orl -192(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -192(%rbp) + movl -216(%rbp), %eax + shll $31, %eax + movl -220(%rbp), %edx + shrl $1, %edx + orl %edx, %eax + movl %eax, -168(%rbp) + movl -216(%rbp), %eax + shrl $1, %eax + orl $-2147483648, %eax + movl %eax, -164(%rbp) + movl $1, %eax + addl -268(%rbp), %eax + movl %eax, -268(%rbp) + jmp ..B1.156 +..B1.129: + movl -228(%rbp), %eax + movl -192(%rbp), %edx + orl -232(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -192(%rbp) + movl -220(%rbp), %eax + movl %eax, -168(%rbp) + movl -216(%rbp), %eax + movl %eax, -164(%rbp) + jmp ..B1.156 +..B1.130: + movl -192(%rbp), %eax + negl %eax + movl %eax, -192(%rbp) + movl -192(%rbp), %eax + testl %eax, %eax + jne ..B1.132 +..B1.131: + movl $0, -172(%rbp) + jmp ..B1.133 +..B1.132: + movl $1, -172(%rbp) +..B1.133: + movl -232(%rbp), %eax + movq %rax, -56(%rbp) + movl -200(%rbp), %eax + negq %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -172(%rbp), %eax + movslq %eax, %rax + negq %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -232(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -172(%rbp) + movl -228(%rbp), %eax + movq %rax, -56(%rbp) + movl -196(%rbp), %eax + negq %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -172(%rbp), %eax + movslq %eax, %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -228(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -172(%rbp) + movl -220(%rbp), %eax + movq %rax, -56(%rbp) + movl -204(%rbp), %eax + negq %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -172(%rbp), %eax + movslq %eax, %rax + addq -56(%rbp), %rax + movq %rax, -56(%rbp) + movl -56(%rbp), %eax + movl %eax, -220(%rbp) + movq -56(%rbp), %rax + shrq $32, %rax + movl %eax, -172(%rbp) + movl -208(%rbp), %eax + negl %eax + addl -216(%rbp), %eax + movl %eax, -216(%rbp) + movl -172(%rbp), %eax + addl -216(%rbp), %eax + movl %eax, -216(%rbp) + movl -216(%rbp), %eax + testl %eax, %eax + je ..B1.135 +..B1.134: + movl -216(%rbp), %eax + movl %eax, -176(%rbp) + movl $0, -212(%rbp) + jmp ..B1.144 +..B1.135: + movl -220(%rbp), %eax + testl %eax, %eax + je ..B1.137 +..B1.136: + movl -220(%rbp), %eax + movl %eax, -176(%rbp) + movl $32, -212(%rbp) + jmp ..B1.144 +..B1.137: + movl -228(%rbp), %eax + testl %eax, %eax + je ..B1.139 +..B1.138: + movl -228(%rbp), %eax + movl %eax, -176(%rbp) + movl $64, -212(%rbp) + jmp ..B1.144 +..B1.139: + movl -232(%rbp), %eax + testl %eax, %eax + je ..B1.141 +..B1.140: + movl -232(%rbp), %eax + movl %eax, -176(%rbp) + movl $96, -212(%rbp) + jmp ..B1.144 +..B1.141: + movl -192(%rbp), %eax + testl %eax, %eax + je ..B1.143 +..B1.142: + movl -192(%rbp), %eax + movl %eax, -176(%rbp) + movl $128, -212(%rbp) + jmp ..B1.144 +..B1.143: + movl -324(%rbp), %eax + movl $1, %edx + movl $0, %ecx + cmpl $1024, %eax + cmove %edx, %ecx + movslq %ecx, %rcx + shlq $3, %rcx + lea _zeros(%rip), %rax + addq %rcx, %rax + movsd (%rax), %xmm0 + movsd %xmm0, -48(%rbp) + fldl -48(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.144: + movl -176(%rbp), %eax + testl $-2147483648, %eax + jne ..B1.146 +..B1.145: + shll $1, -176(%rbp) + movl $1, %eax + addl -212(%rbp), %eax + movl %eax, -212(%rbp) + jmp ..B1.144 +..B1.146: + movl -212(%rbp), %eax + cmpl $32, %eax + jge ..B1.148 +..B1.147: + movl -212(%rbp), %eax + movl %eax, -188(%rbp) + movl -212(%rbp), %eax + negl %eax + addl $32, %eax + movl %eax, -184(%rbp) + movl $1, %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -160(%rbp) + movl -228(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -192(%rbp), %edx + orl -232(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -192(%rbp) + movl -220(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -228(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + andl -160(%rbp), %edx + orl %edx, %eax + movl %eax, -168(%rbp) + movl -216(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -220(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + andl -160(%rbp), %edx + orl %edx, %eax + movl %eax, -164(%rbp) + jmp ..B1.155 +..B1.148: + movl -212(%rbp), %eax + cmpl $64, %eax + jge ..B1.150 +..B1.149: + movl $-32, %eax + addl -212(%rbp), %eax + movl %eax, -188(%rbp) + movl -212(%rbp), %eax + negl %eax + addl $64, %eax + movl %eax, -184(%rbp) + movl $1, %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -160(%rbp) + movl -232(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -192(%rbp), %edx + movl $1, %ecx + testl %edx, %edx + cmovne %ecx, %edx + orl %edx, %eax + movl %eax, -192(%rbp) + movl -228(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -232(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + andl -160(%rbp), %edx + orl %edx, %eax + movl %eax, -168(%rbp) + movl -220(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -228(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + andl -160(%rbp), %edx + orl %edx, %eax + movl %eax, -164(%rbp) + jmp ..B1.155 +..B1.150: + movl -212(%rbp), %eax + cmpl $96, %eax + jge ..B1.152 +..B1.151: + movl $-64, %eax + addl -212(%rbp), %eax + movl %eax, -188(%rbp) + movl -212(%rbp), %eax + negl %eax + addl $96, %eax + movl %eax, -184(%rbp) + movl $1, %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -160(%rbp) + movl -188(%rbp), %eax + movl %eax, %ecx + shll %cl, -192(%rbp) + movl -232(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -192(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + andl -160(%rbp), %edx + orl %edx, %eax + movl %eax, -168(%rbp) + movl -228(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -232(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + andl -160(%rbp), %edx + orl %edx, %eax + movl %eax, -164(%rbp) + jmp ..B1.155 +..B1.152: + movl -212(%rbp), %eax + cmpl $128, %eax + jge ..B1.154 +..B1.153: + movl $-96, %eax + addl -212(%rbp), %eax + movl %eax, -188(%rbp) + movl -212(%rbp), %eax + negl %eax + addl $128, %eax + movl %eax, -184(%rbp) + movl $1, %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + decl %eax + movl %eax, -160(%rbp) + movl $0, -192(%rbp) + movl -192(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl %eax, -168(%rbp) + movl -232(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl -192(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + andl -160(%rbp), %edx + orl %edx, %eax + movl %eax, -164(%rbp) + jmp ..B1.155 +..B1.154: + movl $-128, %eax + addl -212(%rbp), %eax + movl %eax, -188(%rbp) + movl $0, %eax + movl %eax, -168(%rbp) + movl %eax, -192(%rbp) + movl -192(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + movl %eax, -164(%rbp) +..B1.155: + movl -212(%rbp), %eax + negl %eax + addl -268(%rbp), %eax + movl %eax, -268(%rbp) +..B1.156: + movl $-1, %eax + addl -268(%rbp), %eax + cmpl $32766, %eax + jb ..B1.167 +..B1.157: + movl -268(%rbp), %eax + cmpl $32767, %eax + jl ..B1.159 +..B1.158: + movl -272(%rbp), %eax + movslq %eax, %rax + shlq $4, %rax + lea _large_value_80(%rip), %rdx + addq %rax, %rdx + fldt (%rdx) + lea _large_value_80(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt -16(%rbp) + fldt -16(%rbp) + fstpt -32(%rbp) + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.159: + movl -268(%rbp), %eax + negl %eax + incl %eax + movl %eax, -212(%rbp) + movl -212(%rbp), %eax + cmpl $32, %eax + jge ..B1.161 +..B1.160: + movl -212(%rbp), %eax + negl %eax + addl $32, %eax + movl %eax, -188(%rbp) + movl -212(%rbp), %eax + movl %eax, -184(%rbp) + movl $-1, %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -180(%rbp) + movl -168(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -192(%rbp), %edx + movl $1, %ecx + testl %edx, %edx + cmovne %ecx, %edx + orl %edx, %eax + movl %eax, -192(%rbp) + movl -164(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -168(%rbp), %edx + movl -184(%rbp), %ecx + shrl %cl, %edx + orl %edx, %eax + movl %eax, -168(%rbp) + movl -184(%rbp), %eax + movl %eax, %ecx + shrl %cl, -164(%rbp) + jmp ..B1.166 +..B1.161: + movl -212(%rbp), %eax + cmpl $64, %eax + jge ..B1.163 +..B1.162: + movl -212(%rbp), %eax + negl %eax + addl $64, %eax + movl %eax, -188(%rbp) + movl $-32, %eax + addl -212(%rbp), %eax + movl %eax, -184(%rbp) + movl $-1, %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -180(%rbp) + movl -164(%rbp), %eax + movl -188(%rbp), %edx + movl %edx, %ecx + shll %cl, %eax + andl -180(%rbp), %eax + movl -192(%rbp), %edx + orl -168(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -192(%rbp) + movl -164(%rbp), %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl %eax, -168(%rbp) + movl $0, -164(%rbp) + jmp ..B1.166 +..B1.163: + movl -212(%rbp), %eax + cmpl $96, %eax + jge ..B1.165 +..B1.164: + movl -212(%rbp), %eax + negl %eax + addl $96, %eax + movl %eax, -188(%rbp) + movl $-64, %eax + addl -212(%rbp), %eax + movl %eax, -184(%rbp) + movl $-1, %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + notl %eax + movl %eax, -180(%rbp) + movl -164(%rbp), %eax + movl -184(%rbp), %edx + movl %edx, %ecx + shrl %cl, %eax + movl -164(%rbp), %edx + movl -188(%rbp), %ecx + shll %cl, %edx + andl -180(%rbp), %edx + orl -168(%rbp), %edx + orl -192(%rbp), %edx + movl $1, %edx + movl $0, %ecx + cmovne %edx, %ecx + orl %ecx, %eax + movl %eax, -192(%rbp) + movl $0, %eax + movl %eax, -168(%rbp) + movl %eax, -164(%rbp) + jmp ..B1.166 +..B1.165: + movl $1, -192(%rbp) + movl $0, %eax + movl %eax, -168(%rbp) + movl %eax, -164(%rbp) +..B1.166: + movl $0, -268(%rbp) +..B1.167: + movl -192(%rbp), %eax + testl %eax, %eax + je ..B1.222 +..B1.168: + lea _ones(%rip), %rax + movsd (%rax), %xmm0 + movsd %xmm0, -48(%rbp) + fldl -48(%rbp) + lea _small_value_80(%rip), %rax + fldt (%rax) + faddp %st, %st(1) + fstpt -16(%rbp) + movl -324(%rbp), %eax + movl %eax, -156(%rbp) + testl %eax, %eax + je ..B1.172 +..B1.169: + movl -156(%rbp), %eax + cmpl $3072, %eax + je ..B1.182 +..B1.170: + movl -156(%rbp), %eax + cmpl $2048, %eax + je ..B1.186 +..B1.171: + movl -156(%rbp), %eax + cmpl $1024, %eax + je ..B1.204 + jmp ..B1.222 +..B1.172: + movl -192(%rbp), %eax + testl $-2147483648, %eax + je ..B1.182 +..B1.173: + movl -168(%rbp), %eax + andl $1, %eax + movl -192(%rbp), %edx + andl $2147483647, %edx + orl %edx, %eax + je ..B1.182 +..B1.174: + movl $1, %eax + addl -168(%rbp), %eax + movl %eax, -168(%rbp) + jne ..B1.180 +..B1.175: + movl $1, %eax + addl -164(%rbp), %eax + movl %eax, -152(%rbp) + movl %eax, -164(%rbp) + movl -268(%rbp), %eax + testl %eax, %eax + je ..B1.177 +..B1.176: + movl $0, -148(%rbp) + jmp ..B1.178 +..B1.177: + movl $-2147483648, -148(%rbp) +..B1.178: + movl -148(%rbp), %eax + movl -152(%rbp), %edx + cmpl %eax, %edx + jne ..B1.180 +..B1.179: + orl $-2147483648, -164(%rbp) + movl $1, %eax + addl -268(%rbp), %eax + movl %eax, -268(%rbp) +..B1.180: + movl -268(%rbp), %eax + cmpl $32767, %eax + jl ..B1.182 +..B1.181: + movl -272(%rbp), %eax + movslq %eax, %rax + shlq $4, %rax + lea _large_value_80(%rip), %rdx + addq %rax, %rdx + fldt (%rdx) + lea _large_value_80(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt -16(%rbp) + fldt -16(%rbp) + fstpt -32(%rbp) + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.182: + movl -268(%rbp), %eax + testl %eax, %eax + je ..B1.185 +..B1.183: + movl $-1, %eax + addl -268(%rbp), %eax + movl $-2147483648, %edx + negl %edx + addl -164(%rbp), %edx + orl %edx, %eax + orl -168(%rbp), %eax + jne ..B1.222 +..B1.184: + movl -192(%rbp), %eax + cmpl $-2147483648, %eax + jne ..B1.222 +..B1.185: + lea _small_value_80(%rip), %rax + fldt (%rax) + lea _small_value_80(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt -16(%rbp) + jmp ..B1.222 +..B1.186: + movl -268(%rbp), %eax + testl %eax, %eax + jne ..B1.195 +..B1.187: + movl -272(%rbp), %eax + testl %eax, %eax + jne ..B1.194 +..B1.188: + movl -272(%rbp), %eax + testl %eax, %eax + jne ..B1.195 +..B1.189: + movl -164(%rbp), %eax + cmpl $2147483647, %eax + jb ..B1.194 +..B1.190: + movl -164(%rbp), %eax + cmpl $2147483647, %eax + jne ..B1.195 +..B1.191: + movl -168(%rbp), %eax + cmpl $-1, %eax + jb ..B1.194 +..B1.192: + movl -168(%rbp), %eax + cmpl $-1, %eax + jne ..B1.195 +..B1.193: + movl -192(%rbp), %eax + cmpl $-2147483648, %eax + jae ..B1.195 +..B1.194: + lea _small_value_80(%rip), %rax + fldt (%rax) + lea _small_value_80(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt -16(%rbp) +..B1.195: + movl -272(%rbp), %eax + testl %eax, %eax + jne ..B1.222 +..B1.196: + movl $1, %eax + addl -168(%rbp), %eax + movl %eax, -168(%rbp) + jne ..B1.202 +..B1.197: + movl $1, %eax + addl -164(%rbp), %eax + movl %eax, -144(%rbp) + movl %eax, -164(%rbp) + movl -268(%rbp), %eax + testl %eax, %eax + je ..B1.199 +..B1.198: + movl $0, -140(%rbp) + jmp ..B1.200 +..B1.199: + movl $-2147483648, -140(%rbp) +..B1.200: + movl -140(%rbp), %eax + movl -144(%rbp), %edx + cmpl %eax, %edx + jne ..B1.202 +..B1.201: + orl $-2147483648, -164(%rbp) + movl $1, %eax + addl -268(%rbp), %eax + movl %eax, -268(%rbp) +..B1.202: + movl -268(%rbp), %eax + cmpl $32767, %eax + jl ..B1.222 +..B1.203: + movl -272(%rbp), %eax + movslq %eax, %rax + shlq $4, %rax + lea _large_value_80(%rip), %rdx + addq %rax, %rdx + fldt (%rdx) + lea _large_value_80(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt -16(%rbp) + fldt -16(%rbp) + fstpt -32(%rbp) + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.204: + movl -268(%rbp), %eax + testl %eax, %eax + jne ..B1.213 +..B1.205: + movl -272(%rbp), %eax + testl %eax, %eax + je ..B1.212 +..B1.206: + movl -272(%rbp), %eax + testl %eax, %eax + je ..B1.213 +..B1.207: + movl -164(%rbp), %eax + cmpl $2147483647, %eax + jb ..B1.212 +..B1.208: + movl -164(%rbp), %eax + cmpl $2147483647, %eax + jne ..B1.213 +..B1.209: + movl -168(%rbp), %eax + cmpl $-1, %eax + jb ..B1.212 +..B1.210: + movl -168(%rbp), %eax + cmpl $-1, %eax + jne ..B1.213 +..B1.211: + movl -192(%rbp), %eax + cmpl $-2147483648, %eax + jae ..B1.213 +..B1.212: + lea _small_value_80(%rip), %rax + fldt (%rax) + lea _small_value_80(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt -16(%rbp) +..B1.213: + movl -272(%rbp), %eax + testl %eax, %eax + je ..B1.222 +..B1.214: + movl $1, %eax + addl -168(%rbp), %eax + movl %eax, -168(%rbp) + jne ..B1.220 +..B1.215: + movl $1, %eax + addl -164(%rbp), %eax + movl %eax, -136(%rbp) + movl %eax, -164(%rbp) + movl -268(%rbp), %eax + testl %eax, %eax + je ..B1.217 +..B1.216: + movl $0, -132(%rbp) + jmp ..B1.218 +..B1.217: + movl $-2147483648, -132(%rbp) +..B1.218: + movl -132(%rbp), %eax + movl -136(%rbp), %edx + cmpl %eax, %edx + jne ..B1.220 +..B1.219: + orl $-2147483648, -164(%rbp) + movl $1, %eax + addl -268(%rbp), %eax + movl %eax, -268(%rbp) +..B1.220: + movl -268(%rbp), %eax + cmpl $32767, %eax + jl ..B1.222 +..B1.221: + movl -272(%rbp), %eax + movslq %eax, %rax + shlq $4, %rax + lea _large_value_80(%rip), %rdx + addq %rax, %rdx + fldt (%rdx) + lea _large_value_80(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt -16(%rbp) + fldt -16(%rbp) + fstpt -32(%rbp) + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_offset 6, -16 +..B1.222: + movq -104(%rbp), %rax + movzbl 9(%rax), %eax + movzbl %al, %eax + andl $-129, %eax + movl -272(%rbp), %edx + andl $1, %edx + shll $7, %edx + orl %edx, %eax + movq -104(%rbp), %rdx + movb %al, 9(%rdx) + movq -104(%rbp), %rax + movzwl 8(%rax), %eax + movzwl %ax, %eax + andl $-32768, %eax + movl -268(%rbp), %edx + andl $32767, %edx + orl %edx, %eax + movq -104(%rbp), %rdx + movw %ax, 8(%rdx) + movq -104(%rbp), %rax + movl -164(%rbp), %edx + movl %edx, 4(%rax) + movq -104(%rbp), %rax + movl -168(%rbp), %edx + movl %edx, (%rax) + fldt -32(%rbp) + leave + .cfi_restore 6 + ret + .cfi_endproc + .type fmal,@function + .size fmal,.-fmal + .data +# -- End fmal + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmax_gen.S b/external/sgx_libm/intel64/fmax_gen.S new file mode 100644 index 0000000000..b4d21d2e2d --- /dev/null +++ b/external/sgx_libm/intel64/fmax_gen.S @@ -0,0 +1,97 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmax_gen.c" + .text +..TXTST0: +# -- Begin fmax + .text + .align 16,0x90 + .globl fmax +fmax: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fmax.1: +..L2: + + movsd %xmm0, -24(%rsp) + movzwl -18(%rsp), %eax + andl $32752, %eax + movsd %xmm1, -16(%rsp) + cmpl $32752, %eax + je ..B1.7 +..B1.2: + movzwl -10(%rsp), %eax + andl $32752, %eax + cmpl $32752, %eax + jne ..B1.6 +..B1.3: + testl $1048575, -12(%rsp) + jne ..B1.5 +..B1.4: + cmpl $0, -16(%rsp) + je ..B1.6 +..B1.5: + movsd -24(%rsp), %xmm0 + ret +..B1.6: + movsd -24(%rsp), %xmm0 + maxsd -16(%rsp), %xmm0 + ret +..B1.7: + testl $1048575, -20(%rsp) + jne ..B1.9 +..B1.8: + cmpl $0, -24(%rsp) + je ..B1.2 +..B1.9: + movsd -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type fmax,@function + .size fmax,.-fmax + .data +# -- End fmax + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmaxf_gen.S b/external/sgx_libm/intel64/fmaxf_gen.S new file mode 100644 index 0000000000..11343026f0 --- /dev/null +++ b/external/sgx_libm/intel64/fmaxf_gen.S @@ -0,0 +1,91 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmaxf_gen.c" + .text +..TXTST0: +# -- Begin fmaxf + .text + .align 16,0x90 + .globl fmaxf +fmaxf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fmaxf.1: +..L2: + + movss %xmm0, -24(%rsp) + movzwl -22(%rsp), %eax + andl $32640, %eax + movss %xmm1, -16(%rsp) + cmpl $32640, %eax + je ..B1.6 +..B1.2: + movzwl -14(%rsp), %eax + andl $32640, %eax + cmpl $32640, %eax + jne ..B1.5 +..B1.3: + testl $8388607, -16(%rsp) + je ..B1.5 +..B1.4: + movss -24(%rsp), %xmm0 + ret +..B1.5: + movss -24(%rsp), %xmm0 + maxss -16(%rsp), %xmm0 + ret +..B1.6: + testl $8388607, -24(%rsp) + je ..B1.2 +..B1.7: + movss -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type fmaxf,@function + .size fmaxf,.-fmaxf + .data +# -- End fmaxf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmaxl.S b/external/sgx_libm/intel64/fmaxl.S new file mode 100644 index 0000000000..ee873d884e --- /dev/null +++ b/external/sgx_libm/intel64/fmaxl.S @@ -0,0 +1,203 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmaxl.c" + .text +..TXTST0: +# -- Begin fmaxl + .text + .align 16,0x90 + .globl fmaxl +fmaxl: +# parameter 1: 48 + %rsp +# parameter 2: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_fmaxl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %sil, %sil +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 56(%rsp), %ecx + movl %ecx, %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.34 +..B1.4: + movzwl 72(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.17 +..B1.5: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.7: + fldcw 32(%rsp) +..B1.8: + movb $1, %sil +..B1.9: + fldt 48(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fldt 64(%rsp) + fxch %st(1) + fcomip %st(1), %st + jbe ..B1.11 +..B1.10: + fstp %st(0) + jmp ..B1.13 +..B1.11: + fldt 16(%rsp) + fucomip %st(1), %st + jp ..B1.12 + je ..B1.16 +..B1.12: + fstpt 16(%rsp) +..B1.13: + testb %sil, %sil + je ..B1.15 +..B1.14: + fldcw 34(%rsp) +..B1.15: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.16: + testb $-128, 73(%rsp) + jne ..B1.10 + jmp ..B1.12 +..B1.17: + cmpl $-2147483648, 68(%rsp) + jne ..B1.19 +..B1.18: + cmpl $0, 64(%rsp) + je ..B1.5 +..B1.19: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.33 +..B1.20: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.21: + fldcw 32(%rsp) +..B1.22: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.23: + fldcw 34(%rsp) + movzwl 56(%rsp), %ecx +..B1.24: + andl $32767, %ecx + cmpl $32767, %ecx + jne ..B1.27 +..B1.25: + cmpl $-2147483648, 52(%rsp) + jne ..B1.28 +..B1.26: + cmpl $0, 48(%rsp) + jne ..B1.28 +..B1.27: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.28: + movzwl 72(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.31 +..B1.29: + cmpl $-2147483648, 68(%rsp) + jne ..B1.32 +..B1.30: + cmpl $0, 64(%rsp) + jne ..B1.32 +..B1.31: + fldt 64(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.32: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.33: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.24 +..B1.34: + cmpl $-2147483648, 52(%rsp) + jne ..B1.19 +..B1.35: + cmpl $0, 48(%rsp) + je ..B1.4 + jmp ..B1.19 + .align 16,0x90 + .cfi_endproc + .type fmaxl,@function + .size fmaxl,.-fmaxl + .data +# -- End fmaxl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmin_gen.S b/external/sgx_libm/intel64/fmin_gen.S new file mode 100644 index 0000000000..4afa69faad --- /dev/null +++ b/external/sgx_libm/intel64/fmin_gen.S @@ -0,0 +1,97 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmin_gen.c" + .text +..TXTST0: +# -- Begin fmin + .text + .align 16,0x90 + .globl fmin +fmin: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fmin.1: +..L2: + + movsd %xmm0, -24(%rsp) + movzwl -18(%rsp), %eax + andl $32752, %eax + movsd %xmm1, -16(%rsp) + cmpl $32752, %eax + je ..B1.7 +..B1.2: + movzwl -10(%rsp), %eax + andl $32752, %eax + cmpl $32752, %eax + jne ..B1.6 +..B1.3: + testl $1048575, -12(%rsp) + jne ..B1.5 +..B1.4: + cmpl $0, -16(%rsp) + je ..B1.6 +..B1.5: + movsd -24(%rsp), %xmm0 + ret +..B1.6: + movsd -24(%rsp), %xmm0 + minsd -16(%rsp), %xmm0 + ret +..B1.7: + testl $1048575, -20(%rsp) + jne ..B1.9 +..B1.8: + cmpl $0, -24(%rsp) + je ..B1.2 +..B1.9: + movsd -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type fmin,@function + .size fmin,.-fmin + .data +# -- End fmin + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fminf_gen.S b/external/sgx_libm/intel64/fminf_gen.S new file mode 100644 index 0000000000..2126ac6dae --- /dev/null +++ b/external/sgx_libm/intel64/fminf_gen.S @@ -0,0 +1,91 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fminf_gen.c" + .text +..TXTST0: +# -- Begin fminf + .text + .align 16,0x90 + .globl fminf +fminf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fminf.1: +..L2: + + movss %xmm0, -24(%rsp) + movzwl -22(%rsp), %eax + andl $32640, %eax + movss %xmm1, -16(%rsp) + cmpl $32640, %eax + je ..B1.6 +..B1.2: + movzwl -14(%rsp), %eax + andl $32640, %eax + cmpl $32640, %eax + jne ..B1.5 +..B1.3: + testl $8388607, -16(%rsp) + je ..B1.5 +..B1.4: + movss -24(%rsp), %xmm0 + ret +..B1.5: + movss -24(%rsp), %xmm0 + minss -16(%rsp), %xmm0 + ret +..B1.6: + testl $8388607, -24(%rsp) + je ..B1.2 +..B1.7: + movss -16(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type fminf,@function + .size fminf,.-fminf + .data +# -- End fminf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fminl.S b/external/sgx_libm/intel64/fminl.S new file mode 100644 index 0000000000..122e39e01c --- /dev/null +++ b/external/sgx_libm/intel64/fminl.S @@ -0,0 +1,187 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fminl.c" + .text +..TXTST0: +# -- Begin fminl + .text + .align 16,0x90 + .globl fminl +fminl: +# parameter 1: 48 + %rsp +# parameter 2: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_fminl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %sil, %sil +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 56(%rsp), %ecx + movl %ecx, %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.29 +..B1.4: + movzwl 72(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.12 +..B1.5: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.7: + fldcw 32(%rsp) +..B1.8: + movb $1, %sil +..B1.9: + fldt 48(%rsp) + fldt 64(%rsp) + fcomi %st(1), %st + fcmovnbe %st(1), %st + fstp %st(1) + fstpt 16(%rsp) + testb %sil, %sil + je ..B1.11 +..B1.10: + fldcw 34(%rsp) +..B1.11: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.12: + cmpl $-2147483648, 68(%rsp) + jne ..B1.14 +..B1.13: + cmpl $0, 64(%rsp) + je ..B1.5 +..B1.14: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.28 +..B1.15: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.16: + fldcw 32(%rsp) +..B1.17: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.18: + fldcw 34(%rsp) + movzwl 56(%rsp), %ecx +..B1.19: + andl $32767, %ecx + cmpl $32767, %ecx + jne ..B1.22 +..B1.20: + cmpl $-2147483648, 52(%rsp) + jne ..B1.23 +..B1.21: + cmpl $0, 48(%rsp) + jne ..B1.23 +..B1.22: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.23: + movzwl 72(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.26 +..B1.24: + cmpl $-2147483648, 68(%rsp) + jne ..B1.27 +..B1.25: + cmpl $0, 64(%rsp) + jne ..B1.27 +..B1.26: + fldt 64(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.27: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.28: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.19 +..B1.29: + cmpl $-2147483648, 52(%rsp) + jne ..B1.14 +..B1.30: + cmpl $0, 48(%rsp) + je ..B1.4 + jmp ..B1.14 + .align 16,0x90 + .cfi_endproc + .type fminl,@function + .size fminl,.-fminl + .data +# -- End fminl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmod_gen.S b/external/sgx_libm/intel64/fmod_gen.S new file mode 100644 index 0000000000..2a5a27cbec --- /dev/null +++ b/external/sgx_libm/intel64/fmod_gen.S @@ -0,0 +1,212 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmod_gen.c" + .text +..TXTST0: +# -- Begin fmod + .text + .align 16,0x90 + .globl fmod +fmod: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fmod.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movq $0x8000000000000000, %rsi + movd %xmm1, %rcx + movq $0x7fffffffffffffff, %rdi + movd %xmm0, %rax + movsd %xmm0, 16(%rsp) + movsd %xmm1, 24(%rsp) + btrq $63, %rcx + movq $0x3ff0000000000000, %rdx + andq %rax, %rsi + andq %rax, %rdi + cmpq %rdx, %rcx + jne ..B1.30 +..B1.2: + cmpq %rcx, %rdi + ja ..B1.7 +..B1.3: + jne ..B1.6 +..B1.4: + pxor %xmm1, %xmm1 + mulsd %xmm1, %xmm0 +..B1.6: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.7: + movq $0x4330000000000000, %rax + cmpq %rax, %rdi + jae ..B1.9 +..B1.8: + negq %rcx + addq %rdi, %rcx + shrq $52, %rcx + negq %rcx + addq $52, %rcx + movsd 16(%rsp), %xmm0 + shrq %cl, %rdi + shlq %cl, %rdi + orq %rsi, %rdi + movq %rdi, (%rsp) + subsd (%rsp), %xmm0 + movd %xmm0, %rax + orq %rsi, %rax + movq %rax, (%rsp) + movsd (%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.9: + movq $0x7ff0000000000000, %rax + cmpq %rax, %rdi + jae ..B1.11 +..B1.10: + pxor %xmm0, %xmm0 + mulsd 16(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.30: + movq $0x7ff0000000000000, %rax + cmpq %rax, %rdi +..B1.11: + ja ..B1.25 +..B1.12: + cmpq %rax, %rcx + ja ..B1.24 +..B1.13: + testq %rcx, %rcx + je ..B1.23 +..B1.14: + cmpq %rax, %rdi + je ..B1.23 +..B1.15: + cmpq %rax, %rcx + je ..B1.22 +..B1.16: + cmpq %rcx, %rdi + jb ..B1.21 +..B1.17: + je ..B1.27 +..B1.18: + movq %rdi, (%rsp) +..B1.19: + fldl 24(%rsp) + fldl 16(%rsp) +.L_2TAG_PACKET_0.0.2: + fprem + fstsw %ax + andw $1024, %ax + jne .L_2TAG_PACKET_0.0.2 + fstp %st(1) + fstpl 8(%rsp) +..B1.20: + movsd 8(%rsp), %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.21: + movsd 16(%rsp), %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.22: + movsd 16(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.23: + pxor %xmm0, %xmm0 + pxor %xmm1, %xmm1 + divsd %xmm1, %xmm0 + movsd %xmm0, 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.24: + movsd 24(%rsp), %xmm0 + mulsd 16(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.25: + movsd 16(%rsp), %xmm0 + mulsd 24(%rsp), %xmm0 + movsd %xmm0, 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.27: + pxor %xmm0, %xmm0 + mulsd 16(%rsp), %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fmod,@function + .size fmod,.-fmod + .data +# -- End fmod + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmodf_gen.S b/external/sgx_libm/intel64/fmodf_gen.S new file mode 100644 index 0000000000..43c0192674 --- /dev/null +++ b/external/sgx_libm/intel64/fmodf_gen.S @@ -0,0 +1,74 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmodf_gen.c" + .text +..TXTST0: +# -- Begin fmodf + .text + .align 16,0x90 + .globl fmodf +fmodf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_fmodf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + cvtss2sd %xmm0, %xmm0 + cvtss2sd %xmm1, %xmm1 + call fmod@PLT +..B1.4: + cvtsd2ss %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fmodf,@function + .size fmodf,.-fmodf + .data +# -- End fmodf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fmodl.S b/external/sgx_libm/intel64/fmodl.S new file mode 100644 index 0000000000..03f1fe9287 --- /dev/null +++ b/external/sgx_libm/intel64/fmodl.S @@ -0,0 +1,308 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fmodl.c" + .text +..TXTST0: +# -- Begin fmodl + .text + .align 16,0x90 + .globl fmodl +fmodl: +# parameter 1: 80 + %rsp +# parameter 2: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_fmodl.1: +..L2: + + subq $72, %rsp + .cfi_def_cfa_offset 80 + xorb %dl, %dl + fldt 80(%rsp) + fstpt 32(%rsp) + fldt 96(%rsp) + fstpt 48(%rsp) +..B1.2: + fnstcw 66(%rsp) +..B1.3: + movzwl 104(%rsp), %ecx + andl $32767, %ecx + jne ..B1.6 +..B1.4: + cmpl $0, 100(%rsp) + jne ..B1.6 +..B1.5: + cmpl $0, 96(%rsp) + je ..B1.42 +..B1.6: + movzwl 88(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.40 +..B1.7: + cmpl $32767, %ecx + je ..B1.17 +..B1.8: + movzwl 66(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.12 +..B1.9: + orl $-64768, %ecx + movw %cx, 64(%rsp) +..B1.10: + fldcw 64(%rsp) +..B1.11: + movb $1, %dl +..B1.12: + fldt 48(%rsp) + fldt 32(%rsp) + movq $1024, %rcx +.L_2TAG_PACKET_0.0.2: + fprem + fstsw %ax + andq %rcx, %rax + cmpq $1024, %rax + je .L_2TAG_PACKET_0.0.2 + fstp %st(1) + fstpt 16(%rsp) +..B1.13: + testb %dl, %dl + je ..B1.15 +..B1.14: + fldcw 66(%rsp) +..B1.15: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.17: + movq $0x8000000000000000, %rax + cmpq 96(%rsp), %rax + je ..B1.25 +..B1.18: + movzwl 66(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.24 +..B1.19: + orl $-64768, %edx + movw %dx, 64(%rsp) +..B1.20: + fldcw 64(%rsp) +..B1.21: + fldt 80(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpt 16(%rsp) +..B1.22: + fldcw 66(%rsp) +..B1.23: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.24: + fldt 80(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.23 +..B1.25: + cmpl $32767, %esi + je ..B1.31 +..B1.26: + testl %esi, %esi + jne ..B1.30 +..B1.27: + cmpl $0, 84(%rsp) + jne ..B1.29 +..B1.28: + cmpl $0, 80(%rsp) + je ..B1.30 +..B1.29: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 8(%rsp) +..B1.30: + fldt 80(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.31: + cmpl $-2147483648, 84(%rsp) + jne ..B1.30 +..B1.32: + cmpl $0, 80(%rsp) + jne ..B1.30 +..B1.33: + movzwl 66(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.37 +..B1.34: + orl $-64768, %ecx + movw %cx, 64(%rsp) +..B1.35: + fldcw 64(%rsp) +..B1.36: + movb $1, %dl +..B1.37: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + testb %dl, %dl + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 16(%rsp) + je ..B1.39 +..B1.38: + fldcw 66(%rsp) +..B1.39: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.40: + movq $0x8000000000000000, %rax + cmpq 80(%rsp), %rax + jne ..B1.18 +..B1.41: + cmpl $32767, %ecx + je ..B1.17 + jmp ..B1.25 +..B1.42: + movzwl 66(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.46 +..B1.43: + orl $-64768, %ecx + movw %cx, 64(%rsp) +..B1.44: + fldcw 64(%rsp) +..B1.45: + movb $1, %dl +..B1.46: + movzwl 88(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.49 +..B1.47: + movq $0x8000000000000000, %rax + cmpq 80(%rsp), %rax + je ..B1.49 +..B1.48: + fldt 80(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) + jmp ..B1.50 +..B1.49: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 16(%rsp) +..B1.50: + testb %dl, %dl + je ..B1.52 +..B1.51: + fldcw 66(%rsp) +..B1.52: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fmodl,@function + .size fmodl,.-fmodl + .data +# -- End fmodl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/fpclassify.S b/external/sgx_libm/intel64/fpclassify.S new file mode 100644 index 0000000000..fe51fc3393 --- /dev/null +++ b/external/sgx_libm/intel64/fpclassify.S @@ -0,0 +1,423 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "fpclassify.c" + .text +..TXTST0: +# -- Begin __fpclassifyd + .text + .align 16,0x90 + .globl __fpclassifyd +__fpclassifyd: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___fpclassifyd.1: +..L2: + + movd %xmm0, %rcx + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + btrq $63, %rcx + andl $2147483647, %eax + cmpl $2146435072, %eax + jb ..B1.3 +..B1.2: + movq $0x7ff0000000000000, %rdx + xorl %eax, %eax + cmpq %rcx, %rdx + setae %al + ret +..B1.3: + cmpl $1048576, %eax + jae ..B1.5 +..B1.4: + movl $3, %edx + movl $2, %eax + testq %rcx, %rcx + cmovne %edx, %eax + ret +..B1.5: + movl $4, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __fpclassifyd,@function + .size __fpclassifyd,.-__fpclassifyd + .data +# -- End __fpclassifyd + .text +# -- Begin fpclassifyd + .text + .align 16,0x90 + .globl fpclassifyd +fpclassifyd: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_fpclassifyd.4: +..L5: + + movd %xmm0, %rcx + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + btrq $63, %rcx + andl $2147483647, %eax + cmpl $2146435072, %eax + jb ..B2.3 +..B2.2: + movq $0x7ff0000000000000, %rdx + xorl %eax, %eax + cmpq %rcx, %rdx + setae %al + ret +..B2.3: + cmpl $1048576, %eax + jae ..B2.5 +..B2.4: + movl $3, %edx + movl $2, %eax + testq %rcx, %rcx + cmovne %edx, %eax + ret +..B2.5: + movl $4, %eax + ret + .align 16,0x90 + .cfi_endproc + .type fpclassifyd,@function + .size fpclassifyd,.-fpclassifyd + .data +# -- End fpclassifyd + .text +# -- Begin __fpclassify + .text + .align 16,0x90 + .globl __fpclassify +__fpclassify: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___fpclassify.7: +..L8: + + movd %xmm0, %rcx + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + btrq $63, %rcx + andl $2147483647, %eax + cmpl $2146435072, %eax + jb ..B3.3 +..B3.2: + movq $0x7ff0000000000000, %rdx + xorl %eax, %eax + cmpq %rcx, %rdx + setae %al + ret +..B3.3: + cmpl $1048576, %eax + jae ..B3.5 +..B3.4: + movl $3, %edx + movl $2, %eax + testq %rcx, %rcx + cmovne %edx, %eax + ret +..B3.5: + movl $4, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __fpclassify,@function + .size __fpclassify,.-__fpclassify + .data +# -- End __fpclassify + .text +# -- Begin fpclassify + .text + .align 16,0x90 + .globl fpclassify +fpclassify: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value_fpclassify.10: +..L11: + + movd %xmm0, %rcx + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + btrq $63, %rcx + andl $2147483647, %eax + cmpl $2146435072, %eax + jb ..B4.3 +..B4.2: + movq $0x7ff0000000000000, %rdx + xorl %eax, %eax + cmpq %rcx, %rdx + setae %al + ret +..B4.3: + cmpl $1048576, %eax + jae ..B4.5 +..B4.4: + movl $3, %edx + movl $2, %eax + testq %rcx, %rcx + cmovne %edx, %eax + ret +..B4.5: + movl $4, %eax + ret + .align 16,0x90 + .cfi_endproc + .type fpclassify,@function + .size fpclassify,.-fpclassify + .data +# -- End fpclassify + .text +# -- Begin __fpclassifyf + .text + .align 16,0x90 + .globl __fpclassifyf +__fpclassifyf: +# parameter 1: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value___fpclassifyf.13: +..L14: + + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jb ..B5.3 +..B5.2: + movl $0, %eax + setbe %al + ret +..B5.3: + cmpl $8388608, %edx + jae ..B5.5 +..B5.4: + movl $3, %ecx + movl $2, %eax + testl %edx, %edx + cmovne %ecx, %eax + ret +..B5.5: + movl $4, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __fpclassifyf,@function + .size __fpclassifyf,.-__fpclassifyf + .data +# -- End __fpclassifyf + .text +# -- Begin fpclassifyf + .text + .align 16,0x90 + .globl fpclassifyf +fpclassifyf: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value_fpclassifyf.16: +..L17: + + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jb ..B6.3 +..B6.2: + movl $0, %eax + setbe %al + ret +..B6.3: + cmpl $8388608, %edx + jae ..B6.5 +..B6.4: + movl $3, %ecx + movl $2, %eax + testl %edx, %edx + cmovne %ecx, %eax + ret +..B6.5: + movl $4, %eax + ret + .align 16,0x90 + .cfi_endproc + .type fpclassifyf,@function + .size fpclassifyf,.-fpclassifyf + .data +# -- End fpclassifyf + .text +# -- Begin __fpclassifyl + .text + .align 16,0x90 + .globl __fpclassifyl +__fpclassifyl: +# parameter 1: 8 + %rsp +..B7.1: + .cfi_startproc +..___tag_value___fpclassifyl.19: +..L20: + + movzwl 16(%rsp), %ecx + andl $32767, %ecx + movl 12(%rsp), %esi + movl %ecx, %eax + movl %esi, %edx + shll $16, %eax + shrl $16, %edx + orl %edx, %eax + cmpl $2147418112, %eax + jb ..B7.5 +..B7.2: + cmpl $32767, %ecx + je ..B7.12 +..B7.3: + xorl %eax, %eax +..B7.4: + ret +..B7.5: + cmpl $65536, %eax + jae ..B7.11 +..B7.6: + testl %esi, %esi + jne ..B7.8 +..B7.7: + cmpl $0, 8(%rsp) + je ..B7.9 +..B7.8: + movl $3, %eax + ret +..B7.9: + movl $2, %eax +..B7.10: + ret +..B7.11: + andl $32768, %eax + shrl $15, %eax + addl $3, %eax + ret +..B7.12: + cmpl $-2147483648, %esi + jne ..B7.3 +..B7.13: + cmpl $0, 8(%rsp) + jne ..B7.3 +..B7.14: + movl $1, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __fpclassifyl,@function + .size __fpclassifyl,.-__fpclassifyl + .data +# -- End __fpclassifyl + .text +# -- Begin fpclassifyl + .text + .align 16,0x90 + .globl fpclassifyl +fpclassifyl: +# parameter 1: 8 + %rsp +..B8.1: + .cfi_startproc +..___tag_value_fpclassifyl.22: +..L23: + + movzwl 16(%rsp), %ecx + andl $32767, %ecx + movl 12(%rsp), %esi + movl %ecx, %eax + movl %esi, %edx + shll $16, %eax + shrl $16, %edx + orl %edx, %eax + cmpl $2147418112, %eax + jb ..B8.5 +..B8.2: + cmpl $32767, %ecx + je ..B8.12 +..B8.3: + xorl %eax, %eax +..B8.4: + ret +..B8.5: + cmpl $65536, %eax + jae ..B8.11 +..B8.6: + testl %esi, %esi + jne ..B8.8 +..B8.7: + cmpl $0, 8(%rsp) + je ..B8.9 +..B8.8: + movl $3, %eax + ret +..B8.9: + movl $2, %eax +..B8.10: + ret +..B8.11: + andl $32768, %eax + shrl $15, %eax + addl $3, %eax + ret +..B8.12: + cmpl $-2147483648, %esi + jne ..B8.3 +..B8.13: + cmpl $0, 8(%rsp) + jne ..B8.3 +..B8.14: + movl $1, %eax + ret + .align 16,0x90 + .cfi_endproc + .type fpclassifyl,@function + .size fpclassifyl,.-fpclassifyl + .data +# -- End fpclassifyl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/frexp_gen.S b/external/sgx_libm/intel64/frexp_gen.S new file mode 100644 index 0000000000..42177750cb --- /dev/null +++ b/external/sgx_libm/intel64/frexp_gen.S @@ -0,0 +1,115 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "frexp_gen.c" + .text +..TXTST0: +# -- Begin frexp + .text + .align 16,0x90 + .globl frexp +frexp: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_frexp.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + movl %eax, %edx + andl $2147483647, %edx + lea -1048576(%rdx), %ecx + cmpl $2145386496, %ecx + jb ..B1.6 +..B1.2: + testl %ecx, %ecx + jge ..B1.5 +..B1.3: + movl -8(%rsp), %eax + orl %eax, %edx + je ..B1.5 +..B1.4: + lea _TWO_55(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + movl %edx, %ecx + andl $2147483647, %ecx + andl $-2146435073, %edx + shrl $20, %ecx + orl $1071644672, %edx + movl %edx, -4(%rsp) + addl $-1077, %ecx + movl %ecx, (%rdi) + movsd -8(%rsp), %xmm0 + ret +..B1.5: + movl $0, (%rdi) + movsd -8(%rsp), %xmm0 + ret +..B1.6: + andl $-2146435073, %eax + shrl $20, %ecx + orl $1071644672, %eax + movl %eax, -4(%rsp) + addl $-1021, %ecx + movl %ecx, (%rdi) + movsd -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type frexp,@function + .size frexp,.-frexp + .data +# -- End frexp + .section .rodata, "a" + .align 4 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .type _TWO_55,@object + .size _TWO_55,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/frexpf.S b/external/sgx_libm/intel64/frexpf.S new file mode 100644 index 0000000000..58d2539b42 --- /dev/null +++ b/external/sgx_libm/intel64/frexpf.S @@ -0,0 +1,114 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "frexpf.c" + .text +..TXTST0: +# -- Begin frexpf + .text + .align 16,0x90 + .globl frexpf +frexpf: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_frexpf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + movl %edx, %eax + andl $2147483647, %eax + lea -8388608(%rax), %ecx + cmpl $2130706432, %ecx + jb ..B1.5 +..B1.2: + decl %eax + cmpl $2139095039, %eax + jae ..B1.6 +..B1.3: + movl %edx, -20(%rsp) + orl $1056964608, %edx + movl %edx, -24(%rsp) + andl $-2147483648, %edx + orl $1056964608, %edx + movl %edx, -16(%rsp) + movss -24(%rsp), %xmm2 + movss -20(%rsp), %xmm1 + movss -20(%rsp), %xmm0 + subss -16(%rsp), %xmm2 + addss %xmm0, %xmm1 + movd %xmm2, %eax + movss %xmm1, -20(%rsp) + movl %eax, %edx + andl $-2139095041, %eax + andl $2139095040, %edx + orl $1056964608, %eax + shrl $23, %edx + movl %eax, -24(%rsp) + addl $-251, %edx + movl %edx, (%rdi) + movss -24(%rsp), %xmm0 +..B1.4: + ret +..B1.5: + andl $-2139095041, %edx + shrl $23, %ecx + orl $1056964608, %edx + movl %edx, -24(%rsp) + addl $-125, %ecx + movl %ecx, (%rdi) + movss -24(%rsp), %xmm0 + ret +..B1.6: + movss -8(%rsp), %xmm0 + movl $0, (%rdi) + addss %xmm0, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type frexpf,@function + .size frexpf,.-frexpf + .data +# -- End frexpf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/frexpl.S b/external/sgx_libm/intel64/frexpl.S new file mode 100644 index 0000000000..45c09e0930 --- /dev/null +++ b/external/sgx_libm/intel64/frexpl.S @@ -0,0 +1,174 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "frexpl.c" + .text +..TXTST0: +# -- Begin frexpl + .text + .align 16,0x90 + .globl frexpl +frexpl: +# parameter 1: 32 + %rsp +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_frexpl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 40(%rsp), %edx + movl %edx, %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.15 +..B1.4: + testl %eax, %eax + jne ..B1.13 +..B1.5: + cmpq $0, 32(%rsp) + je ..B1.12 +..B1.6: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.14 +..B1.7: + orl $-64768, %edx + movl $0, (%rdi) + movw %dx, 16(%rsp) +..B1.8: + fldcw 16(%rsp) +..B1.9: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) +..B1.10: + fldcw 18(%rsp) +..B1.11: + movzwl 40(%rsp), %edx + movl %edx, %eax + andl $-32768, %edx + andl $32767, %eax + orl $-49154, %edx + addl $-16457, %eax + movw %dx, 40(%rsp) + fldt 32(%rsp) + movl %eax, (%rdi) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.12: + fldt 32(%rsp) + movl $0, (%rdi) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.13: + andl $-32768, %edx + addl $-16382, %eax + orl $-49154, %edx + movw %dx, 40(%rsp) + fldt 32(%rsp) + movl %eax, (%rdi) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.14: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) + jmp ..B1.11 +..B1.15: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + movl $0, (%rdi) + cmpl $768, %eax + je ..B1.21 +..B1.16: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.17: + fldcw 16(%rsp) +..B1.18: + fldt 32(%rsp) + fstpt (%rsp) +..B1.19: + fldcw 18(%rsp) +..B1.20: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.21: + fldt 32(%rsp) + fstpt (%rsp) + jmp ..B1.20 + .align 16,0x90 + .cfi_endproc + .type frexpl,@function + .size frexpl,.-frexpl + .data +# -- End frexpl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/hypot_gen.S b/external/sgx_libm/intel64/hypot_gen.S new file mode 100644 index 0000000000..d1b9a11db6 --- /dev/null +++ b/external/sgx_libm/intel64/hypot_gen.S @@ -0,0 +1,143 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "hypot_gen.c" + .text +..TXTST0: +# -- Begin hypot + .text + .align 16,0x90 + .globl hypot +hypot: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_hypot.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %cl, %cl + movsd %xmm0, 8(%rsp) + movsd %xmm1, 16(%rsp) +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.5: + fldcw 32(%rsp) +..B1.6: + movb $1, %cl +..B1.7: + fldl 8(%rsp) + fmull 8(%rsp) + fldl 16(%rsp) + fmull 16(%rsp) + faddp + fsqrt + fstpl 24(%rsp) +..B1.8: + testb %cl, %cl + je ..B1.10 +..B1.9: + fldcw 34(%rsp) +..B1.10: + movq $0x7ff0000000000000, %rcx + movq 24(%rsp), %rax + cmpq %rcx, %rax + jb ..B1.19 +..B1.11: + movq 8(%rsp), %rdx + movq 16(%rsp), %rsi + btrq $63, %rdx + btrq $63, %rsi + cmpq %rcx, %rax + je ..B1.17 +..B1.12: + cmpq %rcx, %rdx + jne ..B1.14 +..B1.13: + movq %rdx, (%rsp) + movsd (%rsp), %xmm0 + movsd %xmm0, 24(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.14: + cmpq %rcx, %rsi + jne ..B1.17 +..B1.15: + movq %rsi, (%rsp) + movsd (%rsp), %xmm0 + movsd %xmm0, 24(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.17: + movsd 24(%rsp), %xmm0 +..B1.18: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.19: + movsd 24(%rsp), %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type hypot,@function + .size hypot,.-hypot + .data +# -- End hypot + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/hypotf_gen.S b/external/sgx_libm/intel64/hypotf_gen.S new file mode 100644 index 0000000000..6a1b3d8b1c --- /dev/null +++ b/external/sgx_libm/intel64/hypotf_gen.S @@ -0,0 +1,100 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "hypotf_gen.c" + .text +..TXTST0: +# -- Begin hypotf + .text + .align 16,0x90 + .globl hypotf +hypotf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_hypotf.1: +..L2: + + movaps %xmm1, %xmm3 + movaps %xmm0, %xmm1 + pxor %xmm0, %xmm0 + pxor %xmm2, %xmm2 + cvtss2sd %xmm1, %xmm0 + cvtss2sd %xmm3, %xmm2 + mulsd %xmm0, %xmm0 + mulsd %xmm2, %xmm2 + addsd %xmm2, %xmm0 + sqrtsd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm0 + movd %xmm0, %eax + cmpl $2139095040, %eax + jb ..B1.8 +..B1.2: + movd %xmm1, %edx + movd %xmm3, %ecx + andl $2147483647, %edx + andl $2147483647, %ecx + cmpl $2139095040, %eax + je ..B1.8 +..B1.4: + cmpl $2139095040, %edx + jne ..B1.6 +..B1.5: + movl %edx, -8(%rsp) + movss -8(%rsp), %xmm0 + ret +..B1.6: + cmpl $2139095040, %ecx + jne ..B1.8 +..B1.7: + movl %ecx, -8(%rsp) + movss -8(%rsp), %xmm0 +..B1.8: + ret + .align 16,0x90 + .cfi_endproc + .type hypotf,@function + .size hypotf,.-hypotf + .data +# -- End hypotf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/hypotl.S b/external/sgx_libm/intel64/hypotl.S new file mode 100644 index 0000000000..4e5f91abcc --- /dev/null +++ b/external/sgx_libm/intel64/hypotl.S @@ -0,0 +1,849 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "hypotl.c" + .text +..TXTST0: +# -- Begin hypotl + .text + .align 16,0x90 + .globl hypotl +hypotl: +# parameter 1: 32 + %rsp +# parameter 2: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_hypotl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + xorb %sil, %sil +..B1.2: + fnstcw 18(%rsp) +..B1.3: + andb $127, 41(%rsp) + andb $127, 57(%rsp) + movzwl 40(%rsp), %edx + andl $32767, %edx + movzwl 56(%rsp), %eax + andl $32767, %eax + cmpl $32767, %edx + je ..B1.67 +..B1.4: + cmpl $32767, %eax + je ..B1.67 +..B1.5: + movl %edx, %ecx + subl %eax, %ecx + lea 64(%rcx), %edi + cmpl $128, %edi + ja ..B1.25 +..B1.6: + lea (%rdx,%rax), %edi + cmpl $18376, %edi + jge ..B1.35 +..B1.7: + testl %edx, %edx + jne ..B1.12 +..B1.8: + cmpq $0, 32(%rsp) + jne ..B1.12 +..B1.9: + testl %eax, %eax + jne ..B1.12 +..B1.10: + cmpq $0, 48(%rsp) + jne ..B1.12 +..B1.11: + lea _zeros(%rip), %rax + fldl (%rax) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.12: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.16 +..B1.13: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.14: + fldcw 16(%rsp) +..B1.15: + movb $1, %sil +..B1.16: + fldt 32(%rsp) + lea _scales(%rip), %rax + fldt 48(%rsp) + lea 4(%rcx), %edx + cmpl $8, %edx + fldt (%rax) + fmul %st, %st(2) + fmulp %st, %st(1) + ja ..B1.20 +..B1.17: + lea _TWO_48H(%rip), %rax + fld %st(1) + fld %st(2) + fld %st(3) + fld %st(3) + lea _TWO_32H(%rip), %rdx + fxch %st(5) + fcomi %st(4), %st + fldl (%rax) + fmul %st, %st(4) + fxch %st(3) + fadd %st(4), %st + fsubp %st, %st(4) + fld %st(3) + fld %st(5) + fxch %st(4) + fmul %st(6), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(3) + fxch %st(3) + fsub %st(5), %st + fmul %st, %st(1) + fxch %st(4) + fsubr %st, %st(7) + fxch %st(3) + fmul %st(7), %st + fxch %st(2) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + fld %st(0) + fxch %st(3) + fmul %st(0), %st + fadd %st, %st(3) + fldl (%rdx) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + jbe ..B1.19 +..B1.18: + fxch %st(1) + fsubr %st(4), %st + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + jmp ..B1.22 +..B1.19: + fxch %st(2) + fsubr %st(4), %st + fsubrp %st, %st(1) + faddp %st, %st(2) + fxch %st(2) + jmp ..B1.22 +..B1.20: + lea _TWO_48H(%rip), %rax + lea _TWO_32H(%rip), %rdx + testl %ecx, %ecx + fldl (%rax) + fldl (%rdx) + jle ..B1.34 +..B1.21: + fxch %st(1) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(0), %st + fxch %st(2) + fxch %st(1) + fxch %st(2) +..B1.22: + fld %st(0) + lea 16+_scales(%rip), %rax + testb %sil, %sil + fadd %st(2), %st + fsqrt + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fsubrp %st, %st(2) + fld %st(3) + fxch %st(1) + fsub %st(4), %st + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(2) + fadd %st(2), %st + fdivrp %st, %st(1) + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 18(%rsp) +..B1.24: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.25: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.26: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.27: + fldcw 16(%rsp) +..B1.28: + movb $1, %sil +..B1.29: + fldt 32(%rsp) + lea 16+_ranges(%rip), %rax + fldt 48(%rsp) + faddp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rax) + fcomip %st(1), %st + fstp %st(0) + jae ..B1.31 + jp ..B1.31 +..B1.30: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) +..B1.31: + testb %sil, %sil + je ..B1.33 +..B1.32: + fldcw 18(%rsp) +..B1.33: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.34: + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(3) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + jmp ..B1.22 +..B1.35: + movzwl 18(%rsp), %edx + cmpl $47156, %edi + jle ..B1.51 +..B1.36: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.40 +..B1.37: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.38: + fldcw 16(%rsp) +..B1.39: + movb $1, %sil +..B1.40: + fldt 32(%rsp) + lea 16+_scales(%rip), %rax + fldt 48(%rsp) + lea 4(%rcx), %edx + cmpl $8, %edx + fldt (%rax) + fmul %st, %st(2) + fmulp %st, %st(1) + ja ..B1.44 +..B1.41: + lea _TWO_48H(%rip), %rax + fld %st(1) + fld %st(2) + fld %st(3) + fld %st(3) + lea _TWO_32H(%rip), %rdx + fxch %st(5) + fcomi %st(4), %st + fldl (%rax) + fmul %st, %st(4) + fxch %st(3) + fadd %st(4), %st + fsubp %st, %st(4) + fld %st(3) + fld %st(5) + fxch %st(4) + fmul %st(6), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(3) + fxch %st(3) + fsub %st(5), %st + fmul %st, %st(1) + fxch %st(4) + fsubr %st, %st(7) + fxch %st(3) + fmul %st(7), %st + fxch %st(2) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + fld %st(0) + fxch %st(3) + fmul %st(0), %st + fadd %st, %st(3) + fldl (%rdx) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + jbe ..B1.43 +..B1.42: + fxch %st(1) + fsubr %st(4), %st + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + jmp ..B1.46 +..B1.43: + fxch %st(2) + fsubr %st(4), %st + fsubrp %st, %st(1) + faddp %st, %st(2) + fxch %st(2) + jmp ..B1.46 +..B1.44: + lea _TWO_48H(%rip), %rax + lea _TWO_32H(%rip), %rdx + testl %ecx, %ecx + fldl (%rax) + fldl (%rdx) + jle ..B1.65 +..B1.45: + fxch %st(1) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(0), %st + fxch %st(2) + fxch %st(1) + fxch %st(2) +..B1.46: + fldt .L_2il0floatpacket.0(%rip) + fld %st(1) + lea _ranges(%rip), %rax + fadd %st(3), %st + fsqrt + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fsubrp %st, %st(3) + fld %st(4) + fxch %st(1) + fsub %st(5), %st + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(3) + fadd %st(3), %st + fdivrp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rax) + fcomip %st(1), %st + fstp %st(0) + jp ..B1.47 + jbe ..B1.64 +..B1.47: + fldt (%rsp) + lea _scales(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.48: + testb %sil, %sil + je ..B1.50 +..B1.49: + fldcw 18(%rsp) +..B1.50: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.51: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.55 +..B1.52: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.53: + fldcw 16(%rsp) +..B1.54: + movb $1, %sil +..B1.55: + lea 4(%rcx), %eax + cmpl $8, %eax + ja ..B1.59 +..B1.56: + fldt 32(%rsp) + lea _TWO_48H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea _TWO_32H(%rip), %rdx + fldt 48(%rsp) + fld %st(0) + fxch %st(5) + fcomi %st(1), %st + fldl (%rax) + fmul %st, %st(5) + fxch %st(4) + fadd %st(5), %st + fsubp %st, %st(5) + fld %st(4) + fld %st(2) + fxch %st(3) + fmul %st, %st(5) + fxch %st(3) + fadd %st(5), %st + fsubp %st, %st(5) + fld %st(4) + fxch %st(4) + fsub %st(6), %st + fmul %st, %st(1) + fxch %st(5) + fsubr %st, %st(7) + fxch %st(4) + fmul %st(7), %st + fxch %st(2) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fmul %st(0), %st + fld %st(0) + fxch %st(2) + fmul %st(0), %st + fadd %st, %st(2) + fldl (%rdx) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + jbe ..B1.58 +..B1.57: + fxch %st(1) + fsubr %st(3), %st + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + fxch %st(1) + jmp ..B1.61 +..B1.58: + fxch %st(2) + fsubr %st(3), %st + fsubrp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + fxch %st(1) + jmp ..B1.61 +..B1.59: + fldt 32(%rsp) + lea _TWO_48H(%rip), %rax + fldt 48(%rsp) + lea _TWO_32H(%rip), %rdx + testl %ecx, %ecx + fldl (%rax) + fldl (%rdx) + jle ..B1.66 +..B1.60: + fxch %st(1) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(4) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(5) + faddp %st, %st(4) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(0), %st + fxch %st(2) + fxch %st(1) + fxch %st(2) +..B1.61: + fldt .L_2il0floatpacket.0(%rip) + fld %st(1) + testb %sil, %sil + fadd %st(3), %st + fsqrt + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fsubp %st, %st(5) + fld %st(4) + fmul %st(5), %st + fsubrp %st, %st(3) + fld %st(4) + fxch %st(1) + fsub %st(5), %st + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(3) + fadd %st(3), %st + fdivrp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.63 +..B1.62: + fldcw 18(%rsp) +..B1.63: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.64: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.48 +..B1.65: + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(3) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + jmp ..B1.46 +..B1.66: + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fld %st(3) + fsub %st(2), %st + fmul %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + jmp ..B1.61 +..B1.67: + movzwl 18(%rsp), %edi + movl %edi, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.71 +..B1.68: + orl $-64768, %edi + movw %di, 16(%rsp) +..B1.69: + fldcw 16(%rsp) +..B1.70: + movb $1, %sil +..B1.71: + cmpl $32767, %edx + je ..B1.87 +..B1.72: + cmpl $32767, %eax + je ..B1.85 +..B1.73: + fldt 32(%rsp) + fldt 48(%rsp) + faddp %st, %st(1) + fstpt (%rsp) +..B1.74: + testb %sil, %sil + je ..B1.76 +..B1.75: + fldcw 18(%rsp) +..B1.76: + cmpl $32767, %edx + je ..B1.82 +..B1.77: + cmpl $32767, %eax + jne ..B1.81 +..B1.78: + cmpl $-2147483648, 52(%rsp) + jne ..B1.81 +..B1.79: + cmpl $0, 48(%rsp) + jne ..B1.81 +..B1.80: + fldt 48(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.81: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.82: + cmpl $-2147483648, 36(%rsp) + jne ..B1.77 +..B1.83: + cmpl $0, 32(%rsp) + jne ..B1.77 +..B1.84: + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.85: + movq $0x8000000000000000, %rcx + cmpq 48(%rsp), %rcx + je ..B1.73 +..B1.86: + fldt 32(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.74 +..B1.87: + movq $0x8000000000000000, %rcx + cmpq 32(%rsp), %rcx + jne ..B1.86 + jmp ..B1.72 + .align 16,0x90 + .cfi_endproc + .type hypotl,@function + .size hypotl,.-hypotl + .data +# -- End hypotl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_scales: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24653 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8113 + .word 0 + .word 0 + .word 0 + .type _scales,@object + .size _scales,32 + .align 2 +_ranges: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24497 + .word 0 + .word 0 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 32766 + .word 0 + .word 0 + .word 0 + .type _ranges,@object + .size _ranges,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ilogb_gen.S b/external/sgx_libm/intel64/ilogb_gen.S new file mode 100644 index 0000000000..8bd3be4b36 --- /dev/null +++ b/external/sgx_libm/intel64/ilogb_gen.S @@ -0,0 +1,134 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ilogb_gen.c" + .text +..TXTST0: +# -- Begin ilogb + .text + .align 16,0x90 + .globl ilogb +ilogb: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ilogb.1: +..L2: + + movsd %xmm0, -16(%rsp) + movl -12(%rsp), %ecx + andl $2147483647, %ecx + lea -1048576(%rcx), %eax + cmpl $2145386496, %eax + jb ..B1.4 +..B1.2: + testl %eax, %eax + jl ..B1.5 +..B1.3: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + addl $-2146435072, %ecx + orl -16(%rsp), %ecx + movl $2147483647, %ecx + movsd (%rax), %xmm0 + movl $-2147483648, %eax + mulsd (%rdx), %xmm0 + cmove %ecx, %eax + movsd %xmm0, -24(%rsp) + ret +..B1.4: + shrl $20, %eax + addl $-1022, %eax + ret +..B1.5: + movl -16(%rsp), %eax + orl %eax, %ecx + je ..B1.7 +..B1.6: + lea _TWO_55(%rip), %rax + movsd -16(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -16(%rsp) + movl -12(%rsp), %eax + andl $2147483647, %eax + shrl $20, %eax + addl $-1078, %eax + ret +..B1.7: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + movl $-2147483648, %eax + mulsd (%rdx), %xmm0 + movsd %xmm0, -24(%rsp) + ret + .align 16,0x90 + .cfi_endproc + .type ilogb,@function + .size ilogb,.-ilogb + .data +# -- End ilogb + .section .rodata, "a" + .align 4 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .type _TWO_55,@object + .size _TWO_55,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ilogbf.S b/external/sgx_libm/intel64/ilogbf.S new file mode 100644 index 0000000000..be18f3b22b --- /dev/null +++ b/external/sgx_libm/intel64/ilogbf.S @@ -0,0 +1,116 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ilogbf.c" + .text +..TXTST0: +# -- Begin ilogbf + .text + .align 16,0x90 + .globl ilogbf +ilogbf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ilogbf.1: +..L2: + + movd %xmm0, %ecx + movss %xmm0, -16(%rsp) + andl $2147483647, %ecx + addl $-8388608, %ecx + cmpl $2130706432, %ecx + jb ..B1.4 +..B1.2: + testl %ecx, %ecx + jl ..B1.5 +..B1.3: + movl $2147483647, %edx + movl $-2147483648, %eax + cmpl $2130706432, %ecx + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 + cmove %edx, %eax + movss %xmm0, -24(%rsp) + ret +..B1.4: + shrl $23, %ecx + addl $-126, %ecx + movl %ecx, %eax + ret +..B1.5: + cmpl $-8388608, %ecx + je ..B1.7 +..B1.6: + movss -16(%rsp), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + movd %xmm0, %eax + movss %xmm0, -16(%rsp) + andl $2147483647, %eax + shrl $23, %eax + addl $-152, %eax + ret +..B1.7: + movl $-2147483648, %eax + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, -24(%rsp) + ret + .align 16,0x90 + .cfi_endproc + .type ilogbf,@function + .size ilogbf,.-ilogbf + .data +# -- End ilogbf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x7f800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ilogbl.S b/external/sgx_libm/intel64/ilogbl.S new file mode 100644 index 0000000000..0b9cff62e4 --- /dev/null +++ b/external/sgx_libm/intel64/ilogbl.S @@ -0,0 +1,200 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ilogbl.c" + .text +..TXTST0: +# -- Begin ilogbl + .text + .align 16,0x90 + .globl ilogbl +ilogbl: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_ilogbl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + fnstcw 10(%rsp) +..B1.3: + movzwl 40(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.19 +..B1.4: + testl %eax, %eax + jne ..B1.12 +..B1.5: + movzwl 10(%rsp), %edx + cmpq $0, 32(%rsp) + je ..B1.14 +..B1.6: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.13 +..B1.7: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.8: + fldcw 8(%rsp) +..B1.9: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) +..B1.10: + fldcw 10(%rsp) +..B1.11: + movzwl 40(%rsp), %eax + andl $32767, %eax + addl $-16458, %eax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.12: + addl $-16383, %eax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.13: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) + jmp ..B1.11 +..B1.14: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.18 +..B1.15: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.16: + fldcw 8(%rsp) +..B1.17: + fldcw 10(%rsp) +..B1.18: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + movl $-2147483648, %eax + mulsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.19: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + cmpl $-2147483648, 36(%rsp) + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + jne ..B1.22 +..B1.20: + cmpl $0, 32(%rsp) + jne ..B1.22 +..B1.21: + movl $2147483647, %eax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.22: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.26 +..B1.23: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.24: + fldcw 8(%rsp) +..B1.25: + fldcw 10(%rsp) +..B1.26: + movl $-2147483648, %eax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ilogbl,@function + .size ilogbl,.-ilogbl + .data +# -- End ilogbl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/intel_quad_exception.S b/external/sgx_libm/intel64/intel_quad_exception.S new file mode 100644 index 0000000000..d68df25de4 --- /dev/null +++ b/external/sgx_libm/intel64/intel_quad_exception.S @@ -0,0 +1,1993 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "intel_quad_exception.c" + .text +..TXTST0: +# -- Begin __dpml_exception + .text + .align 16,0x90 + .globl __dpml_exception +__dpml_exception: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value___dpml_exception.1: +..L2: + + movq $0x7fffffffffffffff, %rdx + movq (%rdi), %rsi + andq %rsi, %rdx + testq %rsi, %rsi + lea 7+__dpml_response_table(%rip), %rax + lea 6+__dpml_response_table(%rip), %rcx + lea 32(%rdi), %r11 + cmovl %rdx, %rsi + movq $0xffffffff07ffffff, %rdx + andq %rsi, %rdx + movq %rsi, %r9 + shrq $27, %r9 + movq __dpml_globals_table@GOTPCREL(%rip), %r10 + movzbl (%rax,%rdx,8), %r8d + shlq $5, %r8 + movzbl (%rcx,%rdx,8), %esi + addq $-4, %rdx + lea (%r8,%r9,8), %rcx + addq %r10, %rcx + cmpl $4, %esi + cmove %r11, %rcx + cmpq $171, %rdx + ja ..B1.69 +..B1.2: + movl %edx, %r8d + lea .2.9_2.switchtab.1(%rip), %rdx + movzbl (%rdx,%r8), %edx + lea ..1.1_0.TAG.12.0.1(%rip), %rax + addq %rdx, %rax + jmp *%rax +..1.1_0.TAG.12.0.1: +..1.1_0.TAG.9.0.1: +..1.1_0.TAG.11.0.1: +..1.1_0.TAG.8.0.1: +..B1.59: + xorl %esi, %esi + lea 32(%rdi), %rcx + jmp ..B1.70 +..1.1_0.TAG.171.0.1: +..1.1_0.TAG.170.0.1: +..1.1_0.TAG.145.0.1: +..1.1_0.TAG.144.0.1: +..1.1_0.TAG.140.0.1: +..1.1_0.TAG.139.0.1: +..1.1_0.TAG.138.0.1: +..1.1_0.TAG.136.0.1: +..1.1_0.TAG.135.0.1: +..1.1_0.TAG.133.0.1: +..1.1_0.TAG.128.0.1: +..1.1_0.TAG.127.0.1: +..1.1_0.TAG.126.0.1: +..1.1_0.TAG.125.0.1: +..1.1_0.TAG.116.0.1: +..1.1_0.TAG.115.0.1: +..1.1_0.TAG.114.0.1: +..1.1_0.TAG.112.0.1: +..1.1_0.TAG.111.0.1: +..1.1_0.TAG.104.0.1: +..1.1_0.TAG.103.0.1: +..1.1_0.TAG.102.0.1: +..1.1_0.TAG.101.0.1: +..1.1_0.TAG.100.0.1: +..1.1_0.TAG.99.0.1: +..1.1_0.TAG.98.0.1: +..1.1_0.TAG.97.0.1: +..1.1_0.TAG.79.0.1: +..1.1_0.TAG.76.0.1: +..1.1_0.TAG.67.0.1: +..1.1_0.TAG.64.0.1: +..1.1_0.TAG.62.0.1: +..1.1_0.TAG.61.0.1: +..1.1_0.TAG.59.0.1: +..1.1_0.TAG.58.0.1: +..1.1_0.TAG.56.0.1: +..1.1_0.TAG.55.0.1: +..1.1_0.TAG.34.0.1: +..1.1_0.TAG.33.0.1: +..1.1_0.TAG.32.0.1: +..1.1_0.TAG.31.0.1: +..1.1_0.TAG.30.0.1: +..1.1_0.TAG.29.0.1: +..1.1_0.TAG.28.0.1: +..1.1_0.TAG.26.0.1: +..1.1_0.TAG.25.0.1: +..1.1_0.TAG.24.0.1: +..1.1_0.TAG.23.0.1: +..1.1_0.TAG.22.0.1: +..1.1_0.TAG.19.0.1: +..1.1_0.TAG.18.0.1: +..1.1_0.TAG.13.0.1: +..1.1_0.TAG.10.0.1: +..1.1_0.TAG.7.0.1: +..1.1_0.TAG.6.0.1: +..1.1_0.TAG.4.0.1: +..1.1_0.TAG.3.0.1: +..1.1_0.TAG.2.0.1: +..1.1_0.SWBASE.0.1: +..1.1_0.TAG.0.0.1: +..B1.69: + cmpl $4, %esi + ja ..B1.81 +..B1.70: + lea .2.9_2.switchtab.2(%rip), %rdx + movzbl (%rdx,%rsi), %edx + lea ..1.1_1.TAG.4.0.1(%rip), %rax + addq %rdx, %rax + jmp *%rax +..1.1_1.TAG.4.0.1: +..B1.72: + movl $8388608, -16(%rsp) + movss -16(%rsp), %xmm0 + cvtss2sd %xmm0, %xmm0 + mulsd .L_2il0floatpacket.2(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + jmp ..B1.81 +..1.1_1.TAG.3.0.1: +..B1.74: + movl $2130706432, -20(%rsp) + movss -20(%rsp), %xmm1 + movss -20(%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss %xmm1, -20(%rsp) + jmp ..B1.81 +..1.1_1.TAG.2.0.1: +..B1.76: + movl $0, -8(%rsp) +..B1.77: + movss -8(%rsp), %xmm0 + cvtss2sd %xmm0, %xmm0 + movsd .L_2il0floatpacket.3(%rip), %xmm1 + divsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, -8(%rsp) + jmp ..B1.81 +..1.1_1.TAG.1.0.1: +..B1.79: + movl $2139095040, -24(%rsp) + movss -24(%rsp), %xmm1 + movss -24(%rsp), %xmm0 + subss %xmm0, %xmm1 + movss %xmm1, -24(%rsp) +..1.1_1.TAG.0.0.1: +..B1.81: + movq %rcx, %rax + ret + .align 16,0x90 + .cfi_endproc + .type __dpml_exception,@function + .size __dpml_exception,.-__dpml_exception + .section .rodata, "a" + .align 8 + .align 1 +.2.9_2.switchtab.1: + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.12.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .byte ..1.1_0.TAG.171.0.1 - ..1.1_0.TAG.12.0.1 + .align 1 +.2.9_2.switchtab.2: + .byte ..1.1_1.TAG.0.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.1.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.2.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.3.0.1 - ..1.1_1.TAG.4.0.1 + .byte ..1.1_1.TAG.4.0.1 - ..1.1_1.TAG.4.0.1 + .data +# -- End __dpml_exception + .text +# -- Begin __dpml_intel_atan_fixup + .text + .align 16,0x90 + .globl __dpml_intel_atan_fixup +__dpml_intel_atan_fixup: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B2.1: + .cfi_startproc +..___tag_value___dpml_intel_atan_fixup.4: +..L5: + + movq %rcx, %r9 + movq %rdx, %rcx + movq %rdi, %rdx + btrq $63, %rdx + movl $4, %r10d + movq %rdx, %rax + movq %rdx, %r11 + sarq $4, %r11 + andq $15, %rax + testq %r9, %r9 + cmovne %r11, %rdx + cmove %r10, %rax + xorb %dil, %dil + lea (%rdx,%rdx,4), %r9 + lea -22(%rax,%r9,2), %rax + cmpq $77, %rax + ja ..B2.56 +..B2.2: + movl %eax, %eax + lea .2.10_2.switchtab.4(%rip), %rdx + movzwl (%rdx,%rax,2), %edx + lea ..1.2_0.TAG.77.0.2(%rip), %rax + addq %rdx, %rax + jmp *%rax +..1.2_0.TAG.77.0.2: +..B2.4: + movl $5, %eax + movl $11, %r8d + movb $3, %dil + testq %rcx, %rcx + cmovne %rax, %r8 + jne ..B2.51 + jmp ..B2.52 +..1.2_0.TAG.76.0.2: +..B2.6: + movq __x_constants__@GOTPCREL(%rip), %r8 + movq 8(%r8), %rax + jmp ..B2.54 +..1.2_0.TAG.75.0.2: +..1.2_0.TAG.73.0.2: +..1.2_0.TAG.71.0.2: +..1.2_0.TAG.65.0.2: +..1.2_0.TAG.63.0.2: +..1.2_0.TAG.61.0.2: +..1.2_0.TAG.57.0.2: +..1.2_0.TAG.56.0.2: +..1.2_0.TAG.51.0.2: +..1.2_0.TAG.47.0.2: +..1.2_0.TAG.46.0.2: +..1.2_0.TAG.41.0.2: +..1.2_0.TAG.37.0.2: +..1.2_0.TAG.36.0.2: +..1.2_0.TAG.31.0.2: +..1.2_0.TAG.27.0.2: +..1.2_0.TAG.26.0.2: +..1.2_0.TAG.21.0.2: +..1.2_0.TAG.17.0.2: +..1.2_0.TAG.16.0.2: +..1.2_0.TAG.15.0.2: +..1.2_0.TAG.14.0.2: +..1.2_0.TAG.13.0.2: +..1.2_0.TAG.12.0.2: +..1.2_0.TAG.7.0.2: +..1.2_0.TAG.6.0.2: +..1.2_0.TAG.5.0.2: +..1.2_0.TAG.4.0.2: +..1.2_0.TAG.3.0.2: +..1.2_0.TAG.2.0.2: +..B2.7: + testq %rcx, %rcx + jne ..B2.51 + jmp ..B2.52 +..1.2_0.TAG.67.0.2: +..B2.11: + movl $5, %eax + movl $11, %r8d + movb $2, %dil + testq %rcx, %rcx + cmovne %rax, %r8 + jne ..B2.51 + jmp ..B2.52 +..1.2_0.TAG.66.0.2: +..B2.13: + movq __x_constants__@GOTPCREL(%rip), %r8 + movq 8(%r8), %rax + jmp ..B2.55 +..1.2_0.TAG.11.0.2: +..B2.36: + movl $6, %eax + movl $10, %r8d + movb $3, %dil + testq %rcx, %rcx + cmovne %rax, %r8 + jne ..B2.51 + jmp ..B2.52 +..1.2_0.TAG.10.0.2: +..B2.38: + movl $8, %r8d + movb $3, %dil + testq %rcx, %rcx + cmovne %r10, %r8 + jne ..B2.51 + jmp ..B2.52 +..1.2_0.TAG.1.0.2: +..B2.47: + movl $6, %eax + movl $10, %r8d + movb $2, %dil + testq %rcx, %rcx + cmovne %rax, %r8 + jne ..B2.51 + jmp ..B2.52 +..1.2_0.TAG.0.0.2: +..B2.49: + movl $8, %r8d + movb $2, %dil + testq %rcx, %rcx + cmovne %r10, %r8 +..B2.50: + je ..B2.52 +..B2.51: + movl $1182793727, -8(%rsp) + movss -8(%rsp), %xmm1 + movss -8(%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss %xmm1, -8(%rsp) +..B2.52: + testb %dil, %dil + je ..B2.56 +..B2.53: + shlq $4, %r8 + movq __x_constants__@GOTPCREL(%rip), %rax + addq %rax, %r8 + cmpb $3, %dil + movq 8(%r8), %rax + jne ..B2.55 +..B2.54: + btcq $63, %rax +..B2.55: + movq %rax, 8(%rsi) + movq (%r8), %rax + movq %rax, (%rsi) + ret +..1.2_0.SWBASE.0.2: +..B2.56: + ret + .align 16,0x90 + .cfi_endproc + .type __dpml_intel_atan_fixup,@function + .size __dpml_intel_atan_fixup,.-__dpml_intel_atan_fixup + .section .rodata, "a" + .space 1, 0x00 # pad + .align 2 +.2.10_2.switchtab.4: + .word ..1.2_0.TAG.0.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.1.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.10.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.11.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.66.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.67.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.SWBASE.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.75.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.76.0.2 - ..1.2_0.TAG.77.0.2 + .word ..1.2_0.TAG.77.0.2 - ..1.2_0.TAG.77.0.2 + .data +# -- End __dpml_intel_atan_fixup + .text +# -- Begin __dpml_intel_pow_fixup + .text + .align 16,0x90 + .globl __dpml_intel_pow_fixup +__dpml_intel_pow_fixup: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +# parameter 7: 96 + %rsp +..B3.1: + .cfi_startproc +..___tag_value___dpml_intel_pow_fixup.7: +..L8: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $48, %rsp + .cfi_def_cfa_offset 96 + movq %rdi, %r12 + movq %rcx, %r11 + movq %r12, %rcx + sarq $4, %rcx + movq %r12, %r10 + andq $15, %rcx + andq $15, %r10 + movq %r9, %rbx + movq %rsi, %rbp + testq %r12, %r12 + lea (%rcx,%rcx,4), %rcx + lea (%r10,%rcx,2), %r9 + jl ..B3.20 +..B3.2: + movq $0x8000000000000000, %r14 + movl $1, %r15d + xorl %ecx, %ecx + cmpq 8(%r11), %r14 + cmove %r15d, %ecx + xorl %eax, %eax + cmpq $0, 16(%r11) + cmove %r15d, %eax + andl %eax, %ecx + cmpq $94, %r9 + je ..B3.19 +..B3.3: + lea -42(%r9), %rax + cmpq $1, %rax + jbe ..B3.13 +..B3.4: + lea -52(%r9), %rax + cmpq $1, %rax + jbe ..B3.13 +..B3.5: + lea -34(%r9), %rcx + cmpq $1, %rcx + ja ..B3.7 +..B3.6: + xorl %ebx, %ebx + cmpq $5, %r10 + movq $0x7fff000000000000, %rdi + movq __x_constants__@GOTPCREL(%rip), %rdx + cmove %rbx, %rdi + movq 96(%rsp), %r10 + cmpq $3, %r10 + cmove %r14, %rbx + orq %r14, %r12 + movq (%rdx), %rcx + xorq %rbx, %rdi + movq %rcx, (%rbp) + movq %rdi, 8(%rbp) + jmp ..B3.16 +..B3.7: + cmpq $44, %r9 + jne ..B3.16 +..B3.8: + movq __x_constants__@GOTPCREL(%rip), %r9 + movq 8(%r8), %rcx + cmpq 24(%r9), %rcx + jne ..B3.16 +..B3.9: + movq (%r8), %rcx + cmpq 16(%r9), %rcx + jne ..B3.16 +..B3.10: + movq %r11, %rdi + movl $7, %esi + movq %rbx, %rdx +..___tag_value___dpml_intel_pow_fixup.20: + call __dpml_ux_sqrt_evaluation__@PLT +..___tag_value___dpml_intel_pow_fixup.21: +..B3.11: + xorl %r9d, %r9d + testq %rax, %rax + movq %rbx, %rdi + cmove %r15d, %r9d + xorl %edx, %edx + movq %rbp, %rsi + xorl %ecx, %ecx + lea (%rsp), %r8 + movq %r9, 8(%r8) +..___tag_value___dpml_intel_pow_fixup.22: + call __dpml_pack__@PLT +..___tag_value___dpml_intel_pow_fixup.23: + jmp ..B3.15 +..B3.13: + movq __x_constants__@GOTPCREL(%rip), %rdx + movq 32(%rdx), %rbx + movq 40(%rdx), %r8 + movl 4(%r11), %edx + cmpl $1, %edx + movq %rbx, (%rbp) + je ..B3.17 +..B3.14: + testl %edx, %edx + movl $0, %edx + movq $0x7fff000000000000, %rcx + cmovle %r15d, %edx + xorl %ebx, %ebx + cmpq $2, %r10 + movl $0, %r10d + cmove %r15d, %r10d + cmpl %edx, %r10d + cmovne %rcx, %rbx + movq %rbx, 8(%rbp) +..B3.15: + orq %r14, %r12 +..B3.16: + movq %r12, %rax + addq $48, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B3.17: + testl %ecx, %ecx + je ..B3.14 +..B3.18: + movq %r8, 8(%rbp) + jmp ..B3.15 +..B3.19: + movq 96(%rsp), %rcx + xorl %ebx, %ebx + cmpq $3, %rcx + cmove %r14, %rbx + orq %r14, %r12 + movq %rbx, 8(%rbp) + movq (%rdx), %rdx + movq %rdx, (%rbp) + jmp ..B3.16 +..B3.20: + cmpq $95, %r9 + je ..B3.32 +..B3.21: + lea -40(%r9), %rcx + cmpq $1, %rcx + jbe ..B3.29 +..B3.22: + lea -80(%r9), %rcx + cmpq $1, %rcx + jbe ..B3.28 +..B3.23: + lea -90(%r9), %rcx + cmpq $1, %rcx + jbe ..B3.28 +..B3.24: + addq $-46, %r9 + cmpq $1, %r9 + ja ..B3.16 +..B3.25: + movq __x_constants__@GOTPCREL(%rip), %rbx + movq 8(%rdx), %rcx + cmpq 40(%rbx), %rcx + jne ..B3.27 +..B3.26: + movq (%rdx), %rdx + cmpq 32(%rbx), %rdx + je ..B3.16 +..B3.27: + movl $1182793727, 40(%rsp) + movss 40(%rsp), %xmm1 + movss 40(%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss %xmm1, 40(%rsp) + jmp ..B3.16 +..B3.28: + movq 8(%r8), %rdx + btsq $47, %rdx + movq %rdx, 8(%rbp) + movq (%r8), %rcx + movq %rcx, (%rbp) + jmp ..B3.16 +..B3.29: + movq __x_constants__@GOTPCREL(%rip), %rcx + movq 40(%rcx), %rbx + cmpq 8(%rdx), %rbx + jne ..B3.28 +..B3.30: + movq 32(%rcx), %rcx + cmpq (%rdx), %rcx + jne ..B3.28 +..B3.31: + movq %rbx, 8(%rbp) + movq %rcx, (%rbp) + jmp ..B3.16 +..B3.32: + movq 96(%rsp), %rdx + testq %rdx, %rdx + je ..B3.16 +..B3.33: + movq 96(%rsp), %rdx + testq $2, %rdx + je ..B3.16 +..B3.34: + movq 8(%rbp), %rdx + btcq $63, %rdx + movq %rdx, 8(%rbp) + jmp ..B3.16 + .align 16,0x90 + .cfi_endproc + .type __dpml_intel_pow_fixup,@function + .size __dpml_intel_pow_fixup,.-__dpml_intel_pow_fixup + .data +# -- End __dpml_intel_pow_fixup + .text +# -- Begin __dpml_d_intel_order_fixup + .text + .align 16,0x90 + .globl __dpml_d_intel_order_fixup +__dpml_d_intel_order_fixup: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value___dpml_d_intel_order_fixup.42: +..L43: + + ret + .align 16,0x90 + .cfi_endproc + .type __dpml_d_intel_order_fixup,@function + .size __dpml_d_intel_order_fixup,.-__dpml_d_intel_order_fixup + .data +# -- End __dpml_d_intel_order_fixup + .section .rodata, "a" + .space 2, 0x00 # pad + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3e600000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 4 +__dpml_response_table: + .long 0 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 1 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 2 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 3 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 3 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 4 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 4 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 6 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 7 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 8 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 8 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 8 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 9 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 9 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 9 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 10 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 10 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 10 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 11 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 11 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 39 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 39 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 12 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 13 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 14 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 33 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 33 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 33 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 33 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 33 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 33 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 34 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 34 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 34 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 34 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 34 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 34 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 34 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 34 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 16 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 16 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 16 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 16 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 17 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 17 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 17 + .byte 0 + .byte 12 + .byte 0 + .byte 12 + .long 38 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 38 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 38 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 47 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 47 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 47 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 47 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 47 + .byte 0 + .byte 8 + .byte 0 + .byte 8 + .long 47 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 47 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 47 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 37 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 18 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 18 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 18 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 19 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 19 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 19 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 20 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 20 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 20 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 45 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 45 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 21 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 21 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 21 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 40 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 40 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 40 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 40 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 22 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 22 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 22 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 22 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 22 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 22 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 22 + .byte 0 + .byte 11 + .byte 0 + .byte 11 + .long 22 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 22 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 22 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 22 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 22 + .byte 0 + .byte 8 + .byte 0 + .byte 8 + .long 22 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 22 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 22 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 41 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 41 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 41 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 41 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 41 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 41 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 41 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 48 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 48 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 23 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 23 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 23 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 24 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 31 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 32 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 32 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 25 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 25 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 26 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 26 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 26 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 27 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 63 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 63 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 28 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 29 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 29 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 29 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 29 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 29 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 30 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 30 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 35 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 36 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 36 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 49 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 50 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 51 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 50 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 50 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 51 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 51 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 42 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 43 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 44 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 42 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 42 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 43 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 43 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 43 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 44 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 44 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 44 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 44 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 46 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 46 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 46 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 46 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 46 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 53 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 78 + .byte 0 + .byte 1 + .byte 0 + .byte 0 + .long 64 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 64 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 64 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 64 + .byte 0 + .byte 1 + .byte 0 + .byte 1 + .long 66 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 66 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 66 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 67 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 67 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 67 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 65 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 65 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 65 + .byte 0 + .byte 7 + .byte 0 + .byte 7 + .long 65 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 65 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 65 + .byte 2 + .byte 6 + .byte 2 + .byte 8 + .long 65 + .byte 2 + .byte 5 + .byte 2 + .byte 7 + .long 68 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 69 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 70 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 71 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 72 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 72 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 72 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 73 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 73 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 73 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 73 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 74 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 74 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 77 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 77 + .byte 4 + .byte 2 + .byte 4 + .byte 2 + .long 77 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .long 77 + .byte 3 + .byte 6 + .byte 3 + .byte 8 + .long 77 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 77 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .long 79 + .byte 4 + .byte 1 + .byte 4 + .byte 1 + .long 79 + .byte 3 + .byte 5 + .byte 3 + .byte 7 + .type __dpml_response_table,@object + .size __dpml_response_table,1520 + .align 4 + .globl __dpml_globals_table +__dpml_globals_table: + .long 4290772992 + .long 0 + .long 0 + .long 4294443008 + .long 0 + .long 0 + .long 0 + .long 4294934528 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 2147483648 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1 + .long 0 + .long 1 + .long 0 + .long 1 + .long 0 + .long 0 + .long 0 + .long 2147483649 + .long 0 + .long 1 + .long 2147483648 + .long 1 + .long 0 + .long 0 + .long 2147483648 + .long 2139095039 + .long 0 + .long 4294967295 + .long 2146435071 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 2147418111 + .long 4286578687 + .long 0 + .long 4294967295 + .long 4293918719 + .long 4294967295 + .long 4294967295 + .long 4294967295 + .long 4294901759 + .long 2139095040 + .long 0 + .long 0 + .long 2146435072 + .long 0 + .long 0 + .long 0 + .long 2147418112 + .long 4286578688 + .long 0 + .long 0 + .long 4293918720 + .long 0 + .long 0 + .long 0 + .long 4294901760 + .long 872415232 + .long 0 + .long 0 + .long 1018167296 + .long 0 + .long 0 + .long 0 + .long 1066336256 + .long 3019898880 + .long 0 + .long 0 + .long 3165650944 + .long 0 + .long 0 + .long 0 + .long 3213819904 + .long 1065353216 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 1073676288 + .long 3212836864 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 3221159936 + .type __dpml_globals_table,@object + .size __dpml_globals_table,416 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/isfinite.S b/external/sgx_libm/intel64/isfinite.S new file mode 100644 index 0000000000..c1b5e34cac --- /dev/null +++ b/external/sgx_libm/intel64/isfinite.S @@ -0,0 +1,449 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isfinite.c" + .text +..TXTST0: +# -- Begin isfinitel + .text + .align 16,0x90 + .globl isfinitel +isfinitel: +# parameter 1: 8 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_isfinitel.1: +..L2: + + xorl %eax, %eax + movzwl 16(%rsp), %ecx + shll $16, %ecx + movzwl 14(%rsp), %edx + orl %edx, %ecx + andl $2147483647, %ecx + cmpl $2147418112, %ecx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isfinitel,@function + .size isfinitel,.-isfinitel + .data +# -- End isfinitel + .text +# -- Begin __isfinitel + .text + .align 16,0x90 + .globl __isfinitel +__isfinitel: +# parameter 1: 8 + %rsp +..B2.1: + .cfi_startproc +..___tag_value___isfinitel.4: +..L5: + + xorl %eax, %eax + movzwl 16(%rsp), %ecx + shll $16, %ecx + movzwl 14(%rsp), %edx + orl %edx, %ecx + andl $2147483647, %ecx + cmpl $2147418112, %ecx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isfinitel,@function + .size __isfinitel,.-__isfinitel + .data +# -- End __isfinitel + .text +# -- Begin isfinitef + .text + .align 16,0x90 + .globl isfinitef +isfinitef: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value_isfinitef.7: +..L8: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isfinitef,@function + .size isfinitef,.-isfinitef + .data +# -- End isfinitef + .text +# -- Begin __isfinitef + .text + .align 16,0x90 + .globl __isfinitef +__isfinitef: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value___isfinitef.10: +..L11: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isfinitef,@function + .size __isfinitef,.-__isfinitef + .data +# -- End __isfinitef + .text +# -- Begin isfinite + .text + .align 16,0x90 + .globl isfinite +isfinite: +# parameter 1: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value_isfinite.13: +..L14: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isfinite,@function + .size isfinite,.-isfinite + .data +# -- End isfinite + .text +# -- Begin __isfinite + .text + .align 16,0x90 + .globl __isfinite +__isfinite: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value___isfinite.16: +..L17: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isfinite,@function + .size __isfinite,.-__isfinite + .data +# -- End __isfinite + .text +# -- Begin isfinited + .text + .align 16,0x90 + .globl isfinited +isfinited: +# parameter 1: %xmm0 +..B7.1: + .cfi_startproc +..___tag_value_isfinited.19: +..L20: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isfinited,@function + .size isfinited,.-isfinited + .data +# -- End isfinited + .text +# -- Begin __isfinited + .text + .align 16,0x90 + .globl __isfinited +__isfinited: +# parameter 1: %xmm0 +..B8.1: + .cfi_startproc +..___tag_value___isfinited.22: +..L23: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isfinited,@function + .size __isfinited,.-__isfinited + .data +# -- End __isfinited + .text +# -- Begin finitel + .text + .align 16,0x90 + .globl finitel +finitel: +# parameter 1: 8 + %rsp +..B9.1: + .cfi_startproc +..___tag_value_finitel.25: +..L26: + + xorl %eax, %eax + movzwl 16(%rsp), %ecx + shll $16, %ecx + movzwl 14(%rsp), %edx + orl %edx, %ecx + andl $2147483647, %ecx + cmpl $2147418112, %ecx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type finitel,@function + .size finitel,.-finitel + .data +# -- End finitel + .text +# -- Begin __finitel + .text + .align 16,0x90 + .globl __finitel +__finitel: +# parameter 1: 8 + %rsp +..B10.1: + .cfi_startproc +..___tag_value___finitel.28: +..L29: + + xorl %eax, %eax + movzwl 16(%rsp), %ecx + shll $16, %ecx + movzwl 14(%rsp), %edx + orl %edx, %ecx + andl $2147483647, %ecx + cmpl $2147418112, %ecx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __finitel,@function + .size __finitel,.-__finitel + .data +# -- End __finitel + .text +# -- Begin finitef + .text + .align 16,0x90 + .globl finitef +finitef: +# parameter 1: %xmm0 +..B11.1: + .cfi_startproc +..___tag_value_finitef.31: +..L32: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type finitef,@function + .size finitef,.-finitef + .data +# -- End finitef + .text +# -- Begin __finitef + .text + .align 16,0x90 + .globl __finitef +__finitef: +# parameter 1: %xmm0 +..B12.1: + .cfi_startproc +..___tag_value___finitef.34: +..L35: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __finitef,@function + .size __finitef,.-__finitef + .data +# -- End __finitef + .text +# -- Begin finite + .text + .align 16,0x90 + .globl finite +finite: +# parameter 1: %xmm0 +..B13.1: + .cfi_startproc +..___tag_value_finite.37: +..L38: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type finite,@function + .size finite,.-finite + .data +# -- End finite + .text +# -- Begin __finite + .text + .align 16,0x90 + .globl __finite +__finite: +# parameter 1: %xmm0 +..B14.1: + .cfi_startproc +..___tag_value___finite.40: +..L41: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __finite,@function + .size __finite,.-__finite + .data +# -- End __finite + .text +# -- Begin finited + .text + .align 16,0x90 + .globl finited +finited: +# parameter 1: %xmm0 +..B15.1: + .cfi_startproc +..___tag_value_finited.43: +..L44: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type finited,@function + .size finited,.-finited + .data +# -- End finited + .text +# -- Begin __finited + .text + .align 16,0x90 + .globl __finited +__finited: +# parameter 1: %xmm0 +..B16.1: + .cfi_startproc +..___tag_value___finited.46: +..L47: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __finited,@function + .size __finited,.-__finited + .data +# -- End __finited + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/isinf.S b/external/sgx_libm/intel64/isinf.S new file mode 100644 index 0000000000..f2a6d0c7a4 --- /dev/null +++ b/external/sgx_libm/intel64/isinf.S @@ -0,0 +1,309 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isinf.c" + .text +..TXTST0: +# -- Begin __isinfd + .text + .align 16,0x90 + .globl __isinfd +__isinfd: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___isinfd.1: +..L2: + + movq $0x7ff0000000000000, %rax + movd %xmm0, %rcx + cmpq %rax, %rcx + jne ..B1.3 +..B1.2: + movl $1, %eax + ret +..B1.3: + movq $0xfff0000000000000, %rdx + movl $-1, %esi + xorl %eax, %eax + cmpq %rcx, %rdx + cmove %esi, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __isinfd,@function + .size __isinfd,.-__isinfd + .data +# -- End __isinfd + .text +# -- Begin isinfd + .text + .align 16,0x90 + .globl isinfd +isinfd: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_isinfd.4: +..L5: + + movq $0x7ff0000000000000, %rax + movd %xmm0, %rcx + cmpq %rax, %rcx + jne ..B2.3 +..B2.2: + movl $1, %eax + ret +..B2.3: + movq $0xfff0000000000000, %rdx + movl $-1, %esi + xorl %eax, %eax + cmpq %rcx, %rdx + cmove %esi, %eax + ret + .align 16,0x90 + .cfi_endproc + .type isinfd,@function + .size isinfd,.-isinfd + .data +# -- End isinfd + .text +# -- Begin __isinf + .text + .align 16,0x90 + .globl __isinf +__isinf: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___isinf.7: +..L8: + + movq $0x7ff0000000000000, %rax + movd %xmm0, %rcx + cmpq %rax, %rcx + jne ..B3.3 +..B3.2: + movl $1, %eax + ret +..B3.3: + movq $0xfff0000000000000, %rdx + movl $-1, %esi + xorl %eax, %eax + cmpq %rcx, %rdx + cmove %esi, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __isinf,@function + .size __isinf,.-__isinf + .data +# -- End __isinf + .text +# -- Begin isinf + .text + .align 16,0x90 + .globl isinf +isinf: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value_isinf.10: +..L11: + + movq $0x7ff0000000000000, %rax + movd %xmm0, %rcx + cmpq %rax, %rcx + jne ..B4.3 +..B4.2: + movl $1, %eax + ret +..B4.3: + movq $0xfff0000000000000, %rdx + movl $-1, %esi + xorl %eax, %eax + cmpq %rcx, %rdx + cmove %esi, %eax + ret + .align 16,0x90 + .cfi_endproc + .type isinf,@function + .size isinf,.-isinf + .data +# -- End isinf + .text +# -- Begin __isinff + .text + .align 16,0x90 + .globl __isinff +__isinff: +# parameter 1: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value___isinff.13: +..L14: + + movd %xmm0, %edx + cmpl $2139095040, %edx + jne ..B5.3 +..B5.2: + movl $1, %eax + ret +..B5.3: + movl $-1, %ecx + xorl %eax, %eax + cmpl $-8388608, %edx + cmove %ecx, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __isinff,@function + .size __isinff,.-__isinff + .data +# -- End __isinff + .text +# -- Begin isinff + .text + .align 16,0x90 + .globl isinff +isinff: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value_isinff.16: +..L17: + + movd %xmm0, %edx + cmpl $2139095040, %edx + jne ..B6.3 +..B6.2: + movl $1, %eax + ret +..B6.3: + movl $-1, %ecx + xorl %eax, %eax + cmpl $-8388608, %edx + cmove %ecx, %eax + ret + .align 16,0x90 + .cfi_endproc + .type isinff,@function + .size isinff,.-isinff + .data +# -- End isinff + .text +# -- Begin __isinfl + .text + .align 16,0x90 + .globl __isinfl +__isinfl: +# parameter 1: 8 + %rsp +..B7.1: + .cfi_startproc +..___tag_value___isinfl.19: +..L20: + + movzwl 16(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B7.5 +..B7.2: + cmpl $-2147483648, 12(%rsp) + jne ..B7.5 +..B7.3: + cmpl $0, 8(%rsp) + jne ..B7.5 +..B7.4: + movzbl 17(%rsp), %eax + notl %eax + andl $128, %eax + shrl $6, %eax + decl %eax + ret +..B7.5: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __isinfl,@function + .size __isinfl,.-__isinfl + .data +# -- End __isinfl + .text +# -- Begin isinfl + .text + .align 16,0x90 + .globl isinfl +isinfl: +# parameter 1: 8 + %rsp +..B8.1: + .cfi_startproc +..___tag_value_isinfl.22: +..L23: + + movzwl 16(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B8.5 +..B8.2: + cmpl $-2147483648, 12(%rsp) + jne ..B8.5 +..B8.3: + cmpl $0, 8(%rsp) + jne ..B8.5 +..B8.4: + movzbl 17(%rsp), %eax + notl %eax + andl $128, %eax + shrl $6, %eax + decl %eax + ret +..B8.5: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type isinfl,@function + .size isinfl,.-isinfl + .data +# -- End isinfl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/isnan.S b/external/sgx_libm/intel64/isnan.S new file mode 100644 index 0000000000..31d0f2eda5 --- /dev/null +++ b/external/sgx_libm/intel64/isnan.S @@ -0,0 +1,259 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isnan.c" + .text +..TXTST0: +# -- Begin __isnand + .text + .align 16,0x90 + .globl __isnand +__isnand: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___isnand.1: +..L2: + + movq $0x7ff0000000000000, %rdx + movd %xmm0, %rcx + xorl %eax, %eax + btrq $63, %rcx + cmpq %rcx, %rdx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isnand,@function + .size __isnand,.-__isnand + .data +# -- End __isnand + .text +# -- Begin isnand + .text + .align 16,0x90 + .globl isnand +isnand: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_isnand.4: +..L5: + + movq $0x7ff0000000000000, %rdx + movd %xmm0, %rcx + xorl %eax, %eax + btrq $63, %rcx + cmpq %rcx, %rdx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isnand,@function + .size isnand,.-isnand + .data +# -- End isnand + .text +# -- Begin __isnan + .text + .align 16,0x90 + .globl __isnan +__isnan: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___isnan.7: +..L8: + + movq $0x7ff0000000000000, %rdx + movd %xmm0, %rcx + xorl %eax, %eax + btrq $63, %rcx + cmpq %rcx, %rdx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isnan,@function + .size __isnan,.-__isnan + .data +# -- End __isnan + .text +# -- Begin isnan + .text + .align 16,0x90 + .globl isnan +isnan: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value_isnan.10: +..L11: + + movq $0x7ff0000000000000, %rdx + movd %xmm0, %rcx + xorl %eax, %eax + btrq $63, %rcx + cmpq %rcx, %rdx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isnan,@function + .size isnan,.-isnan + .data +# -- End isnan + .text +# -- Begin __isnanf + .text + .align 16,0x90 + .globl __isnanf +__isnanf: +# parameter 1: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value___isnanf.13: +..L14: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + seta %al + ret + .align 16,0x90 + .cfi_endproc + .type __isnanf,@function + .size __isnanf,.-__isnanf + .data +# -- End __isnanf + .text +# -- Begin isnanf + .text + .align 16,0x90 + .globl isnanf +isnanf: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value_isnanf.16: +..L17: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + seta %al + ret + .align 16,0x90 + .cfi_endproc + .type isnanf,@function + .size isnanf,.-isnanf + .data +# -- End isnanf + .text +# -- Begin __isnanl + .text + .align 16,0x90 + .globl __isnanl +__isnanl: +# parameter 1: 8 + %rsp +..B7.1: + .cfi_startproc +..___tag_value___isnanl.19: +..L20: + + movzwl 16(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B7.4 +..B7.2: + xorl %eax, %eax +..B7.3: + ret +..B7.4: + movq $0x8000000000000000, %rdx + movl $1, %ecx + xorl %eax, %eax + cmpq 8(%rsp), %rdx + cmovne %ecx, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __isnanl,@function + .size __isnanl,.-__isnanl + .data +# -- End __isnanl + .text +# -- Begin isnanl + .text + .align 16,0x90 + .globl isnanl +isnanl: +# parameter 1: 8 + %rsp +..B8.1: + .cfi_startproc +..___tag_value_isnanl.22: +..L23: + + movzwl 16(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B8.4 +..B8.2: + xorl %eax, %eax +..B8.3: + ret +..B8.4: + movq $0x8000000000000000, %rdx + movl $1, %ecx + xorl %eax, %eax + cmpq 8(%rsp), %rdx + cmovne %ecx, %eax + ret + .align 16,0x90 + .cfi_endproc + .type isnanl,@function + .size isnanl,.-isnanl + .data +# -- End isnanl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/isnormal.S b/external/sgx_libm/intel64/isnormal.S new file mode 100644 index 0000000000..2794501d32 --- /dev/null +++ b/external/sgx_libm/intel64/isnormal.S @@ -0,0 +1,273 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "isnormal.c" + .text +..TXTST0: +# -- Begin __isnormald + .text + .align 16,0x90 + .globl __isnormald +__isnormald: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___isnormald.1: +..L2: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + addl $-1048576, %edx + cmpl $2145386496, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isnormald,@function + .size __isnormald,.-__isnormald + .data +# -- End __isnormald + .text +# -- Begin isnormald + .text + .align 16,0x90 + .globl isnormald +isnormald: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_isnormald.4: +..L5: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + addl $-1048576, %edx + cmpl $2145386496, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isnormald,@function + .size isnormald,.-isnormald + .data +# -- End isnormald + .text +# -- Begin __isnormal + .text + .align 16,0x90 + .globl __isnormal +__isnormal: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___isnormal.7: +..L8: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + addl $-1048576, %edx + cmpl $2145386496, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isnormal,@function + .size __isnormal,.-__isnormal + .data +# -- End __isnormal + .text +# -- Begin isnormal + .text + .align 16,0x90 + .globl isnormal +isnormal: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value_isnormal.10: +..L11: + + xorl %eax, %eax + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $2147483647, %edx + addl $-1048576, %edx + cmpl $2145386496, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isnormal,@function + .size isnormal,.-isnormal + .data +# -- End isnormal + .text +# -- Begin __isnormalf + .text + .align 16,0x90 + .globl __isnormalf +__isnormalf: +# parameter 1: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value___isnormalf.13: +..L14: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + addl $-8388608, %edx + cmpl $2130706432, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isnormalf,@function + .size __isnormalf,.-__isnormalf + .data +# -- End __isnormalf + .text +# -- Begin isnormalf + .text + .align 16,0x90 + .globl isnormalf +isnormalf: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value_isnormalf.16: +..L17: + + xorl %eax, %eax + movd %xmm0, %edx + andl $2147483647, %edx + addl $-8388608, %edx + cmpl $2130706432, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isnormalf,@function + .size isnormalf,.-isnormalf + .data +# -- End isnormalf + .text +# -- Begin __isnormall + .text + .align 16,0x90 + .globl __isnormall +__isnormall: +# parameter 1: 8 + %rsp +..B7.1: + .cfi_startproc +..___tag_value___isnormall.19: +..L20: + + movzwl 16(%rsp), %edx + shll $16, %edx + movzwl 14(%rsp), %eax + orl %eax, %edx + andl $2147483647, %edx + cmpl $4096, %edx + jb ..B7.4 +..B7.2: + testl $32768, %edx + jne ..B7.4 +..B7.3: + xorl %eax, %eax + ret +..B7.4: + addl $-65536, %edx + xorl %eax, %eax + cmpl $2147352576, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type __isnormall,@function + .size __isnormall,.-__isnormall + .data +# -- End __isnormall + .text +# -- Begin isnormall + .text + .align 16,0x90 + .globl isnormall +isnormall: +# parameter 1: 8 + %rsp +..B8.1: + .cfi_startproc +..___tag_value_isnormall.22: +..L23: + + movzwl 16(%rsp), %edx + shll $16, %edx + movzwl 14(%rsp), %eax + orl %eax, %edx + andl $2147483647, %edx + cmpl $4096, %edx + jb ..B8.4 +..B8.2: + testl $32768, %edx + jne ..B8.4 +..B8.3: + xorl %eax, %eax + ret +..B8.4: + addl $-65536, %edx + xorl %eax, %eax + cmpl $2147352576, %edx + setb %al + ret + .align 16,0x90 + .cfi_endproc + .type isnormall,@function + .size isnormall,.-isnormall + .data +# -- End isnormall + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/j0.S b/external/sgx_libm/intel64/j0.S new file mode 100644 index 0000000000..f8ebda2d7a --- /dev/null +++ b/external/sgx_libm/intel64/j0.S @@ -0,0 +1,2957 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j0.c" + .text +..TXTST0: +# -- Begin j0 + .text + .align 16,0x90 + .globl j0 +j0: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_j0.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $32, %rsp + .cfi_def_cfa_offset 48 + xorb %bl, %bl + movsd %xmm0, 8(%rsp) +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movl 12(%rsp), %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + jge ..B1.14 +..B1.4: + cmpl $1012924416, %eax + jl ..B1.13 +..B1.5: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.7: + fldcw 16(%rsp) +..B1.8: + movb $1, %bl +..B1.9: + addq $-16, %rsp + .cfi_def_cfa_offset 64 + movsd 24(%rsp), %xmm0 + andps .L_2il0floatpacket.0(%rip), %xmm0 + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + fstpt (%rsp) +..___tag_value_j0.7: + call __j0l@PLT +..___tag_value_j0.8: +..B1.20: + addq $16, %rsp + .cfi_def_cfa_offset 48 +..B1.10: + fstpl (%rsp) + testb %bl, %bl + movsd (%rsp), %xmm0 + je ..B1.12 +..B1.11: + fldcw 18(%rsp) +..B1.12: + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 3, -16 +..B1.13: + lea _ones(%rip), %rax + movsd 8(%rsp), %xmm1 + andps .L_2il0floatpacket.0(%rip), %xmm1 + movsd (%rax), %xmm0 + subsd %xmm1, %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 3, -16 +..B1.14: + andl $-2146435073, %eax + orl 8(%rsp), %eax + je ..B1.16 +..B1.15: + lea _ones(%rip), %rax + movsd (%rax), %xmm0 + mulsd 8(%rsp), %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 3, -16 +..B1.16: + lea _zeros(%rip), %rax + movsd (%rax), %xmm0 +..B1.17: + addq $32, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type j0,@function + .size j0,.-j0 + .data +# -- End j0 + .text +# -- Begin __j0l + .text + .align 16,0x90 + .globl __j0l +__j0l: +# parameter 1: 96 + %rsp +..B2.1: + .cfi_startproc +..___tag_value___j0l.29: +..L30: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + lea 176+_S(%rip), %rax + fldt 96(%rsp) + fldt (%rax) + fcomip %st(1), %st + jb ..B2.9 +..B2.2: + lea _S(%rip), %rcx + fldt (%rcx) + fcomip %st(1), %st + jbe ..B2.4 +..B2.3: + lea _Z(%rip), %rax + lea _P1(%rip), %rdx + lea 16+_P1(%rip), %rcx + lea 32+_P1(%rip), %rsi + lea 48+_P1(%rip), %rdi + lea 64+_P1(%rip), %r8 + lea 80+_P1(%rip), %r9 + lea 96+_P1(%rip), %r10 + fldt (%rax) + lea 112+_P1(%rip), %r11 + lea 128+_P1(%rip), %rax + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 144+_P1(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 160+_P1(%rip), %rcx + fmul %st(2), %st + fldt (%rsi) + lea 176+_P1(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 192+_P1(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 208+_P1(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 224+_P1(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 240+_P1(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 256+_P1(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 272+_P1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 288+_P1(%rip), %rdx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + lea 304+_P1(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 320+_P1(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rcx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rsi) + faddp %st, %st(1) + faddp %st, %st(1) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.4: + movl $1, %edx + movl $16, %eax +..B2.5: + fldt (%rax,%rcx) + fcomip %st(1), %st + ja ..B2.8 + jp ..B2.8 +..B2.6: + incq %rdx + addq $16, %rax + cmpq $11, %rdx + jl ..B2.5 +..B2.7: + movq %rdx, %rax + shlq $4, %rax +..B2.8: + lea _Z(%rip), %rcx + fldt (%rax,%rcx) + lea (%rdx,%rdx,4), %rax + shlq $6, %rax + fsubrp %st, %st(1) + fld %st(0) + lea _P(%rip), %rdx + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt -320(%rax,%rdx) + fmul %st(1), %st + fldt -304(%rax,%rdx) + fmul %st(2), %st + fldt -288(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -272(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -256(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -240(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -224(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -208(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -192(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -176(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -160(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -144(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -128(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -112(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -96(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -80(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -64(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -48(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -32(%rax,%rdx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -16(%rax,%rdx) + faddp %st, %st(1) + faddp %st, %st(1) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.9: + lea _ones(%rip), %rax + lea _val_36_0L(%rip), %rdx + lea _PP(%rip), %rcx + lea _QP(%rip), %rsi + lea 16+_PP(%rip), %rdi + lea 16+_QP(%rip), %r8 + lea 32+_PP(%rip), %r9 + lea 32+_QP(%rip), %r10 + fldl (%rax) + lea 48+_PP(%rip), %r11 + fdiv %st(1), %st + lea 48+_QP(%rip), %rax + fxch %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rdx) + lea 64+_PP(%rip), %rdx + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + fxch %st(2) + fstpt (%rsp) + fldt (%rcx) + lea 64+_QP(%rip), %rcx + fmul %st(1), %st + fldt (%rsi) + lea 80+_PP(%rip), %rsi + fmul %st(2), %st + fldt (%rdi) + lea 80+_QP(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 96+_PP(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 96+_QP(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 112+_PP(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 112+_QP(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_PP(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 128+_QP(%rip), %rdx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + lea 144+_PP(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 144+_QP(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 80(%rsp), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + movl $-1, %edx + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rcx) + faddp %st, %st(1) + fstpt -48(%rdi) + fldt (%rsi) + lea 64(%rsp), %rsi + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -16(%rsi) +..___tag_value___j0l.37: + call __libm_sincos_pi4l@PLT +..___tag_value___j0l.38: +..B2.18: + fldt 112(%rsp) + fldt 48(%rsp) + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 96 +..B2.10: + fldt 48(%rsp) + lea _val_0_03L(%rip), %rax + fmulp %st, %st(1) + fldt 64(%rsp) + fmulp %st, %st(2) + fsub %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt (%rax) + fmulp %st, %st(1) + fcomip %st(1), %st + fstp %st(0) + jae ..B2.12 + jp ..B2.12 +..B2.11: + fstp %st(1) + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.12: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B2.20: + addq $16, %rsp + .cfi_def_cfa_offset 96 + movaps (%rsp), %xmm0 +..___tag_value___j0l.44: + call __j0q@PLT +..___tag_value___j0l.45: +..B2.13: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B2.21: + fstpl 8(%rsp) + movsd 8(%rsp), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) +..B2.14: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __j0l,@function + .size __j0l,.-__j0l + .data +# -- End __j0l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_S: + .word 17728 + .word 31608 + .word 43949 + .word 62778 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 32551 + .word 41874 + .word 44957 + .word 57471 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 18949 + .word 61409 + .word 34437 + .word 41670 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 4396 + .word 34605 + .word 55192 + .word 54573 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 9307 + .word 10310 + .word 55728 + .word 33731 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 7613 + .word 2917 + .word 18234 + .word 40173 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 24292 + .word 42693 + .word 42782 + .word 46612 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 12570 + .word 29960 + .word 47214 + .word 53050 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 24415 + .word 36838 + .word 59299 + .word 59487 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 32322 + .word 22879 + .word 15219 + .word 32962 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 56404 + .word 12107 + .word 18542 + .word 36180 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 18639 + .word 44635 + .word 10526 + .word 39398 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _S,@object + .size _S,192 + .align 2 +_Z: + .word 64993 + .word 47321 + .word 43380 + .word 39400 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 10427 + .word 24946 + .word 31449 + .word 45220 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 20142 + .word 26358 + .word 43878 + .word 35445 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 45380 + .word 5013 + .word 8196 + .word 48298 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 36049 + .word 37774 + .word 2551 + .word 61157 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 44499 + .word 20687 + .word 35324 + .word 37009 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 37149 + .word 40892 + .word 28299 + .word 43441 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 59921 + .word 2742 + .word 56472 + .word 49873 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 35749 + .word 60152 + .word 42287 + .word 56306 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 36553 + .word 24054 + .word 44174 + .word 62739 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 12707 + .word 13183 + .word 28829 + .word 34586 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 24309 + .word 45263 + .word 7124 + .word 37803 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _Z,@object + .size _Z,192 + .align 2 +_P1: + .word 41974 + .word 50359 + .word 55 + .word 49432 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 46729 + .word 24287 + .word 10077 + .word 43682 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 54556 + .word 53463 + .word 26566 + .word 47408 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 61625 + .word 30678 + .word 34691 + .word 56786 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 32205 + .word 55323 + .word 47622 + .word 59679 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 29650 + .word 64976 + .word 4011 + .word 64391 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 31057 + .word 21065 + .word 6935 + .word 59041 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 36662 + .word 39842 + .word 13910 + .word 57058 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 21879 + .word 21964 + .word 7382 + .word 44566 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 35904 + .word 38403 + .word 56995 + .word 38056 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 18301 + .word 44371 + .word 51380 + .word 49148 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 24372 + .word 2933 + .word 6164 + .word 36455 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 49391 + .word 5716 + .word 15337 + .word 37270 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 25965 + .word 16194 + .word 56568 + .word 46953 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 45667 + .word 13925 + .word 5584 + .word 35484 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 49022 + .word 26773 + .word 37576 + .word 36812 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 36832 + .word 53763 + .word 58864 + .word 36312 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 33543 + .word 46187 + .word 17185 + .word 59351 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 40102 + .word 5284 + .word 63312 + .word 56590 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 857 + .word 43156 + .word 55730 + .word 34022 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 52121 + .word 9280 + .word 35775 + .word 47190 + .word 16318 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,336 + .align 2 +_P: + .word 25701 + .word 56152 + .word 43593 + .word 44746 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 48832 + .word 40943 + .word 62738 + .word 40407 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 27954 + .word 18691 + .word 56371 + .word 61331 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 59673 + .word 34431 + .word 10026 + .word 51320 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 19628 + .word 6656 + .word 43961 + .word 34852 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 10797 + .word 38877 + .word 18617 + .word 49740 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 55276 + .word 31862 + .word 41256 + .word 61817 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 56169 + .word 58452 + .word 6548 + .word 36482 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 22526 + .word 12680 + .word 38609 + .word 41195 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 35707 + .word 29316 + .word 48923 + .word 38609 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 54924 + .word 17159 + .word 27854 + .word 39283 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 7410 + .word 20104 + .word 60324 + .word 54971 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 42961 + .word 8606 + .word 41997 + .word 49951 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 20439 + .word 51893 + .word 4000 + .word 47026 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 59638 + .word 54459 + .word 36852 + .word 37873 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 53889 + .word 4789 + .word 65352 + .word 38847 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 1714 + .word 3910 + .word 34394 + .word 55562 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 303 + .word 16967 + .word 38717 + .word 64635 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 5713 + .word 19393 + .word 12368 + .word 44599 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 21960 + .word 14969 + .word 53843 + .word 43675 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 52500 + .word 174 + .word 33388 + .word 44907 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 36805 + .word 62602 + .word 43329 + .word 35133 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 27761 + .word 25841 + .word 3607 + .word 63286 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 6612 + .word 54609 + .word 58140 + .word 43860 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 37993 + .word 17870 + .word 56109 + .word 35856 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 61675 + .word 27140 + .word 56422 + .word 41440 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 56971 + .word 52432 + .word 57814 + .word 63191 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 25412 + .word 37118 + .word 3118 + .word 58735 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 38291 + .word 36319 + .word 26004 + .word 41665 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 50251 + .word 22788 + .word 9163 + .word 59245 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 15018 + .word 28 + .word 26139 + .word 39028 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 33331 + .word 48247 + .word 16919 + .word 39314 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 9684 + .word 33609 + .word 24106 + .word 48128 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 51011 + .word 47822 + .word 659 + .word 60363 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 37534 + .word 11575 + .word 45084 + .word 34566 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 45912 + .word 27680 + .word 6912 + .word 42099 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 56715 + .word 12873 + .word 49782 + .word 46172 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 26728 + .word 49648 + .word 65144 + .word 32891 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 40426 + .word 15254 + .word 52157 + .word 35579 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 38384 + .word 45177 + .word 47511 + .word 58357 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 58158 + .word 44133 + .word 45474 + .word 44841 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 25822 + .word 50828 + .word 25446 + .word 60617 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 15324 + .word 12408 + .word 38243 + .word 63699 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 14774 + .word 16677 + .word 5572 + .word 37105 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 22149 + .word 54660 + .word 59654 + .word 35846 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 11697 + .word 52785 + .word 2274 + .word 34156 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 53627 + .word 64285 + .word 10253 + .word 62534 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 24801 + .word 65406 + .word 2005 + .word 46814 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 32190 + .word 19121 + .word 50201 + .word 40636 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 54751 + .word 12899 + .word 38715 + .word 45207 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 43490 + .word 42082 + .word 27556 + .word 37283 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 22028 + .word 56865 + .word 50900 + .word 56715 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 16346 + .word 12991 + .word 64075 + .word 44659 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 52492 + .word 22409 + .word 7105 + .word 40702 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 6702 + .word 59476 + .word 47051 + .word 61808 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 62316 + .word 14189 + .word 19866 + .word 53935 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 9195 + .word 51568 + .word 61124 + .word 40040 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 6439 + .word 11299 + .word 34414 + .word 41343 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 46739 + .word 24947 + .word 62261 + .word 60937 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 58365 + .word 23430 + .word 12962 + .word 38007 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 58251 + .word 41189 + .word 49383 + .word 44339 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 48598 + .word 60621 + .word 33089 + .word 52046 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 15609 + .word 33598 + .word 37151 + .word 63031 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 47302 + .word 16218 + .word 41542 + .word 62539 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 57122 + .word 24762 + .word 37625 + .word 35182 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 14554 + .word 11813 + .word 4690 + .word 56239 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 54525 + .word 1724 + .word 15173 + .word 60713 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 63047 + .word 59633 + .word 16097 + .word 37474 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 47674 + .word 64044 + .word 50935 + .word 38909 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 10733 + .word 57181 + .word 7346 + .word 35019 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 60139 + .word 34186 + .word 61790 + .word 35089 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 42252 + .word 41404 + .word 34184 + .word 42385 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 1522 + .word 6058 + .word 55347 + .word 41209 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 8896 + .word 65510 + .word 60684 + .word 58885 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 5547 + .word 57306 + .word 64532 + .word 55968 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 14723 + .word 16104 + .word 43168 + .word 38160 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 64145 + .word 20360 + .word 50512 + .word 35772 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 36202 + .word 63428 + .word 51591 + .word 58021 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 65464 + .word 45991 + .word 59516 + .word 54144 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24568 + .word 20436 + .word 61634 + .word 37862 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 45319 + .word 25104 + .word 37206 + .word 43484 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 21849 + .word 55910 + .word 13070 + .word 44688 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 3252 + .word 24429 + .word 41684 + .word 61678 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 18877 + .word 5474 + .word 3532 + .word 52835 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 29000 + .word 47276 + .word 64838 + .word 34154 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 20967 + .word 63980 + .word 13404 + .word 46613 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 52562 + .word 53463 + .word 21966 + .word 58373 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 9777 + .word 2939 + .word 17549 + .word 60815 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 26283 + .word 15936 + .word 57935 + .word 36992 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 53769 + .word 29752 + .word 63351 + .word 55571 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 39733 + .word 64164 + .word 46820 + .word 32952 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 176 + .word 24001 + .word 47175 + .word 32916 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 42514 + .word 53223 + .word 40190 + .word 38228 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 32337 + .word 51109 + .word 43299 + .word 44928 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 59799 + .word 62803 + .word 25577 + .word 51379 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 14970 + .word 20015 + .word 15936 + .word 57562 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 65161 + .word 31438 + .word 7531 + .word 65214 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 20513 + .word 44789 + .word 62889 + .word 43571 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 4307 + .word 19900 + .word 64182 + .word 49211 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 23601 + .word 8473 + .word 7427 + .word 49494 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 7362 + .word 8526 + .word 7254 + .word 42403 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 35188 + .word 37258 + .word 23196 + .word 38516 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 28716 + .word 28394 + .word 59353 + .word 59952 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 5380 + .word 17306 + .word 43095 + .word 44938 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 62603 + .word 29353 + .word 43042 + .word 32969 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 14219 + .word 29360 + .word 8286 + .word 39065 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 51755 + .word 8774 + .word 37073 + .word 55906 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 56892 + .word 44416 + .word 43797 + .word 50190 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 61329 + .word 48733 + .word 6023 + .word 35132 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 7541 + .word 9021 + .word 40244 + .word 45179 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 26533 + .word 29344 + .word 18926 + .word 62060 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 30572 + .word 2598 + .word 8389 + .word 52807 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 51943 + .word 22643 + .word 23287 + .word 35717 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 64388 + .word 35284 + .word 47919 + .word 35658 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 29632 + .word 11036 + .word 42088 + .word 47700 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 31422 + .word 44089 + .word 40511 + .word 45376 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 24082 + .word 23937 + .word 40663 + .word 60291 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 35871 + .word 18767 + .word 59204 + .word 34260 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 55945 + .word 59437 + .word 40276 + .word 45420 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 36087 + .word 44447 + .word 31316 + .word 65259 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 33015 + .word 55199 + .word 13485 + .word 41205 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 28040 + .word 38678 + .word 23200 + .word 33402 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 24126 + .word 8131 + .word 32863 + .word 58069 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 35392 + .word 16287 + .word 64004 + .word 38564 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 24419 + .word 65021 + .word 26451 + .word 63502 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 50428 + .word 39809 + .word 46675 + .word 33151 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 43497 + .word 65182 + .word 62592 + .word 53510 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 13653 + .word 47792 + .word 51483 + .word 42124 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 51670 + .word 53417 + .word 2690 + .word 33418 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 18048 + .word 20017 + .word 2806 + .word 37530 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 28377 + .word 1564 + .word 33730 + .word 58682 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 50365 + .word 41139 + .word 10086 + .word 43478 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 61280 + .word 6173 + .word 58518 + .word 33596 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 37780 + .word 41188 + .word 55897 + .word 58318 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 54954 + .word 62311 + .word 27470 + .word 44684 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 57442 + .word 38159 + .word 64608 + .word 36945 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 24087 + .word 55434 + .word 11948 + .word 56328 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 3958 + .word 29640 + .word 49133 + .word 55700 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 27700 + .word 45302 + .word 5983 + .word 42389 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 40427 + .word 54367 + .word 12482 + .word 37240 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 59852 + .word 29007 + .word 23004 + .word 39969 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 34211 + .word 57602 + .word 36659 + .word 58360 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 44442 + .word 16364 + .word 9911 + .word 56161 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 28102 + .word 25155 + .word 37530 + .word 33414 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 6555 + .word 37232 + .word 8513 + .word 61132 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 19389 + .word 63961 + .word 54328 + .word 56964 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 46901 + .word 14299 + .word 54235 + .word 51269 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 21562 + .word 53008 + .word 37762 + .word 35900 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 39053 + .word 49830 + .word 37166 + .word 63741 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 45681 + .word 41863 + .word 1807 + .word 63504 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 32524 + .word 20075 + .word 31047 + .word 55727 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 19491 + .word 55333 + .word 6932 + .word 36559 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 44244 + .word 33552 + .word 34722 + .word 63577 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 16901 + .word 42071 + .word 41001 + .word 48810 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 62438 + .word 12223 + .word 44142 + .word 42160 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 23223 + .word 6493 + .word 11343 + .word 61664 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 62523 + .word 30008 + .word 29610 + .word 53050 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 14947 + .word 31100 + .word 26993 + .word 46432 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 54892 + .word 55125 + .word 25696 + .word 39893 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 64089 + .word 10154 + .word 50994 + .word 64131 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 25208 + .word 35455 + .word 35497 + .word 38745 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 22601 + .word 23897 + .word 16529 + .word 51375 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 39957 + .word 27913 + .word 24611 + .word 54302 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 45382 + .word 20134 + .word 36574 + .word 58452 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 42298 + .word 30543 + .word 37555 + .word 58890 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 22768 + .word 53677 + .word 2298 + .word 49504 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 58111 + .word 6687 + .word 35097 + .word 49208 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 10603 + .word 28285 + .word 57192 + .word 62022 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 32868 + .word 54034 + .word 283 + .word 60966 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 45349 + .word 58038 + .word 8163 + .word 54564 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 55920 + .word 35455 + .word 60237 + .word 53133 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 60123 + .word 63321 + .word 17152 + .word 62548 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 39317 + .word 30736 + .word 60380 + .word 60458 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 49393 + .word 44945 + .word 51803 + .word 41616 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 20738 + .word 26362 + .word 9659 + .word 40012 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 60223 + .word 27976 + .word 18717 + .word 52467 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 54339 + .word 42843 + .word 18062 + .word 50282 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 34001 + .word 60559 + .word 43103 + .word 39476 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 26526 + .word 28531 + .word 16125 + .word 37792 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 6095 + .word 56607 + .word 38079 + .word 40348 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 15971 + .word 7192 + .word 49983 + .word 37562 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 50443 + .word 47213 + .word 11879 + .word 45566 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 11802 + .word 10368 + .word 62578 + .word 52530 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 31461 + .word 32590 + .word 25910 + .word 51580 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 23034 + .word 4503 + .word 56149 + .word 56800 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 23084 + .word 49532 + .word 8891 + .word 43466 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 52278 + .word 51985 + .word 56128 + .word 47325 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 64046 + .word 3409 + .word 24460 + .word 54209 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 21815 + .word 55080 + .word 59949 + .word 58476 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 52803 + .word 16320 + .word 8321 + .word 47500 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 52718 + .word 62993 + .word 9405 + .word 50844 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 54524 + .word 45491 + .word 53115 + .word 54272 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 17147 + .word 2195 + .word 64554 + .word 57739 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 25716 + .word 30593 + .word 61559 + .word 36022 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 34582 + .word 27844 + .word 9712 + .word 38156 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 11089 + .word 32571 + .word 7121 + .word 45346 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 19256 + .word 10500 + .word 41195 + .word 47904 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 34688 + .word 57357 + .word 16578 + .word 34099 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 33812 + .word 7938 + .word 37351 + .word 35991 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 39461 + .word 41125 + .word 38968 + .word 43650 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 44025 + .word 18687 + .word 5475 + .word 36436 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 23695 + .word 42035 + .word 32968 + .word 40701 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 38927 + .word 50812 + .word 3019 + .word 50863 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 61445 + .word 40975 + .word 17938 + .word 45887 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 29652 + .word 52899 + .word 3582 + .word 54866 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 20058 + .word 59066 + .word 2994 + .word 38517 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 39274 + .word 56137 + .word 36322 + .word 45609 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 15638 + .word 5070 + .word 53701 + .word 47866 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 51166 + .word 27629 + .word 45907 + .word 56238 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 29387 + .word 28474 + .word 13265 + .word 41814 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 6001 + .word 55757 + .word 63641 + .word 48808 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 65207 + .word 5152 + .word 25385 + .word 47657 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 16879 + .word 18288 + .word 49778 + .word 55345 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 63014 + .word 23411 + .word 42365 + .word 63147 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 41060 + .word 50204 + .word 58630 + .word 36532 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 38440 + .word 64136 + .word 63792 + .word 39699 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 22495 + .word 32960 + .word 60573 + .word 45833 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 59007 + .word 19608 + .word 21801 + .word 59681 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 39231 + .word 52779 + .word 63106 + .word 34425 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 40257 + .word 55273 + .word 33242 + .word 51859 + .word 16320 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,3520 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,16 + .align 2 +_PP: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 0 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP,@object + .size _PP,160 + .align 2 +_QP: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 0 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .word 0 + .word 0 + .type _QP,@object + .size _QP,160 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,16 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _tonpi,@object + .size _tonpi,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/j0f.S b/external/sgx_libm/intel64/j0f.S new file mode 100644 index 0000000000..69420f75c2 --- /dev/null +++ b/external/sgx_libm/intel64/j0f.S @@ -0,0 +1,596 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j0f.c" + .text +..TXTST0: +# -- Begin j0f + .text + .align 16,0x90 + .globl j0f +j0f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_j0f.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movd %xmm0, %edx + movss %xmm0, 48(%rsp) + andl $2147483647, %edx + cmpl $2139095040, %edx + jae ..B1.18 +..B1.2: + cmpl $1099154394, %edx + jae ..B1.19 +..B1.3: + cmpl $1081424556, %edx + jae ..B1.14 +..B1.4: + cmpl $1048576000, %edx + jae ..B1.13 +..B1.5: + cmpl $998244352, %edx + jae ..B1.12 +..B1.6: + cmpl $947912704, %edx + jae ..B1.11 +..B1.7: + movss .L_2il0floatpacket.0(%rip), %xmm1 + cmpl $838860800, %edx + jae ..B1.9 +..B1.8: + andps .L_2il0floatpacket.1(%rip), %xmm0 + subss %xmm0, %xmm1 + jmp ..B1.10 +..B1.9: + mulss %xmm0, %xmm0 + subss %xmm0, %xmm1 +..B1.10: + movaps %xmm1, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.11: + pxor %xmm0, %xmm0 + lea 8+_Q3(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + lea _Q3(%rip), %rdx + movsd (%rax), %xmm1 + mulsd %xmm0, %xmm1 + addsd (%rdx), %xmm1 + mulsd %xmm0, %xmm1 + addsd .L_2il0floatpacket.2(%rip), %xmm1 + cvtsd2ss %xmm1, %xmm1 + movaps %xmm1, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + pxor %xmm1, %xmm1 + lea 24+_Q2(%rip), %rax + cvtss2sd 48(%rsp), %xmm1 + mulsd %xmm1, %xmm1 + lea 16+_Q2(%rip), %rcx + movaps %xmm1, %xmm0 + lea 8+_Q2(%rip), %rdx + mulsd %xmm1, %xmm0 + lea _Q2(%rip), %rsi + movsd (%rax), %xmm3 + movsd (%rcx), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm0, %xmm2 + addsd (%rdx), %xmm3 + addsd (%rsi), %xmm2 + mulsd %xmm0, %xmm3 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm3 + addsd .L_2il0floatpacket.2(%rip), %xmm3 + cvtsd2ss %xmm3, %xmm3 + movaps %xmm3, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.13: + pxor %xmm1, %xmm1 + lea 112+_Q1(%rip), %rax + cvtss2sd 48(%rsp), %xmm1 + andps .L_2il0floatpacket.3(%rip), %xmm1 + lea 104+_Q1(%rip), %rdx + lea 72+_Q1(%rip), %rcx + lea 88+_Q1(%rip), %rdi + lea 96+_Q1(%rip), %r11 + lea 56+_Q1(%rip), %r8 + lea 40+_Q1(%rip), %rsi + lea 24+_Q1(%rip), %r9 + movsd (%rdx), %xmm6 + lea 32+_Q1(%rip), %rdx + movsd (%rdi), %xmm0 + lea 16+_Q1(%rip), %rdi + movsd (%r11), %xmm5 + lea 8+_Q1(%rip), %r10 + subsd (%rax), %xmm1 + lea 64+_Q1(%rip), %rax + movaps %xmm1, %xmm3 + mulsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd (%rcx), %xmm6 + addsd (%r8), %xmm0 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd (%rsi), %xmm6 + addsd (%r9), %xmm0 + addsd (%rdx), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm3, %xmm0 + mulsd %xmm2, %xmm5 + addsd %xmm0, %xmm6 + lea 80+_Q1(%rip), %rcx + lea 48+_Q1(%rip), %rsi + lea _Q1(%rip), %r8 + addsd (%r10), %xmm6 + movsd (%rcx), %xmm4 + mulsd %xmm2, %xmm4 + mulsd %xmm1, %xmm6 + addsd (%rsi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rdi), %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + addsd (%r8), %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.14: + cmpl $1092798087, %edx + jae ..B1.16 +..B1.15: + cmpl $1088454576, %edx + lea _P1(%rip), %rcx + lea _P2(%rip), %rax + jb ..B1.17 + movq %rax, %rcx + jmp ..B1.17 +..B1.16: + cmpl $1096101336, %edx + lea _P3(%rip), %rcx + lea _P4(%rip), %rax + jb ..L12 + movq %rax, %rcx +..L12: +..B1.17: + pxor %xmm3, %xmm3 + cvtss2sd 48(%rsp), %xmm3 + andps .L_2il0floatpacket.3(%rip), %xmm3 + movsd 96(%rcx), %xmm6 + movsd 80(%rcx), %xmm0 + movsd 88(%rcx), %xmm5 + movsd 72(%rcx), %xmm4 + subsd 104(%rcx), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd 64(%rcx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 48(%rcx), %xmm0 + addsd 56(%rcx), %xmm5 + mulsd %xmm2, %xmm6 + addsd 40(%rcx), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd 32(%rcx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 16(%rcx), %xmm0 + addsd 24(%rcx), %xmm5 + mulsd %xmm2, %xmm6 + addsd 8(%rcx), %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + mulsd %xmm3, %xmm4 + addsd %xmm0, %xmm6 + mulsd %xmm3, %xmm5 + addsd (%rcx), %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.18: + pxor %xmm0, %xmm0 + jbe ..L15 + movss 48(%rsp), %xmm0 +..L15: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.19: + pxor %xmm0, %xmm0 + lea _val_16_0(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + andps .L_2il0floatpacket.3(%rip), %xmm0 + lea (%rsp), %rdi + movsd .L_2il0floatpacket.2(%rip), %xmm1 + lea 8(%rsp), %rsi + divsd %xmm0, %xmm1 + movsd (%rax), %xmm2 + movl $-1, %edx + mulsd %xmm1, %xmm2 + movsd %xmm2, 8(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm2, 24(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm1, 16(%rsi) + movsd %xmm2, 32(%rsi) +..___tag_value_j0f.18: + call __libm_sincos_k32@PLT +..___tag_value_j0f.19: +..B1.20: + lea 40+_QP(%rip), %r10 + lea 40+_PP(%rip), %rdx + movsd 40(%rsp), %xmm2 + lea 24+_QP(%rip), %r11 + lea 24+_PP(%rip), %rcx + lea 32+_PP(%rip), %rdi + lea _tonpi(%rip), %rax + lea 16+_PP(%rip), %r8 + movsd (%r10), %xmm5 + lea 8+_PP(%rip), %rsi + movsd (%rdx), %xmm6 + lea 32+_QP(%rip), %rdx + mulsd %xmm2, %xmm5 + lea _PP(%rip), %r9 + mulsd %xmm2, %xmm6 + addsd (%r11), %xmm5 + addsd (%rcx), %xmm6 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm6 + movsd (%rdx), %xmm4 + lea 16+_QP(%rip), %rcx + mulsd %xmm2, %xmm4 + addsd (%rsi), %xmm6 + movsd (%rdi), %xmm1 + lea _QP(%rip), %rsi + mulsd %xmm2, %xmm1 + addsd (%rcx), %xmm4 + movsd (%rax), %xmm0 + lea 8+_QP(%rip), %rax + mulsd %xmm2, %xmm4 + addsd (%r8), %xmm1 + mulsd 24(%rsp), %xmm0 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm1 + addsd (%rsi), %xmm4 + sqrtsd %xmm0, %xmm0 + addsd (%r9), %xmm1 + movsd 32(%rsp), %xmm3 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm1, %xmm6 + mulsd 16(%rsp), %xmm5 + mulsd 8(%rsp), %xmm6 + mulsd (%rsp), %xmm5 + subsd %xmm5, %xmm6 + mulsd %xmm6, %xmm0 + cvtsd2ss %xmm0, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type j0f,@function + .size j0f,.-j0f + .data +# -- End j0f + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x7fffffff,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.3: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x3f800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +_Q3: + .long 4294966841 + .long 3218079743 + .long 477219499 + .long 1066401791 + .type _Q3,@object + .size _Q3,16 + .align 4 +_Q2: + .long 4294967005 + .long 3218079743 + .long 4292583532 + .long 1066401791 + .long 2963922746 + .long 3208409541 + .long 1698509326 + .long 1054632110 + .type _Q2,@object + .size _Q2,32 + .align 4 +_Q1: + .long 569392270 + .long 3163659129 + .long 911539783 + .long 3219168475 + .long 3927550863 + .long 1069261278 + .long 1680954783 + .long 1068301032 + .long 3247602706 + .long 3212950300 + .long 1528576945 + .long 3210869138 + .long 2120930432 + .long 1060197251 + .long 3147753376 + .long 1057418557 + .long 3445667889 + .long 3201446637 + .long 160313185 + .long 3198274950 + .long 2157358765 + .long 1047004568 + .long 1405517519 + .long 1043512506 + .long 3055202941 + .long 3187001715 + .long 562966967 + .long 3183555197 + .long 781654848 + .long 1073954069 + .type _Q1,@object + .size _Q1,120 + .align 4 +_P1: + .long 2556390964 + .long 3162487616 + .long 168113101 + .long 1070974694 + .long 3865632959 + .long 3214905202 + .long 3384884860 + .long 3215663440 + .long 3461368592 + .long 1064499199 + .long 2947775703 + .long 1063419441 + .long 1964351934 + .long 3207001659 + .long 1081690493 + .long 3204998104 + .long 2315304668 + .long 1053480462 + .long 3655541446 + .long 1050880364 + .long 988219424 + .long 3194139699 + .long 2647984383 + .long 3191029766 + .long 3459760917 + .long 1038956170 + .long 1529622085 + .long 1075188879 + .type _P1,@object + .size _P1,112 + .align 4 +_P2: + .long 2989381656 + .long 3164006638 + .long 2007135498 + .long 3218169721 + .long 3461465629 + .long 1066405759 + .long 1292000183 + .long 1067879320 + .long 1048188593 + .long 3211038307 + .long 2811900586 + .long 3210797269 + .long 275024305 + .long 1058896216 + .long 2179928921 + .long 1057456107 + .long 2316750355 + .long 3200463196 + .long 1626245786 + .long 3198355713 + .long 2429961783 + .long 1046264853 + .long 3081665457 + .long 1043557342 + .long 3760684269 + .long 3186121773 + .long 1825365706 + .long 1075924661 + .type _P2,@object + .size _P2,112 + .align 4 +_P3: + .long 915277891 + .long 3163740397 + .long 1721892699 + .long 1070448958 + .long 3433548142 + .long 3213111280 + .long 3603643349 + .long 3215166749 + .long 2193444562 + .long 1062884841 + .long 1036402988 + .long 1063136790 + .long 2039602830 + .long 3205750717 + .long 2039806946 + .long 3204828766 + .long 3757243411 + .long 1052487712 + .long 2819184679 + .long 1050816211 + .long 1638789445 + .long 3193302656 + .long 96077275 + .long 3191008024 + .long 34207204 + .long 1038327735 + .long 8549046 + .long 1076335940 + .type _P3,@object + .size _P3,112 + .align 4 +_P4: + .long 4010378302 + .long 3164933090 + .long 260862994 + .long 3217715229 + .long 793353311 + .long 1065112761 + .long 2823013001 + .long 1067546520 + .long 4006575139 + .long 3209863700 + .long 3390737311 + .long 3210433566 + .long 1793352299 + .long 1057800372 + .long 3528876835 + .long 1057234714 + .long 2505438989 + .long 3199512871 + .long 2785865938 + .long 3198229698 + .long 565130724 + .long 1045495083 + .long 410977742 + .long 1043470609 + .long 4266013081 + .long 3185543354 + .long 1056076242 + .long 1076747425 + .type _P4,@object + .size _P4,112 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_QP: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP,@object + .size _QP,48 + .align 4 +_PP: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP,@object + .size _PP,48 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/j0l.S b/external/sgx_libm/intel64/j0l.S new file mode 100644 index 0000000000..d2ea20c856 --- /dev/null +++ b/external/sgx_libm/intel64/j0l.S @@ -0,0 +1,86 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j0l.c" + .text +..TXTST0: +# -- Begin j0l + .text + .align 16,0x90 + .globl j0l +j0l: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_j0l.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 48 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B1.6: + addq $16, %rsp + .cfi_def_cfa_offset 32 + movaps (%rsp), %xmm0 +..___tag_value_j0l.6: + call __j0q@PLT +..___tag_value_j0l.7: +..B1.2: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type j0l,@function + .size j0l,.-j0l + .data +# -- End j0l + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/j1.S b/external/sgx_libm/intel64/j1.S new file mode 100644 index 0000000000..b335b1562b --- /dev/null +++ b/external/sgx_libm/intel64/j1.S @@ -0,0 +1,3028 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j1.c" + .text +..TXTST0: +# -- Begin j1 + .text + .align 16,0x90 + .globl j1 +j1: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_j1.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + subq $40, %rsp + .cfi_def_cfa_offset 64 + xorb %r13b, %r13b + movsd %xmm0, 24(%rsp) +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movl 28(%rsp), %r12d + movl %r12d, %edx + andl $2147483647, %edx + shrl $31, %r12d + cmpl $2146435072, %edx + jge ..B1.20 +..B1.4: + cmpl $1012924416, %edx + jge ..B1.12 +..B1.5: + cmpl $1048576, %edx + jle ..B1.7 +..B1.6: + movl %r12d, %r12d + lea _small_value_64(%rip), %rax + movsd 24(%rsp), %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd (%rax,%r12,8), %xmm1 + mulsd (%rax), %xmm1 + subsd %xmm1, %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.7: + movl 24(%rsp), %eax + je ..B1.24 +..B1.8: + orl %eax, %edx + je ..B1.10 +..B1.9: + movl %r12d, %r12d + lea _small_value_64(%rip), %rax + movsd (%rax,%r12,8), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, (%rsp) + movsd 24(%rsp), %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd (%rsp), %xmm1 + subsd %xmm1, %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.10: + movsd 24(%rsp), %xmm0 +..B1.11: + addq $40, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.12: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.16 +..B1.13: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.14: + fldcw 16(%rsp) +..B1.15: + movb $1, %r13b +..B1.16: + addq $-16, %rsp + .cfi_def_cfa_offset 80 + movsd 40(%rsp), %xmm0 + andps .L_2il0floatpacket.1(%rip), %xmm0 + movsd %xmm0, 24(%rsp) + fldl 24(%rsp) + fstpt (%rsp) +..___tag_value_j1.33: + call __j1l@PLT +..___tag_value_j1.34: +..B1.27: + addq $16, %rsp + .cfi_def_cfa_offset 64 +..B1.17: + fstpl 8(%rsp) + testb %r13b, %r13b + movsd 8(%rsp), %xmm1 + je ..B1.19 +..B1.18: + fldcw 18(%rsp) +..B1.19: + movaps %xmm1, %xmm0 + testl %r12d, %r12d + xorps .L_2il0floatpacket.2(%rip), %xmm0 + jne ..L36 + movaps %xmm1, %xmm0 +..L36: + addq $40, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.20: + andl $-2146435073, %edx + orl 24(%rsp), %edx + je ..B1.22 +..B1.21: + lea _ones(%rip), %rax + movsd (%rax), %xmm0 + mulsd 24(%rsp), %xmm0 + addq $40, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.22: + lea _zeros(%rip), %rax + movsd (%rax,%r12,8), %xmm0 +..B1.23: + addq $40, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.24: + testl %eax, %eax + jne ..B1.6 + jmp ..B1.8 + .align 16,0x90 + .cfi_endproc + .type j1,@function + .size j1,.-j1 + .data +# -- End j1 + .text +# -- Begin __j1l + .text + .align 16,0x90 + .globl __j1l +__j1l: +# parameter 1: 96 + %rsp +..B2.1: + .cfi_startproc +..___tag_value___j1l.62: +..L63: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + lea 176+_S(%rip), %rax + fldt 96(%rsp) + fldt (%rax) + fcomip %st(1), %st + jbe ..B2.9 +..B2.2: + lea _S(%rip), %rcx + fldt (%rcx) + fcomip %st(1), %st + jbe ..B2.4 +..B2.3: + fld %st(0) + lea _P1(%rip), %rax + fmul %st(1), %st + lea 16+_P1(%rip), %rdx + fld %st(0) + lea 32+_P1(%rip), %rcx + fmul %st(1), %st + lea 48+_P1(%rip), %rsi + fstpt 64(%rsp) + lea 64+_P1(%rip), %rdi + lea 80+_P1(%rip), %r8 + lea 96+_P1(%rip), %r9 + lea 112+_P1(%rip), %r10 + lea 128+_P1(%rip), %r11 + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%rax) + lea 144+_P1(%rip), %rax + fmul %st(1), %st + fldt (%rdx) + lea 160+_P1(%rip), %rdx + fmul %st(2), %st + fldt (%rcx) + lea 176+_P1(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 192+_P1(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 208+_P1(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 224+_P1(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 240+_P1(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 256+_P1(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 272+_P1(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 288+_P1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.4: + movb $1, %dl + movl $16, %eax +..B2.5: + fldt (%rax,%rcx) + fcomip %st(1), %st + ja ..B2.8 + jp ..B2.8 +..B2.6: + incb %dl + addq $16, %rax + cmpb $11, %dl + jl ..B2.5 +..B2.8: + decb %dl + movzbl %dl, %ecx + lea _Z(%rip), %rax + movq %rcx, %rdx + lea _P(%rip), %rdi + shlq $4, %rdx + lea (%rcx,%rcx,4), %rsi + shlq $6, %rsi + fldt (%rax,%rdx) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%rsi,%rdi) + fmul %st(1), %st + fldt 16(%rsi,%rdi) + fmul %st(2), %st + fldt 32(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 48(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 64(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 80(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 96(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 112(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 128(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 144(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 160(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 176(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 192(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 208(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 224(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 240(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 256(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 272(%rsi,%rdi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 288(%rsi,%rdi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 304(%rsi,%rdi) + faddp %st, %st(1) + faddp %st, %st(1) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.9: + lea _ones(%rip), %rax + lea _val_36_0L(%rip), %rdx + lea _PP(%rip), %rcx + lea _QP(%rip), %rsi + lea 16+_PP(%rip), %rdi + lea 16+_QP(%rip), %r8 + lea 32+_PP(%rip), %r9 + lea 32+_QP(%rip), %r10 + fldl (%rax) + lea 48+_PP(%rip), %r11 + fdiv %st(1), %st + lea 48+_QP(%rip), %rax + fxch %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rdx) + lea 64+_PP(%rip), %rdx + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + fxch %st(2) + fstpt (%rsp) + fldt (%rcx) + lea 64+_QP(%rip), %rcx + fmul %st(1), %st + fldt (%rsi) + lea 80+_PP(%rip), %rsi + fmul %st(2), %st + fldt (%rdi) + lea 80+_QP(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 96+_PP(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 96+_QP(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 112+_PP(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 112+_QP(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_PP(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 128+_QP(%rip), %rdx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + lea 144+_PP(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 144+_QP(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 64(%rsp), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + movl $-3, %edx + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rcx) + faddp %st, %st(1) + fstpt -32(%rdi) + fldt (%rsi) + lea 80(%rsp), %rsi + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -32(%rsi) +..___tag_value___j1l.70: + call __libm_sincos_pi4l@PLT +..___tag_value___j1l.71: +..B2.18: + fldt 112(%rsp) + fldt 48(%rsp) + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 96 +..B2.10: + fldt 64(%rsp) + lea _val_0_03L(%rip), %rax + fmulp %st, %st(1) + fldt 48(%rsp) + fmulp %st, %st(2) + fsub %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt (%rax) + fmulp %st, %st(1) + fcomip %st(1), %st + fstp %st(0) + jae ..B2.12 + jp ..B2.12 +..B2.11: + fstp %st(1) + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B2.12: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B2.20: + addq $16, %rsp + .cfi_def_cfa_offset 96 + movaps (%rsp), %xmm0 +..___tag_value___j1l.77: + call __j1q@PLT +..___tag_value___j1l.78: +..B2.13: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B2.21: + fstpl 8(%rsp) + movsd 8(%rsp), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) +..B2.14: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __j1l,@function + .size __j1l,.-__j1l + .data +# -- End __j1l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_S: + .word 64993 + .word 47321 + .word 43380 + .word 39400 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 10427 + .word 24946 + .word 31449 + .word 45220 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 20142 + .word 26358 + .word 43878 + .word 35445 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 45380 + .word 5013 + .word 8196 + .word 48298 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 36049 + .word 37774 + .word 2551 + .word 61157 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 44499 + .word 20687 + .word 35324 + .word 37009 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 37149 + .word 40892 + .word 28299 + .word 43441 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 59921 + .word 2742 + .word 56472 + .word 49873 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 35749 + .word 60152 + .word 42287 + .word 56306 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 36553 + .word 24054 + .word 44174 + .word 62739 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 12707 + .word 13183 + .word 28829 + .word 34586 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 24309 + .word 45263 + .word 7124 + .word 37803 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _S,@object + .size _S,192 + .align 2 +_P1: + .word 26041 + .word 45178 + .word 34801 + .word 41495 + .word 49090 + .word 0 + .word 0 + .word 0 + .word 65370 + .word 9956 + .word 39004 + .word 61276 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 9622 + .word 32383 + .word 51277 + .word 45692 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 53955 + .word 64596 + .word 5222 + .word 35592 + .word 49100 + .word 0 + .word 0 + .word 0 + .word 34986 + .word 10535 + .word 24469 + .word 42796 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 2569 + .word 3934 + .word 58827 + .word 40937 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 16535 + .word 14264 + .word 30755 + .word 37884 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 39497 + .word 52694 + .word 37205 + .word 63078 + .word 49104 + .word 0 + .word 0 + .word 0 + .word 50010 + .word 60332 + .word 8210 + .word 49710 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 10498 + .word 63852 + .word 64151 + .word 35274 + .word 49105 + .word 0 + .word 0 + .word 0 + .word 55591 + .word 43795 + .word 24807 + .word 46603 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 15642 + .word 32907 + .word 52420 + .word 55914 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 53151 + .word 24867 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 37497 + .word 10412 + .word 6022 + .word 55715 + .word 49100 + .word 0 + .word 0 + .word 0 + .word 14397 + .word 43702 + .word 43690 + .word 43690 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 57427 + .word 55015 + .word 8445 + .word 53508 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 64958 + .word 65535 + .word 65535 + .word 65535 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 64696 + .word 39566 + .word 31598 + .word 54025 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,304 + .align 2 +_Z: + .word 17728 + .word 31608 + .word 43949 + .word 62778 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 32551 + .word 41874 + .word 44957 + .word 57471 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 18949 + .word 61409 + .word 34437 + .word 41670 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 4396 + .word 34605 + .word 55192 + .word 54573 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 9307 + .word 10310 + .word 55728 + .word 33731 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 7613 + .word 2917 + .word 18234 + .word 40173 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 24292 + .word 42693 + .word 42782 + .word 46612 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 12570 + .word 29960 + .word 47214 + .word 53050 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 24415 + .word 36838 + .word 59299 + .word 59487 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 32322 + .word 22879 + .word 15219 + .word 32962 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 56404 + .word 12107 + .word 18542 + .word 36180 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _Z,@object + .size _Z,176 + .align 2 +_P: + .word 43464 + .word 52019 + .word 16370 + .word 39301 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 45212 + .word 20213 + .word 4367 + .word 36322 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 62182 + .word 43016 + .word 65056 + .word 63104 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 45004 + .word 1793 + .word 2432 + .word 46043 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 10697 + .word 46113 + .word 34013 + .word 35792 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 9065 + .word 41098 + .word 5532 + .word 44900 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 26003 + .word 49876 + .word 4534 + .word 63025 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 42133 + .word 20669 + .word 62629 + .word 33244 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 10663 + .word 14825 + .word 55564 + .word 41652 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 21046 + .word 62601 + .word 18713 + .word 35715 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 28431 + .word 25084 + .word 11881 + .word 39361 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 40049 + .word 63841 + .word 60004 + .word 52172 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 992 + .word 25066 + .word 14104 + .word 49616 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 44948 + .word 43537 + .word 5801 + .word 46886 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 65381 + .word 44162 + .word 41036 + .word 37465 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 14125 + .word 39149 + .word 41569 + .word 43450 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 9425 + .word 2504 + .word 59629 + .word 56004 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 7469 + .word 36200 + .word 7418 + .word 55109 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 63186 + .word 26107 + .word 31425 + .word 52790 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 52143 + .word 25611 + .word 44594 + .word 35227 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 35717 + .word 29166 + .word 20585 + .word 41467 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 2832 + .word 5439 + .word 21266 + .word 33717 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 5378 + .word 24417 + .word 51356 + .word 63335 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 48412 + .word 30659 + .word 29190 + .word 42335 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 9054 + .word 19776 + .word 30431 + .word 35870 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 1836 + .word 17934 + .word 4966 + .word 40411 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 4836 + .word 40500 + .word 17629 + .word 63063 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 23076 + .word 41820 + .word 25860 + .word 58134 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 39832 + .word 57656 + .word 52920 + .word 41521 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 22342 + .word 1014 + .word 59094 + .word 59974 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 25371 + .word 16474 + .word 28775 + .word 38931 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 48127 + .word 54624 + .word 55306 + .word 41258 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 60537 + .word 50282 + .word 14991 + .word 48309 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 15691 + .word 57338 + .word 50654 + .word 33690 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 40468 + .word 19472 + .word 58347 + .word 35325 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 2985 + .word 7922 + .word 38039 + .word 52517 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 33464 + .word 30509 + .word 7663 + .word 49252 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 63790 + .word 6933 + .word 28208 + .word 44856 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 21342 + .word 14964 + .word 50588 + .word 39336 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 56226 + .word 19816 + .word 23757 + .word 47758 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 41064 + .word 34118 + .word 40187 + .word 42472 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 9004 + .word 37522 + .word 42571 + .word 60097 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 40290 + .word 31235 + .word 60424 + .word 63498 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 59943 + .word 36153 + .word 34778 + .word 37099 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 23867 + .word 38881 + .word 17085 + .word 35787 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 43845 + .word 22338 + .word 8742 + .word 34578 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 21920 + .word 9728 + .word 29300 + .word 62498 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 43241 + .word 30911 + .word 50314 + .word 48209 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 5869 + .word 26658 + .word 63775 + .word 40733 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 50245 + .word 25343 + .word 31579 + .word 47683 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 51932 + .word 37189 + .word 37317 + .word 37600 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 35305 + .word 45319 + .word 11991 + .word 61881 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 43727 + .word 7380 + .word 41898 + .word 45538 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 55996 + .word 31666 + .word 20048 + .word 46502 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 20142 + .word 56563 + .word 4676 + .word 64142 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 42758 + .word 26948 + .word 20336 + .word 64653 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 18102 + .word 54076 + .word 11950 + .word 42374 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 55144 + .word 962 + .word 65430 + .word 51473 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 35076 + .word 30182 + .word 41634 + .word 65458 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 45599 + .word 55541 + .word 39885 + .word 63330 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 11397 + .word 64373 + .word 55097 + .word 42716 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 7278 + .word 1186 + .word 16759 + .word 52647 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 55821 + .word 1941 + .word 7835 + .word 62966 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 43692 + .word 51803 + .word 23893 + .word 63855 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 7306 + .word 740 + .word 42177 + .word 35243 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 20304 + .word 26112 + .word 14593 + .word 58152 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 44429 + .word 26104 + .word 43204 + .word 60999 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 43100 + .word 25366 + .word 26069 + .word 39382 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 53318 + .word 3475 + .word 36258 + .word 39277 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 61289 + .word 34432 + .word 35705 + .word 37567 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 47881 + .word 43207 + .word 60352 + .word 35669 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 3664 + .word 62231 + .word 63343 + .word 46625 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 41733 + .word 11611 + .word 33384 + .word 42291 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 22414 + .word 28668 + .word 61827 + .word 33289 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 39839 + .word 31083 + .word 29085 + .word 58078 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 45039 + .word 64406 + .word 35589 + .word 44277 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 21856 + .word 35851 + .word 11264 + .word 37516 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 38193 + .word 55017 + .word 53611 + .word 34369 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 50065 + .word 40254 + .word 39875 + .word 57241 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 21434 + .word 36257 + .word 28860 + .word 44273 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 24899 + .word 55058 + .word 27384 + .word 42408 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 23952 + .word 61552 + .word 63266 + .word 45785 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 20309 + .word 44505 + .word 41003 + .word 61821 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 9759 + .word 19768 + .word 52219 + .word 54624 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 3188 + .word 41981 + .word 52169 + .word 34347 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 7467 + .word 53297 + .word 24491 + .word 48747 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 26956 + .word 25629 + .word 26154 + .word 58912 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 2746 + .word 62708 + .word 29606 + .word 64476 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 23526 + .word 40632 + .word 17955 + .word 37512 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 58003 + .word 45489 + .word 17648 + .word 59859 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 12684 + .word 55359 + .word 8573 + .word 33616 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 29881 + .word 6055 + .word 26438 + .word 36076 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 37160 + .word 17925 + .word 32887 + .word 39269 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 52986 + .word 52867 + .word 51415 + .word 50108 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 29602 + .word 44157 + .word 62211 + .word 53157 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 14158 + .word 17332 + .word 5318 + .word 65232 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 63939 + .word 33203 + .word 7646 + .word 33955 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 29120 + .word 11480 + .word 39280 + .word 50030 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 42029 + .word 1146 + .word 14309 + .word 51502 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 13934 + .word 45324 + .word 64176 + .word 62054 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 407 + .word 40447 + .word 21497 + .word 41724 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 29047 + .word 47840 + .word 58616 + .word 39773 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 45982 + .word 37340 + .word 60343 + .word 60272 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 61708 + .word 5158 + .word 50916 + .word 46783 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 15241 + .word 33011 + .word 52635 + .word 33255 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 27136 + .word 17183 + .word 21500 + .word 41066 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 41313 + .word 44818 + .word 44575 + .word 56585 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 1149 + .word 8286 + .word 16932 + .word 53342 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 29145 + .word 29789 + .word 51640 + .word 35705 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 48645 + .word 17912 + .word 55357 + .word 48589 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 34105 + .word 33794 + .word 2760 + .word 63371 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 30589 + .word 55184 + .word 63547 + .word 57492 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 36766 + .word 25700 + .word 37915 + .word 36654 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 54115 + .word 65102 + .word 9808 + .word 39287 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 15191 + .word 22168 + .word 7058 + .word 49192 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 21631 + .word 11360 + .word 58072 + .word 50534 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 52725 + .word 34636 + .word 1139 + .word 62446 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 53409 + .word 43718 + .word 34635 + .word 38501 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 21083 + .word 16045 + .word 34961 + .word 47202 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 38780 + .word 63942 + .word 22964 + .word 35475 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 58574 + .word 20162 + .word 19964 + .word 40809 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 36576 + .word 45489 + .word 13327 + .word 34648 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 40869 + .word 46352 + .word 6352 + .word 58511 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 38766 + .word 2767 + .word 13055 + .word 40283 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 11002 + .word 40490 + .word 24288 + .word 64180 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 21330 + .word 2672 + .word 53484 + .word 34906 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 11637 + .word 63948 + .word 58709 + .word 54245 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 16451 + .word 23295 + .word 46139 + .word 44738 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 40013 + .word 16865 + .word 3459 + .word 33992 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 28055 + .word 62424 + .word 59084 + .word 40217 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 37015 + .word 7577 + .word 64481 + .word 59907 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 8219 + .word 9822 + .word 27279 + .word 47011 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 859 + .word 2558 + .word 12826 + .word 34425 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 34289 + .word 12934 + .word 665 + .word 63599 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 15142 + .word 54455 + .word 30227 + .word 45946 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 13599 + .word 50987 + .word 20426 + .word 40603 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 224 + .word 55674 + .word 54991 + .word 58096 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 12803 + .word 33902 + .word 43760 + .word 61618 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 3255 + .word 47153 + .word 28829 + .word 43826 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 57503 + .word 42370 + .word 48259 + .word 34977 + .word 16317 + .word 0 + .word 0 + .word 0 + .word 28464 + .word 31222 + .word 4873 + .word 39771 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 7076 + .word 4355 + .word 19850 + .word 60674 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 58695 + .word 18024 + .word 41082 + .word 56674 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 1100 + .word 13540 + .word 64577 + .word 34943 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 25873 + .word 27686 + .word 11323 + .word 61856 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 12188 + .word 35264 + .word 2250 + .word 59962 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 59387 + .word 26772 + .word 9493 + .word 52010 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 50361 + .word 26279 + .word 61391 + .word 38047 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 40446 + .word 22175 + .word 52931 + .word 64839 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 16288 + .word 22519 + .word 41833 + .word 33884 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 22795 + .word 59507 + .word 36930 + .word 56848 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 9090 + .word 34727 + .word 62738 + .word 39279 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 6548 + .word 61899 + .word 57259 + .word 65037 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 20477 + .word 44577 + .word 947 + .word 52780 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 9901 + .word 21929 + .word 34492 + .word 43241 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 52812 + .word 31464 + .word 11463 + .word 33533 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 16273 + .word 3725 + .word 28705 + .word 54534 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 28551 + .word 65013 + .word 38971 + .word 50753 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 55907 + .word 45101 + .word 33737 + .word 41084 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 43426 + .word 25495 + .word 20291 + .word 49461 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 1975 + .word 51775 + .word 24779 + .word 38683 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 29807 + .word 50650 + .word 32397 + .word 53456 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 5564 + .word 52273 + .word 7778 + .word 54851 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 7750 + .word 4868 + .word 38403 + .word 61120 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 15407 + .word 2698 + .word 46605 + .word 59622 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 137 + .word 48802 + .word 34590 + .word 52040 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 61391 + .word 58349 + .word 18865 + .word 49927 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 11732 + .word 37228 + .word 55154 + .word 32778 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 21770 + .word 7395 + .word 32621 + .word 61994 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 14091 + .word 47411 + .word 37523 + .word 57988 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 50358 + .word 51525 + .word 37270 + .word 54151 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 22903 + .word 22329 + .word 47941 + .word 33412 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 47512 + .word 65334 + .word 39843 + .word 61750 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 35590 + .word 32984 + .word 45077 + .word 44683 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 56839 + .word 21073 + .word 60125 + .word 40948 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 16525 + .word 17598 + .word 3587 + .word 56588 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 56933 + .word 2767 + .word 44815 + .word 51549 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 35966 + .word 59943 + .word 1117 + .word 42745 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 40172 + .word 7271 + .word 14707 + .word 38800 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 8476 + .word 4419 + .word 45780 + .word 62512 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 49137 + .word 16671 + .word 19871 + .word 37593 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 63934 + .word 59521 + .word 24158 + .word 47409 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 31258 + .word 33926 + .word 28141 + .word 53090 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 17384 + .word 36966 + .word 994 + .word 53889 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 55527 + .word 7910 + .word 53076 + .word 57518 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 18447 + .word 54969 + .word 49626 + .word 45611 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 13282 + .word 62682 + .word 5627 + .word 48010 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 7550 + .word 10759 + .word 6881 + .word 57138 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 65344 + .word 23540 + .word 39388 + .word 59430 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 2956 + .word 21512 + .word 45255 + .word 50285 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 29054 + .word 47408 + .word 36565 + .word 51766 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 19154 + .word 63758 + .word 53467 + .word 57697 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 22082 + .word 2480 + .word 53967 + .word 58888 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 52243 + .word 32283 + .word 44909 + .word 38447 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 7267 + .word 45206 + .word 61308 + .word 38976 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 10717 + .word 24270 + .word 52189 + .word 48572 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 40118 + .word 3643 + .word 65534 + .word 49002 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 44194 + .word 5661 + .word 50617 + .word 36641 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 26911 + .word 20494 + .word 63331 + .word 36858 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 20013 + .word 62028 + .word 17108 + .word 33468 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 9949 + .word 25572 + .word 4049 + .word 36529 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 39945 + .word 24442 + .word 45585 + .word 42322 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 59756 + .word 52868 + .word 48949 + .word 51417 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 35066 + .word 41141 + .word 44695 + .word 47881 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 42453 + .word 21162 + .word 44569 + .word 55557 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 30136 + .word 39390 + .word 37319 + .word 40338 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 60101 + .word 48639 + .word 6972 + .word 46254 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 56660 + .word 41165 + .word 63413 + .word 50313 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 13109 + .word 12767 + .word 29074 + .word 57119 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 2453 + .word 26502 + .word 15952 + .word 44109 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 44844 + .word 50072 + .word 22431 + .word 49646 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 33416 + .word 16999 + .word 40271 + .word 50445 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 26560 + .word 32264 + .word 54945 + .word 56373 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 58100 + .word 55846 + .word 35515 + .word 33528 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 44190 + .word 42353 + .word 4741 + .word 37259 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 47772 + .word 5308 + .word 50468 + .word 42281 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 53822 + .word 6159 + .word 32580 + .word 46797 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 5509 + .word 51700 + .word 62457 + .word 63728 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 52274 + .word 35926 + .word 43999 + .word 35182 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 33647 + .word 41025 + .word 45844 + .word 37383 + .word 16317 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,3520 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,16 + .align 2 +_PP: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 0 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 0 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP,@object + .size _PP,160 + .align 2 +_QP: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _QP,@object + .size _QP,160 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,16 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _tonpi,@object + .size _tonpi,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/j1f.S b/external/sgx_libm/intel64/j1f.S new file mode 100644 index 0000000000..2508345690 --- /dev/null +++ b/external/sgx_libm/intel64/j1f.S @@ -0,0 +1,733 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j1f.c" + .text +..TXTST0: +# -- Begin j1f + .text + .align 16,0x90 + .globl j1f +j1f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_j1f.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + subq $64, %rsp + .cfi_def_cfa_offset 80 + movd %xmm0, %r13d + movss %xmm0, 56(%rsp) + movl %r13d, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jae ..B1.24 +..B1.2: + cmpl $1099993482, %edx + jae ..B1.22 +..B1.3: + cmpl $1075439785, %edx + jae ..B1.16 +..B1.4: + cmpl $1048576000, %edx + jae ..B1.15 +..B1.5: + cmpl $998244352, %edx + jae ..B1.14 +..B1.6: + cmpl $838860800, %edx + jae ..B1.13 +..B1.7: + shrl $31, %r13d + cmpl $8388608, %edx + jbe ..B1.9 +..B1.8: + movl %r13d, %r13d + lea _small_value_32(%rip), %rax + movss .L_2il0floatpacket.0(%rip), %xmm1 + mulss %xmm1, %xmm0 + movss (%rax,%r13,4), %xmm2 + mulss .L_2il0floatpacket.1(%rip), %xmm2 + subss %xmm2, %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.9: + testl %edx, %edx + je ..B1.11 +..B1.10: + lea _small_value_32(%rip), %rax + pxor %xmm2, %xmm2 + pxor %xmm1, %xmm1 + movss (%rax,%r13,4), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + cvtss2sd %xmm0, %xmm2 + movss 56(%rsp), %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 + cvtsd2ss %xmm2, %xmm1 + cvtss2sd %xmm0, %xmm0 + movss %xmm1, (%rsp) + subsd %xmm2, %xmm0 + cvtsd2ss %xmm0, %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.11: + movss 56(%rsp), %xmm0 +..B1.12: + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.13: + movss 56(%rsp), %xmm0 + lea 8+_Q2(%rip), %rax + mulss .L_2il0floatpacket.0(%rip), %xmm0 + lea _Q2(%rip), %rdx + cvtss2sd %xmm0, %xmm0 + movaps %xmm0, %xmm1 + mulsd %xmm0, %xmm1 + movsd (%rax), %xmm2 + mulsd %xmm1, %xmm2 + addsd (%rdx), %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm0, %xmm2 + addsd %xmm0, %xmm2 + cvtsd2ss %xmm2, %xmm2 + movaps %xmm2, %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.14: + movss 56(%rsp), %xmm0 + lea 24+_Q2(%rip), %rax + mulss .L_2il0floatpacket.0(%rip), %xmm0 + lea 16+_Q2(%rip), %rcx + cvtss2sd %xmm0, %xmm0 + movaps %xmm0, %xmm2 + lea 8+_Q2(%rip), %rdx + mulsd %xmm0, %xmm2 + lea _Q2(%rip), %rsi + movaps %xmm2, %xmm1 + mulsd %xmm2, %xmm1 + movsd (%rax), %xmm4 + movsd (%rcx), %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm1, %xmm3 + addsd (%rdx), %xmm4 + addsd (%rsi), %xmm3 + mulsd %xmm1, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm3, %xmm4 + mulsd %xmm0, %xmm4 + addsd %xmm0, %xmm4 + cvtsd2ss %xmm4, %xmm4 + movaps %xmm4, %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.15: + pxor %xmm3, %xmm3 + lea 80+_Q1(%rip), %r9 + cvtss2sd 56(%rsp), %xmm3 + andps .L_2il0floatpacket.2(%rip), %xmm3 + testl $-2147483648, %r13d + movaps %xmm3, %xmm1 + lea 88+_Q1(%rip), %rax + mulsd %xmm3, %xmm1 + lea 72+_Q1(%rip), %rsi + movaps %xmm1, %xmm2 + lea 64+_Q1(%rip), %r13 + mulsd %xmm1, %xmm2 + lea 48+_Q1(%rip), %r10 + movsd (%r9), %xmm5 + lea 56+_Q1(%rip), %rdx + mulsd %xmm2, %xmm5 + lea 40+_Q1(%rip), %rdi + movsd (%rax), %xmm6 + lea 32+_Q1(%rip), %rax + movsd (%rsi), %xmm0 + lea 16+_Q1(%rip), %r11 + movsd (%r13), %xmm4 + lea 24+_Q1(%rip), %rcx + mulsd %xmm2, %xmm6 + addsd (%r10), %xmm5 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd (%rdx), %xmm6 + mulsd %xmm2, %xmm5 + addsd (%rdi), %xmm0 + addsd (%rax), %xmm4 + mulsd %xmm2, %xmm6 + addsd (%r11), %xmm5 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd (%rcx), %xmm6 + mulsd %xmm1, %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm3, %xmm5 + lea 8+_Q1(%rip), %r8 + lea _Q1(%rip), %rdx + addsd (%r8), %xmm0 + addsd (%rdx), %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm3, %xmm4 + addsd %xmm0, %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + movaps %xmm6, %xmm0 + xorps .L_2il0floatpacket.3(%rip), %xmm0 + jne ..L31 + movaps %xmm6, %xmm0 +..L31: + cvtsd2ss %xmm0, %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.16: + pxor %xmm3, %xmm3 + andl $-2147483648, %r13d + cvtss2sd 56(%rsp), %xmm3 + andps .L_2il0floatpacket.2(%rip), %xmm3 + cmpl $1097786634, %edx + jae ..B1.20 +..B1.17: + cmpl $1091204523, %edx + jae ..B1.19 +..B1.18: + cmpl $1085318267, %edx + lea _P1(%rip), %rcx + lea _P2(%rip), %rax + jb ..B1.21 + movq %rax, %rcx + jmp ..B1.21 +..B1.19: + cmpl $1094494752, %edx + lea _P3(%rip), %rcx + lea _P4(%rip), %rax + jb ..B1.21 + movq %rax, %rcx + jmp ..B1.21 +..B1.20: + lea _P5(%rip), %rcx +..B1.21: + testl %r13d, %r13d + movsd 96(%rcx), %xmm6 + movsd 80(%rcx), %xmm0 + movsd 88(%rcx), %xmm5 + movsd 72(%rcx), %xmm4 + subsd 104(%rcx), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd 64(%rcx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 48(%rcx), %xmm0 + addsd 56(%rcx), %xmm5 + mulsd %xmm2, %xmm6 + addsd 40(%rcx), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd 32(%rcx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 16(%rcx), %xmm0 + addsd 24(%rcx), %xmm5 + mulsd %xmm2, %xmm6 + addsd 8(%rcx), %xmm4 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + mulsd %xmm3, %xmm4 + addsd %xmm0, %xmm6 + mulsd %xmm3, %xmm5 + addsd (%rcx), %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + movaps %xmm6, %xmm0 + xorps .L_2il0floatpacket.3(%rip), %xmm0 + jne ..L37 + movaps %xmm6, %xmm0 +..L37: + cvtsd2ss %xmm0, %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.22: + pxor %xmm0, %xmm0 + lea _val_16_0(%rip), %rax + cvtss2sd 56(%rsp), %xmm0 + andps .L_2il0floatpacket.2(%rip), %xmm0 + lea 8(%rsp), %rdi + movsd .L_2il0floatpacket.4(%rip), %xmm1 + lea 16(%rsp), %rsi + divsd %xmm0, %xmm1 + movsd (%rax), %xmm2 + movl $-3, %edx + mulsd %xmm1, %xmm2 + andl $-2147483648, %r13d + movsd %xmm2, 8(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm2, 24(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm1, 16(%rsi) + movsd %xmm2, 32(%rsi) +..___tag_value_j1f.43: + call __libm_sincos_k32@PLT +..___tag_value_j1f.44: +..B1.23: + lea 40+_QP(%rip), %r10 + lea 40+_PP(%rip), %rdx + movsd 48(%rsp), %xmm2 + lea 24+_QP(%rip), %r11 + lea 24+_PP(%rip), %rcx + lea 32+_PP(%rip), %rdi + lea _tonpi(%rip), %rax + lea 16+_PP(%rip), %r8 + movsd (%r10), %xmm5 + lea 8+_PP(%rip), %rsi + movsd (%rdx), %xmm6 + lea 32+_QP(%rip), %rdx + mulsd %xmm2, %xmm5 + lea _PP(%rip), %r9 + mulsd %xmm2, %xmm6 + addsd (%r11), %xmm5 + addsd (%rcx), %xmm6 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm6 + movsd (%rdx), %xmm4 + lea 16+_QP(%rip), %rcx + mulsd %xmm2, %xmm4 + addsd (%rsi), %xmm6 + movsd (%rdi), %xmm1 + lea _QP(%rip), %rsi + mulsd %xmm2, %xmm1 + addsd (%rcx), %xmm4 + movsd (%rax), %xmm0 + lea 8+_QP(%rip), %rax + mulsd %xmm2, %xmm4 + addsd (%r8), %xmm1 + mulsd 32(%rsp), %xmm0 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm1 + addsd (%rsi), %xmm4 + sqrtsd %xmm0, %xmm0 + addsd (%r9), %xmm1 + movsd 40(%rsp), %xmm3 + testl %r13d, %r13d + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm1, %xmm6 + mulsd 24(%rsp), %xmm5 + mulsd 16(%rsp), %xmm6 + mulsd 8(%rsp), %xmm5 + subsd %xmm5, %xmm6 + mulsd %xmm6, %xmm0 + movaps %xmm0, %xmm2 + xorps .L_2il0floatpacket.3(%rip), %xmm2 + jne ..L45 + movaps %xmm0, %xmm2 +..L45: + cvtsd2ss %xmm2, %xmm2 + movaps %xmm2, %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.24: + ja ..B1.26 +..B1.25: + lea _zeros(%rip), %rax + shrl $31, %r13d + movss (%rax,%r13,4), %xmm0 + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 +..B1.26: + movss 56(%rsp), %xmm0 +..B1.27: + addq $64, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type j1f,@function + .size j1f,.-j1f + .data +# -- End j1f + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.2: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x3f000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x0d800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_Q2: + .long 4294942533 + .long 3219128319 + .long 1380922587 + .long 1068848469 + .long 4229217063 + .long 3212603831 + .long 2485211372 + .long 1060546867 + .type _Q2,@object + .size _Q2,32 + .align 4 +_Q1: + .long 4294875887 + .long 1071644671 + .long 4170968197 + .long 1038133990 + .long 82133904 + .long 3215982592 + .long 2332230043 + .long 1043853917 + .long 2564340116 + .long 1063605580 + .long 220691470 + .long 1046506888 + .long 254563561 + .long 3205265147 + .long 694808779 + .long 1046622203 + .long 4019568744 + .long 1051070668 + .long 1556554770 + .long 1044540217 + .long 1786312313 + .long 3191946521 + .long 1750363188 + .long 1039907362 + .type _Q1,@object + .size _Q1,96 + .align 4 +_P1: + .long 3288017007 + .long 3163666881 + .long 1479173198 + .long 3218720463 + .long 2681037136 + .long 1068165283 + .long 482223942 + .long 1068193949 + .long 1641242500 + .long 3212130132 + .long 3602486439 + .long 3210890035 + .long 1295520927 + .long 1059513544 + .long 2893642677 + .long 1057503730 + .long 2144568350 + .long 3200875225 + .long 914896231 + .long 3198366754 + .long 1774974526 + .long 1046581392 + .long 3090631217 + .long 1043566169 + .long 3310618599 + .long 3186783429 + .long 1974431497 + .long 1074702165 + .type _P1,@object + .size _P1,112 + .align 4 +_P2: + .long 216484910 + .long 1015040375 + .long 3011708428 + .long 1070806296 + .long 3332724636 + .long 3214272269 + .long 3160644008 + .long 3215461507 + .long 2925435221 + .long 1063888050 + .long 725350898 + .long 1063337916 + .long 297499451 + .long 3206574940 + .long 3278099830 + .long 3204945545 + .long 2222993240 + .long 1053042193 + .long 2059286351 + .long 1050869046 + .long 306569625 + .long 3193793299 + .long 95256688 + .long 3191038309 + .long 616794992 + .long 1039029534 + .long 4088689232 + .long 1075580917 + .type _P2,@object + .size _P2,112 + .align 4 +_P3: + .long 1314465059 + .long 1017127215 + .long 1413823668 + .long 3218077268 + .long 4087546795 + .long 1065951807 + .long 3559351807 + .long 1067757765 + .long 338531188 + .long 3210711466 + .long 2516776276 + .long 3210695105 + .long 1548953411 + .long 1058452686 + .long 3819184955 + .long 1057373236 + .long 1262833741 + .long 3200137243 + .long 325214128 + .long 3198310046 + .long 1253465703 + .long 1045913252 + .long 3453826356 + .long 1043528319 + .long 2667154656 + .long 3186140571 + .long 3502111785 + .long 1076123856 + .type _P3,@object + .size _P3,112 + .align 4 +_P4: + .long 1657852450 + .long 3163577804 + .long 2020212262 + .long 1070330675 + .long 774106997 + .long 3212888122 + .long 2119717923 + .long 3215085957 + .long 2098754573 + .long 1062575793 + .long 2137093530 + .long 1063017421 + .long 2437037263 + .long 3205513537 + .long 2698759453 + .long 3204752976 + .long 1998212634 + .long 1052165362 + .long 2817762251 + .long 1050764623 + .long 357372240 + .long 3193071576 + .long 3891599306 + .long 3190966182 + .long 2865549426 + .long 1038348895 + .long 4077970850 + .long 1076536762 + .type _P4,@object + .size _P4,112 + .align 4 +_P5: + .long 1537387514 + .long 3166104464 + .long 4237757176 + .long 3217630662 + .long 789391682 + .long 1064857043 + .long 3122547501 + .long 1067488355 + .long 3303098147 + .long 3209681410 + .long 2944525948 + .long 3210343613 + .long 1468487066 + .long 1057519518 + .long 285546763 + .long 1057172625 + .long 830693909 + .long 3199311383 + .long 1284260698 + .long 3198182585 + .long 1823688212 + .long 1045254801 + .long 1962790020 + .long 1043427779 + .long 1867031598 + .long 3185590079 + .long 906299589 + .long 1076918395 + .type _P5,@object + .size _P5,112 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_QP: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP,@object + .size _QP,48 + .align 4 +_PP: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP,@object + .size _PP,48 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/j1l.S b/external/sgx_libm/intel64/j1l.S new file mode 100644 index 0000000000..936d12f68b --- /dev/null +++ b/external/sgx_libm/intel64/j1l.S @@ -0,0 +1,86 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "j1l.c" + .text +..TXTST0: +# -- Begin j1l + .text + .align 16,0x90 + .globl j1l +j1l: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_j1l.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 48 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B1.6: + addq $16, %rsp + .cfi_def_cfa_offset 32 + movaps (%rsp), %xmm0 +..___tag_value_j1l.6: + call __j1q@PLT +..___tag_value_j1l.7: +..B1.2: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type j1l,@function + .size j1l,.-j1l + .data +# -- End j1l + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/jn.S b/external/sgx_libm/intel64/jn.S new file mode 100644 index 0000000000..05c0135d90 --- /dev/null +++ b/external/sgx_libm/intel64/jn.S @@ -0,0 +1,1714 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "jn.c" + .text +..TXTST0: +# -- Begin jn + .text + .align 16,0x90 + .globl jn +jn: +# parameter 1: %edi +# parameter 2: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_jn.1: +..L2: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + subq $208, %rsp + .cfi_def_cfa_offset 240 + movl %edi, %ebx + movsd %xmm0, (%rsp) + movl $1, %r14d + xorb %r15b, %r15b +..B1.2: + fnstcw 194(%rsp) +..B1.3: + movzwl 6(%rsp), %eax + andl $32752, %eax + cmpl $32752, %eax + je ..B1.74 +..B1.4: + testl %ebx, %ebx + je ..B1.55 +..B1.5: + lea _zeros(%rip), %rsi + movsd (%rsp), %xmm2 + movsd (%rsi), %xmm0 + ucomisd %xmm0, %xmm2 + jp ..B1.6 + je ..B1.79 +..B1.6: + testl %ebx, %ebx + jge ..B1.8 +..B1.7: + movl %ebx, %eax + negl %ebx + notl %eax + andl $1, %eax + lea -1(%rax,%rax), %r14d +..B1.8: + comisd %xmm2, %xmm0 + jbe ..B1.10 +..B1.9: + movl %r14d, %eax + negl %eax + testb $1, %bl + xorps .L_2il0floatpacket.1(%rip), %xmm2 + movsd %xmm2, (%rsp) + cmovne %eax, %r14d +..B1.10: + cmpl $1, %ebx + je ..B1.78 +..B1.11: + movl %ebx, %ecx + sarl $5, %ecx + cmpl $160, %ecx + jg ..B1.13 +..B1.12: + movslq %ecx, %rcx + lea XZERO(%rip), %rax + movsd (%rax,%rcx,8), %xmm1 + jmp ..B1.14 +..B1.13: + pxor %xmm1, %xmm1 + lea -640(,%rcx,4), %eax + lea (,%rax,8), %ecx + subl %eax, %ecx + cvtsi2sd %ecx, %xmm1 + addsd .L_2il0floatpacket.0(%rip), %xmm1 +..B1.14: + comisd %xmm2, %xmm1 + ja ..B1.83 +..B1.15: + movzwl 194(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.19 +..B1.16: + orl $-64768, %ecx + movw %cx, 192(%rsp) +..B1.17: + fldcw 192(%rsp) +..B1.18: + movsd (%rsp), %xmm2 + movb $1, %r15b +..B1.19: + movsd %xmm2, 80(%rsp) + cmpl $1753, %ebx + fldl 80(%rsp) + movl %ebx, 80(%rsp) + fildl 80(%rsp) + jg ..B1.32 +..B1.20: + fldt val_0_4(%rip) + fmul %st(1), %st + fcomip %st(2), %st + jbe ..B1.32 +..B1.21: + fstp %st(0) + lea _val_2_0L(%rip), %rax + lea _val_1_0L(%rip), %rcx + testl %ebx, %ebx + fldt (%rax) + fdivrp %st, %st(1) + fldt (%rcx) + movl $0, %ecx + fld %st(0) + movl %ecx, %eax + fld %st(0) + fld %st(2) + fld %st(3) + jle ..B1.25 +..B1.23: + incl %ecx + fmul %st(5), %st + cmpl %ebx, %ecx + jb ..B1.23 +..B1.25: + movl %eax, %ecx + testl %ebx, %ebx + jle ..B1.28 +..B1.27: + incl %ecx + fxch %st(1) + fmul %st(3), %st + fxch %st(3) + fadd %st(4), %st + cmpl %ebx, %ecx + fxch %st(3) + fxch %st(1) + jb ..B1.27 +..B1.28: + fstp %st(3) +..B1.29: + fxch %st(4) + fmul %st(0), %st + fchs +..B1.30: + incl %eax + incl %ebx + movl %eax, %ecx + fld %st(3) + imull %ebx, %ecx + fxch %st(1) + fmul %st, %st(2) + movl %ecx, 80(%rsp) + fildl 80(%rsp) + fdivrp %st, %st(3) + fxch %st(2) + fadd %st, %st(4) + fxch %st(1) + fucomip %st(4), %st + fxch %st(1) + jne ..B1.30 + jp ..B1.30 +..B1.31: + fstp %st(0) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(2) + fdivrp %st, %st(1) + fxch %st(1) + fstpt 32(%rsp) + jmp ..B1.45 +..B1.32: + fcomi %st(1), %st + ja ..B1.51 +..B1.33: + lea _val_20_0L(%rip), %rax + lea _val_1000_0L(%rip), %rcx + fldt (%rax) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fcomip %st(2), %st + ja ..B1.57 +..B1.34: + lea _val_4_0L(%rip), %rax + fld %st(0) + lea _val_1_0L(%rip), %rdi + lea _val_8_0L(%rip), %rsi + lea _val_2_0L(%rip), %r8 + lea _val_3_0L(%rip), %r9 + lea _val_5_0L(%rip), %r10 + movl $-1, %ecx + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fldt (%rax) + xorb %al, %al + fstpt 144(%rsp) + fldt 144(%rsp) + fmulp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + fldt (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + fldt (%rdi) + fld %st(0) + fsubrp %st, %st(3) + fxch %st(1) + fdivrp %st, %st(2) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 80(%rsp) + fldt (%r8) + fstpt 128(%rsp) + fldt 128(%rsp) + fstpt 32(%rsp) + fldt (%r9) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt (%r10) + fstpt (%rsp) + fldt (%rsp) + fldt 96(%rsp) + fldt 32(%rsp) + fldt 16(%rsp) +..B1.35: + fldt 160(%rsp) + fld %st(3) + fmul %st(4), %st + testl %ecx, %ecx + fxch %st(4) + fstpt 96(%rsp) + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt 176(%rsp) + fsub %st, %st(4) + fxch %st(3) + fdivrp %st, %st(4) + fxch %st(6) + fmulp %st, %st(3) + fld %st(3) + fmul %st(4), %st + fsubrp %st, %st(2) + fdivrp %st, %st(1) + fmul %st(1), %st + fldt 96(%rsp) + fldt 32(%rsp) + jle ..B1.37 +..B1.36: + fxch %st(3) + faddp %st, %st(6) + fldt 48(%rsp) + fadd %st(2), %st + fstpt 48(%rsp) + jmp ..B1.38 +..B1.37: + fxch %st(3) + fsubrp %st, %st(6) + fldt 48(%rsp) + fsub %st(2), %st + fstpt 48(%rsp) +..B1.38: + fldt 128(%rsp) + fadd %st, %st(3) + faddp %st, %st(5) + fldt 144(%rsp) + fadd %st, %st(1) + faddp %st, %st(4) + fld %st(1) + fdiv %st(6), %st + fabs + fldt 80(%rsp) + fcomip %st(1), %st + jbe ..B1.40 +..B1.39: + fstpt 80(%rsp) + movb $1, %al + jmp ..B1.41 +..B1.40: + fstp %st(0) + testb %al, %al + jne ..B1.56 +..B1.41: + fldt (%rsp) + negl %ecx + fucomip %st(6), %st + fxch %st(2) + fxch %st(1) + fxch %st(5) + jne ..B1.35 + jp ..B1.35 +..B1.42: + fstp %st(4) + fstp %st(1) + fstp %st(0) + fstp %st(0) + fldt 64(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) + fstpt 32(%rsp) + fldt 112(%rsp) +..B1.43: + addl %ebx, %ebx + addq $-16, %rsp + .cfi_def_cfa_offset 256 + negl %ebx + lea 16(%rsp), %rdi + decl %ebx + lea 48(%rsp), %rsi + movl %ebx, %edx + fstpt (%rsp) + fldt (%rsp) + fstpt 80(%rsi) +..___tag_value_jn.11: + call __libm_sincos_pi4l@PLT +..___tag_value_jn.12: +..B1.82: + fldt 128(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 240 +..B1.44: + fldt 16(%rsp) + lea _tonpi(%rip), %rax + fldt (%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fdivp %st, %st(3) + fxch %st(2) + fsqrt + fldt 32(%rsp) + fmulp %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fmulp %st, %st(1) +..B1.45: + testl %r14d, %r14d + jl ..B1.47 +..B1.46: + fstpt (%rsp) + jmp ..B1.48 +..B1.47: + fchs + fstpt (%rsp) +..B1.48: + testb %r15b, %r15b + je ..B1.50 +..B1.49: + fldcw 194(%rsp) +..B1.50: + fldt (%rsp) + fstpl 16(%rsp) + movsd 16(%rsp), %xmm0 + addq $208, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 240 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.51: + fstp %st(0) + fld %st(0) + lea (%rbx,%rbx), %esi + movl %esi, 80(%rsp) + lea _val_1_0L(%rip), %rcx + lea _val_2_0L(%rip), %rdi + lea _val_0_0L(%rip), %rax + fmul %st(1), %st + fchs + fstpt 64(%rsp) + fld %st(0) + fxch %st(1) + fstpt 112(%rsp) + fldt (%rax) + fldt (%rcx) + fstpt 32(%rsp) + fldt 32(%rsp) + fld %st(0) + fxch %st(1) + fstpt 16(%rsp) + fildl 80(%rsp) + fstpt (%rsp) + fldt (%rsp) + fldt (%rdi) + fstpt 48(%rsp) + fldt (%rsp) + jmp ..B1.52 +..B1.53: + fstp %st(3) + fxch %st(1) + fxch %st(2) + fxch %st(4) + fxch %st(3) + fxch %st(1) +..B1.52: + fldt 48(%rsp) + faddp %st, %st(1) + fld %st(4) + fmul %st(1), %st + fld %st(2) + fmul %st(2), %st + fldt 64(%rsp) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(2) + fldt 32(%rsp) + fmulp %st, %st(6) + faddp %st, %st(5) + fld %st(0) + fxch %st(1) + fdiv %st(5), %st + fucomi %st(4), %st + fxch %st(3) + fstpt 32(%rsp) + jne ..B1.53 + jp ..B1.53 + jmp ..B1.67 +..B1.55: + movsd (%rsp), %xmm0 + call j0@PLT +..B1.83: + addq $208, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 240 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.56: + fstp %st(4) + fstp %st(3) + fstp %st(0) + fstp %st(0) + fldt 64(%rsp) + fstpt (%rsp) + fxch %st(1) + fstpt 16(%rsp) + fstpt 32(%rsp) + fldt 112(%rsp) + jmp ..B1.43 +..B1.57: + fstp %st(0) + lea _val_36_0L(%rip), %rax + fldt (%rax) + fcomi %st(1), %st + jbe ..B1.61 +..B1.58: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 256 + fstpt (%rsp) + fldt (%rsp) + fstpt 128(%rsp) +..___tag_value_jn.37: + call __j0l@PLT +..___tag_value_jn.38: +..B1.84: + fldt 128(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 240 +..B1.59: + fxch %st(1) + fstpt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 256 + fstpt (%rsp) + fldt (%rsp) + fstpt 128(%rsp) +..___tag_value_jn.41: + call __j1l@PLT +..___tag_value_jn.42: +..B1.85: + fldt 128(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 240 +..B1.60: + fxch %st(1) + jmp ..B1.63 +..B1.61: + lea _ones(%rip), %rax + lea _PP0(%rip), %rcx + lea 16+_PP0(%rip), %r9 + lea _PP1(%rip), %r8 + lea 16+_PP1(%rip), %r10 + lea 32+_PP0(%rip), %r11 + lea 48+_PP1(%rip), %rsi + lea 64+_PP0(%rip), %rdi + fldl (%rax) + lea 32+_PP1(%rip), %rax + fdiv %st(2), %st + movl $-1, %edx + fmul %st, %st(1) + fld %st(1) + fmul %st(2), %st + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(1) + fstpt (%rsp) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rcx) + lea 48+_PP0(%rip), %rcx + fmul %st(2), %st + fldt (%r8) + lea 64+_PP1(%rip), %r8 + fmul %st(3), %st + fldt (%r9) + lea 80+_PP0(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r10) + lea 80+_PP1(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + lea 96+_PP0(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 96+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 112+_PP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 112+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 128+_PP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 128+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 144+_PP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 144+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 256 + lea 112(%rsp), %rdi + lea 96(%rsp), %rsi + fxch %st(3) + fstpt (%rsp) + fldt (%rsp) + fstpt 32(%rsi) + fldt (%rax) + lea _QP0(%rip), %rax + faddp %st, %st(3) + fxch %st(2) + fstpt -32(%rsi) + fldt (%rax) + lea _QP1(%rip), %rax + fmul %st(1), %st + fldt (%rax) + lea 16+_QP0(%rip), %rax + fmul %st(2), %st + fldt (%rax) + lea 16+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 32+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 32+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 48+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 48+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 64+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 64+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 80+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 80+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 96+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 96+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 112+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 112+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 144+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rax) + lea 144+_QP1(%rip), %rax + faddp %st, %st(1) + fmul %st(2), %st + fstpt -48(%rsi) + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -16(%rsi) +..___tag_value_jn.45: + call __libm_sincos_pi4l@PLT +..___tag_value_jn.46: +..B1.86: + fldt 128(%rsp) + fldt 80(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 240 +..B1.62: + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt 80(%rsp) + fldt 16(%rsp) + fmul %st(1), %st + fxch %st(5) + fmulp %st, %st(1) + fldt (%rax) + fmulp %st, %st(2) + fxch %st(1) + fsqrt + fldt 96(%rsp) + fmul %st, %st(3) + fxch %st(3) + fsubrp %st, %st(5) + fmul %st, %st(4) + fxch %st(4) + fstpt 32(%rsp) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) +..B1.63: + lea _val_2_0L(%rip), %rax + cmpl $1, %ebx + fldt (%rax) + movl $0, %eax + fld %st(0) + jle ..B1.91 +..B1.64: + fldt 32(%rsp) + decl %ebx +..B1.65: + fld %st(1) + incl %eax + fdiv %st(5), %st + cmpl %ebx, %eax + fmul %st(4), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(2) + fsubp %st, %st(1) + fld %st(3) + jae ..B1.66 +..B1.92: + fstp %st(4) + fxch %st(3) + jmp ..B1.65 +..B1.66: + fstp %st(5) + fstp %st(4) + fstp %st(0) + fstp %st(0) + fstpt 32(%rsp) + jmp ..B1.45 +..B1.67: + fstp %st(2) + fstp %st(4) + fstp %st(0) + fstp %st(1) + fstp %st(1) + fldt 48(%rsp) + decl %ebx + fldt 16(%rsp) + xorl %eax, %eax + movl %ebx, 80(%rsp) + fld %st(0) + fxch %st(1) + fdiv %st, %st(3) + fildl 80(%rsp) + fmul %st(3), %st + fldt 112(%rsp) + fdivr %st, %st(3) +..B1.68: + fld %st(5) + incl %eax + fmul %st(2), %st + fxch %st(2) + fsub %st(5), %st + fxch %st(1) + fmul %st, %st(3) + cmpl %ebx, %eax + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fld %st(5) + fld %st(1) + jge ..B1.69 +..B1.93: + fstp %st(7) + fstp %st(1) + fxch %st(2) + jmp ..B1.68 +..B1.69: + fstp %st(0) + fstp %st(4) + fstp %st(4) + fstp %st(0) + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(1) + fabs + fxch %st(1) + fabs + fcomip %st(1), %st + fstp %st(0) + fxch %st(1) + fstpt (%rsp) + jae ..B1.72 + jp ..B1.72 +..B1.70: + addq $-16, %rsp + .cfi_def_cfa_offset 256 + fstpt (%rsp) +..___tag_value_jn.49: + call __j1l@PLT +..___tag_value_jn.50: +..B1.87: + addq $16, %rsp + .cfi_def_cfa_offset 240 +..B1.71: + fldt (%rsp) + fdivrp %st, %st(1) + jmp ..B1.45 +..B1.72: + addq $-16, %rsp + .cfi_def_cfa_offset 256 + fstpt (%rsp) +..___tag_value_jn.53: + call __j0l@PLT +..___tag_value_jn.54: +..B1.88: + addq $16, %rsp + .cfi_def_cfa_offset 240 +..B1.73: + fldt 32(%rsp) + fdivrp %st, %st(1) + jmp ..B1.45 +..B1.74: + testl $1048575, 4(%rsp) + jne ..B1.77 +..B1.75: + cmpl $0, (%rsp) + jne ..B1.77 +..B1.76: + movzbl 7(%rsp), %ecx + movl %ebx, %eax + andl $128, %ecx + lea _zeros(%rip), %rdx + shrl $7, %ecx + shrl $31, %eax + xorl %eax, %ecx + andl %ebx, %ecx + movsd (%rdx,%rcx,8), %xmm0 + addq $208, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 240 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.77: + movsd (%rsp), %xmm0 + addq $208, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 240 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.78: + movaps %xmm2, %xmm0 + call j1@PLT +..B1.89: + movaps %xmm0, %xmm1 + testl %r14d, %r14d + xorps .L_2il0floatpacket.1(%rip), %xmm1 + jge ..L78 + movaps %xmm1, %xmm0 +..L78: + addq $208, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 240 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.79: + movzbl 7(%rsp), %ecx + movl %ebx, %eax + andl $128, %ecx + shrl $7, %ecx + shrl $31, %eax + xorl %eax, %ecx + andl %ebx, %ecx + movsd (%rsi,%rcx,8), %xmm0 + addq $208, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 240 + .cfi_offset 3, -32 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.91: + fstp %st(3) + fstp %st(2) + fstp %st(1) + jmp ..B1.45 + .align 16,0x90 + .cfi_endproc + .type jn,@function + .size jn,.-jn + .data +# -- End jn + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +val_0_4: + .byte 0x00,0xd0,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xfd,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type val_0_4,@object + .size val_0_4,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40add600 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +XZERO: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x33333333,0x3fd33333 + .long 0x66666666,0x3ff66666 + .long 0x00000000,0x400c0000 + .long 0x00000000,0x401c0000 + .long 0x00000000,0x40280000 + .long 0xcccccccd,0x40324ccc + .long 0x00000000,0x403a0000 + .long 0x00000000,0x40418000 + .long 0x9999999a,0x40469999 + .long 0x00000000,0x404c4000 + .long 0x33333333,0x40513333 + .long 0x00000000,0x40548000 + .long 0x00000000,0x40580000 + .long 0x33333333,0x405bb333 + .long 0xcccccccd,0x405f8ccc + .long 0xcccccccd,0x4061cccc + .long 0x33333333,0x4063e333 + .long 0xcccccccd,0x40660ccc + .long 0x33333333,0x40684333 + .long 0xcccccccd,0x406a8ccc + .long 0x33333333,0x406ce333 + .long 0x66666666,0x406f4666 + .long 0x9999999a,0x4070d999 + .long 0x00000000,0x40721800 + .long 0x9999999a,0x40735999 + .long 0x9999999a,0x4074a199 + .long 0x66666666,0x4075ee66 + .long 0x00000000,0x40774000 + .long 0xcccccccd,0x407894cc + .long 0x66666666,0x4079ee66 + .long 0x33333333,0x407b4b33 + .long 0x33333333,0x407cab33 + .long 0x00000000,0x407e1000 + .long 0x66666666,0x407f7666 + .long 0xcccccccd,0x408070cc + .long 0x33333333,0x40812733 + .long 0x33333333,0x4081df33 + .long 0xcccccccd,0x408298cc + .long 0x33333333,0x40835333 + .long 0x33333333,0x40840f33 + .long 0xcccccccd,0x4084cccc + .long 0x66666666,0x40858a66 + .long 0x66666666,0x40864a66 + .long 0x66666666,0x40870a66 + .long 0x00000000,0x4087cc00 + .long 0x66666666,0x40888e66 + .long 0x9999999a,0x40895199 + .long 0x9999999a,0x408a1599 + .long 0x33333333,0x408adb33 + .long 0xcccccccd,0x408ba0cc + .long 0x00000000,0x408c6000 + .long 0x00000000,0x408d2800 + .long 0x00000000,0x408df000 + .long 0x00000000,0x408ec000 + .long 0x00000000,0x408f8800 + .long 0x00000000,0x40902800 + .long 0x00000000,0x40909000 + .long 0x00000000,0x4090f400 + .long 0x00000000,0x40915c00 + .long 0x00000000,0x4091c000 + .long 0x00000000,0x40922800 + .long 0x00000000,0x40929000 + .long 0x00000000,0x4092f800 + .long 0x00000000,0x40935c00 + .long 0x00000000,0x4093c400 + .long 0x00000000,0x40943000 + .long 0x00000000,0x40949800 + .long 0x00000000,0x40950000 + .long 0x00000000,0x40956800 + .long 0x00000000,0x4095d000 + .long 0x00000000,0x40963c00 + .long 0x00000000,0x4096a400 + .long 0x00000000,0x40971000 + .long 0x00000000,0x40977800 + .long 0x00000000,0x4097e400 + .long 0x00000000,0x40984c00 + .long 0x00000000,0x4098b800 + .long 0x00000000,0x40992400 + .long 0x00000000,0x40999000 + .long 0x00000000,0x4099f800 + .long 0x00000000,0x409a6400 + .long 0x00000000,0x409ad000 + .long 0x00000000,0x409b3c00 + .long 0x00000000,0x409ba800 + .long 0x00000000,0x409c1400 + .long 0x00000000,0x409c8000 + .long 0x00000000,0x409cec00 + .long 0x00000000,0x409d5c00 + .long 0x00000000,0x409dc800 + .long 0x00000000,0x409e3400 + .long 0x00000000,0x409ea000 + .long 0x00000000,0x409f1000 + .long 0x00000000,0x409f7c00 + .long 0x00000000,0x409fe800 + .long 0x00000000,0x40a02c00 + .long 0x00000000,0x40a06200 + .long 0x00000000,0x40a09a00 + .long 0x00000000,0x40a0d000 + .long 0x00000000,0x40a10800 + .long 0x00000000,0x40a13e00 + .long 0x00000000,0x40a17600 + .long 0x00000000,0x40a1ae00 + .long 0x00000000,0x40a1e400 + .long 0x00000000,0x40a21c00 + .long 0x00000000,0x40a25400 + .long 0x00000000,0x40a28c00 + .long 0x00000000,0x40a2c200 + .long 0x00000000,0x40a2fa00 + .long 0x00000000,0x40a33200 + .long 0x00000000,0x40a36a00 + .long 0x00000000,0x40a3a200 + .long 0x00000000,0x40a3da00 + .long 0x00000000,0x40a41200 + .long 0x00000000,0x40a44a00 + .long 0x00000000,0x40a48200 + .long 0x00000000,0x40a4ba00 + .long 0x00000000,0x40a4f200 + .long 0x00000000,0x40a52a00 + .long 0x00000000,0x40a56200 + .long 0x00000000,0x40a59a00 + .long 0x00000000,0x40a5d200 + .long 0x00000000,0x40a60a00 + .long 0x00000000,0x40a64400 + .long 0x00000000,0x40a67c00 + .long 0x00000000,0x40a6b400 + .long 0x00000000,0x40a6ec00 + .long 0x00000000,0x40a72600 + .long 0x00000000,0x40a75e00 + .long 0x00000000,0x40a79600 + .long 0x00000000,0x40a7d000 + .long 0x00000000,0x40a80800 + .long 0x00000000,0x40a84000 + .long 0x00000000,0x40a87a00 + .long 0x00000000,0x40a8b200 + .long 0x00000000,0x40a8ec00 + .long 0x00000000,0x40a92400 + .long 0x00000000,0x40a95c00 + .long 0x00000000,0x40a99600 + .long 0x00000000,0x40a9ce00 + .long 0x00000000,0x40aa0800 + .long 0x00000000,0x40aa4200 + .long 0x00000000,0x40aa7a00 + .long 0x00000000,0x40aab400 + .long 0x00000000,0x40aaec00 + .long 0x00000000,0x40ab2600 + .long 0x00000000,0x40ab6000 + .long 0x00000000,0x40ab9800 + .long 0x00000000,0x40abd200 + .long 0x00000000,0x40ac0a00 + .long 0x00000000,0x40ac4400 + .long 0x00000000,0x40ac7e00 + .long 0x00000000,0x40acb800 + .long 0x00000000,0x40acf000 + .long 0x00000000,0x40ad2a00 + .long 0x00000000,0x40ad6400 + .long 0x00000000,0x40ad9e00 + .long 0x00000000,0x40add600 + .type XZERO,@object + .size XZERO,1288 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_val_2_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _val_2_0L,@object + .size _val_2_0L,16 + .align 2 +_val_1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _val_1_0L,@object + .size _val_1_0L,16 + .align 2 +_val_20_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16387 + .word 0 + .word 0 + .word 0 + .type _val_20_0L,@object + .size _val_20_0L,16 + .align 2 +_val_1000_0L: + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .word 0 + .word 0 + .type _val_1000_0L,@object + .size _val_1000_0L,16 + .align 2 +_val_4_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16385 + .word 0 + .word 0 + .word 0 + .type _val_4_0L,@object + .size _val_4_0L,16 + .align 2 +_val_8_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16386 + .word 0 + .word 0 + .word 0 + .type _val_8_0L,@object + .size _val_8_0L,16 + .align 2 +_val_3_0L: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _val_3_0L,@object + .size _val_3_0L,16 + .align 2 +_val_5_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16385 + .word 0 + .word 0 + .word 0 + .type _val_5_0L,@object + .size _val_5_0L,16 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _tonpi,@object + .size _tonpi,16 + .align 2 +_val_0_0L: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _val_0_0L,@object + .size _val_0_0L,16 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,16 + .align 2 +_PP0: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 0 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP0,@object + .size _PP0,160 + .align 2 +_PP1: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 0 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 0 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP1,@object + .size _PP1,160 + .align 2 +_QP0: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 0 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .word 0 + .word 0 + .type _QP0,@object + .size _QP0,160 + .align 2 +_QP1: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _QP1,@object + .size _QP1,160 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/jnf.S b/external/sgx_libm/intel64/jnf.S new file mode 100644 index 0000000000..3638f57366 --- /dev/null +++ b/external/sgx_libm/intel64/jnf.S @@ -0,0 +1,1156 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "jnf.c" + .text +..TXTST0: +# -- Begin jnf + .text + .align 16,0x90 + .globl jnf +jnf: +# parameter 1: %edi +# parameter 2: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_jnf.1: +..L2: + + pushq %r14 + .cfi_def_cfa_offset 16 + .cfi_offset 14, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + subq $72, %rsp + .cfi_def_cfa_offset 96 + movl %edi, %r14d + movd %xmm0, %r15d + movss %xmm0, (%rsp) + movl %r15d, %ecx + andl $2147483647, %ecx + cmpl $2139095040, %ecx + jae ..B1.41 +..B1.2: + testl %r14d, %r14d + je ..B1.40 +..B1.3: + xorl %r14d, %r15d + shrl $31, %r15d + andl %r14d, %r15d + testl %ecx, %ecx + je ..B1.39 +..B1.4: + movl %r14d, %eax + cltd + xorl %edx, %r14d + subl %edx, %r14d + andps .L_2il0floatpacket.1(%rip), %xmm0 + cmpl $1, %r14d + movss %xmm0, (%rsp) + je ..B1.58 +..B1.5: + movl %r14d, %esi + sarl $3, %esi + cmpl $320, %esi + jg ..B1.7 +..B1.6: + movslq %esi, %rsi + lea function_zeros(%rip), %rcx + movss (%rcx,%rsi,4), %xmm2 + jmp ..B1.8 +..B1.7: + pxor %xmm2, %xmm2 + lea -320(%rsi), %ecx + lea -2560(,%rsi,8), %esi + subl %ecx, %esi + cvtsi2ss %esi, %xmm2 + addss .L_2il0floatpacket.0(%rip), %xmm2 +..B1.8: + comiss %xmm0, %xmm2 + ja ..B1.38 +..B1.9: + pxor %xmm1, %xmm1 + pxor %xmm3, %xmm3 + cvtss2sd %xmm0, %xmm1 + cvtsi2sd %r14d, %xmm3 + cmpl $170, %r14d + jg ..B1.22 +..B1.10: + lea _val_0_6(%rip), %rcx + movsd (%rcx), %xmm2 + mulsd %xmm3, %xmm2 + comisd %xmm1, %xmm2 + jb ..B1.22 +..B1.11: + lea _val_2_0(%rip), %rcx + testl %r14d, %r14d + movsd .L_2il0floatpacket.2(%rip), %xmm4 + movaps %xmm4, %xmm3 + movaps %xmm4, %xmm0 + movaps %xmm4, %xmm2 + divsd (%rcx), %xmm1 + movl $0, %ecx + jle ..B1.15 +..B1.13: + incl %ecx + mulsd %xmm1, %xmm0 + cmpl %r14d, %ecx + jb ..B1.13 +..B1.14: + testl %r14d, %r14d +..B1.15: + movl $0, %ecx + jle ..B1.19 +..B1.17: + incl %ecx + mulsd %xmm2, %xmm3 + addsd %xmm4, %xmm2 + cmpl %r14d, %ecx + jb ..B1.17 +..B1.19: + mulsd %xmm1, %xmm1 + lea _TWO_19H(%rip), %rsi + movsd %xmm4, 16(%rsp) + xorl %ecx, %ecx + movsd %xmm4, 56(%rsp) + xorps .L_2il0floatpacket.4(%rip), %xmm1 + movsd (%rsi), %xmm2 + .align 16,0x90 +..B1.20: + incl %ecx + incl %r14d + movl %ecx, %esi + movaps %xmm4, %xmm8 + imull %r14d, %esi + pxor %xmm4, %xmm4 + movsd 16(%rsp), %xmm5 + movaps %xmm2, %xmm7 + movsd 56(%rsp), %xmm6 + mulsd %xmm1, %xmm5 + cvtsi2sd %esi, %xmm4 + divsd %xmm4, %xmm5 + movsd %xmm5, 16(%rsp) + addsd %xmm5, %xmm6 + mulsd %xmm6, %xmm7 + movsd %xmm6, 56(%rsp) + addsd %xmm7, %xmm6 + movsd %xmm6, 64(%rsp) + movsd 64(%rsp), %xmm4 + subsd %xmm7, %xmm4 + ucomisd %xmm4, %xmm8 + jne ..B1.20 + jp ..B1.20 +..B1.21: + mulsd 56(%rsp), %xmm0 + divsd %xmm3, %xmm0 + jmp ..B1.34 +..B1.22: + comisd %xmm1, %xmm3 + ja ..B1.35 +..B1.23: + pxor %xmm2, %xmm2 + lea (%r14,%r14,4), %ecx + lea 1000(,%rcx,4), %esi + cvtsi2sd %esi, %xmm2 + comisd %xmm1, %xmm2 + ja ..B1.47 +..B1.24: + lea _val_4_0(%rip), %rcx + movaps %xmm3, %xmm10 + lea _val_8_0(%rip), %rdi + lea _val_2_0(%rip), %r8 + movsd .L_2il0floatpacket.2(%rip), %xmm12 + lea _val_3_0(%rip), %r9 + lea _val_5_0(%rip), %r10 + movl $-1, %esi + movsd (%rcx), %xmm11 + movaps %xmm12, %xmm2 + movsd (%rdi), %xmm8 + movaps %xmm12, %xmm9 + movsd (%r8), %xmm7 + xorb %cl, %cl + mulsd %xmm11, %xmm10 + movaps %xmm7, %xmm6 + mulsd %xmm1, %xmm8 + mulsd %xmm3, %xmm10 + movaps %xmm10, %xmm13 + movsd (%r9), %xmm5 + subsd %xmm12, %xmm13 + divsd %xmm8, %xmm13 + movsd %xmm13, 16(%rsp) + movaps %xmm5, %xmm4 + movsd (%r10), %xmm3 +..B1.25: + movaps %xmm4, %xmm14 + movaps %xmm6, %xmm15 + mulsd %xmm4, %xmm14 + testl %esi, %esi + mulsd %xmm8, %xmm15 + movsd %xmm2, 56(%rsp) + movaps %xmm10, %xmm2 + subsd %xmm14, %xmm2 + movaps %xmm3, %xmm14 + mulsd %xmm3, %xmm14 + divsd %xmm15, %xmm2 + movaps %xmm10, %xmm15 + mulsd 16(%rsp), %xmm2 + subsd %xmm14, %xmm15 + movaps %xmm8, %xmm14 + mulsd %xmm5, %xmm14 + divsd %xmm14, %xmm15 + mulsd %xmm2, %xmm15 + jle ..B1.46 +..B1.26: + addsd %xmm2, %xmm12 + addsd %xmm15, %xmm13 +..B1.27: + movsd %xmm15, 16(%rsp) + addsd %xmm7, %xmm6 + divsd %xmm12, %xmm15 + andps .L_2il0floatpacket.3(%rip), %xmm15 + addsd %xmm7, %xmm5 + addsd %xmm11, %xmm4 + addsd %xmm11, %xmm3 + comisd %xmm15, %xmm9 + jbe ..B1.29 +..B1.28: + movaps %xmm15, %xmm9 + movb $1, %cl + jmp ..B1.30 +..B1.29: + testb %cl, %cl + jne ..B1.32 +..B1.30: + lea _TWO_19H(%rip), %rdi + movaps %xmm12, %xmm2 + negl %esi + movsd (%rdi), %xmm14 + mulsd %xmm12, %xmm14 + addsd %xmm14, %xmm2 + movsd %xmm2, 64(%rsp) + movsd 64(%rsp), %xmm2 + subsd %xmm14, %xmm2 + ucomisd 56(%rsp), %xmm2 + jne ..B1.25 + jp ..B1.25 +..B1.32: + addl %r14d, %r14d + lea 56(%rsp), %rdi + negl %r14d + lea 16(%rsp), %rsi + decl %r14d + movaps %xmm1, %xmm0 + movl %r14d, %edx + movsd %xmm13, (%rsp) + movsd %xmm12, -8(%rsi) + movsd %xmm1, 32(%rsi) +..___tag_value_jnf.8: + call __libm_sincos_k32@PLT +..___tag_value_jnf.9: +..B1.33: + lea _tonpi(%rip), %rax + movsd 48(%rsp), %xmm1 + movsd 8(%rsp), %xmm12 + movsd (%rsp), %xmm13 + movsd (%rax), %xmm0 + divsd %xmm1, %xmm0 + sqrtsd %xmm0, %xmm0 + mulsd 16(%rsp), %xmm12 + mulsd 56(%rsp), %xmm13 + subsd %xmm13, %xmm12 + mulsd %xmm12, %xmm0 +..B1.34: + movaps %xmm0, %xmm1 + testl %r15d, %r15d + xorps .L_2il0floatpacket.4(%rip), %xmm1 + jne ..L10 + movaps %xmm0, %xmm1 +..L10: + cvtsd2ss %xmm1, %xmm1 + movaps %xmm1, %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.35: + pxor %xmm8, %xmm8 + lea (%r14,%r14), %esi + cvtsi2sd %esi, %xmm8 + movaps %xmm1, %xmm7 + xorl %ecx, %ecx + mulsd %xmm1, %xmm7 + lea _val_2_0(%rip), %rdi + lea _TWO_19H(%rip), %r8 + pxor %xmm11, %xmm11 + movsd .L_2il0floatpacket.2(%rip), %xmm3 + movaps %xmm1, %xmm9 + movq %rcx, 56(%rsp) + movaps %xmm3, %xmm10 + xorps .L_2il0floatpacket.4(%rip), %xmm7 + movaps %xmm8, %xmm6 + movsd %xmm3, 16(%rsp) + movsd (%rdi), %xmm4 + movsd (%r8), %xmm5 + jmp ..B1.36 +..B1.37: + movsd %xmm12, 56(%rsp) + movsd %xmm12, 16(%rsp) +..B1.36: + movaps %xmm9, %xmm2 + movaps %xmm8, %xmm12 + mulsd %xmm7, %xmm11 + addsd %xmm4, %xmm6 + mulsd %xmm7, %xmm10 + mulsd %xmm6, %xmm2 + mulsd %xmm6, %xmm12 + addsd %xmm11, %xmm2 + addsd %xmm10, %xmm12 + movaps %xmm9, %xmm11 + movaps %xmm2, %xmm9 + divsd %xmm12, %xmm2 + movaps %xmm5, %xmm14 + movaps %xmm8, %xmm10 + mulsd %xmm2, %xmm14 + movaps %xmm12, %xmm8 + movaps %xmm14, %xmm13 + movsd 16(%rsp), %xmm15 + addsd %xmm2, %xmm13 + movsd %xmm13, 64(%rsp) + movsd 64(%rsp), %xmm12 + subsd %xmm14, %xmm12 + ucomisd %xmm12, %xmm15 + jne ..B1.37 + jp ..B1.37 + jmp ..B1.55 +..B1.38: + pxor %xmm0, %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.39: + lea _zeros(%rip), %rax + movss (%rax,%r15,4), %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.40: + movss (%rsp), %xmm0 + call j0f@PLT +..B1.61: + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.41: + ja ..B1.43 +..B1.42: + lea _zeros(%rip), %rax + xorl %r14d, %r15d + shrl $31, %r15d + andl %r14d, %r15d + movss (%rax,%r15,4), %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.43: + movss (%rsp), %xmm0 +..B1.44: + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 14, -16 + .cfi_offset 15, -24 +..B1.46: + subsd %xmm2, %xmm12 + subsd %xmm15, %xmm13 + jmp ..B1.27 +..B1.47: + lea _val_17_0(%rip), %rcx + movsd (%rcx), %xmm2 + comisd %xmm1, %xmm2 + jbe ..B1.49 +..B1.48: + movaps %xmm1, %xmm0 + movsd %xmm1, 48(%rsp) + call j0@PLT +..B1.63: + movsd 48(%rsp), %xmm1 + movaps %xmm0, %xmm2 + movaps %xmm1, %xmm0 + movsd %xmm2, (%rsp) + call j1@PLT +..B1.62: + movsd 48(%rsp), %xmm1 + movsd (%rsp), %xmm2 + jmp ..B1.51 +..B1.49: + movsd .L_2il0floatpacket.2(%rip), %xmm2 + lea _val_16_0(%rip), %rcx + divsd %xmm1, %xmm2 + movsd (%rcx), %xmm8 + movaps %xmm1, %xmm0 + mulsd %xmm2, %xmm8 + lea (%rsp), %rdi + movaps %xmm8, %xmm6 + lea 8(%rsp), %rsi + mulsd %xmm8, %xmm6 + movl $-1, %edx + movaps %xmm6, %xmm7 + mulsd %xmm6, %xmm7 + movq $0, 48(%rsi) + movsd %xmm2, 8(%rsi) + movsd %xmm6, 16(%rsi) + movsd %xmm7, 24(%rsi) + movsd %xmm8, 32(%rsi) + movsd %xmm1, 40(%rsi) +..___tag_value_jnf.59: + call __libm_sincos_k32@PLT +..___tag_value_jnf.60: +..B1.50: + lea 40+_PP1(%rip), %r11 + lea 40+_PP0(%rip), %rcx + movsd 32(%rsp), %xmm7 + lea 24+_PP0(%rip), %rsi + lea 8+_PP0(%rip), %rdi + lea 32+_PP0(%rip), %r8 + movsd 24(%rsp), %xmm6 + lea 16+_PP0(%rip), %r9 + movsd (%r11), %xmm10 + lea _PP0(%rip), %r10 + movsd (%rcx), %xmm2 + lea 24+_PP1(%rip), %rcx + movsd (%r8), %xmm3 + movsd 40(%rsp), %xmm8 + mulsd %xmm7, %xmm10 + mulsd %xmm7, %xmm2 + mulsd %xmm7, %xmm3 + addsd (%rcx), %xmm10 + addsd (%rsi), %xmm2 + addsd (%r9), %xmm3 + mulsd %xmm7, %xmm10 + mulsd %xmm7, %xmm2 + mulsd %xmm7, %xmm3 + addsd (%rdi), %xmm2 + addsd (%r10), %xmm3 + mulsd %xmm6, %xmm2 + lea 8+_PP1(%rip), %rcx + addsd %xmm3, %xmm2 + addsd (%rcx), %xmm10 + lea 32+_PP1(%rip), %rcx + mulsd %xmm6, %xmm10 + movsd (%rcx), %xmm4 + lea 16+_PP1(%rip), %rcx + mulsd %xmm7, %xmm4 + movsd 48(%rsp), %xmm1 + addsd (%rcx), %xmm4 + lea _PP1(%rip), %rcx + mulsd %xmm7, %xmm4 + addsd (%rcx), %xmm4 + lea 40+_QP0(%rip), %rcx + movsd (%rcx), %xmm9 + lea 24+_QP0(%rip), %rcx + mulsd %xmm7, %xmm9 + addsd %xmm4, %xmm10 + addsd (%rcx), %xmm9 + lea 8+_QP0(%rip), %rcx + mulsd %xmm7, %xmm9 + addsd (%rcx), %xmm9 + lea 32+_QP0(%rip), %rcx + movsd (%rcx), %xmm5 + lea 16+_QP0(%rip), %rcx + mulsd %xmm7, %xmm5 + mulsd %xmm6, %xmm9 + addsd (%rcx), %xmm5 + mulsd %xmm8, %xmm9 + mulsd %xmm7, %xmm5 + lea _QP0(%rip), %rcx + addsd (%rcx), %xmm5 + lea 40+_QP1(%rip), %rcx + movsd (%rcx), %xmm11 + lea 24+_QP1(%rip), %rcx + mulsd %xmm7, %xmm11 + mulsd %xmm8, %xmm5 + addsd (%rcx), %xmm11 + addsd %xmm5, %xmm9 + mulsd %xmm7, %xmm11 + lea 8+_QP1(%rip), %rcx + addsd (%rcx), %xmm11 + lea 32+_QP1(%rip), %rcx + mulsd %xmm6, %xmm11 + movsd (%rcx), %xmm6 + lea 16+_QP1(%rip), %rcx + mulsd %xmm7, %xmm6 + mulsd %xmm8, %xmm11 + addsd (%rcx), %xmm6 + mulsd %xmm7, %xmm6 + lea _QP1(%rip), %rcx + movsd 8(%rsp), %xmm7 + mulsd %xmm7, %xmm2 + addsd (%rcx), %xmm6 + lea _tonpi(%rip), %rcx + mulsd %xmm8, %xmm6 + movsd (%rcx), %xmm0 + addsd %xmm6, %xmm11 + mulsd 16(%rsp), %xmm0 + mulsd %xmm11, %xmm7 + sqrtsd %xmm0, %xmm0 + movsd (%rsp), %xmm8 + mulsd %xmm8, %xmm9 + mulsd %xmm10, %xmm8 + subsd %xmm9, %xmm2 + addsd %xmm7, %xmm8 + mulsd %xmm0, %xmm2 + mulsd %xmm8, %xmm0 +..B1.51: + lea _val_2_0(%rip), %rcx + cmpl $1, %r14d + movsd (%rcx), %xmm3 + movl $0, %ecx + divsd %xmm1, %xmm3 + jle ..B1.34 +..B1.52: + decl %r14d +..B1.53: + incl %ecx + pxor %xmm1, %xmm1 + cvtsi2sd %ecx, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm0, %xmm4 + mulsd %xmm0, %xmm1 + cmpl %r14d, %ecx + movaps %xmm1, %xmm0 + subsd %xmm2, %xmm0 + movaps %xmm4, %xmm2 + jb ..B1.53 + jmp ..B1.34 +..B1.55: + movaps %xmm3, %xmm6 + lea -2(%r14,%r14), %ecx + divsd %xmm2, %xmm6 + pxor %xmm5, %xmm5 + movaps %xmm3, %xmm2 + cvtsi2sd %ecx, %xmm5 + divsd %xmm1, %xmm2 + xorl %ecx, %ecx + decl %r14d +..B1.56: + movaps %xmm6, %xmm7 + incl %ecx + mulsd %xmm5, %xmm7 + subsd %xmm4, %xmm5 + mulsd %xmm1, %xmm3 + cmpl %r14d, %ecx + subsd %xmm3, %xmm7 + mulsd %xmm2, %xmm7 + movaps %xmm6, %xmm3 + movaps %xmm7, %xmm6 + jl ..B1.56 +..B1.57: + movaps %xmm1, %xmm0 + movsd %xmm7, (%rsp) + call j0@PLT +..B1.64: + divsd (%rsp), %xmm0 + jmp ..B1.34 +..B1.58: + call j1f@PLT +..B1.65: + movaps %xmm0, %xmm1 + testl %r15d, %r15d + xorps .L_2il0floatpacket.5(%rip), %xmm1 + je ..L61 + movaps %xmm1, %xmm0 +..L61: + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type jnf,@function + .size jnf,.-jnf + .data +# -- End jnf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x7fffffff,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.3: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .long 0x80000000,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x450ea000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +function_zeros: + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x3f000000 + .long 0x3fcccccd + .long 0x40600000 + .long 0x40c33333 + .long 0x4111999a + .long 0x414b3333 + .long 0x4184cccd + .long 0x41a66666 + .long 0x41ca6666 + .long 0x41f0cccd + .long 0x420c0000 + .long 0x42206666 + .long 0x4235999a + .long 0x424b3333 + .long 0x42613333 + .long 0x42780000 + .long 0x42876666 + .long 0x42930000 + .long 0x429ecccd + .long 0x42aacccd + .long 0x42b6cccd + .long 0x42c30000 + .long 0x42cf6666 + .long 0x42dbcccd + .long 0x42e86666 + .long 0x42f50000 + .long 0x4300e666 + .long 0x43074ccd + .long 0x430db333 + .long 0x43143333 + .long 0x431ab333 + .long 0x43214ccd + .long 0x4327e666 + .long 0x432e8000 + .long 0x4335199a + .long 0x433bcccd + .long 0x43428000 + .long 0x43493333 + .long 0x43500000 + .long 0x43560000 + .long 0x435d0000 + .long 0x43640000 + .long 0x436b0000 + .long 0x43720000 + .long 0x43780000 + .long 0x437f0000 + .long 0x43830000 + .long 0x43868000 + .long 0x438a0000 + .long 0x438d8000 + .long 0x43910000 + .long 0x43948000 + .long 0x43980000 + .long 0x439b8000 + .long 0x439f0000 + .long 0x43a28000 + .long 0x43a60000 + .long 0x43a98000 + .long 0x43ad0000 + .long 0x43b08000 + .long 0x43b40000 + .long 0x43b78000 + .long 0x43bb0000 + .long 0x43bf0000 + .long 0x43c28000 + .long 0x43c60000 + .long 0x43c98000 + .long 0x43cd0000 + .long 0x43d08000 + .long 0x43d40000 + .long 0x43d80000 + .long 0x43db8000 + .long 0x43df0000 + .long 0x43e28000 + .long 0x43e60000 + .long 0x43ea0000 + .long 0x43ed8000 + .long 0x43f10000 + .long 0x43f48000 + .long 0x43f88000 + .long 0x43fc0000 + .long 0x43ff8000 + .long 0x44018000 + .long 0x44038000 + .long 0x44054000 + .long 0x44070000 + .long 0x44090000 + .long 0x440ac000 + .long 0x440c8000 + .long 0x440e4000 + .long 0x44104000 + .long 0x44120000 + .long 0x4413c000 + .long 0x4415c000 + .long 0x44178000 + .long 0x44194000 + .long 0x441b4000 + .long 0x441d0000 + .long 0x441ec000 + .long 0x4420c000 + .long 0x44228000 + .long 0x44244000 + .long 0x44264000 + .long 0x44280000 + .long 0x442a0000 + .long 0x442bc000 + .long 0x442d8000 + .long 0x442f8000 + .long 0x44314000 + .long 0x44334000 + .long 0x44350000 + .long 0x4436c000 + .long 0x4438c000 + .long 0x443a8000 + .long 0x443c8000 + .long 0x443e4000 + .long 0x44400000 + .long 0x44420000 + .long 0x4443c000 + .long 0x4445c000 + .long 0x44478000 + .long 0x44498000 + .long 0x444b4000 + .long 0x444d0000 + .long 0x444f0000 + .long 0x4450c000 + .long 0x4452c000 + .long 0x44548000 + .long 0x44568000 + .long 0x44584000 + .long 0x445a4000 + .long 0x445c0000 + .long 0x445e0000 + .long 0x445fc000 + .long 0x4461c000 + .long 0x44638000 + .long 0x44658000 + .long 0x44674000 + .long 0x44694000 + .long 0x446b0000 + .long 0x446cc000 + .long 0x446ec000 + .long 0x44708000 + .long 0x44728000 + .long 0x44744000 + .long 0x44764000 + .long 0x44784000 + .long 0x447a0000 + .long 0x447c0000 + .long 0x447dc000 + .long 0x447fc000 + .long 0x4480c000 + .long 0x4481c000 + .long 0x4482a000 + .long 0x4483a000 + .long 0x44848000 + .long 0x44858000 + .long 0x44866000 + .long 0x44876000 + .long 0x44884000 + .long 0x44894000 + .long 0x448a2000 + .long 0x448b2000 + .long 0x448c0000 + .long 0x448d0000 + .long 0x448e0000 + .long 0x448ee000 + .long 0x448fe000 + .long 0x4490c000 + .long 0x4491c000 + .long 0x4492a000 + .long 0x4493a000 + .long 0x44948000 + .long 0x44958000 + .long 0x44968000 + .long 0x44976000 + .long 0x44986000 + .long 0x44994000 + .long 0x449a4000 + .long 0x449b2000 + .long 0x449c2000 + .long 0x449d2000 + .long 0x449e0000 + .long 0x449f0000 + .long 0x449fe000 + .long 0x44a0e000 + .long 0x44a1c000 + .long 0x44a2c000 + .long 0x44a3c000 + .long 0x44a4a000 + .long 0x44a5a000 + .long 0x44a68000 + .long 0x44a78000 + .long 0x44a88000 + .long 0x44a96000 + .long 0x44aa6000 + .long 0x44ab4000 + .long 0x44ac4000 + .long 0x44ad4000 + .long 0x44ae2000 + .long 0x44af2000 + .long 0x44b00000 + .long 0x44b10000 + .long 0x44b20000 + .long 0x44b2e000 + .long 0x44b3e000 + .long 0x44b4c000 + .long 0x44b5c000 + .long 0x44b6c000 + .long 0x44b7a000 + .long 0x44b8a000 + .long 0x44b9a000 + .long 0x44ba8000 + .long 0x44bb8000 + .long 0x44bc6000 + .long 0x44bd6000 + .long 0x44be6000 + .long 0x44bf4000 + .long 0x44c04000 + .long 0x44c14000 + .long 0x44c22000 + .long 0x44c32000 + .long 0x44c40000 + .long 0x44c50000 + .long 0x44c60000 + .long 0x44c6e000 + .long 0x44c7e000 + .long 0x44c8e000 + .long 0x44c9c000 + .long 0x44cac000 + .long 0x44cba000 + .long 0x44cca000 + .long 0x44cda000 + .long 0x44ce8000 + .long 0x44cf8000 + .long 0x44d08000 + .long 0x44d16000 + .long 0x44d26000 + .long 0x44d36000 + .long 0x44d44000 + .long 0x44d54000 + .long 0x44d64000 + .long 0x44d72000 + .long 0x44d82000 + .long 0x44d92000 + .long 0x44da0000 + .long 0x44db0000 + .long 0x44dc0000 + .long 0x44dce000 + .long 0x44dde000 + .long 0x44dec000 + .long 0x44dfc000 + .long 0x44e0c000 + .long 0x44e1a000 + .long 0x44e2a000 + .long 0x44e3a000 + .long 0x44e48000 + .long 0x44e58000 + .long 0x44e68000 + .long 0x44e76000 + .long 0x44e86000 + .long 0x44e96000 + .long 0x44ea4000 + .long 0x44eb4000 + .long 0x44ec4000 + .long 0x44ed4000 + .long 0x44ee2000 + .long 0x44ef2000 + .long 0x44f02000 + .long 0x44f10000 + .long 0x44f20000 + .long 0x44f30000 + .long 0x44f3e000 + .long 0x44f4e000 + .long 0x44f5e000 + .long 0x44f6c000 + .long 0x44f7c000 + .long 0x44f8c000 + .long 0x44f9a000 + .long 0x44faa000 + .long 0x44fba000 + .long 0x44fc8000 + .long 0x44fd8000 + .long 0x44fe8000 + .long 0x44ff6000 + .long 0x45003000 + .long 0x4500b000 + .long 0x45013000 + .long 0x4501a000 + .long 0x45022000 + .long 0x4502a000 + .long 0x45031000 + .long 0x45039000 + .long 0x45041000 + .long 0x45048000 + .long 0x45050000 + .long 0x45058000 + .long 0x4505f000 + .long 0x45067000 + .long 0x4506f000 + .long 0x45077000 + .long 0x4507e000 + .long 0x45086000 + .long 0x4508e000 + .long 0x45095000 + .long 0x4509d000 + .long 0x450a5000 + .long 0x450ac000 + .long 0x450b4000 + .long 0x450bc000 + .long 0x450c4000 + .long 0x450cb000 + .long 0x450d3000 + .long 0x450db000 + .long 0x450e2000 + .long 0x450ea000 + .type function_zeros,@object + .size function_zeros,1284 + .align 4 +_val_0_6: + .long 858993459 + .long 1071854387 + .type _val_0_6,@object + .size _val_0_6,8 + .align 4 +_val_2_0: + .long 0 + .long 1073741824 + .type _val_2_0,@object + .size _val_2_0,8 + .align 4 +_TWO_19H: + .long 0 + .long 1093140480 + .type _TWO_19H,@object + .size _TWO_19H,8 + .align 4 +_val_4_0: + .long 0 + .long 1074790400 + .type _val_4_0,@object + .size _val_4_0,8 + .align 4 +_val_8_0: + .long 0 + .long 1075838976 + .type _val_8_0,@object + .size _val_8_0,8 + .align 4 +_val_3_0: + .long 0 + .long 1074266112 + .type _val_3_0,@object + .size _val_3_0,8 + .align 4 +_val_5_0: + .long 0 + .long 1075052544 + .type _val_5_0,@object + .size _val_5_0,8 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_val_17_0: + .long 0 + .long 1076953088 + .type _val_17_0,@object + .size _val_17_0,8 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_PP1: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP1,@object + .size _PP1,48 + .align 4 +_PP0: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP0,@object + .size _PP0,48 + .align 4 +_QP0: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP0,@object + .size _QP0,48 + .align 4 +_QP1: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP1,@object + .size _QP1,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/jnl.S b/external/sgx_libm/intel64/jnl.S new file mode 100644 index 0000000000..57e13b0eec --- /dev/null +++ b/external/sgx_libm/intel64/jnl.S @@ -0,0 +1,95 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "jnl.c" + .text +..TXTST0: +# -- Begin jnl + .text + .align 16,0x90 + .globl jnl +jnl: +# parameter 1: %edi +# parameter 2: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_jnl.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + movl %edi, %ebp + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 48 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B1.6: + addq $16, %rsp + .cfi_def_cfa_offset 32 + movl %ebp, %edi + movaps (%rsp), %xmm0 +..___tag_value_jnl.8: + call __jnq@PLT +..___tag_value_jnl.9: +..B1.2: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B1.7: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type jnl,@function + .size jnl,.-jnl + .data +# -- End jnl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/l2q.S b/external/sgx_libm/intel64/l2q.S new file mode 100644 index 0000000000..a238bae0f1 --- /dev/null +++ b/external/sgx_libm/intel64/l2q.S @@ -0,0 +1,106 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "l2q.c" + .text +..TXTST0: +# -- Begin __ltoq + .text + .align 16,0x90 + .globl __ltoq +__ltoq: +# parameter 1: %rdi +# parameter 2: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value___ltoq.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + fnstcw 16(%rsp) +..B1.3: + movzwl 16(%rsp), %eax + orl $-64768, %eax + movw %ax, 18(%rsp) +..B1.4: + fldcw 18(%rsp) +..B1.5: + fldt 32(%rsp) + lea __l_one(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.6: + fldcw 16(%rsp) +..B1.7: + movq (%rsp), %rsi + movq %rsi, %rax + shrq $15, %rsi + movq $0xffffffffffff, %rdx + movl 8(%rsp), %ecx + andq %rdx, %rsi + shlq $48, %rcx + shlq $49, %rax + orq %rcx, %rsi + movq %rax, (%rdi) + movq %rsi, 8(%rdi) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __ltoq,@function + .size __ltoq,.-__ltoq + .data +# -- End __ltoq + .section .rodata, "a" + .align 4 + .align 4 +__l_one: + .long 0 + .long 2147483648 + .long 16383 + .type __l_one,@object + .size __l_one,12 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ldexp_gen.S b/external/sgx_libm/intel64/ldexp_gen.S new file mode 100644 index 0000000000..2be804be25 --- /dev/null +++ b/external/sgx_libm/intel64/ldexp_gen.S @@ -0,0 +1,194 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ldexp_gen.c" + .text +..TXTST0: +# -- Begin ldexp + .text + .align 16,0x90 + .globl ldexp +ldexp: +# parameter 1: %xmm0 +# parameter 2: %edi +..B1.1: + .cfi_startproc +..___tag_value_ldexp.1: +..L2: + + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %esi + movl %esi, %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + je ..B1.17 +..B1.2: + xorb %r8b, %r8b + testl %ecx, %ecx + jne ..B1.7 +..B1.3: + testl $1048575, -4(%rsp) + jne ..B1.6 +..B1.4: + cmpl $0, -8(%rsp) + jne ..B1.6 +..B1.5: + movsd -8(%rsp), %xmm0 + ret +..B1.6: + lea _TWO_55(%rip), %rax + movb $1, %r8b + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %esi + movl %esi, %ecx + andl $32752, %ecx + shrl $4, %ecx + addl $-55, %ecx +..B1.7: + movl $65536, %eax + cmpl $65536, %edi + cmovg %eax, %edi + movl $-65536, %edx + cmpl $-65536, %edi + cmovle %edx, %edi + lea (%rcx,%rdi), %eax + testl %eax, %eax + jle ..B1.12 +..B1.8: + cmpl $2047, %eax + jge ..B1.11 +..B1.9: + andl $2047, %eax + andl $-32753, %esi + shll $4, %eax + orl %eax, %esi + movw %si, -2(%rsp) + movsd -8(%rsp), %xmm0 +..B1.10: + ret +..B1.11: + movb -1(%rsp), %al + lea _large_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.12: + cmpl $-52, %eax + jl ..B1.16 +..B1.13: + lea 8+_TWO_55(%rip), %rdx + lea 55(%rcx,%rdi), %eax + andl $2047, %eax + andl $-32753, %esi + shll $4, %eax + orl %eax, %esi + movw %si, -2(%rsp) + testb %r8b, %r8b + movsd -8(%rsp), %xmm0 + mulsd (%rdx), %xmm0 + je ..B1.15 +..B1.14: + testl %edi, %edi + jl ..B1.10 +..B1.15: + ret +..B1.16: + movb -1(%rsp), %al + lea _small_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.17: + lea _ones(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type ldexp,@function + .size ldexp,.-ldexp + .data +# -- End ldexp + .section .rodata, "a" + .align 4 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .type _TWO_55,@object + .size _TWO_55,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ldexpf.S b/external/sgx_libm/intel64/ldexpf.S new file mode 100644 index 0000000000..cc0d200317 --- /dev/null +++ b/external/sgx_libm/intel64/ldexpf.S @@ -0,0 +1,185 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ldexpf.c" + .text +..TXTST0: +# -- Begin ldexpf + .text + .align 16,0x90 + .globl ldexpf +ldexpf: +# parameter 1: %xmm0 +# parameter 2: %edi +..B1.1: + .cfi_startproc +..___tag_value_ldexpf.1: +..L2: + + movl %edi, %r8d + movss %xmm0, -8(%rsp) + movzwl -6(%rsp), %eax + movl %eax, %esi + andl $32640, %esi + shrl $7, %esi + cmpl $255, %esi + je ..B1.9 +..B1.2: + xorb %dil, %dil + testl %esi, %esi + jne ..B1.5 +..B1.3: + testl $8388607, -8(%rsp) + je ..B1.9 +..B1.4: + movss -8(%rsp), %xmm0 + movb $1, %dil + mulss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, -8(%rsp) + movzwl -6(%rsp), %eax + movl %eax, %esi + andl $32640, %esi + shrl $7, %esi + addl $-25, %esi +..B1.5: + movl $65536, %edx + cmpl $65536, %r8d + cmovg %edx, %r8d + movl $-65536, %ecx + cmpl $-65536, %r8d + cmovle %ecx, %r8d + lea (%rsi,%r8), %edx + testl %edx, %edx + jle ..B1.11 +..B1.6: + cmpl $255, %edx + jge ..B1.10 +..B1.7: + movzbl %dl, %edx + andl $-32641, %eax + shll $7, %edx + orl %edx, %eax + movw %ax, -6(%rsp) + movss -8(%rsp), %xmm0 +..B1.8: + ret +..B1.9: + movss -8(%rsp), %xmm0 + ret +..B1.10: + movb -5(%rsp), %al + lea _large_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + ret +..B1.11: + cmpl $-23, %edx + jl ..B1.15 +..B1.12: + andl $-32641, %eax + lea 25(%rsi,%r8), %edx + movzbl %dl, %edx + shll $7, %edx + orl %edx, %eax + movw %ax, -6(%rsp) + testb %dil, %dil + movss -8(%rsp), %xmm0 + mulss .L_2il0floatpacket.3(%rip), %xmm0 + je ..B1.14 +..B1.13: + testl %r8d, %r8d + jl ..B1.8 +..B1.14: + ret +..B1.15: + movb -5(%rsp), %al + lea _small_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.2(%rip), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type ldexpf,@function + .size ldexpf,.-ldexpf + .data +# -- End ldexpf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x0d800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x33000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ldexpl.S b/external/sgx_libm/intel64/ldexpl.S new file mode 100644 index 0000000000..60cbda83a4 --- /dev/null +++ b/external/sgx_libm/intel64/ldexpl.S @@ -0,0 +1,321 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ldexpl.c" + .text +..TXTST0: +# -- Begin ldexpl + .text + .align 16,0x90 + .globl ldexpl +ldexpl: +# parameter 1: 32 + %rsp +# parameter 2: %edi +..B1.1: + .cfi_startproc +..___tag_value_ldexpl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 40(%rsp), %r8d + movl %r8d, %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.39 +..B1.4: + testl %esi, %esi + jne ..B1.12 +..B1.5: + cmpq $0, 32(%rsp) + je ..B1.15 +..B1.6: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.7: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.8: + fldcw 16(%rsp) +..B1.9: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) +..B1.10: + fldcw 18(%rsp) +..B1.11: + movzwl 40(%rsp), %r8d + movl %r8d, %esi + andl $32767, %esi + addl $-75, %esi +..B1.12: + movl $65536, %edx + cmpl $65536, %edi + cmovg %edx, %edi + movl $-65536, %ecx + xorb %al, %al + cmpl $-65536, %edi + cmovle %ecx, %edi + lea (%rsi,%rdi), %edx + testl %edx, %edx + jle ..B1.23 +..B1.13: + cmpl $32767, %edx + jge ..B1.16 +..B1.14: + andl $-32768, %r8d + andl $32767, %edx + orl %edx, %r8d + movw %r8w, 40(%rsp) + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.15: + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.16: + movzwl 18(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.17: + orl $-64768, %ecx + movw %cx, 16(%rsp) +..B1.18: + fldcw 16(%rsp) +..B1.19: + movb $1, %al +..B1.20: + movb 41(%rsp), %dl + lea _large_value_80(%rip), %rsi + andb $-128, %dl + shrb $7, %dl + fldt (%rsi) + movzbl %dl, %ecx + shlq $4, %rcx + testb %al, %al + fldt (%rsi,%rcx) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.22 +..B1.21: + fldcw 18(%rsp) +..B1.22: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.23: + cmpl $-63, %edx + jl ..B1.31 +..B1.24: + andl $-32768, %r8d + lea 75(%rsi,%rdi), %eax + andl $32767, %eax + orl %eax, %r8d + movzwl 18(%rsp), %eax + movl %eax, %edx + andl $768, %edx + movw %r8w, 40(%rsp) + cmpl $768, %edx + je ..B1.30 +..B1.25: + orl $-64768, %eax + movw %ax, 16(%rsp) +..B1.26: + fldcw 16(%rsp) +..B1.27: + fldt 32(%rsp) + lea 8+_TWO_75(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.28: + fldcw 18(%rsp) +..B1.29: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.30: + fldt 32(%rsp) + lea 8+_TWO_75(%rip), %rax + fmull (%rax) + fstpt (%rsp) + jmp ..B1.29 +..B1.31: + movzwl 18(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.35 +..B1.32: + orl $-64768, %ecx + movw %cx, 16(%rsp) +..B1.33: + fldcw 16(%rsp) +..B1.34: + movb $1, %al +..B1.35: + movb 41(%rsp), %dl + lea _small_value_80(%rip), %rsi + andb $-128, %dl + shrb $7, %dl + fldt (%rsi) + movzbl %dl, %ecx + shlq $4, %rcx + testb %al, %al + fldt (%rsi,%rcx) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.37 +..B1.36: + fldcw 18(%rsp) +..B1.37: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.38: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) + jmp ..B1.11 +..B1.39: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.40: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.41: + fldcw 16(%rsp) +..B1.42: + fldt 32(%rsp) + fstpt (%rsp) +..B1.43: + fldcw 18(%rsp) +..B1.44: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.45: + fldt 32(%rsp) + fstpt (%rsp) + jmp ..B1.44 + .align 16,0x90 + .cfi_endproc + .type ldexpl,@function + .size ldexpl,.-ldexpl + .data +# -- End ldexpl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lgamma.S b/external/sgx_libm/intel64/lgamma.S new file mode 100644 index 0000000000..8ab4cfddb1 --- /dev/null +++ b/external/sgx_libm/intel64/lgamma.S @@ -0,0 +1,7348 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lgamma.c" + .text +..TXTST0: +# -- Begin lgamma + .text + .align 16,0x90 + .globl lgamma +lgamma: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_lgamma.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + lea (%rsp), %rdi +..___tag_value_lgamma.4: + call __libm_lgamma +..___tag_value_lgamma.5: +..B1.2: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type lgamma,@function + .size lgamma,.-lgamma + .data +# -- End lgamma + .text +# -- Begin __libm_lgamma + .text + .align 16,0x90 +__libm_lgamma: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B2.1: + .cfi_startproc +..___tag_value___libm_lgamma.8: +..L9: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $152, %rsp + .cfi_def_cfa_offset 208 + xorb %r12b, %r12b + movsd %xmm0, 32(%rsp) + movq %rdi, %r15 + movb 39(%rsp), %cl + xorb %bpl, %bpl + andb $-128, %cl + shrb $7, %cl + movzwl 38(%rsp), %r14d + andl $32752, %r14d + shrl $4, %r14d + movl %r14d, %r13d + movl 36(%rsp), %edx + shll $20, %r13d + andl $1048575, %edx + movq %fs:40, %rax + orl %edx, %r13d + xorq %rsp, %rax + movq %rax, 144(%rsp) + movb %cl, (%rsp) +..B2.2: + fnstcw 138(%rsp) +..B2.3: +..___tag_value___libm_lgamma.23: + call fegetround@PLT +..___tag_value___libm_lgamma.24: +..B2.205: + movl %eax, %ebx +..B2.4: + testl %ebx, %ebx + je ..B2.6 +..B2.5: + xorl %edi, %edi + movb $1, %r12b +..___tag_value___libm_lgamma.25: + call fesetround@PLT +..___tag_value___libm_lgamma.26: +..B2.6: + movzwl 138(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.10 +..B2.7: + orl $-64768, %edx + movw %dx, 136(%rsp) +..B2.8: + fldcw 136(%rsp) +..B2.9: + movb $1, %bpl +..B2.10: + cmpl $2047, %r14d + jne ..B2.17 +..B2.11: + movl $1, (%r15) + testb %bpl, %bpl + je ..B2.13 +..B2.12: + fldcw 138(%rsp) +..B2.13: + testb %r12b, %r12b + je ..B2.15 +..B2.14: + movl %ebx, %edi +..___tag_value___libm_lgamma.27: + call fesetround@PLT +..___tag_value___libm_lgamma.28: +..B2.15: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 32(%rsp), %xmm0 + mulsd %xmm0, %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.16: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.17: + testl %r14d, %r14d + jne ..B2.22 +..B2.18: + testl $1048575, 36(%rsp) + jne ..B2.22 +..B2.19: + cmpl $0, 32(%rsp) + je ..B2.98 +..B2.22: + movl $1, (%r15) +..B2.23: + movb (%rsp), %al + testb %al, %al + je ..B2.124 +..B2.24: + movsd 32(%rsp), %xmm0 + call nearbyint@PLT +..B2.206: + movsd %xmm0, 128(%rsp) + movsd 128(%rsp), %xmm1 + movsd 32(%rsp), %xmm0 + ucomisd %xmm1, %xmm0 + jp ..B2.25 + je ..B2.117 +..B2.25: + comisd .L_2il0floatpacket.0(%rip), %xmm0 + jbe ..B2.29 +..B2.26: + call ceil@PLT +..B2.207: + movsd %xmm0, 128(%rsp) + movsd 128(%rsp), %xmm1 + addsd .L_2il0floatpacket.0(%rip), %xmm1 + movsd %xmm1, 128(%rsp) + testb $1, 128(%rsp) + jne ..B2.28 +..B2.27: + movl $-1, (%r15) + movsd 32(%rsp), %xmm0 + jmp ..B2.29 +..B2.28: + movsd 32(%rsp), %xmm0 +..B2.29: + cmpl $1073741824, %r13d + jae ..B2.41 +..B2.30: + fldt .L_2il0floatpacket.1(%rip) + movsd %xmm0, 88(%rsp) + fld %st(0) + fldl 88(%rsp) + fcomi %st(2), %st + jae ..B2.109 + jp ..B2.109 +..B2.32: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B2.33 + jb ..B2.32 +..B2.33: + fstp %st(2) + fstpt 96(%rsp) +..B2.34: + andb $127, 105(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fldt 112(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) + call logl@PLT +..B2.209: + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fxch %st(1) + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value___libm_lgamma.52: + call lgamma_pos +..___tag_value___libm_lgamma.53: +..B2.208: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + testb %r12b, %r12b + je ..B2.37 +..B2.35: + fstp %st(0) + movl %ebx, %edi + fstpt (%rsp) +..___tag_value___libm_lgamma.55: + call fesetround@PLT +..___tag_value___libm_lgamma.56: +..B2.36: + fldt (%rsp) + fldt 96(%rsp) +..B2.37: + testb %bpl, %bpl + fsubrp %st, %st(1) + fstpl 128(%rsp) + je ..B2.39 +..B2.38: + fldcw 138(%rsp) +..B2.39: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.40: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.41: + cmpl $1076756480, %r13d + jae ..B2.71 +..B2.42: + fldt .L_2il0floatpacket.4(%rip) + movaps %xmm0, %xmm5 + lea _TWO_52H(%rip), %rax + addsd .L_2il0floatpacket.3(%rip), %xmm0 + movsd %xmm0, 80(%rsp) + movsd 80(%rsp), %xmm0 + movsd (%rax), %xmm1 + subsd %xmm0, %xmm1 + movsd %xmm1, 128(%rsp) + movsd 128(%rsp), %xmm2 + movl 128(%rsp), %ecx + subsd (%rax), %xmm2 + lea _LRIB(%rip), %rax + movsd %xmm2, 128(%rsp) + lea 1(%rcx), %edx + movsd 128(%rsp), %xmm3 + movsd %xmm3, 88(%rsp) + fldl 88(%rsp) + movsd 80(%rsp), %xmm4 + movsd %xmm4, 88(%rsp) + fldl 88(%rsp) + faddp %st, %st(1) + fxch %st(1) + fcomip %st(1), %st + fstp %st(0) + cmova %edx, %ecx + lea (%rcx,%rcx,2), %edx + movslq %edx, %rsi + comisd (%rax,%rsi,8), %xmm5 + jbe ..B2.51 +..B2.43: + movsd 16(%rax,%rsi,8), %xmm0 + comisd %xmm5, %xmm0 + jbe ..B2.51 +..B2.44: + movsd %xmm5, 88(%rsp) + fldl 88(%rsp) + movslq %ecx, %rcx + fsubl 8(%rax,%rsi,8) + fld %st(0) + lea _LRP16(%rip), %rax + fmul %st(1), %st + lea _LRP(%rip), %rsi + fldl (%rax,%rcx,8) + shll $3, %edx + fmul %st(1), %st + testb %r12b, %r12b + movslq %edx, %rdx + fldt 64(%rsi,%rdx,8) + fldt 32(%rsi,%rdx,8) + fldt (%rsi,%rdx,8) + fldt 48(%rsi,%rdx,8) + fldt 16(%rsi,%rdx,8) + fxch %st(5) + faddl 152(%rsi,%rdx,8) + fmul %st(6), %st + faddl 136(%rsi,%rdx,8) + fmul %st(6), %st + faddl 120(%rsi,%rdx,8) + fmul %st(6), %st + faddl 104(%rsi,%rdx,8) + fmul %st(6), %st + faddl 88(%rsi,%rdx,8) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl 160(%rsi,%rdx,8) + fmul %st(4), %st + faddl 144(%rsi,%rdx,8) + fmul %st(4), %st + faddl 128(%rsi,%rdx,8) + fmul %st(4), %st + faddl 112(%rsi,%rdx,8) + fmul %st(4), %st + faddl 96(%rsi,%rdx,8) + fmul %st(4), %st + faddl 80(%rsi,%rdx,8) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + je ..B2.47 +..B2.45: + fstp %st(0) + movl %ebx, %edi +..___tag_value___libm_lgamma.77: + call fesetround@PLT +..___tag_value___libm_lgamma.78: +..B2.46: + fldt 96(%rsp) +..B2.47: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstpl 128(%rsp) + je ..B2.49 +..B2.48: + fldcw 138(%rsp) +..B2.49: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.50: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.51: + lea _RRIB(%rip), %rax + comisd (%rax,%rsi,8), %xmm5 + jbe ..B2.60 +..B2.52: + movsd 16(%rax,%rsi,8), %xmm0 + comisd %xmm5, %xmm0 + jbe ..B2.60 +..B2.53: + movsd %xmm5, 88(%rsp) + lea _RRP(%rip), %rdx + fldl 88(%rsp) + fsubl 8(%rax,%rsi,8) + fld %st(0) + lea (%rcx,%rcx,4), %eax + shll $2, %eax + movslq %eax, %rax + testb %r12b, %r12b + fmul %st(1), %st + fldl 72(%rdx,%rax,8) + fmul %st(1), %st + fldt 32(%rdx,%rax,8) + fldt (%rdx,%rax,8) + fldl 64(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 120(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 112(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 88(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 80(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 136(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 128(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 104(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 96(%rdx,%rax,8) + fmul %st(4), %st + fxch %st(3) + faddl 152(%rdx,%rax,8) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt 48(%rdx,%rax,8) + fldt 16(%rdx,%rax,8) + fxch %st(3) + faddl 144(%rdx,%rax,8) + fmul %st(4), %st + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B2.56 +..B2.54: + fstp %st(0) + movl %ebx, %edi +..___tag_value___libm_lgamma.99: + call fesetround@PLT +..___tag_value___libm_lgamma.100: +..B2.55: + fldt 96(%rsp) +..B2.56: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstpl 128(%rsp) + je ..B2.58 +..B2.57: + fldcw 138(%rsp) +..B2.58: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.59: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.60: + fldt .L_2il0floatpacket.1(%rip) + movsd %xmm5, 88(%rsp) + fld %st(0) + fldl 88(%rsp) + fstpt (%rsp) + fldt (%rsp) + fcomip %st(2), %st + jae ..B2.113 + jp ..B2.113 +..B2.61: + fldt (%rsp) +..B2.62: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B2.63 + jb ..B2.62 +..B2.63: + fstp %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 96(%rsp) +..B2.64: + andb $127, 105(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fldt 112(%rsp) + fstpt (%rsp) + call logl@PLT +..B2.211: + addq $16, %rsp + .cfi_def_cfa_offset 208 + fstpt 96(%rsp) + fldt 96(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fldt 16(%rsp) + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value___libm_lgamma.124: + call lgamma_pos +..___tag_value___libm_lgamma.125: +..B2.210: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + testb %r12b, %r12b + je ..B2.67 +..B2.65: + fstp %st(0) + movl %ebx, %edi + fstpt (%rsp) +..___tag_value___libm_lgamma.127: + call fesetround@PLT +..___tag_value___libm_lgamma.128: +..B2.66: + fldt (%rsp) + fldt 96(%rsp) +..B2.67: + testb %bpl, %bpl + fsubrp %st, %st(1) + fstpl 128(%rsp) + je ..B2.69 +..B2.68: + fldcw 138(%rsp) +..B2.69: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.70: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.71: + cmpl $1076953088, %r13d + jae ..B2.82 +..B2.72: + fldt .L_2il0floatpacket.1(%rip) + movsd %xmm0, 88(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fldl 88(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(1), %st + fldt .L_2il0floatpacket.4(%rip) + fstpt 48(%rsp) + fldt 48(%rsp) + jae ..B2.223 + jp ..B2.223 +..B2.73: + fldt 16(%rsp) + fstp %st(1) +..B2.74: + fldt .L_2il0floatpacket.4(%rip) + fstp %st(0) + fld %st(0) + fxch %st(1) + fldt .L_2il0floatpacket.5(%rip) + fmul %st(1), %st + fadd %st, %st(2) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(2) + fld %st(0) + fsub %st(2), %st + fxch %st(1) + fadd %st(3), %st + fcomi %st(3), %st + fldt 32(%rsp) + fld %st(0) + fldt 48(%rsp) + fldt .L_2il0floatpacket.5(%rip) + fmul %st(3), %st + fadd %st, %st(2) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(3) + fmul %st(1), %st + fld %st(5) + fmul %st(3), %st + fxch %st(2) + fmulp %st, %st(6) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fsubp %st, %st(2) + fxch %st(2) + fsubp %st, %st(1) + fstpt 48(%rsp) + jp ..B2.75 + jb ..B2.74 +..B2.75: + fstp %st(1) + fstpt 16(%rsp) +..B2.76: + andb $127, 41(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fldt 48(%rsp) + fstpt (%rsp) + call logl@PLT +..B2.213: + fstpt 16(%rsp) + fldt 32(%rsp) + fstpt (%rsp) +..___tag_value___libm_lgamma.150: + call lgamma_pos +..___tag_value___libm_lgamma.151: +..B2.212: + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + testb %r12b, %r12b + je ..B2.78 +..B2.77: + movl %ebx, %edi +..___tag_value___libm_lgamma.153: + call fesetround@PLT +..___tag_value___libm_lgamma.154: +..B2.78: + fldt (%rsp) + testb %bpl, %bpl + fldt 16(%rsp) + fsubp %st, %st(1) + fstpl 128(%rsp) + je ..B2.80 +..B2.79: + fldcw 138(%rsp) +..B2.80: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.81: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.82: + movsd %xmm0, 88(%rsp) + cmpl $1082130432, %r13d + fldl 88(%rsp) + jb ..B2.90 +..B2.83: + fldt .L_2il0floatpacket.2(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + fsubr %st(1), %st + fld %st(1) + fchs + fldt (%rax) + fstpt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + fldt (%rsp) + fstpt 32(%rsp) + fstpt 48(%rsp) + fstpt 64(%rsp) + call logl@PLT +..B2.214: + fldt 64(%rsp) + lea _TWO_52H(%rip), %rsi + fldt 48(%rsp) + lea _S26(%rip), %r8 + fmulp %st, %st(2) + lea _S22(%rip), %r9 + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + fldt (%rsp) + lea _S18(%rip), %r10 + movq (%rsi), %rcx + lea _S14(%rip), %r11 + movq %rcx, 128(%rsp) + lea _S10(%rip), %r13 + movsd 128(%rsp), %xmm0 + lea _W4(%rip), %rax + movsd %xmm0, 88(%rsp) + lea _W2(%rip), %rdx + lea _S06(%rip), %r14 + lea _S02(%rip), %r15 + testb %r12b, %r12b + fsubrp %st, %st(3) + fxch %st(1) + fsubr %st, %st(2) + fldt .L_2il0floatpacket.1(%rip) + fdiv %st(1), %st + fld %st(0) + fmul %st(1), %st + fmull (%rax) + lea _S28(%rip), %rax + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(3) + fldl 88(%rsp) + fsubp %st, %st(1) + fstpl 128(%rsp) + fldl (%r8) + fldt (%r13) + fldt (%r14) + fldt (%r15) + movsd 128(%rsp), %xmm1 + subsd (%rsi), %xmm1 + movsd %xmm1, 128(%rsp) + movsd 128(%rsp), %xmm2 + movsd %xmm2, 88(%rsp) + fxch %st(4) + fsubl 88(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(4) + faddl (%r9) + fmul %st(4), %st + faddl (%r10) + fmul %st(4), %st + faddl (%r11) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(3) + fmulp %st, %st(2) + fldl (%rax) + lea _S24(%rip), %rax + fmul %st(1), %st + faddl (%rax) + lea _S20(%rip), %rax + fmul %st(1), %st + faddl (%rax) + lea _S16(%rip), %rax + fmul %st(1), %st + faddl (%rax) + lea _S12(%rip), %rax + fmul %st(1), %st + fldt (%rax) + lea _S08(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + lea _S04(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + je ..B2.86 +..B2.84: + fstp %st(0) + movl %ebx, %edi + fstpt 32(%rsp) +..___tag_value___libm_lgamma.177: + call fesetround@PLT +..___tag_value___libm_lgamma.178: +..B2.85: + fldt 32(%rsp) + fldt 96(%rsp) +..B2.86: + andb $127, 73(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fldt 80(%rsp) + fstpt (%rsp) + fsubrp %st, %st(1) + fstpt 48(%rsp) + call logl@PLT +..B2.215: + fldt 48(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + testb %bpl, %bpl + fsubp %st, %st(1) + fstpl 128(%rsp) + je ..B2.88 +..B2.87: + fldcw 138(%rsp) +..B2.88: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.89: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.90: + lea _TWO_52H(%rip), %rdx + movq (%rdx), %rax + movq %rax, 128(%rsp) + movsd 128(%rsp), %xmm0 + movsd %xmm0, 88(%rsp) + fldl 88(%rsp) + fsub %st(1), %st + fstpl 128(%rsp) + fchs + movsd 128(%rsp), %xmm1 + subsd (%rdx), %xmm1 + movsd %xmm1, 128(%rsp) + movsd 128(%rsp), %xmm2 + movsd %xmm2, 88(%rsp) + fldl 88(%rsp) + fsubr %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fstpt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + call logl@PLT +..B2.217: + fchs + movsd 48(%rsp), %xmm0 + xorps .L_2il0floatpacket.7(%rip), %xmm0 + movsd %xmm0, 104(%rsp) + fldl 104(%rsp) + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value___libm_lgamma.202: + call lgamma_pos +..___tag_value___libm_lgamma.203: +..B2.216: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + fldt (%rsp) + lea _S26(%rip), %rax + lea _S22(%rip), %rdx + lea _S18(%rip), %rcx + lea _S14(%rip), %rsi + lea _S10(%rip), %r8 + lea _S06(%rip), %r9 + lea _S02(%rip), %r10 + lea _S28(%rip), %r11 + lea _S24(%rip), %r13 + lea _S20(%rip), %r14 + lea _S16(%rip), %r15 + testb %r12b, %r12b + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fmul %st(2), %st + fldl (%rax) + lea _S12(%rip), %rax + fmul %st(1), %st + fldt (%r8) + fldt (%r9) + fldt (%r10) + fldt (%rax) + lea _S08(%rip), %rax + fxch %st(4) + faddl (%rdx) + fmul %st(5), %st + faddl (%rcx) + fmul %st(5), %st + faddl (%rsi) + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(4) + fldl (%r11) + fmul %st(2), %st + fldt (%rax) + lea _S04(%rip), %rax + fxch %st(1) + faddl (%r13) + fmul %st(3), %st + fldt (%rax) + fxch %st(1) + faddl (%r14) + fmul %st(4), %st + faddl (%r15) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + je ..B2.93 +..B2.91: + fstp %st(0) + movl %ebx, %edi + fstpt 16(%rsp) +..___tag_value___libm_lgamma.205: + call fesetround@PLT +..___tag_value___libm_lgamma.206: +..B2.92: + fldt 16(%rsp) + fldt 96(%rsp) +..B2.93: + andb $127, 73(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fldt 80(%rsp) + fstpt (%rsp) + fsubrp %st, %st(1) + fstpt 32(%rsp) + call logl@PLT +..B2.218: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + testb %bpl, %bpl + fsubp %st, %st(1) + fstpl 128(%rsp) + je ..B2.95 +..B2.94: + fldcw 138(%rsp) +..B2.95: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.96: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.97: + call __stack_chk_fail@PLT +..B2.98: + movb (%rsp), %al + testb %al, %al + je ..B2.100 +..B2.99: + movl $-1, (%r15) + jmp ..B2.101 +..B2.100: + movl $1, (%r15) +..B2.101: + testb %r12b, %r12b + je ..B2.103 +..B2.102: + movl %ebx, %edi +..___tag_value___libm_lgamma.229: + call fesetround@PLT +..___tag_value___libm_lgamma.230: +..B2.103: + movss .L_2il0floatpacket.8(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + cvtss2sd %xmm1, %xmm1 + movsd %xmm1, 128(%rsp) + je ..B2.105 +..B2.104: + fldcw 138(%rsp) +..B2.105: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 + jmp ..B2.16 +..B2.109: + fstp %st(1) + fxch %st(1) + fstpt 96(%rsp) + jmp ..B2.34 +..B2.113: + fstp %st(0) + fstpt 96(%rsp) + jmp ..B2.64 +..B2.117: + testb %r12b, %r12b + je ..B2.119 +..B2.118: + movl %ebx, %edi +..___tag_value___libm_lgamma.231: + call fesetround@PLT +..___tag_value___libm_lgamma.232: +..B2.119: + movss .L_2il0floatpacket.8(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + cvtss2sd %xmm1, %xmm1 + movsd %xmm1, 128(%rsp) + je ..B2.121 +..B2.120: + fldcw 138(%rsp) +..B2.121: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 + jmp ..B2.16 +..B2.124: + movzwl 38(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2037, %eax + jg ..B2.196 +..B2.125: + je ..B2.193 +..B2.126: + movsd 32(%rsp), %xmm0 + ucomisd .L_2il0floatpacket.9(%rip), %xmm0 + jp ..B2.127 + je ..B2.186 +..B2.127: + cmpl $1032, %r14d + jb ..B2.134 +..B2.128: + fldt .L_2il0floatpacket.2(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movsd %xmm0, 88(%rsp) + fldl 88(%rsp) + fstl 32(%rsp) + fsub %st, %st(1) + fxch %st(1) + fstpt (%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fstpt (%rsp) + fldt (%rax) + fstpt 32(%rsp) + call logl@PLT +..B2.219: + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 208 + fldt (%rsp) + lea _W4(%rip), %rax + fldl 32(%rsp) + lea _W2(%rip), %rdx + fxch %st(3) + fmulp %st, %st(1) + testb %r12b, %r12b + faddp %st, %st(1) + fsub %st(1), %st + fldt .L_2il0floatpacket.1(%rip) + fdivp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fmull (%rax) + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + je ..B2.130 +..B2.129: + movl %ebx, %edi + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_lgamma.235: + call fesetround@PLT +..___tag_value___libm_lgamma.236: +..B2.222: + fldt 16(%rsp) + fldt (%rsp) +..B2.130: + testb %bpl, %bpl + faddp %st, %st(1) + fstpl 128(%rsp) + je ..B2.132 +..B2.131: + fldcw 138(%rsp) +..B2.132: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.133: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.134: + cmpl $1025, %r14d + jb ..B2.141 +..B2.135: + lea _A(%rip), %rdx + lea -1025(%r14), %eax + movslq %eax, %rax + lea _B(%rip), %rcx + movsd %xmm0, 88(%rsp) + lea -3075(%r14,%r14,2), %r13d + fldl 88(%rsp) + lea _C5(%rip), %r14 + shll $3, %r13d + movslq %r13d, %r13 + fsubl (%rdx,%rax,8) + fmull (%rcx,%rax,8) + shlq $4, %r13 + fld %st(0) + fmul %st(1), %st + testb %r12b, %r12b + fldt 16(%r13,%r14) + fmul %st(2), %st + fadd %st(1), %st + fldt (%r13,%r14) + faddp %st, %st(1) + fldt 48(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 32(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 80(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 64(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 112(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 96(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 144(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 128(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 176(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 160(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 208(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 192(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 240(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 224(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 272(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 256(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 304(%r13,%r14) + fmul %st(3), %st + fadd %st(2), %st + fldt 288(%r13,%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 336(%r13,%r14) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 320(%r13,%r14) + faddp %st, %st(1) + fmul %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fstpt 96(%rsp) + je ..B2.137 +..B2.136: + movl %ebx, %edi +..___tag_value___libm_lgamma.257: + call fesetround@PLT +..___tag_value___libm_lgamma.258: +..B2.137: + fldt 352(%r13,%r14) + testb %bpl, %bpl + fldt (%rsp) + fmulp %st, %st(1) + fstpl 128(%rsp) + je ..B2.139 +..B2.138: + fldcw 138(%rsp) +..B2.139: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.140: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.141: + cmpl $1073872896, %r13d + jb ..B2.148 +..B2.142: + lea 48+_C4(%rip), %rcx + lea 16+_C4(%rip), %rax + movsd %xmm0, 88(%rsp) + lea 80+_C4(%rip), %r8 + fldl 88(%rsp) + lea 32+_C4(%rip), %rsi + fld %st(0) + lea 112+_C4(%rip), %r10 + fmul %st(1), %st + lea _C4(%rip), %rdx + lea 64+_C4(%rip), %r9 + lea 144+_C4(%rip), %r13 + lea 96+_C4(%rip), %r11 + lea 176+_C4(%rip), %r15 + lea 128+_C4(%rip), %r14 + testb %r12b, %r12b + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fldt (%rax) + lea 160+_C4(%rip), %rax + fmul %st(1), %st + fadd %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fldt (%rcx) + fmul %st(2), %st + fadd %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r8) + fmul %st(2), %st + fadd %st(3), %st + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r10) + fmul %st(2), %st + fadd %st(3), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r13) + fmul %st(2), %st + fadd %st(3), %st + fldt (%r14) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r15) + fmul %st(2), %st + fadd %st(3), %st + fldt (%rax) + lea 208+_C4(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rax) + lea 192+_C4(%rip), %rax + fmul %st(2), %st + fadd %st(3), %st + fldt (%rax) + lea 240+_C4(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rax) + lea 224+_C4(%rip), %rax + fmul %st(2), %st + fadd %st(3), %st + fldt (%rax) + lea 272+_C4(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rax) + lea 256+_C4(%rip), %rax + fmul %st(2), %st + fadd %st(3), %st + fldt (%rax) + lea 304+_C4(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rax) + lea 288+_C4(%rip), %rax + fmul %st(2), %st + fadd %st(3), %st + fldt (%rax) + lea 336+_C4(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rax) + lea 320+_C4(%rip), %rax + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt (%rax) + lea 352+_C4(%rip), %rax + faddp %st, %st(2) + fmul %st(1), %st + fxch %st(1) + fstpt 96(%rsp) + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B2.144 +..B2.143: + movl %ebx, %edi +..___tag_value___libm_lgamma.279: + call fesetround@PLT +..___tag_value___libm_lgamma.280: +..B2.144: + fldt .L_2il0floatpacket.6(%rip) + testb %bpl, %bpl + fldt 16(%rsp) + fsubp %st, %st(1) + fldt (%rsp) + fmulp %st, %st(1) + fstpl 128(%rsp) + je ..B2.146 +..B2.145: + fldcw 138(%rsp) +..B2.146: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.147: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.148: + cmpl $1073479680, %r13d + jb ..B2.156 +..B2.149: + fldt .L_2il0floatpacket.6(%rip) + lea 168+_C3(%rip), %rax + movsd %xmm0, 88(%rsp) + lea 152+_C3(%rip), %rdx + fldl 88(%rsp) + lea 136+_C3(%rip), %rcx + lea 120+_C3(%rip), %rsi + lea 104+_C3(%rip), %r8 + lea 88+_C3(%rip), %r9 + lea 64+_C3(%rip), %r10 + lea 160+_C3(%rip), %r14 + lea 144+_C3(%rip), %r15 + lea 32+_C3(%rip), %r11 + lea _C3(%rip), %r13 + testb %r12b, %r12b + fsubp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl (%rax) + lea 128+_C3(%rip), %rax + fmul %st(1), %st + fldt (%r10) + fldt (%r11) + fldt (%r13) + fxch %st(3) + faddl (%rdx) + fmul %st(4), %st + faddl (%rcx) + fmul %st(4), %st + faddl (%rsi) + fmul %st(4), %st + faddl (%r8) + fmul %st(4), %st + faddl (%r9) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl (%r14) + fmul %st(2), %st + faddl (%r15) + fmul %st(2), %st + faddl (%rax) + lea 112+_C3(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 96+_C3(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 80+_C3(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 48+_C3(%rip), %rax + fmul %st(2), %st + fldt (%rax) + lea 16+_C3(%rip), %rax + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + je ..B2.152 +..B2.150: + fstp %st(0) + movl %ebx, %edi +..___tag_value___libm_lgamma.301: + call fesetround@PLT +..___tag_value___libm_lgamma.302: +..B2.151: + fldt 96(%rsp) +..B2.152: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstpl 128(%rsp) + je ..B2.154 +..B2.153: + fldcw 138(%rsp) +..B2.154: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.155: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.156: + movsd %xmm0, 88(%rsp) + cmpl $1072955392, %r13d + fldl 88(%rsp) + jb ..B2.164 +..B2.157: + lea _LM(%rip), %rax + lea 184+_LGAMMA_C2(%rip), %rdx + lea 168+_LGAMMA_C2(%rip), %rcx + lea 152+_LGAMMA_C2(%rip), %rsi + lea 136+_LGAMMA_C2(%rip), %r8 + lea 120+_LGAMMA_C2(%rip), %r9 + lea 104+_LGAMMA_C2(%rip), %r10 + lea 80+_LGAMMA_C2(%rip), %r11 + fldt (%rax) + lea 176+_LGAMMA_C2(%rip), %r15 + lea 160+_LGAMMA_C2(%rip), %rax + lea 48+_LGAMMA_C2(%rip), %r13 + lea 16+_LGAMMA_C2(%rip), %r14 + testb %r12b, %r12b + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl (%rdx) + fmul %st(1), %st + fldt (%r11) + fldt (%r13) + fldt (%r14) + fxch %st(3) + faddl (%rcx) + fmul %st(4), %st + faddl (%rsi) + fmul %st(4), %st + faddl (%r8) + fmul %st(4), %st + faddl (%r9) + fmul %st(4), %st + faddl (%r10) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl (%r15) + fmul %st(2), %st + faddl (%rax) + lea 144+_LGAMMA_C2(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 128+_LGAMMA_C2(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 112+_LGAMMA_C2(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 96+_LGAMMA_C2(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 64+_LGAMMA_C2(%rip), %rax + fmul %st(2), %st + fldt (%rax) + lea 32+_LGAMMA_C2(%rip), %rax + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rax) + lea _LGAMMA_C2(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + je ..B2.160 +..B2.158: + fstp %st(0) + movl %ebx, %edi +..___tag_value___libm_lgamma.323: + call fesetround@PLT +..___tag_value___libm_lgamma.324: +..B2.159: + fldt 96(%rsp) +..B2.160: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstpl 128(%rsp) + je ..B2.162 +..B2.161: + fldcw 138(%rsp) +..B2.162: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.163: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.164: + cmpl $1072431104, %r13d + jb ..B2.172 +..B2.165: + fldt .L_2il0floatpacket.1(%rip) + lea 168+_C1(%rip), %rax + lea 152+_C1(%rip), %rdx + lea 136+_C1(%rip), %rcx + lea 120+_C1(%rip), %rsi + lea 160+_C1(%rip), %r14 + lea 144+_C1(%rip), %r15 + lea 104+_C1(%rip), %r8 + lea 88+_C1(%rip), %r9 + lea 64+_C1(%rip), %r10 + lea 32+_C1(%rip), %r11 + lea _C1(%rip), %r13 + testb %r12b, %r12b + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl (%rax) + lea 128+_C1(%rip), %rax + fmul %st(1), %st + fldt (%r10) + fldt (%r11) + fldt (%r13) + fldl (%r14) + fmul %st(5), %st + fxch %st(4) + faddl (%rdx) + fmul %st(5), %st + fxch %st(4) + faddl (%r15) + fmul %st(5), %st + fxch %st(4) + faddl (%rcx) + fmul %st(5), %st + fxch %st(4) + faddl (%rax) + fmul %st(5), %st + fxch %st(4) + faddl (%rsi) + fmul %st(5), %st + lea 112+_C1(%rip), %rax + fxch %st(4) + faddl (%rax) + fmul %st(5), %st + fxch %st(4) + faddl (%r8) + fmul %st(5), %st + lea 96+_C1(%rip), %rax + fxch %st(4) + faddl (%rax) + fmul %st(5), %st + fxch %st(4) + faddl (%r9) + fmul %st(5), %st + lea 80+_C1(%rip), %rax + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(2) + faddl (%rax) + lea 48+_C1(%rip), %rax + fmul %st(1), %st + fldt (%rax) + lea 16+_C1(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B2.168 +..B2.166: + fstp %st(0) + movl %ebx, %edi +..___tag_value___libm_lgamma.345: + call fesetround@PLT +..___tag_value___libm_lgamma.346: +..B2.167: + fldt 96(%rsp) +..B2.168: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstpl 128(%rsp) + je ..B2.170 +..B2.169: + fldcw 138(%rsp) +..B2.170: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.171: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.172: + fldt .L_2il0floatpacket.1(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 224 + fadd %st(1), %st + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value___libm_lgamma.368: + call lgamma_pos +..___tag_value___libm_lgamma.369: +..B2.221: + fldt 32(%rsp) + fxch %st(1) + fstpt 16(%rsp) + fstpt (%rsp) + call logl@PLT +..B2.220: + addq $16, %rsp + .cfi_def_cfa_offset 208 + fstpt 96(%rsp) + fldt 96(%rsp) + testb %r12b, %r12b + je ..B2.175 +..B2.173: + fstp %st(0) + movl %ebx, %edi +..___tag_value___libm_lgamma.371: + call fesetround@PLT +..___tag_value___libm_lgamma.372: +..B2.174: + fldt 96(%rsp) +..B2.175: + fldt (%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstpl 128(%rsp) + je ..B2.177 +..B2.176: + fldcw 138(%rsp) +..B2.177: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 +..B2.178: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.186: + testb %bpl, %bpl + je ..B2.188 +..B2.187: + fldcw 138(%rsp) +..B2.188: + testb %r12b, %r12b + je ..B2.190 +..B2.189: + movl %ebx, %edi +..___tag_value___libm_lgamma.393: + call fesetround@PLT +..___tag_value___libm_lgamma.394: +..B2.190: + movq 144(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.97 +..B2.191: + pxor %xmm0, %xmm0 + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.193: + movl 36(%rsp), %eax + andl $1048575, %eax + cmpl $480473, %eax + jg ..B2.196 +..B2.194: + jne ..B2.126 +..B2.195: + cmpl $663441831, 32(%rsp) + jbe ..B2.126 +..B2.196: + testb %r12b, %r12b + je ..B2.198 +..B2.197: + movl %ebx, %edi +..___tag_value___libm_lgamma.415: + call fesetround@PLT +..___tag_value___libm_lgamma.416: +..B2.198: + lea _PBIG(%rip), %rax + testb %bpl, %bpl + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 128(%rsp) + je ..B2.200 +..B2.199: + fldcw 138(%rsp) +..B2.200: + movq 144(%rsp), %rax + xorq %rsp, %rax + movsd 128(%rsp), %xmm0 + cmpq %fs:40, %rax + jne ..B2.97 + jmp ..B2.16 +..B2.223: + fstp %st(1) + fstp %st(0) + jmp ..B2.76 + .align 16,0x90 + .cfi_endproc + .type __libm_lgamma,@function + .size __libm_lgamma,.-__libm_lgamma + .data +# -- End __libm_lgamma + .text +# -- Begin lgamma_pos + .text + .align 16,0x90 +lgamma_pos: +# parameter 1: 8 + %rsp +..B3.1: + .cfi_startproc +..___tag_value_lgamma_pos.418: +..L419: + + fldt 8(%rsp) + fstl -8(%rsp) + fldt .L_2il0floatpacket.4(%rip) + movzwl -2(%rsp), %ecx + andl $32752, %ecx + shrl $4, %ecx + movl -4(%rsp), %eax + shll $20, %ecx + andl $1048575, %eax + orl %eax, %ecx + cmpl $1074790400, %ecx + jb ..B3.3 +..B3.2: + fstp %st(0) + addl $-1074790400, %ecx + lea _A(%rip), %rax + sarl $20, %ecx + lea _B(%rip), %rdx + movslq %ecx, %rcx + lea _C5(%rip), %rdi + lea (%rcx,%rcx,2), %esi + shll $3, %esi + movslq %esi, %rsi + fldl (%rax,%rcx,8) + shlq $4, %rsi + fsubrp %st, %st(1) + fmull (%rdx,%rcx,8) + fld %st(0) + fmul %st(1), %st + fldt 16(%rdi,%rsi) + fmul %st(2), %st + fadd %st(1), %st + fldt 48(%rdi,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 32(%rdi,%rsi) + faddp %st, %st(1) + fldt 80(%rdi,%rsi) + fmul %st(4), %st + fadd %st(3), %st + fldt 64(%rdi,%rsi) + faddp %st, %st(1) + fldt 112(%rdi,%rsi) + fmul %st(5), %st + fadd %st(4), %st + fldt 144(%rdi,%rsi) + fmul %st(6), %st + fadd %st(5), %st + fldt (%rsi,%rdi) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + fldt 96(%rdi,%rsi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 128(%rdi,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 176(%rdi,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 160(%rdi,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 208(%rdi,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 192(%rdi,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 240(%rdi,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 224(%rdi,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 272(%rdi,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 256(%rdi,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 304(%rdi,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 288(%rdi,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 336(%rdi,%rsi) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 320(%rdi,%rsi) + fadd %st, %st(1) + fxch %st(1) + fmulp %st, %st(2) + fldt 352(%rdi,%rsi) + fmulp %st, %st(2) + fxch %st(1) + jmp ..B3.11 +..B3.3: + cmpl $1073872896, %ecx + jb ..B3.5 +..B3.4: + fstp %st(0) + lea 48+_C4(%rip), %rcx + lea 16+_C4(%rip), %rax + fld %st(0) + lea 80+_C4(%rip), %rdi + fmul %st(1), %st + lea 32+_C4(%rip), %rsi + fldt (%rax) + lea 112+_C4(%rip), %r9 + fmul %st(2), %st + lea _C4(%rip), %rdx + lea 64+_C4(%rip), %r8 + lea 144+_C4(%rip), %r11 + lea 96+_C4(%rip), %r10 + lea 128+_C4(%rip), %rax + fadd %st(1), %st + fldt (%rdx) + lea 176+_C4(%rip), %rdx + faddp %st, %st(1) + fldt (%rcx) + lea 160+_C4(%rip), %rcx + fmul %st(3), %st + fadd %st(2), %st + fldt (%rsi) + lea 208+_C4(%rip), %rsi + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rdi) + lea 192+_C4(%rip), %rdi + fmul %st(3), %st + fadd %st(2), %st + fldt (%r8) + lea 240+_C4(%rip), %r8 + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r9) + lea 224+_C4(%rip), %r9 + fmul %st(3), %st + fadd %st(2), %st + fldt (%r10) + lea 272+_C4(%rip), %r10 + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r11) + lea 256+_C4(%rip), %r11 + fmul %st(3), %st + fadd %st(2), %st + fldt (%rax) + lea 304+_C4(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rdx) + lea 288+_C4(%rip), %rdx + fmul %st(3), %st + fadd %st(2), %st + fldt (%rcx) + lea 336+_C4(%rip), %rcx + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rsi) + lea 320+_C4(%rip), %rsi + fmul %st(3), %st + fadd %st(2), %st + fldt (%rdi) + lea 352+_C4(%rip), %rdi + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r8) + fmul %st(3), %st + fadd %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r10) + fmul %st(3), %st + fadd %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rax) + fmul %st(3), %st + fadd %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rcx) + fmul %st(3), %st + faddp %st, %st(2) + fldt (%rsi) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt (%rdi) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.6(%rip) + fsubrp %st, %st(2) + fmul %st(1), %st + jmp ..B3.11 +..B3.5: + cmpl $1073479680, %ecx + jb ..B3.7 +..B3.6: + fstp %st(0) + fldt .L_2il0floatpacket.6(%rip) + lea 160+_C3(%rip), %rax + lea 144+_C3(%rip), %rdx + lea 128+_C3(%rip), %rcx + lea 112+_C3(%rip), %rsi + lea 96+_C3(%rip), %rdi + lea 80+_C3(%rip), %r8 + lea 48+_C3(%rip), %r9 + lea 168+_C3(%rip), %r11 + fsubrp %st, %st(1) + fld %st(0) + lea 16+_C3(%rip), %r10 + fmul %st(1), %st + fldl (%rax) + lea 152+_C3(%rip), %rax + fmul %st(1), %st + fldt (%r9) + lea 32+_C3(%rip), %r9 + fldt (%r10) + lea _C3(%rip), %r10 + fxch %st(2) + faddl (%rdx) + lea 136+_C3(%rip), %rdx + fmul %st(3), %st + fldt (%r9) + fldt (%r10) + fxch %st(2) + faddl (%rcx) + lea 120+_C3(%rip), %rcx + fmul %st(5), %st + faddl (%rsi) + lea 104+_C3(%rip), %rsi + fmul %st(5), %st + faddl (%rdi) + lea 88+_C3(%rip), %rdi + fmul %st(5), %st + faddl (%r8) + lea 64+_C3(%rip), %r8 + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldl (%r11) + fmul %st(4), %st + fldt (%r8) + fxch %st(1) + faddl (%rax) + fmul %st(5), %st + faddl (%rdx) + fmul %st(5), %st + faddl (%rcx) + fmul %st(5), %st + faddl (%rsi) + fmul %st(5), %st + faddl (%rdi) + fmul %st(5), %st + faddp %st, %st(1) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + jmp ..B3.11 +..B3.7: + cmpl $1072955392, %ecx + jb ..B3.9 +..B3.8: + fstp %st(0) + lea _LM(%rip), %rax + lea 176+_LGAMMA_C2(%rip), %rdx + lea 160+_LGAMMA_C2(%rip), %rcx + lea 144+_LGAMMA_C2(%rip), %rsi + lea 128+_LGAMMA_C2(%rip), %rdi + lea 112+_LGAMMA_C2(%rip), %r8 + lea 96+_LGAMMA_C2(%rip), %r9 + lea 64+_LGAMMA_C2(%rip), %r10 + fldt (%rax) + lea 32+_LGAMMA_C2(%rip), %r11 + lea _LGAMMA_C2(%rip), %rax + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl (%rdx) + lea 184+_LGAMMA_C2(%rip), %rdx + fmul %st(1), %st + fldt (%r10) + lea 80+_LGAMMA_C2(%rip), %r10 + fldt (%r11) + lea 48+_LGAMMA_C2(%rip), %r11 + fldt (%rax) + lea 16+_LGAMMA_C2(%rip), %rax + fxch %st(3) + faddl (%rcx) + lea 168+_LGAMMA_C2(%rip), %rcx + fmul %st(4), %st + fldt (%r10) + fldt (%r11) + fxch %st(2) + faddl (%rsi) + lea 152+_LGAMMA_C2(%rip), %rsi + fmul %st(6), %st + faddl (%rdi) + lea 136+_LGAMMA_C2(%rip), %rdi + fmul %st(6), %st + faddl (%r8) + lea 120+_LGAMMA_C2(%rip), %r8 + fmul %st(6), %st + faddl (%r9) + lea 104+_LGAMMA_C2(%rip), %r9 + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(3) + fldl (%rdx) + fmul %st(4), %st + faddl (%rcx) + fmul %st(4), %st + faddl (%rsi) + fmul %st(4), %st + faddl (%rdi) + fmul %st(4), %st + faddl (%r8) + fmul %st(4), %st + faddl (%r9) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + jmp ..B3.11 +..B3.9: + cmpl $1072431104, %ecx + jb ..B3.11 +..B3.10: + fstp %st(0) + fldt .L_2il0floatpacket.1(%rip) + lea 160+_C1(%rip), %rax + lea 144+_C1(%rip), %rdx + lea 128+_C1(%rip), %rcx + lea 112+_C1(%rip), %rsi + lea 96+_C1(%rip), %rdi + lea 80+_C1(%rip), %r8 + lea 48+_C1(%rip), %r9 + lea 168+_C1(%rip), %r11 + fsubrp %st, %st(1) + fld %st(0) + lea 16+_C1(%rip), %r10 + fmul %st(1), %st + fldl (%rax) + lea 152+_C1(%rip), %rax + fmul %st(1), %st + fldt (%r9) + lea 32+_C1(%rip), %r9 + fldt (%r10) + lea _C1(%rip), %r10 + fxch %st(2) + faddl (%rdx) + lea 136+_C1(%rip), %rdx + fmul %st(3), %st + fldt (%r9) + fldt (%r10) + fxch %st(2) + faddl (%rcx) + lea 120+_C1(%rip), %rcx + fmul %st(5), %st + faddl (%rsi) + lea 104+_C1(%rip), %rsi + fmul %st(5), %st + faddl (%rdi) + lea 88+_C1(%rip), %rdi + fmul %st(5), %st + faddl (%r8) + lea 64+_C1(%rip), %r8 + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldl (%r11) + fmul %st(4), %st + fldt (%r8) + fxch %st(1) + faddl (%rax) + fmul %st(5), %st + faddl (%rdx) + fmul %st(5), %st + faddl (%rcx) + fmul %st(5), %st + faddl (%rsi) + fmul %st(5), %st + faddl (%rdi) + fmul %st(5), %st + faddp %st, %st(1) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) +..B3.11: + fstp %st(1) + ret + .align 16,0x90 + .cfi_endproc + .type lgamma_pos,@function + .size lgamma_pos,.-lgamma_pos + .data +# -- End lgamma_pos + .text +# -- Begin gamma + .text + .align 16,0x90 + .globl gamma +gamma: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value_gamma.421: +..L422: + + pushq %rsi + .cfi_def_cfa_offset 16 + lea (%rsp), %rdi +..___tag_value_gamma.424: + call __libm_lgamma +..___tag_value_gamma.425: +..B4.2: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type gamma,@function + .size gamma,.-gamma + .data +# -- End gamma + .text +# -- Begin lgamma_r + .text + .align 16,0x90 + .globl lgamma_r +lgamma_r: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B5.1: + .cfi_startproc +..___tag_value_lgamma_r.428: +..L429: + + pushq %rsi + .cfi_def_cfa_offset 16 +..___tag_value_lgamma_r.431: + call __libm_lgamma +..___tag_value_lgamma_r.432: +..B5.2: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type lgamma_r,@function + .size lgamma_r,.-lgamma_r + .data +# -- End lgamma_r + .text +# -- Begin gamma_r + .text + .align 16,0x90 + .globl gamma_r +gamma_r: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B6.1: + .cfi_startproc +..___tag_value_gamma_r.435: +..L436: + + pushq %rsi + .cfi_def_cfa_offset 16 +..___tag_value_gamma_r.438: + call __libm_lgamma +..___tag_value_gamma_r.439: +..B6.2: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type gamma_r,@function + .size gamma_r,.-gamma_r + .data +# -- End gamma_r + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 16 +.L_2il0floatpacket.7: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 16 +_LRIB: + .long 3639930760 + .long 3221638968 + .long 169597185 + .long 3221617473 + .long 994230906 + .long 3221595977 + .long 249193764 + .long 3222253755 + .long 1417424869 + .long 3222250609 + .long 2585655974 + .long 3222247463 + .long 679699934 + .long 3222534303 + .long 2054089469 + .long 3222533975 + .long 3428479004 + .long 3222533647 + .long 1666697798 + .long 3222798023 + .long 4119983117 + .long 3222797970 + .long 2278301140 + .long 3222797918 + .long 753528318 + .long 3223060435 + .long 4151019248 + .long 3223060427 + .long 3253542882 + .long 3223060420 + .long 1221915992 + .long 3223322618 + .long 2139183567 + .long 3223322617 + .long 3056451142 + .long 3223322616 + .long 2968798493 + .long 3223453695 + .long 2743618512 + .long 3223453695 + .long 2518438531 + .long 3223453695 + .long 4156721779 + .long 3223584767 + .long 4139833280 + .long 3223584767 + .long 4122944781 + .long 3223584767 + .long 4282834537 + .long 3223715839 + .long 4280864212 + .long 3223715839 + .long 4278893887 + .long 3223715839 + .long 4293918703 + .long 3223846911 + .long 4293792039 + .long 3223846911 + .long 4293665375 + .long 3223846911 + .long 4294888151 + .long 3223977983 + .long 4294876892 + .long 3223977983 + .long 4294865633 + .long 3223977983 + .long 4294961261 + .long 3224109055 + .long 4294960839 + .long 3224109055 + .long 4294960417 + .long 3224109055 + .long 4294966894 + .long 3224240127 + .long 4294966866 + .long 3224240127 + .long 4294966838 + .long 3224240127 + .type _LRIB,@object + .size _LRIB,312 + .space 8, 0x00 # pad + .align 16 +_LRP16: + .long 2378050348 + .long 1101969305 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .type _LRP16,@object + .size _LRP16,104 + .space 8, 0x00 # pad + .align 16 +_LRP: + .word 17751 + .word 54196 + .word 10629 + .word 51164 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 41133 + .word 9612 + .word 27976 + .word 62729 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 42459 + .word 13010 + .word 63969 + .word 39219 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 65437 + .word 25696 + .word 54808 + .word 41154 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 58026 + .word 20377 + .word 22118 + .word 64130 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 35937 + .word 22559 + .word 22660 + .word 49256 + .word 8259 + .word 31940 + .word 14143 + .word 16516 + .word 36722 + .word 48879 + .word 8761 + .word 49313 + .word 17702 + .word 59215 + .word 47717 + .word 16573 + .word 13453 + .word 50588 + .word 11555 + .word 49370 + .word 8896 + .word 4195 + .word 22549 + .word 16631 + .word 8306 + .word 47544 + .word 1832 + .word 49429 + .word 60153 + .word 61869 + .word 6523 + .word 16691 + .word 63612 + .word 2764 + .word 26286 + .word 49489 + .word 63356 + .word 31621 + .word 64278 + .word 16751 + .word 24055 + .word 64192 + .word 21464 + .word 49552 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49769 + .word 49242 + .word 6580 + .word 61152 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 7708 + .word 25266 + .word 60595 + .word 42444 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 45975 + .word 8629 + .word 62832 + .word 64438 + .word 16390 + .word 0 + .word 0 + .word 0 + .word 39855 + .word 22905 + .word 44266 + .word 59689 + .word 49162 + .word 0 + .word 0 + .word 0 + .word 10240 + .word 41089 + .word 5368 + .word 62588 + .word 16398 + .word 0 + .word 0 + .word 0 + .word 3194 + .word 32877 + .word 5879 + .word 49457 + .word 40173 + .word 43959 + .word 59635 + .word 16755 + .word 53371 + .word 1664 + .word 56254 + .word 49591 + .word 34510 + .word 44659 + .word 12150 + .word 16893 + .word 33872 + .word 42862 + .word 8799 + .word 49730 + .word 10662 + .word 44157 + .word 53571 + .word 17030 + .word 55074 + .word 58798 + .word 65525 + .word 49868 + .word 1276 + .word 34610 + .word 36363 + .word 17170 + .word 7041 + .word 29575 + .word 61144 + .word 50007 + .word 19121 + .word 53977 + .word 34010 + .word 17312 + .word 54457 + .word 12310 + .word 48419 + .word 50149 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55737 + .word 12115 + .word 42602 + .word 40775 + .word 16337 + .word 0 + .word 0 + .word 0 + .word 42581 + .word 53029 + .word 20983 + .word 59666 + .word 49157 + .word 0 + .word 0 + .word 0 + .word 24816 + .word 20947 + .word 58172 + .word 55961 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 3130 + .word 13042 + .word 49143 + .word 34463 + .word 49170 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 24697 + .word 14253 + .word 47765 + .word 16408 + .word 0 + .word 0 + .word 0 + .word 32693 + .word 5691 + .word 15709 + .word 49649 + .word 20491 + .word 21402 + .word 35932 + .word 16986 + .word 44071 + .word 16276 + .word 1675 + .word 49861 + .word 13758 + .word 14468 + .word 65445 + .word 17200 + .word 60394 + .word 3375 + .word 60434 + .word 50075 + .word 49748 + .word 2796 + .word 14419 + .word 17415 + .word 61579 + .word 22133 + .word 33066 + .word 50291 + .word 25055 + .word 28661 + .word 31699 + .word 17632 + .word 55823 + .word 18661 + .word 6347 + .word 50508 + .word 58142 + .word 19935 + .word 64799 + .word 17849 + .word 41216 + .word 59562 + .word 42287 + .word 50726 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16006 + .word 65034 + .word 42959 + .word 34185 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 40843 + .word 53953 + .word 46369 + .word 45839 + .word 49160 + .word 0 + .word 0 + .word 0 + .word 54179 + .word 42767 + .word 58812 + .word 64462 + .word 16400 + .word 0 + .word 0 + .word 0 + .word 50676 + .word 3143 + .word 1093 + .word 60276 + .word 49177 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56865 + .word 38982 + .word 63406 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 65273 + .word 45226 + .word 24230 + .word 49857 + .word 23450 + .word 59950 + .word 19796 + .word 17236 + .word 4038 + .word 16755 + .word 26702 + .word 50152 + .word 24087 + .word 51196 + .word 62539 + .word 17533 + .word 25486 + .word 58858 + .word 44079 + .word 50450 + .word 31845 + .word 29909 + .word 37453 + .word 17831 + .word 19699 + .word 12384 + .word 3664 + .word 50750 + .word 26808 + .word 47918 + .word 18611 + .word 18131 + .word 25376 + .word 13791 + .word 62285 + .word 51048 + .word 64886 + .word 33542 + .word 28786 + .word 18433 + .word 54686 + .word 5814 + .word 3500 + .word 51351 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33175 + .word 51870 + .word 55516 + .word 61254 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 3685 + .word 30034 + .word 48430 + .word 40287 + .word 49163 + .word 0 + .word 0 + .word 0 + .word 3323 + .word 33320 + .word 53546 + .word 49572 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 19902 + .word 19517 + .word 60782 + .word 40648 + .word 49186 + .word 0 + .word 0 + .word 0 + .word 28672 + .word 31090 + .word 60187 + .word 37497 + .word 16430 + .word 0 + .word 0 + .word 0 + .word 4362 + .word 57115 + .word 1063 + .word 50082 + .word 17298 + .word 34206 + .word 30558 + .word 17506 + .word 19701 + .word 2977 + .word 30695 + .word 50467 + .word 45209 + .word 25144 + .word 62418 + .word 17892 + .word 6287 + .word 3260 + .word 59477 + .word 50854 + .word 26251 + .word 62311 + .word 23506 + .word 18281 + .word 50215 + .word 3065 + .word 23294 + .word 51244 + .word 519 + .word 28602 + .word 60080 + .word 18671 + .word 56824 + .word 33188 + .word 7096 + .word 51634 + .word 27357 + .word 50961 + .word 5574 + .word 19062 + .word 7770 + .word 52374 + .word 38304 + .word 52025 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33559 + .word 2783 + .word 4720 + .word 38214 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 65291 + .word 24589 + .word 47090 + .word 40315 + .word 49166 + .word 0 + .word 0 + .word 0 + .word 7930 + .word 21505 + .word 15205 + .word 49607 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 61775 + .word 9936 + .word 17817 + .word 40691 + .word 49195 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 37628 + .word 658 + .word 37550 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 14352 + .word 33815 + .word 3114 + .word 50322 + .word 43816 + .word 13363 + .word 33081 + .word 17794 + .word 62601 + .word 27719 + .word 33798 + .word 50803 + .word 1036 + .word 16074 + .word 700 + .word 18277 + .word 33117 + .word 56648 + .word 64173 + .word 51286 + .word 17251 + .word 52492 + .word 29265 + .word 18761 + .word 11155 + .word 27451 + .word 30367 + .word 51772 + .word 7487 + .word 7247 + .word 2371 + .word 19248 + .word 14759 + .word 9929 + .word 13587 + .word 52258 + .word 11730 + .word 26190 + .word 56262 + .word 19733 + .word 56923 + .word 11047 + .word 18072 + .word 52745 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37589 + .word 36570 + .word 62298 + .word 45320 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 17708 + .word 57749 + .word 28642 + .word 45359 + .word 49169 + .word 0 + .word 0 + .word 0 + .word 40067 + .word 38581 + .word 2689 + .word 62790 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 36505 + .word 63458 + .word 34596 + .word 57945 + .word 49204 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 38946 + .word 9029 + .word 60159 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 61014 + .word 7077 + .word 17362 + .word 50576 + .word 11572 + .word 44638 + .word 49972 + .word 18098 + .word 64171 + .word 46242 + .word 17172 + .word 51158 + .word 7607 + .word 1130 + .word 63213 + .word 18682 + .word 20847 + .word 56361 + .word 38627 + .word 51744 + .word 49497 + .word 58620 + .word 43800 + .word 19268 + .word 63056 + .word 11021 + .word 657 + .word 52330 + .word 42127 + .word 49291 + .word 30722 + .word 19856 + .word 13674 + .word 31481 + .word 1908 + .word 52917 + .word 60194 + .word 12516 + .word 3868 + .word 20445 + .word 3386 + .word 31577 + .word 62924 + .word 53506 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44838 + .word 25647 + .word 6736 + .word 62345 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 31560 + .word 12645 + .word 60726 + .word 56699 + .word 49172 + .word 0 + .word 0 + .word 0 + .word 56942 + .word 25011 + .word 17364 + .word 49055 + .word 16425 + .word 0 + .word 0 + .word 0 + .word 3371 + .word 3119 + .word 24466 + .word 56588 + .word 49214 + .word 0 + .word 0 + .word 0 + .word 14336 + .word 15684 + .word 2636 + .word 36719 + .word 16468 + .word 0 + .word 0 + .word 0 + .word 47554 + .word 44810 + .word 53673 + .word 50840 + .word 53371 + .word 50832 + .word 58584 + .word 18417 + .word 46548 + .word 9025 + .word 35353 + .word 51530 + .word 2727 + .word 25780 + .word 5967 + .word 19108 + .word 27113 + .word 1073 + .word 59097 + .word 52222 + .word 11834 + .word 38905 + .word 4058 + .word 19800 + .word 56017 + .word 55971 + .word 60637 + .word 52914 + .word 5287 + .word 8439 + .word 65517 + .word 20493 + .word 37028 + .word 58958 + .word 62480 + .word 53607 + .word 57582 + .word 43721 + .word 1738 + .word 21188 + .word 9819 + .word 37368 + .word 17165 + .word 54304 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13429 + .word 7444 + .word 20593 + .word 34837 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 49742 + .word 37689 + .word 16091 + .word 38981 + .word 49176 + .word 0 + .word 0 + .word 0 + .word 46524 + .word 21314 + .word 39987 + .word 46372 + .word 16432 + .word 0 + .word 0 + .word 0 + .word 14081 + .word 37459 + .word 64348 + .word 36776 + .word 49225 + .word 0 + .word 0 + .word 0 + .word 30720 + .word 57650 + .word 51740 + .word 32812 + .word 16482 + .word 0 + .word 0 + .word 0 + .word 13868 + .word 61714 + .word 32487 + .word 51118 + .word 53288 + .word 8914 + .word 15189 + .word 18750 + .word 25547 + .word 51031 + .word 54157 + .word 51918 + .word 4587 + .word 22569 + .word 2868 + .word 19552 + .word 4628 + .word 56702 + .word 63256 + .word 52720 + .word 60585 + .word 38579 + .word 10763 + .word 20354 + .word 20343 + .word 32825 + .word 42223 + .word 53523 + .word 15259 + .word 21287 + .word 25207 + .word 21157 + .word 19232 + .word 27853 + .word 30722 + .word 54327 + .word 6202 + .word 34921 + .word 46892 + .word 21963 + .word 54314 + .word 63337 + .word 3818 + .word 55135 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12932 + .word 7413 + .word 50416 + .word 52775 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 49070 + .word 42612 + .word 57119 + .word 58471 + .word 49179 + .word 0 + .word 0 + .word 0 + .word 37517 + .word 48554 + .word 12217 + .word 52169 + .word 16439 + .word 0 + .word 0 + .word 0 + .word 3686 + .word 14060 + .word 10284 + .word 62061 + .word 49235 + .word 0 + .word 0 + .word 0 + .word 12288 + .word 36186 + .word 45004 + .word 41528 + .word 16496 + .word 0 + .word 0 + .word 0 + .word 36572 + .word 10708 + .word 62070 + .word 51404 + .word 43863 + .word 23526 + .word 34237 + .word 19093 + .word 49453 + .word 49937 + .word 30100 + .word 52320 + .word 42622 + .word 48103 + .word 45810 + .word 20009 + .word 63343 + .word 18283 + .word 24986 + .word 53236 + .word 211 + .word 7406 + .word 23986 + .word 20928 + .word 55487 + .word 58939 + .word 35978 + .word 54154 + .word 20786 + .word 29108 + .word 45903 + .word 21845 + .word 43676 + .word 27033 + .word 56912 + .word 55073 + .word 56762 + .word 13326 + .word 51569 + .word 22766 + .word 11195 + .word 61166 + .word 50980 + .word 55993 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8176 + .word 5164 + .word 64154 + .word 36090 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 19140 + .word 63711 + .word 39190 + .word 47508 + .word 49183 + .word 0 + .word 0 + .word 0 + .word 61957 + .word 29915 + .word 7046 + .word 34440 + .word 16447 + .word 0 + .word 0 + .word 0 + .word 29909 + .word 15770 + .word 39264 + .word 33288 + .word 49247 + .word 0 + .word 0 + .word 0 + .word 38912 + .word 2108 + .word 35420 + .word 36197 + .word 16511 + .word 0 + .word 0 + .word 0 + .word 63755 + .word 16362 + .word 32791 + .word 51700 + .word 7043 + .word 34288 + .word 50374 + .word 19448 + .word 36869 + .word 13569 + .word 51161 + .word 52734 + .word 30422 + .word 39536 + .word 34368 + .word 20483 + .word 2356 + .word 27571 + .word 10627 + .word 53769 + .word 24204 + .word 35273 + .word 27312 + .word 21520 + .word 8451 + .word 46569 + .word 41820 + .word 54805 + .word 23553 + .word 63476 + .word 47626 + .word 22556 + .word 30024 + .word 47627 + .word 14141 + .word 55843 + .word 22061 + .word 10635 + .word 17534 + .word 23595 + .word 50593 + .word 17237 + .word 38322 + .word 56882 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26357 + .word 41545 + .word 7157 + .word 37888 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 28550 + .word 47270 + .word 51275 + .word 41572 + .word 49187 + .word 0 + .word 0 + .word 0 + .word 7474 + .word 4460 + .word 27226 + .word 52743 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 18816 + .word 51641 + .word 26417 + .word 44610 + .word 49258 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 61733 + .word 61279 + .word 42447 + .word 16526 + .word 0 + .word 0 + .word 0 + .word 45407 + .word 18829 + .word 2399 + .word 52005 + .word 35928 + .word 2098 + .word 15792 + .word 19814 + .word 23614 + .word 62930 + .word 12196 + .word 53160 + .word 7674 + .word 56712 + .word 55660 + .word 20970 + .word 53358 + .word 2019 + .word 18277 + .word 54318 + .word 57563 + .word 186 + .word 18788 + .word 22129 + .word 38957 + .word 32276 + .word 61462 + .word 55475 + .word 46995 + .word 58305 + .word 12150 + .word 23287 + .word 60702 + .word 18274 + .word 9955 + .word 56635 + .word 40407 + .word 43665 + .word 14520 + .word 24448 + .word 50736 + .word 28578 + .word 16181 + .word 57795 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5404 + .word 12511 + .word 60447 + .word 38763 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 42770 + .word 34093 + .word 51209 + .word 39016 + .word 49191 + .word 0 + .word 0 + .word 0 + .word 6888 + .word 59302 + .word 12508 + .word 46457 + .word 16462 + .word 0 + .word 0 + .word 0 + .word 49565 + .word 60790 + .word 42341 + .word 36877 + .word 49270 + .word 0 + .word 0 + .word 0 + .word 28672 + .word 39351 + .word 39031 + .word 32932 + .word 16542 + .word 0 + .word 0 + .word 0 + .word 35933 + .word 37102 + .word 41613 + .word 52318 + .word 59745 + .word 3284 + .word 26050 + .word 20190 + .word 16458 + .word 62792 + .word 1547 + .word 53599 + .word 38519 + .word 37566 + .word 10560 + .word 21472 + .word 36560 + .word 62869 + .word 6875 + .word 54881 + .word 58623 + .word 15626 + .word 21634 + .word 22754 + .word 22503 + .word 3380 + .word 55147 + .word 56163 + .word 21679 + .word 23644 + .word 42908 + .word 24037 + .word 43760 + .word 1032 + .word 52442 + .word 57447 + .word 14782 + .word 45605 + .word 45261 + .word 25322 + .word 22271 + .word 11633 + .word 47287 + .word 58733 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _LRP,@object + .size _LRP,2496 + .align 16 +_RRIB: + .long 4234632914 + .long 3221491298 + .long 2516645996 + .long 3221465084 + .long 798659078 + .long 3221438870 + .long 2133702104 + .long 3221835523 + .long 3164494255 + .long 3221825037 + .long 4195286406 + .long 3221814551 + .long 816546054 + .long 3222285677 + .long 2019136897 + .long 3222284366 + .long 3221727740 + .long 3222283055 + .long 2093868532 + .long 3222538608 + .long 1475393241 + .long 3222538346 + .long 856917950 + .long 3222538084 + .long 2471449286 + .long 3222798751 + .long 629767309 + .long 3222798699 + .long 3083052628 + .long 3222798646 + .long 862741805 + .long 3223060539 + .long 4260232735 + .long 3223060531 + .long 3362756369 + .long 3223060524 + .long 3046734174 + .long 3223322627 + .long 1076409337 + .long 3223322627 + .long 3401051796 + .long 3223322626 + .long 1762435764 + .long 3223453696 + .long 1551329531 + .long 3223453696 + .long 1340223298 + .long 3223453696 + .long 175962963 + .long 3223584768 + .long 155133815 + .long 3223584768 + .long 134304667 + .long 3223584768 + .long 16073407 + .long 3223715840 + .long 14103082 + .long 3223715840 + .long 12132757 + .long 3223715840 + .long 1330068 + .long 3223846912 + .long 1175257 + .long 3223846912 + .long 1020446 + .long 3223846912 + .long 101663 + .long 3223977984 + .long 90404 + .long 3223977984 + .long 79145 + .long 3223977984 + .long 7020 + .long 3224109056 + .long 6457 + .long 3224109056 + .long 5894 + .long 3224109056 + .type _RRIB,@object + .size _RRIB,312 + .space 8, 0x00 # pad + .align 16 +_RRP: + .word 26273 + .word 65347 + .word 56168 + .word 33169 + .word 16329 + .word 0 + .word 0 + .word 0 + .word 899 + .word 31387 + .word 19253 + .word 49663 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 58984 + .word 6058 + .word 23936 + .word 39799 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 62168 + .word 21442 + .word 12332 + .word 46245 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 32619 + .word 37054 + .word 53131 + .word 16575 + .word 61379 + .word 13125 + .word 14178 + .word 16562 + .word 10270 + .word 45115 + .word 37615 + .word 16506 + .word 38745 + .word 51073 + .word 34560 + .word 16498 + .word 53490 + .word 20212 + .word 2544 + .word 16440 + .word 38291 + .word 26669 + .word 54063 + .word 16440 + .word 45779 + .word 11956 + .word 18019 + .word 16540 + .word 18677 + .word 64033 + .word 42794 + .word 16529 + .word 35035 + .word 51098 + .word 10618 + .word 16473 + .word 64107 + .word 31719 + .word 36522 + .word 16468 + .word 8831 + .word 57419 + .word 13215 + .word 16407 + .word 40450 + .word 31904 + .word 29069 + .word 16417 + .word 3821 + .word 29651 + .word 12061 + .word 62640 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 3177 + .word 32099 + .word 13049 + .word 63749 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 10153 + .word 35464 + .word 38075 + .word 52902 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 20859 + .word 27364 + .word 47250 + .word 57481 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 12411 + .word 3381 + .word 24721 + .word 16978 + .word 33723 + .word 48761 + .word 26869 + .word 16934 + .word 60995 + .word 48715 + .word 17741 + .word 16804 + .word 43031 + .word 16238 + .word 40105 + .word 16761 + .word 3889 + .word 41280 + .word 47482 + .word 16635 + .word 43797 + .word 63405 + .word 37827 + .word 16594 + .word 62186 + .word 39109 + .word 61647 + .word 16889 + .word 62356 + .word 27755 + .word 9779 + .word 16848 + .word 54712 + .word 4438 + .word 22518 + .word 16720 + .word 46932 + .word 1372 + .word 7843 + .word 16677 + .word 64555 + .word 14297 + .word 39523 + .word 16553 + .word 24913 + .word 15735 + .word 26400 + .word 16514 + .word 23128 + .word 31275 + .word 33489 + .word 52246 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 56543 + .word 37040 + .word 59300 + .word 54866 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 35342 + .word 2554 + .word 44652 + .word 41504 + .word 16391 + .word 0 + .word 0 + .word 0 + .word 60438 + .word 21728 + .word 35033 + .word 43725 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 2425 + .word 35124 + .word 13908 + .word 17426 + .word 60985 + .word 47869 + .word 25665 + .word 17352 + .word 21213 + .word 45459 + .word 26876 + .word 17133 + .word 52591 + .word 14597 + .word 24526 + .word 17060 + .word 20426 + .word 18941 + .word 5374 + .word 16845 + .word 38724 + .word 49064 + .word 24125 + .word 16773 + .word 29994 + .word 36366 + .word 21088 + .word 17279 + .word 13269 + .word 25406 + .word 24800 + .word 17205 + .word 56893 + .word 35190 + .word 33689 + .word 16988 + .word 18235 + .word 52539 + .word 13276 + .word 16916 + .word 8454 + .word 46451 + .word 9758 + .word 16704 + .word 59084 + .word 57882 + .word 27928 + .word 16633 + .word 38110 + .word 57460 + .word 5118 + .word 49980 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 32056 + .word 19825 + .word 28737 + .word 63161 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 37650 + .word 4479 + .word 6518 + .word 59238 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 47963 + .word 64405 + .word 49841 + .word 37534 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 53082 + .word 25478 + .word 58397 + .word 17968 + .word 35980 + .word 11362 + .word 59289 + .word 17858 + .word 37178 + .word 29007 + .word 44012 + .word 17530 + .word 40762 + .word 17715 + .word 56491 + .word 17422 + .word 58318 + .word 3223 + .word 43216 + .word 17097 + .word 46157 + .word 23530 + .word 32141 + .word 16991 + .word 63138 + .word 35190 + .word 24151 + .word 17748 + .word 9862 + .word 36309 + .word 14376 + .word 17639 + .word 38034 + .word 65220 + .word 2337 + .word 17314 + .word 16819 + .word 31850 + .word 22525 + .word 17205 + .word 7604 + .word 29558 + .word 57367 + .word 16883 + .word 27719 + .word 62170 + .word 8797 + .word 16778 + .word 19348 + .word 65423 + .word 37299 + .word 53534 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 8233 + .word 55180 + .word 9457 + .word 46319 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 43066 + .word 26574 + .word 6722 + .word 65137 + .word 16400 + .word 0 + .word 0 + .word 0 + .word 4285 + .word 7102 + .word 7454 + .word 61224 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 1453 + .word 4915 + .word 61926 + .word 18584 + .word 43088 + .word 28644 + .word 50480 + .word 18434 + .word 16532 + .word 18100 + .word 54137 + .word 17983 + .word 49885 + .word 46980 + .word 54409 + .word 17832 + .word 24326 + .word 38273 + .word 20489 + .word 17385 + .word 28149 + .word 12270 + .word 61982 + .word 17236 + .word 4581 + .word 37632 + .word 45525 + .word 18282 + .word 46626 + .word 30655 + .word 34430 + .word 18132 + .word 63429 + .word 60638 + .word 37201 + .word 17683 + .word 18031 + .word 50879 + .word 14891 + .word 17535 + .word 64064 + .word 1811 + .word 54229 + .word 17089 + .word 27163 + .word 21077 + .word 40059 + .word 16943 + .word 43177 + .word 42972 + .word 46613 + .word 45511 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 51480 + .word 49923 + .word 15697 + .word 40352 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 9513 + .word 31676 + .word 11989 + .word 49652 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 30527 + .word 7034 + .word 38319 + .word 40746 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 7022 + .word 27009 + .word 58741 + .word 19257 + .word 64033 + .word 16049 + .word 22023 + .word 19062 + .word 45243 + .word 42262 + .word 39716 + .word 18476 + .word 50731 + .word 20793 + .word 36853 + .word 18281 + .word 36100 + .word 48270 + .word 37858 + .word 17699 + .word 42104 + .word 28941 + .word 36380 + .word 17506 + .word 23499 + .word 6717 + .word 19492 + .word 18866 + .word 55911 + .word 14060 + .word 7353 + .word 18672 + .word 26519 + .word 16988 + .word 4787 + .word 18087 + .word 28065 + .word 5309 + .word 5697 + .word 17893 + .word 40193 + .word 22022 + .word 5795 + .word 17314 + .word 8456 + .word 42078 + .word 24130 + .word 17122 + .word 59016 + .word 62162 + .word 39673 + .word 39540 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 38154 + .word 49049 + .word 18422 + .word 40324 + .word 16398 + .word 0 + .word 0 + .word 0 + .word 42164 + .word 50610 + .word 50330 + .word 49617 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 25875 + .word 59750 + .word 15469 + .word 40704 + .word 16427 + .word 0 + .word 0 + .word 0 + .word 34173 + .word 58862 + .word 54392 + .word 19977 + .word 59819 + .word 8454 + .word 18296 + .word 19734 + .word 30024 + .word 20882 + .word 32589 + .word 19004 + .word 29754 + .word 31085 + .word 31060 + .word 18761 + .word 52191 + .word 27376 + .word 34749 + .word 18035 + .word 4562 + .word 4929 + .word 33854 + .word 17794 + .word 25001 + .word 9100 + .word 13901 + .word 19490 + .word 47424 + .word 1290 + .word 2840 + .word 19248 + .word 22386 + .word 25633 + .word 77 + .word 18519 + .word 15514 + .word 17548 + .word 1870 + .word 18277 + .word 63012 + .word 41083 + .word 3742 + .word 17554 + .word 48968 + .word 51531 + .word 22462 + .word 17314 + .word 41404 + .word 42732 + .word 62757 + .word 38778 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 7009 + .word 42712 + .word 36892 + .word 45360 + .word 16401 + .word 0 + .word 0 + .word 0 + .word 39847 + .word 2109 + .word 39294 + .word 62791 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 32179 + .word 43914 + .word 44915 + .word 57947 + .word 16436 + .word 0 + .word 0 + .word 0 + .word 27779 + .word 16034 + .word 51140 + .word 20738 + .word 17003 + .word 57008 + .word 53620 + .word 20444 + .word 23469 + .word 38349 + .word 865 + .word 19562 + .word 25226 + .word 11109 + .word 43957 + .word 19268 + .word 36845 + .word 29881 + .word 17299 + .word 18390 + .word 19837 + .word 16116 + .word 50064 + .word 18098 + .word 57862 + .word 29290 + .word 2992 + .word 20149 + .word 46818 + .word 59090 + .word 31382 + .word 19856 + .word 61466 + .word 30954 + .word 38749 + .word 18976 + .word 30984 + .word 39998 + .word 63388 + .word 18682 + .word 41543 + .word 16681 + .word 17428 + .word 17808 + .word 20643 + .word 64049 + .word 24643 + .word 17517 + .word 52468 + .word 15578 + .word 48717 + .word 44571 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 54595 + .word 6191 + .word 4821 + .word 56700 + .word 16404 + .word 0 + .word 0 + .word 0 + .word 50514 + .word 10282 + .word 25695 + .word 49055 + .word 16425 + .word 0 + .word 0 + .word 0 + .word 13176 + .word 11594 + .word 38881 + .word 56588 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 28019 + .word 59660 + .word 42453 + .word 21536 + .word 50810 + .word 20541 + .word 28938 + .word 21188 + .word 53928 + .word 47752 + .word 60679 + .word 20146 + .word 24270 + .word 60826 + .word 4097 + .word 19800 + .word 57327 + .word 59875 + .word 35368 + .word 18762 + .word 31038 + .word 58486 + .word 58593 + .word 18417 + .word 41074 + .word 26743 + .word 60755 + .word 20839 + .word 49334 + .word 8669 + .word 63919 + .word 20493 + .word 20472 + .word 19395 + .word 59120 + .word 19454 + .word 27230 + .word 61299 + .word 5980 + .word 19108 + .word 60536 + .word 14479 + .word 53684 + .word 18072 + .word 24589 + .word 24698 + .word 60903 + .word 17729 + .word 24724 + .word 11272 + .word 24781 + .word 60135 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 54850 + .word 34200 + .word 16766 + .word 38981 + .word 16408 + .word 0 + .word 0 + .word 0 + .word 58717 + .word 18738 + .word 40849 + .word 46372 + .word 16432 + .word 0 + .word 0 + .word 0 + .word 11614 + .word 63671 + .word 65373 + .word 36776 + .word 16457 + .word 0 + .word 0 + .word 0 + .word 54464 + .word 24503 + .word 3823 + .word 22367 + .word 6780 + .word 11041 + .word 46896 + .word 21963 + .word 31922 + .word 33372 + .word 42225 + .word 20755 + .word 24666 + .word 18144 + .word 10765 + .word 20354 + .word 1690 + .word 51390 + .word 54159 + .word 19150 + .word 40728 + .word 53860 + .word 15190 + .word 18750 + .word 62163 + .word 16835 + .word 30725 + .word 21559 + .word 49586 + .word 46435 + .word 25209 + .word 21157 + .word 392 + .word 18629 + .word 63258 + .word 19952 + .word 57023 + .word 35208 + .word 2869 + .word 19552 + .word 15849 + .word 23514 + .word 32489 + .word 18350 + .word 45455 + .word 56342 + .word 1433 + .word 17952 + .word 26203 + .word 24931 + .word 14914 + .word 64372 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 32494 + .word 4334 + .word 57160 + .word 58471 + .word 16411 + .word 0 + .word 0 + .word 0 + .word 38313 + .word 48554 + .word 12217 + .word 52169 + .word 16439 + .word 0 + .word 0 + .word 0 + .word 13841 + .word 14060 + .word 10284 + .word 62061 + .word 16467 + .word 0 + .word 0 + .word 0 + .word 27928 + .word 25887 + .word 22600 + .word 23226 + .word 25867 + .word 43031 + .word 24792 + .word 22767 + .word 61361 + .word 28179 + .word 36008 + .word 21386 + .word 1901 + .word 19713 + .word 23997 + .word 20928 + .word 53849 + .word 49977 + .word 30100 + .word 19552 + .word 12987 + .word 23545 + .word 34237 + .word 19093 + .word 36035 + .word 18526 + .word 55738 + .word 22305 + .word 4173 + .word 53170 + .word 44844 + .word 21845 + .word 20134 + .word 6065 + .word 24986 + .word 20468 + .word 63684 + .word 40633 + .word 45810 + .word 20009 + .word 28281 + .word 10708 + .word 62070 + .word 18636 + .word 42557 + .word 63889 + .word 18197 + .word 18180 + .word 24464 + .word 43564 + .word 52277 + .word 36083 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 8651 + .word 37688 + .word 39193 + .word 47508 + .word 16415 + .word 0 + .word 0 + .word 0 + .word 61957 + .word 29915 + .word 7046 + .word 34440 + .word 16447 + .word 0 + .word 0 + .word 0 + .word 29909 + .word 15770 + .word 39264 + .word 33288 + .word 16479 + .word 0 + .word 0 + .word 0 + .word 16042 + .word 19253 + .word 38322 + .word 24114 + .word 28448 + .word 10617 + .word 17534 + .word 23595 + .word 64229 + .word 46570 + .word 41820 + .word 22037 + .word 23727 + .word 35273 + .word 27312 + .word 21520 + .word 36874 + .word 13569 + .word 51161 + .word 19966 + .word 7043 + .word 34288 + .word 50374 + .word 19448 + .word 38316 + .word 47529 + .word 14141 + .word 23075 + .word 12297 + .word 63477 + .word 47626 + .word 22556 + .word 1229 + .word 27571 + .word 10627 + .word 21001 + .word 30426 + .word 39536 + .word 34368 + .word 20483 + .word 63755 + .word 16362 + .word 32791 + .word 18932 + .word 1939 + .word 19329 + .word 44209 + .word 18417 + .word 1291 + .word 6677 + .word 4999 + .word 37888 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 36671 + .word 58224 + .word 51275 + .word 41572 + .word 16419 + .word 0 + .word 0 + .word 0 + .word 7476 + .word 4460 + .word 27226 + .word 52743 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 18838 + .word 51641 + .word 26417 + .word 44610 + .word 16490 + .word 0 + .word 0 + .word 0 + .word 10710 + .word 48640 + .word 32083 + .word 25027 + .word 33620 + .word 55766 + .word 26236 + .word 24448 + .word 24667 + .word 39142 + .word 61464 + .word 22707 + .word 56170 + .word 8470 + .word 18789 + .word 22129 + .word 23296 + .word 62931 + .word 12196 + .word 20392 + .word 57231 + .word 2098 + .word 15792 + .word 19814 + .word 1704 + .word 49608 + .word 9547 + .word 23867 + .word 46419 + .word 24648 + .word 11891 + .word 23287 + .word 19376 + .word 1296 + .word 18277 + .word 21550 + .word 46223 + .word 56399 + .word 55660 + .word 20970 + .word 45364 + .word 18829 + .word 2399 + .word 19237 + .word 9387 + .word 60414 + .word 47613 + .word 18660 + .type _RRP,@object + .size _RRP,2080 + .align 16 +_LN_SQRT_TWO_PI: + .word 42293 + .word 9717 + .word 36419 + .word 60223 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _LN_SQRT_TWO_PI,@object + .size _LN_SQRT_TWO_PI,16 + .align 16 +_S10: + .word 26777 + .word 63736 + .word 61426 + .word 52480 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _S10,@object + .size _S10,16 + .align 16 +_W2: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _W2,@object + .size _W2,16 + .align 16 +_S06: + .word 26251 + .word 64205 + .word 25991 + .word 44448 + .word 49149 + .word 0 + .word 0 + .word 0 + .type _S06,@object + .size _S06,16 + .align 16 +_S02: + .word 39072 + .word 38974 + .word 13074 + .word 53901 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _S02,@object + .size _S02,16 + .align 16 +_S12: + .word 13864 + .word 61389 + .word 41932 + .word 43701 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _S12,@object + .size _S12,16 + .align 16 +_S08: + .word 6565 + .word 12686 + .word 39772 + .word 32901 + .word 49149 + .word 0 + .word 0 + .word 0 + .type _S08,@object + .size _S08,16 + .align 16 +_S04: + .word 60211 + .word 16071 + .word 37206 + .word 35465 + .word 49150 + .word 0 + .word 0 + .word 0 + .type _S04,@object + .size _S04,16 + .align 16 +_A: + .long 0 + .long 1074790400 + .long 0 + .long 1075838976 + .long 0 + .long 1076887552 + .long 0 + .long 1077936128 + .long 0 + .long 1078984704 + .long 0 + .long 1080033280 + .long 0 + .long 1081081856 + .type _A,@object + .size _A,56 + .space 8, 0x00 # pad + .align 16 +_B: + .long 0 + .long 1070596096 + .long 0 + .long 1069547520 + .long 0 + .long 1068498944 + .long 0 + .long 1067450368 + .long 0 + .long 1066401792 + .long 0 + .long 1065353216 + .long 0 + .long 1064304640 + .type _B,@object + .size _B,56 + .space 8, 0x00 # pad + .align 16 +_C5: + .word 65250 + .word 31226 + .word 64195 + .word 51294 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 2062 + .word 11523 + .word 15490 + .word 40735 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 32754 + .word 31980 + .word 31403 + .word 49421 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 43174 + .word 39951 + .word 44282 + .word 37916 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 17740 + .word 24638 + .word 31711 + .word 45907 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 40119 + .word 37337 + .word 13155 + .word 65076 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 17604 + .word 23486 + .word 20029 + .word 41172 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 33185 + .word 5727 + .word 44714 + .word 50187 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 59315 + .word 25153 + .word 8859 + .word 35740 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 56975 + .word 59828 + .word 57702 + .word 65082 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 44451 + .word 24185 + .word 18874 + .word 60288 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 63603 + .word 63450 + .word 63770 + .word 55108 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 29224 + .word 39171 + .word 38378 + .word 49676 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 11522 + .word 59843 + .word 6225 + .word 34695 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 52920 + .word 16467 + .word 35974 + .word 40266 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 32911 + .word 20526 + .word 49212 + .word 40083 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 50633 + .word 19120 + .word 5716 + .word 64631 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 27278 + .word 20509 + .word 60679 + .word 63371 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 47711 + .word 23018 + .word 38994 + .word 51179 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 57200 + .word 35818 + .word 16826 + .word 37630 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 2413 + .word 19605 + .word 64315 + .word 49218 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 41670 + .word 6403 + .word 34702 + .word 40993 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 6011 + .word 2134 + .word 32659 + .word 52266 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42605 + .word 32107 + .word 35187 + .word 43545 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 3574 + .word 60450 + .word 45882 + .word 53610 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 2808 + .word 20835 + .word 5027 + .word 56256 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 3021 + .word 28181 + .word 33636 + .word 39028 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 14493 + .word 33433 + .word 18281 + .word 35725 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 39323 + .word 51299 + .word 2596 + .word 32961 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 28336 + .word 24032 + .word 53553 + .word 44237 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 52853 + .word 63658 + .word 36534 + .word 41882 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 47917 + .word 51227 + .word 19034 + .word 54081 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 51044 + .word 31166 + .word 18963 + .word 37856 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 35962 + .word 40199 + .word 871 + .word 65049 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 39889 + .word 54182 + .word 40011 + .word 55797 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 29169 + .word 47361 + .word 8730 + .word 38268 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 39706 + .word 37143 + .word 20168 + .word 33289 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 16433 + .word 42895 + .word 21426 + .word 43820 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 1625 + .word 9463 + .word 65082 + .word 51468 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 58247 + .word 1594 + .word 2790 + .word 48648 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 20868 + .word 31765 + .word 34026 + .word 33401 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 23737 + .word 4448 + .word 39427 + .word 52225 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 3456 + .word 40222 + .word 65015 + .word 38939 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 35551 + .word 41260 + .word 40325 + .word 54131 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 8973 + .word 47485 + .word 2472 + .word 41842 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 43053 + .word 31703 + .word 19755 + .word 33274 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36731 + .word 27611 + .word 11212 + .word 55816 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 63893 + .word 30149 + .word 45246 + .word 60594 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 47198 + .word 37666 + .word 57801 + .word 61119 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 25856 + .word 56265 + .word 35798 + .word 40402 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 6470 + .word 34102 + .word 54471 + .word 38654 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 9295 + .word 39366 + .word 17179 + .word 34081 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 45822 + .word 31766 + .word 42784 + .word 47587 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 5059 + .word 11140 + .word 37473 + .word 43359 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 58055 + .word 60744 + .word 5900 + .word 57832 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 38212 + .word 45613 + .word 58947 + .word 40054 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 7938 + .word 56610 + .word 27106 + .word 34591 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 32824 + .word 16764 + .word 60057 + .word 56720 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 10908 + .word 30532 + .word 62164 + .word 40510 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 63750 + .word 13029 + .word 27501 + .word 34026 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 33477 + .word 11068 + .word 13144 + .word 46215 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 42530 + .word 57434 + .word 58521 + .word 52671 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 18986 + .word 9605 + .word 39740 + .word 51163 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 28928 + .word 13634 + .word 42974 + .word 34196 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 35215 + .word 30142 + .word 47225 + .word 54824 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 28719 + .word 4316 + .word 52012 + .word 39873 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 4508 + .word 8703 + .word 27075 + .word 56773 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 26288 + .word 30246 + .word 8808 + .word 42848 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 44455 + .word 3575 + .word 25942 + .word 45691 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2794 + .word 62330 + .word 8461 + .word 63853 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 21479 + .word 44765 + .word 7865 + .word 64840 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 31874 + .word 33681 + .word 56423 + .word 65041 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 21473 + .word 44172 + .word 64358 + .word 41494 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 32222 + .word 10523 + .word 55592 + .word 40956 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 21434 + .word 30837 + .word 63797 + .word 34911 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 39649 + .word 32992 + .word 36682 + .word 50257 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 13095 + .word 39473 + .word 7384 + .word 44359 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 31843 + .word 64809 + .word 59872 + .word 60895 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 8672 + .word 5021 + .word 16314 + .word 40945 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 39714 + .word 18801 + .word 4723 + .word 36324 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 614 + .word 42734 + .word 5731 + .word 57950 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 64434 + .word 24821 + .word 2679 + .word 42435 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 12194 + .word 23846 + .word 20957 + .word 34750 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 10830 + .word 21930 + .word 2400 + .word 48308 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 22166 + .word 52453 + .word 43476 + .word 53777 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 47257 + .word 46311 + .word 24367 + .word 53391 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 54217 + .word 40926 + .word 61378 + .word 34907 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 63951 + .word 56465 + .word 60729 + .word 57145 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 26614 + .word 13946 + .word 18662 + .word 40698 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 1838 + .word 12847 + .word 15941 + .word 59142 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 4759 + .word 49273 + .word 38799 + .word 43731 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 26568 + .word 56798 + .word 57629 + .word 34217 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25804 + .word 39657 + .word 51638 + .word 34652 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 2771 + .word 24731 + .word 11874 + .word 33806 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 19474 + .word 34269 + .word 14010 + .word 33912 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 56824 + .word 53459 + .word 23053 + .word 42279 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 18742 + .word 13031 + .word 52011 + .word 42483 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 5937 + .word 64580 + .word 50859 + .word 35501 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 23055 + .word 38603 + .word 6524 + .word 51938 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 3664 + .word 27625 + .word 50793 + .word 45121 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 52489 + .word 3557 + .word 32438 + .word 62735 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 894 + .word 16203 + .word 51477 + .word 42152 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 34963 + .word 47118 + .word 6430 + .word 37322 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 26422 + .word 42936 + .word 42081 + .word 58310 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 13130 + .word 21399 + .word 54693 + .word 43505 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 30323 + .word 50910 + .word 30337 + .word 35076 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 38115 + .word 10576 + .word 10000 + .word 49442 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 37599 + .word 18432 + .word 63354 + .word 54317 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 58822 + .word 42699 + .word 64187 + .word 54575 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 64288 + .word 61574 + .word 23831 + .word 35266 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 11805 + .word 33285 + .word 40274 + .word 58365 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 20167 + .word 739 + .word 36989 + .word 41119 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 62447 + .word 46690 + .word 58491 + .word 60379 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 1463 + .word 47000 + .word 35484 + .word 44185 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 64817 + .word 40328 + .word 40776 + .word 61320 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60250 + .word 42976 + .word 52322 + .word 36598 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 26918 + .word 53639 + .word 1629 + .word 34777 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 192 + .word 43979 + .word 65472 + .word 34978 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 52261 + .word 56023 + .word 49807 + .word 42881 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 1627 + .word 46939 + .word 43260 + .word 43630 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 60557 + .word 13735 + .word 20430 + .word 35946 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 37731 + .word 15708 + .word 47147 + .word 53188 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 21753 + .word 29315 + .word 41089 + .word 45691 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 6001 + .word 56966 + .word 64901 + .word 64096 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 60203 + .word 9392 + .word 60017 + .word 43055 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 63698 + .word 8838 + .word 668 + .word 38058 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 63354 + .word 11979 + .word 38628 + .word 58569 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 14495 + .word 23154 + .word 18917 + .word 44293 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 21391 + .word 34042 + .word 43308 + .word 35313 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 19364 + .word 56057 + .word 34969 + .word 50274 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 24688 + .word 56191 + .word 53239 + .word 54710 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 29387 + .word 5660 + .word 12964 + .word 55444 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 35686 + .word 64227 + .word 46433 + .word 35526 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 36666 + .word 59843 + .word 47733 + .word 59258 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 36678 + .word 17293 + .word 20572 + .word 41425 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 18431 + .word 63251 + .word 49151 + .word 61285 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 60545 + .word 37455 + .word 56348 + .word 44514 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 37261 + .word 1613 + .word 29792 + .word 57954 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15271 + .word 17124 + .word 50042 + .word 38057 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 7933 + .word 60764 + .word 31972 + .word 35498 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 36698 + .word 903 + .word 21735 + .word 35834 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 61921 + .word 64342 + .word 37428 + .word 43367 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 25723 + .word 57108 + .word 17005 + .word 44538 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 55361 + .word 30601 + .word 552 + .word 36302 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 60144 + .word 14680 + .word 32635 + .word 54172 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 56958 + .word 12456 + .word 10479 + .word 46147 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 483 + .word 34108 + .word 14727 + .word 65164 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 43794 + .word 49057 + .word 50532 + .word 43789 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 12225 + .word 29228 + .word 35085 + .word 38633 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 54219 + .word 64754 + .word 11030 + .word 58760 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 52932 + .word 63137 + .word 8758 + .word 44908 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 27270 + .word 37632 + .word 62601 + .word 35495 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 53773 + .word 63879 + .word 47305 + .word 50923 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 29965 + .word 53650 + .word 14162 + .word 55014 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 10444 + .word 24307 + .word 52989 + .word 56120 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 12949 + .word 6021 + .word 2059 + .word 35728 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 41140 + .word 26313 + .word 26076 + .word 59954 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 53675 + .word 12584 + .word 54309 + .word 41661 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 28849 + .word 13964 + .word 11627 + .word 61991 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 33057 + .word 63851 + .word 41026 + .word 44769 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 61939 + .word 60366 + .word 37868 + .word 56319 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _C5,@object + .size _C5,2688 + .align 16 +_C4: + .word 39764 + .word 13333 + .word 46799 + .word 55432 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 6306 + .word 35111 + .word 59607 + .word 63624 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 40772 + .word 10749 + .word 40067 + .word 48311 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 17977 + .word 41258 + .word 10043 + .word 63023 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 17757 + .word 54940 + .word 38650 + .word 52104 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 36152 + .word 14316 + .word 50442 + .word 43322 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 48990 + .word 25502 + .word 42020 + .word 58640 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 57431 + .word 49505 + .word 17362 + .word 46284 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 34483 + .word 2420 + .word 54299 + .word 50782 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 37575 + .word 3091 + .word 26415 + .word 50860 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 5185 + .word 25440 + .word 63351 + .word 37946 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 37934 + .word 12918 + .word 47534 + .word 41618 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 59537 + .word 51974 + .word 16286 + .word 51369 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 31611 + .word 51820 + .word 58572 + .word 58708 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 57757 + .word 54077 + .word 23114 + .word 64558 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 63584 + .word 48263 + .word 62815 + .word 37616 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 281 + .word 14439 + .word 46939 + .word 38182 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 63169 + .word 10307 + .word 53265 + .word 44896 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 22654 + .word 54923 + .word 22649 + .word 42855 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 37607 + .word 64061 + .word 25856 + .word 50581 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 47296 + .word 11647 + .word 64103 + .word 45853 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 30544 + .word 55384 + .word 11467 + .word 54194 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 39553 + .word 55407 + .word 30581 + .word 33698 + .word 49111 + .word 0 + .word 0 + .word 0 + .type _C4,@object + .size _C4,368 + .align 16 +_C3: + .word 28854 + .word 1182 + .word 12345 + .word 55415 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 12848 + .word 12413 + .word 26149 + .word 42266 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 13313 + .word 43952 + .word 210 + .word 35312 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 13187 + .word 60452 + .word 5475 + .word 43161 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 20972 + .word 51120 + .word 32272 + .word 61954 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 22296 + .word 60123 + .word 44502 + .word 16231 + .word 21517 + .word 49855 + .word 35525 + .word 48979 + .word 44698 + .word 63620 + .word 45930 + .word 16192 + .word 34147 + .word 51190 + .word 16340 + .word 48941 + .word 42301 + .word 55313 + .word 4730 + .word 16154 + .word 35999 + .word 24973 + .word 36325 + .word 48903 + .word 63277 + .word 55760 + .word 33014 + .word 16117 + .word 6314 + .word 46281 + .word 52205 + .word 48867 + .word 12513 + .word 17037 + .word 21130 + .word 16082 + .word 49946 + .word 1999 + .word 4813 + .word 48833 + .word 595 + .word 34534 + .word 265 + .word 16049 + .word 36690 + .word 64093 + .word 7546 + .word 48800 + .type _C3,@object + .size _C3,176 + .align 16 +_LM: + .word 64512 + .word 46577 + .word 49946 + .word 47894 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _LM,@object + .size _LM,16 + .align 16 +_LGAMMA_C2: + .word 3599 + .word 7250 + .word 52710 + .word 63693 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 31159 + .word 473 + .word 17060 + .word 35466 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 23705 + .word 29125 + .word 24135 + .word 63417 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 8259 + .word 13793 + .word 15470 + .word 38689 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 1592 + .word 43035 + .word 5286 + .word 33882 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 34241 + .word 35161 + .word 18170 + .word 34381 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 17215 + .word 38817 + .word 26343 + .word 16274 + .word 43407 + .word 38166 + .word 8095 + .word 49029 + .word 9256 + .word 10755 + .word 64736 + .word 16248 + .word 19293 + .word 8064 + .word 12058 + .word 49006 + .word 55284 + .word 28504 + .word 33554 + .word 16226 + .word 50892 + .word 40251 + .word 63876 + .word 48982 + .word 34903 + .word 32886 + .word 50950 + .word 16204 + .word 5270 + .word 55866 + .word 9779 + .word 48962 + .word 8284 + .word 46907 + .word 3681 + .word 16183 + .word 12968 + .word 35363 + .word 2442 + .word 48942 + .word 52637 + .word 49970 + .word 50463 + .word 16163 + .word 28134 + .word 34361 + .word 26628 + .word 48914 + .type _LGAMMA_C2,@object + .size _LGAMMA_C2,192 + .align 16 +_C1: + .word 51111 + .word 32176 + .word 26595 + .word 37828 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 38980 + .word 38974 + .word 13074 + .word 53901 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30416 + .word 21910 + .word 43743 + .word 52518 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 47709 + .word 16075 + .word 37206 + .word 35465 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 15719 + .word 21694 + .word 57533 + .word 54364 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 13628 + .word 45309 + .word 46092 + .word 16325 + .word 18814 + .word 7557 + .word 28730 + .word 49090 + .word 30522 + .word 27866 + .word 4275 + .word 16320 + .word 35905 + .word 26356 + .word 32871 + .word 49084 + .word 38506 + .word 60969 + .word 40989 + .word 16313 + .word 18199 + .word 53198 + .word 18595 + .word 49079 + .word 21817 + .word 41319 + .word 22094 + .word 16309 + .word 3261 + .word 2506 + .word 46646 + .word 49075 + .word 41261 + .word 44393 + .word 26269 + .word 16306 + .word 45347 + .word 5923 + .word 3109 + .word 49073 + .word 3843 + .word 55608 + .word 31192 + .word 16299 + .word 33944 + .word 58380 + .word 1271 + .word 49050 + .type _C1,@object + .size _C1,176 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xc3300000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x40080000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 4 +.L_2il0floatpacket.8: + .long 0x3f800000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_S26: + .long 1826776023 + .long 1070820717 + .type _S26,@object + .size _S26,8 + .align 4 +_S22: + .long 342869935 + .long 3214497781 + .type _S22,@object + .size _S22,8 + .align 4 +_S18: + .long 1060196486 + .long 3216761200 + .type _S18,@object + .size _S18,8 + .align 4 +_S14: + .long 3265047626 + .long 3217180894 + .type _S14,@object + .size _S14,8 + .align 4 +_W4: + .long 381774871 + .long 3211182444 + .type _W4,@object + .size _W4,8 + .align 4 +_S28: + .long 2468013457 + .long 3218873328 + .type _S28,@object + .size _S28,8 + .align 4 +_S24: + .long 3872164012 + .long 3218225849 + .type _S24,@object + .size _S24,8 + .align 4 +_S20: + .long 1339685656 + .long 3216855407 + .type _S20,@object + .size _S20,8 + .align 4 +_S16: + .long 618803264 + .long 3217033139 + .type _S16,@object + .size _S16,8 + .align 4 +_PBIG: + .long 4294967295 + .long 2146435071 + .type _PBIG,@object + .size _PBIG,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lgammaf.S b/external/sgx_libm/intel64/lgammaf.S new file mode 100644 index 0000000000..dadd3618b9 --- /dev/null +++ b/external/sgx_libm/intel64/lgammaf.S @@ -0,0 +1,6068 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lgammaf.c" + .text +..TXTST0: +# -- Begin lgammaf + .text + .align 16,0x90 + .globl lgammaf +lgammaf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_lgammaf.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $120, %rsp + .cfi_def_cfa_offset 176 + xorb %r12b, %r12b + movss %xmm0, 112(%rsp) + xorb %bpl, %bpl + movzwl 114(%rsp), %r15d + andl $32640, %r15d + movd %xmm0, %eax + shrl $7, %r15d + andl $8388607, %eax + movl %r15d, %r14d + shll $23, %r14d + movb 115(%rsp), %r13b + orl %eax, %r14d + andb $-128, %r13b +..B1.2: + fnstcw 110(%rsp) +..B1.3: +..___tag_value_lgammaf.16: + call fegetround@PLT +..___tag_value_lgammaf.17: +..B1.156: + movl %eax, %ebx +..B1.4: + testl %ebx, %ebx + je ..B1.6 +..B1.5: + xorl %edi, %edi + movb $1, %r12b +..___tag_value_lgammaf.18: + call fesetround@PLT +..___tag_value_lgammaf.19: +..B1.6: + movzwl 110(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.10 +..B1.7: + orl $-64768, %edx + movw %dx, 108(%rsp) +..B1.8: + fldcw 108(%rsp) +..B1.9: + movb $1, %bpl +..B1.10: + cmpl $255, %r15d + jne ..B1.16 +..B1.11: + testb %bpl, %bpl + je ..B1.13 +..B1.12: + fldcw 110(%rsp) +..B1.13: + testb %r12b, %r12b + je ..B1.15 +..B1.14: + movl %ebx, %edi +..___tag_value_lgammaf.20: + call fesetround@PLT +..___tag_value_lgammaf.21: +..B1.15: + movss 112(%rsp), %xmm0 + mulss %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.16: + testl %r14d, %r14d + je ..B1.149 +..B1.17: + testb %r13b, %r13b + jne ..B1.74 +..B1.18: + cmpl $2084876174, %r14d + jae ..B1.136 +..B1.19: + movss 112(%rsp), %xmm0 + ucomiss .L_2il0floatpacket.6(%rip), %xmm0 + jp ..B1.20 + je ..B1.131 +..B1.20: + cmpl $1174405120, %r14d + jb ..B1.26 +..B1.21: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm0, 56(%rsp) + pxor %xmm0, %xmm0 + flds 56(%rsp) + cvtss2sd 56(%rsp), %xmm0 + fsub %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fstps 32(%rsp) + fldt (%rax) + fstpt 16(%rsp) + call log@PLT +..B1.157: + fldt (%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fmull 56(%rsp) + fstpt (%rsp) + je ..B1.23 +..B1.22: + movl %ebx, %edi +..___tag_value_lgammaf.42: + call fesetround@PLT +..___tag_value_lgammaf.43: +..B1.23: + fldt (%rsp) + testb %bpl, %bpl + fldt 16(%rsp) + faddp %st, %st(1) + fsubs 32(%rsp) + fstps 104(%rsp) + je ..B1.124 +..B1.24: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.26: + cmpl $1082130432, %r14d + jb ..B1.33 +..B1.27: + addl $-1082130432, %r14d + lea _A(%rip), %rax + sarl $23, %r14d + lea _B(%rip), %rdx + movslq %r14d, %r14 + lea _C5(%rip), %r8 + movss %xmm0, 56(%rsp) + lea (,%r14,8), %ecx + flds 56(%rsp) + lea (%r14,%r14,2), %esi + movslq %ecx, %rcx + lea _C5_0(%rip), %r9 + movslq %esi, %rsi + testb %r12b, %r12b + fsubs (%rax,%r14,4) + fmuls (%rdx,%r14,4) + fld %st(0) + fmul %st(1), %st + fldl 8(%r8,%rcx,8) + fmul %st(1), %st + fldl (%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 40(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 32(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 8(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl (%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 56(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 48(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 24(%r8,%rcx,8) + fmulp %st, %st(3) + fxch %st(2) + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(2) + faddl 16(%r8,%rcx,8) + fmulp %st, %st(1) + faddl 16(%r9,%rsi,8) + fstpt (%rsp) + je ..B1.30 +..B1.28: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.44: + call fesetround@PLT +..___tag_value_lgammaf.45: +..B1.29: + fldt 80(%rsp) +..B1.30: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.31: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.33: + ucomiss .L_2il0floatpacket.4(%rip), %xmm0 + jp ..B1.34 + je ..B1.126 +..B1.34: + movss %xmm0, 56(%rsp) + cmpl $1073741824, %r14d + flds 56(%rsp) + jbe ..B1.40 +..B1.35: + fldt .L_2il0floatpacket.5(%rip) + fld %st(1) + lea _C4(%rip), %r9 + lea 8+_C4(%rip), %rax + fmul %st(2), %st + lea 32+_C4(%rip), %r10 + fldl (%rax) + lea 40+_C4(%rip), %rdx + fmul %st(1), %st + lea 64+_C4(%rip), %r11 + fldl (%r9) + lea 72+_C4(%rip), %rcx + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + lea 48+_C4(%rip), %r13 + lea 56+_C4(%rip), %rsi + fmul %st(2), %st + fxch %st(1) + faddl (%r11) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + lea 16+_C4(%rip), %r14 + lea 24+_C4(%rip), %r8 + fmul %st(2), %st + fxch %st(1) + faddl (%r13) + fmul %st(2), %st + fxch %st(1) + faddl (%r8) + lea 80+_C4(%rip), %r15 + testb %r12b, %r12b + fmul %st(4), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(3) + fsubrp %st, %st(4) + faddl (%r14) + fmulp %st, %st(1) + faddl (%r15) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.37 +..B1.36: + movl %ebx, %edi +..___tag_value_lgammaf.46: + call fesetround@PLT +..___tag_value_lgammaf.47: +..B1.37: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B1.124 +..B1.38: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.40: + cmpl $1071644672, %r14d + jb ..B1.47 +..B1.41: + fld %st(0) + lea 16+_C3(%rip), %rax + fmul %st(1), %st + lea 48+_C3(%rip), %rdx + fldl (%rax) + lea 32+_C3(%rip), %rcx + fmul %st(1), %st + lea 64+_C3(%rip), %rsi + lea 8+_C3(%rip), %r8 + lea 40+_C3(%rip), %r9 + lea 24+_C3(%rip), %r10 + lea 56+_C3(%rip), %r11 + lea _C3(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B1.44 +..B1.42: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.48: + call fesetround@PLT +..___tag_value_lgammaf.49: +..B1.43: + fldt 80(%rsp) +..B1.44: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.45: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.47: + cmpl $1069547520, %r14d + jb ..B1.54 +..B1.48: + fld %st(0) + lea 16+_LGAMMAF_C2(%rip), %rax + fmul %st(1), %st + lea 48+_LGAMMAF_C2(%rip), %rdx + fldl (%rax) + lea 32+_LGAMMAF_C2(%rip), %rcx + fmul %st(1), %st + lea 64+_LGAMMAF_C2(%rip), %rsi + lea 8+_LGAMMAF_C2(%rip), %r8 + lea 40+_LGAMMAF_C2(%rip), %r9 + lea 24+_LGAMMAF_C2(%rip), %r10 + lea 56+_LGAMMAF_C2(%rip), %r11 + lea _LGAMMAF_C2(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B1.51 +..B1.49: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.50: + call fesetround@PLT +..___tag_value_lgammaf.51: +..B1.50: + fldt 80(%rsp) +..B1.51: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.52: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.54: + cmpl $1067450368, %r14d + jb ..B1.61 +..B1.55: + lea _LM(%rip), %rax + lea 16+_C1(%rip), %rdx + lea 48+_C1(%rip), %rcx + lea 32+_C1(%rip), %rsi + lea 64+_C1(%rip), %r8 + lea 8+_C1(%rip), %r9 + lea 40+_C1(%rip), %r10 + lea 24+_C1(%rip), %r11 + fldl (%rdx) + lea 56+_C1(%rip), %r13 + lea _C1(%rip), %r14 + testb %r12b, %r12b + fxch %st(1) + fsubl (%rax) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(2) + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmulp %st, %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmul %st(2), %st + faddl (%r13) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r14) + fstpt (%rsp) + je ..B1.58 +..B1.56: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.52: + call fesetround@PLT +..___tag_value_lgammaf.53: +..B1.57: + fldt 80(%rsp) +..B1.58: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.59: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.61: + cmpl $1065353216, %r14d + jb ..B1.68 +..B1.62: + fld %st(0) + lea 16+_C0(%rip), %rax + fmul %st(1), %st + lea 48+_C0(%rip), %rdx + fldl (%rax) + lea 32+_C0(%rip), %rcx + fmul %st(1), %st + lea 64+_C0(%rip), %rsi + lea 8+_C0(%rip), %r8 + lea 40+_C0(%rip), %r9 + lea 24+_C0(%rip), %r10 + lea 56+_C0(%rip), %r11 + lea _C0(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B1.65 +..B1.63: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.54: + call fesetround@PLT +..___tag_value_lgammaf.55: +..B1.64: + fldt 80(%rsp) +..B1.65: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.66: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.68: + fldt .L_2il0floatpacket.0(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fadd %st(1), %st + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value_lgammaf.57: + call lgammaf_pos +..___tag_value_lgammaf.58: +..B1.159: + fldt 32(%rsp) + fxch %st(1) + fstpt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B1.158: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + je ..B1.71 +..B1.69: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.60: + call fesetround@PLT +..___tag_value_lgammaf.61: +..B1.70: + fldt 80(%rsp) +..B1.71: + fldt (%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.72: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.74: + movss 112(%rsp), %xmm0 + call nearbyintf@PLT +..B1.160: + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm1 + movss 112(%rsp), %xmm4 + ucomiss %xmm1, %xmm4 + jp ..B1.75 + je ..B1.144 +..B1.75: + cmpl $1073741824, %r14d + jae ..B1.86 +..B1.76: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm4, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B1.141 + jp ..B1.141 +..B1.77: + fldt 16(%rsp) +..B1.78: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B1.79 + jb ..B1.78 +..B1.79: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B1.80: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B1.162: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_lgammaf.63: + call lgammaf_pos +..___tag_value_lgammaf.64: +..B1.161: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B1.83 +..B1.81: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.66: + call fesetround@PLT +..___tag_value_lgammaf.67: +..B1.82: + fldt 80(%rsp) +..B1.83: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.84: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.86: + cmpl $1082130432, %r14d + jae ..B1.103 +..B1.87: + movss .L_2il0floatpacket.2(%rip), %xmm0 + lea _LRIB(%rip), %rdx + movss .L_2il0floatpacket.3(%rip), %xmm2 + subss %xmm4, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm1 + addss %xmm2, %xmm1 + movss %xmm1, 104(%rsp) + pxor %xmm1, %xmm1 + cvtss2sd %xmm4, %xmm1 + movl 104(%rsp), %ecx + andl $1, %ecx + movss 104(%rsp), %xmm3 + subss %xmm2, %xmm3 + movss %xmm3, 104(%rsp) + lea (%rcx,%rcx,2), %eax + comisd (%rdx,%rax,8), %xmm1 + jbe ..B1.90 +..B1.88: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B1.90 +..B1.89: + movss %xmm4, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _LRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B1.98 +..B1.90: + lea _RRIB(%rip), %rdx + comisd (%rdx,%rax,8), %xmm1 + jbe ..B1.93 +..B1.91: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B1.93 +..B1.92: + movss %xmm4, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _RRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B1.98 +..B1.93: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm4, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt (%rsp) + fldt (%rsp) + fcomip %st(2), %st + jae ..B1.142 + jp ..B1.142 +..B1.94: + fldt (%rsp) +..B1.95: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B1.96 + jb ..B1.95 +..B1.96: + fstp %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 80(%rsp) +..B1.97: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B1.164: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstl 16(%rsp) + fstpt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 16(%rsp) + fstpt (%rsp) +..___tag_value_lgammaf.69: + call lgammaf_pos +..___tag_value_lgammaf.70: +..B1.163: + addq $16, %rsp + .cfi_def_cfa_offset 176 + fsubl 16(%rsp) + fstpt (%rsp) +..B1.98: + testb %r12b, %r12b + je ..B1.100 +..B1.99: + movl %ebx, %edi +..___tag_value_lgammaf.72: + call fesetround@PLT +..___tag_value_lgammaf.73: +..B1.100: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B1.124 +..B1.101: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.103: + cmpl $1091567616, %r14d + jae ..B1.114 +..B1.104: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm4, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B1.143 + jp ..B1.143 +..B1.105: + fldt 16(%rsp) +..B1.106: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B1.107 + jb ..B1.106 +..B1.107: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B1.108: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B1.166: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_lgammaf.75: + call lgammaf_pos +..___tag_value_lgammaf.76: +..B1.165: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B1.111 +..B1.109: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf.78: + call fesetround@PLT +..___tag_value_lgammaf.79: +..B1.110: + fldt 80(%rsp) +..B1.111: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.112: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.114: + cmpl $1174405120, %r14d + jb ..B1.120 +..B1.115: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm4, 56(%rsp) + flds 56(%rsp) + fsts (%rsp) + fsub %st, %st(1) + fxch %st(1) + fstpt 8(%rsp) + fchs + fstl 96(%rsp) + movsd 96(%rsp), %xmm0 + fstpt 40(%rsp) + fldt (%rax) + fstpt 24(%rsp) + call log@PLT +..B1.168: + fldt 8(%rsp) + lea _S16(%rip), %rax + fldt 24(%rsp) + lea _S14(%rip), %rdx + fldt 40(%rsp) + lea _S12(%rip), %rcx + movss .L_2il0floatpacket.3(%rip), %xmm2 + lea _S10(%rip), %rsi + fldl (%rax) + lea _S08(%rip), %r8 + movss %xmm2, 104(%rsp) + lea _S06(%rip), %r9 + movss 104(%rsp), %xmm1 + lea _S04(%rip), %r10 + movsd %xmm0, 56(%rsp) + lea _S02(%rip), %r11 + fxch %st(3) + fmull 56(%rsp) + subss 112(%rsp), %xmm1 + fsubp %st, %st(2) + movss %xmm1, 104(%rsp) + movss 104(%rsp), %xmm3 + fxch %st(1) + fsubs (%rsp) + subss %xmm2, %xmm3 + movss %xmm3, 104(%rsp) + movss 104(%rsp), %xmm4 + movss %xmm4, 56(%rsp) + fxch %st(1) + fsubs 56(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fmul %st, %st(2) + andb $127, 73(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + fxch %st(2) + faddl (%rdx) + fmul %st(2), %st + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + call log@PLT +..B1.167: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + je ..B1.117 +..B1.116: + movl %ebx, %edi + fstpl (%rsp) +..___tag_value_lgammaf.80: + call fesetround@PLT +..___tag_value_lgammaf.81: +..B1.172: + fldl (%rsp) +..B1.117: + fldt 8(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.118: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.120: + flds 112(%rsp) + movss .L_2il0floatpacket.3(%rip), %xmm1 + fchs + movaps %xmm1, %xmm0 + fstl 96(%rsp) + subss %xmm4, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm2 + movsd 96(%rsp), %xmm0 + subss %xmm1, %xmm2 + movss %xmm2, 104(%rsp) + movss 104(%rsp), %xmm3 + movss %xmm3, 56(%rsp) + fstpt 40(%rsp) + fldt 40(%rsp) + flds 56(%rsp) + fsubrp %st, %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fstpt 24(%rsp) + call log@PLT +..B1.171: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fchs + fldt 56(%rsp) + fstpt (%rsp) + fstpt 24(%rsp) +..___tag_value_lgammaf.83: + call lgammaf_pos +..___tag_value_lgammaf.84: +..B1.170: + fldt 24(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fldt 24(%rsp) + lea _S14(%rip), %rax + fld %st(0) + lea _S16(%rip), %r8 + fmul %st(1), %st + lea _S10(%rip), %rdx + fxch %st(3) + fsubrp %st, %st(2) + fldl (%rax) + lea _S12(%rip), %r9 + fmul %st(3), %st + lea _S06(%rip), %rcx + fldl (%r8) + lea _S08(%rip), %r10 + fmul %st(4), %st + fxch %st(1) + faddl (%rdx) + fmul %st(4), %st + fxch %st(1) + faddl (%r9) + fmul %st(4), %st + fxch %st(1) + faddl (%rcx) + fmul %st(4), %st + fxch %st(1) + faddl (%r10) + fmul %st(4), %st + lea _S02(%rip), %rsi + fxch %st(1) + faddl (%rsi) + lea _S04(%rip), %r11 + fmulp %st, %st(2) + faddl (%r11) + fmulp %st, %st(3) + andb $127, 73(%rsp) + faddp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B1.169: + fldt 8(%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + je ..B1.122 +..B1.121: + movl %ebx, %edi + fstpl (%rsp) + fstpt 8(%rsp) +..___tag_value_lgammaf.86: + call fesetround@PLT +..___tag_value_lgammaf.87: +..B1.173: + fldt 8(%rsp) + fldl (%rsp) +..B1.122: + testb %bpl, %bpl + fsubrp %st, %st(1) + fstps 104(%rsp) + je ..B1.124 +..B1.123: + fldcw 110(%rsp) +..B1.124: + movss 104(%rsp), %xmm0 +..B1.125: + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.126: + testb %bpl, %bpl + je ..B1.128 +..B1.127: + fldcw 110(%rsp) +..B1.128: + testb %r12b, %r12b + je ..B1.130 +..B1.129: + movl %ebx, %edi +..___tag_value_lgammaf.108: + call fesetround@PLT +..___tag_value_lgammaf.109: +..B1.130: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.131: + testb %bpl, %bpl + je ..B1.133 +..B1.132: + fldcw 110(%rsp) +..B1.133: + testb %r12b, %r12b + je ..B1.135 +..B1.134: + movl %ebx, %edi +..___tag_value_lgammaf.130: + call fesetround@PLT +..___tag_value_lgammaf.131: +..B1.135: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.136: + testb %r12b, %r12b + je ..B1.138 +..B1.137: + movl %ebx, %edi +..___tag_value_lgammaf.152: + call fesetround@PLT +..___tag_value_lgammaf.153: +..B1.138: + lea _PBIG(%rip), %rax + testb %bpl, %bpl + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 104(%rsp) + je ..B1.124 +..B1.139: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.141: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B1.80 +..B1.142: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B1.97 +..B1.143: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B1.108 +..B1.144: + testb %r12b, %r12b + je ..B1.146 +..B1.145: + movl %ebx, %edi +..___tag_value_lgammaf.154: + call fesetround@PLT +..___tag_value_lgammaf.155: +..B1.146: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B1.124 +..B1.147: + fldcw 110(%rsp) + jmp ..B1.124 +..B1.149: + testb %r12b, %r12b + je ..B1.151 +..B1.150: + movl %ebx, %edi +..___tag_value_lgammaf.156: + call fesetround@PLT +..___tag_value_lgammaf.157: +..B1.151: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B1.124 +..B1.152: + fldcw 110(%rsp) + jmp ..B1.124 + .align 16,0x90 + .cfi_endproc + .type lgammaf,@function + .size lgammaf,.-lgammaf + .data +# -- End lgammaf + .text +# -- Begin lgammaf_pos + .text + .align 16,0x90 +lgammaf_pos: +# parameter 1: 8 + %rsp +..B2.1: + .cfi_startproc +..___tag_value_lgammaf_pos.159: +..L160: + + fldt 8(%rsp) + fstl -8(%rsp) + fldt .L_2il0floatpacket.7(%rip) + movzwl -2(%rsp), %ecx + andl $32752, %ecx + shrl $4, %ecx + movl -4(%rsp), %eax + shll $20, %ecx + andl $1048575, %eax + orl %eax, %ecx + cmpl $1074790400, %ecx + jb ..B2.3 +..B2.2: + fstp %st(0) + addl $-1074790400, %ecx + lea _A(%rip), %rax + sarl $20, %ecx + lea _B(%rip), %rdx + movslq %ecx, %rcx + lea _C5(%rip), %r9 + lea _C5_0(%rip), %r8 + lea (,%rcx,8), %esi + movslq %esi, %rsi + lea (%rcx,%rcx,2), %edi + movslq %edi, %rdi + flds (%rax,%rcx,4) + fsubrp %st, %st(1) + fmuls (%rdx,%rcx,4) + fld %st(0) + fmul %st(1), %st + fldl (%r9,%rsi,8) + fmul %st(1), %st + fldl 8(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 32(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 40(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl (%r8,%rdi,8) + fmul %st(2), %st + fxch %st(1) + faddl 8(%r8,%rdi,8) + fmul %st(2), %st + fxch %st(1) + faddl 48(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 56(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 16(%r9,%rsi,8) + fmulp %st, %st(2) + faddl 24(%r9,%rsi,8) + fmulp %st, %st(2) + faddl 16(%r8,%rdi,8) + faddp %st, %st(1) + ret +..B2.3: + cmpl $1073741824, %ecx + jne ..B2.5 +..B2.4: + fstp %st(1) + ret +..B2.5: + jbe ..B2.7 +..B2.6: + fstp %st(0) + fldt .L_2il0floatpacket.5(%rip) + fld %st(1) + lea _C4(%rip), %rax + lea 32+_C4(%rip), %rdx + fmul %st(2), %st + lea 8+_C4(%rip), %r9 + fldl (%rax) + lea 40+_C4(%rip), %r10 + lea 64+_C4(%rip), %rcx + lea 72+_C4(%rip), %r11 + lea 48+_C4(%rip), %rsi + lea 56+_C4(%rip), %rax + lea 16+_C4(%rip), %rdi + lea 80+_C4(%rip), %r8 + fmul %st(1), %st + fldl (%r9) + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + fmul %st(2), %st + fxch %st(1) + faddl (%r11) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + fmul %st(2), %st + fxch %st(1) + faddl (%rax) + fmul %st(2), %st + fxch %st(1) + faddl (%rdi) + lea 24+_C4(%rip), %rdx + fmulp %st, %st(2) + faddl (%rdx) + fmul %st(3), %st + fxch %st(1) + faddl (%r8) + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fmulp %st, %st(1) + ret +..B2.7: + cmpl $1073479680, %ecx + jb ..B2.9 +..B2.8: + fstp %st(0) + fld %st(0) + lea 8+_C3(%rip), %rax + lea 16+_C3(%rip), %r8 + lea 40+_C3(%rip), %rdx + lea 48+_C3(%rip), %r9 + lea 24+_C3(%rip), %rcx + lea 32+_C3(%rip), %r10 + lea 56+_C3(%rip), %rsi + lea 64+_C3(%rip), %r11 + lea _C3(%rip), %rdi + fmul %st(1), %st + fldl (%rax) + fmul %st(1), %st + fldl (%r8) + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r9) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + fmulp %st, %st(2) + faddl (%r11) + fmulp %st, %st(2) + faddl (%rdi) + faddp %st, %st(1) + ret +..B2.9: + cmpl $1073217536, %ecx + jb ..B2.11 +..B2.10: + fstp %st(0) + fld %st(0) + lea 8+_LGAMMAF_C2(%rip), %rax + lea 16+_LGAMMAF_C2(%rip), %r8 + lea 40+_LGAMMAF_C2(%rip), %rdx + lea 48+_LGAMMAF_C2(%rip), %r9 + lea 24+_LGAMMAF_C2(%rip), %rcx + lea 32+_LGAMMAF_C2(%rip), %r10 + lea 56+_LGAMMAF_C2(%rip), %rsi + lea 64+_LGAMMAF_C2(%rip), %r11 + lea _LGAMMAF_C2(%rip), %rdi + fmul %st(1), %st + fldl (%rax) + fmul %st(1), %st + fldl (%r8) + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r9) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + fmulp %st, %st(2) + faddl (%r11) + fmulp %st, %st(2) + faddl (%rdi) + faddp %st, %st(1) + ret +..B2.11: + cmpl $1072955392, %ecx + jb ..B2.13 +..B2.12: + fstp %st(0) + lea _LM(%rip), %rax + lea 8+_C1(%rip), %rdx + lea 16+_C1(%rip), %r9 + lea 40+_C1(%rip), %rcx + lea 48+_C1(%rip), %r10 + lea 24+_C1(%rip), %rsi + lea 32+_C1(%rip), %r11 + lea 56+_C1(%rip), %rdi + fldl (%rax) + lea 64+_C1(%rip), %rax + lea _C1(%rip), %r8 + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldl (%rdx) + fmul %st(1), %st + fldl (%r9) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + fmul %st(2), %st + fxch %st(1) + faddl (%r11) + fmul %st(2), %st + fxch %st(1) + faddl (%rdi) + fmulp %st, %st(2) + faddl (%rax) + fmulp %st, %st(2) + faddl (%r8) + faddp %st, %st(1) + ret +..B2.13: + cmpl $1072693248, %ecx + jb ..B2.4 +..B2.14: + fstp %st(0) + fld %st(0) + lea 8+_C0(%rip), %rax + lea 16+_C0(%rip), %r8 + lea 40+_C0(%rip), %rdx + lea 48+_C0(%rip), %r9 + lea 24+_C0(%rip), %rcx + lea 32+_C0(%rip), %r10 + lea 56+_C0(%rip), %rsi + lea 64+_C0(%rip), %r11 + lea _C0(%rip), %rdi + fmul %st(1), %st + fldl (%rax) + fmul %st(1), %st + fldl (%r8) + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r9) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + fmulp %st, %st(2) + faddl (%r11) + fmulp %st, %st(2) + faddl (%rdi) + faddp %st, %st(1) +..B2.15: + ret + .align 16,0x90 + .cfi_endproc + .type lgammaf_pos,@function + .size lgammaf_pos,.-lgammaf_pos + .data +# -- End lgammaf_pos + .text +# -- Begin gammaf + .text + .align 16,0x90 + .globl gammaf +gammaf: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value_gammaf.162: +..L163: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $120, %rsp + .cfi_def_cfa_offset 176 + xorb %r12b, %r12b + movss %xmm0, 112(%rsp) + xorb %bpl, %bpl + movzwl 114(%rsp), %r15d + andl $32640, %r15d + movd %xmm0, %eax + shrl $7, %r15d + andl $8388607, %eax + movl %r15d, %r14d + shll $23, %r14d + movb 115(%rsp), %r13b + orl %eax, %r14d + andb $-128, %r13b +..B3.2: + fnstcw 110(%rsp) +..B3.3: +..___tag_value_gammaf.177: + call fegetround@PLT +..___tag_value_gammaf.178: +..B3.156: + movl %eax, %ebx +..B3.4: + testl %ebx, %ebx + je ..B3.6 +..B3.5: + xorl %edi, %edi + movb $1, %r12b +..___tag_value_gammaf.179: + call fesetround@PLT +..___tag_value_gammaf.180: +..B3.6: + movzwl 110(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B3.10 +..B3.7: + orl $-64768, %edx + movw %dx, 108(%rsp) +..B3.8: + fldcw 108(%rsp) +..B3.9: + movb $1, %bpl +..B3.10: + cmpl $255, %r15d + jne ..B3.16 +..B3.11: + testb %bpl, %bpl + je ..B3.13 +..B3.12: + fldcw 110(%rsp) +..B3.13: + testb %r12b, %r12b + je ..B3.15 +..B3.14: + movl %ebx, %edi +..___tag_value_gammaf.181: + call fesetround@PLT +..___tag_value_gammaf.182: +..B3.15: + movss 112(%rsp), %xmm0 + mulss %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.16: + testl %r14d, %r14d + je ..B3.149 +..B3.17: + testb %r13b, %r13b + jne ..B3.74 +..B3.18: + cmpl $2084876174, %r14d + jae ..B3.136 +..B3.19: + movss 112(%rsp), %xmm0 + ucomiss .L_2il0floatpacket.6(%rip), %xmm0 + jp ..B3.20 + je ..B3.131 +..B3.20: + cmpl $1174405120, %r14d + jb ..B3.26 +..B3.21: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm0, 56(%rsp) + pxor %xmm0, %xmm0 + flds 56(%rsp) + cvtss2sd 56(%rsp), %xmm0 + fsub %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fstps 32(%rsp) + fldt (%rax) + fstpt 16(%rsp) + call log@PLT +..B3.157: + fldt (%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fmull 56(%rsp) + fstpt (%rsp) + je ..B3.23 +..B3.22: + movl %ebx, %edi +..___tag_value_gammaf.203: + call fesetround@PLT +..___tag_value_gammaf.204: +..B3.23: + fldt (%rsp) + testb %bpl, %bpl + fldt 16(%rsp) + faddp %st, %st(1) + fsubs 32(%rsp) + fstps 104(%rsp) + je ..B3.124 +..B3.24: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.26: + cmpl $1082130432, %r14d + jb ..B3.33 +..B3.27: + addl $-1082130432, %r14d + lea _A(%rip), %rax + sarl $23, %r14d + lea _B(%rip), %rdx + movslq %r14d, %r14 + lea _C5(%rip), %r8 + movss %xmm0, 56(%rsp) + lea (,%r14,8), %ecx + flds 56(%rsp) + lea (%r14,%r14,2), %esi + movslq %ecx, %rcx + lea _C5_0(%rip), %r9 + movslq %esi, %rsi + testb %r12b, %r12b + fsubs (%rax,%r14,4) + fmuls (%rdx,%r14,4) + fld %st(0) + fmul %st(1), %st + fldl 8(%r8,%rcx,8) + fmul %st(1), %st + fldl (%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 40(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 32(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 8(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl (%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 56(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 48(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 24(%r8,%rcx,8) + fmulp %st, %st(3) + fxch %st(2) + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(2) + faddl 16(%r8,%rcx,8) + fmulp %st, %st(1) + faddl 16(%r9,%rsi,8) + fstpt (%rsp) + je ..B3.30 +..B3.28: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.205: + call fesetround@PLT +..___tag_value_gammaf.206: +..B3.29: + fldt 80(%rsp) +..B3.30: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.31: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.33: + ucomiss .L_2il0floatpacket.4(%rip), %xmm0 + jp ..B3.34 + je ..B3.126 +..B3.34: + movss %xmm0, 56(%rsp) + cmpl $1073741824, %r14d + flds 56(%rsp) + jbe ..B3.40 +..B3.35: + fldt .L_2il0floatpacket.5(%rip) + fld %st(1) + lea _C4(%rip), %r9 + lea 8+_C4(%rip), %rax + fmul %st(2), %st + lea 32+_C4(%rip), %r10 + fldl (%rax) + lea 40+_C4(%rip), %rdx + fmul %st(1), %st + lea 64+_C4(%rip), %r11 + fldl (%r9) + lea 72+_C4(%rip), %rcx + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + lea 48+_C4(%rip), %r13 + lea 56+_C4(%rip), %rsi + fmul %st(2), %st + fxch %st(1) + faddl (%r11) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + lea 16+_C4(%rip), %r14 + lea 24+_C4(%rip), %r8 + fmul %st(2), %st + fxch %st(1) + faddl (%r13) + fmul %st(2), %st + fxch %st(1) + faddl (%r8) + lea 80+_C4(%rip), %r15 + testb %r12b, %r12b + fmul %st(4), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(3) + fsubrp %st, %st(4) + faddl (%r14) + fmulp %st, %st(1) + faddl (%r15) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B3.37 +..B3.36: + movl %ebx, %edi +..___tag_value_gammaf.207: + call fesetround@PLT +..___tag_value_gammaf.208: +..B3.37: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B3.124 +..B3.38: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.40: + cmpl $1071644672, %r14d + jb ..B3.47 +..B3.41: + fld %st(0) + lea 16+_C3(%rip), %rax + fmul %st(1), %st + lea 48+_C3(%rip), %rdx + fldl (%rax) + lea 32+_C3(%rip), %rcx + fmul %st(1), %st + lea 64+_C3(%rip), %rsi + lea 8+_C3(%rip), %r8 + lea 40+_C3(%rip), %r9 + lea 24+_C3(%rip), %r10 + lea 56+_C3(%rip), %r11 + lea _C3(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B3.44 +..B3.42: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.209: + call fesetround@PLT +..___tag_value_gammaf.210: +..B3.43: + fldt 80(%rsp) +..B3.44: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.45: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.47: + cmpl $1069547520, %r14d + jb ..B3.54 +..B3.48: + fld %st(0) + lea 16+_LGAMMAF_C2(%rip), %rax + fmul %st(1), %st + lea 48+_LGAMMAF_C2(%rip), %rdx + fldl (%rax) + lea 32+_LGAMMAF_C2(%rip), %rcx + fmul %st(1), %st + lea 64+_LGAMMAF_C2(%rip), %rsi + lea 8+_LGAMMAF_C2(%rip), %r8 + lea 40+_LGAMMAF_C2(%rip), %r9 + lea 24+_LGAMMAF_C2(%rip), %r10 + lea 56+_LGAMMAF_C2(%rip), %r11 + lea _LGAMMAF_C2(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B3.51 +..B3.49: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.211: + call fesetround@PLT +..___tag_value_gammaf.212: +..B3.50: + fldt 80(%rsp) +..B3.51: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.52: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.54: + cmpl $1067450368, %r14d + jb ..B3.61 +..B3.55: + lea _LM(%rip), %rax + lea 16+_C1(%rip), %rdx + lea 48+_C1(%rip), %rcx + lea 32+_C1(%rip), %rsi + lea 64+_C1(%rip), %r8 + lea 8+_C1(%rip), %r9 + lea 40+_C1(%rip), %r10 + lea 24+_C1(%rip), %r11 + fldl (%rdx) + lea 56+_C1(%rip), %r13 + lea _C1(%rip), %r14 + testb %r12b, %r12b + fxch %st(1) + fsubl (%rax) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(2) + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmulp %st, %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmul %st(2), %st + faddl (%r13) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r14) + fstpt (%rsp) + je ..B3.58 +..B3.56: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.213: + call fesetround@PLT +..___tag_value_gammaf.214: +..B3.57: + fldt 80(%rsp) +..B3.58: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.59: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.61: + cmpl $1065353216, %r14d + jb ..B3.68 +..B3.62: + fld %st(0) + lea 16+_C0(%rip), %rax + fmul %st(1), %st + lea 48+_C0(%rip), %rdx + fldl (%rax) + lea 32+_C0(%rip), %rcx + fmul %st(1), %st + lea 64+_C0(%rip), %rsi + lea 8+_C0(%rip), %r8 + lea 40+_C0(%rip), %r9 + lea 24+_C0(%rip), %r10 + lea 56+_C0(%rip), %r11 + lea _C0(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B3.65 +..B3.63: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.215: + call fesetround@PLT +..___tag_value_gammaf.216: +..B3.64: + fldt 80(%rsp) +..B3.65: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.66: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.68: + fldt .L_2il0floatpacket.0(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fadd %st(1), %st + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value_gammaf.218: + call lgammaf_pos +..___tag_value_gammaf.219: +..B3.159: + fldt 32(%rsp) + fxch %st(1) + fstpt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B3.158: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + je ..B3.71 +..B3.69: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.221: + call fesetround@PLT +..___tag_value_gammaf.222: +..B3.70: + fldt 80(%rsp) +..B3.71: + fldt (%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.72: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.74: + movss 112(%rsp), %xmm0 + call nearbyintf@PLT +..B3.160: + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm1 + movss 112(%rsp), %xmm4 + ucomiss %xmm1, %xmm4 + jp ..B3.75 + je ..B3.144 +..B3.75: + cmpl $1073741824, %r14d + jae ..B3.86 +..B3.76: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm4, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B3.141 + jp ..B3.141 +..B3.77: + fldt 16(%rsp) +..B3.78: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B3.79 + jb ..B3.78 +..B3.79: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B3.80: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B3.162: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_gammaf.224: + call lgammaf_pos +..___tag_value_gammaf.225: +..B3.161: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B3.83 +..B3.81: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.227: + call fesetround@PLT +..___tag_value_gammaf.228: +..B3.82: + fldt 80(%rsp) +..B3.83: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.84: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.86: + cmpl $1082130432, %r14d + jae ..B3.103 +..B3.87: + movss .L_2il0floatpacket.2(%rip), %xmm0 + lea _LRIB(%rip), %rdx + movss .L_2il0floatpacket.3(%rip), %xmm2 + subss %xmm4, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm1 + addss %xmm2, %xmm1 + movss %xmm1, 104(%rsp) + pxor %xmm1, %xmm1 + cvtss2sd %xmm4, %xmm1 + movl 104(%rsp), %ecx + andl $1, %ecx + movss 104(%rsp), %xmm3 + subss %xmm2, %xmm3 + movss %xmm3, 104(%rsp) + lea (%rcx,%rcx,2), %eax + comisd (%rdx,%rax,8), %xmm1 + jbe ..B3.90 +..B3.88: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B3.90 +..B3.89: + movss %xmm4, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _LRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B3.98 +..B3.90: + lea _RRIB(%rip), %rdx + comisd (%rdx,%rax,8), %xmm1 + jbe ..B3.93 +..B3.91: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B3.93 +..B3.92: + movss %xmm4, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _RRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B3.98 +..B3.93: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm4, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt (%rsp) + fldt (%rsp) + fcomip %st(2), %st + jae ..B3.142 + jp ..B3.142 +..B3.94: + fldt (%rsp) +..B3.95: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B3.96 + jb ..B3.95 +..B3.96: + fstp %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 80(%rsp) +..B3.97: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B3.164: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstl 16(%rsp) + fstpt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 16(%rsp) + fstpt (%rsp) +..___tag_value_gammaf.230: + call lgammaf_pos +..___tag_value_gammaf.231: +..B3.163: + addq $16, %rsp + .cfi_def_cfa_offset 176 + fsubl 16(%rsp) + fstpt (%rsp) +..B3.98: + testb %r12b, %r12b + je ..B3.100 +..B3.99: + movl %ebx, %edi +..___tag_value_gammaf.233: + call fesetround@PLT +..___tag_value_gammaf.234: +..B3.100: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B3.124 +..B3.101: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.103: + cmpl $1091567616, %r14d + jae ..B3.114 +..B3.104: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm4, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B3.143 + jp ..B3.143 +..B3.105: + fldt 16(%rsp) +..B3.106: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B3.107 + jb ..B3.106 +..B3.107: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B3.108: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B3.166: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_gammaf.236: + call lgammaf_pos +..___tag_value_gammaf.237: +..B3.165: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B3.111 +..B3.109: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf.239: + call fesetround@PLT +..___tag_value_gammaf.240: +..B3.110: + fldt 80(%rsp) +..B3.111: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.112: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.114: + cmpl $1174405120, %r14d + jb ..B3.120 +..B3.115: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm4, 56(%rsp) + flds 56(%rsp) + fsts (%rsp) + fsub %st, %st(1) + fxch %st(1) + fstpt 8(%rsp) + fchs + fstl 96(%rsp) + movsd 96(%rsp), %xmm0 + fstpt 40(%rsp) + fldt (%rax) + fstpt 24(%rsp) + call log@PLT +..B3.168: + fldt 8(%rsp) + lea _S16(%rip), %rax + fldt 24(%rsp) + lea _S14(%rip), %rdx + fldt 40(%rsp) + lea _S12(%rip), %rcx + movss .L_2il0floatpacket.3(%rip), %xmm2 + lea _S10(%rip), %rsi + fldl (%rax) + lea _S08(%rip), %r8 + movss %xmm2, 104(%rsp) + lea _S06(%rip), %r9 + movss 104(%rsp), %xmm1 + lea _S04(%rip), %r10 + movsd %xmm0, 56(%rsp) + lea _S02(%rip), %r11 + fxch %st(3) + fmull 56(%rsp) + subss 112(%rsp), %xmm1 + fsubp %st, %st(2) + movss %xmm1, 104(%rsp) + movss 104(%rsp), %xmm3 + fxch %st(1) + fsubs (%rsp) + subss %xmm2, %xmm3 + movss %xmm3, 104(%rsp) + movss 104(%rsp), %xmm4 + movss %xmm4, 56(%rsp) + fxch %st(1) + fsubs 56(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fmul %st, %st(2) + andb $127, 73(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + fxch %st(2) + faddl (%rdx) + fmul %st(2), %st + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + call log@PLT +..B3.167: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + je ..B3.117 +..B3.116: + movl %ebx, %edi + fstpl (%rsp) +..___tag_value_gammaf.241: + call fesetround@PLT +..___tag_value_gammaf.242: +..B3.172: + fldl (%rsp) +..B3.117: + fldt 8(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.118: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.120: + flds 112(%rsp) + movss .L_2il0floatpacket.3(%rip), %xmm1 + fchs + movaps %xmm1, %xmm0 + fstl 96(%rsp) + subss %xmm4, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm2 + movsd 96(%rsp), %xmm0 + subss %xmm1, %xmm2 + movss %xmm2, 104(%rsp) + movss 104(%rsp), %xmm3 + movss %xmm3, 56(%rsp) + fstpt 40(%rsp) + fldt 40(%rsp) + flds 56(%rsp) + fsubrp %st, %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fstpt 24(%rsp) + call log@PLT +..B3.171: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fchs + fldt 56(%rsp) + fstpt (%rsp) + fstpt 24(%rsp) +..___tag_value_gammaf.244: + call lgammaf_pos +..___tag_value_gammaf.245: +..B3.170: + fldt 24(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fldt 24(%rsp) + lea _S14(%rip), %rax + fld %st(0) + lea _S16(%rip), %r8 + fmul %st(1), %st + lea _S10(%rip), %rdx + fxch %st(3) + fsubrp %st, %st(2) + fldl (%rax) + lea _S12(%rip), %r9 + fmul %st(3), %st + lea _S06(%rip), %rcx + fldl (%r8) + lea _S08(%rip), %r10 + fmul %st(4), %st + fxch %st(1) + faddl (%rdx) + fmul %st(4), %st + fxch %st(1) + faddl (%r9) + fmul %st(4), %st + fxch %st(1) + faddl (%rcx) + fmul %st(4), %st + fxch %st(1) + faddl (%r10) + fmul %st(4), %st + lea _S02(%rip), %rsi + fxch %st(1) + faddl (%rsi) + lea _S04(%rip), %r11 + fmulp %st, %st(2) + faddl (%r11) + fmulp %st, %st(3) + andb $127, 73(%rsp) + faddp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B3.169: + fldt 8(%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + je ..B3.122 +..B3.121: + movl %ebx, %edi + fstpl (%rsp) + fstpt 8(%rsp) +..___tag_value_gammaf.247: + call fesetround@PLT +..___tag_value_gammaf.248: +..B3.173: + fldt 8(%rsp) + fldl (%rsp) +..B3.122: + testb %bpl, %bpl + fsubrp %st, %st(1) + fstps 104(%rsp) + je ..B3.124 +..B3.123: + fldcw 110(%rsp) +..B3.124: + movss 104(%rsp), %xmm0 +..B3.125: + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.126: + testb %bpl, %bpl + je ..B3.128 +..B3.127: + fldcw 110(%rsp) +..B3.128: + testb %r12b, %r12b + je ..B3.130 +..B3.129: + movl %ebx, %edi +..___tag_value_gammaf.269: + call fesetround@PLT +..___tag_value_gammaf.270: +..B3.130: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.131: + testb %bpl, %bpl + je ..B3.133 +..B3.132: + fldcw 110(%rsp) +..B3.133: + testb %r12b, %r12b + je ..B3.135 +..B3.134: + movl %ebx, %edi +..___tag_value_gammaf.291: + call fesetround@PLT +..___tag_value_gammaf.292: +..B3.135: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B3.136: + testb %r12b, %r12b + je ..B3.138 +..B3.137: + movl %ebx, %edi +..___tag_value_gammaf.313: + call fesetround@PLT +..___tag_value_gammaf.314: +..B3.138: + lea _PBIG(%rip), %rax + testb %bpl, %bpl + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 104(%rsp) + je ..B3.124 +..B3.139: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.141: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B3.80 +..B3.142: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B3.97 +..B3.143: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B3.108 +..B3.144: + testb %r12b, %r12b + je ..B3.146 +..B3.145: + movl %ebx, %edi +..___tag_value_gammaf.315: + call fesetround@PLT +..___tag_value_gammaf.316: +..B3.146: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B3.124 +..B3.147: + fldcw 110(%rsp) + jmp ..B3.124 +..B3.149: + testb %r12b, %r12b + je ..B3.151 +..B3.150: + movl %ebx, %edi +..___tag_value_gammaf.317: + call fesetround@PLT +..___tag_value_gammaf.318: +..B3.151: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B3.124 +..B3.152: + fldcw 110(%rsp) + jmp ..B3.124 + .align 16,0x90 + .cfi_endproc + .type gammaf,@function + .size gammaf,.-gammaf + .data +# -- End gammaf + .text +# -- Begin lgammaf_r + .text + .align 16,0x90 + .globl lgammaf_r +lgammaf_r: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B4.1: + .cfi_startproc +..___tag_value_lgammaf_r.320: +..L321: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $120, %rsp + .cfi_def_cfa_offset 176 + xorb %r12b, %r12b + movss %xmm0, 112(%rsp) + movq %rdi, %r15 + movb 115(%rsp), %dl + xorb %bpl, %bpl + andb $-128, %dl + shrb $7, %dl + movd %xmm0, %eax + movzwl 114(%rsp), %r14d + andl $8388607, %eax + andl $32640, %r14d + shrl $7, %r14d + movl %r14d, %r13d + shll $23, %r13d + movb %dl, (%rsp) + orl %eax, %r13d +..B4.2: + fnstcw 110(%rsp) +..B4.3: +..___tag_value_lgammaf_r.335: + call fegetround@PLT +..___tag_value_lgammaf_r.336: +..B4.162: + movl %eax, %ebx +..B4.4: + testl %ebx, %ebx + je ..B4.6 +..B4.5: + xorl %edi, %edi + movb $1, %r12b +..___tag_value_lgammaf_r.337: + call fesetround@PLT +..___tag_value_lgammaf_r.338: +..B4.6: + movzwl 110(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B4.10 +..B4.7: + orl $-64768, %edx + movw %dx, 108(%rsp) +..B4.8: + fldcw 108(%rsp) +..B4.9: + movb $1, %bpl +..B4.10: + cmpl $255, %r14d + jne ..B4.16 +..B4.11: + movl $1, (%r15) + testb %bpl, %bpl + je ..B4.13 +..B4.12: + fldcw 110(%rsp) +..B4.13: + testb %r12b, %r12b + je ..B4.15 +..B4.14: + movl %ebx, %edi +..___tag_value_lgammaf_r.339: + call fesetround@PLT +..___tag_value_lgammaf_r.340: +..B4.15: + movss 112(%rsp), %xmm0 + mulss %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B4.16: + testl %r13d, %r13d + je ..B4.152 +..B4.17: + movb (%rsp), %al + testb %al, %al + movl $1, (%r15) + jne ..B4.74 +..B4.18: + cmpl $2084876174, %r13d + jae ..B4.139 +..B4.19: + movss 112(%rsp), %xmm0 + ucomiss .L_2il0floatpacket.6(%rip), %xmm0 + jp ..B4.20 + je ..B4.134 +..B4.20: + cmpl $1174405120, %r13d + jb ..B4.26 +..B4.21: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm0, 56(%rsp) + pxor %xmm0, %xmm0 + flds 56(%rsp) + cvtss2sd 56(%rsp), %xmm0 + fsub %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fstps 32(%rsp) + fldt (%rax) + fstpt 16(%rsp) + call log@PLT +..B4.163: + fldt (%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fmull 56(%rsp) + fstpt (%rsp) + je ..B4.23 +..B4.22: + movl %ebx, %edi +..___tag_value_lgammaf_r.361: + call fesetround@PLT +..___tag_value_lgammaf_r.362: +..B4.23: + fldt (%rsp) + testb %bpl, %bpl + fldt 16(%rsp) + faddp %st, %st(1) + fsubs 32(%rsp) + fstps 104(%rsp) + je ..B4.127 +..B4.24: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.26: + cmpl $1082130432, %r13d + jb ..B4.33 +..B4.27: + addl $-1082130432, %r13d + lea _A(%rip), %rax + sarl $23, %r13d + lea _B(%rip), %rdx + movslq %r13d, %r13 + lea _C5(%rip), %r8 + movss %xmm0, 56(%rsp) + lea (,%r13,8), %ecx + flds 56(%rsp) + lea (%r13,%r13,2), %esi + movslq %ecx, %rcx + lea _C5_0(%rip), %r9 + movslq %esi, %rsi + testb %r12b, %r12b + fsubs (%rax,%r13,4) + fmuls (%rdx,%r13,4) + fld %st(0) + fmul %st(1), %st + fldl 8(%r8,%rcx,8) + fmul %st(1), %st + fldl (%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 40(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 32(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 8(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl (%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 56(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 48(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 24(%r8,%rcx,8) + fmulp %st, %st(3) + fxch %st(2) + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(2) + faddl 16(%r8,%rcx,8) + fmulp %st, %st(1) + faddl 16(%r9,%rsi,8) + fstpt (%rsp) + je ..B4.30 +..B4.28: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.363: + call fesetround@PLT +..___tag_value_lgammaf_r.364: +..B4.29: + fldt 80(%rsp) +..B4.30: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.31: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.33: + ucomiss .L_2il0floatpacket.4(%rip), %xmm0 + jp ..B4.34 + je ..B4.129 +..B4.34: + movss %xmm0, 56(%rsp) + cmpl $1073741824, %r13d + flds 56(%rsp) + jbe ..B4.40 +..B4.35: + fldt .L_2il0floatpacket.5(%rip) + fld %st(1) + lea _C4(%rip), %r9 + lea 8+_C4(%rip), %rax + fmul %st(2), %st + lea 32+_C4(%rip), %r10 + fldl (%rax) + lea 40+_C4(%rip), %rdx + fmul %st(1), %st + lea 64+_C4(%rip), %r11 + fldl (%r9) + lea 72+_C4(%rip), %rcx + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + lea 48+_C4(%rip), %r13 + lea 56+_C4(%rip), %rsi + fmul %st(2), %st + fxch %st(1) + faddl (%r11) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + lea 16+_C4(%rip), %r14 + lea 24+_C4(%rip), %r8 + fmul %st(2), %st + fxch %st(1) + faddl (%r13) + fmul %st(2), %st + fxch %st(1) + faddl (%r8) + lea 80+_C4(%rip), %r15 + testb %r12b, %r12b + fmul %st(4), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(3) + fsubrp %st, %st(4) + faddl (%r14) + fmulp %st, %st(1) + faddl (%r15) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B4.37 +..B4.36: + movl %ebx, %edi +..___tag_value_lgammaf_r.365: + call fesetround@PLT +..___tag_value_lgammaf_r.366: +..B4.37: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B4.127 +..B4.38: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.40: + cmpl $1071644672, %r13d + jb ..B4.47 +..B4.41: + fld %st(0) + lea 16+_C3(%rip), %rax + fmul %st(1), %st + lea 48+_C3(%rip), %rdx + fldl (%rax) + lea 32+_C3(%rip), %rcx + fmul %st(1), %st + lea 64+_C3(%rip), %rsi + lea 8+_C3(%rip), %r8 + lea 40+_C3(%rip), %r9 + lea 24+_C3(%rip), %r10 + lea 56+_C3(%rip), %r11 + lea _C3(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B4.44 +..B4.42: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.367: + call fesetround@PLT +..___tag_value_lgammaf_r.368: +..B4.43: + fldt 80(%rsp) +..B4.44: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.45: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.47: + cmpl $1069547520, %r13d + jb ..B4.54 +..B4.48: + fld %st(0) + lea 16+_LGAMMAF_C2(%rip), %rax + fmul %st(1), %st + lea 48+_LGAMMAF_C2(%rip), %rdx + fldl (%rax) + lea 32+_LGAMMAF_C2(%rip), %rcx + fmul %st(1), %st + lea 64+_LGAMMAF_C2(%rip), %rsi + lea 8+_LGAMMAF_C2(%rip), %r8 + lea 40+_LGAMMAF_C2(%rip), %r9 + lea 24+_LGAMMAF_C2(%rip), %r10 + lea 56+_LGAMMAF_C2(%rip), %r11 + lea _LGAMMAF_C2(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B4.51 +..B4.49: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.369: + call fesetround@PLT +..___tag_value_lgammaf_r.370: +..B4.50: + fldt 80(%rsp) +..B4.51: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.52: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.54: + cmpl $1067450368, %r13d + jb ..B4.61 +..B4.55: + lea _LM(%rip), %rax + lea 16+_C1(%rip), %rdx + lea 48+_C1(%rip), %rcx + lea 32+_C1(%rip), %rsi + lea 64+_C1(%rip), %r8 + lea 8+_C1(%rip), %r9 + lea 40+_C1(%rip), %r10 + lea 24+_C1(%rip), %r11 + fldl (%rdx) + lea 56+_C1(%rip), %r13 + lea _C1(%rip), %r14 + testb %r12b, %r12b + fxch %st(1) + fsubl (%rax) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(2) + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmulp %st, %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmul %st(2), %st + faddl (%r13) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r14) + fstpt (%rsp) + je ..B4.58 +..B4.56: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.371: + call fesetround@PLT +..___tag_value_lgammaf_r.372: +..B4.57: + fldt 80(%rsp) +..B4.58: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.59: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.61: + cmpl $1065353216, %r13d + jb ..B4.68 +..B4.62: + fld %st(0) + lea 16+_C0(%rip), %rax + fmul %st(1), %st + lea 48+_C0(%rip), %rdx + fldl (%rax) + lea 32+_C0(%rip), %rcx + fmul %st(1), %st + lea 64+_C0(%rip), %rsi + lea 8+_C0(%rip), %r8 + lea 40+_C0(%rip), %r9 + lea 24+_C0(%rip), %r10 + lea 56+_C0(%rip), %r11 + lea _C0(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B4.65 +..B4.63: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.373: + call fesetround@PLT +..___tag_value_lgammaf_r.374: +..B4.64: + fldt 80(%rsp) +..B4.65: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.66: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.68: + fldt .L_2il0floatpacket.0(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fadd %st(1), %st + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value_lgammaf_r.376: + call lgammaf_pos +..___tag_value_lgammaf_r.377: +..B4.165: + fldt 32(%rsp) + fxch %st(1) + fstpt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B4.164: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + je ..B4.71 +..B4.69: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.379: + call fesetround@PLT +..___tag_value_lgammaf_r.380: +..B4.70: + fldt 80(%rsp) +..B4.71: + fldt (%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.72: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.74: + movss 112(%rsp), %xmm0 + call nearbyintf@PLT +..B4.166: + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm1 + movss 112(%rsp), %xmm2 + ucomiss %xmm1, %xmm2 + jp ..B4.75 + je ..B4.147 +..B4.75: + comiss .L_2il0floatpacket.8(%rip), %xmm2 + jbe ..B4.78 +..B4.76: + movaps %xmm2, %xmm0 + movss %xmm2, (%rsp) + call ceilf@PLT +..B4.167: + cvttss2si %xmm0, %eax + movss (%rsp), %xmm2 + testb $1, %al + jne ..B4.78 +..B4.77: + movl $-1, (%r15) +..B4.78: + cmpl $1073741824, %r13d + jae ..B4.89 +..B4.79: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm2, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B4.144 + jp ..B4.144 +..B4.80: + fldt 16(%rsp) +..B4.81: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B4.82 + jb ..B4.81 +..B4.82: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B4.83: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B4.169: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_lgammaf_r.382: + call lgammaf_pos +..___tag_value_lgammaf_r.383: +..B4.168: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B4.86 +..B4.84: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.385: + call fesetround@PLT +..___tag_value_lgammaf_r.386: +..B4.85: + fldt 80(%rsp) +..B4.86: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.87: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.89: + cmpl $1082130432, %r13d + jae ..B4.106 +..B4.90: + movss .L_2il0floatpacket.2(%rip), %xmm1 + lea _LRIB(%rip), %rdx + subss %xmm2, %xmm1 + movss .L_2il0floatpacket.3(%rip), %xmm2 + movss %xmm1, 104(%rsp) + pxor %xmm1, %xmm1 + movss 104(%rsp), %xmm0 + addss %xmm2, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm3 + movl 104(%rsp), %ecx + subss %xmm2, %xmm3 + movss 112(%rsp), %xmm2 + andl $1, %ecx + cvtss2sd %xmm2, %xmm1 + movss %xmm3, 104(%rsp) + lea (%rcx,%rcx,2), %eax + comisd (%rdx,%rax,8), %xmm1 + jbe ..B4.93 +..B4.91: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B4.93 +..B4.92: + movss %xmm2, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _LRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B4.101 +..B4.93: + lea _RRIB(%rip), %rdx + comisd (%rdx,%rax,8), %xmm1 + jbe ..B4.96 +..B4.94: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B4.96 +..B4.95: + movss %xmm2, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _RRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B4.101 +..B4.96: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm2, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt (%rsp) + fldt (%rsp) + fcomip %st(2), %st + jae ..B4.145 + jp ..B4.145 +..B4.97: + fldt (%rsp) +..B4.98: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B4.99 + jb ..B4.98 +..B4.99: + fstp %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 80(%rsp) +..B4.100: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B4.171: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstl 16(%rsp) + fstpt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 16(%rsp) + fstpt (%rsp) +..___tag_value_lgammaf_r.388: + call lgammaf_pos +..___tag_value_lgammaf_r.389: +..B4.170: + addq $16, %rsp + .cfi_def_cfa_offset 176 + fsubl 16(%rsp) + fstpt (%rsp) +..B4.101: + testb %r12b, %r12b + je ..B4.103 +..B4.102: + movl %ebx, %edi +..___tag_value_lgammaf_r.391: + call fesetround@PLT +..___tag_value_lgammaf_r.392: +..B4.103: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B4.127 +..B4.104: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.106: + cmpl $1091567616, %r13d + jae ..B4.117 +..B4.107: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm2, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B4.146 + jp ..B4.146 +..B4.108: + fldt 16(%rsp) +..B4.109: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B4.110 + jb ..B4.109 +..B4.110: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B4.111: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B4.173: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_lgammaf_r.394: + call lgammaf_pos +..___tag_value_lgammaf_r.395: +..B4.172: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B4.114 +..B4.112: + fstp %st(0) + movl %ebx, %edi +..___tag_value_lgammaf_r.397: + call fesetround@PLT +..___tag_value_lgammaf_r.398: +..B4.113: + fldt 80(%rsp) +..B4.114: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.115: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.117: + cmpl $1174405120, %r13d + jb ..B4.123 +..B4.118: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm2, 56(%rsp) + flds 56(%rsp) + fsts (%rsp) + fsub %st, %st(1) + fxch %st(1) + fstpt 8(%rsp) + fchs + fstl 96(%rsp) + movsd 96(%rsp), %xmm0 + fstpt 40(%rsp) + fldt (%rax) + fstpt 24(%rsp) + call log@PLT +..B4.175: + fldt 8(%rsp) + lea _S16(%rip), %rax + fldt 24(%rsp) + lea _S14(%rip), %rdx + fldt 40(%rsp) + lea _S12(%rip), %rcx + movss .L_2il0floatpacket.3(%rip), %xmm2 + lea _S10(%rip), %rsi + fldl (%rax) + lea _S08(%rip), %r8 + movss %xmm2, 104(%rsp) + lea _S06(%rip), %r9 + movss 104(%rsp), %xmm1 + lea _S04(%rip), %r10 + movsd %xmm0, 56(%rsp) + lea _S02(%rip), %r11 + fxch %st(3) + fmull 56(%rsp) + subss 112(%rsp), %xmm1 + fsubp %st, %st(2) + movss %xmm1, 104(%rsp) + movss 104(%rsp), %xmm3 + fxch %st(1) + fsubs (%rsp) + subss %xmm2, %xmm3 + movss %xmm3, 104(%rsp) + movss 104(%rsp), %xmm4 + movss %xmm4, 56(%rsp) + fxch %st(1) + fsubs 56(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fmul %st, %st(2) + andb $127, 73(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + fxch %st(2) + faddl (%rdx) + fmul %st(2), %st + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + call log@PLT +..B4.174: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + je ..B4.120 +..B4.119: + movl %ebx, %edi + fstpl (%rsp) +..___tag_value_lgammaf_r.399: + call fesetround@PLT +..___tag_value_lgammaf_r.400: +..B4.179: + fldl (%rsp) +..B4.120: + fldt 8(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.121: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.123: + flds 112(%rsp) + movss .L_2il0floatpacket.3(%rip), %xmm3 + fchs + movaps %xmm3, %xmm1 + fstl 96(%rsp) + subss %xmm2, %xmm1 + movss %xmm1, 104(%rsp) + movss 104(%rsp), %xmm0 + fstpt 40(%rsp) + fldt 40(%rsp) + subss %xmm3, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm2 + movss %xmm2, 56(%rsp) + flds 56(%rsp) + movsd 96(%rsp), %xmm0 + fsubrp %st, %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fstpt 24(%rsp) + call log@PLT +..B4.178: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fchs + fldt 56(%rsp) + fstpt (%rsp) + fstpt 24(%rsp) +..___tag_value_lgammaf_r.402: + call lgammaf_pos +..___tag_value_lgammaf_r.403: +..B4.177: + fldt 24(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fldt 24(%rsp) + lea _S14(%rip), %rax + fld %st(0) + lea _S16(%rip), %r8 + fmul %st(1), %st + lea _S10(%rip), %rdx + fxch %st(3) + fsubrp %st, %st(2) + fldl (%rax) + lea _S12(%rip), %r9 + fmul %st(3), %st + lea _S06(%rip), %rcx + fldl (%r8) + lea _S08(%rip), %r10 + fmul %st(4), %st + fxch %st(1) + faddl (%rdx) + fmul %st(4), %st + fxch %st(1) + faddl (%r9) + fmul %st(4), %st + fxch %st(1) + faddl (%rcx) + fmul %st(4), %st + fxch %st(1) + faddl (%r10) + fmul %st(4), %st + lea _S02(%rip), %rsi + fxch %st(1) + faddl (%rsi) + lea _S04(%rip), %r11 + fmulp %st, %st(2) + faddl (%r11) + fmulp %st, %st(3) + andb $127, 73(%rsp) + faddp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B4.176: + fldt 8(%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + je ..B4.125 +..B4.124: + movl %ebx, %edi + fstpl (%rsp) + fstpt 8(%rsp) +..___tag_value_lgammaf_r.405: + call fesetround@PLT +..___tag_value_lgammaf_r.406: +..B4.180: + fldt 8(%rsp) + fldl (%rsp) +..B4.125: + testb %bpl, %bpl + fsubrp %st, %st(1) + fstps 104(%rsp) + je ..B4.127 +..B4.126: + fldcw 110(%rsp) +..B4.127: + movss 104(%rsp), %xmm0 +..B4.128: + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B4.129: + testb %bpl, %bpl + je ..B4.131 +..B4.130: + fldcw 110(%rsp) +..B4.131: + testb %r12b, %r12b + je ..B4.133 +..B4.132: + movl %ebx, %edi +..___tag_value_lgammaf_r.427: + call fesetround@PLT +..___tag_value_lgammaf_r.428: +..B4.133: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B4.134: + testb %bpl, %bpl + je ..B4.136 +..B4.135: + fldcw 110(%rsp) +..B4.136: + testb %r12b, %r12b + je ..B4.138 +..B4.137: + movl %ebx, %edi +..___tag_value_lgammaf_r.449: + call fesetround@PLT +..___tag_value_lgammaf_r.450: +..B4.138: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B4.139: + testb %r12b, %r12b + je ..B4.141 +..B4.140: + movl %ebx, %edi +..___tag_value_lgammaf_r.471: + call fesetround@PLT +..___tag_value_lgammaf_r.472: +..B4.141: + lea _PBIG(%rip), %rax + testb %bpl, %bpl + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 104(%rsp) + je ..B4.127 +..B4.142: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.144: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B4.83 +..B4.145: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B4.100 +..B4.146: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B4.111 +..B4.147: + testb %r12b, %r12b + je ..B4.149 +..B4.148: + movl %ebx, %edi +..___tag_value_lgammaf_r.473: + call fesetround@PLT +..___tag_value_lgammaf_r.474: +..B4.149: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B4.127 +..B4.150: + fldcw 110(%rsp) + jmp ..B4.127 +..B4.152: + movb (%rsp), %al + testb %al, %al + je ..B4.154 +..B4.153: + movl $-1, (%r15) + jmp ..B4.155 +..B4.154: + movl $1, (%r15) +..B4.155: + testb %r12b, %r12b + je ..B4.157 +..B4.156: + movl %ebx, %edi +..___tag_value_lgammaf_r.475: + call fesetround@PLT +..___tag_value_lgammaf_r.476: +..B4.157: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B4.127 +..B4.158: + fldcw 110(%rsp) + jmp ..B4.127 + .align 16,0x90 + .cfi_endproc + .type lgammaf_r,@function + .size lgammaf_r,.-lgammaf_r + .data +# -- End lgammaf_r + .text +# -- Begin gammaf_r + .text + .align 16,0x90 + .globl gammaf_r +gammaf_r: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B5.1: + .cfi_startproc +..___tag_value_gammaf_r.478: +..L479: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $120, %rsp + .cfi_def_cfa_offset 176 + xorb %r12b, %r12b + movss %xmm0, 112(%rsp) + movq %rdi, %r15 + movb 115(%rsp), %dl + xorb %bpl, %bpl + andb $-128, %dl + shrb $7, %dl + movd %xmm0, %eax + movzwl 114(%rsp), %r14d + andl $8388607, %eax + andl $32640, %r14d + shrl $7, %r14d + movl %r14d, %r13d + shll $23, %r13d + movb %dl, (%rsp) + orl %eax, %r13d +..B5.2: + fnstcw 110(%rsp) +..B5.3: +..___tag_value_gammaf_r.493: + call fegetround@PLT +..___tag_value_gammaf_r.494: +..B5.162: + movl %eax, %ebx +..B5.4: + testl %ebx, %ebx + je ..B5.6 +..B5.5: + xorl %edi, %edi + movb $1, %r12b +..___tag_value_gammaf_r.495: + call fesetround@PLT +..___tag_value_gammaf_r.496: +..B5.6: + movzwl 110(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B5.10 +..B5.7: + orl $-64768, %edx + movw %dx, 108(%rsp) +..B5.8: + fldcw 108(%rsp) +..B5.9: + movb $1, %bpl +..B5.10: + cmpl $255, %r14d + jne ..B5.16 +..B5.11: + movl $1, (%r15) + testb %bpl, %bpl + je ..B5.13 +..B5.12: + fldcw 110(%rsp) +..B5.13: + testb %r12b, %r12b + je ..B5.15 +..B5.14: + movl %ebx, %edi +..___tag_value_gammaf_r.497: + call fesetround@PLT +..___tag_value_gammaf_r.498: +..B5.15: + movss 112(%rsp), %xmm0 + mulss %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B5.16: + testl %r13d, %r13d + je ..B5.152 +..B5.17: + movb (%rsp), %al + testb %al, %al + movl $1, (%r15) + jne ..B5.74 +..B5.18: + cmpl $2084876174, %r13d + jae ..B5.139 +..B5.19: + movss 112(%rsp), %xmm0 + ucomiss .L_2il0floatpacket.6(%rip), %xmm0 + jp ..B5.20 + je ..B5.134 +..B5.20: + cmpl $1174405120, %r13d + jb ..B5.26 +..B5.21: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm0, 56(%rsp) + pxor %xmm0, %xmm0 + flds 56(%rsp) + cvtss2sd 56(%rsp), %xmm0 + fsub %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fstps 32(%rsp) + fldt (%rax) + fstpt 16(%rsp) + call log@PLT +..B5.163: + fldt (%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fmull 56(%rsp) + fstpt (%rsp) + je ..B5.23 +..B5.22: + movl %ebx, %edi +..___tag_value_gammaf_r.519: + call fesetround@PLT +..___tag_value_gammaf_r.520: +..B5.23: + fldt (%rsp) + testb %bpl, %bpl + fldt 16(%rsp) + faddp %st, %st(1) + fsubs 32(%rsp) + fstps 104(%rsp) + je ..B5.127 +..B5.24: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.26: + cmpl $1082130432, %r13d + jb ..B5.33 +..B5.27: + addl $-1082130432, %r13d + lea _A(%rip), %rax + sarl $23, %r13d + lea _B(%rip), %rdx + movslq %r13d, %r13 + lea _C5(%rip), %r8 + movss %xmm0, 56(%rsp) + lea (,%r13,8), %ecx + flds 56(%rsp) + lea (%r13,%r13,2), %esi + movslq %ecx, %rcx + lea _C5_0(%rip), %r9 + movslq %esi, %rsi + testb %r12b, %r12b + fsubs (%rax,%r13,4) + fmuls (%rdx,%r13,4) + fld %st(0) + fmul %st(1), %st + fldl 8(%r8,%rcx,8) + fmul %st(1), %st + fldl (%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 40(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 32(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 8(%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl (%r9,%rsi,8) + fmul %st(2), %st + fxch %st(1) + faddl 56(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 48(%r8,%rcx,8) + fmul %st(2), %st + fxch %st(1) + faddl 24(%r8,%rcx,8) + fmulp %st, %st(3) + fxch %st(2) + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(2) + faddl 16(%r8,%rcx,8) + fmulp %st, %st(1) + faddl 16(%r9,%rsi,8) + fstpt (%rsp) + je ..B5.30 +..B5.28: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.521: + call fesetround@PLT +..___tag_value_gammaf_r.522: +..B5.29: + fldt 80(%rsp) +..B5.30: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.31: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.33: + ucomiss .L_2il0floatpacket.4(%rip), %xmm0 + jp ..B5.34 + je ..B5.129 +..B5.34: + movss %xmm0, 56(%rsp) + cmpl $1073741824, %r13d + flds 56(%rsp) + jbe ..B5.40 +..B5.35: + fldt .L_2il0floatpacket.5(%rip) + fld %st(1) + lea _C4(%rip), %r9 + lea 8+_C4(%rip), %rax + fmul %st(2), %st + lea 32+_C4(%rip), %r10 + fldl (%rax) + lea 40+_C4(%rip), %rdx + fmul %st(1), %st + lea 64+_C4(%rip), %r11 + fldl (%r9) + lea 72+_C4(%rip), %rcx + fmul %st(2), %st + fxch %st(1) + faddl (%rdx) + fmul %st(2), %st + fxch %st(1) + faddl (%r10) + fmul %st(2), %st + fxch %st(1) + faddl (%rcx) + lea 48+_C4(%rip), %r13 + lea 56+_C4(%rip), %rsi + fmul %st(2), %st + fxch %st(1) + faddl (%r11) + fmul %st(2), %st + fxch %st(1) + faddl (%rsi) + lea 16+_C4(%rip), %r14 + lea 24+_C4(%rip), %r8 + fmul %st(2), %st + fxch %st(1) + faddl (%r13) + fmul %st(2), %st + fxch %st(1) + faddl (%r8) + lea 80+_C4(%rip), %r15 + testb %r12b, %r12b + fmul %st(4), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fxch %st(3) + fsubrp %st, %st(4) + faddl (%r14) + fmulp %st, %st(1) + faddl (%r15) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B5.37 +..B5.36: + movl %ebx, %edi +..___tag_value_gammaf_r.523: + call fesetround@PLT +..___tag_value_gammaf_r.524: +..B5.37: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B5.127 +..B5.38: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.40: + cmpl $1071644672, %r13d + jb ..B5.47 +..B5.41: + fld %st(0) + lea 16+_C3(%rip), %rax + fmul %st(1), %st + lea 48+_C3(%rip), %rdx + fldl (%rax) + lea 32+_C3(%rip), %rcx + fmul %st(1), %st + lea 64+_C3(%rip), %rsi + lea 8+_C3(%rip), %r8 + lea 40+_C3(%rip), %r9 + lea 24+_C3(%rip), %r10 + lea 56+_C3(%rip), %r11 + lea _C3(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B5.44 +..B5.42: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.525: + call fesetround@PLT +..___tag_value_gammaf_r.526: +..B5.43: + fldt 80(%rsp) +..B5.44: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.45: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.47: + cmpl $1069547520, %r13d + jb ..B5.54 +..B5.48: + fld %st(0) + lea 16+_LGAMMAF_C2(%rip), %rax + fmul %st(1), %st + lea 48+_LGAMMAF_C2(%rip), %rdx + fldl (%rax) + lea 32+_LGAMMAF_C2(%rip), %rcx + fmul %st(1), %st + lea 64+_LGAMMAF_C2(%rip), %rsi + lea 8+_LGAMMAF_C2(%rip), %r8 + lea 40+_LGAMMAF_C2(%rip), %r9 + lea 24+_LGAMMAF_C2(%rip), %r10 + lea 56+_LGAMMAF_C2(%rip), %r11 + lea _LGAMMAF_C2(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B5.51 +..B5.49: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.527: + call fesetround@PLT +..___tag_value_gammaf_r.528: +..B5.50: + fldt 80(%rsp) +..B5.51: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.52: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.54: + cmpl $1067450368, %r13d + jb ..B5.61 +..B5.55: + lea _LM(%rip), %rax + lea 16+_C1(%rip), %rdx + lea 48+_C1(%rip), %rcx + lea 32+_C1(%rip), %rsi + lea 64+_C1(%rip), %r8 + lea 8+_C1(%rip), %r9 + lea 40+_C1(%rip), %r10 + lea 24+_C1(%rip), %r11 + fldl (%rdx) + lea 56+_C1(%rip), %r13 + lea _C1(%rip), %r14 + testb %r12b, %r12b + fxch %st(1) + fsubl (%rax) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(2) + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmulp %st, %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmul %st(2), %st + faddl (%r13) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r14) + fstpt (%rsp) + je ..B5.58 +..B5.56: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.529: + call fesetround@PLT +..___tag_value_gammaf_r.530: +..B5.57: + fldt 80(%rsp) +..B5.58: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.59: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.61: + cmpl $1065353216, %r13d + jb ..B5.68 +..B5.62: + fld %st(0) + lea 16+_C0(%rip), %rax + fmul %st(1), %st + lea 48+_C0(%rip), %rdx + fldl (%rax) + lea 32+_C0(%rip), %rcx + fmul %st(1), %st + lea 64+_C0(%rip), %rsi + lea 8+_C0(%rip), %r8 + lea 40+_C0(%rip), %r9 + lea 24+_C0(%rip), %r10 + lea 56+_C0(%rip), %r11 + lea _C0(%rip), %r13 + testb %r12b, %r12b + faddl (%rdx) + fmul %st(1), %st + faddl (%rcx) + fmul %st(1), %st + faddl (%rsi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + faddl (%r13) + fstpt (%rsp) + je ..B5.65 +..B5.63: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.531: + call fesetround@PLT +..___tag_value_gammaf_r.532: +..B5.64: + fldt 80(%rsp) +..B5.65: + fldt (%rsp) + testb %bpl, %bpl + faddp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.66: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.68: + fldt .L_2il0floatpacket.0(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fadd %st(1), %st + fstpt (%rsp) + fstpt 32(%rsp) +..___tag_value_gammaf_r.534: + call lgammaf_pos +..___tag_value_gammaf_r.535: +..B5.165: + fldt 32(%rsp) + fxch %st(1) + fstpt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B5.164: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + je ..B5.71 +..B5.69: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.537: + call fesetround@PLT +..___tag_value_gammaf_r.538: +..B5.70: + fldt 80(%rsp) +..B5.71: + fldt (%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.72: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.74: + movss 112(%rsp), %xmm0 + call nearbyintf@PLT +..B5.166: + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm1 + movss 112(%rsp), %xmm2 + ucomiss %xmm1, %xmm2 + jp ..B5.75 + je ..B5.147 +..B5.75: + comiss .L_2il0floatpacket.8(%rip), %xmm2 + jbe ..B5.78 +..B5.76: + movaps %xmm2, %xmm0 + movss %xmm2, (%rsp) + call ceilf@PLT +..B5.167: + cvttss2si %xmm0, %eax + movss (%rsp), %xmm2 + testb $1, %al + jne ..B5.78 +..B5.77: + movl $-1, (%r15) +..B5.78: + cmpl $1073741824, %r13d + jae ..B5.89 +..B5.79: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm2, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B5.144 + jp ..B5.144 +..B5.80: + fldt 16(%rsp) +..B5.81: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B5.82 + jb ..B5.81 +..B5.82: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B5.83: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B5.169: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_gammaf_r.540: + call lgammaf_pos +..___tag_value_gammaf_r.541: +..B5.168: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B5.86 +..B5.84: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.543: + call fesetround@PLT +..___tag_value_gammaf_r.544: +..B5.85: + fldt 80(%rsp) +..B5.86: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.87: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.89: + cmpl $1082130432, %r13d + jae ..B5.106 +..B5.90: + movss .L_2il0floatpacket.2(%rip), %xmm1 + lea _LRIB(%rip), %rdx + subss %xmm2, %xmm1 + movss .L_2il0floatpacket.3(%rip), %xmm2 + movss %xmm1, 104(%rsp) + pxor %xmm1, %xmm1 + movss 104(%rsp), %xmm0 + addss %xmm2, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm3 + movl 104(%rsp), %ecx + subss %xmm2, %xmm3 + movss 112(%rsp), %xmm2 + andl $1, %ecx + cvtss2sd %xmm2, %xmm1 + movss %xmm3, 104(%rsp) + lea (%rcx,%rcx,2), %eax + comisd (%rdx,%rax,8), %xmm1 + jbe ..B5.93 +..B5.91: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B5.93 +..B5.92: + movss %xmm2, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _LRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B5.101 +..B5.93: + lea _RRIB(%rip), %rdx + comisd (%rdx,%rax,8), %xmm1 + jbe ..B5.96 +..B5.94: + movsd 16(%rdx,%rax,8), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B5.96 +..B5.95: + movss %xmm2, 56(%rsp) + flds 56(%rsp) + shll $2, %ecx + fsubl 8(%rdx,%rax,8) + lea _RRP(%rip), %rax + fldl (%rax,%rcx,8) + fmul %st(1), %st + faddl 8(%rax,%rcx,8) + fmul %st(1), %st + faddl 16(%rax,%rcx,8) + fmulp %st, %st(1) + faddl 24(%rax,%rcx,8) + fstpt (%rsp) + jmp ..B5.101 +..B5.96: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm2, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt (%rsp) + fldt (%rsp) + fcomip %st(2), %st + jae ..B5.145 + jp ..B5.145 +..B5.97: + fldt (%rsp) +..B5.98: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B5.99 + jb ..B5.98 +..B5.99: + fstp %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 80(%rsp) +..B5.100: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B5.171: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstl 16(%rsp) + fstpt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 16(%rsp) + fstpt (%rsp) +..___tag_value_gammaf_r.546: + call lgammaf_pos +..___tag_value_gammaf_r.547: +..B5.170: + addq $16, %rsp + .cfi_def_cfa_offset 176 + fsubl 16(%rsp) + fstpt (%rsp) +..B5.101: + testb %r12b, %r12b + je ..B5.103 +..B5.102: + movl %ebx, %edi +..___tag_value_gammaf_r.549: + call fesetround@PLT +..___tag_value_gammaf_r.550: +..B5.103: + fldt (%rsp) + testb %bpl, %bpl + fstps 104(%rsp) + je ..B5.127 +..B5.104: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.106: + cmpl $1091567616, %r13d + jae ..B5.117 +..B5.107: + fldt .L_2il0floatpacket.0(%rip) + movss %xmm2, 56(%rsp) + fld %st(0) + flds 56(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fcomip %st(2), %st + jae ..B5.146 + jp ..B5.146 +..B5.108: + fldt 16(%rsp) +..B5.109: + fmul %st, %st(1) + fadd %st(2), %st + fcomi %st(2), %st + jp ..B5.110 + jb ..B5.109 +..B5.110: + fstp %st(2) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..B5.111: + andb $127, 89(%rsp) + fldt 80(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B5.173: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fldt 32(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value_gammaf_r.552: + call lgammaf_pos +..___tag_value_gammaf_r.553: +..B5.172: + fldt 16(%rsp) + fxch %st(1) + fstpt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + testb %r12b, %r12b + je ..B5.114 +..B5.112: + fstp %st(0) + movl %ebx, %edi +..___tag_value_gammaf_r.555: + call fesetround@PLT +..___tag_value_gammaf_r.556: +..B5.113: + fldt 80(%rsp) +..B5.114: + fldt 16(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.115: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.117: + cmpl $1174405120, %r13d + jb ..B5.123 +..B5.118: + fldt .L_2il0floatpacket.1(%rip) + lea _LN_SQRT_TWO_PI(%rip), %rax + movss %xmm2, 56(%rsp) + flds 56(%rsp) + fsts (%rsp) + fsub %st, %st(1) + fxch %st(1) + fstpt 8(%rsp) + fchs + fstl 96(%rsp) + movsd 96(%rsp), %xmm0 + fstpt 40(%rsp) + fldt (%rax) + fstpt 24(%rsp) + call log@PLT +..B5.175: + fldt 8(%rsp) + lea _S16(%rip), %rax + fldt 24(%rsp) + lea _S14(%rip), %rdx + fldt 40(%rsp) + lea _S12(%rip), %rcx + movss .L_2il0floatpacket.3(%rip), %xmm2 + lea _S10(%rip), %rsi + fldl (%rax) + lea _S08(%rip), %r8 + movss %xmm2, 104(%rsp) + lea _S06(%rip), %r9 + movss 104(%rsp), %xmm1 + lea _S04(%rip), %r10 + movsd %xmm0, 56(%rsp) + lea _S02(%rip), %r11 + fxch %st(3) + fmull 56(%rsp) + subss 112(%rsp), %xmm1 + fsubp %st, %st(2) + movss %xmm1, 104(%rsp) + movss 104(%rsp), %xmm3 + fxch %st(1) + fsubs (%rsp) + subss %xmm2, %xmm3 + movss %xmm3, 104(%rsp) + movss 104(%rsp), %xmm4 + movss %xmm4, 56(%rsp) + fxch %st(1) + fsubs 56(%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fmul %st, %st(2) + andb $127, 73(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + fxch %st(2) + faddl (%rdx) + fmul %st(2), %st + faddl (%rcx) + fmul %st(2), %st + faddl (%rsi) + fmul %st(2), %st + faddl (%r8) + fmul %st(2), %st + faddl (%r9) + fmul %st(2), %st + faddl (%r10) + fmul %st(2), %st + faddl (%r11) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + call log@PLT +..B5.174: + movsd %xmm0, 56(%rsp) + testb %r12b, %r12b + fldl 56(%rsp) + je ..B5.120 +..B5.119: + movl %ebx, %edi + fstpl (%rsp) +..___tag_value_gammaf_r.557: + call fesetround@PLT +..___tag_value_gammaf_r.558: +..B5.179: + fldl (%rsp) +..B5.120: + fldt 8(%rsp) + testb %bpl, %bpl + fsubp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.121: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.123: + flds 112(%rsp) + movss .L_2il0floatpacket.3(%rip), %xmm3 + fchs + movaps %xmm3, %xmm1 + fstl 96(%rsp) + subss %xmm2, %xmm1 + movss %xmm1, 104(%rsp) + movss 104(%rsp), %xmm0 + fstpt 40(%rsp) + fldt 40(%rsp) + subss %xmm3, %xmm0 + movss %xmm0, 104(%rsp) + movss 104(%rsp), %xmm2 + movss %xmm2, 56(%rsp) + flds 56(%rsp) + movsd 96(%rsp), %xmm0 + fsubrp %st, %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fmul %st(0), %st + fstpt 24(%rsp) + call log@PLT +..B5.178: + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 192 + fchs + fldt 56(%rsp) + fstpt (%rsp) + fstpt 24(%rsp) +..___tag_value_gammaf_r.560: + call lgammaf_pos +..___tag_value_gammaf_r.561: +..B5.177: + fldt 24(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 176 + fldt 24(%rsp) + lea _S14(%rip), %rax + fld %st(0) + lea _S16(%rip), %r8 + fmul %st(1), %st + lea _S10(%rip), %rdx + fxch %st(3) + fsubrp %st, %st(2) + fldl (%rax) + lea _S12(%rip), %r9 + fmul %st(3), %st + lea _S06(%rip), %rcx + fldl (%r8) + lea _S08(%rip), %r10 + fmul %st(4), %st + fxch %st(1) + faddl (%rdx) + fmul %st(4), %st + fxch %st(1) + faddl (%r9) + fmul %st(4), %st + fxch %st(1) + faddl (%rcx) + fmul %st(4), %st + fxch %st(1) + faddl (%r10) + fmul %st(4), %st + lea _S02(%rip), %rsi + fxch %st(1) + faddl (%rsi) + lea _S04(%rip), %r11 + fmulp %st, %st(2) + faddl (%r11) + fmulp %st, %st(3) + andb $127, 73(%rsp) + faddp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(1) + fstpt 8(%rsp) + fldt 64(%rsp) + fstpl 96(%rsp) + movsd 96(%rsp), %xmm0 + call log@PLT +..B5.176: + fldt 8(%rsp) + testb %r12b, %r12b + movsd %xmm0, 56(%rsp) + fldl 56(%rsp) + je ..B5.125 +..B5.124: + movl %ebx, %edi + fstpl (%rsp) + fstpt 8(%rsp) +..___tag_value_gammaf_r.563: + call fesetround@PLT +..___tag_value_gammaf_r.564: +..B5.180: + fldt 8(%rsp) + fldl (%rsp) +..B5.125: + testb %bpl, %bpl + fsubrp %st, %st(1) + fstps 104(%rsp) + je ..B5.127 +..B5.126: + fldcw 110(%rsp) +..B5.127: + movss 104(%rsp), %xmm0 +..B5.128: + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B5.129: + testb %bpl, %bpl + je ..B5.131 +..B5.130: + fldcw 110(%rsp) +..B5.131: + testb %r12b, %r12b + je ..B5.133 +..B5.132: + movl %ebx, %edi +..___tag_value_gammaf_r.585: + call fesetround@PLT +..___tag_value_gammaf_r.586: +..B5.133: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B5.134: + testb %bpl, %bpl + je ..B5.136 +..B5.135: + fldcw 110(%rsp) +..B5.136: + testb %r12b, %r12b + je ..B5.138 +..B5.137: + movl %ebx, %edi +..___tag_value_gammaf_r.607: + call fesetround@PLT +..___tag_value_gammaf_r.608: +..B5.138: + pxor %xmm0, %xmm0 + addq $120, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 176 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B5.139: + testb %r12b, %r12b + je ..B5.141 +..B5.140: + movl %ebx, %edi +..___tag_value_gammaf_r.629: + call fesetround@PLT +..___tag_value_gammaf_r.630: +..B5.141: + lea _PBIG(%rip), %rax + testb %bpl, %bpl + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 104(%rsp) + je ..B5.127 +..B5.142: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.144: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B5.83 +..B5.145: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B5.100 +..B5.146: + fstp %st(0) + fstpt 80(%rsp) + jmp ..B5.111 +..B5.147: + testb %r12b, %r12b + je ..B5.149 +..B5.148: + movl %ebx, %edi +..___tag_value_gammaf_r.631: + call fesetround@PLT +..___tag_value_gammaf_r.632: +..B5.149: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B5.127 +..B5.150: + fldcw 110(%rsp) + jmp ..B5.127 +..B5.152: + movb (%rsp), %al + testb %al, %al + je ..B5.154 +..B5.153: + movl $-1, (%r15) + jmp ..B5.155 +..B5.154: + movl $1, (%r15) +..B5.155: + testb %r12b, %r12b + je ..B5.157 +..B5.156: + movl %ebx, %edi +..___tag_value_gammaf_r.633: + call fesetround@PLT +..___tag_value_gammaf_r.634: +..B5.157: + movss .L_2il0floatpacket.6(%rip), %xmm1 + testb %bpl, %bpl + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, 104(%rsp) + je ..B5.127 +..B5.158: + fldcw 110(%rsp) + jmp ..B5.127 + .align 16,0x90 + .cfi_endproc + .type gammaf_r,@function + .size gammaf_r,.-gammaf_r + .data +# -- End gammaf_r + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 16 +_LN_SQRT_TWO_PI: + .word 42293 + .word 9717 + .word 36419 + .word 60223 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _LN_SQRT_TWO_PI,@object + .size _LN_SQRT_TWO_PI,16 + .align 16 +_A: + .long 1082130432 + .long 1090519040 + .long 1098907648 + .long 1107296256 + .long 1115684864 + .long 1124073472 + .long 1132462080 + .long 1140850688 + .long 1149239296 + .long 1157627904 + .long 1166016512 + .type _A,@object + .size _A,44 + .space 4, 0x00 # pad + .align 16 +_B: + .long 1048576000 + .long 1040187392 + .long 1031798784 + .long 1023410176 + .long 1015021568 + .long 1006632960 + .long 998244352 + .long 989855744 + .long 981467136 + .long 973078528 + .long 964689920 + .type _B,@object + .size _B,44 + .space 4, 0x00 # pad + .align 16 +_C5: + .long 2219950285 + .long 1064025046 + .long 657069815 + .long 3214307011 + .long 2744833897 + .long 1073883684 + .long 3746154693 + .long 1075058958 + .long 24044097 + .long 1068577021 + .long 1852002888 + .long 3217117620 + .long 426096126 + .long 1071550305 + .long 3945160253 + .long 3219869968 + .long 889741930 + .long 1064529657 + .long 2918550257 + .long 3214927323 + .long 3306758232 + .long 1074858655 + .long 2801363753 + .long 1076895752 + .long 216130741 + .long 1069082446 + .long 2022127190 + .long 3217667546 + .long 4043317980 + .long 1072274701 + .long 948933764 + .long 3220711872 + .long 1837011561 + .long 1065353117 + .long 614133169 + .long 3215620106 + .long 128884864 + .long 1075872424 + .long 1749057555 + .long 1078324632 + .long 1278187959 + .long 1069867493 + .long 1878987920 + .long 3218464301 + .long 2508500615 + .long 1073176520 + .long 3716705454 + .long 3221664954 + .long 1971591775 + .long 1066198339 + .long 3489274850 + .long 3216507307 + .long 2978044890 + .long 1076904104 + .long 399657850 + .long 1079744937 + .long 2176842243 + .long 1070795947 + .long 1642919051 + .long 3219397359 + .long 325839939 + .long 1074155724 + .long 1189620011 + .long 3222667808 + .long 583706808 + .long 1067149757 + .long 1974968851 + .long 3217478792 + .long 3433705325 + .long 1077944360 + .long 3946626575 + .long 1081121452 + .long 1495561758 + .long 1071787114 + .long 4062466621 + .long 3220390645 + .long 1556755231 + .long 1075170624 + .long 75679593 + .long 3223694033 + .long 3504606470 + .long 1068150172 + .long 1348305099 + .long 3218489288 + .long 3580634696 + .long 1078988808 + .long 1259291510 + .long 1082352761 + .long 652214916 + .long 1072807425 + .long 4143445962 + .long 3221412067 + .long 2123749472 + .long 1076202613 + .long 4248403985 + .long 3224731560 + .long 1507106795 + .long 1069174188 + .long 3519298167 + .long 3219518582 + .long 3633366982 + .long 1080035328 + .long 2867629808 + .long 1083583554 + .long 3975256969 + .long 1073841792 + .long 2533063588 + .long 3222447083 + .long 3711656185 + .long 1077242956 + .long 3206083648 + .long 3225774644 + .long 4129446490 + .long 1070209876 + .long 3121668168 + .long 3220557159 + .long 3645659330 + .long 1081082878 + .long 1254870306 + .long 1084814091 + .long 1589013900 + .long 1074883091 + .long 485315198 + .long 3223488795 + .long 402512060 + .long 1078287430 + .long 1922980292 + .long 3226820482 + .long 157052617 + .long 1071251449 + .long 2992469705 + .long 3221600396 + .long 1492808525 + .long 1082130942 + .long 3131814131 + .long 1086044499 + .long 2683002247 + .long 1075927855 + .long 2649378904 + .long 3224533843 + .long 3018380877 + .long 1079333956 + .long 653917322 + .long 3227867691 + .long 2713966257 + .long 1072296037 + .long 4209563533 + .long 3222646006 + .long 943575735 + .long 1083179262 + .long 512478091 + .long 1087274844 + .long 3856346814 + .long 1076974372 + .long 1324813592 + .long 3225580569 + .long 1409229319 + .long 1080381507 + .long 3787450294 + .long 3228915583 + .long 3333539597 + .long 1073342203 + .long 2943809629 + .long 3223692845 + .long 794946536 + .long 1084227710 + .long 1068889795 + .long 1088463522 + .long 3231716378 + .long 1078021787 + .long 4072054083 + .long 3226628144 + .long 1998042203 + .long 1081429569 + .long 1148344549 + .long 3229963818 + .type _C5,@object + .size _C5,704 + .align 16 +_C5_0: + .long 2415979356 + .long 1070304454 + .long 2697119297 + .long 3218348439 + .long 4195263586 + .long 1073523467 + .long 3725211212 + .long 1070931684 + .long 2560716363 + .long 3219131775 + .long 4079479268 + .long 1075907809 + .long 1732432466 + .long 1071796064 + .long 3508892908 + .long 3219947991 + .long 2788858919 + .long 1077667382 + .long 2647999156 + .long 1072759450 + .long 547175205 + .long 3220886396 + .long 4254853098 + .long 1079215590 + .long 2099688739 + .long 1073767129 + .long 1386213411 + .long 3221881825 + .long 1373988558 + .long 1080631372 + .long 3012547841 + .long 1074795638 + .long 3012018428 + .long 3222904295 + .long 3968063321 + .long 1082046682 + .long 2372211290 + .long 1075829504 + .long 1852200321 + .long 3223939920 + .long 822603622 + .long 1083320025 + .long 2940107565 + .long 1076868074 + .long 1118670349 + .long 3224982033 + .long 4034033966 + .long 1084551076 + .long 3328910691 + .long 1077911588 + .long 4065388177 + .long 3226027369 + .long 3374537656 + .long 1085781831 + .long 3604631852 + .long 1078957575 + .long 786281660 + .long 3227074315 + .long 3320933858 + .long 1087012393 + .long 4128496013 + .long 1080004805 + .long 820316847 + .long 3228122065 + .long 596318476 + .long 1088242837 + .type _C5_0,@object + .size _C5_0,264 + .space 8, 0x00 # pad + .align 16 +_C4: + .long 951661919 + .long 3199388794 + .long 406044492 + .long 1057185581 + .long 2144499589 + .long 3220511658 + .long 1533861631 + .long 1073519965 + .long 4190848711 + .long 3208779382 + .long 4195628742 + .long 1064581106 + .long 501584638 + .long 3218581252 + .long 4276665641 + .long 1072296199 + .long 2679252139 + .long 3214810152 + .long 1146917984 + .long 1069511714 + .long 3597634954 + .long 3220184694 + .type _C4,@object + .size _C4,88 + .space 8, 0x00 # pad + .align 16 +_C3: + .long 953601802 + .long 1073782987 + .long 53392282 + .long 1061851682 + .long 2280564131 + .long 3213671573 + .long 126074441 + .long 1073190208 + .long 1099663909 + .long 3221770684 + .long 2017365083 + .long 1069271442 + .long 1709742889 + .long 3219105406 + .long 4029656968 + .long 1074967560 + .long 3888843833 + .long 3222480972 + .type _C3,@object + .size _C3,72 + .space 8, 0x00 # pad + .align 16 +_LGAMMAF_C2: + .long 4192182476 + .long 1073863432 + .long 3945858175 + .long 1063638439 + .long 2616885214 + .long 3215216300 + .long 3886441432 + .long 1074077679 + .long 3758761250 + .long 3222447567 + .long 984616456 + .long 1070653784 + .long 2508733349 + .long 3220210863 + .long 2272977058 + .long 1075337602 + .long 3074119607 + .long 3222665277 + .type _LGAMMAF_C2,@object + .size _LGAMMAF_C2,72 + .space 8, 0x00 # pad + .align 16 +_LM: + .long 1666629183 + .long 1073177304 + .type _LM,@object + .size _LM,8 + .space 8, 0x00 # pad + .align 16 +_C1: + .long 3166931522 + .long 3216972217 + .long 900077338 + .long 1065586189 + .long 3591574455 + .long 3213040571 + .long 425993680 + .long 1068534592 + .long 2772351024 + .long 3217220647 + .long 3693139651 + .long 1066567133 + .long 2619486276 + .long 3214985484 + .long 3371509884 + .long 1071576875 + .long 2931564028 + .long 1032391485 + .type _C1,@object + .size _C1,72 + .space 8, 0x00 # pad + .align 16 +_C0: + .long 561403216 + .long 1074066324 + .long 3155481408 + .long 1068272863 + .long 4228834524 + .long 3219267730 + .long 2107372888 + .long 1076349696 + .long 3392182390 + .long 3224133636 + .long 3282054928 + .long 1074040136 + .long 4253763640 + .long 3223020498 + .long 1528000942 + .long 1076400076 + .long 4059292707 + .long 3223275314 + .type _C0,@object + .size _C0,72 + .space 8, 0x00 # pad + .align 16 +_LRIB: + .long 2838661661 + .long 3221617475 + .long 169597185 + .long 3221617473 + .long 1795500005 + .long 3221617470 + .long 3503748181 + .long 3222250619 + .long 1417424869 + .long 3222250609 + .long 2147483648 + .long 3222250589 + .type _LRIB,@object + .size _LRIB,48 + .align 16 +_LRP: + .long 3272807679 + .long 3224639578 + .long 1009311715 + .long 1076045439 + .long 2835657108 + .long 3221135661 + .long 817526409 + .long 1017707397 + .long 2658191496 + .long 3232572725 + .long 2929834182 + .long 1081046750 + .long 2523682372 + .long 3224680861 + .long 915934040 + .long 3166559235 + .type _LRP,@object + .size _LRP,64 + .align 16 +_RRIB: + .long 890743176 + .long 3221465087 + .long 2516645996 + .long 3221465084 + .long 4142548816 + .long 3221465081 + .long 1538591435 + .long 3221825040 + .long 3164494255 + .long 3221825037 + .long 495429779 + .long 3221825035 + .type _RRIB,@object + .size _RRIB,48 + .align 16 +_RRP: + .long 93164946 + .long 1073124518 + .long 2953029931 + .long 1075015403 + .long 1722766176 + .long 1073233897 + .long 1830807661 + .long 1016083003 + .long 308861496 + .long 1079775543 + .long 2541562915 + .long 1077531858 + .long 1596959842 + .long 1075781798 + .long 3819862626 + .long 1021220357 + .type _RRP,@object + .size _RRP,64 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 4 +.L_2il0floatpacket.2: + .long 0xc0200000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x4b400000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +.L_2il0floatpacket.4: + .long 0x40000000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .align 4 +.L_2il0floatpacket.6: + .long 0x3f800000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,4 + .align 4 +_S16: + .long 2760304672 + .long 3218442033 + .type _S16,@object + .size _S16,8 + .align 4 +_S14: + .long 3264091561 + .long 3215213868 + .type _S14,@object + .size _S14,8 + .align 4 +_S12: + .long 1381164920 + .long 3217582605 + .type _S12,@object + .size _S12,8 + .align 4 +_S10: + .long 3387828299 + .long 3217636872 + .type _S10,@object + .size _S10,8 + .align 4 +_S08: + .long 3786959951 + .long 3218084854 + .type _S08,@object + .size _S08,8 + .align 4 +_S06: + .long 2675586079 + .long 3218453489 + .type _S06,@object + .size _S06,8 + .align 4 +_S04: + .long 1432133341 + .long 3219214642 + .type _S04,@object + .size _S04,8 + .align 4 +_S02: + .long 1648889397 + .long 3220853158 + .type _S02,@object + .size _S02,8 + .align 4 +_PBIG: + .long 2139095039 + .long 2139095039 + .type _PBIG,@object + .size _PBIG,8 + .align 4 +.L_2il0floatpacket.8: + .long 0xcb400000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lgammal.S b/external/sgx_libm/intel64/lgammal.S new file mode 100644 index 0000000000..156681889b --- /dev/null +++ b/external/sgx_libm/intel64/lgammal.S @@ -0,0 +1,9424 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lgammal.c" + .text +..TXTST0: +# -- Begin lgammal + .text + .align 16,0x90 + .globl lgammal +lgammal: +# parameter 1: 16 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_lgammal.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + fldt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 32 + lea 16(%rsp), %rdi + fstpt (%rsp) +..___tag_value_lgammal.5: + call __libm_lgammal +..___tag_value_lgammal.6: +..B1.2: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type lgammal,@function + .size lgammal,.-lgammal + .data +# -- End lgammal + .text +# -- Begin __libm_lgammal + .text + .align 16,0x90 +__libm_lgammal: +# parameter 1: 336 + %rsp +# parameter 2: %rdi +..B2.1: + .cfi_startproc +..___tag_value___libm_lgammal.9: +..L10: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $280, %rsp + .cfi_def_cfa_offset 336 + movq %rdi, %rbp + movq %fs:40, %rax + xorl %r12d, %r12d + xorq %rsp, %rax + xorb %r14b, %r14b + movq %rax, 272(%rsp) +..B2.2: + fnstcw 194(%rsp) +..B2.3: +..___tag_value___libm_lgammal.24: + call fegetround@PLT +..___tag_value___libm_lgammal.25: +..B2.275: + movl %eax, %r13d +..B2.4: + testl %r13d, %r13d + je ..B2.6 +..B2.5: + xorl %edi, %edi + movl $1, %r12d +..___tag_value___libm_lgammal.26: + call fesetround@PLT +..___tag_value___libm_lgammal.27: +..B2.6: + movzwl 194(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B2.10 +..B2.7: + orl $-64768, %edx + movw %dx, 192(%rsp) +..B2.8: + fldcw 192(%rsp) +..B2.9: + movb $1, %r14b +..B2.10: + movzbl 345(%rsp), %ecx + lea ones(%rip), %rax + movl %ecx, %r15d + andl $128, %r15d + shrl $7, %r15d + movzwl 344(%rsp), %ebx + movss (%rax,%r15,4), %xmm0 + andl $32767, %ebx + shll $15, %r15d + orl %ebx, %r15d + shll $16, %r15d + movzwl 342(%rsp), %edx + orl %edx, %r15d + cmpl $32767, %ebx + je ..B2.259 +..B2.11: + fldt 336(%rsp) + fldt .L_2il0floatpacket.0(%rip) + fucomi %st(1), %st + jp ..B2.12 + je ..B2.252 +..B2.12: + lea _OFW_BOUND(%rip), %rax + fldt (%rax) + fcomip %st(2), %st + jb ..B2.244 +..B2.13: + fldt .L_2il0floatpacket.1(%rip) + fucomip %st(2), %st + jp ..B2.14 + je ..B2.235 +..B2.14: + fldt .L_2il0floatpacket.2(%rip) + fucomip %st(2), %st + jp ..B2.15 + je ..B2.235 +..B2.15: + testl %r15d, %r15d + jl ..B2.227 +..B2.16: + cmpl $16382, %ebx + jl ..B2.163 +..B2.17: + cmpl $16463, %ebx + jge ..B2.156 +..B2.18: + fldt .L_2il0floatpacket.4(%rip) + fcomip %st(2), %st + jbe ..B2.146 +..B2.19: + fldt .L_2il0floatpacket.5(%rip) + fcomip %st(2), %st + jae ..B2.113 + jp ..B2.113 +..B2.20: + movl %r15d, %eax + andl $2147483647, %eax + cmpl $1073659904, %eax + jl ..B2.104 +..B2.21: + fcomi %st(1), %st + jae ..B2.24 + jp ..B2.24 +..B2.22: + fldt .L_2il0floatpacket.10(%rip) + fcomip %st(2), %st + jbe ..B2.24 +..B2.23: + fstp %st(0) + fldt .L_2il0floatpacket.11(%rip) + movl $1, (%rbp) + jmp ..B2.27 +..B2.24: + fldt .L_2il0floatpacket.11(%rip) + fcomi %st(2), %st + jae ..B2.37 + jp ..B2.37 +..B2.25: + fldt .L_2il0floatpacket.12(%rip) + fcomip %st(3), %st + jbe ..B2.37 +..B2.26: + fstp %st(1) + movl $1, (%rbp) +..B2.27: + lea 2800+_ldbA(%rip), %rdx + lea 480+_dbA(%rip), %rcx + fcomip %st(1), %st + jae ..B2.29 + jp ..B2.29 +..B2.28: + fldt .L_2il0floatpacket.2(%rip) + lea 656+_dbA(%rip), %rcx + lea 2912+_ldbA(%rip), %rdx + fsubrp %st, %st(1) + jmp ..B2.30 +..B2.29: + fldt .L_2il0floatpacket.1(%rip) + fsubp %st, %st(1) +..B2.30: + fldl 88(%rcx) + lea _TWO_32H(%rip), %rax + fmul %st(1), %st + fld %st(1) + fld %st(2) + testl %r12d, %r12d + fldl (%rax) + fmul %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(3) + fsub %st(2), %st + fldt (%rdx) + fxch %st(4) + faddl 104(%rcx) + fmul %st(5), %st + fldt 48(%rdx) + fldt 16(%rdx) + fxch %st(2) + faddl 96(%rcx) + fmul %st(7), %st + faddl 80(%rcx) + fmul %st(7), %st + faddl 152(%rcx) + fmul %st(7), %st + faddl 120(%rcx) + fmul %st(7), %st + faddl 112(%rcx) + fmul %st(7), %st + faddl 136(%rcx) + fmul %st(7), %st + faddl 128(%rcx) + fmul %st(7), %st + faddl 40(%rcx) + fmul %st(7), %st + faddl 32(%rcx) + fmul %st(7), %st + faddl 56(%rcx) + fmul %st(7), %st + faddl 48(%rcx) + fmul %st(7), %st + faddl 144(%rcx) + fmul %st(7), %st + faddp %st, %st(6) + fxch %st(5) + fmul %st(6), %st + faddp %st, %st(5) + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fldt 64(%rdx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 32(%rdx) + faddp %st, %st(1) + fmul %st(4), %st + fldt 80(%rdx) + faddp %st, %st(1) + fmul %st(4), %st + fld %st(1) + fldt 96(%rdx) + faddp %st, %st(2) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + fmul %st(6), %st + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fldl (%rcx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(3) + fmul %st(2), %st + fxch %st(1) + faddl 72(%rcx) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st(5), %st + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(1) + fldl 16(%rcx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl 168(%rcx) + faddp %st, %st(2) + fld %st(3) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(1) + fldl 64(%rcx) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl 8(%rcx) + faddp %st, %st(2) + fld %st(3) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(1) + fldl 160(%rcx) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddl 24(%rcx) + faddp %st, %st(1) + fld %st(1) + fadd %st(3), %st + fsubp %st, %st(3) + fxch %st(2) + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + fxch %st(1) + je ..B2.33 +..B2.31: + fstp %st(1) + fstp %st(0) + movl %r13d, %edi +..___tag_value___libm_lgammal.28: + call fesetround@PLT +..___tag_value___libm_lgammal.29: +..B2.32: + fldt (%rsp) + fldt 16(%rsp) +..B2.33: + testb %r14b, %r14b + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.35 +..B2.34: + fldcw 194(%rsp) +..B2.35: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.36: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.37: + fstp %st(0) + fcomi %st(1), %st + jae ..B2.46 + jp ..B2.46 +..B2.38: + fldt .L_2il0floatpacket.2(%rip) + fcomip %st(2), %st + jbe ..B2.46 +..B2.39: + fstp %st(0) + lea 3024+_ldbA(%rip), %rax + addq $-16, %rsp + .cfi_def_cfa_offset 352 + lea 3040+_ldbA(%rip), %rdi + lea 832+_dbA(%rip), %rsi + movl $1, (%rbp) + lea 16(%rsp), %rdx + fldt (%rax) + fsubrp %st, %st(1) + fstpt (%rsp) +..___tag_value___libm_lgammal.51: + call __libm_p25 +..___tag_value___libm_lgammal.52: +..B2.276: + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B2.40: + testl %r12d, %r12d + je ..B2.42 +..B2.41: + movl %r13d, %edi +..___tag_value___libm_lgammal.54: + call fesetround@PLT +..___tag_value___libm_lgammal.55: +..B2.42: + fldt (%rsp) + testb %r14b, %r14b + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.44 +..B2.43: + fldcw 194(%rsp) +..B2.44: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.45: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.46: + fcomi %st(1), %st + jbe ..B2.95 +..B2.47: + fldt .L_2il0floatpacket.14(%rip) + fcomi %st(2), %st + jae ..B2.56 + jp ..B2.56 +..B2.48: + fstp %st(0) + fldt .L_2il0floatpacket.15(%rip) + fcomi %st(2), %st + jbe ..B2.56 +..B2.49: + fstp %st(1) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + lea 3424+_ldbA(%rip), %rdi + lea 1360+_dbA(%rip), %rsi + lea 16(%rsp), %rdx + movl $-1, (%rbp) + fsubrp %st, %st(1) + fstpt (%rsp) +..___tag_value___libm_lgammal.77: + call __libm_p25 +..___tag_value___libm_lgammal.78: +..B2.277: + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B2.50: + testl %r12d, %r12d + je ..B2.52 +..B2.51: + movl %r13d, %edi +..___tag_value___libm_lgammal.80: + call fesetround@PLT +..___tag_value___libm_lgammal.81: +..B2.52: + fldt (%rsp) + testb %r14b, %r14b + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.54 +..B2.53: + fldcw 194(%rsp) +..B2.54: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.55: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.56: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstp %st(0) + fstpt (%rsp) + fldt (%rsp) + fstpt 64(%rsp) + call nearbyintl@PLT +..B2.278: + fldt 64(%rsp) + fldt .L_2il0floatpacket.0(%rip) + addq $16, %rsp + .cfi_def_cfa_offset 336 + fxch %st(2) + fucomi %st(1), %st + jp ..B2.57 + je ..B2.191 +..B2.57: + fldt .L_2il0floatpacket.17(%rip) + fcomip %st(2), %st + ja ..B2.69 + jp ..B2.69 +..B2.58: + fldt .L_2il0floatpacket.18(%rip) + fcomip %st(2), %st + jb ..B2.69 +..B2.59: + fstp %st(0) + fldt .L_2il0floatpacket.19(%rip) + fcomip %st(1), %st + jae ..B2.61 + jp ..B2.61 +..B2.60: + movl $-1, (%rbp) + jmp ..B2.62 +..B2.61: + movl $1, (%rbp) +..B2.62: + fldt .L_2il0floatpacket.1(%rip) + lea ones(%rip), %rdx + faddp %st, %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fld %st(0) + movb 105(%rsp), %al + andb $-128, %al + shrb $7, %al + fmul %st(1), %st + fstpt 128(%rsp) + fld %st(0) + fchs + movzbl %al, %ecx + fstpt 16(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + lea 240(%rsp), %rdi + fmuls (%rdx,%rcx,4) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_lgammal.105: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.106: +..B2.279: + fstp %st(0) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.63: + fldt 96(%rsp) + lea 1560+_dbA(%rip), %rax + fldt 16(%rsp) + lea 1552+_dbA(%rip), %rdx + lea 1544+_dbA(%rip), %rcx + lea 1536+_dbA(%rip), %rbx + lea 3600+_ldbA(%rip), %rbp + lea 3584+_ldbA(%rip), %rsi + fldl (%rax) + lea 1568+_dbA(%rip), %r10 + fmul %st(2), %st + lea 1576+_dbA(%rip), %r11 + fldt (%rbp) + lea 1584+_dbA(%rip), %r15 + fldt (%rsi) + lea 1592+_dbA(%rip), %rax + lea 3568+_ldbA(%rip), %r8 + lea 3552+_ldbA(%rip), %r9 + testl %r12d, %r12d + fxch %st(2) + faddl (%rdx) + fmul %st(4), %st + fldt (%r8) + fldt (%r9) + fxch %st(2) + faddl (%rcx) + fmul %st(6), %st + faddl (%rbx) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(2) + fldl (%r10) + fmul %st(1), %st + fldt 128(%rsp) + fxch %st(1) + faddl (%r11) + fmul %st(2), %st + faddl (%r15) + fmul %st(2), %st + faddl (%rax) + lea 1600+_dbA(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 1608+_dbA(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 1616+_dbA(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 1624+_dbA(%rip), %rax + fmul %st(2), %st + faddl (%rax) + lea 3664+_ldbA(%rip), %rax + fmul %st(2), %st + fmul %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 240(%rsp) + fldt 240(%rsp) + faddp %st, %st(2) + fldt (%rax) + lea 3648+_ldbA(%rip), %rax + fmul %st(1), %st + fldt (%rax) + lea 3632+_ldbA(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + lea 3616+_ldbA(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(1) + fsubp %st, %st(1) + fstpt (%rsp) + je ..B2.65 +..B2.64: + movl %r13d, %edi +..___tag_value___libm_lgammal.108: + call fesetround@PLT +..___tag_value___libm_lgammal.109: +..B2.65: + fldt 224(%rsp) + testb %r14b, %r14b + fldt (%rsp) + fsubp %st, %st(1) + fldt 208(%rsp) + fsubrp %st, %st(1) + fstpt 176(%rsp) + je ..B2.67 +..B2.66: + fldcw 194(%rsp) +..B2.67: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.68: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.69: + fnstcw (%rsp) + movzwl (%rsp), %eax + orl $3072, %eax + movl %eax, 8(%rsp) + fldcw 8(%rsp) + fistl 16(%rsp) + fldcw (%rsp) + fld %st(1) + lea 848+_ldbA(%rip), %r8 + movl 16(%rsp), %edx + fsubp %st, %st(1) + negl %edx + lea -2(%rdx), %eax + andl $1, %edx + jne ..B2.72 +..B2.70: + fcomi %st(2), %st + jae ..B2.73 + jp ..B2.73 +..B2.71: + movl $-1, (%rbp) + jmp ..B2.74 +..B2.72: + jne ..B2.188 +..B2.73: + movl $1, (%rbp) +..B2.74: + fldt .L_2il0floatpacket.20(%rip) + xorl %edx, %edx + fxch %st(2) + fcomi %st(2), %st + fxch %st(2) + fstp %st(0) + cmova %edx, %eax + movl $17, %ecx + xorl %ebp, %ebp + lea 1424+_ldbA(%rip), %rdx + fcomi %st(2), %st + cmova %ecx, %ebp + addl %ebp, %eax + movslq %eax, %rsi + shlq $4, %rsi + fldt (%rsi,%r8) + lea (%rax,%rax), %r8d + movslq %r8d, %r8 + fsubr %st(2), %st + shlq $4, %r8 + fldt (%r8,%rdx) + fcomip %st(3), %st + jae ..B2.84 + jp ..B2.84 +..B2.75: + fldt 16(%r8,%rdx) + fcomip %st(3), %st + jbe ..B2.84 +..B2.77: + fstp %st(3) + fstp %st(1) + lea _ldbA(%rip), %rbx + lea (%rax,%rax,2), %ecx + movslq %ecx, %rcx + lea (%rax,%rax,4), %eax + shll $2, %eax + lea _dbA(%rip), %rbp + shlq $4, %rcx + addq $-16, %rsp + .cfi_def_cfa_offset 352 + movslq %eax, %rax + lea 256(%rsp), %rdx + fxch %st(1) + fstpt (%rsp) + lea 4480(%rbx,%rcx), %rdi + fstpt 16(%rsp) + lea 2432(%rbp,%rax,8), %rsi +..___tag_value___libm_lgammal.131: + call __libm_p19root +..___tag_value___libm_lgammal.132: +..B2.280: + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B2.78: + testl %r12d, %r12d + je ..B2.80 +..B2.79: + movl %r13d, %edi + fstpt (%rsp) +..___tag_value___libm_lgammal.134: + call fesetround@PLT +..___tag_value___libm_lgammal.135: +..B2.305: + fldt (%rsp) +..B2.80: + fldt 240(%rsp) + testb %r14b, %r14b + fldt 256(%rsp) + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.311 +..B2.81: + fstpt 96(%rsp) +..B2.281: + fldcw 194(%rsp) + jmp ..B2.82 +..B2.311: + fstp %st(0) +..B2.82: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.83: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.84: + fstp %st(0) + fstpt 96(%rsp) +..B2.85: + lea -16382(%rbx), %eax + cmpl $2, %eax + jne ..B2.87 +..B2.86: + fldt .L_2il0floatpacket.21(%rip) + addl $-16380, %ebx + fcomip %st(1), %st + cmova %ebx, %eax +..B2.87: + fldt .L_2il0floatpacket.19(%rip) + lea (%rax,%rax,4), %edx + fmul %st, %st(1) + lea (%rdx,%rdx), %eax + fstp %st(2) + fstpt 80(%rsp) + lea _dbA(%rip), %rsi + fldt .L_2il0floatpacket.16(%rip) + lea _ldbA(%rip), %rbx + movzwl 88(%rsp), %ecx + lea _TWO_32H(%rip), %rbp + andl $-32768, %ecx + orl $-49153, %ecx + movw %cx, 88(%rsp) + fldt 80(%rsp) + shll $2, %edx + fsubp %st, %st(1) + movslq %edx, %rdx + movslq %eax, %rax + shlq $4, %rax + fstpt 80(%rsp) + fldt 80(%rsp) + fldl 1784(%rsi,%rdx,8) + fmul %st(1), %st + fldt 3824(%rbx,%rax) + fldt 3808(%rbx,%rax) + fldt 3792(%rbx,%rax) + fldt 3776(%rbx,%rax) + fldt 3760(%rbx,%rax) + fxch %st(5) + faddl 1776(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1768(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1760(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1752(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1744(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1736(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1728(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1720(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1712(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1704(%rsi,%rdx,8) + fmul %st(6), %st + faddl 1696(%rsi,%rdx,8) + fmul %st(6), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + fldt 3744(%rbx,%rax) + faddp %st, %st(1) + fmul %st(1), %st + fldt 3728(%rbx,%rax) + faddp %st, %st(1) + fmul %st(1), %st + fld %st(1) + fldt 3712(%rbx,%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt 3696(%rbx,%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 3680(%rbx,%rax) + faddp %st, %st(1) + fldl (%rbp) + fld %st(0) + fmul %st(4), %st + fadd %st, %st(3) + fsubrp %st, %st(3) + fxch %st(2) + fstpt 160(%rsp) + fldt 160(%rsp) + fld %st(2) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(2), %st + fxch %st(1) + fsubr %st, %st(3) + fld %st(3) + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(6) + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(2) + fldl 1632(%rsi,%rdx,8) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(4) + fmul %st(2), %st + fxch %st(1) + faddl 1640(%rsi,%rdx,8) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(1) + fmul %st(4), %st + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(5), %st + faddp %st, %st(2) + fldl 1680(%rsi,%rdx,8) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(4) + fmul %st(2), %st + fxch %st(1) + faddl 1688(%rsi,%rdx,8) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(1) + fmul %st(4), %st + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(1) + fmul %st(5), %st + faddp %st, %st(2) + fldl 1664(%rsi,%rdx,8) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fxch %st(1) + faddl 1672(%rsi,%rdx,8) + faddp %st, %st(3) + fld %st(4) + fmul %st(2), %st + fstpt 128(%rsp) + fldt 128(%rsp) + fadd %st, %st(1) + fxch %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fldl 1648(%rsi,%rdx,8) + fld %st(0) + fadd %st(4), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.0(%rip) + fxch %st(3) + faddl 1656(%rsi,%rdx,8) + faddp %st, %st(1) + fstpt (%rsp) + fldt 336(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + fmulp %st, %st(3) + lea 272(%rsp), %rdi + fxch %st(2) + fstpt (%rsp) + fstpt 16(%rsp) + fstpt 64(%rsp) +..___tag_value___libm_lgammal.157: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.158: +..B2.282: + fstp %st(0) + fldt .L_2il0floatpacket.0(%rip) + fldt 64(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.88: + fldt 96(%rsp) + lea ones(%rip), %rdx + movb 105(%rsp), %al + addq $-32, %rsp + .cfi_def_cfa_offset 368 + andb $-128, %al + lea 240(%rsp), %rdi + shrb $7, %al + movzbl %al, %ecx + fmuls (%rdx,%rcx,4) + fstpt (%rsp) + fldt (%rsp) + fxch %st(2) + fstpt 16(%rsp) + fxch %st(1) + fstpt 80(%rsp) + fstpt 64(%rsp) +..___tag_value___libm_lgammal.161: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.162: +..B2.283: + fstp %st(0) + fldt 64(%rsp) + fldt 80(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.89: + fld %st(0) + lea 544+_ldbA(%rip), %rcx + fmul %st(2), %st + fld %st(1) + lea 528+_ldbA(%rip), %rbx + lea 512+_ldbA(%rip), %rbp + lea 496+_ldbA(%rip), %rsi + lea 480+_ldbA(%rip), %r8 + lea 464+_ldbA(%rip), %r9 + lea 448+_ldbA(%rip), %r10 + lea 432+_ldbA(%rip), %r11 + lea 416+_ldbA(%rip), %r15 + lea 304+_ldbA(%rip), %rax + lea 48+_dbA(%rip), %rdx + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(1) + fsub %st(1), %st + fxch %st(2) + fmul %st(0), %st + fldt (%rcx) + lea 400+_ldbA(%rip), %rcx + fmul %st(1), %st + fldt (%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r15) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 384+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 368+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 352+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 336+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fld %st(2) + fmul %st(3), %st + fldt (%rcx) + lea 320+_ldbA(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rax) + lea 64+_dbA(%rip), %rax + faddp %st, %st(2) + fld %st(0) + fldt .L_2il0floatpacket.2(%rip) + fmulp %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fld %st(5) + fmul %st(3), %st + fxch %st(5) + fmul %st(0), %st + faddp %st, %st(1) + fld %st(5) + fmul %st(2), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(3) + fld %st(3) + fadd %st(6), %st + fsubp %st, %st(6) + fmul %st(5), %st + fxch %st(2) + fsub %st(4), %st + faddp %st, %st(1) + fld %st(3) + fxch %st(3) + fsub %st(5), %st + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(3) + fmul %st(4), %st + faddp %st, %st(2) + fldl (%rax) + fld %st(0) + lea 72+_dbA(%rip), %rax + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(6) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fld %st(4) + fxch %st(2) + faddl (%rax) + lea 56+_dbA(%rip), %rax + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fmul %st(1), %st + fld %st(3) + fmul %st(3), %st + fxch %st(3) + fmul %st(5), %st + faddp %st, %st(1) + fxch %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fldl (%rdx) + fld %st(0) + lea ones(%rip), %rdx + fadd %st(3), %st + fmul %st, %st(6) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(6), %st + fsubp %st, %st(6) + fxch %st(2) + fsub %st(5), %st + fld %st(3) + fmul %st(6), %st + fstpt 64(%rsp) + fxch %st(4) + fmul %st, %st(5) + fxch %st(2) + faddl (%rax) + faddp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 80(%rsp) + fldt 16(%rsp) + fld %st(0) + fld %st(1) + fld %st(2) + fldt (%rsp) + fadd %st, %st(1) + fxch %st(1) + fstpt 128(%rsp) + fldt 128(%rsp) + fldt 240(%rsp) + fld %st(0) + fxch %st(1) + fadd %st, %st(5) + movb 137(%rsp), %al + fxch %st(4) + fsub %st(5), %st + andb $-128, %al + fadd %st(4), %st + shrb $7, %al + fadd %st(3), %st + fxch %st(4) + fsub %st(5), %st + movzbl %al, %eax + faddp %st, %st(6) + fxch %st(1) + fmuls (%rdx,%rax,4) + fldt 256(%rsp) + fadd %st, %st(2) + fxch %st(2) + fstpt 144(%rsp) + fldt 144(%rsp) + fxch %st(2) + fadd %st, %st(6) + movb 153(%rsp), %al + fxch %st(3) + faddp %st, %st(6) + fxch %st(2) + faddp %st, %st(3) + fldt 208(%rsp) + andb $-128, %al + fld %st(0) + fldt 64(%rsp) + shrb $7, %al + fadd %st, %st(1) + fxch %st(1) + fchs + fadd %st, %st(2) + movzbl %al, %eax + fxch %st(2) + fchs + fsubp %st, %st(1) + fld %st(1) + fsub %st(6), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(3) + fmuls (%rdx,%rax,4) + fxch %st(4) + fcomip %st(4), %st + fxch %st(3) + fstp %st(0) + fxch %st(5) + fcmovnbe %st(3), %st + fstp %st(3) + fld %st(4) + fldt 224(%rsp) + fsubrp %st, %st(3) + fld %st(4) + fadd %st(4), %st + fstpt 144(%rsp) + fldt 144(%rsp) + fldt 80(%rsp) + fsubrp %st, %st(4) + fxch %st(1) + fadd %st(3), %st + fstpt 128(%rsp) + fldt 128(%rsp) + fld %st(6) + movb 137(%rsp), %al + fsub %st(3), %st + andb $-128, %al + fsub %st(6), %st + shrb $7, %al + fadd %st(4), %st + movzbl %al, %eax + fsub %st(5), %st + fxch %st(3) + faddp %st, %st(6) + fxch %st(5) + fchs + faddp %st, %st(6) + fxch %st(3) + fsubrp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fxch %st(2) + fmuls (%rdx,%rax,4) + movb 153(%rsp), %al + andb $-128, %al + shrb $7, %al + fstpt 128(%rsp) + fldt 128(%rsp) + movzbl %al, %eax + fxch %st(1) + fmuls (%rdx,%rax,4) + fxch %st(1) + fcomip %st(1), %st + fxch %st(2) + fcmovnbe %st(1), %st + fstp %st(1) + fstpt 32(%rsp) + testl %r12d, %r12d + je ..B2.91 +..B2.90: + movl %r13d, %edi + fstpt (%rsp) +..___tag_value___libm_lgammal.164: + call fesetround@PLT +..___tag_value___libm_lgammal.165: +..B2.303: + fldt (%rsp) +..B2.91: + fldt 32(%rsp) + testb %r14b, %r14b + fldt 48(%rsp) + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.312 +..B2.92: + fstpt 144(%rsp) +..B2.284: + fldcw 194(%rsp) + jmp ..B2.93 +..B2.312: + fstp %st(0) +..B2.93: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.94: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.95: + fstp %st(0) + fldt .L_2il0floatpacket.13(%rip) + lea 3168+_ldbA(%rip), %rdi + movl $1, (%rbp) + lea 1008+_dbA(%rip), %rsi + fmul %st, %st(1) + cmpl $16385, %ebx + jne ..B2.97 +..B2.96: + fmul %st, %st(1) + lea 1184+_dbA(%rip), %rsi + lea 3296+_ldbA(%rip), %rdi +..B2.97: + fstp %st(0) + fldt .L_2il0floatpacket.16(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fsubrp %st, %st(1) + fstpt (%rsp) + lea 16(%rsp), %rdx +..___tag_value___libm_lgammal.187: + call __libm_p25 +..___tag_value___libm_lgammal.188: +..B2.285: + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B2.98: + testl %r12d, %r12d + je ..B2.100 +..B2.99: + movl %r13d, %edi +..___tag_value___libm_lgammal.190: + call fesetround@PLT +..___tag_value___libm_lgammal.191: +..B2.100: + fldt (%rsp) + testb %r14b, %r14b + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.102 +..B2.101: + fldcw 194(%rsp) +..B2.102: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.103: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.104: + fstp %st(0) + fldt .L_2il0floatpacket.8(%rip) + lea 2544+_ldbA(%rip), %rdi + lea 128+_dbA(%rip), %rsi + testl %r15d, %r15d + fsubr %st(1), %st + jl ..B2.200 +..B2.105: + fstp %st(1) + movl $1, (%rbp) +..B2.106: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + lea 16(%rsp), %rdx + fstpt (%rsp) +..___tag_value___libm_lgammal.213: + call __libm_p25 +..___tag_value___libm_lgammal.214: +..B2.286: + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B2.107: + testl %r12d, %r12d + je ..B2.109 +..B2.108: + movl %r13d, %edi +..___tag_value___libm_lgammal.216: + call fesetround@PLT +..___tag_value___libm_lgammal.217: +..B2.109: + fldt (%rsp) + testb %r14b, %r14b + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.111 +..B2.110: + fldcw 194(%rsp) +..B2.111: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.112: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.113: + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fstp %st(0) + fstpt (%rsp) + fldt (%rsp) + movss %xmm0, 48(%rsp) + fstpt 64(%rsp) + call nearbyintl@PLT +..B2.287: + fldt 64(%rsp) + fld %st(0) + movss 48(%rsp), %xmm0 + addq $16, %rsp + .cfi_def_cfa_offset 336 + fsub %st(2), %st + fldt .L_2il0floatpacket.0(%rip) + fucomi %st(1), %st + jp ..B2.114 + je ..B2.209 +..B2.114: + fldt .L_2il0floatpacket.9(%rip) + fcomip %st(3), %st + jae ..B2.131 + jp ..B2.131 +..B2.115: + fxch %st(3) + fnstcw (%rsp) + movzwl (%rsp), %eax + orl $3072, %eax + movl %eax, 8(%rsp) + fldcw 8(%rsp) + fistl 16(%rsp) + fldcw (%rsp) + lea 848+_ldbA(%rip), %rbx + movl 16(%rsp), %r8d + movl %r8d, %edx + negl %edx + lea -2(%rdx), %eax + addl $15, %edx + fxch %st(1) + fcomi %st(3), %st + cmova %edx, %eax + lea 1424+_ldbA(%rip), %rdx + movslq %eax, %rcx + shlq $4, %rcx + lea (%rax,%rax), %esi + movslq %esi, %rsi + fldt (%rcx,%rbx) + shlq $4, %rsi + fsubr %st(3), %st + fldt (%rsi,%rdx) + fcomip %st(4), %st + jae ..B2.129 + jp ..B2.129 +..B2.116: + fldt 16(%rsi,%rdx) + fcomip %st(4), %st + jbe ..B2.129 +..B2.117: + fstp %st(2) + fstp %st(2) + negl %r8d + andl $1, %r8d + jne ..B2.120 +..B2.118: + fxch %st(2) + fcomi %st(1), %st + fxch %st(2) + jbe ..B2.121 +..B2.119: + fstp %st(2) + movl $-1, (%rbp) + jmp ..B2.122 +..B2.120: + jne ..B2.202 +..B2.121: + fstp %st(2) + movl $1, (%rbp) +..B2.122: + lea _ldbA(%rip), %rbx + lea (%rax,%rax,2), %ecx + movslq %ecx, %rcx + lea (%rax,%rax,4), %eax + shll $2, %eax + lea _dbA(%rip), %rbp + shlq $4, %rcx + addq $-16, %rsp + .cfi_def_cfa_offset 352 + movslq %eax, %rax + lea 256(%rsp), %rdx + fxch %st(1) + fstpt (%rsp) + lea 4480(%rbx,%rcx), %rdi + fstpt 16(%rsp) + lea 2432(%rbp,%rax,8), %rsi +..___tag_value___libm_lgammal.241: + call __libm_p19root +..___tag_value___libm_lgammal.242: +..B2.288: + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 336 +..B2.123: + testl %r12d, %r12d + je ..B2.125 +..B2.124: + movl %r13d, %edi + fstpt (%rsp) +..___tag_value___libm_lgammal.244: + call fesetround@PLT +..___tag_value___libm_lgammal.245: +..B2.307: + fldt (%rsp) +..B2.125: + fldt 240(%rsp) + testb %r14b, %r14b + fldt 256(%rsp) + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.313 +..B2.126: + fstpt 96(%rsp) +..B2.289: + fldcw 194(%rsp) + jmp ..B2.127 +..B2.313: + fstp %st(0) +..B2.127: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.128: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.129: + fstp %st(0) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(1) + fxch %st(3) + fxch %st(1) + jmp ..B2.132 +..B2.131: + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) +..B2.132: + fldt .L_2il0floatpacket.13(%rip) + addq $-16, %rsp + .cfi_def_cfa_offset 352 + fmulp %st, %st(4) + fstp %st(1) + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + fstpt 32(%rsp) + fxch %st(1) + fstpt 16(%rsp) + movss %xmm0, 48(%rsp) + fstpt 64(%rsp) + call nearbyintl@PLT +..B2.290: + fldt 64(%rsp) + fldt 16(%rsp) + fldt 32(%rsp) + fldt .L_2il0floatpacket.0(%rip) + movss 48(%rsp), %xmm0 + addq $16, %rsp + .cfi_def_cfa_offset 336 + fxch %st(4) + fucomip %st(1), %st + fstp %st(0) + jp ..B2.133 + je ..B2.206 +..B2.133: + fcomip %st(2), %st + jbe ..B2.135 +..B2.134: + movl $-1, (%rbp) + jmp ..B2.136 +..B2.135: + movl $1, (%rbp) +..B2.136: + movss %xmm0, (%rsp) + fxch %st(1) + flds (%rsp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + lea 272(%rsp), %rdi + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_lgammal.269: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.270: +..B2.291: + fstp %st(0) + fldt .L_2il0floatpacket.0(%rip) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.137: + fldt 240(%rsp) + lea _TWO_32H(%rip), %rax + fldt 256(%rsp) + fstp %st(2) + lea 560+_ldbA(%rip), %rdx + fldt 80(%rsp) + fld %st(0) + fld %st(1) + fldl (%rax) + lea 80+_dbA(%rip), %rax + fstpt 16(%rsp) + fldt 16(%rsp) + fmul %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + fld %st(2) + fsub %st(1), %st + fldt .L_2il0floatpacket.13(%rip) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmul %st(7), %st + fstpt 48(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fsubrp %st, %st(6) + fxch %st(3) + fmul %st(5), %st + fstpt 128(%rsp) + fldt 128(%rsp) + fld %st(5) + fadd %st(1), %st + fstpt 144(%rsp) + fldt 144(%rsp) + fsubp %st, %st(1) + fsubr %st, %st(5) + fxch %st(6) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fld %st(5) + fmul %st(2), %st + fxch %st(4) + fmul %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fld %st(3) + fadd %st(3), %st + fstpt (%rsp) + fldt (%rsp) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(4) + faddp %st, %st(2) + fldt 48(%rsp) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) + fldt .L_2il0floatpacket.7(%rip) + fcomip %st(1), %st + fstp %st(0) + fldt .L_2il0floatpacket.0(%rip) + jbe ..B2.139 +..B2.138: + lea 704+_ldbA(%rip), %rdx + lea 96+_dbA(%rip), %rax +..B2.139: + fldt .L_2il0floatpacket.1(%rip) + fld %st(3) + fstp %st(2) + movb 105(%rsp), %cl + lea ones(%rip), %rbx + andb $-128, %cl + fxch %st(1) + fadd %st(2), %st + shrb $7, %cl + fdivr %st(1), %st + fld %st(3) + fldt 16(%rsp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + movzbl %cl, %ebp + fadd %st(4), %st + fsubp %st, %st(1) + fmul %st, %st(6) + fxch %st(4) + fsubrp %st, %st(6) + fxch %st(2) + fsub %st(3), %st + fld %st(0) + fadd %st(4), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st, %st(2) + fxch %st(5) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(5) + fmulp %st, %st(4) + fxch %st(3) + fsubrp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fmul %st(0), %st + fldt 128(%rdx) + fmul %st(1), %st + fldt 112(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 80(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 64(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 32(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 16(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx) + lea 120+_dbA(%rip), %rdx + faddp %st, %st(1) + fmulp %st, %st(1) + fldl (%rax) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(5) + fld %st(0) + fadd %st(6), %st + fsubp %st, %st(6) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(5), %st + fstpt 240(%rsp) + fldt 240(%rsp) + fxch %st(2) + fsub %st(5), %st + fxch %st(4) + fmul %st, %st(5) + fxch %st(1) + faddl 8(%rax) + lea 112+_dbA(%rip), %rax + faddp %st, %st(4) + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 256(%rsp) + fldt 256(%rsp) + fldl (%rax) + fld %st(0) + fadd %st(3), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(2) + fldt 96(%rsp) + fmuls (%rbx,%rbp,4) + fxch %st(2) + faddl (%rdx) + faddp %st, %st(1) + fstpt 48(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + lea 240(%rsp), %rdi + fstpt (%rsp) + fldt (%rsp) + fldt .L_2il0floatpacket.0(%rip) + fstpt 16(%rsp) + fstpt -128(%rdi) +..___tag_value___libm_lgammal.273: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.274: +..B2.292: + fstp %st(0) + fldt 112(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.140: + fldt 16(%rsp) + lea 544+_ldbA(%rip), %rcx + fld %st(1) + lea 528+_ldbA(%rip), %rbx + lea 512+_ldbA(%rip), %rbp + lea 496+_ldbA(%rip), %rsi + fmul %st(1), %st + fld %st(2) + lea 480+_ldbA(%rip), %r8 + lea 464+_ldbA(%rip), %r9 + lea 448+_ldbA(%rip), %r10 + lea 432+_ldbA(%rip), %r11 + lea 416+_ldbA(%rip), %r15 + lea 304+_ldbA(%rip), %rax + lea 48+_dbA(%rip), %rdx + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(2) + fsub %st(1), %st + fxch %st(3) + fmul %st(0), %st + fldt (%rcx) + lea 400+_ldbA(%rip), %rcx + fmul %st(1), %st + fldt (%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r15) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 384+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 368+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 352+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 336+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + lea 320+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(1), %st + fld %st(3) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fld %st(2) + fmul %st(3), %st + fmul %st, %st(2) + fldt (%rax) + lea 64+_dbA(%rip), %rax + faddp %st, %st(2) + fldt .L_2il0floatpacket.2(%rip) + fmulp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fld %st(4) + fmul %st(2), %st + fxch %st(6) + fmul %st(0), %st + faddp %st, %st(1) + fld %st(3) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fld %st(2) + fadd %st(7), %st + fsubp %st, %st(7) + fmul %st(6), %st + fxch %st(3) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fxch %st(2) + fsub %st(6), %st + fmul %st, %st(2) + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(2) + fmul %st(5), %st + faddp %st, %st(1) + fldl (%rax) + fld %st(0) + lea 72+_dbA(%rip), %rax + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fld %st(5) + fmul %st(4), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(3) + fld %st(4) + fxch %st(2) + faddl (%rax) + lea 56+_dbA(%rip), %rax + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmul %st(2), %st + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(1) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fldl (%rdx) + fld %st(0) + lea ones(%rip), %rdx + fadd %st(2), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(1) + fsub %st(4), %st + fld %st(3) + fmul %st(5), %st + fxch %st(5) + fmul %st(6), %st + fxch %st(2) + faddl (%rax) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 64(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fldt 48(%rsp) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 64(%rsp) + fldt 208(%rsp) + fld %st(0) + fchs + fldt (%rsp) + fld %st(0) + fadd %st(3), %st + fstpt 176(%rsp) + fldt 176(%rsp) + fld %st(1) + movb 185(%rsp), %al + fsub %st(1), %st + andb $-128, %al + fadd %st(4), %st + shrb $7, %al + fxch %st(1) + fsubr %st, %st(4) + fxch %st(2) + fadd %st, %st(4) + fcomip %st(3), %st + fxch %st(2) + fstp %st(0) + fldt 32(%rsp) + movzbl %al, %eax + fadd %st, %st(2) + fldt 224(%rsp) + fadd %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + faddp %st, %st(2) + fxch %st(2) + fcmovnbe %st(1), %st + fstp %st(1) + fld %st(1) + fadd %st(3), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fld %st(2) + fsub %st(1), %st + fadd %st(4), %st + fadd %st(2), %st + flds (%rdx,%rax,4) + fmul %st(4), %st + movb 169(%rsp), %al + andb $-128, %al + shrb $7, %al + fstpt 128(%rsp) + fldt 128(%rsp) + fldt 64(%rsp) + fadd %st, %st(2) + movzbl %al, %eax + flds (%rdx,%rax,4) + fmul %st(7), %st + fxch %st(2) + fcomip %st(2), %st + fxch %st(1) + fstpt 112(%rsp) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fcmovbe %st(1), %st + fstp %st(1) + fstpt 96(%rsp) + testl %r12d, %r12d + je ..B2.142 +..B2.141: + movl %r13d, %edi +..___tag_value___libm_lgammal.276: + call fesetround@PLT +..___tag_value___libm_lgammal.277: +..B2.142: + fldt 80(%rsp) + testb %r14b, %r14b + fldt 96(%rsp) + faddp %st, %st(1) + fchs + fstpt 176(%rsp) + je ..B2.144 +..B2.143: + fldt 112(%rsp) + fstpt 144(%rsp) +..B2.293: + fldcw 194(%rsp) +..B2.144: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.145: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.146: + addq $-32, %rsp + .cfi_def_cfa_offset 368 + movl $1, (%rbp) + lea 272(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_lgammal.299: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.300: +..B2.294: + fstp %st(0) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.147: + fldt 336(%rsp) + lea _TWO_32H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea 560+_ldbA(%rip), %rdx + fldt 240(%rsp) + fldl (%rax) + lea 80+_dbA(%rip), %rax + fmul %st, %st(4) + fxch %st(3) + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(3) + fstpt 32(%rsp) + fldt 32(%rsp) + fsubr %st, %st(1) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt .L_2il0floatpacket.6(%rip) + fmul %st(4), %st + fldt .L_2il0floatpacket.6(%rip) + fldt 256(%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt 80(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fsubrp %st, %st(6) + fxch %st(2) + fmul %st(5), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(5) + fadd %st(1), %st + fstpt (%rsp) + fldt (%rsp) + fsubp %st, %st(1) + fmul %st, %st(3) + fsubr %st, %st(5) + fxch %st(2) + faddp %st, %st(5) + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(2) + fmulp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 80(%rsp) + faddp %st, %st(1) + fldt .L_2il0floatpacket.7(%rip) + fcomip %st(2), %st + jbe ..B2.149 +..B2.148: + lea 704+_ldbA(%rip), %rdx + lea 96+_dbA(%rip), %rax +..B2.149: + fldt 48(%rsp) + testl %r12d, %r12d + fstpt 48(%rsp) + fstpt 80(%rsp) + fldt 32(%rsp) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fldt 64(%rsp) + fld %st(0) + fldt .L_2il0floatpacket.1(%rip) + fdiv %st, %st(3) + fxch %st(1) + fmul %st(3), %st + fld %st(0) + fadd %st(4), %st + fsubp %st, %st(1) + fsubr %st, %st(3) + fld %st(3) + fadd %st(1), %st + fmul %st, %st(6) + fld %st(5) + fmul %st(5), %st + faddp %st, %st(7) + fxch %st(1) + fmul %st, %st(5) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(3) + fsubrp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fmul %st(0), %st + fldt 128(%rdx) + fmul %st(1), %st + fldt 112(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 80(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 64(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 32(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt 16(%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx) + lea 120+_dbA(%rip), %rdx + faddp %st, %st(1) + fmulp %st, %st(1) + fldl (%rax) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(1) + fsub %st(4), %st + fld %st(3) + fmul %st(5), %st + fstpt 240(%rsp) + fldt 240(%rsp) + fxch %st(3) + fmul %st, %st(5) + fxch %st(2) + faddl 8(%rax) + lea 112+_dbA(%rip), %rax + faddp %st, %st(1) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 256(%rsp) + fldt 256(%rsp) + fldl (%rax) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fldt 48(%rsp) + fxch %st(1) + faddl (%rdx) + faddp %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fldt 80(%rsp) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 48(%rsp) + je ..B2.152 +..B2.150: + movl %r13d, %edi + fstpt 176(%rsp) +..___tag_value___libm_lgammal.302: + call fesetround@PLT +..___tag_value___libm_lgammal.303: +..B2.151: + fldt 176(%rsp) +..B2.152: + fldt 48(%rsp) + testb %r14b, %r14b + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.154 +..B2.153: + fldt 32(%rsp) + fstpt 160(%rsp) + fldt (%rsp) + fstpt 144(%rsp) + fldt 16(%rsp) + fstpt 128(%rsp) +..B2.295: + fldcw 194(%rsp) +..B2.154: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.155: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.156: + addq $-32, %rsp + .cfi_def_cfa_offset 368 + movl $1, (%rbp) + lea 272(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_lgammal.325: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.326: +..B2.296: + fstp %st(0) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.157: + fldt 336(%rsp) + lea 16+_TWO5600(%rip), %rax + fldt 240(%rsp) + lea _TWO_32H(%rip), %rdx + fldt .L_2il0floatpacket.1(%rip) + testl %r12d, %r12d + fsubrp %st, %st(1) + fstpt 240(%rsp) + fldt 240(%rsp) + fldt (%rax) + fmulp %st, %st(2) + fld %st(1) + fxch %st(2) + fstpt 336(%rsp) + fldt 336(%rsp) + fldl (%rdx) + fld %st(0) + fmul %st(2), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(3) + fsubr %st(2), %st + fxch %st(1) + fmul %st(3), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fld %st(3) + fadd %st(1), %st + fld %st(0) + fsubp %st, %st(2) + fld %st(1) + fmul %st(6), %st + fstpt 64(%rsp) + fxch %st(1) + fsubr %st, %st(4) + fmulp %st, %st(2) + fxch %st(4) + fstpt 48(%rsp) + fldt 256(%rsp) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + je ..B2.159 +..B2.158: + movl %r13d, %edi + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_lgammal.328: + call fesetround@PLT +..___tag_value___libm_lgammal.329: +..B2.304: + fldt 16(%rsp) + fldt (%rsp) +..B2.159: + fldt 64(%rsp) + lea _TWO5600(%rip), %rax + testb %r14b, %r14b + faddp %st, %st(1) + fldt (%rax) + fmulp %st, %st(1) + fstpt 176(%rsp) + je ..B2.314 +..B2.160: + fldt 48(%rsp) + fstpt 160(%rsp) + fstpt 144(%rsp) + fldt 32(%rsp) + fstpt 128(%rsp) +..B2.297: + fldcw 194(%rsp) + jmp ..B2.161 +..B2.314: + fstp %st(0) +..B2.161: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.162: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.163: + fldt .L_2il0floatpacket.3(%rip) + fcomip %st(2), %st + jbe ..B2.165 +..B2.164: + movl $-1, (%rbp) + jmp ..B2.166 +..B2.165: + movl $1, (%rbp) +..B2.166: + movss %xmm0, (%rsp) + flds (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 368 + fmulp %st, %st(2) + lea 272(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fxch %st(1) + fstpt 16(%rsp) + fstpt 80(%rsp) +..___tag_value___libm_lgammal.351: + call __libm_logl_k80@PLT +..___tag_value___libm_lgammal.352: +..B2.298: + fstp %st(0) + fldt 80(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 336 +..B2.167: + cmpl $16313, %ebx + jge ..B2.174 +..B2.168: + fldt 240(%rsp) + testl %r12d, %r12d + fldt 256(%rsp) + faddp %st, %st(1) + fchs + fstpt 176(%rsp) + je ..B2.170 +..B2.169: + movl %r13d, %edi + fstpt 48(%rsp) +..___tag_value___libm_lgammal.354: + call fesetround@PLT +..___tag_value___libm_lgammal.355: +..B2.310: + fldt 48(%rsp) +..B2.170: + testb %r14b, %r14b + je ..B2.315 +..B2.171: + fstpt 80(%rsp) +..B2.299: + fldcw 194(%rsp) + jmp ..B2.172 +..B2.315: + fstp %st(0) +..B2.172: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.173: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.174: + lea 288+_ldbA(%rip), %rax + lea 272+_ldbA(%rip), %rdx + lea 256+_ldbA(%rip), %rcx + lea 240+_ldbA(%rip), %rbx + lea 224+_ldbA(%rip), %rbp + lea 208+_ldbA(%rip), %rsi + lea 192+_ldbA(%rip), %r8 + lea 176+_ldbA(%rip), %r9 + fldt (%rax) + lea 160+_ldbA(%rip), %r10 + fmul %st(1), %st + lea 144+_ldbA(%rip), %r11 + lea 128+_ldbA(%rip), %rax + testl %r15d, %r15d + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rdx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rcx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rbx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rbp) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rsi) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r8) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r9) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r10) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r11) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + lea 112+_ldbA(%rip), %rax + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + lea 96+_ldbA(%rip), %rax + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + lea 80+_ldbA(%rip), %rax + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + lea 64+_ldbA(%rip), %rax + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + lea 48+_ldbA(%rip), %rax + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + lea 32+_ldbA(%rip), %rax + faddp %st, %st(2) + fmul %st, %st(1) + fld %st(0) + fldt (%rax) + lea 16+_ldbA(%rip), %rax + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt (%rax) + lea _ldbA(%rip), %rax + faddp %st, %st(3) + fmul %st, %st(2) + fld %st(0) + fldt (%rax) + lea _TWO_32H(%rip), %rax + faddp %st, %st(4) + fld %st(3) + fldl (%rax) + lea 32+_dbA(%rip), %rax + fld %st(0) + fmul %st(6), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fmul %st, %st(2) + fxch %st(2) + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(2) + fsub %st(4), %st + fld %st(5) + fsub %st(2), %st + fmul %st(5), %st + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fxch %st(1) + fmul %st(4), %st + fldl (%rax) + lea 40+_dbA(%rip), %rax + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(3) + fmul %st(2), %st + fxch %st(1) + faddl (%rax) + lea 16+_dbA(%rip), %rax + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fld %st(2) + fmul %st(6), %st + fxch %st(3) + fmul %st(7), %st + faddp %st, %st(1) + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(1) + fldl (%rax) + fld %st(0) + lea 24+_dbA(%rip), %rax + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(3) + fmul %st(3), %st + fxch %st(1) + faddl (%rax) + lea _dbA(%rip), %rax + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fmul %st(6), %st + fxch %st(2) + fmul %st(7), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(1) + fldl (%rax) + fld %st(0) + lea 8+_dbA(%rip), %rax + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl (%rax) + faddp %st, %st(2) + fld %st(3) + fmul %st(3), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fmul %st(6), %st + fxch %st(2) + fmul %st(7), %st + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(6) + faddp %st, %st(5) + fldt 240(%rsp) + jl ..B2.220 +..B2.175: + fstp %st(2) + fstp %st(2) + fldt 256(%rsp) + fld %st(2) + testl %r12d, %r12d + fsub %st(2), %st + fadd %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fxch %st(2) + je ..B2.178 +..B2.176: + movl %r13d, %edi + fstpt 176(%rsp) + fstpt 16(%rsp) + fstpt 32(%rsp) +..___tag_value___libm_lgammal.376: + call fesetround@PLT +..___tag_value___libm_lgammal.377: +..B2.177: + fldt 32(%rsp) + fldt 16(%rsp) + fldt 176(%rsp) +..B2.178: + testb %r14b, %r14b + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.316 +..B2.179: + fldt 48(%rsp) + fstpt 144(%rsp) + fstpt 160(%rsp) + fldt 64(%rsp) + fstpt 128(%rsp) +..B2.300: + fldcw 194(%rsp) + jmp ..B2.180 +..B2.316: + fstp %st(0) +..B2.180: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 +..B2.181: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.182: + fstp %st(0) + call __stack_chk_fail@PLT +..B2.188: + fcomi %st(2), %st + ja ..B2.71 + jmp ..B2.73 +..B2.191: + fstp %st(0) + fstp %st(1) + fstp %st(0) + movl $1, (%rbp) + testl %r12d, %r12d + je ..B2.193 +..B2.192: + movl %r13d, %edi +..___tag_value___libm_lgammal.398: + call fesetround@PLT +..___tag_value___libm_lgammal.399: +..B2.193: + movss .L_2il0floatpacket.22(%rip), %xmm1 + testb %r14b, %r14b + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, (%rsp) + flds (%rsp) + fstpt 176(%rsp) + je ..B2.195 +..B2.194: + fldcw 194(%rsp) +..B2.195: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.200: + fstp %st(0) + fldt .L_2il0floatpacket.8(%rip) + lea 304+_dbA(%rip), %rsi + movl $-1, (%rbp) + lea 2672+_ldbA(%rip), %rdi + faddp %st, %st(1) + jmp ..B2.106 +..B2.202: + fxch %st(2) + fcomip %st(1), %st + jae ..B2.204 + jp ..B2.204 +..B2.203: + movl $-1, (%rbp) + jmp ..B2.122 +..B2.204: + movl $1, (%rbp) + jmp ..B2.122 +..B2.206: + fcomip %st(2), %st + jae ..B2.135 + jp ..B2.135 + jmp ..B2.134 +..B2.209: + fstp %st(3) + fstp %st(2) + fstp %st(0) + movl $1, (%rbp) + testl %r12d, %r12d + je ..B2.211 +..B2.210: + movl %r13d, %edi + fstpt (%rsp) +..___tag_value___libm_lgammal.400: + call fesetround@PLT +..___tag_value___libm_lgammal.401: +..B2.306: + fldt (%rsp) +..B2.211: + movss .L_2il0floatpacket.22(%rip), %xmm1 + testb %r14b, %r14b + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, (%rsp) + flds (%rsp) + fstpt 176(%rsp) + je ..B2.317 +..B2.212: + fstpt 96(%rsp) +..B2.301: + fldcw 194(%rsp) + jmp ..B2.213 +..B2.317: + fstp %st(0) +..B2.213: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.220: + lea 544+_ldbA(%rip), %rcx + lea 528+_ldbA(%rip), %rbx + fxch %st(5) + fstpt (%rsp) + fld %st(2) + lea 512+_ldbA(%rip), %rbp + lea 496+_ldbA(%rip), %rsi + lea 480+_ldbA(%rip), %r8 + lea 464+_ldbA(%rip), %r9 + lea 448+_ldbA(%rip), %r10 + lea 432+_ldbA(%rip), %r11 + lea 416+_ldbA(%rip), %r15 + lea 304+_ldbA(%rip), %rax + lea 48+_dbA(%rip), %rdx + testl %r12d, %r12d + fsub %st(4), %st + fxch %st(3) + fmul %st(0), %st + fxch %st(5) + fstpt 16(%rsp) + fxch %st(3) + fstpt 32(%rsp) + fldt 32(%rsp) + fldt (%rcx) + lea 400+_ldbA(%rip), %rcx + fmul %st(5), %st + fldt (%rbx) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rbp) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r15) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + lea 384+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + lea 368+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + lea 352+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + lea 336+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + lea 320+_ldbA(%rip), %rcx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt (%rax) + lea 64+_dbA(%rip), %rax + faddp %st, %st(5) + fld %st(4) + fld %st(1) + fmul %st(2), %st + fldt .L_2il0floatpacket.2(%rip) + fmulp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fld %st(3) + fmul %st(3), %st + fxch %st(5) + fmul %st(0), %st + faddp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fsubp %st, %st(5) + fld %st(4) + fxch %st(3) + fsub %st(5), %st + faddp %st, %st(1) + fld %st(3) + fmul %st(7), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fsubr %st, %st(6) + fmul %st(1), %st + fld %st(4) + fmul %st(7), %st + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fldl (%rax) + fld %st(0) + lea 72+_dbA(%rip), %rax + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fxch %st(1) + faddl (%rax) + lea 56+_dbA(%rip), %rax + faddp %st, %st(2) + fld %st(3) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(3) + fmul %st(1), %st + fxch %st(1) + fmul %st(6), %st + fld %st(4) + fmul %st(3), %st + faddp %st, %st(1) + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(2) + fldl (%rdx) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddl (%rax) + faddp %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fsub %st(2), %st + faddp %st, %st(1) + fld %st(2) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fld %st(1) + fldt 16(%rsp) + fadd %st, %st(1) + fxch %st(1) + fchs + fadd %st, %st(1) + fxch %st(1) + fchs + fsubp %st, %st(3) + fldt 256(%rsp) + fsubrp %st, %st(3) + fldt (%rsp) + fsubrp %st, %st(3) + fld %st(0) + fsub %st(4), %st + fsub %st, %st(1) + fxch %st(1) + fchs + fsubp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fsubrp %st, %st(2) + fldt 32(%rsp) + fxch %st(2) + je ..B2.222 +..B2.221: + movl %r13d, %edi + fstpt (%rsp) + fstpt 16(%rsp) + fstpt 32(%rsp) +..___tag_value___libm_lgammal.402: + call fesetround@PLT +..___tag_value___libm_lgammal.403: +..B2.308: + fldt 32(%rsp) + fldt 16(%rsp) + fldt (%rsp) +..B2.222: + testb %r14b, %r14b + faddp %st, %st(1) + fstpt 176(%rsp) + je ..B2.318 +..B2.223: + fldt 48(%rsp) + fstpt 144(%rsp) + fstpt 160(%rsp) + fldt 64(%rsp) + fstpt 128(%rsp) +..B2.302: + fldcw 194(%rsp) + jmp ..B2.224 +..B2.318: + fstp %st(0) +..B2.224: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.227: + cmpl $16446, %ebx + jle ..B2.16 +..B2.228: + fstp %st(0) + fstp %st(0) + movl $1, (%rbp) + testl %r12d, %r12d + je ..B2.230 +..B2.229: + movl %r13d, %edi +..___tag_value___libm_lgammal.404: + call fesetround@PLT +..___tag_value___libm_lgammal.405: +..B2.230: + movss .L_2il0floatpacket.22(%rip), %xmm1 + testb %r14b, %r14b + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + movss %xmm1, (%rsp) + flds (%rsp) + fstpt 176(%rsp) + je ..B2.232 +..B2.231: + fldcw 194(%rsp) +..B2.232: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.235: + fstp %st(1) + movl $1, (%rbp) +..B2.236: + testl %r12d, %r12d + je ..B2.238 +..B2.237: + movl %r13d, %edi + fstp %st(0) +..___tag_value___libm_lgammal.406: + call fesetround@PLT +..___tag_value___libm_lgammal.407: +..B2.309: + fldt .L_2il0floatpacket.0(%rip) +..B2.238: + fstpt 176(%rsp) + testb %r14b, %r14b + je ..B2.240 +..B2.239: + fldcw 194(%rsp) +..B2.240: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.244: + fstp %st(0) + movl $1, (%rbp) + testl %r12d, %r12d + je ..B2.247 +..B2.245: + fstp %st(0) + movl %r13d, %edi +..___tag_value___libm_lgammal.408: + call fesetround@PLT +..___tag_value___libm_lgammal.409: +..B2.246: + fldt 336(%rsp) +..B2.247: + fld %st(0) + testb %r14b, %r14b + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 176(%rsp) + je ..B2.249 +..B2.248: + fldcw 194(%rsp) +..B2.249: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.252: + fstp %st(0) + fstp %st(0) + testl %r12d, %r12d + je ..B2.254 +..B2.253: + movl %r13d, %edi + movl $1, (%rbp) +..___tag_value___libm_lgammal.410: + call fesetround@PLT +..___tag_value___libm_lgammal.411: + movzbl 345(%rsp), %ecx +..B2.254: + movss .L_2il0floatpacket.22(%rip), %xmm1 + andl $128, %ecx + pxor %xmm0, %xmm0 + divss %xmm0, %xmm1 + shrl $7, %ecx + addl %ecx, %ecx + movss %xmm1, (%rsp) + negl %ecx + flds (%rsp) + incl %ecx + fstpt 176(%rsp) + testb %r14b, %r14b + movl %ecx, (%rbp) + je ..B2.256 +..B2.255: + fldcw 194(%rsp) +..B2.256: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.259: + movq $0x8000000000000000, %rax + cmpq 336(%rsp), %rax + je ..B2.270 +..B2.260: + movl $0, (%rbp) + testl %r12d, %r12d + je ..B2.262 +..B2.261: + movl %r13d, %edi +..___tag_value___libm_lgammal.412: + call fesetround@PLT +..___tag_value___libm_lgammal.413: +..B2.262: + fldt 336(%rsp) + fadd %st(0), %st + fstpt 176(%rsp) +..B2.263: + testl %r12d, %r12d + je ..B2.265 +..B2.264: + movl %r13d, %edi +..___tag_value___libm_lgammal.414: + call fesetround@PLT +..___tag_value___libm_lgammal.415: +..B2.265: + testb %r14b, %r14b + je ..B2.267 +..B2.266: + fldcw 194(%rsp) +..B2.267: + fldt 176(%rsp) + movq 272(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.182 + jmp ..B2.36 +..B2.270: + movl $1, (%rbp) + testl %r12d, %r12d + je ..B2.272 +..B2.271: + movl %r13d, %edi +..___tag_value___libm_lgammal.416: + call fesetround@PLT +..___tag_value___libm_lgammal.417: +..B2.272: + fldt 336(%rsp) + fmul %st(0), %st + fstpt 176(%rsp) + jmp ..B2.263 + .align 16,0x90 + .cfi_endproc + .type __libm_lgammal,@function + .size __libm_lgammal,.-__libm_lgammal + .data +# -- End __libm_lgammal + .text +# -- Begin __libm_p25 + .text + .align 16,0x90 +__libm_p25: +# parameter 1: 8 + %rsp +# parameter 2: %rdi +# parameter 3: %rsi +# parameter 4: %rdx +..B3.1: + .cfi_startproc +..___tag_value___libm_p25.419: +..L420: + + lea _TWO_32H(%rip), %rax + fldt 8(%rsp) + fld %st(0) + fld %st(1) + fldl 56(%rsi) + fmul %st(3), %st + fldl (%rax) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(3) + fsub %st(3), %st + fldt 64(%rdi) + fxch %st(2) + faddl 48(%rsi) + fmul %st(5), %st + fldt (%rdi) + fldt 80(%rdi) + fxch %st(2) + faddl 152(%rsi) + fmul %st(7), %st + faddl 144(%rsi) + fmul %st(7), %st + faddl 168(%rsi) + fmul %st(7), %st + faddl 160(%rsi) + fmul %st(7), %st + faddl 104(%rsi) + fmul %st(7), %st + faddl 96(%rsi) + fmul %st(7), %st + faddl 120(%rsi) + fmul %st(7), %st + faddl 112(%rsi) + fmul %st(7), %st + faddl 136(%rsi) + fmul %st(7), %st + faddl 128(%rsi) + fmul %st(7), %st + faddl 40(%rsi) + fmul %st(7), %st + faddl 32(%rsi) + fmul %st(7), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt 16(%rdi) + faddp %st, %st(1) + fmul %st(4), %st + fldt 32(%rdi) + fldt 96(%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + faddp %st, %st(1) + fmul %st(4), %st + fldt 112(%rdi) + faddp %st, %st(1) + fmul %st(4), %st + fld %st(2) + fldt 48(%rdi) + faddp %st, %st(2) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + fmul %st(6), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fldl (%rsi) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(4) + fmul %st(2), %st + fxch %st(1) + faddl 88(%rsi) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fmul %st(5), %st + fld %st(4) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldl 64(%rsi) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(4) + fmul %st(3), %st + fxch %st(1) + faddl 72(%rsi) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fld %st(4) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(1) + fldl 16(%rsi) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(4) + fmul %st, %st(5) + fsubr %st, %st(2) + fmulp %st, %st(3) + fxch %st(3) + faddl 24(%rsi) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fldl 80(%rsi) + fld %st(0) + fadd %st(2), %st + fstpt (%rdx) + fldt (%rdx) + fsubrp %st, %st(1) + faddp %st, %st(1) + faddl 8(%rsi) + faddp %st, %st(1) + fstpt 16(%rdx) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_p25,@function + .size __libm_p25,.-__libm_p25 + .data +# -- End __libm_p25 + .text +# -- Begin __libm_p19root + .text + .align 16,0x90 +__libm_p19root: +# parameter 1: 8 + %rsp +# parameter 2: %rdi +# parameter 3: %rsi +# parameter 4: %rdx +..B4.1: + .cfi_startproc +..___tag_value___libm_p19root.422: +..L423: + + lea _TWO_32H(%rip), %rax + fldt 8(%rsp) + lea ones(%rip), %r10 + fld %st(0) + fld %st(1) + fldl 152(%rsi) + fmul %st(3), %st + fldl (%rax) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(3) + fsub %st(3), %st + fldt 32(%rdi) + fxch %st(2) + faddl 144(%rsi) + fmul %st(5), %st + fldt 16(%rdi) + fldt (%rdi) + fxch %st(2) + faddl 136(%rsi) + fmul %st(7), %st + faddl 128(%rsi) + fmul %st(7), %st + faddl 120(%rsi) + fmul %st(7), %st + faddl 112(%rsi) + fmul %st(7), %st + faddl 104(%rsi) + fmul %st(7), %st + faddl 96(%rsi) + fmul %st(7), %st + faddl 88(%rsi) + fmul %st(7), %st + faddl 80(%rsi) + fmul %st(7), %st + faddl 72(%rsi) + fmul %st(7), %st + faddl 64(%rsi) + fmul %st(7), %st + faddl 56(%rsi) + fmul %st(7), %st + faddl 48(%rsi) + fmul %st(7), %st + faddp %st, %st(4) + fxch %st(3) + fmul %st(6), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fld %st(1) + fld %st(3) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + fmul %st(6), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldl 32(%rsi) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(4) + fmul %st(2), %st + fxch %st(1) + faddl 40(%rsi) + faddp %st, %st(4) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fmul %st(5), %st + fld %st(4) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldl 16(%rsi) + fld %st(0) + fadd %st(3), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fsubp %st, %st(5) + fxch %st(1) + fmul %st(4), %st + fxch %st(2) + fsub %st(4), %st + fxch %st(4) + fmulp %st, %st(5) + faddl 24(%rsi) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt -40(%rsp) + fldt -40(%rsp) + fldl (%rsi) + fld %st(0) + fldl 8(%rsi) + movb -31(%rsp), %cl + fadd %st, %st(1) + fxch %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + andb $-128, %cl + movb -15(%rsp), %r9b + andb $-128, %r9b + shrb $7, %r9b + shrb $7, %cl + movzbl %r9b, %r11d + movzbl %cl, %r8d + flds (%r10,%r11,4) + fmulp %st, %st(1) + fld %st(2) + fadd %st(5), %st + fstpt (%rdx) + fldt (%rdx) + flds (%r10,%r8,4) + fmulp %st, %st(5) + fxch %st(4) + fcomi %st(1), %st + fxch %st(1) + fstp %st(0) + fld %st(3) + fsubr %st(5), %st + fadd %st(3), %st + fadd %st(6), %st + fadd %st(2), %st + fxch %st(1) + fstpt -40(%rsp) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fcmovnbe %st(1), %st + fstp %st(1) + fstpt 16(%rdx) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_p19root,@function + .size __libm_p19root,.-__libm_p19root + .data +# -- End __libm_p19root + .text +# -- Begin gammal + .text + .align 16,0x90 + .globl gammal +gammal: +# parameter 1: 16 + %rsp +..B5.1: + .cfi_startproc +..___tag_value_gammal.425: +..L426: + + pushq %rsi + .cfi_def_cfa_offset 16 + fldt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 32 + lea 16(%rsp), %rdi + fstpt (%rsp) +..___tag_value_gammal.429: + call __libm_lgammal +..___tag_value_gammal.430: +..B5.2: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type gammal,@function + .size gammal,.-gammal + .data +# -- End gammal + .text +# -- Begin lgammal_r + .text + .align 16,0x90 + .globl lgammal_r +lgammal_r: +# parameter 1: 8 + %rsp +# parameter 2: %rdi +..B6.1: + .cfi_startproc +..___tag_value_lgammal_r.433: +..L434: + + fldt 8(%rsp) + fstpt 8(%rsp) + jmp __libm_lgammal + .align 16,0x90 + .cfi_endproc + .type lgammal_r,@function + .size lgammal_r,.-lgammal_r + .data +# -- End lgammal_r + .text +# -- Begin gammal_r + .text + .align 16,0x90 + .globl gammal_r +gammal_r: +# parameter 1: 8 + %rsp +# parameter 2: %rdi +..B7.1: + .cfi_startproc +..___tag_value_gammal_r.436: +..L437: + + fldt 8(%rsp) + fstpt 8(%rsp) + jmp __libm_lgammal + .align 16,0x90 + .cfi_endproc + .type gammal_r,@function + .size gammal_r,.-gammal_r + .data +# -- End gammal_r + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0x03,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,16 + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,16 + .align 16 +.L_2il0floatpacket.12: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,16 + .align 16 +.L_2il0floatpacket.13: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 16 +.L_2il0floatpacket.14: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xa6,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,16 + .align 16 +.L_2il0floatpacket.15: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 16 +.L_2il0floatpacket.16: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,16 + .align 16 +.L_2il0floatpacket.17: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,16 + .align 16 +.L_2il0floatpacket.18: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,16 + .align 16 +.L_2il0floatpacket.19: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.19,@object + .size .L_2il0floatpacket.19,16 + .align 16 +.L_2il0floatpacket.20: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,16 + .align 16 +.L_2il0floatpacket.21: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.21,@object + .size .L_2il0floatpacket.21,16 + .align 16 +_ldbA: + .word 48403 + .word 16065 + .word 37206 + .word 35465 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 32498 + .word 21186 + .word 57533 + .word 54364 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 48455 + .word 64043 + .word 25991 + .word 44448 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 36906 + .word 8596 + .word 53485 + .word 37761 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 16786 + .word 63789 + .word 39740 + .word 32901 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 43334 + .word 50722 + .word 13591 + .word 58371 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 51242 + .word 42271 + .word 52839 + .word 52480 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 22272 + .word 27707 + .word 58025 + .word 47684 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 48537 + .word 42093 + .word 143 + .word 43693 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 5437 + .word 23105 + .word 19142 + .word 40288 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 43105 + .word 25781 + .word 60600 + .word 37244 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 64996 + .word 46896 + .word 33038 + .word 34212 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 8055 + .word 35794 + .word 25027 + .word 61223 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 26586 + .word 4739 + .word 1082 + .word 51475 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 65450 + .word 65402 + .word 39793 + .word 38562 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 18875 + .word 24550 + .word 64026 + .word 48031 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 3811 + .word 11690 + .word 33485 + .word 45433 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 21488 + .word 64404 + .word 56511 + .word 56861 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 64157 + .word 44249 + .word 62935 + .word 34811 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 1503 + .word 1560 + .word 25992 + .word 44448 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 53495 + .word 49976 + .word 39767 + .word 32901 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 21693 + .word 55175 + .word 61890 + .word 52480 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 18005 + .word 14879 + .word 27421 + .word 43701 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 4785 + .word 48109 + .word 28463 + .word 37451 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 17404 + .word 30303 + .word 36440 + .word 32768 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 19413 + .word 44833 + .word 30216 + .word 58252 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 61231 + .word 61633 + .word 10791 + .word 52455 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 18500 + .word 21868 + .word 57423 + .word 47400 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 24302 + .word 39700 + .word 47161 + .word 45652 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 48514 + .word 20900 + .word 46081 + .word 58518 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 11885 + .word 12460 + .word 35625 + .word 41968 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41690 + .word 14982 + .word 21018 + .word 53469 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 2894 + .word 27339 + .word 226 + .word 41728 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 26025 + .word 18501 + .word 20978 + .word 46979 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 53900 + .word 55553 + .word 17653 + .word 38916 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 46603 + .word 2912 + .word 24758 + .word 46603 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 53261 + .word 3328 + .word 208 + .word 53261 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 39946 + .word 2496 + .word 49308 + .word 39945 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 6840 + .word 51193 + .word 61784 + .word 56488 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 58384 + .word 51683 + .word 34508 + .word 64341 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 53773 + .word 3360 + .word 8402 + .word 53773 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 48865 + .word 31388 + .word 13912 + .word 61972 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 65489 + .word 61491 + .word 45504 + .word 47092 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 53102 + .word 49401 + .word 14344 + .word 45627 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 2166 + .word 2831 + .word 24758 + .word 46603 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 9580 + .word 21681 + .word 206 + .word 53261 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 30177 + .word 46479 + .word 48966 + .word 39945 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 52333 + .word 51482 + .word 18491 + .word 56488 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 40942 + .word 14796 + .word 26057 + .word 64313 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 50177 + .word 16139 + .word 15070 + .word 53362 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 2931 + .word 59423 + .word 29748 + .word 57837 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 12931 + .word 12185 + .word 50840 + .word 32873 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 60991 + .word 64091 + .word 63067 + .word 49777 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 24747 + .word 1987 + .word 58544 + .word 40255 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 31726 + .word 62157 + .word 28132 + .word 51504 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 1560 + .word 52396 + .word 29634 + .word 33090 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 51301 + .word 34230 + .word 21183 + .word 41027 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 26476 + .word 19428 + .word 22828 + .word 49163 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 62911 + .word 28656 + .word 40943 + .word 57345 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 51702 + .word 17823 + .word 6657 + .word 32768 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 55405 + .word 47943 + .word 739 + .word 36864 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 47506 + .word 63803 + .word 73 + .word 40960 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 21270 + .word 47505 + .word 6 + .word 45056 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 51059 + .word 36726 + .word 0 + .word 49152 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 8970 + .word 2825 + .word 0 + .word 53248 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 52133 + .word 201 + .word 0 + .word 57344 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 29690 + .word 13 + .word 0 + .word 61440 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 27552 + .word 0 + .word 0 + .word 32768 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 1621 + .word 0 + .word 0 + .word 34816 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 90 + .word 0 + .word 0 + .word 36864 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 5 + .word 0 + .word 0 + .word 38912 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 1630 + .word 57032 + .word 2128 + .word 45018 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 10332 + .word 57727 + .word 35491 + .word 64803 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 59042 + .word 30551 + .word 48083 + .word 40890 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 27388 + .word 36768 + .word 38828 + .word 49140 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 32744 + .word 23607 + .word 24507 + .word 57342 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 30841 + .word 2766 + .word 52220 + .word 65535 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 33024 + .word 16990 + .word 64796 + .word 36863 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 64973 + .word 1725 + .word 65462 + .word 40959 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 40731 + .word 18030 + .word 65529 + .word 45055 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 14452 + .word 28809 + .word 65535 + .word 49151 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 56566 + .word 62710 + .word 65535 + .word 53247 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 13403 + .word 65334 + .word 65535 + .word 57343 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 35846 + .word 65522 + .word 65535 + .word 61439 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 10432 + .word 65535 + .word 65535 + .word 65535 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 63915 + .word 65535 + .word 65535 + .word 34815 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 65446 + .word 65535 + .word 65535 + .word 36863 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 65531 + .word 65535 + .word 65535 + .word 38911 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38912 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 47937 + .word 50671 + .word 32821 + .word 51896 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 8469 + .word 62640 + .word 24113 + .word 51168 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 23666 + .word 39283 + .word 12728 + .word 33144 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 1338 + .word 16824 + .word 25401 + .word 33044 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 38006 + .word 50858 + .word 35636 + .word 41038 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 6523 + .word 10616 + .word 46244 + .word 41017 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 30889 + .word 22666 + .word 15710 + .word 49165 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 22694 + .word 63464 + .word 47653 + .word 49161 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 7860 + .word 665 + .word 58690 + .word 57345 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 35199 + .word 5838 + .word 25732 + .word 57345 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 27551 + .word 53562 + .word 7766 + .word 32768 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 34954 + .word 15277 + .word 5706 + .word 32768 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 10026 + .word 1321 + .word 863 + .word 36864 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 38128 + .word 3645 + .word 634 + .word 36864 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 22656 + .word 19824 + .word 86 + .word 40960 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 3271 + .word 26602 + .word 63 + .word 40960 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 57583 + .word 55422 + .word 7 + .word 45056 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 8869 + .word 50081 + .word 5 + .word 45056 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 59569 + .word 42847 + .word 0 + .word 49152 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 6316 + .word 31480 + .word 0 + .word 49152 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 65078 + .word 3295 + .word 0 + .word 53248 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 35775 + .word 2421 + .word 0 + .word 53248 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 28054 + .word 235 + .word 0 + .word 57344 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 63410 + .word 172 + .word 0 + .word 57344 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 45561 + .word 15 + .word 0 + .word 61440 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 34811 + .word 11 + .word 0 + .word 61440 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 32144 + .word 0 + .word 0 + .word 32768 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 23616 + .word 0 + .word 0 + .word 32768 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 1891 + .word 0 + .word 0 + .word 34816 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 1389 + .word 0 + .word 0 + .word 34816 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 105 + .word 0 + .word 0 + .word 36864 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 77 + .word 0 + .word 0 + .word 36864 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 6 + .word 0 + .word 0 + .word 38912 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 5 + .word 0 + .word 0 + .word 38912 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 30094 + .word 17612 + .word 34825 + .word 45621 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 27787 + .word 64487 + .word 61865 + .word 44498 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 45180 + .word 62215 + .word 30788 + .word 64910 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 56909 + .word 5419 + .word 21954 + .word 64678 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 26983 + .word 61012 + .word 55414 + .word 40900 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 17042 + .word 26812 + .word 58543 + .word 40878 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 17649 + .word 49100 + .word 16895 + .word 49142 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 47753 + .word 6644 + .word 42105 + .word 49138 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 56665 + .word 15855 + .word 40064 + .word 57342 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 9214 + .word 11959 + .word 6291 + .word 57342 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 44995 + .word 64071 + .word 54163 + .word 65535 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 35553 + .word 53091 + .word 49943 + .word 65535 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 39205 + .word 16423 + .word 64904 + .word 36863 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 61074 + .word 52942 + .word 64669 + .word 36863 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 11000 + .word 54094 + .word 65472 + .word 40959 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 41911 + .word 24986 + .word 65449 + .word 40959 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 33350 + .word 16833 + .word 65530 + .word 45055 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 41532 + .word 8229 + .word 65528 + .word 45055 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 52046 + .word 34170 + .word 65535 + .word 49151 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 9080 + .word 22531 + .word 65535 + .word 49151 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 19128 + .word 63123 + .word 65535 + .word 53247 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 61194 + .word 62227 + .word 65535 + .word 53247 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 43497 + .word 65363 + .word 65535 + .word 57343 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 46501 + .word 65299 + .word 65535 + .word 57343 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 33483 + .word 65524 + .word 65535 + .word 61439 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 16207 + .word 65520 + .word 65535 + .word 61439 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 18477 + .word 65535 + .word 65535 + .word 65535 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 1013 + .word 65535 + .word 65535 + .word 65535 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 64152 + .word 65535 + .word 65535 + .word 34815 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 63638 + .word 65535 + .word 65535 + .word 34815 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 65459 + .word 65535 + .word 65535 + .word 36863 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 65431 + .word 65535 + .word 65535 + .word 36863 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 65532 + .word 65535 + .word 65535 + .word 38911 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 65531 + .word 65535 + .word 65535 + .word 38911 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 16368 + .word 23276 + .word 14028 + .word 45039 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 59281 + .word 7220 + .word 1358 + .word 44002 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 209 + .word 31529 + .word 17251 + .word 45971 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 22774 + .word 54591 + .word 46864 + .word 55119 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 36309 + .word 6992 + .word 45734 + .word 65508 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 57509 + .word 44567 + .word 44472 + .word 62561 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 24352 + .word 36914 + .word 35595 + .word 62910 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 36298 + .word 16311 + .word 10079 + .word 34683 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 8745 + .word 24487 + .word 32401 + .word 58540 + .word 16393 + .word 0 + .word 0 + .word 0 + .word 64710 + .word 25493 + .word 17440 + .word 41602 + .word 16391 + .word 0 + .word 0 + .word 0 + .word 9540 + .word 49275 + .word 24345 + .word 64260 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 32123 + .word 43450 + .word 42726 + .word 58824 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 56179 + .word 18517 + .word 55467 + .word 35137 + .word 49163 + .word 0 + .word 0 + .word 0 + .word 59411 + .word 7122 + .word 11027 + .word 48002 + .word 49160 + .word 0 + .word 0 + .word 0 + .word 11599 + .word 47165 + .word 19459 + .word 34091 + .word 49158 + .word 0 + .word 0 + .word 0 + .word 3871 + .word 11740 + .word 51838 + .word 51028 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 54329 + .word 49239 + .word 6514 + .word 47686 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 32133 + .word 56 + .word 14391 + .word 58371 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 29265 + .word 29887 + .word 53486 + .word 37761 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 40734 + .word 56364 + .word 61890 + .word 52480 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 62017 + .word 50151 + .word 39767 + .word 32901 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 62465 + .word 1557 + .word 25992 + .word 44448 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 46350 + .word 21258 + .word 57533 + .word 54364 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 28472 + .word 57318 + .word 11755 + .word 48239 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 64030 + .word 27012 + .word 42555 + .word 59902 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 15295 + .word 64624 + .word 11797 + .word 40022 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 40088 + .word 48672 + .word 55416 + .word 53395 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 32150 + .word 7351 + .word 22467 + .word 34203 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 32397 + .word 56161 + .word 46934 + .word 48494 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 35896 + .word 51119 + .word 32272 + .word 61954 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 64369 + .word 46577 + .word 49946 + .word 47894 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 13507 + .word 11243 + .word 36867 + .word 37912 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 13500 + .word 7397 + .word 345 + .word 51175 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 36308 + .word 1299 + .word 15549 + .word 37687 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 1494 + .word 43036 + .word 5286 + .word 33882 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 51612 + .word 44256 + .word 49203 + .word 47051 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 24103 + .word 45476 + .word 53751 + .word 61816 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 18204 + .word 4207 + .word 64680 + .word 43260 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 39634 + .word 35210 + .word 18170 + .word 34381 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 30073 + .word 2874 + .word 60159 + .word 61890 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 21923 + .word 37483 + .word 63587 + .word 45930 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 17610 + .word 34235 + .word 25953 + .word 38432 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 27391 + .word 45200 + .word 21903 + .word 41572 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 8472 + .word 18376 + .word 37439 + .word 36904 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 15138 + .word 28105 + .word 43771 + .word 52749 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 19597 + .word 13484 + .word 38971 + .word 41168 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 3303 + .word 60299 + .word 50447 + .word 38102 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 47075 + .word 52558 + .word 55475 + .word 37762 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 52173 + .word 35461 + .word 11437 + .word 59897 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 36076 + .word 14373 + .word 35326 + .word 54659 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 59562 + .word 13882 + .word 310 + .word 33073 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 21162 + .word 13390 + .word 51910 + .word 43836 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 25864 + .word 5553 + .word 52105 + .word 33196 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 50214 + .word 4354 + .word 50978 + .word 55906 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 22538 + .word 16515 + .word 54348 + .word 57115 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 25669 + .word 8964 + .word 45428 + .word 52429 + .word 16390 + .word 0 + .word 0 + .word 0 + .word 42066 + .word 12451 + .word 5346 + .word 32773 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 59247 + .word 49506 + .word 42126 + .word 43753 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 41212 + .word 16190 + .word 63627 + .word 33236 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 43030 + .word 44942 + .word 52710 + .word 59310 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 4241 + .word 60350 + .word 9519 + .word 55057 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 13201 + .word 63684 + .word 48400 + .word 58952 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 43405 + .word 43520 + .word 7800 + .word 38026 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 51109 + .word 32176 + .word 26595 + .word 37828 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 39193 + .word 38974 + .word 13074 + .word 53901 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 18403 + .word 21914 + .word 43743 + .word 52518 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 11905 + .word 16066 + .word 37206 + .word 35465 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 39192 + .word 38974 + .word 13074 + .word 53901 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 16822 + .word 16066 + .word 37206 + .word 35465 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 12453 + .word 1560 + .word 25992 + .word 44448 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 46918 + .word 49948 + .word 39767 + .word 32901 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 993 + .word 37711 + .word 1229 + .word 53967 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 22241 + .word 58002 + .word 54887 + .word 56142 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 8639 + .word 23392 + .word 41786 + .word 61781 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 824 + .word 14446 + .word 39837 + .word 35166 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 4398 + .word 47415 + .word 48788 + .word 40961 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 53320 + .word 18702 + .word 33902 + .word 48514 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 47965 + .word 49933 + .word 53838 + .word 58200 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 46987 + .word 9286 + .word 62309 + .word 35268 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 6461 + .word 640 + .word 17377 + .word 43104 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 30338 + .word 25067 + .word 12218 + .word 53050 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 3327 + .word 27408 + .word 8301 + .word 61564 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 59387 + .word 42287 + .word 60059 + .word 60716 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 13826 + .word 21215 + .word 7405 + .word 64741 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 26137 + .word 29234 + .word 53880 + .word 36165 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 10231 + .word 52926 + .word 36203 + .word 41655 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 23407 + .word 27273 + .word 49305 + .word 49005 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 11641 + .word 23288 + .word 44339 + .word 58553 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 25249 + .word 6483 + .word 6272 + .word 35397 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 42921 + .word 12425 + .word 13798 + .word 43198 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 50188 + .word 64017 + .word 41333 + .word 53119 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 25097 + .word 45200 + .word 21903 + .word 41572 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 10972 + .word 60304 + .word 50447 + .word 38102 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 15639 + .word 33828 + .word 25953 + .word 38432 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 37131 + .word 35786 + .word 38971 + .word 41168 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 11219 + .word 39714 + .word 63573 + .word 45930 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 59109 + .word 9738 + .word 44211 + .word 52749 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 51163 + .word 1079 + .word 49343 + .word 61890 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 19090 + .word 15031 + .word 12079 + .word 36906 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 6956 + .word 155 + .word 44549 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 54475 + .word 22231 + .word 8036 + .word 54711 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 43885 + .word 13882 + .word 310 + .word 33073 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 49382 + .word 16501 + .word 54348 + .word 57115 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 54884 + .word 14552 + .word 35326 + .word 54659 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 24455 + .word 7515 + .word 50978 + .word 55906 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 57687 + .word 611 + .word 11437 + .word 59897 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 26110 + .word 1729 + .word 52102 + .word 33196 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 49827 + .word 25553 + .word 55506 + .word 37762 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 45356 + .word 51283 + .word 52132 + .word 43836 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 37526 + .word 52421 + .word 6331 + .word 51720 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 23504 + .word 7355 + .word 4713 + .word 61833 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 28030 + .word 45200 + .word 21903 + .word 41572 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 64882 + .word 60298 + .word 50447 + .word 38102 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 36628 + .word 34230 + .word 25953 + .word 38432 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 2186 + .word 13495 + .word 38971 + .word 41168 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 42048 + .word 38474 + .word 63587 + .word 45930 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 44984 + .word 21655 + .word 43771 + .word 52749 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 10340 + .word 31180 + .word 60154 + .word 61890 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 29368 + .word 33685 + .word 37418 + .word 36904 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 632 + .word 28858 + .word 25336 + .word 44574 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 47657 + .word 7722 + .word 28520 + .word 54386 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 48861 + .word 21442 + .word 12332 + .word 46245 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 55836 + .word 1266 + .word 27621 + .word 35724 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 19864 + .word 22843 + .word 65282 + .word 47516 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 55755 + .word 27362 + .word 47250 + .word 57481 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 27703 + .word 47960 + .word 491 + .word 37689 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 41421 + .word 53711 + .word 6590 + .word 52435 + .word 16394 + .word 0 + .word 0 + .word 0 + .word 57789 + .word 21731 + .word 35033 + .word 43725 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 55298 + .word 55134 + .word 50960 + .word 52072 + .word 16399 + .word 0 + .word 0 + .word 0 + .word 30636 + .word 39282 + .word 62891 + .word 33072 + .word 16404 + .word 0 + .word 0 + .word 0 + .word 7959 + .word 64403 + .word 49841 + .word 37534 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 5854 + .word 54131 + .word 61334 + .word 53522 + .word 16408 + .word 0 + .word 0 + .word 0 + .word 5803 + .word 45364 + .word 48027 + .word 40704 + .word 16415 + .word 0 + .word 0 + .word 0 + .word 1370 + .word 7138 + .word 7454 + .word 61224 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 57336 + .word 44117 + .word 55954 + .word 64739 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 54670 + .word 41483 + .word 43064 + .word 36510 + .word 16428 + .word 0 + .word 0 + .word 0 + .word 42312 + .word 7696 + .word 38319 + .word 40746 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 12302 + .word 62594 + .word 5410 + .word 37618 + .word 16430 + .word 0 + .word 0 + .word 0 + .word 9293 + .word 14879 + .word 6832 + .word 37045 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 2958 + .word 50542 + .word 15469 + .word 40704 + .word 16427 + .word 0 + .word 0 + .word 0 + .word 42649 + .word 12819 + .word 63050 + .word 37565 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 6063 + .word 43732 + .word 62723 + .word 36980 + .word 16457 + .word 0 + .word 0 + .word 0 + .word 22453 + .word 18298 + .word 44915 + .word 57947 + .word 16436 + .word 0 + .word 0 + .word 0 + .word 20554 + .word 96 + .word 8145 + .word 60162 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 27743 + .word 60960 + .word 41480 + .word 33312 + .word 16473 + .word 0 + .word 0 + .word 0 + .word 22238 + .word 6527 + .word 38867 + .word 56588 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 38516 + .word 42313 + .word 15095 + .word 36719 + .word 16468 + .word 0 + .word 0 + .word 0 + .word 36587 + .word 28039 + .word 41391 + .word 50829 + .word 16489 + .word 0 + .word 0 + .word 0 + .word 29867 + .word 13204 + .word 65176 + .word 36776 + .word 16457 + .word 0 + .word 0 + .word 0 + .word 31042 + .word 28858 + .word 52725 + .word 32812 + .word 16482 + .word 0 + .word 0 + .word 0 + .word 10384 + .word 4515 + .word 18607 + .word 62455 + .word 16506 + .word 0 + .word 0 + .word 0 + .word 9765 + .word 184 + .word 10999 + .word 62061 + .word 16467 + .word 0 + .word 0 + .word 0 + .word 31509 + .word 19231 + .word 45642 + .word 41528 + .word 16496 + .word 0 + .word 0 + .word 0 + .word 9807 + .word 42010 + .word 46528 + .word 59283 + .word 16524 + .word 0 + .word 0 + .word 0 + .word 34508 + .word 54054 + .word 11762 + .word 33288 + .word 16479 + .word 0 + .word 0 + .word 0 + .word 35651 + .word 17126 + .word 61083 + .word 36196 + .word 16511 + .word 0 + .word 0 + .word 0 + .word 61937 + .word 2245 + .word 55342 + .word 41983 + .word 16543 + .word 0 + .word 0 + .word 0 + .word 55800 + .word 52004 + .word 63053 + .word 44600 + .word 16490 + .word 0 + .word 0 + .word 0 + .word 1794 + .word 6965 + .word 62764 + .word 42435 + .word 16526 + .word 0 + .word 0 + .word 0 + .word 31259 + .word 48342 + .word 51287 + .word 43067 + .word 16562 + .word 0 + .word 0 + .word 0 + .word 51054 + .word 24828 + .word 3408 + .word 36750 + .word 16502 + .word 0 + .word 0 + .word 0 + .word 10851 + .word 65289 + .word 49628 + .word 32780 + .word 16542 + .word 0 + .word 0 + .word 0 + .word 55922 + .word 53580 + .word 2985 + .word 62379 + .word 16581 + .word 0 + .word 0 + .word 0 + .word 3514 + .word 59781 + .word 19773 + .word 36749 + .word 16514 + .word 0 + .word 0 + .word 0 + .word 6233 + .word 41678 + .word 56685 + .word 32779 + .word 16558 + .word 0 + .word 0 + .word 0 + .word 7397 + .word 40156 + .word 60492 + .word 62376 + .word 16601 + .word 0 + .word 0 + .word 0 + .word 64764 + .word 30182 + .word 28471 + .word 44055 + .word 16526 + .word 0 + .word 0 + .word 0 + .word 47394 + .word 43518 + .word 20307 + .word 41745 + .word 16574 + .word 0 + .word 0 + .word 0 + .word 48961 + .word 13130 + .word 26792 + .word 42193 + .word 16622 + .word 0 + .word 0 + .word 0 + .word 13149 + .word 49204 + .word 39329 + .word 62843 + .word 16538 + .word 0 + .word 0 + .word 0 + .word 63753 + .word 8765 + .word 38452 + .word 33516 + .word 16591 + .word 0 + .word 0 + .word 0 + .word 60000 + .word 22498 + .word 28021 + .word 38134 + .word 16643 + .word 0 + .word 0 + .word 0 + .word 10643 + .word 26389 + .word 15903 + .word 44739 + .word 16551 + .word 0 + .word 0 + .word 0 + .word 24943 + .word 57881 + .word 5976 + .word 53687 + .word 16607 + .word 0 + .word 0 + .word 0 + .word 62568 + .word 44908 + .word 48389 + .word 34359 + .word 16664 + .word 0 + .word 0 + .word 0 + .word 36352 + .word 25695 + .word 54808 + .word 41154 + .word 49155 + .word 0 + .word 0 + .word 0 + .word 53950 + .word 20364 + .word 22118 + .word 64130 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 29016 + .word 1013 + .word 8897 + .word 49860 + .word 49158 + .word 0 + .word 0 + .word 0 + .word 48790 + .word 22905 + .word 44266 + .word 59689 + .word 49162 + .word 0 + .word 0 + .word 0 + .word 10097 + .word 41173 + .word 5368 + .word 62588 + .word 16398 + .word 0 + .word 0 + .word 0 + .word 18460 + .word 26935 + .word 48131 + .word 34999 + .word 49171 + .word 0 + .word 0 + .word 0 + .word 39812 + .word 13033 + .word 49143 + .word 34463 + .word 49170 + .word 0 + .word 0 + .word 0 + .word 11756 + .word 24889 + .word 14253 + .word 47765 + .word 16408 + .word 0 + .word 0 + .word 0 + .word 27397 + .word 56992 + .word 59569 + .word 35306 + .word 49183 + .word 0 + .word 0 + .word 0 + .word 1499 + .word 3328 + .word 1093 + .word 60276 + .word 49177 + .word 0 + .word 0 + .word 0 + .word 54443 + .word 57316 + .word 38982 + .word 63406 + .word 16418 + .word 0 + .word 0 + .word 0 + .word 46810 + .word 23189 + .word 13701 + .word 35573 + .word 49196 + .word 0 + .word 0 + .word 0 + .word 40551 + .word 19489 + .word 60782 + .word 40648 + .word 49186 + .word 0 + .word 0 + .word 0 + .word 16371 + .word 31130 + .word 60187 + .word 37497 + .word 16430 + .word 0 + .word 0 + .word 0 + .word 56271 + .word 55717 + .word 16120 + .word 36897 + .word 49210 + .word 0 + .word 0 + .word 0 + .word 11488 + .word 11046 + .word 17817 + .word 40691 + .word 49195 + .word 0 + .word 0 + .word 0 + .word 54617 + .word 39007 + .word 658 + .word 37550 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 32140 + .word 49295 + .word 21536 + .word 36961 + .word 49225 + .word 0 + .word 0 + .word 0 + .word 5702 + .word 58081 + .word 34597 + .word 57945 + .word 49204 + .word 0 + .word 0 + .word 0 + .word 48280 + .word 56894 + .word 9030 + .word 60159 + .word 16454 + .word 0 + .word 0 + .word 0 + .word 61535 + .word 4768 + .word 37086 + .word 33310 + .word 49241 + .word 0 + .word 0 + .word 0 + .word 53564 + .word 21787 + .word 24446 + .word 56588 + .word 49214 + .word 0 + .word 0 + .word 0 + .word 35771 + .word 11952 + .word 2619 + .word 36719 + .word 16468 + .word 0 + .word 0 + .word 0 + .word 47624 + .word 53808 + .word 19802 + .word 50829 + .word 49257 + .word 0 + .word 0 + .word 0 + .word 42706 + .word 15946 + .word 64291 + .word 36776 + .word 49225 + .word 0 + .word 0 + .word 0 + .word 8317 + .word 44716 + .word 51672 + .word 32812 + .word 16482 + .word 0 + .word 0 + .word 0 + .word 31251 + .word 20899 + .word 16102 + .word 62455 + .word 49274 + .word 0 + .word 0 + .word 0 + .word 2105 + .word 17517 + .word 10872 + .word 62061 + .word 49235 + .word 0 + .word 0 + .word 0 + .word 60728 + .word 14335 + .word 45529 + .word 41528 + .word 16496 + .word 0 + .word 0 + .word 0 + .word 1336 + .word 56903 + .word 46326 + .word 59283 + .word 49292 + .word 0 + .word 0 + .word 0 + .word 34501 + .word 54054 + .word 11762 + .word 33288 + .word 49247 + .word 0 + .word 0 + .word 0 + .word 35638 + .word 17126 + .word 61083 + .word 36196 + .word 16511 + .word 0 + .word 0 + .word 0 + .word 12489 + .word 2246 + .word 55342 + .word 41983 + .word 49311 + .word 0 + .word 0 + .word 0 + .word 55790 + .word 52004 + .word 63053 + .word 44600 + .word 49258 + .word 0 + .word 0 + .word 0 + .word 1778 + .word 6965 + .word 62764 + .word 42435 + .word 16526 + .word 0 + .word 0 + .word 0 + .word 47762 + .word 48342 + .word 51287 + .word 43067 + .word 49330 + .word 0 + .word 0 + .word 0 + .word 51047 + .word 24828 + .word 3408 + .word 36750 + .word 49270 + .word 0 + .word 0 + .word 0 + .word 10839 + .word 65289 + .word 49628 + .word 32780 + .word 16542 + .word 0 + .word 0 + .word 0 + .word 14289 + .word 53581 + .word 2985 + .word 62379 + .word 49349 + .word 0 + .word 0 + .word 0 + .word 3506 + .word 59781 + .word 19773 + .word 36749 + .word 49282 + .word 0 + .word 0 + .word 0 + .word 6220 + .word 41678 + .word 56685 + .word 32779 + .word 16558 + .word 0 + .word 0 + .word 0 + .word 31299 + .word 40156 + .word 60492 + .word 62376 + .word 49369 + .word 0 + .word 0 + .word 0 + .word 64754 + .word 30182 + .word 28471 + .word 44055 + .word 49294 + .word 0 + .word 0 + .word 0 + .word 47368 + .word 43518 + .word 20307 + .word 41745 + .word 16574 + .word 0 + .word 0 + .word 0 + .word 65114 + .word 13130 + .word 26792 + .word 42193 + .word 49390 + .word 0 + .word 0 + .word 0 + .word 13136 + .word 49204 + .word 39329 + .word 62843 + .word 49306 + .word 0 + .word 0 + .word 0 + .word 63757 + .word 8765 + .word 38452 + .word 33516 + .word 16591 + .word 0 + .word 0 + .word 0 + .word 9085 + .word 22499 + .word 28021 + .word 38134 + .word 49411 + .word 0 + .word 0 + .word 0 + .word 10631 + .word 26389 + .word 15903 + .word 44739 + .word 49319 + .word 0 + .word 0 + .word 0 + .word 24915 + .word 57881 + .word 5976 + .word 53687 + .word 16607 + .word 0 + .word 0 + .word 0 + .word 16910 + .word 44909 + .word 48389 + .word 34359 + .word 49432 + .word 0 + .word 0 + .word 0 + .type _ldbA,@object + .size _ldbA,6160 + .align 16 +_dbA: + .long 4235179544 + .long 3219290252 + .long 3295226828 + .long 3164508998 + .long 1649608659 + .long 1072320934 + .long 3173846476 + .long 1014071527 + .long 1542107862 + .long 3218711765 + .long 2540989727 + .long 3163202496 + .long 1649608660 + .long 3220853158 + .long 859914669 + .long 1017880115 + .long 717740104 + .long 3219214642 + .long 2376945980 + .long 3162254827 + .long 1431655765 + .long 1068848469 + .long 1431655765 + .long 1012225365 + .long 1431655765 + .long 1068848469 + .long 42583435 + .long 1011709190 + .long 3362045620 + .long 1072523249 + .long 4064281872 + .long 1016386130 + .long 4002465326 + .long 3220678216 + .long 1750589542 + .long 1014054706 + .long 2343010478 + .long 3220651595 + .long 2022209519 + .long 3165213628 + .long 3582788241 + .long 1077376220 + .long 3584976419 + .long 3225506388 + .long 2237448112 + .long 1085305363 + .long 634573353 + .long 3233318238 + .long 2248101888 + .long 1073427871 + .long 1861873466 + .long 1016835790 + .long 2560862412 + .long 1071060948 + .long 30404090 + .long 3163588833 + .long 1673151062 + .long 1081107801 + .long 641486499 + .long 3229145757 + .long 2847476088 + .long 1079825078 + .long 4109693297 + .long 3227890617 + .long 80699903 + .long 1078574114 + .long 2114691410 + .long 3226679074 + .long 1354791574 + .long 1083527322 + .long 1238563653 + .long 3231741049 + .long 2909836308 + .long 1082322123 + .long 2961745666 + .long 3230453807 + .long 4254370204 + .long 3222569838 + .long 2523116623 + .long 1016608103 + .long 3036354677 + .long 3220338375 + .long 4197032384 + .long 3163739097 + .long 618767413 + .long 1086658447 + .long 4224046954 + .long 3235503748 + .long 918515347 + .long 1104466354 + .long 1558545744 + .long 3253448772 + .long 3598672851 + .long 1075147148 + .long 1862579612 + .long 1019557195 + .long 814211565 + .long 1073042505 + .long 3816489657 + .long 3166119701 + .long 1438601496 + .long 1094947899 + .long 3932640262 + .long 3243813893 + .long 1025077628 + .long 1092155011 + .long 4084583552 + .long 3241103782 + .long 2491631644 + .long 1089473568 + .long 3212116569 + .long 3238261210 + .long 764386880 + .long 1100022671 + .long 1839771210 + .long 3248755462 + .long 3990369246 + .long 1097905463 + .long 1112302030 + .long 3246751353 + .long 717740104 + .long 1070682418 + .long 230143214 + .long 1014072542 + .long 1542107862 + .long 1071228117 + .long 2869986399 + .long 1017025354 + .long 2620920409 + .long 1068568872 + .long 3005931917 + .long 1068498895 + .long 3773030413 + .long 1068741081 + .long 221735135 + .long 1068648815 + .long 1649608659 + .long 1072320934 + .long 2259103138 + .long 1014410184 + .long 1798481678 + .long 1068036068 + .long 1435858614 + .long 1066348979 + .long 2798813559 + .long 1068114295 + .long 1711004053 + .long 1067747678 + .long 2010902109 + .long 1068166444 + .long 2474987820 + .long 1068059813 + .long 780818753 + .long 1068375890 + .long 4117616766 + .long 1068267614 + .long 1604677386 + .long 1068848813 + .long 1854392195 + .long 1067982657 + .long 4235179544 + .long 1071806604 + .long 2606438347 + .long 1015960145 + .long 2893907075 + .long 1066734370 + .long 2294698909 + .long 1014073149 + .long 441808390 + .long 3216064000 + .long 1880662273 + .long 1012321168 + .long 3253204732 + .long 3200326446 + .long 3649195207 + .long 1051723342 + .long 1676415034 + .long 3202599881 + .long 856428669 + .long 1053972858 + .long 3299217318 + .long 1070900044 + .long 4151699616 + .long 1010498715 + .long 1123572530 + .long 1044951237 + .long 3942090667 + .long 3191111442 + .long 179320158 + .long 3191607973 + .long 648955671 + .long 3189543958 + .long 338963396 + .long 3195730567 + .long 729244107 + .long 1047109933 + .long 491939632 + .long 3198035439 + .long 2441649049 + .long 1049392674 + .long 4000663347 + .long 1056276700 + .long 3497022620 + .long 3193423889 + .long 119575502 + .long 1071320806 + .long 3893526980 + .long 3160417465 + .long 2378611747 + .long 3217220647 + .long 3721041488 + .long 3160948136 + .long 212213087 + .long 1003805565 + .long 3707885569 + .long 946762142 + .long 954325311 + .long 1061996326 + .long 2572405945 + .long 3208784108 + .long 2047107390 + .long 1053958905 + .long 2157300588 + .long 3201555925 + .long 3371055275 + .long 1071576875 + .long 1069844800 + .long 1015429887 + .long 3166931521 + .long 3216972217 + .long 3220968514 + .long 3161728497 + .long 4141120019 + .long 1057975373 + .long 3048513049 + .long 3204734413 + .long 1172170140 + .long 1059250739 + .long 2600146741 + .long 3206041877 + .long 2751605624 + .long 1060573214 + .long 1663282963 + .long 3207426590 + .long 3895324829 + .long 1055298027 + .long 157415216 + .long 3202171477 + .long 3734613381 + .long 1056602430 + .long 277770430 + .long 3203481600 + .long 3198889327 + .long 3217706325 + .long 2705408501 + .long 1014676637 + .long 59787751 + .long 1073579891 + .long 1470716836 + .long 1013369721 + .long 2045320829 + .long 1061536716 + .long 93552279 + .long 3208285776 + .long 1578930691 + .long 1053381091 + .long 2541023 + .long 3199217833 + .long 2303467340 + .long 1072252569 + .long 567354353 + .long 1016170573 + .long 4277811695 + .long 1072049730 + .long 3950020367 + .long 3160819724 + .long 2523318625 + .long 1057215902 + .long 2302510246 + .long 3203993877 + .long 298082853 + .long 1058616118 + .long 2097322096 + .long 3205466603 + .long 1798601470 + .long 1060132265 + .long 1407285416 + .long 3206822737 + .long 4077669298 + .long 1054450862 + .long 2333929458 + .long 3201533971 + .long 2747507284 + .long 1055881541 + .long 2839080721 + .long 3202576178 + .long 3383958356 + .long 3218498155 + .long 613656875 + .long 1017795528 + .long 173059452 + .long 1075530818 + .long 704088483 + .long 1015836313 + .long 669591746 + .long 1061765380 + .long 2029568326 + .long 3208524070 + .long 4157429832 + .long 1054150757 + .long 704852271 + .long 3201323640 + .long 846452204 + .long 1073165719 + .long 1707052239 + .long 1015225852 + .long 1011120585 + .long 1074996836 + .long 2354399398 + .long 3161432137 + .long 954697072 + .long 1057288366 + .long 1270411324 + .long 3204047380 + .long 711769130 + .long 1058758297 + .long 1128721 + .long 3205559284 + .long 179011054 + .long 1060257504 + .long 4204770871 + .long 3206955261 + .long 3137275514 + .long 1053955134 + .long 762311517 + .long 3199983289 + .long 728345252 + .long 1056011172 + .long 1369631397 + .long 3202845593 + .long 3569027386 + .long 3214047105 + .long 3629871173 + .long 3159432582 + .long 2480864277 + .long 1072801415 + .long 765976303 + .long 1016615598 + .long 759560957 + .long 1082479958 + .long 4267700141 + .long 3214355674 + .long 519344805 + .long 3246817843 + .long 220815467 + .long 3246677566 + .long 585197945 + .long 1074992152 + .long 3068616556 + .long 1020233496 + .long 4125953813 + .long 3215772665 + .long 1932096513 + .long 3151829739 + .long 891522464 + .long 1087323966 + .long 2489260670 + .long 3237524288 + .long 198576582 + .long 1086294508 + .long 1118764770 + .long 3231025522 + .long 4028480604 + .long 1084377135 + .long 1979567970 + .long 3223360994 + .long 4063308394 + .long 3244561236 + .long 4166146281 + .long 3246077527 + .long 2664161993 + .long 3240072782 + .long 259025260 + .long 3242645417 + .long 378360574 + .long 1070238620 + .long 2959696752 + .long 1069921292 + .long 573154909 + .long 1069707436 + .long 4044344316 + .long 1069551882 + .long 477218588 + .long 1069314503 + .long 0 + .long 3217031168 + .long 2454267026 + .long 1069697316 + .long 1431655765 + .long 3217380693 + .long 2576980378 + .long 1070176665 + .long 0 + .long 3218079744 + .long 1431655765 + .long 1070945621 + .long 0 + .long 3219128320 + .long 2759451285 + .long 3216787420 + .long 439852373 + .long 3160440428 + .long 925239789 + .long 1070204188 + .long 1052235825 + .long 1014694615 + .long 2825585883 + .long 3219218351 + .long 1250510261 + .long 3158266606 + .long 4280873151 + .long 1070880196 + .long 3382653115 + .long 1014364358 + .long 3432120556 + .long 1060112640 + .long 1689864936 + .long 3206804514 + .long 2559966835 + .long 1058598642 + .long 1675881979 + .long 3205446725 + .long 3157807190 + .long 1057195995 + .long 83437824 + .long 3203930944 + .long 714759041 + .long 1055696489 + .long 94115283 + .long 3202310560 + .long 231342353 + .long 1053665780 + .long 2283895727 + .long 3199602663 + .long 2514471110 + .long 1050042839 + .long 1783553765 + .long 3194406773 + .long 2977985131 + .long 3217141333 + .long 1199854581 + .long 3162366396 + .long 2962538897 + .long 3216960405 + .long 4143040985 + .long 3159573871 + .long 1505583242 + .long 1067626192 + .long 1685935487 + .long 1007379916 + .long 1307717362 + .long 1071507942 + .long 2592844004 + .long 1015649171 + .long 799685378 + .long 1060113448 + .long 3181808512 + .long 3206805166 + .long 237118685 + .long 1058600582 + .long 1021521704 + .long 3205452843 + .long 562863096 + .long 1057199158 + .long 124222188 + .long 3203968611 + .long 666083857 + .long 1055962453 + .long 2573104645 + .long 3202709164 + .long 3241565485 + .long 1053885149 + .long 1335355988 + .long 3200533016 + .long 1040080838 + .long 1054134824 + .long 2847172487 + .long 3201012249 + .long 3198889327 + .long 3217706325 + .long 1543330549 + .long 3160864782 + .long 4277811695 + .long 1072049730 + .long 993295933 + .long 1014676638 + .long 59787751 + .long 1073579891 + .long 130295530 + .long 1013369744 + .long 2303467340 + .long 1072252569 + .long 3943765603 + .long 1016170278 + .long 3608922566 + .long 1060045649 + .long 1453569939 + .long 3207287740 + .long 3338057825 + .long 3206066477 + .long 3038862383 + .long 3208900206 + .long 2094875998 + .long 3209983096 + .long 1016858122 + .long 3211012944 + .long 2854570659 + .long 3211659217 + .long 1144696552 + .long 3211904901 + .long 2176258130 + .long 3211749311 + .long 3478125247 + .long 3210994876 + .long 2355567962 + .long 3209692799 + .long 3598755244 + .long 3207186288 + .long 3383958356 + .long 3218498155 + .long 141035778 + .long 3162876606 + .long 1011120585 + .long 1074996836 + .long 1865540452 + .long 1017795522 + .long 173059452 + .long 1075530818 + .long 1582816653 + .long 1015838421 + .long 846452204 + .long 1073165719 + .long 2382960778 + .long 1015259319 + .long 3627221817 + .long 1060257525 + .long 782594551 + .long 3206955283 + .long 1981242537 + .long 1058758037 + .long 1755079229 + .long 3205559658 + .long 2436997517 + .long 1057278666 + .long 3384076381 + .long 3204067450 + .long 2476719666 + .long 1056224805 + .long 337705071 + .long 3201230508 + .long 776493412 + .long 3197801902 + .long 2139883963 + .long 3204685556 + .long 1475852201 + .long 3204789337 + .long 945638604 + .long 3203947238 + .long 3198889327 + .long 3217706325 + .long 4282828456 + .long 3160832800 + .long 4277811695 + .long 1072049730 + .long 993624082 + .long 1014676638 + .long 59787751 + .long 1073579891 + .long 1881378167 + .long 1013369744 + .long 2303467340 + .long 1072252569 + .long 2285482445 + .long 1016170301 + .long 2583886559 + .long 1060132251 + .long 2972085422 + .long 3206822622 + .long 1867851267 + .long 1058615355 + .long 680445507 + .long 3205461644 + .long 1455562209 + .long 1057201491 + .long 2171135678 + .long 3203931082 + .long 973516116 + .long 1055683749 + .long 442346719 + .long 3202274605 + .long 3339219778 + .long 1053603010 + .long 4261370927 + .long 3199529466 + .long 1389725956 + .long 1049937931 + .long 3421055527 + .long 3194266408 + .long 3440444171 + .long 3149749917 + .long 2683862484 + .long 3093774621 + .long 1722766174 + .long 1073233897 + .long 1535800986 + .long 1017782563 + .long 2952983900 + .long 1075015403 + .long 1613333390 + .long 1019450778 + .long 1747624399 + .long 1077465903 + .long 1323746741 + .long 1077414384 + .long 2170768622 + .long 1079283370 + .long 3681271869 + .long 1079585146 + .long 2395326938 + .long 1081247483 + .long 1534348539 + .long 1081774816 + .long 339892429 + .long 1083288020 + .long 3528406654 + .long 1083985153 + .long 2588043907 + .long 1085376283 + .long 2346296707 + .long 1086214596 + .long 207705063 + .long 1087509517 + .long 2560418979 + .long 1088486188 + .long 2868926017 + .long 1088759609 + .long 1843351610 + .long 1091968574 + .long 2991121454 + .long 1008150290 + .long 2149211495 + .long 952864023 + .long 1596959828 + .long 1075781798 + .long 2172289614 + .long 1019977377 + .long 2540785903 + .long 1077531858 + .long 1236674410 + .long 1020936929 + .long 4153228343 + .long 1087542211 + .long 2696338690 + .long 1090238842 + .long 878599865 + .long 1092951715 + .long 1553131440 + .long 1095784438 + .long 1380037893 + .long 1098488966 + .long 2667481451 + .long 1101284640 + .long 2282526011 + .long 1104162081 + .long 2355356013 + .long 1106903006 + .long 2198000318 + .long 1109722332 + .long 415847444 + .long 1112609215 + .long 1244368631 + .long 1115409383 + .long 1504872183 + .long 1118250351 + .long 1483597343 + .long 1121215185 + .long 2372686104 + .long 1123791138 + .long 2950620603 + .long 1012416763 + .long 1854687498 + .long 952811571 + .long 4103214658 + .long 1077594716 + .long 2773032534 + .long 1020189917 + .long 3447799694 + .long 1081361429 + .long 400789830 + .long 1023147708 + .long 3214535591 + .long 1099259453 + .long 1237622722 + .long 1103959294 + .long 3800166525 + .long 1108620252 + .long 3349752687 + .long 1113359257 + .long 1736707866 + .long 1118068670 + .long 1604218008 + .long 1122855127 + .long 472376766 + .long 1127573289 + .long 2849635624 + .long 1132420823 + .long 1552594705 + .long 1137123494 + .long 3251899291 + .long 1141973158 + .long 523050174 + .long 1146711894 + .long 2820496385 + .long 1151553661 + .long 507113183 + .long 1156515491 + .long 3382661695 + .long 1160984436 + .long 1797993220 + .long 1014085677 + .long 1007534641 + .long 957814894 + .long 136949250 + .long 1079957294 + .long 360284395 + .long 1016466469 + .long 784478107 + .long 1086123203 + .long 2737766812 + .long 1029538613 + .long 1541190179 + .long 1113554317 + .long 209153222 + .long 1120512208 + .long 2353533988 + .long 1127569405 + .long 445988592 + .long 1134692642 + .long 3579939511 + .long 1141824664 + .long 1580626808 + .long 1148890066 + .long 214151816 + .long 1156005346 + .long 2068712408 + .long 1163158821 + .long 839406419 + .long 1170342165 + .long 3247543387 + .long 1177546316 + .long 4025420415 + .long 1184654254 + .long 956971024 + .long 1191825477 + .long 2268897124 + .long 1199100768 + .long 3197790250 + .long 1206020453 + .long 2712668744 + .long 1014362371 + .long 420246125 + .long 958137372 + .long 2654663338 + .long 1082564068 + .long 4161996347 + .long 1025251297 + .long 1213005072 + .long 1091554851 + .long 789699257 + .long 1035400076 + .long 800710857 + .long 1129640478 + .long 2496483081 + .long 1139363849 + .long 599798751 + .long 1149188652 + .long 1701185240 + .long 1158910290 + .long 2369516264 + .long 1168692319 + .long 283492325 + .long 1178587937 + .long 3183141054 + .long 1188335795 + .long 3641040163 + .long 1198179274 + .long 561697907 + .long 1208059224 + .long 1909654917 + .long 1217858291 + .long 2831089635 + .long 1227776627 + .long 2923368563 + .long 1237613769 + .long 3277782853 + .long 1247623400 + .long 2305379544 + .long 1257247294 + .long 2173558120 + .long 3167899773 + .long 3928519072 + .long 3112134976 + .long 2855828427 + .long 1085518855 + .long 2402042833 + .long 1029906467 + .long 3668949703 + .long 1097350789 + .long 1498999354 + .long 1041534216 + .long 1894732623 + .long 1147309596 + .long 3157447236 + .long 1159959522 + .long 1106557451 + .long 1172641345 + .long 2830063624 + .long 1185354419 + .long 1827524850 + .long 1198100435 + .long 3148494391 + .long 1210882790 + .long 408406249 + .long 1223697282 + .long 1409028207 + .long 1236424336 + .long 3586220107 + .long 1249179206 + .long 1522157876 + .long 1261965775 + .long 1820647987 + .long 1274787293 + .long 141517691 + .long 1287671841 + .long 1169226569 + .long 1300517027 + .long 1216765362 + .long 1313047128 + .long 1448028998 + .long 1021264728 + .long 3859033985 + .long 964258238 + .long 4275468065 + .long 1088663688 + .long 2839015045 + .long 1031960699 + .long 2471825140 + .long 1103641144 + .long 2116308392 + .long 1045704405 + .long 320063693 + .long 1166181438 + .long 1786259137 + .long 1181976509 + .long 2022503488 + .long 1197803342 + .long 3654410397 + .long 1213661261 + .long 3612544687 + .long 1229551918 + .long 2586390227 + .long 1245478664 + .long 4037720966 + .long 1261441627 + .long 425603198 + .long 1277313397 + .long 2335359117 + .long 1293212748 + .long 663099774 + .long 1309143515 + .long 3275152075 + .long 1325108897 + .long 3939307299 + .long 1341142935 + .long 2389223216 + .long 1357131850 + .long 3001851795 + .long 1372807567 + .long 2843660044 + .long 1027797837 + .long 4081430736 + .long 972886614 + .long 59873159 + .long 1091970578 + .long 89491691 + .long 1036070212 + .long 800587417 + .long 1110354163 + .long 1316695415 + .long 1054362062 + .long 1053415956 + .long 1186120592 + .long 1951112295 + .long 1205224339 + .long 3452306653 + .long 1224406940 + .long 3087408826 + .long 1243649885 + .long 3141065505 + .long 1262791580 + .long 1611223017 + .long 1282016047 + .long 2457220276 + .long 1301315843 + .long 567478369 + .long 1320490698 + .long 744018712 + .long 1339759601 + .long 3767838035 + .long 1359052970 + .long 2731826519 + .long 1378265330 + .long 2965944329 + .long 1397620918 + .long 3792836018 + .long 1416954415 + .long 4140163483 + .long 1435938859 + .long 3803251356 + .long 1031449026 + .long 1468351707 + .long 974519095 + .long 1510773204 + .long 1095479170 + .long 3459876679 + .long 1039900066 + .long 2329980675 + .long 1117254636 + .long 1442547585 + .long 1060380811 + .long 3793321184 + .long 1207035105 + .long 3851928555 + .long 1229621800 + .long 221632261 + .long 1252267869 + .long 2942953492 + .long 1274996464 + .long 3017520070 + .long 1297616871 + .long 239470767 + .long 1320348902 + .long 1043025700 + .long 1343095998 + .long 252688637 + .long 1365768517 + .long 3880214591 + .long 1388528317 + .long 3579258508 + .long 1411323545 + .long 4034496078 + .long 1434003397 + .long 4007330572 + .long 1456787727 + .long 4167750282 + .long 1479686237 + .long 1263363363 + .long 1502124177 + .long 1204128515 + .long 3180787222 + .long 711751003 + .long 3124411148 + .long 655669005 + .long 1099106472 + .long 1779452985 + .long 1041271036 + .long 3714137145 + .long 1124508819 + .long 3422050113 + .long 1068643358 + .long 2129754319 + .long 1228815190 + .long 1696310114 + .long 1255068559 + .long 1933048134 + .long 1281362741 + .long 1387613391 + .long 1307637530 + .long 3120180336 + .long 1333930483 + .long 2543548174 + .long 1360241860 + .long 1743952085 + .long 1386572739 + .long 830746048 + .long 1412924879 + .long 3823372438 + .long 1439300663 + .long 3126160514 + .long 1465701841 + .long 3650788872 + .long 1492126330 + .long 1753940109 + .long 1518485640 + .long 4158688957 + .long 1544943454 + .long 2419002512 + .long 1571054314 + .long 1387068573 + .long 1036196119 + .long 693317055 + .long 975620966 + .long 85037501 + .long 1102875900 + .long 2766547698 + .long 1047046221 + .long 692715848 + .long 1132034342 + .long 4084350207 + .long 1074738271 + .long 3670967869 + .long 1251313085 + .long 877136010 + .long 1281389973 + .long 2367669872 + .long 1311355635 + .long 127681551 + .long 1341415835 + .long 294488793 + .long 1371561390 + .long 2268228308 + .long 1401588863 + .long 1971903155 + .long 1431680659 + .long 3068569563 + .long 1461838328 + .long 2810042085 + .long 1491968471 + .long 1803405805 + .long 1522051425 + .long 2718559511 + .long 1552192554 + .long 1282364655 + .long 1582403523 + .long 2077022624 + .long 1612690417 + .long 3574791831 + .long 1642467624 + .long 1679930357 + .long 3189181796 + .long 2680901783 + .long 3131938295 + .long 3217922759 + .long 1106719372 + .long 512421297 + .long 1047804811 + .long 767402551 + .long 1139855610 + .long 1780644693 + .long 1084244525 + .long 2568107092 + .long 1274594461 + .long 3742446639 + .long 1308542877 + .long 2828203709 + .long 1342408213 + .long 1035153137 + .long 1376332101 + .long 135830143 + .long 1410361976 + .long 3493601403 + .long 1444258562 + .long 2859691870 + .long 1478279541 + .long 289914903 + .long 1512259079 + .long 388251426 + .long 1546250265 + .long 3047966471 + .long 1580303536 + .long 3861742472 + .long 1614266653 + .long 1260166508 + .long 1648392316 + .long 904399223 + .long 1682450578 + .long 3334685854 + .long 1716212562 + .long 883499133 + .long 1045834798 + .long 1040153219 + .long 987496666 + .long 789418155 + .long 1110723643 + .long 2045920566 + .long 1052287721 + .long 682953991 + .long 1147781119 + .long 96584340 + .long 1092099645 + .long 666163210 + .long 1298545479 + .long 1527740296 + .long 1336421526 + .long 43027861 + .long 1374344588 + .long 1893757912 + .long 1412317817 + .long 3310921752 + .long 1450264132 + .long 1086815150 + .long 1488186400 + .long 2822587825 + .long 1526147814 + .long 1629445394 + .long 1564156239 + .long 2622810410 + .long 1602221540 + .long 2876661682 + .long 1640163607 + .long 151499969 + .long 1678143447 + .long 3591180187 + .long 1716205976 + .long 126024331 + .long 1754364017 + .long 3251093187 + .long 1792100966 + .long 2455853998 + .long 3194846833 + .long 2105329433 + .long 3137419111 + .long 1677091468 + .long 1114834807 + .long 3103559369 + .long 1057563919 + .long 156965555 + .long 1155965375 + .long 1332523955 + .long 1098438055 + .long 2734085455 + .long 1323184128 + .long 3116950081 + .long 1365165587 + .long 2683234966 + .long 1407189808 + .long 2373753488 + .long 1449192848 + .long 1367022160 + .long 1491213979 + .long 3828829922 + .long 1533253445 + .long 649201501 + .long 1575312310 + .long 1349232455 + .long 1617392311 + .long 2871919995 + .long 1659495809 + .long 3481654166 + .long 1701624529 + .long 3617101938 + .long 1743779051 + .long 431481593 + .long 1785867563 + .long 121308995 + .long 1828052659 + .long 357611834 + .long 1869892289 + .long 294133886 + .long 3202139689 + .long 3712546231 + .long 3146198591 + .long 3880935161 + .long 1119029102 + .long 59549724 + .long 1063684005 + .long 3647913141 + .long 1164353962 + .long 4227156178 + .long 1109331949 + .long 3682674216 + .long 1348349871 + .long 2807072537 + .long 1394525619 + .long 2124002856 + .long 1440744183 + .long 2605559380 + .long 1486941516 + .long 2185296140 + .long 1533156938 + .long 3364132884 + .long 1579390693 + .long 3636842097 + .long 1625643843 + .long 1564856349 + .long 1671918127 + .long 282911834 + .long 1718215904 + .long 224295158 + .long 1764538898 + .long 1397797422 + .long 1810887684 + .long 130160665 + .long 1857170584 + .long 3494254532 + .long 1903549984 + .long 2087544159 + .long 1949584056 + .long 2070009724 + .long 3207114478 + .long 3313155961 + .long 3151739743 + .long 1799064076 + .long 1123301109 + .long 3318052585 + .long 1067728611 + .long 1398608221 + .long 1172933154 + .long 3195587656 + .long 1117275768 + .long 3966862011 + .long 1374007527 + .long 3094801078 + .long 1424457063 + .long 201966774 + .long 1474951107 + .long 1216746698 + .long 1525492144 + .long 4169038329 + .long 1576047750 + .long 2574869838 + .long 1626540825 + .long 3353136223 + .long 1677069826 + .long 246421124 + .long 1727641760 + .long 3497001028 + .long 1778265406 + .long 1014877316 + .long 1828833334 + .long 2620327651 + .long 1879376562 + .long 1343179361 + .long 1929994932 + .long 3499694378 + .long 1980775534 + .long 852481763 + .long 2031094897 + .long 858300611 + .long 1060903333 + .long 1069421656 + .long 1004554972 + .long 381774873 + .long 1127661932 + .long 2890562600 + .long 1072008419 + .long 3230239600 + .long 1181757061 + .long 1093463150 + .long 1126994478 + .long 2041459920 + .long 1400246667 + .long 1834149192 + .long 1455089424 + .long 3431867819 + .long 1509997896 + .long 673297555 + .long 1564813682 + .long 2939272129 + .long 1619727956 + .long 2561583193 + .long 1674674892 + .long 1592460776 + .long 1729549373 + .long 4229377564 + .long 1784543364 + .long 3147274091 + .long 1839450750 + .long 199676655 + .long 1894400365 + .long 515597810 + .long 1949398723 + .long 2826001657 + .long 2004337665 + .long 1832191040 + .long 2059473164 + .long 486033509 + .long 2114113687 + .long 2615285763 + .long 3215685247 + .long 3139164341 + .long 3160067829 + .long 2576980377 + .long 1132042649 + .long 2136544456 + .long 1076438044 + .long 1202590842 + .long 1190427361 + .long 3058408830 + .long 1135356281 + .long 2163381214 + .long 1426480799 + .long 2353327718 + .long 1485745575 + .long 3794661129 + .long 1544911246 + .long 3594844771 + .long 1604225727 + .long 3801864141 + .long 1663434111 + .long 1474426882 + .long 1722809436 + .long 2103181697 + .long 1782019277 + .long 1306699518 + .long 1841386098 + .long 2394149058 + .long 1900657427 + .long 2802357954 + .long 1959997432 + .long 4190579671 + .long 2019374921 + .long 1589399104 + .long 2078657782 + .long 459261522 + .long 2137266825 + .long 4294967295 + .long 2146435071 + .long 158971950 + .long 3154658393 + .long 3459173435 + .long 3099360488 + .long 2835657100 + .long 3221135661 + .long 3134582638 + .long 3163662002 + .long 1009146449 + .long 1076045439 + .long 2177907437 + .long 1020724564 + .long 2093419253 + .long 1082406719 + .long 3184966549 + .long 3231785529 + .long 3799028631 + .long 1086175845 + .long 81768581 + .long 3235523877 + .long 1017495356 + .long 1089951767 + .long 1546026610 + .long 3239380678 + .long 980092412 + .long 1093867758 + .long 4064795288 + .long 3243341671 + .long 3027586419 + .long 1097863735 + .long 1002816472 + .long 3247290528 + .long 985745927 + .long 1101758613 + .long 1714999460 + .long 3251222455 + .long 808706777 + .long 1105883774 + .long 2540867906 + .long 3255308994 + .long 1548702939 + .long 3157340334 + .long 1276328330 + .long 3102548777 + .long 2523682374 + .long 3224680861 + .long 1002691513 + .long 3168986622 + .long 2919511741 + .long 1081046750 + .long 3737147325 + .long 1024759629 + .long 2879373926 + .long 1098115315 + .long 103788827 + .long 3250052030 + .long 3732555687 + .long 1107111798 + .long 3845853773 + .long 3259114079 + .long 3808164400 + .long 1116131626 + .long 1738785984 + .long 3268214722 + .long 581652 + .long 1125291233 + .long 3382894442 + .long 3277322952 + .long 2879368705 + .long 1134502288 + .long 2391566275 + .long 3286518813 + .long 274553400 + .long 1143638273 + .long 512789562 + .long 3295790146 + .long 3583864087 + .long 1152986324 + .long 2337425402 + .long 3304798727 + .long 1854575809 + .long 3159867196 + .long 1765059742 + .long 3103980390 + .long 1056564255 + .long 3227329098 + .long 957604928 + .long 3170301297 + .long 1737111893 + .long 1086018364 + .long 3821479224 + .long 1030262355 + .long 1397067068 + .long 1113230428 + .long 1054232731 + .long 3267692171 + .long 1978243918 + .long 1127284645 + .long 3722409577 + .long 3281775634 + .long 1918858489 + .long 1141323813 + .long 3391721543 + .long 3295903979 + .long 2607178807 + .long 1155564765 + .long 3212344015 + .long 3310103974 + .long 3369531970 + .long 1169698149 + .long 335451402 + .long 3324302881 + .long 431247382 + .long 1183973580 + .long 3717434926 + .long 3338657222 + .long 1904523769 + .long 1198380992 + .long 8765522 + .long 3352646819 + .long 2089515505 + .long 1016996008 + .long 1260660699 + .long 961055715 + .long 2755288594 + .long 3230032374 + .long 651647436 + .long 3174928677 + .long 3079991920 + .long 1091533276 + .long 3443268597 + .long 1035583207 + .long 3925746702 + .long 1129598292 + .long 1087270140 + .long 3286788174 + .long 494941268 + .long 1149105228 + .long 1413067450 + .long 3306335280 + .long 2943951130 + .long 1168609830 + .long 1917094202 + .long 3325955583 + .long 3282582259 + .long 1188254230 + .long 205065768 + .long 3345548222 + .long 3975827413 + .long 1207978573 + .long 608024766 + .long 3365228477 + .long 514952666 + .long 1227617187 + .long 1683103546 + .long 3384985256 + .long 3324939681 + .long 1247457575 + .long 4078451799 + .long 3404527118 + .long 3100987862 + .long 1019853288 + .long 2384335067 + .long 962691388 + .long 2781784351 + .long 3233000439 + .long 1271614660 + .long 3176489869 + .long 626016822 + .long 1097348250 + .long 3842822006 + .long 1040353260 + .long 2239739676 + .long 1147303774 + .long 189136319 + .long 3307436007 + .long 2396687400 + .long 1172632530 + .long 1908223243 + .long 3332827221 + .long 2121588596 + .long 1198087089 + .long 3983173167 + .long 3358350016 + .long 2487337699 + .long 1223686165 + .long 3249965797 + .long 3383895554 + .long 3887284480 + .long 1249163916 + .long 138948171 + .long 3409430498 + .long 1463100005 + .long 1274763805 + .long 34738943 + .long 3435142323 + .long 2889101777 + .long 1300502035 + .long 2665757401 + .long 3460504734 + .long 987318156 + .long 3170486179 + .long 252831213 + .long 3113594951 + .long 4266405771 + .long 3236147062 + .long 52757777 + .long 3180182741 + .long 1823142101 + .long 1103640807 + .long 3806357955 + .long 1046313461 + .long 875359927 + .long 1166180665 + .long 1815208659 + .long 3329459206 + .long 1303129141 + .long 1197802172 + .long 4280462790 + .long 3361143469 + .long 626701262 + .long 1229550147 + .long 2303856491 + .long 3392960132 + .long 2759522360 + .long 1261440286 + .long 145515022 + .long 3424795397 + .long 2201193688 + .long 1293210725 + .long 2057332964 + .long 3456624552 + .long 3539517099 + .long 1325105434 + .long 1364231459 + .long 3488625947 + .long 3421843712 + .long 1357133388 + .long 200896422 + .long 3520281853 + .long 951171540 + .long 1026768452 + .long 3090769089 + .long 971487574 + .long 4234403032 + .long 3239454189 + .long 1460268972 + .long 3184474466 + .long 1346899734 + .long 1110354113 + .long 145456861 + .long 1052864217 + .long 2924701438 + .long 1186120500 + .long 3023147446 + .long 3352707860 + .long 1486479387 + .long 1224406765 + .long 1193997181 + .long 3391133412 + .long 2679629000 + .long 1262791412 + .long 2670450976 + .long 3429499462 + .long 1831795719 + .long 1301315682 + .long 3473315319 + .long 3467974125 + .long 2616420704 + .long 1339759302 + .long 1949536880 + .long 3506536322 + .long 2518396463 + .long 1378264708 + .long 142869669 + .long 3545106524 + .long 804820494 + .long 1416958345 + .long 2985125801 + .long 3583414179 + .long 2729716642 + .long 3174389784 + .long 1779261930 + .long 3115790859 + .long 2784196366 + .long 3242962813 + .long 2825451289 + .long 3185986297 + .long 2032114899 + .long 1117254632 + .long 1505002334 + .long 1059738942 + .long 3277658686 + .long 1207035096 + .long 498115686 + .long 3377105433 + .long 1711172328 + .long 1252267855 + .long 261417437 + .long 3422480089 + .long 1133240684 + .long 1297616851 + .long 1456800292 + .long 3467832532 + .long 2145797446 + .long 1343095967 + .long 2516644728 + .long 3513252141 + .long 725820954 + .long 1388528302 + .long 3986994814 + .long 3558807006 + .long 1955265405 + .long 1434003000 + .long 122646123 + .long 3604272992 + .long 1491943337 + .long 1479689885 + .long 1036478018 + .long 3649599135 + .long 523859850 + .long 3181400160 + .long 3846079041 + .long 3121433884 + .long 3639230521 + .long 3246590119 + .long 2638130497 + .long 3191278647 + .long 2154057324 + .long 1124508819 + .long 3236410824 + .long 1069265219 + .long 175871336 + .long 1228815189 + .long 2852522281 + .long 3402552205 + .long 1806384070 + .long 1281362740 + .long 423509286 + .long 3455121177 + .long 1160294737 + .long 1333930482 + .long 3543120866 + .long 3507725506 + .long 1036273485 + .long 1386572737 + .long 2942188771 + .long 3560408527 + .long 2777944578 + .long 1439300670 + .long 2738100981 + .long 3613185349 + .long 527942274 + .long 1492126097 + .long 1294011372 + .long 3665970729 + .long 3274455694 + .long 1544947882 + .long 1889769429 + .long 3718530789 + .long 136073262 + .long 1038797747 + .long 502134597 + .long 982165232 + .long 4211775762 + .long 3250359547 + .long 1347037926 + .long 3194312374 + .long 543769047 + .long 1132034342 + .long 1153606166 + .long 1076402838 + .long 3293430877 + .long 1251313085 + .long 540290119 + .long 3428873621 + .long 1766589444 + .long 1311355635 + .long 3887512491 + .long 3488899482 + .long 4113271272 + .long 1371561389 + .long 1216453194 + .long 3549072511 + .long 761821280 + .long 1431680659 + .long 3412859739 + .long 3609321978 + .long 1736216465 + .long 1491968482 + .long 1379671921 + .long 3669534956 + .long 871564305 + .long 1552192257 + .long 3755076681 + .long 3729888559 + .long 465380849 + .long 1612696812 + .long 1801521440 + .long 3789943511 + .long 926050541 + .long 3187761455 + .long 2363428923 + .long 3130505121 + .long 3212464044 + .long 3254203020 + .long 1767044225 + .long 3196691034 + .long 767402551 + .long 1139855610 + .long 3251527812 + .long 1084244526 + .long 2568107110 + .long 1274594461 + .long 3742439917 + .long 3456026525 + .long 2828194370 + .long 1342408213 + .long 1036563767 + .long 3523815749 + .long 138125806 + .long 1410361976 + .long 3332253618 + .long 3591742210 + .long 2265969007 + .long 1478279541 + .long 2044799860 + .long 3659742729 + .long 3159788672 + .long 1546250274 + .long 3040087996 + .long 3727787101 + .long 3566786041 + .long 1614266310 + .long 3445702274 + .long 3795877266 + .long 1647738551 + .long 1682455451 + .long 820553625 + .long 3863686600 + .long 2466985759 + .long 1045839115 + .long 2115301394 + .long 988248469 + .long 789067623 + .long 3258207291 + .long 2594430310 + .long 3200300918 + .long 682953991 + .long 1147781119 + .long 334308353 + .long 1092099647 + .long 666163226 + .long 1298545479 + .long 1527735017 + .long 3483905174 + .long 43015025 + .long 1374344588 + .long 1895454381 + .long 3559801465 + .long 3313337462 + .long 1450264132 + .long 938251762 + .long 3635670048 + .long 2344246077 + .long 1526147814 + .long 3329926839 + .long 3711639890 + .long 2189826955 + .long 1602221552 + .long 307911546 + .long 3787647166 + .long 4271816317 + .long 1678143122 + .long 3455709496 + .long 3863691777 + .long 509127304 + .long 1754367541 + .long 2246034954 + .long 3939578533 + .long 309332673 + .long 3194846686 + .long 4050026421 + .long 3139306075 + .long 1677069013 + .long 3262318455 + .long 407665306 + .long 3207206552 + .long 156965555 + .long 1155965375 + .long 2320115828 + .long 1098438062 + .long 2734085477 + .long 1323184128 + .long 3116943360 + .long 3512649235 + .long 2683227306 + .long 1407189808 + .long 2374702532 + .long 3596676496 + .long 1369556142 + .long 1491213979 + .long 3682738445 + .long 3680737093 + .long 208207094 + .long 1575312310 + .long 1070212038 + .long 3764875962 + .long 1332751409 + .long 1659495819 + .long 2960239586 + .long 3849108041 + .long 1328259946 + .long 1743778590 + .long 2152673987 + .long 3933352648 + .long 2459568424 + .long 1828057070 + .long 1053026559 + .long 4017368800 + .long 4272716315 + .long 3202139688 + .long 2347479448 + .long 3145750572 + .long 3880933726 + .long 3266512750 + .long 1526392126 + .long 3209922805 + .long 3647913141 + .long 1164353962 + .long 3796124307 + .long 1109331951 + .long 3682674239 + .long 1348349871 + .long 2807065817 + .long 3542009267 + .long 2123995152 + .long 1440744183 + .long 2606508288 + .long 3634425164 + .long 2187838465 + .long 1533156938 + .long 3218070138 + .long 3726874341 + .long 3194985081 + .long 1625643843 + .long 1282672122 + .long 3819401778 + .long 3085269549 + .long 1718215913 + .long 4171823927 + .long 3912022409 + .long 2286527342 + .long 1810887222 + .long 4263058773 + .long 4004655668 + .long 276869381 + .long 1903554397 + .long 2981609009 + .long 4097060567 + .long 2069415824 + .long 3207114478 + .long 3815897610 + .long 3150201997 + .long 1799063985 + .long 3270784757 + .long 609928762 + .long 3210962773 + .long 1398608221 + .long 1172933154 + .long 2839394180 + .long 1117275773 + .long 3966862031 + .long 1374007527 + .long 3094795956 + .long 3571940711 + .long 201952387 + .long 1474951107 + .long 1218377639 + .long 3672975792 + .long 4171572408 + .long 1576047750 + .long 2433360787 + .long 3774024473 + .long 2872117748 + .long 1677069826 + .long 1125668053 + .long 3875125411 + .long 1838424462 + .long 1778265418 + .long 1923560800 + .long 3976316898 + .long 2192672438 + .long 1879376253 + .long 2795231406 + .long 4077480577 + .long 3134618972 + .long 1980778833 + .long 2542206299 + .long 4178570441 + .long 858317418 + .long 1060903333 + .long 3120786235 + .long 1004681431 + .long 381774867 + .long 3275145580 + .long 1575769843 + .long 3219836452 + .long 3230239600 + .long 1181757061 + .long 1694309796 + .long 1126994475 + .long 2041459926 + .long 1400246667 + .long 1834143305 + .long 3602573072 + .long 3431862699 + .long 1509997896 + .long 674489055 + .long 3712297330 + .long 2942256815 + .long 1619727956 + .long 2430104127 + .long 3822158540 + .long 1181772448 + .long 1729549373 + .long 3316918483 + .long 3932027016 + .long 2290692518 + .long 1839450757 + .long 717742192 + .long 4041883887 + .long 2723262413 + .long 1949398481 + .long 726994291 + .long 4151823214 + .long 2316520017 + .long 2059476550 + .long 3506192554 + .long 4261590717 + .long 2615285756 + .long 3215685247 + .long 3456994573 + .long 3158988097 + .long 2576980377 + .long 3279526297 + .long 457772008 + .long 3222963352 + .long 1202590842 + .long 1190427361 + .long 3150210795 + .long 1135356295 + .long 2163381170 + .long 1426480799 + .long 2353315751 + .long 3633229223 + .long 3794716365 + .long 1544911246 + .long 3598226895 + .long 3751709375 + .long 3778743776 + .long 1663434111 + .long 1038551128 + .long 3870293084 + .long 2177305923 + .long 1782019278 + .long 316150431 + .long 3988869748 + .long 3666573938 + .long 1900657340 + .long 1225202613 + .long 4107481261 + .long 4106613245 + .long 2019377222 + .long 3685171119 + .long 4226128894 + .long 3001847201 + .long 2137308914 + .long 4294967295 + .long 4293918719 + .type _dbA,@object + .size _dbA,8032 + .space 672, 0x00 # pad + .align 4 +.L_2il0floatpacket.22: + .long 0x3f800000 + .type .L_2il0floatpacket.22,@object + .size .L_2il0floatpacket.22,4 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_OFW_BOUND: + .word 60404 + .word 65533 + .word 19595 + .word 47317 + .word 32753 + .word 0 + .word 0 + .word 0 + .type _OFW_BOUND,@object + .size _OFW_BOUND,16 + .align 2 +_TWO5600: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 21983 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 10783 + .word 0 + .word 0 + .word 0 + .type _TWO5600,@object + .size _TWO5600,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_atan2_k64.S b/external/sgx_libm/intel64/libm_atan2_k64.S new file mode 100644 index 0000000000..a4710fc4a5 --- /dev/null +++ b/external/sgx_libm/intel64/libm_atan2_k64.S @@ -0,0 +1,1434 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_atan2_k64.c" + .text +..TXTST0: +# -- Begin __libm_atan2_k64 + .text + .align 16,0x90 + .globl __libm_atan2_k64 +__libm_atan2_k64: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B1.1: + .cfi_startproc +..___tag_value___libm_atan2_k64.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + movq %rsi, %r9 + movq %rdx, %rax + movzwl 6(%r9), %r11d + andl $32752, %r11d + movb 7(%r9), %sil + movb 7(%rax), %dl + andb $-128, %sil + movzwl 6(%rax), %r10d + andb $-128, %dl + andl $32752, %r10d + shrl $4, %r11d + shrb $7, %sil + shrb $7, %dl + shrl $4, %r10d + cmpl $2047, %r11d + jge ..B1.34 +..B1.2: + cmpl $2047, %r10d + jge ..B1.35 +..B1.3: + testl %r11d, %r11d + jne ..B1.6 +..B1.4: + testl $1048575, 4(%r9) + jne ..B1.6 +..B1.5: + cmpl $0, (%r9) + je ..B1.29 +..B1.6: + testl %r10d, %r10d + jne ..B1.9 +..B1.7: + testl $1048575, 4(%rax) + jne ..B1.9 +..B1.8: + cmpl $0, (%rax) + je ..B1.27 +..B1.9: + movzbl %sil, %r8d + lea _dAtan2Tab(%rip), %rcx + movsd (%r9), %xmm4 + testl %r11d, %r11d + movsd 8(%r9), %xmm6 + movzbl %dl, %r9d + movsd 1904(%rcx,%r8,8), %xmm9 + movsd (%rax), %xmm3 + mulsd %xmm9, %xmm4 + movaps %xmm3, %xmm2 + mulsd %xmm9, %xmm6 + movsd 8(%rax), %xmm9 + movsd 1904(%rcx,%r9,8), %xmm0 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm9 + jle ..B1.47 +..B1.10: + lea 1888+_dAtan2Tab(%rip), %rax + lea -1023(%r11), %r9d + movl %r9d, %r13d + negl %r13d + addl $1023, %r13d + movq (%rax), %r8 + andl $2047, %r13d + movq %r8, -32(%rsp) + shrq $48, %r8 + shll $4, %r13d + andl $-32753, %r8d + movsd %xmm4, -24(%rsp) + orl %r13d, %r8d + movw %r8w, -26(%rsp) + movzwl -18(%rsp), %eax + andl $-32753, %eax + movsd -32(%rsp), %xmm0 + orl $-49168, %eax + movw %ax, -18(%rsp) + mulsd %xmm0, %xmm6 +..B1.11: + testl %r10d, %r10d + jle ..B1.46 +..B1.12: + lea 1888+_dAtan2Tab(%rip), %rax + lea -1023(%r10), %r8d + movsd %xmm2, -16(%rsp) + movq (%rax), %r13 + movl %r8d, %eax + negl %eax + addl $1023, %eax + movq %r13, -32(%rsp) + andl $2047, %eax + shrq $48, %r13 + shll $4, %eax + andl $-32753, %r13d + orl %eax, %r13d + movw %r13w, -26(%rsp) + movzwl -10(%rsp), %eax + andl $-32753, %eax + movsd -32(%rsp), %xmm0 + orl $-49168, %eax + movw %ax, -10(%rsp) + mulsd %xmm0, %xmm9 +..B1.13: + movl %r9d, %eax + subl %r8d, %eax + cmpl $-54, %eax + jle ..B1.24 +..B1.14: + cmpl $54, %eax + jge ..B1.21 +..B1.15: + testb %dl, %dl + jne ..B1.17 +..B1.16: + lea 1992+_dAtan2Tab(%rip), %rax + movsd (%rax), %xmm12 + movaps %xmm12, %xmm13 + jmp ..B1.18 +..B1.17: + lea 1952+_dAtan2Tab(%rip), %rax + lea 1960+_dAtan2Tab(%rip), %r10 + movsd (%rax), %xmm12 + movsd (%r10), %xmm13 +..B1.18: + negl %r9d + lea 1888+_dAtan2Tab(%rip), %rax + movsd -16(%rsp), %xmm8 + lea 1880+_dAtan2Tab(%rip), %r11 + movzwl 6(%rax), %r10d + lea 1023(%r8,%r9), %r8d + andl $2047, %r8d + andl $-32753, %r10d + movsd (%rax), %xmm10 + lea 2016+_dAtan2Tab(%rip), %r9 + shll $4, %r8d + movaps %xmm10, %xmm1 + movsd %xmm10, -64(%rsp) + orl %r8d, %r10d + movw %r10w, -58(%rsp) + movsd -64(%rsp), %xmm4 + mulsd %xmm4, %xmm8 + mulsd %xmm4, %xmm9 + movsd -24(%rsp), %xmm4 + movsd (%r9), %xmm11 + movaps %xmm4, %xmm5 + mulsd %xmm11, %xmm5 + movaps %xmm4, %xmm7 + movaps %xmm5, %xmm3 + subsd %xmm4, %xmm3 + subsd %xmm3, %xmm5 + movaps %xmm11, %xmm3 + mulsd %xmm8, %xmm3 + subsd %xmm5, %xmm7 + movaps %xmm3, %xmm2 + addsd %xmm6, %xmm7 + subsd %xmm8, %xmm2 + subsd %xmm2, %xmm3 + movaps %xmm8, %xmm2 + divsd %xmm3, %xmm1 + movaps %xmm1, %xmm15 + movaps %xmm3, %xmm0 + mulsd %xmm11, %xmm15 + subsd %xmm3, %xmm2 + movaps %xmm15, %xmm14 + addsd %xmm9, %xmm2 + subsd %xmm1, %xmm14 + subsd %xmm14, %xmm15 + movaps %xmm10, %xmm14 + mulsd %xmm15, %xmm0 + movaps %xmm15, %xmm1 + mulsd %xmm2, %xmm1 + subsd %xmm0, %xmm14 + subsd %xmm1, %xmm14 + movaps %xmm15, %xmm1 + mulsd %xmm5, %xmm1 + movaps %xmm14, %xmm0 + addsd %xmm10, %xmm0 + mulsd %xmm0, %xmm14 + movaps %xmm7, %xmm0 + mulsd %xmm15, %xmm14 + mulsd %xmm7, %xmm15 + mulsd %xmm14, %xmm0 + mulsd %xmm5, %xmm14 + addsd %xmm14, %xmm0 + addsd %xmm15, %xmm0 + movaps %xmm0, %xmm14 + addsd %xmm1, %xmm14 + comisd (%r11), %xmm14 + subsd %xmm14, %xmm1 + addsd %xmm0, %xmm1 + jb ..B1.20 +..B1.19: + movsd %xmm14, -64(%rsp) + lea 1984+_dAtan2Tab(%rip), %r9 + movl -60(%rsp), %r8d + lea 1872+_dAtan2Tab(%rip), %r10 + andl $-524288, %r8d + lea 1864+_dAtan2Tab(%rip), %r11 + orl $262144, %r8d + lea 1856+_dAtan2Tab(%rip), %r13 + movl $0, -64(%rsp) + movl %r8d, -60(%rsp) + lea 1848+_dAtan2Tab(%rip), %r8 + movsd -64(%rsp), %xmm1 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm5 + mulsd %xmm1, %xmm7 + movsd (%r9), %xmm0 + movaps %xmm11, %xmm1 + mulsd %xmm0, %xmm3 + lea 1840+_dAtan2Tab(%rip), %r9 + mulsd %xmm2, %xmm0 + movsd %xmm14, -40(%rsp) + movaps %xmm3, %xmm14 + movaps %xmm4, %xmm2 + addsd %xmm0, %xmm14 + movl -36(%rsp), %eax + subsd %xmm14, %xmm3 + andl $2147483647, %eax + addsd %xmm3, %xmm0 + movaps %xmm14, %xmm3 + addl $-1069547520, %eax + sarl $18, %eax + addsd %xmm4, %xmm3 + andl $-2, %eax + subsd %xmm3, %xmm2 + movslq %eax, %rax + addsd %xmm2, %xmm14 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm4 + addsd %xmm4, %xmm14 + movaps %xmm3, %xmm4 + mulsd %xmm11, %xmm4 + addsd %xmm14, %xmm6 + movaps %xmm4, %xmm15 + addsd %xmm0, %xmm6 + subsd %xmm3, %xmm15 + movaps %xmm5, %xmm0 + subsd %xmm15, %xmm4 + addsd %xmm7, %xmm0 + subsd %xmm4, %xmm3 + subsd %xmm0, %xmm5 + addsd %xmm6, %xmm3 + addsd %xmm5, %xmm7 + movaps %xmm0, %xmm5 + movaps %xmm8, %xmm6 + addsd %xmm8, %xmm5 + subsd %xmm5, %xmm6 + addsd %xmm6, %xmm0 + addsd %xmm5, %xmm6 + subsd %xmm6, %xmm8 + addsd %xmm8, %xmm0 + addsd %xmm0, %xmm9 + movaps %xmm5, %xmm0 + mulsd %xmm11, %xmm0 + addsd %xmm7, %xmm9 + movaps %xmm0, %xmm7 + subsd %xmm5, %xmm7 + subsd %xmm7, %xmm0 + movsd (%r10), %xmm7 + lea 1832+_dAtan2Tab(%rip), %r10 + subsd %xmm0, %xmm5 + addsd %xmm9, %xmm5 + movaps %xmm10, %xmm9 + divsd %xmm0, %xmm9 + mulsd %xmm9, %xmm1 + movaps %xmm1, %xmm8 + subsd %xmm9, %xmm8 + movaps %xmm10, %xmm9 + subsd %xmm8, %xmm1 + movaps %xmm12, %xmm8 + mulsd %xmm1, %xmm0 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm5 + mulsd %xmm4, %xmm2 + subsd %xmm0, %xmm9 + subsd %xmm5, %xmm9 + movaps %xmm2, %xmm5 + addsd %xmm9, %xmm10 + mulsd %xmm10, %xmm9 + movaps %xmm3, %xmm10 + mulsd %xmm1, %xmm9 + mulsd %xmm3, %xmm1 + mulsd %xmm9, %xmm10 + mulsd %xmm9, %xmm4 + addsd %xmm4, %xmm10 + addsd %xmm1, %xmm10 + addsd %xmm10, %xmm5 + movaps %xmm5, %xmm3 + movaps %xmm5, %xmm15 + mulsd %xmm5, %xmm3 + subsd %xmm5, %xmm2 + mulsd %xmm11, %xmm15 + mulsd %xmm3, %xmm7 + addsd %xmm2, %xmm10 + movaps %xmm15, %xmm4 + addsd (%r11), %xmm7 + subsd %xmm5, %xmm4 + mulsd %xmm3, %xmm7 + subsd %xmm4, %xmm15 + addsd (%r13), %xmm7 + subsd %xmm15, %xmm5 + mulsd %xmm3, %xmm7 + addsd %xmm5, %xmm10 + addsd (%r8), %xmm7 + mulsd %xmm3, %xmm7 + lea 1824+_dAtan2Tab(%rip), %r11 + movaps %xmm10, %xmm0 + addsd (%r9), %xmm7 + mulsd %xmm3, %xmm7 + movsd (%rcx,%rax,8), %xmm4 + addsd (%r10), %xmm7 + mulsd %xmm3, %xmm7 + addsd (%r11), %xmm7 + mulsd %xmm3, %xmm7 + mulsd %xmm7, %xmm11 + movaps %xmm11, %xmm6 + subsd %xmm7, %xmm6 + subsd %xmm6, %xmm11 + movaps %xmm11, %xmm14 + subsd %xmm11, %xmm7 + mulsd %xmm15, %xmm14 + mulsd %xmm10, %xmm11 + mulsd %xmm7, %xmm0 + mulsd %xmm15, %xmm7 + addsd %xmm11, %xmm0 + movaps %xmm14, %xmm2 + movaps %xmm14, %xmm11 + addsd %xmm15, %xmm2 + addsd %xmm7, %xmm0 + subsd %xmm2, %xmm11 + movaps %xmm2, %xmm3 + movaps %xmm2, %xmm1 + addsd %xmm11, %xmm15 + addsd %xmm2, %xmm11 + addsd %xmm4, %xmm3 + subsd %xmm11, %xmm14 + subsd %xmm3, %xmm1 + addsd %xmm14, %xmm15 + addsd %xmm1, %xmm4 + addsd %xmm3, %xmm1 + addsd %xmm15, %xmm10 + subsd %xmm1, %xmm2 + addsd %xmm0, %xmm10 + addsd %xmm2, %xmm4 + movsd %xmm3, -56(%rsp) + addsd %xmm10, %xmm4 + addsd 8(%rcx,%rax,8), %xmm4 + movb %dl, %cl + shlb $7, %cl + movsd %xmm4, -48(%rsp) + movb -49(%rsp), %al + andb $127, %al + orb %cl, %al + movb %al, -49(%rsp) + movsd -56(%rsp), %xmm7 + movaps %xmm7, %xmm5 + addsd %xmm7, %xmm8 + movb -41(%rsp), %r8b + movb %r8b, %r9b + shrb $7, %r8b + subsd %xmm8, %xmm5 + movaps %xmm8, %xmm6 + addsd %xmm5, %xmm12 + addsd %xmm5, %xmm6 + xorb %r8b, %dl + andb $127, %r9b + shlb $7, %dl + subsd %xmm6, %xmm7 + movsd %xmm8, -56(%rsp) + addsd %xmm7, %xmm12 + orb %dl, %r9b + movb %r9b, -41(%rsp) + movsd -48(%rsp), %xmm9 + movb -49(%rsp), %dl + movb %dl, %al + shrb $7, %dl + addsd %xmm12, %xmm9 + movsd %xmm12, -32(%rsp) + addsd %xmm13, %xmm9 + movsd %xmm9, -48(%rsp) + xorb %sil, %dl + movb -41(%rsp), %cl + movb %cl, %r8b + shrb $7, %cl + andb $127, %al + shlb $7, %dl + xorb %sil, %cl + andb $127, %r8b + shlb $7, %cl + orb %dl, %al + orb %cl, %r8b + movb %al, -49(%rsp) + movb %r8b, -41(%rsp) + movq -56(%rsp), %rsi + movq -48(%rsp), %rax + movq %rsi, (%rdi) + movq %rax, 8(%rdi) + xorl %eax, %eax + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.20: + movaps %xmm14, %xmm0 + lea 1872+_dAtan2Tab(%rip), %rax + mulsd %xmm14, %xmm0 + lea 1864+_dAtan2Tab(%rip), %rcx + movsd (%rax), %xmm3 + lea 1856+_dAtan2Tab(%rip), %r8 + mulsd %xmm0, %xmm3 + lea 1848+_dAtan2Tab(%rip), %r9 + lea 1840+_dAtan2Tab(%rip), %r10 + addsd (%rcx), %xmm3 + mulsd %xmm0, %xmm3 + lea 1832+_dAtan2Tab(%rip), %r11 + movaps %xmm11, %xmm6 + movb %dl, %al + mulsd %xmm14, %xmm6 + addsd (%r8), %xmm3 + shlb $7, %al + mulsd %xmm0, %xmm3 + movaps %xmm6, %xmm2 + subsd %xmm14, %xmm2 + addsd (%r9), %xmm3 + subsd %xmm2, %xmm6 + mulsd %xmm0, %xmm3 + subsd %xmm6, %xmm14 + addsd (%r10), %xmm3 + addsd %xmm14, %xmm1 + mulsd %xmm0, %xmm3 + lea 1824+_dAtan2Tab(%rip), %r13 + addsd (%r11), %xmm3 + mulsd %xmm0, %xmm3 + movaps %xmm6, %xmm5 + movaps %xmm12, %xmm9 + addsd (%r13), %xmm3 + mulsd %xmm0, %xmm3 + mulsd %xmm3, %xmm11 + movaps %xmm11, %xmm14 + subsd %xmm3, %xmm14 + subsd %xmm14, %xmm11 + movaps %xmm11, %xmm4 + subsd %xmm11, %xmm3 + mulsd %xmm6, %xmm4 + mulsd %xmm1, %xmm11 + addsd %xmm4, %xmm5 + movaps %xmm3, %xmm7 + mulsd %xmm1, %xmm7 + mulsd %xmm6, %xmm3 + addsd %xmm11, %xmm7 + movaps %xmm4, %xmm11 + addsd %xmm3, %xmm7 + subsd %xmm5, %xmm11 + movsd %xmm5, -56(%rsp) + addsd %xmm11, %xmm6 + addsd %xmm5, %xmm11 + movb -49(%rsp), %cl + subsd %xmm11, %xmm4 + andb $127, %cl + addsd %xmm4, %xmm6 + orb %al, %cl + addsd %xmm6, %xmm1 + movb %cl, -49(%rsp) + addsd %xmm7, %xmm1 + movsd -56(%rsp), %xmm8 + movaps %xmm8, %xmm10 + addsd %xmm8, %xmm9 + movsd %xmm1, -48(%rsp) + movaps %xmm9, %xmm1 + movb -41(%rsp), %r8b + movb %r8b, %r9b + shrb $7, %r8b + subsd %xmm9, %xmm10 + movsd %xmm9, -56(%rsp) + addsd %xmm10, %xmm1 + addsd %xmm12, %xmm10 + subsd %xmm1, %xmm8 + xorb %r8b, %dl + andb $127, %r9b + shlb $7, %dl + addsd %xmm8, %xmm10 + movsd %xmm10, -32(%rsp) + orb %dl, %r9b + movb %r9b, -41(%rsp) + movsd -48(%rsp), %xmm12 + movb -49(%rsp), %dl + movb %dl, %al + shrb $7, %dl + addsd %xmm10, %xmm12 + addsd %xmm13, %xmm12 + movsd %xmm12, -48(%rsp) + xorb %sil, %dl + movb -41(%rsp), %cl + movb %cl, %r8b + shrb $7, %cl + andb $127, %al + shlb $7, %dl + xorb %sil, %cl + andb $127, %r8b + shlb $7, %cl + orb %dl, %al + orb %cl, %r8b + movb %al, -49(%rsp) + movb %r8b, -41(%rsp) + movq -56(%rsp), %rsi + movq -48(%rsp), %rax + movq %rsi, (%rdi) + movq %rax, 8(%rdi) + xorl %eax, %eax + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.21: + subl %r10d, %r11d + cmpl $74, %r11d + jge ..B1.23 +..B1.22: + divsd %xmm4, %xmm3 + lea 1944+_dAtan2Tab(%rip), %rax + lea 1936+_dAtan2Tab(%rip), %rdx + movsd %xmm3, -32(%rsp) + movsd (%rax), %xmm0 + xorl %eax, %eax + movq (%rdx), %rcx + subsd %xmm3, %xmm0 + movq %rcx, (%rdi) + shrq $56, %rcx + movsd %xmm0, 8(%rdi) + movb 15(%rdi), %r9b + movb %cl, %r8b + shrb $7, %cl + movb %r9b, %r10b + shrb $7, %r9b + xorb %sil, %cl + xorb %sil, %r9b + shlb $7, %cl + andb $127, %r8b + shlb $7, %r9b + andb $127, %r10b + orb %cl, %r8b + orb %r9b, %r10b + movb %r8b, 7(%rdi) + movb %r10b, 15(%rdi) + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.23: + lea 1936+_dAtan2Tab(%rip), %rax + lea 1944+_dAtan2Tab(%rip), %rdx + movq (%rax), %rcx + xorl %eax, %eax + movq (%rdx), %r9 + movq %rcx, (%rdi) + movq %r9, 8(%rdi) + shrq $56, %rcx + shrq $56, %r9 + movb %cl, %r8b + shrb $7, %cl + movb %r9b, %r10b + shrb $7, %r9b + xorb %sil, %cl + xorb %sil, %r9b + shlb $7, %cl + andb $127, %r8b + shlb $7, %r9b + andb $127, %r10b + orb %cl, %r8b + orb %r9b, %r10b + movb %r8b, 7(%rdi) + movb %r10b, 15(%rdi) + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.24: + testb %dl, %dl + jne ..B1.26 +..B1.25: + lea 2016+_dAtan2Tab(%rip), %rdx + lea 1888+_dAtan2Tab(%rip), %rcx + movsd -24(%rsp), %xmm8 + movaps %xmm8, %xmm7 + movsd -16(%rsp), %xmm3 + movsd (%rdx), %xmm10 + movaps %xmm3, %xmm2 + mulsd %xmm10, %xmm7 + mulsd %xmm10, %xmm2 + movaps %xmm7, %xmm0 + movsd (%rcx), %xmm4 + subsd %xmm8, %xmm0 + movaps %xmm4, %xmm5 + subsd %xmm0, %xmm7 + subsd %xmm7, %xmm8 + addsd %xmm6, %xmm8 + movaps %xmm2, %xmm6 + subsd %xmm3, %xmm6 + movaps %xmm8, %xmm11 + subsd %xmm6, %xmm2 + subsd %xmm2, %xmm3 + addsd %xmm9, %xmm3 + movaps %xmm4, %xmm9 + divsd %xmm2, %xmm9 + mulsd %xmm9, %xmm10 + movaps %xmm10, %xmm1 + subsd %xmm9, %xmm1 + subsd %xmm1, %xmm10 + mulsd %xmm10, %xmm2 + movaps %xmm10, %xmm13 + mulsd %xmm10, %xmm3 + mulsd %xmm7, %xmm13 + subsd %xmm2, %xmm5 + movsd %xmm10, -56(%rsp) + subsd %xmm3, %xmm5 + addsd %xmm5, %xmm4 + mulsd %xmm4, %xmm5 + mulsd %xmm10, %xmm5 + mulsd %xmm8, %xmm10 + mulsd %xmm5, %xmm11 + mulsd %xmm5, %xmm7 + movsd %xmm5, -48(%rsp) + addsd %xmm7, %xmm11 + addsd %xmm10, %xmm11 + movaps %xmm11, %xmm12 + addsd %xmm13, %xmm12 + movsd %xmm12, (%rdi) + subsd %xmm12, %xmm13 + movsd %xmm13, -32(%rsp) + addsd %xmm11, %xmm13 + movsd %xmm13, 8(%rdi) + movb 7(%rdi), %r8b + movb %r8b, %r9b + movb 15(%rdi), %r10b + movb %r10b, %r11b + shrb $7, %r8b + andb $127, %r9b + shrb $7, %r10b + movsd %xmm12, -40(%rsp) + xorb %sil, %r8b + xorb %sil, %r10b + shlb $7, %r8b + andb $127, %r11b + shlb $7, %r10b + orb %r8b, %r9b + orb %r10b, %r11b + movb %r9b, 7(%rdi) + movb %r11b, 15(%rdi) + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.26: + lea 1952+_dAtan2Tab(%rip), %rax + lea 1960+_dAtan2Tab(%rip), %rdx + movq (%rax), %rcx + xorl %eax, %eax + movq (%rdx), %r9 + movq %rcx, (%rdi) + movq %r9, 8(%rdi) + shrq $56, %rcx + shrq $56, %r9 + movb %cl, %r8b + shrb $7, %cl + movb %r9b, %r10b + shrb $7, %r9b + xorb %sil, %cl + xorb %sil, %r9b + shlb $7, %cl + andb $127, %r8b + shlb $7, %r9b + andb $127, %r10b + orb %cl, %r8b + orb %r9b, %r10b + movb %r8b, 7(%rdi) + movb %r10b, 15(%rdi) + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.27: + testl %r11d, %r11d + jne ..B1.23 +..B1.28: + testl $1048575, 4(%r9) + jne ..B1.23 + jmp ..B1.57 +..B1.29: + jne ..B1.23 +..B1.31: + testb %dl, %dl + jne ..B1.26 +..B1.32: + lea 1992+_dAtan2Tab(%rip), %rax + movq (%rax), %rdx + xorl %eax, %eax + movq %rdx, (%rdi) + movq %rdx, 8(%rdi) + shrq $56, %rdx + movb %dl, %cl + shrb $7, %dl + andb $127, %cl + xorb %sil, %dl + shlb $7, %dl + orb %dl, %cl + movb %cl, 7(%rdi) + movb %cl, 15(%rdi) + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.34: + je ..B1.51 +..B1.56: + cmpl $2047, %r10d +..B1.35: + je ..B1.48 +..B1.36: + jl ..B1.23 +..B1.38: + cmpl $2047, %r11d + jge ..B1.42 +..B1.39: + testb %dl, %dl + je ..B1.32 + jmp ..B1.26 +..B1.42: + testb %dl, %dl + jne ..B1.44 +..B1.43: + lea 1920+_dAtan2Tab(%rip), %rax + lea 1928+_dAtan2Tab(%rip), %rdx + movq (%rax), %rcx + xorl %eax, %eax + movq (%rdx), %r9 + movq %rcx, (%rdi) + movq %r9, 8(%rdi) + shrq $56, %rcx + shrq $56, %r9 + movb %cl, %r8b + shrb $7, %cl + movb %r9b, %r10b + shrb $7, %r9b + xorb %sil, %cl + xorb %sil, %r9b + shlb $7, %cl + andb $127, %r8b + shlb $7, %r9b + andb $127, %r10b + orb %cl, %r8b + orb %r9b, %r10b + movb %r8b, 7(%rdi) + movb %r10b, 15(%rdi) + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.44: + lea 1968+_dAtan2Tab(%rip), %rax + lea 1976+_dAtan2Tab(%rip), %rdx + movq (%rax), %rcx + xorl %eax, %eax + movq (%rdx), %r9 + movq %rcx, (%rdi) + movq %r9, 8(%rdi) + shrq $56, %rcx + shrq $56, %r9 + movb %cl, %r8b + shrb $7, %cl + movb %r9b, %r10b + shrb $7, %r9b + xorb %sil, %cl + xorb %sil, %r9b + shlb $7, %cl + andb $127, %r8b + shlb $7, %r9b + andb $127, %r10b + orb %cl, %r8b + orb %r9b, %r10b + movb %r8b, 7(%rdi) + movb %r10b, 15(%rdi) +..B1.45: + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.46: + lea 2000+_dAtan2Tab(%rip), %rax + movl $-1022, %r8d + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm9 + movsd %xmm2, -16(%rsp) + jmp ..B1.13 +..B1.47: + lea 2000+_dAtan2Tab(%rip), %rax + movaps %xmm4, %xmm0 + movl $-1022, %r9d + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm6 + movsd %xmm0, -24(%rsp) + jmp ..B1.11 +..B1.48: + testl $1048575, 4(%rax) + jne ..B1.50 +..B1.49: + cmpl $0, (%rax) + je ..B1.38 +..B1.50: + movsd (%r9), %xmm0 + addsd (%rax), %xmm0 + lea 1992+_dAtan2Tab(%rip), %rax + movq (%rax), %rdx + xorl %eax, %eax + movsd %xmm0, (%rdi) + movq %rdx, 8(%rdi) + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 +..B1.51: + testl $1048575, 4(%r9) + jne ..B1.50 +..B1.52: + cmpl $0, (%r9) + jne ..B1.50 +..B1.55: + cmpl $2047, %r10d + je ..B1.48 + jmp ..B1.36 +..B1.57: + cmpl $0, (%r9) + jne ..B1.23 + jmp ..B1.31 + .align 16,0x90 + .cfi_endproc + .type __libm_atan2_k64,@function + .size __libm_atan2_k64,.-__libm_atan2_k64 + .data +# -- End __libm_atan2_k64 + .section .rodata, "a" + .align 16 + .align 16 +_dAtan2Tab: + .long 3892314112 + .long 1069799150 + .long 2332892550 + .long 1039715405 + .long 1342177280 + .long 1070305495 + .long 270726690 + .long 1041535749 + .long 939524096 + .long 1070817911 + .long 2253973841 + .long 3188654726 + .long 3221225472 + .long 1071277294 + .long 3853927037 + .long 1043226911 + .long 2818572288 + .long 1071767563 + .long 2677759107 + .long 1044314101 + .long 3355443200 + .long 1072103591 + .long 1636578514 + .long 3191094734 + .long 1476395008 + .long 1072475260 + .long 1864703685 + .long 3188646936 + .long 805306368 + .long 1072747407 + .long 192551812 + .long 3192726267 + .long 2013265920 + .long 1072892781 + .long 2240369452 + .long 1043768538 + .long 0 + .long 1072999953 + .long 3665168337 + .long 3192705970 + .long 402653184 + .long 1073084787 + .long 1227953434 + .long 3192313277 + .long 2013265920 + .long 1073142981 + .long 3853283127 + .long 1045277487 + .long 805306368 + .long 1073187261 + .long 1676192264 + .long 3192868861 + .long 134217728 + .long 1073217000 + .long 4290763938 + .long 1042034855 + .long 671088640 + .long 1073239386 + .long 994303084 + .long 3189643768 + .long 402653184 + .long 1073254338 + .long 1878067156 + .long 1042652475 + .long 1610612736 + .long 1073265562 + .long 670314820 + .long 1045138554 + .long 3221225472 + .long 1073273048 + .long 691126919 + .long 3189987794 + .long 3489660928 + .long 1073278664 + .long 1618990832 + .long 3188194509 + .long 1207959552 + .long 1073282409 + .long 2198872939 + .long 1044806069 + .long 3489660928 + .long 1073285217 + .long 2633982383 + .long 1042307894 + .long 939524096 + .long 1073287090 + .long 1059367786 + .long 3189114230 + .long 2281701376 + .long 1073288494 + .long 3158525533 + .long 1044484961 + .long 3221225472 + .long 1073289430 + .long 286581777 + .long 1044893263 + .long 4026531840 + .long 1073290132 + .long 2000245215 + .long 3191647611 + .long 134217728 + .long 1073290601 + .long 4205071590 + .long 1045035927 + .long 536870912 + .long 1073290952 + .long 2334392229 + .long 1043447393 + .long 805306368 + .long 1073291186 + .long 2281458177 + .long 3188885569 + .long 3087007744 + .long 1073291361 + .long 691611507 + .long 1044733832 + .long 3221225472 + .long 1073291478 + .long 1816229550 + .long 1044363390 + .long 2281701376 + .long 1073291566 + .long 1993843750 + .long 3189837440 + .long 134217728 + .long 1073291625 + .long 3654754496 + .long 1044970837 + .long 4026531840 + .long 1073291668 + .long 3224300229 + .long 3191935390 + .long 805306368 + .long 1073291698 + .long 2988777976 + .long 3188950659 + .long 536870912 + .long 1073291720 + .long 1030371341 + .long 1043402665 + .long 3221225472 + .long 1073291734 + .long 1524463765 + .long 1044361356 + .long 3087007744 + .long 1073291745 + .long 2754295320 + .long 1044731036 + .long 134217728 + .long 1073291753 + .long 3099629057 + .long 1044970710 + .long 2281701376 + .long 1073291758 + .long 962914160 + .long 3189838838 + .long 805306368 + .long 1073291762 + .long 3543908206 + .long 3188950786 + .long 4026531840 + .long 1073291764 + .long 1849909620 + .long 3191935434 + .long 3221225472 + .long 1073291766 + .long 1641333636 + .long 1044361352 + .long 536870912 + .long 1073291768 + .long 1373968792 + .long 1043402654 + .long 134217728 + .long 1073291769 + .long 2033191599 + .long 1044970710 + .long 3087007744 + .long 1073291769 + .long 4117947437 + .long 1044731035 + .long 805306368 + .long 1073291770 + .long 315378368 + .long 3188950787 + .long 2281701376 + .long 1073291770 + .long 2428571750 + .long 3189838838 + .long 3221225472 + .long 1073291770 + .long 1608007466 + .long 1044361352 + .long 4026531840 + .long 1073291770 + .long 1895711420 + .long 3191935434 + .long 134217728 + .long 1073291771 + .long 2031108713 + .long 1044970710 + .long 536870912 + .long 1073291771 + .long 1362518342 + .long 1043402654 + .long 805306368 + .long 1073291771 + .long 317461253 + .long 3188950787 + .long 939524096 + .long 1073291771 + .long 4117231784 + .long 1044731035 + .long 1073741824 + .long 1073291771 + .long 1607942376 + .long 1044361352 + .long 1207959552 + .long 1073291771 + .long 2428929577 + .long 3189838838 + .long 1207959552 + .long 1073291771 + .long 2031104645 + .long 1044970710 + .long 1342177280 + .long 1073291771 + .long 1895722602 + .long 3191935434 + .long 1342177280 + .long 1073291771 + .long 317465322 + .long 3188950787 + .long 1342177280 + .long 1073291771 + .long 1362515546 + .long 1043402654 + .long 1342177280 + .long 1073291771 + .long 1607942248 + .long 1044361352 + .long 1342177280 + .long 1073291771 + .long 4117231610 + .long 1044731035 + .long 1342177280 + .long 1073291771 + .long 2031104637 + .long 1044970710 + .long 1342177280 + .long 1073291771 + .long 1540251232 + .long 1045150466 + .long 1342177280 + .long 1073291771 + .long 2644671394 + .long 1045270303 + .long 1342177280 + .long 1073291771 + .long 2399244691 + .long 1045360181 + .long 1342177280 + .long 1073291771 + .long 803971124 + .long 1045420100 + .long 1476395008 + .long 1073291771 + .long 3613709523 + .long 3192879152 + .long 1476395008 + .long 1073291771 + .long 2263862659 + .long 3192849193 + .long 1476395008 + .long 1073291771 + .long 177735686 + .long 3192826724 + .long 1476395008 + .long 1073291771 + .long 1650295902 + .long 3192811744 + .long 1476395008 + .long 1073291771 + .long 2754716064 + .long 3192800509 + .long 1476395008 + .long 1073291771 + .long 3490996172 + .long 3192793019 + .long 1476395008 + .long 1073291771 + .long 1895722605 + .long 3192787402 + .long 1476395008 + .long 1073291771 + .long 2263862659 + .long 3192783657 + .long 1476395008 + .long 1073291771 + .long 3613709523 + .long 3192780848 + .long 1476395008 + .long 1073291771 + .long 1650295902 + .long 3192778976 + .long 1476395008 + .long 1073291771 + .long 177735686 + .long 3192777572 + .long 1476395008 + .long 1073291771 + .long 3490996172 + .long 3192776635 + .long 1476395008 + .long 1073291771 + .long 2754716064 + .long 3192775933 + .long 1476395008 + .long 1073291771 + .long 2263862659 + .long 3192775465 + .long 1476395008 + .long 1073291771 + .long 1895722605 + .long 3192775114 + .long 1476395008 + .long 1073291771 + .long 1650295902 + .long 3192774880 + .long 1476395008 + .long 1073291771 + .long 3613709523 + .long 3192774704 + .long 1476395008 + .long 1073291771 + .long 3490996172 + .long 3192774587 + .long 1476395008 + .long 1073291771 + .long 177735686 + .long 3192774500 + .long 1476395008 + .long 1073291771 + .long 2263862659 + .long 3192774441 + .long 1476395008 + .long 1073291771 + .long 2754716064 + .long 3192774397 + .long 1476395008 + .long 1073291771 + .long 1650295902 + .long 3192774368 + .long 1476395008 + .long 1073291771 + .long 1895722605 + .long 3192774346 + .long 1476395008 + .long 1073291771 + .long 3490996172 + .long 3192774331 + .long 1476395008 + .long 1073291771 + .long 3613709523 + .long 3192774320 + .long 1476395008 + .long 1073291771 + .long 2263862659 + .long 3192774313 + .long 1476395008 + .long 1073291771 + .long 177735686 + .long 3192774308 + .long 1476395008 + .long 1073291771 + .long 1650295902 + .long 3192774304 + .long 1476395008 + .long 1073291771 + .long 2754716064 + .long 3192774301 + .long 1476395008 + .long 1073291771 + .long 3490996172 + .long 3192774299 + .long 1476395008 + .long 1073291771 + .long 1895722605 + .long 3192774298 + .long 1476395008 + .long 1073291771 + .long 2263862659 + .long 3192774297 + .long 1476395008 + .long 1073291771 + .long 3613709523 + .long 3192774296 + .long 1476395008 + .long 1073291771 + .long 1650295902 + .long 3192774296 + .long 1476395008 + .long 1073291771 + .long 177735686 + .long 3192774296 + .long 1476395008 + .long 1073291771 + .long 3490996172 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 2754716064 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 2263862659 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1895722605 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1650295902 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1466225875 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1343512524 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1251477510 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1190120835 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1144103328 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1113424990 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1090416237 + .long 3192774295 + .long 1476395008 + .long 1073291771 + .long 1075077068 + .long 3192774295 + .long 1431655765 + .long 3218429269 + .long 2576978363 + .long 1070176665 + .long 2453154343 + .long 3217180964 + .long 4189149139 + .long 1069314502 + .long 1775019125 + .long 3216459198 + .long 273199057 + .long 1068739452 + .long 874748308 + .long 3215993277 + .long 0 + .long 1069547520 + .long 0 + .long 1072693248 + .long 0 + .long 1073741824 + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .long 1413754136 + .long 1072243195 + .long 856972295 + .long 1015129638 + .long 1413754136 + .long 1073291771 + .long 856972295 + .long 1016178214 + .long 1413754136 + .long 1074340347 + .long 856972295 + .long 1017226790 + .long 2134057426 + .long 1073928572 + .long 1285458442 + .long 1016756537 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 2144337920 + .long 0 + .long 1048576 + .long 33554432 + .long 1101004800 + .type _dAtan2Tab,@object + .size _dAtan2Tab,2024 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_atan2l_k80.S b/external/sgx_libm/intel64/libm_atan2l_k80.S new file mode 100644 index 0000000000..65952a4d34 --- /dev/null +++ b/external/sgx_libm/intel64/libm_atan2l_k80.S @@ -0,0 +1,1835 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_atan2l_k80.c" + .text +..TXTST0: +# -- Begin __libm_atan2l_k80 + .text + .align 16,0x90 + .globl __libm_atan2l_k80 +__libm_atan2l_k80: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +..B1.1: + .cfi_startproc +..___tag_value___libm_atan2l_k80.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $224, %rsp + .cfi_def_cfa_offset 272 + movq %rdi, %r15 + movb 9(%rsi), %cl + andb $-128, %cl + shrb $7, %cl + movzbl 9(%rdx), %r14d + movzwl 8(%rsi), %ebp + andl $128, %r14d + andl $32767, %ebp + movq %fs:40, %rax + movzbl %cl, %ebx + xorq %rsp, %rax + movzwl 8(%rdx), %ecx + shrl $7, %r14d + andl $32767, %ecx + movq %rax, 208(%rsp) + cmpl $32767, %ebp + je ..B1.104 +..B1.2: + cmpl $32767, %ecx + je ..B1.92 +..B1.3: + cmpq $0, (%rsi) + jne ..B1.11 +..B1.4: + cmpq $0, (%rdx) + jne ..B1.8 +..B1.5: + movl $0, 32(%r15) + testl %r14d, %r14d + je ..B1.7 +..B1.6: + shlq $4, %rbx + lea _pilo_00l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_00l(%rip), %rax + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + jmp ..B1.13 +..B1.7: + shlq $4, %rbx + lea zeros(%rip), %rax + lea ones(%rip), %rdx + fldt (%rax) + fstpt 16(%r15) + fldt 16(%r15) + fldt (%rdx,%rbx) + fmulp %st, %st(1) + fstpt (%r15) + jmp ..B1.13 +..B1.8: + movl $0, 32(%r15) + testl %r14d, %r14d + je ..B1.10 +..B1.9: + shlq $4, %rbx + lea _pilo_00l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_00l(%rip), %rax + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + jmp ..B1.13 +..B1.10: + shlq $4, %rbx + lea zeros(%rip), %rax + lea ones(%rip), %rdx + fldt (%rax) + fstpt 16(%r15) + fldt 16(%r15) + fldt (%rdx,%rbx) + fmulp %st, %st(1) + fstpt (%r15) + jmp ..B1.13 +..B1.11: + cmpq $0, (%rdx) + jne ..B1.15 +..B1.12: + shlq $4, %rbx + lea _pilo_02l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_02l(%rip), %rax + movl $0, 32(%r15) + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) +..B1.13: + movq 208(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.84 +..B1.14: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.15: + movq (%rdx), %rax + lea 112(%rsp), %rbp + movq 8(%rdx), %rcx + movq %rbp, %rdi + movq 16(%rdx), %r8 + movq 24(%rdx), %r9 + movq 32(%rdx), %r10 + movq 40(%rdx), %rdx + movq %rax, (%rbp) + movq %rcx, 8(%rbp) + movq %rdx, 40(%rbp) + movq (%rsi), %r11 + movq 8(%rsi), %r13 + movq 16(%rsi), %rax + movq 24(%rsi), %rdx + movq 32(%rsi), %rcx + movq 40(%rsi), %rsi + movq %r8, 16(%rbp) + movq %r9, 24(%rbp) + movq %r10, 32(%rbp) + movq %r11, 48(%rbp) + movq %r13, 56(%rbp) + movq %rax, 64(%rbp) + movq %rdx, 72(%rbp) + movq %rcx, 80(%rbp) + movq %rsi, 88(%rbp) +..___tag_value___libm_atan2l_k80.31: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.32: +..B1.16: + lea 160(%rsp), %rdi +..___tag_value___libm_atan2l_k80.33: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.34: +..B1.17: + fldt 112(%rsp) + movq %rbx, %rdx + fld %st(0) + lea ones(%rip), %r13 + fldt 128(%rsp) + movl %r14d, %eax + fadd %st, %st(1) + shlq $4, %rax + fxch %st(1) + fsub %st, %st(2) + shlq $4, %rdx + fxch %st(2) + fsubrp %st, %st(1) + fldt 160(%rsp) + fld %st(0) + fldt 176(%rsp) + movl 144(%rsp), %ecx + fadd %st, %st(1) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fldt (%rax,%r13) + fmul %st, %st(4) + fmulp %st, %st(3) + fldt (%rdx,%r13) + movl 192(%rsp), %eax + cmpl %eax, %ecx + fmul %st, %st(2) + fmul %st, %st(1) + jg ..B1.20 +..B1.18: + jne ..B1.70 +..B1.19: + fxch %st(4) + fcomi %st(2), %st + fxch %st(4) + jbe ..B1.70 +..B1.20: + lea 12(%rax), %edx + cmpl %edx, %ecx + jle ..B1.65 +..B1.21: + lea 75(%rax), %edx + cmpl %edx, %ecx + jle ..B1.38 +..B1.22: + testl %r14d, %r14d + je ..B1.24 +..B1.23: + fstp %st(0) + fstp %st(2) + fstp %st(1) + fstp %st(0) + fstp %st(0) + shlq $4, %rbx + lea _pilo_00l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_00l(%rip), %rax + movl $0, 32(%r15) + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + jmp ..B1.36 +..B1.24: + fxch %st(2) + fstpt 160(%rsp) + fldt 160(%rsp) + movzwl 168(%rsp), %edx + andl $32767, %edx + fxch %st(4) + fstpt 112(%rsp) + fldt 112(%rsp) + cmpl $8383, %edx + jge ..B1.26 +..B1.25: + fstp %st(4) + fstp %st(3) + fxch %st(2) + fstpt 176(%rsp) + fstpt 128(%rsp) + jmp ..B1.32 +..B1.26: + cmpl $24383, %edx + jg ..B1.25 +..B1.28: + movzwl 120(%rsp), %edx + andl $32767, %edx + cmpl $8383, %edx + jl ..B1.25 +..B1.30: + cmpl $24383, %edx + fxch %st(3) + fxch %st(2) + fxch %st(4) + fxch %st(1) + jle ..B1.35 +..B1.31: + fstp %st(1) + fstp %st(2) + fxch %st(1) + fstpt 176(%rsp) + fstpt 128(%rsp) +..B1.32: + fstpt 64(%rsp) + lea 160(%rsp), %rdi +..___tag_value___libm_atan2l_k80.35: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.36: +..B1.33: + fldt 64(%rsp) + movq %rbp, %rdi + fstpt 64(%rsp) +..___tag_value___libm_atan2l_k80.37: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.38: +..B1.34: + fldt 64(%rsp) + fldt 112(%rsp) + fldt 128(%rsp) + fldt 160(%rsp) + fldt 176(%rsp) + movl 144(%rsp), %ecx + movl 192(%rsp), %eax +..B1.35: + fld %st(1) + subl %ecx, %eax + fdiv %st(4), %st + lea _small_value_80(%rip), %rdx + movl %eax, 32(%r15) + lea t32(%rip), %rax + fstpt 16(%rsp) + fldt 16(%rsp) + fxch %st(5) + fstpt 64(%rsp) + fxch %st(3) + fstpt (%rsp) + fldt (%rsp) + fldt (%rax) + fld %st(0) + fmul %st(6), %st + fld %st(0) + fsubr %st(7), %st + faddp %st, %st(1) + fld %st(0) + fsubrp %st, %st(7) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fsub %st(1), %st + faddp %st, %st(1) + fsubr %st, %st(2) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(7), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(6) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(5) + fsubrp %st, %st(1) + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(0) + fldt (%rsp) + fdivrp %st, %st(3) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 64(%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt (%r15) + fmulp %st, %st(1) + fstpt 16(%r15) + fldt (%r13) + fldt (%rdx) + faddp %st, %st(1) + fstpt 32(%rsp) +..B1.36: + movq 208(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.84 +..B1.37: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.38: + fldt (%r13) + subl %ecx, %eax + movzwl 8(%r13), %ebx + movl %ebx, %edx + addl $16383, %eax + andl $-32768, %edx + andl $32767, %eax + xorl %ecx, %ecx + fstpt 96(%rsp) + fldt 96(%rsp) + orl %eax, %edx + movw %dx, 104(%rsp) + xorl %edx, %edx + fxch %st(5) + fstpt 112(%rsp) + fldt 112(%rsp) + xorl %esi, %esi + fxch %st(5) + fstpt 48(%rsp) + fldt 96(%rsp) + fmul %st, %st(3) + fxch %st(3) + fstpt 160(%rsp) + fldt 160(%rsp) + movzwl 168(%rsp), %eax + andl $32767, %eax + fxch %st(3) + fmulp %st, %st(2) + testl %r14d, %r14d + je ..B1.52 +..B1.39: + cmpl $8383, %eax + jge ..B1.41 +..B1.40: + fstp %st(2) + fstp %st(3) + movl %edx, 192(%rsp) + movl %edx, 144(%rsp) + fxch %st(2) + fstpt 176(%rsp) + fstpt 128(%rsp) + jmp ..B1.47 +..B1.41: + cmpl $24383, %eax + jg ..B1.40 +..B1.43: + movzwl 120(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.40 +..B1.45: + cmpl $24383, %eax + fxch %st(4) + fxch %st(3) + fxch %st(2) + fxch %st(1) + jle ..B1.50 +..B1.46: + fstp %st(1) + fstp %st(2) + movl %edx, 192(%rsp) + movl %edx, 144(%rsp) + fxch %st(1) + fstpt 176(%rsp) + fstpt 128(%rsp) +..B1.47: + fstpt 64(%rsp) + lea 160(%rsp), %rdi +..___tag_value___libm_atan2l_k80.56: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.57: +..B1.48: + fldt 64(%rsp) + movq %rbp, %rdi + fstpt 64(%rsp) +..___tag_value___libm_atan2l_k80.58: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.59: +..B1.49: + fldt 64(%rsp) + fldt 112(%rsp) + fldt 128(%rsp) + fldt 160(%rsp) + fldt 176(%rsp) + movl 144(%rsp), %ecx + movl 192(%rsp), %esi +..B1.50: + fld %st(1) + lea t32(%rip), %rax + fdiv %st(4), %st + subl %ecx, %esi + fstpt 16(%rsp) + fldt 16(%rsp) + addl $16383, %esi + fxch %st(5) + fstpt 64(%rsp) + andl $-32768, %ebx + fxch %st(3) + fstpt (%rsp) + fldt (%rsp) + andl $32767, %esi + fldt (%rax) + orl %esi, %ebx + fld %st(0) + lea 48+_P(%rip), %rdx + fmul %st(6), %st + lea 16+_P(%rip), %rcx + fld %st(0) + lea _P(%rip), %rbp + movq __libm_atanl_table_128@GOTPCREL(%rip), %rsi + fsubr %st(7), %st + faddp %st, %st(1) + fld %st(0) + fsubrp %st, %st(7) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fsub %st(1), %st + faddp %st, %st(1) + fsubr %st, %st(2) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(7), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(6) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(5) + fsubrp %st, %st(1) + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fldt (%rsp) + fdivrp %st, %st(2) + faddp %st, %st(1) + fldt 48(%rsp) + fstpt 96(%rsp) + fldt (%rdx) + fldt (%rcx) + fldt (%rbp) + movw %bx, 104(%rsp) + lea 32+_P(%rip), %rbx + fldt 96(%rsp) + fmulp %st, %st(4) + fld %st(3) + fmul %st(4), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(4) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt (%rbx) + fmulp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fldl 8192(%rsi) + fldl 8200(%rsi) + movl $0, 32(%r15) + fsubp %st, %st(2) + fldt 64(%rsp) + fmul %st, %st(1) + fld %st(1) + fxch %st(1) + fmulp %st, %st(3) + fadd %st(2), %st + fstpt (%r15) + fldt (%r15) + fsubp %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%r15) + movq 208(%rsp), %rdi + xorq %rsp, %rdi + cmpq %fs:40, %rdi + jne ..B1.84 +..B1.51: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.52: + cmpl $8383, %eax + jge ..B1.54 +..B1.53: + fstp %st(2) + fstp %st(3) + movl %edx, 192(%rsp) + movl %edx, 144(%rsp) + fxch %st(2) + fstpt 176(%rsp) + fstpt 128(%rsp) + jmp ..B1.60 +..B1.54: + cmpl $24383, %eax + jg ..B1.53 +..B1.56: + movzwl 120(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.53 +..B1.58: + cmpl $24383, %eax + fxch %st(4) + fxch %st(3) + fxch %st(2) + fxch %st(1) + jle ..B1.63 +..B1.59: + fstp %st(1) + fstp %st(2) + movl %edx, 192(%rsp) + movl %edx, 144(%rsp) + fxch %st(1) + fstpt 176(%rsp) + fstpt 128(%rsp) +..B1.60: + fstpt 64(%rsp) + lea 160(%rsp), %rdi +..___tag_value___libm_atan2l_k80.77: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.78: +..B1.61: + fldt 64(%rsp) + movq %rbp, %rdi + fstpt 64(%rsp) +..___tag_value___libm_atan2l_k80.79: + call __libm_normalizel_k80@PLT +..___tag_value___libm_atan2l_k80.80: +..B1.62: + fldt 64(%rsp) + fldt 112(%rsp) + fldt 128(%rsp) + fldt 160(%rsp) + fldt 176(%rsp) + movl 144(%rsp), %ecx + movl 192(%rsp), %esi +..B1.63: + fld %st(1) + lea t32(%rip), %rax + fdiv %st(4), %st + subl %ecx, %esi + fstpt 16(%rsp) + fldt 16(%rsp) + addl $16383, %esi + fxch %st(5) + fstpt 64(%rsp) + andl $-32768, %ebx + fxch %st(3) + fstpt (%rsp) + fldt (%rsp) + andl $32767, %esi + fldt (%rax) + orl %esi, %ebx + fld %st(0) + lea 48+_P(%rip), %rdx + fmul %st(6), %st + lea 16+_P(%rip), %rcx + fld %st(0) + lea _P(%rip), %rbp + movl $0, 32(%r15) + fsubr %st(7), %st + faddp %st, %st(1) + fld %st(0) + fsubrp %st, %st(7) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fsub %st(1), %st + faddp %st, %st(1) + fsubr %st, %st(2) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fmul %st(7), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(6) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(5) + fsubrp %st, %st(1) + fsubp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fldt (%rsp) + fdivrp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt 48(%rsp) + fstpt 96(%rsp) + fldt (%rdx) + fldt (%rcx) + fldt (%rbp) + movw %bx, 104(%rsp) + lea 32+_P(%rip), %rbx + fldt 96(%rsp) + fmul %st, %st(4) + fmul %st, %st(4) + fld %st(4) + fmul %st(5), %st + fld %st(0) + fmul %st(1), %st + fmul %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(1) + fmul %st, %st(6) + fmulp %st, %st(6) + fxch %st(4) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt (%rbx) + fmulp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(2) + fldt 64(%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt (%r15) + fmulp %st, %st(1) + fstpt 16(%r15) + movq 208(%rsp), %rsi + xorq %rsp, %rsi + cmpq %fs:40, %rsi + jne ..B1.84 +..B1.64: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.65: + fldt (%r13) + subl %ecx, %eax + addl $16383, %eax + lea _TWO_63H(%rip), %rcx + movzwl 8(%r13), %edx + andl $32767, %eax + andl $-32768, %edx + lea _TWO_48H(%rip), %rbx + fstpt 96(%rsp) + fldt 96(%rsp) + orl %eax, %edx + movw %dx, 104(%rsp) + fld %st(5) + fxch %st(1) + fstpt (%rsp) + lea 16+ones(%rip), %rbp + fxch %st(1) + fstpt 64(%rsp) + lea 48+_P(%rip), %rsi + fxch %st(4) + fstpt 112(%rsp) + fldt 112(%rsp) + lea 32+_P(%rip), %r8 + fxch %st(3) + fstpt 128(%rsp) + fldt 128(%rsp) + lea 16+_P(%rip), %rdi + fldt 96(%rsp) + lea _P(%rip), %r9 + fmul %st, %st(3) + xorl %eax, %eax + fxch %st(3) + fstpt 160(%rsp) + fldt 160(%rsp) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + fldt .L_2il0floatpacket.11(%rip) + fmul %st(3), %st + fdiv %st(4), %st + fldt .L_2il0floatpacket.12(%rip) + movl %eax, 144(%rsp) + movl %eax, 192(%rsp) + fxch %st(1) + faddl (%rcx) + fstpt 80(%rsp) + fldt 80(%rsp) + fldl (%rbx) + movslq 80(%rsp), %rdx + shlq $4, %rdx + fxch %st(1) + fsubl (%rcx) + fmulp %st, %st(2) + fld %st(5) + fmul %st(1), %st + testl %r14d, %r14d + fadd %st, %st(7) + fxch %st(7) + fstpt 80(%rsp) + fldt 80(%rsp) + fsubp %st, %st(7) + fxch %st(5) + fsub %st(6), %st + faddp %st, %st(3) + fld %st(4) + fmul %st(4), %st + fld %st(0) + fadd %st(5), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fsubp %st, %st(1) + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fld %st(3) + fmul %st(1), %st + fadd %st(3), %st + fld %st(2) + fmul %st(2), %st + fadd %st(7), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + fsubrp %st, %st(5) + fxch %st(3) + fmulp %st, %st(6) + fxch %st(5) + fsubrp %st, %st(1) + fld %st(4) + fadd %st(2), %st + fldt (%rsp) + fdivp %st, %st(1) + fmul %st, %st(4) + fld %st(4) + fadd %st(1), %st + fstpt 80(%rsp) + fxch %st(4) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(2) + fmul %st(4), %st + fldt 80(%rsp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(5), %st + fld %st(6) + fmul %st(1), %st + faddp %st, %st(2) + fxch %st(3) + fmul %st, %st(6) + fldt (%rbp) + faddp %st, %st(7) + fxch %st(1) + faddp %st, %st(6) + fxch %st(5) + fmulp %st, %st(4) + fxch %st(3) + fsubrp %st, %st(1) + fld %st(3) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fld %st(1) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(2) + fmul %st(3), %st + fxch %st(2) + fadd %st(3), %st + fld %st(1) + fmul %st(1), %st + faddp %st, %st(3) + fld %st(3) + fmul %st(4), %st + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fldt (%rsi) + fmul %st(1), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + fmulp %st, %st(2) + fldt (%r9) + faddp %st, %st(2) + fxch %st(4) + fmulp %st, %st(1) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 64(%rsp) + je ..B1.67 +..B1.66: + negq %rdx + fld %st(2) + movq __libm_atanl_table_128@GOTPCREL(%rip), %rax + fldl 8192(%rax,%rdx) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fxch %st(3) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl 8200(%rax,%rdx) + fsubp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.68 +..B1.67: + movq __libm_atanl_table_128@GOTPCREL(%rip), %rax + fld %st(2) + fldl (%rdx,%rax) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(3) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl 8(%rdx,%rax) + faddp %st, %st(3) + faddp %st, %st(2) +..B1.68: + fmul %st, %st(2) + fld %st(2) + fxch %st(2) + fmulp %st, %st(1) + movl $0, 32(%r15) + fadd %st, %st(1) + fxch %st(1) + fstpt (%r15) + fldt (%r15) + fsubp %st, %st(2) + fsubp %st, %st(1) + fstpt 16(%r15) + movq 208(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.84 +..B1.69: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.70: + lea 12(%rcx), %edx + cmpl %edx, %eax + jle ..B1.79 +..B1.71: + fstp %st(3) + fstp %st(0) + lea 75(%rcx), %edx + cmpl %edx, %eax + jg ..B1.77 +..B1.72: + fldt (%r13) + subl %ecx, %eax + addl $16383, %eax + lea 32+_P(%rip), %rbx + movzwl 8(%r13), %edx + andl $32767, %eax + andl $-32768, %edx + lea 16+_P(%rip), %rcx + fstpt 96(%rsp) + orl %eax, %edx + movw %dx, 104(%rsp) + lea 48+_P(%rip), %rax + fldt 96(%rsp) + lea _P(%rip), %rbp + fmulp %st, %st(1) + testl %r14d, %r14d + fdivrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fmul %st(1), %st + fldt (%rax) + fmul %st(1), %st + fldt (%rcx) + movq __libm_atanl_table_128@GOTPCREL(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rbx) + fmulp %st, %st(2) + fldt (%rbp) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(2) + fldl 4096(%rsi) + fmul %st(1), %st + fldl 4104(%rsi) + movl $0, 32(%r15) + je ..B1.74 +..B1.73: + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + jmp ..B1.75 +..B1.74: + fsubp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) +..B1.75: + fld %st(0) + fadd %st(2), %st + fstpt (%r15) + fldt (%r15) + fsubp %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%r15) + movq 208(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.84 +..B1.76: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.77: + fstp %st(1) + fstp %st(0) + fstp %st(0) + shlq $4, %rbx + lea _pilo_02l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_02l(%rip), %rax + movl $0, 32(%r15) + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + movq 208(%rsp), %rbx + xorq %rsp, %rbx + cmpq %fs:40, %rbx + jne ..B1.84 +..B1.78: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.79: + fldt (%r13) + subl %ecx, %eax + addl $16383, %eax + lea _TWO_63H(%rip), %rcx + movzwl 8(%r13), %edx + andl $32767, %eax + andl $-32768, %edx + lea _TWO_48H(%rip), %rbx + fstpt 96(%rsp) + fldt 96(%rsp) + orl %eax, %edx + movw %dx, 104(%rsp) + fld %st(5) + fxch %st(2) + fstpt 64(%rsp) + lea 16+ones(%rip), %rbp + fstpt (%rsp) + lea 48+_P(%rip), %rsi + fxch %st(4) + fstpt 112(%rsp) + fldt 112(%rsp) + lea 16+_P(%rip), %rdi + fxch %st(3) + fstpt 128(%rsp) + fldt 128(%rsp) + lea 32+_P(%rip), %r8 + fldt 96(%rsp) + lea _P(%rip), %r9 + fmul %st, %st(3) + xorl %eax, %eax + fxch %st(3) + fstpt 160(%rsp) + fldt 160(%rsp) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + fldt .L_2il0floatpacket.11(%rip) + fmul %st(4), %st + fdiv %st(3), %st + fldt .L_2il0floatpacket.12(%rip) + movl %eax, 144(%rsp) + movl %eax, 192(%rsp) + fxch %st(1) + faddl (%rcx) + fstpt 80(%rsp) + fld %st(4) + fldt 80(%rsp) + movslq 80(%rsp), %rdx + shlq $4, %rdx + fsubl (%rcx) + fmulp %st, %st(2) + testl %r14d, %r14d + fldl (%rbx) + fmul %st, %st(7) + fxch %st(1) + fadd %st(7), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fsubp %st, %st(7) + fxch %st(5) + fsub %st(6), %st + faddp %st, %st(3) + fld %st(4) + fmul %st(4), %st + fld %st(0) + fadd %st(5), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fsubp %st, %st(1) + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fld %st(5) + fmul %st(1), %st + fadd %st(2), %st + fstpt 16(%rsp) + fld %st(2) + fmul %st(1), %st + fadd %st(4), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fsubrp %st, %st(6) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + fldt 16(%rsp) + fadd %st(2), %st + fldt (%rsp) + fdivp %st, %st(1) + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fstpt 80(%rsp) + fxch %st(3) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(2) + fmul %st(3), %st + fldt 80(%rsp) + fsubp %st, %st(3) + fld %st(2) + fsubr %st(4), %st + fldt 16(%rsp) + fmul %st(1), %st + faddp %st, %st(2) + fldt 16(%rsp) + fmul %st(4), %st + fldt (%rbp) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fsubp %st, %st(3) + fld %st(1) + fmul %st(1), %st + fxch %st(1) + fadd %st(4), %st + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fld %st(2) + fxch %st(4) + fmulp %st, %st(2) + fmul %st(1), %st + fld %st(2) + fadd %st(2), %st + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fld %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fldt (%rsi) + fmul %st(1), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + fmulp %st, %st(2) + fldt (%r9) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 64(%rsp) + je ..B1.81 +..B1.80: + movq __libm_atanl_table_128@GOTPCREL(%rip), %rax + fld %st(2) + fldl 4096(%rax,%rdx) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(3) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl 4104(%rax,%rdx) + faddp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.82 +..B1.81: + negq %rdx + fld %st(2) + movq __libm_atanl_table_128@GOTPCREL(%rip), %rax + fldl 4096(%rax,%rdx) + fsub %st, %st(1) + fsub %st(1), %st + fsubp %st, %st(4) + fxch %st(3) + fstpt 96(%rsp) + fldt 96(%rsp) + fldl 4104(%rax,%rdx) + fsubp %st, %st(3) + faddp %st, %st(2) +..B1.82: + fmul %st, %st(2) + fld %st(2) + fxch %st(2) + fmulp %st, %st(1) + movl $0, 32(%r15) + fadd %st, %st(1) + fxch %st(1) + fstpt (%r15) + fldt (%r15) + fsubp %st, %st(2) + fsubp %st, %st(1) + fstpt 16(%r15) + movq 208(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.84 +..B1.83: + addq $224, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 272 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.84: + call __stack_chk_fail@PLT +..B1.92: + movq $0x8000000000000000, %rax + cmpq (%rdx), %rax + je ..B1.97 +..B1.93: + fldt (%rdx) + lea zeros(%rip), %rax + fldt (%rsi) + movl $0, 32(%r15) + fmulp %st, %st(1) + fstpt (%r15) + fldt (%rax) + fstpt 16(%r15) +..B1.94: + movq 208(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.84 + jmp ..B1.14 +..B1.97: + movl $0, 32(%r15) + cmpl $32767, %ebp + je ..B1.101 +..B1.98: + testl %r14d, %r14d + je ..B1.100 +..B1.99: + shlq $4, %rbx + lea _pilo_00l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_00l(%rip), %rax + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + jmp ..B1.94 +..B1.100: + shlq $4, %rbx + lea zeros(%rip), %rax + lea ones(%rip), %rdx + fldt (%rax) + fstpt 16(%r15) + fldt 16(%r15) + fldt (%rdx,%rbx) + fmulp %st, %st(1) + fstpt (%r15) + jmp ..B1.94 +..B1.101: + shlq $4, %rbx + testl %r14d, %r14d + je ..B1.103 +..B1.102: + lea _pilo_34l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_34l(%rip), %rax + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + jmp ..B1.94 +..B1.103: + lea _pilo_04l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_04l(%rip), %rax + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + jmp ..B1.94 +..B1.104: + movq $0x8000000000000000, %rax + cmpq (%rsi), %rax + jne ..B1.93 +..B1.105: + cmpl $32767, %ecx + je ..B1.92 +..B1.106: + shlq $4, %rbx + lea _pilo_02l(%rip), %rdx + lea _small_value_80(%rip), %rcx + lea _pi_02l(%rip), %rax + movl $0, 32(%r15) + fldt (%rbx,%rdx) + fldt (%rbx,%rax) + fstpt (%r15) + fldt (%rbx,%rcx) + fsubrp %st, %st(1) + fstpt 16(%r15) + jmp ..B1.94 + .align 16,0x90 + .cfi_endproc + .type __libm_atan2l_k80,@function + .size __libm_atan2l_k80,.-__libm_atan2l_k80 + .data +# -- End __libm_atan2l_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,16 + .align 16 +.L_2il0floatpacket.12: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xf8,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,16 + .align 16 +zeros: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type zeros,@object + .size zeros,32 + .align 16 +ones: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type ones,@object + .size ones,32 + .align 16 +t32: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type t32,@object + .size t32,32 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 2 +_pilo_00l: + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 16318 + .word 0 + .word 0 + .word 0 + .type _pilo_00l,@object + .size _pilo_00l,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_pi_00l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49152 + .word 0 + .word 0 + .word 0 + .type _pi_00l,@object + .size _pi_00l,32 + .align 2 +_pilo_02l: + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 16317 + .word 0 + .word 0 + .word 0 + .type _pilo_02l,@object + .size _pilo_02l,32 + .align 2 +_pi_02l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _pi_02l,@object + .size _pi_02l,32 + .align 2 +_P: + .word 43664 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 43235 + .word 52379 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59507 + .word 38278 + .word 9340 + .word 37449 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 9132 + .word 55602 + .word 8665 + .word 58245 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,64 + .align 2 +_pilo_34l: + .word 54470 + .word 48821 + .word 27694 + .word 55510 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 54470 + .word 48821 + .word 27694 + .word 55510 + .word 16319 + .word 0 + .word 0 + .word 0 + .type _pilo_34l,@object + .size _pilo_34l,32 + .align 2 +_pi_34l: + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 37288 + .word 39182 + .word 58361 + .word 38603 + .word 49152 + .word 0 + .word 0 + .word 0 + .type _pi_34l,@object + .size _pi_34l,32 + .align 2 +_pilo_04l: + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 16316 + .word 0 + .word 0 + .word 0 + .type _pilo_04l,@object + .size _pilo_04l,32 + .align 2 +_pi_04l: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 49150 + .word 0 + .word 0 + .word 0 + .type _pi_04l,@object + .size _pi_04l,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_cosh_k64.S b/external/sgx_libm/intel64/libm_cosh_k64.S new file mode 100644 index 0000000000..2926b29694 --- /dev/null +++ b/external/sgx_libm/intel64/libm_cosh_k64.S @@ -0,0 +1,341 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_cosh_k64.c" + .text +..TXTST0: +# -- Begin __libm_cosh_k64 + .text + .align 16,0x90 + .globl __libm_cosh_k64 +__libm_cosh_k64: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_cosh_k64.1: +..L2: + + movsd %xmm0, -32(%rsp) + movzwl -26(%rsp), %eax + andl $32752, %eax + cmpl $16720, %eax + jge ..B1.12 +..B1.2: + movl -28(%rsp), %edx + andl $2147483647, %edx + cmpl $1065646817, %edx + jae ..B1.7 +..B1.3: + cmpl $1012924416, %edx + jae ..B1.5 +..B1.4: + movq $0x3ff0000000000000, %rax + movq %rax, (%rdi) + movq $0, 8(%rdi) + jmp ..B1.6 +..B1.5: + movsd -32(%rsp), %xmm0 + movq $0x3ff0000000000000, %rax + mulsd %xmm0, %xmm0 + movaps %xmm0, %xmm1 + mulsd %xmm0, %xmm1 + movsd .L_2il0floatpacket.3(%rip), %xmm3 + mulsd %xmm1, %xmm3 + movsd .L_2il0floatpacket.5(%rip), %xmm2 + mulsd %xmm1, %xmm2 + addsd .L_2il0floatpacket.4(%rip), %xmm3 + mulsd %xmm0, %xmm3 + movsd %xmm0, -40(%rsp) + addsd %xmm2, %xmm3 + movq %rax, (%rdi) + movsd %xmm3, 8(%rdi) +..B1.6: + xorl %eax, %eax + ret +..B1.7: + movsd -32(%rsp), %xmm2 + lea _TWO_52(%rip), %rax + andps .L_2il0floatpacket.12(%rip), %xmm2 + movsd .L_2il0floatpacket.0(%rip), %xmm4 + mulsd %xmm2, %xmm4 + movsd (%rax), %xmm0 + movsd .L_2il0floatpacket.1(%rip), %xmm1 + addsd %xmm0, %xmm4 + movsd %xmm4, -40(%rsp) + subsd %xmm0, %xmm4 + mulsd %xmm4, %xmm1 + movsd %xmm2, -32(%rsp) + subsd %xmm1, %xmm2 + movsd .L_2il0floatpacket.2(%rip), %xmm3 + movaps %xmm2, %xmm6 + mulsd %xmm3, %xmm4 + movl -40(%rsp), %eax + movl %eax, %r8d + shll $25, %r8d + subsd %xmm4, %xmm6 + sarl $25, %r8d + subsd %xmm6, %xmm2 + subl %r8d, %eax + subsd %xmm4, %xmm2 + movsd .L_2il0floatpacket.11(%rip), %xmm1 + movaps %xmm2, %xmm0 + sarl $7, %eax + addsd %xmm6, %xmm0 + addsd %xmm6, %xmm1 + movzwl 6+.L_2il0floatpacket.11(%rip), %esi + cmpl $1077338037, %edx + jae ..B1.9 +..B1.8: + movaps %xmm0, %xmm7 + xorl %edx, %edx + mulsd %xmm0, %xmm7 + movaps %xmm6, %xmm9 + movsd .L_2il0floatpacket.7(%rip), %xmm8 + movl %eax, %ecx + mulsd %xmm7, %xmm8 + negl %ecx + movsd .L_2il0floatpacket.11(%rip), %xmm3 + addl $1023, %ecx + movsd %xmm1, -32(%rsp) + subl %eax, %ecx + movl %edx, -32(%rsp) + andl $2047, %ecx + movsd -32(%rsp), %xmm10 + andl $-32753, %esi + movsd .L_2il0floatpacket.6(%rip), %xmm4 + decl %eax + movsd .L_2il0floatpacket.6(%rip), %xmm5 + subsd %xmm6, %xmm3 + addsd .L_2il0floatpacket.8(%rip), %xmm8 + addsd %xmm10, %xmm4 + mulsd %xmm7, %xmm8 + subsd %xmm4, %xmm9 + mulsd %xmm0, %xmm8 + addsd %xmm2, %xmm9 + movsd .L_2il0floatpacket.9(%rip), %xmm0 + addsd %xmm8, %xmm9 + mulsd %xmm7, %xmm0 + movsd %xmm3, -24(%rsp) + movl %edx, -24(%rsp) + movsd -24(%rsp), %xmm1 + movslq %r8d, %r8 + addsd .L_2il0floatpacket.10(%rip), %xmm0 + addsd %xmm1, %xmm5 + mulsd %xmm7, %xmm0 + addsd %xmm5, %xmm6 + addsd .L_2il0floatpacket.4(%rip), %xmm0 + addsd %xmm6, %xmm2 + mulsd %xmm7, %xmm0 + xorps .L_2il0floatpacket.13(%rip), %xmm2 + addsd %xmm0, %xmm9 + subsd %xmm8, %xmm2 + movaps %xmm9, %xmm15 + addsd %xmm10, %xmm9 + addsd %xmm0, %xmm2 + movsd .L_2il0floatpacket.11(%rip), %xmm6 + movaps %xmm2, %xmm12 + shll $4, %ecx + addsd %xmm1, %xmm2 + shlq $4, %r8 + orl %ecx, %esi + movsd %xmm6, -16(%rsp) + movw %si, -10(%rsp) + movq __libm_exp_table_128@GOTPCREL(%rip), %rsi + movsd 1032(%r8,%rsi), %xmm13 + mulsd 1024(%r8,%rsi), %xmm9 + negq %r8 + mulsd %xmm13, %xmm15 + mulsd 1024(%rsi,%r8), %xmm2 + mulsd %xmm10, %xmm13 + addsd %xmm9, %xmm15 + movsd 1032(%rsi,%r8), %xmm11 + movaps %xmm13, %xmm14 + mulsd %xmm11, %xmm12 + mulsd %xmm11, %xmm1 + addsd %xmm2, %xmm12 + movsd -16(%rsp), %xmm2 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm12 + addsd %xmm1, %xmm14 + addsd %xmm12, %xmm15 + subsd %xmm14, %xmm13 + movsd %xmm1, -24(%rsp) + addsd %xmm1, %xmm13 + movsd %xmm14, -40(%rsp) + addsd %xmm13, %xmm15 + movsd %xmm13, -32(%rsp) + movsd %xmm14, (%rdi) + movsd %xmm15, 8(%rdi) + ret +..B1.9: + movsd %xmm1, -40(%rsp) + movaps %xmm0, %xmm4 + movl $0, -40(%rsp) + decl %eax + movsd -40(%rsp), %xmm7 + movsd .L_2il0floatpacket.6(%rip), %xmm1 + mulsd %xmm0, %xmm4 + addsd %xmm7, %xmm1 + movsd .L_2il0floatpacket.9(%rip), %xmm5 + subsd %xmm1, %xmm6 + mulsd %xmm4, %xmm5 + addsd %xmm6, %xmm2 + addsd .L_2il0floatpacket.10(%rip), %xmm5 + movsd .L_2il0floatpacket.7(%rip), %xmm6 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm5 + addsd .L_2il0floatpacket.8(%rip), %xmm6 + mulsd %xmm6, %xmm0 + movsd .L_2il0floatpacket.4(%rip), %xmm3 + addsd %xmm0, %xmm5 + mulsd %xmm4, %xmm5 + mulsd %xmm3, %xmm4 + movslq %r8d, %r8 + addsd %xmm4, %xmm5 + shlq $4, %r8 + addsd %xmm5, %xmm2 + movaps %xmm2, %xmm8 + addsd %xmm7, %xmm2 + movq __libm_exp_table_128@GOTPCREL(%rip), %rdx + movsd 1032(%r8,%rdx), %xmm0 + mulsd 1024(%r8,%rdx), %xmm2 + mulsd %xmm0, %xmm8 + mulsd %xmm0, %xmm7 + addsd %xmm2, %xmm8 + movsd %xmm7, -40(%rsp) + movsd %xmm7, (%rdi) + movsd %xmm8, 8(%rdi) +..B1.10: + ret +..B1.12: + xorl %eax, %eax + movq %rax, (%rdi) + movq %rax, 8(%rdi) +..B1.13: + xorl %eax, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __libm_cosh_k64,@function + .size __libm_cosh_k64,.-__libm_cosh_k64 + .data +# -- End __libm_cosh_k64 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.12: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,16 + .align 16 +.L_2il0floatpacket.13: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x6a3d464e,0x3f56c171 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x5554a6cf,0x3fa55555 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 4 +_TWO_52: + .long 0 + .long 1127219200 + .type _TWO_52,@object + .size _TWO_52,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_coshl_k80.S b/external/sgx_libm/intel64/libm_coshl_k80.S new file mode 100644 index 0000000000..6f542ee182 --- /dev/null +++ b/external/sgx_libm/intel64/libm_coshl_k80.S @@ -0,0 +1,748 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_coshl_k80.c" + .text +..TXTST0: +# -- Begin __libm_coshl_k80 + .text + .align 16,0x90 + .globl __libm_coshl_k80 +__libm_coshl_k80: +# parameter 1: 8 + %rsp +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_coshl_k80.1: +..L2: + + movzwl 16(%rsp), %eax + andl $32767, %eax + cmpl $16405, %eax + jge ..B1.20 +..B1.2: + cmpl $16382, %eax + jge ..B1.13 +..B1.3: + cmpl $16378, %eax + jge ..B1.11 +..B1.4: + fldt .L_2il0floatpacket.1(%rip) + cmpl $16372, %eax + jge ..B1.10 +..B1.5: + cmpl $16365, %eax + jge ..B1.9 +..B1.6: + fstpt (%rdi) + cmpl $16308, %eax + jge ..B1.8 +..B1.7: + fldt .L_2il0floatpacket.0(%rip) + fstpt 16(%rdi) + fldt 16(%rdi) + ret +..B1.8: + fldt 8(%rsp) + lea _Q3(%rip), %rax + fldt (%rax) + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) + ret +..B1.9: + fldt 8(%rsp) + lea 16+_Q2(%rip), %rax + lea _Q2(%rip), %rdx + fmul %st(0), %st + fxch %st(1) + fstpt (%rdi) + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) + ret +..B1.10: + fldt 8(%rsp) + lea 48+_Q1(%rip), %rax + lea 32+_Q1(%rip), %rcx + lea 16+_Q1(%rip), %rdx + lea _Q1(%rip), %rsi + fmul %st(0), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt (%rdi) + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + fmulp %st, %st(3) + fldt (%rsi) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) + ret +..B1.11: + fldt 8(%rsp) + lea _TWO_48H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea 96+_Q(%rip), %rdx + fmul %st(3), %st + lea 64+_Q(%rip), %rcx + fld %st(0) + lea 112+_Q(%rip), %r8 + lea 32+_Q(%rip), %rsi + lea 80+_Q(%rip), %r9 + lea 48+_Q(%rip), %r10 + lea 16+_Q(%rip), %r11 + fmul %st(1), %st + fldl (%rax) + lea 144+_Q(%rip), %rax + fadd %st, %st(4) + fxch %st(4) + fstpt -24(%rsp) + fldt -24(%rsp) + fsub %st(4), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(1) + fmul %st(4), %st + fxch %st(6) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(5) + fxch %st(2) + fmul %st(0), %st + fldt (%rdx) + lea 128+_Q(%rip), %rdx + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r8) + fmul %st(4), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(4) + fld %st(5) + fldt (%r11) + faddp %st, %st(5) + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fldt (%rax) + fld %st(0) + fmul %st(7), %st + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fmul %st(1), %st + fmul %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmul %st, %st(2) + fldt (%rdx) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(2) + fmulp %st, %st(4) + fld %st(1) + fadd %st(4), %st + fadd %st(3), %st + fstpt -24(%rsp) + fldt -24(%rsp) + fsubp %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.1(%rip) + faddp %st, %st(1) + fstpt (%rdi) + fldt .L_2il0floatpacket.0(%rip) +..B1.12: + ret +..B1.13: + fldt 8(%rsp) + lea _KLN2(%rip), %rsi + movb 17(%rsp), %cl + lea _TWO_63H(%rip), %rax + andb $-128, %cl + lea _LN2K(%rip), %r8 + shrb $7, %cl + lea 16+_LN2K(%rip), %r9 + fldt (%rsi) + fldl (%rax) + fldt (%r8) + fldt (%r9) + movzbl %cl, %edx + lea ones(%rip), %rcx + lea _TWO_32P(%rip), %r10 + lea _TWO_32(%rip), %r11 + lea 64+_P(%rip), %rsi + lea 32+_P(%rip), %r8 + lea _P(%rip), %r9 + fxch %st(4) + fmull (%rcx,%rdx,8) + fmul %st, %st(3) + fxch %st(2) + fadd %st, %st(3) + fxch %st(3) + fstpt -24(%rsp) + fxch %st(1) + fstpt 8(%rsp) + fldt 8(%rsp) + fldt -24(%rsp) + movl -24(%rsp), %edx + fsubp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + movsbq %dl, %rax + fsubrp %st, %st(1) + fld %st(0) + subl %eax, %edx + fxch %st(3) + fmulp %st, %st(2) + sarl $8, %edx + fxch %st(1) + fsubr %st, %st(2) + fldl (%r10) + lea 48+_P(%rip), %r10 + fmul %st(3), %st + fldl (%r11) + lea 16+_P(%rip), %r11 + fmulp %st, %st(4) + fsubp %st, %st(3) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fsubp %st, %st(1) + fadd %st, %st(1) + fld %st(1) + fmul %st(2), %st + fldt (%rsi) + fmul %st(1), %st + fldt (%r8) + movzwl 16(%rsp), %esi + faddp %st, %st(1) + fmul %st(1), %st + andl $32767, %esi + fldt (%r9) + cmpl $16387, %esi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + jg ..B1.19 +..B1.14: + jne ..B1.18 +..B1.15: + movl 12(%rsp), %esi + cmpl $-782985146, %esi + ja ..B1.19 +..B1.16: + jne ..B1.18 +..B1.17: + cmpl $1501741449, 8(%rsp) + ja ..B1.19 +..B1.18: + fldt .L_2il0floatpacket.1(%rip) + movl %edx, %r8d + negl %r8d + lea -1(%rdx), %esi + addl $16383, %r8d + shlq $4, %rax + subl %edx, %r8d + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + andl $32767, %r8d + fstpt -40(%rsp) + fld %st(1) + movzwl 8+.L_2il0floatpacket.1(%rip), %r9d + fadd %st(1), %st + fxch %st(1) + fsubrp %st, %st(2) + fld %st(2) + andl $-32768, %r9d + fldl 2056(%rdx,%rax) + orl %r8d, %r9d + fldl 2048(%rdx,%rax) + negq %rax + fstpt -72(%rsp) + fldt -72(%rsp) + movw %r9w, -32(%rsp) + fadd %st(1), %st + fmulp %st, %st(3) + fld %st(4) + fmul %st(1), %st + movl %esi, -8(%rsp) + faddp %st, %st(3) + fldl 2056(%rdx,%rax) + fmul %st, %st(2) + fldl 2048(%rdx,%rax) + fld %st(0) + movb 17(%rsp), %al + fadd %st(2), %st + fmulp %st, %st(6) + andb $-128, %al + shrb $7, %al + fxch %st(3) + fsubrp %st, %st(5) + fxch %st(4) + fstpt -56(%rsp) + fld %st(4) + fxch %st(2) + fmul %st, %st(5) + fldt -72(%rsp) + fmul %st, %st(3) + fld %st(0) + movzbl %al, %r10d + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fsub %st(5), %st + fsubr %st, %st(3) + fxch %st(5) + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(0) + fldt -56(%rsp) + faddp %st, %st(4) + fldt -40(%rsp) + fmul %st, %st(5) + fxch %st(1) + fadd %st(5), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldl (%rcx,%r10,8) + fmul %st, %st(1) + fxch %st(1) + fstpt (%rdi) + fmulp %st, %st(1) + fstpt 16(%rdi) + fildl -8(%rsp) + ret +..B1.19: + shlq $4, %rax + decl %edx + movl %edx, -8(%rsp) + faddp %st, %st(1) + fildl -8(%rsp) + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(5), %st + fmul %st(2), %st + movb 17(%rsp), %al + faddp %st, %st(4) + fmul %st, %st(4) + fld %st(0) + andb $-128, %al + shrb $7, %al + fadd %st(5), %st + fsubr %st, %st(1) + movzbl %al, %esi + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fldl (%rcx,%rsi,8) + fmul %st, %st(3) + fxch %st(3) + fstpt (%rdi) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rdi) + ret +..B1.20: + cmpl $32767, %eax + je ..B1.23 +..B1.21: + fldt .L_2il0floatpacket.0(%rip) + lea _infs(%rip), %rax + fstpt 16(%rdi) + fldt (%rax) + fstpt (%rdi) + fldt (%rdi) +..B1.22: + ret +..B1.23: + fldt 8(%rsp) + fmul %st(0), %st + fstpt (%rdi) + fldt (%rdi) + fldt .L_2il0floatpacket.0(%rip) + fstpt 16(%rdi) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_coshl_k80,@function + .size __libm_coshl_k80,.-__libm_coshl_k80 + .data +# -- End __libm_coshl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 2 +_Q3: + .word 21845 + .word 213 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 62430 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 22894 + .word 21845 + .word 43733 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 65531 + .word 65535 + .word 65535 + .word 65535 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 7054 + .word 43693 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 25016 + .word 58228 + .word 24755 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 57397 + .word 35800 + .word 53031 + .word 53262 + .word 16367 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 18360 + .word 43637 + .word 28980 + .word 40373 + .word 49076 + .word 0 + .word 0 + .word 0 + .word 16302 + .word 43691 + .word 43690 + .word 43690 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 46125 + .word 2912 + .word 24758 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 29965 + .word 3335 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 54950 + .word 46751 + .word 32187 + .word 37874 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 30733 + .word 25775 + .word 51110 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 49850 + .word 450 + .word 9929 + .word 51659 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 2776 + .word 45191 + .word 37201 + .word 55334 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,160 + .align 2 +_KLN2: + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 16391 + .word 0 + .word 0 + .word 0 + .type _KLN2,@object + .size _KLN2,16 + .align 2 +_LN2K: + .word 0 + .word 0 + .word 6134 + .word 45426 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 55756 + .word 58609 + .word 48341 + .word 59623 + .word 16343 + .word 0 + .word 0 + .word 0 + .type _LN2K,@object + .size _LN2K,32 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_infs: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .type _infs,@object + .size _infs,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_cosl_k80.S b/external/sgx_libm/intel64/libm_cosl_k80.S new file mode 100644 index 0000000000..f1b0501958 --- /dev/null +++ b/external/sgx_libm/intel64/libm_cosl_k80.S @@ -0,0 +1,848 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_cosl_k80.c" + .text +..TXTST0: +# -- Begin __libm_cosl_k80 + .text + .align 16,0x90 + .globl __libm_cosl_k80 +__libm_cosl_k80: +# parameter 1: 144 + %rsp +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_cosl_k80.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + subq $120, %rsp + .cfi_def_cfa_offset 144 + movq %rdi, %rbp + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 112(%rsp) + movzwl 152(%rsp), %eax + andl $32767, %eax + cmpl $16378, %eax + jge ..B1.18 +..B1.2: + cmpl $16372, %eax + jge ..B1.16 +..B1.3: + cmpl $16364, %eax + jge ..B1.14 +..B1.4: + cmpl $16308, %eax + jge ..B1.12 +..B1.5: + testl %eax, %eax + jne ..B1.8 +..B1.6: + cmpl $0, 148(%rsp) + jne ..B1.8 +..B1.7: + cmpl $0, 144(%rsp) + je ..B1.9 +..B1.8: + lea _ones(%rip), %rax + lea _small_value_80(%rip), %rdx + lea _zeros(%rip), %rcx + fldl (%rax) + fldt (%rdx) + fsubr %st(1), %st + fstpt (%rbp) + fldl (%rcx) + fstpt 16(%rbp) + jmp ..B1.10 +..B1.9: + lea _ones(%rip), %rax + lea _zeros(%rip), %rdx + fldl (%rax) + fstpt (%rbp) + fldt (%rbp) + fldl (%rdx) + fstpt 16(%rbp) +..B1.10: + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.28 +..B1.11: + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.12: + fldt 144(%rsp) + lea _CP3(%rip), %rdx + lea _ones(%rip), %rax + fldt (%rdx) + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 16(%rbp) + fldl (%rax) + fstpt (%rbp) + fldt (%rbp) + movq 112(%rsp), %rcx + xorq %rsp, %rcx + cmpq %fs:40, %rcx + jne ..B1.28 +..B1.13: + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.14: + fldt 144(%rsp) + lea 16+_CP2(%rip), %rdx + fmul %st(0), %st + lea _CP2(%rip), %rcx + fldt (%rdx) + lea _ones(%rip), %rax + fmul %st(1), %st + fldl (%rax) + fstpt (%rbp) + fldt (%rbp) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbp) + movq 112(%rsp), %rbx + xorq %rsp, %rbx + cmpq %fs:40, %rbx + jne ..B1.28 +..B1.15: + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.16: + fldt 144(%rsp) + lea 48+_CP1(%rip), %rdx + fmul %st(0), %st + lea 32+_CP1(%rip), %rbx + fld %st(0) + lea 16+_CP1(%rip), %rcx + fmul %st(1), %st + lea _CP1(%rip), %rsi + fldt (%rdx) + lea _ones(%rip), %rax + fmul %st(1), %st + fldl (%rax) + fstpt (%rbp) + fldt (%rbp) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rbx) + fmulp %st, %st(3) + fldt (%rsi) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rbp) + movq 112(%rsp), %rbp + xorq %rsp, %rbp + cmpq %fs:40, %rbp + jne ..B1.28 +..B1.17: + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.18: + cmpl $16382, %eax + jge ..B1.20 +..B1.19: + fldt 144(%rsp) + xorl %ecx, %ecx + movb 153(%rsp), %bl + xorl %esi, %esi + andb $-128, %bl + lea _TWO_52H(%rip), %rdx + shrb $7, %bl + fldl (%rdx) + movzbl %bl, %eax + lea _ones(%rip), %rbx + fxch %st(1) + fmull (%rbx,%rax,8) + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fstpt 16(%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + jmp ..B1.23 +..B1.20: + je ..B1.33 +..B1.21: + fldt 144(%rsp) + xorl %edi, %edi + movb 153(%rsp), %bl + andb $-128, %bl + shrb $7, %bl + movzbl %bl, %eax + lea _ones(%rip), %rbx + fmull (%rbx,%rax,8) + fstpt 144(%rsp) + fldt 144(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 160 + lea 112(%rsp), %rsi + fstpt (%rsp) +..___tag_value___libm_cosl_k80.41: + call __libm_reduce_pi04l@PLT +..___tag_value___libm_cosl_k80.42: +..B1.38: + movl %eax, %esi + addq $16, %rsp + .cfi_def_cfa_offset 144 +..B1.22: + fldl 96(%rsp) + lea 3(%rsi), %ecx + lea _TWO_52H(%rip), %rax + fld %st(0) + fldl 104(%rsp) + movsd 96(%rsp), %xmm0 + shrl $2, %ecx + mulsd (%rax), %xmm0 + andl $1, %ecx + movsd %xmm0, (%rsp) + fldl (%rsp) + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + faddp %st, %st(1) +..B1.23: + fldt 16(%rsp) + fld %st(2) + fmul %st(1), %st + lea _TWO_53H(%rip), %rax + fxch %st(1) + fmul %st(2), %st + incl %esi + faddp %st, %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fld %st(2) + fmul %st(3), %st + testl $2, %esi + fld %st(0) + fadd %st(2), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fld %st(1) + fmul %st(2), %st + fld %st(0) + faddp %st, %st(2) + fldl (%rax) + fstpt 48(%rsp) + fldl (%rbx,%rcx,8) + je ..B1.25 +..B1.24: + lea 112+_SP(%rip), %rax + lea 80+_SP(%rip), %rdx + fstpt (%rsp) + lea 48+_SP(%rip), %rcx + lea 128+_SP(%rip), %rdi + lea 16+_SP(%rip), %rsi + lea 96+_SP(%rip), %r8 + lea 64+_SP(%rip), %r9 + fldt (%rax) + lea 32+_SP(%rip), %r10 + lea _SP(%rip), %r11 + lea 160+_SP(%rip), %rax + fmul %st(2), %st + fldt (%rdx) + lea 144+_SP(%rip), %rdx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%r11) + faddp %st, %st(3) + fldt 32(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 64(%rsp) + fldt 80(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rdx) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fldt 48(%rsp) + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(2) + fld %st(2) + fldt 16(%rsp) + fld %st(0) + fmul %st(3), %st + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(1) + fmul %st(3), %st + fadd %st, %st(1) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt (%rbp) + fmulp %st, %st(1) + fstpt 16(%rbp) + fldl (%rbx) + jmp ..B1.26 +..B1.25: + fstp %st(4) + fstp %st(4) + lea 112+_CP(%rip), %rax + lea 80+_CP(%rip), %rdx + lea 48+_CP(%rip), %rcx + lea 16+_CP(%rip), %rsi + lea 128+_CP(%rip), %rdi + lea 96+_CP(%rip), %r8 + lea 64+_CP(%rip), %r9 + lea 32+_CP(%rip), %r10 + fldt (%rax) + lea _CP(%rip), %r11 + lea 160+_CP(%rip), %rax + fmul %st(1), %st + fldt (%rdx) + lea 144+_CP(%rip), %rdx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r11) + faddp %st, %st(2) + fldt 32(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 64(%rsp) + fldt 80(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(5) + fldt (%rdx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fld %st(4) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fadd %st, %st(1) + fldt 48(%rsp) + fmul %st(2), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fldl (%rbx) + fadd %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + fstpt (%rbp) + fmulp %st, %st(1) + fstpt 16(%rbp) +..B1.26: + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.28 +..B1.27: + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.28: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.33: + movl 148(%rsp), %eax + cmpl $-921707870, %eax + jb ..B1.19 +..B1.34: + jne ..B1.21 +..B1.35: + cmpl $560513589, 144(%rsp) + jbe ..B1.19 + jmp ..B1.21 + .align 16,0x90 + .cfi_endproc + .type __libm_cosl_k80,@function + .size __libm_cosl_k80,.-__libm_cosl_k80 + .data +# -- End __libm_cosl_k80 + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_CP3: + .word 0 + .word 65450 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .type _CP3,@object + .size _CP3,16 + .align 2 +_CP2: + .word 63855 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 18238 + .word 17476 + .word 43656 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP2,@object + .size _CP2,32 + .align 2 +_CP1: + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 47533 + .word 43689 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 14131 + .word 49466 + .word 24756 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 37142 + .word 18013 + .word 35855 + .word 53259 + .word 16367 + .word 0 + .word 0 + .word 0 + .type _CP1,@object + .size _CP1,64 + .align 2 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP,@object + .size _SP,176 + .align 2 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 0 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 0 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP,@object + .size _CP,176 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_exp_k32.S b/external/sgx_libm/intel64/libm_exp_k32.S new file mode 100644 index 0000000000..3fd3808323 --- /dev/null +++ b/external/sgx_libm/intel64/libm_exp_k32.S @@ -0,0 +1,220 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_exp_k32.c" + .text +..TXTST0: +# -- Begin __libm_exp_k32 + .text + .align 16,0x90 + .globl __libm_exp_k32 +__libm_exp_k32: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___libm_exp_k32.1: +..L2: + + movsd %xmm0, -16(%rsp) + movl -12(%rsp), %eax + movl %eax, %edx + andl $2147483647, %edx + shrl $31, %eax + cmpl $1012924416, %edx + jb ..B1.3 +..B1.2: + movsd .L_2il0floatpacket.0(%rip), %xmm1 + lea _TWO_52H(%rip), %rdx + movsd .L_2il0floatpacket.1(%rip), %xmm3 + lea SC2_BIAS(%rip), %rsi + movsd .L_2il0floatpacket.2(%rip), %xmm4 + lea _SC2(%rip), %r10 + movsd .L_2il0floatpacket.4(%rip), %xmm13 + movsd (%rdx), %xmm2 + movsd .L_2il0floatpacket.6(%rip), %xmm10 + mulsd %xmm0, %xmm1 + movsd .L_2il0floatpacket.9(%rip), %xmm6 + addsd %xmm2, %xmm1 + movsd %xmm1, -40(%rsp) + movsd -40(%rsp), %xmm5 + movsd .L_2il0floatpacket.3(%rip), %xmm7 + subsd %xmm2, %xmm5 + mulsd %xmm5, %xmm3 + mulsd %xmm4, %xmm5 + subsd %xmm3, %xmm0 + movaps %xmm0, %xmm8 + movsd %xmm0, -16(%rsp) + subsd %xmm5, %xmm8 + movaps %xmm8, %xmm9 + subsd %xmm8, %xmm0 + addsd %xmm8, %xmm6 + subsd %xmm5, %xmm0 + movsd %xmm6, -32(%rsp) + addsd %xmm0, %xmm9 + movaps %xmm9, %xmm11 + mulsd %xmm9, %xmm11 + mulsd %xmm11, %xmm13 + mulsd %xmm11, %xmm10 + addsd .L_2il0floatpacket.5(%rip), %xmm13 + addsd .L_2il0floatpacket.7(%rip), %xmm10 + mulsd %xmm11, %xmm13 + mulsd %xmm9, %xmm10 + movl $0, -32(%rsp) + addsd %xmm10, %xmm13 + movsd -32(%rsp), %xmm14 + movsd .L_2il0floatpacket.8(%rip), %xmm12 + addsd %xmm14, %xmm7 + mulsd %xmm11, %xmm13 + mulsd %xmm11, %xmm12 + subsd %xmm7, %xmm8 + addsd %xmm12, %xmm13 + addsd %xmm8, %xmm0 + movl -40(%rsp), %ecx + movl %ecx, %r8d + shll $25, %r8d + addsd %xmm13, %xmm0 + sarl $25, %r8d + subl %r8d, %ecx + movslq %r8d, %r8 + shlq $4, %r8 + movq __libm_exp_table_128@GOTPCREL(%rip), %r9 + shrl $7, %ecx + movslq (%rsi,%rax,4), %rdi + movsd 1032(%r9,%r8), %xmm15 + addq %rcx, %rdi + movaps %xmm15, %xmm1 + mulsd %xmm0, %xmm1 + addsd %xmm14, %xmm0 + mulsd %xmm14, %xmm15 + mulsd 1024(%r9,%r8), %xmm0 + shlq $52, %rdi + addsd %xmm0, %xmm1 + movq %rdi, -24(%rsp) + addsd %xmm15, %xmm1 + mulsd -24(%rsp), %xmm1 + mulsd (%r10,%rax,8), %xmm1 + jmp ..B1.4 +..B1.3: + movsd .L_2il0floatpacket.9(%rip), %xmm1 + addsd -16(%rsp), %xmm1 +..B1.4: + movaps %xmm1, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type __libm_exp_k32,@function + .size __libm_exp_k32,.-__libm_exp_k32 + .data +# -- End __libm_exp_k32 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +SC2_BIAS: + .long 511 + .long 1535 + .type SC2_BIAS,@object + .size SC2_BIAS,8 + .align 4 +_SC2: + .long 0 + .long 1609564160 + .long 0 + .long 535822336 + .type _SC2,@object + .size _SC2,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_exp_k64.S b/external/sgx_libm/intel64/libm_exp_k64.S new file mode 100644 index 0000000000..6069cf9943 --- /dev/null +++ b/external/sgx_libm/intel64/libm_exp_k64.S @@ -0,0 +1,260 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_exp_k64.c" + .text +..TXTST0: +# -- Begin __libm_exp_k64 + .text + .align 16,0x90 + .globl __libm_exp_k64 +__libm_exp_k64: +# parameter 1: %xmm0 +# parameter 2: %rdi +# parameter 3: %rsi +..B1.1: + .cfi_startproc +..___tag_value___libm_exp_k64.1: +..L2: + + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %eax + andl $32752, %eax + movb -1(%rsp), %dl + andb $-128, %dl + shrl $4, %eax + shrb $7, %dl + cmpl $2047, %eax + je ..B1.10 +..B1.2: + cmpl $966, %eax + jge ..B1.6 +..B1.3: + movl $0, (%rdi) + cmpl $917, %eax + jge ..B1.5 +..B1.4: + movq $0x3ff0000000000000, %rax + movq %rax, (%rsi) + movq $0, 8(%rsi) + ret +..B1.5: + movsd .L_2il0floatpacket.9(%rip), %xmm0 + movsd -8(%rsp), %xmm2 + movaps %xmm0, %xmm1 + addsd %xmm2, %xmm1 + movsd %xmm1, (%rsi) + subsd %xmm0, %xmm1 + movsd %xmm1, -24(%rsp) + subsd %xmm1, %xmm2 + movsd %xmm2, 8(%rsi) + ret +..B1.6: + cmpl $1035, %eax + jge ..B1.8 +..B1.7: + movsd -8(%rsp), %xmm0 + lea _TWO_52H(%rip), %rax + movsd .L_2il0floatpacket.0(%rip), %xmm4 + movsd .L_2il0floatpacket.1(%rip), %xmm2 + movsd .L_2il0floatpacket.2(%rip), %xmm3 + mulsd %xmm0, %xmm4 + movsd (%rax), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm12 + addsd %xmm1, %xmm4 + movsd %xmm4, -24(%rsp) + subsd %xmm1, %xmm4 + mulsd %xmm4, %xmm2 + mulsd %xmm3, %xmm4 + subsd %xmm2, %xmm0 + movaps %xmm0, %xmm7 + movsd %xmm0, -8(%rsp) + subsd %xmm4, %xmm7 + movaps %xmm7, %xmm8 + subsd %xmm7, %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm9 + subsd %xmm4, %xmm0 + movsd .L_2il0floatpacket.9(%rip), %xmm5 + addsd %xmm0, %xmm8 + addsd %xmm7, %xmm5 + movaps %xmm8, %xmm10 + mulsd %xmm8, %xmm10 + mulsd %xmm10, %xmm12 + mulsd %xmm10, %xmm9 + addsd .L_2il0floatpacket.5(%rip), %xmm12 + addsd .L_2il0floatpacket.7(%rip), %xmm9 + mulsd %xmm10, %xmm12 + mulsd %xmm8, %xmm9 + movsd %xmm5, -16(%rsp) + addsd %xmm9, %xmm12 + movl $0, -16(%rsp) + movsd -16(%rsp), %xmm14 + movsd .L_2il0floatpacket.3(%rip), %xmm6 + movsd .L_2il0floatpacket.8(%rip), %xmm11 + addsd %xmm14, %xmm6 + mulsd %xmm10, %xmm12 + mulsd %xmm10, %xmm11 + subsd %xmm6, %xmm7 + addsd %xmm11, %xmm12 + addsd %xmm7, %xmm0 + movl -24(%rsp), %r8d + movl %r8d, %edx + shll $25, %edx + addsd %xmm12, %xmm0 + sarl $25, %edx + subl %edx, %r8d + movslq %edx, %rdx + shlq $4, %rdx + movq __libm_exp_table_128@GOTPCREL(%rip), %rcx + sarl $7, %r8d + movsd 1032(%rcx,%rdx), %xmm1 + movaps %xmm1, %xmm13 + mulsd %xmm0, %xmm1 + addsd %xmm14, %xmm0 + mulsd %xmm14, %xmm13 + movsd 1024(%rcx,%rdx), %xmm15 + mulsd %xmm0, %xmm15 + movl %r8d, (%rdi) + addsd %xmm15, %xmm1 + movsd %xmm13, (%rsi) + movsd %xmm1, 8(%rsi) + ret +..B1.8: + movzbl %dl, %edx + lea _inf_zeros(%rip), %rax + movl $0, (%rdi) + movq $0, 8(%rsi) + movq (%rax,%rdx,8), %rcx + movq %rcx, (%rsi) +..B1.9: + ret +..B1.10: + testl $1048575, -4(%rsp) + jne ..B1.13 +..B1.11: + cmpl $0, -8(%rsp) + jne ..B1.13 +..B1.12: + movzbl %dl, %edx + lea _inf_zeros(%rip), %rax + movsd (%rax,%rdx,8), %xmm0 + jmp ..B1.14 +..B1.13: + movsd -8(%rsp), %xmm0 +..B1.14: + movl $0, (%rdi) + movsd %xmm0, (%rsi) + movq $0, 8(%rsi) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_exp_k64,@function + .size __libm_exp_k64,.-__libm_exp_k64 + .data +# -- End __libm_exp_k64 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_inf_zeros: + .long 0 + .long 2146435072 + .long 0 + .long 0 + .type _inf_zeros,@object + .size _inf_zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_expl_k80.S b/external/sgx_libm/intel64/libm_expl_k80.S new file mode 100644 index 0000000000..5b62cc0fb1 --- /dev/null +++ b/external/sgx_libm/intel64/libm_expl_k80.S @@ -0,0 +1,395 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_expl_k80.c" + .text +..TXTST0: +# -- Begin __libm_expl_k80 + .text + .align 16,0x90 + .globl __libm_expl_k80 +__libm_expl_k80: +# parameter 1: %rdi +# parameter 2: %rsi +..B1.1: + .cfi_startproc +..___tag_value___libm_expl_k80.1: +..L2: + + fldt (%rsi) + movb 9(%rsi), %dl + movzwl 8(%rsi), %eax + andb $-128, %dl + andl $32767, %eax + shrb $7, %dl + fstpt -24(%rsp) + fldt -24(%rsp) + fldt 16(%rsi) + cmpl $32767, %eax + je ..B1.11 +..B1.2: + cmpl $16358, %eax + jge ..B1.7 +..B1.3: + cmpl $16183, %eax + jge ..B1.5 +..B1.4: + fstp %st(1) + fstp %st(0) + fldt .L_2il0floatpacket.0(%rip) + fstpt (%rdi) + fldt .L_2il0floatpacket.1(%rip) + fstpt 16(%rdi) + fldt 16(%rdi) + ret +..B1.5: + fldt .L_2il0floatpacket.0(%rip) + lea 16+_P1(%rip), %rax + lea _P1(%rip), %rdx + fldt (%rax) + fmul %st(3), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(3), %st + fmul %st(3), %st + faddp %st, %st(3) + fldt .L_2il0floatpacket.0(%rip) + fadd %st(3), %st + fstpt (%rdi) + fldt (%rdi) + fsubrp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.1(%rip) +..B1.6: + ret +..B1.7: + cmpl $16405, %eax + jge ..B1.9 +..B1.8: + fldt -24(%rsp) + lea _KLN2(%rip), %rdx + lea _TWO_63H(%rip), %rcx + lea _LN2K(%rip), %r8 + lea 16+_LN2K(%rip), %r9 + lea 64+_P(%rip), %r10 + lea 32+_P(%rip), %r11 + fldt (%rdx) + lea _P(%rip), %rdx + fmulp %st, %st(3) + fldt (%rcx) + lea 48+_P(%rip), %rcx + fadd %st, %st(3) + fxch %st(3) + fstpt -56(%rsp) + fldt -56(%rsp) + movl -56(%rsp), %esi + fsubp %st, %st(3) + fldt (%r8) + fmul %st(3), %st + fstpt -56(%rsp) + fxch %st(2) + fchs + fldt -56(%rsp) + movsbq %sil, %rax + fsubrp %st, %st(3) + fldt (%r9) + subl %eax, %esi + fmulp %st, %st(1) + fstpt -56(%rsp) + fldt -56(%rsp) + sarl $8, %esi + fadd %st(2), %st + fld %st(0) + movl %esi, -40(%rsp) + fsub %st(3), %st + fld %st(1) + lea 16+_P(%rip), %rsi + shlq $4, %rax + fsub %st(1), %st + movq __libm_expl_table_256@GOTPCREL(%rip), %r8 + fsubrp %st, %st(4) + fildl -40(%rsp) + fldt -56(%rsp) + fsubp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + fld %st(2) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fld %st(3) + fsub %st(2), %st + fchs + fld %st(0) + fsubr %st(3), %st + fsubrp %st, %st(5) + fsubrp %st, %st(5) + fxch %st(3) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldl 2056(%r8,%rax) + fldl 2048(%r8,%rax) + fld %st(0) + fmul %st(4), %st + fxch %st(3) + fadd %st, %st(4) + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fstpt (%rdi) + fldt (%rdi) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rdi) + ret +..B1.9: + fstp %st(1) + fstp %st(0) + fldt .L_2il0floatpacket.1(%rip) + lea _inf_zeros(%rip), %rax + movzbl %dl, %edx + fstpt 16(%rdi) + shlq $4, %rdx + fldt (%rax,%rdx) + fstpt (%rdi) + fldt (%rdi) +..B1.10: + ret +..B1.11: + fstp %st(0) + cmpl $-2147483648, -20(%rsp) + jne ..B1.15 +..B1.12: + cmpl $0, -24(%rsp) + jne ..B1.15 +..B1.13: + fstp %st(0) + movzbl %dl, %edx + lea _inf_zeros(%rip), %rax + shlq $4, %rdx + fldt (%rax,%rdx) +..B1.15: + fldt .L_2il0floatpacket.1(%rip) + fstpt 16(%rdi) + fstpt (%rdi) + fldt (%rdi) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_expl_k80,@function + .size __libm_expl_k80,.-__libm_expl_k80 + .data +# -- End __libm_expl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 2 +_P1: + .word 43691 + .word 10 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30584 + .word 43703 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,32 + .align 2 +_KLN2: + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 16391 + .word 0 + .word 0 + .word 0 + .type _KLN2,@object + .size _KLN2,16 + .align 2 +_TWO_63H: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16446 + .word 0 + .word 0 + .word 0 + .type _TWO_63H,@object + .size _TWO_63H,16 + .align 2 +_LN2K: + .word 0 + .word 0 + .word 6134 + .word 45426 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 55756 + .word 58609 + .word 48341 + .word 59623 + .word 16343 + .word 0 + .word 0 + .word 0 + .type _LN2K,@object + .size _LN2K,32 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_inf_zeros: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _inf_zeros,@object + .size _inf_zeros,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_fegetenv.S b/external/sgx_libm/intel64/libm_fegetenv.S new file mode 100644 index 0000000000..69dc3ea79f --- /dev/null +++ b/external/sgx_libm/intel64/libm_fegetenv.S @@ -0,0 +1,85 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_fegetenv.c" + .text +..TXTST0: +# -- Begin fegetenv + .text + .align 16,0x90 + .globl fegetenv +fegetenv: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value_fegetenv.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movq %rdi, (%rsp) +..B1.2: + stmxcsr 8(%rsp) +..B1.3: + movq (%rsp), %rdx + movl 8(%rsp), %eax + movl %eax, 28(%rdx) +..B1.4: + movq (%rsp), %rax +..B1.5: + fnstenv (%rax) +..B1.6: + fnclex +..B1.7: + fldenv (%rax) +..B1.8: + xorl %eax, %eax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type fegetenv,@function + .size fegetenv,.-fegetenv + .data +# -- End fegetenv + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_hypot2_k64.S b/external/sgx_libm/intel64/libm_hypot2_k64.S new file mode 100644 index 0000000000..2217a31551 --- /dev/null +++ b/external/sgx_libm/intel64/libm_hypot2_k64.S @@ -0,0 +1,320 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_hypot2_k64.c" + .text +..TXTST0: +# -- Begin __libm_hypot2_k64 + .text + .align 16,0x90 + .globl __libm_hypot2_k64 +__libm_hypot2_k64: +# parameter 1: %rdi +# parameter 2: %xmm0 +# parameter 3: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value___libm_hypot2_k64.1: +..L2: + + movsd %xmm0, -24(%rsp) + movzwl -18(%rsp), %eax + testl $32752, %eax + movsd %xmm1, -16(%rsp) + jne ..B1.8 +..B1.2: + testl $1048575, -20(%rsp) + jne ..B1.8 +..B1.3: + cmpl $0, -24(%rsp) + jne ..B1.8 +..B1.4: + movzwl -10(%rsp), %eax + testl $32752, %eax + jne ..B1.8 +..B1.5: + testl $1048575, -12(%rsp) + jne ..B1.8 +..B1.6: + cmpl $0, -16(%rsp) + jne ..B1.8 +..B1.7: + movq -24(%rsp), %rax + movq -16(%rsp), %rdx + pxor %xmm0, %xmm0 + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + ret +..B1.8: + movsd -24(%rsp), %xmm0 + movsd -16(%rsp), %xmm2 + andps .L_2il0floatpacket.6(%rip), %xmm0 + andps .L_2il0floatpacket.6(%rip), %xmm2 + comisd %xmm2, %xmm0 + jbe ..B1.10 +..B1.9: + movsd %xmm0, -8(%rsp) + movaps %xmm0, %xmm1 + jmp ..B1.11 +..B1.10: + movsd %xmm2, -8(%rsp) + movaps %xmm2, %xmm1 + movaps %xmm0, %xmm2 +..B1.11: + movsd %xmm2, -16(%rsp) + movzwl -10(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + testl %eax, %eax + je ..B1.13 +..B1.12: + addl $-1023, %eax + jmp ..B1.17 +..B1.13: + testl $1048575, -12(%rsp) + jne ..B1.16 +..B1.14: + cmpl $0, -16(%rsp) + jne ..B1.16 +..B1.15: + movl $-10000, %eax + jmp ..B1.17 +..B1.16: + lea 48+_CONSTANTS(%rip), %rax + movaps %xmm2, %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -24(%rsp) + movzwl -18(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + addl $-2046, %eax +..B1.17: + movzwl -2(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + testl %edx, %edx + je ..B1.19 +..B1.18: + addl $-1023, %edx + jmp ..B1.20 +..B1.19: + lea 48+_CONSTANTS(%rip), %rax + movaps %xmm1, %xmm0 + addl $-2046, %edx + mulsd (%rax), %xmm0 + movsd %xmm0, -24(%rsp) + movzwl -18(%rsp), %eax + andl $32752, %eax + shrl $4, %eax +..B1.20: + addl $-56, %edx + cmpl %edx, %eax + lea _CONSTANTS(%rip), %rax + pxor %xmm0, %xmm0 + jg ..L3 + movaps %xmm0, %xmm2 +..L3: + comisd (%rax), %xmm1 + jb ..B1.22 +..B1.21: + lea 40+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm2 + movsd %xmm1, -8(%rsp) + movsd %xmm2, -16(%rsp) + movsd .L_2il0floatpacket.0(%rip), %xmm0 + jmp ..B1.28 +..B1.22: + lea 8+_CONSTANTS(%rip), %rax + comisd (%rax), %xmm1 + jb ..B1.24 +..B1.23: + lea 40+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm2 + movsd %xmm1, -8(%rsp) + movsd %xmm2, -16(%rsp) + movsd .L_2il0floatpacket.3(%rip), %xmm0 + jmp ..B1.28 +..B1.24: + lea 16+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm3 + comisd %xmm1, %xmm3 + jb ..B1.26 +..B1.25: + lea 32+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm2 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm2 + movsd %xmm1, -8(%rsp) + movsd %xmm2, -16(%rsp) + movsd .L_2il0floatpacket.4(%rip), %xmm0 + jmp ..B1.28 +..B1.26: + lea 24+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm3 + comisd %xmm1, %xmm3 + jb ..B1.28 +..B1.27: + lea 32+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm2 + movsd %xmm1, -8(%rsp) + movsd %xmm2, -16(%rsp) + movsd .L_2il0floatpacket.5(%rip), %xmm0 +..B1.28: + movsd .L_2il0floatpacket.1(%rip), %xmm9 + mulsd %xmm1, %xmm9 + movaps %xmm9, %xmm3 + movsd .L_2il0floatpacket.1(%rip), %xmm14 + subsd %xmm1, %xmm3 + mulsd %xmm2, %xmm14 + subsd %xmm3, %xmm9 + movsd .L_2il0floatpacket.2(%rip), %xmm5 + movaps %xmm9, %xmm6 + mulsd %xmm9, %xmm6 + subsd %xmm9, %xmm1 + mulsd %xmm5, %xmm9 + movaps %xmm14, %xmm4 + movaps %xmm6, %xmm8 + mulsd %xmm1, %xmm9 + subsd %xmm2, %xmm4 + mulsd %xmm1, %xmm1 + subsd %xmm4, %xmm14 + addsd %xmm9, %xmm8 + subsd %xmm14, %xmm2 + movaps %xmm14, %xmm12 + movaps %xmm8, %xmm7 + mulsd %xmm14, %xmm12 + subsd %xmm6, %xmm7 + mulsd %xmm5, %xmm14 + subsd %xmm7, %xmm9 + mulsd %xmm2, %xmm14 + mulsd %xmm2, %xmm2 + addsd %xmm1, %xmm9 + movaps %xmm8, %xmm10 + addsd %xmm12, %xmm10 + movaps %xmm10, %xmm13 + movaps %xmm10, %xmm1 + addsd %xmm14, %xmm13 + subsd %xmm8, %xmm1 + movaps %xmm13, %xmm11 + subsd %xmm1, %xmm12 + subsd %xmm10, %xmm11 + addsd %xmm9, %xmm12 + subsd %xmm11, %xmm14 + movsd %xmm13, (%rdi) + addsd %xmm12, %xmm14 + addsd %xmm2, %xmm14 + movsd %xmm14, 8(%rdi) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_hypot2_k64,@function + .size __libm_hypot2_k64,.-__libm_hypot2_k64 + .data +# -- End __libm_hypot2_k64 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.6: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40a00800 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x02000000,0x41a00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x40900800 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0xc0a00800 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x00000000,0xc0900800 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 4 +_CONSTANTS: + .long 0 + .long 1727004672 + .long 4294967295 + .long 1608515583 + .long 4294967295 + .long 481296383 + .long 0 + .long 651165696 + .long 0 + .long 1610612736 + .long 0 + .long 534773760 + .long 0 + .long 2145386496 + .long 0 + .long 1126170624 + .type _CONSTANTS,@object + .size _CONSTANTS,64 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_hypot2l_k80.S b/external/sgx_libm/intel64/libm_hypot2l_k80.S new file mode 100644 index 0000000000..46053cd7bb --- /dev/null +++ b/external/sgx_libm/intel64/libm_hypot2l_k80.S @@ -0,0 +1,496 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_hypot2l_k80.c" + .text +..TXTST0: +# -- Begin __libm_hypot2l_k80 + .text + .align 16,0x90 + .globl __libm_hypot2l_k80 +__libm_hypot2l_k80: +# parameter 1: %rdi +# parameter 2: 8 + %rsp +# parameter 3: 24 + %rsp +..B1.1: + .cfi_startproc +..___tag_value___libm_hypot2l_k80.1: +..L2: + + movzwl 16(%rsp), %eax + testl $32767, %eax + jne ..B1.6 +..B1.2: + cmpq $0, 8(%rsp) + jne ..B1.6 +..B1.3: + movzwl 32(%rsp), %eax + testl $32767, %eax + jne ..B1.6 +..B1.4: + cmpq $0, 24(%rsp) + jne ..B1.6 +..B1.5: + fldt 8(%rsp) + fstpt (%rdi) + fldt 24(%rsp) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) + ret +..B1.6: + fldt 8(%rsp) + fabs + fstpt -56(%rsp) + fldt -56(%rsp) + fldt 24(%rsp) + fabs + fstpt -24(%rsp) + fldt -24(%rsp) + movzwl -48(%rsp), %ecx + movzwl -16(%rsp), %esi + andl $32767, %ecx + andl $32767, %esi + cmpl %esi, %ecx + jg ..B1.11 +..B1.7: + jne ..B1.12 +..B1.8: + movl -52(%rsp), %eax + movl -20(%rsp), %edx + cmpl %edx, %eax + ja ..B1.57 +..B1.9: + jne ..B1.56 +..B1.10: + movl -56(%rsp), %eax + cmpl -24(%rsp), %eax + jbe ..B1.56 +..B1.57: + cmpl %esi, %ecx +..B1.11: + fxch %st(1) + fstpt -40(%rsp) + fldt -40(%rsp) + fld %st(0) + fxch %st(2) + fxch %st(1) + fxch %st(2) + jl ..B1.18 + jmp ..B1.14 +..B1.12: + fstpt -40(%rsp) + fldt -40(%rsp) + fld %st(0) +..B1.13: + jl ..B1.18 +..B1.14: + jne ..B1.19 +..B1.15: + movl -52(%rsp), %eax + movl -20(%rsp), %edx + cmpl %edx, %eax + jb ..B1.18 +..B1.16: + jne ..B1.19 +..B1.17: + movl -56(%rsp), %eax + cmpl -24(%rsp), %eax + jae ..B1.19 +..B1.18: + fstp %st(1) + fxch %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + jmp ..B1.20 +..B1.19: + fstp %st(2) + fstpt -24(%rsp) + fldt -24(%rsp) +..B1.20: + movswl -16(%rsp), %ecx + testl %ecx, %ecx + je ..B1.22 +..B1.21: + addl $-16383, %ecx + jmp ..B1.26 +..B1.22: + movzwl -16(%rsp), %eax + testl $32767, %eax + jne ..B1.25 +..B1.23: + cmpq $0, -24(%rsp) + jne ..B1.25 +..B1.24: + movl $-16526, %ecx + jmp ..B1.26 +..B1.25: + lea 96+_CONSTANTS(%rip), %rax + lea 112+_CONSTANTS(%rip), %rdx + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + fmulp %st, %st(1) + fstpt -56(%rsp) + movswl -48(%rsp), %ecx + addl $-32828, %ecx +..B1.26: + movswl -32(%rsp), %eax + testl %eax, %eax + je ..B1.28 +..B1.27: + addl $-16383, %eax + jmp ..B1.29 +..B1.28: + lea 96+_CONSTANTS(%rip), %rax + lea 112+_CONSTANTS(%rip), %rdx + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + fmulp %st, %st(1) + fstpt -56(%rsp) + movswl -48(%rsp), %eax + addl $-32828, %eax +..B1.29: + fldt .L_2il0floatpacket.0(%rip) + addl $-67, %eax + cmpl %eax, %ecx + movzwl -32(%rsp), %eax + jg ..L3 + fst %st(1) +..L3: + andl $32767, %eax + cmpl $24709, %eax + jg ..B1.34 +..B1.30: + jne ..B1.35 +..B1.31: + lea _CONSTANTS(%rip), %rcx + movl -36(%rsp), %edx + cmpl 4(%rcx), %edx + ja ..B1.34 +..B1.32: + jne ..B1.35 +..B1.33: + movl -40(%rsp), %edx + cmpl (%rcx), %edx + jb ..B1.35 +..B1.34: + fstp %st(0) + lea 80+_CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st, %st(2) + fmul %st, %st(2) + fxch %st(2) + fstpt -40(%rsp) + fldt -40(%rsp) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(2) + fxch %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + fldt .L_2il0floatpacket.1(%rip) + jmp ..B1.53 +..B1.35: + cmpl $24573, %eax + jg ..B1.40 +..B1.36: + jne ..B1.41 +..B1.37: + lea 16+_CONSTANTS(%rip), %rcx + movl -36(%rsp), %edx + cmpl 4(%rcx), %edx + ja ..B1.40 +..B1.38: + jne ..B1.41 +..B1.39: + movl -40(%rsp), %edx + cmpl (%rcx), %edx + jb ..B1.41 +..B1.40: + fstp %st(0) + lea 80+_CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + fstpt -40(%rsp) + fldt -40(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + fldt .L_2il0floatpacket.4(%rip) + jmp ..B1.53 +..B1.41: + cmpl $8127, %eax + jl ..B1.46 +..B1.42: + jne ..B1.47 +..B1.43: + lea 32+_CONSTANTS(%rip), %rcx + movl -36(%rsp), %edx + cmpl 4(%rcx), %edx + jb ..B1.46 +..B1.44: + jne ..B1.47 +..B1.45: + movl -40(%rsp), %edx + cmpl (%rcx), %edx + ja ..B1.47 +..B1.46: + fstp %st(0) + lea 64+_CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st, %st(2) + fmul %st, %st(2) + fxch %st(2) + fstpt -40(%rsp) + fldt -40(%rsp) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(2) + fxch %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + fldt .L_2il0floatpacket.5(%rip) + jmp ..B1.53 +..B1.47: + cmpl $8323, %eax + jl ..B1.52 +..B1.48: + jne ..B1.53 +..B1.49: + lea 48+_CONSTANTS(%rip), %rdx + movl -36(%rsp), %eax + cmpl 4(%rdx), %eax + jb ..B1.52 +..B1.50: + jne ..B1.53 +..B1.51: + movl -40(%rsp), %eax + cmpl (%rdx), %eax + ja ..B1.53 +..B1.52: + fstp %st(0) + lea 64+_CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + fstpt -40(%rsp) + fldt -40(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + fldt .L_2il0floatpacket.6(%rip) +..B1.53: + fldt .L_2il0floatpacket.2(%rip) + fmul %st(3), %st + fld %st(3) + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(3) + fxch %st(2) + fsubr %st, %st(5) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(5), %st + fsub %st, %st(3) + fsubp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(5) + fldt .L_2il0floatpacket.3(%rip) + fmul %st, %st(2) + fxch %st(2) + fmul %st(7), %st + fxch %st(2) + fmulp %st, %st(1) + fmul %st(5), %st + fld %st(2) + fadd %st(2), %st + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(2) + fxch %st(6) + fmul %st(0), %st + faddp %st, %st(1) + fld %st(1) + fadd %st(3), %st + fld %st(0) + fadd %st(7), %st + fstpt (%rdi) + fldt (%rdi) + fxch %st(1) + fsub %st, %st(3) + fxch %st(3) + fsubrp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fxch %st(4) + fmul %st(0), %st + fxch %st(4) + fsubp %st, %st(1) + fsubrp %st, %st(4) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rdi) + ret +..B1.56: + cmpl %esi, %ecx + jmp ..B1.12 + .align 16,0x90 + .cfi_endproc + .type __libm_hypot2l_k80,@function + .size __libm_hypot2l_k80,.-__libm_hypot2l_k80 + .data +# -- End __libm_hypot2l_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0e,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0d,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0e,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x0d,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24709 + .word 0 + .word 0 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 24573 + .word 0 + .word 0 + .word 0 + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 8127 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8323 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24576 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8190 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16445 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,128 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_log1pl_k80.S b/external/sgx_libm/intel64/libm_log1pl_k80.S new file mode 100644 index 0000000000..0f91f7acfd --- /dev/null +++ b/external/sgx_libm/intel64/libm_log1pl_k80.S @@ -0,0 +1,2003 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_log1pl_k80.c" + .text +..TXTST0: +# -- Begin __libm_log1p_k80 + .text + .align 16,0x90 + .globl __libm_log1p_k80 +__libm_log1p_k80: +# parameter 1: %rdi +# parameter 2: %rsi +..B1.1: + .cfi_startproc +..___tag_value___libm_log1p_k80.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + subq $120, %rsp + .cfi_def_cfa_offset 144 + movq %rsi, %r14 + movq %fs:40, %rax + movq %rdi, %r13 + xorq %rsp, %rax + movq %rax, 112(%rsp) + movzwl 8(%r14), %edx + andl $32767, %edx + movl 32(%r14), %ecx + lea (%rcx,%rdx), %eax + cmpl $16511, %eax + jge ..B1.9 +..B1.2: + cmpl $16255, %eax + jle ..B1.8 +..B1.3: + addl $-8383, %edx + cmpl $16000, %edx + jbe ..B1.6 +..B1.4: + movq %r14, %rdi +..___tag_value___libm_log1p_k80.8: + call __libm_normalizel_k80@PLT +..___tag_value___libm_log1p_k80.9: +..B1.5: + movl 32(%r14), %ecx +..B1.6: + fldt (%r14) + addl $16383, %ecx + fldt 16(%r14) + andl $32767, %ecx + andb $127, 9(%rsp) + lea 80(%rsp), %rdi + movzwl -72(%rdi), %eax + lea 48(%rsp), %rsi + andl $-32768, %eax + orl %ecx, %eax + movw %ax, -40(%rsi) + movl $-2147483648, -44(%rsi) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt (%rsi) + fmulp %st, %st(1) + fstpt 16(%rsi) +..___tag_value___libm_log1p_k80.10: + call __libm_log1pl_k80@PLT +..___tag_value___libm_log1p_k80.11: +..B1.7: + fldt 80(%rsp) + fmul %st(1), %st + movl $0, 32(%r13) + fstpt (%r13) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpt 16(%r13) + jmp ..B1.19 +..B1.8: + movq (%r14), %rax + movq %rax, (%r13) + movq 8(%r14), %rdx + movq %rdx, 8(%r13) + movq 16(%r14), %rcx + movq %rcx, 16(%r13) + movq 24(%r14), %rsi + movq %rsi, 24(%r13) + movq 32(%r14), %r8 + movq %r8, 32(%r13) + movq 40(%r14), %rdi + movq %rdi, 40(%r13) + jmp ..B1.19 +..B1.9: + movq %r14, %rdi +..___tag_value___libm_log1p_k80.12: + call __libm_normalizel_k80@PLT +..___tag_value___libm_log1p_k80.13: +..B1.10: + fildl 32(%r14) + fstpt (%rsp) + fldt (%r14) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt 16(%r14) + fstpt 64(%rsp) + fldt 64(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 176 + lea 112(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_log1p_k80.15: + call __libm_logl_k80@PLT +..___tag_value___libm_log1p_k80.16: +..B1.25: + addq $32, %rsp + .cfi_def_cfa_offset 144 +..B1.11: + fldt 80(%rsp) + lea _LN2_K80(%rip), %rax + lea 16+_LN2_K80(%rip), %rdx + fmul %st(1), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fldt 96(%rsp) + fmulp %st, %st(2) + movzwl 88(%rsp), %esi + andl $32767, %esi + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt (%rax) + fldt (%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(0) + movzwl 24(%rsp), %ecx + fadd %st(4), %st + fldt (%rdx) + andl $32767, %ecx + fmulp %st, %st(3) + cmpl %esi, %ecx + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + movl $0, 32(%r13) + jg ..B1.16 +..B1.12: + jne ..B1.17 +..B1.13: + movl 20(%rsp), %eax + movl 84(%rsp), %edx + cmpl %edx, %eax + ja ..B1.16 +..B1.14: + jne ..B1.17 +..B1.15: + movl 16(%rsp), %eax + cmpl 80(%rsp), %eax + jbe ..B1.17 +..B1.16: + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.18 +..B1.17: + fxch %st(2) + fsubr %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) +..B1.18: + fld %st(1) + fadd %st(1), %st + fstpt (%r13) + fldt (%r13) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%r13) +..B1.19: + movq 112(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.21 +..B1.20: + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 13, -16 + .cfi_offset 14, -24 +..B1.21: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __libm_log1p_k80,@function + .size __libm_log1p_k80,.-__libm_log1p_k80 + .data +# -- End __libm_log1p_k80 + .text +# -- Begin __libm_log1pl_k80 + .text + .align 16,0x90 + .globl __libm_log1pl_k80 +__libm_log1pl_k80: +# parameter 1: %rdi +# parameter 2: %rsi +..B2.1: + .cfi_startproc +..___tag_value___libm_log1pl_k80.27: +..L28: + + subq $440, %rsp + .cfi_def_cfa_offset 448 + movq %rsi, %rax + movq %fs:40, %rdx + movq %rdi, %r9 + xorq %rsp, %rdx + lea zeros(%rip), %r8 + movq %rdx, 432(%rsp) + fldt (%rax) + fld %st(0) + fldt 16(%rax) + fadd %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fsub %st, %st(2) + movzbl 9(%rsp), %edi + fxch %st(2) + fsubrp %st, %st(1) + fldt (%r8) + andl $128, %edi + shrl $7, %edi + movl %edi, %edx + movzwl 8(%rsp), %esi + shll $15, %edx + andl $32767, %esi + movl 4(%rsp), %r10d + orl %esi, %edx + movl %r10d, %ecx + shll $16, %edx + shrl $16, %ecx + orl %ecx, %edx + fstpt 16(%r9) + fldt 16(%r9) + cmpl $32767, %esi + je ..B2.115 +..B2.2: + cmpl $-1073774592, %edx + jae ..B2.101 +..B2.3: + fstp %st(1) + fstpt (%r9) + fldt (%r9) +..B2.4: + cmpl $16375, %esi + jge ..B2.52 +..B2.5: + fstp %st(0) + cmpl $16363, %esi + jge ..B2.30 +..B2.6: + fstp %st(0) + cmpl $16298, %esi + jge ..B2.8 +..B2.7: + fldt (%rax) + fstpt (%r9) + fldt 16(%rax) + lea ones(%rip), %rax + fstpt 16(%r9) + fldt (%rax) + jmp ..B2.104 +..B2.8: + fldt (%rax) + lea t32(%rip), %rdx + fld %st(0) + fld %st(1) + lea 32+_S(%rip), %rcx + lea _S(%rip), %rsi + lea 16+_S(%rip), %rdi + lea 64+_S(%rip), %r8 + fldt (%rdx) + fmul %st, %st(2) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(2) + fld %st(1) + fld %st(3) + fsub %st(3), %st + fmul %st, %st(1) + fxch %st(1) + fadd %st(0), %st + fld %st(0) + fld %st(4) + fmul %st(5), %st + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(2) + fld %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(5) + fxch %st(4) + fstpt 16(%rsp) + fldt 16(%rsp) + fxch %st(5) + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(3) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt 16(%rax) + fmulp %st, %st(5) + fxch %st(4) + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(5) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fldt (%rcx) + fld %st(0) + fmul %st(2), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fxch %st(1) + fmul %st(3), %st + fstpt (%rsp) + fldt (%rsp) + fstpt 320(%rsp) + fld %st(1) + fsub %st(6), %st + faddp %st, %st(6) + fld %st(1) + fsub %st(6), %st + fxch %st(1) + fstpt 304(%rsp) + fxch %st(6) + fmulp %st, %st(2) + fld %st(2) + fmul %st(5), %st + fxch %st(3) + fmul %st(6), %st + fxch %st(4) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fld %st(3) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(4) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fldt 16(%rax) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt (%rsi) + fld %st(0) + fld %st(1) + fldt 16(%rsp) + fld %st(0) + fmul %st(4), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + fxch %st(1) + fmul %st(6), %st + fsubr %st, %st(4) + faddp %st, %st(4) + fxch %st(3) + fstpt 80(%rsp) + fldt 80(%rsp) + fld %st(5) + fsub %st(1), %st + fld %st(2) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(2) + fmul %st(4), %st + fldt (%rdi) + fmul %st(6), %st + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 336(%rsp) + fldt 336(%rsp) + fsubr %st, %st(1) + movzwl 344(%rsp), %r10d + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + andl $32767, %r10d + fstpt 352(%rsp) + fldt 32(%rsp) + fld %st(0) + fxch %st(1) + fmul %st(3), %st + fldt 80(%rsp) + fmul %st, %st(2) + fldt 48(%rsp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fld %st(1) + fldt (%rax) + fmul %st, %st(5) + fldt 16(%rax) + fmulp %st, %st(7) + fxch %st(6) + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fldt (%r8) + fmul %st, %st(4) + fxch %st(4) + fstpt 368(%rsp) + fldt 368(%rsp) + fadd %st, %st(1) + fxch %st(4) + fmulp %st, %st(3) + movzwl 376(%rsp), %r11d + andl $32767, %r11d + fxch %st(2) + fstpt 384(%rsp) + fldt 384(%rsp) + cmpl %r11d, %r10d + fldt 64(%rsp) + fldt 96(%rsp) + jg ..B2.13 +..B2.9: + jne ..B2.14 +..B2.10: + movl 340(%rsp), %edx + movl 372(%rsp), %ecx + cmpl %ecx, %edx + ja ..B2.13 +..B2.11: + jne ..B2.14 +..B2.12: + movl 336(%rsp), %edx + cmpl 368(%rsp), %edx + jbe ..B2.14 +..B2.13: + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(5) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + jmp ..B2.15 +..B2.14: + fxch %st(4) + fsubr %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) +..B2.15: + fld %st(2) + movzwl 312(%rsp), %edx + fadd %st(1), %st + fstpt 400(%rsp) + fldt 400(%rsp) + andl $32767, %edx + movzwl 408(%rsp), %ecx + fld %st(2) + andl $32767, %ecx + fadd %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + cmpl %ecx, %edx + fxch %st(2) + faddp %st, %st(4) + fxch %st(3) + fstpt 416(%rsp) + fldt 416(%rsp) + jg ..B2.20 +..B2.16: + jne ..B2.21 +..B2.17: + movl 308(%rsp), %edx + movl 404(%rsp), %ecx + cmpl %ecx, %edx + ja ..B2.20 +..B2.18: + jne ..B2.21 +..B2.19: + movl 304(%rsp), %edx + cmpl 400(%rsp), %edx + jbe ..B2.21 +..B2.20: + fldt (%rsp) + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.22 +..B2.21: + fldt (%rsp) + fxch %st(2) + fsub %st(4), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) +..B2.22: + fld %st(0) + movzwl 8(%rax), %edx + fadd %st(2), %st + fstpt 272(%rsp) + fldt 272(%rsp) + andl $32767, %edx + movzwl 280(%rsp), %ecx + fsubr %st, %st(2) + andl $32767, %ecx + fxch %st(2) + faddp %st, %st(1) + fstpt 288(%rsp) + fldt 288(%rsp) + cmpl %ecx, %edx + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 16(%r9) + fldt 16(%r9) + jg ..B2.27 +..B2.23: + jne ..B2.28 +..B2.24: + movl 276(%rsp), %edx + cmpl 4(%rax), %edx + jb ..B2.27 +..B2.25: + jne ..B2.28 +..B2.26: + movl (%rax), %edx + cmpl 272(%rsp), %edx + jbe ..B2.28 +..B2.27: + fldt (%rax) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%rax) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + jmp ..B2.29 +..B2.28: + fldt (%rax) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 16(%rax) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) +..B2.29: + fld %st(1) + lea ones(%rip), %rax + fadd %st(1), %st + fstpt (%r9) + fldt (%r9) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%r9) + fldt (%rax) + jmp ..B2.104 +..B2.30: + fldt (%rax) + lea t32(%rip), %rdx + fld %st(0) + fld %st(1) + fld %st(2) + lea _S(%rip), %rcx + fxch %st(4) + fstpt 48(%rsp) + lea 16+_S(%rip), %rsi + fldt (%rdx) + lea 32+_S(%rip), %rdi + fmul %st, %st(2) + lea 176+_S(%rip), %r10 + lea 64+_S(%rip), %r8 + lea 160+_S(%rip), %r11 + lea 144+_S(%rip), %rdx + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(2) + fld %st(1) + fld %st(2) + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(5) + fxch %st(1) + fmul %st(5), %st + fadd %st(0), %st + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fld %st(5) + fmul %st(6), %st + faddp %st, %st(4) + fld %st(4) + fxch %st(3) + fstpt 64(%rsp) + fldt 64(%rsp) + fxch %st(2) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt 16(%rax) + fmulp %st, %st(4) + fxch %st(3) + fadd %st(0), %st + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fld %st(3) + fmul %st(3), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fxch %st(4) + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(1) + fsub %st(3), %st + fmul %st, %st(4) + fxch %st(3) + fmul %st(7), %st + faddp %st, %st(4) + fld %st(3) + fadd %st(5), %st + fsubr %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(4) + fld %st(4) + fmulp %st, %st(2) + fstpt 96(%rsp) + fldt 96(%rsp) + fldt 16(%rax) + fldt 64(%rsp) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fmul %st, %st(3) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fld %st(1) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fld %st(1) + fsub %st(1), %st + fldt 80(%rsp) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(2), %st + fxch %st(3) + fmul %st(7), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fldt 16(%rax) + fmul %st(3), %st + faddp %st, %st(5) + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fstpt 128(%rsp) + fldt 128(%rsp) + faddp %st, %st(3) + fldt 48(%rsp) + fmulp %st, %st(3) + fxch %st(2) + fstpt (%rsp) + fldt (%rcx) + lea 128+_S(%rip), %rcx + fld %st(0) + fld %st(1) + fxch %st(2) + fmul %st, %st(3) + fldt 64(%rsp) + fmulp %st, %st(1) + fsubr %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fmul %st(5), %st + fxch %st(2) + fmul %st, %st(5) + fldt 112(%rsp) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(4) + fldt 16(%rsp) + fldt (%rsi) + lea 112+_S(%rip), %rsi + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fstpt 336(%rsp) + fldt 336(%rsp) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fstpt 352(%rsp) + fldt 352(%rsp) + fldt (%rdi) + lea 96+_S(%rip), %rdi + fmul %st, %st(2) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 320(%rsp) + fldt 96(%rsp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 304(%rsp) + fldt 304(%rsp) + fldt (%r8) + lea 80+_S(%rip), %r8 + fldt 32(%rsp) + fmul %st(1), %st + fstpt 368(%rsp) + fldt 368(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fldt 128(%rsp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 384(%rsp) + fldt 384(%rsp) + fldt (%r10) + fldt 48(%rsp) + fmul %st, %st(1) + fldt (%r11) + movzwl 344(%rsp), %r10d + faddp %st, %st(2) + fmul %st, %st(1) + andl $32767, %r10d + fldt (%rdx) + movzwl 376(%rsp), %edx + faddp %st, %st(2) + fmul %st, %st(1) + andl $32767, %edx + fldt (%rcx) + cmpl %edx, %r10d + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rsi) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rdi) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt (%r8) + faddp %st, %st(1) + fld %st(5) + faddp %st, %st(3) + fldt (%rsp) + fmulp %st, %st(1) + fstpt (%rsp) + fldt (%rax) + jg ..B2.35 +..B2.31: + jne ..B2.36 +..B2.32: + movl 340(%rsp), %edx + movl 372(%rsp), %ecx + cmpl %ecx, %edx + ja ..B2.35 +..B2.33: + jne ..B2.36 +..B2.34: + movl 336(%rsp), %edx + cmpl 368(%rsp), %edx + jbe ..B2.36 +..B2.35: + fldt 32(%rsp) + fxch %st(3) + fsubr %st, %st(6) + fxch %st(3) + faddp %st, %st(6) + fxch %st(1) + faddp %st, %st(5) + fxch %st(3) + faddp %st, %st(4) + jmp ..B2.37 +..B2.36: + fldt 32(%rsp) + fsub %st(3), %st + faddp %st, %st(6) + fxch %st(4) + faddp %st, %st(5) + faddp %st, %st(4) +..B2.37: + fld %st(3) + movzwl 312(%rsp), %edx + fadd %st(1), %st + fstpt 400(%rsp) + fldt 400(%rsp) + andl $32767, %edx + movzwl 408(%rsp), %ecx + fsubr %st, %st(1) + andl $32767, %ecx + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) + fstpt 416(%rsp) + fldt 416(%rsp) + fld %st(1) + cmpl %ecx, %edx + fadd %st(4), %st + jg ..B2.42 +..B2.38: + jne ..B2.43 +..B2.39: + movl 308(%rsp), %edx + movl 404(%rsp), %ecx + cmpl %ecx, %edx + ja ..B2.42 +..B2.40: + jne ..B2.43 +..B2.41: + movl 304(%rsp), %edx + cmpl 400(%rsp), %edx + jbe ..B2.43 +..B2.42: + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 16(%rsp) + faddp %st, %st(1) + fxch %st(2) + jmp ..B2.44 +..B2.43: + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fldt 16(%rsp) + faddp %st, %st(4) + faddp %st, %st(3) +..B2.44: + fld %st(2) + movzwl 8(%rax), %edx + fadd %st(1), %st + fstpt 272(%rsp) + fldt 272(%rsp) + andl $32767, %edx + movzwl 280(%rsp), %ecx + fsubr %st, %st(1) + andl $32767, %ecx + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + fstpt 288(%rsp) + fldt 288(%rsp) + cmpl %ecx, %edx + fxch %st(1) + fadd %st(2), %st + fstpt 16(%r9) + fldt 16(%r9) + jg ..B2.49 +..B2.45: + jne ..B2.50 +..B2.46: + movl 276(%rsp), %edx + cmpl 4(%rax), %edx + jb ..B2.49 +..B2.47: + jne ..B2.50 +..B2.48: + movl (%rax), %edx + cmpl 272(%rsp), %edx + jbe ..B2.50 +..B2.49: + fldt (%rax) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%rax) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + jmp ..B2.51 +..B2.50: + fldt (%rax) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 16(%rax) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) +..B2.51: + fld %st(1) + lea ones(%rip), %rax + fadd %st(1), %st + fstpt (%r9) + fldt (%r9) + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt (%rsp) + faddp %st, %st(1) + fstpt 16(%r9) + fldt (%rax) + jmp ..B2.104 +..B2.52: + fstp %st(1) + fldt (%rax) + lea ones(%rip), %r8 + movzwl 8(%rax), %edx + fld %st(0) + andl $32767, %edx + fldt (%r8) + movzwl 8(%r8), %edi + movl %edi, %esi + andl $32767, %esi + fadd %st, %st(1) + cmpl %esi, %edx + jg ..B2.57 +..B2.53: + jne ..B2.58 +..B2.54: + movl 4(%rax), %edx + cmpl 4(%r8), %edx + ja ..B2.57 +..B2.55: + jne ..B2.58 +..B2.56: + movl (%rax), %edx + cmpl (%r8), %edx + jbe ..B2.58 +..B2.57: + fldt 16(%rax) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + fadd %st, %st(3) + fxch %st(3) + fadd %st(4), %st + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.59 +..B2.58: + fldt 16(%rax) + fld %st(1) + fsub %st(3), %st + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + fadd %st(3), %st +..B2.59: + fld %st(0) + movq __libm_rcp_table_256@GOTPCREL(%rip), %r10 + fadd %st(2), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubr %st, %st(2) + movzwl 120(%rsp), %ecx + fxch %st(2) + faddp %st, %st(1) + movl 116(%rsp), %eax + andl $32767, %ecx + shrl $23, %eax + movzbl %al, %eax + fstpt 128(%rsp) + fldt 128(%rsp) + lea -16383(%rcx), %edx + cmpl $16383, %edx + flds (%r10,%rax,4) + jge ..B2.61 +..B2.60: + movl %edx, %r10d + andl $-32768, %edi + negl %r10d + addl $16383, %r10d + andl $32767, %r10d + fxch %st(3) + fstpt (%rsp) + fldt (%rsp) + orl %r10d, %edi + movw %di, 8(%rsp) + fldt (%rsp) + fxch %st(1) + fxch %st(4) + fxch %st(1) + jmp ..B2.62 +..B2.61: + lea _CONSTANTS(%rip), %rdi + fldt (%rdi) +..B2.62: + movzwl 136(%rsp), %edi + andl $32767, %edi + addl $128, %edi + fmul %st, %st(3) + cmpl %edi, %ecx + jge ..B2.64 +..B2.63: + fmulp %st, %st(2) + fxch %st(1) + jmp ..B2.65 +..B2.64: + fstp %st(0) + fstp %st(1) + fld %st(3) +..B2.65: + movl %edx, 96(%rsp) + lea _LN2(%rip), %rdx + fildl 96(%rsp) + lea 16+_LN2(%rip), %rcx + fxch %st(4) + fstpt 64(%rsp) + shlq $4, %rax + movq __libm_logl_table_256@GOTPCREL(%rip), %rdi + fstpt 80(%rsp) + fld %st(1) + fldt (%rdx) + fmul %st(4), %st + fldt (%rcx) + fmulp %st, %st(5) + fld %st(3) + fxch %st(1) + faddl (%rax,%rdi) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 240(%rsp) + fld %st(3) + fxch %st(4) + fmul %st(6), %st + fxch %st(5) + faddl 8(%rdi,%rax) + lea t32(%rip), %rax + fstpt (%rsp) + fld %st(2) + fldt (%rax) + fmul %st, %st(3) + fxch %st(3) + fsubr %st, %st(5) + faddp %st, %st(5) + fxch %st(1) + fsub %st(4), %st + fxch %st(1) + fmul %st(2), %st + fxch %st(2) + fstpt 32(%rsp) + fld %st(2) + fsub %st(2), %st + faddp %st, %st(2) + fld %st(2) + fsub %st(2), %st + fld %st(4) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(5) + fxch %st(3) + faddp %st, %st(5) + fld %st(4) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(5) + faddp %st, %st(2) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 80(%rsp) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubr %st, %st(1) + movzwl 120(%rsp), %r10d + fxch %st(1) + faddp %st, %st(2) + andl $32767, %r10d + fxch %st(1) + fstpt 128(%rsp) + fldt 128(%rsp) + cmpl %esi, %r10d + fldt 64(%rsp) + fld %st(0) + fsubr %st(3), %st + fstpt 48(%rsp) + jg ..B2.70 +..B2.66: + jne ..B2.71 +..B2.67: + movl 116(%rsp), %eax + cmpl 4(%r8), %eax + ja ..B2.70 +..B2.68: + jne ..B2.71 +..B2.69: + movl 112(%rsp), %eax + cmpl (%r8), %eax + jbe ..B2.71 +..B2.70: + fldt 48(%rsp) + fsubrp %st, %st(3) + fsubr %st, %st(2) + fxch %st(3) + fsubrp %st, %st(2) + faddp %st, %st(1) + jmp ..B2.72 +..B2.71: + fldt 48(%rsp) + fadd %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) +..B2.72: + fldt 48(%rsp) + lea _S(%rip), %rax + fld %st(0) + lea 16+_S(%rip), %rdx + lea 32+_S(%rip), %rcx + lea 64+_S(%rip), %rsi + lea 176+_S(%rip), %rdi + lea 160+_S(%rip), %r8 + lea 144+_S(%rip), %r10 + lea 128+_S(%rip), %r11 + fadd %st(2), %st + fstpt 128(%rsp) + fldt 128(%rsp) + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 144(%rsp) + fxch %st(2) + fstpt 64(%rsp) + fld %st(0) + fxch %st(2) + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(1) + fstpt 256(%rsp) + fldt 256(%rsp) + fldt 32(%rsp) + fld %st(0) + fmul %st(2), %st + fsubr %st, %st(4) + faddp %st, %st(4) + fld %st(3) + fld %st(2) + fsub %st(5), %st + fmul %st, %st(1) + fxch %st(1) + fadd %st(0), %st + fld %st(0) + fld %st(6) + fmul %st(7), %st + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(2) + fld %st(2) + fmul %st(3), %st + faddp %st, %st(2) + fld %st(5) + fmul %st(5), %st + fadd %st(0), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fmul %st, %st(4) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fld %st(1) + fsub %st(4), %st + faddp %st, %st(4) + fxch %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + fld %st(6) + fmul %st(4), %st + fxch %st(1) + fsub %st(4), %st + fxch %st(3) + fmul %st, %st(4) + fxch %st(7) + fstpt 160(%rsp) + fldt 160(%rsp) + fmul %st(3), %st + faddp %st, %st(4) + fld %st(3) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fxch %st(2) + fmul %st(6), %st + faddp %st, %st(2) + fld %st(3) + fmulp %st, %st(1) + fld %st(4) + fldt 176(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fstpt 192(%rsp) + fldt 192(%rsp) + fldt 32(%rsp) + fldt 160(%rsp) + fxch %st(1) + fmul %st(2), %st + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fstpt 208(%rsp) + fldt 208(%rsp) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fmul %st(7), %st + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(1) + fld %st(2) + fmulp %st, %st(4) + fldt 192(%rsp) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fstpt 224(%rsp) + fldt 224(%rsp) + faddp %st, %st(2) + fldt 144(%rsp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 80(%rsp) + fldt (%rax) + lea 112+_S(%rip), %rax + fld %st(0) + fld %st(1) + fxch %st(2) + fmul %st, %st(3) + fldt 32(%rsp) + fmulp %st, %st(1) + fsubr %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fmul %st(5), %st + fxch %st(2) + fmul %st, %st(5) + fldt 208(%rsp) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(4) + fldt 96(%rsp) + fldt (%rdx) + lea 96+_S(%rip), %rdx + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fstpt 336(%rsp) + fldt 336(%rsp) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fstpt 352(%rsp) + fldt 352(%rsp) + fldt (%rcx) + lea 80+_S(%rip), %rcx + fmul %st, %st(2) + fxch %st(2) + fstpt 96(%rsp) + fldt 96(%rsp) + fstpt 320(%rsp) + fldt 176(%rsp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 304(%rsp) + fldt 304(%rsp) + fldt (%rsi) + fldt 112(%rsp) + fmul %st(1), %st + fstpt 368(%rsp) + fldt 368(%rsp) + movzwl 344(%rsp), %esi + andl $32767, %esi + fstpt 112(%rsp) + fldt 112(%rsp) + fldt 224(%rsp) + fmulp %st, %st(2) + fxch %st(1) + fstpt 384(%rsp) + fldt 384(%rsp) + fldt (%rdi) + fldt 144(%rsp) + fmul %st, %st(1) + fldt (%r8) + movzwl 376(%rsp), %edi + faddp %st, %st(2) + fmul %st, %st(1) + andl $32767, %edi + fldt (%r10) + cmpl %edi, %esi + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r11) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rdx) + faddp %st, %st(2) + fmulp %st, %st(1) + fldt (%rcx) + faddp %st, %st(1) + fldt 80(%rsp) + fmulp %st, %st(1) + fstpt 80(%rsp) + fld %st(4) + faddp %st, %st(2) + fldt 64(%rsp) + fldt 128(%rsp) + jg ..B2.77 +..B2.73: + jne ..B2.78 +..B2.74: + movl 340(%rsp), %eax + movl 372(%rsp), %edx + cmpl %edx, %eax + ja ..B2.77 +..B2.75: + jne ..B2.78 +..B2.76: + movl 336(%rsp), %eax + cmpl 368(%rsp), %eax + jbe ..B2.78 +..B2.77: + fldt 112(%rsp) + fxch %st(4) + fsubr %st, %st(7) + fxch %st(4) + faddp %st, %st(7) + fxch %st(2) + faddp %st, %st(6) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fxch %st(4) + jmp ..B2.79 +..B2.78: + fldt 112(%rsp) + fsub %st(4), %st + faddp %st, %st(7) + fxch %st(5) + faddp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) +..B2.79: + fld %st(0) + movzwl 312(%rsp), %eax + fadd %st(2), %st + fstpt 400(%rsp) + fldt 400(%rsp) + andl $32767, %eax + movzwl 408(%rsp), %edx + fld %st(3) + andl $32767, %edx + fadd %st(1), %st + fxch %st(1) + fsubr %st, %st(3) + cmpl %edx, %eax + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 416(%rsp) + fldt 416(%rsp) + jg ..B2.84 +..B2.80: + jne ..B2.85 +..B2.81: + movl 308(%rsp), %eax + movl 404(%rsp), %edx + cmpl %edx, %eax + ja ..B2.84 +..B2.82: + jne ..B2.85 +..B2.83: + movl 304(%rsp), %eax + cmpl 400(%rsp), %eax + jbe ..B2.85 +..B2.84: + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 96(%rsp) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.86 +..B2.85: + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fldt 96(%rsp) + faddp %st, %st(2) + faddp %st, %st(1) +..B2.86: + fld %st(0) + movzwl 264(%rsp), %eax + fadd %st(2), %st + fstpt 272(%rsp) + fldt 272(%rsp) + andl $32767, %eax + movzwl 280(%rsp), %edx + fld %st(3) + andl $32767, %edx + fadd %st(1), %st + fxch %st(1) + fsubr %st, %st(3) + cmpl %edx, %eax + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 288(%rsp) + fldt 288(%rsp) + jg ..B2.91 +..B2.87: + jne ..B2.92 +..B2.88: + movl 260(%rsp), %eax + movl 276(%rsp), %edx + cmpl %edx, %eax + ja ..B2.91 +..B2.89: + jne ..B2.92 +..B2.90: + movl 256(%rsp), %eax + cmpl 272(%rsp), %eax + jbe ..B2.92 +..B2.91: + fldt 48(%rsp) + fxch %st(2) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.93 +..B2.92: + fldt 48(%rsp) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) +..B2.93: + fldt 80(%rsp) + fld %st(1) + movzwl 248(%rsp), %edx + fadd %st(3), %st + fstpt 32(%rsp) + fldt 32(%rsp) + andl $32767, %edx + movzwl 40(%rsp), %eax + fsubr %st, %st(3) + andl $32767, %eax + fxch %st(2) + faddp %st, %st(3) + cmpl %edx, %eax + faddp %st, %st(2) + fldt 16(%rsp) + fadd %st(1), %st + jg ..B2.98 +..B2.94: + jne ..B2.99 +..B2.95: + movl 36(%rsp), %eax + movl 244(%rsp), %edx + cmpl %edx, %eax + ja ..B2.98 +..B2.96: + jne ..B2.99 +..B2.97: + movl 32(%rsp), %eax + cmpl 240(%rsp), %eax + jbe ..B2.99 +..B2.98: + fldt 16(%rsp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt (%rsp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + jmp ..B2.100 +..B2.99: + fldt 16(%rsp) + fsub %st(1), %st + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt (%rsp) + faddp %st, %st(1) +..B2.100: + fld %st(0) + fadd %st(2), %st + fstpt (%r9) + fldt (%r9) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%r9) + jmp ..B2.104 +..B2.101: + cmpl $1, %edi + je ..B2.108 +..B2.122: + fstp %st(1) +..B2.102: + lea 16+ones(%rip), %rax + fldt (%rax) + fxch %st(2) + fucomip %st(2), %st + jp ..B2.103 + je ..B2.107 +..B2.103: + fstp %st(1) + lea _infs(%rip), %rax + lea ones(%rip), %rdx + fldl (%rax) + fmulp %st, %st(1) + fstpt (%r9) + fldt (%rdx) +..B2.104: + movq 432(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.106 +..B2.105: + addq $440, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 448 +..B2.106: + fstp %st(0) + call __stack_chk_fail@PLT +..B2.107: + fdivrp %st, %st(1) + lea ones(%rip), %rax + fstpt (%r9) + fldt (%rax) + jmp ..B2.104 +..B2.108: + cmpl $16383, %esi + jne ..B2.122 +..B2.109: + movq $0x8000000000000000, %rdx + cmpq (%rsp), %rdx + jne ..B2.122 +..B2.110: + fxch %st(1) + fstpt (%rsp) + testb $-128, 9(%rsp) + jne ..B2.102 +..B2.111: + cmpl $0, 4(%rsp) + jne ..B2.114 +..B2.113: + cmpl $0, (%rsp) + je ..B2.102 +..B2.114: + fstpt (%r9) + fldt (%r9) + jmp ..B2.4 +..B2.115: + fstp %st(1) + testl %edi, %edi + je ..B2.119 +..B2.116: + cmpl $-2147483648, %r10d + jne ..B2.119 +..B2.117: + cmpl $0, (%rsp) + jne ..B2.119 +..B2.118: + fstp %st(1) + lea _infs(%rip), %rax + lea ones(%rip), %rdx + fldl (%rax) + fmulp %st, %st(1) + fstpt (%r9) + fldt (%rdx) + jmp ..B2.104 +..B2.119: + fstp %st(0) + lea ones(%rip), %rax + fldt (%rax) + fmul %st, %st(1) + fxch %st(1) + fstpt (%r9) + jmp ..B2.104 + .align 16,0x90 + .cfi_endproc + .type __libm_log1pl_k80,@function + .size __libm_log1pl_k80,.-__libm_log1pl_k80 + .data +# -- End __libm_log1pl_k80 + .section .rodata, "a" + .align 16 + .align 16 +zeros: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type zeros,@object + .size zeros,32 + .align 16 +ones: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type ones,@object + .size ones,32 + .align 16 +t32: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type t32,@object + .size t32,32 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_LN2_K80: + .word 0 + .word 0 + .word 6136 + .word 45426 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 12704 + .word 55409 + .word 6480 + .word 47298 + .word 49116 + .word 0 + .word 0 + .word 0 + .type _LN2_K80,@object + .size _LN2_K80,32 + .align 2 +_S: + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16317 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 52429 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 37449 + .word 18724 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 52429 + .word 52428 + .word 52428 + .word 52428 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 11916 + .word 59578 + .word 35746 + .word 47662 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _S,@object + .size _S,192 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,16 + .align 2 +_LN2: + .word 0 + .word 53711 + .word 6135 + .word 45426 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 2022 + .word 26416 + .word 37831 + .word 62295 + .word 16333 + .word 0 + .word 0 + .word 0 + .type _LN2,@object + .size _LN2,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_log_k32.S b/external/sgx_libm/intel64/libm_log_k32.S new file mode 100644 index 0000000000..f6a4e7083c --- /dev/null +++ b/external/sgx_libm/intel64/libm_log_k32.S @@ -0,0 +1,164 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_log_k32.c" + .text +..TXTST0: +# -- Begin __libm_log_k32 + .text + .align 16,0x90 + .globl __libm_log_k32 +__libm_log_k32: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___libm_log_k32.1: +..L2: + + movsd %xmm0, -24(%rsp) + movl -20(%rsp), %ecx + movl %ecx, %eax + andl $2146435072, %eax + negl %eax + lea -1072676864(%rcx), %edx + addl $2145386496, %eax + movl %eax, -12(%rsp) + cmpl $24576, %edx + movl $0, -16(%rsp) + movsd .L_2il0floatpacket.0(%rip), %xmm1 + jae ..B1.3 +..B1.2: + lea 32+_Q(%rip), %rax + addsd %xmm1, %xmm0 + movaps %xmm0, %xmm2 + lea 24+_Q(%rip), %rcx + movsd (%rax), %xmm3 + lea 16+_Q(%rip), %rdx + lea 8+_Q(%rip), %rsi + lea _Q(%rip), %rdi + movsd %xmm0, -24(%rsp) + movsd (%rcx), %xmm1 + mulsd %xmm0, %xmm2 + mulsd %xmm2, %xmm3 + mulsd %xmm2, %xmm1 + addsd (%rdx), %xmm3 + addsd (%rsi), %xmm1 + mulsd %xmm2, %xmm3 + mulsd %xmm0, %xmm1 + addsd %xmm1, %xmm3 + addsd (%rdi), %xmm3 + mulsd %xmm2, %xmm3 + addsd %xmm3, %xmm0 + ret +..B1.3: + movl %ecx, %esi + pxor %xmm0, %xmm0 + shrl $12, %ecx + lea 8+_P(%rip), %rax + movzbl %cl, %r9d + lea _P(%rip), %rdx + movq __libm_rcp_table_256@GOTPCREL(%rip), %rcx + lea _LN2(%rip), %rdi + movsd -24(%rsp), %xmm2 + shrl $20, %esi + addl $-1023, %esi + cvtss2sd (%rcx,%r9,4), %xmm0 + mulsd -16(%rsp), %xmm2 + mulsd %xmm0, %xmm2 + movsd (%rax), %xmm0 + addsd %xmm1, %xmm2 + mulsd %xmm2, %xmm0 + pxor %xmm1, %xmm1 + cvtsi2sd %esi, %xmm1 + addsd (%rdx), %xmm0 + mulsd (%rdi), %xmm1 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm0 + movq __libm_logf_table_256@GOTPCREL(%rip), %r8 + addsd %xmm2, %xmm0 + addsd (%r8,%r9,8), %xmm1 + movsd %xmm2, -24(%rsp) + addsd %xmm1, %xmm0 +..B1.4: + ret + .align 16,0x90 + .cfi_endproc + .type __libm_log_k32,@function + .size __libm_log_k32,.-__libm_log_k32 + .data +# -- End __libm_log_k32 + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 4 +_Q: + .long 4294868184 + .long 3219128319 + .long 1443356411 + .long 1070945621 + .long 823147527 + .long 3218079745 + .long 748089218 + .long 1070176642 + .long 1053536005 + .long 3217353219 + .type _Q,@object + .size _Q,40 + .align 4 +_P: + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .type _P,@object + .size _P,16 + .align 4 +_LN2: + .long 4277811695 + .long 1072049730 + .type _LN2,@object + .size _LN2,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_log_k64.S b/external/sgx_libm/intel64/libm_log_k64.S new file mode 100644 index 0000000000..2e67ca75b5 --- /dev/null +++ b/external/sgx_libm/intel64/libm_log_k64.S @@ -0,0 +1,632 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_log_k64.c" + .text +..TXTST0: +# -- Begin __libm_log_k64 + .text + .align 16,0x90 + .globl __libm_log_k64 +__libm_log_k64: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +# parameter 3: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_log_k64.1: +..L2: + + movaps %xmm1, %xmm6 + movsd %xmm0, -24(%rsp) + movzwl -18(%rsp), %esi + andl $32752, %esi + shrl $4, %esi + cmpl $2047, %esi + jge ..B1.12 +..B1.2: + testl %esi, %esi + jne ..B1.6 +..B1.3: + testl $1048575, -20(%rsp) + jne ..B1.6 +..B1.4: + cmpl $0, -24(%rsp) + jne ..B1.6 +..B1.5: + lea 1640+_libm_log_k64_table(%rip), %rax + lea 1624+_libm_log_k64_table(%rip), %rcx + movq (%rax), %rdx + movq (%rcx), %rsi + movq %rdx, (%rdi) + movq %rsi, 8(%rdi) + ret +..B1.6: + testb $-128, -17(%rsp) + jne ..B1.11 +..B1.7: + movsd -24(%rsp), %xmm4 + testl %esi, %esi + jne ..B1.9 +..B1.8: + lea 1656+_libm_log_k64_table(%rip), %rax + pxor %xmm9, %xmm9 + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm6 + movsd %xmm4, -24(%rsp) + movzwl -18(%rsp), %esi + andl $32752, %esi + shrl $4, %esi + addl $-1076, %esi + cvtsi2sd %esi, %xmm9 + jmp ..B1.10 +..B1.9: + addl $-1023, %esi + pxor %xmm9, %xmm9 + cvtsi2sd %esi, %xmm9 +..B1.10: + lea 1616+_libm_log_k64_table(%rip), %rcx + negl %esi + addl $1023, %esi + lea 1664+_libm_log_k64_table(%rip), %rax + andl $2047, %esi + lea _libm_log_k64_table(%rip), %r11 + shll $4, %esi + lea 1672+_libm_log_k64_table(%rip), %rdx + movzwl 6(%rcx), %r8d + movsd (%rcx), %xmm5 + andl $-32753, %r8d + movsd %xmm5, -16(%rsp) + orl %esi, %r8d + movw %r8w, -10(%rsp) + lea 1680+_libm_log_k64_table(%rip), %rsi + movsd (%rax), %xmm7 + lea 1688+_libm_log_k64_table(%rip), %rax + movsd -16(%rsp), %xmm1 + lea 1600+_libm_log_k64_table(%rip), %rcx + movsd (%rdx), %xmm0 + lea 1608+_libm_log_k64_table(%rip), %rdx + movsd (%rsi), %xmm2 + lea 1592+_libm_log_k64_table(%rip), %rsi + movsd (%rax), %xmm3 + lea 1584+_libm_log_k64_table(%rip), %r8 + movaps %xmm3, %xmm8 + lea 1560+_libm_log_k64_table(%rip), %rax + mulsd %xmm1, %xmm4 + mulsd %xmm1, %xmm6 + mulsd %xmm9, %xmm7 + addsd %xmm4, %xmm8 + mulsd %xmm0, %xmm9 + addsd %xmm4, %xmm2 + subsd %xmm3, %xmm8 + movsd %xmm2, -8(%rsp) + subsd %xmm8, %xmm4 + movl -8(%rsp), %r9d + addsd %xmm4, %xmm6 + andl $127, %r9d + movsd %xmm8, -24(%rsp) + movsd (%rdx), %xmm4 + lea (%r9,%r9,2), %r10d + lea 1576+_libm_log_k64_table(%rip), %r9 + movsd (%r11,%r10,8), %xmm10 + mulsd %xmm10, %xmm8 + addsd 8(%r11,%r10,8), %xmm7 + addsd 16(%r11,%r10,8), %xmm9 + mulsd %xmm6, %xmm10 + subsd %xmm5, %xmm8 + movaps %xmm8, %xmm6 + lea 1568+_libm_log_k64_table(%rip), %r11 + addsd %xmm10, %xmm6 + addsd %xmm9, %xmm10 + addsd %xmm7, %xmm8 + mulsd %xmm6, %xmm4 + movsd %xmm8, (%rdi) + addsd (%rcx), %xmm4 + mulsd %xmm6, %xmm4 + addsd (%rsi), %xmm4 + mulsd %xmm6, %xmm4 + addsd (%r8), %xmm4 + mulsd %xmm6, %xmm4 + addsd (%r9), %xmm4 + mulsd %xmm6, %xmm4 + addsd (%r11), %xmm4 + mulsd %xmm6, %xmm4 + mulsd %xmm6, %xmm6 + addsd (%rax), %xmm4 + mulsd %xmm4, %xmm6 + addsd %xmm6, %xmm10 + movsd %xmm10, 8(%rdi) + ret +..B1.11: + lea 1648+_libm_log_k64_table(%rip), %rax + movq (%rax), %rdx + movq %rdx, (%rdi) + movq %rdx, 8(%rdi) + ret +..B1.12: + lea 1632+_libm_log_k64_table(%rip), %rax + lea 1624+_libm_log_k64_table(%rip), %rdx + movsd -24(%rsp), %xmm0 + movq (%rdx), %rcx + movq %rcx, 8(%rdi) + addsd (%rax), %xmm0 + movsd %xmm0, (%rdi) +..B1.13: + ret + .align 16,0x90 + .cfi_endproc + .type __libm_log_k64,@function + .size __libm_log_k64,.-__libm_log_k64 + .data +# -- End __libm_log_k64 + .section .rodata, "a" + .align 16 + .align 16 +_libm_log_k64_table: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072660480 + .long 1486880768 + .long 1066410070 + .long 1813744607 + .long 3179892593 + .long 0 + .long 1072629760 + .long 377487360 + .long 1067416219 + .long 919019713 + .long 3179241129 + .long 0 + .long 1072599040 + .long 1513619456 + .long 1067944025 + .long 874573033 + .long 3178512940 + .long 0 + .long 1072570368 + .long 3221749760 + .long 1068427825 + .long 4181665006 + .long 3177478212 + .long 0 + .long 1072541696 + .long 4162322432 + .long 1068708823 + .long 627020255 + .long 1028629941 + .long 0 + .long 1072513024 + .long 183107584 + .long 1068957907 + .long 2376703469 + .long 1030233118 + .long 0 + .long 1072486400 + .long 1053425664 + .long 1069192557 + .long 696277142 + .long 1030474863 + .long 0 + .long 1072459776 + .long 3996123136 + .long 1069430535 + .long 2630798680 + .long 1028792016 + .long 0 + .long 1072435200 + .long 3452764160 + .long 1069600382 + .long 624954044 + .long 3177101741 + .long 0 + .long 1072409600 + .long 207650816 + .long 1069717971 + .long 3272735636 + .long 3175176575 + .long 0 + .long 1072386048 + .long 2647228416 + .long 1069827627 + .long 3594228712 + .long 1029303785 + .long 0 + .long 1072362496 + .long 2712010752 + .long 1069938736 + .long 3653242769 + .long 3176839013 + .long 0 + .long 1072338944 + .long 374439936 + .long 1070051337 + .long 4072775574 + .long 3176577495 + .long 0 + .long 1072316416 + .long 3707174912 + .long 1070160474 + .long 1486946159 + .long 1023930920 + .long 0 + .long 1072294912 + .long 1443954688 + .long 1070265993 + .long 293532967 + .long 3176278277 + .long 0 + .long 1072273408 + .long 127762432 + .long 1070372856 + .long 3404145447 + .long 3177023955 + .long 0 + .long 1072252928 + .long 2053832704 + .long 1070475911 + .long 1575076358 + .long 1029048544 + .long 0 + .long 1072232448 + .long 3194093568 + .long 1070580248 + .long 1864169120 + .long 1026866084 + .long 0 + .long 1072212992 + .long 3917201408 + .long 1070638340 + .long 2362145246 + .long 3175606197 + .long 0 + .long 1072193536 + .long 3417112576 + .long 1070689116 + .long 70087871 + .long 3174183577 + .long 0 + .long 1072175104 + .long 4226777088 + .long 1070737793 + .long 1620410586 + .long 3174700065 + .long 0 + .long 1072156672 + .long 3168870400 + .long 1070787042 + .long 311238082 + .long 1025781772 + .long 0 + .long 1072139264 + .long 2150580224 + .long 1070834092 + .long 1664262457 + .long 3175299224 + .long 0 + .long 1072120832 + .long 4095672320 + .long 1070884491 + .long 1657121015 + .long 3174674199 + .long 0 + .long 1072104448 + .long 2595577856 + .long 1070929805 + .long 2014006823 + .long 3175423830 + .long 0 + .long 1072087040 + .long 3747176448 + .long 1070978493 + .long 144991708 + .long 3171552042 + .long 0 + .long 1072070656 + .long 1050435584 + .long 1071024840 + .long 3386227432 + .long 1027876916 + .long 0 + .long 1072055296 + .long 255516672 + .long 1071068760 + .long 2637594316 + .long 1028049573 + .long 0 + .long 1072038912 + .long 1640783872 + .long 1071116120 + .long 893247007 + .long 1028452162 + .long 0 + .long 1072023552 + .long 2940411904 + .long 1071161011 + .long 813240633 + .long 1027664048 + .long 0 + .long 1072009216 + .long 882917376 + .long 1071203348 + .long 2376597551 + .long 3175828767 + .long 0 + .long 1071993856 + .long 213966848 + .long 1071249188 + .long 2977204125 + .long 1028350609 + .long 0 + .long 1071979520 + .long 2921504768 + .long 1071292428 + .long 523218347 + .long 1028007004 + .long 0 + .long 1071965184 + .long 3186655232 + .long 1071336119 + .long 2352907891 + .long 1026967097 + .long 0 + .long 1071951872 + .long 2653364224 + .long 1071377101 + .long 2453418583 + .long 3174349512 + .long 0 + .long 1071938560 + .long 3759783936 + .long 1071418487 + .long 3685870403 + .long 3175415611 + .long 0 + .long 1071925248 + .long 2468364288 + .long 1071460286 + .long 1578908842 + .long 3175510517 + .long 0 + .long 1071911936 + .long 81903616 + .long 1071502506 + .long 770710269 + .long 1026742353 + .long 0 + .long 1071899648 + .long 2799321088 + .long 1071541858 + .long 3822266185 + .long 1028434427 + .long 0 + .long 1071886336 + .long 2142265344 + .long 1071584911 + .long 175901806 + .long 3173871540 + .long 0 + .long 1071874048 + .long 2944024576 + .long 1071625048 + .long 2747360403 + .long 1027672159 + .long 0 + .long 1071862784 + .long 3434301440 + .long 1071653426 + .long 4194662196 + .long 3173893003 + .long 0 + .long 1071850496 + .long 1547755520 + .long 1071673870 + .long 4248764681 + .long 3172759087 + .long 0 + .long 1071839232 + .long 4246986752 + .long 1071692786 + .long 2840205638 + .long 3174430911 + .long 0 + .long 1071826944 + .long 3418390528 + .long 1071713619 + .long 3041880823 + .long 1025440860 + .long 0 + .long 1071816704 + .long 4143093760 + .long 1071731139 + .long 2727587401 + .long 3173965207 + .long 0 + .long 1071805440 + .long 3121326080 + .long 1071750582 + .long 3173887692 + .long 3174190163 + .long 0 + .long 1071794176 + .long 1852893184 + .long 1071770207 + .long 3951060252 + .long 1027348295 + .long 0 + .long 1071783936 + .long 3636379648 + .long 1071788208 + .long 1684924001 + .long 3174777086 + .long 0 + .long 1071773696 + .long 516505600 + .long 1071806366 + .long 429181199 + .long 3173211033 + .long 0 + .long 1071763456 + .long 4186185728 + .long 1071824681 + .long 2044904577 + .long 3174967132 + .long 0 + .long 1071753216 + .long 877596672 + .long 1071843159 + .long 1396318105 + .long 3173959727 + .long 0 + .long 1071742976 + .long 2912784384 + .long 1071861800 + .long 448136789 + .long 3174814192 + .long 0 + .long 1071733760 + .long 3722825728 + .long 1071878720 + .long 714165913 + .long 3173439560 + .long 0 + .long 1071723520 + .long 2522374144 + .long 1071897682 + .long 3227240353 + .long 3173394323 + .long 0 + .long 1071714304 + .long 4165410816 + .long 1071914895 + .long 1365684961 + .long 3174365060 + .long 0 + .long 1071705088 + .long 3477135360 + .long 1071932251 + .long 368482985 + .long 3174140821 + .long 0 + .long 1071695872 + .long 2079455232 + .long 1071949752 + .long 1320576317 + .long 1026822714 + .long 0 + .long 1071687680 + .long 851795968 + .long 1071965432 + .long 3702467026 + .long 1025224125 + .long 0 + .long 1071678464 + .long 647743488 + .long 1071983213 + .long 772992109 + .long 3174038459 + .long 0 + .long 1071670272 + .long 26537984 + .long 1071999146 + .long 2360214276 + .long 3174861275 + .long 0 + .long 1071661056 + .long 1547061248 + .long 1072017216 + .long 2886781435 + .long 1026423395 + .long 0 + .long 1071652864 + .long 2854492160 + .long 1072033410 + .long 215631550 + .long 1025638968 + .long 0 + .long 1071644672 + .long 4277811200 + .long 1072049730 + .long 2479318832 + .long 1026487127 + .long 0 + .long 3219128320 + .long 1431655955 + .long 1070945621 + .long 610 + .long 3218079744 + .long 2545118337 + .long 1070176665 + .long 1378399119 + .long 3217380693 + .long 612435357 + .long 1069697472 + .long 94536557 + .long 3217031348 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .long 0 + .long 4294443008 + .long 0 + .long 1128267776 + .long 4277811200 + .long 1072049730 + .long 2479318832 + .long 1026487127 + .long 64 + .long 1120927744 + .long 0 + .long 1094713344 + .type _libm_log_k64_table,@object + .size _libm_log_k64_table,1696 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_logl.S b/external/sgx_libm/intel64/libm_logl.S new file mode 100644 index 0000000000..f2b01ecfb2 --- /dev/null +++ b/external/sgx_libm/intel64/libm_logl.S @@ -0,0 +1,778 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_logl.c" + .text +..TXTST0: +# -- Begin __libm_logl + .text + .align 16,0x90 + .globl __libm_logl +__libm_logl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value___libm_logl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %sil, %sil +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzbl 57(%rsp), %r8d + andl $128, %r8d + shrl $7, %r8d + movzwl 56(%rsp), %eax + movl %eax, %edx + movl %r8d, %edi + andl $32767, %edx + shll $15, %edi + orl %edx, %edi + shll $16, %edi + movzwl 54(%rsp), %ecx + orl %ecx, %edi + cmpl $2147450880, %edi + jae ..B1.31 +..B1.4: + lea -1073674240(%rdi), %ecx + cmpl $36864, %ecx + ja ..B1.21 +..B1.5: + addl $-1073676287, %edi + cmpl $32769, %edi + ja ..B1.14 +..B1.6: + cmpl $16383, %edx + je ..B1.40 +..B1.7: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.11 +..B1.8: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.9: + fldcw 32(%rsp) +..B1.10: + movb $1, %sil +..B1.11: + fldt 48(%rsp) + lea 8+_ones(%rip), %rax + lea 48+_Q1(%rip), %rdx + lea 16+_Q1(%rip), %rcx + lea 32+_Q1(%rip), %rdi + lea _Q1(%rip), %r8 + testb %sil, %sil + faddl (%rax) + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%rdx) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fmul %st(1), %st + fldt (%rdi) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.13 +..B1.12: + fldcw 34(%rsp) +..B1.13: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.14: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.18 +..B1.15: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.16: + fldcw 32(%rsp) +..B1.17: + movb $1, %sil +..B1.18: + fldt 48(%rsp) + lea 8+_ones(%rip), %rax + lea _TWO_52H(%rip), %rdx + lea 208+_Q2(%rip), %rcx + lea 176+_Q2(%rip), %rdi + lea 144+_Q2(%rip), %r8 + lea 112+_Q2(%rip), %r9 + lea 80+_Q2(%rip), %r10 + lea 48+_Q2(%rip), %r11 + testb %sil, %sil + fldl (%rdx) + lea 192+_Q2(%rip), %rdx + fldt (%rcx) + lea 160+_Q2(%rip), %rcx + fldt (%rdi) + lea 128+_Q2(%rip), %rdi + fxch %st(3) + faddl (%rax) + lea 16+_Q2(%rip), %rax + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fld %st(1) + fsub %st(4), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fmul %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fld %st(0) + fld %st(4) + fmul %st(5), %st + fadd %st, %st(1) + fxch %st(1) + fmul %st, %st(4) + fxch %st(6) + faddp %st, %st(4) + fxch %st(3) + fmul %st(5), %st + fxch %st(2) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%r8) + lea 96+_Q2(%rip), %r8 + faddp %st, %st(3) + fxch %st(2) + fmul %st(5), %st + fldt (%r9) + lea 64+_Q2(%rip), %r9 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r10) + lea 32+_Q2(%rip), %r10 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r11) + lea _Q2(%rip), %r11 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rax) + lea 240+_Q2(%rip), %rax + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rdx) + lea 224+_Q2(%rip), %rdx + fmul %st(6), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(6) + fldt (%r11) + faddp %st, %st(6) + fxch %st(2) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fldt (%rax) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(1) + fld %st(1) + fldt (%rdx) + fld %st(0) + fmul %st(4), %st + faddp %st, %st(3) + fldt 16(%rsp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(5) + fxch %st(1) + fmul %st(4), %st + fxch %st(2) + fadd %st, %st(4) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.20 +..B1.19: + fldcw 34(%rsp) +..B1.20: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.21: + movzwl 34(%rsp), %edi + movl %edi, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.25 +..B1.22: + orl $-64768, %edi + movw %di, 32(%rsp) +..B1.23: + fldcw 32(%rsp) +..B1.24: + movzwl 56(%rsp), %eax + movl %eax, %edx + movb $1, %sil + andl $32767, %edx +..B1.25: + movl $-16383, %ecx + testl %edx, %edx + jne ..B1.28 +..B1.26: + fldt 48(%rsp) + lea _TWO_75(%rip), %rcx + lea _zeros(%rip), %rax + fmull (%rcx) + movl $-16458, %ecx + fstpt 48(%rsp) + fldt 48(%rsp) + fldl (%rax) + movsd (%rax), %xmm0 + fucomip %st(1), %st + fstp %st(0) + jp ..B1.27 + je ..B1.42 +..B1.27: + movzwl 56(%rsp), %eax + movl %eax, %edx + andl $32767, %edx +..B1.28: + lea _TWO_32H(%rip), %rdi + andl $-32768, %eax + orl $-49153, %eax + addl %edx, %ecx + movw %ax, 56(%rsp) + lea 8+_ones(%rip), %r9 + fldt 48(%rsp) + lea 48+_P(%rip), %r10 + fld %st(0) + lea 16+_P(%rip), %r11 + fldl (%rdi) + lea _P(%rip), %rdi + movl 52(%rsp), %edx + fadd %st, %st(1) + shrl $23, %edx + fsubrp %st, %st(1) + movzbl %dl, %eax + lea 64+_P(%rip), %rdx + movq __libm_rcp_table_256@GOTPCREL(%rip), %r8 + fsubr %st, %st(1) + flds (%r8,%rax,4) + fmul %st, %st(1) + fmulp %st, %st(2) + faddl (%r9) + fld %st(0) + movl %ecx, 16(%rsp) + lea 80+_P(%rip), %rcx + shlq $4, %rax + fadd %st(2), %st + fld %st(0) + testb %sil, %sil + fmul %st(1), %st + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fildl 16(%rsp) + fldt (%rcx) + lea 32+_P(%rip), %rcx + fmul %st(3), %st + fldt (%r10) + movq __libm_logl_table_256@GOTPCREL(%rip), %r8 + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(3), %st + fmulp %st, %st(2) + fldt (%rdx) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.0(%rip) + fmul %st(1), %st + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(2) + faddl 8(%r8,%rax) + faddp %st, %st(3) + faddl (%rax,%r8) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.30 +..B1.29: + fldcw 34(%rsp) +..B1.30: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.31: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.35 +..B1.32: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.33: + fldcw 32(%rsp) +..B1.34: + movzbl 57(%rsp), %r8d + movb $1, %sil + andl $128, %r8d + shrl $7, %r8d +..B1.35: + testl %r8d, %r8d + jne ..B1.45 +..B1.36: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.37: + testb %sil, %sil + je ..B1.39 +..B1.38: + fldcw 34(%rsp) +..B1.39: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.40: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.7 +..B1.41: + lea _zeros(%rip), %rax + fldl (%rax) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.42: + lea 8+_ones(%rip), %rax + testb %sil, %sil + movsd (%rax), %xmm1 + divsd %xmm0, %xmm1 + je ..B1.44 +..B1.43: + fldcw 34(%rsp) +..B1.44: + movsd %xmm1, 16(%rsp) + fldl 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.45: + movzwl 56(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.47 +..B1.46: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.36 + jmp ..B1.50 +..B1.47: + testl %eax, %eax + jne ..B1.50 +..B1.48: + cmpq $0, 48(%rsp) + jne ..B1.50 +..B1.49: + lea 8+_ones(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + divsd (%rdx), %xmm0 + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + jmp ..B1.37 +..B1.50: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + jmp ..B1.37 + .align 16,0x90 + .cfi_endproc + .type __libm_logl,@function + .size __libm_logl,.-__libm_logl + .data +# -- End __libm_logl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q1: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 5458 + .word 43692 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 44682 + .word 49156 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 63914 + .word 24446 + .word 52434 + .word 52426 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q2: + .word 58950 + .word 11767 + .word 59949 + .word 40744 + .word 49076 + .word 0 + .word 0 + .word 0 + .word 44486 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 65514 + .word 65535 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 49718 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 36693 + .word 43691 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41156 + .word 18852 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 14101 + .word 65290 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 21744 + .word 48151 + .word 14557 + .word 58254 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 57454 + .word 983 + .word 52353 + .word 52428 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 54021 + .word 59409 + .word 39452 + .word 47662 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 35608 + .word 4659 + .word 11214 + .word 43692 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 35524 + .word 31332 + .word 8749 + .word 40326 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 54832 + .word 20873 + .word 17674 + .word 36915 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 48567 + .word 9481 + .word 46911 + .word 55870 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,256 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,96 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_logl_k80.S b/external/sgx_libm/intel64/libm_logl_k80.S new file mode 100644 index 0000000000..bbc390e8e7 --- /dev/null +++ b/external/sgx_libm/intel64/libm_logl_k80.S @@ -0,0 +1,966 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_logl_k80.c" + .text +..TXTST0: +# -- Begin __libm_log_k80 + .text + .align 16,0x90 + .globl __libm_log_k80 +__libm_log_k80: +# parameter 1: %rdi +# parameter 2: %rsi +..B1.1: + .cfi_startproc +..___tag_value___libm_log_k80.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + subq $88, %rsp + .cfi_def_cfa_offset 112 + movq %rsi, %r12 + movq %rdi, %r13 + movq %r12, %rdi + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 80(%rsp) +..___tag_value___libm_log_k80.8: + call __libm_normalizel_k80@PLT +..___tag_value___libm_log_k80.9: +..B1.2: + fldt (%r12) + fldt 16(%r12) + movl 32(%r12), %eax + cmpl $-1, %eax + je ..B1.15 +..B1.3: + movl %eax, 16(%rsp) + fildl 16(%rsp) + fstpt (%rsp) +..B1.4: + addq $-32, %rsp + .cfi_def_cfa_offset 144 + lea 48(%rsp), %rdi + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_log_k80.11: + call __libm_logl_k80@PLT +..___tag_value___libm_log_k80.12: +..B1.18: + addq $32, %rsp + .cfi_def_cfa_offset 112 +..B1.5: + fldt 16(%rsp) + lea _LN2_K80(%rip), %rax + lea 16+_LN2_K80(%rip), %rdx + fmul %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fldt 32(%rsp) + fmulp %st, %st(2) + movzwl 24(%rsp), %esi + andl $32767, %esi + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + fldt (%rax) + fldt (%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fld %st(0) + movzwl 56(%rsp), %ecx + fadd %st(4), %st + fldt (%rdx) + andl $32767, %ecx + fmulp %st, %st(3) + cmpl %esi, %ecx + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + movl $0, 32(%r13) + jg ..B1.10 +..B1.6: + jne ..B1.11 +..B1.7: + movl 52(%rsp), %eax + movl 20(%rsp), %edx + cmpl %edx, %eax + ja ..B1.10 +..B1.8: + jne ..B1.11 +..B1.9: + movl 48(%rsp), %eax + cmpl 16(%rsp), %eax + jbe ..B1.11 +..B1.10: + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.12 +..B1.11: + fxch %st(2) + fsubr %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) +..B1.12: + fld %st(1) + fadd %st(1), %st + fstpt (%r13) + fldt (%r13) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%r13) + movq 80(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.14 +..B1.13: + addq $88, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.14: + call __stack_chk_fail@PLT +..B1.15: + lea _zeros(%rip), %rax + lea halfs(%rip), %rdx + fldl (%rax) + fstpt (%rsp) + fldt (%rdx) + fmul %st, %st(2) + fmulp %st, %st(1) + jmp ..B1.4 + .align 16,0x90 + .cfi_endproc + .type __libm_log_k80,@function + .size __libm_log_k80,.-__libm_log_k80 + .data +# -- End __libm_log_k80 + .text +# -- Begin __libm_logl_k80 + .text + .align 16,0x90 + .globl __libm_logl_k80 +__libm_logl_k80: +# parameter 1: 8 + %rsp +# parameter 2: 24 + %rsp +# parameter 3: %rdi +..B2.1: + .cfi_startproc +..___tag_value___libm_logl_k80.23: +..L24: + + fldt 8(%rsp) + movzbl 17(%rsp), %r9d + andl $128, %r9d + shrl $7, %r9d + movzwl 16(%rsp), %ecx + movl %ecx, %eax + movl %r9d, %r8d + andl $32767, %eax + shll $15, %r8d + movl 12(%rsp), %edx + orl %eax, %r8d + movl %edx, %esi + shll $16, %r8d + shrl $16, %esi + orl %esi, %r8d + fstpt -24(%rsp) + fldt -24(%rsp) + cmpl $2147450880, %r8d + fldt 24(%rsp) + jae ..B2.14 +..B2.2: + lea -1073674240(%r8), %esi + cmpl $36864, %esi + ja ..B2.8 +..B2.3: + addl $-1073676287, %r8d + cmpl $32769, %r8d + ja ..B2.7 +..B2.4: + lea _ones(%rip), %rax + fldl (%rax) + fucomi %st(2), %st + jne ..B2.6 + jp ..B2.6 +..B2.5: + lea _zeros(%rip), %rax + fldl (%rax) + fucomi %st(2), %st + jp ..B2.27 + je ..B2.23 +..B2.27: + fstp %st(0) +..B2.6: + fld %st(2) + lea 48+_Q1(%rip), %rax + lea 16+_Q1(%rip), %rdx + lea 32+_Q1(%rip), %rcx + lea _Q1(%rip), %rsi + fsub %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubrp %st, %st(4) + faddp %st, %st(3) + fld %st(1) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsub %st, %st(4) + fxch %st(4) + fsubrp %st, %st(3) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(2), %st + fmulp %st, %st(1) + fldt (%rcx) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(3) + fadd %st(1), %st + fstpt (%rdi) + fldt (%rdi) + fsubrp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 16(%rdi) + ret +..B2.7: + lea 8+_ones(%rip), %rax + fld %st(1) + lea _TWO_52H(%rip), %rdx + lea 208+_Q2(%rip), %rcx + lea 176+_Q2(%rip), %rsi + lea 144+_Q2(%rip), %r8 + lea 112+_Q2(%rip), %r9 + lea 80+_Q2(%rip), %r10 + fldl (%rax) + lea 48+_Q2(%rip), %r11 + lea 16+_Q2(%rip), %rax + fadd %st, %st(1) + fld %st(1) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fld %st(0) + fld %st(1) + fxch %st(2) + fstpt -24(%rsp) + fldt -24(%rsp) + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fldl (%rdx) + fmul %st(4), %st + lea 192+_Q2(%rip), %rdx + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fld %st(1) + fmul %st(2), %st + fxch %st(2) + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + fstpt -56(%rsp) + fldt -56(%rsp) + fmul %st, %st(2) + fmul %st(4), %st + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fldt (%rcx) + fmul %st(1), %st + lea 160+_Q2(%rip), %rcx + fldt (%rsi) + lea 128+_Q2(%rip), %rsi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + lea 96+_Q2(%rip), %r8 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + lea 64+_Q2(%rip), %r9 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + lea 32+_Q2(%rip), %r10 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + lea _Q2(%rip), %r11 + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + lea 240+_Q2(%rip), %rax + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx) + lea 224+_Q2(%rip), %rdx + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r11) + faddp %st, %st(2) + fxch %st(5) + fmulp %st, %st(1) + faddp %st, %st(4) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fmulp %st, %st(1) + fld %st(1) + fldt (%rdx) + fld %st(0) + fmul %st(4), %st + faddp %st, %st(3) + fldt -56(%rsp) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(5) + fxch %st(1) + fmul %st(4), %st + fxch %st(2) + fadd %st, %st(4) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fstpt (%rdi) + fldt (%rdi) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rdi) + lea _ones(%rip), %rdi + fldl (%rdi) + ret +..B2.8: + lea _zeros(%rip), %r8 + movl $-16383, %esi + testl %eax, %eax + fldl (%r8) + movsd (%r8), %xmm0 + jne ..B2.11 +..B2.9: + lea _TWO_75(%rip), %rax + movl $-16458, %esi + fldl (%rax) + fmul %st, %st(3) + fxch %st(3) + fucomi %st(1), %st + fxch %st(3) + fmulp %st, %st(2) + jp ..B2.10 + je ..B2.24 +..B2.10: + fxch %st(2) + fstpt -24(%rsp) + fldt -24(%rsp) + movzwl -16(%rsp), %ecx + movl %ecx, %eax + movl -20(%rsp), %edx + andl $32767, %eax + fxch %st(2) +..B2.11: + fstp %st(2) + addl %eax, %esi + fucomi %st(1), %st + fxch %st(1) + fstp %st(0) + jp ..B2.12 + je ..B2.13 +..B2.12: + fstpt -56(%rsp) + movzwl -48(%rsp), %r8d + movl %r8d, %r9d + subl %eax, %r8d + andl $-32768, %r9d + addl $16383, %r8d + andl $32767, %r8d + orl %r8d, %r9d + movw %r9w, -48(%rsp) + fldt -56(%rsp) +..B2.13: + shrl $23, %edx + andl $-32768, %ecx + movzbl %dl, %eax + lea _TWO_32H(%rip), %rdx + orl $-49153, %ecx + lea 8+_ones(%rip), %r8 + movw %cx, -16(%rsp) + lea 48+_P(%rip), %r9 + fldt -24(%rsp) + lea 16+_P(%rip), %r10 + fld %st(0) + lea 64+_P(%rip), %r11 + fldl (%rdx) + lea 32+_P(%rip), %rdx + movq __libm_rcp_table_256@GOTPCREL(%rip), %rcx + fadd %st, %st(1) + movl %esi, -40(%rsp) + lea 80+_P(%rip), %rsi + fsubrp %st, %st(1) + fsubr %st, %st(1) + flds (%rcx,%rax,4) + fmul %st, %st(1) + fmul %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + fstpt -56(%rsp) + fldt -56(%rsp) + lea _P(%rip), %rcx + shlq $4, %rax + faddp %st, %st(1) + fldl (%r8) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + fildl -40(%rsp) + fldt (%rsi) + fmul %st(3), %st + fldt (%r9) + movq __libm_logl_table_256@GOTPCREL(%rip), %rsi + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(3), %st + fmulp %st, %st(2) + fldt (%r11) + fmul %st(3), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(1), %st + fldt .L_2il0floatpacket.3(%rip) + fmulp %st, %st(2) + faddl 8(%rsi,%rax) + faddp %st, %st(2) + faddl (%rax,%rsi) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt (%rdi) + fldt (%rdi) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rdi) + lea _ones(%rip), %rdi + fldl (%rdi) + ret +..B2.14: + fstp %st(0) + testl %r9d, %r9d + jne ..B2.16 +..B2.15: + lea _ones(%rip), %rax + lea _zeros(%rip), %rdx + fldl (%rax) + fmul %st, %st(1) + movsd (%rdx), %xmm1 + fxch %st(1) + jmp ..B2.21 +..B2.16: + cmpl $32767, %eax + je ..B2.22 +..B2.17: + fstp %st(0) + testl %eax, %eax + jne ..B2.20 +..B2.18: + cmpq $0, -24(%rsp) + jne ..B2.20 +..B2.19: + lea _zeros(%rip), %rax + lea 8+_ones(%rip), %rdx + lea _ones(%rip), %rcx + movsd (%rax), %xmm1 + fldl (%rcx) + movsd (%rdx), %xmm0 + divsd %xmm1, %xmm0 + movsd %xmm0, -40(%rsp) + fldl -40(%rsp) + jmp ..B2.21 +..B2.20: + lea _zeros(%rip), %rax + lea _infs(%rip), %rdx + lea _ones(%rip), %rcx + movsd (%rax), %xmm1 + fldl (%rcx) + movsd (%rdx), %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, -40(%rsp) + fldl -40(%rsp) +..B2.21: + movsd %xmm1, -40(%rsp) + fstpt (%rdi) + fldl -40(%rsp) + fstpt 16(%rdi) + ret +..B2.22: + movq $0x8000000000000000, %rax + cmpq -24(%rsp), %rax + jne ..B2.15 + jmp ..B2.28 +..B2.23: + fstp %st(1) + fstp %st(2) + fstp %st(0) + fstpt (%rdi) + fldt (%rdi) + fld %st(0) + fxch %st(1) + fstpt 16(%rdi) + ret +..B2.24: + fstp %st(2) + fstp %st(0) + lea 8+_ones(%rip), %rax + lea _ones(%rip), %rdx + fstpt 16(%rdi) + movsd (%rax), %xmm1 + divsd %xmm0, %xmm1 + movsd %xmm1, -40(%rsp) + fldl -40(%rsp) + fstpt (%rdi) + fldl (%rdx) + ret +..B2.28: + fstp %st(0) + jmp ..B2.20 + .align 16,0x90 + .cfi_endproc + .type __libm_logl_k80,@function + .size __libm_logl_k80,.-__libm_logl_k80 + .data +# -- End __libm_logl_k80 + .section .rodata, "a" + .align 16 + .align 16 +halfs: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type halfs,@object + .size halfs,32 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_LN2_K80: + .word 0 + .word 0 + .word 6136 + .word 45426 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 12704 + .word 55409 + .word 6480 + .word 47298 + .word 49116 + .word 0 + .word 0 + .word 0 + .type _LN2_K80,@object + .size _LN2_K80,32 + .align 2 +_Q1: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 5458 + .word 43692 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 44682 + .word 49156 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 63914 + .word 24446 + .word 52434 + .word 52426 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q2: + .word 58950 + .word 11767 + .word 59949 + .word 40744 + .word 49076 + .word 0 + .word 0 + .word 0 + .word 44486 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 65514 + .word 65535 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 49718 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 36693 + .word 43691 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41156 + .word 18852 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 14101 + .word 65290 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 21744 + .word 48151 + .word 14557 + .word 58254 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 57454 + .word 983 + .word 52353 + .word 52428 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 54021 + .word 59409 + .word 39452 + .word 47662 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 35608 + .word 4659 + .word 11214 + .word 43692 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 35524 + .word 31332 + .word 8749 + .word 40326 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 54832 + .word 20873 + .word 17674 + .word 36915 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 48567 + .word 9481 + .word 46911 + .word 55870 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,256 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,96 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_mul_k64.S b/external/sgx_libm/intel64/libm_mul_k64.S new file mode 100644 index 0000000000..fd242c56a3 --- /dev/null +++ b/external/sgx_libm/intel64/libm_mul_k64.S @@ -0,0 +1,320 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_mul_k64.c" + .text +..TXTST0: +# -- Begin __libm_mul_k64 + .text + .align 16,0x90 + .globl __libm_mul_k64 +__libm_mul_k64: +# parameter 1: %edi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +..B1.1: + .cfi_startproc +..___tag_value___libm_mul_k64.1: +..L2: + + movq %rdx, %rax + movzwl 6(%rsi), %edx + andl $32752, %edx + shrl $4, %edx + movsd (%rsi), %xmm3 + cmpl $2047, %edx + movsd 8(%rsi), %xmm7 + movsd (%rax), %xmm2 + movsd 8(%rax), %xmm4 + je ..B1.12 +..B1.2: + testl %edx, %edx + jne ..B1.7 +..B1.3: + testl $1048575, 4(%rsi) + jne ..B1.7 +..B1.4: + cmpl $0, (%rsi) + je ..B1.12 +..B1.7: + movsd %xmm2, -24(%rsp) +..B1.8: + movzwl -18(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $2047, %eax + je ..B1.12 +..B1.9: + testl %eax, %eax + jne ..B1.13 +..B1.10: + testl $1048575, -20(%rsp) + jne ..B1.13 +..B1.11: + cmpl $0, -24(%rsp) + jne ..B1.13 +..B1.12: + mulsd %xmm2, %xmm3 + movsd %xmm3, (%rcx) + ret +..B1.13: + testl %edx, %edx + jne ..B1.15 +..B1.14: + lea _CONSTANTS(%rip), %rdx + movaps %xmm3, %xmm1 + addl $-1023, %edi + movsd (%rdx), %xmm0 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm7 + jmp ..B1.16 +..B1.15: + lea 32+_CONSTANTS(%rip), %rsi + movl %edx, %r9d + negl %r9d + movaps %xmm3, %xmm1 + addl $-2, %r9d + lea -1023(%rdi,%rdx), %edi + andl $2047, %r9d + movq (%rsi), %r8 + movq %r8, -24(%rsp) + shrq $48, %r8 + shll $4, %r9d + andl $-32753, %r8d + orl %r9d, %r8d + movw %r8w, -18(%rsp) + movsd -24(%rsp), %xmm0 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm7 +..B1.16: + testl %eax, %eax + jne ..B1.18 +..B1.17: + lea _CONSTANTS(%rip), %rax + movaps %xmm2, %xmm8 + addl $-1023, %edi + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm8 + mulsd %xmm0, %xmm4 + jmp ..B1.19 +..B1.18: + lea 32+_CONSTANTS(%rip), %rdx + movl %eax, %r8d + negl %r8d + movaps %xmm2, %xmm8 + addl $-2, %r8d + lea -1023(%rdi,%rax), %edi + andl $2047, %r8d + movq (%rdx), %rsi + movq %rsi, -24(%rsp) + shrq $48, %rsi + shll $4, %r8d + andl $-32753, %esi + orl %r8d, %esi + movw %si, -18(%rsp) + movsd -24(%rsp), %xmm0 + mulsd %xmm0, %xmm8 + mulsd %xmm0, %xmm4 +..B1.19: + movaps %xmm7, %xmm0 + lea 16+_CONSTANTS(%rip), %rax + movaps %xmm4, %xmm10 + addsd %xmm1, %xmm0 + addsd %xmm8, %xmm10 + movaps %xmm0, %xmm5 + movaps %xmm0, %xmm9 + movaps %xmm10, %xmm11 + subsd %xmm1, %xmm5 + movsd (%rax), %xmm1 + subsd %xmm5, %xmm7 + mulsd %xmm1, %xmm9 + mulsd %xmm1, %xmm11 + movaps %xmm9, %xmm6 + subsd %xmm0, %xmm6 + subsd %xmm6, %xmm9 + movaps %xmm9, %xmm5 + subsd %xmm9, %xmm0 + addsd %xmm7, %xmm0 + movaps %xmm10, %xmm7 + subsd %xmm8, %xmm7 + movaps %xmm11, %xmm8 + movaps %xmm0, %xmm6 + subsd %xmm10, %xmm8 + subsd %xmm7, %xmm4 + subsd %xmm8, %xmm11 + mulsd %xmm11, %xmm0 + subsd %xmm11, %xmm10 + mulsd %xmm11, %xmm5 + addsd %xmm4, %xmm10 + mulsd %xmm10, %xmm6 + movaps %xmm5, %xmm4 + mulsd %xmm9, %xmm10 + addsd %xmm10, %xmm6 + addsd %xmm0, %xmm6 + addsd %xmm6, %xmm4 + movsd %xmm4, -16(%rsp) + movzwl -10(%rsp), %edx + movl %edx, %esi + andl $32752, %esi + shrl $4, %esi + lea (%rdi,%rsi), %eax + cmpl $2047, %eax + jl ..B1.21 +..B1.20: + lea _CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + mulsd %xmm3, %xmm0 + mulsd %xmm2, %xmm0 + movsd %xmm0, (%rcx) + ret +..B1.21: + testl %eax, %eax + jle ..B1.23 +..B1.22: + andl $2047, %eax + andl $-32753, %edx + shll $4, %eax + orl %eax, %edx + movw %dx, -10(%rsp) + movq -16(%rsp), %rax + movq %rax, (%rcx) + ret +..B1.23: + cmpl $-9, %eax + jl ..B1.25 +..B1.24: + lea 8+_CONSTANTS(%rip), %rax + lea 32+_CONSTANTS(%rip), %rsi + lea 24+_CONSTANTS(%rip), %rdx + addl $1423, %edi + andl $2047, %edi + shll $4, %edi + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movq (%rsi), %r8 + addsd %xmm0, %xmm5 + movaps %xmm5, %xmm4 + movq %r8, -24(%rsp) + addsd %xmm6, %xmm4 + mulsd %xmm4, %xmm1 + movaps %xmm4, %xmm2 + subsd %xmm5, %xmm2 + movaps %xmm1, %xmm5 + subsd %xmm2, %xmm6 + subsd %xmm4, %xmm5 + shrq $48, %r8 + subsd %xmm5, %xmm1 + andl $-32753, %r8d + subsd %xmm1, %xmm4 + orl %edi, %r8d + addsd %xmm6, %xmm4 + movsd (%rdx), %xmm6 + mulsd %xmm6, %xmm1 + mulsd %xmm6, %xmm4 + movw %r8w, -18(%rsp) + movsd -24(%rsp), %xmm3 + mulsd %xmm3, %xmm1 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm1 + movsd %xmm1, (%rcx) + ret +..B1.25: + cmpl $-62, %eax + jle ..B1.27 +..B1.26: + lea 32+_CONSTANTS(%rip), %rax + lea 1022(%rdi,%rsi), %esi + lea 8+_CONSTANTS(%rip), %rdi + andl $-32753, %edx + orl $16, %edx + andl $2047, %esi + movw %dx, -10(%rsp) + movq (%rax), %rdx + movsd (%rdi), %xmm0 + mulsd %xmm0, %xmm0 + movq %rdx, -24(%rsp) + shrq $48, %rdx + shll $4, %esi + andl $-32753, %edx + orl %esi, %edx + movw %dx, -18(%rsp) + movsd -16(%rsp), %xmm1 + addsd -24(%rsp), %xmm0 + mulsd %xmm0, %xmm1 + movsd %xmm0, -24(%rsp) + movsd %xmm1, -16(%rsp) + movsd %xmm1, (%rcx) + ret +..B1.27: + lea 8+_CONSTANTS(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + mulsd %xmm3, %xmm0 + mulsd %xmm2, %xmm0 + movsd %xmm0, (%rcx) +..B1.28: + ret + .align 16,0x90 + .cfi_endproc + .type __libm_mul_k64,@function + .size __libm_mul_k64,.-__libm_mul_k64 + .data +# -- End __libm_mul_k64 + .section .rodata, "a" + .align 16 + .align 16 +_CONSTANTS: + .long 0 + .long 2145386496 + .long 0 + .long 1048576 + .long 33554432 + .long 1101004800 + .long 0 + .long 653262848 + .long 0 + .long 1072693248 + .type _CONSTANTS,@object + .size _CONSTANTS,40 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_normalizel_k80.S b/external/sgx_libm/intel64/libm_normalizel_k80.S new file mode 100644 index 0000000000..c2071f0bac --- /dev/null +++ b/external/sgx_libm/intel64/libm_normalizel_k80.S @@ -0,0 +1,163 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_normalizel_k80.c" + .text +..TXTST0: +# -- Begin __libm_normalizel_k80 + .text + .align 16,0x90 + .globl __libm_normalizel_k80 +__libm_normalizel_k80: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_normalizel_k80.1: +..L2: + + cmpl $0, 4(%rdi) + jne ..B1.3 +..B1.2: + cmpl $0, (%rdi) + je ..B1.14 +..B1.3: + movzwl 8(%rdi), %eax + movl %eax, %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.14 +..B1.4: + testl %esi, %esi + jle ..B1.16 +..B1.5: + andl $-32768, %eax + addl $-16383, %esi + orl $-49153, %eax +..B1.6: + movw %ax, 8(%rdi) + cmpl $0, 20(%rdi) + jne ..B1.8 +..B1.7: + cmpl $0, 16(%rdi) + je ..B1.13 +..B1.8: + movzwl 24(%rdi), %edx + movl %edx, %ecx + andl $32767, %ecx + jle ..B1.15 +..B1.9: + andl $-32768, %edx + addl $-16383, %ecx + orl $-49153, %edx +..B1.10: + lea -256(%rsi), %eax + cmpl %eax, %ecx + jle ..B1.12 +..B1.11: + subl %esi, %ecx + andl $-32768, %edx + addl $16383, %ecx + andl $32767, %ecx + orl %ecx, %edx + movw %dx, 24(%rdi) + jmp ..B1.13 +..B1.12: + lea zeros(%rip), %rax + fldt (%rax) + fstpt 16(%rdi) +..B1.13: + addl %esi, 32(%rdi) +..B1.14: + ret +..B1.15: + fldt 16(%rdi) + lea _CONSTANTS(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt 16(%rdi) + movzwl 24(%rdi), %edx + movl %edx, %ecx + andl $32767, %ecx + andl $-32768, %edx + addl $-16639, %ecx + orl $-49153, %edx + jmp ..B1.10 +..B1.16: + fldt (%rdi) + lea _CONSTANTS(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fstpt (%rdi) + movzwl 8(%rdi), %eax + movl %eax, %esi + andl $32767, %esi + andl $-32768, %eax + addl $-16639, %esi + orl $-49153, %eax + jmp ..B1.6 + .align 16,0x90 + .cfi_endproc + .type __libm_normalizel_k80,@function + .size __libm_normalizel_k80,.-__libm_normalizel_k80 + .data +# -- End __libm_normalizel_k80 + .section .rodata, "a" + .align 16 + .align 16 +zeros: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type zeros,@object + .size zeros,32 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16639 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_recacoshl_k80.S b/external/sgx_libm/intel64/libm_recacoshl_k80.S new file mode 100644 index 0000000000..d23b01b76b --- /dev/null +++ b/external/sgx_libm/intel64/libm_recacoshl_k80.S @@ -0,0 +1,1655 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_recacoshl_k80.c" + .text +..TXTST0: +# -- Begin __libm_recacoshl_k80 + .text + .align 16,0x90 + .globl __libm_recacoshl_k80 +__libm_recacoshl_k80: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +# parameter 7: 688 + %rsp +# parameter 8: 696 + %rsp +# parameter 9: 704 + %rsp +# parameter 10: 712 + %rsp +..B1.1: + .cfi_startproc +..___tag_value___libm_recacoshl_k80.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r15 + .cfi_def_cfa_offset 24 + .cfi_offset 15, -24 + pushq %rbp + .cfi_def_cfa_offset 32 + .cfi_offset 6, -32 + subq $656, %rsp + .cfi_def_cfa_offset 688 + movq %r9, %rbp + movzwl 8(%rdi), %r10d + movq %r8, %r15 + andl $32767, %r10d + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 640(%rsp) + cmpl $16383, %r10d + movq 704(%rsp), %r13 + jl ..B1.31 +..B1.2: + movzwl 8(%r13), %r9d + movl %r9d, %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.6 +..B1.3: + cmpl $24383, %eax + jg ..B1.6 +..B1.4: + movzwl 8(%r15), %r10d + movl %r10d, %r11d + andl $32767, %r11d + cmpl $8383, %r11d + jl ..B1.6 +..B1.5: + cmpl $24383, %r11d + jle ..B1.9 +..B1.6: + movq %r13, %rdi +..___tag_value___libm_recacoshl_k80.10: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.11: +..B1.7: + movq %r15, %rdi +..___tag_value___libm_recacoshl_k80.12: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.13: +..B1.8: + movzwl 8(%r13), %r9d + movl %r9d, %eax + movzwl 8(%r15), %r10d + movl %r10d, %r11d + andl $32767, %eax + andl $32767, %r11d +..B1.9: + movl 32(%r15), %edx + movl 32(%r13), %ecx + lea -134(%rdx,%r11), %esi + lea (%rax,%rcx), %r8d + cmpl %r8d, %esi + jge ..B1.26 +..B1.10: + lea 134(%rdx,%r11), %esi + cmpl %esi, %r8d + jge ..B1.26 +..B1.11: + cmpl $0, 4(%r13) + jne ..B1.13 +..B1.12: + cmpl $0, (%r13) + je ..B1.26 +..B1.13: + cmpl $0, 4(%r15) + jne ..B1.15 +..B1.14: + cmpl $0, (%r15) + je ..B1.26 +..B1.15: + cmpl %edx, %ecx + je ..B1.17 +..B1.16: + fldt (%r13) + subl %edx, %ecx + fldt 16(%r13) + addl $16383, %ecx + andb $127, 9(%rsp) + andl $32767, %ecx + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 32(%r13) + fxch %st(2) + fstpt (%r13) + fldt (%r13) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%r13) + fldt 16(%r13) + movl 32(%r15), %edx + movzwl 8(%r15), %r10d + movzwl 8(%r13), %r9d + jmp ..B1.18 +..B1.17: + fldt (%r13) + fldt 16(%r13) +..B1.18: + fldt (%r15) + andl $32767, %r9d + andl $32767, %r10d + fld %st(2) + movl %edx, 96(%rsp) + cmpl %r10d, %r9d + fadd %st(1), %st + jg ..B1.23 +..B1.19: + jne ..B1.24 +..B1.20: + movl 4(%r13), %eax + cmpl 4(%r15), %eax + ja ..B1.23 +..B1.21: + jne ..B1.24 +..B1.22: + movl (%r13), %eax + cmpl (%r15), %eax + jbe ..B1.24 +..B1.23: + fldt 16(%r15) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B1.25 +..B1.24: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%r15) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) +..B1.25: + fld %st(0) + fadd %st(2), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 80(%rsp) + jmp ..B1.30 +..B1.26: + cmpq $0, (%r13) + je ..B1.28 +..B1.27: + lea -16517(%rdx,%r11), %edx + lea -16383(%rcx,%rax), %eax + cmpl %eax, %edx + jl ..B1.29 +..B1.28: + movq (%r15), %rax + movq 8(%r15), %rdx + movq 16(%r15), %rcx + movq 24(%r15), %rsi + movq 32(%r15), %r8 + movq 40(%r15), %r9 + movq %rax, 64(%rsp) + movq %rdx, 72(%rsp) + movq %rcx, 80(%rsp) + movq %rsi, 88(%rsp) + movq %r8, 96(%rsp) + movq %r9, 104(%rsp) + jmp ..B1.30 +..B1.29: + movq (%r13), %rax + movq 8(%r13), %rdx + movq 16(%r13), %rcx + movq 24(%r13), %rsi + movq 32(%r13), %r8 + movq 40(%r13), %r9 + movq %rax, 64(%rsp) + movq %rdx, 72(%rsp) + movq %rcx, 80(%rsp) + movq %rsi, 88(%rsp) + movq %r8, 96(%rsp) + movq %r9, 104(%rsp) +..B1.30: + lea ones(%rip), %rax + lea zeros(%rip), %rdx + movl $0, 144(%rsp) + fldt (%rax) + fstpt 112(%rsp) + fldt 112(%rsp) + fldt (%rdx) + fstpt 128(%rsp) + fldt 128(%rsp) + jmp ..B1.59 +..B1.31: + movq 688(%rsp), %r9 + movq (%r9), %rax + movq 8(%r9), %rdx + movq 16(%r9), %rcx + movq 24(%r9), %rsi + movq 32(%r9), %r8 + movq 40(%r9), %r10 + movzwl 8(%r13), %r9d + movq %rax, 64(%rsp) + movl %r9d, %eax + andl $32767, %eax + movq %rdx, 72(%rsp) + cmpl $8383, %eax + movq %rcx, 80(%rsp) + movq %rsi, 88(%rsp) + movq %r8, 96(%rsp) + movq %r10, 104(%rsp) + jl ..B1.35 +..B1.32: + cmpl $24383, %eax + jg ..B1.35 +..B1.33: + movzwl 8(%r15), %r10d + movl %r10d, %r11d + andl $32767, %r11d + cmpl $8383, %r11d + jl ..B1.35 +..B1.34: + cmpl $24383, %r11d + jle ..B1.38 +..B1.35: + movq %r13, %rdi +..___tag_value___libm_recacoshl_k80.14: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.15: +..B1.36: + movq %r15, %rdi +..___tag_value___libm_recacoshl_k80.16: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.17: +..B1.37: + movzwl 8(%r13), %r9d + movl %r9d, %eax + movzwl 8(%r15), %r10d + movl %r10d, %r11d + andl $32767, %eax + andl $32767, %r11d +..B1.38: + movl 32(%r15), %edx + movl 32(%r13), %ecx + lea -134(%rdx,%r11), %esi + lea (%rax,%rcx), %r8d + cmpl %r8d, %esi + jge ..B1.55 +..B1.39: + lea 134(%rdx,%r11), %esi + cmpl %esi, %r8d + jge ..B1.55 +..B1.40: + cmpl $0, 4(%r13) + jne ..B1.42 +..B1.41: + cmpl $0, (%r13) + je ..B1.55 +..B1.42: + cmpl $0, 4(%r15) + jne ..B1.44 +..B1.43: + cmpl $0, (%r15) + je ..B1.55 +..B1.44: + cmpl %edx, %ecx + je ..B1.46 +..B1.45: + fldt (%r13) + subl %edx, %ecx + fldt 16(%r13) + addl $16383, %ecx + andb $127, 9(%rsp) + andl $32767, %ecx + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 32(%r13) + fxch %st(2) + fstpt (%r13) + fldt (%r13) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%r13) + fldt 16(%r13) + movl 32(%r15), %edx + movzwl 8(%r15), %r10d + movzwl 8(%r13), %r9d + jmp ..B1.47 +..B1.46: + fldt (%r13) + fldt 16(%r13) +..B1.47: + fldt (%r15) + andl $32767, %r9d + andl $32767, %r10d + fld %st(2) + movl %edx, 144(%rsp) + cmpl %r10d, %r9d + fsub %st(1), %st + jg ..B1.52 +..B1.48: + jne ..B1.53 +..B1.49: + movl 4(%r13), %eax + cmpl 4(%r15), %eax + ja ..B1.52 +..B1.50: + jne ..B1.53 +..B1.51: + movl (%r13), %eax + cmpl (%r15), %eax + jbe ..B1.53 +..B1.52: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 16(%r15) + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B1.54 +..B1.53: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%r15) + fsubrp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) +..B1.54: + fld %st(1) + lea ones(%rip), %rax + lea zeros(%rip), %rdx + fadd %st(1), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 128(%rsp) + fldt (%rax) + fldt (%rdx) + jmp ..B1.59 +..B1.55: + cmpq $0, (%r13) + je ..B1.57 +..B1.56: + lea -16517(%rdx,%r11), %esi + lea -16383(%rcx,%rax), %eax + cmpl %eax, %esi + jl ..B1.58 +..B1.57: + fldt (%r15) + lea ones(%rip), %rax + movl %edx, 144(%rsp) + lea zeros(%rip), %rdx + fchs + fstpt 112(%rsp) + fldt 16(%r15) + fchs + fstpt 128(%rsp) + fldt (%rax) + fldt (%rdx) + jmp ..B1.59 +..B1.58: + lea ones(%rip), %r10 + lea zeros(%rip), %r11 + movq (%r13), %rax + movq 8(%r13), %rdx + movq 16(%r13), %rcx + fldt (%r10) + fldt (%r11) + movq 24(%r13), %rsi + movq 32(%r13), %r8 + movq 40(%r13), %r9 + movq %rax, 112(%rsp) + movq %rdx, 120(%rsp) + movq %rcx, 128(%rsp) + movq %rsi, 136(%rsp) + movq %r8, 144(%rsp) + movq %r9, 152(%rsp) +..B1.59: + movq 712(%rsp), %r13 + fxch %st(1) + fadd %st(0), %st + movzwl 8(%r13), %r8d + movl %r8d, %r11d + andl $32767, %r11d + movl $0, 288(%rsp) + cmpl $8383, %r11d + fstpt 256(%rsp) + fstpt 272(%rsp) + jl ..B1.63 +..B1.60: + cmpl $24383, %r11d + jg ..B1.63 +..B1.61: + movzwl 264(%rsp), %edx + movl %edx, %r10d + andl $32767, %r10d + cmpl $8383, %r10d + jl ..B1.63 +..B1.62: + cmpl $24383, %r10d + jle ..B1.66 +..B1.63: + movq %r13, %rdi +..___tag_value___libm_recacoshl_k80.18: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.19: +..B1.64: + lea 256(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.20: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.21: +..B1.65: + movzwl 8(%r13), %r8d + movl %r8d, %r11d + movzwl 264(%rsp), %edx + movl %edx, %r10d + andl $32767, %r11d + andl $32767, %r10d +..B1.66: + movl 288(%rsp), %r9d + movl 32(%r13), %eax + lea -134(%r9,%r10), %ecx + lea (%r11,%rax), %esi + cmpl %ecx, %esi + jle ..B1.83 +..B1.67: + lea 134(%r9,%r10), %ecx + cmpl %ecx, %esi + jge ..B1.83 +..B1.68: + cmpl $0, 4(%r13) + jne ..B1.70 +..B1.69: + cmpl $0, (%r13) + je ..B1.83 +..B1.70: + cmpl $0, 260(%rsp) + jne ..B1.72 +..B1.71: + cmpl $0, 256(%rsp) + je ..B1.83 +..B1.72: + cmpl %r9d, %eax + je ..B1.74 +..B1.73: + fldt (%r13) + subl %r9d, %eax + fldt 16(%r13) + addl $16383, %eax + andb $127, 9(%rsp) + andl $32767, %eax + movzwl 8(%rsp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + movw %cx, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r9d, 32(%r13) + fxch %st(2) + fstpt (%r13) + fldt (%r13) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%r13) + fldt 16(%r13) + movzwl 8(%r13), %r8d + jmp ..B1.75 +..B1.74: + fldt (%r13) + fldt 16(%r13) +..B1.75: + fldt 256(%rsp) + movl %edx, %eax + andl $32767, %r8d + andl $32767, %eax + fld %st(2) + cmpl %eax, %r8d + movl %r9d, 192(%rsp) + fadd %st(1), %st + jg ..B1.80 +..B1.76: + andl $32767, %edx + cmpl %edx, %r8d + jne ..B1.81 +..B1.77: + movl 4(%r13), %eax + cmpl 260(%rsp), %eax + ja ..B1.80 +..B1.78: + jne ..B1.81 +..B1.79: + movl (%r13), %eax + cmpl 256(%rsp), %eax + jbe ..B1.81 +..B1.80: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 272(%rsp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.82 +..B1.81: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 272(%rsp) + faddp %st, %st(1) +..B1.82: + fld %st(0) + fadd %st(2), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 176(%rsp) + jmp ..B1.87 +..B1.83: + cmpq $0, (%r13) + je ..B1.85 +..B1.84: + lea -16517(%r9,%r10), %edx + lea -16383(%rax,%r11), %eax + cmpl %eax, %edx + jl ..B1.86 +..B1.85: + movaps 256(%rsp), %xmm0 + movaps 272(%rsp), %xmm1 + movaps 288(%rsp), %xmm2 + movaps %xmm0, 160(%rsp) + movaps %xmm1, 176(%rsp) + movaps %xmm2, 192(%rsp) + jmp ..B1.87 +..B1.86: + movq (%r13), %rax + movq 8(%r13), %rdx + movq 16(%r13), %rcx + movq 24(%r13), %rsi + movq 32(%r13), %r8 + movq 40(%r13), %r9 + movq %rax, 160(%rsp) + movq %rdx, 168(%rsp) + movq %rcx, 176(%rsp) + movq %rsi, 184(%rsp) + movq %r8, 192(%rsp) + movq %r9, 200(%rsp) +..B1.87: + movzwl 168(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.91 +..B1.88: + cmpl $24383, %eax + jg ..B1.91 +..B1.89: + movzwl 72(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.91 +..B1.90: + cmpl $24383, %eax + jle ..B1.93 +..B1.91: + lea 160(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.22: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.23: +..B1.92: + lea 64(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.24: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.25: +..B1.93: + fldt 160(%rsp) + lea t32(%rip), %rdx + fld %st(0) + fld %st(1) + fldt 64(%rsp) + fld %st(0) + fldt (%rdx) + fld %st(0) + fmul %st(6), %st + movq 696(%rsp), %r13 + fsubr %st, %st(5) + movzwl 8(%r13), %esi + movl %esi, %r11d + movl 192(%rsp), %eax + andl $32767, %r11d + addl 96(%rsp), %eax + faddp %st, %st(5) + fld %st(4) + fld %st(3) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + cmpl $8383, %r11d + fmul %st(4), %st + movl %eax, 240(%rsp) + fsubr %st, %st(3) + faddp %st, %st(3) + fmul %st(2), %st + fxch %st(4) + fsub %st(5), %st + fxch %st(1) + fsub %st(2), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 80(%rsp) + fmulp %st, %st(4) + fldt 176(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 208(%rsp) + fldt 208(%rsp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 224(%rsp) + fstpt 32(%rsp) + jl ..B1.97 +..B1.94: + cmpl $24383, %r11d + jg ..B1.97 +..B1.95: + movzwl 8(%rbp), %r8d + movl %r8d, %r10d + andl $32767, %r10d + cmpl $8383, %r10d + jl ..B1.97 +..B1.96: + cmpl $24383, %r10d + jle ..B1.100 +..B1.97: + movq %r13, %rdi +..___tag_value___libm_recacoshl_k80.26: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.27: +..B1.98: + movq %rbp, %rdi +..___tag_value___libm_recacoshl_k80.28: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.29: +..B1.99: + movzwl 8(%r13), %esi + movl %esi, %r11d + movzwl 8(%rbp), %r8d + movl %r8d, %r10d + andl $32767, %r11d + andl $32767, %r10d +..B1.100: + movl 32(%rbp), %r9d + movl 32(%r13), %eax + lea -134(%r9,%r10), %edx + lea (%r11,%rax), %ecx + cmpl %edx, %ecx + jle ..B1.117 +..B1.101: + lea 134(%r9,%r10), %edx + cmpl %edx, %ecx + jge ..B1.117 +..B1.102: + cmpl $0, 4(%r13) + jne ..B1.104 +..B1.103: + cmpl $0, (%r13) + je ..B1.117 +..B1.104: + cmpl $0, 4(%rbp) + jne ..B1.106 +..B1.105: + cmpl $0, (%rbp) + je ..B1.117 +..B1.106: + cmpl %r9d, %eax + je ..B1.108 +..B1.107: + fldt 32(%rsp) + subl %r9d, %eax + fstpt (%rsp) + addl $16383, %eax + fldt (%r13) + andl $32767, %eax + fldt 16(%r13) + andb $127, 9(%rsp) + movzwl 8(%rsp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r9d, 32(%r13) + fxch %st(2) + fstpt (%r13) + fldt (%r13) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%r13) + fldt 16(%r13) + movl 32(%rbp), %r9d + movzwl 8(%rbp), %r8d + movzwl 8(%r13), %esi + jmp ..B1.109 +..B1.108: + fldt (%r13) + fldt 16(%r13) +..B1.109: + fldt (%rbp) + andl $32767, %esi + andl $32767, %r8d + fld %st(2) + movl %r9d, 336(%rsp) + cmpl %r8d, %esi + fadd %st(1), %st + jg ..B1.114 +..B1.110: + jne ..B1.115 +..B1.111: + movl 4(%r13), %eax + cmpl 4(%rbp), %eax + ja ..B1.114 +..B1.112: + jne ..B1.115 +..B1.113: + movl (%r13), %eax + cmpl (%rbp), %eax + jbe ..B1.115 +..B1.114: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 16(%rbp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.116 +..B1.115: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 16(%rbp) + faddp %st, %st(1) +..B1.116: + fld %st(0) + fadd %st(2), %st + fstpt 304(%rsp) + fldt 304(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 320(%rsp) + jmp ..B1.121 +..B1.117: + cmpq $0, (%r13) + je ..B1.119 +..B1.118: + lea -16517(%r9,%r10), %edx + lea -16383(%rax,%r11), %eax + cmpl %eax, %edx + jl ..B1.120 +..B1.119: + movq (%rbp), %rax + movq 8(%rbp), %rdx + movq 16(%rbp), %rcx + movq 24(%rbp), %rsi + movq 32(%rbp), %r8 + movq 40(%rbp), %rbp + movq %rax, 304(%rsp) + movq %rdx, 312(%rsp) + movq %rcx, 320(%rsp) + movq %rsi, 328(%rsp) + movq %r8, 336(%rsp) + movq %rbp, 344(%rsp) + jmp ..B1.121 +..B1.120: + movq (%r13), %rax + movq 8(%r13), %rdx + movq 16(%r13), %rcx + movq 24(%r13), %rbp + movq 32(%r13), %rsi + movq 40(%r13), %rdi + movq %rax, 304(%rsp) + movq %rdx, 312(%rsp) + movq %rcx, 320(%rsp) + movq %rbp, 328(%rsp) + movq %rsi, 336(%rsp) + movq %rdi, 344(%rsp) +..B1.121: + movzwl 312(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.125 +..B1.122: + cmpl $24383, %eax + jg ..B1.125 +..B1.123: + movzwl 120(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.125 +..B1.124: + cmpl $24383, %eax + jle ..B1.127 +..B1.125: + lea 304(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.30: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.31: +..B1.126: + lea 112(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.32: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.33: +..B1.127: + fldt 304(%rsp) + fld %st(0) + fld %st(1) + fldt 16(%rsp) + fld %st(0) + fmul %st(4), %st + movl 336(%rsp), %ecx + fsubr %st, %st(3) + movzwl 216(%rsp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + addl 144(%rsp), %ecx + fxch %st(2) + fsub %st(3), %st + fldt 112(%rsp) + cmpl $8383, %eax + fmul %st, %st(2) + fld %st(0) + movl %ecx, 384(%rsp) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 128(%rsp) + fmulp %st, %st(4) + fldt 320(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 352(%rsp) + fldt 352(%rsp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 368(%rsp) + fldt 368(%rsp) + jl ..B1.131 +..B1.128: + cmpl $24383, %eax + jg ..B1.131 +..B1.129: + movzwl 360(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.131 +..B1.130: + cmpl $24383, %eax + jle ..B1.134 +..B1.131: + fstp %st(1) + fstp %st(0) + lea 208(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.34: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.35: +..B1.132: + lea 352(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.36: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.37: +..B1.133: + fldt 352(%rsp) + fldt 368(%rsp) + movl 384(%rsp), %ecx +..B1.134: + fldt 208(%rsp) + fld %st(2) + fdivr %st(1), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(4) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt 16(%rsp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + movl 240(%rsp), %edx + fsubr %st(4), %st + subl %ecx, %edx + faddp %st, %st(1) + fld %st(0) + decl %edx + movl %edx, 432(%rsp) + fsubr %st(4), %st + fxch %st(2) + fmul %st(3), %st + fsubr %st, %st(7) + faddp %st, %st(7) + fxch %st(2) + fsub %st(6), %st + fld %st(2) + fmul %st(7), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(3) + fxch %st(7) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(6) + faddp %st, %st(5) + fsubrp %st, %st(2) + fxch %st(3) + fsubrp %st, %st(1) + fldt 224(%rsp) + faddp %st, %st(1) + fsubp %st, %st(1) + fldt 48(%rsp) + fdivrp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 400(%rsp) + fldt 400(%rsp) + fsubrp %st, %st(2) + movzwl 408(%rsp), %esi + movl %esi, %eax + andl $32767, %eax + fadd %st, %st(1) + fxch %st(1) + fstpt 416(%rsp) + cmpl $8383, %eax + fstpt 32(%rsp) + jl ..B1.138 +..B1.135: + cmpl $24383, %eax + jg ..B1.138 +..B1.136: + movzwl 264(%rsp), %edi + movl %edi, %r9d + andl $32767, %r9d + cmpl $8383, %r9d + jl ..B1.138 +..B1.137: + cmpl $24383, %r9d + jle ..B1.141 +..B1.138: + lea 400(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.38: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.39: +..B1.139: + lea 256(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.40: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.41: +..B1.140: + movzwl 264(%rsp), %edi + movl %edi, %r9d + movzwl 408(%rsp), %esi + movl %esi, %eax + movl 432(%rsp), %edx + andl $32767, %r9d + andl $32767, %eax +..B1.141: + movl 288(%rsp), %r8d + lea (%rdx,%rax), %ebp + lea -134(%r8,%r9), %ecx + cmpl %ecx, %ebp + jle ..B1.158 +..B1.142: + lea 134(%r8,%r9), %ecx + cmpl %ecx, %ebp + jge ..B1.158 +..B1.143: + cmpl $0, 404(%rsp) + jne ..B1.145 +..B1.144: + cmpl $0, 400(%rsp) + je ..B1.158 +..B1.145: + cmpl $0, 260(%rsp) + jne ..B1.147 +..B1.146: + cmpl $0, 256(%rsp) + je ..B1.158 +..B1.147: + cmpl %r8d, %edx + je ..B1.149 +..B1.148: + fldt 32(%rsp) + subl %r8d, %edx + fstpt (%rsp) + addl $16383, %edx + fldt 400(%rsp) + andl $32767, %edx + fldt 416(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edx, %eax + movl %r8d, %edx + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 400(%rsp) + fldt 400(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 408(%rsp), %esi + movl %esi, %eax + andl $32767, %eax + movl %r8d, 432(%rsp) + movl %eax, %ecx + fstpt 416(%rsp) + fldt 416(%rsp) + jmp ..B1.150 +..B1.149: + fldt 400(%rsp) + movl %esi, %ecx + fldt 416(%rsp) + andl $32767, %ecx +..B1.150: + fldt 256(%rsp) + movl %edi, %ebp + andl $32767, %ebp + fld %st(2) + movl %r8d, 480(%rsp) + cmpl %ebp, %ecx + fadd %st(1), %st + jg ..B1.155 +..B1.151: + andl $32767, %esi + andl $32767, %edi + cmpl %edi, %esi + jne ..B1.156 +..B1.152: + movl 404(%rsp), %ecx + cmpl 260(%rsp), %ecx + ja ..B1.155 +..B1.153: + jne ..B1.156 +..B1.154: + movl 400(%rsp), %ecx + cmpl 256(%rsp), %ecx + jbe ..B1.156 +..B1.155: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 272(%rsp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.157 +..B1.156: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 272(%rsp) + faddp %st, %st(1) +..B1.157: + fld %st(0) + fadd %st(2), %st + fstpt 448(%rsp) + fldt 448(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 464(%rsp) + jmp ..B1.162 +..B1.158: + cmpq $0, 400(%rsp) + je ..B1.160 +..B1.159: + lea -16517(%r8,%r9), %ecx + lea -16383(%rdx,%rax), %ebp + cmpl %ebp, %ecx + jl ..B1.161 +..B1.160: + movaps 256(%rsp), %xmm0 + movaps 272(%rsp), %xmm1 + movaps 288(%rsp), %xmm2 + movaps %xmm0, 448(%rsp) + movaps %xmm1, 464(%rsp) + movaps %xmm2, 480(%rsp) + jmp ..B1.162 +..B1.161: + movaps 400(%rsp), %xmm0 + movaps 416(%rsp), %xmm1 + movaps 432(%rsp), %xmm2 + movaps %xmm0, 448(%rsp) + movaps %xmm1, 464(%rsp) + movaps %xmm2, 480(%rsp) +..B1.162: + cmpl $8383, %eax + jl ..B1.166 +..B1.163: + cmpl $24383, %eax + jg ..B1.166 +..B1.164: + movzwl 456(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.166 +..B1.165: + cmpl $24383, %eax + jle ..B1.169 +..B1.166: + lea 400(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.42: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.43: +..B1.167: + lea 448(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.44: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.45: +..B1.168: + movl 432(%rsp), %edx +..B1.169: + fldt 400(%rsp) + fld %st(0) + fld %st(1) + fldt 16(%rsp) + fld %st(0) + fmul %st(4), %st + addl 480(%rsp), %edx + fsubr %st, %st(3) + movl %edx, 528(%rsp) + faddp %st, %st(3) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fldt 448(%rsp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 464(%rsp) + fmulp %st, %st(4) + fldt 416(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 496(%rsp) + fldt 496(%rsp) + fsubr %st, %st(1) + movzwl 504(%rsp), %eax + fxch %st(1) + faddp %st, %st(2) + andl $32767, %eax + fxch %st(1) + fstpt 512(%rsp) + fldt 512(%rsp) + cmpl $383, %eax + fxch %st(1) + fstpt 32(%rsp) + jl ..B1.171 +..B1.170: + cmpl $32383, %eax + jle ..B1.173 +..B1.171: + fstp %st(0) + lea 496(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.46: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.47: +..B1.172: + fldt 496(%rsp) + fstpt 32(%rsp) + fldt 512(%rsp) + movl 528(%rsp), %edx +..B1.173: + testb $1, %dl + jne ..B1.208 +..B1.174: + lea halfs(%rip), %rax + fldt (%rax) +..B1.175: + fldt 32(%rsp) + fld %st(0) + fsqrt + fldt 16(%rsp) + fmul %st(1), %st + fld %st(0) + movzwl 408(%rsp), %ebp + movl %ebp, %r9d + andl $32767, %r9d + fsubr %st(2), %st + sarl $1, %edx + faddp %st, %st(1) + fld %st(0) + cmpl $8383, %r9d + movl %edx, 576(%rsp) + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fmulp %st, %st(1) + fdiv %st(1), %st + fld %st(0) + fadd %st(2), %st + fstpt 544(%rsp) + fldt 544(%rsp) + fsubrp %st, %st(2) + fadd %st, %st(1) + fxch %st(1) + fstpt 560(%rsp) + fstpt 32(%rsp) + jl ..B1.179 +..B1.176: + cmpl $24383, %r9d + jg ..B1.179 +..B1.177: + movzwl 552(%rsp), %esi + movl %esi, %edi + andl $32767, %edi + cmpl $8383, %edi + jl ..B1.179 +..B1.178: + cmpl $24383, %edi + jle ..B1.182 +..B1.179: + lea 400(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.48: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.49: +..B1.180: + lea 544(%rsp), %rdi +..___tag_value___libm_recacoshl_k80.50: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacoshl_k80.51: +..B1.181: + movzwl 408(%rsp), %ebp + movl %ebp, %r9d + movzwl 552(%rsp), %esi + movl %esi, %edi + movl 576(%rsp), %edx + andl $32767, %r9d + andl $32767, %edi +..B1.182: + movl 432(%rsp), %r8d + lea -134(%rdx,%rdi), %eax + lea (%r9,%r8), %ecx + cmpl %eax, %ecx + jle ..B1.199 +..B1.183: + lea 134(%rdx,%rdi), %eax + cmpl %eax, %ecx + jge ..B1.199 +..B1.184: + cmpl $0, 404(%rsp) + jne ..B1.186 +..B1.185: + cmpl $0, 400(%rsp) + je ..B1.199 +..B1.186: + cmpl $0, 548(%rsp) + jne ..B1.188 +..B1.187: + cmpl $0, 544(%rsp) + je ..B1.199 +..B1.188: + cmpl %edx, %r8d + je ..B1.190 +..B1.189: + fldt 32(%rsp) + subl %edx, %r8d + fstpt (%rsp) + addl $16383, %r8d + fldt 400(%rsp) + andl $32767, %r8d + fldt 416(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %r8d, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 400(%rsp) + fldt 400(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movl %edx, 432(%rsp) + fstpt 416(%rsp) + fldt 416(%rsp) + movzwl 408(%rsp), %ebp + jmp ..B1.191 +..B1.190: + fldt 400(%rsp) + fldt 416(%rsp) +..B1.191: + fldt 544(%rsp) + movl %ebp, %eax + movl %edx, 48(%rsp) + movl %esi, %edx + andl $32767, %eax + andl $32767, %edx + fld %st(2) + cmpl %edx, %eax + fadd %st(1), %st + jg ..B1.196 +..B1.192: + andl $32767, %ebp + andl $32767, %esi + cmpl %esi, %ebp + jne ..B1.197 +..B1.193: + movl 404(%rsp), %eax + cmpl 548(%rsp), %eax + ja ..B1.196 +..B1.194: + jne ..B1.197 +..B1.195: + movl 400(%rsp), %eax + cmpl 544(%rsp), %eax + jbe ..B1.197 +..B1.196: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 560(%rsp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B1.198 +..B1.197: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 560(%rsp) + faddp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) +..B1.198: + fld %st(0) + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B1.203 +..B1.199: + cmpq $0, 400(%rsp) + je ..B1.201 +..B1.200: + lea -16517(%rdx,%rdi), %eax + lea -16383(%r8,%r9), %edx + cmpl %edx, %eax + jl ..B1.202 +..B1.201: + movaps 544(%rsp), %xmm0 + movaps 560(%rsp), %xmm1 + movaps 576(%rsp), %xmm2 + movaps %xmm0, 16(%rsp) + movaps %xmm1, 32(%rsp) + movaps %xmm2, 48(%rsp) + jmp ..B1.203 +..B1.202: + movaps 400(%rsp), %xmm0 + movaps 416(%rsp), %xmm1 + movaps 432(%rsp), %xmm2 + movaps %xmm0, 16(%rsp) + movaps %xmm1, 32(%rsp) + movaps %xmm2, 48(%rsp) +..B1.203: + lea 592(%rsp), %rdi + lea 16(%rsp), %rsi +..___tag_value___libm_recacoshl_k80.52: + call __libm_log1p_k80@PLT +..___tag_value___libm_recacoshl_k80.53: +..B1.204: + addq $-32, %rsp + .cfi_def_cfa_offset 720 + fldt 624(%rsp) + movl 656(%rsp), %edi + fstpt (%rsp) + fldt 640(%rsp) + fstpt 16(%rsp) +..___tag_value___libm_recacoshl_k80.55: + call __libm_scalbl_k80@PLT +..___tag_value___libm_recacoshl_k80.56: +..B1.211: + addq $32, %rsp + .cfi_def_cfa_offset 688 +..B1.205: + movq 640(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.207 +..B1.206: + addq $656, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 688 + .cfi_offset 6, -32 + .cfi_offset 13, -16 + .cfi_offset 15, -24 +..B1.207: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.208: + fldt 32(%rsp) + incl %edx + lea halfs(%rip), %rax + movl %edx, 528(%rsp) + fldt (%rax) + fmul %st, %st(1) + fxch %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fstpt 512(%rsp) + fldt 512(%rsp) + fxch %st(1) + fstpt 496(%rsp) + fxch %st(1) + jmp ..B1.175 + .align 16,0x90 + .cfi_endproc + .type __libm_recacoshl_k80,@function + .size __libm_recacoshl_k80,.-__libm_recacoshl_k80 + .data +# -- End __libm_recacoshl_k80 + .section .rodata, "a" + .align 16 + .align 16 +ones: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type ones,@object + .size ones,32 + .align 16 +zeros: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type zeros,@object + .size zeros,32 + .align 16 +t32: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type t32,@object + .size t32,32 + .align 16 +halfs: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type halfs,@object + .size halfs,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_recacosl_recasinl_k80.S b/external/sgx_libm/intel64/libm_recacosl_recasinl_k80.S new file mode 100644 index 0000000000..233a1e1097 --- /dev/null +++ b/external/sgx_libm/intel64/libm_recacosl_recasinl_k80.S @@ -0,0 +1,5813 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_recacosl_recasinl_k80.c" + .text +..TXTST0: +# -- Begin __libm_carctrigprepare_k80 + .text + .align 16,0x90 + .globl __libm_carctrigprepare_k80 +__libm_carctrigprepare_k80: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +# parameter 7: 320 + %rsp +# parameter 8: 328 + %rsp +# parameter 9: 336 + %rsp +# parameter 10: 344 + %rsp +..B1.1: + .cfi_startproc +..___tag_value___libm_carctrigprepare_k80.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $272, %rsp + .cfi_def_cfa_offset 320 + lea ones(%rip), %r10 + movq %rdx, %rbp + lea zeros(%rip), %r11 + movq %fs:40, %rax + movq %rcx, %r13 + xorq %rsp, %rax + movq %r9, %r14 + fldt (%r10) + movq %r8, %r12 + fldt (%r11) + movq %rsi, %rbx + movq (%rdi), %r10 + movq %rax, 256(%rsp) + xorl %eax, %eax + movq %r10, (%rbp) + movq 8(%rdi), %rdx + movb 9(%rdi), %cl + movq %rbp, %rdi + movq %rdx, 8(%rbp) + andb $127, %cl + movl %eax, 96(%rsp) + fstpt (%rsp) + fldt (%rsp) + fxch %st(1) + fstpt 64(%rsp) + fstpt 80(%rsp) + fldt 80(%rsp) + movl %eax, 32(%rbp) + movb %cl, 9(%rbp) + fstpt 16(%rbp) +..___tag_value___libm_carctrigprepare_k80.14: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.15: +..B1.2: + fldt (%rsp) + movq %r13, %rdi + movq (%rbx), %rax + movq %rax, (%r13) + movq 8(%rbx), %rdx + movb 9(%rbx), %cl + movq %rdx, 8(%r13) + andb $127, %cl + movl $0, 32(%r13) + movb %cl, 9(%r13) + fstpt 16(%r13) +..___tag_value___libm_carctrigprepare_k80.16: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.17: +..B1.3: + fldt (%r13) + lea t32(%rip), %rdx + fld %st(0) + fld %st(1) + fld %st(2) + fldt 16(%r13) + fmulp %st, %st(4) + movq 320(%rsp), %rbx + fxch %st(3) + fadd %st(0), %st + fldt (%rdx) + fmul %st, %st(3) + movl 32(%r13), %eax + fxch %st(2) + fsub %st(3), %st + addl %eax, %eax + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(3) + fsubr %st, %st(4) + fmul %st(4), %st + movl %eax, 32(%rbx) + fadd %st(0), %st + fxch %st(4) + fmul %st(0), %st + fxch %st(2) + fstpt 16(%rsp) + fld %st(3) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt (%rbx) + fldt (%rbx) + fsubrp %st, %st(1) + movzwl 8(%rbp), %edx + movl %edx, %eax + andl $32767, %eax + fadd %st(1), %st + fstpt 16(%rbx) + cmpl $8383, %eax + fstpt 32(%rsp) + jl ..B1.7 +..B1.4: + cmpl $24383, %eax + jg ..B1.7 +..B1.5: + movzwl 72(%rsp), %esi + movl %esi, %r8d + andl $32767, %r8d + cmpl $8383, %r8d + jl ..B1.7 +..B1.6: + cmpl $24383, %r8d + jle ..B1.10 +..B1.7: + movq %rbp, %rdi +..___tag_value___libm_carctrigprepare_k80.18: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.19: +..B1.8: + lea 64(%rsp), %rdi +..___tag_value___libm_carctrigprepare_k80.20: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.21: +..B1.9: + movzwl 8(%rbp), %edx + movl %edx, %eax + movzwl 72(%rsp), %esi + movl %esi, %r8d + andl $32767, %eax + andl $32767, %r8d +..B1.10: + movl 32(%rbp), %ecx + movl 96(%rsp), %r9d + lea (%rax,%rcx), %r13d + lea -134(%r9,%r8), %r11d + cmpl %r13d, %r11d + lea (%r8,%r9), %r10d + jge ..B1.27 +..B1.11: + lea 134(%r9,%r8), %edi + cmpl %edi, %r13d + jge ..B1.27 +..B1.12: + cmpl $0, 4(%rbp) + jne ..B1.14 +..B1.13: + cmpl $0, (%rbp) + je ..B1.27 +..B1.14: + cmpl $0, 68(%rsp) + jne ..B1.16 +..B1.15: + cmpl $0, 64(%rsp) + je ..B1.27 +..B1.16: + cmpl %r9d, %ecx + je ..B1.18 +..B1.17: + fldt 32(%rsp) + subl %r9d, %ecx + fstpt (%rsp) + addl $16383, %ecx + fldt (%rbp) + andl $32767, %ecx + fldt 16(%rbp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r9d, 32(%rbp) + fxch %st(2) + fstpt (%rbp) + fldt (%rbp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbp) + fstpt 32(%rsp) + movzwl 8(%rbp), %edx + jmp ..B1.19 +..B1.18: + fldt (%rbp) + fstpt 32(%rsp) +..B1.19: + fldt 64(%rsp) + movl %esi, %eax + fldt 32(%rsp) + andl $32767, %edx + andl $32767, %eax + movl %r9d, 32(%r14) + cmpl %eax, %edx + fadd %st(1), %st + fstpt 16(%r14) + fldt 16(%r14) + jg ..B1.24 +..B1.20: + movl %esi, %eax + andl $32767, %eax + cmpl %eax, %edx + jne ..B1.25 +..B1.21: + movl 4(%rbp), %eax + cmpl 68(%rsp), %eax + ja ..B1.24 +..B1.22: + jne ..B1.25 +..B1.23: + movl (%rbp), %eax + cmpl 64(%rsp), %eax + jbe ..B1.25 +..B1.24: + fldt 32(%rsp) + fsub %st(1), %st + faddp %st, %st(2) + fldt 80(%rsp) + faddp %st, %st(2) + fldt 16(%rbp) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) + jmp ..B1.26 +..B1.25: + fldt 32(%rsp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 80(%rsp) + fldt 16(%rbp) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) +..B1.26: + fldt 32(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt (%r14) + fldt (%r14) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%r14) + jmp ..B1.31 +..B1.27: + cmpq $0, (%rbp) + je ..B1.29 +..B1.28: + lea -16517(%r9,%r8), %edx + lea -16383(%rcx,%rax), %eax + cmpl %eax, %edx + jl ..B1.30 +..B1.29: + movq 64(%rsp), %rax + movq %rax, (%r14) + movq 96(%rsp), %rax + movq %rax, 32(%r14) + movq 72(%rsp), %rdx + movq 80(%rsp), %rcx + movq 88(%rsp), %r13 + movq 104(%rsp), %rax + movq %rdx, 8(%r14) + movq %rcx, 16(%r14) + movq %r13, 24(%r14) + movq %rax, 40(%r14) + jmp ..B1.31 +..B1.30: + movq (%rbp), %rax + movq %rax, (%r14) + movq 8(%rbp), %rdx + movq %rdx, 8(%r14) + movq 16(%rbp), %rcx + movq %rcx, 16(%r14) + movq 24(%rbp), %r13 + movq %r13, 24(%r14) + movq 32(%rbp), %rax + movq %rax, 32(%r14) + movq 40(%rbp), %rax + movq %rax, 40(%r14) +..B1.31: + movzwl 8(%rbp), %edx + movl %edx, %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.35 +..B1.32: + cmpl $24383, %eax + jg ..B1.35 +..B1.33: + cmpl $8383, %r8d + jl ..B1.35 +..B1.34: + cmpl $24383, %r8d + jle ..B1.38 +..B1.35: + movq %rbp, %rdi +..___tag_value___libm_carctrigprepare_k80.22: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.23: +..B1.36: + lea 64(%rsp), %rdi +..___tag_value___libm_carctrigprepare_k80.24: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.25: +..B1.37: + movzwl 72(%rsp), %esi + movl %esi, %ecx + andl $32767, %ecx + movl 96(%rsp), %r9d + movzwl 8(%rbp), %edx + movl %edx, %eax + andl $32767, %eax + lea (%r9,%rcx), %r10d + lea -134(%r9,%rcx), %r11d +..B1.38: + movl 32(%rbp), %r13d + lea (%rax,%r13), %ecx + cmpl %ecx, %r11d + jge ..B1.55 +..B1.39: + lea 134(%r10), %r8d + cmpl %r8d, %ecx + jge ..B1.55 +..B1.40: + cmpl $0, 4(%rbp) + jne ..B1.42 +..B1.41: + cmpl $0, (%rbp) + je ..B1.55 +..B1.42: + cmpl $0, 68(%rsp) + jne ..B1.44 +..B1.43: + cmpl $0, 64(%rsp) + je ..B1.55 +..B1.44: + cmpl %r9d, %r13d + je ..B1.46 +..B1.45: + fldt 32(%rsp) + subl %r9d, %r13d + fstpt (%rsp) + addl $16383, %r13d + fldt (%rbp) + andl $32767, %r13d + fldt 16(%rbp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %r13d, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r9d, 32(%rbp) + fxch %st(2) + fstpt (%rbp) + fldt (%rbp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbp) + movzwl 8(%rbp), %edx + jmp ..B1.47 +..B1.46: + fldt (%rbp) +..B1.47: + fldt 64(%rsp) + fld %st(1) + movl %esi, %eax + andl $32767, %edx + andl $32767, %eax + fadd %st(1), %st + movl %r9d, 32(%r14) + cmpl %eax, %edx + fstpt 16(%r14) + fldt 16(%r14) + jg ..B1.52 +..B1.48: + andl $32767, %esi + cmpl %esi, %edx + jne ..B1.53 +..B1.49: + movl 4(%rbp), %eax + cmpl 68(%rsp), %eax + ja ..B1.52 +..B1.50: + jne ..B1.53 +..B1.51: + movl (%rbp), %eax + cmpl 64(%rsp), %eax + jbe ..B1.53 +..B1.52: + fldt 80(%rsp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 16(%rbp) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.54 +..B1.53: + fldt 16(%rbp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 80(%rsp) + faddp %st, %st(1) +..B1.54: + fld %st(0) + fadd %st(2), %st + fstpt (%r14) + fldt (%r14) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%r14) + jmp ..B1.59 +..B1.55: + cmpq $0, (%rbp) + je ..B1.57 +..B1.56: + addl $-16517, %r10d + lea -16383(%r13,%rax), %eax + cmpl %eax, %r10d + jl ..B1.58 +..B1.57: + movq 64(%rsp), %rax + movq 72(%rsp), %rdx + movq 80(%rsp), %rcx + movq 88(%rsp), %rsi + movq 96(%rsp), %r8 + movq 104(%rsp), %r9 + movq %rax, (%r14) + movq %rdx, 8(%r14) + movq %rcx, 16(%r14) + movq %rsi, 24(%r14) + movq %r8, 32(%r14) + movq %r9, 40(%r14) + jmp ..B1.59 +..B1.58: + movq (%rbp), %rax + movq %rax, (%r14) + movq 8(%rbp), %rdx + movq %rdx, 8(%r14) + movq 16(%rbp), %rcx + movq %rcx, 16(%r14) + movq 24(%rbp), %rsi + movq %rsi, 24(%r14) + movq 32(%rbp), %r8 + movq %r8, 32(%r14) + movq 40(%rbp), %r9 + movq %r9, 40(%r14) +..B1.59: + movzwl 8(%r14), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.61 +..B1.60: + cmpl $24383, %eax + jle ..B1.63 +..B1.61: + movq %r14, %rdi +..___tag_value___libm_carctrigprepare_k80.26: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.27: +..B1.62: + movq %r14, %rdi +..___tag_value___libm_carctrigprepare_k80.28: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.29: +..B1.63: + fldt (%r14) + fld %st(0) + fld %st(1) + fldt 16(%r14) + fldt 16(%rsp) + movl 32(%r14), %eax + fmul %st(4), %st + addl %eax, %eax + movl %eax, 144(%rsp) + fsubr %st, %st(3) + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(1) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubrp %st, %st(2) + movzwl 120(%rsp), %esi + movl %esi, %r11d + andl $32767, %r11d + fadd %st, %st(1) + fxch %st(1) + fstpt 128(%rsp) + cmpl $8383, %r11d + fstpt 32(%rsp) + jl ..B1.67 +..B1.64: + cmpl $24383, %r11d + jg ..B1.67 +..B1.65: + movzwl 8(%rbx), %r8d + movl %r8d, %r10d + andl $32767, %r10d + cmpl $8383, %r10d + jl ..B1.67 +..B1.66: + cmpl $24383, %r10d + jle ..B1.70 +..B1.67: + lea 112(%rsp), %rdi +..___tag_value___libm_carctrigprepare_k80.30: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.31: +..B1.68: + movq %rbx, %rdi +..___tag_value___libm_carctrigprepare_k80.32: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.33: +..B1.69: + movzwl 120(%rsp), %esi + movl %esi, %r11d + movzwl 8(%rbx), %r8d + movl %r8d, %r10d + movl 144(%rsp), %eax + andl $32767, %r11d + andl $32767, %r10d +..B1.70: + movl 32(%rbx), %r9d + lea (%rax,%r11), %ecx + lea -134(%r9,%r10), %edx + cmpl %edx, %ecx + jle ..B1.87 +..B1.71: + lea 134(%r9,%r10), %edx + cmpl %edx, %ecx + jge ..B1.87 +..B1.72: + cmpl $0, 116(%rsp) + jne ..B1.74 +..B1.73: + cmpl $0, 112(%rsp) + je ..B1.87 +..B1.74: + cmpl $0, 4(%rbx) + jne ..B1.76 +..B1.75: + cmpl $0, (%rbx) + je ..B1.87 +..B1.76: + cmpl %r9d, %eax + je ..B1.78 +..B1.77: + fldt 32(%rsp) + subl %r9d, %eax + fstpt (%rsp) + addl $16383, %eax + fldt 112(%rsp) + andl $32767, %eax + fldt 128(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %edx + andl $-32768, %edx + orl %eax, %edx + movw %dx, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movl %r9d, 144(%rsp) + fstpt 128(%rsp) + fldt 128(%rsp) + movzwl 120(%rsp), %esi + jmp ..B1.79 +..B1.78: + fldt 112(%rsp) + fldt 128(%rsp) +..B1.79: + fldt (%rbx) + movl %esi, %eax + andl $32767, %r8d + andl $32767, %eax + fld %st(2) + cmpl %r8d, %eax + movl %r9d, 192(%rsp) + fadd %st(1), %st + jg ..B1.84 +..B1.80: + andl $32767, %esi + cmpl %r8d, %esi + jne ..B1.85 +..B1.81: + movl 4(%rbx), %eax + cmpl 116(%rsp), %eax + jb ..B1.84 +..B1.82: + jne ..B1.85 +..B1.83: + movl 112(%rsp), %eax + cmpl (%rbx), %eax + jbe ..B1.85 +..B1.84: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 16(%rbx) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.86 +..B1.85: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 16(%rbx) + faddp %st, %st(1) +..B1.86: + fld %st(0) + fadd %st(2), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 176(%rsp) + jmp ..B1.91 +..B1.87: + cmpq $0, 112(%rsp) + je ..B1.89 +..B1.88: + lea -16517(%r9,%r10), %edx + lea -16383(%rax,%r11), %eax + cmpl %eax, %edx + jl ..B1.90 +..B1.89: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rsi + movq 32(%rbx), %r8 + movq 40(%rbx), %r9 + movq %rax, 160(%rsp) + movq %rdx, 168(%rsp) + movq %rcx, 176(%rsp) + movq %rsi, 184(%rsp) + movq %r8, 192(%rsp) + movq %r9, 200(%rsp) + jmp ..B1.91 +..B1.90: + movaps 112(%rsp), %xmm0 + movaps 128(%rsp), %xmm1 + movaps 144(%rsp), %xmm2 + movaps %xmm0, 160(%rsp) + movaps %xmm1, 176(%rsp) + movaps %xmm2, 192(%rsp) +..B1.91: + movzwl 168(%rsp), %eax + andl $32767, %eax + cmpl $383, %eax + jl ..B1.93 +..B1.92: + cmpl $32383, %eax + jle ..B1.94 +..B1.93: + lea 160(%rsp), %rdi +..___tag_value___libm_carctrigprepare_k80.34: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.35: +..B1.94: + movl 192(%rsp), %edx + testb $1, %dl + jne ..B1.193 +..B1.95: + fldt 160(%rsp) + lea halfs(%rip), %rax + fstpt 48(%rsp) + fldt 176(%rsp) + fldt (%rax) + fstpt 32(%rsp) +..B1.96: + fldt 48(%rsp) + fld %st(0) + fsqrt + fldt 16(%rsp) + movq 328(%rsp), %r13 + fmul %st(1), %st + fld %st(0) + sarl $1, %edx + fsubr %st(2), %st + movl %edx, 32(%r13) + faddp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%rsp) + fmulp %st, %st(1) + fdiv %st(1), %st + fld %st(0) + fadd %st(2), %st + fstpt (%r13) + fldt (%r13) + fsubrp %st, %st(2) + movzwl 8(%rbp), %r9d + movl %r9d, %r11d + andl $32767, %r11d + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%r13) + cmpl $8383, %r11d + fstpt 48(%rsp) + jl ..B1.100 +..B1.97: + cmpl $24383, %r11d + jg ..B1.100 +..B1.98: + movzwl 72(%rsp), %ecx + movl %ecx, %r10d + andl $32767, %r10d + cmpl $8383, %r10d + jl ..B1.100 +..B1.99: + cmpl $24383, %r10d + jle ..B1.103 +..B1.100: + movq %rbp, %rdi +..___tag_value___libm_carctrigprepare_k80.36: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.37: +..B1.101: + lea 64(%rsp), %rdi +..___tag_value___libm_carctrigprepare_k80.38: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.39: +..B1.102: + movzwl 8(%rbp), %r9d + movl %r9d, %r11d + movzwl 72(%rsp), %ecx + movl %ecx, %r10d + andl $32767, %r11d + andl $32767, %r10d +..B1.103: + movl 32(%rbp), %eax + movl 96(%rsp), %edx + lea (%r11,%rax), %r8d + lea -134(%rdx,%r10), %esi + cmpl %esi, %r8d + jle ..B1.120 +..B1.104: + lea 134(%rdx,%r10), %esi + cmpl %esi, %r8d + jge ..B1.120 +..B1.105: + cmpl $0, 4(%rbp) + jne ..B1.107 +..B1.106: + cmpl $0, (%rbp) + je ..B1.120 +..B1.107: + cmpl $0, 68(%rsp) + jne ..B1.109 +..B1.108: + cmpl $0, 64(%rsp) + je ..B1.120 +..B1.109: + cmpl %edx, %eax + je ..B1.111 +..B1.110: + fldt 48(%rsp) + subl %edx, %eax + fstpt (%rsp) + addl $16383, %eax + fldt (%rbp) + andl $32767, %eax + fldt 16(%rbp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %esi + andl $-32768, %esi + orl %eax, %esi + movw %si, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 32(%rbp) + fxch %st(2) + fstpt (%rbp) + fldt (%rbp) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbp) + movzwl 8(%rbp), %r9d + jmp ..B1.112 +..B1.111: + fldt (%rbp) +..B1.112: + fldt 64(%rsp) + fld %st(1) + movl %ecx, %eax + andl $32767, %r9d + andl $32767, %eax + fsub %st(1), %st + movl %edx, 32(%r12) + cmpl %eax, %r9d + fstpt 16(%r12) + fldt 16(%r12) + jg ..B1.117 +..B1.113: + andl $32767, %ecx + cmpl %ecx, %r9d + jne ..B1.118 +..B1.114: + movl 4(%rbp), %eax + cmpl 68(%rsp), %eax + ja ..B1.117 +..B1.115: + jne ..B1.118 +..B1.116: + movl (%rbp), %eax + cmpl 64(%rsp), %eax + jbe ..B1.118 +..B1.117: + fldt 16(%rbp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fldt 80(%rsp) + fsubrp %st, %st(3) + faddp %st, %st(2) + jmp ..B1.119 +..B1.118: + fldt 80(%rsp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fldt 16(%rbp) + faddp %st, %st(3) + fsubrp %st, %st(2) +..B1.119: + fld %st(1) + fadd %st(1), %st + fstpt (%r12) + fldt (%r12) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%r12) + jmp ..B1.124 +..B1.120: + cmpq $0, (%rbp) + je ..B1.122 +..B1.121: + lea -16517(%rdx,%r10), %ecx + lea -16383(%rax,%r11), %eax + cmpl %eax, %ecx + jl ..B1.123 +..B1.122: + fldt 64(%rsp) + fchs + movl %edx, 32(%r12) + fstpt (%r12) + fldt 80(%rsp) + fchs + fstpt 16(%r12) + jmp ..B1.124 +..B1.123: + movq (%rbp), %rax + movq %rax, (%r12) + movq 8(%rbp), %rdx + movq %rdx, 8(%r12) + movq 16(%rbp), %rcx + movq %rcx, 16(%r12) + movq 24(%rbp), %rsi + movq %rsi, 24(%r12) + movq 32(%rbp), %r8 + movq %r8, 32(%r12) + movq 40(%rbp), %rbp + movq %rbp, 40(%r12) +..B1.124: + movzwl 8(%r12), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B1.126 +..B1.125: + cmpl $24383, %eax + jle ..B1.128 +..B1.126: + movq %r12, %rdi +..___tag_value___libm_carctrigprepare_k80.40: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.41: +..B1.127: + movq %r12, %rdi +..___tag_value___libm_carctrigprepare_k80.42: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.43: +..B1.128: + fldt (%r12) + fld %st(0) + fld %st(1) + fldt 16(%r12) + fldt 16(%rsp) + movl 32(%r12), %r9d + fmul %st(4), %st + addl %r9d, %r9d + movl %r9d, 144(%rsp) + fsubr %st, %st(3) + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(1) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + fadd %st(0), %st + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubrp %st, %st(2) + movzwl 120(%rsp), %ecx + movl %ecx, %r10d + andl $32767, %r10d + fadd %st, %st(1) + fxch %st(1) + fstpt 128(%rsp) + cmpl $8383, %r10d + fstpt 48(%rsp) + jl ..B1.132 +..B1.129: + cmpl $24383, %r10d + jg ..B1.132 +..B1.130: + movzwl 8(%rbx), %ebp + movl %ebp, %r8d + andl $32767, %r8d + cmpl $8383, %r8d + jl ..B1.132 +..B1.131: + cmpl $24383, %r8d + jle ..B1.135 +..B1.132: + lea 112(%rsp), %rdi +..___tag_value___libm_carctrigprepare_k80.44: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.45: +..B1.133: + movq %rbx, %rdi +..___tag_value___libm_carctrigprepare_k80.46: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.47: +..B1.134: + movzwl 120(%rsp), %ecx + movl %ecx, %r10d + movzwl 8(%rbx), %ebp + movl %ebp, %r8d + movl 144(%rsp), %r9d + andl $32767, %r10d + andl $32767, %r8d +..B1.135: + movl 32(%rbx), %esi + lea (%r9,%r10), %edx + lea -134(%rsi,%r8), %eax + cmpl %eax, %edx + jle ..B1.152 +..B1.136: + lea 134(%rsi,%r8), %eax + cmpl %eax, %edx + jge ..B1.152 +..B1.137: + cmpl $0, 116(%rsp) + jne ..B1.139 +..B1.138: + cmpl $0, 112(%rsp) + je ..B1.152 +..B1.139: + cmpl $0, 4(%rbx) + jne ..B1.141 +..B1.140: + cmpl $0, (%rbx) + je ..B1.152 +..B1.141: + cmpl %esi, %r9d + je ..B1.143 +..B1.142: + fldt 48(%rsp) + subl %esi, %r9d + fstpt (%rsp) + addl $16383, %r9d + fldt 112(%rsp) + andl $32767, %r9d + fldt 128(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %r9d, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movl %esi, 144(%rsp) + fstpt 128(%rsp) + fldt 128(%rsp) + movzwl 120(%rsp), %ecx + jmp ..B1.144 +..B1.143: + fldt 112(%rsp) + fldt 128(%rsp) +..B1.144: + fldt (%rbx) + movl %ecx, %eax + andl $32767, %ebp + andl $32767, %eax + fld %st(2) + cmpl %ebp, %eax + movl %esi, 240(%rsp) + fadd %st(1), %st + jg ..B1.149 +..B1.145: + andl $32767, %ecx + cmpl %ebp, %ecx + jne ..B1.150 +..B1.146: + movl 4(%rbx), %eax + cmpl 116(%rsp), %eax + jb ..B1.149 +..B1.147: + jne ..B1.150 +..B1.148: + movl 112(%rsp), %eax + cmpl (%rbx), %eax + jbe ..B1.150 +..B1.149: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 16(%rbx) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.151 +..B1.150: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 16(%rbx) + faddp %st, %st(1) +..B1.151: + fld %st(0) + fadd %st(2), %st + fstpt 208(%rsp) + fldt 208(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 224(%rsp) + jmp ..B1.156 +..B1.152: + cmpq $0, 112(%rsp) + je ..B1.154 +..B1.153: + lea -16517(%rsi,%r8), %eax + lea -16383(%r9,%r10), %edx + cmpl %edx, %eax + jl ..B1.155 +..B1.154: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rbp + movq 32(%rbx), %rsi + movq 40(%rbx), %rbx + movq %rax, 208(%rsp) + movq %rdx, 216(%rsp) + movq %rcx, 224(%rsp) + movq %rbp, 232(%rsp) + movq %rsi, 240(%rsp) + movq %rbx, 248(%rsp) + jmp ..B1.156 +..B1.155: + movaps 112(%rsp), %xmm0 + movaps 128(%rsp), %xmm1 + movaps 144(%rsp), %xmm2 + movaps %xmm0, 208(%rsp) + movaps %xmm1, 224(%rsp) + movaps %xmm2, 240(%rsp) +..B1.156: + movzwl 216(%rsp), %eax + andl $32767, %eax + cmpl $383, %eax + jl ..B1.158 +..B1.157: + cmpl $32383, %eax + jle ..B1.159 +..B1.158: + lea 208(%rsp), %rdi +..___tag_value___libm_carctrigprepare_k80.48: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.49: +..B1.159: + movl 240(%rsp), %r11d + testl $1, %r11d + jne ..B1.192 +..B1.160: + fldt 208(%rsp) + fstpt 48(%rsp) + fldt 224(%rsp) +..B1.161: + fldt 48(%rsp) + fld %st(0) + fsqrt + fldt 16(%rsp) + fmul %st(1), %st + fld %st(0) + movq 336(%rsp), %rbx + fsubr %st(2), %st + sarl $1, %r11d + faddp %st, %st(1) + fld %st(0) + movl %r11d, 32(%rbx) + fsubr %st(2), %st + fld %st(1) + fmul %st(2), %st + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%rsp) + fmulp %st, %st(1) + fdiv %st(1), %st + fld %st(0) + fadd %st(2), %st + fstpt (%rbx) + fldt (%rbx) + fsubrp %st, %st(2) + movzwl 8(%r13), %ebp + movl %ebp, %r10d + andl $32767, %r10d + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%rbx) + cmpl $8383, %r10d + fstpt 48(%rsp) + jl ..B1.165 +..B1.162: + cmpl $24383, %r10d + jg ..B1.165 +..B1.163: + movzwl 8(%rbx), %esi + movl %esi, %r8d + andl $32767, %r8d + cmpl $8383, %r8d + jl ..B1.165 +..B1.164: + cmpl $24383, %r8d + jle ..B1.168 +..B1.165: + movq %r13, %rdi +..___tag_value___libm_carctrigprepare_k80.50: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.51: +..B1.166: + movq %rbx, %rdi +..___tag_value___libm_carctrigprepare_k80.52: + call __libm_normalizel_k80@PLT +..___tag_value___libm_carctrigprepare_k80.53: +..B1.167: + movzwl 8(%r13), %ebp + movl %ebp, %r10d + movzwl 8(%rbx), %esi + movl %esi, %r8d + movl 32(%rbx), %r11d + andl $32767, %r10d + andl $32767, %r8d +..B1.168: + movl 32(%r13), %r9d + lea -134(%r11,%r8), %edx + movq 344(%rsp), %rax + lea (%r10,%r9), %ecx + cmpl %edx, %ecx + jle ..B1.185 +..B1.169: + lea 134(%r11,%r8), %edx + cmpl %edx, %ecx + jge ..B1.185 +..B1.170: + cmpl $0, 4(%r13) + jne ..B1.172 +..B1.171: + cmpl $0, (%r13) + je ..B1.185 +..B1.172: + cmpl $0, 4(%rbx) + jne ..B1.174 +..B1.173: + cmpl $0, (%rbx) + je ..B1.185 +..B1.174: + cmpl %r11d, %r9d + je ..B1.176 +..B1.175: + fldt 48(%rsp) + subl %r11d, %r9d + fstpt (%rsp) + addl $16383, %r9d + fldt (%r13) + andl $32767, %r9d + fldt 16(%r13) + andb $127, 9(%rsp) + movzwl 8(%rsp), %edx + andl $-32768, %edx + orl %r9d, %edx + movw %dx, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %r11d, 32(%r13) + fxch %st(2) + fstpt (%r13) + fldt (%r13) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%r13) + movl 32(%rbx), %r11d + movzwl 8(%rbx), %esi + movzwl 8(%r13), %ebp + jmp ..B1.177 +..B1.176: + fldt (%r13) +..B1.177: + fldt (%rbx) + fld %st(1) + andl $32767, %ebp + andl $32767, %esi + movl %r11d, 32(%rax) + cmpl %esi, %ebp + fadd %st(1), %st + fstpt 16(%rax) + fldt 16(%rax) + jg ..B1.182 +..B1.178: + jne ..B1.183 +..B1.179: + movl 4(%r13), %edx + cmpl 4(%rbx), %edx + ja ..B1.182 +..B1.180: + jne ..B1.183 +..B1.181: + movl (%r13), %edx + cmpl (%rbx), %edx + jbe ..B1.183 +..B1.182: + fldt 16(%rbx) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 16(%r13) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B1.184 +..B1.183: + fldt 16(%r13) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 16(%rbx) + faddp %st, %st(1) + fstpt (%rsp) + fldt (%rsp) +..B1.184: + fld %st(0) + fadd %st(2), %st + fstpt (%rax) + fldt (%rax) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rax) + jmp ..B1.189 +..B1.185: + cmpq $0, (%r13) + je ..B1.187 +..B1.186: + lea -16517(%r11,%r8), %edx + lea -16383(%r9,%r10), %ecx + cmpl %ecx, %edx + jl ..B1.188 +..B1.187: + movq (%rbx), %rdx + movq %rdx, (%rax) + movq 8(%rbx), %rcx + movq %rcx, 8(%rax) + movq 16(%rbx), %rbp + movq %rbp, 16(%rax) + movq 24(%rbx), %rsi + movq %rsi, 24(%rax) + movq 32(%rbx), %r8 + movq %r8, 32(%rax) + movq 40(%rbx), %rbx + movq %rbx, 40(%rax) + jmp ..B1.189 +..B1.188: + movq (%r13), %rdx + movq %rdx, (%rax) + movq 8(%r13), %rcx + movq %rcx, 8(%rax) + movq 16(%r13), %rbx + movq %rbx, 16(%rax) + movq 24(%r13), %rbp + movq %rbp, 24(%rax) + movq 32(%r13), %rsi + movq %rsi, 32(%rax) + movq 40(%r13), %rdi + movq %rdi, 40(%rax) +..B1.189: + movq 256(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.191 +..B1.190: + addq $272, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 320 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.191: + call __stack_chk_fail@PLT +..B1.192: + fldt 208(%rsp) + incl %r11d + fldt 32(%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 208(%rsp) + fldt 224(%rsp) + fmulp %st, %st(1) + movl %r11d, 240(%rsp) + fstpt 224(%rsp) + fldt 224(%rsp) + jmp ..B1.161 +..B1.193: + fldt 160(%rsp) + incl %edx + lea halfs(%rip), %rax + movl %edx, 192(%rsp) + fldt (%rax) + fmul %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fstpt 160(%rsp) + fstpt 32(%rsp) + fldt 32(%rsp) + fldt 176(%rsp) + fmulp %st, %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + jmp ..B1.96 + .align 16,0x90 + .cfi_endproc + .type __libm_carctrigprepare_k80,@function + .size __libm_carctrigprepare_k80,.-__libm_carctrigprepare_k80 + .data +# -- End __libm_carctrigprepare_k80 + .text +# -- Begin __libm_recacosl_k80 + .text + .align 16,0x90 + .globl __libm_recacosl_k80 +__libm_recacosl_k80: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +# parameter 7: 864 + %rsp +# parameter 8: 872 + %rsp +# parameter 9: 880 + %rsp +# parameter 10: 888 + %rsp +..B2.1: + .cfi_startproc +..___tag_value___libm_recacosl_k80.72: +..L73: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $808, %rsp + .cfi_def_cfa_offset 864 + movq %rdx, %r12 + movq %fs:40, %rax + movq %r9, %r15 + xorq %rsp, %rax + movq %r8, %rbp + movq %rax, 800(%rsp) + movq %rdi, %r14 + movzwl 8(%r12), %eax + andl $32767, %eax + movq 888(%rsp), %r13 + cmpl $8383, %eax + jl ..B2.5 +..B2.2: + cmpl $24383, %eax + jg ..B2.5 +..B2.3: + movzwl 8(%r13), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.5 +..B2.4: + cmpl $24383, %eax + jle ..B2.7 +..B2.5: + movq %r12, %rdi +..___tag_value___libm_recacosl_k80.87: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.88: +..B2.6: + movq %r13, %rdi +..___tag_value___libm_recacosl_k80.89: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.90: +..B2.7: + fldt (%r12) + lea t32(%rip), %rax + fld %st(0) + fldt (%r13) + fdivr %st, %st(1) + fld %st(0) + fld %st(1) + fldt (%rax) + fld %st(0) + fmul %st(5), %st + fld %st(0) + movl 32(%r12), %ebx + fsubr %st(6), %st + subl 32(%r13), %ebx + faddp %st, %st(1) + fld %st(0) + lea 1(%rbx), %edx + movl %edx, 784(%rsp) + fsubr %st(6), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(4) + fld %st(4) + fsub %st(4), %st + fxch %st(3) + fstpt 48(%rsp) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fsubrp %st, %st(3) + fldt 16(%r12) + faddp %st, %st(3) + fldt 16(%r13) + fmul %st(2), %st + fsubrp %st, %st(3) + fdivrp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 752(%rsp) + fldt 752(%rsp) + fsubrp %st, %st(1) + movzwl 760(%rsp), %ecx + fadd %st(1), %st + andl $32767, %ecx + fstpt 768(%rsp) + fstpt 16(%rsp) + lea 1(%rcx,%rbx), %esi + cmpl $16382, %esi + jl ..B2.192 +..B2.8: + movzwl 8(%r14), %eax + andl $32767, %eax + movq 880(%rsp), %rbx + cmpl $16383, %eax + jl ..B2.37 +..B2.9: + movq 864(%rsp), %r9 + movq (%r9), %rax + movq 8(%r9), %rdx + movq 16(%r9), %rcx + movq 24(%r9), %rsi + movq 32(%r9), %r8 + movq 40(%r9), %r10 + movzwl 8(%rbx), %r9d + movq %rax, 416(%rsp) + movl %r9d, %eax + andl $32767, %eax + movq %rdx, 424(%rsp) + cmpl $8383, %eax + movq %rcx, 432(%rsp) + movq %rsi, 440(%rsp) + movq %r8, 448(%rsp) + movq %r10, 456(%rsp) + jl ..B2.13 +..B2.10: + cmpl $24383, %eax + jg ..B2.13 +..B2.11: + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %r11d + cmpl $8383, %r11d + jl ..B2.13 +..B2.12: + cmpl $24383, %r11d + jle ..B2.16 +..B2.13: + movq %rbx, %rdi +..___tag_value___libm_recacosl_k80.91: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.92: +..B2.14: + movq %rbp, %rdi +..___tag_value___libm_recacosl_k80.93: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.94: +..B2.15: + movzwl 8(%rbx), %r9d + movl %r9d, %eax + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %eax + andl $32767, %r11d +..B2.16: + movl 32(%rbp), %edx + movl 32(%rbx), %ecx + lea -134(%rdx,%r11), %esi + lea (%rax,%rcx), %r8d + cmpl %r8d, %esi + jge ..B2.33 +..B2.17: + lea 134(%rdx,%r11), %esi + cmpl %esi, %r8d + jge ..B2.33 +..B2.18: + cmpl $0, 4(%rbx) + jne ..B2.20 +..B2.19: + cmpl $0, (%rbx) + je ..B2.33 +..B2.20: + cmpl $0, 4(%rbp) + jne ..B2.22 +..B2.21: + cmpl $0, (%rbp) + je ..B2.33 +..B2.22: + cmpl %edx, %ecx + je ..B2.24 +..B2.23: + fldt 16(%rsp) + subl %edx, %ecx + fstpt (%rsp) + addl $16383, %ecx + fldt (%rbx) + andl $32767, %ecx + fldt 16(%rbx) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 32(%rbx) + fxch %st(2) + fstpt (%rbx) + fldt (%rbx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbx) + fldt 16(%rbx) + fxch %st(1) + fstpt 16(%rsp) + movl 32(%rbp), %edx + movzwl 8(%rbp), %r10d + movzwl 8(%rbx), %r9d + jmp ..B2.25 +..B2.24: + fldt (%rbx) + fstpt 16(%rsp) + fldt 16(%rbx) +..B2.25: + fldt (%rbp) + andl $32767, %r9d + fldt 16(%rsp) + andl $32767, %r10d + movl %edx, 496(%rsp) + cmpl %r10d, %r9d + fadd %st(1), %st + jg ..B2.30 +..B2.26: + jne ..B2.31 +..B2.27: + movl 4(%rbx), %eax + cmpl 4(%rbp), %eax + ja ..B2.30 +..B2.28: + jne ..B2.31 +..B2.29: + movl (%rbx), %eax + cmpl (%rbp), %eax + jbe ..B2.31 +..B2.30: + fldt 16(%rsp) + fsub %st(1), %st + faddp %st, %st(2) + fldt 16(%rbp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B2.32 +..B2.31: + fldt 16(%rsp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 16(%rbp) + faddp %st, %st(1) + fstpt 16(%rsp) +..B2.32: + fldt 16(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 464(%rsp) + fldt 464(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 480(%rsp) + jmp ..B2.65 +..B2.33: + cmpq $0, (%rbx) + je ..B2.35 +..B2.34: + lea -16517(%rdx,%r11), %edx + lea -16383(%rcx,%rax), %eax + cmpl %eax, %edx + jl ..B2.36 +..B2.35: + movq (%rbp), %rax + movq 8(%rbp), %rdx + movq 16(%rbp), %rcx + movq 24(%rbp), %rbx + movq 32(%rbp), %rsi + movq 40(%rbp), %rbp + movq %rax, 464(%rsp) + movq %rdx, 472(%rsp) + movq %rcx, 480(%rsp) + movq %rbx, 488(%rsp) + movq %rsi, 496(%rsp) + movq %rbp, 504(%rsp) + jmp ..B2.65 +..B2.36: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rbp + movq 32(%rbx), %rsi + movq 40(%rbx), %rbx + movq %rax, 464(%rsp) + movq %rdx, 472(%rsp) + movq %rcx, 480(%rsp) + movq %rbp, 488(%rsp) + movq %rsi, 496(%rsp) + movq %rbx, 504(%rsp) + jmp ..B2.65 +..B2.37: + lea ones(%rip), %rax + lea zeros(%rip), %rdx + movzwl 8(%rbx), %r9d + movl $0, 496(%rsp) + fldt (%rax) + movl %r9d, %eax + andl $32767, %eax + fstpt 464(%rsp) + cmpl $8383, %eax + fldt (%rdx) + fstpt 480(%rsp) + jl ..B2.41 +..B2.38: + cmpl $24383, %eax + jg ..B2.41 +..B2.39: + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %r11d + cmpl $8383, %r11d + jl ..B2.41 +..B2.40: + cmpl $24383, %r11d + jle ..B2.44 +..B2.41: + movq %rbx, %rdi +..___tag_value___libm_recacosl_k80.95: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.96: +..B2.42: + movq %rbp, %rdi +..___tag_value___libm_recacosl_k80.97: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.98: +..B2.43: + movzwl 8(%rbx), %r9d + movl %r9d, %eax + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %eax + andl $32767, %r11d +..B2.44: + movl 32(%rbp), %edx + movl 32(%rbx), %ecx + lea -134(%rdx,%r11), %esi + lea (%rax,%rcx), %r8d + cmpl %r8d, %esi + jge ..B2.61 +..B2.45: + lea 134(%rdx,%r11), %esi + cmpl %esi, %r8d + jge ..B2.61 +..B2.46: + cmpl $0, 4(%rbx) + jne ..B2.48 +..B2.47: + cmpl $0, (%rbx) + je ..B2.61 +..B2.48: + cmpl $0, 4(%rbp) + jne ..B2.50 +..B2.49: + cmpl $0, (%rbp) + je ..B2.61 +..B2.50: + cmpl %edx, %ecx + je ..B2.52 +..B2.51: + fldt 16(%rsp) + subl %edx, %ecx + fstpt (%rsp) + addl $16383, %ecx + fldt (%rbx) + andl $32767, %ecx + fldt 16(%rbx) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 32(%rbx) + fxch %st(2) + fstpt (%rbx) + fldt (%rbx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbx) + fldt 16(%rbx) + fstpt 16(%rsp) + movl 32(%rbp), %edx + movzwl 8(%rbp), %r10d + movzwl 8(%rbx), %r9d + jmp ..B2.53 +..B2.52: + fldt (%rbx) + fldt 16(%rbx) + fstpt 16(%rsp) +..B2.53: + fldt (%rbp) + andl $32767, %r9d + andl $32767, %r10d + fld %st(1) + movl %edx, 448(%rsp) + cmpl %r10d, %r9d + fsub %st(1), %st + jg ..B2.58 +..B2.54: + jne ..B2.59 +..B2.55: + movl 4(%rbx), %eax + cmpl 4(%rbp), %eax + ja ..B2.58 +..B2.56: + jne ..B2.59 +..B2.57: + movl (%rbx), %eax + cmpl (%rbp), %eax + jbe ..B2.59 +..B2.58: + fldt 16(%rsp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fldt 16(%rbp) + fsubrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + jmp ..B2.60 +..B2.59: + fldt 16(%rbp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fldt 16(%rsp) + faddp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) +..B2.60: + fldt 16(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 432(%rsp) + jmp ..B2.65 +..B2.61: + cmpq $0, (%rbx) + je ..B2.63 +..B2.62: + lea -16517(%rdx,%r11), %esi + lea -16383(%rcx,%rax), %eax + cmpl %eax, %esi + jl ..B2.64 +..B2.63: + fldt (%rbp) + fchs + movl %edx, 448(%rsp) + fstpt 416(%rsp) + fldt 16(%rbp) + fchs + fstpt 432(%rsp) + jmp ..B2.65 +..B2.64: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rbp + movq 32(%rbx), %rsi + movq 40(%rbx), %rbx + movq %rax, 416(%rsp) + movq %rdx, 424(%rsp) + movq %rcx, 432(%rsp) + movq %rbp, 440(%rsp) + movq %rsi, 448(%rsp) + movq %rbx, 456(%rsp) +..B2.65: + movzwl 8(%r12), %ebp + movl %ebp, %r9d + andl $32767, %r9d + movl 32(%r12), %edx + incl %edx + movl %edx, 32(%r12) + cmpl $8383, %r9d + jl ..B2.69 +..B2.66: + cmpl $24383, %r9d + jg ..B2.69 +..B2.67: + movzwl 8(%r13), %eax + movl %eax, %r8d + andl $32767, %r8d + cmpl $8383, %r8d + jl ..B2.69 +..B2.68: + cmpl $24383, %r8d + jle ..B2.72 +..B2.69: + movq %r12, %rdi +..___tag_value___libm_recacosl_k80.99: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.100: +..B2.70: + movq %r13, %rdi +..___tag_value___libm_recacosl_k80.101: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.102: +..B2.71: + movzwl 8(%r12), %ebp + movl %ebp, %r9d + movzwl 8(%r13), %eax + movl %eax, %r8d + movl 32(%r12), %edx + andl $32767, %r9d + andl $32767, %r8d +..B2.72: + movl 32(%r13), %esi + lea (%rdx,%r9), %ebx + lea -134(%rsi,%r8), %ecx + cmpl %ecx, %ebx + jle ..B2.89 +..B2.73: + lea 134(%rsi,%r8), %ecx + cmpl %ecx, %ebx + jge ..B2.89 +..B2.74: + cmpl $0, 4(%r12) + jne ..B2.76 +..B2.75: + cmpl $0, (%r12) + je ..B2.89 +..B2.76: + cmpl $0, 4(%r13) + jne ..B2.78 +..B2.77: + cmpl $0, (%r13) + je ..B2.89 +..B2.78: + cmpl %esi, %edx + je ..B2.80 +..B2.79: + fldt 16(%rsp) + subl %esi, %edx + fstpt (%rsp) + addl $16383, %edx + fldt (%r12) + andl $32767, %edx + fldt 16(%r12) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edx, %eax + movl %esi, %edx + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %esi, 32(%r12) + fxch %st(2) + fstpt (%r12) + fldt (%r12) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%r12) + fldt 16(%r12) + movl 32(%r13), %esi + movzwl 8(%r13), %eax + movzwl 8(%r12), %ebp + jmp ..B2.81 +..B2.80: + fldt (%r12) + fldt 16(%r12) +..B2.81: + fldt (%r13) + movl %eax, %ecx + andl $32767, %ebp + andl $32767, %ecx + fld %st(2) + cmpl %ecx, %ebp + movl %esi, 544(%rsp) + fadd %st(1), %st + jg ..B2.86 +..B2.82: + jne ..B2.87 +..B2.83: + movl 4(%r12), %ecx + cmpl 4(%r13), %ecx + ja ..B2.86 +..B2.84: + jne ..B2.87 +..B2.85: + movl (%r12), %ecx + cmpl (%r13), %ecx + jbe ..B2.87 +..B2.86: + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 16(%r13) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + jmp ..B2.88 +..B2.87: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%r13) + faddp %st, %st(2) +..B2.88: + fld %st(1) + fadd %st(1), %st + fstpt 512(%rsp) + fldt 512(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 528(%rsp) + jmp ..B2.93 +..B2.89: + cmpq $0, (%r12) + je ..B2.91 +..B2.90: + lea -16517(%rsi,%r8), %ecx + lea -16383(%rdx,%r9), %ebx + cmpl %ebx, %ecx + jl ..B2.92 +..B2.91: + movq (%r13), %rcx + movq 8(%r13), %rbx + movq 16(%r13), %rbp + movq 24(%r13), %rsi + movq 32(%r13), %r8 + movq 40(%r13), %r9 + movq %rcx, 512(%rsp) + movq %rbx, 520(%rsp) + movq %rbp, 528(%rsp) + movq %rsi, 536(%rsp) + movq %r8, 544(%rsp) + movq %r9, 552(%rsp) + jmp ..B2.93 +..B2.92: + movq (%r12), %rcx + movq 8(%r12), %rbx + movq 16(%r12), %rbp + movq 24(%r12), %rsi + movq 32(%r12), %r8 + movq 40(%r12), %r9 + movq %rcx, 512(%rsp) + movq %rbx, 520(%rsp) + movq %rbp, 528(%rsp) + movq %rsi, 536(%rsp) + movq %r8, 544(%rsp) + movq %r9, 552(%rsp) +..B2.93: + decl %edx + movl %edx, 32(%r12) + movzwl 520(%rsp), %edx + andl $32767, %edx + cmpl $8383, %edx + jl ..B2.97 +..B2.94: + cmpl $24383, %edx + jg ..B2.97 +..B2.95: + movzwl 424(%rsp), %edx + andl $32767, %edx + cmpl $8383, %edx + jl ..B2.97 +..B2.96: + cmpl $24383, %edx + jle ..B2.99 +..B2.97: + lea 512(%rsp), %rdi +..___tag_value___libm_recacosl_k80.103: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.104: +..B2.98: + lea 416(%rsp), %rdi +..___tag_value___libm_recacosl_k80.105: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.106: + movzwl 8(%r13), %eax +..B2.99: + fldt 512(%rsp) + andl $32767, %eax + fld %st(0) + fld %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(4), %st + movl 544(%rsp), %edx + fsubr %st, %st(3) + addl 448(%rsp), %edx + faddp %st, %st(3) + fld %st(2) + cmpl $8383, %eax + movl %edx, 592(%rsp) + fxch %st(2) + fsub %st(3), %st + fldt 416(%rsp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 432(%rsp) + fmulp %st, %st(4) + fldt 528(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 560(%rsp) + fldt 560(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 576(%rsp) + jl ..B2.103 +..B2.100: + cmpl $24383, %eax + jg ..B2.103 +..B2.101: + movzwl 472(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.103 +..B2.102: + cmpl $24383, %eax + jle ..B2.105 +..B2.103: + movq %r13, %rdi +..___tag_value___libm_recacosl_k80.107: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.108: +..B2.104: + lea 464(%rsp), %rdi +..___tag_value___libm_recacosl_k80.109: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.110: +..B2.105: + fldt (%r13) + fld %st(0) + fld %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(4), %st + movq 872(%rsp), %rbx + fsubr %st, %st(3) + movzwl 8(%rbx), %ecx + movl %ecx, %r10d + movl 496(%rsp), %eax + andl $32767, %r10d + addl 32(%r13), %eax + faddp %st, %st(3) + fld %st(2) + cmpl $8383, %r10d + movl %eax, 640(%rsp) + fxch %st(2) + fsub %st(3), %st + fldt 464(%rsp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 480(%rsp) + fmulp %st, %st(4) + fldt 16(%r13) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 608(%rsp) + fldt 608(%rsp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 624(%rsp) + fstpt 16(%rsp) + jl ..B2.109 +..B2.106: + cmpl $24383, %r10d + jg ..B2.109 +..B2.107: + movzwl 8(%r15), %ebp + movl %ebp, %r8d + andl $32767, %r8d + cmpl $8383, %r8d + jl ..B2.109 +..B2.108: + cmpl $24383, %r8d + jle ..B2.112 +..B2.109: + movq %rbx, %rdi +..___tag_value___libm_recacosl_k80.111: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.112: +..B2.110: + movq %r15, %rdi +..___tag_value___libm_recacosl_k80.113: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.114: +..B2.111: + movzwl 8(%rbx), %ecx + movl %ecx, %r10d + movzwl 8(%r15), %ebp + movl %ebp, %r8d + andl $32767, %r10d + andl $32767, %r8d +..B2.112: + movl 32(%r15), %esi + movl 32(%rbx), %r9d + lea -134(%rsi,%r8), %eax + lea (%r10,%r9), %edx + cmpl %eax, %edx + jle ..B2.129 +..B2.113: + lea 134(%rsi,%r8), %eax + cmpl %eax, %edx + jge ..B2.129 +..B2.114: + cmpl $0, 4(%rbx) + jne ..B2.116 +..B2.115: + cmpl $0, (%rbx) + je ..B2.129 +..B2.116: + cmpl $0, 4(%r15) + jne ..B2.118 +..B2.117: + cmpl $0, (%r15) + je ..B2.129 +..B2.118: + cmpl %esi, %r9d + je ..B2.120 +..B2.119: + fldt 16(%rsp) + subl %esi, %r9d + fstpt (%rsp) + addl $16383, %r9d + fldt (%rbx) + andl $32767, %r9d + fldt 16(%rbx) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %r9d, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %esi, 32(%rbx) + fxch %st(2) + fstpt (%rbx) + fldt (%rbx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbx) + fldt 16(%rbx) + movl 32(%r15), %esi + movzwl 8(%r15), %ebp + movzwl 8(%rbx), %ecx + jmp ..B2.121 +..B2.120: + fldt (%rbx) + fldt 16(%rbx) +..B2.121: + fldt (%r15) + andl $32767, %ecx + andl $32767, %ebp + fld %st(2) + movl %esi, 688(%rsp) + cmpl %ebp, %ecx + fadd %st(1), %st + jg ..B2.126 +..B2.122: + jne ..B2.127 +..B2.123: + movl 4(%rbx), %eax + cmpl 4(%r15), %eax + ja ..B2.126 +..B2.124: + jne ..B2.127 +..B2.125: + movl (%rbx), %eax + cmpl (%r15), %eax + jbe ..B2.127 +..B2.126: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 16(%r15) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B2.128 +..B2.127: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 16(%r15) + faddp %st, %st(1) +..B2.128: + fld %st(0) + fadd %st(2), %st + fstpt 656(%rsp) + fldt 656(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 672(%rsp) + jmp ..B2.133 +..B2.129: + cmpq $0, (%rbx) + je ..B2.131 +..B2.130: + lea -16517(%rsi,%r8), %eax + lea -16383(%r9,%r10), %edx + cmpl %edx, %eax + jl ..B2.132 +..B2.131: + movq (%r15), %rax + movq 8(%r15), %rdx + movq 16(%r15), %rcx + movq 24(%r15), %rbx + movq 32(%r15), %rbp + movq 40(%r15), %rsi + movq %rax, 656(%rsp) + movq %rdx, 664(%rsp) + movq %rcx, 672(%rsp) + movq %rbx, 680(%rsp) + movq %rbp, 688(%rsp) + movq %rsi, 696(%rsp) + jmp ..B2.133 +..B2.132: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rbp + movq 32(%rbx), %rsi + movq 40(%rbx), %rbx + movq %rax, 656(%rsp) + movq %rdx, 664(%rsp) + movq %rcx, 672(%rsp) + movq %rbp, 680(%rsp) + movq %rsi, 688(%rsp) + movq %rbx, 696(%rsp) +..B2.133: + movzwl 616(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.137 +..B2.134: + cmpl $24383, %eax + jg ..B2.137 +..B2.135: + movzwl 664(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.137 +..B2.136: + cmpl $24383, %eax + jle ..B2.139 +..B2.137: + lea 608(%rsp), %rdi +..___tag_value___libm_recacosl_k80.115: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.116: +..B2.138: + lea 656(%rsp), %rdi +..___tag_value___libm_recacosl_k80.117: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.118: +..B2.139: + fldt 608(%rsp) + fld %st(0) + fld %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(4), %st + movl 640(%rsp), %edx + fsubr %st, %st(3) + movzwl 568(%rsp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + addl 688(%rsp), %edx + fxch %st(2) + fsub %st(3), %st + fldt 656(%rsp) + cmpl $8383, %eax + fmul %st, %st(2) + fld %st(0) + movl %edx, 736(%rsp) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 672(%rsp) + fmulp %st, %st(4) + fldt 624(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 704(%rsp) + fldt 704(%rsp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 720(%rsp) + fldt 720(%rsp) + jl ..B2.143 +..B2.140: + cmpl $24383, %eax + jg ..B2.143 +..B2.141: + movzwl 712(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B2.143 +..B2.142: + cmpl $24383, %eax + jle ..B2.146 +..B2.143: + fstp %st(1) + fstp %st(0) + lea 560(%rsp), %rdi +..___tag_value___libm_recacosl_k80.119: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.120: +..B2.144: + lea 704(%rsp), %rdi +..___tag_value___libm_recacosl_k80.121: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.122: +..B2.145: + fldt 704(%rsp) + fldt 720(%rsp) + movl 736(%rsp), %edx +..B2.146: + fldt 560(%rsp) + fld %st(2) + fdivr %st(1), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(4) + fstpt 32(%rsp) + fldt 32(%rsp) + fldt 48(%rsp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + movl 592(%rsp), %ecx + fsubr %st(4), %st + subl %edx, %ecx + faddp %st, %st(1) + fld %st(0) + testb $-128, 9(%r14) + fsubr %st(4), %st + fxch %st(2) + fmul %st(3), %st + fsubr %st, %st(7) + faddp %st, %st(7) + fxch %st(2) + fsub %st(6), %st + fld %st(2) + fmul %st(7), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(3) + fxch %st(7) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fxch %st(4) + fsubrp %st, %st(2) + fxch %st(3) + fsubrp %st, %st(1) + fldt 576(%rsp) + faddp %st, %st(1) + fsubp %st, %st(1) + fldt 32(%rsp) + fdivrp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fstpt 16(%rsp) + jne ..B2.155 +..B2.147: + fstpt 320(%rsp) + fldt 320(%rsp) + decl %ecx + movzwl 328(%rsp), %eax + andl $32767, %eax + movl %ecx, 352(%rsp) + cmpl $383, %eax + fxch %st(1) + fstpt 336(%rsp) + fldt 336(%rsp) + jl ..B2.149 +..B2.148: + cmpl $32383, %eax + jle ..B2.151 +..B2.149: + fstp %st(0) + fstp %st(0) + lea 320(%rsp), %rdi +..___tag_value___libm_recacosl_k80.123: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.124: +..B2.150: + fldt 320(%rsp) + fldt 336(%rsp) + movl 352(%rsp), %ecx +..B2.151: + testb $1, %cl + jne ..B2.226 +..B2.152: + lea halfs(%rip), %rax + fldt (%rax) +..B2.153: + fldt 48(%rsp) + fld %st(3) + fsqrt + lea 224(%rsp), %rdi + fmul %st, %st(1) + lea 368(%rsp), %rsi + fld %st(1) + sarl $1, %ecx + fsubr %st(1), %st + movl %ecx, 32(%rsi) + faddp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + fdivr %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt (%rsi) + fldt (%rsi) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsi) +..___tag_value___libm_recacosl_k80.125: + call asinpoly +..___tag_value___libm_recacosl_k80.126: +..B2.154: + fldt 224(%rsp) + fldt 240(%rsp) + movl 256(%rsp), %edi + incl %edi + movl %edi, 256(%rsp) + jmp ..B2.223 +..B2.155: + fstpt 128(%rsp) + fldt 128(%rsp) + decl %ecx + movzwl 136(%rsp), %eax + andl $32767, %eax + movl %ecx, 160(%rsp) + cmpl $383, %eax + fxch %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + jl ..B2.157 +..B2.156: + cmpl $32383, %eax + jle ..B2.159 +..B2.157: + fstp %st(0) + fstp %st(0) + lea 128(%rsp), %rdi +..___tag_value___libm_recacosl_k80.127: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.128: +..B2.158: + fldt 128(%rsp) + fldt 144(%rsp) + movl 160(%rsp), %ecx +..B2.159: + testb $1, %cl + jne ..B2.227 +..B2.160: + lea halfs(%rip), %rax + fldt (%rax) +..B2.161: + fldt 48(%rsp) + fld %st(3) + fsqrt + lea 80(%rsp), %rdi + fmul %st, %st(1) + lea 176(%rsp), %rsi + fld %st(1) + sarl $1, %ecx + fsubr %st(1), %st + movl %ecx, 32(%rsi) + faddp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + fdivr %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt (%rsi) + fldt (%rsi) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsi) +..___tag_value___libm_recacosl_k80.129: + call asinpoly +..___tag_value___libm_recacosl_k80.130: +..B2.162: + lea 16+_PIO2_K80(%rip), %rax + lea 32+_PIO2_K80(%rip), %rdx + movl 112(%rsp), %edi + movl $1, %ebp + incl %edi + movl %edi, 112(%rsp) + fldt (%rax) + movzwl 8(%rax), %esi + andl $32767, %esi + movl $1, 304(%rsp) + cmpl $8383, %esi + fstpt 272(%rsp) + fldt (%rdx) + fstpt 288(%rsp) + jl ..B2.166 +..B2.163: + cmpl $24383, %esi + jg ..B2.166 +..B2.164: + movzwl 88(%rsp), %ebx + andl $32767, %ebx + cmpl $8383, %ebx + jl ..B2.166 +..B2.165: + cmpl $24383, %ebx + jle ..B2.169 +..B2.166: + lea 272(%rsp), %rdi +..___tag_value___libm_recacosl_k80.131: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.132: +..B2.167: + lea 80(%rsp), %rdi +..___tag_value___libm_recacosl_k80.133: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.134: +..B2.168: + movzwl 280(%rsp), %esi + movzwl 88(%rsp), %ebx + andl $32767, %esi + movl 112(%rsp), %edi + andl $32767, %ebx + movl 304(%rsp), %ebp +..B2.169: + lea (%rbp,%rsi), %edx + lea -134(%rdi,%rbx), %eax + cmpl %eax, %edx + jle ..B2.186 +..B2.170: + movl 276(%rsp), %ecx + lea 134(%rdi,%rbx), %eax + cmpl %eax, %edx + jge ..B2.187 +..B2.171: + testl %ecx, %ecx + jne ..B2.173 +..B2.172: + cmpl $0, 272(%rsp) + je ..B2.188 +..B2.173: + movl 84(%rsp), %edx + testl %edx, %edx + jne ..B2.175 +..B2.174: + cmpl $0, 80(%rsp) + je ..B2.187 +..B2.175: + cmpl %edi, %ebp + je ..B2.177 +..B2.176: + fldt 16(%rsp) + subl %edi, %ebp + fstpt (%rsp) + addl $16383, %ebp + fldt 272(%rsp) + andl $32767, %ebp + fldt 288(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ebp, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 272(%rsp) + fldt 272(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 280(%rsp), %esi + movl %edi, 304(%rsp) + andl $32767, %esi + fstpt 288(%rsp) + fldt 288(%rsp) + jmp ..B2.178 +..B2.177: + fldt 272(%rsp) + fldt 288(%rsp) +..B2.178: + fldt 80(%rsp) + fld %st(2) + movl %edi, 256(%rsp) + cmpl %ebx, %esi + fsub %st(1), %st + jg ..B2.183 +..B2.179: + jne ..B2.184 +..B2.180: + movl 276(%rsp), %eax + cmpl %edx, %eax + ja ..B2.183 +..B2.181: + jne ..B2.184 +..B2.182: + movl 272(%rsp), %eax + cmpl 80(%rsp), %eax + jbe ..B2.184 +..B2.183: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 96(%rsp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B2.185 +..B2.184: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 96(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) +..B2.185: + fld %st(0) + fadd %st(2), %st + fstpt 224(%rsp) + fldt 224(%rsp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 240(%rsp) + fldt 240(%rsp) + jmp ..B2.223 +..B2.186: + movl 276(%rsp), %ecx +..B2.187: + testl %ecx, %ecx + jne ..B2.189 +..B2.232: + cmpl $0, 272(%rsp) +..B2.188: + je ..B2.190 +..B2.189: + lea -16517(%rdi,%rbx), %eax + lea -16383(%rbp,%rsi), %edx + cmpl %edx, %eax + jl ..B2.191 +..B2.190: + fldt 80(%rsp) + fchs + movl %edi, 256(%rsp) + fstpt 224(%rsp) + fldt 224(%rsp) + fldt 96(%rsp) + fchs + fstpt 240(%rsp) + fldt 240(%rsp) + jmp ..B2.223 +..B2.191: + fldt 272(%rsp) + fldt 288(%rsp) + movaps 272(%rsp), %xmm0 + movaps 288(%rsp), %xmm1 + movaps 304(%rsp), %xmm2 + movl 304(%rsp), %edi + movaps %xmm0, 224(%rsp) + movaps %xmm1, 240(%rsp) + movaps %xmm2, 256(%rsp) + jmp ..B2.223 +..B2.192: + lea 16+_PIO2_K80(%rip), %rax + lea 32+_PIO2_K80(%rip), %rdx + movl $0, 64(%rsp) + lea 80(%rsp), %rdi + lea 752(%rsp), %rsi + fldt (%rax) + fstpt -48(%rdi) + fldt (%rdx) + fstpt -32(%rdi) +..___tag_value___libm_recacosl_k80.135: + call asinpoly +..___tag_value___libm_recacosl_k80.136: +..B2.193: + fldt 80(%rsp) + lea ones(%rip), %rcx + fldt 96(%rsp) + movb 9(%r14), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + shlq $4, %rdx + movzwl 40(%rsp), %ebp + andl $32767, %ebp + cmpl $8383, %ebp + fldt (%rdx,%rcx) + fmul %st, %st(2) + fxch %st(2) + fstpt 80(%rsp) + fmulp %st, %st(1) + fstpt 96(%rsp) + jl ..B2.197 +..B2.194: + cmpl $24383, %ebp + jg ..B2.197 +..B2.195: + movzwl 88(%rsp), %ebx + andl $32767, %ebx + cmpl $8383, %ebx + jl ..B2.197 +..B2.196: + cmpl $24383, %ebx + jle ..B2.200 +..B2.197: + lea 32(%rsp), %rdi +..___tag_value___libm_recacosl_k80.137: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.138: +..B2.198: + lea 80(%rsp), %rdi +..___tag_value___libm_recacosl_k80.139: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recacosl_k80.140: +..B2.199: + movzwl 88(%rsp), %ebx + movzwl 40(%rsp), %ebp + andl $32767, %ebx + andl $32767, %ebp +..B2.200: + movl 112(%rsp), %edi + movl 64(%rsp), %esi + lea -134(%rdi,%rbx), %eax + lea (%rbp,%rsi), %edx + cmpl %eax, %edx + jle ..B2.217 +..B2.201: + movl 36(%rsp), %ecx + lea 134(%rdi,%rbx), %eax + cmpl %eax, %edx + jge ..B2.218 +..B2.202: + testl %ecx, %ecx + jne ..B2.204 +..B2.203: + cmpl $0, 32(%rsp) + je ..B2.219 +..B2.204: + movl 84(%rsp), %edx + testl %edx, %edx + jne ..B2.206 +..B2.205: + cmpl $0, 80(%rsp) + je ..B2.218 +..B2.206: + cmpl %edi, %esi + je ..B2.208 +..B2.207: + fldt 16(%rsp) + subl %edi, %esi + fstpt (%rsp) + addl $16383, %esi + fldt 32(%rsp) + andl $32767, %esi + fldt 48(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %esi, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 40(%rsp), %ebp + movl %edi, 64(%rsp) + andl $32767, %ebp + fstpt 48(%rsp) + fldt 48(%rsp) + jmp ..B2.209 +..B2.208: + fldt 32(%rsp) + fldt 48(%rsp) +..B2.209: + fldt 80(%rsp) + fld %st(2) + movl %edi, 256(%rsp) + cmpl %ebx, %ebp + fsub %st(1), %st + jg ..B2.214 +..B2.210: + jne ..B2.215 +..B2.211: + movl 36(%rsp), %eax + cmpl %edx, %eax + ja ..B2.214 +..B2.212: + jne ..B2.215 +..B2.213: + movl 32(%rsp), %eax + cmpl 80(%rsp), %eax + jbe ..B2.215 +..B2.214: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 96(%rsp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B2.216 +..B2.215: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 96(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) +..B2.216: + fld %st(0) + fadd %st(2), %st + fstpt 224(%rsp) + fldt 224(%rsp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 240(%rsp) + fldt 240(%rsp) + jmp ..B2.223 +..B2.217: + movl 36(%rsp), %ecx +..B2.218: + testl %ecx, %ecx + jne ..B2.220 +..B2.233: + cmpl $0, 32(%rsp) +..B2.219: + je ..B2.190 +..B2.220: + lea -16517(%rdi,%rbx), %eax + lea -16383(%rsi,%rbp), %edx + cmpl %edx, %eax + jge ..B2.190 +..B2.222: + fldt 32(%rsp) + movl %esi, %edi + fldt 48(%rsp) + movaps 32(%rsp), %xmm0 + movaps 48(%rsp), %xmm1 + movaps 64(%rsp), %xmm2 + movaps %xmm0, 224(%rsp) + movaps %xmm1, 240(%rsp) + movaps %xmm2, 256(%rsp) +..B2.223: + addq $-32, %rsp + .cfi_def_cfa_offset 896 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_recacosl_k80.142: + call __libm_scalbl_k80@PLT +..___tag_value___libm_recacosl_k80.143: +..B2.231: + addq $32, %rsp + .cfi_def_cfa_offset 864 +..B2.224: + movq 800(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B2.228 +..B2.225: + addq $808, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 864 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.226: + lea halfs(%rip), %rax + incl %ecx + movl %ecx, 352(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + fstpt 320(%rsp) + fldt 320(%rsp) + fxch %st(1) + fmul %st(2), %st + fstpt 336(%rsp) + fldt 336(%rsp) + fxch %st(1) + fxch %st(2) + jmp ..B2.153 +..B2.227: + lea halfs(%rip), %rax + incl %ecx + movl %ecx, 160(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + fstpt 128(%rsp) + fldt 128(%rsp) + fxch %st(1) + fmul %st(2), %st + fstpt 144(%rsp) + fldt 144(%rsp) + fxch %st(1) + fxch %st(2) + jmp ..B2.161 +..B2.228: + fstp %st(0) + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __libm_recacosl_k80,@function + .size __libm_recacosl_k80,.-__libm_recacosl_k80 + .data +# -- End __libm_recacosl_k80 + .text +# -- Begin asinpoly + .text + .align 16,0x90 +asinpoly: +# parameter 1: %rdi +# parameter 2: %rsi +..B3.1: + .cfi_startproc +..___tag_value_asinpoly.166: +..L167: + + subq $184, %rsp + .cfi_def_cfa_offset 192 + lea ones(%rip), %rax + movl 32(%rsi), %r8d + movzwl 8(%rsi), %ecx + andl $32767, %ecx + fldt (%rax) + lea 16383(%r8), %edx + movzwl 8(%rax), %eax + andl $32767, %edx + andl $-32768, %eax + addl %ecx, %r8d + orl %edx, %eax + fstpt 112(%rsp) + cmpl $16343, %r8d + jl ..B3.38 +..B3.2: + fldt (%rsi) + lea 240+_ASIN_POLY(%rip), %rdx + fldt 16(%rsi) + lea 208+_ASIN_POLY(%rip), %rcx + movw %ax, 120(%rsp) + lea 272+_ASIN_POLY(%rip), %rax + fldt 112(%rsp) + lea 176+_ASIN_POLY(%rip), %rsi + fmul %st, %st(2) + lea 144+_ASIN_POLY(%rip), %r8 + fld %st(2) + lea 112+_ASIN_POLY(%rip), %r9 + fmul %st(3), %st + lea 80+_ASIN_POLY(%rip), %r10 + fld %st(0) + lea 256+_ASIN_POLY(%rip), %r11 + fmul %st(1), %st + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fxch %st(3) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + fldt (%rax) + lea 224+_ASIN_POLY(%rip), %rax + fmul %st(2), %st + fldt (%rdx) + lea 192+_ASIN_POLY(%rip), %rdx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + lea 160+_ASIN_POLY(%rip), %rcx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 128+_ASIN_POLY(%rip), %rsi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + lea 96+_ASIN_POLY(%rip), %r8 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + lea 64+_ASIN_POLY(%rip), %r9 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + lea t32(%rip), %r10 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + fmul %st(3), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdx) + lea 48+_ASIN_POLY(%rip), %rdx + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%r9) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + fld %st(1) + fldt (%r10) + fstpt 48(%rsp) + fldt 48(%rsp) + fmul %st(3), %st + movzwl 168(%rsp), %eax + fsubr %st, %st(1) + andl $32767, %eax + faddp %st, %st(1) + fld %st(0) + cmpl $16377, %eax + fsubr %st(3), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fld %st(1) + fmul %st(2), %st + fxch %st(5) + fmulp %st, %st(4) + fxch %st(3) + fadd %st(0), %st + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fmul %st(3), %st + fadd %st(0), %st + fld %st(0) + fadd %st(5), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(6) + fxch %st(2) + faddp %st, %st(6) + fxch %st(4) + fmul %st(0), %st + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt (%rdx) + fld %st(0) + fadd %st(2), %st + jg ..B3.7 +..B3.3: + jne ..B3.8 +..B3.4: + movl 164(%rsp), %eax + cmpl 4(%rdx), %eax + ja ..B3.7 +..B3.5: + jne ..B3.8 +..B3.6: + movl 160(%rsp), %eax + cmpl (%rdx), %eax + jbe ..B3.8 +..B3.7: + lea 336+_ASIN_POLY(%rip), %rdx + fsubr %st, %st(2) + lea zeros(%rip), %rax + fxch %st(1) + faddp %st, %st(2) + fldt (%rax) + fldt (%rdx) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + jmp ..B3.9 +..B3.8: + lea zeros(%rip), %rax + fsubr %st, %st(1) + lea 336+_ASIN_POLY(%rip), %rdx + fxch %st(2) + faddp %st, %st(1) + fldt (%rax) + faddp %st, %st(1) + fldt (%rdx) + faddp %st, %st(1) +..B3.9: + fldt 64(%rsp) + lea 32+_ASIN_POLY(%rip), %rdx + fld %st(0) + fld %st(2) + fadd %st(4), %st + fld %st(0) + fld %st(1) + fxch %st(2) + fsubr %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fxch %st(3) + fmul %st, %st(5) + fldt 48(%rsp) + fld %st(0) + fmul %st(6), %st + fsubr %st, %st(5) + faddp %st, %st(5) + fxch %st(2) + fsub %st(4), %st + fld %st(1) + fmulp %st, %st(3) + fxch %st(2) + fsubr %st, %st(3) + faddp %st, %st(3) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fsubr %st, %st(2) + fxch %st(2) + fstpt 128(%rsp) + fldt 128(%rsp) + fld %st(3) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(4) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fldt 96(%rsp) + fmulp %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fldt 128(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubr %st, %st(2) + movzwl 168(%rsp), %eax + fxch %st(1) + faddp %st, %st(2) + fldt (%rdx) + andl $32767, %eax + fld %st(0) + cmpl $16378, %eax + fadd %st(2), %st + jg ..B3.14 +..B3.10: + jne ..B3.15 +..B3.11: + movl 164(%rsp), %eax + cmpl 4(%rdx), %eax + ja ..B3.14 +..B3.12: + jne ..B3.15 +..B3.13: + movl 160(%rsp), %eax + cmpl (%rdx), %eax + jbe ..B3.15 +..B3.14: + lea 320+_ASIN_POLY(%rip), %rax + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + jmp ..B3.16 +..B3.15: + lea 320+_ASIN_POLY(%rip), %rax + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt (%rax) + faddp %st, %st(2) +..B3.16: + fldt 112(%rsp) + lea 16+_ASIN_POLY(%rip), %rdx + fld %st(0) + fld %st(3) + fadd %st(3), %st + fld %st(0) + fld %st(1) + fxch %st(2) + fsubr %st, %st(5) + fxch %st(6) + faddp %st, %st(5) + fldt 48(%rsp) + fmul %st(6), %st + fsubr %st, %st(1) + faddp %st, %st(1) + fmul %st, %st(2) + fsubr %st, %st(1) + fxch %st(1) + fmul %st, %st(3) + fldt 128(%rsp) + fmul %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt 96(%rsp) + fmulp %st, %st(5) + fldt 64(%rsp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubr %st, %st(1) + movzwl 168(%rsp), %eax + fxch %st(2) + faddp %st, %st(1) + fldt (%rdx) + andl $32767, %eax + fld %st(0) + cmpl $16379, %eax + fadd %st(3), %st + jg ..B3.21 +..B3.17: + jne ..B3.22 +..B3.18: + movl 164(%rsp), %eax + cmpl 4(%rdx), %eax + ja ..B3.21 +..B3.19: + jne ..B3.22 +..B3.20: + movl 160(%rsp), %eax + cmpl (%rdx), %eax + jbe ..B3.22 +..B3.21: + lea 304+_ASIN_POLY(%rip), %rax + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt (%rax) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + jmp ..B3.23 +..B3.22: + lea 304+_ASIN_POLY(%rip), %rax + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt (%rax) + faddp %st, %st(1) +..B3.23: + fldt 112(%rsp) + lea _ASIN_POLY(%rip), %rdx + fld %st(0) + fld %st(2) + fadd %st(4), %st + fld %st(0) + fld %st(1) + fxch %st(2) + fsubr %st, %st(6) + fxch %st(5) + faddp %st, %st(6) + fldt 48(%rsp) + fmul %st(5), %st + fsubr %st, %st(1) + faddp %st, %st(1) + fmul %st, %st(2) + fsubr %st, %st(1) + fxch %st(1) + fmul %st, %st(3) + fldt 128(%rsp) + fmul %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 96(%rsp) + fmulp %st, %st(3) + fldt 64(%rsp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubr %st, %st(2) + movzwl 168(%rsp), %eax + fxch %st(1) + faddp %st, %st(2) + fldt (%rdx) + andl $32767, %eax + fld %st(0) + cmpl $16380, %eax + fadd %st(2), %st + jg ..B3.28 +..B3.24: + jne ..B3.29 +..B3.25: + movl 164(%rsp), %eax + cmpl 4(%rdx), %eax + ja ..B3.28 +..B3.26: + jne ..B3.29 +..B3.27: + movl 160(%rsp), %eax + cmpl (%rdx), %eax + jbe ..B3.29 +..B3.28: + lea 288+_ASIN_POLY(%rip), %rax + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + jmp ..B3.30 +..B3.29: + lea 288+_ASIN_POLY(%rip), %rax + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt (%rax) + faddp %st, %st(2) +..B3.30: + fldt 48(%rsp) + fld %st(2) + movzwl 152(%rsp), %edx + fadd %st(2), %st + fmul %st, %st(1) + fld %st(0) + andl $32767, %edx + fsub %st(2), %st + faddp %st, %st(2) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(2) + fsub %st(1), %st + fldt 112(%rsp) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fmul %st(2), %st + fldt 128(%rsp) + fmul %st, %st(4) + fxch %st(1) + faddp %st, %st(4) + fld %st(3) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fmulp %st, %st(2) + faddp %st, %st(1) + fld %st(1) + fldt 96(%rsp) + fmulp %st, %st(5) + fldt 64(%rsp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(2) + fldt 48(%rsp) + fmul %st(4), %st + fsubr %st, %st(1) + faddp %st, %st(1) + fsubr %st, %st(1) + fldt (%rsp) + fld %st(0) + fmul %st(2), %st + fxch %st(1) + fmul %st(3), %st + fldt 32(%rsp) + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(0) + fldt 16(%rsp) + fmulp %st, %st(5) + fldt 80(%rsp) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fadd %st(3), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubr %st, %st(1) + movzwl 168(%rsp), %eax + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fadd %st(2), %st + andl $32767, %eax + cmpl %edx, %eax + jg ..B3.35 +..B3.31: + jne ..B3.36 +..B3.32: + movl 164(%rsp), %eax + movl 148(%rsp), %edx + cmpl %edx, %eax + ja ..B3.35 +..B3.33: + jne ..B3.36 +..B3.34: + movl 160(%rsp), %eax + cmpl 144(%rsp), %eax + jbe ..B3.36 +..B3.35: + fldt 80(%rsp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 16(%rsp) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + jmp ..B3.37 +..B3.36: + fldt 80(%rsp) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + faddp %st, %st(2) +..B3.37: + fld %st(1) + movl $0, 32(%rdi) + fadd %st(1), %st + fstpt (%rdi) + fldt (%rdi) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rdi) + addq $184, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 +..B3.38: + movq (%rsi), %rax + movq 8(%rsi), %rdx + movq 16(%rsi), %rcx + movq 24(%rsi), %r8 + movq 32(%rsi), %r9 + movq 40(%rsi), %rsi + movq %rax, (%rdi) + movq %rdx, 8(%rdi) + movq %rcx, 16(%rdi) + movq %r8, 24(%rdi) + movq %r9, 32(%rdi) + movq %rsi, 40(%rdi) +..B3.39: + addq $184, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type asinpoly,@function + .size asinpoly,.-asinpoly + .data +# -- End asinpoly + .text +# -- Begin __libm_recasinl_k80 + .text + .align 16,0x90 + .globl __libm_recasinl_k80 +__libm_recasinl_k80: +# parameter 1: %rdi +# parameter 2: %rsi +# parameter 3: %rdx +# parameter 4: %rcx +# parameter 5: %r8 +# parameter 6: %r9 +# parameter 7: 704 + %rsp +# parameter 8: 712 + %rsp +# parameter 9: 720 + %rsp +# parameter 10: 728 + %rsp +..B4.1: + .cfi_startproc +..___tag_value___libm_recasinl_k80.173: +..L174: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $648, %rsp + .cfi_def_cfa_offset 704 + movq %rdx, %r12 + movq %fs:40, %rax + movq %r9, %r14 + xorq %rsp, %rax + movq %r8, %rbp + movq %rax, 640(%rsp) + movq %rdi, %r15 + movzwl 8(%r12), %eax + andl $32767, %eax + movq 728(%rsp), %r13 + cmpl $8383, %eax + jl ..B4.5 +..B4.2: + cmpl $24383, %eax + jg ..B4.5 +..B4.3: + movzwl 8(%r13), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.5 +..B4.4: + cmpl $24383, %eax + jle ..B4.7 +..B4.5: + movq %r12, %rdi +..___tag_value___libm_recasinl_k80.188: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.189: +..B4.6: + movq %r13, %rdi +..___tag_value___libm_recasinl_k80.190: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.191: +..B4.7: + fldt (%r12) + lea t32(%rip), %rax + fld %st(0) + fldt (%r13) + fdivr %st, %st(1) + fld %st(0) + fld %st(1) + fldt (%rax) + fld %st(0) + fmul %st(5), %st + fld %st(0) + movl 32(%r12), %ebx + fsubr %st(6), %st + subl 32(%r13), %ebx + faddp %st, %st(1) + fld %st(0) + lea 1(%rbx), %edx + movl %edx, 624(%rsp) + fsubr %st(6), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(3) + fsub %st(4), %st + faddp %st, %st(4) + fld %st(4) + fsub %st(4), %st + fxch %st(3) + fstpt 48(%rsp) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fxch %st(1) + fsubrp %st, %st(4) + fsubrp %st, %st(3) + fldt 16(%r12) + faddp %st, %st(3) + fldt 16(%r13) + fmul %st(2), %st + fsubrp %st, %st(3) + fdivrp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 592(%rsp) + fldt 592(%rsp) + fsubrp %st, %st(1) + movzwl 600(%rsp), %ecx + fadd %st(1), %st + andl $32767, %ecx + fstpt 608(%rsp) + fstpt 16(%rsp) + lea 1(%rcx,%rbx), %esi + cmpl $16382, %esi + jl ..B4.183 +..B4.8: + movzwl 8(%r15), %eax + andl $32767, %eax + movq 720(%rsp), %rbx + cmpl $16383, %eax + jl ..B4.37 +..B4.9: + movq 704(%rsp), %r9 + movq (%r9), %rax + movq 8(%r9), %rdx + movq 16(%r9), %rcx + movq 24(%r9), %rsi + movq 32(%r9), %r8 + movq 40(%r9), %r10 + movzwl 8(%rbx), %r9d + movq %rax, 64(%rsp) + movl %r9d, %eax + andl $32767, %eax + movq %rdx, 72(%rsp) + cmpl $8383, %eax + movq %rcx, 80(%rsp) + movq %rsi, 88(%rsp) + movq %r8, 96(%rsp) + movq %r10, 104(%rsp) + jl ..B4.13 +..B4.10: + cmpl $24383, %eax + jg ..B4.13 +..B4.11: + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %r11d + cmpl $8383, %r11d + jl ..B4.13 +..B4.12: + cmpl $24383, %r11d + jle ..B4.16 +..B4.13: + movq %rbx, %rdi +..___tag_value___libm_recasinl_k80.192: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.193: +..B4.14: + movq %rbp, %rdi +..___tag_value___libm_recasinl_k80.194: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.195: +..B4.15: + movzwl 8(%rbx), %r9d + movl %r9d, %eax + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %eax + andl $32767, %r11d +..B4.16: + movl 32(%rbp), %edx + movl 32(%rbx), %ecx + lea -134(%rdx,%r11), %esi + lea (%rax,%rcx), %r8d + cmpl %r8d, %esi + jge ..B4.33 +..B4.17: + lea 134(%rdx,%r11), %esi + cmpl %esi, %r8d + jge ..B4.33 +..B4.18: + cmpl $0, 4(%rbx) + jne ..B4.20 +..B4.19: + cmpl $0, (%rbx) + je ..B4.33 +..B4.20: + cmpl $0, 4(%rbp) + jne ..B4.22 +..B4.21: + cmpl $0, (%rbp) + je ..B4.33 +..B4.22: + cmpl %edx, %ecx + je ..B4.24 +..B4.23: + fldt 16(%rsp) + subl %edx, %ecx + fstpt (%rsp) + addl $16383, %ecx + fldt (%rbx) + andl $32767, %ecx + fldt 16(%rbx) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 32(%rbx) + fxch %st(2) + fstpt (%rbx) + fldt (%rbx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbx) + fldt 16(%rbx) + fxch %st(1) + fstpt 16(%rsp) + movl 32(%rbp), %edx + movzwl 8(%rbp), %r10d + movzwl 8(%rbx), %r9d + jmp ..B4.25 +..B4.24: + fldt (%rbx) + fstpt 16(%rsp) + fldt 16(%rbx) +..B4.25: + fldt (%rbp) + andl $32767, %r9d + fldt 16(%rsp) + andl $32767, %r10d + movl %edx, 144(%rsp) + cmpl %r10d, %r9d + fadd %st(1), %st + jg ..B4.30 +..B4.26: + jne ..B4.31 +..B4.27: + movl 4(%rbx), %eax + cmpl 4(%rbp), %eax + ja ..B4.30 +..B4.28: + jne ..B4.31 +..B4.29: + movl (%rbx), %eax + cmpl (%rbp), %eax + jbe ..B4.31 +..B4.30: + fldt 16(%rsp) + fsub %st(1), %st + faddp %st, %st(2) + fldt 16(%rbp) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B4.32 +..B4.31: + fldt 16(%rsp) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 16(%rbp) + faddp %st, %st(1) + fstpt 16(%rsp) +..B4.32: + fldt 16(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 128(%rsp) + jmp ..B4.65 +..B4.33: + cmpq $0, (%rbx) + je ..B4.35 +..B4.34: + lea -16517(%rdx,%r11), %edx + lea -16383(%rcx,%rax), %eax + cmpl %eax, %edx + jl ..B4.36 +..B4.35: + movq (%rbp), %rax + movq 8(%rbp), %rdx + movq 16(%rbp), %rcx + movq 24(%rbp), %rbx + movq 32(%rbp), %rsi + movq 40(%rbp), %rbp + movq %rax, 112(%rsp) + movq %rdx, 120(%rsp) + movq %rcx, 128(%rsp) + movq %rbx, 136(%rsp) + movq %rsi, 144(%rsp) + movq %rbp, 152(%rsp) + jmp ..B4.65 +..B4.36: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rbp + movq 32(%rbx), %rsi + movq 40(%rbx), %rbx + movq %rax, 112(%rsp) + movq %rdx, 120(%rsp) + movq %rcx, 128(%rsp) + movq %rbp, 136(%rsp) + movq %rsi, 144(%rsp) + movq %rbx, 152(%rsp) + jmp ..B4.65 +..B4.37: + lea ones(%rip), %rax + lea zeros(%rip), %rdx + movzwl 8(%rbx), %r9d + movl $0, 144(%rsp) + fldt (%rax) + movl %r9d, %eax + andl $32767, %eax + fstpt 112(%rsp) + cmpl $8383, %eax + fldt (%rdx) + fstpt 128(%rsp) + jl ..B4.41 +..B4.38: + cmpl $24383, %eax + jg ..B4.41 +..B4.39: + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %r11d + cmpl $8383, %r11d + jl ..B4.41 +..B4.40: + cmpl $24383, %r11d + jle ..B4.44 +..B4.41: + movq %rbx, %rdi +..___tag_value___libm_recasinl_k80.196: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.197: +..B4.42: + movq %rbp, %rdi +..___tag_value___libm_recasinl_k80.198: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.199: +..B4.43: + movzwl 8(%rbx), %r9d + movl %r9d, %eax + movzwl 8(%rbp), %r10d + movl %r10d, %r11d + andl $32767, %eax + andl $32767, %r11d +..B4.44: + movl 32(%rbp), %edx + movl 32(%rbx), %ecx + lea -134(%rdx,%r11), %esi + lea (%rax,%rcx), %r8d + cmpl %r8d, %esi + jge ..B4.61 +..B4.45: + lea 134(%rdx,%r11), %esi + cmpl %esi, %r8d + jge ..B4.61 +..B4.46: + cmpl $0, 4(%rbx) + jne ..B4.48 +..B4.47: + cmpl $0, (%rbx) + je ..B4.61 +..B4.48: + cmpl $0, 4(%rbp) + jne ..B4.50 +..B4.49: + cmpl $0, (%rbp) + je ..B4.61 +..B4.50: + cmpl %edx, %ecx + je ..B4.52 +..B4.51: + fldt 16(%rsp) + subl %edx, %ecx + fstpt (%rsp) + addl $16383, %ecx + fldt (%rbx) + andl $32767, %ecx + fldt 16(%rbx) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %edx, 32(%rbx) + fxch %st(2) + fstpt (%rbx) + fldt (%rbx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbx) + fldt 16(%rbx) + fstpt 16(%rsp) + movl 32(%rbp), %edx + movzwl 8(%rbp), %r10d + movzwl 8(%rbx), %r9d + jmp ..B4.53 +..B4.52: + fldt (%rbx) + fldt 16(%rbx) + fstpt 16(%rsp) +..B4.53: + fldt (%rbp) + andl $32767, %r9d + andl $32767, %r10d + fld %st(1) + movl %edx, 96(%rsp) + cmpl %r10d, %r9d + fsub %st(1), %st + jg ..B4.58 +..B4.54: + jne ..B4.59 +..B4.55: + movl 4(%rbx), %eax + cmpl 4(%rbp), %eax + ja ..B4.58 +..B4.56: + jne ..B4.59 +..B4.57: + movl (%rbx), %eax + cmpl (%rbp), %eax + jbe ..B4.59 +..B4.58: + fldt 16(%rsp) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fldt 16(%rbp) + fsubrp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + jmp ..B4.60 +..B4.59: + fldt 16(%rbp) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fsubrp %st, %st(3) + fldt 16(%rsp) + faddp %st, %st(3) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) +..B4.60: + fldt 16(%rsp) + fld %st(0) + fadd %st(2), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 80(%rsp) + jmp ..B4.65 +..B4.61: + cmpq $0, (%rbx) + je ..B4.63 +..B4.62: + lea -16517(%rdx,%r11), %esi + lea -16383(%rcx,%rax), %eax + cmpl %eax, %esi + jl ..B4.64 +..B4.63: + fldt (%rbp) + fchs + movl %edx, 96(%rsp) + fstpt 64(%rsp) + fldt 16(%rbp) + fchs + fstpt 80(%rsp) + jmp ..B4.65 +..B4.64: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rbp + movq 32(%rbx), %rsi + movq 40(%rbx), %rbx + movq %rax, 64(%rsp) + movq %rdx, 72(%rsp) + movq %rcx, 80(%rsp) + movq %rbp, 88(%rsp) + movq %rsi, 96(%rsp) + movq %rbx, 104(%rsp) +..B4.65: + movzwl 8(%r12), %ebp + movl %ebp, %r9d + andl $32767, %r9d + movl 32(%r12), %edx + incl %edx + movl %edx, 32(%r12) + cmpl $8383, %r9d + jl ..B4.69 +..B4.66: + cmpl $24383, %r9d + jg ..B4.69 +..B4.67: + movzwl 8(%r13), %eax + movl %eax, %r8d + andl $32767, %r8d + cmpl $8383, %r8d + jl ..B4.69 +..B4.68: + cmpl $24383, %r8d + jle ..B4.72 +..B4.69: + movq %r12, %rdi +..___tag_value___libm_recasinl_k80.200: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.201: +..B4.70: + movq %r13, %rdi +..___tag_value___libm_recasinl_k80.202: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.203: +..B4.71: + movzwl 8(%r12), %ebp + movl %ebp, %r9d + movzwl 8(%r13), %eax + movl %eax, %r8d + movl 32(%r12), %edx + andl $32767, %r9d + andl $32767, %r8d +..B4.72: + movl 32(%r13), %esi + lea (%rdx,%r9), %ebx + lea -134(%rsi,%r8), %ecx + cmpl %ecx, %ebx + jle ..B4.89 +..B4.73: + lea 134(%rsi,%r8), %ecx + cmpl %ecx, %ebx + jge ..B4.89 +..B4.74: + cmpl $0, 4(%r12) + jne ..B4.76 +..B4.75: + cmpl $0, (%r12) + je ..B4.89 +..B4.76: + cmpl $0, 4(%r13) + jne ..B4.78 +..B4.77: + cmpl $0, (%r13) + je ..B4.89 +..B4.78: + cmpl %esi, %edx + je ..B4.80 +..B4.79: + fldt 16(%rsp) + subl %esi, %edx + fstpt (%rsp) + addl $16383, %edx + fldt (%r12) + andl $32767, %edx + fldt 16(%r12) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %edx, %eax + movl %esi, %edx + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %esi, 32(%r12) + fxch %st(2) + fstpt (%r12) + fldt (%r12) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%r12) + fldt 16(%r12) + movl 32(%r13), %esi + movzwl 8(%r13), %eax + movzwl 8(%r12), %ebp + jmp ..B4.81 +..B4.80: + fldt (%r12) + fldt 16(%r12) +..B4.81: + fldt (%r13) + movl %eax, %ecx + andl $32767, %ebp + andl $32767, %ecx + fld %st(2) + cmpl %ecx, %ebp + movl %esi, 192(%rsp) + fadd %st(1), %st + jg ..B4.86 +..B4.82: + jne ..B4.87 +..B4.83: + movl 4(%r12), %ecx + cmpl 4(%r13), %ecx + ja ..B4.86 +..B4.84: + jne ..B4.87 +..B4.85: + movl (%r12), %ecx + cmpl (%r13), %ecx + jbe ..B4.87 +..B4.86: + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt 16(%r13) + faddp %st, %st(1) + faddp %st, %st(1) + fxch %st(1) + jmp ..B4.88 +..B4.87: + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 16(%r13) + faddp %st, %st(2) +..B4.88: + fld %st(1) + fadd %st(1), %st + fstpt 160(%rsp) + fldt 160(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 176(%rsp) + jmp ..B4.93 +..B4.89: + cmpq $0, (%r12) + je ..B4.91 +..B4.90: + lea -16517(%rsi,%r8), %ecx + lea -16383(%rdx,%r9), %ebx + cmpl %ebx, %ecx + jl ..B4.92 +..B4.91: + movq (%r13), %rcx + movq 8(%r13), %rbx + movq 16(%r13), %rbp + movq 24(%r13), %rsi + movq 32(%r13), %r8 + movq 40(%r13), %r9 + movq %rcx, 160(%rsp) + movq %rbx, 168(%rsp) + movq %rbp, 176(%rsp) + movq %rsi, 184(%rsp) + movq %r8, 192(%rsp) + movq %r9, 200(%rsp) + jmp ..B4.93 +..B4.92: + movq (%r12), %rcx + movq 8(%r12), %rbx + movq 16(%r12), %rbp + movq 24(%r12), %rsi + movq 32(%r12), %r8 + movq 40(%r12), %r9 + movq %rcx, 160(%rsp) + movq %rbx, 168(%rsp) + movq %rbp, 176(%rsp) + movq %rsi, 184(%rsp) + movq %r8, 192(%rsp) + movq %r9, 200(%rsp) +..B4.93: + decl %edx + movl %edx, 32(%r12) + movzwl 168(%rsp), %edx + andl $32767, %edx + cmpl $8383, %edx + jl ..B4.97 +..B4.94: + cmpl $24383, %edx + jg ..B4.97 +..B4.95: + movzwl 72(%rsp), %edx + andl $32767, %edx + cmpl $8383, %edx + jl ..B4.97 +..B4.96: + cmpl $24383, %edx + jle ..B4.99 +..B4.97: + lea 160(%rsp), %rdi +..___tag_value___libm_recasinl_k80.204: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.205: +..B4.98: + lea 64(%rsp), %rdi +..___tag_value___libm_recasinl_k80.206: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.207: + movzwl 8(%r13), %eax +..B4.99: + fldt 160(%rsp) + andl $32767, %eax + fld %st(0) + fld %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(4), %st + movl 192(%rsp), %edx + fsubr %st, %st(3) + addl 96(%rsp), %edx + faddp %st, %st(3) + fld %st(2) + cmpl $8383, %eax + movl %edx, 240(%rsp) + fxch %st(2) + fsub %st(3), %st + fldt 64(%rsp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 80(%rsp) + fmulp %st, %st(4) + fldt 176(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 208(%rsp) + fldt 208(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 224(%rsp) + jl ..B4.103 +..B4.100: + cmpl $24383, %eax + jg ..B4.103 +..B4.101: + movzwl 120(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.103 +..B4.102: + cmpl $24383, %eax + jle ..B4.105 +..B4.103: + movq %r13, %rdi +..___tag_value___libm_recasinl_k80.208: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.209: +..B4.104: + lea 112(%rsp), %rdi +..___tag_value___libm_recasinl_k80.210: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.211: +..B4.105: + fldt (%r13) + fld %st(0) + fld %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(4), %st + movq 712(%rsp), %rbx + fsubr %st, %st(3) + movzwl 8(%rbx), %ecx + movl %ecx, %r10d + movl 144(%rsp), %eax + andl $32767, %r10d + addl 32(%r13), %eax + faddp %st, %st(3) + fld %st(2) + cmpl $8383, %r10d + movl %eax, 288(%rsp) + fxch %st(2) + fsub %st(3), %st + fldt 112(%rsp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 128(%rsp) + fmulp %st, %st(4) + fldt 16(%r13) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 256(%rsp) + fldt 256(%rsp) + fsubrp %st, %st(1) + fadd %st(1), %st + fstpt 272(%rsp) + fstpt 16(%rsp) + jl ..B4.109 +..B4.106: + cmpl $24383, %r10d + jg ..B4.109 +..B4.107: + movzwl 8(%r14), %ebp + movl %ebp, %r8d + andl $32767, %r8d + cmpl $8383, %r8d + jl ..B4.109 +..B4.108: + cmpl $24383, %r8d + jle ..B4.112 +..B4.109: + movq %rbx, %rdi +..___tag_value___libm_recasinl_k80.212: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.213: +..B4.110: + movq %r14, %rdi +..___tag_value___libm_recasinl_k80.214: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.215: +..B4.111: + movzwl 8(%rbx), %ecx + movl %ecx, %r10d + movzwl 8(%r14), %ebp + movl %ebp, %r8d + andl $32767, %r10d + andl $32767, %r8d +..B4.112: + movl 32(%r14), %esi + movl 32(%rbx), %r9d + lea -134(%rsi,%r8), %eax + lea (%r10,%r9), %edx + cmpl %eax, %edx + jle ..B4.129 +..B4.113: + lea 134(%rsi,%r8), %eax + cmpl %eax, %edx + jge ..B4.129 +..B4.114: + cmpl $0, 4(%rbx) + jne ..B4.116 +..B4.115: + cmpl $0, (%rbx) + je ..B4.129 +..B4.116: + cmpl $0, 4(%r14) + jne ..B4.118 +..B4.117: + cmpl $0, (%r14) + je ..B4.129 +..B4.118: + cmpl %esi, %r9d + je ..B4.120 +..B4.119: + fldt 16(%rsp) + subl %esi, %r9d + fstpt (%rsp) + addl $16383, %r9d + fldt (%rbx) + andl $32767, %r9d + fldt 16(%rbx) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %r9d, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + movl %esi, 32(%rbx) + fxch %st(2) + fstpt (%rbx) + fldt (%rbx) + fxch %st(2) + fmulp %st, %st(1) + fstpt 16(%rbx) + fldt 16(%rbx) + movl 32(%r14), %esi + movzwl 8(%r14), %ebp + movzwl 8(%rbx), %ecx + jmp ..B4.121 +..B4.120: + fldt (%rbx) + fldt 16(%rbx) +..B4.121: + fldt (%r14) + andl $32767, %ecx + andl $32767, %ebp + fld %st(2) + movl %esi, 336(%rsp) + cmpl %ebp, %ecx + fadd %st(1), %st + jg ..B4.126 +..B4.122: + jne ..B4.127 +..B4.123: + movl 4(%rbx), %eax + cmpl 4(%r14), %eax + ja ..B4.126 +..B4.124: + jne ..B4.127 +..B4.125: + movl (%rbx), %eax + cmpl (%r14), %eax + jbe ..B4.127 +..B4.126: + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fldt 16(%r14) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B4.128 +..B4.127: + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 16(%r14) + faddp %st, %st(1) +..B4.128: + fld %st(0) + fadd %st(2), %st + fstpt 304(%rsp) + fldt 304(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpt 320(%rsp) + jmp ..B4.133 +..B4.129: + cmpq $0, (%rbx) + je ..B4.131 +..B4.130: + lea -16517(%rsi,%r8), %eax + lea -16383(%r9,%r10), %edx + cmpl %edx, %eax + jl ..B4.132 +..B4.131: + movq (%r14), %rax + movq 8(%r14), %rdx + movq 16(%r14), %rcx + movq 24(%r14), %rbx + movq 32(%r14), %rbp + movq 40(%r14), %rsi + movq %rax, 304(%rsp) + movq %rdx, 312(%rsp) + movq %rcx, 320(%rsp) + movq %rbx, 328(%rsp) + movq %rbp, 336(%rsp) + movq %rsi, 344(%rsp) + jmp ..B4.133 +..B4.132: + movq (%rbx), %rax + movq 8(%rbx), %rdx + movq 16(%rbx), %rcx + movq 24(%rbx), %rbp + movq 32(%rbx), %rsi + movq 40(%rbx), %rbx + movq %rax, 304(%rsp) + movq %rdx, 312(%rsp) + movq %rcx, 320(%rsp) + movq %rbp, 328(%rsp) + movq %rsi, 336(%rsp) + movq %rbx, 344(%rsp) +..B4.133: + movzwl 264(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.137 +..B4.134: + cmpl $24383, %eax + jg ..B4.137 +..B4.135: + movzwl 312(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.137 +..B4.136: + cmpl $24383, %eax + jle ..B4.139 +..B4.137: + lea 256(%rsp), %rdi +..___tag_value___libm_recasinl_k80.216: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.217: +..B4.138: + lea 304(%rsp), %rdi +..___tag_value___libm_recasinl_k80.218: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.219: +..B4.139: + fldt 256(%rsp) + fld %st(0) + fld %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(4), %st + movl 288(%rsp), %edx + fsubr %st, %st(3) + movzwl 216(%rsp), %eax + faddp %st, %st(3) + fld %st(2) + andl $32767, %eax + addl 336(%rsp), %edx + fxch %st(2) + fsub %st(3), %st + fldt 304(%rsp) + cmpl $8383, %eax + fmul %st, %st(2) + fld %st(0) + movl %edx, 384(%rsp) + fsub %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st, %st(3) + fld %st(2) + fsub %st(1), %st + fmul %st, %st(5) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(5) + fld %st(4) + fadd %st(4), %st + fsub %st, %st(4) + fxch %st(4) + fchs + faddp %st, %st(5) + fmulp %st, %st(1) + faddp %st, %st(3) + fldt 320(%rsp) + fmulp %st, %st(4) + fldt 272(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 352(%rsp) + fldt 352(%rsp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 368(%rsp) + fldt 368(%rsp) + jl ..B4.143 +..B4.140: + cmpl $24383, %eax + jg ..B4.143 +..B4.141: + movzwl 360(%rsp), %eax + andl $32767, %eax + cmpl $8383, %eax + jl ..B4.143 +..B4.142: + cmpl $24383, %eax + jle ..B4.146 +..B4.143: + fstp %st(1) + fstp %st(0) + lea 208(%rsp), %rdi +..___tag_value___libm_recasinl_k80.220: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.221: +..B4.144: + lea 352(%rsp), %rdi +..___tag_value___libm_recasinl_k80.222: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.223: +..B4.145: + fldt 352(%rsp) + fldt 368(%rsp) + movl 384(%rsp), %edx +..B4.146: + fldt 208(%rsp) + fld %st(2) + fdivr %st(1), %st + fmul %st, %st(2) + fld %st(3) + fxch %st(4) + fstpt 32(%rsp) + fldt 32(%rsp) + fldt 48(%rsp) + fld %st(0) + fmul %st(3), %st + fld %st(0) + movl 240(%rsp), %ecx + fsubr %st(4), %st + subl %edx, %ecx + faddp %st, %st(1) + fld %st(0) + decl %ecx + movl %ecx, 432(%rsp) + fsubr %st(4), %st + fxch %st(2) + fmul %st(3), %st + fsubr %st, %st(7) + faddp %st, %st(7) + fxch %st(2) + fsub %st(6), %st + fld %st(2) + fmul %st(7), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(1) + fmul %st, %st(3) + fxch %st(7) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(1) + fxch %st(4) + fsubrp %st, %st(2) + fxch %st(3) + fsubrp %st, %st(1) + fldt 224(%rsp) + faddp %st, %st(1) + fsubp %st, %st(1) + fldt 32(%rsp) + fdivrp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 400(%rsp) + fldt 400(%rsp) + fsubr %st, %st(2) + movzwl 408(%rsp), %eax + fxch %st(1) + fadd %st, %st(2) + andl $32767, %eax + fxch %st(2) + fstpt 416(%rsp) + fldt 416(%rsp) + cmpl $383, %eax + fxch %st(2) + fstpt 16(%rsp) + fxch %st(1) + jl ..B4.148 +..B4.147: + cmpl $32383, %eax + jle ..B4.150 +..B4.148: + fstp %st(0) + fstp %st(0) + lea 400(%rsp), %rdi +..___tag_value___libm_recasinl_k80.224: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.225: +..B4.149: + fldt 400(%rsp) + fldt 416(%rsp) + movl 432(%rsp), %ecx +..B4.150: + testb $1, %cl + jne ..B4.188 +..B4.151: + lea halfs(%rip), %rax + fldt (%rax) +..B4.152: + fldt 48(%rsp) + fld %st(3) + fsqrt + lea 448(%rsp), %rdi + fmul %st, %st(1) + lea 496(%rsp), %rsi + fld %st(1) + sarl $1, %ecx + fsubr %st(1), %st + movl %ecx, 32(%rsi) + faddp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + fadd %st(0), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + fmul %st(0), %st + faddp %st, %st(1) + fxch %st(2) + fsubrp %st, %st(5) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + fdivr %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt (%rsi) + fldt (%rsi) + fsubrp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rsi) +..___tag_value___libm_recasinl_k80.226: + call asinpoly +..___tag_value___libm_recasinl_k80.227: +..B4.153: + lea 16+_PIO2_K80(%rip), %rax + lea 32+_PIO2_K80(%rip), %rdx + movl 480(%rsp), %edi + xorl %ebp, %ebp + incl %edi + movl %edi, 480(%rsp) + fldt (%rax) + movzwl 8(%rax), %esi + andl $32767, %esi + movl $0, 576(%rsp) + cmpl $8383, %esi + fstpt 544(%rsp) + fldt (%rdx) + fstpt 560(%rsp) + jl ..B4.157 +..B4.154: + cmpl $24383, %esi + jg ..B4.157 +..B4.155: + movzwl 456(%rsp), %ebx + andl $32767, %ebx + cmpl $8383, %ebx + jl ..B4.157 +..B4.156: + cmpl $24383, %ebx + jle ..B4.160 +..B4.157: + lea 544(%rsp), %rdi +..___tag_value___libm_recasinl_k80.228: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.229: +..B4.158: + lea 448(%rsp), %rdi +..___tag_value___libm_recasinl_k80.230: + call __libm_normalizel_k80@PLT +..___tag_value___libm_recasinl_k80.231: +..B4.159: + movzwl 552(%rsp), %esi + movzwl 456(%rsp), %ebx + andl $32767, %esi + movl 480(%rsp), %edi + andl $32767, %ebx + movl 576(%rsp), %ebp +..B4.160: + lea (%rbp,%rsi), %edx + lea -134(%rdi,%rbx), %eax + cmpl %eax, %edx + jle ..B4.177 +..B4.161: + movl 548(%rsp), %ecx + lea 134(%rdi,%rbx), %eax + cmpl %eax, %edx + jge ..B4.178 +..B4.162: + testl %ecx, %ecx + jne ..B4.164 +..B4.163: + cmpl $0, 544(%rsp) + je ..B4.179 +..B4.164: + movl 452(%rsp), %edx + testl %edx, %edx + jne ..B4.166 +..B4.165: + cmpl $0, 448(%rsp) + je ..B4.178 +..B4.166: + cmpl %edi, %ebp + je ..B4.168 +..B4.167: + fldt 16(%rsp) + subl %edi, %ebp + fstpt (%rsp) + addl $16383, %ebp + fldt 544(%rsp) + andl $32767, %ebp + fldt 560(%rsp) + andb $127, 9(%rsp) + movzwl 8(%rsp), %eax + andl $-32768, %eax + orl %ebp, %eax + movw %ax, 8(%rsp) + movl $-2147483648, 4(%rsp) + movl $0, (%rsp) + fldt (%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt 544(%rsp) + fldt 544(%rsp) + fxch %st(2) + fmulp %st, %st(1) + movzwl 552(%rsp), %esi + movl %edi, 576(%rsp) + andl $32767, %esi + fstpt 560(%rsp) + fldt 560(%rsp) + jmp ..B4.169 +..B4.168: + fldt 544(%rsp) + fldt 560(%rsp) +..B4.169: + fldt 448(%rsp) + fld %st(2) + movl %edi, 48(%rsp) + cmpl %ebx, %esi + fsub %st(1), %st + jg ..B4.174 +..B4.170: + jne ..B4.175 +..B4.171: + movl 548(%rsp), %eax + cmpl %edx, %eax + ja ..B4.174 +..B4.172: + jne ..B4.175 +..B4.173: + movl 544(%rsp), %eax + cmpl 448(%rsp), %eax + jbe ..B4.175 +..B4.174: + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fldt 464(%rsp) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + jmp ..B4.176 +..B4.175: + fadd %st, %st(1) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fldt 464(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) +..B4.176: + fld %st(0) + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + jmp ..B4.185 +..B4.177: + movl 548(%rsp), %ecx +..B4.178: + testl %ecx, %ecx + jne ..B4.180 +..B4.193: + cmpl $0, 544(%rsp) +..B4.179: + je ..B4.181 +..B4.180: + lea -16517(%rdi,%rbx), %eax + lea -16383(%rbp,%rsi), %edx + cmpl %edx, %eax + jl ..B4.182 +..B4.181: + fldt 448(%rsp) + fchs + movl %edi, 48(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fldt 464(%rsp) + fchs + fstpt 32(%rsp) + fldt 32(%rsp) + jmp ..B4.185 +..B4.182: + fldt 544(%rsp) + fldt 560(%rsp) + movaps 544(%rsp), %xmm0 + movaps 560(%rsp), %xmm1 + movaps 576(%rsp), %xmm2 + movl 576(%rsp), %edi + movaps %xmm0, 16(%rsp) + movaps %xmm1, 32(%rsp) + movaps %xmm2, 48(%rsp) + jmp ..B4.185 +..B4.183: + lea 16(%rsp), %rdi + lea 592(%rsp), %rsi +..___tag_value___libm_recasinl_k80.232: + call asinpoly +..___tag_value___libm_recasinl_k80.233: +..B4.184: + fldt 16(%rsp) + fldt 32(%rsp) + movl 48(%rsp), %edi +..B4.185: + addq $-32, %rsp + .cfi_def_cfa_offset 736 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_recasinl_k80.235: + call __libm_scalbl_k80@PLT +..___tag_value___libm_recasinl_k80.236: +..B4.192: + addq $32, %rsp + .cfi_def_cfa_offset 704 +..B4.186: + movb 9(%r15), %al + lea ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + shlq $4, %rcx + movq 640(%rsp), %rbx + xorq %rsp, %rbx + cmpq %fs:40, %rbx + fldt (%rdx,%rcx) + fmulp %st, %st(1) + jne ..B4.189 +..B4.187: + addq $648, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 704 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B4.188: + lea halfs(%rip), %rax + incl %ecx + movl %ecx, 432(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + fstpt 400(%rsp) + fldt 400(%rsp) + fxch %st(1) + fmul %st(2), %st + fstpt 416(%rsp) + fldt 416(%rsp) + fxch %st(1) + fxch %st(2) + jmp ..B4.152 +..B4.189: + fstp %st(0) + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __libm_recasinl_k80,@function + .size __libm_recasinl_k80,.-__libm_recasinl_k80 + .data +# -- End __libm_recasinl_k80 + .section .rodata, "a" + .align 16 + .align 16 +ones: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type ones,@object + .size ones,32 + .align 16 +zeros: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type zeros,@object + .size zeros,32 + .align 16 +t32: + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x1f,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type t32,@object + .size t32,32 + .align 16 +halfs: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type halfs,@object + .size halfs,32 + .align 2 +_PIO2_K80: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 36027 + .word 64655 + .word 30161 + .word 60646 + .word 49085 + .word 0 + .word 0 + .word 0 + .type _PIO2_K80,@object + .size _PIO2_K80,48 + .align 2 +_ASIN_POLY: + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39322 + .word 39321 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28087 + .word 46811 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36409 + .word 63715 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 62186 + .word 9163 + .word 53620 + .word 46917 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 11943 + .word 18321 + .word 25215 + .word 36391 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 12527 + .word 63486 + .word 51909 + .word 58572 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 16437 + .word 53165 + .word 60799 + .word 48451 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 39560 + .word 816 + .word 43435 + .word 40940 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 47763 + .word 38463 + .word 31161 + .word 35220 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 61035 + .word 37666 + .word 58653 + .word 60832 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 4110 + .word 2419 + .word 35453 + .word 57515 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 3126 + .word 47859 + .word 6163 + .word 61068 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 56145 + .word 58008 + .word 18829 + .word 55579 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 17944 + .word 24712 + .word 25688 + .word 38195 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 27414 + .word 34244 + .word 64801 + .word 51841 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 63442 + .word 25896 + .word 35822 + .word 55851 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 37640 + .word 1996 + .word 32075 + .word 42748 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 39460 + .word 64770 + .word 43690 + .word 43690 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 48327 + .word 21484 + .word 52058 + .word 52428 + .word 49114 + .word 0 + .word 0 + .word 0 + .word 52692 + .word 45548 + .word 47571 + .word 37453 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 9214 + .word 45875 + .word 56244 + .word 56360 + .word 49110 + .word 0 + .word 0 + .word 0 + .type _ASIN_POLY,@object + .size _ASIN_POLY,352 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_reduce_pi04d.S b/external/sgx_libm/intel64/libm_reduce_pi04d.S new file mode 100644 index 0000000000..a30dabaca8 --- /dev/null +++ b/external/sgx_libm/intel64/libm_reduce_pi04d.S @@ -0,0 +1,313 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_reduce_pi04d.c" + .text +..TXTST0: +# -- Begin __libm_reduce_pi04d + .text + .align 16,0x90 + .globl __libm_reduce_pi04d +__libm_reduce_pi04d: +# parameter 1: %xmm0 +# parameter 2: %rdi +# parameter 3: %esi +..B1.1: + .cfi_startproc +..___tag_value___libm_reduce_pi04d.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movl %esi, %r8d + movsd %xmm0, (%rsp) + xorb %sil, %sil +..B1.2: + fnstcw 10(%rsp) +..B1.3: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.5: + fldcw 8(%rsp) +..B1.6: + movb $1, %sil +..B1.7: + movzwl 6(%rsp), %r10d + movl %r10d, %ecx + andl $32752, %ecx + movl $1374389535, %eax + shrl $4, %ecx + andl $-32753, %r10d + lea -1052(%rcx), %r11d + imull %r11d + sarl $31, %r11d + lea -200(%rcx), %r9d + sarl $3, %edx + andl $2047, %r9d + subl %r11d, %edx + imull $-25, %edx, %eax + shll $4, %r9d + lea -1052(%rax,%rcx), %ecx + orl %r9d, %r10d + movw %r10w, 6(%rsp) + movsd (%rsp), %xmm2 + andl $-134217728, (%rsp) + movsd (%rsp), %xmm1 + cmpl $17, %ecx + subsd %xmm1, %xmm2 + jl ..B1.9 +..B1.8: + movslq %edx, %rdx + lea _DP(%rip), %r9 + movsd (%r9,%rdx,8), %xmm7 + movsd 8(%r9,%rdx,8), %xmm0 + incl %edx + mulsd %xmm2, %xmm7 + mulsd %xmm1, %xmm0 + addsd %xmm0, %xmm7 + movsd %xmm7, (%rsp) + andl $-1048576, (%rsp) + subsd (%rsp), %xmm7 + jmp ..B1.10 +..B1.9: + lea _DP(%rip), %r9 + pxor %xmm7, %xmm7 +..B1.10: + movslq %edx, %rdx + movaps %xmm1, %xmm3 + movaps %xmm1, %xmm5 + lea zero_none(%rip), %r11 + movaps %xmm1, %xmm9 + movaps %xmm1, %xmm11 + movaps %xmm1, %xmm13 + movsd (%r9,%rdx,8), %xmm4 + movsd 8(%r9,%rdx,8), %xmm0 + mulsd %xmm2, %xmm4 + mulsd %xmm0, %xmm3 + mulsd %xmm2, %xmm0 + addsd %xmm3, %xmm4 + movsd 16(%r9,%rdx,8), %xmm8 + addsd %xmm4, %xmm7 + mulsd %xmm8, %xmm5 + mulsd %xmm2, %xmm8 + addsd %xmm5, %xmm0 + movaps %xmm7, %xmm6 + movsd 24(%r9,%rdx,8), %xmm10 + addsd %xmm0, %xmm6 + movsd %xmm6, (%rsp) + movzwl 6(%rsp), %ecx + shrl $4, %ecx + movd %xmm6, %r10 + negl %ecx + movsd 32(%r9,%rdx,8), %xmm12 + movsd 40(%r9,%rdx,8), %xmm14 + addl $51, %ecx + sarq %cl, %r10 + movl %r10d, %eax + shlq %cl, %r10 + addl %r8d, %eax + movq %r10, (%rsp) + movl %eax, %r8d + andl $1, %r8d + subsd (%rsp), %xmm7 + mulsd %xmm12, %xmm9 + mulsd %xmm2, %xmm12 + mulsd %xmm14, %xmm11 + addsd (%r11,%r8,8), %xmm7 + mulsd %xmm2, %xmm14 + addsd %xmm7, %xmm0 + addsd %xmm11, %xmm12 + movaps %xmm1, %xmm7 + testb %sil, %sil + mulsd %xmm10, %xmm7 + mulsd %xmm2, %xmm10 + addsd %xmm7, %xmm8 + addsd %xmm9, %xmm10 + addsd %xmm8, %xmm0 + movsd 48(%r9,%rdx,8), %xmm15 + addsd %xmm10, %xmm0 + mulsd %xmm15, %xmm13 + mulsd %xmm15, %xmm2 + addsd %xmm12, %xmm0 + addsd %xmm13, %xmm14 + movsd 56(%r9,%rdx,8), %xmm3 + addsd %xmm14, %xmm0 + mulsd %xmm3, %xmm1 + addsd %xmm1, %xmm2 + addsd %xmm2, %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd %xmm0, (%rdi) + je ..B1.12 +..B1.11: + fldcw 10(%rsp) +..B1.12: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __libm_reduce_pi04d,@function + .size __libm_reduce_pi04d,.-__libm_reduce_pi04d + .data +# -- End __libm_reduce_pi04d + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.0: + .long 0x54442d18,0x3fe921fb + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +zero_none: + .long 0x00000000,0x00000000 + .long 0x00000000,0xbff00000 + .type zero_none,@object + .size zero_none,16 + .align 4 +_DP: + .long 0 + .long 0 + .long 1610612736 + .long 1282694960 + .long 0 + .long 1256952721 + .long 536870912 + .long 1229269500 + .long 3221225472 + .long 1202544455 + .long 0 + .long 1176818551 + .long 2147483648 + .long 1148939346 + .long 536870912 + .long 1124701124 + .long 3758096384 + .long 1099498527 + .long 3758096384 + .long 1071929578 + .long 1342177280 + .long 1046982385 + .long 805306368 + .long 1020320658 + .long 2147483648 + .long 993817732 + .long 0 + .long 968598976 + .long 2684354560 + .long 942220475 + .long 2415919104 + .long 915426956 + .long 0 + .long 885849629 + .long 536870912 + .long 863855510 + .long 1610612736 + .long 836031391 + .long 4026531840 + .long 810828058 + .long 1073741824 + .long 784674491 + .long 1610612736 + .long 757207974 + .long 3489660928 + .long 732020890 + .long 0 + .long 703061904 + .long 1610612736 + .long 679713053 + .long 2147483648 + .long 652001705 + .long 1073741824 + .long 626850382 + .long 2147483648 + .long 597786158 + .long 805306368 + .long 575535400 + .long 536870912 + .long 548814833 + .long 268435456 + .long 523239288 + .long 3758096384 + .long 495550718 + .long 2952790016 + .long 469954840 + .long 1073741824 + .long 442925723 + .long 1073741824 + .long 416247094 + .long 3758096384 + .long 392128403 + .long 2147483648 + .long 364254062 + .long 3221225472 + .long 339643518 + .long 2684354560 + .long 313162111 + .long 805306368 + .long 286354345 + .long 2952790016 + .long 260811902 + .long 1610612736 + .long 234667567 + .long 3758096384 + .long 207520668 + .long 1073741824 + .long 182175017 + .long 4026531840 + .long 155380331 + .long 805306368 + .long 129417058 + .long 536870912 + .long 103691636 + .long 0 + .long 73760972 + .long 3221225472 + .long 48348958 + .type _DP,@object + .size _DP,392 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_reduce_pi04l.S b/external/sgx_libm/intel64/libm_reduce_pi04l.S new file mode 100644 index 0000000000..b7c70a722c --- /dev/null +++ b/external/sgx_libm/intel64/libm_reduce_pi04l.S @@ -0,0 +1,4808 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_reduce_pi04l.c" + .text +..TXTST0: +# -- Begin __libm_reduce_pi04l + .text + .align 16,0x90 + .globl __libm_reduce_pi04l +__libm_reduce_pi04l: +# parameter 1: 8 + %rsp +# parameter 2: %edi +# parameter 3: %rsi +..B1.1: + .cfi_startproc +..___tag_value___libm_reduce_pi04l.1: +..L2: + + movzwl 16(%rsp), %r8d + andl $32767, %r8d + cmpl $16413, %r8d + jge ..B1.8 +..B1.2: + fldt 8(%rsp) + lea __4onpi_d(%rip), %rax + fldl (%rax) + fmul %st(1), %st + fstpt -24(%rsp) + movzwl -16(%rsp), %ecx + negl %ecx + addl $30, %ecx + movl -20(%rsp), %eax + shrl %cl, %eax + testl %edi, %edi + jne ..B1.4 +..B1.3: + lea 1(%rax), %ecx + andl $-2, %ecx + jmp ..B1.5 +..B1.4: + movl %eax, %ecx + addl %edi, %eax + movl %eax, %edx + andl $1, %edx + addl %edx, %ecx +..B1.5: + lea _TWO_32H(%rip), %rdx + cmpl $16400, %r8d + movl %ecx, -40(%rsp) + fildl -40(%rsp) + fldl (%rdx) + jge ..B1.7 +..B1.6: + lea _pi04_3d(%rip), %rdx + lea 8+_pi04_3d(%rip), %rcx + lea 16+_pi04_3d(%rip), %rdi + fldl (%rdx) + fmul %st(2), %st + fsubrp %st, %st(3) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl (%rcx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl (%rdi) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.15 +..B1.7: + lea _pi04_5d(%rip), %rdx + lea 8+_pi04_5d(%rip), %rcx + lea 16+_pi04_5d(%rip), %rdi + lea 24+_pi04_5d(%rip), %r8 + lea 32+_pi04_5d(%rip), %r9 + fldl (%rdx) + fmul %st(2), %st + fsubrp %st, %st(3) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl (%rcx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fldl (%rdi) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl (%r8) + fmul %st(2), %st + fld %st(0) + fsubr %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fldl (%r9) + fmulp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + jmp ..B1.15 +..B1.8: + fldt 8(%rsp) + lea -16417(%r8), %r9d + movl $-2078209981, %eax + lea _SCALE(%rip), %rcx + imull %r9d + fmull (%rcx) + sarl $31, %r9d + lea -16417(%rdx,%r8), %edx + sarl $4, %edx + subl %r9d, %edx + movl %edx, %r10d + shll $5, %r10d + negl %r10d + addl %edx, %r10d + fstpt 8(%rsp) + fldt 8(%rsp) + movl $0, 8(%rsp) + fldt 8(%rsp) + lea -16417(%r10,%r8), %r8d + cmpl $17, %r8d + fsubr %st, %st(1) + jl ..B1.10 +..B1.9: + movslq %edx, %rax + incl %edx + shlq $4, %rax + lea __4onpi_31l(%rip), %r8 + fldt (%rax,%r8) + fmul %st(2), %st + fldt 16(%r8,%rax) + fmul %st(2), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt -24(%rsp) + andl $-16777216, -24(%rsp) + fldt -24(%rsp) + fsubrp %st, %st(1) + jmp ..B1.11 +..B1.10: + lea _zeros(%rip), %rax + lea __4onpi_31l(%rip), %r8 + fldl (%rax) + fld %st(0) +..B1.11: + movslq %edx, %rdx + fld %st(0) + shlq $4, %rdx + fld %st(3) + fldt (%rdx,%r8) + fmul %st(6), %st + fadd %st, %st(2) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fldt 16(%rdx,%r8) + fmul %st, %st(2) + fld %st(2) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fadd %st(3), %st + fxch %st(2) + fmul %st(5), %st + fadd %st, %st(2) + fld %st(4) + fldt 32(%rdx,%r8) + fmul %st, %st(1) + fxch %st(1) + fadd %st, %st(4) + fxch %st(4) + fstpt -24(%rsp) + movzwl -16(%rsp), %r9d + andl $32767, %r9d + cmpl $16415, %r9d + jge ..B1.13 +..B1.12: + negl %r9d + addl $30, %r9d + movl %r9d, %ecx + movl -20(%rsp), %eax + shrl %cl, %eax + movl %r9d, %ecx + shll %cl, %eax + movl %r9d, %ecx + movl %eax, -20(%rsp) + movl $0, -24(%rsp) + shrl %cl, %eax + jmp ..B1.14 +..B1.13: + negl %r9d + addl $30, %r9d + movl %r9d, %ecx + movl -24(%rsp), %r10d + shrl %cl, %r10d + movl %r9d, %ecx + shll %cl, %r10d + movl %r9d, %ecx + negl %ecx + movl -20(%rsp), %eax + shll %cl, %eax + movl %r9d, %ecx + movl %r10d, -24(%rsp) + shrl %cl, %r10d + orl %r10d, %eax +..B1.14: + fldt -24(%rsp) + addl %edi, %eax + lea zero_none(%rip), %rdi + fsubrp %st, %st(3) + fmul %st(6), %st + fld %st(4) + movl %eax, %ecx + andl $1, %ecx + fadd %st(3), %st + lea 8+_pi04_2d(%rip), %r9 + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fldl (%rdi,%rcx,8) + faddp %st, %st(3) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(4) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(3) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(2) + fldt 48(%rdx,%r8) + fmul %st, %st(1) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fxch %st(1) + fmul %st(4), %st + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(2) + fld %st(3) + fldt 64(%rdx,%r8) + fmul %st, %st(2) + fld %st(2) + fadd %st(4), %st + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fld %st(4) + fxch %st(3) + fmul %st(6), %st + fldt 80(%rdx,%r8) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(4) + fxch %st(2) + fmul %st(5), %st + fldt 96(%rdx,%r8) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(4) + fldt 112(%r8,%rdx) + lea _TWO_32H(%rip), %rdx + lea _pi04_2d(%rip), %r8 + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(2) + fadd %st(2), %st + fldl (%rdx) + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldl (%r8) + fld %st(0) + fmul %st(2), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + fmull (%r9) + faddp %st, %st(1) +..B1.15: + fld %st(1) + lea _TWO_12H(%rip), %rdx + fadd %st(1), %st + fstpt -24(%rsp) + fldt -24(%rsp) + fldl (%rdx) + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstl (%rsi) + fsubrp %st, %st(2) + faddp %st, %st(1) + fstpl 8(%rsi) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_reduce_pi04l,@function + .size __libm_reduce_pi04l,.-__libm_reduce_pi04l + .data +# -- End __libm_reduce_pi04l + .section .rodata, "a" + .align 8 + .align 8 +zero_none: + .long 0x00000000,0x00000000 + .long 0x00000000,0xbff00000 + .type zero_none,@object + .size zero_none,16 + .align 4 +__4onpi_d: + .long 1841940611 + .long 1072979760 + .type __4onpi_d,@object + .size __4onpi_d,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_pi04_3d: + .long 1413754112 + .long 1072243195 + .long 2563527040 + .long 1021855384 + .long 3417685868 + .long 3118450936 + .type _pi04_3d,@object + .size _pi04_3d,24 + .align 4 +_pi04_5d: + .long 1413480448 + .long 1072243195 + .long 442499072 + .long 1036039265 + .long 771751936 + .long 999496074 + .long 622854144 + .long 963347354 + .long 1396597664 + .long 922906692 + .type _pi04_5d,@object + .size _pi04_5d,40 + .align 4 +_SCALE: + .long 0 + .long 845152256 + .type _SCALE,@object + .size _SCALE,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_pi04_2d: + .long 1413480448 + .long 1072243195 + .long 442655537 + .long 1036039265 + .type _pi04_2d,@object + .size _pi04_2d,16 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 2 +__4onpi_31l: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33646 + .word 41721 + .word 16600 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10832 + .word 40072 + .word 16567 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44008 + .word 65043 + .word 16537 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28384 + .word 64154 + .word 16505 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38272 + .word 56162 + .word 16472 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7298 + .word 51682 + .word 16445 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45504 + .word 65320 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61204 + .word 44922 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18652 + .word 50030 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14144 + .word 59657 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37450 + .word 47105 + .word 16290 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14898 + .word 56641 + .word 16259 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34680 + .word 34623 + .word 16226 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4760 + .word 45515 + .word 16196 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41480 + .word 40187 + .word 16166 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47852 + .word 55252 + .word 16134 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54072 + .word 35081 + .word 16103 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26808 + .word 57421 + .word 16071 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20068 + .word 57232 + .word 16042 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49576 + .word 60188 + .word 16009 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10016 + .word 52861 + .word 15978 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30648 + .word 35825 + .word 15947 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60542 + .word 58528 + .word 15918 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65468 + .word 61743 + .word 15887 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64960 + .word 45825 + .word 15851 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50604 + .word 38792 + .word 15825 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18394 + .word 33435 + .word 15794 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55780 + .word 42703 + .word 15763 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 63841 + .word 15731 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63080 + .word 62563 + .word 15700 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20840 + .word 62207 + .word 15669 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30094 + .word 59983 + .word 15639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61818 + .word 60389 + .word 15608 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40186 + .word 40579 + .word 15577 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42170 + .word 58004 + .word 15546 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55276 + .word 39678 + .word 15514 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44672 + .word 36806 + .word 15481 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13060 + .word 34144 + .word 15452 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28016 + .word 57231 + .word 15419 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16112 + .word 44995 + .word 15390 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53464 + .word 33387 + .word 15358 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7296 + .word 60751 + .word 15325 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29452 + .word 45231 + .word 15297 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26208 + .word 49689 + .word 15266 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37900 + .word 44002 + .word 15235 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57340 + .word 33800 + .word 15204 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27544 + .word 50178 + .word 15173 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6168 + .word 40132 + .word 15142 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21392 + .word 43702 + .word 15109 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45168 + .word 54372 + .word 15081 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8986 + .word 40688 + .word 15050 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1648 + .word 53745 + .word 15018 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30520 + .word 55795 + .word 14986 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43060 + .word 32914 + .word 14956 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46172 + .word 52771 + .word 14925 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 45285 + .word 14893 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53590 + .word 44868 + .word 14864 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40786 + .word 35970 + .word 14833 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33436 + .word 65411 + .word 14801 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32006 + .word 61382 + .word 14771 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37856 + .word 45239 + .word 14738 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60894 + .word 49555 + .word 14709 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48064 + .word 53065 + .word 14674 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48624 + .word 54844 + .word 14647 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7988 + .word 40762 + .word 14616 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16270 + .word 58745 + .word 14585 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37064 + .word 50168 + .word 14553 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18624 + .word 63736 + .word 14519 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60758 + .word 44966 + .word 14492 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33304 + .word 47465 + .word 14461 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6226 + .word 60503 + .word 14430 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26380 + .word 54900 + .word 14398 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44352 + .word 49860 + .word 14368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11904 + .word 42646 + .word 14337 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 50279 + .word 14300 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15474 + .word 50606 + .word 14275 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45062 + .word 44137 + .word 14244 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 36063 + .word 14210 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40658 + .word 53854 + .word 14182 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28652 + .word 43690 + .word 14151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24640 + .word 64348 + .word 14118 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30284 + .word 41980 + .word 14088 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45652 + .word 38222 + .word 14057 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15900 + .word 62940 + .word 14026 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31494 + .word 50741 + .word 13996 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43194 + .word 55096 + .word 13965 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1740 + .word 45646 + .word 13933 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28936 + .word 44150 + .word 13903 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8996 + .word 42955 + .word 13872 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44096 + .word 61205 + .word 13839 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44614 + .word 54550 + .word 13810 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24926 + .word 57347 + .word 13779 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3312 + .word 61415 + .word 13745 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64336 + .word 63884 + .word 13717 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2748 + .word 62259 + .word 13685 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56672 + .word 51775 + .word 13653 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32438 + .word 55423 + .word 13624 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17652 + .word 45713 + .word 13593 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65408 + .word 51586 + .word 13558 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40416 + .word 55736 + .word 13531 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52546 + .word 37734 + .word 13500 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48880 + .word 64238 + .word 13469 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56004 + .word 46833 + .word 13437 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61760 + .word 38110 + .word 13405 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41496 + .word 35659 + .word 13374 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25472 + .word 41269 + .word 13342 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45444 + .word 36018 + .word 13314 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6510 + .word 56417 + .word 13283 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3072 + .word 56837 + .word 13252 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61338 + .word 48440 + .word 13221 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49568 + .word 57088 + .word 13189 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4240 + .word 39283 + .word 13157 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18562 + .word 33537 + .word 13128 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31422 + .word 44487 + .word 13097 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31930 + .word 60459 + .word 13066 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42272 + .word 36641 + .word 13033 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28940 + .word 36150 + .word 13004 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21010 + .word 50925 + .word 12973 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29448 + .word 64886 + .word 12941 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20500 + .word 54600 + .word 12911 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54258 + .word 46233 + .word 12880 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32628 + .word 42502 + .word 12848 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61608 + .word 55072 + .word 12818 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6236 + .word 57871 + .word 12786 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42408 + .word 34616 + .word 12756 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56692 + .word 51963 + .word 12724 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39094 + .word 48526 + .word 12694 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59870 + .word 38783 + .word 12663 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26560 + .word 33165 + .word 12632 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58666 + .word 37666 + .word 12601 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58728 + .word 39788 + .word 12569 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9048 + .word 43530 + .word 12538 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58496 + .word 57659 + .word 12505 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12324 + .word 37025 + .word 12477 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38432 + .word 55856 + .word 12445 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35210 + .word 45960 + .word 12415 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45644 + .word 51345 + .word 12384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32854 + .word 63883 + .word 12353 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29348 + .word 41450 + .word 12321 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27384 + .word 38024 + .word 12289 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57356 + .word 57291 + .word 12260 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61164 + .word 51521 + .word 12228 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 59151 + .word 12196 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36704 + .word 39943 + .word 12165 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45864 + .word 50151 + .word 12136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37892 + .word 63687 + .word 12104 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14560 + .word 51615 + .word 12073 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38776 + .word 55684 + .word 12041 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59136 + .word 53570 + .word 12010 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55556 + .word 37955 + .word 11981 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54458 + .word 44670 + .word 11950 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36446 + .word 34084 + .word 11919 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46416 + .word 51693 + .word 11886 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21432 + .word 34376 + .word 11857 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56036 + .word 34809 + .word 11826 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10562 + .word 55654 + .word 11795 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20264 + .word 53052 + .word 11763 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64064 + .word 50415 + .word 11729 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17444 + .word 48295 + .word 11701 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11874 + .word 52677 + .word 11671 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60808 + .word 39275 + .word 11640 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31792 + .word 55677 + .word 11606 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60710 + .word 49006 + .word 11578 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10520 + .word 37403 + .word 11546 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20004 + .word 59470 + .word 11515 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28096 + .word 37612 + .word 11485 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20268 + .word 44280 + .word 11453 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50740 + .word 61588 + .word 11422 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 58835 + .word 11390 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8576 + .word 42496 + .word 11355 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33920 + .word 54912 + .word 11324 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35620 + .word 54843 + .word 11298 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 736 + .word 43591 + .word 11264 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39632 + .word 61060 + .word 11235 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63452 + .word 63129 + .word 11206 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56798 + .word 58512 + .word 11175 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 46333 + .word 11141 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37300 + .word 36598 + .word 11112 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41952 + .word 41639 + .word 11079 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52452 + .word 33459 + .word 11050 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58558 + .word 33287 + .word 11020 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7570 + .word 43843 + .word 10989 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59416 + .word 63990 + .word 10957 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65298 + .word 47744 + .word 10927 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21076 + .word 34089 + .word 10896 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7048 + .word 57394 + .word 10865 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12872 + .word 55405 + .word 10832 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12608 + .word 51669 + .word 10798 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5350 + .word 48455 + .word 10772 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23568 + .word 58692 + .word 10740 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40784 + .word 37046 + .word 10708 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38992 + .word 43861 + .word 10678 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10064 + .word 40199 + .word 10648 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26368 + .word 35771 + .word 10611 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23994 + .word 60721 + .word 10586 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25052 + .word 34302 + .word 10554 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39842 + .word 54964 + .word 10524 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11568 + .word 58277 + .word 10491 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26160 + .word 46438 + .word 10461 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23252 + .word 43049 + .word 10431 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35288 + .word 58000 + .word 10400 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14614 + .word 50216 + .word 10369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1168 + .word 48804 + .word 10336 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60934 + .word 33006 + .word 10307 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 62247 + .word 10272 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59968 + .word 43121 + .word 10240 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25560 + .word 39974 + .word 10212 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1978 + .word 49353 + .word 10183 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16290 + .word 38807 + .word 10152 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8646 + .word 65226 + .word 10121 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56896 + .word 34317 + .word 10088 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40136 + .word 39118 + .word 10057 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14200 + .word 41756 + .word 10026 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59256 + .word 63202 + .word 9995 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 22968 + .word 63553 + .word 9965 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 736 + .word 44292 + .word 9933 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23186 + .word 37760 + .word 9904 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51008 + .word 34950 + .word 9869 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1664 + .word 64248 + .word 9836 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 35199 + .word 9811 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34656 + .word 63747 + .word 9780 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44330 + .word 49864 + .word 9749 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11654 + .word 35567 + .word 9718 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7924 + .word 58919 + .word 9686 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2532 + .word 32800 + .word 9655 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30024 + .word 53799 + .word 9624 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30172 + .word 64347 + .word 9593 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60036 + .word 51382 + .word 9562 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58576 + .word 33093 + .word 9531 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13888 + .word 38760 + .word 9500 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9322 + .word 52460 + .word 9470 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20944 + .word 41077 + .word 9437 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17976 + .word 41861 + .word 9407 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55176 + .word 55158 + .word 9377 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4976 + .word 35223 + .word 9346 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7816 + .word 39783 + .word 9314 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27656 + .word 55669 + .word 9284 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64944 + .word 53184 + .word 9250 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12544 + .word 49190 + .word 9222 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50612 + .word 44644 + .word 9190 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8832 + .word 63111 + .word 9155 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11744 + .word 36870 + .word 9129 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9404 + .word 63025 + .word 9098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47316 + .word 43381 + .word 9067 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55716 + .word 47433 + .word 9035 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46414 + .word 48441 + .word 9005 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19116 + .word 39506 + .word 8974 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48060 + .word 53381 + .word 8943 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57112 + .word 50739 + .word 8911 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5840 + .word 60581 + .word 8879 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62112 + .word 57199 + .word 8846 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35908 + .word 59499 + .word 8818 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13760 + .word 48116 + .word 8787 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3136 + .word 56059 + .word 8752 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37596 + .word 39221 + .word 8726 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3232 + .word 48550 + .word 8691 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 22872 + .word 42749 + .word 8662 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41948 + .word 40319 + .word 8633 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31196 + .word 64693 + .word 8601 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62052 + .word 52923 + .word 8571 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2750 + .word 33544 + .word 8540 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12462 + .word 46179 + .word 8509 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25128 + .word 45120 + .word 8476 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51634 + .word 62523 + .word 8447 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15758 + .word 42163 + .word 8416 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34022 + .word 36267 + .word 8385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41252 + .word 39796 + .word 8353 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49782 + .word 54423 + .word 8323 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25428 + .word 42086 + .word 8291 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34388 + .word 44810 + .word 8260 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7456 + .word 64092 + .word 8228 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48336 + .word 62448 + .word 8196 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60912 + .word 61622 + .word 8167 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17852 + .word 37250 + .word 8137 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57940 + .word 56453 + .word 8106 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47256 + .word 59825 + .word 8074 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3774 + .word 59120 + .word 8044 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43448 + .word 62852 + .word 8012 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4840 + .word 57195 + .word 7982 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40862 + .word 52565 + .word 7951 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1440 + .word 60474 + .word 7919 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55520 + .word 38648 + .word 7889 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15316 + .word 52422 + .word 7857 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18704 + .word 47227 + .word 7827 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48892 + .word 54283 + .word 7795 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12670 + .word 41990 + .word 7765 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27570 + .word 49842 + .word 7734 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47230 + .word 47992 + .word 7703 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41020 + .word 56253 + .word 7671 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23404 + .word 58312 + .word 7641 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35176 + .word 51854 + .word 7610 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49188 + .word 59051 + .word 7578 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16656 + .word 54507 + .word 7546 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41320 + .word 48565 + .word 7517 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 302 + .word 42490 + .word 7486 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26680 + .word 39967 + .word 7454 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41304 + .word 43638 + .word 7424 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2314 + .word 48533 + .word 7393 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63294 + .word 35693 + .word 7362 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24538 + .word 48319 + .word 7331 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56296 + .word 47263 + .word 7300 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 38599 + .word 7268 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6594 + .word 62116 + .word 7238 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47104 + .word 63573 + .word 7198 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34812 + .word 34303 + .word 7176 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5144 + .word 33695 + .word 7145 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24966 + .word 55768 + .word 7114 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62720 + .word 43946 + .word 7078 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31542 + .word 56062 + .word 7052 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62356 + .word 59096 + .word 7020 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28412 + .word 40533 + .word 6990 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24080 + .word 50467 + .word 6958 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33296 + .word 46841 + .word 6925 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39600 + .word 38627 + .word 6897 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14436 + .word 37607 + .word 6865 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39032 + .word 56421 + .word 6833 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64032 + .word 54987 + .word 6804 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27648 + .word 42212 + .word 6768 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43840 + .word 46107 + .word 6739 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17316 + .word 36574 + .word 6711 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8928 + .word 37652 + .word 6677 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24944 + .word 47433 + .word 6648 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 57430 + .word 6616 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39848 + .word 43340 + .word 6585 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64160 + .word 43542 + .word 6555 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35226 + .word 63015 + .word 6525 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40736 + .word 64368 + .word 6493 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42168 + .word 49526 + .word 6462 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45596 + .word 34243 + .word 6432 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20690 + .word 39705 + .word 6401 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54448 + .word 46856 + .word 6368 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64392 + .word 62736 + .word 6337 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12780 + .word 56461 + .word 6307 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15360 + .word 49145 + .word 6277 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20512 + .word 49931 + .word 6242 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54512 + .word 55820 + .word 6212 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8402 + .word 39333 + .word 6184 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34094 + .word 53593 + .word 6153 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31960 + .word 38817 + .word 6121 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16954 + .word 39291 + .word 6091 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49600 + .word 48765 + .word 6056 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59580 + .word 56541 + .word 6029 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35624 + .word 44550 + .word 5998 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4142 + .word 47316 + .word 5967 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43520 + .word 43612 + .word 5935 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20976 + .word 40896 + .word 5902 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63576 + .word 57729 + .word 5874 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37288 + .word 33122 + .word 5843 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24384 + .word 52079 + .word 5809 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47952 + .word 58719 + .word 5779 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44242 + .word 55445 + .word 5750 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61232 + .word 38847 + .word 5716 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 46039 + .word 5683 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13396 + .word 42933 + .word 5657 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 43305 + .word 5622 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40708 + .word 35319 + .word 5595 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44408 + .word 55685 + .word 5564 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42090 + .word 44607 + .word 5533 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25504 + .word 53466 + .word 5500 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24208 + .word 33149 + .word 5470 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5268 + .word 45375 + .word 5440 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 144 + .word 40000 + .word 5409 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56688 + .word 52358 + .word 5376 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25848 + .word 56175 + .word 5345 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57900 + .word 44055 + .word 5315 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24800 + .word 43437 + .word 5283 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17984 + .word 54872 + .word 5249 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25744 + .word 41345 + .word 5223 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7668 + .word 43682 + .word 5191 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47434 + .word 36705 + .word 5161 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20888 + .word 40323 + .word 5129 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3962 + .word 43032 + .word 5099 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50270 + .word 49260 + .word 5068 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20160 + .word 64041 + .word 5032 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25624 + .word 36013 + .word 5004 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48328 + .word 59345 + .word 4975 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51508 + .word 63920 + .word 4943 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27872 + .word 39135 + .word 4913 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13590 + .word 58857 + .word 4882 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50880 + .word 61323 + .word 4847 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44802 + .word 37181 + .word 4820 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53808 + .word 57813 + .word 4789 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64424 + .word 49714 + .word 4757 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31652 + .word 44011 + .word 4727 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28252 + .word 50834 + .word 4696 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30370 + .word 38742 + .word 4665 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57728 + .word 58403 + .word 4628 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35900 + .word 37112 + .word 4603 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40764 + .word 40914 + .word 4572 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 46910 + .word 4541 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17854 + .word 35030 + .word 4510 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4378 + .word 35776 + .word 4479 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57962 + .word 55295 + .word 4448 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 56717 + .word 4415 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37744 + .word 49416 + .word 4384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38484 + .word 35759 + .word 4355 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55020 + .word 54969 + .word 4324 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9188 + .word 55223 + .word 4292 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6822 + .word 43079 + .word 4262 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48870 + .word 40943 + .word 4231 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9936 + .word 42731 + .word 4198 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23430 + .word 43136 + .word 4169 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4700 + .word 55665 + .word 4137 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8056 + .word 40216 + .word 4106 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3716 + .word 45403 + .word 4075 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53440 + .word 49488 + .word 4044 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41776 + .word 50188 + .word 4013 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20994 + .word 64556 + .word 3983 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16252 + .word 60661 + .word 3951 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61252 + .word 65021 + .word 3920 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16236 + .word 43803 + .word 3889 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63064 + .word 35308 + .word 3857 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49096 + .word 39848 + .word 3828 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15680 + .word 48673 + .word 3797 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48068 + .word 50957 + .word 3766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20824 + .word 56086 + .word 3734 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46504 + .word 43224 + .word 3704 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52428 + .word 46094 + .word 3672 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17548 + .word 52066 + .word 3642 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61738 + .word 35565 + .word 3611 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31184 + .word 50588 + .word 3579 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1716 + .word 52681 + .word 3549 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44656 + .word 43385 + .word 3518 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12668 + .word 43259 + .word 3486 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24544 + .word 35408 + .word 3453 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28854 + .word 65018 + .word 3425 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5696 + .word 40391 + .word 3393 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39580 + .word 56400 + .word 3363 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20428 + .word 39579 + .word 3332 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32328 + .word 36727 + .word 3301 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34020 + .word 54457 + .word 3270 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34016 + .word 48400 + .word 3238 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6922 + .word 51417 + .word 3208 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27208 + .word 64641 + .word 3176 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1802 + .word 48886 + .word 3146 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35440 + .word 61590 + .word 3115 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60610 + .word 51604 + .word 3084 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5440 + .word 38199 + .word 3050 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6914 + .word 43867 + .word 3022 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24000 + .word 45256 + .word 2989 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51496 + .word 57396 + .word 2959 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11538 + .word 46256 + .word 2929 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36802 + .word 48020 + .word 2898 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57910 + .word 57903 + .word 2867 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47484 + .word 48798 + .word 2835 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57766 + .word 57709 + .word 2805 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54064 + .word 47856 + .word 2774 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49340 + .word 48080 + .word 2743 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36454 + .word 56731 + .word 2712 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51548 + .word 63385 + .word 2681 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56000 + .word 48716 + .word 2645 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44992 + .word 50040 + .word 2615 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43136 + .word 58177 + .word 2585 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49730 + .word 33270 + .word 2557 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29808 + .word 51063 + .word 2526 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25276 + .word 46724 + .word 2494 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17324 + .word 35928 + .word 2463 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52284 + .word 63916 + .word 2433 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5414 + .word 46704 + .word 2402 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51710 + .word 57168 + .word 2371 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27366 + .word 49253 + .word 2340 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45332 + .word 53033 + .word 2309 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54152 + .word 37418 + .word 2276 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53076 + .word 47398 + .word 2247 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14374 + .word 59477 + .word 2216 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59336 + .word 33435 + .word 2184 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21612 + .word 43267 + .word 2154 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34664 + .word 39372 + .word 2121 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 172 + .word 62761 + .word 2091 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9816 + .word 40715 + .word 2060 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65116 + .word 40481 + .word 2030 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28066 + .word 39184 + .word 1999 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37408 + .word 63923 + .word 1968 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15760 + .word 42305 + .word 1937 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 59340 + .word 1905 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43258 + .word 59402 + .word 1875 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19988 + .word 50087 + .word 1844 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63456 + .word 47833 + .word 1810 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65184 + .word 61426 + .word 1781 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52982 + .word 48456 + .word 1751 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30020 + .word 62809 + .word 1719 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9096 + .word 63061 + .word 1688 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59648 + .word 44374 + .word 1654 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11456 + .word 33847 + .word 1625 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12392 + .word 50500 + .word 1595 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 59196 + .word 1563 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61008 + .word 40265 + .word 1532 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37842 + .word 33270 + .word 1503 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37916 + .word 44543 + .word 1471 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11490 + .word 36421 + .word 1441 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19040 + .word 38397 + .word 1409 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31224 + .word 47162 + .word 1379 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52056 + .word 41461 + .word 1347 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10810 + .word 56374 + .word 1317 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5358 + .word 35086 + .word 1286 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36640 + .word 50226 + .word 1251 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33856 + .word 45597 + .word 1222 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21552 + .word 63128 + .word 1191 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1198 + .word 35616 + .word 1162 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1232 + .word 59506 + .word 1131 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51086 + .word 34963 + .word 1100 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3960 + .word 39061 + .word 1067 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4564 + .word 57134 + .word 1037 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59468 + .word 35285 + .word 1007 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63422 + .word 35431 + .word 976 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38352 + .word 51462 + .word 945 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25806 + .word 55660 + .word 914 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38842 + .word 41327 + .word 883 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17980 + .word 50458 + .word 852 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61194 + .word 59710 + .word 821 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21098 + .word 42086 + .word 790 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16704 + .word 43341 + .word 757 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46316 + .word 52840 + .word 728 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20386 + .word 33936 + .word 697 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20064 + .word 51864 + .word 664 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2268 + .word 57500 + .word 634 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11152 + .word 51171 + .word 604 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23164 + .word 63727 + .word 572 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20514 + .word 40280 + .word 542 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21818 + .word 57922 + .word 511 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32366 + .word 46413 + .word 480 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53972 + .word 43148 + .word 449 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30134 + .word 65133 + .word 418 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15282 + .word 61516 + .word 387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49872 + .word 49222 + .word 355 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9484 + .word 63958 + .word 325 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47028 + .word 35341 + .word 294 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6770 + .word 58613 + .word 263 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33372 + .word 43448 + .word 232 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27792 + .word 51629 + .word 198 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19712 + .word 53691 + .word 170 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42144 + .word 60929 + .word 135 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35240 + .word 48799 + .word 107 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 910 + .word 51212 + .word 77 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65062 + .word 33668 + .word 46 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52624 + .word 51799 + .word 14 + .word 0 + .word 0 + .word 0 + .type __4onpi_31l,@object + .size __4onpi_31l,8592 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_reduce_pio2.S b/external/sgx_libm/intel64/libm_reduce_pio2.S new file mode 100644 index 0000000000..644bf3a434 --- /dev/null +++ b/external/sgx_libm/intel64/libm_reduce_pio2.S @@ -0,0 +1,543 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_reduce_pio2.c" + .text +..TXTST0: +# -- Begin __libm_reduce_pio2d + .text + .align 16,0x90 + .globl __libm_reduce_pio2d +__libm_reduce_pio2d: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_reduce_pio2d.1: +..L2: + + movq %rdi, %r9 + movsd %xmm0, -8(%rsp) + movzbl -1(%rsp), %eax + movl %eax, %r8d + andl $127, %eax + andl $128, %r8d + movb %al, -1(%rsp) + movzwl -2(%rsp), %eax + movl %eax, %edx + andl $32752, %edx + shrl $4, %edx + shrl $7, %r8d + cmpl $1053, %edx + jge ..B1.9 +..B1.2: + lea _PI04_INV(%rip), %rax + movsd -8(%rsp), %xmm0 + movsd (%rax), %xmm1 + mulsd %xmm0, %xmm1 + movsd %xmm1, -16(%rsp) + movzwl -10(%rsp), %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $1023, %ecx + jl ..B1.4 +..B1.3: + movl -12(%rsp), %esi + negl %ecx + orl $-1048576, %esi + addl $30, %ecx + movl -16(%rsp), %eax + shll $11, %esi + shrl $21, %eax + orl %eax, %esi + shrl %cl, %esi + jmp ..B1.5 +..B1.4: + xorl %esi, %esi +..B1.5: + movl %esi, %ecx + lea (%r8,%r8), %eax + andl $1, %ecx + negl %eax + addl %esi, %ecx + incl %esi + shrl $1, %esi + incl %eax + imull %esi, %eax + pxor %xmm7, %xmm7 + cvtsi2sd %ecx, %xmm7 + andl $3, %eax + cmpl $1046, %edx + jge ..B1.7 +..B1.6: + lea _PI04_29x4(%rip), %rdx + lea 8+_PI04_29x4(%rip), %rcx + lea 16+_PI04_29x4(%rip), %rsi + lea 24+_PI04_29x4(%rip), %rdi + movsd (%rdx), %xmm1 + mulsd %xmm7, %xmm1 + movsd (%rcx), %xmm2 + subsd %xmm1, %xmm0 + mulsd %xmm7, %xmm2 + movaps %xmm0, %xmm4 + movsd (%rsi), %xmm3 + subsd %xmm2, %xmm4 + mulsd %xmm7, %xmm3 + subsd %xmm4, %xmm0 + movsd (%rdi), %xmm5 + subsd %xmm2, %xmm0 + mulsd %xmm5, %xmm7 + movaps %xmm4, %xmm2 + subsd %xmm3, %xmm2 + subsd %xmm2, %xmm4 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm0 + subsd %xmm7, %xmm0 + jmp ..B1.8 +..B1.7: + lea _PI04_21x5(%rip), %rdx + lea 8+_PI04_21x5(%rip), %rcx + lea 16+_PI04_21x5(%rip), %rsi + lea 24+_PI04_21x5(%rip), %rdi + lea 32+_PI04_21x5(%rip), %r10 + movsd (%rdx), %xmm1 + movsd (%rcx), %xmm2 + mulsd %xmm7, %xmm1 + mulsd %xmm7, %xmm2 + subsd %xmm1, %xmm0 + movaps %xmm0, %xmm4 + movsd (%rsi), %xmm3 + subsd %xmm2, %xmm4 + mulsd %xmm7, %xmm3 + subsd %xmm4, %xmm0 + movaps %xmm4, %xmm8 + subsd %xmm2, %xmm0 + subsd %xmm3, %xmm8 + movaps %xmm8, %xmm5 + subsd %xmm8, %xmm4 + movsd (%r10), %xmm6 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm0 + addsd %xmm0, %xmm5 + movaps %xmm5, %xmm2 + subsd %xmm5, %xmm8 + addsd %xmm0, %xmm8 + movsd (%rdi), %xmm0 + mulsd %xmm7, %xmm0 + mulsd %xmm6, %xmm7 + subsd %xmm0, %xmm2 + subsd %xmm2, %xmm5 + subsd %xmm0, %xmm5 + addsd %xmm5, %xmm8 + subsd %xmm7, %xmm8 + movaps %xmm8, %xmm0 +..B1.8: + movl %r8d, %r8d + lea _ones(%rip), %rdx + movsd (%rdx,%r8,8), %xmm1 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm0 + movaps %xmm2, %xmm3 + addsd %xmm0, %xmm3 + movsd %xmm3, (%r9) + subsd %xmm3, %xmm2 + addsd %xmm0, %xmm2 + movsd %xmm2, 8(%r9) + ret +..B1.9: + andl $-32753, %eax + lea -200(%rdx), %r10d + andl $2047, %r10d + shll $4, %r10d + orl %r10d, %eax + movw %ax, -2(%rsp) + lea -1052(%rdx), %eax + imull $83886, %eax, %edi + movsd -8(%rsp), %xmm2 + movsd %xmm2, -24(%rsp) + sarl $21, %edi + movslq %edi, %rdi + imull $-25, %edi, %esi + movl -8(%rsp), %r11d + lea -1052(%rsi,%rdx), %ecx + andl $-134217728, %r11d + lea _DP(%rip), %rsi + movl %r11d, -24(%rsp) + negl %ecx + movsd -24(%rsp), %xmm1 + addl $38, %ecx + movaps %xmm1, %xmm3 + movq $-1, %rdx + movsd (%rsi,%rdi,8), %xmm0 + movaps %xmm1, %xmm7 + movsd 8(%rsi,%rdi,8), %xmm5 + movaps %xmm1, %xmm14 + mulsd %xmm5, %xmm3 + subsd %xmm1, %xmm2 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + movaps %xmm0, %xmm6 + shlq %cl, %rdx + addsd %xmm3, %xmm6 + movaps %xmm6, %xmm4 + subsd %xmm6, %xmm0 + movsd 16(%rsi,%rdi,8), %xmm12 + addsd %xmm3, %xmm0 + mulsd %xmm12, %xmm7 + mulsd %xmm2, %xmm12 + addsd %xmm0, %xmm4 + movd %xmm4, %r10 + movsd 24(%rsi,%rdi,8), %xmm3 + mulsd %xmm3, %xmm14 + mulsd %xmm2, %xmm3 + andq %rdx, %r10 + movq %r10, -16(%rsp) + subsd -16(%rsp), %xmm6 + movaps %xmm6, %xmm8 + addsd %xmm5, %xmm8 + movaps %xmm8, %xmm10 + subsd %xmm8, %xmm6 + addsd %xmm7, %xmm10 + addsd %xmm5, %xmm6 + subsd %xmm10, %xmm8 + addsd %xmm6, %xmm0 + addsd %xmm7, %xmm8 + movaps %xmm10, %xmm9 + movaps %xmm1, %xmm5 + movsd 32(%rsi,%rdi,8), %xmm7 + addsd %xmm8, %xmm0 + mulsd %xmm7, %xmm5 + mulsd %xmm2, %xmm7 + addsd %xmm0, %xmm9 + movaps %xmm0, %xmm13 + addsd %xmm12, %xmm9 + addsd %xmm14, %xmm9 + movsd %xmm9, -16(%rsp) + movzwl -10(%rsp), %ecx + shrl $4, %ecx + movd %xmm9, %rax + negl %ecx + movaps %xmm1, %xmm9 + addl $51, %ecx + sarq %cl, %rax + movl %eax, %edx + shlq %cl, %rax + movl %edx, %r11d + movq %rax, -16(%rsp) + lea _zero_none(%rip), %rax + andl $1, %r11d + incl %edx + shrl $1, %edx + lea _PI04_25x2(%rip), %rcx + subsd -16(%rsp), %xmm10 + movsd (%rax,%r11,8), %xmm11 + lea (%r8,%r8), %eax + negl %eax + addsd %xmm10, %xmm13 + incl %eax + subsd %xmm13, %xmm10 + imull %edx, %eax + addsd %xmm11, %xmm13 + addsd %xmm10, %xmm0 + movaps %xmm13, %xmm15 + movaps %xmm1, %xmm11 + lea _TWO_26H(%rip), %rdx + andl $3, %eax + addsd %xmm12, %xmm15 + movaps %xmm15, %xmm4 + subsd %xmm15, %xmm13 + addsd %xmm14, %xmm4 + addsd %xmm12, %xmm13 + subsd %xmm4, %xmm15 + addsd %xmm13, %xmm0 + addsd %xmm14, %xmm15 + movaps %xmm4, %xmm6 + movaps %xmm1, %xmm14 + movsd 40(%rsi,%rdi,8), %xmm12 + addsd %xmm3, %xmm6 + mulsd %xmm12, %xmm9 + addsd %xmm15, %xmm0 + mulsd %xmm2, %xmm12 + subsd %xmm6, %xmm4 + movaps %xmm6, %xmm8 + addsd %xmm3, %xmm4 + addsd %xmm5, %xmm8 + addsd %xmm4, %xmm0 + subsd %xmm8, %xmm6 + movaps %xmm8, %xmm10 + addsd %xmm5, %xmm6 + addsd %xmm7, %xmm10 + addsd %xmm6, %xmm0 + subsd %xmm10, %xmm8 + movsd 48(%rsi,%rdi,8), %xmm3 + movaps %xmm10, %xmm13 + mulsd %xmm3, %xmm11 + addsd %xmm9, %xmm13 + addsd %xmm7, %xmm8 + mulsd %xmm2, %xmm3 + addsd %xmm11, %xmm12 + subsd %xmm13, %xmm10 + addsd %xmm8, %xmm0 + addsd %xmm9, %xmm10 + movsd 56(%rsi,%rdi,8), %xmm15 + movaps %xmm13, %xmm4 + mulsd %xmm15, %xmm14 + addsd %xmm12, %xmm4 + addsd %xmm10, %xmm0 + mulsd %xmm15, %xmm2 + addsd %xmm14, %xmm3 + subsd %xmm4, %xmm13 + movaps %xmm4, %xmm5 + addsd %xmm12, %xmm13 + addsd %xmm3, %xmm5 + addsd %xmm13, %xmm0 + subsd %xmm5, %xmm4 + addsd %xmm3, %xmm4 + movsd 64(%rsi,%rdi,8), %xmm3 + mulsd %xmm3, %xmm1 + addsd %xmm4, %xmm0 + addsd %xmm1, %xmm2 + movaps %xmm2, %xmm3 + lea 8+_PI04_25x2(%rip), %rsi + movsd (%rdx), %xmm1 + lea _ones(%rip), %rdx + addsd %xmm5, %xmm3 + mulsd %xmm3, %xmm1 + addsd %xmm1, %xmm3 + subsd %xmm1, %xmm3 + subsd %xmm3, %xmm5 + addsd %xmm2, %xmm5 + movsd (%rcx), %xmm2 + addsd %xmm5, %xmm0 + movaps %xmm0, %xmm1 + addsd %xmm3, %xmm0 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm3 + mulsd (%rsi), %xmm0 + addsd %xmm0, %xmm1 + movaps %xmm1, %xmm0 + addsd %xmm3, %xmm0 + subsd %xmm0, %xmm3 + addsd %xmm1, %xmm3 + movsd (%rdx,%r8,8), %xmm1 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm3 + movsd %xmm0, (%r9) + movsd %xmm3, 8(%r9) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_reduce_pio2d,@function + .size __libm_reduce_pio2d,.-__libm_reduce_pio2d + .data +# -- End __libm_reduce_pio2d + .section .rodata, "a" + .align 16 + .align 16 +_PI04_INV: + .long 1841940611 + .long 1072979760 + .type _PI04_INV,@object + .size _PI04_INV,8 + .space 8, 0x00 # pad + .align 16 +_PI04_29x4: + .long 1409286144 + .long 1072243195 + .long 301989888 + .long 1040255814 + .long 1006632960 + .long 3156637299 + .long 2207917344 + .long 979464219 + .type _PI04_29x4,@object + .size _PI04_29x4,32 + .align 16 +_PI04_21x5: + .long 0 + .long 1072243194 + .long 0 + .long 1051018307 + .long 0 + .long 3174514122 + .long 0 + .long 3153310618 + .long 3773204808 + .long 981752838 + .type _PI04_21x5,@object + .size _PI04_21x5,40 + .space 8, 0x00 # pad + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_DP: + .long 0 + .long 0 + .long 1610612736 + .long 1282694960 + .long 0 + .long 1256952721 + .long 536870912 + .long 1229269500 + .long 3221225472 + .long 1202544455 + .long 0 + .long 1176818551 + .long 2147483648 + .long 1148939346 + .long 536870912 + .long 1124701124 + .long 3758096384 + .long 1099498527 + .long 3758096384 + .long 1071929578 + .long 1342177280 + .long 1046982385 + .long 805306368 + .long 1020320658 + .long 2147483648 + .long 993817732 + .long 0 + .long 968598976 + .long 2684354560 + .long 942220475 + .long 2415919104 + .long 915426956 + .long 0 + .long 885849629 + .long 536870912 + .long 863855510 + .long 1610612736 + .long 836031391 + .long 4026531840 + .long 810828058 + .long 1073741824 + .long 784674491 + .long 1610612736 + .long 757207974 + .long 3489660928 + .long 732020890 + .long 0 + .long 703061904 + .long 1610612736 + .long 679713053 + .long 2147483648 + .long 652001705 + .long 1073741824 + .long 626850382 + .long 2147483648 + .long 597786158 + .long 805306368 + .long 575535400 + .long 536870912 + .long 548814833 + .long 268435456 + .long 523239288 + .long 3758096384 + .long 495550718 + .long 2952790016 + .long 469954840 + .long 1073741824 + .long 442925723 + .long 1073741824 + .long 416247094 + .long 3758096384 + .long 392128403 + .long 2147483648 + .long 364254062 + .long 3221225472 + .long 339643518 + .long 2684354560 + .long 313162111 + .long 805306368 + .long 286354345 + .long 2952790016 + .long 260811902 + .long 1610612736 + .long 234667567 + .long 3758096384 + .long 207520668 + .long 1073741824 + .long 182175017 + .long 4026531840 + .long 155380331 + .long 805306368 + .long 129417058 + .long 536870912 + .long 103691636 + .long 0 + .long 73760972 + .long 3221225472 + .long 48348958 + .long 536870912 + .long 23784188 + .type _DP,@object + .size _DP,400 + .align 16 +_zero_none: + .long 0 + .long 0 + .long 0 + .long 3220176896 + .type _zero_none,@object + .size _zero_none,16 + .align 16 +_PI04_25x2: + .long 1073741824 + .long 1072243195 + .long 407279769 + .long 1046758445 + .type _PI04_25x2,@object + .size _PI04_25x2,16 + .align 16 +_TWO_26H: + .long 0 + .long 1100480512 + .type _TWO_26H,@object + .size _TWO_26H,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_scalbl_k80.S b/external/sgx_libm/intel64/libm_scalbl_k80.S new file mode 100644 index 0000000000..b06884bd1c --- /dev/null +++ b/external/sgx_libm/intel64/libm_scalbl_k80.S @@ -0,0 +1,247 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_scalbl_k80.c" + .text +..TXTST0: +# -- Begin __libm_scalbl_k80 + .text + .align 16,0x90 + .globl __libm_scalbl_k80 +__libm_scalbl_k80: +# parameter 1: 8 + %rsp +# parameter 2: 24 + %rsp +# parameter 3: %edi +..B1.1: + .cfi_startproc +..___tag_value___libm_scalbl_k80.1: +..L2: + + fldt 24(%rsp) + fldt 8(%rsp) + fld %st(0) + cmpq $0, 8(%rsp) + fadd %st(2), %st + jne ..B1.3 +..B1.2: + fstp %st(2) + fstp %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + ret +..B1.3: + movzwl 16(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.2 +..B1.4: + fstpt -24(%rsp) + fldt -24(%rsp) + movzwl -16(%rsp), %ecx + movl %ecx, %eax + andl $32767, %eax + lea -1(%rdi,%rax), %edx + cmpl $32765, %edx + lea (%rdi,%rax), %esi + ja ..B1.6 +..B1.5: + fstp %st(1) + fstp %st(1) + fstp %st(0) + andl $-32768, %ecx + andl $32767, %esi + orl %esi, %ecx + movw %cx, -16(%rsp) + fldt -24(%rsp) + ret +..B1.6: + cmpl $32766, %esi + jle ..B1.8 +..B1.7: + fstp %st(2) + fstp %st(1) + lea _CONSTANTS(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fmulp %st, %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + ret +..B1.8: + lea 16+_CONSTANTS(%rip), %rax + cmpl $-63, %esi + fldt (%rax) + jge ..B1.10 +..B1.9: + fstp %st(3) + fstp %st(0) + fxch %st(1) + fmul %st(0), %st + fmulp %st, %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + ret +..B1.10: + cmpl $-19, %esi + jge ..B1.12 +..B1.11: + fstp %st(2) + fstp %st(2) + fldt .L_2il0floatpacket.0(%rip) + movzwl 8+.L_2il0floatpacket.0(%rip), %eax + andl $-32768, %eax + fstpt -56(%rsp) + fmul %st(0), %st + faddp %st, %st(1) + fstpt -24(%rsp) + movzwl -16(%rsp), %edx + lea 256(%rdi,%rdx), %edi + andl $-32768, %edx + andl $32767, %edi + orl $-49409, %edx + orl %edi, %eax + movw %ax, -48(%rsp) + fldt -56(%rsp) + movw %dx, -16(%rsp) + fldt -24(%rsp) + fmulp %st, %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) + ret +..B1.12: + fstp %st(1) + fmul %st(0), %st + lea 32+_CONSTANTS(%rip), %rcx + movzwl 8+.L_2il0floatpacket.0(%rip), %r8d + faddp %st, %st(1) + fldt .L_2il0floatpacket.1(%rip) + andl $-32768, %r8d + fmul %st(1), %st + fld %st(0) + fsub %st(2), %st + fsubrp %st, %st(1) + fstpt -40(%rsp) + fldt -40(%rsp) + fsubrp %st, %st(1) + movzwl -32(%rsp), %esi + faddp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + lea -16383(%rsi), %eax + negl %eax + movl %esi, %edx + addl $16383, %eax + lea -32512(%rdi,%rsi), %edi + andl $32767, %eax + andl $-32768, %edx + fstpt -56(%rsp) + orl %eax, %r8d + fldt (%rcx) + andl $32767, %edi + fmulp %st, %st(1) + orl $-49409, %edx + movw %r8w, -48(%rsp) + andl $-32768, %r8d + fldt -56(%rsp) + orl %edi, %r8d + fmulp %st, %st(1) + movw %dx, -32(%rsp) + fldt -40(%rsp) + movw %r8w, -48(%rsp) + fldt -56(%rsp) + fmul %st, %st(1) + fxch %st(1) + fstpt -40(%rsp) + fldt -40(%rsp) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt -24(%rsp) + fldt -24(%rsp) +..B1.13: + ret + .align 16,0x90 + .cfi_endproc + .type __libm_scalbl_k80,@function + .size __libm_scalbl_k80,.-__libm_scalbl_k80 + .data +# -- End __libm_scalbl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 2 +_CONSTANTS: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16127 + .word 0 + .word 0 + .word 0 + .type _CONSTANTS,@object + .size _CONSTANTS,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_sincos_k32.S b/external/sgx_libm/intel64/libm_sincos_k32.S new file mode 100644 index 0000000000..2816a3e943 --- /dev/null +++ b/external/sgx_libm/intel64/libm_sincos_k32.S @@ -0,0 +1,366 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sincos_k32.c" + .text +..TXTST0: +# -- Begin __libm_sincos_k32 + .text + .align 16,0x90 + .globl __libm_sincos_k32 +__libm_sincos_k32: +# parameter 1: %xmm0 +# parameter 2: %rdi +# parameter 3: %rsi +# parameter 4: %edx +..B1.1: + .cfi_startproc +..___tag_value___libm_sincos_k32.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + pushq %rbp + .cfi_def_cfa_offset 32 + .cfi_offset 6, -32 + subq $16, %rsp + .cfi_def_cfa_offset 48 + lea iones(%rip), %rax + movsd %xmm0, 8(%rsp) + movl %edx, %ecx + movl 12(%rsp), %r12d + movl %r12d, %r10d + shrl $31, %r12d + andl $2147483647, %r10d + imull (%rax,%r12,4), %ecx + movq %rsi, %rbp + andps .L_2il0floatpacket.2(%rip), %xmm0 + movq %rdi, %rbx + cmpl $1103101952, %r10d + jae ..B1.9 +..B1.2: + cmpl $1073283072, %r10d + ja ..B1.6 +..B1.3: + incl %ecx + movl %ecx, %edx + andl $2, %edx + je ..B1.5 +..B1.4: + subsd .L_2il0floatpacket.0(%rip), %xmm0 + movsd %xmm0, 8(%rsp) + jmp ..B1.11 +..B1.5: + movsd %xmm0, 8(%rsp) + jmp ..B1.11 +..B1.6: + lea _INV_PI04(%rip), %rax + lea _TWO_52H(%rip), %rdx + pxor %xmm2, %xmm2 + pxor %xmm5, %xmm5 + movsd %xmm0, 8(%rsp) + movsd (%rax), %xmm3 + mulsd %xmm0, %xmm3 + movsd (%rdx), %xmm1 + addsd %xmm3, %xmm1 + movsd %xmm1, (%rsp) + movl (%rsp), %r9d + cvtsi2sd %r9d, %xmm2 + cmpltsd %xmm2, %xmm3 + movd %xmm3, %edi + negl %edi + subl %edi, %r9d + addl %r9d, %ecx + movl %ecx, %r8d + andl $1, %r8d + addl %r8d, %r9d + addl %r8d, %ecx + cvtsi2sd %r9d, %xmm5 + cmpl $1090519040, %r10d + jae ..B1.8 +..B1.7: + lea _DP2(%rip), %rax + lea 8+_DP2(%rip), %rdx + lea 16+_DP2(%rip), %rdi + movsd (%rax), %xmm1 + mulsd %xmm5, %xmm1 + movsd (%rdx), %xmm2 + movl %ecx, %edx + mulsd %xmm5, %xmm2 + subsd %xmm1, %xmm0 + movsd (%rdi), %xmm3 + andl $2, %edx + mulsd %xmm3, %xmm5 + subsd %xmm2, %xmm0 + subsd %xmm5, %xmm0 + movsd %xmm0, 8(%rsp) + jmp ..B1.11 +..B1.8: + lea _DP3(%rip), %rax + lea 8+_DP3(%rip), %rdx + movsd 8(%rsp), %xmm0 + lea 16+_DP3(%rip), %rdi + lea 24+_DP3(%rip), %r8 + movsd (%rax), %xmm1 + movsd (%rdx), %xmm2 + movl %ecx, %edx + mulsd %xmm5, %xmm1 + andl $2, %edx + mulsd %xmm5, %xmm2 + subsd %xmm1, %xmm0 + movsd (%rdi), %xmm3 + subsd %xmm2, %xmm0 + mulsd %xmm5, %xmm3 + movsd (%r8), %xmm4 + subsd %xmm3, %xmm0 + mulsd %xmm4, %xmm5 + subsd %xmm5, %xmm0 + movsd %xmm0, 8(%rsp) + jmp ..B1.11 +..B1.9: + movl %ecx, %esi + lea 8(%rsp), %rdi + movsd %xmm0, (%rdi) +..___tag_value___libm_sincos_k32.10: + call __libm_reduce_pi04d@PLT +..___tag_value___libm_sincos_k32.11: +..B1.17: + movl %eax, %ecx +..B1.10: + incl %ecx + movl %ecx, %edx + movsd 8(%rsp), %xmm0 + andl $2, %edx +..B1.11: + movaps %xmm0, %xmm2 + lea 24+_CP(%rip), %rsi + mulsd %xmm0, %xmm2 + lea 8+_CP(%rip), %rdi + movaps %xmm2, %xmm1 + lea 24+_SP(%rip), %r8 + mulsd %xmm2, %xmm1 + lea 32+_CP(%rip), %r10 + movsd (%rsi), %xmm6 + lea 32+_SP(%rip), %rsi + mulsd %xmm1, %xmm6 + lea 8+_SP(%rip), %r9 + movsd (%rsi), %xmm4 + lea 16+_CP(%rip), %r11 + mulsd %xmm1, %xmm4 + addsd (%rdi), %xmm6 + lea 16+_SP(%rip), %rdi + lea 2(%rcx), %eax + movsd (%r8), %xmm5 + lea _SP(%rip), %r8 + movsd (%r10), %xmm3 + mulsd %xmm1, %xmm5 + addsd (%rdi), %xmm4 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm6 + addsd (%r9), %xmm5 + mulsd %xmm1, %xmm4 + addsd (%r11), %xmm3 + addsd .L_2il0floatpacket.1(%rip), %xmm6 + mulsd %xmm1, %xmm5 + addsd (%r8), %xmm4 + mulsd %xmm1, %xmm3 + mulsd %xmm0, %xmm5 + mulsd %xmm2, %xmm4 + addsd %xmm0, %xmm5 + mulsd %xmm0, %xmm4 + shrl $2, %ecx + addsd %xmm4, %xmm5 + andl $1, %ecx + xorq %rcx, %r12 + lea _CP(%rip), %rcx + shrl $2, %eax + andl $1, %eax + testl %edx, %edx + addsd (%rcx), %xmm3 + lea ones(%rip), %rcx + mulsd %xmm2, %xmm3 + movsd (%rcx,%r12,8), %xmm0 + addsd %xmm3, %xmm6 + je ..B1.13 +..B1.12: + mulsd %xmm0, %xmm6 + movsd (%rcx,%rax,8), %xmm0 + mulsd %xmm0, %xmm5 + movsd %xmm6, (%rbx) + movsd %xmm5, (%rbp) + addq $16, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 12, -16 +..B1.13: + mulsd %xmm5, %xmm0 + movsd %xmm0, (%rbx) + movsd (%rcx,%rax,8), %xmm0 + mulsd %xmm0, %xmm6 + movsd %xmm6, (%rbp) +..B1.14: + addq $16, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __libm_sincos_k32,@function + .size __libm_sincos_k32,.-__libm_sincos_k32 + .data +# -- End __libm_sincos_k32 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.2: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x54442d18,0x3fe921fb + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_INV_PI04: + .long 1841940611 + .long 1072979760 + .type _INV_PI04,@object + .size _INV_PI04,8 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_DP2: + .long 1413742592 + .long 1072243195 + .long 1279262720 + .long 1031179299 + .long 1880851354 + .long 996723793 + .type _DP2,@object + .size _DP2,24 + .align 4 +_DP3: + .long 1073741824 + .long 1072243195 + .long 0 + .long 1046758445 + .long 2147483648 + .long 1021855384 + .long 1880851354 + .long 996723793 + .type _DP3,@object + .size _DP3,32 + .align 4 +_CP: + .long 4294960802 + .long 3219128319 + .long 1427442001 + .long 1067799893 + .long 2926645240 + .long 3210133867 + .long 2571283200 + .long 1056571689 + .long 2069816734 + .long 3197257552 + .type _CP,@object + .size _CP,40 + .align 4 +_SP: + .long 1431654765 + .long 3217380693 + .long 285032968 + .long 1065423121 + .long 3653044354 + .long 3207201183 + .long 2777006020 + .long 1053236634 + .long 43514947 + .long 3193610888 + .type _SP,@object + .size _SP,40 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_sincos_k64.S b/external/sgx_libm/intel64/libm_sincos_k64.S new file mode 100644 index 0000000000..c86f6c9625 --- /dev/null +++ b/external/sgx_libm/intel64/libm_sincos_k64.S @@ -0,0 +1,846 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sincos_k64.c" + .text +..TXTST0: +# -- Begin __libm_sincos_k64 + .text + .align 16,0x90 + .globl __libm_sincos_k64 +__libm_sincos_k64: +# parameter 1: %xmm0 +# parameter 2: %rdi +# parameter 3: %rsi +..B1.1: + .cfi_startproc +..___tag_value___libm_sincos_k64.1: +..L2: + + pushq %r15 + .cfi_def_cfa_offset 16 + .cfi_offset 15, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + subq $56, %rsp + .cfi_def_cfa_offset 80 + movq %rsi, %r15 + movsd %xmm0, (%rsp) + movq %rdi, %rbx + movzwl 6(%rsp), %edx + movq %fs:40, %rax + andl $32752, %edx + movsd (%rsp), %xmm0 + xorq %rsp, %rax + movq %rax, 48(%rsp) + movb 7(%rsp), %al + andb $127, %al + movsd %xmm0, 8(%rsp) + cmpl $32752, %edx + je ..B1.13 +..B1.2: + movb %al, 15(%rsp) + movzwl 14(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $771, %eax + jl ..B1.9 +..B1.3: + cmpl $1040, %eax + jge ..B1.5 +..B1.4: + lea 2176+sincos_table(%rip), %rax + movsd (%rax), %xmm1 + xorl %eax, %eax + movsd %xmm1, 40(%rsp) + jmp ..B1.7 +..B1.5: + lea 32(%rsp), %rdi +..___tag_value___libm_sincos_k64.8: + call __libm_reduce_pio2d@PLT +..___tag_value___libm_sincos_k64.9: +..B1.6: + movsd 32(%rsp), %xmm0 + movsd 40(%rsp), %xmm1 +..B1.7: + lea 2048+sincos_table(%rip), %rcx + lea 2056+sincos_table(%rip), %rsi + lea 2064+sincos_table(%rip), %r8 + lea 2072+sincos_table(%rip), %r9 + lea 2112+sincos_table(%rip), %r11 + lea 2080+sincos_table(%rip), %r10 + shll $4, %eax + movsd (%rcx), %xmm13 + lea 2104+sincos_table(%rip), %rcx + mulsd %xmm0, %xmm13 + movsd (%r8), %xmm11 + lea 2144+sincos_table(%rip), %r8 + movsd (%r9), %xmm12 + lea 2136+sincos_table(%rip), %r9 + movsd (%r11), %xmm15 + lea 2120+sincos_table(%rip), %r11 + addsd (%rsi), %xmm13 + movsd %xmm13, (%rsp) + movl (%rsp), %edi + subsd (%rsi), %xmm13 + lea 2096+sincos_table(%rip), %rsi + mulsd %xmm13, %xmm11 + lea (%rdi,%rax), %edx + mulsd %xmm13, %xmm12 + mulsd (%r10), %xmm13 + subsd %xmm11, %xmm0 + movaps %xmm0, %xmm10 + lea 2128+sincos_table(%rip), %r10 + movsd (%r8), %xmm11 + lea 16(%rdi,%rax), %eax + lea 2088+sincos_table(%rip), %rdi + andl $63, %edx + shll $2, %edx + andl $63, %eax + shll $2, %eax + subsd %xmm12, %xmm10 + movaps %xmm10, %xmm14 + subsd %xmm10, %xmm0 + mulsd %xmm10, %xmm14 + subsd %xmm12, %xmm0 + mulsd %xmm14, %xmm11 + mulsd %xmm14, %xmm15 + subsd %xmm13, %xmm0 + addsd (%r9), %xmm11 + addsd (%rcx), %xmm15 + addsd %xmm1, %xmm0 + mulsd %xmm14, %xmm11 + mulsd %xmm14, %xmm15 + addsd (%r10), %xmm11 + addsd (%rsi), %xmm15 + mulsd %xmm14, %xmm11 + mulsd %xmm14, %xmm15 + addsd (%r11), %xmm11 + addsd (%rdi), %xmm15 + mulsd %xmm14, %xmm11 + mulsd %xmm14, %xmm15 + lea sincos_table(%rip), %rcx + movaps %xmm10, %xmm12 + mulsd %xmm10, %xmm15 + movsd 8(%rcx,%rdx,8), %xmm2 + movaps %xmm2, %xmm1 + mulsd %xmm11, %xmm1 + mulsd %xmm2, %xmm12 + movsd (%rcx,%rdx,8), %xmm9 + movsd (%rcx,%rax,8), %xmm6 + movaps %xmm9, %xmm8 + movsd 24(%rcx,%rdx,8), %xmm4 + movaps %xmm6, %xmm3 + movsd 24(%rcx,%rax,8), %xmm5 + addsd %xmm4, %xmm8 + mulsd %xmm10, %xmm4 + addsd %xmm5, %xmm3 + mulsd %xmm10, %xmm5 + mulsd %xmm10, %xmm9 + mulsd %xmm10, %xmm6 + movsd %xmm1, 16(%rsp) + movaps %xmm4, %xmm13 + movsd 8(%rcx,%rax,8), %xmm1 + movaps %xmm5, %xmm14 + mulsd %xmm1, %xmm10 + addsd %xmm2, %xmm13 + addsd %xmm1, %xmm14 + mulsd %xmm1, %xmm11 + subsd %xmm13, %xmm2 + subsd %xmm14, %xmm1 + addsd %xmm4, %xmm2 + addsd %xmm5, %xmm1 + movaps %xmm8, %xmm7 + subsd %xmm12, %xmm8 + mulsd %xmm15, %xmm7 + mulsd %xmm3, %xmm15 + subsd %xmm10, %xmm3 + mulsd %xmm0, %xmm8 + mulsd %xmm3, %xmm0 + addsd 16(%rcx,%rdx,8), %xmm8 + addsd 16(%rcx,%rax,8), %xmm0 + addsd %xmm2, %xmm8 + addsd %xmm1, %xmm0 + movsd %xmm11, 24(%rsp) + movaps %xmm13, %xmm11 + movsd %xmm15, 8(%rsp) + movaps %xmm14, %xmm15 + addsd %xmm9, %xmm11 + addsd %xmm6, %xmm15 + subsd %xmm11, %xmm13 + subsd %xmm15, %xmm14 + addsd %xmm13, %xmm9 + addsd %xmm14, %xmm6 + addsd %xmm9, %xmm8 + addsd %xmm6, %xmm0 + addsd %xmm7, %xmm8 + addsd 8(%rsp), %xmm0 + addsd 16(%rsp), %xmm8 + addsd 24(%rsp), %xmm0 + movsd %xmm11, (%rbx) + movsd %xmm8, 8(%rbx) + movsd %xmm15, (%r15) + movsd %xmm0, 8(%r15) + movq 48(%rsp), %rbx + xorq %rsp, %rbx + cmpq %fs:40, %rbx + jne ..B1.11 +..B1.8: + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -24 + .cfi_offset 15, -16 +..B1.9: + xorl %eax, %eax + movsd %xmm0, (%rbx) + movq %rax, 8(%rbx) + movq $0x3ff0000000000000, %rbx + movq %rbx, (%r15) + movq %rax, 8(%r15) + movq 48(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + jne ..B1.11 +..B1.10: + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -24 + .cfi_offset 15, -16 +..B1.11: + call __stack_chk_fail@PLT +..B1.13: + lea 2176+sincos_table(%rip), %rax + xorl %edx, %edx + movq %rdx, 8(%rbx) + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + movsd %xmm0, (%rbx) + movsd %xmm0, (%r15) + movq %rdx, 8(%r15) + movq 48(%rsp), %rcx + xorq %rsp, %rcx + cmpq %fs:40, %rcx + jne ..B1.11 + jmp ..B1.8 + .align 16,0x90 + .cfi_endproc + .type __libm_sincos_k64,@function + .size __libm_sincos_k64,.-__libm_sincos_k64 + .data +# -- End __libm_sincos_k64 + .section .rodata, "a" + .align 16 + .align 16 +sincos_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 1072693248 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1071644672 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 1071644672 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1070596096 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 1070596096 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1069547520 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 3217031168 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 3218079744 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 3218079744 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 3219128320 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 3220176896 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3219128320 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 3219128320 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3218079744 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 3218079744 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3217031168 + .long 0 + .long 2147483648 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 1069547520 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 1070596096 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 1070596096 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 1071644672 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 1072693248 + .long 1841940611 + .long 1076125488 + .long 0 + .long 1127743488 + .long 1413480448 + .long 1069097467 + .long 442499072 + .long 1032893537 + .long 771977331 + .long 996350346 + .long 1431655765 + .long 3217380693 + .long 286331153 + .long 1065423121 + .long 436314138 + .long 3207201184 + .long 2773927732 + .long 1053236707 + .long 0 + .long 3219128320 + .long 1431655765 + .long 1067799893 + .long 381774871 + .long 3210133868 + .long 436314138 + .long 1056571808 + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 2146435072 + .type sincos_table,@object + .size sincos_table,2192 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_sinh_k64.S b/external/sgx_libm/intel64/libm_sinh_k64.S new file mode 100644 index 0000000000..a3e2e60c2d --- /dev/null +++ b/external/sgx_libm/intel64/libm_sinh_k64.S @@ -0,0 +1,394 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sinh_k64.c" + .text +..TXTST0: +# -- Begin __libm_sinh_k64 + .text + .align 16,0x90 + .globl __libm_sinh_k64 +__libm_sinh_k64: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_sinh_k64.1: +..L2: + + movaps %xmm0, %xmm3 + movsd %xmm3, -32(%rsp) + movzwl -26(%rsp), %eax + andl $32752, %eax + shrl $4, %eax + cmpl $1045, %eax + jge ..B1.11 +..B1.2: + movl -28(%rsp), %edx + movl %edx, %ecx + andl $2147483647, %ecx + cmpl $1066695393, %ecx + jae ..B1.7 +..B1.3: + cmpl $1012924416, %ecx + jae ..B1.5 +..B1.4: + movsd %xmm3, (%rdi) + movq $0, 8(%rdi) + jmp ..B1.6 +..B1.5: + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.3(%rip), %xmm4 + movsd .L_2il0floatpacket.5(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.4(%rip), %xmm4 + addsd .L_2il0floatpacket.6(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + movsd %xmm1, -40(%rsp) + addsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + movsd %xmm3, (%rdi) + movsd %xmm4, 8(%rdi) +..B1.6: + xorl %eax, %eax + ret +..B1.7: + movsd -32(%rsp), %xmm2 + lea _TWO_52(%rip), %rax + andps .L_2il0floatpacket.13(%rip), %xmm2 + movsd .L_2il0floatpacket.0(%rip), %xmm4 + mulsd %xmm2, %xmm4 + movsd (%rax), %xmm0 + movsd .L_2il0floatpacket.1(%rip), %xmm1 + addsd %xmm0, %xmm4 + movsd %xmm4, -40(%rsp) + subsd %xmm0, %xmm4 + mulsd %xmm4, %xmm1 + movsd %xmm2, -32(%rsp) + subsd %xmm1, %xmm2 + movsd .L_2il0floatpacket.2(%rip), %xmm3 + movaps %xmm2, %xmm6 + mulsd %xmm3, %xmm4 + movl -40(%rsp), %eax + movl %eax, %r10d + shll $25, %r10d + subsd %xmm4, %xmm6 + sarl $25, %r10d + subsd %xmm6, %xmm2 + subl %r10d, %eax + subsd %xmm4, %xmm2 + movsd .L_2il0floatpacket.15(%rip), %xmm1 + movaps %xmm2, %xmm0 + sarl $7, %eax + addsd %xmm6, %xmm0 + addsd %xmm6, %xmm1 + cmpl $1077338037, %ecx + jae ..B1.9 +..B1.8: + movaps %xmm0, %xmm7 + xorl %ecx, %ecx + mulsd %xmm0, %xmm7 + movaps %xmm6, %xmm9 + movsd .L_2il0floatpacket.8(%rip), %xmm8 + movl %eax, %esi + mulsd %xmm7, %xmm8 + negl %esi + movsd .L_2il0floatpacket.15(%rip), %xmm3 + addl $1023, %esi + movsd %xmm1, -32(%rsp) + subl %eax, %esi + movl %ecx, -32(%rsp) + andl $2047, %esi + movsd -32(%rsp), %xmm10 + decl %eax + movsd .L_2il0floatpacket.7(%rip), %xmm4 + subsd %xmm6, %xmm3 + addsd .L_2il0floatpacket.9(%rip), %xmm8 + addsd %xmm10, %xmm4 + mulsd %xmm7, %xmm8 + subsd %xmm4, %xmm9 + mulsd %xmm0, %xmm8 + addsd %xmm2, %xmm9 + movsd .L_2il0floatpacket.10(%rip), %xmm0 + addsd %xmm8, %xmm9 + mulsd %xmm7, %xmm0 + movsd %xmm3, -24(%rsp) + lea ones(%rip), %r11 + movl %ecx, -24(%rsp) + movsd -24(%rsp), %xmm1 + movsd .L_2il0floatpacket.7(%rip), %xmm5 + movslq %r10d, %r10 + addsd .L_2il0floatpacket.11(%rip), %xmm0 + addsd %xmm1, %xmm5 + mulsd %xmm7, %xmm0 + addsd %xmm5, %xmm6 + addsd .L_2il0floatpacket.12(%rip), %xmm0 + addsd %xmm6, %xmm2 + mulsd %xmm7, %xmm0 + xorps .L_2il0floatpacket.14(%rip), %xmm2 + addsd %xmm0, %xmm9 + subsd %xmm8, %xmm2 + shlq $4, %r10 + addsd %xmm0, %xmm2 + movaps %xmm9, %xmm0 + movaps %xmm2, %xmm12 + movq __libm_exp_table_128@GOTPCREL(%rip), %r9 + addsd %xmm10, %xmm9 + addsd %xmm1, %xmm2 + mulsd 1024(%r10,%r9), %xmm9 + movsd 1032(%r10,%r9), %xmm13 + negq %r10 + movzwl 6+.L_2il0floatpacket.15(%rip), %r8d + movsd .L_2il0floatpacket.15(%rip), %xmm6 + andl $-32753, %r8d + shll $4, %esi + movsd 1032(%r9,%r10), %xmm11 + orl %esi, %r8d + mulsd 1024(%r9,%r10), %xmm2 + mulsd %xmm11, %xmm12 + mulsd %xmm11, %xmm1 + mulsd %xmm13, %xmm0 + addsd %xmm2, %xmm12 + mulsd %xmm10, %xmm13 + addsd %xmm9, %xmm0 + movsd %xmm6, -16(%rsp) + movaps %xmm13, %xmm14 + movw %r8w, -10(%rsp) + movsd -16(%rsp), %xmm2 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm12 + subsd %xmm1, %xmm14 + subsd %xmm12, %xmm0 + subsd %xmm14, %xmm13 + shrl $31, %edx + subsd %xmm1, %xmm13 + movsd (%r11,%rdx,8), %xmm15 + addsd %xmm13, %xmm0 + movsd %xmm14, -40(%rsp) + mulsd %xmm15, %xmm14 + mulsd %xmm15, %xmm0 + movsd %xmm1, -24(%rsp) + movsd %xmm13, -32(%rsp) + movsd %xmm14, (%rdi) + movsd %xmm0, 8(%rdi) + ret +..B1.9: + movsd %xmm1, -40(%rsp) + movaps %xmm0, %xmm4 + movl $0, -40(%rsp) + decl %eax + movsd -40(%rsp), %xmm7 + lea ones(%rip), %rsi + movsd .L_2il0floatpacket.7(%rip), %xmm1 + movsd .L_2il0floatpacket.10(%rip), %xmm5 + addsd %xmm7, %xmm1 + mulsd %xmm0, %xmm4 + subsd %xmm1, %xmm6 + mulsd %xmm4, %xmm5 + addsd %xmm6, %xmm2 + addsd .L_2il0floatpacket.11(%rip), %xmm5 + movsd .L_2il0floatpacket.8(%rip), %xmm6 + mulsd %xmm4, %xmm6 + mulsd %xmm4, %xmm5 + addsd .L_2il0floatpacket.9(%rip), %xmm6 + mulsd %xmm6, %xmm0 + movsd .L_2il0floatpacket.12(%rip), %xmm3 + addsd %xmm0, %xmm5 + mulsd %xmm4, %xmm5 + mulsd %xmm3, %xmm4 + movslq %r10d, %r10 + addsd %xmm4, %xmm5 + shlq $4, %r10 + addsd %xmm5, %xmm2 + movaps %xmm2, %xmm8 + addsd %xmm7, %xmm2 + movq __libm_exp_table_128@GOTPCREL(%rip), %rcx + shrl $31, %edx + movsd 1032(%r10,%rcx), %xmm0 + mulsd 1024(%r10,%rcx), %xmm2 + mulsd %xmm0, %xmm8 + mulsd %xmm0, %xmm7 + addsd %xmm2, %xmm8 + movsd (%rsi,%rdx,8), %xmm2 + movsd %xmm7, -40(%rsp) + mulsd %xmm2, %xmm7 + mulsd %xmm8, %xmm2 + movsd %xmm7, (%rdi) + movsd %xmm2, 8(%rdi) +..B1.10: + ret +..B1.11: + movb -25(%rsp), %dl + andb $-128, %dl + shrb $7, %dl + cmpl $2047, %eax + je ..B1.14 +..B1.12: + movzbl %dl, %edx + lea infs(%rip), %rax + pxor %xmm0, %xmm0 + movq $0, 8(%rdi) + movl (%rax,%rdx,4), %ecx + cvtsi2sdq %rcx, %xmm0 + movsd %xmm0, (%rdi) +..B1.13: + xorl %eax, %eax + ret +..B1.14: + movq -32(%rsp), %rax + movq %rax, (%rdi) + movq $0, 8(%rdi) + jmp ..B1.13 + .align 16,0x90 + .cfi_endproc + .type __libm_sinh_k64,@function + .size __libm_sinh_k64,.-__libm_sinh_k64 + .data +# -- End __libm_sinh_k64 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.13: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,16 + .align 16 +.L_2il0floatpacket.14: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0xb9ff12f0,0x3ec71e39 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x111111c1,0x3f811111 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x1940cd88,0x3f2a01a0 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x55555555,0x3fc55555 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.15: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_52: + .long 0 + .long 1127219200 + .type _TWO_52,@object + .size _TWO_52,8 + .align 4 +infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type infs,@object + .size infs,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_sinhl_k80.S b/external/sgx_libm/intel64/libm_sinhl_k80.S new file mode 100644 index 0000000000..f307983252 --- /dev/null +++ b/external/sgx_libm/intel64/libm_sinhl_k80.S @@ -0,0 +1,745 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sinhl_k80.c" + .text +..TXTST0: +# -- Begin __libm_sinhl_k80 + .text + .align 16,0x90 + .globl __libm_sinhl_k80 +__libm_sinhl_k80: +# parameter 1: 8 + %rsp +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_sinhl_k80.1: +..L2: + + movzwl 16(%rsp), %eax + andl $32767, %eax + cmpl $16405, %eax + jge ..B1.20 +..B1.2: + cmpl $16382, %eax + jge ..B1.13 +..B1.3: + fldt 8(%rsp) + cmpl $16378, %eax + jge ..B1.11 +..B1.4: + cmpl $16373, %eax + jge ..B1.10 +..B1.5: + cmpl $16366, %eax + jge ..B1.9 +..B1.6: + fstpt (%rdi) + fldt (%rdi) + cmpl $16308, %eax + jge ..B1.8 +..B1.7: + fstp %st(0) + fldt .L_2il0floatpacket.0(%rip) + fstpt 16(%rdi) + fldt 16(%rdi) + ret +..B1.8: + lea _Q3(%rip), %rax + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) + ret +..B1.9: + fld %st(0) + lea 16+_Q2(%rip), %rax + lea _Q2(%rip), %rdx + fmul %st(1), %st + fxch %st(1) + fstpt (%rdi) + fldt (%rdi) + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) + ret +..B1.10: + fld %st(0) + lea 48+_Q1(%rip), %rax + lea 32+_Q1(%rip), %rcx + lea 16+_Q1(%rip), %rdx + lea _Q1(%rip), %rsi + fmul %st(1), %st + fld %st(0) + fmul %st(1), %st + fxch %st(2) + fstpt (%rdi) + fldt (%rdi) + fldt (%rax) + fmul %st(3), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + fmulp %st, %st(4) + fldt (%rsi) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) + ret +..B1.11: + lea _TWO_48H(%rip), %rax + fld %st(0) + fmul %st(1), %st + lea 112+_Q(%rip), %rdx + fld %st(0) + lea 80+_Q(%rip), %rcx + lea 48+_Q(%rip), %rsi + lea 96+_Q(%rip), %r9 + lea 16+_Q(%rip), %r8 + lea 64+_Q(%rip), %r10 + lea 32+_Q(%rip), %r11 + fmul %st(1), %st + fld %st(2) + fxch %st(3) + fstpt -88(%rsp) + fldt -88(%rsp) + fldl (%rax) + lea _Q(%rip), %rax + fadd %st, %st(4) + fxch %st(4) + fstpt -24(%rsp) + fldt -24(%rsp) + fsubp %st, %st(4) + fld %st(3) + fld %st(1) + fsub %st(5), %st + fmul %st, %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fxch %st(4) + fstpt -72(%rsp) + fldt -72(%rsp) + fmul %st(0), %st + fldt (%rdx) + lea 128+_Q(%rip), %rdx + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r9) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt (%rax) + faddp %st, %st(4) + fxch %st(4) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(0) + fldt (%rdx) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + fxch %st(4) + fmulp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fldt -88(%rsp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldt -72(%rsp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt (%rdi) + fldt (%rdi) + fsubrp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 16(%rdi) + fldt .L_2il0floatpacket.0(%rip) +..B1.12: + ret +..B1.13: + fldt 8(%rsp) + lea ones(%rip), %rax + movb 17(%rsp), %dl + lea _KLN2(%rip), %r8 + andb $-128, %dl + lea _TWO_63H(%rip), %rsi + shrb $7, %dl + lea _LN2K(%rip), %r9 + fldt (%r8) + fldl (%rsi) + fldt (%r9) + movzbl %dl, %ecx + lea 16+_LN2K(%rip), %r10 + lea _TWO_32P(%rip), %r11 + lea 64+_P(%rip), %rsi + lea 32+_P(%rip), %r8 + lea _P(%rip), %r9 + fldl (%rax,%rcx,8) + lea _TWO_32(%rip), %rcx + fmul %st, %st(4) + fxch %st(3) + fmul %st(4), %st + fadd %st(2), %st + fstpt -24(%rsp) + fxch %st(3) + fstpt 8(%rsp) + fldt 8(%rsp) + fldt -24(%rsp) + movl -24(%rsp), %edx + fsubp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + movsbq %dl, %rax + fxch %st(3) + fsubrp %st, %st(1) + fld %st(0) + subl %eax, %edx + fldt (%r10) + lea 48+_P(%rip), %r10 + fmulp %st, %st(4) + sarl $8, %edx + fsub %st(3), %st + fldl (%r11) + lea 16+_P(%rip), %r11 + fmul %st(1), %st + fldl (%rcx) + fmulp %st, %st(2) + movzwl 16(%rsp), %ecx + fsubp %st, %st(1) + fld %st(0) + andl $32767, %ecx + cmpl $16387, %ecx + fxch %st(1) + fsubr %st, %st(2) + fxch %st(4) + fsubrp %st, %st(2) + fadd %st(1), %st + fld %st(0) + fmul %st(1), %st + fldt (%rsi) + fmul %st(1), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + jg ..B1.19 +..B1.14: + jne ..B1.18 +..B1.15: + movl 12(%rsp), %ecx + cmpl $-782985146, %ecx + ja ..B1.19 +..B1.16: + jne ..B1.18 +..B1.17: + cmpl $1501741449, 8(%rsp) + ja ..B1.19 +..B1.18: + fldt .L_2il0floatpacket.1(%rip) + movl %edx, %esi + negl %esi + lea -1(%rdx), %ecx + addl $16383, %esi + shlq $4, %rax + subl %edx, %esi + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + andl $32767, %esi + fstpt -40(%rsp) + fld %st(0) + movzwl 8+.L_2il0floatpacket.1(%rip), %r8d + fadd %st(2), %st + fxch %st(2) + fsubrp %st, %st(1) + fxch %st(2) + fstpt -88(%rsp) + fld %st(2) + fldl 2056(%rdx,%rax) + andl $-32768, %r8d + fldl 2048(%rdx,%rax) + negq %rax + fstpt -72(%rsp) + fldt -72(%rsp) + orl %esi, %r8d + movw %r8w, -32(%rsp) + fadd %st(1), %st + fmulp %st, %st(3) + fld %st(4) + fmul %st(1), %st + movl %ecx, -8(%rsp) + faddp %st, %st(3) + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + fld %st(0) + fadd %st(2), %st + fmulp %st, %st(6) + fld %st(6) + fmul %st(2), %st + fsubrp %st, %st(6) + fxch %st(5) + fstpt -56(%rsp) + fxch %st(4) + fmul %st, %st(5) + fldt -72(%rsp) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fsub %st(5), %st + fsubr %st, %st(3) + fxch %st(5) + fsubrp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(0) + fldt -56(%rsp) + faddp %st, %st(4) + fldt -40(%rsp) + fmul %st, %st(5) + fxch %st(1) + fsub %st(5), %st + fsubr %st, %st(2) + fxch %st(5) + fsubrp %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(1) + fldt -88(%rsp) + fmul %st, %st(2) + fxch %st(2) + fstpt (%rdi) + fmulp %st, %st(1) + fstpt 16(%rdi) + fildl -8(%rsp) + ret +..B1.19: + shlq $4, %rax + decl %edx + movl %edx, -8(%rsp) + faddp %st, %st(1) + fildl -8(%rsp) + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(6), %st + fmul %st(2), %st + faddp %st, %st(4) + fmul %st, %st(5) + fld %st(0) + fadd %st(6), %st + fsubr %st, %st(1) + fxch %st(6) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + fstpt (%rdi) + fmulp %st, %st(2) + fxch %st(1) + fstpt 16(%rdi) + ret +..B1.20: + movb 17(%rsp), %dl + andb $-128, %dl + shrb $7, %dl + cmpl $32767, %eax + je ..B1.23 +..B1.21: + fldt .L_2il0floatpacket.0(%rip) + movzbl %dl, %eax + lea _infs(%rip), %rdx + shlq $4, %rax + fstpt 16(%rdi) + fldt (%rdx,%rax) + fstpt (%rdi) + fldt (%rdx) +..B1.22: + ret +..B1.23: + fldt 8(%rsp) + fstpt (%rdi) + fldt (%rdi) + fmul %st(0), %st + fldt .L_2il0floatpacket.0(%rip) + fstpt 16(%rdi) + ret + .align 16,0x90 + .cfi_endproc + .type __libm_sinhl_k80,@function + .size __libm_sinhl_k80,.-__libm_sinhl_k80 + .data +# -- End __libm_sinhl_k80 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 2 +_Q3: + .word 21845 + .word 44373 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 29491 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 1838 + .word 3745 + .word 35050 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 56472 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 6470 + .word 8609 + .word 207 + .word 53261 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 51515 + .word 9159 + .word 10794 + .word 47344 + .word 16364 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 43620 + .word 43690 + .word 43690 + .word 43690 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 52382 + .word 3328 + .word 208 + .word 53261 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 44665 + .word 46658 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 15678 + .word 35942 + .word 11071 + .word 55090 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 10412 + .word 23121 + .word 12507 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 37213 + .word 41879 + .word 65084 + .word 55102 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 1721 + .word 42148 + .word 19309 + .word 52099 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,144 + .align 2 +_KLN2: + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 16391 + .word 0 + .word 0 + .word 0 + .type _KLN2,@object + .size _KLN2,16 + .align 2 +_LN2K: + .word 0 + .word 0 + .word 6134 + .word 45426 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 55756 + .word 58609 + .word 48341 + .word 59623 + .word 16343 + .word 0 + .word 0 + .word 0 + .type _LN2K,@object + .size _LN2K,32 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_infs: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32767 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 65535 + .word 0 + .word 0 + .word 0 + .type _infs,@object + .size _infs,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_sinl_k80.S b/external/sgx_libm/intel64/libm_sinl_k80.S new file mode 100644 index 0000000000..23cbd838a2 --- /dev/null +++ b/external/sgx_libm/intel64/libm_sinl_k80.S @@ -0,0 +1,830 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sinl_k80.c" + .text +..TXTST0: +# -- Begin __libm_sinl_k80 + .text + .align 16,0x90 + .globl __libm_sinl_k80 +__libm_sinl_k80: +# parameter 1: 160 + %rsp +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_sinl_k80.1: +..L2: + + pushq %r15 + .cfi_def_cfa_offset 16 + .cfi_offset 15, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + pushq %rbp + .cfi_def_cfa_offset 32 + .cfi_offset 6, -32 + subq $128, %rsp + .cfi_def_cfa_offset 160 + movq %rdi, %r15 + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 120(%rsp) + movzwl 168(%rsp), %eax + andl $32767, %eax + cmpl $16378, %eax + jge ..B1.13 +..B1.2: + fldt 160(%rsp) + cmpl $16372, %eax + jge ..B1.11 +..B1.3: + cmpl $16364, %eax + jge ..B1.9 +..B1.4: + fstpt (%r15) + fldt (%r15) + cmpl $16308, %eax + jge ..B1.6 +..B1.5: + fstp %st(0) + lea _zeros(%rip), %rax + lea _ones(%rip), %rdx + fldl (%rax) + fstpt 16(%r15) + fldl (%rdx) + jmp ..B1.7 +..B1.6: + lea _SP3(%rip), %rax + lea _ones(%rip), %rdx + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmulp %st, %st(1) + fstpt 16(%r15) + fldl (%rdx) +..B1.7: + movq 120(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.23 +..B1.8: + addq $128, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 15, -16 +..B1.9: + fld %st(0) + lea 16+_SP2(%rip), %rax + fmul %st(1), %st + lea _SP2(%rip), %rdx + lea _ones(%rip), %rcx + fxch %st(1) + fstpt (%r15) + fldt (%r15) + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + movsd (%rcx), %xmm0 + faddp %st, %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + fstpt 16(%r15) + movq 120(%rsp), %rbx + xorq %rsp, %rbx + cmpq %fs:40, %rbx + jne ..B1.24 +..B1.10: + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + addq $128, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 15, -16 +..B1.11: + fld %st(0) + lea 48+_SP1(%rip), %rax + fmul %st(1), %st + lea 32+_SP1(%rip), %rcx + fld %st(0) + lea 16+_SP1(%rip), %rdx + fmul %st(1), %st + lea _SP1(%rip), %rbx + lea _ones(%rip), %rbp + fxch %st(2) + fstpt (%r15) + fldt (%r15) + fldt (%rax) + fmul %st(3), %st + fldt (%rdx) + movsd (%rbp), %xmm0 + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + fmulp %st, %st(4) + fldt (%rbx) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%r15) + movq 120(%rsp), %rsi + xorq %rsp, %rsi + cmpq %fs:40, %rsi + jne ..B1.24 +..B1.12: + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + addq $128, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 15, -16 +..B1.13: + cmpl $16382, %eax + jge ..B1.15 +..B1.14: + fldt 160(%rsp) + xorl %ecx, %ecx + movb 169(%rsp), %bl + lea _ones(%rip), %rbp + andb $-128, %bl + lea _TWO_52H(%rip), %rax + shrb $7, %bl + fldl (%rax) + movzbl %bl, %ebx + fxch %st(1) + fmull (%rbp,%rbx,8) + fmul %st, %st(1) + fld %st(1) + fadd %st(1), %st + fstpt (%rsp) + fstpt 24(%rsp) + fldt 24(%rsp) + fstpt 160(%rsp) + fldt 160(%rsp) + fldt (%rsp) + fsubp %st, %st(2) + fld %st(1) + fsubrp %st, %st(1) + fxch %st(1) + jmp ..B1.18 +..B1.15: + je ..B1.27 +..B1.16: + fldt 160(%rsp) + lea _ones(%rip), %rbp + movb 169(%rsp), %al + xorl %edi, %edi + andb $-128, %al + shrb $7, %al + movzbl %al, %ebx + fmull (%rbp,%rbx,8) + fstpt 160(%rsp) + fldt 160(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 176 + lea 120(%rsp), %rsi + fstpt (%rsp) +..___tag_value___libm_sinl_k80.44: + call __libm_reduce_pi04l@PLT +..___tag_value___libm_sinl_k80.45: +..B1.32: + movl %eax, %ecx + addq $16, %rsp + .cfi_def_cfa_offset 160 +..B1.17: + fldl 104(%rsp) + lea 1(%rcx), %eax + lea _TWO_52H(%rip), %rdx + fld %st(0) + movsd 104(%rsp), %xmm0 + sarl $2, %eax + movslq %eax, %rax + mulsd (%rdx), %xmm0 + xorq %rax, %rbx + movsd %xmm0, 16(%rsp) + andq $1, %rbx + fldl 16(%rsp) + fadd %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fldl 112(%rsp) + faddp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fstpt 24(%rsp) +..B1.18: + fldt 24(%rsp) + fld %st(1) + fmul %st(3), %st + fld %st(3) + fmulp %st, %st(2) + lea _TWO_53H(%rip), %rax + incl %ecx + testb $2, %cl + faddp %st, %st(1) + fstpt 40(%rsp) + fldt 40(%rsp) + fld %st(1) + fmul %st(2), %st + fld %st(0) + fadd %st(2), %st + fstpt 72(%rsp) + fldt 72(%rsp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 56(%rsp) + fldt 56(%rsp) + fxch %st(1) + fstpt 88(%rsp) + fldt 88(%rsp) + fmul %st(0), %st + fld %st(0) + faddp %st, %st(2) + fldl (%rax) + je ..B1.20 +..B1.19: + fstp %st(4) + fstp %st(2) + lea 112+_CP(%rip), %rax + lea 80+_CP(%rip), %rdx + lea 128+_CP(%rip), %rdi + lea 96+_CP(%rip), %r8 + lea 48+_CP(%rip), %rcx + lea 64+_CP(%rip), %r9 + lea 16+_CP(%rip), %rsi + lea 32+_CP(%rip), %r10 + fldt (%rax) + lea _CP(%rip), %r11 + lea 160+_CP(%rip), %rax + fmul %st(1), %st + fldt (%rdx) + lea 144+_CP(%rip), %rdx + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r11) + faddp %st, %st(2) + fldt 72(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 56(%rsp) + fldt 40(%rsp) + fldt 88(%rsp) + fldt (%rax) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(4) + fldt (%rdx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fld %st(3) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fadd %st(1), %st + fmul %st, %st(3) + fadd %st(3), %st + fstpt (%rsp) + fldt (%rsp) + fsubp %st, %st(3) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(1) + fld %st(1) + fldl (%rbp) + fld %st(0) + fxch %st(1) + fadd %st, %st(2) + fxch %st(1) + fsub %st(2), %st + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fldl (%rbp,%rbx,8) + fmul %st, %st(1) + fxch %st(1) + fstpt (%r15) + fmulp %st, %st(2) + fxch %st(1) + fstpt 16(%r15) + jmp ..B1.21 +..B1.20: + lea 112+_SP(%rip), %rax + lea 80+_SP(%rip), %rdx + lea 48+_SP(%rip), %rcx + lea 128+_SP(%rip), %rdi + lea 16+_SP(%rip), %rsi + lea 96+_SP(%rip), %r8 + lea 64+_SP(%rip), %r9 + lea 32+_SP(%rip), %r10 + fldt (%rax) + lea _SP(%rip), %r11 + lea 160+_SP(%rip), %rax + fmul %st(3), %st + fldt (%rdx) + lea 144+_SP(%rip), %rdx + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + fmul %st(4), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt (%r11) + faddp %st, %st(4) + fldt 72(%rsp) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt 56(%rsp) + fldt 40(%rsp) + fldt (%rax) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(3) + fldt (%rdx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fldt 88(%rsp) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fmul %st, %st(1) + fadd %st(1), %st + fstpt (%rsp) + fldt (%rsp) + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(3) + fmul %st(1), %st + fxch %st(1) + fmul %st(3), %st + fldt 24(%rsp) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldl (%rbp,%rbx,8) + fmul %st, %st(1) + fxch %st(1) + fstpt (%r15) + fmulp %st, %st(1) + fstpt 16(%r15) + fldl (%rbp) +..B1.21: + movq 120(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.23 +..B1.22: + addq $128, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 15, -16 +..B1.23: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.24: + call __stack_chk_fail@PLT +..B1.27: + movl 164(%rsp), %eax + cmpl $-921707870, %eax + jb ..B1.14 +..B1.28: + jne ..B1.16 +..B1.29: + cmpl $560513589, 160(%rsp) + jbe ..B1.14 + jmp ..B1.16 + .align 16,0x90 + .cfi_endproc + .type __libm_sinl_k80,@function + .size __libm_sinl_k80,.-__libm_sinl_k80 + .data +# -- End __libm_sinl_k80 + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 2 +_SP3: + .word 17476 + .word 43656 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _SP3,@object + .size _SP3,16 + .align 2 +_SP2: + .word 43210 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 1587 + .word 57422 + .word 34932 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP2,@object + .size _SP2,32 + .align 2 +_SP1: + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 12518 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 43088 + .word 7396 + .word 207 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 55827 + .word 48618 + .word 3602 + .word 47342 + .word 16364 + .word 0 + .word 0 + .word 0 + .type _SP1,@object + .size _SP1,64 + .align 2 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 0 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 0 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP,@object + .size _CP,176 + .align 2 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP,@object + .size _SP,176 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_sse2_sincos.S b/external/sgx_libm/intel64/libm_sse2_sincos.S new file mode 100644 index 0000000000..19101b10f4 --- /dev/null +++ b/external/sgx_libm/intel64/libm_sse2_sincos.S @@ -0,0 +1,1406 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_sse2_sincos.c" + .text +..TXTST0: +# -- Begin __libm_sse2_sincos + .text + .align 16,0x90 + .globl __libm_sse2_sincos +__libm_sse2_sincos: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___libm_sse2_sincos.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movq %fs:40, %rax + xorq %rsp, %rax + movsd %xmm0, (%rsp) + movq %rax, 40(%rsp) +..B1.2: + pextrw $3, %xmm0, %eax + andw $32767, %ax + subw $12336, %ax + cmpw $4293, %ax + ja .L_2TAG_PACKET_0.0.1 + unpcklpd %xmm0, %xmm0 + movapd PI32INV(%rip), %xmm1 + mulpd %xmm0, %xmm1 + movapd SHIFTER(%rip), %xmm2 + cvtsd2si %xmm1, %edx + addpd %xmm2, %xmm1 + movapd P_1(%rip), %xmm3 + subpd %xmm2, %xmm1 + movapd P_2(%rip), %xmm2 + mulpd %xmm1, %xmm3 + addq $1865216, %rdx + movapd %xmm0, %xmm4 + andq $63, %rdx + movapd SC_4(%rip), %xmm5 + lea Ctable(%rip), %rax + shlq $6, %rdx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subpd %xmm3, %xmm0 + mulpd P_3(%rip), %xmm1 + subpd %xmm3, %xmm4 + movapd 16(%rax), %xmm7 + movapd %xmm4, %xmm3 + subpd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + movapd SC_2(%rip), %xmm6 + mulpd %xmm4, %xmm7 + subpd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subpd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subpd %xmm3, %xmm1 + movapd 48(%rax), %xmm3 + addpd %xmm3, %xmm2 + subpd %xmm2, %xmm7 + mulpd %xmm7, %xmm1 + movapd 16(%rax), %xmm7 + mulpd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulpd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm7 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulpd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, %xmm0 + addpd 16(%rax), %xmm3 + addpd %xmm5, %xmm6 + movq %xmm6, %xmm5 + unpckhpd %xmm6, %xmm6 + unpcklpd %xmm5, %xmm5 + mulpd %xmm7, %xmm6 + mulpd %xmm5, %xmm2 + movapd %xmm4, %xmm7 + addpd %xmm3, %xmm4 + movapd 16(%rax), %xmm5 + subpd %xmm3, %xmm5 + subpd %xmm4, %xmm3 + addpd 32(%rax), %xmm1 + addpd %xmm0, %xmm5 + addpd %xmm7, %xmm3 + addpd %xmm5, %xmm1 + addpd %xmm3, %xmm1 + addpd %xmm2, %xmm1 + addpd %xmm6, %xmm1 + addpd %xmm4, %xmm1 + movq %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + jmp ..B1.7 +.L_2TAG_PACKET_0.0.1: + jg .L_2TAG_PACKET_1.0.1 + movq %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orw $32768, %ax + pinsrw $3, %eax, %xmm1 + addsd ONE(%rip), %xmm1 + cmpw $32784, %ax + jge .L_2TAG_PACKET_2.0.1 + mulsd ALL_ONES(%rip), %xmm0 + jmp ..B1.7 +.L_2TAG_PACKET_2.0.1: + movq TWO_POW_55(%rip), %xmm3 + mulsd %xmm0, %xmm3 + subsd %xmm3, %xmm0 + mulsd TWO_POW_M55(%rip), %xmm0 + jmp ..B1.7 +.L_2TAG_PACKET_1.0.1: + pextrw $3, %xmm0, %eax + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_3.0.1 +..B1.3: + movsd (%rsp), %xmm0 + lea 24(%rsp), %rdi +..___tag_value___libm_sse2_sincos.4: + call __libm_reduce_pio2d@PLT +..___tag_value___libm_sse2_sincos.5: +..B1.4: + movl %eax, 16(%rsp) +..B1.5: + movq 24(%rsp), %xmm0 + movq 32(%rsp), %xmm6 + unpcklpd %xmm0, %xmm0 + unpcklpd %xmm6, %xmm6 + movapd PI32INV(%rip), %xmm1 + mulpd %xmm0, %xmm1 + movapd SHIFTER(%rip), %xmm2 + cvtsd2si %xmm1, %edx + addpd %xmm2, %xmm1 + movapd P_1(%rip), %xmm3 + subpd %xmm2, %xmm1 + movapd P_2(%rip), %xmm2 + mulpd %xmm1, %xmm3 + movl 16(%rsp), %eax + shlq $4, %rax + addq $1865216, %rdx + movapd %xmm0, %xmm4 + addq %rax, %rdx + andq $63, %rdx + movapd SC_4(%rip), %xmm5 + lea Ctable(%rip), %rax + shlq $6, %rdx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subpd %xmm3, %xmm0 + mulpd P_3(%rip), %xmm1 + subpd %xmm3, %xmm4 + movapd 16(%rax), %xmm7 + movapd %xmm4, %xmm3 + subpd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + mulpd %xmm4, %xmm7 + subpd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subpd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subpd %xmm3, %xmm1 + movapd 48(%rax), %xmm3 + addpd %xmm3, %xmm2 + subpd %xmm2, %xmm7 + subpd %xmm6, %xmm1 + movapd SC_2(%rip), %xmm6 + mulpd %xmm7, %xmm1 + movapd 16(%rax), %xmm7 + mulpd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulpd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm7 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulpd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, %xmm0 + addpd 16(%rax), %xmm3 + addpd %xmm5, %xmm6 + movq %xmm6, %xmm5 + unpckhpd %xmm6, %xmm6 + unpcklpd %xmm5, %xmm5 + mulpd %xmm7, %xmm6 + mulpd %xmm5, %xmm2 + movapd %xmm4, %xmm7 + addpd %xmm3, %xmm4 + movapd 16(%rax), %xmm5 + subpd %xmm3, %xmm5 + subpd %xmm4, %xmm3 + addpd 32(%rax), %xmm1 + addpd %xmm0, %xmm5 + addpd %xmm7, %xmm3 + addpd %xmm5, %xmm1 + addpd %xmm3, %xmm1 + addpd %xmm2, %xmm1 + addpd %xmm6, %xmm1 + addpd %xmm4, %xmm1 + movq %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + jmp ..B1.7 +.L_2TAG_PACKET_3.0.1: + movq (%rsp), %xmm0 + pxor %xmm1, %xmm1 + mulsd %xmm1, %xmm0 + movq %xmm0, %xmm1 + movq %xmm0, 8(%rsp) + jmp ..B1.7 +.L_2TAG_PACKET_4.0.1: +..B1.7: + movq 40(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.9 +..B1.8: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.9: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __libm_sse2_sincos,@function + .size __libm_sse2_sincos,.-__libm_sse2_sincos + .data +# -- End __libm_sse2_sincos + .section .rodata, "a" + .align 16 + .align 16 +PI32INV: + .long 1841940611 + .long 1076125488 + .long 1841940611 + .long 1076125488 + .type PI32INV,@object + .size PI32INV,16 + .align 16 +SHIFTER: + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .type SHIFTER,@object + .size SHIFTER,16 + .align 16 +P_1: + .long 1413480448 + .long 1069097467 + .long 1413480448 + .long 1069097467 + .type P_1,@object + .size P_1,16 + .align 16 +P_2: + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .type P_2,@object + .size P_2,16 + .align 16 +SC_4: + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .type SC_4,@object + .size SC_4,16 + .align 16 +Ctable: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 3217031168 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 3220176896 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 1069547520 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 1071644672 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 1072693248 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 1069547520 + .type Ctable,@object + .size Ctable,4096 + .space 512, 0x00 # pad + .align 16 +P_3: + .long 771977331 + .long 996350346 + .long 771977331 + .long 996350346 + .type P_3,@object + .size P_3,16 + .align 16 +SC_2: + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .type SC_2,@object + .size SC_2,16 + .align 16 +SC_3: + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .type SC_3,@object + .size SC_3,16 + .align 16 +SC_1: + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .type SC_1,@object + .size SC_1,16 + .align 16 +TWO_POW_55: + .long 0 + .long 1130364928 + .type TWO_POW_55,@object + .size TWO_POW_55,8 + .align 8 +ONE: + .long 0 + .long 1072693248 + .type ONE,@object + .size ONE,8 + .align 8 +ALL_ONES: + .long 4294967295 + .long 1072693247 + .type ALL_ONES,@object + .size ALL_ONES,8 + .align 8 +TWO_POW_M55: + .long 0 + .long 3162505216 + .type TWO_POW_M55,@object + .size TWO_POW_M55,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/libm_strtoull.S b/external/sgx_libm/intel64/libm_strtoull.S new file mode 100644 index 0000000000..7ac4bbcccd --- /dev/null +++ b/external/sgx_libm/intel64/libm_strtoull.S @@ -0,0 +1,1006 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "libm_strtoull.c" + .text +..TXTST0: +# -- Begin __libm_conv_strtoull + .text + .align 16,0x90 + .globl __libm_conv_strtoull +__libm_conv_strtoull: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value___libm_conv_strtoull.1: +..L2: + + movq %rdi, %rdx + xorl %esi, %esi + testq %rdi, %rdi + je ..B1.7 +..B1.2: + movsbl (%rdi), %eax + testl %eax, %eax + je ..B1.7 +..B1.4: + incq %rdx + incl %esi + cmpb $0, (%rdx) + jne ..B1.4 +..B1.5: + testl %esi, %esi + je ..B1.7 +..B1.6: + lea -48(%rax), %ecx + cmpl $9, %ecx + jbe ..B1.8 +..B1.7: + xorl %eax, %eax + jmp ..B1.21 +..B1.8: + cmpl $48, %eax + je ..B1.23 +..B1.9: + movl $1, %ecx + cmpl $1, %esi + jle ..B1.14 +..B1.10: + movslq %esi, %rax +..B1.11: + movsbl (%rcx,%rdi), %r8d + addl $-48, %r8d + cmpl $9, %r8d + ja ..B1.7 +..B1.12: + incq %rcx + cmpq %rax, %rcx + jl ..B1.11 +..B1.14: + movl $64, %ecx + cmpl $64, %esi + cmovb %esi, %ecx + xorl %eax, %eax + testl %esi, %esi + jle ..B1.21 +..B1.15: + movl %ecx, %r9d + xorl %r10d, %r10d + shrl $1, %r9d + movl $1, %edi + xorl %r8d, %r8d + xorl %r11d, %r11d + testl %r9d, %r9d + jbe ..B1.19 +..B1.16: + movq %r12, -8(%rsp) + xorl %edi, %edi + lea _C_MUL_10_POW_I(%rip), %rsi + .cfi_offset 12, -16 +..B1.17: + movb -1(%r11,%rdx), %r12b + incl %r8d + addb $-48, %r12b + movsbq %r12b, %r12 + lea (%rsi,%r12,8), %r12 + addq (%r12,%r10), %rax + movb -2(%r11,%rdx), %r12b + addq $-2, %r11 + addb $-48, %r12b + movsbq %r12b, %r12 + lea (%rsi,%r12,8), %r12 + addq 80(%r12,%r10), %rdi + addq $160, %r10 + cmpl %r9d, %r8d + jb ..B1.17 +..B1.18: + movq -8(%rsp), %r12 + .cfi_restore 12 + addq %rdi, %rax + lea 1(%r8,%r8), %edi +..B1.19: + lea -1(%rdi), %esi + cmpl %esi, %ecx + jbe ..B1.21 +..B1.20: + movslq %edi, %rdi + lea _C_MUL_10_POW_I(%rip), %r8 + subq %rdi, %rdx + lea (%rdi,%rdi,4), %rcx + movb (%rdx), %dl + addb $-48, %dl + movsbq %dl, %rsi + shlq $4, %rcx + lea (%rcx,%rsi,8), %r9 + addq -80(%r8,%r9), %rax +..B1.21: + ret +..B1.23: + cmpl $3, %esi + jl ..B1.25 +..B1.24: + movsbl 1(%rdi), %eax + andl $-33, %eax + cmpl $88, %eax + je ..B1.38 +..B1.25: + movl $1, %ecx + cmpl $1, %esi + jle ..B1.30 +..B1.26: + movslq %esi, %rax +..B1.27: + movsbl (%rcx,%rdi), %r8d + addl $-48, %r8d + cmpl $7, %r8d + ja ..B1.7 +..B1.28: + incq %rcx + cmpq %rax, %rcx + jl ..B1.27 +..B1.30: + decl %esi + movl $22, %r8d + cmpl $22, %esi + cmovb %esi, %r8d + xorl %eax, %eax + testl %esi, %esi + jle ..B1.21 +..B1.31: + movl %r8d, %edi + xorl %esi, %esi + shrl $1, %edi + xorl %r9d, %r9d + movl $1, %r11d + xorl %r10d, %r10d + testl %edi, %edi + jbe ..B1.35 +..B1.32: + movq %r12, -8(%rsp) + xorl %r11d, %r11d + .cfi_offset 12, -16 +..B1.33: + movslq %r9d, %r9 + movl %r10d, %ecx + incl %esi + movb -1(%r9,%rdx), %r12b + addb $-48, %r12b + movsbq %r12b, %r12 + shlq %cl, %r12 + lea 3(%r10), %ecx + addq %r12, %rax + addl $6, %r10d + movb -2(%r9,%rdx), %r12b + addl $-2, %r9d + addb $-48, %r12b + movsbq %r12b, %r12 + shlq %cl, %r12 + addq %r12, %r11 + cmpl %edi, %esi + jb ..B1.33 +..B1.34: + movq -8(%rsp), %r12 + .cfi_restore 12 + addq %r11, %rax + lea 1(%rsi,%rsi), %r11d +..B1.35: + lea -1(%r11), %ecx + cmpl %ecx, %r8d + jbe ..B1.21 +..B1.36: + movslq %r11d, %r11 + subq %r11, %rdx + lea 61(%r11,%r11,2), %ecx + movb (%rdx), %dl + addb $-48, %dl + movsbq %dl, %rsi + shlq %cl, %rsi + addq %rsi, %rax + jmp ..B1.21 +..B1.38: + movslq %esi, %rax + xorl %ecx, %ecx + addq $-2, %rax +..B1.39: + movsbl 2(%rcx,%rdi), %r9d + lea -48(%r9), %r8d + cmpl $9, %r8d + jbe ..B1.42 +..B1.40: + lea -97(%r9), %r8d + cmpl $5, %r8d + jbe ..B1.42 +..B1.41: + addl $-65, %r9d + cmpl $5, %r9d + ja ..B1.7 +..B1.42: + incq %rcx + cmpq %rax, %rcx + jb ..B1.39 +..B1.43: + addl $-2, %esi + movl $16, %r9d + cmpl $16, %esi + cmovb %esi, %r9d + xorl %eax, %eax + testl %esi, %esi + jle ..B1.21 +..B1.44: + movl %r9d, %r8d + xorl %r10d, %r10d + shrl $1, %r8d + movl $1, %ecx + xorl %r11d, %r11d + testl %r8d, %r8d + jbe ..B1.54 +..B1.45: + movq %r12, -8(%rsp) + .cfi_offset 12, -16 +..B1.46: + movslq %r11d, %rsi + movsbl -1(%rsi,%rdx), %edi + lea -48(%rdi), %ecx + cmpl $9, %ecx + ja ..B1.48 +..B1.47: + movsbq %cl, %rdi + jmp ..B1.49 +..B1.48: + lea -97(%rdi), %ecx + lea -87(%rdi), %r12d + addl $-55, %edi + cmpl $5, %ecx + movsbq %r12b, %r12 + movsbq %dil, %rdi + cmovbe %r12, %rdi +..B1.49: + lea (,%r10,8), %ecx + shlq %cl, %rdi + movsbl -2(%rsi,%rdx), %ecx + addq %rdi, %rax + lea -48(%rcx), %esi + cmpl $9, %esi + ja ..B1.51 +..B1.50: + movsbq %sil, %rsi + jmp ..B1.52 +..B1.51: + lea -97(%rcx), %edi + lea -87(%rcx), %esi + addl $-55, %ecx + cmpl $5, %edi + movsbq %sil, %r12 + movsbq %cl, %rsi + cmovbe %r12, %rsi +..B1.52: + addl $-2, %r11d + lea 4(,%r10,8), %ecx + shlq %cl, %rsi + incl %r10d + addq %rsi, %rax + cmpl %r8d, %r10d + jb ..B1.46 +..B1.53: + movq -8(%rsp), %r12 + .cfi_restore 12 + lea 1(%r10,%r10), %ecx +..B1.54: + lea -1(%rcx), %esi + cmpl %esi, %r9d + jbe ..B1.21 +..B1.55: + movslq %ecx, %rcx + subq %rcx, %rdx + movsbl (%rdx), %esi + lea -48(%rsi), %edx + cmpl $9, %edx + ja ..B1.57 +..B1.56: + movsbq %dl, %rdx + jmp ..B1.58 +..B1.57: + lea -97(%rsi), %edi + lea -87(%rsi), %edx + addl $-55, %esi + cmpl $5, %edi + movsbq %dl, %r8 + movsbq %sil, %rdx + cmovbe %r8, %rdx +..B1.58: + lea 60(,%rcx,4), %ecx + shlq %cl, %rdx + addq %rdx, %rax + jmp ..B1.21 + .align 16,0x90 + .cfi_endproc + .type __libm_conv_strtoull,@function + .size __libm_conv_strtoull,.-__libm_conv_strtoull + .data +# -- End __libm_conv_strtoull + .section .rodata, "a" + .align 8 + .align 8 +_C_MUL_10_POW_I: + .long 0x00000000,0x00000000 + .long 0x00000001,0x00000000 + .long 0x00000002,0x00000000 + .long 0x00000003,0x00000000 + .long 0x00000004,0x00000000 + .long 0x00000005,0x00000000 + .long 0x00000006,0x00000000 + .long 0x00000007,0x00000000 + .long 0x00000008,0x00000000 + .long 0x00000009,0x00000000 + .long 0x00000000,0x00000000 + .long 0x0000000a,0x00000000 + .long 0x00000014,0x00000000 + .long 0x0000001e,0x00000000 + .long 0x00000028,0x00000000 + .long 0x00000032,0x00000000 + .long 0x0000003c,0x00000000 + .long 0x00000046,0x00000000 + .long 0x00000050,0x00000000 + .long 0x0000005a,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000064,0x00000000 + .long 0x000000c8,0x00000000 + .long 0x0000012c,0x00000000 + .long 0x00000190,0x00000000 + .long 0x000001f4,0x00000000 + .long 0x00000258,0x00000000 + .long 0x000002bc,0x00000000 + .long 0x00000320,0x00000000 + .long 0x00000384,0x00000000 + .long 0x00000000,0x00000000 + .long 0x000003e8,0x00000000 + .long 0x000007d0,0x00000000 + .long 0x00000bb8,0x00000000 + .long 0x00000fa0,0x00000000 + .long 0x00001388,0x00000000 + .long 0x00001770,0x00000000 + .long 0x00001b58,0x00000000 + .long 0x00001f40,0x00000000 + .long 0x00002328,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00002710,0x00000000 + .long 0x00004e20,0x00000000 + .long 0x00007530,0x00000000 + .long 0x00009c40,0x00000000 + .long 0x0000c350,0x00000000 + .long 0x0000ea60,0x00000000 + .long 0x00011170,0x00000000 + .long 0x00013880,0x00000000 + .long 0x00015f90,0x00000000 + .long 0x00000000,0x00000000 + .long 0x000186a0,0x00000000 + .long 0x00030d40,0x00000000 + .long 0x000493e0,0x00000000 + .long 0x00061a80,0x00000000 + .long 0x0007a120,0x00000000 + .long 0x000927c0,0x00000000 + .long 0x000aae60,0x00000000 + .long 0x000c3500,0x00000000 + .long 0x000dbba0,0x00000000 + .long 0x00000000,0x00000000 + .long 0x000f4240,0x00000000 + .long 0x001e8480,0x00000000 + .long 0x002dc6c0,0x00000000 + .long 0x003d0900,0x00000000 + .long 0x004c4b40,0x00000000 + .long 0x005b8d80,0x00000000 + .long 0x006acfc0,0x00000000 + .long 0x007a1200,0x00000000 + .long 0x00895440,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00989680,0x00000000 + .long 0x01312d00,0x00000000 + .long 0x01c9c380,0x00000000 + .long 0x02625a00,0x00000000 + .long 0x02faf080,0x00000000 + .long 0x03938700,0x00000000 + .long 0x042c1d80,0x00000000 + .long 0x04c4b400,0x00000000 + .long 0x055d4a80,0x00000000 + .long 0x00000000,0x00000000 + .long 0x05f5e100,0x00000000 + .long 0x0bebc200,0x00000000 + .long 0x11e1a300,0x00000000 + .long 0x17d78400,0x00000000 + .long 0x1dcd6500,0x00000000 + .long 0x23c34600,0x00000000 + .long 0x29b92700,0x00000000 + .long 0x2faf0800,0x00000000 + .long 0x35a4e900,0x00000000 + .long 0x00000000,0x00000000 + .long 0x3b9aca00,0x00000000 + .long 0x77359400,0x00000000 + .long 0xb2d05e00,0x00000000 + .long 0xee6b2800,0x00000000 + .long 0x2a05f200,0x00000001 + .long 0x65a0bc00,0x00000001 + .long 0xa13b8600,0x00000001 + .long 0xdcd65000,0x00000001 + .long 0x18711a00,0x00000002 + .long 0x00000000,0x00000000 + .long 0x540be400,0x00000002 + .long 0xa817c800,0x00000004 + .long 0xfc23ac00,0x00000006 + .long 0x502f9000,0x00000009 + .long 0xa43b7400,0x0000000b + .long 0xf8475800,0x0000000d + .long 0x4c533c00,0x00000010 + .long 0xa05f2000,0x00000012 + .long 0xf46b0400,0x00000014 + .long 0x00000000,0x00000000 + .long 0x4876e800,0x00000017 + .long 0x90edd000,0x0000002e + .long 0xd964b800,0x00000045 + .long 0x21dba000,0x0000005d + .long 0x6a528800,0x00000074 + .long 0xb2c97000,0x0000008b + .long 0xfb405800,0x000000a2 + .long 0x43b74000,0x000000ba + .long 0x8c2e2800,0x000000d1 + .long 0x00000000,0x00000000 + .long 0xd4a51000,0x000000e8 + .long 0xa94a2000,0x000001d1 + .long 0x7def3000,0x000002ba + .long 0x52944000,0x000003a3 + .long 0x27395000,0x0000048c + .long 0xfbde6000,0x00000574 + .long 0xd0837000,0x0000065d + .long 0xa5288000,0x00000746 + .long 0x79cd9000,0x0000082f + .long 0x00000000,0x00000000 + .long 0x4e72a000,0x00000918 + .long 0x9ce54000,0x00001230 + .long 0xeb57e000,0x00001b48 + .long 0x39ca8000,0x00002461 + .long 0x883d2000,0x00002d79 + .long 0xd6afc000,0x00003691 + .long 0x25226000,0x00003faa + .long 0x73950000,0x000048c2 + .long 0xc207a000,0x000051da + .long 0x00000000,0x00000000 + .long 0x107a4000,0x00005af3 + .long 0x20f48000,0x0000b5e6 + .long 0x316ec000,0x000110d9 + .long 0x41e90000,0x00016bcc + .long 0x52634000,0x0001c6bf + .long 0x62dd8000,0x000221b2 + .long 0x7357c000,0x00027ca5 + .long 0x83d20000,0x0002d798 + .long 0x944c4000,0x0003328b + .long 0x00000000,0x00000000 + .long 0xa4c68000,0x00038d7e + .long 0x498d0000,0x00071afd + .long 0xee538000,0x000aa87b + .long 0x931a0000,0x000e35fa + .long 0x37e08000,0x0011c379 + .long 0xdca70000,0x001550f7 + .long 0x816d8000,0x0018de76 + .long 0x26340000,0x001c6bf5 + .long 0xcafa8000,0x001ff973 + .long 0x00000000,0x00000000 + .long 0x6fc10000,0x002386f2 + .long 0xdf820000,0x00470de4 + .long 0x4f430000,0x006a94d7 + .long 0xbf040000,0x008e1bc9 + .long 0x2ec50000,0x00b1a2bc + .long 0x9e860000,0x00d529ae + .long 0x0e470000,0x00f8b0a1 + .long 0x7e080000,0x011c3793 + .long 0xedc90000,0x013fbe85 + .long 0x00000000,0x00000000 + .long 0x5d8a0000,0x01634578 + .long 0xbb140000,0x02c68af0 + .long 0x189e0000,0x0429d069 + .long 0x76280000,0x058d15e1 + .long 0xd3b20000,0x06f05b59 + .long 0x313c0000,0x0853a0d2 + .long 0x8ec60000,0x09b6e64a + .long 0xec500000,0x0b1a2bc2 + .long 0x49da0000,0x0c7d713b + .long 0x00000000,0x00000000 + .long 0xa7640000,0x0de0b6b3 + .long 0x4ec80000,0x1bc16d67 + .long 0xf62c0000,0x29a2241a + .long 0x9d900000,0x3782dace + .long 0x44f40000,0x45639182 + .long 0xec580000,0x53444835 + .long 0x93bc0000,0x6124fee9 + .long 0x3b200000,0x6f05b59d + .long 0xe2840000,0x7ce66c50 + .long 0x00000000,0x00000000 + .long 0x89e80000,0x8ac72304 + .long 0x13d00000,0x158e4609 + .long 0x9db80000,0xa055690d + .long 0x27a00000,0x2b1c8c12 + .long 0xb1880000,0xb5e3af16 + .long 0x3b700000,0x40aad21b + .long 0xc5580000,0xcb71f51f + .long 0x4f400000,0x56391824 + .long 0xd9280000,0xe1003b28 + .long 0x00000000,0x00000000 + .long 0x63100000,0x6bc75e2d + .long 0xc6200000,0xd78ebc5a + .long 0x29300000,0x43561a88 + .long 0x8c400000,0xaf1d78b5 + .long 0xef500000,0x1ae4d6e2 + .long 0x52600000,0x86ac3510 + .long 0xb5700000,0xf273933d + .long 0x18800000,0x5e3af16b + .long 0x7b900000,0xca024f98 + .long 0x00000000,0x00000000 + .long 0xdea00000,0x35c9adc5 + .long 0xbd400000,0x6b935b8b + .long 0x9be00000,0xa15d0951 + .long 0x7a800000,0xd726b717 + .long 0x59200000,0x0cf064dd + .long 0x37c00000,0x42ba12a3 + .long 0x16600000,0x7883c069 + .long 0xf5000000,0xae4d6e2e + .long 0xd3a00000,0xe4171bf4 + .long 0x00000000,0x00000000 + .long 0xb2400000,0x19e0c9ba + .long 0x64800000,0x33c19375 + .long 0x16c00000,0x4da25d30 + .long 0xc9000000,0x678326ea + .long 0x7b400000,0x8163f0a5 + .long 0x2d800000,0x9b44ba60 + .long 0xdfc00000,0xb525841a + .long 0x92000000,0xcf064dd5 + .long 0x44400000,0xe8e71790 + .long 0x00000000,0x00000000 + .long 0xf6800000,0x02c7e14a + .long 0xed000000,0x058fc295 + .long 0xe3800000,0x0857a3e0 + .long 0xda000000,0x0b1f852b + .long 0xd0800000,0x0de76676 + .long 0xc7000000,0x10af47c1 + .long 0xbd800000,0x1377290c + .long 0xb4000000,0x163f0a57 + .long 0xaa800000,0x1906eba2 + .long 0x00000000,0x00000000 + .long 0xa1000000,0x1bcecced + .long 0x42000000,0x379d99db + .long 0xe3000000,0x536c66c8 + .long 0x84000000,0x6f3b33b6 + .long 0x25000000,0x8b0a00a4 + .long 0xc6000000,0xa6d8cd91 + .long 0x67000000,0xc2a79a7f + .long 0x08000000,0xde76676d + .long 0xa9000000,0xfa45345a + .long 0x00000000,0x00000000 + .long 0x4a000000,0x16140148 + .long 0x94000000,0x2c280290 + .long 0xde000000,0x423c03d8 + .long 0x28000000,0x58500521 + .long 0x72000000,0x6e640669 + .long 0xbc000000,0x847807b1 + .long 0x06000000,0x9a8c08fa + .long 0x50000000,0xb0a00a42 + .long 0x9a000000,0xc6b40b8a + .long 0x00000000,0x00000000 + .long 0xe4000000,0xdcc80cd2 + .long 0xc8000000,0xb99019a5 + .long 0xac000000,0x96582678 + .long 0x90000000,0x7320334b + .long 0x74000000,0x4fe8401e + .long 0x58000000,0x2cb04cf1 + .long 0x3c000000,0x097859c4 + .long 0x20000000,0xe6406697 + .long 0x04000000,0xc308736a + .long 0x00000000,0x00000000 + .long 0xe8000000,0x9fd0803c + .long 0xd0000000,0x3fa10079 + .long 0xb8000000,0xdf7180b6 + .long 0xa0000000,0x7f4200f3 + .long 0x88000000,0x1f128130 + .long 0x70000000,0xbee3016d + .long 0x58000000,0x5eb381aa + .long 0x40000000,0xfe8401e7 + .long 0x28000000,0x9e548224 + .long 0x00000000,0x00000000 + .long 0x10000000,0x3e250261 + .long 0x20000000,0x7c4a04c2 + .long 0x30000000,0xba6f0723 + .long 0x40000000,0xf8940984 + .long 0x50000000,0x36b90be5 + .long 0x60000000,0x74de0e46 + .long 0x70000000,0xb30310a7 + .long 0x80000000,0xf1281308 + .long 0x90000000,0x2f4d1569 + .long 0x00000000,0x00000000 + .long 0xa0000000,0x6d7217ca + .long 0x40000000,0xdae42f95 + .long 0xe0000000,0x4856475f + .long 0x80000000,0xb5c85f2a + .long 0x20000000,0x233a76f5 + .long 0xc0000000,0x90ac8ebf + .long 0x60000000,0xfe1ea68a + .long 0x00000000,0x6b90be55 + .long 0xa0000000,0xd902d61f + .long 0x00000000,0x00000000 + .long 0x40000000,0x4674edea + .long 0x80000000,0x8ce9dbd4 + .long 0xc0000000,0xd35ec9be + .long 0x00000000,0x19d3b7a9 + .long 0x40000000,0x6048a593 + .long 0x80000000,0xa6bd937d + .long 0xc0000000,0xed328167 + .long 0x00000000,0x33a76f52 + .long 0x40000000,0x7a1c5d3c + .long 0x00000000,0x00000000 + .long 0x80000000,0xc0914b26 + .long 0x00000000,0x8122964d + .long 0x80000000,0x41b3e173 + .long 0x00000000,0x02452c9a + .long 0x80000000,0xc2d677c0 + .long 0x00000000,0x8367c2e7 + .long 0x80000000,0x43f90e0d + .long 0x00000000,0x048a5934 + .long 0x80000000,0xc51ba45a + .long 0x00000000,0x00000000 + .long 0x00000000,0x85acef81 + .long 0x00000000,0x0b59df02 + .long 0x00000000,0x9106ce83 + .long 0x00000000,0x16b3be04 + .long 0x00000000,0x9c60ad85 + .long 0x00000000,0x220d9d06 + .long 0x00000000,0xa7ba8c87 + .long 0x00000000,0x2d677c08 + .long 0x00000000,0xb3146b89 + .long 0x00000000,0x00000000 + .long 0x00000000,0x38c15b0a + .long 0x00000000,0x7182b614 + .long 0x00000000,0xaa44111e + .long 0x00000000,0xe3056c28 + .long 0x00000000,0x1bc6c732 + .long 0x00000000,0x5488223c + .long 0x00000000,0x8d497d46 + .long 0x00000000,0xc60ad850 + .long 0x00000000,0xfecc335a + .long 0x00000000,0x00000000 + .long 0x00000000,0x378d8e64 + .long 0x00000000,0x6f1b1cc8 + .long 0x00000000,0xa6a8ab2c + .long 0x00000000,0xde363990 + .long 0x00000000,0x15c3c7f4 + .long 0x00000000,0x4d515658 + .long 0x00000000,0x84dee4bc + .long 0x00000000,0xbc6c7320 + .long 0x00000000,0xf3fa0184 + .long 0x00000000,0x00000000 + .long 0x00000000,0x2b878fe8 + .long 0x00000000,0x570f1fd0 + .long 0x00000000,0x8296afb8 + .long 0x00000000,0xae1e3fa0 + .long 0x00000000,0xd9a5cf88 + .long 0x00000000,0x052d5f70 + .long 0x00000000,0x30b4ef58 + .long 0x00000000,0x5c3c7f40 + .long 0x00000000,0x87c40f28 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb34b9f10 + .long 0x00000000,0x66973e20 + .long 0x00000000,0x19e2dd30 + .long 0x00000000,0xcd2e7c40 + .long 0x00000000,0x807a1b50 + .long 0x00000000,0x33c5ba60 + .long 0x00000000,0xe7115970 + .long 0x00000000,0x9a5cf880 + .long 0x00000000,0x4da89790 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00f436a0 + .long 0x00000000,0x01e86d40 + .long 0x00000000,0x02dca3e0 + .long 0x00000000,0x03d0da80 + .long 0x00000000,0x04c51120 + .long 0x00000000,0x05b947c0 + .long 0x00000000,0x06ad7e60 + .long 0x00000000,0x07a1b500 + .long 0x00000000,0x0895eba0 + .long 0x00000000,0x00000000 + .long 0x00000000,0x098a2240 + .long 0x00000000,0x13144480 + .long 0x00000000,0x1c9e66c0 + .long 0x00000000,0x26288900 + .long 0x00000000,0x2fb2ab40 + .long 0x00000000,0x393ccd80 + .long 0x00000000,0x42c6efc0 + .long 0x00000000,0x4c511200 + .long 0x00000000,0x55db3440 + .long 0x00000000,0x00000000 + .long 0x00000000,0x5f655680 + .long 0x00000000,0xbecaad00 + .long 0x00000000,0x1e300380 + .long 0x00000000,0x7d955a00 + .long 0x00000000,0xdcfab080 + .long 0x00000000,0x3c600700 + .long 0x00000000,0x9bc55d80 + .long 0x00000000,0xfb2ab400 + .long 0x00000000,0x5a900a80 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb9f56100 + .long 0x00000000,0x73eac200 + .long 0x00000000,0x2de02300 + .long 0x00000000,0xe7d58400 + .long 0x00000000,0xa1cae500 + .long 0x00000000,0x5bc04600 + .long 0x00000000,0x15b5a700 + .long 0x00000000,0xcfab0800 + .long 0x00000000,0x89a06900 + .long 0x00000000,0x00000000 + .long 0x00000000,0x4395ca00 + .long 0x00000000,0x872b9400 + .long 0x00000000,0xcac15e00 + .long 0x00000000,0x0e572800 + .long 0x00000000,0x51ecf200 + .long 0x00000000,0x9582bc00 + .long 0x00000000,0xd9188600 + .long 0x00000000,0x1cae5000 + .long 0x00000000,0x60441a00 + .long 0x00000000,0x00000000 + .long 0x00000000,0xa3d9e400 + .long 0x00000000,0x47b3c800 + .long 0x00000000,0xeb8dac00 + .long 0x00000000,0x8f679000 + .long 0x00000000,0x33417400 + .long 0x00000000,0xd71b5800 + .long 0x00000000,0x7af53c00 + .long 0x00000000,0x1ecf2000 + .long 0x00000000,0xc2a90400 + .long 0x00000000,0x00000000 + .long 0x00000000,0x6682e800 + .long 0x00000000,0xcd05d000 + .long 0x00000000,0x3388b800 + .long 0x00000000,0x9a0ba000 + .long 0x00000000,0x008e8800 + .long 0x00000000,0x67117000 + .long 0x00000000,0xcd945800 + .long 0x00000000,0x34174000 + .long 0x00000000,0x9a9a2800 + .long 0x00000000,0x00000000 + .long 0x00000000,0x011d1000 + .long 0x00000000,0x023a2000 + .long 0x00000000,0x03573000 + .long 0x00000000,0x04744000 + .long 0x00000000,0x05915000 + .long 0x00000000,0x06ae6000 + .long 0x00000000,0x07cb7000 + .long 0x00000000,0x08e88000 + .long 0x00000000,0x0a059000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x0b22a000 + .long 0x00000000,0x16454000 + .long 0x00000000,0x2167e000 + .long 0x00000000,0x2c8a8000 + .long 0x00000000,0x37ad2000 + .long 0x00000000,0x42cfc000 + .long 0x00000000,0x4df26000 + .long 0x00000000,0x59150000 + .long 0x00000000,0x6437a000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x6f5a4000 + .long 0x00000000,0xdeb48000 + .long 0x00000000,0x4e0ec000 + .long 0x00000000,0xbd690000 + .long 0x00000000,0x2cc34000 + .long 0x00000000,0x9c1d8000 + .long 0x00000000,0x0b77c000 + .long 0x00000000,0x7ad20000 + .long 0x00000000,0xea2c4000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x59868000 + .long 0x00000000,0xb30d0000 + .long 0x00000000,0x0c938000 + .long 0x00000000,0x661a0000 + .long 0x00000000,0xbfa08000 + .long 0x00000000,0x19270000 + .long 0x00000000,0x72ad8000 + .long 0x00000000,0xcc340000 + .long 0x00000000,0x25ba8000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x7f410000 + .long 0x00000000,0xfe820000 + .long 0x00000000,0x7dc30000 + .long 0x00000000,0xfd040000 + .long 0x00000000,0x7c450000 + .long 0x00000000,0xfb860000 + .long 0x00000000,0x7ac70000 + .long 0x00000000,0xfa080000 + .long 0x00000000,0x79490000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xf88a0000 + .long 0x00000000,0xf1140000 + .long 0x00000000,0xe99e0000 + .long 0x00000000,0xe2280000 + .long 0x00000000,0xdab20000 + .long 0x00000000,0xd33c0000 + .long 0x00000000,0xcbc60000 + .long 0x00000000,0xc4500000 + .long 0x00000000,0xbcda0000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb5640000 + .long 0x00000000,0x6ac80000 + .long 0x00000000,0x202c0000 + .long 0x00000000,0xd5900000 + .long 0x00000000,0x8af40000 + .long 0x00000000,0x40580000 + .long 0x00000000,0xf5bc0000 + .long 0x00000000,0xab200000 + .long 0x00000000,0x60840000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x15e80000 + .long 0x00000000,0x2bd00000 + .long 0x00000000,0x41b80000 + .long 0x00000000,0x57a00000 + .long 0x00000000,0x6d880000 + .long 0x00000000,0x83700000 + .long 0x00000000,0x99580000 + .long 0x00000000,0xaf400000 + .long 0x00000000,0xc5280000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xdb100000 + .long 0x00000000,0xb6200000 + .long 0x00000000,0x91300000 + .long 0x00000000,0x6c400000 + .long 0x00000000,0x47500000 + .long 0x00000000,0x22600000 + .long 0x00000000,0xfd700000 + .long 0x00000000,0xd8800000 + .long 0x00000000,0xb3900000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x8ea00000 + .long 0x00000000,0x1d400000 + .long 0x00000000,0xabe00000 + .long 0x00000000,0x3a800000 + .long 0x00000000,0xc9200000 + .long 0x00000000,0x57c00000 + .long 0x00000000,0xe6600000 + .long 0x00000000,0x75000000 + .long 0x00000000,0x03a00000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x92400000 + .long 0x00000000,0x24800000 + .long 0x00000000,0xb6c00000 + .long 0x00000000,0x49000000 + .long 0x00000000,0xdb400000 + .long 0x00000000,0x6d800000 + .long 0x00000000,0xffc00000 + .long 0x00000000,0x92000000 + .long 0x00000000,0x24400000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xb6800000 + .long 0x00000000,0x6d000000 + .long 0x00000000,0x23800000 + .long 0x00000000,0xda000000 + .long 0x00000000,0x90800000 + .long 0x00000000,0x47000000 + .long 0x00000000,0xfd800000 + .long 0x00000000,0xb4000000 + .long 0x00000000,0x6a800000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x21000000 + .long 0x00000000,0x42000000 + .long 0x00000000,0x63000000 + .long 0x00000000,0x84000000 + .long 0x00000000,0xa5000000 + .long 0x00000000,0xc6000000 + .long 0x00000000,0xe7000000 + .long 0x00000000,0x08000000 + .long 0x00000000,0x29000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x4a000000 + .long 0x00000000,0x94000000 + .long 0x00000000,0xde000000 + .long 0x00000000,0x28000000 + .long 0x00000000,0x72000000 + .long 0x00000000,0xbc000000 + .long 0x00000000,0x06000000 + .long 0x00000000,0x50000000 + .long 0x00000000,0x9a000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xe4000000 + .long 0x00000000,0xc8000000 + .long 0x00000000,0xac000000 + .long 0x00000000,0x90000000 + .long 0x00000000,0x74000000 + .long 0x00000000,0x58000000 + .long 0x00000000,0x3c000000 + .long 0x00000000,0x20000000 + .long 0x00000000,0x04000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xe8000000 + .long 0x00000000,0xd0000000 + .long 0x00000000,0xb8000000 + .long 0x00000000,0xa0000000 + .long 0x00000000,0x88000000 + .long 0x00000000,0x70000000 + .long 0x00000000,0x58000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x28000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x10000000 + .long 0x00000000,0x20000000 + .long 0x00000000,0x30000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x50000000 + .long 0x00000000,0x60000000 + .long 0x00000000,0x70000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x90000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xa0000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0xe0000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x20000000 + .long 0x00000000,0xc0000000 + .long 0x00000000,0x60000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0xa0000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0xc0000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0xc0000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x40000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x80000000 + .type _C_MUL_10_POW_I,@object + .size _C_MUL_10_POW_I,5120 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/llrint_gen.S b/external/sgx_libm/intel64/llrint_gen.S new file mode 100644 index 0000000000..521d61705a --- /dev/null +++ b/external/sgx_libm/intel64/llrint_gen.S @@ -0,0 +1,88 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llrint_gen.c" + .text +..TXTST0: +# -- Begin llrint + .text + .align 16,0x90 + .globl llrint +llrint: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_llrint.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_def_cfa 6, 16 + .cfi_offset 6, -16 + subq $16, %rsp + movq $0, -16(%rbp) + movl $0, -8(%rbp) +..B1.2: + pushq %rax + xorpd %xmm1, %xmm1 + stmxcsr -8(%rbp) + andl $-2, -8(%rbp) + ldmxcsr -8(%rbp) + cvtsd2si %xmm0, %rax + addsd %xmm0, %xmm1 + movq %rax, -16(%rbp) + stmxcsr -8(%rbp) + popq %rax +..B1.3: + movq -16(%rbp), %rax + movq %rbp, %rsp + popq %rbp + .cfi_restore 6 + ret + .align 16,0x90 + .cfi_endproc + .type llrint,@function + .size llrint,.-llrint + .data +# -- End llrint + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/llrintf_gen.S b/external/sgx_libm/intel64/llrintf_gen.S new file mode 100644 index 0000000000..88e55452d0 --- /dev/null +++ b/external/sgx_libm/intel64/llrintf_gen.S @@ -0,0 +1,88 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llrintf_gen.c" + .text +..TXTST0: +# -- Begin llrintf + .text + .align 16,0x90 + .globl llrintf +llrintf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_llrintf.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_def_cfa 6, 16 + .cfi_offset 6, -16 + subq $16, %rsp + movq $0, -16(%rbp) + movl $0, -8(%rbp) +..B1.2: + pushq %rax + xorpd %xmm1, %xmm1 + stmxcsr -8(%rbp) + andl $-2, -8(%rbp) + ldmxcsr -8(%rbp) + cvtss2si %xmm0, %rax + addss %xmm0, %xmm1 + movq %rax, -16(%rbp) + stmxcsr -8(%rbp) + popq %rax +..B1.3: + movq -16(%rbp), %rax + movq %rbp, %rsp + popq %rbp + .cfi_restore 6 + ret + .align 16,0x90 + .cfi_endproc + .type llrintf,@function + .size llrintf,.-llrintf + .data +# -- End llrintf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/llrintl.S b/external/sgx_libm/intel64/llrintl.S new file mode 100644 index 0000000000..b2e5f8e7a3 --- /dev/null +++ b/external/sgx_libm/intel64/llrintl.S @@ -0,0 +1,314 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llrintl.c" + .text +..TXTST0: +# -- Begin llrintl + .text + .align 16,0x90 + .globl llrintl +llrintl: +# parameter 1: 80 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_llrintl.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + subq $56, %rsp + .cfi_def_cfa_offset 80 + fldt 80(%rsp) + movzbl 89(%rsp), %edi + movzwl 88(%rsp), %r8d + andl $128, %edi + andl $32767, %r8d + shrl $7, %edi + fstpt 32(%rsp) + cmpl $16445, %r8d + jge ..B1.8 +..B1.2: + testl %r8d, %r8d + jne ..B1.6 +..B1.3: + cmpl $0, 84(%rsp) + jne ..B1.5 +..B1.4: + cmpl $0, 80(%rsp) + je ..B1.6 +..B1.5: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 8(%rsp) +..B1.6: + fldt 32(%rsp) + fistpq 16(%rsp) +..B1.7: + movq 16(%rsp), %rax + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.8: + cmpl $16447, %r8d + jge ..B1.21 +..B1.9: + movl %edi, %esi + movq $0x7fffffffffffffff, %rax + addq %rax, %rsi + cmpl $16446, %r8d + jge ..B1.16 +..B1.10: + fnstcw 4(%rsp) +..B1.11: + movl 80(%rsp), %ebx + movl %ebx, %ebp + movzwl 4(%rsp), %r11d + andl $1, %ebp + movl 84(%rsp), %ecx + andl $3072, %r11d + jne ..B1.13 +..B1.12: + movl %ebx, %eax + andl $3, %ebx + movl %ecx, %edx + movl $1, %r9d + cmpl $3, %ebx + movl $0, %ebx + cmovne %ebx, %r9d + shrl $1, %edx + shll $31, %ecx + shrl $1, %eax + orl %eax, %ecx + shlq $32, %rdx + orq %rcx, %rdx + addq %r9, %rdx + jmp ..B1.17 +..B1.13: + movl $1, %eax + xorl %edx, %edx + cmpl $3072, %r11d + cmove %eax, %edx + xorl %r10d, %r10d + cmpl $2048, %r11d + movl %eax, %r9d + cmove %eax, %r10d + testl %edi, %edi + cmove %edi, %r9d + andl %r9d, %r10d + xorl %r9d, %r9d + cmpl $1024, %r11d + cmove %eax, %r9d + xorl %r11d, %r11d + testl %edi, %edi + cmovne %r11d, %eax + orl %r10d, %edx + andl %eax, %r9d + orl %r9d, %edx + je ..B1.15 +..B1.14: + movl %ecx, %edx + shrl $1, %edx + shll $31, %ecx + shrl $1, %ebx + orl %ebx, %ecx + shlq $32, %rdx + orq %rcx, %rdx + jmp ..B1.17 +..B1.15: + movl %ecx, %edx + movl %ebx, %eax + shrl $1, %edx + shll $31, %ecx + shrl $1, %eax + orl %eax, %ecx + shlq $32, %rdx + orq %rcx, %rdx + andq $1, %rbx + addq %rbx, %rdx + jmp ..B1.17 +..B1.16: + movl 84(%rsp), %edx + xorl %ebp, %ebp + shlq $32, %rdx + movl 80(%rsp), %eax + orq %rax, %rdx +..B1.17: + movq %rdx, %rax + xorl %ecx, %ecx + negq %rax + testl %edi, %edi + cmove %rdx, %rax + cmpq %rdx, %rax + setae %cl + cmpq %rsi, %rdx + movl $0, %edx + setbe %dl + testl %edx, %ecx + je ..B1.21 +..B1.18: + testl %ebp, %ebp + je ..B1.20 +..B1.19: + lea _ones(%rip), %rdx + lea _small_value_64(%rip), %rcx + movq %rax, 16(%rsp) + movsd (%rdx), %xmm0 + addsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) +..B1.20: + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.21: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movq $0x8000000000000000, %rcx + cmpl $32767, %r8d + movq %rcx, 16(%rsp) + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 8(%rsp) + jne ..B1.24 +..B1.22: + cmpl $-2147483648, 84(%rsp) + jne ..B1.29 +..B1.23: + cmpl $0, 80(%rsp) + jne ..B1.29 +..B1.24: + fnstcw 2(%rsp) +..B1.25: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.26: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.27: + fldcw (%rsp) +..B1.28: + fldcw 2(%rsp) +..B1.29: + movq 16(%rsp), %rax + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type llrintl,@function + .size llrintl,.-llrintl + .data +# -- End llrintl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/llround_gen.S b/external/sgx_libm/intel64/llround_gen.S new file mode 100644 index 0000000000..9a4fc739ac --- /dev/null +++ b/external/sgx_libm/intel64/llround_gen.S @@ -0,0 +1,138 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llround_gen.c" + .text +..TXTST0: +# -- Begin llround + .text + .align 16,0x90 + .globl llround +llround: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_llround.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) + movq $0, 8(%rsp) + movl $0, 16(%rsp) +..B1.2: + stmxcsr 16(%rsp) + movsd (%rsp), %xmm1 + xorpd %xmm2, %xmm2 + andl $-2, 16(%rsp) + ldmxcsr 16(%rsp) + cvtsd2si %xmm1, %rax + addsd %xmm1, %xmm2 + movq %rax, 8(%rsp) + stmxcsr 16(%rsp) +..B1.3: + testb $1, 16(%rsp) + jne ..B1.6 +..B1.4: + pxor %xmm2, %xmm2 + movq 8(%rsp), %rax + cvtsi2sdq %rax, %xmm2 + movsd (%rsp), %xmm1 + movaps %xmm1, %xmm0 + subsd %xmm2, %xmm0 + andps .L_2il0floatpacket.1(%rip), %xmm0 + ucomisd .L_2il0floatpacket.0(%rip), %xmm0 + jp ..B1.5 + je ..B1.7 +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.6: + movq 8(%rsp), %rax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.7: + pxor %xmm0, %xmm0 + comisd %xmm0, %xmm1 + jbe ..B1.10 +..B1.8: + comisd %xmm2, %xmm1 + jbe ..B1.5 +..B1.9: + incq %rax + movq %rax, 8(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.10: + comisd %xmm1, %xmm2 + jbe ..B1.5 +..B1.11: + decq %rax + movq %rax, 8(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type llround,@function + .size llround,.-llround + .data +# -- End llround + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/llroundf_gen.S b/external/sgx_libm/intel64/llroundf_gen.S new file mode 100644 index 0000000000..9cf1b3a981 --- /dev/null +++ b/external/sgx_libm/intel64/llroundf_gen.S @@ -0,0 +1,138 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llroundf_gen.c" + .text +..TXTST0: +# -- Begin llroundf + .text + .align 16,0x90 + .globl llroundf +llroundf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_llroundf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movss %xmm0, 16(%rsp) + movq $0, (%rsp) + movl $0, 8(%rsp) +..B1.2: + stmxcsr 8(%rsp) + movsd 16(%rsp), %xmm1 + xorpd %xmm2, %xmm2 + andl $-2, 8(%rsp) + ldmxcsr 8(%rsp) + cvtss2si %xmm1, %rax + addss %xmm1, %xmm2 + movq %rax, (%rsp) + stmxcsr 8(%rsp) +..B1.3: + testb $1, 8(%rsp) + jne ..B1.6 +..B1.4: + pxor %xmm2, %xmm2 + movq (%rsp), %rax + cvtsi2ssq %rax, %xmm2 + movss 16(%rsp), %xmm1 + movaps %xmm1, %xmm0 + subss %xmm2, %xmm0 + andps .L_2il0floatpacket.1(%rip), %xmm0 + ucomiss .L_2il0floatpacket.0(%rip), %xmm0 + jp ..B1.5 + je ..B1.7 +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.6: + movq (%rsp), %rax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.7: + pxor %xmm0, %xmm0 + comiss %xmm0, %xmm1 + jbe ..B1.10 +..B1.8: + comiss %xmm2, %xmm1 + jbe ..B1.5 +..B1.9: + incq %rax + movq %rax, (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.10: + comiss %xmm1, %xmm2 + jbe ..B1.5 +..B1.11: + decq %rax + movq %rax, (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type llroundf,@function + .size llroundf,.-llroundf + .data +# -- End llroundf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x7fffffff,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 4 +.L_2il0floatpacket.0: + .long 0x3f000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/llroundl.S b/external/sgx_libm/intel64/llroundl.S new file mode 100644 index 0000000000..5b390da096 --- /dev/null +++ b/external/sgx_libm/intel64/llroundl.S @@ -0,0 +1,236 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "llroundl.c" + .text +..TXTST0: +# -- Begin llroundl + .text + .align 16,0x90 + .globl llroundl +llroundl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_llroundl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %dl, %dl +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movb 57(%rsp), %r8b + lea _range(%rip), %rdi + andb $-128, %r8b + shrb $7, %r8b + movzbl %r8b, %eax + movq %rax, %rsi + shlq $4, %rsi + movzwl 56(%rsp), %r9d + andl $32767, %r9d + movzwl 8(%rsi,%rdi), %ecx + andl $32767, %ecx + cmpl %ecx, %r9d + jl ..B1.8 +..B1.4: + jne ..B1.16 +..B1.5: + movl 52(%rsp), %ecx + cmpl 4(%rsi,%rdi), %ecx + jb ..B1.8 +..B1.6: + jne ..B1.16 +..B1.7: + movl 48(%rsp), %ecx + cmpl (%rsi,%rdi), %ecx + ja ..B1.16 +..B1.8: + cmpl $16383, %r9d + jl ..B1.10 +..B1.9: + movl %r9d, %edi + negl %edi + movl 52(%rsp), %r10d + movl %r10d, %eax + movl 48(%rsp), %edx + movl %edx, %esi + shlq $32, %r10 + lea 29(%rdi), %ecx + shrl %cl, %eax + addl $62, %edi + shrl %cl, %esi + cmpl $16414, %r9d + movl %edi, %ecx + cmovl %eax, %esi + orq %rdx, %r10 + andl $1, %esi + shrq %cl, %r10 + addq %rsi, %r10 + movq %r10, %r9 + negq %r9 + testb %r8b, %r8b + cmovne %r9, %r10 + movq %r10, %rax + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.10: + cmpl $16382, %r9d + je ..B1.23 +..B1.11: + testl %r9d, %r9d + jne ..B1.15 +..B1.12: + cmpl $0, 52(%rsp) + jne ..B1.14 +..B1.13: + cmpl $0, 48(%rsp) + je ..B1.15 +..B1.14: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, (%rsp) +..B1.15: + xorl %eax, %eax + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.16: + movzwl 34(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.20 +..B1.17: + orl $-64768, %ecx + movw %cx, 32(%rsp) +..B1.18: + fldcw 32(%rsp) +..B1.19: + movb $1, %dl +..B1.20: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + testb %dl, %dl + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + je ..B1.22 +..B1.21: + fldcw 34(%rsp) +..B1.22: + movq $0x8000000000000000, %rax + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.23: + lea iones(%rip), %rdx + movslq (%rdx,%rax,4), %rax + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type llroundl,@function + .size llroundl,.-llroundl + .data +# -- End llroundl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 2 +_range: + .word 65534 + .word 65535 + .word 65535 + .word 65535 + .word 16445 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49214 + .word 0 + .word 0 + .word 0 + .type _range,@object + .size _range,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log10_gen.S b/external/sgx_libm/intel64/log10_gen.S new file mode 100644 index 0000000000..24aa936736 --- /dev/null +++ b/external/sgx_libm/intel64/log10_gen.S @@ -0,0 +1,784 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10_gen.c" + .text +..TXTST0: +# -- Begin log10 + .text + .align 16,0x90 + .globl log10 +log10: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_log10.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movl $1054736384, %ecx + movd %ecx, %xmm7 + xorpd %xmm3, %xmm3 + movl $30704, %edx + pinsrw $3, %edx, %xmm3 + movq %xmm0, %xmm1 + movl $32768, %edx + movd %edx, %xmm4 + movapd HIGHSIGMASK(%rip), %xmm5 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $16352, %ecx + psrlq $27, %xmm0 + movq LOG10_E(%rip), %xmm2 + psrld $2, %xmm0 + rcpps %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + mulss %xmm7, %xmm0 + orpd %xmm3, %xmm1 + lea L_tbl(%rip), %r11 + andpd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + subsd %xmm5, %xmm1 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm6, %xmm0 + andl $32752, %eax + subl %ecx, %eax + cvtsi2sd %eax, %xmm7 + mulpd %xmm0, %xmm5 + mulsd %xmm0, %xmm1 + movq log2(%rip), %xmm6 + movapd coeff(%rip), %xmm3 + subsd %xmm2, %xmm5 + andl $16711680, %edx + shrl $12, %edx + movapd -1504(%r11,%rdx), %xmm0 + movapd 16+coeff(%rip), %xmm4 + addsd %xmm5, %xmm1 + movapd 32+coeff(%rip), %xmm2 + mulsd %xmm7, %xmm6 + pshufd $68, %xmm1, %xmm5 + mulsd 8+log2(%rip), %xmm7 + mulsd %xmm1, %xmm3 + addsd %xmm6, %xmm0 + mulpd %xmm5, %xmm4 + movq 8+LOG10_E(%rip), %xmm6 + mulpd %xmm5, %xmm5 + addpd %xmm2, %xmm4 + mulpd %xmm5, %xmm3 + pshufd $228, %xmm0, %xmm2 + addsd %xmm1, %xmm0 + mulsd %xmm1, %xmm4 + subsd %xmm0, %xmm2 + mulsd %xmm1, %xmm6 + addsd %xmm2, %xmm1 + pshufd $238, %xmm0, %xmm2 + mulsd %xmm5, %xmm5 + addsd %xmm2, %xmm7 + addsd %xmm6, %xmm1 + addpd %xmm3, %xmm4 + addsd %xmm7, %xmm1 + mulpd %xmm5, %xmm4 + addsd %xmm4, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + movq (%rsp), %xmm0 + movq (%rsp), %xmm1 + addl $16, %eax + cmpl $32768, %eax + jae .L_2TAG_PACKET_2.0.2 + cmpl $16, %eax + jb .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_4.0.2: + addsd %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_5.0.2: + ja .L_2TAG_PACKET_4.0.2 + cmpl $0, %edx + ja .L_2TAG_PACKET_4.0.2 + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_3.0.2: + xorpd %xmm1, %xmm1 + addsd %xmm0, %xmm1 + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.2 + xorpd %xmm1, %xmm1 + movl $18416, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movq %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $18416, %ecx + psrlq $27, %xmm0 + movq LOG10_E(%rip), %xmm2 + psrld $2, %xmm0 + rcpps %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + addl %ecx, %ecx + cmpl $-2097152, %ecx + jae .L_2TAG_PACKET_5.0.2 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.2 +.L_2TAG_PACKET_6.0.2: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + movl $9, 16(%rsp) + jmp .L_2TAG_PACKET_8.0.2 +.L_2TAG_PACKET_7.0.2: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + divsd %xmm1, %xmm0 + movl $8, 16(%rsp) +.L_2TAG_PACKET_8.0.2: + movq %xmm0, 8(%rsp) +..B1.3: + movq 8(%rsp), %xmm0 +.L_2TAG_PACKET_9.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type log10,@function + .size log10,.-log10 + .data +# -- End log10 + .section .rodata, "a" + .align 16 + .align 16 +HIGHSIGMASK: + .long 4160749568 + .long 4294967295 + .long 0 + .long 4294959104 + .type HIGHSIGMASK,@object + .size HIGHSIGMASK,16 + .align 16 +LOG10_E: + .long 0 + .long 1071366144 + .long 3207479560 + .long 1062894188 + .type LOG10_E,@object + .size LOG10_E,16 + .align 16 +L_tbl: + .long 1352628224 + .long 1070810131 + .long 521319256 + .long 1025503025 + .long 2150839296 + .long 1070801944 + .long 3329350096 + .long 3170190015 + .long 1360613376 + .long 1070793794 + .long 2024059075 + .long 1024991594 + .long 1875350528 + .long 1070785680 + .long 2163882141 + .long 3163564137 + .long 2312126464 + .long 1070777602 + .long 1975711076 + .long 1023674196 + .long 1306336256 + .long 1070769560 + .long 3524899523 + .long 3170508164 + .long 1806334976 + .long 1070761553 + .long 4254777025 + .long 1025238739 + .long 2483193856 + .long 1070753581 + .long 3800671317 + .long 3172916830 + .long 2025350144 + .long 1070745644 + .long 1731514745 + .long 1025501083 + .long 3433285632 + .long 1070737741 + .long 2551857336 + .long 3169662186 + .long 1134317568 + .long 1070729873 + .long 3426297655 + .long 3172637891 + .long 2457152512 + .long 1070722038 + .long 63549415 + .long 1025415416 + .long 1861803008 + .long 1070714237 + .long 1910171636 + .long 1023977580 + .long 2414140416 + .long 1070706469 + .long 4002514337 + .long 3170841618 + .long 2900726784 + .long 1070698734 + .long 3268064083 + .long 1022459609 + .long 2123517952 + .long 1070691032 + .long 1767031218 + .long 1022448156 + .long 3194569728 + .long 1070683362 + .long 3402332618 + .long 3171671160 + .long 650882048 + .long 1070675725 + .long 4146023905 + .long 3171023038 + .long 1928988672 + .long 1070668119 + .long 1438617867 + .long 1016360491 + .long 1594908672 + .long 1070660545 + .long 971389377 + .long 1024763979 + .long 2818746368 + .long 1070653002 + .long 3555925341 + .long 3172434821 + .long 194584576 + .long 1070645491 + .long 943919215 + .long 3172950063 + .long 1215096832 + .long 1070638010 + .long 2283358588 + .long 1022335098 + .long 501519360 + .long 1070630560 + .long 480904295 + .long 1024437959 + .long 1278266368 + .long 1070623140 + .long 2755806066 + .long 3172342012 + .long 2487812096 + .long 1070615750 + .long 2489653202 + .long 3172481099 + .long 3085451264 + .long 1070608390 + .long 3759184951 + .long 3172574892 + .long 2039090176 + .long 1070601060 + .long 1361176676 + .long 3172355319 + .long 953057280 + .long 1070591423 + .long 1176587546 + .long 3166422018 + .long 3370524672 + .long 1070576879 + .long 3669570051 + .long 1025376630 + .long 749742080 + .long 1070562394 + .long 707700964 + .long 3170814058 + .long 4008353792 + .long 1070547965 + .long 3247327652 + .long 1022431400 + .long 2612455424 + .long 1070533594 + .long 2453457344 + .long 3172322969 + .long 3230920704 + .long 1070519279 + .long 1296781801 + .long 1025115335 + .long 3965253632 + .long 1070505020 + .long 373075289 + .long 1017938528 + .long 2593157120 + .long 1070476669 + .long 1068054086 + .long 1021616576 + .long 925962240 + .long 1070448537 + .long 850121213 + .long 1023928989 + .long 1732556800 + .long 1070420620 + .long 1305206740 + .long 3172665570 + .long 3815630848 + .long 1070392915 + .long 192642943 + .long 3172699907 + .long 2001758208 + .long 1070365420 + .long 2820786683 + .long 1024704867 + .long 16746496 + .long 1070338131 + .long 1399573110 + .long 3171372773 + .long 1886492672 + .long 1070311044 + .long 3621428075 + .long 3172974358 + .long 3338196992 + .long 1070284157 + .long 3793882035 + .long 1025124701 + .long 381769728 + .long 1070257468 + .long 3877933342 + .long 3170195490 + .long 2186491904 + .long 1070230972 + .long 1838687089 + .long 1017927292 + .long 1008330752 + .long 1070204668 + .long 2228321664 + .long 1025352196 + .long 2247065600 + .long 1070178552 + .long 1413900906 + .long 3170902532 + .long 2964070400 + .long 1070152622 + .long 3590454629 + .long 1025016844 + .long 465154048 + .long 1070126876 + .long 2079688550 + .long 3172268183 + .long 883615744 + .long 1070101310 + .long 989244452 + .long 3171900485 + .long 1993768960 + .long 1070075922 + .long 1124327841 + .long 3172964992 + .long 1794471936 + .long 1070050710 + .long 1140575046 + .long 1022673726 + .long 2797932544 + .long 1070025671 + .long 1894836933 + .long 3172544059 + .long 3433797632 + .long 1070000803 + .long 3221831166 + .long 3171921685 + .long 2338371584 + .long 1069976104 + .long 3732461053 + .long 3164513518 + .long 2644013056 + .long 1069951571 + .long 2519460462 + .long 3172548740 + .long 3383814144 + .long 1069927202 + .long 2290997657 + .long 1025499649 + .long 3781380096 + .long 1069902995 + .long 380479405 + .long 1025184136 + .long 3245785088 + .long 1069878948 + .long 1096398261 + .long 3169885192 + .long 1366712320 + .long 1069855059 + .long 2218343715 + .long 3170281628 + .long 2204717056 + .long 1069831325 + .long 2668334011 + .long 1025264524 + .long 1401772032 + .long 1069807745 + .long 4103993159 + .long 1022925721 + .long 3356721152 + .long 1069784316 + .long 3573790772 + .long 3172186527 + .long 4041148416 + .long 1069761037 + .long 4027691910 + .long 3171276990 + .long 3880151040 + .long 1069737906 + .long 4087118786 + .long 3172710734 + .long 3453364224 + .long 1069714921 + .long 99014299 + .long 3172003077 + .long 3491092480 + .long 1069692080 + .long 3801836701 + .long 3172989287 + .long 575580160 + .long 1069669382 + .long 1920406012 + .long 3170874125 + .long 22282240 + .long 1069646824 + .long 964193370 + .long 1019363159 + .long 2991429632 + .long 1069624404 + .long 3372589890 + .long 1023425053 + .long 2189645824 + .long 1069602122 + .long 2610503872 + .long 1023652442 + .long 3341467648 + .long 1069579975 + .long 1190292004 + .long 1022425665 + .long 3711293440 + .long 1069557962 + .long 1104795356 + .long 1023625829 + .long 1380401152 + .long 1069524644 + .long 1156998217 + .long 1025100499 + .long 765710336 + .long 1069481144 + .long 1736649113 + .long 1024999439 + .long 849412096 + .long 1069437902 + .long 2618178330 + .long 3170853629 + .long 1433104384 + .long 1069394915 + .long 43477267 + .long 3170378811 + .long 2548596736 + .long 1069352180 + .long 3967367063 + .long 1025246584 + .long 157577216 + .long 1069309695 + .long 100402533 + .long 3172825502 + .long 3326238720 + .long 1069267455 + .long 1176892909 + .long 1025464099 + .long 4155494400 + .long 1069225459 + .long 3713707617 + .long 3172630046 + .long 3545804800 + .long 1069183704 + .long 857007315 + .long 1024965777 + .long 2602520576 + .long 1069142187 + .long 2588758347 + .long 1022463131 + .long 2631196672 + .long 1069100905 + .long 2118424235 + .long 1022490989 + .long 838135808 + .long 1069059856 + .long 4117002727 + .long 1024874520 + .long 3210903552 + .long 1069019036 + .long 650070125 + .long 3172012966 + .long 3039211520 + .long 1068978444 + .long 438055812 + .long 1017743757 + .long 2385633280 + .long 1068938077 + .long 3011990369 + .long 3171312044 + .long 3491618816 + .long 1068897932 + .long 712813818 + .long 3172720400 + .long 183644160 + .long 1068858008 + .long 4287006742 + .long 1022379728 + .long 3639214080 + .long 1068818300 + .long 353762279 + .long 3172980009 + .long 3728416768 + .long 1068778808 + .long 1851367730 + .long 1025486574 + .long 3370094592 + .long 1068739529 + .long 4046594913 + .long 3172567047 + .long 1348407296 + .long 1068700461 + .long 143189675 + .long 1025397632 + .long 899403776 + .long 1068661601 + .long 3753687842 + .long 3170772772 + .long 1117708288 + .long 1068622947 + .long 1857340812 + .long 3170782678 + .long 1248276480 + .long 1068584497 + .long 1289858203 + .long 1025222289 + .long 683237376 + .long 1068546249 + .long 2356679608 + .long 3171629170 + .long 3253764096 + .long 1068508200 + .long 3267136556 + .long 1018554987 + .long 94478336 + .long 1068441756 + .long 1927868814 + .long 3169378180 + .long 3233144832 + .long 1068366445 + .long 2682188854 + .long 1023964004 + .long 2940297216 + .long 1068291522 + .long 275301289 + .long 1023944679 + .long 3677708288 + .long 1068216982 + .long 302658771 + .long 1024465567 + .long 1576968192 + .long 1068142822 + .long 3672035940 + .long 3172254610 + .long 1614069760 + .long 1068069037 + .long 480052905 + .long 3172692062 + .long 424435712 + .long 1067995624 + .long 2207869657 + .long 3170965436 + .long 3477782528 + .long 1067922578 + .long 2980661858 + .long 3164990018 + .long 3598401536 + .long 1067849897 + .long 1974393034 + .long 3171357083 + .long 2435235840 + .long 1067777577 + .long 1385289011 + .long 1024615823 + .long 1867333632 + .long 1067705614 + .long 3442236633 + .long 1025334384 + .long 3999301632 + .long 1067634004 + .long 3506472073 + .long 1025132546 + .long 2566971392 + .long 1067562745 + .long 1425757592 + .long 3172358463 + .long 112943104 + .long 1067491833 + .long 1693407156 + .long 3172426603 + .long 3079929856 + .long 1067392159 + .long 3999942455 + .long 1018549369 + .long 2443837440 + .long 1067251701 + .long 974534460 + .long 1023963412 + .long 359366656 + .long 1067111917 + .long 2204915018 + .long 1013514416 + .long 3564519424 + .long 1066972799 + .long 3977441659 + .long 3170879860 + .long 2011086848 + .long 1066834343 + .long 590145514 + .long 1025390011 + .long 3216982016 + .long 1066696541 + .long 3629120110 + .long 1024330313 + .long 2194128896 + .long 1066559388 + .long 2367098512 + .long 3172260338 + .long 2916220928 + .long 1066422877 + .long 2262431886 + .long 1021229446 + .long 2263941120 + .long 1066172214 + .long 3118507287 + .long 1021484970 + .long 3076292608 + .long 1065901726 + .long 1411737803 + .long 3172957147 + .long 1186136064 + .long 1065632488 + .long 3109349337 + .long 1025397383 + .long 3085303808 + .long 1065364487 + .long 584715031 + .long 3172596519 + .long 1821048832 + .long 1064842211 + .long 2182246895 + .long 3172536214 + .long 697368576 + .long 1064311094 + .long 3157561765 + .long 3172716357 + .long 894042112 + .long 1063260131 + .long 3237958154 + .long 3172587292 + .long 0 + .long 0 + .long 0 + .long 0 + .type L_tbl,@object + .size L_tbl,2064 + .align 16 +log2: + .long 1352628224 + .long 1066615827 + .long 521319256 + .long 1021308721 + .type log2,@object + .size log2,16 + .align 16 +coeff: + .long 3248877870 + .long 1077250164 + .long 1691676429 + .long 3221787401 + .long 945132465 + .long 3223701783 + .long 3700831335 + .long 1073506818 + .long 2141010593 + .long 1075227551 + .long 3698831637 + .long 3220339442 + .type coeff,@object + .size coeff,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log10f_gen.S b/external/sgx_libm/intel64/log10f_gen.S new file mode 100644 index 0000000000..7bf4ceb71f --- /dev/null +++ b/external/sgx_libm/intel64/log10f_gen.S @@ -0,0 +1,285 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10f_gen.c" + .text +..TXTST0: +# -- Begin log10f + .text + .align 16,0x90 + .globl log10f +log10f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_log10f.1: +..L2: + + movd %xmm0, %edi + movss %xmm0, -8(%rsp) + cmpl $2139095040, %edi + jae ..B1.14 +..B1.2: + lea -1065222144(%rdi), %eax + cmpl $196608, %eax + jae ..B1.7 +..B1.3: + cmpl $1065353216, %edi + jne ..B1.5 +..B1.4: + pxor %xmm3, %xmm3 + jmp ..B1.6 +..B1.5: + movss -8(%rsp), %xmm0 + lea 40+_Q(%rip), %rax + lea 32+_Q(%rip), %rsi + addss .L_2il0floatpacket.0(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + movaps %xmm0, %xmm1 + lea 24+_Q(%rip), %rdx + movsd (%rax), %xmm3 + lea 16+_Q(%rip), %rdi + movsd (%rsi), %xmm2 + lea 8+_Q(%rip), %rcx + lea _Q(%rip), %r8 + mulsd %xmm0, %xmm1 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm2 + addsd (%rdx), %xmm3 + addsd (%rdi), %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm2 + addsd (%rcx), %xmm3 + addsd (%r8), %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm0, %xmm2 + addsd %xmm2, %xmm3 + cvtsd2ss %xmm3, %xmm3 +..B1.6: + movaps %xmm3, %xmm0 + ret +..B1.7: + movl %edi, %eax + movl %edi, %esi + shrl $23, %eax + andl $8388607, %esi + addl $-127, %eax + movl %esi, -8(%rsp) + cmpl $8388608, %edi + jae ..B1.10 +..B1.8: + testl %edi, %edi + je ..B1.22 +..B1.9: + movss -8(%rsp), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + movd %xmm0, %esi + movss %xmm0, -8(%rsp) + movl %esi, %eax + movl %esi, %edi + shrl $23, %eax + addl $-152, %eax +..B1.10: + imull $21846, %eax, %edx + sarl $15, %edx + cmpl $34, %eax + ja ..B1.13 +..B1.11: + andl $-2, %edx + lea _exact_values(%rip), %rcx + movslq %edx, %rdx + cmpl (%rcx,%rdx,4), %edi + jne ..B1.13 +..B1.12: + movss 4(%rcx,%rdx,4), %xmm0 + ret +..B1.13: + shrl $15, %edi + orl $1065353216, %esi + movzbl %dil, %r8d + pxor %xmm2, %xmm2 + movl %esi, -8(%rsp) + pxor %xmm0, %xmm0 + movq __libm_rcp_table_256@GOTPCREL(%rip), %rsi + lea 16+_P(%rip), %rdx + cvtss2sd -8(%rsp), %xmm2 + cvtss2sd (%rsi,%r8,4), %xmm0 + mulsd %xmm0, %xmm2 + lea 8+_P(%rip), %rcx + movsd (%rdx), %xmm0 + lea _P(%rip), %r9 + movq __libm_logf_table_256@GOTPCREL(%rip), %rdi + pxor %xmm3, %xmm3 + cvtsi2sd %eax, %xmm3 + addsd .L_2il0floatpacket.2(%rip), %xmm2 + mulsd %xmm2, %xmm0 + lea _LOG102(%rip), %rax + mulsd (%rax), %xmm3 + addsd (%rcx), %xmm0 + mulsd %xmm2, %xmm0 + movsd (%rdi,%r8,8), %xmm1 + mulsd %xmm2, %xmm0 + addsd %xmm1, %xmm2 + mulsd (%r9), %xmm2 + addsd %xmm2, %xmm0 + addsd %xmm3, %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.14: + movl %edi, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.20 +..B1.15: + testl $-2147483648, %edi + je ..B1.20 +..B1.16: + testl %eax, %eax + jne ..B1.18 +..B1.17: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + ret +..B1.18: + movss .L_2il0floatpacket.3(%rip), %xmm1 + pxor %xmm0, %xmm0 + mulss %xmm1, %xmm0 +..B1.19: + ret +..B1.20: + movss -8(%rsp), %xmm0 + ret +..B1.22: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type log10f,@function + .size log10f,.-log10f + .data +# -- End log10f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x7f800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_Q: + .long 354870542 + .long 1071369083 + .long 354784454 + .long 3217804155 + .long 1678399179 + .long 1069713319 + .long 656012052 + .long 3216755581 + .long 509767151 + .long 1068907598 + .long 3001134819 + .long 3216124527 + .type _Q,@object + .size _Q,48 + .align 4 +_exact_values: + .long 4294967295 + .long 4294967295 + .long 1092616192 + .long 1065353216 + .long 1120403456 + .long 1073741824 + .long 1148846080 + .long 1077936128 + .long 1176256512 + .long 1082130432 + .long 1203982336 + .long 1084227584 + .long 1232348160 + .long 1086324736 + .long 1259902592 + .long 1088421888 + .long 1287568416 + .long 1090519040 + .long 1315859240 + .long 1091567616 + .long 4294967295 + .long 4294967295 + .long 1343554297 + .long 1092616192 + .type _exact_values,@object + .size _exact_values,96 + .align 4 +_P: + .long 354870542 + .long 1071369083 + .long 1669757279 + .long 3217804158 + .long 3421439185 + .long 1069713323 + .type _P,@object + .size _P,24 + .align 4 +_LOG102: + .long 1352628735 + .long 1070810131 + .type _LOG102,@object + .size _LOG102,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log10l.S b/external/sgx_libm/intel64/log10l.S new file mode 100644 index 0000000000..d8604ea777 --- /dev/null +++ b/external/sgx_libm/intel64/log10l.S @@ -0,0 +1,1052 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10l.c" + .text +..TXTST0: +# -- Begin log10l + .text + .align 16,0x90 + .globl log10l +log10l: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_log10l.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %r8b, %r8b +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzbl 57(%rsp), %r9d + andl $128, %r9d + shrl $7, %r9d + movzwl 56(%rsp), %esi + movl %esi, %edi + movl %r9d, %edx + andl $32767, %edi + shll $15, %edx + movl 52(%rsp), %ecx + orl %edi, %edx + movl %ecx, %eax + shll $16, %edx + shrl $16, %eax + orl %eax, %edx + cmpl $2147450880, %edx + jae ..B1.29 +..B1.4: + addl $-1073676224, %edx + cmpl $32863, %edx + ja ..B1.13 +..B1.5: + cmpl $16383, %edi + je ..B1.38 +..B1.6: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.10 +..B1.7: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.8: + fldcw 24(%rsp) +..B1.9: + movb $1, %r8b +..B1.10: + fldt 48(%rsp) + lea 8+_ones(%rip), %rax + lea 112+_P(%rip), %rcx + lea 80+_P(%rip), %rsi + lea 48+_P(%rip), %rdi + lea 96+_P(%rip), %r10 + lea _TWO_32H(%rip), %rdx + lea 64+_P(%rip), %r11 + lea 16+_P(%rip), %r9 + testb %r8b, %r8b + fldt (%rcx) + lea 128+_P(%rip), %rcx + fldt (%rsi) + fldl (%rdx) + lea _P(%rip), %rdx + fldt (%rdi) + fxch %st(4) + faddl (%rax) + lea 32+_P(%rip), %rax + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fld %st(1) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(1) + fsub %st(3), %st + fxch %st(2) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r10) + fmul %st(5), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt (%rdx) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt (%rcx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.12 +..B1.11: + fldcw 26(%rsp) +..B1.12: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.13: + cmpl $16383, %edi + jl ..B1.19 +..B1.14: + cmpl $16471, %edi + jge ..B1.19 +..B1.15: + movl $1431655766, %eax + lea -16383(%rdi), %r9d + imull %r9d + sarl $31, %r9d + subl %r9d, %edx + lea _exact_values(%rip), %r9 + addl %edx, %edx + movslq %edx, %rdx + shlq $4, %rdx + movzwl 8(%rdx,%r9), %r10d + andl $32767, %r10d + cmpl %r10d, %edi + jne ..B1.19 +..B1.16: + cmpl 4(%rdx,%r9), %ecx + jne ..B1.19 +..B1.17: + movl 48(%rsp), %eax + cmpl (%rdx,%r9), %eax + jne ..B1.19 +..B1.18: + fldt 16(%r9,%rdx) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.19: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.23 +..B1.20: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.21: + fldcw 24(%rsp) +..B1.22: + movzwl 56(%rsp), %esi + movl %esi, %edi + movb $1, %r8b + andl $32767, %edi +..B1.23: + movl $-16383, %eax + testl %edi, %edi + jne ..B1.26 +..B1.24: + fldt 48(%rsp) + lea _TWO_75(%rip), %rax + lea _zeros(%rip), %rdx + fmull (%rax) + movl $-16458, %eax + fstpt 48(%rsp) + fldt 48(%rsp) + fldl (%rdx) + movsd (%rdx), %xmm0 + fucomip %st(1), %st + fstp %st(0) + jp ..B1.25 + je ..B1.40 +..B1.25: + movzwl 56(%rsp), %esi + movl %esi, %edi + andl $32767, %edi +..B1.26: + lea _TWO_32H(%rip), %rcx + andl $-32768, %esi + orl $-49153, %esi + addl %eax, %edi + movw %si, 56(%rsp) + lea 8+_ones(%rip), %r9 + fldt 48(%rsp) + lea 112+_P(%rip), %r10 + fld %st(0) + lea 80+_P(%rip), %r11 + fldl (%rcx) + lea 16+_P(%rip), %rcx + movl 52(%rsp), %edx + fadd %st, %st(1) + shrl $23, %edx + fsubrp %st, %st(1) + movzbl %dl, %eax + lea 48+_P(%rip), %rdx + movq __libm_rcp_table_256@GOTPCREL(%rip), %rsi + fsubr %st, %st(1) + flds (%rsi,%rax,4) + lea 96+_P(%rip), %rsi + fmul %st, %st(1) + fmulp %st, %st(2) + faddl (%r9) + fld %st(0) + lea 64+_P(%rip), %r9 + movl %edi, 16(%rsp) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%r10) + lea 32+_P(%rip), %r10 + fmul %st(2), %st + fldt (%r11) + lea _P(%rip), %r11 + shlq $4, %rax + faddp %st, %st(1) + fmul %st(2), %st + testb %r8b, %r8b + fldt (%rdx) + lea 128+_P(%rip), %rdx + movq __libm_log10l_table_256@GOTPCREL(%rip), %rdi + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%r11) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt (%rdx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(1) + fildl 16(%rsp) + fldt .L_2il0floatpacket.0(%rip) + fmul %st(1), %st + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(2) + faddl 8(%rdi,%rax) + faddp %st, %st(3) + faddl (%rax,%rdi) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.28 +..B1.27: + fldcw 26(%rsp) +..B1.28: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.29: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.33 +..B1.30: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.31: + fldcw 24(%rsp) +..B1.32: + movzbl 57(%rsp), %r9d + movb $1, %r8b + andl $128, %r9d + shrl $7, %r9d +..B1.33: + testl %r9d, %r9d + jne ..B1.43 +..B1.34: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.35: + testb %r8b, %r8b + je ..B1.37 +..B1.36: + fldcw 26(%rsp) +..B1.37: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.38: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.6 +..B1.39: + lea _zeros(%rip), %rax + fldl (%rax) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.40: + lea 8+_ones(%rip), %rax + testb %r8b, %r8b + movsd (%rax), %xmm1 + divsd %xmm0, %xmm1 + je ..B1.42 +..B1.41: + fldcw 26(%rsp) +..B1.42: + movsd %xmm1, 16(%rsp) + fldl 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.43: + movzwl 56(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.45 +..B1.44: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.34 + jmp ..B1.48 +..B1.45: + testl %eax, %eax + jne ..B1.48 +..B1.46: + cmpq $0, 48(%rsp) + jne ..B1.48 +..B1.47: + lea 8+_ones(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + divsd (%rdx), %xmm0 + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + jmp ..B1.35 +..B1.48: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + jmp ..B1.35 + .align 16,0x90 + .cfi_endproc + .type log10l,@function + .size log10l,.-log10l + .data +# -- End log10l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xc8,0xd4,0x0e,0xee,0x0c,0x01,0x86,0xd8,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x85,0x9a,0x20,0x9a,0xfd,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_P: + .word 23339 + .word 38197 + .word 10353 + .word 43319 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 29077 + .word 14120 + .word 55465 + .word 56923 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 63176 + .word 31258 + .word 15131 + .word 37949 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 29577 + .word 14120 + .word 55465 + .word 56923 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 61319 + .word 34328 + .word 5050 + .word 45539 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 52415 + .word 26390 + .word 15131 + .word 37949 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 16765 + .word 7621 + .word 20590 + .word 65056 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 14162 + .word 11829 + .word 26041 + .word 56924 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 56923 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,144 + .align 2 +_exact_values: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40000 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50000 + .word 16399 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62500 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39062 + .word 16406 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57344 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8192 + .word 48828 + .word 16409 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10240 + .word 61035 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63744 + .word 38146 + .word 16416 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46912 + .word 47683 + .word 16419 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45056 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42256 + .word 59604 + .word 16422 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59178 + .word 37252 + .word 16426 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53248 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8436 + .word 46566 + .word 16429 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57344 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 43313 + .word 58207 + .word 16432 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61440 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1024 + .word 51647 + .word 36379 + .word 16436 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50432 + .word 48174 + .word 45474 + .word 16439 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30272 + .word 27450 + .word 56843 + .word 16442 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35304 + .word 8964 + .word 35527 + .word 16446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38912 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44130 + .word 60357 + .word 44408 + .word 16449 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6010 + .word 9911 + .word 55511 + .word 16452 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 36864 + .word 28332 + .word 30770 + .word 34694 + .word 16456 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45056 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 46080 + .word 2647 + .word 5695 + .word 43368 + .word 16459 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47104 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 41216 + .word 52461 + .word 7118 + .word 54210 + .word 16462 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 33952 + .word 16404 + .word 20833 + .word 33881 + .word 16466 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51200 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 42440 + .word 36889 + .word 42425 + .word 42351 + .word 16469 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53248 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 3898 + .word 62496 + .word 36647 + .word 52939 + .word 16472 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 16387 + .word 0 + .word 0 + .word 0 + .type _exact_values,@object + .size _exact_values,960 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log10l_table.S b/external/sgx_libm/intel64/log10l_table.S new file mode 100644 index 0000000000..4574b6e180 --- /dev/null +++ b/external/sgx_libm/intel64/log10l_table.S @@ -0,0 +1,559 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log10l_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_log10l_table_256 +__libm_log10l_table_256: + .long 0x45bfc000,0x3f4bd270 + .long 0xeb5a6902,0x3cc024b0 + .long 0x793a4000,0x3f64e84e + .long 0xbdc59429,0x3ccd29dc + .long 0x5ab86000,0x3f717508 + .long 0xf6df9894,0xbc6f70c9 + .long 0x9d914000,0x3f787cff + .long 0xeb029384,0x3cde94f0 + .long 0x72b8c000,0x3f7ea9d3 + .long 0x75a2920a,0xbd001bfa + .long 0x95daa000,0x3f82df9d + .long 0x77634a76,0xbcf3c705 + .long 0x72d64000,0x3f866df1 + .long 0x93609ef4,0xbcf1a833 + .long 0xef5ec000,0x3f898d79 + .long 0x7a519e99,0x3d16f7e1 + .long 0xf3f94000,0x3f8d22ad + .long 0xa10c1504,0x3d079c92 + .long 0x1d30c000,0x3f902423 + .long 0x2dcf9263,0x3cecc021 + .long 0x98898000,0x3f91f23a + .long 0x21ad4280,0xbce5b1e0 + .long 0x7b818000,0x3f93881a + .long 0x9c5111b1,0x3d0f3cbd + .long 0x1e75a000,0x3f951f6e + .long 0xaf539251,0xbcdcad0e + .long 0xe7adc000,0x3f96f2bc + .long 0x7385f0a6,0x3cf6d084 + .long 0x2cdf4000,0x3f988d36 + .long 0x41385083,0xbd04c3af + .long 0xaf014000,0x3f9a292b + .long 0x3724b270,0xbd2b3f0c + .long 0x3117c000,0x3f9bc6a0 + .long 0x667331b5,0x3d25cb86 + .long 0x7de3c000,0x3f9d6596 + .long 0x31612f8e,0xbd14f74b + .long 0x67fc4000,0x3f9f0611 + .long 0x143b6bad,0xbd0c30f3 + .long 0xe4f78000,0x3fa05409 + .long 0x5b985713,0x3ce9bb8e + .long 0x432ea000,0x3fa125d0 + .long 0x68a0dc47,0x3cf06e09 + .long 0x440d2000,0x3fa1f85d + .long 0x507c1dd7,0x3d133627 + .long 0x57496000,0x3fa2ad75 + .long 0x7f319445,0x3ce7c850 + .long 0x2a00e000,0x3fa38177 + .long 0x9d2bb1a5,0x3d080fdc + .long 0xe165a000,0x3fa45643 + .long 0xf742c845,0x3d0c2a9f + .long 0x03446000,0x3fa52bdd + .long 0x5036c404,0x3d25b862 + .long 0x6b7ec000,0x3fa5e396 + .long 0x23196824,0xbd36b572 + .long 0x47c5c000,0x3fa6baaf + .long 0x6d3e4a28,0xbd1b7614 + .long 0xe8c4c000,0x3fa773b3 + .long 0xf794b354,0x3d39e3f5 + .long 0xebee8000,0x3fa84c51 + .long 0x2cb6638b,0x3d1a2aaa + .long 0x786fc000,0x3fa906a6 + .long 0xdfffb059,0x3cecab9f + .long 0xabf00000,0x3fa9c197 + .long 0x3d6e4566,0x3d1badcf + .long 0x71218000,0x3faa9c78 + .long 0xcb03a47d,0x3d21f757 + .long 0x9c8d4000,0x3fab58c0 + .long 0x3b0fe4fe,0x3d31be11 + .long 0xbcdd4000,0x3fac15a8 + .long 0xb6d13ff4,0x3d3dbf2d + .long 0xe2c28000,0x3facd331 + .long 0x77fafd44,0x3d267bed + .long 0xd766c000,0x3fadb11e + .long 0x23c3e44c,0xbd240bcd + .long 0x9346c000,0x3fae7008 + .long 0xd4c5edca,0xbd2619d1 + .long 0xc6754000,0x3faf2f96 + .long 0xb182cded,0x3d15dbd8 + .long 0x8d450000,0x3fafefca + .long 0xcc1beb8a,0x3d2fd5cf + .long 0x83764000,0x3fb05852 + .long 0x779b9fcf,0x3cf77c3e + .long 0xaac7c000,0x3fb0b913 + .long 0xbc7f44a6,0x3d33a6ff + .long 0x4f258000,0x3fb11a29 + .long 0xb8d25b3a,0xbd360a72 + .long 0xa2698000,0x3fb16b51 + .long 0x7904e2d7,0xbd376f39 + .long 0xadacc000,0x3fb1cd03 + .long 0x084a2298,0x3d217bee + .long 0xdd776000,0x3fb22f0b + .long 0xa204f9bf,0xbd3a0ad1 + .long 0xca38e000,0x3fb2916a + .long 0xffeb8381,0xbd2c3074 + .long 0x0df76000,0x3fb2f421 + .long 0x0d443b33,0x3d18f3ef + .long 0xc3c48000,0x3fb346a6 + .long 0x15025ea7,0x3d306599 + .long 0xbc606000,0x3fb3a9fe + .long 0xa7db519f,0xbd27eca8 + .long 0x10a3c000,0x3fb3fd0c + .long 0xb6f7db46,0xbd35abc5 + .long 0xd3540000,0x3fb46107 + .long 0x813a4964,0x3d25039a + .long 0xd1696000,0x3fb4c55d + .long 0x64286476,0x3d1ff9d8 + .long 0x330c0000,0x3fb51940 + .long 0x2c505825,0x3ca5ed92 + .long 0x0ee70000,0x3fb56d62 + .long 0x06e88a06,0x3d315e58 + .long 0xcf260000,0x3fb5d2ab + .long 0xd90fb16b,0x3d378d89 + .long 0xa5dec000,0x3fb6275a + .long 0x405920cd,0xbcdfa0db + .long 0xaf26c000,0x3fb68d4e + .long 0x1d3da9e2,0x3d37ee53 + .long 0x5c54c000,0x3fb6e28c + .long 0x9d9b5afe,0xbd3d72f7 + .long 0x9665c000,0x3fb7380b + .long 0xb00e89cf,0xbd20707b + .long 0xc2790000,0x3fb78dcc + .long 0x9a7343d9,0xbd37a4ff + .long 0x2cf28000,0x3fb7f50c + .long 0xfacefdb0,0xbd45431c + .long 0xd5eb0000,0x3fb84b5f + .long 0x2b4f09ce,0xbd302851 + .long 0xbab2c000,0x3fb8a1f6 + .long 0x11e41a3e,0xbd2bb389 + .long 0x44558000,0x3fb8f8d1 + .long 0xbf96339c,0xbd1083fd + .long 0xdcd64000,0x3fb94fef + .long 0xe07d5241,0xbd4136f4 + .long 0xef314000,0x3fb9a752 + .long 0xa5e3191a,0x3d40a49e + .long 0xe7614000,0x3fb9fefa + .long 0xa1f54e0a,0xbd40902f + .long 0x325f4000,0x3fba56e8 + .long 0xec5e03cc,0x3d3c86ee + .long 0x3e298000,0x3fbaaf1b + .long 0xcb09696b,0xbd1130fe + .long 0x79c34000,0x3fbb0794 + .long 0x628b8546,0x3d495642 + .long 0x553b0000,0x3fbb6054 + .long 0xa20d3394,0x3d32f77b + .long 0x41ab8000,0x3fbbb95b + .long 0x61433066,0xbd418d39 + .long 0xb1400000,0x3fbc12a9 + .long 0xd5882f66,0xbd3f86c6 + .long 0x17380000,0x3fbc6c40 + .long 0x219900ae,0x3d45f518 + .long 0xba424000,0x3fbcb41f + .long 0x6665a718,0x3d443661 + .long 0xce734000,0x3fbd0e38 + .long 0xd0afc15d,0xbd1b04a7 + .long 0x21940000,0x3fbd689b + .long 0x80039681,0xbd2d9a08 + .long 0x2b1d0000,0x3fbdc347 + .long 0xd102c576,0x3d442ff9 + .long 0x300d8000,0x3fbe0c06 + .long 0xe391d6b6,0xbd46ba4d + .long 0x190e4000,0x3fbe6738 + .long 0x23d01c6b,0xbd1ad0ad + .long 0x0d208000,0x3fbec2b5 + .long 0xb6656ff4,0x3d2b355d + .long 0x2b938000,0x3fbf0c1c + .long 0x4980111b,0xbd37d822 + .long 0x6c9cc000,0x3fbf6821 + .long 0xd0891bcc,0x3d1c9a3b + .long 0x38184000,0x3fbfb1f6 + .long 0x16ca77f0,0x3d36f3d3 + .long 0xaf4ce000,0x3fc00742 + .long 0xee8b5696,0x3d27e0ee + .long 0x90650000,0x3fc02c64 + .long 0xe445f2fd,0x3d42d27a + .long 0xe63e2000,0x3fc05af1 + .long 0xa16f7336,0xbd4c4b92 + .long 0xea724000,0x3fc0804b + .long 0xb736f965,0xbd255d7c + .long 0xd6712000,0x3fc0af1f + .long 0x009609f5,0xbd35b214 + .long 0xa8806000,0x3fc0d4b2 + .long 0xc4dfdce2,0xbd2800b0 + .long 0xf136a000,0x3fc0fa5e + .long 0x2043a891,0x3ceb0a92 + .long 0x4fb3e000,0x3fc1299a + .long 0x26f70b35,0x3d182c63 + .long 0x6253c000,0x3fc14f80 + .long 0x44ac2d9f,0x3d1f65c1 + .long 0x5d158000,0x3fc17580 + .long 0x33b79054,0x3d2f04d6 + .long 0x637cc000,0x3fc19b9a + .long 0xe16cee25,0xbd4d6b79 + .long 0xc26ee000,0x3fc1cb5f + .long 0x6b51c369,0xbd0e934a + .long 0xe65f2000,0x3fc1f1b4 + .long 0x70fcf287,0x3d264160 + .long 0x8b5dc000,0x3fc21824 + .long 0xa3811df5,0x3d1f2866 + .long 0xd62ae000,0x3fc23eae + .long 0x75f6e51d,0xbd1c4ef6 + .long 0xebd34000,0x3fc26553 + .long 0xcd48326e,0xbd308652 + .long 0xf1b12000,0x3fc28c13 + .long 0xdfe3a7af,0xbd2c0024 + .long 0x14382000,0x3fc2bcaa + .long 0x21480e44,0xbd38f4c6 + .long 0x40b78000,0x3fc2e3a7 + .long 0x60689912,0x3cbd2885 + .long 0xd8f34000,0x3fc30abf + .long 0x508d5aa5,0xbd3893a6 + .long 0x03984000,0x3fc331f4 + .long 0xe9a3a8db,0x3d409691 + .long 0xe7a60000,0x3fc35943 + .long 0x43d5764a,0x3d2a3e8e + .long 0xac6e8000,0x3fc380af + .long 0x4d90e64e,0xbd1fc4d9 + .long 0x7997c000,0x3fc3a837 + .long 0xab2a4593,0xbd286816 + .long 0x771ca000,0x3fc3cfdb + .long 0x16e57a0f,0xbd2493c7 + .long 0x0d39a000,0x3fc3eda9 + .long 0x2ae78433,0x3d277ad1 + .long 0xc0950000,0x3fc4157e + .long 0xa37f5324,0x3d27333a + .long 0x13fb2000,0x3fc43d71 + .long 0xb82461da,0xbd4b3f09 + .long 0x30ad2000,0x3fc46580 + .long 0x72bdc442,0xbd198b79 + .long 0x40464000,0x3fc48dac + .long 0xc1788616,0xbd2c28bc + .long 0x6cbbc000,0x3fc4b5f5 + .long 0xef1ba41e,0xbd2e5a23 + .long 0xe05e6000,0x3fc4de5b + .long 0x8b90e0a0,0x3d4582b8 + .long 0x07770000,0x3fc4fcbc + .long 0x794dd932,0xbd13d6f8 + .long 0x1e926000,0x3fc52556 + .long 0x9b81384c,0xbd322350 + .long 0xf3198000,0x3fc54e0d + .long 0x2cd70aca,0x3d30ca92 + .long 0x7112c000,0x3fc56cab + .long 0x2a6e4407,0xbd10ed4c + .long 0xba734000,0x3fc59597 + .long 0x187e8930,0x3d4b1553 + .long 0x3a508000,0x3fc5bea2 + .long 0x1e386e4d,0xbd402641 + .long 0x08de4000,0x3fc5dd7e + .long 0x0b3f247b,0xbd2f4535 + .long 0xd3f90000,0x3fc606bd + .long 0x7c6ff8cd,0x3d51aaa0 + .long 0x518a4000,0x3fc6301c + .long 0x4d6761d0,0x3d401ece + .long 0x70618000,0x3fc64f37 + .long 0xa791b8a6,0x3d322b46 + .long 0x14c20000,0x3fc678cc + .long 0x7917b19f,0xbd4d287f + .long 0x05ed4000,0x3fc69810 + .long 0xcb5870e8,0xbd46b8cb + .long 0x5f9bc000,0x3fc6c1db + .long 0x986fe812,0xbd3994b8 + .long 0x8ecd0000,0x3fc6e148 + .long 0x4fa56719,0x3d54407b + .long 0x2e7e4000,0x3fc70b4b + .long 0xc215a307,0x3d0b8ea3 + .long 0x09144000,0x3fc72ae2 + .long 0x8e443b8a,0x3d55fc4a + .long 0x81bd8000,0x3fc7551c + .long 0xaffc42e9,0x3d3b9ef2 + .long 0x76cc4000,0x3fc774dd + .long 0x8d3f5094,0x3d1ded36 + .long 0x5db00000,0x3fc79f50 + .long 0xdd7a0df9,0x3d3d105d + .long 0xde098000,0x3fc7bf3b + .long 0xf47b93c9,0x3d4f301f + .long 0xcac44000,0x3fc7e9e7 + .long 0x64ca2675,0xbd300eff + .long 0x49030000,0x3fc809fe + .long 0xa2382d7a,0xbd57f954 + .long 0x57998000,0x3fc82a27 + .long 0xa5427ebe,0xbd51a131 + .long 0xc6260000,0x3fc85525 + .long 0x18660d2c,0xbd4f67be + .long 0x79834000,0x3fc8757a + .long 0xe73d6696,0xbd53bc75 + .long 0x058d8000,0x3fc895e2 + .long 0x37dbd0a7,0x3d3c0532 + .long 0x37698000,0x3fc8c134 + .long 0x6534d35a,0xbd55670a + .long 0x12ef0000,0x3fc8e1c8 + .long 0x21fe7581,0x3d595f21 + .long 0x11218000,0x3fc9026f + .long 0xaefa5f2f,0x3d47e805 + .long 0x48888000,0x3fc92329 + .long 0xfa5a2c46,0x3d301501 + .long 0x4b834000,0x3fc94eea + .long 0x142e461b,0xbd361a29 + .long 0xb63a0000,0x3fc96fd1 + .long 0xe74e02a0,0xbd1fb7d8 + .long 0xa6620000,0x3fc990cc + .long 0x8c78b1e9,0x3d54d5fa + .long 0x33334000,0x3fc9b1db + .long 0xf104deb4,0x3d3085fd + .long 0x740e4000,0x3fc9d2fd + .long 0x4be3a88f,0x3d530348 + .long 0xeedc8000,0x3fc9ff49 + .long 0xe2bda395,0x3d5aa98b + .long 0x84fc0000,0x3fca209a + .long 0xb83b532a,0xbd580433 + .long 0x1e440000,0x3fca41ff + .long 0xada9a5e4,0xbd3fa98d + .long 0xd2cec000,0x3fca6377 + .long 0xe131e3b9,0xbd564407 + .long 0xbae0c000,0x3fca8504 + .long 0x018eb699,0x3d49f5f5 + .long 0xeeec0000,0x3fcaa6a5 + .long 0x1db03170,0xbd401d1e + .long 0x878d8000,0x3fcac85b + .long 0x09bf0cc9,0xbd2e1c0b + .long 0x9d900000,0x3fcaea25 + .long 0x1d013253,0xbd27d321 + .long 0x49eb4000,0x3fcb0c04 + .long 0x85567deb,0x3d36d506 + .long 0xa5c50000,0x3fcb2df7 + .long 0xe6dd603b,0x3d14c9cc + .long 0xca710000,0x3fcb4fff + .long 0x81ec1ae1,0xbd4b2ea2 + .long 0xd1714000,0x3fcb721c + .long 0xf660b9da,0x3d47e295 + .long 0xd4780000,0x3fcb944e + .long 0xa337b6c0,0xbd558993 + .long 0xed658000,0x3fcbb695 + .long 0x5395b891,0xbd51c199 + .long 0x364ac000,0x3fcbd8f2 + .long 0xa0feae19,0x3d560784 + .long 0xc96a0000,0x3fcbfb63 + .long 0xd6eafbe6,0xbd36014a + .long 0xc134c000,0x3fcc1dea + .long 0x84f72786,0x3d44e96e + .long 0x384f4000,0x3fcc4087 + .long 0x3f7c716e,0x3d3f006e + .long 0x498f0000,0x3fcc6339 + .long 0x93e69cea,0x3d33c317 + .long 0x0ffc0000,0x3fcc8601 + .long 0x7e3ccfb7,0x3d2dae5f + .long 0x065c4000,0x3fcc9d3d + .long 0xa7bafd57,0x3d4b4180 + .long 0x375b8000,0x3fccc029 + .long 0xfa45fc85,0x3d503cf7 + .long 0x6697c000,0x3fcce32b + .long 0xcc5fc3d0,0xbd5a2df8 + .long 0xafd54000,0x3fcd0643 + .long 0xf7c24bc7,0xbd55fdc6 + .long 0x2f0e0000,0x3fcd2972 + .long 0xc812d894,0xbd45bacd + .long 0x00710000,0x3fcd4cb7 + .long 0x2cb52790,0xbd0bc64a + .long 0xab3f8000,0x3fcd6446 + .long 0x8139913c,0x3d392b7b + .long 0xef71c000,0x3fcd87b0 + .long 0x822c4d80,0x3d4b449e + .long 0xd1fe8000,0x3fcdab31 + .long 0x4f09d1d4,0x3d49a698 + .long 0x6fdc8000,0x3fcdcec9 + .long 0x4231d353,0x3d311dde + .long 0x88764000,0x3fcde690 + .long 0x8e8f9b14,0xbd350c11 + .long 0x4a25c000,0x3fce0a4e + .long 0x1868dfd1,0x3d0ffb66 + .long 0x15754000,0x3fce2e23 + .long 0x6ad712e4,0x3d4e32b0 + .long 0x22d18000,0x3fce4613 + .long 0x75f8b410,0xbd4b758b + .long 0x95c78000,0x3fce6a0e + .long 0x94c67dc7,0xbd2e13dc + .long 0x6243c000,0x3fce8e21 + .long 0xf23f1279,0x3d4d600d + .long 0xf26e0000,0x3fcea63a + .long 0x668806d4,0x3cef1bb1 + .long 0xed160000,0x3fceca74 + .long 0xfe665305,0xbd4f489c + .long 0x92ccc000,0x3fceeec6 + .long 0x1d627f70,0x3d4259f1 + .long 0x36b8c000,0x3fcf070a + .long 0x714687e0,0x3d49c0c3 + .long 0x93e34000,0x3fcf2b83 + .long 0x5715356c,0x3d345a59 + .long 0xef53c000,0x3fcf5014 + .long 0xb6f783a8,0xbd5ad2b5 + .long 0x3af18000,0x3fcf6883 + .long 0x4bcc6e04,0x3d58bfdb + .long 0xd9f3c000,0x3fcf8d3c + .long 0xf63ab05d,0x3d58276d + .long 0x1add8000,0x3fcfa5c6 + .long 0x9beccf8d,0x3d43e926 + .long 0x567e8000,0x3fcfcaa8 + .long 0x362fdd81,0x3d5d3cfe + .long 0xc8744000,0x3fcfe34c + .long 0xc008381c,0xbd113e5f + .long 0xfd74e000,0x3fd0042b + .long 0x617c00f4,0x3d551936 + .long 0xf6a18000,0x3fd016bd + .long 0x52b01c58,0x3cd77bf6 + .long 0x2f906000,0x3fd02326 + .long 0x9269b5c5,0x3d53227c + .long 0xed8d4000,0x3fd035cc + .long 0x46d0dd58,0xbd4abd7e + .long 0x0e86a000,0x3fd04243 + .long 0x07af3e66,0xbcb117c1 + .long 0xc842c000,0x3fd04ebe + .long 0xa51b431d,0xbd4a401d + .long 0xe84fc000,0x3fd06182 + .long 0x4e2f0b29,0x3d54abd9 + .long 0xb609c000,0x3fd06e0c + .long 0xcd12a34d,0x3d538308 + .long 0x0bec8000,0x3fd080e6 + .long 0x7faf9c27,0x3d4e24d8 + .long 0x0d896000,0x3fd08d7e + .long 0xf5dd9bd9,0xbd58cad1 + .long 0xc96a2000,0x3fd0a06c + .long 0xb30ebd03,0x3cf56aec + .long 0x1f3b2000,0x3fd0ad13 + .long 0xf6264d3a,0x3d5c5508 + .long 0x71e78000,0x3fd0c017 + .long 0x801d3fff,0xbd440944 + .long 0x3cad8000,0x3fd0cccc + .long 0x8fd76450,0xbd50b4df + .long 0xd91a4000,0x3fd0d986 + .long 0xeca91a49,0xbd46ae31 + .long 0xb8860000,0x3fd0eca9 + .long 0x0cf1281c,0x3d5a2d53 + .long 0xf87fe000,0x3fd0f972 + .long 0x0e3b7b78,0x3d53d583 + .long 0x1cf0e000,0x3fd10642 + .long 0x36cc41d7,0x3d37dcbc + .long 0xebe28000,0x3fd11983 + .long 0x56ee7372,0x3d453935 + .long 0xe35b8000,0x3fd12661 + .long 0xf97392ab,0xbd3e990a + .long 0xd277a000,0x3fd13345 + .long 0xd681ef76,0xbd2625f2 + .long 0xf5974000,0x3fd146a6 + .long 0x4e1038a4,0xbd57c5c5 + .long 0xe81ea000,0x3fd15399 + .long 0xd5972106,0x3d407ab6 + .long 0xe5d3a000,0x3fd16092 + .long 0x74a3a2b7,0x3d434c04 + .long 0xc3b7a000,0x3fd17413 + .long 0xadcb10c6,0x3d46bb42 + .long 0xf629e000,0x3fd1811b + .long 0xc5305a70,0xbd420a8b + .long 0x47b46000,0x3fd18e2a + .long 0x61f0b069,0x3d3a17c8 + .long 0xbe1a4000,0x3fd19b3e + .long 0x9d0c4bc2,0x3d306106 + .long 0x017cc000,0x3fd1aee9 + .long 0xf7f8b601,0xbd475f35 + .long 0xed714000,0x3fd1bc0c + .long 0x4ef21e21,0xbd463c17 + .long 0x12abc000,0x3fd1c937 + .long 0x61c2e7a5,0x3d3ffdc5 + .long 0x77148000,0x3fd1d667 + .long 0xa4cb0170,0xbd260af0 + .long 0xd1286000,0x3fd1ea3b + .long 0xc64da380,0x3d4c38dc + .long 0xed934000,0x3fd1f77b + .long 0x11c5ddf7,0xbd53b3e4 + .long 0x5e1b0000,0x3fd204c2 + .long 0x7b28110e,0x3d28fa35 + .long 0x28ce8000,0x3fd2120f + .long 0x0bc856ad,0xbd564e99 + .long 0x53c4a000,0x3fd21f62 + .long 0xe0bb0bd9,0xbd52ff6c + .long 0xe51d6000,0x3fd22cbb + .long 0x9c33f19c,0x3d0531fc + .long 0x4c976000,0x3fd240ce + .long 0x4672ee85,0xbd4777b4 + .long 0xf8ece000,0x3fd24e37 + .long 0x8e29bedb,0xbd3461fa + .long 0x215b0000,0x3fd25ba8 + .long 0x2d8bf07a,0xbd4007bf + .long 0xcc2a0000,0x3fd2691e + .long 0xd592a8b0,0xbd4f7b1a + .long 0xffab4000,0x3fd2769b + .long 0x75f34cfe,0xbd520002 + .long 0xc2394000,0x3fd2841f + .long 0xf75ce6c1,0x3d52c96f + .long 0x1a384000,0x3fd291aa + .long 0x73fd8960,0x3d42f012 + .long 0x0e154000,0x3fd29f3b + .long 0xa111a5a3,0x3d584ad4 + .long 0xee47a000,0x3fd2b3a0 + .long 0x875f458c,0xbd2044f7 + .long 0x842c0000,0x3fd2c142 + .long 0xb02650df,0x3d43cbc1 + .long 0xccb7c000,0x3fd2ceea + .long 0xb6dc5d61,0xbd249ad3 + .long 0xce830000,0x3fd2dc99 + .long 0xfe13a4e3,0xbd0beb52 + .long 0x902fc000,0x3fd2ea4f + .long 0x4d1def58,0x3d57d999 + .long 0x186a2000,0x3fd2f80c + .long 0xb0baac1f,0x3d37f290 + .long 0x6de7c000,0x3fd305cf + .long 0x4343671c,0xbd4e1284 + .long 0x97684000,0x3fd31399 + .long 0x31df7b15,0xbd28c485 + .long 0x9bb5a000,0x3fd3216a + .long 0xc8a62d99,0xbd1838f8 + .long 0x81a3c000,0x3fd32f42 + .long 0x7ce7627b,0x3d4dfd72 + .long 0x50110000,0x3fd33d21 + .long 0x0c6b638c,0x3d023363 + .type __libm_log10l_table_256,@object + .size __libm_log10l_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/log1p_gen.S b/external/sgx_libm/intel64/log1p_gen.S new file mode 100644 index 0000000000..ce83de9783 --- /dev/null +++ b/external/sgx_libm/intel64/log1p_gen.S @@ -0,0 +1,574 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log1p_gen.c" + .text +..TXTST0: +# -- Begin log1p + .text + .align 16,0x90 + .globl log1p +log1p: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_log1p.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edi + movl %edi, %edx + andl $2147483647, %edx + cmpl $2146435072, %edx + jae ..B1.24 +..B1.2: + cmpl $-1074790400, %edi + jae ..B1.20 +..B1.3: + cmpl $1068646400, %edx + jae ..B1.16 +..B1.4: + cmpl $1066401792, %edx + jae ..B1.15 +..B1.5: + cmpl $1059061760, %edx + jae ..B1.14 +..B1.6: + cmpl $1012924416, %edx + jae ..B1.13 +..B1.7: + cmpl $1048576, %edx + jb ..B1.9 +..B1.8: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm1 + subsd %xmm1, %xmm0 + ret +..B1.9: + movl -8(%rsp), %eax + orl %eax, %edx + je ..B1.11 +..B1.10: + lea _small_value_64(%rip), %rax + movsd -8(%rsp), %xmm0 + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm1 + movsd %xmm1, -40(%rsp) + subsd %xmm1, %xmm0 + ret +..B1.11: + movsd -8(%rsp), %xmm0 +..B1.12: + ret +..B1.13: + movsd -8(%rsp), %xmm3 + lea 24+_Q3(%rip), %rax + movaps %xmm3, %xmm1 + lea 16+_Q3(%rip), %rcx + mulsd %xmm3, %xmm1 + lea 8+_Q3(%rip), %rdx + movsd (%rax), %xmm0 + lea _Q3(%rip), %rsi + movsd (%rcx), %xmm2 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm2 + addsd (%rdx), %xmm0 + addsd (%rsi), %xmm2 + mulsd %xmm1, %xmm0 + mulsd %xmm3, %xmm2 + movsd %xmm1, -16(%rsp) + addsd %xmm2, %xmm0 + mulsd %xmm3, %xmm0 + addsd %xmm3, %xmm0 + ret +..B1.14: + movsd -8(%rsp), %xmm3 + lea 56+_Q2(%rip), %rdx + movaps %xmm3, %xmm5 + lea 64+_Q2(%rip), %r8 + mulsd %xmm3, %xmm5 + lea 40+_Q2(%rip), %rcx + movsd (%rdx), %xmm6 + lea 48+_Q2(%rip), %r9 + movsd (%r8), %xmm4 + lea 24+_Q2(%rip), %rsi + mulsd %xmm5, %xmm6 + lea 32+_Q2(%rip), %r10 + mulsd %xmm5, %xmm4 + addsd (%rcx), %xmm6 + addsd (%r9), %xmm4 + mulsd %xmm5, %xmm6 + mulsd %xmm5, %xmm4 + addsd (%rsi), %xmm6 + addsd (%r10), %xmm4 + mulsd %xmm5, %xmm6 + mulsd %xmm5, %xmm4 + xorl %eax, %eax + movaps %xmm3, %xmm10 + movl %eax, -8(%rsp) + lea 8+_Q2(%rip), %rdi + movsd -8(%rsp), %xmm0 + lea 16+_Q2(%rip), %r11 + movaps %xmm0, %xmm1 + movaps %xmm0, %xmm7 + mulsd %xmm0, %xmm7 + subsd %xmm0, %xmm10 + addsd (%rdi), %xmm6 + addsd (%r11), %xmm4 + addsd %xmm10, %xmm1 + mulsd %xmm3, %xmm6 + mulsd %xmm5, %xmm4 + mulsd %xmm10, %xmm1 + addsd %xmm4, %xmm6 + movaps %xmm0, %xmm2 + mulsd %xmm10, %xmm2 + mulsd %xmm5, %xmm6 + addsd %xmm1, %xmm2 + addsd %xmm6, %xmm10 + movsd %xmm7, -16(%rsp) + movl %eax, -16(%rsp) + lea _Q2(%rip), %rax + movsd -16(%rsp), %xmm8 + subsd %xmm8, %xmm7 + movsd (%rax), %xmm9 + addsd %xmm2, %xmm7 + mulsd %xmm9, %xmm7 + mulsd %xmm8, %xmm9 + addsd %xmm7, %xmm10 + addsd %xmm9, %xmm0 + movsd %xmm0, -8(%rsp) + addsd %xmm10, %xmm0 + movsd %xmm10, -24(%rsp) + ret +..B1.15: + movsd -8(%rsp), %xmm12 + lea 96+_Q1(%rip), %rcx + movaps %xmm12, %xmm1 + lea 88+_Q1(%rip), %r11 + mulsd %xmm12, %xmm1 + lea _TWO_32P(%rip), %rdx + movsd (%rcx), %xmm2 + lea 80+_Q1(%rip), %rsi + movsd (%r11), %xmm7 + lea 64+_Q1(%rip), %rdi + mulsd %xmm1, %xmm2 + lea 56+_Q1(%rip), %rcx + mulsd %xmm1, %xmm7 + addsd (%rsi), %xmm2 + movsd (%rdx), %xmm4 + lea 72+_Q1(%rip), %rdx + mulsd %xmm1, %xmm2 + lea 48+_Q1(%rip), %r8 + addsd (%rdx), %xmm7 + addsd (%rdi), %xmm2 + mulsd %xmm1, %xmm7 + mulsd %xmm1, %xmm2 + addsd (%rcx), %xmm7 + addsd (%r8), %xmm2 + mulsd %xmm1, %xmm7 + mulsd %xmm1, %xmm2 + lea 40+_Q1(%rip), %rsi + lea 32+_Q1(%rip), %r9 + lea 24+_Q1(%rip), %rdi + lea _TWO_32(%rip), %rax + movaps %xmm12, %xmm0 + movaps %xmm12, %xmm6 + mulsd %xmm4, %xmm0 + lea 16+_Q1(%rip), %r10 + addsd (%rsi), %xmm7 + mulsd (%rax), %xmm6 + addsd (%r9), %xmm2 + mulsd %xmm1, %xmm7 + mulsd %xmm1, %xmm2 + addsd (%rdi), %xmm7 + addsd (%r10), %xmm2 + mulsd %xmm1, %xmm7 + mulsd %xmm1, %xmm2 + lea 8+_Q1(%rip), %r8 + lea 112+_Q1(%rip), %r9 + movsd %xmm0, -40(%rsp) + movaps %xmm12, %xmm3 + movsd -40(%rsp), %xmm5 + lea 104+_Q1(%rip), %r10 + movaps %xmm4, %xmm9 + subsd %xmm6, %xmm5 + addsd (%r8), %xmm7 + subsd %xmm5, %xmm3 + mulsd %xmm12, %xmm7 + mulsd %xmm3, %xmm12 + addsd %xmm7, %xmm2 + movsd (%r9), %xmm11 + movaps %xmm5, %xmm15 + movaps %xmm11, %xmm8 + mulsd %xmm5, %xmm11 + mulsd %xmm3, %xmm8 + mulsd %xmm3, %xmm15 + addsd (%r10), %xmm11 + addsd %xmm8, %xmm2 + addsd %xmm12, %xmm15 + movaps %xmm11, %xmm10 + movaps %xmm15, %xmm14 + movsd (%rax), %xmm13 + addsd %xmm2, %xmm10 + mulsd %xmm10, %xmm9 + mulsd %xmm13, %xmm10 + movsd %xmm9, -40(%rsp) + movsd -40(%rsp), %xmm0 + movsd %xmm5, -8(%rsp) + subsd %xmm10, %xmm0 + movaps %xmm5, %xmm10 + subsd %xmm0, %xmm11 + mulsd %xmm5, %xmm10 + addsd %xmm11, %xmm2 + addsd %xmm10, %xmm14 + mulsd %xmm1, %xmm2 + mulsd %xmm14, %xmm4 + mulsd %xmm13, %xmm14 + movsd %xmm4, -40(%rsp) + movsd -40(%rsp), %xmm4 + movsd %xmm3, -24(%rsp) + subsd %xmm14, %xmm4 + movsd %xmm1, -16(%rsp) + subsd %xmm4, %xmm10 + addsd %xmm15, %xmm10 + mulsd %xmm0, %xmm10 + mulsd %xmm4, %xmm0 + addsd %xmm2, %xmm10 + addsd %xmm5, %xmm0 + addsd %xmm3, %xmm10 + movsd %xmm0, -32(%rsp) + addsd %xmm10, %xmm0 + ret +..B1.16: + cmpl $1130364928, %edx + jae ..B1.18 +..B1.17: + lea _ones(%rip), %rcx + pxor %xmm1, %xmm1 + movsd -8(%rsp), %xmm7 + xorl %esi, %esi + movq __libm_rcp_table_256@GOTPCREL(%rip), %rdi + lea 8+_ones(%rip), %r8 + movl %esi, -8(%rsp) + lea _TWO_32(%rip), %r9 + movsd (%rcx), %xmm0 + movsd -8(%rsp), %xmm5 + addsd %xmm7, %xmm0 + subsd %xmm5, %xmm7 + movsd %xmm0, -32(%rsp) + movl -28(%rsp), %eax + movl %eax, %edx + andl $2146435072, %edx + movl %eax, %ecx + negl %edx + shrl $12, %eax + addl $2145386496, %edx + movl %edx, -28(%rsp) + movzbl %al, %edx + movl %esi, -32(%rsp) + movsd (%r8), %xmm2 + movsd (%r9), %xmm3 + cvtss2sd (%rdi,%rdx,4), %xmm1 + mulsd -32(%rsp), %xmm1 + mulsd %xmm1, %xmm5 + addsd %xmm1, %xmm2 + mulsd %xmm1, %xmm7 + addsd %xmm2, %xmm5 + movaps %xmm5, %xmm4 + movsd %xmm5, -16(%rsp) + addsd %xmm7, %xmm4 + movsd %xmm4, -8(%rsp) + addsd %xmm3, %xmm4 + movsd %xmm4, -40(%rsp) + movsd -40(%rsp), %xmm6 + shrl $20, %ecx + subsd (%r9), %xmm6 + movsd %xmm7, -24(%rsp) + addl $-1023, %ecx + movsd %xmm2, -32(%rsp) + subsd %xmm6, %xmm5 + addsd %xmm5, %xmm7 + jmp ..B1.19 +..B1.18: + movl %edx, %ecx + pxor %xmm0, %xmm0 + shrl $12, %edx + andl $1048575, %edi + movzbl %dl, %edx + orl $1072693248, %edi + movq __libm_rcp_table_256@GOTPCREL(%rip), %rax + lea 8+_ones(%rip), %r8 + movl %edi, -4(%rsp) + shlq $32, %rdi + movl -8(%rsp), %esi + orq %rsi, %rdi + cvtss2sd (%rax,%rdx,4), %xmm0 + movq %rdi, -24(%rsp) + movl $0, -8(%rsp) + movsd -8(%rsp), %xmm6 + movsd -24(%rsp), %xmm7 + shrl $20, %ecx + subsd %xmm6, %xmm7 + mulsd %xmm0, %xmm6 + mulsd %xmm0, %xmm7 + addsd (%r8), %xmm6 + movsd %xmm0, -32(%rsp) + addl $-1023, %ecx +..B1.19: + movaps %xmm6, %xmm0 + lea 32+_P(%rip), %rsi + lea 24+_P(%rip), %r9 + lea 16+_P(%rip), %rdi + lea 8+_P(%rip), %r10 + lea _P(%rip), %r8 + lea 8+_LN2(%rip), %r11 + addsd %xmm7, %xmm0 + movaps %xmm0, %xmm1 + mulsd %xmm0, %xmm1 + movsd (%rsi), %xmm3 + mulsd %xmm1, %xmm3 + movsd (%r9), %xmm2 + mulsd %xmm1, %xmm2 + addsd (%rdi), %xmm3 + mulsd %xmm1, %xmm3 + addsd (%r10), %xmm2 + mulsd %xmm0, %xmm2 + addsd (%r8), %xmm3 + pxor %xmm0, %xmm0 + cvtsi2sd %ecx, %xmm0 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm2 + lea _LN2(%rip), %rcx + addsd %xmm2, %xmm3 + movsd (%rcx), %xmm4 + addsd %xmm3, %xmm7 + mulsd %xmm0, %xmm4 + movsd (%r11), %xmm5 + mulsd %xmm5, %xmm0 + shlq $4, %rdx + movq __libm_log_table_256@GOTPCREL(%rip), %rax + movsd %xmm1, -16(%rsp) + addsd (%rax,%rdx), %xmm4 + addsd 8(%rax,%rdx), %xmm0 + addsd %xmm4, %xmm7 + addsd %xmm6, %xmm0 + movsd %xmm0, -8(%rsp) + addsd %xmm7, %xmm0 + movsd %xmm7, -24(%rsp) + ret +..B1.20: + lea _zeros(%rip), %rax + addl $-1072693248, %edx + orl -8(%rsp), %edx + movsd (%rax), %xmm1 + jne ..B1.22 +..B1.21: + lea 8+_ones(%rip), %rax + movsd (%rax), %xmm0 + divsd %xmm1, %xmm0 + ret +..B1.22: + lea _infs(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm1, %xmm0 +..B1.23: + ret +..B1.24: + addl $1048576, %edi + orl -8(%rsp), %edi + je ..B1.27 +..B1.25: + lea _ones(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 +..B1.26: + ret +..B1.27: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type log1p,@function + .size log1p,.-log1p + .data +# -- End log1p + .section .rodata, "a" + .align 4 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_Q3: + .long 0 + .long 3219128320 + .long 1431655765 + .long 1070945621 + .long 55924054 + .long 3218079744 + .long 2711205044 + .long 1070176665 + .type _Q3,@object + .size _Q3,32 + .align 4 +_Q2: + .long 0 + .long 3219128320 + .long 1431655765 + .long 1070945621 + .long 4294967292 + .long 3218079743 + .long 2577017633 + .long 1070176665 + .long 1431726806 + .long 3217380693 + .long 2027016470 + .long 1069697316 + .long 3108735575 + .long 3217031167 + .long 1449976333 + .long 1069315434 + .long 60833854 + .long 3216612762 + .type _Q2,@object + .size _Q2,72 + .align 4 +_Q1: + .long 3234281536 + .long 3150348867 + .long 1430600241 + .long 1047876949 + .long 4294967294 + .long 3218079743 + .long 2576981961 + .long 1070176665 + .long 1431660017 + .long 3217380693 + .long 2452398325 + .long 1069697316 + .long 4287730462 + .long 3217031167 + .long 2576343554 + .long 1069314503 + .long 1474253516 + .long 3216611738 + .long 2720006255 + .long 1068975428 + .long 1874652295 + .long 3216331940 + .long 2893691300 + .long 1068761010 + .long 1325424864 + .long 3216153938 + .long 0 + .long 3219128320 + .long 0 + .long 1070945621 + .type _Q1,@object + .size _Q1,120 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_P: + .long 0 + .long 3219128320 + .long 1431621855 + .long 1070945621 + .long 4294842013 + .long 3218079743 + .long 1289448124 + .long 1070176674 + .long 2077359316 + .long 3217380703 + .type _P,@object + .size _P,40 + .align 4 +_LN2: + .long 897137782 + .long 1038760431 + .long 4276092928 + .long 1072049730 + .type _LN2,@object + .size _LN2,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log1pf_gen.S b/external/sgx_libm/intel64/log1pf_gen.S new file mode 100644 index 0000000000..9eace98e22 --- /dev/null +++ b/external/sgx_libm/intel64/log1pf_gen.S @@ -0,0 +1,163 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log1pf_gen.c" + .text +..TXTST0: +# -- Begin log1pf + .text + .align 16,0x90 + .globl log1pf +log1pf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_log1pf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + pxor %xmm2, %xmm2 + cvtss2sd %xmm0, %xmm2 + movd %xmm0, %eax + movaps %xmm2, %xmm1 + andl $2147483647, %eax + cmpl $2139095040, %eax + andps .L_2il0floatpacket.6(%rip), %xmm1 + ja ..B1.9 +..B1.2: + movsd .L_2il0floatpacket.0(%rip), %xmm0 + comisd %xmm2, %xmm0 + jb ..B1.5 +..B1.3: + ucomisd %xmm0, %xmm2 + jp ..B1.4 + je ..B1.10 +..B1.4: + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.3(%rip), %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B1.5: + comisd .L_2il0floatpacket.1(%rip), %xmm1 + jb ..B1.7 +..B1.6: + movsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd %xmm2, %xmm0 + call log@PLT +..B1.13: + cvtsd2ss %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B1.7: + movaps %xmm2, %xmm1 + pxor %xmm0, %xmm0 + mulsd %xmm2, %xmm1 + mulsd .L_2il0floatpacket.4(%rip), %xmm1 + subsd %xmm1, %xmm2 + cvtsd2ss %xmm2, %xmm0 +..B1.8: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B1.9: + addss %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 16 +..B1.10: + movss .L_2il0floatpacket.2(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type log1pf,@function + .size log1pf,.-log1pf + .data +# -- End log1pf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.6: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3e300000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 4 +.L_2il0floatpacket.2: + .long 0xbf800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x7f800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log1pl.S b/external/sgx_libm/intel64/log1pl.S new file mode 100644 index 0000000000..4cfbf09a90 --- /dev/null +++ b/external/sgx_libm/intel64/log1pl.S @@ -0,0 +1,1027 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log1pl.c" + .text +..TXTST0: +# -- Begin log1pl + .text + .align 16,0x90 + .globl log1pl +log1pl: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_log1pl.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %cl, %cl +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movzbl 105(%rsp), %r8d + andl $128, %r8d + shrl $7, %r8d + movl %r8d, %edi + movzwl 104(%rsp), %esi + shll $15, %edi + andl $32767, %esi + orl %esi, %edi + shll $16, %edi + movzwl 102(%rsp), %eax + orl %eax, %edi + movzwl 82(%rsp), %eax + cmpl $32767, %esi + je ..B1.71 +..B1.4: + cmpl $-1073774592, %edi + jae ..B1.57 +..B1.5: + cmpl $16379, %esi + jge ..B1.47 +..B1.6: + cmpl $16369, %esi + jge ..B1.40 +..B1.7: + cmpl $16358, %esi + jge ..B1.33 +..B1.8: + cmpl $16345, %esi + jge ..B1.26 +..B1.9: + cmpl $16308, %esi + jge ..B1.19 +..B1.10: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.14 +..B1.11: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.12: + fldcw 80(%rsp) +..B1.13: + movzwl 104(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.14: + testl %esi, %esi + jle ..B1.67 +..B1.15: + fldt 96(%rsp) + lea _TWO_75(%rip), %rax + movb 105(%rsp), %dl + lea _ones(%rip), %rsi + andb $-128, %dl + lea 8+_TWO_75(%rip), %r8 + shrb $7, %dl + fldl (%rax) + fmul %st(1), %st + movzbl %dl, %edi + fxch %st(1) + fmull (%rsi,%rdi,8) + fsubrp %st, %st(1) + fmull (%r8) + fstpt (%rsp) +..B1.16: + testb %cl, %cl + je ..B1.18 +..B1.17: + fldcw 82(%rsp) +..B1.18: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.19: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.23 +..B1.20: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.21: + fldcw 80(%rsp) +..B1.22: + movb $1, %cl +..B1.23: + fldt 96(%rsp) + lea _Q3(%rip), %rax + lea _TWO_75(%rip), %rdx + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fadd %st(1), %st + fstpt (%rsp) + fldl (%rdx) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.25 +..B1.24: + fldcw 82(%rsp) +..B1.25: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.26: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.30 +..B1.27: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.28: + fldcw 80(%rsp) +..B1.29: + movb $1, %cl +..B1.30: + fldt 96(%rsp) + lea 16+_Q2(%rip), %rax + lea _Q2(%rip), %rdx + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.32 +..B1.31: + fldcw 82(%rsp) +..B1.32: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.33: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.37 +..B1.34: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.35: + fldcw 80(%rsp) +..B1.36: + movb $1, %cl +..B1.37: + fldt 96(%rsp) + lea 48+_Q1(%rip), %rax + fld %st(0) + lea 32+_Q1(%rip), %rsi + fmul %st(1), %st + lea 16+_Q1(%rip), %rdx + fldt (%rax) + lea _Q1(%rip), %rdi + fmul %st(1), %st + testb %cl, %cl + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.39 +..B1.38: + fldcw 82(%rsp) +..B1.39: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.40: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.44 +..B1.41: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.42: + fldcw 80(%rsp) +..B1.43: + movb $1, %cl +..B1.44: + fldt 96(%rsp) + lea _TWO_52H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea 208+_Q(%rip), %rdi + lea 176+_Q(%rip), %r8 + lea 144+_Q(%rip), %r9 + fldl (%rax) + lea 112+_Q(%rip), %r10 + fmul %st(4), %st + lea 80+_Q(%rip), %r11 + lea 48+_Q(%rip), %rax + lea 224+_Q(%rip), %rsi + lea 240+_Q(%rip), %rdx + testb %cl, %cl + fadd %st, %st(3) + fsubrp %st, %st(3) + fld %st(2) + fxch %st(2) + fsub %st(3), %st + fmul %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fxch %st(3) + fstpt 32(%rsp) + fldt 32(%rsp) + fmul %st(0), %st + fstpt 64(%rsp) + fldt 64(%rsp) + faddp %st, %st(3) + fstpt 48(%rsp) + fldt (%rdx) + lea 16+_Q(%rip), %rdx + fmul %st, %st(1) + fldt (%rsi) + lea 192+_Q(%rip), %rsi + fldt (%rdi) + lea 160+_Q(%rip), %rdi + fmul %st(4), %st + fldt (%r8) + lea 128+_Q(%rip), %r8 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r9) + lea 96+_Q(%rip), %r9 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r10) + lea 64+_Q(%rip), %r10 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r11) + lea 32+_Q(%rip), %r11 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rax) + lea _Q(%rip), %rax + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rsi) + fmul %st(5), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(5) + fld %st(1) + fldt (%rax) + faddp %st, %st(6) + fxch %st(5) + fmul %st(6), %st + faddp %st, %st(1) + faddp %st, %st(3) + fldt 48(%rsp) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(4) + fldt 64(%rsp) + fmulp %st, %st(1) + fldt 32(%rsp) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(2) + fmul %st(1), %st + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.46 +..B1.45: + fldcw 82(%rsp) +..B1.46: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.47: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.51 +..B1.48: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.49: + fldcw 80(%rsp) +..B1.50: + movzbl 105(%rsp), %r8d + movb $1, %cl + andl $128, %r8d + shrl $7, %r8d +..B1.51: + lea ranges(%rip), %rax + cmpl (%rax,%r8,4), %edi + jae ..B1.53 +..B1.52: + fldt 96(%rsp) + xorl %edi, %edi + movzwl 104(%rsp), %eax + lea _shifters(%rip), %rsi + andl $32767, %eax + fld %st(0) + addl $-16415, %eax + lea zero_one(%rip), %r8 + lea _ones(%rip), %r9 + setl %dil + fldl (%r9) + fstpt (%rsp) + fldl (%rsi,%rdi,8) + fmul %st(2), %st + movzwl 8(%rsp), %r11d + fadd %st, %st(1) + andl $-32768, %r11d + fsubrp %st, %st(1) + movq __libm_rcp_table_256@GOTPCREL(%rip), %rsi + fsubr %st, %st(1) + faddl (%r8,%rdi,8) + xorl $1, %edi + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(1) + faddl (%r8,%rdi,8) + fadd %st, %st(1) + fxch %st(1) + fstpt 96(%rsp) + movzwl 104(%rsp), %edx + andl $32767, %edx + movl %edx, %r10d + addl $-16383, %edx + negl %r10d + movl 100(%rsp), %eax + addl $-2, %r10d + shrl $23, %eax + andl $32767, %r10d + movzbl %al, %eax + orl %r10d, %r11d + movw %r11w, 8(%rsp) + fldt (%rsp) + fmuls (%rsi,%rax,4) + jmp ..B1.54 +..B1.53: + fldt 96(%rsp) + lea zero_one(%rip), %rdx + lea _TWO_32H(%rip), %rdi + faddl (%rdx,%r8,8) + fstpt 96(%rsp) + fldl (%rdi) + movzwl 104(%rsp), %eax + movl %eax, %edx + andl $-32768, %eax + andl $32767, %edx + orl $-49153, %eax + addl $-16383, %edx + movw %ax, 104(%rsp) + fldt 96(%rsp) + fld %st(0) + movl 100(%rsp), %esi + fadd %st(2), %st + shrl $23, %esi + fsubp %st, %st(2) + movzbl %sil, %eax + fsub %st(1), %st + movq __libm_rcp_table_256@GOTPCREL(%rip), %r8 + fxch %st(1) + fstpt 32(%rsp) + flds (%r8,%rax,4) +..B1.54: + fldt 32(%rsp) + lea 8+_ones(%rip), %rsi + fmul %st(1), %st + lea 48+_P(%rip), %rdi + fxch %st(2) + fmulp %st, %st(1) + fxch %st(1) + faddl (%rsi) + fld %st(0) + lea 16+_P(%rip), %r8 + movl %edx, 48(%rsp) + lea 80+_P(%rip), %rdx + lea 64+_P(%rip), %r9 + lea 32+_P(%rip), %r10 + lea _P(%rip), %r11 + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fildl 48(%rsp) + fldt (%rdx) + fmul %st(3), %st + fldt (%rdi) + shlq $4, %rax + faddp %st, %st(1) + fmul %st(3), %st + testb %cl, %cl + fldt (%r8) + movq __libm_logl_table_256@GOTPCREL(%rip), %rdx + faddp %st, %st(1) + fmul %st(3), %st + fmulp %st, %st(2) + fldt (%r9) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fldt .L_2il0floatpacket.0(%rip) + fmul %st(1), %st + fldt .L_2il0floatpacket.1(%rip) + fmulp %st, %st(2) + faddl 8(%rdx,%rax) + faddp %st, %st(3) + faddl (%rax,%rdx) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + je ..B1.56 +..B1.55: + fldcw 82(%rsp) +..B1.56: + fldt 32(%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.57: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.61 +..B1.58: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.59: + fldcw 80(%rsp) +..B1.60: + movb $1, %cl +..B1.61: + fldt 96(%rsp) + lea 8+_ones(%rip), %rdx + lea _zeros(%rip), %rax + fldl (%rdx) + movsd (%rdx), %xmm0 + movsd (%rax), %xmm1 + fucomip %st(1), %st + fstp %st(0) + jp ..B1.62 + je ..B1.63 +..B1.62: + lea _infs(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm1, %xmm0 + movsd %xmm0, 48(%rsp) + fldl 48(%rsp) + fstpt (%rsp) + jmp ..B1.64 +..B1.63: + divsd %xmm1, %xmm0 + movsd %xmm0, 48(%rsp) + fldl 48(%rsp) + fstpt (%rsp) +..B1.64: + testb %cl, %cl + je ..B1.66 +..B1.65: + fldcw 82(%rsp) +..B1.66: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.67: + cmpl $0, 100(%rsp) + jne ..B1.69 +..B1.68: + cmpl $0, 96(%rsp) + je ..B1.70 +..B1.69: + fldt 96(%rsp) + lea _TWO_75(%rip), %rdx + movb 105(%rsp), %sil + lea _ones(%rip), %rdi + andb $-128, %sil + lea _small_value_80(%rip), %rax + lea 8+_TWO_75(%rip), %r9 + fldl (%rdx) + shrb $7, %sil + fmul %st(1), %st + fldt (%rax) + fmul %st(0), %st + movzbl %sil, %r8d + fstpt 16(%rsp) + fxch %st(1) + fmull (%rdi,%r8,8) + fsubrp %st, %st(1) + fmull (%r9) + fstpt (%rsp) + jmp ..B1.16 +..B1.70: + fldt 96(%rsp) + fstpt (%rsp) + jmp ..B1.16 +..B1.71: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.75 +..B1.72: + orl $-64768, %eax + movw %ax, 80(%rsp) +..B1.73: + fldcw 80(%rsp) +..B1.74: + movzbl 105(%rsp), %r8d + movb $1, %cl + andl $128, %r8d + shrl $7, %r8d +..B1.75: + testl %r8d, %r8d + je ..B1.78 +..B1.76: + cmpl $-2147483648, 100(%rsp) + jne ..B1.78 +..B1.77: + cmpl $0, 96(%rsp) + je ..B1.82 +..B1.78: + fldt 96(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.79: + testb %cl, %cl + je ..B1.81 +..B1.80: + fldcw 82(%rsp) +..B1.81: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.82: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 48(%rsp) + fldl 48(%rsp) + fstpt (%rsp) + jmp ..B1.79 + .align 16,0x90 + .cfi_endproc + .type log1pl,@function + .size log1pl,.-log1pl + .data +# -- End log1pl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xdc,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +zero_one: + .long 0x00000000,0x00000000 + .long 0x00000000,0x3ff00000 + .type zero_one,@object + .size zero_one,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +ranges: + .long 1078558720 + .long 3221127168 + .type ranges,@object + .size ranges,8 + .align 4 +_shifters: + .long 0 + .long 1098383360 + .long 0 + .long 1123549184 + .type _shifters,@object + .size _shifters,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_Q3: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 4096 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 53521 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 65509 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 43631 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 43690 + .word 6 + .word 32768 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 60885 + .word 52536 + .word 52444 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 14363 + .word 62279 + .word 27629 + .word 62293 + .word 49080 + .word 0 + .word 0 + .word 0 + .word 44555 + .word 43690 + .word 43690 + .word 43690 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 64968 + .word 65535 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 50395 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 39590 + .word 43714 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 15749 + .word 18782 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 61040 + .word 7204 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 10454 + .word 61175 + .word 14561 + .word 58254 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 57771 + .word 22430 + .word 52985 + .word 52428 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 7036 + .word 15828 + .word 36565 + .word 47662 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 17194 + .word 46991 + .word 54030 + .word 43687 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 63541 + .word 11931 + .word 21910 + .word 40326 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 36457 + .word 1697 + .word 61895 + .word 37932 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 65454 + .word 16107 + .word 6024 + .word 35469 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,256 + .align 2 +_P: + .word 65 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 44010 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 58670 + .word 61414 + .word 65535 + .word 65535 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24905 + .word 46201 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 57053 + .word 27587 + .word 64478 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 41508 + .word 48914 + .word 32459 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,96 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log2_gen.S b/external/sgx_libm/intel64/log2_gen.S new file mode 100644 index 0000000000..e1907d9c6f --- /dev/null +++ b/external/sgx_libm/intel64/log2_gen.S @@ -0,0 +1,774 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2_gen.c" + .text +..TXTST0: +# -- Begin log2 + .text + .align 16,0x90 + .globl log2 +log2: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_log2.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movl $1069088768, %ecx + movd %rcx, %xmm7 + movapd HIGHSIGMASK(%rip), %xmm5 + movq $0x77f0000000000000, %rdx + movd %rdx, %xmm3 + movl $32768, %r9d + movd %r9, %xmm4 + movq %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $16352, %ecx + psrlq $27, %xmm0 + movq LOG2_E(%rip), %xmm2 + psrld $2, %xmm0 + rcpps %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + mulss %xmm7, %xmm0 + orpd %xmm3, %xmm1 + lea L_tbl(%rip), %r11 + andpd %xmm1, %xmm5 + paddd %xmm4, %xmm0 + subsd %xmm5, %xmm1 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm6, %xmm0 + andl $32752, %eax + subl %ecx, %eax + sarl $4, %eax + cvtsi2sd %eax, %xmm7 + mulpd %xmm0, %xmm5 + mulsd %xmm0, %xmm1 + movapd coeff(%rip), %xmm3 + subsd %xmm2, %xmm5 + andl $16711680, %edx + shrl $12, %edx + movapd -912(%r11,%rdx), %xmm0 + movapd 16+coeff(%rip), %xmm4 + addsd %xmm5, %xmm1 + movapd 32+coeff(%rip), %xmm2 + movq $0xbf5dabe1161bb241, %r8 + movd %r8, %xmm6 + movapd %xmm1, %xmm5 + unpcklpd %xmm1, %xmm5 + mulsd %xmm1, %xmm3 + addsd %xmm7, %xmm0 + mulpd %xmm5, %xmm4 + mulpd %xmm5, %xmm5 + addpd %xmm2, %xmm4 + mulpd %xmm5, %xmm3 + movapd %xmm0, %xmm7 + unpcklpd %xmm0, %xmm7 + addsd %xmm1, %xmm0 + mulsd %xmm1, %xmm4 + subsd %xmm0, %xmm7 + mulsd %xmm1, %xmm6 + pshufd $238, %xmm0, %xmm2 + addsd %xmm7, %xmm1 + mulsd %xmm5, %xmm5 + addpd %xmm3, %xmm4 + addsd %xmm6, %xmm2 + mulpd %xmm5, %xmm4 + addsd %xmm2, %xmm1 + addsd %xmm4, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + movq (%rsp), %xmm0 + movq (%rsp), %xmm1 + addl $16, %eax + cmpl $32768, %eax + jae .L_2TAG_PACKET_2.0.2 + cmpl $16, %eax + jb .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_4.0.2: + addsd %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_5.0.2: + ja .L_2TAG_PACKET_4.0.2 + cmpl $0, %edx + ja .L_2TAG_PACKET_4.0.2 + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_2.0.2: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + addl %ecx, %ecx + cmpl $-2097152, %ecx + jae .L_2TAG_PACKET_5.0.2 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.2 +.L_2TAG_PACKET_6.0.2: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + movl $171, 16(%rsp) + mulsd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_8.0.2 +.L_2TAG_PACKET_7.0.2: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + divsd %xmm1, %xmm0 + movl $170, 16(%rsp) + jmp .L_2TAG_PACKET_8.0.2 +.L_2TAG_PACKET_3.0.2: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.2 + xorpd %xmm1, %xmm1 + movl $18416, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + xorpd %xmm2, %xmm2 + movl $16368, %eax + pinsrw $3, %eax, %xmm2 + movq %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $18416, %ecx + psrlq $27, %xmm0 + movq LOG2_E(%rip), %xmm2 + psrld $2, %xmm0 + rcpps %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $78, %xmm5, %xmm6 + psrlq $12, %xmm1 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_8.0.2: + movq %xmm0, 8(%rsp) +..B1.3: + movq 8(%rsp), %xmm0 +.L_2TAG_PACKET_9.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type log2,@function + .size log2,.-log2 + .data +# -- End log2 + .section .rodata, "a" + .align 16 + .align 16 +HIGHSIGMASK: + .long 4160749568 + .long 4294967295 + .long 0 + .long 4294959104 + .type HIGHSIGMASK,@object + .size HIGHSIGMASK,16 + .align 16 +LOG2_E: + .long 0 + .long 1073160192 + .long 370913857 + .long 3210587105 + .type LOG2_E,@object + .size LOG2_E,16 + .align 16 +L_tbl: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 3065110528 + .long 1072676937 + .long 969155058 + .long 1027421928 + .long 3789631488 + .long 1072660714 + .long 1061361078 + .long 1026032326 + .long 2461925376 + .long 1072644578 + .long 1624763829 + .long 3175910818 + .long 3729080320 + .long 1072628527 + .long 1845599454 + .long 1028591843 + .long 3710689280 + .long 1072612561 + .long 3776236642 + .long 1025648432 + .long 2882404352 + .long 1072596679 + .long 3683226528 + .long 3174591570 + .long 1779716096 + .long 1072580880 + .long 1916484889 + .long 3173934989 + .long 996708352 + .long 1072565163 + .long 716999656 + .long 3175673444 + .long 1184837632 + .long 1072549527 + .long 1973599317 + .long 3174949482 + .long 3051761664 + .long 1072533971 + .long 1437348984 + .long 1028530411 + .long 3065225216 + .long 1072518495 + .long 1219343899 + .long 1028525753 + .long 2041864192 + .long 1072503098 + .long 388496599 + .long 3175919551 + .long 851140608 + .long 1072487779 + .long 2822909360 + .long 3173772990 + .long 414302208 + .long 1072472537 + .long 1306322068 + .long 1026235748 + .long 1703325696 + .long 1072457371 + .long 1651655805 + .long 3174368281 + .long 1444937728 + .long 1072442281 + .long 1145646243 + .long 3175573309 + .long 709566464 + .long 1072427266 + .long 3608295147 + .long 3168585112 + .long 615415808 + .long 1072412325 + .long 2957847316 + .long 1027961637 + .long 2327523328 + .long 1072397457 + .long 3266875511 + .long 3175163169 + .long 2761863168 + .long 1072382662 + .long 3329930550 + .long 1027790656 + .long 3174416384 + .long 1072367939 + .long 3349298596 + .long 3172501429 + .long 570335232 + .long 1072353288 + .long 905028281 + .long 3175970581 + .long 588005376 + .long 1072338707 + .long 40558280 + .long 1022275054 + .long 318357504 + .long 1072324196 + .long 3000963593 + .long 3175644723 + .long 1188933632 + .long 1072309754 + .long 1152643439 + .long 3171407768 + .long 373186560 + .long 1072295381 + .long 3440409283 + .long 3174861647 + .long 3674587136 + .long 1072281075 + .long 1985407462 + .long 1026124611 + .long 4051050496 + .long 1072266837 + .long 2734481544 + .long 1026856954 + .long 3089022976 + .long 1072252666 + .long 3365453112 + .long 1028135364 + .long 2412838912 + .long 1072238561 + .long 1203709499 + .long 3175656792 + .long 3683999744 + .long 1072224521 + .long 4237943120 + .long 3176014210 + .long 10571776 + .long 1072210547 + .long 1358548904 + .long 3174161579 + .long 1716314112 + .long 1072196636 + .long 1192519078 + .long 3175777045 + .long 1980272640 + .long 1072182789 + .long 1567013979 + .long 3174472130 + .long 2605957120 + .long 1072169005 + .long 1671600287 + .long 1028158963 + .long 1135812608 + .long 1072155284 + .long 1547709291 + .long 3174179085 + .long 3735490560 + .long 1072141624 + .long 2225392115 + .long 1027056729 + .long 3718443008 + .long 1072128026 + .long 3797315894 + .long 3175978381 + .long 3020144640 + .long 1072114489 + .long 569231379 + .long 3176080301 + .long 3607605248 + .long 1072101012 + .long 2931542967 + .long 1028585043 + .long 3183849472 + .long 1072087595 + .long 1779595699 + .long 1025078612 + .long 3777277952 + .long 1072074237 + .long 3836888569 + .long 3176101128 + .long 3151212544 + .long 1072060938 + .long 4204238866 + .long 1027628024 + .long 3393323008 + .long 1072047697 + .long 3590952967 + .long 1024914744 + .long 2325151744 + .long 1072034514 + .long 2081953065 + .long 1024436445 + .long 2091569152 + .long 1072021388 + .long 1869579321 + .long 3176039801 + .long 570331136 + .long 1072008319 + .long 1169272038 + .long 1028145343 + .long 4256530432 + .long 1071995305 + .long 3897289024 + .long 3171837174 + .long 2492289024 + .long 1071982348 + .long 3892405903 + .long 3175484647 + .long 1826058240 + .long 1071969446 + .long 4079999923 + .long 3175326622 + .long 242364416 + .long 1071956599 + .long 850820968 + .long 3175983841 + .long 46260224 + .long 1071943806 + .long 2164938638 + .long 1028426857 + .long 3567947776 + .long 1071931066 + .long 2011723452 + .long 1028083988 + .long 277430272 + .long 1071918381 + .long 2531435800 + .long 3169601318 + .long 1143848960 + .long 1071905748 + .long 294923185 + .long 1023738369 + .long 4275343360 + .long 1071893167 + .long 2459435756 + .long 1028412742 + .long 3508592640 + .long 1071880639 + .long 503755275 + .long 3173140530 + .long 1293312000 + .long 1071868163 + .long 3333822795 + .long 1026993594 + .long 101961728 + .long 1071855738 + .long 2904005851 + .long 1027338469 + .long 2429362176 + .long 1071843363 + .long 1235892196 + .long 3175679811 + .long 2202386432 + .long 1071831039 + .long 2295142960 + .long 1028565357 + .long 1959501824 + .long 1071818765 + .long 254808788 + .long 1028157588 + .long 4260454400 + .long 1071806540 + .long 1281464327 + .long 3173548784 + .long 3096002560 + .long 1071794365 + .long 2126040068 + .long 3168834094 + .long 1067458560 + .long 1071782239 + .long 957416402 + .long 3171516564 + .long 796413952 + .long 1071770161 + .long 3663270514 + .long 1026937343 + .long 629456896 + .long 1071758131 + .long 2081311685 + .long 1026861414 + .long 3227787264 + .long 1071746148 + .long 325239760 + .long 3175812466 + .long 2681995264 + .long 1071734213 + .long 692600417 + .long 1028316258 + .long 1691656192 + .long 1071722325 + .long 2854288619 + .long 3174069820 + .long 2975059968 + .long 1071710483 + .long 2357806657 + .long 3175896595 + .long 1853362176 + .long 1071686938 + .long 182026883 + .long 3174676055 + .long 4247105536 + .long 1071663574 + .long 1264810745 + .long 1026738550 + .long 671424512 + .long 1071636109 + .long 321222784 + .long 1028039985 + .long 4092968960 + .long 1071590092 + .long 3658154599 + .long 3175856095 + .long 193347584 + .long 1071544424 + .long 723354347 + .long 3173824323 + .long 985587712 + .long 1071499097 + .long 2344377442 + .long 1027857554 + .long 1801297920 + .long 1071454107 + .long 2398211919 + .long 3175430015 + .long 2750758912 + .long 1071409449 + .long 223148174 + .long 1028267694 + .long 118882304 + .long 1071365119 + .long 1958423088 + .long 1026816298 + .long 3531350016 + .long 1071321110 + .long 875023512 + .long 1027316085 + .long 1581752320 + .long 1071277420 + .long 345754833 + .long 1027657950 + .long 473587712 + .long 1071234043 + .long 3024467474 + .long 3175496105 + .long 2533163008 + .long 1071190974 + .long 3279280870 + .long 3173991880 + .long 1902854144 + .long 1071148210 + .long 3170372974 + .long 3174359141 + .long 1709547520 + .long 1071105746 + .long 3312617382 + .long 3175326532 + .long 1168744448 + .long 1071063578 + .long 2799128425 + .long 1027228825 + .long 4163903488 + .long 1071021701 + .long 1285964057 + .long 3176060221 + .long 2056257536 + .long 1070980113 + .long 2706516695 + .long 1028650734 + .long 3739770880 + .long 1070938808 + .long 246392277 + .long 3174722093 + .long 1271734272 + .long 1070897784 + .long 3679462403 + .long 3174159366 + .long 4223328256 + .long 1070857035 + .long 2433294629 + .long 1027980203 + .long 1015963648 + .long 1070816560 + .long 4253198713 + .long 1026847814 + .long 1862295552 + .long 1070776353 + .long 1509191037 + .long 3173682029 + .long 103178240 + .long 1070736412 + .long 3582688163 + .long 3173089500 + .long 2264358912 + .long 1070696732 + .long 1779381280 + .long 1025292403 + .long 2278850560 + .long 1070657311 + .long 3240888728 + .long 1027177644 + .long 2954207232 + .long 1070618145 + .long 3564986365 + .long 1024870970 + .long 1865613312 + .long 1070562367 + .long 3892585078 + .long 1027946215 + .long 3434348544 + .long 1070485036 + .long 3011363162 + .long 3175199985 + .long 671449088 + .long 1070408197 + .long 1145012811 + .long 1026506981 + .long 1327038464 + .long 1070331842 + .long 227553652 + .long 1028331265 + .long 766836736 + .long 1070255966 + .long 518075456 + .long 3175312400 + .long 3434479616 + .long 1070180562 + .long 1452680450 + .long 3174267422 + .long 1364688896 + .long 1070105626 + .long 2571031723 + .long 3174222501 + .long 4236263424 + .long 1070031150 + .long 3514507731 + .long 3175326685 + .long 706019328 + .long 1069957131 + .long 2980398698 + .long 1026808442 + .long 1347502080 + .long 1069883561 + .long 1818423398 + .long 3175271900 + .long 4280483840 + .long 1069810435 + .long 3925170731 + .long 3175415416 + .long 3750608896 + .long 1069737749 + .long 710015584 + .long 3170118559 + .long 3004235776 + .long 1069665497 + .long 3823542833 + .long 3174354681 + .long 1393737728 + .long 1069593674 + .long 4238122296 + .long 1028475778 + .long 1621164032 + .long 1069497029 + .long 2232087921 + .long 3175937870 + .long 2762080256 + .long 1069355067 + .long 3580752115 + .long 3175802838 + .long 2914779136 + .long 1069213933 + .long 1251526596 + .long 1028548772 + .long 3808428032 + .long 1069073617 + .long 1491573749 + .long 1025131695 + .long 3589865472 + .long 1068934110 + .long 2320751647 + .long 3175285520 + .long 1102381056 + .long 1068795403 + .long 2369472545 + .long 3174735692 + .long 164790272 + .long 1068657486 + .long 3958705468 + .long 1027545055 + .long 966098944 + .long 1068520350 + .long 91754714 + .long 3174161762 + .long 100794368 + .long 1068269030 + .long 3205869737 + .long 3173509296 + .long 2079653888 + .long 1067997831 + .long 930310477 + .long 1028614386 + .long 3471048704 + .long 1067728143 + .long 1091811766 + .long 1028000848 + .long 1092419584 + .long 1067459950 + .long 629649056 + .long 3175844743 + .long 3079012352 + .long 1066936100 + .long 3939938999 + .long 3172112142 + .long 3666608128 + .long 1066405591 + .long 4185504407 + .long 3175959388 + .long 526647296 + .long 1065354156 + .long 1469727419 + .long 3173760470 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type L_tbl,@object + .size L_tbl,2064 + .align 16 +coeff: + .long 1367832035 + .long 1066403058 + .long 2677381210 + .long 3216320731 + .long 3610762001 + .long 3214607116 + .long 1215221452 + .long 1069835102 + .long 2894285243 + .long 1067936923 + .long 3011779882 + .long 3218479542 + .type coeff,@object + .size coeff,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log2f_gen.S b/external/sgx_libm/intel64/log2f_gen.S new file mode 100644 index 0000000000..7da6f101d8 --- /dev/null +++ b/external/sgx_libm/intel64/log2f_gen.S @@ -0,0 +1,243 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2f_gen.c" + .text +..TXTST0: +# -- Begin log2f + .text + .align 16,0x90 + .globl log2f +log2f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_log2f.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + cmpl $2139095040, %edx + jae ..B1.14 +..B1.2: + lea -1065222144(%rdx), %eax + cmpl $196608, %eax + jae ..B1.7 +..B1.3: + cmpl $1065353216, %edx + jne ..B1.5 +..B1.4: + pxor %xmm3, %xmm3 + jmp ..B1.6 +..B1.5: + movss -8(%rsp), %xmm0 + lea 40+_Q(%rip), %rax + lea 32+_Q(%rip), %rsi + addss .L_2il0floatpacket.0(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + movaps %xmm0, %xmm1 + lea 24+_Q(%rip), %rdx + movsd (%rax), %xmm3 + lea 16+_Q(%rip), %rdi + movsd (%rsi), %xmm2 + lea 8+_Q(%rip), %rcx + lea _Q(%rip), %r8 + mulsd %xmm0, %xmm1 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm2 + addsd (%rdx), %xmm3 + addsd (%rdi), %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm1, %xmm2 + addsd (%rcx), %xmm3 + addsd (%r8), %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm0, %xmm2 + addsd %xmm2, %xmm3 + cvtsd2ss %xmm3, %xmm3 +..B1.6: + movaps %xmm3, %xmm0 + ret +..B1.7: + movl %edx, %r9d + movl %edx, %eax + shrl $23, %r9d + andl $8388607, %eax + addl $-127, %r9d + movl %eax, -8(%rsp) + cmpl $8388608, %edx + jae ..B1.10 +..B1.8: + testl %edx, %edx + je ..B1.22 +..B1.9: + movss -8(%rsp), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + movd %xmm0, %eax + movss %xmm0, -8(%rsp) + movl %eax, %r9d + movl %eax, %edx + shrl $23, %r9d + addl $-152, %r9d +..B1.10: + testl $8388607, %edx + jne ..B1.12 +..B1.11: + pxor %xmm0, %xmm0 + cvtsi2ss %r9d, %xmm0 + ret +..B1.12: + shrl $15, %edx + orl $1065353216, %eax + movzbl %dl, %edi + pxor %xmm2, %xmm2 + movl %eax, -8(%rsp) + pxor %xmm0, %xmm0 + movq __libm_rcp_table_256@GOTPCREL(%rip), %rax + lea 16+_P(%rip), %rdx + lea 8+_P(%rip), %rcx + lea _P(%rip), %r8 + movq __libm_logf_table_256@GOTPCREL(%rip), %rsi + pxor %xmm3, %xmm3 + cvtss2sd -8(%rsp), %xmm2 + cvtss2sd (%rax,%rdi,4), %xmm0 + cvtsi2sd %r9d, %xmm3 + mulsd %xmm0, %xmm2 + movsd (%rdx), %xmm0 + movsd (%rsi,%rdi,8), %xmm1 + addsd .L_2il0floatpacket.2(%rip), %xmm2 + mulsd %xmm2, %xmm0 + addsd (%rcx), %xmm0 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm0 + addsd %xmm1, %xmm2 + mulsd (%r8), %xmm2 + addsd %xmm2, %xmm0 + addsd %xmm3, %xmm0 + cvtsd2ss %xmm0, %xmm0 +..B1.13: + ret +..B1.14: + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.20 +..B1.15: + testl $-2147483648, %edx + je ..B1.20 +..B1.16: + testl %eax, %eax + jne ..B1.18 +..B1.17: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + ret +..B1.18: + movss .L_2il0floatpacket.3(%rip), %xmm1 + pxor %xmm0, %xmm0 + mulss %xmm1, %xmm0 +..B1.19: + ret +..B1.20: + movss -8(%rsp), %xmm0 + ret +..B1.22: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type log2f,@function + .size log2f,.-log2f + .data +# -- End log2f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x7f800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_Q: + .long 1697350398 + .long 1073157447 + .long 1697278904 + .long 3219592519 + .long 3711670093 + .long 1071564553 + .long 491294680 + .long 3218543945 + .long 1795286032 + .long 1070757723 + .long 557036084 + .long 3217959989 + .type _Q,@object + .size _Q,48 + .align 4 +_P: + .long 1697350398 + .long 1073157447 + .long 605117704 + .long 3219592522 + .long 782203563 + .long 1071564561 + .type _P,@object + .size _P,24 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log2l.S b/external/sgx_libm/intel64/log2l.S new file mode 100644 index 0000000000..a068414a1a --- /dev/null +++ b/external/sgx_libm/intel64/log2l.S @@ -0,0 +1,541 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2l.c" + .text +..TXTST0: +# -- Begin log2l + .text + .align 16,0x90 + .globl log2l +log2l: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_log2l.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %sil, %sil +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzbl 57(%rsp), %r8d + andl $128, %r8d + shrl $7, %r8d + movzwl 56(%rsp), %eax + movl %eax, %edx + movl %r8d, %edi + andl $32767, %edx + shll $15, %edi + orl %edx, %edi + shll $16, %edi + movzwl 54(%rsp), %ecx + orl %ecx, %edi + cmpl $2147450880, %edi + jae ..B1.28 +..B1.4: + addl $-1073676224, %edi + cmpl $32863, %edi + ja ..B1.13 +..B1.5: + cmpl $16383, %edx + je ..B1.37 +..B1.6: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.10 +..B1.7: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.8: + fldcw 24(%rsp) +..B1.9: + movb $1, %sil +..B1.10: + fldt 48(%rsp) + lea 8+_ones(%rip), %rax + lea 112+_P(%rip), %rcx + lea 80+_P(%rip), %rdi + lea 48+_P(%rip), %r8 + lea 96+_P(%rip), %r10 + lea _TWO_32H(%rip), %rdx + lea 64+_P(%rip), %r11 + lea 16+_P(%rip), %r9 + testb %sil, %sil + fldt (%rcx) + lea 128+_P(%rip), %rcx + fldt (%rdi) + fldl (%rdx) + lea _P(%rip), %rdx + fldt (%r8) + fxch %st(4) + faddl (%rax) + lea 32+_P(%rip), %rax + fld %st(0) + fmul %st(1), %st + fmul %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(2) + fmul %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fld %st(1) + fxch %st(2) + fmul %st, %st(3) + fxch %st(2) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(1) + fsub %st(3), %st + fxch %st(2) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r10) + fmul %st(5), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt (%rdx) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fldt (%rcx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.12 +..B1.11: + fldcw 26(%rsp) +..B1.12: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.13: + movzwl 26(%rsp), %edi + movl %edi, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.17 +..B1.14: + orl $-64768, %edi + movw %di, 24(%rsp) +..B1.15: + fldcw 24(%rsp) +..B1.16: + movzwl 56(%rsp), %eax + movl %eax, %edx + movb $1, %sil + andl $32767, %edx +..B1.17: + movl $-16383, %ecx + testl %edx, %edx + jne ..B1.20 +..B1.18: + fldt 48(%rsp) + lea _TWO_75(%rip), %rcx + lea _zeros(%rip), %rax + fmull (%rcx) + movl $-16458, %ecx + fstpt 48(%rsp) + fldt 48(%rsp) + fldl (%rax) + movsd (%rax), %xmm0 + fucomip %st(1), %st + fstp %st(0) + jp ..B1.19 + je ..B1.39 +..B1.19: + movzwl 56(%rsp), %eax + movl %eax, %edx + andl $32767, %edx +..B1.20: + movl 52(%rsp), %edi + cmpl $-2147483648, %edi + jne ..B1.25 +..B1.21: + cmpl $0, 48(%rsp) + jne ..B1.25 +..B1.22: + addl %edx, %ecx + movl %ecx, 16(%rsp) + testb %sil, %sil + fildl 16(%rsp) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 26(%rsp) +..B1.24: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.25: + addl %edx, %ecx + lea _TWO_32H(%rip), %rdx + andl $-32768, %eax + lea 8+_ones(%rip), %r8 + orl $-49153, %eax + lea 112+_P(%rip), %r9 + movw %ax, 56(%rsp) + lea 80+_P(%rip), %r10 + fldt 48(%rsp) + lea 48+_P(%rip), %r11 + fld %st(0) + fldl (%rdx) + lea 16+_P(%rip), %rdx + shrl $23, %edi + fadd %st, %st(1) + movzbl %dil, %eax + fsubrp %st, %st(1) + movq __libm_rcp_table_256@GOTPCREL(%rip), %rdi + fsubr %st, %st(1) + flds (%rdi,%rax,4) + lea 96+_P(%rip), %rdi + fmul %st, %st(1) + fmulp %st, %st(2) + faddl (%r8) + fld %st(0) + lea 64+_P(%rip), %r8 + movl %ecx, 16(%rsp) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%r9) + lea 32+_P(%rip), %r9 + fmul %st(2), %st + fldt (%r10) + lea _P(%rip), %r10 + shlq $4, %rax + faddp %st, %st(1) + fmul %st(2), %st + testb %sil, %sil + fldt (%r11) + lea 128+_P(%rip), %r11 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdx) + movq __libm_log2l_table_256@GOTPCREL(%rip), %rdx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%r10) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt (%r11) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(2) + fmulp %st, %st(1) + fildl 16(%rsp) + fxch %st(2) + faddl 8(%rdx,%rax) + fxch %st(2) + faddl (%rax,%rdx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.27 +..B1.26: + fldcw 26(%rsp) +..B1.27: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.28: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.32 +..B1.29: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.30: + fldcw 24(%rsp) +..B1.31: + movzbl 57(%rsp), %r8d + movb $1, %sil + andl $128, %r8d + shrl $7, %r8d +..B1.32: + testl %r8d, %r8d + jne ..B1.42 +..B1.33: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.34: + testb %sil, %sil + je ..B1.36 +..B1.35: + fldcw 26(%rsp) +..B1.36: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.37: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.6 +..B1.38: + lea _zeros(%rip), %rax + fldl (%rax) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.39: + lea 8+_ones(%rip), %rax + testb %sil, %sil + movsd (%rax), %xmm1 + divsd %xmm0, %xmm1 + je ..B1.41 +..B1.40: + fldcw 26(%rsp) +..B1.41: + movsd %xmm1, 16(%rsp) + fldl 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.42: + movzwl 56(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + jne ..B1.44 +..B1.43: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.33 + jmp ..B1.47 +..B1.44: + testl %eax, %eax + jne ..B1.47 +..B1.45: + cmpq $0, 48(%rsp) + jne ..B1.47 +..B1.46: + lea 8+_ones(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + divsd (%rdx), %xmm0 + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + jmp ..B1.34 +..B1.47: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 16(%rsp) + fldl 16(%rsp) + fstpt (%rsp) + jmp ..B1.34 + .align 16,0x90 + .cfi_endproc + .type log2l,@function + .size log2l,.-log2l + .data +# -- End log2l + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_P: + .word 17354 + .word 24031 + .word 3064 + .word 38062 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 61628 + .word 23575 + .word 15145 + .word 47274 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 60493 + .word 53279 + .word 20193 + .word 63032 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 62043 + .word 23575 + .word 15145 + .word 47274 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 33329 + .word 29325 + .word 25223 + .word 37819 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 5068 + .word 45194 + .word 20193 + .word 63032 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 43239 + .word 63403 + .word 6517 + .word 54028 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 25259 + .word 45714 + .word 45135 + .word 47274 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14848 + .word 47274 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,144 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log2l_table.S b/external/sgx_libm/intel64/log2l_table.S new file mode 100644 index 0000000000..d85ec17901 --- /dev/null +++ b/external/sgx_libm/intel64/log2l_table.S @@ -0,0 +1,559 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log2l_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_log2l_table_256 +__libm_log2l_table_256: + .long 0xa42e4000,0x3f671b0e + .long 0x1dbbd1a5,0x3cefda26 + .long 0x8eaec000,0x3f815cfe + .long 0xac00d0eb,0x3cf06028 + .long 0x0c5d0000,0x3f8cfee7 + .long 0x6dfa58c3,0xbd0a2394 + .long 0x62192000,0x3f94564a + .long 0x88333d4e,0x3d0068bc + .long 0xace34000,0x3f997723 + .long 0xac9ac44a,0x3d1765d0 + .long 0xc69b8000,0x3f9f5923 + .long 0xcfb08e1d,0xbd25afb7 + .long 0xa085c000,0x3fa2a094 + .long 0xa481e15f,0x3d2692b8 + .long 0x1776a000,0x3fa53894 + .long 0x36a2459e,0x3d201dc0 + .long 0x9b914000,0x3fa8324c + .long 0x2b15e585,0x3d178efe + .long 0xce080000,0x3faacf54 + .long 0x8e2d6a53,0xbd340b58 + .long 0x58dac000,0x3fadced9 + .long 0xd3ddb87a,0x3d2c119c + .long 0xfbca8000,0x3fb0387e + .long 0x16f872eb,0x3d1a7682 + .long 0x06748000,0x3fb18ac6 + .long 0xdff59ce4,0xbd18ff0d + .long 0x3e136000,0x3fb30edd + .long 0x15f8f5c1,0xbd29e679 + .long 0x59364000,0x3fb463c1 + .long 0x07b8e917,0x3d193671 + .long 0x3c3f8000,0x3fb5b9e1 + .long 0x4ce80f25,0x3d410e4a + .long 0x3259c000,0x3fb7113f + .long 0x637425fc,0x3d403cdb + .long 0x8d1b0000,0x3fb869dd + .long 0x3dfca47b,0x3d401a71 + .long 0xa49d0000,0x3fb9c3be + .long 0x8c6c8e73,0x3d4909ed + .long 0xd7960000,0x3fbb1ee4 + .long 0xf4540d3e,0x3d370159 + .long 0x8b70c000,0x3fbc7b52 + .long 0x0d939dcf,0x3d48e27d + .long 0x2c678000,0x3fbdd90a + .long 0x04d3d5b4,0xbd312b9c + .long 0x976c4000,0x3fbf05d4 + .long 0xcd9838ba,0xbd3fd7bc + .long 0xbaee8000,0x3fc032fb + .long 0x7d1edf2f,0xbd429af3 + .long 0xa9f32000,0x3fc0e3b5 + .long 0xeeb39e80,0x3d3094fb + .long 0x5c7d2000,0x3fc19519 + .long 0xa7453897,0xbd3b4aad + .long 0xc2ab2000,0x3fc22dad + .long 0xd23af327,0x3d4496d2 + .long 0x231e0000,0x3fc2e050 + .long 0xa377c7ec,0xbd350520 + .long 0x9c2b2000,0x3fc379f7 + .long 0xa3793dbe,0x3d256aea + .long 0x2ba1c000,0x3fc42ddd + .long 0xac74b87f,0xbd36ad5b + .long 0x9e680000,0x3fc4c89b + .long 0x02de76ad,0x3d2fd2e8 + .long 0x29ffc000,0x3fc563dc + .long 0x78df21ad,0xbd434df3 + .long 0x5f5d8000,0x3fc619a2 + .long 0xaf108e66,0xbd29cc54 + .long 0xbf368000,0x3fc6b5ff + .long 0x175a06f6,0xbd337788 + .long 0xf6610000,0x3fc752e1 + .long 0x902c7d37,0xbd2ca90f + .long 0xe7540000,0x3fc7f049 + .long 0xec326af7,0xbd483153 + .long 0x0abfc000,0x3fc8a898 + .long 0xab240e90,0xbd166ccc + .long 0xcca64000,0x3fc94724 + .long 0x82d7bfe5,0x3d47be4d + .long 0x24970000,0x3fc9e63a + .long 0xca6bec19,0x3d4f45ea + .long 0xfeb20000,0x3fca85d8 + .long 0xd08dc20f,0x3d17b6aa + .long 0x497d8000,0x3fcb2602 + .long 0x90cb67ba,0xbd565d39 + .long 0xf5ee4000,0x3fcbc6b6 + .long 0xcabaa043,0xbd51b254 + .long 0xf770c000,0x3fcc67f7 + .long 0xab00c050,0xbd49821f + .long 0xb2234000,0x3fcceec4 + .long 0xdad67ab8,0x3d3f73bc + .long 0x7ad10000,0x3fcd9109 + .long 0x370c6558,0x3d5cc12e + .long 0x57f3c000,0x3fce33dd + .long 0x4a928ccd,0x3d433481 + .long 0x46bc8000,0x3fced741 + .long 0x984a7cdc,0xbd23bfd7 + .long 0x46ff0000,0x3fcf7b36 + .long 0x48e15c73,0xbd32f9b5 + .long 0xa943e000,0x3fd00223 + .long 0x00388584,0xbd2f3862 + .long 0x74bf0000,0x3fd054a4 + .long 0xf7113597,0x3d4d6efe + .long 0x9b926000,0x3fd0999d + .long 0xa7e48c00,0xbd397bf5 + .long 0x6d3b4000,0x3fd0eca6 + .long 0xcb31a070,0xbd5a7f50 + .long 0x2e85c000,0x3fd13ffa + .long 0xc54ae907,0xbd471577 + .long 0x44fa0000,0x3fd185a4 + .long 0x6fa317ed,0x3d44f66d + .long 0x12f28000,0x3fd1cb83 + .long 0xce4e50d0,0xbd1010cf + .long 0x441ce000,0x3fd21fa1 + .long 0xf89df349,0x3d379e4a + .long 0x26e60000,0x3fd265f5 + .long 0x84a6a593,0x3d2e59ad + .long 0xc34be000,0x3fd2baa0 + .long 0xcd51a1bf,0x3d1ebefe + .long 0x45de2000,0x3fd3016b + .long 0xec0723df,0x3d1ce045 + .long 0x38aa2000,0x3fd3486c + .long 0xaa5dfd69,0x3d434f09 + .long 0xefaa8000,0x3fd38fa3 + .long 0x91962d0f,0x3d2313fc + .long 0xc0816000,0x3fd3e562 + .long 0xfa64765f,0x3d440340 + .long 0x1f53c000,0x3fd42d14 + .long 0x167aead5,0xbd4374da + .long 0x543f2000,0x3fd474fd + .long 0x400ce06e,0x3d216293 + .long 0xb6810000,0x3fd4bd1e + .long 0x8d05e4fa,0xbd5ab857 + .long 0x9e236000,0x3fd50578 + .long 0xbbaffd12,0xbd542eea + .long 0x64004000,0x3fd54e0b + .long 0x92de8d74,0xbd323e74 + .long 0x61c40000,0x3fd596d7 + .long 0xb5eabc35,0xbd6f07ff + .long 0xf1eec000,0x3fd5dfdc + .long 0xd2926f16,0xbd51f1bb + .long 0x6fd94000,0x3fd6291c + .long 0xdc0e627c,0xbd4ac899 + .long 0x37b58000,0x3fd67296 + .long 0xd82f9efc,0x3d541782 + .long 0xa6930000,0x3fd6bc4a + .long 0x46b4eaee,0xbd5f036d + .long 0x1a5fc000,0x3fd7063a + .long 0x0e43a37f,0xbd461b8d + .long 0xf1ed0000,0x3fd75064 + .long 0xec06848a,0x3d3c558f + .long 0x8cf10000,0x3fd79acb + .long 0x9ea019ad,0x3d2c7d46 + .long 0x1e438000,0x3fd7d67c + .long 0x2119c4e9,0x3d672dc9 + .long 0x4068c000,0x3fd8214f + .long 0x8322d649,0xbd505944 + .long 0x36dec000,0x3fd86c5f + .long 0x982b6522,0xbd5c2445 + .long 0x64dd8000,0x3fd8b7ac + .long 0x3c24b943,0xbcf8cd4c + .long 0x7a0c8000,0x3fd8f416 + .long 0x1882631a,0xbd506e0d + .long 0xd5e1c000,0x3fd93fd2 + .long 0x37daf317,0xbd0c6d2c + .long 0x84298000,0x3fd98bcd + .long 0x1c4482c6,0xbd56ba65 + .long 0x33e70000,0x3fd9c8c3 + .long 0x2b947c14,0xbd565ac6 + .long 0x14298000,0x3fda152f + .long 0x0e65d2ce,0x3d1b3d7b + .long 0xd95fc000,0x3fda527f + .long 0xad63ae87,0x3d58ff36 + .long 0x3edec000,0x3fda9f5e + .long 0x112e6c5e,0xbd38668d + .long 0x2b574000,0x3fdadd0b + .long 0x1a609aaa,0x3d55a69a + .long 0x6f520000,0x3fdb2a5d + .long 0xfdf426cf,0xbcff5369 + .long 0x99b00000,0x3fdb6867 + .long 0x84b3fb1a,0x3d47c5c7 + .long 0x1b888000,0x3fdbb62f + .long 0xef0b8928,0xbd29427b + .long 0x9f664000,0x3fdbf497 + .long 0x3da6863a,0x3d63342a + .long 0x6e83c000,0x3fdc332a + .long 0xb6303c0d,0xbd6315fe + .long 0xc2d44000,0x3fdc819d + .long 0x95d8ac46,0x3d5fe438 + .long 0x8e19c000,0x3fdcc090 + .long 0x870d5301,0xbd4085c5 + .long 0x611b0000,0x3fdcffae + .long 0xb8e97d14,0xbd676a4e + .long 0x76d44000,0x3fdd3ef7 + .long 0x378ff59d,0xbcc81e2b + .long 0x02710000,0x3fdd8e50 + .long 0x99a48379,0x3d128679 + .long 0x486cc000,0x3fddcdfb + .long 0x57e20e48,0xbd397d70 + .long 0x94244000,0x3fde0dd2 + .long 0x4e05d479,0x3d5fe3e2 + .long 0x22a28000,0x3fde4dd6 + .long 0x3522eadc,0x3d407f39 + .long 0x31710000,0x3fde8e06 + .long 0xd1f94399,0x3d54efc5 + .long 0xfe9ac000,0x3fdece62 + .long 0x793f3b67,0xbd63755a + .long 0x4a154000,0x3fdf1f16 + .long 0x1e0f6657,0xbd3d990d + .long 0xa9064000,0x3fdf5fd8 + .long 0x0109b0f1,0xbd1cb6f7 + .long 0x937e8000,0x3fdfa0c8 + .long 0xcacac36e,0xbd2515e1 + .long 0x49bb8000,0x3fdfe1e6 + .long 0x293a746b,0xbd5cca93 + .long 0x06416000,0x3fe01199 + .long 0xd8721fec,0xbd594c3a + .long 0x0e91e000,0x3fe03256 + .long 0x3e307cbb,0x3d467783 + .long 0x5ebce000,0x3fe0532a + .long 0xa9a9f37a,0xbd576c46 + .long 0x17f60000,0x3fe07416 + .long 0xbbaf9ab0,0xbd3ebdb1 + .long 0x53f38000,0x3fe08cd6 + .long 0x7d0732d6,0x3d5072ba + .long 0x55c12000,0x3fe0adeb + .long 0x502d528c,0xbd5f89ea + .long 0x1d5d2000,0x3fe0cf18 + .long 0x656576a5,0xbd317e70 + .long 0xcd0ac000,0x3fe0f05c + .long 0xc4d028f0,0x3d5dae75 + .long 0x87578000,0x3fe111b9 + .long 0xfb8eb2af,0x3d51553a + .long 0x6f1bc000,0x3fe1332e + .long 0x1e351573,0x3d5ee62e + .long 0xa77c2000,0x3fe154bb + .long 0x96dcbe61,0x3d1109e5 + .long 0x9bfa2000,0x3fe16df5 + .long 0x0adf6a55,0xbd693ea9 + .long 0xb6e2c000,0x3fe18fad + .long 0x517ae88c,0x3d63c19b + .long 0x849ae000,0x3fe1b17e + .long 0xff1e8ea2,0xbd3ecf4d + .long 0x6a0de000,0x3fe1caeb + .long 0x854dfeca,0x3d5027e9 + .long 0xc8310000,0x3fe1ece7 + .long 0x7a9fc25e,0xbd6136da + .long 0x3dae0000,0x3fe20efd + .long 0xa02e61be,0x3d2df373 + .long 0xe375e000,0x3fe2289d + .long 0xc27a8169,0xbd4bfa6f + .long 0x9b6a8000,0x3fe24adf + .long 0x14538362,0xbd601f94 + .long 0xd1aea000,0x3fe26d3a + .long 0xb5d13c0f,0x3d6cfc3a + .long 0x0c276000,0x3fe28710 + .long 0xcec1b4ea,0x3d61f3e3 + .long 0x3b3c0000,0x3fe2a998 + .long 0xcb3fff52,0x3d6b2840 + .long 0x5c842000,0x3fe2c38f + .long 0xdfa568f7,0x3d10bad7 + .long 0xfac06000,0x3fe2e644 + .long 0xbe206bcc,0xbd60284e + .long 0x5c482000,0x3fe3005e + .long 0x50757c6c,0x3d4411d0 + .long 0xe1d88000,0x3fe32341 + .long 0x4bed16a8,0x3d5370c2 + .long 0xde748000,0x3fe33d7d + .long 0x4a603b86,0xbd57fbb4 + .long 0xc5650000,0x3fe3608f + .long 0x14f8ca8f,0x3d3a63aa + .long 0xb9548000,0x3fe37aee + .long 0xc4484d2e,0xbd52b278 + .long 0x7d9a8000,0x3fe39e2f + .long 0xf9f603ee,0xbd627a85 + .long 0xc68fa000,0x3fe3b8b1 + .long 0x9336b66e,0x3d4bb4b6 + .long 0xe613e000,0x3fe3dc21 + .long 0xe04a7773,0xbd60c6e3 + .long 0xe33ba000,0x3fe3f6c7 + .long 0xfc271317,0x3d325d25 + .long 0x4b1fe000,0x3fe4117d + .long 0xf19c5879,0xbd47fe42 + .long 0xefeec000,0x3fe43531 + .long 0x74b82e7e,0xbd52f11d + .long 0x969d0000,0x3fe4500b + .long 0xbb075298,0x3d65b869 + .long 0xe41a2000,0x3fe46af4 + .long 0x4d994a2a,0xbd182943 + .long 0x19316000,0x3fe48eef + .long 0x3956fa5e,0x3d6990d4 + .long 0x333d4000,0x3fe4a9fd + .long 0xe1bd6277,0x3d67e24a + .long 0x318c0000,0x3fe4c51b + .long 0x2a8a4d7a,0xbd5f91de + .long 0x26d38000,0x3fe4e049 + .long 0xdd409e96,0xbd320665 + .long 0x63f64000,0x3fe5049f + .long 0x7b11231a,0x3d5b76a8 + .long 0xe3022000,0x3fe51ff2 + .long 0xa00b120a,0xbd56879f + .long 0x98572000,0x3fe53b56 + .long 0xfa5c51d1,0x3d673642 + .long 0x973dc000,0x3fe556ca + .long 0x459db47f,0xbd53cd8a + .long 0xf3200000,0x3fe5724e + .long 0x9385d649,0x3d591597 + .long 0x03a5c000,0x3fe59719 + .long 0x449e2590,0xbd31bb71 + .long 0xda198000,0x3fe5b2c3 + .long 0x492bf6ff,0xbd5b8afe + .long 0x4f3e4000,0x3fe5ce7f + .long 0x4f9a9e0c,0x3d76ae3f + .long 0x77184000,0x3fe5ea4b + .long 0x06727b86,0x3d65cd66 + .long 0x65cf0000,0x3fe60628 + .long 0x2f6664db,0x3d5e3c54 + .long 0x2faf4000,0x3fe62216 + .long 0x60c37437,0xbd773ea5 + .long 0xe929c000,0x3fe63e14 + .long 0xcd9d28e6,0x3d346549 + .long 0xa6d5c000,0x3fe65a24 + .long 0xc074b84d,0x3d5de792 + .long 0x7d6f8000,0x3fe67645 + .long 0x3180227e,0x3d45bfa4 + .long 0x81d94000,0x3fe69277 + .long 0x137a3d8c,0xbd5aaf6f + .long 0xc91b8000,0x3fe6aeba + .long 0x459f4910,0xbd2c3a4f + .long 0x6865c000,0x3fe6cb0f + .long 0xdb502403,0x3d51d406 + .long 0x750e8000,0x3fe6e775 + .long 0x54ae8096,0x3d57aac5 + .long 0x0493c000,0x3fe703ed + .long 0xd0d1a7f0,0xbd4c2657 + .long 0x2c9b0000,0x3fe72076 + .long 0xf1ec6bfa,0x3d6cb070 + .long 0x02f2c000,0x3fe73d11 + .long 0x28f88499,0x3d130454 + .long 0x9d914000,0x3fe759bd + .long 0x84b0b58b,0x3d5ed855 + .long 0x12968000,0x3fe7767c + .long 0x12e0b4f3,0xbd46eb96 + .long 0x784b4000,0x3fe7934c + .long 0x9cb23d17,0x3d6f0113 + .long 0xe522c000,0x3fe7b02e + .long 0xa5258bb7,0x3d77f7ed + .long 0x92280000,0x3fe7c37a + .long 0x818d34cf,0xbd6804b7 + .long 0x3d39c000,0x3fe7e07b + .long 0xf457de07,0x3d650290 + .long 0x2c1b4000,0x3fe7fd8e + .long 0xb343a140,0x3d2a15a5 + .long 0x75dc0000,0x3fe81ab3 + .long 0x2ec63274,0x3d584b7a + .long 0x31b7c000,0x3fe837eb + .long 0x22b56634,0x3d6c362e + .long 0x7716c000,0x3fe85535 + .long 0xa24036e1,0xbd7707b5 + .long 0xa808c000,0x3fe868c6 + .long 0xdc0e40d3,0xbd5bd2ae + .long 0x0713c000,0x3fe88630 + .long 0x6f909cf3,0xbd6203b8 + .long 0x2ee78000,0x3fe8a3ac + .long 0xbd315db9,0xbd5c935d + .long 0x3791c000,0x3fe8c13b + .long 0x11e2bd73,0x3d5dffed + .long 0x70e24000,0x3fe8d4fa + .long 0x8994b162,0xbd3b912d + .long 0x2639c000,0x3fe8f2a9 + .long 0x1cc06b22,0xbd677406 + .long 0xfd704000,0x3fe9106a + .long 0x6f31880a,0xbd1b76a4 + .long 0x3a284000,0x3fe9244c + .long 0x7db199c6,0xbd72bd2d + .long 0x2b878000,0x3fe9422e + .long 0x1eceebf4,0x3d607320 + .long 0x81210000,0x3fe96023 + .long 0x2956f019,0x3d6518a1 + .long 0x3737c000,0x3fe97427 + .long 0x71deb637,0x3d61e54d + .long 0x16b18000,0x3fe9923d + .long 0xebd2e82c,0x3d5028ed + .long 0x9e1bc000,0x3fe9b066 + .long 0xc89c6f2d,0xbd210f7a + .long 0x45f2c000,0x3fe9c48d + .long 0xe6a10cca,0xbd55b5da + .long 0xc93fc000,0x3fe9e2d7 + .long 0x6045b96c,0xbd74e31c + .long 0x39988000,0x3fea0136 + .long 0xd9459b34,0x3d3d25cf + .long 0x4e0bc000,0x3fea1580 + .long 0xd0364be2,0x3d744421 + .long 0x2ea54000,0x3fea3400 + .long 0x3388b97b,0x3d5c79a4 + .long 0xa67f8000,0x3fea4860 + .long 0xa2e241fc,0xbd5eddce + .long 0x414dc000,0x3fea6702 + .long 0xcc538261,0xbd43167c + .long 0x4e2e0000,0x3fea7b79 + .long 0xf16ff990,0xbd43cf0f + .long 0xee1c0000,0x3fea9a3c + .long 0xe3084679,0x3cf6c31d + .long 0x1be18000,0x3feab915 + .long 0x2c022617,0xbd672292 + .long 0xb33ac000,0x3feacdb0 + .long 0xb1410c94,0xbd4b23e5 + .long 0x60094000,0x3feaecab + .long 0x0ae3394c,0x3d50556b + .long 0x107c4000,0x3feb015e + .long 0xed2b2eb2,0xbd5d0db1 + .long 0x0cb28000,0x3feb161a + .long 0xd90df0b9,0x3d5353b3 + .long 0x8761c000,0x3feb3545 + .long 0x2b834fe3,0x3d647978 + .long 0xe5b20000,0x3feb4a18 + .long 0x2a855a1a,0x3d402327 + .long 0x9b240000,0x3feb6967 + .long 0x3726f484,0xbd7b3b86 + .long 0x90874000,0x3feb7e52 + .long 0x09b9625e,0x3d2d2152 + .long 0xd0b8c000,0x3feb9dc4 + .long 0x29c44115,0xbd46be4a + .long 0x92ddc000,0x3febb2c7 + .long 0xd690403e,0xbd28b7fc + .long 0xaeddc000,0x3febd25d + .long 0xb0f92e32,0x3d46a10e + .long 0x742ac000,0x3febe778 + .long 0x7ecf463f,0xbd6ad6fb + .long 0xe3b98000,0x3febfc9c + .long 0x1185e784,0xbd42cbe5 + .long 0xbdb50000,0x3fec1c65 + .long 0x6951096d,0x3d3e742a + .long 0x7dd04000,0x3fec31a2 + .long 0xcbdb5d9e,0xbd7a5b21 + .long 0x076cc000,0x3fec46e9 + .long 0x86f88587,0xbd3ddb78 + .long 0x43730000,0x3fec66e5 + .long 0xbaa5a734,0x3d523bf0 + .long 0x6c790000,0x3fec7c44 + .long 0xf67dd7ae,0xbd7c7a0d + .long 0x7ed84000,0x3fec91ad + .long 0x6188e18f,0x3d722f0b + .long 0xc4194000,0x3fecb1dd + .long 0x4bba7e1c,0x3d77b6c1 + .long 0xc6410000,0x3fecc75f + .long 0xb0c280a9,0x3d64f1b9 + .long 0xd2374000,0x3fecdceb + .long 0x391924a7,0xbd49ad57 + .long 0xcb184000,0x3fecfd50 + .long 0x6ab58d83,0xbd6078ca + .long 0x18c18000,0x3fed12f6 + .long 0xeb119dc6,0xbd6fe599 + .long 0x914e4000,0x3fed28a5 + .long 0x26c0de13,0xbd6fb0e6 + .long 0x3e504000,0x3fed3e5f + .long 0x9ace87f7,0xbd506b11 + .long 0xf93fc000,0x3fed5f08 + .long 0x4f2d37b7,0xbd73bb6d + .long 0x539dc000,0x3fed74dc + .long 0xb806844c,0x3d727a5f + .long 0x045b0000,0x3fed8aba + .long 0xf65ddbc9,0x3d2c7a4f + .long 0x15464000,0x3feda0a2 + .long 0x0af75927,0x3d74c8da + .long 0xb896c000,0x3fedc191 + .long 0x5363737e,0xbd6cdb50 + .long 0xe53dc000,0x3fedd793 + .long 0xa1dc7b13,0xbd76ffa3 + .long 0x94d7c000,0x3fededa0 + .long 0x1919aabd,0x3d6747e2 + .long 0xd174c000,0x3fee03b7 + .long 0x2f683f98,0xbd514fc4 + .long 0xa531c000,0x3fee19d9 + .long 0x3a87769f,0x3d7728dc + .long 0x1a3c0000,0x3fee3006 + .long 0x768a06ef,0xbd7a0e7d + .long 0xce9f8000,0x3fee515c + .long 0x518e12cc,0xbd65f71b + .long 0x03cb4000,0x3fee67a4 + .long 0xfaf8e258,0x3d75735c + .long 0xfe538000,0x3fee7df5 + .long 0xf6a2b592,0x3d55669d + .long 0xc8a70000,0x3fee9452 + .long 0xec9f90f7,0x3d60278c + .long 0x6d444000,0x3feeaaba + .long 0x2268e3e2,0x3d799543 + .long 0xf6b98000,0x3feec12c + .long 0x09d2dc10,0xbd468988 + .long 0x6fa38000,0x3feed7aa + .long 0x51433cdb,0xbd7387ac + .long 0xe2aec000,0x3feeee32 + .long 0x4fd75f61,0x3d597da2 + .long 0x3bbf4000,0x3fef1014 + .long 0x68ea48c7,0x3d71983c + .long 0x4f39c000,0x3fef26b8 + .long 0x4efa434d,0xbd72177b + .long 0x82ae0000,0x3fef3d67 + .long 0xf9197819,0x3d6fbc2b + .long 0xe1110000,0x3fef5421 + .long 0xa92b420d,0x3d69402d + .long 0x75670000,0x3fef6ae7 + .long 0x00c52b20,0xbd67cf2e + .long 0x4ac44000,0x3fef81b8 + .long 0x10fed627,0x3d2f2407 + .long 0x6c4e4000,0x3fef9894 + .long 0xd2088b22,0x3d61d346 + .long 0xe53ac000,0x3fefaf7b + .long 0xf5920222,0x3d69b7dc + .long 0xc0d04000,0x3fefc66e + .long 0xdbf33c61,0x3d6314d8 + .long 0x0a660000,0x3fefdd6d + .long 0x088b0624,0x3d603dc6 + .long 0xcd644000,0x3feff476 + .long 0xf02b035e,0x3d6e05d5 + .type __libm_log2l_table_256,@object + .size __libm_log2l_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/log_gen.S b/external/sgx_libm/intel64/log_gen.S new file mode 100644 index 0000000000..1a11f6b3d2 --- /dev/null +++ b/external/sgx_libm/intel64/log_gen.S @@ -0,0 +1,758 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log_gen.c" + .text +..TXTST0: +# -- Begin log + .text + .align 16,0x90 + .globl log +log: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_log.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + movq $0x3ff0000000000000, %rax + movd %rax, %xmm2 + movq $0x77f0000000000000, %rdx + movd %rdx, %xmm3 + movl $32768, %ecx + movd %rcx, %xmm4 + movq $0xffffe00000000000, %r8 + movd %r8, %xmm5 + movq %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + movl $16352, %ecx + psrlq $27, %xmm0 + lea L_tbl(%rip), %r11 + psrld $2, %xmm0 + rcpps %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $228, %xmm5, %xmm6 + psrlq $12, %xmm1 + subl $16, %eax + cmpl $32736, %eax + jae .L_2TAG_PACKET_0.0.2 +.L_2TAG_PACKET_1.0.2: + paddd %xmm4, %xmm0 + orpd %xmm3, %xmm1 + movd %xmm0, %edx + psllq $29, %xmm0 + andpd %xmm1, %xmm5 + andpd %xmm6, %xmm0 + subsd %xmm5, %xmm1 + mulpd %xmm0, %xmm5 + andl $32752, %eax + subl %ecx, %eax + cvtsi2sd %eax, %xmm7 + mulsd %xmm0, %xmm1 + movq log2(%rip), %xmm6 + movapd coeff(%rip), %xmm3 + subsd %xmm2, %xmm5 + andl $16711680, %edx + shrl $12, %edx + movapd (%r11,%rdx), %xmm0 + movapd 16+coeff(%rip), %xmm4 + addsd %xmm5, %xmm1 + movapd 32+coeff(%rip), %xmm2 + mulsd %xmm7, %xmm6 + movapd %xmm1, %xmm5 + unpcklpd %xmm1, %xmm5 + mulsd 8+log2(%rip), %xmm7 + mulsd %xmm1, %xmm3 + addsd %xmm6, %xmm0 + mulpd %xmm5, %xmm4 + mulpd %xmm5, %xmm5 + movapd %xmm0, %xmm6 + unpcklpd %xmm0, %xmm6 + addsd %xmm1, %xmm0 + addpd %xmm2, %xmm4 + mulpd %xmm5, %xmm3 + subsd %xmm0, %xmm6 + mulsd %xmm1, %xmm4 + pshufd $238, %xmm0, %xmm2 + addsd %xmm6, %xmm1 + mulsd %xmm5, %xmm5 + addsd %xmm2, %xmm7 + addpd %xmm3, %xmm4 + addsd %xmm7, %xmm1 + mulpd %xmm5, %xmm4 + addsd %xmm4, %xmm1 + pshufd $238, %xmm4, %xmm5 + addsd %xmm5, %xmm1 + addsd %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + movq (%rsp), %xmm0 + movq (%rsp), %xmm1 + addl $16, %eax + cmpl $32768, %eax + jae .L_2TAG_PACKET_2.0.2 + cmpl $16, %eax + jb .L_2TAG_PACKET_3.0.2 +.L_2TAG_PACKET_4.0.2: + addsd %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_5.0.2: + ja .L_2TAG_PACKET_4.0.2 + cmpl $0, %edx + ja .L_2TAG_PACKET_4.0.2 + jmp .L_2TAG_PACKET_6.0.2 +.L_2TAG_PACKET_3.0.2: + xorpd %xmm1, %xmm1 + addsd %xmm0, %xmm1 + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.2 + xorpd %xmm1, %xmm1 + movl $18416, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + movq %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orpd %xmm2, %xmm0 + psrlq $27, %xmm0 + movl $18416, %ecx + psrld $2, %xmm0 + rcpps %xmm0, %xmm0 + psllq $12, %xmm1 + pshufd $228, %xmm5, %xmm6 + psrlq $12, %xmm1 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_2.0.2: + movd %xmm1, %edx + psrlq $32, %xmm1 + movd %xmm1, %ecx + addl %ecx, %ecx + cmpl $-2097152, %ecx + jae .L_2TAG_PACKET_5.0.2 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_7.0.2 +.L_2TAG_PACKET_6.0.2: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $32752, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm0 + movl $3, 16(%rsp) + jmp .L_2TAG_PACKET_8.0.2 +.L_2TAG_PACKET_7.0.2: + xorpd %xmm1, %xmm1 + xorpd %xmm0, %xmm0 + movl $49136, %eax + pinsrw $3, %eax, %xmm0 + divsd %xmm1, %xmm0 + movl $2, 16(%rsp) +.L_2TAG_PACKET_8.0.2: + movq %xmm0, 8(%rsp) +..B1.3: + movq 8(%rsp), %xmm0 +.L_2TAG_PACKET_9.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type log,@function + .size log,.-log + .data +# -- End log + .section .rodata, "a" + .align 16 + .align 16 +L_tbl: + .long 4277811200 + .long 1072049730 + .long 2479318832 + .long 1026487127 + .long 2854492160 + .long 1072033410 + .long 215631550 + .long 1025638968 + .long 1547061248 + .long 1072017216 + .long 2886781435 + .long 1026423395 + .long 649825280 + .long 1072001146 + .long 4281533405 + .long 1024038923 + .long 646346752 + .long 1071985198 + .long 1562735921 + .long 1023790276 + .long 2203734016 + .long 1071969370 + .long 1838397691 + .long 3173936209 + .long 1872169984 + .long 1071953661 + .long 3981202460 + .long 1022325013 + .long 669557760 + .long 1071938069 + .long 4182597802 + .long 3173174122 + .long 4076413952 + .long 1071922591 + .long 1209029111 + .long 3170736207 + .long 556125184 + .long 1071907228 + .long 821086028 + .long 3173437049 + .long 204914688 + .long 1071891976 + .long 2097025986 + .long 3171071798 + .long 387545088 + .long 1071876834 + .long 3142936996 + .long 3173092218 + .long 2912783360 + .long 1071861800 + .long 2502420140 + .long 1024505919 + .long 1144260608 + .long 1071846874 + .long 3315658140 + .long 3173469843 + .long 1471209472 + .long 1071832053 + .long 129621009 + .long 3172443877 + .long 1829683200 + .long 1071817336 + .long 3885467693 + .long 1025535275 + .long 288676864 + .long 1071802722 + .long 86139472 + .long 3171639793 + .long 3636378624 + .long 1071788208 + .long 1850238587 + .long 1024654342 + .long 1606817792 + .long 1071773795 + .long 3388899795 + .long 3173675586 + .long 1236164608 + .long 1071759480 + .long 3983599207 + .long 1020046558 + .long 1089616896 + .long 1071745262 + .long 4171974224 + .long 1024773198 + .long 4143093760 + .long 1071731139 + .long 2727587401 + .long 3173965207 + .long 600267776 + .long 1071717112 + .long 3147685042 + .long 3173353031 + .long 2249313280 + .long 1071703177 + .long 125835074 + .long 1025255832 + .long 3805303808 + .long 1071689334 + .long 2289991207 + .long 1025460331 + .long 87278592 + .long 1071675583 + .long 1106114045 + .long 1025933602 + .long 3195405312 + .long 1071661920 + .long 3885316576 + .long 3171206239 + .long 3853649920 + .long 1071648346 + .long 2977069852 + .long 3171236771 + .long 2944026624 + .long 1071625048 + .long 1008093493 + .long 1023444474 + .long 3993180160 + .long 1071598247 + .long 1862355595 + .long 1024642533 + .long 1454641152 + .long 1071571617 + .long 1514603089 + .long 1026500596 + .long 3286085632 + .long 1071545154 + .long 1400028424 + .long 3173279056 + .long 438773760 + .long 1071518858 + .long 120727864 + .long 3172148914 + .long 1212979200 + .long 1071492725 + .long 1625055594 + .long 3172901933 + .long 1189017600 + .long 1071466754 + .long 3920062376 + .long 1025727407 + .long 403064832 + .long 1071440943 + .long 1053271728 + .long 3171391427 + .long 3343210496 + .long 1071415289 + .long 3243395502 + .long 3173627613 + .long 1765777408 + .long 1071389792 + .long 2145968512 + .long 1026354304 + .long 461430784 + .long 1071364449 + .long 4094322285 + .long 1026021467 + .long 71706624 + .long 1071339258 + .long 763632021 + .long 1024496933 + .long 1380503552 + .long 1071314217 + .long 1383547992 + .long 3173088453 + .long 1015732224 + .long 1071289325 + .long 3198646877 + .long 1025390322 + .long 35977216 + .long 1071264580 + .long 2141026805 + .long 1025754693 + .long 3927306240 + .long 1071239979 + .long 282116272 + .long 3173394334 + .long 1125341184 + .long 1071215523 + .long 2768427504 + .long 3172279059 + .long 1666971648 + .long 1071191208 + .long 786837629 + .long 3172427445 + .long 2827694080 + .long 1071167033 + .long 3857122416 + .long 3173014241 + .long 2003683328 + .long 1071142997 + .long 859010954 + .long 1026545007 + .long 1004017664 + .long 1071119098 + .long 3356644970 + .long 3173458064 + .long 1753020416 + .long 1071095334 + .long 788338552 + .long 1026157693 + .long 1992718336 + .long 1071071704 + .long 1239179443 + .long 1026394889 + .long 3870234624 + .long 1071048206 + .long 2082614663 + .long 1024926053 + .long 1050437632 + .long 1071024840 + .long 660007840 + .long 1025548499 + .long 188395520 + .long 1071001603 + .long 3878792704 + .long 3173889571 + .long 3747176448 + .long 1070978493 + .long 144991708 + .long 3171552042 + .long 1405669376 + .long 1070955511 + .long 3999088879 + .long 1025486317 + .long 121151488 + .long 1070932654 + .long 2170865497 + .long 1026473584 + .long 2652319744 + .long 1070909920 + .long 453695652 + .long 3173916809 + .long 3262236672 + .long 1070887309 + .long 157800053 + .long 3173984206 + .long 601221120 + .long 1070864820 + .long 3968917661 + .long 1023992886 + .long 1999843328 + .long 1070842450 + .long 3053895004 + .long 1024998228 + .long 1992167424 + .long 1070820199 + .long 2968614856 + .long 1024552653 + .long 3788726272 + .long 1070798065 + .long 3542170808 + .long 3173573242 + .long 2094829568 + .long 1070776048 + .long 1246758132 + .long 1026202874 + .long 288675840 + .long 1070754146 + .long 3747328950 + .long 1026331585 + .long 1829681152 + .long 1070732357 + .long 3125197546 + .long 1024100318 + .long 1666869248 + .long 1070710681 + .long 1363656119 + .long 1026336493 + .long 3417110528 + .long 1070689116 + .long 4154791553 + .long 1026267853 + .long 2183653376 + .long 1070667662 + .long 1671819292 + .long 3173785870 + .long 1734434816 + .long 1070646317 + .long 373091049 + .long 1025972363 + .long 1615681536 + .long 1070625080 + .long 384650897 + .long 1022926043 + .long 1445382144 + .long 1070603950 + .long 344320330 + .long 3172397196 + .long 1823715328 + .long 1070569756 + .long 3389841200 + .long 1025231852 + .long 3839688704 + .long 1070527917 + .long 1706790417 + .long 3167363349 + .long 4293332992 + .long 1070486286 + .long 1614935088 + .long 1019351591 + .long 2966720512 + .long 1070444861 + .long 4145393717 + .long 3173711658 + .long 4066729984 + .long 1070403639 + .long 1974925028 + .long 3171437182 + .long 3337621504 + .long 1070362619 + .long 3314953170 + .long 3169971314 + .long 943448064 + .long 1070321799 + .long 1498682038 + .long 3173862340 + .long 1465634816 + .long 1070281176 + .long 1319952810 + .long 3171693965 + .long 1015734272 + .long 1070240749 + .long 1347821929 + .long 3173544515 + .long 118001664 + .long 1070200516 + .long 1751482746 + .long 1026134093 + .long 3707174912 + .long 1070160474 + .long 1486946159 + .long 1023930920 + .long 3946381312 + .long 1070120623 + .long 2867408081 + .long 3171368276 + .long 1699848192 + .long 1070080961 + .long 2590187139 + .long 1025379803 + .long 2235846656 + .long 1070041485 + .long 1888568069 + .long 3172754960 + .long 2339729408 + .long 1070002194 + .long 3852214753 + .long 3173323149 + .long 3196850176 + .long 1069963086 + .long 742141560 + .long 1025101707 + .long 1800683520 + .long 1069924160 + .long 3949500444 + .long 3172102179 + .long 3835801600 + .long 1069885413 + .long 3848895943 + .long 1025913832 + .long 2201202688 + .long 1069846845 + .long 1425913464 + .long 1025868665 + .long 2778279936 + .long 1069808453 + .long 2120889677 + .long 3173831128 + .long 2954203136 + .long 1069770236 + .long 592147081 + .long 1019621288 + .long 210141184 + .long 1069732193 + .long 3414275233 + .long 1023647084 + .long 709476352 + .long 1069694321 + .long 2413027164 + .long 1024462115 + .long 2116284416 + .long 1069656619 + .long 1144559924 + .long 1026336654 + .long 2183651328 + .long 1069619086 + .long 3459057650 + .long 1025634168 + .long 3047047168 + .long 1069581720 + .long 1879674924 + .long 3173508573 + .long 970711040 + .long 1069541521 + .long 1335954173 + .long 3173332182 + .long 2198478848 + .long 1069467449 + .long 2951103968 + .long 3173892200 + .long 1669611520 + .long 1069393703 + .long 531044147 + .long 1025149248 + .long 29114368 + .long 1069320280 + .long 3327831251 + .long 1025918673 + .long 2376949760 + .long 1069247176 + .long 737634533 + .long 3172176000 + .long 1085390848 + .long 1069174390 + .long 3108243400 + .long 3171828406 + .long 1566130176 + .long 1069101918 + .long 985483226 + .long 1025708380 + .long 792780800 + .long 1069029758 + .long 4184866295 + .long 1024426204 + .long 183156736 + .long 1068957907 + .long 2845699378 + .long 1022107277 + .long 1301782528 + .long 1068886362 + .long 1012735262 + .long 3173804294 + .long 1562411008 + .long 1068815121 + .long 2197086703 + .long 3170187813 + .long 2815549440 + .long 1068744181 + .long 2782613207 + .long 1026345054 + .long 2756124672 + .long 1068673540 + .long 2929486205 + .long 3173037800 + .long 3511050240 + .long 1068603195 + .long 1443733147 + .long 3173331549 + .long 3047047168 + .long 1068533144 + .long 1879674924 + .long 3172459997 + .long 3221667840 + .long 1068427825 + .long 1338588027 + .long 3171815742 + .long 3453861888 + .long 1068288883 + .long 1205348359 + .long 3172624626 + .long 3506110464 + .long 1068150514 + .long 893105198 + .long 1025571866 + .long 346013696 + .long 1068012714 + .long 3495569021 + .long 3172563349 + .long 4074029056 + .long 1067875476 + .long 3961106338 + .long 3171065595 + .long 3559784448 + .long 1067738798 + .long 1975385384 + .long 3173783155 + .long 797769728 + .long 1067602675 + .long 3760305787 + .long 1026047642 + .long 2313633792 + .long 1067467101 + .long 1559353171 + .long 1023480256 + .long 3960766464 + .long 1067213778 + .long 1067365107 + .long 1025865926 + .long 684261376 + .long 1066944805 + .long 844762164 + .long 3173687482 + .long 630718464 + .long 1066676905 + .long 2458269694 + .long 1024033081 + .long 1486061568 + .long 1066410070 + .long 115537874 + .long 3173243995 + .long 2743664640 + .long 1065886792 + .long 3665098304 + .long 3173471607 + .long 1971912704 + .long 1065357333 + .long 2577214440 + .long 3171993451 + .long 1498939392 + .long 1064306693 + .long 3409036923 + .long 1025599151 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type L_tbl,@object + .size L_tbl,2064 + .align 16 +log2: + .long 4277811200 + .long 1067855426 + .long 2479318832 + .long 1022292823 + .type log2,@object + .size log2,16 + .align 16 +coeff: + .long 2454267026 + .long 1069697316 + .long 0 + .long 3218079744 + .long 1030730101 + .long 3217380702 + .long 1431655765 + .long 1070945621 + .long 2576980378 + .long 1070176665 + .long 0 + .long 3219128320 + .type coeff,@object + .size coeff,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/log_table.S b/external/sgx_libm/intel64/log_table.S new file mode 100644 index 0000000000..eebf30a349 --- /dev/null +++ b/external/sgx_libm/intel64/log_table.S @@ -0,0 +1,559 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "log_table.c" + .section .rodata, "a" + .align 32 + .align 32 + .globl __libm_log_table_256 +__libm_log_table_256: + .long 0x2779c19c,0x3e057562 + .long 0x00000000,0x3f600401 + .long 0x540e0a5d,0x3df4586b + .long 0x00000000,0x3f781212 + .long 0x5df1d574,0x3e3f2d06 + .long 0x00000000,0x3f841929 + .long 0xe0cc0310,0x3e3098eb + .long 0x00000000,0x3f8c3173 + .long 0x861d36aa,0x3e1ac733 + .long 0x00000000,0x3f91a6b9 + .long 0x0e5dc270,0x3e3766b0 + .long 0x00000000,0x3f95ba9a + .long 0xcf80538b,0x3dfd0c97 + .long 0x00000000,0x3f99d2a8 + .long 0x01095e5d,0x3e22cbcc + .long 0x00000000,0x3f9d6b27 + .long 0x5531753a,0x3e5433bf + .long 0x00000000,0x3fa0c58f + .long 0x86a4cae2,0x3e4e32f3 + .long 0x00000000,0x3fa2954c + .long 0x2b382296,0x3e36d4b6 + .long 0x00000000,0x3fa4a94d + .long 0x6b08209f,0x3e5e5a97 + .long 0x00000000,0x3fa67c94 + .long 0x0d02a20b,0x3e56c61e + .long 0x00000000,0x3fa85188 + .long 0xe988d46e,0x3e57ce75 + .long 0x00000000,0x3faa6b8a + .long 0x78fa4c28,0x3e0bdcaa + .long 0x00000000,0x3fac441e + .long 0x069e5bd9,0x3e23606d + .long 0x00000000,0x3fae1e67 + .long 0x008c9838,0x3e21ab93 + .long 0x00000000,0x3faffa69 + .long 0xc0123f2a,0x3e638bb4 + .long 0x00000000,0x3fb0ec13 + .long 0x42c9365e,0x3e590f46 + .long 0x00000000,0x3fb1dbd2 + .long 0xe38bd0cb,0x3e609fcb + .long 0x00000000,0x3fb2cc72 + .long 0xcc85ea5e,0x3e64fa3d + .long 0x00000000,0x3fb3bdf5 + .long 0xb814e378,0x3e5ea804 + .long 0x00000000,0x3fb4b05d + .long 0xc07f6cbe,0x3e5f3ad5 + .long 0x00000000,0x3fb580db + .long 0x4f332994,0x3e6126cb + .long 0x00000000,0x3fb674f0 + .long 0x46bb18e7,0x3e4635ab + .long 0x00000000,0x3fb769ef + .long 0x23f3f334,0x3e43a835 + .long 0x00000000,0x3fb85fd9 + .long 0x622b8758,0x3e575652 + .long 0x00000000,0x3fb9335e + .long 0xfa6531cd,0x3e406472 + .long 0x00000000,0x3fba2b02 + .long 0xd57cb81c,0x3e658350 + .long 0x00000000,0x3fbb0004 + .long 0x843191b0,0x3e5da7f2 + .long 0x00000000,0x3fbbf968 + .long 0x750465fd,0x3e67fdc2 + .long 0x00000000,0x3fbccfed + .long 0xa89401fa,0x3e58e111 + .long 0x00000000,0x3fbda727 + .long 0xde61a8fd,0x3e5ff843 + .long 0x00000000,0x3fbea325 + .long 0xbcbe8b53,0x3e6fdb7f + .long 0x00000000,0x3fbf7be9 + .long 0x7ce635d5,0x3e64bfc9 + .long 0x00000000,0x3fc02ab3 + .long 0x133742da,0x3e65e748 + .long 0x00000000,0x3fc097ce + .long 0x8f7bc671,0x3e7044fc + .long 0x00000000,0x3fc1178e + .long 0xcce888b8,0x3e6f6fb3 + .long 0x00000000,0x3fc18574 + .long 0xa08b164f,0x3e52f92e + .long 0x00000000,0x3fc1f3b9 + .long 0x56b4e87b,0x3e4e6ddf + .long 0x00000000,0x3fc2625d + .long 0x73ad9970,0x3e390d02 + .long 0x00000000,0x3fc2d161 + .long 0x85c23082,0x3e72e822 + .long 0x00000000,0x3fc340c5 + .long 0xaa42e1ae,0x3e69d5fc + .long 0x00000000,0x3fc3b08b + .long 0x06ed14f1,0x3e306f00 + .long 0x00000000,0x3fc40dfb + .long 0xef836a49,0x3e7d194b + .long 0x00000000,0x3fc47e74 + .long 0xbc83d21d,0x3e7ec8cd + .long 0x00000000,0x3fc4ef51 + .long 0xa2c28034,0x3e7c0574 + .long 0x00000000,0x3fc56092 + .long 0x3530a5ba,0x3e65f35d + .long 0x00000000,0x3fc5d238 + .long 0xbb20ab0e,0x3e5b99ae + .long 0x00000000,0x3fc6313a + .long 0x706cb199,0x3e7b577a + .long 0x00000000,0x3fc6a399 + .long 0x8350bc53,0x3e7ba79c + .long 0x00000000,0x3fc70337 + .long 0x274badf2,0x3e428f61 + .long 0x00000000,0x3fc77654 + .long 0x16849fa4,0x3e550581 + .long 0x00000000,0x3fc7e9d8 + .long 0x4baffaa4,0x3e6d67d4 + .long 0x00000000,0x3fc84a6b + .long 0x61fae141,0x3e7abeb4 + .long 0x00000000,0x3fc8ab47 + .long 0x0369cf31,0x3e7212cb + .long 0x00000000,0x3fc91fe4 + .long 0x9d5bb3d2,0x3e60046a + .long 0x00000000,0x3fc98163 + .long 0x904d6866,0x3e2c2259 + .long 0x00000000,0x3fc9f6c4 + .long 0xa19f5411,0x3e549a47 + .long 0x00000000,0x3fca58e7 + .long 0x759a5351,0x3e7862d2 + .long 0x00000000,0x3fcabb55 + .long 0xf400c4b3,0x3e62467b + .long 0x00000000,0x3fcb1e10 + .long 0xf9503717,0x3e727c6c + .long 0x00000000,0x3fcb94ee + .long 0xabdf1b3f,0x3e780cea + .long 0x00000000,0x3fcbf851 + .long 0xe97aab9f,0x3e652fc8 + .long 0x00000000,0x3fcc5c02 + .long 0x8a4a9e8b,0x3e793b67 + .long 0x00000000,0x3fccc000 + .long 0xce7d8064,0x3e73390a + .long 0x00000000,0x3fcd244d + .long 0x2835ff73,0x3e5fd97a + .long 0x00000000,0x3fcd88e9 + .long 0x804954d6,0x3e5bf577 + .long 0x00000000,0x3fcdedd4 + .long 0x024244ec,0x3e7ffce2 + .long 0x00000000,0x3fce530e + .long 0x7137ba40,0x3e4648b9 + .long 0x00000000,0x3fceb89a + .long 0x7bcea6d1,0x3e7f5bf3 + .long 0x00000000,0x3fcf1e75 + .long 0x1abc74cf,0x3e5756be + .long 0x00000000,0x3fcf84a3 + .long 0xe6831bc0,0x3e59f503 + .long 0x00000000,0x3fcfeb22 + .long 0x83851858,0x3e88e06b + .long 0x00000000,0x3fd028f9 + .long 0x6b43c71e,0x3e8c1b2c + .long 0x00000000,0x3fd05c8b + .long 0xf2ea89fa,0x3e81f15c + .long 0x00000000,0x3fd085eb + .long 0x2224e892,0x3e8c65a3 + .long 0x00000000,0x3fd0b9c8 + .long 0x20336a5b,0x3e782de0 + .long 0x00000000,0x3fd0edd0 + .long 0x8fdd9770,0x3e733c01 + .long 0x00000000,0x3fd12202 + .long 0x9a817c85,0x3e824f5d + .long 0x00000000,0x3fd14be2 + .long 0x5be801bd,0x3e81de31 + .long 0x00000000,0x3fd18061 + .long 0xc766b993,0x3e87c5f8 + .long 0x00000000,0x3fd1b50b + .long 0x85a1f823,0x3e88f9e4 + .long 0x00000000,0x3fd1df4c + .long 0x350fbd75,0x3e7b43ae + .long 0x00000000,0x3fd21445 + .long 0x4920ddbb,0x3e8323d7 + .long 0x00000000,0x3fd23ec5 + .long 0x5f6600ba,0x3e83f0e1 + .long 0x00000000,0x3fd2740d + .long 0x4073b3be,0x3e8579bf + .long 0x00000000,0x3fd29ecd + .long 0x72f2232b,0x3e256e67 + .long 0x00000000,0x3fd2d466 + .long 0x3a896d5f,0x3e8609d5 + .long 0x00000000,0x3fd2ff66 + .long 0x8ddf913a,0x3e72cd56 + .long 0x00000000,0x3fd33550 + .long 0xd7253e69,0x3e77b113 + .long 0x00000000,0x3fd36092 + .long 0xce9e941f,0x3e88666f + .long 0x00000000,0x3fd38bf1 + .long 0x60ed52d8,0x3e7dcccc + .long 0x00000000,0x3fd3c252 + .long 0x0f983d68,0x3e78f05a + .long 0x00000000,0x3fd3edf4 + .long 0x6390dbb2,0x3e61eaf4 + .long 0x00000000,0x3fd419b4 + .long 0xe916a76d,0x3e8c0a73 + .long 0x00000000,0x3fd44591 + .long 0x2b59a2e0,0x3e7d6dbc + .long 0x00000000,0x3fd47c91 + .long 0xc24fc7a2,0x3e70554a + .long 0x00000000,0x3fd4a8b3 + .long 0x33faf275,0x3e821120 + .long 0x00000000,0x3fd4d4f3 + .long 0x2cfac6d3,0x3e81b43f + .long 0x00000000,0x3fd50152 + .long 0x3d98a28d,0x3e78d1f5 + .long 0x00000000,0x3fd52dd0 + .long 0x44e3b5b4,0x3e6e3dc5 + .long 0x00000000,0x3fd55a6d + .long 0x2c814b0b,0x3e658895 + .long 0x00000000,0x3fd5925d + .long 0x6c7ee0a5,0x3e7ad50f + .long 0x00000000,0x3fd5bf40 + .long 0xd6e34245,0x3e6eae1a + .long 0x00000000,0x3fd5ec43 + .long 0x83dd4a7f,0x3e89b605 + .long 0x00000000,0x3fd61965 + .long 0xa87b925b,0x3e724d6c + .long 0x00000000,0x3fd646a8 + .long 0xd28ed1d3,0x3e8ba63b + .long 0x00000000,0x3fd6740a + .long 0x18a4a613,0x3e86e94b + .long 0x00000000,0x3fd6a18d + .long 0xb0b244a7,0x3e3619c3 + .long 0x00000000,0x3fd6cf31 + .long 0x173b6f5e,0x3e8d0a5e + .long 0x00000000,0x3fd6f180 + .long 0x3be91c4c,0x3e7c6e25 + .long 0x00000000,0x3fd71f5d + .long 0xab8359ed,0x3e8dfacd + .long 0x00000000,0x3fd74d5a + .long 0x6fb93ec4,0x3e82457a + .long 0x00000000,0x3fd77b79 + .long 0x3c4bbc8b,0x3e8113e3 + .long 0x00000000,0x3fd7a9b9 + .long 0x31fa7741,0x3e2bf5b5 + .long 0x00000000,0x3fd7d81b + .long 0x186f4789,0x3e69c139 + .long 0x00000000,0x3fd8069e + .long 0x7956aae8,0x3e8a7df1 + .long 0x00000000,0x3fd82996 + .long 0xfeab799a,0x3e7ddb72 + .long 0x00000000,0x3fd85855 + .long 0x33b8ef04,0x3e760c9f + .long 0x00000000,0x3fd88736 + .long 0x19dccb10,0x3e82e757 + .long 0x00000000,0x3fd8aa75 + .long 0x9c910289,0x3e8b9104 + .long 0x00000000,0x3fd8d992 + .long 0xa230be1d,0x3e8d4fb2 + .long 0x00000000,0x3fd908d2 + .long 0xcac1703a,0x3e8cf381 + .long 0x00000000,0x3fd92c59 + .long 0xb4a553e7,0x3e743b8f + .long 0x00000000,0x3fd95bd7 + .long 0x5b5274b7,0x3e51a3ee + .long 0x00000000,0x3fd98b78 + .long 0x0d70a52d,0x3e8e67a8 + .long 0x00000000,0x3fd9af47 + .long 0x4f0d2c7f,0x3e483229 + .long 0x00000000,0x3fd9df27 + .long 0xb48f7d3d,0x3e8da29f + .long 0x00000000,0x3fda0325 + .long 0xc6457f9d,0x3e2127d3 + .long 0x00000000,0x3fda3344 + .long 0xe0b95e88,0x3e77a030 + .long 0x00000000,0x3fda5772 + .long 0x991f7846,0x3e565dd1 + .long 0x00000000,0x3fda87d0 + .long 0x256f237b,0x3e7b00fe + .long 0x00000000,0x3fdaac2e + .long 0xa0437713,0x3e7bf7da + .long 0x00000000,0x3fdadccc + .long 0xc8192dd8,0x3e6f58f3 + .long 0x00000000,0x3fdb015b + .long 0xa41f8565,0x3e6d31ac + .long 0x00000000,0x3fdb323a + .long 0x25494b61,0x3e3118a4 + .long 0x00000000,0x3fdb56fa + .long 0x92694e9d,0x3e84cb37 + .long 0x00000000,0x3fdb881a + .long 0x2c99792a,0x3e8de7b6 + .long 0x00000000,0x3fdbad0b + .long 0x85ec7449,0x3e82ef03 + .long 0x00000000,0x3fdbd212 + .long 0x0c4250d7,0x3e6b7844 + .long 0x00000000,0x3fdc0392 + .long 0xfce511d5,0x3e5e4d32 + .long 0x00000000,0x3fdc28cb + .long 0x78348ca5,0x3e8708e4 + .long 0x00000000,0x3fdc4e19 + .long 0x992488fb,0x3e88e8aa + .long 0x00000000,0x3fdc7ff9 + .long 0xc144344b,0x3e793a76 + .long 0x00000000,0x3fdca57b + .long 0x5f7d6efe,0x3e44b9d7 + .long 0x00000000,0x3fdccb13 + .long 0x4de9f3e0,0x3e8a31e6 + .long 0x00000000,0x3fdcf0c0 + .long 0x80488966,0x3e7d6d68 + .long 0x00000000,0x3fdd2320 + .long 0x9add7f4d,0x3e71b7be + .long 0x00000000,0x3fdd4902 + .long 0xb9ac5131,0x3e8231a4 + .long 0x00000000,0x3fdd6efa + .long 0x4bdc3bac,0x3e7c1eb9 + .long 0x00000000,0x3fdd9509 + .long 0xaa85604a,0x3e8fd258 + .long 0x00000000,0x3fddbb2e + .long 0x57753a10,0x3e6a22f2 + .long 0x00000000,0x3fddee2f + .long 0xcd94df8d,0x3e5a2726 + .long 0x00000000,0x3fde148a + .long 0x7ff6aa8c,0x3e4493fe + .long 0x00000000,0x3fde3afc + .long 0xb6cae4c0,0x3e6036a8 + .long 0x00000000,0x3fde6185 + .long 0x546c92af,0x3e7e208f + .long 0x00000000,0x3fde8825 + .long 0x8619d6bd,0x3e67564c + .long 0x00000000,0x3fdeaedd + .long 0xf8b97910,0x3e77d0da + .long 0x00000000,0x3fded5ac + .long 0x5c542068,0x3e6368b5 + .long 0x00000000,0x3fdefc93 + .long 0xbff8880b,0x3e8442ae + .long 0x00000000,0x3fdf2391 + .long 0x259bcade,0x3e8dc063 + .long 0x00000000,0x3fdf4aa7 + .long 0xd802b8c4,0x3e63e185 + .long 0x00000000,0x3fdf71d6 + .long 0xde5f6650,0x3e7b2cec + .long 0x00000000,0x3fdf991c + .long 0x21ff49a1,0x3e8b4d35 + .long 0x00000000,0x3fdfc07a + .long 0xa7c2b8c5,0x3e81d607 + .long 0x00000000,0x3fdfe7f1 + .long 0x0b9d6ee5,0x3e84f140 + .long 0x00000000,0x3fe007c0 + .long 0xd0756a93,0x3e70cc52 + .long 0x00000000,0x3fe01b94 + .long 0x3aad0772,0x3e800319 + .long 0x00000000,0x3fe02f74 + .long 0x759dd00c,0x3e97cec0 + .long 0x00000000,0x3fe04360 + .long 0xc67418f8,0x3e9588ff + .long 0x00000000,0x3fe05759 + .long 0x51e8da67,0x3e6911cf + .long 0x00000000,0x3fe06b5f + .long 0xa048907b,0x3e44cf15 + .long 0x00000000,0x3fe078bf + .long 0xc39803ff,0x3e8a1f9e + .long 0x00000000,0x3fe08cd9 + .long 0x06525ba1,0x3e8d33e4 + .long 0x00000000,0x3fe0a100 + .long 0x3b46098d,0x3e7d11a2 + .long 0x00000000,0x3fe0b534 + .long 0x39b814fa,0x3e991286 + .long 0x00000000,0x3fe0c974 + .long 0x432f7532,0x3e782dcc + .long 0x00000000,0x3fe0ddc2 + .long 0x4618affd,0x3e82ebf2 + .long 0x00000000,0x3fe0eb52 + .long 0x1d77bbef,0x3e8084e9 + .long 0x00000000,0x3fe0ffb5 + .long 0xcfaf1c2c,0x3e7ed4be + .long 0x00000000,0x3fe11425 + .long 0xbfce7a70,0x3e83c766 + .long 0x00000000,0x3fe128a2 + .long 0x1930b4c4,0x3e84afc2 + .long 0x00000000,0x3fe13652 + .long 0x4b441313,0x3e862d2a + .long 0x00000000,0x3fe14ae5 + .long 0xcb6b7c9c,0x3e94338e + .long 0x00000000,0x3fe15f85 + .long 0xfd3aea12,0x3e7c608c + .long 0x00000000,0x3fe16d4d + .long 0x266a0b45,0x3e9841ba + .long 0x00000000,0x3fe18203 + .long 0xe75899eb,0x3e978963 + .long 0x00000000,0x3fe196c7 + .long 0x9e2b1260,0x3e7c5bd1 + .long 0x00000000,0x3fe1a4a7 + .long 0xa79bc2a5,0x3e98192c + .long 0x00000000,0x3fe1b981 + .long 0x0d5eb986,0x3e9d1762 + .long 0x00000000,0x3fe1ce69 + .long 0x28836a17,0x3e93bc0d + .long 0x00000000,0x3fe1dc61 + .long 0xb47416ca,0x3e9455a1 + .long 0x00000000,0x3fe1f160 + .long 0xdf997414,0x3e8dd01c + .long 0x00000000,0x3fe2066d + .long 0x72755e61,0x3e9748f4 + .long 0x00000000,0x3fe2147d + .long 0x586cc870,0x3e978bd7 + .long 0x00000000,0x3fe229a1 + .long 0x05ced5b8,0x3e90834a + .long 0x00000000,0x3fe237c1 + .long 0xb34d2934,0x3e9cdf01 + .long 0x00000000,0x3fe24cfc + .long 0xd891ba01,0x3e857355 + .long 0x00000000,0x3fe25b2c + .long 0x103a61e4,0x3e8357df + .long 0x00000000,0x3fe2707f + .long 0x7071361a,0x3e908594 + .long 0x00000000,0x3fe285e0 + .long 0xdcc2f0a7,0x3e81c22d + .long 0x00000000,0x3fe29429 + .long 0xc30f37c8,0x3e89c2bf + .long 0x00000000,0x3fe2a9a2 + .long 0x604c3ff4,0x3e76468e + .long 0x00000000,0x3fe2b7fb + .long 0x7d42bf88,0x3e88e57d + .long 0x00000000,0x3fe2c65a + .long 0xd0b235f1,0x3e85ec37 + .long 0x00000000,0x3fe2dbf5 + .long 0xca965170,0x3e987f2e + .long 0x00000000,0x3fe2ea64 + .long 0xb996d64e,0x3e71b426 + .long 0x00000000,0x3fe30018 + .long 0xb998ef97,0x3e9d3516 + .long 0x00000000,0x3fe30e97 + .long 0x9d3de3b9,0x3e9d7ba6 + .long 0x00000000,0x3fe32463 + .long 0xcad27856,0x3e78a56b + .long 0x00000000,0x3fe332f4 + .long 0x9f9e227c,0x3e5ce8c9 + .long 0x00000000,0x3fe348d9 + .long 0xadb2d775,0x3e9f1887 + .long 0x00000000,0x3fe35779 + .long 0x53263e64,0x3e92c34d + .long 0x00000000,0x3fe36621 + .long 0xcd4571cb,0x3e93e786 + .long 0x00000000,0x3fe37c29 + .long 0xe748544b,0x3e671976 + .long 0x00000000,0x3fe38ae2 + .long 0xf9cce311,0x3e85e980 + .long 0x00000000,0x3fe399a1 + .long 0x3a222092,0x3e9fcef7 + .long 0x00000000,0x3fe3afcc + .long 0xed5008bd,0x3e840d4c + .long 0x00000000,0x3fe3be9d + .long 0x1452e9ec,0x3e901695 + .long 0x00000000,0x3fe3cd74 + .long 0xb62b2ce8,0x3e7c8c7b + .long 0x00000000,0x3fe3e3c4 + .long 0xd8d571ad,0x3e964fda + .long 0x00000000,0x3fe3f2ac + .long 0x498c3678,0x3e7092e5 + .long 0x00000000,0x3fe4019c + .long 0xc8960bd4,0x3e884e25 + .long 0x00000000,0x3fe41810 + .long 0x5157ce35,0x3e84637d + .long 0x00000000,0x3fe42711 + .long 0xafcc2a6b,0x3e8384ad + .long 0x00000000,0x3fe43619 + .long 0x9a4ffe6d,0x3e875a3a + .long 0x00000000,0x3fe44528 + .long 0x4e8516c0,0x3e819322 + .long 0x00000000,0x3fe45bcc + .long 0xfe3457c8,0x3e70f88b + .long 0x00000000,0x3fe46aed + .long 0x69a4a836,0x3e73f451 + .long 0x00000000,0x3fe47a15 + .long 0x32f98351,0x3e87bfff + .long 0x00000000,0x3fe48944 + .long 0x06a8d925,0x3e9796d3 + .long 0x00000000,0x3fe4a018 + .long 0xaef076e2,0x3e593acb + .long 0x00000000,0x3fe4af5a + .long 0xd0e13620,0x3e94b7b7 + .long 0x00000000,0x3fe4bea2 + .long 0x88cfb12e,0x3e91e215 + .long 0x00000000,0x3fe4cdf2 + .long 0x0b0cb912,0x3e99f328 + .long 0x00000000,0x3fe4dd49 + .long 0xa0e67b10,0x3e8b9929 + .long 0x00000000,0x3fe4eca8 + .long 0xb401f873,0x3e7e6c75 + .long 0x00000000,0x3fe503c4 + .long 0x15ce5326,0x3e8999ff + .long 0x00000000,0x3fe51335 + .long 0x5f3840b2,0x3e4ce28f + .long 0x00000000,0x3fe522ae + .long 0x2b9988ba,0x3e73433c + .long 0x00000000,0x3fe5322e + .long 0x0122cc5c,0x3e9972f3 + .long 0x00000000,0x3fe541b5 + .long 0xac4eb353,0x3e9fb797 + .long 0x00000000,0x3fe55144 + .long 0x78d26225,0x3e988a2a + .long 0x00000000,0x3fe560db + .long 0x333017fe,0x3e735dc6 + .long 0x00000000,0x3fe5707a + .long 0xff9e8c9a,0x3e5dab71 + .long 0x00000000,0x3fe587f6 + .long 0xe623c257,0x3e92ef91 + .long 0x00000000,0x3fe597a7 + .long 0x715f0d98,0x3e9ac697 + .long 0x00000000,0x3fe5a760 + .long 0x21dc5b09,0x3e9a52be + .long 0x00000000,0x3fe5b721 + .long 0xdf20565e,0x3e928863 + .long 0x00000000,0x3fe5c6ea + .long 0x7afa1d46,0x3e717543 + .long 0x00000000,0x3fe5d6bb + .long 0x71f3b726,0x3e90c8ba + .long 0x00000000,0x3fe5e693 + .long 0xda3470be,0x3e98c345 + .long 0x00000000,0x3fe5f673 + .long 0x24c45894,0x3e9d470b + .long 0x00000000,0x3fe6065b + .long 0x0d6b6214,0x3e9f4f98 + .long 0x00000000,0x3fe6164b + .long 0xe85e3147,0x3e9fd9f2 + .long 0x00000000,0x3fe62643 + .type __libm_log_table_256,@object + .size __libm_log_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/logb_gen.S b/external/sgx_libm/intel64/logb_gen.S new file mode 100644 index 0000000000..d1f8050802 --- /dev/null +++ b/external/sgx_libm/intel64/logb_gen.S @@ -0,0 +1,132 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logb_gen.c" + .text +..TXTST0: +# -- Begin logb + .text + .align 16,0x90 + .globl logb +logb: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_logb.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + movl %eax, %edx + andl $2147483647, %edx + lea -1048576(%rdx), %ecx + cmpl $2145386496, %ecx + jb ..B1.7 +..B1.2: + testl %ecx, %ecx + jge ..B1.6 +..B1.3: + movl -8(%rsp), %eax + orl %eax, %edx + je ..B1.8 +..B1.4: + lea _TWO_55(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) + pxor %xmm0, %xmm0 + movl -4(%rsp), %edx + andl $2147483647, %edx + shrl $20, %edx + addl $-1078, %edx + cvtsi2sd %edx, %xmm0 +..B1.5: + ret +..B1.6: + lea _ones(%rip), %rdx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm1 + mulsd %xmm1, %xmm0 + ret +..B1.7: + shrl $20, %ecx + pxor %xmm0, %xmm0 + addl $-1022, %ecx + cvtsi2sd %ecx, %xmm0 + ret +..B1.8: + lea 8+_ones(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + divsd (%rdx), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type logb,@function + .size logb,.-logb + .data +# -- End logb + .section .rodata, "a" + .align 4 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .type _TWO_55,@object + .size _TWO_55,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/logbf.S b/external/sgx_libm/intel64/logbf.S new file mode 100644 index 0000000000..330dd4f8aa --- /dev/null +++ b/external/sgx_libm/intel64/logbf.S @@ -0,0 +1,123 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logbf.c" + .text +..TXTST0: +# -- Begin logbf + .text + .align 16,0x90 + .globl logbf +logbf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_logbf.1: +..L2: + + movd %xmm0, %eax + movss %xmm0, -8(%rsp) + movl %eax, %edx + andl $2147483647, %edx + addl $-8388608, %edx + cmpl $2130706432, %edx + jb ..B1.7 +..B1.2: + testl %edx, %edx + jge ..B1.6 +..B1.3: + cmpl $-8388608, %edx + je ..B1.8 +..B1.4: + movss -8(%rsp), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + movd %xmm0, %eax + movss %xmm0, -8(%rsp) + pxor %xmm0, %xmm0 + andl $2147483647, %eax + shrl $23, %eax + addl $-152, %eax + cvtsi2ss %eax, %xmm0 +..B1.5: + ret +..B1.6: + lea _ones(%rip), %rdx + shrl $31, %eax + movss (%rdx,%rax,4), %xmm1 + mulss %xmm1, %xmm0 + ret +..B1.7: + shrl $23, %edx + pxor %xmm0, %xmm0 + addl $-126, %edx + cvtsi2ss %edx, %xmm0 + ret +..B1.8: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type logbf,@function + .size logbf,.-logbf + .data +# -- End logbf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/logbl.S b/external/sgx_libm/intel64/logbl.S new file mode 100644 index 0000000000..629052bf4f --- /dev/null +++ b/external/sgx_libm/intel64/logbl.S @@ -0,0 +1,165 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logbl.c" + .text +..TXTST0: +# -- Begin logbl + .text + .align 16,0x90 + .globl logbl +logbl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_logbl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %al, %al +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 26(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.7 +..B1.4: + orl $-64768, %ecx + movw %cx, 24(%rsp) +..B1.5: + fldcw 24(%rsp) +..B1.6: + movb $1, %al +..B1.7: + movzwl 56(%rsp), %edx + andl $32767, %edx + cmpl $32767, %edx + je ..B1.16 +..B1.8: + testl %edx, %edx + jne ..B1.11 +..B1.9: + cmpq $0, 48(%rsp) + je ..B1.15 +..B1.10: + fldt 48(%rsp) + lea _TWO_75(%rip), %rdx + fmull (%rdx) + fstpt 48(%rsp) + movzwl 56(%rsp), %ecx + andl $32767, %ecx + addl $-16458, %ecx + movl %ecx, (%rsp) + fildl (%rsp) + fstpt 8(%rsp) + jmp ..B1.12 +..B1.11: + addl $-16383, %edx + movl %edx, (%rsp) + fildl (%rsp) + fstpt 8(%rsp) +..B1.12: + testb %al, %al + je ..B1.14 +..B1.13: + fldcw 26(%rsp) +..B1.14: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.15: + lea 8+_ones(%rip), %rdx + lea _zeros(%rip), %rcx + movsd (%rdx), %xmm0 + divsd (%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 8(%rsp) + jmp ..B1.12 +..B1.16: + fldt 48(%rsp) + lea _ones(%rip), %rcx + movb 57(%rsp), %dl + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + fmull (%rcx,%rsi,8) + fstpt 8(%rsp) + jmp ..B1.12 + .align 16,0x90 + .cfi_endproc + .type logbl,@function + .size logbl,.-logbl + .data +# -- End logbl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/logf_gen.S b/external/sgx_libm/intel64/logf_gen.S new file mode 100644 index 0000000000..9b3bd3f0f8 --- /dev/null +++ b/external/sgx_libm/intel64/logf_gen.S @@ -0,0 +1,234 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logf_gen.c" + .text +..TXTST0: +# -- Begin logf + .text + .align 16,0x90 + .globl logf +logf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_logf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + cmpl $2139095040, %edx + jae ..B1.11 +..B1.2: + lea -1065091072(%rdx), %eax + cmpl $524288, %eax + jae ..B1.7 +..B1.3: + cmpl $1065353216, %edx + jne ..B1.5 +..B1.4: + pxor %xmm3, %xmm3 + jmp ..B1.6 +..B1.5: + movss -8(%rsp), %xmm0 + lea 32+_Q(%rip), %rax + lea 24+_Q(%rip), %rcx + addss .L_2il0floatpacket.0(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + movaps %xmm0, %xmm2 + lea 16+_Q(%rip), %rdx + movsd (%rax), %xmm3 + lea 8+_Q(%rip), %rsi + movsd (%rcx), %xmm1 + lea _Q(%rip), %rdi + mulsd %xmm0, %xmm2 + mulsd %xmm2, %xmm3 + mulsd %xmm2, %xmm1 + addsd (%rdx), %xmm3 + addsd (%rsi), %xmm1 + mulsd %xmm2, %xmm3 + mulsd %xmm0, %xmm1 + addsd %xmm1, %xmm3 + addsd (%rdi), %xmm3 + mulsd %xmm2, %xmm3 + addsd %xmm0, %xmm3 + cvtsd2ss %xmm3, %xmm3 +..B1.6: + movaps %xmm3, %xmm0 + ret +..B1.7: + movl %edx, %esi + movl %edx, %eax + shrl $23, %esi + andl $8388607, %eax + addl $-127, %esi + cmpl $8388608, %edx + jae ..B1.10 +..B1.8: + movl %eax, -8(%rsp) + testl %edx, %edx + je ..B1.19 +..B1.9: + movss -8(%rsp), %xmm0 + mulss .L_2il0floatpacket.2(%rip), %xmm0 + movd %xmm0, %eax + movss %xmm0, -8(%rsp) + movl %eax, %esi + movl %eax, %edx + shrl $23, %esi + addl $-152, %esi +..B1.10: + shrl $15, %edx + orl $1065353216, %eax + movzbl %dl, %r8d + pxor %xmm1, %xmm1 + movl %eax, -8(%rsp) + pxor %xmm0, %xmm0 + movq __libm_rcp_table_256@GOTPCREL(%rip), %rax + lea 8+_P(%rip), %rdx + cvtss2sd -8(%rsp), %xmm1 + cvtss2sd (%rax,%r8,4), %xmm0 + mulsd %xmm0, %xmm1 + lea _P(%rip), %rcx + movsd (%rdx), %xmm0 + pxor %xmm2, %xmm2 + cvtsi2sd %esi, %xmm2 + addsd .L_2il0floatpacket.1(%rip), %xmm1 + mulsd %xmm1, %xmm0 + lea _LN2(%rip), %rsi + mulsd (%rsi), %xmm2 + addsd (%rcx), %xmm0 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movq __libm_logf_table_256@GOTPCREL(%rip), %rdi + addsd %xmm1, %xmm0 + addsd (%rdi,%r8,8), %xmm2 + addsd %xmm2, %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.11: + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.17 +..B1.12: + testl $-2147483648, %edx + je ..B1.17 +..B1.13: + testl %eax, %eax + jne ..B1.15 +..B1.14: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + ret +..B1.15: + movss .L_2il0floatpacket.3(%rip), %xmm1 + pxor %xmm0, %xmm0 + mulss %xmm1, %xmm0 +..B1.16: + ret +..B1.17: + movss -8(%rsp), %xmm0 + ret +..B1.19: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type logf,@function + .size logf,.-logf + .data +# -- End logf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x4c000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x7f800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_Q: + .long 4294868184 + .long 3219128319 + .long 1443356411 + .long 1070945621 + .long 823147527 + .long 3218079745 + .long 748089218 + .long 1070176642 + .long 1053536005 + .long 3217353219 + .type _Q,@object + .size _Q,40 + .align 4 +_P: + .long 3879088107 + .long 3219128321 + .long 1754324240 + .long 1070945626 + .type _P,@object + .size _P,16 + .align 4 +_LN2: + .long 4277811695 + .long 1072049730 + .type _LN2,@object + .size _LN2,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/logf_table.S b/external/sgx_libm/intel64/logf_table.S new file mode 100644 index 0000000000..9122ccb3c6 --- /dev/null +++ b/external/sgx_libm/intel64/logf_table.S @@ -0,0 +1,303 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logf_table.c" + .section .rodata, "a" + .align 32 + .align 32 + .globl __libm_logf_table_256 +__libm_logf_table_256: + .long 0x55d5889e,0x3f600401 + .long 0x14586b54,0x3f781212 + .long 0xf96832f0,0x3f841929 + .long 0x84c75f07,0x3f8c3173 + .long 0x1ac73386,0x3f91a6b9 + .long 0x5d9ac03a,0x3f95ba9a + .long 0x074325f4,0x3f99d2a8 + .long 0x25979802,0x3f9d6b27 + .long 0xa19dfaa9,0x3fa0c58f + .long 0x78cbce1b,0x3fa2954c + .long 0x2da96c57,0x3fa4a94d + .long 0xf2d4bb58,0x3fa67c94 + .long 0xb630f068,0x3fa85188 + .long 0xbe73af4c,0x3faa6b8a + .long 0x06f72a9e,0x3fac441e + .long 0x13606d07,0x3fae1e67 + .long 0x11ab9301,0x3faffa69 + .long 0x9c5da601,0x3fb0ec13 + .long 0x643d190b,0x3fb1dbd2 + .long 0x84fe5f1c,0x3fb2cc72 + .long 0xa7d1ee64,0x3fb3bdf5 + .long 0x7aa012e0,0x3fb4b05d + .long 0x7ceb5702,0x3fb580db + .long 0x89365a7a,0x3fb674f0 + .long 0x2c6b568d,0x3fb769ef + .long 0x27506a48,0x3fb85fd9 + .long 0x5d594989,0x3fb9335e + .long 0x20c8e5f5,0x3fba2b02 + .long 0xac1a86ac,0x3fbb0004 + .long 0x769fca11,0x3fbbf968 + .long 0xbfee13a8,0x3fbccfed + .long 0x638446a2,0x3fbda727 + .long 0x7fe10f7a,0x3fbea325 + .long 0xfedbfde6,0x3fbf7be9 + .long 0x52ff25f4,0x3fc02ab3 + .long 0x579d204d,0x3fc097ce + .long 0x8227e47c,0x3fc1178e + .long 0x7dbecf34,0x3fc18574 + .long 0x25f25d41,0x3fc1f3b9 + .long 0x1e6ddf57,0x3fc2625d + .long 0x0c86813a,0x3fc2d161 + .long 0x9741142e,0x3fc340c5 + .long 0x6757f2a9,0x3fc3b08b + .long 0x08378004,0x3fc40dfb + .long 0xe8ca5f7c,0x3fc47e74 + .long 0xf6466de4,0x3fc4ef51 + .long 0xe02ba516,0x3fc56092 + .long 0x57cd74d5,0x3fc5d238 + .long 0x37335d76,0x3fc6313a + .long 0xdabbd383,0x3fc6a399 + .long 0xdd3ce41a,0x3fc70337 + .long 0x128f6127,0x3fc77654 + .long 0x2a0b022d,0x3fc7e9d8 + .long 0x759f512f,0x3fc84a6b + .long 0xd5f5a310,0x3fc8ab47 + .long 0x9096581b,0x3fc91fe4 + .long 0x4011aa76,0x3fc98163 + .long 0x07089664,0x3fc9f6c4 + .long 0x29348f43,0x3fca58e7 + .long 0xc31693ad,0x3fcabb55 + .long 0x4919efd0,0x3fcb1e10 + .long 0x93e367cb,0x3fcb94ee + .long 0xc067555f,0x3fcbf851 + .long 0x54bf23a6,0x3fcc5c02 + .long 0xc9db3c52,0x3fccc000 + .long 0x99c85674,0x3fcd244d + .long 0x3fb2f450,0x3fcd88e9 + .long 0x37eaef01,0x3fcdedd4 + .long 0xffe71012,0x3fce530e + .long 0x1648b971,0x3fceb89a + .long 0xfadf9bde,0x3fcf1e75 + .long 0x2ead7c36,0x3fcf84a3 + .long 0x33ea07cd,0x3fcfeb22 + .long 0xc7035c1c,0x3fd028f9 + .long 0xe0d9635a,0x3fd05c8b + .long 0x8f8ae797,0x3fd085eb + .long 0xe32d1911,0x3fd0b9c8 + .long 0x60b78081,0x3fd0edd0 + .long 0x4cf0063f,0x3fd12202 + .long 0x927aecd4,0x3fd14be2 + .long 0x8ef18adf,0x3fd18061 + .long 0xbe2fc63b,0x3fd1b50b + .long 0xc7cf242d,0x3fd1df4c + .long 0x6d0eb8d4,0x3fd21445 + .long 0x991eba49,0x3fd23ec5 + .long 0x9f870afb,0x3fd2740d + .long 0xabcdfa04,0x3fd29ecd + .long 0x02adccee,0x3fd2d466 + .long 0xb04ea9d4,0x3fd2ff66 + .long 0x4b355a38,0x3fd33550 + .long 0x5ec44f5d,0x3fd36092 + .long 0xc3337e75,0x3fd38bf1 + .long 0x77333184,0x3fd3c252 + .long 0x63c1683e,0x3fd3edf4 + .long 0x23d5e8c7,0x3fd419b4 + .long 0xe0539f49,0x3fd44591 + .long 0x75b6f0ad,0x3fd47c91 + .long 0x41552b09,0x3fd4a8b3 + .long 0x908901a0,0x3fd4d4f3 + .long 0x8da1f968,0x3fd50152 + .long 0x6347d4f6,0x3fd52dd0 + .long 0x3c7b8a8a,0x3fd55a6d + .long 0x2b112a59,0x3fd5925d + .long 0x6b543db2,0x3fd5bf40 + .long 0x3d5c35ae,0x3fd5ec43 + .long 0xcdb02c1f,0x3fd61965 + .long 0x4935b2a2,0x3fd646a8 + .long 0xdd31de95,0x3fd6740a + .long 0xb74a58c5,0x3fd6a18d + .long 0x058670ec,0x3fd6cf31 + .long 0xe852f0ba,0x3fd6f180 + .long 0x71b894f0,0x3fd71f5d + .long 0xefd66d5c,0x3fd74d5a + .long 0x922bd37e,0x3fd77b79 + .long 0x889f19e2,0x3fd7a9b9 + .long 0x037eb6a6,0x3fd7d81b + .long 0x33827231,0x3fd8069e + .long 0xd3ef8bcb,0x3fd82996 + .long 0x776dcbfb,0x3fd85855 + .long 0x58327ccf,0x3fd88736 + .long 0x973ab8cf,0x3fd8aa75 + .long 0xdc8824e5,0x3fd8d992 + .long 0xea7d9512,0x3fd908d2 + .long 0xe79c0e56,0x3fd92c59 + .long 0x50ee3ed3,0x3fd95bd7 + .long 0x11a3ee5b,0x3fd98b78 + .long 0xf33d406c,0x3fd9af47 + .long 0x0c1914a8,0x3fd9df27 + .long 0xed14fda5,0x3fda0325 + .long 0x0224fa79,0x3fda3344 + .long 0x5e80c383,0x3fda5772 + .long 0x165dd199,0x3fda87d0 + .long 0x6c03f896,0x3fdaac2e + .long 0x6fdf6a81,0x3fdadccc + .long 0x3eb1e790,0x3fdb015b + .long 0x3a635948,0x3fdb323a + .long 0x04462909,0x3fdb56fa + .long 0xa659bc93,0x3fdb881a + .long 0xef3db165,0x3fdbad0b + .long 0x97781c2f,0x3fdbd212 + .long 0x36f08819,0x3fdc0392 + .long 0x1e4d32fd,0x3fdc28cb + .long 0xb84723c2,0x3fdc4e19 + .long 0xc74554c9,0x3fdc7ff9 + .long 0x64e9db05,0x3fdca57b + .long 0x0a5cebb0,0x3fdccb13 + .long 0xd18f326f,0x3fdcf0c0 + .long 0x75b5a201,0x3fdd2320 + .long 0x46defa6b,0x3fdd4902 + .long 0x918d25cd,0x3fdd6efa + .long 0x707ae52f,0x3fdd9509 + .long 0xfe92c554,0x3fddbb2e + .long 0x3445e4af,0x3fddee2f + .long 0x1a2726ce,0x3fde148a + .long 0x0a49ff40,0x3fde3afc + .long 0x206d516e,0x3fde6185 + .long 0x78823d52,0x3fde8825 + .long 0x2eac990c,0x3fdeaedd + .long 0x5f436be3,0x3fded5ac + .long 0x26d16ab9,0x3fdefc93 + .long 0xa2157600,0x3fdf2391 + .long 0xee03192d,0x3fdf4aa7 + .long 0x27c30bb0,0x3fdf71d6 + .long 0x6cb3b379,0x3fdf991c + .long 0xda69a910,0x3fdfc07a + .long 0x8eb03d3e,0x3fdfe7f1 + .long 0x53c5002e,0x3fe007c0 + .long 0x2198a5a1,0x3fe01b94 + .long 0x400c64eb,0x3fe02f74 + .long 0xbe7603ad,0x3fe04360 + .long 0xac47fe34,0x3fe05759 + .long 0x1911cf52,0x3fe06b5f + .long 0x0533c568,0x3fe078bf + .long 0x687e7b0e,0x3fe08cd9 + .long 0x74cf9019,0x3fe0a100 + .long 0x3a234477,0x3fe0b534 + .long 0xc89431ce,0x3fe0c974 + .long 0x305b9886,0x3fe0ddc2 + .long 0x4bafc918,0x3fe0eb52 + .long 0x4213a476,0x3fe0ffb5 + .long 0x3da97d9f,0x3fe11425 + .long 0x4f1d9aff,0x3fe128a2 + .long 0x52bf0865,0x3fe13652 + .long 0x58b4a92d,0x3fe14ae5 + .long 0xa19c765b,0x3fe15f85 + .long 0x38c119fa,0x3fe16d4d + .long 0xc20dd133,0x3fe18203 + .long 0xbc4b1f3b,0x3fe196c7 + .long 0x38b7a33c,0x3fe1a4a7 + .long 0xc0c9653d,0x3fe1b981 + .long 0xe8bb106b,0x3fe1ce69 + .long 0x9de06944,0x3fe1dc61 + .long 0xa2ad0da4,0x3fe1f160 + .long 0x7740737e,0x3fe2066d + .long 0xba47a394,0x3fe2147d + .long 0xbc5ebac3,0x3fe229a1 + .long 0x841a502e,0x3fe237c1 + .long 0xe6f80d9a,0x3fe24cfc + .long 0x55cd5762,0x3fe25b2c + .long 0x4d5f7c41,0x3fe2707f + .long 0x842ca384,0x3fe285e0 + .long 0x4708b773,0x3fe29429 + .long 0x670aff0c,0x3fe2a9a2 + .long 0x2c8d1cc1,0x3fe2b7fb + .long 0x6395f5f5,0x3fe2c65a + .long 0x57b0df43,0x3fe2dbf5 + .long 0xc3f97655,0x3fe2ea64 + .long 0x23684d73,0x3fe30018 + .long 0xe9a8b5cd,0x3fe30e97 + .long 0xebdd34ea,0x3fe32463 + .long 0x314ad796,0x3fe332f4 + .long 0x0e7464d0,0x3fe348d9 + .long 0xf8c43d6e,0x3fe35779 + .long 0x961a6a99,0x3fe36621 + .long 0x9f3c366a,0x3fe37c29 + .long 0x171976e7,0x3fe38ae2 + .long 0x57a603e7,0x3fe399a1 + .long 0xfe77b9d1,0x3fe3afcc + .long 0x503533b5,0x3fe3be9d + .long 0x80b4a8a3,0x3fe3cd74 + .long 0x3918f76c,0x3fe3e3c4 + .long 0xb27ed6c7,0x3fe3f2ac + .long 0x2125ca93,0x3fe4019c + .long 0x61389722,0x3fe41810 + .long 0x518df545,0x3fe42711 + .long 0x4e12b6bf,0x3fe43619 + .long 0x5d68ea69,0x3fe44528 + .long 0x464c893a,0x3fe45bcc + .long 0x21f117fc,0x3fe46aed + .long 0x27e8a2d3,0x3fe47a15 + .long 0x5efffccc,0x3fe48944 + .long 0xbcb69835,0x3fe4a018 + .long 0x0c9d65d7,0x3fe4af5a + .long 0xa5bdbe87,0x3fe4bea2 + .long 0x8f10ac47,0x3fe4cdf2 + .long 0xcf994058,0x3fe4dd49 + .long 0x6e64a684,0x3fe4eca8 + .long 0x3cd8eb68,0x3fe503c4 + .long 0x6667fc57,0x3fe51335 + .long 0x0738a3d8,0x3fe522ae + .long 0x26867857,0x3fe5322e + .long 0xcb979809,0x3fe541b5 + .long 0xfdbcbd62,0x3fe55144 + .long 0xc45153c7,0x3fe560db + .long 0x26bb8c66,0x3fe5707a + .long 0x0ed5b900,0x3fe587f6 + .long 0x977c8f31,0x3fe597a7 + .long 0xd634bb8b,0x3fe5a760 + .long 0xd295f10f,0x3fe5b721 + .long 0x94431ef9,0x3fe5c6ea + .long 0x22ea86f6,0x3fe5d6bb + .long 0x8645d390,0x3fe5e693 + .long 0xc61a2ed2,0x3fe5f673 + .long 0xea385926,0x3fe6065b + .long 0xfa7cc06b,0x3fe6164b + .long 0xfecf9743,0x3fe62643 + .type __libm_logf_table_256,@object + .size __libm_logf_table_256,2048 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/logl.S b/external/sgx_libm/intel64/logl.S new file mode 100644 index 0000000000..5479c7e4e0 --- /dev/null +++ b/external/sgx_libm/intel64/logl.S @@ -0,0 +1,66 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logl.c" + .text +..TXTST0: +# -- Begin logl + .text + .align 16,0x90 + .globl logl +logl: +# parameter 1: 8 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_logl.1: +..L2: + + fldt 8(%rsp) + fstpt 8(%rsp) + jmp __libm_logl@PLT + .align 16,0x90 + .cfi_endproc + .type logl,@function + .size logl,.-logl + .data +# -- End logl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/logl_table.S b/external/sgx_libm/intel64/logl_table.S new file mode 100644 index 0000000000..596f44159c --- /dev/null +++ b/external/sgx_libm/intel64/logl_table.S @@ -0,0 +1,559 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "logl_table.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __libm_logl_table_256 +__libm_logl_table_256: + .long 0x55d5a000,0x3f600401 + .long 0xf98e1114,0xbce76218 + .long 0x14588000,0x3f781212 + .long 0xf5a30364,0xbcf4abf1 + .long 0xf9684000,0x3f841929 + .long 0xa8bfb25e,0xbcfa20e2 + .long 0x84c74000,0x3f8c3173 + .long 0x18823013,0x3d0f0660 + .long 0x1ac72000,0x3f91a6b9 + .long 0x36a9c5bb,0x3d13861d + .long 0x5d9ac000,0x3f95ba9a + .long 0xe08d78ac,0x3cacbb84 + .long 0x07434000,0x3f99d2a8 + .long 0xeb1d2ef8,0xbd1a0c1f + .long 0x2597c000,0x3f9d6b27 + .long 0xa1a37071,0xbd23fef6 + .long 0xa19e0000,0x3fa0c58f + .long 0x58b17913,0xbd0559d1 + .long 0x78cbc000,0x3fa2954c + .long 0x570c1572,0x3d1c3526 + .long 0x2da98000,0x3fa4a94d + .long 0xbad48944,0xbd23a98f + .long 0xf2d4c000,0x3fa67c94 + .long 0xec19afa2,0xbd029efb + .long 0xb6310000,0x3fa85188 + .long 0xdf4d03fb,0xbd1f2fd5 + .long 0xbe73c000,0x3faa6b8a + .long 0x5c8ed1b8,0xbd20b3b9 + .long 0x06f74000,0x3fac441e + .long 0x6cf5e5d5,0xbd2561c1 + .long 0x13608000,0x3fae1e67 + .long 0xa4275f13,0xbd22f961 + .long 0x11ab8000,0x3faffa69 + .long 0x98381a8f,0x3d23008c + .long 0x9c5da000,0x3fb0ec13 + .long 0xe54ebd73,0x3d180247 + .long 0x643d2000,0x3fb1dbd2 + .long 0x9a20edb0,0xbd1bd36c + .long 0x84fe6000,0x3fb2cc72 + .long 0x34cd5d84,0xbcec742f + .long 0xa7d1e000,0x3fb3bdf5 + .long 0xa5db4ed7,0x3d2cc85e + .long 0x7aa00000,0x3fb4b05d + .long 0x8ddf26e3,0x3d32e053 + .long 0x7ceb8000,0x3fb580db + .long 0x26833e56,0xbd447f01 + .long 0x89364000,0x3fb674f0 + .long 0x4c9d3302,0x3d3a7999 + .long 0x2c6b8000,0x3fb769ef + .long 0xe71892b5,0xbd44b944 + .long 0x27508000,0x3fb85fd9 + .long 0x19970c1c,0xbd35b818 + .long 0x5d594000,0x3fb9335e + .long 0x3abd47da,0x3d23115c + .long 0x20c90000,0x3fba2b02 + .long 0x9c652090,0xbd3a0b35 + .long 0xac1a8000,0x3fbb0004 + .long 0x037f2b35,0x3d1aaf97 + .long 0x769fc000,0x3fbbf968 + .long 0x8d824283,0x3d24218c + .long 0xbfee0000,0x3fbccfed + .long 0x2fe71256,0x3d33a823 + .long 0x63844000,0x3fbda727 + .long 0x1fa71733,0x3d1a8940 + .long 0x7fe10000,0x3fbea325 + .long 0x47e4627a,0x3d2ef30d + .long 0xfedc0000,0x3fbf7be9 + .long 0x2b2b3bc6,0xbd00d05d + .long 0x52ff2000,0x3fc02ab3 + .long 0x5d569b2b,0x3d27ce63 + .long 0x579d2000,0x3fc097ce + .long 0xda652881,0x3ce33742 + .long 0x82280000,0x3fc1178e + .long 0xcc74be04,0xbd4b8421 + .long 0x7dbec000,0x3fc18574 + .long 0x45bd9b49,0x3d3e6744 + .long 0x25f26000,0x3fc1f3b9 + .long 0x9b083633,0xbd15f74e + .long 0x1e6de000,0x3fc2625d + .long 0xf09e3d82,0xbcf52962 + .long 0x0c868000,0x3fc2d161 + .long 0xcb81b4a1,0x3d039d6c + .long 0x97412000,0x3fc340c5 + .long 0xf7d9d386,0xbd37a3dc + .long 0x67580000,0x3fc3b08b + .long 0xf29320fb,0xbd3aade8 + .long 0x08378000,0x3fc40dfb + .long 0xc4f7b685,0x3c9bb453 + .long 0xe8ca6000,0x3fc47e74 + .long 0xb7020316,0xbcf07c95 + .long 0xf6466000,0x3fc4ef51 + .long 0x21c8cd53,0x3d3bc83d + .long 0xe02bc000,0x3fc56092 + .long 0xfe5d989a,0xbd4ae9eb + .long 0x57cd4000,0x3fc5d238 + .long 0x4b74dcf5,0x3d5a6a61 + .long 0x37334000,0x3fc6313a + .long 0x561bc2b2,0x3d4d7641 + .long 0xdabc0000,0x3fc6a399 + .long 0x399a856a,0xbd563e4d + .long 0xdd3d0000,0x3fc70337 + .long 0x1d685519,0xbd4be57a + .long 0x128f8000,0x3fc77654 + .long 0x520d9718,0xbd4ed8b4 + .long 0x2a0b4000,0x3fc7e9d8 + .long 0x605bf1b1,0xbd5ee97b + .long 0x759f8000,0x3fc84a6b + .long 0x0ab7e182,0xbd5768a0 + .long 0xd5f5c000,0x3fc8ab47 + .long 0xf5f4572e,0xbd4cf028 + .long 0x90964000,0x3fc91fe4 + .long 0x79850e19,0x3d481b4e + .long 0x4011c000,0x3fc98163 + .long 0x30b7dd0f,0xbd458a91 + .long 0x07088000,0x3fc9f6c4 + .long 0x5a19605e,0x3d466413 + .long 0x29348000,0x3fca58e7 + .long 0x504551b1,0x3d3e867d + .long 0xc3168000,0x3fcabb55 + .long 0x9a875994,0x3d43acd2 + .long 0x491a0000,0x3fcb1e10 + .long 0xed340663,0xbd402ffc + .long 0x93e38000,0x3fcb94ee + .long 0x47492dd7,0xbd48357e + .long 0xc0674000,0x3fcbf851 + .long 0xd9fbd5aa,0x3d455ef8 + .long 0x54bf4000,0x3fcc5c02 + .long 0x5184bd39,0xbd4c5a15 + .long 0xc9db4000,0x3fccc000 + .long 0x5d57aff9,0xbd1d6d58 + .long 0x99c84000,0x3fcd244d + .long 0x032241dc,0x3d4673ec + .long 0x3fb30000,0x3fcd88e9 + .long 0x0234bf51,0xbd375f28 + .long 0x37eb0000,0x3fcdedd4 + .long 0x565353b4,0xbd40ff6d + .long 0xffe70000,0x3fce530e + .long 0x276041f4,0x3d401212 + .long 0x1648c000,0x3fceb89a + .long 0x16fee901,0xbd2a3b21 + .long 0xfadfc000,0x3fcf1e75 + .long 0x64bb07ee,0xbd5210c5 + .long 0x2ead8000,0x3fcf84a3 + .long 0xb3098725,0xbd1e5438 + .long 0x33ea0000,0x3fcfeb22 + .long 0xde00938b,0x3d2f3418 + .long 0xc7036000,0x3fd028f9 + .long 0xe9f33100,0xbd2f1eb9 + .long 0xe0d96000,0x3fd05c8b + .long 0xc77ccb58,0x3d2ad0f1 + .long 0x8f8ae000,0x3fd085eb + .long 0x3f45fe7b,0x3d3e5d51 + .long 0xe32d2000,0x3fd0b9c8 + .long 0xedbee0d8,0xbd3bbb62 + .long 0x60b78000,0x3fd0edd0 + .long 0x2d8435f5,0x3d0019b5 + .long 0x4cf02000,0x3fd12202 + .long 0xa2415097,0xbd59c089 + .long 0x927ae000,0x3fd14be2 + .long 0xc85685e2,0x3d49a817 + .long 0x8ef18000,0x3fd18061 + .long 0x1bc9638d,0x3d45be80 + .long 0xbe2fc000,0x3fd1b50b + .long 0x3263201f,0x3d38ecd7 + .long 0xc7cf2000,0x3fd1df4c + .long 0x0455f7e4,0x3d30b43f + .long 0x6d0ea000,0x3fd21445 + .long 0xf5d235d7,0x3d58d43e + .long 0x991ec000,0x3fd23ec5 + .long 0x48a2e522,0xbd36dbe4 + .long 0x9f872000,0x3fd2740d + .long 0xfa32bfeb,0xbd5504cf + .long 0xabce0000,0x3fd29ecd + .long 0x8847bb7a,0xbd37f189 + .long 0x02ade000,0x3fd2d466 + .long 0xbb9aa833,0xbd5311a1 + .long 0xb04ea000,0x3fd2ff66 + .long 0xd5f0c8e9,0x3d43a896 + .long 0x4b356000,0x3fd33550 + .long 0xec6206db,0xbd372206 + .long 0x5ec44000,0x3fd36092 + .long 0xf344bbd1,0x3d4eb929 + .long 0xc3336000,0x3fd38bf1 + .long 0xa0f4a8b7,0x3d5e74f4 + .long 0x77332000,0x3fd3c252 + .long 0x4b606bd6,0x3d5183b5 + .long 0x63c16000,0x3fd3edf4 + .long 0xeb4069e1,0x3d407cc1 + .long 0x23d5e000,0x3fd419b4 + .long 0x6ec90e0a,0x3d418e43 + .long 0xe053a000,0x3fd44591 + .long 0x92923d88,0xbd06e958 + .long 0x75b6e000,0x3fd47c91 + .long 0x8b804f1b,0x3d50ad66 + .long 0x41554000,0x3fd4a8b3 + .long 0xe1791b98,0xbd54f6c0 + .long 0x90890000,0x3fd4d4f3 + .long 0x3a9f1441,0x3d19fd79 + .long 0x8da1e000,0x3fd50152 + .long 0x3694fa6b,0x3d5967d6 + .long 0x6347e000,0x3fd52dd0 + .long 0xeb98a049,0xbd46133a + .long 0x3c7b8000,0x3fd55a6d + .long 0xd6cf85a4,0x3d45138e + .long 0x2b110000,0x3fd5925d + .long 0x4b0b521a,0x3d652c81 + .long 0x6b544000,0x3fd5bf40 + .long 0xeb68981c,0xbd227023 + .long 0x3d5c4000,0x3fd5ec43 + .long 0xf6eb1741,0xbd44a472 + .long 0xcdb04000,0x3fd61965 + .long 0xac078912,0xbd53e115 + .long 0x4935c000,0x3fd646a8 + .long 0x6d25a6ca,0xbd4abc23 + .long 0xdd320000,0x3fd6740a + .long 0xb8b270ac,0xbd60b5c4 + .long 0xb74a8000,0x3fd6a18d + .long 0x67b50a45,0xbd639d6d + .long 0x05868000,0x3fd6cf31 + .long 0xddac7ab9,0xbd4e27a6 + .long 0xe8530000,0x3fd6f180 + .long 0x0a20af33,0xbd4e8c49 + .long 0x71b88000,0x3fd71f5d + .long 0x712fcc92,0x3d54efa4 + .long 0xefd68000,0x3fd74d5a + .long 0x30990150,0xbd52a3e5 + .long 0x922bc000,0x3fd77b79 + .long 0xf6201124,0x3d537dc9 + .long 0x889f4000,0x3fd7a9b9 + .long 0x0dd20a44,0xbd630ed1 + .long 0x037ec000,0x3fd7d81b + .long 0x622fc2c1,0xbd42b381 + .long 0x33828000,0x3fd8069e + .long 0xe1da7992,0xbd4b9e42 + .long 0xd3ef8000,0x3fd82996 + .long 0xae7d64a2,0x3d47956a + .long 0x776e0000,0x3fd85855 + .long 0x0cccc887,0xbd6a02a9 + .long 0x58328000,0x3fd88736 + .long 0x1f7fc497,0xbd2988e2 + .long 0x973ac000,0x3fd8aa75 + .long 0x9e0af65a,0xbd3cc466 + .long 0xdc884000,0x3fd8d992 + .long 0xebb56b23,0xbd5b1b77 + .long 0xea7d8000,0x3fd908d2 + .long 0xf0e513c0,0x3d551185 + .long 0xe79c0000,0x3fd92c59 + .long 0x039fe987,0x3d4cac17 + .long 0x50ee4000,0x3fd95bd7 + .long 0x0649244f,0xbd12d6ab + .long 0x11a3c000,0x3fd98b78 + .long 0x3a5b6609,0x3d672da9 + .long 0xf33d4000,0x3fd9af47 + .long 0x59d98c86,0x3cfae14a + .long 0x0c190000,0x3fd9df27 + .long 0x963f4336,0x3d54a786 + .long 0xed150000,0x3fda0325 + .long 0xb0d5e095,0xbd22dc20 + .long 0x02250000,0x3fda3344 + .long 0x40314305,0xbd361cdd + .long 0x5e80c000,0x3fda5772 + .long 0xd1062b1b,0x3d2c172b + .long 0x165dc000,0x3fda87d0 + .long 0x7845f58e,0x3d51991f + .long 0x6c040000,0x3fdaac2e + .long 0xc856ee3b,0xbd3da90d + .long 0x6fdf8000,0x3fdadccc + .long 0x23b48979,0xbd557ef2 + .long 0x3eb20000,0x3fdb015b + .long 0xa4504de4,0xbd586fcd + .long 0x3a638000,0x3fdb323a + .long 0x7a9aa342,0xbd635be0 + .long 0x04464000,0x3fdb56fa + .long 0xad27be67,0xbd56f6ad + .long 0xa659c000,0x3fdb881a + .long 0x58ba5c9c,0xbd2b65ac + .long 0xef3d8000,0x3fdbad0b + .long 0xe4a81b98,0x3d68b265 + .long 0x97780000,0x3fdbd212 + .long 0xa247841c,0x3d5c2f63 + .long 0x36f08000,0x3fdc0392 + .long 0x435af523,0x3d403109 + .long 0x1e4d4000,0x3fdc28cb + .long 0xdc568214,0xbd4a0635 + .long 0xb8474000,0x3fdc4e19 + .long 0x9ad9f32c,0xbd5c3e5b + .long 0xc7454000,0x3fdc7ff9 + .long 0x47d5b6ca,0x3d54c924 + .long 0x64e9c000,0x3fdca57b + .long 0xd12a2803,0x3d5b0510 + .long 0x0a5d0000,0x3fdccb13 + .long 0x48811a12,0xbd545041 + .long 0xd18f4000,0x3fdcf0c0 + .long 0xc2008d44,0xbd4b2160 + .long 0x75b58000,0x3fdd2320 + .long 0x12cccc3a,0x3d610091 + .long 0x46df0000,0x3fdd4902 + .long 0x0b2c4c2c,0xbd365228 + .long 0x918d4000,0x3fdd6efa + .long 0x7676c78e,0xbd5a329d + .long 0x707ac000,0x3fdd9509 + .long 0x77579caf,0x3d6297b8 + .long 0xfe92c000,0x3fddbb2e + .long 0x0943c435,0x3d3550ac + .long 0x3445c000,0x3fddee2f + .long 0x3a0f9d04,0x3d625775 + .long 0x1a274000,0x3fde148a + .long 0x20732293,0xbd59326b + .long 0x0a4a0000,0x3fde3afc + .long 0x573921f0,0xbd080095 + .long 0x206d4000,0x3fde6185 + .long 0xc9807dcf,0x3d516d95 + .long 0x78824000,0x3fde8825 + .long 0xaa15d3d9,0xbd25726d + .long 0x2eac8000,0x3fdeaedd + .long 0xad7934b2,0x3d590c33 + .long 0x5f438000,0x3fded5ac + .long 0x1bc1c15c,0xbd541d1a + .long 0x26d14000,0x3fdefc93 + .long 0x206858e7,0x3d655c54 + .long 0xa2154000,0x3fdf2391 + .long 0x202b7ba5,0x3d6affe2 + .long 0xee030000,0x3fdf4aa7 + .long 0x56f014a9,0x3d592cde + .long 0x27c30000,0x3fdf71d6 + .long 0xe30f87ad,0x3d47600a + .long 0x6cb38000,0x3fdf991c + .long 0xcca0cdf3,0x3d69bcbe + .long 0xda698000,0x3fdfc07a + .long 0x2683bdae,0x3d6487fd + .long 0x8eb04000,0x3fdfe7f1 + .long 0xceb37e7a,0xbd260f51 + .long 0x53c50000,0x3fe007c0 + .long 0xc9c065f1,0x3cf73add + .long 0x2198a000,0x3fe01b94 + .long 0x5498efb5,0x3d4683ab + .long 0x400c8000,0x3fe02f74 + .long 0xe23775e2,0xbd6b154b + .long 0xbe760000,0x3fe04360 + .long 0x030d58c4,0x3d3d6774 + .long 0xac480000,0x3fe05759 + .long 0x83c1e850,0xbd2cc5f3 + .long 0x1911e000,0x3fe06b5f + .long 0x2598b50b,0xbd60ae17 + .long 0x0533c000,0x3fe078bf + .long 0x907b7d7f,0x3d45a048 + .long 0x687e8000,0x3fe08cd9 + .long 0xc00a19af,0xbd43c67f + .long 0x74cfa000,0x3fe0a100 + .long 0x22f73f90,0xbd5fcd6d + .long 0x3a234000,0x3fe0b534 + .long 0x4c68a7e5,0x3d41da30 + .long 0xc8942000,0x3fe0c974 + .long 0xa7cdcbb8,0x3d61cdc0 + .long 0x305ba000,0x3fe0ddc2 + .long 0x566f7df8,0xbd4de684 + .long 0x4bafc000,0x3fe0eb52 + .long 0x7feb3411,0x3d5230c5 + .long 0x4213a000,0x3fe0ffb5 + .long 0xbeeae6be,0x3d41d77b + .long 0x3da98000,0x3fe11425 + .long 0x3d4743ea,0xbd33050e + .long 0x4f1da000,0x3fe128a2 + .long 0x5906450d,0xbd440318 + .long 0x52bf0000,0x3fe13652 + .long 0xa621d4be,0x3d50c985 + .long 0x58b4a000,0x3fe14ae5 + .long 0x9895512f,0x3d525a20 + .long 0xa19c6000,0x3fe15f85 + .long 0xe4dca81e,0x3d665b5b + .long 0x38c12000,0x3fe16d4d + .long 0xaf71a89e,0xbd481628 + .long 0xc20de000,0x3fe18203 + .long 0x4bb7b8b9,0xbd5d995f + .long 0xbc4b2000,0x3fe196c7 + .long 0x14cec2c3,0xbd18a766 + .long 0x38b7a000,0x3fe1a4a7 + .long 0x26042793,0x3d39e2b1 + .long 0xc0c96000,0x3fe1b981 + .long 0x549461ed,0x3d44f378 + .long 0xe8bb0000,0x3fe1ce69 + .long 0xcc3339e5,0x3d606af5 + .long 0x9de06000,0x3fe1dc61 + .long 0xa1767071,0x3d528836 + .long 0xa2ad0000,0x3fe1f160 + .long 0x6c9de298,0x3d5b4741 + .long 0x77406000,0x3fe2066d + .long 0xd051f38d,0x3d637e65 + .long 0xba47c000,0x3fe2147d + .long 0x0cf5c8e9,0xbd6c6c55 + .long 0xbc5ec000,0x3fe229a1 + .long 0xf20d6e42,0xbd44f266 + .long 0x841a6000,0x3fe237c1 + .long 0xa47dba85,0xbd5fa312 + .long 0xe6f82000,0x3fe24cfc + .long 0xb65cb7bb,0xbd626596 + .long 0x55cd6000,0x3fe25b2c + .long 0x2ff856c0,0xbd513b72 + .long 0x4d5f8000,0x3fe2707f + .long 0xc37d4cdf,0xbd3df8b3 + .long 0x842ca000,0x3fe285e0 + .long 0x866d5f22,0x3d3c1c4d + .long 0x4708c000,0x3fe29429 + .long 0x7aca88eb,0xbd5119e8 + .long 0x670b0000,0x3fe2a9a2 + .long 0x1c2e5d10,0xbd1e7864 + .long 0x2c8d2000,0x3fe2b7fb + .long 0x00c270dd,0xbd39fb3c + .long 0x63960000,0x3fe2c65a + .long 0x03be9586,0xbd5415ea + .long 0x57b0e000,0x3fe2dbf5 + .long 0x07b9dc11,0xbd17a6e5 + .long 0xc3f96000,0x3fe2ea64 + .long 0x8b7d46fa,0x3d6654b2 + .long 0x23686000,0x3fe30018 + .long 0x5363d25e,0xbd628cd2 + .long 0xe9a8c000,0x3fe30e97 + .long 0x06943683,0xbd546671 + .long 0xebdd4000,0x3fe32463 + .long 0xc46cb528,0xbd562c21 + .long 0x314ae000,0x3fe332f4 + .long 0x1ea74541,0xbd50d4b6 + .long 0x0e746000,0x3fe348d9 + .long 0x44f828b5,0x3d433f3c + .long 0xf8c44000,0x3fe35779 + .long 0x22a46dd6,0xbd34934a + .long 0x961a8000,0x3fe36621 + .long 0x0cdd9d24,0xbd6566ce + .long 0x9f3c2000,0x3fe37c29 + .long 0x8e5820fe,0x3d666a2b + .long 0x17198000,0x3fe38ae2 + .long 0x576aad35,0xbd52316f + .long 0x57a60000,0x3fe399a1 + .long 0x62286d89,0x3d3f399c + .long 0xfe77c000,0x3fe3afcc + .long 0xedc1a56f,0xbd48bbbb + .long 0x50352000,0x3fe3be9d + .long 0x22f47589,0x3d63b540 + .long 0x80b4a000,0x3fe3cd74 + .long 0x9ebf0b71,0x3d51452e + .long 0x39190000,0x3fe3e3c4 + .long 0x4c617cda,0xbd512753 + .long 0xb27ec000,0x3fe3f2ac + .long 0x8d68a543,0x3d66c6ab + .long 0x2125c000,0x3fe4019c + .long 0xd9e1e717,0x3d552630 + .long 0x6138a000,0x3fe41810 + .long 0xa1618e8d,0xbd51bb4f + .long 0x518de000,0x3fe42711 + .long 0x38d47013,0x3d65455f + .long 0x4e12c000,0x3fe43619 + .long 0xaca69593,0xbd52819e + .long 0x5d68e000,0x3fe44528 + .long 0xf367503a,0x3d54d27f + .long 0x464ca000,0x3fe45bcc + .long 0xa4ffdcb2,0xbd66c5eb + .long 0x21f12000,0x3fe46aed + .long 0xa0df038b,0xbd50072e + .long 0x27e8a000,0x3fe47a15 + .long 0x83594fab,0x3d369a4a + .long 0x5f000000,0x3fe48944 + .long 0x95dc2343,0xbd39a0cf + .long 0xbcb6a000,0x3fe4a018 + .long 0xdb5ebf58,0xbd4f2ae4 + .long 0x0c9d6000,0x3fe4af5a + .long 0xedc4bac0,0x3d475de0 + .long 0xa5bdc000,0x3fe4bea2 + .long 0xefe50211,0xbd278f64 + .long 0x8f10c000,0x3fe4cdf2 + .long 0x7690ed86,0xbd63b982 + .long 0xcf994000,0x3fe4dd49 + .long 0x24d59d34,0x3d061972 + .long 0x6e64a000,0x3fe4eca8 + .long 0xb1079278,0x3d4a0e67 + .long 0x3cd90000,0x3fe503c4 + .long 0x0f1a734d,0xbd6497fc + .long 0x6667e000,0x3fe51335 + .long 0x4c9987aa,0x3d6c5739 + .long 0x0738a000,0x3fe522ae + .long 0x8164c759,0x3d3ebe70 + .long 0x26868000,0x3fe5322e + .long 0xba2da8ad,0xbd4ea333 + .long 0xcb978000,0x3fe541b5 + .long 0x62e3a6b9,0x3d680916 + .long 0xfdbcc000,0x3fe55144 + .long 0x2b35ba3e,0xbd34ec53 + .long 0xc4518000,0x3fe560db + .long 0x776b86a6,0xbd761cb6 + .long 0x26bb8000,0x3fe5707a + .long 0x5ff9981f,0x3d58ccc0 + .long 0x0ed5c000,0x3fe587f6 + .long 0xe6cce4c9,0xbd4c00c2 + .long 0x977cc000,0x3fe597a7 + .long 0xf6a33533,0xbd786770 + .long 0xd6348000,0x3fe5a760 + .long 0x365e53d9,0x3d7dc57c + .long 0xd2960000,0x3fe5b721 + .long 0x4f6ab8cd,0xbd5de23a + .long 0x94434000,0x3fe5c6ea + .long 0xa68978ec,0xbd70837e + .long 0x22ea8000,0x3fe5d6bb + .long 0xea2eecbe,0x3d4bd7d0 + .long 0x86460000,0x3fe5e693 + .long 0x23677de5,0xbd763831 + .long 0xc61a4000,0x3fe5f673 + .long 0x7a110a0e,0xbd612e5c + .long 0xea384000,0x3fe6065b + .long 0xc49e2cb9,0x3d692622 + .long 0xfa7cc000,0x3fe6164b + .long 0x27c383a0,0x3d0ad6c4 + .long 0xfecfc000,0x3fe62643 + .long 0x3ae25ed1,0xbd745e87 + .type __libm_logl_table_256,@object + .size __libm_logl_table_256,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/lrint_gen.S b/external/sgx_libm/intel64/lrint_gen.S new file mode 100644 index 0000000000..b3d895587c --- /dev/null +++ b/external/sgx_libm/intel64/lrint_gen.S @@ -0,0 +1,88 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lrint_gen.c" + .text +..TXTST0: +# -- Begin lrint + .text + .align 16,0x90 + .globl lrint +lrint: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_lrint.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_def_cfa 6, 16 + .cfi_offset 6, -16 + subq $16, %rsp + movq $0, -16(%rbp) + movl $0, -8(%rbp) +..B1.2: + pushq %rax + xorpd %xmm1, %xmm1 + stmxcsr -8(%rbp) + andl $-2, -8(%rbp) + ldmxcsr -8(%rbp) + cvtsd2si %xmm0, %rax + addsd %xmm0, %xmm1 + movq %rax, -16(%rbp) + stmxcsr -8(%rbp) + popq %rax +..B1.3: + movq -16(%rbp), %rax + movq %rbp, %rsp + popq %rbp + .cfi_restore 6 + ret + .align 16,0x90 + .cfi_endproc + .type lrint,@function + .size lrint,.-lrint + .data +# -- End lrint + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lrintf_gen.S b/external/sgx_libm/intel64/lrintf_gen.S new file mode 100644 index 0000000000..984b6174b7 --- /dev/null +++ b/external/sgx_libm/intel64/lrintf_gen.S @@ -0,0 +1,88 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lrintf_gen.c" + .text +..TXTST0: +# -- Begin lrintf + .text + .align 16,0x90 + .globl lrintf +lrintf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_lrintf.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_def_cfa 6, 16 + .cfi_offset 6, -16 + subq $16, %rsp + movq $0, -16(%rbp) + movl $0, -8(%rbp) +..B1.2: + pushq %rax + xorpd %xmm1, %xmm1 + stmxcsr -8(%rbp) + andl $-2, -8(%rbp) + ldmxcsr -8(%rbp) + cvtss2si %xmm0, %rax + addss %xmm0, %xmm1 + movq %rax, -16(%rbp) + stmxcsr -8(%rbp) + popq %rax +..B1.3: + movq -16(%rbp), %rax + movq %rbp, %rsp + popq %rbp + .cfi_restore 6 + ret + .align 16,0x90 + .cfi_endproc + .type lrintf,@function + .size lrintf,.-lrintf + .data +# -- End lrintf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lrintl.S b/external/sgx_libm/intel64/lrintl.S new file mode 100644 index 0000000000..6473321dfd --- /dev/null +++ b/external/sgx_libm/intel64/lrintl.S @@ -0,0 +1,314 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lrintl.c" + .text +..TXTST0: +# -- Begin lrintl + .text + .align 16,0x90 + .globl lrintl +lrintl: +# parameter 1: 80 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_lrintl.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + subq $56, %rsp + .cfi_def_cfa_offset 80 + fldt 80(%rsp) + movzbl 89(%rsp), %edi + movzwl 88(%rsp), %r8d + andl $128, %edi + andl $32767, %r8d + shrl $7, %edi + fstpt 32(%rsp) + cmpl $16445, %r8d + jge ..B1.8 +..B1.2: + testl %r8d, %r8d + jne ..B1.6 +..B1.3: + cmpl $0, 84(%rsp) + jne ..B1.5 +..B1.4: + cmpl $0, 80(%rsp) + je ..B1.6 +..B1.5: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 8(%rsp) +..B1.6: + fldt 32(%rsp) + fistpq 16(%rsp) +..B1.7: + movq 16(%rsp), %rax + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.8: + cmpl $16447, %r8d + jge ..B1.21 +..B1.9: + movl %edi, %esi + movq $0x7fffffffffffffff, %rax + addq %rax, %rsi + cmpl $16446, %r8d + jge ..B1.16 +..B1.10: + fnstcw 4(%rsp) +..B1.11: + movl 80(%rsp), %ebx + movl %ebx, %ebp + movzwl 4(%rsp), %r11d + andl $1, %ebp + movl 84(%rsp), %ecx + andl $3072, %r11d + jne ..B1.13 +..B1.12: + movl %ebx, %eax + andl $3, %ebx + movl %ecx, %edx + movl $1, %r9d + cmpl $3, %ebx + movl $0, %ebx + cmovne %ebx, %r9d + shrl $1, %edx + shll $31, %ecx + shrl $1, %eax + orl %eax, %ecx + shlq $32, %rdx + orq %rcx, %rdx + addq %r9, %rdx + jmp ..B1.17 +..B1.13: + movl $1, %eax + xorl %edx, %edx + cmpl $3072, %r11d + cmove %eax, %edx + xorl %r10d, %r10d + cmpl $2048, %r11d + movl %eax, %r9d + cmove %eax, %r10d + testl %edi, %edi + cmove %edi, %r9d + andl %r9d, %r10d + xorl %r9d, %r9d + cmpl $1024, %r11d + cmove %eax, %r9d + xorl %r11d, %r11d + testl %edi, %edi + cmovne %r11d, %eax + orl %r10d, %edx + andl %eax, %r9d + orl %r9d, %edx + je ..B1.15 +..B1.14: + movl %ecx, %edx + shrl $1, %edx + shll $31, %ecx + shrl $1, %ebx + orl %ebx, %ecx + shlq $32, %rdx + orq %rcx, %rdx + jmp ..B1.17 +..B1.15: + movl %ecx, %edx + movl %ebx, %eax + shrl $1, %edx + shll $31, %ecx + shrl $1, %eax + orl %eax, %ecx + shlq $32, %rdx + orq %rcx, %rdx + andq $1, %rbx + addq %rbx, %rdx + jmp ..B1.17 +..B1.16: + movl 84(%rsp), %edx + xorl %ebp, %ebp + shlq $32, %rdx + movl 80(%rsp), %eax + orq %rax, %rdx +..B1.17: + movq %rdx, %rax + xorl %ecx, %ecx + negq %rax + testl %edi, %edi + cmove %rdx, %rax + cmpq %rdx, %rax + setae %cl + cmpq %rsi, %rdx + movl $0, %edx + setbe %dl + testl %edx, %ecx + je ..B1.21 +..B1.18: + testl %ebp, %ebp + je ..B1.20 +..B1.19: + lea _ones(%rip), %rdx + lea _small_value_64(%rip), %rcx + movq %rax, 16(%rsp) + movsd (%rdx), %xmm0 + addsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) +..B1.20: + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.21: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movq $0x8000000000000000, %rcx + cmpl $32767, %r8d + movq %rcx, 16(%rsp) + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 8(%rsp) + jne ..B1.24 +..B1.22: + cmpl $-2147483648, 84(%rsp) + jne ..B1.29 +..B1.23: + cmpl $0, 80(%rsp) + jne ..B1.29 +..B1.24: + fnstcw 2(%rsp) +..B1.25: + movzwl 2(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.26: + orl $-64768, %edx + movw %dx, (%rsp) +..B1.27: + fldcw (%rsp) +..B1.28: + fldcw 2(%rsp) +..B1.29: + movq 16(%rsp), %rax + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type lrintl,@function + .size lrintl,.-lrintl + .data +# -- End lrintl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lround_gen.S b/external/sgx_libm/intel64/lround_gen.S new file mode 100644 index 0000000000..95136def07 --- /dev/null +++ b/external/sgx_libm/intel64/lround_gen.S @@ -0,0 +1,138 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lround_gen.c" + .text +..TXTST0: +# -- Begin lround + .text + .align 16,0x90 + .globl lround +lround: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_lround.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) + movq $0, 8(%rsp) + movl $0, 16(%rsp) +..B1.2: + stmxcsr 16(%rsp) + movsd (%rsp), %xmm1 + xorpd %xmm2, %xmm2 + andl $-2, 16(%rsp) + ldmxcsr 16(%rsp) + cvtsd2si %xmm1, %rax + addsd %xmm1, %xmm2 + movq %rax, 8(%rsp) + stmxcsr 16(%rsp) +..B1.3: + testb $1, 16(%rsp) + jne ..B1.6 +..B1.4: + pxor %xmm2, %xmm2 + movq 8(%rsp), %rax + cvtsi2sdq %rax, %xmm2 + movsd (%rsp), %xmm1 + movaps %xmm1, %xmm0 + subsd %xmm2, %xmm0 + andps .L_2il0floatpacket.1(%rip), %xmm0 + ucomisd .L_2il0floatpacket.0(%rip), %xmm0 + jp ..B1.5 + je ..B1.7 +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.6: + movq 8(%rsp), %rax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.7: + pxor %xmm0, %xmm0 + comisd %xmm0, %xmm1 + jbe ..B1.10 +..B1.8: + comisd %xmm2, %xmm1 + jbe ..B1.5 +..B1.9: + incq %rax + movq %rax, 8(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.10: + comisd %xmm1, %xmm2 + jbe ..B1.5 +..B1.11: + decq %rax + movq %rax, 8(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type lround,@function + .size lround,.-lround + .data +# -- End lround + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lroundf_gen.S b/external/sgx_libm/intel64/lroundf_gen.S new file mode 100644 index 0000000000..43fd9b79c7 --- /dev/null +++ b/external/sgx_libm/intel64/lroundf_gen.S @@ -0,0 +1,138 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lroundf_gen.c" + .text +..TXTST0: +# -- Begin lroundf + .text + .align 16,0x90 + .globl lroundf +lroundf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_lroundf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movss %xmm0, 16(%rsp) + movq $0, (%rsp) + movl $0, 8(%rsp) +..B1.2: + stmxcsr 8(%rsp) + movsd 16(%rsp), %xmm1 + xorpd %xmm2, %xmm2 + andl $-2, 8(%rsp) + ldmxcsr 8(%rsp) + cvtss2si %xmm1, %rax + addss %xmm1, %xmm2 + movq %rax, (%rsp) + stmxcsr 8(%rsp) +..B1.3: + testb $1, 8(%rsp) + jne ..B1.6 +..B1.4: + pxor %xmm2, %xmm2 + movq (%rsp), %rax + cvtsi2ssq %rax, %xmm2 + movss 16(%rsp), %xmm1 + movaps %xmm1, %xmm0 + subss %xmm2, %xmm0 + andps .L_2il0floatpacket.1(%rip), %xmm0 + ucomiss .L_2il0floatpacket.0(%rip), %xmm0 + jp ..B1.5 + je ..B1.7 +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.6: + movq (%rsp), %rax + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.7: + pxor %xmm0, %xmm0 + comiss %xmm0, %xmm1 + jbe ..B1.10 +..B1.8: + comiss %xmm2, %xmm1 + jbe ..B1.5 +..B1.9: + incq %rax + movq %rax, (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.10: + comiss %xmm1, %xmm2 + jbe ..B1.5 +..B1.11: + decq %rax + movq %rax, (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type lroundf,@function + .size lroundf,.-lroundf + .data +# -- End lroundf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x7fffffff,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 4 +.L_2il0floatpacket.0: + .long 0x3f000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/lroundl.S b/external/sgx_libm/intel64/lroundl.S new file mode 100644 index 0000000000..d60f8badfd --- /dev/null +++ b/external/sgx_libm/intel64/lroundl.S @@ -0,0 +1,243 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "lroundl.c" + .text +..TXTST0: +# -- Begin lroundl + .text + .align 16,0x90 + .globl lroundl +lroundl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_lroundl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %dl, %dl +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movb 57(%rsp), %r8b + lea _range(%rip), %rdi + andb $-128, %r8b + shrb $7, %r8b + movzbl %r8b, %eax + movq %rax, %rsi + shlq $4, %rsi + movzwl 56(%rsp), %r9d + andl $32767, %r9d + movzwl 8(%rsi,%rdi), %ecx + andl $32767, %ecx + cmpl %ecx, %r9d + jl ..B1.8 +..B1.4: + jne ..B1.16 +..B1.5: + movl 52(%rsp), %ecx + cmpl 4(%rsi,%rdi), %ecx + jb ..B1.8 +..B1.6: + jne ..B1.16 +..B1.7: + movl 48(%rsp), %ecx + cmpl (%rsi,%rdi), %ecx + ja ..B1.16 +..B1.8: + cmpl $16383, %r9d + jl ..B1.10 +..B1.9: + movl %r9d, %edi + negl %edi + movl 52(%rsp), %r10d + movl %r10d, %eax + movl 48(%rsp), %edx + movl %edx, %esi + shlq $32, %r10 + lea 29(%rdi), %ecx + shrl %cl, %eax + addl $62, %edi + shrl %cl, %esi + cmpl $16414, %r9d + movl %edi, %ecx + cmovl %eax, %esi + orq %rdx, %r10 + andl $1, %esi + shrq %cl, %r10 + addq %rsi, %r10 + movq %r10, %r9 + negq %r9 + testb %r8b, %r8b + cmovne %r9, %r10 + movq %r10, %rax + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.10: + cmpl $16382, %r9d + je ..B1.23 +..B1.11: + testl %r9d, %r9d + jne ..B1.15 +..B1.12: + cmpl $0, 52(%rsp) + jne ..B1.14 +..B1.13: + cmpl $0, 48(%rsp) + je ..B1.15 +..B1.14: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, (%rsp) +..B1.15: + xorl %eax, %eax + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.16: + lea lres_maxmin(%rip), %rcx + movq (%rcx,%rax,8), %rax + movzwl 34(%rsp), %ecx + movl %ecx, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.20 +..B1.17: + orl $-64768, %ecx + movw %cx, 32(%rsp) +..B1.18: + fldcw 32(%rsp) +..B1.19: + movb $1, %dl +..B1.20: + lea _infs(%rip), %rcx + lea _zeros(%rip), %rsi + testb %dl, %dl + movsd (%rcx), %xmm0 + mulsd (%rsi), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + je ..B1.22 +..B1.21: + fldcw 34(%rsp) +..B1.22: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.23: + lea iones(%rip), %rdx + movslq (%rdx,%rax,4), %rax + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type lroundl,@function + .size lroundl,.-lroundl + .data +# -- End lroundl + .section .rodata, "a" + .align 8 + .align 8 +lres_maxmin: + .long 0xffffffff,0x7fffffff + .long 0x00000000,0x80000000 + .type lres_maxmin,@object + .size lres_maxmin,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 2 +_range: + .word 65534 + .word 65535 + .word 65535 + .word 65535 + .word 16445 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49214 + .word 0 + .word 0 + .word 0 + .type _range,@object + .size _range,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/modf_gen.S b/external/sgx_libm/intel64/modf_gen.S new file mode 100644 index 0000000000..e40486993c --- /dev/null +++ b/external/sgx_libm/intel64/modf_gen.S @@ -0,0 +1,153 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "modf_gen.c" + .text +..TXTST0: +# -- Begin modf + .text + .align 16,0x90 + .globl modf +modf: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_modf.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + movl %eax, %r8d + andl $2147483647, %r8d + lea -1072693248(%r8), %edx + cmpl $54525952, %edx + jae ..B1.9 +..B1.2: + movl %r8d, %ecx + shrl $20, %ecx + movl -8(%rsp), %esi + cmpl $1094713344, %r8d + jae ..B1.4 +..B1.3: + negl %ecx + movl $-1, %edx + addl $19, %ecx + shll %cl, %edx + movl %edx, %ecx + andl %eax, %edx + notl %ecx + andl %eax, %ecx + movl %edx, 4(%rdi) + orl %esi, %ecx + movl $0, (%rdi) + jmp ..B1.5 +..B1.4: + negl %ecx + movl $-1, %edx + addl $19, %ecx + shll %cl, %edx + movl %edx, %ecx + andl %esi, %edx + notl %ecx + movl %edx, (%rdi) + andl %esi, %ecx + movl %eax, 4(%rdi) +..B1.5: + testl %ecx, %ecx + je ..B1.7 +..B1.6: + movsd -8(%rsp), %xmm0 + subsd (%rdi), %xmm0 + ret +..B1.7: + lea _zeros(%rip), %rdx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm0 +..B1.8: + ret +..B1.9: + shrl $31, %eax + cmpl $2146435072, %r8d + jb ..B1.12 +..B1.10: + addl $-2146435072, %r8d + orl -8(%rsp), %r8d + je ..B1.13 +..B1.11: + movsd -8(%rsp), %xmm0 + addsd %xmm0, %xmm0 + movsd %xmm0, (%rdi) + ret +..B1.12: + cmpl $1072693248, %r8d + jbe ..B1.14 +..B1.13: + movl %eax, %eax + lea _zeros(%rip), %rcx + movq -8(%rsp), %rdx + movq %rdx, (%rdi) + movsd (%rcx,%rax,8), %xmm0 + ret +..B1.14: + lea _zeros(%rip), %rdx + movsd -8(%rsp), %xmm0 + movq (%rdx,%rax,8), %rcx + movq %rcx, (%rdi) + ret + .align 16,0x90 + .cfi_endproc + .type modf,@function + .size modf,.-modf + .data +# -- End modf + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/modff.S b/external/sgx_libm/intel64/modff.S new file mode 100644 index 0000000000..4232ea9187 --- /dev/null +++ b/external/sgx_libm/intel64/modff.S @@ -0,0 +1,126 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "modff.c" + .text +..TXTST0: +# -- Begin modff + .text + .align 16,0x90 + .globl modff +modff: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_modff.1: +..L2: + + movd %xmm0, %esi + movss %xmm0, -8(%rsp) + movl %esi, %ecx + andl $2147483647, %ecx + lea -1065353216(%rcx), %eax + cmpl $192937984, %eax + jae ..B1.6 +..B1.2: + shrl $23, %ecx + movl $-1, %edx + negl %ecx + addl $22, %ecx + shll %cl, %edx + movl %edx, %eax + andl %esi, %edx + notl %eax + movl %edx, (%rdi) + testl %eax, %esi + je ..B1.4 +..B1.3: + subss (%rdi), %xmm0 + ret +..B1.4: + lea _zeros(%rip), %rax + shrl $31, %esi + movss (%rax,%rsi,4), %xmm0 +..B1.5: + ret +..B1.6: + shrl $31, %esi + cmpl $2139095040, %ecx + ja ..B1.11 +..B1.7: + cmpl $1065353216, %ecx + jbe ..B1.9 +..B1.8: + movl %esi, %esi + lea _zeros(%rip), %rdx + movl -8(%rsp), %eax + movl %eax, (%rdi) + movss (%rdx,%rsi,4), %xmm0 + ret +..B1.9: + lea _zeros(%rip), %rax + movss -8(%rsp), %xmm0 + movl (%rax,%rsi,4), %edx + movl %edx, (%rdi) +..B1.10: + ret +..B1.11: + movss -8(%rsp), %xmm0 + addss %xmm0, %xmm0 + movss %xmm0, (%rdi) + ret + .align 16,0x90 + .cfi_endproc + .type modff,@function + .size modff,.-modff + .data +# -- End modff + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/modfl.S b/external/sgx_libm/intel64/modfl.S new file mode 100644 index 0000000000..1788f0b5df --- /dev/null +++ b/external/sgx_libm/intel64/modfl.S @@ -0,0 +1,262 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "modfl.c" + .text +..TXTST0: +# -- Begin modfl + .text + .align 16,0x90 + .globl modfl +modfl: +# parameter 1: 48 + %rsp +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_modfl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 56(%rsp), %ecx + andl $32767, %ecx + cmpl $16446, %ecx + jge ..B1.21 +..B1.4: + cmpl $16383, %ecx + jl ..B1.16 +..B1.5: + fldt 48(%rsp) + cmpl $16415, %ecx + fstpt (%rsp) + jge ..B1.7 +..B1.6: + negl %ecx + movl $-1, %eax + addl $30, %ecx + shll %cl, %eax + movl %eax, %ecx + notl %ecx + movl 52(%rsp), %edx + andl %edx, %ecx + andl %eax, %edx + orl 48(%rsp), %ecx + movl %edx, 52(%rsp) + xorl %edx, %edx + jmp ..B1.8 +..B1.7: + negl %ecx + movl $-1, %edx + addl $30, %ecx + shll %cl, %edx + movl %edx, %ecx + notl %ecx + movl 48(%rsp), %eax + andl %eax, %ecx + andl %eax, %edx +..B1.8: + movl %edx, 48(%rsp) + testl %ecx, %ecx + je ..B1.14 +..B1.9: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.31 +..B1.10: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.11: + fldcw 24(%rsp) +..B1.12: + fldt 48(%rsp) + fstpt (%rdi) + fldt (%rdi) + fldt (%rsp) + fsubp %st, %st(1) + fstpt (%rsp) +..B1.13: + fldcw 26(%rsp) + jmp ..B1.15 +..B1.14: + fldt 48(%rsp) + lea _zeros(%rip), %rdx + movb 57(%rsp), %al + andb $-128, %al + fstpt (%rdi) + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fstpt (%rsp) +..B1.15: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.16: + testl %ecx, %ecx + jne ..B1.20 +..B1.17: + cmpl $0, 52(%rsp) + jne ..B1.19 +..B1.18: + cmpl $0, 48(%rsp) + je ..B1.20 +..B1.19: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 16(%rsp) +..B1.20: + movb 57(%rsp), %al + lea _zeros(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + fstpt (%rdi) + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.21: + cmpl $32767, %ecx + jne ..B1.24 +..B1.22: + cmpl $-2147483648, 52(%rsp) + jne ..B1.25 +..B1.23: + cmpl $0, 48(%rsp) + jne ..B1.25 +..B1.24: + fldt 48(%rsp) + lea _zeros(%rip), %rdx + movb 57(%rsp), %al + andb $-128, %al + shrb $7, %al + fstpt (%rdi) + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.25: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.32 +..B1.26: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.27: + fldcw 24(%rsp) +..B1.28: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) + fldt (%rsp) + fstpt (%rdi) +..B1.29: + fldcw 26(%rsp) +..B1.30: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.31: + fldt 48(%rsp) + fstpt (%rdi) + fldt (%rdi) + fldt (%rsp) + fsubp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.32: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) + fldt (%rsp) + fstpt (%rdi) + jmp ..B1.30 + .align 16,0x90 + .cfi_endproc + .type modfl,@function + .size modfl,.-modfl + .data +# -- End modfl + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nan.S b/external/sgx_libm/intel64/nan.S new file mode 100644 index 0000000000..d5e836144b --- /dev/null +++ b/external/sgx_libm/intel64/nan.S @@ -0,0 +1,144 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nan.c" + .text +..TXTST0: +# -- Begin nanf + .text + .align 16,0x90 + .globl nanf +nanf: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value_nanf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 +..___tag_value_nanf.4: + call __libm_conv_strtoull@PLT +..___tag_value_nanf.5: +..B1.2: + andl $4194303, %eax + orl $2143289344, %eax + movl %eax, (%rsp) + movss (%rsp), %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type nanf,@function + .size nanf,.-nanf + .data +# -- End nanf + .text +# -- Begin nan + .text + .align 16,0x90 + .globl nan +nan: +# parameter 1: %rdi +..B2.1: + .cfi_startproc +..___tag_value_nan.8: +..L9: + + pushq %rsi + .cfi_def_cfa_offset 16 +..___tag_value_nan.11: + call __libm_conv_strtoull@PLT +..___tag_value_nan.12: +..B2.2: + movq $0x7ffffffffffff, %rdx + andq %rax, %rdx + movq $0x7ff8000000000000, %rax + orq %rdx, %rax + movq %rax, (%rsp) + movsd (%rsp), %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type nan,@function + .size nan,.-nan + .data +# -- End nan + .text +# -- Begin nanl + .text + .align 16,0x90 + .globl nanl +nanl: +# parameter 1: %rdi +..B3.1: + .cfi_startproc +..___tag_value_nanl.15: +..L16: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..___tag_value_nanl.18: + call __libm_conv_strtoull@PLT +..___tag_value_nanl.19: +..B3.5: + movq %rax, %rdx +..B3.2: + movq $0xc000000000000000, %rax + orq %rax, %rdx + movq %rdx, (%rsp) + movl $32767, %edx + movw %dx, 8(%rsp) + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type nanl,@function + .size nanl,.-nanl + .data +# -- End nanl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nearbyint_gen.S b/external/sgx_libm/intel64/nearbyint_gen.S new file mode 100644 index 0000000000..b7b32a6eda --- /dev/null +++ b/external/sgx_libm/intel64/nearbyint_gen.S @@ -0,0 +1,435 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nearbyint_gen.c" + .text +..TXTST0: +# -- Begin nearbyint + .text + .align 16,0x90 + .globl nearbyint +nearbyint: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_nearbyint.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + stmxcsr 8(%rsp) +..B1.3: + movzwl 6(%rsp), %esi + andl $32752, %esi + shrl $4, %esi + cmpl $1075, %esi + jge ..B1.62 +..B1.4: + movl 8(%rsp), %eax + andl $24576, %eax + cmpl $8192, %eax + je ..B1.49 +..B1.5: + cmpl $16384, %eax + jne ..B1.19 +..B1.6: + cmpl $1023, %esi + jl ..B1.14 +..B1.7: + cmpl $1043, %esi + jle ..B1.9 +..B1.8: + negl %esi + movl $-1, %edi + addl $19, %esi + movl %esi, %ecx + shll %cl, %edi + movl (%rsp), %eax + andl %eax, %edi + movl %edi, (%rsp) + xorl %eax, %edi + jmp ..B1.10 +..B1.9: + negl %esi + movl $1048575, %eax + addl $19, %esi + movl 4(%rsp), %edx + movl %edx, %edi + movl %esi, %ecx + andl $1048575, %edi + shll %cl, %eax + andl $-1048576, %edx + andl %edi, %eax + orl %eax, %edx + movl %edx, 4(%rsp) + andl $1048575, %edx + xorl %edx, %edi + orl (%rsp), %edi + movl $0, (%rsp) +..B1.10: + testb $-128, 7(%rsp) + jne ..B1.13 +..B1.11: + testl %edi, %edi + je ..B1.13 +..B1.12: + lea _ones(%rip), %rax + movsd (%rsp), %xmm0 + addsd (%rax), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.13: + movsd (%rsp), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.14: + testl %esi, %esi + jne ..B1.18 +..B1.15: + testl $1048575, 4(%rsp) + jne ..B1.18 +..B1.16: + cmpl $0, (%rsp) + je ..B1.13 +..B1.18: + movb 7(%rsp), %al + lea _pone_nzero(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movsd (%rdx,%rcx,8), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.19: + cmpl $24576, %eax + jne ..B1.26 +..B1.20: + cmpl $1023, %esi + jl ..B1.25 +..B1.21: + cmpl $1043, %esi + jle ..B1.23 +..B1.22: + negl %esi + movl $-1, %eax + addl $19, %esi + movl %esi, %ecx + shll %cl, %eax + andl (%rsp), %eax + jmp ..B1.24 +..B1.23: + negl %esi + movl $1048575, %eax + addl $19, %esi + movl %esi, %ecx + shll %cl, %eax + movl 4(%rsp), %edx + movl %edx, %edi + andl %eax, %edx + andl $-1048576, %edi + andl $1048575, %edx + xorl %eax, %eax + orl %edx, %edi + movl %edi, 4(%rsp) +..B1.24: + movl %eax, (%rsp) + movsd (%rsp), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.25: + movb 7(%rsp), %al + lea _zeros(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movsd (%rdx,%rcx,8), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.26: + cmpl $1023, %esi + jl ..B1.42 +..B1.27: + movl (%rsp), %eax + cmpl $1043, %esi + jl ..B1.29 +..B1.28: + movl %eax, %edx + lea 13(%rsi), %ecx + shll %cl, %edx + xorl %r9d, %r9d + jmp ..B1.30 +..B1.29: + movl 4(%rsp), %edx + lea 13(%rsi), %ecx + andl $1048575, %edx + movl %eax, %r9d + shll %cl, %edx +..B1.30: + cmpl $1043, %esi + jle ..B1.32 +..B1.31: + negl %esi + movl $-1, %edi + addl $19, %esi + movl %esi, %ecx + shll %cl, %edi + andl %edi, %eax + jmp ..B1.33 +..B1.32: + negl %esi + movl $1048575, %eax + addl $19, %esi + movl %esi, %ecx + shll %cl, %eax + movl 4(%rsp), %edi + movl %edi, %r8d + andl %eax, %edi + andl $-1048576, %r8d + andl $1048575, %edi + xorl %eax, %eax + orl %edi, %r8d + movl %r8d, 4(%rsp) +..B1.33: + movl %eax, (%rsp) + testl %edx, %edx + jge ..B1.13 +..B1.34: + andl $2147483647, %edx + orl %r9d, %edx + jne ..B1.37 +..B1.35: + movzwl 6(%rsp), %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $1043, %ecx + jle ..B1.38 +..B1.36: + negl %ecx + movl $1, %edx + addl $19, %ecx + shll %cl, %edx + testl %edx, %eax + je ..B1.13 +..B1.37: + movb 7(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movsd (%rsp), %xmm0 + movzbl %al, %ecx + addsd (%rdx,%rcx,8), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.38: + negl %ecx + movl $1, %eax + addl $19, %ecx + shll %cl, %eax + testl %eax, 4(%rsp) + je ..B1.13 +..B1.39: + movb 7(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movsd (%rsp), %xmm0 + movzbl %al, %ecx + addsd (%rdx,%rcx,8), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.42: + cmpl $1022, %esi + jg ..B1.48 +..B1.43: + jne ..B1.25 +..B1.44: + movl 4(%rsp), %eax + andl $1048575, %eax + jg ..B1.48 +..B1.45: + jne ..B1.25 +..B1.46: + cmpl $0, (%rsp) + jbe ..B1.25 +..B1.48: + movb 7(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movsd (%rdx,%rcx,8), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.49: + cmpl $1023, %esi + jl ..B1.57 +..B1.50: + cmpl $1043, %esi + jle ..B1.52 +..B1.51: + negl %esi + movl $-1, %eax + addl $19, %esi + movl %esi, %ecx + shll %cl, %eax + movl (%rsp), %edi + andl %edi, %eax + movl %eax, (%rsp) + xorl %eax, %edi + jmp ..B1.53 +..B1.52: + negl %esi + movl $1048575, %eax + addl $19, %esi + movl 4(%rsp), %edx + movl %edx, %edi + movl %esi, %ecx + andl $1048575, %edi + shll %cl, %eax + andl $-1048576, %edx + andl %edi, %eax + orl %eax, %edx + movl %edx, 4(%rsp) + andl $1048575, %edx + xorl %edx, %edi + orl (%rsp), %edi + movl $0, (%rsp) +..B1.53: + testb $-128, 7(%rsp) + je ..B1.13 +..B1.54: + testl %edi, %edi + je ..B1.13 +..B1.55: + lea 8+_ones(%rip), %rax + movsd (%rsp), %xmm0 + addsd (%rax), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.57: + testl %esi, %esi + jne ..B1.61 +..B1.58: + testl $1048575, 4(%rsp) + jne ..B1.61 +..B1.59: + cmpl $0, (%rsp) + je ..B1.13 +..B1.61: + movb 7(%rsp), %al + lea _pzero_none(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movsd (%rdx,%rcx,8), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.62: + lea _ones(%rip), %rax + movsd (%rsp), %xmm0 + mulsd (%rax), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type nearbyint,@function + .size nearbyint,.-nearbyint + .data +# -- End nearbyint + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_pone_nzero: + .long 0 + .long 1072693248 + .long 0 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_pzero_none: + .long 0 + .long 0 + .long 0 + .long 3220176896 + .type _pzero_none,@object + .size _pzero_none,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nearbyintf_gen.S b/external/sgx_libm/intel64/nearbyintf_gen.S new file mode 100644 index 0000000000..06543a1462 --- /dev/null +++ b/external/sgx_libm/intel64/nearbyintf_gen.S @@ -0,0 +1,336 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nearbyintf_gen.c" + .text +..TXTST0: +# -- Begin nearbyintf + .text + .align 16,0x90 + .globl nearbyintf +nearbyintf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_nearbyintf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movss %xmm0, 8(%rsp) +..B1.2: + stmxcsr 4(%rsp) +..B1.3: + movzwl 10(%rsp), %eax + andl $32640, %eax + shrl $7, %eax + cmpl $150, %eax + jge ..B1.10 +..B1.4: + movl 4(%rsp), %edx + andl $24576, %edx + cmpl $8192, %edx + je ..B1.32 +..B1.5: + cmpl $16384, %edx + jne ..B1.15 +..B1.6: + cmpl $127, %eax + jl ..B1.11 +..B1.7: + negl %eax + movl $8388607, %edx + addl $22, %eax + movl 8(%rsp), %esi + movl %esi, %edi + movl %eax, %ecx + andl $8388607, %edi + shll %cl, %edx + andl $-8388608, %esi + andl %edi, %edx + orl %edx, %esi + movl %esi, %eax + andl $8388607, %eax + movl %esi, 8(%rsp) + testl $-2147483648, %esi + jne ..B1.10 +..B1.8: + cmpl %edi, %eax + je ..B1.10 +..B1.9: + movss 8(%rsp), %xmm0 + addss .L_2il0floatpacket.1(%rip), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.10: + movss 8(%rsp), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.11: + testl %eax, %eax + jne ..B1.14 +..B1.12: + testl $8388607, 8(%rsp) + je ..B1.10 +..B1.14: + movb 11(%rsp), %dl + lea _pone_nzero(%rip), %rcx + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + movl 8(%rsp), %eax + movl %eax, (%rsp) + movss (%rcx,%rsi,4), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.15: + cmpl $24576, %edx + jne ..B1.20 +..B1.16: + cmpl $127, %eax + jl ..B1.18 +..B1.17: + negl %eax + movl $8388607, %edx + addl $22, %eax + movl %eax, %ecx + shll %cl, %edx + movl 8(%rsp), %esi + movl %esi, %edi + andl %edx, %esi + andl $-8388608, %edi + andl $8388607, %esi + orl %esi, %edi + movl %edi, 8(%rsp) + movss 8(%rsp), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.18: + movb 11(%rsp), %dl + lea _zeros(%rip), %rcx + andb $-128, %dl + movl 8(%rsp), %eax + movl %eax, (%rsp) + shrb $7, %dl + movzbl %dl, %esi + movss (%rcx,%rsi,4), %xmm0 +..B1.19: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.20: + cmpl $127, %eax + jl ..B1.27 +..B1.21: + movl 8(%rsp), %edi + movl %edi, %esi + andl $8388607, %esi + lea 10(%rax), %ecx + negl %eax + movl %esi, %r8d + addl $22, %eax + movl $8388607, %edx + shll %cl, %r8d + movl %eax, %ecx + shll %cl, %edx + andl $-8388608, %edi + andl %edx, %esi + orl %esi, %edi + movl %edi, 8(%rsp) + testl %r8d, %r8d + jge ..B1.10 +..B1.22: + cmpl $-2147483648, %r8d + jne ..B1.24 +..B1.23: + movzwl 10(%rsp), %ecx + movl $1, %eax + shrl $7, %ecx + negl %ecx + addl $22, %ecx + shll %cl, %eax + testl %eax, 8(%rsp) + je ..B1.10 +..B1.24: + movb 11(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movss 8(%rsp), %xmm0 + movzbl %al, %ecx + addss (%rdx,%rcx,4), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.27: + cmpl $126, %eax + jg ..B1.31 +..B1.28: + jne ..B1.30 +..B1.29: + testl $8388607, 8(%rsp) + jg ..B1.31 +..B1.30: + movb 11(%rsp), %dl + lea _zeros(%rip), %rcx + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + movl 8(%rsp), %eax + movl %eax, (%rsp) + movss (%rcx,%rsi,4), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.31: + movb 11(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.32: + cmpl $127, %eax + jl ..B1.37 +..B1.33: + negl %eax + movl $8388607, %edx + addl $22, %eax + movl 8(%rsp), %esi + movl %esi, %edi + movl %eax, %ecx + andl $8388607, %edi + shll %cl, %edx + andl $-8388608, %esi + andl %edi, %edx + orl %edx, %esi + movl %esi, %eax + andl $8388607, %eax + movl %esi, 8(%rsp) + testl $-2147483648, %esi + je ..B1.10 +..B1.34: + cmpl %edi, %eax + je ..B1.10 +..B1.35: + movss 8(%rsp), %xmm0 + addss .L_2il0floatpacket.0(%rip), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.37: + testl %eax, %eax + jne ..B1.40 +..B1.38: + testl $8388607, 8(%rsp) + je ..B1.10 +..B1.40: + movb 11(%rsp), %dl + lea _pzero_none(%rip), %rcx + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + movl 8(%rsp), %eax + movl %eax, (%rsp) + movss (%rcx,%rsi,4), %xmm0 + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type nearbyintf,@function + .size nearbyintf,.-nearbyintf + .data +# -- End nearbyintf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x3f800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_pone_nzero: + .long 1065353216 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_pzero_none: + .long 0 + .long 3212836864 + .type _pzero_none,@object + .size _pzero_none,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nearbyintl.S b/external/sgx_libm/intel64/nearbyintl.S new file mode 100644 index 0000000000..02ceb8f562 --- /dev/null +++ b/external/sgx_libm/intel64/nearbyintl.S @@ -0,0 +1,617 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nearbyintl.c" + .text +..TXTST0: +# -- Begin nearbyintl + .text + .align 16,0x90 + .globl nearbyintl +nearbyintl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_nearbyintl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %dil, %dil +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 56(%rsp), %r8d + andl $32767, %r8d + movzwl 26(%rsp), %r9d + cmpl $16446, %r8d + jge ..B1.95 +..B1.4: + movl %r9d, %eax + andl $3072, %eax + cmpl $1024, %eax + je ..B1.77 +..B1.5: + cmpl $2048, %eax + jne ..B1.24 +..B1.6: + cmpl $16383, %r8d + jl ..B1.19 +..B1.7: + cmpl $16415, %r8d + jl ..B1.9 +..B1.8: + negl %r8d + movl $-1, %edx + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %edx + movl 48(%rsp), %eax + andl %eax, %edx + movl %edx, 48(%rsp) + xorl %eax, %edx + jmp ..B1.10 +..B1.9: + negl %r8d + movl $-1, %edx + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %edx + movl 52(%rsp), %eax + andl %eax, %edx + movl %edx, 52(%rsp) + xorl %eax, %edx + orl 48(%rsp), %edx + movl $0, 48(%rsp) +..B1.10: + testb $-128, 57(%rsp) + jne ..B1.18 +..B1.11: + testl %edx, %edx + je ..B1.18 +..B1.12: + movl %r9d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.101 +..B1.13: + orl $-64768, %r9d + movw %r9w, 24(%rsp) +..B1.14: + fldcw 24(%rsp) +..B1.15: + fldt 48(%rsp) + lea _ones(%rip), %rax + faddl (%rax) + fstpt (%rsp) +..B1.16: + fldcw 26(%rsp) +..B1.17: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.18: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.19: + testl %r8d, %r8d + jne ..B1.23 +..B1.20: + cmpq $0, 48(%rsp) + jne ..B1.22 +..B1.21: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.22: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 16(%rsp) +..B1.23: + movb 57(%rsp), %al + lea _pone_nzero(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.24: + cmpl $3072, %eax + jne ..B1.35 +..B1.25: + cmpl $16383, %r8d + jl ..B1.30 +..B1.26: + cmpl $16415, %r8d + jl ..B1.28 +..B1.27: + negl %r8d + movl $-1, %eax + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %eax + andl 48(%rsp), %eax + jmp ..B1.29 +..B1.28: + negl %r8d + movl $-1, %eax + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %eax + andl %eax, 52(%rsp) + xorl %eax, %eax +..B1.29: + movl %eax, 48(%rsp) + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.30: + testl %r8d, %r8d + jne ..B1.34 +..B1.31: + cmpl $0, 52(%rsp) + jne ..B1.33 +..B1.32: + cmpl $0, 48(%rsp) + je ..B1.34 +..B1.33: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 16(%rsp) +..B1.34: + movb 57(%rsp), %al + lea _zeros(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.35: + cmpl $16383, %r8d + jl ..B1.69 +..B1.36: + movl 48(%rsp), %esi + cmpl $16414, %r8d + jl ..B1.38 +..B1.37: + movl %esi, %edx + lea 2(%r8), %ecx + shll %cl, %edx + xorl %eax, %eax + jmp ..B1.39 +..B1.38: + movl 52(%rsp), %edx + lea 2(%r8), %ecx + shll %cl, %edx + movl %esi, %eax +..B1.39: + cmpl $16415, %r8d + jl ..B1.41 +..B1.40: + movl %r8d, %ecx + movl $-1, %r10d + negl %ecx + addl $30, %ecx + shll %cl, %r10d + andl %r10d, %esi + movl %esi, 48(%rsp) + jmp ..B1.42 +..B1.41: + movl %r8d, %ecx + movl $-1, %r10d + negl %ecx + xorl %esi, %esi + addl $30, %ecx + shll %cl, %r10d + movl $0, 48(%rsp) + andl %r10d, 52(%rsp) +..B1.42: + testl %edx, %edx + jge ..B1.68 +..B1.43: + andl $2147483647, %edx + orl %eax, %edx + je ..B1.51 +..B1.44: + movl %r9d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.48 +..B1.45: + orl $-64768, %r9d + movw %r9w, 24(%rsp) +..B1.46: + fldcw 24(%rsp) +..B1.47: + movb $1, %dil +..B1.48: + fldt 48(%rsp) + lea _ones(%rip), %rdx + movb 57(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + testb %dil, %dil + faddl (%rdx,%rcx,8) + fstpt (%rsp) + je ..B1.50 +..B1.49: + fldcw 26(%rsp) +..B1.50: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.51: + cmpl $16415, %r8d + jl ..B1.60 +..B1.52: + negl %r8d + movl $1, %eax + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %eax + testl %eax, %esi + je ..B1.68 +..B1.53: + movl %r9d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.57 +..B1.54: + orl $-64768, %r9d + movw %r9w, 24(%rsp) +..B1.55: + fldcw 24(%rsp) +..B1.56: + movb $1, %dil +..B1.57: + fldt 48(%rsp) + lea _ones(%rip), %rdx + movb 57(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + testb %dil, %dil + faddl (%rdx,%rcx,8) + fstpt (%rsp) + je ..B1.59 +..B1.58: + fldcw 26(%rsp) +..B1.59: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.60: + negl %r8d + movl $1, %eax + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %eax + testl %eax, 52(%rsp) + je ..B1.68 +..B1.61: + movl %r9d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.65 +..B1.62: + orl $-64768, %r9d + movw %r9w, 24(%rsp) +..B1.63: + fldcw 24(%rsp) +..B1.64: + movb $1, %dil +..B1.65: + fldt 48(%rsp) + lea _ones(%rip), %rdx + movb 57(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + testb %dil, %dil + faddl (%rdx,%rcx,8) + fstpt (%rsp) + je ..B1.67 +..B1.66: + fldcw 26(%rsp) +..B1.67: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.68: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.69: + cmpl $16382, %r8d + jg ..B1.76 +..B1.70: + je ..B1.102 +..B1.71: + testl %r8d, %r8d + jne ..B1.75 +..B1.72: + cmpl $0, 52(%rsp) + jne ..B1.74 +..B1.73: + cmpl $0, 48(%rsp) + je ..B1.75 +..B1.74: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 16(%rsp) +..B1.75: + movb 57(%rsp), %al + lea _zeros(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.76: + movb 57(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.77: + cmpl $16383, %r8d + jl ..B1.90 +..B1.78: + cmpl $16415, %r8d + jl ..B1.80 +..B1.79: + negl %r8d + movl $-1, %eax + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %eax + movl 48(%rsp), %edx + andl %edx, %eax + movl %eax, 48(%rsp) + xorl %eax, %edx + jmp ..B1.81 +..B1.80: + negl %r8d + movl $-1, %eax + addl $30, %r8d + movl %r8d, %ecx + shll %cl, %eax + movl 52(%rsp), %edx + andl %edx, %eax + xorl %eax, %edx + orl 48(%rsp), %edx + movl %eax, 52(%rsp) + movl $0, 48(%rsp) +..B1.81: + testb $-128, 57(%rsp) + je ..B1.89 +..B1.82: + testl %edx, %edx + je ..B1.89 +..B1.83: + movl %r9d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.105 +..B1.84: + orl $-64768, %r9d + movw %r9w, 24(%rsp) +..B1.85: + fldcw 24(%rsp) +..B1.86: + fldt 48(%rsp) + lea 8+_ones(%rip), %rax + faddl (%rax) + fstpt (%rsp) +..B1.87: + fldcw 26(%rsp) +..B1.88: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.89: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.90: + testl %r8d, %r8d + jne ..B1.94 +..B1.91: + cmpq $0, 48(%rsp) + jne ..B1.93 +..B1.92: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.93: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 16(%rsp) +..B1.94: + movb 57(%rsp), %al + lea _pzero_none(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.95: + movl %r9d, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.106 +..B1.96: + orl $-64768, %r9d + movw %r9w, 24(%rsp) +..B1.97: + fldcw 24(%rsp) +..B1.98: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.99: + fldcw 26(%rsp) +..B1.100: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.101: + fldt 48(%rsp) + lea _ones(%rip), %rax + faddl (%rax) + fstpt (%rsp) + jmp ..B1.17 +..B1.102: + movl 52(%rsp), %eax + cmpl $-2147483648, %eax + ja ..B1.76 +..B1.103: + jne ..B1.75 +..B1.104: + cmpl $0, 48(%rsp) + ja ..B1.76 + jmp ..B1.75 +..B1.105: + fldt 48(%rsp) + lea 8+_ones(%rip), %rax + faddl (%rax) + fstpt (%rsp) + jmp ..B1.88 +..B1.106: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) + jmp ..B1.100 + .align 16,0x90 + .cfi_endproc + .type nearbyintl,@function + .size nearbyintl,.-nearbyintl + .data +# -- End nearbyintl + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_pone_nzero: + .long 0 + .long 1072693248 + .long 0 + .long 2147483648 + .type _pone_nzero,@object + .size _pone_nzero,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_pzero_none: + .long 0 + .long 0 + .long 0 + .long 3220176896 + .type _pzero_none,@object + .size _pzero_none,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nextafter_gen.S b/external/sgx_libm/intel64/nextafter_gen.S new file mode 100644 index 0000000000..9d8d5ea14b --- /dev/null +++ b/external/sgx_libm/intel64/nextafter_gen.S @@ -0,0 +1,202 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nextafter_gen.c" + .text +..TXTST0: +# -- Begin nextafter + .text + .align 16,0x90 + .globl nextafter +nextafter: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_nextafter.1: +..L2: + + movsd %xmm0, -16(%rsp) + movzwl -10(%rsp), %r8d + andl $32752, %r8d + shrl $4, %r8d + movsd %xmm1, -8(%rsp) + cmpl $2047, %r8d + je ..B1.23 +..B1.2: + movzwl -2(%rsp), %edi + andl $32752, %edi + shrl $4, %edi + cmpl $2047, %edi + je ..B1.20 +..B1.3: + movsd -8(%rsp), %xmm0 + movsd -16(%rsp), %xmm1 + ucomisd %xmm0, %xmm1 + jp ..B1.4 + je ..B1.17 +..B1.4: + movl -12(%rsp), %edx + movl %edx, %eax + andl $2147483647, %eax + orl -16(%rsp), %eax + je ..B1.19 +..B1.5: + movl %edx, %eax + movl -4(%rsp), %ecx + xorl %ecx, %eax + movq -16(%rsp), %rsi + testl $-2147483648, %eax + jne ..B1.11 +..B1.6: + cmpl %edi, %r8d + jg ..B1.11 +..B1.7: + jne ..B1.12 +..B1.8: + andl $1048575, %edx + andl $1048575, %ecx + cmpl %ecx, %edx + jg ..B1.11 +..B1.9: + jne ..B1.12 +..B1.10: + movl -16(%rsp), %eax + cmpl -8(%rsp), %eax + jbe ..B1.12 +..B1.11: + decq %rsi + movq %rsi, -16(%rsp) + jmp ..B1.13 +..B1.12: + incq %rsi + movq %rsi, -16(%rsp) +..B1.13: + movl -12(%rsp), %edx + andl $2147483647, %edx + lea -1048576(%rdx), %eax + cmpl $2145386496, %eax + jb ..B1.18 +..B1.14: + cmpl $1048576, %edx + jae ..B1.16 +..B1.15: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -24(%rsp) + movsd -16(%rsp), %xmm0 + ret +..B1.16: + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -24(%rsp) + movsd -16(%rsp), %xmm0 +..B1.17: + ret +..B1.18: + movsd -16(%rsp), %xmm0 + ret +..B1.19: + movb -1(%rsp), %al + lea _small_value_64(%rip), %rdi + andb $-128, %al + lea _smallest_value_64(%rip), %rdx + shrb $7, %al + movsd (%rdi), %xmm0 + mulsd %xmm0, %xmm0 + movzbl %al, %ecx + movsd %xmm0, -24(%rsp) + movq (%rdx,%rcx,8), %rsi + movq %rsi, -16(%rsp) + jmp ..B1.18 +..B1.20: + testl $1048575, -4(%rsp) + jne ..B1.22 +..B1.21: + cmpl $0, -8(%rsp) + je ..B1.3 +..B1.22: + movsd -16(%rsp), %xmm0 + addsd -8(%rsp), %xmm0 + ret +..B1.23: + testl $1048575, -12(%rsp) + jne ..B1.22 +..B1.24: + cmpl $0, -16(%rsp) + jne ..B1.22 + jmp ..B1.2 + .align 16,0x90 + .cfi_endproc + .type nextafter,@function + .size nextafter,.-nextafter + .data +# -- End nextafter + .section .rodata, "a" + .align 4 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nextafterf_gen.S b/external/sgx_libm/intel64/nextafterf_gen.S new file mode 100644 index 0000000000..7725fa21da --- /dev/null +++ b/external/sgx_libm/intel64/nextafterf_gen.S @@ -0,0 +1,182 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nextafterf_gen.c" + .text +..TXTST0: +# -- Begin nextafterf + .text + .align 16,0x90 + .globl nextafterf +nextafterf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_nextafterf.1: +..L2: + + movss %xmm0, -8(%rsp) + movzwl -6(%rsp), %edi + andl $32640, %edi + shrl $7, %edi + movss %xmm1, -16(%rsp) + cmpl $255, %edi + je ..B1.20 +..B1.2: + movzwl -14(%rsp), %esi + andl $32640, %esi + shrl $7, %esi + cmpl $255, %esi + je ..B1.18 +..B1.3: + movss -16(%rsp), %xmm0 + movss -8(%rsp), %xmm1 + ucomiss %xmm0, %xmm1 + jp ..B1.4 + je ..B1.15 +..B1.4: + movl -8(%rsp), %ecx + testl $2147483647, %ecx + je ..B1.17 +..B1.5: + movl %ecx, %eax + movl -16(%rsp), %edx + xorl %edx, %eax + testl $-2147483648, %eax + jne ..B1.9 +..B1.6: + cmpl %esi, %edi + jg ..B1.9 +..B1.7: + jne ..B1.10 +..B1.8: + movl %ecx, %eax + andl $8388607, %edx + andl $8388607, %eax + cmpl %edx, %eax + jle ..B1.10 +..B1.9: + decl %ecx + movl %ecx, -20(%rsp) + jmp ..B1.11 +..B1.10: + incl %ecx + movl %ecx, -20(%rsp) +..B1.11: + andl $2147483647, %ecx + lea -8388608(%rcx), %eax + cmpl $2130706432, %eax + jb ..B1.16 +..B1.12: + cmpl $8388608, %ecx + jae ..B1.14 +..B1.13: + movss .L_2il0floatpacket.0(%rip), %xmm1 + movss %xmm1, -24(%rsp) + movss -24(%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss -20(%rsp), %xmm0 + movss %xmm1, -24(%rsp) + ret +..B1.14: + movss .L_2il0floatpacket.1(%rip), %xmm0 + movss %xmm0, -24(%rsp) + movss -24(%rsp), %xmm1 + mulss %xmm0, %xmm1 + movss -20(%rsp), %xmm0 + movss %xmm1, -24(%rsp) +..B1.15: + ret +..B1.16: + movss -20(%rsp), %xmm0 + ret +..B1.17: + movb -13(%rsp), %al + lea _smallest_value_32(%rip), %rdx + andb $-128, %al + movss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, -24(%rsp) + shrb $7, %al + movss -24(%rsp), %xmm1 + mulss %xmm0, %xmm1 + movss %xmm1, -24(%rsp) + movzbl %al, %ecx + movl (%rdx,%rcx,4), %esi + movl %esi, -20(%rsp) + jmp ..B1.16 +..B1.18: + testl $8388607, -16(%rsp) + je ..B1.3 +..B1.19: + movss -8(%rsp), %xmm0 + addss -16(%rsp), %xmm0 + ret +..B1.20: + testl $8388607, -8(%rsp) + jne ..B1.19 + jmp ..B1.2 + .align 16,0x90 + .cfi_endproc + .type nextafterf,@function + .size nextafterf,.-nextafterf + .data +# -- End nextafterf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x0d800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_smallest_value_32: + .long 1 + .long 2147483649 + .type _smallest_value_32,@object + .size _smallest_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nextafterl.S b/external/sgx_libm/intel64/nextafterl.S new file mode 100644 index 0000000000..17e8aa1407 --- /dev/null +++ b/external/sgx_libm/intel64/nextafterl.S @@ -0,0 +1,382 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nextafterl.c" + .text +..TXTST0: +# -- Begin nextafterl + .text + .align 16,0x90 + .globl nextafterl +nextafterl: +# parameter 1: 48 + %rsp +# parameter 2: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_nextafterl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 56(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.53 +..B1.4: + movzwl 72(%rsp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.45 +..B1.5: + fldt 48(%rsp) + fldt 64(%rsp) + fucomi %st(1), %st + jp ..B1.6 + je ..B1.54 +..B1.6: + fstp %st(0) + testl %esi, %esi + jne ..B1.9 +..B1.7: + cmpl $0, 52(%rsp) + jne ..B1.9 +..B1.8: + cmpl $0, 48(%rsp) + je ..B1.44 +..B1.9: + movb 73(%rsp), %al + movb 57(%rsp), %dl + andb $-128, %al + andb $-128, %dl + shrb $7, %al + shrb $7, %dl + fstpt 16(%rsp) + cmpb %dl, %al + jne ..B1.15 +..B1.10: + cmpl %ecx, %esi + jg ..B1.15 +..B1.11: + jne ..B1.29 +..B1.12: + movl 52(%rsp), %eax + movl 68(%rsp), %edx + cmpl %edx, %eax + ja ..B1.15 +..B1.13: + jne ..B1.29 +..B1.14: + movl 48(%rsp), %eax + cmpl 64(%rsp), %eax + jbe ..B1.29 +..B1.15: + movzwl 24(%rsp), %edx + movl %edx, %edi + movl 16(%rsp), %eax + andl $32767, %edi + decl %eax + movl %eax, 16(%rsp) + cmpl $-1, %eax + jne ..B1.34 +..B1.16: + movl 20(%rsp), %eax + decl %eax + testl %edi, %edi + je ..B1.22 +..B1.17: + cmpl $2147483647, %eax + jne ..B1.21 +..B1.18: + decl %edi + andl $-32768, %edx + andl $32767, %edi + orl %edi, %edx + movw %dx, 24(%rsp) + testl %edi, %edi + je ..B1.20 +..B1.19: + movl %edx, %edi + orl $-2147483648, %eax + movl %eax, 20(%rsp) + andl $32767, %edi + jmp ..B1.34 +..B1.20: + movl %edx, %edi + movl %eax, 20(%rsp) + andl $32767, %edi + jmp ..B1.34 +..B1.21: + movl %eax, 20(%rsp) + jmp ..B1.35 +..B1.22: + movl %eax, 20(%rsp) +..B1.23: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.24: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.25: + fldcw 32(%rsp) +..B1.26: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) +..B1.27: + fldcw 34(%rsp) +..B1.28: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.29: + movzwl 24(%rsp), %ecx + movl %ecx, %edi + movl 16(%rsp), %eax + andl $32767, %edi + incl %eax + movl %eax, 16(%rsp) + jne ..B1.33 +..B1.30: + movl $-2147483648, %eax + xorl %edx, %edx + testl %edi, %edi + movl 20(%rsp), %esi + cmove %eax, %edx + incl %esi + cmpl %edx, %esi + jne ..B1.32 +..B1.31: + incl %edi + andl $-32768, %ecx + andl $32767, %edi + orl $-2147483648, %esi + orl %edi, %ecx + movl %ecx, %edi + movl %esi, 20(%rsp) + andl $32767, %edi + movw %cx, 24(%rsp) + jmp ..B1.33 +..B1.32: + movl %esi, 20(%rsp) +..B1.33: + cmpl $32767, %edi + je ..B1.37 +..B1.34: + testl %edi, %edi + je ..B1.23 +..B1.35: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.36: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.28 +..B1.37: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.38: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.39: + fldcw 32(%rsp) +..B1.40: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) +..B1.41: + fldcw 34(%rsp) +..B1.42: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.43: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.42 +..B1.44: + fstp %st(0) + movb 73(%rsp), %al + lea _smallest_value_80(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + shlq $4, %rcx + fldt (%rdx,%rcx) + movzwl 8(%rdx,%rcx), %edi + fstpt 16(%rsp) + andl $32767, %edi + jmp ..B1.34 +..B1.45: + movq $0x8000000000000000, %rax + cmpq 64(%rsp), %rax + je ..B1.5 +..B1.46: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.52 +..B1.47: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.48: + fldcw 32(%rsp) +..B1.49: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt 16(%rsp) +..B1.50: + fldcw 34(%rsp) +..B1.51: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.52: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.51 +..B1.53: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.46 + jmp ..B1.4 +..B1.54: + fstp %st(1) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type nextafterl,@function + .size nextafterl,.-nextafterl + .data +# -- End nextafterl + .section .rodata, "a" + .align 4 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_smallest_value_80: + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 0 + .word 0 + .type _smallest_value_80,@object + .size _smallest_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nexttoward_gen.S b/external/sgx_libm/intel64/nexttoward_gen.S new file mode 100644 index 0000000000..aa9a7f0e30 --- /dev/null +++ b/external/sgx_libm/intel64/nexttoward_gen.S @@ -0,0 +1,212 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nexttoward_gen.c" + .text +..TXTST0: +# -- Begin nexttoward + .text + .align 16,0x90 + .globl nexttoward +nexttoward: +# parameter 1: %xmm0 +# parameter 2: 8 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_nexttoward.1: +..L2: + + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %eax + andl $32752, %eax + cmpl $32752, %eax + je ..B1.22 +..B1.2: + movzwl 16(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.20 +..B1.3: + fldl -8(%rsp) + fldt 8(%rsp) + fucomi %st(1), %st + jp ..B1.4 + je ..B1.24 +..B1.4: + fstp %st(0) + movl -4(%rsp), %eax + andl $2147483647, %eax + orl -8(%rsp), %eax + je ..B1.19 +..B1.5: + fstpt -24(%rsp) + movb -15(%rsp), %dl + movb 17(%rsp), %al + andb $-128, %dl + andb $-128, %al + shrb $7, %dl + shrb $7, %al + movq -8(%rsp), %rcx + cmpb %dl, %al + jne ..B1.11 +..B1.6: + movzwl -16(%rsp), %eax + andl $32767, %eax + cmpl %esi, %eax + jg ..B1.11 +..B1.7: + jne ..B1.12 +..B1.8: + movl -20(%rsp), %eax + movl 12(%rsp), %edx + cmpl %edx, %eax + ja ..B1.11 +..B1.9: + jne ..B1.12 +..B1.10: + movl -24(%rsp), %eax + cmpl 8(%rsp), %eax + jbe ..B1.12 +..B1.11: + decq %rcx + movq %rcx, -40(%rsp) + jmp ..B1.13 +..B1.12: + incq %rcx + movq %rcx, -40(%rsp) +..B1.13: + movl -36(%rsp), %edx + andl $2147483647, %edx + lea -1048576(%rdx), %eax + cmpl $2145386496, %eax + jb ..B1.18 +..B1.14: + cmpl $1048576, %edx + jae ..B1.16 +..B1.15: + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -32(%rsp) + movsd -40(%rsp), %xmm0 + ret +..B1.16: + lea _large_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, -32(%rsp) + movsd -40(%rsp), %xmm0 +..B1.17: + ret +..B1.18: + movsd -40(%rsp), %xmm0 + ret +..B1.19: + fstp %st(0) + movb 17(%rsp), %al + lea _small_value_64(%rip), %rdi + andb $-128, %al + lea _smallest_value_64(%rip), %rdx + shrb $7, %al + movsd (%rdi), %xmm0 + mulsd %xmm0, %xmm0 + movzbl %al, %ecx + movsd %xmm0, -32(%rsp) + movq (%rdx,%rcx,8), %rsi + movq %rsi, -40(%rsp) + jmp ..B1.18 +..B1.20: + movq $0x8000000000000000, %rax + cmpq 8(%rsp), %rax + je ..B1.3 +..B1.21: + fldl -8(%rsp) + fldt 8(%rsp) + fmulp %st, %st(1) + fstpl -40(%rsp) + movsd -40(%rsp), %xmm0 + ret +..B1.22: + testl $1048575, -4(%rsp) + jne ..B1.21 +..B1.23: + cmpl $0, -8(%rsp) + jne ..B1.21 + jmp ..B1.2 +..B1.24: + fstp %st(1) + fstpl -40(%rsp) + movsd -40(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type nexttoward,@function + .size nexttoward,.-nexttoward + .data +# -- End nexttoward + .section .rodata, "a" + .align 4 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nexttowardf_gen.S b/external/sgx_libm/intel64/nexttowardf_gen.S new file mode 100644 index 0000000000..cb6ecda6e4 --- /dev/null +++ b/external/sgx_libm/intel64/nexttowardf_gen.S @@ -0,0 +1,201 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nexttowardf_gen.c" + .text +..TXTST0: +# -- Begin nexttowardf + .text + .align 16,0x90 + .globl nexttowardf +nexttowardf: +# parameter 1: %xmm0 +# parameter 2: 8 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_nexttowardf.1: +..L2: + + movss %xmm0, -16(%rsp) + movzwl -14(%rsp), %eax + andl $32640, %eax + cmpl $32640, %eax + je ..B1.22 +..B1.2: + movzwl 16(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.20 +..B1.3: + flds -16(%rsp) + fldt 8(%rsp) + fucomi %st(1), %st + jp ..B1.4 + je ..B1.23 +..B1.4: + fstp %st(0) + movl -16(%rsp), %ecx + testl $2147483647, %ecx + je ..B1.19 +..B1.5: + fstpt -24(%rsp) + movb -15(%rsp), %dl + movb 17(%rsp), %al + andb $-128, %dl + andb $-128, %al + shrb $7, %dl + shrb $7, %al + cmpb %dl, %al + jne ..B1.11 +..B1.6: + movzwl -16(%rsp), %eax + andl $32767, %eax + cmpl %esi, %eax + jg ..B1.11 +..B1.7: + jne ..B1.12 +..B1.8: + movl -20(%rsp), %eax + movl 12(%rsp), %edx + cmpl %edx, %eax + ja ..B1.11 +..B1.9: + jne ..B1.12 +..B1.10: + movl -24(%rsp), %eax + cmpl 8(%rsp), %eax + jbe ..B1.12 +..B1.11: + decl %ecx + movl %ecx, -24(%rsp) + jmp ..B1.13 +..B1.12: + incl %ecx + movl %ecx, -24(%rsp) +..B1.13: + andl $2147483647, %ecx + lea -8388608(%rcx), %eax + cmpl $2130706432, %eax + jb ..B1.18 +..B1.14: + cmpl $8388608, %ecx + jae ..B1.16 +..B1.15: + movss .L_2il0floatpacket.0(%rip), %xmm1 + movss %xmm1, -8(%rsp) + movss -8(%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss -24(%rsp), %xmm0 + movss %xmm1, -8(%rsp) + ret +..B1.16: + movss .L_2il0floatpacket.1(%rip), %xmm0 + movss %xmm0, -8(%rsp) + movss -8(%rsp), %xmm1 + mulss %xmm0, %xmm1 + movss -24(%rsp), %xmm0 + movss %xmm1, -8(%rsp) +..B1.17: + ret +..B1.18: + movss -24(%rsp), %xmm0 + ret +..B1.19: + fstp %st(0) + movb 17(%rsp), %al + lea _smallest_value_32(%rip), %rdx + andb $-128, %al + movss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, -8(%rsp) + shrb $7, %al + movss -8(%rsp), %xmm1 + mulss %xmm0, %xmm1 + movss %xmm1, -8(%rsp) + movzbl %al, %ecx + movl (%rdx,%rcx,4), %esi + movl %esi, -24(%rsp) + jmp ..B1.18 +..B1.20: + movq $0x8000000000000000, %rax + cmpq 8(%rsp), %rax + je ..B1.3 +..B1.21: + flds -16(%rsp) + fldt 8(%rsp) + fmulp %st, %st(1) + fstps -24(%rsp) + movss -24(%rsp), %xmm0 + ret +..B1.22: + testl $8388607, -16(%rsp) + jne ..B1.21 + jmp ..B1.2 +..B1.23: + fstp %st(1) + fstps -24(%rsp) + movss -24(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type nexttowardf,@function + .size nexttowardf,.-nexttowardf + .data +# -- End nexttowardf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x0d800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_smallest_value_32: + .long 1 + .long 2147483649 + .type _smallest_value_32,@object + .size _smallest_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/nexttowardl.S b/external/sgx_libm/intel64/nexttowardl.S new file mode 100644 index 0000000000..765e2c35bf --- /dev/null +++ b/external/sgx_libm/intel64/nexttowardl.S @@ -0,0 +1,382 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "nexttowardl.c" + .text +..TXTST0: +# -- Begin nexttowardl + .text + .align 16,0x90 + .globl nexttowardl +nexttowardl: +# parameter 1: 48 + %rsp +# parameter 2: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_nexttowardl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 56(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.53 +..B1.4: + movzwl 72(%rsp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.45 +..B1.5: + fldt 48(%rsp) + fldt 64(%rsp) + fucomi %st(1), %st + jp ..B1.6 + je ..B1.54 +..B1.6: + fstp %st(0) + testl %esi, %esi + jne ..B1.9 +..B1.7: + cmpl $0, 52(%rsp) + jne ..B1.9 +..B1.8: + cmpl $0, 48(%rsp) + je ..B1.44 +..B1.9: + movb 73(%rsp), %al + movb 57(%rsp), %dl + andb $-128, %al + andb $-128, %dl + shrb $7, %al + shrb $7, %dl + fstpt 16(%rsp) + cmpb %dl, %al + jne ..B1.15 +..B1.10: + cmpl %ecx, %esi + jg ..B1.15 +..B1.11: + jne ..B1.29 +..B1.12: + movl 52(%rsp), %eax + movl 68(%rsp), %edx + cmpl %edx, %eax + ja ..B1.15 +..B1.13: + jne ..B1.29 +..B1.14: + movl 48(%rsp), %eax + cmpl 64(%rsp), %eax + jbe ..B1.29 +..B1.15: + movzwl 24(%rsp), %edx + movl %edx, %edi + movl 16(%rsp), %eax + andl $32767, %edi + decl %eax + movl %eax, 16(%rsp) + cmpl $-1, %eax + jne ..B1.34 +..B1.16: + movl 20(%rsp), %eax + decl %eax + testl %edi, %edi + je ..B1.22 +..B1.17: + cmpl $2147483647, %eax + jne ..B1.21 +..B1.18: + decl %edi + andl $-32768, %edx + andl $32767, %edi + orl %edi, %edx + movw %dx, 24(%rsp) + testl %edi, %edi + je ..B1.20 +..B1.19: + movl %edx, %edi + orl $-2147483648, %eax + movl %eax, 20(%rsp) + andl $32767, %edi + jmp ..B1.34 +..B1.20: + movl %edx, %edi + movl %eax, 20(%rsp) + andl $32767, %edi + jmp ..B1.34 +..B1.21: + movl %eax, 20(%rsp) + jmp ..B1.35 +..B1.22: + movl %eax, 20(%rsp) +..B1.23: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.24: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.25: + fldcw 32(%rsp) +..B1.26: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) +..B1.27: + fldcw 34(%rsp) +..B1.28: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.29: + movzwl 24(%rsp), %ecx + movl %ecx, %edi + movl 16(%rsp), %eax + andl $32767, %edi + incl %eax + movl %eax, 16(%rsp) + jne ..B1.33 +..B1.30: + movl $-2147483648, %eax + xorl %edx, %edx + testl %edi, %edi + movl 20(%rsp), %esi + cmove %eax, %edx + incl %esi + cmpl %edx, %esi + jne ..B1.32 +..B1.31: + incl %edi + andl $-32768, %ecx + andl $32767, %edi + orl $-2147483648, %esi + orl %edi, %ecx + movl %ecx, %edi + movl %esi, 20(%rsp) + andl $32767, %edi + movw %cx, 24(%rsp) + jmp ..B1.33 +..B1.32: + movl %esi, 20(%rsp) +..B1.33: + cmpl $32767, %edi + je ..B1.37 +..B1.34: + testl %edi, %edi + je ..B1.23 +..B1.35: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.36: + lea _small_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.28 +..B1.37: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.38: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.39: + fldcw 32(%rsp) +..B1.40: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) +..B1.41: + fldcw 34(%rsp) +..B1.42: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.43: + lea _large_value_80(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt (%rsp) + jmp ..B1.42 +..B1.44: + fstp %st(0) + movb 73(%rsp), %al + lea _smallest_value_80(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + shlq $4, %rcx + fldt (%rdx,%rcx) + movzwl 8(%rdx,%rcx), %edi + fstpt 16(%rsp) + andl $32767, %edi + jmp ..B1.34 +..B1.45: + movq $0x8000000000000000, %rax + cmpq 64(%rsp), %rax + je ..B1.5 +..B1.46: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.52 +..B1.47: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.48: + fldcw 32(%rsp) +..B1.49: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt 16(%rsp) +..B1.50: + fldcw 34(%rsp) +..B1.51: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.52: + fldt 48(%rsp) + fldt 64(%rsp) + fmulp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.51 +..B1.53: + movq $0x8000000000000000, %rax + cmpq 48(%rsp), %rax + jne ..B1.46 + jmp ..B1.4 +..B1.54: + fstp %st(1) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type nexttowardl,@function + .size nexttowardl,.-nexttowardl + .data +# -- End nexttowardl + .section .rodata, "a" + .align 4 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_smallest_value_80: + .word 1 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 0 + .word 0 + .word 0 + .type _smallest_value_80,@object + .size _smallest_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/pow_gen.S b/external/sgx_libm/intel64/pow_gen.S new file mode 100644 index 0000000000..5df1c692ec --- /dev/null +++ b/external/sgx_libm/intel64/pow_gen.S @@ -0,0 +1,4493 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "pow_gen.c" + .text +..TXTST0: +# -- Begin pow + .text + .align 16,0x90 + .globl pow +pow: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_pow.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movsd %xmm0, 8(%rsp) + movsd %xmm1, 16(%rsp) +..B1.2: + movlpd SIGMASK(%rip), %xmm7 + movlpd ONEMASK(%rip), %xmm2 + andpd %xmm0, %xmm7 + movq %xmm0, %xmm4 + psrlq $44, %xmm0 + pextrw $0, %xmm0, %eax + orpd %xmm2, %xmm7 + pextrw $3, %xmm4, %ecx + andl $255, %eax + addl $1, %eax + andl $510, %eax + lea rcp_t1(%rip), %r8 + mulsd (%r8,%rax,4), %xmm7 + movlpd (%r8,%rax,4), %xmm5 + addl %eax, %eax + lea log2_t1(%rip), %r8 + movapd (%r8,%rax,4), %xmm6 + movl $32751, %edx + subl %ecx, %edx + subl $16, %ecx + orl %edx, %ecx + cmpl $-2147483648, %ecx + jae .L_2TAG_PACKET_0.0.2 + movl $0, %ecx + movl $261759, %edx +.L_2TAG_PACKET_1.0.2: +.L_2TAG_PACKET_2.0.2: + movd %edx, %xmm1 + psubq %xmm1, %xmm0 + psrlq $8, %xmm0 + cvtdq2pd %xmm0, %xmm0 + movlpd HALFSIG(%rip), %xmm1 + movq %xmm7, %xmm3 + psrlq $38, %xmm7 + pextrw $0, %xmm7, %eax + andpd SIGMASK(%rip), %xmm4 + andl $255, %eax + addl $1, %eax + andl $510, %eax + lea rcp_t2(%rip), %r8 + mulsd (%r8,%rax,4), %xmm3 + mulsd (%r8,%rax,4), %xmm5 + addl %eax, %eax + lea log2_t2(%rip), %r8 + addpd (%r8,%rax,4), %xmm6 + orpd ONEMASK(%rip), %xmm4 + addsd %xmm0, %xmm6 + andpd %xmm4, %xmm1 + movq %xmm3, %xmm2 + psrlq $31, %xmm3 + pextrw $0, %xmm3, %eax + movlpd HALFSIG(%rip), %xmm0 + subsd %xmm1, %xmm4 + movlpd LHN(%rip), %xmm7 + andl $511, %eax + addl $1, %eax + andl $1022, %eax + lea rcp_t3(%rip), %r8 + mulsd (%r8,%rax,4), %xmm5 + mulsd (%r8,%rax,4), %xmm2 + lea log2_t3(%rip), %r8 + addpd (%r8,%rax,8), %xmm6 + andpd %xmm5, %xmm0 + subsd %xmm0, %xmm5 + addsd %xmm2, %xmm7 + movq %xmm0, %xmm3 + mulsd %xmm1, %xmm0 + mulsd %xmm5, %xmm1 + mulsd %xmm4, %xmm3 + subsd %xmm0, %xmm2 + mulsd %xmm5, %xmm4 + movq %xmm6, %xmm0 + subsd %xmm1, %xmm2 + addsd %xmm7, %xmm6 + movlpd 16(%rsp), %xmm1 + pextrw $3, %xmm1, %eax + subsd %xmm3, %xmm2 + subsd %xmm6, %xmm0 + movlpd HALFSIG(%rip), %xmm3 + pextrw $3, %xmm6, %edx + subsd %xmm4, %xmm2 + movq %xmm6, %xmm4 + addsd %xmm7, %xmm0 + subsd %xmm2, %xmm7 + subsd %xmm2, %xmm6 + unpcklpd %xmm7, %xmm7 + andl $32752, %eax + cmpl $32752, %eax + jae .L_2TAG_PACKET_3.0.2 + andl $32752, %edx + subl $16368, %eax + addl %edx, %eax + movl $16544, %edx + subl %eax, %edx + subl $15472, %eax + orl %eax, %edx + cmpl $-2147483648, %edx + jae .L_2TAG_PACKET_4.0.2 +.L_2TAG_PACKET_5.0.2: + subsd %xmm6, %xmm4 + subsd %xmm4, %xmm2 + movlpd HALFSIG(%rip), %xmm4 + andpd %xmm1, %xmm3 + andpd %xmm6, %xmm4 + subsd %xmm2, %xmm0 + xorpd %xmm2, %xmm2 + movl $16480, %edx + pinsrw $3, %edx, %xmm2 + movq %xmm3, %xmm5 + mulsd %xmm4, %xmm3 + subsd %xmm4, %xmm6 + subsd %xmm5, %xmm1 + mulsd %xmm2, %xmm3 + mulsd %xmm6, %xmm5 + movapd clv(%rip), %xmm2 + mulsd %xmm1, %xmm4 + cvtsd2si %xmm3, %eax + mulsd %xmm1, %xmm6 + movapd 16+clv(%rip), %xmm1 + addsd %xmm4, %xmm5 + pshufd $238, %xmm6, %xmm4 + addsd %xmm6, %xmm5 + movl $130943, %edx + subl %eax, %edx + addl $123391, %eax + orl %eax, %edx + subl $123391, %eax + cmpl $0, %edx + jle .L_2TAG_PACKET_6.0.2 + addl %eax, %ecx + andl $127, %eax + andl $-128, %ecx + addl $130944, %ecx + addsd %xmm0, %xmm4 + movq %xmm3, %xmm0 + addsd Shifter(%rip), %xmm3 + mulpd %xmm7, %xmm2 + subsd Shifter(%rip), %xmm3 + mulpd %xmm7, %xmm7 + subsd %xmm3, %xmm0 + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + lea exp2_tbl(%rip), %r8 + movapd (%r8,%rax), %xmm3 + movapd cev(%rip), %xmm6 + mulpd %xmm7, %xmm1 + addpd %xmm1, %xmm2 + pshufd $238, %xmm2, %xmm1 + mulsd %xmm7, %xmm2 + xorpd %xmm7, %xmm7 + movl $16256, %edx + addsd %xmm1, %xmm2 + pinsrw $3, %edx, %xmm7 + addsd %xmm4, %xmm2 + movlpd 32+cev(%rip), %xmm4 + movd %ecx, %xmm1 + mulsd 16(%rsp), %xmm2 + mulsd %xmm7, %xmm0 + psllq $45, %xmm1 + pshufd $68, %xmm1, %xmm1 + movapd 16+cev(%rip), %xmm7 + addsd %xmm2, %xmm5 + addsd %xmm5, %xmm0 + unpcklpd %xmm0, %xmm0 + mulpd %xmm0, %xmm6 + mulsd %xmm0, %xmm4 + pshufd $238, %xmm3, %xmm5 + mulpd %xmm0, %xmm0 + addpd %xmm6, %xmm7 + mulpd %xmm0, %xmm7 + mulsd %xmm3, %xmm0 + pshufd $238, %xmm7, %xmm6 + mulsd %xmm7, %xmm0 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm4 + addsd %xmm5, %xmm0 + addsd %xmm6, %xmm0 + addsd %xmm4, %xmm0 + addsd %xmm3, %xmm0 + mulsd %xmm1, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + movlpd 16(%rsp), %xmm1 + movlpd ABSVALMASK(%rip), %xmm3 + movd %xmm1, %eax + movq %xmm1, %xmm2 + andpd %xmm3, %xmm1 + psrlq $32, %xmm1 + movd %xmm1, %ecx + cmpl $2146435072, %ecx + jae .L_2TAG_PACKET_7.0.2 + orl %ecx, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_8.0.2 + cmpl $0, %edx + jge .L_2TAG_PACKET_9.0.2 + negl %edx + addl $32751, %edx + psllq $52, %xmm3 + orpd %xmm3, %xmm2 + movl $1011, %ecx + movd %ecx, %xmm3 + psrlq $20, %xmm1 + psubd %xmm3, %xmm1 + pxor %xmm3, %xmm3 + pmaxsw %xmm3, %xmm1 + psllq %xmm1, %xmm2 + pcmpeqd %xmm3, %xmm2 + pmovmskb %xmm2, %eax + movl %edx, %ecx + andl $32767, %edx + cmpl $32752, %edx + jae .L_2TAG_PACKET_10.0.2 + andl $255, %eax + cmpl $255, %eax + jne .L_2TAG_PACKET_11.0.2 + movlpd 16(%rsp), %xmm1 + movlpd 16(%rsp), %xmm2 + movl $1012, %ecx + movd %ecx, %xmm3 + andpd ABSVALMASK(%rip), %xmm1 + psrlq $52, %xmm1 + psubd %xmm3, %xmm1 + movlpd NEG_ZERO(%rip), %xmm3 + psllq %xmm1, %xmm2 + pcmpeqd %xmm3, %xmm2 + pmovmskb %xmm2, %eax + andl $255, %eax + movl $261889, %ecx + addl %eax, %ecx + andl $262144, %ecx + cmpl $16, %edx + jb .L_2TAG_PACKET_12.0.2 + movl $786047, %edx + movlpd SIGMASK(%rip), %xmm3 + movlpd ONEMASK(%rip), %xmm2 + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_7.0.2: + movlpd 8(%rsp), %xmm7 + movlpd 8(%rsp), %xmm4 + movd %xmm7, %edx + psrlq $32, %xmm7 + movd %xmm7, %eax + movl %eax, %ecx + andl $2147483647, %eax + cmpl $2146435072, %eax + jb .L_2TAG_PACKET_13.0.2 + ja .L_2TAG_PACKET_14.0.2 + cmpl $0, %edx + ja .L_2TAG_PACKET_14.0.2 + jmp .L_2TAG_PACKET_13.0.2 +.L_2TAG_PACKET_9.0.2: + movl $0, %ecx +.L_2TAG_PACKET_12.0.2: + xorpd %xmm0, %xmm0 + movl $17392, %eax + pinsrw $3, %eax, %xmm0 + movlpd SIGMASK(%rip), %xmm7 + movlpd ONEMASK(%rip), %xmm2 + mulsd %xmm4, %xmm0 + movd %xmm4, %edx + psrlq $32, %xmm4 + movd %xmm4, %eax + cmpl $0, %edx + je .L_2TAG_PACKET_15.0.2 + movq 16(%rsp), %xmm4 + pextrw $3, %xmm4, %eax + andl $49152, %eax + cmpl $16384, %eax + je .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_17.0.2: + andpd %xmm0, %xmm7 + movq %xmm0, %xmm4 + andpd ABSVALMASK(%rip), %xmm0 + psrlq $44, %xmm0 + pextrw $0, %xmm0, %eax + orpd %xmm2, %xmm7 + andl $255, %eax + addl $1, %eax + andl $510, %eax + lea rcp_t1(%rip), %r8 + mulsd (%r8,%rax,4), %xmm7 + movlpd (%r8,%rax,4), %xmm5 + addl %eax, %eax + lea log2_t1(%rip), %r8 + movapd (%r8,%rax,4), %xmm6 + movl $278143, %edx + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_15.0.2: + movl %eax, %edx + andl $2147483647, %edx + cmpl $0, %edx + jne .L_2TAG_PACKET_17.0.2 + movl 20(%rsp), %edx + andl $-2147483648, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_18.0.2 + shll $13, %ecx + andl %ecx, %eax + movl $2146435072, %edx + orl %eax, %edx + movd %edx, %xmm0 + psllq $32, %xmm0 + movlpd ONEMASK(%rip), %xmm1 + movlpd 8(%rsp), %xmm2 + divsd %xmm2, %xmm1 +.L_2TAG_PACKET_19.0.2: + movl $27, (%rsp) + jmp .L_2TAG_PACKET_20.0.2 +.L_2TAG_PACKET_18.0.2: + shll $13, %ecx + andl %ecx, %eax + cmpl $0, %eax + jne .L_2TAG_PACKET_21.0.2 + pxor %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_10.0.2: + movlpd SIGMASK(%rip), %xmm3 + xorpd %xmm1, %xmm1 + andpd %xmm4, %xmm3 + pcmpeqd %xmm3, %xmm1 + pmovmskb %xmm1, %ecx + andl $255, %ecx + cmpl $255, %ecx + jne .L_2TAG_PACKET_14.0.2 + pextrw $3, %xmm4, %ecx + andl $32768, %ecx + cmpl $0, %ecx + je .L_2TAG_PACKET_22.0.2 + andl $255, %eax + cmpl $255, %eax + jne .L_2TAG_PACKET_23.0.2 + movlpd 16(%rsp), %xmm1 + movlpd 16(%rsp), %xmm2 + movl $1012, %ecx + movd %ecx, %xmm3 + andpd ABSVALMASK(%rip), %xmm1 + psrlq $52, %xmm1 + psubd %xmm3, %xmm1 + pxor %xmm3, %xmm3 + psllq %xmm1, %xmm2 + pcmpeqd %xmm3, %xmm2 + pmovmskb %xmm2, %eax + andl $255, %eax + cmpl $255, %eax + je .L_2TAG_PACKET_23.0.2 + movlpd 16(%rsp), %xmm1 + pextrw $3, %xmm1, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_24.0.2 +.L_2TAG_PACKET_21.0.2: + movq NEG_ZERO(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_24.0.2: + movq NEG_INF(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_23.0.2: + movlpd 16(%rsp), %xmm1 + pextrw $3, %xmm1, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_25.0.2 + pxor %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_22.0.2: + movlpd 16(%rsp), %xmm1 + pextrw $3, %xmm1, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_25.0.2 + pxor %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_14.0.2: + addsd %xmm4, %xmm4 + movq %xmm4, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_11.0.2: + movlpd 8(%rsp), %xmm2 + movd %xmm2, %eax + psrlq $32, %xmm2 + movd %xmm2, %edx + andl $2147483647, %edx + orl %edx, %eax + movl $0, %ecx + cmpl $0, %eax + je .L_2TAG_PACKET_15.0.2 + movlpd sNaN(%rip), %xmm0 + mulsd %xmm0, %xmm0 + movl $28, (%rsp) + jmp .L_2TAG_PACKET_20.0.2 +.L_2TAG_PACKET_3.0.2: + movlpd 8(%rsp), %xmm4 + movlpd 16(%rsp), %xmm2 + movd %xmm4, %eax + cmpl $0, %eax + jne .L_2TAG_PACKET_13.0.2 + psrlq $32, %xmm4 + movd %xmm4, %edx + cmpl $1072693248, %edx + je .L_2TAG_PACKET_26.0.2 + cmpl $-1074790400, %edx + jne .L_2TAG_PACKET_13.0.2 + movlpd SIGMASK(%rip), %xmm3 + xorpd %xmm1, %xmm1 + andpd %xmm2, %xmm3 + pcmpeqd %xmm3, %xmm1 + pmovmskb %xmm1, %eax + cmpl $255, %eax + jne .L_2TAG_PACKET_27.0.2 + movq ONEMASK(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_13.0.2: + movlpd SIGMASK(%rip), %xmm3 + xorpd %xmm1, %xmm1 + andpd %xmm2, %xmm3 + pcmpeqd %xmm3, %xmm1 + pmovmskb %xmm1, %eax + andl $255, %eax + cmpl $255, %eax + jne .L_2TAG_PACKET_27.0.2 + pextrw $3, %xmm2, %eax + movlpd 8(%rsp), %xmm4 + andl $32768, %eax + xorl $-1074790400, %ecx + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_26.0.2 + cmpl $0, %eax + je .L_2TAG_PACKET_28.0.2 + pextrw $3, %xmm4, %eax + andl $32752, %eax + cmpl $16368, %eax + jae .L_2TAG_PACKET_29.0.2 + movd %xmm4, %eax + psrlq $32, %xmm4 + movd %xmm4, %edx + andl $2147483647, %edx + orl %eax, %edx + cmpl $0, %edx + jne .L_2TAG_PACKET_25.0.2 + xorpd %xmm1, %xmm1 + xorpd %xmm4, %xmm4 + movl $16368, %eax + pinsrw $3, %eax, %xmm1 + divsd %xmm4, %xmm1 + movq %xmm1, %xmm0 + jmp .L_2TAG_PACKET_19.0.2 +.L_2TAG_PACKET_29.0.2: + pxor %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_28.0.2: + pextrw $3, %xmm4, %eax + andl $32752, %eax + cmpl $16368, %eax + jae .L_2TAG_PACKET_25.0.2 + pxor %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_25.0.2: + movq INF(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_27.0.2: + addsd %xmm2, %xmm2 + movq %xmm2, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_30.0.2: + movl $26, (%rsp) + jmp .L_2TAG_PACKET_20.0.2 +.L_2TAG_PACKET_31.0.2: + movl $29, (%rsp) + jmp .L_2TAG_PACKET_20.0.2 +.L_2TAG_PACKET_8.0.2: + movd %xmm4, %eax + psrlq $32, %xmm4 + movd %xmm4, %edx + andl $2147483647, %edx + movl %eax, %ecx + orl %edx, %eax + movlpd ONEMASK(%rip), %xmm0 + cmpl $0, %eax + je .L_2TAG_PACKET_30.0.2 + movd %xmm4, %eax + andl $2147483647, %eax + cmpl $2146435072, %eax + ja .L_2TAG_PACKET_31.0.2 + jb .L_2TAG_PACKET_32.0.2 + cmpl $0, %ecx + ja .L_2TAG_PACKET_31.0.2 +.L_2TAG_PACKET_32.0.2: +.L_2TAG_PACKET_26.0.2: + movq ONEMASK(%rip), %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_33.0.2: + movl $24, (%rsp) + jmp .L_2TAG_PACKET_20.0.2 +.L_2TAG_PACKET_34.0.2: + movl $25, (%rsp) + jmp .L_2TAG_PACKET_20.0.2 +.L_2TAG_PACKET_6.0.2: + cmpl $0, %eax + jle .L_2TAG_PACKET_35.0.2 + cmpl $262144, %eax + jae .L_2TAG_PACKET_36.0.2 + movl %eax, %edx + andl $127, %eax + addl $261888, %ecx + subl $128, %edx + andl $-128, %edx + movl $16368, %edi + jmp .L_2TAG_PACKET_37.0.2 +.L_2TAG_PACKET_35.0.2: + cmpl $-261632, %eax + jle .L_2TAG_PACKET_16.0.2 + movl %eax, %edx + andl $127, %eax + addl $128, %ecx + andl $-128, %edx + addl $261760, %edx + movl $0, %edi +.L_2TAG_PACKET_37.0.2: + addsd %xmm0, %xmm4 + movq %xmm3, %xmm0 + addsd Shifter(%rip), %xmm3 + movl %edx, %esi + subl $130944, %esi + mulpd %xmm7, %xmm2 + subsd Shifter(%rip), %xmm3 + mulpd %xmm7, %xmm7 + subsd %xmm3, %xmm0 + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %eax + lea exp2_tbl(%rip), %r8 + movapd (%r8,%rax), %xmm3 + movapd cev(%rip), %xmm6 + mulpd %xmm7, %xmm1 + addpd %xmm1, %xmm2 + pshufd $238, %xmm2, %xmm1 + mulsd %xmm7, %xmm2 + addsd %xmm1, %xmm2 + addsd %xmm4, %xmm2 + movlpd 32+cev(%rip), %xmm4 + movd %edx, %xmm1 + subl $130944, %edx + negl %edx + sarl $7, %edx + addl $2, %edx + movl %edx, %eax + andl $32, %eax + addl %eax, %edx + xorpd %xmm7, %xmm7 + movl $16256, %eax + pinsrw $3, %eax, %xmm7 + mulsd 16(%rsp), %xmm2 + mulsd %xmm7, %xmm0 + psllq $45, %xmm1 + pshufd $68, %xmm1, %xmm1 + movapd 16+cev(%rip), %xmm7 + addsd %xmm2, %xmm5 + mulpd %xmm1, %xmm3 + addsd %xmm5, %xmm0 + unpcklpd %xmm0, %xmm0 + mulpd %xmm0, %xmm6 + mulsd %xmm0, %xmm4 + mulpd %xmm0, %xmm0 + addpd %xmm6, %xmm7 + mulpd %xmm0, %xmm7 + mulsd %xmm3, %xmm0 + pshufd $238, %xmm7, %xmm6 + mulsd %xmm7, %xmm0 + pshufd $238, %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm4 + movd %ecx, %xmm7 + psllq $45, %xmm7 + movd %edx, %xmm2 + pcmpeqd %xmm1, %xmm1 + psllq %xmm2, %xmm1 + addsd %xmm5, %xmm0 + addsd %xmm6, %xmm0 + andpd %xmm3, %xmm1 + addsd %xmm4, %xmm0 + xorpd %xmm6, %xmm6 + pcmpeqd %xmm4, %xmm4 + psllq %xmm2, %xmm4 + subsd %xmm1, %xmm3 + movq %xmm1, %xmm2 + addsd %xmm0, %xmm1 + andpd %xmm4, %xmm1 + pinsrw $3, %edi, %xmm6 + subsd %xmm1, %xmm2 + addsd %xmm2, %xmm0 + addsd %xmm3, %xmm0 + cmpl $0, %esi + jge .L_2TAG_PACKET_38.0.2 + mulsd %xmm7, %xmm0 + mulsd %xmm7, %xmm1 + addsd %xmm1, %xmm0 + mulsd %xmm0, %xmm6 + addsd %xmm6, %xmm0 + pextrw $3, %xmm0, %eax + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_33.0.2 + cmpl $0, %eax + je .L_2TAG_PACKET_34.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_38.0.2: + addsd %xmm1, %xmm0 + mulsd %xmm7, %xmm0 + mulsd %xmm0, %xmm6 + addsd %xmm6, %xmm0 + pextrw $3, %xmm0, %eax + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_33.0.2 + cmpl $0, %eax + je .L_2TAG_PACKET_39.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_39.0.2: + xorpd %xmm2, %xmm2 + movl $1, %eax + movd %eax, %xmm2 + mulsd %xmm2, %xmm2 + jmp .L_2TAG_PACKET_34.0.2 +.L_2TAG_PACKET_16.0.2: + movlpd EMIN(%rip), %xmm0 + movd %ecx, %xmm1 + mulsd %xmm0, %xmm0 + psllq $45, %xmm1 + orpd %xmm1, %xmm0 + jmp .L_2TAG_PACKET_34.0.2 +.L_2TAG_PACKET_36.0.2: + xorpd %xmm1, %xmm1 + movl $32751, %eax + pinsrw $3, %eax, %xmm1 + mulsd %xmm1, %xmm1 + cmpl $0, %ecx + je .L_2TAG_PACKET_40.0.2 + movlpd NEG_INF(%rip), %xmm0 + jmp .L_2TAG_PACKET_33.0.2 +.L_2TAG_PACKET_40.0.2: + movlpd INF(%rip), %xmm0 + jmp .L_2TAG_PACKET_33.0.2 +.L_2TAG_PACKET_41.0.2: + movlpd 8(%rsp), %xmm4 + pextrw $3, %xmm4, %edx + andl $32752, %edx + subl $16368, %edx + pextrw $3, %xmm1, %eax + xorl %edx, %eax + andl $32768, %eax + cmpl $0, %eax + jne .L_2TAG_PACKET_16.0.2 + jmp .L_2TAG_PACKET_36.0.2 +.L_2TAG_PACKET_4.0.2: + pshufd $68, %xmm1, %xmm4 + mulpd %xmm6, %xmm4 + pextrw $3, %xmm4, %eax + andl $32752, %eax + movl $16544, %edx + subl %eax, %edx + subl $15472, %eax + orl %eax, %edx + cmpl $-2147483648, %edx + jb .L_2TAG_PACKET_5.0.2 + cmpl $-2147483648, %eax + jb .L_2TAG_PACKET_41.0.2 + orl $130944, %ecx + movd %ecx, %xmm0 + psllq $45, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_20.0.2: + movq %xmm0, 24(%rsp) +..B1.3: + movq 24(%rsp), %xmm0 +.L_2TAG_PACKET_42.0.2: +..B1.5: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type pow,@function + .size pow,.-pow + .data +# -- End pow + .section .rodata, "a" + .align 16 + .align 16 +SIGMASK: + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 1048575 + .type SIGMASK,@object + .size SIGMASK,16 + .align 16 +ONEMASK: + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .type ONEMASK,@object + .size ONEMASK,16 + .align 16 +log2_t1: + .long 0 + .long 0 + .long 0 + .long 0 + .long 1641152512 + .long 1065811444 + .long 1188689655 + .long 1027383036 + .long 830078976 + .long 1066853925 + .long 1683363035 + .long 1027948302 + .long 2542927872 + .long 1067522658 + .long 3621009110 + .long 1028493916 + .long 2686386176 + .long 1067891457 + .long 1949948784 + .long 1027381598 + .long 1667006464 + .long 1068256947 + .long 3184186889 + .long 1028293010 + .long 2150858752 + .long 1068558987 + .long 2486115301 + .long 1028528023 + .long 1655242752 + .long 1068739056 + .long 773151300 + .long 1026560495 + .long 1341652992 + .long 1068918120 + .long 2376679343 + .long 1026589938 + .long 861732864 + .long 1069095356 + .long 3976461951 + .long 1025794178 + .long 3619700736 + .long 1069270713 + .long 1113925208 + .long 1027979240 + .long 3789324288 + .long 1069445746 + .long 590586460 + .long 1028271785 + .long 2182004736 + .long 1069583575 + .long 297009670 + .long 1026900933 + .long 976470016 + .long 1069669519 + .long 2876077132 + .long 1027955084 + .long 665796608 + .long 1069755258 + .long 4251263665 + .long 1023912865 + .long 1282670592 + .long 1069839958 + .long 614174576 + .long 1028506527 + .long 1687183360 + .long 1069924424 + .long 2120169064 + .long 1026082260 + .long 4017643520 + .long 1070008228 + .long 1495131896 + .long 1028622058 + .long 4207116288 + .long 1070091353 + .long 1370573431 + .long 1027824851 + .long 1789706240 + .long 1070173781 + .long 3512135184 + .long 1026825352 + .long 53207040 + .long 1070255920 + .long 3737096549 + .long 1026438963 + .long 330194944 + .long 1070337330 + .long 2978734829 + .long 1028330940 + .long 3604373504 + .long 1070418425 + .long 3265342761 + .long 1026602327 + .long 2318204928 + .long 1070498761 + .long 3507296498 + .long 1027877621 + .long 3818315776 + .long 1070578756 + .long 677794871 + .long 1028109305 + .long 154591232 + .long 1070627028 + .long 135420162 + .long 1027142134 + .long 632459264 + .long 1070666446 + .long 256228069 + .long 1027376412 + .long 2011426816 + .long 1070705675 + .long 184843939 + .long 1027577616 + .long 2429726720 + .long 1070744485 + .long 3907638365 + .long 1027382133 + .long 2912112640 + .long 1070783319 + .long 596296254 + .long 1022964981 + .long 3197370368 + .long 1070821720 + .long 1122235614 + .long 1028265681 + .long 1147121664 + .long 1070859908 + .long 1274805357 + .long 1028037537 + .long 2702757888 + .long 1070897876 + .long 1929563301 + .long 1027984695 + .long 3792781312 + .long 1070935387 + .long 260587083 + .long 1027244900 + .long 1736605696 + .long 1070972899 + .long 1038777690 + .long 1028224348 + .long 2490597376 + .long 1071010174 + .long 574252996 + .long 1028557352 + .long 2465140736 + .long 1071047207 + .long 243175481 + .long 1026641700 + .long 2144403456 + .long 1071083992 + .long 835940059 + .long 1025870511 + .long 1797877760 + .long 1071120523 + .long 2362104182 + .long 1024853432 + .long 1487233024 + .long 1071156794 + .long 1462661599 + .long 1025546239 + .long 2657701888 + .long 1071193041 + .long 3841377895 + .long 1028504382 + .long 2881359872 + .long 1071229019 + .long 174174934 + .long 1028491418 + .long 1607143424 + .long 1071264722 + .long 3643575766 + .long 1028610165 + .long 2395561984 + .long 1071300143 + .long 2430782595 + .long 1027372849 + .long 658427904 + .long 1071335525 + .long 161357664 + .long 1028306250 + .long 242749440 + .long 1071370366 + .long 470667040 + .long 1025936066 + .long 3127775232 + .long 1071405408 + .long 2529919486 + .long 1027847357 + .long 2341548032 + .long 1071440150 + .long 89987554 + .long 1026534819 + .long 539168768 + .long 1071474585 + .long 2531816708 + .long 1025043792 + .long 234864640 + .long 1071508706 + .long 753765034 + .long 1027859052 + .long 2905993216 + .long 1071542763 + .long 3767440865 + .long 1023481353 + .long 3544465408 + .long 1071576755 + .long 756421882 + .long 1027650395 + .long 2658430976 + .long 1071610420 + .long 2178519328 + .long 1028288112 + .long 2660024320 + .long 1071644012 + .long 780560797 + .long 1023043397 + .long 2121920512 + .long 1071660969 + .long 3880750062 + .long 1025990162 + .long 2371102720 + .long 1071677556 + .long 2026769115 + .long 1027312699 + .long 1355743232 + .long 1071694102 + .long 3943781029 + .long 1028003666 + .long 649166848 + .long 1071710472 + .long 2315768408 + .long 1028563913 + .long 3712673792 + .long 1071726796 + .long 427741889 + .long 1025493722 + .long 1031030784 + .long 1071743075 + .long 132151873 + .long 1025660183 + .long 1854838784 + .long 1071759170 + .long 1812291413 + .long 1027042047 + .long 1572052992 + .long 1071775215 + .long 2231490673 + .long 1027883742 + .long 3357544448 + .long 1071791208 + .long 2435425658 + .long 1025969268 + .long 2690285568 + .long 1071807011 + .long 816977062 + .long 1028436202 + .long 473251840 + .long 3218771869 + .long 1330616403 + .long 3175482613 + .long 2934157312 + .long 3218740486 + .long 3685911680 + .long 3175415699 + .long 2326081536 + .long 3218709220 + .long 4062709 + .long 3171839703 + .long 1474240512 + .long 3218678073 + .long 3223011199 + .long 3174963306 + .long 2315530240 + .long 3218647330 + .long 3482179715 + .long 3175726112 + .long 3209805824 + .long 3218616430 + .long 1850213782 + .long 3175467046 + .long 92246016 + .long 3218585658 + .long 2672047941 + .long 3174429943 + .long 939302912 + .long 3218555302 + .long 2683312141 + .long 3175097844 + .long 3886694400 + .long 3218525081 + .long 3584491562 + .long 3175164762 + .long 3897806848 + .long 3218494709 + .long 2353689255 + .long 3175401216 + .long 2446540800 + .long 3218464767 + .long 3549477525 + .long 3175044174 + .long 863473664 + .long 3218434969 + .long 834332530 + .long 3174636992 + .long 1568866304 + .long 3218405023 + .long 3528175174 + .long 3174626157 + .long 558092288 + .long 3218375520 + .long 2586999089 + .long 3168836697 + .long 2316124160 + .long 3218346169 + .long 686294058 + .long 3172297276 + .long 3825598464 + .long 3218316675 + .long 1136723030 + .long 3175382806 + .long 4172640256 + .long 3218287637 + .long 3760034353 + .long 3171774178 + .long 143781888 + .long 3218258460 + .long 1815979570 + .long 3174536455 + .long 2912956416 + .long 3218229746 + .long 4273313359 + .long 3173677065 + .long 1821376512 + .long 3218200896 + .long 1051181106 + .long 3175433943 + .long 3545214976 + .long 3218172213 + .long 881689764 + .long 3173077446 + .long 977260544 + .long 3218144009 + .long 607141 + .long 3173756076 + .long 2363125760 + .long 3218115672 + .long 1333321633 + .long 3175335724 + .long 2364801024 + .long 3218087202 + .long 3356747073 + .long 3174852978 + .long 2121375744 + .long 3218038698 + .long 549802689 + .long 3174897014 + .long 155041792 + .long 3217983102 + .long 4093639872 + .long 3174461350 + .long 4268572672 + .long 3217927248 + .long 3146719241 + .long 3173737604 + .long 3896410112 + .long 3217871768 + .long 3834824761 + .long 3171284429 + .long 492560384 + .long 3217816668 + .long 239252792 + .long 3173483664 + .long 4219723776 + .long 3217761952 + .long 3911150007 + .long 3175766937 + .long 1522245632 + .long 3217706989 + .long 2153956895 + .long 3175454574 + .long 3796140032 + .long 3217653061 + .long 1733676290 + .long 3175095395 + .long 155754496 + .long 3217598893 + .long 1693604437 + .long 3175909818 + .long 2753691648 + .long 3217544480 + .long 3490227517 + .long 3173083716 + .long 3246325760 + .long 3217491126 + .long 1834407662 + .long 3175168640 + .long 2629189632 + .long 3217437536 + .long 394182940 + .long 3174297893 + .long 4285202432 + .long 3217384365 + .long 127148739 + .long 3175942199 + .long 2197757952 + .long 3217331621 + .long 326147828 + .long 3175005587 + .long 623484928 + .long 3217278646 + .long 2190917468 + .long 3175273136 + .long 1792204800 + .long 3217226104 + .long 3259512355 + .long 3174781320 + .long 41181184 + .long 3217174003 + .long 3260046653 + .long 3174058211 + .long 1413185536 + .long 3217121676 + .long 2746620881 + .long 3175463126 + .long 2720399360 + .long 3217069797 + .long 590176758 + .long 3175866008 + .long 1549172736 + .long 3217005579 + .long 3081069142 + .long 3175953539 + .long 2465087488 + .long 3216902292 + .long 4241850246 + .long 3175110025 + .long 3847749632 + .long 3216799930 + .long 59228567 + .long 3174380829 + .long 4210442240 + .long 3216698507 + .long 2884243012 + .long 3174896587 + .long 1231667200 + .long 3216596658 + .long 2996426567 + .long 3174508538 + .long 1101037568 + .long 3216495763 + .long 3170347605 + .long 3176066808 + .long 2861760512 + .long 3216395836 + .long 52313802 + .long 3174148818 + .long 3538583552 + .long 3216295495 + .long 291262391 + .long 3169534916 + .long 2493661184 + .long 3216196139 + .long 979886872 + .long 3175226185 + .long 3478798336 + .long 3216096373 + .long 329155479 + .long 3175972274 + .long 4175200256 + .long 3215997608 + .long 3920581672 + .long 3172282657 + .long 4103045120 + .long 3215814286 + .long 1366711740 + .long 3174574396 + .long 3613917184 + .long 3215617982 + .long 3682391844 + .long 3173719142 + .long 3246555136 + .long 3215423741 + .long 4071576370 + .long 3174315914 + .long 575995904 + .long 3215228718 + .long 2479189453 + .long 3173663302 + .long 2771812352 + .long 3215032905 + .long 1608471371 + .long 3175357197 + .long 3995074560 + .long 3214744373 + .long 766833229 + .long 3175292855 + .long 830078976 + .long 3214361213 + .long 1258533011 + .long 3175547121 + .long 219152384 + .long 3213976530 + .long 1716511551 + .long 3175540921 + .long 1290797056 + .long 3213306911 + .long 1477436787 + .long 3173730612 + .long 1836580864 + .long 3212249540 + .long 1456335140 + .long 3175441338 + .long 0 + .long 0 + .long 0 + .long 0 + .type log2_t1,@object + .size log2_t1,2064 + .align 16 +log2_t2: + .long 0 + .long 0 + .long 0 + .long 0 + .long 2088763392 + .long 1059147817 + .long 4130365781 + .long 1025575177 + .long 3758096384 + .long 1060385579 + .long 3761435677 + .long 1024020876 + .long 1623195648 + .long 1061142175 + .long 1460419383 + .long 1028311484 + .long 2740977664 + .long 1061528887 + .long 1629990790 + .long 1027810560 + .long 3418357760 + .long 1061907277 + .long 3164482262 + .long 1027367455 + .long 372244480 + .long 1062246601 + .long 749537322 + .long 1027570412 + .long 1678770176 + .long 1062435842 + .long 1420381118 + .long 1028382503 + .long 3506438144 + .long 1062625106 + .long 2539787500 + .long 1028059273 + .long 1584398336 + .long 1062814394 + .long 4277851274 + .long 1025918452 + .long 230686720 + .long 1063003705 + .long 2279601279 + .long 1027165899 + .long 3765436416 + .long 1063193038 + .long 1648733663 + .long 1027693874 + .long 3958898688 + .long 1063319229 + .long 3585544732 + .long 1028203366 + .long 4208984064 + .long 1063413919 + .long 395326031 + .long 1026777160 + .long 2644508672 + .long 1063508621 + .long 3080139365 + .long 1026686561 + .long 3572498432 + .long 1063603334 + .long 3213016626 + .long 1028477442 + .long 2711093248 + .long 1063698059 + .long 439612993 + .long 1027235725 + .long 71303168 + .long 1063792796 + .long 847494235 + .long 1028613481 + .long 4256169984 + .long 1063887543 + .long 1915821278 + .long 1028326816 + .long 2392850432 + .long 1063982303 + .long 2225307780 + .long 1026401230 + .long 3082813440 + .long 1064077074 + .long 3438929084 + .long 1027103624 + .long 2043674624 + .long 1064171857 + .long 2082386238 + .long 1027684439 + .long 3582459904 + .long 1064266651 + .long 1897021122 + .long 1028567773 + .long 3855876096 + .long 1064333048 + .long 1828790394 + .long 1028459899 + .long 2926837760 + .long 1064380457 + .long 4113329424 + .long 1027931731 + .long 1157627904 + .long 1064427872 + .long 1702728849 + .long 1027539743 + .long 2849243136 + .long 1064475292 + .long 981368224 + .long 1027987814 + .long 3713007616 + .long 1064522718 + .long 3588215231 + .long 1027706406 + .long 3754950656 + .long 1064570150 + .long 2599429676 + .long 1027136642 + .long 2981101568 + .long 1064617588 + .long 3033621989 + .long 1027640910 + .long 1397751808 + .long 1064665032 + .long 1866428510 + .long 1026593332 + .long 3305635840 + .long 1064712481 + .long 3898020334 + .long 1028538281 + .long 121372672 + .long 1064759937 + .long 2418247211 + .long 1028479303 + .long 440926208 + .long 1064807398 + .long 2151876465 + .long 1027654537 + .long 4270325760 + .long 1064854864 + .long 638259760 + .long 1025479387 + .long 3025666048 + .long 1064902337 + .long 3300197061 + .long 1024786488 + .long 1007943680 + .long 1064949816 + .long 2066224929 + .long 1028181309 + .long 2518679552 + .long 1064997300 + .long 1194091706 + .long 1027784991 + .long 3268673536 + .long 1065044790 + .long 3941768658 + .long 1028458821 + .long 3264479232 + .long 1065092286 + .long 2285092471 + .long 1025632049 + .long 2511601664 + .long 1065139788 + .long 274659519 + .long 1028009304 + .long 1016594432 + .long 1065187296 + .long 2660244528 + .long 1028621601 + .long 3080716288 + .long 1065234809 + .long 2948866684 + .long 1027363323 + .long 119799808 + .long 1065282329 + .long 2305553338 + .long 1027606374 + .long 730071040 + .long 1065329854 + .long 1656362908 + .long 1027822979 + .long 2458910720 + .long 1065365300 + .long 1598786858 + .long 1026178251 + .long 2587623424 + .long 1065383126 + .long 2378958549 + .long 1028197240 + .long 839778304 + .long 1065406897 + .long 1456429431 + .long 1026244901 + .long 3036413952 + .long 1065430670 + .long 1932205944 + .long 1027981879 + .long 590872576 + .long 1065454447 + .long 4023608769 + .long 1027958429 + .long 2096103424 + .long 1065478226 + .long 3732079947 + .long 1027967416 + .long 3260284928 + .long 1065502008 + .long 336608668 + .long 1026095801 + .long 4086300672 + .long 1065525793 + .long 136967562 + .long 1028120471 + .long 282460160 + .long 1065549582 + .long 3624814115 + .long 1028328839 + .long 441843712 + .long 1065573373 + .long 3566723455 + .long 1022759747 + .long 272236544 + .long 1065597167 + .long 4015454571 + .long 1028257780 + .long 4072013824 + .long 1065620963 + .long 4162319098 + .long 1028151765 + .long 3254255616 + .long 1065644763 + .long 3888083220 + .long 1027286836 + .long 2116943872 + .long 1065668566 + .long 1025436577 + .long 1027036048 + .long 663224320 + .long 1065692372 + .long 2834872887 + .long 1025744984 + .long 3191078912 + .long 1065716180 + .long 1809631811 + .long 1027064556 + .long 1113718784 + .long 1065739992 + .long 1168962244 + .long 1027829789 + .long 3024224256 + .long 1065763806 + .long 2016586535 + .long 1027435289 + .long 335675392 + .long 1065787624 + .long 1431812300 + .long 1027676827 + .long 1836580864 + .long 3212249540 + .long 1456335140 + .long 3175441338 + .long 2446065664 + .long 3212225994 + .long 1539749707 + .long 3174539680 + .long 1201405952 + .long 3212202447 + .long 1821058149 + .long 3175488506 + .long 2397044736 + .long 3212178898 + .long 3567155664 + .long 3175677071 + .long 1737228288 + .long 3212155348 + .long 3350760572 + .long 3175687587 + .long 3516137472 + .long 3212131796 + .long 54506174 + .long 3175826950 + .long 3438280704 + .long 3212108243 + .long 1906648915 + .long 3172999433 + .long 1502347264 + .long 3212084689 + .long 2084064274 + .long 3175617184 + .long 2003042304 + .long 3212061133 + .long 2608241578 + .long 3175876387 + .long 644612096 + .long 3212037576 + .long 1051263361 + .long 3175383946 + .long 1721237504 + .long 3212014017 + .long 3354885735 + .long 3173549367 + .long 936902656 + .long 3211990457 + .long 87463564 + .long 3175445923 + .long 2586312704 + .long 3211966895 + .long 506361461 + .long 3173795297 + .long 2373189632 + .long 3211943332 + .long 3280686310 + .long 3176104310 + .long 297533440 + .long 3211919768 + .long 3617245347 + .long 3172626443 + .long 652738560 + .long 3211896202 + .long 579141699 + .long 3175545653 + .long 3438542848 + .long 3211872634 + .long 3721652079 + .long 3176073447 + .long 64225280 + .long 3211849066 + .long 4212107268 + .long 3176133288 + .long 3413901312 + .long 3211825495 + .long 2932346116 + .long 3176017856 + .long 601882624 + .long 3211801924 + .long 3484155727 + .long 3176018735 + .long 435159040 + .long 3211768414 + .long 1225556500 + .long 3173101246 + .long 224395264 + .long 3211721265 + .long 1151472644 + .long 3175433137 + .long 570949632 + .long 3211674113 + .long 169440649 + .long 3175424350 + .long 1473249280 + .long 3211626958 + .long 767490525 + .long 3174092077 + .long 2929197056 + .long 3211579800 + .long 3954462340 + .long 3175313650 + .long 642777088 + .long 3211532640 + .long 293664658 + .long 3175782850 + .long 3202875392 + .long 3211485476 + .long 2810753961 + .long 3172053070 + .long 2016935936 + .long 3211438310 + .long 68049842 + .long 3174903053 + .long 1379401728 + .long 3211391141 + .long 2125367929 + .long 3172998826 + .long 1288175616 + .long 3211343969 + .long 2899939163 + .long 3173729914 + .long 1741684736 + .long 3211296794 + .long 3555933291 + .long 3175823424 + .long 2739404800 + .long 3211249616 + .long 3666032509 + .long 3173379218 + .long 4278714368 + .long 3211202435 + .long 836003693 + .long 3174279974 + .long 2063597568 + .long 3211155252 + .long 1236704766 + .long 3174628627 + .long 387448832 + .long 3211108066 + .long 2756688253 + .long 3175196858 + .long 3543662592 + .long 3211060876 + .long 3160170483 + .long 3175973516 + .long 2941255680 + .long 3211013684 + .long 2830353174 + .long 3175364122 + .long 2873098240 + .long 3210966489 + .long 4144291481 + .long 3175737650 + .long 3338141696 + .long 3210919291 + .long 3260331491 + .long 3175267671 + .long 39845888 + .long 3210872091 + .long 1922313952 + .long 3172367859 + .long 1566048256 + .long 3210824887 + .long 3310171853 + .long 3174855326 + .long 3620732928 + .long 3210777680 + .long 3325808113 + .long 3175681701 + .long 3815768064 + .long 3210721230 + .long 3926816425 + .long 3173875772 + .long 1439694848 + .long 3210626806 + .long 2528441557 + .long 3175954827 + .long 112197632 + .long 3210532376 + .long 2735049661 + .long 3176047308 + .long 4125097984 + .long 3210437939 + .long 2814107016 + .long 3175038571 + .long 589299712 + .long 3210343498 + .long 84420116 + .long 3175362012 + .long 2387607552 + .long 3210249050 + .long 886636141 + .long 3175106949 + .long 926941184 + .long 3210154597 + .long 4249864732 + .long 3174015648 + .long 498073600 + .long 3210060138 + .long 2571744411 + .long 3176070508 + .long 1099956224 + .long 3209965673 + .long 191977345 + .long 3175708074 + .long 2728394752 + .long 3209871202 + .long 1836848871 + .long 3175824104 + .long 1086324736 + .long 3209776726 + .long 3259464767 + .long 3174065342 + .long 929038336 + .long 3209673352 + .long 885961784 + .long 3173053400 + .long 1719664640 + .long 3209484376 + .long 3633085090 + .long 3175298882 + .long 245366784 + .long 3209295389 + .long 622998640 + .long 3175676299 + .long 794820608 + .long 3209106390 + .long 183843539 + .long 3175700419 + .long 3361734656 + .long 3208917379 + .long 319142191 + .long 3175621005 + .long 3644850176 + .long 3208728357 + .long 4064393657 + .long 3175686713 + .long 3279945728 + .long 3208436088 + .long 921315957 + .long 3167773730 + .long 3263168512 + .long 3208057998 + .long 1191737347 + .long 3175145444 + .long 2940207104 + .long 3207679885 + .long 676306098 + .long 3174972367 + .long 293601280 + .long 3207009515 + .long 3713153157 + .long 3176043736 + .long 989855744 + .long 3205960985 + .long 847981310 + .long 3172455261 + .long 0 + .long 0 + .long 0 + .long 0 + .type log2_t2,@object + .size log2_t2,2064 + .align 16 +log2_t3: + .long 0 + .long 0 + .long 0 + .long 0 + .long 3221225472 + .long 1052246016 + .long 10217817 + .long 1028072176 + .long 2684354560 + .long 1053294593 + .long 1823923246 + .long 1027991127 + .long 2684354560 + .long 1053884417 + .long 2844515178 + .long 1028130658 + .long 0 + .long 1054277635 + .long 1230948249 + .long 1025710668 + .long 2952790016 + .long 1054670852 + .long 1764281763 + .long 1028204164 + .long 1744830464 + .long 1054965763 + .long 2682119783 + .long 1027942224 + .long 1879048192 + .long 1055129604 + .long 690677466 + .long 1027931089 + .long 3623878656 + .long 1055326213 + .long 2988899587 + .long 1028585756 + .long 2013265920 + .long 1055522823 + .long 2646883118 + .long 1027643276 + .long 1207959552 + .long 1055719433 + .long 3152640337 + .long 1026797173 + .long 4026531840 + .long 1055883274 + .long 2707659781 + .long 1026392505 + .long 2348810240 + .long 1055997958 + .long 2715649106 + .long 1027422884 + .long 3087007744 + .long 1056096263 + .long 285997833 + .long 1028488126 + .long 0 + .long 1056194569 + .long 2595623046 + .long 1027865547 + .long 1610612736 + .long 1056292874 + .long 3757543522 + .long 1027743124 + .long 2550136832 + .long 1056374795 + .long 1685325986 + .long 1027848425 + .long 603979776 + .long 1056473101 + .long 971111892 + .long 1028643022 + .long 3422552064 + .long 1056571406 + .long 1310768194 + .long 1027840696 + .long 2348810240 + .long 1056669712 + .long 647785154 + .long 1027472771 + .long 335544320 + .long 1056751634 + .long 3447719136 + .long 1027384110 + .long 0 + .long 1056849940 + .long 2473353221 + .long 1028109426 + .long 134217728 + .long 1056948246 + .long 3908013601 + .long 1026650988 + .long 335544320 + .long 1057005580 + .long 3241725099 + .long 1023809487 + .long 4261412864 + .long 1057046540 + .long 3592425610 + .long 1028549905 + .long 637534208 + .long 1057095694 + .long 1951774861 + .long 1025790338 + .long 1476395008 + .long 1057144847 + .long 2386717008 + .long 1027825275 + .long 2550136832 + .long 1057194000 + .long 936867399 + .long 1026725625 + .long 3825205248 + .long 1057243153 + .long 3781996145 + .long 1026256374 + .long 33554432 + .long 1057284115 + .long 1781441569 + .long 1026554167 + .long 1677721600 + .long 1057333268 + .long 541855954 + .long 1027837629 + .long 3556769792 + .long 1057382421 + .long 3808194027 + .long 1026230743 + .long 1342177280 + .long 1057431575 + .long 1679773493 + .long 1024039205 + .long 2516582400 + .long 1057472536 + .long 4034037987 + .long 1022229492 + .long 671088640 + .long 1057521690 + .long 1732823594 + .long 1026728033 + .long 3321888768 + .long 1057570843 + .long 2629452715 + .long 1028246558 + .long 1912602624 + .long 1057619997 + .long 2171860443 + .long 1027730387 + .long 704643072 + .long 1057669151 + .long 1413946002 + .long 1027714921 + .long 2717908992 + .long 1057710112 + .long 3583986569 + .long 1027909771 + .long 1912602624 + .long 1057759266 + .long 2993702118 + .long 1024684384 + .long 1275068416 + .long 1057808420 + .long 3380540156 + .long 1028118518 + .long 872415232 + .long 1057857574 + .long 3787132338 + .long 1027925509 + .long 3556769792 + .long 1057898535 + .long 399829967 + .long 1027972484 + .long 3556769792 + .long 1057947689 + .long 99635239 + .long 1022741119 + .long 3724541952 + .long 1057996843 + .long 3258250598 + .long 1027826609 + .long 4211081216 + .long 1058029590 + .long 3506657137 + .long 1027308398 + .long 3741319168 + .long 1058050071 + .long 541288431 + .long 1027107230 + .long 4127195136 + .long 1058074648 + .long 3646427416 + .long 1027904075 + .long 335544320 + .long 1058099226 + .long 246496071 + .long 1025659624 + .long 922746880 + .long 1058123803 + .long 2177775776 + .long 1028406323 + .long 1627389952 + .long 1058148380 + .long 1181919501 + .long 1028360402 + .long 1577058304 + .long 1058168861 + .long 1426415599 + .long 1028530121 + .long 2483027968 + .long 1058193438 + .long 1417624514 + .long 1027006858 + .long 3489660928 + .long 1058218015 + .long 3323042516 + .long 1021955058 + .long 285212672 + .long 1058242593 + .long 710383729 + .long 1028457251 + .long 570425344 + .long 1058263074 + .long 179923617 + .long 1028480130 + .long 1879048192 + .long 1058287651 + .long 1513572732 + .long 1026553379 + .long 3271557120 + .long 1058312228 + .long 3860576606 + .long 1028277345 + .long 486539264 + .long 1058336806 + .long 742310640 + .long 1027879207 + .long 1107296256 + .long 1058357287 + .long 2654634259 + .long 1027755563 + .long 2801795072 + .long 1058381864 + .long 2910466432 + .long 1028276410 + .long 318767104 + .long 1058406442 + .long 4054947979 + .long 1026798334 + .long 2231369728 + .long 1058431019 + .long 878023543 + .long 1023510847 + .long 4227858432 + .long 1058455596 + .long 263450436 + .long 1028652562 + .long 989855744 + .long 1058476078 + .long 3244478756 + .long 1024589954 + .long 3187671040 + .long 1058500655 + .long 1529358695 + .long 1027496060 + .long 1207959552 + .long 1058525233 + .long 1449606828 + .long 1025374457 + .long 3607101440 + .long 1058549810 + .long 1121865491 + .long 1028651213 + .long 704643072 + .long 1058570292 + .long 76632162 + .long 1015281729 + .long 3305111552 + .long 1058594869 + .long 1705840257 + .long 1026852007 + .long 1711276032 + .long 1058619447 + .long 2189122428 + .long 1028401790 + .long 234881024 + .long 1058644025 + .long 3860440574 + .long 1027979737 + .long 1946157056 + .long 1058664506 + .long 3805699399 + .long 1027836413 + .long 654311424 + .long 1058689084 + .long 3144514508 + .long 1028333941 + .long 3774873600 + .long 1058713661 + .long 1551239808 + .long 1026867407 + .long 2701131776 + .long 1058738239 + .long 3872647589 + .long 1023700698 + .long 1711276032 + .long 1058762817 + .long 2939649020 + .long 1028642081 + .long 3858759680 + .long 1058783298 + .long 3869973501 + .long 1024259487 + .long 3070230528 + .long 1058807876 + .long 3430235573 + .long 1027394848 + .long 2399141888 + .long 1058832454 + .long 2837866956 + .long 1024798194 + .long 1811939328 + .long 1058857032 + .long 3195008471 + .long 1028558077 + .long 4278190080 + .long 1058877513 + .long 925127753 + .long 1028542902 + .long 3909091328 + .long 1058902091 + .long 3453656528 + .long 1026590044 + .long 3623878656 + .long 1058926669 + .long 2547020848 + .long 1028250625 + .long 3456106496 + .long 1058951247 + .long 3173507594 + .long 1027808713 + .long 1962934272 + .long 1058971729 + .long 624230052 + .long 1027649088 + .long 1979711488 + .long 1058996307 + .long 1896525098 + .long 1028127351 + .long 2113929216 + .long 1059020885 + .long 3776127051 + .long 1026276788 + .long 2332033024 + .long 1059045463 + .long 1850790470 + .long 1028492603 + .long 3481272320 + .long 1059065900 + .long 111238633 + .long 1028379644 + .long 2944401408 + .long 1059076141 + .long 1234093769 + .long 1028494241 + .long 3212836864 + .long 1059088430 + .long 4181043184 + .long 1026804589 + .long 3523215360 + .long 1059100719 + .long 2569064410 + .long 1028514056 + .long 3892314112 + .long 1059113008 + .long 312914348 + .long 1028228528 + .long 3523215360 + .long 1059123249 + .long 3115983504 + .long 1028199393 + .long 3992977408 + .long 1059135538 + .long 2038492604 + .long 1024861349 + .long 209715200 + .long 1059147828 + .long 152199155 + .long 1027874535 + .long 780140544 + .long 1059160117 + .long 1978960733 + .long 1027229157 + .long 578813952 + .long 1059170358 + .long 505645676 + .long 1026884061 + .long 1241513984 + .long 1059182647 + .long 514239020 + .long 1027707324 + .long 1962934272 + .long 1059194936 + .long 2032269232 + .long 1021518627 + .long 2726297600 + .long 1059207225 + .long 3497533428 + .long 1028043129 + .long 3548381184 + .long 1059219514 + .long 3658695522 + .long 1027915933 + .long 3556769792 + .long 1059229755 + .long 501547381 + .long 1028018915 + .long 184549376 + .long 1059242045 + .long 3705047602 + .long 1024687479 + .long 1149239296 + .long 1059254334 + .long 675335170 + .long 1028011771 + .long 2172649472 + .long 1059266623 + .long 2543593460 + .long 1027713249 + .long 2348810240 + .long 1059276864 + .long 2216047412 + .long 1027673535 + .long 3464495104 + .long 1059289153 + .long 712855157 + .long 1028296196 + .long 343932928 + .long 1059301443 + .long 930266665 + .long 1027043929 + .long 1568669696 + .long 1059313732 + .long 780927773 + .long 1025654091 + .long 1912602624 + .long 1059323973 + .long 3399331078 + .long 1024229490 + .long 3229614080 + .long 1059336262 + .long 3996204339 + .long 1026644611 + .long 301989888 + .long 1059348552 + .long 143359080 + .long 1028079044 + .long 1728053248 + .long 1059360841 + .long 2849827553 + .long 1027273550 + .long 3204448256 + .long 1059373130 + .long 2690987141 + .long 1026998795 + .long 3758096384 + .long 1059383371 + .long 2222711807 + .long 1027188284 + .long 1031798784 + .long 1059395661 + .long 1353013621 + .long 1028180599 + .long 2659188736 + .long 1059407950 + .long 756253115 + .long 1027136298 + .long 41943040 + .long 1059420240 + .long 532576643 + .long 1026486854 + .long 763363328 + .long 1059430481 + .long 3289135452 + .long 1026299195 + .long 2533359616 + .long 1059442770 + .long 1513734706 + .long 1027630332 + .long 67108864 + .long 1059455060 + .long 2085312894 + .long 1023872287 + .long 1937768448 + .long 1059467349 + .long 3183199319 + .long 1028270313 + .long 2826960896 + .long 1059477590 + .long 3972158195 + .long 1028082057 + .long 503316480 + .long 1059489880 + .long 264248663 + .long 1028526857 + .long 2533359616 + .long 1059502169 + .long 3362227203 + .long 1027150375 + .long 318767104 + .long 1059514459 + .long 4064547853 + .long 1024810530 + .long 268435456 + .long 3205959634 + .long 691182318 + .long 3173304996 + .long 3456106496 + .long 3205947346 + .long 2237848631 + .long 3175922029 + .long 1291845632 + .long 3205939155 + .long 2610806712 + .long 3173520353 + .long 150994944 + .long 3205926868 + .long 1392581829 + .long 3174351268 + .long 3271557120 + .long 3205914580 + .long 3292400060 + .long 3175929370 + .long 2080374784 + .long 3205902293 + .long 4178356410 + .long 3175965902 + .long 872415232 + .long 3205890006 + .long 330416743 + .long 3174570455 + .long 3925868544 + .long 3205877718 + .long 1897771058 + .long 3174145242 + .long 2650800128 + .long 3205865431 + .long 3340394865 + .long 3175328080 + .long 1358954496 + .long 3205853144 + .long 4006478009 + .long 3174644517 + .long 33554432 + .long 3205840857 + .long 2338318098 + .long 3175328560 + .long 1996488704 + .long 3205832665 + .long 908420916 + .long 3175917031 + .long 637534208 + .long 3205820378 + .long 1000116813 + .long 3175123051 + .long 3539992576 + .long 3205808090 + .long 4281444920 + .long 3175253057 + .long 2130706432 + .long 3205795803 + .long 376816689 + .long 3172256578 + .long 687865856 + .long 3205783516 + .long 196000653 + .long 3170433881 + .long 3506438144 + .long 3205771228 + .long 2744030195 + .long 3174702892 + .long 2013265920 + .long 3205758941 + .long 2211786449 + .long 3173892702 + .long 486539264 + .long 3205746654 + .long 4020273651 + .long 3175077302 + .long 2315255808 + .long 3205738462 + .long 3572678407 + .long 3175733405 + .long 754974720 + .long 3205726175 + .long 1564087220 + .long 3174977341 + .long 3456106496 + .long 3205713887 + .long 1784641315 + .long 3175256025 + .long 1845493760 + .long 3205701600 + .long 679907493 + .long 3173008683 + .long 201326592 + .long 3205689313 + .long 2119625261 + .long 3172818812 + .long 2818572288 + .long 3205677025 + .long 2101485035 + .long 3175178180 + .long 1124073472 + .long 3205664738 + .long 2832998731 + .long 3174717836 + .long 3690987520 + .long 3205652450 + .long 3610578708 + .long 3175551729 + .long 1946157056 + .long 3205640163 + .long 2398766049 + .long 3174966407 + .long 3623878656 + .long 3205631971 + .long 3995335152 + .long 3175656959 + .long 1828716544 + .long 3205619684 + .long 183250326 + .long 3175973344 + .long 16777216 + .long 3205607397 + .long 4019803825 + .long 3175116509 + .long 2466250752 + .long 3205595109 + .long 1578128721 + .long 3175183606 + .long 603979776 + .long 3205582822 + .long 112661265 + .long 3170010307 + .long 2986344448 + .long 3205570534 + .long 3756900035 + .long 3175992425 + .long 1073741824 + .long 3205558247 + .long 3996691019 + .long 3174185852 + .long 3422552064 + .long 3205545959 + .long 4247306560 + .long 3172221188 + .long 1442840576 + .long 3205533672 + .long 920037013 + .long 3174307610 + .long 2969567232 + .long 3205525480 + .long 2901018317 + .long 3175306400 + .long 956301312 + .long 3205513193 + .long 4209407270 + .long 3173953969 + .long 3204448256 + .long 3205500905 + .long 4232478211 + .long 3174316659 + .long 2248146944 + .long 3205480404 + .long 3976793802 + .long 3175786245 + .long 2348810240 + .long 3205455829 + .long 223141518 + .long 3175696845 + .long 2415919104 + .long 3205431254 + .long 2202058045 + .long 3173520944 + .long 2415919104 + .long 3205406679 + .long 780543142 + .long 3170584573 + .long 2348810240 + .long 3205382104 + .long 1379108477 + .long 3174272970 + .long 2248146944 + .long 3205357529 + .long 875461665 + .long 3170488084 + .long 704643072 + .long 3205341146 + .long 2105849568 + .long 3174271106 + .long 503316480 + .long 3205316571 + .long 1835672135 + .long 3174776330 + .long 234881024 + .long 3205291996 + .long 3252628102 + .long 3176108718 + .long 4227858432 + .long 3205267420 + .long 2720009520 + .long 3176111930 + .long 3892314112 + .long 3205242845 + .long 850238367 + .long 3174795595 + .long 3489660928 + .long 3205218270 + .long 3536085073 + .long 3174303192 + .long 3019898880 + .long 3205193695 + .long 3558909717 + .long 3175373323 + .long 2516582400 + .long 3205169120 + .long 920693007 + .long 3174667265 + .long 704643072 + .long 3205152737 + .long 4071589563 + .long 3175526566 + .long 100663296 + .long 3205128162 + .long 3392361480 + .long 3175871650 + .long 3758096384 + .long 3205103586 + .long 2972601747 + .long 3174998742 + .long 3053453312 + .long 3205079011 + .long 1605892160 + .long 3175139069 + .long 2315255808 + .long 3205054436 + .long 1553740054 + .long 3169146216 + .long 1476395008 + .long 3205029861 + .long 3751995331 + .long 3176004720 + .long 637534208 + .long 3205005286 + .long 3091908485 + .long 3174267031 + .long 4026531840 + .long 3204980710 + .long 3333214935 + .long 3172771610 + .long 3053453312 + .long 3204956135 + .long 790487160 + .long 3174501480 + .long 939524096 + .long 3204939752 + .long 1992793420 + .long 3175422045 + .long 4194304000 + .long 3204915176 + .long 3717748377 + .long 3174284044 + .long 3087007744 + .long 3204890601 + .long 105034497 + .long 3174659776 + .long 1912602624 + .long 3204866026 + .long 4120994791 + .long 3175985638 + .long 704643072 + .long 3204841451 + .long 136721814 + .long 3175923992 + .long 3758096384 + .long 3204816875 + .long 4178760049 + .long 3174289887 + .long 2449473536 + .long 3204792300 + .long 1385241146 + .long 3173295534 + .long 1073741824 + .long 3204767725 + .long 614436572 + .long 3174892815 + .long 3959422976 + .long 3204743149 + .long 3717352206 + .long 3173503234 + .long 1543503872 + .long 3204726766 + .long 2074792065 + .long 3174982293 + .long 33554432 + .long 3204702191 + .long 1160049312 + .long 3175315117 + .long 2785017856 + .long 3204677615 + .long 947382601 + .long 3173470865 + .long 1174405120 + .long 3204653040 + .long 1784674375 + .long 3173592242 + .long 3791650816 + .long 3204628464 + .long 3966380974 + .long 3175406146 + .long 2080374784 + .long 3204603889 + .long 90923019 + .long 3175186916 + .long 301989888 + .long 3204579314 + .long 2809276197 + .long 3175891468 + .long 2785017856 + .long 3204554738 + .long 2488581129 + .long 3175422649 + .long 100663296 + .long 3204538355 + .long 4207284753 + .long 3176089346 + .long 2516582400 + .long 3204513779 + .long 1763582947 + .long 3173239999 + .long 536870912 + .long 3204489204 + .long 1591642683 + .long 3175659480 + .long 2818572288 + .long 3204464628 + .long 1247815734 + .long 3175781625 + .long 1543503872 + .long 3204431850 + .long 3175237814 + .long 3174372638 + .long 1610612736 + .long 3204382699 + .long 3136020064 + .long 3174117678 + .long 1543503872 + .long 3204333548 + .long 145926225 + .long 3175399182 + .long 1409286144 + .long 3204284397 + .long 1146502365 + .long 3174956000 + .long 1140850688 + .long 3204235246 + .long 1806880589 + .long 3175568698 + .long 3825205248 + .long 3204202478 + .long 748557588 + .long 3171070759 + .long 3355443200 + .long 3204153327 + .long 3616893112 + .long 3175503309 + .long 2818572288 + .long 3204104176 + .long 3332544853 + .long 3175717064 + .long 2214592512 + .long 3204055025 + .long 59215988 + .long 3174426688 + .long 1476395008 + .long 3204005874 + .long 2509632280 + .long 3174354848 + .long 603979776 + .long 3203956723 + .long 1669980294 + .long 3175609302 + .long 3959422976 + .long 3203907571 + .long 231858041 + .long 3175323695 + .long 2885681152 + .long 3203858420 + .long 192153543 + .long 3175961815 + .long 1744830464 + .long 3203809269 + .long 507582953 + .long 3175426507 + .long 3758096384 + .long 3203776501 + .long 1672537466 + .long 3176048847 + .long 2483027968 + .long 3203727350 + .long 3522791035 + .long 3172632365 + .long 1006632960 + .long 3203678199 + .long 2149811783 + .long 3175485759 + .long 3758096384 + .long 3203629047 + .long 1999469990 + .long 3175541209 + .long 2147483648 + .long 3203579896 + .long 2226222860 + .long 3173477057 + .long 402653184 + .long 3203530745 + .long 4286112849 + .long 3172408839 + .long 2818572288 + .long 3203481593 + .long 713604598 + .long 3174828560 + .long 872415232 + .long 3203432442 + .long 2347361448 + .long 3173841417 + .long 1879048192 + .long 3203366901 + .long 1438571646 + .long 3174899801 + .long 402653184 + .long 3203301366 + .long 3419522004 + .long 3175593882 + .long 268435456 + .long 3203203063 + .long 4288382338 + .long 3174545520 + .long 4160749568 + .long 3203104759 + .long 272162157 + .long 3174838779 + .long 3489660928 + .long 3203006456 + .long 2794103335 + .long 3176033766 + .long 2684354560 + .long 3202908153 + .long 2632246937 + .long 3175930608 + .long 1744830464 + .long 3202809850 + .long 1508829515 + .long 3174219824 + .long 536870912 + .long 3202711547 + .long 3295780812 + .long 3172985552 + .long 3355443200 + .long 3202613243 + .long 1122596525 + .long 3174655334 + .long 805306368 + .long 3202547708 + .long 2645694757 + .long 3175532338 + .long 3355443200 + .long 3202449404 + .long 1159177678 + .long 3174604459 + .long 2684354560 + .long 3202351098 + .long 1034248407 + .long 3175079694 + .long 2684354560 + .long 3202154491 + .long 1158806475 + .long 3171580989 + .long 2147483648 + .long 3201957884 + .long 1293148021 + .long 3171385480 + .long 1073741824 + .long 3201761277 + .long 3828985497 + .long 3175006371 + .long 4026531840 + .long 3201564669 + .long 3153776129 + .long 3174482233 + .long 2147483648 + .long 3201368062 + .long 171710315 + .long 3175446758 + .long 0 + .long 3201040382 + .long 1900250098 + .long 3174781524 + .long 2147483648 + .long 3200778238 + .long 2246244539 + .long 3175572705 + .long 536870912 + .long 3200385023 + .long 3628536486 + .long 3175901120 + .long 1073741824 + .long 3199729663 + .long 231762015 + .long 3175023909 + .long 2147483648 + .long 3198681087 + .long 1401818636 + .long 3175134547 + .long 0 + .long 0 + .long 0 + .long 0 + .type log2_t3,@object + .size log2_t3,4112 + .space 496, 0x00 # pad + .align 16 +clv: + .long 1655945238 + .long 1069842388 + .long 2523158510 + .long 1048167334 + .long 713798755 + .long 3216330823 + .long 1181303047 + .long 3218484803 + .type clv,@object + .size clv,32 + .align 16 +exp2_tbl: + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 2851812149 + .long 1072698941 + .long 2595802551 + .long 1016815913 + .long 1048019041 + .long 1072704666 + .long 1398474845 + .long 3161559171 + .long 3899555717 + .long 1072710421 + .long 427280750 + .long 3163595548 + .long 3541402996 + .long 1072716208 + .long 2759177317 + .long 1015903202 + .long 702412510 + .long 1072722027 + .long 3803266086 + .long 3163328991 + .long 410360776 + .long 1072727877 + .long 1269990655 + .long 1013024446 + .long 3402036099 + .long 1072733758 + .long 405889333 + .long 1016154232 + .long 1828292879 + .long 1072739672 + .long 1255956746 + .long 1016636974 + .long 728909815 + .long 1072745618 + .long 383930225 + .long 1016078044 + .long 852742562 + .long 1072751596 + .long 667253586 + .long 1010842135 + .long 2952712987 + .long 1072757606 + .long 3293494651 + .long 3161168877 + .long 3490863953 + .long 1072763649 + .long 960797497 + .long 3163997456 + .long 3228316108 + .long 1072769725 + .long 3010241991 + .long 3159471380 + .long 2930322912 + .long 1072775834 + .long 2599499422 + .long 3163762623 + .long 3366293073 + .long 1072781976 + .long 3119426313 + .long 1015169130 + .long 1014845819 + .long 1072788152 + .long 3117910645 + .long 3162607681 + .long 948735466 + .long 1072794361 + .long 3516338027 + .long 3163623459 + .long 3949972341 + .long 1072800603 + .long 2068408548 + .long 1015962444 + .long 2214878420 + .long 1072806880 + .long 892270087 + .long 3164164998 + .long 828946858 + .long 1072813191 + .long 10642492 + .long 1016988014 + .long 586995997 + .long 1072819536 + .long 41662347 + .long 3163676568 + .long 2288159958 + .long 1072825915 + .long 2169144468 + .long 1015924597 + .long 2440944790 + .long 1072832329 + .long 2492769773 + .long 1015196030 + .long 1853186616 + .long 1072838778 + .long 3066496370 + .long 1016705150 + .long 1337108031 + .long 1072845262 + .long 3203724452 + .long 1015726421 + .long 1709341917 + .long 1072851781 + .long 2571168217 + .long 1015201075 + .long 3790955393 + .long 1072858335 + .long 2352942461 + .long 3164228666 + .long 4112506593 + .long 1072864925 + .long 2947355221 + .long 1015419624 + .long 3504003472 + .long 1072871551 + .long 3594001059 + .long 3158379228 + .long 2799960843 + .long 1072878213 + .long 1423655380 + .long 1016070727 + .long 2839424854 + .long 1072884911 + .long 1171596163 + .long 1014090255 + .long 171030293 + .long 1072891646 + .long 3526460132 + .long 1015477354 + .long 4232894513 + .long 1072898416 + .long 2383938684 + .long 1015717095 + .long 2992903935 + .long 1072905224 + .long 2218154405 + .long 1016276769 + .long 1603444721 + .long 1072912069 + .long 1548633640 + .long 3163249902 + .long 926591435 + .long 1072918951 + .long 3208833761 + .long 3163962090 + .long 1829099622 + .long 1072925870 + .long 1016661180 + .long 3164509581 + .long 887463927 + .long 1072932827 + .long 3596744162 + .long 3161842742 + .long 3272845541 + .long 1072939821 + .long 928852419 + .long 3164536824 + .long 1276261410 + .long 1072946854 + .long 300981947 + .long 1015732745 + .long 78413852 + .long 1072953925 + .long 4183226867 + .long 3164065827 + .long 569847338 + .long 1072961034 + .long 472945272 + .long 3160339305 + .long 3645941911 + .long 1072968181 + .long 3814685080 + .long 3162621917 + .long 1617004845 + .long 1072975368 + .long 82804943 + .long 1011391354 + .long 3978100823 + .long 1072982593 + .long 3513027190 + .long 1016894539 + .long 3049340112 + .long 1072989858 + .long 3062915824 + .long 1014219171 + .long 4040676318 + .long 1072997162 + .long 4090609238 + .long 1016712034 + .long 3577096743 + .long 1073004506 + .long 2951496418 + .long 1014842263 + .long 2583551245 + .long 1073011890 + .long 3161094195 + .long 1016655067 + .long 1990012071 + .long 1073019314 + .long 3529070563 + .long 3163861769 + .long 2731501122 + .long 1073026778 + .long 1774031854 + .long 3163518597 + .long 1453150082 + .long 1073034283 + .long 498154668 + .long 3162536638 + .long 3395129871 + .long 1073041828 + .long 4025345434 + .long 3163383964 + .long 917841882 + .long 1073049415 + .long 18715564 + .long 1016707884 + .long 3566716925 + .long 1073057042 + .long 1536826855 + .long 1015191009 + .long 3712504873 + .long 1073064711 + .long 88491948 + .long 1016476236 + .long 2321106615 + .long 1073072422 + .long 2171176610 + .long 1010584347 + .long 363667784 + .long 1073080175 + .long 813753949 + .long 1016833785 + .long 3111574537 + .long 1073087969 + .long 2606161479 + .long 3163808322 + .long 2956612997 + .long 1073095806 + .long 2118169750 + .long 3163784129 + .long 885834528 + .long 1073103686 + .long 1973258546 + .long 3163310140 + .long 2186617381 + .long 1073111608 + .long 2270764083 + .long 3164321289 + .long 3561793907 + .long 1073119573 + .long 1157054052 + .long 1012938926 + .long 1719614413 + .long 1073127582 + .long 330458197 + .long 3164331316 + .long 1963711167 + .long 1073135634 + .long 1744767756 + .long 3161622870 + .long 1013258799 + .long 1073143730 + .long 1748797610 + .long 3161177658 + .long 4182873220 + .long 1073151869 + .long 629542646 + .long 3163044879 + .long 3907805044 + .long 1073160053 + .long 2257091225 + .long 3162598983 + .long 1218806132 + .long 1073168282 + .long 1818613051 + .long 3163597017 + .long 1447192521 + .long 1073176555 + .long 1462857171 + .long 3163563097 + .long 1339972927 + .long 1073184873 + .long 167908908 + .long 1016620728 + .long 1944781191 + .long 1073193236 + .long 3993278767 + .long 3162772855 + .long 19972402 + .long 1073201645 + .long 3507899861 + .long 1017057868 + .long 919555682 + .long 1073210099 + .long 3121969534 + .long 1013996802 + .long 1413356050 + .long 1073218599 + .long 1651349290 + .long 3163716742 + .long 2571947539 + .long 1073227145 + .long 3558159063 + .long 3164425245 + .long 1176749997 + .long 1073235738 + .long 2738998779 + .long 3163084420 + .long 2604962541 + .long 1073244377 + .long 2614425274 + .long 3164587768 + .long 3649726105 + .long 1073253063 + .long 4085036346 + .long 1016698050 + .long 1110089947 + .long 1073261797 + .long 1451641638 + .long 1016523249 + .long 380978316 + .long 1073270578 + .long 854188970 + .long 3161511262 + .long 2568320822 + .long 1073279406 + .long 2732824428 + .long 1015401491 + .long 194117574 + .long 1073288283 + .long 777528611 + .long 3164460665 + .long 2966275557 + .long 1073297207 + .long 2176155323 + .long 3160891335 + .long 3418903055 + .long 1073306180 + .long 2527457337 + .long 3161869180 + .long 2682146384 + .long 1073315202 + .long 2082178512 + .long 3164411995 + .long 1892288442 + .long 1073324273 + .long 2446255666 + .long 3163648957 + .long 2191782032 + .long 1073333393 + .long 2960257726 + .long 1014791238 + .long 434316067 + .long 1073342563 + .long 2028358766 + .long 1014506698 + .long 2069751141 + .long 1073351782 + .long 1562170674 + .long 3163773257 + .long 3964284211 + .long 1073361051 + .long 2111583915 + .long 1016475740 + .long 2990417245 + .long 1073370371 + .long 3683467745 + .long 3164417902 + .long 321958744 + .long 1073379742 + .long 3401933766 + .long 1016843134 + .long 1434058175 + .long 1073389163 + .long 251133233 + .long 1016134345 + .long 3218338682 + .long 1073398635 + .long 3404164304 + .long 3163525684 + .long 2572866477 + .long 1073408159 + .long 878562433 + .long 1016570317 + .long 697153126 + .long 1073417735 + .long 1283515428 + .long 3164331765 + .long 3092190715 + .long 1073427362 + .long 814012167 + .long 3160571998 + .long 2380618042 + .long 1073437042 + .long 3149557219 + .long 3164369375 + .long 4076559943 + .long 1073446774 + .long 2119478330 + .long 3161806927 + .long 815859274 + .long 1073456560 + .long 240396590 + .long 3164536019 + .long 2420883922 + .long 1073466398 + .long 2049810052 + .long 1015168464 + .long 1540824585 + .long 1073476290 + .long 1064017010 + .long 3164536266 + .long 3716502172 + .long 1073486235 + .long 2303740125 + .long 1015091301 + .long 1610600570 + .long 1073496235 + .long 3766732298 + .long 1016808759 + .long 777507147 + .long 1073506289 + .long 4282924204 + .long 1016236109 + .long 2483480501 + .long 1073516397 + .long 1216371780 + .long 1014082748 + .long 3706687593 + .long 1073526560 + .long 3521726939 + .long 1014301643 + .long 1432208378 + .long 1073536779 + .long 1401068914 + .long 3163412539 + .long 1242007932 + .long 1073547053 + .long 1132034716 + .long 3164388407 + .long 135105010 + .long 1073557383 + .long 1906148727 + .long 3164424315 + .long 3707479175 + .long 1073567768 + .long 3613079302 + .long 1015213314 + .long 382305176 + .long 1073578211 + .long 2347622376 + .long 3163627201 + .long 64696965 + .long 1073588710 + .long 1768797490 + .long 1016865536 + .long 4076975200 + .long 1073599265 + .long 2029000898 + .long 1016257111 + .long 863738719 + .long 1073609879 + .long 1326992219 + .long 3163661773 + .long 351641897 + .long 1073620550 + .long 2172261526 + .long 3164059175 + .long 3884662774 + .long 1073631278 + .long 2158611599 + .long 1015258761 + .long 4224142467 + .long 1073642065 + .long 3389820385 + .long 1016255778 + .long 2728693978 + .long 1073652911 + .long 396109971 + .long 3164511267 + .long 764307441 + .long 1073663816 + .long 3021057420 + .long 3164378099 + .long 3999357479 + .long 1073674779 + .long 2258941616 + .long 1016973300 + .long 929806999 + .long 1073685803 + .long 3205336643 + .long 1016308133 + .long 1533953344 + .long 1073696886 + .long 769171850 + .long 1016714209 + .long 2912730644 + .long 1073708029 + .long 3490067721 + .long 3164453650 + .long 2174652632 + .long 1073719233 + .long 4087714590 + .long 1015498835 + .long 730821105 + .long 1073730498 + .long 2523232743 + .long 1013115764 + .type exp2_tbl,@object + .size exp2_tbl,2048 + .align 16 +cev: + .long 3884607281 + .long 1062590591 + .long 3607404735 + .long 1068264200 + .long 1874480759 + .long 1065595563 + .long 4286760334 + .long 1070514109 + .long 4277811695 + .long 1072049730 + .type cev,@object + .size cev,40 + .space 8, 0x00 # pad + .align 16 +ABSVALMASK: + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .type ABSVALMASK,@object + .size ABSVALMASK,16 + .align 4 +rcp_t1: + .long 0 + .long 1072693248 + .long 0 + .long 1072676992 + .long 0 + .long 1072660992 + .long 0 + .long 1072645248 + .long 0 + .long 1072629696 + .long 0 + .long 1072614400 + .long 0 + .long 1072599360 + .long 0 + .long 1072584512 + .long 0 + .long 1072569856 + .long 0 + .long 1072555456 + .long 0 + .long 1072541312 + .long 0 + .long 1072527296 + .long 0 + .long 1072513472 + .long 0 + .long 1072499904 + .long 0 + .long 1072486464 + .long 0 + .long 1072473280 + .long 0 + .long 1072460224 + .long 0 + .long 1072447360 + .long 0 + .long 1072434688 + .long 0 + .long 1072422208 + .long 0 + .long 1072409856 + .long 0 + .long 1072397696 + .long 0 + .long 1072385664 + .long 0 + .long 1072373824 + .long 0 + .long 1072362112 + .long 0 + .long 1072350592 + .long 0 + .long 1072339200 + .long 0 + .long 1072327936 + .long 0 + .long 1072316864 + .long 0 + .long 1072305856 + .long 0 + .long 1072295040 + .long 0 + .long 1072284352 + .long 0 + .long 1072273792 + .long 0 + .long 1072263424 + .long 0 + .long 1072253120 + .long 0 + .long 1072242944 + .long 0 + .long 1072232896 + .long 0 + .long 1072222976 + .long 0 + .long 1072213184 + .long 0 + .long 1072203520 + .long 0 + .long 1072193920 + .long 0 + .long 1072184448 + .long 0 + .long 1072175104 + .long 0 + .long 1072165888 + .long 0 + .long 1072156736 + .long 0 + .long 1072147776 + .long 0 + .long 1072138816 + .long 0 + .long 1072129984 + .long 0 + .long 1072121280 + .long 0 + .long 1072112704 + .long 0 + .long 1072104192 + .long 0 + .long 1072095744 + .long 0 + .long 1072087424 + .long 0 + .long 1072079168 + .long 0 + .long 1072071040 + .long 0 + .long 1072062976 + .long 0 + .long 1072054976 + .long 0 + .long 1072047104 + .long 0 + .long 1072039296 + .long 0 + .long 1072031552 + .long 0 + .long 1072023936 + .long 0 + .long 1072016384 + .long 0 + .long 1072008896 + .long 0 + .long 1072001536 + .long 0 + .long 1071994176 + .long 0 + .long 1071986944 + .long 0 + .long 1071979776 + .long 0 + .long 1071972672 + .long 0 + .long 1071965696 + .long 0 + .long 1071958720 + .long 0 + .long 1071951808 + .long 0 + .long 1071945024 + .long 0 + .long 1071938304 + .long 0 + .long 1071931584 + .long 0 + .long 1071924992 + .long 0 + .long 1071918464 + .long 0 + .long 1071911936 + .long 0 + .long 1071905536 + .long 0 + .long 1071899200 + .long 0 + .long 1071892864 + .long 0 + .long 1071886656 + .long 0 + .long 1071880448 + .long 0 + .long 1071874368 + .long 0 + .long 1071868288 + .long 0 + .long 1071862272 + .long 0 + .long 1071856384 + .long 0 + .long 1071850496 + .long 0 + .long 1071844608 + .long 0 + .long 1071838848 + .long 0 + .long 1071833152 + .long 0 + .long 1071827456 + .long 0 + .long 1071821824 + .long 0 + .long 1071816256 + .long 0 + .long 1071810752 + .long 0 + .long 1071805248 + .long 0 + .long 1071799872 + .long 0 + .long 1071794496 + .long 0 + .long 1071789120 + .long 0 + .long 1071783872 + .long 0 + .long 1071778624 + .long 0 + .long 1071773440 + .long 0 + .long 1071768320 + .long 0 + .long 1071763200 + .long 0 + .long 1071758144 + .long 0 + .long 1071753152 + .long 0 + .long 1071748160 + .long 0 + .long 1071743232 + .long 0 + .long 1071738368 + .long 0 + .long 1071733504 + .long 0 + .long 1071728704 + .long 0 + .long 1071723968 + .long 0 + .long 1071719232 + .long 0 + .long 1071714560 + .long 0 + .long 1071709952 + .long 0 + .long 1071705344 + .long 0 + .long 1071700800 + .long 0 + .long 1071696256 + .long 0 + .long 1071691776 + .long 0 + .long 1071687296 + .long 0 + .long 1071682880 + .long 0 + .long 1071678528 + .long 0 + .long 1071674176 + .long 0 + .long 1071669824 + .long 0 + .long 1071665536 + .long 0 + .long 1071661312 + .long 0 + .long 1071657088 + .long 0 + .long 1071652928 + .long 0 + .long 1071648768 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .type rcp_t1,@object + .size rcp_t1,1040 + .align 4 +HALFSIG: + .long 4160749568 + .long 4294967295 + .type HALFSIG,@object + .size HALFSIG,8 + .align 4 +rcp_t2: + .long 0 + .long 1072693248 + .long 0 + .long 1072693056 + .long 0 + .long 1072692800 + .long 0 + .long 1072692544 + .long 0 + .long 1072692288 + .long 0 + .long 1072692032 + .long 0 + .long 1072691776 + .long 0 + .long 1072691520 + .long 0 + .long 1072691264 + .long 0 + .long 1072691008 + .long 0 + .long 1072690752 + .long 0 + .long 1072690496 + .long 0 + .long 1072690240 + .long 0 + .long 1072689984 + .long 0 + .long 1072689728 + .long 0 + .long 1072689472 + .long 0 + .long 1072689216 + .long 0 + .long 1072688960 + .long 0 + .long 1072688704 + .long 0 + .long 1072688448 + .long 0 + .long 1072688192 + .long 0 + .long 1072687936 + .long 0 + .long 1072687680 + .long 0 + .long 1072687424 + .long 0 + .long 1072687168 + .long 0 + .long 1072686912 + .long 0 + .long 1072686656 + .long 0 + .long 1072686400 + .long 0 + .long 1072686144 + .long 0 + .long 1072685888 + .long 0 + .long 1072685632 + .long 0 + .long 1072685376 + .long 0 + .long 1072685120 + .long 0 + .long 1072684864 + .long 0 + .long 1072684608 + .long 0 + .long 1072684352 + .long 0 + .long 1072684096 + .long 0 + .long 1072683840 + .long 0 + .long 1072683584 + .long 0 + .long 1072683328 + .long 0 + .long 1072683072 + .long 0 + .long 1072682816 + .long 0 + .long 1072682560 + .long 0 + .long 1072682304 + .long 0 + .long 1072682048 + .long 0 + .long 1072681792 + .long 0 + .long 1072681600 + .long 0 + .long 1072681344 + .long 0 + .long 1072681088 + .long 0 + .long 1072680832 + .long 0 + .long 1072680576 + .long 0 + .long 1072680320 + .long 0 + .long 1072680064 + .long 0 + .long 1072679808 + .long 0 + .long 1072679552 + .long 0 + .long 1072679296 + .long 0 + .long 1072679040 + .long 0 + .long 1072678784 + .long 0 + .long 1072678528 + .long 0 + .long 1072678272 + .long 0 + .long 1072678016 + .long 0 + .long 1072677760 + .long 0 + .long 1072677504 + .long 0 + .long 1072677248 + .long 0 + .long 1072697344 + .long 0 + .long 1072697280 + .long 0 + .long 1072697216 + .long 0 + .long 1072697152 + .long 0 + .long 1072697088 + .long 0 + .long 1072697024 + .long 0 + .long 1072696960 + .long 0 + .long 1072696896 + .long 0 + .long 1072696832 + .long 0 + .long 1072696768 + .long 0 + .long 1072696704 + .long 0 + .long 1072696640 + .long 0 + .long 1072696576 + .long 0 + .long 1072696512 + .long 0 + .long 1072696448 + .long 0 + .long 1072696384 + .long 0 + .long 1072696320 + .long 0 + .long 1072696256 + .long 0 + .long 1072696192 + .long 0 + .long 1072696128 + .long 0 + .long 1072696064 + .long 0 + .long 1072696000 + .long 0 + .long 1072695936 + .long 0 + .long 1072695872 + .long 0 + .long 1072695808 + .long 0 + .long 1072695744 + .long 0 + .long 1072695680 + .long 0 + .long 1072695616 + .long 0 + .long 1072695552 + .long 0 + .long 1072695488 + .long 0 + .long 1072695424 + .long 0 + .long 1072695360 + .long 0 + .long 1072695296 + .long 0 + .long 1072695232 + .long 0 + .long 1072695168 + .long 0 + .long 1072695104 + .long 0 + .long 1072695040 + .long 0 + .long 1072694976 + .long 0 + .long 1072694912 + .long 0 + .long 1072694848 + .long 0 + .long 1072694784 + .long 0 + .long 1072694720 + .long 0 + .long 1072694656 + .long 0 + .long 1072694592 + .long 0 + .long 1072694528 + .long 0 + .long 1072694464 + .long 0 + .long 1072694400 + .long 0 + .long 1072694336 + .long 0 + .long 1072694272 + .long 0 + .long 1072694208 + .long 0 + .long 1072694144 + .long 0 + .long 1072694080 + .long 0 + .long 1072694016 + .long 0 + .long 1072693952 + .long 0 + .long 1072693888 + .long 0 + .long 1072693824 + .long 0 + .long 1072693760 + .long 0 + .long 1072693696 + .long 0 + .long 1072693632 + .long 0 + .long 1072693568 + .long 0 + .long 1072693504 + .long 0 + .long 1072693440 + .long 0 + .long 1072693376 + .long 0 + .long 1072693312 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .type rcp_t2,@object + .size rcp_t2,1040 + .align 4 +LHN: + .long 1073741824 + .long 3220641095 + .type LHN,@object + .size LHN,8 + .align 4 +rcp_t3: + .long 1073741824 + .long 1073157447 + .long 3221225472 + .long 1073157445 + .long 1073741824 + .long 1073157444 + .long 0 + .long 1073157443 + .long 2147483648 + .long 1073157441 + .long 0 + .long 1073157440 + .long 2147483648 + .long 1073157438 + .long 1073741824 + .long 1073157437 + .long 3221225472 + .long 1073157435 + .long 1073741824 + .long 1073157434 + .long 3221225472 + .long 1073157432 + .long 2147483648 + .long 1073157431 + .long 0 + .long 1073157430 + .long 2147483648 + .long 1073157428 + .long 0 + .long 1073157427 + .long 2147483648 + .long 1073157425 + .long 1073741824 + .long 1073157424 + .long 3221225472 + .long 1073157422 + .long 1073741824 + .long 1073157421 + .long 3221225472 + .long 1073157419 + .long 2147483648 + .long 1073157418 + .long 0 + .long 1073157417 + .long 2147483648 + .long 1073157415 + .long 0 + .long 1073157414 + .long 3221225472 + .long 1073157412 + .long 1073741824 + .long 1073157411 + .long 3221225472 + .long 1073157409 + .long 1073741824 + .long 1073157408 + .long 3221225472 + .long 1073157406 + .long 2147483648 + .long 1073157405 + .long 0 + .long 1073157404 + .long 2147483648 + .long 1073157402 + .long 0 + .long 1073157401 + .long 3221225472 + .long 1073157399 + .long 1073741824 + .long 1073157398 + .long 3221225472 + .long 1073157396 + .long 1073741824 + .long 1073157395 + .long 3221225472 + .long 1073157393 + .long 2147483648 + .long 1073157392 + .long 0 + .long 1073157391 + .long 2147483648 + .long 1073157389 + .long 0 + .long 1073157388 + .long 3221225472 + .long 1073157386 + .long 1073741824 + .long 1073157385 + .long 3221225472 + .long 1073157383 + .long 1073741824 + .long 1073157382 + .long 0 + .long 1073157381 + .long 2147483648 + .long 1073157379 + .long 0 + .long 1073157378 + .long 2147483648 + .long 1073157376 + .long 0 + .long 1073157375 + .long 3221225472 + .long 1073157373 + .long 1073741824 + .long 1073157372 + .long 3221225472 + .long 1073157370 + .long 1073741824 + .long 1073157369 + .long 0 + .long 1073157368 + .long 2147483648 + .long 1073157366 + .long 0 + .long 1073157365 + .long 2147483648 + .long 1073157363 + .long 1073741824 + .long 1073157362 + .long 3221225472 + .long 1073157360 + .long 1073741824 + .long 1073157359 + .long 3221225472 + .long 1073157357 + .long 1073741824 + .long 1073157356 + .long 0 + .long 1073157355 + .long 2147483648 + .long 1073157353 + .long 0 + .long 1073157352 + .long 2147483648 + .long 1073157350 + .long 1073741824 + .long 1073157349 + .long 3221225472 + .long 1073157347 + .long 1073741824 + .long 1073157346 + .long 3221225472 + .long 1073157344 + .long 2147483648 + .long 1073157343 + .long 0 + .long 1073157342 + .long 2147483648 + .long 1073157340 + .long 0 + .long 1073157339 + .long 2147483648 + .long 1073157337 + .long 1073741824 + .long 1073157336 + .long 3221225472 + .long 1073157334 + .long 1073741824 + .long 1073157333 + .long 3221225472 + .long 1073157331 + .long 2147483648 + .long 1073157330 + .long 0 + .long 1073157329 + .long 2147483648 + .long 1073157327 + .long 0 + .long 1073157326 + .long 3221225472 + .long 1073157324 + .long 1073741824 + .long 1073157323 + .long 3221225472 + .long 1073157321 + .long 1073741824 + .long 1073157320 + .long 3221225472 + .long 1073157318 + .long 2147483648 + .long 1073157317 + .long 0 + .long 1073157316 + .long 2147483648 + .long 1073157314 + .long 0 + .long 1073157313 + .long 3221225472 + .long 1073157311 + .long 1073741824 + .long 1073157310 + .long 3221225472 + .long 1073157308 + .long 1073741824 + .long 1073157307 + .long 0 + .long 1073157306 + .long 2147483648 + .long 1073157304 + .long 0 + .long 1073157303 + .long 2147483648 + .long 1073157301 + .long 0 + .long 1073157300 + .long 3221225472 + .long 1073157298 + .long 1073741824 + .long 1073157297 + .long 3221225472 + .long 1073157295 + .long 1073741824 + .long 1073157294 + .long 0 + .long 1073157293 + .long 2147483648 + .long 1073157291 + .long 0 + .long 1073157290 + .long 2147483648 + .long 1073157288 + .long 1073741824 + .long 1073157287 + .long 3221225472 + .long 1073157285 + .long 1073741824 + .long 1073157284 + .long 3221225472 + .long 1073157282 + .long 1073741824 + .long 1073157281 + .long 0 + .long 1073157280 + .long 2147483648 + .long 1073157278 + .long 0 + .long 1073157277 + .long 2147483648 + .long 1073157275 + .long 1073741824 + .long 1073157274 + .long 3221225472 + .long 1073157272 + .long 1073741824 + .long 1073157271 + .long 3221225472 + .long 1073157269 + .long 2147483648 + .long 1073157268 + .long 0 + .long 1073157267 + .long 2147483648 + .long 1073157265 + .long 0 + .long 1073157264 + .long 2147483648 + .long 1073157539 + .long 3221225472 + .long 1073157538 + .long 1073741824 + .long 1073157538 + .long 2147483648 + .long 1073157537 + .long 3221225472 + .long 1073157536 + .long 0 + .long 1073157536 + .long 1073741824 + .long 1073157535 + .long 2147483648 + .long 1073157534 + .long 3221225472 + .long 1073157533 + .long 0 + .long 1073157533 + .long 1073741824 + .long 1073157532 + .long 3221225472 + .long 1073157531 + .long 0 + .long 1073157531 + .long 1073741824 + .long 1073157530 + .long 2147483648 + .long 1073157529 + .long 3221225472 + .long 1073157528 + .long 0 + .long 1073157528 + .long 1073741824 + .long 1073157527 + .long 2147483648 + .long 1073157526 + .long 0 + .long 1073157526 + .long 1073741824 + .long 1073157525 + .long 2147483648 + .long 1073157524 + .long 3221225472 + .long 1073157523 + .long 0 + .long 1073157523 + .long 1073741824 + .long 1073157522 + .long 2147483648 + .long 1073157521 + .long 3221225472 + .long 1073157520 + .long 0 + .long 1073157520 + .long 2147483648 + .long 1073157519 + .long 3221225472 + .long 1073157518 + .long 0 + .long 1073157518 + .long 1073741824 + .long 1073157517 + .long 2147483648 + .long 1073157516 + .long 3221225472 + .long 1073157515 + .long 0 + .long 1073157515 + .long 1073741824 + .long 1073157514 + .long 2147483648 + .long 1073157513 + .long 0 + .long 1073157513 + .long 1073741824 + .long 1073157512 + .long 2147483648 + .long 1073157511 + .long 3221225472 + .long 1073157510 + .long 0 + .long 1073157510 + .long 1073741824 + .long 1073157509 + .long 2147483648 + .long 1073157508 + .long 3221225472 + .long 1073157507 + .long 0 + .long 1073157507 + .long 2147483648 + .long 1073157506 + .long 3221225472 + .long 1073157505 + .long 0 + .long 1073157505 + .long 1073741824 + .long 1073157504 + .long 2147483648 + .long 1073157503 + .long 3221225472 + .long 1073157502 + .long 0 + .long 1073157502 + .long 1073741824 + .long 1073157501 + .long 3221225472 + .long 1073157500 + .long 0 + .long 1073157500 + .long 1073741824 + .long 1073157499 + .long 2147483648 + .long 1073157498 + .long 3221225472 + .long 1073157497 + .long 0 + .long 1073157497 + .long 1073741824 + .long 1073157496 + .long 2147483648 + .long 1073157495 + .long 3221225472 + .long 1073157494 + .long 1073741824 + .long 1073157494 + .long 2147483648 + .long 1073157493 + .long 3221225472 + .long 1073157492 + .long 0 + .long 1073157492 + .long 1073741824 + .long 1073157491 + .long 2147483648 + .long 1073157490 + .long 3221225472 + .long 1073157489 + .long 0 + .long 1073157489 + .long 1073741824 + .long 1073157488 + .long 3221225472 + .long 1073157487 + .long 0 + .long 1073157487 + .long 1073741824 + .long 1073157486 + .long 2147483648 + .long 1073157485 + .long 3221225472 + .long 1073157484 + .long 0 + .long 1073157484 + .long 1073741824 + .long 1073157483 + .long 2147483648 + .long 1073157482 + .long 0 + .long 1073157482 + .long 1073741824 + .long 1073157481 + .long 2147483648 + .long 1073157480 + .long 3221225472 + .long 1073157479 + .long 0 + .long 1073157479 + .long 1073741824 + .long 1073157478 + .long 2147483648 + .long 1073157477 + .long 3221225472 + .long 1073157476 + .long 0 + .long 1073157476 + .long 2147483648 + .long 1073157475 + .long 3221225472 + .long 1073157474 + .long 0 + .long 1073157474 + .long 1073741824 + .long 1073157473 + .long 2147483648 + .long 1073157472 + .long 3221225472 + .long 1073157471 + .long 0 + .long 1073157471 + .long 1073741824 + .long 1073157470 + .long 2147483648 + .long 1073157469 + .long 0 + .long 1073157469 + .long 1073741824 + .long 1073157468 + .long 2147483648 + .long 1073157467 + .long 3221225472 + .long 1073157466 + .long 0 + .long 1073157466 + .long 1073741824 + .long 1073157465 + .long 2147483648 + .long 1073157464 + .long 3221225472 + .long 1073157463 + .long 0 + .long 1073157463 + .long 2147483648 + .long 1073157462 + .long 3221225472 + .long 1073157461 + .long 0 + .long 1073157461 + .long 1073741824 + .long 1073157460 + .long 2147483648 + .long 1073157459 + .long 3221225472 + .long 1073157458 + .long 0 + .long 1073157458 + .long 1073741824 + .long 1073157457 + .long 3221225472 + .long 1073157456 + .long 0 + .long 1073157456 + .long 1073741824 + .long 1073157455 + .long 2147483648 + .long 1073157454 + .long 3221225472 + .long 1073157453 + .long 0 + .long 1073157453 + .long 1073741824 + .long 1073157452 + .long 2147483648 + .long 1073157451 + .long 3221225472 + .long 1073157450 + .long 1073741824 + .long 1073157450 + .long 2147483648 + .long 1073157449 + .long 3221225472 + .long 1073157448 + .long 0 + .long 1073157448 + .long 1073741824 + .long 1073157447 + .long 0 + .long 0 + .type rcp_t3,@object + .size rcp_t3,2064 + .align 4 +Shifter: + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .type Shifter,@object + .size Shifter,16 + .align 4 +NEG_ZERO: + .long 0 + .long 2147483648 + .type NEG_ZERO,@object + .size NEG_ZERO,8 + .align 4 +NEG_INF: + .long 0 + .long 4293918720 + .type NEG_INF,@object + .size NEG_INF,8 + .align 4 +sNaN: + .long 1 + .long 2146435072 + .type sNaN,@object + .size sNaN,8 + .align 4 +INF: + .long 0 + .long 2146435072 + .type INF,@object + .size INF,8 + .align 4 +EMIN: + .long 0 + .long 1048576 + .type EMIN,@object + .size EMIN,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/powf_gen.S b/external/sgx_libm/intel64/powf_gen.S new file mode 100644 index 0000000000..f841ac81fe --- /dev/null +++ b/external/sgx_libm/intel64/powf_gen.S @@ -0,0 +1,892 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "powf_gen.c" + .text +..TXTST0: +# -- Begin powf + .text + .align 16,0x90 + .globl powf +powf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_powf.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movss %xmm0, 16(%rsp) + movss %xmm1, 24(%rsp) +..B1.2: + movq $0x3ff0000000000000, %r8 + movd %r8, %xmm5 + movd %xmm0, %eax + lea B_table(%rip), %r11 + psllq $32, %xmm0 + psrlq $3, %xmm0 + cvtss2sd %xmm1, %xmm1 + movapd cv(%rip), %xmm6 + orpd %xmm0, %xmm5 + movl $2130706431, %ecx + movl %eax, %edx + subl $8388608, %edx + cmpl %edx, %ecx + jb .L_2TAG_PACKET_0.0.2 + movl $0, %ecx + shrl $16, %eax +.L_2TAG_PACKET_1.0.2: +.L_2TAG_PACKET_2.0.2: + movl $127, %edx + andl %eax, %edx + addl $1, %edx + andl $254, %edx + movq (%r11,%rdx,8), %xmm3 + movl $130944, %r8d + addl %edx, %r8d + movd %r8, %xmm7 + movq 8(%r11,%rdx,8), %xmm0 + addl $65, %eax + sarl $7, %eax + subl $127, %eax + cvtsi2sd %eax, %xmm4 + psllq $45, %xmm7 + subsd %xmm7, %xmm5 + movl %eax, %edx + sarl $31, %eax + addl %eax, %edx + xorl %edx, %eax + movapd 16+cv(%rip), %xmm2 + mulsd %xmm3, %xmm5 + movq $0x42e8000000000000, %r9 + movd %r9, %xmm3 + pshufd $68, %xmm5, %xmm7 + addsd %xmm5, %xmm0 + bsr %eax, %eax + mulpd %xmm7, %xmm6 + mulpd %xmm7, %xmm7 + addsd %xmm4, %xmm0 + pextrw $3, %xmm1, %edx + addpd %xmm2, %xmm6 + andl $32752, %edx + shrl $4, %edx + subl $993, %eax + addl %edx, %eax + cmpl $35, %eax + jae .L_2TAG_PACKET_3.0.2 + mulsd %xmm1, %xmm0 + mulsd %xmm7, %xmm7 + movq %xmm0, %xmm4 + addsd %xmm3, %xmm0 + mulpd %xmm7, %xmm6 + movd %xmm0, %eax + subsd %xmm3, %xmm0 + pshufd $238, %xmm6, %xmm7 + subsd %xmm0, %xmm4 + addsd %xmm7, %xmm6 + movapd cev(%rip), %xmm7 + mulsd %xmm6, %xmm1 + movapd 16+cev(%rip), %xmm2 + xorpd %xmm6, %xmm6 + addsd %xmm1, %xmm4 + pshufd $68, %xmm4, %xmm5 + movl %eax, %edx + sarl $1, %edx + andl $31, %eax + movq 1056(%r11,%rax,8), %xmm3 + orl $16368, %ecx + andl $-16, %edx + addl %edx, %ecx + pinsrw $3, %ecx, %xmm6 + mulpd %xmm5, %xmm7 + mulsd %xmm5, %xmm5 + mulsd %xmm3, %xmm4 + addpd %xmm7, %xmm2 + mulsd %xmm6, %xmm3 + mulsd %xmm2, %xmm5 + pshufd $238, %xmm2, %xmm0 + mulsd %xmm6, %xmm4 + addsd %xmm5, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm0, %xmm3 + cvtpd2ps %xmm3, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + movq ABSVALMASK(%rip), %xmm3 + movd %xmm1, %edx + movq %xmm1, %xmm0 + movq %xmm1, %xmm7 + andpd %xmm3, %xmm0 + psrlq $32, %xmm0 + movd %xmm0, %ecx + cmpl $2146435072, %ecx + jae .L_2TAG_PACKET_4.0.2 + orl %ecx, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_5.0.2 + movl 16(%rsp), %edx + cmpl $2139095039, %edx + jbe .L_2TAG_PACKET_6.0.2 + movl 24(%rsp), %eax + movl %eax, %r9d + shrl $23, %r9d + andl $255, %r9d + subl $127, %r9d + movl %r9d, %ecx + sarl $31, %ecx + notl %ecx + addl $8, %r9d + andl %r9d, %ecx + subl $32, %ecx + movl %ecx, %r8d + sarl $31, %r8d + andl %r8d, %ecx + addl $32, %ecx + andl $8388607, %eax + orl $8388608, %eax + shlq %cl, %rax + andl $2147483647, %edx + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_7.0.2 + testl $2147483647, %eax + jne .L_2TAG_PACKET_8.0.2 + movl %eax, %ecx + shrl $16, %ecx + cmpl $8388608, %edx + jb .L_2TAG_PACKET_9.0.2 + movl 16(%rsp), %eax + shrl $16, %eax + andl $32767, %eax + jmp .L_2TAG_PACKET_1.0.2 +.L_2TAG_PACKET_4.0.2: + movss 16(%rsp), %xmm0 + movd %xmm0, %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + ja .L_2TAG_PACKET_10.0.2 + jmp .L_2TAG_PACKET_11.0.2 +.L_2TAG_PACKET_10.0.2: + movss 16(%rsp), %xmm0 + addss %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_6.0.2: + movl $0, %ecx +.L_2TAG_PACKET_9.0.2: + xorpd %xmm0, %xmm0 + movl $24448, %edx + pinsrw $1, %edx, %xmm0 + movss 16(%rsp), %xmm4 + movq EXPMASK(%rip), %xmm5 + mulss %xmm0, %xmm4 + movd %xmm4, %edx + andl $2147483647, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_12.0.2 + pextrw $1, %xmm4, %eax + movaps %xmm4, %xmm0 + andps ABSVALS(%rip), %xmm4 + psllq $29, %xmm0 + orpd %xmm0, %xmm5 + andl $32767, %eax + subl $8192, %eax + jmp .L_2TAG_PACKET_2.0.2 +.L_2TAG_PACKET_13.0.2: + movl 24(%rsp), %edx + andl $-2147483648, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_14.0.2 + movss ONEMASK(%rip), %xmm0 + xorps %xmm4, %xmm4 + divss %xmm4, %xmm0 +.L_2TAG_PACKET_15.0.2: + movl $33, (%rsp) + jmp .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_12.0.2: + movl 24(%rsp), %edx + andl $-2147483648, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_17.0.2 + shll $16, %ecx + movl 16(%rsp), %edx + andl %ecx, %edx + orl $2139095040, %edx + movd %edx, %xmm0 + movss ONEMASK(%rip), %xmm5 + divss %xmm4, %xmm5 + jmp .L_2TAG_PACKET_15.0.2 +.L_2TAG_PACKET_17.0.2: + shll $16, %ecx + movd %xmm4, %edx + andl %ecx, %edx + cmpl $0, %edx + jne .L_2TAG_PACKET_18.0.2 + xorps %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_7.0.2: + movl 16(%rsp), %edx + cmpl $2139095040, %edx + je .L_2TAG_PACKET_19.0.2 + andl $2147483647, %edx + cmpl $2139095040, %edx + ja .L_2TAG_PACKET_10.0.2 + cmpl $-2147483648, %eax + jne .L_2TAG_PACKET_20.0.2 + pextrw $3, %xmm1, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_21.0.2 +.L_2TAG_PACKET_18.0.2: + movl $-2147483648, %eax + movd %rax, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_21.0.2: + movl $-8388608, %eax + movd %rax, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_20.0.2: + pextrw $3, %xmm1, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_22.0.2 + xorps %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_19.0.2: + pextrw $3, %xmm1, %eax + andl $32768, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_22.0.2 + xorps %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_8.0.2: + cmpl $0, %edx + je .L_2TAG_PACKET_13.0.2 + movss sNaN(%rip), %xmm0 + mulss %xmm0, %xmm0 + movl $34, (%rsp) + jmp .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_11.0.2: + movss 16(%rsp), %xmm4 + movss 24(%rsp), %xmm1 + movl 24(%rsp), %eax + movl %eax, %ecx + andl $2147483647, %eax + cmpl $2139095040, %eax + ja .L_2TAG_PACKET_23.0.2 + andl $-2147483648, %ecx + movd %xmm4, %edx + movl $2147483647, %eax + andl %edx, %eax + je .L_2TAG_PACKET_12.0.2 + xorl $-1082130432, %edx + cmpl $0, %edx + je .L_2TAG_PACKET_24.0.2 + cmpl $0, %ecx + je .L_2TAG_PACKET_25.0.2 + movd %xmm4, %eax + andl $2147483647, %eax + cmpl $1065353216, %eax + jae .L_2TAG_PACKET_14.0.2 + jmp .L_2TAG_PACKET_22.0.2 +.L_2TAG_PACKET_14.0.2: + xorps %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_24.0.2: + stmxcsr 4(%rsp) + andl $-34, 4(%rsp) + ldmxcsr 4(%rsp) + movl $1065353216, %eax + movd %rax, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_25.0.2: + pextrw $1, %xmm4, %eax + andl $32640, %eax + cmpl $16256, %eax + jae .L_2TAG_PACKET_22.0.2 + xorps %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_22.0.2: + movl $2139095040, %eax + movd %rax, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_26.0.2: + movl $32, (%rsp) + jmp .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_27.0.2: + movl $35, (%rsp) + jmp .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_23.0.2: + movss 24(%rsp), %xmm0 + addss %xmm0, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_5.0.2: + movss 16(%rsp), %xmm4 + movss 24(%rsp), %xmm1 + movd %xmm4, %eax + movss ONEMASK(%rip), %xmm0 + cmpl $0, %eax + je .L_2TAG_PACKET_26.0.2 + movd %xmm4, %eax + xorps %xmm2, %xmm2 + addss %xmm2, %xmm4 + andl $2147483647, %eax + cmpl $2139095040, %eax + ja .L_2TAG_PACKET_27.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_28.0.2: + mulsd %xmm7, %xmm7 + mulpd %xmm7, %xmm6 + pshufd $238, %xmm6, %xmm7 + addsd %xmm7, %xmm0 + mulsd %xmm1, %xmm0 + movapd cev(%rip), %xmm7 + mulsd %xmm6, %xmm1 + movq %xmm0, %xmm4 + addsd %xmm3, %xmm0 + movd %xmm0, %eax + subsd %xmm3, %xmm0 + subsd %xmm0, %xmm4 + movapd 16+cev(%rip), %xmm2 + xorpd %xmm6, %xmm6 + addsd %xmm1, %xmm4 + pshufd $68, %xmm4, %xmm5 + movl %eax, %edx + sarl $1, %edx + andl $31, %eax + movq 1056(%r11,%rax,8), %xmm3 + orl $16368, %ecx + andl $-16, %edx + addl %edx, %ecx + pinsrw $3, %ecx, %xmm6 + mulpd %xmm5, %xmm7 + mulsd %xmm5, %xmm5 + mulsd %xmm3, %xmm4 + addpd %xmm7, %xmm2 + mulsd %xmm6, %xmm3 + mulsd %xmm6, %xmm4 + mulsd %xmm2, %xmm5 + pshufd $238, %xmm2, %xmm0 + addsd %xmm5, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm3, %xmm0 + cvtpd2ps %xmm0, %xmm0 + pextrw $1, %xmm0, %eax + andl $32767, %eax + cmpl $32640, %eax + jae .L_2TAG_PACKET_29.0.2 + cmpl $16, %eax + jb .L_2TAG_PACKET_30.0.2 + jmp ..B1.5 +.L_2TAG_PACKET_31.0.2: + orl $32639, %ecx + xorpd %xmm0, %xmm0 + pinsrw $1, %ecx, %xmm0 + addss %xmm0, %xmm0 +.L_2TAG_PACKET_29.0.2: + movl $30, (%rsp) + jmp .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_32.0.2: + movl $8388608, %eax + movd %eax, %xmm5 + mulss %xmm5, %xmm5 + xorpd %xmm0, %xmm0 + pinsrw $1, %ecx, %xmm0 +.L_2TAG_PACKET_30.0.2: + movl $31, (%rsp) + jmp .L_2TAG_PACKET_16.0.2 +.L_2TAG_PACKET_3.0.2: + movl 16(%rsp), %edx + cmpl $1065353216, %edx + je .L_2TAG_PACKET_24.0.2 + movl 24(%rsp), %edx + andl $2147483647, %edx + cmpl $2139095040, %edx + jae .L_2TAG_PACKET_11.0.2 + cmpl $0, %edx + je .L_2TAG_PACKET_5.0.2 + cmpl $0, %eax + jl .L_2TAG_PACKET_33.0.2 + cmpl $38, %eax + jb .L_2TAG_PACKET_28.0.2 + movl 16(%rsp), %edx + andl $2139095040, %edx + subl $1056964608, %edx + cmpl $8388608, %edx + jbe .L_2TAG_PACKET_34.0.2 +.L_2TAG_PACKET_35.0.2: + movl 16(%rsp), %eax + movl 24(%rsp), %edx + andl $2139095040, %eax + subl $1065353216, %eax + xorl %edx, %eax + andl $-2147483648, %eax + cmpl $0, %eax + je .L_2TAG_PACKET_31.0.2 + jmp .L_2TAG_PACKET_32.0.2 +.L_2TAG_PACKET_34.0.2: + movss 16(%rsp), %xmm4 + movl $1065353216, %eax + movd %eax, %xmm2 + pslld $1, %xmm4 + psrld $1, %xmm4 + subss %xmm4, %xmm2 + movd %xmm2, %edx + andl $2139095040, %edx + je .L_2TAG_PACKET_33.0.2 + movq %xmm1, %xmm4 + mulsd %xmm0, %xmm4 + pextrw $3, %xmm4, %eax + andl $32752, %eax + cmpl $16496, %eax + jb .L_2TAG_PACKET_28.0.2 + jmp .L_2TAG_PACKET_35.0.2 +.L_2TAG_PACKET_33.0.2: + shll $16, %ecx + orl $1065353216, %ecx + movd %ecx, %xmm0 + jmp ..B1.5 +.L_2TAG_PACKET_16.0.2: + movss %xmm0, 8(%rsp) +..B1.3: + movss 8(%rsp), %xmm0 +.L_2TAG_PACKET_36.0.2: +..B1.5: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type powf,@function + .size powf,.-powf + .data +# -- End powf + .section .rodata, "a" + .align 16 + .align 16 +B_table: + .long 1697350398 + .long 1073157447 + .long 0 + .long 0 + .long 3983912013 + .long 1073134173 + .long 2244132864 + .long 1066854294 + .long 3077571303 + .long 1073111605 + .long 1972305920 + .long 1067891411 + .long 787997771 + .long 1073089711 + .long 2678235136 + .long 1068559160 + .long 2608086797 + .long 1073068460 + .long 4207480832 + .long 1068917750 + .long 4250927815 + .long 1073047825 + .long 1085124608 + .long 1069271106 + .long 4006130247 + .long 1073027780 + .long 2363127808 + .long 1069583448 + .long 2255915958 + .long 1073008300 + .long 3799560192 + .long 1069755113 + .long 1031537321 + .long 1072989361 + .long 972806144 + .long 1069924378 + .long 3606154084 + .long 1072970940 + .long 3492741120 + .long 1070091307 + .long 1235818328 + .long 1072953018 + .long 766832640 + .long 1070255966 + .long 2880061438 + .long 1072935573 + .long 1278367744 + .long 1070418414 + .long 525144062 + .long 1072918588 + .long 3103942656 + .long 1070578710 + .long 3251485016 + .long 1072902043 + .long 3671264256 + .long 1070666503 + .long 2604098795 + .long 1072885923 + .long 2869823488 + .long 1070744583 + .long 2408035495 + .long 1072870211 + .long 3466906624 + .long 1070821668 + .long 1357880318 + .long 1072854892 + .long 1271733248 + .long 1070897784 + .long 1394140652 + .long 1072839951 + .long 972806144 + .long 1070972954 + .long 3210356685 + .long 1072825374 + .long 3449621504 + .long 1071047201 + .long 1774519652 + .long 1072811149 + .long 1662393344 + .long 1071120549 + .long 3338441873 + .long 1072797262 + .long 2300516352 + .long 1071193018 + .long 3804456356 + .long 1072783702 + .long 176119808 + .long 1071264630 + .long 1462910403 + .long 1072770458 + .long 4147676160 + .long 1071335403 + .long 1149890700 + .long 1072757518 + .long 2905168896 + .long 1071405359 + .long 1234436653 + .long 1072744872 + .long 3761433600 + .long 1071474515 + .long 2089211650 + .long 1072732510 + .long 2716292096 + .long 1071542890 + .long 1684223316 + .long 1072720423 + .long 1758136320 + .long 1071610501 + .long 4072784951 + .long 1072708601 + .long 2341968384 + .long 1071661018 + .long 2114454037 + .long 1072697037 + .long 14039552 + .long 1071694085 + .long 2012861074 + .long 1072678195 + .long 4204914176 + .long 1071726793 + .long 2037138800 + .long 1072656045 + .long 513134592 + .long 1071759153 + .long 3417210877 + .long 1072634361 + .long 3559335936 + .long 1071791169 + .long 3694789629 + .long 1072613129 + .long 1904282624 + .long 3218771961 + .long 2992528814 + .long 1072592335 + .long 714524672 + .long 3218709255 + .long 3882342941 + .long 1072571965 + .long 180337664 + .long 3218647192 + .long 2671772639 + .long 1072552007 + .long 47131648 + .long 3218585759 + .long 2172608510 + .long 1072532448 + .long 1751500800 + .long 3218524943 + .long 3001586108 + .long 1072513276 + .long 4058951680 + .long 3218464732 + .long 3477449063 + .long 1072494480 + .long 2999895040 + .long 3218405115 + .long 3818975826 + .long 1072476049 + .long 398715904 + .long 3218346080 + .long 1758664544 + .long 1072457973 + .long 3815829504 + .long 3218287614 + .long 1046539701 + .long 1072440241 + .long 722717696 + .long 3218229709 + .long 2778964739 + .long 1072422843 + .long 1399058432 + .long 3218172352 + .long 1026978211 + .long 1072405771 + .long 227933184 + .long 3218115534 + .long 4238694625 + .long 1072389014 + .long 2835759104 + .long 3218038744 + .long 811117725 + .long 1072372566 + .long 3554951168 + .long 3217927202 + .long 1975098645 + .long 1072356416 + .long 2818570240 + .long 3217816679 + .long 3079413536 + .long 1072340557 + .long 3041732608 + .long 3217707156 + .long 712695513 + .long 1072324982 + .long 180338688 + .long 3217598616 + .long 1238508315 + .long 1072309682 + .long 835166208 + .long 3217491040 + .long 3563503614 + .long 1072294650 + .long 704622592 + .long 3217384412 + .long 3383126459 + .long 1072279880 + .long 1695342592 + .long 3217278715 + .long 1724836050 + .long 1072265365 + .long 3266000896 + .long 3217173933 + .long 608820196 + .long 1072251098 + .long 2363885568 + .long 3217070051 + .long 3005930546 + .long 1072237072 + .long 3908239360 + .long 3216902938 + .long 4207804139 + .long 1072223282 + .long 448159744 + .long 3216698681 + .long 378851326 + .long 1072209723 + .long 2530197504 + .long 3216496132 + .long 1405092650 + .long 1072196387 + .long 4268273664 + .long 3216295264 + .long 795096448 + .long 1072183270 + .long 2785038336 + .long 3216096050 + .long 1417164049 + .long 1072170366 + .long 522182656 + .long 3215814333 + .long 2583387630 + .long 1072157670 + .long 3386466304 + .long 3215422356 + .long 20099889 + .long 1072145178 + .long 3838140416 + .long 3215033528 + .long 3019600065 + .long 1072132883 + .long 2250194944 + .long 3214361582 + .long 53601996 + .long 1072120783 + .long 2718924800 + .long 3213307003 + .long 1697350398 + .long 1072108871 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 3541402996 + .long 1072716208 + .long 1828292879 + .long 1072739672 + .long 3490863953 + .long 1072763649 + .long 1014845819 + .long 1072788152 + .long 828946858 + .long 1072813191 + .long 1853186616 + .long 1072838778 + .long 4112506593 + .long 1072864925 + .long 171030293 + .long 1072891646 + .long 926591435 + .long 1072918951 + .long 1276261410 + .long 1072946854 + .long 1617004845 + .long 1072975368 + .long 3577096743 + .long 1073004506 + .long 1453150082 + .long 1073034283 + .long 3712504873 + .long 1073064711 + .long 2956612997 + .long 1073095806 + .long 1719614413 + .long 1073127582 + .long 3907805044 + .long 1073160053 + .long 1944781191 + .long 1073193236 + .long 2571947539 + .long 1073227145 + .long 1110089947 + .long 1073261797 + .long 2966275557 + .long 1073297207 + .long 2191782032 + .long 1073333393 + .long 2990417245 + .long 1073370371 + .long 2572866477 + .long 1073408159 + .long 4076559943 + .long 1073446774 + .long 3716502172 + .long 1073486235 + .long 3706687593 + .long 1073526560 + .long 3707479175 + .long 1073567768 + .long 863738719 + .long 1073609879 + .long 2728693978 + .long 1073652911 + .long 1533953344 + .long 1073696886 + .type B_table,@object + .size B_table,1312 + .align 16 +cv: + .long 531389993 + .long 1067950900 + .long 4289495988 + .long 1069842387 + .long 2705553552 + .long 3216330822 + .long 4277811695 + .long 3218484802 + .type cv,@object + .size cv,32 + .align 16 +cev: + .long 1874480759 + .long 1065595563 + .long 4286760334 + .long 1070514109 + .long 3607404735 + .long 1068264200 + .long 4277811695 + .long 1072049730 + .type cev,@object + .size cev,32 + .align 16 +ABSVALMASK: + .long 4294967295 + .long 2147483647 + .type ABSVALMASK,@object + .size ABSVALMASK,8 + .space 8, 0x00 # pad + .align 16 +ABSVALS: + .long 2147483647 + .long 0 + .long 0 + .long 0 + .type ABSVALS,@object + .size ABSVALS,16 + .align 8 +EXPMASK: + .long 0 + .long 1072693248 + .type EXPMASK,@object + .size EXPMASK,8 + .align 4 +ONEMASK: + .long 1065353216 + .type ONEMASK,@object + .size ONEMASK,4 + .align 4 +sNaN: + .long 2139095041 + .type sNaN,@object + .size sNaN,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/powl.S b/external/sgx_libm/intel64/powl.S new file mode 100644 index 0000000000..564551d4bc --- /dev/null +++ b/external/sgx_libm/intel64/powl.S @@ -0,0 +1,2945 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "powl.c" + .text +..TXTST0: +# -- Begin powl + .text + .align 16,0x90 + .globl powl +powl: +# parameter 1: 336 + %rsp +# parameter 2: 352 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_powl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $280, %rsp + .cfi_def_cfa_offset 336 + xorb %r10b, %r10b + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 264(%rsp) +..B1.2: + fnstcw 250(%rsp) +..B1.3: + movzbl 345(%rsp), %ecx + xorl %r15d, %r15d + shrl $7, %ecx + movzwl 344(%rsp), %r14d + shll $15, %ecx + andl $32767, %r14d + movl 340(%rsp), %edx + orl %r14d, %ecx + movl %edx, %eax + movzbl 361(%rsp), %r8d + shrl $7, %r8d + shll $16, %ecx + shrl $16, %eax + movzwl 360(%rsp), %r12d + orl %eax, %ecx + shll $15, %r8d + andl $32767, %r12d + movl 356(%rsp), %eax + orl %r12d, %r8d + movl %eax, %ebx + movl %ecx, %r9d + shll $16, %r8d + andl $2147483647, %r9d + shrl $16, %ebx + cmpl $1073709056, %r9d + movl %ecx, %r13d + setb %r15b + orl %ebx, %r8d + movl %r8d, %ebp + andl $2147483647, %r8d + shrl $31, %ebp + movl %ebp, 128(%rsp) + xorl %ebp, %r15d + movl %r8d, %ebp + orl %eax, %ebp + shrl $31, %r13d + movl 352(%rsp), %r11d + orl %r11d, %ebp + movl 336(%rsp), %ebx + movl %r15d, 256(%rsp) + je ..B1.5 +..B1.4: + addl $-1073709056, %ecx + lea -2147483648(%rdx), %r15d + orl %r15d, %ecx + movl %r15d, 24(%rsp) + orl %ebx, %ecx + jne ..B1.11 +..B1.5: + cmpl $2147450880, %r8d + jae ..B1.8 +..B1.6: + cmpl $2147450880, %r9d + jb ..B1.9 +..B1.7: + addl $-2147483648, %edx + orl %ebx, %edx + je ..B1.9 +..B1.8: + fldt 336(%rsp) + fldt 352(%rsp) + fmulp %st, %st(1) + fstpt 224(%rsp) +..B1.9: + lea _ones(%rip), %rax + movq 264(%rsp), %rdx + xorq %rsp, %rdx + cmpq %fs:40, %rdx + movsd (%rax), %xmm0 + jne ..B1.155 +..B1.10: + movsd %xmm0, (%rsp) + fldl (%rsp) + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.11: + xorl %ecx, %ecx + lea -1073709056(%r8), %r15d + movq %rcx, 16(%rsp) + cmpl $4194304, %r15d + movq %rcx, 240(%rsp) + movl %r15d, 8(%rsp) + jae ..B1.16 +..B1.12: + movl %r8d, %edi + shrl $16, %edi + cmpl $1075806208, %r8d + ja ..B1.14 +..B1.13: + movl %edi, %ecx + movl %eax, %ebp + negl %ecx + addl $30, %ecx + shrl %cl, %ebp + movl %ebp, (%rsp) + lea 2(%rdi), %ecx + movl %eax, %ebp + shll %cl, %ebp + orl %r11d, %ebp + cmpl $1075740672, %r8d + cmova %r11d, %ebp + jmp ..B1.15 +..B1.14: + movl %edi, %ecx + movl %r11d, %ebp + negl %ecx + xorl %r15d, %r15d + addl $30, %ecx + shrl %cl, %ebp + movl %ebp, (%rsp) + lea 2(%rdi), %ecx + movl %r11d, %ebp + shll %cl, %ebp + cmpl $1077837824, %r8d + cmovae %r15d, %ebp +..B1.15: + xorl %ecx, %ecx + andl $1, (%rsp) + movl %r13d, %r15d + cmove %rcx, %r15 + movl (%rsp), %ecx + movq %r15, 240(%rsp) + movq %rcx, 16(%rsp) + jmp ..B1.17 +..B1.16: + xorl %ecx, %ecx + cmpl $1073709056, %r8d + cmovae %ecx, %ebp +..B1.17: + cmpl $32767, %r14d + je ..B1.233 +..B1.18: + cmpl $32767, %r12d + je ..B1.189 +..B1.19: + movl %edx, %ecx + andl $2147483647, %ecx + orl %ebx, %ecx + jne ..B1.26 +..B1.20: + movl %edx, %ecx + orl %r9d, %ecx + jne ..B1.26 +..B1.21: + movl $1, %edx + xorl %ecx, %ecx + testl %ebp, %ebp + cmove %edx, %ecx + movq 240(%rsp), %rax + andl %ecx, %eax + cmpl $0, 128(%rsp) + jne ..B1.157 +..B1.22: + cmpl $65536, %r8d + jae ..B1.24 +..B1.23: + lea _smallest_value_64(%rip), %rdx + movq (%rdx), %rcx + movq %rcx, 216(%rsp) +..B1.24: + movl %eax, %eax + lea _zeros(%rip), %rdx + movq 264(%rsp), %rcx + xorq %rsp, %rcx + cmpq %fs:40, %rcx + movsd (%rdx,%rax,8), %xmm0 + jne ..B1.155 +..B1.25: + movsd %xmm0, (%rsp) + fldl (%rsp) + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.26: + testl %r13d, %r13d + je ..B1.32 +..B1.27: + cmpl $1077837824, %r8d + jae ..B1.29 +..B1.28: + testl %ebp, %ebp + jne ..B1.160 +..B1.29: + lea -1073709056(%r9), %ecx + orl 24(%rsp), %ecx + orl %ebx, %ecx + jne ..B1.32 +..B1.30: + lea _ones(%rip), %rax + movq 16(%rsp), %rdx + movq 264(%rsp), %rcx + xorq %rsp, %rcx + movsd (%rax,%rdx,8), %xmm0 + cmpq %fs:40, %rcx + jne ..B1.155 +..B1.31: + movsd %xmm0, (%rsp) + fldl (%rsp) + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.32: + lea -65536(%r9), %r12d + lea -65536(%r8), %ecx + orl %ecx, %r12d + testl $-2147483648, %r12d + je ..B1.34 +..B1.33: + lea _smallest_value_64(%rip), %rcx + movq (%rcx), %r12 + movq %r12, 216(%rsp) +..B1.34: + movl %eax, %ecx + andl $2147483647, %ecx + orl %r11d, %ecx + jne ..B1.67 +..B1.35: + cmpl $1073709056, %r8d + jne ..B1.47 +..B1.36: + cmpl $0, 128(%rsp) + je ..B1.45 +..B1.37: + movzwl 250(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.41 +..B1.38: + orl $-64768, %edx + movw %dx, 248(%rsp) +..B1.39: + fldcw 248(%rsp) +..B1.40: + movb $1, %r10b +..B1.41: + fldt 336(%rsp) + lea _ones(%rip), %rax + testb %r10b, %r10b + movsd (%rax), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fdivp %st, %st(1) + fstpt 144(%rsp) + je ..B1.43 +..B1.42: + fldcw 250(%rsp) +..B1.43: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.44: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.45: + fldt 336(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.46: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.47: + cmpl $1073643520, %r8d + jne ..B1.67 +..B1.48: + movzwl 250(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.52 +..B1.49: + orl $-64768, %edx + movw %dx, 248(%rsp) +..B1.50: + fldcw 248(%rsp) +..B1.51: + movb $1, %r10b +..B1.52: + cmpl $0, 128(%rsp) + je ..B1.60 +..B1.53: + fldt 336(%rsp) + lea _ones(%rip), %rcx + movzbl 345(%rsp), %ebp + shrl $7, %ebp + movzwl 344(%rsp), %eax + shll $15, %ebp + andl $32767, %eax + orl %eax, %ebp + shll $16, %ebp + movzwl 342(%rsp), %edx + orl %edx, %ebp + fstpt 32(%rsp) + fldt 32(%rsp) + fstp %st(0) + fldl (%rcx) + fstpt (%rsp) + fldt (%rsp) + lea -536838144(%rbp), %ebx + cmpl $1073741824, %ebx + jbe ..B1.57 +..B1.54: + cmpl $536838144, %ebp + jae ..B1.56 +..B1.55: + fldt 32(%rsp) + lea _invsqrtl_scales(%rip), %rax + lea 16+_invsqrtl_scales(%rip), %rdx + fldt (%rax) + fmulp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + fstp %st(0) + fldt (%rdx) + fstpt (%rsp) + jmp ..B1.57 +..B1.56: + fldt 32(%rsp) + lea 32+_invsqrtl_scales(%rip), %rax + lea 48+_invsqrtl_scales(%rip), %rdx + fldt (%rax) + fmulp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + fstp %st(0) + fldt (%rdx) + fstpt (%rsp) +..B1.57: + fldt 32(%rsp) + lea _TWO_43H(%rip), %rax + fld %st(0) + fxch %st(1) + fdivr %st, %st(2) + fxch %st(2) + fstpt 64(%rsp) + fldl (%rax) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) + fstpt 32(%rsp) +..B1.58: + fldt 64(%rsp) + fsqrt + fstpt 96(%rsp) +..B1.59: + fldt 96(%rsp) + fld %st(0) + fldt 16(%rsp) + fld %st(0) + fldt 32(%rsp) + fmul %st(4), %st + fldl (%rax) + lea 8+_ones(%rip), %rax + fmul %st(5), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(3) + fsubr %st(5), %st + fmul %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fld %st(1) + fxch %st(3) + fmul %st(4), %st + fmul %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fmul %st(3), %st + fldt .L_2il0floatpacket.0(%rip) + fldt (%rsp) + fxch %st(2) + faddl (%rax) + faddp %st, %st(4) + fxch %st(5) + fmulp %st, %st(3) + fxch %st(4) + fmulp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 144(%rsp) + jmp ..B1.63 +..B1.60: + fldt 336(%rsp) + fstpt 48(%rsp) +..B1.61: + fldt 48(%rsp) + fsqrt + fstpt 80(%rsp) +..B1.62: + fldt 80(%rsp) + fstpt 144(%rsp) +..B1.63: + testb %r10b, %r10b + je ..B1.65 +..B1.64: + fldcw 250(%rsp) +..B1.65: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.66: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.67: + movzwl 250(%rsp), %r11d + movl %r11d, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.71 +..B1.68: + orl $-64768, %r11d + movw %r11w, 248(%rsp) +..B1.69: + fldcw 248(%rsp) +..B1.70: + movb $1, %r10b +..B1.71: + fldt 336(%rsp) + lea _ones(%rip), %r11 + testl %ebp, %ebp + fmull (%r11,%r13,8) + fstpt 336(%rsp) + fldt 336(%rsp) + jne ..B1.100 +..B1.72: + cmpl $1048576, 8(%rsp) + jae ..B1.100 +..B1.73: + movl %r8d, %ecx + lea _exact_masks(%rip), %r12 + shrl $16, %ecx + negl %ecx + addl $30, %ecx + shrl %cl, %eax + cmpl $46, %eax + lea -2(%rax), %edi + jb ..L136 + movl $46, %edi +..L136: + movslq %edi, %rdi + movl 4(%r12,%rdi,8), %ebp + andl %ebp, %edx + movl (%r12,%rdi,8), %r13d + andl %r13d, %ebx + orl %ebx, %edx + jne ..B1.100 +..B1.74: + movq 240(%rsp), %rdx + cmpl $65535, %r9d + fldl (%r11,%rdx,8) + ja ..B1.76 +..B1.75: + lea _TWO_75(%rip), %rdx + fldl (%rdx) + fmulp %st, %st(2) + fxch %st(1) + fstpt 176(%rsp) + movzwl 184(%rsp), %ebp + movl %ebp, %ebx + andl $32767, %ebx + addl $-16458, %ebx + jmp ..B1.77 +..B1.76: + movzwl 344(%rsp), %ebx + fxch %st(1) + fstpt 176(%rsp) + andl $32767, %ebx + movzwl 184(%rsp), %ebp + addl $-16383, %ebx +..B1.77: + lea iones(%rip), %rdx + andl $-32768, %ebp + movl 128(%rsp), %ecx + orl $-49153, %ebp + movw %bp, 184(%rsp) + movl (%rdx,%rcx,4), %edx + imull %eax, %edx + imull %ebx, %edx + lea 16445(%rdx), %ebx + cmpl $32829, %ebx + lea 16383(%rdx), %ecx + jb ..B1.85 +..B1.78: + shlq $4, 240(%rsp) + cmpl $-63, %ecx + jg ..B1.80 +..B1.79: + lea _small_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) + jmp ..B1.81 +..B1.80: + lea _large_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) +..B1.81: + fstpt 144(%rsp) + testb %r10b, %r10b + je ..B1.245 +..B1.82: + fstpt 32(%rsp) +..B1.237: + fldcw 250(%rsp) + jmp ..B1.83 +..B1.245: + fstp %st(0) +..B1.83: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.84: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.85: + fstpt 32(%rsp) + testl %ecx, %ecx + jg ..B1.87 +..B1.86: + addl $16458, %edx + movzwl 40(%rsp), %ecx + andl $32767, %edx + andl $-32768, %ecx + orl %edx, %ecx + lea 8+_TWO_75(%rip), %rdx + movw %cx, 40(%rsp) + fldt 32(%rsp) + fmull (%rdx) + fstpt 32(%rsp) + fldt 32(%rsp) + jmp ..B1.88 +..B1.87: + movzwl 40(%rsp), %edx + andl $32767, %ecx + andl $-32768, %edx + orl %ecx, %edx + movw %dx, 40(%rsp) + fldt 32(%rsp) +..B1.88: + cmpl $-2147483648, 180(%rsp) + jne ..B1.95 +..B1.89: + cmpl $0, 176(%rsp) + jne ..B1.95 +..B1.90: + fstpt 144(%rsp) +..B1.91: + testb %r10b, %r10b + je ..B1.93 +..B1.92: + fldcw 250(%rsp) +..B1.93: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.94: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.95: + fldt 176(%rsp) + lea _zeros(%rip), %rdx + fstpt 112(%rsp) + fldt 112(%rsp) + fldl (%r11) + movl $0, 112(%rsp) + fld %st(0) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fldt 112(%rsp) + fsubr %st, %st(3) + fldl (%rdx) + jmp ..B1.96 +..B1.99: + fld %st(1) + fadd %st(5), %st + fld %st(2) + fmul %st(6), %st + fxch %st(1) + fmulp %st, %st(6) + faddp %st, %st(5) + fld %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + movl $0, 112(%rsp) + fldt 112(%rsp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(5) + fxch %st(1) +..B1.96: + testb $1, %al + je ..B1.98 +..B1.97: + fld %st(1) + fadd %st(5), %st + fmulp %st, %st(1) + fld %st(4) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(1) + fmulp %st, %st(4) + fxch %st(3) + fstpt 16(%rsp) + fldt 16(%rsp) + movl $0, 16(%rsp) + fldt 16(%rsp) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(4) + fxch %st(3) +..B1.98: + shrl $1, %eax + testl %eax, %eax + je ..B1.169 + jmp ..B1.99 +..B1.100: + lea -1073676224(%r9), %eax + cmpl $32864, %eax + jae ..B1.102 +..B1.101: + lea 8+_ones(%rip), %rdx + lea _TWO_32H(%rip), %rcx + movb $1, %al + fldl (%rdx) + faddp %st, %st(1) + fld %st(0) + fld %st(1) + fxch %st(2) + fstpt 192(%rsp) + fldt 192(%rsp) + fldl (%rcx) + fmul %st, %st(2) + fxch %st(2) + fadd %st, %st(3) + fsubrp %st, %st(3) + fsub %st(2), %st + fxch %st(2) + jmp ..B1.106 +..B1.102: + xorb %al, %al + cmpl $65535, %r9d + ja ..B1.104 +..B1.103: + lea _TWO_75(%rip), %rdx + fldl (%rdx) + fmulp %st, %st(1) + fstpt 176(%rsp) + movzwl 184(%rsp), %edx + movl %edx, %edi + andl $32767, %edi + addl $-16458, %edi + jmp ..B1.105 +..B1.104: + movzwl 344(%rsp), %edi + fstpt 176(%rsp) + andl $32767, %edi + movzwl 184(%rsp), %edx + addl $-16383, %edi +..B1.105: + andl $-32768, %edx + lea 8+_ones(%rip), %rbx + orl $-49153, %edx + movw %dx, 184(%rsp) + lea _TWO_32H(%rip), %rdx + fldt 176(%rsp) + fld %st(0) + fld %st(1) + movl 180(%rsp), %esi + fldl (%rdx) + fmul %st, %st(2) + movq __libm_rcp_table_256@GOTPCREL(%rip), %rcx + fxch %st(1) + fadd %st(2), %st + shrl $23, %esi + fsubp %st, %st(2) + movzbl %sil, %esi + fxch %st(1) + fsubr %st, %st(2) + flds (%rcx,%rsi,4) + fmul %st, %st(1) + fmulp %st, %st(3) + faddl (%rbx) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fstpt 192(%rsp) + fldt 192(%rsp) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) +..B1.106: + fldt 192(%rsp) + lea 128+_LP(%rip), %rdx + fld %st(0) + lea 112+_LP(%rip), %rcx + lea 96+_LP(%rip), %rbx + lea 80+_LP(%rip), %rbp + lea 64+_LP(%rip), %r9 + lea 48+_LP(%rip), %r12 + lea 32+_LP(%rip), %r13 + lea 16+_LP(%rip), %r14 + lea _LP(%rip), %r15 + testb %al, %al + fadd %st(2), %st + fmul %st(4), %st + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + fmul %st(0), %st + fld %st(0) + fadd %st(3), %st + fld %st(0) + fxch %st(6) + fstpt 16(%rsp) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(6) + fsubrp %st, %st(6) + fxch %st(1) + fsub %st(5), %st + faddp %st, %st(3) + fldt (%rdx) + fmul %st(1), %st + fldt (%rcx) + fmul %st(2), %st + fldt (%rbx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rbp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r12) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r13) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r14) + faddp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fmul %st(4), %st + fld %st(2) + fadd %st(1), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fmul %st(4), %st + fldt (%r15) + fmul %st, %st(5) + fld %st(5) + fadd %st(2), %st + fsubr %st, %st(6) + fxch %st(2) + faddp %st, %st(6) + fmulp %st, %st(3) + fxch %st(1) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fldt (%rsp) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(1) + fadd %st(4), %st + fldt 16(%rsp) + faddp %st, %st(3) + faddp %st, %st(2) + je ..B1.108 +..B1.107: + fld %st(0) + fld %st(1) + fxch %st(2) + fxch %st(5) + fxch %st(2) + jmp ..B1.109 +..B1.108: + fstp %st(3) + movslq %esi, %rsi + pxor %xmm0, %xmm0 + lea _LT2(%rip), %rax + movq %rsi, %rdx + shlq $4, %rdx + lea _LLN2(%rip), %rbp + movq __libm_logl_table_256@GOTPCREL(%rip), %rcx + lea 16+_LLN2(%rip), %rbx + cvtss2sd (%rax,%rsi,4), %xmm0 + fldl (%rdx,%rcx) + fldt (%rbx) + fldt (%rbp) + addsd 8(%rdx,%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + movl %edi, (%rsp) + fildl (%rsp) + fmul %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(2) + fadd %st(1), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(4), %st + fld %st(0) + fld %st(2) + fsub %st(2), %st + fadd %st(6), %st + faddp %st, %st(4) +..B1.109: + fld %st(1) + fadd %st(4), %st + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 24(%rsp), %edx + shll $16, %edx + movzwl 22(%rsp), %eax + orl %eax, %edx + andl $2147483647, %edx + lea -1610514432(%rdx,%r8), %ecx + cmpl $538050560, %ecx + lea (%r8,%rdx), %eax + jbe ..B1.123 +..B1.110: + cmpl $-2146402304, %eax + jbe ..B1.118 +..B1.111: + fstp %st(4) + fstp %st(4) + fstp %st(2) + fstp %st(1) + shlq $4, 240(%rsp) + cmpl $0, 256(%rsp) + je ..B1.113 +..B1.112: + lea _small_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) + jmp ..B1.114 +..B1.113: + lea _large_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) +..B1.114: + fstpt 144(%rsp) + testb %r10b, %r10b + je ..B1.246 +..B1.115: + fldt 32(%rsp) + fstpt 160(%rsp) + fxch %st(2) + fstpt 112(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) + fldt 192(%rsp) + fstpt 176(%rsp) +..B1.238: + fldcw 250(%rsp) + jmp ..B1.116 +..B1.246: + fstp %st(2) + fstp %st(1) + fstp %st(0) +..B1.116: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.117: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.118: + cmpl $1610514432, %eax + jae ..B1.123 +..B1.119: + fstp %st(4) + fstp %st(4) + fstp %st(2) + fstp %st(1) + movq 240(%rsp), %rcx + lea _small_value_80(%rip), %rdx + movl %ecx, %eax + xorl 256(%rsp), %eax + shlq $4, %rax + testb %r10b, %r10b + fldt (%rdx,%rax) + faddl (%r11,%rcx,8) + fstpt 144(%rsp) + je ..B1.247 +..B1.120: + fldt 32(%rsp) + fstpt 160(%rsp) + fxch %st(2) + fstpt 112(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) + fldt 192(%rsp) + fstpt 176(%rsp) +..B1.239: + fldcw 250(%rsp) + jmp ..B1.121 +..B1.247: + fstp %st(2) + fstp %st(1) + fstp %st(0) +..B1.121: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.122: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.123: + fstp %st(1) + fld %st(0) + fmul %st(5), %st + movq 240(%rsp), %rax + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fld %st(3) + fldt 352(%rsp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 128(%rsp) + fldt 128(%rsp) + fsubp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fmul %st(3), %st + fxch %st(5) + fmulp %st, %st(1) + faddp %st, %st(4) + fld %st(3) + fxch %st(1) + fmulp %st, %st(2) + fadd %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fldl (%r11,%rax,8) + movzwl 24(%rsp), %eax + shll $16, %eax + movzwl 22(%rsp), %edx + orl %edx, %eax + andl $2147483647, %eax + fstpl 208(%rsp) + cmpl $1072398336, %eax + jae ..B1.131 +..B1.124: + fstp %st(4) + cmpl $1069318144, %eax + jae ..B1.126 +..B1.125: + fstp %st(2) + fldl 208(%rsp) + fmul %st, %st(3) + faddp %st, %st(3) + fxch %st(1) + fxch %st(2) + jmp ..B1.127 +..B1.126: + lea 16+_EP1(%rip), %rax + lea _EP1(%rip), %rdx + fldt (%rax) + fmul %st(4), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(4), %st + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fldl 208(%rsp) + fmul %st, %st(1) + faddp %st, %st(1) +..B1.127: + fstpt 144(%rsp) + testb %r10b, %r10b + je ..B1.248 +..B1.128: + fldt 128(%rsp) + fstpt 160(%rsp) + fstpt 16(%rsp) + fxch %st(1) + fstpt 112(%rsp) + fstpt (%rsp) + fldt 192(%rsp) + fstpt 176(%rsp) + fldl 208(%rsp) + fstpt 32(%rsp) +..B1.240: + fldcw 250(%rsp) + jmp ..B1.129 +..B1.248: + fstp %st(2) + fstp %st(1) + fstp %st(0) +..B1.129: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.130: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.131: + fldt .L_2il0floatpacket.1(%rip) + lea _TWO_63H(%rip), %rdx + fmul %st(1), %st + lea ESC2_BIAS(%rip), %rbx + fxch %st(1) + fstpt 144(%rsp) + fldl (%rdx) + movl 256(%rsp), %eax + fadd %st, %st(1) + fxch %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + fsubp %st, %st(1) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(1), %st + movl 160(%rsp), %edx + movl %edx, %esi + movsbq %dl, %rcx + fsubr %st(2), %st + fldt .L_2il0floatpacket.3(%rip) + subl %ecx, %esi + fmulp %st, %st(2) + fld %st(0) + sarl $8, %esi + fsub %st(2), %st + movl (%rbx,%rax,4), %ebp + fadd %st(6), %st + fstpt 128(%rsp) + fldt 128(%rsp) + lea -1(%rbp,%rsi), %edi + cmpl $32766, %edi + lea (%rbp,%rsi), %ebx + fsubp %st, %st(6) + fsub %st(5), %st + fsubp %st, %st(1) + fstpt 112(%rsp) + fldt 144(%rsp) + jb ..B1.139 +..B1.132: + fstp %st(0) + fstp %st(2) + fstp %st(2) + shlq $4, 240(%rsp) + cmpl $1, %ebx + jg ..B1.134 +..B1.133: + lea _small_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) + jmp ..B1.135 +..B1.134: + lea _large_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) +..B1.135: + fstpt 144(%rsp) + testb %r10b, %r10b + je ..B1.249 +..B1.136: + fldt 128(%rsp) + fstpt 160(%rsp) + fxch %st(1) + fstpt 16(%rsp) + fxch %st(1) + fstpt 112(%rsp) + fstpt (%rsp) + fldt 192(%rsp) + fstpt 176(%rsp) + fldl 208(%rsp) + fstpt 32(%rsp) +..B1.241: + fldcw 250(%rsp) + jmp ..B1.137 +..B1.249: + fstp %st(2) + fstp %st(0) + fstp %st(0) +..B1.137: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.138: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.139: + fldl 208(%rsp) + andl $32767, %ebx + fstpt 32(%rsp) + fld %st(4) + fxch %st(2) + fstpt 16(%rsp) + lea 48+_EP(%rip), %rsi + movzwl 40(%rsp), %ebp + lea 32+_EP(%rip), %rdi + andl $-32768, %ebp + lea 16+_EP(%rip), %r8 + fstpt 144(%rsp) + orl %ebx, %ebp + lea 64+_EP(%rip), %rbx + lea _EP(%rip), %r9 + fxch %st(1) + fstpt (%rsp) + addl $4196735, %edx + fldt 112(%rsp) + movslq %ecx, %rcx + faddp %st, %st(2) + shlq $4, %rcx + fadd %st(1), %st + fld %st(0) + cmpl $3070, %edx + fmul %st(1), %st + fldt (%rbx) + fmul %st(1), %st + fldt (%rsi) + fmul %st(2), %st + fldt (%rdi) + movq __libm_expl_table_256@GOTPCREL(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + movw %bp, 40(%rsp) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fmulp %st, %st(3) + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fxch %st(1) + fadd %st(2), %st + fldl 2048(%rcx,%r11) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fxch %st(1) + fmul %st, %st(3) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(1) + fmull 2056(%rcx,%r11) + faddp %st, %st(2) + fldt 16(%rsp) + fxch %st(3) + faddl 2056(%rcx,%r11) + faddp %st, %st(2) + fldt 144(%rsp) + fldt (%rsp) + ja ..B1.142 +..B1.140: + lea _Eexpbut(%rip), %rdx + fldt (%rdx) + fcomip %st(2), %st + jbe ..B1.142 +..B1.141: + fstp %st(1) + fld %st(1) + lea _TWO_12H(%rip), %rdx + shlq $4, %rax + fadd %st(3), %st + fldl (%rdx) + lea _ESC2(%rip), %rcx + fmul %st(1), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 128(%rsp) + fldt 128(%rsp) + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt (%rax,%rcx) + fldt 32(%rsp) + fmul %st, %st(3) + fxch %st(1) + fmul %st, %st(3) + fxch %st(4) + fmulp %st, %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 144(%rsp) + jmp ..B1.143 +..B1.142: + fstp %st(1) + shlq $4, %rax + lea _ESC2(%rip), %rdx + fldt (%rax,%rdx) + fmul %st, %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 32(%rsp) + fmulp %st, %st(1) + fstpt 144(%rsp) +..B1.143: + movzwl 152(%rsp), %ecx + shll $16, %ecx + movzwl 150(%rsp), %eax + orl %eax, %ecx + andl $2147483647, %ecx + lea -98304(%rcx), %edx + cmpl $2147319808, %edx + jb ..B1.151 +..B1.144: + shlq $4, 240(%rsp) + cmpl $65535, %ecx + ja ..B1.146 +..B1.145: + lea _small_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) + fstpt 224(%rsp) + jmp ..B1.147 +..B1.146: + lea _large_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) + fstpt 144(%rsp) +..B1.147: + testb %r10b, %r10b + je ..B1.250 +..B1.148: + fldt 128(%rsp) + fstpt 160(%rsp) + fxch %st(2) + fstpt 112(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) + fldt 192(%rsp) + fstpt 176(%rsp) +..B1.242: + fldcw 250(%rsp) + jmp ..B1.149 +..B1.250: + fstp %st(2) + fstp %st(1) + fstp %st(0) +..B1.149: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.150: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.151: + testb %r10b, %r10b + je ..B1.251 +..B1.152: + fldt 128(%rsp) + fstpt 160(%rsp) + fxch %st(2) + fstpt 112(%rsp) + fstpt (%rsp) + fstpt 16(%rsp) + fldt 192(%rsp) + fstpt 176(%rsp) +..B1.243: + fldcw 250(%rsp) + jmp ..B1.153 +..B1.251: + fstp %st(2) + fstp %st(1) + fstp %st(0) +..B1.153: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.154: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.155: + call __stack_chk_fail@PLT +..B1.157: + lea _ones(%rip), %rdx + lea _zeros(%rip), %rcx + movsd (%rdx,%rax,8), %xmm0 + divsd (%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + movq 264(%rsp), %rbx + xorq %rsp, %rbx + cmpq %fs:40, %rbx + je ..B1.44 +..B1.159: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.160: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + movq 264(%rsp), %rcx + xorq %rsp, %rcx + cmpq %fs:40, %rcx + jne ..B1.159 + jmp ..B1.44 +..B1.169: + fstp %st(4) + fstp %st(0) + cmpl $0, 128(%rsp) + jne ..B1.171 +..B1.170: + fstp %st(0) + fstpt (%rsp) + fldt (%rsp) + jmp ..B1.172 +..B1.171: + fld %st(1) + lea 8+_ones(%rip), %rax + fadd %st(3), %st + fdivr %st, %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fld %st(0) + movl $0, (%rsp) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fldt (%rsp) + fmul %st, %st(5) + fsubr %st, %st(2) + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(5) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddl (%rax) + faddp %st, %st(4) + fmulp %st, %st(3) + fsubp %st, %st(2) +..B1.172: + fld %st(0) + fmul %st(3), %st + fld %st(0) + fld %st(4) + fmul %st(4), %st + fadd %st(1), %st + fstpt 144(%rsp) + movzwl 152(%rsp), %edx + shll $16, %edx + movzwl 150(%rsp), %eax + orl %eax, %edx + andl $2147483647, %edx + cmpl $65535, %edx + ja ..B1.174 +..B1.173: + fld %st(4) + fdivrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + fadd %st, %st(3) + fxch %st(3) + fmul %st(4), %st + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fadd %st(1), %st + fstpt 144(%rsp) + fldt 144(%rsp) + movzwl 152(%rsp), %edx + shll $16, %edx + movzwl 150(%rsp), %eax + orl %eax, %edx + andl $2147483647, %edx + fxch %st(1) + fxch %st(3) + fxch %st(2) +..B1.174: + fstp %st(1) + fstp %st(1) + fstp %st(0) + fstp %st(1) + fstp %st(0) + lea -98304(%rdx), %eax + cmpl $2147319808, %eax + jb ..B1.91 +..B1.175: + shlq $4, 240(%rsp) + cmpl $65535, %edx + ja ..B1.177 +..B1.176: + lea _small_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) + fstpt 224(%rsp) + jmp ..B1.178 +..B1.177: + lea _large_value_80(%rip), %rdx + movq 240(%rsp), %rax + fldt (%rax,%rdx) + fldt (%rdx) + fmulp %st, %st(1) + fstpt 144(%rsp) +..B1.178: + testb %r10b, %r10b + je ..B1.180 +..B1.179: + fldcw 250(%rsp) +..B1.180: + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 + jmp ..B1.44 +..B1.189: + movq $0x8000000000000000, %rcx + cmpq 352(%rsp), %rcx + je ..B1.193 +..B1.190: + fldt 336(%rsp) + fldt 352(%rsp) + fmulp %st, %st(1) + fstpt 224(%rsp) + fldt 224(%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 + jmp ..B1.44 +..B1.193: + cmpl $32767, %r14d + je ..B1.223 +..B1.194: + cmpl $32767, %r12d + jne ..B1.19 +..B1.195: + cmpl $-2147483648, %eax + jne ..B1.19 +..B1.196: + testl %r11d, %r11d + jne ..B1.19 +..B1.197: + cmpl $1073709056, %r9d + jae ..B1.210 +..B1.198: + orl %r9d, %ebx + jne ..B1.203 +..B1.199: + lea _zeros(%rip), %rax + cmpl $0, 128(%rsp) + movsd (%rax), %xmm0 + jne ..B1.219 +..B1.200: + movsd %xmm0, (%rsp) + fldl (%rsp) +..B1.201: + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.202: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.203: + cmpl $65536, %r9d + jae ..B1.205 +..B1.204: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 216(%rsp) +..B1.205: + cmpl $0, 128(%rsp) + je ..B1.207 +..B1.206: + lea _infs(%rip), %rax + fldl (%rax) + jmp ..B1.208 +..B1.207: + lea _zeros(%rip), %rax + fldl (%rax) +..B1.208: + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.209: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.210: + addl $-1073709056, %r9d + orl 24(%rsp), %r9d + orl %ebx, %r9d + je ..B1.216 +..B1.211: + cmpl $0, 128(%rsp) + je ..B1.213 +..B1.212: + lea _zeros(%rip), %rax + fldl (%rax) + jmp ..B1.214 +..B1.213: + lea _infs(%rip), %rax + fldl (%rax) +..B1.214: + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 +..B1.215: + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.216: + lea _ones(%rip), %rax + movq 16(%rsp), %rdx + movq 264(%rsp), %rcx + xorq %rsp, %rcx + movsd (%rax,%rdx,8), %xmm0 + cmpq %fs:40, %rcx + jne ..B1.155 +..B1.217: + movsd %xmm0, (%rsp) + fldl (%rsp) + addq $280, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 336 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.219: + lea _ones(%rip), %rax + movsd (%rax), %xmm1 + divsd %xmm0, %xmm1 + movsd %xmm1, (%rsp) + fldl (%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + jmp ..B1.201 +..B1.223: + cmpl $-2147483648, %edx + jne ..B1.194 +..B1.224: + testl %ebx, %ebx + jne ..B1.194 +..B1.225: + cmpl $65536, %r8d + jae ..B1.227 +..B1.226: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 216(%rsp) +..B1.227: + xorl %eax, %eax + testl %ebp, %ebp + je ..L377 + movq %rax, 240(%rsp) +..L377: + cmpl $0, 128(%rsp) + je ..B1.229 +..B1.228: + lea _zeros(%rip), %rax + movq 240(%rsp), %rdx + fldl (%rax,%rdx,8) + jmp ..B1.230 +..B1.229: + lea _infs(%rip), %rax + movq 240(%rsp), %rdx + fldl (%rax,%rdx,8) +..B1.230: + movq 264(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.159 + jmp ..B1.44 +..B1.233: + movq $0x8000000000000000, %rcx + cmpq 336(%rsp), %rcx + jne ..B1.190 +..B1.234: + cmpl $32767, %r12d + je ..B1.189 + jmp ..B1.193 + .align 16,0x90 + .cfi_endproc + .type powl,@function + .size powl,.-powl + .data +# -- End powl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_43H: + .long 0 + .long 1118306304 + .type _TWO_43H,@object + .size _TWO_43H,8 + .align 4 +_exact_masks: + .long 131071 + .long 0 + .long 4294967295 + .long 1 + .long 4294967295 + .long 511 + .long 4294967295 + .long 16383 + .long 4294967295 + .long 131071 + .long 4294967295 + .long 1048575 + .long 4294967295 + .long 2097151 + .long 4294967295 + .long 8388607 + .long 4294967295 + .long 16777215 + .long 4294967295 + .long 33554431 + .long 4294967295 + .long 33554431 + .long 4294967295 + .long 67108863 + .long 4294967295 + .long 134217727 + .long 4294967295 + .long 134217727 + .long 4294967295 + .long 134217727 + .long 4294967295 + .long 268435455 + .long 4294967295 + .long 268435455 + .long 4294967295 + .long 268435455 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 536870911 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 1073741823 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .long 4294967295 + .long 2147483647 + .type _exact_masks,@object + .size _exact_masks,376 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_LT2: + .long 180342526 + .long 2357584585 + .long 2340989257 + .long 193458247 + .long 2370723239 + .long 2317577053 + .long 2382055315 + .long 232148275 + .long 200972627 + .long 2376530255 + .long 2376860906 + .long 222325808 + .long 228268523 + .long 229816737 + .long 2387925496 + .long 239088248 + .long 235445027 + .long 219576635 + .long 2365457762 + .long 200344795 + .long 2377779510 + .long 2396359259 + .long 256760275 + .long 2390604874 + .long 2403557039 + .long 2397936349 + .long 2387307486 + .long 2389941185 + .long 2375749593 + .long 224865835 + .long 2394232861 + .long 180745560 + .long 231885773 + .long 2352962188 + .long 2306055684 + .long 206875141 + .long 258325764 + .long 2386208973 + .long 231066739 + .long 195513036 + .long 2360327132 + .long 2396045581 + .long 236564318 + .long 2282584976 + .long 2351736009 + .long 236364231 + .long 2384427773 + .long 267355851 + .long 255771104 + .long 265321597 + .long 2384375360 + .long 2399209743 + .long 186438128 + .long 2407131686 + .long 2382793784 + .long 2395218767 + .long 229223248 + .long 256892528 + .long 2394735602 + .long 2385223602 + .long 2372921302 + .long 2398642377 + .long 2399679754 + .long 255686225 + .long 220689523 + .long 2385772978 + .long 209771590 + .long 2396079173 + .long 247531082 + .long 236085121 + .long 264660069 + .long 2357821390 + .long 236486650 + .long 2368138461 + .long 239690108 + .long 2396070228 + .long 196955922 + .long 217533735 + .long 255641653 + .long 249646543 + .long 253232621 + .long 246212714 + .long 2396427575 + .long 261629730 + .long 2364672847 + .long 2403865410 + .long 251273869 + .long 261125380 + .long 2388321036 + .long 2375891827 + .long 2381014317 + .long 2414822930 + .long 2406245053 + .long 2406988902 + .long 2395399973 + .long 213294711 + .long 2401319324 + .long 265450299 + .long 231845893 + .long 260578794 + .long 258934474 + .long 2368795786 + .long 2422506717 + .long 218205033 + .long 258708287 + .long 257044854 + .long 2396281866 + .long 2415975150 + .long 257697283 + .long 2393801226 + .long 2388654986 + .long 262910764 + .long 235638432 + .long 268054962 + .long 271083258 + .long 256780444 + .long 256064350 + .long 252979189 + .long 2420460964 + .long 233178508 + .long 251655134 + .long 2404577473 + .long 2408876374 + .long 2401072099 + .long 228623072 + .long 2421706621 + .long 2353033467 + .long 2411792212 + .long 2345330012 + .long 2397189005 + .long 243110369 + .long 2408213151 + .long 219253901 + .long 246695172 + .long 259288551 + .long 254210780 + .long 261865355 + .long 230359170 + .long 263524551 + .long 2405618542 + .long 2399869921 + .long 233826616 + .long 2362750769 + .long 257576291 + .long 251808114 + .long 2403390977 + .long 253249058 + .long 261065811 + .long 215406974 + .long 2407628993 + .long 258391343 + .long 2394470699 + .long 258495470 + .long 2415771687 + .long 224670583 + .long 263047889 + .long 2389031226 + .long 259453051 + .long 266564569 + .long 2422023012 + .long 264051375 + .long 2409075373 + .long 252244729 + .long 220302768 + .long 254847756 + .long 243124762 + .long 2363519942 + .long 2393496158 + .long 2402135082 + .long 2365706590 + .long 237902971 + .long 262295026 + .long 252689257 + .long 236678680 + .long 255167613 + .long 2406879752 + .long 274254693 + .long 259983961 + .long 245852525 + .long 256459527 + .long 220533989 + .long 245387845 + .long 243835221 + .long 2377853444 + .long 274540751 + .long 229741069 + .long 263626566 + .long 220608387 + .long 226161046 + .long 247301717 + .long 268433686 + .long 222008210 + .long 2414961139 + .long 276137642 + .long 2412197898 + .long 258445918 + .long 2412645341 + .long 260857859 + .long 263113037 + .long 2386484264 + .long 2390742630 + .long 259665290 + .long 2363417497 + .long 2384122046 + .long 263493300 + .long 219472625 + .long 2420433676 + .long 274201285 + .long 2404911312 + .long 257926520 + .long 260332203 + .long 256695016 + .long 218494534 + .long 2420150889 + .long 2414586287 + .long 267006159 + .long 231320206 + .long 2382797064 + .long 2414903062 + .long 263514471 + .long 2406010284 + .long 2410428205 + .long 2414319991 + .long 249083715 + .long 2381171937 + .long 236369629 + .long 2409614279 + .long 2424220710 + .long 2378379154 + .long 218677462 + .long 2382987336 + .long 2377870458 + .long 258155310 + .long 2368239928 + .long 2414896572 + .long 193310867 + .long 256673115 + .long 2406448055 + .long 271719709 + .long 248566852 + .long 229016248 + .long 272541555 + .long 2382115967 + .long 2375311600 + .long 2393766434 + .long 257187362 + .long 277931545 + .long 281038165 + .long 2373962226 + .long 261638946 + .long 255465134 + .long 273460929 + .long 275851296 + .long 2417166241 + .long 2361106656 + .long 278653754 + .type _LT2,@object + .size _LT2,1024 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +ESC2_BIAS: + .long 4095 + .long 28671 + .type ESC2_BIAS,@object + .size ESC2_BIAS,8 + .align 4 +_TWO_12H: + .long 0 + .long 1085800448 + .type _TWO_12H,@object + .size _TWO_12H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 2 +_invsqrtl_scales: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 24575 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 20479 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 8191 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 12287 + .word 0 + .word 0 + .word 0 + .type _invsqrtl_scales,@object + .size _invsqrtl_scales,64 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_LP: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 52785 + .word 52428 + .word 52428 + .word 52428 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 44453 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 25655 + .word 14678 + .word 9362 + .word 37449 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 38741 + .word 53722 + .word 65535 + .word 65535 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 45676 + .word 59527 + .word 48579 + .word 58254 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 41682 + .word 64796 + .word 25002 + .word 52429 + .word 49147 + .word 0 + .word 0 + .word 0 + .type _LP,@object + .size _LP,144 + .align 2 +_LLN2: + .word 0 + .word 53711 + .word 6135 + .word 45426 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 2022 + .word 26416 + .word 37831 + .word 62295 + .word 16333 + .word 0 + .word 0 + .word 0 + .type _LLN2,@object + .size _LLN2,32 + .align 2 +_EP1: + .word 43691 + .word 10 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30584 + .word 43703 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _EP1,@object + .size _EP1,32 + .align 2 +_EP: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _EP,@object + .size _EP,80 + .align 2 +_Eexpbut: + .word 60207 + .word 4624 + .word 35943 + .word 45420 + .word 49164 + .word 0 + .word 0 + .word 0 + .type _Eexpbut,@object + .size _Eexpbut,16 + .align 2 +_ESC2: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 28671 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 4095 + .word 0 + .word 0 + .word 0 + .type _ESC2,@object + .size _ESC2,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/q2l.S b/external/sgx_libm/intel64/q2l.S new file mode 100644 index 0000000000..6c9150bee8 --- /dev/null +++ b/external/sgx_libm/intel64/q2l.S @@ -0,0 +1,289 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "q2l.c" + .text +..TXTST0: +# -- Begin __qtol + .text + .align 16,0x90 + .globl __qtol +__qtol: +# parameter 1: %rdi +..B1.1: + .cfi_startproc +..___tag_value___qtol.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movq %rdi, %rdx + movq $0xffffffffffff, %rcx + movq 8(%rdx), %rax + movq %rax, %rsi + shrq $48, %rsi + andq %rax, %rcx + movq (%rdx), %rdi + movq %rdi, %r8 + movl %esi, %edx + shlq $15, %rcx + andl $32767, %edx + shrq $49, %r8 + shlq $15, %rdi + orq %r8, %rcx + cmpl $32767, %edx + jne ..B1.7 +..B1.2: + orq %rcx, %rdi + je ..B1.6 +..B1.3: + movq $0x4000000000000000, %rdx + testq %rcx, %rdx + jne ..B1.5 +..B1.4: + movq p_zero(%rip), %rax + movsd (%rax), %xmm0 + divsd %xmm0, %xmm0 + movsd %xmm0, (%rsp) +..B1.5: + orq %rdx, %rcx +..B1.6: + btsq $63, %rcx + movl %esi, 24(%rsp) + movq %rcx, 16(%rsp) + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.7: + testl %edx, %edx + je ..B1.9 +..B1.8: + movq $0x8000000000000000, %rax + orq %rax, %rcx + jmp ..B1.11 +..B1.9: + movq %rcx, %rax + orq %rdi, %rax + je ..B1.22 +..B1.10: + movq p_tiny(%rip), %rax + movq p_one(%rip), %r8 + movsd (%rax), %xmm0 + mulsd (%r8), %xmm0 + movsd %xmm0, (%rsp) +..B1.11: + testq %rdi, %rdi + je ..B1.21 +..B1.12: + stmxcsr 8(%rsp) +..B1.13: + movl 8(%rsp), %eax + shrl $3, %eax + andl $3072, %eax + jne ..B1.15 +..B1.14: + testq %rdi, %rdi + jl ..B1.23 + jmp ..B1.18 +..B1.15: + testl $32768, %esi + je ..B1.17 +..B1.16: + cmpl $1024, %eax + je ..B1.23 + jmp ..B1.18 +..B1.17: + cmpl $2048, %eax + je ..B1.23 +..B1.18: + testl %edx, %edx + jne ..B1.20 +..B1.19: + movq p_norm(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, (%rsp) + jmp ..B1.21 +..B1.20: + movq p_one(%rip), %rax + movq p_norm(%rip), %rdx + movsd (%rax), %xmm0 + addsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) +..B1.21: + movl %esi, 24(%rsp) + movq %rcx, 16(%rsp) + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.22: + movl %esi, 24(%rsp) + movq $0, 16(%rsp) + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.23: + incq %rcx + testl %edx, %edx + je ..B1.29 +..B1.24: + testq %rcx, %rcx + jne ..B1.28 +..B1.25: + incl %esi + movq $0x8000000000000000, %rcx + movl %esi, %edx + andl $32767, %edx +..B1.26: + cmpl $32767, %edx + jne ..B1.18 +..B1.27: + movq p_huge(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, (%rsp) + jmp ..B1.21 +..B1.28: + movq $0x8000000000000000, %rdx + movl $1, %r8d + cmpq %rdi, %rdx + movl $0, %edi + movq p_one(%rip), %r9 + movq p_norm(%rip), %r10 + cmove %r8d, %edi + testl %eax, %eax + movl $0, %eax + movsd (%r9), %xmm0 + cmove %r8d, %eax + addsd (%r10), %xmm0 + andl %eax, %edi + notl %edi + movslq %edi, %rdi + movsd %xmm0, (%rsp) + andq %rdi, %rcx + jmp ..B1.21 +..B1.29: + movq $0x8000000000000000, %rdx + movl $1, %r8d + cmpq %rdi, %rdx + movl $0, %edi + cmove %r8d, %edi + testl %eax, %eax + movl $0, %eax + cmove %r8d, %eax + andl %eax, %edi + notl %edi + movslq %edi, %rdi + andq %rdi, %rcx + jge ..B1.19 +..B1.30: + incl %esi + movl %esi, %edx + andl $32767, %edx + jmp ..B1.26 + .align 16,0x90 + .cfi_endproc + .type __qtol,@function + .size __qtol,.-__qtol + .data +# -- End __qtol + .data + .align 8 + .align 8 +p_zero: + .quad d_zero + .type p_zero,@object + .size p_zero,8 + .align 8 +p_tiny: + .quad d_tiny + .type p_tiny,@object + .size p_tiny,8 + .align 8 +p_one: + .quad d_one + .type p_one,@object + .size p_one,8 + .align 8 +p_norm: + .quad d_norm + .type p_norm,@object + .size p_norm,8 + .align 8 +p_huge: + .quad d_huge + .type p_huge,@object + .size p_huge,8 + .section .rodata, "a" + .align 8 + .align 8 +d_zero: + .long 0x00000000,0x00000000 + .type d_zero,@object + .size d_zero,8 + .align 8 +d_tiny: + .long 0x00000001,0x00000000 + .type d_tiny,@object + .size d_tiny,8 + .align 8 +d_one: + .long 0x00000000,0x3ff00000 + .type d_one,@object + .size d_one,8 + .align 8 +d_norm: + .long 0x00000000,0x00100000 + .type d_norm,@object + .size d_norm,8 + .align 8 +d_huge: + .long 0xffffffff,0x7fefffff + .type d_huge,@object + .size d_huge,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/rcp_table.S b/external/sgx_libm/intel64/rcp_table.S new file mode 100644 index 0000000000..ec4cfe363d --- /dev/null +++ b/external/sgx_libm/intel64/rcp_table.S @@ -0,0 +1,820 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rcp_table.c" + .section .rodata, "a" + .align 32 + .align 32 + .globl __libm_rcp_table_256 +__libm_rcp_table_256: + .long 0x3f7f8000 + .long 0x3f7e8000 + .long 0x3f7d8000 + .long 0x3f7c8000 + .long 0x3f7ba000 + .long 0x3f7aa000 + .long 0x3f79a000 + .long 0x3f78c000 + .long 0x3f77c000 + .long 0x3f76e000 + .long 0x3f75e000 + .long 0x3f750000 + .long 0x3f742000 + .long 0x3f732000 + .long 0x3f724000 + .long 0x3f716000 + .long 0x3f708000 + .long 0x3f6fa000 + .long 0x3f6ec000 + .long 0x3f6de000 + .long 0x3f6d0000 + .long 0x3f6c2000 + .long 0x3f6b6000 + .long 0x3f6a8000 + .long 0x3f69a000 + .long 0x3f68c000 + .long 0x3f680000 + .long 0x3f672000 + .long 0x3f666000 + .long 0x3f658000 + .long 0x3f64c000 + .long 0x3f640000 + .long 0x3f632000 + .long 0x3f626000 + .long 0x3f61a000 + .long 0x3f60e000 + .long 0x3f600000 + .long 0x3f5f4000 + .long 0x3f5e8000 + .long 0x3f5dc000 + .long 0x3f5d0000 + .long 0x3f5c4000 + .long 0x3f5b8000 + .long 0x3f5ae000 + .long 0x3f5a2000 + .long 0x3f596000 + .long 0x3f58a000 + .long 0x3f57e000 + .long 0x3f574000 + .long 0x3f568000 + .long 0x3f55e000 + .long 0x3f552000 + .long 0x3f546000 + .long 0x3f53c000 + .long 0x3f532000 + .long 0x3f526000 + .long 0x3f51c000 + .long 0x3f510000 + .long 0x3f506000 + .long 0x3f4fc000 + .long 0x3f4f2000 + .long 0x3f4e6000 + .long 0x3f4dc000 + .long 0x3f4d2000 + .long 0x3f4c8000 + .long 0x3f4be000 + .long 0x3f4b4000 + .long 0x3f4aa000 + .long 0x3f4a0000 + .long 0x3f496000 + .long 0x3f48c000 + .long 0x3f482000 + .long 0x3f478000 + .long 0x3f46e000 + .long 0x3f464000 + .long 0x3f45c000 + .long 0x3f452000 + .long 0x3f448000 + .long 0x3f43e000 + .long 0x3f436000 + .long 0x3f42c000 + .long 0x3f422000 + .long 0x3f41a000 + .long 0x3f410000 + .long 0x3f408000 + .long 0x3f3fe000 + .long 0x3f3f6000 + .long 0x3f3ec000 + .long 0x3f3e4000 + .long 0x3f3da000 + .long 0x3f3d2000 + .long 0x3f3ca000 + .long 0x3f3c0000 + .long 0x3f3b8000 + .long 0x3f3b0000 + .long 0x3f3a8000 + .long 0x3f39e000 + .long 0x3f396000 + .long 0x3f38e000 + .long 0x3f386000 + .long 0x3f37e000 + .long 0x3f376000 + .long 0x3f36c000 + .long 0x3f364000 + .long 0x3f35c000 + .long 0x3f354000 + .long 0x3f34c000 + .long 0x3f344000 + .long 0x3f33c000 + .long 0x3f334000 + .long 0x3f32e000 + .long 0x3f326000 + .long 0x3f31e000 + .long 0x3f316000 + .long 0x3f30e000 + .long 0x3f306000 + .long 0x3f2fe000 + .long 0x3f2f8000 + .long 0x3f2f0000 + .long 0x3f2e8000 + .long 0x3f2e2000 + .long 0x3f2da000 + .long 0x3f2d2000 + .long 0x3f2cc000 + .long 0x3f2c4000 + .long 0x3f2bc000 + .long 0x3f2b6000 + .long 0x3f2ae000 + .long 0x3f2a8000 + .long 0x3f2a0000 + .long 0x3f29a000 + .long 0x3f292000 + .long 0x3f28c000 + .long 0x3f284000 + .long 0x3f27e000 + .long 0x3f276000 + .long 0x3f270000 + .long 0x3f268000 + .long 0x3f262000 + .long 0x3f25c000 + .long 0x3f254000 + .long 0x3f24e000 + .long 0x3f248000 + .long 0x3f240000 + .long 0x3f23a000 + .long 0x3f234000 + .long 0x3f22e000 + .long 0x3f226000 + .long 0x3f220000 + .long 0x3f21a000 + .long 0x3f214000 + .long 0x3f20e000 + .long 0x3f206000 + .long 0x3f200000 + .long 0x3f1fa000 + .long 0x3f1f4000 + .long 0x3f1ee000 + .long 0x3f1e8000 + .long 0x3f1e2000 + .long 0x3f1dc000 + .long 0x3f1d6000 + .long 0x3f1d0000 + .long 0x3f1ca000 + .long 0x3f1c4000 + .long 0x3f1be000 + .long 0x3f1b8000 + .long 0x3f1b2000 + .long 0x3f1ac000 + .long 0x3f1a6000 + .long 0x3f1a0000 + .long 0x3f19a000 + .long 0x3f194000 + .long 0x3f190000 + .long 0x3f18a000 + .long 0x3f184000 + .long 0x3f17e000 + .long 0x3f178000 + .long 0x3f172000 + .long 0x3f16e000 + .long 0x3f168000 + .long 0x3f162000 + .long 0x3f15c000 + .long 0x3f158000 + .long 0x3f152000 + .long 0x3f14c000 + .long 0x3f148000 + .long 0x3f142000 + .long 0x3f13c000 + .long 0x3f138000 + .long 0x3f132000 + .long 0x3f12c000 + .long 0x3f128000 + .long 0x3f122000 + .long 0x3f11c000 + .long 0x3f118000 + .long 0x3f112000 + .long 0x3f10e000 + .long 0x3f108000 + .long 0x3f104000 + .long 0x3f0fe000 + .long 0x3f0f8000 + .long 0x3f0f4000 + .long 0x3f0ee000 + .long 0x3f0ea000 + .long 0x3f0e6000 + .long 0x3f0e0000 + .long 0x3f0dc000 + .long 0x3f0d6000 + .long 0x3f0d2000 + .long 0x3f0cc000 + .long 0x3f0c8000 + .long 0x3f0c2000 + .long 0x3f0be000 + .long 0x3f0ba000 + .long 0x3f0b4000 + .long 0x3f0b0000 + .long 0x3f0ac000 + .long 0x3f0a6000 + .long 0x3f0a2000 + .long 0x3f09e000 + .long 0x3f098000 + .long 0x3f094000 + .long 0x3f090000 + .long 0x3f08a000 + .long 0x3f086000 + .long 0x3f082000 + .long 0x3f07e000 + .long 0x3f078000 + .long 0x3f074000 + .long 0x3f070000 + .long 0x3f06c000 + .long 0x3f066000 + .long 0x3f062000 + .long 0x3f05e000 + .long 0x3f05a000 + .long 0x3f056000 + .long 0x3f052000 + .long 0x3f04c000 + .long 0x3f048000 + .long 0x3f044000 + .long 0x3f040000 + .long 0x3f03c000 + .long 0x3f038000 + .long 0x3f034000 + .long 0x3f030000 + .long 0x3f02a000 + .long 0x3f026000 + .long 0x3f022000 + .long 0x3f01e000 + .long 0x3f01a000 + .long 0x3f016000 + .long 0x3f012000 + .long 0x3f00e000 + .long 0x3f00a000 + .long 0x3f006000 + .long 0x3f002000 + .type __libm_rcp_table_256,@object + .size __libm_rcp_table_256,1024 + .align 32 + .globl __libm_double_rcp_table_256 +__libm_double_rcp_table_256: + .long 0 + .long 1072689152 + .long 0 + .long 1072680960 + .long 0 + .long 1072672768 + .long 0 + .long 1072664576 + .long 0 + .long 1072657408 + .long 0 + .long 1072649216 + .long 0 + .long 1072641024 + .long 0 + .long 1072633856 + .long 0 + .long 1072625664 + .long 0 + .long 1072618496 + .long 0 + .long 1072610304 + .long 0 + .long 1072603136 + .long 0 + .long 1072595968 + .long 0 + .long 1072587776 + .long 0 + .long 1072580608 + .long 0 + .long 1072573440 + .long 0 + .long 1072566272 + .long 0 + .long 1072559104 + .long 0 + .long 1072551936 + .long 0 + .long 1072544768 + .long 0 + .long 1072537600 + .long 0 + .long 1072530432 + .long 0 + .long 1072524288 + .long 0 + .long 1072517120 + .long 0 + .long 1072509952 + .long 0 + .long 1072502784 + .long 0 + .long 1072496640 + .long 0 + .long 1072489472 + .long 0 + .long 1072483328 + .long 0 + .long 1072476160 + .long 0 + .long 1072470016 + .long 0 + .long 1072463872 + .long 0 + .long 1072456704 + .long 0 + .long 1072450560 + .long 0 + .long 1072444416 + .long 0 + .long 1072438272 + .long 0 + .long 1072431104 + .long 0 + .long 1072424960 + .long 0 + .long 1072418816 + .long 0 + .long 1072412672 + .long 0 + .long 1072406528 + .long 0 + .long 1072400384 + .long 0 + .long 1072394240 + .long 0 + .long 1072389120 + .long 0 + .long 1072382976 + .long 0 + .long 1072376832 + .long 0 + .long 1072370688 + .long 0 + .long 1072364544 + .long 0 + .long 1072359424 + .long 0 + .long 1072353280 + .long 0 + .long 1072348160 + .long 0 + .long 1072342016 + .long 0 + .long 1072335872 + .long 0 + .long 1072330752 + .long 0 + .long 1072325632 + .long 0 + .long 1072319488 + .long 0 + .long 1072314368 + .long 0 + .long 1072308224 + .long 0 + .long 1072303104 + .long 0 + .long 1072297984 + .long 0 + .long 1072292864 + .long 0 + .long 1072286720 + .long 0 + .long 1072281600 + .long 0 + .long 1072276480 + .long 0 + .long 1072271360 + .long 0 + .long 1072266240 + .long 0 + .long 1072261120 + .long 0 + .long 1072256000 + .long 0 + .long 1072250880 + .long 0 + .long 1072245760 + .long 0 + .long 1072240640 + .long 0 + .long 1072235520 + .long 0 + .long 1072230400 + .long 0 + .long 1072225280 + .long 0 + .long 1072220160 + .long 0 + .long 1072216064 + .long 0 + .long 1072210944 + .long 0 + .long 1072205824 + .long 0 + .long 1072200704 + .long 0 + .long 1072196608 + .long 0 + .long 1072191488 + .long 0 + .long 1072186368 + .long 0 + .long 1072182272 + .long 0 + .long 1072177152 + .long 0 + .long 1072173056 + .long 0 + .long 1072167936 + .long 0 + .long 1072163840 + .long 0 + .long 1072158720 + .long 0 + .long 1072154624 + .long 0 + .long 1072149504 + .long 0 + .long 1072145408 + .long 0 + .long 1072141312 + .long 0 + .long 1072136192 + .long 0 + .long 1072132096 + .long 0 + .long 1072128000 + .long 0 + .long 1072123904 + .long 0 + .long 1072118784 + .long 0 + .long 1072114688 + .long 0 + .long 1072110592 + .long 0 + .long 1072106496 + .long 0 + .long 1072102400 + .long 0 + .long 1072098304 + .long 0 + .long 1072093184 + .long 0 + .long 1072089088 + .long 0 + .long 1072084992 + .long 0 + .long 1072080896 + .long 0 + .long 1072076800 + .long 0 + .long 1072072704 + .long 0 + .long 1072068608 + .long 0 + .long 1072064512 + .long 0 + .long 1072061440 + .long 0 + .long 1072057344 + .long 0 + .long 1072053248 + .long 0 + .long 1072049152 + .long 0 + .long 1072045056 + .long 0 + .long 1072040960 + .long 0 + .long 1072036864 + .long 0 + .long 1072033792 + .long 0 + .long 1072029696 + .long 0 + .long 1072025600 + .long 0 + .long 1072022528 + .long 0 + .long 1072018432 + .long 0 + .long 1072014336 + .long 0 + .long 1072011264 + .long 0 + .long 1072007168 + .long 0 + .long 1072003072 + .long 0 + .long 1072000000 + .long 0 + .long 1071995904 + .long 0 + .long 1071992832 + .long 0 + .long 1071988736 + .long 0 + .long 1071985664 + .long 0 + .long 1071981568 + .long 0 + .long 1071978496 + .long 0 + .long 1071974400 + .long 0 + .long 1071971328 + .long 0 + .long 1071967232 + .long 0 + .long 1071964160 + .long 0 + .long 1071960064 + .long 0 + .long 1071956992 + .long 0 + .long 1071953920 + .long 0 + .long 1071949824 + .long 0 + .long 1071946752 + .long 0 + .long 1071943680 + .long 0 + .long 1071939584 + .long 0 + .long 1071936512 + .long 0 + .long 1071933440 + .long 0 + .long 1071930368 + .long 0 + .long 1071926272 + .long 0 + .long 1071923200 + .long 0 + .long 1071920128 + .long 0 + .long 1071917056 + .long 0 + .long 1071913984 + .long 0 + .long 1071909888 + .long 0 + .long 1071906816 + .long 0 + .long 1071903744 + .long 0 + .long 1071900672 + .long 0 + .long 1071897600 + .long 0 + .long 1071894528 + .long 0 + .long 1071891456 + .long 0 + .long 1071888384 + .long 0 + .long 1071885312 + .long 0 + .long 1071882240 + .long 0 + .long 1071879168 + .long 0 + .long 1071876096 + .long 0 + .long 1071873024 + .long 0 + .long 1071869952 + .long 0 + .long 1071866880 + .long 0 + .long 1071863808 + .long 0 + .long 1071860736 + .long 0 + .long 1071857664 + .long 0 + .long 1071854592 + .long 0 + .long 1071851520 + .long 0 + .long 1071849472 + .long 0 + .long 1071846400 + .long 0 + .long 1071843328 + .long 0 + .long 1071840256 + .long 0 + .long 1071837184 + .long 0 + .long 1071834112 + .long 0 + .long 1071832064 + .long 0 + .long 1071828992 + .long 0 + .long 1071825920 + .long 0 + .long 1071822848 + .long 0 + .long 1071820800 + .long 0 + .long 1071817728 + .long 0 + .long 1071814656 + .long 0 + .long 1071812608 + .long 0 + .long 1071809536 + .long 0 + .long 1071806464 + .long 0 + .long 1071804416 + .long 0 + .long 1071801344 + .long 0 + .long 1071798272 + .long 0 + .long 1071796224 + .long 0 + .long 1071793152 + .long 0 + .long 1071790080 + .long 0 + .long 1071788032 + .long 0 + .long 1071784960 + .long 0 + .long 1071782912 + .long 0 + .long 1071779840 + .long 0 + .long 1071777792 + .long 0 + .long 1071774720 + .long 0 + .long 1071771648 + .long 0 + .long 1071769600 + .long 0 + .long 1071766528 + .long 0 + .long 1071764480 + .long 0 + .long 1071762432 + .long 0 + .long 1071759360 + .long 0 + .long 1071757312 + .long 0 + .long 1071754240 + .long 0 + .long 1071752192 + .long 0 + .long 1071749120 + .long 0 + .long 1071747072 + .long 0 + .long 1071744000 + .long 0 + .long 1071741952 + .long 0 + .long 1071739904 + .long 0 + .long 1071736832 + .long 0 + .long 1071734784 + .long 0 + .long 1071732736 + .long 0 + .long 1071729664 + .long 0 + .long 1071727616 + .long 0 + .long 1071725568 + .long 0 + .long 1071722496 + .long 0 + .long 1071720448 + .long 0 + .long 1071718400 + .long 0 + .long 1071715328 + .long 0 + .long 1071713280 + .long 0 + .long 1071711232 + .long 0 + .long 1071709184 + .long 0 + .long 1071706112 + .long 0 + .long 1071704064 + .long 0 + .long 1071702016 + .long 0 + .long 1071699968 + .long 0 + .long 1071696896 + .long 0 + .long 1071694848 + .long 0 + .long 1071692800 + .long 0 + .long 1071690752 + .long 0 + .long 1071688704 + .long 0 + .long 1071686656 + .long 0 + .long 1071683584 + .long 0 + .long 1071681536 + .long 0 + .long 1071679488 + .long 0 + .long 1071677440 + .long 0 + .long 1071675392 + .long 0 + .long 1071673344 + .long 0 + .long 1071671296 + .long 0 + .long 1071669248 + .long 0 + .long 1071666176 + .long 0 + .long 1071664128 + .long 0 + .long 1071662080 + .long 0 + .long 1071660032 + .long 0 + .long 1071657984 + .long 0 + .long 1071655936 + .long 0 + .long 1071653888 + .long 0 + .long 1071651840 + .long 0 + .long 1071649792 + .long 0 + .long 1071647744 + .long 0 + .long 1071645696 + .type __libm_double_rcp_table_256,@object + .size __libm_double_rcp_table_256,2048 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/remainder_gen.S b/external/sgx_libm/intel64/remainder_gen.S new file mode 100644 index 0000000000..b76afc36f3 --- /dev/null +++ b/external/sgx_libm/intel64/remainder_gen.S @@ -0,0 +1,311 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remainder_gen.c" + .text +..TXTST0: +# -- Begin remainder + .text + .align 16,0x90 + .globl remainder +remainder: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_remainder.1: +..L2: + + movq $0x7fffffffffffffff, %rdi + movd %xmm0, %r9 + movq $0x7ff0000000000000, %rax + movd %xmm1, %rdx + movsd %xmm0, -32(%rsp) + movsd %xmm1, -40(%rsp) + andq %r9, %rdi + btrq $63, %rdx + movq $0x7ff0000000000000, %rcx + andq %rdi, %rax + andq %rdx, %rcx + xorb %r8b, %r8b + shrq $52, %rax + shrq $52, %rcx + addl $-1023, %eax + movq %rdi, -16(%rsp) + addl $-1023, %ecx + movq %rdx, -8(%rsp) + sarq $63, %r9 + movq $0, -24(%rsp) + cmpl $1024, %eax + movsd -16(%rsp), %xmm2 + movsd -8(%rsp), %xmm0 + je ..B1.5 +..B1.2: + cmpl $1024, %ecx + je ..B1.5 +..B1.3: + testq %rdi, %rdi + je ..B1.5 +..B1.4: + testq %rdx, %rdx + jne ..B1.6 +..B1.5: + movb $1, %r8b +..B1.6: + movq $0xfffffffffffff, %rsi + andq %rsi, %rdi + andq %rsi, %rdx + testb %r8b, %r8b + je ..B1.17 +..B1.7: + testq %rdi, %rdi + je ..B1.9 +..B1.8: + cmpl $1024, %eax + je ..B1.43 +..B1.9: + testq %rdx, %rdx + je ..B1.11 +..B1.10: + cmpl $1024, %ecx + je ..B1.44 +..B1.11: + movsd -24(%rsp), %xmm1 + ucomisd %xmm1, %xmm0 + jp ..B1.12 + je ..B1.45 +..B1.12: + movsd -24(%rsp), %xmm0 + ucomisd %xmm0, %xmm2 + jp ..B1.13 + je ..B1.15 +..B1.13: + testq %rdi, %rdi + jne ..B1.15 +..B1.14: + cmpl $1024, %eax + je ..B1.45 +..B1.15: + movsd -32(%rsp), %xmm0 +..B1.16: + ret +..B1.17: + comisd %xmm2, %xmm0 + jb ..B1.23 +..B1.18: + ucomisd %xmm0, %xmm2 + jp ..B1.19 + je ..B1.57 +..B1.19: + cmpl $1023, %eax + je ..B1.21 +..B1.20: + movaps %xmm2, %xmm1 + addsd %xmm2, %xmm1 + comisd %xmm1, %xmm0 + jae ..B1.22 +..B1.21: + testl %r9d, %r9d + subsd %xmm0, %xmm2 + movaps %xmm2, %xmm0 + xorps .L_2il0floatpacket.1(%rip), %xmm0 + jne ..L3 + movaps %xmm2, %xmm0 +..L3: + ret +..B1.22: + movsd -32(%rsp), %xmm0 + ret +..B1.23: + cmpl $-1023, %eax + je ..B1.53 +..B1.24: + movq $0x10000000000000, %r8 + orq %r8, %rdi +..B1.25: + cmpl $-1023, %ecx + je ..B1.49 +..B1.26: + movq $0x10000000000000, %r8 + orq %r8, %rdx +..B1.27: + subl %ecx, %eax + xorl %r8d, %r8d + xorl %r11d, %r11d + incl %eax + je ..B1.31 +..B1.28: + movl $1, %r10d +..B1.29: + movq %rdi, %r8 + incl %r11d + subq %rdx, %r8 + cmpq %rdx, %rdi + cmovae %r8, %rdi + movl $0, %r8d + cmovae %r10, %r8 + addq %rdi, %rdi + cmpl %eax, %r11d + jb ..B1.29 +..B1.31: + testq %rdi, %rdi + je ..B1.58 +..B1.32: + shrq $1, %rdi + cmpq %rsi, %rdi + ja ..B1.36 +..B1.34: + addq %rdi, %rdi + decl %ecx + cmpq %rsi, %rdi + jbe ..B1.34 +..B1.36: + cmpl $-1022, %ecx + jl ..B1.38 +..B1.37: + movslq %ecx, %rcx + andq %rdi, %rsi + addq $1023, %rcx + jmp ..B1.39 +..B1.38: + negl %ecx + movq %rdi, %rsi + addl $2, %ecx + shrq %cl, %rsi + xorl %ecx, %ecx +..B1.39: + shlq $52, %rcx + orq %rsi, %rcx + movq %rcx, -40(%rsp) + movsd -40(%rsp), %xmm2 + movaps %xmm2, %xmm1 + addsd %xmm2, %xmm1 + comisd %xmm0, %xmm1 + jb ..B1.42 +..B1.40: + ucomisd %xmm1, %xmm0 + jp ..B1.41 + je ..B1.48 +..B1.41: + subsd %xmm0, %xmm2 +..B1.42: + movaps %xmm2, %xmm0 + testl %r9d, %r9d + xorps .L_2il0floatpacket.1(%rip), %xmm0 + jne ..L4 + movaps %xmm2, %xmm0 +..L4: + ret +..B1.43: + movsd -32(%rsp), %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + ret +..B1.44: + movsd -40(%rsp), %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + ret +..B1.45: + movsd -24(%rsp), %xmm0 + movsd -24(%rsp), %xmm1 + divsd %xmm1, %xmm0 + ret +..B1.48: + movaps %xmm2, %xmm0 + testq %r8, %r8 + xorps .L_2il0floatpacket.1(%rip), %xmm0 + je ..B1.42 + movaps %xmm0, %xmm2 + jmp ..B1.42 +..B1.49: + testq %rdx, %rdx + je ..B1.26 +..B1.50: + movl $-1022, %ecx +..B1.51: + addq %rdx, %rdx + decl %ecx + cmpq %rsi, %rdx + jbe ..B1.51 + jmp ..B1.27 +..B1.53: + testq %rdi, %rdi + je ..B1.24 +..B1.54: + movl $-1022, %eax +..B1.55: + addq %rdi, %rdi + decl %eax + cmpq %rsi, %rdi + jbe ..B1.55 + jmp ..B1.25 +..B1.57: + movsd -24(%rsp), %xmm0 + mulsd -32(%rsp), %xmm0 + ret +..B1.58: + movsd -24(%rsp), %xmm0 + mulsd -32(%rsp), %xmm0 + movq %rdi, -40(%rsp) + ret + .align 16,0x90 + .cfi_endproc + .type remainder,@function + .size remainder,.-remainder + .data +# -- End remainder + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x33333333,0x3ffb3333 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End + + .globl drem + .equ drem, remainder + diff --git a/external/sgx_libm/intel64/remainderf_gen.S b/external/sgx_libm/intel64/remainderf_gen.S new file mode 100644 index 0000000000..48bf94945f --- /dev/null +++ b/external/sgx_libm/intel64/remainderf_gen.S @@ -0,0 +1,78 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remainderf_gen.c" + .text +..TXTST0: +# -- Begin remainderf + .text + .align 16,0x90 + .globl remainderf +remainderf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_remainderf.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + cvtss2sd %xmm0, %xmm0 + cvtss2sd %xmm1, %xmm1 + call remainder@PLT +..B1.4: + cvtsd2ss %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type remainderf,@function + .size remainderf,.-remainderf + .data +# -- End remainderf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End + + .globl dremf + .equ dremf, remainderf + diff --git a/external/sgx_libm/intel64/remainderl.S b/external/sgx_libm/intel64/remainderl.S new file mode 100644 index 0000000000..8174b7d7a2 --- /dev/null +++ b/external/sgx_libm/intel64/remainderl.S @@ -0,0 +1,313 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remainderl.c" + .text +..TXTST0: +# -- Begin remainderl + .text + .align 16,0x90 + .globl remainderl +remainderl: +# parameter 1: 80 + %rsp +# parameter 2: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_remainderl.1: +..L2: + + subq $72, %rsp + .cfi_def_cfa_offset 80 + xorb %dl, %dl + fldt 80(%rsp) + fstpt 32(%rsp) + fldt 96(%rsp) + fstpt 48(%rsp) +..B1.2: + fnstcw 66(%rsp) +..B1.3: + movzwl 104(%rsp), %ecx + andl $32767, %ecx + jne ..B1.6 +..B1.4: + cmpl $0, 100(%rsp) + jne ..B1.6 +..B1.5: + cmpl $0, 96(%rsp) + je ..B1.42 +..B1.6: + movzwl 88(%rsp), %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.40 +..B1.7: + cmpl $32767, %ecx + je ..B1.17 +..B1.8: + movzwl 66(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.12 +..B1.9: + orl $-64768, %ecx + movw %cx, 64(%rsp) +..B1.10: + fldcw 64(%rsp) +..B1.11: + movb $1, %dl +..B1.12: + fldt 48(%rsp) + fldt 32(%rsp) + movq $1024, %rcx +.L_2TAG_PACKET_0.0.2: + fprem1 + fstsw %ax + andq %rcx, %rax + cmpq $1024, %rax + je .L_2TAG_PACKET_0.0.2 + fstp %st(1) + fstpt 16(%rsp) +..B1.13: + testb %dl, %dl + je ..B1.15 +..B1.14: + fldcw 66(%rsp) +..B1.15: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.17: + movq $0x8000000000000000, %rax + cmpq 96(%rsp), %rax + je ..B1.25 +..B1.18: + movzwl 66(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.24 +..B1.19: + orl $-64768, %edx + movw %dx, 64(%rsp) +..B1.20: + fldcw 64(%rsp) +..B1.21: + fldt 80(%rsp) + fldt 96(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.22: + fldcw 66(%rsp) +..B1.23: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.24: + fldt 80(%rsp) + fldt 96(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.23 +..B1.25: + cmpl $32767, %esi + je ..B1.31 +..B1.26: + testl %esi, %esi + jne ..B1.30 +..B1.27: + cmpl $0, 84(%rsp) + jne ..B1.29 +..B1.28: + cmpl $0, 80(%rsp) + je ..B1.30 +..B1.29: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 8(%rsp) +..B1.30: + fldt 80(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.31: + cmpl $-2147483648, 84(%rsp) + jne ..B1.30 +..B1.32: + cmpl $0, 80(%rsp) + jne ..B1.30 +..B1.33: + movzwl 66(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.37 +..B1.34: + orl $-64768, %ecx + movw %cx, 64(%rsp) +..B1.35: + fldcw 64(%rsp) +..B1.36: + movb $1, %dl +..B1.37: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + testb %dl, %dl + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 16(%rsp) + je ..B1.39 +..B1.38: + fldcw 66(%rsp) +..B1.39: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.40: + movq $0x8000000000000000, %rax + cmpq 80(%rsp), %rax + jne ..B1.18 +..B1.41: + cmpl $32767, %ecx + je ..B1.17 + jmp ..B1.25 +..B1.42: + movzwl 66(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.46 +..B1.43: + orl $-64768, %ecx + movw %cx, 64(%rsp) +..B1.44: + fldcw 64(%rsp) +..B1.45: + movb $1, %dl +..B1.46: + movzwl 88(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.51 +..B1.47: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 16(%rsp) +..B1.48: + testb %dl, %dl + je ..B1.50 +..B1.49: + fldcw 66(%rsp) +..B1.50: + fldt 16(%rsp) + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.51: + movq $0x8000000000000000, %rax + cmpq 80(%rsp), %rax + je ..B1.47 +..B1.52: + fldt 80(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) + jmp ..B1.48 + .align 16,0x90 + .cfi_endproc + .type remainderl,@function + .size remainderl,.-remainderl + .data +# -- End remainderl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End + + .globl dreml + .equ dreml, remainderl + diff --git a/external/sgx_libm/intel64/remquo.S b/external/sgx_libm/intel64/remquo.S new file mode 100644 index 0000000000..dfb79d1776 --- /dev/null +++ b/external/sgx_libm/intel64/remquo.S @@ -0,0 +1,411 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remquo.c" + .text +..TXTST0: +# -- Begin remquo + .text + .align 16,0x90 + .globl remquo +remquo: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +# parameter 3: %rdi +..B1.1: + .cfi_startproc +..___tag_value_remquo.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + movq $0x7fffffffffffffff, %r8 + movd %xmm0, %rdx + movq $0x7fffffffffffffff, %rsi + movd %xmm1, %r9 + movsd %xmm0, -32(%rsp) + movsd %xmm1, -40(%rsp) + andq %rdx, %r8 + andq %r9, %rsi + sarq $63, %rdx + movq $0x7ff0000000000000, %rcx + sarq $63, %r9 + andq %rsi, %rcx + movl $-1, %eax + movl $1, %ebx + cmpl %edx, %r9d + movq $0x7ff0000000000000, %r9 + movq %r8, -16(%rsp) + movq %rsi, -8(%rsp) + cmovne %eax, %ebx + xorb %bpl, %bpl + andq %r8, %r9 + shrq $52, %r9 + shrq $52, %rcx + addl $-1023, %r9d + addl $-1023, %ecx + movq $0, -24(%rsp) + cmpl $1024, %r9d + movsd -16(%rsp), %xmm2 + movsd -8(%rsp), %xmm0 + je ..B1.5 +..B1.2: + cmpl $1024, %ecx + je ..B1.5 +..B1.3: + testq %r8, %r8 + je ..B1.5 +..B1.4: + testq %rsi, %rsi + jne ..B1.6 +..B1.5: + movb $1, %bpl +..B1.6: + movq $0xfffffffffffff, %r11 + movq %r8, %rax + movq %rsi, %r10 + andq %r11, %rax + andq %r11, %r10 + testb %bpl, %bpl + je ..B1.18 +..B1.7: + movl $0, (%rdi) + testq %rax, %rax + je ..B1.9 +..B1.8: + cmpl $1024, %r9d + je ..B1.47 +..B1.9: + testq %r10, %r10 + je ..B1.11 +..B1.10: + cmpl $1024, %ecx + je ..B1.48 +..B1.11: + testq %rsi, %rsi + je ..B1.49 +..B1.12: + testq %r8, %r8 + je ..B1.16 +..B1.14: + testq %rax, %rax + jne ..B1.16 +..B1.15: + cmpl $1024, %r9d + je ..B1.49 +..B1.16: + movsd -32(%rsp), %xmm0 +..B1.17: + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.18: + comisd %xmm2, %xmm0 + jb ..B1.25 +..B1.19: + ucomisd %xmm0, %xmm2 + jp ..B1.20 + je ..B1.62 +..B1.20: + cmpl $1023, %r9d + je ..B1.22 +..B1.21: + movaps %xmm2, %xmm1 + addsd %xmm2, %xmm1 + comisd %xmm1, %xmm0 + jae ..B1.24 +..B1.22: + movl %ebx, (%rdi) +..B1.23: + testl %edx, %edx + subsd %xmm0, %xmm2 + movaps %xmm2, %xmm0 + xorps .L_2il0floatpacket.1(%rip), %xmm0 + jne ..L14 + movaps %xmm2, %xmm0 +..L14: + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.24: + movl $0, (%rdi) + movsd -32(%rsp), %xmm0 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.25: + cmpl $-1023, %r9d + je ..B1.58 +..B1.26: + movq $0x10000000000000, %rbp + orq %rbp, %rax +..B1.27: + cmpl $-1023, %ecx + je ..B1.54 +..B1.28: + movq $0x10000000000000, %rbp + orq %rbp, %r10 +..B1.29: + subl %ecx, %r9d + xorl %ebp, %ebp + xorl %esi, %esi + incl %r9d + je ..B1.35 +..B1.31: + addl %ebp, %ebp + cmpq %r10, %rax + jb ..B1.33 +..B1.32: + subq %r10, %rax + incl %ebp +..B1.33: + incl %esi + addq %rax, %rax + cmpl %r9d, %esi + jb ..B1.31 +..B1.35: + testq %rax, %rax + je ..B1.63 +..B1.36: + shrq $1, %rax + movq $0xfffffffffffff, %rsi + cmpq %rsi, %rax + ja ..B1.40 +..B1.38: + addq %rax, %rax + decl %ecx + cmpq %rsi, %rax + jbe ..B1.38 +..B1.40: + cmpl $-1022, %ecx + jl ..B1.42 +..B1.41: + movslq %ecx, %rcx + movq $0xfffffffffffff, %rsi + andq %rax, %rsi + addq $1023, %rcx + jmp ..B1.43 +..B1.42: + negl %ecx + movq %rax, %rsi + addl $2, %ecx + shrq %cl, %rsi + xorl %ecx, %ecx +..B1.43: + shlq $52, %rcx + orq %rsi, %rcx + movq %rcx, -40(%rsp) + movsd -40(%rsp), %xmm2 + movaps %xmm2, %xmm1 + addsd %xmm2, %xmm1 + comisd %xmm0, %xmm1 + jb ..B1.46 +..B1.44: + ucomisd %xmm1, %xmm0 + jp ..B1.45 + je ..B1.52 +..B1.45: + incl %ebp + subsd %xmm0, %xmm2 +..B1.46: + andl $2147483647, %ebp + movaps %xmm2, %xmm0 + imull %ebp, %ebx + testl %edx, %edx + xorps .L_2il0floatpacket.1(%rip), %xmm0 + movl %ebx, (%rdi) + jne ..L29 + movaps %xmm2, %xmm0 +..L29: + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.47: + movsd -32(%rsp), %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.48: + movsd -40(%rsp), %xmm0 + mulsd .L_2il0floatpacket.0(%rip), %xmm0 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.49: + movsd -24(%rsp), %xmm0 + movsd -24(%rsp), %xmm1 + divsd %xmm1, %xmm0 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.52: + testl $1, %ebp + je ..B1.46 +..B1.53: + xorps .L_2il0floatpacket.1(%rip), %xmm2 + incl %ebp + jmp ..B1.46 +..B1.54: + testq %r10, %r10 + je ..B1.28 +..B1.55: + movl $-1022, %ecx + movq $0xfffffffffffff, %rbp +..B1.56: + addq %r10, %r10 + decl %ecx + cmpq %rbp, %r10 + jbe ..B1.56 + jmp ..B1.29 +..B1.58: + testq %rax, %rax + je ..B1.26 +..B1.59: + movl $-1022, %r9d + movq $0xfffffffffffff, %rbp +..B1.60: + addq %rax, %rax + decl %r9d + cmpq %rbp, %rax + jbe ..B1.60 + jmp ..B1.27 +..B1.62: + movl %ebx, (%rdi) + movsd -24(%rsp), %xmm0 + mulsd -32(%rsp), %xmm0 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 24 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.63: + andl $2147483647, %ebp + imull %ebp, %ebx + movl %ebx, (%rdi) + movsd -24(%rsp), %xmm0 + mulsd -32(%rsp), %xmm0 + movq %rax, -40(%rsp) + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type remquo,@function + .size remquo,.-remquo + .data +# -- End remquo + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x33333333,0x3ffb3333 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/remquof.S b/external/sgx_libm/intel64/remquof.S new file mode 100644 index 0000000000..a4866f0b2d --- /dev/null +++ b/external/sgx_libm/intel64/remquof.S @@ -0,0 +1,75 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remquof.c" + .text +..TXTST0: +# -- Begin remquof + .text + .align 16,0x90 + .globl remquof +remquof: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +# parameter 3: %rdi +..B1.1: + .cfi_startproc +..___tag_value_remquof.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 + cvtss2sd %xmm0, %xmm0 + cvtss2sd %xmm1, %xmm1 + call remquo@PLT +..B1.2: + cvtsd2ss %xmm0, %xmm0 + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type remquof,@function + .size remquof,.-remquof + .data +# -- End remquof + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/remquol.S b/external/sgx_libm/intel64/remquol.S new file mode 100644 index 0000000000..0b15bd3228 --- /dev/null +++ b/external/sgx_libm/intel64/remquol.S @@ -0,0 +1,1244 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "remquol.c" + .text +..TXTST0: +# -- Begin remquol + .text + .align 16,0x90 + .globl remquol +remquol: +# parameter 1: 80 + %rsp +# parameter 2: 96 + %rsp +# parameter 3: %rdi +..B1.1: + .cfi_startproc +..___tag_value_remquol.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %rbx + .cfi_def_cfa_offset 32 + .cfi_offset 3, -32 + pushq %rbp + .cfi_def_cfa_offset 40 + .cfi_offset 6, -40 + subq $40, %rsp + .cfi_def_cfa_offset 80 + movq %rdi, %r13 + xorb %r12b, %r12b +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 104(%rsp), %edx + movl $0, (%r13) + andl $32767, %edx + jne ..B1.6 +..B1.4: + cmpl $0, 100(%rsp) + jne ..B1.6 +..B1.5: + cmpl $0, 96(%rsp) + je ..B1.50 +..B1.6: + movzwl 88(%rsp), %ecx + andl $32767, %ecx + cmpl $32767, %ecx + je ..B1.48 +..B1.7: + cmpl $32767, %edx + je ..B1.25 +..B1.8: + movzwl 34(%rsp), %edx + movl %edx, %eax + movb 89(%rsp), %bpl + andl $3840, %eax + movb 105(%rsp), %bl + andb $-128, %bpl + andb $-128, %bl + shrb $7, %bpl + shrb $7, %bl + cmpl $768, %eax + je ..B1.12 +..B1.9: + andl $-3841, %edx + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.10: + fldcw 32(%rsp) +..B1.11: + movb $1, %r12b +..B1.12: + addq $-32, %rsp + .cfi_def_cfa_offset 112 + movq %r13, %rdi + fldt 112(%rsp) + fstpt (%rsp) + fldt 128(%rsp) + fstpt 16(%rsp) +..___tag_value_remquol.13: + call __libm_remquol@PLT +..___tag_value_remquol.14: +..B1.63: + addq $32, %rsp + .cfi_def_cfa_offset 80 +..B1.13: + fstpt 16(%rsp) + testb %r12b, %r12b + je ..B1.15 +..B1.14: + fldcw 34(%rsp) +..B1.15: + movl (%r13), %esi + testl %esi, %esi + je ..B1.19 +..B1.16: + movzbl %bl, %edx + lea iones(%rip), %rax + movl (%rax,%rdx,4), %ecx + imull %ecx, %esi + cmpb %bpl, %bl + je ..B1.18 +..B1.17: + orl $-2147483648, %esi + movl %esi, (%r13) + jmp ..B1.19 +..B1.18: + andl $2147483647, %esi + movl %esi, (%r13) +..B1.19: + movzwl 24(%rsp), %eax + testl $32767, %eax + jne ..B1.24 +..B1.20: + cmpq $0, 16(%rsp) + jne ..B1.22 +..B1.21: + movzbl %bpl, %edx + lea _zeros(%rip), %rax + fldl (%rax,%rdx,8) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.22: + fldt 16(%rsp) + lea _small_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 8(%rsp) +..B1.23: + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.24: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.25: + movq $0x8000000000000000, %rax + cmpq 96(%rsp), %rax + je ..B1.33 +..B1.26: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.32 +..B1.27: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.28: + fldcw 32(%rsp) +..B1.29: + fldt 80(%rsp) + fldt 96(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.30: + fldcw 34(%rsp) +..B1.31: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.32: + fldt 80(%rsp) + fldt 96(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.31 +..B1.33: + cmpl $32767, %ecx + je ..B1.39 +..B1.34: + testl %ecx, %ecx + jne ..B1.38 +..B1.35: + cmpl $0, 84(%rsp) + jne ..B1.37 +..B1.36: + cmpl $0, 80(%rsp) + je ..B1.38 +..B1.37: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 8(%rsp) +..B1.38: + fldt 80(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.39: + cmpl $-2147483648, 84(%rsp) + jne ..B1.38 +..B1.40: + cmpl $0, 80(%rsp) + jne ..B1.38 +..B1.41: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.42: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.43: + fldcw 32(%rsp) +..B1.44: + movb $1, %r12b +..B1.45: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + testb %r12b, %r12b + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 16(%rsp) + je ..B1.47 +..B1.46: + fldcw 34(%rsp) +..B1.47: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.48: + movq $0x8000000000000000, %rax + cmpq 80(%rsp), %rax + jne ..B1.26 +..B1.49: + cmpl $32767, %edx + je ..B1.25 + jmp ..B1.33 +..B1.50: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.54 +..B1.51: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.52: + fldcw 32(%rsp) +..B1.53: + movb $1, %r12b +..B1.54: + movzwl 88(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.59 +..B1.55: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 16(%rsp) +..B1.56: + testb %r12b, %r12b + je ..B1.58 +..B1.57: + fldcw 34(%rsp) +..B1.58: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 40 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 32 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -32 + .cfi_offset 6, -40 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.59: + movq $0x8000000000000000, %rax + cmpq 80(%rsp), %rax + je ..B1.55 +..B1.60: + fldt 80(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) + jmp ..B1.56 + .align 16,0x90 + .cfi_endproc + .type remquol,@function + .size remquol,.-remquol + .data +# -- End remquol + .text +# -- Begin __libm_remquol + .text + .align 16,0x90 + .globl __libm_remquol +__libm_remquol: +# parameter 1: 208 + %rsp +# parameter 2: 224 + %rsp +# parameter 3: %rdi +..B2.1: + .cfi_startproc +..___tag_value___libm_remquol.115: +..L116: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $152, %rsp + .cfi_def_cfa_offset 208 + lea _ones(%rip), %rax + fldt 208(%rsp) + movq %rdi, %rbx + andb $127, 233(%rsp) + movzwl 216(%rsp), %r15d + andl $32767, %r15d + movzwl 232(%rsp), %r11d + andl $32767, %r11d + fstpt 112(%rsp) + fldt 112(%rsp) + cmpl $32703, %r15d + fldt 224(%rsp) + fstpt 128(%rsp) + fldt 128(%rsp) + fldl (%rax) + movl $0, 128(%rsp) + jl ..B2.8 +..B2.2: + fstp %st(0) + cmpl $32703, %r11d + jl ..B2.5 +..B2.3: + lea 8+_scales(%rip), %rax + movq %rbx, %rdi + fldl (%rax) + fmul %st, %st(1) + fxch %st(1) + fstpt 224(%rsp) + fldt 224(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 240 + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_remquol.131: + call __libm_remquol@PLT +..___tag_value___libm_remquol.132: +..B2.35: + addq $32, %rsp + .cfi_def_cfa_offset 208 +..B2.4: + lea _scales(%rip), %rax + fmull (%rax) + fstpt 112(%rsp) + fldt 112(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.5: + lea 8+_scales(%rip), %rax + addq $-32, %rsp + .cfi_def_cfa_offset 240 + movq %rbx, %rdi + fldl (%rax) + fmulp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_remquol.155: + call __libm_remquol@PLT +..___tag_value___libm_remquol.156: +..B2.6: + lea _scales(%rip), %rax + movq %rbx, %rdi + fldl (%rax) + fmulp %st, %st(1) + fstpt (%rsp) + fldt 256(%rsp) + fstpt 16(%rsp) +..___tag_value___libm_remquol.157: + call __libm_remquol@PLT +..___tag_value___libm_remquol.158: +..B2.37: + addq $32, %rsp + .cfi_def_cfa_offset 208 +..B2.7: + fstpt 112(%rsp) + fldt 112(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.8: + cmpl $64, %r11d + jge ..B2.12 +..B2.9: + fstp %st(0) + lea _scales(%rip), %rax + movq %rbx, %rdi + fldl (%rax) + fmul %st, %st(1) + fxch %st(1) + fstpt 224(%rsp) + fldt 224(%rsp) + fxch %st(1) + fstpt (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 240 + fxch %st(1) + fstpt (%rsp) + fstpt 16(%rsp) +..___tag_value___libm_remquol.181: + call __libm_remquol@PLT +..___tag_value___libm_remquol.182: +..B2.38: + addq $32, %rsp + .cfi_def_cfa_offset 208 +..B2.10: + fldt (%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 240 + fmulp %st, %st(1) + movq %rbx, %rdi + fstpt (%rsp) + fldt 256(%rsp) + fstpt 16(%rsp) +..___tag_value___libm_remquol.185: + call __libm_remquol@PLT +..___tag_value___libm_remquol.186: +..B2.39: + addq $32, %rsp + .cfi_def_cfa_offset 208 +..B2.11: + lea 8+_scales(%rip), %rax + fmull (%rax) + fstpt 112(%rsp) + fldt 112(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.12: + lea 1(%r15), %eax + cmpl %eax, %r11d + jg ..B2.31 +..B2.13: + lea -32(%r15), %eax + cmpl %eax, %r11d + jle ..B2.22 +..B2.14: + fstp %st(0) + fldt 128(%rsp) + fld %st(2) + fdiv %st(2), %st + lea _TWO_63H(%rip), %rax + fld %st(2) + lea _halfs(%rip), %rdx + fsub %st(2), %st + fldl (%rax) + fld %st(0) + fadd %st(3), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fmul %st, %st(3) + movl 16(%rsp), %eax + fxch %st(3) + fsubrp %st, %st(5) + fmul %st(2), %st + fsubrp %st, %st(4) + fld %st(1) + fsubr %st(1), %st + fabs + fldl (%rdx) + fucomi %st(1), %st + fxch %st(1) + fstp %st(0) + jp ..B2.15 + je ..B2.16 +..B2.15: + fstp %st(3) + fstp %st(1) + fstp %st(0) + fstp %st(0) + movl %eax, (%rbx) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.16: + fmul %st(3), %st + fld %st(4) + fabs + fcomip %st(1), %st + fstp %st(0) + jp ..B2.17 + jbe ..B2.21 +..B2.17: + fcomip %st(1), %st + fstp %st(0) + ja ..B2.19 + jp ..B2.19 +..B2.18: + decl %eax + faddp %st, %st(1) + movl %eax, (%rbx) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.19: + incl %eax + fsubrp %st, %st(1) + movl %eax, (%rbx) +..B2.20: + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.21: + fstp %st(2) + fstp %st(0) + fstp %st(0) + movl %eax, (%rbx) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.22: + fldt 128(%rsp) + subl %r11d, %r15d + fstpt 32(%rsp) + fldt 32(%rsp) + fld %st(1) + fdiv %st(3), %st + fld %st(3) + fsubp %st, %st(2) + xorl %r10d, %r10d + addl $-31, %r15d + movl %r15d, %ecx + jle ..B2.32 +..B2.23: + lea _TWO_63H(%rip), %rdi + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 16(%rsp) + fldt 16(%rsp) + fxch %st(2) + fstpt 96(%rsp) + fldl (%rdi) + movzwl 8(%rsp), %eax + movzwl 88(%rsp), %r8d + andl $32767, %eax + movzwl 24(%rsp), %esi + movl 20(%rsp), %ebp + movzwl 104(%rsp), %edx + movzwl 136(%rsp), %r12d + movl 132(%rsp), %r13d + movzwl 72(%rsp), %r14d + movl 4(%rsp), %r9d + movq %rbx, 48(%rsp) + xorl %ebx, %ebx +..B2.24: + movl %esi, %edi + andl $-32768, %r8d + subl %r15d, %edi + andl $-32768, %edx + andl $32767, %edi + andl $-32768, %r14d + orl %edi, %r8d + lea (%r12,%r15), %edi + movw %r8w, 88(%rsp) + andl $32767, %edi + movl %ebp, 84(%rsp) + orl %edi, %edx + fldt 80(%rsp) + movl $1, %edi + testl %eax, %eax + fmul %st(5), %st + cmove %eax, %edi + subl %r15d, %ecx + imull %r15d, %edi + fadd %st(1), %st + fstpt 16(%rsp) + fldt 16(%rsp) + addl %eax, %edi + movw %dx, 104(%rsp) + andl $32767, %edi + movl %r13d, 100(%rsp) + orl %edi, %r14d + movw %r14w, 72(%rsp) + fsub %st(1), %st + fldt 96(%rsp) + fmul %st(1), %st + movl %r9d, 68(%rsp) + fsubrp %st, %st(6) + fldt 64(%rsp) + fmulp %st, %st(1) + shll %cl, %r10d + cmpl $32, %ecx + movl %r15d, %ecx + fsubrp %st, %st(5) + fxch %st(4) + fstpt 112(%rsp) + fldt 112(%rsp) + cmovae %ebx, %r10d + movzwl 120(%rsp), %edi + andl $32767, %edi + subl %r11d, %edi + movl %edi, %r15d + addl 16(%rsp), %r10d + addl $-31, %r15d + fxch %st(4) + jg ..B2.24 +..B2.25: + movq 48(%rsp), %rbx +..B2.26: + fldt 32(%rsp) + fld %st(1) + fxch %st(4) + fmul %st(6), %st + lea _halfs(%rip), %rdx + shll %cl, %r10d + xorl %eax, %eax + cmpl $32, %ecx + fadd %st, %st(4) + fxch %st(4) + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(3) + cmovb %r10d, %eax + fxch %st(1) + fsub %st(3), %st + fmul %st, %st(2) + addl 16(%rsp), %eax + fxch %st(2) + fsubrp %st, %st(7) + fmul %st(1), %st + fsubrp %st, %st(6) + fld %st(5) + fabs + fldl (%rdx) + fmul %st(6), %st + fstpt (%rsp) + fldt (%rsp) + fcomip %st(1), %st + ja ..B2.30 +..B2.27: + fldt (%rsp) + fcomip %st(1), %st + fstp %st(0) + jae ..B2.29 + jp ..B2.29 +..B2.28: + fstp %st(2) + fstp %st(0) + fxch %st(1) + fcomip %st(1), %st + fstp %st(0) + fld %st(1) + movl %eax, (%rbx) + fsub %st(1), %st + fxch %st(1) + faddp %st, %st(2) + fcmovb %st(1), %st + fstp %st(1) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.29: + fstp %st(0) + fstp %st(2) + fldt 32(%rsp) + fxch %st(3) + fdivr %st(4), %st + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + addl 16(%rsp), %eax + fxch %st(2) + fsubrp %st, %st(3) + fmulp %st, %st(1) + movl %eax, (%rbx) + fsubrp %st, %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.30: + fstp %st(5) + fstp %st(4) + fstp %st(3) + fstp %st(1) + fstp %st(0) + fstp %st(0) + movl %eax, (%rbx) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.31: + fstp %st(1) + fstp %st(0) + movl $0, (%rbx) + addq $152, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 208 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B2.32: + fstp %st(2) + lea _TWO_63H(%rip), %rax + fldl (%rax) + jmp ..B2.26 + .align 16,0x90 + .cfi_endproc + .type __libm_remquol,@function + .size __libm_remquol,.-__libm_remquol + .data +# -- End __libm_remquol + .section .rodata, "a" + .align 4 + .align 4 +iones: + .long 1 + .long -1 + .type iones,@object + .size iones,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_scales: + .long 0 + .long 1341128704 + .long 0 + .long 804257792 + .type _scales,@object + .size _scales,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_halfs: + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .type _halfs,@object + .size _halfs,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/rint_gen.S b/external/sgx_libm/intel64/rint_gen.S new file mode 100644 index 0000000000..71ee463b45 --- /dev/null +++ b/external/sgx_libm/intel64/rint_gen.S @@ -0,0 +1,89 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rint_gen.c" + .text +..TXTST0: +# -- Begin rint + .text + .align 16,0x90 + .globl rint +rint: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_rint.1: +..L2: + +..B1.2: + xorpd %xmm1, %xmm1 + ucomisd p2to52(%rip), %xmm0 + jae .L_2TAG_PACKET_0.0.1 + ucomisd m2to52(%rip), %xmm0 + jbe .L_2TAG_PACKET_0.0.1 + ucomisd %xmm1, %xmm0 + je .L_2TAG_PACKET_0.0.1 + cvtsd2si %xmm0, %rax + cvtsi2sdq %rax, %xmm0 +.L_2TAG_PACKET_0.0.1: + ret +..B1.3: + .align 16,0x90 + .cfi_endproc + .type rint,@function + .size rint,.-rint + .data +# -- End rint + .section .rodata, "a" + .align 16 + .align 16 +p2to52: + .long 0x00000000,0x43300000 + .type p2to52,@object + .size p2to52,8 + .space 8, 0x00 # pad + .align 16 +m2to52: + .long 0x00000000,0xc3300000 + .type m2to52,@object + .size m2to52,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/rintf_gen.S b/external/sgx_libm/intel64/rintf_gen.S new file mode 100644 index 0000000000..caef1e7adb --- /dev/null +++ b/external/sgx_libm/intel64/rintf_gen.S @@ -0,0 +1,89 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rintf_gen.c" + .text +..TXTST0: +# -- Begin rintf + .text + .align 16,0x90 + .globl rintf +rintf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_rintf.1: +..L2: + +..B1.2: + xorps %xmm1, %xmm1 + ucomiss p2to23(%rip), %xmm0 + jae .L_2TAG_PACKET_0.0.1 + ucomiss m2to23(%rip), %xmm0 + jbe .L_2TAG_PACKET_0.0.1 + ucomiss %xmm1, %xmm0 + je .L_2TAG_PACKET_0.0.1 + cvtss2si %xmm0, %eax + cvtsi2ss %eax, %xmm0 +.L_2TAG_PACKET_0.0.1: + ret +..B1.3: + .align 16,0x90 + .cfi_endproc + .type rintf,@function + .size rintf,.-rintf + .data +# -- End rintf + .section .rodata, "a" + .align 16 + .align 16 +p2to23: + .long 0x4b000000 + .type p2to23,@object + .size p2to23,4 + .space 12, 0x00 # pad + .align 16 +m2to23: + .long 0xcb000000 + .type m2to23,@object + .size m2to23,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/rintl.S b/external/sgx_libm/intel64/rintl.S new file mode 100644 index 0000000000..0c1537593b --- /dev/null +++ b/external/sgx_libm/intel64/rintl.S @@ -0,0 +1,163 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "rintl.c" + .text +..TXTST0: +# -- Begin rintl + .text + .align 16,0x90 + .globl rintl +rintl: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_rintl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + xorb %cl, %cl +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movb 41(%rsp), %dl + movzwl 40(%rsp), %eax + andb $-128, %dl + andl $32767, %eax + shrb $7, %dl + movzwl 18(%rsp), %esi + cmpl $16446, %eax + jge ..B1.13 +..B1.4: + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.8 +..B1.5: + orl $-64768, %esi + movw %si, 16(%rsp) +..B1.6: + fldcw 16(%rsp) +..B1.7: + movb $1, %cl +..B1.8: + fldt 32(%rsp) + lea _TWO_63(%rip), %rax + movzbl %dl, %edx + testb %cl, %cl + fldl (%rax,%rdx,8) + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 32(%rsp) + je ..B1.10 +..B1.9: + fldcw 18(%rsp) +..B1.10: + fldt 32(%rsp) + lea _zeros(%rip), %rax + fldl (%rax) + fucomip %st(1), %st + jp ..B1.12 + je ..B1.19 +..B1.12: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.13: + movl %esi, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.20 +..B1.14: + orl $-64768, %esi + movw %si, 16(%rsp) +..B1.15: + fldcw 16(%rsp) +..B1.16: + fldt 32(%rsp) + fstpt (%rsp) +..B1.17: + fldcw 18(%rsp) +..B1.18: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.19: + fstp %st(0) + fldl (%rax,%rdx,8) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.20: + fldt 32(%rsp) + fstpt (%rsp) + jmp ..B1.18 + .align 16,0x90 + .cfi_endproc + .type rintl,@function + .size rintl,.-rintl + .data +# -- End rintl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63: + .long 0 + .long 1138753536 + .long 0 + .long 3286237184 + .type _TWO_63,@object + .size _TWO_63,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/round_gen.S b/external/sgx_libm/intel64/round_gen.S new file mode 100644 index 0000000000..3aec83c446 --- /dev/null +++ b/external/sgx_libm/intel64/round_gen.S @@ -0,0 +1,181 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "round_gen.c" + .text +..TXTST0: +# -- Begin round + .text + .align 16,0x90 + .globl round +round: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_round.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, (%rsp) +..B1.2: + movapd bns(%rip), %xmm2 + movapd %xmm0, %xmm3 + movapd %xmm0, %xmm1 + psrlq $52, %xmm0 + movd %xmm0, %eax + andpd s(%rip), %xmm0 + psubd %xmm0, %xmm2 + psrlq %xmm2, %xmm1 + psllq %xmm2, %xmm1 + testl $2048, %eax + jne .L_2TAG_PACKET_0.0.1 + cmpl $1023, %eax + jl .L_2TAG_PACKET_1.0.1 + cmpl $1074, %eax + jg .L_2TAG_PACKET_2.0.1 + subsd %xmm1, %xmm3 + movq %xmm1, %xmm0 + cmppd $5, p_half(%rip), %xmm3 + andpd p_one(%rip), %xmm3 + addsd %xmm3, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_1.0.1: + cmpl $1022, %eax + jl .L_2TAG_PACKET_3.0.1 + movq p_one(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_3.0.1: + pxor %xmm0, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_2.0.1: + movq (%rsp), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_0.0.1: + cmpl $3071, %eax + jl .L_2TAG_PACKET_4.0.1 + cmpl $3122, %eax + jg .L_2TAG_PACKET_2.0.1 + subsd %xmm1, %xmm3 + movq %xmm1, %xmm0 + cmppd $2, n_half(%rip), %xmm3 + andpd n_one(%rip), %xmm3 + addsd %xmm3, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_4.0.1: + cmpl $3070, %eax + jl .L_2TAG_PACKET_5.0.1 + movq n_one(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_5.0.1: + movq 8+zeros(%rip), %xmm0 + movq %xmm0, 8(%rsp) +.L_2TAG_PACKET_6.0.1: +..B1.4: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type round,@function + .size round,.-round + .data +# -- End round + .section .rodata, "a" + .align 16 + .align 16 +bns: + .long 1075 + .long 0 + .long 1075 + .long 0 + .type bns,@object + .size bns,16 + .align 16 +s: + .long 2047 + .long 0 + .long 0 + .long 0 + .type s,@object + .size s,16 + .align 16 +p_half: + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .type p_half,@object + .size p_half,16 + .align 16 +p_one: + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .type p_one,@object + .size p_one,16 + .align 16 +n_half: + .long 0 + .long 3219128320 + .long 0 + .long 1127219200 + .type n_half,@object + .size n_half,16 + .align 16 +n_one: + .long 0 + .long 3220176896 + .long 0 + .long 1127219200 + .type n_one,@object + .size n_one,16 + .align 16 +zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type zeros,@object + .size zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/roundf_gen.S b/external/sgx_libm/intel64/roundf_gen.S new file mode 100644 index 0000000000..8bd688ee02 --- /dev/null +++ b/external/sgx_libm/intel64/roundf_gen.S @@ -0,0 +1,118 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "roundf_gen.c" + .text +..TXTST0: +# -- Begin roundf + .text + .align 16,0x90 + .globl roundf +roundf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_roundf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movss %xmm0, 8(%rsp) +..B1.2: + movl 8(%rsp), %eax + testl %eax, %eax + jl .L_2TAG_PACKET_0.0.1 + cmpl $1056964608, %eax + jl .L_2TAG_PACKET_1.0.1 + cmpl $1258291200, %eax + jge .L_2TAG_PACKET_2.0.1 + cmpl $1065353216, %eax + je .L_2TAG_PACKET_2.0.1 + addss half(%rip), %xmm0 + cvttss2si %xmm0, %eax + cvtsi2ss %eax, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_1.0.1: + pxor %xmm0, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_2.0.1: + movss 8(%rsp), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_3.0.1: + movss nzero(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_0.0.1: + andl $2147483647, %eax + cmpl $1056964608, %eax + jl .L_2TAG_PACKET_3.0.1 + cmpl $1258291200, %eax + jge .L_2TAG_PACKET_2.0.1 + cmpl $1065353216, %eax + je .L_2TAG_PACKET_2.0.1 + subss half(%rip), %xmm0 + cvttss2si %xmm0, %eax + cvtsi2ss %eax, %xmm0 + movss %xmm0, (%rsp) +.L_2TAG_PACKET_4.0.1: +..B1.4: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type roundf,@function + .size roundf,.-roundf + .data +# -- End roundf + .section .rodata, "a" + .align 4 + .align 4 +half: + .long 1056964608 + .type half,@object + .size half,4 + .align 4 +nzero: + .long 2147483648 + .type nzero,@object + .size nzero,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/roundl.S b/external/sgx_libm/intel64/roundl.S new file mode 100644 index 0000000000..75046e8fa0 --- /dev/null +++ b/external/sgx_libm/intel64/roundl.S @@ -0,0 +1,245 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "roundl.c" + .text +..TXTST0: +# -- Begin roundl + .text + .align 16,0x90 + .globl roundl +roundl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_roundl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %al, %al +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 56(%rsp), %edi + andl $32767, %edi + cmpl $16446, %edi + jge ..B1.25 +..B1.4: + cmpl $16383, %edi + jl ..B1.19 +..B1.5: + cmpl $16414, %edi + jge ..B1.7 +..B1.6: + movl 52(%rsp), %edx + lea 2(%rdi), %ecx + negl %edi + movl %edx, %esi + addl $30, %edi + shll %cl, %esi + movl %edi, %ecx + shrl %cl, %edx + movl %edi, %ecx + shll %cl, %edx + movl %edx, 52(%rsp) + movl $0, 48(%rsp) + jmp ..B1.10 +..B1.7: + jle ..B1.9 +..B1.8: + movl 48(%rsp), %edx + lea 2(%rdi), %ecx + negl %edi + movl %edx, %esi + addl $30, %edi + shll %cl, %esi + movl %edi, %ecx + shrl %cl, %edx + movl %edi, %ecx + shll %cl, %edx + movl %edx, 48(%rsp) + jmp ..B1.10 +..B1.9: + movl 48(%rsp), %esi + movl $0, 48(%rsp) +..B1.10: + testl %esi, %esi + jge ..B1.18 +..B1.11: + movzwl 26(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.15 +..B1.12: + orl $-64768, %ecx + movw %cx, 24(%rsp) +..B1.13: + fldcw 24(%rsp) +..B1.14: + movb $1, %al +..B1.15: + fldt 48(%rsp) + lea _ones(%rip), %rcx + movb 57(%rsp), %dl + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %esi + testb %al, %al + faddl (%rcx,%rsi,8) + fstpt (%rsp) + je ..B1.17 +..B1.16: + fldcw 26(%rsp) +..B1.17: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.18: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.19: + cmpl $16382, %edi + je ..B1.32 +..B1.20: + testl %edi, %edi + jne ..B1.24 +..B1.21: + cmpl $0, 52(%rsp) + jne ..B1.23 +..B1.22: + cmpl $0, 48(%rsp) + je ..B1.24 +..B1.23: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, 16(%rsp) +..B1.24: + movb 57(%rsp), %al + lea _zeros(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.25: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.31 +..B1.26: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.27: + fldcw 24(%rsp) +..B1.28: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.29: + fldcw 26(%rsp) +..B1.30: + fldt (%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.31: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt (%rsp) + jmp ..B1.30 +..B1.32: + movb 57(%rsp), %al + lea _ones(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type roundl,@function + .size roundl,.-roundl + .data +# -- End roundl + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalb_gen.S b/external/sgx_libm/intel64/scalb_gen.S new file mode 100644 index 0000000000..9d63d2832e --- /dev/null +++ b/external/sgx_libm/intel64/scalb_gen.S @@ -0,0 +1,369 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalb_gen.c" + .text +..TXTST0: +# -- Begin scalb + .text + .align 16,0x90 + .globl scalb +scalb: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_scalb.1: +..L2: + + movaps %xmm1, %xmm2 + movsd %xmm0, -16(%rsp) + movzwl -10(%rsp), %eax + movl %eax, %edx + movsd %xmm2, -8(%rsp) + andl $32752, %edx + movzwl -2(%rsp), %ecx + andl $32752, %ecx + shrl $4, %edx + shrl $4, %ecx + cmpl $2047, %edx + je ..B1.56 +..B1.2: + cmpl $2047, %ecx + je ..B1.37 +..B1.3: + cmpl $1023, %ecx + jl ..B1.20 +..B1.4: + cmpl $1044, %ecx + jge ..B1.7 +..B1.5: + lea _TWO_52H(%rip), %rcx + pxor %xmm1, %xmm1 + movsd (%rcx), %xmm0 + addsd %xmm2, %xmm0 + movsd %xmm0, -24(%rsp) + movl -24(%rsp), %edi + cvtsi2sd %edi, %xmm1 + ucomisd %xmm2, %xmm1 + jp ..B1.6 + je ..B1.10 +..B1.6: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + ret +..B1.7: + movb -1(%rsp), %sil + lea large_integers(%rip), %rdi + andb $-128, %sil + shrb $7, %sil + movzbl %sil, %r8d + cmpl $1075, %ecx + movl (%rdi,%r8,4), %edi + jge ..B1.10 +..B1.8: + addl $13, %ecx + movl -8(%rsp), %esi + shll %cl, %esi + testl %esi, %esi + jne ..B1.6 +..B1.10: + testl %edx, %edx + jne ..B1.15 +..B1.11: + testl $1048575, -12(%rsp) + jne ..B1.14 +..B1.12: + cmpl $0, -16(%rsp) + jne ..B1.14 +..B1.13: + movsd -16(%rsp), %xmm0 + ret +..B1.14: + lea _TWO_55(%rip), %rax + movsd -16(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -16(%rsp) + movzwl -10(%rsp), %eax + movl %eax, %edx + andl $32752, %edx + shrl $4, %edx + addl $-55, %edx +..B1.15: + movl $65536, %ecx + cmpl $65536, %edi + cmovg %ecx, %edi + movl $-65536, %esi + cmpl $-65536, %edi + cmovge %edi, %esi + lea (%rdx,%rsi), %ecx + testl %ecx, %ecx + jle ..B1.33 +..B1.16: + cmpl $2047, %ecx + jl ..B1.18 +..B1.17: + movb -9(%rsp), %al + lea _large_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.18: + andl $2047, %ecx + andl $-32753, %eax + shll $4, %ecx + orl %ecx, %eax + movw %ax, -10(%rsp) + movsd -16(%rsp), %xmm0 +..B1.19: + ret +..B1.20: + testl %ecx, %ecx + jne ..B1.24 +..B1.21: + testl $1048575, -4(%rsp) + jne ..B1.24 +..B1.22: + cmpl $0, -8(%rsp) + jne ..B1.24 +..B1.23: + lea _ones(%rip), %rax + movsd -16(%rsp), %xmm0 + mulsd (%rax), %xmm0 + ret +..B1.24: + cmpl $2047, %edx + jne ..B1.6 +..B1.25: + testl %ecx, %ecx + jle ..B1.6 +..B1.26: + cmpl $1, %ecx + jne ..B1.30 +..B1.27: + movl -4(%rsp), %eax + andl $1048575, %eax +..B1.28: + jne ..B1.30 +..B1.29: + cmpl $0, -8(%rsp) + jbe ..B1.6 +..B1.30: + movb -9(%rsp), %al + lea _infs(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movsd (%rdx,%rcx,8), %xmm0 + ret +..B1.33: + cmpl $-52, %ecx + jge ..B1.35 +..B1.34: + movb -9(%rsp), %al + lea _small_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.35: + andl $-32753, %eax + lea 55(%rdx,%rsi), %edx + andl $2047, %edx + shll $4, %edx + orl %edx, %eax + movw %ax, -10(%rsp) + lea 8+_TWO_55(%rip), %rax + movsd -16(%rsp), %xmm0 + mulsd (%rax), %xmm0 +..B1.36: + ret +..B1.37: + testl $1048575, -4(%rsp) + jne ..B1.51 +..B1.38: + cmpl $0, -8(%rsp) + jne ..B1.51 +..B1.39: + testl %edx, %edx + jne ..B1.46 +..B1.40: + testl $1048575, -12(%rsp) + jne ..B1.47 +..B1.41: + cmpl $0, -16(%rsp) + jne ..B1.47 +..B1.42: + testb $-128, -1(%rsp) + je ..B1.44 +..B1.43: + movsd -16(%rsp), %xmm0 + ret +..B1.44: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 +..B1.45: + ret +..B1.46: + cmpl $2047, %edx + je ..B1.52 +..B1.47: + movb -9(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + testb $-128, -1(%rsp) + je ..B1.49 +..B1.48: + lea _zeros(%rip), %rax + movsd (%rax,%rdx,8), %xmm0 + ret +..B1.49: + lea _infs(%rip), %rax + movsd (%rax,%rdx,8), %xmm0 +..B1.50: + ret +..B1.51: + movsd -16(%rsp), %xmm0 + addsd -8(%rsp), %xmm0 + ret +..B1.52: + testb $-128, -1(%rsp) + jne ..B1.54 +..B1.53: + movsd -16(%rsp), %xmm0 + ret +..B1.54: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 +..B1.55: + ret +..B1.56: + testl $1048575, -12(%rsp) + jne ..B1.51 +..B1.57: + cmpl $0, -16(%rsp) + jne ..B1.51 +..B1.58: + cmpl $2047, %ecx + je ..B1.37 + jmp ..B1.20 + .align 16,0x90 + .cfi_endproc + .type scalb,@function + .size scalb,.-scalb + .data +# -- End scalb + .section .rodata, "a" + .align 4 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +large_integers: + .long 65536 + .long -65536 + .type large_integers,@object + .size large_integers,8 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .type _TWO_55,@object + .size _TWO_55,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalbf.S b/external/sgx_libm/intel64/scalbf.S new file mode 100644 index 0000000000..a8e79cb12b --- /dev/null +++ b/external/sgx_libm/intel64/scalbf.S @@ -0,0 +1,321 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbf.c" + .text +..TXTST0: +# -- Begin scalbf + .text + .align 16,0x90 + .globl scalbf +scalbf: +# parameter 1: %xmm0 +# parameter 2: %xmm1 +..B1.1: + .cfi_startproc +..___tag_value_scalbf.1: +..L2: + + movss %xmm0, -16(%rsp) + movzwl -14(%rsp), %esi + movl %esi, %edx + movss %xmm1, -24(%rsp) + andl $32640, %edx + movzwl -22(%rsp), %r8d + andl $32640, %r8d + shrl $7, %edx + shrl $7, %r8d + cmpl $255, %edx + je ..B1.48 +..B1.2: + cmpl $255, %r8d + je ..B1.31 +..B1.3: + cmpl $127, %r8d + jl ..B1.16 +..B1.4: + cmpl $150, %r8d + jge ..B1.7 +..B1.5: + movd %xmm1, %edi + movl %r8d, %ecx + andl $8388607, %edi + negl %ecx + movl %edi, %eax + addl $22, %ecx + orl $8388608, %eax + addl $10, %r8d + shrl %cl, %eax + movl %r8d, %ecx + shll %cl, %edi + testl %edi, %edi + je ..B1.8 +..B1.6: + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 + ret +..B1.7: + movl $65536, %eax +..B1.8: + testl %edx, %edx + jne ..B1.11 +..B1.9: + testl $8388607, -16(%rsp) + je ..B1.15 +..B1.10: + movss -16(%rsp), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + movss %xmm0, -16(%rsp) + movzwl -14(%rsp), %esi + movl %esi, %edx + andl $32640, %edx + shrl $7, %edx + addl $-25, %edx +..B1.11: + movl $65536, %ecx + cmpl $65536, %eax + movzbl -21(%rsp), %edi + cmovg %ecx, %eax + movl %eax, %r8d + negl %r8d + testl $128, %edi + cmovne %r8d, %eax + lea (%rdx,%rax), %ecx + testl %ecx, %ecx + jle ..B1.27 +..B1.12: + cmpl $255, %ecx + jge ..B1.26 +..B1.13: + movzbl %cl, %ecx + andl $-32641, %esi + shll $7, %ecx + orl %ecx, %esi + movw %si, -14(%rsp) + movss -16(%rsp), %xmm0 +..B1.14: + ret +..B1.15: + movss -16(%rsp), %xmm0 + ret +..B1.16: + testl %r8d, %r8d + jne ..B1.19 +..B1.17: + testl $8388607, -24(%rsp) + je ..B1.15 +..B1.19: + cmpl $255, %edx + jne ..B1.6 +..B1.20: + testl %r8d, %r8d + jle ..B1.6 +..B1.21: + cmpl $1, %r8d + jne ..B1.23 +..B1.22: + testl $8388607, -24(%rsp) + jle ..B1.6 +..B1.23: + movb -13(%rsp), %al + lea _infs(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + ret +..B1.26: + movb -13(%rsp), %al + lea _large_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.2(%rip), %xmm0 + movss %xmm0, -24(%rsp) + ret +..B1.27: + cmpl $-23, %ecx + jge ..B1.29 +..B1.28: + movb -13(%rsp), %al + lea _small_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.3(%rip), %xmm0 + jmp ..B1.30 +..B1.29: + movl -16(%rsp), %ecx + lea 25(%rdx,%rax), %eax + movl %ecx, -24(%rsp) + shrl $16, %ecx + movzbl %al, %eax + andl $-32641, %ecx + shll $7, %eax + orl %eax, %ecx + movw %cx, -22(%rsp) + movss -24(%rsp), %xmm0 + mulss .L_2il0floatpacket.4(%rip), %xmm0 +..B1.30: + movss %xmm0, -24(%rsp) + ret +..B1.31: + testl $8388607, -24(%rsp) + jne ..B1.43 +..B1.32: + testl %edx, %edx + jne ..B1.38 +..B1.33: + testl $8388607, -16(%rsp) + jne ..B1.39 +..B1.34: + testb $-128, -21(%rsp) + je ..B1.36 +..B1.35: + movss -16(%rsp), %xmm0 + ret +..B1.36: + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 +..B1.37: + ret +..B1.38: + cmpl $255, %edx + je ..B1.44 +..B1.39: + movb -13(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + testb $-128, -21(%rsp) + je ..B1.41 +..B1.40: + lea _zeros(%rip), %rax + movss (%rax,%rdx,4), %xmm0 + ret +..B1.41: + lea _infs(%rip), %rax + movss (%rax,%rdx,4), %xmm0 +..B1.42: + ret +..B1.43: + movss -16(%rsp), %xmm0 + addss -24(%rsp), %xmm0 + ret +..B1.44: + testb $-128, -21(%rsp) + jne ..B1.46 +..B1.45: + movss -16(%rsp), %xmm0 + ret +..B1.46: + pxor %xmm0, %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 +..B1.47: + ret +..B1.48: + testl $8388607, -16(%rsp) + jne ..B1.43 +..B1.49: + cmpl $255, %r8d + je ..B1.31 + jmp ..B1.16 + .align 16,0x90 + .cfi_endproc + .type scalbf,@function + .size scalbf,.-scalbf + .data +# -- End scalbf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x7f800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x4c000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x71800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x0d800000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +.L_2il0floatpacket.4: + .long 0x33000000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .align 4 +_infs: + .long 2139095040 + .long 4286578688 + .type _infs,@object + .size _infs,8 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalbl.S b/external/sgx_libm/intel64/scalbl.S new file mode 100644 index 0000000000..9fe1d5ab06 --- /dev/null +++ b/external/sgx_libm/intel64/scalbl.S @@ -0,0 +1,623 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbl.c" + .text +..TXTST0: +# -- Begin scalbl + .text + .align 16,0x90 + .globl scalbl +scalbl: +# parameter 1: 48 + %rsp +# parameter 2: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_scalbl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + xorb %dl, %dl +..B1.2: + fnstcw 34(%rsp) +..B1.3: + movzwl 56(%rsp), %eax + andl $32767, %eax + movzwl 72(%rsp), %ecx + andl $32767, %ecx + cmpl $32767, %eax + je ..B1.100 +..B1.4: + cmpl $32767, %ecx + je ..B1.69 +..B1.5: + cmpl $16383, %ecx + jl ..B1.32 +..B1.6: + movzwl 34(%rsp), %edi + movl %edi, %esi + andl $768, %esi + cmpl $768, %esi + je ..B1.10 +..B1.7: + orl $-64768, %edi + movw %di, 32(%rsp) +..B1.8: + fldcw 32(%rsp) +..B1.9: + movb $1, %dl +..B1.10: + cmpl $16414, %ecx + jge ..B1.15 +..B1.11: + fldt 64(%rsp) + lea _TWO_63H(%rip), %rcx + fldl (%rcx) + fadd %st(1), %st + fstpt 16(%rsp) + fildl 16(%rsp) + movl 16(%rsp), %edi + fucomip %st(1), %st + fstp %st(0) + jp ..B1.12 + je ..B1.20 +..B1.12: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + testb %dl, %dl + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + je ..B1.14 +..B1.13: + fldcw 34(%rsp) +..B1.14: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.15: + movb 73(%rsp), %sil + lea large_integers(%rip), %rdi + andb $-128, %sil + shrb $7, %sil + movzbl %sil, %r8d + cmpl $16446, %ecx + movl (%rdi,%r8,4), %edi + jge ..B1.20 +..B1.16: + addl $2, %ecx + movl 64(%rsp), %esi + shll %cl, %esi + testl %esi, %esi + je ..B1.20 +..B1.17: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + testb %dl, %dl + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + je ..B1.19 +..B1.18: + fldcw 34(%rsp) +..B1.19: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.20: + testl %eax, %eax + jne ..B1.26 +..B1.21: + cmpq $0, 48(%rsp) + jne ..B1.25 +..B1.22: + testb %dl, %dl + je ..B1.24 +..B1.23: + fldcw 34(%rsp) +..B1.24: + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.25: + fldt 48(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 48(%rsp) + movzwl 56(%rsp), %eax + andl $32767, %eax + addl $-75, %eax +..B1.26: + movl $65536, %ecx + cmpl $65536, %edi + cmovg %ecx, %edi + movl $-65536, %esi + cmpl $-65536, %edi + cmovge %edi, %esi + lea (%rax,%rsi), %ecx + testl %ecx, %ecx + jle ..B1.49 +..B1.27: + cmpl $32767, %ecx + jge ..B1.48 +..B1.28: + movzwl 56(%rsp), %eax + andl $32767, %ecx + andl $-32768, %eax + orl %ecx, %eax + movw %ax, 56(%rsp) + fldt 48(%rsp) +..B1.29: + fstpt 16(%rsp) + testb %dl, %dl + je ..B1.31 +..B1.30: + fldcw 34(%rsp) +..B1.31: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.32: + testl %ecx, %ecx + jne ..B1.40 +..B1.33: + cmpq $0, 64(%rsp) + jne ..B1.40 +..B1.34: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.55 +..B1.35: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.36: + fldcw 32(%rsp) +..B1.37: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) +..B1.38: + fldcw 34(%rsp) +..B1.39: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.40: + cmpl $32767, %eax + je ..B1.56 +..B1.41: + movzwl 34(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.42: + orl $-64768, %ecx + movw %cx, 32(%rsp) +..B1.43: + fldcw 32(%rsp) +..B1.44: + movb $1, %dl +..B1.45: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + testb %dl, %dl + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + je ..B1.47 +..B1.46: + fldcw 34(%rsp) +..B1.47: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.48: + movb 57(%rsp), %al + lea _large_value_80(%rip), %rsi + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %ecx + shlq $4, %rcx + fldt (%rsi,%rcx) + fmulp %st, %st(1) + jmp ..B1.29 +..B1.49: + cmpl $-63, %ecx + jge ..B1.51 +..B1.50: + movb 57(%rsp), %al + lea _small_value_80(%rip), %rsi + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %ecx + shlq $4, %rcx + fldt (%rsi,%rcx) + fmulp %st, %st(1) + jmp ..B1.52 +..B1.51: + fldt 48(%rsp) + lea 75(%rax,%rsi), %eax + movzwl 56(%rsp), %ecx + andl $32767, %eax + lea 8+_TWO_75(%rip), %rsi + andl $-32768, %ecx + fstpt 16(%rsp) + orl %eax, %ecx + movw %cx, 24(%rsp) + fldt 16(%rsp) + fmull (%rsi) +..B1.52: + fstpt 16(%rsp) + testb %dl, %dl + je ..B1.54 +..B1.53: + fldcw 34(%rsp) +..B1.54: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.55: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) + jmp ..B1.39 +..B1.56: + testl %ecx, %ecx + jle ..B1.61 +..B1.57: + cmpl $1, %ecx + jne ..B1.68 +..B1.58: + movl 68(%rsp), %eax + cmpl $-2147483648, %eax + jb ..B1.61 +..B1.59: + jne ..B1.68 +..B1.60: + cmpl $0, 64(%rsp) + ja ..B1.68 +..B1.61: + movzwl 34(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.65 +..B1.62: + orl $-64768, %ecx + movw %cx, 32(%rsp) +..B1.63: + fldcw 32(%rsp) +..B1.64: + movb $1, %dl +..B1.65: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + testb %dl, %dl + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + je ..B1.67 +..B1.66: + fldcw 34(%rsp) +..B1.67: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.68: + movb 57(%rsp), %al + lea _infs(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.69: + movq $0x8000000000000000, %rcx + cmpq 64(%rsp), %rcx + je ..B1.77 +..B1.70: + movzwl 34(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.76 +..B1.71: + orl $-64768, %edx + movw %dx, 32(%rsp) +..B1.72: + fldcw 32(%rsp) +..B1.73: + fldt 48(%rsp) + fldt 64(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) +..B1.74: + fldcw 34(%rsp) +..B1.75: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.76: + fldt 48(%rsp) + fldt 64(%rsp) + faddp %st, %st(1) + fstpt 16(%rsp) + jmp ..B1.75 +..B1.77: + movzwl 34(%rsp), %esi + movl %esi, %ecx + andl $768, %ecx + cmpl $768, %ecx + je ..B1.81 +..B1.78: + orl $-64768, %esi + movw %si, 32(%rsp) +..B1.79: + fldcw 32(%rsp) +..B1.80: + movb $1, %dl +..B1.81: + testl %eax, %eax + jne ..B1.89 +..B1.82: + cmpl $0, 52(%rsp) + jne ..B1.84 +..B1.83: + cmpl $0, 48(%rsp) + je ..B1.85 +..B1.84: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rcx + movq %rcx, (%rsp) +..B1.85: + cmpq $0, 48(%rsp) + jne ..B1.90 +..B1.86: + testb $-128, 73(%rsp) + je ..B1.88 +..B1.87: + fldt 48(%rsp) + fstpt 16(%rsp) + jmp ..B1.94 +..B1.88: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + jmp ..B1.94 +..B1.89: + cmpl $32767, %eax + je ..B1.97 +..B1.90: + movb 57(%rsp), %al + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + testb $-128, 73(%rsp) + je ..B1.92 +..B1.91: + lea _zeros(%rip), %rax + movsd (%rax,%rcx,8), %xmm0 + jmp ..B1.93 +..B1.92: + lea _infs(%rip), %rax + movsd (%rax,%rcx,8), %xmm0 +..B1.93: + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) +..B1.94: + testb %dl, %dl + je ..B1.96 +..B1.95: + fldcw 34(%rsp) +..B1.96: + fldt 16(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.97: + testb $-128, 73(%rsp) + jne ..B1.99 +..B1.98: + fldt 48(%rsp) + fstpt 16(%rsp) + jmp ..B1.94 +..B1.99: + lea _infs(%rip), %rax + lea _zeros(%rip), %rcx + movsd (%rax), %xmm0 + mulsd (%rcx), %xmm0 + movsd %xmm0, 8(%rsp) + fldl 8(%rsp) + fstpt 16(%rsp) + jmp ..B1.94 +..B1.100: + movq $0x8000000000000000, %rsi + cmpq 48(%rsp), %rsi + jne ..B1.70 +..B1.101: + cmpl $32767, %ecx + je ..B1.69 + jmp ..B1.32 + .align 16,0x90 + .cfi_endproc + .type scalbl,@function + .size scalbl,.-scalbl + .data +# -- End scalbl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +large_integers: + .long 65536 + .long -65536 + .type large_integers,@object + .size large_integers,8 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalbln_gen.S b/external/sgx_libm/intel64/scalbln_gen.S new file mode 100644 index 0000000000..54f08a639c --- /dev/null +++ b/external/sgx_libm/intel64/scalbln_gen.S @@ -0,0 +1,195 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbln_gen.c" + .text +..TXTST0: +# -- Begin scalbln + .text + .align 16,0x90 + .globl scalbln +scalbln: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_scalbln.1: +..L2: + + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %esi + movl %esi, %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + je ..B1.17 +..B1.2: + xorb %r8b, %r8b + testl %ecx, %ecx + jne ..B1.7 +..B1.3: + testl $1048575, -4(%rsp) + jne ..B1.6 +..B1.4: + cmpl $0, -8(%rsp) + jne ..B1.6 +..B1.5: + movsd -8(%rsp), %xmm0 + ret +..B1.6: + lea _TWO_55(%rip), %rax + movb $1, %r8b + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %esi + movl %esi, %ecx + andl $32752, %ecx + shrl $4, %ecx + addl $-55, %ecx +..B1.7: + movl $65536, %eax + cmpq $65536, %rdi + cmovg %rax, %rdi + movq $-65536, %rdx + cmpq $-65536, %rdi + movslq %ecx, %rcx + cmovl %rdx, %rdi + addq %rdi, %rcx + testl %ecx, %ecx + jle ..B1.12 +..B1.8: + cmpl $2047, %ecx + jge ..B1.11 +..B1.9: + andl $2047, %ecx + andl $-32753, %esi + shll $4, %ecx + orl %ecx, %esi + movw %si, -2(%rsp) + movsd -8(%rsp), %xmm0 +..B1.10: + ret +..B1.11: + movb -1(%rsp), %al + lea _large_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.12: + cmpl $-52, %ecx + jl ..B1.16 +..B1.13: + addl $55, %ecx + lea 8+_TWO_55(%rip), %rax + andl $2047, %ecx + andl $-32753, %esi + shll $4, %ecx + orl %ecx, %esi + movw %si, -2(%rsp) + testb %r8b, %r8b + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + je ..B1.15 +..B1.14: + testq %rdi, %rdi + jl ..B1.10 +..B1.15: + ret +..B1.16: + movb -1(%rsp), %al + lea _small_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.17: + lea _ones(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type scalbln,@function + .size scalbln,.-scalbln + .data +# -- End scalbln + .section .rodata, "a" + .align 4 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .type _TWO_55,@object + .size _TWO_55,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalblnf.S b/external/sgx_libm/intel64/scalblnf.S new file mode 100644 index 0000000000..917c6bf513 --- /dev/null +++ b/external/sgx_libm/intel64/scalblnf.S @@ -0,0 +1,186 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalblnf.c" + .text +..TXTST0: +# -- Begin scalblnf + .text + .align 16,0x90 + .globl scalblnf +scalblnf: +# parameter 1: %xmm0 +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_scalblnf.1: +..L2: + + movq %rdi, %r8 + movss %xmm0, -8(%rsp) + movzwl -6(%rsp), %eax + movl %eax, %esi + andl $32640, %esi + shrl $7, %esi + cmpl $255, %esi + je ..B1.9 +..B1.2: + xorb %dil, %dil + testl %esi, %esi + jne ..B1.5 +..B1.3: + testl $8388607, -8(%rsp) + je ..B1.9 +..B1.4: + movss -8(%rsp), %xmm0 + movb $1, %dil + mulss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, -8(%rsp) + movzwl -6(%rsp), %eax + movl %eax, %esi + andl $32640, %esi + shrl $7, %esi + addl $-25, %esi +..B1.5: + movl $65536, %edx + cmpq $65536, %r8 + cmovg %rdx, %r8 + movq $-65536, %rcx + cmpq $-65536, %r8 + movslq %esi, %rsi + cmovl %rcx, %r8 + addq %r8, %rsi + testl %esi, %esi + jle ..B1.11 +..B1.6: + cmpl $255, %esi + jge ..B1.10 +..B1.7: + movzbl %sil, %esi + andl $-32641, %eax + shll $7, %esi + orl %esi, %eax + movw %ax, -6(%rsp) + movss -8(%rsp), %xmm0 +..B1.8: + ret +..B1.9: + movss -8(%rsp), %xmm0 + ret +..B1.10: + movb -5(%rsp), %al + lea _large_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + ret +..B1.11: + cmpl $-23, %esi + jl ..B1.15 +..B1.12: + addl $25, %esi + andl $-32641, %eax + movzbl %sil, %esi + shll $7, %esi + orl %esi, %eax + movw %ax, -6(%rsp) + testb %dil, %dil + movss -8(%rsp), %xmm0 + mulss .L_2il0floatpacket.3(%rip), %xmm0 + je ..B1.14 +..B1.13: + testq %r8, %r8 + jl ..B1.8 +..B1.14: + ret +..B1.15: + movb -5(%rsp), %al + lea _small_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.2(%rip), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type scalblnf,@function + .size scalblnf,.-scalblnf + .data +# -- End scalblnf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x0d800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x33000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalblnl.S b/external/sgx_libm/intel64/scalblnl.S new file mode 100644 index 0000000000..f934b79dfa --- /dev/null +++ b/external/sgx_libm/intel64/scalblnl.S @@ -0,0 +1,322 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalblnl.c" + .text +..TXTST0: +# -- Begin scalblnl + .text + .align 16,0x90 + .globl scalblnl +scalblnl: +# parameter 1: 32 + %rsp +# parameter 2: %rdi +..B1.1: + .cfi_startproc +..___tag_value_scalblnl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 40(%rsp), %eax + movl %eax, %r9d + andq $32767, %r9 + cmpq $32767, %r9 + je ..B1.39 +..B1.4: + testq %r9, %r9 + jne ..B1.12 +..B1.5: + cmpq $0, 32(%rsp) + je ..B1.15 +..B1.6: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.7: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.8: + fldcw 16(%rsp) +..B1.9: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) +..B1.10: + fldcw 18(%rsp) +..B1.11: + movzwl 40(%rsp), %eax + movl %eax, %ecx + andl $32767, %ecx + movl %ecx, %r9d + addq $-75, %r9 +..B1.12: + movl $65536, %esi + cmpq $65536, %rdi + cmovg %rsi, %rdi + movq $-65536, %r8 + xorb %dl, %dl + cmpq $-65536, %rdi + cmovl %r8, %rdi + lea (%r9,%rdi), %rcx + testq %rcx, %rcx + jle ..B1.23 +..B1.13: + cmpq $32767, %rcx + jge ..B1.16 +..B1.14: + andl $-32768, %eax + andl $32767, %ecx + orl %ecx, %eax + movw %ax, 40(%rsp) + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.15: + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.16: + movzwl 18(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.20 +..B1.17: + orl $-64768, %ecx + movw %cx, 16(%rsp) +..B1.18: + fldcw 16(%rsp) +..B1.19: + movb $1, %dl +..B1.20: + movb 41(%rsp), %al + lea _large_value_80(%rip), %rsi + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %ecx + shlq $4, %rcx + testb %dl, %dl + fldt (%rsi,%rcx) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.22 +..B1.21: + fldcw 18(%rsp) +..B1.22: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.23: + cmpq $-63, %rcx + jl ..B1.31 +..B1.24: + andl $-32768, %eax + lea 75(%r9,%rdi), %rdx + andl $32767, %edx + orl %edx, %eax + movzwl 18(%rsp), %edx + movw %ax, 40(%rsp) + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.30 +..B1.25: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.26: + fldcw 16(%rsp) +..B1.27: + fldt 32(%rsp) + lea 8+_TWO_75(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.28: + fldcw 18(%rsp) +..B1.29: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.30: + fldt 32(%rsp) + lea 8+_TWO_75(%rip), %rax + fmull (%rax) + fstpt (%rsp) + jmp ..B1.29 +..B1.31: + movzwl 18(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.35 +..B1.32: + orl $-64768, %ecx + movw %cx, 16(%rsp) +..B1.33: + fldcw 16(%rsp) +..B1.34: + movb $1, %dl +..B1.35: + movb 41(%rsp), %al + lea _small_value_80(%rip), %rsi + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %ecx + shlq $4, %rcx + testb %dl, %dl + fldt (%rsi,%rcx) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.37 +..B1.36: + fldcw 18(%rsp) +..B1.37: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.38: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) + jmp ..B1.11 +..B1.39: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.40: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.41: + fldcw 16(%rsp) +..B1.42: + fldt 32(%rsp) + fstpt (%rsp) +..B1.43: + fldcw 18(%rsp) +..B1.44: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.45: + fldt 32(%rsp) + fstpt (%rsp) + jmp ..B1.44 + .align 16,0x90 + .cfi_endproc + .type scalblnl,@function + .size scalblnl,.-scalblnl + .data +# -- End scalblnl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalbn_gen.S b/external/sgx_libm/intel64/scalbn_gen.S new file mode 100644 index 0000000000..27322b85b0 --- /dev/null +++ b/external/sgx_libm/intel64/scalbn_gen.S @@ -0,0 +1,194 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbn_gen.c" + .text +..TXTST0: +# -- Begin scalbn + .text + .align 16,0x90 + .globl scalbn +scalbn: +# parameter 1: %xmm0 +# parameter 2: %edi +..B1.1: + .cfi_startproc +..___tag_value_scalbn.1: +..L2: + + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %esi + movl %esi, %ecx + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + je ..B1.17 +..B1.2: + xorb %r8b, %r8b + testl %ecx, %ecx + jne ..B1.7 +..B1.3: + testl $1048575, -4(%rsp) + jne ..B1.6 +..B1.4: + cmpl $0, -8(%rsp) + jne ..B1.6 +..B1.5: + movsd -8(%rsp), %xmm0 + ret +..B1.6: + lea _TWO_55(%rip), %rax + movb $1, %r8b + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) + movzwl -2(%rsp), %esi + movl %esi, %ecx + andl $32752, %ecx + shrl $4, %ecx + addl $-55, %ecx +..B1.7: + movl $65536, %eax + cmpl $65536, %edi + cmovg %eax, %edi + movl $-65536, %edx + cmpl $-65536, %edi + cmovle %edx, %edi + lea (%rcx,%rdi), %eax + testl %eax, %eax + jle ..B1.12 +..B1.8: + cmpl $2047, %eax + jge ..B1.11 +..B1.9: + andl $2047, %eax + andl $-32753, %esi + shll $4, %eax + orl %eax, %esi + movw %si, -2(%rsp) + movsd -8(%rsp), %xmm0 +..B1.10: + ret +..B1.11: + movb -1(%rsp), %al + lea _large_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.12: + cmpl $-52, %eax + jl ..B1.16 +..B1.13: + lea 8+_TWO_55(%rip), %rdx + lea 55(%rcx,%rdi), %eax + andl $2047, %eax + andl $-32753, %esi + shll $4, %eax + orl %eax, %esi + movw %si, -2(%rsp) + testb %r8b, %r8b + movsd -8(%rsp), %xmm0 + mulsd (%rdx), %xmm0 + je ..B1.15 +..B1.14: + testl %edi, %edi + jl ..B1.10 +..B1.15: + ret +..B1.16: + movb -1(%rsp), %al + lea _small_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + ret +..B1.17: + lea _ones(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type scalbn,@function + .size scalbn,.-scalbn + .data +# -- End scalbn + .section .rodata, "a" + .align 4 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .long 0 + .long 1015021568 + .type _TWO_55,@object + .size _TWO_55,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalbnf.S b/external/sgx_libm/intel64/scalbnf.S new file mode 100644 index 0000000000..23c5beb1a1 --- /dev/null +++ b/external/sgx_libm/intel64/scalbnf.S @@ -0,0 +1,185 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbnf.c" + .text +..TXTST0: +# -- Begin scalbnf + .text + .align 16,0x90 + .globl scalbnf +scalbnf: +# parameter 1: %xmm0 +# parameter 2: %edi +..B1.1: + .cfi_startproc +..___tag_value_scalbnf.1: +..L2: + + movl %edi, %r8d + movss %xmm0, -8(%rsp) + movzwl -6(%rsp), %eax + movl %eax, %esi + andl $32640, %esi + shrl $7, %esi + cmpl $255, %esi + je ..B1.9 +..B1.2: + xorb %dil, %dil + testl %esi, %esi + jne ..B1.5 +..B1.3: + testl $8388607, -8(%rsp) + je ..B1.9 +..B1.4: + movss -8(%rsp), %xmm0 + movb $1, %dil + mulss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, -8(%rsp) + movzwl -6(%rsp), %eax + movl %eax, %esi + andl $32640, %esi + shrl $7, %esi + addl $-25, %esi +..B1.5: + movl $65536, %edx + cmpl $65536, %r8d + cmovg %edx, %r8d + movl $-65536, %ecx + cmpl $-65536, %r8d + cmovle %ecx, %r8d + lea (%rsi,%r8), %edx + testl %edx, %edx + jle ..B1.11 +..B1.6: + cmpl $255, %edx + jge ..B1.10 +..B1.7: + movzbl %dl, %edx + andl $-32641, %eax + shll $7, %edx + orl %edx, %eax + movw %ax, -6(%rsp) + movss -8(%rsp), %xmm0 +..B1.8: + ret +..B1.9: + movss -8(%rsp), %xmm0 + ret +..B1.10: + movb -5(%rsp), %al + lea _large_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + ret +..B1.11: + cmpl $-23, %edx + jl ..B1.15 +..B1.12: + andl $-32641, %eax + lea 25(%rsi,%r8), %edx + movzbl %dl, %edx + shll $7, %edx + orl %edx, %eax + movw %ax, -6(%rsp) + testb %dil, %dil + movss -8(%rsp), %xmm0 + mulss .L_2il0floatpacket.3(%rip), %xmm0 + je ..B1.14 +..B1.13: + testl %r8d, %r8d + jl ..B1.8 +..B1.14: + ret +..B1.15: + movb -5(%rsp), %al + lea _small_value_32(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + movss (%rdx,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.2(%rip), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type scalbnf,@function + .size scalbnf,.-scalbnf + .data +# -- End scalbnf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x0d800000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0x33000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/scalbnl.S b/external/sgx_libm/intel64/scalbnl.S new file mode 100644 index 0000000000..3d755cd844 --- /dev/null +++ b/external/sgx_libm/intel64/scalbnl.S @@ -0,0 +1,321 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "scalbnl.c" + .text +..TXTST0: +# -- Begin scalbnl + .text + .align 16,0x90 + .globl scalbnl +scalbnl: +# parameter 1: 32 + %rsp +# parameter 2: %edi +..B1.1: + .cfi_startproc +..___tag_value_scalbnl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 40(%rsp), %r8d + movl %r8d, %esi + andl $32767, %esi + cmpl $32767, %esi + je ..B1.39 +..B1.4: + testl %esi, %esi + jne ..B1.12 +..B1.5: + cmpq $0, 32(%rsp) + je ..B1.15 +..B1.6: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.7: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.8: + fldcw 16(%rsp) +..B1.9: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) +..B1.10: + fldcw 18(%rsp) +..B1.11: + movzwl 40(%rsp), %r8d + movl %r8d, %esi + andl $32767, %esi + addl $-75, %esi +..B1.12: + movl $65536, %edx + cmpl $65536, %edi + cmovg %edx, %edi + movl $-65536, %ecx + xorb %al, %al + cmpl $-65536, %edi + cmovle %ecx, %edi + lea (%rsi,%rdi), %edx + testl %edx, %edx + jle ..B1.23 +..B1.13: + cmpl $32767, %edx + jge ..B1.16 +..B1.14: + andl $-32768, %r8d + andl $32767, %edx + orl %edx, %r8d + movw %r8w, 40(%rsp) + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.15: + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.16: + movzwl 18(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.20 +..B1.17: + orl $-64768, %ecx + movw %cx, 16(%rsp) +..B1.18: + fldcw 16(%rsp) +..B1.19: + movb $1, %al +..B1.20: + movb 41(%rsp), %dl + lea _large_value_80(%rip), %rsi + andb $-128, %dl + shrb $7, %dl + fldt (%rsi) + movzbl %dl, %ecx + shlq $4, %rcx + testb %al, %al + fldt (%rsi,%rcx) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.22 +..B1.21: + fldcw 18(%rsp) +..B1.22: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.23: + cmpl $-63, %edx + jl ..B1.31 +..B1.24: + andl $-32768, %r8d + lea 75(%rsi,%rdi), %eax + andl $32767, %eax + orl %eax, %r8d + movzwl 18(%rsp), %eax + movl %eax, %edx + andl $768, %edx + movw %r8w, 40(%rsp) + cmpl $768, %edx + je ..B1.30 +..B1.25: + orl $-64768, %eax + movw %ax, 16(%rsp) +..B1.26: + fldcw 16(%rsp) +..B1.27: + fldt 32(%rsp) + lea 8+_TWO_75(%rip), %rax + fmull (%rax) + fstpt (%rsp) +..B1.28: + fldcw 18(%rsp) +..B1.29: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.30: + fldt 32(%rsp) + lea 8+_TWO_75(%rip), %rax + fmull (%rax) + fstpt (%rsp) + jmp ..B1.29 +..B1.31: + movzwl 18(%rsp), %ecx + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.35 +..B1.32: + orl $-64768, %ecx + movw %cx, 16(%rsp) +..B1.33: + fldcw 16(%rsp) +..B1.34: + movb $1, %al +..B1.35: + movb 41(%rsp), %dl + lea _small_value_80(%rip), %rsi + andb $-128, %dl + shrb $7, %dl + fldt (%rsi) + movzbl %dl, %ecx + shlq $4, %rcx + testb %al, %al + fldt (%rsi,%rcx) + fmulp %st, %st(1) + fstpt (%rsp) + je ..B1.37 +..B1.36: + fldcw 18(%rsp) +..B1.37: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.38: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) + jmp ..B1.11 +..B1.39: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.45 +..B1.40: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.41: + fldcw 16(%rsp) +..B1.42: + fldt 32(%rsp) + fstpt (%rsp) +..B1.43: + fldcw 18(%rsp) +..B1.44: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.45: + fldt 32(%rsp) + fstpt (%rsp) + jmp ..B1.44 + .align 16,0x90 + .cfi_endproc + .type scalbnl,@function + .size scalbnl,.-scalbnl + .data +# -- End scalbnl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/signbit.S b/external/sgx_libm/intel64/signbit.S new file mode 100644 index 0000000000..f5f7efaf4e --- /dev/null +++ b/external/sgx_libm/intel64/signbit.S @@ -0,0 +1,233 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "signbit.c" + .text +..TXTST0: +# -- Begin __signbitd + .text + .align 16,0x90 + .globl __signbitd +__signbitd: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value___signbitd.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __signbitd,@function + .size __signbitd,.-__signbitd + .data +# -- End __signbitd + .text +# -- Begin signbitd + .text + .align 16,0x90 + .globl signbitd +signbitd: +# parameter 1: %xmm0 +..B2.1: + .cfi_startproc +..___tag_value_signbitd.4: +..L5: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type signbitd,@function + .size signbitd,.-signbitd + .data +# -- End signbitd + .text +# -- Begin __signbit + .text + .align 16,0x90 + .globl __signbit +__signbit: +# parameter 1: %xmm0 +..B3.1: + .cfi_startproc +..___tag_value___signbit.7: +..L8: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __signbit,@function + .size __signbit,.-__signbit + .data +# -- End __signbit + .text +# -- Begin signbit + .text + .align 16,0x90 + .globl signbit +signbit: +# parameter 1: %xmm0 +..B4.1: + .cfi_startproc +..___tag_value_signbit.10: +..L11: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type signbit,@function + .size signbit,.-signbit + .data +# -- End signbit + .text +# -- Begin __signbitf + .text + .align 16,0x90 + .globl __signbitf +__signbitf: +# parameter 1: %xmm0 +..B5.1: + .cfi_startproc +..___tag_value___signbitf.13: +..L14: + + movd %xmm0, %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __signbitf,@function + .size __signbitf,.-__signbitf + .data +# -- End __signbitf + .text +# -- Begin signbitf + .text + .align 16,0x90 + .globl signbitf +signbitf: +# parameter 1: %xmm0 +..B6.1: + .cfi_startproc +..___tag_value_signbitf.16: +..L17: + + movd %xmm0, %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type signbitf,@function + .size signbitf,.-signbitf + .data +# -- End signbitf + .text +# -- Begin __signbitl + .text + .align 16,0x90 + .globl __signbitl +__signbitl: +# parameter 1: 8 + %rsp +..B7.1: + .cfi_startproc +..___tag_value___signbitl.19: +..L20: + + movzbl 17(%rsp), %eax + shrl $7, %eax + movzwl 16(%rsp), %edx + shll $15, %eax + andl $32767, %edx + orl %edx, %eax + shll $16, %eax + movzwl 14(%rsp), %ecx + orl %ecx, %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type __signbitl,@function + .size __signbitl,.-__signbitl + .data +# -- End __signbitl + .text +# -- Begin signbitl + .text + .align 16,0x90 + .globl signbitl +signbitl: +# parameter 1: 8 + %rsp +..B8.1: + .cfi_startproc +..___tag_value_signbitl.22: +..L23: + + movzbl 17(%rsp), %eax + shrl $7, %eax + movzwl 16(%rsp), %edx + shll $15, %eax + andl $32767, %edx + orl %edx, %eax + shll $16, %eax + movzwl 14(%rsp), %ecx + orl %ecx, %eax + shrl $31, %eax + ret + .align 16,0x90 + .cfi_endproc + .type signbitl,@function + .size signbitl,.-signbitl + .data +# -- End signbitl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/significand_gen.S b/external/sgx_libm/intel64/significand_gen.S new file mode 100644 index 0000000000..d3f789b75d --- /dev/null +++ b/external/sgx_libm/intel64/significand_gen.S @@ -0,0 +1,119 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "significand_gen.c" + .text +..TXTST0: +# -- Begin significand + .text + .align 16,0x90 + .globl significand +significand: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_significand.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %ecx + movl %ecx, %edx + andl $2147483647, %edx + lea -1048576(%rdx), %eax + cmpl $2145386496, %eax + jb ..B1.8 +..B1.2: + testl %eax, %eax + jge ..B1.7 +..B1.3: + movl -8(%rsp), %eax + orl %eax, %edx + jne ..B1.5 +..B1.4: + movsd -8(%rsp), %xmm0 + ret +..B1.5: + lea _TWO_55(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + andl $-2146435073, %edx + orl $1072693248, %edx + movl %edx, -4(%rsp) + movsd -8(%rsp), %xmm0 +..B1.6: + ret +..B1.7: + lea _ones(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 + ret +..B1.8: + andl $-2146435073, %ecx + orl $1072693248, %ecx + movl %ecx, -4(%rsp) + movsd -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type significand,@function + .size significand,.-significand + .data +# -- End significand + .section .rodata, "a" + .align 4 + .align 4 +_TWO_55: + .long 0 + .long 1130364928 + .type _TWO_55,@object + .size _TWO_55,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/significandf_gen.S b/external/sgx_libm/intel64/significandf_gen.S new file mode 100644 index 0000000000..390a851e54 --- /dev/null +++ b/external/sgx_libm/intel64/significandf_gen.S @@ -0,0 +1,101 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "significandf_gen.c" + .text +..TXTST0: +# -- Begin significandf + .text + .align 16,0x90 + .globl significandf +significandf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_significandf.1: +..L2: + + movaps %xmm0, %xmm1 + movd %xmm1, %ecx + movss %xmm1, -8(%rsp) + movl %ecx, %edx + andl $2147483647, %edx + lea -8388608(%rdx), %eax + cmpl $2130706432, %eax + jb ..B1.6 +..B1.2: + decl %edx + cmpl $2139095039, %edx + jae ..B1.4 +..B1.3: + movss .L_2il0floatpacket.0(%rip), %xmm0 + mulss %xmm0, %xmm1 + movd %xmm1, %eax + andl $-2139095041, %eax + orl $1065353216, %eax + movl %eax, -8(%rsp) + movss -8(%rsp), %xmm0 + ret +..B1.4: + movss -8(%rsp), %xmm0 +..B1.5: + ret +..B1.6: + andl $-2139095041, %ecx + orl $1065353216, %ecx + movl %ecx, -8(%rsp) + movss -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type significandf,@function + .size significandf,.-significandf + .data +# -- End significandf + .section .rodata, "a" + .align 4 + .align 4 +.L_2il0floatpacket.0: + .long 0x4c000000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/significandl.S b/external/sgx_libm/intel64/significandl.S new file mode 100644 index 0000000000..051c22980f --- /dev/null +++ b/external/sgx_libm/intel64/significandl.S @@ -0,0 +1,164 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "significandl.c" + .text +..TXTST0: +# -- Begin significandl + .text + .align 16,0x90 + .globl significandl +significandl: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_significandl.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + fnstcw 18(%rsp) +..B1.3: + movzwl 40(%rsp), %edx + movl %edx, %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.15 +..B1.4: + testl %eax, %eax + jne ..B1.13 +..B1.5: + cmpq $0, 32(%rsp) + je ..B1.12 +..B1.6: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.14 +..B1.7: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.8: + fldcw 16(%rsp) +..B1.9: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) +..B1.10: + fldcw 18(%rsp) +..B1.11: + movzwl 40(%rsp), %eax + andl $-32768, %eax + orl $-49153, %eax + movw %ax, 40(%rsp) + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.12: + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.13: + andl $-32768, %edx + orl $-49153, %edx + movw %dx, 40(%rsp) + fldt 32(%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.14: + fldt 32(%rsp) + lea _TWO_75(%rip), %rax + fmull (%rax) + fstpt 32(%rsp) + jmp ..B1.11 +..B1.15: + movzwl 18(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.21 +..B1.16: + orl $-64768, %edx + movw %dx, 16(%rsp) +..B1.17: + fldcw 16(%rsp) +..B1.18: + fldt 32(%rsp) + fstpt (%rsp) +..B1.19: + fldcw 18(%rsp) +..B1.20: + fldt (%rsp) + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 +..B1.21: + fldt 32(%rsp) + fstpt (%rsp) + jmp ..B1.20 + .align 16,0x90 + .cfi_endproc + .type significandl,@function + .size significandl,.-significandl + .data +# -- End significandl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sin_gen.S b/external/sgx_libm/intel64/sin_gen.S new file mode 100644 index 0000000000..b0a8199ab6 --- /dev/null +++ b/external/sgx_libm/intel64/sin_gen.S @@ -0,0 +1,1150 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sin_gen.c" + .text +..TXTST0: +# -- Begin sin + .text + .align 16,0x90 + .globl sin +sin: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_sin.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) +..B1.2: + pextrw $3, %xmm0, %eax + andw $32767, %ax + subw $12336, %ax + cmpw $4293, %ax + ja .L_2TAG_PACKET_0.0.1 + movq PI32INV(%rip), %xmm1 + mulsd %xmm0, %xmm1 + movapd ONEHALF(%rip), %xmm5 + movsd SIGN_MASK(%rip), %xmm4 + andpd %xmm0, %xmm4 + orps %xmm4, %xmm5 + addpd %xmm5, %xmm1 + cvttsd2si %xmm1, %edx + cvtsi2sd %edx, %xmm1 + movapd P_2(%rip), %xmm6 + movq $0x3fb921fb54400000, %r8 + movd %r8, %xmm3 + movapd SC_4(%rip), %xmm5 + pshufd $68, %xmm0, %xmm4 + mulsd %xmm1, %xmm3 + unpcklpd %xmm1, %xmm1 + andl $63, %edx + shll $5, %edx + lea Ctable(%rip), %rax + addq %rdx, %rax + mulpd %xmm1, %xmm6 + mulsd P_3(%rip), %xmm1 + subsd %xmm3, %xmm4 + movq 8(%rax), %xmm7 + subsd %xmm3, %xmm0 + movapd %xmm4, %xmm3 + unpcklpd %xmm4, %xmm3 + subsd %xmm6, %xmm4 + pshufd $68, %xmm0, %xmm0 + movapd (%rax), %xmm2 + mulpd %xmm0, %xmm5 + subpd %xmm6, %xmm0 + mulsd %xmm4, %xmm7 + subsd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subsd %xmm6, %xmm3 + movapd SC_2(%rip), %xmm6 + subsd %xmm3, %xmm1 + movq 24(%rax), %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm7 + mulsd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulsd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulsd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movq %xmm3, %xmm0 + addsd 8(%rax), %xmm3 + mulpd %xmm7, %xmm1 + movq %xmm4, %xmm7 + addsd %xmm3, %xmm4 + addpd %xmm5, %xmm6 + movq 8(%rax), %xmm5 + subsd %xmm3, %xmm5 + subsd %xmm4, %xmm3 + addsd 16(%rax), %xmm1 + mulpd %xmm2, %xmm6 + addsd %xmm0, %xmm5 + addsd %xmm7, %xmm3 + addsd %xmm5, %xmm1 + addsd %xmm3, %xmm1 + addsd %xmm6, %xmm1 + unpckhpd %xmm6, %xmm6 + movq %xmm4, %xmm0 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_0.0.1: + jg .L_2TAG_PACKET_1.0.1 + shrl $4, %eax + cmpw $3325, %ax + jne .L_2TAG_PACKET_2.0.1 + mulsd ALL_ONES(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_2.0.1: + movq TWO_POW_55(%rip), %xmm3 + mulsd %xmm0, %xmm3 + subsd %xmm0, %xmm3 + mulsd TWO_POW_M55(%rip), %xmm3 + jmp ..B1.4 +.L_2TAG_PACKET_1.0.1: + pextrw $3, %xmm0, %eax + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_3.0.1 + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + subl $16224, %ecx + shrl $7, %ecx + andl $65532, %ecx + lea PI_INV_TABLE(%rip), %r11 + addq %r11, %rcx + movd %xmm0, %rax + movl 20(%rcx), %r10d + movl 24(%rcx), %r8d + movl %eax, %edx + shrq $21, %rax + orl $-2147483648, %eax + shrl $11, %eax + movl %r10d, %r9d + imulq %rdx, %r10 + imulq %rax, %r9 + imulq %rax, %r8 + movl 16(%rcx), %esi + movl 12(%rcx), %edi + movl %r10d, %r11d + shrq $32, %r10 + addq %r10, %r9 + addq %r8, %r11 + movl %r11d, %r8d + shrq $32, %r11 + addq %r11, %r9 + movl %esi, %r10d + imulq %rdx, %rsi + imulq %rax, %r10 + movl %edi, %r11d + imulq %rdx, %rdi + movl %esi, %ebx + shrq $32, %rsi + addq %rbx, %r9 + movl %r9d, %ebx + shrq $32, %r9 + addq %rsi, %r10 + addq %r9, %r10 + shlq $32, %rbx + orq %rbx, %r8 + imulq %rax, %r11 + movl 8(%rcx), %r9d + movl 4(%rcx), %esi + movl %edi, %ebx + shrq $32, %rdi + addq %rbx, %r10 + movl %r10d, %ebx + shrq $32, %r10 + addq %rdi, %r11 + addq %r10, %r11 + movq %r9, %rdi + imulq %rdx, %r9 + imulq %rax, %rdi + movl %r9d, %r10d + shrq $32, %r9 + addq %r10, %r11 + movl %r11d, %r10d + shrq $32, %r11 + addq %r9, %rdi + addq %r11, %rdi + movq %rsi, %r9 + imulq %rdx, %rsi + imulq %rax, %r9 + shlq $32, %r10 + orq %rbx, %r10 + movl (%rcx), %eax + movl %esi, %r11d + shrq $32, %rsi + addq %r11, %rdi + movl %edi, %r11d + shrq $32, %rdi + addq %rsi, %r9 + addq %rdi, %r9 + imulq %rax, %rdx + pextrw $3, %xmm0, %ebx + lea PI_INV_TABLE(%rip), %rdi + subq %rdi, %rcx + addl %ecx, %ecx + addl %ecx, %ecx + addl %ecx, %ecx + addl $19, %ecx + movl $32768, %esi + andl %ebx, %esi + shrl $4, %ebx + andl $2047, %ebx + subl $1023, %ebx + subl %ebx, %ecx + addq %rdx, %r9 + movl %ecx, %edx + addl $32, %edx + cmpl $1, %ecx + jl .L_2TAG_PACKET_4.0.1 + negl %ecx + addl $29, %ecx + shll %cl, %r9d + movl %r9d, %edi + andl $536870911, %r9d + testl $268435456, %r9d + jne .L_2TAG_PACKET_5.0.1 + shrl %cl, %r9d + movl $0, %ebx + shlq $32, %r9 + orq %r11, %r9 +.L_2TAG_PACKET_6.0.1: +.L_2TAG_PACKET_7.0.1: + cmpq $0, %r9 + je .L_2TAG_PACKET_8.0.1 +.L_2TAG_PACKET_9.0.1: + bsr %r9, %r11 + movl $29, %ecx + subl %r11d, %ecx + jle .L_2TAG_PACKET_10.0.1 + shlq %cl, %r9 + movq %r10, %rax + shlq %cl, %r10 + addl %ecx, %edx + negl %ecx + addl $64, %ecx + shrq %cl, %rax + shrq %cl, %r8 + orq %rax, %r9 + orq %r8, %r10 +.L_2TAG_PACKET_11.0.1: + cvtsi2sdq %r9, %xmm0 + shrq $1, %r10 + cvtsi2sdq %r10, %xmm3 + xorpd %xmm4, %xmm4 + shll $4, %edx + negl %edx + addl $16368, %edx + orl %esi, %edx + xorl %ebx, %edx + pinsrw $3, %edx, %xmm4 + movq PI_4(%rip), %xmm2 + movq 8+PI_4(%rip), %xmm6 + xorpd %xmm5, %xmm5 + subl $1008, %edx + pinsrw $3, %edx, %xmm5 + mulsd %xmm4, %xmm0 + shll $16, %esi + sarl $31, %esi + mulsd %xmm5, %xmm3 + movq %xmm0, %xmm1 + mulsd %xmm2, %xmm0 + shrl $29, %edi + addsd %xmm3, %xmm1 + mulsd %xmm2, %xmm3 + addl %esi, %edi + xorl %esi, %edi + mulsd %xmm1, %xmm6 + movl %edi, %eax + addsd %xmm3, %xmm6 + movq %xmm0, %xmm2 + addsd %xmm6, %xmm0 + subsd %xmm0, %xmm2 + addsd %xmm2, %xmm6 +.L_2TAG_PACKET_12.0.1: + movq PI32INV(%rip), %xmm1 + mulsd %xmm0, %xmm1 + movq ONEHALF(%rip), %xmm5 + movq SIGN_MASK(%rip), %xmm4 + andpd %xmm0, %xmm4 + orps %xmm4, %xmm5 + addpd %xmm5, %xmm1 + cvttsd2si %xmm1, %edx + cvtsi2sd %edx, %xmm1 + movq P_1(%rip), %xmm3 + movapd P_2(%rip), %xmm2 + mulsd %xmm1, %xmm3 + unpcklpd %xmm1, %xmm1 + shll $3, %eax + addl $1865216, %edx + movq %xmm0, %xmm4 + addl %eax, %edx + andl $63, %edx + movapd SC_4(%rip), %xmm5 + lea Ctable(%rip), %rax + shll $5, %edx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subsd %xmm3, %xmm0 + mulsd P_3(%rip), %xmm1 + subsd %xmm3, %xmm4 + movq 8(%rax), %xmm7 + unpcklpd %xmm0, %xmm0 + movq %xmm4, %xmm3 + subsd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + mulsd %xmm4, %xmm7 + subsd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subsd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subsd %xmm3, %xmm1 + movq 24(%rax), %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm7 + subsd %xmm6, %xmm1 + movapd SC_2(%rip), %xmm6 + mulsd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulsd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulsd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movq %xmm3, %xmm0 + addsd 8(%rax), %xmm3 + mulpd %xmm7, %xmm1 + movq %xmm4, %xmm7 + addsd %xmm3, %xmm4 + addpd %xmm5, %xmm6 + movq 8(%rax), %xmm5 + subsd %xmm3, %xmm5 + subsd %xmm4, %xmm3 + addsd 16(%rax), %xmm1 + mulpd %xmm2, %xmm6 + addsd %xmm0, %xmm5 + addsd %xmm7, %xmm3 + addsd %xmm5, %xmm1 + addsd %xmm3, %xmm1 + addsd %xmm6, %xmm1 + unpckhpd %xmm6, %xmm6 + movq %xmm4, %xmm0 + addsd %xmm6, %xmm1 + addsd %xmm1, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_8.0.1: + addl $64, %edx + movq %r10, %r9 + movq %r8, %r10 + movq $0, %r8 + cmpq $0, %r9 + jne .L_2TAG_PACKET_9.0.1 + addl $64, %edx + movq %r10, %r9 + movq %r8, %r10 + cmpq $0, %r9 + jne .L_2TAG_PACKET_9.0.1 + xorpd %xmm0, %xmm0 + xorpd %xmm6, %xmm6 + jmp .L_2TAG_PACKET_12.0.1 +.L_2TAG_PACKET_10.0.1: + je .L_2TAG_PACKET_11.0.1 + negl %ecx + shrq %cl, %r10 + movq %r9, %rax + shrq %cl, %r9 + subl %ecx, %edx + negl %ecx + addl $64, %ecx + shlq %cl, %rax + orq %rax, %r10 + jmp .L_2TAG_PACKET_11.0.1 +.L_2TAG_PACKET_4.0.1: + negl %ecx + shlq $32, %r9 + orq %r11, %r9 + shlq %cl, %r9 + movq %r9, %rdi + testl $-2147483648, %r9d + jne .L_2TAG_PACKET_13.0.1 + shrl %cl, %r9d + movl $0, %ebx + shrq $3, %rdi + jmp .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_5.0.1: + shrl %cl, %r9d + movl $536870912, %ebx + shrl %cl, %ebx + shlq $32, %r9 + orq %r11, %r9 + shlq $32, %rbx + addl $536870912, %edi + movq $0, %rcx + movq $0, %r11 + subq %r8, %rcx + sbbq %r10, %r11 + sbbq %r9, %rbx + movq %rcx, %r8 + movq %r11, %r10 + movq %rbx, %r9 + movl $32768, %ebx + jmp .L_2TAG_PACKET_6.0.1 +.L_2TAG_PACKET_13.0.1: + shrl %cl, %r9d + movq $0x100000000, %rbx + shrq %cl, %rbx + movq $0, %rcx + movq $0, %r11 + subq %r8, %rcx + sbbq %r10, %r11 + sbbq %r9, %rbx + movq %rcx, %r8 + movq %r11, %r10 + movq %rbx, %r9 + movl $32768, %ebx + shrq $3, %rdi + addl $536870912, %edi + jmp .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_3.0.1: + movq 8(%rsp), %xmm0 + mulsd NEG_ZERO(%rip), %xmm0 + movq %xmm0, (%rsp) +.L_2TAG_PACKET_14.0.1: +..B1.4: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type sin,@function + .size sin,.-sin + .data +# -- End sin + .section .rodata, "a" + .align 16 + .align 16 +ONEHALF: + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .type ONEHALF,@object + .size ONEHALF,16 + .align 16 +P_2: + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .type P_2,@object + .size P_2,16 + .align 16 +SC_4: + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .type SC_4,@object + .size SC_4,16 + .align 16 +Ctable: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 1072693248 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1071644672 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 1071644672 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1070596096 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 1070596096 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1069547520 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 1072683149 + .long 1073741824 + .long 3163061750 + .long 0 + .long 3217031168 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 1072652951 + .long 536870912 + .long 1014325783 + .long 0 + .long 3218079744 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 1072602945 + .long 3758096384 + .long 1015505073 + .long 0 + .long 3218079744 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 1072533611 + .long 536870912 + .long 1014257638 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 1072445618 + .long 2147483648 + .long 3161907377 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 1072339814 + .long 3758096384 + .long 1010431536 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3162686945 + .long 0 + .long 3219128320 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1013450602 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 1071761211 + .long 536870912 + .long 1015752157 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 1071524701 + .long 536870912 + .long 1012796809 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 1071152610 + .long 3758096384 + .long 3160878317 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 1070765062 + .long 2684354560 + .long 3161838221 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 1070135480 + .long 3221225472 + .long 3160567065 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 1069094822 + .long 3758096384 + .long 3158189848 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 393047345 + .long 1064548654 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3220176896 + .long 18115067 + .long 1066642694 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3220176896 + .long 2476548698 + .long 1067846634 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3220176896 + .long 2255197647 + .long 1068727457 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3220176896 + .long 1945768569 + .long 1069431400 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 3220176896 + .long 1539668340 + .long 1069912679 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 3220176896 + .long 1403757309 + .long 1070403070 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 2485417816 + .long 3217109964 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 3219128320 + .long 2598800519 + .long 3215750067 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3219128320 + .long 2140183630 + .long 1067272748 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3219128320 + .long 1699043957 + .long 1069418613 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 3219128320 + .long 1991047213 + .long 3215237169 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3218079744 + .long 240740309 + .long 1068244255 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 3218079744 + .long 257503056 + .long 1067164005 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 257503056 + .long 3214647653 + .long 2748392742 + .long 3220166797 + .long 1073741824 + .long 1015578102 + .long 0 + .long 1069547520 + .long 240740309 + .long 3215727903 + .long 3489094832 + .long 3220136599 + .long 536870912 + .long 3161809431 + .long 0 + .long 1070596096 + .long 1991047213 + .long 1067753521 + .long 1455828442 + .long 3220086593 + .long 3758096384 + .long 3162988721 + .long 0 + .long 1070596096 + .long 1699043957 + .long 3216902261 + .long 3476196678 + .long 3220017259 + .long 536870912 + .long 3161741286 + .long 0 + .long 1071644672 + .long 2140183630 + .long 3214756396 + .long 4051746225 + .long 3219929266 + .long 2147483648 + .long 1014423729 + .long 0 + .long 1071644672 + .long 2598800519 + .long 1068266419 + .long 688824739 + .long 3219823462 + .long 3758096384 + .long 3157915184 + .long 0 + .long 1071644672 + .long 2485417816 + .long 1069626316 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1015203297 + .long 0 + .long 1071644672 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3160934250 + .long 0 + .long 1072693248 + .long 1539668340 + .long 3217396327 + .long 967731400 + .long 3219244859 + .long 536870912 + .long 3163235805 + .long 0 + .long 1072693248 + .long 1945768569 + .long 3216915048 + .long 939980347 + .long 3219008349 + .long 536870912 + .long 3160280457 + .long 0 + .long 1072693248 + .long 2255197647 + .long 3216211105 + .long 2796464483 + .long 3218636258 + .long 3758096384 + .long 1013394669 + .long 0 + .long 1072693248 + .long 2476548698 + .long 3215330282 + .long 785751814 + .long 3218248710 + .long 2684354560 + .long 1014354573 + .long 0 + .long 1072693248 + .long 18115067 + .long 3214126342 + .long 1013556747 + .long 3217619128 + .long 3221225472 + .long 1013083417 + .long 0 + .long 1072693248 + .long 393047345 + .long 3212032302 + .long 3156849708 + .long 3216578470 + .long 3758096384 + .long 1010706200 + .long 0 + .long 1072693248 + .type Ctable,@object + .size Ctable,2048 + .align 16 +SC_2: + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .type SC_2,@object + .size SC_2,16 + .align 16 +SC_3: + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .type SC_3,@object + .size SC_3,16 + .align 16 +SC_1: + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .type SC_1,@object + .size SC_1,16 + .align 16 +PI_INV_TABLE: + .long 0 + .long 0 + .long 2734261102 + .long 1313084713 + .long 4230436817 + .long 4113882560 + .long 3680671129 + .long 1011060801 + .long 4266746795 + .long 3736847713 + .long 3072618042 + .long 1112396512 + .long 105459434 + .long 164729372 + .long 4263373596 + .long 2972297022 + .long 3900847605 + .long 784024708 + .long 3919343654 + .long 3026157121 + .long 965858873 + .long 2203269620 + .long 2625920907 + .long 3187222587 + .long 536385535 + .long 3724908559 + .long 4012839307 + .long 1510632735 + .long 1832287951 + .long 667617719 + .long 1330003814 + .long 2657085997 + .long 1965537991 + .long 3957715323 + .long 1023883767 + .long 2320667370 + .long 1811636145 + .long 529358088 + .long 1443049542 + .long 4235946923 + .long 4040145953 + .type PI_INV_TABLE,@object + .size PI_INV_TABLE,164 + .space 12, 0x00 # pad + .align 16 +PI_4: + .long 1073741824 + .long 1072243195 + .long 407279769 + .long 1046758445 + .type PI_4,@object + .size PI_4,16 + .align 8 +PI32INV: + .long 1841940611 + .long 1076125488 + .type PI32INV,@object + .size PI32INV,8 + .align 8 +SIGN_MASK: + .long 0 + .long 2147483648 + .type SIGN_MASK,@object + .size SIGN_MASK,8 + .align 8 +P_3: + .long 771977331 + .long 996350346 + .type P_3,@object + .size P_3,8 + .align 8 +ALL_ONES: + .long 4294967295 + .long 1072693247 + .type ALL_ONES,@object + .size ALL_ONES,8 + .align 8 +TWO_POW_55: + .long 0 + .long 1130364928 + .type TWO_POW_55,@object + .size TWO_POW_55,8 + .align 8 +TWO_POW_M55: + .long 0 + .long 1015021568 + .type TWO_POW_M55,@object + .size TWO_POW_M55,8 + .align 8 +P_1: + .long 1413480448 + .long 1069097467 + .type P_1,@object + .size P_1,8 + .align 8 +NEG_ZERO: + .long 0 + .long 2147483648 + .type NEG_ZERO,@object + .size NEG_ZERO,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sincos_gen.S b/external/sgx_libm/intel64/sincos_gen.S new file mode 100644 index 0000000000..1ca9835a35 --- /dev/null +++ b/external/sgx_libm/intel64/sincos_gen.S @@ -0,0 +1,1479 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincos_gen.c" + .text +..TXTST0: +# -- Begin sincos + .text + .align 16,0x90 + .globl sincos +sincos: +# parameter 1: %xmm0 +# parameter 2: %rdi +# parameter 3: %rsi +..B1.1: + .cfi_startproc +..___tag_value_sincos.1: +..L2: + + subq $72, %rsp + .cfi_def_cfa_offset 80 + movq %fs:40, %rax + xorq %rsp, %rax + movsd %xmm0, 8(%rsp) + movq %rdi, 16(%rsp) + movq %rsi, 24(%rsp) + movq %rax, 56(%rsp) +..B1.2: + stmxcsr (%rsp) + movl (%rsp), %eax + andl $-24577, %eax + cmpl (%rsp), %eax + jne .L_2TAG_PACKET_0.0.1 +.L_2TAG_PACKET_1.0.1: + pextrw $3, %xmm0, %eax + andw $32767, %ax + subw $12336, %ax + cmpw $4293, %ax + ja .L_2TAG_PACKET_2.0.1 + unpcklpd %xmm0, %xmm0 + movapd PI32INV(%rip), %xmm1 + mulpd %xmm0, %xmm1 + movapd SHIFTER(%rip), %xmm2 + cvtsd2si %xmm1, %edx + addpd %xmm2, %xmm1 + movapd P_1(%rip), %xmm3 + subpd %xmm2, %xmm1 + movapd P_2(%rip), %xmm2 + mulpd %xmm1, %xmm3 + addq $1865216, %rdx + movapd %xmm0, %xmm4 + andq $63, %rdx + movapd SC_4(%rip), %xmm5 + lea Ctable(%rip), %rax + shlq $6, %rdx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subpd %xmm3, %xmm0 + mulpd P_3(%rip), %xmm1 + subpd %xmm3, %xmm4 + movapd 16(%rax), %xmm7 + movapd %xmm4, %xmm3 + subpd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + movapd SC_2(%rip), %xmm6 + mulpd %xmm4, %xmm7 + subpd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subpd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subpd %xmm3, %xmm1 + movapd 48(%rax), %xmm3 + addpd %xmm3, %xmm2 + subpd %xmm2, %xmm7 + mulpd %xmm7, %xmm1 + movapd 16(%rax), %xmm7 + mulpd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulpd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm7 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulpd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, %xmm0 + addpd 16(%rax), %xmm3 + addpd %xmm5, %xmm6 + movq %xmm6, %xmm5 + unpckhpd %xmm6, %xmm6 + unpcklpd %xmm5, %xmm5 + mulpd %xmm7, %xmm6 + mulpd %xmm5, %xmm2 + movapd %xmm4, %xmm7 + addpd %xmm3, %xmm4 + movapd 16(%rax), %xmm5 + subpd %xmm3, %xmm5 + subpd %xmm4, %xmm3 + addpd 32(%rax), %xmm1 + addpd %xmm0, %xmm5 + addpd %xmm7, %xmm3 + addpd %xmm5, %xmm1 + movl (%rsp), %eax + andl $-24577, %eax + cmpl (%rsp), %eax + je .L_2TAG_PACKET_3.0.1 + stmxcsr 4(%rsp) + movl (%rsp), %eax + andl $24576, %eax + orl %eax, 4(%rsp) + ldmxcsr 4(%rsp) +.L_2TAG_PACKET_3.0.1: + addpd %xmm3, %xmm1 + addpd %xmm2, %xmm1 + addpd %xmm6, %xmm1 + addpd %xmm4, %xmm1 + movq %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + movq 16(%rsp), %rax + movq %xmm0, (%rax) + movq 24(%rsp), %rax + movq %xmm1, (%rax) + jmp ..B1.7 +.L_2TAG_PACKET_2.0.1: + jg .L_2TAG_PACKET_4.0.1 + movq %xmm0, %xmm1 + pextrw $3, %xmm0, %eax + orw $32768, %ax + pinsrw $3, %eax, %xmm1 + addsd ONE(%rip), %xmm1 + cmpw $32784, %ax + jge .L_2TAG_PACKET_5.0.1 + movl (%rsp), %eax + andl $-24577, %eax + cmpl (%rsp), %eax + je .L_2TAG_PACKET_6.0.1 + stmxcsr 4(%rsp) + movl (%rsp), %eax + andl $24576, %eax + orl %eax, 4(%rsp) + ldmxcsr 4(%rsp) +.L_2TAG_PACKET_6.0.1: + mulsd ALL_ONES(%rip), %xmm0 + movq 16(%rsp), %rax + movq %xmm0, (%rax) + movq 24(%rsp), %rax + movq %xmm1, (%rax) + jmp ..B1.7 +.L_2TAG_PACKET_5.0.1: + movq TWO_POW_55(%rip), %xmm3 + mulsd %xmm0, %xmm3 + subsd %xmm3, %xmm0 + mulsd TWO_POW_M55(%rip), %xmm0 + movq 16(%rsp), %rax + movq %xmm0, (%rax) + movq 24(%rsp), %rax + movq %xmm1, (%rax) + jmp .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_4.0.1: + pextrw $3, %xmm0, %eax + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_8.0.1 +..B1.3: + movsd 8(%rsp), %xmm0 + lea 40(%rsp), %rdi +..___tag_value_sincos.4: + call __libm_reduce_pio2d@PLT +..___tag_value_sincos.5: +..B1.4: + movl %eax, 32(%rsp) +..B1.5: + movq 40(%rsp), %xmm0 + movq 48(%rsp), %xmm6 + unpcklpd %xmm0, %xmm0 + unpcklpd %xmm6, %xmm6 + movapd PI32INV(%rip), %xmm1 + mulpd %xmm0, %xmm1 + movapd SHIFTER(%rip), %xmm2 + cvtsd2si %xmm1, %edx + addpd %xmm2, %xmm1 + movapd P_1(%rip), %xmm3 + subpd %xmm2, %xmm1 + movapd P_2(%rip), %xmm2 + mulpd %xmm1, %xmm3 + movl 32(%rsp), %eax + shlq $4, %rax + addq $1865216, %rdx + movapd %xmm0, %xmm4 + addq %rax, %rdx + andq $63, %rdx + movapd SC_4(%rip), %xmm5 + lea Ctable(%rip), %rax + shlq $6, %rdx + addq %rdx, %rax + mulpd %xmm1, %xmm2 + subpd %xmm3, %xmm0 + mulpd P_3(%rip), %xmm1 + subpd %xmm3, %xmm4 + movapd 16(%rax), %xmm7 + movapd %xmm4, %xmm3 + subpd %xmm2, %xmm4 + mulpd %xmm0, %xmm5 + subpd %xmm2, %xmm0 + mulpd %xmm4, %xmm7 + subpd %xmm4, %xmm3 + mulpd %xmm0, %xmm5 + mulpd %xmm0, %xmm0 + subpd %xmm2, %xmm3 + movapd (%rax), %xmm2 + subpd %xmm3, %xmm1 + movapd 48(%rax), %xmm3 + addpd %xmm3, %xmm2 + subpd %xmm2, %xmm7 + subpd %xmm6, %xmm1 + movapd SC_2(%rip), %xmm6 + mulpd %xmm7, %xmm1 + movapd 16(%rax), %xmm7 + mulpd %xmm4, %xmm2 + mulpd %xmm0, %xmm6 + mulpd %xmm4, %xmm3 + mulpd %xmm0, %xmm2 + mulpd %xmm0, %xmm7 + mulpd %xmm0, %xmm0 + addpd SC_3(%rip), %xmm5 + mulpd (%rax), %xmm4 + addpd SC_1(%rip), %xmm6 + mulpd %xmm0, %xmm5 + movapd %xmm3, %xmm0 + addpd 16(%rax), %xmm3 + addpd %xmm5, %xmm6 + movq %xmm6, %xmm5 + unpckhpd %xmm6, %xmm6 + unpcklpd %xmm5, %xmm5 + mulpd %xmm7, %xmm6 + mulpd %xmm5, %xmm2 + movapd %xmm4, %xmm7 + addpd %xmm3, %xmm4 + movapd 16(%rax), %xmm5 + subpd %xmm3, %xmm5 + subpd %xmm4, %xmm3 + addpd 32(%rax), %xmm1 + addpd %xmm0, %xmm5 + addpd %xmm7, %xmm3 + addpd %xmm5, %xmm1 + movl (%rsp), %eax + andl $-24577, %eax + cmpl (%rsp), %eax + je .L_2TAG_PACKET_9.0.1 + stmxcsr 4(%rsp) + movl (%rsp), %eax + andl $24576, %eax + orl %eax, 4(%rsp) + ldmxcsr 4(%rsp) +.L_2TAG_PACKET_9.0.1: + addpd %xmm3, %xmm1 + addpd %xmm2, %xmm1 + addpd %xmm6, %xmm1 + addpd %xmm4, %xmm1 + movq %xmm1, %xmm0 + unpckhpd %xmm1, %xmm1 + movq 16(%rsp), %rax + movq %xmm0, (%rax) + movq 24(%rsp), %rax + movq %xmm1, (%rax) + jmp ..B1.7 +.L_2TAG_PACKET_8.0.1: + movq 8(%rsp), %xmm0 + pxor %xmm1, %xmm1 + mulsd %xmm1, %xmm0 + movq 16(%rsp), %rax + movq %xmm0, (%rax) + movq 24(%rsp), %rax + movq %xmm0, (%rax) +.L_2TAG_PACKET_7.0.1: + movl (%rsp), %eax + andl $-24577, %eax + cmpl (%rsp), %eax + je .L_2TAG_PACKET_10.0.1 + stmxcsr 4(%rsp) + movl (%rsp), %eax + andl $24576, %eax + orl %eax, 4(%rsp) + ldmxcsr 4(%rsp) +.L_2TAG_PACKET_10.0.1: + jmp ..B1.7 +.L_2TAG_PACKET_0.0.1: + movl %eax, 4(%rsp) + ldmxcsr 4(%rsp) + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_11.0.1: +..B1.7: + movq 56(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.9 +..B1.8: + addq $72, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 +..B1.9: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type sincos,@function + .size sincos,.-sincos + .data +# -- End sincos + .section .rodata, "a" + .align 16 + .align 16 +PI32INV: + .long 1841940611 + .long 1076125488 + .long 1841940611 + .long 1076125488 + .type PI32INV,@object + .size PI32INV,16 + .align 16 +SHIFTER: + .long 0 + .long 1127743488 + .long 0 + .long 1127743488 + .type SHIFTER,@object + .size SHIFTER,16 + .align 16 +P_1: + .long 1413480448 + .long 1069097467 + .long 1413480448 + .long 1069097467 + .type P_1,@object + .size P_1,16 + .align 16 +P_2: + .long 442499072 + .long 1032893537 + .long 442499072 + .long 1032893537 + .type P_2,@object + .size P_2,16 + .align 16 +SC_4: + .long 2773927732 + .long 1053236707 + .long 436314138 + .long 1056571808 + .type SC_4,@object + .size SC_4,16 + .align 16 +Ctable: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 3217031168 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 3218079744 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 3219128320 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 3219128320 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 3220176896 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 3220176896 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 1064548654 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 3163061750 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 3220176896 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 1066642694 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 1014325783 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 1067846634 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 1015505073 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 3220176896 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 1068727457 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 1014257638 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 1069431400 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 3161907377 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 1069912679 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 1010431536 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 1070403070 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 3162686945 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 3220176896 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 3217719929 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 3163282740 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 3219128320 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 3217109964 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 1013450602 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 3215750067 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 1015752157 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 1067272748 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 1012796809 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 1069418613 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 3160878317 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 3219128320 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 3215237169 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 3161838221 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 1068244255 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 3160567065 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 3218079744 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 1067164005 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 3158189848 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 3217031168 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 393047345 + .long 1064548654 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 3220166797 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 1015578102 + .long 0 + .long 3220176896 + .long 0 + .long 1069547520 + .long 18115067 + .long 1066642694 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 3220136599 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 3161809431 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2476548698 + .long 1067846634 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 3220086593 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 3162988721 + .long 0 + .long 3220176896 + .long 0 + .long 1070596096 + .long 2255197647 + .long 1068727457 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 3220017259 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 3161741286 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1945768569 + .long 1069431400 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 3219929266 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 1014423729 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1539668340 + .long 1069912679 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 3219823462 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 3157915184 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 1403757309 + .long 1070403070 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 3219700864 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 1015203297 + .long 0 + .long 3220176896 + .long 0 + .long 1071644672 + .long 2583490354 + .long 3217719929 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 3219562654 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 1015799092 + .long 0 + .long 3219128320 + .long 0 + .long 1071644672 + .long 2485417816 + .long 3217109964 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 3219410163 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 3160934250 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2598800519 + .long 3215750067 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 3219244859 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 3163235805 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 2140183630 + .long 1067272748 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 3219008349 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 3160280457 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1699043957 + .long 1069418613 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 3218636258 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 1013394669 + .long 0 + .long 3219128320 + .long 0 + .long 1072693248 + .long 1991047213 + .long 3215237169 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 3218248710 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 1014354573 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 240740309 + .long 1068244255 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 3217619128 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 1013083417 + .long 0 + .long 3218079744 + .long 0 + .long 1072693248 + .long 257503056 + .long 1067164005 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 3216578470 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 1010706200 + .long 0 + .long 3217031168 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 257503056 + .long 3214647653 + .long 393047345 + .long 3212032302 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 1069094822 + .long 1073741824 + .long 1015578102 + .long 3758096384 + .long 3158189848 + .long 0 + .long 1069547520 + .long 0 + .long 1072693248 + .long 240740309 + .long 3215727903 + .long 18115067 + .long 3214126342 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 1070135480 + .long 536870912 + .long 3161809431 + .long 3221225472 + .long 3160567065 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1991047213 + .long 1067753521 + .long 2476548698 + .long 3215330282 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 1070765062 + .long 3758096384 + .long 3162988721 + .long 2684354560 + .long 3161838221 + .long 0 + .long 1070596096 + .long 0 + .long 1072693248 + .long 1699043957 + .long 3216902261 + .long 2255197647 + .long 3216211105 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 1071152610 + .long 536870912 + .long 3161741286 + .long 3758096384 + .long 3160878317 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2140183630 + .long 3214756396 + .long 1945768569 + .long 3216915048 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 1071524701 + .long 2147483648 + .long 1014423729 + .long 536870912 + .long 1012796809 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2598800519 + .long 1068266419 + .long 1539668340 + .long 3217396327 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 1071761211 + .long 3758096384 + .long 3157915184 + .long 536870912 + .long 1015752157 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2485417816 + .long 1069626316 + .long 1403757309 + .long 3217886718 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 1071926515 + .long 536870912 + .long 1015203297 + .long 536870912 + .long 1013450602 + .long 0 + .long 1071644672 + .long 0 + .long 1072693248 + .long 2583490354 + .long 1070236281 + .long 2583490354 + .long 1070236281 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 1072079006 + .long 536870912 + .long 1015799092 + .long 536870912 + .long 3163282740 + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .long 1403757309 + .long 3217886718 + .long 2485417816 + .long 1069626316 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 1072217216 + .long 536870912 + .long 3160934250 + .long 536870912 + .long 3162686945 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1539668340 + .long 3217396327 + .long 2598800519 + .long 1068266419 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 1072339814 + .long 536870912 + .long 3163235805 + .long 3758096384 + .long 1010431536 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 1945768569 + .long 3216915048 + .long 2140183630 + .long 3214756396 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 1072445618 + .long 536870912 + .long 3160280457 + .long 2147483648 + .long 3161907377 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2255197647 + .long 3216211105 + .long 1699043957 + .long 3216902261 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 1072533611 + .long 3758096384 + .long 1013394669 + .long 536870912 + .long 1014257638 + .long 0 + .long 1072693248 + .long 0 + .long 1071644672 + .long 2476548698 + .long 3215330282 + .long 1991047213 + .long 1067753521 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 1072602945 + .long 2684354560 + .long 1014354573 + .long 3758096384 + .long 1015505073 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 18115067 + .long 3214126342 + .long 240740309 + .long 3215727903 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 1072652951 + .long 3221225472 + .long 1013083417 + .long 536870912 + .long 1014325783 + .long 0 + .long 1072693248 + .long 0 + .long 1070596096 + .long 393047345 + .long 3212032302 + .long 257503056 + .long 3214647653 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 1072683149 + .long 3758096384 + .long 1010706200 + .long 1073741824 + .long 3163061750 + .long 0 + .long 1072693248 + .long 0 + .long 1069547520 + .type Ctable,@object + .size Ctable,4096 + .space 512, 0x00 # pad + .align 16 +P_3: + .long 771977331 + .long 996350346 + .long 771977331 + .long 996350346 + .type P_3,@object + .size P_3,16 + .align 16 +SC_2: + .long 286331153 + .long 1065423121 + .long 1431655765 + .long 1067799893 + .type SC_2,@object + .size SC_2,16 + .align 16 +SC_3: + .long 436314138 + .long 3207201184 + .long 381774871 + .long 3210133868 + .type SC_3,@object + .size SC_3,16 + .align 16 +SC_1: + .long 1431655765 + .long 3217380693 + .long 0 + .long 3219128320 + .type SC_1,@object + .size SC_1,16 + .align 16 +TWO_POW_55: + .long 0 + .long 1130364928 + .type TWO_POW_55,@object + .size TWO_POW_55,8 + .align 8 +ONE: + .long 0 + .long 1072693248 + .type ONE,@object + .size ONE,8 + .align 8 +ALL_ONES: + .long 4294967295 + .long 1072693247 + .type ALL_ONES,@object + .size ALL_ONES,8 + .align 8 +TWO_POW_M55: + .long 0 + .long 3162505216 + .type TWO_POW_M55,@object + .size TWO_POW_M55,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sincos_pi4l.S b/external/sgx_libm/intel64/sincos_pi4l.S new file mode 100644 index 0000000000..d664d8382e --- /dev/null +++ b/external/sgx_libm/intel64/sincos_pi4l.S @@ -0,0 +1,5050 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincos_pi4l.c" + .text +..TXTST0: +# -- Begin __libm_sincos_pi4l + .text + .align 16,0x90 + .globl __libm_sincos_pi4l +__libm_sincos_pi4l: +# parameter 1: 80 + %rsp +# parameter 2: %rdi +# parameter 3: %rsi +# parameter 4: %edx +..B1.1: + .cfi_startproc +..___tag_value___libm_sincos_pi4l.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + subq $56, %rsp + .cfi_def_cfa_offset 80 + lea _pzerol_value(%rip), %rax + fldt 80(%rsp) + movl %edx, %r8d + movl %r8d, %r9d + fld %st(0) + movq %fs:40, %rcx + negl %r9d + xorq %rsp, %rcx + fchs + fldt (%rax) + lea _pion4(%rip), %r11 + movl $1, %r10d + fcomi %st(2), %st + movq %rcx, 48(%rsp) + fxch %st(2) + fcmovnbe %st(1), %st + fstp %st(1) + fldt (%r11) + movl $-1, %ecx + cmova %r9d, %r8d + cmovbe %r10d, %ecx + fcomi %st(1), %st + jbe ..B1.3 +..B1.2: + fstp %st(2) + testl $1, %r8d + fsub %st, %st(1) + fcmovne %st(1), %st + fstp %st(1) + jmp ..B1.22 +..B1.3: + lea _cody_thres_val(%rip), %rax + fldz + fldt (%rax) + fcomip %st(3), %st + jbe ..B1.5 +..B1.4: + fstp %st(3) + fstp %st(0) + fstp %st(1) + lea __4onpi(%rip), %rax + lea _PI04(%rip), %r10 + lea 16+_PI04(%rip), %r11 + lea 32+_PI04(%rip), %r13 + fldt (%rax) + fmul %st(1), %st + fnstcw (%rsp) + movzwl (%rsp), %eax + orl $3072, %eax + movl %eax, 8(%rsp) + fldcw 8(%rsp) + fistpl 16(%rsp) + fldcw (%rsp) + fldt (%r10) + fldt (%r11) + fldt (%r13) + movl 16(%rsp), %r9d + addl %r9d, %r8d + testl $1, %r8d + lea 1(%r9), %edx + cmovne %edx, %r9d + movl %r9d, 24(%rsp) + fildl 24(%rsp) + fmul %st, %st(3) + fxch %st(3) + fsubrp %st, %st(4) + fxch %st(1) + fmul %st(2), %st + fsubrp %st, %st(3) + fmulp %st, %st(1) + fsubrp %st, %st(1) + jmp ..B1.22 +..B1.5: + fxch %st(2) + fstpt 16(%rsp) + movl $-2078209981, %eax + movzwl 24(%rsp), %r11d + movl %r11d, %r9d + andl $32767, %r9d + andl $-32768, %r11d + lea -16417(%r9), %r13d + imull %r13d + sarl $31, %r13d + lea -16417(%rdx,%r9), %eax + sarl $4, %eax + lea -62(%r9), %r10d + subl %r13d, %eax + andl $32767, %r10d + movl %eax, %r14d + orl %r10d, %r11d + shll $5, %r14d + negl %r14d + addl %eax, %r14d + movw %r11w, 24(%rsp) + fldt 16(%rsp) + fstpt (%rsp) + fldt (%rsp) + movl $0, (%rsp) + lea -16417(%r14,%r9), %edx + fldt (%rsp) + cmpl $23, %edx + fsubr %st, %st(1) + jl ..B1.7 +..B1.6: + movslq %eax, %rdx + incl %eax + shlq $4, %rdx + lea _4OPI(%rip), %r13 + fxch %st(3) + fstpt 16(%rsp) + fldt (%rdx,%r13) + fmul %st(1), %st + fldt 16(%rdx,%r13) + fmul %st(4), %st + faddp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + andl $-16777216, 32(%rsp) + fldt 32(%rsp) + fsubrp %st, %st(1) + jmp ..B1.8 +..B1.7: + fstp %st(3) + fld %st(3) + lea _4OPI(%rip), %r13 +..B1.8: + movslq %eax, %rdx + fld %st(3) + shlq $4, %rdx + lea _ADDING(%rip), %r9 + fldt 16(%rdx,%r13) + fmul %st, %st(1) + fmul %st(3), %st + fldt (%rdx,%r13) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fldt 32(%rdx,%r13) + fmul %st(6), %st + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fadd %st, %st(1) + fstpt 32(%rsp) + fldt (%r9) + fld %st(0) + fadd %st(2), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + movl 16(%rsp), %r9d + fcomi %st(1), %st + fxch %st(1) + fstp %st(0) + fldt (%rsp) + jbe ..B1.10 +..B1.9: + lea _nonel_value(%rip), %rdx + decl %r9d + fldt (%rdx) + faddp %st, %st(2) +..B1.10: + addl %r9d, %r8d + fxch %st(1) + fsubrp %st, %st(2) + testl $1, %r8d + je ..B1.13 +..B1.11: + fstp %st(5) + lea _nonel_value(%rip), %rdx + fldt (%rdx) + fxch %st(5) +..B1.13: + movslq %eax, %rax + movl $5, %r9d + fxch %st(1) + faddp %st, %st(5) + lea 2(%rax), %rdx + movl %edx, %r11d + faddp %st, %st(4) + negl %r11d + addl $532, %r11d + cmpl $5, %r11d + cmova %r9d, %r11d + cmpq $532, %rdx + jge ..B1.20 +..B1.14: + movl %r11d, %r9d + movl $1, %r14d + shrl $1, %r9d + xorl %r10d, %r10d + testl %r9d, %r9d + jbe ..B1.18 +..B1.15: + fldt .L_2il0floatpacket.0(%rip) + shlq $4, %rdx + addq %r13, %rdx +..B1.16: + jmp ..L8 +..L9: + faddp %st, %st(1) +..L8: + fld %st(3) + lea (%r10,%r10), %r14d + movslq %r14d, %r14 + incl %r10d + shlq $4, %r14 + cmpl %r9d, %r10d + fldt 16(%rdx,%r14) + fmul %st, %st(1) + fmul %st(3), %st + fldt (%rdx,%r14) + fmul %st(4), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(6) + fldt 32(%rdx,%r14) + fmul %st(5), %st + faddp %st, %st(1) + jb ..L9 + faddp %st, %st(1) +..B1.17: + faddp %st, %st(4) + lea 1(%r10,%r10), %r14d +..B1.18: + decl %r14d + movslq %r14d, %r14 + movslq %r11d, %r11 + cmpq %r11, %r14 + jae ..B1.20 +..B1.19: + lea 2(%r14,%rax), %rax + shlq $4, %rax + fldt (%rax,%r13) + fmulp %st, %st(1) + fldt 16(%rax,%r13) + fmulp %st, %st(3) + fadd %st(2), %st + fadd %st, %st(3) +..B1.20: + fstp %st(2) + fstp %st(1) + fmulp %st, %st(1) +..B1.22: + testl $1, %r8d + lea ssign(%rip), %rdx + lea csign(%rip), %r10 + lea 1(%r8), %eax + cmovne %eax, %r8d + fld %st(0) + andl $7, %r8d + movl (%rdx,%r8,4), %r9d + imull %r9d, %ecx + fmul %st(1), %st + movl (%r10,%r8,4), %eax + andl $3, %r8d + decl %r8d + movl %ecx, 24(%rsp) + cmpl $1, %r8d + fildl 24(%rsp) + ja ..B1.24 +..B1.23: + lea _PC(%rip), %rdx + lea 16+_PC(%rip), %rcx + lea 32+_PC(%rip), %r8 + lea 48+_PC(%rip), %r9 + lea 64+_PC(%rip), %r10 + lea 80+_PC(%rip), %r11 + lea 96+_PC(%rip), %r13 + lea 112+_PC(%rip), %r14 + fldt (%rdx) + lea _ponel_value(%rip), %rdx + movl %eax, 24(%rsp) + fmul %st(2), %st + fldt (%rcx) + lea 32+_PS(%rip), %rcx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + lea 64+_PS(%rip), %r8 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + lea 80+_PS(%rip), %r9 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + lea 96+_PS(%rip), %r10 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r11) + lea 112+_PS(%rip), %r11 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r13) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r14) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 16+_PS(%rip), %rdx + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rdi) + lea _PS(%rip), %rdi + fldt (%rdx) + fldt (%r8) + fldt (%r9) + fldt (%rdi) + lea 48+_PS(%rip), %rdi + fmul %st(4), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fildl 24(%rsp) + fmulp %st, %st(1) + fstpt (%rsi) + jmp ..B1.25 +..B1.24: + lea _PS(%rip), %rdx + lea 16+_PS(%rip), %rcx + lea 32+_PS(%rip), %r8 + lea 48+_PS(%rip), %r9 + lea 64+_PS(%rip), %r10 + lea 80+_PS(%rip), %r11 + lea 96+_PS(%rip), %r13 + lea 112+_PS(%rip), %r14 + fldt (%rdx) + lea 48+_PC(%rip), %rdx + movl %eax, 24(%rsp) + lea _PC(%rip), %rax + fmul %st(2), %st + fldt (%rcx) + lea 64+_PC(%rip), %rcx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + lea 96+_PC(%rip), %r8 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + lea 112+_PC(%rip), %r9 + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + lea _ponel_value(%rip), %r10 + faddp %st, %st(1) + fmul %st(2), %st + fildl 24(%rsp) + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r13) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r14) + faddp %st, %st(1) + fmul %st(3), %st + fmul %st(4), %st + faddp %st, %st(4) + fxch %st(3) + fmulp %st, %st(1) + fstpt (%rdi) + lea 16+_PC(%rip), %rdi + fldt (%rax) + lea 32+_PC(%rip), %rax + fmul %st(1), %st + fldt (%rdi) + lea 80+_PC(%rip), %rdi + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt (%rsi) +..B1.25: + movq 48(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.27 +..B1.26: + addq $56, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 13, -16 + .cfi_offset 14, -24 +..B1.27: + call __stack_chk_fail@PLT + .align 16,0x90 + .cfi_endproc + .type __libm_sincos_pi4l,@function + .size __libm_sincos_pi4l,.-__libm_sincos_pi4l + .data +# -- End __libm_sincos_pi4l + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 4 +ssign: + .long 1 + .long 1 + .long 1 + .long 1 + .long -1 + .long -1 + .long -1 + .long -1 + .type ssign,@object + .size ssign,32 + .align 4 +csign: + .long 1 + .long 1 + .long -1 + .long -1 + .long -1 + .long -1 + .long 1 + .long 1 + .type csign,@object + .size csign,32 + .align 2 +_pzerol_value: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _pzerol_value,@object + .size _pzerol_value,16 + .align 2 +_pion4: + .word 49717 + .word 8552 + .word 55970 + .word 51471 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _pion4,@object + .size _pion4,16 + .align 2 +_cody_thres_val: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16413 + .word 0 + .word 0 + .word 0 + .type _cody_thres_val,@object + .size _cody_thres_val,16 + .align 2 +__4onpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16383 + .word 0 + .word 0 + .word 0 + .type __4onpi,@object + .size __4onpi,16 + .align 2 +_PI04: + .word 0 + .word 0 + .word 55936 + .word 51471 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41728 + .word 34949 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 14087 + .word 41696 + .word 12696 + .word 36145 + .word 16328 + .word 0 + .word 0 + .word 0 + .type _PI04,@object + .size _PI04,48 + .align 2 +_4OPI: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33646 + .word 41721 + .word 16445 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10832 + .word 40072 + .word 16412 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44008 + .word 65043 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28384 + .word 64154 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38272 + .word 56162 + .word 16317 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7298 + .word 51682 + .word 16290 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45504 + .word 65320 + .word 16254 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61204 + .word 44922 + .word 16227 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18652 + .word 50030 + .word 16196 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14144 + .word 59657 + .word 16163 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37450 + .word 47105 + .word 16135 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14898 + .word 56641 + .word 16104 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34680 + .word 34623 + .word 16071 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4760 + .word 45515 + .word 16041 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41480 + .word 40187 + .word 16011 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47852 + .word 55252 + .word 15979 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54072 + .word 35081 + .word 15948 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26808 + .word 57421 + .word 15916 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20068 + .word 57232 + .word 15887 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49576 + .word 60188 + .word 15854 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10016 + .word 52861 + .word 15823 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30648 + .word 35825 + .word 15792 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60542 + .word 58528 + .word 15763 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65468 + .word 61743 + .word 15732 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64960 + .word 45825 + .word 15696 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50604 + .word 38792 + .word 15670 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18394 + .word 33435 + .word 15639 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55780 + .word 42703 + .word 15608 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 63841 + .word 15576 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63080 + .word 62563 + .word 15545 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20840 + .word 62207 + .word 15514 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30094 + .word 59983 + .word 15484 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61818 + .word 60389 + .word 15453 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40186 + .word 40579 + .word 15422 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42170 + .word 58004 + .word 15391 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55276 + .word 39678 + .word 15359 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44672 + .word 36806 + .word 15326 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13060 + .word 34144 + .word 15297 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28016 + .word 57231 + .word 15264 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16112 + .word 44995 + .word 15235 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53464 + .word 33387 + .word 15203 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7296 + .word 60751 + .word 15170 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29452 + .word 45231 + .word 15142 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26208 + .word 49689 + .word 15111 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37900 + .word 44002 + .word 15080 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57340 + .word 33800 + .word 15049 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27544 + .word 50178 + .word 15018 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6168 + .word 40132 + .word 14987 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21392 + .word 43702 + .word 14954 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45168 + .word 54372 + .word 14926 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8986 + .word 40688 + .word 14895 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1648 + .word 53745 + .word 14863 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30520 + .word 55795 + .word 14831 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43060 + .word 32914 + .word 14801 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46172 + .word 52771 + .word 14770 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14056 + .word 45285 + .word 14738 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53590 + .word 44868 + .word 14709 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40786 + .word 35970 + .word 14678 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33436 + .word 65411 + .word 14646 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32006 + .word 61382 + .word 14616 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37856 + .word 45239 + .word 14583 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60894 + .word 49555 + .word 14554 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48064 + .word 53065 + .word 14519 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48624 + .word 54844 + .word 14492 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7988 + .word 40762 + .word 14461 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16270 + .word 58745 + .word 14430 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37064 + .word 50168 + .word 14398 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18624 + .word 63736 + .word 14364 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60758 + .word 44966 + .word 14337 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33304 + .word 47465 + .word 14306 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6226 + .word 60503 + .word 14275 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26380 + .word 54900 + .word 14243 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44352 + .word 49860 + .word 14213 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11904 + .word 42646 + .word 14182 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55296 + .word 50279 + .word 14145 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15474 + .word 50606 + .word 14120 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45062 + .word 44137 + .word 14089 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 36063 + .word 14055 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40658 + .word 53854 + .word 14027 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28652 + .word 43690 + .word 13996 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24640 + .word 64348 + .word 13963 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30284 + .word 41980 + .word 13933 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45652 + .word 38222 + .word 13902 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15900 + .word 62940 + .word 13871 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31494 + .word 50741 + .word 13841 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43194 + .word 55096 + .word 13810 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1740 + .word 45646 + .word 13778 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28936 + .word 44150 + .word 13748 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8996 + .word 42955 + .word 13717 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44096 + .word 61205 + .word 13684 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44614 + .word 54550 + .word 13655 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24926 + .word 57347 + .word 13624 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3312 + .word 61415 + .word 13590 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64336 + .word 63884 + .word 13562 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2748 + .word 62259 + .word 13530 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56672 + .word 51775 + .word 13498 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32438 + .word 55423 + .word 13469 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17652 + .word 45713 + .word 13438 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65408 + .word 51586 + .word 13403 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40416 + .word 55736 + .word 13376 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52546 + .word 37734 + .word 13345 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48880 + .word 64238 + .word 13314 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56004 + .word 46833 + .word 13282 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61760 + .word 38110 + .word 13250 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41496 + .word 35659 + .word 13219 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25472 + .word 41269 + .word 13187 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45444 + .word 36018 + .word 13159 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6510 + .word 56417 + .word 13128 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3072 + .word 56837 + .word 13097 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61338 + .word 48440 + .word 13066 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49568 + .word 57088 + .word 13034 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4240 + .word 39283 + .word 13002 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18562 + .word 33537 + .word 12973 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31422 + .word 44487 + .word 12942 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31930 + .word 60459 + .word 12911 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42272 + .word 36641 + .word 12878 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28940 + .word 36150 + .word 12849 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21010 + .word 50925 + .word 12818 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29448 + .word 64886 + .word 12786 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20500 + .word 54600 + .word 12756 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54258 + .word 46233 + .word 12725 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32628 + .word 42502 + .word 12693 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61608 + .word 55072 + .word 12663 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6236 + .word 57871 + .word 12631 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42408 + .word 34616 + .word 12601 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56692 + .word 51963 + .word 12569 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39094 + .word 48526 + .word 12539 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59870 + .word 38783 + .word 12508 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26560 + .word 33165 + .word 12477 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58666 + .word 37666 + .word 12446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58728 + .word 39788 + .word 12414 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9048 + .word 43530 + .word 12383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58496 + .word 57659 + .word 12350 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12324 + .word 37025 + .word 12322 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38432 + .word 55856 + .word 12290 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35210 + .word 45960 + .word 12260 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45644 + .word 51345 + .word 12229 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32854 + .word 63883 + .word 12198 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29348 + .word 41450 + .word 12166 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27384 + .word 38024 + .word 12134 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57356 + .word 57291 + .word 12105 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61164 + .word 51521 + .word 12073 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 59151 + .word 12041 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36704 + .word 39943 + .word 12010 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45864 + .word 50151 + .word 11981 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37892 + .word 63687 + .word 11949 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14560 + .word 51615 + .word 11918 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38776 + .word 55684 + .word 11886 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59136 + .word 53570 + .word 11855 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55556 + .word 37955 + .word 11826 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54458 + .word 44670 + .word 11795 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36446 + .word 34084 + .word 11764 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46416 + .word 51693 + .word 11731 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21432 + .word 34376 + .word 11702 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56036 + .word 34809 + .word 11671 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10562 + .word 55654 + .word 11640 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20264 + .word 53052 + .word 11608 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64064 + .word 50415 + .word 11574 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17444 + .word 48295 + .word 11546 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11874 + .word 52677 + .word 11516 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60808 + .word 39275 + .word 11485 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31792 + .word 55677 + .word 11451 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60710 + .word 49006 + .word 11423 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10520 + .word 37403 + .word 11391 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20004 + .word 59470 + .word 11360 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28096 + .word 37612 + .word 11330 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20268 + .word 44280 + .word 11298 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50740 + .word 61588 + .word 11267 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 58835 + .word 11235 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8576 + .word 42496 + .word 11200 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33920 + .word 54912 + .word 11169 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35620 + .word 54843 + .word 11143 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 736 + .word 43591 + .word 11109 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39632 + .word 61060 + .word 11080 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63452 + .word 63129 + .word 11051 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56798 + .word 58512 + .word 11020 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13472 + .word 46333 + .word 10986 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37300 + .word 36598 + .word 10957 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41952 + .word 41639 + .word 10924 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52452 + .word 33459 + .word 10895 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58558 + .word 33287 + .word 10865 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7570 + .word 43843 + .word 10834 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59416 + .word 63990 + .word 10802 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65298 + .word 47744 + .word 10772 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21076 + .word 34089 + .word 10741 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7048 + .word 57394 + .word 10710 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12872 + .word 55405 + .word 10677 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12608 + .word 51669 + .word 10643 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5350 + .word 48455 + .word 10617 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23568 + .word 58692 + .word 10585 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40784 + .word 37046 + .word 10553 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38992 + .word 43861 + .word 10523 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10064 + .word 40199 + .word 10493 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26368 + .word 35771 + .word 10456 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23994 + .word 60721 + .word 10431 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25052 + .word 34302 + .word 10399 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39842 + .word 54964 + .word 10369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11568 + .word 58277 + .word 10336 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26160 + .word 46438 + .word 10306 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23252 + .word 43049 + .word 10276 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35288 + .word 58000 + .word 10245 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14614 + .word 50216 + .word 10214 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1168 + .word 48804 + .word 10181 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60934 + .word 33006 + .word 10152 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64512 + .word 62247 + .word 10117 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59968 + .word 43121 + .word 10085 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25560 + .word 39974 + .word 10057 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1978 + .word 49353 + .word 10028 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16290 + .word 38807 + .word 9997 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8646 + .word 65226 + .word 9966 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56896 + .word 34317 + .word 9933 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40136 + .word 39118 + .word 9902 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14200 + .word 41756 + .word 9871 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59256 + .word 63202 + .word 9840 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 22968 + .word 63553 + .word 9810 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 736 + .word 44292 + .word 9778 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23186 + .word 37760 + .word 9749 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51008 + .word 34950 + .word 9714 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1664 + .word 64248 + .word 9681 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 35199 + .word 9656 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34656 + .word 63747 + .word 9625 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44330 + .word 49864 + .word 9594 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11654 + .word 35567 + .word 9563 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7924 + .word 58919 + .word 9531 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2532 + .word 32800 + .word 9500 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30024 + .word 53799 + .word 9469 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30172 + .word 64347 + .word 9438 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60036 + .word 51382 + .word 9407 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 58576 + .word 33093 + .word 9376 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13888 + .word 38760 + .word 9345 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9322 + .word 52460 + .word 9315 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20944 + .word 41077 + .word 9282 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17976 + .word 41861 + .word 9252 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55176 + .word 55158 + .word 9222 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4976 + .word 35223 + .word 9191 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7816 + .word 39783 + .word 9159 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27656 + .word 55669 + .word 9129 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64944 + .word 53184 + .word 9095 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12544 + .word 49190 + .word 9067 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50612 + .word 44644 + .word 9035 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8832 + .word 63111 + .word 9000 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11744 + .word 36870 + .word 8974 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9404 + .word 63025 + .word 8943 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47316 + .word 43381 + .word 8912 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55716 + .word 47433 + .word 8880 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46414 + .word 48441 + .word 8850 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19116 + .word 39506 + .word 8819 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48060 + .word 53381 + .word 8788 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57112 + .word 50739 + .word 8756 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5840 + .word 60581 + .word 8724 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62112 + .word 57199 + .word 8691 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35908 + .word 59499 + .word 8663 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13760 + .word 48116 + .word 8632 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3136 + .word 56059 + .word 8597 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37596 + .word 39221 + .word 8571 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3232 + .word 48550 + .word 8536 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 22872 + .word 42749 + .word 8507 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41948 + .word 40319 + .word 8478 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31196 + .word 64693 + .word 8446 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62052 + .word 52923 + .word 8416 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2750 + .word 33544 + .word 8385 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12462 + .word 46179 + .word 8354 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25128 + .word 45120 + .word 8321 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51634 + .word 62523 + .word 8292 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15758 + .word 42163 + .word 8261 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34022 + .word 36267 + .word 8230 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41252 + .word 39796 + .word 8198 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49782 + .word 54423 + .word 8168 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25428 + .word 42086 + .word 8136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34388 + .word 44810 + .word 8105 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7456 + .word 64092 + .word 8073 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48336 + .word 62448 + .word 8041 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60912 + .word 61622 + .word 8012 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17852 + .word 37250 + .word 7982 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57940 + .word 56453 + .word 7951 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47256 + .word 59825 + .word 7919 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3774 + .word 59120 + .word 7889 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43448 + .word 62852 + .word 7857 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4840 + .word 57195 + .word 7827 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40862 + .word 52565 + .word 7796 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1440 + .word 60474 + .word 7764 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55520 + .word 38648 + .word 7734 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15316 + .word 52422 + .word 7702 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 18704 + .word 47227 + .word 7672 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48892 + .word 54283 + .word 7640 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12670 + .word 41990 + .word 7610 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27570 + .word 49842 + .word 7579 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47230 + .word 47992 + .word 7548 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41020 + .word 56253 + .word 7516 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23404 + .word 58312 + .word 7486 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35176 + .word 51854 + .word 7455 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49188 + .word 59051 + .word 7423 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16656 + .word 54507 + .word 7391 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41320 + .word 48565 + .word 7362 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 302 + .word 42490 + .word 7331 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 26680 + .word 39967 + .word 7299 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41304 + .word 43638 + .word 7269 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2314 + .word 48533 + .word 7238 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63294 + .word 35693 + .word 7207 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24538 + .word 48319 + .word 7176 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56296 + .word 47263 + .word 7145 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 38599 + .word 7113 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6594 + .word 62116 + .word 7083 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47104 + .word 63573 + .word 7043 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34812 + .word 34303 + .word 7021 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5144 + .word 33695 + .word 6990 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24966 + .word 55768 + .word 6959 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62720 + .word 43946 + .word 6923 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31542 + .word 56062 + .word 6897 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 62356 + .word 59096 + .word 6865 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28412 + .word 40533 + .word 6835 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24080 + .word 50467 + .word 6803 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33296 + .word 46841 + .word 6770 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39600 + .word 38627 + .word 6742 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14436 + .word 37607 + .word 6710 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39032 + .word 56421 + .word 6678 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64032 + .word 54987 + .word 6649 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27648 + .word 42212 + .word 6613 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43840 + .word 46107 + .word 6584 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17316 + .word 36574 + .word 6556 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8928 + .word 37652 + .word 6522 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24944 + .word 47433 + .word 6493 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 57430 + .word 6461 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39848 + .word 43340 + .word 6430 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64160 + .word 43542 + .word 6400 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35226 + .word 63015 + .word 6370 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40736 + .word 64368 + .word 6338 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42168 + .word 49526 + .word 6307 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45596 + .word 34243 + .word 6277 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20690 + .word 39705 + .word 6246 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54448 + .word 46856 + .word 6213 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64392 + .word 62736 + .word 6182 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12780 + .word 56461 + .word 6152 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15360 + .word 49145 + .word 6122 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20512 + .word 49931 + .word 6087 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54512 + .word 55820 + .word 6057 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8402 + .word 39333 + .word 6029 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34094 + .word 53593 + .word 5998 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31960 + .word 38817 + .word 5966 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16954 + .word 39291 + .word 5936 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49600 + .word 48765 + .word 5901 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59580 + .word 56541 + .word 5874 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35624 + .word 44550 + .word 5843 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4142 + .word 47316 + .word 5812 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43520 + .word 43612 + .word 5780 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20976 + .word 40896 + .word 5747 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63576 + .word 57729 + .word 5719 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37288 + .word 33122 + .word 5688 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24384 + .word 52079 + .word 5654 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47952 + .word 58719 + .word 5624 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44242 + .word 55445 + .word 5595 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61232 + .word 38847 + .word 5561 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63232 + .word 46039 + .word 5528 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13396 + .word 42933 + .word 5502 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27392 + .word 43305 + .word 5467 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40708 + .word 35319 + .word 5440 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44408 + .word 55685 + .word 5409 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 42090 + .word 44607 + .word 5378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25504 + .word 53466 + .word 5345 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24208 + .word 33149 + .word 5315 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5268 + .word 45375 + .word 5285 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 144 + .word 40000 + .word 5254 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56688 + .word 52358 + .word 5221 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25848 + .word 56175 + .word 5190 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57900 + .word 44055 + .word 5160 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24800 + .word 43437 + .word 5128 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17984 + .word 54872 + .word 5094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25744 + .word 41345 + .word 5068 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 7668 + .word 43682 + .word 5036 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47434 + .word 36705 + .word 5006 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20888 + .word 40323 + .word 4974 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3962 + .word 43032 + .word 4944 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50270 + .word 49260 + .word 4913 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20160 + .word 64041 + .word 4877 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25624 + .word 36013 + .word 4849 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48328 + .word 59345 + .word 4820 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51508 + .word 63920 + .word 4788 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27872 + .word 39135 + .word 4758 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 13590 + .word 58857 + .word 4727 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 50880 + .word 61323 + .word 4692 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44802 + .word 37181 + .word 4665 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53808 + .word 57813 + .word 4634 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64424 + .word 49714 + .word 4602 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31652 + .word 44011 + .word 4572 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28252 + .word 50834 + .word 4541 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30370 + .word 38742 + .word 4510 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57728 + .word 58403 + .word 4473 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35900 + .word 37112 + .word 4448 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 40764 + .word 40914 + .word 4417 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21472 + .word 46910 + .word 4386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17854 + .word 35030 + .word 4355 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4378 + .word 35776 + .word 4324 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57962 + .word 55295 + .word 4293 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 64352 + .word 56717 + .word 4260 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37744 + .word 49416 + .word 4229 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38484 + .word 35759 + .word 4200 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 55020 + .word 54969 + .word 4169 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9188 + .word 55223 + .word 4137 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6822 + .word 43079 + .word 4107 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48870 + .word 40943 + .word 4076 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9936 + .word 42731 + .word 4043 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23430 + .word 43136 + .word 4014 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4700 + .word 55665 + .word 3982 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 8056 + .word 40216 + .word 3951 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3716 + .word 45403 + .word 3920 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53440 + .word 49488 + .word 3889 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 41776 + .word 50188 + .word 3858 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20994 + .word 64556 + .word 3828 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16252 + .word 60661 + .word 3796 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61252 + .word 65021 + .word 3765 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16236 + .word 43803 + .word 3734 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63064 + .word 35308 + .word 3702 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49096 + .word 39848 + .word 3673 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15680 + .word 48673 + .word 3642 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 48068 + .word 50957 + .word 3611 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20824 + .word 56086 + .word 3579 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46504 + .word 43224 + .word 3549 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52428 + .word 46094 + .word 3517 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17548 + .word 52066 + .word 3487 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61738 + .word 35565 + .word 3456 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31184 + .word 50588 + .word 3424 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1716 + .word 52681 + .word 3394 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44656 + .word 43385 + .word 3363 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12668 + .word 43259 + .word 3331 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24544 + .word 35408 + .word 3298 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28854 + .word 65018 + .word 3270 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5696 + .word 40391 + .word 3238 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 39580 + .word 56400 + .word 3208 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20428 + .word 39579 + .word 3177 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32328 + .word 36727 + .word 3146 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34020 + .word 54457 + .word 3115 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34016 + .word 48400 + .word 3083 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6922 + .word 51417 + .word 3053 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27208 + .word 64641 + .word 3021 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1802 + .word 48886 + .word 2991 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 35440 + .word 61590 + .word 2960 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 60610 + .word 51604 + .word 2929 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5440 + .word 38199 + .word 2895 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6914 + .word 43867 + .word 2867 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 24000 + .word 45256 + .word 2834 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51496 + .word 57396 + .word 2804 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11538 + .word 46256 + .word 2774 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36802 + .word 48020 + .word 2743 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57910 + .word 57903 + .word 2712 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47484 + .word 48798 + .word 2680 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 57766 + .word 57709 + .word 2650 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54064 + .word 47856 + .word 2619 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49340 + .word 48080 + .word 2588 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36454 + .word 56731 + .word 2557 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51548 + .word 63385 + .word 2526 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56000 + .word 48716 + .word 2490 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 44992 + .word 50040 + .word 2460 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43136 + .word 58177 + .word 2430 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49730 + .word 33270 + .word 2402 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 29808 + .word 51063 + .word 2371 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25276 + .word 46724 + .word 2339 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17324 + .word 35928 + .word 2308 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52284 + .word 63916 + .word 2278 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5414 + .word 46704 + .word 2247 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51710 + .word 57168 + .word 2216 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27366 + .word 49253 + .word 2185 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 45332 + .word 53033 + .word 2154 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 54152 + .word 37418 + .word 2121 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53076 + .word 47398 + .word 2092 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 14374 + .word 59477 + .word 2061 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59336 + .word 33435 + .word 2029 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21612 + .word 43267 + .word 1999 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34664 + .word 39372 + .word 1966 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 172 + .word 62761 + .word 1936 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9816 + .word 40715 + .word 1905 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65116 + .word 40481 + .word 1875 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28066 + .word 39184 + .word 1844 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37408 + .word 63923 + .word 1813 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15760 + .word 42305 + .word 1782 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 28236 + .word 59340 + .word 1750 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43258 + .word 59402 + .word 1720 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19988 + .word 50087 + .word 1689 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63456 + .word 47833 + .word 1655 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 65184 + .word 61426 + .word 1626 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52982 + .word 48456 + .word 1596 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30020 + .word 62809 + .word 1564 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9096 + .word 63061 + .word 1533 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59648 + .word 44374 + .word 1499 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11456 + .word 33847 + .word 1470 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 12392 + .word 50500 + .word 1440 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 56432 + .word 59196 + .word 1408 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61008 + .word 40265 + .word 1377 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37842 + .word 33270 + .word 1348 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 37916 + .word 44543 + .word 1316 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11490 + .word 36421 + .word 1286 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19040 + .word 38397 + .word 1254 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 31224 + .word 47162 + .word 1224 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 52056 + .word 41461 + .word 1192 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 10810 + .word 56374 + .word 1162 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 5358 + .word 35086 + .word 1131 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 36640 + .word 50226 + .word 1096 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33856 + .word 45597 + .word 1067 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21552 + .word 63128 + .word 1036 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1198 + .word 35616 + .word 1007 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 1232 + .word 59506 + .word 976 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 51086 + .word 34963 + .word 945 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 3960 + .word 39061 + .word 912 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 4564 + .word 57134 + .word 882 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 59468 + .word 35285 + .word 852 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 63422 + .word 35431 + .word 821 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38352 + .word 51462 + .word 790 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 25806 + .word 55660 + .word 759 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 38842 + .word 41327 + .word 728 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 17980 + .word 50458 + .word 697 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 61194 + .word 59710 + .word 666 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21098 + .word 42086 + .word 635 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 16704 + .word 43341 + .word 602 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 46316 + .word 52840 + .word 573 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20386 + .word 33936 + .word 542 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20064 + .word 51864 + .word 509 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 2268 + .word 57500 + .word 479 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 11152 + .word 51171 + .word 449 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 23164 + .word 63727 + .word 417 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 20514 + .word 40280 + .word 387 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 21818 + .word 57922 + .word 356 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32366 + .word 46413 + .word 325 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 53972 + .word 43148 + .word 294 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 30134 + .word 65133 + .word 263 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 15282 + .word 61516 + .word 232 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 49872 + .word 49222 + .word 200 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 9484 + .word 63958 + .word 170 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 47028 + .word 35341 + .word 139 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 6770 + .word 58613 + .word 108 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 33372 + .word 43448 + .word 77 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 27792 + .word 51629 + .word 43 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 19712 + .word 53691 + .word 15 + .word 0 + .word 0 + .word 0 + .type _4OPI,@object + .size _4OPI,8512 + .space 192, 0x00 # pad + .align 2 +_ADDING: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16446 + .word 0 + .word 0 + .word 0 + .type _ADDING,@object + .size _ADDING,16 + .align 2 +_nonel_value: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _nonel_value,@object + .size _nonel_value,16 + .align 2 +_PC: + .word 23996 + .word 61276 + .word 60076 + .word 54715 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 29541 + .word 45883 + .word 23690 + .word 51658 + .word 49114 + .word 0 + .word 0 + .word 0 + .word 41007 + .word 30189 + .word 50933 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 11013 + .word 35124 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 13032 + .word 3304 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 45630 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .type _PC,@object + .size _PC,128 + .align 2 +_ponel_value: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _ponel_value,@object + .size _ponel_value,16 + .align 2 +_PS: + .word 25 + .word 22807 + .word 53737 + .word 51452 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 54536 + .word 42444 + .word 58524 + .word 55101 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 63911 + .word 27722 + .word 12213 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 3718 + .word 18986 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 10480 + .word 46680 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 12958 + .word 3329 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 35030 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _PS,@object + .size _PS,128 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sincosd_table.S b/external/sgx_libm/intel64/sincosd_table.S new file mode 100644 index 0000000000..369422e4b4 --- /dev/null +++ b/external/sgx_libm/intel64/sincosd_table.S @@ -0,0 +1,767 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincosd_table.c" + .section .rodata, "a" + .align 16 + .align 16 + .globl __libm_sindl_cosdl_table +__libm_sindl_cosdl_table: + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 730455326 + .long 1066524427 + .long 1746175880 + .long 1010139981 + .long 2549460874 + .long 1072692928 + .long 4286585365 + .long 3162605893 + .long 3388464167 + .long 1067572824 + .long 3405773388 + .long 1011262106 + .long 2025784679 + .long 1072691970 + .long 3458349249 + .long 3162669794 + .long 1223674126 + .long 1068157895 + .long 1350368814 + .long 3158420169 + .long 3977438749 + .long 1072690373 + .long 2138672104 + .long 1015504988 + .long 1835684136 + .long 1068620687 + .long 3698316769 + .long 3158223757 + .long 1903230966 + .long 1072688139 + .long 1549185311 + .long 1015860439 + .long 3099754755 + .long 1068912598 + .long 85775068 + .long 3160181596 + .long 3021477282 + .long 1072685267 + .long 1009168830 + .long 3161309439 + .long 2604423020 + .long 1069204064 + .long 2303648607 + .long 1009017464 + .long 2499307462 + .long 1072681759 + .long 1081812731 + .long 1015750919 + .long 1280271059 + .long 1069494996 + .long 1784430238 + .long 1012342196 + .long 631389835 + .long 1072677616 + .long 319889322 + .long 1015931913 + .long 2525863449 + .long 1069666412 + .long 3319430370 + .long 1012720668 + .long 2838533242 + .long 1072672838 + .long 3931096191 + .long 3163228296 + .long 1739084661 + .long 1069811211 + .long 266127812 + .long 1005440081 + .long 2486166620 + .long 1072667428 + .long 1862034983 + .long 3163124964 + .long 2114679690 + .long 1069955610 + .long 1043937223 + .long 3160884320 + .long 2357271575 + .long 1072661387 + .long 1809738197 + .long 1015448300 + .long 3715523151 + .long 1070099565 + .long 3282620278 + .long 1013092107 + .long 1765324482 + .long 1072654717 + .long 2731192352 + .long 3162086677 + .long 2890029302 + .long 1070243033 + .long 2223107338 + .long 3159965253 + .long 846856320 + .long 1072647420 + .long 116450415 + .long 3163379753 + .long 919455349 + .long 1070385970 + .long 2064618035 + .long 3159935516 + .long 558794511 + .long 1072639498 + .long 1424282741 + .long 3161718678 + .long 4075075869 + .long 1070528331 + .long 3748620424 + .long 3160490968 + .long 2675554853 + .long 1072630953 + .long 3840651826 + .long 3156703495 + .long 3247638160 + .long 1070633085 + .long 3696489768 + .long 1014652612 + .long 1195949845 + .long 1072621789 + .long 1259393923 + .long 3162332067 + .long 3711077929 + .long 1070703626 + .long 3146917124 + .long 1014611084 + .long 3814620032 + .long 1072612007 + .long 3070837564 + .long 3162674392 + .long 3481523655 + .long 1070773815 + .long 2713761655 + .long 1014001377 + .long 1853610783 + .long 1072601612 + .long 3649998803 + .long 1015704482 + .long 925886800 + .long 1070843631 + .long 436010265 + .long 3162460259 + .long 323245311 + .long 1072590606 + .long 3093873492 + .long 1015519453 + .long 3489713627 + .long 1070913051 + .long 528334979 + .long 1014764117 + .long 738112715 + .long 1072578992 + .long 334349375 + .long 3162809522 + .long 1955204085 + .long 1070982056 + .long 1689242582 + .long 1014445850 + .long 1112681756 + .long 1072566774 + .long 1734695380 + .long 3163113281 + .long 533648188 + .long 1071050624 + .long 3960375553 + .long 1012377538 + .long 251639813 + .long 1072553956 + .long 3380683078 + .long 1012638586 + .long 4008023681 + .long 1071118733 + .long 570275026 + .long 1014484594 + .long 2039991128 + .long 1072540541 + .long 1062999797 + .long 3162182390 + .long 580452267 + .long 1071186365 + .long 3449718872 + .long 3161633148 + .long 2553046639 + .long 1072526534 + .long 2419472295 + .long 3163244343 + .long 554048209 + .long 1071253497 + .long 2399772791 + .long 3156410517 + .long 2935979925 + .long 1072511939 + .long 1428602113 + .long 1015064920 + .long 2000132179 + .long 1071320109 + .long 2171125689 + .long 3159852223 + .long 808310631 + .long 1072496761 + .long 4227501583 + .long 1014931887 + .long 3669886408 + .long 1071386181 + .long 3536165134 + .long 1013933230 + .long 3142990026 + .long 1072481003 + .long 4101727212 + .long 3163150444 + .long 725933569 + .long 1071451694 + .long 522349177 + .long 3161311953 + .long 490548333 + .long 1072464672 + .long 2395907389 + .long 3162833649 + .long 1948536952 + .long 1071516626 + .long 320619183 + .long 1014863857 + .long 1332553480 + .long 1072447771 + .long 3321840403 + .long 3163208850 + .long 3991904492 + .long 1071580958 + .long 2374541978 + .long 1014892768 + .long 2010331591 + .long 1072430306 + .long 1428309641 + .long 3163418034 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .long 3898100906 + .long 1072412282 + .long 3501572579 + .long 1015868565 + .long 553508627 + .long 1071676209 + .long 3116078237 + .long 1016033865 + .long 511109854 + .long 1072393706 + .long 3227708102 + .long 3163199948 + .long 1051516202 + .long 1071707417 + .long 2823792103 + .long 1015984420 + .long 3268258117 + .long 1072374581 + .long 893580578 + .long 1013933326 + .long 3614471965 + .long 1071738286 + .long 2346555295 + .long 3158494963 + .long 2829987804 + .long 1072354915 + .long 4086147764 + .long 3161968777 + .long 2215771410 + .long 1071768808 + .long 2812627676 + .long 1015346091 + .long 3450400421 + .long 1072334713 + .long 2241324349 + .long 3163087632 + .long 4168894840 + .long 1071798972 + .long 555969416 + .long 1015775320 + .long 1494583111 + .long 1072313982 + .long 92043893 + .long 3160700658 + .long 74799710 + .long 1071828771 + .long 2770520589 + .long 3160558553 + .long 2610427048 + .long 1072292727 + .long 436010265 + .long 3162460259 + .long 2488647350 + .long 1071858193 + .long 3884027735 + .long 1013773085 + .long 245529108 + .long 1072270956 + .long 3304882442 + .long 1014213155 + .long 2982005049 + .long 1071887231 + .long 3980032926 + .long 3161177863 + .long 1408525265 + .long 1072248674 + .long 1201054953 + .long 1015994881 + .long 2219342526 + .long 1071915876 + .long 3430823751 + .long 3163318748 + .long 890610472 + .long 1072225889 + .long 1982309908 + .long 3162056199 + .long 1379669533 + .long 1071944119 + .long 3329850390 + .long 3162839200 + .long 2731495481 + .long 1072202607 + .long 1347545148 + .long 1014567853 + .long 2167951316 + .long 1071971951 + .long 2070879930 + .long 1013227818 + .long 3030457399 + .long 1072178836 + .long 162525240 + .long 3161624810 + .long 2531396568 + .long 1071999364 + .long 4091857862 + .long 3162202094 + .long 2821963458 + .long 1072154583 + .long 1545337900 + .long 3160735078 + .long 965516331 + .long 1072026350 + .long 156922899 + .long 1014731144 + .long 3771230594 + .long 1072129855 + .long 3521184819 + .long 1014696396 + .long 820015888 + .long 1072052900 + .long 2191736501 + .long 1015202773 + .long 3869592889 + .long 1072104660 + .long 2133682458 + .long 3163440098 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 1719614413 + .long 1072079006 + .long 330458198 + .long 3163282740 + .long 3869592889 + .long 1072104660 + .long 2133682458 + .long 3163440098 + .long 820015888 + .long 1072052900 + .long 2191736501 + .long 1015202773 + .long 3771230594 + .long 1072129855 + .long 3521184819 + .long 1014696396 + .long 965516331 + .long 1072026350 + .long 156922899 + .long 1014731144 + .long 2821963458 + .long 1072154583 + .long 1545337900 + .long 3160735078 + .long 2531396568 + .long 1071999364 + .long 4091857862 + .long 3162202094 + .long 3030457399 + .long 1072178836 + .long 162525240 + .long 3161624810 + .long 2167951316 + .long 1071971951 + .long 2070879930 + .long 1013227818 + .long 2731495481 + .long 1072202607 + .long 1347545148 + .long 1014567853 + .long 1379669533 + .long 1071944119 + .long 3329850390 + .long 3162839200 + .long 890610472 + .long 1072225889 + .long 1982309908 + .long 3162056199 + .long 2219342526 + .long 1071915876 + .long 3430823751 + .long 3163318748 + .long 1408525265 + .long 1072248674 + .long 1201054953 + .long 1015994881 + .long 2982005049 + .long 1071887231 + .long 3980032926 + .long 3161177863 + .long 245529108 + .long 1072270956 + .long 3304882442 + .long 1014213155 + .long 2488647350 + .long 1071858193 + .long 3884027735 + .long 1013773085 + .long 2610427048 + .long 1072292727 + .long 436010265 + .long 3162460259 + .long 74799710 + .long 1071828771 + .long 2770520589 + .long 3160558553 + .long 1494583111 + .long 1072313982 + .long 92043893 + .long 3160700658 + .long 4168894840 + .long 1071798972 + .long 555969416 + .long 1015775320 + .long 3450400421 + .long 1072334713 + .long 2241324349 + .long 3163087632 + .long 2215771410 + .long 1071768808 + .long 2812627676 + .long 1015346091 + .long 2829987804 + .long 1072354915 + .long 4086147764 + .long 3161968777 + .long 3614471965 + .long 1071738286 + .long 2346555295 + .long 3158494963 + .long 3268258117 + .long 1072374581 + .long 893580578 + .long 1013933326 + .long 1051516202 + .long 1071707417 + .long 2823792103 + .long 1015984420 + .long 511109854 + .long 1072393706 + .long 3227708102 + .long 3163199948 + .long 553508627 + .long 1071676209 + .long 3116078237 + .long 1016033865 + .long 3898100906 + .long 1072412282 + .long 3501572579 + .long 1015868565 + .long 0 + .long 1071644672 + .long 0 + .long 0 + .long 2010331591 + .long 1072430306 + .long 1428309641 + .long 3163418034 + .long 3991904492 + .long 1071580958 + .long 2374541978 + .long 1014892768 + .long 1332553480 + .long 1072447771 + .long 3321840403 + .long 3163208850 + .long 1948536952 + .long 1071516626 + .long 320619183 + .long 1014863857 + .long 490548333 + .long 1072464672 + .long 2395907389 + .long 3162833649 + .long 725933569 + .long 1071451694 + .long 522349177 + .long 3161311953 + .long 3142990026 + .long 1072481003 + .long 4101727212 + .long 3163150444 + .long 3669886408 + .long 1071386181 + .long 3536165134 + .long 1013933230 + .long 808310631 + .long 1072496761 + .long 4227501583 + .long 1014931887 + .long 2000132179 + .long 1071320109 + .long 2171125689 + .long 3159852223 + .long 2935979925 + .long 1072511939 + .long 1428602113 + .long 1015064920 + .long 554048209 + .long 1071253497 + .long 2399772791 + .long 3156410517 + .long 2553046639 + .long 1072526534 + .long 2419472295 + .long 3163244343 + .long 580452267 + .long 1071186365 + .long 3449718872 + .long 3161633148 + .long 2039991128 + .long 1072540541 + .long 1062999797 + .long 3162182390 + .long 4008023681 + .long 1071118733 + .long 570275026 + .long 1014484594 + .long 251639813 + .long 1072553956 + .long 3380683078 + .long 1012638586 + .long 533648188 + .long 1071050624 + .long 3960375553 + .long 1012377538 + .long 1112681756 + .long 1072566774 + .long 1734695380 + .long 3163113281 + .long 1955204085 + .long 1070982056 + .long 1689242582 + .long 1014445850 + .long 738112715 + .long 1072578992 + .long 334349375 + .long 3162809522 + .long 3489713627 + .long 1070913051 + .long 528334979 + .long 1014764117 + .long 323245311 + .long 1072590606 + .long 3093873492 + .long 1015519453 + .long 925886800 + .long 1070843631 + .long 436010265 + .long 3162460259 + .long 1853610783 + .long 1072601612 + .long 3649998803 + .long 1015704482 + .long 3481523655 + .long 1070773815 + .long 2713761655 + .long 1014001377 + .long 3814620032 + .long 1072612007 + .long 3070837564 + .long 3162674392 + .long 3711077929 + .long 1070703626 + .long 3146917124 + .long 1014611084 + .long 1195949845 + .long 1072621789 + .long 1259393923 + .long 3162332067 + .long 3247638160 + .long 1070633085 + .long 3696489768 + .long 1014652612 + .long 2675554853 + .long 1072630953 + .long 3840651826 + .long 3156703495 + .long 4075075869 + .long 1070528331 + .long 3748620424 + .long 3160490968 + .long 558794511 + .long 1072639498 + .long 1424282741 + .long 3161718678 + .long 919455349 + .long 1070385970 + .long 2064618035 + .long 3159935516 + .long 846856320 + .long 1072647420 + .long 116450415 + .long 3163379753 + .long 2890029302 + .long 1070243033 + .long 2223107338 + .long 3159965253 + .long 1765324482 + .long 1072654717 + .long 2731192352 + .long 3162086677 + .long 3715523151 + .long 1070099565 + .long 3282620278 + .long 1013092107 + .long 2357271575 + .long 1072661387 + .long 1809738197 + .long 1015448300 + .long 2114679690 + .long 1069955610 + .long 1043937223 + .long 3160884320 + .long 2486166620 + .long 1072667428 + .long 1862034983 + .long 3163124964 + .long 1739084661 + .long 1069811211 + .long 266127812 + .long 1005440081 + .long 2838533242 + .long 1072672838 + .long 3931096191 + .long 3163228296 + .long 2525863449 + .long 1069666412 + .long 3319430370 + .long 1012720668 + .long 631389835 + .long 1072677616 + .long 319889322 + .long 1015931913 + .long 1280271059 + .long 1069494996 + .long 1784430238 + .long 1012342196 + .long 2499307462 + .long 1072681759 + .long 1081812731 + .long 1015750919 + .long 2604423020 + .long 1069204064 + .long 2303648607 + .long 1009017464 + .long 3021477282 + .long 1072685267 + .long 1009168830 + .long 3161309439 + .long 3099754755 + .long 1068912598 + .long 85775068 + .long 3160181596 + .long 1903230966 + .long 1072688139 + .long 1549185311 + .long 1015860439 + .long 1835684136 + .long 1068620687 + .long 3698316769 + .long 3158223757 + .long 3977438749 + .long 1072690373 + .long 2138672104 + .long 1015504988 + .long 1223674126 + .long 1068157895 + .long 1350368814 + .long 3158420169 + .long 2025784679 + .long 1072691970 + .long 3458349249 + .long 3162669794 + .long 3388464167 + .long 1067572824 + .long 3405773388 + .long 1011262106 + .long 2549460874 + .long 1072692928 + .long 4286585365 + .long 3162605893 + .long 730455326 + .long 1066524427 + .long 1746175880 + .long 1010139981 + .type __libm_sindl_cosdl_table,@object + .size __libm_sindl_cosdl_table,2880 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/sincosf_gen.S b/external/sgx_libm/intel64/sincosf_gen.S new file mode 100644 index 0000000000..cce988fef3 --- /dev/null +++ b/external/sgx_libm/intel64/sincosf_gen.S @@ -0,0 +1,531 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincosf_gen.c" + .text +..TXTST0: +# -- Begin sincosf + .text + .align 16,0x90 + .globl sincosf +sincosf: +# parameter 1: %xmm0 +# parameter 2: %rdi +# parameter 3: %rsi +..B1.1: + .cfi_startproc +..___tag_value_sincosf.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 + movq %rdi, (%rsp) + movq %rsi, 8(%rsp) +..B1.2: + pextrw $1, %xmm0, %eax + andw $32767, %ax + subw $128, %ax + cmpw $17791, %ax + ja .L_2TAG_PACKET_0.0.1 + movq PI_32_RECIP(%rip), %xmm1 + mulss %xmm0, %xmm1 + movapd BIT_31(%rip), %xmm3 + cvtss2si %xmm1, %edx + movl %edx, %ecx + andpd %xmm0, %xmm3 + cvtss2sd %xmm0, %xmm0 + movlhps %xmm0, %xmm0 + addss SHIFTER(%rip), %xmm1 + subss SHIFTER(%rip), %xmm1 + movapd %xmm3, %xmm4 + psllq $32, %xmm3 + psllq $29, %xmm4 + xorpd %xmm4, %xmm3 + addl $1865216, %edx + shll $4, %edx + addl $1865232, %ecx + shll $4, %ecx + movq P_1(%rip), %xmm2 + xorpd %xmm3, %xmm2 + xorpd P_2(%rip), %xmm3 + movlhps %xmm2, %xmm2 + movlhps %xmm3, %xmm3 + lea Ctable(%rip), %rax + andq $1008, %rdx + andq $1008, %rcx + addq %rax, %rcx + addq %rdx, %rax + psllq $29, %xmm1 + movlhps %xmm1, %xmm1 + mulpd %xmm1, %xmm2 + mulpd %xmm1, %xmm3 + subpd %xmm2, %xmm0 + addpd %xmm0, %xmm3 + mulpd %xmm0, %xmm0 + movapd C_1(%rip), %xmm4 + movapd S_1(%rip), %xmm5 + movapd ONE(%rip), %xmm1 + mulpd %xmm0, %xmm4 + mulpd %xmm0, %xmm5 + movapd C_2(%rip), %xmm6 + movapd S_2(%rip), %xmm7 + mulpd %xmm0, %xmm0 + addpd %xmm1, %xmm4 + mulpd %xmm0, %xmm6 + addpd %xmm1, %xmm5 + mulpd %xmm0, %xmm7 + addpd %xmm6, %xmm4 + addpd %xmm7, %xmm5 + movq (%rax), %xmm2 + movq 8(%rax), %xmm1 + movhpd (%rcx), %xmm2 + movhpd 8(%rcx), %xmm1 + mulpd %xmm1, %xmm3 + mulpd %xmm4, %xmm2 + mulpd %xmm5, %xmm3 + addpd %xmm3, %xmm2 + cvtpd2ps %xmm2, %xmm0 + movq (%rsp), %rax + movss %xmm0, (%rax) + movq 8(%rsp), %rax + pshufd $1, %xmm0, %xmm0 + movss %xmm0, (%rax) + jmp ..B1.7 +.L_2TAG_PACKET_0.0.1: + jg .L_2TAG_PACKET_1.0.1 + cvtss2sd %xmm0, %xmm0 + movq ONE(%rip), %xmm1 + movq %xmm0, %xmm2 + mulsd ONE_M230(%rip), %xmm0 + mulsd %xmm2, %xmm2 + subsd %xmm2, %xmm1 + cvtsd2ss %xmm0, %xmm0 + cvtsd2ss %xmm1, %xmm1 + movq (%rsp), %rax + movss %xmm0, (%rax) + movq 8(%rsp), %rax + movss %xmm1, (%rax) + jmp ..B1.7 +.L_2TAG_PACKET_1.0.1: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_2.0.1 + cvtss2sd %xmm0, %xmm0 + movq %xmm0, 16(%rsp) +..B1.3: + movsd 16(%rsp), %xmm0 +..___tag_value_sincosf.4: + call __libm_sse2_sincos@PLT +..___tag_value_sincosf.5: +..B1.4: + movsd %xmm0, 24(%rsp) +..B1.5: + movq 24(%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + cvtsd2ss %xmm1, %xmm1 + movq (%rsp), %rax + movss %xmm0, (%rax) + movq 8(%rsp), %rax + movss %xmm1, (%rax) + jmp ..B1.7 +.L_2TAG_PACKET_2.0.1: + pxor %xmm1, %xmm1 + mulss %xmm1, %xmm0 + movq (%rsp), %rax + movss %xmm0, (%rax) + movq 8(%rsp), %rax + movss %xmm0, (%rax) +.L_2TAG_PACKET_3.0.1: +..B1.7: + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type sincosf,@function + .size sincosf,.-sincosf + .data +# -- End sincosf + .section .rodata, "a" + .align 16 + .align 16 +BIT_31: + .long 2147483648 + .long 0 + .long 0 + .long 0 + .type BIT_31,@object + .size BIT_31,16 + .align 16 +P_1: + .long 1413758976 + .long 2008621563 + .type P_1,@object + .size P_1,8 + .space 8, 0x00 # pad + .align 16 +P_2: + .long 1734816687 + .long 1966270393 + .type P_2,@object + .size P_2,8 + .space 8, 0x00 # pad + .align 16 +Ctable: + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 1072683149 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 1072652951 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 1072602945 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 1072533611 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 1072445618 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 1072339814 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 1072217216 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 1072079006 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 1071926515 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 1071761211 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 1071524701 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 1071152610 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 1070765062 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 1070135480 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 1069094822 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 2748392742 + .long 1072683149 + .long 3156849708 + .long 3216578470 + .long 3489094832 + .long 1072652951 + .long 1013556747 + .long 3217619128 + .long 1455828442 + .long 1072602945 + .long 785751814 + .long 3218248710 + .long 3476196678 + .long 1072533611 + .long 2796464483 + .long 3218636258 + .long 4051746225 + .long 1072445618 + .long 939980347 + .long 3219008349 + .long 688824739 + .long 1072339814 + .long 967731400 + .long 3219244859 + .long 1796544321 + .long 1072217216 + .long 621354454 + .long 3219410163 + .long 1719614413 + .long 1072079006 + .long 1719614413 + .long 3219562654 + .long 621354454 + .long 1071926515 + .long 1796544321 + .long 3219700864 + .long 967731400 + .long 1071761211 + .long 688824739 + .long 3219823462 + .long 939980347 + .long 1071524701 + .long 4051746225 + .long 3219929266 + .long 2796464483 + .long 1071152610 + .long 3476196678 + .long 3220017259 + .long 785751814 + .long 1070765062 + .long 1455828442 + .long 3220086593 + .long 1013556747 + .long 1070135480 + .long 3489094832 + .long 3220136599 + .long 3156849708 + .long 1069094822 + .long 2748392742 + .long 3220166797 + .long 0 + .long 0 + .long 0 + .long 3220176896 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 3220166797 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 3220136599 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 3220086593 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 3220017259 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 3219929266 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 3219823462 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 3219700864 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 3219562654 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 3219410163 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 3219244859 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 3219008349 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 3218636258 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 3218248710 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 3217619128 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 3216578470 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 2748392742 + .long 3220166797 + .long 3156849708 + .long 1069094822 + .long 3489094832 + .long 3220136599 + .long 1013556747 + .long 1070135480 + .long 1455828442 + .long 3220086593 + .long 785751814 + .long 1070765062 + .long 3476196678 + .long 3220017259 + .long 2796464483 + .long 1071152610 + .long 4051746225 + .long 3219929266 + .long 939980347 + .long 1071524701 + .long 688824739 + .long 3219823462 + .long 967731400 + .long 1071761211 + .long 1796544321 + .long 3219700864 + .long 621354454 + .long 1071926515 + .long 1719614413 + .long 3219562654 + .long 1719614413 + .long 1072079006 + .long 621354454 + .long 3219410163 + .long 1796544321 + .long 1072217216 + .long 967731400 + .long 3219244859 + .long 688824739 + .long 1072339814 + .long 939980347 + .long 3219008349 + .long 4051746225 + .long 1072445618 + .long 2796464483 + .long 3218636258 + .long 3476196678 + .long 1072533611 + .long 785751814 + .long 3218248710 + .long 1455828442 + .long 1072602945 + .long 1013556747 + .long 3217619128 + .long 3489094832 + .long 1072652951 + .long 3156849708 + .long 3216578470 + .long 2748392742 + .long 1072683149 + .type Ctable,@object + .size Ctable,1024 + .align 16 +C_1: + .long 0 + .long 3219128320 + .long 0 + .long 3219128320 + .type C_1,@object + .size C_1,16 + .align 16 +S_1: + .long 1431655765 + .long 3217380693 + .long 1431655765 + .long 3217380693 + .type S_1,@object + .size S_1,16 + .align 16 +ONE: + .long 0 + .long 1072693248 + .long 0 + .long 1072693248 + .type ONE,@object + .size ONE,16 + .align 16 +C_2: + .long 1431655765 + .long 1067799893 + .long 1431655765 + .long 1067799893 + .type C_2,@object + .size C_2,16 + .align 16 +S_2: + .long 286331153 + .long 1065423121 + .long 286331153 + .long 1065423121 + .type S_2,@object + .size S_2,16 + .align 8 +PI_32_RECIP: + .long 1092811139 + .long 0 + .type PI_32_RECIP,@object + .size PI_32_RECIP,8 + .align 8 +SHIFTER: + .long 1262485504 + .type SHIFTER,@object + .size SHIFTER,4 + .space 4, 0x00 # pad + .align 8 +ONE_M230: + .long 4286578688 + .long 1072693247 + .type ONE_M230,@object + .size ONE_M230,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sincosl.S b/external/sgx_libm/intel64/sincosl.S new file mode 100644 index 0000000000..4fb7522bf7 --- /dev/null +++ b/external/sgx_libm/intel64/sincosl.S @@ -0,0 +1,1226 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sincosl.c" + .text +..TXTST0: +# -- Begin sincosl + .text + .align 16,0x90 + .globl sincosl +sincosl: +# parameter 1: 224 + %rsp +# parameter 2: %rdi +# parameter 3: %rsi +..B1.1: + .cfi_startproc +..___tag_value_sincosl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $176, %rsp + .cfi_def_cfa_offset 224 + movq %rsi, %r14 + movq %fs:40, %rax + movq %rdi, %r13 + xorq %rsp, %rax + xorb %r12b, %r12b + movq %rax, 168(%rsp) +..B1.2: + fnstcw 146(%rsp) +..B1.3: + movzwl 232(%rsp), %edx + andl $32767, %edx + movzwl 146(%rsp), %ecx + cmpl $32767, %edx + je ..B1.70 +..B1.4: + cmpl $16378, %edx + jge ..B1.42 +..B1.5: + cmpl $16372, %edx + jge ..B1.34 +..B1.6: + cmpl $16364, %edx + jge ..B1.26 +..B1.7: + cmpl $16308, %edx + jge ..B1.18 +..B1.8: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.12 +..B1.9: + orl $-64768, %ecx + movw %cx, 144(%rsp) +..B1.10: + fldcw 144(%rsp) +..B1.11: + movzwl 232(%rsp), %edx + movb $1, %r12b + andl $32767, %edx +..B1.12: + testl %edx, %edx + jle ..B1.59 +..B1.13: + fldt 224(%rsp) + lea _TWO_75(%rip), %rax + lea _small_value_80(%rip), %rcx + lea 8+_TWO_75(%rip), %rdx + lea _ones(%rip), %rbx + fldl (%rax) + fmul %st(1), %st + fsubp %st, %st(1) + fldt (%rcx) + fsubrl (%rbx) + fstpt 32(%rsp) + fmull (%rdx) + fstpt 16(%rsp) +..B1.14: + testb %r12b, %r12b + je ..B1.16 +..B1.15: + fldcw 146(%rsp) +..B1.16: + fldt 16(%rsp) + fstpt (%r13) + fldt 32(%rsp) + fstpt (%r14) + movq 168(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.17: + addq $176, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 224 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.18: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.22 +..B1.19: + orl $-64768, %ecx + movw %cx, 144(%rsp) +..B1.20: + fldcw 144(%rsp) +..B1.21: + movb $1, %r12b +..B1.22: + fldt 224(%rsp) + lea _SP3(%rip), %rax + lea _CP3(%rip), %rdx + lea _ones(%rip), %rcx + testb %r12b, %r12b + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + fadd %st(1), %st + fstpt 32(%rsp) + fldt (%rdx) + fmul %st(1), %st + fmulp %st, %st(1) + faddl (%rcx) + fstpt 16(%rsp) + je ..B1.24 +..B1.23: + fldcw 146(%rsp) +..B1.24: + fldt 32(%rsp) + fstpt (%r13) + fldt 16(%rsp) + fstpt (%r14) + movq 168(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.25: + addq $176, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 224 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.26: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.30 +..B1.27: + orl $-64768, %ecx + movw %cx, 144(%rsp) +..B1.28: + fldcw 144(%rsp) +..B1.29: + movb $1, %r12b +..B1.30: + fldt 224(%rsp) + lea 16+_SP2(%rip), %rax + fld %st(0) + lea _SP2(%rip), %rdx + fmul %st(1), %st + lea 16+_CP2(%rip), %rcx + fldt (%rax) + lea _CP2(%rip), %rbx + fmul %st(1), %st + lea _ones(%rip), %rbp + fldt (%rdx) + testb %r12b, %r12b + faddp %st, %st(1) + fmul %st(1), %st + fmul %st(2), %st + faddp %st, %st(2) + fxch %st(1) + fstpt 32(%rsp) + fldt (%rcx) + fmul %st(1), %st + fldt (%rbx) + faddp %st, %st(1) + fmulp %st, %st(1) + faddl (%rbp) + fstpt 16(%rsp) + je ..B1.32 +..B1.31: + fldcw 146(%rsp) +..B1.32: + fldt 32(%rsp) + fstpt (%r13) + fldt 16(%rsp) + fstpt (%r14) + movq 168(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.33: + addq $176, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 224 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.34: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.35: + orl $-64768, %ecx + movw %cx, 144(%rsp) +..B1.36: + fldcw 144(%rsp) +..B1.37: + movb $1, %r12b +..B1.38: + fldt 224(%rsp) + lea 32+_SP1(%rip), %rcx + fld %st(0) + lea _SP1(%rip), %rbx + fmul %st(1), %st + lea 48+_SP1(%rip), %rax + fld %st(0) + lea 48+_CP1(%rip), %rbp + fmul %st(1), %st + lea 16+_SP1(%rip), %rdx + fldt (%rax) + lea 16+_CP1(%rip), %rsi + fmul %st(1), %st + lea 32+_CP1(%rip), %rdi + fldt (%rdx) + lea _CP1(%rip), %r8 + lea _ones(%rip), %r9 + testb %r12b, %r12b + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + fmul %st(2), %st + fldt (%rbx) + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(3) + fxch %st(2) + fstpt 32(%rsp) + fldt (%rbp) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rdi) + fmulp %st, %st(3) + fldt (%r8) + faddp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + faddl (%r9) + fstpt 16(%rsp) + je ..B1.40 +..B1.39: + fldcw 146(%rsp) +..B1.40: + fldt 32(%rsp) + fstpt (%r13) + fldt 16(%rsp) + fstpt (%r14) + movq 168(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.41: + addq $176, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 224 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.42: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.46 +..B1.43: + orl $-64768, %ecx + movw %cx, 144(%rsp) +..B1.44: + fldcw 144(%rsp) +..B1.45: + movb $1, %r12b +..B1.46: + fldt 224(%rsp) + lea _ones(%rip), %rbp + movzbl 233(%rsp), %ebx + xorl %eax, %eax + andl $128, %ebx + shrl $7, %ebx + fmull (%rbp,%rbx,8) + fstpt 224(%rsp) + fldt 224(%rsp) + movzwl 232(%rsp), %edx + andl $32767, %edx + cmpl $16382, %edx + jge ..B1.48 +..B1.47: + lea _TWO_52H(%rip), %rcx + fld %st(0) + xorl %edx, %edx + fldl (%rcx) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fld %st(1) + fsubp %st, %st(1) + fxch %st(1) + jmp ..B1.51 +..B1.48: + je ..B1.67 +..B1.49: + addq $-16, %rsp + .cfi_def_cfa_offset 240 + xorl %edi, %edi + lea 168(%rsp), %rsi + fstpt (%rsp) +..___tag_value_sincosl.83: + call __libm_reduce_pi04l@PLT +..___tag_value_sincosl.84: +..B1.85: + movl %eax, %edx + addq $16, %rsp + .cfi_def_cfa_offset 224 +..B1.50: + fldl 152(%rsp) + lea 1(%rdx), %eax + lea _TWO_52H(%rip), %rcx + fld %st(0) + movsd 152(%rsp), %xmm0 + shrl $2, %eax + xorl %eax, %ebx + lea 3(%rdx), %eax + mulsd (%rcx), %xmm0 + andl $1, %ebx + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + shrl $2, %eax + fadd %st, %st(1) + andl $1, %eax + fsubrp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubr %st, %st(1) + fldl 160(%rsp) + faddp %st, %st(2) + fadd %st(1), %st +..B1.51: + fldt 16(%rsp) + lea 112+_SP(%rip), %rcx + fld %st(0) + lea 80+_SP(%rip), %rsi + fmul %st(3), %st + lea 48+_SP(%rip), %rdi + fxch %st(1) + fmul %st(0), %st + fld %st(0) + fld %st(1) + fxch %st(5) + fstpt 48(%rsp) + fldt 48(%rsp) + lea 128+_SP(%rip), %r9 + fmul %st(4), %st + lea 16+_SP(%rip), %r8 + lea 96+_SP(%rip), %r10 + lea 64+_SP(%rip), %r11 + movl %ebx, %ebx + incl %edx + testb $2, %dl + faddp %st, %st(3) + fld %st(2) + fxch %st(1) + fadd %st(3), %st + fmul %st, %st(1) + fxch %st(3) + fmul %st, %st(5) + fxch %st(1) + faddp %st, %st(5) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fmul %st(0), %st + fld %st(0) + fadd %st(5), %st + fxch %st(4) + fstpt 64(%rsp) + fstpt 112(%rsp) + fldt 112(%rsp) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rcx) + lea 32+_SP(%rip), %rcx + fmul %st(4), %st + fldt (%rsi) + lea _SP(%rip), %rsi + faddp %st, %st(1) + fmul %st(4), %st + fldt (%rdi) + lea 160+_SP(%rip), %rdi + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r8) + lea 144+_SP(%rip), %r8 + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r9) + lea _TWO_53H(%rip), %r9 + fmul %st(5), %st + fldt (%r10) + lea 112+_CP(%rip), %r10 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r11) + lea 80+_CP(%rip), %r11 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + lea 48+_CP(%rip), %rcx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rsi) + lea 16+_CP(%rip), %rsi + faddp %st, %st(1) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(5) + fldt (%rdi) + lea 128+_CP(%rip), %rdi + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(3) + fldt (%r8) + lea 96+_CP(%rip), %r8 + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 96(%rsp) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fldl (%r9) + fstpt 128(%rsp) + fldt 128(%rsp) + lea 64+_CP(%rip), %r9 + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(3), %st + fldt 64(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 16(%rsp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(2) + faddp %st, %st(1) + fldt (%r10) + fmul %st(3), %st + fldt (%r11) + lea 32+_CP(%rip), %r10 + lea _CP(%rip), %r11 + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + lea 160+_CP(%rip), %rcx + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rsi) + lea 144+_CP(%rip), %rsi + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + fmul %st(4), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(4) + fldt (%r11) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt (%rcx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt (%rsi) + fldt 80(%rsp) + fmul %st(1), %st + faddp %st, %st(2) + fldt 112(%rsp) + fmulp %st, %st(4) + fldt 96(%rsp) + fmulp %st, %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fldt 128(%rsp) + fmul %st(1), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fldl (%rbp) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fldl (%rbp,%rbx,8) + fldl (%rbp,%rax,8) + je ..B1.53 +..B1.52: + fxch %st(1) + fmul %st, %st(4) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(1) + fldt 32(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + fstpt 16(%rsp) + jmp ..B1.54 +..B1.53: + fldt 32(%rsp) + fmul %st(2), %st + fxch %st(4) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmul %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fstpt 16(%rsp) + fstpt 32(%rsp) +..B1.54: + testb %r12b, %r12b + je ..B1.56 +..B1.55: + fldcw 146(%rsp) +..B1.56: + fldt 16(%rsp) + fstpt (%r13) + fldt 32(%rsp) + fstpt (%r14) + movq 168(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.57: + addq $176, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 224 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.58: + call __stack_chk_fail@PLT +..B1.59: + cmpl $0, 228(%rsp) + jne ..B1.61 +..B1.60: + cmpl $0, 224(%rsp) + je ..B1.62 +..B1.61: + fldt 224(%rsp) + lea _TWO_75(%rip), %rbx + movb 233(%rsp), %al + lea _small_value_80(%rip), %rcx + andb $-128, %al + lea _ones(%rip), %rsi + lea 8+_TWO_75(%rip), %rbp + fldl (%rbx) + shrb $7, %al + fmul %st(1), %st + fsubp %st, %st(1) + fldt (%rcx) + fxch %st(1) + fmull (%rbp) + movzbl %al, %edx + shlq $4, %rdx + fstpt 16(%rsp) + fldl (%rsi) + fsub %st(1), %st + fstpt 32(%rsp) + fldt (%rcx,%rdx) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.14 +..B1.62: + fldt 224(%rsp) + lea _ones(%rip), %rax + fstpt 16(%rsp) + fldl (%rax) + fstpt 32(%rsp) + jmp ..B1.14 +..B1.67: + movl 228(%rsp), %edx + cmpl $-921707870, %edx + jb ..B1.47 +..B1.68: + jne ..B1.49 +..B1.69: + cmpl $560513589, 224(%rsp) + jbe ..B1.47 + jmp ..B1.49 +..B1.70: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.74 +..B1.71: + orl $-64768, %ecx + movw %cx, 144(%rsp) +..B1.72: + fldcw 144(%rsp) +..B1.73: + movb $1, %r12b +..B1.74: + cmpl $-2147483648, 228(%rsp) + jne ..B1.77 +..B1.75: + cmpl $0, 224(%rsp) + jne ..B1.77 +..B1.76: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt 16(%rsp) + jmp ..B1.78 +..B1.77: + fldt 224(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) +..B1.78: + testb %r12b, %r12b + je ..B1.80 +..B1.79: + fldcw 146(%rsp) +..B1.80: + fldt 16(%rsp) + fstpt (%r13) + fldt (%r13) + fstpt (%r14) + movq 168(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 + jmp ..B1.17 + .align 16,0x90 + .cfi_endproc + .type sincosl,@function + .size sincosl,.-sincosl + .data +# -- End sincosl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_SP3: + .word 17476 + .word 43656 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _SP3,@object + .size _SP3,16 + .align 2 +_CP3: + .word 0 + .word 65450 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .type _CP3,@object + .size _CP3,16 + .align 2 +_SP2: + .word 43210 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 1587 + .word 57422 + .word 34932 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP2,@object + .size _SP2,32 + .align 2 +_CP2: + .word 63855 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 18238 + .word 17476 + .word 43656 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP2,@object + .size _CP2,32 + .align 2 +_SP1: + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 12518 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 43088 + .word 7396 + .word 207 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 55827 + .word 48618 + .word 3602 + .word 47342 + .word 16364 + .word 0 + .word 0 + .word 0 + .type _SP1,@object + .size _SP1,64 + .align 2 +_CP1: + .word 65535 + .word 65535 + .word 65535 + .word 65535 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 47533 + .word 43689 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 14131 + .word 49466 + .word 24756 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 37142 + .word 18013 + .word 35855 + .word 53259 + .word 16367 + .word 0 + .word 0 + .word 0 + .type _CP1,@object + .size _CP1,64 + .align 2 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP,@object + .size _SP,176 + .align 2 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 0 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 0 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP,@object + .size _CP,176 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sindl.S b/external/sgx_libm/intel64/sindl.S new file mode 100644 index 0000000000..42958e7e65 --- /dev/null +++ b/external/sgx_libm/intel64/sindl.S @@ -0,0 +1,837 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sindl.c" + .text +..TXTST0: +# -- Begin sindl + .text + .align 16,0x90 + .globl sindl +sindl: +# parameter 1: 112 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_sindl.1: +..L2: + + subq $104, %rsp + .cfi_def_cfa_offset 112 + xorb %r8b, %r8b +..B1.2: + fnstcw 90(%rsp) +..B1.3: + movzwl 90(%rsp), %edx + movl %edx, %eax + andl $3840, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + andl $-3841, %edx + orl $-64768, %edx + movw %dx, 88(%rsp) +..B1.5: + fldcw 88(%rsp) +..B1.6: + movb $1, %r8b +..B1.7: + fldt 112(%rsp) + lea ones(%rip), %rdi + movzwl 120(%rsp), %eax + movl %eax, %esi + shrl $15, %eax + andl $32767, %esi + cmpl $32767, %esi + flds (%rdi,%rax,4) + movss (%rdi,%rax,4), %xmm0 + fmul %st, %st(1) + je ..B1.32 +..B1.8: + fldt .L_2il0floatpacket.0(%rip) + fstpt 72(%rsp) + fldt 72(%rsp) + fucomip %st(2), %st + jp ..B1.9 + je ..B1.31 +..B1.9: + testl %esi, %esi + je ..B1.24 +..B1.10: + cmpl $7, %esi + fxch %st(1) + jl ..B1.25 +..B1.11: + cmpl $10783, %esi + jl ..B1.26 +..B1.12: + fstp %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + cmpl $16446, %esi + jge ..B1.17 +..B1.13: + fldt .L_2il0floatpacket.2(%rip) + lea _Rcp90(%rip), %rax + fldt 72(%rsp) + fldt (%rax) + fmulp %st, %st(3) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + fstpt 48(%rsp) + fldt 48(%rsp) + movl 48(%rsp), %ecx + movl %ecx, %edx + andl $2, %edx + fsubp %st, %st(2) + fldt 112(%rsp) + fldt .L_2il0floatpacket.3(%rip) + fmulp %st, %st(3) + shrl $1, %edx + fsubp %st, %st(2) + mulss (%rdi,%rdx,4), %xmm0 + fucomip %st(1), %st + jp ..B1.14 + je ..B1.30 +..B1.14: + fldt .L_2il0floatpacket.4(%rip) + lea _TWO_53H(%rip), %rax + fmul %st(1), %st + fld %st(1) + movss %xmm0, (%rsp) + testb $1, %cl + fsubr %st(1), %st + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fld %st(0) + fld %st(3) + fsubr %st(3), %st + fchs + fmul %st, %st(3) + fld %st(4) + fxch %st(1) + fmul %st(5), %st + faddp %st, %st(4) + fld %st(4) + fldl (%rax) + fld %st(0) + fmul %st(5), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fxch %st(3) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fxch %st(1) + fmul %st(2), %st + fld %st(5) + fadd %st(1), %st + fsubp %st, %st(1) + fsub %st, %st(1) + fxch %st(1) + fchs + fstpt 32(%rsp) + fld %st(4) + fmul %st(5), %st + fld %st(0) + fmul %st(1), %st + flds (%rsp) + fstps 64(%rsp) + je ..B1.16 +..B1.15: + fstp %st(6) + fstp %st(1) + fld %st(2) + lea 112+_cosdl_poly_coeff(%rip), %rax + fmul %st(3), %st + lea 80+_cosdl_poly_coeff(%rip), %rdx + fmul %st, %st(2) + fld %st(1) + fmul %st(5), %st + fxch %st(4) + fstpt (%rsp) + fldt (%rsp) + fld %st(2) + lea 48+_cosdl_poly_coeff(%rip), %rcx + lea 96+_cosdl_poly_coeff(%rip), %rsi + lea 64+_cosdl_poly_coeff(%rip), %rdi + lea 32+_cosdl_poly_coeff(%rip), %r9 + lea 24+_cosdl_mp_poly_coeff(%rip), %r10 + lea 8+_cosdl_mp_poly_coeff(%rip), %r11 + fmul %st(7), %st + fxch %st(1) + fmul %st(6), %st + faddp %st, %st(5) + fld %st(1) + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(3) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) + faddp %st, %st(3) + fldt (%rax) + fmul %st(5), %st + fldt (%rdx) + lea 16+_cosdl_mp_poly_coeff(%rip), %rax + lea _cosdl_mp_poly_coeff(%rip), %rdx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmul %st(6), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r9) + faddp %st, %st(1) + faddp %st, %st(1) + fmulp %st, %st(2) + fldl (%r10) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fldl (%r11) + fmulp %st, %st(4) + faddp %st, %st(3) + fldl (%rax) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldl (%rdx) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt (%rsp) + fmulp %st, %st(2) + fld %st(1) + fldt 16(%rsp) + fmulp %st, %st(2) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + flds 64(%rsp) + fld %st(0) + fldt .L_2il0floatpacket.5(%rip) + fadd %st(4), %st + fmul %st, %st(1) + fldt .L_2il0floatpacket.5(%rip) + fsubp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 72(%rsp) + jmp ..B1.27 +..B1.16: + fld %st(6) + lea 128+_sindl_poly_coeff(%rip), %rax + fmul %st(2), %st + lea 96+_sindl_poly_coeff(%rip), %rdx + fstpt 16(%rsp) + lea 64+_sindl_poly_coeff(%rip), %rcx + fxch %st(2) + fstpt (%rsp) + fldt (%rsp) + lea 32+_sindl_poly_coeff(%rip), %rsi + lea 112+_sindl_poly_coeff(%rip), %rdi + lea 80+_sindl_poly_coeff(%rip), %r9 + lea 48+_sindl_poly_coeff(%rip), %r10 + lea 24+_sindl_mp_poly_coeff(%rip), %r11 + fmul %st(4), %st + fmul %st, %st(3) + fxch %st(5) + fmul %st(6), %st + fldt 32(%rsp) + fmul %st, %st(5) + fxch %st(1) + faddp %st, %st(5) + fld %st(5) + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(3) + fsubr %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + lea 8+_sindl_mp_poly_coeff(%rip), %rax + lea 16+_sindl_mp_poly_coeff(%rip), %rdx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + lea _sindl_mp_poly_coeff(%rip), %rcx + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%rdi) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 16(%rsp) + fmul %st, %st(1) + fldl (%r11) + fmulp %st, %st(1) + faddp %st, %st(1) + fldl (%rax) + fmulp %st, %st(5) + faddp %st, %st(4) + fldl (%rdx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldl (%rcx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldt (%rsp) + fmulp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + flds 64(%rsp) + fld %st(0) + fmulp %st, %st(2) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 72(%rsp) + jmp ..B1.27 +..B1.17: + fstp %st(0) + lea -16446(%rsi), %ecx + cmpl $14, %ecx + jle ..B1.19 +..B1.18: + addl $-16449, %esi + movl $715827883, %eax + imull %esi + movl %esi, %ecx + sarl $1, %edx + sarl $31, %ecx + subl %ecx, %edx + lea (,%rdx,8), %r9d + lea (%r9,%rdx,4), %r10d + subl %r10d, %esi + lea 3(%rsi), %ecx +..B1.19: + movl 116(%rsp), %r11d + movl %r11d, %esi + shll $8, %esi + movl $381774871, %eax + movl %esi, %edx + andl $-16777216, %r11d + shrl $3, %edx + movl %r11d, %r10d + mull %edx + shrl $19, %r11d + shrl $2, %edx + imull $-360, %edx, %eax + addl %eax, %esi + movl $381774871, %eax + mull %r11d + shrl $16, %r10d + movl $381774871, %eax + shrl $2, %edx + imull $-360, %edx, %r9d + addl %r9d, %r10d + movl 112(%rsp), %r9d + addl %r10d, %esi + movl %r9d, %r10d + shrl $3, %r10d + mull %r10d + movl $-1240768329, %eax + shrl $2, %edx + imull $-360, %edx, %r11d + addl %r11d, %r9d + addl %r9d, %esi + shll %cl, %esi + imull %esi + movl %esi, %ecx + addl %esi, %edx + sarl $8, %edx + sarl $31, %ecx + subl %ecx, %edx + imull $-360, %edx, %eax + lea (%rsi,%rax), %edx + cmpl $179, %edx + lea -180(%rsi,%rax), %ecx + movl $2, %esi + movl $0, %eax + cmovg %ecx, %edx + cmovg %esi, %eax + cmpl $89, %edx + jle ..B1.21 +..B1.20: + incl %eax + addl $-90, %edx +..B1.21: + movl %edx, %ecx + orl %eax, %ecx + je ..B1.27 +..B1.22: + movl %eax, %ecx + andl $2, %eax + andl $1, %ecx + addl %ecx, %ecx + shrl $1, %eax + mulss (%rdi,%rax,4), %xmm0 + movq __libm_sindl_cosdl_table@GOTPCREL(%rip), %rdi + lea (%rcx,%rdx,4), %edx + movss %xmm0, (%rsp) + flds (%rsp) + movslq %edx, %rdx + fldl (%rdi,%rdx,8) + faddl 8(%rdi,%rdx,8) + fmulp %st, %st(1) + fstpt 72(%rsp) + jmp ..B1.27 +..B1.24: + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + testl $-1048576, 116(%rsp) + je ..B1.26 +..B1.25: + lea _TWO5600(%rip), %rax + lea _TWO_53H(%rip), %rdx + lea 8+_sindl_mp_poly_coeff(%rip), %rcx + lea _sindl_mp_poly_coeff(%rip), %rsi + lea 16+_TWO5600(%rip), %rdi + fldt (%rax) + fmulp %st, %st(1) + fld %st(0) + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fldl (%rdx) + fmul %st(1), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fldl (%rcx) + fmulp %st, %st(2) + fldl (%rsi) + fmul %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fld %st(0) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fsub %st, %st(1) + fsubp %st, %st(1) + fsub %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(1) + fldt (%rdi) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 72(%rsp) + jmp ..B1.27 +..B1.26: + lea _TWO5600(%rip), %rax + lea _TWO_53H(%rip), %rdx + lea 8+_sindl_mp_poly_coeff(%rip), %rcx + lea _sindl_mp_poly_coeff(%rip), %rsi + lea 16+_TWO5600(%rip), %rdi + fldt (%rax) + fmulp %st, %st(1) + fld %st(0) + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fldl (%rdx) + fmul %st(1), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fsubr %st(1), %st + fldl (%rcx) + fmulp %st, %st(2) + fldl (%rsi) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fld %st(0) + fxch %st(2) + fmulp %st, %st(3) + fxch %st(1) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fsub %st, %st(1) + fsubp %st, %st(1) + fsub %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(1) + faddp %st, %st(1) + fldt (%rdi) + fmulp %st, %st(1) + fstpt 72(%rsp) +..B1.27: + testb %r8b, %r8b + je ..B1.29 +..B1.28: + fldcw 90(%rsp) +..B1.29: + fldt 72(%rsp) + addq $104, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 112 +..B1.30: + fstp %st(0) + fldt 72(%rsp) + testb $1, %cl + movss %xmm0, (%rsp) + flds (%rsp) + fcmove %st(1), %st + fstp %st(1) + fstpt 72(%rsp) + jmp ..B1.27 +..B1.31: + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fmulp %st, %st(1) + fstpt 72(%rsp) + jmp ..B1.27 +..B1.32: + fstp %st(0) + fldt .L_2il0floatpacket.0(%rip) + fmul %st(1), %st + fstpt 72(%rsp) + fstpt 112(%rsp) + jmp ..B1.27 + .align 16,0x90 + .cfi_endproc + .type sindl,@function + .size sindl,.-sindl + .data +# -- End sindl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x80,0x13,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3e,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb4,0x05,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 16 +_cosdl_poly_coeff: + .word 52350 + .word 41213 + .word 3800 + .word 40885 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 28613 + .word 7908 + .word 35668 + .word 34008 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 19927 + .word 58728 + .word 49885 + .word 45261 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 32884 + .word 22035 + .word 23267 + .word 64541 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 36401 + .word 51897 + .word 8309 + .word 57265 + .word 49070 + .word 0 + .word 0 + .word 0 + .word 34286 + .word 2728 + .word 41564 + .word 34642 + .word 16284 + .word 0 + .word 0 + .word 0 + .word 63248 + .word 18030 + .word 35596 + .word 60796 + .word 49032 + .word 0 + .word 0 + .word 0 + .word 52149 + .word 21294 + .word 63985 + .word 40123 + .word 16245 + .word 0 + .word 0 + .word 0 + .type _cosdl_poly_coeff,@object + .size _cosdl_poly_coeff,128 + .align 16 +_cosdl_mp_poly_coeff: + .long 3675529145 + .long 3206805153 + .long 2134983071 + .long 3151100167 + .long 1787026573 + .long 1043372817 + .long 205083639 + .long 988746860 + .type _cosdl_mp_poly_coeff,@object + .size _cosdl_mp_poly_coeff,32 + .align 16 +_sindl_poly_coeff: + .word 51374 + .word 38121 + .word 13586 + .word 36602 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 50116 + .word 41339 + .word 4204 + .word 60892 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 33704 + .word 2155 + .word 42839 + .word 60780 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 21250 + .word 19076 + .word 27901 + .word 57780 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 9076 + .word 49244 + .word 613 + .word 64083 + .word 16311 + .word 0 + .word 0 + .word 0 + .word 40572 + .word 30418 + .word 36251 + .word 46520 + .word 49061 + .word 0 + .word 0 + .word 0 + .word 3227 + .word 25505 + .word 5540 + .word 47626 + .word 16274 + .word 0 + .word 0 + .word 0 + .word 60933 + .word 3300 + .word 57416 + .word 36218 + .word 49023 + .word 0 + .word 0 + .word 0 + .word 45811 + .word 42646 + .word 37125 + .word 42185 + .word 16235 + .word 0 + .word 0 + .word 0 + .type _sindl_poly_coeff,@object + .size _sindl_poly_coeff,144 + .align 16 +_sindl_mp_poly_coeff: + .long 2723323193 + .long 1066524486 + .long 2863989530 + .long 1008058840 + .long 227815288 + .long 3199056770 + .long 3752327299 + .long 3142458725 + .type _sindl_mp_poly_coeff,@object + .size _sindl_mp_poly_coeff,32 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 2 +_Rcp90: + .word 46603 + .word 2912 + .word 24758 + .word 46603 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _Rcp90,@object + .size _Rcp90,16 + .align 2 +_TWO5600: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 21983 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 10783 + .word 0 + .word 0 + .word 0 + .type _TWO5600,@object + .size _TWO5600,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sinf_gen.S b/external/sgx_libm/intel64/sinf_gen.S new file mode 100644 index 0000000000..5e58fe229f --- /dev/null +++ b/external/sgx_libm/intel64/sinf_gen.S @@ -0,0 +1,543 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinf_gen.c" + .text +..TXTST0: +# -- Begin sinf + .text + .align 16,0x90 + .globl sinf +sinf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_sinf.1: +..L2: + +..B1.2: + subq $32, %rsp + .cfi_def_cfa_offset 40 + stmxcsr 8(%rsp) + cmpl $-24577, 8(%rsp) + jne .L_2TAG_PACKET_0.0.1 +.L_2TAG_PACKET_1.0.1: + pshuflw $68, %xmm0, %xmm1 + movd %xmm0, %ecx + cvtps2pd %xmm1, %xmm1 + movq $0x40445f306e000000, %rax + movd %rax, %xmm2 + movl $2147483647, %r10d + movl $1241513983, %r8d + andl %ecx, %r10d + subl %r10d, %r8d + subl $964689920, %r10d + orl %r10d, %r8d + jl .L_2TAG_PACKET_2.0.1 + movq $0x4338000000000000, %r11 + movd %r11, %xmm4 + mulsd %xmm1, %xmm2 + movq $0xbe5b1bbead603d8b, %rdx + movd %rdx, %xmm3 + movapd %xmm2, %xmm5 + addsd %xmm4, %xmm2 + movd %xmm2, %r9d + subsd %xmm4, %xmm2 + mulsd %xmm3, %xmm1 +.L_2TAG_PACKET_3.0.1: + lea Ctable(%rip), %r10 + movl $384, %eax + movq $0x40c37423899a1558, %rdx + movd %rdx, %xmm4 + subsd %xmm2, %xmm5 + addl %r9d, %r9d + movl %r9d, %r8d + sarb $7, %r9b + andl %r8d, %eax + addb %r9b, %r8b + xorb %r9b, %r8b + addsd %xmm5, %xmm1 + andl $254, %r8d + movsd (%r10,%r8,8), %xmm3 + movq $0x40a9f02f6222c720, %r11 + movd %r11, %xmm0 + movapd %xmm1, %xmm2 + unpcklpd %xmm1, %xmm2 + mulsd %xmm1, %xmm1 + movsd 8(%r10,%r8,8), %xmm5 + movl %eax, %r9d + addl $128, %r9d + andl $256, %r9d + shlq $55, %r9 + mulsd %xmm2, %xmm3 + movd %r9, %xmm2 + subsd %xmm1, %xmm0 + andl $256, %eax + shlq $55, %rax + subsd %xmm1, %xmm4 + movd %rax, %xmm1 + xorpd %xmm2, %xmm4 + mulsd %xmm5, %xmm0 + mulsd %xmm4, %xmm3 + xorpd %xmm1, %xmm0 + addsd %xmm3, %xmm0 + movl 8(%rsp), %eax + andl $-24577, %eax + cmpl 8(%rsp), %eax + jne .L_2TAG_PACKET_4.0.1 +.L_2TAG_PACKET_5.0.1: + cvtpd2ps %xmm0, %xmm0 + addq $32, %rsp + ret +.L_2TAG_PACKET_2.0.1: + andl $2147483647, %ecx + cmpl $1040187392, %ecx + ja .L_2TAG_PACKET_6.0.1 + cvtss2sd %xmm0, %xmm0 + mulsd ONE_M230(%rip), %xmm0 + movl 8(%rsp), %eax + andl $-24577, %eax + cmpl 8(%rsp), %eax + jne .L_2TAG_PACKET_4.0.1 + jmp .L_2TAG_PACKET_5.0.1 +.L_2TAG_PACKET_6.0.1: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_7.0.1 + shrl $23, %r10d + subl $27, %r10d + andl $65528, %r10d + lea Pitable(%rip), %rax + movsd (%rax,%r10,2), %xmm3 + movsd 8(%rax,%r10,2), %xmm5 + movq $0xffffffffff000000, %r9 + movd %r9, %xmm2 + movq $0x4338000000000000, %r11 + movd %r11, %xmm4 + andpd %xmm3, %xmm2 + psllq $40, %xmm3 + mulsd %xmm1, %xmm2 + mulsd %xmm1, %xmm3 + mulsd %xmm5, %xmm1 + movapd %xmm2, %xmm0 + addsd %xmm3, %xmm2 + movapd %xmm2, %xmm5 + subsd %xmm2, %xmm0 + addsd %xmm4, %xmm2 + addsd %xmm0, %xmm3 + movd %xmm2, %r9d + subsd %xmm4, %xmm2 + addsd %xmm3, %xmm1 + jmp .L_2TAG_PACKET_3.0.1 +.L_2TAG_PACKET_7.0.1: + movl 8(%rsp), %eax + andl $-24577, %eax + cmpl 8(%rsp), %eax + je .L_2TAG_PACKET_8.0.1 + stmxcsr 16(%rsp) + movl 8(%rsp), %eax + andl $24576, %eax + orl %eax, 16(%rsp) + ldmxcsr 16(%rsp) +.L_2TAG_PACKET_8.0.1: + subss %xmm0, %xmm0 + addq $32, %rsp + ret +.L_2TAG_PACKET_0.0.1: + movl 8(%rsp), %eax + andl $-24577, %eax + movl %eax, 16(%rsp) + ldmxcsr 16(%rsp) + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_4.0.1: + stmxcsr 16(%rsp) + movl 8(%rsp), %eax + andl $24576, %eax + orl %eax, 16(%rsp) + ldmxcsr 16(%rsp) + jmp .L_2TAG_PACKET_5.0.1 + .cfi_def_cfa_offset 8 +..B1.3: + .align 16,0x90 + .cfi_endproc + .type sinf,@function + .size sinf,.-sinf + .data +# -- End sinf + .section .rodata, "a" + .align 16 + .align 16 +Ctable: + .long 3861233235 + .long 1053076412 + .long 0 + .long 0 + .long 3836476539 + .long 1053076004 + .long 1466910230 + .long 1054802127 + .long 522802171 + .long 1053074781 + .long 1693671239 + .long 1055850091 + .long 1381230637 + .long 1053072742 + .long 3419039295 + .long 1056390099 + .long 3096463640 + .long 1053069889 + .long 3054827835 + .long 1056896220 + .long 163641427 + .long 1053066225 + .long 3381119115 + .long 1057182863 + .long 2063766514 + .long 1053061750 + .long 544295963 + .long 1057434550 + .long 3193221610 + .long 1053056468 + .long 3297207428 + .long 1057685321 + .long 36665700 + .long 1053050383 + .long 2811721921 + .long 1057935027 + .long 4043704933 + .long 1053043496 + .long 2950925715 + .long 1058098350 + .long 2964703016 + .long 1053035814 + .long 2674059679 + .long 1058221912 + .long 3789723003 + .long 1053027340 + .long 879820317 + .long 1058344717 + .long 2671784286 + .long 1053018080 + .long 1979618421 + .long 1058466690 + .long 2093526290 + .long 1053008039 + .long 3945677176 + .long 1058587758 + .long 2262842797 + .long 1052997223 + .long 2796081240 + .long 1058707849 + .long 1097233945 + .long 1052985639 + .long 1373383079 + .long 1058826890 + .long 2796885356 + .long 1052973293 + .long 941816458 + .long 1058944809 + .long 646746141 + .long 1052960194 + .long 1372808103 + .long 1059061535 + .long 2767093429 + .long 1052946348 + .long 664370609 + .long 1059119379 + .long 2028347177 + .long 1052931765 + .long 1369913724 + .long 1059176444 + .long 1799297257 + .long 1052916453 + .long 3344537919 + .long 1059232808 + .long 3039475318 + .long 1052900421 + .long 2500108843 + .long 1059288438 + .long 4275292648 + .long 1052883679 + .long 944109265 + .long 1059343300 + .long 1575056534 + .long 1052866238 + .long 2771364651 + .long 1059397360 + .long 1407782048 + .long 1052848107 + .long 1264637048 + .long 1059450587 + .long 3436142021 + .long 1052829297 + .long 453708735 + .long 1059502948 + .long 488211833 + .long 1052809821 + .long 2313428161 + .long 1059554411 + .long 2993330 + .long 1052789689 + .long 2550341159 + .long 1059604946 + .long 755484892 + .long 1052767523 + .long 3567792879 + .long 1059654522 + .long 3348027550 + .long 1052724710 + .long 1659779181 + .long 1059703110 + .long 2580634211 + .long 1052680662 + .long 4268074870 + .long 1059750679 + .long 742418353 + .long 1052635405 + .long 4288148241 + .long 1059797202 + .long 3250975870 + .long 1052588965 + .long 1618129506 + .long 1059842651 + .long 1401987205 + .long 1052541372 + .long 3231311734 + .long 1059886997 + .long 2361617751 + .long 1052492653 + .long 1772140623 + .long 1059930215 + .long 3322544997 + .long 1052442838 + .long 1395127179 + .long 1059972278 + .long 17970311 + .long 1052391958 + .long 652328457 + .long 1060013161 + .long 3823857331 + .long 1052340041 + .long 1148832537 + .long 1060052839 + .long 3024934267 + .long 1052287121 + .long 3311502568 + .long 1060091288 + .long 1388494065 + .long 1052233229 + .long 1077921708 + .long 1060119411 + .long 902054988 + .long 1052178397 + .long 115411415 + .long 1060137373 + .long 1689375324 + .long 1052122658 + .long 3838419993 + .long 1060154686 + .long 1925003623 + .long 1052066046 + .long 1813501338 + .long 1060171342 + .long 2042383238 + .long 1052008595 + .long 2490283769 + .long 1060187329 + .long 350661592 + .long 1051950340 + .long 3162654741 + .long 1060202638 + .long 1535093810 + .long 1051891315 + .long 2878576948 + .long 1060217260 + .long 3681356269 + .long 1051831556 + .long 2463945945 + .long 1060231186 + .long 2478530408 + .long 1051771100 + .long 250409509 + .long 1060244408 + .long 3726787968 + .long 1051698237 + .long 687004205 + .long 1060256917 + .long 2082609563 + .long 1051574753 + .long 1475857720 + .long 1060268706 + .long 1666812989 + .long 1051450094 + .long 2181617495 + .long 1060279768 + .long 2865853451 + .long 1051324335 + .long 4249822861 + .long 1060290096 + .long 321119318 + .long 1051197553 + .long 2434209605 + .long 1060299685 + .long 4207787592 + .long 1051069822 + .long 1992674941 + .long 1060308528 + .long 1382541649 + .long 1050941222 + .long 1522351063 + .long 1060316620 + .long 2429158325 + .long 1050811828 + .long 1563320407 + .long 1060323956 + .long 2803392399 + .long 1050681719 + .long 316258674 + .long 1060330532 + .long 3917367244 + .long 1050428795 + .long 2243801771 + .long 1060336343 + .long 1991825541 + .long 1050166188 + .long 900924147 + .long 1060341387 + .long 624330694 + .long 1049902623 + .long 418831766 + .long 1060345660 + .long 3087185898 + .long 1049638258 + .long 2627920248 + .long 1060349159 + .long 3670374716 + .long 1049121932 + .long 2769466396 + .long 1060351883 + .long 3431923622 + .long 1048590963 + .long 2385983684 + .long 1060353830 + .long 918535681 + .long 1047542708 + .long 735532773 + .long 1060354999 + .long 0 + .long 0 + .long 3384690142 + .long 1060355388 + .type Ctable,@object + .size Ctable,1040 + .align 16 +Pitable: + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1832810809 + .long 1078222640 + .long 4036845384 + .long 1030771879 + .long 1916669064 + .long 1072155675 + .long 660066805 + .long 1024797180 + .long 3829231700 + .long 1062745828 + .long 2884172442 + .long 1017445907 + .long 540874025 + .long 1055617650 + .long 4198409884 + .long 1011844330 + .long 2839315448 + .long 1046639136 + .long 4204424928 + .long 1000582120 + .long 1329339431 + .long 1038229673 + .long 1295478839 + .long 993391741 + .long 658191860 + .long 1024797180 + .long 3691886121 + .long 979325773 + .long 1966800710 + .long 1020436418 + .long 1882642597 + .long 977095991 + .long 2100977488 + .long 1012908661 + .long 1840335565 + .long 967470816 + .long 4198093645 + .long 1000582120 + .long 3307942521 + .long 957055414 + .long 2839123165 + .long 996851343 + .long 1387472776 + .long 952638316 + .long 2788761024 + .long 988712873 + .long 3005712498 + .long 944467026 + .long 3694676832 + .long 979325773 + .long 1326507024 + .long 934847846 + .long 221775557 + .long 970149340 + .long 1133527550 + .long 924162364 + .type Pitable,@object + .size Pitable,240 + .align 8 +ONE_M230: + .long 4286578688 + .long 1072693247 + .type ONE_M230,@object + .size ONE_M230,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sinh_gen.S b/external/sgx_libm/intel64/sinh_gen.S new file mode 100644 index 0000000000..d584312f9c --- /dev/null +++ b/external/sgx_libm/intel64/sinh_gen.S @@ -0,0 +1,457 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinh_gen.c" + .text +..TXTST0: +# -- Begin sinh + .text + .align 16,0x90 + .globl sinh +sinh: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_sinh.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $1077338037, %ecx + jae ..B1.12 +..B1.2: + cmpl $1066695393, %ecx + jae ..B1.11 +..B1.3: + cmpl $1012924416, %ecx + jae ..B1.10 +..B1.4: + shrl $31, %eax + cmpl $1048576, %ecx + jb ..B1.6 +..B1.5: + movsd .L_2il0floatpacket.13(%rip), %xmm1 + addsd %xmm0, %xmm1 + movsd %xmm1, -24(%rsp) + movsd -24(%rsp), %xmm2 + mulsd %xmm2, %xmm0 + ret +..B1.6: + movl -8(%rsp), %edx + orl %edx, %ecx + je ..B1.8 +..B1.7: + lea _small_value_64(%rip), %rdx + movsd (%rdx,%rax,8), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, -24(%rsp) + movsd -24(%rsp), %xmm0 + addsd -8(%rsp), %xmm0 + ret +..B1.8: + movsd -8(%rsp), %xmm0 +..B1.9: + ret +..B1.10: + movsd -8(%rsp), %xmm4 + movaps %xmm4, %xmm2 + mulsd %xmm4, %xmm2 + movaps %xmm2, %xmm1 + mulsd %xmm2, %xmm1 + movsd .L_2il0floatpacket.9(%rip), %xmm0 + movsd .L_2il0floatpacket.11(%rip), %xmm3 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm3 + addsd .L_2il0floatpacket.10(%rip), %xmm0 + addsd .L_2il0floatpacket.12(%rip), %xmm3 + mulsd %xmm1, %xmm0 + mulsd %xmm2, %xmm3 + addsd %xmm3, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm4, %xmm0 + ret +..B1.11: + movsd -8(%rsp), %xmm1 + lea _TWO_52(%rip), %rdx + andps .L_2il0floatpacket.14(%rip), %xmm1 + lea _ptwo_32p1(%rip), %rsi + movsd .L_2il0floatpacket.0(%rip), %xmm2 + lea _ntwo_32p1(%rip), %rdi + mulsd %xmm1, %xmm2 + lea _two_32(%rip), %r8 + movsd .L_2il0floatpacket.1(%rip), %xmm3 + andl $-2147483648, %eax + movsd %xmm1, -8(%rsp) + movsd .L_2il0floatpacket.2(%rip), %xmm4 + movsd (%rsi), %xmm6 + movsd (%rdi), %xmm7 + movsd .L_2il0floatpacket.4(%rip), %xmm13 + movsd .L_2il0floatpacket.6(%rip), %xmm14 + movsd .L_2il0floatpacket.3(%rip), %xmm8 + movsd .L_2il0floatpacket.3(%rip), %xmm9 + addsd (%rdx), %xmm2 + movsd %xmm2, -24(%rsp) + movsd -24(%rsp), %xmm5 + movl -24(%rsp), %r10d + movl %r10d, %ecx + shll $25, %ecx + subsd (%rdx), %xmm5 + mulsd %xmm5, %xmm3 + mulsd %xmm4, %xmm5 + subsd %xmm3, %xmm1 + movaps %xmm1, %xmm10 + sarl $25, %ecx + subsd %xmm5, %xmm10 + movaps %xmm10, %xmm11 + movaps %xmm10, %xmm15 + movslq %ecx, %rcx + subsd %xmm10, %xmm1 + addsd %xmm10, %xmm6 + subsd %xmm10, %xmm7 + subsd %xmm5, %xmm1 + movsd %xmm6, -40(%rsp) + subl %ecx, %r10d + movsd %xmm7, -32(%rsp) + pxor %xmm5, %xmm5 + movsd -40(%rsp), %xmm2 + addsd %xmm1, %xmm11 + subsd (%r8), %xmm2 + movaps %xmm11, %xmm12 + addsd %xmm2, %xmm8 + mulsd %xmm11, %xmm12 + subsd %xmm8, %xmm15 + mulsd %xmm12, %xmm13 + mulsd %xmm12, %xmm14 + addsd %xmm1, %xmm15 + addsd .L_2il0floatpacket.5(%rip), %xmm13 + addsd .L_2il0floatpacket.7(%rip), %xmm14 + mulsd %xmm12, %xmm13 + mulsd %xmm12, %xmm14 + mulsd %xmm11, %xmm13 + addsd .L_2il0floatpacket.8(%rip), %xmm14 + addsd %xmm13, %xmm15 + mulsd %xmm12, %xmm14 + movsd -32(%rsp), %xmm0 + addsd %xmm14, %xmm15 + addsd (%r8), %xmm0 + shrl $7, %r10d + addsd %xmm0, %xmm9 + shll $23, %r10d + addsd %xmm9, %xmm10 + shlq $4, %rcx + lea 1056964608(%r10), %r9d + negl %r10d + orl %eax, %r9d + addl $1056964608, %r10d + addsd %xmm10, %xmm1 + orl %r10d, %eax + movl %eax, -12(%rsp) + movq __libm_exp_table_128@GOTPCREL(%rip), %rax + xorps .L_2il0floatpacket.15(%rip), %xmm1 + movl %r9d, -16(%rsp) + subsd %xmm13, %xmm1 + cvtss2sd -16(%rsp), %xmm5 + addsd %xmm14, %xmm1 + movsd 1032(%rax,%rcx), %xmm8 + movaps %xmm8, %xmm4 + mulsd %xmm15, %xmm4 + addsd %xmm2, %xmm15 + mulsd %xmm8, %xmm2 + mulsd 1024(%rax,%rcx), %xmm15 + negq %rcx + addsd %xmm15, %xmm4 + movsd 1032(%rax,%rcx), %xmm15 + movaps %xmm15, %xmm3 + mulsd %xmm1, %xmm3 + addsd %xmm0, %xmm1 + mulsd %xmm15, %xmm0 + mulsd %xmm5, %xmm4 + mulsd 1024(%rax,%rcx), %xmm1 + mulsd %xmm2, %xmm5 + addsd %xmm1, %xmm3 + pxor %xmm1, %xmm1 + cvtss2sd -12(%rsp), %xmm1 + mulsd %xmm1, %xmm3 + mulsd %xmm0, %xmm1 + subsd %xmm3, %xmm4 + movaps %xmm5, %xmm0 + subsd %xmm1, %xmm0 + subsd %xmm0, %xmm5 + subsd %xmm1, %xmm5 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm0 + ret +..B1.12: + cmpl $1082536910, %ecx + jb ..B1.18 +..B1.13: + jne ..B1.15 +..B1.14: + cmpl $-1883637635, -8(%rsp) + jbe ..B1.18 +..B1.15: + cmpl $2146435072, %ecx + jb ..B1.19 +..B1.16: + movsd -8(%rsp), %xmm0 + addsd %xmm0, %xmm0 +..B1.17: + ret +..B1.18: + movsd -8(%rsp), %xmm12 + lea _TWO_52(%rip), %rdx + andps .L_2il0floatpacket.14(%rip), %xmm12 + lea _ptwo_32p1(%rip), %rcx + movsd .L_2il0floatpacket.0(%rip), %xmm0 + lea _two_32(%rip), %rsi + mulsd %xmm12, %xmm0 + andl $-2147483648, %eax + movsd .L_2il0floatpacket.1(%rip), %xmm1 + lea _TWO_512(%rip), %r9 + movsd %xmm12, -8(%rsp) + movsd .L_2il0floatpacket.2(%rip), %xmm2 + movsd .L_2il0floatpacket.6(%rip), %xmm11 + movsd .L_2il0floatpacket.4(%rip), %xmm8 + movsd (%rcx), %xmm4 + movsd .L_2il0floatpacket.3(%rip), %xmm5 + movsd .L_2il0floatpacket.8(%rip), %xmm10 + movl $0, -16(%rsp) + addsd (%rdx), %xmm0 + movsd %xmm0, -24(%rsp) + movsd -24(%rsp), %xmm3 + movl -24(%rsp), %edi + movl %edi, %r8d + shll $25, %r8d + subsd (%rdx), %xmm3 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm3 + subsd %xmm1, %xmm12 + movaps %xmm12, %xmm6 + sarl $25, %r8d + subsd %xmm3, %xmm6 + movaps %xmm6, %xmm7 + subl %r8d, %edi + shrl $7, %edi + subsd %xmm6, %xmm12 + addsd %xmm6, %xmm4 + subsd %xmm3, %xmm12 + movsd %xmm4, -24(%rsp) + addsd %xmm12, %xmm7 + movaps %xmm7, %xmm9 + mulsd %xmm7, %xmm9 + mulsd %xmm9, %xmm11 + mulsd %xmm9, %xmm8 + mulsd %xmm9, %xmm10 + addsd .L_2il0floatpacket.7(%rip), %xmm11 + addsd .L_2il0floatpacket.5(%rip), %xmm8 + mulsd %xmm9, %xmm11 + mulsd %xmm7, %xmm8 + movsd -24(%rsp), %xmm0 + addsd %xmm8, %xmm11 + subsd (%rsi), %xmm0 + mulsd %xmm9, %xmm11 + addsd %xmm0, %xmm5 + addsd %xmm10, %xmm11 + subsd %xmm5, %xmm6 + shll $20, %edi + addsd %xmm6, %xmm12 + movslq %r8d, %r8 + addl $534773760, %edi + shlq $4, %r8 + orl %edi, %eax + movl %eax, -12(%rsp) + addsd %xmm11, %xmm12 + movq __libm_exp_table_128@GOTPCREL(%rip), %rax + movsd 1032(%rax,%r8), %xmm13 + movaps %xmm13, %xmm14 + mulsd %xmm12, %xmm14 + addsd %xmm0, %xmm12 + mulsd %xmm13, %xmm0 + mulsd 1024(%rax,%r8), %xmm12 + addsd %xmm12, %xmm14 + addsd %xmm14, %xmm0 + mulsd -16(%rsp), %xmm0 + mulsd (%r9), %xmm0 + ret +..B1.19: + lea _large_value_64(%rip), %rdx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm0 + mulsd (%rdx), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type sinh,@function + .size sinh,.-sinh + .data +# -- End sinh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.14: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,16 + .align 16 +.L_2il0floatpacket.15: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0xb9ff12f0,0x3ec71e39 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x111111c1,0x3f811111 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x1940cd88,0x3f2a01a0 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x55555555,0x3fc55555 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_TWO_52: + .long 0 + .long 1127219200 + .type _TWO_52,@object + .size _TWO_52,8 + .align 4 +_ptwo_32p1: + .long 1048576 + .long 1106247680 + .type _ptwo_32p1,@object + .size _ptwo_32p1,8 + .align 4 +_ntwo_32p1: + .long 4292870144 + .long 3253731327 + .type _ntwo_32p1,@object + .size _ntwo_32p1,8 + .align 4 +_two_32: + .long 0 + .long 1106247680 + .type _two_32,@object + .size _two_32,8 + .align 4 +_TWO_512: + .long 0 + .long 1609564160 + .type _TWO_512,@object + .size _TWO_512,8 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sinhf_gen.S b/external/sgx_libm/intel64/sinhf_gen.S new file mode 100644 index 0000000000..6875ce04c9 --- /dev/null +++ b/external/sgx_libm/intel64/sinhf_gen.S @@ -0,0 +1,365 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinhf_gen.c" + .text +..TXTST0: +# -- Begin sinhf + .text + .align 16,0x90 + .globl sinhf +sinhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_sinhf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + movl %edx, %eax + andl $2147483647, %eax + cmpl $1107296256, %eax + jae ..B1.14 +..B1.2: + cmpl $1056964608, %eax + jae ..B1.13 +..B1.3: + cmpl $1031798784, %eax + jae ..B1.12 +..B1.4: + cmpl $838860800, %eax + jae ..B1.11 +..B1.5: + shrl $31, %edx + cmpl $8388608, %eax + jb ..B1.7 +..B1.6: + movss .L_2il0floatpacket.16(%rip), %xmm1 + addss %xmm0, %xmm1 + movss %xmm1, -16(%rsp) + ret +..B1.7: + testl %eax, %eax + je ..B1.9 +..B1.8: + lea _small_value_32(%rip), %rax + movss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.15(%rip), %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm0 + addss -8(%rsp), %xmm0 + ret +..B1.9: + movss -8(%rsp), %xmm0 +..B1.10: + ret +..B1.11: + pxor %xmm1, %xmm1 + cvtss2sd -8(%rsp), %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.13(%rip), %xmm2 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.14(%rip), %xmm2 + mulsd %xmm0, %xmm2 + mulsd %xmm1, %xmm2 + addsd %xmm1, %xmm2 + cvtsd2ss %xmm2, %xmm2 + movaps %xmm2, %xmm0 + ret +..B1.12: + pxor %xmm3, %xmm3 + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.8(%rip), %xmm4 + movsd .L_2il0floatpacket.10(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.9(%rip), %xmm4 + addsd .L_2il0floatpacket.11(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm3, %xmm4 + cvtsd2ss %xmm4, %xmm4 + movaps %xmm4, %xmm0 + ret +..B1.13: + pxor %xmm3, %xmm3 + andl $-2147483648, %edx + cvtss2sd -8(%rsp), %xmm3 + andps .L_2il0floatpacket.17(%rip), %xmm3 + pxor %xmm4, %xmm4 + movsd .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm6, %xmm6 + mulsd %xmm3, %xmm0 + movsd .L_2il0floatpacket.4(%rip), %xmm7 + movsd .L_2il0floatpacket.6(%rip), %xmm5 + addsd .L_2il0floatpacket.1(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm1 + movl -16(%rsp), %esi + movl %esi, %eax + shll $26, %eax + subss .L_2il0floatpacket.2(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + sarl $26, %eax + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm7 + mulsd %xmm2, %xmm5 + addsd .L_2il0floatpacket.5(%rip), %xmm7 + addsd .L_2il0floatpacket.7(%rip), %xmm5 + mulsd %xmm2, %xmm7 + mulsd %xmm3, %xmm5 + addsd .L_2il0floatpacket.18(%rip), %xmm7 + movslq %eax, %rax + movaps %xmm7, %xmm0 + subl %eax, %esi + addsd %xmm5, %xmm0 + subsd %xmm5, %xmm7 + shrl $6, %esi + shll $23, %esi + shlq $3, %rax + lea 1056964608(%rsi), %ecx + negl %esi + addl $1056964608, %esi + orl %edx, %ecx + orl %esi, %edx + movl %edx, -20(%rsp) + movq __libm_expf_table_64@GOTPCREL(%rip), %rdx + movl %ecx, -24(%rsp) + cvtss2sd -24(%rsp), %xmm4 + cvtss2sd -20(%rsp), %xmm6 + mulsd 256(%rdx,%rax), %xmm0 + negq %rax + mulsd %xmm4, %xmm0 + mulsd 256(%rdx,%rax), %xmm7 + mulsd %xmm6, %xmm7 + subsd %xmm7, %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.14: + cmpl $1119016188, %eax + jbe ..B1.18 +..B1.15: + cmpl $2139095040, %eax + jb ..B1.19 +..B1.16: + movss -8(%rsp), %xmm0 + addss %xmm0, %xmm0 +..B1.17: + ret +..B1.18: + pxor %xmm3, %xmm3 + andl $-2147483648, %edx + cvtss2sd -8(%rsp), %xmm3 + andps .L_2il0floatpacket.17(%rip), %xmm3 + movsd .L_2il0floatpacket.0(%rip), %xmm0 + mulsd %xmm3, %xmm0 + movsd .L_2il0floatpacket.6(%rip), %xmm4 + movl $0, -24(%rsp) + addsd .L_2il0floatpacket.1(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm0 + movl -16(%rsp), %eax + movl %eax, %ecx + shll $26, %ecx + subss .L_2il0floatpacket.2(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + mulsd .L_2il0floatpacket.3(%rip), %xmm1 + sarl $26, %ecx + addsd %xmm1, %xmm3 + movaps %xmm3, %xmm2 + subl %ecx, %eax + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm4 + addsd .L_2il0floatpacket.5(%rip), %xmm0 + addsd .L_2il0floatpacket.7(%rip), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm3, %xmm4 + shrl $6, %eax + addsd %xmm4, %xmm0 + shll $20, %eax + addsd .L_2il0floatpacket.18(%rip), %xmm0 + addl $1071644672, %eax + movslq %ecx, %rcx + orl %eax, %edx + movl %edx, -20(%rsp) + movq __libm_expf_table_64@GOTPCREL(%rip), %rdx + mulsd 256(%rdx,%rcx,8), %xmm0 + mulsd -24(%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + ret +..B1.19: + lea _large_value_32(%rip), %rax + shrl $31, %edx + movss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.12(%rip), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type sinhf,@function + .size sinhf,.-sinhf + .data +# -- End sinhf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.17: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40571547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x41680000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.3: + .long 0xfefa39ef,0xbf862e42 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xeb78fa85,0x3fa56420 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x008d6118,0x3fe00000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xda752d4f,0x3fc55550 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0xffffe7c6,0x3fefffff + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x4bc96d7d,0x3ec749d8 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x326ed15a,0x3f811111 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0xd09557cf,0x3f2a0168 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x552ed1e2,0x3fc55555 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x1fc8e65a,0x3f8111c7 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0x4fa4d5d9,0x3fc55555 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 8 +.L_2il0floatpacket.18: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,8 + .align 4 +.L_2il0floatpacket.2: + .long 0x4b400000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.12: + .long 0x71800000 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,4 + .align 4 +.L_2il0floatpacket.15: + .long 0x0d800000 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,4 + .align 4 +.L_2il0floatpacket.16: + .long 0x3f800000 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sinhl.S b/external/sgx_libm/intel64/sinhl.S new file mode 100644 index 0000000000..5aa5fd95fd --- /dev/null +++ b/external/sgx_libm/intel64/sinhl.S @@ -0,0 +1,960 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinhl.c" + .text +..TXTST0: +# -- Begin sinhl + .text + .align 16,0x90 + .globl sinhl +sinhl: +# parameter 1: 96 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_sinhl.1: +..L2: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + xorb %cl, %cl +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movzwl 104(%rsp), %esi + andl $32767, %esi + cmpl $16396, %esi + jge ..B1.59 +..B1.4: + cmpl $16382, %esi + jge ..B1.46 +..B1.5: + movzwl 82(%rsp), %edx + cmpl $16378, %esi + jge ..B1.39 +..B1.6: + cmpl $16373, %esi + jge ..B1.32 +..B1.7: + cmpl $16366, %esi + jge ..B1.25 +..B1.8: + cmpl $16308, %esi + jge ..B1.18 +..B1.9: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.13 +..B1.10: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.11: + fldcw 80(%rsp) +..B1.12: + movzwl 104(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.13: + testl %esi, %esi + jle ..B1.70 +..B1.14: + fldt 96(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rdx + fldl (%rax) + fmul %st(1), %st + faddp %st, %st(1) + fmull (%rdx) + fstpt (%rsp) +..B1.15: + testb %cl, %cl + je ..B1.17 +..B1.16: + fldcw 82(%rsp) +..B1.17: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.18: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.22 +..B1.19: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.20: + fldcw 80(%rsp) +..B1.21: + movb $1, %cl +..B1.22: + fldt 96(%rsp) + lea _Q3(%rip), %rax + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 82(%rsp) +..B1.24: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.25: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.26: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.27: + fldcw 80(%rsp) +..B1.28: + movb $1, %cl +..B1.29: + fldt 96(%rsp) + lea 16+_Q2(%rip), %rax + fld %st(0) + lea _Q2(%rip), %rdx + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.31 +..B1.30: + fldcw 82(%rsp) +..B1.31: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.32: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.36 +..B1.33: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.34: + fldcw 80(%rsp) +..B1.35: + movb $1, %cl +..B1.36: + fldt 96(%rsp) + lea 48+_Q1(%rip), %rax + fld %st(0) + lea 32+_Q1(%rip), %rsi + fmul %st(1), %st + lea 16+_Q1(%rip), %rdx + fld %st(0) + lea _Q1(%rip), %rdi + fmul %st(1), %st + testb %cl, %cl + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.38 +..B1.37: + fldcw 82(%rsp) +..B1.38: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.39: + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.43 +..B1.40: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.41: + fldcw 80(%rsp) +..B1.42: + movb $1, %cl +..B1.43: + fldt 96(%rsp) + lea _TWO_48H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea 112+_Q(%rip), %rsi + fmul %st(3), %st + lea 80+_Q(%rip), %rdi + fld %st(0) + lea 48+_Q(%rip), %r8 + fmul %st(1), %st + lea 16+_Q(%rip), %r9 + fldl (%rax) + lea 96+_Q(%rip), %r10 + lea 64+_Q(%rip), %r11 + lea 32+_Q(%rip), %rax + lea 128+_Q(%rip), %rdx + testb %cl, %cl + fadd %st, %st(4) + fxch %st(4) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(4) + fld %st(3) + fxch %st(3) + fsub %st(4), %st + fmul %st, %st(3) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(3) + fxch %st(4) + fstpt 48(%rsp) + fxch %st(2) + fstpt 32(%rsp) + fldt 32(%rsp) + fmul %st(0), %st + fldt (%rdx) + lea _Q(%rip), %rdx + fmul %st, %st(2) + fmulp %st, %st(1) + fldt (%rsi) + fmul %st(4), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(4), %st + fldt (%r10) + fmul %st(5), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(5) + fldt (%rdx) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 48(%rsp) + fld %st(0) + fmul %st(3), %st + fldt 96(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldt 32(%rsp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.45 +..B1.44: + fldt 16(%rsp) + fstpt 32(%rsp) +..B1.84: + fldcw 82(%rsp) +..B1.45: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.46: + movzwl 82(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.50 +..B1.47: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.48: + fldcw 80(%rsp) +..B1.49: + movb $1, %cl +..B1.50: + fldt 96(%rsp) + lea ones(%rip), %rax + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %rdi + fldt .L_2il0floatpacket.1(%rip) + lea _TWO_32(%rip), %r8 + fldt .L_2il0floatpacket.2(%rip) + lea _TWO_32P(%rip), %r9 + movb 105(%rsp), %dl + lea 64+_P(%rip), %r10 + fldl (%rdi) + andb $-128, %dl + fldl (%r8) + lea 32+_P(%rip), %r11 + shrb $7, %dl + lea 48+_P(%rip), %rdi + fstl 16(%rsp) + movzbl %dl, %esi + lea 16+_P(%rip), %r8 + fldl (%rax,%rsi,8) + lea _P(%rip), %rsi + fmul %st, %st(6) + fxch %st(5) + fmul %st(6), %st + fadd %st(2), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fsubp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fmulp %st, %st(2) + fxch %st(4) + fstpt 96(%rsp) + fldt 96(%rsp) + fsubp %st, %st(2) + fld %st(1) + movl 32(%rsp), %edx + fsub %st(1), %st + movsbq %dl, %rax + subl %eax, %edx + shrl $8, %edx + fxch %st(3) + fstpt 64(%rsp) + fldt 64(%rsp) + fldl (%r9) + fmul %st(4), %st + fxch %st(5) + fmulp %st, %st(4) + movzwl 104(%rsp), %r9d + fxch %st(3) + fsubrp %st, %st(4) + fld %st(3) + andl $32767, %r9d + cmpl $16387, %r9d + fxch %st(2) + fsub %st(4), %st + fsubp %st, %st(1) + fadd %st, %st(1) + fld %st(1) + fmul %st(2), %st + fldt (%r10) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rdi) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + jle ..B1.54 +..B1.51: + addl $16350, %edx + faddp %st, %st(1) + movzwl 72(%rsp), %esi + andl $32767, %edx + andl $-32768, %esi + shlq $4, %rax + orl %edx, %esi + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + testb %cl, %cl + movw %si, 72(%rsp) + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + fld %st(0) + fmul %st(3), %st + fxch %st(3) + fadd %st(5), %st + fmul %st(2), %st + faddp %st, %st(3) + fmul %st, %st(4) + fld %st(0) + fadd %st(5), %st + fsubr %st, %st(1) + fxch %st(5) + faddp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(1) + fldt 64(%rsp) + fmul %st, %st(3) + fmulp %st, %st(1) + fldl 16(%rsp) + fmul %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + je ..B1.86 +..B1.52: + fstpt 48(%rsp) +..B1.85: + fldcw 82(%rsp) + jmp ..B1.53 +..B1.86: + fstp %st(0) +..B1.53: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.54: + je ..B1.74 +..B1.55: + fxch %st(2) + fstpt 48(%rsp) +..B1.56: + movzwl 56(%rsp), %r8d + lea 16382(%rdx), %esi + negl %edx + andl $-32768, %r8d + addl $16382, %edx + fld %st(0) + andl $32767, %edx + andl $32767, %esi + shlq $4, %rax + orl %edx, %r8d + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + fadd %st(2), %st + fxch %st(2) + fsubrp %st, %st(1) + fld %st(2) + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + negq %rax + fstpt 16(%rsp) + fldt 16(%rsp) + movzwl 72(%rsp), %edi + fadd %st(1), %st + fmulp %st, %st(4) + fld %st(4) + fmul %st(1), %st + andl $-32768, %edi + faddp %st, %st(4) + fldl 2056(%rdx,%rax) + orl %esi, %edi + fldl 2048(%rdx,%rax) + testb %cl, %cl + fld %st(0) + movw %di, 72(%rsp) + fadd %st(2), %st + fmulp %st, %st(5) + fld %st(6) + fmul %st(2), %st + movw %r8w, 56(%rsp) + fsubrp %st, %st(5) + fxch %st(4) + fstpt 32(%rsp) + fxch %st(3) + fmul %st, %st(5) + fldt 16(%rsp) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fsub %st(5), %st + fsubr %st, %st(4) + fxch %st(5) + fsubrp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 32(%rsp) + faddp %st, %st(2) + fldt 64(%rsp) + fmul %st, %st(1) + fld %st(1) + fxch %st(4) + fmulp %st, %st(1) + fldt 48(%rsp) + fmul %st, %st(5) + fxch %st(4) + fsub %st(5), %st + fsubr %st, %st(2) + fxch %st(5) + fsubrp %st, %st(2) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + fsubrp %st, %st(2) + faddp %st, %st(1) + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.58 +..B1.57: + fldcw 82(%rsp) +..B1.58: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.59: + je ..B1.79 +..B1.60: + movzwl 82(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.64 +..B1.61: + orl $-64768, %edx + movw %dx, 80(%rsp) +..B1.62: + fldcw 80(%rsp) +..B1.63: + movzwl 104(%rsp), %esi + movb $1, %cl + andl $32767, %esi +..B1.64: + cmpl $32767, %esi + jne ..B1.66 +..B1.65: + fldt 96(%rsp) + fstpt (%rsp) + jmp ..B1.67 +..B1.66: + movb 105(%rsp), %al + lea _large_value_80(%rip), %rsi + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %edx + shlq $4, %rdx + fldt (%rsi,%rdx) + fmulp %st, %st(1) + fstpt (%rsp) +..B1.67: + testb %cl, %cl + je ..B1.69 +..B1.68: + fldcw 82(%rsp) +..B1.69: + fldt (%rsp) + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 +..B1.70: + cmpl $0, 100(%rsp) + jne ..B1.72 +..B1.71: + cmpl $0, 96(%rsp) + je ..B1.73 +..B1.72: + fldt 96(%rsp) + lea _small_value_80(%rip), %rsi + movb 105(%rsp), %al + andb $-128, %al + shrb $7, %al + fldt (%rsi) + movzbl %al, %edx + shlq $4, %rdx + fldt (%rsi,%rdx) + fmulp %st, %st(1) + fstpt 32(%rsp) + fldt 32(%rsp) + faddp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.73: + fldt 96(%rsp) + fstpt (%rsp) + jmp ..B1.15 +..B1.74: + movl 100(%rsp), %esi + cmpl $-782985146, %esi + ja ..B1.51 +..B1.75: + jne ..B1.55 +..B1.76: + cmpl $1501741449, 96(%rsp) + ja ..B1.51 + jmp ..B1.55 +..B1.79: + movl 100(%rsp), %eax + cmpl $-1317741120, %eax + jb ..B1.4 +..B1.80: + jne ..B1.60 +..B1.81: + cmpl $833536233, 96(%rsp) + jbe ..B1.4 + jmp ..B1.60 + .align 16,0x90 + .cfi_endproc + .type sinhl,@function + .size sinhl,.-sinhl + .data +# -- End sinhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 2 +_Q3: + .word 21845 + .word 44373 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 29491 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 1838 + .word 3745 + .word 35050 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 56472 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 6470 + .word 8609 + .word 207 + .word 53261 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 51515 + .word 9159 + .word 10794 + .word 47344 + .word 16364 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 43620 + .word 43690 + .word 43690 + .word 43690 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 52382 + .word 3328 + .word 208 + .word 53261 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 44665 + .word 46658 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 15678 + .word 35942 + .word 11071 + .word 55090 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 10412 + .word 23121 + .word 12507 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 37213 + .word 41879 + .word 65084 + .word 55102 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 1721 + .word 42148 + .word 19309 + .word 52099 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,144 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sinl.S b/external/sgx_libm/intel64/sinl.S new file mode 100644 index 0000000000..eb9b79a4a8 --- /dev/null +++ b/external/sgx_libm/intel64/sinl.S @@ -0,0 +1,1048 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sinl.c" + .text +..TXTST0: +# -- Begin sinl + .text + .align 16,0x90 + .globl sinl +sinl: +# parameter 1: 192 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_sinl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + pushq %rbp + .cfi_def_cfa_offset 32 + .cfi_offset 6, -32 + subq $160, %rsp + .cfi_def_cfa_offset 192 + xorb %r12b, %r12b + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 152(%rsp) +..B1.2: + fnstcw 130(%rsp) +..B1.3: + movzwl 200(%rsp), %edx + andl $32767, %edx + movzwl 130(%rsp), %ecx + cmpl $32767, %edx + je ..B1.70 +..B1.4: + cmpl $16378, %edx + jge ..B1.42 +..B1.5: + cmpl $16372, %edx + jge ..B1.34 +..B1.6: + cmpl $16364, %edx + jge ..B1.26 +..B1.7: + cmpl $16308, %edx + jge ..B1.18 +..B1.8: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.12 +..B1.9: + orl $-64768, %ecx + movw %cx, 128(%rsp) +..B1.10: + fldcw 128(%rsp) +..B1.11: + movzwl 200(%rsp), %edx + movb $1, %r12b + andl $32767, %edx +..B1.12: + testl %edx, %edx + jle ..B1.59 +..B1.13: + fldt 192(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rdx + fldl (%rax) + fmul %st(1), %st + fsubp %st, %st(1) + fmull (%rdx) + fstpt 16(%rsp) +..B1.14: + testb %r12b, %r12b + je ..B1.16 +..B1.15: + fldcw 130(%rsp) +..B1.16: + movq 152(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.17: + fldt 16(%rsp) + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 12, -16 +..B1.18: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.22 +..B1.19: + orl $-64768, %ecx + movw %cx, 128(%rsp) +..B1.20: + fldcw 128(%rsp) +..B1.21: + movb $1, %r12b +..B1.22: + fldt 192(%rsp) + lea _SP3(%rip), %rax + testb %r12b, %r12b + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.24 +..B1.23: + fldcw 130(%rsp) +..B1.24: + movq 152(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.25: + fldt 16(%rsp) + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 12, -16 +..B1.26: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.30 +..B1.27: + orl $-64768, %ecx + movw %cx, 128(%rsp) +..B1.28: + fldcw 128(%rsp) +..B1.29: + movb $1, %r12b +..B1.30: + fldt 192(%rsp) + lea 16+_SP2(%rip), %rax + fld %st(0) + lea _SP2(%rip), %rdx + fmul %st(1), %st + testb %r12b, %r12b + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.32 +..B1.31: + fldcw 130(%rsp) +..B1.32: + movq 152(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.33: + fldt 16(%rsp) + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 12, -16 +..B1.34: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.38 +..B1.35: + orl $-64768, %ecx + movw %cx, 128(%rsp) +..B1.36: + fldcw 128(%rsp) +..B1.37: + movb $1, %r12b +..B1.38: + fldt 192(%rsp) + lea 48+_SP1(%rip), %rax + fld %st(0) + lea 32+_SP1(%rip), %rcx + fmul %st(1), %st + lea 16+_SP1(%rip), %rdx + fld %st(0) + lea _SP1(%rip), %rbx + fmul %st(1), %st + testb %r12b, %r12b + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + fmulp %st, %st(2) + fldt (%rbx) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.40 +..B1.39: + fldcw 130(%rsp) +..B1.40: + movq 152(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.41: + fldt 16(%rsp) + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 12, -16 +..B1.42: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.46 +..B1.43: + orl $-64768, %ecx + movw %cx, 128(%rsp) +..B1.44: + fldcw 128(%rsp) +..B1.45: + movzwl 200(%rsp), %edx + movb $1, %r12b + andl $32767, %edx +..B1.46: + cmpl $16382, %edx + jge ..B1.48 +..B1.47: + fldt 192(%rsp) + xorl %ecx, %ecx + movb 201(%rsp), %bpl + lea _TWO_52H(%rip), %rdx + andb $-128, %bpl + shrb $7, %bpl + fldl (%rdx) + movzbl %bpl, %eax + lea _ones(%rip), %rbp + fldl (%rbp,%rax,8) + fmul %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fxch %st(1) + fstpt 16(%rsp) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(1) + fld %st(0) + fsubr %st(2), %st + fxch %st(2) + fstpt 192(%rsp) + fldt 192(%rsp) + jmp ..B1.51 +..B1.48: + je ..B1.67 +..B1.49: + fldt 192(%rsp) + lea _ones(%rip), %rbp + movzbl 201(%rsp), %ebx + xorl %edi, %edi + andl $128, %ebx + shrl $7, %ebx + fmull (%rbp,%rbx,8) + fstpt 192(%rsp) + fldt 192(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 208 + lea 152(%rsp), %rsi + fstpt (%rsp) +..___tag_value_sinl.55: + call __libm_reduce_pi04l@PLT +..___tag_value_sinl.56: +..B1.85: + movl %eax, %ecx + addq $16, %rsp + .cfi_def_cfa_offset 192 +..B1.50: + fldl 136(%rsp) + lea 1(%rcx), %eax + lea _TWO_52H(%rip), %rdx + fld %st(0) + movsd 136(%rsp), %xmm0 + shrl $2, %eax + xorl %eax, %ebx + mulsd (%rdx), %xmm0 + andl $1, %ebx + fldl (%rbp,%rbx,8) + movsd %xmm0, 32(%rsp) + fstpt 16(%rsp) + fldl 32(%rsp) + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(1) + fldl 144(%rsp) + faddp %st, %st(2) + fld %st(0) + fadd %st(2), %st +..B1.51: + fld %st(1) + lea _TWO_53H(%rip), %rax + fmul %st(3), %st + fld %st(3) + fmul %st(2), %st + incl %ecx + faddp %st, %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fld %st(2) + fmul %st(3), %st + testb $2, %cl + fld %st(0) + fadd %st(2), %st + fstpt 80(%rsp) + fldt 80(%rsp) + fld %st(1) + fmul %st(3), %st + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fmul %st(0), %st + fld %st(0) + faddp %st, %st(2) + fldl (%rax) + fstpt 48(%rsp) + je ..B1.53 +..B1.52: + fstp %st(2) + fstp %st(2) + fstp %st(2) + lea 128+_CP(%rip), %rsi + lea 112+_CP(%rip), %rax + lea 96+_CP(%rip), %rdi + lea 80+_CP(%rip), %rdx + lea 64+_CP(%rip), %r8 + lea 48+_CP(%rip), %rcx + lea 32+_CP(%rip), %r9 + lea 16+_CP(%rip), %rbx + fldt (%rax) + lea _CP(%rip), %r10 + lea 160+_CP(%rip), %r11 + lea 144+_CP(%rip), %rax + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rbx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rsi) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r10) + faddp %st, %st(2) + fldt 80(%rsp) + fmulp %st, %st(2) + faddp %st, %st(1) + fldt 96(%rsp) + fldt 64(%rsp) + fldt 112(%rsp) + fldt 48(%rsp) + fldt (%r11) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fxch %st(3) + fmulp %st, %st(5) + fldt (%rax) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(5) + fld %st(4) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fadd %st(2), %st + fmul %st, %st(1) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldl (%rbp) + fadd %st, %st(1) + fsub %st(1), %st + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 16(%rsp) + fmul %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fstpt 32(%rsp) + jmp ..B1.54 +..B1.53: + lea 112+_SP(%rip), %rax + lea 80+_SP(%rip), %rdx + lea 48+_SP(%rip), %rcx + lea 128+_SP(%rip), %rbp + lea 16+_SP(%rip), %rbx + lea 96+_SP(%rip), %rsi + lea 64+_SP(%rip), %rdi + lea 32+_SP(%rip), %r8 + fldt (%rax) + lea _SP(%rip), %r9 + lea 160+_SP(%rip), %r10 + lea 144+_SP(%rip), %r11 + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rbx) + faddp %st, %st(1) + fmul %st(2), %st + fldt (%rbp) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%r9) + faddp %st, %st(3) + fldt 80(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + fldt 96(%rsp) + fldt 64(%rsp) + fldt (%r10) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + fmulp %st, %st(2) + fldt (%r11) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldt 112(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fld %st(5) + fldt 48(%rsp) + fmul %st(2), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(3) + fmul %st(1), %st + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fldt 16(%rsp) + fmul %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 32(%rsp) +..B1.54: + testb %r12b, %r12b + je ..B1.56 +..B1.55: + fldcw 130(%rsp) +..B1.56: + movq 152(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.57: + fldt 32(%rsp) + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 192 + .cfi_offset 3, -24 + .cfi_offset 6, -32 + .cfi_offset 12, -16 +..B1.58: + call __stack_chk_fail@PLT +..B1.59: + cmpl $0, 196(%rsp) + jne ..B1.61 +..B1.60: + cmpl $0, 192(%rsp) + je ..B1.62 +..B1.61: + fldt 192(%rsp) + lea _TWO_75(%rip), %rbx + movb 201(%rsp), %al + lea _small_value_80(%rip), %rcx + andb $-128, %al + lea 8+_TWO_75(%rip), %rbp + shrb $7, %al + fldl (%rbx) + fmul %st(1), %st + fsubp %st, %st(1) + fldt (%rcx) + fxch %st(1) + fmull (%rbp) + movzbl %al, %edx + shlq $4, %rdx + fstpt 16(%rsp) + fldt (%rcx,%rdx) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.14 +..B1.62: + fldt 192(%rsp) + fstpt 16(%rsp) + jmp ..B1.14 +..B1.67: + movl 196(%rsp), %eax + cmpl $-921707870, %eax + jb ..B1.47 +..B1.68: + jne ..B1.49 +..B1.69: + cmpl $560513589, 192(%rsp) + jbe ..B1.47 + jmp ..B1.49 +..B1.70: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.74 +..B1.71: + orl $-64768, %ecx + movw %cx, 128(%rsp) +..B1.72: + fldcw 128(%rsp) +..B1.73: + movb $1, %r12b +..B1.74: + cmpl $-2147483648, 196(%rsp) + jne ..B1.77 +..B1.75: + cmpl $0, 192(%rsp) + jne ..B1.77 +..B1.76: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt 16(%rsp) + jmp ..B1.78 +..B1.77: + fldt 192(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) +..B1.78: + testb %r12b, %r12b + je ..B1.80 +..B1.79: + fldcw 130(%rsp) +..B1.80: + movq 152(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.58 +..B1.81: + fldt 16(%rsp) + addq $160, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 24 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type sinl,@function + .size sinl,.-sinl + .data +# -- End sinl + .section .rodata, "a" + .align 4 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 2 +_SP3: + .word 17476 + .word 43656 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _SP3,@object + .size _SP3,16 + .align 2 +_SP2: + .word 43210 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 1587 + .word 57422 + .word 34932 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP2,@object + .size _SP2,32 + .align 2 +_SP1: + .word 43690 + .word 43690 + .word 43690 + .word 43690 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 12518 + .word 34952 + .word 34952 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 43088 + .word 7396 + .word 207 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 55827 + .word 48618 + .word 3602 + .word 47342 + .word 16364 + .word 0 + .word 0 + .word 0 + .type _SP1,@object + .size _SP1,64 + .align 2 +_CP: + .word 51631 + .word 16464 + .word 16497 + .word 44012 + .word 16306 + .word 0 + .word 0 + .word 0 + .word 43685 + .word 43690 + .word 43690 + .word 43690 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 46557 + .word 2912 + .word 24758 + .word 46603 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 28380 + .word 3328 + .word 208 + .word 53261 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 23816 + .word 50302 + .word 32187 + .word 37874 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 49866 + .word 64527 + .word 51070 + .word 36726 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 65056 + .word 3638 + .word 41889 + .word 51659 + .word 49114 + .word 0 + .word 0 + .word 0 + .word 13834 + .word 11317 + .word 33607 + .word 55101 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 40709 + .word 42374 + .word 64411 + .word 45709 + .word 49098 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43008 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _CP,@object + .size _CP,176 + .align 2 +_SP: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 34948 + .word 34952 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 53243 + .word 3328 + .word 208 + .word 53261 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 30577 + .word 46649 + .word 7466 + .word 47343 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 11760 + .word 43464 + .word 11071 + .word 55090 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 47000 + .word 43232 + .word 12444 + .word 45202 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 52983 + .word 47009 + .word 40440 + .word 55103 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 35433 + .word 14927 + .word 40941 + .word 51860 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 1340 + .word 16361 + .word 50747 + .word 38523 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _SP,@object + .size _SP,176 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sqrt.S b/external/sgx_libm/intel64/sqrt.S new file mode 100644 index 0000000000..ca5b6693cf --- /dev/null +++ b/external/sgx_libm/intel64/sqrt.S @@ -0,0 +1,80 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrt.c" + .text +..TXTST0: +# -- Begin sqrt + .text + .align 16,0x90 + .globl sqrt +sqrt: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_sqrt.1: +..L2: + + pushq %rsi + .cfi_def_cfa_offset 16 +..B1.2: + movq %xmm0, %xmm2 + xorpd %xmm1, %xmm1 + sqrtsd %xmm0, %xmm0 + ucomisd %xmm1, %xmm2 + jae ..B1.5 + jp ..B1.5 + movq %xmm0, (%rsp) +..B1.3: + movq (%rsp), %xmm0 +.L_2TAG_PACKET_0.0.2: +..B1.5: + popq %rcx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type sqrt,@function + .size sqrt,.-sqrt + .data +# -- End sqrt + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sqrt_tab_t.S b/external/sgx_libm/intel64/sqrt_tab_t.S new file mode 100644 index 0000000000..64efaa5b42 --- /dev/null +++ b/external/sgx_libm/intel64/sqrt_tab_t.S @@ -0,0 +1,815 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrt_tab_t.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __sqrt_t_table +__sqrt_t_table: + .long 0x400672f9 + .long 0xc060f4f5 + .long 0xba659415,0x40052c06 + .long 0x4003de5a + .long 0xc05e5b2f + .long 0xfe66c797,0x4005170e + .long 0x40015b59 + .long 0xc05bce24 + .long 0x13b32f30,0x40050255 + .long 0x3ffdd2b8 + .long 0xc0594d7e + .long 0xdae79d26,0x4004edd7 + .long 0x3ff90fa1 + .long 0xc056d8e8 + .long 0x13220f7f,0x4004d996 + .long 0x3ff46c51 + .long 0xc0547012 + .long 0xb3fa6a49,0x4004c58e + .long 0x3fefe7bb + .long 0xc05212ae + .long 0xa20bcbc6,0x4004b1c0 + .long 0x3feb80db + .long 0xc04fc070 + .long 0xc76937e4,0x40049e2a + .long 0x3fe736b7 + .long 0xc04d790f + .long 0x1f93d776,0x40048acc + .long 0x3fe30860 + .long 0xc04b3c44 + .long 0xa15ae4b0,0x400477a3 + .long 0x3fdef4f0 + .long 0xc04909cc + .long 0x697f4726,0x400464b0 + .long 0x3fdafb8a + .long 0xc046e163 + .long 0x6403b289,0x400451f1 + .long 0x3fd71b59 + .long 0xc044c2ca + .long 0xb7aecc11,0x40043f65 + .long 0x3fd35392 + .long 0xc042adc3 + .long 0x76dd1156,0x40042d0c + .long 0x3fcfa371 + .long 0xc040a213 + .long 0xd01983f9,0x40041ae4 + .long 0x3fcc0a37 + .long 0xc03e9f7d + .long 0xbecf4a2b,0x400408ed + .long 0x3fc88730 + .long 0xc03ca5ca + .long 0x7b0eeed7,0x4003f726 + .long 0x3fc519ad + .long 0xc03ab4c5 + .long 0x50846ea3,0x4003e58e + .long 0x3fc1c105 + .long 0xc038cc36 + .long 0x3decb5a1,0x4003d424 + .long 0x3fbe7c97 + .long 0xc036ebed + .long 0xb2048812,0x4003c2e7 + .long 0x3fbb4bc6 + .long 0xc03513b5 + .long 0xb29c9700,0x4003b1d7 + .long 0x3fb82dfc + .long 0xc0334360 + .long 0xa89c0a0a,0x4003a0f3 + .long 0x3fb522a8 + .long 0xc0317abe + .long 0xc440fe15,0x4003903a + .long 0x3fb2293e + .long 0xc02fb9a2 + .long 0x596206ff,0x40037fac + .long 0x3faf4138 + .long 0xc02dffe0 + .long 0xb44972f3,0x40036f47 + .long 0x3fac6a14 + .long 0xc02c4d4c + .long 0x1107001d,0x40035f0c + .long 0x3fa9a354 + .long 0xc02aa1be + .long 0xe7c62025,0x40034ef8 + .long 0x3fa6ec80 + .long 0xc028fd0d + .long 0x815ec2da,0x40033f0d + .long 0x3fa44523 + .long 0xc0275f11 + .long 0x2e0b0c0e,0x40032f49 + .long 0x3fa1accc + .long 0xc025c7a5 + .long 0x66b9f8b6,0x40031fab + .long 0x3f9f230f + .long 0xc02436a3 + .long 0x788665c8,0x40031033 + .long 0x3f9ca783 + .long 0xc022abe8 + .long 0xded1e594,0x400300e0 + .long 0x3f9a39c2 + .long 0xc0212751 + .long 0x0842a075,0x4002f1b3 + .long 0x3f97d96b + .long 0xc01fa8bb + .long 0x494fbc25,0x4002e2a9 + .long 0x3f95861f + .long 0xc01e3006 + .long 0x2b018f07,0x4002d3c3 + .long 0x3f933f82 + .long 0xc01cbd11 + .long 0x142c8510,0x4002c500 + .long 0x3f91053c + .long 0xc01b4fbd + .long 0x7f1daa26,0x4002b65f + .long 0x3f8ed6f7 + .long 0xc019e7eb + .long 0xdda5e7e2,0x4002a7e0 + .long 0x3f8cb461 + .long 0xc018857f + .long 0xc9948908,0x40029983 + .long 0x3f8a9d2a + .long 0xc017285b + .long 0xaa59eeeb,0x40028b47 + .long 0x3f889104 + .long 0xc015d062 + .long 0xf2821162,0x40027d2b + .long 0x3f868fa5 + .long 0xc0147d7c + .long 0x669445ed,0x40026f30 + .long 0x3f8498c3 + .long 0xc0132f8a + .long 0x3b85fad8,0x40026154 + .long 0x3f82ac1a + .long 0xc011e676 + .long 0x3e988364,0x40025397 + .long 0x3f80c964 + .long 0xc010a224 + .long 0xcf7601fc,0x400245f8 + .long 0x3f7de0c1 + .long 0xc00f627e + .long 0xaab7acb5,0x40023878 + .long 0x3f7a419f + .long 0xc00e276a + .long 0x36aab17c,0x40022b16 + .long 0x3f76b4e6 + .long 0xc00cf0d1 + .long 0x0f2aa54c,0x40021dd1 + .long 0x3f733a1e + .long 0xc00bbe9d + .long 0xdacdcc1a,0x400210a8 + .long 0x3f6fd0d4 + .long 0xc00a90b8 + .long 0x30e54b08,0x4002039d + .long 0x3f6c7897 + .long 0xc009670b + .long 0x8e05e1b3,0x4001f6ad + .long 0x3f6930fa + .long 0xc0084182 + .long 0xa51b1d74,0x4001e9d9 + .long 0x3f65f994 + .long 0xc0072009 + .long 0x1cf6297b,0x4001dd21 + .long 0x3f62d1fe + .long 0xc006028b + .long 0x8103f9e2,0x4001d083 + .long 0x3f5fb9d5 + .long 0xc004e8f5 + .long 0x7cc51dba,0x4001c400 + .long 0x3f5cb0b7 + .long 0xc003d333 + .long 0xa3e7f161,0x4001b797 + .long 0x3f59b649 + .long 0xc002c134 + .long 0xb4f86544,0x4001ab48 + .long 0x3f56ca2e + .long 0xc001b2e5 + .long 0x4bc09f7e,0x40019f13 + .long 0x3f53ec0f + .long 0xc000a834 + .long 0x04a8d6a9,0x400192f7 + .long 0x3f511b96 + .long 0xbfff4221 + .long 0x9d5a7e63,0x400186f3 + .long 0x3f4e5870 + .long 0xbffd3ad2 + .long 0xb211c804,0x40017b08 + .long 0x3f4ba24c + .long 0xbffb3a5b + .long 0xfc173425,0x40016f35 + .long 0x3f48f8dc + .long 0xbff9409b + .long 0x1e599490,0x4001637b + .long 0x3f465bd5 + .long 0xbff74d73 + .long 0xc880b659,0x400157d7 + .long 0x3f43caeb + .long 0xbff560c5 + .long 0xbd156bcf,0x40014c4b + .long 0x3f4145d7 + .long 0xbff37a71 + .long 0x9283ab1d,0x400140d6 + .long 0x3f3ecc53 + .long 0xbff19a5c + .long 0x19073c6b,0x40013578 + .long 0x3f3c5e1c + .long 0xbfefc069 + .long 0xfd4a0663,0x40012a2f + .long 0x3f39faef + .long 0xbfedec7b + .long 0xede7b908,0x40011efd + .long 0x3f37a28c + .long 0xbfec1e78 + .long 0xb252b4d7,0x400113e1 + .long 0x3f3554b6 + .long 0xbfea5645 + .long 0xf9904832,0x400108da + .long 0x3f33112e + .long 0xbfe893c7 + .long 0x7e150822,0x4000fde9 + .long 0x3f30d7ba + .long 0xbfe6d6e5 + .long 0xfd1a5086,0x4000f30c + .long 0x3f2ea821 + .long 0xbfe51f87 + .long 0x3d632fc4,0x4000e845 + .long 0x3f2c822c + .long 0xbfe36d94 + .long 0xf11c7d33,0x4000dd91 + .long 0x3f2a65a2 + .long 0xbfe1c0f3 + .long 0xd61ea754,0x4000d2f2 + .long 0x3f285250 + .long 0xbfe0198f + .long 0xc0d51627,0x4000c867 + .long 0x3f264803 + .long 0xbfde7750 + .long 0x61244ec6,0x4000bdf0 + .long 0x3f244687 + .long 0xbfdcda1f + .long 0x7a6b2e99,0x4000b38c + .long 0x3f224dad + .long 0xbfdb41e7 + .long 0xd19f4764,0x4000a93b + .long 0x3f205d44 + .long 0xbfd9ae92 + .long 0x2ad2e77d,0x40009efe + .long 0x3f1e751f + .long 0xbfd8200d + .long 0x5dbcaf97,0x400094d3 + .long 0x3f1c9510 + .long 0xbfd69641 + .long 0x14b04d5e,0x40008abb + .long 0x3f1abcec + .long 0xbfd5111c + .long 0x2cda2e67,0x400080b5 + .long 0x3f18ec88 + .long 0xbfd3908a + .long 0x6ab42acc,0x400076c1 + .long 0x3f1723ba + .long 0xbfd21477 + .long 0x8e9d45e3,0x40006cdf + .long 0x3f156259 + .long 0xbfd09cd0 + .long 0x62171386,0x4000630f + .long 0x3f13a83e + .long 0xbfcf2984 + .long 0xbfb6fb6a,0x40005950 + .long 0x3f11f542 + .long 0xbfcdba80 + .long 0x68a7e5f7,0x40004fa3 + .long 0x3f104940 + .long 0xbfcc4fb3 + .long 0x2ef38d27,0x40004607 + .long 0x3f0ea414 + .long 0xbfcae90c + .long 0xe03435f5,0x40003c7b + .long 0x3f0d0598 + .long 0xbfc98678 + .long 0x3b99fee4,0x40003301 + .long 0x3f0b6dab + .long 0xbfc827e9 + .long 0x28d4ef26,0x40002997 + .long 0x3f09dc2b + .long 0xbfc6cd4e + .long 0x6d906b03,0x4000203d + .long 0x3f0850f6 + .long 0xbfc57696 + .long 0xd0880103,0x400016f3 + .long 0x3f06cbec + .long 0xbfc423b3 + .long 0x37509185,0x40000dba + .long 0x3f054cee + .long 0xbfc2d495 + .long 0x66ce8c53,0x40000490 + .long 0x3f03d3dc + .long 0xbfc1892d + .long 0x72279bc0,0x3ffff6ec + .long 0x3f026099 + .long 0xbfc0416c + .long 0xeda5cd81,0x3fffe4d6 + .long 0x3f00f308 + .long 0xbfbefd45 + .long 0x0c012834,0x3fffd2e0 + .long 0x3eff1616 + .long 0xbfbdbca8 + .long 0x52f75b3b,0x3fffc107 + .long 0x3efc510e + .long 0xbfbc7f88 + .long 0x799a7f94,0x3fffaf4c + .long 0x3ef996c2 + .long 0xbfbb45d9 + .long 0x55edcc30,0x3fff9daf + .long 0x3ef6e6fb + .long 0xbfba0f8b + .long 0x537eb099,0x3fff8c2f + .long 0x3ef44186 + .long 0xbfb8dc92 + .long 0x38cd722f,0x3fff7acc + .long 0x3ef1a631 + .long 0xbfb7ace2 + .long 0xc800858f,0x3fff6985 + .long 0x3eef14c9 + .long 0xbfb6806e + .long 0xaed5086e,0x3fff585b + .long 0x3eec8d1e + .long 0xbfb55729 + .long 0x88bfcc7e,0x3fff474d + .long 0x3eea0f02 + .long 0xbfb43109 + .long 0x3db0d3c5,0x3fff365b + .long 0x3ee79a45 + .long 0xbfb30e00 + .long 0x4f3507e4,0x3fff2584 + .long 0x3ee52ebb + .long 0xbfb1ee03 + .long 0x7dab64e4,0x3fff14c8 + .long 0x3ee2cc37 + .long 0xbfb0d107 + .long 0x9247f5f1,0x3fff0427 + .long 0x3ee0728f + .long 0xbfafb700 + .long 0x252987ab,0x3ffef3a1 + .long 0x3ede2198 + .long 0xbfae9fe4 + .long 0x12fb7286,0x3ffee335 + .long 0x3edbd929 + .long 0xbfad8ba8 + .long 0x0e1fbfd6,0x3ffed2e3 + .long 0x3ed9991a + .long 0xbfac7a41 + .long 0xc33c7a14,0x3ffec2aa + .long 0x3ed76144 + .long 0xbfab6ba5 + .long 0xf7968902,0x3ffeb28b + .long 0x3ed53180 + .long 0xbfaa5fca + .long 0x72271f31,0x3ffea286 + .long 0x3ed309a8 + .long 0xbfa956a6 + .long 0xf446dfa2,0x3ffe9299 + .long 0x3ed0e998 + .long 0xbfa8502f + .long 0x31fc7113,0x3ffe82c6 + .long 0x3eced12c + .long 0xbfa74c5a + .long 0xc17a77a1,0x3ffe730a + .long 0x3eccc040 + .long 0xbfa64b20 + .long 0xb683d568,0x3ffe6367 + .long 0x3ecab6b3 + .long 0xbfa54c76 + .long 0x93851ebf,0x3ffe53dc + .long 0x3ec8b462 + .long 0xbfa45054 + .long 0x48e8d2d8,0x3ffe4469 + .long 0x3ec6b92d + .long 0xbfa356b0 + .long 0x72ed724b,0x3ffe350d + .long 0x3ec4c4f3 + .long 0xbfa25f82 + .long 0xf5acec61,0x3ffe25c8 + .long 0x3ec2d795 + .long 0xbfa16ac0 + .long 0x67c5c2c3,0x3ffe169b + .long 0x3ec0f0f5 + .long 0xbfa07864 + .long 0xd8265439,0x3ffe0784 + .long 0x3fbe23c8 + .long 0xc01f118b + .long 0x1ec5a532,0x3ffdf113 + .long 0x3fba7d85 + .long 0xc01d3ac5 + .long 0x0000d4c8,0x3ffdd36c + .long 0x3fb6f02d + .long 0xc01b6d00 + .long 0x57cb9031,0x3ffdb61c + .long 0x3fb37ae5 + .long 0xc019a7fe + .long 0x72ed1c77,0x3ffd9922 + .long 0x3fb01cdd + .long 0xc017eb83 + .long 0x95b0b15c,0x3ffd7c7c + .long 0x3facd54f + .long 0xc0163758 + .long 0x6603fec1,0x3ffd6029 + .long 0x3fa9a37b + .long 0xc0148b45 + .long 0x469777ae,0x3ffd4427 + .long 0x3fa686a9 + .long 0xc012e714 + .long 0xa71adcce,0x3ffd2874 + .long 0x3fa37e28 + .long 0xc0114a91 + .long 0x0c38599d,0x3ffd0d10 + .long 0x3fa08950 + .long 0xc00fb58a + .long 0xfc8f14cb,0x3ffcf1f7 + .long 0x3f9da77d + .long 0xc00e27d0 + .long 0x5027d5b6,0x3ffcd72b + .long 0x3f9ad814 + .long 0xc00ca133 + .long 0x77f69e05,0x3ffcbca8 + .long 0x3f981a7f + .long 0xc00b2187 + .long 0x4e14c785,0x3ffca26e + .long 0x3f956e2d + .long 0xc009a89f + .long 0x67cdb787,0x3ffc887b + .long 0x3f92d292 + .long 0xc0083650 + .long 0x7d1a45e5,0x3ffc6ece + .long 0x3f90472b + .long 0xc006ca73 + .long 0x887296e4,0x3ffc5566 + .long 0x3f8dcb76 + .long 0xc00564de + .long 0x1b6717e3,0x3ffc3c42 + .long 0x3f8b5ef7 + .long 0xc004056b + .long 0x264323b8,0x3ffc2360 + .long 0x3f890138 + .long 0xc002abf5 + .long 0x8c0c1853,0x3ffc0abf + .long 0x3f86b1c6 + .long 0xc0015858 + .long 0x4069b804,0x3ffbf25f + .long 0x3f847032 + .long 0xc0000a6f + .long 0xf2c0f56b,0x3ffbda3d + .long 0x3f823c13 + .long 0xbffd8435 + .long 0xe82b41be,0x3ffbc25a + .long 0x3f801501 + .long 0xbffafe6e + .long 0xd0c8f1c2,0x3ffbaab4 + .long 0x3f7bf536 + .long 0xbff8834b + .long 0xc1a3163f,0x3ffb934a + .long 0x3f77d900 + .long 0xbff6128d + .long 0xc6e21d7e,0x3ffb7c1b + .long 0x3f73d4ab + .long 0xbff3abf8 + .long 0xe60015a5,0x3ffb6526 + .long 0x3f6fe784 + .long 0xbff14f50 + .long 0x21cbd876,0x3ffb4e6b + .long 0x3f6c10e1 + .long 0xbfeefc5d + .long 0x9ee07b4c,0x3ffb37e7 + .long 0x3f68501d + .long 0xbfecb2e7 + .long 0x6d2d48b6,0x3ffb219b + .long 0x3f64a499 + .long 0xbfea72b8 + .long 0xa81c9b61,0x3ffb0b85 + .long 0x3f610dbb + .long 0xbfe83b9d + .long 0x902fdc83,0x3ffaf5a5 + .long 0x3f5d8aee + .long 0xbfe60d61 + .long 0x27f22c44,0x3ffadffa + .long 0x3f5a1ba3 + .long 0xbfe3e7d3 + .long 0xa3884d02,0x3ffaca82 + .long 0x3f56bf51 + .long 0xbfe1cac5 + .long 0x554d369e,0x3ffab53e + .long 0x3f537570 + .long 0xbfdfb606 + .long 0x5450035a,0x3ffaa02c + .long 0x3f503d7f + .long 0xbfdda969 + .long 0xe28ff013,0x3ffa8b4b + .long 0x3f4d1702 + .long 0xbfdba4c2 + .long 0x3ccf3bef,0x3ffa769c + .long 0x3f4a017f + .long 0xbfd9a7e6 + .long 0xadd0d7d8,0x3ffa621c + .long 0x3f46fc82 + .long 0xbfd7b2ab + .long 0x73a23063,0x3ffa4dcc + .long 0x3f440799 + .long 0xbfd5c4e8 + .long 0xd9b8e6fd,0x3ffa39aa + .long 0x3f412258 + .long 0xbfd3de77 + .long 0x47a99575,0x3ffa25b7 + .long 0x3f3e4c53 + .long 0xbfd1ff2e + .long 0xd6d4c329,0x3ffa11f0 + .long 0x3f3b8525 + .long 0xbfd026eb + .long 0x1e725d64,0x3ff9fe57 + .long 0x3f38cc6a + .long 0xbfce5587 + .long 0x4a856a92,0x3ff9eae9 + .long 0x3f3621c3 + .long 0xbfcc8ae0 + .long 0xd3534a3f,0x3ff9d7a6 + .long 0x3f3384d1 + .long 0xbfcac6d1 + .long 0xf6170fe5,0x3ff9c48e + .long 0x3f30f53c + .long 0xbfc9093b + .long 0x43d296cd,0x3ff9b1a1 + .long 0x3f2e72ac + .long 0xbfc751fb + .long 0xfbbf8768,0x3ff99edc + .long 0x3f2bfccb + .long 0xbfc5a0f2 + .long 0xaa7c60ad,0x3ff98c41 + .long 0x3f299349 + .long 0xbfc3f600 + .long 0x9e5e0c30,0x3ff979ce + .long 0x3f2735d5 + .long 0xbfc25106 + .long 0x47a967c7,0x3ff96783 + .long 0x3f24e423 + .long 0xbfc0b1e7 + .long 0x213a91b3,0x3ff9555f + .long 0x3f229de8 + .long 0xbfbf1887 + .long 0xb92f1e71,0x3ff94361 + .long 0x3f2062db + .long 0xbfbd84c7 + .long 0x4e9fbb55,0x3ff9318a + .long 0x3f1e32b7 + .long 0xbfbbf68e + .long 0x8c3e135d,0x3ff91fd8 + .long 0x3f1c0d36 + .long 0xbfba6dc0 + .long 0xe5486399,0x3ff90e4b + .long 0x3f19f217 + .long 0xbfb8ea42 + .long 0xbecd10bc,0x3ff8fce3 + .long 0x3f17e11a + .long 0xbfb76bfc + .long 0xbe525978,0x3ff8eb9f + .long 0x3f15d9ff + .long 0xbfb5f2d3 + .long 0x48293568,0x3ff8da7f + .long 0x3f13dc8c + .long 0xbfb47eb1 + .long 0x05d5e650,0x3ff8c982 + .long 0x3f11e884 + .long 0xbfb30f7c + .long 0x60ba5dac,0x3ff8b8a7 + .long 0x3f0ffdb0 + .long 0xbfb1a51e + .long 0xefd22e82,0x3ff8a7ee + .long 0x3f0e1bd7 + .long 0xbfb03f80 + .long 0x47805b92,0x3ff89758 + .long 0x3f0c42c3 + .long 0xbfaede8a + .long 0xcd57cc04,0x3ff886e2 + .long 0x3f0a7241 + .long 0xbfad8229 + .long 0x46b3d0d8,0x3ff8768e + .long 0x3f08aa1e + .long 0xbfac2a48 + .long 0x4cc7ad59,0x3ff8665a + .long 0x3f06ea27 + .long 0xbfaad6cf + .long 0x3347fcf1,0x3ff85646 + .long 0x3f05322e + .long 0xbfa987ad + .long 0xcc7c68cf,0x3ff84651 + .long 0x3f038204 + .long 0xbfa83ccd + .long 0x95d48bda,0x3ff8367c + .long 0x3f01d97a + .long 0xbfa6f61c + .long 0x40b0d774,0x3ff826c6 + .long 0x3f003866 + .long 0xbfa5b387 + .long 0x521e69ab,0x3ff8172e + .long 0x3efd3d38 + .long 0xbfa474fb + .long 0x64a31380,0x3ff807b4 + .long 0x3efa17e4 + .long 0xbfa33a67 + .long 0x344463f5,0x3ff7f858 + .long 0x3ef70080 + .long 0xbfa203b9 + .long 0x536e309d,0x3ff7e919 + .long 0x3ef3f6bd + .long 0xbfa0d0df + .long 0x51d9db7f,0x3ff7d9f7 + .long 0x3ef0fa4e + .long 0xbf9fa1ca + .long 0x03bdd024,0x3ff7caf2 + .long 0x3eee0ae8 + .long 0xbf9e7667 + .long 0xd06a95a6,0x3ff7bc08 + .long 0x3eeb2842 + .long 0xbf9d4ea8 + .long 0x96a621bf,0x3ff7ad3b + .long 0x3ee85215 + .long 0xbf9c2a7d + .long 0xfac56bba,0x3ff79e89 + .long 0x3ee5881d + .long 0xbf9b09d5 + .long 0x79c2bb58,0x3ff78ff3 + .long 0x3ee2ca16 + .long 0xbf99eca3 + .long 0xfa3e419f,0x3ff78177 + .long 0x3ee017bf + .long 0xbf98d2d7 + .long 0x07c1acb7,0x3ff77317 + .long 0x3edd70d7 + .long 0xbf97bc62 + .long 0x49bbc9e6,0x3ff764d0 + .long 0x3edad522 + .long 0xbf96a937 + .long 0x8367baca,0x3ff756a3 + .long 0x3ed84462 + .long 0xbf959948 + .long 0x6acc6906,0x3ff74890 + .long 0x3ed5be5d + .long 0xbf948c88 + .long 0xbcc0ac8a,0x3ff73a96 + .long 0x3ed342d8 + .long 0xbf9382e7 + .long 0xed77fbb2,0x3ff72cb5 + .long 0x3ed0d19d + .long 0xbf927c5c + .long 0x1262b283,0x3ff71eee + .long 0x3ece6a74 + .long 0xbf9178d7 + .long 0x928b4839,0x3ff7113e + .long 0x3ecc0d29 + .long 0xbf90784d + .long 0x46765494,0x3ff703a7 + .long 0x3ec9b988 + .long 0xbf8f7ab1 + .long 0xd271890f,0x3ff6f627 + .long 0x3ec76f5d + .long 0xbf8e7ff8 + .long 0x1330f37e,0x3ff6e8c0 + .long 0x3ec52e79 + .long 0xbf8d8817 + .long 0xca5f6659,0x3ff6db6f + .long 0x3ec2f6aa + .long 0xbf8c9300 + .long 0x7a3c2c24,0x3ff6ce36 + .long 0x3ec0c7c2 + .long 0xbf8ba0aa + .long 0x18d80162,0x3ff6c114 + .long 0x3ebea193 + .long 0xbf8ab109 + .long 0x4b1eb26b,0x3ff6b408 + .long 0x3ebc83f0 + .long 0xbf89c412 + .long 0xcd29fcba,0x3ff6a712 + .long 0x3eba6eaf + .long 0xbf88d9bb + .long 0x664b0f09,0x3ff69a33 + .long 0x3eb861a4 + .long 0xbf87f1f9 + .long 0xcfa00fd5,0x3ff68d69 + .long 0x3eb65ca6 + .long 0xbf870cc3 + .long 0xe9d2a6b3,0x3ff680b5 + .long 0x3eb45f8c + .long 0xbf862a0e + .long 0x5e7a0e0b,0x3ff67417 + .long 0x3eb26a30 + .long 0xbf8549d1 + .long 0xfe6852bf,0x3ff6678d + .long 0x3eb07c6a + .long 0xbf846c01 + .long 0x6f577b40,0x3ff65b19 + .long 0x3eae9616 + .long 0xbf839096 + .long 0x94beacb4,0x3ff64eb9 + .long 0x3eacb70d + .long 0xbf82b786 + .long 0x2d87a5b4,0x3ff6426e + .long 0x3eaadf2d + .long 0xbf81e0c9 + .long 0x133eca3a,0x3ff63637 + .long 0x3ea90e52 + .long 0xbf810c55 + .long 0xf3b8ca64,0x3ff62a13 + .long 0x3ea74459 + .long 0xbf803a22 + .long 0xb1e928a1,0x3ff61e04 + .long 0x3ea58123 + .long 0xbf7ed44e + .long 0xf9c12cea,0x3ff61208 + .long 0x3ea3c48d + .long 0xbf7d38b8 + .long 0xb0f105b4,0x3ff60620 + .long 0x3ea20e79 + .long 0xbf7ba172 + .long 0x9c747236,0x3ff5fa4b + .long 0x3ea05ec6 + .long 0xbf7a0e6a + .long 0x79454bb5,0x3ff5ee89 + .long 0x3e9eb556 + .long 0xbf787f92 + .long 0x2c804088,0x3ff5e2da + .long 0x3e9d120c + .long 0xbf76f4d9 + .long 0x686ac26d,0x3ff5d73d + .long 0x3e9b74ca + .long 0xbf756e31 + .long 0x1493b001,0x3ff5cbb3 + .long 0x3e99dd75 + .long 0xbf73eb8c + .long 0x048406f4,0x3ff5c03b + .long 0x3e984bef + .long 0xbf726cd9 + .long 0xf4dbeebe,0x3ff5b4d4 + .long 0x3e96c01f + .long 0xbf70f20b + .long 0xbbe3f38a,0x3ff5a980 + .long 0x3e9539e9 + .long 0xbf6f7b14 + .long 0x37ac4b0e,0x3ff59e3e + .long 0x3e93b933 + .long 0xbf6e07e5 + .long 0x294f0c16,0x3ff5930d + .long 0x3e923de4 + .long 0xbf6c9870 + .long 0x5aaed17d,0x3ff587ed + .long 0x3e90c7e3 + .long 0xbf6b2caa + .long 0xc550e64d,0x3ff57cde + .long 0x3e8f5718 + .long 0xbf69c484 + .long 0x1e1a64d6,0x3ff571e1 + .long 0x3e8deb6b + .long 0xbf685ff2 + .long 0x4990847b,0x3ff566f4 + .long 0x3e8c84c4 + .long 0xbf66fee6 + .long 0x0dee1cfa,0x3ff55c18 + .long 0x3e8b230e + .long 0xbf65a155 + .long 0x4a4098f7,0x3ff5514c + .long 0x3e89c631 + .long 0xbf644732 + .long 0xd65fdb98,0x3ff54690 + .long 0x3e886e18 + .long 0xbf62f072 + .long 0x9358f9fc,0x3ff53be5 + .type __sqrt_t_table,@object + .size __sqrt_t_table,4096 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/sqrtf_gen.S b/external/sgx_libm/intel64/sqrtf_gen.S new file mode 100644 index 0000000000..317421b256 --- /dev/null +++ b/external/sgx_libm/intel64/sqrtf_gen.S @@ -0,0 +1,93 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrtf_gen.c" + .text +..TXTST0: +# -- Begin sqrtf + .text + .align 16,0x90 + .globl sqrtf +sqrtf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_sqrtf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + movss %xmm0, 8(%rsp) +..B1.2: + testb $128, 11(%rsp) + jne .L_2TAG_PACKET_0.0.2 + sqrtss %xmm0, %xmm0 +.L_2TAG_PACKET_1.0.2: + jmp ..B1.5 +.L_2TAG_PACKET_0.0.2: + ucomiss 4+zeros(%rip), %xmm0 + sqrtss %xmm0, %xmm0 + jp .L_2TAG_PACKET_1.0.2 + je .L_2TAG_PACKET_1.0.2 + movss %xmm0, (%rsp) +..B1.3: + movss (%rsp), %xmm0 +.L_2TAG_PACKET_2.0.2: +..B1.5: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type sqrtf,@function + .size sqrtf,.-sqrtf + .data +# -- End sqrtf + .section .rodata, "a" + .align 16 + .align 16 +zeros: + .long 0 + .long 2147483648 + .type zeros,@object + .size zeros,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/sqrtl.S b/external/sgx_libm/intel64/sqrtl.S new file mode 100644 index 0000000000..2d105b0cee --- /dev/null +++ b/external/sgx_libm/intel64/sqrtl.S @@ -0,0 +1,211 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "sqrtl.c" + .text +..TXTST0: +# -- Begin sqrtl + .text + .align 16,0x90 + .globl sqrtl +sqrtl: +# parameter 1: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_sqrtl.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + xorb %cl, %cl + fldt 64(%rsp) + fstpt 32(%rsp) +..B1.2: + fnstcw 10(%rsp) +..B1.3: + movzwl 72(%rsp), %eax + andl $32767, %eax + cmpl $32767, %eax + je ..B1.23 +..B1.4: + testb $-128, 73(%rsp) + jne ..B1.13 +..B1.5: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.7: + fldcw 8(%rsp) +..B1.8: + movb $1, %cl +..B1.9: + fldt 32(%rsp) + fsqrt + fstpt 16(%rsp) +..B1.10: + testb %cl, %cl + je ..B1.12 +..B1.11: + fldcw 10(%rsp) +..B1.12: + fldt 16(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.13: + testl %eax, %eax + jne ..B1.16 +..B1.14: + cmpq $0, 64(%rsp) + jne ..B1.16 +..B1.15: + fldt 64(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.16: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.20 +..B1.17: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.18: + fldcw 8(%rsp) +..B1.19: + movb $1, %cl +..B1.20: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + testb %cl, %cl + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 16(%rsp) + je ..B1.22 +..B1.21: + fldcw 10(%rsp) +..B1.22: + fldt 16(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.23: + cmpl $-2147483648, 68(%rsp) + jne ..B1.25 +..B1.24: + cmpl $0, 64(%rsp) + je ..B1.4 +..B1.25: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.31 +..B1.26: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.27: + fldcw 8(%rsp) +..B1.28: + fldt 64(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) +..B1.29: + fldcw 10(%rsp) +..B1.30: + fldt 16(%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.31: + fldt 64(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) + jmp ..B1.30 + .align 16,0x90 + .cfi_endproc + .type sqrtl,@function + .size sqrtl,.-sqrtl + .data +# -- End sqrtl + .section .rodata, "a" + .align 4 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tan_gen.S b/external/sgx_libm/intel64/tan_gen.S new file mode 100644 index 0000000000..f7cc7fa1db --- /dev/null +++ b/external/sgx_libm/intel64/tan_gen.S @@ -0,0 +1,2170 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tan_gen.c" + .text +..TXTST0: +# -- Begin tan + .text + .align 16,0x90 + .globl tan +tan: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_tan.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + movsd %xmm0, 8(%rsp) +..B1.2: + pextrw $3, %xmm0, %eax + andl $32767, %eax + subl $16314, %eax + cmpl $270, %eax + ja .L_2TAG_PACKET_0.0.1 + movapd ONEHALF(%rip), %xmm5 + movapd MUL16(%rip), %xmm6 + unpcklpd %xmm0, %xmm0 + movapd sign_mask(%rip), %xmm4 + andpd %xmm0, %xmm4 + movapd PI32INV(%rip), %xmm1 + mulpd %xmm0, %xmm1 + orps %xmm4, %xmm5 + addpd %xmm5, %xmm1 + movapd %xmm1, %xmm7 + unpckhpd %xmm7, %xmm7 + cvttsd2si %xmm7, %rdx + cvttpd2dq %xmm1, %xmm1 + cvtdq2pd %xmm1, %xmm1 + mulpd %xmm6, %xmm1 + movapd P_1(%rip), %xmm3 + movq QQ_2(%rip), %xmm5 + addq $469248, %rdx + movapd P_2(%rip), %xmm4 + mulpd %xmm1, %xmm3 + andq $31, %rdx + mulsd %xmm1, %xmm5 + movq %rdx, %rcx + mulpd %xmm1, %xmm4 + shlq $1, %rcx + subpd %xmm3, %xmm0 + mulpd P_3(%rip), %xmm1 + addq %rcx, %rdx + shlq $2, %rcx + addq %rcx, %rdx + addsd %xmm0, %xmm5 + movapd %xmm0, %xmm2 + subpd %xmm4, %xmm0 + movq ONE(%rip), %xmm6 + shlq $4, %rdx + lea Ctable(%rip), %rax + andpd MASK_35(%rip), %xmm5 + movapd %xmm0, %xmm3 + addq %rdx, %rax + subpd %xmm0, %xmm2 + unpckhpd %xmm0, %xmm0 + divsd %xmm5, %xmm6 + subpd %xmm4, %xmm2 + movapd 16(%rax), %xmm7 + subsd %xmm5, %xmm3 + mulpd %xmm0, %xmm7 + subpd %xmm1, %xmm2 + movapd 48(%rax), %xmm1 + mulpd %xmm0, %xmm1 + movapd 96(%rax), %xmm4 + mulpd %xmm0, %xmm4 + addsd %xmm3, %xmm2 + movapd %xmm0, %xmm3 + mulpd %xmm0, %xmm0 + addpd (%rax), %xmm7 + addpd 32(%rax), %xmm1 + mulpd %xmm0, %xmm1 + addpd 80(%rax), %xmm4 + addpd %xmm1, %xmm7 + movapd 112(%rax), %xmm1 + mulpd %xmm0, %xmm1 + mulpd %xmm0, %xmm0 + addpd %xmm1, %xmm4 + movapd 64(%rax), %xmm1 + mulpd %xmm0, %xmm1 + addpd %xmm1, %xmm7 + movapd %xmm3, %xmm1 + mulpd %xmm0, %xmm3 + mulsd %xmm0, %xmm0 + mulpd 144(%rax), %xmm1 + mulpd %xmm3, %xmm4 + movq %xmm1, %xmm3 + addpd %xmm4, %xmm7 + movq %xmm1, %xmm4 + mulsd %xmm7, %xmm0 + unpckhpd %xmm7, %xmm7 + addsd %xmm7, %xmm0 + unpckhpd %xmm1, %xmm1 + addsd %xmm1, %xmm3 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm1 + movq %xmm2, %xmm4 + movq 144(%rax), %xmm7 + unpckhpd %xmm2, %xmm2 + addsd 152(%rax), %xmm7 + mulsd %xmm2, %xmm7 + addsd 136(%rax), %xmm7 + addsd %xmm1, %xmm7 + addsd %xmm7, %xmm0 + movq ONE(%rip), %xmm7 + mulsd %xmm6, %xmm4 + movq 168(%rax), %xmm2 + andpd %xmm6, %xmm2 + mulsd %xmm2, %xmm5 + mulsd 160(%rax), %xmm6 + subsd %xmm5, %xmm7 + subsd 128(%rax), %xmm2 + subsd %xmm4, %xmm7 + mulsd %xmm6, %xmm7 + movq %xmm3, %xmm4 + subsd %xmm2, %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm4 + addsd %xmm4, %xmm0 + subsd %xmm7, %xmm0 + addsd %xmm3, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_0.0.1: + jg .L_2TAG_PACKET_1.0.1 + pextrw $3, %xmm0, %eax + movl %eax, %edx + andl $32752, %eax + je .L_2TAG_PACKET_2.0.1 + andl $32767, %edx + cmpl $15904, %edx + jb .L_2TAG_PACKET_3.0.1 + movq %xmm0, %xmm2 + movq %xmm0, %xmm3 + movq Q_11(%rip), %xmm1 + mulsd %xmm0, %xmm2 + mulsd %xmm2, %xmm3 + mulsd %xmm2, %xmm1 + addsd Q_9(%rip), %xmm1 + mulsd %xmm2, %xmm1 + addsd Q_7(%rip), %xmm1 + mulsd %xmm2, %xmm1 + addsd Q_5(%rip), %xmm1 + mulsd %xmm2, %xmm1 + addsd Q_3(%rip), %xmm1 + mulsd %xmm3, %xmm1 + addsd %xmm1, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_3.0.1: + movq TWO_POW_55(%rip), %xmm3 + mulsd %xmm0, %xmm3 + addsd %xmm3, %xmm0 + mulsd TWO_POW_M55(%rip), %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_2.0.1: + movq %xmm0, %xmm1 + mulsd %xmm1, %xmm1 + jmp ..B1.4 +.L_2TAG_PACKET_1.0.1: + pextrw $3, %xmm0, %eax + andl $32752, %eax + cmpl $32752, %eax + je .L_2TAG_PACKET_4.0.1 + pextrw $3, %xmm0, %ecx + andl $32752, %ecx + subl $16224, %ecx + shrl $7, %ecx + andl $65532, %ecx + lea PI_INV_TABLE(%rip), %r11 + addq %r11, %rcx + movd %xmm0, %rax + movl 20(%rcx), %r10d + movl 24(%rcx), %r8d + movl %eax, %edx + shrq $21, %rax + orl $-2147483648, %eax + shrl $11, %eax + movl %r10d, %r9d + imulq %rdx, %r10 + imulq %rax, %r9 + imulq %rax, %r8 + movl 16(%rcx), %esi + movl 12(%rcx), %edi + movl %r10d, %r11d + shrq $32, %r10 + addq %r10, %r9 + addq %r8, %r11 + movl %r11d, %r8d + shrq $32, %r11 + addq %r11, %r9 + movl %esi, %r10d + imulq %rdx, %rsi + imulq %rax, %r10 + movl %edi, %r11d + imulq %rdx, %rdi + movl %esi, %ebx + shrq $32, %rsi + addq %rbx, %r9 + movl %r9d, %ebx + shrq $32, %r9 + addq %rsi, %r10 + addq %r9, %r10 + shlq $32, %rbx + orq %rbx, %r8 + imulq %rax, %r11 + movl 8(%rcx), %r9d + movl 4(%rcx), %esi + movl %edi, %ebx + shrq $32, %rdi + addq %rbx, %r10 + movl %r10d, %ebx + shrq $32, %r10 + addq %rdi, %r11 + addq %r10, %r11 + movq %r9, %rdi + imulq %rdx, %r9 + imulq %rax, %rdi + movl %r9d, %r10d + shrq $32, %r9 + addq %r10, %r11 + movl %r11d, %r10d + shrq $32, %r11 + addq %r9, %rdi + addq %r11, %rdi + movq %rsi, %r9 + imulq %rdx, %rsi + imulq %rax, %r9 + shlq $32, %r10 + orq %rbx, %r10 + movl (%rcx), %eax + movl %esi, %r11d + shrq $32, %rsi + addq %r11, %rdi + movl %edi, %r11d + shrq $32, %rdi + addq %rsi, %r9 + addq %rdi, %r9 + imulq %rax, %rdx + pextrw $3, %xmm0, %ebx + lea PI_INV_TABLE(%rip), %rdi + subq %rdi, %rcx + addl %ecx, %ecx + addl %ecx, %ecx + addl %ecx, %ecx + addl $19, %ecx + movl $32768, %esi + andl %ebx, %esi + shrl $4, %ebx + andl $2047, %ebx + subl $1023, %ebx + subl %ebx, %ecx + addq %rdx, %r9 + movl %ecx, %edx + addl $32, %edx + cmpl $0, %ecx + jl .L_2TAG_PACKET_5.0.1 + negl %ecx + addl $29, %ecx + shll %cl, %r9d + movl %r9d, %edi + andl $1073741823, %r9d + testl $536870912, %r9d + jne .L_2TAG_PACKET_6.0.1 + shrl %cl, %r9d + movl $0, %ebx + shlq $32, %r9 + orq %r11, %r9 +.L_2TAG_PACKET_7.0.1: +.L_2TAG_PACKET_8.0.1: + cmpq $0, %r9 + je .L_2TAG_PACKET_9.0.1 +.L_2TAG_PACKET_10.0.1: + bsr %r9, %r11 + movl $29, %ecx + subl %r11d, %ecx + jle .L_2TAG_PACKET_11.0.1 + shlq %cl, %r9 + movq %r10, %rax + shlq %cl, %r10 + addl %ecx, %edx + negl %ecx + addl $64, %ecx + shrq %cl, %rax + shrq %cl, %r8 + orq %rax, %r9 + orq %r8, %r10 +.L_2TAG_PACKET_12.0.1: + cvtsi2sdq %r9, %xmm0 + shrq $1, %r10 + cvtsi2sdq %r10, %xmm3 + xorpd %xmm4, %xmm4 + shll $4, %edx + negl %edx + addl $16368, %edx + orl %esi, %edx + xorl %ebx, %edx + pinsrw $3, %edx, %xmm4 + movq PI_4(%rip), %xmm2 + movq 8+PI_4(%rip), %xmm7 + xorpd %xmm5, %xmm5 + subl $1008, %edx + pinsrw $3, %edx, %xmm5 + mulsd %xmm4, %xmm0 + shll $16, %esi + sarl $31, %esi + mulsd %xmm5, %xmm3 + movq %xmm0, %xmm1 + mulsd %xmm2, %xmm0 + shrl $30, %edi + addsd %xmm3, %xmm1 + mulsd %xmm2, %xmm3 + addl %esi, %edi + xorl %esi, %edi + mulsd %xmm1, %xmm7 + movl %edi, %eax + addsd %xmm3, %xmm7 + movq %xmm0, %xmm2 + addsd %xmm7, %xmm0 + subsd %xmm0, %xmm2 + addsd %xmm2, %xmm7 + movapd PI32INV(%rip), %xmm1 + unpcklpd %xmm0, %xmm0 + movapd sign_mask(%rip), %xmm4 + andpd %xmm0, %xmm4 + mulpd %xmm0, %xmm1 + unpcklpd %xmm7, %xmm7 + movapd ONEHALF(%rip), %xmm5 + movapd MUL16(%rip), %xmm6 + orps %xmm4, %xmm5 + addpd %xmm5, %xmm1 + movapd %xmm1, %xmm5 + unpckhpd %xmm5, %xmm5 + cvttsd2si %xmm5, %edx + cvttpd2dq %xmm1, %xmm1 + cvtdq2pd %xmm1, %xmm1 + mulpd %xmm6, %xmm1 + movapd P_1(%rip), %xmm3 + movq QQ_2(%rip), %xmm5 + shll $4, %eax + addl $469248, %edx + movapd P_2(%rip), %xmm4 + mulpd %xmm1, %xmm3 + addl %eax, %edx + andl $31, %edx + mulsd %xmm1, %xmm5 + movl %edx, %ecx + mulpd %xmm1, %xmm4 + shll $1, %ecx + subpd %xmm3, %xmm0 + mulpd P_3(%rip), %xmm1 + addl %ecx, %edx + shll $2, %ecx + addl %ecx, %edx + addsd %xmm0, %xmm5 + movapd %xmm0, %xmm2 + subpd %xmm4, %xmm0 + movq ONE(%rip), %xmm6 + shll $4, %edx + lea Ctable(%rip), %rax + andpd MASK_35(%rip), %xmm5 + movapd %xmm0, %xmm3 + addq %rdx, %rax + subpd %xmm0, %xmm2 + unpckhpd %xmm0, %xmm0 + divsd %xmm5, %xmm6 + subpd %xmm4, %xmm2 + subsd %xmm5, %xmm3 + subpd %xmm1, %xmm2 + movapd 48(%rax), %xmm1 + addpd %xmm7, %xmm2 + movapd 16(%rax), %xmm7 + mulpd %xmm0, %xmm7 + movapd 96(%rax), %xmm4 + mulpd %xmm0, %xmm1 + mulpd %xmm0, %xmm4 + addsd %xmm3, %xmm2 + movapd %xmm0, %xmm3 + mulpd %xmm0, %xmm0 + addpd (%rax), %xmm7 + addpd 32(%rax), %xmm1 + mulpd %xmm0, %xmm1 + addpd 80(%rax), %xmm4 + addpd %xmm1, %xmm7 + movapd 112(%rax), %xmm1 + mulpd %xmm0, %xmm1 + mulpd %xmm0, %xmm0 + addpd %xmm1, %xmm4 + movapd 64(%rax), %xmm1 + mulpd %xmm0, %xmm1 + addpd %xmm1, %xmm7 + movapd %xmm3, %xmm1 + mulpd %xmm0, %xmm3 + mulsd %xmm0, %xmm0 + mulpd 144(%rax), %xmm1 + mulpd %xmm3, %xmm4 + movq %xmm1, %xmm3 + addpd %xmm4, %xmm7 + movq %xmm1, %xmm4 + mulsd %xmm7, %xmm0 + unpckhpd %xmm7, %xmm7 + addsd %xmm7, %xmm0 + unpckhpd %xmm1, %xmm1 + addsd %xmm1, %xmm3 + subsd %xmm3, %xmm4 + addsd %xmm4, %xmm1 + movq %xmm2, %xmm4 + movq 144(%rax), %xmm7 + unpckhpd %xmm2, %xmm2 + addsd 152(%rax), %xmm7 + mulsd %xmm2, %xmm7 + addsd 136(%rax), %xmm7 + addsd %xmm1, %xmm7 + addsd %xmm7, %xmm0 + movq ONE(%rip), %xmm7 + mulsd %xmm6, %xmm4 + movq 168(%rax), %xmm2 + andpd %xmm6, %xmm2 + mulsd %xmm2, %xmm5 + mulsd 160(%rax), %xmm6 + subsd %xmm5, %xmm7 + subsd 128(%rax), %xmm2 + subsd %xmm4, %xmm7 + mulsd %xmm6, %xmm7 + movq %xmm3, %xmm4 + subsd %xmm2, %xmm3 + addsd %xmm3, %xmm2 + subsd %xmm2, %xmm4 + addsd %xmm4, %xmm0 + subsd %xmm7, %xmm0 + addsd %xmm3, %xmm0 + jmp ..B1.4 +.L_2TAG_PACKET_9.0.1: + addl $64, %edx + movq %r10, %r9 + movq %r8, %r10 + movq $0, %r8 + cmpq $0, %r9 + jne .L_2TAG_PACKET_10.0.1 + addl $64, %edx + movq %r10, %r9 + movq %r8, %r10 + cmpq $0, %r9 + jne .L_2TAG_PACKET_10.0.1 + jmp .L_2TAG_PACKET_12.0.1 +.L_2TAG_PACKET_11.0.1: + je .L_2TAG_PACKET_12.0.1 + negl %ecx + shrq %cl, %r10 + movq %r9, %rax + shrq %cl, %r9 + subl %ecx, %edx + negl %ecx + addl $64, %ecx + shlq %cl, %rax + orq %rax, %r10 + jmp .L_2TAG_PACKET_12.0.1 +.L_2TAG_PACKET_5.0.1: + notl %ecx + shlq $32, %r9 + orq %r11, %r9 + shlq %cl, %r9 + movq %r9, %rdi + testl $-2147483648, %r9d + jne .L_2TAG_PACKET_13.0.1 + shrl %cl, %r9d + movl $0, %ebx + shrq $2, %rdi + jmp .L_2TAG_PACKET_8.0.1 +.L_2TAG_PACKET_6.0.1: + shrl %cl, %r9d + movl $1073741824, %ebx + shrl %cl, %ebx + shlq $32, %r9 + orq %r11, %r9 + shlq $32, %rbx + addl $1073741824, %edi + movq $0, %rcx + movq $0, %r11 + subq %r8, %rcx + sbbq %r10, %r11 + sbbq %r9, %rbx + movq %rcx, %r8 + movq %r11, %r10 + movq %rbx, %r9 + movl $32768, %ebx + jmp .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_13.0.1: + shrl %cl, %r9d + movq $0x100000000, %rbx + shrq %cl, %rbx + movq $0, %rcx + movq $0, %r11 + subq %r8, %rcx + sbbq %r10, %r11 + sbbq %r9, %rbx + movq %rcx, %r8 + movq %r11, %r10 + movq %rbx, %r9 + movl $32768, %ebx + shrq $2, %rdi + addl $1073741824, %edi + jmp .L_2TAG_PACKET_8.0.1 +.L_2TAG_PACKET_4.0.1: + movq 8(%rsp), %xmm0 + mulsd NEG_ZERO(%rip), %xmm0 + movq %xmm0, (%rsp) +.L_2TAG_PACKET_14.0.1: +..B1.4: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type tan,@function + .size tan,.-tan + .data +# -- End tan + .section .rodata, "a" + .align 16 + .align 16 +ONEHALF: + .long 0 + .long 1071644672 + .long 0 + .long 1071644672 + .type ONEHALF,@object + .size ONEHALF,16 + .align 16 +MUL16: + .long 0 + .long 1076887552 + .long 0 + .long 1072693248 + .type MUL16,@object + .size MUL16,16 + .align 16 +sign_mask: + .long 0 + .long 2147483648 + .long 0 + .long 2147483648 + .type sign_mask,@object + .size sign_mask,16 + .align 16 +PI32INV: + .long 1841940611 + .long 1071931184 + .long 1841940611 + .long 1076125488 + .type PI32INV,@object + .size PI32INV,16 + .align 16 +P_1: + .long 1413758976 + .long 1069097467 + .long 1413742592 + .long 1069097467 + .type P_1,@object + .size P_1,16 + .align 16 +P_2: + .long 1734819840 + .long 3174229945 + .long 1280049152 + .long 1028033571 + .type P_2,@object + .size P_2,16 + .align 16 +P_3: + .long 923219018 + .long 984130272 + .long 57701189 + .long 988383790 + .type P_3,@object + .size P_3,16 + .align 16 +Ctable: + .long 0 + .long 0 + .long 0 + .long 0 + .long 2284589306 + .long 1066820852 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1441186365 + .long 1065494243 + .long 1431655765 + .long 1070945621 + .long 0 + .long 0 + .long 0 + .long 0 + .long 236289504 + .long 1064135997 + .long 286331153 + .long 1069617425 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1160476131 + .long 1062722102 + .long 463583772 + .long 1068212666 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1313038235 + .long 1066745731 + .long 0 + .long 0 + .long 1013878342 + .long 1067152618 + .long 0 + .long 0 + .long 3663426833 + .long 1065725283 + .long 3693284251 + .long 1069118808 + .long 650852232 + .long 1065882376 + .long 1996245381 + .long 1071000265 + .long 2008746170 + .long 1064664197 + .long 3055842593 + .long 1068578846 + .long 1495406348 + .long 1064652437 + .long 2269530157 + .long 1069711235 + .long 285563696 + .long 1063576465 + .long 1046897440 + .long 1067705865 + .long 233429731 + .long 1063453151 + .long 522045958 + .long 1068476590 + .long 2354785698 + .long 1069102779 + .long 1317599141 + .long 1012432133 + .long 0 + .long 1072693248 + .long 2828230105 + .long 1065606626 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1512545955 + .long 1068119047 + .long 0 + .long 0 + .long 1127048698 + .long 1067909459 + .long 0 + .long 0 + .long 2300200450 + .long 1067254767 + .long 3593250296 + .long 1070233561 + .long 3009365544 + .long 1066902117 + .long 1127373050 + .long 1071173457 + .long 3046103305 + .long 1066371299 + .long 24583402 + .long 1069723988 + .long 4082511758 + .long 1065914199 + .long 3223889699 + .long 1070020367 + .long 548927984 + .long 1065415756 + .long 558065897 + .long 1068949418 + .long 680073315 + .long 1064940726 + .long 388873200 + .long 1068944270 + .long 3763679576 + .long 1070167541 + .long 1497360404 + .long 1009710547 + .long 0 + .long 1072693248 + .long 64931152 + .long 1067729411 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2467582782 + .long 1069256389 + .long 0 + .long 0 + .long 162150096 + .long 1068946420 + .long 0 + .long 0 + .long 3702794237 + .long 1068579152 + .long 3631919291 + .long 1070936926 + .long 3456821413 + .long 1068217218 + .long 2031366438 + .long 1071495745 + .long 1596664020 + .long 1067799281 + .long 1509038701 + .long 1070601643 + .long 583171477 + .long 1067510148 + .long 3785344682 + .long 1070618476 + .long 2402036048 + .long 1067075736 + .long 3233018412 + .long 1069913186 + .long 411280568 + .long 1066710556 + .long 1065584192 + .long 1069747896 + .long 895247324 + .long 1070819848 + .long 500078909 + .long 3161288781 + .long 0 + .long 1072693248 + .long 729983843 + .long 1068994194 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1458794562 + .long 1070398550 + .long 0 + .long 0 + .long 2857777489 + .long 1070137637 + .long 0 + .long 0 + .long 1024359517 + .long 1069876531 + .long 2616040238 + .long 1071582937 + .long 1609024636 + .long 1069675088 + .long 2529240549 + .long 1071836633 + .long 1510128600 + .long 1069440113 + .long 2251697184 + .long 1071253687 + .long 1262761453 + .long 1069142850 + .long 1263091857 + .long 1071190461 + .long 3043383486 + .long 1068885191 + .long 2476932470 + .long 1070842002 + .long 3659995028 + .long 1068669200 + .long 855891755 + .long 1070696894 + .long 2583490354 + .long 1071284857 + .long 3062633575 + .long 1014008623 + .long 0 + .long 1072693248 + .long 2550940471 + .long 1069938201 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3422807297 + .long 1071640847 + .long 0 + .long 0 + .long 1151658053 + .long 1071494715 + .long 0 + .long 0 + .long 929607071 + .long 1071346340 + .long 1037049034 + .long 1072037305 + .long 2786928657 + .long 1071215282 + .long 1447406859 + .long 1072265209 + .long 3490952107 + .long 1071090851 + .long 3205232916 + .long 1071968658 + .long 1297344304 + .long 1070977120 + .long 1066110976 + .long 1071946035 + .long 3803721480 + .long 1070871082 + .long 1496754229 + .long 1071807201 + .long 2982550683 + .long 1070773243 + .long 4014441989 + .long 1071736222 + .long 419968236 + .long 1071717047 + .long 3451266538 + .long 3163444811 + .long 0 + .long 1072693248 + .long 2960267235 + .long 1070745841 + .long 0 + .long 0 + .long 0 + .long 0 + .long 724322768 + .long 1072881308 + .long 0 + .long 0 + .long 643153048 + .long 1072905816 + .long 0 + .long 0 + .long 4285079458 + .long 1072928558 + .long 3912524733 + .long 1072622983 + .long 118362272 + .long 1072952754 + .long 4107767972 + .long 1072827408 + .long 2689502883 + .long 1072976922 + .long 946523347 + .long 1072772766 + .long 573204189 + .long 1073001761 + .long 581531518 + .long 1072826391 + .long 1386236526 + .long 1073026959 + .long 3718905905 + .long 1072832823 + .long 1145558140 + .long 1073052673 + .long 513572637 + .long 1072861969 + .long 716700048 + .long 1071997368 + .long 547126769 + .long 1015523525 + .long 0 + .long 1072693248 + .long 1097907398 + .long 1071420120 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3349892442 + .long 1074290212 + .long 0 + .long 0 + .long 3913197405 + .long 1074501181 + .long 0 + .long 0 + .long 2494034522 + .long 1074739170 + .long 1264738763 + .long 1073084804 + .long 1520293906 + .long 1074899632 + .long 1958936600 + .long 1073411493 + .long 2133649635 + .long 1075052171 + .long 4270740730 + .long 1073574708 + .long 1728930189 + .long 1075224844 + .long 1303998552 + .long 1073799186 + .long 618611933 + .long 1075420255 + .long 1769828046 + .long 1073938542 + .long 2200537986 + .long 1075641421 + .long 433361110 + .long 1074105369 + .long 719595600 + .long 1072317184 + .long 294527206 + .long 3162140088 + .long 0 + .long 1073741824 + .long 3811788216 + .long 3218400550 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1704352102 + .long 1075943001 + .long 0 + .long 0 + .long 2284589306 + .long 1076258036 + .long 0 + .long 0 + .long 2211264291 + .long 1076659010 + .long 0 + .long 1073741824 + .long 1441186365 + .long 1077028579 + .long 1431655765 + .long 1074091349 + .long 876943673 + .long 1077353622 + .long 2863311531 + .long 1074440874 + .long 236289504 + .long 1077767485 + .long 286331153 + .long 1074860305 + .long 2805473311 + .long 1078115278 + .long 95443718 + .long 1075163227 + .long 1160476131 + .long 1078450742 + .long 463583772 + .long 1075552698 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1330165971 + .long 3207850745 + .long 0 + .long 0 + .long 217536623 + .long 1059109098 + .long 0 + .long 0 + .long 3492120849 + .long 3205151475 + .long 602185705 + .long 3215678092 + .long 760422958 + .long 1056312597 + .long 555127889 + .long 1067545266 + .long 3139784124 + .long 3202470837 + .long 3690544014 + .long 3213150171 + .long 95707915 + .long 1053635428 + .long 4003114407 + .long 1064581412 + .long 2034926231 + .long 3199711161 + .long 3759536023 + .long 3210559989 + .long 3826928214 + .long 1050893819 + .long 3837960785 + .long 1061790379 + .long 1526325248 + .long 3217967566 + .long 2356426521 + .long 1025423456 + .long 0 + .long 0 + .long 457728975 + .long 1071088276 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1398462608 + .long 3207303968 + .long 0 + .long 0 + .long 26205983 + .long 1058461213 + .long 0 + .long 0 + .long 56226238 + .long 3204528612 + .long 2754706541 + .long 3215359511 + .long 2187799823 + .long 1055634437 + .long 790323742 + .long 1067402587 + .long 1372385848 + .long 3201651479 + .long 4097292716 + .long 3212856302 + .long 3348210357 + .long 1052830099 + .long 2442796466 + .long 1064337602 + .long 862608142 + .long 3198830754 + .long 170296152 + .long 3210060867 + .long 3755571428 + .long 1049933343 + .long 3614866008 + .long 1061361670 + .long 719978496 + .long 3217669096 + .long 1998842465 + .long 3174703977 + .long 0 + .long 0 + .long 3749156607 + .long 1071048258 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3120498638 + .long 3206749304 + .long 0 + .long 0 + .long 2773578114 + .long 1058009312 + .long 0 + .long 0 + .long 2030783676 + .long 3203817873 + .long 2223654598 + .long 3215071936 + .long 2976134650 + .long 1054987244 + .long 706390066 + .long 1067217386 + .long 4258437615 + .long 3200900378 + .long 1066252975 + .long 3212391267 + .long 815777514 + .long 1051989462 + .long 3202745457 + .long 1064010682 + .long 2493556375 + .long 3198004753 + .long 1046243251 + .long 3209678971 + .long 2593078846 + .long 1049017717 + .long 2763962276 + .long 1060970161 + .long 701480960 + .long 3217377742 + .long 3205862232 + .long 3174660915 + .long 0 + .long 0 + .long 2267016812 + .long 1071015664 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 2107155798 + .long 3206166872 + .long 0 + .long 0 + .long 2642992129 + .long 1057424578 + .long 0 + .long 0 + .long 1936992811 + .long 3203204426 + .long 1485063559 + .long 3214682643 + .long 1432914553 + .long 1054319398 + .long 3996381654 + .long 1067075828 + .long 2833029256 + .long 3200223545 + .long 2866066872 + .long 3211982662 + .long 2432888737 + .long 1051234178 + .long 3669764559 + .long 1063748136 + .long 2458496952 + .long 3197170774 + .long 1948234989 + .long 3209098147 + .long 2843698787 + .long 1048163519 + .long 3398041407 + .long 1060559728 + .long 2829230080 + .long 3217092115 + .long 1034046433 + .long 3174271903 + .long 0 + .long 0 + .long 298675305 + .long 1070989821 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 437603223 + .long 3205589761 + .long 0 + .long 0 + .long 759330352 + .long 1057048511 + .long 0 + .long 0 + .long 3107463368 + .long 3202507988 + .long 3144465176 + .long 3214191500 + .long 2290961810 + .long 1053841035 + .long 1618153340 + .long 1066971547 + .long 3836869393 + .long 3199400272 + .long 584032116 + .long 3211469261 + .long 1245704358 + .long 1050626462 + .long 4247487438 + .long 1063561943 + .long 1669034927 + .long 3196274812 + .long 3844233498 + .long 3208626322 + .long 2706958524 + .long 1047411374 + .long 3857199098 + .long 1060281647 + .long 3593904128 + .long 3216590719 + .long 3267547836 + .long 3172163321 + .long 0 + .long 0 + .long 4076712227 + .long 1070970214 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3290090340 + .long 3204793485 + .long 0 + .long 0 + .long 3685760367 + .long 1056668370 + .long 0 + .long 0 + .long 2655163949 + .long 3201674917 + .long 628750575 + .long 3213566872 + .long 680140505 + .long 1053299777 + .long 2954464709 + .long 1066900026 + .long 803201619 + .long 3198516435 + .long 1466315631 + .long 3210837162 + .long 1611220163 + .long 1049972438 + .long 2766187256 + .long 1063437894 + .long 1804579484 + .long 3195331491 + .long 3695969289 + .long 3207854418 + .long 2617238373 + .long 1046675948 + .long 3095830084 + .long 1060095334 + .long 3789570048 + .long 3216034914 + .long 23826559 + .long 3172048060 + .long 0 + .long 0 + .long 3870939386 + .long 1070956467 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1571758758 + .long 3203672535 + .long 0 + .long 0 + .long 113026373 + .long 1056416381 + .long 0 + .long 0 + .long 1913766298 + .long 3200523326 + .long 2507068734 + .long 3212502004 + .long 4000648818 + .long 1053003803 + .long 2446607349 + .long 1066858259 + .long 912662124 + .long 3197333001 + .long 1349489537 + .long 3209765608 + .long 3412972607 + .long 1049641401 + .long 1721283327 + .long 1063366855 + .long 1466691883 + .long 3194116746 + .long 3852528092 + .long 3206760861 + .long 285443293 + .long 1046158380 + .long 1758739894 + .long 1059895449 + .long 1858781184 + .long 3214984212 + .long 3447575948 + .long 1024675855 + .long 0 + .long 0 + .long 2242038011 + .long 1070948320 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 0 + .long 0 + .long 0 + .long 0 + .long 737611454 + .long 1056336527 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3594790527 + .long 1052911621 + .long 381774871 + .long 1066844524 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3303051618 + .long 1049456050 + .long 3154187623 + .long 1063343722 + .long 0 + .long 0 + .long 0 + .long 0 + .long 528061788 + .long 1045944910 + .long 2469719819 + .long 1059831159 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1431655765 + .long 1070945621 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1571758758 + .long 1056188887 + .long 0 + .long 0 + .long 113026373 + .long 1056416381 + .long 0 + .long 0 + .long 1913766298 + .long 1053039678 + .long 2507068734 + .long 1065018356 + .long 4000648818 + .long 1053003803 + .long 2446607349 + .long 1066858259 + .long 912662124 + .long 1049849353 + .long 1349489537 + .long 1062281960 + .long 3412972607 + .long 1049641401 + .long 1721283327 + .long 1063366855 + .long 1466691883 + .long 1046633098 + .long 3852528092 + .long 1059277213 + .long 285443293 + .long 1046158380 + .long 1758739894 + .long 1059895449 + .long 1858781184 + .long 1067500564 + .long 3447575948 + .long 3172159503 + .long 0 + .long 0 + .long 2242038011 + .long 1070948320 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3290090340 + .long 1057309837 + .long 0 + .long 0 + .long 3685760367 + .long 1056668370 + .long 0 + .long 0 + .long 2655163949 + .long 1054191269 + .long 628750575 + .long 1066083224 + .long 680140505 + .long 1053299777 + .long 2954464709 + .long 1066900026 + .long 803201619 + .long 1051032787 + .long 1466315631 + .long 1063353514 + .long 1611220163 + .long 1049972438 + .long 2766187256 + .long 1063437894 + .long 1804579484 + .long 1047847843 + .long 3695969289 + .long 1060370770 + .long 2617238373 + .long 1046675948 + .long 3095830084 + .long 1060095334 + .long 3789570048 + .long 1068551266 + .long 23826559 + .long 1024564412 + .long 0 + .long 0 + .long 3870939386 + .long 1070956467 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 437603223 + .long 1058106113 + .long 0 + .long 0 + .long 759330352 + .long 1057048511 + .long 0 + .long 0 + .long 3107463368 + .long 1055024340 + .long 3144465176 + .long 1066707852 + .long 2290961810 + .long 1053841035 + .long 1618153340 + .long 1066971547 + .long 3836869393 + .long 1051916624 + .long 584032116 + .long 1063985613 + .long 1245704358 + .long 1050626462 + .long 4247487438 + .long 1063561943 + .long 1669034927 + .long 1048791164 + .long 3844233498 + .long 1061142674 + .long 2706958524 + .long 1047411374 + .long 3857199098 + .long 1060281647 + .long 3593904128 + .long 1069107071 + .long 3267547836 + .long 1024679673 + .long 0 + .long 0 + .long 4076712227 + .long 1070970214 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 2107155798 + .long 1058683224 + .long 0 + .long 0 + .long 2642992129 + .long 1057424578 + .long 0 + .long 0 + .long 1936992811 + .long 1055720778 + .long 1485063559 + .long 1067198995 + .long 1432914553 + .long 1054319398 + .long 3996381654 + .long 1067075828 + .long 2833029256 + .long 1052739897 + .long 2866066872 + .long 1064499014 + .long 2432888737 + .long 1051234178 + .long 3669764559 + .long 1063748136 + .long 2458496952 + .long 1049687126 + .long 1948234989 + .long 1061614499 + .long 2843698787 + .long 1048163519 + .long 3398041407 + .long 1060559728 + .long 2829230080 + .long 1069608467 + .long 1034046433 + .long 1026788255 + .long 0 + .long 0 + .long 298675305 + .long 1070989821 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 3120498638 + .long 1059265656 + .long 0 + .long 0 + .long 2773578114 + .long 1058009312 + .long 0 + .long 0 + .long 2030783676 + .long 1056334225 + .long 2223654598 + .long 1067588288 + .long 2976134650 + .long 1054987244 + .long 706390066 + .long 1067217386 + .long 4258437615 + .long 1053416730 + .long 1066252975 + .long 1064907619 + .long 815777514 + .long 1051989462 + .long 3202745457 + .long 1064010682 + .long 2493556375 + .long 1050521105 + .long 1046243251 + .long 1062195323 + .long 2593078846 + .long 1049017717 + .long 2763962276 + .long 1060970161 + .long 701480960 + .long 1069894094 + .long 3205862232 + .long 1027177267 + .long 0 + .long 0 + .long 2267016812 + .long 1071015664 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1398462608 + .long 1059820320 + .long 0 + .long 0 + .long 26205983 + .long 1058461213 + .long 0 + .long 0 + .long 56226238 + .long 1057044964 + .long 2754706541 + .long 1067875863 + .long 2187799823 + .long 1055634437 + .long 790323742 + .long 1067402587 + .long 1372385848 + .long 1054167831 + .long 4097292716 + .long 1065372654 + .long 3348210357 + .long 1052830099 + .long 2442796466 + .long 1064337602 + .long 862608142 + .long 1051347106 + .long 170296152 + .long 1062577219 + .long 3755571428 + .long 1049933343 + .long 3614866008 + .long 1061361670 + .long 719978496 + .long 1070185448 + .long 1998842465 + .long 1027220329 + .long 0 + .long 0 + .long 3749156607 + .long 1071048258 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1330165971 + .long 1060367097 + .long 0 + .long 0 + .long 217536623 + .long 1059109098 + .long 0 + .long 0 + .long 3492120849 + .long 1057667827 + .long 602185705 + .long 1068194444 + .long 760422958 + .long 1056312597 + .long 555127889 + .long 1067545266 + .long 3139784124 + .long 1054987189 + .long 3690544014 + .long 1065666523 + .long 95707915 + .long 1053635428 + .long 4003114407 + .long 1064581412 + .long 2034926231 + .long 1052227513 + .long 3759536023 + .long 1063076341 + .long 3826928214 + .long 1050893819 + .long 3837960785 + .long 1061790379 + .long 1526325248 + .long 1070483918 + .long 2356426521 + .long 3172907104 + .long 0 + .long 0 + .long 457728975 + .long 1071088276 + .long 0 + .long 1072693248 + .long 0 + .long 4294967288 + .long 1704352102 + .long 3223426649 + .long 0 + .long 0 + .long 2284589306 + .long 1076258036 + .long 0 + .long 0 + .long 2211264291 + .long 3224142658 + .long 0 + .long 3221225472 + .long 1441186365 + .long 1077028579 + .long 1431655765 + .long 1074091349 + .long 876943673 + .long 3224837270 + .long 2863311531 + .long 3221924522 + .long 236289504 + .long 1077767485 + .long 286331153 + .long 1074860305 + .long 2805473311 + .long 3225598926 + .long 95443718 + .long 3222646875 + .long 1160476131 + .long 1078450742 + .long 463583772 + .long 1075552698 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 0 + .long 1073741824 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3349892442 + .long 3221773860 + .long 0 + .long 0 + .long 3913197405 + .long 1074501181 + .long 0 + .long 0 + .long 2494034522 + .long 3222222818 + .long 1264738763 + .long 3220568452 + .long 1520293906 + .long 1074899632 + .long 1958936600 + .long 1073411493 + .long 2133649635 + .long 3222535819 + .long 4270740730 + .long 3221058356 + .long 1728930189 + .long 1075224844 + .long 1303998552 + .long 1073799186 + .long 618611933 + .long 3222903903 + .long 1769828046 + .long 3221422190 + .long 2200537986 + .long 1075641421 + .long 433361110 + .long 1074105369 + .long 719595600 + .long 3219800832 + .long 294527206 + .long 1014656440 + .long 0 + .long 1073741824 + .long 3811788216 + .long 3218400550 + .long 0 + .long 0 + .long 0 + .long 0 + .long 724322768 + .long 3220364956 + .long 0 + .long 0 + .long 643153048 + .long 1072905816 + .long 0 + .long 0 + .long 4285079458 + .long 3220412206 + .long 3912524733 + .long 3220106631 + .long 118362272 + .long 1072952754 + .long 4107767972 + .long 1072827408 + .long 2689502883 + .long 3220460570 + .long 946523347 + .long 3220256414 + .long 573204189 + .long 1073001761 + .long 581531518 + .long 1072826391 + .long 1386236526 + .long 3220510607 + .long 3718905905 + .long 3220316471 + .long 1145558140 + .long 1073052673 + .long 513572637 + .long 1072861969 + .long 716700048 + .long 3219481016 + .long 547126769 + .long 3163007173 + .long 0 + .long 1072693248 + .long 1097907398 + .long 1071420120 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3422807297 + .long 3219124495 + .long 0 + .long 0 + .long 1151658053 + .long 1071494715 + .long 0 + .long 0 + .long 929607071 + .long 3218829988 + .long 1037049034 + .long 3219520953 + .long 2786928657 + .long 1071215282 + .long 1447406859 + .long 1072265209 + .long 3490952107 + .long 3218574499 + .long 3205232916 + .long 3219452306 + .long 1297344304 + .long 1070977120 + .long 1066110976 + .long 1071946035 + .long 3803721480 + .long 3218354730 + .long 1496754229 + .long 3219290849 + .long 2982550683 + .long 1070773243 + .long 4014441989 + .long 1071736222 + .long 419968236 + .long 3219200695 + .long 3451266538 + .long 1015961163 + .long 0 + .long 1072693248 + .long 2960267235 + .long 1070745841 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1458794562 + .long 3217882198 + .long 0 + .long 0 + .long 2857777489 + .long 1070137637 + .long 0 + .long 0 + .long 1024359517 + .long 3217360179 + .long 2616040238 + .long 3219066585 + .long 1609024636 + .long 1069675088 + .long 2529240549 + .long 1071836633 + .long 1510128600 + .long 3216923761 + .long 2251697184 + .long 3218737335 + .long 1262761453 + .long 1069142850 + .long 1263091857 + .long 1071190461 + .long 3043383486 + .long 3216368839 + .long 2476932470 + .long 3218325650 + .long 3659995028 + .long 1068669200 + .long 855891755 + .long 1070696894 + .long 2583490354 + .long 3218768505 + .long 3062633575 + .long 3161492271 + .long 0 + .long 1072693248 + .long 2550940471 + .long 1069938201 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2467582782 + .long 3216740037 + .long 0 + .long 0 + .long 162150096 + .long 1068946420 + .long 0 + .long 0 + .long 3702794237 + .long 3216062800 + .long 3631919291 + .long 3218420574 + .long 3456821413 + .long 1068217218 + .long 2031366438 + .long 1071495745 + .long 1596664020 + .long 3215282929 + .long 1509038701 + .long 3218085291 + .long 583171477 + .long 1067510148 + .long 3785344682 + .long 1070618476 + .long 2402036048 + .long 3214559384 + .long 3233018412 + .long 3217396834 + .long 411280568 + .long 1066710556 + .long 1065584192 + .long 1069747896 + .long 895247324 + .long 3218303496 + .long 500078909 + .long 1013805133 + .long 0 + .long 1072693248 + .long 729983843 + .long 1068994194 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1512545955 + .long 3215602695 + .long 0 + .long 0 + .long 1127048698 + .long 1067909459 + .long 0 + .long 0 + .long 2300200450 + .long 3214738415 + .long 3593250296 + .long 3217717209 + .long 3009365544 + .long 1066902117 + .long 1127373050 + .long 1071173457 + .long 3046103305 + .long 3213854947 + .long 24583402 + .long 3217207636 + .long 4082511758 + .long 1065914199 + .long 3223889699 + .long 1070020367 + .long 548927984 + .long 3212899404 + .long 558065897 + .long 3216433066 + .long 680073315 + .long 1064940726 + .long 388873200 + .long 1068944270 + .long 3763679576 + .long 3217651189 + .long 1497360404 + .long 3157194195 + .long 0 + .long 1072693248 + .long 64931152 + .long 1067729411 + .long 0 + .long 0 + .long 0 + .long 0 + .long 1313038235 + .long 3214229379 + .long 0 + .long 0 + .long 1013878342 + .long 1067152618 + .long 0 + .long 0 + .long 3663426833 + .long 3213208931 + .long 3693284251 + .long 3216602456 + .long 650852232 + .long 1065882376 + .long 1996245381 + .long 1071000265 + .long 2008746170 + .long 3212147845 + .long 3055842593 + .long 3216062494 + .long 1495406348 + .long 1064652437 + .long 2269530157 + .long 1069711235 + .long 285563696 + .long 3211060113 + .long 1046897440 + .long 3215189513 + .long 233429731 + .long 1063453151 + .long 522045958 + .long 1068476590 + .long 2354785698 + .long 3216586427 + .long 1317599141 + .long 3159915781 + .long 0 + .long 1072693248 + .long 2828230105 + .long 1065606626 + .long 0 + .long 0 + .long 0 + .long 0 + .type Ctable,@object + .size Ctable,5632 + .align 16 +MASK_35: + .long 4294705152 + .long 4294967295 + .long 0 + .long 0 + .type MASK_35,@object + .size MASK_35,16 + .align 16 +Q_11: + .long 3103673719 + .long 1065509018 + .type Q_11,@object + .size Q_11,8 + .space 8, 0x00 # pad + .align 16 +Q_9: + .long 3213130307 + .long 1066820768 + .type Q_9,@object + .size Q_9,8 + .space 8, 0x00 # pad + .align 16 +Q_7: + .long 1388628139 + .long 1068212666 + .type Q_7,@object + .size Q_7,8 + .space 8, 0x00 # pad + .align 16 +Q_5: + .long 285812550 + .long 1069617425 + .type Q_5,@object + .size Q_5,8 + .space 8, 0x00 # pad + .align 16 +Q_3: + .long 1431655954 + .long 1070945621 + .type Q_3,@object + .size Q_3,8 + .space 8, 0x00 # pad + .align 16 +PI_INV_TABLE: + .long 0 + .long 0 + .long 2734261102 + .long 1313084713 + .long 4230436817 + .long 4113882560 + .long 3680671129 + .long 1011060801 + .long 4266746795 + .long 3736847713 + .long 3072618042 + .long 1112396512 + .long 105459434 + .long 164729372 + .long 4263373596 + .long 2972297022 + .long 3900847605 + .long 784024708 + .long 3919343654 + .long 3026157121 + .long 965858873 + .long 2203269620 + .long 2625920907 + .long 3187222587 + .long 536385535 + .long 3724908559 + .long 4012839307 + .long 1510632735 + .long 1832287951 + .long 667617719 + .long 1330003814 + .long 2657085997 + .long 1965537991 + .long 3957715323 + .long 1023883767 + .long 2320667370 + .long 1811636145 + .long 529358088 + .long 1443049542 + .long 4235946923 + .long 4040145953 + .type PI_INV_TABLE,@object + .size PI_INV_TABLE,164 + .space 12, 0x00 # pad + .align 16 +PI_4: + .long 0 + .long 1072243195 + .long 1175561766 + .long 1048908043 + .type PI_4,@object + .size PI_4,16 + .align 8 +QQ_2: + .long 1734816687 + .long 1026746297 + .type QQ_2,@object + .size QQ_2,8 + .align 8 +ONE: + .long 0 + .long 1072693248 + .type ONE,@object + .size ONE,8 + .align 8 +TWO_POW_55: + .long 0 + .long 1130364928 + .type TWO_POW_55,@object + .size TWO_POW_55,8 + .align 8 +TWO_POW_M55: + .long 0 + .long 1015021568 + .type TWO_POW_M55,@object + .size TWO_POW_M55,8 + .align 4 +NEG_ZERO: + .long 0 + .long 2147483648 + .type NEG_ZERO,@object + .size NEG_ZERO,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tanf_gen.S b/external/sgx_libm/intel64/tanf_gen.S new file mode 100644 index 0000000000..0007a4e83c --- /dev/null +++ b/external/sgx_libm/intel64/tanf_gen.S @@ -0,0 +1,858 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanf_gen.c" + .text +..TXTST0: +# -- Begin tanf + .text + .align 16,0x90 + .globl tanf +tanf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_tanf.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 +..B1.2: + stmxcsr 16(%rsp) + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + jne .L_2TAG_PACKET_0.0.1 +.L_2TAG_PACKET_1.0.1: + pextrw $1, %xmm0, %eax + andw $32767, %ax + subw $128, %ax + cmpw $18175, %ax + ja .L_2TAG_PACKET_2.0.1 + movq PI_32_RECIP(%rip), %xmm1 + mulss %xmm0, %xmm1 + movapd BIT_31(%rip), %xmm7 + cvtss2si %xmm1, %edx + andpd %xmm0, %xmm7 + cvtss2sd %xmm0, %xmm0 + movq SHIFTER_16(%rip), %xmm4 + addss %xmm1, %xmm4 + addss SHIFTER(%rip), %xmm1 + subss SHIFTER_16(%rip), %xmm4 + subss SHIFTER(%rip), %xmm1 + movapd %xmm7, %xmm5 + psllq $32, %xmm7 + psllq $29, %xmm5 + xorpd %xmm5, %xmm7 + addl $1865216, %edx + movq PP_1(%rip), %xmm5 + xorpd %xmm7, %xmm5 + movq P_1(%rip), %xmm2 + xorpd %xmm7, %xmm2 + movq PP_2(%rip), %xmm6 + xorpd %xmm7, %xmm6 + movq P_2(%rip), %xmm3 + xorpd %xmm7, %xmm3 + lea Ctable(%rip), %rax + shll $3, %edx + andq $248, %rdx + addq %rdx, %rax + shlq $3, %rdx + addq %rdx, %rax + psllq $29, %xmm4 + psllq $29, %xmm1 + mulsd %xmm4, %xmm5 + mulsd %xmm1, %xmm2 + mulsd %xmm4, %xmm6 + mulsd %xmm1, %xmm3 + addsd %xmm0, %xmm5 + addsd %xmm0, %xmm2 + addsd %xmm6, %xmm5 + addsd %xmm3, %xmm2 + movq ONE(%rip), %xmm7 + divsd %xmm5, %xmm7 + mulsd 64(%rax), %xmm7 + movq 56(%rax), %xmm3 + mulsd %xmm2, %xmm3 + movq 24(%rax), %xmm4 + mulsd %xmm2, %xmm4 + movq 40(%rax), %xmm5 + mulsd %xmm2, %xmm5 + movq 8(%rax), %xmm6 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm2 + addsd 48(%rax), %xmm3 + addsd 16(%rax), %xmm4 + addsd 32(%rax), %xmm5 + addsd (%rax), %xmm6 + mulsd %xmm2, %xmm3 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm2 + addsd %xmm5, %xmm3 + addsd %xmm6, %xmm4 + mulsd %xmm2, %xmm3 + addsd %xmm4, %xmm3 + subsd %xmm7, %xmm3 + movsd %xmm3, %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + jne .L_2TAG_PACKET_3.0.1 + cvtsd2ss %xmm0, %xmm0 + jmp ..B1.6 +.L_2TAG_PACKET_2.0.1: + jg .L_2TAG_PACKET_4.0.1 + cvtss2sd %xmm0, %xmm0 + mulsd ONE_P230(%rip), %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + jne .L_2TAG_PACKET_3.0.1 + cvtsd2ss %xmm0, %xmm0 + jmp ..B1.6 +.L_2TAG_PACKET_4.0.1: + movd %xmm0, %eax + andl $2139095040, %eax + cmpl $2139095040, %eax + je .L_2TAG_PACKET_5.0.1 + cvtss2sd %xmm0, %xmm0 + movq %xmm0, (%rsp) +..B1.3: + movsd (%rsp), %xmm0 + call tan@PLT +..B1.9: + movsd %xmm0, 8(%rsp) +..B1.4: + movq 8(%rsp), %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + jne .L_2TAG_PACKET_3.0.1 + cvtsd2ss %xmm0, %xmm0 + jmp ..B1.6 +.L_2TAG_PACKET_5.0.1: + subss %xmm0, %xmm0 + movl 16(%rsp), %eax + andl $-24577, %eax + cmpl 16(%rsp), %eax + je .L_2TAG_PACKET_6.0.1 + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) +.L_2TAG_PACKET_6.0.1: + jmp ..B1.6 +.L_2TAG_PACKET_7.0.1: + cvtsd2ss %xmm0, %xmm0 + jmp ..B1.6 +.L_2TAG_PACKET_0.0.1: + movl %eax, 20(%rsp) + ldmxcsr 20(%rsp) + jmp .L_2TAG_PACKET_1.0.1 +.L_2TAG_PACKET_3.0.1: + stmxcsr 20(%rsp) + movl 16(%rsp), %eax + andl $24576, %eax + orl %eax, 20(%rsp) + ldmxcsr 20(%rsp) + jmp .L_2TAG_PACKET_7.0.1 +.L_2TAG_PACKET_8.0.1: +..B1.6: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type tanf,@function + .size tanf,.-tanf + .data +# -- End tanf + .section .rodata, "a" + .align 16 + .align 16 +BIT_31: + .long 2147483648 + .long 0 + .long 0 + .long 0 + .type BIT_31,@object + .size BIT_31,16 + .align 16 +PP_1: + .long 1413742592 + .long 4156105211 + .type PP_1,@object + .size PP_1,8 + .space 8, 0x00 # pad + .align 16 +P_1: + .long 1414004736 + .long 4156105211 + .type P_1,@object + .size P_1,8 + .space 8, 0x00 # pad + .align 16 +PP_2: + .long 1280075305 + .long 4115041315 + .type PP_2,@object + .size PP_2,8 + .space 8, 0x00 # pad + .align 16 +P_2: + .long 3409656221 + .long 1972279101 + .type P_2,@object + .size P_2,8 + .space 8, 0x00 # pad + .align 16 +Ctable: + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1431655765 + .long 1070945621 + .long 0 + .long 0 + .long 286331153 + .long 1069617425 + .long 0 + .long 0 + .long 463583772 + .long 1068212666 + .long 0 + .long 0 + .long 2354785698 + .long 1069102779 + .long 3310429884 + .long 1072703419 + .long 3693284251 + .long 1069118808 + .long 1996245381 + .long 1071000265 + .long 3055842593 + .long 1068578846 + .long 2269530157 + .long 1069711235 + .long 1046897440 + .long 1067705865 + .long 522045958 + .long 1068476590 + .long 0 + .long 0 + .long 3763679576 + .long 1070167541 + .long 404682282 + .long 1072734736 + .long 3593250296 + .long 1070233561 + .long 1127373050 + .long 1071173457 + .long 24583402 + .long 1069723988 + .long 3223889699 + .long 1070020367 + .long 558065897 + .long 1068949418 + .long 388873200 + .long 1068944270 + .long 0 + .long 0 + .long 895247324 + .long 1070819848 + .long 582494902 + .long 1072789737 + .long 3631919291 + .long 1070936926 + .long 2031366438 + .long 1071495745 + .long 1509038701 + .long 1070601643 + .long 3785344682 + .long 1070618476 + .long 3233018412 + .long 1069913186 + .long 1065584192 + .long 1069747896 + .long 0 + .long 0 + .long 2583490354 + .long 1071284857 + .long 855738471 + .long 1072873155 + .long 2616040238 + .long 1071582937 + .long 2529240549 + .long 1071836633 + .long 2251697184 + .long 1071253687 + .long 1263091857 + .long 1071190461 + .long 2476932470 + .long 1070842002 + .long 855891755 + .long 1070696894 + .long 0 + .long 0 + .long 419968236 + .long 1071717047 + .long 1813808633 + .long 1072992828 + .long 1037049034 + .long 1072037305 + .long 1447406859 + .long 1072265209 + .long 3205232916 + .long 1071968658 + .long 1066110976 + .long 1071946035 + .long 1496754229 + .long 1071807201 + .long 4014441989 + .long 1071736222 + .long 0 + .long 0 + .long 716700048 + .long 1071997368 + .long 274476850 + .long 1073161398 + .long 3912524733 + .long 1072622983 + .long 4107767972 + .long 1072827408 + .long 946523347 + .long 1072772766 + .long 581531518 + .long 1072826391 + .long 3718905905 + .long 1072832823 + .long 513572637 + .long 1072861969 + .long 0 + .long 0 + .long 719595600 + .long 1072317184 + .long 1194536594 + .long 1073399478 + .long 1264738763 + .long 1073084804 + .long 1958936600 + .long 1073411493 + .long 4270740730 + .long 1073574708 + .long 1303998552 + .long 1073799186 + .long 1769828046 + .long 1073938542 + .long 433361110 + .long 1074105369 + .long 0 + .long 0 + .long 0 + .long 1072693248 + .long 0 + .long 1073741824 + .long 0 + .long 1073741824 + .long 1431655765 + .long 1074091349 + .long 2863311531 + .long 1074440874 + .long 286331153 + .long 1074860305 + .long 95443718 + .long 1075163227 + .long 463583772 + .long 1075552698 + .long 0 + .long 0 + .long 1526324265 + .long 3217967566 + .long 457728975 + .long 1071088276 + .long 602185705 + .long 3215678092 + .long 555127889 + .long 1067545266 + .long 3690544014 + .long 3213150171 + .long 4003114407 + .long 1064581412 + .long 3759536023 + .long 3210559989 + .long 3837960785 + .long 1061790379 + .long 0 + .long 1072693248 + .long 719981842 + .long 3217669096 + .long 3749156607 + .long 1071048258 + .long 2754706541 + .long 3215359511 + .long 790323742 + .long 1067402587 + .long 4097292716 + .long 3212856302 + .long 2442796466 + .long 1064337602 + .long 170296152 + .long 3210060867 + .long 3614866008 + .long 1061361670 + .long 0 + .long 1072693248 + .long 701484222 + .long 3217377742 + .long 2267016812 + .long 1071015664 + .long 2223654598 + .long 3215071936 + .long 706390066 + .long 1067217386 + .long 1066252975 + .long 3212391267 + .long 3202745457 + .long 1064010682 + .long 1046243251 + .long 3209678971 + .long 2763962276 + .long 1060970161 + .long 0 + .long 1072693248 + .long 2829232582 + .long 3217092115 + .long 298675305 + .long 1070989821 + .long 1485063559 + .long 3214682643 + .long 3996381654 + .long 1067075828 + .long 2866066872 + .long 3211982662 + .long 3669764559 + .long 1063748136 + .long 1948234989 + .long 3209098147 + .long 3398041407 + .long 1060559728 + .long 0 + .long 1072693248 + .long 3593905368 + .long 3216590719 + .long 4076712227 + .long 1070970214 + .long 3144465176 + .long 3214191500 + .long 1618153340 + .long 1066971547 + .long 584032116 + .long 3211469261 + .long 4247487438 + .long 1063561943 + .long 3844233498 + .long 3208626322 + .long 3857199098 + .long 1060281647 + .long 0 + .long 1072693248 + .long 3789571175 + .long 3216034914 + .long 3870939386 + .long 1070956467 + .long 628750575 + .long 3213566872 + .long 2954464709 + .long 1066900026 + .long 1466315631 + .long 3210837162 + .long 2766187256 + .long 1063437894 + .long 3695969289 + .long 3207854418 + .long 3095830084 + .long 1060095334 + .long 0 + .long 1072693248 + .long 1858778712 + .long 3214984212 + .long 2242038011 + .long 1070948320 + .long 2507068734 + .long 3212502004 + .long 2446607349 + .long 1066858259 + .long 1349489537 + .long 3209765608 + .long 1721283327 + .long 1063366855 + .long 3852528092 + .long 3206760861 + .long 1758739894 + .long 1059895449 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1431655765 + .long 1070945621 + .long 0 + .long 0 + .long 381774871 + .long 1066844524 + .long 0 + .long 0 + .long 3154187623 + .long 1063343722 + .long 0 + .long 0 + .long 2469719819 + .long 1059831159 + .long 0 + .long 1072693248 + .long 1858778712 + .long 1067500564 + .long 2242038011 + .long 1070948320 + .long 2507068734 + .long 1065018356 + .long 2446607349 + .long 1066858259 + .long 1349489537 + .long 1062281960 + .long 1721283327 + .long 1063366855 + .long 3852528092 + .long 1059277213 + .long 1758739894 + .long 1059895449 + .long 0 + .long 1072693248 + .long 3789571175 + .long 1068551266 + .long 3870939386 + .long 1070956467 + .long 628750575 + .long 1066083224 + .long 2954464709 + .long 1066900026 + .long 1466315631 + .long 1063353514 + .long 2766187256 + .long 1063437894 + .long 3695969289 + .long 1060370770 + .long 3095830084 + .long 1060095334 + .long 0 + .long 1072693248 + .long 3593905368 + .long 1069107071 + .long 4076712227 + .long 1070970214 + .long 3144465176 + .long 1066707852 + .long 1618153340 + .long 1066971547 + .long 584032116 + .long 1063985613 + .long 4247487438 + .long 1063561943 + .long 3844233498 + .long 1061142674 + .long 3857199098 + .long 1060281647 + .long 0 + .long 1072693248 + .long 2829232582 + .long 1069608467 + .long 298675305 + .long 1070989821 + .long 1485063559 + .long 1067198995 + .long 3996381654 + .long 1067075828 + .long 2866066872 + .long 1064499014 + .long 3669764559 + .long 1063748136 + .long 1948234989 + .long 1061614499 + .long 3398041407 + .long 1060559728 + .long 0 + .long 1072693248 + .long 701484222 + .long 1069894094 + .long 2267016812 + .long 1071015664 + .long 2223654598 + .long 1067588288 + .long 706390066 + .long 1067217386 + .long 1066252975 + .long 1064907619 + .long 3202745457 + .long 1064010682 + .long 1046243251 + .long 1062195323 + .long 2763962276 + .long 1060970161 + .long 0 + .long 1072693248 + .long 719981842 + .long 1070185448 + .long 3749156607 + .long 1071048258 + .long 2754706541 + .long 1067875863 + .long 790323742 + .long 1067402587 + .long 4097292716 + .long 1065372654 + .long 2442796466 + .long 1064337602 + .long 170296152 + .long 1062577219 + .long 3614866008 + .long 1061361670 + .long 0 + .long 1072693248 + .long 1526324265 + .long 1070483918 + .long 457728975 + .long 1071088276 + .long 602185705 + .long 1068194444 + .long 555127889 + .long 1067545266 + .long 3690544014 + .long 1065666523 + .long 4003114407 + .long 1064581412 + .long 3759536023 + .long 1063076341 + .long 3837960785 + .long 1061790379 + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .long 0 + .long 1073741824 + .long 0 + .long 3221225472 + .long 1431655765 + .long 1074091349 + .long 2863311531 + .long 3221924522 + .long 286331153 + .long 1074860305 + .long 95443718 + .long 3222646875 + .long 463583772 + .long 1075552698 + .long 0 + .long 0 + .long 719595600 + .long 3219800832 + .long 1194536594 + .long 1073399478 + .long 1264738763 + .long 3220568452 + .long 1958936600 + .long 1073411493 + .long 4270740730 + .long 3221058356 + .long 1303998552 + .long 1073799186 + .long 1769828046 + .long 3221422190 + .long 433361110 + .long 1074105369 + .long 0 + .long 0 + .long 716700048 + .long 3219481016 + .long 274476850 + .long 1073161398 + .long 3912524733 + .long 3220106631 + .long 4107767972 + .long 1072827408 + .long 946523347 + .long 3220256414 + .long 581531518 + .long 1072826391 + .long 3718905905 + .long 3220316471 + .long 513572637 + .long 1072861969 + .long 0 + .long 0 + .long 419968236 + .long 3219200695 + .long 1813808633 + .long 1072992828 + .long 1037049034 + .long 3219520953 + .long 1447406859 + .long 1072265209 + .long 3205232916 + .long 3219452306 + .long 1066110976 + .long 1071946035 + .long 1496754229 + .long 3219290849 + .long 4014441989 + .long 1071736222 + .long 0 + .long 0 + .long 2583490354 + .long 3218768505 + .long 855738471 + .long 1072873155 + .long 2616040238 + .long 3219066585 + .long 2529240549 + .long 1071836633 + .long 2251697184 + .long 3218737335 + .long 1263091857 + .long 1071190461 + .long 2476932470 + .long 3218325650 + .long 855891755 + .long 1070696894 + .long 0 + .long 0 + .long 895247324 + .long 3218303496 + .long 582494902 + .long 1072789737 + .long 3631919291 + .long 3218420574 + .long 2031366438 + .long 1071495745 + .long 1509038701 + .long 3218085291 + .long 3785344682 + .long 1070618476 + .long 3233018412 + .long 3217396834 + .long 1065584192 + .long 1069747896 + .long 0 + .long 0 + .long 3763679576 + .long 3217651189 + .long 404682282 + .long 1072734736 + .long 3593250296 + .long 3217717209 + .long 1127373050 + .long 1071173457 + .long 24583402 + .long 3217207636 + .long 3223889699 + .long 1070020367 + .long 558065897 + .long 3216433066 + .long 388873200 + .long 1068944270 + .long 0 + .long 0 + .long 2354785698 + .long 3216586427 + .long 3310429884 + .long 1072703419 + .long 3693284251 + .long 3216602456 + .long 1996245381 + .long 1071000265 + .long 3055842593 + .long 3216062494 + .long 2269530157 + .long 1069711235 + .long 1046897440 + .long 3215189513 + .long 522045958 + .long 1068476590 + .long 0 + .long 0 + .type Ctable,@object + .size Ctable,2304 + .align 16 +ONE: + .long 0 + .long 1072693248 + .type ONE,@object + .size ONE,8 + .space 8, 0x00 # pad + .align 16 +ONE_P230: + .long 4194304 + .long 1072693248 + .type ONE_P230,@object + .size ONE_P230,8 + .align 8 +PI_32_RECIP: + .long 1092811139 + .long 0 + .type PI_32_RECIP,@object + .size PI_32_RECIP,8 + .align 8 +SHIFTER_16: + .long 1296039936 + .long 0 + .type SHIFTER_16,@object + .size SHIFTER_16,8 + .align 4 +SHIFTER: + .long 1262485504 + .type SHIFTER,@object + .size SHIFTER,4 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tanh_gen.S b/external/sgx_libm/intel64/tanh_gen.S new file mode 100644 index 0000000000..208a8d01ee --- /dev/null +++ b/external/sgx_libm/intel64/tanh_gen.S @@ -0,0 +1,501 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanh_gen.c" + .text +..TXTST0: +# -- Begin tanh + .text + .align 16,0x90 + .globl tanh +tanh: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_tanh.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %eax + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $2146435072, %ecx + jae ..B1.16 +..B1.2: + cmpl $1077088193, %ecx + jae ..B1.15 +..B1.3: + cmpl $1075078759, %ecx + jae ..B1.14 +..B1.4: + cmpl $1066695393, %ecx + jae ..B1.13 +..B1.5: + cmpl $1012924416, %ecx + jae ..B1.12 +..B1.6: + shrl $31, %eax + cmpl $1048576, %ecx + jb ..B1.8 +..B1.7: + movl %eax, %eax + lea _small_value_64(%rip), %rdx + movsd (%rdx,%rax,8), %xmm1 + mulsd (%rdx), %xmm1 + subsd %xmm1, %xmm0 + ret +..B1.8: + movl -8(%rsp), %edx + orl %edx, %ecx + je ..B1.10 +..B1.9: + lea _small_value_64(%rip), %rdx + movsd -8(%rsp), %xmm0 + movsd (%rdx,%rax,8), %xmm1 + mulsd (%rdx), %xmm1 + movsd %xmm1, -32(%rsp) + subsd %xmm1, %xmm0 + ret +..B1.10: + movsd -8(%rsp), %xmm0 +..B1.11: + ret +..B1.12: + movsd -8(%rsp), %xmm4 + movaps %xmm4, %xmm2 + mulsd %xmm4, %xmm2 + movaps %xmm2, %xmm1 + mulsd %xmm2, %xmm1 + movsd .L_2il0floatpacket.20(%rip), %xmm0 + movsd .L_2il0floatpacket.22(%rip), %xmm3 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm3 + addsd .L_2il0floatpacket.21(%rip), %xmm0 + addsd .L_2il0floatpacket.23(%rip), %xmm3 + mulsd %xmm1, %xmm0 + mulsd %xmm2, %xmm3 + addsd %xmm3, %xmm0 + mulsd %xmm4, %xmm0 + addsd %xmm4, %xmm0 + ret +..B1.13: + movsd -8(%rsp), %xmm0 + lea _TWO_52(%rip), %rdx + andps .L_2il0floatpacket.24(%rip), %xmm0 + xorl %r10d, %r10d + mulsd .L_2il0floatpacket.10(%rip), %xmm0 + movq $0x3ff0000000000000, %rsi + movsd .L_2il0floatpacket.11(%rip), %xmm4 + lea _TWO_32(%rip), %r9 + mulsd %xmm0, %xmm4 + lea ones(%rip), %r11 + movsd .L_2il0floatpacket.12(%rip), %xmm5 + movsd .L_2il0floatpacket.13(%rip), %xmm6 + movsd .L_2il0floatpacket.25(%rip), %xmm3 + movaps %xmm3, %xmm8 + addsd (%rdx), %xmm4 + movsd %xmm4, -32(%rsp) + movsd -32(%rsp), %xmm7 + movsd .L_2il0floatpacket.15(%rip), %xmm12 + movsd .L_2il0floatpacket.17(%rip), %xmm14 + movsd .L_2il0floatpacket.14(%rip), %xmm2 + movaps %xmm2, %xmm9 + subsd (%rdx), %xmm7 + mulsd %xmm7, %xmm5 + mulsd %xmm6, %xmm7 + subsd %xmm5, %xmm0 + movaps %xmm0, %xmm10 + movaps %xmm3, %xmm6 + movl -32(%rsp), %ecx + movl %ecx, %edi + shll $25, %edi + subsd %xmm7, %xmm10 + movaps %xmm10, %xmm11 + subsd %xmm10, %xmm0 + addsd %xmm10, %xmm8 + subsd %xmm7, %xmm0 + movsd %xmm8, -40(%rsp) + addsd %xmm0, %xmm11 + movaps %xmm11, %xmm13 + mulsd %xmm11, %xmm13 + mulsd %xmm13, %xmm12 + mulsd %xmm13, %xmm14 + addsd .L_2il0floatpacket.16(%rip), %xmm12 + addsd .L_2il0floatpacket.18(%rip), %xmm14 + mulsd %xmm13, %xmm12 + mulsd %xmm13, %xmm14 + mulsd %xmm11, %xmm12 + addsd .L_2il0floatpacket.19(%rip), %xmm14 + movl %r10d, -40(%rsp) + movsd -40(%rsp), %xmm4 + mulsd %xmm13, %xmm14 + addsd %xmm4, %xmm9 + sarl $25, %edi + subsd %xmm9, %xmm10 + subl %edi, %ecx + addsd %xmm10, %xmm0 + movslq %edi, %rdi + addsd %xmm12, %xmm0 + shlq $4, %rdi + addsd %xmm14, %xmm0 + movq __libm_exp_table_128@GOTPCREL(%rip), %r8 + shrl $7, %ecx + movsd (%r9), %xmm5 + movsd 1032(%r8,%rdi), %xmm15 + movaps %xmm15, %xmm1 + mulsd %xmm0, %xmm1 + addsd %xmm4, %xmm0 + mulsd %xmm15, %xmm4 + mulsd 1024(%r8,%rdi), %xmm0 + shlq $52, %rcx + addsd %xmm0, %xmm1 + addq %rsi, %rcx + movaps %xmm2, %xmm0 + movq %rcx, -16(%rsp) + movsd -16(%rsp), %xmm7 + mulsd %xmm7, %xmm1 + mulsd %xmm4, %xmm7 + movaps %xmm7, %xmm10 + addsd %xmm7, %xmm0 + addsd %xmm7, %xmm6 + addsd (%r9), %xmm0 + addsd %xmm5, %xmm6 + movsd %xmm0, -32(%rsp) + movsd -32(%rsp), %xmm0 + movsd %xmm6, -32(%rsp) + subsd %xmm5, %xmm0 + movsd -32(%rsp), %xmm9 + subsd %xmm0, %xmm10 + subsd (%r9), %xmm9 + addsd %xmm2, %xmm10 + movsd %xmm7, -40(%rsp) + movaps %xmm9, %xmm8 + shrl $31, %eax + subsd %xmm9, %xmm7 + addsd %xmm1, %xmm10 + addsd %xmm3, %xmm7 + movsd (%r11,%rax,8), %xmm12 + addsd %xmm7, %xmm1 + addsd %xmm1, %xmm8 + divsd %xmm8, %xmm3 + movsd %xmm3, -24(%rsp) + movl %r10d, -24(%rsp) + movsd -24(%rsp), %xmm11 + mulsd %xmm11, %xmm1 + subsd %xmm11, %xmm3 + mulsd %xmm11, %xmm9 + mulsd %xmm3, %xmm8 + addsd %xmm2, %xmm9 + addsd %xmm8, %xmm1 + movaps %xmm11, %xmm2 + addsd %xmm1, %xmm9 + addsd %xmm3, %xmm2 + mulsd %xmm9, %xmm2 + movaps %xmm0, %xmm1 + mulsd %xmm11, %xmm0 + subsd %xmm2, %xmm3 + mulsd %xmm3, %xmm1 + addsd %xmm11, %xmm3 + mulsd %xmm3, %xmm10 + movsd %xmm0, -8(%rsp) + addsd %xmm10, %xmm1 + mulsd %xmm12, %xmm0 + mulsd %xmm1, %xmm12 + addsd %xmm12, %xmm0 + ret +..B1.14: + lea _TWO_32(%rip), %rdx + lea _TWO_52(%rip), %rcx + movsd -8(%rsp), %xmm1 + movq $0x3ff0000000000000, %rsi + andps .L_2il0floatpacket.24(%rip), %xmm1 + lea twos(%rip), %r8 + movsd .L_2il0floatpacket.0(%rip), %xmm3 + movaps %xmm1, %xmm7 + movsd (%rdx), %xmm0 + lea ones(%rip), %r9 + movsd (%rcx), %xmm4 + addsd %xmm1, %xmm0 + movsd %xmm0, -32(%rsp) + movsd -32(%rsp), %xmm6 + movsd .L_2il0floatpacket.1(%rip), %xmm2 + mulsd %xmm1, %xmm2 + subsd (%rdx), %xmm6 + movsd .L_2il0floatpacket.2(%rip), %xmm12 + subsd %xmm6, %xmm7 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm7 + addsd %xmm6, %xmm4 + addsd %xmm2, %xmm7 + movsd %xmm4, -32(%rsp) + movsd -32(%rsp), %xmm5 + movsd .L_2il0floatpacket.6(%rip), %xmm9 + movsd .L_2il0floatpacket.25(%rip), %xmm11 + movslq -32(%rsp), %rdi + shlq $52, %rdi + subsd (%rcx), %xmm5 + addq %rsi, %rdi + subsd %xmm5, %xmm6 + movq %rdi, -16(%rsp) + addsd %xmm6, %xmm7 + movaps %xmm7, %xmm8 + mulsd %xmm7, %xmm8 + mulsd %xmm8, %xmm12 + mulsd %xmm8, %xmm9 + addsd .L_2il0floatpacket.3(%rip), %xmm12 + addsd .L_2il0floatpacket.7(%rip), %xmm9 + mulsd %xmm8, %xmm12 + mulsd %xmm8, %xmm9 + addsd .L_2il0floatpacket.4(%rip), %xmm12 + addsd .L_2il0floatpacket.8(%rip), %xmm9 + mulsd %xmm8, %xmm12 + mulsd %xmm8, %xmm9 + addsd .L_2il0floatpacket.5(%rip), %xmm12 + addsd .L_2il0floatpacket.9(%rip), %xmm9 + mulsd %xmm7, %xmm12 + movsd -16(%rsp), %xmm10 + subsd %xmm12, %xmm9 + divsd %xmm9, %xmm12 + mulsd .L_2il0floatpacket.10(%rip), %xmm12 + shrl $31, %eax + addsd %xmm11, %xmm12 + movl %eax, %r10d + movsd %xmm12, -24(%rsp) + xorl $1, %eax + mulsd %xmm10, %xmm12 + movsd (%r8,%rax,8), %xmm0 + addsd %xmm11, %xmm12 + divsd %xmm12, %xmm0 + movsd %xmm7, -8(%rsp) + addsd (%r9,%r10,8), %xmm0 + ret +..B1.15: + lea ones(%rip), %rdx + lea _small_value_64(%rip), %rcx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm0 + subsd (%rcx,%rax,8), %xmm0 + ret +..B1.16: + andl $-2146435073, %ecx + orl -8(%rsp), %ecx + jne ..B1.18 +..B1.17: + lea ones(%rip), %rdx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm0 + ret +..B1.18: + movsd -8(%rsp), %xmm0 +..B1.19: + ret + .align 16,0x90 + .cfi_endproc + .type tanh,@function + .size tanh,.-tanh + .data +# -- End tanh + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.24: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.24,@object + .size .L_2il0floatpacket.24,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x60000000,0x40071547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0xf85ddf44,0x3e64ae0b + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.2: + .long 0xfc0798c2,0x3fb3adff + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x0e243699,0x406e3d92 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0xefbe8c98,0x40f689a6 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x1ba09c9e,0x4156de47 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0xa57ad784,0x4018d7c2 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0x63529aa4,0x40b6b90b + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0xafc4d247,0x412d4376 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x41707ef8 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0x652b82fe,0x40671547 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x00000000,0x3f762e42 + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x3de6af28,0x3e2fdf47 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0x00000000,0xbff00000 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 8 +.L_2il0floatpacket.15: + .long 0x6887cd7c,0x3f811111 + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,8 + .align 8 +.L_2il0floatpacket.16: + .long 0x55555405,0x3fc55555 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,8 + .align 8 +.L_2il0floatpacket.17: + .long 0x87372663,0x3f56c16c + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,8 + .align 8 +.L_2il0floatpacket.18: + .long 0x5555541d,0x3fa55555 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,8 + .align 8 +.L_2il0floatpacket.19: + .long 0x00000000,0x3fe00000 + .type .L_2il0floatpacket.19,@object + .size .L_2il0floatpacket.19,8 + .align 8 +.L_2il0floatpacket.20: + .long 0xbe3b77e0,0x3f9662a1 + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,8 + .align 8 +.L_2il0floatpacket.21: + .long 0x1110d2a4,0x3fc11111 + .type .L_2il0floatpacket.21,@object + .size .L_2il0floatpacket.21,8 + .align 8 +.L_2il0floatpacket.22: + .long 0x00fa2d61,0xbfaba1ba + .type .L_2il0floatpacket.22,@object + .size .L_2il0floatpacket.22,8 + .align 8 +.L_2il0floatpacket.23: + .long 0x55555555,0xbfd55555 + .type .L_2il0floatpacket.23,@object + .size .L_2il0floatpacket.23,8 + .align 8 +.L_2il0floatpacket.25: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.25,@object + .size .L_2il0floatpacket.25,8 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 8 +twos: + .long 0x00000000,0x40000000 + .long 0x00000000,0xc0000000 + .type twos,@object + .size twos,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_TWO_52: + .long 0 + .long 1127219200 + .type _TWO_52,@object + .size _TWO_52,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tanhf_gen.S b/external/sgx_libm/intel64/tanhf_gen.S new file mode 100644 index 0000000000..fa590bb2e1 --- /dev/null +++ b/external/sgx_libm/intel64/tanhf_gen.S @@ -0,0 +1,419 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanhf_gen.c" + .text +..TXTST0: +# -- Begin tanhf + .text + .align 16,0x90 + .globl tanhf +tanhf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_tanhf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + movl %edx, %eax + andl $2147483647, %eax + cmpl $1098907648, %eax + jae ..B1.15 +..B1.2: + cmpl $1065353216, %eax + jae ..B1.14 +..B1.3: + cmpl $1048576000, %eax + jae ..B1.12 +..B1.4: + cmpl $838860800, %eax + jae ..B1.11 +..B1.5: + shrl $31, %edx + cmpl $8388608, %eax + jb ..B1.7 +..B1.6: + movl %edx, %edx + lea _small_value_32(%rip), %rax + movss (%rax,%rdx,4), %xmm1 + mulss .L_2il0floatpacket.28(%rip), %xmm1 + subss %xmm1, %xmm0 + ret +..B1.7: + testl %eax, %eax + je ..B1.9 +..B1.8: + lea _small_value_32(%rip), %rax + pxor %xmm2, %xmm2 + pxor %xmm1, %xmm1 + cvtss2sd -8(%rsp), %xmm2 + movss (%rax,%rdx,4), %xmm0 + mulss .L_2il0floatpacket.28(%rip), %xmm0 + cvtss2sd %xmm0, %xmm0 + cvtsd2ss %xmm0, %xmm1 + subsd %xmm0, %xmm2 + pxor %xmm0, %xmm0 + movss %xmm1, -16(%rsp) + cvtsd2ss %xmm2, %xmm0 + ret +..B1.9: + movss -8(%rsp), %xmm0 +..B1.10: + ret +..B1.11: + pxor %xmm3, %xmm3 + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.22(%rip), %xmm4 + movsd .L_2il0floatpacket.25(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.23(%rip), %xmm4 + addsd .L_2il0floatpacket.26(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.24(%rip), %xmm4 + addsd .L_2il0floatpacket.27(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm3, %xmm4 + jmp ..B1.13 +..B1.12: + pxor %xmm3, %xmm3 + cvtss2sd -8(%rsp), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 + movsd .L_2il0floatpacket.12(%rip), %xmm4 + movsd .L_2il0floatpacket.17(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.13(%rip), %xmm4 + addsd .L_2il0floatpacket.18(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.14(%rip), %xmm4 + addsd .L_2il0floatpacket.19(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.15(%rip), %xmm4 + addsd .L_2il0floatpacket.20(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm0, %xmm2 + addsd .L_2il0floatpacket.16(%rip), %xmm4 + addsd .L_2il0floatpacket.21(%rip), %xmm2 + mulsd %xmm0, %xmm4 + mulsd %xmm1, %xmm2 + addsd %xmm2, %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm3, %xmm4 +..B1.13: + cvtsd2ss %xmm4, %xmm4 + movaps %xmm4, %xmm0 + ret +..B1.14: + pxor %xmm5, %xmm5 + movq $0x3ff0000000000000, %rax + cvtss2sd -8(%rsp), %xmm5 + andps .L_2il0floatpacket.29(%rip), %xmm5 + mulsd .L_2il0floatpacket.0(%rip), %xmm5 + movsd .L_2il0floatpacket.1(%rip), %xmm0 + movsd .L_2il0floatpacket.8(%rip), %xmm7 + addsd %xmm5, %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, -16(%rsp) + movss -16(%rsp), %xmm1 + movsd .L_2il0floatpacket.4(%rip), %xmm8 + movsd .L_2il0floatpacket.6(%rip), %xmm2 + movsd .L_2il0floatpacket.10(%rip), %xmm6 + movsd .L_2il0floatpacket.30(%rip), %xmm9 + movl -16(%rsp), %edx + shlq $52, %rdx + subss .L_2il0floatpacket.2(%rip), %xmm1 + cvtss2sd %xmm1, %xmm1 + addq %rax, %rdx + subsd %xmm1, %xmm5 + movaps %xmm5, %xmm3 + mulsd %xmm5, %xmm3 + movaps %xmm3, %xmm4 + mulsd %xmm3, %xmm4 + mulsd %xmm4, %xmm7 + mulsd %xmm4, %xmm8 + mulsd %xmm4, %xmm2 + addsd .L_2il0floatpacket.9(%rip), %xmm7 + mulsd %xmm4, %xmm6 + addsd .L_2il0floatpacket.5(%rip), %xmm8 + addsd .L_2il0floatpacket.7(%rip), %xmm2 + mulsd %xmm3, %xmm7 + addsd .L_2il0floatpacket.11(%rip), %xmm6 + mulsd %xmm4, %xmm8 + mulsd %xmm3, %xmm2 + mulsd %xmm5, %xmm7 + mulsd %xmm5, %xmm6 + addsd %xmm2, %xmm8 + addsd %xmm6, %xmm7 + movq %rdx, -24(%rsp) + addsd %xmm7, %xmm8 + movsd .L_2il0floatpacket.3(%rip), %xmm10 + addsd %xmm9, %xmm8 + mulsd -24(%rsp), %xmm8 + testl $-2147483648, -8(%rsp) + addsd %xmm9, %xmm8 + divsd %xmm8, %xmm10 + subsd %xmm10, %xmm9 + movaps %xmm9, %xmm0 + xorps .L_2il0floatpacket.31(%rip), %xmm0 + jne ..L3 + movaps %xmm9, %xmm0 +..L3: + cvtsd2ss %xmm0, %xmm0 + ret +..B1.15: + shrl $31, %edx + cmpl $2139095040, %eax + jb ..B1.20 +..B1.16: + jne ..B1.18 +..B1.17: + movl %edx, %edx + lea ones(%rip), %rax + movss (%rax,%rdx,4), %xmm0 + ret +..B1.18: + movss -8(%rsp), %xmm0 +..B1.19: + ret +..B1.20: + lea ones(%rip), %rax + lea _small_value_32(%rip), %rcx + movss (%rax,%rdx,4), %xmm0 + subss (%rcx,%rdx,4), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type tanhf,@function + .size tanhf,.-tanhf + .data +# -- End tanhf + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.29: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.29,@object + .size .L_2il0floatpacket.29,16 + .align 16 +.L_2il0floatpacket.31: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.31,@object + .size .L_2il0floatpacket.31,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x652b82fe,0x40071547 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x41600000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.3: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x55f6ce44,0x3eb67839 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 8 +.L_2il0floatpacket.5: + .long 0x17eb7c1b,0x3f83b2ac + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,8 + .align 8 +.L_2il0floatpacket.6: + .long 0x5a9238ae,0x3f24300f + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,8 + .align 8 +.L_2il0floatpacket.7: + .long 0xfe8df8b5,0x3fcebfbd + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x97a846d7,0x3ef0355a + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0xb399a1da,0x3fac6b09 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x2d719ac7,0x3f55d7f6 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 8 +.L_2il0floatpacket.11: + .long 0xfe8bdf78,0x3fe62e42 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,8 + .align 8 +.L_2il0floatpacket.12: + .long 0x8d21df9d,0x3eed02fa + .type .L_2il0floatpacket.12,@object + .size .L_2il0floatpacket.12,8 + .align 8 +.L_2il0floatpacket.13: + .long 0x4a9bd1ce,0x3f3d92d7 + .type .L_2il0floatpacket.13,@object + .size .L_2il0floatpacket.13,8 + .align 8 +.L_2il0floatpacket.14: + .long 0x4b00cfe8,0x3f6d0411 + .type .L_2il0floatpacket.14,@object + .size .L_2il0floatpacket.14,8 + .align 8 +.L_2il0floatpacket.15: + .long 0x616f3508,0x3f96640f + .type .L_2il0floatpacket.15,@object + .size .L_2il0floatpacket.15,8 + .align 8 +.L_2il0floatpacket.16: + .long 0xd4e5c3b2,0x3fc11110 + .type .L_2il0floatpacket.16,@object + .size .L_2il0floatpacket.16,8 + .align 8 +.L_2il0floatpacket.17: + .long 0x112b299f,0xbf1cd749 + .type .L_2il0floatpacket.17,@object + .size .L_2il0floatpacket.17,8 + .align 8 +.L_2il0floatpacket.18: + .long 0x6388aa74,0xbf563031 + .type .L_2il0floatpacket.18,@object + .size .L_2il0floatpacket.18,8 + .align 8 +.L_2il0floatpacket.19: + .long 0xd81e0536,0xbf821e4b + .type .L_2il0floatpacket.19,@object + .size .L_2il0floatpacket.19,8 + .align 8 +.L_2il0floatpacket.20: + .long 0xdc3e3757,0xbfaba1ab + .type .L_2il0floatpacket.20,@object + .size .L_2il0floatpacket.20,8 + .align 8 +.L_2il0floatpacket.21: + .long 0x547e4ef2,0xbfd55555 + .type .L_2il0floatpacket.21,@object + .size .L_2il0floatpacket.21,8 + .align 8 +.L_2il0floatpacket.22: + .long 0x7be81b29,0x3f6ab4a5 + .type .L_2il0floatpacket.22,@object + .size .L_2il0floatpacket.22,8 + .align 8 +.L_2il0floatpacket.23: + .long 0x9dbd8fad,0x3f966488 + .type .L_2il0floatpacket.23,@object + .size .L_2il0floatpacket.23,8 + .align 8 +.L_2il0floatpacket.24: + .long 0x0f94d287,0x3fc11111 + .type .L_2il0floatpacket.24,@object + .size .L_2il0floatpacket.24,8 + .align 8 +.L_2il0floatpacket.25: + .long 0xa5e0a14a,0xbf821629 + .type .L_2il0floatpacket.25,@object + .size .L_2il0floatpacket.25,8 + .align 8 +.L_2il0floatpacket.26: + .long 0x983e34ea,0xbfaba1b8 + .type .L_2il0floatpacket.26,@object + .size .L_2il0floatpacket.26,8 + .align 8 +.L_2il0floatpacket.27: + .long 0x5553e1cf,0xbfd55555 + .type .L_2il0floatpacket.27,@object + .size .L_2il0floatpacket.27,8 + .align 8 +.L_2il0floatpacket.30: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.30,@object + .size .L_2il0floatpacket.30,8 + .align 4 +.L_2il0floatpacket.2: + .long 0x4b000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.28: + .long 0x0d800000 + .type .L_2il0floatpacket.28,@object + .size .L_2il0floatpacket.28,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +ones: + .long 0x3f800000 + .long 0xbf800000 + .type ones,@object + .size ones,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tanhl.S b/external/sgx_libm/intel64/tanhl.S new file mode 100644 index 0000000000..89bc17c931 --- /dev/null +++ b/external/sgx_libm/intel64/tanhl.S @@ -0,0 +1,1042 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanhl.c" + .text +..TXTST0: +# -- Begin tanhl + .text + .align 16,0x90 + .globl tanhl +tanhl: +# parameter 1: 64 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_tanhl.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + xorb %dil, %dil +..B1.2: + fnstcw 50(%rsp) +..B1.3: + movb 73(%rsp), %al + andb $-128, %al + shrb $7, %al + movzwl 72(%rsp), %ecx + andl $32767, %ecx + movzbl %al, %esi + cmpl $16388, %ecx + movzwl 50(%rsp), %eax + jge ..B1.57 +..B1.4: + cmpl $16382, %ecx + jge ..B1.46 +..B1.5: + cmpl $16376, %ecx + jge ..B1.39 +..B1.6: + cmpl $16371, %ecx + jge ..B1.32 +..B1.7: + cmpl $16365, %ecx + jge ..B1.25 +..B1.8: + cmpl $16308, %ecx + jge ..B1.18 +..B1.9: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.13 +..B1.10: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.11: + fldcw 48(%rsp) +..B1.12: + movzwl 72(%rsp), %ecx + movb $1, %dil + andl $32767, %ecx +..B1.13: + testl %ecx, %ecx + jle ..B1.66 +..B1.14: + fldt 64(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rdx + fldl (%rax) + fmul %st(1), %st + fsubp %st, %st(1) + fmull (%rdx) + fstpt (%rsp) +..B1.15: + testb %dil, %dil + je ..B1.17 +..B1.16: + fldcw 50(%rsp) +..B1.17: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.18: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.22 +..B1.19: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.20: + fldcw 48(%rsp) +..B1.21: + movb $1, %dil +..B1.22: + fldt 64(%rsp) + lea _Q3(%rip), %rax + testb %dil, %dil + fldt (%rax) + fmul %st(1), %st + fmul %st(1), %st + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.24 +..B1.23: + fldcw 50(%rsp) +..B1.24: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.25: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.29 +..B1.26: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.27: + fldcw 48(%rsp) +..B1.28: + movb $1, %dil +..B1.29: + fldt 64(%rsp) + lea 16+_Q2(%rip), %rax + fld %st(0) + lea _Q2(%rip), %rdx + fmul %st(1), %st + testb %dil, %dil + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.31 +..B1.30: + fldcw 50(%rsp) +..B1.31: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.32: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.36 +..B1.33: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.34: + fldcw 48(%rsp) +..B1.35: + movb $1, %dil +..B1.36: + fldt 64(%rsp) + lea 48+_Q1(%rip), %rax + fld %st(0) + lea 32+_Q1(%rip), %rcx + fmul %st(1), %st + lea 16+_Q1(%rip), %rdx + fld %st(0) + lea _Q1(%rip), %rsi + fmul %st(1), %st + testb %dil, %dil + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + fmulp %st, %st(2) + fldt (%rsi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt (%rsp) + je ..B1.38 +..B1.37: + fldcw 50(%rsp) +..B1.38: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.39: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.43 +..B1.40: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.41: + fldcw 48(%rsp) +..B1.42: + movb $1, %dil +..B1.43: + fldt 64(%rsp) + lea _TWO_52H(%rip), %rax + fld %st(0) + fld %st(1) + fld %st(2) + lea 240+_Q(%rip), %rdx + fmul %st(3), %st + lea 208+_Q(%rip), %rcx + fld %st(0) + lea 176+_Q(%rip), %rsi + fmul %st(1), %st + lea 144+_Q(%rip), %r8 + fldl (%rax) + lea 112+_Q(%rip), %r9 + fmul %st(5), %st + lea 80+_Q(%rip), %r10 + lea 48+_Q(%rip), %r11 + lea 16+_Q(%rip), %rax + testb %dil, %dil + fadd %st, %st(4) + fsubrp %st, %st(4) + fld %st(3) + fxch %st(3) + fsub %st(4), %st + fmul %st, %st(3) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(3) + fld %st(2) + fmul %st(2), %st + fxch %st(4) + fstpt (%rsp) + fldt (%rsp) + fmul %st(0), %st + fstpt 32(%rsp) + fldt 32(%rsp) + fxch %st(5) + fstpt 16(%rsp) + fld %st(2) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(4) + fmul %st(0), %st + fldt (%rdx) + lea 224+_Q(%rip), %rdx + fmul %st(5), %st + fldt (%rcx) + lea 192+_Q(%rip), %rcx + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rsi) + lea 160+_Q(%rip), %rsi + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r8) + lea 128+_Q(%rip), %r8 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r9) + lea 96+_Q(%rip), %r9 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r10) + lea 64+_Q(%rip), %r10 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%r11) + lea 32+_Q(%rip), %r11 + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rax) + lea _Q(%rip), %rax + faddp %st, %st(1) + fmul %st(5), %st + fldt (%rdx) + lea 272+_Q(%rip), %rdx + fmul %st(6), %st + fldt (%rcx) + lea 256+_Q(%rip), %rcx + faddp %st, %st(1) + fmul %st(6), %st + fldt (%rsi) + lea _TWO_48H(%rip), %rsi + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(6), %st + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(6) + fldt (%rax) + faddp %st, %st(6) + fxch %st(2) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fldt (%rdx) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fxch %st(3) + fmulp %st, %st(2) + fldt (%rcx) + fmul %st, %st(1) + fxch %st(1) + faddp %st, %st(3) + fldt 32(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt 16(%rsp) + fld %st(0) + fldl (%rsi) + fld %st(0) + fadd %st(4), %st + fsub %st, %st(1) + fxch %st(1) + fmul %st, %st(2) + fsubr %st, %st(4) + fxch %st(5) + faddp %st, %st(4) + fldt 64(%rsp) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldt (%rsp) + fmul %st, %st(3) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + je ..B1.80 +..B1.44: + fstpt 16(%rsp) +..B1.79: + fldcw 50(%rsp) + jmp ..B1.45 +..B1.80: + fstp %st(0) +..B1.45: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.46: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.50 +..B1.47: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.48: + fldcw 48(%rsp) +..B1.49: + movzwl 72(%rsp), %ecx + movb $1, %dil + andl $32767, %ecx +..B1.50: + fldt 64(%rsp) + lea twos(%rip), %r8 + fldt .L_2il0floatpacket.0(%rip) + lea _TWO_63H(%rip), %r9 + fstpt 32(%rsp) + lea _TWO_32(%rip), %r10 + fldt .L_2il0floatpacket.1(%rip) + lea _TWO_32P(%rip), %r11 + fxch %st(1) + fmull (%r8,%rsi,8) + lea 64+_P(%rip), %r8 + fmul %st, %st(1) + fldl (%r9) + lea 32+_P(%rip), %r9 + fadd %st, %st(2) + fxch %st(2) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(2) + fldt .L_2il0floatpacket.2(%rip) + fmul %st(2), %st + movl 16(%rsp), %edx + fsubrp %st, %st(1) + fld %st(0) + fldt .L_2il0floatpacket.3(%rip) + fmulp %st, %st(3) + movsbq %dl, %rax + fsub %st(2), %st + fldl (%r10) + lea _P(%rip), %r10 + fldl (%r11) + lea 48+_P(%rip), %r11 + fmul %st(2), %st + subl %eax, %edx + fxch %st(1) + fmul %st, %st(2) + shrl $8, %edx + fxch %st(2) + fsubrp %st, %st(1) + fld %st(0) + addl $16383, %edx + andl $32767, %edx + fxch %st(1) + fsubr %st, %st(3) + shlq $4, %rax + fxch %st(4) + fsubrp %st, %st(3) + fadd %st(2), %st + fld %st(0) + fmul %st(1), %st + fldt (%r8) + lea 16+_P(%rip), %r8 + fmul %st(1), %st + fldt (%r9) + movzwl 8+.L_2il0floatpacket.0(%rip), %r9d + faddp %st, %st(1) + fmul %st(1), %st + andl $-32768, %r9d + fldt (%r10) + orl %edx, %r9d + movq __libm_expl_table_256@GOTPCREL(%rip), %rdx + cmpl $16385, %ecx + movw %r9w, 40(%rsp) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fldl 2056(%rdx,%rax) + fldl 2048(%rdx,%rax) + fld %st(0) + fmul %st(4), %st + fxch %st(4) + fadd %st(5), %st + fmul %st(2), %st + faddp %st, %st(4) + fmul %st, %st(4) + jge ..B1.52 +..B1.51: + fldt 32(%rsp) + fld %st(1) + lea _TWO_32H(%rip), %rax + fadd %st(6), %st + fadd %st(4), %st + fsubp %st, %st(4) + fxch %st(1) + fsub %st(3), %st + faddp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fxch %st(2) + fmulp %st, %st(1) + fldt .L_2il0floatpacket.0(%rip) + fadd %st, %st(1) + fld %st(1) + fadd %st(3), %st + fdivr %st(1), %st + fld %st(2) + fldl (%rax) + fld %st(0) + fadd %st(3), %st + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fmul %st, %st(4) + fxch %st(3) + fsubr %st, %st(4) + fxch %st(2) + fsub %st(3), %st + fld %st(0) + fadd %st(4), %st + fmul %st, %st(6) + fxch %st(1) + fmul %st, %st(2) + fxch %st(6) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fmulp %st, %st(3) + fxch %st(2) + fsubrp %st, %st(3) + fldt .L_2il0floatpacket.4(%rip) + fmul %st, %st(1) + fxch %st(1) + fsubrp %st, %st(2) + fmulp %st, %st(2) + fsubp %st, %st(1) + fstpt (%rsp) + jmp ..B1.54 +..B1.52: + je ..B1.70 +..B1.53: + fstp %st(2) + fldt .L_2il0floatpacket.0(%rip) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(3) + faddp %st, %st(2) + fldt 32(%rsp) + fmulp %st, %st(2) + fadd %st, %st(1) + fldt .L_2il0floatpacket.4(%rip) + fdivp %st, %st(2) + fsubp %st, %st(1) + fstpt (%rsp) +..B1.54: + fldt (%rsp) + testq %rsi, %rsi + fld %st(0) + fchs + fcmove %st(1), %st + fstp %st(1) + fstpt (%rsp) + testb %dil, %dil + je ..B1.56 +..B1.55: + fldcw 50(%rsp) +..B1.56: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.57: + movl %eax, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.61 +..B1.58: + orl $-64768, %eax + movw %ax, 48(%rsp) +..B1.59: + fldcw 48(%rsp) +..B1.60: + movzwl 72(%rsp), %ecx + movb $1, %dil + andl $32767, %ecx +..B1.61: + cmpl $32767, %ecx + je ..B1.73 +..B1.62: + movq %rsi, %rdx + lea _small_value_80(%rip), %rax + shlq $4, %rdx + lea ones(%rip), %rcx + fldt (%rax,%rdx) + fsubrl (%rcx,%rsi,8) + fstpt (%rsp) +..B1.63: + testb %dil, %dil + je ..B1.65 +..B1.64: + fldcw 50(%rsp) +..B1.65: + fldt (%rsp) + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.66: + cmpl $0, 68(%rsp) + jne ..B1.68 +..B1.67: + cmpl $0, 64(%rsp) + je ..B1.69 +..B1.68: + fldt 64(%rsp) + lea _small_value_80(%rip), %rax + shlq $4, %rsi + fldt (%rax) + fldt (%rax,%rsi) + fmulp %st, %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubrp %st, %st(1) + fstpt (%rsp) + jmp ..B1.15 +..B1.69: + fldt 64(%rsp) + fstpt (%rsp) + jmp ..B1.15 +..B1.70: + movl 68(%rsp), %eax + cmpl $-1771674010, %eax + jb ..B1.51 +..B1.71: + jne ..B1.53 +..B1.72: + cmpl $1717986918, 64(%rsp) + jb ..B1.51 + jmp ..B1.53 +..B1.73: + cmpl $-2147483648, 68(%rsp) + jne ..B1.76 +..B1.74: + cmpl $0, 64(%rsp) + jne ..B1.76 +..B1.75: + lea ones(%rip), %rax + fldl (%rax,%rsi,8) + fstpt (%rsp) + jmp ..B1.63 +..B1.76: + fldt 64(%rsp) + fstpt (%rsp) + jmp ..B1.63 + .align 16,0x90 + .cfi_endproc + .type tanhl,@function + .size tanhl,.-tanhl + .data +# -- End tanhl + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0xf0,0x17,0x5c,0x29,0x3b,0xaa,0xb8,0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0xf8,0x17,0x72,0xb1,0xf6,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x30,0x71,0xd8,0x50,0x19,0xc2,0xb8,0xd4,0xbf,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 8 +twos: + .long 0x00000000,0x40000000 + .long 0x00000000,0xc0000000 + .type twos,@object + .size twos,16 + .align 8 +ones: + .long 0x00000000,0x3ff00000 + .long 0x00000000,0xbff00000 + .type ones,@object + .size ones,16 + .align 4 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_TWO_32: + .long 0 + .long 1106247680 + .type _TWO_32,@object + .size _TWO_32,8 + .align 4 +_TWO_32P: + .long 1048576 + .long 1106247680 + .type _TWO_32P,@object + .size _TWO_32P,8 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 2 +_Q3: + .word 21845 + .word 42325 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .type _Q3,@object + .size _Q3,16 + .align 2 +_Q2: + .word 36147 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 55638 + .word 59918 + .word 34848 + .word 34952 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,32 + .align 2 +_Q1: + .word 43688 + .word 43690 + .word 43690 + .word 43690 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 48627 + .word 34947 + .word 34952 + .word 34952 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 23872 + .word 38674 + .word 53460 + .word 56589 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 33152 + .word 13396 + .word 6324 + .word 45860 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,64 + .align 2 +_Q: + .word 43505 + .word 43690 + .word 43690 + .word 43690 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 51768 + .word 34951 + .word 34952 + .word 34952 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 53715 + .word 3536 + .word 53469 + .word 56589 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 37274 + .word 24708 + .word 42049 + .word 45863 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 51222 + .word 13677 + .word 6831 + .word 37175 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 45961 + .word 31945 + .word 59504 + .word 60265 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 5972 + .word 17449 + .word 45604 + .word 48849 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 32816 + .word 2946 + .word 4564 + .word 39596 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 14786 + .word 2112 + .word 44465 + .word 64190 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 3031 + .word 16844 + .word 22916 + .word 52030 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 47485 + .word 32270 + .word 51436 + .word 42167 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 3071 + .word 14344 + .word 30185 + .word 34131 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 24996 + .word 54454 + .word 53234 + .word 54781 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 39193 + .word 24581 + .word 37984 + .word 42131 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 5913 + .word 28127 + .word 47865 + .word 55395 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 25952 + .word 54950 + .word 21582 + .word 44803 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 43680 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 34944 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _Q,@object + .size _Q,288 + .align 2 +_P: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 10558 + .word 43680 + .word 43690 + .word 43690 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59664 + .word 43680 + .word 43690 + .word 43690 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 56450 + .word 15979 + .word 35652 + .word 34952 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 7105 + .word 47411 + .word 25657 + .word 46603 + .word 16373 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,80 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tanl.S b/external/sgx_libm/intel64/tanl.S new file mode 100644 index 0000000000..24f7d378aa --- /dev/null +++ b/external/sgx_libm/intel64/tanl.S @@ -0,0 +1,1843 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tanl.c" + .text +..TXTST0: +# -- Begin tanl + .text + .align 16,0x90 + .globl tanl +tanl: +# parameter 1: 144 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_tanl.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + subq $120, %rsp + .cfi_def_cfa_offset 144 + xorb %r13b, %r13b + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 104(%rsp) +..B1.2: + fnstcw 82(%rsp) +..B1.3: + movzwl 152(%rsp), %eax + andl $32767, %eax + movzwl 82(%rsp), %ecx + cmpl $16373, %eax + jge ..B1.41 +..B1.4: + cmpl $16371, %eax + jge ..B1.33 +..B1.5: + cmpl $16364, %eax + jge ..B1.25 +..B1.6: + cmpl $16308, %eax + jge ..B1.17 +..B1.7: + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.11 +..B1.8: + orl $-64768, %ecx + movw %cx, 80(%rsp) +..B1.9: + fldcw 80(%rsp) +..B1.10: + movzwl 152(%rsp), %eax + movb $1, %r13b + andl $32767, %eax +..B1.11: + testl %eax, %eax + jle ..B1.83 +..B1.12: + fldt 144(%rsp) + lea _TWO_75(%rip), %rax + lea 8+_TWO_75(%rip), %rdx + fldl (%rax) + fmul %st(1), %st + faddp %st, %st(1) + fmull (%rdx) + fstpt 16(%rsp) +..B1.13: + testb %r13b, %r13b + je ..B1.15 +..B1.14: + fldcw 82(%rsp) +..B1.15: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.16: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.17: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.21 +..B1.18: + orl $-64768, %ecx + movw %cx, 80(%rsp) +..B1.19: + fldcw 80(%rsp) +..B1.20: + movb $1, %r13b +..B1.21: + fldt 144(%rsp) + lea _P3(%rip), %rax + fld %st(0) + testb %r13b, %r13b + fmul %st(1), %st + fldt (%rax) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.23 +..B1.22: + fldcw 82(%rsp) +..B1.23: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.24: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.25: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.29 +..B1.26: + orl $-64768, %ecx + movw %cx, 80(%rsp) +..B1.27: + fldcw 80(%rsp) +..B1.28: + movb $1, %r13b +..B1.29: + fldt 144(%rsp) + lea 16+_P2(%rip), %rax + fld %st(0) + lea _P2(%rip), %rdx + fmul %st(1), %st + testb %r13b, %r13b + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmulp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.31 +..B1.30: + fldcw 82(%rsp) +..B1.31: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.32: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.33: + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.37 +..B1.34: + orl $-64768, %ecx + movw %cx, 80(%rsp) +..B1.35: + fldcw 80(%rsp) +..B1.36: + movb $1, %r13b +..B1.37: + fldt 144(%rsp) + lea 48+_P1(%rip), %rax + fld %st(0) + lea 32+_P1(%rip), %rcx + fmul %st(1), %st + lea 16+_P1(%rip), %rdx + fld %st(0) + lea _P1(%rip), %rsi + fmul %st(1), %st + testb %r13b, %r13b + fldt (%rax) + fmul %st(1), %st + fldt (%rdx) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rcx) + fmulp %st, %st(2) + fldt (%rsi) + faddp %st, %st(2) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + fmul %st(1), %st + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.39 +..B1.38: + fldcw 82(%rsp) +..B1.39: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.40: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.41: + movl %ecx, %edx + andl $768, %edx + cmpl $768, %edx + je ..B1.45 +..B1.42: + orl $-64768, %ecx + movw %cx, 80(%rsp) +..B1.43: + fldcw 80(%rsp) +..B1.44: + movzwl 152(%rsp), %eax + movb $1, %r13b + andl $32767, %eax +..B1.45: + movb 153(%rsp), %dl + andb $-128, %dl + shrb $7, %dl + movzbl %dl, %r12d + cmpl $16413, %eax + jge ..B1.52 +..B1.46: + fldt 144(%rsp) + lea _Pi4Inv(%rip), %rdx + fld %st(0) + fabs + fldl (%rdx) + fmul %st(1), %st + fstpt 64(%rsp) + movzwl 72(%rsp), %ecx + andl $32767, %ecx + cmpl $16383, %ecx + jge ..B1.48 +..B1.47: + fstp %st(0) + lea _TWO_48H(%rip), %rax + fld %st(0) + fld %st(1) + lea _KPi04(%rip), %rdx + fldl (%rax) + fmul %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(2) + fsub %st(2), %st + fldt (%rdx) + fmul %st(4), %st + fstpt 64(%rsp) + movl $1, %edx + fxch %st(3) + jmp ..B1.63 +..B1.48: + fstp %st(1) + negl %ecx + lea _TWO_32H(%rip), %rdi + addl $30, %ecx + movl 68(%rsp), %edx + shrl %cl, %edx + fldl (%rdi) + incl %edx + movl %edx, %esi + andl $-2, %esi + movl %esi, 32(%rsp) + cmpl $16400, %eax + fildl 32(%rsp) + jge ..B1.50 +..B1.49: + lea _Pi04x3(%rip), %rax + lea 8+_Pi04x3(%rip), %rcx + lea 16+_Pi04x3(%rip), %rsi + fldl (%rax) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl (%rcx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fld %st(0) + fldl (%rsi) + fmulp %st, %st(3) + fsub %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) + jmp ..B1.51 +..B1.50: + lea _Pi04x5(%rip), %rax + lea 8+_Pi04x5(%rip), %rcx + lea 16+_Pi04x5(%rip), %rsi + lea 24+_Pi04x5(%rip), %rdi + lea 32+_Pi04x5(%rip), %r8 + fldl (%rax) + fmul %st(1), %st + fsubrp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldl (%rcx) + fmul %st(3), %st + fsubr %st, %st(2) + fxch %st(1) + fsub %st(2), %st + fsubp %st, %st(1) + faddp %st, %st(3) + fld %st(0) + fldl (%rsi) + fmul %st(3), %st + fsubr %st, %st(1) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(4) + faddp %st, %st(2) + fldl (%rdi) + fmul %st(3), %st + fsubr %st, %st(1) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(1) + fsubrp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fldl (%r8) + fmulp %st, %st(2) + fld %st(0) + fsub %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + fsubrp %st, %st(1) + faddp %st, %st(2) +..B1.51: + lea _TWO_48H(%rip), %rax + fld %st(0) + fld %st(1) + lea _ones(%rip), %rcx + lea _KPi04(%rip), %rsi + fldl (%rax) + fmul %st, %st(2) + fxch %st(1) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldl (%rcx,%r12,8) + fmul %st, %st(2) + fld %st(2) + fxch %st(1) + fmulp %st, %st(4) + fadd %st(3), %st + fstpt 144(%rsp) + fldt 144(%rsp) + fldt (%rsi) + fmul %st(1), %st + fstpt 64(%rsp) + jmp ..B1.63 +..B1.52: + cmpl $32767, %eax + jne ..B1.61 +..B1.53: + cmpl $-2147483648, 148(%rsp) + jne ..B1.56 +..B1.54: + cmpl $0, 144(%rsp) + jne ..B1.56 +..B1.55: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fstpt 16(%rsp) + jmp ..B1.57 +..B1.56: + fldt 144(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 16(%rsp) +..B1.57: + testb %r13b, %r13b + je ..B1.59 +..B1.58: + fldcw 82(%rsp) +..B1.59: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.60: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.61: + addq $-16, %rsp + .cfi_def_cfa_offset 160 + xorl %edi, %edi + fldt 160(%rsp) + lea 104(%rsp), %rsi + fabs + fstpt (%rsp) +..___tag_value_tanl.49: + call __libm_reduce_pi04l@PLT +..___tag_value_tanl.50: +..B1.97: + movl %eax, %edx + addq $16, %rsp + .cfi_def_cfa_offset 144 +..B1.62: + fldl 88(%rsp) + incl %edx + lea _TWO_48H(%rip), %rcx + fld %st(0) + movsd 88(%rsp), %xmm0 + lea _ones(%rip), %rax + fldl (%rcx) + fldl (%rax,%r12,8) + lea _KPi04(%rip), %r12 + mulsd (%rcx), %xmm0 + fldt (%r12) + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fadd %st, %st(4) + fsubrp %st, %st(4) + fxch %st(3) + fsubr %st, %st(4) + fmul %st(1), %st + fldl 96(%rsp) + faddp %st, %st(5) + fxch %st(1) + fmulp %st, %st(4) + fld %st(0) + fadd %st(4), %st + fmul %st, %st(3) + fxch %st(3) + fstpt 64(%rsp) + fxch %st(2) + fstpt 144(%rsp) + fldt 144(%rsp) +..B1.63: + movzwl 72(%rsp), %ecx + andl $32767, %ecx + cmpl $16383, %ecx + jge ..B1.73 +..B1.64: + testb $2, %dl + je ..B1.69 +..B1.65: + lea 8+_ones(%rip), %rax + fld %st(2) + fmul %st(4), %st + lea 80+_PG(%rip), %rdx + fxch %st(4) + fstpt 32(%rsp) + fldt 32(%rsp) + lea 64+_PG(%rip), %rcx + fmul %st(1), %st + lea 48+_PG(%rip), %rsi + lea 32+_PG(%rip), %rdi + lea 16+_PG(%rip), %r8 + lea _PG(%rip), %r9 + lea _ones(%rip), %r10 + testb %r13b, %r13b + faddp %st, %st(4) + fxch %st(2) + fstpt 48(%rsp) + fldt 48(%rsp) + fmul %st(0), %st + faddp %st, %st(3) + fld %st(2) + fmul %st(3), %st + fldl (%rax) + fdiv %st(3), %st + fmul %st, %st(2) + fldt (%rdx) + fmul %st(2), %st + fldt (%rcx) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fld %st(3) + fadd %st(2), %st + fsub %st(4), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(6) + fldt (%r9) + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fld %st(2) + fsubr %st(2), %st + fxch %st(6) + fmulp %st, %st(5) + faddp %st, %st(4) + fldt 48(%rsp) + fld %st(0) + fmul %st(6), %st + fxch %st(1) + fmul %st(3), %st + fldt 32(%rsp) + fmul %st(3), %st + faddp %st, %st(2) + faddl (%r10) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.102 +..B1.66: + fstpt 64(%rsp) +..B1.98: + fldcw 82(%rsp) + jmp ..B1.67 +..B1.102: + fstp %st(0) +..B1.67: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.68: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.69: + fld %st(0) + lea 80+_PT(%rip), %rax + fmul %st(1), %st + lea 64+_PT(%rip), %rdx + fxch %st(3) + fstpt 48(%rsp) + fld %st(2) + fmul %st(3), %st + lea 48+_PT(%rip), %rcx + fldt (%rax) + lea 32+_PT(%rip), %rsi + fmul %st(1), %st + lea 16+_PT(%rip), %rdi + fldt (%rdx) + lea _PT(%rip), %r8 + fmul %st(2), %st + testb %r13b, %r13b + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%r8) + faddp %st, %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(1) + fmul %st(2), %st + fld %st(2) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fld %st(2) + fmul %st(1), %st + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldt 48(%rsp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fadd %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) + je ..B1.103 +..B1.70: + fstpt 64(%rsp) +..B1.99: + fldcw 82(%rsp) + jmp ..B1.71 +..B1.103: + fstp %st(0) +..B1.71: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.72: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.73: + fstp %st(0) + negl %ecx + pxor %xmm2, %xmm2 + addl $30, %ecx + movl 68(%rsp), %eax + shrl %cl, %eax + movl %eax, %edi + movzbl 153(%rsp), %esi + negl %edi + testl $128, %esi + movsd .L_2il0floatpacket.0(%rip), %xmm0 + cmovne %edi, %eax + testb $2, %dl + cvtsi2sd %eax, %xmm2 + mulsd %xmm2, %xmm0 + movsd .L_2il0floatpacket.1(%rip), %xmm1 + mulsd %xmm1, %xmm2 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + movsd %xmm2, 32(%rsp) + fsubrp %st, %st(2) + fld %st(1) + fldl 32(%rsp) + fsubrp %st, %st(4) + fadd %st(3), %st + je ..B1.78 +..B1.74: + fld %st(2) + lea 80+_PT(%rip), %rdx + fmul %st(4), %st + fld %st(4) + fmul %st(2), %st + lea 64+_PT(%rip), %rcx + lea 48+_PT(%rip), %rsi + lea 32+_PT(%rip), %rdi + lea 16+_PT(%rip), %r8 + lea _PT(%rip), %r9 + addl %eax, %eax + movslq %eax, %rax + lea _TG(%rip), %r10 + lea _TT(%rip), %r11 + lea _ones(%rip), %r12 + testb %r13b, %r13b + faddp %st, %st(1) + fld %st(3) + fmul %st(4), %st + faddp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fxch %st(3) + fstpt 32(%rsp) + fxch %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + fldt (%rdx) + fmul %st(3), %st + fldt (%rcx) + fmul %st(4), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fxch %st(1) + fmul %st, %st(3) + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fldl 272(%r10,%rax,8) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(4) + faddl 280(%r11,%rax,8) + fxch %st(3) + faddl 272(%r11,%rax,8) + fld %st(0) + fadd %st(4), %st + fxch %st(3) + fmull 280(%r10,%rax,8) + lea 8+_ones(%rip), %r10 + faddp %st, %st(2) + fld %st(1) + fadd %st(5), %st + fldt 32(%rsp) + fadd %st, %st(1) + fsubr %st, %st(1) + fxch %st(1) + fsubr %st, %st(6) + fxch %st(6) + fstpt 48(%rsp) + fldt 48(%rsp) + faddp %st, %st(3) + fld %st(0) + fxch %st(4) + fdivrl (%r12) + fmul %st, %st(5) + fadd %st, %st(4) + fxch %st(1) + fsubrp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fld %st(2) + fmul %st(1), %st + faddp %st, %st(6) + fxch %st(2) + fmul %st(4), %st + fld %st(4) + fmul %st(4), %st + fxch %st(4) + fadd %st(7), %st + fxch %st(7) + fmulp %st, %st(5) + faddl (%r10) + lea _GG(%rip), %r10 + faddp %st, %st(5) + fmulp %st, %st(4) + fsubp %st, %st(3) + fxch %st(3) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + faddl 272(%r10,%rax,8) + fxch %st(1) + faddl 280(%r10,%rax,8) + faddp %st, %st(1) + fstpt 16(%rsp) + fldt 48(%rsp) + je ..B1.104 +..B1.75: + fstpt 64(%rsp) +..B1.100: + fldcw 82(%rsp) + jmp ..B1.76 +..B1.104: + fstp %st(0) +..B1.76: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.77: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.78: + fld %st(0) + lea 80+_PT(%rip), %rdx + fmul %st(1), %st + lea 64+_PT(%rip), %rcx + fld %st(0) + lea 48+_PT(%rip), %rsi + fmul %st(1), %st + lea 32+_PT(%rip), %rdi + fxch %st(4) + fstpt 48(%rsp) + lea 16+_PT(%rip), %r8 + fldt (%rdx) + lea _PT(%rip), %r9 + fmul %st(4), %st + addl %eax, %eax + fldt (%rcx) + lea _TG(%rip), %r10 + fmul %st(5), %st + lea _GG(%rip), %r11 + fldt (%rsi) + lea 8+_ones(%rip), %r12 + movslq %eax, %rax + testb %r13b, %r13b + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(5), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(5) + fld %st(3) + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(4) + fmul %st(3), %st + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(3) + fxch %st(1) + fmulp %st, %st(3) + fld %st(3) + fmul %st(1), %st + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(0) + fldt 48(%rsp) + fmul %st, %st(3) + faddp %st, %st(3) + fld %st(2) + fadd %st(4), %st + fmul %st, %st(1) + fstpt 144(%rsp) + fldt 144(%rsp) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(2) + fadd %st(2), %st + fldl 272(%r10,%rax,8) + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(5), %st + fxch %st(4) + faddl 280(%r11,%rax,8) + fxch %st(5) + faddl 272(%r11,%rax,8) + fxch %st(2) + fmull 280(%r10,%rax,8) + lea _ones(%rip), %r10 + faddp %st, %st(1) + fld %st(1) + fadd %st(5), %st + fdivrl (%r12) + fmul %st, %st(3) + fld %st(3) + fadd %st(1), %st + fsubp %st, %st(4) + fld %st(3) + fsubr %st(1), %st + fld %st(3) + fmul %st(1), %st + fxch %st(2) + fmul %st, %st(7) + fxch %st(7) + faddp %st, %st(2) + fxch %st(3) + fmul %st(4), %st + fld %st(4) + fmul %st(3), %st + fxch %st(3) + fadd %st(6), %st + fxch %st(6) + fmulp %st, %st(5) + faddl (%r10) + lea _TT(%rip), %r10 + faddp %st, %st(1) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(1) + fmulp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldl 272(%r10,%rax,8) + fld %st(0) + fadd %st(2), %st + fsub %st, %st(1) + fxch %st(1) + fsubr %st(2), %st + fxch %st(3) + faddl 280(%r10,%rax,8) + faddp %st, %st(3) + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + je ..B1.105 +..B1.79: + fstpt 64(%rsp) +..B1.101: + fldcw 82(%rsp) + jmp ..B1.80 +..B1.105: + fstp %st(0) +..B1.80: + movq 104(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.82 +..B1.81: + fldt 16(%rsp) + addq $120, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 144 + .cfi_offset 12, -16 + .cfi_offset 13, -24 +..B1.82: + call __stack_chk_fail@PLT +..B1.83: + cmpl $0, 148(%rsp) + jne ..B1.85 +..B1.84: + cmpl $0, 144(%rsp) + je ..B1.86 +..B1.85: + fldt 144(%rsp) + lea _TWO_75(%rip), %rsi + movb 153(%rsp), %al + lea _small_value_80(%rip), %rcx + andb $-128, %al + lea 8+_TWO_75(%rip), %rdi + shrb $7, %al + fldl (%rsi) + fmul %st(1), %st + faddp %st, %st(1) + fldt (%rcx) + fxch %st(1) + fmull (%rdi) + movzbl %al, %edx + shlq $4, %rdx + fstpt 16(%rsp) + fldt (%rcx,%rdx) + fmulp %st, %st(1) + fstpt (%rsp) + jmp ..B1.13 +..B1.86: + fldt 144(%rsp) + fstpt 16(%rsp) + jmp ..B1.13 + .align 16,0x90 + .cfi_endproc + .type tanl,@function + .size tanl,.-tanl + .data +# -- End tanl + .section .rodata, "a" + .align 16 + .align 16 +_TWO_75: + .long 0 + .long 1151336448 + .long 0 + .long 994050048 + .type _TWO_75,@object + .size _TWO_75,16 + .align 16 +_P3: + .word 13380 + .word 43827 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _P3,@object + .size _P3,16 + .align 16 +_P2: + .word 42806 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 23834 + .word 52331 + .word 35007 + .word 34952 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P2,@object + .size _P2,32 + .align 16 +_P1: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 34953 + .word 34952 + .word 34952 + .word 34952 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 31445 + .word 3491 + .word 53469 + .word 56589 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 16733 + .word 58542 + .word 44372 + .word 45863 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,64 + .align 16 +_Pi4Inv: + .long 1841940611 + .long 1072979760 + .type _Pi4Inv,@object + .size _Pi4Inv,8 + .space 8, 0x00 # pad + .align 16 +_TWO_48H: + .long 0 + .long 1123549184 + .type _TWO_48H,@object + .size _TWO_48H,8 + .space 8, 0x00 # pad + .align 16 +_KPi04: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16387 + .word 0 + .word 0 + .word 0 + .type _KPi04,@object + .size _KPi04,16 + .align 16 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .space 8, 0x00 # pad + .align 16 +_Pi04x3: + .long 1413754112 + .long 1072243195 + .long 2563527040 + .long 1021855384 + .long 3417685868 + .long 3118450936 + .type _Pi04x3,@object + .size _Pi04x3,24 + .space 8, 0x00 # pad + .align 16 +_Pi04x5: + .long 1413480448 + .long 1072243195 + .long 442499072 + .long 1036039265 + .long 771751936 + .long 999496074 + .long 622854144 + .long 963347354 + .long 1396597664 + .long 922906692 + .type _Pi04x5,@object + .size _Pi04x5,40 + .space 8, 0x00 # pad + .align 16 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 16 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 16 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 16 +_PG: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 46604 + .word 2912 + .word 24758 + .word 46603 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 64867 + .word 2218 + .word 21984 + .word 35507 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 37428 + .word 49066 + .word 48281 + .word 56811 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 28819 + .word 40692 + .word 30466 + .word 45908 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 58229 + .word 57025 + .word 27882 + .word 37211 + .word 16364 + .word 0 + .word 0 + .word 0 + .type _PG,@object + .size _PG,96 + .align 16 +_PT: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 35260 + .word 34952 + .word 34952 + .word 34952 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 59431 + .word 3445 + .word 53469 + .word 56589 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 60805 + .word 19035 + .word 42054 + .word 45863 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 32963 + .word 17667 + .word 64505 + .word 37174 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 33271 + .word 14204 + .word 52730 + .word 60442 + .word 16374 + .word 0 + .word 0 + .word 0 + .type _PT,@object + .size _PT,96 + .align 16 +_TG: + .long 2684354560 + .long 3221230545 + .long 1980244105 + .long 1046278452 + .long 0 + .long 3221225472 + .long 0 + .long 0 + .long 2684354560 + .long 3221230545 + .long 1980244105 + .long 1046278452 + .long 3758096384 + .long 3221246014 + .long 1513286675 + .long 1048381067 + .long 0 + .long 3221272655 + .long 4057975187 + .long 3193921290 + .long 2147483648 + .long 3221311866 + .long 2902494488 + .long 1046516509 + .long 3221225472 + .long 3221365863 + .long 1948335328 + .long 3196126810 + .long 2684354560 + .long 3221438007 + .long 3744091947 + .long 3192783219 + .long 2684354560 + .long 3221533379 + .long 3860423252 + .long 1047335024 + .long 2147483648 + .long 3221659806 + .long 862942416 + .long 1049198788 + .long 0 + .long 3221829776 + .long 543592927 + .long 3195468420 + .long 0 + .long 3222064283 + .long 2814267453 + .long 1048596082 + .long 536870912 + .long 3222337673 + .long 2980891112 + .long 3196362141 + .long 2684354560 + .long 3222595502 + .long 141458722 + .long 1049458206 + .long 3221225472 + .long 3223031588 + .long 2120823910 + .long 1049591613 + .long 3221225472 + .long 3223617753 + .long 663882580 + .long 3198186420 + .long 2147483648 + .long 3224659859 + .long 3051968734 + .long 3194791707 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1077176211 + .long 3051968734 + .long 1047308059 + .long 3221225472 + .long 1076134105 + .long 663882580 + .long 1050702772 + .long 3221225472 + .long 1075547940 + .long 2120823910 + .long 3197075261 + .long 2684354560 + .long 1075111854 + .long 141458722 + .long 3196941854 + .long 536870912 + .long 1074854025 + .long 2980891112 + .long 1048878493 + .long 0 + .long 1074580635 + .long 2814267453 + .long 3196079730 + .long 0 + .long 1074346128 + .long 543592927 + .long 1047984772 + .long 2147483648 + .long 1074176158 + .long 862942416 + .long 3196682436 + .long 2684354560 + .long 1074049731 + .long 3860423252 + .long 3194818672 + .long 2684354560 + .long 1073954359 + .long 3744091947 + .long 1045299571 + .long 3221225472 + .long 1073882215 + .long 1948335328 + .long 1048643162 + .long 2147483648 + .long 1073828218 + .long 2902494488 + .long 3194000157 + .long 0 + .long 1073789007 + .long 4057975187 + .long 1046437642 + .long 3758096384 + .long 1073762366 + .long 1513286675 + .long 3195864715 + .long 2684354560 + .long 1073746897 + .long 1980244105 + .long 3193762100 + .long 0 + .long 1073741824 + .long 0 + .long 0 + .long 2684354560 + .long 1073746897 + .long 1980244105 + .long 3193762100 + .type _TG,@object + .size _TG,560 + .align 16 +_TT: + .long 1610612736 + .long 3220285245 + .long 1765132704 + .long 1046851815 + .long 0 + .long 3220176896 + .long 0 + .long 0 + .long 3221225472 + .long 3219980491 + .long 3100042604 + .long 3192709428 + .long 1073741824 + .long 3219800832 + .long 2956254064 + .long 1046813655 + .long 0 + .long 3219635098 + .long 829070670 + .long 1046664815 + .long 0 + .long 3219481016 + .long 3358544266 + .long 3195362300 + .long 2147483648 + .long 3219336728 + .long 4185368031 + .long 3193047295 + .long 536870912 + .long 3219200695 + .long 1373988029 + .long 1045159724 + .long 0 + .long 3219014926 + .long 4104169752 + .long 3192540796 + .long 2147483648 + .long 3218768505 + .long 843197631 + .long 3193568495 + .long 0 + .long 3218531914 + .long 1839318447 + .long 1044402419 + .long 1073741824 + .long 3218303496 + .long 1215676724 + .long 1044727608 + .long 1610612736 + .long 3218081786 + .long 2922073518 + .long 3193275942 + .long 0 + .long 3217651190 + .long 2818065035 + .long 1045408462 + .long 2147483648 + .long 3217226924 + .long 2142552361 + .long 1043903475 + .long 2147483648 + .long 3216586427 + .long 1153689642 + .long 3190339163 + .long 2147483648 + .long 3215533863 + .long 3288774277 + .long 3189012002 + .long 0 + .long 0 + .long 0 + .long 0 + .long 2147483648 + .long 1068050215 + .long 3288774277 + .long 1041528354 + .long 2147483648 + .long 1069102779 + .long 1153689642 + .long 1042855515 + .long 2147483648 + .long 1069743276 + .long 2142552361 + .long 3191387123 + .long 0 + .long 1070167542 + .long 2818065035 + .long 3192892110 + .long 1610612736 + .long 1070598138 + .long 2922073518 + .long 1045792294 + .long 1073741824 + .long 1070819848 + .long 1215676724 + .long 3192211256 + .long 0 + .long 1071048266 + .long 1839318447 + .long 3191886067 + .long 2147483648 + .long 1071284857 + .long 843197631 + .long 1046084847 + .long 0 + .long 1071531278 + .long 4104169752 + .long 1045057148 + .long 536870912 + .long 1071717047 + .long 1373988029 + .long 3192643372 + .long 2147483648 + .long 1071853080 + .long 4185368031 + .long 1045563647 + .long 0 + .long 1071997368 + .long 3358544266 + .long 1047878652 + .long 0 + .long 1072151450 + .long 829070670 + .long 3194148463 + .long 1073741824 + .long 1072317184 + .long 2956254064 + .long 3194297303 + .long 3221225472 + .long 1072496843 + .long 3100042604 + .long 1045225780 + .long 0 + .long 1072693248 + .long 0 + .long 0 + .long 1610612736 + .long 1072801597 + .long 1765132704 + .long 3194335463 + .type _TT,@object + .size _TT,560 + .align 16 +_GG: + .long 3221225472 + .long 1072496843 + .long 3100042604 + .long 1045225780 + .long 0 + .long 1072693248 + .long 2680413623 + .long 2803148914 + .long 1610612736 + .long 1072801597 + .long 1765132704 + .long 3194335463 + .long 2147483648 + .long 1072922365 + .long 4224648010 + .long 1047203520 + .long 0 + .long 1073058513 + .long 1429029132 + .long 1047610106 + .long 0 + .long 1073213977 + .long 2662307862 + .long 3195905419 + .long 2147483648 + .long 1073394115 + .long 2332932060 + .long 3196140229 + .long 3221225472 + .long 1073606419 + .long 4089189126 + .long 3194062807 + .long 3758096384 + .long 1073801761 + .long 295749197 + .long 3195130376 + .long 1073741824 + .long 1073958991 + .long 862942416 + .long 3195633860 + .long 0 + .long 1074158535 + .long 1551453531 + .long 3197746903 + .long 0 + .long 1074421594 + .long 590804010 + .long 3196516863 + .long 0 + .long 1074786323 + .long 1872593098 + .long 1046983523 + .long 3758096384 + .long 1075059710 + .long 2286165020 + .long 1046614587 + .long 2147483648 + .long 1075509055 + .long 2023416727 + .long 3198791271 + .long 1610612736 + .long 1076121196 + .long 3469402705 + .long 3196752904 + .long 0 + .long 1077172992 + .long 2869016295 + .long 3199393764 + .long 0 + .long 0 + .long 0 + .long 0 + .long 0 + .long 3224656640 + .long 2869016295 + .long 1051910116 + .long 1610612736 + .long 3223604844 + .long 3469402705 + .long 1049269256 + .long 2147483648 + .long 3222992703 + .long 2023416727 + .long 1051307623 + .long 3758096384 + .long 3222543358 + .long 2286165020 + .long 3194098235 + .long 0 + .long 3222269971 + .long 1872593098 + .long 3194467171 + .long 0 + .long 3221905242 + .long 590804010 + .long 1049033215 + .long 0 + .long 3221642183 + .long 1551453531 + .long 1050263255 + .long 1073741824 + .long 3221442639 + .long 862942416 + .long 1048150212 + .long 3758096384 + .long 3221285409 + .long 295749197 + .long 1047646728 + .long 3221225472 + .long 3221090067 + .long 4089189126 + .long 1046579159 + .long 2147483648 + .long 3220877763 + .long 2332932060 + .long 1048656581 + .long 0 + .long 3220697625 + .long 2662307862 + .long 1048421771 + .long 0 + .long 3220542161 + .long 1429029132 + .long 3195093754 + .long 2147483648 + .long 3220406013 + .long 4224648010 + .long 3194687168 + .long 1610612736 + .long 3220285245 + .long 1765132704 + .long 1046851815 + .long 0 + .long 3220176896 + .long 2680413623 + .long 655665266 + .long 3221225472 + .long 3219980491 + .long 3100042604 + .long 3192709428 + .type _GG,@object + .size _GG,560 + .align 16 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 8 +.L_2il0floatpacket.0: + .long 0x54400000,0x3fa921fb + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x1a626331,0x3d80b461 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tgamma.S b/external/sgx_libm/intel64/tgamma.S new file mode 100644 index 0000000000..f277e018cd --- /dev/null +++ b/external/sgx_libm/intel64/tgamma.S @@ -0,0 +1,3885 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tgamma.c" + .text +..TXTST0: +# -- Begin tgamma + .text + .align 16,0x90 + .globl tgamma +tgamma: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_tgamma.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %r15 + .cfi_def_cfa_offset 40 + .cfi_offset 15, -40 + pushq %rbx + .cfi_def_cfa_offset 48 + .cfi_offset 3, -48 + pushq %rbp + .cfi_def_cfa_offset 56 + .cfi_offset 6, -56 + subq $104, %rsp + .cfi_def_cfa_offset 160 + fldz + lea _zeros(%rip), %r15 + xorl %r12d, %r12d + movd %xmm0, %rax + xorb %r13b, %r13b + movsd %xmm0, 72(%rsp) + fstpt 48(%rsp) + movq (%r15), %rdx + movq %rax, 16(%rsp) + movq %rdx, 80(%rsp) +..B1.2: + fnstcw 90(%rsp) +..B1.3: + movzwl 90(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 88(%rsp) +..B1.5: + fldcw 88(%rsp) +..B1.6: + movb $1, %r13b +..B1.7: +..___tag_value_tgamma.16: + call fegetround@PLT +..___tag_value_tgamma.17: +..B1.121: + movl %eax, %r14d +..B1.8: + testl %r14d, %r14d + je ..B1.10 +..B1.9: + xorl %edi, %edi + movl $1, %r12d +..___tag_value_tgamma.18: + call fesetround@PLT +..___tag_value_tgamma.19: +..B1.10: + movzwl 78(%rsp), %edx + andl $32752, %edx + shrl $4, %edx + movl 76(%rsp), %ebx + shrl $31, %ebx + cmpl $2047, %edx + je ..B1.108 +..B1.11: + movsd 72(%rsp), %xmm2 + movsd (%r15), %xmm0 + movl 20(%rsp), %eax + andl $2147483647, %eax + movl 16(%rsp), %ecx + movl %eax, 20(%rsp) + movsd %xmm0, (%rsp) + ucomisd %xmm0, %xmm2 + jp ..B1.12 + je ..B1.103 +..B1.12: + cmpl $262144, %eax + jl ..B1.98 +..B1.13: + je ..B1.97 +..B1.14: + testl %ebx, %ebx + je ..B1.25 +..B1.15: + cmpl $1075, %edx + jge ..B1.87 +..B1.16: + lea _TWO_52H(%rip), %rax + movsd 16(%rsp), %xmm1 + movaps %xmm1, %xmm0 + addsd (%rax), %xmm0 + movsd %xmm0, 40(%rsp) + movsd 40(%rsp), %xmm0 + movl 40(%rsp), %r15d + subsd (%rax), %xmm0 + comisd %xmm1, %xmm0 + jbe ..B1.18 +..B1.17: + lea _ones(%rip), %rax + incl %r15d + subsd (%rax), %xmm0 +..B1.18: + ucomisd %xmm0, %xmm1 + jp ..B1.19 + je ..B1.82 +..B1.19: + movsd .L_2il0floatpacket.0(%rip), %xmm0 + comisd %xmm2, %xmm0 + jbe ..B1.25 +..B1.20: + testl %r12d, %r12d + je ..B1.22 +..B1.21: + movl %r14d, %edi +..___tag_value_tgamma.20: + call fesetround@PLT +..___tag_value_tgamma.21: +..B1.22: + lea _small_value_64(%rip), %rax + notl %r15d + andl $1, %r15d + testb %r13b, %r13b + movsd (%rax,%r15,8), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.24 +..B1.23: + fldcw 90(%rsp) +..B1.24: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.25: + lea _overflow_boundary(%rip), %rax + comisd (%rax), %xmm2 + jae ..B1.92 +..B1.26: + testl %ebx, %ebx + je ..B1.28 +..B1.27: + lea _TWO_52H(%rip), %rax + lea 144+_tgamma_sin_table(%rip), %rcx + movsd 16(%rsp), %xmm0 + lea 128+_tgamma_sin_table(%rip), %rsi + movaps %xmm0, %xmm1 + movaps %xmm0, %xmm3 + lea 112+_tgamma_sin_table(%rip), %r8 + lea 96+_tgamma_sin_table(%rip), %r9 + fldt (%rcx) + lea 80+_tgamma_sin_table(%rip), %r10 + fldt (%rsi) + lea 64+_tgamma_sin_table(%rip), %r11 + lea 48+_tgamma_sin_table(%rip), %r15 + addsd (%rax), %xmm1 + fldt (%r8) + lea 32+_tgamma_sin_table(%rip), %rdi + fldt (%r9) + lea 16+_tgamma_sin_table(%rip), %rcx + fldt (%r10) + lea _tgamma_sin_table(%rip), %rsi + movsd %xmm1, 40(%rsp) + movsd 40(%rsp), %xmm2 + movsd (%rax), %xmm1 + subsd %xmm1, %xmm2 + subsd %xmm2, %xmm3 + movsd %xmm3, 24(%rsp) + andl $2147483647, 28(%rsp) + fldl 24(%rsp) + fld %st(0) + fmul %st(1), %st + fmul %st, %st(6) + fxch %st(6) + faddp %st, %st(5) + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + faddp %st, %st(1) + fmul %st(3), %st + faddp %st, %st(1) + fmul %st(2), %st + fld %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r15) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(1) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(1) + fmulp %st, %st(3) + fldt (%rsi) + faddp %st, %st(3) + fmulp %st, %st(2) + faddp %st, %st(1) + fstpt 48(%rsp) + jmp ..B1.29 +..B1.28: + lea _TWO_52H(%rip), %rax + movsd 16(%rsp), %xmm0 + movsd (%rax), %xmm1 +..B1.29: + addsd %xmm0, %xmm1 + movsd %xmm1, 40(%rsp) + movsd 40(%rsp), %xmm1 + movl 40(%rsp), %ecx + subsd (%rax), %xmm1 + lea _ones(%rip), %rax + movsd (%rax), %xmm3 + comisd %xmm0, %xmm1 + jbe ..B1.31 +..B1.30: + decl %ecx + subsd %xmm3, %xmm1 +..B1.31: + lea 1(%rcx), %r15d + andl $1, %r15d + comisd .L_2il0floatpacket.1(%rip), %xmm0 + jb ..B1.54 +..B1.32: + movl %ecx, %ebp + movl %ecx, %edx + andl $-16, %ebp + andl $15, %edx + movl %ebp, %esi + cmpl $16, %ecx + movl %ebp, %ecx + movaps %xmm0, %xmm2 + lea _tgamma_A_table(%rip), %r8 + subsd %xmm1, %xmm2 + movsd %xmm2, 64(%rsp) + lea -2(%rdx), %eax + fldl 64(%rsp) + cmovl %eax, %edx + sarl $2, %esi + fld %st(0) + sarl $3, %ecx + addl %ebp, %esi + sarl $4, %ebp + addl %ebp, %ecx + addl %ecx, %esi + movslq %esi, %rsi + shlq $4, %rsi + fmul %st(1), %st + testl %edx, %edx + fldt 352(%r8,%rsi) + fldt (%r8,%rsi) + fmul %st(3), %st + movsd %xmm3, 64(%rsp) + fadd %st(2), %st + fldt 176(%r8,%rsi) + movsd %xmm2, 32(%rsp) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 16(%r8,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 32(%r8,%rsi) + fmul %st(4), %st + fadd %st(3), %st + fldt 192(%r8,%rsi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 208(%r8,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 224(%r8,%rsi) + fldt 240(%r8,%rsi) + fldt 256(%r8,%rsi) + fldt 48(%r8,%rsi) + fmul %st(6), %st + fadd %st(5), %st + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fldt 64(%r8,%rsi) + fmul %st(5), %st + fadd %st(4), %st + faddp %st, %st(1) + fmulp %st, %st(2) + fldt 80(%r8,%rsi) + fmul %st(4), %st + fadd %st(3), %st + faddp %st, %st(1) + fmulp %st, %st(1) + fldt 96(%r8,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 128(%r8,%rsi) + fmul %st(4), %st + fadd %st(3), %st + fldt 272(%r8,%rsi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt 288(%r8,%rsi) + fldt 304(%r8,%rsi) + faddp %st, %st(2) + fldt 112(%r8,%rsi) + fmul %st(5), %st + fadd %st(4), %st + faddp %st, %st(1) + fmulp %st, %st(2) + fmulp %st, %st(1) + fldt 144(%r8,%rsi) + fmul %st(3), %st + fadd %st(2), %st + fldt 160(%r8,%rsi) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fldt 320(%r8,%rsi) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt 336(%r8,%rsi) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 8(%rsp) + fldl 64(%rsp) + fld %st(0) + je ..B1.37 +..B1.33: + movl $1, %eax + jle ..B1.37 +..B1.34: + movsd %xmm0, 64(%rsp) + fldl 64(%rsp) +..B1.35: + movl %eax, 64(%rsp) + incl %eax + fildl 64(%rsp) + cmpl %edx, %eax + fsubr %st(1), %st + fmulp %st, %st(2) + jle ..B1.35 +..B1.36: + fstp %st(0) +..B1.37: + testl %ebx, %ebx + je ..B1.48 +..B1.38: + fldt 48(%rsp) + fldt 8(%rsp) + movsd %xmm0, 64(%rsp) + fldl 64(%rsp) + fmulp %st, %st(2) + fmulp %st, %st(1) + fmulp %st, %st(1) + fdivrp %st, %st(1) + movsd .L_2il0floatpacket.4(%rip), %xmm0 + fstpl (%rsp) + movsd (%rsp), %xmm1 + comisd 72(%rsp), %xmm0 + jbe ..B1.45 +..B1.39: + movaps %xmm1, %xmm0 + testl %r15d, %r15d + xorps .L_2il0floatpacket.5(%rip), %xmm0 + jne ..L42 + movaps %xmm1, %xmm0 +..L42: + testl %r12d, %r12d + je ..B1.42 +..B1.40: + movl %r14d, %edi + movsd %xmm0, 80(%rsp) +..___tag_value_tgamma.43: + call fesetround@PLT +..___tag_value_tgamma.44: +..B1.41: + movsd 80(%rsp), %xmm0 + xorl %r12d, %r12d +..B1.42: + lea _tgamma_A176_inv(%rip), %rax + testl %r15d, %r15d + movsd %xmm0, 64(%rsp) + fldl 64(%rsp) + fldt (%rax) + fmulp %st, %st(1) + je ..B1.44 +..B1.43: + fchs + fstpl 80(%rsp) + jmp ..B1.46 +..B1.44: + fstpl 80(%rsp) + jmp ..B1.46 +..B1.45: + movsd %xmm1, 80(%rsp) +..B1.46: + shll $31, %r15d + xorl %r15d, 84(%rsp) + testl %r12d, %r12d + je ..B1.51 +..B1.47: + movl %r14d, %edi +..___tag_value_tgamma.45: + call fesetround@PLT +..___tag_value_tgamma.46: + jmp ..B1.51 +..B1.48: + fstp %st(1) + fldt 8(%rsp) + testl %r12d, %r12d + fmulp %st, %st(1) + fstpt 8(%rsp) + je ..B1.50 +..B1.49: + movl %r14d, %edi +..___tag_value_tgamma.47: + call fesetround@PLT +..___tag_value_tgamma.48: +..B1.50: + fldt 8(%rsp) + fstpl 80(%rsp) +..B1.51: + testb %r13b, %r13b + je ..B1.53 +..B1.52: + movsd 32(%rsp), %xmm0 + movsd %xmm0, 24(%rsp) +..B1.122: + fldcw 90(%rsp) +..B1.53: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.54: + fldt .L_2il0floatpacket.2(%rip) + comisd %xmm0, %xmm3 + movsd %xmm0, 64(%rsp) + fldl 64(%rsp) + movsd %xmm3, 64(%rsp) + fldl 64(%rsp) + fadd %st(1), %st + fcmovbe %st(1), %st + fcomi %st(2), %st + fxch %st(2) + fstp %st(0) + jb ..B1.56 +..B1.55: + movsd %xmm3, 64(%rsp) + lea _tgamma_A150_table(%rip), %rbp + fldl 64(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fstl 24(%rsp) + fxch %st(1) + jmp ..B1.60 +..B1.56: + fldt .L_2il0floatpacket.3(%rip) + fcomi %st(2), %st + ja ..B1.58 + jp ..B1.58 +..B1.57: + fstp %st(0) + lea _local_minimum(%rip), %rax + lea _tgamma_A125_table(%rip), %rbp + movsd %xmm3, 64(%rsp) + fldl 64(%rsp) + faddl (%rax) + fsubrp %st, %st(2) + fxch %st(1) + fstl 24(%rsp) + fxch %st(1) + jmp ..B1.60 +..B1.58: + fcomip %st(2), %st + jbe ..B1.60 +..B1.59: + movsd %xmm3, 64(%rsp) + lea _tgamma_A100_table(%rip), %rbp + fldl 64(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fstl 24(%rsp) + fxch %st(1) +..B1.60: + fstp %st(1) + fldt (%rbp) + testl %edx, %edx + je ..B1.63 +..B1.61: + fldl 24(%rsp) + fldt 240(%rbp) + fmul %st(1), %st + fldt 224(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 208(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 192(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 176(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 160(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 144(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 128(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 112(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 96(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 80(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 64(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 48(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 32(%rbp) + faddp %st, %st(1) + fmul %st(1), %st + fldt 16(%rbp) + faddp %st, %st(1) + fmulp %st, %st(1) + faddp %st, %st(1) +..B1.63: + comisd %xmm0, %xmm3 + jbe ..B1.72 +..B1.64: + fstp %st(1) + testl %ebx, %ebx + je ..B1.68 +..B1.65: + fldt 48(%rsp) + testl %r12d, %r12d + fmulp %st, %st(1) + movsd %xmm3, 64(%rsp) + fldl 64(%rsp) + fdivp %st, %st(1) + fchs + fstpt (%rsp) + je ..B1.67 +..B1.66: + movl %r14d, %edi +..___tag_value_tgamma.69: + call fesetround@PLT +..___tag_value_tgamma.70: +..B1.67: + fldt (%rsp) + fchs + fstpl 80(%rsp) + shll $31, %r15d + xorl %r15d, 84(%rsp) + jmp ..B1.79 +..B1.68: + testl %r12d, %r12d + je ..B1.71 +..B1.69: + movl %r14d, %edi + fstpt (%rsp) +..___tag_value_tgamma.71: + call fesetround@PLT +..___tag_value_tgamma.72: +..B1.70: + fldt (%rsp) + movsd 16(%rsp), %xmm0 +..B1.71: + movsd %xmm0, 64(%rsp) + fldl 64(%rsp) + fdivrp %st, %st(1) + fstpl 80(%rsp) + jmp ..B1.79 +..B1.72: + testl %ebx, %ebx + je ..B1.76 +..B1.73: + fldt 48(%rsp) + testl %r12d, %r12d + fmulp %st, %st(2) + fmulp %st, %st(1) + movsd %xmm3, 64(%rsp) + fldl 64(%rsp) + fdivp %st, %st(1) + fstpt (%rsp) + je ..B1.75 +..B1.74: + movl %r14d, %edi +..___tag_value_tgamma.73: + call fesetround@PLT +..___tag_value_tgamma.74: +..B1.75: + fldt (%rsp) + fstpl 80(%rsp) + jmp ..B1.79 +..B1.76: + fstp %st(1) + testl %r12d, %r12d + je ..B1.78 +..B1.77: + movl %r14d, %edi + fstpt (%rsp) +..___tag_value_tgamma.75: + call fesetround@PLT +..___tag_value_tgamma.76: +..B1.123: + fldt (%rsp) +..B1.78: + fstpl 80(%rsp) +..B1.79: + testb %r13b, %r13b + je ..B1.81 +..B1.80: + fldcw 90(%rsp) +..B1.81: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.82: + testl %r12d, %r12d + je ..B1.84 +..B1.83: + movl %r14d, %edi +..___tag_value_tgamma.97: + call fesetround@PLT +..___tag_value_tgamma.98: +..B1.84: + movsd (%rsp), %xmm0 + testb %r13b, %r13b + divsd %xmm0, %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.86 +..B1.85: + fldcw 90(%rsp) +..B1.86: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.87: + testl %r12d, %r12d + je ..B1.89 +..B1.88: + movl %r14d, %edi +..___tag_value_tgamma.119: + call fesetround@PLT +..___tag_value_tgamma.120: +..B1.89: + movsd (%rsp), %xmm0 + testb %r13b, %r13b + divsd %xmm0, %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.91 +..B1.90: + fldcw 90(%rsp) +..B1.91: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.92: + testl %r12d, %r12d + je ..B1.94 +..B1.93: + movl %r14d, %edi +..___tag_value_tgamma.141: + call fesetround@PLT +..___tag_value_tgamma.142: +..B1.94: + lea _large_value_64(%rip), %rax + testb %r13b, %r13b + movsd (%rax), %xmm0 + mulsd %xmm0, %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.96 +..B1.95: + fldcw 90(%rsp) +..B1.96: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.97: + testl %ecx, %ecx + jne ..B1.14 +..B1.98: + testl %r12d, %r12d + je ..B1.100 +..B1.99: + movl %r14d, %edi +..___tag_value_tgamma.163: + call fesetround@PLT +..___tag_value_tgamma.164: +..B1.100: + movl %ebx, %ebx + lea _large_value_64(%rip), %rax + testb %r13b, %r13b + movsd (%rax,%rbx,8), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.102 +..B1.101: + fldcw 90(%rsp) +..B1.102: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.103: + testl %r12d, %r12d + je ..B1.105 +..B1.104: + movl %r14d, %edi +..___tag_value_tgamma.185: + call fesetround@PLT +..___tag_value_tgamma.186: +..B1.105: + lea _ones(%rip), %rax + testb %r13b, %r13b + movsd (%rax,%rbx,8), %xmm0 + divsd (%rsp), %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.107 +..B1.106: + fldcw 90(%rsp) +..B1.107: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.108: + testl %r12d, %r12d + je ..B1.110 +..B1.109: + movl %r14d, %edi +..___tag_value_tgamma.207: + call fesetround@PLT +..___tag_value_tgamma.208: +..B1.110: + testl %ebx, %ebx + je ..B1.113 +..B1.111: + testl $1048575, 76(%rsp) + jne ..B1.113 +..B1.112: + cmpl $0, 72(%rsp) + je ..B1.116 +..B1.113: + lea _ones(%rip), %rax + testb %r13b, %r13b + movsd 72(%rsp), %xmm0 + mulsd (%rax), %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.115 +..B1.114: + fldcw 90(%rsp) +..B1.115: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 160 + .cfi_offset 3, -48 + .cfi_offset 6, -56 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 + .cfi_offset 15, -40 +..B1.116: + lea 8+_zeros(%rip), %rax + testb %r13b, %r13b + movsd (%rax), %xmm0 + divsd (%r15), %xmm0 + movsd %xmm0, 80(%rsp) + je ..B1.118 +..B1.117: + fldcw 90(%rsp) +..B1.118: + movsd 80(%rsp), %xmm0 + addq $104, %rsp + .cfi_def_cfa_offset 56 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 48 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 40 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type tgamma,@function + .size tgamma,.-tgamma + .data +# -- End tgamma + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.5: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0xc0672000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +.L_2il0floatpacket.1: + .long 0x00000000,0x40000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,8 + .align 8 +.L_2il0floatpacket.4: + .long 0x00000000,0xc0660000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_52H: + .long 0 + .long 1127743488 + .type _TWO_52H,@object + .size _TWO_52H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_small_value_64: + .long 0 + .long 24117248 + .long 0 + .long 2171600896 + .type _small_value_64,@object + .size _small_value_64,16 + .align 4 +_overflow_boundary: + .long 3848402504 + .long 1080390650 + .type _overflow_boundary,@object + .size _overflow_boundary,8 + .align 4 +_local_minimum: + .long 2371549438 + .long 1071483745 + .type _local_minimum,@object + .size _local_minimum,8 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 2 +_tgamma_sin_table: + .word 39192 + .word 38974 + .word 13074 + .word 53901 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 25233 + .word 24099 + .word 23041 + .word 53198 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 14010 + .word 1755 + .word 29241 + .word 50004 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 12661 + .word 39557 + .word 743 + .word 54836 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 23329 + .word 12349 + .word 46418 + .word 39360 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 43549 + .word 22984 + .word 36093 + .word 39843 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 50635 + .word 59140 + .word 19560 + .word 59922 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 39826 + .word 40176 + .word 51583 + .word 34788 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 63061 + .word 25910 + .word 60600 + .word 64252 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 21154 + .word 4399 + .word 17218 + .word 48316 + .word 16350 + .word 0 + .word 0 + .word 0 + .type _tgamma_sin_table,@object + .size _tgamma_sin_table,160 + .align 2 +_tgamma_A_table: + .word 44002 + .word 44608 + .word 34249 + .word 61198 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 28120 + .word 46089 + .word 18909 + .word 51744 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 6796 + .word 56365 + .word 948 + .word 39330 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 21872 + .word 3113 + .word 40348 + .word 48989 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 15275 + .word 60291 + .word 893 + .word 59613 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 41018 + .word 41834 + .word 14754 + .word 46766 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 10107 + .word 10320 + .word 24796 + .word 32841 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 40832 + .word 16832 + .word 38712 + .word 55795 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 8761 + .word 28554 + .word 35431 + .word 39961 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 12838 + .word 702 + .word 32174 + .word 51595 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 442 + .word 50835 + .word 62234 + .word 59850 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 53618 + .word 2208 + .word 54662 + .word 64445 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 33537 + .word 7687 + .word 12653 + .word 64976 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 5604 + .word 18060 + .word 46944 + .word 34352 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 5422 + .word 18393 + .word 57870 + .word 37869 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 27417 + .word 51069 + .word 14904 + .word 43119 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 16515 + .word 36952 + .word 46206 + .word 50255 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 22913 + .word 57796 + .word 61047 + .word 59491 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 55054 + .word 14521 + .word 23522 + .word 35521 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 3828 + .word 37429 + .word 19301 + .word 42457 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 18611 + .word 8353 + .word 56126 + .word 50041 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 63177 + .word 14708 + .word 18871 + .word 56010 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 51349 + .word 6910 + .word 18794 + .word 33038 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 59411 + .word 13918 + .word 30079 + .word 63615 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 40356 + .word 37493 + .word 20410 + .word 60584 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 59667 + .word 1960 + .word 42334 + .word 54496 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 24443 + .word 19594 + .word 17897 + .word 45291 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 24957 + .word 63432 + .word 54964 + .word 32848 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 7770 + .word 43625 + .word 45329 + .word 33905 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 34249 + .word 63845 + .word 17962 + .word 44463 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 49963 + .word 34728 + .word 51109 + .word 54055 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 57585 + .word 19701 + .word 6443 + .word 57077 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 61186 + .word 8282 + .word 25787 + .word 47837 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 26720 + .word 42621 + .word 41546 + .word 37680 + .word 49154 + .word 0 + .word 0 + .word 0 + .word 18366 + .word 28044 + .word 60147 + .word 62846 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 6968 + .word 10789 + .word 37601 + .word 32880 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 60700 + .word 57063 + .word 36736 + .word 35909 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 61862 + .word 56439 + .word 50993 + .word 40752 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 41843 + .word 39363 + .word 59360 + .word 47812 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 63511 + .word 43763 + .word 855 + .word 57724 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 64510 + .word 20731 + .word 32839 + .word 35752 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 60398 + .word 46667 + .word 43836 + .word 45454 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 49807 + .word 23281 + .word 46849 + .word 59658 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 37270 + .word 40485 + .word 38862 + .word 41131 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 55072 + .word 194 + .word 57504 + .word 62944 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 6484 + .word 60537 + .word 3975 + .word 55679 + .word 16389 + .word 0 + .word 0 + .word 0 + .word 11759 + .word 24340 + .word 39489 + .word 49925 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 22650 + .word 18020 + .word 56002 + .word 47553 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 65458 + .word 2450 + .word 7569 + .word 42768 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 2740 + .word 58538 + .word 8888 + .word 35477 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 24012 + .word 19369 + .word 10014 + .word 51050 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 32754 + .word 14555 + .word 56874 + .word 50646 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 6322 + .word 39288 + .word 8326 + .word 56228 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 51606 + .word 9409 + .word 56084 + .word 47341 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 19293 + .word 17746 + .word 29435 + .word 49011 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 22538 + .word 37169 + .word 56949 + .word 41021 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 65507 + .word 8897 + .word 64576 + .word 64934 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 21309 + .word 38834 + .word 44023 + .word 38745 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 52933 + .word 53016 + .word 24774 + .word 40865 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 4045 + .word 21262 + .word 61923 + .word 45295 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 26065 + .word 18177 + .word 3420 + .word 52438 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 45505 + .word 1968 + .word 16227 + .word 62949 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 1037 + .word 13974 + .word 10559 + .word 38924 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 39502 + .word 38026 + .word 65467 + .word 49371 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 34978 + .word 59813 + .word 17957 + .word 64181 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 4031 + .word 54789 + .word 33142 + .word 42976 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 2719 + .word 21031 + .word 60489 + .word 60330 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 20734 + .word 53765 + .word 40154 + .word 46919 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 63028 + .word 7231 + .word 17811 + .word 43725 + .word 16468 + .word 0 + .word 0 + .word 0 + .word 32606 + .word 48355 + .word 22399 + .word 43710 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 29042 + .word 46559 + .word 51950 + .word 41588 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 47396 + .word 18113 + .word 2918 + .word 37305 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 22233 + .word 40098 + .word 6225 + .word 61543 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 611 + .word 49379 + .word 57729 + .word 43678 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 10450 + .word 9675 + .word 56147 + .word 41083 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 37401 + .word 8271 + .word 47219 + .word 34504 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 34774 + .word 15943 + .word 11357 + .word 45081 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 6639 + .word 15692 + .word 42534 + .word 45536 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 51630 + .word 6378 + .word 12961 + .word 37818 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 59527 + .word 55742 + .word 41884 + .word 59714 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 15629 + .word 31501 + .word 45205 + .word 59448 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 53044 + .word 1871 + .word 3840 + .word 62990 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 49829 + .word 44544 + .word 39222 + .word 35206 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 8319 + .word 42513 + .word 20106 + .word 41214 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 56062 + .word 65309 + .word 8860 + .word 50097 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 39637 + .word 65 + .word 3840 + .word 62744 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 8819 + .word 49083 + .word 32007 + .word 40272 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 33763 + .word 5027 + .word 16250 + .word 52917 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 4751 + .word 2633 + .word 61342 + .word 35759 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 8844 + .word 54174 + .word 63762 + .word 50574 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 8334 + .word 8890 + .word 4484 + .word 39560 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 4811 + .word 30700 + .word 3620 + .word 48492 + .word 16556 + .word 0 + .word 0 + .word 0 + .word 24963 + .word 23772 + .word 56823 + .word 39936 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 33598 + .word 3946 + .word 44700 + .word 37958 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 46964 + .word 13072 + .word 50440 + .word 33963 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 60803 + .word 30641 + .word 14857 + .word 55738 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 54016 + .word 37905 + .word 6345 + .word 39067 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 52847 + .word 8984 + .word 26176 + .word 34926 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 36664 + .word 26865 + .word 35876 + .word 39170 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 52449 + .word 52544 + .word 53629 + .word 43890 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 12025 + .word 58412 + .word 44187 + .word 43481 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 31442 + .word 43543 + .word 55683 + .word 35857 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 3846 + .word 7199 + .word 40600 + .word 56439 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 59606 + .word 22885 + .word 19144 + .word 49661 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 40642 + .word 40248 + .word 11664 + .word 52797 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 62936 + .word 44294 + .word 39296 + .word 59383 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 2909 + .word 51304 + .word 40819 + .word 35037 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 28573 + .word 45780 + .word 52012 + .word 42966 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 18650 + .word 49015 + .word 44104 + .word 54288 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 55601 + .word 45035 + .word 39824 + .word 35129 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 34144 + .word 30699 + .word 57231 + .word 46486 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 46246 + .word 1151 + .word 17498 + .word 63193 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 4951 + .word 25890 + .word 61661 + .word 44882 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 6537 + .word 64648 + .word 46171 + .word 35209 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 3418 + .word 59105 + .word 44678 + .word 47100 + .word 16651 + .word 0 + .word 0 + .word 0 + .word 12496 + .word 39220 + .word 65358 + .word 37319 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 42985 + .word 15941 + .word 31416 + .word 35438 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 48809 + .word 58407 + .word 25474 + .word 63277 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 16086 + .word 46002 + .word 58617 + .word 51682 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 55157 + .word 44549 + .word 61270 + .word 35823 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 21856 + .word 27160 + .word 26283 + .word 61078 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 57421 + .word 61358 + .word 44892 + .word 42671 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 51328 + .word 61945 + .word 60158 + .word 43127 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 51733 + .word 1166 + .word 54323 + .word 42075 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 52270 + .word 46964 + .word 5686 + .word 34493 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 2083 + .word 1761 + .word 7136 + .word 54130 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 16904 + .word 37253 + .word 64186 + .word 43390 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 30519 + .word 46073 + .word 2795 + .word 46255 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 6923 + .word 13957 + .word 9241 + .word 52280 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 60036 + .word 4102 + .word 42534 + .word 62082 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 23471 + .word 7124 + .word 59867 + .word 38328 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 43652 + .word 58293 + .word 38720 + .word 48757 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 30217 + .word 2002 + .word 31515 + .word 63491 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 32079 + .word 61591 + .word 63175 + .word 42230 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 708 + .word 13247 + .word 38402 + .word 57649 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 48098 + .word 14626 + .word 62525 + .word 41069 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 41824 + .word 29269 + .word 27314 + .word 64550 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 61231 + .word 60847 + .word 45074 + .word 55796 + .word 16751 + .word 0 + .word 0 + .word 0 + .word 41222 + .word 6965 + .word 41751 + .word 35359 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 3873 + .word 17289 + .word 23432 + .word 33549 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 31267 + .word 5735 + .word 3862 + .word 59787 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 54508 + .word 24423 + .word 13439 + .word 48632 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 1373 + .word 13548 + .word 5598 + .word 33375 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 51134 + .word 47274 + .word 24966 + .word 54404 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 6577 + .word 45385 + .word 2362 + .word 45409 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 3828 + .word 42112 + .word 22766 + .word 42583 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 12956 + .word 14074 + .word 46709 + .word 41030 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 36968 + .word 52126 + .word 60443 + .word 33467 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 6923 + .word 15273 + .word 58034 + .word 52381 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 32660 + .word 35575 + .word 5652 + .word 38971 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 58845 + .word 37118 + .word 55534 + .word 41636 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 18460 + .word 14335 + .word 18170 + .word 47252 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 64257 + .word 33925 + .word 29284 + .word 56405 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 4762 + .word 47478 + .word 23933 + .word 35021 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 60070 + .word 43233 + .word 33997 + .word 44796 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 15498 + .word 56159 + .word 37136 + .word 58624 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 45618 + .word 14567 + .word 62599 + .word 39157 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 56427 + .word 8703 + .word 58958 + .word 53630 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 17868 + .word 58209 + .word 63399 + .word 38294 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 23727 + .word 3602 + .word 56293 + .word 60260 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 11566 + .word 31203 + .word 21261 + .word 41104 + .word 16856 + .word 0 + .word 0 + .word 0 + .word 50659 + .word 54826 + .word 2447 + .word 33815 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 40123 + .word 27511 + .word 38472 + .word 64120 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 60369 + .word 44894 + .word 35604 + .word 57033 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 46499 + .word 27632 + .word 5436 + .word 46222 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 30082 + .word 48277 + .word 45112 + .word 62871 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 22164 + .word 19009 + .word 61576 + .word 49094 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 46565 + .word 37565 + .word 23059 + .word 47623 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 32180 + .word 46156 + .word 40449 + .word 42167 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 43791 + .word 4543 + .word 64119 + .word 40210 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 35508 + .word 36368 + .word 50300 + .word 65316 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 24682 + .word 25954 + .word 24264 + .word 50994 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 2360 + .word 57697 + .word 56537 + .word 35655 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 35000 + .word 46863 + .word 45329 + .word 38168 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 34434 + .word 1782 + .word 6514 + .word 43468 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 42662 + .word 49367 + .word 10572 + .word 52120 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 20865 + .word 43286 + .word 18750 + .word 65033 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 9813 + .word 41323 + .word 59938 + .word 41786 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 37980 + .word 55255 + .word 47419 + .word 54914 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 3267 + .word 59107 + .word 21702 + .word 36808 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 56442 + .word 35583 + .word 19842 + .word 50549 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 14786 + .word 14705 + .word 8555 + .word 36161 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 5861 + .word 33921 + .word 55110 + .word 56952 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 12507 + .word 56326 + .word 38818 + .word 47266 + .word 16964 + .word 0 + .word 0 + .word 0 + .word 3472 + .word 16935 + .word 53300 + .word 65107 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 37860 + .word 60441 + .word 22458 + .word 61688 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 12243 + .word 56252 + .word 28016 + .word 54783 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 4212 + .word 39051 + .word 42484 + .word 44250 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 23380 + .word 35543 + .word 1695 + .word 59694 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 16948 + .word 23513 + .word 25700 + .word 44731 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 46140 + .word 40761 + .word 17956 + .word 49463 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 31263 + .word 46633 + .word 29941 + .word 41835 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 63205 + .word 61824 + .word 34317 + .word 39543 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 2572 + .word 33857 + .word 17789 + .word 63992 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 34199 + .word 18923 + .word 17606 + .word 49855 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 56334 + .word 35260 + .word 24180 + .word 33058 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 60689 + .word 52750 + .word 35337 + .word 35448 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 55452 + .word 53681 + .word 28550 + .word 40494 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 52405 + .word 7414 + .word 26290 + .word 48744 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 27310 + .word 49480 + .word 17006 + .word 61076 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 58002 + .word 7573 + .word 241 + .word 39403 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 30618 + .word 4587 + .word 23737 + .word 51968 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 41850 + .word 57331 + .word 43567 + .word 34937 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 44076 + .word 54284 + .word 21386 + .word 48090 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 47582 + .word 54033 + .word 55369 + .word 34454 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 6559 + .word 5249 + .word 7172 + .word 54302 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 25070 + .word 13550 + .word 42045 + .word 60321 + .word 17075 + .word 0 + .word 0 + .word 0 + .word 25751 + .word 29482 + .word 15881 + .word 62993 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 20424 + .word 12720 + .word 54361 + .word 59648 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 47709 + .word 29790 + .word 54671 + .word 52895 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 19590 + .word 27782 + .word 43363 + .word 42595 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 58921 + .word 35180 + .word 21269 + .word 57023 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30519 + .word 24253 + .word 59969 + .word 41055 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 16433 + .word 48540 + .word 61714 + .word 51024 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 28524 + .word 50460 + .word 14901 + .word 41561 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 3212 + .word 32692 + .word 57818 + .word 38984 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 39499 + .word 42357 + .word 61063 + .word 62879 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 23069 + .word 2532 + .word 8249 + .word 48896 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 10213 + .word 8193 + .word 57687 + .word 61912 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 54407 + .word 51976 + .word 21399 + .word 33245 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 30319 + .word 6795 + .word 56359 + .word 38081 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 56783 + .word 23918 + .word 44955 + .word 45999 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 48670 + .word 51841 + .word 19543 + .word 57851 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 40765 + .word 30890 + .word 33317 + .word 37455 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 26976 + .word 54195 + .word 64249 + .word 49555 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 53450 + .word 46734 + .word 58278 + .word 33402 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 16139 + .word 61138 + .word 10791 + .word 46069 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 19833 + .word 46025 + .word 1951 + .word 33050 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 63698 + .word 28854 + .word 16724 + .word 52116 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 51628 + .word 52030 + .word 9741 + .word 32928 + .word 17190 + .word 0 + .word 0 + .word 0 + .word 12285 + .word 10951 + .word 58642 + .word 61183 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 21683 + .word 21165 + .word 28859 + .word 57903 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 16106 + .word 65177 + .word 61473 + .word 51279 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 10066 + .word 60251 + .word 8712 + .word 41178 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 11765 + .word 63661 + .word 54012 + .word 54733 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 6745 + .word 52609 + .word 60525 + .word 37899 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 48001 + .word 64846 + .word 20212 + .word 52373 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 17748 + .word 43200 + .word 11817 + .word 41329 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 21018 + .word 45635 + .word 21983 + .word 38507 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 3148 + .word 52957 + .word 41657 + .word 61926 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 4827 + .word 784 + .word 31692 + .word 48072 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 34179 + .word 53889 + .word 29926 + .word 58425 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 50615 + .word 27492 + .word 10833 + .word 62832 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 38001 + .word 13025 + .word 51995 + .word 36075 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 57519 + .word 47991 + .word 3845 + .word 43713 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 52312 + .word 45573 + .word 61386 + .word 55158 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 13085 + .word 59531 + .word 16529 + .word 35826 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 20993 + .word 34790 + .word 57361 + .word 47533 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 9726 + .word 28278 + .word 20623 + .word 64228 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 29543 + .word 44397 + .word 26216 + .word 44369 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 63031 + .word 4436 + .word 65303 + .word 63733 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 3202 + .word 26777 + .word 12818 + .word 50273 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 59134 + .word 17584 + .word 37875 + .word 50102 + .word 17306 + .word 0 + .word 0 + .word 0 + .word 7773 + .word 6529 + .word 24897 + .word 59610 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 9176 + .word 34994 + .word 24066 + .word 56385 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 38670 + .word 17644 + .word 9278 + .word 49874 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 31722 + .word 46384 + .word 26212 + .word 39944 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 4438 + .word 35654 + .word 55200 + .word 52739 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 27356 + .word 43702 + .word 58298 + .word 35147 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 11597 + .word 6768 + .word 60887 + .word 53553 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 2200 + .word 56289 + .word 1997 + .word 41129 + .word 49151 + .word 0 + .word 0 + .word 0 + .word 51208 + .word 51045 + .word 15577 + .word 38092 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 64525 + .word 30741 + .word 24355 + .word 61096 + .word 49152 + .word 0 + .word 0 + .word 0 + .word 16273 + .word 9188 + .word 1200 + .word 47354 + .word 49153 + .word 0 + .word 0 + .word 0 + .word 32505 + .word 64701 + .word 51161 + .word 55474 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 58255 + .word 43751 + .word 28307 + .word 59734 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 597 + .word 44015 + .word 59274 + .word 34374 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 17221 + .word 11824 + .word 60854 + .word 41770 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 32240 + .word 33006 + .word 58370 + .word 52867 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 22765 + .word 17058 + .word 17899 + .word 34437 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 3694 + .word 59578 + .word 1196 + .word 45807 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 37424 + .word 8934 + .word 53804 + .word 62023 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 6800 + .word 58264 + .word 43923 + .word 42913 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 27007 + .word 15916 + .word 20851 + .word 61705 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 33570 + .word 44306 + .word 22975 + .word 48691 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _tgamma_A_table,@object + .size _tgamma_A_table,4416 + .space 192, 0x00 # pad + .align 2 +_tgamma_A176_inv: + .word 38655 + .word 8470 + .word 22633 + .word 47709 + .word 15340 + .word 0 + .word 0 + .word 0 + .type _tgamma_A176_inv,@object + .size _tgamma_A176_inv,16 + .align 2 +_tgamma_A150_table: + .word 61060 + .word 8155 + .word 61816 + .word 65535 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 47752 + .word 30749 + .word 4057 + .word 37827 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 24760 + .word 16820 + .word 52631 + .word 64803 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 36324 + .word 24890 + .word 11532 + .word 59368 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 63381 + .word 49585 + .word 20519 + .word 63827 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 54086 + .word 22318 + .word 4776 + .word 62483 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 24236 + .word 16506 + .word 21666 + .word 59746 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 44402 + .word 44414 + .word 37650 + .word 53079 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 34766 + .word 8695 + .word 24359 + .word 42592 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30542 + .word 64415 + .word 14059 + .word 59378 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 36037 + .word 62568 + .word 21045 + .word 34628 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 39650 + .word 28877 + .word 62299 + .word 64900 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 43413 + .word 4175 + .word 59877 + .word 46549 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 13603 + .word 64648 + .word 43425 + .word 47701 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 48047 + .word 22044 + .word 23868 + .word 61943 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 17548 + .word 29243 + .word 63955 + .word 38195 + .word 49138 + .word 0 + .word 0 + .word 0 + .type _tgamma_A150_table,@object + .size _tgamma_A150_table,256 + .align 2 +_tgamma_A125_table: + .word 29804 + .word 14935 + .word 58389 + .word 58038 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 54039 + .word 49353 + .word 64455 + .word 62712 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 7246 + .word 48092 + .word 40889 + .word 56162 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 5238 + .word 25576 + .word 20384 + .word 34263 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 38009 + .word 2645 + .word 35759 + .word 42176 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 32410 + .word 34387 + .word 48471 + .word 48379 + .word 49147 + .word 0 + .word 0 + .word 0 + .word 9060 + .word 33571 + .word 56968 + .word 36683 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 26873 + .word 9749 + .word 59107 + .word 49208 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 61297 + .word 63742 + .word 25286 + .word 34210 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 6011 + .word 50033 + .word 7349 + .word 46841 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 30597 + .word 45929 + .word 271 + .word 64276 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 60120 + .word 8046 + .word 54753 + .word 44175 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 32461 + .word 45691 + .word 56111 + .word 58214 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 38908 + .word 23877 + .word 33636 + .word 50495 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 35983 + .word 59115 + .word 59685 + .word 60013 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 38519 + .word 97 + .word 2340 + .word 53304 + .word 49143 + .word 0 + .word 0 + .word 0 + .type _tgamma_A125_table,@object + .size _tgamma_A125_table,256 + .align 2 +_tgamma_A100_table: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 50486 + .word 32176 + .word 26595 + .word 37828 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 33232 + .word 55464 + .word 50705 + .word 64818 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 56000 + .word 37024 + .word 35961 + .word 59472 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 6308 + .word 2395 + .word 34858 + .word 64338 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 22779 + .word 60710 + .word 1868 + .word 64356 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 33054 + .word 60854 + .word 741 + .word 65087 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 46387 + .word 11445 + .word 51950 + .word 65273 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 6735 + .word 17127 + .word 21437 + .word 65409 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 40596 + .word 22792 + .word 61241 + .word 65445 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 7521 + .word 26365 + .word 15230 + .word 65303 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 33891 + .word 37638 + .word 54039 + .word 64371 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 37411 + .word 53884 + .word 56799 + .word 60663 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 30408 + .word 30767 + .word 55068 + .word 50398 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 49794 + .word 38369 + .word 16703 + .word 62901 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 52540 + .word 1662 + .word 21259 + .word 41989 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _tgamma_A100_table,@object + .size _tgamma_A100_table,256 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tgammaf.S b/external/sgx_libm/intel64/tgammaf.S new file mode 100644 index 0000000000..542a1e6d4b --- /dev/null +++ b/external/sgx_libm/intel64/tgammaf.S @@ -0,0 +1,1280 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tgammaf.c" + .text +..TXTST0: +# -- Begin tgammaf + .text + .align 16,0x90 + .globl tgammaf +tgammaf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_tgammaf.1: +..L2: + + pushq %r12 + .cfi_def_cfa_offset 16 + .cfi_offset 12, -16 + pushq %r13 + .cfi_def_cfa_offset 24 + .cfi_offset 13, -24 + pushq %r14 + .cfi_def_cfa_offset 32 + .cfi_offset 14, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $32, %rsp + .cfi_def_cfa_offset 80 + xorb %r12b, %r12b + pxor %xmm2, %xmm2 + pxor %xmm1, %xmm1 + movss %xmm0, 24(%rsp) + movd %xmm0, %r14d + movss %xmm1, (%rsp) + movsd %xmm2, 8(%rsp) +..___tag_value_tgammaf.14: + call fegetround@PLT +..___tag_value_tgammaf.15: +..B1.94: + movsd 8(%rsp), %xmm2 + movl %eax, %ebp +..B1.2: + testl %ebp, %ebp + je ..B1.4 +..B1.3: + xorl %edi, %edi + movb $1, %r12b + movsd %xmm2, 8(%rsp) +..___tag_value_tgammaf.16: + call fesetround@PLT +..___tag_value_tgammaf.17: +..B1.95: + movsd 8(%rsp), %xmm2 +..B1.4: + movzwl 26(%rsp), %eax + andl $32640, %eax + shrl $7, %eax + movl 24(%rsp), %ebx + shrl $31, %ebx + cmpl $255, %eax + je ..B1.84 +..B1.5: + movss 24(%rsp), %xmm5 + andl $2147483647, %r14d + movl %r14d, 8(%rsp) + ucomiss (%rsp), %xmm5 + jp ..B1.6 + je ..B1.81 +..B1.6: + cmpl $2097152, %r14d + jle ..B1.78 +..B1.7: + testl %ebx, %ebx + je ..B1.16 +..B1.8: + cmpl $150, %eax + jge ..B1.72 +..B1.9: + movss .L_2il0floatpacket.2(%rip), %xmm3 + movss 8(%rsp), %xmm4 + movaps %xmm3, %xmm1 + movss (%rsp), %xmm0 + addss %xmm4, %xmm1 + movss %xmm1, 20(%rsp) + movss %xmm0, 16(%rsp) + movss 20(%rsp), %xmm0 + movl 20(%rsp), %r14d + subss %xmm3, %xmm0 + comiss %xmm4, %xmm0 + jbe ..B1.11 +..B1.10: + incl %r14d + subss .L_2il0floatpacket.11(%rip), %xmm0 +..B1.11: + ucomiss %xmm0, %xmm4 + jp ..B1.12 + je ..B1.69 +..B1.12: + movss .L_2il0floatpacket.3(%rip), %xmm0 + comiss %xmm5, %xmm0 + jbe ..B1.17 +..B1.13: + testb %r12b, %r12b + je ..B1.15 +..B1.14: + movl %ebp, %edi +..___tag_value_tgammaf.18: + call fesetround@PLT +..___tag_value_tgammaf.19: +..B1.15: + lea _small_value_32(%rip), %rax + notl %r14d + andl $1, %r14d + movss (%rax,%r14,4), %xmm0 + mulss .L_2il0floatpacket.4(%rip), %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.16: + movss (%rsp), %xmm0 + movss %xmm0, 16(%rsp) +..B1.17: + cvtss2sd %xmm5, %xmm5 + lea _overflow_boundary(%rip), %rdx + comisd (%rdx), %xmm5 + jae ..B1.75 +..B1.18: + movss .L_2il0floatpacket.2(%rip), %xmm9 + testl %ebx, %ebx + je ..B1.20 +..B1.19: + movss 8(%rsp), %xmm8 + movaps %xmm9, %xmm2 + movaps %xmm8, %xmm1 + addss %xmm8, %xmm2 + movss %xmm2, 20(%rsp) + pxor %xmm2, %xmm2 + movss 20(%rsp), %xmm0 + lea 8+_tgamma_sin_table(%rip), %rcx + lea 24+_tgamma_sin_table(%rip), %r8 + subss %xmm9, %xmm0 + movsd (%rcx), %xmm7 + subss %xmm0, %xmm1 + movd %xmm1, %edx + lea 40+_tgamma_sin_table(%rip), %r10 + movsd (%r8), %xmm3 + andl $2147483647, %edx + lea _tgamma_sin_table(%rip), %rsi + movl %edx, (%rsp) + lea 56+_tgamma_sin_table(%rip), %r14 + movsd (%r10), %xmm4 + lea 16+_tgamma_sin_table(%rip), %r9 + lea 32+_tgamma_sin_table(%rip), %r11 + lea 48+_tgamma_sin_table(%rip), %rdx + cvtss2sd (%rsp), %xmm2 + movaps %xmm2, %xmm6 + mulsd %xmm2, %xmm6 + mulsd %xmm6, %xmm7 + addsd %xmm6, %xmm3 + addsd %xmm6, %xmm4 + mulsd %xmm6, %xmm3 + addsd (%rsi), %xmm7 + mulsd %xmm6, %xmm4 + mulsd %xmm6, %xmm7 + addsd (%r9), %xmm3 + addsd (%r11), %xmm4 + mulsd %xmm3, %xmm7 + movsd (%r14), %xmm5 + mulsd %xmm4, %xmm7 + addsd %xmm6, %xmm5 + mulsd %xmm5, %xmm6 + addsd (%rdx), %xmm6 + mulsd %xmm6, %xmm7 + mulsd %xmm2, %xmm7 + addsd %xmm7, %xmm2 + jmp ..B1.21 +..B1.20: + movss 8(%rsp), %xmm8 +..B1.21: + movaps %xmm8, %xmm1 + addss %xmm9, %xmm8 + movss %xmm8, 20(%rsp) + movss 20(%rsp), %xmm0 + movl 20(%rsp), %ecx + subss %xmm9, %xmm0 + andl $1048575, %ecx + comiss %xmm1, %xmm0 + jbe ..B1.23 +..B1.22: + decl %ecx + subss .L_2il0floatpacket.11(%rip), %xmm0 +..B1.23: + comiss .L_2il0floatpacket.5(%rip), %xmm1 + lea 1(%rcx), %r14d + jb ..B1.39 +..B1.24: + movaps %xmm1, %xmm3 + movl %ecx, %esi + andl $-8, %esi + movl %ecx, %edx + andl $7, %edx + cmpl $8, %ecx + movl %esi, %ecx + lea _tgamma_A_table(%rip), %r8 + subss %xmm0, %xmm3 + cvtss2sd %xmm3, %xmm3 + movaps %xmm3, %xmm8 + lea -2(%rdx), %eax + mulsd %xmm3, %xmm8 + cmovl %eax, %edx + sarl $1, %ecx + addl %esi, %ecx + sarl $3, %esi + addl %esi, %ecx + movslq %ecx, %rcx + testl %edx, %edx + movsd (%r8,%rcx,8), %xmm9 + mulsd %xmm3, %xmm9 + movsd 8(%r8,%rcx,8), %xmm0 + addsd %xmm8, %xmm9 + mulsd %xmm3, %xmm0 + addsd 48(%r8,%rcx,8), %xmm9 + addsd %xmm8, %xmm0 + mulsd 96(%r8,%rcx,8), %xmm9 + addsd 56(%r8,%rcx,8), %xmm0 + movsd 16(%r8,%rcx,8), %xmm4 + mulsd %xmm3, %xmm4 + mulsd %xmm0, %xmm9 + addsd %xmm8, %xmm4 + movsd 24(%r8,%rcx,8), %xmm5 + mulsd %xmm3, %xmm5 + addsd 64(%r8,%rcx,8), %xmm4 + movsd 32(%r8,%rcx,8), %xmm6 + addsd %xmm8, %xmm5 + mulsd %xmm3, %xmm6 + mulsd %xmm4, %xmm9 + addsd 72(%r8,%rcx,8), %xmm5 + addsd %xmm8, %xmm6 + mulsd %xmm5, %xmm9 + addsd 80(%r8,%rcx,8), %xmm6 + movsd 40(%r8,%rcx,8), %xmm7 + mulsd %xmm3, %xmm7 + mulsd %xmm6, %xmm9 + addsd %xmm7, %xmm8 + movsd .L_2il0floatpacket.10(%rip), %xmm3 + movsd %xmm3, 8(%rsp) + addsd 88(%r8,%rcx,8), %xmm8 + mulsd %xmm8, %xmm9 + movsd %xmm9, (%rsp) + je ..B1.29 +..B1.25: + movl $1, %eax + jle ..B1.29 +..B1.26: + pxor %xmm0, %xmm0 + cvtss2sd %xmm1, %xmm0 +..B1.27: + pxor %xmm4, %xmm4 + movaps %xmm0, %xmm5 + cvtsi2sd %eax, %xmm4 + incl %eax + subsd %xmm4, %xmm5 + mulsd %xmm5, %xmm3 + cmpl %edx, %eax + jle ..B1.27 +..B1.29: + testl %ebx, %ebx + je ..B1.35 +..B1.30: + cvtss2sd %xmm1, %xmm1 + mulsd %xmm2, %xmm1 + mulsd (%rsp), %xmm1 + mulsd %xmm3, %xmm1 + movsd 8(%rsp), %xmm0 + divsd %xmm1, %xmm0 + movss .L_2il0floatpacket.6(%rip), %xmm2 + movsd %xmm0, 8(%rsp) + comiss 24(%rsp), %xmm2 + jbe ..B1.32 +..B1.31: + lea _tgamma_A40_inv(%rip), %rax + mulsd (%rax), %xmm0 + movsd %xmm0, 8(%rsp) +..B1.32: + testb %r12b, %r12b + je ..B1.34 +..B1.33: + movl %ebp, %edi +..___tag_value_tgammaf.37: + call fesetround@PLT +..___tag_value_tgammaf.38: +..B1.34: + movsd 8(%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movd %xmm0, %eax + shll $31, %r14d + xorl %r14d, %eax + movl %eax, 16(%rsp) + movss 16(%rsp), %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.35: + movsd (%rsp), %xmm0 + testb %r12b, %r12b + mulsd %xmm3, %xmm0 + movsd %xmm0, (%rsp) + je ..B1.37 +..B1.36: + movl %ebp, %edi +..___tag_value_tgammaf.56: + call fesetround@PLT +..___tag_value_tgammaf.57: +..B1.37: + movsd (%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 16(%rsp) +..B1.38: + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.39: + movss .L_2il0floatpacket.11(%rip), %xmm6 + pxor %xmm0, %xmm0 + cvtss2sd %xmm1, %xmm0 + comiss %xmm1, %xmm6 + jbe ..B1.41 +..B1.40: + movsd .L_2il0floatpacket.10(%rip), %xmm3 + addsd %xmm0, %xmm3 + jmp ..B1.42 +..B1.41: + movaps %xmm0, %xmm3 +..B1.42: + comisd .L_2il0floatpacket.7(%rip), %xmm3 + jb ..B1.44 +..B1.43: + lea _tgamma_A175_table(%rip), %r13 + subsd .L_2il0floatpacket.10(%rip), %xmm3 + cvtsd2ss %xmm3, %xmm3 + movss %xmm3, (%rsp) + jmp ..B1.50 +..B1.44: + comisd .L_2il0floatpacket.8(%rip), %xmm3 + jb ..B1.46 +..B1.45: + lea _tgamma_A150_table(%rip), %r13 + subsd .L_2il0floatpacket.10(%rip), %xmm3 + cvtsd2ss %xmm3, %xmm3 + movss %xmm3, (%rsp) + jmp ..B1.50 +..B1.46: + movsd .L_2il0floatpacket.9(%rip), %xmm4 + comisd %xmm4, %xmm3 + jb ..B1.48 +..B1.47: + lea _local_minimum(%rip), %rdx + lea _tgamma_A125_table(%rip), %r13 + movsd .L_2il0floatpacket.10(%rip), %xmm4 + addsd (%rdx), %xmm4 + subsd %xmm4, %xmm3 + cvtsd2ss %xmm3, %xmm3 + movss %xmm3, (%rsp) + jmp ..B1.50 +..B1.48: + comisd %xmm3, %xmm4 + jbe ..B1.50 +..B1.49: + lea _tgamma_A100_table(%rip), %r13 + subsd .L_2il0floatpacket.10(%rip), %xmm3 + cvtsd2ss %xmm3, %xmm3 + movss %xmm3, (%rsp) +..B1.50: + movsd (%r13), %xmm3 + testl %eax, %eax + movsd %xmm3, 8(%rsp) + je ..B1.53 +..B1.51: + pxor %xmm4, %xmm4 + cvtss2sd (%rsp), %xmm4 + movsd 56(%r13), %xmm3 + mulsd %xmm4, %xmm3 + movsd 8(%rsp), %xmm5 + addsd 48(%r13), %xmm3 + mulsd %xmm4, %xmm3 + addsd 40(%r13), %xmm3 + mulsd %xmm4, %xmm3 + addsd 32(%r13), %xmm3 + mulsd %xmm4, %xmm3 + addsd 24(%r13), %xmm3 + mulsd %xmm4, %xmm3 + addsd 16(%r13), %xmm3 + mulsd %xmm4, %xmm3 + addsd 8(%r13), %xmm3 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + movsd %xmm5, 8(%rsp) +..B1.53: + comiss %xmm1, %xmm6 + jbe ..B1.61 +..B1.54: + testl %ebx, %ebx + je ..B1.58 +..B1.55: + mulsd 8(%rsp), %xmm2 + testb %r12b, %r12b + movsd .L_2il0floatpacket.10(%rip), %xmm0 + divsd %xmm2, %xmm0 + movsd %xmm0, (%rsp) + je ..B1.57 +..B1.56: + movl %ebp, %edi +..___tag_value_tgammaf.75: + call fesetround@PLT +..___tag_value_tgammaf.76: +..B1.57: + movsd (%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movd %xmm0, %eax + shll $31, %r14d + xorl %r14d, %eax + movl %eax, 16(%rsp) + movss 16(%rsp), %xmm0 + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.58: + movsd 8(%rsp), %xmm1 + testb %r12b, %r12b + divsd %xmm0, %xmm1 + movsd %xmm1, 8(%rsp) + je ..B1.67 +..B1.59: + movl %ebp, %edi +..___tag_value_tgammaf.94: + call fesetround@PLT +..___tag_value_tgammaf.95: + jmp ..B1.67 +..B1.61: + testl %ebx, %ebx + je ..B1.65 +..B1.62: + mulsd %xmm0, %xmm2 + testb %r12b, %r12b + mulsd 8(%rsp), %xmm2 + movsd .L_2il0floatpacket.10(%rip), %xmm1 + divsd %xmm2, %xmm1 + movsd %xmm1, (%rsp) + je ..B1.64 +..B1.63: + movl %ebp, %edi +..___tag_value_tgammaf.96: + call fesetround@PLT +..___tag_value_tgammaf.97: +..B1.64: + movsd (%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.65: + testb %r12b, %r12b + je ..B1.67 +..B1.66: + movl %ebp, %edi +..___tag_value_tgammaf.115: + call fesetround@PLT +..___tag_value_tgammaf.116: +..B1.67: + movsd 8(%rsp), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, 16(%rsp) +..B1.68: + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.69: + testb %r12b, %r12b + je ..B1.71 +..B1.70: + movl %ebp, %edi +..___tag_value_tgammaf.134: + call fesetround@PLT +..___tag_value_tgammaf.135: +..B1.71: + movss (%rsp), %xmm0 + divss %xmm0, %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.72: + testb %r12b, %r12b + je ..B1.74 +..B1.73: + movl %ebp, %edi +..___tag_value_tgammaf.153: + call fesetround@PLT +..___tag_value_tgammaf.154: +..B1.74: + movss (%rsp), %xmm0 + divss %xmm0, %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.75: + testb %r12b, %r12b + je ..B1.77 +..B1.76: + movl %ebp, %edi +..___tag_value_tgammaf.172: + call fesetround@PLT +..___tag_value_tgammaf.173: +..B1.77: + movl $1904214016, 20(%rsp) + movss 20(%rsp), %xmm1 + movss 20(%rsp), %xmm0 + mulss %xmm0, %xmm1 + movss %xmm1, 20(%rsp) + movss 20(%rsp), %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.78: + movss (%rsp), %xmm0 + testb %r12b, %r12b + movss %xmm0, 16(%rsp) + je ..B1.80 +..B1.79: + movl %ebp, %edi +..___tag_value_tgammaf.191: + call fesetround@PLT +..___tag_value_tgammaf.192: +..B1.80: + movl %ebx, %ebx + lea _large_value_32(%rip), %rax + movl (%rax,%rbx,4), %edx + movl %edx, 20(%rsp) + movss 20(%rsp), %xmm0 + mulss .L_2il0floatpacket.0(%rip), %xmm0 + movss %xmm0, 20(%rsp) + movss 20(%rsp), %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.81: + testb %r12b, %r12b + je ..B1.83 +..B1.82: + movl %ebp, %edi +..___tag_value_tgammaf.210: + call fesetround@PLT +..___tag_value_tgammaf.211: +..B1.83: + lea _ones(%rip), %rax + movss (%rax,%rbx,4), %xmm0 + divss (%rsp), %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.84: + testb %r12b, %r12b + je ..B1.86 +..B1.85: + movl %ebp, %edi +..___tag_value_tgammaf.229: + call fesetround@PLT +..___tag_value_tgammaf.230: +..B1.86: + testl %ebx, %ebx + je ..B1.89 +..B1.87: + testl $8388607, 24(%rsp) + je ..B1.91 +..B1.89: + movss (%rsp), %xmm0 + movss %xmm0, 16(%rsp) + movl %r14d, 8(%rsp) +..B1.90: + movl 24(%rsp), %eax + movl %eax, 20(%rsp) + movss 20(%rsp), %xmm1 + movss 20(%rsp), %xmm0 + addss %xmm0, %xmm1 + movss %xmm1, 20(%rsp) + movss 20(%rsp), %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 80 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 12, -16 + .cfi_offset 13, -24 + .cfi_offset 14, -32 +..B1.91: + movss .L_2il0floatpacket.1(%rip), %xmm0 + divss (%rsp), %xmm0 + movss %xmm0, 16(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 24 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 16 + .cfi_restore 12 + popq %r12 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type tgammaf,@function + .size tgammaf,.-tgammaf + .data +# -- End tgammaf + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.7: + .long 0x00000000,0x3ffc0000 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,8 + .align 8 +.L_2il0floatpacket.8: + .long 0x00000000,0x3ff80000 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,8 + .align 8 +.L_2il0floatpacket.9: + .long 0x00000000,0x3ff40000 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,8 + .align 8 +.L_2il0floatpacket.10: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,8 + .align 4 +.L_2il0floatpacket.0: + .long 0x71800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x80000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +.L_2il0floatpacket.2: + .long 0x4b400000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,4 + .align 4 +.L_2il0floatpacket.3: + .long 0xc22c0000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,4 + .align 4 +.L_2il0floatpacket.4: + .long 0x0d800000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,4 + .align 4 +.L_2il0floatpacket.5: + .long 0x40000000 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,4 + .align 4 +.L_2il0floatpacket.6: + .long 0xc2200000 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,4 + .align 4 +.L_2il0floatpacket.11: + .long 0x3f800000 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,4 + .align 4 +_small_value_32: + .long 226492416 + .long 2373976064 + .type _small_value_32,@object + .size _small_value_32,8 + .align 4 +_overflow_boundary: + .long 0 + .long 1078035746 + .type _overflow_boundary,@object + .size _overflow_boundary,8 + .align 4 +_tgamma_sin_table: + .long 1980114658 + .long 3200337074 + .long 804494867 + .long 1049689241 + .long 2884431818 + .long 1079329239 + .long 930502348 + .long 3223780109 + .long 1245824743 + .long 1080878479 + .long 2510431012 + .long 1073721695 + .long 1661126174 + .long 1078219640 + .long 1205599443 + .long 3223573914 + .type _tgamma_sin_table,@object + .size _tgamma_sin_table,64 + .align 4 +_tgamma_A_table: + .long 3121394612 + .long 1074393041 + .long 2029996066 + .long 1073722195 + .long 4137005464 + .long 1071238760 + .long 3372276227 + .long 3220751114 + .long 68401302 + .long 3222286887 + .long 1275947047 + .long 3223263002 + .long 4031994882 + .long 1074665426 + .long 1089993416 + .long 1074817170 + .long 427005612 + .long 1075089294 + .long 1508975772 + .long 1075601433 + .long 2111623053 + .long 1076192020 + .long 75538972 + .long 1077100653 + .long 2171869559 + .long 1055005400 + .long 2919987515 + .long 1074143787 + .long 860307162 + .long 1073890599 + .long 2407232453 + .long 1073038722 + .long 1468490975 + .long 3216757264 + .long 846192051 + .long 3221294835 + .long 402234383 + .long 3222573752 + .long 2566208764 + .long 1073763360 + .long 162360449 + .long 1073949715 + .long 1512348533 + .long 1074371728 + .long 2920174397 + .long 1074968946 + .long 3785085665 + .long 1075671857 + .long 1922428759 + .long 1076496000 + .long 2446382284 + .long 1072101083 + .long 42366358 + .long 1073746704 + .long 3587290866 + .long 1073390434 + .long 1169958761 + .long 1072607731 + .long 3891474799 + .long 3217275878 + .long 1452792685 + .long 3221010072 + .long 1006385979 + .long 3222363118 + .long 3663632771 + .long 1072778759 + .long 3212960448 + .long 1073036150 + .long 2202365811 + .long 1073636095 + .long 2023822532 + .long 1074258740 + .long 40477660 + .long 1075053854 + .long 658935515 + .long 1076010306 + .long 932572503 + .long 1105834679 + .long 1233355998 + .long 1073412029 + .long 3033646034 + .long 1073097432 + .long 3149182759 + .long 1072206908 + .long 1726027606 + .long 3217766868 + .long 3439348786 + .long 3220880557 + .long 2080997065 + .long 3222253033 + .long 843307201 + .long 1072200111 + .long 3138702878 + .long 1072613342 + .long 3610734718 + .long 1073142430 + .long 2651617324 + .long 1073914526 + .long 2611481547 + .long 1074796471 + .long 3284459136 + .long 1075745821 + .long 1365755587 + .long 1144167771 + .long 2699624028 + .long 1073212595 + .long 2232824171 + .long 1072922970 + .long 3659224963 + .long 1071959670 + .long 3026238542 + .long 3218100813 + .long 4240441539 + .long 3220810712 + .long 1772362075 + .long 3222132889 + .long 3742687744 + .long 1071863890 + .long 56227394 + .long 1072220001 + .long 969667939 + .long 1072882737 + .long 880059910 + .long 1073714908 + .long 247554419 + .long 1074515829 + .long 48918556 + .long 1075495246 + .long 2601377264 + .long 1185936586 + .long 3625529495 + .long 1073077476 + .long 3298250746 + .long 1072804056 + .long 2971501690 + .long 1071788510 + .long 2950162741 + .long 3218231788 + .long 26528490 + .long 3220765509 + .long 3761284804 + .long 3222050392 + .long 3800626879 + .long 1071658634 + .long 1108715276 + .long 1071977390 + .long 286829382 + .long 1072720005 + .long 3141975933 + .long 1073477575 + .long 4145290123 + .long 1074329952 + .long 2167683451 + .long 1075329952 + .long 0 + .long 1072693248 + .type _tgamma_A_table,@object + .size _tgamma_A_table,624 + .align 4 +_tgamma_A40_inv: + .long 3988571200 + .long 914969834 + .type _tgamma_A40_inv,@object + .size _tgamma_A40_inv,8 + .align 4 +_tgamma_A175_table: + .long 1682645026 + .long 1072688670 + .long 3753006229 + .long 3219243438 + .long 177700005 + .long 1072453288 + .long 3289039035 + .long 3219374666 + .long 2492560830 + .long 1071326765 + .long 123078934 + .long 3217486055 + .long 3499570675 + .long 1068068407 + .long 1362583934 + .long 3212265128 + .type _tgamma_A175_table,@object + .size _tgamma_A175_table,64 + .align 4 +_tgamma_A150_table: + .long 988281800 + .long 1072692321 + .long 502740408 + .long 3219277207 + .long 2058512241 + .long 1072588117 + .long 2109547492 + .long 3219675970 + .long 3371209031 + .long 1071892748 + .long 3191518250 + .long 3218447665 + .long 3816909947 + .long 1069498883 + .long 1366906983 + .long 3214177035 + .type _tgamma_A150_table,@object + .size _tgamma_A150_table,64 + .align 4 +_local_minimum: + .long 2371549438 + .long 1071483745 + .type _local_minimum,@object + .size _local_minimum,8 + .align 4 +_tgamma_A125_table: + .long 2191760034 + .long 1072453340 + .long 2642694891 + .long 3186525859 + .long 1706815263 + .long 1071344724 + .long 1896485049 + .long 3217079006 + .long 441733475 + .long 1069848224 + .long 978611902 + .long 3216500728 + .long 351495825 + .long 1068442485 + .long 1680249708 + .long 3216253219 + .type _tgamma_A125_table,@object + .size _tgamma_A125_table,64 + .align 4 +_tgamma_A100_table: + .long 4293468318 + .long 1072693247 + .long 3444857508 + .long 3219290252 + .long 3510931740 + .long 1072670280 + .long 3644082616 + .long 3219982336 + .long 2685454907 + .long 1072646231 + .long 4151446349 + .long 3220059936 + .long 4004008463 + .long 1072263166 + .long 1217534056 + .long 3218706582 + .type _tgamma_A100_table,@object + .size _tgamma_A100_table,64 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/tgammal.S b/external/sgx_libm/intel64/tgammal.S new file mode 100644 index 0000000000..5153d99b22 --- /dev/null +++ b/external/sgx_libm/intel64/tgammal.S @@ -0,0 +1,4186 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "tgammal.c" + .text +..TXTST0: +# -- Begin tgammal + .text + .align 16,0x90 + .globl tgammal +tgammal: +# parameter 1: 368 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_tgammal.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + pushq %rbp + .cfi_def_cfa_offset 48 + .cfi_offset 6, -48 + subq $320, %rsp + .cfi_def_cfa_offset 368 + xorb %bpl, %bpl + fldt 368(%rsp) + xorb %r14b, %r14b + movq %fs:40, %rax + xorq %rsp, %rax + movq %rax, 304(%rsp) + fstpt 240(%rsp) +..B1.2: + fnstcw 258(%rsp) +..B1.3: + movzwl 258(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.7 +..B1.4: + orl $-64768, %edx + movw %dx, 256(%rsp) +..B1.5: + fldcw 256(%rsp) +..B1.6: + movb $1, %r14b +..B1.7: +..___tag_value_tgammal.14: + call fegetround@PLT +..___tag_value_tgammal.15: +..B1.195: + movl %eax, %r13d +..B1.8: + testl %r13d, %r13d + je ..B1.10 +..B1.9: + xorl %edi, %edi + movb $1, %bpl +..___tag_value_tgammal.16: + call fesetround@PLT +..___tag_value_tgammal.17: +..B1.10: + movl 376(%rsp), %ebx + movzwl 376(%rsp), %ecx + shrl $15, %ebx + andl $32767, %ecx + andl $1, %ebx + cmpl $32767, %ecx + je ..B1.178 +..B1.11: + fldt 368(%rsp) + lea _zeros(%rip), %rax + andl $32767, 248(%rsp) + fldl (%rax) + movsd (%rax), %xmm0 + fstpt 224(%rsp) + fldt 224(%rsp) + fucomip %st(1), %st + jp ..B1.12 + je ..B1.171 +..B1.12: + testl %ebx, %ebx + je ..B1.24 +..B1.13: + cmpl $16446, %ecx + jge ..B1.142 +..B1.14: + fldt 240(%rsp) + lea _TWO_63H(%rip), %rax + fld %st(0) + fldl (%rax) + fadd %st, %st(1) + fxch %st(1) + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(1) + movl 112(%rsp), %r15d + fcomi %st(1), %st + jbe ..B1.16 +..B1.15: + lea _ones(%rip), %rax + incl %r15d + fsubl (%rax) +..B1.16: + fucomip %st(1), %st + fstp %st(0) + jp ..B1.17 + je ..B1.135 +..B1.17: + fldt .L_2il0floatpacket.0(%rip) + fcomip %st(1), %st + jbe ..B1.24 +..B1.18: + fstp %st(0) + testb %bpl, %bpl + je ..B1.20 +..B1.19: + movl %r13d, %edi +..___tag_value_tgammal.18: + call fesetround@PLT +..___tag_value_tgammal.19: +..B1.20: + notl %r15d + lea _small_value_80(%rip), %rax + andl $1, %r15d + shlq $4, %r15 + fldt (%rax) + testb %r14b, %r14b + fldt (%rax,%r15) + fmulp %st, %st(1) + fstpt 64(%rsp) + je ..B1.22 +..B1.21: + fldcw 258(%rsp) +..B1.22: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.23: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.24: + lea _POS_OVERFLOW(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + fstp %st(0) + jp ..B1.25 + jb ..B1.164 +..B1.25: + testl %ecx, %ecx + jne ..B1.28 +..B1.26: + cmpl $536870912, 372(%rsp) + jb ..B1.149 +..B1.27: + movq $0x2000000000000000, %rax + cmpq 368(%rsp), %rax + je ..B1.149 +..B1.28: + fldt 240(%rsp) + fldz + fstpt 144(%rsp) + fldt 144(%rsp) + fld %st(0) + fstpt 128(%rsp) + fldt 128(%rsp) + testl %ebx, %ebx + fxch %st(2) + fstpt 176(%rsp) + fldt 176(%rsp) + fstpt 208(%rsp) + fldt 208(%rsp) + fxch %st(2) + fstpt 192(%rsp) + fldt 192(%rsp) + fldt 224(%rsp) + fstpt 160(%rsp) + fldt 160(%rsp) + je ..B1.32 +..B1.29: + fstp %st(1) + lea _TWO_63H(%rip), %rax + cmpl $16299, %ecx + fldl (%rax) + jle ..B1.31 +..B1.30: + fldt .L_2il0floatpacket.1(%rip) + lea _TWO_53H(%rip), %rax + fxch %st(3) + fstps 96(%rsp) + fld %st(3) + lea 96+_tgammal_S(%rip), %rdx + fadd %st(1), %st + lea 80+_tgammal_S(%rip), %rsi + fsub %st(1), %st + lea 64+_tgammal_S(%rip), %r8 + fsubr %st(4), %st + fstpt 80(%rsp) + lea 48+_tgammal_S(%rip), %r9 + andl $32767, 88(%rsp) + lea 32+_tgammal_S(%rip), %r10 + fstpt 48(%rsp) + lea 16+_tgammal_S(%rip), %r11 + fstpt (%rsp) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt 80(%rsp) + fmul %st, %st(2) + fld %st(0) + fsub %st(3), %st + fchs + fsubrp %st, %st(3) + fld %st(2) + fld %st(1) + fsub %st(4), %st + fmul %st, %st(1) + fld %st(2) + fmul %st(3), %st + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fld %st(4) + fmul %st(5), %st + fxch %st(3) + fstpt 16(%rsp) + fld %st(2) + fldl (%rax) + lea _tgammal_S(%rip), %rax + fld %st(0) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fld %st(4) + fmul %st(1), %st + fld %st(5) + fadd %st(1), %st + fsubp %st, %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + fsubrp %st, %st(5) + fxch %st(4) + fstpt 160(%rsp) + fldt (%rdx) + fmul %st(1), %st + fldt (%rsi) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r8) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r9) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r10) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%r11) + faddp %st, %st(1) + fmul %st(1), %st + fldt (%rax) + lea _tgammal_S2(%rip), %rax + faddp %st, %st(1) + fmulp %st, %st(1) + fldl (%rax) + lea 8+_tgammal_S2(%rip), %rax + fld %st(0) + fmul %st(4), %st + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + faddl (%rax) + fld %st(0) + lea 8+_tgammal_S1(%rip), %rax + fmul %st(4), %st + faddp %st, %st(3) + fmul %st(4), %st + faddp %st, %st(2) + fldl (%rax) + fld %st(0) + lea _tgammal_S1(%rip), %rax + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fldl (%rax) + fld %st(0) + lea _ones(%rip), %rax + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(5) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fld %st(1) + fmul %st(4), %st + fxch %st(4) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fld %st(2) + fldl (%rax) + fld %st(0) + fadd %st(4), %st + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fmul %st(7), %st + fmul %st, %st(6) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(5) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fmul %st, %st(4) + fldt 16(%rsp) + fld %st(0) + fmulp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fadd %st(2), %st + fsubp %st, %st(2) + fld %st(1) + fxch %st(2) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fld %st(2) + fld %st(3) + fxch %st(2) + fstpt 192(%rsp) + fldt 192(%rsp) + fldt 176(%rsp) + fmul %st, %st(4) + fxch %st(4) + fstpt 128(%rsp) + fxch %st(3) + fmulp %st, %st(2) + fldt 160(%rsp) + fmul %st, %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 144(%rsp) + fldt (%rsp) + fldt 48(%rsp) + flds 96(%rsp) + fldt 64(%rsp) + fxch %st(4) + fxch %st(2) + fxch %st(3) + fxch %st(1) + fxch %st(3) + jmp ..B1.33 +..B1.31: + fldt 208(%rsp) + fstpt 192(%rsp) + fldt 224(%rsp) + fstpt 128(%rsp) + fldt 128(%rsp) + fstpt 144(%rsp) + fldt 144(%rsp) + fxch %st(1) + jmp ..B1.33 +..B1.32: + lea _TWO_63H(%rip), %rax + fldl (%rax) +..B1.33: + fldt .L_2il0floatpacket.2(%rip) + fcomip %st(5), %st + jp ..B1.34 + jbe ..B1.95 +..B1.34: + fld %st(4) + fadd %st(1), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(1) + movl 112(%rsp), %edx + fcomi %st(4), %st + jbe ..B1.36 +..B1.35: + lea _ones(%rip), %rax + decl %edx + fsubl (%rax) +..B1.36: + cmpl $2, %edx + lea 1(%rdx), %r15d + jl ..B1.41 +..B1.37: + fstp %st(3) + testb $1, %dl + je ..B1.39 +..B1.38: + lea _ones(%rip), %rax + lea -1(%rdx), %r9d + fldl (%rax) + fsubr %st, %st(4) + fxch %st(4) + fstpt 208(%rsp) + fxch %st(3) + fsubrp %st, %st(2) + jmp ..B1.40 +..B1.39: + fstp %st(3) + movl %edx, %r9d +..B1.40: + fldt .L_2il0floatpacket.3(%rip) + addl $-2, %r9d + sarl $1, %r9d + lea _tgammal_T2(%rip), %rsi + movl %r9d, %eax + faddp %st, %st(2) + fldt 208(%rsp) + lea (,%r9,8), %r8d + shll $4, %eax + lea _tgammal_A2(%rip), %r10 + subl %r9d, %eax + lea (%r8,%r9,4), %r9d + movslq %eax, %rax + fsubp %st, %st(2) + shlq $4, %rax + movslq %r9d, %r9 + addq %rsi, %rax + lea (%r10,%r9,8), %rsi + fxch %st(2) + fxch %st(1) + fxch %st(2) + jmp ..B1.55 +..B1.41: + fstp %st(0) + fldt .L_2il0floatpacket.4(%rip) + fcomip %st(4), %st + jbe ..B1.43 +..B1.42: + movl $3, %r9d + jmp ..B1.54 +..B1.43: + fldt .L_2il0floatpacket.6(%rip) + fcomip %st(4), %st + jbe ..B1.45 +..B1.44: + xorl %r9d, %r9d + jmp ..B1.54 +..B1.45: + fldt .L_2il0floatpacket.7(%rip) + fcomip %st(4), %st + jbe ..B1.47 +..B1.46: + fldt .L_2il0floatpacket.3(%rip) + movl $1, %r9d + fsubrp %st, %st(4) + jmp ..B1.54 +..B1.47: + fldt .L_2il0floatpacket.8(%rip) + fcomip %st(4), %st + jbe ..B1.49 +..B1.48: + lea _ones(%rip), %rax + movl $2, %r9d + fldl (%rax) + fsubp %st, %st(4) + jmp ..B1.54 +..B1.49: + fldt .L_2il0floatpacket.9(%rip) + fcomip %st(4), %st + jbe ..B1.51 +..B1.50: + lea _ones(%rip), %rax + xorl %r9d, %r9d + fxch %st(3) + fsubl (%rax) + fxch %st(3) + jmp ..B1.54 +..B1.51: + fldt .L_2il0floatpacket.10(%rip) + fcomip %st(4), %st + jbe ..B1.53 +..B1.52: + fldt .L_2il0floatpacket.11(%rip) + movl $1, %r9d + fsubrp %st, %st(4) + jmp ..B1.54 +..B1.53: + fldt .L_2il0floatpacket.5(%rip) + movl $2, %r9d + fsubp %st, %st(4) +..B1.54: + movl %r9d, %eax + lea _tgammal_T1(%rip), %rsi + shll $4, %eax + lea (,%r9,8), %r8d + subl %r9d, %eax + lea (%r8,%r9,4), %r9d + lea _tgammal_A1(%rip), %r10 + shlq $4, %rax + fxch %st(2) + fstpt 208(%rsp) + addq %rsi, %rax + lea (%r10,%r9,8), %rsi +..B1.55: + cmpl $16299, %ecx + jle ..B1.61 +..B1.56: + fstp %st(1) + fldt 224(%rax) + testb $1, %dl + fmul %st(2), %st + fldt 208(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 192(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 176(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 160(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 144(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 128(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 112(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 96(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 80(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 64(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 48(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 32(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fldt 16(%rax) + faddp %st, %st(1) + fmul %st(2), %st + fld %st(2) + fldt (%rax) + faddp %st, %st(2) + fld %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(4) + fsub %st(2), %st + fldt .L_2il0floatpacket.1(%rip) + fmul %st(4), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fld %st(1) + fmul %st(3), %st + fxch %st(2) + fsubr %st, %st(4) + fmul %st(1), %st + fld %st(1) + fmul %st(5), %st + fxch %st(4) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(4) + faddp %st, %st(3) + fldl 88(%rsi) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(4) + faddp %st, %st(3) + faddp %st, %st(2) + fldl 80(%rsi) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(4), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fld %st(1) + fmul %st(4), %st + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(1) + fmul %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldl 72(%rsi) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + fldl 64(%rsi) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(4), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + fld %st(2) + fmul %st(4), %st + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(4) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(3) + fldl 56(%rsi) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + fld %st(3) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + faddp %st, %st(1) + fldl 48(%rsi) + fld %st(0) + fadd %st(4), %st + fsubr %st, %st(1) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fld %st(2) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(4), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(3) + fxch %st(1) + faddp %st, %st(3) + fld %st(1) + fmul %st(3), %st + fld %st(1) + fmul %st(5), %st + fxch %st(4) + fmul %st(5), %st + faddp %st, %st(1) + fxch %st(1) + fmul %st(2), %st + faddp %st, %st(1) + fldl 40(%rsi) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(4), %st + fsubr %st, %st(4) + fxch %st(2) + faddp %st, %st(4) + faddp %st, %st(3) + fldl 32(%rsi) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(3) + fld %st(2) + fadd %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(2), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fld %st(2) + fmul %st(2), %st + fxch %st(2) + fmul %st(5), %st + faddp %st, %st(2) + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldl 24(%rsi) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + faddp %st, %st(2) + fldl 16(%rsi) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(2), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(5), %st + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(4) + fld %st(3) + fmulp %st, %st(1) + faddp %st, %st(4) + fxch %st(2) + fmulp %st, %st(1) + faddp %st, %st(2) + fldl 8(%rsi) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(3) + fxch %st(1) + fadd %st, %st(3) + fsubrp %st, %st(2) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fldl (%rsi) + fld %st(0) + fadd %st(3), %st + fsubr %st, %st(1) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fstpt 96(%rsp) + fldt 96(%rsp) + fsubrp %st, %st(2) + faddp %st, %st(1) + fldt 16(%rsp) + je ..B1.59 +..B1.57: + cmpl $1, %edx + jle ..B1.59 +..B1.58: + fstp %st(0) + fstp %st(1) + fldt .L_2il0floatpacket.1(%rip) + fldt .L_2il0floatpacket.1(%rip) + fldt 96(%rsp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fxch %st(1) + fsub %st(3), %st + faddp %st, %st(4) + fld %st(3) + fldt 208(%rsp) + fmul %st, %st(3) + fld %st(0) + fadd %st(4), %st + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(4) + fxch %st(3) + fmul %st, %st(5) + fsubr %st, %st(3) + fxch %st(1) + fmul %st(3), %st + fxch %st(3) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fadd %st, %st(3) + fxch %st(2) + fmulp %st, %st(1) + fstpt 96(%rsp) + jmp ..B1.63 +..B1.59: + fstpt 112(%rsp) + fxch %st(1) + jmp ..B1.62 +..B1.61: + lea _ones(%rip), %rax + fldl (%rax) + fstpt 96(%rsp) +..B1.62: + testl %edx, %edx + jle ..B1.76 +..B1.63: + fstp %st(0) + testl %ebx, %ebx + jne ..B1.70 +..B1.64: + testb %bpl, %bpl + je ..B1.66 +..B1.65: + movl %r13d, %edi + fstpt (%rsp) + fstpt 64(%rsp) +..___tag_value_tgammal.37: + call fesetround@PLT +..___tag_value_tgammal.38: +..B1.206: + fldt 64(%rsp) + fldt (%rsp) +..B1.66: + fldt 96(%rsp) + testb %r14b, %r14b + faddp %st, %st(1) + fstpt 64(%rsp) + je ..B1.212 +..B1.67: + fstpt 80(%rsp) +..B1.196: + fldcw 258(%rsp) + jmp ..B1.68 +..B1.212: + fstp %st(0) +..B1.68: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.69: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.70: + fldt .L_2il0floatpacket.1(%rip) + lea _ones(%rip), %rax + fldt .L_2il0floatpacket.1(%rip) + testb %bpl, %bpl + fldt 128(%rsp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fsub %st(2), %st + fldt 144(%rsp) + faddp %st, %st(1) + fldt 96(%rsp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fld %st(2) + fmul %st(4), %st + fxch %st(1) + fsub %st(3), %st + faddp %st, %st(5) + fld %st(4) + fmul %st(2), %st + fxch %st(4) + fmulp %st, %st(5) + fxch %st(4) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + fld %st(0) + fadd %st(2), %st + fld %st(2) + fxch %st(1) + fdivrl (%rax) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(1), %st + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(6), %st + fadd %st, %st(4) + fsubrp %st, %st(4) + fxch %st(3) + fsubr %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fxch %st(2) + fmul %st(4), %st + fld %st(2) + fmul %st(4), %st + fxch %st(3) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + fldt .L_2il0floatpacket.5(%rip) + fsub %st(2), %st + fldt .L_2il0floatpacket.5(%rip) + fsub %st(1), %st + fsubp %st, %st(3) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fsubp %st, %st(1) + fstpt 272(%rsp) + fldt 272(%rsp) + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 288(%rsp) + fldt 288(%rsp) + fld %st(3) + fmul %st(2), %st + fstpt 16(%rsp) + fld %st(2) + fmul %st(1), %st + fxch %st(1) + fmulp %st, %st(4) + faddp %st, %st(3) + fmulp %st, %st(1) + faddp %st, %st(1) + je ..B1.72 +..B1.71: + movl %r13d, %edi + fstpt (%rsp) + fstpt 64(%rsp) +..___tag_value_tgammal.56: + call fesetround@PLT +..___tag_value_tgammal.57: +..B1.205: + fldt 64(%rsp) + fldt (%rsp) +..B1.72: + fldt 16(%rsp) + andl $1, %r15d + shll $15, %r15d + faddp %st, %st(1) + fstpt 64(%rsp) + xorl %r15d, 72(%rsp) + testb %r14b, %r14b + je ..B1.213 +..B1.73: + fldt 48(%rsp) + fstpt 112(%rsp) + fstpt 80(%rsp) +..B1.197: + fldcw 258(%rsp) + jmp ..B1.74 +..B1.213: + fstp %st(0) +..B1.74: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.75: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.76: + lea _ones(%rip), %rax + testl %ebx, %ebx + fldl (%rax) + fstpt (%rsp) + jne ..B1.86 +..B1.77: + fstp %st(0) + fldt 176(%rsp) + cmpl $100, %ecx + fldt 160(%rsp) + faddp %st, %st(1) + jge ..B1.79 +..B1.78: + fstp %st(1) + fldt (%rsp) + fdivp %st, %st(1) + fldt 96(%rsp) + fmulp %st, %st(1) + fstpt 96(%rsp) + jmp ..B1.80 +..B1.79: + fldt (%rsp) + fdivp %st, %st(1) + fxch %st(2) + fstpt 64(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(2), %st + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(1) + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fldt .L_2il0floatpacket.1(%rip) + fldt 176(%rsp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fsubr %st, %st(1) + fmul %st(5), %st + fld %st(5) + fldt 160(%rsp) + faddp %st, %st(3) + fmul %st(2), %st + fxch %st(2) + fmul %st(3), %st + faddp %st, %st(2) + faddp %st, %st(1) + fldt .L_2il0floatpacket.5(%rip) + fsub %st(3), %st + fldt .L_2il0floatpacket.5(%rip) + fsub %st(1), %st + fsubp %st, %st(4) + fxch %st(1) + fsubrp %st, %st(3) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(4) + faddp %st, %st(2) + fld %st(5) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(5), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fmul %st, %st(6) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(2) + fmul %st(1), %st + fld %st(2) + fmul %st(4), %st + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(1) + faddp %st, %st(5) + fxch %st(1) + fstpt 288(%rsp) + fld %st(0) + fxch %st(2) + fstpt 272(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fldt 96(%rsp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fsub %st(1), %st + faddp %st, %st(4) + fld %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fadd %st, %st(4) + fxch %st(4) + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(4) + fxch %st(3) + fmul %st, %st(4) + fsubr %st, %st(2) + fxch %st(5) + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(2) + fld %st(1) + fmulp %st, %st(5) + fxch %st(4) + fstpt 96(%rsp) + fmulp %st, %st(3) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 224(%rsp) + fldt 64(%rsp) +..B1.80: + testb %bpl, %bpl + je ..B1.82 +..B1.81: + movl %r13d, %edi + fstpt 64(%rsp) +..___tag_value_tgammal.75: + call fesetround@PLT +..___tag_value_tgammal.76: +..B1.208: + fldt 64(%rsp) +..B1.82: + fldt 224(%rsp) + testb %r14b, %r14b + fldt 96(%rsp) + faddp %st, %st(1) + fstpt 64(%rsp) + je ..B1.214 +..B1.83: + fstpt 80(%rsp) +..B1.198: + fldcw 258(%rsp) + jmp ..B1.84 +..B1.214: + fstp %st(0) +..B1.84: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.85: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.86: + cmpl $100, %ecx + jge ..B1.88 +..B1.87: + fstp %st(0) + fldt 192(%rsp) + fldt 96(%rsp) + fmulp %st, %st(1) + faddp %st, %st(1) + fldt (%rsp) + fdivp %st, %st(1) + fstpt (%rsp) + jmp ..B1.89 +..B1.88: + fldt .L_2il0floatpacket.1(%rip) + fldt .L_2il0floatpacket.1(%rip) + fldt 96(%rsp) + fmul %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsubp %st, %st(3) + fsub %st(2), %st + faddp %st, %st(4) + fldt 192(%rsp) + fmul %st, %st(1) + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(2) + fsub %st(1), %st + faddp %st, %st(3) + fld %st(3) + fmul %st(3), %st + fld %st(2) + fmul %st(2), %st + fxch %st(4) + fmulp %st, %st(3) + faddp %st, %st(2) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fldt (%rsp) + fdivp %st, %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(1), %st + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(1) + fld %st(0) + fsubrp %st, %st(2) + fld %st(1) + fld %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(5), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fsubr %st, %st(4) + fxch %st(4) + faddp %st, %st(5) + fmul %st(4), %st + fld %st(1) + fmul %st(4), %st + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + faddp %st, %st(1) + fxch %st(2) + fmul %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fldt .L_2il0floatpacket.5(%rip) + fsub %st(1), %st + fldt .L_2il0floatpacket.5(%rip) + fsub %st(1), %st + fsubp %st, %st(2) + fxch %st(2) + fsubrp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(3) + fxch %st(2) + faddp %st, %st(3) + fld %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fadd %st, %st(2) + fxch %st(2) + fstpt 112(%rsp) + fldt 112(%rsp) + fsubp %st, %st(2) + fxch %st(1) + fmul %st, %st(4) + fsubr %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmul %st(1), %st + fld %st(4) + fmul %st(3), %st + fstpt (%rsp) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt 224(%rsp) + fstpt 272(%rsp) + fstpt 288(%rsp) +..B1.89: + testb %bpl, %bpl + je ..B1.91 +..B1.90: + movl %r13d, %edi + fstpt 64(%rsp) +..___tag_value_tgammal.94: + call fesetround@PLT +..___tag_value_tgammal.95: +..B1.207: + fldt 64(%rsp) +..B1.91: + fldt 224(%rsp) + andl $1, %r15d + fldt (%rsp) + shll $15, %r15d + faddp %st, %st(1) + fstpt 64(%rsp) + xorl %r15d, 72(%rsp) + testb %r14b, %r14b + je ..B1.215 +..B1.92: + fstpt 80(%rsp) +..B1.199: + fldcw 258(%rsp) + jmp ..B1.93 +..B1.215: + fstp %st(0) +..B1.93: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.94: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.95: + fstp %st(1) + fstp %st(1) + fstp %st(1) + lea _ones(%rip), %rax + fld %st(1) + fldl (%rax) + fdiv %st, %st(1) + fld %st(1) + fmul %st(2), %st + fstpt (%rsp) + fstpl 80(%rsp) + addq $-32, %rsp + .cfi_def_cfa_offset 400 + lea 224(%rsp), %rdi + fxch %st(2) + fstpt (%rsp) + fldt 32(%rdi) + fstpt 16(%rsp) + fxch %st(1) + fstpt 48(%rsp) + fstpt 80(%rsp) +..___tag_value_tgammal.114: + call __libm_logl_k80@PLT +..___tag_value_tgammal.115: +..B1.200: + fstp %st(0) + fldt 80(%rsp) + fldt 48(%rsp) + addq $32, %rsp + .cfi_def_cfa_offset 368 +..B1.96: + fldt .L_2il0floatpacket.3(%rip) + lea 56+_tgammal_B(%rip), %rax + fxch %st(2) + fstpt 48(%rsp) + lea 48+_tgammal_B(%rip), %rdx + fldt (%rsp) + lea 40+_tgammal_B(%rip), %rcx + fldt 192(%rsp) + lea 32+_tgammal_B(%rip), %rsi + fldl (%rax) + lea 24+_tgammal_B(%rip), %r8 + fmul %st(2), %st + lea 16+_tgammal_B(%rip), %r9 + fldt .L_2il0floatpacket.1(%rip) + lea 8+_tgammal_B(%rip), %r10 + lea _tgammal_B(%rip), %r11 + lea _tgammal_B0(%rip), %rdi + lea 8+_tgammal_C(%rip), %rax + testl %ebx, %ebx + fxch %st(1) + faddl (%rdx) + lea _tgammal_C(%rip), %rdx + fmul %st(3), %st + fldt (%rdi) + fxch %st(1) + faddl (%rcx) + fmul %st(4), %st + faddl (%rsi) + fmul %st(4), %st + faddl (%r8) + fmul %st(4), %st + faddl (%r9) + fmul %st(4), %st + faddl (%r10) + fmul %st(4), %st + faddl (%r11) + fmulp %st, %st(4) + faddp %st, %st(3) + fxch %st(2) + fmulp %st, %st(3) + fld %st(0) + fldt 240(%rsp) + fsub %st, %st(5) + fxch %st(3) + fmul %st(5), %st + fld %st(5) + fadd %st(1), %st + fsubp %st, %st(1) + fsubr %st, %st(5) + fxch %st(3) + fchs + fldt 208(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(4), %st + fadd %st, %st(3) + fxch %st(3) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(3) + fxch %st(2) + fstpt 192(%rsp) + fldt 192(%rsp) + fld %st(4) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(4) + fxch %st(3) + faddp %st, %st(4) + fxch %st(3) + fmul %st, %st(4) + fld %st(6) + fmul %st(1), %st + faddp %st, %st(5) + fxch %st(2) + fmulp %st, %st(6) + fxch %st(5) + faddp %st, %st(3) + fstpt 208(%rsp) + fld %st(3) + fadd %st(2), %st + fld %st(0) + fadd %st(2), %st + fsub %st, %st(2) + fxch %st(2) + fchs + fadd %st(1), %st + fxch %st(1) + fsubrp %st, %st(5) + fxch %st(2) + faddp %st, %st(4) + fxch %st(1) + faddp %st, %st(3) + fld %st(0) + fadd %st(3), %st + fld %st(0) + fxch %st(1) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(4) + fld %st(3) + fadd %st(3), %st + fadd %st, %st(1) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fchs + fadd %st(1), %st + fxch %st(1) + fsubrp %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldl (%rax) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fldl (%rdx) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + faddp %st, %st(2) + fld %st(0) + fadd %st(3), %st + fsub %st, %st(3) + fxch %st(3) + fchs + faddp %st, %st(1) + faddp %st, %st(1) + fld %st(1) + fadd %st(1), %st + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fldt 48(%rsp) + jne ..B1.108 +..B1.97: + fxch %st(1) + fstpt 288(%rsp) + lea 160(%rsp), %rdi + fxch %st(1) + fstpt 112(%rdi) + lea 272(%rsp), %rsi + fstpt -112(%rdi) +..___tag_value_tgammal.117: + call __libm_expl_k80@PLT +..___tag_value_tgammal.118: +..B1.201: + fldt 48(%rsp) +..B1.98: + testb %bpl, %bpl + fxch %st(1) + je ..B1.101 +..B1.99: + movl %r13d, %edi + fstpt (%rsp) + fstpt 48(%rsp) +..___tag_value_tgammal.119: + call fesetround@PLT +..___tag_value_tgammal.120: +..B1.100: + fldt 48(%rsp) + fldt (%rsp) +..B1.101: + fldt 160(%rsp) + fxch %st(1) + faddp %st, %st(2) + fxch %st(1) + fstpt (%rsp) + fldt 176(%rsp) + movl (%rsp), %edx + cmpl $16383, %edx + faddp %st, %st(1) + fldl 80(%rsp) + fstpt (%rsp) + jg ..B1.103 +..B1.102: + addl $16383, %edx + movzwl 8(%rsp), %eax + andl $32767, %edx + andl $-32768, %eax + orl %edx, %eax + movw %ax, 8(%rsp) + fldt (%rsp) + fmulp %st, %st(1) + jmp ..B1.104 +..B1.103: + lea _TWO_POW_16383(%rip), %rax + andl $32767, %edx + movzwl 8(%rsp), %ecx + andl $-32768, %ecx + orl %edx, %ecx + fldt (%rax) + fmulp %st, %st(1) + movw %cx, 8(%rsp) + fldt (%rsp) + fmulp %st, %st(1) +..B1.104: + fstpt 64(%rsp) + testb %r14b, %r14b + je ..B1.106 +..B1.105: + fldt 16(%rsp) + fstpt 112(%rsp) +..B1.202: + fldcw 258(%rsp) +..B1.106: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.107: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.108: + fxch %st(2) + fchs + lea 160(%rsp), %rdi + fstpt 112(%rdi) + lea 272(%rsp), %rsi + fchs + incl %r15d + fstpt 16(%rsi) + fstpt -112(%rdi) +..___tag_value_tgammal.138: + call __libm_expl_k80@PLT +..___tag_value_tgammal.139: +..B1.203: + fldt 48(%rsp) +..B1.109: + fldt 128(%rsp) + fld %st(0) + fld %st(1) + fxch %st(4) + faddp %st, %st(3) + fxch %st(2) + fstpt (%rsp) + fldt 144(%rsp) + movl (%rsp), %eax + fadd %st, %st(2) + fxch %st(2) + fdivrl 80(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(1), %st + fld %st(0) + fadd %st(2), %st + fsubp %st, %st(1) + fsubr %st, %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fadd %st, %st(5) + fsubrp %st, %st(5) + fxch %st(2) + fsub %st(4), %st + faddp %st, %st(3) + fld %st(2) + fmul %st(1), %st + fld %st(4) + fmul %st(3), %st + fxch %st(3) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fxch %st(1) + fmul %st, %st(4) + fxch %st(4) + faddp %st, %st(1) + fldt .L_2il0floatpacket.5(%rip) + fsub %st(2), %st + fldt .L_2il0floatpacket.5(%rip) + fsub %st(1), %st + fsubp %st, %st(3) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(0) + fadd %st(2), %st + fsubr %st, %st(1) + fxch %st(2) + faddp %st, %st(1) + fld %st(1) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fadd %st, %st(1) + fsubrp %st, %st(1) + fstpt 272(%rsp) + fldt 272(%rsp) + fld %st(3) + fmul %st(1), %st + fxch %st(1) + fsubr %st, %st(3) + fxch %st(3) + faddp %st, %st(2) + fxch %st(1) + fmul %st, %st(3) + fld %st(4) + fmul %st(1), %st + faddp %st, %st(4) + fstpt 288(%rsp) + fxch %st(1) + fmulp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fldt 160(%rsp) + fld %st(0) + fldt 176(%rsp) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(3), %st + fadd %st, %st(2) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 160(%rsp) + fldt 160(%rsp) + fsubr %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fstpt 176(%rsp) + fldt 176(%rsp) + fld %st(3) + fldt .L_2il0floatpacket.1(%rip) + fmul %st(5), %st + fadd %st, %st(1) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fsubp %st, %st(1) + fld %st(0) + fmul %st(3), %st + fxch %st(1) + fsubr %st, %st(5) + fxch %st(4) + faddp %st, %st(5) + fld %st(4) + fmul %st(2), %st + fxch %st(2) + fmulp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fxch %st(1) + fmulp %st, %st(3) + faddp %st, %st(2) + fld %st(1) + fadd %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + movzwl 72(%rsp), %edx + andl $32767, %edx + lea -1(%rax,%rdx), %ecx + cmpl $32765, %ecx + lea (%rax,%rdx), %ebx + ja ..B1.115 +..B1.110: + fstp %st(1) + fstp %st(1) + fldl 80(%rsp) + lea 16382(%rax), %edx + fstpt (%rsp) + cmpl $32765, %edx + ja ..B1.112 +..B1.111: + addl $16383, %eax + movzwl 8(%rsp), %edx + andl $32767, %eax + andl $-32768, %edx + orl %eax, %edx + movw %dx, 8(%rsp) + fldt (%rsp) + fmulp %st, %st(1) + fstpt 64(%rsp) + jmp ..B1.128 +..B1.112: + cmpl $16383, %eax + jle ..B1.114 +..B1.113: + lea _TWO_POW_16383(%rip), %rdx + andl $32767, %eax + movzwl 8(%rsp), %ecx + andl $-32768, %ecx + orl %eax, %ecx + fldt (%rdx) + fmulp %st, %st(1) + movw %cx, 8(%rsp) + fldt (%rsp) + fmulp %st, %st(1) + fstpt 64(%rsp) + jmp ..B1.128 +..B1.114: + lea _TWO_POW_M16382(%rip), %rdx + addl $32765, %eax + movzwl 8(%rsp), %ecx + andl $32767, %eax + andl $-32768, %ecx + orl %eax, %ecx + fldt (%rdx) + fmulp %st, %st(1) + movw %cx, 8(%rsp) + fldt (%rsp) + fmulp %st, %st(1) + fstpt 64(%rsp) + jmp ..B1.128 +..B1.115: + fstp %st(0) + cmpl $32766, %ebx + jle ..B1.117 +..B1.116: + fstp %st(0) + fstp %st(0) + lea _TWO_POW_16383(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 64(%rsp) + jmp ..B1.128 +..B1.117: + cmpl $-65, %ebx + jg ..B1.119 +..B1.118: + fstp %st(0) + fstp %st(0) + lea _TWO_POW_M16382(%rip), %rax + fldt (%rax) + fmul %st(0), %st + fstpt 64(%rsp) + jmp ..B1.128 +..B1.119: + fldl 80(%rsp) + cmpl $-16382, %eax + fstpt (%rsp) + jl ..B1.124 +..B1.120: + addl $16383, %eax + fld %st(0) + movzwl 8(%rsp), %edx + andl $32767, %eax + andl $-32768, %edx + orl %eax, %edx + lea _TWO_53H(%rip), %rax + movw %dx, 8(%rsp) + testb %bpl, %bpl + fldt (%rsp) + fldl (%rax) + fmul %st(3), %st + fsub %st, %st(2) + fxch %st(2) + fstpt 48(%rsp) + fldt 48(%rsp) + fsubrp %st, %st(2) + fxch %st(1) + fsub %st, %st(2) + fxch %st(2) + fchs + faddp %st, %st(3) + fmul %st, %st(2) + fmulp %st, %st(1) + fstpt 16(%rsp) + je ..B1.123 +..B1.121: + movl %r13d, %edi + fstpt (%rsp) +..___tag_value_tgammal.140: + call fesetround@PLT +..___tag_value_tgammal.141: +..B1.122: + fldt (%rsp) + xorb %bpl, %bpl +..B1.123: + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 64(%rsp) + jmp ..B1.128 +..B1.124: + lea _TWO_POW_M16000(%rip), %rcx + negl %eax + addl $-15999, %eax + lea _TWO_32H(%rip), %rsi + movzwl 8(%rsp), %edx + andl $32767, %eax + andl $-32768, %edx + lea _small_value_80(%rip), %rbx + fldt (%rcx) + orl %eax, %edx + fmul %st, %st(1) + lea _TWO_32HP(%rip), %rax + fld %st(1) + testb %bpl, %bpl + fxch %st(1) + fmulp %st, %st(3) + movw %dx, 8(%rsp) + fadd %st(2), %st + fldl (%rax) + fldt (%rbx) + fmul %st(0), %st + fstpt 32(%rsp) + fldt (%rsp) + fadd %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fxch %st(2) + fmull (%rsi) + fsubrp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fsubp %st, %st(1) + fsubrp %st, %st(1) + faddp %st, %st(1) + je ..B1.127 +..B1.125: + movl %r13d, %edi + fstpt (%rsp) +..___tag_value_tgammal.142: + call fesetround@PLT +..___tag_value_tgammal.143: +..B1.126: + fldt (%rsp) + xorb %bpl, %bpl +..B1.127: + fldt 16(%rsp) + faddp %st, %st(1) + fstpt 64(%rsp) + movzwl 72(%rsp), %eax + andl $-32768, %eax + andl $2147483647, 68(%rsp) + movw %ax, 72(%rsp) +..B1.128: + andl $1, %r15d + shll $15, %r15d + xorl %r15d, 72(%rsp) + testb %bpl, %bpl + je ..B1.130 +..B1.129: + movl %r13d, %edi +..___tag_value_tgammal.144: + call fesetround@PLT +..___tag_value_tgammal.145: +..B1.130: + testb %r14b, %r14b + je ..B1.132 +..B1.131: + fldt 48(%rsp) + fstpt 112(%rsp) +..B1.204: + fldcw 258(%rsp) +..B1.132: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.133: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.134: + fstp %st(0) + call __stack_chk_fail@PLT +..B1.135: + fstp %st(0) + testb %bpl, %bpl + je ..B1.137 +..B1.136: + movl %r13d, %edi + movsd %xmm0, (%rsp) +..___tag_value_tgammal.163: + call fesetround@PLT +..___tag_value_tgammal.164: +..B1.211: + movsd (%rsp), %xmm0 +..B1.137: + divsd %xmm0, %xmm0 + movsd %xmm0, (%rsp) + testb %r14b, %r14b + fldl (%rsp) + fstpt 64(%rsp) + je ..B1.139 +..B1.138: + fldcw 258(%rsp) +..B1.139: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 + jmp ..B1.23 +..B1.142: + fstp %st(0) + testb %bpl, %bpl + je ..B1.144 +..B1.143: + movl %r13d, %edi + movsd %xmm0, (%rsp) +..___tag_value_tgammal.165: + call fesetround@PLT +..___tag_value_tgammal.166: +..B1.210: + movsd (%rsp), %xmm0 +..B1.144: + divsd %xmm0, %xmm0 + movsd %xmm0, (%rsp) + testb %r14b, %r14b + fldl (%rsp) + fstpt 64(%rsp) + je ..B1.146 +..B1.145: + fldcw 258(%rsp) +..B1.146: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 + jmp ..B1.23 +..B1.149: + testb %bpl, %bpl + je ..B1.151 +..B1.150: + movl %r13d, %edi +..___tag_value_tgammal.167: + call fesetround@PLT +..___tag_value_tgammal.168: +..B1.151: + movl %ebx, %eax + lea _large_value_80(%rip), %rdx + shlq $4, %rax + testl %ebx, %ebx + fldt (%rdx) + fldt (%rdx,%rax) + fmulp %st, %st(1) + fstpt 64(%rsp) + je ..B1.153 +..B1.152: + shll $15, %ebx + orl %ebx, 72(%rsp) +..B1.153: + testb %r14b, %r14b + je ..B1.155 +..B1.154: + fldcw 258(%rsp) +..B1.155: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 + jmp ..B1.23 +..B1.164: + testb %bpl, %bpl + je ..B1.166 +..B1.165: + movl %r13d, %edi +..___tag_value_tgammal.169: + call fesetround@PLT +..___tag_value_tgammal.170: +..B1.166: + lea _large_value_80(%rip), %rax + testb %r14b, %r14b + fldt (%rax) + fmul %st(0), %st + fstpt 64(%rsp) + je ..B1.168 +..B1.167: + fldcw 258(%rsp) +..B1.168: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 + jmp ..B1.23 +..B1.171: + fstp %st(0) + testb %bpl, %bpl + je ..B1.173 +..B1.172: + movl %r13d, %edi + movsd %xmm0, (%rsp) +..___tag_value_tgammal.171: + call fesetround@PLT +..___tag_value_tgammal.172: +..B1.209: + movsd (%rsp), %xmm0 +..B1.173: + lea _ones(%rip), %rax + testb %r14b, %r14b + movsd (%rax,%rbx,8), %xmm1 + divsd %xmm0, %xmm1 + movsd %xmm1, (%rsp) + fldl (%rsp) + fstpt 64(%rsp) + je ..B1.175 +..B1.174: + fldcw 258(%rsp) +..B1.175: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 + jmp ..B1.23 +..B1.178: + testl %ebx, %ebx + je ..B1.181 +..B1.179: + cmpl $-2147483648, 372(%rsp) + jne ..B1.181 +..B1.180: + cmpl $0, 368(%rsp) + je ..B1.187 +..B1.181: + fldt 368(%rsp) + lea _ones(%rip), %rax + testb %r14b, %r14b + fmull (%rax) + fstpt 64(%rsp) + je ..B1.183 +..B1.182: + fldcw 258(%rsp) +..B1.183: + testb %bpl, %bpl + je ..B1.185 +..B1.184: + movl %r13d, %edi +..___tag_value_tgammal.173: + call fesetround@PLT +..___tag_value_tgammal.174: +..B1.185: + fldt 64(%rsp) + movq 304(%rsp), %rax + xorq %rsp, %rax + cmpq %fs:40, %rax + jne ..B1.134 +..B1.186: + addq $320, %rsp + .cfi_def_cfa_offset 48 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 40 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 368 + .cfi_offset 3, -40 + .cfi_offset 6, -48 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.187: + testb %bpl, %bpl + je ..B1.189 +..B1.188: + movl %r13d, %edi +..___tag_value_tgammal.192: + call fesetround@PLT +..___tag_value_tgammal.193: +..B1.189: + lea 8+_zeros(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + divsd (%rdx), %xmm0 + movsd %xmm0, (%rsp) + fldl (%rsp) + fstpt 64(%rsp) + fldt 64(%rsp) + movq 304(%rsp), %rcx + xorq %rsp, %rcx + cmpq %fs:40, %rcx + jne ..B1.134 + jmp ..B1.23 + .align 16,0x90 + .cfi_endproc + .type tgammal,@function + .size tgammal,.-tgammal + .data +# -- End tgammal + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.0: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xdc,0x09,0xc0,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,16 + .align 16 +.L_2il0floatpacket.1: + .byte 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 16 +.L_2il0floatpacket.2: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfc,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 16 +.L_2il0floatpacket.5: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.5,@object + .size .L_2il0floatpacket.5,16 + .align 16 +.L_2il0floatpacket.6: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xfd,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.6,@object + .size .L_2il0floatpacket.6,16 + .align 16 +.L_2il0floatpacket.7: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.7,@object + .size .L_2il0floatpacket.7,16 + .align 16 +.L_2il0floatpacket.8: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.8,@object + .size .L_2il0floatpacket.8,16 + .align 16 +.L_2il0floatpacket.9: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.9,@object + .size .L_2il0floatpacket.9,16 + .align 16 +.L_2il0floatpacket.10: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.10,@object + .size .L_2il0floatpacket.10,16 + .align 16 +.L_2il0floatpacket.11: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 + .type .L_2il0floatpacket.11,@object + .size .L_2il0floatpacket.11,16 + .align 16 +_TWO_53H: + .long 0 + .long 1128792064 + .type _TWO_53H,@object + .size _TWO_53H,8 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_TWO_63H: + .long 0 + .long 1139277824 + .type _TWO_63H,@object + .size _TWO_63H,8 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_tgammal_S2: + .long 1076610156 + .long 1072298443 + .long 2174450924 + .long 1012377779 + .type _tgammal_S2,@object + .size _tgammal_S2,16 + .align 4 +_tgammal_S1: + .long 1649608659 + .long 3220853158 + .long 544854255 + .long 3162597952 + .type _tgammal_S1,@object + .size _tgammal_S1,16 + .align 4 +_tgammal_A2: + .long 1833415567 + .long 1073038586 + .long 2552883231 + .long 1018148522 + .long 1595568275 + .long 1072556376 + .long 458238143 + .long 1015211580 + .long 3568820252 + .long 1071968804 + .long 1244365593 + .long 1010337025 + .long 799339768 + .long 1070612333 + .long 3666663601 + .long 1014637144 + .long 2303274075 + .long 1069290379 + .long 1349342802 + .long 1013375288 + .long 3297989586 + .long 1067256475 + .long 254004781 + .long 1007721194 + .long 3884346469 + .long 1076314993 + .long 442477728 + .long 1020223370 + .long 318512670 + .long 1076897708 + .long 471158811 + .long 1020359281 + .long 2510778168 + .long 1076450444 + .long 1901825555 + .long 1020381374 + .long 1635478559 + .long 1075598710 + .long 824259222 + .long 1018719588 + .long 1081324001 + .long 1074338163 + .long 3447625061 + .long 1017363587 + .long 3947156014 + .long 1072861090 + .long 1379190805 + .long 1015115048 + .long 420607958 + .long 1081212458 + .long 3477976495 + .long 1025491940 + .long 3806068795 + .long 1082138936 + .long 4217379562 + .long 1025598832 + .long 3604563515 + .long 1082026571 + .long 2373575058 + .long 1026208390 + .long 2007420787 + .long 1081336307 + .long 1677630540 + .long 1025930127 + .long 1505609351 + .long 1080304853 + .long 3680187356 + .long 1024342399 + .long 1798798240 + .long 1079036631 + .long 724429118 + .long 1022004699 + .long 573661072 + .long 1087072564 + .long 1175535566 + .long 1031320119 + .long 3742832273 + .long 1088193077 + .long 2163102943 + .long 1030481607 + .long 1347160184 + .long 1088323961 + .long 872134502 + .long 1032553403 + .long 3527047012 + .long 1087786342 + .long 974187100 + .long 1028831099 + .long 1718309677 + .long 1086914107 + .long 744179587 + .long 1031128181 + .long 2775103229 + .long 1085724862 + .long 1153587355 + .long 1029745229 + .long 1670522313 + .long 1093749470 + .long 3603089619 + .long 1038783597 + .long 2795800948 + .long 1094969738 + .long 1113103030 + .long 1039749901 + .long 3483985892 + .long 1095195750 + .long 707212107 + .long 1037942235 + .long 3634938287 + .long 1094882573 + .long 3822913920 + .long 1039689416 + .long 1233016495 + .long 1094091821 + .long 3838048750 + .long 1037461559 + .long 817468048 + .long 1093018536 + .long 360059332 + .long 1037856380 + .long 3404619429 + .long 1101025312 + .long 2324006265 + .long 1046266629 + .long 1757595371 + .long 1102333247 + .long 3317464771 + .long 1041601336 + .long 2951620935 + .long 1102677785 + .long 2114793479 + .long 1046829217 + .long 1356962213 + .long 1102426961 + .long 3236647680 + .long 1046257529 + .long 378361594 + .long 1101790815 + .long 2326245451 + .long 1045004339 + .long 704627613 + .long 1100821691 + .long 771850637 + .long 1043974839 + .type _tgammal_A2,@object + .size _tgammal_A2,576 + .align 4 +_tgammal_A1: + .long 4294967295 + .long 1072693247 + .long 4294254158 + .long 1017118719 + .long 4235179544 + .long 3219290252 + .long 1647137719 + .long 3164508998 + .long 3258652024 + .long 1072670296 + .long 2787078119 + .long 1015928435 + .long 2402437986 + .long 3219982865 + .long 3119239167 + .long 3164440263 + .long 89167536 + .long 1072654929 + .long 3734368228 + .long 1015667286 + .long 3963139337 + .long 3220139136 + .long 2050876349 + .long 3162686202 + .long 2444554090 + .long 1072454648 + .long 2100370444 + .long 1016394631 + .long 2397397425 + .long 1067486888 + .long 3603318790 + .long 1011860326 + .long 3126988118 + .long 1071287373 + .long 3410508918 + .long 1015153675 + .long 480439205 + .long 3216734124 + .long 3426889025 + .long 3160197739 + .long 927904425 + .long 1069712317 + .long 1130465219 + .long 1014845612 + .long 4266680347 + .long 3216234636 + .long 1626218864 + .long 3161277677 + .long 0 + .long 1072693248 + .long 1528870101 + .long 964807786 + .long 119575502 + .long 3218804454 + .long 1881625935 + .long 3159804816 + .long 2341912255 + .long 1071274903 + .long 3500227044 + .long 1010193322 + .long 2554745004 + .long 3216302649 + .long 3304224511 + .long 3156439793 + .long 2968672914 + .long 1068696059 + .long 4206584367 + .long 1012030447 + .long 1090398824 + .long 1060208439 + .long 842313838 + .long 1004803849 + .long 4294967295 + .long 1072693247 + .long 4294967295 + .long 1017118719 + .long 4235179544 + .long 3219290252 + .long 4177388891 + .long 3164508998 + .long 3258652024 + .long 1072670296 + .long 1161858311 + .long 1015929131 + .long 2402437986 + .long 3219982865 + .long 3056812941 + .long 3164521903 + .long 89167541 + .long 1072654929 + .long 2427235615 + .long 1014999039 + .long 3963139706 + .long 3220139136 + .long 3024603167 + .long 3163626566 + .type _tgammal_A1,@object + .size _tgammal_A1,384 + .align 4 +_tgammal_B: + .long 381774871 + .long 3211182444 + .long 436314138 + .long 1061814688 + .long 327235604 + .long 3208872248 + .long 723058467 + .long 1061917982 + .long 3650698365 + .long 3210701488 + .long 440509466 + .long 1064976804 + .long 3406779288 + .long 3214819974 + .long 941491840 + .long 1070005910 + .type _tgammal_B,@object + .size _tgammal_B,64 + .align 4 +_tgammal_C: + .long 3362045620 + .long 1072523249 + .long 4064281872 + .long 1016386130 + .type _tgammal_C,@object + .size _tgammal_C,16 + .align 4 +_TWO_32H: + .long 0 + .long 1106771968 + .type _TWO_32H,@object + .size _TWO_32H,8 + .align 4 +_TWO_32HP: + .long 1048576 + .long 1106771968 + .type _TWO_32HP,@object + .size _TWO_32HP,8 + .align 2 +_small_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 6383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 39151 + .word 0 + .word 0 + .word 0 + .type _small_value_80,@object + .size _small_value_80,32 + .align 2 +_POS_OVERFLOW: + .word 11809 + .word 27445 + .word 35846 + .word 56177 + .word 16393 + .word 0 + .word 0 + .word 0 + .type _POS_OVERFLOW,@object + .size _POS_OVERFLOW,16 + .align 2 +_tgammal_S: + .word 24210 + .word 1753 + .word 29241 + .word 50004 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 51350 + .word 39166 + .word 743 + .word 54836 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 3640 + .word 30975 + .word 46417 + .word 39360 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 53672 + .word 10841 + .word 35989 + .word 39843 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 36569 + .word 52859 + .word 829 + .word 59922 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 48029 + .word 59092 + .word 17416 + .word 34773 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 51219 + .word 52454 + .word 61951 + .word 62382 + .word 49123 + .word 0 + .word 0 + .word 0 + .type _tgammal_S,@object + .size _tgammal_S,112 + .align 2 +_tgammal_T2: + .word 46722 + .word 54455 + .word 58933 + .word 43588 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 11656 + .word 9670 + .word 26887 + .word 53935 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 37336 + .word 10857 + .word 59094 + .word 50631 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 42778 + .word 63737 + .word 45056 + .word 33859 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 26755 + .word 45167 + .word 18275 + .word 32926 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 44721 + .word 19678 + .word 48085 + .word 54982 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 51053 + .word 39319 + .word 36729 + .word 62310 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 45874 + .word 5043 + .word 3955 + .word 43983 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 10698 + .word 13153 + .word 62730 + .word 37178 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 47802 + .word 34638 + .word 48577 + .word 58524 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 5552 + .word 49084 + .word 18209 + .word 47263 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 27946 + .word 40146 + .word 45659 + .word 36839 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 43027 + .word 63179 + .word 35272 + .word 58163 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 51497 + .word 52569 + .word 40730 + .word 59709 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 50075 + .word 12939 + .word 25687 + .word 50566 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 50229 + .word 1163 + .word 49491 + .word 48597 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 65107 + .word 33673 + .word 57229 + .word 54934 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 40234 + .word 4993 + .word 58268 + .word 55864 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 37170 + .word 65173 + .word 7022 + .word 51747 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 26509 + .word 26471 + .word 6311 + .word 44116 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 19430 + .word 24800 + .word 9769 + .word 34884 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 11267 + .word 5159 + .word 36913 + .word 51530 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 64725 + .word 57237 + .word 10436 + .word 35732 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 9979 + .word 17874 + .word 14609 + .word 46771 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 48661 + .word 14142 + .word 37902 + .word 57970 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 44331 + .word 229 + .word 33140 + .word 34177 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 18505 + .word 49699 + .word 39129 + .word 38384 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 55009 + .word 45387 + .word 16863 + .word 41316 + .word 16352 + .word 0 + .word 0 + .word 0 + .word 32472 + .word 62749 + .word 3488 + .word 43302 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 38507 + .word 49300 + .word 64329 + .word 42149 + .word 16346 + .word 0 + .word 0 + .word 0 + .word 54685 + .word 59022 + .word 19355 + .word 48977 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 11322 + .word 9818 + .word 14110 + .word 61121 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 35672 + .word 18289 + .word 56841 + .word 34043 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 40623 + .word 27826 + .word 27872 + .word 34330 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 23588 + .word 8736 + .word 44949 + .word 63368 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 65458 + .word 32180 + .word 45318 + .word 53999 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 7083 + .word 36157 + .word 35044 + .word 42795 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 41937 + .word 53706 + .word 63704 + .word 63466 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 56782 + .word 14002 + .word 58756 + .word 44258 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 50000 + .word 929 + .word 21531 + .word 58307 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 29164 + .word 41738 + .word 63210 + .word 36416 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 22318 + .word 7527 + .word 19550 + .word 43267 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 36459 + .word 32677 + .word 20918 + .word 49089 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 54142 + .word 37469 + .word 39035 + .word 54353 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 43987 + .word 37066 + .word 46591 + .word 55009 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 23593 + .word 355 + .word 54000 + .word 36277 + .word 16394 + .word 0 + .word 0 + .word 0 + .word 38981 + .word 26613 + .word 65277 + .word 49004 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 37709 + .word 48898 + .word 35761 + .word 58794 + .word 16390 + .word 0 + .word 0 + .word 0 + .word 20062 + .word 54760 + .word 43546 + .word 63578 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 4376 + .word 65424 + .word 42405 + .word 62684 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 53174 + .word 32360 + .word 45557 + .word 56872 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 50961 + .word 21643 + .word 2055 + .word 47845 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 44504 + .word 53228 + .word 208 + .word 37559 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 22458 + .word 24129 + .word 6745 + .word 55322 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 45571 + .word 12909 + .word 9586 + .word 38400 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 63967 + .word 2945 + .word 37284 + .word 50443 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 40100 + .word 52281 + .word 37909 + .word 62907 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 14124 + .word 37910 + .word 18802 + .word 37402 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 28370 + .word 35717 + .word 42940 + .word 43396 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 57898 + .word 23307 + .word 6391 + .word 45620 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 46932 + .word 12112 + .word 28768 + .word 37645 + .word 16401 + .word 0 + .word 0 + .word 0 + .word 4289 + .word 37433 + .word 59606 + .word 54245 + .word 16399 + .word 0 + .word 0 + .word 0 + .word 64482 + .word 38480 + .word 36982 + .word 34595 + .word 16398 + .word 0 + .word 0 + .word 0 + .word 60245 + .word 51970 + .word 24673 + .word 39653 + .word 16396 + .word 0 + .word 0 + .word 0 + .word 5116 + .word 50868 + .word 49618 + .word 41328 + .word 16394 + .word 0 + .word 0 + .word 0 + .word 41766 + .word 46400 + .word 3930 + .word 39543 + .word 16392 + .word 0 + .word 0 + .word 0 + .word 10780 + .word 29057 + .word 64174 + .word 35004 + .word 16390 + .word 0 + .word 0 + .word 0 + .word 53671 + .word 48824 + .word 23962 + .word 57716 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 53678 + .word 31584 + .word 52783 + .word 44557 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 6190 + .word 44351 + .word 42084 + .word 64733 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 38744 + .word 53501 + .word 23462 + .word 44426 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 5624 + .word 56691 + .word 10270 + .word 57805 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 37833 + .word 48670 + .word 48257 + .word 35818 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 2793 + .word 44149 + .word 23652 + .word 43316 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 36532 + .word 60099 + .word 3358 + .word 47101 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 26210 + .word 6795 + .word 18267 + .word 52540 + .word 16408 + .word 0 + .word 0 + .word 0 + .word 4852 + .word 29729 + .word 14912 + .word 39944 + .word 16407 + .word 0 + .word 0 + .word 0 + .word 5407 + .word 41984 + .word 60375 + .word 53635 + .word 16405 + .word 0 + .word 0 + .word 0 + .word 50093 + .word 12566 + .word 13387 + .word 64582 + .word 16403 + .word 0 + .word 0 + .word 0 + .word 49147 + .word 13632 + .word 405 + .word 35287 + .word 16402 + .word 0 + .word 0 + .word 0 + .word 19308 + .word 51191 + .word 49444 + .word 35336 + .word 16400 + .word 0 + .word 0 + .word 0 + .word 42358 + .word 64331 + .word 14656 + .word 65374 + .word 16397 + .word 0 + .word 0 + .word 0 + .word 20975 + .word 39047 + .word 28983 + .word 56232 + .word 16395 + .word 0 + .word 0 + .word 0 + .word 29936 + .word 14466 + .word 41903 + .word 45232 + .word 16393 + .word 0 + .word 0 + .word 0 + .word 29960 + .word 52783 + .word 56228 + .word 34190 + .word 16391 + .word 0 + .word 0 + .word 0 + .word 35121 + .word 10599 + .word 28021 + .word 48776 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 24922 + .word 26565 + .word 63850 + .word 32942 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 35914 + .word 31178 + .word 25984 + .word 42348 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 32787 + .word 34531 + .word 38943 + .word 53136 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 12957 + .word 55078 + .word 57592 + .word 59546 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _tgammal_T2,@object + .size _tgammal_T2,1440 + .align 2 +_tgammal_T1: + .word 33333 + .word 22332 + .word 1335 + .word 65087 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 47908 + .word 35098 + .word 63659 + .word 65273 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 46380 + .word 12569 + .word 56008 + .word 65411 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 48850 + .word 62280 + .word 7688 + .word 65472 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 39250 + .word 51171 + .word 14264 + .word 65504 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 1152 + .word 29364 + .word 36762 + .word 65519 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 3017 + .word 25231 + .word 24799 + .word 65523 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 25322 + .word 65334 + .word 59366 + .word 65496 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 56776 + .word 58800 + .word 13007 + .word 65323 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 19307 + .word 43631 + .word 60167 + .word 64530 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 36275 + .word 49480 + .word 28369 + .word 61762 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 21913 + .word 46254 + .word 26555 + .word 54444 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 35908 + .word 6208 + .word 45367 + .word 40294 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 27036 + .word 5944 + .word 26542 + .word 42848 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 29582 + .word 26316 + .word 64938 + .word 47331 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 2023 + .word 42870 + .word 23457 + .word 61457 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 65015 + .word 19522 + .word 60134 + .word 39847 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 37347 + .word 35810 + .word 25431 + .word 54185 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 59586 + .word 38885 + .word 5307 + .word 36118 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 55581 + .word 26604 + .word 61099 + .word 48328 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 26530 + .word 8530 + .word 11497 + .word 64510 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 5884 + .word 49309 + .word 23213 + .word 43047 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 39008 + .word 7698 + .word 42498 + .word 57424 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 52706 + .word 42552 + .word 1743 + .word 38295 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 36375 + .word 51085 + .word 41378 + .word 51088 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 45665 + .word 51480 + .word 46902 + .word 34067 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 45474 + .word 25613 + .word 9050 + .word 44941 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 10137 + .word 18971 + .word 38654 + .word 59779 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 53562 + .word 56969 + .word 3619 + .word 46768 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 12931 + .word 40754 + .word 53864 + .word 63282 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 16582 + .word 62753 + .word 30052 + .word 46783 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 41763 + .word 18743 + .word 29826 + .word 47859 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 61445 + .word 12179 + .word 9444 + .word 35298 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 19195 + .word 47291 + .word 36415 + .word 61711 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 13845 + .word 40089 + .word 27018 + .word 32909 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 12017 + .word 58217 + .word 13416 + .word 64677 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 35895 + .word 43222 + .word 31657 + .word 65323 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 20613 + .word 26232 + .word 50069 + .word 65270 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 35252 + .word 65344 + .word 3340 + .word 65456 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 10600 + .word 13283 + .word 40541 + .word 64928 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 11880 + .word 32674 + .word 50280 + .word 34435 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 63446 + .word 286 + .word 54268 + .word 48349 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 8548 + .word 23982 + .word 1825 + .word 63713 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 34666 + .word 29375 + .word 64038 + .word 41244 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 59811 + .word 4152 + .word 44775 + .word 65267 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 18717 + .word 22920 + .word 1335 + .word 65087 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 45811 + .word 56269 + .word 63659 + .word 65273 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 65298 + .word 48931 + .word 56016 + .word 65411 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 32491 + .word 12018 + .word 7860 + .word 65472 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 14368 + .word 44485 + .word 16906 + .word 65504 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 41970 + .word 59715 + .word 3074 + .word 65520 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 4801 + .word 21592 + .word 65211 + .word 65527 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 62592 + .word 41973 + .word 39337 + .word 65531 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 13381 + .word 40677 + .word 15011 + .word 65529 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 46580 + .word 36519 + .word 54875 + .word 65490 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 37477 + .word 29387 + .word 41414 + .word 65216 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 16797 + .word 56146 + .word 15453 + .word 63766 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 40859 + .word 15091 + .word 60713 + .word 58161 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 1004 + .word 12255 + .word 49061 + .word 43226 + .word 49150 + .word 0 + .word 0 + .word 0 + .word 52096 + .word 41479 + .word 59455 + .word 37399 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _tgammal_T1,@object + .size _tgammal_T1,960 + .align 2 +_tgammal_B0: + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16379 + .word 0 + .word 0 + .word 0 + .type _tgammal_B0,@object + .size _tgammal_B0,16 + .align 2 +_TWO_POW_16383: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 32766 + .word 0 + .word 0 + .word 0 + .type _TWO_POW_16383,@object + .size _TWO_POW_16383,16 + .align 2 +_TWO_POW_M16382: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 1 + .word 0 + .word 0 + .word 0 + .type _TWO_POW_M16382,@object + .size _TWO_POW_M16382,16 + .align 2 +_TWO_POW_M16000: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 383 + .word 0 + .word 0 + .word 0 + .type _TWO_POW_M16000,@object + .size _TWO_POW_M16000,16 + .align 2 +_large_value_80: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 26383 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 59151 + .word 0 + .word 0 + .word 0 + .type _large_value_80,@object + .size _large_value_80,32 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/trig_pi_bits.S b/external/sgx_libm/intel64/trig_pi_bits.S new file mode 100644 index 0000000000..2977f39ed4 --- /dev/null +++ b/external/sgx_libm/intel64/trig_pi_bits.S @@ -0,0 +1,310 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "trig_pi_bits.c" + .section .rodata, "a" + .align 8 + .align 8 + .globl __four_over_pi +__four_over_pi: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0xdb939105,0x0028be60 + .long 0xf47d4d37,0x4a7f09d5 + .long 0x664f10e4,0x7036d8a5 + .long 0xeaf7aef1,0x107f9458 + .long 0x8e909374,0x586dc91b + .long 0xba827464,0xb801924b + .long 0xc72c4a69,0x873f877a + .long 0x7d4baed1,0xcfba208d + .long 0x09ad17df,0x213a671c + .long 0x8e60d4ce,0x904e6475 + .long 0xe2ef7e4a,0x7d272117 + .long 0xfff78166,0x0ec7fe25 + .long 0x62d6829b,0x03fbcbc4 + .long 0xb3c9f2c2,0x47db4d9f + .long 0xd9a797fa,0x6dd3d18f + .long 0xb1faf97c,0x8b5d49ee + .long 0x7de294a4,0x5ecf41ce + .long 0xec47e357,0xba9afed7 + .long 0x11bf1eda,0x421580cc + .long 0x0826bd0d,0xeafc33ef + .long 0x5857b986,0x876a78e4 + .long 0x57c5281a,0xc2196661 + .long 0x20135cc9,0x10237ff6 + .long 0x55b29cea,0xcc418185 + .long 0xf0231ad1,0x3258389e + .long 0xf3773a02,0xf10670d9 + .long 0x1da2e587,0x4aa0d671 + .long 0x3455c641,0x29b76bd1 + .long 0xc14fdf8c,0x4fa97fc1 + .long 0x93e60c9f,0xfa0cb0b7 + .long 0xbbdac797,0x6ef0cf49 + .long 0xcd72bc9f,0xbe27ce87 + .long 0x641f1f09,0xc761fc48 + .long 0x5dcb4c10,0x1abe9bb5 + .long 0x2d674670,0xcec57185 + .long 0x534b1740,0xf0b12b50 + .long 0x8b5c78e6,0x03119f61 + .long 0x8cdf34ad,0xb1a6c018 + .long 0x554dfd8f,0x25e9ed35 + .long 0xff1d934a,0xb5c60428 + .long 0xdc3e1f18,0xa7592af5 + .long 0xc545d592,0xd5ec1eb9 + .long 0xce2129f2,0x7036758e + .long 0xb588d516,0xc8c91de2 + .long 0xc2bc77f3,0xae47c006 + .long 0xda879998,0x867fcc67 + .long 0xeb361fdf,0x55e651fe + .long 0x7a0c982f,0xadd948a2 + .long 0xc24d9b35,0xf9b3713b + .long 0x85b78ed6,0x0fd775f7 + .long 0x08b4ba21,0x24a6f78a + .long 0x8cb2b185,0x8a135638 + .long 0x78143005,0xb8c232df + .long 0xf8060d04,0xe9c77cd6 + .long 0xc05220d6,0xcb9884a0 + .long 0x2b7cba47,0xe3bd5fec + .long 0xd9c43637,0x90d29234 + .long 0xb3985aa9,0x6a9097eb + .long 0x74fca981,0x0a02ad26 + .long 0xf0a8e20f,0x9fddd720 + .long 0x96a32bef,0x185e1ce2 + .long 0x8b72effd,0x75dbd8e9 + .long 0xf0499172,0x3be06359 + .long 0xb4aa0a23,0x954db672 + .long 0x44850981,0x58709df2 + .long 0x16711131,0x26d184b1 + .long 0x7cc5c02b,0x72246c93 + .long 0x4a44357f,0x50f53952 + .long 0x2507bbb3,0x7f2f8033 + .long 0xe03c7b30,0x9c3d4f84 + .long 0x31e50164,0xf9ecca3e + .long 0xc24bbcd1,0xcf9c706c + .long 0x1ec82ae7,0x42e704a2 + .long 0x91cbcc9e,0xed4bb0a4 + .long 0x29dc87f9,0xdb554324 + .long 0x52859e78,0xdae5b2cc + .long 0xfd25e53a,0x9e506277 + .long 0xcc665afb,0x2139b8a5 + .long 0xc3bf6eed,0x620d97d7 + .long 0x19d09c9c,0x26921b29 + .long 0x0567c279,0x4c97636e + .long 0x4e5d3dc7,0x6f094c63 + .long 0x035a0212,0x014c0043 + .long 0x2a91c0b9,0xd63b8b24 + .long 0x699f7ddc,0xdd0935af + .long 0xa7e9a523,0x921bbbc5 + .long 0x54f47c82,0xbda46d14 + .long 0x1f92fd5a,0xb3cce608 + .long 0xb740d750,0x18ec97cf + .long 0x54957019,0x1fe2614a + .long 0x4c920c9d,0x0dc4361b + .long 0x539b9511,0x5316f51c + .long 0x7d4ab559,0x704242da + .long 0xd4011776,0x852741c9 + .long 0xba85fe61,0xceed315d + .long 0x89c74a5a,0xdf5ad26e + .long 0x95052b5a,0x65ab3331 + .long 0x62141c8b,0xb8a42276 + .long 0x01dddc0c,0x2fa90125 + .long 0x2a1c7a92,0x3cc9ff00 + .long 0x1920f765,0x70998f78 + .long 0x6510e321,0xe5cfe8ff + .long 0x674e64a3,0x8377904c + .long 0xc5cef7c2,0x1c3779ed + .long 0x201724e0,0x0acdc568 + .long 0x363a03eb,0x16a48444 + .long 0xf6c3e40e,0xe01b12ff + .long 0x6958aef2,0x1d861645 + .long 0xef500401,0xd86e6271 + .long 0x527dadba,0x3cb489dd + .long 0x85028bc9,0xeec8b6ea + .long 0x0ccec246,0xa25da0d9 + .long 0x9470a8c7,0xa503aa8e + .long 0x89971370,0x6bbb6bc4 + .long 0x65d5b020,0x9b671e8b + .long 0x0263100a,0xcfc0fdbc + .long 0xed0e4548,0xe64c5b41 + .long 0x3124bd52,0x0316f0f6 + .long 0x93b34de9,0xeb71a972 + .long 0x24aada10,0xcdaa79a5 + .long 0x7be31d94,0xb77798c6 + .long 0xff2ae86b,0xa2da0df6 + .long 0x6b8036be,0x8c4577e8 + .long 0x2dc17b4c,0xc3199359 + .long 0x95cebfd1,0x194a6fd5 + .long 0xef9d77e4,0xee7e5abc + .long 0xfda31985,0xca0c202a + .long 0xbe877936,0x72c10188 + .long 0xc6d5c273,0x692ccf63 + .long 0xa92f84ed,0x4dba5093 + .long 0xbc2a1953,0x48ccc6aa + .long 0xcfc2f35e,0xe9707483 + .long 0xc122dedc,0x16ddbe48 + .long 0xb1b89b9b,0x85e254e9 + .long 0x12a6edf6,0xc03afbd6 + .long 0xb3f3dd87,0xb12e99aa + .long 0x6c706663,0x40b44b7c + .long 0x9221a817,0x1deb70f6 + .long 0x8bfc2b26,0x7dfd2031 + .long 0x0fdb77b4,0xbb376f17 + .long 0xb6ca8e89,0x07f1e42d + .long 0x24d4eb41,0x68e6abc0 + .long 0x4a5fa012,0x15edad0b + .long 0xaa9da856,0xe9c1f683 + .long 0x8b6df73f,0x5eca8485 + .long 0xe27f6fa2,0x797ebfb6 + .long 0x2a419c20,0x5b1db93f + .long 0x7fe1ff41,0x0f855ba1 + .long 0xd861860a,0xcf8a0cd9 + .long 0xf9ecdb9b,0xbaaf536b + .long 0x56efcc52,0x63ce59e5 + .long 0xcc10cb71,0x35e105b7 + .long 0x9c326e32,0xcd584973 + .long 0xe8802939,0xcc3f5b2f + .long 0x5691dbc8,0x1b016837 + .long 0x172e5258,0x748498a1 + .long 0xc054a64d,0x5c38159a + .long 0x47b13c4c,0xd5542df5 + .long 0x0c176a4b,0xd7db84f9 + .long 0x4d8ca869,0xa170ec87 + .long 0x7a887dc5,0x2dc2352c + .long 0xffc9e000,0xb91a63dd + .long 0x683353e6,0xc30b5023 + .long 0xacc2974b,0x694834e8 + .long 0xf684742f,0xd0be6d32 + .long 0xef45eae0,0x9f7076e6 + .long 0x8205d54b,0x68b2971a + .long 0x051fe181,0x954009fc + .long 0x235065b7,0xf85902c5 + .long 0x76ad895a,0xafa1cabf + .long 0xbcc167af,0xcd225eff + .long 0x2a0a9296,0xee53da9a + .long 0x0b6616b5,0xb113ef3e + .long 0x5343698e,0xe571fd23 + .long 0x2c4fc525,0x8817d5e9 + .long 0x3321b75c,0x4e200048 + .long 0x582fc459,0x6db7b27d + .long 0x6b2c2334,0x535ac1c0 + .long 0x5443bec7,0x302c9215 + .long 0xc1a8cd50,0xb0dca54e + .long 0xb311783e,0x301ef701 + .long 0xb5907cfa,0x8a53b232 + .long 0x1926cc6f,0x37991f36 + .long 0x35161df1,0xb670e5e9 + .long 0xbc0f0eae,0x78da44f6 + .long 0xdd557d6f,0x91861197 + .long 0x974bab3b,0x74b1a49b + .long 0x8721f118,0x5103908f + .long 0xf5b9f29f,0x7a7f4a7c + .long 0xf1780223,0x088d645b + .long 0x9bb1bf6c,0x75fff89a + .long 0x175f2cab,0x304224dd + .long 0x5edc8f9a,0x5ae75bb3 + .long 0xfdf7dcca,0x8471aa73 + .long 0x402dc36c,0x6eb26d54 + .long 0x181f7962,0xb8892e9d + .long 0x43430620,0xb61d0b05 + .long 0x8a405d9e,0x65199f85 + .long 0x7bd1558d,0xa7efbf7f + .long 0x7b2e6ea2,0x9fb644f6 + .long 0xea0c70db,0xff25f109 + .long 0x15aa362d,0xbc4db165 + .long 0x33cb6244,0x6a2d03b3 + .long 0x558b38f3,0x8d15dbe2 + .long 0xaa979ae7,0xa66e4835 + .long 0xc45282ff,0x0a8fb317 + .long 0x4ee38b21,0x7efd385b + .long 0x6a6d3f34,0xb8a1353a + .long 0x4b984e4b,0x7bbbf24d + .long 0x3646c2bf,0xd1084e32 + .long 0xf6070be1,0x205a92be + .long 0x53b30895,0x2d14e326 + .long 0xb1b02586,0x37154ab5 + .long 0x99255a58,0x42ee1c06 + .long 0x8fc3c45f,0x1689bb94 + .long 0x72ff0b6f,0xc46d7d3d + .long 0x33177a18,0x0d3baf0d + .long 0x99fbcce4,0x17b766e3 + .long 0xd6186f15,0xae05f266 + .long 0x440fb612,0xf871a0d4 + .long 0x0b68462b,0x1c777747 + .long 0xfcd6661e,0xd18b0875 + .long 0xbea193ff,0xb6701527 + .long 0x794d88a2,0x0195ab9e + .long 0x24d9eaba,0x48ab4e37 + .long 0xa6f9f2a9,0x154e09a0 + .long 0xe643b5ea,0x03546c4c + .long 0x2c9969e2,0x52015a7c + .long 0x0db47e6c,0x1fe5d322 + .long 0x9ec873e6,0xe48852a0 + .long 0x51f70e9d,0x3727d015 + .long 0xf7e77f97,0x3850bad9 + .long 0xdedeab2e,0xf517a919 + .long 0xe20ad56e,0xa8bd9548 + .long 0x618a8860,0x90421b96 + .long 0xe27527b9,0xd1ce79b8 + .long 0x55bff283,0x503ed27a + .long 0x4afea531,0xc7229671 + .long 0x43eb96b6,0x7074f3f1 + .long 0x90e14ee1,0xe1b151d8 + .long 0x21d8441e,0x88651e4b + .long 0x2004afd0,0xd30a868b + .long 0x4f1e3931,0xe409a222 + .long 0x708eb13a,0x2a1ef6f9 + .long 0xfdefe483,0xbd09a299 + .long 0x64cf42df,0x4ae8d96c + .long 0x18f749f7,0x2f771469 + .long 0x26a54a6a,0x785a4665 + .long 0x3b424827,0x0a339a2d + .long 0x98e09c08,0xd132a613 + .long 0x43e3bd69,0xdf1f8cae + .long 0x3c484aa7,0xf9d58502 + .long 0xd446696a,0x6d535f9b + .long 0xe0987765,0xfe6d75b7 + .long 0xceb12868,0x808d85a7 + .long 0x9ea34e6a,0xa0db7b5c + .long 0x9ad6c9d1,0x6e20970c + .long 0xc034957d,0xbb4d001d + .long 0x601c7838,0x3f135640 + .long 0x7cd92a3c,0x4fe26ca5 + .long 0x3f133aac,0x6ba9d2ce + .type __four_over_pi,@object + .size __four_over_pi,2104 + .data + .section .note.GNU-stack, "" +# End diff --git a/external/sgx_libm/intel64/trunc_gen.S b/external/sgx_libm/intel64/trunc_gen.S new file mode 100644 index 0000000000..374a372a63 --- /dev/null +++ b/external/sgx_libm/intel64/trunc_gen.S @@ -0,0 +1,126 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "trunc_gen.c" + .text +..TXTST0: +# -- Begin trunc + .text + .align 16,0x90 + .globl trunc +trunc: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_trunc.1: +..L2: + + movsd %xmm0, -8(%rsp) + movl -4(%rsp), %edx + movl %edx, %eax + andl $2147483647, %eax + addl $-1072693248, %eax + cmpl $54525952, %eax + jae ..B1.6 +..B1.2: + movl %eax, %ecx + shrl $20, %ecx + cmpl $22020096, %eax + jae ..B1.4 +..B1.3: + negl %ecx + movl $-1, %eax + addl $20, %ecx + shll %cl, %eax + andl %eax, %edx + movl %edx, -4(%rsp) + movl $0, -8(%rsp) + movsd -8(%rsp), %xmm0 + ret +..B1.4: + negl %ecx + movl $-1, %eax + addl $20, %ecx + shll %cl, %eax + andl %eax, -8(%rsp) + movsd -8(%rsp), %xmm0 +..B1.5: + ret +..B1.6: + testl %eax, %eax + jl ..B1.9 +..B1.7: + lea _ones(%rip), %rax + movsd -8(%rsp), %xmm0 + mulsd (%rax), %xmm0 +..B1.8: + ret +..B1.9: + lea _zeros(%rip), %rax + shrl $31, %edx + movsd (%rax,%rdx,8), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type trunc,@function + .size trunc,.-trunc + .data +# -- End trunc + .section .rodata, "a" + .align 4 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/truncf.S b/external/sgx_libm/intel64/truncf.S new file mode 100644 index 0000000000..5b4ecdd7eb --- /dev/null +++ b/external/sgx_libm/intel64/truncf.S @@ -0,0 +1,90 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "truncf.c" + .text +..TXTST0: +# -- Begin truncf + .text + .align 16,0x90 + .globl truncf +truncf: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_truncf.1: +..L2: + + movd %xmm0, %edx + movss %xmm0, -8(%rsp) + movl %edx, %ecx + andl $2147483647, %ecx + addl $-1065353216, %ecx + cmpl $192937984, %ecx + jb ..B1.5 +..B1.2: + testl %ecx, %ecx + jl ..B1.6 +..B1.4: + ret +..B1.5: + shrl $23, %ecx + movl $-1, %eax + negl %ecx + addl $23, %ecx + shll %cl, %eax + andl %eax, %edx + movl %edx, -8(%rsp) + movss -8(%rsp), %xmm0 + ret +..B1.6: + andl $-2147483648, %edx + movl %edx, -8(%rsp) + movss -8(%rsp), %xmm0 + ret + .align 16,0x90 + .cfi_endproc + .type truncf,@function + .size truncf,.-truncf + .data +# -- End truncf + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/truncl.S b/external/sgx_libm/intel64/truncl.S new file mode 100644 index 0000000000..e637ebb60f --- /dev/null +++ b/external/sgx_libm/intel64/truncl.S @@ -0,0 +1,180 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "truncl.c" + .text +..TXTST0: +# -- Begin truncl + .text + .align 16,0x90 + .globl truncl +truncl: +# parameter 1: 48 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_truncl.1: +..L2: + + subq $40, %rsp + .cfi_def_cfa_offset 48 +..B1.2: + fnstcw 26(%rsp) +..B1.3: + movzwl 56(%rsp), %ecx + andl $32767, %ecx + cmpl $16446, %ecx + jge ..B1.14 +..B1.4: + cmpl $16383, %ecx + jl ..B1.9 +..B1.5: + cmpl $16415, %ecx + jge ..B1.7 +..B1.6: + negl %ecx + addl $30, %ecx + movl 52(%rsp), %eax + shrl %cl, %eax + shll %cl, %eax + movl %eax, 52(%rsp) + xorl %eax, %eax + jmp ..B1.8 +..B1.7: + negl %ecx + addl $30, %ecx + movl 48(%rsp), %eax + shrl %cl, %eax + shll %cl, %eax +..B1.8: + movl %eax, 48(%rsp) + fldt 48(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.9: + testl %ecx, %ecx + jne ..B1.13 +..B1.10: + cmpl $0, 52(%rsp) + jne ..B1.12 +..B1.11: + cmpl $0, 48(%rsp) + je ..B1.13 +..B1.12: + lea _smallest_value_64(%rip), %rax + movq (%rax), %rdx + movq %rdx, (%rsp) +..B1.13: + movb 57(%rsp), %al + lea _zeros(%rip), %rdx + andb $-128, %al + shrb $7, %al + movzbl %al, %ecx + fldl (%rdx,%rcx,8) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.14: + movzwl 26(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.20 +..B1.15: + orl $-64768, %edx + movw %dx, 24(%rsp) +..B1.16: + fldcw 24(%rsp) +..B1.17: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) +..B1.18: + fldcw 26(%rsp) +..B1.19: + fldt 8(%rsp) + addq $40, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 48 +..B1.20: + fldt 48(%rsp) + lea _ones(%rip), %rax + fmull (%rax) + fstpt 8(%rsp) + jmp ..B1.19 + .align 16,0x90 + .cfi_endproc + .type truncl,@function + .size truncl,.-truncl + .data +# -- End truncl + .section .rodata, "a" + .align 4 + .align 4 +_smallest_value_64: + .long 1 + .long 0 + .long 1 + .long 2147483648 + .type _smallest_value_64,@object + .size _smallest_value_64,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/y0.S b/external/sgx_libm/intel64/y0.S new file mode 100644 index 0000000000..d2ea09d103 --- /dev/null +++ b/external/sgx_libm/intel64/y0.S @@ -0,0 +1,4231 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y0.c" + .text +..TXTST0: +# -- Begin y0 + .text + .align 16,0x90 + .globl y0 +y0: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_y0.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + xorb %bl, %bl + movsd %xmm0, (%rsp) +..B1.2: + fnstcw 10(%rsp) +..B1.3: + movl 4(%rsp), %edx + movl %edx, %ecx + andl $2147483647, %ecx + cmpl $2146435072, %ecx + jge ..B1.13 +..B1.4: + cmpq $0, (%rsp) + jle ..B1.19 +..B1.5: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.7: + fldcw 8(%rsp) +..B1.8: + movb $1, %bl +..B1.9: + addq $-16, %rsp + .cfi_def_cfa_offset 48 + fldl 16(%rsp) + fstpt (%rsp) +..___tag_value_y0.7: + call __y0l@PLT +..___tag_value_y0.8: +..B1.25: + addq $16, %rsp + .cfi_def_cfa_offset 32 +..B1.10: + fstpl (%rsp) + testb %bl, %bl + movsd (%rsp), %xmm0 + je ..B1.12 +..B1.11: + fldcw 10(%rsp) +..B1.12: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 3, -16 +..B1.13: + andl $-2146435073, %ecx + orl (%rsp), %ecx + jne ..B1.18 +..B1.14: + lea _zeros(%rip), %rax + testl $-2147483648, %edx + movsd (%rax), %xmm0 + je ..B1.17 +..B1.15: + lea _infs(%rip), %rax + movsd (%rax), %xmm1 + mulsd %xmm1, %xmm0 +..B1.17: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 3, -16 +..B1.18: + movsd (%rsp), %xmm0 + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 3, -16 +..B1.19: + lea _zeros(%rip), %rax + movl (%rsp), %edx + orl %edx, %ecx + movsd (%rax), %xmm1 + je ..B1.21 +..B1.20: + lea _infs(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm1, %xmm0 + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 3, -16 +..B1.21: + lea 8+_ones(%rip), %rax + movsd (%rax), %xmm0 + divsd %xmm1, %xmm0 +..B1.22: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type y0,@function + .size y0,.-y0 + .data +# -- End y0 + .text +# -- Begin __y0l + .text + .align 16,0x90 + .globl __y0l +__y0l: +# parameter 1: 96 + %rsp +..B2.1: + .cfi_startproc +..___tag_value___y0l.34: +..L35: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + lea 176+_S(%rip), %rax + fldt 96(%rsp) + fldt (%rax) + fcomip %st(1), %st + jb ..B2.22 +..B2.2: + lea _val_0_6L(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + ja ..B2.20 +..B2.3: + lea _val_1_2L(%rip), %rax + fldt (%rax) + fcomi %st(1), %st + jbe ..B2.5 +..B2.4: + fstp %st(0) + lea _Z(%rip), %rax + lea _P11(%rip), %rdx + lea 16+_P11(%rip), %rcx + lea 32+_P11(%rip), %rdi + lea 48+_P11(%rip), %r8 + lea 64+_P11(%rip), %r9 + lea 80+_P11(%rip), %r10 + fldt (%rax) + lea _Q11(%rip), %rsi + lea 16+_Q11(%rip), %r11 + lea 96+_P11(%rip), %rax + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 112+_P11(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 128+_P11(%rip), %rcx + fmul %st(2), %st + fldt (%rsi) + lea 144+_P11(%rip), %rsi + fmul %st(4), %st + fldt (%rdi) + lea 32+_Q11(%rip), %rdi + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r8) + lea 160+_P11(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r9) + lea 176+_P11(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r10) + lea 192+_P11(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + lea 208+_P11(%rip), %r11 + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt (%rax) + lea 48+_Q11(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rdx) + lea _ones(%rip), %rdx + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rcx) + lea 224+_P11(%rip), %rcx + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rsi) + lea 240+_P11(%rip), %rsi + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rdi) + lea 256+_P11(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r8) + lea 272+_P11(%rip), %r8 + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + faddp %st, %st(3) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fdivrl (%rdx) + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B2.27 +..B2.5: + lea _S(%rip), %rcx + fldt (%rcx) + fcomip %st(2), %st + jbe ..B2.7 +..B2.6: + lea _P12(%rip), %rax + lea 16+_P12(%rip), %rdx + lea 32+_P12(%rip), %rcx + lea 48+_P12(%rip), %rsi + lea 64+_P12(%rip), %rdi + lea 80+_P12(%rip), %r8 + lea 96+_P12(%rip), %r9 + lea 112+_P12(%rip), %r10 + fldt (%rax) + lea 128+_P12(%rip), %r11 + lea 144+_P12(%rip), %rax + fxch %st(1) + fsubrp %st, %st(2) + fld %st(1) + fmul %st(2), %st + fmul %st, %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 160+_P12(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 176+_P12(%rip), %rcx + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt (%rsi) + lea 192+_P12(%rip), %rsi + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rdi) + lea 208+_P12(%rip), %rdi + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%r8) + lea 224+_P12(%rip), %r8 + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r9) + lea 240+_P12(%rip), %r9 + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%r10) + lea 256+_P12(%rip), %r10 + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r11) + lea 272+_P12(%rip), %r11 + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rax) + lea 288+_P12(%rip), %rax + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rdx) + lea 304+_P12(%rip), %rdx + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rcx) + lea 320+_P12(%rip), %rcx + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rsi) + lea 336+_P12(%rip), %rsi + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rdi) + lea 352+_P12(%rip), %rdi + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r8) + lea 368+_P12(%rip), %r8 + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%r9) + lea 384+_P12(%rip), %r9 + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r10) + lea 400+_P12(%rip), %r10 + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%r11) + lea 416+_P12(%rip), %r11 + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rax) + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rdx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rcx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rsi) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rdi) + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%r8) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r9) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r11) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.7: + fstp %st(0) + lea _val_3_0L(%rip), %rax + fldt (%rax) + fcomi %st(1), %st + jbe ..B2.9 +..B2.8: + lea _P20(%rip), %rax + lea 16+_P20(%rip), %rdx + lea 32+_P20(%rip), %rcx + lea 48+_P20(%rip), %rsi + lea 64+_P20(%rip), %rdi + lea 80+_P20(%rip), %r8 + lea 96+_P20(%rip), %r9 + lea 112+_P20(%rip), %r10 + lea 128+_P20(%rip), %r11 + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rax) + lea 144+_P20(%rip), %rax + fmul %st(1), %st + fldt (%rdx) + lea 160+_P20(%rip), %rdx + fmul %st(2), %st + fldt (%rcx) + lea 176+_P20(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 192+_P20(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 208+_P20(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 224+_P20(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 240+_P20(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 256+_P20(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 272+_P20(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%r10) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r11) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.9: + fstp %st(0) + lea _val_3_875L(%rip), %rax + fldt (%rax) + fcomi %st(1), %st + jbe ..B2.11 +..B2.10: + lea _P21(%rip), %rax + lea 16+_P21(%rip), %rdx + lea 32+_P21(%rip), %rcx + lea 48+_P21(%rip), %rsi + lea 64+_P21(%rip), %rdi + lea 80+_P21(%rip), %r8 + lea 96+_P21(%rip), %r9 + lea 112+_P21(%rip), %r10 + fldt (%rax) + fxch %st(1) + fsubrp %st, %st(2) + fld %st(1) + lea 128+_P21(%rip), %r11 + lea 144+_P21(%rip), %rax + fmul %st(2), %st + fmul %st, %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 160+_P21(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 176+_P21(%rip), %rcx + faddp %st, %st(3) + fxch %st(1) + fmul %st, %st(2) + fldt (%rsi) + lea 192+_P21(%rip), %rsi + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rdi) + lea 208+_P21(%rip), %rdi + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%r8) + lea 224+_P21(%rip), %r8 + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r9) + lea 240+_P21(%rip), %r9 + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%r10) + lea 256+_P21(%rip), %r10 + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r11) + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rax) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rdx) + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rcx) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%rsi) + faddp %st, %st(3) + fmul %st, %st(2) + fldt (%rdi) + faddp %st, %st(2) + fmul %st, %st(1) + fldt (%r8) + faddp %st, %st(3) + fmulp %st, %st(2) + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%r10) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.11: + fstp %st(0) + lea 16+_S(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + jb ..B2.13 +..B2.12: + lea 16+_Z(%rip), %rax + lea _P22(%rip), %rdx + lea 16+_P22(%rip), %rcx + lea 32+_P22(%rip), %rsi + lea 48+_P22(%rip), %rdi + lea 64+_P22(%rip), %r8 + lea 80+_P22(%rip), %r9 + lea 96+_P22(%rip), %r10 + fldt (%rax) + lea 112+_P22(%rip), %r11 + lea 128+_P22(%rip), %rax + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 144+_P22(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 160+_P22(%rip), %rcx + fmul %st(2), %st + fldt (%rsi) + lea 176+_P22(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 192+_P22(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 208+_P22(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 224+_P22(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 240+_P22(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 256+_P22(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 272+_P22(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 288+_P22(%rip), %rdx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rdx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.13: + lea 32+_S(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + jbe ..B2.15 +..B2.14: + lea 32+_Z(%rip), %rax + lea _P3(%rip), %rdx + lea 16+_P3(%rip), %rcx + lea 32+_P3(%rip), %rsi + lea 48+_P3(%rip), %rdi + lea 64+_P3(%rip), %r8 + lea 80+_P3(%rip), %r9 + fldt (%rax) + lea 96+_P3(%rip), %r10 + lea 112+_P3(%rip), %r11 + lea 128+_P3(%rip), %rax + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 144+_P3(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 160+_P3(%rip), %rcx + fmul %st(2), %st + fldt (%rsi) + lea 176+_P3(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 192+_P3(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 208+_P3(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 224+_P3(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 240+_P3(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 256+_P3(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 272+_P3(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 288+_P3(%rip), %rdx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + lea 304+_P3(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 320+_P3(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 336+_P3(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rsi) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rdi) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.15: + movl $3, %edx + movl $48, %eax +..B2.16: + fldt (%rax,%rcx) + fcomip %st(1), %st + ja ..B2.19 + jp ..B2.19 +..B2.17: + incq %rdx + addq $16, %rax + cmpq $11, %rdx + jl ..B2.16 +..B2.18: + movq %rdx, %rax + shlq $4, %rax +..B2.19: + lea _Z(%rip), %rcx + fldt (%rax,%rcx) + lea (%rdx,%rdx,4), %rax + shlq $6, %rax + fsubrp %st, %st(1) + fld %st(0) + lea _P(%rip), %rdx + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt -960(%rax,%rdx) + fmul %st(1), %st + fldt -944(%rax,%rdx) + fmul %st(2), %st + fldt -928(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -912(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -896(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -880(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -864(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -848(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -832(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -816(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -800(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -784(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -768(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -752(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -736(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -720(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -704(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -688(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -672(%rax,%rdx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -656(%rax,%rdx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.27 +..B2.20: + fld %st(0) + lea _P0(%rip), %rax + fmul %st(1), %st + lea 16+_P0(%rip), %rdx + fxch %st(1) + fld %st(1) + lea 32+_P0(%rip), %rcx + fmul %st(2), %st + lea 48+_P0(%rip), %rsi + lea 64+_P0(%rip), %rdi + lea 80+_P0(%rip), %r8 + lea 96+_P0(%rip), %r9 + lea 112+_P0(%rip), %r10 + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + fxch %st(1) + fstpt (%rsp) + fldt (%rax) + fmul %st(2), %st + fldt (%rdx) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt (%r9) + faddp %st, %st(1) + fmulp %st, %st(1) + fldt (%r10) + faddp %st, %st(2) + faddp %st, %st(1) + fstpt 16(%rsp) +..___tag_value___y0l.38: + call __j0l@PLT +..___tag_value___y0l.39: +..B2.31: + fldt 112(%rsp) + fxch %st(1) + fstpt 32(%rsp) + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 96 +..B2.21: + fxch %st(1) + fstpl 40(%rsp) + movsd 40(%rsp), %xmm0 + fstpt (%rsp) + call log@PLT +..B2.32: + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt 16(%rsp) + movsd %xmm0, 32(%rsp) + fldt (%rax) + fmulp %st, %st(1) + fmull 32(%rsp) + faddp %st, %st(1) + jmp ..B2.27 +..B2.22: + lea _ones(%rip), %rax + lea _val_36_0L(%rip), %rdx + lea _PP(%rip), %rcx + lea _QP(%rip), %rsi + lea 16+_PP(%rip), %rdi + lea 16+_QP(%rip), %r8 + lea 32+_PP(%rip), %r9 + lea 32+_QP(%rip), %r10 + fldl (%rax) + lea 48+_PP(%rip), %r11 + fdiv %st(1), %st + lea 48+_QP(%rip), %rax + fxch %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rdx) + lea 64+_PP(%rip), %rdx + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fxch %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + fxch %st(2) + fstpt (%rsp) + fldt (%rcx) + lea 64+_QP(%rip), %rcx + fmul %st(1), %st + fldt (%rsi) + lea 80+_PP(%rip), %rsi + fmul %st(2), %st + fldt (%rdi) + lea 80+_QP(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 96+_PP(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 96+_QP(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 112+_PP(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 112+_QP(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_PP(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 128+_QP(%rip), %rdx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + lea 144+_PP(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 144+_QP(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 80(%rsp), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + movl $-1, %edx + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rcx) + faddp %st, %st(1) + fstpt -48(%rdi) + fldt (%rsi) + lea 64(%rsp), %rsi + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -16(%rsi) +..___tag_value___y0l.42: + call __libm_sincos_pi4l@PLT +..___tag_value___y0l.43: +..B2.33: + fldt 112(%rsp) + fldt 48(%rsp) + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 96 +..B2.23: + fldt 64(%rsp) + lea _val_0_03L(%rip), %rax + fmulp %st, %st(1) + fldt 48(%rsp) + fmulp %st, %st(2) + fadd %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt (%rax) + fmulp %st, %st(1) + fcomip %st(1), %st + fstp %st(0) + jae ..B2.25 + jp ..B2.25 +..B2.24: + fstp %st(1) + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + jmp ..B2.27 +..B2.25: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B2.35: + addq $16, %rsp + .cfi_def_cfa_offset 96 + movaps (%rsp), %xmm0 +..___tag_value___y0l.47: + call __y0q@PLT +..___tag_value___y0l.48: +..B2.26: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B2.36: + fstpl 40(%rsp) + movsd 40(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) +..B2.27: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __y0l,@function + .size __y0l,.-__y0l + .data +# -- End __y0l + .section .rodata, "a" + .align 4 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_S: + .word 5921 + .word 65426 + .word 63142 + .word 35997 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 29632 + .word 15745 + .word 62068 + .word 44479 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 41288 + .word 2893 + .word 15731 + .word 35209 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 12322 + .word 41360 + .word 35270 + .word 48124 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 21828 + .word 62500 + .word 60486 + .word 61019 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 54460 + .word 63729 + .word 58186 + .word 36952 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 27250 + .word 3142 + .word 10825 + .word 43393 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 20649 + .word 49414 + .word 53633 + .word 49831 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 59160 + .word 26587 + .word 26484 + .word 56269 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 57283 + .word 10561 + .word 16432 + .word 62706 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 44243 + .word 51162 + .word 18495 + .word 34571 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 63781 + .word 54231 + .word 15770 + .word 37789 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _S,@object + .size _S,192 + .align 2 +_val_0_6L: + .word 39322 + .word 39321 + .word 39321 + .word 39321 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _val_0_6L,@object + .size _val_0_6L,16 + .align 2 +_val_1_2L: + .word 39322 + .word 39321 + .word 39321 + .word 39321 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _val_1_2L,@object + .size _val_1_2L,16 + .align 2 +_Z: + .word 20971 + .word 41151 + .word 30150 + .word 58561 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 56848 + .word 49844 + .word 39532 + .word 64842 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 5940 + .word 14600 + .word 60967 + .word 58048 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 48233 + .word 9194 + .word 47533 + .word 41870 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 19716 + .word 3898 + .word 3621 + .word 54727 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 41547 + .word 400 + .word 58272 + .word 33793 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 46312 + .word 65374 + .word 26362 + .word 40225 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 15253 + .word 48480 + .word 38891 + .word 46657 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 12158 + .word 16394 + .word 14239 + .word 53090 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 31253 + .word 2914 + .word 8779 + .word 59523 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 29606 + .word 9567 + .word 8455 + .word 32978 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 51148 + .word 41491 + .word 50276 + .word 36194 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _Z,@object + .size _Z,192 + .align 2 +_P11: + .word 21672 + .word 14168 + .word 38767 + .word 33539 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 41169 + .word 50619 + .word 21849 + .word 37014 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 55003 + .word 42793 + .word 44721 + .word 50737 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 1169 + .word 13656 + .word 30890 + .word 57268 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 2761 + .word 22275 + .word 55697 + .word 58639 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 63624 + .word 9235 + .word 64995 + .word 56818 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 62376 + .word 14952 + .word 24232 + .word 50456 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 35764 + .word 14862 + .word 11423 + .word 44812 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 799 + .word 749 + .word 44421 + .word 44099 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 57800 + .word 45157 + .word 3532 + .word 40524 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 54824 + .word 35595 + .word 46140 + .word 46550 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 57927 + .word 14014 + .word 38764 + .word 61194 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 31025 + .word 58986 + .word 13056 + .word 57752 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 25304 + .word 41780 + .word 21387 + .word 41754 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 38881 + .word 54183 + .word 37931 + .word 34827 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 19650 + .word 12565 + .word 569 + .word 58514 + .word 16383 + .word 0 + .word 0 + .word 0 + .word 23916 + .word 27820 + .word 49726 + .word 50434 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 37686 + .word 17141 + .word 5720 + .word 38948 + .word 16317 + .word 0 + .word 0 + .word 0 + .type _P11,@object + .size _P11,288 + .align 2 +_Q11: + .word 14194 + .word 21345 + .word 52686 + .word 49437 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 16969 + .word 59638 + .word 1826 + .word 39310 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 28926 + .word 48282 + .word 1364 + .word 41291 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 13574 + .word 15497 + .word 63728 + .word 57349 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _Q11,@object + .size _Q11,64 + .align 2 +_P12: + .word 59330 + .word 22263 + .word 34178 + .word 51006 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 16861 + .word 21193 + .word 35273 + .word 46715 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 2103 + .word 12628 + .word 1838 + .word 41114 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 46148 + .word 53581 + .word 46203 + .word 46468 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 19710 + .word 1268 + .word 64842 + .word 38086 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 10276 + .word 59226 + .word 39596 + .word 48586 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 31029 + .word 64049 + .word 23137 + .word 50693 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 22014 + .word 1854 + .word 56980 + .word 45052 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 12740 + .word 38047 + .word 44756 + .word 35383 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 9689 + .word 42893 + .word 35756 + .word 50848 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 16570 + .word 20820 + .word 51546 + .word 34499 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 49962 + .word 36228 + .word 57995 + .word 45370 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 32489 + .word 35981 + .word 43312 + .word 58898 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 10311 + .word 12657 + .word 16405 + .word 38148 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 32504 + .word 29604 + .word 49577 + .word 49580 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 65322 + .word 54336 + .word 27403 + .word 64825 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 33227 + .word 51353 + .word 11288 + .word 42704 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 30209 + .word 39595 + .word 16790 + .word 56786 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 17645 + .word 4926 + .word 40100 + .word 38165 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 6983 + .word 2488 + .word 5292 + .word 51990 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 4652 + .word 21592 + .word 9570 + .word 36478 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 53361 + .word 14763 + .word 26464 + .word 52381 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 50485 + .word 35307 + .word 30503 + .word 59794 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 18614 + .word 21402 + .word 49824 + .word 37715 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 55547 + .word 61092 + .word 564 + .word 48870 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 9082 + .word 24716 + .word 52021 + .word 40706 + .word 16382 + .word 0 + .word 0 + .word 0 + .word 17305 + .word 30912 + .word 47308 + .word 59790 + .word 16380 + .word 0 + .word 0 + .word 0 + .type _P12,@object + .size _P12,432 + .align 2 +_val_3_0L: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _val_3_0L,@object + .size _val_3_0L,16 + .align 2 +_P20: + .word 37654 + .word 4018 + .word 25149 + .word 64448 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 19189 + .word 12397 + .word 54733 + .word 33028 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 22349 + .word 41220 + .word 13172 + .word 45200 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 43891 + .word 61784 + .word 34756 + .word 53833 + .word 16358 + .word 0 + .word 0 + .word 0 + .word 23592 + .word 62506 + .word 40671 + .word 50152 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 27771 + .word 49376 + .word 49653 + .word 53593 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 29892 + .word 65375 + .word 48818 + .word 47355 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 33664 + .word 20071 + .word 46988 + .word 35237 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 40179 + .word 47562 + .word 27113 + .word 46088 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 39977 + .word 33568 + .word 2856 + .word 39237 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 22462 + .word 11227 + .word 63692 + .word 48552 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 9895 + .word 49985 + .word 29445 + .word 35598 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 41034 + .word 13031 + .word 20740 + .word 35245 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 32927 + .word 48253 + .word 43 + .word 37376 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 5109 + .word 58801 + .word 31733 + .word 33042 + .word 16379 + .word 0 + .word 0 + .word 0 + .word 34717 + .word 51477 + .word 15888 + .word 35209 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 4166 + .word 43043 + .word 47592 + .word 42555 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 20077 + .word 289 + .word 31753 + .word 49394 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _P20,@object + .size _P20,288 + .align 2 +_val_3_875L: + .word 0 + .word 0 + .word 0 + .word 63488 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _val_3_875L,@object + .size _val_3_875L,16 + .align 2 +_P21: + .word 27895 + .word 14185 + .word 11256 + .word 61473 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 55110 + .word 27090 + .word 21413 + .word 51858 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 47481 + .word 51958 + .word 45685 + .word 44708 + .word 49121 + .word 0 + .word 0 + .word 0 + .word 53606 + .word 43192 + .word 10601 + .word 36675 + .word 49120 + .word 0 + .word 0 + .word 0 + .word 9703 + .word 39697 + .word 3773 + .word 54687 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 39016 + .word 46259 + .word 57439 + .word 47927 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 18601 + .word 64800 + .word 43294 + .word 45654 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 11755 + .word 20846 + .word 12691 + .word 36847 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 34925 + .word 21969 + .word 12496 + .word 40232 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 33074 + .word 22131 + .word 45345 + .word 58077 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 28402 + .word 30562 + .word 17788 + .word 44258 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 64431 + .word 22682 + .word 21098 + .word 38133 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 38064 + .word 47115 + .word 9737 + .word 49752 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 32940 + .word 23551 + .word 17164 + .word 63584 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 20289 + .word 55054 + .word 36724 + .word 37823 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 46434 + .word 29308 + .word 2375 + .word 53705 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 16931 + .word 9593 + .word 51956 + .word 35227 + .word 16378 + .word 0 + .word 0 + .word 0 + .type _P21,@object + .size _P21,272 + .align 2 +_P22: + .word 40244 + .word 7737 + .word 8636 + .word 43048 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 47822 + .word 28463 + .word 39991 + .word 46660 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 52293 + .word 15799 + .word 45377 + .word 51162 + .word 49113 + .word 0 + .word 0 + .word 0 + .word 37860 + .word 10494 + .word 27911 + .word 39108 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 1970 + .word 24596 + .word 57275 + .word 48105 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 64547 + .word 28877 + .word 41771 + .word 52711 + .word 16352 + .word 0 + .word 0 + .word 0 + .word 63459 + .word 4647 + .word 40018 + .word 64048 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 38817 + .word 50313 + .word 34514 + .word 41599 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 6873 + .word 59727 + .word 11575 + .word 48044 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 29515 + .word 62000 + .word 64058 + .word 40336 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 47818 + .word 19180 + .word 47066 + .word 42033 + .word 49133 + .word 0 + .word 0 + .word 0 + .word 35527 + .word 6093 + .word 4081 + .word 54678 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 16787 + .word 50723 + .word 15144 + .word 52417 + .word 16370 + .word 0 + .word 0 + .word 0 + .word 27442 + .word 31785 + .word 24103 + .word 36633 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 6233 + .word 52232 + .word 32482 + .word 57483 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 59606 + .word 43125 + .word 44255 + .word 61366 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 29998 + .word 6975 + .word 18760 + .word 53326 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 24786 + .word 2384 + .word 4789 + .word 52762 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 34816 + .word 30902 + .word 22802 + .word 44066 + .word 49086 + .word 0 + .word 0 + .word 0 + .type _P22,@object + .size _P22,304 + .align 2 +_P3: + .word 38373 + .word 25081 + .word 52784 + .word 41269 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 2433 + .word 58494 + .word 34093 + .word 49310 + .word 49089 + .word 0 + .word 0 + .word 0 + .word 20384 + .word 14386 + .word 32743 + .word 56565 + .word 16322 + .word 0 + .word 0 + .word 0 + .word 12279 + .word 3882 + .word 34299 + .word 37877 + .word 49096 + .word 0 + .word 0 + .word 0 + .word 57529 + .word 46240 + .word 60154 + .word 40126 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 46223 + .word 16522 + .word 54101 + .word 39334 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 17152 + .word 52627 + .word 55415 + .word 33597 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 46957 + .word 15713 + .word 64890 + .word 47269 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 63416 + .word 7921 + .word 11783 + .word 63655 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 22182 + .word 52374 + .word 10257 + .word 64822 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 20533 + .word 18718 + .word 7837 + .word 41493 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 34870 + .word 43221 + .word 2667 + .word 34068 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 62446 + .word 64657 + .word 15033 + .word 39509 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 31017 + .word 38768 + .word 5018 + .word 46409 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 37858 + .word 10529 + .word 62079 + .word 49339 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 60794 + .word 51427 + .word 47345 + .word 37742 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 8999 + .word 61205 + .word 62511 + .word 36506 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 22683 + .word 43326 + .word 42314 + .word 55672 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 37536 + .word 24482 + .word 58150 + .word 50356 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 47735 + .word 57962 + .word 45199 + .word 44407 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 54502 + .word 19410 + .word 25859 + .word 39334 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 1861 + .word 57822 + .word 27975 + .word 42824 + .word 49086 + .word 0 + .word 0 + .word 0 + .type _P3,@object + .size _P3,352 + .align 2 +_P: + .word 6710 + .word 46975 + .word 45541 + .word 45018 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 47994 + .word 32334 + .word 52627 + .word 65214 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 25829 + .word 961 + .word 45314 + .word 63623 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 56740 + .word 896 + .word 13408 + .word 40400 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 60385 + .word 50719 + .word 53670 + .word 35961 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 18363 + .word 40724 + .word 30788 + .word 37641 + .word 16343 + .word 0 + .word 0 + .word 0 + .word 54199 + .word 26560 + .word 1100 + .word 63052 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 31112 + .word 47384 + .word 24910 + .word 52460 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 62051 + .word 62630 + .word 7457 + .word 41285 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 41021 + .word 16553 + .word 53133 + .word 51701 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 43336 + .word 19494 + .word 20322 + .word 38261 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 44128 + .word 40851 + .word 40287 + .word 33282 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 15978 + .word 61692 + .word 60093 + .word 46462 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 34924 + .word 34591 + .word 27618 + .word 49090 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 22325 + .word 56457 + .word 51367 + .word 65297 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 21258 + .word 62600 + .word 63264 + .word 33170 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 31459 + .word 43701 + .word 15672 + .word 42803 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 10392 + .word 64190 + .word 8847 + .word 51227 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 34244 + .word 38351 + .word 44643 + .word 65457 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 24705 + .word 53181 + .word 1549 + .word 55232 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 24274 + .word 2157 + .word 59872 + .word 44641 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 44404 + .word 52032 + .word 31206 + .word 56185 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 42376 + .word 53700 + .word 44782 + .word 63474 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 55880 + .word 43379 + .word 3093 + .word 34064 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 62288 + .word 61979 + .word 24976 + .word 35576 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 30673 + .word 34148 + .word 2010 + .word 61956 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 45192 + .word 28065 + .word 60055 + .word 61722 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 24582 + .word 59932 + .word 774 + .word 41831 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 39741 + .word 15639 + .word 29541 + .word 39821 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 32965 + .word 53765 + .word 3652 + .word 39681 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 55274 + .word 5931 + .word 14729 + .word 36200 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 4659 + .word 41741 + .word 5124 + .word 48783 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 61896 + .word 13936 + .word 31722 + .word 42885 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 29587 + .word 13947 + .word 35938 + .word 34351 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 30548 + .word 42185 + .word 15217 + .word 58709 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 32944 + .word 45803 + .word 62008 + .word 44929 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 15543 + .word 17819 + .word 22981 + .word 37733 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 40787 + .word 12944 + .word 27687 + .word 34273 + .word 49144 + .word 0 + .word 0 + .word 0 + .word 14474 + .word 51712 + .word 20794 + .word 57241 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 31505 + .word 44115 + .word 25843 + .word 56405 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 29537 + .word 33343 + .word 23367 + .word 43948 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 15837 + .word 34931 + .word 8097 + .word 48214 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 1126 + .word 23018 + .word 59367 + .word 62418 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 50591 + .word 16203 + .word 45917 + .word 57446 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 6095 + .word 44294 + .word 16725 + .word 34699 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 2346 + .word 25530 + .word 14073 + .word 51139 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 48724 + .word 10078 + .word 7882 + .word 59578 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 3077 + .word 7734 + .word 24746 + .word 33688 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 52085 + .word 9505 + .word 49832 + .word 37954 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 41663 + .word 47247 + .word 238 + .word 62191 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 48361 + .word 39255 + .word 14492 + .word 33999 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 35816 + .word 34414 + .word 54424 + .word 37185 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 20077 + .word 189 + .word 48758 + .word 39656 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 35728 + .word 48114 + .word 41225 + .word 51144 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 10943 + .word 64308 + .word 2314 + .word 53541 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 32154 + .word 56468 + .word 40039 + .word 32925 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 4941 + .word 52917 + .word 35073 + .word 34082 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 61194 + .word 15048 + .word 42139 + .word 49938 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 19128 + .word 18289 + .word 6860 + .word 51502 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 49300 + .word 58708 + .word 59005 + .word 55071 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 26502 + .word 47642 + .word 36933 + .word 42964 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 30051 + .word 60756 + .word 30625 + .word 41460 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 61015 + .word 15762 + .word 48007 + .word 60846 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 21975 + .word 20753 + .word 22643 + .word 48677 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 54246 + .word 4624 + .word 38600 + .word 33572 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 59379 + .word 53723 + .word 32353 + .word 42607 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 40791 + .word 16038 + .word 57576 + .word 57139 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 25939 + .word 3603 + .word 54023 + .word 55128 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 7176 + .word 58381 + .word 25669 + .word 36047 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 23057 + .word 6107 + .word 22526 + .word 49962 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 19351 + .word 39386 + .word 35003 + .word 63923 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 45293 + .word 12882 + .word 9948 + .word 58748 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 20001 + .word 20829 + .word 53529 + .word 36918 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 21919 + .word 49831 + .word 37577 + .word 39856 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 47026 + .word 46471 + .word 55318 + .word 49443 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 61519 + .word 51459 + .word 6950 + .word 50870 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 1555 + .word 2971 + .word 23597 + .word 62610 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 45926 + .word 36681 + .word 39043 + .word 38451 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 64160 + .word 21923 + .word 31542 + .word 47202 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 36569 + .word 36429 + .word 41036 + .word 40257 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 63272 + .word 57206 + .word 4215 + .word 41813 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 38880 + .word 42175 + .word 14999 + .word 35837 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 42787 + .word 9806 + .word 63168 + .word 59020 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 31095 + .word 14929 + .word 48209 + .word 41580 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 36413 + .word 27679 + .word 45695 + .word 64718 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 24761 + .word 31380 + .word 27544 + .word 35930 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 11221 + .word 62995 + .word 50975 + .word 54692 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 29668 + .word 1933 + .word 17144 + .word 45888 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 30810 + .word 24149 + .word 32113 + .word 34254 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 34856 + .word 24408 + .word 21475 + .word 41075 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 33943 + .word 23810 + .word 62559 + .word 60314 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 3305 + .word 24934 + .word 37437 + .word 47776 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 54895 + .word 55211 + .word 32000 + .word 34613 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 35009 + .word 47065 + .word 21660 + .word 64281 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 9852 + .word 9156 + .word 55656 + .word 46121 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 36442 + .word 41210 + .word 20060 + .word 40802 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 21758 + .word 47322 + .word 2788 + .word 58210 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 52348 + .word 9004 + .word 18276 + .word 61559 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 54786 + .word 7147 + .word 27070 + .word 43826 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 34268 + .word 15768 + .word 2480 + .word 60089 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 1157 + .word 52048 + .word 20458 + .word 40588 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 51540 + .word 48806 + .word 47292 + .word 62380 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 19999 + .word 57758 + .word 46120 + .word 57112 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 21459 + .word 54484 + .word 23863 + .word 35854 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 28754 + .word 5362 + .word 55327 + .word 62303 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 45243 + .word 6687 + .word 17114 + .word 61365 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 32048 + .word 1009 + .word 39781 + .word 52368 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 64584 + .word 3308 + .word 26412 + .word 38818 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 23088 + .word 38547 + .word 22659 + .word 65247 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 14061 + .word 22418 + .word 61292 + .word 34447 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 57848 + .word 26921 + .word 61797 + .word 57155 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 1597 + .word 31414 + .word 38572 + .word 39774 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 30034 + .word 27108 + .word 16687 + .word 65316 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 32265 + .word 44536 + .word 9779 + .word 53216 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 550 + .word 16407 + .word 19715 + .word 43369 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 7132 + .word 1973 + .word 39654 + .word 33659 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 19090 + .word 42384 + .word 19608 + .word 54616 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 29916 + .word 8899 + .word 53582 + .word 50715 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 63987 + .word 34002 + .word 32751 + .word 41084 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 31930 + .word 50610 + .word 35321 + .word 40669 + .word 49085 + .word 0 + .word 0 + .word 0 + .word 64556 + .word 32042 + .word 47688 + .word 39353 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 22761 + .word 33268 + .word 25802 + .word 54704 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 48596 + .word 35082 + .word 36228 + .word 55222 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 62834 + .word 26257 + .word 62649 + .word 62428 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 22216 + .word 57771 + .word 11637 + .word 59993 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 32841 + .word 24077 + .word 25618 + .word 53031 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 7134 + .word 15474 + .word 25724 + .word 50216 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 679 + .word 61058 + .word 8963 + .word 33314 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 30607 + .word 23707 + .word 50236 + .word 62315 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 57112 + .word 44811 + .word 22996 + .word 58760 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 7925 + .word 14145 + .word 19419 + .word 54389 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 15063 + .word 11101 + .word 53306 + .word 33747 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 17212 + .word 63840 + .word 49608 + .word 61962 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 64221 + .word 2367 + .word 56115 + .word 44976 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 25958 + .word 42476 + .word 21228 + .word 41045 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 39160 + .word 29939 + .word 20970 + .word 56757 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 34212 + .word 35958 + .word 8729 + .word 51611 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 47817 + .word 56326 + .word 46415 + .word 42719 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 14697 + .word 51278 + .word 14116 + .word 38800 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 42056 + .word 1202 + .word 6817 + .word 52251 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 9811 + .word 3897 + .word 54180 + .word 38147 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 22279 + .word 36400 + .word 23268 + .word 48339 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 3604 + .word 63501 + .word 23839 + .word 53404 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 1179 + .word 37183 + .word 50892 + .word 54850 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 59751 + .word 27404 + .word 14795 + .word 57826 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 14718 + .word 11779 + .word 34360 + .word 46330 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 59705 + .word 41619 + .word 32041 + .word 48245 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 23030 + .word 54615 + .word 27535 + .word 57905 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 39169 + .word 62610 + .word 58529 + .word 59687 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 51398 + .word 44311 + .word 12717 + .word 50833 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 27431 + .word 2954 + .word 22657 + .word 51954 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 58296 + .word 29685 + .word 27243 + .word 58169 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 51216 + .word 48206 + .word 42318 + .word 59054 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 56132 + .word 37000 + .word 55250 + .word 38652 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 33362 + .word 39562 + .word 49329 + .word 39051 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 45334 + .word 5673 + .word 58520 + .word 48690 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 35653 + .word 20625 + .word 33642 + .word 49050 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 58051 + .word 8993 + .word 6809 + .word 36624 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 52356 + .word 59873 + .word 62958 + .word 36858 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 32142 + .word 25405 + .word 33867 + .word 33307 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 49519 + .word 13151 + .word 56037 + .word 36991 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 44868 + .word 63207 + .word 24006 + .word 43028 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 8083 + .word 45145 + .word 39702 + .word 51683 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 45111 + .word 52725 + .word 38011 + .word 48603 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 60521 + .word 20244 + .word 23464 + .word 55814 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 20556 + .word 16261 + .word 38082 + .word 40872 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 25337 + .word 58099 + .word 56911 + .word 46447 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 37285 + .word 19168 + .word 56812 + .word 50878 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 15949 + .word 20065 + .word 40118 + .word 57328 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 40507 + .word 40248 + .word 14830 + .word 44509 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 5104 + .word 24529 + .word 29756 + .word 49797 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 46472 + .word 25780 + .word 5432 + .word 50788 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 15446 + .word 10547 + .word 15373 + .word 56506 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 3213 + .word 104 + .word 59551 + .word 33676 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 34009 + .word 54843 + .word 32265 + .word 37318 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 45472 + .word 58672 + .word 64591 + .word 42366 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 32200 + .word 21528 + .word 8481 + .word 46835 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 49716 + .word 3176 + .word 29068 + .word 63703 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 39156 + .word 24341 + .word 43754 + .word 35182 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 61730 + .word 30329 + .word 55010 + .word 38388 + .word 16320 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,2880 + .align 2 +_P0: + .word 46060 + .word 21479 + .word 19707 + .word 37102 + .word 16345 + .word 0 + .word 0 + .word 0 + .word 35676 + .word 11242 + .word 15120 + .word 54134 + .word 49120 + .word 0 + .word 0 + .word 0 + .word 34641 + .word 49003 + .word 21090 + .word 56946 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 36501 + .word 52298 + .word 48288 + .word 40780 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 2947 + .word 56486 + .word 859 + .word 36145 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 6106 + .word 41115 + .word 36319 + .word 33709 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 13230 + .word 6676 + .word 23048 + .word 46558 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 62532 + .word 24192 + .word 46286 + .word 38694 + .word 49147 + .word 0 + .word 0 + .word 0 + .type _P0,@object + .size _P0,128 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _tonpi,@object + .size _tonpi,16 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,16 + .align 2 +_PP: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 0 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP,@object + .size _PP,160 + .align 2 +_QP: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 0 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .word 0 + .word 0 + .type _QP,@object + .size _QP,160 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/y0f.S b/external/sgx_libm/intel64/y0f.S new file mode 100644 index 0000000000..c9f3efb8d0 --- /dev/null +++ b/external/sgx_libm/intel64/y0f.S @@ -0,0 +1,805 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y0f.c" + .text +..TXTST0: +# -- Begin y0f + .text + .align 16,0x90 + .globl y0f +y0f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_y0f.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movd %xmm0, %ecx + movss %xmm0, 48(%rsp) + lea -1(%rcx), %eax + cmpl $2139095039, %eax + jae ..B1.13 +..B1.2: + cmpl $1099978979, %ecx + jae ..B1.21 +..B1.3: + cmpl $1094450314, %ecx + jae ..B1.12 +..B1.4: + cmpl $1085128690, %ecx + jae ..B1.11 +..B1.5: + cmpl $1074568695, %ecx + jae ..B1.10 +..B1.6: + cmpl $1058642330, %ecx + jb ..B1.8 +..B1.7: + cvtss2sd %xmm0, %xmm0 + lea 168+_P1(%rip), %rax + lea 160+_P1(%rip), %rdx + lea 144+_P1(%rip), %r9 + lea 128+_P1(%rip), %rcx + lea 112+_P1(%rip), %r10 + lea 96+_P1(%rip), %rsi + lea 80+_P1(%rip), %r11 + lea 64+_P1(%rip), %rdi + movsd (%rdx), %xmm6 + lea 32+_P1(%rip), %r8 + movsd (%r9), %xmm1 + lea 16+_P1(%rip), %rdx + lea 56+_P1(%rip), %r9 + subsd (%rax), %xmm0 + movaps %xmm0, %xmm2 + lea 48+_P1(%rip), %rax + mulsd %xmm0, %xmm2 + movaps %xmm2, %xmm3 + mulsd %xmm2, %xmm3 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm1 + addsd (%rcx), %xmm6 + addsd (%r10), %xmm1 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm1 + addsd (%rsi), %xmm6 + addsd (%r11), %xmm1 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm1 + addsd (%rdi), %xmm6 + addsd (%rax), %xmm1 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm1 + addsd (%r8), %xmm6 + addsd (%rdx), %xmm1 + mulsd %xmm3, %xmm6 + mulsd %xmm2, %xmm1 + lea 152+_P1(%rip), %rsi + lea 136+_P1(%rip), %r11 + lea 120+_P1(%rip), %rdi + lea 104+_P1(%rip), %rax + lea 88+_P1(%rip), %r8 + lea 72+_P1(%rip), %rdx + lea _P1(%rip), %rcx + lea 24+_P1(%rip), %r10 + movsd (%rsi), %xmm5 + lea 8+_P1(%rip), %rsi + mulsd %xmm3, %xmm5 + addsd %xmm1, %xmm6 + movsd (%r11), %xmm4 + mulsd %xmm3, %xmm4 + addsd (%rdi), %xmm5 + addsd (%rcx), %xmm6 + mulsd %xmm3, %xmm5 + addsd (%rax), %xmm4 + mulsd %xmm3, %xmm4 + addsd (%r8), %xmm5 + mulsd %xmm3, %xmm5 + addsd (%rdx), %xmm4 + mulsd %xmm3, %xmm4 + addsd (%r9), %xmm5 + lea 40+_P1(%rip), %rcx + mulsd %xmm3, %xmm5 + addsd (%rcx), %xmm4 + addsd (%r10), %xmm5 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm5 + addsd (%rsi), %xmm4 + mulsd %xmm0, %xmm5 + mulsd %xmm0, %xmm4 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.8: + pxor %xmm3, %xmm3 + cvtss2sd 48(%rsp), %xmm3 + movaps %xmm3, %xmm0 + movsd %xmm3, (%rsp) +..___tag_value_y0f.6: + call __libm_log_k32@PLT +..___tag_value_y0f.7: +..B1.25: + movsd (%rsp), %xmm3 +..B1.9: + mulsd %xmm3, %xmm3 + lea _tonpi(%rip), %rax + movaps %xmm3, %xmm2 + lea 32+_Q1(%rip), %rdx + lea 24+_Q2(%rip), %r9 + lea 16+_Q2(%rip), %r11 + mulsd %xmm3, %xmm2 + lea 24+_Q1(%rip), %rdi + movsd (%rax), %xmm6 + lea 16+_Q1(%rip), %rcx + mulsd %xmm0, %xmm6 + lea 8+_Q2(%rip), %r10 + movsd (%rdx), %xmm0 + lea _Q2(%rip), %rax + movsd (%r9), %xmm5 + lea 8+_Q1(%rip), %r8 + movsd (%r11), %xmm4 + lea _Q1(%rip), %rsi + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm4 + addsd (%rcx), %xmm0 + addsd (%r10), %xmm5 + addsd (%rax), %xmm4 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + mulsd %xmm3, %xmm4 + addsd (%rsi), %xmm0 + addsd %xmm4, %xmm5 + movsd (%rdi), %xmm1 + mulsd %xmm2, %xmm1 + mulsd %xmm6, %xmm5 + addsd (%r8), %xmm1 + mulsd %xmm3, %xmm1 + addsd %xmm1, %xmm0 + addsd %xmm5, %xmm0 + addsd %xmm6, %xmm0 + cvtsd2ss %xmm0, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.10: + pxor %xmm0, %xmm0 + lea 144+_P2(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + lea 136+_P2(%rip), %rdx + lea 120+_P2(%rip), %r9 + lea 104+_P2(%rip), %rcx + lea 88+_P2(%rip), %r10 + lea 72+_P2(%rip), %rsi + lea 56+_P2(%rip), %r11 + lea 40+_P2(%rip), %rdi + lea 8+_P2(%rip), %r8 + movsd (%rdx), %xmm6 + lea 128+_P2(%rip), %rdx + movsd (%r9), %xmm1 + lea 112+_P2(%rip), %r9 + subsd (%rax), %xmm0 + lea 24+_P2(%rip), %rax + movaps %xmm0, %xmm3 + mulsd %xmm0, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + addsd (%rcx), %xmm6 + addsd (%r10), %xmm1 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + addsd (%rsi), %xmm6 + addsd (%r11), %xmm1 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + addsd (%rdi), %xmm6 + addsd (%rax), %xmm1 + mulsd %xmm2, %xmm6 + mulsd %xmm3, %xmm1 + addsd (%r8), %xmm6 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm6 + movsd (%rdx), %xmm5 + lea 96+_P2(%rip), %rcx + mulsd %xmm2, %xmm5 + lea 80+_P2(%rip), %r10 + addsd %xmm1, %xmm6 + addsd (%rcx), %xmm5 + movsd (%r9), %xmm4 + lea 64+_P2(%rip), %rsi + mulsd %xmm2, %xmm4 + lea 48+_P2(%rip), %r11 + mulsd %xmm2, %xmm5 + addsd (%r10), %xmm4 + addsd (%rsi), %xmm5 + mulsd %xmm2, %xmm4 + mulsd %xmm2, %xmm5 + addsd (%r11), %xmm4 + lea 32+_P2(%rip), %rdi + lea 16+_P2(%rip), %rax + mulsd %xmm2, %xmm4 + lea _P2(%rip), %r8 + addsd (%rdi), %xmm5 + addsd (%rax), %xmm4 + mulsd %xmm2, %xmm5 + mulsd %xmm3, %xmm4 + addsd (%r8), %xmm5 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.11: + cmpl $1091143997, %ecx + pxor %xmm0, %xmm0 + lea _P3(%rip), %rdx + lea _P4(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + jb ..L12 + movq %rax, %rdx +..L12: + movsd 104(%rdx), %xmm6 + movsd 88(%rdx), %xmm1 + movsd 96(%rdx), %xmm5 + movsd 80(%rdx), %xmm4 + subsd 112(%rdx), %xmm0 + movaps %xmm0, %xmm3 + mulsd %xmm0, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd 72(%rdx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 56(%rdx), %xmm1 + addsd 64(%rdx), %xmm5 + mulsd %xmm2, %xmm6 + addsd 48(%rdx), %xmm4 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd 40(%rdx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 24(%rdx), %xmm1 + addsd 32(%rdx), %xmm5 + mulsd %xmm2, %xmm6 + addsd 16(%rdx), %xmm4 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm5 + addsd 8(%rdx), %xmm6 + mulsd %xmm3, %xmm4 + mulsd %xmm0, %xmm1 + addsd (%rdx), %xmm5 + mulsd %xmm0, %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm1, %xmm6 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + cmpl $1097751532, %ecx + pxor %xmm3, %xmm3 + lea _P5(%rip), %rdx + lea _P6(%rip), %rax + cvtss2sd 48(%rsp), %xmm3 + jb ..L15 + movq %rax, %rdx +..L15: + movsd 80(%rdx), %xmm6 + movsd 88(%rdx), %xmm5 + movsd 96(%rdx), %xmm0 + movsd 72(%rdx), %xmm4 + subsd 104(%rdx), %xmm3 + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm0 + addsd 48(%rdx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 56(%rdx), %xmm5 + addsd 64(%rdx), %xmm0 + mulsd %xmm2, %xmm6 + addsd 40(%rdx), %xmm4 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm0 + addsd 16(%rdx), %xmm6 + mulsd %xmm2, %xmm4 + addsd 24(%rdx), %xmm5 + addsd 32(%rdx), %xmm0 + mulsd %xmm1, %xmm6 + addsd 8(%rdx), %xmm4 + mulsd %xmm1, %xmm5 + mulsd %xmm2, %xmm0 + addsd (%rdx), %xmm6 + mulsd %xmm3, %xmm4 + mulsd %xmm3, %xmm5 + addsd %xmm0, %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.13: + movl %ecx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.20 +..B1.14: + testl %eax, %eax + je ..B1.19 +..B1.15: + testl $-2147483648, %ecx + pxor %xmm0, %xmm0 + je ..B1.18 +..B1.16: + movss .L_2il0floatpacket.1(%rip), %xmm1 + mulss %xmm1, %xmm0 +..B1.18: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.19: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.20: + movss 48(%rsp), %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.21: + pxor %xmm0, %xmm0 + lea _val_16_0(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + movsd .L_2il0floatpacket.2(%rip), %xmm1 + lea (%rsp), %rdi + divsd %xmm0, %xmm1 + movsd (%rax), %xmm2 + lea 8(%rsp), %rsi + mulsd %xmm1, %xmm2 + movl $-1, %edx + movsd %xmm2, 8(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm2, 24(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm1, 16(%rsi) + movsd %xmm2, 32(%rsi) +..___tag_value_y0f.24: + call __libm_sincos_k32@PLT +..___tag_value_y0f.25: +..B1.22: + lea 40+_QP(%rip), %r10 + lea 40+_PP(%rip), %rdx + movsd 40(%rsp), %xmm2 + lea 24+_QP(%rip), %r11 + lea 24+_PP(%rip), %rcx + lea 32+_PP(%rip), %rdi + lea _tonpi(%rip), %rax + lea 16+_PP(%rip), %r8 + movsd (%r10), %xmm5 + lea 8+_PP(%rip), %rsi + movsd (%rdx), %xmm6 + lea 32+_QP(%rip), %rdx + mulsd %xmm2, %xmm5 + lea _PP(%rip), %r9 + mulsd %xmm2, %xmm6 + addsd (%r11), %xmm5 + addsd (%rcx), %xmm6 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm6 + movsd (%rdx), %xmm4 + lea 16+_QP(%rip), %rcx + mulsd %xmm2, %xmm4 + addsd (%rsi), %xmm6 + movsd (%rdi), %xmm1 + lea _QP(%rip), %rsi + mulsd %xmm2, %xmm1 + addsd (%rcx), %xmm4 + movsd (%rax), %xmm0 + lea 8+_QP(%rip), %rax + mulsd %xmm2, %xmm4 + addsd (%r8), %xmm1 + mulsd 24(%rsp), %xmm0 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm1 + addsd (%rsi), %xmm4 + sqrtsd %xmm0, %xmm0 + addsd (%r9), %xmm1 + movsd 32(%rsp), %xmm3 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm1, %xmm6 + mulsd 16(%rsp), %xmm5 + mulsd (%rsp), %xmm6 + mulsd 8(%rsp), %xmm5 + addsd %xmm5, %xmm6 + mulsd %xmm6, %xmm0 + cvtsd2ss %xmm0, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type y0f,@function + .size y0f,.-y0f + .data +# -- End y0f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x7f800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_P1: + .long 4195291908 + .long 3162175307 + .long 406986291 + .long 1072440375 + .long 2776221165 + .long 3219095096 + .long 1133938471 + .long 1070349075 + .long 2954828429 + .long 3217879437 + .long 2763399148 + .long 1070335612 + .long 808830809 + .long 3217701246 + .long 1570268664 + .long 1070154462 + .long 3296077481 + .long 3217609508 + .long 420330990 + .long 1070118798 + .long 773510171 + .long 3217614074 + .long 4056659129 + .long 1070174592 + .long 3219431954 + .long 3217750970 + .long 3785879815 + .long 1070358232 + .long 574751405 + .long 3217779900 + .long 4260549547 + .long 1069957964 + .long 2938320462 + .long 3216782740 + .long 3378329138 + .long 1068120728 + .long 1915664650 + .long 3213929269 + .long 3426344990 + .long 1063895342 + .long 349103460 + .long 3207738231 + .long 3100907498 + .long 1072470062 + .type _P1,@object + .size _P1,176 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_Q1: + .long 2580172613 + .long 3216172246 + .long 1084453148 + .long 1069988811 + .long 2056290550 + .long 3213915569 + .long 1236657422 + .long 1061266913 + .long 2321867150 + .long 3202594720 + .type _Q1,@object + .size _Q1,40 + .align 4 +_Q2: + .long 4294648676 + .long 3218079743 + .long 3841535415 + .long 1066401791 + .long 664070481 + .long 3208409496 + .long 1981210199 + .long 1054621065 + .type _Q2,@object + .size _Q2,32 + .align 4 +_P2: + .long 1454683265 + .long 3163093641 + .long 1453379447 + .long 3218719554 + .long 687601567 + .long 1068108233 + .long 2612704149 + .long 1068365525 + .long 3658933664 + .long 3212579183 + .long 2932711330 + .long 3210863403 + .long 1642366143 + .long 1059690534 + .long 3271323791 + .long 1057665714 + .long 1907282597 + .long 3201598976 + .long 379771377 + .long 3197347542 + .long 4245487245 + .long 3193415108 + .long 3608497393 + .long 1045674492 + .long 2931231697 + .long 3190739602 + .long 990015633 + .long 1041359383 + .long 1316300206 + .long 3186258158 + .long 3640313785 + .long 3183477336 + .long 2399178872 + .long 3182342144 + .long 1279629276 + .long 1034489495 + .long 1301829276 + .long 1074768211 + .type _P2,@object + .size _P2,152 + .align 4 +_P3: + .long 2564005090 + .long 1014927793 + .long 2691273771 + .long 1070806220 + .long 300870104 + .long 3214257910 + .long 1691761700 + .long 3215496860 + .long 2795355208 + .long 1063989012 + .long 2286168356 + .long 1063375710 + .long 3010782666 + .long 3206704598 + .long 629642940 + .long 3204978559 + .long 4085313989 + .long 1053206786 + .long 1695842824 + .long 1050888907 + .long 399213285 + .long 3194002865 + .long 3012936744 + .long 3191097259 + .long 3874678520 + .long 1039019405 + .long 2821019721 + .long 1035940102 + .long 3303481603 + .long 1075599389 + .type _P3,@object + .size _P3,120 + .align 4 +_P4: + .long 3357785889 + .long 3165432791 + .long 3430075659 + .long 3218077237 + .long 1374220014 + .long 1065943908 + .long 2803440381 + .long 1067771495 + .long 3788987270 + .long 3210752606 + .long 378839180 + .long 3210732089 + .long 3385429871 + .long 1058535500 + .long 2609792408 + .long 1057402845 + .long 2316098656 + .long 3200270393 + .long 2785606124 + .long 3198332594 + .long 1489685130 + .long 1046034133 + .long 973177683 + .long 1043605688 + .long 113866720 + .long 3186126026 + .long 1355313597 + .long 3183357512 + .long 899972440 + .long 1076130263 + .type _P4,@object + .size _P4,120 + .align 4 +_P5: + .long 1219042543 + .long 1017436670 + .long 659497129 + .long 1070330666 + .long 2213395954 + .long 3212885037 + .long 920472610 + .long 3215092907 + .long 483400048 + .long 1062596670 + .long 3012498212 + .long 1063037606 + .long 1375970636 + .long 3205547500 + .long 3836089736 + .long 3204771982 + .long 199192965 + .long 1052233910 + .long 194857414 + .long 1050781561 + .long 2407988550 + .long 3193126966 + .long 3806101946 + .long 3190982557 + .long 3164279536 + .long 1038193510 + .long 3298944842 + .long 1076541665 + .type _P5,@object + .size _P5,112 + .align 4 +_P6: + .long 4139807906 + .long 1017960487 + .long 1501500641 + .long 3217630659 + .long 2447579003 + .long 1064854100 + .long 511348540 + .long 1067492433 + .long 1810619958 + .long 3209696179 + .long 1806624601 + .long 3210355872 + .long 4035698547 + .long 1057552651 + .long 467530437 + .long 1057185016 + .long 2985801821 + .long 3199346510 + .long 2460583618 + .long 3198194818 + .long 4117830692 + .long 1045310355 + .long 1133672721 + .long 1043441078 + .long 2717688296 + .long 3185336108 + .long 1946169876 + .long 1076920380 + .type _P6,@object + .size _P6,112 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_QP: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP,@object + .size _QP,48 + .align 4 +_PP: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP,@object + .size _PP,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/y0l.S b/external/sgx_libm/intel64/y0l.S new file mode 100644 index 0000000000..1443a25af1 --- /dev/null +++ b/external/sgx_libm/intel64/y0l.S @@ -0,0 +1,86 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y0l.c" + .text +..TXTST0: +# -- Begin y0l + .text + .align 16,0x90 + .globl y0l +y0l: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_y0l.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 48 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B1.6: + addq $16, %rsp + .cfi_def_cfa_offset 32 + movaps (%rsp), %xmm0 +..___tag_value_y0l.6: + call __y0q@PLT +..___tag_value_y0l.7: +..B1.2: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type y0l,@function + .size y0l,.-y0l + .data +# -- End y0l + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/y1.S b/external/sgx_libm/intel64/y1.S new file mode 100644 index 0000000000..c7fdf10f2f --- /dev/null +++ b/external/sgx_libm/intel64/y1.S @@ -0,0 +1,3354 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y1.c" + .text +..TXTST0: +# -- Begin y1 + .text + .align 16,0x90 + .globl y1 +y1: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_y1.1: +..L2: + + pushq %r15 + .cfi_def_cfa_offset 16 + .cfi_offset 15, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + xorb %r15b, %r15b + movsd %xmm0, (%rsp) +..B1.2: + fnstcw 10(%rsp) +..B1.3: + movl 4(%rsp), %eax + movl %eax, %ecx + andl $2147483647, %ecx + cmpl $2146435072, %ecx + jge ..B1.13 +..B1.4: + cmpq $0, (%rsp) + jle ..B1.19 +..B1.5: + movzwl 10(%rsp), %edx + movl %edx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.9 +..B1.6: + orl $-64768, %edx + movw %dx, 8(%rsp) +..B1.7: + fldcw 8(%rsp) +..B1.8: + movb $1, %r15b +..B1.9: + addq $-16, %rsp + .cfi_def_cfa_offset 48 + fldl 16(%rsp) + fstpt (%rsp) +..___tag_value_y1.7: + call __y1l@PLT +..___tag_value_y1.8: +..B1.25: + addq $16, %rsp + .cfi_def_cfa_offset 32 +..B1.10: + fstpl (%rsp) + testb %r15b, %r15b + movsd (%rsp), %xmm0 + je ..B1.12 +..B1.11: + fldcw 10(%rsp) +..B1.12: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 15, -16 +..B1.13: + andl $-2146435073, %ecx + orl (%rsp), %ecx + jne ..B1.18 +..B1.14: + testl $-2147483648, %eax + je ..B1.16 +..B1.15: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 15, -16 +..B1.16: + lea _zeros(%rip), %rdx + shrl $31, %eax + movsd (%rdx,%rax,8), %xmm0 +..B1.17: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 15, -16 +..B1.18: + movsd (%rsp), %xmm0 + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 15, -16 +..B1.19: + lea _zeros(%rip), %rax + movl (%rsp), %edx + orl %edx, %ecx + movsd (%rax), %xmm1 + je ..B1.21 +..B1.20: + lea _infs(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm1, %xmm0 + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 32 + .cfi_offset 15, -16 +..B1.21: + lea 8+_ones(%rip), %rax + movsd (%rax), %xmm0 + divsd %xmm1, %xmm0 +..B1.22: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type y1,@function + .size y1,.-y1 + .data +# -- End y1 + .text +# -- Begin __y1l + .text + .align 16,0x90 + .globl __y1l +__y1l: +# parameter 1: 96 + %rsp +..B2.1: + .cfi_startproc +..___tag_value___y1l.39: +..L40: + + subq $88, %rsp + .cfi_def_cfa_offset 96 + lea 176+_S(%rip), %rax + fldt 96(%rsp) + fldt (%rax) + fcomip %st(1), %st + jb ..B2.14 +..B2.2: + lea _val_1_77L(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + ja ..B2.12 +..B2.3: + lea _S(%rip), %rcx + fldt (%rcx) + fcomip %st(1), %st + jbe ..B2.5 +..B2.4: + lea _Z(%rip), %rax + lea _P1(%rip), %rdx + lea 16+_P1(%rip), %rcx + lea _Q1(%rip), %rsi + lea 32+_P1(%rip), %rdi + lea 48+_P1(%rip), %r8 + lea 16+_Q1(%rip), %r9 + fldt (%rax) + lea 64+_P1(%rip), %r10 + lea 80+_P1(%rip), %r11 + lea 32+_Q1(%rip), %rax + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 96+_P1(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 112+_P1(%rip), %rcx + fmul %st(2), %st + fldt (%rsi) + lea 48+_Q1(%rip), %rsi + fmul %st(4), %st + fldt (%rdi) + lea 128+_P1(%rip), %rdi + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r8) + lea 144+_P1(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r9) + lea 64+_Q1(%rip), %r9 + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt (%r10) + lea 160+_P1(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + lea 176+_P1(%rip), %r11 + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rax) + lea 80+_Q1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%rdx) + lea _ones(%rip), %rdx + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rcx) + lea 192+_P1(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rsi) + lea 208+_P1(%rip), %rsi + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt (%rdi) + lea 224+_P1(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r8) + lea 240+_P1(%rip), %r8 + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + faddp %st, %st(3) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fdivrl (%rdx) + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B2.19 +..B2.5: + lea 16+_S(%rip), %rax + fldt (%rax) + fcomip %st(1), %st + jbe ..B2.7 +..B2.6: + lea 16+_Z(%rip), %rax + lea _P2(%rip), %rdx + lea 16+_P2(%rip), %rcx + lea _Q2(%rip), %rsi + lea 32+_P2(%rip), %rdi + lea 48+_P2(%rip), %r8 + lea 16+_Q2(%rip), %r9 + fldt (%rax) + lea 64+_P2(%rip), %r10 + lea 80+_P2(%rip), %r11 + lea 32+_Q2(%rip), %rax + fsubrp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt (%rdx) + lea 96+_P2(%rip), %rdx + fmul %st(1), %st + fldt (%rcx) + lea 112+_P2(%rip), %rcx + fmul %st(2), %st + fldt (%rsi) + lea 48+_Q2(%rip), %rsi + fmul %st(4), %st + fldt (%rdi) + lea 128+_P2(%rip), %rdi + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r8) + lea 144+_P2(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r9) + lea 64+_Q2(%rip), %r9 + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt (%r10) + lea 160+_P2(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + lea 176+_P2(%rip), %r11 + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rax) + lea 80+_Q2(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%rdx) + lea _ones(%rip), %rdx + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%rcx) + lea 192+_P2(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rsi) + lea 208+_P2(%rip), %rsi + faddp %st, %st(3) + fxch %st(2) + fmul %st(4), %st + fldt (%rdi) + lea 224+_P2(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r8) + lea 240+_P2(%rip), %r8 + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(3) + fxch %st(2) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + faddp %st, %st(3) + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fxch %st(2) + fdivrl (%rdx) + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(3) + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + faddp %st, %st(2) + fmulp %st, %st(1) + jmp ..B2.19 +..B2.7: + movl $2, %edx + movl $32, %eax +..B2.8: + fldt (%rax,%rcx) + fcomip %st(1), %st + ja ..B2.11 + jp ..B2.11 +..B2.9: + incq %rdx + addq $16, %rax + cmpq $11, %rdx + jl ..B2.8 +..B2.10: + movq %rdx, %rax + shlq $4, %rax +..B2.11: + lea _Z(%rip), %rcx + fldt (%rax,%rcx) + lea (%rdx,%rdx,4), %rax + shlq $6, %rax + fsubrp %st, %st(1) + fld %st(0) + lea _P(%rip), %rdx + fmul %st(1), %st + fstpt 64(%rsp) + fldt 64(%rsp) + fldt -640(%rax,%rdx) + fmul %st(1), %st + fldt -624(%rax,%rdx) + fmul %st(2), %st + fldt -608(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -592(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -576(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -560(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -544(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -528(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -512(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -496(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -480(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -464(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -448(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -432(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -416(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -400(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -384(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt -368(%rax,%rdx) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt -352(%rax,%rdx) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt -336(%rax,%rdx) + faddp %st, %st(1) + faddp %st, %st(1) + jmp ..B2.19 +..B2.12: + fld %st(0) + lea _P0(%rip), %rax + fmul %st(1), %st + lea 16+_P0(%rip), %rdx + fxch %st(1) + fld %st(1) + lea 32+_P0(%rip), %rcx + fmul %st(2), %st + lea 48+_P0(%rip), %rsi + lea 64+_P0(%rip), %rdi + lea 80+_P0(%rip), %r8 + lea 96+_P0(%rip), %r9 + lea 112+_P0(%rip), %r10 + lea 128+_P0(%rip), %r11 + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(2) + fstpt 64(%rsp) + fldt 64(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rax) + lea 144+_P0(%rip), %rax + fmul %st(3), %st + fldt (%rdx) + fmul %st(4), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(4), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(4) + fldt (%r11) + faddp %st, %st(1) + fmulp %st, %st(2) + fldt (%rax) + faddp %st, %st(3) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%rsp) +..___tag_value___y1l.43: + call __j1l@PLT +..___tag_value___y1l.44: +..B2.23: + fldt 112(%rsp) + fldt 16(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 96 +..B2.13: + fxch %st(1) + fstl 40(%rsp) + fstp %st(0) + movsd 40(%rsp), %xmm0 + fxch %st(1) + fstpt 16(%rsp) + fstpt (%rsp) + call log@PLT +..B2.24: + fldt 96(%rsp) + lea _val_N1_0L(%rip), %rdx + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt 16(%rsp) + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fldt (%rdx) + fdivp %st, %st(4) + fxch %st(3) + faddp %st, %st(1) + fmulp %st, %st(2) + faddp %st, %st(1) + jmp ..B2.19 +..B2.14: + lea _ones(%rip), %rax + lea _val_36_0L(%rip), %rdx + lea _PP(%rip), %rcx + lea _QP(%rip), %rsi + lea 16+_PP(%rip), %rdi + lea 16+_QP(%rip), %r8 + lea 32+_PP(%rip), %r9 + lea 32+_QP(%rip), %r10 + fldl (%rax) + lea 48+_PP(%rip), %r11 + fdiv %st(1), %st + lea 48+_QP(%rip), %rax + fxch %st(1) + fxch %st(1) + fstpt (%rsp) + fldt (%rsp) + fldt (%rdx) + lea 64+_PP(%rip), %rdx + fmulp %st, %st(1) + fld %st(0) + fmul %st(1), %st + fstpt 48(%rsp) + fldt 48(%rsp) + fxch %st(1) + fstpt 64(%rsp) + fldt 64(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + fxch %st(2) + fstpt (%rsp) + fldt (%rcx) + lea 64+_QP(%rip), %rcx + fmul %st(1), %st + fldt (%rsi) + lea 80+_PP(%rip), %rsi + fmul %st(2), %st + fldt (%rdi) + lea 80+_QP(%rip), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + lea 96+_PP(%rip), %r8 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + lea 96+_QP(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + lea 112+_PP(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + lea 112+_QP(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_PP(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + lea 128+_QP(%rip), %rdx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rcx) + lea 144+_PP(%rip), %rcx + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rsi) + lea 144+_QP(%rip), %rsi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdi) + lea 80(%rsp), %rdi + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rdx) + movl $-3, %edx + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rcx) + faddp %st, %st(1) + fstpt -48(%rdi) + fldt (%rsi) + lea 64(%rsp), %rsi + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -16(%rsi) +..___tag_value___y1l.47: + call __libm_sincos_pi4l@PLT +..___tag_value___y1l.48: +..B2.25: + fldt 112(%rsp) + fldt 48(%rsp) + fldt 32(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 96 +..B2.15: + fldt 64(%rsp) + lea _val_0_03L(%rip), %rax + fmulp %st, %st(1) + fldt 48(%rsp) + fmulp %st, %st(2) + fadd %st, %st(1) + fld %st(1) + fabs + fxch %st(1) + fabs + fldt (%rax) + fmulp %st, %st(1) + fcomip %st(1), %st + fstp %st(0) + jae ..B2.17 + jp ..B2.17 +..B2.16: + fstp %st(1) + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt (%rax) + fmulp %st, %st(1) + fsqrt + fmulp %st, %st(1) + jmp ..B2.19 +..B2.17: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 112 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B2.27: + addq $16, %rsp + .cfi_def_cfa_offset 96 + movaps (%rsp), %xmm0 +..___tag_value___y1l.52: + call __y1q@PLT +..___tag_value___y1l.53: +..B2.18: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B2.28: + fstpl 40(%rsp) + movsd 40(%rsp), %xmm0 + movsd %xmm0, 32(%rsp) + fldl 32(%rsp) +..B2.19: + addq $88, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type __y1l,@function + .size __y1l,.-__y1l + .data +# -- End __y1l + .section .rodata, "a" + .align 4 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_S: + .word 56848 + .word 49844 + .word 39532 + .word 64842 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 5940 + .word 14600 + .word 60967 + .word 58048 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 48233 + .word 9194 + .word 47533 + .word 41870 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 19716 + .word 3898 + .word 3621 + .word 54727 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 41547 + .word 400 + .word 58272 + .word 33793 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 46312 + .word 65374 + .word 26362 + .word 40225 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 15253 + .word 48480 + .word 38891 + .word 46657 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 12158 + .word 16394 + .word 14239 + .word 53090 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 31253 + .word 2914 + .word 8779 + .word 59523 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 29606 + .word 9567 + .word 8455 + .word 32978 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 51148 + .word 41491 + .word 50276 + .word 36194 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 1224 + .word 58769 + .word 30330 + .word 39411 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _S,@object + .size _S,192 + .align 2 +_val_1_77L: + .word 36700 + .word 62914 + .word 23592 + .word 57999 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _val_1_77L,@object + .size _val_1_77L,16 + .align 2 +_Z: + .word 5921 + .word 65426 + .word 63142 + .word 35997 + .word 16384 + .word 0 + .word 0 + .word 0 + .word 29632 + .word 15745 + .word 62068 + .word 44479 + .word 16385 + .word 0 + .word 0 + .word 0 + .word 41288 + .word 2893 + .word 15731 + .word 35209 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 12322 + .word 41360 + .word 35270 + .word 48124 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 21828 + .word 62500 + .word 60486 + .word 61019 + .word 16386 + .word 0 + .word 0 + .word 0 + .word 54460 + .word 63729 + .word 58186 + .word 36952 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 27250 + .word 3142 + .word 10825 + .word 43393 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 20649 + .word 49414 + .word 53633 + .word 49831 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 59160 + .word 26587 + .word 26484 + .word 56269 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 57283 + .word 10561 + .word 16432 + .word 62706 + .word 16387 + .word 0 + .word 0 + .word 0 + .word 44243 + .word 51162 + .word 18495 + .word 34571 + .word 16388 + .word 0 + .word 0 + .word 0 + .word 63781 + .word 54231 + .word 15770 + .word 37789 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _Z,@object + .size _Z,192 + .align 2 +_P1: + .word 21770 + .word 62666 + .word 46899 + .word 35378 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 28454 + .word 23396 + .word 41885 + .word 48017 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 61344 + .word 9332 + .word 29378 + .word 47284 + .word 49120 + .word 0 + .word 0 + .word 0 + .word 60127 + .word 25512 + .word 35054 + .word 43181 + .word 16353 + .word 0 + .word 0 + .word 0 + .word 25808 + .word 25324 + .word 9989 + .word 53047 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 46582 + .word 21062 + .word 5476 + .word 44690 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 61332 + .word 1419 + .word 18476 + .word 34785 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 51513 + .word 63307 + .word 40855 + .word 38307 + .word 49134 + .word 0 + .word 0 + .word 0 + .word 22560 + .word 55588 + .word 5655 + .word 48627 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 56966 + .word 1018 + .word 54245 + .word 62436 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 17453 + .word 15035 + .word 65421 + .word 57312 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 53367 + .word 52143 + .word 3664 + .word 58921 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 16321 + .word 41163 + .word 52734 + .word 35978 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 15288 + .word 52738 + .word 13594 + .word 53174 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 42685 + .word 25071 + .word 48779 + .word 62301 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 7354 + .word 8216 + .word 60720 + .word 54923 + .word 49085 + .word 0 + .word 0 + .word 0 + .type _P1,@object + .size _P1,256 + .align 2 +_Q1: + .word 64227 + .word 6706 + .word 76 + .word 58690 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 8371 + .word 16695 + .word 56692 + .word 45251 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 9179 + .word 20845 + .word 29706 + .word 43997 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 44943 + .word 15045 + .word 18794 + .word 45614 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 10671 + .word 41768 + .word 56247 + .word 64663 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 25530 + .word 4231 + .word 4140 + .word 59815 + .word 16381 + .word 0 + .word 0 + .word 0 + .type _Q1,@object + .size _Q1,96 + .align 2 +_P2: + .word 42420 + .word 39002 + .word 59647 + .word 60050 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 9209 + .word 30875 + .word 32003 + .word 38109 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 63337 + .word 29381 + .word 46828 + .word 35859 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 25340 + .word 63034 + .word 61574 + .word 39960 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 21587 + .word 1531 + .word 17186 + .word 56230 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 35654 + .word 56865 + .word 61897 + .word 49746 + .word 49126 + .word 0 + .word 0 + .word 0 + .word 6701 + .word 41291 + .word 18798 + .word 55141 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 35596 + .word 2936 + .word 34861 + .word 35797 + .word 16365 + .word 0 + .word 0 + .word 0 + .word 59382 + .word 44988 + .word 46794 + .word 33373 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 39208 + .word 51898 + .word 38063 + .word 56363 + .word 49138 + .word 0 + .word 0 + .word 0 + .word 34426 + .word 35681 + .word 546 + .word 45071 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 27055 + .word 35919 + .word 19182 + .word 39238 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 11379 + .word 16934 + .word 10723 + .word 57120 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 30778 + .word 48366 + .word 51582 + .word 60462 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 38504 + .word 65531 + .word 34807 + .word 43722 + .word 49149 + .word 0 + .word 0 + .word 0 + .word 52867 + .word 16075 + .word 29885 + .word 33161 + .word 49086 + .word 0 + .word 0 + .word 0 + .type _P2,@object + .size _P2,256 + .align 2 +_Q2: + .word 24596 + .word 8363 + .word 28671 + .word 51312 + .word 16360 + .word 0 + .word 0 + .word 0 + .word 22889 + .word 23763 + .word 37225 + .word 46345 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 24119 + .word 47441 + .word 54379 + .word 48688 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 1240 + .word 59184 + .word 48701 + .word 46748 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 22888 + .word 65215 + .word 58633 + .word 45869 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 31023 + .word 50278 + .word 49158 + .word 64237 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _Q2,@object + .size _Q2,96 + .align 2 +_P: + .word 61722 + .word 43505 + .word 23994 + .word 37346 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 30291 + .word 24028 + .word 22863 + .word 34750 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 1126 + .word 901 + .word 35659 + .word 64778 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 24961 + .word 30514 + .word 59096 + .word 39096 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 35564 + .word 61687 + .word 10716 + .word 35707 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 46848 + .word 13986 + .word 10777 + .word 37699 + .word 49111 + .word 0 + .word 0 + .word 0 + .word 25983 + .word 4211 + .word 22533 + .word 63008 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 41622 + .word 55080 + .word 16927 + .word 53017 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 59504 + .word 42891 + .word 54413 + .word 41203 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 12571 + .word 13616 + .word 30559 + .word 53698 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 24504 + .word 22188 + .word 22875 + .word 38390 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 45455 + .word 51567 + .word 14687 + .word 35767 + .word 16364 + .word 0 + .word 0 + .word 0 + .word 2489 + .word 10124 + .word 54664 + .word 47037 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 18722 + .word 39166 + .word 48910 + .word 55942 + .word 49137 + .word 0 + .word 0 + .word 0 + .word 52167 + .word 5 + .word 15467 + .word 33747 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 64650 + .word 13451 + .word 38167 + .word 40566 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 40279 + .word 20454 + .word 61426 + .word 45514 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 34995 + .word 30989 + .word 51614 + .word 33113 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 57629 + .word 30042 + .word 51710 + .word 35580 + .word 16381 + .word 0 + .word 0 + .word 0 + .word 22801 + .word 35092 + .word 8589 + .word 55177 + .word 16319 + .word 0 + .word 0 + .word 0 + .word 18213 + .word 9889 + .word 16490 + .word 42684 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 35117 + .word 3709 + .word 30056 + .word 56315 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 23979 + .word 26668 + .word 51699 + .word 63315 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 37328 + .word 63574 + .word 8303 + .word 34466 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 46391 + .word 17329 + .word 18036 + .word 35570 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 30054 + .word 21312 + .word 25061 + .word 63482 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 2570 + .word 34880 + .word 30954 + .word 61846 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 48934 + .word 61799 + .word 17650 + .word 43599 + .word 49118 + .word 0 + .word 0 + .word 0 + .word 9996 + .word 54252 + .word 12364 + .word 40067 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 26028 + .word 41231 + .word 49512 + .word 42301 + .word 16357 + .word 0 + .word 0 + .word 0 + .word 36582 + .word 15370 + .word 8472 + .word 36675 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 63654 + .word 5080 + .word 49106 + .word 53579 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 31057 + .word 54537 + .word 2640 + .word 43916 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 21142 + .word 46896 + .word 24614 + .word 39087 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 3964 + .word 40668 + .word 52365 + .word 60967 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 39332 + .word 9457 + .word 22878 + .word 52919 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 54210 + .word 18213 + .word 48816 + .word 39742 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 59971 + .word 56061 + .word 65402 + .word 41492 + .word 16376 + .word 0 + .word 0 + .word 0 + .word 50867 + .word 29775 + .word 29962 + .word 60938 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 39008 + .word 10804 + .word 60432 + .word 53771 + .word 49083 + .word 0 + .word 0 + .word 0 + .word 8797 + .word 29964 + .word 61128 + .word 42619 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 49667 + .word 64253 + .word 56687 + .word 49119 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 12708 + .word 20574 + .word 59517 + .word 62457 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 61123 + .word 30114 + .word 53775 + .word 59072 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 12480 + .word 24376 + .word 40478 + .word 34829 + .word 49108 + .word 0 + .word 0 + .word 0 + .word 31610 + .word 2541 + .word 29797 + .word 53230 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 57351 + .word 51530 + .word 20151 + .word 60005 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 27929 + .word 50140 + .word 46261 + .word 35597 + .word 16350 + .word 0 + .word 0 + .word 0 + .word 13266 + .word 42539 + .word 17988 + .word 38413 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 60482 + .word 30188 + .word 54757 + .word 33461 + .word 49125 + .word 0 + .word 0 + .word 0 + .word 28412 + .word 55589 + .word 45206 + .word 34637 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 32067 + .word 62816 + .word 60815 + .word 40858 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 5401 + .word 9100 + .word 50782 + .word 40732 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 54621 + .word 58390 + .word 59249 + .word 57428 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 35825 + .word 1375 + .word 322 + .word 55483 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 16432 + .word 16110 + .word 8852 + .word 37720 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 5000 + .word 34131 + .word 51425 + .word 35608 + .word 49146 + .word 0 + .word 0 + .word 0 + .word 53929 + .word 6276 + .word 23388 + .word 58152 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 51579 + .word 17004 + .word 5616 + .word 54145 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 7103 + .word 16103 + .word 63732 + .word 61608 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 53540 + .word 14563 + .word 28490 + .word 42103 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 50538 + .word 7801 + .word 54621 + .word 42667 + .word 16326 + .word 0 + .word 0 + .word 0 + .word 21289 + .word 53272 + .word 50234 + .word 61084 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 53615 + .word 53374 + .word 57363 + .word 50528 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 54514 + .word 9539 + .word 36475 + .word 33817 + .word 16340 + .word 0 + .word 0 + .word 0 + .word 31658 + .word 4746 + .word 1163 + .word 44700 + .word 16342 + .word 0 + .word 0 + .word 0 + .word 52867 + .word 45166 + .word 52684 + .word 57761 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 48341 + .word 5188 + .word 19803 + .word 58551 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 18455 + .word 50865 + .word 10646 + .word 36603 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 16819 + .word 38651 + .word 15489 + .word 53797 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 57587 + .word 29612 + .word 6330 + .word 65256 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 60926 + .word 53369 + .word 5356 + .word 64182 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 26295 + .word 42515 + .word 37715 + .word 37910 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 26848 + .word 34589 + .word 11687 + .word 44170 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 52547 + .word 41404 + .word 29188 + .word 51071 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 59720 + .word 37814 + .word 50864 + .word 57112 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 63754 + .word 1059 + .word 28610 + .word 65011 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 48135 + .word 53252 + .word 54091 + .word 43638 + .word 16375 + .word 0 + .word 0 + .word 0 + .word 14971 + .word 8471 + .word 3609 + .word 49212 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 4052 + .word 57147 + .word 31484 + .word 54446 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 11824 + .word 2112 + .word 5588 + .word 41288 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 30937 + .word 56824 + .word 10791 + .word 37103 + .word 49094 + .word 0 + .word 0 + .word 0 + .word 13479 + .word 25038 + .word 44704 + .word 59408 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 6837 + .word 41457 + .word 42451 + .word 43375 + .word 16334 + .word 0 + .word 0 + .word 0 + .word 53800 + .word 46435 + .word 51001 + .word 65352 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 15811 + .word 55852 + .word 5902 + .word 37814 + .word 49110 + .word 0 + .word 0 + .word 0 + .word 19663 + .word 64639 + .word 1883 + .word 55408 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 5332 + .word 44968 + .word 15414 + .word 48765 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 24635 + .word 46043 + .word 59114 + .word 34832 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 15088 + .word 55241 + .word 15044 + .word 44102 + .word 49124 + .word 0 + .word 0 + .word 0 + .word 6405 + .word 38383 + .word 37570 + .word 61587 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 22931 + .word 45450 + .word 10147 + .word 51835 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 64299 + .word 50831 + .word 27180 + .word 35495 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 23200 + .word 7806 + .word 1364 + .word 35222 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 45807 + .word 4679 + .word 55327 + .word 47491 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 30764 + .word 65323 + .word 55387 + .word 45120 + .word 16372 + .word 0 + .word 0 + .word 0 + .word 15039 + .word 21256 + .word 11217 + .word 60156 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 57173 + .word 14361 + .word 2624 + .word 34299 + .word 49143 + .word 0 + .word 0 + .word 0 + .word 56410 + .word 62508 + .word 42699 + .word 45420 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 50446 + .word 42024 + .word 63781 + .word 38435 + .word 49087 + .word 0 + .word 0 + .word 0 + .word 10333 + .word 60348 + .word 17128 + .word 40300 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 43838 + .word 25371 + .word 62467 + .word 64794 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 26845 + .word 6377 + .word 43437 + .word 57595 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 7442 + .word 5283 + .word 26036 + .word 37481 + .word 49102 + .word 0 + .word 0 + .word 0 + .word 15454 + .word 29184 + .word 54291 + .word 63010 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 5297 + .word 38874 + .word 4456 + .word 64615 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 12966 + .word 61910 + .word 53167 + .word 53110 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 20395 + .word 4102 + .word 12283 + .word 41188 + .word 49117 + .word 0 + .word 0 + .word 0 + .word 19094 + .word 29300 + .word 12828 + .word 33187 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 28120 + .word 22694 + .word 2680 + .word 36839 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 25698 + .word 43431 + .word 60429 + .word 58329 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 59006 + .word 57475 + .word 62067 + .word 42866 + .word 49130 + .word 0 + .word 0 + .word 0 + .word 60088 + .word 17714 + .word 44332 + .word 33435 + .word 16368 + .word 0 + .word 0 + .word 0 + .word 3844 + .word 12917 + .word 11965 + .word 57777 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 17310 + .word 43236 + .word 29566 + .word 44535 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 38891 + .word 11594 + .word 35001 + .word 36788 + .word 49140 + .word 0 + .word 0 + .word 0 + .word 62784 + .word 19866 + .word 27725 + .word 56232 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 26552 + .word 62874 + .word 50518 + .word 55747 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 41449 + .word 54733 + .word 7288 + .word 42389 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 25436 + .word 16965 + .word 21076 + .word 40960 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 39083 + .word 3258 + .word 61438 + .word 39229 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 62602 + .word 12963 + .word 51303 + .word 56904 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 41532 + .word 46799 + .word 27449 + .word 55757 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 25508 + .word 35836 + .word 14539 + .word 65290 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 34796 + .word 56106 + .word 58112 + .word 60724 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 52331 + .word 50671 + .word 56071 + .word 55789 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 50430 + .word 49256 + .word 15625 + .word 50948 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 15753 + .word 56169 + .word 3376 + .word 35261 + .word 16349 + .word 0 + .word 0 + .word 0 + .word 47489 + .word 43658 + .word 29070 + .word 63380 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 14447 + .word 45157 + .word 5 + .word 62576 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 14392 + .word 17120 + .word 59854 + .word 55457 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 2389 + .word 54610 + .word 7938 + .word 36154 + .word 16362 + .word 0 + .word 0 + .word 0 + .word 24225 + .word 54966 + .word 22944 + .word 63335 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 6246 + .word 36346 + .word 2616 + .word 48455 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 61678 + .word 13662 + .word 7713 + .word 42050 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 4329 + .word 54820 + .word 31411 + .word 61458 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 48026 + .word 57812 + .word 53661 + .word 52979 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 47545 + .word 24071 + .word 10224 + .word 46463 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 51405 + .word 19517 + .word 26454 + .word 39893 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 2714 + .word 52847 + .word 64285 + .word 36922 + .word 49088 + .word 0 + .word 0 + .word 0 + .word 51895 + .word 36793 + .word 33802 + .word 38136 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 2488 + .word 31490 + .word 30800 + .word 50300 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 13623 + .word 29920 + .word 59063 + .word 53960 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 4071 + .word 44015 + .word 56417 + .word 57333 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 57861 + .word 52773 + .word 20389 + .word 58553 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 64934 + .word 37948 + .word 51829 + .word 48662 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 56954 + .word 19807 + .word 167 + .word 48948 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 28104 + .word 12997 + .word 51038 + .word 61119 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 3409 + .word 4305 + .word 3650 + .word 60679 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 43193 + .word 24597 + .word 44129 + .word 53916 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 17521 + .word 14667 + .word 10096 + .word 52923 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 55445 + .word 18677 + .word 32228 + .word 61988 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 19057 + .word 4855 + .word 59096 + .word 60271 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 13479 + .word 55645 + .word 42570 + .word 41372 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 1282 + .word 28535 + .word 31957 + .word 39927 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 572 + .word 61602 + .word 36341 + .word 52326 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 28923 + .word 3577 + .word 27552 + .word 50228 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 55167 + .word 15365 + .word 46318 + .word 39497 + .word 16374 + .word 0 + .word 0 + .word 0 + .word 19602 + .word 36437 + .word 16591 + .word 37792 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 46605 + .word 39778 + .word 56315 + .word 52295 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 30298 + .word 45364 + .word 48554 + .word 37056 + .word 49091 + .word 0 + .word 0 + .word 0 + .word 36916 + .word 47157 + .word 55353 + .word 44757 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 36754 + .word 52515 + .word 12207 + .word 52242 + .word 16331 + .word 0 + .word 0 + .word 0 + .word 22625 + .word 1809 + .word 14640 + .word 50749 + .word 16333 + .word 0 + .word 0 + .word 0 + .word 16563 + .word 52625 + .word 13365 + .word 56520 + .word 49107 + .word 0 + .word 0 + .word 0 + .word 27329 + .word 9102 + .word 21835 + .word 42848 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 25313 + .word 26147 + .word 37973 + .word 47112 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 62093 + .word 47762 + .word 2878 + .word 53553 + .word 16348 + .word 0 + .word 0 + .word 0 + .word 45304 + .word 46632 + .word 22697 + .word 58245 + .word 49122 + .word 0 + .word 0 + .word 0 + .word 52304 + .word 22429 + .word 48300 + .word 47033 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 1240 + .word 8778 + .word 3434 + .word 50676 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 64382 + .word 35832 + .word 24068 + .word 53872 + .word 16361 + .word 0 + .word 0 + .word 0 + .word 9372 + .word 49794 + .word 11542 + .word 57592 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 29118 + .word 43193 + .word 8003 + .word 35849 + .word 49135 + .word 0 + .word 0 + .word 0 + .word 3582 + .word 16932 + .word 42429 + .word 38089 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 26846 + .word 61869 + .word 11277 + .word 45246 + .word 16371 + .word 0 + .word 0 + .word 0 + .word 12490 + .word 64508 + .word 30037 + .word 47862 + .word 49145 + .word 0 + .word 0 + .word 0 + .word 36625 + .word 65383 + .word 13633 + .word 34114 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 6011 + .word 54183 + .word 37651 + .word 35991 + .word 16380 + .word 0 + .word 0 + .word 0 + .word 43024 + .word 51442 + .word 35220 + .word 35244 + .word 16321 + .word 0 + .word 0 + .word 0 + .word 2338 + .word 9974 + .word 58099 + .word 36011 + .word 16323 + .word 0 + .word 0 + .word 0 + .word 54231 + .word 56678 + .word 56840 + .word 40082 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 47406 + .word 57592 + .word 65286 + .word 50617 + .word 49099 + .word 0 + .word 0 + .word 0 + .word 15992 + .word 46142 + .word 20381 + .word 45257 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 17722 + .word 6937 + .word 55940 + .word 54630 + .word 16339 + .word 0 + .word 0 + .word 0 + .word 44953 + .word 7303 + .word 1203 + .word 38053 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 9155 + .word 41724 + .word 2745 + .word 45433 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 23208 + .word 13836 + .word 51920 + .word 47377 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 46053 + .word 58453 + .word 7516 + .word 56049 + .word 16354 + .word 0 + .word 0 + .word 0 + .word 51100 + .word 31216 + .word 1872 + .word 41469 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 24653 + .word 32384 + .word 37643 + .word 48672 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 61101 + .word 35176 + .word 37213 + .word 47362 + .word 49129 + .word 0 + .word 0 + .word 0 + .word 62301 + .word 22066 + .word 41591 + .word 55226 + .word 16367 + .word 0 + .word 0 + .word 0 + .word 37791 + .word 15476 + .word 41140 + .word 62892 + .word 16366 + .word 0 + .word 0 + .word 0 + .word 18919 + .word 33505 + .word 35758 + .word 36479 + .word 49141 + .word 0 + .word 0 + .word 0 + .word 58610 + .word 16753 + .word 52674 + .word 39626 + .word 49139 + .word 0 + .word 0 + .word 0 + .word 19653 + .word 21667 + .word 11428 + .word 45800 + .word 16377 + .word 0 + .word 0 + .word 0 + .word 51212 + .word 10491 + .word 15737 + .word 59703 + .word 16373 + .word 0 + .word 0 + .word 0 + .word 54759 + .word 31668 + .word 63308 + .word 34425 + .word 49148 + .word 0 + .word 0 + .word 0 + .word 62523 + .word 11996 + .word 50486 + .word 33912 + .word 49089 + .word 0 + .word 0 + .word 0 + .type _P,@object + .size _P,3200 + .align 2 +_P0: + .word 10891 + .word 2847 + .word 4043 + .word 50135 + .word 16324 + .word 0 + .word 0 + .word 0 + .word 8878 + .word 10523 + .word 36094 + .word 35357 + .word 49101 + .word 0 + .word 0 + .word 0 + .word 12191 + .word 2098 + .word 38631 + .word 38182 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 58416 + .word 39431 + .word 6152 + .word 63591 + .word 49116 + .word 0 + .word 0 + .word 0 + .word 18600 + .word 1852 + .word 53867 + .word 39282 + .word 16356 + .word 0 + .word 0 + .word 0 + .word 37377 + .word 45824 + .word 1379 + .word 34108 + .word 49131 + .word 0 + .word 0 + .word 0 + .word 58815 + .word 28468 + .word 57342 + .word 38462 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 35703 + .word 42482 + .word 52164 + .word 49581 + .word 49142 + .word 0 + .word 0 + .word 0 + .word 14326 + .word 44453 + .word 47843 + .word 56988 + .word 16378 + .word 0 + .word 0 + .word 0 + .word 21045 + .word 58852 + .word 12449 + .word 51395 + .word 49148 + .word 0 + .word 0 + .word 0 + .type _P0,@object + .size _P0,160 + .align 2 +_val_N1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _val_N1_0L,@object + .size _val_N1_0L,16 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _tonpi,@object + .size _tonpi,16 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,16 + .align 2 +_PP: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 0 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 0 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP,@object + .size _PP,160 + .align 2 +_QP: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _QP,@object + .size _QP,160 + .align 2 +_val_0_03L: + .word 49807 + .word 10485 + .word 36700 + .word 62914 + .word 16377 + .word 0 + .word 0 + .word 0 + .type _val_0_03L,@object + .size _val_0_03L,16 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/y1f.S b/external/sgx_libm/intel64/y1f.S new file mode 100644 index 0000000000..f9d2339cfc --- /dev/null +++ b/external/sgx_libm/intel64/y1f.S @@ -0,0 +1,921 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y1f.c" + .text +..TXTST0: +# -- Begin y1f + .text + .align 16,0x90 + .globl y1f +y1f: +# parameter 1: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_y1f.1: +..L2: + + subq $56, %rsp + .cfi_def_cfa_offset 64 + movd %xmm0, %edx + movss %xmm0, 48(%rsp) + lea -1(%rdx), %eax + cmpl $2139095039, %eax + jae ..B1.17 +..B1.2: + cmpl $1100816743, %edx + jae ..B1.25 +..B1.3: + cmpl $1099170276, %edx + jae ..B1.16 +..B1.4: + cmpl $1096140558, %edx + jae ..B1.15 +..B1.5: + cmpl $1092849338, %edx + jae ..B1.14 +..B1.6: + cmpl $1088602350, %edx + jae ..B1.13 +..B1.7: + cmpl $1081952922, %edx + jae ..B1.12 +..B1.8: + cmpl $1071812444, %edx + jb ..B1.10 +..B1.9: + cvtss2sd %xmm0, %xmm0 + lea 128+_P1(%rip), %rax + lea 120+_P1(%rip), %rdx + lea 88+_P1(%rip), %rcx + lea 56+_P1(%rip), %rsi + lea 104+_P1(%rip), %r8 + lea 24+_P1(%rip), %rdi + lea 72+_P1(%rip), %r9 + lea 40+_P1(%rip), %r10 + movsd (%rdx), %xmm6 + lea 80+_P1(%rip), %rdx + lea 8+_P1(%rip), %r11 + subsd (%rax), %xmm0 + movaps %xmm0, %xmm2 + lea 112+_P1(%rip), %rax + mulsd %xmm0, %xmm2 + movaps %xmm2, %xmm3 + mulsd %xmm2, %xmm3 + mulsd %xmm3, %xmm6 + movsd (%r8), %xmm1 + lea 64+_P1(%rip), %r8 + movsd (%rax), %xmm5 + mulsd %xmm3, %xmm1 + addsd (%rcx), %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd (%r9), %xmm1 + addsd (%rdx), %xmm5 + mulsd %xmm3, %xmm1 + addsd (%rsi), %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd (%r10), %xmm1 + lea 48+_P1(%rip), %rcx + lea 32+_P1(%rip), %r9 + mulsd %xmm3, %xmm1 + addsd (%rdi), %xmm6 + addsd (%rcx), %xmm5 + mulsd %xmm2, %xmm6 + addsd (%r11), %xmm1 + mulsd %xmm3, %xmm5 + mulsd %xmm0, %xmm6 + mulsd %xmm0, %xmm1 + lea 96+_P1(%rip), %rdi + lea 16+_P1(%rip), %rsi + lea _P1(%rip), %r10 + addsd %xmm1, %xmm6 + addsd (%rsi), %xmm5 + movsd (%rdi), %xmm4 + mulsd %xmm3, %xmm4 + mulsd %xmm2, %xmm5 + addsd (%r8), %xmm4 + mulsd %xmm3, %xmm4 + addsd (%r9), %xmm4 + mulsd %xmm3, %xmm4 + addsd (%r10), %xmm4 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.10: + pxor %xmm4, %xmm4 + cvtss2sd 48(%rsp), %xmm4 + movaps %xmm4, %xmm0 + movsd %xmm4, (%rsp) +..___tag_value_y1f.6: + call __libm_log_k32@PLT +..___tag_value_y1f.7: +..B1.29: + movsd (%rsp), %xmm4 +..B1.11: + lea _tonpi(%rip), %rax + movaps %xmm4, %xmm2 + mulsd %xmm4, %xmm2 + lea 40+_Q2(%rip), %r10 + movsd (%rax), %xmm7 + movaps %xmm2, %xmm3 + mulsd %xmm7, %xmm0 + lea 40+_Q1(%rip), %rdx + divsd %xmm4, %xmm7 + mulsd %xmm2, %xmm3 + lea 24+_Q2(%rip), %r11 + movsd (%r10), %xmm6 + lea 24+_Q1(%rip), %rcx + movsd (%rdx), %xmm8 + lea 32+_Q2(%rip), %rdx + mulsd %xmm3, %xmm6 + lea 32+_Q1(%rip), %rdi + mulsd %xmm3, %xmm8 + addsd (%r11), %xmm6 + addsd (%rcx), %xmm8 + mulsd %xmm3, %xmm6 + mulsd %xmm3, %xmm8 + movsd (%rdx), %xmm5 + lea 16+_Q2(%rip), %rcx + mulsd %xmm3, %xmm5 + lea 8+_Q2(%rip), %rax + addsd (%rax), %xmm6 + addsd (%rcx), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm3, %xmm5 + mulsd %xmm4, %xmm6 + lea 8+_Q1(%rip), %rsi + lea 16+_Q1(%rip), %r8 + movsd (%rdi), %xmm1 + lea _Q1(%rip), %r9 + mulsd %xmm3, %xmm1 + addsd (%rsi), %xmm8 + addsd (%r8), %xmm1 + mulsd %xmm2, %xmm8 + mulsd %xmm3, %xmm1 + mulsd %xmm4, %xmm8 + addsd (%r9), %xmm1 + lea _Q2(%rip), %rsi + mulsd %xmm4, %xmm1 + addsd (%rsi), %xmm5 + addsd %xmm1, %xmm8 + mulsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + mulsd %xmm6, %xmm0 + subsd %xmm7, %xmm0 + addsd %xmm0, %xmm8 + cvtsd2ss %xmm8, %xmm8 + movaps %xmm8, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.12: + pxor %xmm0, %xmm0 + lea 112+_P2(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + lea 104+_P2(%rip), %rdx + lea 72+_P2(%rip), %rcx + lea 40+_P2(%rip), %rsi + lea 88+_P2(%rip), %r8 + lea 96+_P2(%rip), %r11 + lea 56+_P2(%rip), %r9 + lea 8+_P2(%rip), %rdi + lea 24+_P2(%rip), %r10 + movsd (%rdx), %xmm6 + lea 32+_P2(%rip), %rdx + movsd (%r8), %xmm1 + lea 16+_P2(%rip), %r8 + movsd (%r11), %xmm5 + subsd (%rax), %xmm0 + lea 64+_P2(%rip), %rax + movaps %xmm0, %xmm3 + mulsd %xmm0, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rcx), %xmm6 + addsd (%r9), %xmm1 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rsi), %xmm6 + addsd (%r10), %xmm1 + addsd (%rdx), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rdi), %xmm6 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm6 + lea 80+_P2(%rip), %rsi + lea 48+_P2(%rip), %rdi + lea _P2(%rip), %rcx + addsd %xmm1, %xmm6 + addsd (%rcx), %xmm5 + movsd (%rsi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rdi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%r8), %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.13: + pxor %xmm3, %xmm3 + lea 104+_P3(%rip), %rax + cvtss2sd 48(%rsp), %xmm3 + lea 96+_P3(%rip), %rdx + lea 64+_P3(%rip), %rcx + lea 80+_P3(%rip), %rdi + lea 88+_P3(%rip), %r11 + lea 48+_P3(%rip), %r8 + lea 32+_P3(%rip), %rsi + lea 16+_P3(%rip), %r9 + lea _P3(%rip), %r10 + movsd (%rdx), %xmm6 + lea 24+_P3(%rip), %rdx + movsd (%rdi), %xmm0 + lea 8+_P3(%rip), %rdi + movsd (%r11), %xmm5 + subsd (%rax), %xmm3 + lea 56+_P3(%rip), %rax + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd (%rcx), %xmm6 + addsd (%r8), %xmm0 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd (%rsi), %xmm6 + addsd (%r9), %xmm0 + addsd (%rdx), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + addsd %xmm0, %xmm6 + mulsd %xmm3, %xmm5 + addsd (%r10), %xmm6 + lea 72+_P3(%rip), %rcx + lea 40+_P3(%rip), %rsi + movsd (%rcx), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rsi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rdi), %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.14: + pxor %xmm0, %xmm0 + lea 112+_P4(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + lea 104+_P4(%rip), %rdx + lea 72+_P4(%rip), %rcx + lea 40+_P4(%rip), %rsi + lea 88+_P4(%rip), %r8 + lea 96+_P4(%rip), %r11 + lea 56+_P4(%rip), %r9 + lea 8+_P4(%rip), %rdi + lea 24+_P4(%rip), %r10 + movsd (%rdx), %xmm6 + lea 32+_P4(%rip), %rdx + movsd (%r8), %xmm1 + lea 16+_P4(%rip), %r8 + movsd (%r11), %xmm5 + subsd (%rax), %xmm0 + lea 64+_P4(%rip), %rax + movaps %xmm0, %xmm3 + mulsd %xmm0, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rcx), %xmm6 + addsd (%r9), %xmm1 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rsi), %xmm6 + addsd (%r10), %xmm1 + addsd (%rdx), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rdi), %xmm6 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm6 + lea 80+_P4(%rip), %rsi + lea 48+_P4(%rip), %rdi + lea _P4(%rip), %rcx + addsd %xmm1, %xmm6 + addsd (%rcx), %xmm5 + movsd (%rsi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rdi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%r8), %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.15: + pxor %xmm3, %xmm3 + lea 104+_P5(%rip), %rax + cvtss2sd 48(%rsp), %xmm3 + lea 96+_P5(%rip), %rdx + lea 64+_P5(%rip), %rcx + lea 80+_P5(%rip), %rdi + lea 88+_P5(%rip), %r11 + lea 48+_P5(%rip), %r8 + lea 32+_P5(%rip), %rsi + lea 16+_P5(%rip), %r9 + lea _P5(%rip), %r10 + movsd (%rdx), %xmm6 + lea 24+_P5(%rip), %rdx + movsd (%rdi), %xmm0 + lea 8+_P5(%rip), %rdi + movsd (%r11), %xmm5 + subsd (%rax), %xmm3 + lea 56+_P5(%rip), %rax + movaps %xmm3, %xmm1 + mulsd %xmm3, %xmm1 + movaps %xmm1, %xmm2 + mulsd %xmm1, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd (%rcx), %xmm6 + addsd (%r8), %xmm0 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm0 + mulsd %xmm2, %xmm5 + addsd (%rsi), %xmm6 + addsd (%r9), %xmm0 + addsd (%rdx), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm1, %xmm0 + mulsd %xmm1, %xmm5 + addsd %xmm0, %xmm6 + mulsd %xmm3, %xmm5 + addsd (%r10), %xmm6 + lea 72+_P5(%rip), %rcx + lea 40+_P5(%rip), %rsi + movsd (%rcx), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rsi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rdi), %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.16: + pxor %xmm0, %xmm0 + lea 112+_P6(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + lea 104+_P6(%rip), %rdx + lea 72+_P6(%rip), %rcx + lea 40+_P6(%rip), %rsi + lea 88+_P6(%rip), %r8 + lea 96+_P6(%rip), %r11 + lea 56+_P6(%rip), %r9 + lea 8+_P6(%rip), %rdi + lea 24+_P6(%rip), %r10 + movsd (%rdx), %xmm6 + lea 32+_P6(%rip), %rdx + movsd (%r8), %xmm1 + lea 16+_P6(%rip), %r8 + movsd (%r11), %xmm5 + subsd (%rax), %xmm0 + lea 64+_P6(%rip), %rax + movaps %xmm0, %xmm3 + mulsd %xmm0, %xmm3 + movaps %xmm3, %xmm2 + mulsd %xmm3, %xmm2 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rcx), %xmm6 + addsd (%r9), %xmm1 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm2, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rsi), %xmm6 + addsd (%r10), %xmm1 + addsd (%rdx), %xmm5 + mulsd %xmm2, %xmm6 + mulsd %xmm3, %xmm1 + mulsd %xmm2, %xmm5 + addsd (%rdi), %xmm6 + mulsd %xmm0, %xmm1 + mulsd %xmm0, %xmm6 + lea 80+_P6(%rip), %rsi + lea 48+_P6(%rip), %rdi + lea _P6(%rip), %rcx + addsd %xmm1, %xmm6 + addsd (%rcx), %xmm5 + movsd (%rsi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%rdi), %xmm4 + mulsd %xmm2, %xmm4 + addsd (%r8), %xmm4 + mulsd %xmm3, %xmm4 + addsd %xmm4, %xmm5 + addsd %xmm5, %xmm6 + cvtsd2ss %xmm6, %xmm6 + movaps %xmm6, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.17: + movl %edx, %eax + andl $2147483647, %eax + cmpl $2139095040, %eax + ja ..B1.24 +..B1.18: + testl %eax, %eax + je ..B1.23 +..B1.19: + testl $-2147483648, %edx + pxor %xmm0, %xmm0 + je ..B1.22 +..B1.20: + movss .L_2il0floatpacket.1(%rip), %xmm1 + mulss %xmm1, %xmm0 +..B1.22: + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.23: + movss .L_2il0floatpacket.0(%rip), %xmm0 + pxor %xmm1, %xmm1 + divss %xmm1, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.24: + movss 48(%rsp), %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 64 +..B1.25: + pxor %xmm0, %xmm0 + lea _val_16_0(%rip), %rax + cvtss2sd 48(%rsp), %xmm0 + movsd .L_2il0floatpacket.2(%rip), %xmm1 + lea (%rsp), %rdi + divsd %xmm0, %xmm1 + movsd (%rax), %xmm2 + lea 8(%rsp), %rsi + mulsd %xmm1, %xmm2 + movl $-3, %edx + movsd %xmm2, 8(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm2, 24(%rsi) + mulsd %xmm2, %xmm2 + movsd %xmm1, 16(%rsi) + movsd %xmm2, 32(%rsi) +..___tag_value_y1f.26: + call __libm_sincos_k32@PLT +..___tag_value_y1f.27: +..B1.26: + lea 40+_QP(%rip), %r10 + lea 40+_PP(%rip), %rdx + movsd 40(%rsp), %xmm2 + lea 24+_QP(%rip), %r11 + lea 24+_PP(%rip), %rcx + lea 32+_PP(%rip), %rdi + lea _tonpi(%rip), %rax + lea 16+_PP(%rip), %r8 + movsd (%r10), %xmm5 + lea 8+_PP(%rip), %rsi + movsd (%rdx), %xmm6 + lea 32+_QP(%rip), %rdx + mulsd %xmm2, %xmm5 + lea _PP(%rip), %r9 + mulsd %xmm2, %xmm6 + addsd (%r11), %xmm5 + addsd (%rcx), %xmm6 + mulsd %xmm2, %xmm5 + mulsd %xmm2, %xmm6 + movsd (%rdx), %xmm4 + lea 16+_QP(%rip), %rcx + mulsd %xmm2, %xmm4 + addsd (%rsi), %xmm6 + movsd (%rdi), %xmm1 + lea _QP(%rip), %rsi + mulsd %xmm2, %xmm1 + addsd (%rcx), %xmm4 + movsd (%rax), %xmm0 + lea 8+_QP(%rip), %rax + mulsd %xmm2, %xmm4 + addsd (%r8), %xmm1 + mulsd 24(%rsp), %xmm0 + addsd (%rax), %xmm5 + mulsd %xmm2, %xmm1 + addsd (%rsi), %xmm4 + sqrtsd %xmm0, %xmm0 + addsd (%r9), %xmm1 + movsd 32(%rsp), %xmm3 + mulsd %xmm3, %xmm5 + mulsd %xmm3, %xmm6 + addsd %xmm4, %xmm5 + addsd %xmm1, %xmm6 + mulsd 16(%rsp), %xmm5 + mulsd (%rsp), %xmm6 + mulsd 8(%rsp), %xmm5 + addsd %xmm5, %xmm6 + mulsd %xmm6, %xmm0 + cvtsd2ss %xmm0, %xmm0 + addq $56, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type y1f,@function + .size y1f,.-y1f + .data +# -- End y1f + .section .rodata, "a" + .align 8 + .align 8 +.L_2il0floatpacket.2: + .long 0x00000000,0x3ff00000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,8 + .align 4 +.L_2il0floatpacket.0: + .long 0xbf800000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x7f800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +_P1: + .long 3588334709 + .long 1014823416 + .long 1143617537 + .long 1071688264 + .long 543393268 + .long 3216922360 + .long 1079832790 + .long 3214987951 + .long 1415988155 + .long 3212027618 + .long 2493495630 + .long 1065248537 + .long 1666720954 + .long 3211084359 + .long 543676354 + .long 1062304274 + .long 4191589146 + .long 3208689738 + .long 2170605073 + .long 1060053158 + .long 3542706363 + .long 3206309752 + .long 3704389215 + .long 1057513307 + .long 2063423420 + .long 3203511534 + .long 3202091398 + .long 1054023270 + .long 2674374220 + .long 3198818668 + .long 2780141937 + .long 1047561374 + .long 3571446339 + .long 1073845182 + .type _P1,@object + .size _P1,136 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_Q2: + .long 4294700894 + .long 1071644671 + .long 4245872852 + .long 3215982591 + .long 2793978972 + .long 1063605588 + .long 1731774639 + .long 3205263755 + .long 824990963 + .long 1051113520 + .long 1573521749 + .long 3191272273 + .type _Q2,@object + .size _Q2,48 + .align 4 +_Q1: + .long 330682653 + .long 3217627238 + .long 1311559603 + .long 1068225431 + .long 1711886415 + .long 3211277751 + .long 3301707240 + .long 1058195349 + .long 1381458166 + .long 3199245881 + .long 361785213 + .long 1044511851 + .type _Q1,@object + .size _Q1,48 + .align 4 +_P2: + .long 2989758108 + .long 1017408064 + .long 1458640109 + .long 3218458565 + .long 2240523794 + .long 1067453343 + .long 773815536 + .long 1068111321 + .long 2743923681 + .long 3211856434 + .long 3232814431 + .long 3210853997 + .long 2451601872 + .long 1059272649 + .long 1805313442 + .long 1057512342 + .long 1838988672 + .long 3200779931 + .long 3139341808 + .long 3198309937 + .long 844655003 + .long 1046186753 + .long 3216852589 + .long 1043859826 + .long 2659303056 + .long 3187506951 + .long 2880143704 + .long 1034033463 + .long 1317515310 + .long 1075165182 + .type _P2,@object + .size _P2,120 + .align 4 +_P3: + .long 280256326 + .long 3163962304 + .long 1070207352 + .long 1070686105 + .long 878012560 + .long 3213896505 + .long 4238571140 + .long 3215341917 + .long 3113338666 + .long 1063505618 + .long 910161668 + .long 1063287399 + .long 1478416875 + .long 3206238429 + .long 3015160168 + .long 3204904859 + .long 3974776004 + .long 1052866426 + .long 579855125 + .long 1050851686 + .long 261378128 + .long 3193590641 + .long 798233178 + .long 3191027115 + .long 1498363474 + .long 1038832298 + .long 2925619636 + .long 1075917095 + .type _P3,@object + .size _P3,112 + .align 4 +_P4: + .long 738390343 + .long 1012897491 + .long 2706267969 + .long 3217932622 + .long 4014538048 + .long 1065632415 + .long 3590329970 + .long 1067673559 + .long 671215353 + .long 3210335979 + .long 2374781669 + .long 3210593529 + .long 1890699418 + .long 1058215403 + .long 1890155166 + .long 1057321344 + .long 1713507622 + .long 3199871308 + .long 2862637523 + .long 3198281783 + .long 1122846306 + .long 1045733660 + .long 622299794 + .long 1043564297 + .long 2771483851 + .long 3185854918 + .long 1632198108 + .long 3183235242 + .long 953430534 + .long 1076330385 + .type _P4,@object + .size _P4,120 + .align 4 +_P5: + .long 342107947 + .long 1017254688 + .long 3187585117 + .long 1070231586 + .long 1823227594 + .long 3212600587 + .long 444207028 + .long 3215024921 + .long 1802122913 + .long 1062365956 + .long 1966738039 + .long 1062934367 + .long 3649894624 + .long 3205237410 + .long 1726294277 + .long 3204703097 + .long 1880085380 + .long 1051980794 + .long 1949762981 + .long 1050731607 + .long 2695921962 + .long 3192939649 + .long 1096030507 + .long 3190939319 + .long 3356663664 + .long 1038219909 + .long 2296284299 + .long 1076743037 + .type _P5,@object + .size _P5,112 + .align 4 +_P6: + .long 1104511903 + .long 3165887820 + .long 3273918356 + .long 3217557377 + .long 1767833442 + .long 1064652506 + .long 4164235278 + .long 1067433581 + .long 3499046825 + .long 3209421592 + .long 1038038689 + .long 3210276846 + .long 3702826228 + .long 1057329476 + .long 3651609877 + .long 1057129169 + .long 1779967631 + .long 3199161987 + .long 3308825176 + .long 3198147781 + .long 897891533 + .long 1045052198 + .long 2444111938 + .long 1043454098 + .long 144575532 + .long 3185257015 + .long 1701846534 + .long 3183129264 + .long 1767841339 + .long 1077021468 + .type _P6,@object + .size _P6,120 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_QP: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP,@object + .size _QP,48 + .align 4 +_PP: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP,@object + .size _PP,48 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/y1l.S b/external/sgx_libm/intel64/y1l.S new file mode 100644 index 0000000000..1798aae609 --- /dev/null +++ b/external/sgx_libm/intel64/y1l.S @@ -0,0 +1,86 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "y1l.c" + .text +..TXTST0: +# -- Begin y1l + .text + .align 16,0x90 + .globl y1l +y1l: +# parameter 1: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_y1l.1: +..L2: + + subq $24, %rsp + .cfi_def_cfa_offset 32 + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 48 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B1.6: + addq $16, %rsp + .cfi_def_cfa_offset 32 + movaps (%rsp), %xmm0 +..___tag_value_y1l.6: + call __y1q@PLT +..___tag_value_y1l.7: +..B1.2: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B1.7: + addq $24, %rsp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type y1l,@function + .size y1l,.-y1l + .data +# -- End y1l + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/yn.S b/external/sgx_libm/intel64/yn.S new file mode 100644 index 0000000000..100e3f3fb8 --- /dev/null +++ b/external/sgx_libm/intel64/yn.S @@ -0,0 +1,1623 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "yn.c" + .text +..TXTST0: +# -- Begin yn + .text + .align 16,0x90 + .globl yn +yn: +# parameter 1: %edi +# parameter 2: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_yn.1: +..L2: + + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r14 + .cfi_def_cfa_offset 24 + .cfi_offset 14, -24 + pushq %r15 + .cfi_def_cfa_offset 32 + .cfi_offset 15, -32 + subq $224, %rsp + .cfi_def_cfa_offset 256 + movl %edi, %r13d + movsd %xmm0, (%rsp) + xorb %r14b, %r14b +..B1.2: + fnstcw 218(%rsp) +..B1.3: + movzwl 6(%rsp), %ecx + movl $1, %r15d + andl $32752, %ecx + shrl $4, %ecx + cmpl $2047, %ecx + je ..B1.58 +..B1.4: + lea _zeros(%rip), %rax + movsd (%rsp), %xmm0 + movsd (%rax), %xmm1 + comisd %xmm0, %xmm1 + jb ..B1.8 +..B1.5: + ucomisd %xmm1, %xmm0 + jp ..B1.6 + je ..B1.37 +..B1.6: + lea _infs(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm1, %xmm0 +..B1.7: + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.8: + testl %r13d, %r13d + je ..B1.36 +..B1.9: + jge ..B1.11 +..B1.10: + negl %r13d + movl %r13d, %eax + notl %eax + andl $1, %eax + lea -1(%rax,%rax), %r15d +..B1.11: + cmpl $1, %r13d + je ..B1.50 +..B1.12: + movl %r13d, %ecx + sarl $5, %ecx + cmpl $160, %ecx + jg ..B1.14 +..B1.13: + movslq %ecx, %rcx + lea XINF(%rip), %rax + movsd (%rax,%rcx,8), %xmm1 + jmp ..B1.15 +..B1.14: + pxor %xmm1, %xmm1 + lea -640(,%rcx,4), %eax + lea (,%rax,8), %ecx + subl %eax, %ecx + cvtsi2sd %ecx, %xmm1 + addsd .L_2il0floatpacket.0(%rip), %xmm1 +..B1.15: + comisd %xmm0, %xmm1 + ja ..B1.35 +..B1.16: + movzwl 218(%rsp), %ecx + movl %ecx, %eax + andl $768, %eax + cmpl $768, %eax + je ..B1.20 +..B1.17: + orl $-64768, %ecx + movw %cx, 216(%rsp) +..B1.18: + fldcw 216(%rsp) +..B1.19: + movsd (%rsp), %xmm0 + movb $1, %r14b +..B1.20: + movsd %xmm0, (%rsp) + lea _val_20_0L(%rip), %rax + fldl (%rsp) + lea _val_1000_0L(%rip), %rcx + movl %r13d, (%rsp) + fildl (%rsp) + fldt (%rax) + fmul %st(1), %st + fldt (%rcx) + faddp %st, %st(1) + fcomip %st(2), %st + ja ..B1.39 +..B1.21: + lea _val_4_0L(%rip), %rcx + fld %st(0) + lea _val_8_0L(%rip), %rsi + movl $-1, %eax + lea _val_n1_0L(%rip), %r8 + lea _val_3_0L(%rip), %r10 + lea _val_p1_0L(%rip), %rdi + lea _val_5_0L(%rip), %r11 + lea _val_2_0L(%rip), %r9 + fxch %st(2) + fstl 112(%rsp) + fldt (%rcx) + xorb %cl, %cl + fstpt 136(%rsp) + fldt 136(%rsp) + fmulp %st, %st(3) + fxch %st(1) + fmulp %st, %st(2) + fxch %st(1) + fstpt 200(%rsp) + fldt 200(%rsp) + fldt (%rsi) + lea _val_0_0L(%rip), %rsi + fmulp %st, %st(2) + fxch %st(1) + fstpt 168(%rsp) + fldt 168(%rsp) + fldt (%rdi) + fstpt (%rsp) + fldt (%rsp) + fstpt 64(%rsp) + fldt (%r8) + faddp %st, %st(2) + fdivrp %st, %st(1) + fstpt 48(%rsp) + fldt 48(%rsp) + fldt (%r9) + fstpt 80(%rsp) + fldt 80(%rsp) + fstpt 152(%rsp) + fldt (%r10) + fstpt 32(%rsp) + fldt 32(%rsp) + fstpt 96(%rsp) + fldt (%r11) + fstpt 16(%rsp) + fldt (%rsi) + fstpt 120(%rsp) + fldt 16(%rsp) + fldt 96(%rsp) + fldt 32(%rsp) + fldt (%rsp) +..B1.22: + fldt 200(%rsp) + fld %st(3) + fmul %st(4), %st + testl %eax, %eax + fsubr %st(1), %st + fxch %st(4) + fstpt 96(%rsp) + fxch %st(1) + fstpt 16(%rsp) + fldt 16(%rsp) + fstpt 184(%rsp) + fldt 184(%rsp) + fldt 80(%rsp) + fldt 168(%rsp) + fmul %st, %st(1) + fxch %st(1) + fdivrp %st, %st(5) + fxch %st(6) + fmulp %st, %st(4) + fld %st(4) + fmul %st(5), %st + fsubrp %st, %st(2) + fxch %st(2) + fmul %st, %st(5) + fxch %st(5) + fdivrp %st, %st(1) + fmul %st(2), %st + fldt 96(%rsp) + jle ..B1.24 +..B1.23: + fldt 48(%rsp) + fadd %st(2), %st + fstpt 48(%rsp) + fxch %st(3) + faddp %st, %st(2) + jmp ..B1.25 +..B1.24: + fldt 48(%rsp) + fsub %st(2), %st + fstpt 48(%rsp) + fxch %st(3) + fsubrp %st, %st(2) +..B1.25: + fldt 152(%rsp) + fadd %st, %st(5) + fldt 80(%rsp) + faddp %st, %st(1) + fstpt 80(%rsp) + fld %st(0) + fdiv %st(2), %st + fldt 136(%rsp) + fadd %st, %st(4) + faddp %st, %st(5) + fld %st(0) + fchs + fldt 120(%rsp) + fcomip %st(2), %st + fcmovbe %st(1), %st + fstp %st(1) + fldt 64(%rsp) + fcomip %st(1), %st + jbe ..B1.27 +..B1.26: + fstpt 64(%rsp) + movb $1, %cl + jmp ..B1.28 +..B1.27: + fstp %st(0) + testb %cl, %cl + jne ..B1.38 +..B1.28: + fldt 16(%rsp) + negl %eax + fucomip %st(2), %st + fxch %st(4) + fxch %st(1) + jne ..B1.22 + jp ..B1.22 +..B1.29: + fstp %st(2) + fstp %st(0) + fstp %st(1) + fldt 184(%rsp) + fstpt 16(%rsp) + fstpt (%rsp) + fstpt 32(%rsp) + fldl 112(%rsp) +..B1.30: + addl %r13d, %r13d + addq $-16, %rsp + .cfi_def_cfa_offset 272 + negl %r13d + lea 32(%rsp), %rdi + decl %r13d + lea 48(%rsp), %rsi + movl %r13d, %edx + fstpt (%rsp) + fldt (%rsp) + fstpl 80(%rsi) +..___tag_value_yn.22: + call __libm_sincos_pi4l@PLT +..___tag_value_yn.23: +..B1.67: + fldl 128(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 256 +..B1.31: + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt 32(%rsp) + fldt 48(%rsp) + fmulp %st, %st(1) + fldt (%rax) + fdivp %st, %st(3) + fxch %st(2) + fsqrt + fldt 16(%rsp) + fmulp %st, %st(2) + fxch %st(2) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt 16(%rsp) +..B1.32: + testb %r14b, %r14b + je ..B1.34 +..B1.33: + fldcw 218(%rsp) +..B1.34: + fldt 16(%rsp) + testl %r15d, %r15d + fstpl (%rsp) + movsd (%rsp), %xmm1 + movaps %xmm1, %xmm0 + xorps .L_2il0floatpacket.1(%rip), %xmm0 + jl ..L25 + movaps %xmm1, %xmm0 +..L25: + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.35: + movb 7(%rsp), %al + lea _large_value_64(%rip), %rcx + andb $-128, %al + shrb $7, %al + movzbl %al, %edx + movsd (%rcx,%rdx,8), %xmm0 + mulsd (%rcx), %xmm0 + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.36: + call y0@PLT +..B1.68: + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.37: + lea 8+_ones(%rip), %rax + movsd (%rax), %xmm0 + divsd %xmm1, %xmm0 + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.38: + fstp %st(2) + fstp %st(3) + fstp %st(1) + fldt 184(%rsp) + fstpt 16(%rsp) + fxch %st(1) + fstpt (%rsp) + fstpt 32(%rsp) + fldl 112(%rsp) + jmp ..B1.30 +..B1.39: + fstp %st(0) + lea _val_36_0L(%rip), %rax + fldt (%rax) + fcomi %st(1), %st + jbe ..B1.43 +..B1.40: + fstp %st(0) + addq $-16, %rsp + .cfi_def_cfa_offset 272 + fstpt (%rsp) + fldt (%rsp) + fstpl 128(%rsp) +..___tag_value_yn.71: + call __y0l@PLT +..___tag_value_yn.72: +..B1.69: + fldl 128(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 256 +..B1.41: + fxch %st(1) + fstpt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 272 + fstpt (%rsp) + fldt (%rsp) + fstpl 128(%rsp) +..___tag_value_yn.75: + call __y1l@PLT +..___tag_value_yn.76: +..B1.70: + fldl 128(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 256 +..B1.42: + fxch %st(1) + jmp ..B1.45 +..B1.43: + lea _ones(%rip), %rax + lea _PP0(%rip), %rcx + lea 16+_PP0(%rip), %r9 + lea _PP1(%rip), %r8 + lea 16+_PP1(%rip), %r10 + lea 32+_PP0(%rip), %r11 + lea 48+_PP1(%rip), %rsi + lea 64+_PP0(%rip), %rdi + fldl (%rax) + lea 32+_PP1(%rip), %rax + fdiv %st(2), %st + movl $-1, %edx + fmul %st, %st(1) + fld %st(1) + fmul %st(2), %st + fstpt 96(%rsp) + fldt 96(%rsp) + fxch %st(1) + fstpt (%rsp) + fxch %st(1) + fstpt 80(%rsp) + fldt 80(%rsp) + fldt (%rcx) + lea 48+_PP0(%rip), %rcx + fmul %st(2), %st + fldt (%r8) + lea 64+_PP1(%rip), %r8 + fmul %st(3), %st + fldt (%r9) + lea 80+_PP0(%rip), %r9 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r10) + lea 80+_PP1(%rip), %r10 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + lea 96+_PP0(%rip), %r11 + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 96+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rcx) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rsi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rdi) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r8) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r9) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r10) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%r11) + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 112+_PP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 112+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 128+_PP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 128+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 144+_PP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(3), %st + fldt (%rax) + lea 144+_PP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fstpt 16(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 272 + lea 96(%rsp), %rdi + lea 112(%rsp), %rsi + fxch %st(3) + fstpt (%rsp) + fldt (%rsp) + fstpl 16(%rsi) + fldt (%rax) + lea _QP0(%rip), %rax + faddp %st, %st(3) + fxch %st(2) + fstpt -32(%rsi) + fldt (%rax) + lea _QP1(%rip), %rax + fmul %st(1), %st + fldt (%rax) + lea 16+_QP0(%rip), %rax + fmul %st(2), %st + fldt (%rax) + lea 16+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 32+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 32+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 48+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 48+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 64+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 64+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 80+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 80+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 96+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 96+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 112+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 112+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 128+_QP1(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmul %st(2), %st + fldt (%rax) + lea 144+_QP0(%rip), %rax + faddp %st, %st(2) + fxch %st(1) + fmulp %st, %st(2) + fldt (%rax) + lea 144+_QP1(%rip), %rax + faddp %st, %st(1) + fmul %st(2), %st + fstpt -64(%rsi) + fldt (%rax) + faddp %st, %st(1) + fmulp %st, %st(1) + fstpt -48(%rsi) +..___tag_value_yn.79: + call __libm_sincos_pi4l@PLT +..___tag_value_yn.80: +..B1.71: + fldl 128(%rsp) + fldt 80(%rsp) + fldt 64(%rsp) + fldt 48(%rsp) + addq $16, %rsp + .cfi_def_cfa_offset 256 +..B1.44: + fldt (%rsp) + lea _tonpi(%rip), %rax + fldt 96(%rsp) + fmul %st, %st(2) + fmulp %st, %st(4) + fldt 16(%rsp) + fldt (%rax) + fmulp %st, %st(2) + fxch %st(1) + fsqrt + fldt 80(%rsp) + fmul %st, %st(2) + fxch %st(3) + faddp %st, %st(2) + fmul %st, %st(1) + fxch %st(1) + fstpt 32(%rsp) + fxch %st(2) + fmulp %st, %st(1) + fsubp %st, %st(2) + fmulp %st, %st(1) +..B1.45: + lea _val_2_0L(%rip), %rax + cmpl $1, %r13d + fldt (%rax) + movl $0, %eax + fld %st(0) + jle ..B1.49 +..B1.46: + fldt 32(%rsp) + decl %r13d +..B1.47: + fld %st(1) + incl %eax + fdiv %st(5), %st + cmpl %r13d, %eax + fmul %st(4), %st + fxch %st(2) + fadd %st(3), %st + fxch %st(2) + fsubp %st, %st(1) + fld %st(3) + jae ..B1.48 +..B1.73: + fstp %st(4) + fxch %st(3) + jmp ..B1.47 +..B1.48: + fstp %st(5) + fstp %st(4) + fstp %st(0) + fstp %st(0) + fxch %st(1) + fstpt 16(%rsp) + fstpt 32(%rsp) + jmp ..B1.32 +..B1.49: + fstp %st(3) + fstp %st(2) + fstp %st(1) + fstpt 16(%rsp) + jmp ..B1.32 +..B1.50: + testl %ecx, %ecx + jne ..B1.57 +..B1.51: + testl $1048575, 4(%rsp) + jne ..B1.57 +..B1.52: + cmpl $1, (%rsp) + jne ..B1.57 +..B1.53: + lea _large_value_64(%rip), %rax + testl %r15d, %r15d + movsd (%rax), %xmm1 + jl ..B1.55 +..B1.54: + lea 8+_large_value_64(%rip), %rax + movsd (%rax), %xmm0 + mulsd %xmm1, %xmm0 + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.55: + movaps %xmm1, %xmm0 + mulsd %xmm1, %xmm0 +..B1.56: + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.57: + call y1@PLT +..B1.72: + movaps %xmm0, %xmm1 + testl %r15d, %r15d + xorps .L_2il0floatpacket.1(%rip), %xmm1 + jge ..L104 + movaps %xmm1, %xmm0 +..L104: + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.58: + testl $1048575, 4(%rsp) + jne ..B1.64 +..B1.59: + cmpl $0, (%rsp) + jne ..B1.64 +..B1.60: + testb $-128, 7(%rsp) + je ..B1.62 +..B1.61: + lea _infs(%rip), %rax + lea _zeros(%rip), %rdx + movsd (%rax), %xmm0 + mulsd (%rdx), %xmm0 + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.62: + lea _zeros(%rip), %rdx + movl %r13d, %eax + shrl $31, %eax + andl %r13d, %eax + movsd (%rdx,%rax,8), %xmm0 +..B1.63: + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 256 + .cfi_offset 13, -16 + .cfi_offset 14, -24 + .cfi_offset 15, -32 +..B1.64: + lea _ones(%rip), %rax + movsd (%rsp), %xmm0 + mulsd (%rax), %xmm0 + addq $224, %rsp + .cfi_def_cfa_offset 32 + .cfi_restore 15 + popq %r15 + .cfi_def_cfa_offset 24 + .cfi_restore 14 + popq %r14 + .cfi_def_cfa_offset 16 + .cfi_restore 13 + popq %r13 + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type yn,@function + .size yn,.-yn + .data +# -- End yn + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.1: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,16 + .align 8 +.L_2il0floatpacket.0: + .long 0x00000000,0x40adc000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,8 + .align 8 +XINF: + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x00000000,0x00000000 + .long 0x33333333,0x3fd33333 + .long 0xcccccccd,0x3ff4cccc + .long 0x33333333,0x400b3333 + .long 0x33333333,0x401b3333 + .long 0x33333333,0x40273333 + .long 0xcccccccd,0x4031cccc + .long 0x66666666,0x40396666 + .long 0x9999999a,0x40411999 + .long 0x9999999a,0x40461999 + .long 0x66666666,0x404ba666 + .long 0x9999999a,0x4050d999 + .long 0x00000000,0x40542000 + .long 0x33333333,0x40579333 + .long 0x9999999a,0x405b3999 + .long 0x00000000,0x405f0000 + .long 0x00000000,0x40618000 + .long 0x00000000,0x40638000 + .long 0x00000000,0x4065a000 + .long 0x00000000,0x4067e000 + .long 0x00000000,0x406a2000 + .long 0x00000000,0x406c8000 + .long 0x00000000,0x406ee000 + .long 0x00000000,0x4070a000 + .long 0x00000000,0x4071e000 + .long 0x00000000,0x40732000 + .long 0x00000000,0x40746000 + .long 0x00000000,0x4075b000 + .long 0x00000000,0x40770000 + .long 0x00000000,0x40785000 + .long 0x00000000,0x4079a000 + .long 0x00000000,0x407b0000 + .long 0x00000000,0x407c6000 + .long 0x00000000,0x407dc000 + .long 0x00000000,0x407f3000 + .long 0x00000000,0x40804800 + .long 0x00000000,0x40810000 + .long 0x00000000,0x4081b800 + .long 0x00000000,0x40827000 + .long 0x00000000,0x40832800 + .long 0x00000000,0x4083e000 + .long 0x00000000,0x4084a000 + .long 0x00000000,0x40856000 + .long 0x00000000,0x40861800 + .long 0x00000000,0x4086d800 + .long 0x00000000,0x4087a000 + .long 0x00000000,0x40886000 + .long 0x00000000,0x40892000 + .long 0x00000000,0x4089e800 + .long 0x00000000,0x408aa800 + .long 0x00000000,0x408b7000 + .long 0x00000000,0x408c3000 + .long 0x00000000,0x408cf800 + .long 0x00000000,0x408dc000 + .long 0x00000000,0x408e8800 + .long 0x00000000,0x408f5800 + .long 0x00000000,0x40901000 + .long 0x00000000,0x40907400 + .long 0x00000000,0x4090d800 + .long 0x00000000,0x40914000 + .long 0x00000000,0x4091a800 + .long 0x00000000,0x40920c00 + .long 0x00000000,0x40927400 + .long 0x00000000,0x4092dc00 + .long 0x00000000,0x40934400 + .long 0x00000000,0x4093a800 + .long 0x00000000,0x40941000 + .long 0x00000000,0x40947800 + .long 0x00000000,0x4094e400 + .long 0x00000000,0x40954c00 + .long 0x00000000,0x4095b400 + .long 0x00000000,0x40961c00 + .long 0x00000000,0x40968800 + .long 0x00000000,0x4096f000 + .long 0x00000000,0x40975c00 + .long 0x00000000,0x4097c400 + .long 0x00000000,0x40983000 + .long 0x00000000,0x40989800 + .long 0x00000000,0x40990400 + .long 0x00000000,0x40997000 + .long 0x00000000,0x4099d800 + .long 0x00000000,0x409a4400 + .long 0x00000000,0x409ab000 + .long 0x00000000,0x409b1c00 + .long 0x00000000,0x409b8800 + .long 0x00000000,0x409bf400 + .long 0x00000000,0x409c6000 + .long 0x00000000,0x409ccc00 + .long 0x00000000,0x409d3800 + .long 0x00000000,0x409da400 + .long 0x00000000,0x409e1000 + .long 0x00000000,0x409e8000 + .long 0x00000000,0x409eec00 + .long 0x00000000,0x409f5800 + .long 0x00000000,0x409fc800 + .long 0x00000000,0x40a01a00 + .long 0x00000000,0x40a05000 + .long 0x00000000,0x40a08800 + .long 0x00000000,0x40a0be00 + .long 0x00000000,0x40a0f600 + .long 0x00000000,0x40a12c00 + .long 0x00000000,0x40a16400 + .long 0x00000000,0x40a19a00 + .long 0x00000000,0x40a1d200 + .long 0x00000000,0x40a20a00 + .long 0x00000000,0x40a24000 + .long 0x00000000,0x40a27800 + .long 0x00000000,0x40a2b000 + .long 0x00000000,0x40a2e800 + .long 0x00000000,0x40a31e00 + .long 0x00000000,0x40a35600 + .long 0x00000000,0x40a38e00 + .long 0x00000000,0x40a3c600 + .long 0x00000000,0x40a3fe00 + .long 0x00000000,0x40a43600 + .long 0x00000000,0x40a46e00 + .long 0x00000000,0x40a4a600 + .long 0x00000000,0x40a4de00 + .long 0x00000000,0x40a51600 + .long 0x00000000,0x40a54e00 + .long 0x00000000,0x40a58600 + .long 0x00000000,0x40a5be00 + .long 0x00000000,0x40a5f600 + .long 0x00000000,0x40a62e00 + .long 0x00000000,0x40a66600 + .long 0x00000000,0x40a6a000 + .long 0x00000000,0x40a6d800 + .long 0x00000000,0x40a71000 + .long 0x00000000,0x40a74800 + .long 0x00000000,0x40a78200 + .long 0x00000000,0x40a7ba00 + .long 0x00000000,0x40a7f200 + .long 0x00000000,0x40a82c00 + .long 0x00000000,0x40a86400 + .long 0x00000000,0x40a89c00 + .long 0x00000000,0x40a8d600 + .long 0x00000000,0x40a90e00 + .long 0x00000000,0x40a94600 + .long 0x00000000,0x40a98000 + .long 0x00000000,0x40a9b800 + .long 0x00000000,0x40a9f200 + .long 0x00000000,0x40aa2a00 + .long 0x00000000,0x40aa6400 + .long 0x00000000,0x40aa9c00 + .long 0x00000000,0x40aad600 + .long 0x00000000,0x40ab1000 + .long 0x00000000,0x40ab4800 + .long 0x00000000,0x40ab8200 + .long 0x00000000,0x40abba00 + .long 0x00000000,0x40abf400 + .long 0x00000000,0x40ac2e00 + .long 0x00000000,0x40ac6600 + .long 0x00000000,0x40aca000 + .long 0x00000000,0x40acda00 + .long 0x00000000,0x40ad1200 + .long 0x00000000,0x40ad4c00 + .long 0x00000000,0x40ad8600 + .long 0x00000000,0x40adc000 + .type XINF,@object + .size XINF,1288 + .align 4 +_zeros: + .long 0 + .long 0 + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,16 + .align 4 +_infs: + .long 0 + .long 2146435072 + .long 0 + .long 4293918720 + .type _infs,@object + .size _infs,16 + .align 4 +_large_value_64: + .long 0 + .long 2121269248 + .long 0 + .long 4268752896 + .type _large_value_64,@object + .size _large_value_64,16 + .align 4 +_ones: + .long 0 + .long 1072693248 + .long 0 + .long 3220176896 + .type _ones,@object + .size _ones,16 + .align 2 +_val_20_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16387 + .word 0 + .word 0 + .word 0 + .type _val_20_0L,@object + .size _val_20_0L,16 + .align 2 +_val_1000_0L: + .word 0 + .word 0 + .word 0 + .word 64000 + .word 16392 + .word 0 + .word 0 + .word 0 + .type _val_1000_0L,@object + .size _val_1000_0L,16 + .align 2 +_val_4_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16385 + .word 0 + .word 0 + .word 0 + .type _val_4_0L,@object + .size _val_4_0L,16 + .align 2 +_val_8_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16386 + .word 0 + .word 0 + .word 0 + .type _val_8_0L,@object + .size _val_8_0L,16 + .align 2 +_val_n1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 49151 + .word 0 + .word 0 + .word 0 + .type _val_n1_0L,@object + .size _val_n1_0L,16 + .align 2 +_val_3_0L: + .word 0 + .word 0 + .word 0 + .word 49152 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _val_3_0L,@object + .size _val_3_0L,16 + .align 2 +_val_p1_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _val_p1_0L,@object + .size _val_p1_0L,16 + .align 2 +_val_5_0L: + .word 0 + .word 0 + .word 0 + .word 40960 + .word 16385 + .word 0 + .word 0 + .word 0 + .type _val_5_0L,@object + .size _val_5_0L,16 + .align 2 +_val_2_0L: + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16384 + .word 0 + .word 0 + .word 0 + .type _val_2_0L,@object + .size _val_2_0L,16 + .align 2 +_val_0_0L: + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .type _val_0_0L,@object + .size _val_0_0L,16 + .align 2 +_tonpi: + .word 5418 + .word 20036 + .word 33646 + .word 41721 + .word 16382 + .word 0 + .word 0 + .word 0 + .type _tonpi,@object + .size _tonpi,16 + .align 2 +_val_36_0L: + .word 0 + .word 0 + .word 0 + .word 36864 + .word 16388 + .word 0 + .word 0 + .word 0 + .type _val_36_0L,@object + .size _val_36_0L,16 + .align 2 +_PP0: + .word 3555 + .word 4199 + .word 61716 + .word 36505 + .word 49086 + .word 0 + .word 0 + .word 0 + .word 21640 + .word 56203 + .word 47336 + .word 57608 + .word 16322 + .word 0 + .word 0 + .word 0 + .word 3059 + .word 27554 + .word 42044 + .word 45622 + .word 49095 + .word 0 + .word 0 + .word 0 + .word 55815 + .word 35656 + .word 54748 + .word 47307 + .word 16332 + .word 0 + .word 0 + .word 0 + .word 42025 + .word 6728 + .word 28939 + .word 34692 + .word 49106 + .word 0 + .word 0 + .word 0 + .word 58943 + .word 11189 + .word 14960 + .word 38786 + .word 16344 + .word 0 + .word 0 + .word 0 + .word 43526 + .word 20005 + .word 29826 + .word 37014 + .word 49119 + .word 0 + .word 0 + .word 0 + .word 58976 + .word 17109 + .word 36079 + .word 36708 + .word 16359 + .word 0 + .word 0 + .word 0 + .word 58243 + .word 36408 + .word 14563 + .word 58254 + .word 49136 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP0,@object + .size _PP0,160 + .align 2 +_PP1: + .word 52008 + .word 23245 + .word 2457 + .word 38658 + .word 16318 + .word 0 + .word 0 + .word 0 + .word 61876 + .word 57278 + .word 25234 + .word 61346 + .word 49090 + .word 0 + .word 0 + .word 0 + .word 33834 + .word 23040 + .word 39409 + .word 49003 + .word 16327 + .word 0 + .word 0 + .word 0 + .word 54525 + .word 6554 + .word 40935 + .word 51421 + .word 49100 + .word 0 + .word 0 + .word 0 + .word 9848 + .word 9769 + .word 18248 + .word 38344 + .word 16338 + .word 0 + .word 0 + .word 0 + .word 45790 + .word 60252 + .word 47538 + .word 43957 + .word 49112 + .word 0 + .word 0 + .word 0 + .word 27022 + .word 41654 + .word 23333 + .word 43744 + .word 16351 + .word 0 + .word 0 + .word 0 + .word 12816 + .word 40723 + .word 46387 + .word 47196 + .word 49127 + .word 0 + .word 0 + .word 0 + .word 4849 + .word 19418 + .word 12136 + .word 48545 + .word 16369 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 32768 + .word 16383 + .word 0 + .word 0 + .word 0 + .type _PP1,@object + .size _PP1,160 + .align 2 +_QP0: + .word 30466 + .word 14887 + .word 33885 + .word 35327 + .word 16316 + .word 0 + .word 0 + .word 0 + .word 41139 + .word 65374 + .word 59488 + .word 50915 + .word 49088 + .word 0 + .word 0 + .word 0 + .word 35675 + .word 30946 + .word 22284 + .word 35505 + .word 16325 + .word 0 + .word 0 + .word 0 + .word 65216 + .word 29458 + .word 42913 + .word 63176 + .word 49097 + .word 0 + .word 0 + .word 0 + .word 5130 + .word 24339 + .word 48915 + .word 38634 + .word 16335 + .word 0 + .word 0 + .word 0 + .word 30040 + .word 27658 + .word 23448 + .word 34596 + .word 49109 + .word 0 + .word 0 + .word 0 + .word 37816 + .word 17431 + .word 24401 + .word 49646 + .word 16347 + .word 0 + .word 0 + .word 0 + .word 4377 + .word 35057 + .word 45578 + .word 33037 + .word 49123 + .word 0 + .word 0 + .word 0 + .word 19863 + .word 65266 + .word 6202 + .word 53939 + .word 16363 + .word 0 + .word 0 + .word 0 + .word 58254 + .word 36408 + .word 14563 + .word 58254 + .word 49142 + .word 0 + .word 0 + .word 0 + .type _QP0,@object + .size _QP0,160 + .align 2 +_QP1: + .word 65402 + .word 6822 + .word 45128 + .word 37300 + .word 49084 + .word 0 + .word 0 + .word 0 + .word 41532 + .word 52948 + .word 50360 + .word 54021 + .word 16320 + .word 0 + .word 0 + .word 0 + .word 21320 + .word 30785 + .word 26870 + .word 37955 + .word 49093 + .word 0 + .word 0 + .word 0 + .word 55382 + .word 38611 + .word 29746 + .word 34115 + .word 16330 + .word 0 + .word 0 + .word 0 + .word 37194 + .word 6554 + .word 16235 + .word 42314 + .word 49103 + .word 0 + .word 0 + .word 0 + .word 17886 + .word 15840 + .word 33918 + .word 38666 + .word 16341 + .word 0 + .word 0 + .word 0 + .word 62905 + .word 55876 + .word 18072 + .word 57284 + .word 49115 + .word 0 + .word 0 + .word 0 + .word 28423 + .word 64693 + .word 26579 + .word 40379 + .word 16355 + .word 0 + .word 0 + .word 0 + .word 40135 + .word 58793 + .word 24002 + .word 37757 + .word 49132 + .word 0 + .word 0 + .word 0 + .word 43691 + .word 43690 + .word 43690 + .word 43690 + .word 16376 + .word 0 + .word 0 + .word 0 + .type _QP1,@object + .size _QP1,160 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ynf.S b/external/sgx_libm/intel64/ynf.S new file mode 100644 index 0000000000..627810e6cf --- /dev/null +++ b/external/sgx_libm/intel64/ynf.S @@ -0,0 +1,1220 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ynf.c" + .text +..TXTST0: +# -- Begin ynf + .text + .align 16,0x90 + .globl ynf +ynf: +# parameter 1: %edi +# parameter 2: %xmm0 +..B1.1: + .cfi_startproc +..___tag_value_ynf.1: +..L2: + + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + pushq %rbp + .cfi_def_cfa_offset 24 + .cfi_offset 6, -24 + subq $72, %rsp + .cfi_def_cfa_offset 96 + movl %edi, %ebx + movd %xmm0, %ecx + movss %xmm0, (%rsp) + lea -1(%rcx), %esi + cmpl $2139095039, %esi + jae ..B1.48 +..B1.2: + testl %ebx, %ebx + je ..B1.59 +..B1.3: + movl %ecx, %ebp + movl %ebx, %eax + cltd + xorl %ebx, %ebp + shrl $31, %ebp + andl %ebx, %ebp + xorl %edx, %ebx + subl %edx, %ebx + cmpl $1, %ebx + je ..B1.58 +..B1.4: + movl %ebx, %edi + sarl $3, %edi + cmpl $320, %edi + jg ..B1.6 +..B1.5: + movslq %edi, %rdi + lea function_zeros(%rip), %rsi + movss (%rsi,%rdi,4), %xmm0 + jmp ..B1.7 +..B1.6: + pxor %xmm0, %xmm0 + lea -320(%rdi), %esi + lea -2560(,%rdi,8), %edi + subl %esi, %edi + cvtsi2ss %edi, %xmm0 + addss .L_2il0floatpacket.0(%rip), %xmm0 +..B1.7: + movss (%rsp), %xmm3 + comiss %xmm3, %xmm0 + ja ..B1.47 +..B1.8: + cvtss2sd %xmm3, %xmm3 + cmpl $6, %ebx + jge ..B1.26 +..B1.9: + lea _val_0_6(%rip), %rcx + movsd (%rcx), %xmm1 + comisd %xmm3, %xmm1 + jb ..B1.27 +..B1.10: + lea _val_2_0(%rip), %rsi + pxor %xmm5, %xmm5 + lea _zeros(%rip), %rcx + movaps %xmm3, %xmm6 + pxor %xmm4, %xmm4 + testl %ebx, %ebx + pxor %xmm1, %xmm1 + movsd (%rsi), %xmm7 + lea _ones(%rip), %rsi + movsd %xmm1, 8(%rsp) + divsd %xmm7, %xmm6 + cvtss2sd (%rsi), %xmm5 + cvtss2sd (%rcx), %xmm4 + divsd %xmm3, %xmm7 + movsd %xmm5, (%rsp) + movaps %xmm5, %xmm2 + movaps %xmm5, %xmm1 + movaps %xmm5, %xmm8 + movl $0, %ecx + jle ..B1.14 +..B1.11: + movaps %xmm1, %xmm9 +..B1.12: + incl %ecx + mulsd %xmm6, %xmm1 + cmpl %ebx, %ecx + mulsd %xmm7, %xmm9 + jb ..B1.12 +..B1.13: + movsd %xmm9, (%rsp) + testl %ebx, %ebx +..B1.14: + movl $0, %ecx + jle ..B1.18 +..B1.16: + movaps %xmm5, %xmm7 + incl %ecx + divsd %xmm8, %xmm7 + movaps %xmm2, %xmm9 + cmpl %ebx, %ecx + mulsd %xmm8, %xmm2 + addsd %xmm7, %xmm4 + addsd %xmm5, %xmm8 + jb ..B1.16 +..B1.17: + movsd %xmm9, 8(%rsp) +..B1.18: + mulsd %xmm6, %xmm6 + lea _TWO_19H(%rip), %rcx + movsd %xmm5, 32(%rsp) + movaps %xmm4, %xmm8 + movsd %xmm4, 64(%rsp) + xorl %r8d, %r8d + xorps .L_2il0floatpacket.3(%rip), %xmm6 + movl %ebx, %edi + movsd (%rcx), %xmm7 + movl %ebx, %ecx +..B1.19: + incl %r8d + incl %edi + movl %r8d, %r9d + movaps %xmm8, %xmm13 + imull %edi, %r9d + pxor %xmm8, %xmm8 + movss (%rsi), %xmm9 + pxor %xmm10, %xmm10 + movsd 32(%rsp), %xmm11 + movaps %xmm7, %xmm12 + mulsd %xmm6, %xmm11 + cvtsi2ss %r9d, %xmm8 + divss %xmm8, %xmm9 + addl $2, %ecx + cvtsi2sd %ecx, %xmm10 + cvtss2sd %xmm9, %xmm9 + mulsd %xmm9, %xmm10 + mulsd %xmm9, %xmm11 + addsd %xmm10, %xmm4 + addsd %xmm11, %xmm5 + movsd %xmm11, 32(%rsp) + mulsd %xmm4, %xmm11 + addsd 64(%rsp), %xmm11 + mulsd %xmm11, %xmm12 + movsd %xmm11, 64(%rsp) + addsd %xmm12, %xmm11 + movsd %xmm11, 56(%rsp) + movsd 56(%rsp), %xmm8 + subsd %xmm12, %xmm8 + ucomisd %xmm13, %xmm8 + jne ..B1.19 + jp ..B1.19 +..B1.20: + divsd %xmm2, %xmm1 + lea _eulon2(%rip), %rcx + movsd %xmm1, 32(%rsp) + mulsd %xmm1, %xmm5 + movsd (%rcx), %xmm1 + mulsd %xmm1, %xmm3 + movaps %xmm3, %xmm0 + movsd %xmm5, 16(%rsp) + movsd %xmm6, 24(%rsp) +..___tag_value_ynf.8: + call __libm_log_k32@PLT +..___tag_value_ynf.9: +..B1.62: + movsd 24(%rsp), %xmm6 + movaps %xmm0, %xmm1 + movsd 16(%rsp), %xmm5 +..B1.21: + lea _tonpi(%rip), %rsi + lea _oonpi(%rip), %rcx + xorps .L_2il0floatpacket.3(%rip), %xmm6 + cmpl $1, %ebx + movsd (%rsi), %xmm0 + movl $0, %esi + mulsd %xmm5, %xmm0 + movsd (%rcx), %xmm2 + lea -1(%rbx), %ecx + mulsd %xmm1, %xmm0 + movsd 64(%rsp), %xmm1 + mulsd %xmm2, %xmm1 + mulsd 32(%rsp), %xmm1 + subsd %xmm1, %xmm0 + movsd 8(%rsp), %xmm1 + jle ..B1.25 +..B1.22: + movaps %xmm1, %xmm4 + decl %ebx +..B1.23: + incl %esi + lea -1(%rcx), %edi + imull %esi, %ecx + mulsd %xmm6, %xmm4 + cvtsi2sd %ecx, %xmm3 + divsd %xmm3, %xmm4 + movl %edi, %ecx + cmpl %ebx, %esi + addsd %xmm4, %xmm1 + jb ..B1.23 +..B1.25: + mulsd %xmm2, %xmm1 + mulsd (%rsp), %xmm1 + subsd %xmm1, %xmm0 + jmp ..B1.46 +..B1.26: + cmpl $80, %ebx + jge ..B1.35 +..B1.27: + lea _val_18_0(%rip), %rcx + movsd (%rcx), %xmm1 + comisd %xmm3, %xmm1 + jbe ..B1.29 +..B1.28: + movaps %xmm3, %xmm0 + movsd %xmm3, 48(%rsp) + call y0@PLT +..B1.64: + movsd 48(%rsp), %xmm3 + movaps %xmm0, %xmm1 + movaps %xmm3, %xmm0 + movsd %xmm1, (%rsp) + call y1@PLT +..B1.63: + movsd 48(%rsp), %xmm3 + movsd (%rsp), %xmm1 + jmp ..B1.31 +..B1.29: + lea _ones(%rip), %rcx + pxor %xmm1, %xmm1 + lea _val_16_0(%rip), %r8 + lea (%rsp), %rdi + movaps %xmm3, %xmm0 + lea 8(%rsp), %rsi + movl $-1, %edx + cvtss2sd (%rcx), %xmm1 + divsd %xmm3, %xmm1 + movsd (%r8), %xmm8 + mulsd %xmm1, %xmm8 + movaps %xmm8, %xmm6 + mulsd %xmm8, %xmm6 + movaps %xmm6, %xmm7 + mulsd %xmm6, %xmm7 + movq $0, 56(%rsi) + movsd %xmm1, 8(%rsi) + movsd %xmm6, 16(%rsi) + movsd %xmm7, 24(%rsi) + movsd %xmm8, 32(%rsi) + movsd %xmm3, 40(%rsi) +..___tag_value_ynf.10: + call __libm_sincos_k32@PLT +..___tag_value_ynf.11: +..B1.30: + lea 40+_PP1(%rip), %r11 + lea 40+_PP0(%rip), %rcx + movsd 32(%rsp), %xmm7 + lea 24+_PP0(%rip), %rsi + lea 8+_PP0(%rip), %rdi + lea 32+_PP0(%rip), %r8 + movsd 24(%rsp), %xmm6 + lea 16+_PP0(%rip), %r9 + movsd (%r11), %xmm11 + lea _PP0(%rip), %r10 + movsd (%rcx), %xmm1 + lea 24+_PP1(%rip), %rcx + movsd (%r8), %xmm2 + movsd 40(%rsp), %xmm8 + mulsd %xmm7, %xmm11 + mulsd %xmm7, %xmm1 + mulsd %xmm7, %xmm2 + addsd (%rcx), %xmm11 + addsd (%rsi), %xmm1 + addsd (%r9), %xmm2 + mulsd %xmm7, %xmm11 + mulsd %xmm7, %xmm1 + mulsd %xmm7, %xmm2 + addsd (%rdi), %xmm1 + addsd (%r10), %xmm2 + mulsd %xmm6, %xmm1 + lea 8+_PP1(%rip), %rcx + addsd %xmm2, %xmm1 + addsd (%rcx), %xmm11 + lea 32+_PP1(%rip), %rcx + mulsd %xmm6, %xmm11 + movsd (%rcx), %xmm4 + lea 16+_PP1(%rip), %rcx + mulsd %xmm7, %xmm4 + movsd 48(%rsp), %xmm3 + addsd (%rcx), %xmm4 + lea _PP1(%rip), %rcx + mulsd %xmm7, %xmm4 + addsd (%rcx), %xmm4 + lea 40+_QP0(%rip), %rcx + movsd (%rcx), %xmm9 + lea 24+_QP0(%rip), %rcx + mulsd %xmm7, %xmm9 + addsd %xmm4, %xmm11 + addsd (%rcx), %xmm9 + lea 8+_QP0(%rip), %rcx + mulsd %xmm7, %xmm9 + addsd (%rcx), %xmm9 + lea 32+_QP0(%rip), %rcx + movsd (%rcx), %xmm5 + lea 16+_QP0(%rip), %rcx + mulsd %xmm7, %xmm5 + mulsd %xmm6, %xmm9 + addsd (%rcx), %xmm5 + mulsd %xmm8, %xmm9 + mulsd %xmm7, %xmm5 + lea _QP0(%rip), %rcx + addsd (%rcx), %xmm5 + lea 40+_QP1(%rip), %rcx + movsd (%rcx), %xmm10 + lea 24+_QP1(%rip), %rcx + mulsd %xmm7, %xmm10 + mulsd %xmm8, %xmm5 + addsd (%rcx), %xmm10 + addsd %xmm5, %xmm9 + mulsd %xmm7, %xmm10 + lea 8+_QP1(%rip), %rcx + addsd (%rcx), %xmm10 + lea 32+_QP1(%rip), %rcx + mulsd %xmm6, %xmm10 + movsd (%rcx), %xmm6 + lea 16+_QP1(%rip), %rcx + mulsd %xmm7, %xmm6 + mulsd %xmm8, %xmm10 + addsd (%rcx), %xmm6 + mulsd %xmm7, %xmm6 + lea _QP1(%rip), %rcx + movsd 8(%rsp), %xmm7 + mulsd %xmm7, %xmm9 + addsd (%rcx), %xmm6 + mulsd %xmm11, %xmm7 + mulsd %xmm8, %xmm6 + lea _tonpi(%rip), %rcx + addsd %xmm6, %xmm10 + movsd (%rcx), %xmm0 + mulsd 16(%rsp), %xmm0 + movsd (%rsp), %xmm8 + sqrtsd %xmm0, %xmm0 + mulsd %xmm8, %xmm1 + mulsd %xmm10, %xmm8 + addsd %xmm9, %xmm1 + subsd %xmm7, %xmm8 + mulsd %xmm0, %xmm1 + mulsd %xmm8, %xmm0 +..B1.31: + lea _val_2_0(%rip), %rcx + cmpl $1, %ebx + movsd (%rcx), %xmm2 + movl $0, %ecx + divsd %xmm3, %xmm2 + jle ..B1.46 +..B1.32: + decl %ebx +..B1.33: + incl %ecx + pxor %xmm3, %xmm3 + cvtsi2sd %ecx, %xmm3 + mulsd %xmm2, %xmm3 + movaps %xmm0, %xmm4 + mulsd %xmm0, %xmm3 + cmpl %ebx, %ecx + movaps %xmm3, %xmm0 + subsd %xmm1, %xmm0 + movaps %xmm4, %xmm1 + jb ..B1.33 + jmp ..B1.46 +..B1.35: + pxor %xmm1, %xmm1 + lea 5000(%rbx,%rbx,4), %ecx + cvtsi2sd %ecx, %xmm1 + comisd %xmm3, %xmm1 + ja ..B1.27 +..B1.36: + pxor %xmm1, %xmm1 + lea _val_4_0(%rip), %rsi + cvtsi2sd %ebx, %xmm1 + movsd (%rsi), %xmm15 + pxor %xmm2, %xmm2 + movaps %xmm15, %xmm14 + lea _val_5_0(%rip), %rsi + mulsd %xmm1, %xmm14 + lea 4+_ones(%rip), %r9 + cvtss2sd (%r9), %xmm2 + mulsd %xmm1, %xmm14 + lea _val_8_0(%rip), %rdi + addsd %xmm14, %xmm2 + movsd (%rdi), %xmm11 + pxor %xmm1, %xmm1 + mulsd %xmm3, %xmm11 + lea _ones(%rip), %r8 + cvtss2sd (%r8), %xmm1 + divsd %xmm11, %xmm2 + lea _val_2_0(%rip), %r10 + lea _val_3_0(%rip), %r11 + movaps %xmm1, %xmm12 + movaps %xmm1, %xmm4 + movsd %xmm2, 32(%rsp) + movaps %xmm1, %xmm13 + movsd (%rsi), %xmm6 + movl $-1, %ecx + movsd (%r10), %xmm10 + xorb %sil, %sil + movsd (%r11), %xmm8 + movaps %xmm10, %xmm9 + divsd %xmm1, %xmm12 + movaps %xmm8, %xmm7 +..B1.37: + movsd %xmm4, 64(%rsp) + movaps %xmm7, %xmm4 + mulsd %xmm7, %xmm4 + movaps %xmm14, %xmm5 + movaps %xmm6, %xmm0 + testl %ecx, %ecx + mulsd %xmm6, %xmm0 + subsd %xmm4, %xmm5 + movaps %xmm9, %xmm4 + mulsd %xmm11, %xmm4 + divsd %xmm4, %xmm5 + movaps %xmm14, %xmm4 + mulsd 32(%rsp), %xmm5 + subsd %xmm0, %xmm4 + movaps %xmm11, %xmm0 + mulsd %xmm8, %xmm0 + divsd %xmm0, %xmm4 + mulsd %xmm5, %xmm4 + jle ..B1.57 +..B1.38: + addsd %xmm5, %xmm1 + addsd %xmm4, %xmm2 +..B1.39: + movsd %xmm4, 32(%rsp) + addsd %xmm10, %xmm9 + mulsd %xmm12, %xmm4 + addsd %xmm10, %xmm8 + addsd %xmm15, %xmm7 + addsd %xmm15, %xmm6 + andps .L_2il0floatpacket.2(%rip), %xmm4 + comisd %xmm4, %xmm13 + jbe ..B1.41 +..B1.40: + movaps %xmm4, %xmm13 + movb $1, %sil + jmp ..B1.42 +..B1.41: + testb %sil, %sil + jne ..B1.44 +..B1.42: + lea _TWO_19H(%rip), %rdi + movaps %xmm1, %xmm4 + negl %ecx + movsd (%rdi), %xmm5 + mulsd %xmm1, %xmm5 + addsd %xmm5, %xmm4 + movsd %xmm4, 56(%rsp) + movsd 56(%rsp), %xmm4 + subsd %xmm5, %xmm4 + ucomisd 64(%rsp), %xmm4 + jne ..B1.37 + jp ..B1.37 +..B1.44: + addl %ebx, %ebx + lea 64(%rsp), %rdi + negl %ebx + lea 32(%rsp), %rsi + decl %ebx + movaps %xmm3, %xmm0 + movl %ebx, %edx + movsd %xmm2, (%rsp) + movsd %xmm1, -24(%rsi) + movsd %xmm3, 16(%rsi) +..___tag_value_ynf.12: + call __libm_sincos_k32@PLT +..___tag_value_ynf.13: +..B1.45: + lea _tonpi(%rip), %rax + movsd 48(%rsp), %xmm3 + movsd 8(%rsp), %xmm1 + movsd (%rsp), %xmm2 + movsd (%rax), %xmm0 + divsd %xmm3, %xmm0 + sqrtsd %xmm0, %xmm0 + mulsd 64(%rsp), %xmm1 + mulsd 32(%rsp), %xmm2 + addsd %xmm2, %xmm1 + mulsd %xmm1, %xmm0 +..B1.46: + movaps %xmm0, %xmm1 + testl %ebp, %ebp + xorps .L_2il0floatpacket.3(%rip), %xmm1 + jne ..L14 + movaps %xmm0, %xmm1 +..L14: + cvtsd2ss %xmm1, %xmm1 + movaps %xmm1, %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.47: + lea _large_value_32(%rip), %rax + shrl $31, %ecx + movss (%rax,%rcx,4), %xmm0 + mulss .L_2il0floatpacket.1(%rip), %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.48: + movl %ecx, %ebp + andl $2147483647, %ebp + cmpl $2139095040, %ebp + ja ..B1.55 +..B1.49: + testl %ebp, %ebp + je ..B1.54 +..B1.50: + testl $-2147483648, %ecx + je ..B1.52 +..B1.51: + lea _zeros(%rip), %rax + lea _infs(%rip), %rdx + movss (%rax), %xmm0 + mulss (%rdx), %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.52: + lea _zeros(%rip), %rax + movl %ebx, %ecx + shrl $31, %ecx + andl %ebx, %ecx + movss (%rax,%rcx,4), %xmm0 +..B1.53: + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.54: + lea 4+_ones(%rip), %rax + lea _zeros(%rip), %rdx + movss (%rax), %xmm0 + divss (%rdx), %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.55: + lea _ones(%rip), %rax + movss (%rsp), %xmm0 + mulss (%rax), %xmm0 + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.57: + subsd %xmm5, %xmm1 + subsd %xmm4, %xmm2 + jmp ..B1.39 +..B1.58: + movss (%rsp), %xmm0 + call y1f@PLT +..B1.65: + movaps %xmm0, %xmm1 + testl %ebp, %ebp + xorps .L_2il0floatpacket.4(%rip), %xmm1 + je ..L63 + movaps %xmm1, %xmm0 +..L63: + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_def_cfa_offset 96 + .cfi_offset 3, -16 + .cfi_offset 6, -24 +..B1.59: + movss (%rsp), %xmm0 + call y0f@PLT +..B1.66: + addq $72, %rsp + .cfi_def_cfa_offset 24 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 16 + .cfi_restore 3 + popq %rbx + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ynf,@function + .size ynf,.-ynf + .data +# -- End ynf + .data + .align 4 + .align 4 +_zeros: + .long 0 + .long 2147483648 + .type _zeros,@object + .size _zeros,8 + .align 4 +_ones: + .long 1065353216 + .long 3212836864 + .type _ones,@object + .size _ones,8 + .align 4 +_infs: + .long 2139095040 + .long 4286578688 + .type _infs,@object + .size _infs,8 + .section .rodata, "a" + .align 16 + .align 16 +.L_2il0floatpacket.2: + .long 0xffffffff,0x7fffffff,0x00000000,0x00000000 + .type .L_2il0floatpacket.2,@object + .size .L_2il0floatpacket.2,16 + .align 16 +.L_2il0floatpacket.3: + .long 0x00000000,0x80000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.3,@object + .size .L_2il0floatpacket.3,16 + .align 16 +.L_2il0floatpacket.4: + .long 0x80000000,0x00000000,0x00000000,0x00000000 + .type .L_2il0floatpacket.4,@object + .size .L_2il0floatpacket.4,16 + .align 4 +.L_2il0floatpacket.0: + .long 0x450e6000 + .type .L_2il0floatpacket.0,@object + .size .L_2il0floatpacket.0,4 + .align 4 +.L_2il0floatpacket.1: + .long 0x71800000 + .type .L_2il0floatpacket.1,@object + .size .L_2il0floatpacket.1,4 + .align 4 +function_zeros: + .long 0x00000000 + .long 0x00000000 + .long 0x00000000 + .long 0x3ecccccd + .long 0x3fa66666 + .long 0x40400000 + .long 0x40a9999a + .long 0x4101999a + .long 0x41366666 + .long 0x4171999a + .long 0x4198cccd + .long 0x41ba6666 + .long 0x41df3333 + .long 0x42026666 + .long 0x42160000 + .long 0x422a0000 + .long 0x423f3333 + .long 0x42546666 + .long 0x426a0000 + .long 0x42803333 + .long 0x428b999a + .long 0x42970000 + .long 0x42a2999a + .long 0x42ae6666 + .long 0x42ba6666 + .long 0x42c66666 + .long 0x42d2999a + .long 0x42decccd + .long 0x42eb3333 + .long 0x42f7999a + .long 0x4302199a + .long 0x43086666 + .long 0x430ecccd + .long 0x43153333 + .long 0x431b999a + .long 0x4322199a + .long 0x4328999a + .long 0x432f199a + .long 0x4335b333 + .long 0x433c3333 + .long 0x4342e666 + .long 0x43498000 + .long 0x43503333 + .long 0x4356e666 + .long 0x435d999a + .long 0x43644ccd + .long 0x436b0000 + .long 0x4371cccd + .long 0x4378999a + .long 0x437f6666 + .long 0x4383199a + .long 0x43868ccd + .long 0x4389f333 + .long 0x438d6666 + .long 0x4390d99a + .long 0x43944ccd + .long 0x4397c000 + .long 0x439b3333 + .long 0x439eb333 + .long 0x43a23333 + .long 0x43a5a666 + .long 0x43a92666 + .long 0x43aca666 + .long 0x43b02666 + .long 0x43b3a666 + .long 0x43b73333 + .long 0x43bab333 + .long 0x43be4000 + .long 0x43c1c000 + .long 0x43c54ccd + .long 0x43c8d99a + .long 0x43cc6666 + .long 0x43cff333 + .long 0x43d38000 + .long 0x43d70ccd + .long 0x43da999a + .long 0x43de2666 + .long 0x43e1c000 + .long 0x43e54ccd + .long 0x43e8e666 + .long 0x43ec8000 + .long 0x43f00ccd + .long 0x43f3a666 + .long 0x43f74000 + .long 0x43fad99a + .long 0x43fe7333 + .long 0x44010666 + .long 0x4402d333 + .long 0x4404a000 + .long 0x44067333 + .long 0x44084000 + .long 0x440a0ccd + .long 0x440be000 + .long 0x440daccd + .long 0x440f8000 + .long 0x44114ccd + .long 0x44132000 + .long 0x4414f333 + .long 0x4416c666 + .long 0x4418999a + .long 0x441a6666 + .long 0x441c399a + .long 0x441e0ccd + .long 0x441fe000 + .long 0x4421b333 + .long 0x44238ccd + .long 0x44256000 + .long 0x44273333 + .long 0x44290666 + .long 0x442ae000 + .long 0x442cb333 + .long 0x442e8666 + .long 0x44306000 + .long 0x44323333 + .long 0x44340ccd + .long 0x4435e000 + .long 0x4437b99a + .long 0x44398ccd + .long 0x443b6666 + .long 0x443d4000 + .long 0x443f199a + .long 0x4440eccd + .long 0x4442c666 + .long 0x4444a000 + .long 0x4446799a + .long 0x44485333 + .long 0x444a2ccd + .long 0x444c0666 + .long 0x444de000 + .long 0x444fb99a + .long 0x44519333 + .long 0x44536ccd + .long 0x44554666 + .long 0x44572000 + .long 0x44590000 + .long 0x445ad99a + .long 0x445cb333 + .long 0x445e9333 + .long 0x44606ccd + .long 0x44624666 + .long 0x44642666 + .long 0x44660000 + .long 0x4467d99a + .long 0x4469b99a + .long 0x446b9333 + .long 0x446d7333 + .long 0x446f5333 + .long 0x44712ccd + .long 0x44730ccd + .long 0x4474e666 + .long 0x4476c666 + .long 0x4478a666 + .long 0x447a8000 + .long 0x447c6000 + .long 0x447e4000 + .long 0x44801000 + .long 0x4480fccd + .long 0x4481eccd + .long 0x4482dccd + .long 0x4483cccd + .long 0x4484bccd + .long 0x4485accd + .long 0x44869ccd + .long 0x44878ccd + .long 0x44887ccd + .long 0x44896ccd + .long 0x448a5ccd + .long 0x448b4ccd + .long 0x448c3ccd + .long 0x448d2ccd + .long 0x448e1ccd + .long 0x448f0ccd + .long 0x448ffccd + .long 0x4490eccd + .long 0x4491e000 + .long 0x4492d000 + .long 0x4493c000 + .long 0x4494b000 + .long 0x4495a333 + .long 0x44969333 + .long 0x44978333 + .long 0x44987333 + .long 0x44996666 + .long 0x449a5666 + .long 0x449b499a + .long 0x449c399a + .long 0x449d299a + .long 0x449e1ccd + .long 0x449f0ccd + .long 0x44a00000 + .long 0x44a0f000 + .long 0x44a1e333 + .long 0x44a2d333 + .long 0x44a3c666 + .long 0x44a4b666 + .long 0x44a5a99a + .long 0x44a6999a + .long 0x44a78ccd + .long 0x44a87ccd + .long 0x44a97000 + .long 0x44aa6333 + .long 0x44ab5333 + .long 0x44ac4666 + .long 0x44ad399a + .long 0x44ae299a + .long 0x44af1ccd + .long 0x44b01000 + .long 0x44b10333 + .long 0x44b1f333 + .long 0x44b2e666 + .long 0x44b3d99a + .long 0x44b4cccd + .long 0x44b5bccd + .long 0x44b6b000 + .long 0x44b7a333 + .long 0x44b89666 + .long 0x44b9899a + .long 0x44ba7ccd + .long 0x44bb6ccd + .long 0x44bc6000 + .long 0x44bd5333 + .long 0x44be4666 + .long 0x44bf399a + .long 0x44c02ccd + .long 0x44c12000 + .long 0x44c21333 + .long 0x44c30666 + .long 0x44c3f99a + .long 0x44c4eccd + .long 0x44c5e000 + .long 0x44c6d333 + .long 0x44c7c666 + .long 0x44c8b99a + .long 0x44c9accd + .long 0x44caa000 + .long 0x44cb9333 + .long 0x44cc899a + .long 0x44cd7ccd + .long 0x44ce7000 + .long 0x44cf6333 + .long 0x44d05666 + .long 0x44d1499a + .long 0x44d23ccd + .long 0x44d33333 + .long 0x44d42666 + .long 0x44d5199a + .long 0x44d60ccd + .long 0x44d70000 + .long 0x44d7f666 + .long 0x44d8e99a + .long 0x44d9dccd + .long 0x44dad000 + .long 0x44dbc666 + .long 0x44dcb99a + .long 0x44ddaccd + .long 0x44dea333 + .long 0x44df9666 + .long 0x44e0899a + .long 0x44e18000 + .long 0x44e27333 + .long 0x44e36666 + .long 0x44e45ccd + .long 0x44e55000 + .long 0x44e64333 + .long 0x44e7399a + .long 0x44e82ccd + .long 0x44e92333 + .long 0x44ea1666 + .long 0x44eb099a + .long 0x44ec0000 + .long 0x44ecf333 + .long 0x44ede99a + .long 0x44eedccd + .long 0x44efd333 + .long 0x44f0c666 + .long 0x44f1bccd + .long 0x44f2b000 + .long 0x44f3a666 + .long 0x44f4999a + .long 0x44f59000 + .long 0x44f68333 + .long 0x44f7799a + .long 0x44f86ccd + .long 0x44f96333 + .long 0x44fa599a + .long 0x44fb4ccd + .long 0x44fc4333 + .long 0x44fd3666 + .long 0x44fe2ccd + .long 0x44ff2000 + .long 0x45000b33 + .long 0x45008666 + .long 0x45010000 + .long 0x45017000 + .long 0x4501f000 + .long 0x45027000 + .long 0x4502e000 + .long 0x45036000 + .long 0x4503e000 + .long 0x45045000 + .long 0x4504d000 + .long 0x45055000 + .long 0x4505c000 + .long 0x45064000 + .long 0x4506c000 + .long 0x45073000 + .long 0x4507b000 + .long 0x45083000 + .long 0x4508a000 + .long 0x45092000 + .long 0x4509a000 + .long 0x450a1000 + .long 0x450a9000 + .long 0x450b1000 + .long 0x450b8000 + .long 0x450c0000 + .long 0x450c8000 + .long 0x450cf000 + .long 0x450d7000 + .long 0x450df000 + .long 0x450e6000 + .type function_zeros,@object + .size function_zeros,1284 + .align 4 +_val_0_6: + .long 858993459 + .long 1071854387 + .type _val_0_6,@object + .size _val_0_6,8 + .align 4 +_val_2_0: + .long 0 + .long 1073741824 + .type _val_2_0,@object + .size _val_2_0,8 + .align 4 +_TWO_19H: + .long 0 + .long 1093140480 + .type _TWO_19H,@object + .size _TWO_19H,8 + .align 4 +_eulon2: + .long 3400611180 + .long 1072463685 + .type _eulon2,@object + .size _eulon2,8 + .align 4 +_tonpi: + .long 1841940611 + .long 1071931184 + .type _tonpi,@object + .size _tonpi,8 + .align 4 +_oonpi: + .long 1841940611 + .long 1070882608 + .type _oonpi,@object + .size _oonpi,8 + .align 4 +_val_18_0: + .long 0 + .long 1077018624 + .type _val_18_0,@object + .size _val_18_0,8 + .align 4 +_val_16_0: + .long 0 + .long 1076887552 + .type _val_16_0,@object + .size _val_16_0,8 + .align 4 +_PP1: + .long 551 + .long 1072693248 + .long 4267608614 + .long 1061027839 + .long 3690881252 + .long 3200414971 + .long 3933039373 + .long 1046848465 + .long 3246008603 + .long 3189439465 + .long 1689113401 + .long 1037483563 + .type _PP1,@object + .size _PP1,48 + .align 4 +_PP0: + .long 4294966288 + .long 1072693247 + .long 4269912424 + .long 3207725055 + .long 1780799603 + .long 1052554744 + .long 2285933488 + .long 3194113879 + .long 3892950982 + .long 1041746526 + .long 150212775 + .long 3184818833 + .type _PP0,@object + .size _PP0,48 + .align 4 +_QP0: + .long 4294921804 + .long 3212836863 + .long 4153409851 + .long 1056096255 + .long 2226361937 + .long 3196916170 + .long 3849695089 + .long 1044094312 + .long 663042994 + .long 3187124278 + .long 3336948587 + .long 1035486718 + .type _QP0,@object + .size _QP0,48 + .align 4 +_QP1: + .long 4294954956 + .long 1066926079 + .long 4141388976 + .long 3204071423 + .long 1500123100 + .long 1049740228 + .long 3264213437 + .long 3191856517 + .long 1489731078 + .long 1039824630 + .long 1807021260 + .long 3183130166 + .type _QP1,@object + .size _QP1,48 + .align 4 +_val_4_0: + .long 0 + .long 1074790400 + .type _val_4_0,@object + .size _val_4_0,8 + .align 4 +_val_5_0: + .long 0 + .long 1075052544 + .type _val_5_0,@object + .size _val_5_0,8 + .align 4 +_val_8_0: + .long 0 + .long 1075838976 + .type _val_8_0,@object + .size _val_8_0,8 + .align 4 +_val_3_0: + .long 0 + .long 1074266112 + .type _val_3_0,@object + .size _val_3_0,8 + .align 4 +_large_value_32: + .long 1904214016 + .long 4051697664 + .type _large_value_32,@object + .size _large_value_32,8 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/intel64/ynl.S b/external/sgx_libm/intel64/ynl.S new file mode 100644 index 0000000000..1c5b35aa9f --- /dev/null +++ b/external/sgx_libm/intel64/ynl.S @@ -0,0 +1,95 @@ +/* +* Math library +* +* Copyright (C) 2016 Intel Corporation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* +* Author Name +* History: +* 03-14-2016 Initial version. numerics svn rev. 12864 +*/ + .file "ynl.c" + .text +..TXTST0: +# -- Begin ynl + .text + .align 16,0x90 + .globl ynl +ynl: +# parameter 1: %edi +# parameter 2: 32 + %rsp +..B1.1: + .cfi_startproc +..___tag_value_ynl.1: +..L2: + + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + subq $16, %rsp + .cfi_def_cfa_offset 32 + movl %edi, %ebp + fldt 32(%rsp) + addq $-16, %rsp + .cfi_def_cfa_offset 48 + lea 16(%rsp), %rdi + fstpt (%rsp) + call __ltoq@PLT +..B1.6: + addq $16, %rsp + .cfi_def_cfa_offset 32 + movl %ebp, %edi + movaps (%rsp), %xmm0 +..___tag_value_ynl.8: + call __ynq@PLT +..___tag_value_ynl.9: +..B1.2: + movaps %xmm0, (%rsp) + lea (%rsp), %rdi + call __qtol@PLT +..B1.7: + addq $16, %rsp + .cfi_def_cfa_offset 16 + .cfi_restore 6 + popq %rbp + .cfi_def_cfa_offset 8 + ret + .align 16,0x90 + .cfi_endproc + .type ynl,@function + .size ynl,.-ynl + .data +# -- End ynl + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 1 +# End diff --git a/external/sgx_libm/makefile b/external/sgx_libm/makefile new file mode 100644 index 0000000000..e275bca40f --- /dev/null +++ b/external/sgx_libm/makefile @@ -0,0 +1,25 @@ +ARCH ?= intel64 +.PHONE: lib clean +all: lib + cp $(ARCH)/libm.a libm.a +ifeq ($(ARCH),ia32) +CFLAGS := -m32 +endif + +SRC_FILES := $(wildcard $(ARCH)/*.S) +OBJ_FILES := $(SRC_FILES:.S=.o) +STATIC_LIB:= $(ARCH)/libm.a +SHARED_LIB:= $(ARCH)/libm.so +lib : $(STATIC_LIB) $(SHARED_LIB) + +%.o : %.S + gcc $(CFLAGS) -c $< -o $@ + +$(STATIC_LIB) : $(OBJ_FILES) + ar crv $@ $^ + +$(SHARED_LIB) : $(OBJ_FILES) + gcc $(CFLAGS) -shared -o $@ $^ + +clean: + -rm -rf $(OBJ_FILES) $(STATIC_LIB) $(SHARED_LIB) libm.a diff --git a/external/tinyxml/tinystr.cpp b/external/tinyxml/tinystr.cpp new file mode 100644 index 0000000000..07047a77ba --- /dev/null +++ b/external/tinyxml/tinystr.cpp @@ -0,0 +1,117 @@ +/* +www.sourceforge.net/projects/tinyxml +Original file by Yves Berquin. + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +/* + * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005. + */ + + + +#ifndef TIXML_USE_STL + +#include "tinystr.h" + +// Error value for find primitive +const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); + + +// Null rep. +TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; + + +void TiXmlString::reserve (size_type cap) +{ + if (cap > capacity()) + { + TiXmlString tmp; + tmp.init(length(), cap); + memcpy(tmp.start(), data(), length()); + swap(tmp); + } +} + + +TiXmlString& TiXmlString::assign(const char* str, size_type len) +{ + size_type cap = capacity(); + if (len > cap || cap > 3*(len + 8)) + { + TiXmlString tmp; + tmp.init(len); + memcpy(tmp.start(), str, len); + swap(tmp); + } + else + { + memmove(start(), str, len); + set_size(len); + } + return *this; +} + + +TiXmlString& TiXmlString::append(const char* str, size_type len) +{ + size_type newsize = length() + len; + if (newsize > capacity()) + { + reserve (newsize + capacity()); + } + memmove(finish(), str, len); + set_size(newsize); + return *this; +} + + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) +{ + TiXmlString tmp; + tmp.reserve(a.length() + b.length()); + tmp += a; + tmp += b; + return tmp; +} + +TiXmlString operator + (const TiXmlString & a, const char* b) +{ + TiXmlString tmp; + TiXmlString::size_type b_len = static_cast( strlen(b) ); + tmp.reserve(a.length() + b_len); + tmp += a; + tmp.append(b, b_len); + return tmp; +} + +TiXmlString operator + (const char* a, const TiXmlString & b) +{ + TiXmlString tmp; + TiXmlString::size_type a_len = static_cast( strlen(a) ); + tmp.reserve(a_len + b.length()); + tmp.append(a, a_len); + tmp += b; + return tmp; +} + + +#endif // TIXML_USE_STL diff --git a/external/tinyxml/tinystr.h b/external/tinyxml/tinystr.h new file mode 100644 index 0000000000..3c2aa9d54d --- /dev/null +++ b/external/tinyxml/tinystr.h @@ -0,0 +1,319 @@ +/* +www.sourceforge.net/projects/tinyxml +Original file by Yves Berquin. + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +/* + * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005. + * + * - completely rewritten. compact, clean, and fast implementation. + * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems) + * - fixed reserve() to work as per specification. + * - fixed buggy compares operator==(), operator<(), and operator>() + * - fixed operator+=() to take a const ref argument, following spec. + * - added "copy" constructor with length, and most compare operators. + * - added swap(), clear(), size(), capacity(), operator+(). + */ + +#ifndef TIXML_USE_STL + +#ifndef TIXML_STRING_INCLUDED +#define TIXML_STRING_INCLUDED + +#include +#include + +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: +*/ +#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + #define TIXML_EXPLICIT explicit +#elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + #define TIXML_EXPLICIT explicit +#else + #define TIXML_EXPLICIT +#endif + + +/* + TiXmlString is an emulation of a subset of the std::string template. + Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. + Only the member functions relevant to the TinyXML project have been implemented. + The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase + a string and there's no more room, we allocate a buffer twice as big as we need. +*/ +class TiXmlString +{ + public : + // The size type used + typedef size_t size_type; + + // Error value for find primitive + static const size_type npos; // = -1; + + + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + // = operator + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + // = operator + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) + { + // Lee: the original form: + // rep_ = static_cast(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; + } + else + { + rep_ = &nullrep_; + } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; + +} ; + + +inline bool operator == (const TiXmlString & a, const TiXmlString & b) +{ + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare +} +inline bool operator < (const TiXmlString & a, const TiXmlString & b) +{ + return strcmp(a.c_str(), b.c_str()) < 0; +} + +inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } +inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } +inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } +inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } + +inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } +inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } +inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } +inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); +TiXmlString operator + (const TiXmlString & a, const char* b); +TiXmlString operator + (const char* a, const TiXmlString & b); + + +/* + TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. + Only the operators that we need for TinyXML have been developped. +*/ +class TiXmlOutStream : public TiXmlString +{ +public : + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } + +} ; + +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL diff --git a/external/tinyxml/tinyxml.cpp b/external/tinyxml/tinyxml.cpp new file mode 100644 index 0000000000..968f2409c3 --- /dev/null +++ b/external/tinyxml/tinyxml.cpp @@ -0,0 +1,1840 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#include + +#ifdef TIXML_USE_STL +#include +#include +#endif + +#include "tinyxml.h" + +FILE* TiXmlFOpen( const char* filename, const char* mode ); + +bool TiXmlBase::condenseWhiteSpace = true; + +// Microsoft compiler security +FILE* TiXmlFOpen( const char* filename, const char* mode ) +{ + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + FILE* fp = 0; + errno_t err = fopen_s( &fp, filename, mode ); + if ( !err && fp ) + return fp; + return 0; + #else + return fopen( filename, mode ); + #endif +} + +void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) +{ + int i=0; + + while( i<(int)str.length() ) + { + unsigned char c = (unsigned char) str[i]; + + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) + { + // Hexadecimal character reference. + // Pass through unchanged. + // © -- copyright symbol, for example. + // + // The -1 is a bug fix from Rob Laveaux. It keeps + // an overflow from happening if there is no ';'. + // There are actually 2 ways to exit this loop - + // while fails (error case) and break (semicolon found). + // However, there is no mechanism (currently) for + // this function to return an error. + while ( i<(int)str.length()-1 ) + { + outString->append( str.c_str() + i, 1 ); + ++i; + if ( str[i] == ';' ) + break; + } + } + else if ( c == '&' ) + { + outString->append( entity[0].str, entity[0].strLength ); + ++i; + } + else if ( c == '<' ) + { + outString->append( entity[1].str, entity[1].strLength ); + ++i; + } + else if ( c == '>' ) + { + outString->append( entity[2].str, entity[2].strLength ); + ++i; + } + else if ( c == '\"' ) + { + outString->append( entity[3].str, entity[3].strLength ); + ++i; + } + else if ( c == '\'' ) + { + outString->append( entity[4].str, entity[4].strLength ); + ++i; + } + else if ( c < 32 ) + { + // Easy pass at non-alpha/numeric/symbol + // Below 32 is symbolic. + char buf[ 32 ]; + + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); + #else + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); + #endif + + //*ME: warning C4267: convert 'size_t' to 'int' + //*ME: Int-Cast to make compiler happy ... + outString->append( buf, (int)strlen( buf ) ); + ++i; + } + else + { + //char realc = (char) c; + //outString->append( &realc, 1 ); + *outString += (char) c; // somewhat more efficient function call. + ++i; + } + } +} + + +TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() +{ + parent = 0; + type = _type; + firstChild = 0; + lastChild = 0; + prev = 0; + next = 0; +} + + +TiXmlNode::~TiXmlNode() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } +} + + +void TiXmlNode::CopyTo( TiXmlNode* target ) const +{ + target->SetValue (value.c_str() ); + target->userData = userData; + target->location = location; +} + + +void TiXmlNode::Clear() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } + + firstChild = 0; + lastChild = 0; +} + + +TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) +{ + assert( node->parent == 0 || node->parent == this ); + assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + + if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + delete node; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + node->parent = this; + + node->prev = lastChild; + node->next = 0; + + if ( lastChild ) + lastChild->next = node; + else + firstChild = node; // it was an empty list. + + lastChild = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) +{ + if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + + return LinkEndChild( node ); +} + + +TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) +{ + if ( !beforeThis || beforeThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->next = beforeThis; + node->prev = beforeThis->prev; + if ( beforeThis->prev ) + { + beforeThis->prev->next = node; + } + else + { + assert( firstChild == beforeThis ); + firstChild = node; + } + beforeThis->prev = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) +{ + if ( !afterThis || afterThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->prev = afterThis; + node->next = afterThis->next; + if ( afterThis->next ) + { + afterThis->next->prev = node; + } + else + { + assert( lastChild == afterThis ); + lastChild = node; + } + afterThis->next = node; + return node; +} + + +TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) +{ + if ( !replaceThis ) + return 0; + + if ( replaceThis->parent != this ) + return 0; + + if ( withThis.ToDocument() ) { + // A document can never be a child. Thanks to Noam. + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = withThis.Clone(); + if ( !node ) + return 0; + + node->next = replaceThis->next; + node->prev = replaceThis->prev; + + if ( replaceThis->next ) + replaceThis->next->prev = node; + else + lastChild = node; + + if ( replaceThis->prev ) + replaceThis->prev->next = node; + else + firstChild = node; + + delete replaceThis; + node->parent = this; + return node; +} + + +bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) +{ + if ( !removeThis ) { + return false; + } + + if ( removeThis->parent != this ) + { + assert( 0 ); + return false; + } + + if ( removeThis->next ) + removeThis->next->prev = removeThis->prev; + else + lastChild = removeThis->prev; + + if ( removeThis->prev ) + removeThis->prev->next = removeThis->next; + else + firstChild = removeThis->next; + + delete removeThis; + return true; +} + +const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = firstChild; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = lastChild; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild(); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling(); + } +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild( val ); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling( val ); + } +} + + +const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = next; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = prev; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +void TiXmlElement::RemoveAttribute( const char * name ) +{ + #ifdef TIXML_USE_STL + TIXML_STRING str( name ); + TiXmlAttribute* node = attributeSet.Find( str ); + #else + TiXmlAttribute* node = attributeSet.Find( name ); + #endif + if ( node ) + { + attributeSet.Remove( node ); + delete node; + } +} + +const TiXmlElement* TiXmlNode::FirstChildElement() const +{ + const TiXmlNode* node; + + for ( node = FirstChild(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = FirstChild( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement() const +{ + const TiXmlNode* node; + + for ( node = NextSibling(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = NextSibling( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlDocument* TiXmlNode::GetDocument() const +{ + const TiXmlNode* node; + + for( node = this; node; node = node->parent ) + { + if ( node->ToDocument() ) + return node->ToDocument(); + } + return 0; +} + + +TiXmlElement::TiXmlElement (const char * _value) + : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} + + +#ifdef TIXML_USE_STL +TiXmlElement::TiXmlElement( const std::string& _value ) + : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} +#endif + + +TiXmlElement::TiXmlElement( const TiXmlElement& copy) + : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) +{ + firstChild = lastChild = 0; + copy.CopyTo( this ); +} + + +void TiXmlElement::operator=( const TiXmlElement& base ) +{ + ClearThis(); + base.CopyTo( this ); +} + + +TiXmlElement::~TiXmlElement() +{ + ClearThis(); +} + + +void TiXmlElement::ClearThis() +{ + Clear(); + while( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } +} + + +const char* TiXmlElement::Attribute( const char* name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return node->Value(); + return 0; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( attrib ) + return &attrib->ValueStr(); + return 0; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, int* i ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const char* result = 0; + + if ( attrib ) { + result = attrib->Value(); + if ( i ) { + attrib->QueryIntValue( i ); + } + } + return result; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const std::string* result = 0; + + if ( attrib ) { + result = &attrib->ValueStr(); + if ( i ) { + attrib->QueryIntValue( i ); + } + } + return result; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, double* d ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const char* result = 0; + + if ( attrib ) { + result = attrib->Value(); + if ( d ) { + attrib->QueryDoubleValue( d ); + } + } + return result; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const std::string* result = 0; + + if ( attrib ) { + result = &attrib->ValueStr(); + if ( d ) { + attrib->QueryDoubleValue( d ); + } + } + return result; +} +#endif + + +int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryIntValue( ival ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryIntValue( ival ); +} +#endif + + +int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryDoubleValue( dval ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryDoubleValue( dval ); +} +#endif + + +void TiXmlElement::SetAttribute( const char * name, int val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetIntValue( val ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, int val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetIntValue( val ); + } +} +#endif + + +void TiXmlElement::SetDoubleAttribute( const char * name, double val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetDoubleValue( val ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetDoubleAttribute( const std::string& name, double val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetDoubleValue( val ); + } +} +#endif + + +void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); + if ( attrib ) { + attrib->SetValue( cvalue ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); + if ( attrib ) { + attrib->SetValue( _value ); + } +} +#endif + + +void TiXmlElement::Print( FILE* cfile, int depth ) const +{ + int i; + assert( cfile ); + for ( i=0; iNext() ) + { + fprintf( cfile, " " ); + attrib->Print( cfile, depth ); + } + + // There are 3 different formatting approaches: + // 1) An element without children is printed as a node + // 2) An element with only a text child is printed as text + // 3) An element with children is printed on multiple lines. + TiXmlNode* node; + if ( !firstChild ) + { + fprintf( cfile, " />" ); + } + else if ( firstChild == lastChild && firstChild->ToText() ) + { + fprintf( cfile, ">" ); + firstChild->Print( cfile, depth + 1 ); + fprintf( cfile, "", value.c_str() ); + } + else + { + fprintf( cfile, ">" ); + + for ( node = firstChild; node; node=node->NextSibling() ) + { + if ( !node->ToText() ) + { + fprintf( cfile, "\n" ); + } + node->Print( cfile, depth+1 ); + } + fprintf( cfile, "\n" ); + for( i=0; i", value.c_str() ); + } +} + + +void TiXmlElement::CopyTo( TiXmlElement* target ) const +{ + // superclass: + TiXmlNode::CopyTo( target ); + + // Element class: + // Clone the attributes, then clone the children. + const TiXmlAttribute* attribute = 0; + for( attribute = attributeSet.First(); + attribute; + attribute = attribute->Next() ) + { + target->SetAttribute( attribute->Name(), attribute->Value() ); + } + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + +bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this, attributeSet.First() ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +TiXmlNode* TiXmlElement::Clone() const +{ + TiXmlElement* clone = new TiXmlElement( Value() ); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +const char* TiXmlElement::GetText() const +{ + const TiXmlNode* child = this->FirstChild(); + if ( child ) { + const TiXmlText* childText = child->ToText(); + if ( childText ) { + return childText->Value(); + } + } + return 0; +} + + +TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + ClearError(); +} + +TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} + + +#ifdef TIXML_USE_STL +TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} +#endif + + +TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDocument::operator=( const TiXmlDocument& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) +{ + return LoadFile( Value(), encoding ); +} + + +bool TiXmlDocument::SaveFile() const +{ + return SaveFile( Value() ); +} + +bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) +{ + TIXML_STRING filename( _filename ); + value = filename; + + // reading in binary mode so that tinyxml can normalize the EOL + FILE* file = TiXmlFOpen( value.c_str (), "rb" ); + + if ( file ) + { + bool result = LoadFile( file, encoding ); + fclose( file ); + return result; + } + else + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } +} + +bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) +{ + if ( !file ) + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Delete the existing data: + Clear(); + location.Clear(); + + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); + + // Strange case, but good to handle up front. + if ( length <= 0 ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Subtle bug here. TinyXml did use fgets. But from the XML spec: + // 2.11 End-of-Line Handling + // + // + // ...the XML processor MUST behave as if it normalized all line breaks in external + // parsed entities (including the document entity) on input, before parsing, by translating + // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to + // a single #xA character. + // + // + // It is not clear fgets does that, and certainly isn't clear it works cross platform. + // Generally, you expect fgets to translate from the convention of the OS to the c/unix + // convention, and not work generally. + + /* + while( fgets( buf, sizeof(buf), file ) ) + { + data += buf; + } + */ + + char* buf = new char[ length+1 ]; + buf[0] = 0; + + if ( fread( buf, length, 1, file ) != 1 ) { + delete [] buf; + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Process the buffer in place to normalize new lines. (See comment above.) + // Copies from the 'p' to 'q' pointer, where p can advance faster if + // a newline-carriage return is hit. + // + // Wikipedia: + // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or + // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... + // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others + // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS + // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 + + const char* p = buf; // the read head + char* q = buf; // the write head + const char CR = 0x0d; + const char LF = 0x0a; + + buf[length] = 0; + while( *p ) { + assert( p < (buf+length) ); + assert( q <= (buf+length) ); + assert( q <= p ); + + if ( *p == CR ) { + *q++ = LF; + p++; + if ( *p == LF ) { // check for CR+LF (and skip LF) + p++; + } + } + else { + *q++ = *p++; + } + } + assert( q <= (buf+length) ); + *q = 0; + + Parse( buf, 0, encoding ); + + delete [] buf; + return !Error(); +} + + +bool TiXmlDocument::SaveFile( const char * filename ) const +{ + // The old c stuff lives on... + FILE* fp = TiXmlFOpen( filename, "w" ); + if ( fp ) + { + bool result = SaveFile( fp ); + fclose( fp ); + return result; + } + return false; +} + + +bool TiXmlDocument::SaveFile( FILE* fp ) const +{ + if ( useMicrosoftBOM ) + { + const unsigned char TIXML_UTF_LEAD_0 = 0xefU; + const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; + const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + + fputc( TIXML_UTF_LEAD_0, fp ); + fputc( TIXML_UTF_LEAD_1, fp ); + fputc( TIXML_UTF_LEAD_2, fp ); + } + Print( fp, 0 ); + return (ferror(fp) == 0); +} + + +void TiXmlDocument::CopyTo( TiXmlDocument* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->error = error; + target->errorId = errorId; + target->errorDesc = errorDesc; + target->tabsize = tabsize; + target->errorLocation = errorLocation; + target->useMicrosoftBOM = useMicrosoftBOM; + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + + +TiXmlNode* TiXmlDocument::Clone() const +{ + TiXmlDocument* clone = new TiXmlDocument(); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlDocument::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + node->Print( cfile, depth ); + fprintf( cfile, "\n" ); + } +} + + +bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +const TiXmlAttribute* TiXmlAttribute::Next() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} + +/* +TiXmlAttribute* TiXmlAttribute::Next() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} +*/ + +const TiXmlAttribute* TiXmlAttribute::Previous() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} + +/* +TiXmlAttribute* TiXmlAttribute::Previous() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} +*/ + +void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + TIXML_STRING n, v; + + EncodeString( name, &n ); + EncodeString( value, &v ); + + if (value.find ('\"') == TIXML_STRING::npos) { + if ( cfile ) { + fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; + } + } + else { + if ( cfile ) { + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; + } + } +} + + +int TiXmlAttribute::QueryIntValue( int* ival ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +int TiXmlAttribute::QueryDoubleValue( double* dval ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +void TiXmlAttribute::SetIntValue( int _value ) +{ + char buf [64]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); + #else + sprintf (buf, "%d", _value); + #endif + SetValue (buf); +} + +void TiXmlAttribute::SetDoubleValue( double _value ) +{ + char buf [256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); + #else + sprintf (buf, "%g", _value); + #endif + SetValue (buf); +} + +int TiXmlAttribute::IntValue() const +{ + return atoi (value.c_str ()); +} + +double TiXmlAttribute::DoubleValue() const +{ + return atof (value.c_str ()); +} + + +TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlComment::operator=( const TiXmlComment& base ) +{ + Clear(); + base.CopyTo( this ); +} + + +void TiXmlComment::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlComment::CopyTo( TiXmlComment* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlComment::Clone() const +{ + TiXmlComment* clone = new TiXmlComment(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlText::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + if ( cdata ) + { + int i; + fprintf( cfile, "\n" ); + for ( i=0; i\n", value.c_str() ); // unformatted output + } + else + { + TIXML_STRING buffer; + EncodeString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); + } +} + + +void TiXmlText::CopyTo( TiXmlText* target ) const +{ + TiXmlNode::CopyTo( target ); + target->cdata = cdata; +} + + +bool TiXmlText::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlText::Clone() const +{ + TiXmlText* clone = 0; + clone = new TiXmlText( "" ); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlDeclaration::TiXmlDeclaration( const char * _version, + const char * _encoding, + const char * _standalone ) + : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} + + +#ifdef TIXML_USE_STL +TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ) + : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} +#endif + + +TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) + : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + if ( cfile ) fprintf( cfile, "" ); + if ( str ) (*str) += "?>"; +} + + +void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->version = version; + target->encoding = encoding; + target->standalone = standalone; +} + + +bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlDeclaration::Clone() const +{ + TiXmlDeclaration* clone = new TiXmlDeclaration(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlUnknown::Print( FILE* cfile, int depth ) const +{ + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlUnknown::Clone() const +{ + TiXmlUnknown* clone = new TiXmlUnknown(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlAttributeSet::TiXmlAttributeSet() +{ + sentinel.next = &sentinel; + sentinel.prev = &sentinel; +} + + +TiXmlAttributeSet::~TiXmlAttributeSet() +{ + assert( sentinel.next == &sentinel ); + assert( sentinel.prev == &sentinel ); +} + + +void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) +{ + #ifdef TIXML_USE_STL + assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. + #else + assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. + #endif + + addMe->next = &sentinel; + addMe->prev = sentinel.prev; + + sentinel.prev->next = addMe; + sentinel.prev = addMe; +} + +void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) +{ + TiXmlAttribute* node; + + for( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node == removeMe ) + { + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = 0; + node->prev = 0; + return; + } + } + assert( 0 ); // we tried to remove a non-linked attribute. +} + + +#ifdef TIXML_USE_STL +TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} + +TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) +{ + TiXmlAttribute* attrib = Find( _name ); + if ( !attrib ) { + attrib = new TiXmlAttribute(); + Add( attrib ); + attrib->SetName( _name ); + } + return attrib; +} +#endif + + +TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} + + +TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) +{ + TiXmlAttribute* attrib = Find( _name ); + if ( !attrib ) { + attrib = new TiXmlAttribute(); + Add( attrib ); + attrib->SetName( _name ); + } + return attrib; +} + + +#ifdef TIXML_USE_STL +std::istream& operator>> (std::istream & in, TiXmlNode & base) +{ + TIXML_STRING tag; + tag.reserve( 8 * 1000 ); + base.StreamIn( &in, &tag ); + + base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + return in; +} +#endif + + +#ifdef TIXML_USE_STL +std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out << printer.Str(); + + return out; +} + + +std::string& operator<< (std::string& out, const TiXmlNode& base ) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out.append( printer.Str() ); + + return out; +} +#endif + + +TiXmlHandle TiXmlHandle::FirstChild() const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement() const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild(); + for ( i=0; + child && iNextSibling(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild( value ); + for ( i=0; + child && iNextSibling( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement(); + for ( i=0; + child && iNextSiblingElement(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement( value ); + for ( i=0; + child && iNextSiblingElement( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) +{ + DoIndent(); + buffer += "<"; + buffer += element.Value(); + + for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) + { + buffer += " "; + attrib->Print( 0, 0, &buffer ); + } + + if ( !element.FirstChild() ) + { + buffer += " />"; + DoLineBreak(); + } + else + { + buffer += ">"; + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) + { + simpleTextPrint = true; + // no DoLineBreak()! + } + else + { + DoLineBreak(); + } + } + ++depth; + return true; +} + + +bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) +{ + --depth; + if ( !element.FirstChild() ) + { + // nothing. + } + else + { + if ( simpleTextPrint ) + { + simpleTextPrint = false; + } + else + { + DoIndent(); + } + buffer += ""; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlText& text ) +{ + if ( text.CDATA() ) + { + DoIndent(); + buffer += ""; + DoLineBreak(); + } + else if ( simpleTextPrint ) + { + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + } + else + { + DoIndent(); + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) +{ + DoIndent(); + declaration.Print( 0, 0, &buffer ); + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlComment& comment ) +{ + DoIndent(); + buffer += ""; + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) +{ + DoIndent(); + buffer += "<"; + buffer += unknown.Value(); + buffer += ">"; + DoLineBreak(); + return true; +} + diff --git a/external/tinyxml/tinyxml.h b/external/tinyxml/tinyxml.h new file mode 100644 index 0000000000..01822911c7 --- /dev/null +++ b/external/tinyxml/tinyxml.h @@ -0,0 +1,1799 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TINYXML_INCLUDED +#define TINYXML_INCLUDED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4530 ) +#pragma warning( disable : 4786 ) +#endif + +#include +#include +#include +#include +#include + +// Help out windows: +#if defined( _DEBUG ) && !defined( DEBUG ) +#define DEBUG +#endif + +#ifdef TIXML_USE_STL + #include + #include + #include + #define TIXML_STRING std::string +#else + #include "tinystr.h" + #define TIXML_STRING TiXmlString +#endif + +// Deprecated library function hell. Compilers want to use the +// new safe versions. This probably doesn't fully address the problem, +// but it gets closer. There are too many compilers for me to fully +// test. If you get compilation troubles, undefine TIXML_SAFE +#define TIXML_SAFE + +#ifdef TIXML_SAFE + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + // Microsoft visual studio, version 2005 and higher. + #define TIXML_SNPRINTF _snprintf_s + #define TIXML_SSCANF sscanf_s + #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + //#pragma message( "Using _sn* functions." ) + #define TIXML_SNPRINTF _snprintf + #define TIXML_SSCANF sscanf + #elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_SSCANF sscanf + #else + #define TIXML_SNPRINTF snprintf + #define TIXML_SSCANF sscanf + #endif +#endif + +class TiXmlDocument; +class TiXmlElement; +class TiXmlComment; +class TiXmlUnknown; +class TiXmlAttribute; +class TiXmlText; +class TiXmlDeclaration; +class TiXmlParsingData; + +const int TIXML_MAJOR_VERSION = 2; +const int TIXML_MINOR_VERSION = 6; +const int TIXML_PATCH_VERSION = 1; + +/* Internal structure for tracking location of items + in the XML file. +*/ +struct TiXmlCursor +{ + TiXmlCursor() { Clear(); } + void Clear() { row = col = -1; } + + int row; // 0 based. + int col; // 0 based. +}; + + +/** + Implements the interface to the "Visitor pattern" (see the Accept() method.) + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simply called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its sibilings will be Visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + + You should never change the document from a callback. + + @sa TiXmlNode::Accept() +*/ +class TiXmlVisitor +{ +public: + virtual ~TiXmlVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } + /// Visit a document. + virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } + + /// Visit an element. + virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } + /// Visit an element. + virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } + + /// Visit a declaration + virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } + /// Visit a text node + virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } + /// Visit a comment node + virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } + /// Visit an unknow node + virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } +}; + +// Only used by Attribute::Query functions +enum +{ + TIXML_SUCCESS, + TIXML_NO_ATTRIBUTE, + TIXML_WRONG_TYPE +}; + + +// Used by the parsing routines. +enum TiXmlEncoding +{ + TIXML_ENCODING_UNKNOWN, + TIXML_ENCODING_UTF8, + TIXML_ENCODING_LEGACY +}; + +const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; + +/** TiXmlBase is a base class for every class in TinyXml. + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. + + In XML, the document and elements can contain + other elements and other types of nodes. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + A Decleration contains: Attributes (not on tree) + @endverbatim +*/ +class TiXmlBase +{ + friend class TiXmlNode; + friend class TiXmlElement; + friend class TiXmlDocument; + +public: + TiXmlBase() : userData(0) {} + virtual ~TiXmlBase() {} + + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. + + This is a formatted print, and will insert + tabs and newlines. + + (For an unformatted stream, use the << operator.) + */ + virtual void Print( FILE* cfile, int depth ) const = 0; + + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing this + value is not thread safe. + */ + static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } + + /// Return the current white space setting. + static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } + + /** Return the position, in the original source file, of this node or attribute. + The row and column are 1-based. (That is the first row and first column is + 1,1). If the returns values are 0 or less, then the parser does not have + a row and column value. + + Generally, the row and column value will be set when the TiXmlDocument::Load(), + TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set + when the DOM was created from operator>>. + + The values reflect the initial load. Once the DOM is modified programmatically + (by adding or changing nodes and attributes) the new values will NOT update to + reflect changes in the document. + + There is a minor performance cost to computing the row and column. Computation + can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. + + @sa TiXmlDocument::SetTabSize() + */ + int Row() const { return location.row + 1; } + int Column() const { return location.col + 1; } ///< See Row() + + void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. + void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. + const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. + + // Table that returs, for a given lead byte, the total number of bytes + // in the UTF-8 sequence. + static const int utf8ByteTable[256]; + + virtual const char* Parse( const char* p, + TiXmlParsingData* data, + TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; + + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + or they will be transformed into entities! + */ + static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); + + enum + { + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + TIXML_ERROR_EMBEDDED_NULL, + TIXML_ERROR_PARSING_CDATA, + TIXML_ERROR_DOCUMENT_TOP_ONLY, + + TIXML_ERROR_STRING_COUNT + }; + +protected: + + static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); + + inline static bool IsWhiteSpace( char c ) + { + return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); + } + inline static bool IsWhiteSpace( int c ) + { + if ( c < 256 ) + return IsWhiteSpace( (char) c ); + return false; // Again, only truly correct for English/Latin...but usually works. + } + + #ifdef TIXML_USE_STL + static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); + static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); + #endif + + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ + static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); + + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText( const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase, // whether to ignore case in the end tag + TiXmlEncoding encoding ); // the current encoding + + // If an entity has been found, transform it into a character. + static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); + + // Get a character, while interpreting entities. + // The length can be from 0 to 4 bytes. + inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) + { + assert( p ); + if ( encoding == TIXML_ENCODING_UTF8 ) + { + *length = utf8ByteTable[ *((const unsigned char*)p) ]; + assert( *length >= 0 && *length < 5 ); + } + else + { + *length = 1; + } + + if ( *length == 1 ) + { + if ( *p == '&' ) + return GetEntity( p, _value, length, encoding ); + *_value = *p; + return p+1; + } + else if ( *length ) + { + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + // and the null terminator isn't needed + for( int i=0; p[i] && i<*length; ++i ) { + _value[i] = p[i]; + } + return p + (*length); + } + else + { + // Not valid text. + return 0; + } + } + + // Return true if the next characters in the stream are any of the endTag sequences. + // Ignore case only works for english, and should only be relied on when comparing + // to English words: StringEqual( p, "version", true ) is fine. + static bool StringEqual( const char* p, + const char* endTag, + bool ignoreCase, + TiXmlEncoding encoding ); + + static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + + TiXmlCursor location; + + /// Field containing a generic user pointer + void* userData; + + // None of these methods are reliable for any language except English. + // Good for approximation, not great for accuracy. + static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); + static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); + inline static int ToLower( int v, TiXmlEncoding encoding ) + { + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( v < 128 ) return tolower( v ); + return v; + } + else + { + return tolower( v ); + } + } + static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + +private: + TiXmlBase( const TiXmlBase& ); // not implemented. + void operator=( const TiXmlBase& base ); // not allowed. + + struct Entity + { + const char* str; + unsigned int strLength; + char chr; + }; + enum + { + NUM_ENTITY = 5, + MAX_ENTITY_LENGTH = 6 + + }; + static Entity entity[ NUM_ENTITY ]; + static bool condenseWhiteSpace; +}; + + +/** The parent class for everything in the Document Object Model. + (Except for attributes). + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. +*/ +class TiXmlNode : public TiXmlBase +{ + friend class TiXmlDocument; + friend class TiXmlElement; + +public: + #ifdef TIXML_USE_STL + + /** An input stream operator, for every class. Tolerant of newlines and + formatting, but doesn't expect them. + */ + friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + + /** An output stream operator, for every class. Note that this outputs + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. + + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. + + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. + + A TiXmlDocument will read nodes until it reads a root element, and + all the children of that root element. + */ + friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); + + /// Appends the XML node or attribute to a std::string. + friend std::string& operator<< (std::string& out, const TiXmlNode& base ); + + #endif + + /** The types of XML nodes supported by TinyXml. (All the + unsupported types are picked up by UNKNOWN.) + */ + enum NodeType + { + TINYXML_DOCUMENT, + TINYXML_ELEMENT, + TINYXML_COMMENT, + TINYXML_UNKNOWN, + TINYXML_TEXT, + TINYXML_DECLARATION, + TINYXML_TYPECOUNT + }; + + virtual ~TiXmlNode(); + + /** The meaning of 'value' changes for the specific type of + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ + const char *Value() const { return value.c_str (); } + + #ifdef TIXML_USE_STL + /** Return Value() as a std::string. If you only use STL, + this is more efficient than calling Value(). + Only available in STL mode. + */ + const std::string& ValueStr() const { return value; } + #endif + + const TIXML_STRING& ValueTStr() const { return value; } + + /** Changes the value of the node. Defined as: + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + void SetValue(const char * _value) { value = _value;} + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Delete all the children of this node. Does not affect 'this'. + void Clear(); + + /// One step up the DOM. + TiXmlNode* Parent() { return parent; } + const TiXmlNode* Parent() const { return parent; } + + const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild() { return firstChild; } + const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + /// The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const char * _value ) { + // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) + // call the method, cast the return back to non-const. + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); + } + const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild() { return lastChild; } + + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const char * _value ) { + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. + #endif + + /** An alternate way to walk the children of a node. + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ + const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); + } + + /// This flavor of IterateChildren searches for children with a particular 'value' + const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + #endif + + /** Add a new node related to this. Adds a child past the LastChild. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); + + + /** Add a new node related to this. Adds a child past the LastChild. + + NOTE: the node to be added is passed by pointer, and will be + henceforth owned (and deleted) by tinyXml. This method is efficient + and avoids an extra copy, but should be used with care as it + uses a different memory model than the other insert functions. + + @sa InsertEndChild + */ + TiXmlNode* LinkEndChild( TiXmlNode* addThis ); + + /** Add a new node related to this. Adds a child before the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child after the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); + + /** Replace a child of this node. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); + + /// Delete a child of this node. + bool RemoveChild( TiXmlNode* removeThis ); + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling() const { return prev; } + TiXmlNode* PreviousSibling() { return prev; } + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const char *_prev ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Navigate to a sibling node. + const TiXmlNode* NextSibling() const { return next; } + TiXmlNode* NextSibling() { return next; } + + /// Navigate to a sibling node with the given 'value'. + const TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const char* _next ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement() const; + TiXmlElement* NextSiblingElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const char *_next ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); + } + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /** Query the type (as an enumerated value, above) of this node. + The possible types are: DOCUMENT, ELEMENT, COMMENT, + UNKNOWN, TEXT, and DECLARATION. + */ + int Type() const { return type; } + + /** Return a pointer to the Document this node lives in. + Returns null if not in a document. + */ + const TiXmlDocument* GetDocument() const; + TiXmlDocument* GetDocument() { + return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); + } + + /// Returns true if this node has no children. + bool NoChildren() const { return !firstChild; } + + virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + /** Create an exact duplicate of this node and return it. The memory must be deleted + by the caller. + */ + virtual TiXmlNode* Clone() const = 0; + + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( TiXmlVisitor* visitor ) const = 0; + +protected: + TiXmlNode( NodeType _type ); + + // Copy to the allocated object. Shared functionality between Clone, Copy constructor, + // and the assignment operator. + void CopyTo( TiXmlNode* target ) const; + + #ifdef TIXML_USE_STL + // The real work of the input operator. + virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; + #endif + + // Figure out what is at *p, and parse it. Returns null if it is not an xml node. + TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); + + TiXmlNode* parent; + NodeType type; + + TiXmlNode* firstChild; + TiXmlNode* lastChild; + + TIXML_STRING value; + + TiXmlNode* prev; + TiXmlNode* next; + +private: + TiXmlNode( const TiXmlNode& ); // not implemented. + void operator=( const TiXmlNode& base ); // not allowed. +}; + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. +*/ +class TiXmlAttribute : public TiXmlBase +{ + friend class TiXmlAttributeSet; + +public: + /// Construct an empty attribute. + TiXmlAttribute() : TiXmlBase() + { + document = 0; + prev = next = 0; + } + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlAttribute( const std::string& _name, const std::string& _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + #endif + + /// Construct an attribute with a name and value. + TiXmlAttribute( const char * _name, const char * _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + + const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. + #ifdef TIXML_USE_STL + const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. + #endif + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + + // Get the tinyxml string representation + const TIXML_STRING& NameTStr() const { return name; } + + /** QueryIntValue examines the value string. It is an alternative to the + IntValue() method with richer error checking. + If the value is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. + + A specialized but useful call. Note that for success it returns 0, + which is the opposite of almost all other TinyXml calls. + */ + int QueryIntValue( int* _value ) const; + /// QueryDoubleValue examines the value string. See QueryIntValue(). + int QueryDoubleValue( double* _value ) const; + + void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const char* _value ) { value = _value; } ///< Set the value. + + void SetIntValue( int _value ); ///< Set the value from an integer. + void SetDoubleValue( double _value ); ///< Set the value from a double. + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetName( const std::string& _name ) { name = _name; } + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Get the next sibling attribute in the DOM. Returns null at end. + const TiXmlAttribute* Next() const; + TiXmlAttribute* Next() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + } + + /// Get the previous sibling attribute in the DOM. Returns null at beginning. + const TiXmlAttribute* Previous() const; + TiXmlAttribute* Previous() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + } + + bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } + bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } + bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } + + /* Attribute parsing starts: first letter of the name + returns: the next char after the value end quote + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + // Prints this Attribute to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + + // [internal use] + // Set the document pointer so the attribute can report errors. + void SetDocument( TiXmlDocument* doc ) { document = doc; } + +private: + TiXmlAttribute( const TiXmlAttribute& ); // not implemented. + void operator=( const TiXmlAttribute& base ); // not allowed. + + TiXmlDocument* document; // A pointer back to a document, for error reporting. + TIXML_STRING name; + TIXML_STRING value; + TiXmlAttribute* prev; + TiXmlAttribute* next; +}; + + +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. + + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. + + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. +*/ +class TiXmlAttributeSet +{ +public: + TiXmlAttributeSet(); + ~TiXmlAttributeSet(); + + void Add( TiXmlAttribute* attribute ); + void Remove( TiXmlAttribute* attribute ); + + const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + + TiXmlAttribute* Find( const char* _name ) const; + TiXmlAttribute* FindOrCreate( const char* _name ); + +# ifdef TIXML_USE_STL + TiXmlAttribute* Find( const std::string& _name ) const; + TiXmlAttribute* FindOrCreate( const std::string& _name ); +# endif + + +private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! + TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed + void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) + + TiXmlAttribute sentinel; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class TiXmlElement : public TiXmlNode +{ +public: + /// Construct an element. + TiXmlElement (const char * in_value); + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlElement( const std::string& _value ); + #endif + + TiXmlElement( const TiXmlElement& ); + + void operator=( const TiXmlElement& base ); + + virtual ~TiXmlElement(); + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + */ + const char* Attribute( const char* name ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ + const char* Attribute( const char* name, int* i ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an double, + the double value will be put in the return 'd', if 'd' + is non-null. + */ + const char* Attribute( const char* name, double* d ) const; + + /** QueryIntAttribute examines the attribute - it is an alternative to the + Attribute() method with richer error checking. + If the attribute is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. If the attribute + does not exist, then TIXML_NO_ATTRIBUTE is returned. + */ + int QueryIntAttribute( const char* name, int* _value ) const; + /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). + int QueryDoubleAttribute( const char* name, double* _value ) const; + /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). + int QueryFloatAttribute( const char* name, float* _value ) const { + double d; + int result = QueryDoubleAttribute( name, &d ); + if ( result == TIXML_SUCCESS ) { + *_value = (float)d; + } + return result; + } + + #ifdef TIXML_USE_STL + /// QueryStringAttribute examines the attribute - see QueryIntAttribute(). + int QueryStringAttribute( const char* name, std::string* _value ) const { + const char* cstr = Attribute( name ); + if ( cstr ) { + *_value = std::string( cstr ); + return TIXML_SUCCESS; + } + return TIXML_NO_ATTRIBUTE; + } + + /** Template form of the attribute query which will try to read the + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. + + NOTE: This method doesn't work correctly for 'string' types that contain spaces. + + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ + template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + std::stringstream sstream( node->ValueStr() ); + sstream >> *outValue; + if ( !sstream.fail() ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; + } + + int QueryValueAttribute( const std::string& name, std::string* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + *outValue = node->ValueStr(); + return TIXML_SUCCESS; + } + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char* name, const char * _value ); + + #ifdef TIXML_USE_STL + const std::string* Attribute( const std::string& name ) const; + const std::string* Attribute( const std::string& name, int* i ) const; + const std::string* Attribute( const std::string& name, double* d ) const; + int QueryIntAttribute( const std::string& name, int* _value ) const; + int QueryDoubleAttribute( const std::string& name, double* _value ) const; + + /// STL std::string form. + void SetAttribute( const std::string& name, const std::string& _value ); + ///< STL std::string form. + void SetAttribute( const std::string& name, int _value ); + ///< STL std::string form. + void SetDoubleAttribute( const std::string& name, double value ); + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char * name, int value ); + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetDoubleAttribute( const char * name, double value ); + + /** Deletes an attribute with the given name. + */ + void RemoveAttribute( const char * name ); + #ifdef TIXML_USE_STL + void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. + #endif + + const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. + TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } + const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + safe type casts on the referenced node. + */ + const char* GetText() const; + + /// Creates a new Element and returns it - the returned element is a copy. + virtual TiXmlNode* Clone() const; + // Print the Element to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: next char past '<' + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + + void CopyTo( TiXmlElement* target ) const; + void ClearThis(); // like clear, but initializes 'this' object as well + + // Used to be public [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + /* [internal use] + Reads the "value" of the element -- another element, or text. + This should terminate with the current end tag. + */ + const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + +private: + TiXmlAttributeSet attributeSet; +}; + + +/** An XML comment. +*/ +class TiXmlComment : public TiXmlNode +{ +public: + /// Constructs an empty comment. + TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} + /// Construct a comment from text. + TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { + SetValue( _value ); + } + TiXmlComment( const TiXmlComment& ); + void operator=( const TiXmlComment& base ); + + virtual ~TiXmlComment() {} + + /// Returns a copy of this Comment. + virtual TiXmlNode* Clone() const; + // Write this Comment to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: at the ! of the !-- + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlComment* target ) const; + + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif +// virtual void StreamOut( TIXML_OSTREAM * out ) const; + +private: + +}; + + +/** XML text. A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). +*/ +class TiXmlText : public TiXmlNode +{ + friend class TiXmlElement; +public: + /** Constructor for text element. By default, it is treated as + normal, encoded text. If you want it be output as a CDATA text + element, set the parameter _cdata to 'true' + */ + TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) + { + SetValue( initValue ); + cdata = false; + } + virtual ~TiXmlText() {} + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) + { + SetValue( initValue ); + cdata = false; + } + #endif + + TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } + void operator=( const TiXmlText& base ) { base.CopyTo( this ); } + + // Write this text object to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /// Queries whether this represents text using a CDATA section. + bool CDATA() const { return cdata; } + /// Turns on or off a CDATA representation of text. + void SetCDATA( bool _cdata ) { cdata = _cdata; } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + /// [internal use] Creates a new Element and returns it. + virtual TiXmlNode* Clone() const; + void CopyTo( TiXmlText* target ) const; + + bool Blank() const; // returns true if all white space and new lines + // [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + bool cdata; // true if this should be input and output as a CDATA style text element +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + + @endverbatim + + TinyXml will happily read or write files without a declaration, + however. There are 3 possible attributes to the declaration: + version, encoding, and standalone. + + Note: In this version of the code, the attributes are + handled as special cases, not generic attributes, simply + because there can only be at most 3 and they are always the same. +*/ +class TiXmlDeclaration : public TiXmlNode +{ +public: + /// Construct an empty declaration. + TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {} + +#ifdef TIXML_USE_STL + /// Constructor. + TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ); +#endif + + /// Construct. + TiXmlDeclaration( const char* _version, + const char* _encoding, + const char* _standalone ); + + TiXmlDeclaration( const TiXmlDeclaration& copy ); + void operator=( const TiXmlDeclaration& copy ); + + virtual ~TiXmlDeclaration() {} + + /// Version. Will return an empty string if none was found. + const char *Version() const { return version.c_str (); } + /// Encoding. Will return an empty string if none was found. + const char *Encoding() const { return encoding.c_str (); } + /// Is this a standalone document? + const char *Standalone() const { return standalone.c_str (); } + + /// Creates a copy of this Declaration and returns it. + virtual TiXmlNode* Clone() const; + // Print this declaration to a FILE stream. + virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlDeclaration* target ) const; + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + + TIXML_STRING version; + TIXML_STRING encoding; + TIXML_STRING standalone; +}; + + +/** Any tag that tinyXml doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into TiXmlUnknowns. +*/ +class TiXmlUnknown : public TiXmlNode +{ +public: + TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} + virtual ~TiXmlUnknown() {} + + TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } + void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } + + /// Creates a copy of this Unknown and returns it. + virtual TiXmlNode* Clone() const; + // Print this Unknown to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected: + void CopyTo( TiXmlUnknown* target ) const; + + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + +}; + + +/** Always the top level node. A document binds together all the + XML pieces. It can be saved, loaded, and printed to the screen. + The 'value' of a document node is the xml file name. +*/ +class TiXmlDocument : public TiXmlNode +{ +public: + /// Create an empty document, that has no name. + TiXmlDocument(); + /// Create a document with a name. The name of the document is also the filename of the xml. + TiXmlDocument( const char * documentName ); + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlDocument( const std::string& documentName ); + #endif + + TiXmlDocument( const TiXmlDocument& copy ); + void operator=( const TiXmlDocument& copy ); + + virtual ~TiXmlDocument() {} + + /** Load a file using the current document value. + Returns true if successful. Will delete any existing + document data before loading. + */ + bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the current document value. Returns true if successful. + bool SaveFile() const; + /// Load a file using the given filename. Returns true if successful. + bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given filename. Returns true if successful. + bool SaveFile( const char * filename ) const; + /** Load a file using the given FILE*. Returns true if successful. Note that this method + doesn't stream - the entire object pointed at by the FILE* + will be interpreted as an XML file. TinyXML doesn't stream in XML from the current + file location. Streaming may be added in the future. + */ + bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given FILE*. Returns true if successful. + bool SaveFile( FILE* ) const; + + #ifdef TIXML_USE_STL + bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. + { + return LoadFile( filename.c_str(), encoding ); + } + bool SaveFile( const std::string& filename ) const ///< STL std::string version. + { + return SaveFile( filename.c_str() ); + } + #endif + + /** Parse the given null terminated block of xml data. Passing in an encoding to this + method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml + to use that encoding, regardless of what TinyXml might otherwise try to detect. + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + + /** Get the root element -- the only top level element -- of the document. + In well formed XML, there should only be one. TinyXml is tolerant of + multiple elements at the document level. + */ + const TiXmlElement* RootElement() const { return FirstChildElement(); } + TiXmlElement* RootElement() { return FirstChildElement(); } + + /** If an error occurs, Error will be set to true. Also, + - The ErrorId() will contain the integer identifier of the error (not generally useful) + - The ErrorDesc() method will return the name of the error. (very useful) + - The ErrorRow() and ErrorCol() will return the location of the error (if known) + */ + bool Error() const { return error; } + + /// Contains a textual (english) description of the error if one occurs. + const char * ErrorDesc() const { return errorDesc.c_str (); } + + /** Generally, you probably want the error string ( ErrorDesc() ). But if you + prefer the ErrorId, this function will fetch it. + */ + int ErrorId() const { return errorId; } + + /** Returns the location (if known) of the error. The first column is column 1, + and the first row is row 1. A value of 0 means the row and column wasn't applicable + (memory errors, for example, have no row/column) or the parser lost the error. (An + error in the error reporting, in that case.) + + @sa SetTabSize, Row, Column + */ + int ErrorRow() const { return errorLocation.row+1; } + int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() + + /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) + to report the correct values for row and column. It does not change the output + or input in any way. + + By calling this method, with a tab size + greater than 0, the row and column of each node and attribute is stored + when the file is loaded. Very useful for tracking the DOM back in to + the source file. + + The tab size is required for calculating the location of nodes. If not + set, the default of 4 is used. The tabsize is set per document. Setting + the tabsize to 0 disables row/column tracking. + + Note that row and column tracking is not supported when using operator>>. + + The tab size needs to be enabled before the parse or load. Correct usage: + @verbatim + TiXmlDocument doc; + doc.SetTabSize( 8 ); + doc.Load( "myfile.xml" ); + @endverbatim + + @sa Row, Column + */ + void SetTabSize( int _tabsize ) { tabsize = _tabsize; } + + int TabSize() const { return tabsize; } + + /** If you have handled the error, it can be reset with this call. The error + state is automatically cleared if you Parse a new XML block. + */ + void ClearError() { error = false; + errorId = 0; + errorDesc = ""; + errorLocation.row = errorLocation.col = 0; + //errorLocation.last = 0; + } + + /** Write the document to standard out using formatted printing ("pretty print"). */ + void Print() const { Print( stdout, 0 ); } + + /* Write the document to a string using formatted printing ("pretty print"). This + will allocate a character array (new char[]) and return it as a pointer. The + calling code pust call delete[] on the return char* to avoid a memory leak. + */ + //char* PrintToMemory() const; + + /// Print this Document to a FILE stream. + virtual void Print( FILE* cfile, int depth = 0 ) const; + // [internal use] + void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + + virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + // [internal use] + virtual TiXmlNode* Clone() const; + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + void CopyTo( TiXmlDocument* target ) const; + + bool error; + int errorId; + TIXML_STRING errorDesc; + int tabsize; + TiXmlCursor errorLocation; + bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. +}; + + +/** + A TiXmlHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + + + + + + + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + TiXmlElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + TiXmlElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + TiXmlElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + TiXmlElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity + of such code. A TiXmlHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + TiXmlHandle docHandle( &document ); + TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + TiXmlHandle handleCopy = handle; + @endverbatim + + What they should not be used for is iteration: + + @verbatim + int i=0; + while ( true ) + { + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); + if ( !child ) + break; + // do something + ++i; + } + @endverbatim + + It seems reasonable, but it is in fact two embedded while loops. The Child method is + a linear walk to find the element, so this code would iterate much more than it needs + to. Instead, prefer: + + @verbatim + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); + + for( child; child; child=child->NextSiblingElement() ) + { + // do something + } + @endverbatim +*/ +class TiXmlHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } + /// Copy constructor + TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } + TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } + + /// Return a handle to the first child node. + TiXmlHandle FirstChild() const; + /// Return a handle to the first child node with the given name. + TiXmlHandle FirstChild( const char * value ) const; + /// Return a handle to the first child element. + TiXmlHandle FirstChildElement() const; + /// Return a handle to the first child element with the given name. + TiXmlHandle FirstChildElement( const char * value ) const; + + /** Return a handle to the "index" child with the given name. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( const char* value, int index ) const; + /** Return a handle to the "index" child. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( int index ) const; + /** Return a handle to the "index" child element with the given name. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( const char* value, int index ) const; + /** Return a handle to the "index" child element. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( int index ) const; + + #ifdef TIXML_USE_STL + TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } + TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } + + TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } + TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } + #endif + + /** Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* ToNode() const { return node; } + /** Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } + /** Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } + /** Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } + + /** @deprecated use ToNode. + Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* Node() const { return ToNode(); } + /** @deprecated use ToElement. + Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* Element() const { return ToElement(); } + /** @deprecated use ToText() + Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* Text() const { return ToText(); } + /** @deprecated use ToUnknown() + Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* Unknown() const { return ToUnknown(); } + +private: + TiXmlNode* node; +}; + + +/** Print to memory functionality. The TiXmlPrinter is useful when you need to: + + -# Print to memory (especially in non-STL mode) + -# Control formatting (line endings, etc.) + + When constructed, the TiXmlPrinter is in its default "pretty printing" mode. + Before calling Accept() you can call methods to control the printing + of the XML document. After TiXmlNode::Accept() is called, the printed document can + be accessed via the CStr(), Str(), and Size() methods. + + TiXmlPrinter uses the Visitor API. + @verbatim + TiXmlPrinter printer; + printer.SetIndent( "\t" ); + + doc.Accept( &printer ); + fprintf( stdout, "%s", printer.CStr() ); + @endverbatim +*/ +class TiXmlPrinter : public TiXmlVisitor +{ +public: + TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), + buffer(), indent( " " ), lineBreak( "\n" ) {} + + virtual bool VisitEnter( const TiXmlDocument& doc ); + virtual bool VisitExit( const TiXmlDocument& doc ); + + virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); + virtual bool VisitExit( const TiXmlElement& element ); + + virtual bool Visit( const TiXmlDeclaration& declaration ); + virtual bool Visit( const TiXmlText& text ); + virtual bool Visit( const TiXmlComment& comment ); + virtual bool Visit( const TiXmlUnknown& unknown ); + + /** Set the indent characters for printing. By default 4 spaces + but tab (\t) is also useful, or null/empty string for no indentation. + */ + void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } + /// Query the indention string. + const char* Indent() { return indent.c_str(); } + /** Set the line breaking string. By default set to newline (\n). + Some operating systems prefer other characters, or can be + set to the null/empty string for no indenation. + */ + void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } + /// Query the current line breaking string. + const char* LineBreak() { return lineBreak.c_str(); } + + /** Switch over to "stream printing" which is the most dense formatting without + linebreaks. Common when the XML is needed for network transmission. + */ + void SetStreamPrinting() { indent = ""; + lineBreak = ""; + } + /// Return the result. + const char* CStr() { return buffer.c_str(); } + /// Return the length of the result string. + size_t Size() { return buffer.size(); } + + #ifdef TIXML_USE_STL + /// Return the result. + const std::string& Str() { return buffer; } + #endif + +private: + void DoIndent() { + for( int i=0; i +#include + +#include "tinyxml.h" + +//#define DEBUG_PARSER +#if defined( DEBUG_PARSER ) +# if defined( DEBUG ) && defined( _MSC_VER ) +# include +# define TIXML_LOG OutputDebugString +# else +# define TIXML_LOG printf +# endif +#endif + +// Note tha "PutString" hardcodes the same list. This +// is less flexible than it appears. Changing the entries +// or order will break putstring. +TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = +{ + { "&", 5, '&' }, + { "<", 4, '<' }, + { ">", 4, '>' }, + { """, 6, '\"' }, + { "'", 6, '\'' } +}; + +// Bunch of unicode info at: +// http://www.unicode.org/faq/utf_bom.html +// Including the basic of this table, which determines the #bytes in the +// sequence from the lead byte. 1 placed for invalid sequences -- +// although the result will be junk, pass it through as much as possible. +// Beware of the non-characters in UTF-8: +// ef bb bf (Microsoft "lead bytes") +// ef bf be +// ef bf bf + +const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + +const int TiXmlBase::utf8ByteTable[256] = +{ + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid +}; + + +void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +{ + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) + *length = 1; + else if ( input < 0x800 ) + *length = 2; + else if ( input < 0x10000 ) + *length = 3; + else if ( input < 0x200000 ) + *length = 4; + else + { *length = 0; return; } // This code won't covert this correctly anyway. + + output += *length; + + // Scary scary fall throughs. + switch (*length) + { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + } +} + + +/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalpha( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalpha( anyByte ); +// } +} + + +/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalnum( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalnum( anyByte ); +// } +} + + +class TiXmlParsingData +{ + friend class TiXmlDocument; + public: + void Stamp( const char* now, TiXmlEncoding encoding ); + + const TiXmlCursor& Cursor() { return cursor; } + + private: + // Only used by the document! + TiXmlParsingData( const char* start, int _tabsize, int row, int col ) + { + assert( start ); + stamp = start; + tabsize = _tabsize; + cursor.row = row; + cursor.col = col; + } + + TiXmlCursor cursor; + const char* stamp; + int tabsize; +}; + + +void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) +{ + assert( now ); + + // Do nothing if the tabsize is 0. + if ( tabsize < 1 ) + { + return; + } + + // Get the current row, column. + int row = cursor.row; + int col = cursor.col; + const char* p = stamp; + assert( p ); + + while ( p < now ) + { + // Treat p as unsigned, so we have a happy compiler. + const unsigned char* pU = (const unsigned char*)p; + + // Code contributed by Fletcher Dunn: (modified by lee) + switch (*pU) { + case 0: + // We *should* never get here, but in case we do, don't + // advance past the terminating null character, ever + return; + + case '\r': + // bump down to the next line + ++row; + col = 0; + // Eat the character + ++p; + + // Check for \r\n sequence, and treat this as a single character + if (*p == '\n') { + ++p; + } + break; + + case '\n': + // bump down to the next line + ++row; + col = 0; + + // Eat the character + ++p; + + // Check for \n\r sequence, and treat this as a single + // character. (Yes, this bizarre thing does occur still + // on some arcane platforms...) + if (*p == '\r') { + ++p; + } + break; + + case '\t': + // Eat the character + ++p; + + // Skip to next tab stop + col = (col / tabsize + 1) * tabsize; + break; + + case TIXML_UTF_LEAD_0: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( *(p+1) && *(p+2) ) + { + // In these cases, don't advance the column. These are + // 0-width spaces. + if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) + p += 3; + else + { p +=3; ++col; } // A normal character. + } + } + else + { + ++p; + ++col; + } + break; + + default: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // Eat the 1 to 4 byte utf8 character. + int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; + if ( step == 0 ) + step = 1; // Error case from bad encoding, but handle gracefully. + p += step; + + // Just advance one column, of course. + ++col; + } + else + { + ++p; + ++col; + } + break; + } + } + cursor.row = row; + cursor.col = col; + assert( cursor.row >= -1 ); + assert( cursor.col >= -1 ); + stamp = p; + assert( stamp ); +} + + +const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) +{ + if ( !p || !*p ) + { + return 0; + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + while ( *p ) + { + const unsigned char* pU = (const unsigned char*)p; + + // Skip the stupid Microsoft UTF-8 Byte order marks + if ( *(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==TIXML_UTF_LEAD_1 + && *(pU+2)==TIXML_UTF_LEAD_2 ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbeU ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbfU ) + { + p += 3; + continue; + } + + if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. + ++p; + else + break; + } + } + else + { + while ( *p && IsWhiteSpace( *p ) ) + ++p; + } + + return p; +} + +#ifdef TIXML_USE_STL +/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) +{ + for( ;; ) + { + if ( !in->good() ) return false; + + int c = in->peek(); + // At this scope, we can't get to a document. So fail silently. + if ( !IsWhiteSpace( c ) || c <= 0 ) + return true; + + *tag += (char) in->get(); + } +} + +/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) +{ + //assert( character > 0 && character < 128 ); // else it won't work in utf-8 + while ( in->good() ) + { + int c = in->peek(); + if ( c == character ) + return true; + if ( c <= 0 ) // Silent failure: can't get document at this scope + return false; + + in->get(); + *tag += (char) c; + } + return false; +} +#endif + +// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The +// "assign" optimization removes over 10% of the execution time. +// +const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) +{ + // Oddly, not supported on some comilers, + //name->clear(); + // So use this: + *name = ""; + assert( p ); + + // Names start with letters or underscores. + // Of course, in unicode, tinyxml has no idea what a letter *is*. The + // algorithm is generous. + // + // After that, they can be letters, underscores, numbers, + // hyphens, or colons. (Colons are valid ony for namespaces, + // but tinyxml can't tell namespaces from names.) + if ( p && *p + && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) + { + const char* start = p; + while( p && *p + && ( IsAlphaNum( (unsigned char ) *p, encoding ) + || *p == '_' + || *p == '-' + || *p == '.' + || *p == ':' ) ) + { + //(*name) += *p; // expensive + ++p; + } + if ( p-start > 0 ) { + name->assign( start, p-start ); + } + return p; + } + return 0; +} + +const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) +{ + // Presume an entity, and pull it out. + TIXML_STRING ent; + int i; + *length = 0; + + if ( *(p+1) && *(p+1) == '#' && *(p+2) ) + { + unsigned long ucs = 0; + ptrdiff_t delta = 0; + unsigned mult = 1; + + if ( *(p+2) == 'x' ) + { + // Hexadecimal. + if ( !*(p+3) ) return 0; + + const char* q = p+3; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != 'x' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else if ( *q >= 'a' && *q <= 'f' ) + ucs += mult * (*q - 'a' + 10); + else if ( *q >= 'A' && *q <= 'F' ) + ucs += mult * (*q - 'A' + 10 ); + else + return 0; + mult *= 16; + --q; + } + } + else + { + // Decimal. + if ( !*(p+2) ) return 0; + + const char* q = p+2; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != '#' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else + return 0; + mult *= 10; + --q; + } + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + } + else + { + *value = (char)ucs; + *length = 1; + } + return p + delta + 1; + } + + // Now try to match it. + for( i=0; iappend( cArr, len ); + } + } + else + { + bool whitespace = false; + + // Remove leading white space: + p = SkipWhiteSpace( p, encoding ); + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) ) + { + if ( *p == '\r' || *p == '\n' ) + { + whitespace = true; + ++p; + } + else if ( IsWhiteSpace( *p ) ) + { + whitespace = true; + ++p; + } + else + { + // If we've found whitespace, add it before the + // new character. Any whitespace just becomes a space. + if ( whitespace ) + { + (*text) += ' '; + whitespace = false; + } + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + if ( len == 1 ) + (*text) += cArr[0]; // more efficient + else + text->append( cArr, len ); + } + } + } + if ( p && *p ) + p += strlen( endTag ); + return p; +} + +#ifdef TIXML_USE_STL + +void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + // The basic issue with a document is that we don't know what we're + // streaming. Read something presumed to be a tag (and hope), then + // identify it, and call the appropriate stream method on the tag. + // + // This "pre-streaming" will never read the closing ">" so the + // sub-tag can orient itself. + + if ( !StreamTo( in, '<', tag ) ) + { + SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + while ( in->good() ) + { + int tagIndex = (int) tag->length(); + while ( in->good() && in->peek() != '>' ) + { + int c = in->get(); + if ( c <= 0 ) + { + SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + break; + } + (*tag) += (char) c; + } + + if ( in->good() ) + { + // We now have something we presume to be a node of + // some sort. Identify it, and call the node to + // continue streaming. + TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); + + if ( node ) + { + node->StreamIn( in, tag ); + bool isElement = node->ToElement() != 0; + delete node; + node = 0; + + // If this is the root element, we're done. Parsing will be + // done by the >> operator. + if ( isElement ) + { + return; + } + } + else + { + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + } + } + // We should have returned sooner. + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); +} + +#endif + +const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) +{ + ClearError(); + + // Parse away, at the document level. Since a document + // contains nothing but other tags, most of what happens + // here is skipping white space. + if ( !p || !*p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + // Note that, for a document, this needs to come + // before the while space skip, so that parsing + // starts from the pointer we are given. + location.Clear(); + if ( prevData ) + { + location.row = prevData->cursor.row; + location.col = prevData->cursor.col; + } + else + { + location.row = 0; + location.col = 0; + } + TiXmlParsingData data( p, TabSize(), location.row, location.col ); + location = data.Cursor(); + + if ( encoding == TIXML_ENCODING_UNKNOWN ) + { + // Check for the Microsoft UTF-8 lead bytes. + const unsigned char* pU = (const unsigned char*)p; + if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 + && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 + && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) + { + encoding = TIXML_ENCODING_UTF8; + useMicrosoftBOM = true; + } + } + + p = SkipWhiteSpace( p, encoding ); + if ( !p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + while ( p && *p ) + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, &data, encoding ); + LinkEndChild( node ); + } + else + { + break; + } + + // Did we get encoding info? + if ( encoding == TIXML_ENCODING_UNKNOWN + && node->ToDeclaration() ) + { + TiXmlDeclaration* dec = node->ToDeclaration(); + const char* enc = dec->Encoding(); + assert( enc ); + + if ( *enc == 0 ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice + else + encoding = TIXML_ENCODING_LEGACY; + } + + p = SkipWhiteSpace( p, encoding ); + } + + // Was this empty? + if ( !firstChild ) { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); + return 0; + } + + // All is well. + return p; +} + +void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + // The first error in a chain is more accurate - don't set again! + if ( error ) + return; + + assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); + error = true; + errorId = err; + errorDesc = errorString[ errorId ]; + + errorLocation.Clear(); + if ( pError && data ) + { + data->Stamp( pError, encoding ); + errorLocation = data->Cursor(); + } +} + + +TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) +{ + TiXmlNode* returnNode = 0; + + p = SkipWhiteSpace( p, encoding ); + if( !p || !*p || *p != '<' ) + { + return 0; + } + + p = SkipWhiteSpace( p, encoding ); + + if ( !p || !*p ) + { + return 0; + } + + // What is this thing? + // - Elements start with a letter or underscore, but xml is reserved. + // - Comments: "; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // [ 1475201 ] TinyXML parses entities in comments + // Oops - ReadText doesn't work, because we don't want to parse the entities. + // p = ReadText( p, &value, false, endTag, false, encoding ); + // + // from the XML spec: + /* + [Definition: Comments may appear anywhere in a document outside other markup; in addition, + they may appear within the document type declaration at places allowed by the grammar. + They are not part of the document's character data; an XML processor MAY, but need not, + make it possible for an application to retrieve the text of comments. For compatibility, + the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity + references MUST NOT be recognized within comments. + + An example of a comment: + + + */ + + value = ""; + // Keep all the white space. + while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) + { + value.append( p, 1 ); + ++p; + } + if ( p && *p ) + p += strlen( endTag ); + + return p; +} + + +const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) return 0; + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + // Read the name, the '=' and the value. + const char* pErr = p; + p = ReadName( p, &name, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p || *p != '=' ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + ++p; // skip '=' + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + const char* end; + const char SINGLE_QUOTE = '\''; + const char DOUBLE_QUOTE = '\"'; + + if ( *p == SINGLE_QUOTE ) + { + ++p; + end = "\'"; // single quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else if ( *p == DOUBLE_QUOTE ) + { + ++p; + end = "\""; // double quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else + { + // All attribute values should be in single or double quotes. + // But this is such a common error that the parser will try + // its best, even without them. + value = ""; + while ( p && *p // existence + && !IsWhiteSpace( *p ) // whitespace + && *p != '/' && *p != '>' ) // tag end + { + if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { + // [ 1451649 ] Attribute values with trailing quotes not handled correctly + // We did not have an opening quote but seem to have a + // closing one. Give up and throw an error. + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + value += *p; + ++p; + } + } + return p; +} + +#ifdef TIXML_USE_STL +void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->peek(); + if ( !cdata && (c == '<' ) ) + { + return; + } + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + in->get(); // "commits" the peek made above + + if ( cdata && c == '>' && tag->size() >= 3 ) { + size_t len = tag->size(); + if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { + // terminator of cdata. + return; + } + } + } +} +#endif + +const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + value = ""; + TiXmlDocument* document = GetDocument(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + const char* const startTag = ""; + + if ( cdata || StringEqual( p, startTag, false, encoding ) ) + { + cdata = true; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // Keep all the white space, ignore the encoding, etc. + while ( p && *p + && !StringEqual( p, endTag, false, encoding ) + ) + { + value += *p; + ++p; + } + + TIXML_STRING dummy; + p = ReadText( p, &dummy, false, endTag, false, encoding ); + return p; + } + else + { + bool ignoreWhite = true; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false, encoding ); + if ( p ) + return p-1; // don't truncate the '<' + return 0; + } +} + +#ifdef TIXML_USE_STL +void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } +} +#endif + +const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) +{ + p = SkipWhiteSpace( p, _encoding ); + // Find the beginning, find the end, and look for + // the stuff in-between. + TiXmlDocument* document = GetDocument(); + if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); + return 0; + } + if ( data ) + { + data->Stamp( p, _encoding ); + location = data->Cursor(); + } + p += 5; + + version = ""; + encoding = ""; + standalone = ""; + + while ( p && *p ) + { + if ( *p == '>' ) + { + ++p; + return p; + } + + p = SkipWhiteSpace( p, _encoding ); + if ( StringEqual( p, "version", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + version = attrib.Value(); + } + else if ( StringEqual( p, "encoding", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + encoding = attrib.Value(); + } + else if ( StringEqual( p, "standalone", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + standalone = attrib.Value(); + } + else + { + // Read over whatever it is. + while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) + ++p; + } + } + return 0; +} + +bool TiXmlText::Blank() const +{ + for ( unsigned i=0; i + +typedef HMODULE lib_t; + +#define __itt_get_proc(lib, name) GetProcAddress(lib, name) +#define __itt_load_lib(name) LoadLibraryA(name) +#define __itt_unload_lib(handle) FreeLibrary(handle) +#define __itt_system_error() (int)GetLastError() +#endif /* ANNOTATE_DECLARE */ + +#else /* defined(WIN32) || defined(_WIN32) */ + +#if defined _M_IX86 || __i386__ +# define ANNOTATEAPI __attribute__ ((cdecl)) +#else +# define ANNOTATEAPI /* actual only on x86 platform */ +#endif + + +#ifndef ANNOTATE_DECLARE +#include +#include +#include + +typedef void* lib_t; + +#define __itt_get_proc(lib, name) dlsym(lib, name) +#define __itt_load_lib(name) dlopen(name, RTLD_LAZY) +#define __itt_unload_lib(handle) dlclose(handle) +#define __itt_system_error() errno +#endif /* ANNOTATE_DECLARE */ + +#endif /* defined(WIN32) || defined(_WIN32) */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _ITTNOTIFY_H_ + +/* Handles for sites and tasks. + */ +typedef void* __itt_model_site; /* handle for lexical site */ +typedef void* __itt_model_site_instance; /* handle for dynamic instance */ +typedef void* __itt_model_task; /* handle for lexical site */ +typedef void* __itt_model_task_instance; /* handle for dynamic instance */ + +typedef enum { + __itt_model_disable_observation, + __itt_model_disable_collection +} __itt_model_disable; + +#endif /* _ITTNOTIFY_H_ */ + +/*** Use the routines in libittnotify.dll. ***/ + +/* Basic approach: + * For the case of calling the dll, there is an __annotate_routine function + * declared as a comdat in each compilation unit with annotations present. + * That routine in turn has an internal static structure that is initialized + * once to contain the address of functions occuring in libittnotify.dll. + * Each time an annotation macro is invoked, that causes a call to the + * __annotate_routine function to get addresses of the routines, followed + * by calling the specific routine, provided the address is non-null. + */ + +/* This set of macros generates calls that are part of application images, + * which call the __itt_model_xxx routines in the dynamically loaded + * libittnotify.dll. + */ +#ifndef _ITTNOTIFY_H_ +#define ITT_NOTIFY_DECL(_text) _text +#else +#define ITT_NOTIFY_DECL(_text) +#endif + +/* For C++, a static initialization is used */ +#if defined(__cplusplus) && defined(WIN32) +#define _ANNOTATE_ROUTINES_ADDR __annotate_routines_s +#else +#define _ANNOTATE_ROUTINES_ADDR __annotate_routines_init( __annotate_routines() ) +#endif /* __cplusplus */ + + +#define _ANNOTATE_DECLARE_0(_BASENAME) \ +typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(); \ +static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop() { }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(); ) + +#define _ANNOTATE_DECLARE_0_INT(_BASENAME) \ +typedef int (ANNOTATEAPI * __annotate_##_BASENAME##_t)(); \ +static __inline int ANNOTATEAPI __annotate_##_BASENAME##_t_nop() { return 0; }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(); ) + +#define _ANNOTATE_CALL_0(_BASENAME) { _ANNOTATE_ROUTINES_ADDR->_BASENAME(); } + +#define _ANNOTATE_DECLARE_1(_BASENAME, _P1TYPE) \ +typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(_P1TYPE p1); \ +static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop(_P1TYPE p1) { (void)p1; }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(_P1TYPE p1); ) + +#define _ANNOTATE_CALL_1(_BASENAME, _P1) { _ANNOTATE_ROUTINES_ADDR->_BASENAME(_P1); } + +#define _ANNOTATE_DECLARE_2(_BASENAME, _P1TYPE, _P2TYPE) \ +typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(_P1TYPE p1, _P2TYPE p2); \ +static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop(_P1TYPE p1, _P2TYPE p2) { (void)p1; (void)p2; }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(_P1TYPE p1, _P2TYPE p2); ) + +#define _ANNOTATE_CALL_2(_BASENAME, _P1, _P2) { _ANNOTATE_ROUTINES_ADDR->_BASENAME((_P1), (_P2)); } + +/*** Declare routines appropriately based on usage style ***/ + +/* Depending on above, this will either expand to comdats that are + * used directly, or comdats that call routines in libittnotify.dll + */ +_ANNOTATE_DECLARE_1(site_beginA, const char *) +_ANNOTATE_DECLARE_0(site_end_2) +_ANNOTATE_DECLARE_1(task_beginA, const char *) +_ANNOTATE_DECLARE_0(task_end_2) +_ANNOTATE_DECLARE_1(iteration_taskA, const char *) +_ANNOTATE_DECLARE_1(lock_acquire_2, void *) +_ANNOTATE_DECLARE_1(lock_release_2, void *) +_ANNOTATE_DECLARE_2(record_allocation, void *, size_t) +_ANNOTATE_DECLARE_1(record_deallocation, void *) +_ANNOTATE_DECLARE_2(induction_uses, void *, size_t) +_ANNOTATE_DECLARE_2(reduction_uses, void *, size_t) +_ANNOTATE_DECLARE_2(observe_uses, void *, size_t) +_ANNOTATE_DECLARE_1(clear_uses, void *) +_ANNOTATE_DECLARE_1(disable_push, __itt_model_disable) +_ANNOTATE_DECLARE_0(disable_pop) +_ANNOTATE_DECLARE_1(aggregate_task, size_t) +_ANNOTATE_DECLARE_0_INT(is_collection_disabled) + +/* All of the symbols potentially in the library + */ +struct __annotate_routines { + volatile int initialized; + __annotate_site_beginA_t site_beginA; + __annotate_site_end_2_t site_end_2; + __annotate_task_beginA_t task_beginA; + __annotate_task_end_2_t task_end_2; + __annotate_iteration_taskA_t iteration_taskA; + __annotate_lock_acquire_2_t lock_acquire_2; + __annotate_lock_release_2_t lock_release_2; + __annotate_record_allocation_t record_allocation; + __annotate_record_deallocation_t record_deallocation; + __annotate_induction_uses_t induction_uses; + __annotate_reduction_uses_t reduction_uses; + __annotate_observe_uses_t observe_uses; + __annotate_clear_uses_t clear_uses; + __annotate_disable_push_t disable_push; + __annotate_disable_pop_t disable_pop; + __annotate_aggregate_task_t aggregate_task; + __annotate_is_collection_disabled_t is_collection_disabled; +}; + +/* This comdat-ed routine means there is a single instance of the function pointer + * structure per image + */ +static __inline struct __annotate_routines* __annotate_routines() +{ + static struct __annotate_routines __annotate_routines; + return &__annotate_routines; +} + +/* This routine is called to get the address of an initialized + * set of function pointers for the annotation routines. + */ + +#ifdef ANNOTATE_DECLARE +extern struct __annotate_routines* ANNOTATEAPI __annotate_routines_init(struct __annotate_routines* itt); +#else +#ifdef ANNOTATE_DEFINE + /* */ +#else + static __inline +#endif +struct __annotate_routines* +ANNOTATEAPI +__annotate_routines_init(struct __annotate_routines* itt) { + + if (itt->initialized) { + return itt; + } else { + + /* Initialized by first invocation + * This assumes that the code here can be executed successfully + * by multiple threads, should that ever happen. + */ + int do_disable_pop = 0; +#if !(defined(WIN32) || defined(_WIN32)) + char* lib_name = NULL; +#endif + + lib_t itt_notify = 0; + +#if defined(WIN32) || defined(_WIN32) + itt_notify = __itt_load_lib("libittnotify.dll"); +#else + if (sizeof(void*) > 4) { + lib_name = getenv("INTEL_LIBITTNOTIFY64"); + } else { + lib_name = getenv("INTEL_LIBITTNOTIFY32"); + } + if (lib_name) { + itt_notify = __itt_load_lib(lib_name); + } +#endif + if (itt_notify != NULL) { + + /* The static variables initialized and itt are reported as race conditions + * or inconsistent lock usage by Dependencies Modeling in some obscure cases + * involving multiple dlls. Ignoring this initialization phase gets rid of + * this problem. + */ + __annotate_disable_push_t disable_push; + __annotate_is_collection_disabled_t is_collection_disabled; + disable_push = (__annotate_disable_push_t) __itt_get_proc(itt_notify, "__itt_model_disable_push"); + is_collection_disabled = (__annotate_is_collection_disabled_t) __itt_get_proc(itt_notify, "__itt_model_is_collection_disabled"); + if (disable_push) { + if ( ! (is_collection_disabled && is_collection_disabled()) ) + { + // disable collection only if it is not disabled already (for example, started paused) + disable_push(__itt_model_disable_observation); + do_disable_pop = 1; + } + } + itt->site_beginA = (__annotate_site_beginA_t) __itt_get_proc(itt_notify, "__itt_model_site_beginA"); + itt->site_end_2 = (__annotate_site_end_2_t) __itt_get_proc(itt_notify, "__itt_model_site_end_2"); + itt->task_beginA = (__annotate_task_beginA_t) __itt_get_proc(itt_notify, "__itt_model_task_beginA"); + itt->task_end_2 = (__annotate_task_end_2_t) __itt_get_proc(itt_notify, "__itt_model_task_end_2"); + itt->iteration_taskA = (__annotate_iteration_taskA_t) __itt_get_proc(itt_notify, "__itt_model_iteration_taskA"); + itt->lock_acquire_2 = (__annotate_lock_acquire_2_t) __itt_get_proc(itt_notify, "__itt_model_lock_acquire_2"); + itt->lock_release_2 = (__annotate_lock_release_2_t) __itt_get_proc(itt_notify, "__itt_model_lock_release_2"); + itt->record_allocation = (__annotate_record_allocation_t) __itt_get_proc(itt_notify, "__itt_model_record_allocation"); + itt->record_deallocation = (__annotate_record_deallocation_t)__itt_get_proc(itt_notify, "__itt_model_record_deallocation"); + itt->induction_uses = (__annotate_induction_uses_t) __itt_get_proc(itt_notify, "__itt_model_induction_uses"); + itt->reduction_uses = (__annotate_reduction_uses_t) __itt_get_proc(itt_notify, "__itt_model_reduction_uses"); + itt->observe_uses = (__annotate_observe_uses_t) __itt_get_proc(itt_notify, "__itt_model_observe_uses"); + itt->clear_uses = (__annotate_clear_uses_t) __itt_get_proc(itt_notify, "__itt_model_clear_uses"); + itt->disable_push = disable_push; + itt->disable_pop = (__annotate_disable_pop_t) __itt_get_proc(itt_notify, "__itt_model_disable_pop"); + itt->aggregate_task = (__annotate_aggregate_task_t) __itt_get_proc(itt_notify, "__itt_model_aggregate_task"); + itt->is_collection_disabled = is_collection_disabled; + } + /* No-op routine for any that didn't get resolved */ + if (!itt->site_beginA) itt->site_beginA = __annotate_site_beginA_t_nop; + if (!itt->site_end_2) itt->site_end_2 = __annotate_site_end_2_t_nop; + if (!itt->task_beginA) itt->task_beginA = __annotate_task_beginA_t_nop; + if (!itt->task_end_2) itt->task_end_2 = __annotate_task_end_2_t_nop; + if (!itt->iteration_taskA) itt->iteration_taskA = __annotate_iteration_taskA_t_nop; + if (!itt->lock_acquire_2) itt->lock_acquire_2 = __annotate_lock_acquire_2_t_nop; + if (!itt->lock_release_2) itt->lock_release_2 = __annotate_lock_release_2_t_nop; + if (!itt->record_allocation) itt->record_allocation = __annotate_record_allocation_t_nop; + if (!itt->record_deallocation) itt->record_deallocation=__annotate_record_deallocation_t_nop; + if (!itt->induction_uses) itt->induction_uses = __annotate_induction_uses_t_nop; + if (!itt->reduction_uses) itt->reduction_uses = __annotate_reduction_uses_t_nop; + if (!itt->observe_uses) itt->observe_uses = __annotate_observe_uses_t_nop; + if (!itt->clear_uses) itt->clear_uses = __annotate_clear_uses_t_nop; + if (!itt->disable_push) itt->disable_push = __annotate_disable_push_t_nop; + if (!itt->disable_pop) itt->disable_pop = __annotate_disable_pop_t_nop; + if (!itt->aggregate_task) itt->aggregate_task = __annotate_aggregate_task_t_nop; + if (!itt->is_collection_disabled) itt->is_collection_disabled = __annotate_is_collection_disabled_t_nop; + + itt->initialized = 1; + + if (do_disable_pop) { + itt->disable_pop(); + } + } + return itt; +} +#endif /* ANNOTATE_DECLARE */ + +/* For C++ only, use a class to force initialization */ + +#if defined(__cplusplus) && defined(WIN32) +/* Force one-shot initialization so individual calls don't need it */ +static struct __annotate_routines* __annotate_routines_s = __annotate_routines_init( __annotate_routines() ); +#endif + +/* For C++, allow the Annotate::SiteBegin(x) form. For Windows CLR, this is the default + * expansion for the macros (with no-inline) to get the best call stacks in the tools. */ +#if defined(__cplusplus) +/* Ensure this code is managed and non-inlinable */ +#if defined(WIN32) && defined(__CLR_VER) +#pragma managed(push, on) +#define ANNOTATE_CLR_NOINLINE __declspec(noinline) +#else +#define ANNOTATE_CLR_NOINLINE +#endif +class Annotate { +public: + static ANNOTATE_CLR_NOINLINE void SiteBegin(const char* site) { _ANNOTATE_ROUTINES_ADDR->site_beginA(site); } + static ANNOTATE_CLR_NOINLINE void SiteEnd() { _ANNOTATE_ROUTINES_ADDR->site_end_2(); } + static ANNOTATE_CLR_NOINLINE void TaskBegin(const char* task) { _ANNOTATE_ROUTINES_ADDR->task_beginA(task); } + static ANNOTATE_CLR_NOINLINE void TaskEnd() { _ANNOTATE_ROUTINES_ADDR->task_end_2(); } + static ANNOTATE_CLR_NOINLINE void IterationTask(const char* task) { _ANNOTATE_ROUTINES_ADDR->iteration_taskA(task); } + static ANNOTATE_CLR_NOINLINE void LockAcquire(void* lockId) { _ANNOTATE_ROUTINES_ADDR->lock_acquire_2(lockId); } + static ANNOTATE_CLR_NOINLINE void LockRelease(void* lockId) { _ANNOTATE_ROUTINES_ADDR->lock_release_2(lockId); } + static ANNOTATE_CLR_NOINLINE void RecordAllocation(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->record_allocation(p, s); } + static ANNOTATE_CLR_NOINLINE void RecordDeallocation(void *p) { _ANNOTATE_ROUTINES_ADDR->record_deallocation(p); } + static ANNOTATE_CLR_NOINLINE void InductionUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->induction_uses(p, s); } + static ANNOTATE_CLR_NOINLINE void ReductionUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->reduction_uses(p, s); } + static ANNOTATE_CLR_NOINLINE void ObserveUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->observe_uses(p, s); } + static ANNOTATE_CLR_NOINLINE void ClearUses(void *p) { _ANNOTATE_ROUTINES_ADDR->clear_uses(p); } + static ANNOTATE_CLR_NOINLINE void DisablePush(__itt_model_disable d) { _ANNOTATE_ROUTINES_ADDR->disable_push(d); } + static ANNOTATE_CLR_NOINLINE void DisablePop() { _ANNOTATE_ROUTINES_ADDR->disable_pop(); } + static ANNOTATE_CLR_NOINLINE void AggregateTask(size_t c) { _ANNOTATE_ROUTINES_ADDR->aggregate_task(c); } +}; +#if defined(WIN32) && defined(__CLR_VER) +#pragma managed(pop) +#endif +#undef ANNOTATE_CLR_NOINLINE +#endif + +#if defined(__cplusplus) && defined(WIN32) && defined(__CLR_VER) + +#define ANNOTATE_SITE_BEGIN(_SITE) Annotate::SiteBegin(#_SITE) +#define ANNOTATE_SITE_END(...) Annotate::SiteEnd() +#define ANNOTATE_TASK_BEGIN(_TASK) Annotate::TaskBegin(#_TASK) +#define ANNOTATE_TASK_END(...) Annotate::TaskEnd() +#define ANNOTATE_ITERATION_TASK(_TASK) Annotate::IterationTask(#_TASK) +#define ANNOTATE_LOCK_ACQUIRE(_ADDR) Annotate::LockAcquire(_ADDR) +#define ANNOTATE_LOCK_RELEASE(_ADDR) Annotate::LockRelease(_ADDR) +#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) Annotate::RecordAllocation((_ADDR), (_SIZE)) +#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) Annotate::RecordDeallocation(_ADDR) +#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) Annotate::InductionUses((_ADDR), (_SIZE)) +#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) Annotate::ReductionUses((_ADDR), (_SIZE)) +#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) Annotate::ObserveUses((_ADDR), (_SIZE)) +#define ANNOTATE_CLEAR_USES(_ADDR) Annotate::ClearUses(_ADDR) +#define ANNOTATE_DISABLE_OBSERVATION_PUSH Annotate::DisablePush(itt_model_disable_observation) +#define ANNOTATE_DISABLE_OBSERVATION_POP Annotate::DisablePop() +#define ANNOTATE_DISABLE_COLLECTION_PUSH Annotate::DisablePush(__itt_model_disable_collection) +#define ANNOTATE_DISABLE_COLLECTION_POP Annotate::DisablePop() +#define ANNOTATE_AGGREGATE_TASK(_COUNT) Annotate::AggregateTask(_COUNT) + +#else + +/* Mark the start of a site (region) to be analyzed by the tool */ +#define ANNOTATE_SITE_BEGIN(_SITE) _ANNOTATE_CALL_1(site_beginA, #_SITE) + +/* Mark the end of a site (region) to be analyzed by the tool and + * indicate a WaitForAll task synchronization */ +#define ANNOTATE_SITE_END(...) _ANNOTATE_CALL_0(site_end_2) + +/* Mark the beginning of a region of code that constitutes a task */ +#define ANNOTATE_TASK_BEGIN(_TASK) _ANNOTATE_CALL_1(task_beginA, #_TASK) + +/* Mark the end of a region of code that constitutes a task */ +#define ANNOTATE_TASK_END(...) _ANNOTATE_CALL_0(task_end_2) + +/* Mark the break between one task and the next task (a "split" description model + * rather than a "begin/end" description model. */ +#define ANNOTATE_ITERATION_TASK(_TASK) _ANNOTATE_CALL_1(iteration_taskA, #_TASK) + +/* Acquire a lock identified by lockId */ +#define ANNOTATE_LOCK_ACQUIRE(_ADDR) _ANNOTATE_CALL_1(lock_acquire_2, (_ADDR)) + +/* Release a lock identified by lockId */ +#define ANNOTATE_LOCK_RELEASE(_ADDR) _ANNOTATE_CALL_1(lock_release_2, (_ADDR)) + +/* Record user allocation of memory */ +#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) _ANNOTATE_CALL_2(record_allocation, (_ADDR), (_SIZE)) + +/* Record user deallocation of memory */ +#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) _ANNOTATE_CALL_1(record_deallocation, (_ADDR)) + +/* Denote storage as an inductive value */ +#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(induction_uses, (_ADDR), (_SIZE)) + +/* Denote storage as a reduction */ +#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(reduction_uses, (_ADDR), (_SIZE)) + +/* Record all observations of uses */ +#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(observe_uses, (_ADDR), (_SIZE)) + +/* Clear handling of values */ +#define ANNOTATE_CLEAR_USES(_ADDR) _ANNOTATE_CALL_1(clear_uses, (_ADDR)) + +/* Push disable of observations */ +#define ANNOTATE_DISABLE_OBSERVATION_PUSH _ANNOTATE_CALL_1(disable_push, __itt_model_disable_observation) + +/* Pop disable of observations */ +#define ANNOTATE_DISABLE_OBSERVATION_POP _ANNOTATE_CALL_0(disable_pop) + +/* Push disable of collection */ +#define ANNOTATE_DISABLE_COLLECTION_PUSH _ANNOTATE_CALL_1(disable_push, __itt_model_disable_collection) + +/* Pop disable of collection */ +#define ANNOTATE_DISABLE_COLLECTION_POP _ANNOTATE_CALL_0(disable_pop) + +/* Task aggregation */ +#define ANNOTATE_AGGREGATE_TASK(_COUNT) _ANNOTATE_CALL_1(aggregate_task, (_COUNT)) + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ANNOTATE_EXPAND_NULL */ + +#endif /* _ADVISOR_ANNOTATE_H_ */ diff --git a/external/vtune/linux/include/advisor_annotate.f90 b/external/vtune/linux/include/advisor_annotate.f90 new file mode 100644 index 0000000000..d4d2d34d62 --- /dev/null +++ b/external/vtune/linux/include/advisor_annotate.f90 @@ -0,0 +1,706 @@ +! ======================================================================== +! +! SAMPLE SOURCE CODE - SUBJECT TO THE TERMS OF END-USER LICENSE AGREEMENT +! FOR INTEL(R) ADVISOR XE 2016. +! +! Copyright (c) 2012-2015 Intel Corporation. All rights reserved. +! +! THIS FILE IS PROVIDED "AS IS" WITH NO WARRANTIES, EXPRESS OR IMPLIED, +! INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY, +! FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT OF INTELLECTUAL +! PROPERTY RIGHTS. +! +! ======================================================================== +! + +!-------- +! +! This file defines functions used by the Intel(R) Advisor XE +! "Dependencies Modeling" and "Suitability Modeling" analysis, which +! are described in the "Annotations" section of the help. +! +! Version of the annotations. +! The presence of this macro serves to idetify the annotation definition +! file and the form of annotations. +! INTEL_ADVISOR_ANNOTATION_VERSION 1.0 +!-------- + +module advisor_annotate + use, intrinsic :: iso_c_binding, only: C_PTR, C_FUNPTR, C_INT, C_CHAR, C_NULL_CHAR, C_F_PROCPOINTER, C_LOC, C_ASSOCIATED + implicit none + + !-------- + ! + ! Public interface + ! + !-------- + + public :: annotate_site_begin + public :: annotate_site_end + public :: annotate_task_begin + public :: annotate_task_end + public :: annotate_iteration_task + public :: annotate_lock_acquire + public :: annotate_lock_release + public :: annotate_disable_observation_push + public :: annotate_disable_observation_pop + public :: annotate_disable_collection_push + public :: annotate_disable_collection_pop + public :: annotate_induction_uses + public :: annotate_reduction_uses + public :: annotate_observe_uses + public :: annotate_clear_uses + public :: annotate_aggregate_task + + interface annotate_induction_uses + module procedure annotate_induction_uses_i2 + module procedure annotate_induction_uses_i4 + module procedure annotate_induction_uses_i8 + module procedure annotate_induction_uses_r4 + module procedure annotate_induction_uses_r8 + module procedure annotate_induction_uses_c4 + module procedure annotate_induction_uses_c8 + end interface annotate_induction_uses + + interface annotate_reduction_uses + module procedure annotate_reduction_uses_i2 + module procedure annotate_reduction_uses_i4 + module procedure annotate_reduction_uses_i8 + module procedure annotate_reduction_uses_r4 + module procedure annotate_reduction_uses_r8 + module procedure annotate_reduction_uses_c4 + module procedure annotate_reduction_uses_c8 + end interface annotate_reduction_uses + + interface annotate_observe_uses + module procedure annotate_observe_uses_i2 + module procedure annotate_observe_uses_i4 + module procedure annotate_observe_uses_i8 + module procedure annotate_observe_uses_r4 + module procedure annotate_observe_uses_r8 + module procedure annotate_observe_uses_c4 + module procedure annotate_observe_uses_c8 + end interface annotate_observe_uses + + interface annotate_clear_uses + module procedure annotate_clear_uses_i2 + module procedure annotate_clear_uses_i4 + module procedure annotate_clear_uses_i8 + module procedure annotate_clear_uses_r4 + module procedure annotate_clear_uses_r8 + module procedure annotate_clear_uses_c4 + module procedure annotate_clear_uses_c8 + end interface annotate_clear_uses + + private + + !-------- + ! + ! Interfaces to the itt_notify entry points + ! + !-------- + + enum, bind(C) + enumerator :: disable_observation + enumerator :: disable_collection + end enum + + abstract interface + + subroutine itt_proc_noargs() bind(C) + end subroutine itt_proc_noargs + + subroutine itt_proc_with_name(name, len) bind(C) + import + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + end subroutine itt_proc_with_name + + subroutine itt_proc_with_int(intval) bind(C) + import + integer(kind=C_INT), intent(in), value :: intval + end subroutine itt_proc_with_int + + subroutine itt_proc_with_disable(disable_kind) bind(C) + import + integer(kind=C_INT), intent(in), value :: disable_kind + end subroutine itt_proc_with_disable + + subroutine itt_proc_with_addr_size(addr, size) bind(C) + import + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + end subroutine itt_proc_with_addr_size + + end interface + + !-------- + ! + ! Subroutine pointer variables to access the itt_notify entry points + ! + !-------- + +!dec$ if defined(use_initialized_proc_ptrs) + procedure(itt_proc_with_name), pointer :: site_begin => site_begin_load + procedure(itt_proc_noargs), pointer :: site_end_2 => site_end_2_load + procedure(itt_proc_with_name), pointer :: task_begin => task_begin_load + procedure(itt_proc_noargs), pointer :: task_end_2 => task_end_2_load + procedure(itt_proc_noargs), pointer :: iteration_task => iteration_task_load + procedure(itt_proc_with_int), pointer :: lock_acquire_2 => lock_acquire_2_load + procedure(itt_proc_with_int), pointer :: lock_release_2 => lock_release_2_load + procedure(itt_proc_with_disable), pointer :: disable_push => disable_push_load + procedure(itt_proc_noargs), pointer :: disable_pop => disable_pop_load + procedure(itt_proc_with_addr_size), pointer :: induction_uses => induction_uses_load + procedure(itt_proc_with_addr_size), pointer :: reduction_uses => reduction_uses_load + procedure(itt_proc_with_addr_size), pointer :: observe_uses => observe_uses_load + procedure(itt_proc_with_addr_size), pointer :: clear_uses => clear_uses_load + procedure(itt_proc_with_int), pointer :: aggregate_task => aggregate_task_load +!dec$ else + procedure(itt_proc_with_name), pointer :: site_begin + procedure(itt_proc_noargs), pointer :: site_end_2 + procedure(itt_proc_with_name), pointer :: task_begin + procedure(itt_proc_noargs), pointer :: task_end_2 + procedure(itt_proc_with_name), pointer :: iteration_task + procedure(itt_proc_with_int), pointer :: lock_acquire_2 + procedure(itt_proc_with_int), pointer :: lock_release_2 + procedure(itt_proc_with_disable), pointer :: disable_push + procedure(itt_proc_noargs), pointer :: disable_pop + procedure(itt_proc_with_addr_size), pointer :: induction_uses + procedure(itt_proc_with_addr_size), pointer :: reduction_uses + procedure(itt_proc_with_addr_size), pointer :: observe_uses + procedure(itt_proc_with_addr_size), pointer :: clear_uses + procedure(itt_proc_with_int), pointer :: aggregate_task + + logical :: initialized = .false. +!dec$ endif + + + !-------- + ! + ! Functions for loading dynamic libraries + ! + !-------- + + interface + + !dec$ if defined(_WIN32) + + !DEC$OBJCOMMENT LIB:"KERNEL32.LIB" + !DEC$OBJCOMMENT LIB:"advisor.lib" + + function load_library(file) + import + !dec$ attributes default, stdcall, decorate, alias : 'LoadLibraryA' :: load_library + type(C_PTR) :: load_library + character(kind=C_CHAR), dimension(*), intent(in) :: file + end function load_library + + function get_library_entry(library, proc_name) + import + !dec$ attributes default, stdcall, decorate, alias : 'GetProcAddress' :: get_library_entry + type(C_FUNPTR) :: get_library_entry + type(C_PTR), intent(in), value :: library + character(kind=C_CHAR), dimension(*), intent(in) :: proc_name + end function get_library_entry + + !dec$ else + + function load_library(file, mode) bind(C, name="dlopen") + import + type(C_PTR) :: load_library + character(kind=C_CHAR), dimension(*), intent(in) :: file + integer(kind=C_INT), intent(in), value :: mode + end function load_library + + function get_library_entry(library, proc_name) bind(C, name="dlsym") + import + type(C_FUNPTR) :: get_library_entry + type(C_PTR), intent(in), value :: library + character(kind=C_CHAR), dimension(*), intent(in) :: proc_name + end function get_library_entry + + !dec$ endif + + end interface + +contains + + !-------- + ! + ! The public interface subroutines just make sure the module has been initialized, + ! and then make an indirect call through the corresponding pointer variables. + ! Initializing the module tries to load the itt notify library. If the library + ! is loaded successfully, the variables are set to point to the corresponding + ! entries in the library. If the library load fails, the variables are set to point + ! to stub routines. + ! + !-------- + + subroutine annotate_site_begin(site_name) + !DEC$ ATTRIBUTES DEFAULT :: annotate_site_begin + character(len=*), intent(in) :: site_name + if (.not. initialized) call load_itt_library + call site_begin(site_name, len(site_name)) + end subroutine annotate_site_begin + + subroutine annotate_site_end + !DEC$ ATTRIBUTES DEFAULT :: annotate_site_end + if (.not. initialized) call load_itt_library + call site_end_2 + end subroutine annotate_site_end + + subroutine annotate_task_begin(task_name) + !DEC$ ATTRIBUTES DEFAULT :: annotate_task_begin + character(len=*), intent(in) :: task_name + if (.not. initialized) call load_itt_library + call task_begin(task_name, len(task_name)) + end subroutine annotate_task_begin + + subroutine annotate_task_end + !DEC$ ATTRIBUTES DEFAULT :: annotate_task_end + if (.not. initialized) call load_itt_library + call task_end_2 + end subroutine annotate_task_end + + subroutine annotate_iteration_task(task_name) + !DEC$ ATTRIBUTES DEFAULT :: annotate_iteration_task + character(len=*), intent(in) :: task_name + if (.not. initialized) call load_itt_library + call iteration_task(task_name, len(task_name)) + end subroutine annotate_iteration_task + + subroutine annotate_lock_acquire(lock_id) + !DEC$ ATTRIBUTES DEFAULT :: annotate_lock_acquire + integer, intent(in) :: lock_id + if (.not. initialized) call load_itt_library + call lock_acquire_2(lock_id) + end subroutine annotate_lock_acquire + + subroutine annotate_lock_release(lock_id) + !DEC$ ATTRIBUTES DEFAULT :: annotate_lock_release + integer, intent(in) :: lock_id + if (.not. initialized) call load_itt_library + call lock_release_2(lock_id) + end subroutine annotate_lock_release + + subroutine annotate_disable_observation_push + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_observation_push + if (.not. initialized) call load_itt_library + call disable_push(disable_observation) + end subroutine annotate_disable_observation_push + + subroutine annotate_disable_observation_pop + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_observation_pop + if (.not. initialized) call load_itt_library + call disable_pop + end subroutine annotate_disable_observation_pop + + subroutine annotate_disable_collection_push + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_collection_push + if (.not. initialized) call load_itt_library + call disable_push(disable_collection) + end subroutine annotate_disable_collection_push + + subroutine annotate_disable_collection_pop + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_collection_pop + if (.not. initialized) call load_itt_library + call disable_pop + end subroutine annotate_disable_collection_pop + + subroutine annotate_induction_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 2) + end subroutine annotate_induction_uses_i2 + + subroutine annotate_induction_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 4) + end subroutine annotate_induction_uses_i4 + + subroutine annotate_induction_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 8) + end subroutine annotate_induction_uses_i8 + + subroutine annotate_induction_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 4) + end subroutine annotate_induction_uses_r4 + + subroutine annotate_induction_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 8) + end subroutine annotate_induction_uses_r8 + + subroutine annotate_induction_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 8) + end subroutine annotate_induction_uses_c4 + + subroutine annotate_induction_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 16) + end subroutine annotate_induction_uses_c8 + + subroutine annotate_reduction_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 2) + end subroutine annotate_reduction_uses_i2 + + subroutine annotate_reduction_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 4) + end subroutine annotate_reduction_uses_i4 + + subroutine annotate_reduction_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 8) + end subroutine annotate_reduction_uses_i8 + + subroutine annotate_reduction_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 4) + end subroutine annotate_reduction_uses_r4 + + subroutine annotate_reduction_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 8) + end subroutine annotate_reduction_uses_r8 + + subroutine annotate_reduction_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 8) + end subroutine annotate_reduction_uses_c4 + + subroutine annotate_reduction_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 16) + end subroutine annotate_reduction_uses_c8 + + subroutine annotate_observe_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 2) + end subroutine annotate_observe_uses_i2 + + subroutine annotate_observe_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 4) + end subroutine annotate_observe_uses_i4 + + subroutine annotate_observe_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 8) + end subroutine annotate_observe_uses_i8 + + subroutine annotate_observe_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 4) + end subroutine annotate_observe_uses_r4 + + subroutine annotate_observe_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 8) + end subroutine annotate_observe_uses_r8 + + subroutine annotate_observe_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 8) + end subroutine annotate_observe_uses_c4 + + subroutine annotate_observe_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 16) + end subroutine annotate_observe_uses_c8 + + subroutine annotate_clear_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 2) + end subroutine annotate_clear_uses_i2 + + subroutine annotate_clear_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 4) + end subroutine annotate_clear_uses_i4 + + subroutine annotate_clear_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 8) + end subroutine annotate_clear_uses_i8 + + subroutine annotate_clear_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 4) + end subroutine annotate_clear_uses_r4 + + subroutine annotate_clear_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 8) + end subroutine annotate_clear_uses_r8 + + subroutine annotate_clear_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 8) + end subroutine annotate_clear_uses_c4 + + subroutine annotate_clear_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 16) + end subroutine annotate_clear_uses_c8 + + subroutine annotate_aggregate_task(count) + !DEC$ ATTRIBUTES DEFAULT :: annotate_aggregate_task + integer, intent(in) :: count + if (.not. initialized) call load_itt_library + call aggregate_task(count) + end subroutine annotate_aggregate_task + + + !-------- + ! + ! These are the load-library subroutines. + ! + !-------- + +!dec$ if defined(use_initialized_proc_ptrs) + + subroutine site_begin_load(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + call load_itt_library + call site_begin(name, len) + end subroutine site_begin_load + + subroutine site_end_2_load bind(C) + call load_itt_library + call site_end_2 + end subroutine site_end_2_load + + subroutine task_begin_load(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + call load_itt_library + call task_begin(name, len) + end subroutine task_begin_load + + subroutine task_end_2_load bind(C) + call load_itt_library + call task_end_2 + end subroutine task_end_2_load + + subroutine iteration_task_load(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + call load_itt_library + call iteration_task(name, len) + end subroutine iteration_task_load + + subroutine lock_acquire_2_load(lock_id) bind(C) + integer(kind=C_INT), intent(in), value :: lock_id + call load_itt_library + call lock_acquire_2(lock_id) + end subroutine lock_acquire_2_load + + subroutine lock_release_2_load(lock_id) bind(C) + integer(kind=C_INT), intent(in), value :: lock_id + call load_itt_library + call lock_release_2(lock_id) + end subroutine lock_release_2_load + + subroutine disable_push_load(disable_kind) bind(C) + integer(kind=C_INT), intent(in), value :: disable_kind + call load_itt_library + call disable_push(disable_kind) + end subroutine disable_push_load + + subroutine disable_pop_load bind(C) + call load_itt_library + call disable_pop + end subroutine disable_pop_load + + subroutine induction_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call induction_uses(addr, size) + end subroutine induction_uses_load + + subroutine reduction_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call reduction_uses(addr, size) + end subroutine reduction_uses_load + + subroutine observe_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call observe_uses(addr, size) + end subroutine observe_uses_load + + subroutine clear_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call clear_uses(addr, size) + end subroutine clear_uses_load + + subroutine annotate_task_load(count) bind(C) + integer(kind=C_INT), intent(in), value :: count + call load_itt_library + call annotate_task(count) + end subroutine annotate_task_load + +!dec$ endif + + !-------- + ! + ! These are the stub subroutines. + ! + !-------- + + subroutine itt_proc_stub() bind(C) + end subroutine itt_proc_stub + + subroutine itt_proc_with_name_stub(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + end subroutine itt_proc_with_name_stub + + subroutine itt_proc_with_int_stub(count) bind(C) + integer(kind=C_INT), intent(in), value :: count + end subroutine itt_proc_with_int_stub + + subroutine itt_proc_with_disable_stub(disable_kind) bind(C) + integer(kind=C_INT), value :: disable_kind + end subroutine itt_proc_with_disable_stub + + subroutine itt_proc_with_addr_size_stub(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + end subroutine itt_proc_with_addr_size_stub + + !-------- + ! + ! Internal support code to load the itt notify library and get pointers + ! to its entry points. + ! + !-------- + + subroutine load_itt_library + type(C_PTR) :: library + character*1024 ittnotify_path + +!dec$ if defined(_WIN32) + library = load_library("libittnotify.dll"C) +!dec$ else if defined(__APPLE__) + library = load_library("libittnotify.dylib"C, 0) +!dec$ else +!dec$ if defined(__X86_64) .or. defined(_M_X64) + call getenv('INTEL_LIBITTNOTIFY64',ittnotify_path) +!dec$ else + call getenv('INTEL_LIBITTNOTIFY32',ittnotify_path) +!dec$ endif + if ( ittnotify_path /= '' ) then + ! print *,' libpath: "'//trim(ittnotify_path)//'"' + library = load_library(trim(ittnotify_path)//char(0), 1) ! 1 is RTLD_LAZY + else + ! print *,' libpath: "libittnotify.so"' + library = load_library("libittnotify.so"C, 1) ! 1 is RTLD_LAZY + endif +!dec$ endif + + if (C_ASSOCIATED(library)) then + ! print *, "Library loaded" + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_site_beginAL"C), site_begin) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_site_end_2"C), site_end_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_task_beginAL"C), task_begin) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_task_end_2"C), task_end_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_iteration_taskAL"C), iteration_task) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_lock_acquire_2"C), lock_acquire_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_lock_release_2"C), lock_release_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_disable_push"C), disable_push) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_disable_pop"C), disable_pop) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_induction_uses"C), induction_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_reduction_uses"C), reduction_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_observe_uses"C), observe_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_clear_uses"C), clear_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_aggregate_task"C), aggregate_task) + else + ! print *, "Library not found" + site_begin => itt_proc_with_name_stub + site_end_2 => itt_proc_stub + task_begin => itt_proc_with_name_stub + task_end_2 => itt_proc_stub + iteration_task => itt_proc_with_name_stub + lock_acquire_2 => itt_proc_with_int_stub + lock_release_2 => itt_proc_with_int_stub + disable_push => itt_proc_with_disable_stub + disable_pop => itt_proc_stub + induction_uses => itt_proc_with_addr_size_stub + reduction_uses => itt_proc_with_addr_size_stub + observe_uses => itt_proc_with_addr_size_stub + clear_uses => itt_proc_with_addr_size_stub + aggregate_task => itt_proc_with_int_stub + end if + + initialized = .true. + end subroutine + +end module advisor_annotate diff --git a/external/vtune/linux/include/internal/ittnotify.h b/external/vtune/linux/include/internal/ittnotify.h new file mode 100644 index 0000000000..43f4f1f3ae --- /dev/null +++ b/external/vtune/linux/include/internal/ittnotify.h @@ -0,0 +1,260 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _INTERNAL_ITTNOTIFY_H_ +#define _INTERNAL_ITTNOTIFY_H_ + +/** + * @file + * @brief Internal User API functions and types + */ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define INTEL_ITTNOTIFY_API_PRIVATE +#include "../ittnotify.h" + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _INTERNAL_ITTNOTIFY_H_ */ diff --git a/external/vtune/linux/include/ittnotify.f90 b/external/vtune/linux/include/ittnotify.f90 new file mode 100644 index 0000000000..ba49cb0c4a --- /dev/null +++ b/external/vtune/linux/include/ittnotify.f90 @@ -0,0 +1,473 @@ +! ======================================================================== +! +! This file is provided under a dual BSD/GPLv2 license. When using or +! redistributing this file, you may do so under either license. +! +! GPL LICENSE SUMMARY +! +! Copyright (c) 2005-2014 Intel Corporation. All rights reserved. +! +! This program is free software; you can redistribute it and/or modify +! it under the terms of version 2 of the GNU General Public License as +! published by the Free Software Foundation. +! +! 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +! The full GNU General Public License is included in this distribution +! in the file called LICENSE.GPL. +! +! Contact Information: +! http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ +! +! BSD LICENSE +! +! Copyright (c) 2005-2014 Intel Corporation. All rights reserved. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! +! * Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions and the following disclaimer in +! the documentation and/or other materials provided with the +! distribution. +! * Neither the name of Intel Corporation nor the names of its +! contributors may be used to endorse or promote products derived +! from this software without specific prior written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +! OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! +! ======================================================================== +! + +!-------- +! +! This file defines functions used by Intel(R) Parallel Inspector and +! Amplifier. +! +! Version of ittnotify that was used to generate this file. +! This is not Fortran code that can be used to check but rather a comment +! that only serves to identify the interface. +! INTEL_ITT_FORTRAN_API_VERSION 3.0 +!-------- + +module ittnotify + use, intrinsic :: iso_c_binding, only: C_PTR, C_FUNPTR, C_INT, C_CHAR, C_NULL_CHAR, C_F_PROCPOINTER, C_LOC, C_ASSOCIATED + implicit none + + !-------- + ! + ! Public interface + ! + !-------- + integer, parameter :: itt_ptr = int_ptr_kind() + public :: itt_pause + public :: itt_resume + public :: itt_thread_ignore + public :: itt_suppress_push + public :: itt_suppress_pop + public :: itt_suppress_mark_range + public :: itt_suppress_clear_range + public :: itt_sync_prepare + public :: itt_sync_cancel + public :: itt_sync_acquired + public :: itt_sync_releasing + public :: itt_fsync_prepare + public :: itt_fsync_cancel + public :: itt_fsync_acquired + public :: itt_fsync_releasing + public :: itt_sync_destroy + public :: itt_sync_create + public :: itt_sync_rename + public :: itt_thread_set_name + public :: itt_heap_record_memory_growth_begin + public :: itt_heap_record_memory_growth_end + public :: itt_heap_reset_detection + public :: itt_heap_record + + integer, parameter, public :: itt_attr_barrier = 1 + integer, parameter, public :: itt_attr_mutex = 2 + integer, parameter, public :: itt_suppress_threading_errors = 255 + integer, parameter, public :: itt_suppress_memory_errors = 65280 + integer, parameter, public :: itt_suppress_all_errors = 2147483647 + integer, parameter, public :: itt_unsuppress_range = 0 + integer, parameter, public :: itt_suppress_range = 1 + integer, parameter, public :: itt_heap_leaks = 1 + integer, parameter, public :: itt_heap_growth = 2 + + private + + abstract interface + + subroutine itt_proc_none() bind(C) + import + end subroutine itt_proc_none + + subroutine itt_proc_sup_push(mask) bind(C) + import + integer, intent(in), value :: mask + end subroutine itt_proc_sup_push + + subroutine itt_proc_sup_range(action, mask, addr, size) bind(C) + import + integer, intent(in), value :: action + integer, intent(in), value :: mask + integer(kind=itt_ptr), intent(in), value :: addr + integer(kind=itt_ptr), intent(in), value :: size + end subroutine itt_proc_sup_range + + subroutine itt_proc_address(addr) bind(C) + import + integer(kind=itt_ptr), intent(in), value :: addr + end subroutine itt_proc_address + + subroutine itt_proc_create(addr, objname, attribute) bind(C) + import + integer(kind=itt_ptr), intent(in), value :: addr + character(kind=C_CHAR), dimension(*), intent(in) :: objname + integer, intent(in), value :: attribute + end subroutine itt_proc_create + + subroutine itt_proc_name(name) bind(C) + import + character(kind=C_CHAR), dimension(*), intent(in) :: name + end subroutine itt_proc_name + + subroutine itt_proc_rename(addr, objname) bind(C) + import + integer(kind=itt_ptr), intent(in), value :: addr + character(kind=C_CHAR), dimension(*), intent(in) :: objname + end subroutine itt_proc_rename + + subroutine itt_proc_heapmask(heapmask) bind(C) + import + integer, intent(in), value :: heapmask + end subroutine itt_proc_heapmask + + end interface + + type(C_FUNPTR) :: itt_pause_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_pause_ptr__3_0' :: itt_pause_fort_ptr + type(C_FUNPTR) :: itt_resume_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_resume_ptr__3_0' :: itt_resume_fort_ptr + type(C_FUNPTR) :: itt_thread_ignore_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_thread_ignore_ptr__3_0' :: itt_thread_ignore_fort_ptr + type(C_FUNPTR) :: itt_suppress_push_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_suppress_push_ptr__3_0' :: itt_suppress_push_fort_ptr + type(C_FUNPTR) :: itt_suppress_pop_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_suppress_pop_ptr__3_0' :: itt_suppress_pop_fort_ptr + type(C_FUNPTR) :: itt_suppress_mark_range_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_suppress_mark_range_ptr__3_0' :: itt_suppress_mark_range_fort_ptr + type(C_FUNPTR) :: itt_suppress_clear_range_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_suppress_clear_range_ptr__3_0' :: itt_suppress_clear_range_fort_ptr + type(C_FUNPTR) :: itt_sync_prepare_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_sync_prepare_ptr__3_0' :: itt_sync_prepare_fort_ptr + type(C_FUNPTR) :: itt_sync_cancel_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_sync_cancel_ptr__3_0' :: itt_sync_cancel_fort_ptr + type(C_FUNPTR) :: itt_sync_acquired_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_sync_acquired_ptr__3_0' :: itt_sync_acquired_fort_ptr + type(C_FUNPTR) :: itt_sync_releasing_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_sync_releasing_ptr__3_0' :: itt_sync_releasing_fort_ptr + type(C_FUNPTR) :: itt_fsync_prepare_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_fsync_prepare_ptr__3_0' :: itt_fsync_prepare_fort_ptr + type(C_FUNPTR) :: itt_fsync_cancel_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_fsync_cancel_ptr__3_0' :: itt_fsync_cancel_fort_ptr + type(C_FUNPTR) :: itt_fsync_acquired_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_fsync_acquired_ptr__3_0' :: itt_fsync_acquired_fort_ptr + type(C_FUNPTR) :: itt_fsync_releasing_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_fsync_releasing_ptr__3_0' :: itt_fsync_releasing_fort_ptr + type(C_FUNPTR) :: itt_sync_destroy_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_sync_destroy_ptr__3_0' :: itt_sync_destroy_fort_ptr + type(C_FUNPTR) :: itt_sync_create_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_sync_create_ptr__3_0' :: itt_sync_create_fort_ptr + type(C_FUNPTR) :: itt_sync_rename_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_sync_rename_ptr__3_0' :: itt_sync_rename_fort_ptr + type(C_FUNPTR) :: itt_thread_set_name_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_thread_set_name_ptr__3_0' :: itt_thread_set_name_fort_ptr + type(C_FUNPTR) :: itt_heap_record_memory_growth_begin_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_heap_record_memory_growth_begin_ptr__3_0' :: itt_heap_record_memory_growth_begin_fort_ptr + type(C_FUNPTR) :: itt_heap_record_memory_growth_end_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_heap_record_memory_growth_end_ptr__3_0' :: itt_heap_record_memory_growth_end_fort_ptr + type(C_FUNPTR) :: itt_heap_reset_detection_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_heap_reset_detection_ptr__3_0' :: itt_heap_reset_detection_fort_ptr + type(C_FUNPTR) :: itt_heap_record_fort_ptr + !DEC$ ATTRIBUTES C, EXTERN, ALIAS:'__itt_heap_record_ptr__3_0' :: itt_heap_record_fort_ptr + + contains + + subroutine itt_pause() + procedure(itt_proc_none), pointer :: pause_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_pause + if (C_ASSOCIATED(itt_pause_fort_ptr)) then + call C_F_PROCPOINTER(itt_pause_fort_ptr, pause_ptr) + call pause_ptr() + end if + end subroutine itt_pause + + subroutine itt_resume() + procedure(itt_proc_none), pointer :: resume_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_resume + if (C_ASSOCIATED(itt_resume_fort_ptr)) then + call C_F_PROCPOINTER(itt_resume_fort_ptr, resume_ptr) + call resume_ptr() + end if + end subroutine itt_resume + + subroutine itt_thread_ignore() + procedure(itt_proc_none), pointer :: thread_ignore_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_thread_ignore + if (C_ASSOCIATED(itt_thread_ignore_fort_ptr)) then + call C_F_PROCPOINTER(itt_thread_ignore_fort_ptr, thread_ignore_ptr) + call thread_ignore_ptr() + end if + end subroutine itt_thread_ignore + + subroutine itt_suppress_push(mask) + procedure(itt_proc_sup_push), pointer :: suppress_push_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_suppress_push + integer, intent(in), value :: mask + if (C_ASSOCIATED(itt_suppress_push_fort_ptr)) then + call C_F_PROCPOINTER(itt_suppress_push_fort_ptr, suppress_push_ptr) + call suppress_push_ptr(mask) + end if + end subroutine itt_suppress_push + + subroutine itt_suppress_pop() + procedure(itt_proc_none), pointer :: suppress_pop_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_suppress_pop + if (C_ASSOCIATED(itt_suppress_pop_fort_ptr)) then + call C_F_PROCPOINTER(itt_suppress_pop_fort_ptr, suppress_pop_ptr) + call suppress_pop_ptr() + end if + end subroutine itt_suppress_pop + + subroutine itt_suppress_mark_range(action, mask, addr, size) + procedure(itt_proc_sup_range), pointer :: suppress_mark_range_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_suppress_mark_range + integer, intent(in), value :: action + integer, intent(in), value :: mask + integer(kind=itt_ptr), intent(in), value :: addr + integer(kind=itt_ptr), intent(in), value :: size + if (C_ASSOCIATED(itt_suppress_mark_range_fort_ptr)) then + call C_F_PROCPOINTER(itt_suppress_mark_range_fort_ptr, suppress_mark_range_ptr) + call suppress_mark_range_ptr(action, mask, addr, size) + end if + end subroutine itt_suppress_mark_range + + subroutine itt_suppress_clear_range(action, mask, addr, size) + procedure(itt_proc_sup_range), pointer :: suppress_clear_range_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_suppress_clear_range + integer, intent(in), value :: action + integer, intent(in), value :: mask + integer(kind=itt_ptr), intent(in), value :: addr + integer(kind=itt_ptr), intent(in), value :: size + if (C_ASSOCIATED(itt_suppress_clear_range_fort_ptr)) then + call C_F_PROCPOINTER(itt_suppress_clear_range_fort_ptr, suppress_clear_range_ptr) + call suppress_clear_range_ptr(action, mask, addr, size) + end if + end subroutine itt_suppress_clear_range + + subroutine itt_sync_prepare(addr) + procedure(itt_proc_address), pointer :: sync_prepare_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_sync_prepare + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_sync_prepare_fort_ptr)) then + call C_F_PROCPOINTER(itt_sync_prepare_fort_ptr, sync_prepare_ptr) + call sync_prepare_ptr(addr) + end if + end subroutine itt_sync_prepare + + subroutine itt_sync_cancel(addr) + procedure(itt_proc_address), pointer :: sync_cancel_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_sync_cancel + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_sync_cancel_fort_ptr)) then + call C_F_PROCPOINTER(itt_sync_cancel_fort_ptr, sync_cancel_ptr) + call sync_cancel_ptr(addr) + end if + end subroutine itt_sync_cancel + + subroutine itt_sync_acquired(addr) + procedure(itt_proc_address), pointer :: sync_acquired_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_sync_acquired + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_sync_acquired_fort_ptr)) then + call C_F_PROCPOINTER(itt_sync_acquired_fort_ptr, sync_acquired_ptr) + call sync_acquired_ptr(addr) + end if + end subroutine itt_sync_acquired + + subroutine itt_sync_releasing(addr) + procedure(itt_proc_address), pointer :: sync_releasing_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_sync_releasing + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_sync_releasing_fort_ptr)) then + call C_F_PROCPOINTER(itt_sync_releasing_fort_ptr, sync_releasing_ptr) + call sync_releasing_ptr(addr) + end if + end subroutine itt_sync_releasing + + subroutine itt_fsync_prepare(addr) + procedure(itt_proc_address), pointer :: fsync_prepare_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_fsync_prepare + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_fsync_prepare_fort_ptr)) then + call C_F_PROCPOINTER(itt_fsync_prepare_fort_ptr, fsync_prepare_ptr) + call fsync_prepare_ptr(addr) + end if + end subroutine itt_fsync_prepare + + subroutine itt_fsync_cancel(addr) + procedure(itt_proc_address), pointer :: fsync_cancel_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_fsync_cancel + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_fsync_cancel_fort_ptr)) then + call C_F_PROCPOINTER(itt_fsync_cancel_fort_ptr, fsync_cancel_ptr) + call fsync_cancel_ptr(addr) + end if + end subroutine itt_fsync_cancel + + subroutine itt_fsync_acquired(addr) + procedure(itt_proc_address), pointer :: fsync_acquired_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_fsync_acquired + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_fsync_acquired_fort_ptr)) then + call C_F_PROCPOINTER(itt_fsync_acquired_fort_ptr, fsync_acquired_ptr) + call fsync_acquired_ptr(addr) + end if + end subroutine itt_fsync_acquired + + subroutine itt_fsync_releasing(addr) + procedure(itt_proc_address), pointer :: fsync_releasing_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_fsync_releasing + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_fsync_releasing_fort_ptr)) then + call C_F_PROCPOINTER(itt_fsync_releasing_fort_ptr, fsync_releasing_ptr) + call fsync_releasing_ptr(addr) + end if + end subroutine itt_fsync_releasing + + subroutine itt_sync_destroy(addr) + procedure(itt_proc_address), pointer :: sync_destroy_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_sync_destroy + integer(kind=itt_ptr), intent(in), value :: addr + if (C_ASSOCIATED(itt_sync_destroy_fort_ptr)) then + call C_F_PROCPOINTER(itt_sync_destroy_fort_ptr, sync_destroy_ptr) + call sync_destroy_ptr(addr) + end if + end subroutine itt_sync_destroy + + subroutine itt_sync_create(addr, objname, attribute) + procedure(itt_proc_create), pointer :: sync_create_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_sync_create + integer(kind=itt_ptr), intent(in), value :: addr + character(len=*), intent(in) :: objname + integer, intent(in), value :: attribute + CHARACTER(LEN=1,KIND=C_CHAR) :: objnametmp(LEN_TRIM(objname)+1) + INTEGER :: iobjname, nobjname + if (C_ASSOCIATED(itt_sync_create_fort_ptr)) then + nobjname = LEN_TRIM(objname) + DO iobjname = 1, nobjname + objnametmp(iobjname) = objname(iobjname:iobjname) + END DO + objnametmp(nobjname + 1) = C_NULL_CHAR + call C_F_PROCPOINTER(itt_sync_create_fort_ptr, sync_create_ptr) + call sync_create_ptr(addr, objnametmp, attribute) + end if + end subroutine itt_sync_create + + subroutine itt_sync_rename(addr, objname) + procedure(itt_proc_rename), pointer :: sync_rename_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_sync_rename + integer(kind=itt_ptr), intent(in), value :: addr + character(len=*), intent(in) :: objname + CHARACTER(LEN=1,KIND=C_CHAR) :: objnametmp(LEN_TRIM(objname)+1) + INTEGER :: iobjname, nobjname + if (C_ASSOCIATED(itt_sync_rename_fort_ptr)) then + nobjname = LEN_TRIM(objname) + DO iobjname = 1, nobjname + objnametmp(iobjname) = objname(iobjname:iobjname) + END DO + objnametmp(nobjname + 1) = C_NULL_CHAR + call C_F_PROCPOINTER(itt_sync_rename_fort_ptr, sync_rename_ptr) + call sync_rename_ptr(addr, objnametmp) + end if + end subroutine itt_sync_rename + + subroutine itt_thread_set_name(name) + procedure(itt_proc_name), pointer :: thread_set_name_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_thread_set_name + character(len=*), intent(in) :: name + CHARACTER(LEN=1,KIND=C_CHAR) :: nametmp(LEN_TRIM(name)+1) + INTEGER :: iname, nname + if (C_ASSOCIATED(itt_thread_set_name_fort_ptr)) then + nname = LEN_TRIM(name) + DO iname = 1, nname + nametmp(iname) = name(iname:iname) + END DO + nametmp(nname + 1) = C_NULL_CHAR + call C_F_PROCPOINTER(itt_thread_set_name_fort_ptr, thread_set_name_ptr) + call thread_set_name_ptr(nametmp) + end if + end subroutine itt_thread_set_name + + subroutine itt_heap_record_memory_growth_begin() + procedure(itt_proc_none), pointer :: heap_record_memory_growth_begin_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_heap_record_memory_growth_begin + if (C_ASSOCIATED(itt_heap_record_memory_growth_begin_fort_ptr)) then + call C_F_PROCPOINTER(itt_heap_record_memory_growth_begin_fort_ptr, heap_record_memory_growth_begin_ptr) + call heap_record_memory_growth_begin_ptr() + end if + end subroutine itt_heap_record_memory_growth_begin + + subroutine itt_heap_record_memory_growth_end() + procedure(itt_proc_none), pointer :: heap_record_memory_growth_end_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_heap_record_memory_growth_end + if (C_ASSOCIATED(itt_heap_record_memory_growth_end_fort_ptr)) then + call C_F_PROCPOINTER(itt_heap_record_memory_growth_end_fort_ptr, heap_record_memory_growth_end_ptr) + call heap_record_memory_growth_end_ptr() + end if + end subroutine itt_heap_record_memory_growth_end + + subroutine itt_heap_reset_detection(heapmask) + procedure(itt_proc_heapmask), pointer :: heap_reset_detection_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_heap_reset_detection + integer, intent(in), value :: heapmask + if (C_ASSOCIATED(itt_heap_reset_detection_fort_ptr)) then + call C_F_PROCPOINTER(itt_heap_reset_detection_fort_ptr, heap_reset_detection_ptr) + call heap_reset_detection_ptr(heapmask) + end if + end subroutine itt_heap_reset_detection + + subroutine itt_heap_record(heapmask) + procedure(itt_proc_heapmask), pointer :: heap_record_ptr + !DEC$ ATTRIBUTES DEFAULT :: itt_heap_record + integer, intent(in), value :: heapmask + if (C_ASSOCIATED(itt_heap_record_fort_ptr)) then + call C_F_PROCPOINTER(itt_heap_record_fort_ptr, heap_record_ptr) + call heap_record_ptr(heapmask) + end if + end subroutine itt_heap_record + + + end module ittnotify + diff --git a/external/vtune/linux/include/ittnotify.h b/external/vtune/linux/include/ittnotify.h new file mode 100644 index 0000000000..1ce41c8260 --- /dev/null +++ b/external/vtune/linux/include/ittnotify.h @@ -0,0 +1,4123 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _ITTNOTIFY_H_ +#define _ITTNOTIFY_H_ + +/** +@file +@brief Public User API functions and types +@mainpage + +The ITT API is used to annotate a user's program with additional information +that can be used by correctness and performance tools. The user inserts +calls in their program. Those calls generate information that is collected +at runtime, and used by Intel(R) Threading Tools. + +@section API Concepts +The following general concepts are used throughout the API. + +@subsection Unicode Support +Many API functions take character string arguments. On Windows, there +are two versions of each such function. The function name is suffixed +by W if Unicode support is enabled, and by A otherwise. Any API function +that takes a character string argument adheres to this convention. + +@subsection Conditional Compilation +Many users prefer having an option to modify ITT API code when linking it +inside their runtimes. ITT API header file provides a mechanism to replace +ITT API function names inside your code with empty strings. To do this, +define the macros INTEL_NO_ITTNOTIFY_API during compilation and remove the +static library from the linker script. + +@subsection Domains +[see domains] +Domains provide a way to separate notification for different modules or +libraries in a program. Domains are specified by dotted character strings, +e.g. TBB.Internal.Control. + +A mechanism (to be specified) is provided to enable and disable +domains. By default, all domains are enabled. +@subsection Named Entities and Instances +Named entities (frames, regions, tasks, and markers) communicate +information about the program to the analysis tools. A named entity often +refers to a section of program code, or to some set of logical concepts +that the programmer wants to group together. + +Named entities relate to the programmer's static view of the program. When +the program actually executes, many instances of a given named entity +may be created. + +The API annotations denote instances of named entities. The actual +named entities are displayed using the analysis tools. In other words, +the named entities come into existence when instances are created. + +Instances of named entities may have instance identifiers (IDs). Some +API calls use instance identifiers to create relationships between +different instances of named entities. Other API calls associate data +with instances of named entities. + +Some named entities must always have instance IDs. In particular, regions +and frames always have IDs. Task and markers need IDs only if the ID is +needed in another API call (such as adding a relation or metadata). + +The lifetime of instance IDs is distinct from the lifetime of +instances. This allows various relationships to be specified separate +from the actual execution of instances. This flexibility comes at the +expense of extra API calls. + +The same ID may not be reused for different instances, unless a previous +[ref] __itt_id_destroy call for that ID has been issued. +*/ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +#ifdef INTEL_ITTNOTIFY_ENABLE_LEGACY +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# pragma message("WARNING!!! Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro") +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# warning "Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro" +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# include "legacy/ittnotify.h" +#endif /* INTEL_ITTNOTIFY_ENABLE_LEGACY */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** @cond exclude_from_gpa_documentation */ +/** + * @defgroup public Public API + * @{ + * @} + */ + +/** + * @defgroup control Collection Control + * @ingroup public + * General behavior: application continues to run, but no profiling information is being collected + * + * Pausing occurs not only for the current thread but for all process as well as spawned processes + * - Intel(R) Parallel Inspector and Intel(R) Inspector XE: + * - Does not analyze or report errors that involve memory access. + * - Other errors are reported as usual. Pausing data collection in + * Intel(R) Parallel Inspector and Intel(R) Inspector XE + * only pauses tracing and analyzing memory access. + * It does not pause tracing or analyzing threading APIs. + * . + * - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE: + * - Does continue to record when new threads are started. + * . + * - Other effects: + * - Possible reduction of runtime overhead. + * . + * @{ + */ +/** @brief Pause collection */ +void ITTAPI __itt_pause(void); +/** @brief Resume collection */ +void ITTAPI __itt_resume(void); +/** @brief Detach collection */ +void ITTAPI __itt_detach(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, pause, (void)) +ITT_STUBV(ITTAPI, void, resume, (void)) +ITT_STUBV(ITTAPI, void, detach, (void)) +#define __itt_pause ITTNOTIFY_VOID(pause) +#define __itt_pause_ptr ITTNOTIFY_NAME(pause) +#define __itt_resume ITTNOTIFY_VOID(resume) +#define __itt_resume_ptr ITTNOTIFY_NAME(resume) +#define __itt_detach ITTNOTIFY_VOID(detach) +#define __itt_detach_ptr ITTNOTIFY_NAME(detach) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_pause() +#define __itt_pause_ptr 0 +#define __itt_resume() +#define __itt_resume_ptr 0 +#define __itt_detach() +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_pause_ptr 0 +#define __itt_resume_ptr 0 +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} control group */ +/** @endcond */ + +/** + * @defgroup threads Threads + * @ingroup public + * Give names to threads + * @{ + */ +/** + * @brief Sets thread name of calling thread + * @param[in] name - name of thread + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_thread_set_nameA(const char *name); +void ITTAPI __itt_thread_set_nameW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_thread_set_name __itt_thread_set_nameW +# define __itt_thread_set_name_ptr __itt_thread_set_nameW_ptr +#else /* UNICODE */ +# define __itt_thread_set_name __itt_thread_set_nameA +# define __itt_thread_set_name_ptr __itt_thread_set_nameA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_thread_set_name(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, thread_set_nameA, (const char *name)) +ITT_STUBV(ITTAPI, void, thread_set_nameW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, thread_set_name, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thread_set_nameA ITTNOTIFY_VOID(thread_set_nameA) +#define __itt_thread_set_nameA_ptr ITTNOTIFY_NAME(thread_set_nameA) +#define __itt_thread_set_nameW ITTNOTIFY_VOID(thread_set_nameW) +#define __itt_thread_set_nameW_ptr ITTNOTIFY_NAME(thread_set_nameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thread_set_name ITTNOTIFY_VOID(thread_set_name) +#define __itt_thread_set_name_ptr ITTNOTIFY_NAME(thread_set_name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thread_set_nameA(name) +#define __itt_thread_set_nameA_ptr 0 +#define __itt_thread_set_nameW(name) +#define __itt_thread_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thread_set_name(name) +#define __itt_thread_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thread_set_nameA_ptr 0 +#define __itt_thread_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thread_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_gpa_documentation */ + +/** + * @brief Mark current thread as ignored from this point on, for the duration of its existence. + */ +void ITTAPI __itt_thread_ignore(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, thread_ignore, (void)) +#define __itt_thread_ignore ITTNOTIFY_VOID(thread_ignore) +#define __itt_thread_ignore_ptr ITTNOTIFY_NAME(thread_ignore) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_thread_ignore() +#define __itt_thread_ignore_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_thread_ignore_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} threads group */ + +/** + * @defgroup suppress Error suppression + * @ingroup public + * General behavior: application continues to run, but errors are suppressed + * + * @{ + */ + +/*****************************************************************//** + * @name group of functions used for error suppression in correctness tools + *********************************************************************/ +/** @{ */ +/** + * @hideinitializer + * @brief possible value for suppression mask + */ +#define __itt_suppress_all_errors 0x7fffffff + +/** + * @hideinitializer + * @brief possible value for suppression mask (suppresses errors from threading analysis) + */ +#define __itt_suppress_threading_errors 0x000000ff + +/** + * @hideinitializer + * @brief possible value for suppression mask (suppresses errors from memory analysis) + */ +#define __itt_suppress_memory_errors 0x0000ff00 + +/** + * @brief Start suppressing errors identified in mask on this thread + */ +void ITTAPI __itt_suppress_push(unsigned int mask); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_push, (unsigned int mask)) +#define __itt_suppress_push ITTNOTIFY_VOID(suppress_push) +#define __itt_suppress_push_ptr ITTNOTIFY_NAME(suppress_push) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_push(mask) +#define __itt_suppress_push_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_push_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Undo the effects of the matching call to __itt_suppress_push + */ +void ITTAPI __itt_suppress_pop(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_pop, (void)) +#define __itt_suppress_pop ITTNOTIFY_VOID(suppress_pop) +#define __itt_suppress_pop_ptr ITTNOTIFY_NAME(suppress_pop) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_pop() +#define __itt_suppress_pop_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_pop_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @enum __itt_model_disable + * @brief Enumerator for the disable methods + */ +typedef enum __itt_suppress_mode { + __itt_unsuppress_range, + __itt_suppress_range +} __itt_suppress_mode_t; + +/** + * @brief Mark a range of memory for error suppression or unsuppression for error types included in mask + */ +void ITTAPI __itt_suppress_mark_range(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_mark_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size)) +#define __itt_suppress_mark_range ITTNOTIFY_VOID(suppress_mark_range) +#define __itt_suppress_mark_range_ptr ITTNOTIFY_NAME(suppress_mark_range) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_mark_range(mask) +#define __itt_suppress_mark_range_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_mark_range_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Undo the effect of a matching call to __itt_suppress_mark_range. If not matching + * call is found, nothing is changed. + */ +void ITTAPI __itt_suppress_clear_range(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_clear_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size)) +#define __itt_suppress_clear_range ITTNOTIFY_VOID(suppress_clear_range) +#define __itt_suppress_clear_range_ptr ITTNOTIFY_NAME(suppress_clear_range) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_clear_range(mask) +#define __itt_suppress_clear_range_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_clear_range_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} */ +/** @} suppress group */ + +/** + * @defgroup sync Synchronization + * @ingroup public + * Indicate user-written synchronization code + * @{ + */ +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_barrier 1 + +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_mutex 2 + +/** +@brief Name a synchronization object +@param[in] addr Handle for the synchronization object. You should +use a real address to uniquely identify the synchronization object. +@param[in] objtype null-terminated object type string. If NULL is +passed, the name will be "User Synchronization". +@param[in] objname null-terminated object name string. If NULL, +no name will be assigned to the object. +@param[in] attribute one of [#__itt_attr_barrier, #__itt_attr_mutex] + */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_sync_createA(void *addr, const char *objtype, const char *objname, int attribute); +void ITTAPI __itt_sync_createW(void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_sync_create __itt_sync_createW +# define __itt_sync_create_ptr __itt_sync_createW_ptr +#else /* UNICODE */ +# define __itt_sync_create __itt_sync_createA +# define __itt_sync_create_ptr __itt_sync_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_sync_create (void *addr, const char *objtype, const char *objname, int attribute); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_createA, (void *addr, const char *objtype, const char *objname, int attribute)) +ITT_STUBV(ITTAPI, void, sync_createW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_create, (void *addr, const char* objtype, const char* objname, int attribute)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_createA ITTNOTIFY_VOID(sync_createA) +#define __itt_sync_createA_ptr ITTNOTIFY_NAME(sync_createA) +#define __itt_sync_createW ITTNOTIFY_VOID(sync_createW) +#define __itt_sync_createW_ptr ITTNOTIFY_NAME(sync_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_create ITTNOTIFY_VOID(sync_create) +#define __itt_sync_create_ptr ITTNOTIFY_NAME(sync_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_createA(addr, objtype, objname, attribute) +#define __itt_sync_createA_ptr 0 +#define __itt_sync_createW(addr, objtype, objname, attribute) +#define __itt_sync_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_create(addr, objtype, objname, attribute) +#define __itt_sync_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_createA_ptr 0 +#define __itt_sync_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** +@brief Rename a synchronization object + +You can use the rename call to assign or reassign a name to a given +synchronization object. +@param[in] addr handle for the synchronization object. +@param[in] name null-terminated object name string. +*/ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_sync_renameA(void *addr, const char *name); +void ITTAPI __itt_sync_renameW(void *addr, const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_sync_rename __itt_sync_renameW +# define __itt_sync_rename_ptr __itt_sync_renameW_ptr +#else /* UNICODE */ +# define __itt_sync_rename __itt_sync_renameA +# define __itt_sync_rename_ptr __itt_sync_renameA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_sync_rename(void *addr, const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_renameA, (void *addr, const char *name)) +ITT_STUBV(ITTAPI, void, sync_renameW, (void *addr, const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_rename, (void *addr, const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_renameA ITTNOTIFY_VOID(sync_renameA) +#define __itt_sync_renameA_ptr ITTNOTIFY_NAME(sync_renameA) +#define __itt_sync_renameW ITTNOTIFY_VOID(sync_renameW) +#define __itt_sync_renameW_ptr ITTNOTIFY_NAME(sync_renameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_rename ITTNOTIFY_VOID(sync_rename) +#define __itt_sync_rename_ptr ITTNOTIFY_NAME(sync_rename) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_renameA(addr, name) +#define __itt_sync_renameA_ptr 0 +#define __itt_sync_renameW(addr, name) +#define __itt_sync_renameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_rename(addr, name) +#define __itt_sync_rename_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_renameA_ptr 0 +#define __itt_sync_renameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_rename_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + @brief Destroy a synchronization object. + @param addr Handle for the synchronization object. + */ +void ITTAPI __itt_sync_destroy(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_destroy, (void *addr)) +#define __itt_sync_destroy ITTNOTIFY_VOID(sync_destroy) +#define __itt_sync_destroy_ptr ITTNOTIFY_NAME(sync_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_destroy(addr) +#define __itt_sync_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/*****************************************************************//** + * @name group of functions is used for performance measurement tools + *********************************************************************/ +/** @{ */ +/** + * @brief Enter spin loop on user-defined sync object + */ +void ITTAPI __itt_sync_prepare(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_prepare, (void *addr)) +#define __itt_sync_prepare ITTNOTIFY_VOID(sync_prepare) +#define __itt_sync_prepare_ptr ITTNOTIFY_NAME(sync_prepare) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_prepare(addr) +#define __itt_sync_prepare_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_prepare_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Quit spin loop without acquiring spin object + */ +void ITTAPI __itt_sync_cancel(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_cancel, (void *addr)) +#define __itt_sync_cancel ITTNOTIFY_VOID(sync_cancel) +#define __itt_sync_cancel_ptr ITTNOTIFY_NAME(sync_cancel) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_cancel(addr) +#define __itt_sync_cancel_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_cancel_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Successful spin loop completion (sync object acquired) + */ +void ITTAPI __itt_sync_acquired(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_acquired, (void *addr)) +#define __itt_sync_acquired ITTNOTIFY_VOID(sync_acquired) +#define __itt_sync_acquired_ptr ITTNOTIFY_NAME(sync_acquired) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_acquired(addr) +#define __itt_sync_acquired_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_acquired_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Start sync object releasing code. Is called before the lock release call. + */ +void ITTAPI __itt_sync_releasing(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_releasing, (void *addr)) +#define __itt_sync_releasing ITTNOTIFY_VOID(sync_releasing) +#define __itt_sync_releasing_ptr ITTNOTIFY_NAME(sync_releasing) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_releasing(addr) +#define __itt_sync_releasing_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_releasing_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} */ + +/** @} sync group */ + +/**************************************************************//** + * @name group of functions is used for correctness checking tools + ******************************************************************/ +/** @{ */ +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_prepare(void* addr); + */ +void ITTAPI __itt_fsync_prepare(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_prepare, (void *addr)) +#define __itt_fsync_prepare ITTNOTIFY_VOID(fsync_prepare) +#define __itt_fsync_prepare_ptr ITTNOTIFY_NAME(fsync_prepare) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_prepare(addr) +#define __itt_fsync_prepare_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_prepare_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_cancel(void *addr); + */ +void ITTAPI __itt_fsync_cancel(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_cancel, (void *addr)) +#define __itt_fsync_cancel ITTNOTIFY_VOID(fsync_cancel) +#define __itt_fsync_cancel_ptr ITTNOTIFY_NAME(fsync_cancel) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_cancel(addr) +#define __itt_fsync_cancel_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_cancel_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_acquired(void *addr); + */ +void ITTAPI __itt_fsync_acquired(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_acquired, (void *addr)) +#define __itt_fsync_acquired ITTNOTIFY_VOID(fsync_acquired) +#define __itt_fsync_acquired_ptr ITTNOTIFY_NAME(fsync_acquired) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_acquired(addr) +#define __itt_fsync_acquired_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_acquired_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_releasing(void* addr); + */ +void ITTAPI __itt_fsync_releasing(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_releasing, (void *addr)) +#define __itt_fsync_releasing ITTNOTIFY_VOID(fsync_releasing) +#define __itt_fsync_releasing_ptr ITTNOTIFY_NAME(fsync_releasing) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_releasing(addr) +#define __itt_fsync_releasing_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_releasing_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} */ + +/** + * @defgroup model Modeling by Intel(R) Parallel Advisor + * @ingroup public + * This is the subset of itt used for modeling by Intel(R) Parallel Advisor. + * This API is called ONLY using annotate.h, by "Annotation" macros + * the user places in their sources during the parallelism modeling steps. + * + * site_begin/end and task_begin/end take the address of handle variables, + * which are writeable by the API. Handles must be 0 initialized prior + * to the first call to begin, or may cause a run-time failure. + * The handles are initialized in a multi-thread safe way by the API if + * the handle is 0. The commonly expected idiom is one static handle to + * identify a site or task. If a site or task of the same name has already + * been started during this collection, the same handle MAY be returned, + * but is not required to be - it is unspecified if data merging is done + * based on name. These routines also take an instance variable. Like + * the lexical instance, these must be 0 initialized. Unlike the lexical + * instance, this is used to track a single dynamic instance. + * + * API used by the Intel(R) Parallel Advisor to describe potential concurrency + * and related activities. User-added source annotations expand to calls + * to these procedures to enable modeling of a hypothetical concurrent + * execution serially. + * @{ + */ +#if !defined(_ADVISOR_ANNOTATE_H_) || defined(ANNOTATE_EXPAND_NULL) + +typedef void* __itt_model_site; /*!< @brief handle for lexical site */ +typedef void* __itt_model_site_instance; /*!< @brief handle for dynamic instance */ +typedef void* __itt_model_task; /*!< @brief handle for lexical site */ +typedef void* __itt_model_task_instance; /*!< @brief handle for dynamic instance */ + +/** + * @enum __itt_model_disable + * @brief Enumerator for the disable methods + */ +typedef enum { + __itt_model_disable_observation, + __itt_model_disable_collection +} __itt_model_disable; + +#endif /* !_ADVISOR_ANNOTATE_H_ || ANNOTATE_EXPAND_NULL */ + +/** + * @brief ANNOTATE_SITE_BEGIN/ANNOTATE_SITE_END support. + * + * site_begin/end model a potential concurrency site. + * site instances may be recursively nested with themselves. + * site_end exits the most recently started but unended site for the current + * thread. The handle passed to end may be used to validate structure. + * Instances of a site encountered on different threads concurrently + * are considered completely distinct. If the site name for two different + * lexical sites match, it is unspecified whether they are treated as the + * same or different for data presentation. + */ +void ITTAPI __itt_model_site_begin(__itt_model_site *site, __itt_model_site_instance *instance, const char *name); +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_model_site_beginW(const wchar_t *name); +#endif +void ITTAPI __itt_model_site_beginA(const char *name); +void ITTAPI __itt_model_site_beginAL(const char *name, size_t siteNameLen); +void ITTAPI __itt_model_site_end (__itt_model_site *site, __itt_model_site_instance *instance); +void ITTAPI __itt_model_site_end_2(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_site_begin, (__itt_model_site *site, __itt_model_site_instance *instance, const char *name)) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, model_site_beginW, (const wchar_t *name)) +#endif +ITT_STUBV(ITTAPI, void, model_site_beginA, (const char *name)) +ITT_STUBV(ITTAPI, void, model_site_beginAL, (const char *name, size_t siteNameLen)) +ITT_STUBV(ITTAPI, void, model_site_end, (__itt_model_site *site, __itt_model_site_instance *instance)) +ITT_STUBV(ITTAPI, void, model_site_end_2, (void)) +#define __itt_model_site_begin ITTNOTIFY_VOID(model_site_begin) +#define __itt_model_site_begin_ptr ITTNOTIFY_NAME(model_site_begin) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_site_beginW ITTNOTIFY_VOID(model_site_beginW) +#define __itt_model_site_beginW_ptr ITTNOTIFY_NAME(model_site_beginW) +#endif +#define __itt_model_site_beginA ITTNOTIFY_VOID(model_site_beginA) +#define __itt_model_site_beginA_ptr ITTNOTIFY_NAME(model_site_beginA) +#define __itt_model_site_beginAL ITTNOTIFY_VOID(model_site_beginAL) +#define __itt_model_site_beginAL_ptr ITTNOTIFY_NAME(model_site_beginAL) +#define __itt_model_site_end ITTNOTIFY_VOID(model_site_end) +#define __itt_model_site_end_ptr ITTNOTIFY_NAME(model_site_end) +#define __itt_model_site_end_2 ITTNOTIFY_VOID(model_site_end_2) +#define __itt_model_site_end_2_ptr ITTNOTIFY_NAME(model_site_end_2) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_site_begin(site, instance, name) +#define __itt_model_site_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_site_beginW(name) +#define __itt_model_site_beginW_ptr 0 +#endif +#define __itt_model_site_beginA(name) +#define __itt_model_site_beginA_ptr 0 +#define __itt_model_site_beginAL(name, siteNameLen) +#define __itt_model_site_beginAL_ptr 0 +#define __itt_model_site_end(site, instance) +#define __itt_model_site_end_ptr 0 +#define __itt_model_site_end_2() +#define __itt_model_site_end_2_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_site_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_site_beginW_ptr 0 +#endif +#define __itt_model_site_beginA_ptr 0 +#define __itt_model_site_beginAL_ptr 0 +#define __itt_model_site_end_ptr 0 +#define __itt_model_site_end_2_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_TASK_BEGIN/ANNOTATE_TASK_END support + * + * task_begin/end model a potential task, which is contained within the most + * closely enclosing dynamic site. task_end exits the most recently started + * but unended task. The handle passed to end may be used to validate + * structure. It is unspecified if bad dynamic nesting is detected. If it + * is, it should be encoded in the resulting data collection. The collector + * should not fail due to construct nesting issues, nor attempt to directly + * indicate the problem. + */ +void ITTAPI __itt_model_task_begin(__itt_model_task *task, __itt_model_task_instance *instance, const char *name); +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_model_task_beginW(const wchar_t *name); +void ITTAPI __itt_model_iteration_taskW(const wchar_t *name); +#endif +void ITTAPI __itt_model_task_beginA(const char *name); +void ITTAPI __itt_model_task_beginAL(const char *name, size_t taskNameLen); +void ITTAPI __itt_model_iteration_taskA(const char *name); +void ITTAPI __itt_model_iteration_taskAL(const char *name, size_t taskNameLen); +void ITTAPI __itt_model_task_end (__itt_model_task *task, __itt_model_task_instance *instance); +void ITTAPI __itt_model_task_end_2(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_task_begin, (__itt_model_task *task, __itt_model_task_instance *instance, const char *name)) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, model_task_beginW, (const wchar_t *name)) +ITT_STUBV(ITTAPI, void, model_iteration_taskW, (const wchar_t *name)) +#endif +ITT_STUBV(ITTAPI, void, model_task_beginA, (const char *name)) +ITT_STUBV(ITTAPI, void, model_task_beginAL, (const char *name, size_t taskNameLen)) +ITT_STUBV(ITTAPI, void, model_iteration_taskA, (const char *name)) +ITT_STUBV(ITTAPI, void, model_iteration_taskAL, (const char *name, size_t taskNameLen)) +ITT_STUBV(ITTAPI, void, model_task_end, (__itt_model_task *task, __itt_model_task_instance *instance)) +ITT_STUBV(ITTAPI, void, model_task_end_2, (void)) +#define __itt_model_task_begin ITTNOTIFY_VOID(model_task_begin) +#define __itt_model_task_begin_ptr ITTNOTIFY_NAME(model_task_begin) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_task_beginW ITTNOTIFY_VOID(model_task_beginW) +#define __itt_model_task_beginW_ptr ITTNOTIFY_NAME(model_task_beginW) +#define __itt_model_iteration_taskW ITTNOTIFY_VOID(model_iteration_taskW) +#define __itt_model_iteration_taskW_ptr ITTNOTIFY_NAME(model_iteration_taskW) +#endif +#define __itt_model_task_beginA ITTNOTIFY_VOID(model_task_beginA) +#define __itt_model_task_beginA_ptr ITTNOTIFY_NAME(model_task_beginA) +#define __itt_model_task_beginAL ITTNOTIFY_VOID(model_task_beginAL) +#define __itt_model_task_beginAL_ptr ITTNOTIFY_NAME(model_task_beginAL) +#define __itt_model_iteration_taskA ITTNOTIFY_VOID(model_iteration_taskA) +#define __itt_model_iteration_taskA_ptr ITTNOTIFY_NAME(model_iteration_taskA) +#define __itt_model_iteration_taskAL ITTNOTIFY_VOID(model_iteration_taskAL) +#define __itt_model_iteration_taskAL_ptr ITTNOTIFY_NAME(model_iteration_taskAL) +#define __itt_model_task_end ITTNOTIFY_VOID(model_task_end) +#define __itt_model_task_end_ptr ITTNOTIFY_NAME(model_task_end) +#define __itt_model_task_end_2 ITTNOTIFY_VOID(model_task_end_2) +#define __itt_model_task_end_2_ptr ITTNOTIFY_NAME(model_task_end_2) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_task_begin(task, instance, name) +#define __itt_model_task_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_task_beginW(name) +#define __itt_model_task_beginW_ptr 0 +#endif +#define __itt_model_task_beginA(name) +#define __itt_model_task_beginA_ptr 0 +#define __itt_model_task_beginAL(name, siteNameLen) +#define __itt_model_task_beginAL_ptr 0 +#define __itt_model_iteration_taskA(name) +#define __itt_model_iteration_taskA_ptr 0 +#define __itt_model_iteration_taskAL(name, siteNameLen) +#define __itt_model_iteration_taskAL_ptr 0 +#define __itt_model_task_end(task, instance) +#define __itt_model_task_end_ptr 0 +#define __itt_model_task_end_2() +#define __itt_model_task_end_2_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_task_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_task_beginW_ptr 0 +#endif +#define __itt_model_task_beginA_ptr 0 +#define __itt_model_task_beginAL_ptr 0 +#define __itt_model_iteration_taskA_ptr 0 +#define __itt_model_iteration_taskAL_ptr 0 +#define __itt_model_task_end_ptr 0 +#define __itt_model_task_end_2_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_LOCK_ACQUIRE/ANNOTATE_LOCK_RELEASE support + * + * lock_acquire/release model a potential lock for both lockset and + * performance modeling. Each unique address is modeled as a separate + * lock, with invalid addresses being valid lock IDs. Specifically: + * no storage is accessed by the API at the specified address - it is only + * used for lock identification. Lock acquires may be self-nested and are + * unlocked by a corresponding number of releases. + * (These closely correspond to __itt_sync_acquired/__itt_sync_releasing, + * but may not have identical semantics.) + */ +void ITTAPI __itt_model_lock_acquire(void *lock); +void ITTAPI __itt_model_lock_acquire_2(void *lock); +void ITTAPI __itt_model_lock_release(void *lock); +void ITTAPI __itt_model_lock_release_2(void *lock); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_lock_acquire, (void *lock)) +ITT_STUBV(ITTAPI, void, model_lock_acquire_2, (void *lock)) +ITT_STUBV(ITTAPI, void, model_lock_release, (void *lock)) +ITT_STUBV(ITTAPI, void, model_lock_release_2, (void *lock)) +#define __itt_model_lock_acquire ITTNOTIFY_VOID(model_lock_acquire) +#define __itt_model_lock_acquire_ptr ITTNOTIFY_NAME(model_lock_acquire) +#define __itt_model_lock_acquire_2 ITTNOTIFY_VOID(model_lock_acquire_2) +#define __itt_model_lock_acquire_2_ptr ITTNOTIFY_NAME(model_lock_acquire_2) +#define __itt_model_lock_release ITTNOTIFY_VOID(model_lock_release) +#define __itt_model_lock_release_ptr ITTNOTIFY_NAME(model_lock_release) +#define __itt_model_lock_release_2 ITTNOTIFY_VOID(model_lock_release_2) +#define __itt_model_lock_release_2_ptr ITTNOTIFY_NAME(model_lock_release_2) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_lock_acquire(lock) +#define __itt_model_lock_acquire_ptr 0 +#define __itt_model_lock_acquire_2(lock) +#define __itt_model_lock_acquire_2_ptr 0 +#define __itt_model_lock_release(lock) +#define __itt_model_lock_release_ptr 0 +#define __itt_model_lock_release_2(lock) +#define __itt_model_lock_release_2_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_lock_acquire_ptr 0 +#define __itt_model_lock_acquire_2_ptr 0 +#define __itt_model_lock_release_ptr 0 +#define __itt_model_lock_release_2_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_RECORD_ALLOCATION/ANNOTATE_RECORD_DEALLOCATION support + * + * record_allocation/deallocation describe user-defined memory allocator + * behavior, which may be required for correctness modeling to understand + * when storage is not expected to be actually reused across threads. + */ +void ITTAPI __itt_model_record_allocation (void *addr, size_t size); +void ITTAPI __itt_model_record_deallocation(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_record_allocation, (void *addr, size_t size)) +ITT_STUBV(ITTAPI, void, model_record_deallocation, (void *addr)) +#define __itt_model_record_allocation ITTNOTIFY_VOID(model_record_allocation) +#define __itt_model_record_allocation_ptr ITTNOTIFY_NAME(model_record_allocation) +#define __itt_model_record_deallocation ITTNOTIFY_VOID(model_record_deallocation) +#define __itt_model_record_deallocation_ptr ITTNOTIFY_NAME(model_record_deallocation) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_record_allocation(addr, size) +#define __itt_model_record_allocation_ptr 0 +#define __itt_model_record_deallocation(addr) +#define __itt_model_record_deallocation_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_record_allocation_ptr 0 +#define __itt_model_record_deallocation_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_INDUCTION_USES support + * + * Note particular storage is inductive through the end of the current site + */ +void ITTAPI __itt_model_induction_uses(void* addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_induction_uses, (void *addr, size_t size)) +#define __itt_model_induction_uses ITTNOTIFY_VOID(model_induction_uses) +#define __itt_model_induction_uses_ptr ITTNOTIFY_NAME(model_induction_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_induction_uses(addr, size) +#define __itt_model_induction_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_induction_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_REDUCTION_USES support + * + * Note particular storage is used for reduction through the end + * of the current site + */ +void ITTAPI __itt_model_reduction_uses(void* addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_reduction_uses, (void *addr, size_t size)) +#define __itt_model_reduction_uses ITTNOTIFY_VOID(model_reduction_uses) +#define __itt_model_reduction_uses_ptr ITTNOTIFY_NAME(model_reduction_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_reduction_uses(addr, size) +#define __itt_model_reduction_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_reduction_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_OBSERVE_USES support + * + * Have correctness modeling record observations about uses of storage + * through the end of the current site + */ +void ITTAPI __itt_model_observe_uses(void* addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_observe_uses, (void *addr, size_t size)) +#define __itt_model_observe_uses ITTNOTIFY_VOID(model_observe_uses) +#define __itt_model_observe_uses_ptr ITTNOTIFY_NAME(model_observe_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_observe_uses(addr, size) +#define __itt_model_observe_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_observe_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_CLEAR_USES support + * + * Clear the special handling of a piece of storage related to induction, + * reduction or observe_uses + */ +void ITTAPI __itt_model_clear_uses(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_clear_uses, (void *addr)) +#define __itt_model_clear_uses ITTNOTIFY_VOID(model_clear_uses) +#define __itt_model_clear_uses_ptr ITTNOTIFY_NAME(model_clear_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_clear_uses(addr) +#define __itt_model_clear_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_clear_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_DISABLE_*_PUSH/ANNOTATE_DISABLE_*_POP support + * + * disable_push/disable_pop push and pop disabling based on a parameter. + * Disabling observations stops processing of memory references during + * correctness modeling, and all annotations that occur in the disabled + * region. This allows description of code that is expected to be handled + * specially during conversion to parallelism or that is not recognized + * by tools (e.g. some kinds of synchronization operations.) + * This mechanism causes all annotations in the disabled region, other + * than disable_push and disable_pop, to be ignored. (For example, this + * might validly be used to disable an entire parallel site and the contained + * tasks and locking in it for data collection purposes.) + * The disable for collection is a more expensive operation, but reduces + * collector overhead significantly. This applies to BOTH correctness data + * collection and performance data collection. For example, a site + * containing a task might only enable data collection for the first 10 + * iterations. Both performance and correctness data should reflect this, + * and the program should run as close to full speed as possible when + * collection is disabled. + */ +void ITTAPI __itt_model_disable_push(__itt_model_disable x); +void ITTAPI __itt_model_disable_pop(void); +void ITTAPI __itt_model_aggregate_task(size_t x); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_disable_push, (__itt_model_disable x)) +ITT_STUBV(ITTAPI, void, model_disable_pop, (void)) +ITT_STUBV(ITTAPI, void, model_aggregate_task, (size_t x)) +#define __itt_model_disable_push ITTNOTIFY_VOID(model_disable_push) +#define __itt_model_disable_push_ptr ITTNOTIFY_NAME(model_disable_push) +#define __itt_model_disable_pop ITTNOTIFY_VOID(model_disable_pop) +#define __itt_model_disable_pop_ptr ITTNOTIFY_NAME(model_disable_pop) +#define __itt_model_aggregate_task ITTNOTIFY_VOID(model_aggregate_task) +#define __itt_model_aggregate_task_ptr ITTNOTIFY_NAME(model_aggregate_task) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_disable_push(x) +#define __itt_model_disable_push_ptr 0 +#define __itt_model_disable_pop() +#define __itt_model_disable_pop_ptr 0 +#define __itt_model_aggregate_task(x) +#define __itt_model_aggregate_task_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_disable_push_ptr 0 +#define __itt_model_disable_pop_ptr 0 +#define __itt_model_aggregate_task_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} model group */ + +/** + * @defgroup heap Heap + * @ingroup public + * Heap group + * @{ + */ + +typedef void* __itt_heap_function; + +/** + * @brief Create an identification for heap function + * @return non-zero identifier or NULL + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_heap_function ITTAPI __itt_heap_function_createA(const char* name, const char* domain); +__itt_heap_function ITTAPI __itt_heap_function_createW(const wchar_t* name, const wchar_t* domain); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_heap_function_create __itt_heap_function_createW +# define __itt_heap_function_create_ptr __itt_heap_function_createW_ptr +#else +# define __itt_heap_function_create __itt_heap_function_createA +# define __itt_heap_function_create_ptr __itt_heap_function_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_heap_function ITTAPI __itt_heap_function_create(const char* name, const char* domain); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createA, (const char* name, const char* domain)) +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createW, (const wchar_t* name, const wchar_t* domain)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_create, (const char* name, const char* domain)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_heap_function_createA ITTNOTIFY_DATA(heap_function_createA) +#define __itt_heap_function_createA_ptr ITTNOTIFY_NAME(heap_function_createA) +#define __itt_heap_function_createW ITTNOTIFY_DATA(heap_function_createW) +#define __itt_heap_function_createW_ptr ITTNOTIFY_NAME(heap_function_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_heap_function_create ITTNOTIFY_DATA(heap_function_create) +#define __itt_heap_function_create_ptr ITTNOTIFY_NAME(heap_function_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_heap_function_createA(name, domain) (__itt_heap_function)0 +#define __itt_heap_function_createA_ptr 0 +#define __itt_heap_function_createW(name, domain) (__itt_heap_function)0 +#define __itt_heap_function_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_heap_function_create(name, domain) (__itt_heap_function)0 +#define __itt_heap_function_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_heap_function_createA_ptr 0 +#define __itt_heap_function_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_heap_function_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an allocation begin occurrence. + */ +void ITTAPI __itt_heap_allocate_begin(__itt_heap_function h, size_t size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_allocate_begin, (__itt_heap_function h, size_t size, int initialized)) +#define __itt_heap_allocate_begin ITTNOTIFY_VOID(heap_allocate_begin) +#define __itt_heap_allocate_begin_ptr ITTNOTIFY_NAME(heap_allocate_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_allocate_begin(h, size, initialized) +#define __itt_heap_allocate_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_allocate_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an allocation end occurrence. + */ +void ITTAPI __itt_heap_allocate_end(__itt_heap_function h, void** addr, size_t size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_allocate_end, (__itt_heap_function h, void** addr, size_t size, int initialized)) +#define __itt_heap_allocate_end ITTNOTIFY_VOID(heap_allocate_end) +#define __itt_heap_allocate_end_ptr ITTNOTIFY_NAME(heap_allocate_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_allocate_end(h, addr, size, initialized) +#define __itt_heap_allocate_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_allocate_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an free begin occurrence. + */ +void ITTAPI __itt_heap_free_begin(__itt_heap_function h, void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_free_begin, (__itt_heap_function h, void* addr)) +#define __itt_heap_free_begin ITTNOTIFY_VOID(heap_free_begin) +#define __itt_heap_free_begin_ptr ITTNOTIFY_NAME(heap_free_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_free_begin(h, addr) +#define __itt_heap_free_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_free_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an free end occurrence. + */ +void ITTAPI __itt_heap_free_end(__itt_heap_function h, void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_free_end, (__itt_heap_function h, void* addr)) +#define __itt_heap_free_end ITTNOTIFY_VOID(heap_free_end) +#define __itt_heap_free_end_ptr ITTNOTIFY_NAME(heap_free_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_free_end(h, addr) +#define __itt_heap_free_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_free_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an reallocation begin occurrence. + */ +void ITTAPI __itt_heap_reallocate_begin(__itt_heap_function h, void* addr, size_t new_size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_reallocate_begin, (__itt_heap_function h, void* addr, size_t new_size, int initialized)) +#define __itt_heap_reallocate_begin ITTNOTIFY_VOID(heap_reallocate_begin) +#define __itt_heap_reallocate_begin_ptr ITTNOTIFY_NAME(heap_reallocate_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_reallocate_begin(h, addr, new_size, initialized) +#define __itt_heap_reallocate_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_reallocate_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an reallocation end occurrence. + */ +void ITTAPI __itt_heap_reallocate_end(__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_reallocate_end, (__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized)) +#define __itt_heap_reallocate_end ITTNOTIFY_VOID(heap_reallocate_end) +#define __itt_heap_reallocate_end_ptr ITTNOTIFY_NAME(heap_reallocate_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_reallocate_end(h, addr, new_addr, new_size, initialized) +#define __itt_heap_reallocate_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_reallocate_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief internal access begin */ +void ITTAPI __itt_heap_internal_access_begin(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_internal_access_begin, (void)) +#define __itt_heap_internal_access_begin ITTNOTIFY_VOID(heap_internal_access_begin) +#define __itt_heap_internal_access_begin_ptr ITTNOTIFY_NAME(heap_internal_access_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_internal_access_begin() +#define __itt_heap_internal_access_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_internal_access_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief internal access end */ +void ITTAPI __itt_heap_internal_access_end(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_internal_access_end, (void)) +#define __itt_heap_internal_access_end ITTNOTIFY_VOID(heap_internal_access_end) +#define __itt_heap_internal_access_end_ptr ITTNOTIFY_NAME(heap_internal_access_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_internal_access_end() +#define __itt_heap_internal_access_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_internal_access_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief record memory growth begin */ +void ITTAPI __itt_heap_record_memory_growth_begin(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_begin, (void)) +#define __itt_heap_record_memory_growth_begin ITTNOTIFY_VOID(heap_record_memory_growth_begin) +#define __itt_heap_record_memory_growth_begin_ptr ITTNOTIFY_NAME(heap_record_memory_growth_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_record_memory_growth_begin() +#define __itt_heap_record_memory_growth_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_record_memory_growth_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief record memory growth end */ +void ITTAPI __itt_heap_record_memory_growth_end(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_end, (void)) +#define __itt_heap_record_memory_growth_end ITTNOTIFY_VOID(heap_record_memory_growth_end) +#define __itt_heap_record_memory_growth_end_ptr ITTNOTIFY_NAME(heap_record_memory_growth_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_record_memory_growth_end() +#define __itt_heap_record_memory_growth_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_record_memory_growth_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Specify the type of heap detection/reporting to modify. + */ +/** + * @hideinitializer + * @brief Report on memory leaks. + */ +#define __itt_heap_leaks 0x00000001 + +/** + * @hideinitializer + * @brief Report on memory growth. + */ +#define __itt_heap_growth 0x00000002 + + +/** @brief heap reset detection */ +void ITTAPI __itt_heap_reset_detection(unsigned int reset_mask); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_reset_detection, (unsigned int reset_mask)) +#define __itt_heap_reset_detection ITTNOTIFY_VOID(heap_reset_detection) +#define __itt_heap_reset_detection_ptr ITTNOTIFY_NAME(heap_reset_detection) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_reset_detection() +#define __itt_heap_reset_detection_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_reset_detection_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief report */ +void ITTAPI __itt_heap_record(unsigned int record_mask); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_record, (unsigned int record_mask)) +#define __itt_heap_record ITTNOTIFY_VOID(heap_record) +#define __itt_heap_record_ptr ITTNOTIFY_NAME(heap_record) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_record() +#define __itt_heap_record_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_record_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} heap group */ +/** @endcond */ +/* ========================================================================== */ + +/** + * @defgroup domains Domains + * @ingroup public + * Domains group + * @{ + */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_domain +{ + volatile int flags; /*!< Zero if disabled, non-zero if enabled. The meaning of different non-zero values is reserved to the runtime */ + const char* nameA; /*!< Copy of original name in ASCII. */ +#if defined(UNICODE) || defined(_UNICODE) + const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ +#else /* UNICODE || _UNICODE */ + void* nameW; +#endif /* UNICODE || _UNICODE */ + int extra1; /*!< Reserved to the runtime */ + void* extra2; /*!< Reserved to the runtime */ + struct ___itt_domain* next; +} __itt_domain; + +#pragma pack(pop) +/** @endcond */ + +/** + * @ingroup domains + * @brief Create a domain. + * Create domain using some domain name: the URI naming style is recommended. + * Because the set of domains is expected to be static over the application's + * execution time, there is no mechanism to destroy a domain. + * Any domain can be accessed by any thread in the process, regardless of + * which thread created the domain. This call is thread-safe. + * @param[in] name name of domain + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_domain* ITTAPI __itt_domain_createA(const char *name); +__itt_domain* ITTAPI __itt_domain_createW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_domain_create __itt_domain_createW +# define __itt_domain_create_ptr __itt_domain_createW_ptr +#else /* UNICODE */ +# define __itt_domain_create __itt_domain_createA +# define __itt_domain_create_ptr __itt_domain_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_domain* ITTAPI __itt_domain_create(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_domain*, domain_createA, (const char *name)) +ITT_STUB(ITTAPI, __itt_domain*, domain_createW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_domain*, domain_create, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_domain_createA ITTNOTIFY_DATA(domain_createA) +#define __itt_domain_createA_ptr ITTNOTIFY_NAME(domain_createA) +#define __itt_domain_createW ITTNOTIFY_DATA(domain_createW) +#define __itt_domain_createW_ptr ITTNOTIFY_NAME(domain_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_domain_create ITTNOTIFY_DATA(domain_create) +#define __itt_domain_create_ptr ITTNOTIFY_NAME(domain_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_domain_createA(name) (__itt_domain*)0 +#define __itt_domain_createA_ptr 0 +#define __itt_domain_createW(name) (__itt_domain*)0 +#define __itt_domain_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_domain_create(name) (__itt_domain*)0 +#define __itt_domain_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_domain_createA_ptr 0 +#define __itt_domain_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_domain_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} domains group */ + +/** + * @defgroup ids IDs + * @ingroup public + * IDs group + * @{ + */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_id +{ + unsigned long long d1, d2, d3; +} __itt_id; + +#pragma pack(pop) +/** @endcond */ + +static const __itt_id __itt_null = { 0, 0, 0 }; + +/** + * @ingroup ids + * @brief A convenience function is provided to create an ID without domain control. + * @brief This is a convenience function to initialize an __itt_id structure. This function + * does not affect the collector runtime in any way. After you make the ID with this + * function, you still must create it with the __itt_id_create function before using the ID + * to identify a named entity. + * @param[in] addr The address of object; high QWORD of the ID value. + * @param[in] extra The extra data to unique identify object; low QWORD of the ID value. + */ + +ITT_INLINE __itt_id ITTAPI __itt_id_make(void* addr, unsigned long long extra) ITT_INLINE_ATTRIBUTE; +ITT_INLINE __itt_id ITTAPI __itt_id_make(void* addr, unsigned long long extra) +{ + __itt_id id = __itt_null; + id.d1 = (unsigned long long)((uintptr_t)addr); + id.d2 = (unsigned long long)extra; + id.d3 = (unsigned long long)0; /* Reserved. Must be zero */ + return id; +} + +/** + * @ingroup ids + * @brief Create an instance of identifier. + * This establishes the beginning of the lifetime of an instance of + * the given ID in the trace. Once this lifetime starts, the ID + * can be used to tag named entity instances in calls such as + * __itt_task_begin, and to specify relationships among + * identified named entity instances, using the \ref relations APIs. + * Instance IDs are not domain specific! + * @param[in] domain The domain controlling the execution of this call. + * @param[in] id The ID to create. + */ +void ITTAPI __itt_id_create(const __itt_domain *domain, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, id_create, (const __itt_domain *domain, __itt_id id)) +#define __itt_id_create(d,x) ITTNOTIFY_VOID_D1(id_create,d,x) +#define __itt_id_create_ptr ITTNOTIFY_NAME(id_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_id_create(domain,id) +#define __itt_id_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_id_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup ids + * @brief Destroy an instance of identifier. + * This ends the lifetime of the current instance of the given ID value in the trace. + * Any relationships that are established after this lifetime ends are invalid. + * This call must be performed before the given ID value can be reused for a different + * named entity instance. + * @param[in] domain The domain controlling the execution of this call. + * @param[in] id The ID to destroy. + */ +void ITTAPI __itt_id_destroy(const __itt_domain *domain, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, id_destroy, (const __itt_domain *domain, __itt_id id)) +#define __itt_id_destroy(d,x) ITTNOTIFY_VOID_D1(id_destroy,d,x) +#define __itt_id_destroy_ptr ITTNOTIFY_NAME(id_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_id_destroy(domain,id) +#define __itt_id_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_id_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} ids group */ + +/** + * @defgroup handless String Handles + * @ingroup public + * String Handles group + * @{ + */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_string_handle +{ + const char* strA; /*!< Copy of original string in ASCII. */ +#if defined(UNICODE) || defined(_UNICODE) + const wchar_t* strW; /*!< Copy of original string in UNICODE. */ +#else /* UNICODE || _UNICODE */ + void* strW; +#endif /* UNICODE || _UNICODE */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_string_handle* next; +} __itt_string_handle; + +#pragma pack(pop) +/** @endcond */ + +/** + * @ingroup handles + * @brief Create a string handle. + * Create and return handle value that can be associated with a string. + * Consecutive calls to __itt_string_handle_create with the same name + * return the same value. Because the set of string handles is expected to remain + * static during the application's execution time, there is no mechanism to destroy a string handle. + * Any string handle can be accessed by any thread in the process, regardless of which thread created + * the string handle. This call is thread-safe. + * @param[in] name The input string + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_string_handle* ITTAPI __itt_string_handle_createA(const char *name); +__itt_string_handle* ITTAPI __itt_string_handle_createW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_string_handle_create __itt_string_handle_createW +# define __itt_string_handle_create_ptr __itt_string_handle_createW_ptr +#else /* UNICODE */ +# define __itt_string_handle_create __itt_string_handle_createA +# define __itt_string_handle_create_ptr __itt_string_handle_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_string_handle* ITTAPI __itt_string_handle_create(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createA, (const char *name)) +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_create, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_string_handle_createA ITTNOTIFY_DATA(string_handle_createA) +#define __itt_string_handle_createA_ptr ITTNOTIFY_NAME(string_handle_createA) +#define __itt_string_handle_createW ITTNOTIFY_DATA(string_handle_createW) +#define __itt_string_handle_createW_ptr ITTNOTIFY_NAME(string_handle_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_string_handle_create ITTNOTIFY_DATA(string_handle_create) +#define __itt_string_handle_create_ptr ITTNOTIFY_NAME(string_handle_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_string_handle_createA(name) (__itt_string_handle*)0 +#define __itt_string_handle_createA_ptr 0 +#define __itt_string_handle_createW(name) (__itt_string_handle*)0 +#define __itt_string_handle_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_string_handle_create(name) (__itt_string_handle*)0 +#define __itt_string_handle_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_string_handle_createA_ptr 0 +#define __itt_string_handle_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_string_handle_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} handles group */ + +/** @cond exclude_from_documentation */ +typedef unsigned long long __itt_timestamp; +/** @endcond */ + +#define __itt_timestamp_none ((__itt_timestamp)-1LL) + +/** @cond exclude_from_gpa_documentation */ + +/** + * @ingroup timestamps + * @brief Return timestamp corresponding to the current moment. + * This returns the timestamp in the format that is the most relevant for the current + * host or platform (RDTSC, QPC, and others). You can use the "<" operator to + * compare __itt_timestamp values. + */ +__itt_timestamp ITTAPI __itt_get_timestamp(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_timestamp, get_timestamp, (void)) +#define __itt_get_timestamp ITTNOTIFY_DATA(get_timestamp) +#define __itt_get_timestamp_ptr ITTNOTIFY_NAME(get_timestamp) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_get_timestamp() +#define __itt_get_timestamp_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_get_timestamp_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} timestamps */ +/** @endcond */ + +/** @cond exclude_from_gpa_documentation */ + +/** + * @defgroup regions Regions + * @ingroup public + * Regions group + * @{ + */ +/** + * @ingroup regions + * @brief Begin of region instance. + * Successive calls to __itt_region_begin with the same ID are ignored + * until a call to __itt_region_end with the same ID + * @param[in] domain The domain for this region instance + * @param[in] id The instance ID for this region instance. Must not be __itt_null + * @param[in] parentid The instance ID for the parent of this region instance, or __itt_null + * @param[in] name The name of this region + */ +void ITTAPI __itt_region_begin(const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name); + +/** + * @ingroup regions + * @brief End of region instance. + * The first call to __itt_region_end with a given ID ends the + * region. Successive calls with the same ID are ignored, as are + * calls that do not have a matching __itt_region_begin call. + * @param[in] domain The domain for this region instance + * @param[in] id The instance ID for this region instance + */ +void ITTAPI __itt_region_end(const __itt_domain *domain, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, region_begin, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, region_end, (const __itt_domain *domain, __itt_id id)) +#define __itt_region_begin(d,x,y,z) ITTNOTIFY_VOID_D3(region_begin,d,x,y,z) +#define __itt_region_begin_ptr ITTNOTIFY_NAME(region_begin) +#define __itt_region_end(d,x) ITTNOTIFY_VOID_D1(region_end,d,x) +#define __itt_region_end_ptr ITTNOTIFY_NAME(region_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_region_begin(d,x,y,z) +#define __itt_region_begin_ptr 0 +#define __itt_region_end(d,x) +#define __itt_region_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_region_begin_ptr 0 +#define __itt_region_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} regions group */ + +/** + * @defgroup frames Frames + * @ingroup public + * Frames are similar to regions, but are intended to be easier to use and to implement. + * In particular: + * - Frames always represent periods of elapsed time + * - By default, frames have no nesting relationships + * @{ + */ + +/** + * @ingroup frames + * @brief Begin a frame instance. + * Successive calls to __itt_frame_begin with the + * same ID are ignored until a call to __itt_frame_end with the same ID. + * @param[in] domain The domain for this frame instance + * @param[in] id The instance ID for this frame instance or NULL + */ +void ITTAPI __itt_frame_begin_v3(const __itt_domain *domain, __itt_id *id); + +/** + * @ingroup frames + * @brief End a frame instance. + * The first call to __itt_frame_end with a given ID + * ends the frame. Successive calls with the same ID are ignored, as are + * calls that do not have a matching __itt_frame_begin call. + * @param[in] domain The domain for this frame instance + * @param[in] id The instance ID for this frame instance or NULL for current + */ +void ITTAPI __itt_frame_end_v3(const __itt_domain *domain, __itt_id *id); + +/** + * @ingroup frames + * @brief Submits a frame instance. + * Successive calls to __itt_frame_begin or __itt_frame_submit with the + * same ID are ignored until a call to __itt_frame_end or __itt_frame_submit + * with the same ID. + * Passing special __itt_timestamp_none value as "end" argument means + * take the current timestamp as the end timestamp. + * @param[in] domain The domain for this frame instance + * @param[in] id The instance ID for this frame instance or NULL + * @param[in] begin Timestamp of the beginning of the frame + * @param[in] end Timestamp of the end of the frame + */ +void ITTAPI __itt_frame_submit_v3(const __itt_domain *domain, __itt_id *id, + __itt_timestamp begin, __itt_timestamp end); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, frame_begin_v3, (const __itt_domain *domain, __itt_id *id)) +ITT_STUBV(ITTAPI, void, frame_end_v3, (const __itt_domain *domain, __itt_id *id)) +ITT_STUBV(ITTAPI, void, frame_submit_v3, (const __itt_domain *domain, __itt_id *id, __itt_timestamp begin, __itt_timestamp end)) +#define __itt_frame_begin_v3(d,x) ITTNOTIFY_VOID_D1(frame_begin_v3,d,x) +#define __itt_frame_begin_v3_ptr ITTNOTIFY_NAME(frame_begin_v3) +#define __itt_frame_end_v3(d,x) ITTNOTIFY_VOID_D1(frame_end_v3,d,x) +#define __itt_frame_end_v3_ptr ITTNOTIFY_NAME(frame_end_v3) +#define __itt_frame_submit_v3(d,x,b,e) ITTNOTIFY_VOID_D3(frame_submit_v3,d,x,b,e) +#define __itt_frame_submit_v3_ptr ITTNOTIFY_NAME(frame_submit_v3) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_frame_begin_v3(domain,id) +#define __itt_frame_begin_v3_ptr 0 +#define __itt_frame_end_v3(domain,id) +#define __itt_frame_end_v3_ptr 0 +#define __itt_frame_submit_v3(domain,id,begin,end) +#define __itt_frame_submit_v3_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_frame_begin_v3_ptr 0 +#define __itt_frame_end_v3_ptr 0 +#define __itt_frame_submit_v3_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} frames group */ +/** @endcond */ + +/** + * @defgroup taskgroup Task Group + * @ingroup public + * Task Group + * @{ + */ +/** + * @ingroup task_groups + * @brief Denotes a task_group instance. + * Successive calls to __itt_task_group with the same ID are ignored. + * @param[in] domain The domain for this task_group instance + * @param[in] id The instance ID for this task_group instance. Must not be __itt_null. + * @param[in] parentid The instance ID for the parent of this task_group instance, or __itt_null. + * @param[in] name The name of this task_group + */ +void ITTAPI __itt_task_group(const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_group, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +#define __itt_task_group(d,x,y,z) ITTNOTIFY_VOID_D3(task_group,d,x,y,z) +#define __itt_task_group_ptr ITTNOTIFY_NAME(task_group) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_group(d,x,y,z) +#define __itt_task_group_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_group_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} taskgroup group */ + +/** + * @defgroup tasks Tasks + * @ingroup public + * A task instance represents a piece of work performed by a particular + * thread for a period of time. A call to __itt_task_begin creates a + * task instance. This becomes the current instance for that task on that + * thread. A following call to __itt_task_end on the same thread ends the + * instance. There may be multiple simultaneous instances of tasks with the + * same name on different threads. If an ID is specified, the task instance + * receives that ID. Nested tasks are allowed. + * + * Note: The task is defined by the bracketing of __itt_task_begin and + * __itt_task_end on the same thread. If some scheduling mechanism causes + * task switching (the thread executes a different user task) or task + * switching (the user task switches to a different thread) then this breaks + * the notion of current instance. Additional API calls are required to + * deal with that possibility. + * @{ + */ + +/** + * @ingroup tasks + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] taskid The instance ID for this task instance, or __itt_null + * @param[in] parentid The parent instance to which this task instance belongs, or __itt_null + * @param[in] name The name of this task + */ +void ITTAPI __itt_task_begin(const __itt_domain *domain, __itt_id taskid, __itt_id parentid, __itt_string_handle *name); + +/** + * @ingroup tasks + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] taskid The identifier for this task instance (may be 0) + * @param[in] parentid The parent of this task (may be 0) + * @param[in] fn The pointer to the function you are tracing + */ +void ITTAPI __itt_task_begin_fn(const __itt_domain *domain, __itt_id taskid, __itt_id parentid, void* fn); + +/** + * @ingroup tasks + * @brief End the current task instance. + * @param[in] domain The domain for this task + */ +void ITTAPI __itt_task_end(const __itt_domain *domain); + +/** + * @ingroup tasks + * @brief Begin an overlapped task instance. + * @param[in] domain The domain for this task. + * @param[in] taskid The identifier for this task instance, *cannot* be __itt_null. + * @param[in] parentid The parent of this task, or __itt_null. + * @param[in] name The name of this task. + */ +void ITTAPI __itt_task_begin_overlapped(const __itt_domain* domain, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); + +/** + * @ingroup tasks + * @brief End an overlapped task instance. + * @param[in] domain The domain for this task + * @param[in] taskid Explicit ID of finished task + */ +void ITTAPI __itt_task_end_overlapped(const __itt_domain *domain, __itt_id taskid); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_begin, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, task_begin_fn, (const __itt_domain *domain, __itt_id id, __itt_id parentid, void* fn)) +ITT_STUBV(ITTAPI, void, task_end, (const __itt_domain *domain)) +ITT_STUBV(ITTAPI, void, task_begin_overlapped, (const __itt_domain *domain, __itt_id taskid, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, task_end_overlapped, (const __itt_domain *domain, __itt_id taskid)) +#define __itt_task_begin(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin,d,x,y,z) +#define __itt_task_begin_ptr ITTNOTIFY_NAME(task_begin) +#define __itt_task_begin_fn(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin_fn,d,x,y,z) +#define __itt_task_begin_fn_ptr ITTNOTIFY_NAME(task_begin_fn) +#define __itt_task_end(d) ITTNOTIFY_VOID_D0(task_end,d) +#define __itt_task_end_ptr ITTNOTIFY_NAME(task_end) +#define __itt_task_begin_overlapped(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin_overlapped,d,x,y,z) +#define __itt_task_begin_overlapped_ptr ITTNOTIFY_NAME(task_begin_overlapped) +#define __itt_task_end_overlapped(d,x) ITTNOTIFY_VOID_D1(task_end_overlapped,d,x) +#define __itt_task_end_overlapped_ptr ITTNOTIFY_NAME(task_end_overlapped) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_begin(domain,id,parentid,name) +#define __itt_task_begin_ptr 0 +#define __itt_task_begin_fn(domain,id,parentid,fn) +#define __itt_task_begin_fn_ptr 0 +#define __itt_task_end(domain) +#define __itt_task_end_ptr 0 +#define __itt_task_begin_overlapped(domain,taskid,parentid,name) +#define __itt_task_begin_overlapped_ptr 0 +#define __itt_task_end_overlapped(domain,taskid) +#define __itt_task_end_overlapped_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_begin_ptr 0 +#define __itt_task_begin_fn_ptr 0 +#define __itt_task_end_ptr 0 +#define __itt_task_begin_overlapped_ptr 0 +#define __itt_task_end_overlapped_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} tasks group */ + + +/** + * @defgroup markers Markers + * Markers represent a single discreet event in time. Markers have a scope, + * described by an enumerated type __itt_scope. Markers are created by + * the API call __itt_marker. A marker instance can be given an ID for use in + * adding metadata. + * @{ + */ + +/** + * @brief Describes the scope of an event object in the trace. + */ +typedef enum +{ + __itt_scope_unknown = 0, + __itt_scope_global, + __itt_scope_track_group, + __itt_scope_track, + __itt_scope_task, + __itt_scope_marker +} __itt_scope; + +/** @cond exclude_from_documentation */ +#define __itt_marker_scope_unknown __itt_scope_unknown +#define __itt_marker_scope_global __itt_scope_global +#define __itt_marker_scope_process __itt_scope_track_group +#define __itt_marker_scope_thread __itt_scope_track +#define __itt_marker_scope_task __itt_scope_task +/** @endcond */ + +/** + * @ingroup markers + * @brief Create a marker instance + * @param[in] domain The domain for this marker + * @param[in] id The instance ID for this marker or __itt_null + * @param[in] name The name for this marker + * @param[in] scope The scope for this marker + */ +void ITTAPI __itt_marker(const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, marker, (const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope)) +#define __itt_marker(d,x,y,z) ITTNOTIFY_VOID_D3(marker,d,x,y,z) +#define __itt_marker_ptr ITTNOTIFY_NAME(marker) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_marker(domain,id,name,scope) +#define __itt_marker_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_marker_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} markers group */ + +/** + * @defgroup metadata Metadata + * The metadata API is used to attach extra information to named + * entities. Metadata can be attached to an identified named entity by ID, + * or to the current entity (which is always a task). + * + * Conceptually metadata has a type (what kind of metadata), a key (the + * name of the metadata), and a value (the actual data). The encoding of + * the value depends on the type of the metadata. + * + * The type of metadata is specified by an enumerated type __itt_metdata_type. + * @{ + */ + +/** + * @ingroup parameters + * @brief describes the type of metadata + */ +typedef enum { + __itt_metadata_unknown = 0, + __itt_metadata_u64, /**< Unsigned 64-bit integer */ + __itt_metadata_s64, /**< Signed 64-bit integer */ + __itt_metadata_u32, /**< Unsigned 32-bit integer */ + __itt_metadata_s32, /**< Signed 32-bit integer */ + __itt_metadata_u16, /**< Unsigned 16-bit integer */ + __itt_metadata_s16, /**< Signed 16-bit integer */ + __itt_metadata_float, /**< Signed 32-bit floating-point */ + __itt_metadata_double /**< SIgned 64-bit floating-point */ +} __itt_metadata_type; + +/** + * @ingroup parameters + * @brief Add metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + * @param[in] key The name of the metadata + * @param[in] type The type of the metadata + * @param[in] count The number of elements of the given type. If count == 0, no metadata will be added. + * @param[in] data The metadata itself +*/ +void ITTAPI __itt_metadata_add(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, metadata_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data)) +#define __itt_metadata_add(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(metadata_add,d,x,y,z,a,b) +#define __itt_metadata_add_ptr ITTNOTIFY_NAME(metadata_add) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_metadata_add(d,x,y,z,a,b) +#define __itt_metadata_add_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_metadata_add_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup parameters + * @brief Add string metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + * @param[in] key The name of the metadata + * @param[in] data The metadata itself + * @param[in] length The number of characters in the string, or -1 if the length is unknown but the string is null-terminated +*/ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_metadata_str_addA(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length); +void ITTAPI __itt_metadata_str_addW(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t *data, size_t length); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_metadata_str_add __itt_metadata_str_addW +# define __itt_metadata_str_add_ptr __itt_metadata_str_addW_ptr +#else /* UNICODE */ +# define __itt_metadata_str_add __itt_metadata_str_addA +# define __itt_metadata_str_add_ptr __itt_metadata_str_addA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_metadata_str_add(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length); +#endif + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_addA, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length)) +ITT_STUBV(ITTAPI, void, metadata_str_addW, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t *data, size_t length)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_addA(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_addA,d,x,y,z,a) +#define __itt_metadata_str_addA_ptr ITTNOTIFY_NAME(metadata_str_addA) +#define __itt_metadata_str_addW(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_addW,d,x,y,z,a) +#define __itt_metadata_str_addW_ptr ITTNOTIFY_NAME(metadata_str_addW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add,d,x,y,z,a) +#define __itt_metadata_str_add_ptr ITTNOTIFY_NAME(metadata_str_add) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_addA(d,x,y,z,a) +#define __itt_metadata_str_addA_ptr 0 +#define __itt_metadata_str_addW(d,x,y,z,a) +#define __itt_metadata_str_addW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add(d,x,y,z,a) +#define __itt_metadata_str_add_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_addA_ptr 0 +#define __itt_metadata_str_addW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup parameters + * @brief Add metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] scope The scope of the instance to which the metadata is to be added + + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + + * @param[in] key The name of the metadata + * @param[in] type The type of the metadata + * @param[in] count The number of elements of the given type. If count == 0, no metadata will be added. + * @param[in] data The metadata itself +*/ +void ITTAPI __itt_metadata_add_with_scope(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, metadata_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data)) +#define __itt_metadata_add_with_scope(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(metadata_add_with_scope,d,x,y,z,a,b) +#define __itt_metadata_add_with_scope_ptr ITTNOTIFY_NAME(metadata_add_with_scope) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_metadata_add_with_scope(d,x,y,z,a,b) +#define __itt_metadata_add_with_scope_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_metadata_add_with_scope_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup parameters + * @brief Add string metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] scope The scope of the instance to which the metadata is to be added + + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + + * @param[in] key The name of the metadata + * @param[in] data The metadata itself + * @param[in] length The number of characters in the string, or -1 if the length is unknown but the string is null-terminated +*/ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_metadata_str_add_with_scopeA(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length); +void ITTAPI __itt_metadata_str_add_with_scopeW(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_metadata_str_add_with_scope __itt_metadata_str_add_with_scopeW +# define __itt_metadata_str_add_with_scope_ptr __itt_metadata_str_add_with_scopeW_ptr +#else /* UNICODE */ +# define __itt_metadata_str_add_with_scope __itt_metadata_str_add_with_scopeA +# define __itt_metadata_str_add_with_scope_ptr __itt_metadata_str_add_with_scopeA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_metadata_str_add_with_scope(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length); +#endif + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeA, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length)) +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeW, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_add_with_scopeA(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scopeA,d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeA_ptr ITTNOTIFY_NAME(metadata_str_add_with_scopeA) +#define __itt_metadata_str_add_with_scopeW(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scopeW,d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeW_ptr ITTNOTIFY_NAME(metadata_str_add_with_scopeW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_with_scope(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scope,d,x,y,z,a) +#define __itt_metadata_str_add_with_scope_ptr ITTNOTIFY_NAME(metadata_str_add_with_scope) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_add_with_scopeA(d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeA_ptr 0 +#define __itt_metadata_str_add_with_scopeW(d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_with_scope(d,x,y,z,a) +#define __itt_metadata_str_add_with_scope_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_add_with_scopeA_ptr 0 +#define __itt_metadata_str_add_with_scopeW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_with_scope_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} metadata group */ + +/** + * @defgroup relations Relations + * Instances of named entities can be explicitly associated with other + * instances using instance IDs and the relationship API calls. + * + * @{ + */ + +/** + * @ingroup relations + * @brief The kind of relation between two instances is specified by the enumerated type __itt_relation. + * Relations between instances can be added with an API call. The relation + * API uses instance IDs. Relations can be added before or after the actual + * instances are created and persist independently of the instances. This + * is the motivation for having different lifetimes for instance IDs and + * the actual instances. + */ +typedef enum +{ + __itt_relation_is_unknown = 0, + __itt_relation_is_dependent_on, /**< "A is dependent on B" means that A cannot start until B completes */ + __itt_relation_is_sibling_of, /**< "A is sibling of B" means that A and B were created as a group */ + __itt_relation_is_parent_of, /**< "A is parent of B" means that A created B */ + __itt_relation_is_continuation_of, /**< "A is continuation of B" means that A assumes the dependencies of B */ + __itt_relation_is_child_of, /**< "A is child of B" means that A was created by B (inverse of is_parent_of) */ + __itt_relation_is_continued_by, /**< "A is continued by B" means that B assumes the dependencies of A (inverse of is_continuation_of) */ + __itt_relation_is_predecessor_to /**< "A is predecessor to B" means that B cannot start until A completes (inverse of is_dependent_on) */ +} __itt_relation; + +/** + * @ingroup relations + * @brief Add a relation to the current task instance. + * The current task instance is the head of the relation. + * @param[in] domain The domain controlling this call + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add_to_current(const __itt_domain *domain, __itt_relation relation, __itt_id tail); + +/** + * @ingroup relations + * @brief Add a relation between two instance identifiers. + * @param[in] domain The domain controlling this call + * @param[in] head The ID for the head of the relation + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add(const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, relation_add_to_current, (const __itt_domain *domain, __itt_relation relation, __itt_id tail)) +ITT_STUBV(ITTAPI, void, relation_add, (const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail)) +#define __itt_relation_add_to_current(d,x,y) ITTNOTIFY_VOID_D2(relation_add_to_current,d,x,y) +#define __itt_relation_add_to_current_ptr ITTNOTIFY_NAME(relation_add_to_current) +#define __itt_relation_add(d,x,y,z) ITTNOTIFY_VOID_D3(relation_add,d,x,y,z) +#define __itt_relation_add_ptr ITTNOTIFY_NAME(relation_add) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_relation_add_to_current(d,x,y) +#define __itt_relation_add_to_current_ptr 0 +#define __itt_relation_add(d,x,y,z) +#define __itt_relation_add_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_relation_add_to_current_ptr 0 +#define __itt_relation_add_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} relations group */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_clock_info +{ + unsigned long long clock_freq; /*!< Clock domain frequency */ + unsigned long long clock_base; /*!< Clock domain base timestamp */ +} __itt_clock_info; + +#pragma pack(pop) +/** @endcond */ + +/** @cond exclude_from_documentation */ +typedef void (ITTAPI *__itt_get_clock_info_fn)(__itt_clock_info* clock_info, void* data); +/** @endcond */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_clock_domain +{ + __itt_clock_info info; /*!< Most recent clock domain info */ + __itt_get_clock_info_fn fn; /*!< Callback function pointer */ + void* fn_data; /*!< Input argument for the callback function */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_clock_domain* next; +} __itt_clock_domain; + +#pragma pack(pop) +/** @endcond */ + +/** + * @ingroup clockdomains + * @brief Create a clock domain. + * Certain applications require the capability to trace their application using + * a clock domain different than the CPU, for instance the instrumentation of events + * that occur on a GPU. + * Because the set of domains is expected to be static over the application's execution time, + * there is no mechanism to destroy a domain. + * Any domain can be accessed by any thread in the process, regardless of which thread created + * the domain. This call is thread-safe. + * @param[in] fn A pointer to a callback function which retrieves alternative CPU timestamps + * @param[in] fn_data Argument for a callback function; may be NULL + */ +__itt_clock_domain* ITTAPI __itt_clock_domain_create(__itt_get_clock_info_fn fn, void* fn_data); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_clock_domain*, clock_domain_create, (__itt_get_clock_info_fn fn, void* fn_data)) +#define __itt_clock_domain_create ITTNOTIFY_DATA(clock_domain_create) +#define __itt_clock_domain_create_ptr ITTNOTIFY_NAME(clock_domain_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_clock_domain_create(fn,fn_data) (__itt_clock_domain*)0 +#define __itt_clock_domain_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_clock_domain_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomains + * @brief Recalculate clock domains frequences and clock base timestamps. + */ +void ITTAPI __itt_clock_domain_reset(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, clock_domain_reset, (void)) +#define __itt_clock_domain_reset ITTNOTIFY_VOID(clock_domain_reset) +#define __itt_clock_domain_reset_ptr ITTNOTIFY_NAME(clock_domain_reset) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_clock_domain_reset() +#define __itt_clock_domain_reset_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_clock_domain_reset_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomain + * @brief Create an instance of identifier. This establishes the beginning of the lifetime of + * an instance of the given ID in the trace. Once this lifetime starts, the ID can be used to + * tag named entity instances in calls such as __itt_task_begin, and to specify relationships among + * identified named entity instances, using the \ref relations APIs. + * @param[in] domain The domain controlling the execution of this call. + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] id The ID to create. + */ +void ITTAPI __itt_id_create_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id); + +/** + * @ingroup clockdomain + * @brief Destroy an instance of identifier. This ends the lifetime of the current instance of the + * given ID value in the trace. Any relationships that are established after this lifetime ends are + * invalid. This call must be performed before the given ID value can be reused for a different + * named entity instance. + * @param[in] domain The domain controlling the execution of this call. + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] id The ID to destroy. + */ +void ITTAPI __itt_id_destroy_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, id_create_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id)) +ITT_STUBV(ITTAPI, void, id_destroy_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id)) +#define __itt_id_create_ex(d,x,y,z) ITTNOTIFY_VOID_D3(id_create_ex,d,x,y,z) +#define __itt_id_create_ex_ptr ITTNOTIFY_NAME(id_create_ex) +#define __itt_id_destroy_ex(d,x,y,z) ITTNOTIFY_VOID_D3(id_destroy_ex,d,x,y,z) +#define __itt_id_destroy_ex_ptr ITTNOTIFY_NAME(id_destroy_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_id_create_ex(domain,clock_domain,timestamp,id) +#define __itt_id_create_ex_ptr 0 +#define __itt_id_destroy_ex(domain,clock_domain,timestamp,id) +#define __itt_id_destroy_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_id_create_ex_ptr 0 +#define __itt_id_destroy_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomain + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid The instance ID for this task instance, or __itt_null + * @param[in] parentid The parent instance to which this task instance belongs, or __itt_null + * @param[in] name The name of this task + */ +void ITTAPI __itt_task_begin_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); + +/** + * @ingroup clockdomain + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid The identifier for this task instance, or __itt_null + * @param[in] parentid The parent of this task, or __itt_null + * @param[in] fn The pointer to the function you are tracing + */ +void ITTAPI __itt_task_begin_fn_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, void* fn); + +/** + * @ingroup clockdomain + * @brief End the current task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + */ +void ITTAPI __itt_task_end_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_begin_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, task_begin_fn_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, void* fn)) +ITT_STUBV(ITTAPI, void, task_end_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp)) +#define __itt_task_begin_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_ex,d,x,y,z,a,b) +#define __itt_task_begin_ex_ptr ITTNOTIFY_NAME(task_begin_ex) +#define __itt_task_begin_fn_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_fn_ex,d,x,y,z,a,b) +#define __itt_task_begin_fn_ex_ptr ITTNOTIFY_NAME(task_begin_fn_ex) +#define __itt_task_end_ex(d,x,y) ITTNOTIFY_VOID_D2(task_end_ex,d,x,y) +#define __itt_task_end_ex_ptr ITTNOTIFY_NAME(task_end_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_begin_ex(domain,clock_domain,timestamp,id,parentid,name) +#define __itt_task_begin_ex_ptr 0 +#define __itt_task_begin_fn_ex(domain,clock_domain,timestamp,id,parentid,fn) +#define __itt_task_begin_fn_ex_ptr 0 +#define __itt_task_end_ex(domain,clock_domain,timestamp) +#define __itt_task_end_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_begin_ex_ptr 0 +#define __itt_task_begin_fn_ex_ptr 0 +#define __itt_task_end_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @defgroup counters Counters + * @ingroup public + * Counters are user-defined objects with a monotonically increasing + * value. Counter values are 64-bit unsigned integers. + * Counters have names that can be displayed in + * the tools. + * @{ + */ + +/** + * @brief opaque structure for counter identification + */ +/** @cond exclude_from_documentation */ + +typedef struct ___itt_counter* __itt_counter; + +/** + * @brief Create an unsigned 64 bits integer counter with given name/domain + * + * After __itt_counter_create() is called, __itt_counter_inc(id), __itt_counter_inc_delta(id, delta), + * __itt_counter_set_value(id, value_ptr) or __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) + * can be used to change the value of the counter, where value_ptr is a pointer to an unsigned 64 bits integer + * + * The call is equal to __itt_counter_create_typed(name, domain, __itt_metadata_u64) + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_counter ITTAPI __itt_counter_createA(const char *name, const char *domain); +__itt_counter ITTAPI __itt_counter_createW(const wchar_t *name, const wchar_t *domain); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_counter_create __itt_counter_createW +# define __itt_counter_create_ptr __itt_counter_createW_ptr +#else /* UNICODE */ +# define __itt_counter_create __itt_counter_createA +# define __itt_counter_create_ptr __itt_counter_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_counter ITTAPI __itt_counter_create(const char *name, const char *domain); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_counter, counter_createA, (const char *name, const char *domain)) +ITT_STUB(ITTAPI, __itt_counter, counter_createW, (const wchar_t *name, const wchar_t *domain)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_counter, counter_create, (const char *name, const char *domain)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_createA ITTNOTIFY_DATA(counter_createA) +#define __itt_counter_createA_ptr ITTNOTIFY_NAME(counter_createA) +#define __itt_counter_createW ITTNOTIFY_DATA(counter_createW) +#define __itt_counter_createW_ptr ITTNOTIFY_NAME(counter_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create ITTNOTIFY_DATA(counter_create) +#define __itt_counter_create_ptr ITTNOTIFY_NAME(counter_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_createA(name, domain) +#define __itt_counter_createA_ptr 0 +#define __itt_counter_createW(name, domain) +#define __itt_counter_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create(name, domain) +#define __itt_counter_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_createA_ptr 0 +#define __itt_counter_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Increment the unsigned 64 bits integer counter value + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_inc(__itt_counter id); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_inc, (__itt_counter id)) +#define __itt_counter_inc ITTNOTIFY_VOID(counter_inc) +#define __itt_counter_inc_ptr ITTNOTIFY_NAME(counter_inc) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_inc(id) +#define __itt_counter_inc_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_inc_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** + * @brief Increment the unsigned 64 bits integer counter value with x + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_inc_delta(__itt_counter id, unsigned long long value); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_inc_delta, (__itt_counter id, unsigned long long value)) +#define __itt_counter_inc_delta ITTNOTIFY_VOID(counter_inc_delta) +#define __itt_counter_inc_delta_ptr ITTNOTIFY_NAME(counter_inc_delta) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_inc_delta(id, value) +#define __itt_counter_inc_delta_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_inc_delta_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Decrement the unsigned 64 bits integer counter value + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_dec(__itt_counter id); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_dec, (__itt_counter id)) +#define __itt_counter_dec ITTNOTIFY_VOID(counter_dec) +#define __itt_counter_dec_ptr ITTNOTIFY_NAME(counter_dec) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_dec(id) +#define __itt_counter_dec_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_dec_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** + * @brief Decrement the unsigned 64 bits integer counter value with x + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_dec_delta(__itt_counter id, unsigned long long value); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_dec_delta, (__itt_counter id, unsigned long long value)) +#define __itt_counter_dec_delta ITTNOTIFY_VOID(counter_dec_delta) +#define __itt_counter_dec_delta_ptr ITTNOTIFY_NAME(counter_dec_delta) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_dec_delta(id, value) +#define __itt_counter_dec_delta_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_dec_delta_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup counters + * @brief Increment a counter by one. + * The first call with a given name creates a counter by that name and sets its + * value to zero. Successive calls increment the counter value. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + */ +void ITTAPI __itt_counter_inc_v3(const __itt_domain *domain, __itt_string_handle *name); + +/** + * @ingroup counters + * @brief Increment a counter by the value specified in delta. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + * @param[in] delta The amount by which to increment the counter + */ +void ITTAPI __itt_counter_inc_delta_v3(const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_inc_v3, (const __itt_domain *domain, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, counter_inc_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta)) +#define __itt_counter_inc_v3(d,x) ITTNOTIFY_VOID_D1(counter_inc_v3,d,x) +#define __itt_counter_inc_v3_ptr ITTNOTIFY_NAME(counter_inc_v3) +#define __itt_counter_inc_delta_v3(d,x,y) ITTNOTIFY_VOID_D2(counter_inc_delta_v3,d,x,y) +#define __itt_counter_inc_delta_v3_ptr ITTNOTIFY_NAME(counter_inc_delta_v3) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_inc_v3(domain,name) +#define __itt_counter_inc_v3_ptr 0 +#define __itt_counter_inc_delta_v3(domain,name,delta) +#define __itt_counter_inc_delta_v3_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_inc_v3_ptr 0 +#define __itt_counter_inc_delta_v3_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + + +/** + * @ingroup counters + * @brief Decrement a counter by one. + * The first call with a given name creates a counter by that name and sets its + * value to zero. Successive calls decrement the counter value. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + */ +void ITTAPI __itt_counter_dec_v3(const __itt_domain *domain, __itt_string_handle *name); + +/** + * @ingroup counters + * @brief Decrement a counter by the value specified in delta. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + * @param[in] delta The amount by which to decrement the counter + */ +void ITTAPI __itt_counter_dec_delta_v3(const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_dec_v3, (const __itt_domain *domain, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, counter_dec_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta)) +#define __itt_counter_dec_v3(d,x) ITTNOTIFY_VOID_D1(counter_dec_v3,d,x) +#define __itt_counter_dec_v3_ptr ITTNOTIFY_NAME(counter_dec_v3) +#define __itt_counter_dec_delta_v3(d,x,y) ITTNOTIFY_VOID_D2(counter_dec_delta_v3,d,x,y) +#define __itt_counter_dec_delta_v3_ptr ITTNOTIFY_NAME(counter_dec_delta_v3) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_dec_v3(domain,name) +#define __itt_counter_dec_v3_ptr 0 +#define __itt_counter_dec_delta_v3(domain,name,delta) +#define __itt_counter_dec_delta_v3_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_dec_v3_ptr 0 +#define __itt_counter_dec_delta_v3_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} counters group */ + + +/** + * @brief Set the counter value + */ +void ITTAPI __itt_counter_set_value(__itt_counter id, void *value_ptr); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_set_value, (__itt_counter id, void *value_ptr)) +#define __itt_counter_set_value ITTNOTIFY_VOID(counter_set_value) +#define __itt_counter_set_value_ptr ITTNOTIFY_NAME(counter_set_value) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_set_value(id, value_ptr) +#define __itt_counter_set_value_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_set_value_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Set the counter value + */ +void ITTAPI __itt_counter_set_value_ex(__itt_counter id, __itt_clock_domain *clock_domain, unsigned long long timestamp, void *value_ptr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_set_value_ex, (__itt_counter id, __itt_clock_domain *clock_domain, unsigned long long timestamp, void *value_ptr)) +#define __itt_counter_set_value_ex ITTNOTIFY_VOID(counter_set_value_ex) +#define __itt_counter_set_value_ex_ptr ITTNOTIFY_NAME(counter_set_value_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) +#define __itt_counter_set_value_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_set_value_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Create a typed counter with given name/domain + * + * After __itt_counter_create_typed() is called, __itt_counter_inc(id), __itt_counter_inc_delta(id, delta), + * __itt_counter_set_value(id, value_ptr) or __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) + * can be used to change the value of the counter + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_counter ITTAPI __itt_counter_create_typedA(const char *name, const char *domain, __itt_metadata_type type); +__itt_counter ITTAPI __itt_counter_create_typedW(const wchar_t *name, const wchar_t *domain, __itt_metadata_type type); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_counter_create_typed __itt_counter_create_typedW +# define __itt_counter_create_typed_ptr __itt_counter_create_typedW_ptr +#else /* UNICODE */ +# define __itt_counter_create_typed __itt_counter_create_typedA +# define __itt_counter_create_typed_ptr __itt_counter_create_typedA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_counter ITTAPI __itt_counter_create_typed(const char *name, const char *domain, __itt_metadata_type type); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_counter, counter_create_typedA, (const char *name, const char *domain, __itt_metadata_type type)) +ITT_STUB(ITTAPI, __itt_counter, counter_create_typedW, (const wchar_t *name, const wchar_t *domain, __itt_metadata_type type)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_counter, counter_create_typed, (const char *name, const char *domain, __itt_metadata_type type)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_create_typedA ITTNOTIFY_DATA(counter_create_typedA) +#define __itt_counter_create_typedA_ptr ITTNOTIFY_NAME(counter_create_typedA) +#define __itt_counter_create_typedW ITTNOTIFY_DATA(counter_create_typedW) +#define __itt_counter_create_typedW_ptr ITTNOTIFY_NAME(counter_create_typedW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_typed ITTNOTIFY_DATA(counter_create_typed) +#define __itt_counter_create_typed_ptr ITTNOTIFY_NAME(counter_create_typed) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_create_typedA(name, domain, type) +#define __itt_counter_create_typedA_ptr 0 +#define __itt_counter_create_typedW(name, domain, type) +#define __itt_counter_create_typedW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_typed(name, domain, type) +#define __itt_counter_create_typed_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_create_typedA_ptr 0 +#define __itt_counter_create_typedW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_typed_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Destroy the counter identified by the pointer previously returned by __itt_counter_create() or + * __itt_counter_create_typed() + */ +void ITTAPI __itt_counter_destroy(__itt_counter id); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_destroy, (__itt_counter id)) +#define __itt_counter_destroy ITTNOTIFY_VOID(counter_destroy) +#define __itt_counter_destroy_ptr ITTNOTIFY_NAME(counter_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_destroy(id) +#define __itt_counter_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} counters group */ + +/** + * @ingroup markers + * @brief Create a marker instance. + * @param[in] domain The domain for this marker + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] id The instance ID for this marker, or __itt_null + * @param[in] name The name for this marker + * @param[in] scope The scope for this marker + */ +void ITTAPI __itt_marker_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, marker_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope)) +#define __itt_marker_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(marker_ex,d,x,y,z,a,b) +#define __itt_marker_ex_ptr ITTNOTIFY_NAME(marker_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_marker_ex(domain,clock_domain,timestamp,id,name,scope) +#define __itt_marker_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_marker_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomain + * @brief Add a relation to the current task instance. + * The current task instance is the head of the relation. + * @param[in] domain The domain controlling this call + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add_to_current_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail); + +/** + * @ingroup clockdomain + * @brief Add a relation between two instance identifiers. + * @param[in] domain The domain controlling this call + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] head The ID for the head of the relation + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, relation_add_to_current_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail)) +ITT_STUBV(ITTAPI, void, relation_add_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail)) +#define __itt_relation_add_to_current_ex(d,x,y,z,a) ITTNOTIFY_VOID_D4(relation_add_to_current_ex,d,x,y,z,a) +#define __itt_relation_add_to_current_ex_ptr ITTNOTIFY_NAME(relation_add_to_current_ex) +#define __itt_relation_add_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(relation_add_ex,d,x,y,z,a,b) +#define __itt_relation_add_ex_ptr ITTNOTIFY_NAME(relation_add_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_relation_add_to_current_ex(domain,clock_domain,timestame,relation,tail) +#define __itt_relation_add_to_current_ex_ptr 0 +#define __itt_relation_add_ex(domain,clock_domain,timestamp,head,relation,tail) +#define __itt_relation_add_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_relation_add_to_current_ex_ptr 0 +#define __itt_relation_add_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +typedef enum ___itt_track_group_type +{ + __itt_track_group_type_normal = 0 +} __itt_track_group_type; +/** @endcond */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_track_group +{ + __itt_string_handle* name; /*!< Name of the track group */ + struct ___itt_track* track; /*!< List of child tracks */ + __itt_track_group_type tgtype; /*!< Type of the track group */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_track_group* next; +} __itt_track_group; + +#pragma pack(pop) +/** @endcond */ + +/** + * @brief Placeholder for custom track types. Currently, "normal" custom track + * is the only available track type. + */ +typedef enum ___itt_track_type +{ + __itt_track_type_normal = 0 +#ifdef INTEL_ITTNOTIFY_API_PRIVATE + , __itt_track_type_queue +#endif /* INTEL_ITTNOTIFY_API_PRIVATE */ +} __itt_track_type; + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_track +{ + __itt_string_handle* name; /*!< Name of the track group */ + __itt_track_group* group; /*!< Parent group to a track */ + __itt_track_type ttype; /*!< Type of the track */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_track* next; +} __itt_track; + +#pragma pack(pop) +/** @endcond */ + +/** + * @brief Create logical track group. + */ +__itt_track_group* ITTAPI __itt_track_group_create(__itt_string_handle* name, __itt_track_group_type track_group_type); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_track_group*, track_group_create, (__itt_string_handle* name, __itt_track_group_type track_group_type)) +#define __itt_track_group_create ITTNOTIFY_DATA(track_group_create) +#define __itt_track_group_create_ptr ITTNOTIFY_NAME(track_group_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_track_group_create(name) (__itt_track_group*)0 +#define __itt_track_group_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_track_group_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Create logical track. + */ +__itt_track* ITTAPI __itt_track_create(__itt_track_group* track_group, __itt_string_handle* name, __itt_track_type track_type); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_track*, track_create, (__itt_track_group* track_group,__itt_string_handle* name, __itt_track_type track_type)) +#define __itt_track_create ITTNOTIFY_DATA(track_create) +#define __itt_track_create_ptr ITTNOTIFY_NAME(track_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_track_create(track_group,name,track_type) (__itt_track*)0 +#define __itt_track_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_track_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Set the logical track. + */ +void ITTAPI __itt_set_track(__itt_track* track); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, set_track, (__itt_track *track)) +#define __itt_set_track ITTNOTIFY_VOID(set_track) +#define __itt_set_track_ptr ITTNOTIFY_NAME(set_track) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_set_track(track) +#define __itt_set_track_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_set_track_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/* ========================================================================== */ +/** @cond exclude_from_gpa_documentation */ +/** + * @defgroup events Events + * @ingroup public + * Events group + * @{ + */ +/** @brief user event type */ +typedef int __itt_event; + +/** + * @brief Create an event notification + * @note name or namelen being null/name and namelen not matching, user event feature not enabled + * @return non-zero event identifier upon success and __itt_err otherwise + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_event LIBITTAPI __itt_event_createA(const char *name, int namelen); +__itt_event LIBITTAPI __itt_event_createW(const wchar_t *name, int namelen); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_event_create __itt_event_createW +# define __itt_event_create_ptr __itt_event_createW_ptr +#else +# define __itt_event_create __itt_event_createA +# define __itt_event_create_ptr __itt_event_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_event LIBITTAPI __itt_event_create(const char *name, int namelen); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen)) +ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA ITTNOTIFY_DATA(event_createA) +#define __itt_event_createA_ptr ITTNOTIFY_NAME(event_createA) +#define __itt_event_createW ITTNOTIFY_DATA(event_createW) +#define __itt_event_createW_ptr ITTNOTIFY_NAME(event_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create ITTNOTIFY_DATA(event_create) +#define __itt_event_create_ptr ITTNOTIFY_NAME(event_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA(name, namelen) (__itt_event)0 +#define __itt_event_createA_ptr 0 +#define __itt_event_createW(name, namelen) (__itt_event)0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create(name, namelen) (__itt_event)0 +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA_ptr 0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event occurrence. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_start(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event)) +#define __itt_event_start ITTNOTIFY_DATA(event_start) +#define __itt_event_start_ptr ITTNOTIFY_NAME(event_start) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_start(event) (int)0 +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event end occurrence. + * @note It is optional if events do not have durations. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_end(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event)) +#define __itt_event_end ITTNOTIFY_DATA(event_end) +#define __itt_event_end_ptr ITTNOTIFY_NAME(event_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_end(event) (int)0 +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} events group */ + + +/** + * @defgroup arrays Arrays Visualizer + * @ingroup public + * Visualize arrays + * @{ + */ + +/** + * @enum __itt_av_data_type + * @brief Defines types of arrays data (for C/C++ intrinsic types) + */ +typedef enum +{ + __itt_e_first = 0, + __itt_e_char = 0, /* 1-byte integer */ + __itt_e_uchar, /* 1-byte unsigned integer */ + __itt_e_int16, /* 2-byte integer */ + __itt_e_uint16, /* 2-byte unsigned integer */ + __itt_e_int32, /* 4-byte integer */ + __itt_e_uint32, /* 4-byte unsigned integer */ + __itt_e_int64, /* 8-byte integer */ + __itt_e_uint64, /* 8-byte unsigned integer */ + __itt_e_float, /* 4-byte floating */ + __itt_e_double, /* 8-byte floating */ + __itt_e_last = __itt_e_double +} __itt_av_data_type; + +/** + * @brief Save an array data to a file. + * Output format is defined by the file extension. The csv and bmp formats are supported (bmp - for 2-dimensional array only). + * @param[in] data - pointer to the array data + * @param[in] rank - the rank of the array + * @param[in] dimensions - pointer to an array of integers, which specifies the array dimensions. + * The size of dimensions must be equal to the rank + * @param[in] type - the type of the array, specified as one of the __itt_av_data_type values (for intrinsic types) + * @param[in] filePath - the file path; the output format is defined by the file extension + * @param[in] columnOrder - defines how the array is stored in the linear memory. + * It should be 1 for column-major order (e.g. in FORTRAN) or 0 - for row-major order (e.g. in C). + */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int ITTAPI __itt_av_saveA(void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder); +int ITTAPI __itt_av_saveW(void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_av_save __itt_av_saveW +# define __itt_av_save_ptr __itt_av_saveW_ptr +#else /* UNICODE */ +# define __itt_av_save __itt_av_saveA +# define __itt_av_save_ptr __itt_av_saveA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int ITTAPI __itt_av_save(void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, av_saveA, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder)) +ITT_STUB(ITTAPI, int, av_saveW, (void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, av_save, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_av_saveA ITTNOTIFY_DATA(av_saveA) +#define __itt_av_saveA_ptr ITTNOTIFY_NAME(av_saveA) +#define __itt_av_saveW ITTNOTIFY_DATA(av_saveW) +#define __itt_av_saveW_ptr ITTNOTIFY_NAME(av_saveW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_av_save ITTNOTIFY_DATA(av_save) +#define __itt_av_save_ptr ITTNOTIFY_NAME(av_save) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_av_saveA(name) +#define __itt_av_saveA_ptr 0 +#define __itt_av_saveW(name) +#define __itt_av_saveW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_av_save(name) +#define __itt_av_save_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_av_saveA_ptr 0 +#define __itt_av_saveW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_av_save_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +void ITTAPI __itt_enable_attach(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, enable_attach, (void)) +#define __itt_enable_attach ITTNOTIFY_VOID(enable_attach) +#define __itt_enable_attach_ptr ITTNOTIFY_NAME(enable_attach) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_enable_attach() +#define __itt_enable_attach_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_enable_attach_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_gpa_documentation */ + +/** @} arrays group */ + +/** @endcond */ + +/** + * @brief Module load info + * This API is used to report necessary information in case of module relocation + * @param[in] start_addr - relocated module start address + * @param[in] end_addr - relocated module end address + * @param[in] path - file system path to the module + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_module_loadA(void *start_addr, void *end_addr, const char *path); +void ITTAPI __itt_module_loadW(void *start_addr, void *end_addr, const wchar_t *path); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_module_load __itt_module_loadW +# define __itt_module_load_ptr __itt_module_loadW_ptr +#else /* UNICODE */ +# define __itt_module_load __itt_module_loadA +# define __itt_module_load_ptr __itt_module_loadA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_module_load(void *start_addr, void *end_addr, const char *path); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, void, module_loadA, (void *start_addr, void *end_addr, const char *path)) +ITT_STUB(ITTAPI, void, module_loadW, (void *start_addr, void *end_addr, const wchar_t *path)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const char *path)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_module_loadA ITTNOTIFY_VOID(module_loadA) +#define __itt_module_loadA_ptr ITTNOTIFY_NAME(module_loadA) +#define __itt_module_loadW ITTNOTIFY_VOID(module_loadW) +#define __itt_module_loadW_ptr ITTNOTIFY_NAME(module_loadW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_module_load ITTNOTIFY_VOID(module_load) +#define __itt_module_load_ptr ITTNOTIFY_NAME(module_load) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_module_loadA(start_addr, end_addr, path) +#define __itt_module_loadA_ptr 0 +#define __itt_module_loadW(start_addr, end_addr, path) +#define __itt_module_loadW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_module_load(start_addr, end_addr, path) +#define __itt_module_load_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_module_loadA_ptr 0 +#define __itt_module_loadW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_module_load_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _ITTNOTIFY_H_ */ + +#ifdef INTEL_ITTNOTIFY_API_PRIVATE + +#ifndef _ITTNOTIFY_PRIVATE_ +#define _ITTNOTIFY_PRIVATE_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @ingroup clockdomain + * @brief Begin an overlapped task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid The identifier for this task instance, *cannot* be __itt_null. + * @param[in] parentid The parent of this task, or __itt_null. + * @param[in] name The name of this task. + */ +void ITTAPI __itt_task_begin_overlapped_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); + +/** + * @ingroup clockdomain + * @brief End an overlapped task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid Explicit ID of finished task + */ +void ITTAPI __itt_task_end_overlapped_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_begin_overlapped_ex, (const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name)) +ITT_STUBV(ITTAPI, void, task_end_overlapped_ex, (const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid)) +#define __itt_task_begin_overlapped_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_overlapped_ex,d,x,y,z,a,b) +#define __itt_task_begin_overlapped_ex_ptr ITTNOTIFY_NAME(task_begin_overlapped_ex) +#define __itt_task_end_overlapped_ex(d,x,y,z) ITTNOTIFY_VOID_D3(task_end_overlapped_ex,d,x,y,z) +#define __itt_task_end_overlapped_ex_ptr ITTNOTIFY_NAME(task_end_overlapped_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_begin_overlapped_ex(domain,clock_domain,timestamp,taskid,parentid,name) +#define __itt_task_begin_overlapped_ex_ptr 0 +#define __itt_task_end_overlapped_ex(domain,clock_domain,timestamp,taskid) +#define __itt_task_end_overlapped_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_begin_overlapped_ex_ptr 0 +#define __itt_task_end_overlapped_ptr 0 +#define __itt_task_end_overlapped_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @defgroup makrs_internal Marks + * @ingroup internal + * Marks group + * @warning Internal API: + * - It is not shipped to outside of Intel + * - It is delivered to internal Intel teams using e-mail or SVN access only + * @{ + */ +/** @brief user mark type */ +typedef int __itt_mark_type; + +/** + * @brief Creates a user mark type with the specified name using char or Unicode string. + * @param[in] name - name of mark to create + * @return Returns a handle to the mark type + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_mark_type ITTAPI __itt_mark_createA(const char *name); +__itt_mark_type ITTAPI __itt_mark_createW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_mark_create __itt_mark_createW +# define __itt_mark_create_ptr __itt_mark_createW_ptr +#else /* UNICODE */ +# define __itt_mark_create __itt_mark_createA +# define __itt_mark_create_ptr __itt_mark_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_mark_type ITTAPI __itt_mark_create(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_mark_type, mark_createA, (const char *name)) +ITT_STUB(ITTAPI, __itt_mark_type, mark_createW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_mark_type, mark_create, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_createA ITTNOTIFY_DATA(mark_createA) +#define __itt_mark_createA_ptr ITTNOTIFY_NAME(mark_createA) +#define __itt_mark_createW ITTNOTIFY_DATA(mark_createW) +#define __itt_mark_createW_ptr ITTNOTIFY_NAME(mark_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_create ITTNOTIFY_DATA(mark_create) +#define __itt_mark_create_ptr ITTNOTIFY_NAME(mark_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_createA(name) (__itt_mark_type)0 +#define __itt_mark_createA_ptr 0 +#define __itt_mark_createW(name) (__itt_mark_type)0 +#define __itt_mark_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_create(name) (__itt_mark_type)0 +#define __itt_mark_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_createA_ptr 0 +#define __itt_mark_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Creates a "discrete" user mark type of the specified type and an optional parameter using char or Unicode string. + * + * - The mark of "discrete" type is placed to collection results in case of success. It appears in overtime view(s) as a special tick sign. + * - The call is "synchronous" - function returns after mark is actually added to results. + * - This function is useful, for example, to mark different phases of application + * (beginning of the next mark automatically meand end of current region). + * - Can be used together with "continuous" marks (see below) at the same collection session + * @param[in] mt - mark, created by __itt_mark_create(const char* name) function + * @param[in] parameter - string parameter of mark + * @return Returns zero value in case of success, non-zero value otherwise. + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int ITTAPI __itt_markA(__itt_mark_type mt, const char *parameter); +int ITTAPI __itt_markW(__itt_mark_type mt, const wchar_t *parameter); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_mark __itt_markW +# define __itt_mark_ptr __itt_markW_ptr +#else /* UNICODE */ +# define __itt_mark __itt_markA +# define __itt_mark_ptr __itt_markA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int ITTAPI __itt_mark(__itt_mark_type mt, const char *parameter); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, markA, (__itt_mark_type mt, const char *parameter)) +ITT_STUB(ITTAPI, int, markW, (__itt_mark_type mt, const wchar_t *parameter)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark, (__itt_mark_type mt, const char *parameter)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_markA ITTNOTIFY_DATA(markA) +#define __itt_markA_ptr ITTNOTIFY_NAME(markA) +#define __itt_markW ITTNOTIFY_DATA(markW) +#define __itt_markW_ptr ITTNOTIFY_NAME(markW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark ITTNOTIFY_DATA(mark) +#define __itt_mark_ptr ITTNOTIFY_NAME(mark) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_markA(mt, parameter) (int)0 +#define __itt_markA_ptr 0 +#define __itt_markW(mt, parameter) (int)0 +#define __itt_markW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark(mt, parameter) (int)0 +#define __itt_mark_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_markA_ptr 0 +#define __itt_markW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Use this if necessary to create a "discrete" user event type (mark) for process + * rather then for one thread + * @see int __itt_mark(__itt_mark_type mt, const char* parameter); + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int ITTAPI __itt_mark_globalA(__itt_mark_type mt, const char *parameter); +int ITTAPI __itt_mark_globalW(__itt_mark_type mt, const wchar_t *parameter); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_mark_global __itt_mark_globalW +# define __itt_mark_global_ptr __itt_mark_globalW_ptr +#else /* UNICODE */ +# define __itt_mark_global __itt_mark_globalA +# define __itt_mark_global_ptr __itt_mark_globalA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int ITTAPI __itt_mark_global(__itt_mark_type mt, const char *parameter); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, mark_globalA, (__itt_mark_type mt, const char *parameter)) +ITT_STUB(ITTAPI, int, mark_globalW, (__itt_mark_type mt, const wchar_t *parameter)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_global, (__itt_mark_type mt, const char *parameter)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_globalA ITTNOTIFY_DATA(mark_globalA) +#define __itt_mark_globalA_ptr ITTNOTIFY_NAME(mark_globalA) +#define __itt_mark_globalW ITTNOTIFY_DATA(mark_globalW) +#define __itt_mark_globalW_ptr ITTNOTIFY_NAME(mark_globalW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_global ITTNOTIFY_DATA(mark_global) +#define __itt_mark_global_ptr ITTNOTIFY_NAME(mark_global) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_globalA(mt, parameter) (int)0 +#define __itt_mark_globalA_ptr 0 +#define __itt_mark_globalW(mt, parameter) (int)0 +#define __itt_mark_globalW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_global(mt, parameter) (int)0 +#define __itt_mark_global_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_globalA_ptr 0 +#define __itt_mark_globalW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_global_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Creates an "end" point for "continuous" mark with specified name. + * + * - Returns zero value in case of success, non-zero value otherwise. + * Also returns non-zero value when preceding "begin" point for the + * mark with the same name failed to be created or not created. + * - The mark of "continuous" type is placed to collection results in + * case of success. It appears in overtime view(s) as a special tick + * sign (different from "discrete" mark) together with line from + * corresponding "begin" mark to "end" mark. + * @note Continuous marks can overlap and be nested inside each other. + * Discrete mark can be nested inside marked region + * @param[in] mt - mark, created by __itt_mark_create(const char* name) function + * @return Returns zero value in case of success, non-zero value otherwise. + */ +int ITTAPI __itt_mark_off(__itt_mark_type mt); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, int, mark_off, (__itt_mark_type mt)) +#define __itt_mark_off ITTNOTIFY_DATA(mark_off) +#define __itt_mark_off_ptr ITTNOTIFY_NAME(mark_off) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_mark_off(mt) (int)0 +#define __itt_mark_off_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_mark_off_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Use this if necessary to create an "end" point for mark of process + * @see int __itt_mark_off(__itt_mark_type mt); + */ +int ITTAPI __itt_mark_global_off(__itt_mark_type mt); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, int, mark_global_off, (__itt_mark_type mt)) +#define __itt_mark_global_off ITTNOTIFY_DATA(mark_global_off) +#define __itt_mark_global_off_ptr ITTNOTIFY_NAME(mark_global_off) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_mark_global_off(mt) (int)0 +#define __itt_mark_global_off_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_mark_global_off_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} marks group */ + +/** + * @defgroup counters_internal Counters + * @ingroup internal + * Counters group + * @{ + */ + + +/** + * @defgroup stitch Stack Stitching + * @ingroup internal + * Stack Stitching group + * @{ + */ +/** + * @brief opaque structure for counter identification + */ +typedef struct ___itt_caller *__itt_caller; + +/** + * @brief Create the stitch point e.g. a point in call stack where other stacks should be stitched to. + * The function returns a unique identifier which is used to match the cut points with corresponding stitch points. + */ +__itt_caller ITTAPI __itt_stack_caller_create(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_caller, stack_caller_create, (void)) +#define __itt_stack_caller_create ITTNOTIFY_DATA(stack_caller_create) +#define __itt_stack_caller_create_ptr ITTNOTIFY_NAME(stack_caller_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_caller_create() (__itt_caller)0 +#define __itt_stack_caller_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_caller_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Destroy the inforamtion about stitch point identified by the pointer previously returned by __itt_stack_caller_create() + */ +void ITTAPI __itt_stack_caller_destroy(__itt_caller id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, stack_caller_destroy, (__itt_caller id)) +#define __itt_stack_caller_destroy ITTNOTIFY_VOID(stack_caller_destroy) +#define __itt_stack_caller_destroy_ptr ITTNOTIFY_NAME(stack_caller_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_caller_destroy(id) +#define __itt_stack_caller_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_caller_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Sets the cut point. Stack from each event which occurs after this call will be cut + * at the same stack level the function was called and stitched to the corresponding stitch point. + */ +void ITTAPI __itt_stack_callee_enter(__itt_caller id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, stack_callee_enter, (__itt_caller id)) +#define __itt_stack_callee_enter ITTNOTIFY_VOID(stack_callee_enter) +#define __itt_stack_callee_enter_ptr ITTNOTIFY_NAME(stack_callee_enter) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_callee_enter(id) +#define __itt_stack_callee_enter_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_callee_enter_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief This function eliminates the cut point which was set by latest __itt_stack_callee_enter(). + */ +void ITTAPI __itt_stack_callee_leave(__itt_caller id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, stack_callee_leave, (__itt_caller id)) +#define __itt_stack_callee_leave ITTNOTIFY_VOID(stack_callee_leave) +#define __itt_stack_callee_leave_ptr ITTNOTIFY_NAME(stack_callee_leave) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_callee_leave(id) +#define __itt_stack_callee_leave_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_callee_leave_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} stitch group */ + +/* ***************************************************************************************************************************** */ + +#include + +/** @cond exclude_from_documentation */ +typedef enum __itt_error_code +{ + __itt_error_success = 0, /*!< no error */ + __itt_error_no_module = 1, /*!< module can't be loaded */ + /* %1$s -- library name; win: %2$d -- system error code; unx: %2$s -- system error message. */ + __itt_error_no_symbol = 2, /*!< symbol not found */ + /* %1$s -- library name, %2$s -- symbol name. */ + __itt_error_unknown_group = 3, /*!< unknown group specified */ + /* %1$s -- env var name, %2$s -- group name. */ + __itt_error_cant_read_env = 4, /*!< GetEnvironmentVariable() failed */ + /* %1$s -- env var name, %2$d -- system error. */ + __itt_error_env_too_long = 5, /*!< variable value too long */ + /* %1$s -- env var name, %2$d -- actual length of the var, %3$d -- max allowed length. */ + __itt_error_system = 6 /*!< pthread_mutexattr_init or pthread_mutex_init failed */ + /* %1$s -- function name, %2$d -- errno. */ +} __itt_error_code; + +typedef void (__itt_error_handler_t)(__itt_error_code code, va_list); +__itt_error_handler_t* __itt_set_error_handler(__itt_error_handler_t*); + +const char* ITTAPI __itt_api_version(void); +/** @endcond */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#define __itt_error_handler ITT_JOIN(INTEL_ITTNOTIFY_PREFIX, error_handler) +void __itt_error_handler(__itt_error_code code, va_list args); +extern const int ITTNOTIFY_NAME(err); +#define __itt_err ITTNOTIFY_NAME(err) +ITT_STUB(ITTAPI, const char*, api_version, (void)) +#define __itt_api_version ITTNOTIFY_DATA(api_version) +#define __itt_api_version_ptr ITTNOTIFY_NAME(api_version) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_api_version() (const char*)0 +#define __itt_api_version_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_api_version_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _ITTNOTIFY_PRIVATE_ */ + +#endif /* INTEL_ITTNOTIFY_API_PRIVATE */ diff --git a/external/vtune/linux/include/jitprofiling.h b/external/vtune/linux/include/jitprofiling.h new file mode 100644 index 0000000000..ef6557b4f2 --- /dev/null +++ b/external/vtune/linux/include/jitprofiling.h @@ -0,0 +1,694 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __JITPROFILING_H__ +#define __JITPROFILING_H__ + +/** + * @brief JIT Profiling APIs + * + * The JIT Profiling API is used to report information about just-in-time + * generated code that can be used by performance tools. The user inserts + * calls in the code generator to report information before JIT-compiled + * code goes to execution. This information is collected at runtime and used + * by tools like Intel(R) VTune(TM) Amplifier to display performance metrics + * associated with JIT-compiled code. + * + * These APIs can be used to\n + * - **Profile trace-based and method-based JIT-compiled + * code**. Some examples of environments that you can profile with these APIs: + * dynamic JIT compilation of JavaScript code traces, JIT execution in OpenCL(TM) + * software technology, Java/.NET managed execution environments, and custom + * ISV JIT engines. + * @code + * #include + * + * if (iJIT_IsProfilingActive != iJIT_SAMPLING_ON) { + * return; + * } + * + * iJIT_Method_Load jmethod = {0}; + * jmethod.method_id = iJIT_GetNewMethodID(); + * jmethod.method_name = "method_name"; + * jmethod.class_file_name = "class_name"; + * jmethod.source_file_name = "source_file_name"; + * jmethod.method_load_address = code_addr; + * jmethod.method_size = code_size; + * + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL); + * @endcode + * + * * Expected behavior: + * * If any iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an + * already reported method, then such a method becomes invalid and its + * memory region is treated as unloaded. VTune Amplifier displays the metrics + * collected by the method until it is overwritten. + * * If supplied line number information contains multiple source lines for + * the same assembly instruction (code location), then VTune Amplifier picks up + * the first line number. + * * Dynamically generated code can be associated with a module name. + * Use the iJIT_Method_Load_V2 structure.\n + * Clarification of some cases: + * * If you register a function with the same method ID multiple times, + * specifying different module names, then the VTune Amplifier picks up + * the module name registered first. If you want to distinguish the same + * function between different JIT engines, supply different method IDs for + * each function. Other symbolic information (for example, source file) + * can be identical. + * + * - **Analyze split functions** (multiple joint or disjoint code regions + * belonging to the same function) **including re-JIT** + * with potential overlapping of code regions in time, which is common in + * resource-limited environments. + * @code + * #include + * + * unsigned int method_id = iJIT_GetNewMethodID(); + * + * iJIT_Method_Load a = {0}; + * a.method_id = method_id; + * a.method_load_address = 0x100; + * a.method_size = 0x20; + * + * iJIT_Method_Load b = {0}; + * b.method_id = method_id; + * b.method_load_address = 0x200; + * b.method_size = 0x30; + * + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&b); + * @endcode + * + * * Expected behaviour: + * * If a iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an + * already reported method, then such a method becomes invalid and + * its memory region is treated as unloaded. + * * All code regions reported with the same method ID are considered as + * belonging to the same method. Symbolic information (method name, + * source file name) will be taken from the first notification, and all + * subsequent notifications with the same method ID will be processed + * only for line number table information. So, the VTune Amplifier will map + * samples to a source line using the line number table from the current + * notification while taking the source file name from the very first one.\n + * Clarification of some cases:\n + * * If you register a second code region with a different source file + * name and the same method ID, then this information will be saved and + * will not be considered as an extension of the first code region, but + * VTune Amplifier will use the source file of the first code region and map + * performance metrics incorrectly. + * * If you register a second code region with the same source file as + * for the first region and the same method ID, then the source file will be + * discarded but VTune Amplifier will map metrics to the source file correctly. + * * If you register a second code region with a null source file and + * the same method ID, then provided line number info will be associated + * with the source file of the first code region. + * + * - **Explore inline functions** including multi-level hierarchy of + * nested inline methods which shows how performance metrics are distributed through them. + * @code + * #include + * + * // method_id parent_id + * // [-- c --] 3000 2000 + * // [---- d -----] 2001 1000 + * // [---- b ----] 2000 1000 + * // [------------ a ----------------] 1000 n/a + * + * iJIT_Method_Load a = {0}; + * a.method_id = 1000; + * + * iJIT_Method_Inline_Load b = {0}; + * b.method_id = 2000; + * b.parent_method_id = 1000; + * + * iJIT_Method_Inline_Load c = {0}; + * c.method_id = 3000; + * c.parent_method_id = 2000; + * + * iJIT_Method_Inline_Load d = {0}; + * d.method_id = 2001; + * d.parent_method_id = 1000; + * + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&b); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&c); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&d); + * @endcode + * + * * Requirements: + * * Each inline (iJIT_Method_Inline_Load) method should be associated + * with two method IDs: one for itself; one for its immediate parent. + * * Address regions of inline methods of the same parent method cannot + * overlap each other. + * * Execution of the parent method must not be started until it and all + * its inline methods are reported. + * * Expected behaviour: + * * In case of nested inline methods an order of + * iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED events is not important. + * * If any event overwrites either inline method or top parent method, + * then the parent, including inline methods, becomes invalid and its memory + * region is treated as unloaded. + * + * **Life time of allocated data**\n + * The client sends an event notification to the agent with event-specific + * data, which is a structure. The pointers in the structure refer to memory + * allocated by the client, which responsible for releasing it. The pointers are + * used by the iJIT_NotifyEvent method to copy client's data in a trace file, + * and they are not used after the iJIT_NotifyEvent method returns. + */ + +/** + * @defgroup jitapi JIT Profiling + * @ingroup internal + * @{ + */ + +/** + * @brief Enumerator for the types of notifications + */ +typedef enum iJIT_jvm_event +{ + iJVM_EVENT_TYPE_SHUTDOWN = 2, /**<\brief Send this to shutdown the agent. + * Use NULL for event data. */ + + iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED = 13, /**<\brief Send when dynamic code is + * JIT compiled and loaded into + * memory by the JIT engine, but + * before the code is executed. + * Use iJIT_Method_Load as event + * data. */ +/** @cond exclude_from_documentation */ + iJVM_EVENT_TYPE_METHOD_UNLOAD_START, /**<\brief Send when compiled dynamic + * code is being unloaded from memory. + * Use iJIT_Method_Load as event data.*/ +/** @endcond */ + + iJVM_EVENT_TYPE_METHOD_UPDATE, /**<\brief Send to provide new content for + * a previously reported dynamic code. + * The previous content will be invalidated + * starting from the time of the notification. + * Use iJIT_Method_Load as event data but + * required fields are following: + * - method_id identify the code to update. + * - method_load_address specify start address + * within identified code range + * where update should be started. + * - method_size specify length of updated code + * range. */ + + + iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, /**<\brief Send when an inline dynamic + * code is JIT compiled and loaded + * into memory by the JIT engine, + * but before the parent code region + * starts executing. + * Use iJIT_Method_Inline_Load as event data.*/ + +/** @cond exclude_from_documentation */ + iJVM_EVENT_TYPE_METHOD_UPDATE_V2, +/** @endcond */ + + iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 = 21, /**<\brief Send when a dynamic code is + * JIT compiled and loaded into + * memory by the JIT engine, but + * before the code is executed. + * Use iJIT_Method_Load_V2 as event data. */ + + iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 /**<\brief Send when a dynamic code is + * JIT compiled and loaded into + * memory by the JIT engine, but + * before the code is executed. + * Use iJIT_Method_Load_V3 as event data. */ +} iJIT_JVM_EVENT; + +/** + * @brief Enumerator for the agent's mode + */ +typedef enum _iJIT_IsProfilingActiveFlags +{ + iJIT_NOTHING_RUNNING = 0x0000, /**<\brief The agent is not running; + * iJIT_NotifyEvent calls will + * not be processed. */ + iJIT_SAMPLING_ON = 0x0001, /**<\brief The agent is running and + * ready to process notifications. */ +} iJIT_IsProfilingActiveFlags; + +/** + * @brief Description of a single entry in the line number information of a code region. + * @details A table of line number entries gives information about how the reported code region + * is mapped to source file. + * Intel(R) VTune(TM) Amplifier uses line number information to attribute + * the samples (virtual address) to a line number. \n + * It is acceptable to report different code addresses for the same source line: + * @code + * Offset LineNumber + * 1 2 + * 12 4 + * 15 2 + * 18 1 + * 21 30 + * + * VTune Amplifier constructs the following table using the client data + * + * Code subrange Line number + * 0-1 2 + * 1-12 4 + * 12-15 2 + * 15-18 1 + * 18-21 30 + * @endcode + */ +typedef struct _LineNumberInfo +{ + unsigned int Offset; /**<\brief Offset from the begining of the code region. */ + unsigned int LineNumber; /**<\brief Matching source line number offset (from beginning of source file). */ + +} *pLineNumberInfo, LineNumberInfo; + +/** + * @brief Enumerator for the code architecture. + */ +typedef enum _iJIT_CodeArchitecture +{ + iJIT_CA_NATIVE = 0, /**<\brief Native to the process architecture that is calling it. */ + + iJIT_CA_32, /**<\brief 32-bit machine code. */ + + iJIT_CA_64 /**<\brief 64-bit machine code. */ + +} iJIT_CodeArchitecture; + +#pragma pack(push, 8) + +/** + * @brief Description of a JIT-compiled method + * @details When you use the iJIT_Method_Load structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED + * as an event type to report it. + */ +typedef struct _iJIT_Method_Load +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself.\n + * You must use the same method ID for all code + * regions of the same method, otherwise different + * method IDs specify different methods. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Can't be NULL. */ + + void* method_load_address; /**<\brief The start virtual address of the method code + * region. If NULL, data provided with + * event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table.0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array */ + + unsigned int class_id; /**<\brief This field is obsolete. */ + + char* class_file_name; /**<\brief Class name. Can be NULL.*/ + + char* source_file_name; /**<\brief Source file name. Can be NULL.*/ + +} *piJIT_Method_Load, iJIT_Method_Load; + +/** + * @brief Description of a JIT-compiled method + * @details When you use the iJIT_Method_Load_V2 structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 + * as an event type to report it. + */ +typedef struct _iJIT_Method_Load_V2 +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself.\n + * You must use the same method ID for all code + * regions of the same method, otherwise different + * method IDs specify different methods. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Can't be NULL. */ + + void* method_load_address; /**<\brief The start virtual address of the method code + * region. If NULL, then data provided with the + * event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table. 0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array. */ + + char* class_file_name; /**<\brief Class name. Can be NULL. */ + + char* source_file_name; /**<\brief Source file name. Can be NULL. */ + + char* module_name; /**<\brief Module name. Can be NULL. + The module name can be useful for distinguishing among + different JIT engines. VTune Amplifier will display + reported methods grouped by specific module. */ + +} *piJIT_Method_Load_V2, iJIT_Method_Load_V2; + +/** + * @brief Description of a JIT-compiled method + * @details The iJIT_Method_Load_V3 structure is the same as iJIT_Method_Load_V2 + * with a newly introduced 'arch' field that specifies architecture of the code region. + * When you use the iJIT_Method_Load_V3 structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 + * as an event type to report it. + */ +typedef struct _iJIT_Method_Load_V3 +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or manage ID uniqueness + * and correct range by yourself.\n + * You must use the same method ID for all code + * regions of the same method, otherwise they are + * treated as regions of different methods. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Cannot be NULL. */ + + void* method_load_address; /**<\brief The start virtual address of the method code + * region. If NULL, then data provided with the + * event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table. 0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array. */ + + char* class_file_name; /**<\brief Class name. Can be NULL. */ + + char* source_file_name; /**<\brief Source file name. Can be NULL. */ + + char* module_name; /**<\brief Module name. Can be NULL. + * The module name can be useful for distinguishing among + * different JIT engines. VTune Amplifier will display + * reported methods grouped by specific module. */ + + iJIT_CodeArchitecture module_arch; /**<\brief Architecture of the method's code region. + * By default, it is the same as the process + * architecture that is calling it. + * For example, you can use it if your 32-bit JIT + * engine generates 64-bit code. + * + * If JIT engine reports both 32-bit and 64-bit types + * of methods then VTune Amplifier splits the methods + * with the same module name but with different + * architectures in two different modules. VTune Amplifier + * modifies the original name provided with a 64-bit method + * version by ending it with '(64)' */ + +} *piJIT_Method_Load_V3, iJIT_Method_Load_V3; + +/** + * @brief Description of an inline JIT-compiled method + * @details When you use the_iJIT_Method_Inline_Load structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED + * as an event type to report it. + */ +typedef struct _iJIT_Method_Inline_Load +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself. */ + + unsigned int parent_method_id; /**<\brief Unique immediate parent's method ID. + * Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Can't be NULL. */ + + void* method_load_address; /** <\brief The virtual address on which the method + * is inlined. If NULL, then data provided with + * the event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table. 0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array */ + + char* class_file_name; /**<\brief Class name. Can be NULL.*/ + + char* source_file_name; /**<\brief Source file name. Can be NULL.*/ + +} *piJIT_Method_Inline_Load, iJIT_Method_Inline_Load; + +/** @cond exclude_from_documentation */ +/** + * @brief Description of a segment type + * @details Use the segment type to specify a type of data supplied + * with the iJVM_EVENT_TYPE_METHOD_UPDATE_V2 event to be applied to + * a certain code trace. + */ +typedef enum _iJIT_SegmentType +{ + iJIT_CT_UNKNOWN = 0, + + iJIT_CT_CODE, /**<\brief Executable code. */ + + iJIT_CT_DATA, /**<\brief Data (not executable code). + * VTune Amplifier uses the format string + * (see iJIT_Method_Update) to represent + * this data in the VTune Amplifier GUI */ + + iJIT_CT_KEEP, /**<\brief Use the previous markup for the trace. + * Can be used for the following + * iJVM_EVENT_TYPE_METHOD_UPDATE_V2 events, + * if the type of the previously reported segment + * type is the same. */ + iJIT_CT_EOF +} iJIT_SegmentType; + +/** + * @brief Description of a dynamic update of the content within JIT-compiled method + * @details The JIT engine may generate the methods that are updated at runtime + * partially by mixed (data + executable code) content. When you use the iJIT_Method_Update + * structure to describe the update of the content within a JIT-compiled method, + * use iJVM_EVENT_TYPE_METHOD_UPDATE_V2 as an event type to report it. + * + * On the first Update event, VTune Amplifier copies the original code range reported by + * the iJVM_EVENT_TYPE_METHOD_LOAD event, then modifies it with the supplied bytes and + * adds the modified range to the original method. For next update events, VTune Amplifier + * does the same but it uses the latest modified version of a code region for update. + * Eventually, VTune Amplifier GUI displays multiple code ranges for the method reported by + * the iJVM_EVENT_TYPE_METHOD_LOAD event. + * Notes: + * - Multiple update events with different types for the same trace are allowed + * but they must be reported for the same code ranges. + * Example, + * @code + * [-- data---] Allowed + * [-- code --] Allowed + * [code] Ignored + * [-- data---] Allowed + * [-- code --] Allowed + * [------------ trace ---------] + * @endcode + * - The types of previously reported events can be changed but they must be reported + * for the same code ranges. + * Example, + * @code + * [-- data---] Allowed + * [-- code --] Allowed + * [-- data---] Allowed + * [-- code --] Allowed + * [------------ trace ---------] + * @endcode + */ + +typedef struct _iJIT_Method_Update +{ + void* load_address; /**<\brief Start address of the update within a method */ + + unsigned int size; /**<\brief The update size */ + + iJIT_SegmentType type; /**<\brief Type of the update */ + + const char* data_format; /**<\brief C string that contains a format string + * that follows the same specifications as format in printf. + * The format string is used for iJIT_CT_CODE only + * and cannot be NULL. + * Format can be changed on the fly. */ +} *piJIT_Method_Update, iJIT_Method_Update; + +/** @endcond */ + +#pragma pack(pop) + +/** @cond exclude_from_documentation */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef CDECL +# if defined WIN32 || defined _WIN32 +# define CDECL __cdecl +# else /* defined WIN32 || defined _WIN32 */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86_64 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* defined WIN32 || defined _WIN32 */ +#endif /* CDECL */ + +#define JITAPI CDECL +/** @endcond */ + +/** + * @brief Generates a new unique method ID. + * + * You must use this API to obtain unique and valid method IDs for methods or + * traces reported to the agent if you don't have your own mechanism to generate + * unique method IDs. + * + * @return a new unique method ID. When out of unique method IDs, this API + * returns 0, which is not an accepted value. + */ +unsigned int JITAPI iJIT_GetNewMethodID(void); + +/** + * @brief Returns the current mode of the agent. + * + * @return iJIT_SAMPLING_ON, indicating that agent is running, or + * iJIT_NOTHING_RUNNING if no agent is running. + */ +iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void); + +/** + * @brief Reports infomation about JIT-compiled code to the agent. + * + * The reported information is used to attribute samples obtained from any + * Intel(R) VTune(TM) Amplifier collector. This API needs to be called + * after JIT compilation and before the first entry into the JIT-compiled + * code. + * + * @param[in] event_type - type of the data sent to the agent + * @param[in] EventSpecificData - pointer to event-specific data + * + * @returns 1 on success, otherwise 0. + */ +int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @endcond */ + +/** @} jitapi group */ + +#endif /* __JITPROFILING_H__ */ diff --git a/external/vtune/linux/include/legacy/ittnotify.h b/external/vtune/linux/include/legacy/ittnotify.h new file mode 100644 index 0000000000..b40a5f9244 --- /dev/null +++ b/external/vtune/linux/include/legacy/ittnotify.h @@ -0,0 +1,1039 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _LEGACY_ITTNOTIFY_H_ +#define _LEGACY_ITTNOTIFY_H_ + +/** + * @file + * @brief Legacy User API functions and types + */ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup legacy Legacy API + * @{ + * @} + */ + +/** + * @defgroup legacy_control Collection Control + * @ingroup legacy + * General behavior: application continues to run, but no profiling information is being collected + * + * Pausing occurs not only for the current thread but for all process as well as spawned processes + * - Intel(R) Parallel Inspector and Intel(R) Inspector XE: + * - Does not analyze or report errors that involve memory access. + * - Other errors are reported as usual. Pausing data collection in + * Intel(R) Parallel Inspector and Intel(R) Inspector XE + * only pauses tracing and analyzing memory access. + * It does not pause tracing or analyzing threading APIs. + * . + * - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE: + * - Does continue to record when new threads are started. + * . + * - Other effects: + * - Possible reduction of runtime overhead. + * . + * @{ + */ +#ifndef _ITTNOTIFY_H_ +/** @brief Pause collection */ +void ITTAPI __itt_pause(void); +/** @brief Resume collection */ +void ITTAPI __itt_resume(void); +/** @brief Detach collection */ +void ITTAPI __itt_detach(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, pause, (void)) +ITT_STUBV(ITTAPI, void, resume, (void)) +ITT_STUBV(ITTAPI, void, detach, (void)) +#define __itt_pause ITTNOTIFY_VOID(pause) +#define __itt_pause_ptr ITTNOTIFY_NAME(pause) +#define __itt_resume ITTNOTIFY_VOID(resume) +#define __itt_resume_ptr ITTNOTIFY_NAME(resume) +#define __itt_detach ITTNOTIFY_VOID(detach) +#define __itt_detach_ptr ITTNOTIFY_NAME(detach) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_pause() +#define __itt_pause_ptr 0 +#define __itt_resume() +#define __itt_resume_ptr 0 +#define __itt_detach() +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_pause_ptr 0 +#define __itt_resume_ptr 0 +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +#endif /* _ITTNOTIFY_H_ */ +/** @} legacy_control group */ + +/** + * @defgroup legacy_threads Threads + * @ingroup legacy + * Threads group + * @warning Legacy API + * @{ + */ +/** + * @deprecated Legacy API + * @brief Set name to be associated with thread in analysis GUI. + * @return __itt_err upon failure (name or namelen being null,name and namelen mismatched) + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int LIBITTAPI __itt_thr_name_setA(const char *name, int namelen); +int LIBITTAPI __itt_thr_name_setW(const wchar_t *name, int namelen); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_thr_name_set __itt_thr_name_setW +# define __itt_thr_name_set_ptr __itt_thr_name_setW_ptr +#else +# define __itt_thr_name_set __itt_thr_name_setA +# define __itt_thr_name_set_ptr __itt_thr_name_setA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int LIBITTAPI __itt_thr_name_set(const char *name, int namelen); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, thr_name_setA, (const char *name, int namelen)) +ITT_STUB(LIBITTAPI, int, thr_name_setW, (const wchar_t *name, int namelen)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, thr_name_set, (const char *name, int namelen)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thr_name_setA ITTNOTIFY_DATA(thr_name_setA) +#define __itt_thr_name_setA_ptr ITTNOTIFY_NAME(thr_name_setA) +#define __itt_thr_name_setW ITTNOTIFY_DATA(thr_name_setW) +#define __itt_thr_name_setW_ptr ITTNOTIFY_NAME(thr_name_setW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thr_name_set ITTNOTIFY_DATA(thr_name_set) +#define __itt_thr_name_set_ptr ITTNOTIFY_NAME(thr_name_set) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thr_name_setA(name, namelen) +#define __itt_thr_name_setA_ptr 0 +#define __itt_thr_name_setW(name, namelen) +#define __itt_thr_name_setW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thr_name_set(name, namelen) +#define __itt_thr_name_set_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thr_name_setA_ptr 0 +#define __itt_thr_name_setW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thr_name_set_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Mark current thread as ignored from this point on, for the duration of its existence. + */ +void LIBITTAPI __itt_thr_ignore(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, thr_ignore, (void)) +#define __itt_thr_ignore ITTNOTIFY_VOID(thr_ignore) +#define __itt_thr_ignore_ptr ITTNOTIFY_NAME(thr_ignore) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_thr_ignore() +#define __itt_thr_ignore_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_thr_ignore_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_threads group */ + +/** + * @defgroup legacy_sync Synchronization + * @ingroup legacy + * Synchronization group + * @warning Legacy API + * @{ + */ +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_barrier 1 + +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_mutex 2 + +/** + * @deprecated Legacy API + * @brief Assign a name to a sync object using char or Unicode string + * @param[in] addr - pointer to the sync object. You should use a real pointer to your object + * to make sure that the values don't clash with other object addresses + * @param[in] objtype - null-terminated object type string. If NULL is passed, the object will + * be assumed to be of generic "User Synchronization" type + * @param[in] objname - null-terminated object name string. If NULL, no name will be assigned + * to the object -- you can use the __itt_sync_rename call later to assign + * the name + * @param[in] attribute - one of [#__itt_attr_barrier, #__itt_attr_mutex] values which defines the + * exact semantics of how prepare/acquired/releasing calls work. + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_sync_set_nameA(void *addr, const char *objtype, const char *objname, int attribute); +void ITTAPI __itt_sync_set_nameW(void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_sync_set_name __itt_sync_set_nameW +# define __itt_sync_set_name_ptr __itt_sync_set_nameW_ptr +#else /* UNICODE */ +# define __itt_sync_set_name __itt_sync_set_nameA +# define __itt_sync_set_name_ptr __itt_sync_set_nameA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_sync_set_name(void *addr, const char* objtype, const char* objname, int attribute); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_set_nameA, (void *addr, const char *objtype, const char *objname, int attribute)) +ITT_STUBV(ITTAPI, void, sync_set_nameW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_set_name, (void *addr, const char *objtype, const char *objname, int attribute)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_set_nameA ITTNOTIFY_VOID(sync_set_nameA) +#define __itt_sync_set_nameA_ptr ITTNOTIFY_NAME(sync_set_nameA) +#define __itt_sync_set_nameW ITTNOTIFY_VOID(sync_set_nameW) +#define __itt_sync_set_nameW_ptr ITTNOTIFY_NAME(sync_set_nameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_set_name ITTNOTIFY_VOID(sync_set_name) +#define __itt_sync_set_name_ptr ITTNOTIFY_NAME(sync_set_name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_set_nameA(addr, objtype, objname, attribute) +#define __itt_sync_set_nameA_ptr 0 +#define __itt_sync_set_nameW(addr, objtype, objname, attribute) +#define __itt_sync_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_set_name(addr, objtype, objname, attribute) +#define __itt_sync_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_set_nameA_ptr 0 +#define __itt_sync_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Assign a name and type to a sync object using char or Unicode string + * @param[in] addr - pointer to the sync object. You should use a real pointer to your object + * to make sure that the values don't clash with other object addresses + * @param[in] objtype - null-terminated object type string. If NULL is passed, the object will + * be assumed to be of generic "User Synchronization" type + * @param[in] objname - null-terminated object name string. If NULL, no name will be assigned + * to the object -- you can use the __itt_sync_rename call later to assign + * the name + * @param[in] typelen, namelen - a length of string for appropriate objtype and objname parameter + * @param[in] attribute - one of [#__itt_attr_barrier, #__itt_attr_mutex] values which defines the + * exact semantics of how prepare/acquired/releasing calls work. + * @return __itt_err upon failure (name or namelen being null,name and namelen mismatched) + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int LIBITTAPI __itt_notify_sync_nameA(void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute); +int LIBITTAPI __itt_notify_sync_nameW(void *addr, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_notify_sync_name __itt_notify_sync_nameW +#else +# define __itt_notify_sync_name __itt_notify_sync_nameA +#endif +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int LIBITTAPI __itt_notify_sync_name(void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, notify_sync_nameA, (void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute)) +ITT_STUB(LIBITTAPI, int, notify_sync_nameW, (void *addr, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, notify_sync_name, (void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_notify_sync_nameA ITTNOTIFY_DATA(notify_sync_nameA) +#define __itt_notify_sync_nameA_ptr ITTNOTIFY_NAME(notify_sync_nameA) +#define __itt_notify_sync_nameW ITTNOTIFY_DATA(notify_sync_nameW) +#define __itt_notify_sync_nameW_ptr ITTNOTIFY_NAME(notify_sync_nameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_notify_sync_name ITTNOTIFY_DATA(notify_sync_name) +#define __itt_notify_sync_name_ptr ITTNOTIFY_NAME(notify_sync_name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_notify_sync_nameA(addr, objtype, typelen, objname, namelen, attribute) +#define __itt_notify_sync_nameA_ptr 0 +#define __itt_notify_sync_nameW(addr, objtype, typelen, objname, namelen, attribute) +#define __itt_notify_sync_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_notify_sync_name(addr, objtype, typelen, objname, namelen, attribute) +#define __itt_notify_sync_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_notify_sync_nameA_ptr 0 +#define __itt_notify_sync_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_notify_sync_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Enter spin loop on user-defined sync object + */ +void LIBITTAPI __itt_notify_sync_prepare(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_prepare, (void *addr)) +#define __itt_notify_sync_prepare ITTNOTIFY_VOID(notify_sync_prepare) +#define __itt_notify_sync_prepare_ptr ITTNOTIFY_NAME(notify_sync_prepare) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_prepare(addr) +#define __itt_notify_sync_prepare_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_prepare_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Quit spin loop without acquiring spin object + */ +void LIBITTAPI __itt_notify_sync_cancel(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_cancel, (void *addr)) +#define __itt_notify_sync_cancel ITTNOTIFY_VOID(notify_sync_cancel) +#define __itt_notify_sync_cancel_ptr ITTNOTIFY_NAME(notify_sync_cancel) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_cancel(addr) +#define __itt_notify_sync_cancel_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_cancel_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Successful spin loop completion (sync object acquired) + */ +void LIBITTAPI __itt_notify_sync_acquired(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_acquired, (void *addr)) +#define __itt_notify_sync_acquired ITTNOTIFY_VOID(notify_sync_acquired) +#define __itt_notify_sync_acquired_ptr ITTNOTIFY_NAME(notify_sync_acquired) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_acquired(addr) +#define __itt_notify_sync_acquired_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_acquired_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Start sync object releasing code. Is called before the lock release call. + */ +void LIBITTAPI __itt_notify_sync_releasing(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_releasing, (void *addr)) +#define __itt_notify_sync_releasing ITTNOTIFY_VOID(notify_sync_releasing) +#define __itt_notify_sync_releasing_ptr ITTNOTIFY_NAME(notify_sync_releasing) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_releasing(addr) +#define __itt_notify_sync_releasing_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_releasing_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_sync group */ + +#ifndef _ITTNOTIFY_H_ +/** + * @defgroup legacy_events Events + * @ingroup legacy + * Events group + * @{ + */ + +/** @brief user event type */ +typedef int __itt_event; + +/** + * @brief Create an event notification + * @note name or namelen being null/name and namelen not matching, user event feature not enabled + * @return non-zero event identifier upon success and __itt_err otherwise + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_event LIBITTAPI __itt_event_createA(const char *name, int namelen); +__itt_event LIBITTAPI __itt_event_createW(const wchar_t *name, int namelen); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_event_create __itt_event_createW +# define __itt_event_create_ptr __itt_event_createW_ptr +#else +# define __itt_event_create __itt_event_createA +# define __itt_event_create_ptr __itt_event_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_event LIBITTAPI __itt_event_create(const char *name, int namelen); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen)) +ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA ITTNOTIFY_DATA(event_createA) +#define __itt_event_createA_ptr ITTNOTIFY_NAME(event_createA) +#define __itt_event_createW ITTNOTIFY_DATA(event_createW) +#define __itt_event_createW_ptr ITTNOTIFY_NAME(event_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create ITTNOTIFY_DATA(event_create) +#define __itt_event_create_ptr ITTNOTIFY_NAME(event_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA(name, namelen) (__itt_event)0 +#define __itt_event_createA_ptr 0 +#define __itt_event_createW(name, namelen) (__itt_event)0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create(name, namelen) (__itt_event)0 +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA_ptr 0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event occurrence. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_start(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event)) +#define __itt_event_start ITTNOTIFY_DATA(event_start) +#define __itt_event_start_ptr ITTNOTIFY_NAME(event_start) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_start(event) (int)0 +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event end occurrence. + * @note It is optional if events do not have durations. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_end(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event)) +#define __itt_event_end ITTNOTIFY_DATA(event_end) +#define __itt_event_end_ptr ITTNOTIFY_NAME(event_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_end(event) (int)0 +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_events group */ +#endif /* _ITTNOTIFY_H_ */ + +/** + * @defgroup legacy_memory Memory Accesses + * @ingroup legacy + */ + +/** + * @deprecated Legacy API + * @brief Inform the tool of memory accesses on reading + */ +void LIBITTAPI __itt_memory_read(void *addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, memory_read, (void *addr, size_t size)) +#define __itt_memory_read ITTNOTIFY_VOID(memory_read) +#define __itt_memory_read_ptr ITTNOTIFY_NAME(memory_read) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_memory_read(addr, size) +#define __itt_memory_read_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_memory_read_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Inform the tool of memory accesses on writing + */ +void LIBITTAPI __itt_memory_write(void *addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, memory_write, (void *addr, size_t size)) +#define __itt_memory_write ITTNOTIFY_VOID(memory_write) +#define __itt_memory_write_ptr ITTNOTIFY_NAME(memory_write) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_memory_write(addr, size) +#define __itt_memory_write_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_memory_write_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Inform the tool of memory accesses on updating + */ +void LIBITTAPI __itt_memory_update(void *address, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, memory_update, (void *addr, size_t size)) +#define __itt_memory_update ITTNOTIFY_VOID(memory_update) +#define __itt_memory_update_ptr ITTNOTIFY_NAME(memory_update) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_memory_update(addr, size) +#define __itt_memory_update_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_memory_update_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_memory group */ + +/** + * @defgroup legacy_state Thread and Object States + * @ingroup legacy + */ + +/** @brief state type */ +typedef int __itt_state_t; + +/** @cond exclude_from_documentation */ +typedef enum __itt_obj_state { + __itt_obj_state_err = 0, + __itt_obj_state_clr = 1, + __itt_obj_state_set = 2, + __itt_obj_state_use = 3 +} __itt_obj_state_t; + +typedef enum __itt_thr_state { + __itt_thr_state_err = 0, + __itt_thr_state_clr = 1, + __itt_thr_state_set = 2 +} __itt_thr_state_t; + +typedef enum __itt_obj_prop { + __itt_obj_prop_watch = 1, + __itt_obj_prop_ignore = 2, + __itt_obj_prop_sharable = 3 +} __itt_obj_prop_t; + +typedef enum __itt_thr_prop { + __itt_thr_prop_quiet = 1 +} __itt_thr_prop_t; +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object states + */ +__itt_state_t LIBITTAPI __itt_state_get(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_state_t, state_get, (void)) +#define __itt_state_get ITTNOTIFY_DATA(state_get) +#define __itt_state_get_ptr ITTNOTIFY_NAME(state_get) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_state_get(void) (__itt_state_t)0 +#define __itt_state_get_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_state_get_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object states + */ +__itt_state_t LIBITTAPI __itt_state_set(__itt_state_t s); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_state_t, state_set, (__itt_state_t s)) +#define __itt_state_set ITTNOTIFY_DATA(state_set) +#define __itt_state_set_ptr ITTNOTIFY_NAME(state_set) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_state_set(s) (__itt_state_t)0 +#define __itt_state_set_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_state_set_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object modes + */ +__itt_thr_state_t LIBITTAPI __itt_thr_mode_set(__itt_thr_prop_t p, __itt_thr_state_t s); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_thr_state_t, thr_mode_set, (__itt_thr_prop_t p, __itt_thr_state_t s)) +#define __itt_thr_mode_set ITTNOTIFY_DATA(thr_mode_set) +#define __itt_thr_mode_set_ptr ITTNOTIFY_NAME(thr_mode_set) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_thr_mode_set(p, s) (__itt_thr_state_t)0 +#define __itt_thr_mode_set_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_thr_mode_set_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object modes + */ +__itt_obj_state_t LIBITTAPI __itt_obj_mode_set(__itt_obj_prop_t p, __itt_obj_state_t s); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_obj_state_t, obj_mode_set, (__itt_obj_prop_t p, __itt_obj_state_t s)) +#define __itt_obj_mode_set ITTNOTIFY_DATA(obj_mode_set) +#define __itt_obj_mode_set_ptr ITTNOTIFY_NAME(obj_mode_set) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_obj_mode_set(p, s) (__itt_obj_state_t)0 +#define __itt_obj_mode_set_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_obj_mode_set_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_state group */ + +/** + * @defgroup frames Frames + * @ingroup legacy + * Frames group + * @{ + */ +/** + * @brief opaque structure for frame identification + */ +typedef struct __itt_frame_t *__itt_frame; + +/** + * @brief Create a global frame with given domain + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_frame ITTAPI __itt_frame_createA(const char *domain); +__itt_frame ITTAPI __itt_frame_createW(const wchar_t *domain); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_frame_create __itt_frame_createW +# define __itt_frame_create_ptr __itt_frame_createW_ptr +#else /* UNICODE */ +# define __itt_frame_create __itt_frame_createA +# define __itt_frame_create_ptr __itt_frame_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_frame ITTAPI __itt_frame_create(const char *domain); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_frame, frame_createA, (const char *domain)) +ITT_STUB(ITTAPI, __itt_frame, frame_createW, (const wchar_t *domain)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_frame_createA ITTNOTIFY_DATA(frame_createA) +#define __itt_frame_createA_ptr ITTNOTIFY_NAME(frame_createA) +#define __itt_frame_createW ITTNOTIFY_DATA(frame_createW) +#define __itt_frame_createW_ptr ITTNOTIFY_NAME(frame_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_frame_create ITTNOTIFY_DATA(frame_create) +#define __itt_frame_create_ptr ITTNOTIFY_NAME(frame_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_frame_createA(domain) +#define __itt_frame_createA_ptr 0 +#define __itt_frame_createW(domain) +#define __itt_frame_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_frame_create(domain) +#define __itt_frame_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_frame_createA_ptr 0 +#define __itt_frame_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_frame_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief Record an frame begin occurrence. */ +void ITTAPI __itt_frame_begin(__itt_frame frame); +/** @brief Record an frame end occurrence. */ +void ITTAPI __itt_frame_end (__itt_frame frame); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, frame_begin, (__itt_frame frame)) +ITT_STUBV(ITTAPI, void, frame_end, (__itt_frame frame)) +#define __itt_frame_begin ITTNOTIFY_VOID(frame_begin) +#define __itt_frame_begin_ptr ITTNOTIFY_NAME(frame_begin) +#define __itt_frame_end ITTNOTIFY_VOID(frame_end) +#define __itt_frame_end_ptr ITTNOTIFY_NAME(frame_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_frame_begin(frame) +#define __itt_frame_begin_ptr 0 +#define __itt_frame_end(frame) +#define __itt_frame_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_frame_begin_ptr 0 +#define __itt_frame_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} frames group */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LEGACY_ITTNOTIFY_H_ */ diff --git a/external/vtune/linux/include/libittnotify.h b/external/vtune/linux/include/libittnotify.h new file mode 100644 index 0000000000..15d8056a9d --- /dev/null +++ b/external/vtune/linux/include/libittnotify.h @@ -0,0 +1,71 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LIBITTNOTIFY_H_ +#define _LIBITTNOTIFY_H_ + +#ifndef __ITT_INTERNAL_INCLUDE +# if defined WIN32 || defined _WIN32 +# pragma message("WARNING!!! Include file libittnotify.h is deprecated and should not be included anymore") +# else /* WIN32 */ +# warning "Include file libittnotify.h is deprecated and should not be included anymore" +# endif /* WIN32 */ +#endif /* __ITT_INTERNAL_INCLUDE */ +#include "legacy/ittnotify.h" + +#endif /* _LIBITTNOTIFY_H_ */ diff --git a/external/vtune/linux/include/llvm_jit_event_listener.hpp b/external/vtune/linux/include/llvm_jit_event_listener.hpp new file mode 100644 index 0000000000..2d1ca7fc43 --- /dev/null +++ b/external/vtune/linux/include/llvm_jit_event_listener.hpp @@ -0,0 +1,241 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This file implements an interface bridge from Low-Level Virtual Machine + * llvm::JITEventListener to Intel JIT Profiling API. It passes the function + * and line information to the appropriate functions in the JIT profiling + * interface so that any LLVM-based JIT engine can emit the JIT code + * notifications that the profiler will receive. + * + * Usage model: + * + * 1. Register the listener implementation instance with the execution engine: + * + * #include + * ... + * ExecutionEngine *TheExecutionEngine; + * ... + * TheExecutionEngine = EngineBuilder(TheModule).create(); + * ... + * __itt_llvm_jit_event_listener jitListener; + * TheExecutionEngine->RegisterJITEventListener(&jitListener); + * ... + * + * 2. When compiling make sure to add the ITT API include directory to the + * compiler include directories, ITT API library directory to the linker + * library directories and link with jitprofling static library. + */ + +#ifndef __ITT_LLVM_JIT_EVENT_LISTENER_HPP__ +#define __ITT_LLVM_JIT_EVENT_LISTENER_HPP__ + +#include "jitprofiling.h" + +#include +#include +#include +#include + +#include +#include + +// Uncomment the line below to turn on logging to stderr +#define JITPROFILING_DEBUG_ENABLE + +// Some elementary logging support +#ifdef JITPROFILING_DEBUG_ENABLE +#include +#include +static void _jit_debug(const char* format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); +} +// Use the macro as JITDEBUG(("foo: %d", foo_val)); +#define JITDEBUG(x) \ + do { \ + _jit_debug("jit-listener: "); \ + _jit_debug x; \ + } \ + while (0) +#else +#define JITDEBUG(x) +#endif + +// LLVM JIT event listener, translates the notifications to the JIT profiling +// API information. +class __itt_llvm_jit_event_listener : public llvm::JITEventListener +{ +public: + __itt_llvm_jit_event_listener() {} + +public: + virtual void NotifyFunctionEmitted(const llvm::Function &F, + void *Code, size_t Size, const EmittedFunctionDetails &Details) + { + std::string name = F.getName().str(); + JITDEBUG(("function jitted:\n")); + JITDEBUG((" addr=0x%08x\n", (int)Code)); + JITDEBUG((" name=`%s'\n", name.c_str())); + JITDEBUG((" code-size=%d\n", (int)Size)); + JITDEBUG((" line-infos-count=%d\n", Details.LineStarts.size())); + + // The method must not be in the map - the entry must have been cleared + // from the map in NotifyFreeingMachineCode in case of rejitting. + assert(m_addr2MethodId.find(Code) == m_addr2MethodId.end()); + + int mid = iJIT_GetNewMethodID(); + m_addr2MethodId[Code] = mid; + + iJIT_Method_Load mload; + memset(&mload, 0, sizeof mload); + mload.method_id = mid; + + // Populate the method size and name information + // TODO: The JIT profiling API should have members as const char pointers. + mload.method_name = (char*)name.c_str(); + mload.method_load_address = Code; + mload.method_size = (unsigned int)Size; + + // Populate line information now. + // From the JIT API documentation it is not quite clear whether the + // line information can be given in ranges, so we'll populate it for + // every byte of the function, hmm. + std::string srcFilePath; + std::vector lineInfos; + char *addr = (char*)Code; + char *lineAddr = addr; // Exclusive end point at which current + // line info changes. + const llvm::DebugLoc* loc = 0; // Current line info + int lineIndex = -1; // Current index into the line info table + for (int i = 0; i < Size; ++i, ++addr) { + while (addr >= lineAddr) { + if (lineIndex >= 0 && lineIndex < Details.LineStarts.size()) { + loc = &Details.LineStarts[lineIndex].Loc; + std::string p = getSrcFilePath(F.getContext(), *loc); + assert(srcFilePath.empty() || p == srcFilePath); + srcFilePath = p; + } else { + loc = NULL; + } + lineIndex++; + if (lineIndex >= 0 && lineIndex < Details.LineStarts.size()) { + lineAddr = (char*)Details.LineStarts[lineIndex].Address; + } else { + lineAddr = addr + Size; + } + } + if (loc) { + int line = loc->getLine(); + LineNumberInfo info = { i, line }; + lineInfos.push_back(info); + JITDEBUG((" addr 0x%08x -> line %d\n", addr, line)); + } + } + if (!lineInfos.empty()) { + mload.line_number_size = lineInfos.size(); + JITDEBUG((" translated to %d line infos to JIT", (int)lineInfos.size())); + mload.line_number_table = &lineInfos[0]; + mload.source_file_name = (char*)srcFilePath.c_str(); + } + + iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &mload); + } + + virtual void NotifyFreeingMachineCode(void *OldPtr) + { + JITDEBUG(("function unjitted\n")); + JITDEBUG((" addr=0x%08x\n", (int)OldPtr)); + Addr2MethodId::iterator it = m_addr2MethodId.find(OldPtr); + assert(it != m_addr2MethodId.end()); + iJIT_Method_Id mid = { it->second }; + iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_UNLOAD_START, &mid); + m_addr2MethodId.erase(it); + } + +private: + std::string getSrcFilePath(const llvm::LLVMContext& ctx, const llvm::DebugLoc& loc) + { + llvm::MDNode* node = loc.getAsMDNode(ctx); + llvm::DILocation srcLoc(node); + return srcLoc.getDirectory().str() + "/" + srcLoc.getFilename().str(); + } + +private: + /// Don't copy + __itt_llvm_jit_event_listener(const __itt_llvm_jit_event_listener&); + __itt_llvm_jit_event_listener& operator=(const __itt_llvm_jit_event_listener&); + +private: + typedef std::vector LineInfoList; + + // The method unload notification in VTune JIT profiling API takes the + // method ID, not method address so have to maintain the mapping. Is + // there a more efficient and simple way to do this like attaching the + // method ID information somehow to the LLVM function instance? + // + // TODO: It would be more convenient for the JIT API to take the method + // address, not method ID. + typedef std::map Addr2MethodId; + Addr2MethodId m_addr2MethodId; +}; + +#endif // Header guard diff --git a/external/vtune/linux/include/prototype/ittnotify.h b/external/vtune/linux/include/prototype/ittnotify.h new file mode 100644 index 0000000000..85aabe5806 --- /dev/null +++ b/external/vtune/linux/include/prototype/ittnotify.h @@ -0,0 +1,263 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _PROTOTYPE_ITTNOTIFY_H_ +#define _PROTOTYPE_ITTNOTIFY_H_ + +/** + * @file + * @brief Prototype User API functions and types + */ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup prototype Prototype API + * @{ + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _PROTOTYPE_ITTNOTIFY_H_ */ diff --git a/external/vtune/linux/sdk/src/ittnotify/LICENSE.BSD b/external/vtune/linux/sdk/src/ittnotify/LICENSE.BSD new file mode 100644 index 0000000000..7beafe5ce9 --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/LICENSE.BSD @@ -0,0 +1,7 @@ +Copyright (c) 2011, Intel Corporation +All rights reserved. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +• Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/external/vtune/linux/sdk/src/ittnotify/LICENSE.GPL b/external/vtune/linux/sdk/src/ittnotify/LICENSE.GPL new file mode 100644 index 0000000000..efe910f4f0 --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/LICENSE.GPL @@ -0,0 +1,65 @@ +The GNU General Public License (GPL) +Version 2, June 1991 +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +Preamble +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. +NO WARRANTY +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. +One line to give the program's name and a brief idea of what it does. +Copyright (C) +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 +Also add information on how to contact you by electronic and paper mail. +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: +Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: +Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. +signature of Ty Coon, 1 April 1989 +Ty Coon, President of Vice +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. diff --git a/external/vtune/linux/sdk/src/ittnotify/Makefile b/external/vtune/linux/sdk/src/ittnotify/Makefile new file mode 100644 index 0000000000..adb8b1ecad --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/Makefile @@ -0,0 +1,17 @@ +OBJ := ittnotify_static.o jitprofiling.o + +LIBNAME := libittnotify.a + +INCLUDE += -I ../../../include + +CFLAGS += $(INCLUDE) -fPIC + +.PHONY: all +all: $(LIBNAME) + +$(LIBNAME): $(OBJ) + $(AR) rcs $@ $^ + +.PHONY: clean +clean: + @$(RM) $(LIBNAME) $(OBJ) diff --git a/external/vtune/linux/sdk/src/ittnotify/disable_warnings.h b/external/vtune/linux/sdk/src/ittnotify/disable_warnings.h new file mode 100644 index 0000000000..4210f86bfd --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/disable_warnings.h @@ -0,0 +1,77 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ittnotify_config.h" + +#if ITT_PLATFORM==ITT_PLATFORM_WIN + +#pragma warning (disable: 593) /* parameter "XXXX" was set but never used */ +#pragma warning (disable: 344) /* typedef name has already been declared (with same type) */ +#pragma warning (disable: 174) /* expression has no effect */ +#pragma warning (disable: 4127) /* conditional expression is constant */ +#pragma warning (disable: 4306) /* conversion from '?' to '?' of greater size */ + +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if defined __INTEL_COMPILER + +#pragma warning (disable: 869) /* parameter "XXXXX" was never referenced */ +#pragma warning (disable: 1418) /* external function definition with no prior declaration */ +#pragma warning (disable: 1419) /* external declaration in primary source file */ + +#endif /* __INTEL_COMPILER */ diff --git a/external/vtune/linux/sdk/src/ittnotify/ittnotify_config.h b/external/vtune/linux/sdk/src/ittnotify/ittnotify_config.h new file mode 100644 index 0000000000..2489297bd3 --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/ittnotify_config.h @@ -0,0 +1,541 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _ITTNOTIFY_CONFIG_H_ +#define _ITTNOTIFY_CONFIG_H_ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +#ifndef ITT_ARCH_IA32 +# define ITT_ARCH_IA32 1 +#endif /* ITT_ARCH_IA32 */ + +#ifndef ITT_ARCH_IA32E +# define ITT_ARCH_IA32E 2 +#endif /* ITT_ARCH_IA32E */ + +#ifndef ITT_ARCH_ARM +# define ITT_ARCH_ARM 4 +#endif /* ITT_ARCH_ARM */ + +#ifndef ITT_ARCH_PPC64 +# define ITT_ARCH_PPC64 5 +#endif /* ITT_ARCH_PPC64 */ + +#ifndef ITT_ARCH +# if defined _M_IX86 || defined __i386__ +# define ITT_ARCH ITT_ARCH_IA32 +# elif defined _M_X64 || defined _M_AMD64 || defined __x86_64__ +# define ITT_ARCH ITT_ARCH_IA32E +# elif defined _M_IA64 || defined __ia64__ +# define ITT_ARCH ITT_ARCH_IA64 +# elif defined _M_ARM || defined __arm__ +# define ITT_ARCH ITT_ARCH_ARM +# elif defined __powerpc64__ +# define ITT_ARCH ITT_ARCH_PPC64 +# endif +#endif + +#ifdef __cplusplus +# define ITT_EXTERN_C extern "C" +# define ITT_EXTERN_C_BEGIN extern "C" { +# define ITT_EXTERN_C_END } +#else +# define ITT_EXTERN_C /* nothing */ +# define ITT_EXTERN_C_BEGIN /* nothing */ +# define ITT_EXTERN_C_END /* nothing */ +#endif /* __cplusplus */ + +#define ITT_TO_STR_AUX(x) #x +#define ITT_TO_STR(x) ITT_TO_STR_AUX(x) + +#define __ITT_BUILD_ASSERT(expr, suffix) do { \ + static char __itt_build_check_##suffix[(expr) ? 1 : -1]; \ + __itt_build_check_##suffix[0] = 0; \ +} while(0) +#define _ITT_BUILD_ASSERT(expr, suffix) __ITT_BUILD_ASSERT((expr), suffix) +#define ITT_BUILD_ASSERT(expr) _ITT_BUILD_ASSERT((expr), __LINE__) + +#define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 } + +/* Replace with snapshot date YYYYMMDD for promotion build. */ +#define API_VERSION_BUILD 20111111 + +#ifndef API_VERSION_NUM +#define API_VERSION_NUM 0.0.0 +#endif /* API_VERSION_NUM */ + +#define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \ + " (" ITT_TO_STR(API_VERSION_BUILD) ")" + +/* OS communication functions */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +typedef HMODULE lib_t; +typedef DWORD TIDT; +typedef CRITICAL_SECTION mutex_t; +#define MUTEX_INITIALIZER { 0 } +#define strong_alias(name, aliasname) /* empty for Windows */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */ +#endif /* _GNU_SOURCE */ +#ifndef __USE_UNIX98 +#define __USE_UNIX98 1 /* need for PTHREAD_MUTEX_RECURSIVE, on SLES11.1 with gcc 4.3.4 wherein pthread.h missing dependency on __USE_XOPEN2K8 */ +#endif /*__USE_UNIX98*/ +#include +typedef void* lib_t; +typedef pthread_t TIDT; +typedef pthread_mutex_t mutex_t; +#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); +#define strong_alias(name, aliasname) _strong_alias(name, aliasname) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_get_proc(lib, name) GetProcAddress(lib, name) +#define __itt_mutex_init(mutex) InitializeCriticalSection(mutex) +#define __itt_mutex_lock(mutex) EnterCriticalSection(mutex) +#define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex) +#define __itt_load_lib(name) LoadLibraryA(name) +#define __itt_unload_lib(handle) FreeLibrary(handle) +#define __itt_system_error() (int)GetLastError() +#define __itt_fstrcmp(s1, s2) lstrcmpA(s1, s2) +#define __itt_fstrnlen(s, l) strnlen_s(s, l) +#define __itt_fstrcpyn(s1, b, s2, l) strncpy_s(s1, b, s2, l) +#define __itt_fstrdup(s) _strdup(s) +#define __itt_thread_id() GetCurrentThreadId() +#define __itt_thread_yield() SwitchToThread() +#ifndef ITT_SIMPLE_INIT +ITT_INLINE long +__itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; +ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) +{ + return InterlockedIncrement(ptr); +} +#endif /* ITT_SIMPLE_INIT */ +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +#define __itt_get_proc(lib, name) dlsym(lib, name) +#define __itt_mutex_init(mutex) {\ + pthread_mutexattr_t mutex_attr; \ + int error_code = pthread_mutexattr_init(&mutex_attr); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutexattr_init", \ + error_code); \ + error_code = pthread_mutexattr_settype(&mutex_attr, \ + PTHREAD_MUTEX_RECURSIVE); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", \ + error_code); \ + error_code = pthread_mutex_init(mutex, &mutex_attr); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutex_init", \ + error_code); \ + error_code = pthread_mutexattr_destroy(&mutex_attr); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", \ + error_code); \ +} +#define __itt_mutex_lock(mutex) pthread_mutex_lock(mutex) +#define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex) +#define __itt_load_lib(name) dlopen(name, RTLD_LAZY) +#define __itt_unload_lib(handle) dlclose(handle) +#define __itt_system_error() errno +#define __itt_fstrcmp(s1, s2) strcmp(s1, s2) + +/* makes customer code define safe APIs for SDL_STRNLEN_S and SDL_STRNCPY_S */ +#ifdef SDL_STRNLEN_S +#define __itt_fstrnlen(s, l) SDL_STRNLEN_S(s, l) +#else +#define __itt_fstrnlen(s, l) strlen(s) +#endif /* SDL_STRNLEN_S */ +#ifdef SDL_STRNCPY_S +#define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l) +#else +#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, l) +#endif /* SDL_STRNCPY_S */ + +#define __itt_fstrdup(s) strdup(s) +#define __itt_thread_id() pthread_self() +#define __itt_thread_yield() sched_yield() +//#if ITT_ARCH==ITT_ARCH_IA64 +#if defined(ITT_ARCH_IA64) && ITT_ARCH==ITT_ARCH_IA64 +#ifdef __INTEL_COMPILER +#define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val) +#else /* __INTEL_COMPILER */ +/* TODO: Add Support for not Intel compilers for IA-64 architecture */ +#endif /* __INTEL_COMPILER */ +#elif ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_IA32E /* ITT_ARCH!=ITT_ARCH_IA64 */ +ITT_INLINE long +__TBB_machine_fetchadd4(volatile void* ptr, long addend) ITT_INLINE_ATTRIBUTE; +ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend) +{ + long result; + __asm__ __volatile__("lock\nxadd %0,%1" + : "=r"(result),"=m"(*(int*)ptr) + : "0"(addend), "m"(*(int*)ptr) + : "memory"); + return result; +} +#elif ITT_ARCH==ITT_ARCH_ARM || ITT_ARCH==ITT_ARCH_PPC64 +#define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val) +#endif /* ITT_ARCH==ITT_ARCH_IA64 */ +#ifndef ITT_SIMPLE_INIT +ITT_INLINE long +__itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; +ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) +{ + return __TBB_machine_fetchadd4(ptr, 1) + 1L; +} +#endif /* ITT_SIMPLE_INIT */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +typedef enum { + __itt_collection_normal = 0, + __itt_collection_paused = 1 +} __itt_collection_state; + +typedef enum { + __itt_thread_normal = 0, + __itt_thread_ignored = 1 +} __itt_thread_state; + +#pragma pack(push, 8) + +typedef struct ___itt_thread_info +{ + const char* nameA; /*!< Copy of original name in ASCII. */ +#if defined(UNICODE) || defined(_UNICODE) + const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ +#else /* UNICODE || _UNICODE */ + void* nameW; +#endif /* UNICODE || _UNICODE */ + TIDT tid; + __itt_thread_state state; /*!< Thread state (paused or normal) */ + int extra1; /*!< Reserved to the runtime */ + void* extra2; /*!< Reserved to the runtime */ + struct ___itt_thread_info* next; +} __itt_thread_info; + +#include "ittnotify_types.h" /* For __itt_group_id definition */ + +typedef struct ___itt_api_info_20101001 +{ + const char* name; + void** func_ptr; + void* init_func; + __itt_group_id group; +} __itt_api_info_20101001; + +typedef struct ___itt_api_info +{ + const char* name; + void** func_ptr; + void* init_func; + void* null_func; + __itt_group_id group; +} __itt_api_info; + +struct ___itt_domain; +struct ___itt_string_handle; + +typedef struct ___itt_global +{ + unsigned char magic[8]; + unsigned long version_major; + unsigned long version_minor; + unsigned long version_build; + volatile long api_initialized; + volatile long mutex_initialized; + volatile long atomic_counter; + mutex_t mutex; + lib_t lib; + void* error_handler; + const char** dll_path_ptr; + __itt_api_info* api_list_ptr; + struct ___itt_global* next; + /* Joinable structures below */ + __itt_thread_info* thread_list; + struct ___itt_domain* domain_list; + struct ___itt_string_handle* string_list; + __itt_collection_state state; +} __itt_global; + +#pragma pack(pop) + +#define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \ + h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ + if (h != NULL) { \ + h->tid = t; \ + h->nameA = NULL; \ + h->nameW = n ? _wcsdup(n) : NULL; \ + h->state = s; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->thread_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \ + h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ + if (h != NULL) { \ + h->tid = t; \ + h->nameA = n ? __itt_fstrdup(n) : NULL; \ + h->nameW = NULL; \ + h->state = s; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->thread_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_DOMAIN_W(gptr,h,h_tail,name) { \ + h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ + if (h != NULL) { \ + h->flags = 1; /* domain is enabled by default */ \ + h->nameA = NULL; \ + h->nameW = name ? _wcsdup(name) : NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->domain_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_DOMAIN_A(gptr,h,h_tail,name) { \ + h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ + if (h != NULL) { \ + h->flags = 1; /* domain is enabled by default */ \ + h->nameA = name ? __itt_fstrdup(name) : NULL; \ + h->nameW = NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->domain_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \ + h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ + if (h != NULL) { \ + h->strA = NULL; \ + h->strW = name ? _wcsdup(name) : NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->string_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \ + h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ + if (h != NULL) { \ + h->strA = name ? __itt_fstrdup(name) : NULL; \ + h->strW = NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->string_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#endif /* _ITTNOTIFY_CONFIG_H_ */ diff --git a/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.c b/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.c new file mode 100644 index 0000000000..9303895a27 --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.c @@ -0,0 +1,1080 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ittnotify_config.h" + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define PATH_MAX 512 +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +#include +#include +#include +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#include +#include +#include + +#define INTEL_NO_MACRO_BODY +#define INTEL_ITTNOTIFY_API_PRIVATE +#include "ittnotify.h" +#include "legacy/ittnotify.h" + +#include "disable_warnings.h" + +static const char api_version[] = API_VERSION "\0\n@(#) $Revision: 422936 $\n"; + +#define _N_(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) + +#if ITT_OS==ITT_OS_WIN +static const char* ittnotify_lib_name = "libittnotify.dll"; +#elif ITT_OS==ITT_OS_LINUX || ITT_OS==ITT_OS_FREEBSD +static const char* ittnotify_lib_name = "libittnotify.so"; +#elif ITT_OS==ITT_OS_MAC +static const char* ittnotify_lib_name = "libittnotify.dylib"; +#else +#error Unsupported or unknown OS. +#endif + +#ifdef __ANDROID__ +#include +#include +#include +#include +#include +#include +#include + +#ifdef ITT_ANDROID_LOG + #define ITT_ANDROID_LOG_TAG "INTEL_VTUNE_USERAPI" + #define ITT_ANDROID_LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ITT_ANDROID_LOG_TAG, __VA_ARGS__)) + #define ITT_ANDROID_LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ITT_ANDROID_LOG_TAG, __VA_ARGS__)) + #define ITT_ANDROID_LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR,ITT_ANDROID_LOG_TAG, __VA_ARGS__)) + #define ITT_ANDROID_LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG,ITT_ANDROID_LOG_TAG, __VA_ARGS__)) +#else + #define ITT_ANDROID_LOGI(...) + #define ITT_ANDROID_LOGW(...) + #define ITT_ANDROID_LOGE(...) + #define ITT_ANDROID_LOGD(...) +#endif + +/* default location of userapi collector on Android */ +#define ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(x) "/data/data/com.intel.vtune/perfrun/lib" \ + #x "/runtime/libittnotify.so" + +#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM +#define ANDROID_ITTNOTIFY_DEFAULT_PATH ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(32) +#else +#define ANDROID_ITTNOTIFY_DEFAULT_PATH ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(64) +#endif + +#endif + + +#ifndef LIB_VAR_NAME +#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM +#define LIB_VAR_NAME INTEL_LIBITTNOTIFY32 +#else +#define LIB_VAR_NAME INTEL_LIBITTNOTIFY64 +#endif +#endif /* LIB_VAR_NAME */ + +#define ITT_MUTEX_INIT_AND_LOCK(p) { \ + if (!p.mutex_initialized) \ + { \ + if (__itt_interlocked_increment(&p.atomic_counter) == 1) \ + { \ + __itt_mutex_init(&p.mutex); \ + p.mutex_initialized = 1; \ + } \ + else \ + while (!p.mutex_initialized) \ + __itt_thread_yield(); \ + } \ + __itt_mutex_lock(&p.mutex); \ +} + +const int _N_(err) = 0; + +typedef int (__itt_init_ittlib_t)(const char*, __itt_group_id); + +/* this define used to control initialization function name. */ +#ifndef __itt_init_ittlib_name +ITT_EXTERN_C int _N_(init_ittlib)(const char*, __itt_group_id); +static __itt_init_ittlib_t* __itt_init_ittlib_ptr = _N_(init_ittlib); +#define __itt_init_ittlib_name __itt_init_ittlib_ptr +#endif /* __itt_init_ittlib_name */ + +typedef void (__itt_fini_ittlib_t)(void); + +/* this define used to control finalization function name. */ +#ifndef __itt_fini_ittlib_name +ITT_EXTERN_C void _N_(fini_ittlib)(void); +static __itt_fini_ittlib_t* __itt_fini_ittlib_ptr = _N_(fini_ittlib); +#define __itt_fini_ittlib_name __itt_fini_ittlib_ptr +#endif /* __itt_fini_ittlib_name */ + +/* building pointers to imported funcs */ +#undef ITT_STUBV +#undef ITT_STUB +#define ITT_STUB(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args \ +{ \ + __itt_init_ittlib_name(NULL, __itt_group_all); \ + if (ITTNOTIFY_NAME(name) && ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init))) \ + return ITTNOTIFY_NAME(name) params; \ + else \ + return (type)0; \ +} + +#define ITT_STUBV(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args \ +{ \ + __itt_init_ittlib_name(NULL, __itt_group_all); \ + if (ITTNOTIFY_NAME(name) && ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init))) \ + ITTNOTIFY_NAME(name) params; \ + else \ + return; \ +} + +#undef __ITT_INTERNAL_INIT +#include "ittnotify_static.h" + +#undef ITT_STUB +#undef ITT_STUBV +#define ITT_STUB(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END + +#define ITT_STUBV(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END + +#define __ITT_INTERNAL_INIT +#include "ittnotify_static.h" +#undef __ITT_INTERNAL_INIT + +ITT_GROUP_LIST(group_list); + +#pragma pack(push, 8) + +typedef struct ___itt_group_alias +{ + const char* env_var; + __itt_group_id groups; +} __itt_group_alias; + +static __itt_group_alias group_alias[] = { + { "KMP_FOR_TPROFILE", (__itt_group_id)(__itt_group_control | __itt_group_thread | __itt_group_sync | __itt_group_mark) }, + { "KMP_FOR_TCHECK", (__itt_group_id)(__itt_group_control | __itt_group_thread | __itt_group_sync | __itt_group_fsync | __itt_group_mark | __itt_group_suppress) }, + { NULL, (__itt_group_none) }, + { api_version, (__itt_group_none) } /* !!! Just to avoid unused code elimination !!! */ +}; + +#pragma pack(pop) + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(push) +#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static __itt_api_info api_list[] = { +/* Define functions with static implementation */ +#undef ITT_STUB +#undef ITT_STUBV +#define ITT_STUB(api,type,name,args,params,nameindll,group,format) { ITT_TO_STR(ITT_JOIN(__itt_,nameindll)), (void**)(void*)&ITTNOTIFY_NAME(name), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), (__itt_group_id)(group)}, +#define ITT_STUBV ITT_STUB +#define __ITT_INTERNAL_INIT +#include "ittnotify_static.h" +#undef __ITT_INTERNAL_INIT +/* Define functions without static implementation */ +#undef ITT_STUB +#undef ITT_STUBV +#define ITT_STUB(api,type,name,args,params,nameindll,group,format) {ITT_TO_STR(ITT_JOIN(__itt_,nameindll)), (void**)(void*)&ITTNOTIFY_NAME(name), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), NULL, (__itt_group_id)(group)}, +#define ITT_STUBV ITT_STUB +#include "ittnotify_static.h" + {NULL, NULL, NULL, NULL, __itt_group_none} +}; + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(pop) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static const char dll_path[PATH_MAX] = { 0 }; + +/* static part descriptor which handles. all notification api attributes. */ +__itt_global _N_(_ittapi_global) = { + ITT_MAGIC, /* identification info */ + ITT_MAJOR, ITT_MINOR, API_VERSION_BUILD, /* version info */ + 0, /* api_initialized */ + 0, /* mutex_initialized */ + 0, /* atomic_counter */ + MUTEX_INITIALIZER, /* mutex */ + NULL, /* dynamic library handle */ + NULL, /* error_handler */ + (const char**)&dll_path, /* dll_path_ptr */ + (__itt_api_info*)&api_list, /* api_list_ptr */ + NULL, /* next __itt_global */ + NULL, /* thread_list */ + NULL, /* domain_list */ + NULL, /* string_list */ + __itt_collection_normal /* collection state */ +}; + +ITT_EXTERN_C __itt_global* _N_(get_ittapi_global)() { return &_N_(_ittapi_global); } +typedef void (__itt_api_init_t)(__itt_global*, __itt_group_id); +typedef void (__itt_api_fini_t)(__itt_global*); + +/* ========================================================================= */ + +#ifdef ITT_NOTIFY_EXT_REPORT +ITT_EXTERN_C void _N_(error_handler)(__itt_error_code, va_list args); +#endif /* ITT_NOTIFY_EXT_REPORT */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(push) +#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static void __itt_report_error(__itt_error_code code, ...) +{ + va_list args; + va_start(args, code); + if (_N_(_ittapi_global).error_handler != NULL) + { + __itt_error_handler_t* handler = (__itt_error_handler_t*)(size_t)_N_(_ittapi_global).error_handler; + handler(code, args); + } +#ifdef ITT_NOTIFY_EXT_REPORT + _N_(error_handler)(code, args); +#endif /* ITT_NOTIFY_EXT_REPORT */ + va_end(args); +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(pop) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createW),_init))(const wchar_t* name) +{ + __itt_domain *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { + if (ITTNOTIFY_NAME(domain_createW) && ITTNOTIFY_NAME(domain_createW) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createW),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(domain_createW)(name); + } + } + for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; h_tail = h, h = h->next) + { + if (h->nameW != NULL && !wcscmp(h->nameW, name)) break; + } + if (h == NULL) + { + NEW_DOMAIN_W(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createA),_init))(const char* name) +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_create),_init))(const char* name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +{ + __itt_domain *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + if (ITTNOTIFY_NAME(domain_createA) && ITTNOTIFY_NAME(domain_createA) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createA),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(domain_createA)(name); + } +#else + if (ITTNOTIFY_NAME(domain_create) && ITTNOTIFY_NAME(domain_create) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_create),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(domain_create)(name); + } +#endif + } + for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; h_tail = h, h = h->next) + { + if (h->nameA != NULL && !__itt_fstrcmp(h->nameA, name)) break; + } + if (h == NULL) + { + NEW_DOMAIN_A(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createW),_init))(const wchar_t* name) +{ + __itt_string_handle *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { + if (ITTNOTIFY_NAME(string_handle_createW) && ITTNOTIFY_NAME(string_handle_createW) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createW),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(string_handle_createW)(name); + } + } + for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; h_tail = h, h = h->next) + { + if (h->strW != NULL && !wcscmp(h->strW, name)) break; + } + if (h == NULL) + { + NEW_STRING_HANDLE_W(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createA),_init))(const char* name) +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_create),_init))(const char* name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +{ + __itt_string_handle *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + if (ITTNOTIFY_NAME(string_handle_createA) && ITTNOTIFY_NAME(string_handle_createA) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createA),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(string_handle_createA)(name); + } +#else + if (ITTNOTIFY_NAME(string_handle_create) && ITTNOTIFY_NAME(string_handle_create) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_create),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(string_handle_create)(name); + } +#endif + } + for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; h_tail = h, h = h->next) + { + if (h->strA != NULL && !__itt_fstrcmp(h->strA, name)) break; + } + if (h == NULL) + { + NEW_STRING_HANDLE_A(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +/* -------------------------------------------------------------------------- */ + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(pause),_init))(void) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(pause) && ITTNOTIFY_NAME(pause) != ITT_VERSIONIZE(ITT_JOIN(_N_(pause),_init))) + { + ITTNOTIFY_NAME(pause)(); + } + else + { + _N_(_ittapi_global).state = __itt_collection_paused; + } +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(resume),_init))(void) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(resume) && ITTNOTIFY_NAME(resume) != ITT_VERSIONIZE(ITT_JOIN(_N_(resume),_init))) + { + ITTNOTIFY_NAME(resume)(); + } + else + { + _N_(_ittapi_global).state = __itt_collection_normal; + } +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))(const wchar_t* name) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(thread_set_nameW) && ITTNOTIFY_NAME(thread_set_nameW) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))) + { + ITTNOTIFY_NAME(thread_set_nameW)(name); + } +} + +static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_setW),_init))(const wchar_t* name, int namelen) +{ + (void)namelen; + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))(name); + return 0; +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))(const char* name) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))(const char* name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } +#if ITT_PLATFORM==ITT_PLATFORM_WIN + if (ITTNOTIFY_NAME(thread_set_nameA) && ITTNOTIFY_NAME(thread_set_nameA) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))) + { + ITTNOTIFY_NAME(thread_set_nameA)(name); + } +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + if (ITTNOTIFY_NAME(thread_set_name) && ITTNOTIFY_NAME(thread_set_name) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))) + { + ITTNOTIFY_NAME(thread_set_name)(name); + } +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_setA),_init))(const char* name, int namelen) +{ + (void)namelen; + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))(name); + return 0; +} +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_set),_init))(const char* name, int namelen) +{ + (void)namelen; + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))(name); + return 0; +} +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))(void) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(thread_ignore) && ITTNOTIFY_NAME(thread_ignore) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))) + { + ITTNOTIFY_NAME(thread_ignore)(); + } +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_ignore),_init))(void) +{ + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))(); +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(enable_attach),_init))(void) +{ +#ifdef __ANDROID__ + /* + * if LIB_VAR_NAME env variable were set before then stay previous value + * else set default path + */ + setenv(ITT_TO_STR(LIB_VAR_NAME), ANDROID_ITTNOTIFY_DEFAULT_PATH, 0); +#endif +} + +/* -------------------------------------------------------------------------- */ + +static const char* __itt_fsplit(const char* s, const char* sep, const char** out, int* len) +{ + int i; + int j; + + if (!s || !sep || !out || !len) + return NULL; + + for (i = 0; s[i]; i++) + { + int b = 0; + for (j = 0; sep[j]; j++) + if (s[i] == sep[j]) + { + b = 1; + break; + } + if (!b) + break; + } + + if (!s[i]) + return NULL; + + *len = 0; + *out = &s[i]; + + for (; s[i]; i++, (*len)++) + { + int b = 0; + for (j = 0; sep[j]; j++) + if (s[i] == sep[j]) + { + b = 1; + break; + } + if (b) + break; + } + + for (; s[i]; i++) + { + int b = 0; + for (j = 0; sep[j]; j++) + if (s[i] == sep[j]) + { + b = 1; + break; + } + if (!b) + break; + } + + return &s[i]; +} + +/* This function return value of env variable that placed into static buffer. + * !!! The same static buffer is used for subsequent calls. !!! + * This was done to aviod dynamic allocation for few calls. + * Actually we need this function only four times. + */ +static const char* __itt_get_env_var(const char* name) +{ +#define MAX_ENV_VALUE_SIZE 4086 + static char env_buff[MAX_ENV_VALUE_SIZE]; + static char* env_value = (char*)env_buff; + + if (name != NULL) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + size_t max_len = MAX_ENV_VALUE_SIZE - (size_t)(env_value - env_buff); + DWORD rc = GetEnvironmentVariableA(name, env_value, (DWORD)max_len); + if (rc >= max_len) + __itt_report_error(__itt_error_env_too_long, name, (size_t)rc - 1, (size_t)(max_len - 1)); + else if (rc > 0) + { + const char* ret = (const char*)env_value; + env_value += rc + 1; + return ret; + } + else + { + /* If environment variable is empty, GetEnvirornmentVariables() + * returns zero (number of characters (not including terminating null), + * and GetLastError() returns ERROR_SUCCESS. */ + DWORD err = GetLastError(); + if (err == ERROR_SUCCESS) + return env_value; + + if (err != ERROR_ENVVAR_NOT_FOUND) + __itt_report_error(__itt_error_cant_read_env, name, (int)err); + } +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ + char* env = getenv(name); + if (env != NULL) + { + size_t len = __itt_fstrnlen(env, MAX_ENV_VALUE_SIZE); + size_t max_len = MAX_ENV_VALUE_SIZE - (size_t)(env_value - env_buff); + if (len < max_len) + { + const char* ret = (const char*)env_value; + __itt_fstrcpyn(env_value, max_len, env, len + 1); + env_value += len + 1; + return ret; + } else + __itt_report_error(__itt_error_env_too_long, name, (size_t)len, (size_t)(max_len - 1)); + } +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + } + return NULL; +} + +static const char* __itt_get_lib_name(void) +{ + const char* lib_name = __itt_get_env_var(ITT_TO_STR(LIB_VAR_NAME)); + +#ifdef __ANDROID__ + if (lib_name == NULL) + { + +#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM + const char* const marker_filename = "com.intel.itt.collector_lib_32"; +#else + const char* const marker_filename = "com.intel.itt.collector_lib_64"; +#endif + + char system_wide_marker_filename[PATH_MAX] = {0}; + int itt_marker_file_fd = -1; + ssize_t res = 0; + + res = snprintf(system_wide_marker_filename, PATH_MAX - 1, "%s%s", "/data/local/tmp/", marker_filename); + if (res < 0) + { + ITT_ANDROID_LOGE("Unable to concatenate marker file string."); + return lib_name; + } + itt_marker_file_fd = open(system_wide_marker_filename, O_RDONLY); + + if (itt_marker_file_fd == -1) + { + const pid_t my_pid = getpid(); + char cmdline_path[PATH_MAX] = {0}; + char package_name[PATH_MAX] = {0}; + char app_sandbox_file[PATH_MAX] = {0}; + int cmdline_fd = 0; + + ITT_ANDROID_LOGI("Unable to open system-wide marker file."); + res = snprintf(cmdline_path, PATH_MAX - 1, "/proc/%d/cmdline", my_pid); + if (res < 0) + { + ITT_ANDROID_LOGE("Unable to get cmdline path string."); + return lib_name; + } + + ITT_ANDROID_LOGI("CMD file: %s\n", cmdline_path); + cmdline_fd = open(cmdline_path, O_RDONLY); + if (cmdline_fd == -1) + { + ITT_ANDROID_LOGE("Unable to open %s file!", cmdline_path); + return lib_name; + } + res = read(cmdline_fd, package_name, PATH_MAX - 1); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to read %s file!", cmdline_path); + res = close(cmdline_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", cmdline_path); + } + return lib_name; + } + res = close(cmdline_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", cmdline_path); + return lib_name; + } + ITT_ANDROID_LOGI("Package name: %s\n", package_name); + res = snprintf(app_sandbox_file, PATH_MAX - 1, "/data/data/%s/%s", package_name, marker_filename); + if (res < 0) + { + ITT_ANDROID_LOGE("Unable to concatenate marker file string."); + return lib_name; + } + + ITT_ANDROID_LOGI("Lib marker file name: %s\n", app_sandbox_file); + itt_marker_file_fd = open(app_sandbox_file, O_RDONLY); + if (itt_marker_file_fd == -1) + { + ITT_ANDROID_LOGE("Unable to open app marker file!"); + return lib_name; + } + } + + { + char itt_lib_name[PATH_MAX] = {0}; + + res = read(itt_marker_file_fd, itt_lib_name, PATH_MAX - 1); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to read %s file!", itt_marker_file_fd); + res = close(itt_marker_file_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", itt_marker_file_fd); + } + return lib_name; + } + ITT_ANDROID_LOGI("ITT Lib path: %s", itt_lib_name); + res = close(itt_marker_file_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", itt_marker_file_fd); + return lib_name; + } + ITT_ANDROID_LOGI("Set env %s to %s", ITT_TO_STR(LIB_VAR_NAME), itt_lib_name); + res = setenv(ITT_TO_STR(LIB_VAR_NAME), itt_lib_name, 0); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to set env var!"); + return lib_name; + } + lib_name = __itt_get_env_var(ITT_TO_STR(LIB_VAR_NAME)); + ITT_ANDROID_LOGI("ITT Lib path from env: %s", lib_name); + } + } +#endif + + return lib_name; +} + +#ifndef min +#define min(a,b) (a) < (b) ? (a) : (b) +#endif /* min */ + +static __itt_group_id __itt_get_groups(void) +{ + register int i; + __itt_group_id res = __itt_group_none; + const char* var_name = "INTEL_ITTNOTIFY_GROUPS"; + const char* group_str = __itt_get_env_var(var_name); + + if (group_str != NULL) + { + int len; + char gr[255]; + const char* chunk; + while ((group_str = __itt_fsplit(group_str, ",; ", &chunk, &len)) != NULL) + { + int min_len = min(len, (int)(sizeof(gr) - 1)); + __itt_fstrcpyn(gr, sizeof(gr) - 1, chunk, min_len); + gr[min_len] = 0; + + for (i = 0; group_list[i].name != NULL; i++) + { + if (!__itt_fstrcmp(gr, group_list[i].name)) + { + res = (__itt_group_id)(res | group_list[i].id); + break; + } + } + } + /* TODO: !!! Workaround for bug with warning for unknown group !!! + * Should be fixed in new initialization scheme. + * Now the following groups should be set always. */ + for (i = 0; group_list[i].id != __itt_group_none; i++) + if (group_list[i].id != __itt_group_all && + group_list[i].id > __itt_group_splitter_min && + group_list[i].id < __itt_group_splitter_max) + res = (__itt_group_id)(res | group_list[i].id); + return res; + } + else + { + for (i = 0; group_alias[i].env_var != NULL; i++) + if (__itt_get_env_var(group_alias[i].env_var) != NULL) + return group_alias[i].groups; + } + + return res; +} + +static int __itt_lib_version(lib_t lib) +{ + if (lib == NULL) + return 0; + if (__itt_get_proc(lib, "__itt_api_init")) + return 2; + if (__itt_get_proc(lib, "__itt_api_version")) + return 1; + return 0; +} + +/* It's not used right now! Comment it out to avoid warnings. +static void __itt_reinit_all_pointers(void) +{ + register int i; + // Fill all pointers with initial stubs + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].init_func; +} +*/ + +static void __itt_nullify_all_pointers(void) +{ + register int i; + /* Nulify all pointers except domain_create and string_handle_create */ + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(push) +#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ +#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_EXTERN_C void _N_(fini_ittlib)(void) +{ + __itt_api_fini_t* __itt_api_fini_ptr = NULL; + static volatile TIDT current_thread = 0; + + if (_N_(_ittapi_global).api_initialized) + { + __itt_mutex_lock(&_N_(_ittapi_global).mutex); + if (_N_(_ittapi_global).api_initialized) + { + if (current_thread == 0) + { + current_thread = __itt_thread_id(); + if (_N_(_ittapi_global).lib != NULL) + { + __itt_api_fini_ptr = (__itt_api_fini_t*)(size_t)__itt_get_proc(_N_(_ittapi_global).lib, "__itt_api_fini"); + } + if (__itt_api_fini_ptr) + { + __itt_api_fini_ptr(&_N_(_ittapi_global)); + } + + __itt_nullify_all_pointers(); + + /* TODO: !!! not safe !!! don't support unload so far. + * if (_N_(_ittapi_global).lib != NULL) + * __itt_unload_lib(_N_(_ittapi_global).lib); + * _N_(_ittapi_global).lib = NULL; + */ + _N_(_ittapi_global).api_initialized = 0; + current_thread = 0; + } + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + } +} + +ITT_EXTERN_C int _N_(init_ittlib)(const char* lib_name, __itt_group_id init_groups) +{ + register int i; + __itt_group_id groups; +#ifdef ITT_COMPLETE_GROUP + __itt_group_id zero_group = __itt_group_none; +#endif /* ITT_COMPLETE_GROUP */ + static volatile TIDT current_thread = 0; + + if (!_N_(_ittapi_global).api_initialized) + { +#ifndef ITT_SIMPLE_INIT + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); +#endif /* ITT_SIMPLE_INIT */ + + if (!_N_(_ittapi_global).api_initialized) + { + if (current_thread == 0) + { + current_thread = __itt_thread_id(); + if (lib_name == NULL) + { + lib_name = __itt_get_lib_name(); + } + groups = __itt_get_groups(); + if (groups != __itt_group_none || lib_name != NULL) + { + _N_(_ittapi_global).lib = __itt_load_lib((lib_name == NULL) ? ittnotify_lib_name : lib_name); + + if (_N_(_ittapi_global).lib != NULL) + { + __itt_api_init_t* __itt_api_init_ptr; + int lib_version = __itt_lib_version(_N_(_ittapi_global).lib); + + switch (lib_version) { + case 0: + groups = __itt_group_legacy; + case 1: + /* Fill all pointers from dynamic library */ + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + { + if (_N_(_ittapi_global).api_list_ptr[i].group & groups & init_groups) + { + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = (void*)__itt_get_proc(_N_(_ittapi_global).lib, _N_(_ittapi_global).api_list_ptr[i].name); + if (*_N_(_ittapi_global).api_list_ptr[i].func_ptr == NULL) + { + /* Restore pointers for function with static implementation */ + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; + __itt_report_error(__itt_error_no_symbol, lib_name, _N_(_ittapi_global).api_list_ptr[i].name); +#ifdef ITT_COMPLETE_GROUP + zero_group = (__itt_group_id)(zero_group | _N_(_ittapi_global).api_list_ptr[i].group); +#endif /* ITT_COMPLETE_GROUP */ + } + } + else + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; + } + + if (groups == __itt_group_legacy) + { + /* Compatibility with legacy tools */ + ITTNOTIFY_NAME(thread_ignore) = ITTNOTIFY_NAME(thr_ignore); +#if ITT_PLATFORM==ITT_PLATFORM_WIN + ITTNOTIFY_NAME(sync_createA) = ITTNOTIFY_NAME(sync_set_nameA); + ITTNOTIFY_NAME(sync_createW) = ITTNOTIFY_NAME(sync_set_nameW); +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ + ITTNOTIFY_NAME(sync_create) = ITTNOTIFY_NAME(sync_set_name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + ITTNOTIFY_NAME(sync_prepare) = ITTNOTIFY_NAME(notify_sync_prepare); + ITTNOTIFY_NAME(sync_cancel) = ITTNOTIFY_NAME(notify_sync_cancel); + ITTNOTIFY_NAME(sync_acquired) = ITTNOTIFY_NAME(notify_sync_acquired); + ITTNOTIFY_NAME(sync_releasing) = ITTNOTIFY_NAME(notify_sync_releasing); + } + +#ifdef ITT_COMPLETE_GROUP + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + if (_N_(_ittapi_global).api_list_ptr[i].group & zero_group) + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; +#endif /* ITT_COMPLETE_GROUP */ + break; + case 2: + __itt_api_init_ptr = (__itt_api_init_t*)(size_t)__itt_get_proc(_N_(_ittapi_global).lib, "__itt_api_init"); + if (__itt_api_init_ptr) + __itt_api_init_ptr(&_N_(_ittapi_global), init_groups); + break; + } + } + else + { + __itt_nullify_all_pointers(); + + __itt_report_error(__itt_error_no_module, lib_name, +#if ITT_PLATFORM==ITT_PLATFORM_WIN + __itt_system_error() +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + dlerror() +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + ); + } + } + else + { + __itt_nullify_all_pointers(); + } + _N_(_ittapi_global).api_initialized = 1; + current_thread = 0; + /* !!! Just to avoid unused code elimination !!! */ + if (__itt_fini_ittlib_ptr == _N_(fini_ittlib)) current_thread = 0; + } + } + +#ifndef ITT_SIMPLE_INIT + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#endif /* ITT_SIMPLE_INIT */ + } + + /* Evaluating if any function ptr is non empty and it's in init_groups */ + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + { + if (*_N_(_ittapi_global).api_list_ptr[i].func_ptr != _N_(_ittapi_global).api_list_ptr[i].null_func && + _N_(_ittapi_global).api_list_ptr[i].group & init_groups) + { + return 1; + } + } + return 0; +} + +ITT_EXTERN_C __itt_error_handler_t* _N_(set_error_handler)(__itt_error_handler_t* handler) +{ + __itt_error_handler_t* prev = (__itt_error_handler_t*)(size_t)_N_(_ittapi_global).error_handler; + _N_(_ittapi_global).error_handler = (void*)(size_t)handler; + return prev; +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(pop) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + diff --git a/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.h b/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.h new file mode 100644 index 0000000000..e728f8b154 --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.h @@ -0,0 +1,376 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ittnotify_config.h" + +#ifndef ITT_FORMAT_DEFINED +# ifndef ITT_FORMAT +# define ITT_FORMAT +# endif /* ITT_FORMAT */ +# ifndef ITT_NO_PARAMS +# define ITT_NO_PARAMS +# endif /* ITT_NO_PARAMS */ +#endif /* ITT_FORMAT_DEFINED */ + +/* + * parameters for macro expected: + * ITT_STUB(api, type, func_name, arguments, params, func_name_in_dll, group, printf_fmt) + */ +#ifdef __ITT_INTERNAL_INIT + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_domain*, domain_createA, (const char *name), (ITT_FORMAT name), domain_createA, __itt_group_structure, "\"%s\"") +ITT_STUB(ITTAPI, __itt_domain*, domain_createW, (const wchar_t *name), (ITT_FORMAT name), domain_createW, __itt_group_structure, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_domain*, domain_create, (const char *name), (ITT_FORMAT name), domain_create, __itt_group_structure, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createA, (const char *name), (ITT_FORMAT name), string_handle_createA, __itt_group_structure, "\"%s\"") +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createW, (const wchar_t *name), (ITT_FORMAT name), string_handle_createW, __itt_group_structure, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_create, (const char *name), (ITT_FORMAT name), string_handle_create, __itt_group_structure, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_STUBV(ITTAPI, void, pause, (void), (ITT_NO_PARAMS), pause, __itt_group_control | __itt_group_legacy, "no args") +ITT_STUBV(ITTAPI, void, resume, (void), (ITT_NO_PARAMS), resume, __itt_group_control | __itt_group_legacy, "no args") + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, thread_set_nameA, (const char *name), (ITT_FORMAT name), thread_set_nameA, __itt_group_thread, "\"%s\"") +ITT_STUBV(ITTAPI, void, thread_set_nameW, (const wchar_t *name), (ITT_FORMAT name), thread_set_nameW, __itt_group_thread, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, thread_set_name, (const char *name), (ITT_FORMAT name), thread_set_name, __itt_group_thread, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, thread_ignore, (void), (ITT_NO_PARAMS), thread_ignore, __itt_group_thread, "no args") + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, thr_name_setA, (const char *name, int namelen), (ITT_FORMAT name, namelen), thr_name_setA, __itt_group_thread | __itt_group_legacy, "\"%s\", %d") +ITT_STUB(LIBITTAPI, int, thr_name_setW, (const wchar_t *name, int namelen), (ITT_FORMAT name, namelen), thr_name_setW, __itt_group_thread | __itt_group_legacy, "\"%S\", %d") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, thr_name_set, (const char *name, int namelen), (ITT_FORMAT name, namelen), thr_name_set, __itt_group_thread | __itt_group_legacy, "\"%s\", %d") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(LIBITTAPI, void, thr_ignore, (void), (ITT_NO_PARAMS), thr_ignore, __itt_group_thread | __itt_group_legacy, "no args") +#endif /* __ITT_INTERNAL_BODY */ + +ITT_STUBV(ITTAPI, void, enable_attach, (void), (ITT_NO_PARAMS), enable_attach, __itt_group_all, "no args") + +#else /* __ITT_INTERNAL_INIT */ + +ITT_STUBV(ITTAPI, void, detach, (void), (ITT_NO_PARAMS), detach, __itt_group_control | __itt_group_legacy, "no args") + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_createA, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_createA, __itt_group_sync | __itt_group_fsync, "%p, \"%s\", \"%s\", %x") +ITT_STUBV(ITTAPI, void, sync_createW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_createW, __itt_group_sync | __itt_group_fsync, "%p, \"%S\", \"%S\", %x") +ITT_STUBV(ITTAPI, void, sync_renameA, (void *addr, const char *name), (ITT_FORMAT addr, name), sync_renameA, __itt_group_sync | __itt_group_fsync, "%p, \"%s\"") +ITT_STUBV(ITTAPI, void, sync_renameW, (void *addr, const wchar_t *name), (ITT_FORMAT addr, name), sync_renameW, __itt_group_sync | __itt_group_fsync, "%p, \"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_create, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_create, __itt_group_sync | __itt_group_fsync, "%p, \"%s\", \"%s\", %x") +ITT_STUBV(ITTAPI, void, sync_rename, (void *addr, const char *name), (ITT_FORMAT addr, name), sync_rename, __itt_group_sync | __itt_group_fsync, "%p, \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_destroy, (void *addr), (ITT_FORMAT addr), sync_destroy, __itt_group_sync | __itt_group_fsync, "%p") + +ITT_STUBV(ITTAPI, void, sync_prepare, (void* addr), (ITT_FORMAT addr), sync_prepare, __itt_group_sync, "%p") +ITT_STUBV(ITTAPI, void, sync_cancel, (void *addr), (ITT_FORMAT addr), sync_cancel, __itt_group_sync, "%p") +ITT_STUBV(ITTAPI, void, sync_acquired, (void *addr), (ITT_FORMAT addr), sync_acquired, __itt_group_sync, "%p") +ITT_STUBV(ITTAPI, void, sync_releasing, (void* addr), (ITT_FORMAT addr), sync_releasing, __itt_group_sync, "%p") + +ITT_STUBV(ITTAPI, void, suppress_push, (unsigned int mask), (ITT_FORMAT mask), suppress_push, __itt_group_suppress, "%p") +ITT_STUBV(ITTAPI, void, suppress_pop, (void), (ITT_NO_PARAMS), suppress_pop, __itt_group_suppress, "no args") +ITT_STUBV(ITTAPI, void, suppress_mark_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size),(ITT_FORMAT mode, mask, address, size), suppress_mark_range, __itt_group_suppress, "%d, %p, %p, %d") +ITT_STUBV(ITTAPI, void, suppress_clear_range,(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size),(ITT_FORMAT mode, mask, address, size), suppress_clear_range,__itt_group_suppress, "%d, %p, %p, %d") + +ITT_STUBV(ITTAPI, void, fsync_prepare, (void* addr), (ITT_FORMAT addr), sync_prepare, __itt_group_fsync, "%p") +ITT_STUBV(ITTAPI, void, fsync_cancel, (void *addr), (ITT_FORMAT addr), sync_cancel, __itt_group_fsync, "%p") +ITT_STUBV(ITTAPI, void, fsync_acquired, (void *addr), (ITT_FORMAT addr), sync_acquired, __itt_group_fsync, "%p") +ITT_STUBV(ITTAPI, void, fsync_releasing, (void* addr), (ITT_FORMAT addr), sync_releasing, __itt_group_fsync, "%p") + +ITT_STUBV(ITTAPI, void, model_site_begin, (__itt_model_site *site, __itt_model_site_instance *instance, const char *name), (ITT_FORMAT site, instance, name), model_site_begin, __itt_group_model, "%p, %p, \"%s\"") +ITT_STUBV(ITTAPI, void, model_site_end, (__itt_model_site *site, __itt_model_site_instance *instance), (ITT_FORMAT site, instance), model_site_end, __itt_group_model, "%p, %p") +ITT_STUBV(ITTAPI, void, model_task_begin, (__itt_model_task *task, __itt_model_task_instance *instance, const char *name), (ITT_FORMAT task, instance, name), model_task_begin, __itt_group_model, "%p, %p, \"%s\"") +ITT_STUBV(ITTAPI, void, model_task_end, (__itt_model_task *task, __itt_model_task_instance *instance), (ITT_FORMAT task, instance), model_task_end, __itt_group_model, "%p, %p") +ITT_STUBV(ITTAPI, void, model_lock_acquire, (void *lock), (ITT_FORMAT lock), model_lock_acquire, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_lock_release, (void *lock), (ITT_FORMAT lock), model_lock_release, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_record_allocation, (void *addr, size_t size), (ITT_FORMAT addr, size), model_record_allocation, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_record_deallocation, (void *addr), (ITT_FORMAT addr), model_record_deallocation, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_induction_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_induction_uses, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_reduction_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_reduction_uses, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_observe_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_observe_uses, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_clear_uses, (void* addr), (ITT_FORMAT addr), model_clear_uses, __itt_group_model, "%p") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, model_site_beginW, (const wchar_t *name), (ITT_FORMAT name), model_site_beginW, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_task_beginW, (const wchar_t *name), (ITT_FORMAT name), model_task_beginW, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_iteration_taskW, (const wchar_t *name), (ITT_FORMAT name), model_iteration_taskW, __itt_group_model, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, model_site_beginA, (const char *name), (ITT_FORMAT name), model_site_beginA, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_site_beginAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_site_beginAL, __itt_group_model, "\"%s\", %d") +ITT_STUBV(ITTAPI, void, model_task_beginA, (const char *name), (ITT_FORMAT name), model_task_beginA, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_task_beginAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_task_beginAL, __itt_group_model, "\"%s\", %d") +ITT_STUBV(ITTAPI, void, model_iteration_taskA, (const char *name), (ITT_FORMAT name), model_iteration_taskA, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_iteration_taskAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_iteration_taskAL, __itt_group_model, "\"%s\", %d") +ITT_STUBV(ITTAPI, void, model_site_end_2, (void), (ITT_NO_PARAMS), model_site_end_2, __itt_group_model, "no args") +ITT_STUBV(ITTAPI, void, model_task_end_2, (void), (ITT_NO_PARAMS), model_task_end_2, __itt_group_model, "no args") +ITT_STUBV(ITTAPI, void, model_lock_acquire_2, (void *lock), (ITT_FORMAT lock), model_lock_acquire_2, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_lock_release_2, (void *lock), (ITT_FORMAT lock), model_lock_release_2, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_aggregate_task, (size_t count), (ITT_FORMAT count), model_aggregate_task, __itt_group_model, "%d") +ITT_STUBV(ITTAPI, void, model_disable_push, (__itt_model_disable x), (ITT_FORMAT x), model_disable_push, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_disable_pop, (void), (ITT_NO_PARAMS), model_disable_pop, __itt_group_model, "no args") +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createA, (const char *name, const char *domain), (ITT_FORMAT name, domain), heap_function_createA, __itt_group_heap, "\"%s\", \"%s\"") +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createW, (const wchar_t *name, const wchar_t *domain), (ITT_FORMAT name, domain), heap_function_createW, __itt_group_heap, "\"%s\", \"%s\"") +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_create, (const char *name, const char *domain), (ITT_FORMAT name, domain), heap_function_create, __itt_group_heap, "\"%s\", \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, heap_allocate_begin, (__itt_heap_function h, size_t size, int initialized), (ITT_FORMAT h, size, initialized), heap_allocate_begin, __itt_group_heap, "%p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_allocate_end, (__itt_heap_function h, void** addr, size_t size, int initialized), (ITT_FORMAT h, addr, size, initialized), heap_allocate_end, __itt_group_heap, "%p, %p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_free_begin, (__itt_heap_function h, void* addr), (ITT_FORMAT h, addr), heap_free_begin, __itt_group_heap, "%p, %p") +ITT_STUBV(ITTAPI, void, heap_free_end, (__itt_heap_function h, void* addr), (ITT_FORMAT h, addr), heap_free_end, __itt_group_heap, "%p, %p") +ITT_STUBV(ITTAPI, void, heap_reallocate_begin, (__itt_heap_function h, void* addr, size_t new_size, int initialized), (ITT_FORMAT h, addr, new_size, initialized), heap_reallocate_begin, __itt_group_heap, "%p, %p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_reallocate_end, (__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized), (ITT_FORMAT h, addr, new_addr, new_size, initialized), heap_reallocate_end, __itt_group_heap, "%p, %p, %p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_internal_access_begin, (void), (ITT_NO_PARAMS), heap_internal_access_begin, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_internal_access_end, (void), (ITT_NO_PARAMS), heap_internal_access_end, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_begin, (void), (ITT_NO_PARAMS), heap_record_memory_growth_begin, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_end, (void), (ITT_NO_PARAMS), heap_record_memory_growth_end, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_reset_detection, (unsigned int reset_mask), (ITT_FORMAT reset_mask), heap_reset_detection, __itt_group_heap, "%u") +ITT_STUBV(ITTAPI, void, heap_record, (unsigned int record_mask), (ITT_FORMAT record_mask), heap_record, __itt_group_heap, "%u") + +ITT_STUBV(ITTAPI, void, id_create, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), id_create, __itt_group_structure, "%p, %lu") +ITT_STUBV(ITTAPI, void, id_destroy, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), id_destroy, __itt_group_structure, "%p, %lu") + +ITT_STUB(ITTAPI, __itt_timestamp, get_timestamp, (void), (ITT_NO_PARAMS), get_timestamp, __itt_group_structure, "no args") + +ITT_STUBV(ITTAPI, void, region_begin, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), region_begin, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, region_end, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), region_end, __itt_group_structure, "%p, %lu") + +#ifndef __ITT_INTERNAL_BODY +ITT_STUBV(ITTAPI, void, frame_begin_v3, (const __itt_domain *domain, __itt_id *id), (ITT_FORMAT domain, id), frame_begin_v3, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, frame_end_v3, (const __itt_domain *domain, __itt_id *id), (ITT_FORMAT domain, id), frame_end_v3, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, frame_submit_v3, (const __itt_domain *domain, __itt_id *id, __itt_timestamp begin, __itt_timestamp end), (ITT_FORMAT domain, id, begin, end), frame_submit_v3, __itt_group_structure, "%p, %p, %lu, %lu") +#endif /* __ITT_INTERNAL_BODY */ + +ITT_STUBV(ITTAPI, void, task_group, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_group, __itt_group_structure, "%p, %lu, %lu, %p") + +ITT_STUBV(ITTAPI, void, task_begin, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_begin, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_begin_fn, (const __itt_domain *domain, __itt_id id, __itt_id parent, void* fn), (ITT_FORMAT domain, id, parent, fn), task_begin_fn, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_end, (const __itt_domain *domain), (ITT_FORMAT domain), task_end, __itt_group_structure, "%p") + +ITT_STUBV(ITTAPI, void, counter_inc_v3, (const __itt_domain *domain, __itt_string_handle *name), (ITT_FORMAT domain, name), counter_inc_v3, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, counter_inc_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long value), (ITT_FORMAT domain, name, value), counter_inc_delta_v3, __itt_group_structure, "%p, %p, %lu") + +ITT_STUBV(ITTAPI, void, marker, (const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope), (ITT_FORMAT domain, id, name, scope), marker, __itt_group_structure, "%p, %lu, %p, %d") + +ITT_STUBV(ITTAPI, void, metadata_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data), (ITT_FORMAT domain, id, key, type, count, data), metadata_add, __itt_group_structure, "%p, %lu, %p, %d, %lu, %p") +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_addA, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_addA, __itt_group_structure, "%p, %lu, %p, %p, %lu") +ITT_STUBV(ITTAPI, void, metadata_str_addW, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_addW, __itt_group_structure, "%p, %lu, %p, %p, %lu") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_add, __itt_group_structure, "%p, %lu, %p, %p, %lu") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_STUBV(ITTAPI, void, relation_add_to_current, (const __itt_domain *domain, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, relation, tail), relation_add_to_current, __itt_group_structure, "%p, %lu, %p") +ITT_STUBV(ITTAPI, void, relation_add, (const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, head, relation, tail), relation_add, __itt_group_structure, "%p, %p, %lu, %p") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen), (ITT_FORMAT name, namelen), event_createA, __itt_group_mark | __itt_group_legacy, "\"%s\", %d") +ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen), (ITT_FORMAT name, namelen), event_createW, __itt_group_mark | __itt_group_legacy, "\"%S\", %d") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen), (ITT_FORMAT name, namelen), event_create, __itt_group_mark | __itt_group_legacy, "\"%s\", %d") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event), (ITT_FORMAT event), event_start, __itt_group_mark | __itt_group_legacy, "%d") +ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event), (ITT_FORMAT event), event_end, __itt_group_mark | __itt_group_legacy, "%d") +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_set_nameA, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_nameA, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", \"%s\", %x") +ITT_STUBV(ITTAPI, void, sync_set_nameW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_nameW, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%S\", \"%S\", %x") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_set_name, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_name, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "p, \"%s\", \"%s\", %x") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, notify_sync_nameA, (void *p, const char *objtype, int typelen, const char *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_nameA, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", %d, \"%s\", %d, %x") +ITT_STUB(LIBITTAPI, int, notify_sync_nameW, (void *p, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_nameW, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%S\", %d, \"%S\", %d, %x") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, notify_sync_name, (void *p, const char *objtype, int typelen, const char *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_name, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", %d, \"%s\", %d, %x") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_STUBV(LIBITTAPI, void, notify_sync_prepare, (void *p), (ITT_FORMAT p), notify_sync_prepare, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +ITT_STUBV(LIBITTAPI, void, notify_sync_cancel, (void *p), (ITT_FORMAT p), notify_sync_cancel, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +ITT_STUBV(LIBITTAPI, void, notify_sync_acquired, (void *p), (ITT_FORMAT p), notify_sync_acquired, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +ITT_STUBV(LIBITTAPI, void, notify_sync_releasing, (void *p), (ITT_FORMAT p), notify_sync_releasing, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +#endif /* __ITT_INTERNAL_BODY */ + +ITT_STUBV(LIBITTAPI, void, memory_read, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_read, __itt_group_legacy, "%p, %lu") +ITT_STUBV(LIBITTAPI, void, memory_write, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_write, __itt_group_legacy, "%p, %lu") +ITT_STUBV(LIBITTAPI, void, memory_update, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_update, __itt_group_legacy, "%p, %lu") + +ITT_STUB(LIBITTAPI, __itt_state_t, state_get, (void), (ITT_NO_PARAMS), state_get, __itt_group_legacy, "no args") +ITT_STUB(LIBITTAPI, __itt_state_t, state_set, (__itt_state_t s), (ITT_FORMAT s), state_set, __itt_group_legacy, "%d") +ITT_STUB(LIBITTAPI, __itt_obj_state_t, obj_mode_set, (__itt_obj_prop_t p, __itt_obj_state_t s), (ITT_FORMAT p, s), obj_mode_set, __itt_group_legacy, "%d, %d") +ITT_STUB(LIBITTAPI, __itt_thr_state_t, thr_mode_set, (__itt_thr_prop_t p, __itt_thr_state_t s), (ITT_FORMAT p, s), thr_mode_set, __itt_group_legacy, "%d, %d") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_frame, frame_createA, (const char *domain), (ITT_FORMAT domain), frame_createA, __itt_group_frame, "\"%s\"") +ITT_STUB(ITTAPI, __itt_frame, frame_createW, (const wchar_t *domain), (ITT_FORMAT domain), frame_createW, __itt_group_frame, "\"%s\"") +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain), (ITT_FORMAT domain), frame_create, __itt_group_frame, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, frame_begin, (__itt_frame frame), (ITT_FORMAT frame), frame_begin, __itt_group_frame, "%p") +ITT_STUBV(ITTAPI, void, frame_end, (__itt_frame frame), (ITT_FORMAT frame), frame_end, __itt_group_frame, "%p") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_counter, counter_createA, (const char *name, const char *domain), (ITT_FORMAT name, domain), counter_createA, __itt_group_counter, "\"%s\", \"%s\"") +ITT_STUB(ITTAPI, __itt_counter, counter_createW, (const wchar_t *name, const wchar_t *domain), (ITT_FORMAT name, domain), counter_createW, __itt_group_counter, "\"%s\", \"%s\"") +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_counter, counter_create, (const char *name, const char *domain), (ITT_FORMAT name, domain), counter_create, __itt_group_counter, "\"%s\", \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, counter_destroy, (__itt_counter id), (ITT_FORMAT id), counter_destroy, __itt_group_counter, "%p") +ITT_STUBV(ITTAPI, void, counter_inc, (__itt_counter id), (ITT_FORMAT id), counter_inc, __itt_group_counter, "%p") +ITT_STUBV(ITTAPI, void, counter_inc_delta, (__itt_counter id, unsigned long long value), (ITT_FORMAT id, value), counter_inc_delta, __itt_group_counter, "%p, %lu") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_mark_type, mark_createA, (const char *name), (ITT_FORMAT name), mark_createA, __itt_group_mark, "\"%s\"") +ITT_STUB(ITTAPI, __itt_mark_type, mark_createW, (const wchar_t *name), (ITT_FORMAT name), mark_createW, __itt_group_mark, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_mark_type, mark_create, (const char *name), (ITT_FORMAT name), mark_create, __itt_group_mark, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, markA, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), markA, __itt_group_mark, "%d, \"%s\"") +ITT_STUB(ITTAPI, int, markW, (__itt_mark_type mt, const wchar_t *parameter), (ITT_FORMAT mt, parameter), markW, __itt_group_mark, "%d, \"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark, __itt_group_mark, "%d, \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_off, (__itt_mark_type mt), (ITT_FORMAT mt), mark_off, __itt_group_mark, "%d") +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, mark_globalA, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark_globalA, __itt_group_mark, "%d, \"%s\"") +ITT_STUB(ITTAPI, int, mark_globalW, (__itt_mark_type mt, const wchar_t *parameter), (ITT_FORMAT mt, parameter), mark_globalW, __itt_group_mark, "%d, \"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_global, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark_global, __itt_group_mark, "%d, \"%S\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_global_off, (__itt_mark_type mt), (ITT_FORMAT mt), mark_global_off, __itt_group_mark, "%d") + +#ifndef __ITT_INTERNAL_BODY +ITT_STUB(ITTAPI, __itt_caller, stack_caller_create, (void), (ITT_NO_PARAMS), stack_caller_create, __itt_group_stitch, "no args") +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, stack_caller_destroy, (__itt_caller id), (ITT_FORMAT id), stack_caller_destroy, __itt_group_stitch, "%p") +ITT_STUBV(ITTAPI, void, stack_callee_enter, (__itt_caller id), (ITT_FORMAT id), stack_callee_enter, __itt_group_stitch, "%p") +ITT_STUBV(ITTAPI, void, stack_callee_leave, (__itt_caller id), (ITT_FORMAT id), stack_callee_leave, __itt_group_stitch, "%p") + +ITT_STUB(ITTAPI, __itt_clock_domain*, clock_domain_create, (__itt_get_clock_info_fn fn, void* fn_data), (ITT_FORMAT fn, fn_data), clock_domain_create, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, clock_domain_reset, (void), (ITT_NO_PARAMS), clock_domain_reset, __itt_group_structure, "no args") +ITT_STUBV(ITTAPI, void, id_create_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), id_create_ex, __itt_group_structure, "%p, %p, %lu, %lu") +ITT_STUBV(ITTAPI, void, id_destroy_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), id_destroy_ex, __itt_group_structure, "%p, %p, %lu, %lu") +ITT_STUBV(ITTAPI, void, task_begin_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, name), task_begin_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_begin_fn_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, void* fn), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, fn), task_begin_fn_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_end_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp), (ITT_FORMAT domain, clock_domain, timestamp), task_end_ex, __itt_group_structure, "%p, %p, %lu") +ITT_STUBV(ITTAPI, void, task_begin_overlapped, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_begin_overlapped, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_begin_overlapped_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, name), task_begin_overlapped_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_end_overlapped, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), task_end_overlapped, __itt_group_structure, "%p, %lu") +ITT_STUBV(ITTAPI, void, task_end_overlapped_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), task_end_overlapped_ex, __itt_group_structure, "%p, %p, %lu, %lu") +ITT_STUBV(ITTAPI, void, marker_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope), (ITT_FORMAT domain, clock_domain, timestamp, id, name, scope), marker_ex, __itt_group_structure, "%p, %p, %lu, %lu, %p, %d") +ITT_STUBV(ITTAPI, void, metadata_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data), (ITT_FORMAT domain, scope, key, type, count, data), metadata_add_with_scope, __itt_group_structure, "%p, %d, %p, %d, %lu, %p") +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeA, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scopeA, __itt_group_structure, "%p, %d, %p, %p, %lu") +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeW, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scopeW, __itt_group_structure, "%p, %d, %p, %p, %lu") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scope, __itt_group_structure, "%p, %d, %p, %p, %lu") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, relation_add_to_current_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, clock_domain, timestamp, relation, tail), relation_add_to_current_ex, __itt_group_structure, "%p, %p, %lu, %d, %lu") +ITT_STUBV(ITTAPI, void, relation_add_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, clock_domain, timestamp, head, relation, tail), relation_add_ex, __itt_group_structure, "%p, %p, %lu, %lu, %d, %lu") +ITT_STUB(ITTAPI, __itt_track_group*, track_group_create, (__itt_string_handle* name, __itt_track_group_type track_group_type), (ITT_FORMAT name, track_group_type), track_group_create, __itt_group_structure, "%p, %d") +ITT_STUB(ITTAPI, __itt_track*, track_create, (__itt_track_group* track_group,__itt_string_handle* name, __itt_track_type track_type), (ITT_FORMAT track_group, name, track_type), track_create, __itt_group_structure, "%p, %p, %d") +ITT_STUBV(ITTAPI, void, set_track, (__itt_track *track), (ITT_FORMAT track), set_track, __itt_group_structure, "%p") + +#ifndef __ITT_INTERNAL_BODY +ITT_STUB(ITTAPI, const char*, api_version, (void), (ITT_NO_PARAMS), api_version, __itt_group_all & ~__itt_group_legacy, "no args") +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, av_saveA, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_saveA, __itt_group_arrays, "%p, %d, %p, %d, \"%s\", %d") +ITT_STUB(ITTAPI, int, av_saveW, (void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_saveW, __itt_group_arrays, "%p, %d, %p, %d, \"%S\", %d") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, av_save, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_save, __itt_group_arrays, "%p, %d, %p, %d, \"%s\", %d") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, module_loadA, (void *start_addr, void* end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_loadA, __itt_group_none, "%p, %p, %p") +ITT_STUBV(ITTAPI, void, module_loadW, (void *start_addr, void* end_addr, const wchar_t *path), (ITT_FORMAT start_addr, end_addr, path), module_loadW, __itt_group_none, "%p, %p, %p") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_load, __itt_group_none, "%p, %p, %p") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ + + +#endif /* __ITT_INTERNAL_INIT */ diff --git a/external/vtune/linux/sdk/src/ittnotify/ittnotify_types.h b/external/vtune/linux/sdk/src/ittnotify/ittnotify_types.h new file mode 100644 index 0000000000..d6320d2b4a --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/ittnotify_types.h @@ -0,0 +1,115 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ITTNOTIFY_TYPES_H_ +#define _ITTNOTIFY_TYPES_H_ + +typedef enum ___itt_group_id +{ + __itt_group_none = 0, + __itt_group_legacy = 1<<0, + __itt_group_control = 1<<1, + __itt_group_thread = 1<<2, + __itt_group_mark = 1<<3, + __itt_group_sync = 1<<4, + __itt_group_fsync = 1<<5, + __itt_group_jit = 1<<6, + __itt_group_model = 1<<7, + __itt_group_splitter_min = 1<<7, + __itt_group_counter = 1<<8, + __itt_group_frame = 1<<9, + __itt_group_stitch = 1<<10, + __itt_group_heap = 1<<11, + __itt_group_splitter_max = 1<<12, + __itt_group_structure = 1<<12, + __itt_group_suppress = 1<<13, + __itt_group_arrays = 1<<14, + __itt_group_all = -1 +} __itt_group_id; + +#pragma pack(push, 8) + +typedef struct ___itt_group_list +{ + __itt_group_id id; + const char* name; +} __itt_group_list; + +#pragma pack(pop) + +#define ITT_GROUP_LIST(varname) \ + static __itt_group_list varname[] = { \ + { __itt_group_all, "all" }, \ + { __itt_group_control, "control" }, \ + { __itt_group_thread, "thread" }, \ + { __itt_group_mark, "mark" }, \ + { __itt_group_sync, "sync" }, \ + { __itt_group_fsync, "fsync" }, \ + { __itt_group_jit, "jit" }, \ + { __itt_group_model, "model" }, \ + { __itt_group_counter, "counter" }, \ + { __itt_group_frame, "frame" }, \ + { __itt_group_stitch, "stitch" }, \ + { __itt_group_heap, "heap" }, \ + { __itt_group_structure, "structure" }, \ + { __itt_group_suppress, "suppress" }, \ + { __itt_group_arrays, "arrays" }, \ + { __itt_group_none, NULL } \ + } + +#endif /* _ITTNOTIFY_TYPES_H_ */ diff --git a/external/vtune/linux/sdk/src/ittnotify/jitprofiling.c b/external/vtune/linux/sdk/src/ittnotify/jitprofiling.c new file mode 100644 index 0000000000..647aac1193 --- /dev/null +++ b/external/vtune/linux/sdk/src/ittnotify/jitprofiling.c @@ -0,0 +1,315 @@ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ittnotify_config.h" + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#pragma optimize("", off) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM != ITT_PLATFORM_MAC && ITT_PLATFORM != ITT_PLATFORM_FREEBSD +#include +#endif +#include + +#include "jitprofiling.h" + +static const char rcsid[] = "\n@(#) $Revision: 398909 $\n"; + +#define DLL_ENVIRONMENT_VAR "VS_PROFILER" + +#ifndef NEW_DLL_ENVIRONMENT_VAR +#if ITT_ARCH==ITT_ARCH_IA32 +#define NEW_DLL_ENVIRONMENT_VAR "INTEL_JIT_PROFILER32" +#else +#define NEW_DLL_ENVIRONMENT_VAR "INTEL_JIT_PROFILER64" +#endif +#endif /* NEW_DLL_ENVIRONMENT_VAR */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define DEFAULT_DLLNAME "JitPI.dll" +HINSTANCE m_libHandle = NULL; +#elif ITT_PLATFORM==ITT_PLATFORM_MAC +#define DEFAULT_DLLNAME "libJitPI.dylib" +void* m_libHandle = NULL; +#else +#define DEFAULT_DLLNAME "libJitPI.so" +void* m_libHandle = NULL; +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/* default location of JIT profiling agent on Android */ +#define ANDROID_JIT_AGENT_PATH "/data/intel/libittnotify.so" + +/* the function pointers */ +typedef unsigned int(*TPInitialize)(void); +static TPInitialize FUNC_Initialize=NULL; + +typedef unsigned int(*TPNotify)(unsigned int, void*); +static TPNotify FUNC_NotifyEvent=NULL; + +static iJIT_IsProfilingActiveFlags executionMode = iJIT_NOTHING_RUNNING; + +/* end collector dll part. */ + +/* loadiJIT_Funcs() : this function is called just in the beginning + * and is responsible to load the functions from BistroJavaCollector.dll + * result: + * on success: the functions loads, iJIT_DLL_is_missing=0, return value = 1 + * on failure: the functions are NULL, iJIT_DLL_is_missing=1, return value = 0 + */ +static int loadiJIT_Funcs(void); + +/* global representing whether the collector can't be loaded */ +static int iJIT_DLL_is_missing = 0; + +ITT_EXTERN_C int JITAPI +iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData) +{ + int ReturnValue; + + /* initialization part - the collector has not been loaded yet. */ + if (!FUNC_NotifyEvent) + { + if (iJIT_DLL_is_missing) + return 0; + + if (!loadiJIT_Funcs()) + return 0; + } + + if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED || + event_type == iJVM_EVENT_TYPE_METHOD_UPDATE) + { + if (((piJIT_Method_Load)EventSpecificData)->method_id == 0) + return 0; + } + else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2) + { + if (((piJIT_Method_Load_V2)EventSpecificData)->method_id == 0) + return 0; + } + else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3) + { + if (((piJIT_Method_Load_V3)EventSpecificData)->method_id == 0) + return 0; + } + else if (event_type == iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED) + { + if (((piJIT_Method_Inline_Load)EventSpecificData)->method_id == 0 || + ((piJIT_Method_Inline_Load)EventSpecificData)->parent_method_id == 0) + return 0; + } + + ReturnValue = (int)FUNC_NotifyEvent(event_type, EventSpecificData); + + return ReturnValue; +} + +ITT_EXTERN_C iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive() +{ + if (!iJIT_DLL_is_missing) + { + loadiJIT_Funcs(); + } + + return executionMode; +} + +/* This function loads the collector dll and the relevant functions. + * on success: all functions load, iJIT_DLL_is_missing = 0, return value = 1 + * on failure: all functions are NULL, iJIT_DLL_is_missing = 1, return value = 0 + */ +static int loadiJIT_Funcs() +{ + static int bDllWasLoaded = 0; + char *dllName = (char*)rcsid; /* !! Just to avoid unused code elimination */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN + DWORD dNameLength = 0; +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + + if(bDllWasLoaded) + { + /* dll was already loaded, no need to do it for the second time */ + return 1; + } + + /* Assumes that the DLL will not be found */ + iJIT_DLL_is_missing = 1; + FUNC_NotifyEvent = NULL; + + if (m_libHandle) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + FreeLibrary(m_libHandle); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + dlclose(m_libHandle); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + m_libHandle = NULL; + } + + /* Try to get the dll name from the environment */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN + dNameLength = GetEnvironmentVariableA(NEW_DLL_ENVIRONMENT_VAR, NULL, 0); + if (dNameLength) + { + DWORD envret = 0; + dllName = (char*)malloc(sizeof(char) * (dNameLength + 1)); + if(dllName != NULL) + { + envret = GetEnvironmentVariableA(NEW_DLL_ENVIRONMENT_VAR, + dllName, dNameLength); + if (envret) + { + /* Try to load the dll from the PATH... */ + m_libHandle = LoadLibraryExA(dllName, + NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + } + free(dllName); + } + } else { + /* Try to use old VS_PROFILER variable */ + dNameLength = GetEnvironmentVariableA(DLL_ENVIRONMENT_VAR, NULL, 0); + if (dNameLength) + { + DWORD envret = 0; + dllName = (char*)malloc(sizeof(char) * (dNameLength + 1)); + if(dllName != NULL) + { + envret = GetEnvironmentVariableA(DLL_ENVIRONMENT_VAR, + dllName, dNameLength); + if (envret) + { + /* Try to load the dll from the PATH... */ + m_libHandle = LoadLibraryA(dllName); + } + free(dllName); + } + } + } +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + dllName = getenv(NEW_DLL_ENVIRONMENT_VAR); + if (!dllName) + dllName = getenv(DLL_ENVIRONMENT_VAR); +#if defined(__ANDROID__) || defined(ANDROID) + if (!dllName) + dllName = ANDROID_JIT_AGENT_PATH; +#endif + if (dllName) + { + /* Try to load the dll from the PATH... */ + m_libHandle = dlopen(dllName, RTLD_LAZY); + } +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + + if (!m_libHandle) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + m_libHandle = LoadLibraryA(DEFAULT_DLLNAME); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + m_libHandle = dlopen(DEFAULT_DLLNAME, RTLD_LAZY); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + } + + /* if the dll wasn't loaded - exit. */ + if (!m_libHandle) + { + iJIT_DLL_is_missing = 1; /* don't try to initialize + * JIT agent the second time + */ + return 0; + } + +#if ITT_PLATFORM==ITT_PLATFORM_WIN + FUNC_NotifyEvent = (TPNotify)GetProcAddress(m_libHandle, "NotifyEvent"); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + FUNC_NotifyEvent = (TPNotify)dlsym(m_libHandle, "NotifyEvent"); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + if (!FUNC_NotifyEvent) + { + FUNC_Initialize = NULL; + return 0; + } + +#if ITT_PLATFORM==ITT_PLATFORM_WIN + FUNC_Initialize = (TPInitialize)GetProcAddress(m_libHandle, "Initialize"); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + FUNC_Initialize = (TPInitialize)dlsym(m_libHandle, "Initialize"); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + if (!FUNC_Initialize) + { + FUNC_NotifyEvent = NULL; + return 0; + } + + executionMode = (iJIT_IsProfilingActiveFlags)FUNC_Initialize(); + + bDllWasLoaded = 1; + iJIT_DLL_is_missing = 0; /* DLL is ok. */ + + return 1; +} + +ITT_EXTERN_C unsigned int JITAPI iJIT_GetNewMethodID() +{ + static unsigned int methodID = 1; + + if (methodID == 0) + return 0; /* ERROR : this is not a valid value */ + + return methodID++; +} diff --git a/linux/installer/bin/build-installpkg.sh b/linux/installer/bin/build-installpkg.sh new file mode 100755 index 0000000000..5db4537402 --- /dev/null +++ b/linux/installer/bin/build-installpkg.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +set -e + +[[ $# -eq 1 ]] || { + echo "Usage : ./build-installpkg.sh sdk | psw " + exit 1 +} + +[[ "$1" == "sdk" ]] || [[ "$1" == "psw" ]] || { + echo "Usage : ./build-installpkg.sh sdk | psw " + exit 1 +} + +INSTALLER_TYPE="$1" + +SCRIPT_DIR=$(dirname "$0") +ROOT_DIR="${SCRIPT_DIR}/../../.." +LINUX_INSTALLER_COMMON_DIR="${ROOT_DIR}/linux/installer/common" +LINUX_INSTALLER_COMMON_SDK_DIR="${LINUX_INSTALLER_COMMON_DIR}/sdk" +LINUX_INSTALLER_COMMON_PSW_DIR="${LINUX_INSTALLER_COMMON_DIR}/psw" + +# The result dir of the build +BUILD_DIR=${ROOT_DIR}/build/linux + +# Get the architecture of the build from generated binary +get_arch() +{ + local a=$(readelf -h $BUILD_DIR/sgx_sign | awk '/Class:/{print $2}') + test $a = ELF64 && echo 'x86_64' || echo 'x86' +} + + +ARCH=$(get_arch) + +case $ARCH in + x86_64)PACKAGE_SUFFIX="x64" + ;; + x86)PACKAGE_SUFFIX="x86" + ;; +esac + +case "$INSTALLER_TYPE" in + psw) + source ${LINUX_INSTALLER_COMMON_PSW_DIR}/installConfig.${PACKAGE_SUFFIX} + ${LINUX_INSTALLER_COMMON_PSW_DIR}/createTarball.sh + cp ${LINUX_INSTALLER_COMMON_PSW_DIR}/output/${TARBALL_NAME} ${SCRIPT_DIR} + ;; + sdk) + source ${LINUX_INSTALLER_COMMON_SDK_DIR}/installConfig.${PACKAGE_SUFFIX} + ${LINUX_INSTALLER_COMMON_SDK_DIR}/createTarball.sh + cp ${LINUX_INSTALLER_COMMON_SDK_DIR}/output/${TARBALL_NAME} ${SCRIPT_DIR} + ;; +esac + +trap "rm -f ${SCRIPT_DIR}/$TARBALL_NAME 2>/dev/null" 0 + +# Create the tarball and compute its MD5 check sum. +m=$(md5sum ${SCRIPT_DIR}/$TARBALL_NAME | awk '{print $1}') +v=$(awk '/STRFILEVER/ {print $3}' ${ROOT_DIR}/common/inc/internal/se_version.h|sed 's/^\"\(.*\)\"$/\1/') +TEMPLATE_FILE=$SCRIPT_DIR/install-sgx-"$INSTALLER_TYPE".bin.tmpl +INSTALLER_NAME=$SCRIPT_DIR/sgx_linux_"${PACKAGE_SUFFIX}"_"$INSTALLER_TYPE"_"$v".bin +l=$(wc -l $TEMPLATE_FILE | awk '{print $1}') +l=$(($l+1)) + +sed -e "s:@linenum@:$l:" \ + -e "s:@md5sum@:$m:" \ + -e "s:@arch@:$ARCH:" \ + $TEMPLATE_FILE > $INSTALLER_NAME + +cat ${SCRIPT_DIR}/${TARBALL_NAME} >> $INSTALLER_NAME +chmod +x $INSTALLER_NAME +echo "Generated ${INSTALLER_TYPE} installer: $INSTALLER_NAME" +exit 0 diff --git a/linux/installer/bin/install-sgx-psw.bin.tmpl b/linux/installer/bin/install-sgx-psw.bin.tmpl new file mode 100755 index 0000000000..4c36e367ff --- /dev/null +++ b/linux/installer/bin/install-sgx-psw.bin.tmpl @@ -0,0 +1,110 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +modinfo isgx &> /dev/null +if [[ $? != "0" ]]; then + echo "Please install the driver package before the PSW package" + exit 4 +fi + +set -e + +PKG_NAME="Intel SGX PSW Package" + +if test $(id -u) -ne 0; then + echo "Root privilege is required to install $PKG_NAME." + exit 4 +fi + + +PKG_ARCH=@arch@ +ARCH=$(arch) + +if [ $ARCH == "i386" ] || [ $ARCH == "i586" ] || [ $ARCH == "i686" ]; then + ARCH=x86 +fi + +if [[ $ARCH != $PKG_ARCH ]]; then + echo "$PKG_ARCH $PKG_NAME can not be installed on $ARCH platform." + exit 4 +fi + +PATH=/usr/bin:/bin +umask 022 + +PSWPKG=`mktemp -t sgx-psw-pkg.XXXXXX` +PSW_TEMP_FOLDER=`mktemp -d sgx-psw-XXXXXX -p /tmp` +trap "rm -fr $PSWPKG $PSW_TEMP_FOLDER= 2>/dev/null; exit 3" HUP INT QUIT TERM + +# The number of lines in this script (plus 1). Using this number to +# calculate the start address of the payload. +NR_SCRIPT_LINES=@linenum@ + +# Run /usr/bin/md5sum on the binary payload to get the MD5 check sum. +CHKSUM=@md5sum@ + +# Get the install payload from this shell script. +echo -n "Unpacking $PKG_NAME ..." +tail -n +$NR_SCRIPT_LINES "$0" > $PSWPKG +echo " done." + +echo -n "Verifying the integrity of the install package ..." +if test $(md5sum $PSWPKG | awk '{print $1}') != $CHKSUM; then + echo " The install package appears to be corrupted." + exit 1 +fi +echo " done." + +echo -n "Installing $PKG_NAME ..." +tar zxf $PSWPKG -C $PSW_TEMP_FOLDER >/dev/null 2>&1 +retcode=$? # Save the return code +# Clean-up the temporary tarball. +rm -f $PSWPKG 2>/dev/null + +if test $retcode -ne 0; then + echo " failed." + exit 2 +fi + +pushd $PSW_TEMP_FOLDER + +source scripts/installConfig +make install + +popd + +${SGX_PACKAGES_PATH}/${PSW_PKG_NAME}/scripts/install.sh + +rm -fr ${PSW_TEMP_FOLDER} + + +exit 0 diff --git a/linux/installer/bin/install-sgx-sdk.bin.tmpl b/linux/installer/bin/install-sgx-sdk.bin.tmpl new file mode 100755 index 0000000000..71457ba804 --- /dev/null +++ b/linux/installer/bin/install-sgx-sdk.bin.tmpl @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +set -e + +PKG_NAME="Intel SGX SDK" + +if test $(id -u) -ne 0; then + echo "Root privilege is required to install $PKG_NAME." + exit 4 +fi + +PATH=/usr/bin:/bin +umask 022 + +SDKPKG=`mktemp -t sgx-sdk-pkg.XXXXXX` +SDK_TEMP_FOLDER=`mktemp -d sgx-sdk-XXXXXX -p /tmp` +trap "rm -rf $SDKPKG $SDK_TEMP_FOLDER 2>/dev/null; exit 3" HUP INT QUIT TERM + +# The number of lines in this script (plus 1). Using this number to +# calculate the start address of the payload. +NR_SCRIPT_LINES=@linenum@ + +# Run /usr/bin/md5sum on the binary payload to get the MD5 check sum. +CHKSUM=@md5sum@ + +# Get the install payload from this shell script. +echo -n "Unpacking $PKG_NAME ..." +tail -n +$NR_SCRIPT_LINES "$0" > $SDKPKG +echo " done." + +echo -n "Verifying the integrity of the install package ..." +if test $(md5sum $SDKPKG | awk '{print $1}') != $CHKSUM; then + echo " The install package appears to be corrupted." + exit 1 +fi +echo " done." + +echo -n "Installing $PKG_NAME ..." +tar zxf $SDKPKG -C $SDK_TEMP_FOLDER >/dev/null 2>&1 +retcode=$? # Save the return code +# Clean-up the temporary tarball. +rm -f $SDKPKG 2>/dev/null + +if test $retcode -ne 0; then + echo " failed." + exit 2 +fi +echo " done." + +pushd ${SDK_TEMP_FOLDER} + +source scripts/installConfig +make install + +popd + +${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/scripts/install.sh + +rm -fr ${SDK_TEMP_FOLDER} + +exit 0 diff --git a/linux/installer/common/gen_source/gen_source.py b/linux/installer/common/gen_source/gen_source.py new file mode 100755 index 0000000000..65774728f0 --- /dev/null +++ b/linux/installer/common/gen_source/gen_source.py @@ -0,0 +1,210 @@ +#!/usr/bin/env python +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +# This script is used to copy file from src to dest as descript in a BOM file +# example: python gen_source.py --bom=PATH_TO_BOM [--cleanup=false] [--deliverydir=DIR_RELATIVE_TO_gen_source.py] +# + + +import sys +import os +import shutil +import getopt + +def parse_cmd(argc, argv): + global bom_file + global cleanup + global deliverydir + + bom_file = "" + cleanup = True + deliverydir = "" + + local_path = os.path.split(os.path.realpath(sys.argv[0]))[0] + + try: + opts, args = getopt.getopt(sys.argv[1:], "", ["bom=", "cleanup=", "deliverydir="]) + except getopt.GetoptError as err: + print str(err) + return False + + for option, value in opts: + if option == "--bom": + bom_file = value + if not os.path.exists(os.path.join(local_path, bom_file)): + return False + + if option == "--cleanup": + cleanup = value + if cleanup.lower() != "true" and cleanup.lower() != "false": + return False + if cleanup.lower() == "false": + cleanup = False + + if option == "--deliverydir": + deliverydir = value + + + if bom_file == "": + return False + + return True + +################################################################################ +# Name: copy_folder_unrecursively() # +# Usage: # +# return: True if the operation is successful. False otherwise. # +################################################################################ +def copy_folder_unrecursively(src_dir, dest_dir): + if os.path.isdir(src_dir) == True : + print "Warning: The src is a fold ......" + return False + + #print "copy" + src_dir + "->" + dest_dir + try: + shutil.copy(src_dir, dest_dir) + return True + except: + print "Error !!!: can't find file:" + src_dir + return False + +################################################################################ +# Name: copy_folder_recursively() # +# Usage: # +################################################################################ +def copy_folder_recursively(src_dir, dest_dir): + if os.path.isdir(src_dir) == True: + #copy the folder + if os.path.exists(dest_dir) == False: + os.makedirs(dest_dir) + + for item in os.listdir(src_dir): + #print (os.path.join(src_dir, item)).replace("\\", "/") + copy_folder_recursively((os.path.join(src_dir, item)).replace("\\", "/"), (os.path.join(dest_dir, item)).replace("\\", "/")) + continue + else: + #copy the file + print "copy file from " + src_dir + " to " + dest_dir + shutil.copyfile(src_dir, dest_dir) + + + #if os.path.isdir(src_dir) == False or os.path.isdir(dest_dir) == False: + # print "Bom file error at copying " + src_dir + " to " + dest_dir + # exit(-1) + + +################################################################################ +# Name: read_BOM() # +# Usage: read bom_file # +# return: the contents in bom_file # +################################################################################ +def read_BOM(local_path): + #get the BOM file path that need to open + file_list = local_path + "/" + bom_file + f = open(file_list, 'r') + #read the content in BOM file + lines = f.readlines() + f.close() + return lines + +################################################################################ +# Name: copy_files() # +# Usage: copy file from src to dest # +# return: # +################################################################################ +def copy_txt_files(local_path): + home_path = os.path.realpath(os.path.join(local_path, "..", "..", "..", "..")) + + #read BOM file contents + lines = read_BOM(local_path) + + for line in lines[1:]: + if line == "\n": + continue + src = line.split('\t')[0] + dest = line.split('\t')[1] + src = src.replace("\\", "/") + dest = dest.replace("\\", "/") + if deliverydir == "": + src = src.replace("/", home_path + "/") + else: + src = src.replace("/", deliverydir + "/") + dest = dest.replace("/", local_path + "/output/") + #print "copy folder from " + src + " to " + dest + + if os.path.exists(src) == True: + #check whether the src is a fold or file + if os.path.isdir(src) == False : + #the src is a file + if os.path.exists(os.path.dirname(dest)) == False: + os.makedirs(os.path.dirname(dest)) + ret = copy_folder_unrecursively(src, dest) + if ret == False: + break + + else: + #the src is a fold + copy_folder_recursively(src, dest) + else: + #although the src file isn't exist, create the dest folder + if os.path.exists(os.path.dirname(dest)) == False: + os.makedirs(os.path.dirname(dest)) + print "Error !!!: src folder not exist" + src + + +if __name__ == "__main__": + ret = parse_cmd(len(sys.argv), sys.argv) + if ret == False: + print "Usage:" + print "python gen_source.py --bom=PATH_TO_BOM [--cleanup=false] [--deliverydir=DIR_RELATIVE_TO_gen_source.py]" + exit(1) + + #script locate direction + local_path = os.path.split(os.path.realpath(sys.argv[0]))[0] + local_dir = os.path.basename(local_path) + local_path = local_path.replace("\\", "/") + + ret = os.path.exists(local_path + "/output") + if ret == True: + if cleanup == True: + print "clean the dest dir" + shutil.rmtree(local_path + "/output") + os.mkdir(local_path + "/output") + else: + print "Create the dest dir" + os.mkdir(local_path + "/output") + + #cpoy the files + copy_txt_files(local_path) + + print "Copy files finished ......" + exit(0) diff --git a/linux/installer/common/licenses/BOM_license.txt b/linux/installer/common/licenses/BOM_license.txt new file mode 100644 index 0000000000..e03073c637 --- /dev/null +++ b/linux/installer/common/licenses/BOM_license.txt @@ -0,0 +1,2 @@ +DeliveryName InstallName FileCheckSum FileFeature FileOwner +/License.txt /package/licenses/License.txt 0 main STP diff --git a/linux/installer/common/psw/BOMs/psw_base.txt b/linux/installer/common/psw/BOMs/psw_base.txt new file mode 100644 index 0000000000..5a5325372b --- /dev/null +++ b/linux/installer/common/psw/BOMs/psw_base.txt @@ -0,0 +1,12 @@ +DeliveryName InstallName FileCheckSum FileFeature FileOwner +/build/linux/aesmd.conf /package/aesm/aesmd.conf 0 main STP +/build/linux/aesmd.service /package/aesm/aesmd.service 0 main STP +/build/linux/aesm_service /package/aesm/aesm_service 0 main STP +/build/linux/le_prod_css.bin /package/aesm/le_prod_css.bin 0 main STP +/build/linux/libsgx_le.signed.so /package/aesm/libsgx_le.signed.so 0 main STP +/build/linux/libsgx_pve.signed.so /package/aesm/libsgx_pve.signed.so 0 main STP +/build/linux/libsgx_qe.signed.so /package/aesm/libsgx_qe.signed.so 0 main STP +/linux/installer/common/psw/install.sh /scripts/install.sh 0 main STP +/linux/installer/common/psw/Makefile /Makefile 0 main STP +/psw/ae/aesm_service/config/network/aesmd.conf /package/aesm/conf/aesmd.conf 0 main STP +/psw/ae/aesm_service/data/white_list_cert_to_be_verify.bin /package/aesm/data/white_list_cert_to_be_verify.bin 0 main STP diff --git a/linux/installer/common/psw/BOMs/psw_x64.txt b/linux/installer/common/psw/BOMs/psw_x64.txt new file mode 100644 index 0000000000..88502f37a6 --- /dev/null +++ b/linux/installer/common/psw/BOMs/psw_x64.txt @@ -0,0 +1,4 @@ +DeliveryName InstallName FileCheckSum FileFeature FileOwner +/build/linux/libsgx_uae_service.so /package/lib64/libsgx_uae_service.so 0 main STP +/build/linux/libsgx_urts.so /package/lib64/libsgx_urts.so 0 main STP +/linux/installer/common/psw/installConfig.x64 /scripts/installConfig 0 main STP diff --git a/linux/installer/common/psw/BOMs/psw_x86.txt b/linux/installer/common/psw/BOMs/psw_x86.txt new file mode 100644 index 0000000000..715c3db84d --- /dev/null +++ b/linux/installer/common/psw/BOMs/psw_x86.txt @@ -0,0 +1,4 @@ +DeliveryName InstallName FileCheckSum FileFeature FileOwner +/build/linux/libsgx_uae_service.so /package/lib/libsgx_uae_service.so 0 main STP +/build/linux/libsgx_urts.so /package/lib/libsgx_urts.so 0 main STP +/linux/installer/common/psw/installConfig.x86 /scripts/installConfig 0 main STP diff --git a/linux/installer/common/psw/Makefile b/linux/installer/common/psw/Makefile new file mode 100644 index 0000000000..648f6ee7b0 --- /dev/null +++ b/linux/installer/common/psw/Makefile @@ -0,0 +1,52 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include scripts/installConfig + +SOURCE_FOLDER=package +SCRIPTS_FOLDER=scripts + +INSTALL_PATH=$(DESTDIR)/$(SGX_PACKAGES_PATH)/$(PSW_PKG_NAME) +SOURCE_INSTALL_PATH=$(INSTALL_PATH) +SCRIPTS_INSTALL_PATH=$(INSTALL_PATH)/$(SCRIPTS_FOLDER) +PSW_LIB_PATH=$(SOURCE_INSTALL_PATH)/$(LIB_DIR) + +default: + +install: + install -d $(SOURCE_INSTALL_PATH) + install -d $(SCRIPTS_INSTALL_PATH) + install -d $(DESTDIR)/usr/lib + cp -r $(SOURCE_FOLDER)/* $(SOURCE_INSTALL_PATH) + install $(SCRIPTS_FOLDER)/* $(SCRIPTS_INSTALL_PATH) + mv $(PSW_LIB_PATH)/libsgx_uae_service.so $(DESTDIR)/usr/lib + mv $(PSW_LIB_PATH)/libsgx_urts.so $(DESTDIR)/usr/lib + rmdir $(PSW_LIB_PATH) diff --git a/linux/installer/common/psw/createTarball.sh b/linux/installer/common/psw/createTarball.sh new file mode 100755 index 0000000000..79d1df3506 --- /dev/null +++ b/linux/installer/common/psw/createTarball.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +set -e + +SCRIPT_DIR=$(dirname "$0") +ROOT_DIR="${SCRIPT_DIR}/../../../../" +BUILD_DIR="${ROOT_DIR}/build/linux" +LINUX_INSTALLER_DIR="${ROOT_DIR}/linux/installer" +LINUX_INSTALLER_COMMON_DIR="${LINUX_INSTALLER_DIR}/common" + +INSTALL_PATH=${SCRIPT_DIR}/output + +# Cleanup +rm -fr ${INSTALL_PATH} + +# Get the architecture of the build from generated binary +get_arch() +{ + local a=$(readelf -h $BUILD_DIR/sgx_sign | awk '/Class:/{print $2}') + test $a = ELF64 && echo 'x64' || echo 'x86' +} + +ARCH=$(get_arch) + +# Fetch the gen_source script +cp ${LINUX_INSTALLER_COMMON_DIR}/gen_source/gen_source.py ${SCRIPT_DIR} + +# Copy the files according to the BOM +python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/psw_base.txt +python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/psw_${ARCH}.txt --cleanup=false +python ${SCRIPT_DIR}/gen_source.py --bom=../licenses/BOM_license.txt --cleanup=false + +# Create the tarball +source ${SCRIPT_DIR}/installConfig.${ARCH} + +pushd ${INSTALL_PATH} &> /dev/null +tar -zcvf ${TARBALL_NAME} * +popd &> /dev/null diff --git a/linux/installer/common/psw/install.sh b/linux/installer/common/psw/install.sh new file mode 100755 index 0000000000..5e38a9b449 --- /dev/null +++ b/linux/installer/common/psw/install.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +set -e + +SCRIPT_DIR=$(dirname "$0") +source ${SCRIPT_DIR}/installConfig + +PSW_DST_PATH=${SGX_PACKAGES_PATH}/${PSW_PKG_NAME} +AESM_PATH=$PSW_DST_PATH/aesm + +# Install the AESM service + +cut -d: -f1 /etc/passwd | grep -q -w aesmd || \ + /usr/sbin/useradd -r -c "User for aesmd" \ + -d /var/opt/aesmd -s /sbin/nologin aesmd + +mkdir -p /var/opt/aesmd +cp -rf $AESM_PATH/data /var/opt/aesmd/ +rm -rf $AESM_PATH/data +cp -rf $AESM_PATH/conf/aesmd.conf /etc/aesmd.conf +rm -rf $AESM_PATH/conf +chmod 0644 /etc/aesmd.conf +chown -R aesmd /var/opt/aesmd +chmod 0750 /var/opt/aesmd + +if [ -d /run/systemd/system ]; then + AESMD_NAME=aesmd.service + AESMD_TEMP=$AESM_PATH/$AESMD_NAME + if [ -d /lib/systemd/system ]; then + AESMD_DEST=/lib/systemd/system/$AESMD_NAME + else + AESMD_DEST=/usr/lib/systemd/system/$AESMD_NAME + fi + echo -n "Installing $AESMD_NAME service ..." + sed -e "s:@aesm_folder@:$AESM_PATH:" \ + $AESMD_TEMP > $AESMD_DEST + chmod 0644 $AESMD_DEST + rm -f $AESMD_TEMP + rm -f $AESM_PATH/aesmd.conf + DISABLE_AESMD="systemctl disable aesmd" + systemctl enable aesmd + retval=$? +elif [ -d /etc/init/ ]; then + AESMD_NAME=aesmd.conf + AESMD_TEMP=$AESM_PATH/$AESMD_NAME + AESMD_DEST=/etc/init/$AESMD_NAME + echo -n "Installing $AESMD_NAME service ..." + sed -e "s:@aesm_folder@:$AESM_PATH:" \ + $AESMD_TEMP > $AESMD_DEST + chmod 0644 $AESMD_DEST + rm -f $AESMD_TEMP + rm -f $AESM_PATH/aesmd.service + sudo /sbin/initctl reload-configuration + retval=$? +else + echo " failed." + echo "Unsupported platform - neither systemctl nor initctl is found." + exit 5 +fi + +if test $retval -ne 0; then + echo "$rcmngr failed to install $AESMD_NAME." + exit 6 +fi + +echo " done." + + +cat > $PSW_DST_PATH/uninstall.sh </build/linux/libsample_libcrypto.so /package/SampleCode/RemoteAttestation/sample_libcrypto/libsample_libcrypto.so 0 main STP +/common/inc/sgx_attributes.h /package/include/./sgx_attributes.h 0 main STP +/common/inc/sgx_cpuid.h /package/include/./sgx_cpuid.h 0 main STP +/common/inc/sgx_defs.h /package/include/./sgx_defs.h 0 main STP +/common/inc/sgx_dh.h /package/include/./sgx_dh.h 0 main STP +/common/inc/sgx_ecp_types.h /package/include/./sgx_ecp_types.h 0 main STP +/common/inc/sgx_edger8r.h /package/include/./sgx_edger8r.h 0 main STP +/common/inc/sgx_eid.h /package/include/./sgx_eid.h 0 main STP +/common/inc/sgx_error.h /package/include/./sgx_error.h 0 main STP +/common/inc/sgx.h /package/include/./sgx.h 0 main STP +/common/inc/sgx_intrin.h /package/include/./sgx_intrin.h 0 main STP +/common/inc/sgx_key_exchange.h /package/include/./sgx_key_exchange.h 0 main STP +/common/inc/sgx_key.h /package/include/./sgx_key.h 0 main STP +/common/inc/sgx_quote.h /package/include/./sgx_quote.h 0 main STP +/common/inc/sgx_report.h /package/include/./sgx_report.h 0 main STP +/common/inc/sgx_spinlock.h /package/include/./sgx_spinlock.h 0 main STP +/common/inc/sgx_tae_service.edl /package/include/./sgx_tae_service.edl 0 main STP +/common/inc/sgx_tae_service.h /package/include/./sgx_tae_service.h 0 main STP +/common/inc/sgx_tcrypto.h /package/include/./sgx_tcrypto.h 0 main STP +/common/inc/sgx_thread.h /package/include/./sgx_thread.h 0 main STP +/common/inc/sgx_tkey_exchange.edl /package/include/./sgx_tkey_exchange.edl 0 main STP +/common/inc/sgx_tkey_exchange.h /package/include/./sgx_tkey_exchange.h 0 main STP +/common/inc/sgx_trts_exception.h /package/include/./sgx_trts_exception.h 0 main STP +/common/inc/sgx_trts.h /package/include/./sgx_trts.h 0 main STP +/common/inc/sgx_tseal.h /package/include/./sgx_tseal.h 0 main STP +/common/inc/sgx_tstdc.edl /package/include/./sgx_tstdc.edl 0 main STP +/common/inc/sgx_uae_service.h /package/include/./sgx_uae_service.h 0 main STP +/common/inc/sgx_ukey_exchange.h /package/include/./sgx_ukey_exchange.h 0 main STP +/common/inc/sgx_urts.h /package/include/./sgx_urts.h 0 main STP +/common/inc/sgx_utils.h /package/include/./sgx_utils.h 0 main STP +/common/inc/stdc++/exception /package/include/stdc++/exception 0 main STP +/common/inc/stdc++/linux/exception /package/include/stdc++/linux/exception 0 main STP +/common/inc/stdc++/linux/typeinfo /package/include/stdc++/linux/typeinfo 0 main STP +/common/inc/stdc++/new /package/include/stdc++/new 0 main STP +/common/inc/stdc++/typeinfo /package/include/stdc++/typeinfo 0 main STP +/common/inc/tlibc/assert.h /package/include/tlibc/assert.h 0 main STP +/common/inc/tlibc/ctype.h /package/include/tlibc/ctype.h 0 main STP +/common/inc/tlibc/endian.h /package/include/tlibc/endian.h 0 main STP +/common/inc/tlibc/errno.h /package/include/tlibc/errno.h 0 main STP +/common/inc/tlibc/float.h /package/include/tlibc/float.h 0 main STP +/common/inc/tlibc/inttypes.h /package/include/tlibc/inttypes.h 0 main STP +/common/inc/tlibc/iso646.h /package/include/tlibc/iso646.h 0 main STP +/common/inc/tlibc/limits.h /package/include/tlibc/limits.h 0 main STP +/common/inc/tlibc/math.h /package/include/tlibc/math.h 0 main STP +/common/inc/tlibc/stdarg.h /package/include/tlibc/stdarg.h 0 main STP +/common/inc/tlibc/stdbool.h /package/include/tlibc/stdbool.h 0 main STP +/common/inc/tlibc/stddef.h /package/include/tlibc/stddef.h 0 main STP +/common/inc/tlibc/stdint.h /package/include/tlibc/stdint.h 0 main STP +/common/inc/tlibc/stdio.h /package/include/tlibc/stdio.h 0 main STP +/common/inc/tlibc/stdlib.h /package/include/tlibc/stdlib.h 0 main STP +/common/inc/tlibc/string.h /package/include/tlibc/string.h 0 main STP +/common/inc/tlibc/sys/cdefs.h /package/include/tlibc/sys/cdefs.h 0 main STP +/common/inc/tlibc/sys/endian.h /package/include/tlibc/sys/endian.h 0 main STP +/common/inc/tlibc/sys/limits.h /package/include/tlibc/sys/limits.h 0 main STP +/common/inc/tlibc/sys/stdint.h /package/include/tlibc/sys/stdint.h 0 main STP +/common/inc/tlibc/sys/_types.h /package/include/tlibc/sys/_types.h 0 main STP +/common/inc/tlibc/sys/types.h /package/include/tlibc/sys/types.h 0 main STP +/common/inc/tlibc/time.h /package/include/tlibc/time.h 0 main STP +/common/inc/tlibc/unistd.h /package/include/tlibc/unistd.h 0 main STP +/common/inc/tlibc/wchar.h /package/include/tlibc/wchar.h 0 main STP +/common/inc/tlibc/wctype.h /package/include/tlibc/wctype.h 0 main STP +/common/src/se_memory.c /package/ptrace/se_memory.c 0 main STP +/common/src/se_trace.c /package/ptrace/se_trace.c 0 main STP +/linux/installer/common/sdk/install.sh /scripts/install.sh 0 main STP +/linux/installer/common/sdk/Makefile /Makefile 0 main STP +/SampleCode/LocalAttestation/App/App.cpp /package/SampleCode/LocalAttestation/App/App.cpp 0 main STP +/SampleCode/LocalAttestation/.cproject /package/SampleCode/LocalAttestation/.cproject 0 main STP +/SampleCode/LocalAttestation/Enclave1/Enclave1.config.xml /package/SampleCode/LocalAttestation/Enclave1/Enclave1.config.xml 0 main STP +/SampleCode/LocalAttestation/Enclave1/Enclave1.cpp /package/SampleCode/LocalAttestation/Enclave1/Enclave1.cpp 0 main STP +/SampleCode/LocalAttestation/Enclave1/Enclave1.edl /package/SampleCode/LocalAttestation/Enclave1/Enclave1.edl 0 main STP +/SampleCode/LocalAttestation/Enclave1/Enclave1_private.pem /package/SampleCode/LocalAttestation/Enclave1/Enclave1_private.pem 0 main STP +/SampleCode/LocalAttestation/Enclave1/Utility_E1.cpp /package/SampleCode/LocalAttestation/Enclave1/Utility_E1.cpp 0 main STP +/SampleCode/LocalAttestation/Enclave1/Utility_E1.h /package/SampleCode/LocalAttestation/Enclave1/Utility_E1.h 0 main STP +/SampleCode/LocalAttestation/Enclave2/Enclave2.config.xml /package/SampleCode/LocalAttestation/Enclave2/Enclave2.config.xml 0 main STP +/SampleCode/LocalAttestation/Enclave2/Enclave2.cpp /package/SampleCode/LocalAttestation/Enclave2/Enclave2.cpp 0 main STP +/SampleCode/LocalAttestation/Enclave2/Enclave2.edl /package/SampleCode/LocalAttestation/Enclave2/Enclave2.edl 0 main STP +/SampleCode/LocalAttestation/Enclave2/Enclave2_private.pem /package/SampleCode/LocalAttestation/Enclave2/Enclave2_private.pem 0 main STP +/SampleCode/LocalAttestation/Enclave2/Utility_E2.cpp /package/SampleCode/LocalAttestation/Enclave2/Utility_E2.cpp 0 main STP +/SampleCode/LocalAttestation/Enclave2/Utility_E2.h /package/SampleCode/LocalAttestation/Enclave2/Utility_E2.h 0 main STP +/SampleCode/LocalAttestation/Enclave3/Enclave3.config.xml /package/SampleCode/LocalAttestation/Enclave3/Enclave3.config.xml 0 main STP +/SampleCode/LocalAttestation/Enclave3/Enclave3.cpp /package/SampleCode/LocalAttestation/Enclave3/Enclave3.cpp 0 main STP +/SampleCode/LocalAttestation/Enclave3/Enclave3.edl /package/SampleCode/LocalAttestation/Enclave3/Enclave3.edl 0 main STP +/SampleCode/LocalAttestation/Enclave3/Enclave3_private.pem /package/SampleCode/LocalAttestation/Enclave3/Enclave3_private.pem 0 main STP +/SampleCode/LocalAttestation/Enclave3/Utility_E3.cpp /package/SampleCode/LocalAttestation/Enclave3/Utility_E3.cpp 0 main STP +/SampleCode/LocalAttestation/Enclave3/Utility_E3.h /package/SampleCode/LocalAttestation/Enclave3/Utility_E3.h 0 main STP +/SampleCode/LocalAttestation/Include/dh_session_protocol.h /package/SampleCode/LocalAttestation/Include/dh_session_protocol.h 0 main STP +/SampleCode/LocalAttestation/LocalAttestationCode/datatypes.h /package/SampleCode/LocalAttestation/LocalAttestationCode/datatypes.h 0 main STP +/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.cpp /package/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.cpp 0 main STP +/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.h /package/SampleCode/LocalAttestation/LocalAttestationCode/EnclaveMessageExchange.h 0 main STP +/SampleCode/LocalAttestation/LocalAttestationCode/error_codes.h /package/SampleCode/LocalAttestation/LocalAttestationCode/error_codes.h 0 main STP +/SampleCode/LocalAttestation/LocalAttestationCode/LocalAttestationCode.edl /package/SampleCode/LocalAttestation/LocalAttestationCode/LocalAttestationCode.edl 0 main STP +/SampleCode/LocalAttestation/Makefile /package/SampleCode/LocalAttestation/Makefile 0 main STP +/SampleCode/LocalAttestation/README.txt /package/SampleCode/LocalAttestation/README.txt 0 main STP +/SampleCode/LocalAttestation/.project /package/SampleCode/LocalAttestation/.project 0 main STP +/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.cpp /package/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.cpp 0 main STP +/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.h /package/SampleCode/LocalAttestation/Untrusted_LocalAttestation/UntrustedEnclaveMessageExchange.h 0 main STP +/SampleCode/PowerTransition/App/App.cpp /package/SampleCode/PowerTransition/App/App.cpp 0 main STP +/SampleCode/PowerTransition/App/ErrorSupport.cpp /package/SampleCode/PowerTransition/App/ErrorSupport.cpp 0 main STP +/SampleCode/PowerTransition/App/ErrorSupport.h /package/SampleCode/PowerTransition/App/ErrorSupport.h 0 main STP +/SampleCode/PowerTransition/App/rwlock.cpp /package/SampleCode/PowerTransition/App/rwlock.cpp 0 main STP +/SampleCode/PowerTransition/App/rwlock.h /package/SampleCode/PowerTransition/App/rwlock.h 0 main STP +/SampleCode/PowerTransition/Common/types.h /package/SampleCode/PowerTransition/Common/types.h 0 main STP +/SampleCode/PowerTransition/.cproject /package/SampleCode/PowerTransition/.cproject 0 main STP +/SampleCode/PowerTransition/Enclave/Enclave.config.xml /package/SampleCode/PowerTransition/Enclave/Enclave.config.xml 0 main STP +/SampleCode/PowerTransition/Enclave/Enclave.cpp /package/SampleCode/PowerTransition/Enclave/Enclave.cpp 0 main STP +/SampleCode/PowerTransition/Enclave/Enclave.edl /package/SampleCode/PowerTransition/Enclave/Enclave.edl 0 main STP +/SampleCode/PowerTransition/Enclave/Enclave.lds /package/SampleCode/PowerTransition/Enclave/Enclave.lds 0 main STP +/SampleCode/PowerTransition/Enclave/Enclave_private.pem /package/SampleCode/PowerTransition/Enclave/Enclave_private.pem 0 main STP +/SampleCode/PowerTransition/Makefile /package/SampleCode/PowerTransition/Makefile 0 main STP +/SampleCode/PowerTransition/.project /package/SampleCode/PowerTransition/.project 0 main STP +/SampleCode/PowerTransition/README.txt /package/SampleCode/PowerTransition/README.txt 0 main STP +/SampleCode/RemoteAttestation/.cproject /package/SampleCode/RemoteAttestation/.cproject 0 main STP +/SampleCode/RemoteAttestation/isv_app/isv_app.cpp /package/SampleCode/RemoteAttestation/isv_app/isv_app.cpp 0 main STP +/SampleCode/RemoteAttestation/isv_app/sample_messages.h /package/SampleCode/RemoteAttestation/isv_app/sample_messages.h 0 main STP +/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.config.xml /package/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.config.xml 0 main STP +/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.cpp /package/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.cpp 0 main STP +/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.edl /package/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.edl 0 main STP +/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.lds /package/SampleCode/RemoteAttestation/isv_enclave/isv_enclave.lds 0 main STP +/SampleCode/RemoteAttestation/isv_enclave/isv_enclave_private.pem /package/SampleCode/RemoteAttestation/isv_enclave/isv_enclave_private.pem 0 main STP +/SampleCode/RemoteAttestation/Makefile /package/SampleCode/RemoteAttestation/Makefile 0 main STP +/SampleCode/RemoteAttestation/README.txt /package/SampleCode/RemoteAttestation/README.txt 0 main STP +/SampleCode/RemoteAttestation/.project /package/SampleCode/RemoteAttestation/.project 0 main STP +/SampleCode/RemoteAttestation/service_provider/ecp.cpp /package/SampleCode/RemoteAttestation/service_provider/ecp.cpp 0 main STP +/SampleCode/RemoteAttestation/service_provider/ecp.h /package/SampleCode/RemoteAttestation/service_provider/ecp.h 0 main STP +/SampleCode/RemoteAttestation/service_provider/ias_ra.cpp /package/SampleCode/RemoteAttestation/service_provider/ias_ra.cpp 0 main STP +/SampleCode/RemoteAttestation/service_provider/ias_ra.h /package/SampleCode/RemoteAttestation/service_provider/ias_ra.h 0 main STP +/SampleCode/RemoteAttestation/service_provider/network_ra.cpp /package/SampleCode/RemoteAttestation/service_provider/network_ra.cpp 0 main STP +/SampleCode/RemoteAttestation/service_provider/network_ra.h /package/SampleCode/RemoteAttestation/service_provider/network_ra.h 0 main STP +/SampleCode/RemoteAttestation/service_provider/remote_attestation_result.h /package/SampleCode/RemoteAttestation/service_provider/remote_attestation_result.h 0 main STP +/SampleCode/RemoteAttestation/service_provider/service_provider.cpp /package/SampleCode/RemoteAttestation/service_provider/service_provider.cpp 0 main STP +/SampleCode/RemoteAttestation/service_provider/service_provider.h /package/SampleCode/RemoteAttestation/service_provider/service_provider.h 0 main STP +/SampleCode/SampleEnclave/App/App.cpp /package/SampleCode/SampleEnclave/App/App.cpp 0 main STP +/SampleCode/SampleEnclave/App/App.h /package/SampleCode/SampleEnclave/App/App.h 0 main STP +/SampleCode/SampleEnclave/App/Edger8rSyntax/Arrays.cpp /package/SampleCode/SampleEnclave/App/Edger8rSyntax/Arrays.cpp 0 main STP +/SampleCode/SampleEnclave/App/Edger8rSyntax/Functions.cpp /package/SampleCode/SampleEnclave/App/Edger8rSyntax/Functions.cpp 0 main STP +/SampleCode/SampleEnclave/App/Edger8rSyntax/Pointers.cpp /package/SampleCode/SampleEnclave/App/Edger8rSyntax/Pointers.cpp 0 main STP +/SampleCode/SampleEnclave/App/Edger8rSyntax/Types.cpp /package/SampleCode/SampleEnclave/App/Edger8rSyntax/Types.cpp 0 main STP +/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp /package/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp 0 main STP +/SampleCode/SampleEnclave/App/TrustedLibrary/Libcxx.cpp /package/SampleCode/SampleEnclave/App/TrustedLibrary/Libcxx.cpp 0 main STP +/SampleCode/SampleEnclave/App/TrustedLibrary/Thread.cpp /package/SampleCode/SampleEnclave/App/TrustedLibrary/Thread.cpp 0 main STP +/SampleCode/SampleEnclave/.cproject /package/SampleCode/SampleEnclave/.cproject 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.cpp /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.edl /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Arrays.edl 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.cpp /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.edl /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Functions.edl 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.cpp /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.edl /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Pointers.edl 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.cpp /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.edl /package/SampleCode/SampleEnclave/Enclave/Edger8rSyntax/Types.edl 0 main STP +/SampleCode/SampleEnclave/Enclave/Enclave.config.xml /package/SampleCode/SampleEnclave/Enclave/Enclave.config.xml 0 main STP +/SampleCode/SampleEnclave/Enclave/Enclave.cpp /package/SampleCode/SampleEnclave/Enclave/Enclave.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/Enclave.edl /package/SampleCode/SampleEnclave/Enclave/Enclave.edl 0 main STP +/SampleCode/SampleEnclave/Enclave/Enclave.h /package/SampleCode/SampleEnclave/Enclave/Enclave.h 0 main STP +/SampleCode/SampleEnclave/Enclave/Enclave.lds /package/SampleCode/SampleEnclave/Enclave/Enclave.lds 0 main STP +/SampleCode/SampleEnclave/Enclave/Enclave_private.pem /package/SampleCode/SampleEnclave/Enclave/Enclave_private.pem 0 main STP +/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.cpp /package/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl /package/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl 0 main STP +/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.cpp /package/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.edl /package/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libcxx.edl 0 main STP +/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.cpp /package/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.cpp 0 main STP +/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.edl /package/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Thread.edl 0 main STP +/SampleCode/SampleEnclave/Include/user_types.h /package/SampleCode/SampleEnclave/Include/user_types.h 0 main STP +/SampleCode/SampleEnclave/Makefile /package/SampleCode/SampleEnclave/Makefile 0 main STP +/SampleCode/SampleEnclave/.project /package/SampleCode/SampleEnclave/.project 0 main STP +/SampleCode/SampleEnclave/README.txt /package/SampleCode/SampleEnclave/README.txt 0 main STP +/sdk/debugger_interface/linux/se_ptrace.c /package/ptrace/se_ptrace.c 0 main STP +/sdk/sample_libcrypto/sample_libcrypto.h /package/SampleCode/RemoteAttestation/sample_libcrypto/sample_libcrypto.h 0 main STP +/sdk/tlibstdcxx/stlport/algorithm /package/include/stlport/algorithm 0 main STP +/sdk/tlibstdcxx/stlport/assert.h /package/include/stlport/assert.h 0 main STP +/sdk/tlibstdcxx/stlport/bitset /package/include/stlport/bitset 0 main STP +/sdk/tlibstdcxx/stlport/cassert /package/include/stlport/cassert 0 main STP +/sdk/tlibstdcxx/stlport/cctype /package/include/stlport/cctype 0 main STP +/sdk/tlibstdcxx/stlport/cerrno /package/include/stlport/cerrno 0 main STP +/sdk/tlibstdcxx/stlport/cfloat /package/include/stlport/cfloat 0 main STP +/sdk/tlibstdcxx/stlport/ciso646 /package/include/stlport/ciso646 0 main STP +/sdk/tlibstdcxx/stlport/climits /package/include/stlport/climits 0 main STP +/sdk/tlibstdcxx/stlport/cmath /package/include/stlport/cmath 0 main STP +/sdk/tlibstdcxx/stlport/complex /package/include/stlport/complex 0 main STP +/sdk/tlibstdcxx/stlport/cstdarg /package/include/stlport/cstdarg 0 main STP +/sdk/tlibstdcxx/stlport/cstddef /package/include/stlport/cstddef 0 main STP +/sdk/tlibstdcxx/stlport/cstdio /package/include/stlport/cstdio 0 main STP +/sdk/tlibstdcxx/stlport/cstdlib /package/include/stlport/cstdlib 0 main STP +/sdk/tlibstdcxx/stlport/cstring /package/include/stlport/cstring 0 main STP +/sdk/tlibstdcxx/stlport/ctime /package/include/stlport/ctime 0 main STP +/sdk/tlibstdcxx/stlport/ctype.h /package/include/stlport/ctype.h 0 main STP +/sdk/tlibstdcxx/stlport/cwchar /package/include/stlport/cwchar 0 main STP +/sdk/tlibstdcxx/stlport/cwctype /package/include/stlport/cwctype 0 main STP +/sdk/tlibstdcxx/stlport/deque /package/include/stlport/deque 0 main STP +/sdk/tlibstdcxx/stlport/errno.h /package/include/stlport/errno.h 0 main STP +/sdk/tlibstdcxx/stlport/exception /package/include/stlport/exception 0 main STP +/sdk/tlibstdcxx/stlport/float.h /package/include/stlport/float.h 0 main STP +/sdk/tlibstdcxx/stlport/functional /package/include/stlport/functional 0 main STP +/sdk/tlibstdcxx/stlport/iso646.h /package/include/stlport/iso646.h 0 main STP +/sdk/tlibstdcxx/stlport/iterator /package/include/stlport/iterator 0 main STP +/sdk/tlibstdcxx/stlport/limits.h /package/include/stlport/limits.h 0 main STP +/sdk/tlibstdcxx/stlport/limits /package/include/stlport/limits 0 main STP +/sdk/tlibstdcxx/stlport/list /package/include/stlport/list 0 main STP +/sdk/tlibstdcxx/stlport/map /package/include/stlport/map 0 main STP +/sdk/tlibstdcxx/stlport/math.h /package/include/stlport/math.h 0 main STP +/sdk/tlibstdcxx/stlport/memory /package/include/stlport/memory 0 main STP +/sdk/tlibstdcxx/stlport/new.h /package/include/stlport/new.h 0 main STP +/sdk/tlibstdcxx/stlport/new /package/include/stlport/new 0 main STP +/sdk/tlibstdcxx/stlport/numeric /package/include/stlport/numeric 0 main STP +/sdk/tlibstdcxx/stlport/queue /package/include/stlport/queue 0 main STP +/sdk/tlibstdcxx/stlport/set /package/include/stlport/set 0 main STP +/sdk/tlibstdcxx/stlport/stack /package/include/stlport/stack 0 main STP +/sdk/tlibstdcxx/stlport/stdarg.h /package/include/stlport/stdarg.h 0 main STP +/sdk/tlibstdcxx/stlport/stddef.h /package/include/stlport/stddef.h 0 main STP +/sdk/tlibstdcxx/stlport/stdexcept /package/include/stlport/stdexcept 0 main STP +/sdk/tlibstdcxx/stlport/stdio.h /package/include/stlport/stdio.h 0 main STP +/sdk/tlibstdcxx/stlport/stdlib.h /package/include/stlport/stdlib.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_abbrevs.h /package/include/stlport/stl/_abbrevs.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_algobase.c /package/include/stlport/stl/_algobase.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_algobase.h /package/include/stlport/stl/_algobase.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_algo.c /package/include/stlport/stl/_algo.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_algo.h /package/include/stlport/stl/_algo.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_alloc.c /package/include/stlport/stl/_alloc.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_alloc.h /package/include/stlport/stl/_alloc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_auto_ptr.h /package/include/stlport/stl/_auto_ptr.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_bitset.c /package/include/stlport/stl/_bitset.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_bitset.h /package/include/stlport/stl/_bitset.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/boost_type_traits.h /package/include/stlport/stl/boost_type_traits.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_bvector.h /package/include/stlport/stl/_bvector.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_carray.h /package/include/stlport/stl/_carray.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cctype.h /package/include/stlport/stl/_cctype.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/char_traits.h /package/include/stlport/stl/char_traits.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_clocale.h /package/include/stlport/stl/_clocale.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/c_locale.h /package/include/stlport/stl/c_locale.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cmath.h /package/include/stlport/stl/_cmath.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_codecvt.h /package/include/stlport/stl/_codecvt.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_collate.h /package/include/stlport/stl/_collate.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_complex.c /package/include/stlport/stl/_complex.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_complex.h /package/include/stlport/stl/_complex.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/concept_checks.h /package/include/stlport/stl/concept_checks.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_aix.h /package/include/stlport/stl/config/_aix.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_apcc.h /package/include/stlport/stl/config/_apcc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_apple.h /package/include/stlport/stl/config/_apple.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_as400.h /package/include/stlport/stl/config/_as400.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_auto_link.h /package/include/stlport/stl/config/_auto_link.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_bc.h /package/include/stlport/stl/config/_bc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_como.h /package/include/stlport/stl/config/_como.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/compat.h /package/include/stlport/stl/config/compat.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_config_compat_post.h /package/include/stlport/stl/_config_compat_post.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_cray.h /package/include/stlport/stl/config/_cray.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_cygwin.h /package/include/stlport/stl/config/_cygwin.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_dec.h /package/include/stlport/stl/config/_dec.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_dec_vms.h /package/include/stlport/stl/config/_dec_vms.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_detect_dll_or_lib.h /package/include/stlport/stl/config/_detect_dll_or_lib.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_dm.h /package/include/stlport/stl/config/_dm.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_epilog.h /package/include/stlport/stl/config/_epilog.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_evc.h /package/include/stlport/stl/config/_evc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/features.h /package/include/stlport/stl/config/features.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_feedback.h /package/include/stlport/stl/config/_feedback.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_freebsd.h /package/include/stlport/stl/config/_freebsd.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_fujitsu.h /package/include/stlport/stl/config/_fujitsu.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_gcc.h /package/include/stlport/stl/config/_gcc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/host.h /package/include/stlport/stl/config/host.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_hpacc.h /package/include/stlport/stl/config/_hpacc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_hpux.h /package/include/stlport/stl/config/_hpux.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_ibm.h /package/include/stlport/stl/config/_ibm.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_icc.h /package/include/stlport/stl/config/_icc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_intel.h /package/include/stlport/stl/config/_intel.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_kai.h /package/include/stlport/stl/config/_kai.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_linux.h /package/include/stlport/stl/config/_linux.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_mac.h /package/include/stlport/stl/config/_mac.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_macosx.h /package/include/stlport/stl/config/_macosx.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_mlc.h /package/include/stlport/stl/config/_mlc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_msvc.h /package/include/stlport/stl/config/_msvc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_mwerks.h /package/include/stlport/stl/config/_mwerks.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_native_headers.h /package/include/stlport/stl/config/_native_headers.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_openbsd.h /package/include/stlport/stl/config/_openbsd.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_prolog.h /package/include/stlport/stl/config/_prolog.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_sgi.h /package/include/stlport/stl/config/_sgi.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_sgx.h /package/include/stlport/stl/config/_sgx.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_solaris.h /package/include/stlport/stl/config/_solaris.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/stl_confix.h /package/include/stlport/stl/config/stl_confix.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/stl_mycomp.h /package/include/stlport/stl/config/stl_mycomp.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_sunprocc.h /package/include/stlport/stl/config/_sunprocc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_system.h /package/include/stlport/stl/config/_system.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/user_config.h /package/include/stlport/stl/config/user_config.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_warnings_off.h /package/include/stlport/stl/config/_warnings_off.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_watcom.h /package/include/stlport/stl/config/_watcom.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/config/_windows.h /package/include/stlport/stl/config/_windows.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_construct.h /package/include/stlport/stl/_construct.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cprolog.h /package/include/stlport/stl/_cprolog.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_csetjmp.h /package/include/stlport/stl/_csetjmp.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_csignal.h /package/include/stlport/stl/_csignal.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cstdarg.h /package/include/stlport/stl/_cstdarg.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cstddef.h /package/include/stlport/stl/_cstddef.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cstdio.h /package/include/stlport/stl/_cstdio.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cstdlib.h /package/include/stlport/stl/_cstdlib.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cstring.h /package/include/stlport/stl/_cstring.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ctime.h /package/include/stlport/stl/_ctime.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ctraits_fns.h /package/include/stlport/stl/_ctraits_fns.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ctype.h /package/include/stlport/stl/_ctype.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cwchar.h /package/include/stlport/stl/_cwchar.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_cwctype.h /package/include/stlport/stl/_cwctype.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/debug/_debug.h /package/include/stlport/stl/debug/_debug.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_deque.c /package/include/stlport/stl/_deque.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_deque.h /package/include/stlport/stl/_deque.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_epilog.h /package/include/stlport/stl/_epilog.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_exception.h /package/include/stlport/stl/_exception.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_facets_fwd.h /package/include/stlport/stl/_facets_fwd.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_fstream.c /package/include/stlport/stl/_fstream.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_fstream.h /package/include/stlport/stl/_fstream.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_function_adaptors.h /package/include/stlport/stl/_function_adaptors.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_function_base.h /package/include/stlport/stl/_function_base.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_function.h /package/include/stlport/stl/_function.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_hash_fun.h /package/include/stlport/stl/_hash_fun.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_hash_map.h /package/include/stlport/stl/_hash_map.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_hash_set.h /package/include/stlport/stl/_hash_set.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_hashtable.c /package/include/stlport/stl/_hashtable.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_hashtable.h /package/include/stlport/stl/_hashtable.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_heap.c /package/include/stlport/stl/_heap.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_heap.h /package/include/stlport/stl/_heap.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_iomanip.h /package/include/stlport/stl/_iomanip.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ios_base.h /package/include/stlport/stl/_ios_base.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ios.c /package/include/stlport/stl/_ios.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ioserr.h /package/include/stlport/stl/_ioserr.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_iosfwd.h /package/include/stlport/stl/_iosfwd.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ios.h /package/include/stlport/stl/_ios.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_iostream_string.h /package/include/stlport/stl/_iostream_string.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_istreambuf_iterator.h /package/include/stlport/stl/_istreambuf_iterator.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_istream.c /package/include/stlport/stl/_istream.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_istream.h /package/include/stlport/stl/_istream.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_iterator_base.h /package/include/stlport/stl/_iterator_base.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_iterator.h /package/include/stlport/stl/_iterator.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_iterator_old.h /package/include/stlport/stl/_iterator_old.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_limits.c /package/include/stlport/stl/_limits.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_limits.h /package/include/stlport/stl/_limits.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_list.c /package/include/stlport/stl/_list.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_list.h /package/include/stlport/stl/_list.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_locale.h /package/include/stlport/stl/_locale.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_map.h /package/include/stlport/stl/_map.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_mbstate_t.h /package/include/stlport/stl/_mbstate_t.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_messages_facets.h /package/include/stlport/stl/_messages_facets.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_monetary.c /package/include/stlport/stl/_monetary.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_monetary.h /package/include/stlport/stl/_monetary.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_move_construct_fwk.h /package/include/stlport/stl/_move_construct_fwk.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/msl_string.h /package/include/stlport/stl/msl_string.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_new.h /package/include/stlport/stl/_new.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_numeric.c /package/include/stlport/stl/_numeric.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_numeric.h /package/include/stlport/stl/_numeric.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_num_get.c /package/include/stlport/stl/_num_get.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_num_get.h /package/include/stlport/stl/_num_get.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_numpunct.h /package/include/stlport/stl/_numpunct.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_num_put.c /package/include/stlport/stl/_num_put.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_num_put.h /package/include/stlport/stl/_num_put.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ostreambuf_iterator.h /package/include/stlport/stl/_ostreambuf_iterator.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ostream.c /package/include/stlport/stl/_ostream.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ostream.h /package/include/stlport/stl/_ostream.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_pair.h /package/include/stlport/stl/_pair.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/pointers/_deque.h /package/include/stlport/stl/pointers/_deque.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/pointers/_list.h /package/include/stlport/stl/pointers/_list.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/pointers/_set.h /package/include/stlport/stl/pointers/_set.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/pointers/_slist.h /package/include/stlport/stl/pointers/_slist.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/pointers/_tools.h /package/include/stlport/stl/pointers/_tools.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/pointers/_vector.h /package/include/stlport/stl/pointers/_vector.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_prolog.h /package/include/stlport/stl/_prolog.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_pthread_alloc.h /package/include/stlport/stl/_pthread_alloc.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_ptrs_specialize.h /package/include/stlport/stl/_ptrs_specialize.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_queue.h /package/include/stlport/stl/_queue.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_range_errors.c /package/include/stlport/stl/_range_errors.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_range_errors.h /package/include/stlport/stl/_range_errors.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_raw_storage_iter.h /package/include/stlport/stl/_raw_storage_iter.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_relops_cont.h /package/include/stlport/stl/_relops_cont.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_relops_hash_cont.h /package/include/stlport/stl/_relops_hash_cont.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_rope.c /package/include/stlport/stl/_rope.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_rope.h /package/include/stlport/stl/_rope.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_set.h /package/include/stlport/stl/_set.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_slist_base.c /package/include/stlport/stl/_slist_base.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_slist_base.h /package/include/stlport/stl/_slist_base.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_slist.c /package/include/stlport/stl/_slist.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_slist.h /package/include/stlport/stl/_slist.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_sparc_atomic.h /package/include/stlport/stl/_sparc_atomic.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_sstream.c /package/include/stlport/stl/_sstream.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_sstream.h /package/include/stlport/stl/_sstream.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_stack.h /package/include/stlport/stl/_stack.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.c /package/include/stlport/stl/_stdexcept_base.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.h /package/include/stlport/stl/_stdexcept_base.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_stdexcept.h /package/include/stlport/stl/_stdexcept.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_stlport_version.h /package/include/stlport/stl/_stlport_version.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_streambuf.c /package/include/stlport/stl/_streambuf.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_streambuf.h /package/include/stlport/stl/_streambuf.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_stream_iterator.h /package/include/stlport/stl/_stream_iterator.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_base.h /package/include/stlport/stl/_string_base.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string.c /package/include/stlport/stl/_string.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_fwd.h /package/include/stlport/stl/_string_fwd.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_hash.h /package/include/stlport/stl/_string_hash.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string.h /package/include/stlport/stl/_string.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_io.c /package/include/stlport/stl/_string_io.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_io.h /package/include/stlport/stl/_string_io.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_npos.h /package/include/stlport/stl/_string_npos.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_operators.h /package/include/stlport/stl/_string_operators.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_sum.h /package/include/stlport/stl/_string_sum.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_sum_methods.h /package/include/stlport/stl/_string_sum_methods.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_string_workaround.h /package/include/stlport/stl/_string_workaround.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_strstream.h /package/include/stlport/stl/_strstream.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_tempbuf.c /package/include/stlport/stl/_tempbuf.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_tempbuf.h /package/include/stlport/stl/_tempbuf.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_threads.c /package/include/stlport/stl/_threads.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_threads.h /package/include/stlport/stl/_threads.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_time_facets.c /package/include/stlport/stl/_time_facets.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_time_facets.h /package/include/stlport/stl/_time_facets.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_tree.c /package/include/stlport/stl/_tree.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_tree.h /package/include/stlport/stl/_tree.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_typeinfo.h /package/include/stlport/stl/_typeinfo.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/type_manips.h /package/include/stlport/stl/type_manips.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/type_traits.h /package/include/stlport/stl/type_traits.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_uninitialized.h /package/include/stlport/stl/_uninitialized.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_unordered_map.h /package/include/stlport/stl/_unordered_map.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_unordered_set.h /package/include/stlport/stl/_unordered_set.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_valarray.c /package/include/stlport/stl/_valarray.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_valarray.h /package/include/stlport/stl/_valarray.h 0 main STP +/sdk/tlibstdcxx/stlport/stl/_vector.c /package/include/stlport/stl/_vector.c 0 main STP +/sdk/tlibstdcxx/stlport/stl/_vector.h /package/include/stlport/stl/_vector.h 0 main STP +/sdk/tlibstdcxx/stlport/string.h /package/include/stlport/string.h 0 main STP +/sdk/tlibstdcxx/stlport/string /package/include/stlport/string 0 main STP +/sdk/tlibstdcxx/stlport/time.h /package/include/stlport/time.h 0 main STP +/sdk/tlibstdcxx/stlport/typeinfo.h /package/include/stlport/typeinfo.h 0 main STP +/sdk/tlibstdcxx/stlport/typeinfo /package/include/stlport/typeinfo 0 main STP +/sdk/tlibstdcxx/stlport/type_traits /package/include/stlport/type_traits 0 main STP +/sdk/tlibstdcxx/stlport/unordered_map /package/include/stlport/unordered_map 0 main STP +/sdk/tlibstdcxx/stlport/unordered_set /package/include/stlport/unordered_set 0 main STP +/sdk/tlibstdcxx/stlport/using/cstring /package/include/stlport/using/cstring 0 main STP +/sdk/tlibstdcxx/stlport/using/export /package/include/stlport/using/export 0 main STP +/sdk/tlibstdcxx/stlport/using/fstream /package/include/stlport/using/fstream 0 main STP +/sdk/tlibstdcxx/stlport/using/h/fstream.h /package/include/stlport/using/h/fstream.h 0 main STP +/sdk/tlibstdcxx/stlport/using/h/iomanip.h /package/include/stlport/using/h/iomanip.h 0 main STP +/sdk/tlibstdcxx/stlport/using/h/iostream.h /package/include/stlport/using/h/iostream.h 0 main STP +/sdk/tlibstdcxx/stlport/using/h/ostream.h /package/include/stlport/using/h/ostream.h 0 main STP +/sdk/tlibstdcxx/stlport/using/h/streambuf.h /package/include/stlport/using/h/streambuf.h 0 main STP +/sdk/tlibstdcxx/stlport/using/h/strstream.h /package/include/stlport/using/h/strstream.h 0 main STP +/sdk/tlibstdcxx/stlport/using/iomanip /package/include/stlport/using/iomanip 0 main STP +/sdk/tlibstdcxx/stlport/using/iosfwd /package/include/stlport/using/iosfwd 0 main STP +/sdk/tlibstdcxx/stlport/using/ios /package/include/stlport/using/ios 0 main STP +/sdk/tlibstdcxx/stlport/using/iostream /package/include/stlport/using/iostream 0 main STP +/sdk/tlibstdcxx/stlport/using/istream /package/include/stlport/using/istream 0 main STP +/sdk/tlibstdcxx/stlport/using/locale /package/include/stlport/using/locale 0 main STP +/sdk/tlibstdcxx/stlport/using/ostream /package/include/stlport/using/ostream 0 main STP +/sdk/tlibstdcxx/stlport/using/sstream /package/include/stlport/using/sstream 0 main STP +/sdk/tlibstdcxx/stlport/using/streambuf /package/include/stlport/using/streambuf 0 main STP +/sdk/tlibstdcxx/stlport/using/strstream /package/include/stlport/using/strstream 0 main STP +/sdk/tlibstdcxx/stlport/utility /package/include/stlport/utility 0 main STP +/sdk/tlibstdcxx/stlport/valarray /package/include/stlport/valarray 0 main STP +/sdk/tlibstdcxx/stlport/vector /package/include/stlport/vector 0 main STP +/sdk/tlibstdcxx/stlport/wchar.h /package/include/stlport/wchar.h 0 main STP +/sdk/tlibstdcxx/stlport/wctype.h /package/include/stlport/wctype.h 0 main STP diff --git a/linux/installer/common/sdk/BOMs/sdk_x64.txt b/linux/installer/common/sdk/BOMs/sdk_x64.txt new file mode 100644 index 0000000000..0d8926c423 --- /dev/null +++ b/linux/installer/common/sdk/BOMs/sdk_x64.txt @@ -0,0 +1,25 @@ +DeliveryName InstallName FileCheckSum FileFeature FileOwner +/build/linux/gdb-sgx-plugin/gdb_sgx_cmd /package/lib64/gdb-sgx-plugin/gdb_sgx_cmd 0 main STP +/build/linux/gdb-sgx-plugin/gdb_sgx_plugin.py /package/lib64/gdb-sgx-plugin/gdb_sgx_plugin.py 0 main STP +/build/linux/gdb-sgx-plugin/load_symbol_cmd.py /package/lib64/gdb-sgx-plugin/load_symbol_cmd.py 0 main STP +/build/linux/gdb-sgx-plugin/readelf.py /package/lib64/gdb-sgx-plugin/readelf.py 0 main STP +/build/linux/gdb-sgx-plugin/sgx_emmt.py /package/lib64/gdb-sgx-plugin/sgx_emmt.py 0 main STP +/build/linux/libsgx_ptrace.so /package/lib64/libsgx_ptrace.so 0 main STP +/build/linux/libsgx_tcrypto.a /package/lib64/libsgx_tcrypto.a 0 main STP +/build/linux/libsgx_tkey_exchange.a /package/lib64/libsgx_tkey_exchange.a 0 main STP +/build/linux/libsgx_trts.a /package/lib64/libsgx_trts.a 0 main STP +/build/linux/libsgx_trts_sim.a /package/lib64/libsgx_trts_sim.a 0 main STP +/build/linux/libsgx_tservice.a /package/lib64/libsgx_tservice.a 0 main STP +/build/linux/libsgx_tservice_sim.a /package/lib64/libsgx_tservice_sim.a 0 main STP +/build/linux/libsgx_tstdc.a /package/lib64/libsgx_tstdc.a 0 main STP +/build/linux/libsgx_tstdcxx.a /package/lib64/libsgx_tstdcxx.a 0 main STP +/build/linux/libsgx_uae_service_deploy.so /package/lib64/libsgx_uae_service.so 0 main STP +/build/linux/libsgx_uae_service_sim.so /package/lib64/libsgx_uae_service_sim.so 0 main STP +/build/linux/libsgx_ukey_exchange.a /package/lib64/libsgx_ukey_exchange.a 0 main STP +/build/linux/libsgx_urts_deploy.so /package/lib64/libsgx_urts.so 0 main STP +/build/linux/libsgx_urts_sim.so /package/lib64/libsgx_urts_sim.so 0 main STP +/build/linux/STLport_Changes_SGX.txt /package/lib64/STLport_Changes_SGX.txt 0 main STP +/build/linux/sgx_config_cpusvn /package/bin/x64/sgx_config_cpusvn 0 main STP +/build/linux/sgx_edger8r /package/bin/x64/sgx_edger8r 0 main STP +/build/linux/sgx_sign /package/bin/x64/sgx_sign 0 main STP +/linux/installer/common/sdk/installConfig.x64 /scripts/installConfig 0 main STP diff --git a/linux/installer/common/sdk/BOMs/sdk_x86.txt b/linux/installer/common/sdk/BOMs/sdk_x86.txt new file mode 100644 index 0000000000..23f3b47a2b --- /dev/null +++ b/linux/installer/common/sdk/BOMs/sdk_x86.txt @@ -0,0 +1,25 @@ +DeliveryName InstallName FileCheckSum FileFeature FileOwner +/build/linux/gdb-sgx-plugin/gdb_sgx_cmd /package/lib/gdb-sgx-plugin/gdb_sgx_cmd 0 main STP +/build/linux/gdb-sgx-plugin/gdb_sgx_plugin.py /package/lib/gdb-sgx-plugin/gdb_sgx_plugin.py 0 main STP +/build/linux/gdb-sgx-plugin/load_symbol_cmd.py /package/lib/gdb-sgx-plugin/load_symbol_cmd.py 0 main STP +/build/linux/gdb-sgx-plugin/readelf.py /package/lib/gdb-sgx-plugin/readelf.py 0 main STP +/build/linux/gdb-sgx-plugin/sgx_emmt.py /package/lib/gdb-sgx-plugin/sgx_emmt.py 0 main STP +/build/linux/libsgx_ptrace.so /package/lib/libsgx_ptrace.so 0 main STP +/build/linux/libsgx_tcrypto.a /package/lib/libsgx_tcrypto.a 0 main STP +/build/linux/libsgx_tkey_exchange.a /package/lib/libsgx_tkey_exchange.a 0 main STP +/build/linux/libsgx_trts.a /package/lib/libsgx_trts.a 0 main STP +/build/linux/libsgx_trts_sim.a /package/lib/libsgx_trts_sim.a 0 main STP +/build/linux/libsgx_tservice.a /package/lib/libsgx_tservice.a 0 main STP +/build/linux/libsgx_tservice_sim.a /package/lib/libsgx_tservice_sim.a 0 main STP +/build/linux/libsgx_tstdc.a /package/lib/libsgx_tstdc.a 0 main STP +/build/linux/libsgx_tstdcxx.a /package/lib/libsgx_tstdcxx.a 0 main STP +/build/linux/libsgx_uae_service_deploy.so /package/lib/libsgx_uae_service.so 0 main STP +/build/linux/libsgx_uae_service_sim.so /package/lib/libsgx_uae_service_sim.so 0 main STP +/build/linux/libsgx_ukey_exchange.a /package/lib/libsgx_ukey_exchange.a 0 main STP +/build/linux/libsgx_urts_deploy.so /package/lib/libsgx_urts.so 0 main STP +/build/linux/libsgx_urts_sim.so /package/lib/libsgx_urts_sim.so 0 main STP +/build/linux/STLport_Changes_SGX.txt /package/lib/STLport_Changes_SGX.txt 0 main STP +/build/linux/sgx_config_cpusvn /package/bin/x86/sgx_config_cpusvn 0 main STP +/build/linux/sgx_edger8r /package/bin/x86/sgx_edger8r 0 main STP +/build/linux/sgx_sign /package/bin/x86/sgx_sign 0 main STP +/linux/installer/common/sdk/installConfig.x86 /scripts/installConfig 0 main STP diff --git a/linux/installer/common/sdk/Makefile b/linux/installer/common/sdk/Makefile new file mode 100644 index 0000000000..68363821d5 --- /dev/null +++ b/linux/installer/common/sdk/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include scripts/installConfig + +SOURCE_FOLDER=package +SCRIPTS_FOLDER=scripts + +INSTALL_PATH=$(DESTDIR)/$(SGX_PACKAGES_PATH)/$(SDK_PKG_NAME) +SOURCE_INSTALL_PATH=$(INSTALL_PATH) +SCRIPTS_INSTALL_PATH=$(INSTALL_PATH)/$(SCRIPTS_FOLDER) +SDK_LIB_PATH=$(SOURCE_INSTALL_PATH)/$(LIB_DIR) + +default: + +install: + install -d $(SOURCE_INSTALL_PATH) + install -d $(SCRIPTS_INSTALL_PATH) + install -d $(DESTDIR)/usr/lib + cp -r $(SOURCE_FOLDER)/* $(SOURCE_INSTALL_PATH) + install $(SCRIPTS_FOLDER)/* $(SCRIPTS_INSTALL_PATH) + mv $(SDK_LIB_PATH)/libsgx_uae_service_sim.so $(DESTDIR)/usr/lib + mv $(SDK_LIB_PATH)/libsgx_urts_sim.so $(DESTDIR)/usr/lib diff --git a/linux/installer/common/sdk/createTarball.sh b/linux/installer/common/sdk/createTarball.sh new file mode 100755 index 0000000000..cda3c29a07 --- /dev/null +++ b/linux/installer/common/sdk/createTarball.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +set -e + +SCRIPT_DIR=$(dirname "$0") +ROOT_DIR="${SCRIPT_DIR}/../../../../" +BUILD_DIR="${ROOT_DIR}/build/linux" +LINUX_INSTALLER_DIR="${ROOT_DIR}/linux/installer" +LINUX_INSTALLER_COMMON_DIR="${LINUX_INSTALLER_DIR}/common" + +INSTALL_PATH=${SCRIPT_DIR}/output + +# Cleanup +rm -fr ${INSTALL_PATH} + +# Get the architecture of the build from generated binary +get_arch() +{ + local a=$(readelf -h $BUILD_DIR/sgx_sign | awk '/Class:/{print $2}') + test $a = ELF64 && echo 'x64' || echo 'x86' +} + +ARCH=$(get_arch) + +# Fetch the gen_source script +cp ${LINUX_INSTALLER_COMMON_DIR}/gen_source/gen_source.py ${SCRIPT_DIR} + +# Copy the files according to the BOM +python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/sdk_base.txt +python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/sdk_${ARCH}.txt --cleanup=false +python ${SCRIPT_DIR}/gen_source.py --bom=../licenses/BOM_license.txt --cleanup=false + +# Create the tarball +source ${SCRIPT_DIR}/installConfig.${ARCH} + +pushd ${INSTALL_PATH} &> /dev/null +tar -zcvf ${TARBALL_NAME} * +popd &> /dev/null diff --git a/linux/installer/common/sdk/install.sh b/linux/installer/common/sdk/install.sh new file mode 100755 index 0000000000..cea3366a1f --- /dev/null +++ b/linux/installer/common/sdk/install.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +set -e + +SCRIPT_DIR=$(dirname "$0") +source ${SCRIPT_DIR}/installConfig + +# Generate the script to preload SGX ptrace library for gdb +SDK_DST_PATH=${SGX_PACKAGES_PATH}/${SDK_PKG_NAME} +GDB_SCRIPT=/usr/bin/sgx-gdb +SDK_LIB_PATH=${SDK_DST_PATH}/${LIB_DIR} + +generate_gdb_script() +{ + cat > $GDB_SCRIPT < $SDK_DST_PATH/uninstall.sh < +typedef struct _aesm_thread_t *aesm_thread_t; +typedef ptrdiff_t aesm_thread_arg_type_t; +typedef ae_error_t (*aesm_thread_function_t)(aesm_thread_arg_type_t arg); + +ae_error_t aesm_create_thread(aesm_thread_function_t function_entry, aesm_thread_arg_type_t arg, aesm_thread_t* h); +ae_error_t aesm_free_thread(aesm_thread_t h); +ae_error_t aesm_join_thread(aesm_thread_t h, ae_error_t *thread_ret); + +extern const uint32_t AESM_THREAD_INFINITE; + +ae_error_t aesm_wait_thread(aesm_thread_t h, ae_error_t *thread_ret, unsigned long milisecond); + +#endif diff --git a/psw/ae/aesm_service/include/oal/error_report.h b/psw/ae/aesm_service/include/oal/error_report.h new file mode 100644 index 0000000000..5e05334c26 --- /dev/null +++ b/psw/ae/aesm_service/include/oal/error_report.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __OAL_ERROR_REPORT_H__ +#define __OAL_ERROR_REPORT_H__ +#define AESM_LOG_REPORT_FATAL 0 +#define AESM_LOG_REPORT_ERROR 1 +#define AESM_LOG_REPORT_WARNING 2 +#include "event_strings.h" +#ifdef __cplusplus +extern "C" { +#endif/*__cplusplus*/ + void aesm_log_report(int level, const char *format, ...); + void aesm_log_init(void); + void aesm_log_fini(void); +#ifdef __cplusplus +}; +#endif/*__cplusplus*/ + +#define AESM_LOG_FATAL(format, args...) aesm_log_report(AESM_LOG_REPORT_FATAL, format, ## args) +#define AESM_LOG_ERROR(format, args...) aesm_log_report(AESM_LOG_REPORT_ERROR, format, ## args) +#define AESM_LOG_WARN(format, args...) aesm_log_report(AESM_LOG_REPORT_WARNING, format, ## args) +#define AESM_LOG_INIT() aesm_log_init() +#define AESM_LOG_FINI() aesm_log_fini() + +#endif/*__OAL_ERROR_REPORT_H__*/ + diff --git a/psw/ae/aesm_service/include/oal/internal_log.h b/psw/ae/aesm_service/include/oal/internal_log.h new file mode 100644 index 0000000000..93ce70df43 --- /dev/null +++ b/psw/ae/aesm_service/include/oal/internal_log.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __OAL_INTERNAL_LOG_H__ +#define __OAL_INTERNAL_LOG_H__ +#ifdef DBG_LOG +#include +#define FATAL_LOG_LEVEL 0 /*report critical internal error*/ +#define ERROR_LOG_LEVEL 1 /*report internal error message*/ +#define WARN_LOG_LEVEL 2 /*report internal warning messages*/ +#define INFO_LOG_LEVEL 3 /*aesm high level trace information, usually information for each components*/ +#define DEBUG_LOG_LEVEL 4 /*aesm middle level trace information, usually information for each function*/ +#define TRACE_LOG_LEVEL 5 /*aesm low level trace information, usually inside a control flow*/ +#ifdef __cplusplus +extern "C" { +#endif/*__cplusplus*/ + void aesm_internal_log(const char *filename, int line_no, const char *funname, int level, const char *format, ...); + void aesm_set_log_level(int level); + void aesm_dbg_format_hex(const uint8_t *data, uint32_t data_len, char *out_buf, uint32_t buf_size); + int enter_module(int module_index); + void leave_module(int module_index); +#ifdef __cplusplus +}; +#endif/*__cplusplus*/ + +#define AESM_DBG_FATAL(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, FATAL_LOG_LEVEL, format, ## args) +#define AESM_DBG_ERROR(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, ERROR_LOG_LEVEL, format, ## args) +#define AESM_DBG_WARN(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, WARN_LOG_LEVEL, format, ## args) +#define AESM_DBG_INFO(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, INFO_LOG_LEVEL, format, ## args) +#define AESM_DBG_DEBUG(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, DEBUG_LOG_LEVEL, format, ## args) +#define AESM_DBG_TRACE(format, args...) aesm_internal_log(__FILE__, __LINE__, __FUNCTION__, TRACE_LOG_LEVEL, format, ## args) + +#define AESM_SET_DBG_LEVEL(level) aesm_set_log_level(level) +#else +#define AESM_DBG_FATAL(args...) +#define AESM_DBG_ERROR(args...) +#define AESM_DBG_WARN(args...) +#define AESM_DBG_INFO(args...) +#define AESM_DBG_DEBUG(args...) +#define AESM_DBG_TRACE(args...) +#define AESM_SET_DBG_LEVEL(level) +#endif/*DBG_LOG*/ + +#define SGX_DBGPRINT_ONE_STRING_ONE_INT(x,y) AESM_DBG_WARN("%s %d", x, y) +#define SGX_DBGPRINT_ONE_STRING_ONE_INT_LTP(x,y) AESM_DBG_WARN("LTP: %s %d", x, y) +#define SGX_DBGPRINT_PRINT_FUNCTION_AND_RETURNVAL(x,y) AESM_DBG_WARN("%s returned %d",x,y) +#define SGX_DBGPRINT_PRINT_TWO_STRINGS(x,y) AESM_DBG_WARN("%s %s",x, y) +#define SGX_DBGPRINT_PRINT_TWO_STRINGS_ONE_INT(x,y,z) AESM_DBG_WARN("%s %s %d", x,y,z) +#define SGX_DBGPRINT_PRINT_FIVE_STRINGS(a,b,c,d,e) AESM_DBG_WARN("%s %s %s %s %s",a,b,c,d,e) +#define SGX_DBGPRINT_PRINT_STRING_LTP(x) AESM_DBG_WARN("%s",x) +#define SGX_DBGPRINT_PRINT_STRING(x) AESM_DBG_WARN("%s",x) + +#define SGX_DBGPRINT_ONE_STRING_ONE_INT_CERT(x,y) AESM_DBG_WARN("cert: %s %d", x, y) +#define SGX_DBGPRINT_ONE_STRING_ONE_INT_OCSP(x,y) AESM_DBG_WARN("OCSP: %s %d", x, y) + +#define SGX_DBGPRINT_ONE_STRING_TWO_INTS_EPH(x,y,z) +#define SGX_DBGPRINT_ONE_STRING_TWO_INTS_CREATE_SESSION(x,y,z) +#define SGX_DBGPRINT_ONE_STRING_TWO_INTS_ENDPOINT_SELECTION(x,y,z) + +#endif/*__OAL_INTERNAL_LOG_H__*/ + diff --git a/psw/ae/aesm_service/include/oal/oal.h b/psw/ae/aesm_service/include/oal/oal.h new file mode 100644 index 0000000000..47854de0c9 --- /dev/null +++ b/psw/ae/aesm_service/include/oal/oal.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AESM_OAL_H_ +#define _AESM_OAL_H_ +#include "oal/aesm_network.h" +#include "oal/aesm_persistent_storage.h" +#include "oal/power.h" +#include "oal/error_report.h" +#include "oal/internal_log.h" +#include "oal/aesm_thread.h" + +#define CLASS_UNCOPYABLE(classname) \ + private: \ + classname(const classname&); \ + classname& operator=(const classname&); +#endif + diff --git a/psw/ae/aesm_service/include/oal/power.h b/psw/ae/aesm_service/include/oal/power.h new file mode 100644 index 0000000000..faf992e024 --- /dev/null +++ b/psw/ae/aesm_service/include/oal/power.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __OAL_POWER_H__ +#include + +ae_error_t aesm_start_request_wake_execution(); +ae_error_t aesm_stop_request_wake_execution(); +#endif + diff --git a/psw/ae/aesm_service/source/aesm/application/AEClass.h b/psw/ae/aesm_service/source/aesm/application/AEClass.h new file mode 100644 index 0000000000..0fe1b5d87b --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/AEClass.h @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AE_CLASS_H_ +#define _AE_CLASS_H_ +#include "sgx_eid.h" +#include "sgx_key.h" +#include "se_thread.h" +#include "sgx_urts.h" +#include "internal/se_stdio.h" +#include "oal/oal.h" +#include "aeerror.h" +#include +#include + +template +class Singleton +{ + CLASS_UNCOPYABLE(Singleton) +public: + static T& instance() + { + if (0 == _instance) + { + _instance = new T(); + atexit(destroy); + } + return *_instance; + } + + virtual ~Singleton() + { + _instance = NULL; + } + +protected: + Singleton(){} +private: + static void destroy() + { + if ( _instance != 0 ) + { + delete _instance; + _instance = 0; + } + } + static T * volatile _instance; +}; + +template +class SingletonEnclave: public Singleton +{ + CLASS_UNCOPYABLE(SingletonEnclave) +public: + + virtual ae_error_t load_enclave(); + void unload_enclave(); +protected: + sgx_enclave_id_t m_enclave_id; + sgx_launch_token_t m_launch_token; + sgx_misc_attribute_t m_attributes; + SingletonEnclave():m_enclave_id(0) + { + memset(&m_launch_token, 0, sizeof(m_launch_token)); + memset(&m_attributes, 0, sizeof(m_attributes)); + } + ~SingletonEnclave(){} + virtual void before_enclave_load() {} + virtual int get_debug_flag() = 0; + +}; +template +ae_error_t SingletonEnclave::load_enclave() +{ + before_enclave_load(); + + if(m_enclave_id) + return AE_SUCCESS; + + aesm_enclave_id_t aesm_enclave_id = T::get_enclave_fid(); + AESM_DBG_INFO("loading enclave %d",aesm_enclave_id); + + sgx_status_t ret; + ae_error_t ae_err; + char enclave_path[MAX_PATH]= {0}; + if((ae_err = aesm_get_pathname(FT_ENCLAVE_NAME, aesm_enclave_id, enclave_path, + MAX_PATH)) + !=AE_SUCCESS){ + AESM_DBG_ERROR("fail to get enclave pathname"); + return ae_err; + } + int launch_token_update; + ret = sgx_create_enclave(enclave_path, get_debug_flag(), &m_launch_token, + &launch_token_update, &m_enclave_id, + &m_attributes); + if (ret == SGX_ERROR_NO_DEVICE){ + AESM_DBG_ERROR("AE SERVER NOT AVAILABLE in load enclave: %s",enclave_path); + return AE_SERVER_NOT_AVAILABLE; + } + if (ret != SGX_SUCCESS){ + AESM_DBG_ERROR("Create Enclave failed:%d",ret); + return AE_FAILURE; + } + AESM_DBG_INFO("enclave %d loaded with id 0X%llX",aesm_enclave_id,m_enclave_id); + + return AE_SUCCESS; +} + +template +void SingletonEnclave::unload_enclave() +{ + if (m_enclave_id) + { + AESM_DBG_INFO("unload enclave 0X%llX",m_enclave_id); + sgx_destroy_enclave(m_enclave_id); + m_enclave_id = 0; + } + + return; +} + +template +T * volatile Singleton::_instance = 0; + +#define AESM_RETRY_COUNT 3 + +ae_error_t sgx_error_to_ae_error(sgx_status_t status); +#endif + diff --git a/psw/ae/aesm_service/source/aesm/application/aesm_config.cpp b/psw/ae/aesm_service/source/aesm/application/aesm_config.cpp new file mode 100644 index 0000000000..c651501f0c --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/aesm_config.cpp @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "aesm_config.h" +#include "aesm_proxy_type.h" +#include "oal.h" +#include +#include +#include + +#define AESM_CONFIG_FILE "/etc/aesmd.conf" +#define MAX_LINE 1024 +#define URL_PATTERN "[[:blank:]]*(http[s]?://[^[:blank:]]*)[[:blank:]]*" //pattern used to match a URL which should be started with http:// or https:// +#define OPTION_COMMENT "(#.*)?" + +enum _config_value_t{ + config_comment, + config_space, + config_endpoint_url, + config_pse_rl_url, + config_pse_ocsp_url, + config_aesm_proxy_url, + config_aesm_proxy_type, + config_value_nums +}; + +struct _config_patterns_t{ + enum _config_value_t id; + const char *pattern; +}config_patterns[]={ + {config_comment, "^[[:blank:]]*#"}, //matching a line with comments only (It is started by #) + {config_space, "^[[:blank:]]*$"}, //matching empty line + {config_endpoint_url, "^[[:blank:]]*endpoint[[:blank:]]*url[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: endpoint url = .... + {config_pse_rl_url, "^[[:blank:]]*pse[[:blank:]]*rl[[:blank:]]*url[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: pse rl url = ... + {config_pse_ocsp_url, "^[[:blank:]]*pse[[:blank:]]*ocsp[[:blank:]]*url[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: pse ocsp url = ... + {config_aesm_proxy_url,"^[[:blank:]]*aesm[[:blank:]]*proxy[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: aesm proxy = ... + {config_aesm_proxy_type, "^[[:blank:]]*proxy[[:blank:]]*type[[:blank:]]*=[[:blank:]]([^[:blank:]]+)[[:blank:]]*" OPTION_COMMENT "$"}//matching line in format: proxy type = [direct|default|manual] +}; + +#define NUM_CONFIG_PATTERNS (sizeof(config_patterns)/sizeof(config_patterns[0])) + +typedef struct _config_entry_t{ + bool initialized; + regex_t reg; +} config_entry_t; + +//static function to initialize all regular expression pattern +static void init_config_patterns(config_entry_t entries[]) +{ + uint32_t i; + for(i=0;i=config_value_nums){ + AESM_DBG_ERROR("config id %d is too large", entry_id); + continue; + } + if(entries[entry_id].initialized){ + AESM_DBG_ERROR("duplicated item for config id %d",entry_id); + continue; + } + if(regcomp(&entries[entry_id].reg,config_patterns[i].pattern, REG_EXTENDED|REG_ICASE)!=0){ + AESM_DBG_ERROR("Invalid config pattern %s", config_patterns[i].pattern); + continue; + } + entries[entry_id].initialized=true; + } +} + +static void release_config_patterns(config_entry_t entries[]) +{ + uint32_t i; + for(i=0;i=MAX_PATH){ + AESM_DBG_ERROR("too long endpoint url in config file"); + }else{ + memcpy(infos.endpoint_url, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so); + infos.endpoint_url[matches[1].rm_eo-matches[1].rm_so]='\0'; + } + break; + case config_pse_rl_url: + if(matches[1].rm_eo-matches[1].rm_so>=MAX_PATH){ + AESM_DBG_ERROR("too long pse pr url in config file"); + }else{ + memcpy(infos.pse_rl_url, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so); + infos.pse_rl_url[matches[1].rm_eo-matches[1].rm_so]='\0'; + } + break; + case config_pse_ocsp_url: + if(matches[1].rm_eo-matches[1].rm_so>=MAX_PATH){ + AESM_DBG_ERROR("too long pse ocsp url in config file"); + }else{ + memcpy(infos.pse_ocsp_url, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so); + infos.pse_ocsp_url[matches[1].rm_eo-matches[1].rm_so]='\0'; + } + break; + case config_aesm_proxy_url: + if(matches[1].rm_eo-matches[1].rm_so>=MAX_PATH){ + AESM_DBG_ERROR("too long aesm proxy url in config file"); + }else{ + memcpy(infos.aesm_proxy, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so); + infos.aesm_proxy[matches[1].rm_eo-matches[1].rm_so]='\0'; + } + break; + case config_aesm_proxy_type://It is a proxy type, we need change the string to integer by calling function read_aesm_proxy_type + infos.proxy_type = read_aesm_proxy_type(line+matches[1].rm_so, matches[1].rm_eo-matches[1].rm_so); + break; + default: + AESM_DBG_ERROR("reg exp type %d not processed", i); + break; + } + break; + } + } + if(i>=config_value_nums){//the line matching nothing + AESM_DBG_ERROR("aesm config file error: invalid line[%s]",line); + return false; + } + return true; +} + +bool read_aesm_config(aesm_config_infos_t& infos) +{ + char line[MAX_LINE]; + int line_no=0; + bool ret = true; + config_entry_t entries[config_value_nums]; + memset(&entries,0,sizeof(entries)); + memset(&infos, 0, sizeof(aesm_config_infos_t)); + strcpy(infos.endpoint_url, DEFAULT_URL); + strcpy(infos.pse_rl_url, DEFAULT_PSE_RL_URL); + strcpy(infos.pse_ocsp_url, DEFAULT_PSE_OCSP_URL); + + infos.proxy_type = AESM_PROXY_TYPE_DEFAULT_PROXY; + FILE *f =fopen(AESM_CONFIG_FILE, "r"); + if(f==NULL){ + AESM_DBG_ERROR("Cannnot read aesm config file %s",AESM_CONFIG_FILE); + return false; + } + init_config_patterns(entries); + while(fgets(line, MAX_LINE, f)!=NULL){ + size_t len=strlen(line); + if(len>0&&line[len-1]=='\n')line[len-1]='\0';//remove the line ending + line_no++; + if(!config_process_one_line(line, entries, infos)){ + AESM_LOG_WARN("format error in file %s:%d [%s]",AESM_CONFIG_FILE, line_no, line); + ret = false;//continue process the file but save the error status + } + } + release_config_patterns(entries); + fclose(f); + if(infos.proxy_type>=NUM_PROXY_TYPE|| + (infos.proxy_type==AESM_PROXY_TYPE_MANUAL_PROXY&&infos.aesm_proxy[0]=='\0')){ + AESM_DBG_WARN("Invalid proxy type %d",infos.proxy_type); + infos.proxy_type = AESM_PROXY_TYPE_DIRECT_ACCESS; + ret = false; + } + return ret; +} + diff --git a/psw/ae/aesm_service/source/aesm/application/aesm_config.h b/psw/ae/aesm_service/source/aesm/application/aesm_config.h new file mode 100644 index 0000000000..0dc5b5f24f --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/aesm_config.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AESM_CONFIG_H_ +#define _AESM_CONFIG_H_ +#include "se_types.h" +#include "se_wrapper.h" +#include "aesm_logic.h" +typedef struct _aesm_config_infos_t{ + uint32_t proxy_type; + char endpoint_url[MAX_PATH]; + char pse_rl_url[MAX_PATH]; + char pse_ocsp_url[MAX_PATH]; + char aesm_proxy[MAX_PATH]; +}aesm_config_infos_t; +#endif + diff --git a/psw/ae/aesm_service/source/aesm/application/aesm_logic.cpp b/psw/ae/aesm_service/source/aesm/application/aesm_logic.cpp new file mode 100644 index 0000000000..84b124a0b9 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/aesm_logic.cpp @@ -0,0 +1,549 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "QEClass.h" +#include "LEClass.h" +#include "PVEClass.h" + +#include "arch.h" +#include "sgx_report.h" +#include "sgx_tseal.h" +#include "epid_pve_type.h" +#include "util.h" +#include +#include +#include "oal/oal.h" +#include "oal/aesm_thread.h" +#include "aesm_encode.h" +#include "aesm_epid_blob.h" +#include "aesm_logic.h" +#include "pve_logic.h" +#include "qe_logic.h" +#include "platform_info_logic.h" +#include "prov_msg_size.h" +#include "se_sig_rl.h" +#include "se_quote_internal.h" +#include "endpoint_select_info.h" +#include "se_wrapper.h" +#include "ippcp.h" +#include "ippcore.h" +#include +#include +#include "ippcp.h" +#include "ippcore.h" +#include "prof_fun.h" +#include "aesm_long_lived_thread.h" +#include "sgx_profile.h" + +#define CHECK_SERVICE_STATUS if (!is_service_running()) return AESM_SERVICE_STOPPED; +#define CHECK_SGX_STATUS if (g_sgx_device_status != SGX_ENABLED) return AESM_SGX_DEVICE_NOT_AVAILABLE; + +AESMLogicMutex AESMLogic::_qe_pve_mutex; +AESMLogicMutex AESMLogic::_pse_mutex; +AESMLogicMutex AESMLogic::_le_mutex; + +bool AESMLogic::_is_qe_psvn_set; +bool AESMLogic::_is_pse_psvn_set; +psvn_t AESMLogic::_qe_psvn; +psvn_t AESMLogic::_pse_psvn; + +static ae_error_t thread_to_load_qe(aesm_thread_arg_type_t arg) +{ + epid_blob_with_cur_psvn_t epid_data; + ae_error_t ae_ret = AE_FAILURE; + UNUSED(arg); + AESM_DBG_TRACE("start to load qe"); + memset(&epid_data, 0, sizeof(epid_data)); + AESMLogicLock lock(AESMLogic::_qe_pve_mutex); + if((ae_ret = EPIDBlob::instance().read(epid_data)) == AE_SUCCESS) + { + AESM_DBG_TRACE("EPID blob is read successfully, loading QE ..."); + ae_ret = CQEClass::instance().load_enclave(); + if(AE_SUCCESS != ae_ret) + { + AESM_DBG_WARN("fail to load QE: %d", ae_ret); + }else{ + AESM_DBG_TRACE("QE loaded successfully"); + } + } + AESM_DBG_TRACE("QE Thread finished succ"); + return AE_SUCCESS; +} + +// Must be called when AESM starts +ae_error_t AESMLogic::service_start() +{ + AESM_PROFILE_INIT; + ae_error_t ae_ret = AE_SUCCESS; + + AESM_LOG_INIT(); + + //ippInit();//no ippInit available for c version ipp + AESM_DBG_INFO("aesm service is starting"); + ae_ret = CLEClass::instance().load_enclave(); + if(AE_SUCCESS != ae_ret) + { + AESM_DBG_INFO("fail to load LE: %d", ae_ret); + AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_SERVICE_UNAVAILABLE]); + + return ae_ret; + } + + aesm_thread_t qe_thread=NULL; + ae_error_t aesm_ret1 = aesm_create_thread(thread_to_load_qe, 0,&qe_thread); + if(AE_SUCCESS != aesm_ret1 ){ + AESM_DBG_WARN("Fail to create thread to preload QE:%d",aesm_ret1); + }else{ + (void)aesm_free_thread(qe_thread);//release thread handle to free memory + } + + AESM_DBG_TRACE("aesm service is started"); + + return AE_SUCCESS; +} + +void AESMLogic::service_stop() +{ + CPVEClass::instance().unload_enclave(); + CQEClass::instance().unload_enclave(); + CLEClass::instance().unload_enclave(); + stop_all_long_lived_threads(); + AESM_DBG_INFO("aesm service down"); + AESM_LOG_FINI(); + + AESM_PROFILE_OUTPUT; +} + +bool AESMLogic::is_service_running() +{ + return true; +} + +ae_error_t AESMLogic::save_unverified_white_list(const uint8_t *white_list_cert, uint32_t white_list_cert_size) +{ + wl_cert_chain_t old_cert; + const wl_cert_chain_t *p_new_cert = reinterpret_cast(white_list_cert); + uint32_t old_cert_size = sizeof(old_cert); + memset(&old_cert, 0, sizeof(old_cert)); + if((aesm_read_data(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID, reinterpret_cast(&old_cert), &old_cert_size) == AE_SUCCESS) + && (old_cert_size == sizeof(old_cert)) && (white_list_cert_size >= sizeof(wl_cert_chain_t))) + { + if(_ntohl(p_new_cert->wl_cert.wl_version) <= _ntohl(old_cert.wl_cert.wl_version)) + { + AESM_DBG_WARN("White list version downgraded! current version is %d, new version is %d", + _ntohl(old_cert.wl_cert.wl_version), _ntohl(p_new_cert->wl_cert.wl_version)); + return OAL_PARAMETER_ERROR; // OAL_PARAMETER_ERROR used here is to indicate the white list is incorrect + } + } + return aesm_write_data(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID, white_list_cert, white_list_cert_size); +} + +aesm_error_t AESMLogic::white_list_register( + const uint8_t *white_list_cert, uint32_t white_list_cert_size) +{ + AESM_DBG_INFO("enter function"); + CHECK_SERVICE_STATUS; + AESMLogicLock lock(_le_mutex); + CHECK_SERVICE_STATUS; + ae_error_t ret_le = AE_SUCCESS; + if (NULL == white_list_cert||0==white_list_cert_size){ + AESM_DBG_TRACE("Invalid parameter"); + return AESM_PARAMETER_ERROR; + } + ae_error_t ae_ret = CLEClass::instance().load_enclave(); + if(ae_ret == AE_SERVER_NOT_AVAILABLE) + { + AESM_DBG_WARN("LE not loaded due to AE_SERVER_NOT_AVAILABLE, possible SGX Env Not Ready"); + ret_le = save_unverified_white_list(white_list_cert, white_list_cert_size); + } + else if(AE_FAILED(ae_ret)) + { + AESM_DBG_ERROR("LE not loaded:%d", ae_ret); + return AESM_UNEXPECTED_ERROR; + }else{ + ret_le = static_cast(CLEClass::instance().white_list_register( + white_list_cert, white_list_cert_size)); + } + + switch (ret_le) + { + case AE_SUCCESS: + return AESM_SUCCESS; + case LE_INVALID_PARAMETER: + AESM_DBG_TRACE("Invalid parameter"); + return AESM_PARAMETER_ERROR; + case LE_INVALID_ATTRIBUTE: + AESM_DBG_TRACE("Launch token error"); + return AESM_GET_LICENSETOKEN_ERROR; + default: + AESM_DBG_WARN("unexpeted error %d", ret_le); + return AESM_UNEXPECTED_ERROR; + } +} + +aesm_error_t AESMLogic::get_launch_token( + const uint8_t * mrenclave, uint32_t mrenclave_size, + const uint8_t *public_key, uint32_t public_key_size, + const uint8_t *se_attributes, uint32_t se_attributes_size, + uint8_t * lictoken, uint32_t lictoken_size) +{ + AESM_DBG_INFO("enter function"); + + CHECK_SERVICE_STATUS; + AESMLogicLock lock(_le_mutex); + CHECK_SERVICE_STATUS; + + ae_error_t ret_le = AE_SUCCESS; + if (NULL == mrenclave || + NULL == public_key || + NULL == se_attributes || + NULL == lictoken) + { + //sizes are checked in CLEClass::get_launch_token() + AESM_DBG_TRACE("Invalid parameter"); + return AESM_PARAMETER_ERROR; + } + ae_error_t ae_ret = CLEClass::instance().load_enclave(); + if(ae_ret == AE_SERVER_NOT_AVAILABLE) + { + AESM_LOG_ERROR("%s", g_event_string_table[SGX_EVENT_SERVICE_UNAVAILABLE]); + AESM_DBG_FATAL("LE not loaded due to AE_SERVER_NOT_AVAILABLE, possible SGX Env Not Ready"); + return AESM_NO_DEVICE_ERROR; + } + else if(AE_FAILED(ae_ret)) + { + AESM_DBG_ERROR("LE not loaded:%d", ae_ret); + return AESM_UNEXPECTED_ERROR; + } + ret_le = static_cast(CLEClass::instance().get_launch_token( + const_cast(mrenclave), mrenclave_size, + const_cast(public_key), public_key_size, + const_cast(se_attributes), se_attributes_size, + lictoken, lictoken_size)); + + switch (ret_le) + { + case AE_SUCCESS: + return AESM_SUCCESS; + case LE_INVALID_PARAMETER: + AESM_DBG_TRACE("Invalid parameter"); + return AESM_PARAMETER_ERROR; + case LE_INVALID_ATTRIBUTE: + case LE_INVALID_PRIVILEGE_ERROR: + AESM_DBG_TRACE("Launch token error"); + return AESM_GET_LICENSETOKEN_ERROR; + case LE_WHITELIST_UNINITIALIZED_ERROR: + AESM_DBG_TRACE("LE whitelist uninitialized error"); + return AESM_UNEXPECTED_ERROR; + default: + AESM_DBG_WARN("unexpeted error %d", ret_le); + return AESM_UNEXPECTED_ERROR; + } +} + +/* This function will be called outside aesm(from urts_internal) */ +extern "C" sgx_status_t get_launch_token(const enclave_css_t* signature, + const sgx_attributes_t* attribute, + sgx_launch_token_t* launch_token) +{ + AESM_DBG_INFO("enter function"); + return AESMLogic::get_launch_token(signature, attribute, launch_token); +} + +ae_error_t AESMLogic::get_qe_isv_svn(uint16_t& isv_svn) +{ + if(!_is_qe_psvn_set){ + ae_error_t ae_err = CQEClass::instance().load_enclave(); + if(AE_SUCCESS != ae_err){ + AESM_DBG_ERROR("Fail to load QE Enclave:%d",ae_err); + return ae_err; + } + } + assert(_is_qe_psvn_set); + if(0!=memcpy_s(&isv_svn, sizeof(isv_svn), &_qe_psvn.isv_svn, sizeof(_qe_psvn.isv_svn))){ + AESM_DBG_ERROR("memcpy failed"); + return AE_FAILURE; + } + return AE_SUCCESS; +} + +ae_error_t AESMLogic::get_pse_isv_svn(uint16_t& isv_svn) +{ + return AE_FAILURE; +} + +ae_error_t AESMLogic::get_qe_cpu_svn(sgx_cpu_svn_t& cpu_svn) +{ + if(!_is_qe_psvn_set){ + ae_error_t ae_err = CQEClass::instance().load_enclave(); + if(AE_SUCCESS != ae_err){ + AESM_DBG_ERROR("Fail to load QE Enclave:%d",ae_err); + return ae_err; + } + } + assert(_is_qe_psvn_set); + if(0!=memcpy_s(&cpu_svn, sizeof(sgx_cpu_svn_t), &_qe_psvn.cpu_svn, sizeof(_qe_psvn.cpu_svn))){ + AESM_DBG_ERROR("memcpy failed"); + return AE_FAILURE; + } + return AE_SUCCESS; +} + + + +ae_error_t AESMLogic::set_psvn(uint16_t prod_id, uint16_t isv_svn, sgx_cpu_svn_t cpu_svn) +{ + if(prod_id == QE_PROD_ID){ + if(_is_qe_psvn_set){ + if(0!=memcmp(&_qe_psvn.isv_svn, &isv_svn, sizeof(isv_svn))|| + 0!=memcmp(&_qe_psvn.cpu_svn, &cpu_svn, sizeof(sgx_cpu_svn_t))){ + AESM_DBG_ERROR("PSVN unmatched for QE/PVE"); + return AE_PSVN_UNMATCHED_ERROR; + } + }else{ + if(0!=memcpy_s(&_qe_psvn.isv_svn, sizeof(_qe_psvn.isv_svn), &isv_svn, sizeof(isv_svn))|| + 0!=memcpy_s(&_qe_psvn.cpu_svn, sizeof(_qe_psvn.cpu_svn), &cpu_svn, sizeof(sgx_cpu_svn_t))){ + AESM_DBG_ERROR("memcpy failed"); + return AE_FAILURE; + } + AESM_DBG_TRACE("get QE or PvE isv_svn=%d",(int)isv_svn); + _is_qe_psvn_set = true; + return AE_SUCCESS; + } + }else if(prod_id == PSE_PROD_ID){ + if(_is_pse_psvn_set){ + if(0!=memcmp(&_pse_psvn.isv_svn, &isv_svn, sizeof(isv_svn))|| + 0!=memcmp(&_pse_psvn.cpu_svn, &cpu_svn, sizeof(sgx_cpu_svn_t))){ + AESM_DBG_ERROR("PSVN unmatched for PSE"); + return AE_PSVN_UNMATCHED_ERROR; + } + }else{ + if(0!=memcpy_s(&_pse_psvn.isv_svn, sizeof(_pse_psvn.isv_svn), &isv_svn, sizeof(isv_svn))|| + 0!=memcpy_s(&_pse_psvn.cpu_svn, sizeof(_pse_psvn.cpu_svn), &cpu_svn, sizeof(sgx_cpu_svn_t))){ + AESM_DBG_ERROR("memcpy failed"); + return AE_FAILURE; + } + AESM_DBG_TRACE("get PSE isv_svn=%d", (int)isv_svn); + _is_pse_psvn_set = true; + return AE_SUCCESS; + } + } + return AE_SUCCESS; +} + +sgx_status_t AESMLogic::get_launch_token(const enclave_css_t* signature, + const sgx_attributes_t* attribute, + sgx_launch_token_t* launch_token) +{ + AESM_DBG_INFO("enter function"); + AESMLogicLock lock(_le_mutex); + + ae_error_t ret_le = AE_SUCCESS; + // load LE to get launch token + if((ret_le=CLEClass::instance().load_enclave()) != AE_SUCCESS) + { + if(ret_le == AE_SERVER_NOT_AVAILABLE) + { + AESM_DBG_FATAL("LE not loaded due to AE_SERVER_NOT_AVAILABLE, possible SGX Env Not Ready"); + return SGX_ERROR_NO_DEVICE; + } + AESM_DBG_FATAL("fail to load LE:%d",ret_le); + return SGX_ERROR_UNEXPECTED; + } + + + ret_le = static_cast(CLEClass::instance().get_launch_token( + const_cast(reinterpret_cast(&signature->body.enclave_hash)), + sizeof(sgx_measurement_t), + const_cast(reinterpret_cast(&signature->key.modulus)), + sizeof(signature->key.modulus), + const_cast(reinterpret_cast(attribute)), + sizeof(sgx_attributes_t), + reinterpret_cast(launch_token), + sizeof(token_t))); + switch (ret_le) + { + case AE_SUCCESS: + break; + case LE_INVALID_PARAMETER: + AESM_DBG_TRACE("Invalid parameter"); + return SGX_ERROR_INVALID_PARAMETER; + case LE_INVALID_ATTRIBUTE: + case LE_INVALID_PRIVILEGE_ERROR: + AESM_DBG_TRACE("Launch token error"); + return SGX_ERROR_SERVICE_INVALID_PRIVILEGE; + case LE_WHITELIST_UNINITIALIZED_ERROR: + AESM_DBG_TRACE("LE whitelist uninitialized error"); + return SGX_ERROR_UNEXPECTED; + default: + AESM_DBG_WARN("unexpeted error %d", ret_le); + return SGX_ERROR_UNEXPECTED; + } + + token_t *lt = reinterpret_cast(launch_token); + ret_le = set_psvn(signature->body.isv_prod_id, signature->body.isv_svn, lt->cpu_svn_le); + if(AE_PSVN_UNMATCHED_ERROR == ret_le) + { + //QE or PSE has been changed, but AESM doesn't restart. Will not provide service. + return SGX_ERROR_SERVICE_UNAVAILABLE; + }else if(AE_SUCCESS != ret_le) { + AESM_DBG_ERROR("fail to save psvn:%d", ret_le); + return SGX_ERROR_UNEXPECTED; + } + + return SGX_SUCCESS; +} + +aesm_error_t AESMLogic::create_session( + uint32_t* session_id, + uint8_t* se_dh_msg1, uint32_t se_dh_msg1_size) +{ + return AESM_SERVICE_NOT_AVAILABLE; +} + +aesm_error_t AESMLogic::exchange_report( + uint32_t session_id, + const uint8_t* se_dh_msg2, uint32_t se_dh_msg2_size, + uint8_t* se_dh_msg3, uint32_t se_dh_msg3_size) +{ + return AESM_SERVICE_NOT_AVAILABLE; +} + +aesm_error_t AESMLogic::close_session( + uint32_t session_id) +{ + return AESM_SERVICE_NOT_AVAILABLE; +} + +aesm_error_t AESMLogic::invoke_service( + const uint8_t* pse_message_req, uint32_t pse_message_req_size, + uint8_t* pse_message_resp, uint32_t pse_message_resp_size) +{ + return AESM_SERVICE_NOT_AVAILABLE;; +} + +aesm_error_t AESMLogic::get_ps_cap( + uint64_t* ps_cap) +{ + return AESM_PSDA_UNAVAILABLE; +} + +#define CHECK_EPID_PROVISIONG_STATUS \ + if(!query_pve_thread_status()){\ + return AESM_BUSY;\ + } + +aesm_error_t AESMLogic::init_quote( + uint8_t *target_info, uint32_t target_info_size, + uint8_t *gid, uint32_t gid_size) +{ + ae_error_t ret = AE_SUCCESS; + uint16_t qe_isv_svn = 0xFFFF; + sgx_cpu_svn_t qe_cpu_svn; + memset(&qe_cpu_svn, 0, sizeof(qe_cpu_svn)); + AESM_DBG_INFO("init_quote"); + if(sizeof(sgx_target_info_t) != target_info_size || + sizeof(sgx_epid_group_id_t) != gid_size) + { + return AESM_PARAMETER_ERROR; + } + AESMLogicLock lock(_qe_pve_mutex); + CHECK_EPID_PROVISIONG_STATUS; + ret = get_qe_cpu_svn(qe_cpu_svn); + if(AE_SUCCESS != ret) + { + return AESM_UNEXPECTED_ERROR; + } + ret = get_qe_isv_svn(qe_isv_svn); + if(AE_SUCCESS != ret) + { + return AESM_UNEXPECTED_ERROR; + } + return QEAESMLogic::init_quote( + reinterpret_cast(target_info), + gid, gid_size, qe_isv_svn, qe_cpu_svn); +} + +aesm_error_t AESMLogic::get_quote(const uint8_t *report, uint32_t report_size, + uint32_t quote_type, + const uint8_t *spid, uint32_t spid_size, + const uint8_t *nonce, uint32_t nonce_size, + const uint8_t *sigrl, uint32_t sigrl_size, + uint8_t *qe_report, uint32_t qe_report_size, + uint8_t *quote, uint32_t buf_size) +{ + AESM_DBG_INFO("get_quote"); + if(sizeof(sgx_report_t) != report_size || + sizeof(sgx_spid_t) != spid_size) + { + return AESM_PARAMETER_ERROR; + } + if((nonce && sizeof(sgx_quote_nonce_t) != nonce_size) + || (qe_report && sizeof(sgx_report_t) != qe_report_size)) + + { + return AESM_PARAMETER_ERROR; + } + AESMLogicLock lock(_qe_pve_mutex); + CHECK_EPID_PROVISIONG_STATUS; + return QEAESMLogic::get_quote(report, quote_type, spid, nonce, sigrl, + sigrl_size, qe_report, quote, buf_size); +} + +uint32_t AESMLogic::endpoint_selection(endpoint_selection_infos_t& es_info) +{ + AESMLogicLock lock(_qe_pve_mutex); + SGX_DBGPRINT_ONE_STRING_TWO_INTS_ENDPOINT_SELECTION(__FUNCTION__" (line, 0)", __LINE__, 0); + return EndpointSelectionInfo::instance().start_protocol(es_info); +} + + +aesm_error_t AESMLogic::report_attestation_status( + uint8_t* platform_info, uint32_t platform_info_size, + uint32_t attestation_status, + uint8_t* update_info, uint32_t update_info_size) +{ + AESM_DBG_INFO("report_attestation_status"); + AESMLogicLock lock(_pse_mutex); + return PlatformInfoLogic::report_attestation_status(platform_info, platform_info_size, attestation_status, update_info, update_info_size); +} + +ae_error_t sgx_error_to_ae_error(sgx_status_t status) +{ + if(SGX_ERROR_OUT_OF_MEMORY == status) + return AE_OUT_OF_MEMORY_ERROR; + if(SGX_SUCCESS == status) + return AE_SUCCESS; + return AE_FAILURE; +} + diff --git a/psw/ae/aesm_service/source/aesm/application/aesm_logic.h b/psw/ae/aesm_service/source/aesm/application/aesm_logic.h new file mode 100644 index 0000000000..48ef7fc527 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/aesm_logic.h @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _AESM_LOGIC_H_ +#define _AESM_LOGIC_H_ +#include "sgx_urts.h" +#include "aesm_error.h" +#include "arch.h" +#include "aeerror.h" +#include "tlv_common.h" +#include "se_thread.h" +#include "internal/se_stdio.h" +#include "internal/se_memcpy.h" +#include "internal/uncopyable.h" +#include "oal/oal.h" +#include +#include +#include "se_wrapper.h" +#include "upse/platform_info_blob.h" + +#include "default_url_info.hh" + +/*File to declare AESMLogic Class */ + +const uint32_t THREAD_TIMEOUT = 5000; + +class AESMLogicMutex{ + CLASS_UNCOPYABLE(AESMLogicMutex) +public: + AESMLogicMutex() {se_mutex_init(&mutex);} + ~AESMLogicMutex() { se_mutex_destroy(&mutex);} + void lock() { se_mutex_lock(&mutex); } + void unlock() { se_mutex_unlock(&mutex); } +private: + se_mutex_t mutex; +}; + +class AESMLogicLock { + CLASS_UNCOPYABLE(AESMLogicLock) +public: + explicit AESMLogicLock(AESMLogicMutex& cs) :_cs(cs) { _cs.lock(); } + ~AESMLogicLock() { _cs.unlock(); } +private: + AESMLogicMutex& _cs; +}; + +#define QE_PROD_ID 1 +#define PSE_PROD_ID 2 + + +typedef struct _endpoint_selection_infos_t endpoint_selection_infos_t; +class AESMLogic{ +public: + static AESMLogicMutex _qe_pve_mutex, _pse_mutex, _le_mutex; /*mutex to lock external interface*/ +private: + static psvn_t _qe_psvn, _pse_psvn; /*two different cpu svn used although they're same. We should only access qe_psvn when qe_pve_mutex is acquired and only access pse_psvn when pse_mutext is acquired*/ + static bool _is_qe_psvn_set, _is_pse_psvn_set; + static ae_error_t set_psvn(uint16_t prod_id, uint16_t isv_svn, sgx_cpu_svn_t cpu_svn); + static ae_error_t save_unverified_white_list(const uint8_t *white_list_cert, uint32_t white_list_cert_size); +public: + static ae_error_t get_qe_isv_svn(uint16_t& isv_svn);/*This function should only be called when _qe_pve_mutex is acquired*/ + static ae_error_t get_qe_cpu_svn(sgx_cpu_svn_t& cpu_svn);/*This function should only be called when _qe_pve_mutex is acquired*/ + static ae_error_t get_pse_isv_svn(uint16_t& isv_svn); /*This function should only be called when _pse_mutex is acquired*/ + static ae_error_t get_pse_cpu_svn(sgx_cpu_svn_t& cpu_svn);/*This function should only be called when _pse_mutex is acquired*/ + + static ae_error_t service_start(); + static void service_stop(); + + static bool is_service_running(); + + static sgx_status_t get_launch_token(const enclave_css_t* signature, + const sgx_attributes_t* attribute, + sgx_launch_token_t* launch_token); + + static aesm_error_t get_launch_token( + const uint8_t *mrenclave, uint32_t mrenclave_size, + const uint8_t *public_key, uint32_t public_key_size, + const uint8_t *se_attributes, uint32_t se_attributes_size, + uint8_t * lictoken, uint32_t lictoken_size); + + static aesm_error_t init_quote(uint8_t *target_info, uint32_t target_info_size, + uint8_t *gid, uint32_t gid_size); + + static aesm_error_t get_quote(const uint8_t *report, uint32_t report_size, + uint32_t quote_type, + const uint8_t *spid, uint32_t spid_size, + const uint8_t *nonce, uint32_t nonce_size, + const uint8_t *sigrl, uint32_t sigrl_size, + uint8_t *qe_report, uint32_t qe_report_size, + uint8_t *quote, uint32_t buf_size); + + static aesm_error_t create_session( + uint32_t* session_id, + uint8_t* se_dh_msg1, uint32_t se_dh_msg1_size); + + static aesm_error_t exchange_report( + uint32_t session_id, + const uint8_t* se_dh_msg2, uint32_t se_dh_msg2_size, + uint8_t* se_dh_msg3, uint32_t se_dh_msg3_size); + + static aesm_error_t close_session( + uint32_t session_id); + + static aesm_error_t invoke_service( + const uint8_t* pse_message_req, uint32_t pse_message_req_size, + uint8_t* pse_message_resp, uint32_t pse_message_resp_size); + + static aesm_error_t get_ps_cap( + uint64_t* ps_cap); + + static uint32_t endpoint_selection(endpoint_selection_infos_t& es_info); + + static aesm_error_t report_attestation_status( + uint8_t* platform_info, uint32_t platform_info_size, + uint32_t attestation_status, + uint8_t* update_info, uint32_t update_info_size); + + static aesm_error_t white_list_register( + const uint8_t *white_list_cert, uint32_t white_list_cert_size); + +}; +#endif + diff --git a/psw/ae/aesm_service/source/aesm/application/aesm_proxy_type.h b/psw/ae/aesm_service/source/aesm/application/aesm_proxy_type.h new file mode 100644 index 0000000000..092ff42949 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/aesm_proxy_type.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __AESM_PROXY_TYPE_H__ +#define __AESM_PROXY_TYPE_H__ +#define AESM_PROXY_TYPE_DIRECT_ACCESS 0 +#define AESM_PROXY_TYPE_DEFAULT_PROXY 1 +#define AESM_PROXY_TYPE_MANUAL_PROXY 2 +#define AESM_PROXY_TYPE_MAX_VALUE 2 + +#define AESM_PROXY_DEFAULT_VALUE AESM_PROXY_TYPE_DEFAULT_PROXY +#endif diff --git a/psw/ae/aesm_service/source/aesm/application/aesm_rand.cpp b/psw/ae/aesm_service/source/aesm/application/aesm_rand.cpp new file mode 100644 index 0000000000..c22f98eb41 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/aesm_rand.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include +#include "sgx_read_rand.h" +#include "se_wrapper.h" +#include "aesm_rand.h" +#include "AEClass.h" + + +extern "C" ae_error_t aesm_read_rand(unsigned char *rand_buf, unsigned int length_in_bytes) +{ + // check parameters + // + if (!rand_buf || !length_in_bytes) + { + return AE_INVALID_PARAMETER; + } + + sgx_status_t sgx_status = sgx_read_rand(rand_buf, length_in_bytes); + + return sgx_error_to_ae_error(sgx_status); +} + + + diff --git a/psw/ae/aesm_service/source/aesm/application/aesm_rand.h b/psw/ae/aesm_service/source/aesm/application/aesm_rand.h new file mode 100644 index 0000000000..f1576e31dd --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/aesm_rand.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef __AESM_RAND_H__ +#define __AESM_RAND_H__ + +#include "aeerror.h" + +extern "C" ae_error_t aesm_read_rand(unsigned char *rand, unsigned int length_in_bytes); + +#endif diff --git a/psw/ae/aesm_service/source/aesm/application/event_strings.cpp b/psw/ae/aesm_service/source/aesm/application/event_strings.cpp new file mode 100644 index 0000000000..91c384b36d --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/event_strings.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +const char* g_event_string_table[] = { + "SGX EPID provisioning network failure", // SGX_EVENT_EPID_PROV_FAILURE //network + "Fail to save attestation key in persistent storage", + // SGX_EVENT_EPID_BLOB_PERSISTENT_STROAGE_FAILURE + "Platform Info Blob Signature Error", // SGX_EVENT_PIB_SIGNATURE_FAILURE, + "PSE certificate provisioning failure", // SGX_EVENT_PSE_CERT_PROV_FAILURE //network + "OCSP failure", // SGX_EVENT_OCSP_FAILURE //network + "DAL failure", // SGX_EVENT_DAL_COMM_FAILURE //communication + "SGX disabled", // SGX_EVENT_DISABLED + "SGX Service unavailable", // SGX_EVENT_SERVICE_UNAVAILABLE + "SGX AESM will exit", // SGX_EVENT_AESM_EXIT + "PSE certificate revoked", // SGX_EVENT_PSE_CERT_REVOCATION + "PCH EPID group revoked", // SGX_EVENT_ME_EPID_GROUP_REVOCATION + "SGX EPID revocation", // SGX_EVENT_EPID_REVOCATION //SigRL fail + "SGX EPID blob integrity error", // SGX_EVENT_EPID_INTEGRITY_ERROR + "LTP blob integrity error", // SGX_EVENT_LTP_BLOB_INTEGRITY_ERROR + "LTP blob invalid error", //SGX_EVENT_LTP_BLOB_INVALID_ERROR + "PCH EPID SigRL integrity error", // SGX_EVENT_EPID11_SIGRL_INTEGRITY_ERROR + "PCH EPID PrivRL integrity error", // SGX_EVENT_EPID11_PRIVRL_INTEGRITY_ERROR + "SGX EPID SigRL integrity error", // SGX_EVENT_EPID20_SIGRL_INTEGRITY_ERROR + "PCH EPID RL retrieval failure", // SGX_EVENT_EPID11_RL_RETRIEVAL_FAILURE + "Integrity error during SGX EPID provisioning", // SGX_EVENT_EPID_PROV_INTEGRITY_ERROR + "Integrity error during PSE certificate provisioning", + // SGX_EVENT_PSE_CERT_PROV_INTEGRITY_ERROR + "OCSP response error", // SGX_EVENT_OCSP_RESPONSE_ERROR //based on non-crypto checks that AESM does + "DAL SIGMA error", // SGX_EVENT_DAL_SIGMA_ERROR //DAL returns error during Sigma protocol + "LTP failure", // SGX_EVENT_LTP_FAILURE //other than above + "DAL not installed or broken installation", // SGX_EVENT_DAL_NOT_AVAILABLE_ERROR //other than above + "PCH EPID group certificate provisioning error", + // SGX_EVENT_EPID11_GROUP_CERT_PROV_ERROR + "PSE certificate provisioning failure (Server Protocol Response %d)", + // SGX_EVENT_PSE_CERT_PROV_PROTOCOL_RESPONSE_FAILURE //backend server protocol + "PSE certificate provisioning failure (Server General Response %d)", + // SGX_EVENT_PSE_CERT_PROV_GENERAL_RESPONSE_FAILURE //backend server status + "PCH EPID signature revoked", // SGX_EVENT_ME_EPID_SIG_REVOCATION, + "PCH EPID key revoked", // SGX_EVENT_ME_EPID_KEY_REVOCATION, + "SIGMA S2 integrity error", // SGX_EVENT_SIGMA_S2_INTEGRITY_ERROR + "DAL service layer error", // SGX_EVENT_DAL_SERVICE_ERROR + "PSE attestation error" // SGX_EVENT_PSE_ATTESTATION_ERROR + +}; diff --git a/psw/ae/aesm_service/source/aesm/application/event_strings.h b/psw/ae/aesm_service/source/aesm/application/event_strings.h new file mode 100644 index 0000000000..e19c851544 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/event_strings.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _EVENT_STRINGS_H_ +#define _EVENT_STRINGS_H_ +typedef enum { + SGX_EVENT_EPID_PROV_FAILURE, /*network*/ + SGX_EVENT_EPID_BLOB_PERSISTENT_STROAGE_FAILURE, + SGX_EVENT_PID_SIGNATURE_FAILURE, + SGX_EVENT_PSE_CERT_PROV_FAILURE, + SGX_EVENT_OCSP_FAILURE, + SGX_EVENT_DAL_COMM_FAILURE, /*communication*/ + SGX_EVENT_DISABLED, + SGX_EVENT_SERVICE_UNAVAILABLE, + SGX_EVENT_AESM_EXIT, + SGX_EVENT_PSE_CERT_REVOCATION, + SGX_EVENT_ME_EPID_GROUP_REVOCATION, + SGX_EVENT_EPID_REVOCATION, /*SigRL fail*/ + SGX_EVENT_EPID_INTEGRITY_ERROR, + SGX_EVENT_LTP_BLOB_INTEGRITY_ERROR, + SGX_EVENT_LTP_BLOB_INVALID_ERROR, + SGX_EVENT_EPID11_SIGRL_INTEGRITY_ERROR, + SGX_EVENT_EPID11_PRIVRL_INTEGRITY_ERROR, + SGX_EVENT_EPID20_SIGRL_INTEGRITY_ERROR, + SGX_EVENT_EPID11_RL_RETRIEVAL_FAILURE, + SGX_EVENT_EPID_PROV_INTEGRITY_ERROR, + SGX_EVENT_PSE_CERT_PROV_INTEGRITY_ERROR, + SGX_EVENT_OCSP_RESPONSE_ERROR, /*based on non-crypto checks that AESM does*/ + SGX_EVENT_DAL_SIGMA_ERROR, /*DAL returns error during Sigma protocol*/ + SGX_EVENT_LTP_FAILURE, /*other than above*/ + SGX_EVENT_DAL_NOT_AVAILABLE_ERROR, + SGX_EVENT_EPID11_GROUP_CERT_PROV_ERROR, + SGX_EVENT_PSE_CERT_PROV_PROTOCOL_RESPONSE_FAILURE, + SGX_EVENT_PSE_CERT_PROV_GENERAL_RESPONSE_FAILURE, + SGX_EVENT_ME_EPID_SIG_REVOCATION, + SGX_EVENT_ME_EPID_KEY_REVOCATION, + SGX_EVENT_SIGMA_S2_INTEGRITY_ERROR, + SGX_EVENT_DAL_SERVICE_ERROR, + SGX_EVENT_PSE_ATTESTATION_ERROR +}sgx_event_string_table_t; + +extern const char* g_event_string_table[]; +#endif + diff --git a/psw/ae/aesm_service/source/aesm/application/main.cpp b/psw/ae/aesm_service/source/aesm/application/main.cpp new file mode 100644 index 0000000000..459bce923e --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/main.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +static bool curl_initialized; +bool is_curl_initialized_succ() +{ + return curl_initialized; +} + +static CAESMServer* server = NULL; +volatile bool reload = false; + +void signal_handler(int sig) +{ + switch(sig) + { + case SIGTERM: + if (server) + { + reload = false; + server->shutDown(); + } + break; + case SIGHUP: + if (server) + { + reload = true; + server->shutDown(); + } + break; + default: + break; + } +} + +int main() { + if(daemon(0, 0) < 0) + { + AESM_LOG_INIT(); + AESM_LOG_FATAL("Fail to set daemon."); + AESM_LOG_FINI(); + exit(1); + } + CURLcode curl_code = curl_global_init(CURL_GLOBAL_DEFAULT); + if(curl_code!=CURLE_OK){ + curl_initialized = false; + }else{ + curl_initialized = true; + } + signal(SIGCHLD, SIG_IGN); + signal(SIGHUP, signal_handler); + //ignore SIGPIPE, socket is unexpectedly closed by client + signal(SIGPIPE, SIG_IGN); + signal(SIGTERM, signal_handler); + try{ + do{ + reload = false; + AESMLogicWrapper* aesmLogic = new AESMLogicWrapper(); + if(aesmLogic->service_start()!=AE_SUCCESS){ + AESM_LOG_ERROR("Fail to start service."); + delete aesmLogic; + exit(1); + } + UnixServerSocket* serverSock = new UnixServerSocket(CONFIG_SOCKET_PATH); + + CSelector* selector = new CSelector(serverSock); + server = new CAESMServer(serverSock, selector, aesmLogic); + + AESM_LOG_WARN("The server sock is %#lx" ,serverSock); + + server->init(); + server->doWork(); + CAESMServer* temp_server = server; + server = NULL; + delete temp_server; + }while(reload == true); + } + catch(char const* error_msg) + { + AESM_LOG_FATAL("%s", error_msg); + } + + + return 0; +} diff --git a/psw/ae/aesm_service/source/aesm/application/prof_fun.h b/psw/ae/aesm_service/source/aesm/application/prof_fun.h new file mode 100644 index 0000000000..c4c6d2876b --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/application/prof_fun.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PROFILE_FUN_H_ +#define _PROFILE_FUN_H_ +#include "sgx_profile.h" +#include "oal/oal.h" + +#ifdef _PROFILE_ +class AESMProfileUtil{ + const char *tag; +public: + AESMProfileUtil(const char *ttag){ + this->tag = ttag; + PROFILE_START(ttag); + } + ~AESMProfileUtil(){ + PROFILE_END(tag); + } + static void output(){ + char filename[MAX_PATH]; + if(aesm_get_cpathname(FT_PERSISTENT_STORAGE, AESM_PERF_DATA_FID, filename, MAX_PATH)==AE_SUCCESS){ + PROFILE_OUTPUT(filename); + } + } +}; +#define AESM_PROFILE_FUN AESMProfileUtil __aesm_profile_util_##__LINE__(__PRETTY_FUNCTION__) /*Gcc in Linux does not support concatenation of __FUNCTION__, is it a compiler bug?*/ +#define AESM_PROFILE_INIT PROFILE_INIT() +#define AESM_PROFILE_OUTPUT AESMProfileUtil::output() +#else +#define AESM_PROFILE_FUN +#define AESM_PROFILE_INIT +#define AESM_PROFILE_OUTPUT +#endif + +#endif/*_AESM_PROFILE_H_*/ diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_ecdsa.cpp b/psw/ae/aesm_service/source/aesm/extension/aesm_ecdsa.cpp new file mode 100644 index 0000000000..92832a0469 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_ecdsa.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "sgx_memset_s.h" +#include "sgx_tcrypto.h" +#include "aeerror.h" +#include "tlv_common.h" +#include "cipher.h" + +ae_error_t aesm_check_pek_signature(const signed_pek_t& signed_pek) +{ + uint8_t result = SGX_EC_INVALID_SIGNATURE; + sgx_status_t sgx_code = check_pek_signature(signed_pek, &result); + if(sgx_code == SGX_ERROR_OUT_OF_MEMORY) + return AE_OUT_OF_MEMORY_ERROR; + else if(sgx_code != SGX_SUCCESS) + return AE_FAILURE; //unknown error code + else if(result != SGX_EC_VALID)//sgx_code is SGX_SUCCESS + return PVE_MSG_ERROR; //signature verification failed + else + return AE_SUCCESS;//PEK Singatue verified successfully +} + diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_encode.cpp b/psw/ae/aesm_service/source/aesm/extension/aesm_encode.cpp new file mode 100644 index 0000000000..bebc4a7e95 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_encode.cpp @@ -0,0 +1,276 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "aesm_encode.h" +#include "se_memcpy.h" +#include "AEClass.h" +#include "PVEClass.h" +#include "tlv_common.h" +#include +#include +#include +#include +#include + +/** +* Method converts byte containing value from 0x00-0x0F into its corresponding ASCII code, +* e.g. converts 0x00 to '0', 0x0A to 'A'. +* Note: This is mainly a helper method for internal use in byte_array_to_hex_string(). +* +* @param in byte to be converted (allowed values: 0x00-0x0F) +* +* @return ASCII code representation of the byte or 0 if method failed (e.g input value was not in provided range). +*/ +static uint8_t convert_value_to_ascii(uint8_t in) +{ + if(in <= 0x09) + { + return (uint8_t)(in + '0'); + } + else if(in <= 0x0F) + { + return (uint8_t)(in - 10 + 'A'); + } + + return 0; +} + +/** +* Method converts char containing ASCII code into its corresponding value, +* e.g. converts '0' to 0x00, 'A' to 0x0A. +* +* @param in char containing ASCII code (allowed values: '0-9', 'a-f', 'A-F') +* @param val output parameter containing converted value, if method suceeds. +* +* @return true if conversion succeeds, false otherwise +*/ +static bool convert_ascii_to_value(uint8_t in, uint8_t& val) +{ + if(in >= '0' && in <= '9') + { + val = static_cast(in - '0'); + } + else if(in >= 'A' && in <= 'F') + { + val = static_cast(in - 'A'+10); + } + else if(in >= 'a' && in <= 'f') + { + val = static_cast(in - 'a'+10); + } + else + { + return false; + } + + return true; +} + +//Function to do HEX encoding of array of bytes +//@param in_buf, bytes array whose length is in_size +// out_buf, output the HEX encoding of in_buf on success. +//@return true on success and false on error +//The out_size must always be 2*in_size since each byte into encoded by 2 characters +static bool byte_array_to_hex_string(const uint8_t *in_buf, uint32_t in_size, uint8_t *out_buf, uint32_t out_size) +{ + if(in_buf==NULL||out_buf==NULL|| out_size!=in_size*2 )return false; + + for(uint32_t i=0; i< in_size; i++) + { + *out_buf++ = convert_value_to_ascii( static_cast(*in_buf >> 4)); + *out_buf++ = convert_value_to_ascii( static_cast(*in_buf & 0xf)); + in_buf++; + } + return true; +} + +//Function to do HEX decoding +//@param in_buf, character strings which are HEX encoding of a byte array +// out_buf, output the decode byte array on success +//@return true on success and false on error +//The in_size must be even number and equals 2*out_size +static bool hex_string_to_byte_array(const uint8_t *in_buf, uint32_t in_size, uint8_t *out_buf, uint32_t out_size) +{ + if(in_buf==NULL||out_buf==NULL||out_size*2!=in_size)return false; + + for(uint32_t i=0;i(value_second+ (value_first<<4)); + } + return true; +} + +//Function to use openssl to do BASE64 encoding +static bool base_64_encode(const uint8_t *in_buf, uint32_t in_size, uint8_t *out_buf, uint32_t *out_size) +{ + BIO* bioMem = NULL; + bool ret = false; + BIO *bio64 = NULL; + BIO_METHOD *bm = BIO_f_base64(); + if(bm == NULL) + goto ret_point; + bio64 = BIO_new(bm); + if(bio64 == NULL) + goto ret_point; + BIO_set_flags(bio64, BIO_FLAGS_BASE64_NO_NL); + bm = BIO_s_mem(); + if(bm == NULL) + goto ret_point; + bioMem = BIO_new(bm); + if(bioMem == NULL) + goto ret_point; + (void)BIO_push(bio64, bioMem); + + if(BIO_write(bio64, in_buf, in_size) != (int)in_size){ + goto ret_point; + } + (void)BIO_flush(bio64); + + BUF_MEM *bptr; + BIO_get_mem_ptr(bio64, &bptr); + if(bptr==NULL){ + goto ret_point; + } + if(*out_size < bptr->length){ + goto ret_point; + } + if(memcpy_s(out_buf, *out_size,bptr->data, bptr->length)!=0) + goto ret_point; + + *out_size = static_cast(bptr->length); + ret = true; +ret_point: + BIO_free_all(bio64);//we need not free bioMem too because the free_all has free it. + return ret; +} + +//Function to use openssl to do BASE64 decoding +static bool base_64_decode(const uint8_t *in_buf, uint32_t in_size, uint8_t *out_buf, uint32_t *out_size) +{ + BIO *b64 =NULL, *bmem = NULL; + bool ret = false; + int read=0; + memset(out_buf, 0, *out_size); + BIO_METHOD *bm = BIO_f_base64(); + if(bm == NULL) + goto ret_point; + b64 = BIO_new(bm); + if(b64 == NULL) + goto ret_point; + BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); + bmem = BIO_new_mem_buf(const_cast(in_buf), in_size); + if(bmem == NULL){ + goto ret_point; + } + bmem = BIO_push(b64, bmem); + read = BIO_read(bmem, out_buf, *out_size); + if(read < 0) + goto ret_point; + *out_size = read; + ret = true; +ret_point: + BIO_free_all(bmem); + return ret; +} + +//Function to give an upbound of size of data after BASE64 decoding +//@param length: the length in bytes of BASE64 encoded data +//@return an upbound of length in bytes of decoded data +static uint32_t get_unbase_64_length(uint32_t length) +{ + return (length * 3 / 4) + ((length * 3 % 4 > 0) ? 1 : 0 ); +} + +//Function to give an upbound of size of data after BASR64 encoding +//@param length: the length in bytes of data to be encoded +//@return an upbound of length in bytes of data after encoding +static uint32_t get_base_64_length_upbound(uint32_t length) +{ + uint32_t extra = (length+9)/10+50;//using enough extra memory + return extra+(length*4+2)/3; +} + +uint32_t get_request_encoding_length(const uint8_t *req) +{ + //adding 1 extra byte to hold '\0' + return static_cast(2*PROVISION_REQUEST_HEADER_SIZE+get_base_64_length_upbound(GET_BODY_SIZE_FROM_PROVISION_REQUEST(req))+1); +} + +uint32_t get_response_decoding_length(uint32_t buf_len) +{ + if(buf_len<2*PROVISION_RESPONSE_HEADER_SIZE) + return 0; + return static_cast(get_unbase_64_length(buf_len-2*static_cast(PROVISION_RESPONSE_HEADER_SIZE)) + PROVISION_RESPONSE_HEADER_SIZE); +} + +bool encode_request(const uint8_t *req, uint32_t req_len, uint8_t *out_buf, uint32_t *out_len) +{ + uint32_t encoded_header_size = static_cast(2*PROVISION_REQUEST_HEADER_SIZE); + if(*out_len(2*PROVISION_RESPONSE_HEADER_SIZE), resp, static_cast(PROVISION_RESPONSE_HEADER_SIZE))) + return false; + if(*out_len(PROVISION_RESPONSE_HEADER_SIZE); + if(!base_64_decode(input_buf+static_cast(2*PROVISION_RESPONSE_HEADER_SIZE), input_len - static_cast(2*PROVISION_RESPONSE_HEADER_SIZE), + resp+static_cast(PROVISION_RESPONSE_HEADER_SIZE), out_len)) + return false; + *out_len += static_cast(PROVISION_RESPONSE_HEADER_SIZE); + if(*out_len != GET_SIZE_FROM_PROVISION_RESPONSE(resp)) + return false; + return true; +} diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_encode.h b/psw/ae/aesm_service/source/aesm/extension/aesm_encode.h new file mode 100644 index 0000000000..3b35f281e0 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_encode.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AESM_ENCODE_H_ +#define _AESM_ENCODE_H_ +#include "sgx_urts.h" +#include "se_thread.h" +#ifdef __cplusplus +extern "C"{ +#endif + +uint32_t certPseSvn(); + +/*Function to provide an upbound of buffer size of encoded message for an input request + *@param req, the header for the input request such as ProvMsg1 or ProvMsg3 + *@return an upbound of the required buffer size for the encoded message + */ +uint32_t get_request_encoding_length(const uint8_t *req); + +/*Function to provide an upbound of the response body size given the length of encoded response message + *@param buf_len, the length of the encoded message for an response message + *@return an upbound of the length in bytes of decoded response message body such as ProvMsg2 or ProvMsg4 + */ +uint32_t get_response_decoding_length(uint32_t buf_len); + +/*Function to encode an request message so that we could send it to Provisioning server + *@param req, pointer to the request + *@param out_buf, pointer to a buffer to receive the encoded request message + *@param out_len, *out_len to pass in the buffer len and return the encoded message length when successful + *@return true if successful and false if there's any error. No error code provided + */ +bool encode_request(const uint8_t *req, uint32_t req_len, uint8_t *out_buf, uint32_t *out_len); + +/*Function to decode an response message from Provisioning Server + *@param input_buf, pointer to the encoded response message + *@param input_len, length in bytes of the encoded response message + *@param resp, pointer to a bufer to recieve the decoded message + *@param out_len, *out_len to pass in the buffer len and return the decoded response message + *@return true if successful and false if there's any error. No error code provided + */ +bool decode_response(const uint8_t *input_buf, uint32_t input_len, uint8_t *resp, uint32_t *out_len); +#ifdef __cplusplus +}; +#endif/*__cplusplus*/ +#endif/*_AESM_ENCOCE_H_*/ + diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.cpp b/psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.cpp new file mode 100644 index 0000000000..cbfa1cd6fa --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "aesm_epid_blob.h" +#include "internal/se_memcpy.h" +#include "oal/oal.h" +#include "byte_order.h" + + +ae_error_t EPIDBlob::read(epid_blob_with_cur_psvn_t& blob) +{ + ae_error_t ae_ret = AE_FAILURE; + if(status == not_initialized){ + uint32_t data_size = sizeof(blob_cache); + if((ae_ret=aesm_read_data(FT_PERSISTENT_STORAGE, EPID_DATA_BLOB_FID, reinterpret_cast(&blob_cache), &data_size))!=AE_SUCCESS){ + goto CLEANUP_READ_FILE; + } + + if( data_size != sizeof(blob_cache) ) + { + ae_ret = QE_EPIDBLOB_ERROR; + goto CLEANUP_READ_FILE; + } + status = update_to_date; +CLEANUP_READ_FILE: + if(status!=update_to_date) + status = not_available;//epid blob lost + } + + if(status == update_to_date){ + if(memcpy_s(&blob, sizeof(blob), &blob_cache, sizeof(blob_cache))!=0){ + status = not_available; //invalid + ae_ret = AE_FAILURE; + }else{ + ae_ret = AE_SUCCESS; + } + } + return ae_ret; +} + +ae_error_t EPIDBlob::write(const epid_blob_with_cur_psvn_t& blob) +{ + ae_error_t ae_ret = AE_FAILURE; + status = not_available; + if((ae_ret = aesm_write_data(FT_PERSISTENT_STORAGE, EPID_DATA_BLOB_FID,reinterpret_cast(&blob), sizeof(blob)))!=AE_SUCCESS) + { + AESM_DBG_WARN("fail to write epid blob to persistent storage:%d",ae_ret); + AESM_LOG_WARN("%s",g_event_string_table[SGX_EVENT_EPID_BLOB_PERSISTENT_STROAGE_FAILURE]); + // continue to update cache + } + if(memcpy_s(&blob_cache, sizeof(blob_cache), &blob, sizeof(blob))!=0){ + status = not_available; //invalid status + ae_ret = AE_FAILURE; + }else{ + status = update_to_date; + ae_ret = AE_SUCCESS; + } + return ae_ret; +} + +// +// get_sgx_gid +// +// get sgx gid from epid blob, specifically from stored group cert in epid blob +// +// inputs +// +// pgid: pointer to gid +// +// outputs +// +// *pgid: gid +// status +// +ae_error_t EPIDBlob::get_sgx_gid(uint32_t* pgid) +{ + ae_error_t aesm_result = AE_SUCCESS; + epid_blob_with_cur_psvn_t epid_blob; + sgx_sealed_data_t *sealed_epid = reinterpret_cast(epid_blob.trusted_epid_blob); + + if (NULL != pgid) { + // + // get the epid blob + // + aesm_result = this->read(epid_blob); + if (AE_SUCCESS == aesm_result) { + // + // get the gid + // + uint32_t plain_text_offset = sealed_epid->plain_text_offset; + se_plaintext_epid_data_t* plain_text = reinterpret_cast(epid_blob.trusted_epid_blob + sizeof(sgx_sealed_data_t) + plain_text_offset); + if(memcpy_s(pgid, sizeof(*pgid), &plain_text->epid_group_cert.gid, sizeof(plain_text->epid_group_cert.gid))) //read gid from EPID Data blob + { + AESM_DBG_ERROR("memcpy_s failed"); + aesm_result = AE_FAILURE; + } + // + // return little-endian + // + *pgid = _htonl(*pgid); + AESM_DBG_TRACE(": get gid %d from epid blob", *pgid); + } + } + else { + aesm_result = AE_INVALID_PARAMETER; + } + + return aesm_result; + +} diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.h b/psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.h new file mode 100644 index 0000000000..16b49e20d6 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AESM_EPID_BLOB_H_ +#define _AESM_EPID_BLOB_H_ +/*File to declare class for EPIDBlob*/ +#include "se_types.h" +#include "sgx_tseal.h" +#include "oal/oal.h" +#include "AEClass.h" +#include "epid_pve_type.h" +#include "assert.h" +#include "aeerror.h" +#include "se_thread.h" +#include "provision_msg.h" +#include "internal/se_rwlock.h" + +typedef struct _epid_blob_with_cur_psvn_t{ + uint8_t trusted_epid_blob[HARD_CODED_EPID_BLOB_SIZE]; + psvn_t cur_psvn; +}epid_blob_with_cur_psvn_t; + +#define SGX_EPID_BLOB_SIZE sizeof(epid_blob_with_cur_psvn_t) + +class EPIDBlob: public Singleton{ + CLASS_UNCOPYABLE(EPIDBlob) + epid_blob_with_cur_psvn_t blob_cache; + friend class Singleton; + enum EPIDBlobStatus {not_initialized=0, update_to_date=1, not_available=2} status; + EPIDBlob(){memset(&blob_cache, 0 ,sizeof(blob_cache));status = not_initialized;} +public: + ae_error_t read(epid_blob_with_cur_psvn_t& blob); + ae_error_t write(const epid_blob_with_cur_psvn_t& blob); + ae_error_t get_sgx_gid(uint32_t* pgid);/*get little endian gid from epid data blob*/ +}; +#endif/*_AESM_EPID_BLOB_H_*/ + diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_http_msg.cpp b/psw/ae/aesm_service/source/aesm/extension/aesm_http_msg.cpp new file mode 100644 index 0000000000..0f7ffbc682 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_http_msg.cpp @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include "aesm_encode.h" +#include "oal.h" +#include "se_wrapper.h" +#include "prof_fun.h" +#include "aesm_proxy_type.h" +#include "endpoint_select_info.h" +#include "util.h" + +#include +#ifndef INTERNET_DEFAULT_HTTP_PORT +#define INTERNET_DEFAULT_HTTP_PORT 80 +#endif + +#define AESM_DEFAULT_CONN_TIME_OUT 1000 +#define AESM_DEFAULT_TIME_OUT 10000 + +bool is_curl_initialized_succ(void);//network is available only when curl library is successfully initialized + +typedef struct _network_malloc_info_t{ + char *base; + uint32_t size; +}network_malloc_info_t; + +static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) +{ + network_malloc_info_t* s=reinterpret_cast(stream); + uint32_t start=0; + if(s->base==NULL){ + s->base = reinterpret_cast(malloc(size*nmemb)); + s->size = static_cast(size*nmemb); + if(s->base==NULL){ + AESM_DBG_ERROR("malloc error in write callback fun"); + return 0; + } + }else{ + uint32_t newsize = s->size+static_cast(size*nmemb); + char *p=reinterpret_cast(malloc(newsize)); + if(p == NULL){ + free(s->base); + s->base = NULL; + AESM_DBG_ERROR("malloc error in write callback fun"); + return 0; + } + memcpy(p, s->base, s->size); + free(s->base); + start = s->size; + s->base = p; + s->size = newsize; + } + memcpy(s->base +start, ptr, size*nmemb); + return nmemb; +} + +static ae_error_t http_network_init(CURL **curl, const char *url, bool is_ocsp) +{ + CURLcode cc = CURLE_OK; + UNUSED(is_ocsp); + AESM_DBG_TRACE("http init for url %s",url); + if(!is_curl_initialized_succ()){ + AESM_DBG_ERROR("libcurl not initialized"); + return AE_FAILURE;//fatal error that libcurl could not be initialized + } + std::string url_path = url; + uint32_t proxy_type; + char proxy_url[MAX_PATH]; + EndpointSelectionInfo::instance().get_proxy(proxy_type, proxy_url); + + *curl = curl_easy_init(); + if(!*curl){ + AESM_DBG_ERROR("fail to init curl handle"); + return AE_FAILURE; + } + if((cc=curl_easy_setopt(*curl, CURLOPT_URL, url_path.c_str()))!=CURLE_OK){ + AESM_DBG_ERROR("fail error code %d in set url %s",(int)cc, url_path.c_str()); + return AE_FAILURE; + } + (void)curl_easy_setopt(*curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + //setting proxy now + if(proxy_type == AESM_PROXY_TYPE_DIRECT_ACCESS){ + AESM_DBG_TRACE("use no proxy"); + (void)curl_easy_setopt(*curl, CURLOPT_NOPROXY , "*"); + }else if(proxy_type == AESM_PROXY_TYPE_MANUAL_PROXY){ + AESM_DBG_TRACE("use manual proxy %s",proxy_url); + (void)curl_easy_setopt(*curl, CURLOPT_PROXY, proxy_url); + } + return AE_SUCCESS; +} + +static ae_error_t http_network_send_data(CURL *curl, const char *req_msg, uint32_t msg_size, char **resp_msg, uint32_t& resp_size, http_methods_t method, bool is_ocsp) +{ + AESM_DBG_TRACE("send data method=%d",method); + struct curl_slist *headers=NULL; + CURLcode cc=CURLE_OK; + if(is_ocsp){ + headers = curl_slist_append(headers, "Accept: application/ocsp-response"); + if(headers==NULL){ + AESM_DBG_ERROR("fail in add accept ocsp-response header"); + return AE_FAILURE; + } + headers = curl_slist_append(headers, "Content-Type: application/ocsp-request"); + if(headers == NULL){ + AESM_DBG_ERROR("fail in add content type ocsp-request"); + return AE_FAILURE; + } + AESM_DBG_TRACE("ocsp request"); + } + char buf[50]; + sprintf(buf, "Content-Length: %u", (unsigned int)msg_size); + headers = curl_slist_append(headers, buf); + if(headers == NULL){ + AESM_DBG_ERROR("fail to add content-length header"); + return AE_FAILURE; + } + if((cc=curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers))!=CURLE_OK){ + AESM_DBG_ERROR("fail to set http header:%d",(int)cc); + return AE_FAILURE; + } + if(method == POST){ + if((cc=curl_easy_setopt(curl, CURLOPT_POSTFIELDS, req_msg))!=CURLE_OK){ + AESM_DBG_ERROR("fail to set POST fields:%d",(int)cc); + return AE_FAILURE; + } + if((cc=curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, msg_size))!=CURLE_OK){ + AESM_DBG_ERROR("fail to set POST fields size:%d",(int)cc); + return AE_FAILURE; + } + } + if((cc=curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback))!=CURLE_OK){ + AESM_DBG_ERROR("Fail to set callback function:%d",(int)cc); + return AE_FAILURE; + } + + network_malloc_info_t malloc_info; + malloc_info.base=NULL; + malloc_info.size = 0; + if((cc=curl_easy_setopt(curl, CURLOPT_WRITEDATA, reinterpret_cast(&malloc_info)))!=CURLE_OK){ + AESM_DBG_ERROR("fail to set write back function parameter:%d",(int)cc); + return AE_FAILURE; + } + if((cc=curl_easy_perform(curl))!=CURLE_OK){ + if(malloc_info.base){ + free(malloc_info.base); + } + AESM_DBG_ERROR("fail in connect:%d",(int)cc); + return OAL_NETWORK_UNAVAILABLE_ERROR; + } + *resp_msg = malloc_info.base; + resp_size = malloc_info.size; + AESM_DBG_TRACE("get response size=%d",resp_size); + return AE_SUCCESS; +} + +static void http_network_fini(CURL *curl) +{ + if(curl!=NULL) + curl_easy_cleanup(curl); +} + + +ae_error_t aesm_network_send_receive(const char *server_url, const uint8_t *req, uint32_t req_size, + uint8_t **p_resp, uint32_t *p_resp_size, http_methods_t method, bool is_ocsp) +{ + AESM_PROFILE_FUN; + ae_error_t ret= AE_SUCCESS; + CURL *curl = NULL; + ret = http_network_init(&curl, server_url, is_ocsp); + if(ret != AE_SUCCESS){ + goto ret_point; + } + ret = http_network_send_data(curl, reinterpret_cast(req), req_size, + reinterpret_cast(p_resp), *p_resp_size, method, is_ocsp); +ret_point: + http_network_fini(curl); + return ret; +} + +void aesm_free_network_response_buffer(uint8_t *resp) +{ + if(resp!=NULL)free(resp); +} diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.cpp b/psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.cpp new file mode 100644 index 0000000000..1395c8438d --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.cpp @@ -0,0 +1,510 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "aesm_long_lived_thread.h" +#include "pve_logic.h" +#include "platform_info_logic.h" +#include "oal/internal_log.h" +#include "se_time.h" +#include "se_wrapper.h" +#include +#include +#include + +enum _thread_state +{ + ths_idle, + ths_busy, + ths_stop//The thread is to be stopped and no new job will be accepted +}; + +enum _io_cache_state +{ + ioc_idle, //thread has been finished + ioc_busy, //thread not finished yet + ioc_stop //thread stop required +}; + +#define MAX_OUTPUT_CACHE 50 +class ThreadStatus; +class BaseThreadIOCache; +typedef ae_error_t (*long_lived_thread_func_t)(BaseThreadIOCache *cache); + +//Base class for cached data of each thread to fork +class BaseThreadIOCache:private Uncopyable{ + time_t timeout; //The data will timeout after the time if the state is not busy + int ref_count; //ref_count is used to track how many threads are currently referencing the data + _io_cache_state status; + //handle of the thread, some thread will be waited by other threads so that we could not + // free the handle until all other threads have got notification that the thread is terminated + aesm_thread_t thread_handle; + friend class ThreadStatus; +protected: + ae_error_t ae_ret; + BaseThreadIOCache():ref_count(0),status(ioc_busy){ + timeout=0; + thread_handle=NULL; + ae_ret = AE_FAILURE; + } + virtual ThreadStatus& get_thread()=0; +public: + virtual ae_error_t entry(void)=0; + virtual bool operator==(const BaseThreadIOCache& oc)const=0; + ae_error_t start(BaseThreadIOCache *&out_ioc, uint32_t timeout=THREAD_TIMEOUT); + void deref(void); + void set_status_finish(); +public: + virtual ~BaseThreadIOCache(){} +}; + +class ThreadStatus: private Uncopyable +{ +private: + AESMLogicMutex thread_mutex; + _thread_state thread_state; + uint64_t status_clock; + BaseThreadIOCache *cur_iocache; + std::listoutput_cache; +protected: + friend class BaseThreadIOCache; + //function to look up cached output, there will be no real thread associated with the input ioc + //If a match is found the input parameter will be free automatically and the matched value is returned + //return true if a thread will be forked for the out_ioc + bool find_or_insert_iocache(BaseThreadIOCache* ioc, BaseThreadIOCache *&out_ioc) + { + AESMLogicLock locker(thread_mutex); + std::list::reverse_iterator it; + out_ioc=NULL; + if(thread_state == ths_stop){ + AESM_DBG_TRACE("thread %p has been stopped and ioc %p not inserted", this,ioc); + delete ioc; + return false;//never visit any item after thread is stopped + } + time_t cur=time(NULL); + AESM_DBG_TRACE("cache size %d",(int)output_cache.size()); + BaseThreadIOCache *remove_candidate = NULL; + for(it=output_cache.rbegin();it!=output_cache.rend();++it){//visit the cache in reverse order so that the newest item will be visited firstly + BaseThreadIOCache *pioc=*it; + if((pioc->status==ioc_idle)&&(pioc->timeoutref_count==0&&remove_candidate==NULL){ + remove_candidate = pioc; + } + continue;//value timeout + } + if(*pioc==*ioc){//matched value find + pioc->ref_count++;//reference it + AESM_DBG_TRACE("IOC %p matching input IOC %p (ref_count:%d,status:%d,timeout:%d) in thread %p",pioc, ioc,(int)pioc->ref_count,(int)pioc->status, (int)pioc->timeout, this); + out_ioc= pioc; + delete ioc; + return false; + } + } + if(thread_state == ths_busy){//It is not permitted to insert in busy status + AESM_DBG_TRACE("thread busy when trying insert input ioc %p",ioc); + delete ioc; + return false; + } + if(remove_candidate!=NULL){ + output_cache.remove(remove_candidate); + delete remove_candidate; + } + if(output_cache.size()>=MAX_OUTPUT_CACHE){ + std::list::iterator fit; + bool erased=false; + for(fit = output_cache.begin(); fit!=output_cache.end();++fit){ + BaseThreadIOCache *pioc=*fit; + if(pioc->ref_count==0){//find a not timeout item to remove + assert(pioc->status==ioc_idle); + AESM_DBG_TRACE("erase idle ioc %p", pioc); + output_cache.erase(fit); + erased = true; + AESM_DBG_TRACE("thread %p cache size %d",this, output_cache.size()); + delete pioc; + break; + } + } + if(!erased){//no item could be removed + AESM_DBG_TRACE("no free ioc found and cannot insert ioc %p",ioc); + delete ioc; + return false;//similar as busy status + } + } + output_cache.push_back(ioc); + out_ioc = cur_iocache = ioc; + cur_iocache->ref_count=2;//initialize to be refenced by parent thread and the thread itself + thread_state = ths_busy;//mark thread to be busy that the thread to be started + AESM_DBG_TRACE("successfully add ioc %p (status=%d,timeout=%d) into thread %p",out_ioc, (int)out_ioc->status, (int)out_ioc->timeout, this); + return true; + } + +public: + ThreadStatus():output_cache() + { + thread_state = ths_idle; + status_clock = 0; + cur_iocache = NULL; + } + void set_status_finish(BaseThreadIOCache* ioc);//only called at the end of aesm_long_lived_thread_entry + void deref(BaseThreadIOCache* iocache); + ae_error_t wait_iocache(BaseThreadIOCache* ioc); + + //create thread and wait at most 'timeout' for the thread to be finished + // It will first look up whether there is a previous run with same input before starting the thread + // we should not delete ioc after calling to this function + ae_error_t set_thread_start(BaseThreadIOCache* ioc, BaseThreadIOCache *&out_ioc, uint32_t timeout=THREAD_TIMEOUT); + + void stop_thread();//We need wait for thread to be terminated and all thread_handle in list to be closed + + ~ThreadStatus(){stop_thread();}//ThreadStatus instance should be global object. Otherwise, it is possible that the object is destroyed before a thread waiting for and IOCache got notified and causing exception + + ae_error_t wait_for_cur_thread(void); + + //function to query whether current thread is idle, + //if it is idle, return true and reset clock to current clock value + bool query_status_and_reset_clock(void); +}; + +ae_error_t BaseThreadIOCache::start(BaseThreadIOCache *&out_ioc, uint32_t timeout_value) +{ + return get_thread().set_thread_start(this, out_ioc, timeout_value); +} + +void BaseThreadIOCache::deref(void) +{ + get_thread().deref(this); +} + +void BaseThreadIOCache::set_status_finish(void) +{ + get_thread().set_status_finish(this); +} + +//This is thread entry wrapper for all threads +static ae_error_t aesm_long_lived_thread_entry(aesm_thread_arg_type_t arg) +{ + BaseThreadIOCache *cache=(BaseThreadIOCache *)arg; + ae_error_t ae_err = cache->entry(); + cache->set_status_finish(); + return ae_err; +} + +void ThreadStatus::stop_thread() +{ + //change state to stop + thread_mutex.lock(); + thread_state = ths_stop; + + do{ + std::list::iterator it; + for(it=output_cache.begin(); it!=output_cache.end();++it){ + BaseThreadIOCache *p=*it; + if(p->status != ioc_stop){//It has not been processed + p->status = ioc_stop; + break; + } + } + if(it!=output_cache.end()){//found item to stop + BaseThreadIOCache *p=*it; + p->ref_count++; + thread_mutex.unlock(); + wait_iocache(p); + thread_mutex.lock(); + }else{ + break; + } + }while(1); + + thread_mutex.unlock(); + //This function should only be called at AESM exit + //Leave memory leak here is OK and all pointer to BaseThreadIOCache will not be released +} + +ae_error_t ThreadStatus::wait_for_cur_thread(void) +{ + BaseThreadIOCache *ioc=NULL; + thread_mutex.lock(); + if(cur_iocache!=NULL){ + ioc = cur_iocache; + ioc->ref_count++; + } + thread_mutex.unlock(); + if(ioc!=NULL){ + return wait_iocache(ioc); + } + return AE_SUCCESS; +} + +ae_error_t ThreadStatus::wait_iocache(BaseThreadIOCache* ioc) +{ + ae_error_t ae_ret=AE_SUCCESS; + bool need_wait=false; + aesm_thread_t handle=NULL; + thread_mutex.lock(); + if(ioc->thread_handle!=NULL){ + AESM_DBG_TRACE("wait for busy ioc %p(refcount=%d)",ioc,ioc->ref_count); + need_wait = true; + handle = ioc->thread_handle; + } + thread_mutex.unlock(); + if(need_wait){ + ae_ret= aesm_wait_thread(handle, &ae_ret, AESM_THREAD_INFINITE); + } + deref(ioc); + return ae_ret; +} + +void ThreadStatus::deref(BaseThreadIOCache *ioc) +{ + aesm_thread_t handle = NULL; + time_t cur=time(NULL); + { + AESMLogicLock locker(thread_mutex); + AESM_DBG_TRACE("deref ioc %p (ref_count=%d,status=%d,timeout=%d) of thread %p",ioc,(int)ioc->ref_count,(int)ioc->status,(int)ioc->timeout, this); + --ioc->ref_count; + if(ioc->ref_count == 0){//try free the thread handle now + handle = ioc->thread_handle; + ioc->thread_handle = NULL; + if(ioc->status == ioc_busy){ + ioc->status = ioc_idle; + } + AESM_DBG_TRACE("free thread handle for ioc %p",ioc); + } + if(ioc->ref_count==0 &&(ioc->status==ioc_stop||ioc->timeoutthread_handle); + if (ae_ret != AE_SUCCESS) + { + AESM_DBG_TRACE("fail to create thread for ioc %p",out_ioc); + AESMLogicLock locker(thread_mutex); + thread_state = ths_idle; + out_ioc->status = ioc_idle;//set to finished status + cur_iocache = NULL; + deref(out_ioc); + return ae_ret; + }else{ + AESM_DBG_TRACE("succ create thread %p for ioc %p",this, out_ioc); + } + } + + if(out_ioc == NULL){ + AESM_DBG_TRACE("no ioc created for input ioc %p in thread %p",ioc, this); + return OAL_THREAD_TIMEOUT_ERROR; + } + + {//check whether thread has been finished + AESMLogicLock locker(thread_mutex); + if(out_ioc->status!=ioc_busy){//job is done + AESM_DBG_TRACE("job done for ioc %p (status=%d,timeout=%d,ref_count=%d) in thread %p",out_ioc, (int)out_ioc->status,(int)out_ioc->timeout,(int)out_ioc->ref_count,this); + return AE_SUCCESS; + } + } + + if(timeout >= AESM_THREAD_INFINITE ){ + ae_ret = aesm_join_thread(out_ioc->thread_handle, &ret); + }else{ + uint64_t now = se_get_tick_count(); + double timediff = static_cast(timeout) - (static_cast(now - status_clock))/static_cast(se_get_tick_count_freq()) *1000; + if (timediff <= 0.0) { + AESM_DBG_ERROR("long flow thread timeout"); + return OAL_THREAD_TIMEOUT_ERROR; + } + else{ + AESM_DBG_TRACE("timeout:%u,timediff: %f", timeout,timediff); + ae_ret = aesm_wait_thread(out_ioc->thread_handle, &ret, (unsigned long)timediff); + } + } + AESM_DBG_TRACE("wait for ioc %p (status=%d,timeout=%d,ref_count=%d) result:%d",out_ioc,(int)out_ioc->status,(int)out_ioc->timeout,(int)out_ioc->ref_count, ae_ret); + return ae_ret; +}; + +#define TIMEOUT_SHORT_TIME 60 +#define TIMEOUT_FOR_A_WHILE (5*60) +#define TIMEOUT_LONG_TIME (3600*24) //at most once every day +static time_t get_timeout_via_ae_error(ae_error_t ae) +{ + time_t cur=time(NULL); + switch(ae){ + case AE_SUCCESS: + case OAL_PROXY_SETTING_ASSIST: + case OAL_NETWORK_RESEND_REQUIRED: + return cur-1;//always timeout, the error code will never be reused + case PVE_INTEGRITY_CHECK_ERROR: + case OAL_NETWORK_UNAVAILABLE_ERROR: + case OAL_NETWORK_BUSY: + case PVE_SERVER_BUSY_ERROR: + return cur+TIMEOUT_SHORT_TIME; //retry after short time + case QE_REVOKED_ERROR: + case PVE_REVOKED_ERROR: + case PVE_MSG_ERROR: + case PVE_PERFORMANCE_REKEY_NOT_SUPPORTED: + case PSW_UPDATED_REQUIRED: + return cur+TIMEOUT_LONG_TIME; + default: + return cur+TIMEOUT_FOR_A_WHILE;//not retry too quickly for unknown error + } +} + +void ThreadStatus::set_status_finish(BaseThreadIOCache* ioc) +{ + aesm_thread_t handle = NULL; + { + AESMLogicLock locker(thread_mutex); + assert(thread_state==ths_busy||thread_state==ths_stop); + assert(ioc->status == ioc_busy); + AESM_DBG_TRACE("set finish status for ioc %p(status=%d,timeout=%d,ref_count=%d) of thread %p",ioc, (int)ioc->status,(int)ioc->timeout,(int)ioc->ref_count,this); + if(thread_state==ths_busy){ + AESM_DBG_TRACE("set thread %p to idle", this); + thread_state=ths_idle; + cur_iocache = NULL; + } + ioc->status=ioc_idle; + ioc->ref_count--; + ioc->timeout = get_timeout_via_ae_error(ioc->ae_ret); + if(ioc->ref_count==0){//try free thread handle + handle = ioc->thread_handle; + ioc->thread_handle = NULL; + AESM_DBG_TRACE("thread handle release for ioc %p and status to idle of thread %p",ioc, this); + } + } + if(handle!=NULL){ + aesm_free_thread(handle); + } +} + +bool ThreadStatus::query_status_and_reset_clock(void) +{ + AESMLogicLock locker(thread_mutex); + if(thread_state == ths_busy || thread_state == ths_stop) + return false; + status_clock = se_get_tick_count(); + return true; +} + +//Code above implement logic of threads in the AESM Service +//Code below to define IOCache of each thread +static ThreadStatus epid_thread; + + +class EpidProvIOCache:public BaseThreadIOCache{ + bool performance_rekey;//input +protected: + EpidProvIOCache(bool perf_rekey){ + this->performance_rekey = perf_rekey; + } + virtual ae_error_t entry(void); + virtual ThreadStatus& get_thread(); + friend ae_error_t start_epid_provision_thread(bool performance_rekey, unsigned long timeout); +public: + virtual bool operator==(const BaseThreadIOCache& oc)const{ + const EpidProvIOCache *p=dynamic_cast(&oc); + if(p==NULL)return false; + return performance_rekey==p->performance_rekey;//only compare input + } +}; + + +ThreadStatus& EpidProvIOCache::get_thread() +{ + return epid_thread; +} + + +ae_error_t EpidProvIOCache::entry() +{ + return ae_ret = PvEAESMLogic::epid_provision_thread_func(performance_rekey); +} + + +//start implementation of external functions + +#define INIT_THREAD(cache_type, timeout, init_list) \ + BaseThreadIOCache *ioc = new cache_type init_list; \ + BaseThreadIOCache *out_ioc = NULL; \ + ae_error_t ae_ret = AE_FAILURE; \ + ae_ret = ioc->start(out_ioc, (uint32_t)(timeout)); \ + if(ae_ret != AE_SUCCESS){ \ + if(out_ioc!=NULL){out_ioc->deref();}\ + return ae_ret; \ + }\ + assert(out_ioc!=NULL);\ + cache_type *pioc = dynamic_cast(out_ioc);\ + assert(pioc!=NULL); + //now the thread has finished it's execution and we could read result without lock +#define COPY_OUTPUT(x) x=pioc->x +#define FINI_THREAD() \ + ae_ret = pioc->ae_ret;\ + pioc->deref();/*derefence the cache object after usage of it*/ \ + return ae_ret; + +//usage model +//INIT_THREAD(thread_used, cache_type, timeout, init_list) +// COPY_OUTPUT(is_new_pairing);// copy out output parameter except for return value from pioc object to output parameter, such as +//FINI_THREAD(thread_used) + +ae_error_t start_epid_provision_thread(bool performance_rekey, unsigned long timeout) +{ + INIT_THREAD(EpidProvIOCache, timeout, (performance_rekey)) + FINI_THREAD() +} + +bool query_pve_thread_status(void) +{ + return epid_thread.query_status_and_reset_clock(); +} + +ae_error_t wait_pve_thread(void) +{ + return epid_thread.wait_for_cur_thread(); +} + +void stop_all_long_lived_threads(void) +{ + epid_thread.stop_thread(); +} diff --git a/psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.h b/psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.h new file mode 100644 index 0000000000..1685b80078 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AESM_LONG_LIVED_THREAD_H_ +#define _AESM_LONG_LIVED_THREAD_H_ +#include "aesm_logic.h" + +extern ae_error_t start_epid_provision_thread(bool performance_rekey, unsigned long timeout=THREAD_TIMEOUT); +extern bool query_pve_thread_status(void);/*return true if idle and reset clock for thread*/ +extern ae_error_t wait_pve_thread(void); +extern void stop_all_long_lived_threads(void); +#endif + diff --git a/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.cpp b/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.cpp new file mode 100644 index 0000000000..0c0f8754cd --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.cpp @@ -0,0 +1,290 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "endpoint_select_info.h" +#include "PVEClass.h" +#include "prov_msg_size.h" +#include "network_encoding_wrapper.h" +#include "ipp_wrapper.h" +#include "sgx_tcrypto.h" +#include "ippcp.h" +#include "ippcore.h" +#include "sgx_read_rand.h" +#include "se_wrapper.h" +#include + + +//Function to do basic checking of the endpoint selection blob. Esp to avoid no zero-ending in the input string url +static bool is_valid_endpoint_selection_info(const endpoint_selection_infos_t& es_info) +{ + if(es_info.aesm_data_type != AESM_DATA_ENDPOINT_SELECTION_INFOS) + return false; + if(es_info.aesm_data_version != AESM_DATA_ENDPOINT_SELECTION_VERSION) + return false; + if(strnlen(es_info.provision_url,MAX_PATH)>=MAX_PATH) + return false; + return true; +} + +ae_error_t EndpointSelectionInfo::read_pek(endpoint_selection_infos_t& es_info) +{ + ae_error_t ae_err=AE_SUCCESS; + uint32_t es_info_size = sizeof(es_info); + + ae_err = aesm_read_data(FT_PERSISTENT_STORAGE, PROVISION_PEK_BLOB_FID, reinterpret_cast(&es_info), &es_info_size); + + if(AE_SUCCESS == ae_err && (es_info_size != sizeof(es_info)||!is_valid_endpoint_selection_info(es_info))){ + AESM_DBG_ERROR("Invalid ES result in persistent storage:size %d, expected size %d", es_info_size, sizeof(es_info)); + ae_err = OAL_FILE_ACCESS_ERROR; + } + + if(AE_SUCCESS == ae_err){ + AESM_DBG_INFO("Read ES result from persistent storage successfully"); + }else{ + AESM_DBG_WARN("ES result in persistent storage failed to load:%d", ae_err); + } + + return ae_err; +} + +ae_error_t EndpointSelectionInfo::write_pek(const endpoint_selection_infos_t& es_info) +{ + return aesm_write_data(FT_PERSISTENT_STORAGE, PROVISION_PEK_BLOB_FID, reinterpret_cast(&es_info), sizeof(es_info)); +} + +static ae_error_t ipp_error_to_ae_error(IppStatus ipp_status) +{ + if(ipp_status == ippStsNoErr) return AE_SUCCESS; + else if(ipp_status == ippStsMemAllocErr|| + ipp_status == ippStsNoMemErr) return AE_OUT_OF_MEMORY_ERROR; + else return AE_FAILURE;//unknown or unexpected ipp error +} + +ae_error_t aesm_check_pek_signature(const signed_pek_t& signed_pek); +IppStatus get_provision_server_rsa_pub_key_in_ipp_format(const signed_pek_t& pek, IppsRSAPublicKeyState **rsa_pub_key); + +//The function is to verify the PEK ECDSA Signature and RSA Signature for ES Msg2 +// When PvE uses PEK, it will re-check the ECDSA Signature +//The function will only be called after ES protocol is completed. But it will not be called when reading data back from persitent storage +//@param provision_ttl: The TTL field from ES Msg2 in little endian format +//@param rsa_signature: The RSA Signature in ES Msg2, it is RSA Signature to XID:TTL:provision_url +//@param xid: The transaction id (XID) of the ES Protocol +//@return AE_SUCCESS if signature verification success and passed +//@return PVE_MSG_ERROR if signature verification failed or message error +//other kinds of error code could be returned too due to corresponding error situation +ae_error_t EndpointSelectionInfo::verify_signature(const endpoint_selection_infos_t& es_info, uint8_t xid[XID_SIZE], uint8_t rsa_signature[PVE_RSA_KEY_BYTES], uint16_t provision_ttl) +{ + //Do signature verification here + ae_error_t ae_err = AE_SUCCESS; + IppsRSAPublicKeyState *rsa_pub_key = NULL; + Ipp8u *buffer = NULL; + int public_key_buffer_size = 0; + int vr = 0; + uint16_t ttl=_htons(provision_ttl); + IppStatus ipp_status = ippStsNoErr; + uint8_t msg_buf[XID_SIZE + sizeof(ttl) + MAX_PATH]; + uint32_t buf_size = 0; + + ae_err = aesm_check_pek_signature(es_info.pek); + if(AE_SUCCESS != ae_err){ + AESM_DBG_ERROR("PEK Signature verifcation not passed:%d",ae_err); + goto ret_point; + } + AESM_DBG_INFO("PEK signature verified successfully"); + buf_size = XID_SIZE +static_cast(sizeof(ttl) + strnlen_s(es_info.provision_url, MAX_PATH)); + if(0!=memcpy_s(msg_buf,sizeof(msg_buf), xid, XID_SIZE)|| + 0!=memcpy_s(msg_buf+XID_SIZE, sizeof(ttl) + MAX_PATH, &ttl, sizeof(ttl))|| + 0!=memcpy_s(msg_buf+XID_SIZE+sizeof(ttl), MAX_PATH, es_info.provision_url, buf_size-XID_SIZE-sizeof(ttl))){ + ae_err = AE_FAILURE; + AESM_DBG_ERROR("memcpy error"); + goto ret_point; + } + + ipp_status = get_provision_server_rsa_pub_key_in_ipp_format(es_info.pek, &rsa_pub_key); + if(ippStsNoErr != ipp_status){ + AESM_DBG_ERROR("Fail to load rsa public key from PEK:%d", ipp_status); + ae_err = ipp_error_to_ae_error(ipp_status); + goto ret_point; + } + ipp_status = ippsRSA_GetBufferSizePublicKey(&public_key_buffer_size, rsa_pub_key); + if(ippStsNoErr != ipp_status){ + AESM_DBG_ERROR("Fail to get rsa public key size:%s", ipp_status); + ae_err = ipp_error_to_ae_error(ipp_status); + goto ret_point; + } + buffer = (Ipp8u *)malloc(public_key_buffer_size); + if(NULL == buffer){ + AESM_DBG_ERROR("malloc error"); + ae_err = AE_OUT_OF_MEMORY_ERROR; + goto ret_point; + } + ipp_status = ippsRSAVerify_PKCS1v15(msg_buf, buf_size, rsa_signature, &vr, rsa_pub_key, ippHashAlg_SHA256, buffer); + if(ippStsNoErr != ipp_status){ + AESM_DBG_ERROR("Fail to verify rsa signature:%d", ipp_status); + ae_err = ipp_error_to_ae_error(ipp_status); + goto ret_point; + } + if(vr == 0){ + AESM_DBG_TRACE("rsa signature verification failed"); + ae_err = PVE_MSG_ERROR; + goto ret_point; + }else{ + AESM_DBG_TRACE("rsa signature verification passed"); + ae_err = AE_SUCCESS; + } +ret_point: + if(NULL != rsa_pub_key){ + secure_free_rsa_pub_key(PVE_RSA_KEY_BYTES, sizeof(uint32_t), rsa_pub_key); + } + if(NULL != buffer){ + free(buffer); + } + return ae_err; +} + +#define MAX_ENCLAVE_LOST_RETRY_TIME 1 + +bool read_aesm_config(aesm_config_infos_t& infos); + +//Function to implement the end point selection protocol +ae_error_t EndpointSelectionInfo::start_protocol(endpoint_selection_infos_t& es_info) +{ + AESMLogicLock lock(_es_lock); + uint32_t msg_size = 0; + uint8_t *resp = NULL; + uint32_t resp_size = 0; + uint16_t provision_ttl = 0; + uint8_t *msg = NULL; + uint8_t rsa_signature[PVE_RSA_KEY_BYTES]; + gen_endpoint_selection_output_t enclave_output; + ae_error_t ae_ret = AE_SUCCESS; + uint32_t enclave_lost_count = 0; + + AESM_DBG_DEBUG("enter fun"); + memset(&es_info, 0, sizeof(es_info)); + memset(&enclave_output, 0, sizeof(enclave_output)); + if(!_is_server_url_loaded){ + (void) read_aesm_config(_server_urls); + _is_server_url_loaded = true; + } + + do{ + if((ae_ret = CPVEClass::instance().load_enclave())!=AE_SUCCESS){ + AESM_DBG_ERROR("Fail to load PVE enclave:%d", ae_ret); + goto final_point; + } + //call PvE to generate the partition and xid + ae_ret = static_cast(CPVEClass::instance().gen_es_msg1_data(&enclave_output)); + if(ae_ret == AE_ENCLAVE_LOST&& (++enclave_lost_count)<=MAX_ENCLAVE_LOST_RETRY_TIME ){ + CPVEClass::instance().unload_enclave();//unload and reload PvE when enclave lost encountered + continue; + }else if(ae_ret == AE_SUCCESS){ + break; + }else{ + AESM_DBG_ERROR("fail to generate parition by PvE"); + goto final_point; + } + }while(1); + + AESM_DBG_TRACE("use parition %d from PvE", (int)enclave_output.selector_id); + + AESM_DBG_INFO("Connect to server url \"%s\" for endpoint selection", _server_urls.endpoint_url); + + msg_size = estimate_es_msg1_size(); + assert(msg_size>0); + msg = reinterpret_cast(malloc(msg_size)); + if(msg == NULL){ + AESM_DBG_ERROR("malloc error"); + ae_ret = AE_OUT_OF_MEMORY_ERROR; + goto final_point; + } + memset(msg, 0, msg_size); + + ae_ret = static_cast(CPVEClass::instance().gen_es_msg1(msg, msg_size, enclave_output));//Generate EndPoint Selection Msg1 + if(ae_ret != AE_SUCCESS){ + AESM_DBG_ERROR("ES msg1 generation failed:%d",ae_ret); + goto final_point; + } + AESM_DBG_TRACE("ES msg1 generated"); + + ae_ret = AESMNetworkEncoding::aesm_send_recv_msg_encoding(_server_urls.endpoint_url, msg, msg_size, resp, resp_size);//Encoding/send/receive/Decoding + + if(ae_ret != AE_SUCCESS){ + AESM_DBG_ERROR("fail to send ES msg1 to backend server:%d",ae_ret); + if(OAL_PROXY_SETTING_ASSIST == ae_ret){//when proxy setting assistant required, return directly + goto final_point; + } + if(read_pek(es_info)==AE_SUCCESS){ + ae_ret = AE_SUCCESS;//use es_info inside persistent storage and ignore network error + } + goto final_point; + } + assert(resp != NULL); + AESM_DBG_TRACE("start to process ES msg2"); + ae_ret = static_cast(CPVEClass::instance().proc_es_msg2(resp, resp_size, es_info.provision_url, provision_ttl, enclave_output.xid, rsa_signature , es_info.pek)); + if(AE_SUCCESS != ae_ret){ + AESM_DBG_WARN("Fail to process ES msg2 from backend server:%d",ae_ret); + goto final_point; + } + + AESM_DBG_TRACE("ES Msg2 decoded successfully, ttl %ds",provision_ttl); + ae_ret = verify_signature(es_info, enclave_output.xid, rsa_signature, provision_ttl); + if(AE_SUCCESS != ae_ret){ + AESM_DBG_WARN("Signature verification in ES Msg2 failed"); + goto final_point; + } + AESM_DBG_TRACE("Signature in ES Msg2 verified"); + es_info.aesm_data_type = AESM_DATA_ENDPOINT_SELECTION_INFOS; + es_info.aesm_data_version = AESM_DATA_ENDPOINT_SELECTION_VERSION; + (void)write_pek(es_info);//ignore file writing error + AESM_DBG_TRACE("end point selection succ, provisioning url: %s",es_info.provision_url); + +final_point: + if(msg!=NULL)free(msg); + if(resp!=NULL){ + AESMNetworkEncoding::aesm_free_response_msg(resp); + } + + return ae_ret; +} + +void EndpointSelectionInfo::get_proxy(uint32_t& proxy_type, char proxy_url[MAX_PATH]) +{ + AESMLogicLock lock(_es_lock); + if(!_is_server_url_loaded){ + (void)read_aesm_config(_server_urls); + _is_server_url_loaded=true; + } + proxy_type = _server_urls.proxy_type; + strcpy(proxy_url, _server_urls.aesm_proxy); +} + diff --git a/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.h b/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.h new file mode 100644 index 0000000000..39c38a0ebb --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _ENDPOINT_SELECT_INFO_H_ +#define _ENDPOINT_SELECT_INFO_H_ +#include "se_types.h" +#include "sgx_tseal.h" +#include "aeerror.h" +#include "tlv_common.h" +#include "se_thread.h" +#include "internal/se_rwlock.h" +#include "oal/oal.h" +#include "se_wrapper.h" +#include +#include +#include "AEClass.h" +#include "aesm_logic.h" + +#define AESM_DATA_ENDPOINT_SELECTION_INFOS 'B' +#define AESM_DATA_ENDPOINT_SELECTION_VERSION 1 +#pragma pack(1) +#include "aesm_config.h" + +/*Struct for data to save endpoint selection protocol result into persistent data storage*/ +typedef struct _endpoint_selection_infos_t{ + uint8_t aesm_data_type; + uint8_t aesm_data_version; + signed_pek_t pek; + char provision_url[MAX_PATH]; +}endpoint_selection_infos_t; +#pragma pack() + +/*An interface to provide the endpoint selection protocol and also provide some URLs (result of ES protocol or some static url) + *Singleton class used to provide a singleton instance in memory and lock used so that it could be shared by PvE/PSEPR + *EndpointSelectionInfo::instance().start_protocol(...) could be used to get endpoint selection result + * It will restart the ES protocol to get updated data. If the protocol fails, it may resue existing endpoint selection protocol result in persistent storage + */ +class EndpointSelectionInfo: public Singleton{ + CLASS_UNCOPYABLE(EndpointSelectionInfo); + friend class Singleton; +private: + AESMLogicMutex _es_lock; /*lock used since the data will be accessed by two different components: PSEPR and PVE*/ + aesm_config_infos_t _server_urls; /*some readonly urls */ + bool _is_server_url_valid; /*Set it to true when field _server_urls is valid*/ + bool _is_server_url_loaded;/*Set it to true after trying to read _server_urls from persistent storage. If _is_server_url_valid is false but this field is true, it means there're problem in persistent storage access*/ + static ae_error_t read_pek(endpoint_selection_infos_t& es_info); /*read _es_info from persistent storage*/ + static ae_error_t write_pek(const endpoint_selection_infos_t& es_info); /*save _es_info to persistent storage*/ + ae_error_t verify_signature(const endpoint_selection_infos_t& es_info, uint8_t xid[XID_SIZE], uint8_t rsa_signature[PVE_RSA_KEY_BYTES], uint16_t ttl); /*verify rsa signature in ES protocol result*/ +public: + EndpointSelectionInfo(){ + memset(&_server_urls, 0, sizeof(_server_urls)); + _is_server_url_loaded=false; + _is_server_url_valid=false; + } +public: + void get_proxy(uint32_t& proxy_type, char proxy_url[MAX_PATH]); + /*Function to get result of Endpoint Selection Protocol from Backend Server*/ + ae_error_t start_protocol(endpoint_selection_infos_t& es_info); +}; +#endif /*_ENDPOINT_SELECT_INFO_H_*/ + diff --git a/psw/ae/aesm_service/source/aesm/extension/platform_info_logic.cpp b/psw/ae/aesm_service/source/aesm/extension/platform_info_logic.cpp new file mode 100644 index 0000000000..40ed197950 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/platform_info_logic.cpp @@ -0,0 +1,345 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "util.h" +#include "platform_info_logic.h" +#include "sgx_quote.h" +#include "aesm_encode.h" +#include "pve_logic.h" +#include "aesm_logic.h" +#include +#include "sgx_profile.h" +#include "le2be_macros.h" +#include "pibsk_pub.hh" +#include "sgx_sha256_128.h" +#include "aesm_long_lived_thread.h" + +ae_error_t PlatformInfoLogic::get_sgx_epid_group_flags(const platform_info_blob_wrapper_t* p_platform_info_blob, uint8_t* pflags) +{ + ae_error_t retval = AE_SUCCESS; + if (NULL != pflags && NULL != p_platform_info_blob && p_platform_info_blob->valid_info_blob){ + *pflags = p_platform_info_blob->platform_info_blob.sgx_epid_group_flags; + } + else { + retval = AE_INVALID_PARAMETER; + } + return retval; +} + +ae_error_t PlatformInfoLogic::get_sgx_tcb_evaluation_flags(const platform_info_blob_wrapper_t* p_platform_info_blob, uint16_t* pflags) +{ + ae_error_t retval = AE_SUCCESS; + if (NULL != pflags && NULL != p_platform_info_blob && p_platform_info_blob->valid_info_blob) { + const uint16_t* p = reinterpret_cast(p_platform_info_blob->platform_info_blob.sgx_tcb_evaluation_flags); + *pflags = lv_ntohs(*p); + } + else { + retval = AE_INVALID_PARAMETER; + } + return retval; +} + +bool PlatformInfoLogic::sgx_gid_out_of_date(const platform_info_blob_wrapper_t* p_platform_info_blob) +{ + uint8_t flags = 0; + bool retVal = false; + ae_error_t getflagsError = get_sgx_epid_group_flags(p_platform_info_blob, &flags); + if (AE_SUCCESS == getflagsError) { + retVal = (0 != (QE_EPID_GROUP_OUT_OF_DATE & flags)); + } + SGX_DBGPRINT_ONE_STRING_TWO_INTS_CREATE_SESSION(__FUNCTION__" returning ", retVal, retVal); + + return retVal; +} + +ae_error_t PlatformInfoLogic::need_epid_provisioning(const platform_info_blob_wrapper_t* p_platform_info_blob) +{ + ae_error_t status = AESM_NEP_DONT_NEED_EPID_PROVISIONING; + if (sgx_gid_out_of_date(p_platform_info_blob) && + !qe_svn_out_of_date(p_platform_info_blob) && + !cpu_svn_out_of_date(p_platform_info_blob)) + { + status = AESM_NEP_DONT_NEED_UPDATE_PVEQE; // don't need update, but need epid provisioning + } + else if (!sgx_gid_out_of_date(p_platform_info_blob) && performance_rekey_available(p_platform_info_blob)) + { + status = AESM_NEP_PERFORMANCE_REKEY; + } + SGX_DBGPRINT_ONE_STRING_TWO_INTS_CREATE_SESSION(__FUNCTION__" returning ", status, status); + return status; +} + + +ae_error_t pib_verify_signature(platform_info_blob_wrapper_t& piBlobWrapper) +{ + ae_error_t ae_err = AE_FAILURE; + sgx_ecc_state_handle_t ecc_handle = NULL; + + uint8_t result = SGX_EC_INVALID_SIGNATURE; + + const uint32_t data_size = static_cast(sizeof(piBlobWrapper.platform_info_blob) - sizeof(piBlobWrapper.platform_info_blob.signature)); + + + piBlobWrapper.valid_info_blob = false; + do + { + sgx_ec256_public_t publicKey; + sgx_ec256_signature_t signature; + sgx_status_t sgx_status; + + //BREAK_IF_TRUE((sizeof(publicKey) != sizeof(s_pib_pub_key_big_endian)), ae_err, AE_FAILURE); + //BREAK_IF_TRUE((sizeof(signature) != sizeof(piBlobWrapper.platform_info_blob.signature)), ae_err, AE_FAILURE); + + // convert the public key to little endian + if(0!=memcpy_s(&publicKey, sizeof(publicKey), s_pib_pub_key_big_endian, sizeof(s_pib_pub_key_big_endian))){ + ae_err = AE_FAILURE; + break; + } + SwapEndian_32B(((uint8_t*)&publicKey) + 0); + SwapEndian_32B(((uint8_t*)&publicKey) + 32); + + // convert the signature to little endian + if(0!=memcpy_s(&signature, sizeof(signature), &piBlobWrapper.platform_info_blob.signature, sizeof(piBlobWrapper.platform_info_blob.signature))){ + ae_err = AE_FAILURE; + break; + } + SwapEndian_32B(((uint8_t*)&signature) + 0); + SwapEndian_32B(((uint8_t*)&signature) + 32); + + sgx_status = sgx_ecc256_open_context(&ecc_handle); + BREAK_IF_TRUE((SGX_SUCCESS != sgx_status), ae_err, AE_FAILURE); + + sgx_status = sgx_ecdsa_verify((uint8_t*)&piBlobWrapper.platform_info_blob, data_size, &publicKey, &signature, &result, ecc_handle); + BREAK_IF_TRUE((SGX_SUCCESS != sgx_status), ae_err, AE_FAILURE); + + if (SGX_EC_VALID != result) + { + AESM_LOG_WARN(g_event_string_table[SGX_EVENT_PID_SIGNATURE_FAILURE]); + break; + } + + piBlobWrapper.valid_info_blob = true; + + ae_err = AE_SUCCESS; + + } while (0); + if (ecc_handle != NULL) { + sgx_ecc256_close_context(ecc_handle); + } + + return ae_err; +} + +aesm_error_t PlatformInfoLogic::report_attestation_status( + uint8_t* platform_info, uint32_t platform_info_size, + uint32_t attestation_status, + uint8_t* update_info, uint32_t update_info_size) +{ + AESM_DBG_TRACE("enter fun"); + // + // we don't do anything without platform info + // + if (NULL == platform_info) { + return AESM_PARAMETER_ERROR; + } + + platform_info_blob_wrapper_t pibw; + + // + // presence of platform info is conditional, on whether we're up to date + // if we're up to date, no platform info and no need for update info + // + if (((sizeof(pibw.platform_info_blob) > platform_info_size)) || ((NULL != update_info) && (sizeof(sgx_update_info_bit_t) > update_info_size))) { + return AESM_PARAMETER_ERROR; + } + + pibw.valid_info_blob = false; + memcpy_s(&pibw.platform_info_blob, sizeof(pibw.platform_info_blob), platform_info, platform_info_size); + + aesm_error_t status = AESM_SUCCESS; // status only tells app to look at updateInfo + + // + // contents of input platform info can get stale, but not by virtue of anything we do + // (the latest/current versions can change) + // therefore, we'll use the same platform info the whole time + // + bool pibSigGood = (AE_SUCCESS == pib_verify_signature(pibw)); + // + // invalid pib is an error whenever it's provided + // + if (!pibSigGood) { + AESM_DBG_ERROR("pib verify signature failed"); + return AESM_PLATFORM_INFO_BLOB_INVALID_SIG; + } + + ae_error_t nepStatus = need_epid_provisioning(&pibw); + AESM_DBG_TRACE("need_epid_provisioning return %d",nepStatus); + switch (nepStatus) + { + case AESM_NEP_DONT_NEED_EPID_PROVISIONING: + { + break; + } + case AESM_NEP_DONT_NEED_UPDATE_PVEQE: // sure thing + { + AESMLogicLock lock(AESMLogic::_qe_pve_mutex); + if(!query_pve_thread_status()){//If another thread is busy on Epid Provisioning + status = AESM_SUCCESS; + break; + } + bool perfRekey = false; + status = PvEAESMLogic::provision(perfRekey, THREAD_TIMEOUT); + if (AESM_BUSY == status || //thread timeout + AESM_PROXY_SETTING_ASSIST == status || //uae service need to set up proxy info and retry + AESM_UPDATE_AVAILABLE == status) //PSW need be updated + { + return status;//We should return to uae serivce directly + } + if (AESM_SUCCESS != status && + AESM_OUT_OF_MEMORY_ERROR != status && + AESM_BACKEND_SERVER_BUSY != status && + AESM_NETWORK_ERROR != status && + AESM_NETWORK_BUSY_ERROR != status) + { + status = AESM_SGX_PROVISION_FAILED; + } + break; + } + case AESM_NEP_PERFORMANCE_REKEY: + { + if (0 == attestation_status) // pr only if we succeeded (also we'll never get pr unless gid up-to-date) + { + bool perfRekey = true; + AESMLogicLock lock(AESMLogic::_qe_pve_mutex); + if(!query_pve_thread_status()){//If another thread is busy on Epid Provisioning + status = AESM_SUCCESS; + break; + } + status = PvEAESMLogic::provision(perfRekey, THREAD_TIMEOUT); + if (AESM_BUSY == status ||//thread timeout + AESM_PROXY_SETTING_ASSIST == status ||//uae service need to set up proxy info and retry + AESM_UPDATE_AVAILABLE == status) + { + return status;//We should return to uae serivce directly + } + if (AESM_SUCCESS != status && + AESM_OUT_OF_MEMORY_ERROR != status && + AESM_BACKEND_SERVER_BUSY != status && + AESM_NETWORK_ERROR != status && + AESM_NETWORK_BUSY_ERROR != status) + { + status = AESM_SGX_PROVISION_FAILED; + } + } + break; + } + default: + { + status = AESM_UNEXPECTED_ERROR; + break; + } + } + + // + // don't nag happy app about updates + // + if ((0 != attestation_status) && (NULL != update_info)) + { + sgx_update_info_bit_t* p_update_info = (sgx_update_info_bit_t*)update_info; + memset(p_update_info, 0, sizeof(*p_update_info)); + + // + // here, we treat values that get reported live - cpusvn, qe.isvsvn + // in normal flow, live values reported to attestation server will be the same as current values now so + // we just look at out-of-date bits corresponding to these values. + // the alternative would be to compare current with latest as reported by IAS. this + // isn't an option for cpusvn since what we get from IAS is equivalent cpusvn. + // + if (cpu_svn_out_of_date(&pibw)) + { + p_update_info->ucodeUpdate = 1; + status = AESM_UPDATE_AVAILABLE; + } + if (qe_svn_out_of_date(&pibw)) + { + p_update_info->pswUpdate = 1; + status = AESM_UPDATE_AVAILABLE; + } + + } + return status; +} + +bool PlatformInfoLogic::cpu_svn_out_of_date(const platform_info_blob_wrapper_t* p_platform_info_blob) +{ + uint16_t flags = 0; + bool retVal = false; + ae_error_t getflagsError = get_sgx_tcb_evaluation_flags(p_platform_info_blob, &flags); + if (AE_SUCCESS == getflagsError) { + retVal = ( 0 !=(QUOTE_CPUSVN_OUT_OF_DATE & flags)); + } + SGX_DBGPRINT_ONE_STRING_TWO_INTS_CREATE_SESSION(__FUNCTION__" returning ", retVal, retVal); + + return retVal; +} + +bool PlatformInfoLogic::qe_svn_out_of_date(const platform_info_blob_wrapper_t* p_platform_info_blob) +{ + uint16_t flags = 0; + // + // default to true since easy to update QE/PvE + // + bool retVal = true; + ae_error_t getflagsError = get_sgx_tcb_evaluation_flags(p_platform_info_blob, &flags); + if (AE_SUCCESS == getflagsError) { + retVal = ( 0 !=(QUOTE_ISVSVN_QE_OUT_OF_DATE & flags)); + } + SGX_DBGPRINT_ONE_STRING_TWO_INTS_CREATE_SESSION(__FUNCTION__" returning ", retVal, retVal); + return retVal; +} + +bool PlatformInfoLogic::performance_rekey_available(const platform_info_blob_wrapper_t* p_platform_info_blob) +{ + // + // return whether platform info blob says PR is available + // the group associated with PR that's returned corresponds to the group + // that we'll be in **after** executing PR + // + bool retVal = false; + uint8_t flags; + ae_error_t getflagsError = get_sgx_epid_group_flags(p_platform_info_blob, &flags); + if (AE_SUCCESS == getflagsError) { + retVal = static_cast(flags & PERF_REKEY_FOR_QE_EPID_GROUP_AVAILABLE); + } + SGX_DBGPRINT_ONE_STRING_TWO_INTS_CREATE_SESSION(__FUNCTION__" returning ", retVal, retVal); + return retVal; +} diff --git a/psw/ae/aesm_service/source/aesm/extension/platform_info_logic.h b/psw/ae/aesm_service/source/aesm/extension/platform_info_logic.h new file mode 100644 index 0000000000..d77a713496 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/platform_info_logic.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PLATFORM_INFO_LOGIC_H_ +#define _PLATFORM_INFO_LOGIC_H_ +#include "sgx_urts.h" +#include "aesm_error.h" +#include "aeerror.h" +#include "oal/oal.h" +#include "upse/platform_info_blob.h" + +struct update_pse_thread_func_arg; + +/*File to declare PlatformInfoLogic Class which is platform independent*/ +class PlatformInfoLogic{ +public: + static aesm_error_t report_attestation_status( + uint8_t* platform_info, uint32_t platform_info_size, + uint32_t attestation_status, + uint8_t* update_info, uint32_t update_info_size); + + + static ae_error_t need_epid_provisioning(const platform_info_blob_wrapper_t* p_platform_info_blob); + + static bool sgx_gid_out_of_date(const platform_info_blob_wrapper_t* p_platform_info_blob); + static bool cpu_svn_out_of_date(const platform_info_blob_wrapper_t* p_platform_info_blob); + static bool qe_svn_out_of_date(const platform_info_blob_wrapper_t* p_platform_info_blob); + static bool performance_rekey_available(const platform_info_blob_wrapper_t* p_platform_info_blob); + +private: + static ae_error_t get_sgx_epid_group_flags(const platform_info_blob_wrapper_t* p_platform_info_blob, uint8_t* flags); + static ae_error_t get_sgx_tcb_evaluation_flags(const platform_info_blob_wrapper_t* p_platform_info_blob, uint16_t* flags); + +}; +#endif + diff --git a/psw/ae/aesm_service/source/aesm/extension/type_length_value.cpp b/psw/ae/aesm_service/source/aesm/extension/type_length_value.cpp new file mode 100644 index 0000000000..301026fb57 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/type_length_value.cpp @@ -0,0 +1,526 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: type_length_value.cpp + * Description: Cpp file for code to decoding/encoding of the TLV, the type length value encoding format of Provision Message + */ + +#include "type_length_value.h" +#include "sgx.h" +#include "se_wrapper.h" +#include "oal/oal.h" +#include + +#ifdef DBG_LOG +#define CASE_ENUM_RET_STRING(x) case x: return #x; +const char *get_tlv_enum_type_t_string(uint8_t type){ + switch(type){ + CASE_ENUM_RET_STRING(TLV_CIPHER_TEXT) + CASE_ENUM_RET_STRING(TLV_BLOCK_CIPHER_TEXT) + CASE_ENUM_RET_STRING(TLV_BLOCK_CIPHER_INFO) + CASE_ENUM_RET_STRING(TLV_MESSAGE_AUTHENTICATION_CODE) + CASE_ENUM_RET_STRING(TLV_NONCE) + CASE_ENUM_RET_STRING(TLV_EPID_GID) + CASE_ENUM_RET_STRING(TLV_EPID_SIG_RL) + CASE_ENUM_RET_STRING(TLV_EPID_GROUP_CERT) + CASE_ENUM_RET_STRING(TLV_DEVICE_ID) + CASE_ENUM_RET_STRING(TLV_PS_ID) + CASE_ENUM_RET_STRING(TLV_EPID_JOIN_PROOF) + CASE_ENUM_RET_STRING(TLV_EPID_SIG) + CASE_ENUM_RET_STRING(TLV_EPID_MEMBERSHIP_CREDENTIAL) + CASE_ENUM_RET_STRING(TLV_EPID_PSVN) + CASE_ENUM_RET_STRING(TLV_QUOTE) + CASE_ENUM_RET_STRING(TLV_X509_CERT_TLV) + CASE_ENUM_RET_STRING(TLV_X509_CSR_TLV) + CASE_ENUM_RET_STRING(TLV_ES_SELECTOR) + CASE_ENUM_RET_STRING(TLV_ES_INFORMATION) + CASE_ENUM_RET_STRING(TLV_FLAGS) + CASE_ENUM_RET_STRING(TLV_QUOTE_SIG) + CASE_ENUM_RET_STRING(TLV_PEK) + CASE_ENUM_RET_STRING(TLV_SIGNATURE) + default: + return "Unknown TLV"; + } +} +#endif +//Function to write tlv header into a msg according to tlv info, the input buffer size should be at least MAX_TLV_HEADER_SIZE +static tlv_status_t write_tlv_header(uint8_t *msg, const tlv_info_t *info) +{ + uint8_t type = info->type; + if(info->size>UINT16_MAX ||info->header_size == LARGE_TLV_HEADER_SIZE){//6 bytes header + uint32_t size = info->size; //4 bytes in size field + type |= FOUR_BYTES_SIZE_TYPE; + msg[0] = type; + msg[1] = info->version; + size = _htonl(size); + if(memcpy_s(&msg[2], sizeof(uint32_t), &size, sizeof(size))!=0){ + AESM_DBG_ERROR("memcpy failed"); + return TLV_UNKNOWN_ERROR; + } + }else{//4 bytes header + uint16_t size = (uint16_t)info->size;//2 bytes in size field + msg[0] = type; + msg[1] = info->version; + size = _htons(size); + if(memcpy_s(&msg[2], sizeof(uint16_t), &size, sizeof(size))!=0){ + AESM_DBG_ERROR("memcpy failed"); + return TLV_UNKNOWN_ERROR; + } + } + return TLV_SUCCESS; +} + +//Function to read the first tlv info from msg and return length in bytes of the TLV header (so it provides offset of TLV payload) +// the function return 0 on error +static uint32_t read_tlv_info(const tlv_msg_t& msg, tlv_info_t *info) +{ + if(msg.msg_sizetype = GET_TLV_TYPE(msg.msg_buf[0]); + info->version = msg.msg_buf[1]; + if(IS_FOUR_BYTES_SIZE_TYPE(msg.msg_buf[0])){//four bytes or two bytes of size + if(msg.msg_sizesize, sizeof(info->size), &msg.msg_buf[2], sizeof(uint32_t)); + info->size = _ntohl(info->size); + info->payload = msg.msg_buf+LARGE_TLV_HEADER_SIZE; + info->header_size = LARGE_TLV_HEADER_SIZE; + return LARGE_TLV_HEADER_SIZE;//6 bytes TLV header + }else{ + uint16_t size = 0; + (void)memcpy_s(&size, sizeof(uint16_t), &msg.msg_buf[2], sizeof(uint16_t)); + info->size = (uint32_t)_ntohs(size); //reorder to form little endian size value and extended by 0 + info->payload = msg.msg_buf+SMALL_TLV_HEADER_SIZE; + info->header_size = SMALL_TLV_HEADER_SIZE; + return SMALL_TLV_HEADER_SIZE; //4 bytes TLV header + } +} + +static bool decode_one_tlv(tlv_msg_t& msg, tlv_info_t *info) +{ + if(msg.msg_sizesize; + if(msg.msg_sizeUINT16_MAX){//6 bytes TLV header + if(payload_size>UINT32_MAX-LARGE_TLV_HEADER_SIZE)//overflow of uint32_t, return 0 to indicate error + return 0; + return LARGE_TLV_HEADER_SIZE; + }else{ + return SMALL_TLV_HEADER_SIZE;//4 bytes TLV header + } +} + +uint32_t get_tlv_header_size(const tlv_info_t *info) +{ + assert(info->header_size == LARGE_TLV_HEADER_SIZE|| + info->header_size == SMALL_TLV_HEADER_SIZE); + return info->header_size; +} + +uint32_t get_tlv_total_size(const tlv_info_t &info) +{ + return get_tlv_header_size(&info)+info.size; +} + +static uint32_t calc_one_tlv_size(const tlv_info_t& infos) +{ + uint32_t the_size = 0; + if(infos.header_size == UNKNOWN_TLV_HEADER_SIZE) + the_size = get_tlv_total_size(infos.size); + else + the_size = get_tlv_total_size(infos); + return the_size; +} + + +static tlv_status_t tlv_msg_init_one_tlv(tlv_info_t* infos, const tlv_msg_t& tlv_msg) +{ + uint16_t hsize; + tlv_status_t status = TLV_SUCCESS; + if(infos->header_size == UNKNOWN_TLV_HEADER_SIZE) + hsize = get_tlv_header_size_from_payload_size(infos->size); //TLV header size + else + hsize = (uint8_t)infos->header_size; + uint32_t tsize = hsize+infos->size; //size of header and payload + if(tlv_msg.msg_sizeheader_size = hsize; + infos->payload = tlv_msg.msg_buf + hsize; //initialize the payload of the tlv_info + if(tsize=1); + assert(info.payload!=NULL); + return info.payload; +} + +tlv_msg_t cipher_text_tlv_get_encrypted_text(const tlv_info_t& info) +{ + assert(info.type == TLV_CIPHER_TEXT && info.size>=1); + assert(info.payload!=NULL); + tlv_msg_t tlv_msg; + tlv_msg.msg_buf = info.payload+1; + tlv_msg.msg_size = info.size -1; + return tlv_msg; +} + +tlv_iv_t *block_cipher_tlv_get_iv(const tlv_info_t& info) +{ + assert(info.type == TLV_BLOCK_CIPHER_TEXT && info.size >= IV_SIZE); + assert(info.payload!=NULL); + return reinterpret_cast(info.payload); +} + +tlv_msg_t block_cipher_tlv_get_encrypted_text(const tlv_info_t& info) +{ + assert(info.type == TLV_BLOCK_CIPHER_TEXT && info.size >= IV_SIZE); + assert(info.payload!=NULL); + tlv_msg_t tlv_msg; + tlv_msg.msg_buf = info.payload + IV_SIZE; + tlv_msg.msg_size = info.size - IV_SIZE; + return tlv_msg; +} + + +fmsp_t *device_id_tlv_get_fmsp(const tlv_info_t& info) +{ + assert(info.type == TLV_DEVICE_ID && info.size == DEVICE_ID_TLV_PAYLOAD_SIZE()); + assert(info.payload!=NULL); + return reinterpret_cast(info.payload+sizeof(psvn_t)+sizeof(ppid_t)); +} + +psvn_t *device_id_tlv_get_psvn(const tlv_info_t& info) +{ + assert(info.type == TLV_DEVICE_ID && info.size == DEVICE_ID_TLV_PAYLOAD_SIZE()); + assert(info.payload!=NULL); + return reinterpret_cast(info.payload+sizeof(ppid_t)); +} + + +tlv_status_t TLVsMsg::init_from_tlv_msg(const tlv_msg_t& tlv_msg) +{ + clear(); + msg.msg_size = tlv_msg.msg_size; + msg.msg_buf = (uint8_t *)malloc(msg.msg_size); + if(msg.msg_buf == NULL){ + msg.msg_size = 0; + AESM_DBG_ERROR("malloc failed"); + return TLV_OUT_OF_MEMORY_ERROR; + } + if(memcpy_s(msg.msg_buf, msg.msg_size, tlv_msg.msg_buf, tlv_msg.msg_size)!=0){ + AESM_DBG_ERROR("memcpy failed"); + return TLV_UNKNOWN_ERROR; + } + tlv_msg_t tlv_tmp = msg; + tlv_info_t one_info; + tlv_info_t *new_info = NULL; + while(tlv_tmp.msg_size>0){ + if(decode_one_tlv(tlv_tmp, &one_info)){ + tlv_status_t ret = create_new_info(new_info); + if(ret != TLV_SUCCESS) return ret; + if(memcpy_s(new_info, sizeof(*new_info), &one_info, sizeof(one_info))!=0){ + AESM_DBG_ERROR("memcpy failed"); + return TLV_UNKNOWN_ERROR; + } +#ifdef DBG_LOG + char dbg_str[256]; + aesm_dbg_format_hex(new_info->payload, new_info->size, dbg_str, 256); + AESM_DBG_TRACE("Decode One TLV: type %s, size %u, version %d, payload:%s",get_tlv_enum_type_t_string(new_info->type), new_info->size, (int)new_info->version,dbg_str); +#endif + }else{ + return TLV_INVALID_MSG_ERROR; + } + } + return TLV_SUCCESS; +} + +tlv_status_t TLVsMsg::init_from_buffer(const uint8_t *msg_buf, uint32_t msg_size) +{ + tlv_msg_t tlv_msg; + tlv_msg.msg_buf=const_cast(msg_buf); + tlv_msg.msg_size = msg_size; + return init_from_tlv_msg(tlv_msg); +} + +tlv_status_t TLVsMsg::alloc_more_buffer(uint32_t new_size, tlv_msg_t& new_buf) +{ + if(msg.msg_buf == NULL){ + assert(msg.msg_size==0); + msg.msg_buf = (uint8_t *)malloc(new_size); + if(msg.msg_buf == NULL){ + return TLV_OUT_OF_MEMORY_ERROR; + } + msg.msg_size = new_size; + new_buf = msg; + }else{ + uint8_t *old_p = msg.msg_buf; + uint8_t *p = (uint8_t *)malloc(msg.msg_size+new_size); + if(p==NULL){ + return (TLV_OUT_OF_MEMORY_ERROR); + } + if(0!=memcpy_s(p,msg.msg_size+new_size, old_p, msg.msg_size)){ + free(p); + return TLV_UNKNOWN_ERROR; + } + size_t i; + for(i=0;ipayload, new_info->size, dbg_str, 256);\ + AESM_DBG_INFO("create TLV: type %s, size %u, version %d, payload %s", get_tlv_enum_type_t_string(new_info->type), new_info->size, (int)new_info->version, dbg_str);\ +} +#else +#define ADD_TLV_DBG_INFO +#endif + +tlv_status_t TLVsMsg::add_cipher_text(const uint8_t *text, uint32_t len, uint8_t key_id) +{ + tlv_info_t one_info; + one_info.header_size = UNKNOWN_TLV_HEADER_SIZE; + one_info.payload = NULL; + one_info.size = CIPHER_TEXT_TLV_PAYLOAD_SIZE(len); + one_info.type = TLV_CIPHER_TEXT; + one_info.version = TLV_VERSION_1; + uint32_t size = ::calc_one_tlv_size(one_info); + tlv_msg_t new_buf; + tlv_info_t *new_info = NULL; + tlv_status_t ret = alloc_more_buffer(size, new_buf); + if(ret != TLV_SUCCESS) + return ret; + ret = create_new_info(new_info); + if(ret != TLV_SUCCESS) + return ret; + if((ret = ::tlv_msg_init_one_tlv(&one_info, new_buf)) !=TLV_SUCCESS){ + return ret; + } + *cipher_text_tlv_get_key_id(one_info)=key_id; + new_buf = cipher_text_tlv_get_encrypted_text(one_info); + if(memcpy_s(new_buf.msg_buf, new_buf.msg_size, text, len)!=0){ + return TLV_UNKNOWN_ERROR; + } + if(memcpy_s(new_info, sizeof(*new_info), &one_info, sizeof(one_info))!=0){ + return TLV_UNKNOWN_ERROR; + } + ADD_TLV_DBG_INFO + return TLV_SUCCESS; +} + +tlv_status_t TLVsMsg::add_block_cipher_text(const uint8_t iv[IV_SIZE],const uint8_t *text, uint32_t len) +{ + tlv_info_t one_info; + one_info.header_size = UNKNOWN_TLV_HEADER_SIZE; + one_info.payload = NULL; + one_info.size = BLOCK_CIPHER_TEXT_TLV_PAYLOAD_SIZE(len); + one_info.type = TLV_BLOCK_CIPHER_TEXT; + one_info.version = TLV_VERSION_1; + uint32_t size = ::calc_one_tlv_size(one_info); + tlv_msg_t new_buf; + tlv_info_t *new_info = NULL; + tlv_status_t ret = alloc_more_buffer(size, new_buf); + if(ret != TLV_SUCCESS) + return ret; + ret = create_new_info(new_info); + if(ret != TLV_SUCCESS) + return ret; + if((ret=::tlv_msg_init_one_tlv(&one_info, new_buf))!=TLV_SUCCESS){ + return ret; + } + new_buf = block_cipher_tlv_get_encrypted_text(one_info); + if(len>0&&text!=NULL){ + if(memcpy_s(new_buf.msg_buf, new_buf.msg_size, text, len)!=0){ + return (TLV_UNKNOWN_ERROR); + } + } + if(memcpy_s(block_cipher_tlv_get_iv(one_info), IV_SIZE, iv, IV_SIZE)!=0){ + return (TLV_UNKNOWN_ERROR); + } + if(memcpy_s(new_info, sizeof(*new_info), &one_info, sizeof(one_info))!=0){ + return TLV_UNKNOWN_ERROR; + } + ADD_TLV_DBG_INFO + return TLV_SUCCESS; +} + +tlv_status_t TLVsMsg::add_block_cipher_info(const uint8_t sk[SK_SIZE]) +{ + tlv_info_t one_info; + one_info.header_size = UNKNOWN_TLV_HEADER_SIZE; + one_info.payload = NULL; + one_info.size = BLOCK_CIPHER_INFO_TLV_PAYLOAD_SIZE(); + one_info.type = TLV_BLOCK_CIPHER_INFO; + one_info.version = TLV_VERSION_1; + uint32_t size = ::calc_one_tlv_size(one_info); + tlv_msg_t new_buf; + tlv_info_t *new_info = NULL; + tlv_status_t ret = alloc_more_buffer(size, new_buf); + if(ret!=TLV_SUCCESS) + return ret; + ret = create_new_info(new_info); + if(ret!=TLV_SUCCESS) + return ret; + if((ret=::tlv_msg_init_one_tlv(&one_info, new_buf))!=TLV_SUCCESS){ + return ret; + } + if(memcpy_s(one_info.payload, one_info.size, sk, SK_SIZE)!=0){ + return (TLV_UNKNOWN_ERROR); + } + if(memcpy_s(new_info, sizeof(*new_info),&one_info, sizeof(one_info))!=0) + return TLV_UNKNOWN_ERROR; + ADD_TLV_DBG_INFO + return TLV_SUCCESS; +} + +#define ADD_TLV_BY_DATA_SIZE(data_type, data, data_size) \ + tlv_info_t one_info; \ + one_info.header_size = UNKNOWN_TLV_HEADER_SIZE; \ + one_info.payload = NULL;\ + one_info.size = data_size;\ + one_info.type = data_type; \ + one_info.version = TLV_VERSION_1; \ + uint32_t size = ::calc_one_tlv_size(one_info);\ + tlv_msg_t new_buf; \ + tlv_info_t *new_info = NULL; \ + tlv_status_t ret = alloc_more_buffer(size, new_buf); \ + if(ret!=TLV_SUCCESS){ \ + return ret; \ + } \ + ret = create_new_info(new_info); \ + if(ret != TLV_SUCCESS) \ + return ret; \ + if((ret=::tlv_msg_init_one_tlv(&one_info, new_buf))!=TLV_SUCCESS){ \ + return ret; \ + }\ + if(memcpy_s(one_info.payload, one_info.size, data, data_size)!=0){\ + return (TLV_UNKNOWN_ERROR);\ + }\ + if(memcpy_s(new_info, sizeof(*new_info), &one_info, sizeof(one_info))!=0) \ + return TLV_UNKNOWN_ERROR; \ + ADD_TLV_DBG_INFO \ + return TLV_SUCCESS; + +tlv_status_t TLVsMsg::add_mac(const uint8_t mac[MAC_SIZE]) +{ + ADD_TLV_BY_DATA_SIZE(TLV_MESSAGE_AUTHENTICATION_CODE, mac, MAC_SIZE) +} + +tlv_status_t TLVsMsg::add_nonce(const uint8_t *nonce, uint32_t nonce_size) +{ + ADD_TLV_BY_DATA_SIZE(TLV_NONCE, nonce, nonce_size) +} + + +tlv_status_t TLVsMsg::add_epid_gid(const GroupID& gid) +{ + ADD_TLV_BY_DATA_SIZE(TLV_EPID_GID, &gid, sizeof(GroupID)) +} + + +tlv_status_t TLVsMsg::add_quote(const uint8_t *quote_data, uint32_t quote_size) +{ + ADD_TLV_BY_DATA_SIZE(TLV_QUOTE, quote_data, quote_size) +} + + +tlv_status_t TLVsMsg::add_x509_csr(const uint8_t *csr_data, uint32_t csr_size) +{ + ADD_TLV_BY_DATA_SIZE(TLV_X509_CSR_TLV, csr_data, csr_size) +} + + +tlv_status_t TLVsMsg::add_quote_signature(const uint8_t *quote_signature, uint32_t sign_size) +{ + tlv_info_t one_info; + one_info.header_size = LARGE_TLV_HEADER_SIZE;//always use large tlv for sigrl and epid sig + one_info.payload = NULL; + one_info.size = sign_size; + one_info.type = TLV_QUOTE_SIG; + one_info.version = TLV_VERSION_1; + uint32_t size = ::calc_one_tlv_size(one_info); + tlv_msg_t new_buf; + tlv_info_t *new_info = NULL; + tlv_status_t ret = alloc_more_buffer(size, new_buf); + if(ret!=TLV_SUCCESS) + return ret; + ret = create_new_info(new_info); + if(ret!=TLV_SUCCESS) + return ret; + if((ret=::tlv_msg_init_one_tlv(&one_info, new_buf))!=TLV_SUCCESS){ + return (TLV_UNKNOWN_ERROR); + } + if(memcpy_s(one_info.payload, one_info.size, quote_signature, sign_size)!=0){ + return (TLV_UNKNOWN_ERROR); + } + if(memcpy_s(new_info, sizeof(*new_info),&one_info, sizeof(one_info))!=0) + return TLV_UNKNOWN_ERROR; + ADD_TLV_DBG_INFO + return TLV_SUCCESS; +} + + +tlv_status_t TLVsMsg::add_es_selector(uint8_t protocol, uint8_t selector_id) +{ + uint8_t buf[2]; + buf[0]=protocol; + buf[1]=selector_id; + ADD_TLV_BY_DATA_SIZE(TLV_ES_SELECTOR, buf, static_cast(2*sizeof(uint8_t))) +} diff --git a/psw/ae/aesm_service/source/aesm/extension/type_length_value.h b/psw/ae/aesm_service/source/aesm/extension/type_length_value.h new file mode 100644 index 0000000000..047538148b --- /dev/null +++ b/psw/ae/aesm_service/source/aesm/extension/type_length_value.h @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: type_length_value.h + * Description: Header file for data structure and macro definition of the TLV, the type length value encoding format of Provision Message + * + * Unaligned data will be used and for TLV, no data structure but some macros are used to extract information from TLV (due to var size of some fields) + * A tlv_info_t structure is defined for decoded TLV header information + * + *To encoding TLV: + * i) declare array of tlv_info_t and filling type/version/size of each TLV + * ii) call get_tlv_msg_size to calculate size of encoded buffer + * iii) prepare the output buffer in tlv_msg_t (set both msg_buf and msg_size) + * iv) call tlv_msg_init to initialize tlv headers of all sub-tlv + * v) use function like cipher_text_tlv_get_encrypted_text(...) to get pointer to each payload component + * vi) copy corresponding data into each payload + *To decoding TLV: + * i) initialize tlv_msg_t to input buffer (msg_buf and msg_size) + * ii) call read_tlv_info to get correpondent tlv_info_t array + * iii) use function like cipher_text_tlv_get_encrypted_text(...) to get pointer to each payload component + * or access size field of tlv_info_t directly to get size of payload + *Usually, there're multiple level of TLVs. + * So in encoding TLV, we need + * go through step i) and ii) from inner-most level TLV to out-most level of TLV to define + * tlv_info_t of all level of TLVs and get msg size for them + * Usually, the tlv_info_t of outer level is dependent on size of inner level + * After that, we could prepare the output buffer which is step iii) according to size of outmost level TLVs + * call tlv_msg_init to initialize TLV headers and get start address of payload (where inner TLV will share the memory) + * from outmost level to innermost level which is step iv) and v) + * In decoding TLV, it is simpler, just decode from outmost-level to innermost-level and do decryption if required + */ + +#ifndef _PVE_TLV_H +#define _PVE_TLV_H +#include "epid_types.h" +#include "sgx_urts.h" +#include +#include +#include +#include "oal/oal.h" +#include "tlv_common.h" +#include "se_sig_rl.h" +#include "se_wrapper.h" + +#define FOUR_BYTES_SIZE_TYPE 128 /*mask used in type of TLV to indicate that 'size' field uses 4 bytes*/ + +#ifndef UINT16_MAX +#define UINT16_MAX 0xFFFF +#endif +#ifndef UINT32_MAX +#define UINT32_MAX 0xFFFFFFFFU +#endif + +#define IS_FOUR_BYTES_SIZE_TYPE(x) (((x)&FOUR_BYTES_SIZE_TYPE)!=0) +#define GET_TLV_TYPE(x) ((uint8_t)((x)&~FOUR_BYTES_SIZE_TYPE)) + +typedef enum _tlv_status_t { + TLV_SUCCESS=0, + TLV_OUT_OF_MEMORY_ERROR=1, + TLV_INVALID_PARAMETER_ERROR, + TLV_INVALID_MSG_ERROR, + TLV_UNKNOWN_ERROR, + TLV_MORE_TLVS, /*There're more TLVs in the encoded buffer than user's expectation*/ + TLV_INSUFFICIENT_MEMORY, /*There'ld be more data in the TLV buffer according to the partially decoded data*/ + TLV_INVALID_FORMAT, /*Invalid data format in the TLV buffer to be decoded*/ + TLV_UNSUPPORTED /*the feature has not been supported such as version is later than supported version*/ +}tlv_status_t; + +/*usually, we could initialize header_size by UNKOWN_TLV_HEADER_SIZE + *but sometimes, we could initialize it by LARGE_TLV_HEADER_SIZE if we want to always use 4 bytes for size even though it is small such as in EPIDSignature TLV*/ +#define UNKNOWN_TLV_HEADER_SIZE 0 +#define TLV_HEADER_SIZE_OFFSET 2 +#define SMALL_TLV_HEADER_SIZE 4 +#define LARGE_TLV_HEADER_SIZE 6 +#define MAX_TLV_HEADER_SIZE 6 /*an upper bound for TLV header size*/ +#define SHORT_TLV_MAX_SIZE UINT16_MAX +/*It defines a TLV information + *All those information is encoded inside a TLV but not in this structure*/ +typedef struct _tlv_info_t{ + uint8_t type; /*type of tlv must be between 0 and 127 before encoding*/ + uint8_t version; + uint16_t header_size; /*header_size used to easy query begin and end address of TLV*/ + uint32_t size; /* 2 or 4 bytes size after encoding but always 4 bytes in this structure*/ + uint8_t *payload; /*pointer to payload of the TLV*/ +}tlv_info_t; + +typedef struct _tlv_msg_t{ + uint8_t *msg_buf; + uint32_t msg_size; +}tlv_msg_t; + +#define SIGRL_CERT_PREFIX_SIZE (sizeof(se_sig_rl_t)-sizeof(SigRL)) /*size for version and type*/ +#define SIGRL_CERT_HEADER_SIZE (sizeof(se_sig_rl_t)-sizeof(SigRLEntry)) +#define SIGRL_CERT_SIZE(sigrl_count) (sizeof(se_sig_rl_t)+((sigrl_count)-1)*sizeof(SigRLEntry)+2*SE_ECDSA_SIGN_SIZE) +#define EPID_SIGNATURE_HEADER_SIZE (sizeof(EPIDSignature)-sizeof(NRProof)) +#define EPID_SIGNATURE_SIZE(sign_count) (sizeof(EPIDSignature)+((sign_count)-1)*sizeof(NRProof)) + + +/*Function to decode a buffer which contains a list of TLV containers + *msg.msg_buf: pointer to the start address of the buffer + *msg.msg_size: number of bytes of the buffer + *tlvs_count: input/output parameter, the input *tlvs_count gives size of array infos and offsets + * when the function return successful (TLV_SUCCESS) or there're too many TLVs (TLV_MORE_TLVS), + * the output of *tlvs_count returns the number of TLVs in the msg + *infos: output parameter, infos[i] gives the decoded TLV structure information of the i'th TLV in the msg + *return: TLV_SUCCESS on success or other value to indicate error + */ +tlv_status_t read_tlv_infos(const tlv_msg_t& msg, uint32_t *tlvs_count, tlv_info_t infos[]); + +/*Function to return the header size in encoded TLV buffer*/ +uint32_t get_tlv_header_size(const tlv_info_t *info); + +/*Function to return the estimated upper bound of length of TLV in bytes given length in bytes of payload. + * Currently, it returns the exact value for TLV encoding, it should not be used for TLV decoding + *return 0 if there's any error + */ +inline static uint32_t get_tlv_total_size(size_t payload_size) +{ + if(payload_size>UINT16_MAX){/*6 bytes TLV header*/ + if(payload_size>UINT32_MAX-LARGE_TLV_HEADER_SIZE)/*overflow of uint32_t, return 0 to indicate error*/ + return 0; + return static_cast(payload_size+LARGE_TLV_HEADER_SIZE); + }else{ + return static_cast(payload_size+SMALL_TLV_HEADER_SIZE);/*4 bytes TLV header*/ + } +} + + +/*Function to return number in bytes of a msg with some encoded TLVs + *tlvs_count gives number of TLVs in the msg and infos[i] gives info of the i'th TLV*/ +uint32_t get_tlv_msg_size(uint32_t tlvs_count, const tlv_info_t infos[]); + +/*Function to initialize a msg of some encoded TLVs + *Before calling the function, all fields except payload of infos[.] has been initialized + *After calling to the function, the TLV header of all TLVs will be fill in and payload of info[.] will be initialized + *After calling to the function, we could use payload field + *tlvs_count: input parameter gives number of TLV in the msg + *infos: input parameter where infos[i] is the tlv structure information of the i'th TLV + *tlv_msg.msg_buf: the msg buffer to be initialized + *tlv_msg.msg_size: input parameter gives the size of the msg buffer, it must be result of function get_tlv_msg_count(tlvs_count, infos); + *The function return TLV_SUCCESS on success and other to indicate any error + */ +tlv_status_t tlv_msg_init(uint32_t tlvs_count, tlv_info_t infos[], const tlv_msg_t& tlv_msg); + +/*Function used to initialize msg header only without checking payload size + *The function will return size in bytes of the header to be filled + * the payload field will be set but payload size not checked + *msg: The buffer to fill + *info: the tlv_info of the TLV + */ +uint32_t tlv_msg_init_one_header(uint8_t msg[MAX_TLV_HEADER_SIZE], tlv_info_t& info); + +/*Macro used to crack tlv structure, the pointer type of payload must be uint8_t * + *The alignment of all types used inside payload should be 1 (which means no alignment) + *cipher text TLV*/ +#define CIPHER_TEXT_TLV_PAYLOAD_SIZE(text_size) ((text_size)+1) /*size of payload*/ +#define CIPHER_TEXT_TLV_SIZE(text_size) get_tlv_total_size(CIPHER_TEXT_TLV_PAYLOAD_SIZE(text_size)) /*size of TLV*/ +uint8_t *cipher_text_tlv_get_key_id(const tlv_info_t& info); /*given tlv_info_t, return pointer to key_id*/ +tlv_msg_t cipher_text_tlv_get_encrypted_text(const tlv_info_t& info); /*given tlv_info_t return tlv_msg for encrypted text so that we could restart decode*/ +/*block cipher text TLV*/ +#define BLOCK_CIPHER_TEXT_TLV_PAYLOAD_SIZE(text_size) ((text_size)+IV_SIZE) /*size of payload*/ +#define BLOCK_CIPHER_TEXT_TLV_SIZE(text_size) get_tlv_total_size(BLOCK_CIPHER_TEXT_TLV_PAYLOAD_SIZE(text_size)) /*size of TLV*/ +struct _tlv_iv_t;/*an incomplete type for iv only*/ +typedef struct _tlv_iv_t tlv_iv_t; +tlv_iv_t *block_cipher_tlv_get_iv(const tlv_info_t& info); +tlv_msg_t block_cipher_tlv_get_encrypted_text(const tlv_info_t& info); +#define BLOCK_CIPHER_TEXT_SIZE_FROM_PAYLOAD_SIZE(psize) ((psize)-IV_SIZE) + +/*block cipher info TLV*/ +#define BLOCK_CIPHER_INFO_TLV_PAYLOAD_SIZE() SK_SIZE /*size of payload*/ +#define BLOCK_CIPHER_INFO_TLV_SIZE() get_tlv_total_size(BLOCK_CIPHER_INFO_TLV_PAYLOAD_SIZE()) +struct _tlv_sk_t; /*an incomplete type for SK only*/ +typedef struct _tlv_sk_t tlv_sk_t; +tlv_sk_t *block_cipher_info_tlv_get_sk(const tlv_info_t& info); + +/*message authentication code TLV*/ +#define MAC_TLV_PAYLOAD_SIZE(mac_size) (mac_size) +#define MAC_TLV_SIZE(mac_size) get_tlv_total_size(MAC_TLV_PAYLOAD_SIZE(mac_size)) +struct _tlv_mac_t; /*an incomplete type for MAC only*/ +typedef struct _tlv_mac_t tlv_mac_t; +tlv_mac_t *mac_tlv_get_mac(const tlv_info_t& info); +/*NONCE TLV*/ +#define NONCE_TLV_PAYLOAD_SIZE(nonce_size) (nonce_size) +#define NONCE_TLV_SIZE(nonce_size) get_tlv_total_size(NONCE_TLV_PAYLOAD_SIZE(nonce_size)) +struct _tlv_nonce_t; +typedef struct _tlv_nonce_t tlv_nonce_t; +tlv_nonce_t *nonce_tlv_get_nonce(const tlv_info_t& info); + +/*EPID GID TLV*/ +#define EPID_GID_TLV_PAYLOAD_SIZE() (sizeof(GroupID)) +#define EPID_GID_TLV_SIZE() get_tlv_total_size(EPID_GID_TLV_PAYLOAD_SIZE()) +struct _tlv_gid_t; /*an incomplete type for GID only*/ +typedef struct _tlv_gid_t tlv_gid_t; +tlv_sk_t *epid_gid_tlv_get_gid(const tlv_info_t& info); + +/*EPID SigRL TLV*/ +#define EPID_SIGRL_TLV_PAYLOAD_SIZE(sigrl_count) (sizeof(se_sig_rl_t)+sizeof(SigRLEntry)*(sigrl_count)-sizeof(SigRLEntry)+ECDSA_SIGN_SIZE*2) +#define EPID_SIGRL_TLV_SIZE(sigrl_count) (sigrl_count>0?get_tlv_total_size(EPID_SIGRL_TLV_PAYLOAD_SIZE(sigrl_count)):0) + +/*EPID SigRL PSVN TLV*/ +#define EPID_SIGRL_PSVN_TLV_PAYLOAD_SIZE() (sizeof(psvn_t)) +#define EPID_SIGRL_PSVN_TLV_SIZE() get_tlv_total_size(EPID_SIGRL_PSVN_TLV_PAYLOAD_SIZE()) +psvn_t *epid_sigrl_psvn_tlv_get_psvn(const tlv_info_t& info); + +/*EPID group certificate TLV*/ +#define EPID_GROUP_CERT_TLV_PAYLOAD_SIZE() (sizeof(signed_epid_group_cert_t)) +#define EPID_GROUP_CERT_TLV_SIZE() get_tlv_total_size(EPID_GROUP_CERT_TLV_PAYLOAD_SIZE()) + +/*Device ID TLV*/ +#define DEVICE_ID_TLV_PAYLOAD_SIZE() (sizeof(ppid_t)+sizeof(fmsp_t)+sizeof(psvn_t)) +#define DEVICE_ID_TLV_SIZE() get_tlv_total_size(DEVICE_ID_TLV_PAYLOAD_SIZE()) +ppid_t *device_id_tlv_get_ppid(const tlv_info_t& info); +fmsp_t *device_id_tlv_get_fmsp(const tlv_info_t& info); +psvn_t *device_id_tlv_get_psvn(const tlv_info_t& info); + +/*PSID TLV*/ +#define PSID_TLV_PAYLOAD_SIZE() (sizeof(psid_t)) +#define PSID_TLV_SIZE() get_tlv_total_size(PSID_TLV_PAYLOAD_SIZE()) +psid_t *psid_tlv_get_psid(const tlv_info_t& info); + +/*Join Proof TLV*/ +#define EPID_JOIN_PROOF_TLV_PAYLOAD_SIZE() (JOIN_PROOF_SIZE+BLIND_ESCROW_SIZE) +#define EPID_JOIN_PROOF_TLV_SIZE() get_tlv_total_size(EPID_JOIN_PROOF_TLV_PAYLOAD_SIZE()) + +/*EPID Signature TLV*/ +#define EPID_SIGNATURE_TLV_PAYLOAD_SIZE(sign_count) (sizeof(EPIDSignature)+sizeof(NRProof)*(sign_count)-sizeof(NRProof)) +#define EPID_SIGNATURE_TLV_SIZE(sign_count) (LARGE_TLV_HEADER_SIZE+EPID_SIGNATURE_TLV_PAYLOAD_SIZE(sign_count)) /*always use large header size for Signature TLV*/ + +/*EPID Membership Credential TLV*/ +#define MEMBERSHIP_CREDENTIAL_TLV_PAYLOAD_SIZE() (sizeof(membertship_credential_with_escrow_t)) +#define MEMBERSHIP_CREDENTIAL_TLV_SIZE() get_tlv_total_size(MEMBERSHIP_CREDENTIAL_TLV_PAYLOAD_SIZE()) +PElemStr *membership_credential_tlv_get_x(const tlv_info_t& info); +G1ElemStr *membership_credential_tlv_get_A(const tlv_info_t& info); + +/*FLAGS TLV*/ +#define FLAGS_TLV_PAYLOAD_SIZE() FLAGS_SIZE +#define FLAGS_TLV_SIZE() get_tlv_total_size(FLAGS_TLV_PAYLOAD_SIZE()) + +#define ES_SELECTOR_TLV_PAYLOAD_SIZE() 2 +#define ES_SELECTOR_TLV_SIZE() get_tlv_total_size(ES_SELECTOR_TLV_PAYLOAD_SIZE()) +uint8_t *es_selector_tlv_get_es_type(const tlv_info_t& info); +uint8_t *es_selector_tlv_get_selector_id(const tlv_info_t& info); + +class TLVsMsg{ + uint32_t num_infos; + tlv_info_t* infos; + tlv_msg_t msg; + CLASS_UNCOPYABLE(TLVsMsg) +protected: + void clear(){ + if(msg.msg_buf!=NULL){free(msg.msg_buf);msg.msg_buf=NULL;msg.msg_size=0;} + if(infos!=NULL){free(infos);infos=NULL;num_infos=0;} + } + tlv_status_t alloc_more_buffer(uint32_t buffer, tlv_msg_t& new_buf); + tlv_status_t create_new_info(tlv_info_t *& new_info){ + if(num_infos==0){ + assert(infos==NULL); + infos = (tlv_info_t *)malloc(sizeof(tlv_info_t)); + if(infos==NULL) return TLV_OUT_OF_MEMORY_ERROR; + num_infos=1; + new_info = infos; + }else{ + tlv_info_t * p = (tlv_info_t *)malloc(sizeof(tlv_info_t)*(num_infos+1)); + if(p==NULL){ + return TLV_OUT_OF_MEMORY_ERROR; + } + if(0!=memcpy_s(p, sizeof(tlv_info_t)*(num_infos+1), infos, sizeof(tlv_info_t)*num_infos)){ + free(p); + return TLV_UNKNOWN_ERROR; + } + free(infos); + infos = p; + new_info = infos + (num_infos); + num_infos ++; + } + return TLV_SUCCESS; + } +public: + TLVsMsg(){ + num_infos = 0; + infos = NULL; + msg.msg_size = 0; + msg.msg_buf = NULL; + } + ~TLVsMsg(){ + clear(); + } + tlv_status_t init_from_buffer(const uint8_t *msg, uint32_t msg_size); + tlv_status_t init_from_tlv_msg(const tlv_msg_t& tlv_msg); + uint32_t get_tlv_count()const{return num_infos;} + tlv_info_t& operator[](uint32_t x){ + assert(x +#include +#include "IAESMLogic.h" +#include + +class AESMLogicWrapper :public IAESMLogic { + public: + AESMLogicWrapper() { + } + + ae_error_t service_start(){ + return AESMLogic::service_start(); + } + + void service_stop(); + + virtual aesm_error_t initQuote(uint8_t *target_info, + uint32_t target_info_length, + uint8_t *gid, + uint32_t gid_length); + + virtual aesm_error_t getQuote(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, uint8_t* quote, + uint32_t qe_reportSize, uint8_t* qe_report); + + virtual aesm_error_t closeSession(uint32_t sessionId); + + virtual aesm_error_t createSession(uint32_t *session_id, + uint8_t *se_dh_msg1, + uint32_t se_dh_msg1_size); + + virtual aesm_error_t exchangeReport(uint32_t session_id, + const uint8_t* se_dh_msg2, + uint32_t se_dh_msg2_size, + uint8_t* se_dh_msg3, + uint32_t se_dh_msg3_size); + + virtual aesm_error_t getLaunchToken(const uint8_t *measurement, + uint32_t measurement_size, + const uint8_t *public_key, + uint32_t public_key_size, + const uint8_t *se_attributes, + uint32_t se_attributes_size, + uint8_t **launch_token, + uint32_t *launch_token_size); + + virtual aesm_error_t invokeService(const uint8_t *pse_message_req, + uint32_t pse_message_req_size, + uint8_t *pse_message_resp, + uint32_t pse_message_resp_size); + + virtual aesm_error_t getPsCap(uint64_t* ps_cap); + virtual aesm_error_t reportAttestationStatus(uint8_t* platform_info, uint32_t platform_info_size, + uint32_t attestation_error_code, + uint8_t* update_info, uint32_t update_info_size); + + private: + AESMLogicWrapper& operator=(const AESMLogicWrapper&); + AESMLogicWrapper(const AESMLogicWrapper&); +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMQueue.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMQueue.h new file mode 100644 index 0000000000..31cb79d86d --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMQueue.h @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef AESM_QUEUE_H +#define AESM_QUEUE_H + +#include +#include +#include "RequestData.h" +#include "IAERequest.h" +#include "IAESMQueue.h" +#include + +template +class AESMQueue : public IAESMQueue { + public: + AESMQueue(); + ~AESMQueue(); + + void push(T*); + T* blockingPop(); + void close(); + + private: + std::queue m_queue; + pthread_cond_t m_queueCond; + pthread_mutex_t m_queueMutex; + volatile uint8_t m_events; + private: + AESMQueue& operator=(const AESMQueue&); + AESMQueue(const AESMQueue&); +}; + +#define QUEUE_EVENT_CLOSE 1 + +template +AESMQueue::AESMQueue() : + m_queue() +{ + int rc; + + rc = pthread_mutex_init(&m_queueMutex, NULL); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to initialize mutex"); + exit(-1); + } + + rc = pthread_cond_init(&m_queueCond, NULL); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to initialize a condition variable"); + exit(-1); + } + + m_events = 0; +} + +template +AESMQueue::~AESMQueue() +{ + int rc; + + rc = pthread_mutex_destroy(&m_queueMutex); + if (rc != 0) + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to destroy mutex"); + + rc = pthread_cond_destroy(&m_queueCond); + if (rc != 0) + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to destory a condition variable"); + +} + +template +void AESMQueue::push(T* value) +{ + int rc; + + rc = pthread_mutex_lock(&m_queueMutex); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to acquire mutex"); + exit(-1); + } + + m_queue.push(value); + + // m_events |= QUEUE_EVENT_INSERT; + rc = pthread_cond_signal(&m_queueCond); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to signal condition"); + exit(-1); + } + + rc = pthread_mutex_unlock(&m_queueMutex); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to unlock mutex"); + exit(-1); + } +} + +template +T* AESMQueue::blockingPop() +{ + int rc; + T* value = NULL; + + rc = pthread_mutex_lock(&m_queueMutex); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to acquire mutex"); + exit(-1); + } + + while(1) { + // check CLOSE event + if (m_events & QUEUE_EVENT_CLOSE) { + //epmty the queue + while (!m_queue.empty()) + { + value = m_queue.front(); + m_queue.pop(); + delete value; + } + value = NULL; + break; + } + if (!m_queue.empty()) { + // queue is not empty + value = m_queue.front(); + m_queue.pop(); + break; + } + else { + rc = pthread_cond_wait(&m_queueCond, &m_queueMutex); + + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed wait on a condition"); + exit(-1); + } + } + } + + rc = pthread_mutex_unlock(&m_queueMutex); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to unlock mutex"); + exit(-1); + } + + return value; +} + +template +void AESMQueue::close() +{ + int rc; + + rc = pthread_mutex_lock(&m_queueMutex); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to acquire mutex"); + exit(-1); + } + + m_events |= QUEUE_EVENT_CLOSE; + rc = pthread_cond_signal(&m_queueCond); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to signal a condition"); + exit(-1); + } + + rc = pthread_mutex_unlock(&m_queueMutex); + if (rc != 0) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Failed to unlock mutex"); + exit(-1); + } +} + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMQueueManager.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMQueueManager.h new file mode 100644 index 0000000000..90e1497c81 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMQueueManager.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef AESM_QUEUE_MANAGER_H +#define AESM_QUEUE_MANAGER_H + +#include "RequestData.h" +#include "AESMWorkerThread.h" +#include + +class AESMQueueManager +{ + public: + AESMQueueManager( + AESMWorkerThread *quotingThread, + AESMWorkerThread *launchThread, + AESMWorkerThread *platformServiceThread + ); + + ~AESMQueueManager(); + + void enqueue(RequestData* requestData); + + void shutDown(); + private: + AESMQueueManager& operator=(const AESMQueueManager&); + AESMQueueManager(const AESMQueueManager&); + void startQueueThreads(); + + AESMWorkerThread* m_quotingThread; + AESMWorkerThread* m_launchThread; + AESMWorkerThread* m_platformServiceThread; +}; + +#endif //AESM_QUEUE_MANAGER_H diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMWorkerThread.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMWorkerThread.h new file mode 100644 index 0000000000..acf943d505 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/AESMWorkerThread.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AESM_WORKER_THREAD_H_ +#define _AESM_WORKER_THREAD_H_ +#include "Thread.h" +#include "IAESMLogic.h" +#include "IAESMQueue.h" +#include "ITransporter.h" +#include "RequestData.h" + + +class AESMWorkerThread : public Thread +{ + public: + AESMWorkerThread(IAESMLogic& aesmLogic, ITransporter& transporter, IAESMQueue* queue); + ~AESMWorkerThread(); + virtual void enqueue(RequestData* request); + virtual void shutDown(); + private: + virtual void run(); + AESMWorkerThread& operator=(const AESMWorkerThread&); + AESMWorkerThread(const AESMWorkerThread&); + IAESMLogic &m_aesmLogic; + ITransporter &m_transporter; + IAESMQueue *m_queue; +}; +#endif + + diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/CAESMServer.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/CAESMServer.h new file mode 100644 index 0000000000..422bbcdb9d --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/CAESMServer.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _CAESM_SERVER_H_ +#define _CAESM_SERVER_H_ + +#include "CSelector.h" +#include "IServerSocket.h" +#include "ITransporter.h" +#include "ISerializer.h" +#include "IAESMLogic.h" +#include "AESMQueueManager.h" +#include + +using namespace std; + +/* + * Encapsulates all AESM server logic + */ +class CAESMServer +{ +public: + virtual ~CAESMServer(); + CAESMServer(IServerSocket* server_sock, CSelector* selector, IAESMLogic* aesmLogic); + + void doWork(); + void shutDown(); + void init(); + + //creates an AESMQueueManager instance with three queues and three work threads (one for each event class) + static AESMQueueManager* constructAESMQueueManager(IAESMLogic& aesmLogic, ITransporter& transporter); + +protected: + + IServerSocket* m_serverSocket; + CSelector* m_selector; + ITransporter* m_transporter; + AESMQueueManager* m_queueManager; + IAESMLogic* m_aesmLogic; + bool m_shutDown; + int m_fdPipe[2]; + +private: + CAESMServer& operator=(const CAESMServer&); + CAESMServer(const CAESMServer&); +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/CSelector.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/CSelector.h new file mode 100644 index 0000000000..6ba0d4e97b --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/CSelector.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _SELECTOR_H +#define _SELECTOR_H + +#include +#include "IServerSocket.h" +#include +#include + +class ICommunicationSocket; + +class CSelector +{ +public: + + CSelector(IServerSocket* serverSock); + virtual ~CSelector(); + + virtual void addSocket(ICommunicationSocket*); + virtual void removeSocket(ICommunicationSocket*); + + virtual bool select(int fd_term = -1); + virtual bool canAcceptConnection(); + virtual std::list getSocsWithNewContent(); + +private: + CSelector& operator=(const CSelector&); + CSelector(const CSelector&); + + IServerSocket* m_serverSock; + std::list m_connectedSockets; + fd_set m_workingSet; +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/IAESMQueue.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/IAESMQueue.h new file mode 100644 index 0000000000..6e2df26c7f --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/IAESMQueue.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef IAESM_QUEUE_H +#define IAESM_QUEUE_H + +template +class IAESMQueue { + public: + virtual void push(T*) = 0; + virtual T* blockingPop() = 0; + virtual void close() = 0; + virtual ~IAESMQueue() {} +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/IServerSocket.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/IServerSocket.h new file mode 100644 index 0000000000..ae8e3175b4 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/IServerSocket.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _I_SERVER_SOCKET_H +#define _I_SERVER_SOCKET_H + +/* + Interface for the server socket; + Will be used to accept connections from clients. +*/ +class ICommunicationSocket; + +class IServerSocket +{ +public: + virtual void init() = 0; + virtual int getSockDescriptor() = 0; + virtual ICommunicationSocket* accept() = 0; + virtual ~IServerSocket() {}; +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/RequestData.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/RequestData.h new file mode 100644 index 0000000000..d4a75757d5 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/RequestData.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _REQUEST_DATA_H +#define _REQUEST_DATA_H + +#include "ICommunicationSocket.h" +#include "IAERequest.h" + +class RequestData { + public: + RequestData(ICommunicationSocket* socket = NULL, IAERequest* request = NULL): m_socket(socket), m_request(request) {}; + ~RequestData() + { + delete m_socket; + delete m_request; + } + void setSocket(ICommunicationSocket* socket) { m_socket = socket; } + void setRequest(IAERequest* request) { m_request = request; } + + ICommunicationSocket* getSocket() { return m_socket; } + IAERequest* getRequest() { return m_request; } + + private: + ICommunicationSocket* m_socket; + IAERequest* m_request; + RequestData& operator=(const RequestData& other); + RequestData(const RequestData& other); +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/Thread.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/Thread.h new file mode 100644 index 0000000000..6f2dda55e7 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/Thread.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AESM_WRAPPER_THREAD_H_ +#define _AESM_WRAPPER_THREAD_H_ +#include + +class Thread +{ + public: + Thread(); + virtual ~Thread(); + + void start(); + + void stop(); //set a flag to signal the thread to be stopped. It is the run() implementation's responsibility to check this and to return. + bool isStopped(); + void join(); + + private: + void virtual run() = 0; + Thread& operator=(const Thread&); + Thread(const Thread&); + + volatile bool m_shutDown; + pthread_t m_thread; + static void* doWork(void* param); + + +}; +#endif + diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/UnixServerSocket.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/UnixServerSocket.h new file mode 100644 index 0000000000..b6afb5f265 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/UnixServerSocket.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _UNIX_SERVER_SOCKET_H +#define _UNIX_SERVER_SOCKET_H + +/* + * Interface for the server socket; + * Will be used to accept connections from clients. +**/ +#include "IServerSocket.h" + +class UnixServerSocket: public IServerSocket +{ +public: + UnixServerSocket(const char* socketbase, const unsigned int clientTimeout = 0); + virtual ~UnixServerSocket(); + + virtual void init(); + virtual ICommunicationSocket* accept(); + + virtual int getSockDescriptor() { return mSocket; } + +private: + UnixServerSocket& operator=(const UnixServerSocket&); + UnixServerSocket(const UnixServerSocket&); + const char* mSocketBase; + int mSocket; + unsigned int mClientTimeout; +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/inc/aesm_exception.h b/psw/ae/aesm_service/source/aesm_wrapper/inc/aesm_exception.h new file mode 100644 index 0000000000..9bf3bcc166 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/inc/aesm_exception.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AESM_EXCEPTION_H_ +#define __AESM_EXCEPTION_H_ + +#include + +class aesm_exception{ +public: + aesm_exception(std::string& msg){ + mMsg = msg; + } + + const std::string message() { return mMsg; } + +protected: + std::string mMsg; +}; + +#endif diff --git a/psw/ae/aesm_service/source/aesm_wrapper/src/AESMLogicWrapper.cpp b/psw/ae/aesm_service/source/aesm_wrapper/src/AESMLogicWrapper.cpp new file mode 100644 index 0000000000..9ff970e0e7 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/src/AESMLogicWrapper.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "AESMLogicWrapper.h" +#include +#include + +#include "LEClass.h" +#include "Config.h" + +aesm_error_t AESMLogicWrapper::initQuote(uint8_t *target_info, + uint32_t target_info_length, + uint8_t *gid, + uint32_t gid_length) +{ + return AESMLogic::init_quote(target_info, target_info_length, + gid, gid_length); +} + +aesm_error_t AESMLogicWrapper::getQuote(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, uint8_t* quote, + uint32_t qe_reportSize, uint8_t* qe_report) +{ + + return AESMLogic::get_quote(report, reportLength, + quoteType, + spid, spidLength, + nonce, nonceLength, + sig_rl, sig_rlLength, + qe_report, qe_reportSize, + quote, bufferSize); + +} + +aesm_error_t AESMLogicWrapper::closeSession(uint32_t sessionId) +{ + return AESMLogic::close_session(sessionId); +} + +aesm_error_t AESMLogicWrapper::createSession(uint32_t *session_id, + uint8_t *se_dh_msg1, + uint32_t se_dh_msg1_size) +{ + + return AESMLogic::create_session(session_id, se_dh_msg1, se_dh_msg1_size); + +} + +aesm_error_t AESMLogicWrapper::exchangeReport(uint32_t session_id, + const uint8_t* se_dh_msg2, + uint32_t se_dh_msg2_size, + uint8_t* se_dh_msg3, + uint32_t se_dh_msg3_size ) +{ + return AESMLogic::exchange_report(session_id, + se_dh_msg2, + se_dh_msg2_size, + se_dh_msg3, + se_dh_msg3_size); +} + +aesm_error_t AESMLogicWrapper::getLaunchToken(const uint8_t *measurement, + uint32_t measurement_size, + const uint8_t *mrsigner, + uint32_t mrsigner_size, + const uint8_t *se_attributes, + uint32_t se_attributes_size, + uint8_t **launch_token, + uint32_t *launch_token_size) +{ + *launch_token_size = sizeof(token_t); + *launch_token = new uint8_t[*launch_token_size]; + + return AESMLogic::get_launch_token(measurement, + measurement_size, + mrsigner, + mrsigner_size, + se_attributes, + se_attributes_size, + *launch_token, + *launch_token_size); + +} + +aesm_error_t AESMLogicWrapper::invokeService(const uint8_t *pse_message_req, + uint32_t pse_message_req_size, + uint8_t *pse_message_resp, + uint32_t pse_message_resp_size) +{ + return AESMLogic::invoke_service(pse_message_req, + pse_message_req_size, + pse_message_resp, + pse_message_resp_size); +} + +aesm_error_t AESMLogicWrapper::getPsCap(uint64_t* ps_cap) +{ + return AESMLogic::get_ps_cap(ps_cap); +} + +aesm_error_t AESMLogicWrapper::reportAttestationStatus(uint8_t* platform_info, uint32_t platform_info_size, + uint32_t attestation_error_code, + uint8_t* update_info, uint32_t update_info_size) + +{ + return AESMLogic::report_attestation_status(platform_info,platform_info_size, + attestation_error_code, + update_info, update_info_size); +} + +void AESMLogicWrapper::service_stop() +{ + AESMLogic::service_stop(); +} diff --git a/psw/ae/aesm_service/source/aesm_wrapper/src/AESMQueueManager.cpp b/psw/ae/aesm_service/source/aesm_wrapper/src/AESMQueueManager.cpp new file mode 100644 index 0000000000..1b3686d11f --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/src/AESMQueueManager.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "AESMQueueManager.h" +#include "IAERequest.h" + +#include + +AESMQueueManager::AESMQueueManager( + AESMWorkerThread *quotingThread, + AESMWorkerThread *launchThread, + AESMWorkerThread *platformServiceThread + ) : + m_quotingThread(quotingThread), + m_launchThread(launchThread), + m_platformServiceThread(platformServiceThread) +{ + startQueueThreads(); +} + +AESMQueueManager::~AESMQueueManager() +{ + delete m_quotingThread; + delete m_launchThread; + delete m_platformServiceThread; +} + +void AESMQueueManager::startQueueThreads() +{ + m_launchThread->start(); + m_quotingThread->start(); + m_platformServiceThread->start(); +} + +void AESMQueueManager::enqueue(RequestData* requestData) +{ + if(requestData != NULL && requestData->getRequest() != NULL) + { + switch (requestData->getRequest()->getRequestClass()) { + case IAERequest::QUOTING_CLASS: + m_quotingThread->enqueue(requestData); + break; + case IAERequest::LAUNCH_CLASS: + m_launchThread->enqueue(requestData); + break; + case IAERequest::PLATFORM_CLASS: + m_platformServiceThread->enqueue(requestData); + break; + default: //if we reach this point, this could only mean a corrupted or a forged message. In any case, close the connection + // Closing the connection will translate in an IPC error on the client side in case of corruption (and we would be correct), or in unexpected manner for forged messages (the case of an attacker client) + delete requestData; //this will delete the socket also. + AESM_LOG_ERROR("Malformed request received (May be forged for attack)"); + } + + } +} + +void AESMQueueManager::shutDown() +{ + m_launchThread->shutDown(); + m_quotingThread->shutDown(); + m_platformServiceThread->shutDown(); +} diff --git a/psw/ae/aesm_service/source/aesm_wrapper/src/AESMWorkerThread.cpp b/psw/ae/aesm_service/source/aesm_wrapper/src/AESMWorkerThread.cpp new file mode 100644 index 0000000000..c698997e52 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/src/AESMWorkerThread.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "AESMWorkerThread.h" +#include "RequestData.h" +#include "IAEResponse.h" + +AESMWorkerThread::AESMWorkerThread(IAESMLogic& aesmLogic, ITransporter& transporter, IAESMQueue* queue) + : m_aesmLogic(aesmLogic), + m_transporter(transporter), + m_queue(queue) +{} + +AESMWorkerThread::~AESMWorkerThread() +{ + shutDown(); + delete m_queue; +} + +/*override*/ +void AESMWorkerThread::run() +{ + while (!isStopped()) { + RequestData* requestData = m_queue->blockingPop(); + if (isStopped()) + break; + IAEResponse *response = requestData->getRequest()->execute(&m_aesmLogic); + m_transporter.sendResponse(response, requestData->getSocket()); + delete requestData; + delete response; + } +} + +void AESMWorkerThread::enqueue(RequestData* requestData) +{ + if (isStopped()) { + //! [mlu] don't like the silent ignore; at least a log should go here. + return; + } + m_queue->push(requestData); +} + +void AESMWorkerThread::shutDown() +{ + stop(); + m_queue->close(); + join(); +} + +/*--------------------------------------------------------------------------------------------------*/ diff --git a/psw/ae/aesm_service/source/aesm_wrapper/src/CAESMServer.cpp b/psw/ae/aesm_service/source/aesm_wrapper/src/CAESMServer.cpp new file mode 100644 index 0000000000..ad4764e11b --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/src/CAESMServer.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "CAESMServer.h" +#include "SocketTransporter.h" +#include "ProtobufSerializer.h" +#include "RequestData.h" +#include "AESMQueue.h" +#include "AESMWorkerThread.h" + +#include +#include +#include + + + +/*static*/ +AESMQueueManager* CAESMServer::constructAESMQueueManager(IAESMLogic& aesmLogic, ITransporter& transporter) +{ + return new AESMQueueManager( + new AESMWorkerThread(aesmLogic, transporter, new AESMQueue()), + new AESMWorkerThread(aesmLogic, transporter, new AESMQueue()), + new AESMWorkerThread(aesmLogic, transporter, new AESMQueue()) + ); +} + +CAESMServer::CAESMServer(IServerSocket* server_sock, CSelector* selector, IAESMLogic* aesmLogic): + m_serverSocket(server_sock), + m_selector(selector), + m_aesmLogic(aesmLogic), + m_shutDown(false) +{ + // Dependency injection + ISerializer* serializer = new ProtobufSerializer(); + m_transporter = new SocketTransporter(NULL, serializer); + + m_queueManager = constructAESMQueueManager(*aesmLogic, *m_transporter); +} + +CAESMServer::~CAESMServer() +{ + delete m_transporter; + delete m_queueManager; + delete m_serverSocket; + delete m_selector; + delete m_aesmLogic; +} + +/* + * Verify that the server was initialized with proper parameters + * Create the worker thread for the server; + * This function will throw whatever it is that the called functions throw. + */ +void CAESMServer::init() +{ + if(NULL == this->m_serverSocket || + NULL == this->m_selector) + { + std::string msg("null members"); + throw new aesm_exception(msg); + } + + this->m_serverSocket->init(); +} + +void CAESMServer::doWork() +{ + // pipe is used to prevent select from blocking current thread + if (pipe(m_fdPipe) < 0) { + std::string msg("failed to create pipe"); + throw new aesm_exception(msg); + } + + while(!m_shutDown) { + + if (!m_selector->select(m_fdPipe[0])) + break; + + if(m_selector->canAcceptConnection()) + { + ICommunicationSocket* commSock = this->m_serverSocket->accept(); + if (commSock == NULL) + continue; + + m_selector->addSocket(commSock); + } + + std::list socketsWithData = m_selector->getSocsWithNewContent(); + std::list::const_iterator it = socketsWithData.begin(); + + for (;it != socketsWithData.end(); ++it) { + try { + IAERequest *request = m_transporter->receiveRequest(*it); + RequestData *requestData = new RequestData(*it, request); //deleted by the AESMWorkerThread after response is sent + + m_queueManager->enqueue(requestData); + + } catch (SockDisconnectedException& e) { + m_selector->removeSocket(*it); + } + } + } + + close(m_fdPipe[0]); + close(m_fdPipe[1]); +} + +void CAESMServer::shutDown() +{ + m_shutDown = true; + + // notify CSelector to terminate + if (write(m_fdPipe[1], &m_fdPipe[1], sizeof(int)) < 0) + { + // do nothing + } + + m_aesmLogic->service_stop(); +} diff --git a/psw/ae/aesm_service/source/aesm_wrapper/src/CSelector.cpp b/psw/ae/aesm_service/source/aesm_wrapper/src/CSelector.cpp new file mode 100644 index 0000000000..f69c559c20 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/src/CSelector.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "CSelector.h" +#include "ICommunicationSocket.h" +#include +#include +#include +#include + +CSelector::CSelector(IServerSocket* serverSock) : + m_serverSock(serverSock) +{ + m_connectedSockets.clear(); + FD_ZERO(&m_workingSet); +} + + +CSelector::~CSelector() +{ +} + +void CSelector::addSocket(ICommunicationSocket* socket) +{ + m_connectedSockets.push_back(socket); +} + +void CSelector::removeSocket(ICommunicationSocket* socket) +{ + m_connectedSockets.remove(socket); +} + +bool CSelector::select(int fd_term) +{ + int max_sd; + std::list::const_iterator it = m_connectedSockets.begin(); + + FD_ZERO(&m_workingSet); + FD_SET(m_serverSock->getSockDescriptor(), &m_workingSet); + max_sd = m_serverSock->getSockDescriptor(); + + if (fd_term != -1) { + // a pipe is setup to prevent select from blocking current thread + FD_SET(fd_term, &m_workingSet); + if (fd_term > max_sd) + max_sd = fd_term; + } + + for(; it!=m_connectedSockets.end(); ++it) { + int sock_fd = (*it)->getSockDescriptor(); + if (sock_fd > max_sd) + max_sd = sock_fd; + + FD_SET(sock_fd, &m_workingSet); + } + + int rc = (int) TEMP_FAILURE_RETRY(::select(max_sd + 1, &m_workingSet, NULL, NULL, NULL)); + if (rc < 0) { + throw "Select failed"; /* TODO throw a specific exception */ + } + + if (fd_term != -1 && FD_ISSET(fd_term, &m_workingSet)) + return false; + + return true; +} + +bool CSelector::canAcceptConnection() +{ + if (FD_ISSET(m_serverSock->getSockDescriptor(), &m_workingSet)) { + return true; + } else { + return false; + } +} + +std::list CSelector::getSocsWithNewContent() +{ + std::list socketswithContent; + std::list::iterator it = m_connectedSockets.begin(); + + while( it!=m_connectedSockets.end()) + { + if (FD_ISSET((*it)->getSockDescriptor(), &m_workingSet)) { + socketswithContent.push_back(*it); + m_connectedSockets.erase(it++); + } else { + ++it; + } + } + + return socketswithContent; +} diff --git a/psw/ae/aesm_service/source/aesm_wrapper/src/Thread.cpp b/psw/ae/aesm_service/source/aesm_wrapper/src/Thread.cpp new file mode 100644 index 0000000000..7339b05f30 --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/src/Thread.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "Thread.h" +#include +#include +#include +#include +#include "util.h" + + +/*--------------------------------------------------------------------------------------------------*/ + +Thread::Thread() + : m_shutDown(false), m_thread(0) +{ +} + +Thread::~Thread() +{ +} + +void Thread::start() +{ + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + + int rc = pthread_create(&m_thread, &attr, Thread::doWork, (void*)this); + assert(rc == 0); + UNUSED(rc); + + pthread_attr_destroy(&attr); +} + +void Thread::stop() +{ + m_shutDown = true; +} + +bool Thread::isStopped() +{ + return m_shutDown; +} + +/*virtual*/ +void Thread::run() +{ +} + +/*static*/ +void* Thread::doWork(void* param) +{ + //! [MLU] is this safe for derived classes? + try + { + Thread* thread = static_cast(param); + thread->run(); + } + catch(std::bad_alloc& allocationException) + { + aesm_log_report(AESM_LOG_REPORT_ERROR, "Unable to allocate memory"); + throw; + } + + return NULL; +}; + + +void Thread::join() +{ + void* res; + pthread_join(m_thread, &res); +} + +/*--------------------------------------------------------------------------------------------------*/ diff --git a/psw/ae/aesm_service/source/aesm_wrapper/src/UnixServerSocket.cpp b/psw/ae/aesm_service/source/aesm_wrapper/src/UnixServerSocket.cpp new file mode 100644 index 0000000000..a9228f889d --- /dev/null +++ b/psw/ae/aesm_service/source/aesm_wrapper/src/UnixServerSocket.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include +#include + +#include "NonBlockingUnixCommunicationSocket.h" +#include "UnixServerSocket.h" + +UnixServerSocket::UnixServerSocket(const char* socketbase, const unsigned int clientTimeout) : + mSocketBase(socketbase), + mSocket(-1), + mClientTimeout(clientTimeout) +{ +} + +UnixServerSocket::~UnixServerSocket() { + if (mSocket > 0) + close(mSocket); +} + +void UnixServerSocket::init() +{ + /* init will always return directly with success if object was created with pre-existent socket */ + if (mSocket > 0) + return; + + struct sockaddr_un server_address; + + mSocket = socket(AF_UNIX, SOCK_STREAM, 0); + if (mSocket < 0) { + throw("Failed to create socket"); + } + + server_address.sun_family = AF_UNIX; + memset(server_address.sun_path, 0, sizeof(server_address.sun_path)); + // leave the first byte to 0 in order to have an abstract socket address + strncpy(server_address.sun_path + 1, mSocketBase, sizeof(server_address.sun_path) - 1); + unlink(server_address.sun_path); + + socklen_t server_len = sizeof(server_address); + int rc = bind(mSocket, (sockaddr*)&server_address, server_len); + if (rc < 0) { + close(mSocket); + throw("Failed to create socket"); + } + + rc = listen(mSocket, 32); + if (rc < 0) { + close(mSocket); + throw("Error listening on socket"); + } +} + +ICommunicationSocket* UnixServerSocket::accept() +{ + int client_sockfd = (int) TEMP_FAILURE_RETRY(::accept(mSocket, NULL, NULL)); + if (client_sockfd < 0) + return NULL; + + NonBlockingUnixCommunicationSocket* sock = new NonBlockingUnixCommunicationSocket(client_sockfd); + + bool initializationSuccessfull = false; + + if (sock != NULL) + initializationSuccessfull = sock->init(); + + if (initializationSuccessfull == false) + { + delete sock; + sock = NULL; + } + else + { + //set AESM specific timeout for operations with client sockets + sock->setTimeout(mClientTimeout); + } + + return sock; +} diff --git a/psw/ae/aesm_service/source/epid_provision/epid_endpoint_selection.cpp b/psw/ae/aesm_service/source/epid_provision/epid_endpoint_selection.cpp new file mode 100644 index 0000000000..26f1beedb5 --- /dev/null +++ b/psw/ae/aesm_service/source/epid_provision/epid_endpoint_selection.cpp @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "provision_msg.h" +#include "type_length_value.h" +#include +#include "PVEClass.h" +#include "aesm_rand.h" +#include "se_wrapper.h" +#include "epid_utility.h" +#include "prof_fun.h" +#include "oal/internal_log.h" +#include + +static ae_error_t prov_es_gen_header(provision_request_header_t *es_header, + const uint8_t *xid, + uint32_t msg_buffer_size) +{ + uint32_t total_size = 0; + + total_size = ES_SELECTOR_TLV_SIZE(); + //initialize ES Msg1 Header + es_header->protocol = ENDPOINT_SELECTION; + es_header->type = TYPE_ES_MSG1; + es_header->version = TLV_VERSION_1; + if(0!=memcpy_s(es_header->xid, XID_SIZE, xid, XID_SIZE)){ + AESM_DBG_FATAL("memcpy error"); + return PVE_UNEXPECTED_ERROR; + } + uint32_t size_in; + size_in = _htonl(total_size);//big endian size required in msg header + if(0!=memcpy_s(&es_header->size,sizeof(es_header->size), &size_in, sizeof(size_in))){ + AESM_DBG_FATAL("memcpy error"); + return PVE_UNEXPECTED_ERROR; + } + if(total_size +sizeof(*es_header) >msg_buffer_size){//the input msg body buffer size is not large enough + AESM_DBG_ERROR("input msg buffer is too small"); + return PVE_INSUFFICIENT_MEMORY_ERROR; + } + return AE_SUCCESS; +} + +uint32_t CPVEClass::gen_es_msg1( + uint8_t *msg, + uint32_t msg_size, + const gen_endpoint_selection_output_t& es_output) +{ + ae_error_t ret; + AESM_PROFILE_FUN; + if(msg_size < PROVISION_REQUEST_HEADER_SIZE) + return PVE_INSUFFICIENT_MEMORY_ERROR; + provision_request_header_t *es_header = reinterpret_cast(msg); + + ret = prov_es_gen_header(es_header, es_output.xid, msg_size); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to generate Endpoint Selection Msg1 Header:%d",ret); + return ret; + } + + { + TLVsMsg tlvs_msg; + tlv_status_t tlv_status = tlvs_msg.add_es_selector(SE_EPID_PROVISIONING, es_output.selector_id); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("fail to create ES Selector TLV:%d",ret); + return ret; + } + assert(tlvs_msg.get_tlv_msg_size()<=msg_size - PROVISION_REQUEST_HEADER_SIZE); //The checking should have been done in prov_es_gen_header + if(0!=memcpy_s(msg+PROVISION_REQUEST_HEADER_SIZE, msg_size-PROVISION_REQUEST_HEADER_SIZE, tlvs_msg.get_tlv_msg(), tlvs_msg.get_tlv_msg_size())){ + AESM_DBG_FATAL("memcpy failed"); + return PVE_UNEXPECTED_ERROR; + } + return AE_SUCCESS; + } +} + +#define ES_MSG2_FIELD_COUNT 3 +#define ES_FIELD0_MIN_SIZE 3 +#define ES_FIELD0_MAX_SIZE (MAX_PATH-1) +uint32_t CPVEClass::proc_es_msg2( + const uint8_t *msg, + uint32_t msg_size, + char server_url[MAX_PATH], + uint16_t& ttl, + const uint8_t xid[XID_SIZE], + uint8_t rsa_signature[PVE_RSA_KEY_BYTES], + signed_pek_t& pek) +{ + uint32_t ae_ret = PVE_MSG_ERROR; + TLVsMsg tlvs_msg; + AESM_PROFILE_FUN; + tlv_status_t tlv_status; + uint16_t time_in_net; + const provision_response_header_t *resp_header = (const provision_response_header_t *)msg; + const uint8_t *resp_body = msg + PROVISION_RESPONSE_HEADER_SIZE; + if(msg_sizeprotocol != ENDPOINT_SELECTION || resp_header->version!=TLV_VERSION_1 || resp_header->type != TYPE_ES_MSG2){ + AESM_DBG_ERROR("ES Msg2 header error"); + goto final_point; + } + ae_ret = check_endpoint_pg_stauts(resp_header); + if(AE_SUCCESS != ae_ret){ + AESM_DBG_ERROR("Backend report error in ES Msg2 Header:%d",ae_ret); + goto final_point; + } + if(0!=memcmp(xid, resp_header->xid, XID_SIZE)){ + AESM_DBG_ERROR("XID in ES Msg2 header doesn't match the one in ES Msg1"); + ae_ret = PVE_MSG_ERROR; + goto final_point; + } + uint32_t size; size = GET_BODY_SIZE_FROM_PROVISION_RESPONSE(msg); + if(size + PROVISION_RESPONSE_HEADER_SIZE != msg_size){ //size information inconsistent + AESM_DBG_ERROR("message size inconsistent in ES Msg2"); + ae_ret = PVE_MSG_ERROR; + goto final_point; + } + tlv_status = tlvs_msg.init_from_buffer(resp_body, msg_size - static_cast(PROVISION_RESPONSE_HEADER_SIZE)); + ae_ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ae_ret){ + AESM_DBG_ERROR("Fail to decode ES Msg2:%d",ae_ret); + goto final_point; + } + if(tlvs_msg.get_tlv_count() != ES_MSG2_FIELD_COUNT){//three TLVs + AESM_DBG_ERROR("Invaid number of TLV in ES Msg2"); + ae_ret = PVE_MSG_ERROR; + goto final_point; + } + if(tlvs_msg[0].type != TLV_ES_INFORMATION || tlvs_msg[0].version != TLV_VERSION_1 || tlvs_msg[0].header_size != SMALL_TLV_HEADER_SIZE){//TLV header checking + AESM_DBG_ERROR("Invalid TLV in ES Msg2"); + ae_ret = PVE_MSG_ERROR; + goto final_point; + } + + if(tlvs_msg[0].sizeES_FIELD0_MAX_SIZE){//size checking + AESM_DBG_ERROR("Invalid TLV in ES Msg2"); + ae_ret = PVE_MSG_ERROR; + goto final_point; + } + if(tlvs_msg[1].type != TLV_SIGNATURE || tlvs_msg[1].version != TLV_VERSION_1 || + tlvs_msg[1].header_size!=SMALL_TLV_HEADER_SIZE||tlvs_msg[1].size != PVE_RSA_KEY_BYTES+1 || + tlvs_msg[1].payload[0] != PEK_PRIV){ + ae_ret = PVE_MSG_ERROR; + AESM_DBG_ERROR("Invalid Signature TLV: type %d, version %d, size %d while expected value is %d, %d, %d", + tlvs_msg[1].type, tlvs_msg[1].version, tlvs_msg[1].size, + TLV_SIGNATURE, TLV_VERSION_1, PVE_RSA_KEY_BYTES); + goto final_point; + } + if(tlvs_msg[2].type != TLV_PEK || tlvs_msg[2].version != TLV_VERSION_1 || + tlvs_msg[2].header_size!=SMALL_TLV_HEADER_SIZE||tlvs_msg[2].size != sizeof(signed_pek_t)){ + ae_ret = PVE_MSG_ERROR; + AESM_DBG_ERROR("Invalid PEK TLV: type %d, version %d, size %d while expected value is %d, %d, %d", + tlvs_msg[2].type, tlvs_msg[2].version, tlvs_msg[2].size, + TLV_PEK, TLV_VERSION_1, sizeof(signed_pek_t)); + goto final_point; + } + //skip the byte for KEY_ID + if(memcpy_s(rsa_signature, PVE_RSA_KEY_BYTES, tlvs_msg[1].payload+1, tlvs_msg[1].size-1)!=0){ + ae_ret = AE_FAILURE; + AESM_DBG_ERROR("memcpy failed"); + goto final_point; + } + if(memcpy_s(&pek, sizeof(pek), tlvs_msg[2].payload, tlvs_msg[2].size)!=0){ + ae_ret = AE_FAILURE; + AESM_DBG_ERROR("memcpy failed"); + goto final_point; + } + + time_in_net = *(uint16_t *)tlvs_msg[0].payload;//TTL in ES + ttl = lv_ntohs(time_in_net);//First two bytes in payload for TTL (maximal seconds that the URL to be valid) + if(memcpy_s(server_url, MAX_PATH, tlvs_msg[0].payload+2, tlvs_msg[0].size-2)!=0){//other bytes for URL + ae_ret = AE_FAILURE; + AESM_DBG_ERROR("memcpy failed"); + goto final_point; + } + server_url[tlvs_msg[0].size-2]='\0'; + ae_ret = AE_SUCCESS; +final_point: + return ae_ret; +} diff --git a/psw/ae/aesm_service/source/epid_provision/epid_provision_msg1.cpp b/psw/ae/aesm_service/source/epid_provision/epid_provision_msg1.cpp new file mode 100644 index 0000000000..ac0b03bd62 --- /dev/null +++ b/psw/ae/aesm_service/source/epid_provision/epid_provision_msg1.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "type_length_value.h" +#include "sgx_tcrypto_internal.h" +#include "epid_utility.h" +#include "oal/oal.h" +#include "aeerror.h" +#include "PVEClass.h" +#include "se_wrapper.h" + + /** + * File: epid_provision_msg1.cpp + * Description: Provide the untrusted implementation of code to generate ProvMsg1 + */ + +//For each ProvMsg, the first field is msg header (which including XID) +//But in the code here, XID is not counted as a TLV field(since it is part of msg header) +// and the index of TLV field is started from 0. + +//Msg1 Top TLVs: TLV_CIPHER_TEXT(rsa_oaep_result),E+MAC(encrypted_and_mac_data) +#define MSG1_TOP_FIELDS_COUNT 3 +#define MSG1_TOP_FIELD_RSA_OAEP_DATA msg1_fields[0] +#define MSG1_TOP_FIELD_GCM_DATA msg1_fields[1] +#define MSG1_TOP_FIELD_GCM_MAC msg1_fields[2] + + + +//Function to initialize TLV Header for ProvMsg1 and check whether input buffer for ProvMsg1 is large enough +//field1_data_size[in]: size of field1_data which varies according to whether performance rekey used. +//msg1_buffer_size[in]: size of buffer used to hold generated ProvMsg1, it is used by the function to verify whether size of buffer is large enough +//xid[in]: Transaction ID used in protocol +//msg1_header[out]: request header for ProvMsg1 to fill in +static ae_error_t prov_msg1_gen_header(provision_request_header_t *msg1_header, + uint32_t field1_data_size, + const uint8_t *xid, + uint32_t msg1_buffer_size) +{ + uint32_t total_size = 0; + + if(sizeof(*msg1_header)>msg1_buffer_size){ + AESM_DBG_ERROR("Too small ProvMsg1 buffer size"); + return PVE_INSUFFICIENT_MEMORY_ERROR; + } + total_size = CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES) + BLOCK_CIPHER_TEXT_TLV_SIZE(field1_data_size) +MAC_TLV_SIZE(MAC_SIZE); + //initialize field in Msg1 Header + msg1_header->protocol = SE_EPID_PROVISIONING; + msg1_header->type = TYPE_PROV_MSG1; + msg1_header->version = TLV_VERSION_1; + if(0!=memcpy_s(msg1_header->xid, XID_SIZE, xid, XID_SIZE)){ + AESM_DBG_FATAL("fail in memcpy"); + return PVE_UNEXPECTED_ERROR; + } + uint32_t size_in; + size_in = _htonl(total_size);//big endian size required in msg header + if(0!=memcpy_s(&msg1_header->size, sizeof(msg1_header->size),&size_in, sizeof(size_in))){ + AESM_DBG_FATAL("fail in memcpy"); + return PVE_UNEXPECTED_ERROR; + } + if(total_size +sizeof(*msg1_header) >msg1_buffer_size){//the input msg body size is not large enough + AESM_DBG_ERROR("Too small ProvMsg1 buffer size"); + return PVE_INSUFFICIENT_MEMORY_ERROR; + } + return AE_SUCCESS; +} + +//Function to generate ProvMsg1 +//Input psvn could be NULL to use the current psvn, or input the previous_psvn from preivous ProvMsg2 +//The function will generate a random transaction id which is used by msg header of msg1 +//The function return AE_SUCCESS on success and other to indicate error +//Format of ProvMsg1: RSA-OAEP(SK,PSID),E+MAC(DeviceID[:Flags]) +//@psvn: the input psvn or NULL +//@pek: the input PEK got from endpoint selection +//@performance_rekey_used: true for performance rekey and false for first provisioning, backup retrieval or TCB upgrade +//@msg1: buffer to receive ProvMsg1 (including both header and body) +//@msg1_size: size of buffer for generating ProvMsg1 +//@return AE_SUCCESS on success +uint32_t CPVEClass::gen_prov_msg1(const psvn_t *psvn, + const signed_pek_t& pek, + bool performance_rekey_used, + uint8_t *msg1, + uint32_t msg1_size) +{ + uint32_t ret = AE_SUCCESS; + prov_msg1_output_t msg1_output; + //ProvMsg1 header will be in the beginning part of the output msg + provision_request_header_t *msg1_header = reinterpret_cast(msg1); + memset(&msg1_output, 0, sizeof(msg1_output)); + + ret = gen_prov_msg1_data(psvn, &pek, performance_rekey_used, &msg1_output); + if(AE_SUCCESS !=ret ){ + AESM_DBG_ERROR("Gen ProvMsg1 in trusted code failed:%d",ret); + return ret; + } + + ret = prov_msg1_gen_header(msg1_header, msg1_output.field1_data_size, msg1_output.xid, msg1_size); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("fail to generate ProvMsg1 Header:%d",ret); + return ret; + } + + { + TLVsMsg tlvs_msg1; + tlv_status_t tlv_status; + tlv_status= tlvs_msg1.add_cipher_text(msg1_output.field0, PVE_RSA_KEY_BYTES, PEK_PUB); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("Fail to generate field0 TLV of ProvMsg1:%d",ret); + return ret; + } + tlv_status = tlvs_msg1.add_block_cipher_text(msg1_output.field1_iv, msg1_output.field1_data, msg1_output.field1_data_size); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("Fail to generate field1 TLV of ProvMsg1:%d",ret); + return ret; + } + tlv_status = tlvs_msg1.add_mac(msg1_output.field1_mac); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("Fail to create field2 TLV of ProvMsg1:%d",ret); + return ret; + } + uint32_t size = tlvs_msg1.get_tlv_msg_size(); + if(memcpy_s(msg1+PROVISION_REQUEST_HEADER_SIZE, msg1_size - PROVISION_REQUEST_HEADER_SIZE, + tlvs_msg1.get_tlv_msg(), size)!=0){ + AESM_DBG_FATAL("memcpy error"); + return PVE_UNEXPECTED_ERROR;//The size overflow has been checked in header generation + } + } + return AE_SUCCESS; +} + + diff --git a/psw/ae/aesm_service/source/epid_provision/epid_provision_msg2.cpp b/psw/ae/aesm_service/source/epid_provision/epid_provision_msg2.cpp new file mode 100644 index 0000000000..c688b00511 --- /dev/null +++ b/psw/ae/aesm_service/source/epid_provision/epid_provision_msg2.cpp @@ -0,0 +1,537 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "type_length_value.h" +#include "sgx_tcrypto_internal.h" +#include "epid_utility.h" +#include "aeerror.h" +#include "PVEClass.h" +#include "aesm_rand.h" +#include "se_wrapper.h" +#include + +/** +* File: epid_provision_msg2.cpp +* Description: Provide the untrusted implementation of code to process ProvMsg2 +* +* Untrusted Code for EPID Provision +*/ +#define MSG2_TOP_FIELDS_COUNT_WITH_SIGRL 4 +#define MSG2_TOP_FIELDS_COUNT_WITHOUT_SIGRL 3 +#define MSG2_TOP_FIELD_NONCE tlvs_msg2[0] +#define MSG2_TOP_FIELD_DATA tlvs_msg2[1] +#define MSG2_TOP_FIELD_MAC tlvs_msg2[2] +#define MSG2_TOP_FIELD_SIGRL tlvs_msg2[3] +#define MSG2_FIELD1_MAX_COUNT 8 +#define MSG2_FIELD1_MIN_COUNT 6 +#define MSG2_FIELD1_GROUP_CERT tlvs_field1[0] +#define MSG2_FIELD1_NONCE tlvs_field1[1] +#define MSG2_FIELD1_PREV_PSVN tlvs_field1[2]//optional field +#define MSG2_FIELD1_PSID tlvs_field1[psid_index]//psid_index is 2 if optional PREV_PSVN is not present or 3 if it is present +#define MSG2_FIELD1_ENC_TCB tlvs_field1[psid_index+1] +#define MSG2_FIELD1_MAC_TCB tlvs_field1[psid_index+2] +#define MSG2_FIELD1_DEVICE_ID tlvs_field1[psid_index+3] +#define PREV_GID_INDEX (psid_index+4) +#define MSG2_FIELD1_PREV_GID tlvs_field1[PREV_GID_INDEX] + + +//Function to verify that EPID SigRL type and version is correct for sigrl +static ae_error_t verify_sigrl_cert_type_version(const se_sig_rl_t *sigrl_cert) +{ + if(sigrl_cert->epid_identifier!=SE_EPID_SIG_RL_ID|| + sigrl_cert->protocol_version!=SE_EPID_SIG_RL_VERSION) + return PVE_INTEGRITY_CHECK_ERROR; + return AE_SUCCESS; +} + +static ae_error_t msg2_integrity_checking(const TLVsMsg& tlvs_msg2) +{ + uint32_t tlv_count = tlvs_msg2.get_tlv_count(); + if(tlv_count != MSG2_TOP_FIELDS_COUNT_WITH_SIGRL && tlv_count != MSG2_TOP_FIELDS_COUNT_WITHOUT_SIGRL) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG2_TOP_FIELD_NONCE.type != TLV_NONCE || MSG2_TOP_FIELD_NONCE.size != NONCE_SIZE || MSG2_TOP_FIELD_NONCE.version != TLV_VERSION_1) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG2_TOP_FIELD_NONCE.header_size != SMALL_TLV_HEADER_SIZE)//NONCE TLV has small header size + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG2_TOP_FIELD_DATA.type != TLV_BLOCK_CIPHER_TEXT || MSG2_TOP_FIELD_DATA.version != TLV_VERSION_1) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG2_TOP_FIELD_MAC.type != TLV_MESSAGE_AUTHENTICATION_CODE || MSG2_TOP_FIELD_MAC.version != TLV_VERSION_1 || MSG2_TOP_FIELD_MAC.size != MAC_SIZE) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG2_TOP_FIELD_MAC.header_size != SMALL_TLV_HEADER_SIZE) + return PVE_INTEGRITY_CHECK_ERROR; + if(tlv_count == MSG2_TOP_FIELDS_COUNT_WITH_SIGRL){ + if(MSG2_TOP_FIELD_SIGRL.type != TLV_EPID_SIG_RL || MSG2_TOP_FIELD_SIGRL.version != TLV_VERSION_1) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG2_TOP_FIELD_SIGRL.size < 2*SE_ECDSA_SIGN_SIZE + sizeof(se_sig_rl_t)) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG2_TOP_FIELD_SIGRL.header_size != LARGE_TLV_HEADER_SIZE) + return PVE_INTEGRITY_CHECK_ERROR; + return verify_sigrl_cert_type_version(reinterpret_cast(MSG2_TOP_FIELD_SIGRL.payload)); + } + return AE_SUCCESS; +} + +//check the format of msg2_field1 and copy correspondent data input msg2_blob_input +static ae_error_t msg2_field1_msg_check_copy(const TLVsMsg& tlvs_field1, proc_prov_msg2_blob_input_t& msg2_blob_input, const signed_pek_t& pek) +{ + uint32_t tlv_count = tlvs_field1.get_tlv_count(); + uint32_t psid_index = 2; + msg2_blob_input.is_previous_psvn_provided = false; + if(tlv_countMSG2_FIELD1_MAX_COUNT){ + return PVE_MSG_ERROR; + } + uint32_t i; + for(i=0;i(&pek.n), static_cast(sizeof(pek.n)+sizeof(pek.e)), &psid_hash)); + if(AE_SUCCESS != ret) + return ret; + if(0!=memcmp(&psid_hash, MSG2_FIELD1_PSID.payload, sizeof(psid_hash)))//PSID does not match + return PVE_MSG_ERROR; + + tlv_msg_t tcb_data = block_cipher_tlv_get_encrypted_text(MSG2_FIELD1_ENC_TCB); + if(0!=memcpy_s(&msg2_blob_input.group_cert, sizeof(msg2_blob_input.group_cert), MSG2_FIELD1_GROUP_CERT.payload, MSG2_FIELD1_GROUP_CERT.size)|| + 0!=memcpy_s(&msg2_blob_input.challenge_nonce, CHALLENGE_NONCE_SIZE, MSG2_FIELD1_NONCE.payload, MSG2_FIELD1_NONCE.size)|| + 0!=memcpy_s(&msg2_blob_input.equivalent_psvn, sizeof(psvn_t), device_id_tlv_get_psvn(MSG2_FIELD1_DEVICE_ID),sizeof(psvn_t))|| + 0!=memcpy_s(&msg2_blob_input.fmsp, sizeof(fmsp_t), device_id_tlv_get_fmsp(MSG2_FIELD1_DEVICE_ID), sizeof(fmsp_t))|| + 0!=memcpy_s(&msg2_blob_input.tcb_iv, IV_SIZE, block_cipher_tlv_get_iv(MSG2_FIELD1_ENC_TCB), IV_SIZE)|| + 0!=memcpy_s(&msg2_blob_input.encrypted_tcb, SK_SIZE, tcb_data.msg_buf, tcb_data.msg_size)|| + 0!=memcpy_s(&msg2_blob_input.tcb_mac, MAC_SIZE, MSG2_FIELD1_MAC_TCB.payload, MSG2_FIELD1_MAC_TCB.size)){ + return PVE_UNEXPECTED_ERROR; + } + return AE_SUCCESS; +} + +//Function to check message header of ProvMsg2 to determine whether it is valid +//@msg2_header, input the message header of ProvMsg2 +//@return AE_SUCCESS if the message header is valid ProvMsg2 or error code if there're any problems +static ae_error_t check_prov_msg2_header(const provision_response_header_t *msg2_header, uint32_t msg2_size) +{ + if(msg2_header->protocol != SE_EPID_PROVISIONING || msg2_header->type != TYPE_PROV_MSG2 || + msg2_header->version != TLV_VERSION_1){ + return PVE_INTEGRITY_CHECK_ERROR; + } + uint32_t size_in_header = lv_ntohl(msg2_header->size); + if(size_in_header + PROVISION_RESPONSE_HEADER_SIZE != msg2_size) + return PVE_INTEGRITY_CHECK_ERROR; + return AE_SUCCESS; +} + +static uint32_t estimate_epid_sig_size(uint32_t sigrl_size) +{ + uint32_t sigrl_body_size = 0; + uint32_t sigrl_extra_size = static_cast(sizeof(se_sig_rl_t)-sizeof(SigRLEntry)+2*ECDSA_SIGN_SIZE); + if(sigrl_size<=sigrl_extra_size){ + return static_cast(sizeof(EPIDSignature)-sizeof(NRProof)); + }else{ + sigrl_body_size = sigrl_size - sigrl_extra_size; + size_t entry_count = sigrl_body_size/sizeof(SigRLEntry); + return static_cast(sizeof(EPIDSignature)-sizeof(NRProof)+sizeof(NRProof)*entry_count); + } +} + +static ae_error_t gen_msg3_header(const gen_prov_msg3_output_t& msg3_output, const uint8_t xid[XID_SIZE], provision_request_header_t *msg3_header, uint32_t& msg3_size) +{ + msg3_header->protocol = SE_EPID_PROVISIONING; + msg3_header->version = TLV_VERSION_1; + msg3_header->type = TYPE_PROV_MSG3; + size_t field1_size = 0; + if(msg3_output.is_join_proof_generated){ + field1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(HARD_CODED_JOIN_PROOF_WITH_ESCROW_TLV_SIZE)+MAC_TLV_SIZE(MAC_SIZE); + }else{ + field1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(0)+MAC_TLV_SIZE(MAC_SIZE); + } + size_t total_body_size = NONCE_TLV_SIZE(NONCE_SIZE) + BLOCK_CIPHER_TEXT_TLV_SIZE(field1_size)+MAC_TLV_SIZE(MAC_SIZE); + if(msg3_output.is_epid_sig_generated){ + total_body_size += BLOCK_CIPHER_TEXT_TLV_SIZE(msg3_output.epid_sig_output_size)+MAC_TLV_SIZE(MAC_SIZE); + } + uint32_t size_in_net = _htonl(total_body_size); + if(0!=memcpy_s(&msg3_header->size, sizeof(msg3_header->size), &size_in_net, sizeof(size_in_net))) + return PVE_UNEXPECTED_ERROR;//size in Big Endian in message header of ProvMsg3 + if(total_body_size>msg3_size - PROVISION_REQUEST_HEADER_SIZE ){//make sure buffer size provided by user is large enough + return PVE_INSUFFICIENT_MEMORY_ERROR; + } + if(0!=memcpy_s(msg3_header->xid, XID_SIZE, xid, XID_SIZE)) + return PVE_UNEXPECTED_ERROR; //copy transaction id of ProvMsg2 + msg3_size = static_cast(total_body_size + PROVISION_REQUEST_HEADER_SIZE); + return AE_SUCCESS; +} + +//Function to decode ProvMsg2 and generate ProvMsg3 on success +//ProvMsg2 Format: +//R, E+MAC(**), [SigRL with ECDSA Sig] +//@msg2, the input buffer for ProvMsg2 in TLV encoded format +//@msg2_size, size of buffer msg2 +//@pek, the input pek got from endpoint selection protocol +//@epid_blob, input an optional old epid data blob used to generate non-revoke proof if required +//@blob_size, the buffer size of epid_blob +//@ek2, an output parameter for EK2 used in provision protocol which could be reused in proc_prov_msg4 +//@previous_psvn, an optional output buffer for Previous SigRL PSVN if old epid blob is missing or invalid +// so that caller could repeat ProvMsg1 and ProvMsg4 to retrieve backuped old epid data blob +//@msg3, output the ProvMsg3 in TLV encoded format +//@msg3_size: input the size of buffer msg3 +//@return AE_SUCCESS on success and error code on failure +// PVE_EPID_BLOB_ERROR is returned if old_epid_blob is required but it is invalid or not provided and +// previous_psvn will be filled in by a Previous SigRL PSVN +uint32_t CPVEClass::proc_prov_msg2( + const uint8_t* msg2, + uint32_t msg2_size, + const signed_pek_t& pek, + const uint8_t* epid_blob, + uint32_t blob_size, + uint8_t ek2[SK_SIZE], + psvn_t* previous_psvn, + uint8_t* msg3, + uint32_t msg3_size) +{ + ae_error_t ret = AE_SUCCESS; + const se_sig_rl_t *sigrl = NULL; + uint32_t sigrl_size = 0; + uint8_t *epid_sig = NULL; + uint8_t *decoded_msg2 = NULL; + uint8_t *encrypted_field1 = NULL; + uint8_t aad[PROVISION_RESPONSE_HEADER_SIZE+sizeof(RLver_t)+sizeof(GroupID)]; + size_t aad_size = PROVISION_RESPONSE_HEADER_SIZE; + const provision_response_header_t *msg2_header = reinterpret_cast(msg2); + provision_request_header_t *msg3_header = reinterpret_cast(msg3); + if(msg2_size < PROVISION_RESPONSE_HEADER_SIZE){ + AESM_DBG_ERROR("ProvMsg2 size too small"); + return PVE_MSG_ERROR; + } + if(msg3_size (PROVISION_RESPONSE_HEADER_SIZE), msg2_size - static_cast(PROVISION_RESPONSE_HEADER_SIZE)); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("Fail to decode ProvMsg2:%d",ret); + break; + } + ret = msg2_integrity_checking(tlvs_msg2);//checking and verifying that TLV structure is correct and version is supported + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("ProvMsg2 integrity checking error:%d",ret); + break; + } + prov_get_ek2_input_t ek2_input; + if(memcpy_s(ek2_input.nonce, NONCE_SIZE, MSG2_TOP_FIELD_NONCE.payload, NONCE_SIZE)!=0){ + AESM_DBG_FATAL("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + if(memcpy_s(ek2_input.xid, XID_SIZE, msg2_header->xid, XID_SIZE)!=0){ + AESM_DBG_FATAL("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + //call PvE to get EK2 + se_static_assert(SK_SIZE == sizeof(prov_get_ek2_output_t)); + ret = static_cast(get_ek2(&ek2_input, reinterpret_cast(ek2))); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to get EK2:%d",ret); + break; + } + if(tlvs_msg2.get_tlv_count() == MSG2_TOP_FIELDS_COUNT_WITH_SIGRL){//RLver and gid is added as part of AAD if available + sigrl = reinterpret_cast(MSG2_TOP_FIELD_SIGRL.payload); + if(0!=memcpy_s(aad+PROVISION_RESPONSE_HEADER_SIZE, sizeof(RLver_t), &sigrl->sig_rl.RLver, sizeof(RLver_t))){ + AESM_DBG_FATAL("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + if(0!=memcpy_s(aad+PROVISION_RESPONSE_HEADER_SIZE+sizeof(RLver_t), sizeof(GroupID), &sigrl->sig_rl.gid, sizeof(GroupID))){ + AESM_DBG_FATAL("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + aad_size += sizeof(RLver_t)+sizeof(GroupID); + sigrl_size = MSG2_TOP_FIELD_SIGRL.size; + } + se_static_assert(SK_SIZE==sizeof(sgx_aes_gcm_128bit_key_t)); + tlv_msg_t field1 = block_cipher_tlv_get_encrypted_text(MSG2_TOP_FIELD_DATA); + decoded_msg2 = reinterpret_cast(malloc(field1.msg_size)); + if(NULL == decoded_msg2){ + AESM_DBG_ERROR("malloc error"); + ret= AE_OUT_OF_MEMORY_ERROR; + break; + } + //decrypt ProvMsg2 by EK2 + sgx_status_t sgx_status = sgx_rijndael128GCM_decrypt(reinterpret_cast(ek2), + field1.msg_buf, field1.msg_size, decoded_msg2, + reinterpret_cast(block_cipher_tlv_get_iv(MSG2_TOP_FIELD_DATA)), IV_SIZE, + aad, static_cast(aad_size), reinterpret_cast(MSG2_TOP_FIELD_MAC.payload)); + if(SGX_ERROR_MAC_MISMATCH == sgx_status){ + AESM_DBG_ERROR("Fail to decrypt ProvMsg2 body by EK2"); + ret = PVE_INTEGRITY_CHECK_ERROR; + break; + } + if( AE_SUCCESS != (ret = sgx_error_to_ae_error(sgx_status))){ + AESM_DBG_ERROR("error in decrypting ProvMsg2 body:%d",sgx_status); + break; + } + + ret = check_epid_pve_pg_status_after_mac_verification(msg2_header); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Backend server reported error in ProvMsg2 passed MAC verification:%d",ret); + break; + } + TLVsMsg tlvs_field1; + tlv_status = tlvs_field1.init_from_buffer(decoded_msg2, field1.msg_size);//decode TLV structure of field1 of ProvMsg2 + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("Fail to decode field1 of ProvMsg2:%d",tlv_status); + break; + } + proc_prov_msg2_blob_input_t msg2_blob_input; + ret = msg2_field1_msg_check_copy(tlvs_field1, msg2_blob_input, pek);//version/type checking to verify message format + if( AE_SUCCESS != ret){ + AESM_DBG_ERROR("field1 of ProvMsg2 checking error:%d",ret); + break; + } + gen_prov_msg3_output_t msg3_fixed_output; + memset(&msg3_fixed_output, 0, sizeof(msg3_fixed_output)); + //collect old epid blob + if(epid_blob==NULL){ + memset(msg2_blob_input.old_epid_data_blob, 0, HARD_CODED_EPID_BLOB_SIZE); + }else if(blob_size!=HARD_CODED_EPID_BLOB_SIZE){ + AESM_DBG_FATAL("epid blob internal size error"); + ret = PVE_UNEXPECTED_ERROR; + break; + }else{ +#ifdef DBG_LOG + { + char dbg_str[256]; + aesm_dbg_format_hex(reinterpret_cast(&epid_blob), blob_size, dbg_str, 256); + AESM_DBG_TRACE("old epid blob=%s",dbg_str); + } +#endif + if(0!=memcpy_s(msg2_blob_input.old_epid_data_blob, HARD_CODED_EPID_BLOB_SIZE, epid_blob, blob_size)){ + AESM_DBG_FATAL("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + } + uint32_t epid_sig_output_size = estimate_epid_sig_size(sigrl_size) + MAX_TLV_HEADER_SIZE; + epid_sig = reinterpret_cast(malloc(epid_sig_output_size)); + if(NULL == epid_sig){ + AESM_DBG_ERROR("malloc error"); + ret = AE_OUT_OF_MEMORY_ERROR; + break; + } + ret = (ae_error_t)proc_prov_msg2_data(&msg2_blob_input, reinterpret_cast(sigrl), sigrl_size, + &msg3_fixed_output, epid_sig, epid_sig_output_size);//ecall to process msg2 data and generate msg3 data in PvE + if( PVE_EPIDBLOB_ERROR == ret){ + if(previous_psvn == NULL){ + AESM_DBG_ERROR("PvE requires previous PSVN but it is not provided"); + ret = PVE_PARAMETER_ERROR; + break; + }else{//output previous svn in correspondent to sigrl in epid blob error + if(0!=memcpy_s(previous_psvn, sizeof(psvn_t), &msg2_blob_input.previous_psvn, sizeof(psvn_t))){ + AESM_DBG_FATAL("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + } + } + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("PvE report error %d in processing ProvMsg2",ret); + break; + } + uint8_t iv[IV_SIZE]; + uint8_t mac[MAC_SIZE]; + uint8_t *payload_data=NULL; + uint32_t payload_size = 0; + ret = aesm_read_rand(iv, IV_SIZE); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("fail to generate random number:%d",ret); + break; + } + //Now start to generate ProvMsg3 + ret = gen_msg3_header(msg3_fixed_output, ek2_input.xid, msg3_header,msg3_size);//first generate header + if( AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to generate ProvMsg3 Header:%d",ret); + break; + } + TLVsMsg tlvs_msg3; + tlv_status = tlvs_msg3.add_nonce(ek2_input.nonce, NONCE_SIZE); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("Fail to generate Nonce TLV in ProvMsg3:%d",tlv_status); + break; + } + if(msg3_fixed_output.is_join_proof_generated){ + payload_data = msg3_fixed_output.field1_data; + payload_size = static_cast(HARD_CODED_JOIN_PROOF_WITH_ESCROW_TLV_SIZE); + } + TLVsMsg tlvs_m3field1; + tlv_status = tlvs_m3field1.add_block_cipher_text(msg3_fixed_output.field1_iv, payload_data, payload_size); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to generate Field3.1 TLV in ProvMsg3:%d",tlv_status); + break; + } + tlv_status = tlvs_m3field1.add_mac(msg3_fixed_output.field1_mac); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to generate Field3.2 TLV in ProvMsg3:%d",tlv_status); + break; + } + encrypted_field1 = reinterpret_cast(malloc(tlvs_m3field1.get_tlv_msg_size())); + if( NULL == encrypted_field1){ + AESM_DBG_ERROR("malloc error"); + ret = AE_OUT_OF_MEMORY_ERROR; + break; + } + //encrypt field1 using ek2 as key + sgx_status = sgx_rijndael128GCM_encrypt(reinterpret_cast(ek2), + tlvs_m3field1.get_tlv_msg(), tlvs_m3field1.get_tlv_msg_size(), encrypted_field1, + iv, IV_SIZE, reinterpret_cast(msg3_header), PROVISION_REQUEST_HEADER_SIZE, + reinterpret_cast(mac)); + if(AE_SUCCESS != (ret = sgx_error_to_ae_error(sgx_status))){ + AESM_DBG_ERROR("fail to encrypting ProvMsg3 body by ek2:%d",sgx_status); + break; + } + tlv_status = tlvs_msg3.add_block_cipher_text(iv, encrypted_field1, tlvs_m3field1.get_tlv_msg_size()); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to create Field1 TLV of ProvMsg3:%d",tlv_status); + break; + } + ret = tlv_error_2_pve_error(tlvs_msg3.add_mac(mac)); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to create Field2 TLV of ProvMsg3:%d",ret); + break; + } + if(msg3_fixed_output.is_epid_sig_generated){ + tlv_status = tlvs_msg3.add_block_cipher_text(msg3_fixed_output.epid_sig_iv, epid_sig, msg3_fixed_output.epid_sig_output_size); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to create Field3 TLV of ProvMsg3:%d",tlv_status); + break; + } + tlv_status = tlvs_msg3.add_mac(msg3_fixed_output.epid_sig_mac); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Fail to create Field4 TLV of ProvMsg3:%d",tlv_status); + break; + } + } + assert( tlvs_msg3.get_tlv_msg_size() <= msg3_size - PROVISION_REQUEST_HEADER_SIZE);//The checking should have been done in header generation + + if(0!=memcpy_s(msg3+PROVISION_REQUEST_HEADER_SIZE, msg3_size-PROVISION_REQUEST_HEADER_SIZE, + tlvs_msg3.get_tlv_msg(), tlvs_msg3.get_tlv_msg_size())){ + AESM_DBG_FATAL("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + AESM_DBG_TRACE("ProvMsg3 generated successfully"); + ret = AE_SUCCESS; + }while(0); + if(decoded_msg2)free(decoded_msg2); + if(encrypted_field1) free(encrypted_field1); + if(epid_sig)free(epid_sig); + return ret; +} diff --git a/psw/ae/aesm_service/source/epid_provision/epid_provision_msg4.cpp b/psw/ae/aesm_service/source/epid_provision/epid_provision_msg4.cpp new file mode 100644 index 0000000000..18cccf91e0 --- /dev/null +++ b/psw/ae/aesm_service/source/epid_provision/epid_provision_msg4.cpp @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "type_length_value.h" +#include "sgx_tcrypto_internal.h" +#include +#include "epid_utility.h" +#include "aeerror.h" +#include "PVEClass.h" +#include "se_wrapper.h" +#include "oal/internal_log.h" +/** +* File: epid_provision_msg4.cpp +* Description: Provide the untrusted implementation of code to process ProvMsg4 +* +* Untrusted Code for EPID Provision +*/ +#define MSG4_TOP_FIELDS_COUNT 3 +#define MSG4_TOP_FIELD_NONCE tlvs_msg4[0] +#define MSG4_TOP_FIELD_DATA tlvs_msg4[1] +#define MSG4_TOP_FIELD_MAC tlvs_msg4[2] + +#define MSG4_FIELD1_COUNT 6 +#define MSG4_FIELD1_DEVICE_ID tlvs_field1[5] +#define MSG4_FIELD1_ENC_TCB tlvs_field1[0] +#define MSG4_FIELD1_MAC_TCB tlvs_field1[1] +#define MSG4_FIELD1_ENC_Axf tlvs_field1[2] +#define MSG4_FIELD1_MAC_Axf tlvs_field1[3] +#define MSG4_FIELD1_GROUP_CERT tlvs_field1[4] + + +static ae_error_t msg4_integrity_checking(const TLVsMsg& tlvs_msg4) +{ + uint32_t tlv_count = tlvs_msg4.get_tlv_count(); + if(tlv_count != MSG4_TOP_FIELDS_COUNT) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG4_TOP_FIELD_NONCE.type != TLV_NONCE || MSG4_TOP_FIELD_NONCE.size != NONCE_SIZE || + MSG4_TOP_FIELD_NONCE.version != TLV_VERSION_1 || MSG4_TOP_FIELD_NONCE.header_size != SMALL_TLV_HEADER_SIZE) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG4_TOP_FIELD_DATA.type != TLV_BLOCK_CIPHER_TEXT || MSG4_TOP_FIELD_DATA.version != TLV_VERSION_1) + return PVE_INTEGRITY_CHECK_ERROR; + if(MSG4_TOP_FIELD_MAC.type != TLV_MESSAGE_AUTHENTICATION_CODE || MSG4_TOP_FIELD_MAC.version != TLV_VERSION_1 || + MSG4_TOP_FIELD_MAC.size != MAC_SIZE || MSG4_TOP_FIELD_MAC.header_size != SMALL_TLV_HEADER_SIZE) + return PVE_INTEGRITY_CHECK_ERROR; + return AE_SUCCESS; +} + +static ae_error_t msg4_field1_msg_checking(const TLVsMsg& tlvs_field1) +{ + uint32_t tlv_count = tlvs_field1.get_tlv_count(); + if(tlv_count!=MSG4_FIELD1_COUNT){ + return PVE_MSG_ERROR; + } + uint32_t i; + for(i=0;iprotocol != SE_EPID_PROVISIONING || msg4_header->type != TYPE_PROV_MSG4 || + msg4_header->version != TLV_VERSION_1){ + return PVE_INTEGRITY_CHECK_ERROR; + } + uint32_t size_in_header = lv_ntohl(msg4_header->size); + if(size_in_header + PROVISION_RESPONSE_HEADER_SIZE != msg4_size) + return PVE_INTEGRITY_CHECK_ERROR; + return AE_SUCCESS; +} + + +//Function to decode ProvMsg4 and generate epid data blob +uint32_t CPVEClass::proc_prov_msg4( + bool use_ek2_in_input, + const uint8_t ek2[SK_SIZE], + const uint8_t* msg4, + uint32_t msg4_size, + uint8_t* data_blob, + uint32_t blob_size) +{ + ae_error_t ret = AE_SUCCESS; + uint8_t local_ek2[SK_SIZE]; + uint8_t *decoded_msg4 = NULL; + const provision_response_header_t *msg4_header = reinterpret_cast(msg4); + if(msg4_size < PROVISION_RESPONSE_HEADER_SIZE){ + AESM_DBG_ERROR("invalid msg4 size"); + return PVE_MSG_ERROR; + } + if(blob_size != HARD_CODED_EPID_BLOB_SIZE){ + AESM_DBG_FATAL("invalid input epid blob size"); + return PVE_PARAMETER_ERROR; + } + + ret = check_prov_msg4_header(msg4_header, msg4_size); + if( AE_SUCCESS != ret){ + AESM_DBG_ERROR("Invalid ProvMsg4 Header:%d",ret); + return ret; + } + ret = check_epid_pve_pg_status_before_mac_verification(msg4_header); + if( AE_SUCCESS != ret){ + AESM_DBG_ERROR("Backend return failure in ProvMsg4 Header:%d",ret); + return ret; + } + + do{ + TLVsMsg tlvs_msg4; + tlv_status_t tlv_status; + tlv_status = tlvs_msg4.init_from_buffer(msg4+static_cast(PROVISION_RESPONSE_HEADER_SIZE), msg4_size - static_cast(PROVISION_RESPONSE_HEADER_SIZE)); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS!=ret){ + AESM_DBG_ERROR("fail to decode ProvMsg4:%d",tlv_status); + break; + } + ret = msg4_integrity_checking(tlvs_msg4); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("ProvMsg4 integrity checking error:%d",ret); + break; + } + AESM_DBG_TRACE("ProvMsg4 decoded"); + if(!use_ek2_in_input){ //we need generate ek2 + prov_get_ek2_input_t ek2_input; + if(memcpy_s(ek2_input.nonce, NONCE_SIZE, MSG4_TOP_FIELD_NONCE.payload, NONCE_SIZE)!=0){ + AESM_DBG_ERROR("fail in memcpy"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + if(memcpy_s(ek2_input.xid, XID_SIZE, msg4_header->xid, XID_SIZE)!=0){ + AESM_DBG_ERROR("fail in memcpy"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + //call PvE to get EK2 + se_static_assert(SK_SIZE == sizeof(prov_get_ek2_output_t)); + + ret = (ae_error_t)get_ek2(&ek2_input, reinterpret_cast(local_ek2)); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("fail to get EK2:%d",ret); + break; + } + }else{//reuse ek2 generated in processing ProvMsg2 + if(0!=memcpy_s(local_ek2, sizeof(local_ek2), ek2, SK_SIZE)){ + AESM_DBG_ERROR("fail in memcpy"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + } + se_static_assert(SK_SIZE==sizeof(sgx_aes_gcm_128bit_key_t)); + tlv_msg_t field1 = block_cipher_tlv_get_encrypted_text(MSG4_TOP_FIELD_DATA); + decoded_msg4 = reinterpret_cast(malloc(field1.msg_size)); + if(NULL == decoded_msg4){ + AESM_DBG_ERROR("malloc error"); + ret = AE_OUT_OF_MEMORY_ERROR; + break; + } + sgx_status_t sgx_status = sgx_rijndael128GCM_decrypt(reinterpret_cast(local_ek2), + field1.msg_buf, field1.msg_size, decoded_msg4, + reinterpret_cast(block_cipher_tlv_get_iv(MSG4_TOP_FIELD_DATA)), IV_SIZE, + reinterpret_cast(msg4_header), PROVISION_RESPONSE_HEADER_SIZE, + reinterpret_cast(MSG4_TOP_FIELD_MAC.payload)); + if(SGX_ERROR_MAC_MISMATCH == sgx_status){ + AESM_DBG_ERROR("fail to decrypt ProvMsg4 by EK2"); + ret = PVE_INTEGRITY_CHECK_ERROR; + break; + } + if( AE_SUCCESS != (ret = sgx_error_to_ae_error(sgx_status))){ + AESM_DBG_ERROR("error in decrypting ProvMsg4:%d",sgx_status); + break; + } + AESM_DBG_TRACE("ProvMsg4 decrypted by EK2 successfully"); + ret = check_epid_pve_pg_status_after_mac_verification(msg4_header); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("Backend reported error passed MAC verification:%d",ret); + break; + } + TLVsMsg tlvs_field1; + tlv_status = tlvs_field1.init_from_buffer(decoded_msg4, field1.msg_size); + ret = tlv_error_2_pve_error(tlv_status); + if(AE_SUCCESS != ret){ + AESM_DBG_ERROR("ProvMsg4 Field2.1 decoding failed:%d",tlv_status); + break; + } + ret = msg4_field1_msg_checking(tlvs_field1); + if( AE_SUCCESS != ret){ + AESM_DBG_ERROR("ProvMsg4 Field2.1 invalid:%d",ret); + break; + } + proc_prov_msg4_input_t msg4_input; + if(sizeof(proc_prov_msg4_output_t)!=SGX_TRUSTED_EPID_BLOB_SIZE){ + AESM_DBG_FATAL("Trusted ProvMsg4 output buffer size error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + tlv_msg_t tcb_data = block_cipher_tlv_get_encrypted_text(MSG4_FIELD1_ENC_TCB); + tlv_msg_t Axf_data = block_cipher_tlv_get_encrypted_text(MSG4_FIELD1_ENC_Axf); + if(0!=memcpy_s(&msg4_input.group_cert, sizeof(msg4_input.group_cert), MSG4_FIELD1_GROUP_CERT.payload, MSG4_FIELD1_GROUP_CERT.size)|| + 0!=memcpy_s(&msg4_input.equivalent_psvn, sizeof(psvn_t), device_id_tlv_get_psvn(MSG4_FIELD1_DEVICE_ID), sizeof(psvn_t))|| + 0!=memcpy_s(&msg4_input.fmsp, sizeof(fmsp_t), device_id_tlv_get_fmsp(MSG4_FIELD1_DEVICE_ID), sizeof(fmsp_t))|| + 0!=memcpy_s(&msg4_input.tcb_iv, IV_SIZE, block_cipher_tlv_get_iv(MSG4_FIELD1_ENC_TCB), IV_SIZE)|| + 0!=memcpy_s(&msg4_input.encrypted_tcb, SK_SIZE, tcb_data.msg_buf, tcb_data.msg_size)|| + 0!=memcpy_s(&msg4_input.tcb_mac, MAC_SIZE, MSG4_FIELD1_MAC_TCB.payload, MSG4_FIELD1_MAC_TCB.size)|| + 0!=memcpy_s(&msg4_input.member_credential_iv, IV_SIZE, block_cipher_tlv_get_iv(MSG4_FIELD1_ENC_Axf), IV_SIZE)|| + 0!=memcpy_s(&msg4_input.encrypted_member_credential, HARD_CODED_EPID_MEMBER_WITH_ESCROW_TLV_SIZE, Axf_data.msg_buf, Axf_data.msg_size)|| + 0!=memcpy_s(&msg4_input.member_credential_mac, MAC_SIZE, MSG4_FIELD1_MAC_Axf.payload, MSG4_FIELD1_MAC_Axf.size)){ + AESM_DBG_ERROR("memcpy error"); + ret = PVE_UNEXPECTED_ERROR; + break; + } + ret = (ae_error_t)proc_prov_msg4_data(&msg4_input, reinterpret_cast(data_blob)); + AESM_DBG_TRACE("PvE return %d in Process ProvMsg4",ret); + }while(0); + if(decoded_msg4)free(decoded_msg4); + return ret; +} diff --git a/psw/ae/aesm_service/source/epid_provision/epid_utility.cpp b/psw/ae/aesm_service/source/epid_provision/epid_utility.cpp new file mode 100644 index 0000000000..7e39e0cb79 --- /dev/null +++ b/psw/ae/aesm_service/source/epid_provision/epid_utility.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "epid_utility.h" + +ae_error_t tlv_error_2_pve_error(tlv_status_t tlv_status) +{ + switch(tlv_status){ + case TLV_SUCCESS: + return AE_SUCCESS; + case TLV_INVALID_PARAMETER_ERROR: + return PVE_PARAMETER_ERROR; + case TLV_INVALID_MSG_ERROR: + case TLV_INVALID_FORMAT: + return PVE_MSG_ERROR; + case TLV_INSUFFICIENT_MEMORY: + return PVE_INSUFFICIENT_MEMORY_ERROR; + case TLV_OUT_OF_MEMORY_ERROR: + return AE_OUT_OF_MEMORY_ERROR; + case TLV_UNKNOWN_ERROR: + case TLV_MORE_TLVS: + case TLV_UNSUPPORTED: + return PVE_UNEXPECTED_ERROR; + } + return PVE_UNEXPECTED_ERROR; +} + +ae_error_t check_endpoint_pg_stauts(const provision_response_header_t *msg_header) +{ + uint16_t gstatus; + gstatus = lv_ntohs(msg_header->gstatus); + switch(gstatus){ + case GRS_SERVER_BUSY: + return PVE_SERVER_BUSY_ERROR; + case GRS_INTEGRITY_CHECK_FAIL: + return PVE_INTEGRITY_CHECK_ERROR; + case GRS_INCOMPATIBLE_VERSION://Backend report that PSW has used too old protocol, we need update PSW software + return PSW_UPDATED_REQUIRED; + case GRS_INCORRECT_SYNTAX: + return PVE_MSG_ERROR; + case GRS_OK: + return AE_SUCCESS; + default: //For endpoint selection, no MAC checking of error code required so that return server reported error directly + return PVE_SERVER_REPORTED_ERROR; + } +} + +ae_error_t check_epid_pve_pg_status_before_mac_verification(const provision_response_header_t *msg_header) +{ + uint16_t gstatus; + gstatus = lv_ntohs(msg_header->gstatus); + switch(gstatus){ + case GRS_SERVER_BUSY: + return PVE_SERVER_BUSY_ERROR; + case GRS_INTEGRITY_CHECK_FAIL: + return PVE_INTEGRITY_CHECK_ERROR; + case GRS_INCOMPATIBLE_VERSION://Backend report that PSW has used too old protocol, we need update PSW software, no MAC provided + return PSW_UPDATED_REQUIRED; + case GRS_INCORRECT_SYNTAX: + return PVE_MSG_ERROR; + case GRS_OK: + return AE_SUCCESS; + case GRS_PROTOCOL_ERROR: + return AE_SUCCESS;//ignore those errors to check them after mac verification passed + default: + return PVE_SERVER_REPORTED_ERROR; + } +} + +ae_error_t check_epid_pve_pg_status_after_mac_verification(const provision_response_header_t *msg_header) +{ + uint16_t gstatus, pstatus; + gstatus = lv_ntohs(msg_header->gstatus); + pstatus = lv_ntohs(msg_header->pstatus); + switch(gstatus){ + case GRS_OK: + if(pstatus!=SE_PRS_OK) + return PVE_SERVER_REPORTED_ERROR; + return AE_SUCCESS; + case GRS_PROTOCOL_ERROR: + AESM_DBG_INFO("Server reported protocol error %d", (int)pstatus); + switch(pstatus){ + case SE_PRS_STATUS_INTEGRITY_FAILED: + return PVE_INTEGRITY_CHECK_ERROR; + case SE_PRS_PLATFORM_REVOKED: + return PVE_REVOKED_ERROR; + case SE_PRS_PERFORMANCE_REKEY_NOT_SUPPORTED: + return PVE_PERFORMANCE_REKEY_NOT_SUPPORTED; + default: + return PVE_SERVER_REPORTED_ERROR; + } + default: + return PVE_SERVER_REPORTED_ERROR; + } +} diff --git a/psw/ae/aesm_service/source/epid_provision/epid_utility.h b/psw/ae/aesm_service/source/epid_provision/epid_utility.h new file mode 100644 index 0000000000..ebc9498ab3 --- /dev/null +++ b/psw/ae/aesm_service/source/epid_provision/epid_utility.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _EPID_UTILITY_H_ +#define _EPID_UTILITY_H_ + +#include "aeerror.h" +#include "arch.h" +#include "type_length_value.h" + +ae_error_t tlv_error_2_pve_error(tlv_status_t tlv_status); +ae_error_t check_endpoint_pg_stauts(const provision_response_header_t *msg_header); +ae_error_t check_epid_pve_pg_status_before_mac_verification(const provision_response_header_t *msg_header); +ae_error_t check_epid_pve_pg_status_after_mac_verification(const provision_response_header_t *msg_header); +#endif + diff --git a/psw/ae/aesm_service/source/le/LEClass.cpp b/psw/ae/aesm_service/source/le/LEClass.cpp new file mode 100644 index 0000000000..3412fc3943 --- /dev/null +++ b/psw/ae/aesm_service/source/le/LEClass.cpp @@ -0,0 +1,271 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include "LEClass.h" +#include "aeerror.h" +#include "arch.h" +#include "ae_ipp.h" +#include "util.h" + +extern "C" sgx_status_t sgx_create_le(const char *file_name, const char *prd_css_file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr, int *production_loaded); + +#include "launch_enclave_u.h" +#include "launch_enclave_u.c" + +int CLEClass::white_list_register( + const uint8_t *white_list_cert, + uint32_t white_list_cert_size, + bool save_to_persistent_storage) +{ + sgx_status_t ret = SGX_SUCCESS; + int retry = 0; + uint32_t status = 0; + + assert(m_enclave_id); + + ret = le_init_white_list_wrapper(m_enclave_id, &status, + const_cast(white_list_cert), + white_list_cert_size); + for(; ret == SGX_ERROR_ENCLAVE_LOST && retry < AESM_RETRY_COUNT; retry++) + { + unload_enclave(); + if(AE_SUCCESS != load_enclave_only()) + return AE_FAILURE; + ret = le_init_white_list_wrapper(m_enclave_id, &status, + const_cast(white_list_cert), + white_list_cert_size); + } + + if(SGX_SUCCESS!=ret) + return sgx_error_to_ae_error(ret); + AESM_DBG_TRACE("le_init_white_list_wrapper return %d",status); + if(AE_SUCCESS == status&&save_to_persistent_storage){//successfully register the white list cert + if(AE_SUCCESS != aesm_write_data(FT_PERSISTENT_STORAGE,AESM_WHITE_LIST_CERT_FID,white_list_cert, white_list_cert_size)){//ignore error if failed to save in persistent storage + AESM_DBG_WARN("Fail to save white list cert in persistent storage"); + } + } + return status; +} + + +void CLEClass::load_white_cert_list() +{ + load_verified_white_cert_list(); + load_white_cert_list_to_be_verify();//If this version is older than previous one, it will not be loaded +} + +ae_error_t CLEClass::load_verified_white_cert_list() +{ + ae_error_t ae_err; + uint32_t white_cert_size=0; + ae_err = aesm_query_data_size(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_FID, &white_cert_size); + if(AE_SUCCESS == ae_err && white_cert_size ==0){//file not existing or 0 size + AESM_DBG_TRACE("no white cert list available in persistent storage"); + return AE_SUCCESS; + } + if(AE_SUCCESS != ae_err) + return ae_err; + uint8_t *p = (uint8_t *)malloc(white_cert_size); + if(NULL == p){ + AESM_DBG_ERROR("out of memory"); + return AE_OUT_OF_MEMORY_ERROR; + } + ae_err = aesm_read_data(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_FID, p, &white_cert_size); + if(AE_SUCCESS != ae_err){ + AESM_DBG_WARN("Fail to read white cert list file"); + free(p); + return ae_err; + } + ae_err = (ae_error_t)white_list_register(p, white_cert_size,false);//Need not save the data to file again + if(AE_SUCCESS!=ae_err){ + AESM_DBG_WARN("fail to register white cert list file in persistent storage"); + } + free(p); + return ae_err; +} + +//This function must be called after white list cert has been verified and the file may overwrite the original one +ae_error_t CLEClass::load_white_cert_list_to_be_verify() +{ + ae_error_t ae_err; + uint32_t white_cert_size=0; + ae_err = aesm_query_data_size(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID, &white_cert_size); + if(AE_SUCCESS != ae_err || white_cert_size ==0){//file not existing or 0 size + AESM_DBG_TRACE("no white cert list to be verify in persistent storage"); + return AE_SUCCESS; + } + uint8_t *p = (uint8_t *)malloc(white_cert_size); + if(NULL == p){ + AESM_DBG_ERROR("out of memory"); + return AE_OUT_OF_MEMORY_ERROR; + } + ae_err = aesm_read_data(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID, p, &white_cert_size); + if(AE_SUCCESS != ae_err){ + AESM_DBG_WARN("Fail to read white cert list file"); + free(p); + return ae_err; + } + ae_err = (ae_error_t)white_list_register(p, white_cert_size,true);//We need to overwrite the original white list file if the file is passed + if(AE_SUCCESS!=ae_err){ + AESM_DBG_WARN("fail to register white cert list file in persistent storage"); + } + {//Always remove the file now. If it is not verified, the file has problem and remove it; otherwise, it has been saved as the AESM_WHITE_LIST_CERT_FID + char white_list_to_be_verify_path_name[MAX_PATH]; + ae_err = aesm_get_pathname(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID, white_list_to_be_verify_path_name, MAX_PATH); + if(AE_SUCCESS == ae_err){ + se_delete_tfile(white_list_to_be_verify_path_name); + } + } + free(p); + return ae_err; +} + +ae_error_t CLEClass::load_enclave_only() +{ + before_enclave_load(); + + assert(m_enclave_id==0); + sgx_status_t ret; + ae_error_t ae_err; + char prod_css_path[MAX_PATH]={0}; + char enclave_path[MAX_PATH]= {0}; + char *p_prod_css_path = prod_css_path; + int production_le_loaded = 0; + if((ae_err = aesm_get_pathname(FT_PERSISTENT_STORAGE, LE_PROD_SIG_STRUCT_FID, prod_css_path, MAX_PATH))!=AE_SUCCESS){ + AESM_DBG_WARN("fail to get production sig struction of LE"); + p_prod_css_path = NULL; + } + if((ae_err = aesm_get_pathname(FT_ENCLAVE_NAME, get_enclave_fid(), enclave_path,//get non-production signed LE pathname + MAX_PATH)) + !=AE_SUCCESS){ + AESM_DBG_ERROR("fail to get LE pathname"); + return ae_err; + } + int launch_token_update; +#ifdef AESM_SIM + UNUSED(p_prod_css_path); + UNUSED(production_le_loaded); + ret = sgx_create_enclave(enclave_path, get_debug_flag(), &m_launch_token, + &launch_token_update, &m_enclave_id, + &m_attributes);//simulation mode has no sgx_create_le function. Use sgx_create_enclave + if(ret != SGX_SUCCESS){ + AESM_DBG_ERROR("Fail to load LE"); + return AE_FAILURE; + } + return AE_SUCCESS; +#else + ret = sgx_create_le(enclave_path, p_prod_css_path, get_debug_flag(), &m_launch_token, + &launch_token_update, &m_enclave_id, + &m_attributes, &production_le_loaded); + if (ret == SGX_ERROR_NO_DEVICE){ + AESM_DBG_ERROR("AE SERVER NOT AVAILABLE in load non-production signed LE: %s",enclave_path); + return AE_SERVER_NOT_AVAILABLE; + } + if (ret != SGX_SUCCESS){ + AESM_DBG_ERROR("Loading LE failed:%d",ret); + return AE_FAILURE; + }else if(production_le_loaded!=0){//production signed LE loaded + AESM_DBG_INFO("Production signed LE loaded, try loading white list now"); + }else{ + AESM_DBG_INFO("Debug signed LE loaded"); + } + return AE_SUCCESS; +#endif +} + +ae_error_t CLEClass::load_enclave() +{ + if(m_enclave_id){//LE has been loaded before + return AE_SUCCESS; + } + ae_error_t ae_err = load_enclave_only(); + if( AE_SUCCESS == ae_err){ + load_white_cert_list(); + } + return ae_err; +} + +int CLEClass::get_launch_token( + uint8_t * mrenclave, uint32_t mrenclave_size, + uint8_t *public_key, uint32_t public_key_size, + uint8_t *se_attributes, uint32_t se_attributes_size, + uint8_t * lictoken, uint32_t lictoken_size + ) +{ + sgx_status_t ret = SGX_SUCCESS; + int retry = 0; + int status = 0; + + assert(m_enclave_id); + sgx_measurement_t mrsigner; + + if(mrenclave_size !=sizeof(sgx_measurement_t) || + SE_KEY_SIZE != public_key_size || + se_attributes_size != sizeof(sgx_attributes_t) || + lictoken_size < sizeof(token_t) ) + return LE_INVALID_PARAMETER; + //set mrsigner based on the hash of isv pub key from enclave signature + IppStatus ipperrorCode = ippStsNoErr; + ipperrorCode = ippsHashMessage(reinterpret_cast(public_key), public_key_size, reinterpret_cast(&mrsigner), IPP_ALG_HASH_SHA256); + if( ipperrorCode != ippStsNoErr){ + return AE_FAILURE; + } + +#ifdef DBG_LOG + char mrsigner_info[256]; + aesm_dbg_format_hex((uint8_t *)&mrsigner, sizeof(mrsigner), mrsigner_info, 256); + AESM_DBG_INFO("try to load Enclave with mrsigner:%s",mrsigner_info); +#endif + + //get launch token by ecall into LE + ret = le_get_launch_token_wrapper(m_enclave_id, &status, + reinterpret_cast(mrenclave), + &mrsigner, + reinterpret_cast(se_attributes), + reinterpret_cast(lictoken)); + for(; ret == SGX_ERROR_ENCLAVE_LOST && retry < AESM_RETRY_COUNT; retry++) + { + unload_enclave(); + if(AE_SUCCESS != load_enclave()) + return AE_FAILURE; + ret = le_get_launch_token_wrapper(m_enclave_id, &status, + reinterpret_cast(mrenclave), + &mrsigner, + reinterpret_cast(se_attributes), + reinterpret_cast(lictoken)); + } + + if(SGX_SUCCESS!=ret) + return sgx_error_to_ae_error(ret); + return status; +} diff --git a/psw/ae/aesm_service/source/le/LEClass.h b/psw/ae/aesm_service/source/le/LEClass.h new file mode 100644 index 0000000000..c69a6461c4 --- /dev/null +++ b/psw/ae/aesm_service/source/le/LEClass.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _LE_CLASS_H_ +#define _LE_CLASS_H_ +#include "arch.h" +#include "AEClass.h" +#include "ae_debug_flag.hh" + +class CLEClass: public SingletonEnclave +{ + friend class Singleton; + friend class SingletonEnclave; + static aesm_enclave_id_t get_enclave_fid(){return LE_ENCLAVE_FID;} +protected: + CLEClass(){}; + ~CLEClass(){}; + virtual int get_debug_flag() { return LE_DEBUG_FLAG;} + void load_white_cert_list(); + ae_error_t load_enclave_only();/*protected function to load Enclave only without loading white list*/ + ae_error_t load_verified_white_cert_list(); + ae_error_t load_white_cert_list_to_be_verify(); +public: + virtual ae_error_t load_enclave();/*overload LE load enclave function since i) we have two different LE SigStruct now, ii) we need load white list*/ + int get_launch_token( + uint8_t * mrenclave, uint32_t mrenclave_size, + uint8_t *mrsigner, uint32_t mrsigner_size, + uint8_t *se_attributes, uint32_t se_attributes_size, + uint8_t * lictoken, uint32_t lictoken_size + ); + int white_list_register( + const uint8_t *white_list_cert, + uint32_t white_list_cert_size, + bool save_to_persistent_storage=true); +}; +#endif + + diff --git a/psw/ae/aesm_service/source/network/network_encoding_wrapper.cpp b/psw/ae/aesm_service/source/network/network_encoding_wrapper.cpp new file mode 100644 index 0000000000..88ed8b874d --- /dev/null +++ b/psw/ae/aesm_service/source/network/network_encoding_wrapper.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "network_encoding_wrapper.h" +#include "oal/oal.h" +#include "aesm_encode.h" + +ae_error_t AESMNetworkEncoding::aesm_send_recv_msg(const char *url, const uint8_t * msg, uint32_t msg_size, uint8_t* &resp_msg, uint32_t& resp_size, http_methods_t type, bool is_ocsp) +{ + return ::aesm_network_send_receive(url, msg, msg_size, &resp_msg, &resp_size, type, is_ocsp); +} + +ae_error_t AESMNetworkEncoding::aesm_send_recv_msg_encoding_internal(const char *url, const uint8_t * msg, uint32_t msg_size, uint8_t* &resp, uint32_t& resp_size) +{ + resp = NULL; + resp_size = 0; + + ae_error_t ae_ret = AE_SUCCESS; + uint8_t *encode_msg = NULL; + uint32_t encoding_size = get_request_encoding_length(msg); + uint8_t *recv_msg = NULL; + uint32_t decode_buffer_size = 0; + uint32_t recv_size = 0; + if(encoding_size == 0){ + AESM_DBG_WARN("invalid msg_size 0 to send to url:%s", url); + ae_ret = AE_FAILURE; + goto ret_point; + } + encode_msg = reinterpret_cast(malloc(encoding_size)); + if(encode_msg == NULL){ + AESM_DBG_ERROR("malloc failed"); + ae_ret = AE_OUT_OF_MEMORY_ERROR; + goto ret_point; + } +#ifdef DBG_LOG + char dbg_hex_string[256]; + aesm_dbg_format_hex(msg, msg_size, dbg_hex_string, 256); + AESM_DBG_TRACE("send msg \"%s\" to server:%s",dbg_hex_string, url); +#endif + memset(encode_msg, 0, encoding_size); + if(!encode_request(msg, msg_size, encode_msg, &encoding_size)){ + AESM_DBG_ERROR("message encoding error, msg size %d",msg_size); + ae_ret = PVE_UNEXPECTED_ERROR; + goto ret_point; + } + AESM_DBG_TRACE("encoded msg %.*s",encoding_size, encode_msg); + ae_ret = aesm_network_send_receive(url, encode_msg, encoding_size, + &recv_msg, &recv_size, POST, false); + if(ae_ret != AE_SUCCESS ){ + AESM_DBG_ERROR("fail to send encoded msg (size=%d) to url:%s",encoding_size, url); + goto ret_point; + } + if(recv_msg == NULL){ + AESM_DBG_ERROR("recv NULL message from backend server"); + ae_ret = PVE_UNEXPECTED_ERROR; + goto ret_point; + } + AESM_DBG_TRACE("response msg %.*s", recv_size, recv_msg); + decode_buffer_size= get_response_decoding_length(recv_size); + + if(decode_buffer_size == 0){ + AESM_DBG_ERROR("response 0 length message from backend server:%s",url); + ae_ret = PVE_UNEXPECTED_ERROR; + goto ret_point; + } + AESM_DBG_TRACE("Succ recv msg:%.*s", recv_size, recv_msg); + + resp = reinterpret_cast(malloc(decode_buffer_size)); + if(resp == NULL){ + AESM_DBG_ERROR("malloc error"); + ae_ret = AE_OUT_OF_MEMORY_ERROR; + goto ret_point; + } + memset(resp, 0, decode_buffer_size); + if(!decode_response(recv_msg,recv_size, resp, &decode_buffer_size)){ + AESM_DBG_WARN("fail to decode message from server"); + ae_ret = PVE_MSG_ERROR; + goto ret_point; + } +#ifdef DBG_LOG + aesm_dbg_format_hex(resp, decode_buffer_size, dbg_hex_string, 256); + AESM_DBG_TRACE("succ decode msg \"%s\" ",dbg_hex_string); +#endif + resp_size = decode_buffer_size; +ret_point: + aesm_free_network_response_buffer(recv_msg); + if(ae_ret != AE_SUCCESS){ + if(resp!=NULL)free(resp); + resp = NULL; + } + if(encode_msg!=NULL)free(encode_msg); + return ae_ret; +} + + +void AESMNetworkEncoding::aesm_free_response_msg(uint8_t *resp) +{ + if(resp!=NULL){ + free(resp); + } +} + + +ae_error_t AESMNetworkEncoding::aesm_send_recv_msg_encoding(const char *url, const uint8_t * msg, uint32_t msg_size, uint8_t* &resp, uint32_t& resp_size) +{ + resp = NULL; + resp_size = 0; + AESM_DBG_TRACE("send msg to url %s",url); + //call global function to encoding message, send/receive message via HTTP POST and decode response message + return aesm_send_recv_msg_encoding_internal(url, msg, msg_size, resp, resp_size); +} + + diff --git a/psw/ae/aesm_service/source/network/network_encoding_wrapper.h b/psw/ae/aesm_service/source/network/network_encoding_wrapper.h new file mode 100644 index 0000000000..0fc68064b8 --- /dev/null +++ b/psw/ae/aesm_service/source/network/network_encoding_wrapper.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _NETWORK_WRAPPER_H_ +#define _NETWORK_WRAPPER_H_ +#include "sgx_urts.h" +#include "aesm_error.h" +#include "arch.h" +#include "aeerror.h" +#include "tlv_common.h" +#include "se_thread.h" +#include "oal/oal.h" +#include "se_wrapper.h" +#include "endpoint_select_info.h" + +/*Class for network interface inside AESM*/ +class AESMNetworkEncoding{ +protected: + static ae_error_t aesm_send_recv_msg_encoding_internal(const char *url, const uint8_t * msg, uint32_t msg_size, uint8_t* &resp_msg, uint32_t& resp_size); +public: + /*Function to send data to server via HTTP/HTTPS protocol*/ + static ae_error_t aesm_send_recv_msg(const char *url, const uint8_t * msg, uint32_t msg_size, uint8_t* &resp_msg, uint32_t& resp_size, http_methods_t type= POST, bool is_ocsp=false); + /*Function to send data to server via HTTP/HTTPS protocol but the data to be send will be HEX/BASE64 encoded and the respose message is decoded. It is used for ES/SGX/PSEPR Provisioning*/ + static ae_error_t aesm_send_recv_msg_encoding(const char *url, const uint8_t * msg, uint32_t msg_size, uint8_t* &resp_msg, uint32_t& resp_size); + static void aesm_free_response_msg(uint8_t *resp); /*Function to free the buffer of resp_msg from previous two functions*/ +}; +#endif + diff --git a/psw/ae/aesm_service/source/oal/aesm_thread.cpp b/psw/ae/aesm_service/source/oal/aesm_thread.cpp new file mode 100644 index 0000000000..85a6d110ac --- /dev/null +++ b/psw/ae/aesm_service/source/oal/aesm_thread.cpp @@ -0,0 +1,285 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "oal/aesm_thread.h" +#include +#include +#include +#include +#include "oal/internal_log.h" +#include "se_thread.h"//using se_mutex + +const uint32_t AESM_THREAD_INFINITE = 0xffffffff; // special flag to indicate that thread to be blocked + +//thread status: +// At the beginning, status is initialized to AESM_THREAD_INIT +// After the started thread has copied all input data, the status will be updated to AESM_THREAD_RUNNING (So that aesm_free_thread could be called and mainthread could quit) +// If the thread has finished before function like aesm_free_thread is called, the thread will find the status is still AESM_TRHEAD_RUNNING, +// it will update the status to AESM_THREAD_PENDING and leave the resource free to following call of aesm_free_thread +// If the thread is finished after function aesm_free_thread is called, the status should be AESM_THREAD_FREED, so that it should free the resource. +// If aesm_join_thread is called, it will wait the thread to be finished (so that it should find the status to be AESM_THREAD_PENDING when pthread_join returned +// and it will update the status to AESM_THREAD_DETACHED +// If aesm_free_thread is called before the thread has been finished, so the function find the status is AESM_THREAD_RUNNING, +// it will update the status to AESM_THREAD_FREED and leaving the memory free the aesm_thread_proc +// But when aesm_free_thread is called and it found the thread has been finished so that the status is AESM_THREAD_PENDING or AESM_THREAD_DETACHED +// the function should free all the resource. +enum _aesm_thread_status_t{AESM_THREAD_INIT, AESM_THREAD_INVALID, AESM_THREAD_RUNNING, AESM_THREAD_PENDING, AESM_THREAD_DETACHED, AESM_THREAD_FREED}; + + +struct _aesm_thread_t{ + pthread_mutex_t mutex; + pthread_cond_t copy_cond; + pthread_cond_t timeout_cond; + aesm_thread_arg_type_t arg; + aesm_thread_function_t fun_entry; + ae_error_t ae_ret; + pthread_t hthread; + volatile _aesm_thread_status_t status; +}; + +static void aesm_dealloc_resource(aesm_thread_t h) +{ + h->status = AESM_THREAD_INVALID; + pthread_cond_destroy(&h->copy_cond); + pthread_cond_destroy(&h->timeout_cond); + (void)pthread_mutex_destroy(&h->mutex); + free(h); +} + +void* aesm_thread_proc(void* param) +{ + struct _aesm_thread_t *p=(struct _aesm_thread_t *)param; + aesm_thread_function_t fun_entry = NULL; + aesm_thread_arg_type_t arg = 0; + AESM_DBG_TRACE("start running thread %p...",param); + if(pthread_mutex_lock(&p->mutex)!=0){ + AESM_DBG_ERROR("fail to lock the thread mutex of thread %p",param); + return reinterpret_cast(static_cast(AE_FAILURE)); + } + fun_entry = p->fun_entry; + arg = p->arg; + p->status = AESM_THREAD_RUNNING; + p->ae_ret = AE_FAILURE; + pthread_cond_signal(&p->copy_cond);//notify mainthread that input parameter data has been copied to thread and we could release it(if aesm_thread_free has been called) + pthread_mutex_unlock(&p->mutex); + AESM_DBG_TRACE("thread parameters of thread %p copied",param); + ae_error_t err = fun_entry(arg); + AESM_DBG_TRACE("returned from user defined thread code for thread %p",param); + pthread_mutex_lock(&p->mutex); + p->ae_ret = err; + if(p->status == AESM_THREAD_RUNNING){ + p->status = AESM_THREAD_PENDING; + pthread_cond_signal(&p->timeout_cond); + pthread_mutex_unlock(&p->mutex); + AESM_DBG_TRACE("thread %p change to status AESM_THREAD_PEDNING",param); + }else if(p->status == AESM_THREAD_FREED){ + pthread_mutex_unlock(&p->mutex); + pthread_detach(p->hthread); + aesm_dealloc_resource(p); + AESM_DBG_TRACE("resource of thread %p has been dealloced",param); + }else{ + p->status = AESM_THREAD_INVALID;//It should never be reached + pthread_mutex_unlock(&p->mutex); + AESM_DBG_TRACE("thread %p status invalid",param); + assert(0); + } + return reinterpret_cast(static_cast(err)); +} + +ae_error_t aesm_create_thread(aesm_thread_function_t function_entry, aesm_thread_arg_type_t arg, aesm_thread_t* h) +{ + ae_error_t err = AE_SUCCESS; + int r=0; + int mutex_inited = 0; + int copy_cond_inited = 0; + int timeout_cond_inited = 0; + assert(h!=NULL); + AESM_DBG_TRACE("start to create a thread"); + struct _aesm_thread_t *p=(struct _aesm_thread_t *)malloc(sizeof(struct _aesm_thread_t)); + if(p==NULL){ + AESM_DBG_ERROR("fail to malloc"); + err = AE_OUT_OF_MEMORY_ERROR; + goto ret_point; + } + memset(p, 0, sizeof(struct _aesm_thread_t)); + p->arg = arg; + p->fun_entry = function_entry; + if(pthread_mutex_init(&p->mutex, NULL)!=0){ + err = AE_FAILURE; + AESM_DBG_ERROR("fail to init mutex"); + goto ret_point; + } + mutex_inited=1; + if(pthread_cond_init(&p->copy_cond, NULL)!=0){ + err = AE_FAILURE; + AESM_DBG_ERROR("fail to init copy cond"); + goto ret_point; + } + copy_cond_inited=1; + if(pthread_cond_init(&p->timeout_cond, NULL)!=0){ + err = AE_FAILURE; + AESM_DBG_ERROR("fail to init timeout cond"); + goto ret_point; + } + timeout_cond_inited=1; + p->status = AESM_THREAD_INIT; + r=pthread_create(&p->hthread, NULL, aesm_thread_proc, p); + if(r!=0){ + AESM_DBG_ERROR("fail to create thread"); + err = OAL_THREAD_ERROR; + goto ret_point; + } + *h = p; + AESM_DBG_TRACE("thread %p created successfully",p); +ret_point: + if(err!=AE_SUCCESS&&p!=NULL){ + if(mutex_inited!=0){ + (void)pthread_mutex_destroy(&p->mutex); + } + if(copy_cond_inited!=0){ + (void)pthread_cond_destroy(&p->copy_cond); + } + if(timeout_cond_inited!=0){ + (void)pthread_cond_destroy(&p->timeout_cond); + } + free(p); + } + return err; +} + +ae_error_t aesm_join_thread(aesm_thread_t h, ae_error_t *thread_ret) +{ + void *ret_value; + AESM_DBG_TRACE("start to join thread %p",h); + if(0!=pthread_join(h->hthread, &ret_value)){ + AESM_DBG_ERROR("fail to join thread %p",h); + return OAL_THREAD_ERROR; + } + if(pthread_mutex_lock(&h->mutex)!=0){ + AESM_DBG_ERROR("fail to lock thread %p",h); + return AE_FAILURE; + } + if(h->status != AESM_THREAD_PENDING){ + AESM_DBG_ERROR("thread %p status error %d in join",h,h->status); + h->status = AESM_THREAD_INVALID;//invalid + pthread_mutex_unlock(&h->mutex); + assert(0); + return OAL_THREAD_ERROR; + } + h->status = AESM_THREAD_DETACHED;//no call to pthread_detach after pthread_join + pthread_mutex_unlock(&h->mutex); + *thread_ret = static_cast(reinterpret_cast(ret_value)); + AESM_DBG_TRACE("thread %p join successfully with return value %d",h,*thread_ret); + return AE_SUCCESS; +} + +ae_error_t aesm_free_thread(aesm_thread_t h) +{ + AESM_DBG_TRACE("start to free thread %p",h); + if(pthread_mutex_lock(&h->mutex)!=0){ + AESM_DBG_ERROR("fail to lock thread %p",h); + return AE_FAILURE; + } + if(h->status == AESM_THREAD_INIT){//wait for parameters copy to be finished in thread_proc + AESM_DBG_TRACE("wait for parameter copy in thread %p",h); + (void)pthread_cond_wait(&h->copy_cond, &h->mutex);//ignore the waiting error, we will continue to free the thread info even if waiting failed anyway + //The h->status should have been updated if the waiting of copy_cond is finished + } + if(h->status == AESM_THREAD_RUNNING){ + h->status = AESM_THREAD_FREED; + }else if(h->status == AESM_THREAD_PENDING){ + h->status = AESM_THREAD_DETACHED; + pthread_detach(h->hthread); + AESM_DBG_TRACE("thread %p detached",h); + } + if(h->status == AESM_THREAD_DETACHED){ + pthread_mutex_unlock(&h->mutex); + aesm_dealloc_resource(h); + AESM_DBG_TRACE("thread %p resource dealloced",h); + return AE_SUCCESS; + }else if(h->status != AESM_THREAD_FREED){ + pthread_mutex_unlock(&h->mutex); + AESM_DBG_ERROR("thread %p status error %d",h,h->status); + aesm_dealloc_resource(h);//dealloc anyway + assert(0); + return OAL_THREAD_ERROR; + }else{ + pthread_mutex_unlock(&h->mutex); + AESM_DBG_TRACE("thread %p marked to be free",h); + return AE_SUCCESS; + } +} + + +ae_error_t aesm_wait_thread(aesm_thread_t h, ae_error_t *thread_ret, unsigned long milisecond) +{ + AESM_DBG_TRACE("start to wait thread %p for %d ms",h,milisecond); + pthread_mutex_lock(&h->mutex); + if(h->status==AESM_THREAD_PENDING||h->status==AESM_THREAD_DETACHED){//if the thread has been finished + pthread_mutex_unlock(&h->mutex); + AESM_DBG_TRACE("thread %p is pending",h); + return AE_SUCCESS; + }else if(h->status!=AESM_THREAD_INIT&&h->status!=AESM_THREAD_RUNNING){ + pthread_mutex_unlock(&h->mutex); + AESM_DBG_ERROR("invalid thread status %d for thread %p",h->status,h); + return OAL_THREAD_ERROR; + } + struct timespec abstime; + clock_gettime(CLOCK_REALTIME, &abstime); + abstime.tv_sec += milisecond/1000 + (abstime.tv_nsec/1000000+milisecond%1000)/1000; + abstime.tv_nsec = (abstime.tv_nsec/1000000+milisecond%1000)%1000 *1000000 + abstime.tv_nsec%1000000; + + + + int err_no; + err_no = pthread_cond_timedwait(&h->timeout_cond , &h->mutex , &abstime); + if(err_no == ETIMEDOUT) + { + pthread_mutex_unlock(&h->mutex); + AESM_DBG_TRACE("thread %p waiting timeout",h); + return OAL_THREAD_TIMEOUT_ERROR; + } + else if(err_no == 0) + { + *thread_ret = h->ae_ret; + pthread_mutex_unlock(&h->mutex); + AESM_DBG_TRACE("thread %p is detached with return value %d",h,*thread_ret); + return AE_SUCCESS; + } + else + { + pthread_mutex_unlock(&h->mutex); + AESM_DBG_ERROR("thread wait error in thread %p",h); + return OAL_THREAD_ERROR; + } +} diff --git a/psw/ae/aesm_service/source/oal/aesm_util.cpp b/psw/ae/aesm_service/source/oal/aesm_util.cpp new file mode 100644 index 0000000000..d50b6ffb36 --- /dev/null +++ b/psw/ae/aesm_service/source/oal/aesm_util.cpp @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +//#include "memset_s.h" +#include "persistent_storage_info.h" +#include "oal/aesm_persistent_storage.h" +#include "internal/se_stdio.h" +#include +#include +#include +#include +#include + + +static ae_error_t aesm_get_path( + const char *p_file_name, + char *p_file_path, + size_t buf_size) +{ + if(!p_file_name || !p_file_path) + return OAL_PARAMETER_ERROR; + + Dl_info dl_info; + if(0==dladdr(__builtin_return_address(0), &dl_info)|| + NULL==dl_info.dli_fname) + return AE_FAILURE; + if(strlen(dl_info.dli_fname)>buf_size-1) + return OAL_PATHNAME_BUFFER_OVERFLOW_ERROR; + strncpy(p_file_path,dl_info.dli_fname,buf_size); + char* p_last_slash = strrchr(p_file_path, '/' ); + if ( p_last_slash != NULL ) + { + p_last_slash++; //increment beyond the last slash + *p_last_slash = '\0'; //null terminate the string + } + else p_file_path[0] = '\0'; + if(strlen(p_file_path)+strlen(p_file_name)+sizeof(char)>buf_size) + return OAL_PATHNAME_BUFFER_OVERFLOW_ERROR; + strncat(p_file_path,p_file_name, strlen(p_file_name)); + return AE_SUCCESS; +} + +#define AESM_DATA_FOLDER "/var/opt/aesmd/data/" +static ae_error_t aesm_get_data_path( + const char *p_file_name, + char *p_file_path, + size_t buf_size) +{ + if(!p_file_name || !p_file_path) + return OAL_PARAMETER_ERROR; + + if(strlen(AESM_DATA_FOLDER)+strlen(p_file_name)+sizeof(char)>buf_size) + return OAL_PATHNAME_BUFFER_OVERFLOW_ERROR; + strcpy(p_file_path, AESM_DATA_FOLDER); + strncat(p_file_path,p_file_name, strlen(p_file_name)); + return AE_SUCCESS; +} + +static ae_error_t aesm_write_file( + const uint8_t *p_buf, + uint32_t buf_size, + char *p_file_name, + bool is_full_path) +{ + ae_error_t ret = AE_FAILURE; + uint32_t write_length = 0; + FILE* p_file = NULL; + char p_full_path[MAX_PATH]= {0}; + if(is_full_path){ + if(strlen(p_file_name)>MAX_PATH-1){ + ret = OAL_PATHNAME_BUFFER_OVERFLOW_ERROR; + goto CLEANUP; + } + strcpy(p_full_path, p_file_name); + }else{ + if((ret=aesm_get_data_path(p_file_name, p_full_path, MAX_PATH)) != AE_SUCCESS) + goto CLEANUP; + } + if(NULL == (p_file = fopen(p_full_path, "wb"))){ + ret = OAL_FILE_ACCESS_ERROR; + goto CLEANUP; + } + + write_length = (uint32_t)fwrite(p_buf, 1, buf_size, p_file); + if(buf_size != write_length){ + ret = OAL_FILE_ACCESS_ERROR; + goto CLEANUP; + } + ret = AE_SUCCESS; + +CLEANUP: + if(p_file) + fclose(p_file); + return ret; +} + +static ae_error_t aesm_read_file( + uint8_t *p_buf, + uint32_t& buf_size, + char *p_file_name, + bool is_full_path) +{ + ae_error_t ret = AE_FAILURE; + FILE* p_file = NULL; + char p_full_path[MAX_PATH]= {0}; + if(is_full_path){ + if(strlen(p_file_name)>MAX_PATH-1){ + ret = OAL_PATHNAME_BUFFER_OVERFLOW_ERROR; + goto CLEANUP; + } + strcpy(p_full_path, p_file_name); + }else{ + if((ret=aesm_get_data_path(p_file_name, p_full_path, MAX_PATH)) != AE_SUCCESS) + goto CLEANUP; + } + if(NULL == (p_file = fopen(p_full_path, "rb"))){ + ret = OAL_FILE_ACCESS_ERROR; + goto CLEANUP; + } + + buf_size = (uint32_t)fread(p_buf, 1, buf_size, p_file); + ret = AE_SUCCESS; + +CLEANUP: + if(p_file) + fclose(p_file); + return ret; +} + +ae_error_t aesm_get_pathname(aesm_data_type_t type, aesm_data_id_t id, char *buf, uint32_t buf_size) +{ + const persistent_storage_info_t *info = get_persistent_storage_info(id); + if(info == NULL) + return OAL_PARAMETER_ERROR; + if(info->type != type) + return OAL_PARAMETER_ERROR; + if(info->type == FT_ENCLAVE_NAME){ + char local_info_name[MAX_PATH]; + sprintf(local_info_name,"libsgx_%s.signed.so",info->name); + return aesm_get_path(local_info_name, buf, buf_size); + }else if(info->loc == AESM_LOCATION_DATA){ + return aesm_get_data_path(info->name, buf, buf_size); + }else{//info->loc == AESM_LOCATION_EXE_FOLDER + return aesm_get_path(info->name, buf, buf_size); + } +} + +//alias function for aesm_get_pathname +ae_error_t aesm_get_cpathname(aesm_data_type_t type, aesm_data_id_t id, char *buf, uint32_t buf_size) +{ + return aesm_get_pathname(type, id, buf, buf_size); +} + +ae_error_t aesm_query_data_size(aesm_data_type_t type, aesm_data_id_t data_id, uint32_t *p_size) +{ + char pathname[MAX_PATH]; + ae_error_t ret = AE_SUCCESS; + + const persistent_storage_info_t *info = get_persistent_storage_info(data_id); + if(info == NULL) + return OAL_PARAMETER_ERROR; + if(info->access == AESM_FILE_ACCESS_PATH_ONLY) + return OAL_PARAMETER_ERROR; + + ret = aesm_get_pathname(type, data_id, pathname, MAX_PATH); + if(ret != AE_SUCCESS) + return ret; + + struct stat stat_info; + + if(stat(pathname, &stat_info)!=0){//Maybe file has not been created + *p_size = 0; + return AE_SUCCESS; + } + *p_size = (uint32_t)stat_info.st_size; + return AE_SUCCESS; +} + +ae_error_t aesm_read_data(aesm_data_type_t type, aesm_data_id_t data_id, uint8_t *buf, uint32_t *p_size) +{ + char pathname[MAX_PATH]; + ae_error_t ret = AE_SUCCESS; + const persistent_storage_info_t *info = get_persistent_storage_info(data_id); + if(info == NULL) + return OAL_PARAMETER_ERROR; + if(info->access == AESM_FILE_ACCESS_PATH_ONLY) + return OAL_PARAMETER_ERROR; + ret = aesm_get_pathname(type, data_id, pathname, MAX_PATH); + if(ret != AE_SUCCESS) + return ret; + + if((ret=aesm_read_file(buf, *p_size, pathname, true))!=AE_SUCCESS) + return ret; + return AE_SUCCESS; +} + +ae_error_t aesm_write_data(aesm_data_type_t type, aesm_data_id_t data_id, const uint8_t *buf, uint32_t size) +{ + char pathname[MAX_PATH]; + ae_error_t ret = AE_SUCCESS; + + const persistent_storage_info_t *info = get_persistent_storage_info(data_id); + if(info == NULL) + return OAL_PARAMETER_ERROR; + if(info->access != AESM_FILE_ACCESS_ALL) + return OAL_PARAMETER_ERROR; + + ret = aesm_get_pathname(type, data_id, pathname, MAX_PATH); + if(ret != AE_SUCCESS) + return ret; + if((ret=aesm_write_file(buf, size, pathname, true))!=AE_SUCCESS) + return ret; + return AE_SUCCESS; +} + diff --git a/psw/ae/aesm_service/source/oal/error_report.cpp b/psw/ae/aesm_service/source/oal/error_report.cpp new file mode 100644 index 0000000000..aa230adb8a --- /dev/null +++ b/psw/ae/aesm_service/source/oal/error_report.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include "oal/error_report.h" + +void aesm_log_init(void) +{ + openlog("aesm_service", LOG_CONS|LOG_PID, LOG_USER); +} + +void aesm_log_fini(void) +{ + closelog(); +} + +void aesm_log_report(int level, const char *format, ...) +{ + int priority = 0; + va_list ap; + va_start(ap, format); + switch(level){ + case AESM_LOG_REPORT_FATAL: + priority = LOG_CRIT; + break; + case AESM_LOG_REPORT_ERROR: + priority = LOG_ERR; + break; + case AESM_LOG_REPORT_WARNING: + priority = LOG_WARNING; + break; + default: + return;//ignore + } + vsyslog(priority, format, ap); + va_end(ap); +} + diff --git a/psw/ae/aesm_service/source/oal/internal_log.cpp b/psw/ae/aesm_service/source/oal/internal_log.cpp new file mode 100644 index 0000000000..4a692e3352 --- /dev/null +++ b/psw/ae/aesm_service/source/oal/internal_log.cpp @@ -0,0 +1,232 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifdef DBG_LOG +#include "oal/oal.h" +#include "se_wrapper.h" +#include "se_stdio.h" +#include +#include +#include +#include +#include "se_thread.h" +static int aesm_trace_level = TRACE_LOG_LEVEL; +static int at_start=1; + +ae_error_t load_log_config(void); +se_mutex_t cs; +static ae_error_t init_log_file(void) +{ + char filename[MAX_PATH]; + ae_error_t err = aesm_get_pathname(FT_PERSISTENT_STORAGE, AESM_DBG_LOG_FID, filename, MAX_PATH); + if(err != AE_SUCCESS) + return err; + (void)load_log_config(); + return AE_SUCCESS; +} + +#define TIME_BUF_SIZE 100 +void aesm_internal_log(const char *file_name, int line_no, const char *funname, int level, const char *format, ...) +{ + if(level <= aesm_trace_level){ + if(at_start){ + at_start=0; + se_mutex_init(&cs); + init_log_file(); + } + char filename[MAX_PATH]; + ae_error_t err = aesm_get_cpathname(FT_PERSISTENT_STORAGE, AESM_DBG_LOG_FID, filename, MAX_PATH); + if(err != AE_SUCCESS) + return; + FILE *logfile = NULL; + se_mutex_lock(&cs); + errno_t err_code = fopen_s(&logfile, filename, "a+"); + if(err_code!=0){ + se_mutex_unlock(&cs); + return; + } + time_t t; + struct tm time_info; + va_list varg; + char time_buf[TIME_BUF_SIZE]; + time(&t); + struct tm *temp_time_info; + temp_time_info = localtime(&t); + memcpy_s(&time_info, sizeof(time_info), temp_time_info, sizeof(*temp_time_info)); + if(strftime(time_buf, TIME_BUF_SIZE, "%c", &time_info)!=0){ + fprintf(logfile, "[%s|%d|%s|%s]",file_name, line_no, funname, time_buf); + }else{ + fprintf(logfile, "[%s|%d|%s]",file_name, line_no, funname); + } + va_start(varg, format); + vfprintf(logfile, format, varg); + va_end(varg); + fprintf(logfile, "\n"); + fflush(logfile); + fclose(logfile); + se_mutex_unlock(&cs); + } +} + + +void aesm_set_log_level(int level) +{ + aesm_trace_level = level; +} + +static char half_byte_to_char(int x) +{ + assert(0<=x&&x<=0xF); + if(0<=x&&x<=9)return (char)('0'+x); + else return (char)('A'+x-10); +} + +void aesm_dbg_format_hex(const uint8_t *data, uint32_t data_len, char *out_buf, uint32_t buf_size) +{ + uint32_t i; + assert(buf_size>0); + if(data_len==0){ + out_buf[0]='\0'; + return; + } + if(buf_size/3>=data_len){ + for(i=0;i>4)&0xF; + out_buf[i*3]=half_byte_to_char(high); + out_buf[i*3+1]=half_byte_to_char(low); + out_buf[i*3+2]=' '; + } + out_buf[data_len*3-1]='\0'; + }else if(buf_size>10){ + uint32_t tcount=buf_size/3-1; + uint32_t off; + uint32_t ecount=tcount/2,bcount=tcount-ecount; + for(i=0;i>4)&0xF; + out_buf[i*3]=half_byte_to_char(high); + out_buf[i*3+1]=half_byte_to_char(low); + out_buf[i*3+2]=' '; + } + out_buf[i*3]=out_buf[i*3+1]=out_buf[i*3+2]='.'; + off=i*3+3; + for(i=0;i>4)&0xF; + out_buf[off+i*3]=half_byte_to_char(high); + out_buf[off+i*3+1]=half_byte_to_char(low); + out_buf[off+i*3+2]=' '; + } + out_buf[off+i*3-1]='\0'; + }else{ + for(i=0;/*i>4)&0xF; + out_buf[i*3]=half_byte_to_char(high); + out_buf[i*3+1]=half_byte_to_char(low); + out_buf[i*3+2]=' '; + } + out_buf[i*3]='\0'; + } +} + +#include "tinyxml.h" + +static const char *xml_get_child_text(TiXmlNode *parent, const char *name) +{ + if(parent == NULL) return NULL; + TiXmlNode *sub_node = parent->FirstChild(name); + if(sub_node == NULL) return NULL; + TiXmlElement *elem = sub_node->ToElement(); + if(elem == NULL) return NULL; + return elem->GetText(); +} + +static const char *dbg_level_str[]={ + "fatal", + "error", + "warning", + "info", + "debug", + "trace" +}; +#define DBG_LEVEL_COUNT (sizeof(dbg_level_str)/sizeof(dbg_level_str[0])) +static int find_dbg_level_str(const char *text_level) +{ + uint32_t i; + size_t text_level_len = strlen(text_level); + for(i=0;itext_level_len)cur_len=text_level_len; + if(_strnicmp(text_level, dbg_level_str[i], cur_len)==0){ + return (int)i; + } + } + AESM_DBG_ERROR("unkown level %s",text_level); + return -1; +} + +ae_error_t load_log_config(void) +{ + char path_name[MAX_PATH]; + ae_error_t ae_err = AE_SUCCESS; + if((ae_err=aesm_get_cpathname(FT_PERSISTENT_STORAGE, AESM_DBG_LOG_CFG_FID, path_name, MAX_PATH))!=AE_SUCCESS){ + AESM_DBG_ERROR("fail to read config path"); + return ae_err; + } + + TiXmlDocument doc(path_name); + bool load_ok = doc.LoadFile(); + if(!load_ok){ + AESM_DBG_ERROR("fail to load config file %s", path_name); + return OAL_FILE_ACCESS_ERROR; + } + TiXmlNode *pmetadata_node = doc.FirstChild("DbgLog"); + const char *temp_text = xml_get_child_text(pmetadata_node, "level"); + if(temp_text!=NULL){ + if(isdigit(temp_text[0])){ + AESM_SET_DBG_LEVEL(atoi(temp_text)); + }else{ + int level = find_dbg_level_str(temp_text); + if(level>=0){ + AESM_SET_DBG_LEVEL(level); + } + } + }else{ + AESM_DBG_ERROR("fail to find level"); + } + return AE_SUCCESS; +} + +#endif + diff --git a/psw/ae/aesm_service/source/oal/oal_power.cpp b/psw/ae/aesm_service/source/oal/oal_power.cpp new file mode 100644 index 0000000000..74df14cd2f --- /dev/null +++ b/psw/ae/aesm_service/source/oal/oal_power.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +ae_error_t aesm_start_request_wake_execution() +{ + return AE_SUCCESS; +} + +ae_error_t aesm_stop_request_wake_execution() +{ + return AE_SUCCESS; +} + diff --git a/psw/ae/aesm_service/source/protobuf/Makefile b/psw/ae/aesm_service/source/protobuf/Makefile new file mode 100644 index 0000000000..ef629ad97e --- /dev/null +++ b/psw/ae/aesm_service/source/protobuf/Makefile @@ -0,0 +1,54 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR = $(shell pwd)/../../../../.. +include $(TOP_DIR)/buildenv.mk + +RPC_PROTP_DIR = $(TOP_DIR)/psw/ae/common/proto/ + +RPC_PROTO = messages.proto +RPC_PB_H = messages.pb.h +RPC_PB_C = messages.pb.cc + +PROTOC = protoc + +all: $(RPC_PB_C) + +$(RPC_PROTO): + cp $(RPC_PROTP_DIR)$(RPC_PROTO) . + +$(RPC_PB_C): $(RPC_PROTO) + $(PROTOC) $^ --cpp_out=. + +CLEANFILES = $(RPC_PB_H) $(RPC_PB_C) $(RPC_PROTO) + +clean: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) diff --git a/psw/ae/aesm_service/source/pve/PVEClass.cpp b/psw/ae/aesm_service/source/pve/PVEClass.cpp new file mode 100644 index 0000000000..4ba432e15b --- /dev/null +++ b/psw/ae/aesm_service/source/pve/PVEClass.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include "PVEClass.h" +#include "QEClass.h" +#include "util.h" +#include "prof_fun.h" +#include "sgx_report.h" +#include "sgx_tseal.h" +#include "epid_pve_type.h" +#include "provision_enclave_u.h" +#include "provision_enclave_u.c" + +void CPVEClass::before_enclave_load() { + // always unload qe enclave before loading pve enclave + CQEClass::instance().unload_enclave(); +} + +uint32_t CPVEClass::gen_prov_msg1_data( + const psvn_t* psvn, + const signed_pek_t *pek, + bool performance_rekey_used, + prov_msg1_output_t* output) +{ + uint32_t ret = AE_SUCCESS; + sgx_status_t status = SGX_SUCCESS; + AESM_PROFILE_FUN; + if(m_enclave_id==0){ + AESM_DBG_ERROR("call gen_prov_msg1_data without loading PvE"); + return AE_FAILURE; + } + + status = gen_prov_msg1_data_wrapper( + m_enclave_id, &ret, + psvn, + pek, + performance_rekey_used?1:0, + output); + if(status == SGX_ERROR_ENCLAVE_LOST) + ret = AE_ENCLAVE_LOST; + else if(status != SGX_SUCCESS) + ret = AE_FAILURE; + return ret; +} + +uint32_t CPVEClass::get_ek2( + const prov_get_ek2_input_t* input, + prov_get_ek2_output_t* ek2) +{ + uint32_t ret = AE_SUCCESS; + sgx_status_t status = SGX_SUCCESS; + AESM_PROFILE_FUN; + if(m_enclave_id==0){ + AESM_DBG_ERROR("call get_ek2 without loading PvE"); + return AE_FAILURE; + } + + status = get_ek2_wrapper( + m_enclave_id, &ret, + input, + ek2); + if(status == SGX_ERROR_ENCLAVE_LOST) + ret = AE_ENCLAVE_LOST; + else if(status != SGX_SUCCESS) + ret = AE_FAILURE; + return ret; +} + +uint32_t CPVEClass::proc_prov_msg2_data( + const proc_prov_msg2_blob_input_t* input, + const uint8_t* sigrl, + uint32_t sigrl_size, + gen_prov_msg3_output_t* msg3_fixed_output, + uint8_t* epid_sig, + uint32_t epid_sig_buffer_size) +{ + uint32_t ret = AE_SUCCESS; + sgx_status_t status = SGX_SUCCESS; + AESM_PROFILE_FUN; + if(m_enclave_id==0){ + AESM_DBG_ERROR("call proc_prov_msg2_data without loading PvE"); + return AE_FAILURE; + } + + status = proc_prov_msg2_data_wrapper( + m_enclave_id, &ret, + input, + sigrl, sigrl_size, + msg3_fixed_output, + epid_sig, epid_sig_buffer_size); + if(status == SGX_ERROR_ENCLAVE_LOST) + ret = AE_ENCLAVE_LOST; + else if(status != SGX_SUCCESS) + ret = AE_FAILURE; + return ret; +} + +uint32_t CPVEClass::proc_prov_msg4_data( + const proc_prov_msg4_input_t* msg4_input, + proc_prov_msg4_output_t* data_blob) +{ + uint32_t ret = AE_SUCCESS; + sgx_status_t status = SGX_SUCCESS; + AESM_PROFILE_FUN; + if(m_enclave_id==0){ + AESM_DBG_ERROR("call proc_prov_msg4_data without loading PvE"); + return AE_FAILURE; + } + + status = proc_prov_msg4_data_wrapper( + m_enclave_id, &ret, + msg4_input, + data_blob); + if(status == SGX_ERROR_ENCLAVE_LOST) + ret = AE_ENCLAVE_LOST; + else if(status != SGX_SUCCESS) + ret = AE_FAILURE; + return ret; +} + +uint32_t CPVEClass::gen_es_msg1_data( + gen_endpoint_selection_output_t* es_output) +{ + uint32_t ret = AE_SUCCESS; + sgx_status_t status = SGX_SUCCESS; + AESM_PROFILE_FUN; + if(m_enclave_id==0){ + AESM_DBG_ERROR("call gen_es_msg1_data without loading PvE"); + return AE_FAILURE; + } + + status = gen_es_msg1_data_wrapper( + m_enclave_id, &ret, + es_output); + if(status == SGX_ERROR_ENCLAVE_LOST) + ret = AE_ENCLAVE_LOST; + else if(status != SGX_SUCCESS) + ret = AE_FAILURE; + return ret; +} + + diff --git a/psw/ae/aesm_service/source/pve/PVEClass.h b/psw/ae/aesm_service/source/pve/PVEClass.h new file mode 100644 index 0000000000..3ea1a828c9 --- /dev/null +++ b/psw/ae/aesm_service/source/pve/PVEClass.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PVE_CLASS_H_ +#define _PVE_CLASS_H_ +#include "AEClass.h" +#include "aeerror.h" +#include "provision_msg.h" +#include "ae_debug_flag.hh" + +class CPVEClass: public SingletonEnclave +{ + friend class Singleton; + friend class SingletonEnclave; + static aesm_enclave_id_t get_enclave_fid(){return PVE_ENCLAVE_FID;} +protected: + CPVEClass(){}; + ~CPVEClass(){}; + virtual void before_enclave_load(); + virtual int get_debug_flag() { return AE_DEBUG_FLAG;} + + uint32_t gen_prov_msg1_data( + const psvn_t* psvn, + const signed_pek_t *pek, + bool performance_rekey_used, + prov_msg1_output_t* output); + + uint32_t get_ek2( + const prov_get_ek2_input_t* input, + prov_get_ek2_output_t* ek2); + + uint32_t proc_prov_msg2_data( + const proc_prov_msg2_blob_input_t* input, + const uint8_t* sigrl, + uint32_t sigrl_size, + gen_prov_msg3_output_t* msg3_fixed_output, + uint8_t* epid_sig, + uint32_t epid_sig_buffer_size); + + uint32_t proc_prov_msg4_data( + const proc_prov_msg4_input_t* msg4_input, + proc_prov_msg4_output_t* data_blob); + +public: + uint32_t gen_es_msg1_data( + gen_endpoint_selection_output_t* es_output); + + uint32_t gen_prov_msg1( + const psvn_t* psvn, + const signed_pek_t& pek, + bool performance_rekey_used, + uint8_t* msg1, + uint32_t msg1_size); + + uint32_t proc_prov_msg2( + const uint8_t* msg2, + uint32_t msg2_size, + const signed_pek_t& pek, + const uint8_t* epid_blob, + uint32_t blob_size, + uint8_t ek2[SK_SIZE], + psvn_t* sigrl_svn, + uint8_t* msg3, + uint32_t msg3_size); + + uint32_t proc_prov_msg4( + bool use_ek2_in_input, + const uint8_t ek2[SK_SIZE], + const uint8_t* msg4, + uint32_t msg4_size, + uint8_t* data_blob, + uint32_t blob_size); + + uint32_t gen_es_msg1( + uint8_t *msg, + uint32_t msg_size, + const gen_endpoint_selection_output_t& es1_output); + + uint32_t proc_es_msg2( + const uint8_t *msg, + uint32_t msg_size, + char server_url[MAX_PATH], + uint16_t& ttl, + const uint8_t xid[XID_SIZE], + uint8_t rsa_signature[PVE_RSA_KEY_BYTES], + signed_pek_t& pek); +}; +#endif + diff --git a/psw/ae/aesm_service/source/pve/prov_msg_size.h b/psw/ae/aesm_service/source/pve/prov_msg_size.h new file mode 100644 index 0000000000..ebf7a737e1 --- /dev/null +++ b/psw/ae/aesm_service/source/pve/prov_msg_size.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _PROV_MSG_SIZE_H_ +#define _PROV_MSG_SIZE_H_ + +#include "type_length_value.h" + +/*Inline functions to estimate size of ProvMsg1, ProvMsg3 etc*/ + +/*Function to estimate the size of ProvMsg1 + TLV_CIPHER_TEXT(SK, PSID): E+MAC(Device_ID_TLV[:FLAG_TLV])*/ +inline uint32_t estimate_msg1_size(bool performance_rekey) +{ + size_t field0_size = CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES); + size_t field1_0_size = DEVICE_ID_TLV_SIZE(); + size_t field1_1_size = performance_rekey? FLAGS_TLV_SIZE():0; + size_t field1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(field1_0_size+field1_1_size); + size_t field2_size = MAC_TLV_SIZE(MAC_SIZE); + return static_cast(PROVISION_REQUEST_HEADER_SIZE+field0_size+field1_size+field2_size); /*no checking for integer overflow since the size of msg1 is fixed and small*/ +} + +/*Function to estimate the size of ProvMsg3 + NONCE_TLV(NONCE_SIZE):E+MAC(E+MAC(EPID_JOIN_PROOF_TLV):E+MAC(EPID_SIGNATURE_TLV))*/ +inline uint32_t calc_msg3_size_by_sigrl_count(uint32_t sigrl_count) +{ + size_t field0_size = NONCE_TLV_SIZE(NONCE_SIZE); + size_t field1_0_size = BLOCK_CIPHER_TEXT_TLV_SIZE(EPID_JOIN_PROOF_TLV_SIZE()); + size_t field1_1_size = MAC_TLV_SIZE(MAC_SIZE); + size_t field3_0_size = EPID_SIGNATURE_TLV_SIZE(sigrl_count); + size_t field1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(field1_0_size+field1_1_size); + size_t field2_size = MAC_TLV_SIZE(MAC_SIZE); + size_t field3_size = BLOCK_CIPHER_TEXT_TLV_SIZE(field3_0_size); + size_t field4_size = MAC_TLV_SIZE(MAC_SIZE); + return static_cast(PROVISION_REQUEST_HEADER_SIZE+field0_size+field1_size+field2_size+field3_size+field4_size); +} + +/*Function to estimate the count of SigRL Entry inside a ProvMsg2 + Nonce_TLV(NONCE_SIZE):E+MAC(PubGroupCert:ChallengeNonce[:SigrlPSVN]:PSID:E+MAC(TCB_KEY):deviceID)[:signed SigRL]*/ +inline uint32_t estimate_sigrl_count_by_msg2_size(uint32_t msg2_size) +{ + size_t field_0_size = NONCE_TLV_SIZE(NONCE_SIZE); + size_t field_1_0_size = EPID_GROUP_CERT_TLV_SIZE(); + size_t field_1_1_size = NONCE_TLV_SIZE(CHALLENGE_NONCE_SIZE); + size_t field_1_2_size = EPID_SIGRL_PSVN_TLV_SIZE(); /*It is always present if sigrl entry count is nonzero*/ + size_t field_1_3_size = PSID_TLV_SIZE(); + size_t field_1_4_size = BLOCK_CIPHER_TEXT_TLV_SIZE(SK_SIZE); + size_t field_1_5_size = MAC_TLV_SIZE(MAC_SIZE); + size_t field_1_6_size = DEVICE_ID_TLV_SIZE(); + size_t field_1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(field_1_0_size+field_1_1_size+field_1_2_size + + field_1_3_size + field_1_4_size + field_1_5_size + field_1_6_size); + size_t field_2_size = MAC_TLV_SIZE(MAC_SIZE); + size_t field_3_size = 0; + if(PROVISION_RESPONSE_HEADER_SIZE+field_0_size+field_1_size+field_2_size>=msg2_size) + return 0; + field_3_size = msg2_size - (PROVISION_RESPONSE_HEADER_SIZE+field_0_size+field_1_size+field_2_size); + if(field_3_size < ECDSA_SIGN_SIZE*2 +sizeof(SigRL)) + return 0; + field_3_size -= ECDSA_SIGN_SIZE*2 + sizeof(SigRL); + /*The first SigRLEntry has been included into SigRL structure so that an extra 1 is added*/ + return static_cast(1+field_3_size/sizeof(SigRLEntry)); +} + +inline uint32_t estimate_msg3_size_by_msg2_size(uint32_t msg2_size) +{ + return calc_msg3_size_by_sigrl_count(estimate_sigrl_count_by_msg2_size(msg2_size)); +} + +inline uint32_t estimate_es_msg1_size(void) +{ + return static_cast(PROVISION_REQUEST_HEADER_SIZE+ES_SELECTOR_TLV_SIZE()); +} +#endif + diff --git a/psw/ae/aesm_service/source/pve/pve_logic.cpp b/psw/ae/aesm_service/source/pve/pve_logic.cpp new file mode 100644 index 0000000000..8853118e60 --- /dev/null +++ b/psw/ae/aesm_service/source/pve/pve_logic.cpp @@ -0,0 +1,436 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "pve_logic.h" +#include "aesm_logic.h" +#include "PVEClass.h" +#include "QEClass.h" +#include "oal/oal.h" +#include "aesm_epid_blob.h" +#include "se_wrapper.h" +#include "prov_msg_size.h" +#include "network_encoding_wrapper.h" +#include "prof_fun.h" +#include "aesm_long_lived_thread.h" +#include + +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} + +//Function to continue process Provisioning logic when the response of ProvMsg1 is ProvMsg2 +ae_error_t PvEAESMLogic::process_pve_msg2(psvn_t& sigrl_psvn, const uint8_t* msg2, uint32_t msg2_size, const endpoint_selection_infos_t& es_info) +{ + uint32_t msg_size = 0; + uint8_t *msg = NULL; + uint8_t *resp_msg = NULL; + uint32_t resp_size = 0; + epid_blob_with_cur_psvn_t epid_data; + ae_error_t ret = AE_SUCCESS; + uint8_t ek2[SK_SIZE]; + AESM_PROFILE_FUN; + + AESM_DBG_DEBUG("enter fun"); + AESM_DBG_TRACE("processing msg2 whose length is %d",msg2_size); + memset(&epid_data, 0, sizeof(epid_data)); + + + if(EPIDBlob::instance().read(epid_data)!=AE_SUCCESS){ + //First try to read existing EPID Blob to get old epid blob + //error code of reading epid blob will be ignored since old epid blob is optional + AESM_DBG_TRACE("read old epid blob fail"); + }else{ + AESM_DBG_TRACE("succ read old epid blob"); + } + + msg_size = estimate_msg3_size_by_msg2_size(msg2_size); //estimate an upbound for msg3 size + AESM_DBG_TRACE("estimate msg3 size: %d",msg_size); + + assert(msg_size > 0); + msg = reinterpret_cast(malloc(msg_size)); + if(msg == NULL){ + AESM_DBG_ERROR("malloc failed"); + ret = AE_OUT_OF_MEMORY_ERROR; + goto CLEANUP; + } + memset(msg, 0, msg_size); + AESM_DBG_TRACE("start processing msg2 and gen msg3"); + ret = static_cast(CPVEClass::instance().proc_prov_msg2(msg2, msg2_size, es_info.pek, epid_data.trusted_epid_blob, SGX_TRUSTED_EPID_BLOB_SIZE,//discard curpsvn in epid blob which is used in untrusted code only + ek2, &sigrl_psvn, msg, msg_size));//with help of PvE, process ProvMsg2 and generate ProvMsg3 + + if(ret == AE_SUCCESS){ + if(GET_SIZE_FROM_PROVISION_REQUEST(msg)>msg_size){ + AESM_DBG_ERROR("prov msg2 size %d is larger than buffer size %d", GET_SIZE_FROM_PROVISION_REQUEST(msg), msg_size); + ret = PVE_UNEXPECTED_ERROR; + goto CLEANUP; + } + AESM_DBG_TRACE("Start send msg3 and recv msg4"); + msg_size = static_cast(GET_SIZE_FROM_PROVISION_REQUEST(msg));//get the real size of ProvMsg3 + ret = AESMNetworkEncoding::aesm_send_recv_msg_encoding(es_info.provision_url, + msg, msg_size, resp_msg, resp_size); //Encoding ProvMsg3, send to server, receive ProvMsg4 and decode + if(ret != AE_SUCCESS){ + AESM_LOG_ERROR("%s",g_event_string_table[SGX_EVENT_EPID_PROV_FAILURE]); + AESM_DBG_WARN("send prov msg3 via network failed:%d",ret); + goto CLEANUP; + } + assert(resp_msg!=NULL); + AESM_DBG_TRACE("Start to proc msg4"); + ret = process_pve_msg4(resp_msg, resp_size, NULL, true, ek2);//The response msg must be ProvMsg4, process it to generate EPIDBlob + if(ret != AE_SUCCESS){ + AESM_DBG_TRACE("processing msg4 failed:%d",ret); + goto CLEANUP; + } + ret = AE_SUCCESS; + AESM_DBG_TRACE("processing msg4 succ"); + }else{ + AESM_DBG_WARN("fail to process prov msg2:%d",ret); + } +CLEANUP: + SAFE_FREE(msg); + if(resp_msg!=NULL) + AESMNetworkEncoding::aesm_free_response_msg(resp_msg); + return ret; +} + +//Function to finish the Provisioning Logic when a ProvMsg4 is expected or encountered +ae_error_t PvEAESMLogic::process_pve_msg4(const uint8_t* msg4, uint32_t msg4_size, const psvn_t* old_psvn, bool use_ek2, const uint8_t ek2[SK_SIZE]) +{ + AESM_PROFILE_FUN; + epid_blob_with_cur_psvn_t epid_data; + ae_error_t ret = AE_SUCCESS; + + AESM_DBG_DEBUG("enter fun"); + AESM_DBG_TRACE("processing msg4 with size %d",msg4_size); + memset(&epid_data, 0, sizeof(epid_data)); + + //with the help of PvE to process ProvMsg4 and generate EPIDDataBlob + if((ret = static_cast(CPVEClass::instance().proc_prov_msg4(use_ek2, ek2, msg4, msg4_size, + epid_data.trusted_epid_blob, SGX_TRUSTED_EPID_BLOB_SIZE )))!=AE_SUCCESS){ + AESM_DBG_WARN("proc prov msg4 fail:%d",ret); + goto fini; + } + if(NULL != old_psvn){ + if(0!=memcpy_s(&epid_data.cur_psvn, sizeof(epid_data.cur_psvn), + old_psvn, sizeof(psvn_t))){ + AESM_DBG_ERROR("memcpy failed"); + ret = PVE_UNEXPECTED_ERROR; + goto fini; + } + }else{//using current QE/PvE PSVN + uint16_t isv_svn; + ret = AESMLogic::get_qe_cpu_svn(epid_data.cur_psvn.cpu_svn); + if(AE_SUCCESS != ret){ + goto fini; + } + ret = AESMLogic::get_qe_isv_svn(isv_svn); + if(AE_SUCCESS != ret){ + goto fini; + } + if(0!=memcpy_s(&epid_data.cur_psvn.isv_svn, sizeof(epid_data.cur_psvn.isv_svn), &isv_svn, sizeof(isv_svn))){ + AESM_DBG_ERROR("memcpy failed"); + ret = PVE_UNEXPECTED_ERROR; + goto fini; + } + } + ret=EPIDBlob::instance().write(epid_data);//save the data into persistent data storage + if(AE_SUCCESS!=ret){ + AESM_DBG_WARN("fail to write epid_data:%d",ret); + } +fini: + return (ae_error_t)ret; +} + +//Function to process the Provisioning Logic for backup retrieval of old epid data blob +//The function assumes that the PvE state has been IDLE +ae_error_t PvEAESMLogic::update_old_blob(const psvn_t& psvn, const endpoint_selection_infos_t& es_info) +{ + uint32_t msg_size = 0; + uint8_t *msg = NULL; + uint32_t ae_ret = AE_SUCCESS; + uint8_t *resp_msg = NULL; + uint32_t resp_size = 0; + + AESM_PROFILE_FUN; + AESM_DBG_DEBUG("enter fun"); + + msg_size = estimate_msg1_size(false); + assert(msg_size > 0); + + msg = reinterpret_cast(malloc(msg_size)); + if(msg == NULL){ + AESM_DBG_ERROR("malloc fail"); + ae_ret = AE_OUT_OF_MEMORY_ERROR; + goto ret_point; + } + memset(msg, 0, msg_size); + + AESM_DBG_TRACE("start to gen prov msg1, estimated size %d", msg_size); + ae_ret = CPVEClass::instance().gen_prov_msg1(&psvn, es_info.pek, + false, msg, msg_size);//generate ProvMsg1 + if (ae_ret != AE_SUCCESS) + { + AESM_DBG_WARN("gen prov msg1 failed:%d",ae_ret); + goto ret_point; + } + msg_size = static_cast(GET_SIZE_FROM_PROVISION_REQUEST(msg)); + + AESM_DBG_TRACE("start to send msg1 to server and recv msg4"); + ae_ret = AESMNetworkEncoding::aesm_send_recv_msg_encoding(es_info.provision_url, + msg, msg_size, resp_msg,resp_size);//encoding/send/receive/decoding + if(ae_ret != AE_SUCCESS){ + AESM_LOG_ERROR("%s",g_event_string_table[SGX_EVENT_EPID_PROV_FAILURE]); + AESM_DBG_WARN("send prov msg1 via network failed:%d",ae_ret); + goto ret_point; + } + assert(resp_msg != NULL); + if (resp_size < PROVISION_RESPONSE_HEADER_SIZE) { + AESM_DBG_WARN("response message %d too small",resp_size); + ae_ret = PVE_UNEXPECTED_ERROR; + goto ret_point; + } + + AESM_DBG_TRACE("start to proc msg4"); + + if(GET_TYPE_FROM_PROVISION_RESPONSE(resp_msg) == TYPE_PROV_MSG4){ + ae_ret = process_pve_msg4(resp_msg, resp_size, &psvn, false, NULL);//process ProvMsg4 and generated/save EPID Data Blob + AESM_DBG_TRACE("msg4 processing finished, status %d",ae_ret); + }else{ + AESM_DBG_WARN("response message is not prov msg4"); + ae_ret = PVE_UNEXPECTED_ERROR; + } +ret_point: + if(msg)free(msg); + if(resp_msg!=NULL){ + AESMNetworkEncoding::aesm_free_response_msg(resp_msg); + } + return (ae_error_t)ae_ret; +} + +aesm_error_t PvEAESMLogic::pve_error_postprocess(ae_error_t ae_error) +{ + switch(ae_error){ + case AE_SUCCESS: + return AESM_SUCCESS; + case OAL_NETWORK_UNAVAILABLE_ERROR: + { + AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_EPID_PROV_FAILURE]); + return AESM_NETWORK_ERROR; + } + case OAL_THREAD_TIMEOUT_ERROR: + return AESM_BUSY; + case OAL_NETWORK_BUSY: + return AESM_NETWORK_BUSY_ERROR; + case OAL_PROXY_SETTING_ASSIST: + return AESM_PROXY_SETTING_ASSIST; + case OAL_FILE_ACCESS_ERROR: + case OAL_CONFIG_FILE_ERROR: + return AESM_FILE_ACCESS_ERROR; + case PVE_PARAMETER_ERROR: + case AE_INVALID_PARAMETER: + case OAL_PARAMETER_ERROR: + return AESM_PARAMETER_ERROR; + case PVE_EPIDBLOB_ERROR: + return AESM_EPIDBLOB_ERROR; + case AE_ENCLAVE_LOST: + case AE_SERVER_NOT_AVAILABLE: + return AESM_NO_DEVICE_ERROR; + case PVE_INTEGRITY_CHECK_ERROR: + { + AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_EPID_PROV_INTEGRITY_ERROR]); + return AESM_SGX_PROVISION_FAILED; + } + case PVE_SIGRL_INTEGRITY_CHECK_ERROR: + { + AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_EPID20_SIGRL_INTEGRITY_ERROR]); + return AESM_SGX_PROVISION_FAILED; + } + case PVE_SERVER_REPORTED_ERROR: + case PVE_MSG_ERROR: + return AESM_SGX_PROVISION_FAILED; + case PVE_REVOKED_ERROR: + return AESM_EPID_REVOKED_ERROR; + case PVE_SERVER_BUSY_ERROR: + return AESM_BACKEND_SERVER_BUSY; + case AE_OUT_OF_MEMORY_ERROR: + return AESM_OUT_OF_MEMORY_ERROR; + case PSW_UPDATED_REQUIRED: + return AESM_UPDATE_AVAILABLE; + default: + return AESM_UNEXPECTED_ERROR; + } +} + +aesm_error_t PvEAESMLogic::provision(bool performance_rekey_used, uint32_t timeout_usec) +{ + ae_error_t ae_ret = AE_SUCCESS; + AESM_PROFILE_FUN; + AESM_DBG_DEBUG("enter fun"); + + ae_ret = start_epid_provision_thread(performance_rekey_used, timeout_usec); + + return pve_error_postprocess(ae_ret); +} + + +ae_error_t PvEAESMLogic::epid_provision_thread_func(bool performance_rekey_used) +{ + uint32_t msg_size = 0; + uint8_t *msg = NULL; + uint8_t *resp_msg = NULL; + uint32_t resp_size = 0; + ae_error_t ae_ret = AE_SUCCESS; + uint32_t repeat = 0; + int retry = 0; + endpoint_selection_infos_t es_info; + + if(AE_SUCCESS!=(ae_ret=aesm_start_request_wake_execution())){ + AESM_DBG_ERROR("fail to request wake execution:%d", ae_ret); + return ae_ret; + } + + if((ae_ret = EndpointSelectionInfo::instance().start_protocol(es_info))!=AE_SUCCESS){//EndPoint Selection Protocol to setup Provisioning URL + (void)aesm_stop_request_wake_execution(); + AESM_DBG_WARN("end point selection failed:%d",ae_ret); + return ae_ret; + } + + //If enclave_lost encountered(such as S3/S4 reached, the retry will be increased by 1, for other kinds of exception like network error, repeat is increased by 1) + while((ae_ret!=AE_ENCLAVE_LOST&&repeat < AESM_RETRY_COUNT) || (ae_ret == AE_ENCLAVE_LOST && retry < AESM_RETRY_COUNT)){ + if(ae_ret == AE_ENCLAVE_LOST){ + AESM_DBG_TRACE("enclave lost inside SGX Provisioning and reload PvE required"); + CPVEClass::instance().unload_enclave();//force PVE to be reloaded later + } + if((ae_ret = CPVEClass::instance().load_enclave())!=AE_SUCCESS) + { + AESM_DBG_ERROR("load pve failed:%d",ae_ret); + break; + } + //estimate upbound size of ProvMsg1 and alloc memory for it + msg_size = estimate_msg1_size(performance_rekey_used); + AESM_DBG_TRACE("estimate msg1 size :%d",msg_size); + assert(msg_size > 0); + if(msg!=NULL)free(msg); + msg = (uint8_t *)malloc(msg_size); + if(msg == NULL){ + AESM_DBG_TRACE("malloc failed"); + ae_ret = AE_OUT_OF_MEMORY_ERROR; + break; + } + memset(msg, 0, msg_size); + + //Generate ProvMsg1 + ae_ret = static_cast(CPVEClass::instance().gen_prov_msg1(NULL, es_info.pek, performance_rekey_used, msg, msg_size));//Generate ProvMsg1 + if (ae_ret != AE_SUCCESS) + { + if(ae_ret == AE_ENCLAVE_LOST){ + AESM_DBG_TRACE("Enclave lost after gen_prov_msg1"); + retry++; + continue; + } + AESM_DBG_WARN("fail to generate prov msg1:%d",ae_ret); + break; + } + assert( msg != NULL && GET_SIZE_FROM_PROVISION_REQUEST(msg) >= PROVISION_REQUEST_HEADER_SIZE); + msg_size = static_cast(GET_SIZE_FROM_PROVISION_REQUEST(msg)); + AESM_DBG_TRACE("msg1 generated with size %d",msg_size); + + if(resp_msg!=NULL){ + AESMNetworkEncoding::aesm_free_response_msg(resp_msg); + resp_msg=NULL; + } + AESM_DBG_TRACE("start to send prov msg1 and recv response"); + ae_ret = AESMNetworkEncoding::aesm_send_recv_msg_encoding(es_info.provision_url, + msg,msg_size, resp_msg, resp_size);//encoding/send ProvMsg1, receiving and decoding resp message + if(ae_ret != AE_SUCCESS){ + AESM_DBG_WARN("send msg1 via network fail:%d",ae_ret); + break;//aesm_send_recv_se_msg will not return AE_ENCLAVE_LOST + } + + assert (resp_msg != NULL && resp_size >= PROVISION_RESPONSE_HEADER_SIZE); + + if(GET_TYPE_FROM_PROVISION_RESPONSE(resp_msg) == TYPE_PROV_MSG2){//If responsed msg is ProvMsg2 + psvn_t sigrl_svn; + AESM_DBG_TRACE("start to process prov msg2, size %d", resp_size); + ae_ret = process_pve_msg2(sigrl_svn, resp_msg, resp_size, es_info); + if(ae_ret != AE_SUCCESS){ + if(ae_ret == PVE_EPIDBLOB_ERROR){//If it reports old EPID Blob Error + AESM_DBG_TRACE("retrieve old epid blob"); + if((ae_ret = update_old_blob(sigrl_svn, es_info))!=AE_SUCCESS){//try to retrieve old EPID blob from backend server + if(ae_ret == AE_ENCLAVE_LOST){ + AESM_DBG_TRACE("PvE Enclave lost in update_old_blob"); + retry++; + continue; + } + AESM_DBG_WARN("fail to retrieve old epid blob:%d",ae_ret); + break; + }else{ + AESM_DBG_TRACE("retrieve old epid blob successfully"); + ae_ret = AE_FAILURE;//set to failure + repeat++;//only retry after update old epid blob + continue; + } + }else if(ae_ret == AE_ENCLAVE_LOST){ + AESM_DBG_TRACE("PvE enclave lost in process_pve_msg2"); + retry++; + continue; + }else{ + AESM_DBG_WARN("processing prov msg2 failed:%d",ae_ret); + break; + } + } + }else if(GET_TYPE_FROM_PROVISION_RESPONSE(resp_msg) == TYPE_PROV_MSG4){ + AESM_DBG_TRACE("start to process prov msg4 for current psvn"); + if((ae_ret = process_pve_msg4(resp_msg,resp_size, NULL, false, NULL))!=AE_SUCCESS){//process ProvMsg4 to generate EPID blob if resp is Msg4 + if(ae_ret == AE_ENCLAVE_LOST){ + AESM_DBG_TRACE("PvE Enclave lost in process_pve_msg4"); + retry++; + continue; + } + AESM_DBG_WARN("fail to process prov msg4:%d",ae_ret); + break; + } + }else{ + AESM_DBG_ERROR("Invalid resp msg type from backend server:%d",(int)GET_TYPE_FROM_PROVISION_RESPONSE(resp_msg)); + ae_ret = AE_FAILURE; + break; + } + AESM_DBG_TRACE("provisioning succ"); + ae_ret = AE_SUCCESS; + break; + } + + SAFE_FREE(msg); + if(resp_msg!=NULL){ + AESMNetworkEncoding::aesm_free_response_msg(resp_msg); + } + (void)aesm_stop_request_wake_execution(); + return ae_ret; + +} diff --git a/psw/ae/aesm_service/source/pve/pve_logic.h b/psw/ae/aesm_service/source/pve/pve_logic.h new file mode 100644 index 0000000000..c07a1495f8 --- /dev/null +++ b/psw/ae/aesm_service/source/pve/pve_logic.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PVE_LOGIC_H_ +#define _PVE_LOGIC_H_ +#include "sgx_urts.h" +#include "aesm_error.h" +#include "arch.h" +#include "aeerror.h" +#include "tlv_common.h" +#include "se_thread.h" +#include "oal/oal.h" +#include "se_wrapper.h" +#include +#include + +typedef struct _endpoint_selection_infos_t endpoint_selection_infos_t; + +class PvEAESMLogic{ +public: + static aesm_error_t provision(bool performance_rekey_used, uint32_t timeout_usec); + static aesm_error_t pve_error_postprocess(ae_error_t ae_error); + static ae_error_t epid_provision_thread_func(bool performance_rekey_used); /*call get_epid_provision_thread_status().start(performance_rekey_used) to invoke this function with timeout*/ +private: + static ae_error_t update_old_blob(const psvn_t& psvn, const endpoint_selection_infos_t& es_info); + static ae_error_t process_pve_msg2(psvn_t& sigrl_psvn, const uint8_t *msg2, uint32_t msg2_size, const endpoint_selection_infos_t& es_info); + static ae_error_t process_pve_msg4(const uint8_t *msg4, uint32_t msg4_size, const psvn_t* old_psvn, bool use_ek2, const uint8_t ek2[SK_SIZE]); +}; +#endif + diff --git a/psw/ae/aesm_service/source/qe/QEClass.cpp b/psw/ae/aesm_service/source/qe/QEClass.cpp new file mode 100644 index 0000000000..7e41bdaf76 --- /dev/null +++ b/psw/ae/aesm_service/source/qe/QEClass.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include "arch.h" +#include "QEClass.h" +#include "PVEClass.h" +#include "se_memcpy.h" +#include "prof_fun.h" +#include "quoting_enclave_u.h" +#include "quoting_enclave_u.c" + +void CQEClass::before_enclave_load() { + // always unload qe enclave before loading pve enclave + CPVEClass::instance().unload_enclave(); +} + +uint32_t CQEClass::get_qe_target( + sgx_target_info_t *p_qe_target) +{ + token_t *p_launch = + reinterpret_cast(&m_launch_token); + + /* We need to make sure the QE is successfully loaded and then we can use + the cached attributes and launch token. */ + assert(m_enclave_id); + memset(p_qe_target, 0, sizeof(sgx_target_info_t)); + memcpy_s(&p_qe_target->attributes, sizeof(p_qe_target->attributes), + &m_attributes.secs_attr, sizeof(m_attributes.secs_attr)); + memcpy_s(&p_qe_target->misc_select, sizeof(p_qe_target->misc_select), + &m_attributes.misc_select, sizeof(m_attributes.misc_select)); + memcpy_s(&p_qe_target->mr_enclave, sizeof(p_qe_target->mr_enclave), + &p_launch->body.mr_enclave, + sizeof(p_launch->body.mr_enclave)); + return AE_SUCCESS; +} + +uint32_t CQEClass::verify_blob( + uint8_t *p_epid_blob, + uint32_t blob_size, + bool *p_is_resealed) +{ + uint32_t ret = AE_SUCCESS; + sgx_status_t status = SGX_SUCCESS; + uint8_t is_resealed = 0; + int retry = 0; + AESM_PROFILE_FUN; + + assert(m_enclave_id); + status = ::verify_blob(m_enclave_id, &ret, p_epid_blob, blob_size, + &is_resealed); + for(; status == SGX_ERROR_ENCLAVE_LOST && retry < AESM_RETRY_COUNT; retry++) + { + unload_enclave(); + if(AE_SUCCESS != load_enclave()) + return AE_FAILURE; + status = ::verify_blob(m_enclave_id, &ret, p_epid_blob, blob_size, + &is_resealed); + } + if(status != SGX_SUCCESS) + return AE_FAILURE; + if(ret == AE_SUCCESS) + { + *p_is_resealed = is_resealed != 0; + } + if(ret == QE_EPIDBLOB_ERROR) + { + AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_EPID_INTEGRITY_ERROR]); + } + return ret; +} + +uint32_t CQEClass::get_quote( + uint8_t *p_epid_blob, + uint32_t blob_size, + const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + const sgx_spid_t *p_spid, + const sgx_quote_nonce_t *p_nonce, + const uint8_t *p_sigrl, + uint32_t sigrl_size, + sgx_report_t *p_qe_report, + uint8_t *p_quote, + uint32_t quote_size) +{ + uint32_t ret = AE_SUCCESS; + sgx_status_t status = SGX_SUCCESS; + int retry = 0; + AESM_PROFILE_FUN; + + assert(m_enclave_id); + status = ::get_quote( + m_enclave_id, + &ret, + p_epid_blob, + blob_size, + p_report, + quote_type, + p_spid, + p_nonce, + p_sigrl, + sigrl_size, + p_qe_report, + p_quote, + quote_size); + for(; status == SGX_ERROR_ENCLAVE_LOST && retry < AESM_RETRY_COUNT; retry++) + { + unload_enclave(); + if(AE_SUCCESS != load_enclave()) + return AE_FAILURE; + status = ::get_quote( + m_enclave_id, + &ret, + p_epid_blob, + blob_size, + p_report, + quote_type, + p_spid, + p_nonce, + p_sigrl, + sigrl_size, + p_qe_report, + p_quote, + quote_size); + } + if(status != SGX_SUCCESS) + return AE_FAILURE; + if(ret == QE_REVOKED_ERROR) + { + AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_EPID_REVOCATION]); + } + else if(ret == QE_SIGRL_ERROR) + { + AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_EPID20_SIGRL_INTEGRITY_ERROR]); + } + return ret; +} diff --git a/psw/ae/aesm_service/source/qe/QEClass.h b/psw/ae/aesm_service/source/qe/QEClass.h new file mode 100644 index 0000000000..e1e83ea4d4 --- /dev/null +++ b/psw/ae/aesm_service/source/qe/QEClass.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _QE_CLASS_H_ +#define _QE_CLASS_H_ +#include "AEClass.h" +#include "aeerror.h" +#include "sgx_report.h" +#include "sgx_quote.h" +#include "ae_debug_flag.hh" + +class CQEClass: public SingletonEnclave +{ + friend class Singleton; + friend class SingletonEnclave; + static aesm_enclave_id_t get_enclave_fid(){return QE_ENCLAVE_FID;} +protected: + CQEClass(){}; + ~CQEClass(){}; + virtual void before_enclave_load(); + virtual int get_debug_flag() { return AE_DEBUG_FLAG;} + +public: + uint32_t get_qe_target( + sgx_target_info_t *p_qe_target); + uint32_t verify_blob( + uint8_t *p_epid_blob, + uint32_t blob_size, + bool *p_is_resealed); + uint32_t get_quote( + uint8_t *p_epid_blob, + uint32_t blob_size, + const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + const sgx_spid_t *p_spid, + const sgx_quote_nonce_t *p_nonce, + const uint8_t *p_sigrl, + uint32_t sigrl_size, + sgx_report_t *p_qe_report, + uint8_t *p_quote, + uint32_t quote_size); +}; +#endif + diff --git a/psw/ae/aesm_service/source/qe/qe_logic.cpp b/psw/ae/aesm_service/source/qe/qe_logic.cpp new file mode 100644 index 0000000000..66d8e567b2 --- /dev/null +++ b/psw/ae/aesm_service/source/qe/qe_logic.cpp @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "aesm_epid_blob.h" +#include "qe_logic.h" +#include "pve_logic.h" +#include "aesm_logic.h" +#include "PVEClass.h" +#include "QEClass.h" +#include "se_sig_rl.h" +#include "se_quote_internal.h" +#include "se_wrapper.h" +#include "prof_fun.h" +#include "util.h" + +static ae_error_t get_qe_target(sgx_target_info_t *p_qe_target) +{ + ae_error_t ae_ret = AE_SUCCESS; + + if((ae_ret = CQEClass::instance().load_enclave())!=AE_SUCCESS) + { + AESM_DBG_ERROR("Fail to load QE:%d",ae_ret); + return ae_ret; + } + ae_ret = static_cast(CQEClass::instance().get_qe_target(p_qe_target)); + if(ae_ret != AE_SUCCESS) + return ae_ret; + return AE_SUCCESS; +} + +//Function to do reprovision if flag updated is false and set it to true if updated successfully +//The flag updated is used to simpilify logic in caller's code so that provision will not be invoked again +//if a previous provision has been successfully run +//After reprovision, the output epid_blob will be copied into output parameter epid_data +static aesm_error_t try_reprovision_if_not(bool& updated, epid_blob_with_cur_psvn_t& epid_data) +{ + aesm_error_t aesm_result; + ae_error_t ae_ret; + if(updated){ + // We've just got a EPID blob. It's a rare case to reach here. + // No retry, just return error. + AESM_DBG_ERROR("try to reprovision again after another provision"); + return AESM_EPIDBLOB_ERROR; + } + // The EPID blob is corrupted, and we've not provisioned yet, then + // we need to start the provision process. + if((aesm_result = PvEAESMLogic::provision(false, THREAD_TIMEOUT))!=AESM_SUCCESS){ + + AESM_DBG_ERROR("pve provision failed:%d", aesm_result); + return aesm_result; + } + updated = true; + // Update the epid blob after a successful provisioning. + if((ae_ret = EPIDBlob::instance().read(epid_data))!=AE_SUCCESS){ + AESM_DBG_ERROR("read epid blob failed:%d", ae_ret); + return AESM_EPIDBLOB_ERROR; + } + return AESM_SUCCESS; +} + +//Function to fetch gid from Epid Data Blob and also return target info +//EPID Provisioning will be redone if Epid Data Blob is not existing/invalid or +// the qe_isv_svn or cpu_svn don't match that in Epid Data Blob +aesm_error_t QEAESMLogic::init_quote( + sgx_target_info_t *target, + uint8_t *gid, uint32_t gid_size, + uint16_t qe_isv_svn, const sgx_cpu_svn_t qe_cpu_svn) +{ + ae_error_t ae_ret = AE_SUCCESS; + EPIDBlob& epid_blob = EPIDBlob::instance(); + AESM_DBG_DEBUG("enter fun"); + aesm_error_t aesm_result = AESM_UNEXPECTED_ERROR; + + AESM_PROFILE_FUN; + + epid_blob_with_cur_psvn_t epid_data; + bool resealed = false; + bool updated = false; + memset(&epid_data,0,sizeof(epid_data)); + + AESM_DBG_TRACE("start read and verify old epid blob"); + if((ae_ret = epid_blob.read(epid_data))!=AE_SUCCESS){ + if(AESM_SUCCESS!=(aesm_result = try_reprovision_if_not(updated, epid_data))){ + goto ret_point; + } + } + + if((ae_ret = CQEClass::instance().load_enclave())!=AE_SUCCESS) + { + AESM_DBG_ERROR("Fail to load QE:%d", ae_ret); + aesm_result = AESM_UNEXPECTED_ERROR; + goto ret_point; + } + ae_ret = static_cast(CQEClass::instance().verify_blob(epid_data.trusted_epid_blob, + SGX_TRUSTED_EPID_BLOB_SIZE, + &resealed)); + if(ae_ret == QE_EPIDBLOB_ERROR){ + if(AESM_SUCCESS!=(aesm_result = try_reprovision_if_not(updated, epid_data))){ + goto ret_point; + } + } + else if(ae_ret != AE_SUCCESS) + { + aesm_result = AESM_UNEXPECTED_ERROR; + goto ret_point; + } + + // Assert the size of GID, we have already checked it in upper level. + assert(sizeof(uint32_t) == gid_size); + UNUSED(gid_size); + + if (AE_SUCCESS != EPIDBlob::instance().get_sgx_gid((uint32_t*) gid)) { + aesm_result = AESM_UNEXPECTED_ERROR; + goto ret_point; + } + + AESM_DBG_TRACE("get gid %d from epid blob (little-endian)", + *(uint32_t*) gid); + + if(get_qe_target(target)!=AE_SUCCESS){ + AESM_DBG_ERROR("get qe target failed"); + aesm_result = AESM_UNEXPECTED_ERROR; + goto ret_point; + } + AESM_DBG_TRACE("get qe_target flags:%llx xfrm:%llx", + target->attributes.flags, target->attributes.xfrm); + //Any Quoting enclave related code must be before this section to avoid QE/PvE unloading each other + //Do the upgrade reprovision if required + AESM_DBG_TRACE("qe_isv_svn %d, epid_isv_svn %df",qe_isv_svn, epid_data.cur_psvn.isv_svn); + if((qe_isv_svn > epid_data.cur_psvn.isv_svn) + || (0!=memcmp(&qe_cpu_svn, &epid_data.cur_psvn.cpu_svn, + sizeof(sgx_cpu_svn_t)))) + { + //We will ignore all provision failure when there is a working EPID blob and leave the decision to attestation server + if(AESM_SUCCESS == (aesm_result = try_reprovision_if_not(updated, epid_data))){ + resealed = false; + }else if(AESM_PROXY_SETTING_ASSIST == aesm_result || + AESM_BUSY == aesm_result || + AESM_UPDATE_AVAILABLE == aesm_result ){//we should not ignore the three special error + goto ret_point; + } + } + //Any Quoting enclave related code must be before this section to avoid QE/PvE unloading each other */ + aesm_result = AESM_SUCCESS; +ret_point: + if(resealed && aesm_result == AESM_SUCCESS){ + AESM_DBG_TRACE("Update epid blob"); + if((ae_ret=epid_blob.write(epid_data))!=AE_SUCCESS){ + AESM_DBG_WARN("Fail to update epid blob:%d",ae_ret); + } + } + return aesm_result; +} + +/* Assuming buffer size is checked before calling this function, and get_quote + in QE will also check size. */ +aesm_error_t QEAESMLogic::get_quote(const uint8_t *report, + uint32_t quote_type, + const uint8_t *spid, + const uint8_t *nonce, + const uint8_t *sigrl, uint32_t sigrl_size, + uint8_t *qe_report, + uint8_t *quote, uint32_t buf_size) +{ + epid_blob_with_cur_psvn_t epid_data; + uint32_t ae_ret = AE_SUCCESS; + aesm_error_t aesm_result = AESM_UNEXPECTED_ERROR; + EPIDBlob& epid_blob = EPIDBlob::instance(); + + AESM_PROFILE_FUN; + memset(&epid_data, 0, sizeof(epid_data)); + + AESM_DBG_TRACE("start to read and verify epid blob"); + + if((ae_ret = epid_blob.read(epid_data))!=AE_SUCCESS){ + if((aesm_result = PvEAESMLogic::provision(false, THREAD_TIMEOUT))!=AESM_SUCCESS){ + + AESM_DBG_ERROR("pve provision failed:%d", aesm_result); + goto CLEANUP; + } + } + + if(CQEClass::instance().load_enclave()) + { + AESM_DBG_ERROR("load QE failed"); + aesm_result = AESM_UNEXPECTED_ERROR; + goto CLEANUP; + } + AESM_DBG_TRACE("start to get quote"); + ae_ret = CQEClass::instance().get_quote(epid_data.trusted_epid_blob, + SGX_TRUSTED_EPID_BLOB_SIZE, + reinterpret_cast(report), + static_cast(quote_type), + reinterpret_cast(spid), + reinterpret_cast(nonce), + sigrl, + sigrl_size, + reinterpret_cast(qe_report), + quote, + buf_size); + if(ae_ret != AE_SUCCESS) + { + AESM_DBG_TRACE("get_quote failed:%d",ae_ret); + if(ae_ret == QE_EPIDBLOB_ERROR) + aesm_result = AESM_EPIDBLOB_ERROR; + else if(ae_ret == QE_PARAMETER_ERROR) + aesm_result = AESM_PARAMETER_ERROR; + else if(ae_ret == QE_REVOKED_ERROR) + aesm_result = AESM_EPID_REVOKED_ERROR; + else + aesm_result = AESM_UNEXPECTED_ERROR; + goto CLEANUP; + } + AESM_DBG_TRACE("get quote succ"); + aesm_result = AESM_SUCCESS; +CLEANUP: + return aesm_result; +} + diff --git a/psw/ae/aesm_service/source/qe/qe_logic.h b/psw/ae/aesm_service/source/qe/qe_logic.h new file mode 100644 index 0000000000..22227bd103 --- /dev/null +++ b/psw/ae/aesm_service/source/qe/qe_logic.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _QE_LOGIC_H_ +#define _QE_LOGIC_H_ + +#include "sgx_urts.h" +#include "aesm_error.h" +#include "arch.h" +#include "aeerror.h" +#include "tlv_common.h" +#include "se_thread.h" +#include "oal/oal.h" +#include +#include + +class QEAESMLogic{ +public: + static aesm_error_t init_quote(sgx_target_info_t *target_info, + uint8_t *gid, uint32_t gid_size, uint16_t qe_isv_svn, + const sgx_cpu_svn_t qe_cpu_svn); + + static aesm_error_t get_quote(const uint8_t *report, + uint32_t quote_type, + const uint8_t *spid, + const uint8_t *nonce, + const uint8_t *sigrl, uint32_t sigrl_size, + uint8_t *qe_report, + uint8_t *quote, uint32_t buf_size); +}; +#endif + diff --git a/psw/ae/aesm_service/source/storage/persistent_storage_info.h b/psw/ae/aesm_service/source/storage/persistent_storage_info.h new file mode 100644 index 0000000000..1f9e4e5b2e --- /dev/null +++ b/psw/ae/aesm_service/source/storage/persistent_storage_info.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PERSISTENT_STORAGE_INFO_H_ +#define _PERSISTENT_STORAGE_INFO_H_ +#include "oal/aesm_persistent_storage.h" + +typedef enum _aesm_location_info_t {AESM_LOCATION_EXE_FOLDER, AESM_LOCATION_DATA} aesm_location_info_t; +typedef enum _aesm_file_access_type_t { + AESM_FILE_ACCESS_PATH_ONLY, /*We will only get pathname of the file obj via oal interface but AESM could still access the file via other APIs*/ + AESM_FILE_ACCESS_READ_ONLY, /*Only read the data*/ + AESM_FILE_ACCESS_ALL /*read and write*/ +} aesm_file_access_type_t; + +/*The table defines detail information about the persistent storages*/ +typedef struct _persistent_storage_info_t{ + aesm_data_type_t type; + aesm_location_info_t loc; + aesm_file_access_type_t access; + const char *name; +}persistent_storage_info_t; + +const persistent_storage_info_t* get_persistent_storage_info(aesm_data_id_t id); +#endif + diff --git a/psw/ae/aesm_service/source/storage/persistent_storage_table.cpp b/psw/ae/aesm_service/source/storage/persistent_storage_table.cpp new file mode 100644 index 0000000000..076056a8d2 --- /dev/null +++ b/psw/ae/aesm_service/source/storage/persistent_storage_table.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "persistent_storage_info.h" +#include "util.h" + +//The ordering of the array must be same as the enumerartion aesm_data_id_t +static const persistent_storage_info_t psinfos[]={ + {FT_ENCLAVE_NAME, AESM_LOCATION_EXE_FOLDER, AESM_FILE_ACCESS_PATH_ONLY, "le"},//LE_ENCLAVE_FID + {FT_ENCLAVE_NAME, AESM_LOCATION_EXE_FOLDER, AESM_FILE_ACCESS_PATH_ONLY, "qe"},//QE_ENCLAVE_FID + {FT_ENCLAVE_NAME, AESM_LOCATION_EXE_FOLDER, AESM_FILE_ACCESS_PATH_ONLY, "pve"},//PVE_ENCLAVE_FID + {FT_ENCLAVE_NAME, AESM_LOCATION_EXE_FOLDER, AESM_FILE_ACCESS_PATH_ONLY, "pse_op"},//PSE_OP_ENCLAVE_FID + {FT_ENCLAVE_NAME, AESM_LOCATION_EXE_FOLDER, AESM_FILE_ACCESS_PATH_ONLY, "pse_pr"},//PSE_PR_ENCLAVE_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_EXE_FOLDER, AESM_FILE_ACCESS_PATH_ONLY, "le_prod_css.bin"},//LE_PROD_SIG_STRUCT_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "endpoint_selection_info.blob"},//PROVISION_PEK_BLOB_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "epid_data.blob"},//EPID_DATA_BLOB_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_READ_ONLY, "aesm_server_url.blob"},//AESM_SERVER_URL_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_PATH_ONLY, "pse_vmc.db"},//VMC_DATABASE_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_PATH_ONLY, "backup_pse_vmc.db"},//VMC_DATABASE_BK_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_PATH_ONLY, "prebuild_pse_vmc.db"},//VMC_DATABASE_PREBUILD_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_EXE_FOLDER, AESM_FILE_ACCESS_PATH_ONLY, "PSDA.dalp"}, //PSDA_FID, path only information? + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "aesm_network_setting.blob"},//NETWORK_SETTING_FID +#ifdef DBG_LOG + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "internal_log.txt"}, //AESM_DBG_LOG_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "internal_log_cfg.xml"}, //AESM_DBG_LOG_CFG_FID +#endif +#ifdef _PROFILE_ + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "perf_time.csv"}, //AESM_PERF_DATA_FID +#endif + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "white_list_cert.bin"},//AESM_WHITE_LIST_CERT_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "white_list_cert_to_be_verify.bin"},//AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "OcspResponseVLR.dat"}, //PSE_PR_OCSPRESP_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "LTPairing.blob"}, //PSE_PR_LT_PAIRING_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "CertificateChain.list"},//PSE_PR_CERTIFICATE_CHAIN_FID + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "Certificate.cer"},//PSE_PR_CERTIFICATE_FID, user may add some postfix after name retrieved + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "Certificate2.cer"}, + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "Certificate3.cer"}, + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "Certificate4.cer"}, + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "Certificate5.cer"}, + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "Certificate6.cer"}, + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_ALL, "CertificateMax.cer"}, + {FT_PERSISTENT_STORAGE, AESM_LOCATION_DATA, AESM_FILE_ACCESS_PATH_ONLY, ""},//PSE_PR_SIGRL_FID, user may add some postfix after name retrieved +}; + +se_static_assert(sizeof(psinfos)/sizeof(persistent_storage_info_t) == NUMBER_OF_FIDS); + +const persistent_storage_info_t* get_persistent_storage_info(aesm_data_id_t id) +{ + if(id<0||id>=NUMBER_OF_FIDS) + return NULL; + return &psinfos[id]; +} + +aesm_data_id_t operator++(aesm_data_id_t& id, int) +{ + aesm_data_id_t retid = id; + switch (id) + { + case PSE_PR_CERTIFICATE_FID: + id = PSE_PR_CERTIFICATE_FID2; + break; + case PSE_PR_CERTIFICATE_FID2: + id = PSE_PR_CERTIFICATE_FID3; + break; + case PSE_PR_CERTIFICATE_FID3: + id = PSE_PR_CERTIFICATE_FID4; + break; + case PSE_PR_CERTIFICATE_FID4: + id = PSE_PR_CERTIFICATE_FID5; + break; + case PSE_PR_CERTIFICATE_FID5: + id = PSE_PR_CERTIFICATE_FID6; + break; + case PSE_PR_CERTIFICATE_FID6: + id = PSE_PR_CERTIFICATE_FID_MAX; + break; + default: + id = NUMBER_OF_FIDS; + break; + } + + return retid; +} + diff --git a/psw/ae/aesm_service/source/upse/platform_info_blob.h b/psw/ae/aesm_service/source/upse/platform_info_blob.h new file mode 100644 index 0000000000..f24a566f99 --- /dev/null +++ b/psw/ae/aesm_service/source/upse/platform_info_blob.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PLATFORM_INFO_BLOB_H_ +#define _PLATFORM_INFO_BLOB_H_ + +#include +#include "epid_pve_type.h" +#include "sgx_tcrypto.h" + + +#pragma pack(push, 1) + +#define ISVSVN_SIZE 2 +#define PSDA_SVN_SIZE 4 +#define RSA_SHA256_SIZE 256 + +typedef uint8_t tcb_psvn_t[PSVN_SIZE]; +typedef uint8_t psda_svn_t[PSDA_SVN_SIZE]; +typedef uint8_t pse_isvsvn_t[ISVSVN_SIZE]; + +/* Masks for sgx_epid_group_flags*/ +const uint8_t QE_EPID_GROUP_REVOKED = 0x01; +const uint8_t PERF_REKEY_FOR_QE_EPID_GROUP_AVAILABLE = 0x02; +const uint8_t QE_EPID_GROUP_OUT_OF_DATE = 0x04; + +/* Masks for sgx_tcb_evaluation_flags*/ +const uint16_t QUOTE_CPUSVN_OUT_OF_DATE = 0x0001; +const uint16_t QUOTE_ISVSVN_QE_OUT_OF_DATE = 0x0002; + +/* Masks for sgx_pse_evaluation_flags + PS_SEC_PROP_DESC.PSE_ISVSVN is out of date*/ +const int PSE_ISVSVN_OUT_OF_DATE = 0x0001; +/* CSME EPID 1.1 group identified by PS_SEC_PROP_DESC. PS_HW_GID has been revoked*/ +const int EPID_GROUP_ID_BY_PS_HW_GID_REVOKED = 0x0002; +/* PSDA SVN indicated in PS_SEC_PROP_DESC.PS_HW_SEC_INFO is out of date*/ +const int SVN_FROM_PS_HW_SEC_INFO_OUT_OF_DATE = 0x0004; +/* CSME EPID 1.1 SigRL version indicated in PS_SEC_PROP_DESC. PS_HW_SIG_RLver is out of date*/ +const int SIGRL_VER_FROM_PS_HW_SIG_RLVER_OUT_OF_DATE = 0x0008; +/* CSME EPID 1.1 PrivRL version indicated in PS_SEC_PROP_DESC. PS_HW_PrivKey_RLver is out of date*/ +const int PRIVRL_VER_FROM_PS_HW_PRV_KEY_RLVER_OUT_OF_DATE = 0x0010; + + + +typedef struct _platform_info_blob_wrapper_t +{ + bool valid_info_blob; + struct + { + uint8_t sgx_epid_group_flags; + uint8_t sgx_tcb_evaluation_flags[2]; + uint8_t pse_evaluation_flags[2]; + tcb_psvn_t latest_equivalent_tcb_psvn; + pse_isvsvn_t latest_pse_isvsvn; + psda_svn_t latest_psda_svn; + GroupID performance_rekey_gid; + GroupID gid; + sgx_ec256_signature_t signature; + } platform_info_blob; +} platform_info_blob_wrapper_t; + +#pragma pack(pop) + +ae_error_t pib_verify_signature(platform_info_blob_wrapper_t& piBlobWrapper); + +#endif diff --git a/psw/ae/buildenv.mk b/psw/ae/buildenv.mk new file mode 100644 index 0000000000..fe89e61471 --- /dev/null +++ b/psw/ae/buildenv.mk @@ -0,0 +1,95 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +ENV := $(strip $(wildcard $(TOP_DIR)/buildenv.mk)) + +ifeq ($(ENV),) + $(error "Can't find $(TOP_DIR)/buildenv.mk") +endif + +include $(TOP_DIR)/buildenv.mk + +WORK_DIR := $(shell pwd) +AENAME := $(notdir $(WORK_DIR)) +SONAME := $(AENAME).so +ifdef DEBUG +CONFIG := config_debug.xml +else +CONFIG := config.xml +endif +EDLFILE := $(wildcard *.edl) + +LINUX_EPID := $(LINUX_EXTERNAL_DIR)/epid/lib/linux + +EXTERNAL_LIB_NO_CRYPTO = -lsgx_tstdc + +URTSLIB := -lsgx_urts +TRTSLIB := -lsgx_trts +EXTERNAL_LIB_NO_CRYPTO += -lsgx_tservice + +TCRYPTO_LIBDIR := $(LINUX_SDK_DIR)/tlibcrypto +EXTERNAL_LIB = $(EXTERNAL_LIB_NO_CRYPTO) -L$(TCRYPTO_LIBDIR) -lsgx_tcrypto + +INCLUDE := -I$(LINUX_PSW_DIR)/ae/inc \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(LINUX_SDK_DIR)/selib \ + -I$(LINUX_SDK_DIR)/trts + +SIGNTOOL := $(ROOT_DIR)/build/linux/sgx_sign +SGXSIGN := $(ROOT_DIR)/build/linux/sgx_sign + +KEYFILE := $(LINUX_SDK_DIR)/sign_tool/sample_sec.pem +EDGER8R := $(LINUX_SDK_DIR)/edger8r/linux/_build/Edger8r.native + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) +CFLAGS += $(ENCLAVE_CFLAGS) + +LDTFLAGS = -L$(BUILD_DIR) -Wl,--whole-archive $(TRTSLIB) -Wl,--no-whole-archive \ + -Wl,--start-group $(EXTERNAL_LIB) -Wl,--end-group \ + -Wl,--version-script=$(ROOT_DIR)/build-scripts/enclave.lds $(ENCLAVE_LDFLAGS) + +LDTFLAGS_NO_CRYPTO = -L$(BUILD_DIR) -Wl,--whole-archive $(TRTSLIB) -Wl,--no-whole-archive \ + -Wl,--start-group $(EXTERNAL_LIB_NO_CRYPTO) -Wl,--end-group \ + -Wl,--version-script=$(ROOT_DIR)/build-scripts/enclave.lds $(ENCLAVE_LDFLAGS) + +LDTFLAGS += -fuse-ld=gold -Wl,--rosegment -Wl,-Map=out.map +LDTFLAGS_NO_CRYPTO += -fuse-ld=gold -Wl,--rosegment -Wl,-Map=out.map + +DEFINES := -D__linux__ + +vpath %.cpp $(COMMON_DIR)/src:\ + $(LINUX_PSW_DIR)/ae/common + +.PHONY : version +version: + echo "#include \"se_version.h\"\nchar version[] = \"\$$SGXVer: LinuxOpenSource\" STRFILEVER \"\$$\";" > $(LINUX_PSW_DIR)/ae/common/version.cpp diff --git a/psw/ae/common/inc/AECloseSessionRequest.h b/psw/ae/common/inc/AECloseSessionRequest.h new file mode 100644 index 0000000000..3d598b21e7 --- /dev/null +++ b/psw/ae/common/inc/AECloseSessionRequest.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_CLOSE_SESSION_REQUEST_H +#define _AE_CLOSE_SESSION_REQUEST_H + +#include + +class AECloseSessionRequest : public IAERequest +{ + public: + AECloseSessionRequest(); + AECloseSessionRequest(uint32_t sessionId, uint32_t timeout); + AECloseSessionRequest(const AECloseSessionRequest& other); + ~AECloseSessionRequest(); + + AEMessage* serialize(ISerializer* serializer); + void inflateValues(uint32_t sessionId, uint32_t timeout); + + //getters + int GetSessionId() const { return mSessionId; } + + //operators + bool operator==(const AECloseSessionRequest& other) const; + AECloseSessionRequest& operator=(const AECloseSessionRequest& request); + + //checks + bool check(); + void visit(IAERequestVisitor& visitor); + + //hooks + IAEResponse* execute(IAESMLogic* aesmLogic); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + + protected: + void ReleaseMemory(); + void CopyFields(uint32_t sessionId, uint32_t timeout); + + uint32_t mSessionId; +}; + +#endif diff --git a/psw/ae/common/inc/AECloseSessionResponse.h b/psw/ae/common/inc/AECloseSessionResponse.h new file mode 100644 index 0000000000..8927ec27cb --- /dev/null +++ b/psw/ae/common/inc/AECloseSessionResponse.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_CLOSE_SESSION_RESPONSE_H +#define _AE_CLOSE_SESSION_RESPONSE_H + +#include + +class AECloseSessionResponse : public IAEResponse +{ + public: + AECloseSessionResponse(); + AECloseSessionResponse(int errorCode); + AECloseSessionResponse(const AECloseSessionResponse& other); + ~AECloseSessionResponse(); + + AEMessage* serialize(ISerializer* serializer); + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + void inflateValues(int errorCode); + + //operators + bool operator==(const AECloseSessionResponse& other) const; + AECloseSessionResponse& operator=(const AECloseSessionResponse& other); + + //checks + bool check(); + virtual void visit(IAEResponseVisitor& visitor); + + protected: + void ReleaseMemory(); + void CopyFields(int errorCode); + +}; + +#endif diff --git a/psw/ae/common/inc/AECreateSessionRequest.h b/psw/ae/common/inc/AECreateSessionRequest.h new file mode 100644 index 0000000000..b900dac958 --- /dev/null +++ b/psw/ae/common/inc/AECreateSessionRequest.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_CREATE_SESSION_REQUEST_H +#define __AE_CREATE_SESSION_REQUEST_H + +#include +class AESMLogicWrapper; + +class AECreateSessionRequest : public IAERequest +{ + public: + AECreateSessionRequest(); + AECreateSessionRequest(uint32_t dhMsg1Size, uint32_t timeout = 0); + AECreateSessionRequest(const AECreateSessionRequest& other); + ~AECreateSessionRequest(); + + AEMessage* serialize(ISerializer* serializer); + void inflateValues(uint32_t dhMsg1Size, uint32_t timeout = 0); + + //getters + uint32_t GetDHMsg1Size() const {return mDHMsg1Size;} + + //operators + bool operator==(const AECreateSessionRequest& other) const; + AECreateSessionRequest& operator=(const AECreateSessionRequest& other); + + //checks + bool check(); + virtual IAEResponse* execute(IAESMLogic*); + void visit(IAERequestVisitor& visitor); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + protected: + void ReleaseMemory(); + void CopyFields(uint32_t dhMsg1Size, uint32_t timeout); + + uint32_t mDHMsg1Size; +}; + +#endif diff --git a/psw/ae/common/inc/AECreateSessionResponse.h b/psw/ae/common/inc/AECreateSessionResponse.h new file mode 100644 index 0000000000..5193bd8feb --- /dev/null +++ b/psw/ae/common/inc/AECreateSessionResponse.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_CREATE_SESSION_RESPONSE_H +#define _AE_CREATE_SESSION_RESPONSE_H + +#include +#include + +class AECreateSessionResponse : public IAEResponse +{ + public: + AECreateSessionResponse(); + AECreateSessionResponse(int errorCode, uint32_t sessionId, uint32_t dhMsg1Length, const uint8_t* dhMsg1); + AECreateSessionResponse(const AECreateSessionResponse& other); + ~AECreateSessionResponse(); + + AEMessage* serialize(ISerializer* serializer); + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + void inflateValues(int errorCode, uint32_t sessionId, uint32_t dhMsg1Length, const uint8_t* dhMsg1); + + inline int GetSessionId() const { return mSessionId; } + inline uint32_t GetDHMsg1Length() const { return mDHMsg1Length; } + inline const uint8_t* GetDHMsg1() const { return mDHMsg1; } + + //operators + bool operator==(const AECreateSessionResponse& other) const; + AECreateSessionResponse& operator=(const AECreateSessionResponse& other); + + //checks + bool check(); + virtual void visit(IAEResponseVisitor& visitor); + + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint32_t sessionId, uint32_t dhMsg1Length, const uint8_t* dhMsg1); + + uint32_t mSessionId; + uint32_t mDHMsg1Length; + uint8_t* mDHMsg1; +}; + +#endif diff --git a/psw/ae/common/inc/AEExchangeReportRequest.h b/psw/ae/common/inc/AEExchangeReportRequest.h new file mode 100644 index 0000000000..78be0d53b5 --- /dev/null +++ b/psw/ae/common/inc/AEExchangeReportRequest.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_EXCHANGE_REPORT_REQUEST_H +#define _AE_EXCHANGE_REPORT_REQUEST_H + +#include +#include + +class AEExchangeReportRequest : public IAERequest +{ + public: + AEExchangeReportRequest(); + AEExchangeReportRequest(uint32_t sessionId, uint32_t dhMsg2Length, const uint8_t* dhMsg2, uint32_t dhMsg3Length, uint32_t timeout=0); + AEExchangeReportRequest(const AEExchangeReportRequest& other); + ~AEExchangeReportRequest(); + + AEMessage* serialize(ISerializer* serializer); + void inflateValues(uint32_t sessionId, uint32_t dhMsg2Length, const uint8_t* dhMsg2, uint32_t dhMsg3Length, uint32_t timeout=0); + + //getters + uint32_t GetSessionId() const { return mSessionId; } + uint32_t GetDHMsg2Length() const { return mDHMsg2Length; } + uint32_t GetDHMsg3Length() const { return mDHMsg3Length; } + const uint8_t* GetDHMsg2() const { return mDHMsg2; } + + //operators + bool operator==(const AEExchangeReportRequest& other) const; + AEExchangeReportRequest& operator=(const AEExchangeReportRequest& other); + + //checkers + bool check(); + IAEResponse* execute(IAESMLogic* aesmLogic); + void visit(IAERequestVisitor& visitor); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + protected: + void ReleaseMemory(); + void CopyFields(uint32_t sessionId, uint32_t dhMsg2Length, const uint8_t* dhMsg2, uint32_t dhMsg3Length, uint32_t timeout); + + uint32_t mSessionId; + uint32_t mDHMsg2Length; + uint8_t* mDHMsg2; + uint32_t mDHMsg3Length; +}; + +#endif diff --git a/psw/ae/common/inc/AEExchangeReportResponse.h b/psw/ae/common/inc/AEExchangeReportResponse.h new file mode 100644 index 0000000000..7a20d0891d --- /dev/null +++ b/psw/ae/common/inc/AEExchangeReportResponse.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_EXCHANGE_REPORT_RESPONSE_H +#define _AE_EXCHANGE_REPORT_RESPONSE_H + +#include +#include + +class AEExchangeReportResponse : public IAEResponse +{ + public: + AEExchangeReportResponse(); + AEExchangeReportResponse(int errorCode, uint32_t dhMsg3Length, const uint8_t* dhMsg3); + AEExchangeReportResponse(const AEExchangeReportResponse& other); + ~AEExchangeReportResponse(); + + AEMessage* serialize(ISerializer* serializer); + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + void inflateValues(int errorCode, uint32_t dhMsg3Length, const uint8_t* dhMsg3); + + //getters + uint32_t GetDHMsg3Length() const { return mDHMsg3Length; } + const uint8_t* GetDHMsg3() const { return mDHMsg3; } + + //operators + bool operator==(const AEExchangeReportResponse& other) const; + AEExchangeReportResponse& operator=(const AEExchangeReportResponse& other); + + //checkers + bool check(); + virtual void visit(IAEResponseVisitor& visitor); + + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint32_t dhMsg3Length, const uint8_t* dhMsg3); + + uint32_t mDHMsg3Length; + uint8_t* mDHMsg3; +}; + +#endif diff --git a/psw/ae/common/inc/AEGetLaunchTokenRequest.h b/psw/ae/common/inc/AEGetLaunchTokenRequest.h new file mode 100644 index 0000000000..fefd1d5102 --- /dev/null +++ b/psw/ae/common/inc/AEGetLaunchTokenRequest.h @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_GET_LICENSE_TOKEN_H +#define __AE_GET_LICENSE_TOKEN_H + +#include +#include + +class IAESMLogic; + +class AEGetLaunchTokenRequest : public IAERequest +{ + public: + AEGetLaunchTokenRequest(); + AEGetLaunchTokenRequest(uint32_t measurementLength, const uint8_t* measurement, + uint32_t sigstructLength, const uint8_t* sigstruct, + uint32_t attributesLength, const uint8_t* attributes, uint32_t timeout = 0); + AEGetLaunchTokenRequest(const AEGetLaunchTokenRequest& other); + + ~AEGetLaunchTokenRequest(); + + + AEMessage* serialize(ISerializer* serializer); + void inflateValues(uint32_t measurementLength,const uint8_t* measurement, + uint32_t sigstructLength,const uint8_t* sigstruct, + uint32_t attributesLength,const uint8_t* attributes, + uint32_t timeout = 0); + + //inlines + uint32_t GetMeasurementLength() const { return mEnclaveMeasurementLength; } + const uint8_t* GetMeasurement() const { return mEnclaveMeasurement; } + uint32_t GetSigstructLength() const { return mSigstructLength; } + const uint8_t* GetSigstruct() const { return mSigstruct; } + uint32_t GetAttributesLength() const { return mSEAttributesLength; } + const uint8_t* GetAttributes() const { return mSEAttributes; } + + //operators + bool operator==( const AEGetLaunchTokenRequest& other) const; + AEGetLaunchTokenRequest& operator=(const AEGetLaunchTokenRequest& other); + + //checks + bool check(); + virtual IAEResponse* execute(IAESMLogic*); + + void visit(IAERequestVisitor& visitor); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + protected: + //release all members + void ReleaseMemory(); + void CopyFields(uint32_t measurementLength,const uint8_t* measurement, + uint32_t sigstructLength,const uint8_t* sigstruct, + uint32_t attributesLength,const uint8_t* attributes, + uint32_t timeout); + + uint32_t mEnclaveMeasurementLength; + uint8_t* mEnclaveMeasurement; + + uint32_t mSigstructLength; + uint8_t* mSigstruct; + + uint32_t mSEAttributesLength; + uint8_t* mSEAttributes; +}; + +#endif diff --git a/psw/ae/common/inc/AEGetLaunchTokenResponse.h b/psw/ae/common/inc/AEGetLaunchTokenResponse.h new file mode 100644 index 0000000000..b4a73f4abe --- /dev/null +++ b/psw/ae/common/inc/AEGetLaunchTokenResponse.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_GET_LICENSE_TOKEN_H +#define _AE_GET_LICENSE_TOKEN_H + +#include +#include + +class AEGetLaunchTokenResponse : public IAEResponse +{ + public: + AEGetLaunchTokenResponse(); + AEGetLaunchTokenResponse(int errorCode, uint32_t tokenLength, const uint8_t* token); + AEGetLaunchTokenResponse(const AEGetLaunchTokenResponse& other); + + ~AEGetLaunchTokenResponse(); + + AEMessage* serialize(ISerializer* serializer); + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + void inflateValues(int errorCode, uint32_t tokenLength,const uint8_t* token); + + //inlines + int GetTokenLength() const { return mTokenLength; } + const uint8_t* GetToken() const { return mToken; } + + //operators + bool operator==(const AEGetLaunchTokenResponse& other) const; + AEGetLaunchTokenResponse& operator=(const AEGetLaunchTokenResponse& other); + + //checks + bool check(); + virtual void visit(IAEResponseVisitor& visitor); + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint32_t tokenLength,const uint8_t* token); + + uint32_t mTokenLength; + uint8_t* mToken; +}; + +#endif diff --git a/psw/ae/common/inc/AEGetPsCapRequest.h b/psw/ae/common/inc/AEGetPsCapRequest.h new file mode 100644 index 0000000000..d72496e222 --- /dev/null +++ b/psw/ae/common/inc/AEGetPsCapRequest.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_GET_PS_CAP_REQUEST_H +#define __AE_GET_PS_CAP_REQUEST_H + +#include +class IAESMLogic; + +class AEGetPsCapRequest : public IAERequest{ + public: + AEGetPsCapRequest(uint32_t timeout = 0); + AEGetPsCapRequest(const AEGetPsCapRequest& other); + ~AEGetPsCapRequest(); + + void ReleaseMemory(); + + AEMessage* serialize(ISerializer* serializer); + + //inflater -> empty for now ... but soon + void inflateValues(uint32_t timeout = 0); + + //checks + bool check() {return true;} // no special check for this object. Maybe later + virtual IAEResponse* execute(IAESMLogic*); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + bool operator==(const AEGetPsCapRequest& other) const; + AEGetPsCapRequest& operator=(const AEGetPsCapRequest& other); + void visit(IAERequestVisitor& visitor); + void CopyFields(uint32_t timeout); +}; + +#endif diff --git a/psw/ae/common/inc/AEGetPsCapResponse.h b/psw/ae/common/inc/AEGetPsCapResponse.h new file mode 100644 index 0000000000..572156e895 --- /dev/null +++ b/psw/ae/common/inc/AEGetPsCapResponse.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_GET_PS_CAP_RESPONSE_H +#define __AE_GET_PS_CAP_RESPONSE_H + +#include +#include + +class ISerializer; + +class AEGetPsCapResponse : public IAEResponse +{ + public: + AEGetPsCapResponse(); //default ... will prepare a response that will later be inflated + + AEGetPsCapResponse(int errorCode, uint64_t ps_cap); + AEGetPsCapResponse(const AEGetPsCapResponse& other); + + ~AEGetPsCapResponse(); + + //inflater + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + + inline uint64_t GetPsCap() const { return mPsCap;} + + AEMessage* serialize(ISerializer* serializer); + + //this is used to inflate values from a serializer, instead of creating the object directly + void inflateValues(int errorCode, uint64_t ps_cap); + + //operators + virtual bool operator==(const AEGetPsCapResponse &other) const; + AEGetPsCapResponse& operator=(const AEGetPsCapResponse &other); + + void visit(IAEResponseVisitor& visitor); + + //checks + bool check(); + + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint64_t ps_cap); + + uint64_t mPsCap; +}; + +#endif diff --git a/psw/ae/common/inc/AEGetQuoteRequest.h b/psw/ae/common/inc/AEGetQuoteRequest.h new file mode 100644 index 0000000000..0a0d5925d3 --- /dev/null +++ b/psw/ae/common/inc/AEGetQuoteRequest.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_GET_QUOTE_H +#define __AE_GET_QUOTE_H + +#include +#include +class IAESMLogic; + +class AEGetQuoteRequest : public IAERequest +{ + public: + AEGetQuoteRequest(); + AEGetQuoteRequest(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, + bool qe_report, + uint32_t timeout = 0); + AEGetQuoteRequest(const AEGetQuoteRequest& other); + + ~AEGetQuoteRequest(); + + AEMessage* serialize(ISerializer* serializer); + void inflateValues(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, + bool qe_report, + uint32_t timeout = 0); + + inline const uint8_t* GetReport() const { return mReport; } + inline uint32_t GetReportLength() const { return mReportLength; } + inline uint32_t GetQuoteType() const { return mQuoteType; } + inline uint32_t GetSPIDLength() const { return mSPIDLength; } + inline const uint8_t* GetSPID() const { return mSPID; } + inline uint32_t GetNonceLength() const { return mNonceLength; } + inline const uint8_t* GetNonce() const { return mNonce; } + inline const uint8_t* GetSigRL() const { return mSigRL; } + inline uint32_t GetSigRLLength() const { return mSigRLLength; } + inline uint32_t GetBufferSize() const { return mBufferSize; } + inline bool GetQEReport() const { return mQEReport; } + + //operators + virtual bool operator==(const AEGetQuoteRequest& other) const; + AEGetQuoteRequest& operator=(const AEGetQuoteRequest& other); + + //checks + bool check(); + virtual IAEResponse* execute(IAESMLogic*); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + + void visit(IAERequestVisitor& visitor); + + protected: + + void ReleaseMemory(); + void CopyFields(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, + bool qe_report, + uint32_t timeout); + + uint32_t mReportLength; + uint8_t* mReport; + + uint32_t mQuoteType; + + uint32_t mSPIDLength; + uint8_t* mSPID; + + uint32_t mNonceLength; + uint8_t* mNonce; + + uint32_t mSigRLLength; + uint8_t* mSigRL; + + uint32_t mBufferSize; + bool mQEReport; + +}; + + +#endif diff --git a/psw/ae/common/inc/AEGetQuoteResponse.h b/psw/ae/common/inc/AEGetQuoteResponse.h new file mode 100644 index 0000000000..48b9411630 --- /dev/null +++ b/psw/ae/common/inc/AEGetQuoteResponse.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_GET_QUOTE_RESPONSE_H +#define __AE_GET_QUOTE_RESPONSE_H + +#include +#include + +class AEGetQuoteResponse : public IAEResponse +{ + public: + AEGetQuoteResponse(); + AEGetQuoteResponse(int errorCode, uint32_t quoteLength, const uint8_t* quote, + uint32_t qeReportLength, const uint8_t* qeReport); + AEGetQuoteResponse(const AEGetQuoteResponse& other); + + ~AEGetQuoteResponse(); + + AEMessage* serialize(ISerializer* serializer); + bool inflateWithMessage(AEMessage* message, ISerializer* response); + void inflateValues(int errorCode, uint32_t quoteLength,const uint8_t* quote, + uint32_t qeReportLength, const uint8_t* qeReport); + + + //operators + bool operator==(const AEGetQuoteResponse& other) const; + AEGetQuoteResponse& operator=(const AEGetQuoteResponse& other); + + //getters + inline uint32_t GetQuoteLength() { return mQuoteLength; } + inline const uint8_t* GetQuote() { return mQuote; } + inline uint32_t GetQEReportLength() { return mQEReportLength; } + inline const uint8_t* GetQEReport() { return mQEReport; } + + //checks + bool check(); + virtual void visit(IAEResponseVisitor& visitor); + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint32_t quoteLength,const uint8_t* quote, + uint32_t qeReportLength, const uint8_t* qeReport); + + uint32_t mQuoteLength; + uint8_t* mQuote; + uint32_t mQEReportLength; + uint8_t* mQEReport; +}; + +#endif diff --git a/psw/ae/common/inc/AEInitQuoteRequest.h b/psw/ae/common/inc/AEInitQuoteRequest.h new file mode 100644 index 0000000000..f8a4d546d1 --- /dev/null +++ b/psw/ae/common/inc/AEInitQuoteRequest.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_INIT_QUOTE_REQUEST_H +#define __AE_INIT_QUOTE_REQUEST_H + +#include +class IAESMLogic; + +class AEInitQuoteRequest : public IAERequest{ + public: + AEInitQuoteRequest(uint32_t timeout = 0); + AEInitQuoteRequest(const AEInitQuoteRequest& other); + ~AEInitQuoteRequest(); + + void CopyFields(uint32_t timeout); + void ReleaseMemory(); + + AEMessage* serialize(ISerializer* serializer); + + //inflater -> empty for now ... but soon + void inflateValues(uint32_t timeout = 0); + + //checks + bool check() {return true;} // no special check for this object. Maybe later + virtual IAEResponse* execute(IAESMLogic*); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + + bool operator==(const AEInitQuoteRequest& other) const; + AEInitQuoteRequest& operator=(const AEInitQuoteRequest& other); + + void visit(IAERequestVisitor& visitor); +}; + + + +#endif diff --git a/psw/ae/common/inc/AEInitQuoteResponse.h b/psw/ae/common/inc/AEInitQuoteResponse.h new file mode 100644 index 0000000000..7ddb111d4e --- /dev/null +++ b/psw/ae/common/inc/AEInitQuoteResponse.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_INIT_QUOTE_RESPONSE_H +#define __AE_INIT_QUOTE_RESPONSE_H + +#include +#include + +class ISerializer; + +class AEInitQuoteResponse : public IAEResponse +{ + public: + AEInitQuoteResponse(); //default ... will prepare a response that will later be inflated + + AEInitQuoteResponse(int errorCode, uint32_t gidLength, const uint8_t* gid, + uint32_t targetInfoLength, const uint8_t* targetInfo); + AEInitQuoteResponse(const AEInitQuoteResponse& other); + + ~AEInitQuoteResponse(); + + //inflater + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + + inline const uint8_t* GetGID() const { return mGID;} + inline uint32_t GetGIDLength() const { return mGIDLength; } + inline const uint8_t* GetTargetInfo() const { return mTargetInfo;} + inline uint32_t GetTargetInfoLength() const { return mTargetInfoLength; } + + AEMessage* serialize(ISerializer* serializer); + + //this is used to inflate values from a serializer, instead of creating the object directly + void inflateValues(int errorCode, uint32_t gidLength, const uint8_t* gid, + uint32_t targetInfoLength, const uint8_t* targetInfo); + + + //operators + virtual bool operator==(const AEInitQuoteResponse &other) const; + AEInitQuoteResponse& operator=(const AEInitQuoteResponse &other); + + //checks + bool check(); + virtual void visit(IAEResponseVisitor& visitor); + + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint32_t gidLength,const uint8_t* gid, + uint32_t targetInfoLength,const uint8_t* targetInfo); + + uint32_t mGIDLength; + uint32_t mTargetInfoLength; + + uint8_t* mTargetInfo; + uint8_t* mGID; +}; + +#endif diff --git a/psw/ae/common/inc/AEInvokeServiceRequest.h b/psw/ae/common/inc/AEInvokeServiceRequest.h new file mode 100644 index 0000000000..53755ae397 --- /dev/null +++ b/psw/ae/common/inc/AEInvokeServiceRequest.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_INVOKE_SERVICE_REQUEST_H +#define _AE_INVOKE_SERVICE_REQUEST_H + +#include +#include + +class AEInvokeServiceRequest : public IAERequest +{ + public: + AEInvokeServiceRequest(); + AEInvokeServiceRequest(uint32_t pseMessageLength, const uint8_t* pseMessage, uint32_t pseResponseSize, uint32_t timeout = 0); + AEInvokeServiceRequest(const AEInvokeServiceRequest& other); + ~AEInvokeServiceRequest(); + + AEMessage* serialize(ISerializer* serializer); + void inflateValues(uint32_t pseMessageLength, const uint8_t* pseMessage, uint32_t pseResponseSize, uint32_t timeout = 0); + + //getters + inline uint32_t GetPSEMessageLength() const { return mPSEMessageLength; } + inline const uint8_t* GetPSEMessage() const { return mPSEMessage; } + inline uint32_t GetResponseSize() const { return mResponseSize; } + + //operators + bool operator==(const AEInvokeServiceRequest& other) const; + AEInvokeServiceRequest& operator=(const AEInvokeServiceRequest& other); + + //checks + bool check(); + virtual IAEResponse* execute(IAESMLogic*); + void visit(IAERequestVisitor& visitor); + + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + protected: + void ReleaseMemory(); + void CopyFields(uint32_t pseMessageLength, const uint8_t* pseMessage, uint32_t pseResponseSize, uint32_t timeout); + + uint32_t mPSEMessageLength; + uint8_t* mPSEMessage; + uint32_t mResponseSize; +}; + +#endif diff --git a/psw/ae/common/inc/AEInvokeServiceResponse.h b/psw/ae/common/inc/AEInvokeServiceResponse.h new file mode 100644 index 0000000000..412ccadd46 --- /dev/null +++ b/psw/ae/common/inc/AEInvokeServiceResponse.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_INVOKE_SERVICE_RESPONSE_H +#define _AE_INVOKE_SERVICE_RESPONSE_H + +#include +#include + +class AEInvokeServiceResponse : public IAEResponse +{ + public: + AEInvokeServiceResponse(); + AEInvokeServiceResponse(int errorCode, uint32_t pseMessageLength, const uint8_t* pseMessage); + AEInvokeServiceResponse(const AEInvokeServiceResponse& other); + ~AEInvokeServiceResponse(); + + AEMessage* serialize(ISerializer* serializer); + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + void inflateValues(int errorCode, uint32_t pseMessageLength,const uint8_t* pseMessage); + + //getters + inline uint32_t GetPSEMessageLength() const { return mPSEMessageLength; } + inline const uint8_t* GetPSEMessage() const { return mPSEMessage; } + + //operators + bool operator==(const AEInvokeServiceResponse& other) const; + AEInvokeServiceResponse& operator=(const AEInvokeServiceResponse& other); + + //checks + bool check(); + virtual void visit(IAEResponseVisitor& visitor); + + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint32_t pseMessageLength,const uint8_t* pseMessage); + + uint32_t mPSEMessageLength; + uint8_t* mPSEMessage; +}; +#endif diff --git a/psw/ae/common/inc/AEReportAttestationRequest.h b/psw/ae/common/inc/AEReportAttestationRequest.h new file mode 100644 index 0000000000..cd669b8aa2 --- /dev/null +++ b/psw/ae/common/inc/AEReportAttestationRequest.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_REPORT_ATTESTATION_REQUEST_H +#define _AE_REPORT_ATTESTATION_REQUEST_H + +#include + +class AEReportAttestationRequest : public IAERequest +{ + public: + AEReportAttestationRequest(); + AEReportAttestationRequest(uint32_t platformInfoLength, const uint8_t* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout = 0); + AEReportAttestationRequest(const AEReportAttestationRequest& other); + ~AEReportAttestationRequest(); + + AEMessage* serialize(ISerializer* serializer); + void inflateValues(uint32_t platformInfoLength, const uint8_t* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout = 0); + + //getters + inline uint32_t GetAttestationErrorCode() const { return mAttestationErrorCode; } + inline uint32_t GetPlatformInfoLength() const { return mPlatformInfoLength;} + inline const uint8_t* GetPlatformInfo() const { return mPlatformInfo;} + inline uint32_t GetUpdateInfoLength() const { return mUpdateInfoLength;} + + //operators + bool operator==(const AEReportAttestationRequest& other) const; + AEReportAttestationRequest& operator=(const AEReportAttestationRequest& request); + + //checks + bool check(); + + //hooks + IAEResponse* execute(IAESMLogic* aesmLogic); + + //used to determin in which queue to be placed + virtual RequestClass getRequestClass(); + void visit(IAERequestVisitor& visitor); + + protected: + void ReleaseMemory(); + void CopyFields(uint32_t platformInfoLength, const uint8_t* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout); + + uint32_t mAttestationErrorCode; + + uint32_t mPlatformInfoLength; + uint8_t* mPlatformInfo; + uint32_t mUpdateInfoLength; +}; + +#endif diff --git a/psw/ae/common/inc/AEReportAttestationResponse.h b/psw/ae/common/inc/AEReportAttestationResponse.h new file mode 100644 index 0000000000..a736a5d818 --- /dev/null +++ b/psw/ae/common/inc/AEReportAttestationResponse.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_REPORT_ATTESTATION_ERROR_RESPONSE_H +#define _AE_REPORT_ATTESTATION_ERROR_RESPONSE_H + +#include + +class AEReportAttestationResponse : public IAEResponse +{ + public: + AEReportAttestationResponse(); + AEReportAttestationResponse(int errorCode, uint32_t UpdateInfoLength, const uint8_t* UpdateInfo); + AEReportAttestationResponse(const AEReportAttestationResponse& other); + ~AEReportAttestationResponse(); + + AEMessage* serialize(ISerializer* serializer); + bool inflateWithMessage(AEMessage* message, ISerializer* serializer); + void inflateValues(int errorCode, uint32_t updateInfoLength,const uint8_t* updateInfo); + + + //inlines + int GetUpdateInfoLength() const { return mUpdateInfoLength; } + const uint8_t* GetUpdateInfo() const { return mUpdateInfo; } + + //operators + bool operator==(const AEReportAttestationResponse& other) const; + AEReportAttestationResponse& operator=(const AEReportAttestationResponse& other); + + //checks + bool check(); + void visit(IAEResponseVisitor& visitor); + + protected: + void ReleaseMemory(); + void CopyFields(int errorCode, uint32_t updateInfoLength, const uint8_t* updateInfo); + + uint32_t mUpdateInfoLength; + uint8_t* mUpdateInfo; +}; + +#endif diff --git a/psw/ae/common/inc/Config.h b/psw/ae/common/inc/Config.h new file mode 100644 index 0000000000..801fd8101f --- /dev/null +++ b/psw/ae/common/inc/Config.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _PSW_COMMON_INC_CONFIG_H +#define _PSW_COMMON_INC_CONFIG_H + + +#ifndef CONFIG_SOCKET_PATH + #define CONFIG_SOCKET_PATH "sgx_aesm_socket_base" +#endif /* CONFIG_SOCKET_PATH */ + + +#define MAX_MEMORY_ALLOCATION 1<<25 //32 MB +#define IPC_LATENCY 10000 +#define AESM_IPC_LATENCY 1000 //1 second (AESM must be fair; also, clients should finsih writing and reading with speed) + //This timeout could be reduced even more +#endif + diff --git a/psw/ae/common/inc/IAERequest.h b/psw/ae/common/inc/IAERequest.h new file mode 100644 index 0000000000..9254c0b3d4 --- /dev/null +++ b/psw/ae/common/inc/IAERequest.h @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_REQUEST_H__ +#define __AE_REQUEST_H__ + +#include +#include +#include +#include +#include + +struct AEMessage{ + uint32_t size; + char* data; + +#ifdef __cplusplus + AEMessage(): size(0), data(NULL) {} + ~AEMessage(){ + if (data != NULL) delete [] data; + data = NULL; + } + + bool operator==(const AEMessage &other) const + { + if (this == &other) return true; + if (this == NULL) return false; + + if (size != other.size) return false; + if (memcmp(data, other.data, size) != 0) return false; + return true; + } + + void copyFields(const AEMessage& other) + { + size = other.size; + + if (other.data == NULL) + data = NULL; + else + { + data = new char[size]; + + memcpy(data, other.data, size); + } + } + + AEMessage& operator=(const AEMessage& other) + { + if (this == &other) + return *this; + + if (data != NULL) + delete [] data; + + copyFields(other); + + return *this; + } + + AEMessage(const AEMessage& other) + { + copyFields(other); + } +#endif +}; + +class ISerializer; +class IAEResponse; +class IAESMLogic; + +class AECloseSessionRequest; +class AEExchangeReportRequest; +class AEInvokeServiceRequest; +class AECreateSessionRequest; +class AEReportAttestationRequest; +class AEGetLaunchTokenRequest; +class AEGetQuoteRequest; +class AEInitQuoteRequest; +class AEGetPsCapRequest; + +class IAERequestVisitor +{ + public: + virtual void visitInitQuoteRequest(AEInitQuoteRequest&) = 0; + virtual void visitGetQuoteRequest(AEGetQuoteRequest&) = 0; + virtual void visitGetLaunchTokenRequest(AEGetLaunchTokenRequest&) = 0; + virtual void visitReportAttestationRequest(AEReportAttestationRequest&) = 0; + virtual void visitCreateSessionRequest(AECreateSessionRequest&) = 0; + virtual void visitInvokeServiceRequest(AEInvokeServiceRequest&) = 0; + virtual void visitExchangeReportRequest(AEExchangeReportRequest&) = 0; + virtual void visitCloseSessionRequest(AECloseSessionRequest&) = 0; + virtual void visitGetPsCapRequest(AEGetPsCapRequest&) = 0; + + virtual ~IAERequestVisitor() = 0; +}; + +class IAERequest{ + public: + typedef enum {QUOTING_CLASS, LAUNCH_CLASS, PLATFORM_CLASS} RequestClass; + + IAERequest(uint32_t timeout = IPC_LATENCY) : mTimeout(timeout), mValidSizeCheck(false) {} //constructor with default parameter + virtual ~IAERequest() {} + + virtual void visit(IAERequestVisitor&) = 0; + virtual AEMessage* serialize(ISerializer* serializer) =0; + + virtual RequestClass getRequestClass() = 0; + + //this method is added especially for future compatibility (may be used to check thigs like the message MAC) + virtual bool check() {return false;} //although only some requests will need more complex logic here, this will default to + //invalid. Validity needs to be explicitly declared in children :) + virtual IAEResponse* execute(IAESMLogic* aesmLogic) =0; + + //timeout + uint32_t GetTimeout() const { return mTimeout; } + protected: + uint32_t mTimeout; + bool mValidSizeCheck; +}; + +#endif diff --git a/psw/ae/common/inc/IAEResponse.h b/psw/ae/common/inc/IAEResponse.h new file mode 100644 index 0000000000..0fb9719b99 --- /dev/null +++ b/psw/ae/common/inc/IAEResponse.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_RESPONSE_H +#define __AE_RESPONSE_H + +#include +#include +#include +#include + + +struct AEMessage; +class ISerializer; + +class AECloseSessionResponse; +class AEExchangeReportResponse; +class AEInvokeServiceResponse; +class AECreateSessionResponse; +class AEReportAttestationResponse; +class AEGetLaunchTokenResponse; +class AEGetQuoteResponse; +class AEInitQuoteResponse; +class AEGetPsCapResponse; + +#include + +class IAEResponseVisitor +{ + public: + virtual void visitInitQuoteResponse(AEInitQuoteResponse&) = 0; + virtual void visitGetQuoteResponse(AEGetQuoteResponse&) = 0; + virtual void visitGetLaunchTokenResponse(AEGetLaunchTokenResponse&) = 0; + virtual void visitReportAttestationResponse(AEReportAttestationResponse&) = 0; + virtual void visitCreateSessionResponse(AECreateSessionResponse&) = 0; + virtual void visitInvokeServiceResponse(AEInvokeServiceResponse&) = 0; + virtual void visitExchangeReportResponse(AEExchangeReportResponse&) = 0; + virtual void visitCloseSessionResponse(AECloseSessionResponse&) = 0; + virtual void visitGetPsCapResponse(AEGetPsCapResponse&) = 0; + + virtual ~IAEResponseVisitor() {}; +}; + +class IAEResponse{ + public: + IAEResponse() : mErrorCode(SGX_ERROR_UNEXPECTED),mValidSizeCheck(false) {} + inline virtual ~IAEResponse() {} + virtual AEMessage* serialize(ISerializer* serializer) =0; + virtual bool inflateWithMessage(AEMessage* message, ISerializer* serializer) =0; + + //operators + virtual bool operator==(const IAEResponse& other) const {return this == &other;} + + //this method is added especially for future compatibility (may be used to check thigs like the message MAC) + virtual bool check() {return false;} //although only some responses will need more complex logic here, this will default to + //invalid. Validity needs to be explicitly declared in children :) + + inline int GetErrorCode() const { return mErrorCode; } + inline void SetErrorCode(uint32_t error) { mErrorCode = error; } + + virtual void visit(IAEResponseVisitor& visitor) = 0; + + protected: + uint32_t mErrorCode; + bool mValidSizeCheck; + +}; + +#endif diff --git a/psw/ae/common/inc/IAESMLogic.h b/psw/ae/common/inc/IAESMLogic.h new file mode 100644 index 0000000000..95d685b9ab --- /dev/null +++ b/psw/ae/common/inc/IAESMLogic.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _I_AESM_LOGIC_H +#define _I_AESM_LOGIC_H + +#include +#include +#include + +class IAESMLogic { + public: + virtual aesm_error_t initQuote(uint8_t *target_info, + uint32_t target_info_length, + uint8_t *gid, + uint32_t gid_length) = 0; + + virtual aesm_error_t getQuote(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, uint8_t* quote, + uint32_t qe_reportSize, uint8_t* qe_report) = 0; + + virtual aesm_error_t createSession(uint32_t *session_id, + uint8_t *se_dh_msg1, + uint32_t se_dh_msg1_size) = 0; + + virtual aesm_error_t closeSession(uint32_t sessionId) = 0; + + virtual aesm_error_t exchangeReport(uint32_t session_id, + const uint8_t* se_dh_msg2, + uint32_t se_dh_msg2_size, + uint8_t* se_dh_msg3, + uint32_t se_dh_msg3_size) = 0; + + virtual aesm_error_t getLaunchToken(const uint8_t* measurement, uint32_t measurement_size, + const uint8_t *public_key, uint32_t public_key_size, + const uint8_t* se_attributes, uint32_t se_attributes_size, + uint8_t** launch_token, uint32_t* launch_tocken_size) = 0; + + virtual aesm_error_t invokeService(const uint8_t *pse_message_req, + uint32_t pse_message_req_size, + uint8_t *pse_message_resp, + uint32_t pse_message_resp_size) = 0; + + virtual aesm_error_t getPsCap(uint64_t* ps_cap) = 0; + + virtual aesm_error_t reportAttestationStatus(uint8_t* platform_info, uint32_t platform_info_size, + uint32_t attestation_error_code, + uint8_t* update_info, uint32_t update_info_size) = 0; + virtual void service_stop() = 0; + virtual ~IAESMLogic(){}; +}; + +#endif diff --git a/psw/ae/common/inc/ICommunicationSocket.h b/psw/ae/common/inc/ICommunicationSocket.h new file mode 100644 index 0000000000..c1639d6752 --- /dev/null +++ b/psw/ae/common/inc/ICommunicationSocket.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_GATEWAY_H +#define __AE_GATEWAY_H + +#include +#include +#include + +class SockDisconnectedException : public std::exception { +}; + +class ICommunicationSocket{ + public: + virtual ~ICommunicationSocket() {} + + //init returns true on successful connection + virtual bool init() =0; + virtual char* readRaw(ssize_t length) = 0; //throw(SockDisconnectedException) = 0; + virtual ssize_t writeRaw(const char* data, ssize_t length) = 0; + virtual int getSockDescriptor() = 0; + virtual bool wasTimeoutDetected() = 0; + virtual bool setTimeout(uint32_t milliseconds) = 0; + protected: + int mSocket; +}; + +#endif + diff --git a/psw/ae/common/inc/ISerializer.h b/psw/ae/common/inc/ISerializer.h new file mode 100644 index 0000000000..6da6d931ec --- /dev/null +++ b/psw/ae/common/inc/ISerializer.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_SERIALIZER_H_ +#define __AE_SERIALIZER_H_ + +struct AEMessage; + +class AEInitQuoteRequest; +class AEInitQuoteResponse; + +class AEGetQuoteRequest; +class AEGetQuoteResponse; + +class AEGetLaunchTokenRequest; +class AEGetLaunchTokenResponse; + +class AECreateSessionRequest; +class AECreateSessionResponse; + +class AEInvokeServiceRequest; +class AEInvokeServiceResponse; + +class AEExchangeReportRequest; +class AEExchangeReportResponse; + +class AECloseSessionRequest; +class AECloseSessionResponse; + +class AEGetPsCapRequest; +class AEGetPsCapResponse; + +class AEReportAttestationRequest; +class AEReportAttestationResponse; + + +class IAERequest; +class IAEResponse; + +class ISerializer{ + public: + //request serializers + virtual AEMessage* serialize(AEInitQuoteRequest* request) = 0; + virtual AEMessage* serialize(AEGetQuoteRequest* request) = 0; + virtual AEMessage* serialize(AEGetLaunchTokenRequest* request) = 0; + virtual AEMessage* serialize(AECreateSessionRequest* request) = 0; + virtual AEMessage* serialize(AEInvokeServiceRequest* request) = 0; + virtual AEMessage* serialize(AEExchangeReportRequest* request) = 0; + virtual AEMessage* serialize(AECloseSessionRequest* request) = 0; + virtual AEMessage* serialize(AEGetPsCapRequest* request) = 0; + virtual AEMessage* serialize(AEReportAttestationRequest* request) = 0; + + //response serializers + virtual AEMessage* serialize(AEInitQuoteResponse* response) = 0; + virtual AEMessage* serialize(AEGetQuoteResponse* response) = 0; + virtual AEMessage* serialize(AEGetLaunchTokenResponse* response) = 0; + virtual AEMessage* serialize(AECreateSessionResponse* response) = 0; + virtual AEMessage* serialize(AEInvokeServiceResponse* response) = 0; + virtual AEMessage* serialize(AEExchangeReportResponse* response) = 0; + virtual AEMessage* serialize(AECloseSessionResponse* response) = 0; + virtual AEMessage* serialize(AEGetPsCapResponse* response) = 0; + virtual AEMessage* serialize(AEReportAttestationResponse* response) = 0; + + //request inflater -> will inflate request objects by unmarshaling communication level data (this will be used by server) + virtual IAERequest* inflateRequest(AEMessage* message) = 0; + + //response inflater -> will inflate response objects with data by unmarshaling communication level data + virtual bool inflateResponse(AEMessage* message, AEInitQuoteResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AEGetQuoteResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AEGetLaunchTokenResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AECreateSessionResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AEInvokeServiceResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AEExchangeReportResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AECloseSessionResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AEGetPsCapResponse* response) = 0; + virtual bool inflateResponse(AEMessage* message, AEReportAttestationResponse* response) = 0; + + + virtual ~ISerializer() {} +}; + +#endif diff --git a/psw/ae/common/inc/ISocketFactory.h b/psw/ae/common/inc/ISocketFactory.h new file mode 100644 index 0000000000..e4ddff35b9 --- /dev/null +++ b/psw/ae/common/inc/ISocketFactory.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_SOCKET_FACTORY_H +#define __AE_SOCKET_FACTORY_H + +#include + +class ISocketFactory +{ +public: + virtual ~ISocketFactory() {} + + virtual ICommunicationSocket* NewCommunicationSocket() = 0; +}; + +#endif diff --git a/psw/ae/common/inc/ITransporter.h b/psw/ae/common/inc/ITransporter.h new file mode 100644 index 0000000000..cb7e8e4c1e --- /dev/null +++ b/psw/ae/common/inc/ITransporter.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_TRANSPORTER_H +#define __AE_TRANSPORTER_H + +class IAERequest; +class IAEResponse; +class ICommunicationSocket; + +#include + +class ITransporter{ + public: + virtual ~ITransporter() {}; + + virtual uae_oal_status_t transact(IAERequest* request, IAEResponse* response) = 0; + virtual IAERequest* receiveRequest(ICommunicationSocket* sock) = 0; //throw(SockDisconnectedException) = 0; + virtual uae_oal_status_t sendResponse(IAEResponse* response, ICommunicationSocket* sock) = 0; + + protected: +}; + +#endif diff --git a/psw/ae/common/inc/NonBlockingUnixCommunicationSocket.h b/psw/ae/common/inc/NonBlockingUnixCommunicationSocket.h new file mode 100644 index 0000000000..3abc1e9883 --- /dev/null +++ b/psw/ae/common/inc/NonBlockingUnixCommunicationSocket.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_NON_BLOCKING_COMM_SOCKET_H +#define __AE_NON_BLOCKING_COMM_SOCKET_H + +#include + +#define MAX_EVENTS 12 + +class NonBlockingUnixCommunicationSocket : public UnixCommunicationSocket +{ +public: + NonBlockingUnixCommunicationSocket(const char* socketbase) : UnixCommunicationSocket(socketbase), mEvents(NULL), mEpoll(-1) {} + NonBlockingUnixCommunicationSocket(int socket) : UnixCommunicationSocket(socket), mEvents(NULL), mEpoll(-1) {} + + ~NonBlockingUnixCommunicationSocket(); + + bool init(); + char* readRaw(ssize_t length); //throw(SockDisconnectedException) = 0; + ssize_t writeRaw(const char* data, ssize_t length); + int getSockDescriptor(); + bool wasTimeoutDetected(); + bool setTimeout(uint32_t milliseconds); + + void Cancel() const; + +protected: + bool MakeNonBlocking(); + ssize_t partialRead(char* buffer, ssize_t maxLength); + + //members + struct epoll_event *mEvents; //epoll for events on two sources: 0->special command pipe. 1->the socket + int mEpoll; + int mCommandPipe[2]; +private: + //non-copyable + NonBlockingUnixCommunicationSocket(const NonBlockingUnixCommunicationSocket&); + NonBlockingUnixCommunicationSocket& operator=(const NonBlockingUnixCommunicationSocket&); +}; + +#endif diff --git a/psw/ae/common/inc/NonBlockingUnixSocketFactory.h b/psw/ae/common/inc/NonBlockingUnixSocketFactory.h new file mode 100644 index 0000000000..befaefd082 --- /dev/null +++ b/psw/ae/common/inc/NonBlockingUnixSocketFactory.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_NON_BLOCKING_UNIX_SOCKET_FACTORY_H +#define __AE_NON_BLOCKING_UNIX_SOCKET_FACTORY_H + +#include + +class NonBlockingUnixSocketFactory : public UnixSocketFactory +{ +public: + NonBlockingUnixSocketFactory(const char* socketbase) : UnixSocketFactory(socketbase) {} + ~NonBlockingUnixSocketFactory() {} + + ICommunicationSocket* NewCommunicationSocket(); +}; + +#endif diff --git a/psw/ae/common/inc/ProtobufSerializer.h b/psw/ae/common/inc/ProtobufSerializer.h new file mode 100644 index 0000000000..b2e694334b --- /dev/null +++ b/psw/ae/common/inc/ProtobufSerializer.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_PROTOBUF_SERIALIZER +#define __AE_PROTOBUF_SERIALIZER + +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wconversion" +#include +#pragma GCC diagnostic pop + +class IAERequest; +class IAEResponse; + + +class ProtobufSerializer : public ISerializer{ + public: + ~ProtobufSerializer() {} + + //request serializers + AEMessage* serialize(AEInitQuoteRequest* request); + AEMessage* serialize(AEGetQuoteRequest* request); + AEMessage* serialize(AEGetLaunchTokenRequest* request); + AEMessage* serialize(AECreateSessionRequest* request); + AEMessage* serialize(AEInvokeServiceRequest* request); + AEMessage* serialize(AEExchangeReportRequest* request); + AEMessage* serialize(AECloseSessionRequest* request); + AEMessage* serialize(AEGetPsCapRequest* request); + AEMessage* serialize(AEReportAttestationRequest* request); + + //response serializers + AEMessage* serialize(AEInitQuoteResponse* response); + AEMessage* serialize(AEGetQuoteResponse* response); + AEMessage* serialize(AEGetLaunchTokenResponse* response); + AEMessage* serialize(AECreateSessionResponse* response); + AEMessage* serialize(AEInvokeServiceResponse* response); + AEMessage* serialize(AEExchangeReportResponse* response); + AEMessage* serialize(AECloseSessionResponse* response); + AEMessage* serialize(AEGetPsCapResponse* response); + AEMessage* serialize(AEReportAttestationResponse* response); + + //base inflate request + IAERequest* inflateRequest(AEMessage* message); + + //response inflaters + bool inflateResponse(AEMessage* message, AEInitQuoteResponse* response); + bool inflateResponse(AEMessage* message, AEGetQuoteResponse* response); + bool inflateResponse(AEMessage* message, AEGetLaunchTokenResponse* response); + bool inflateResponse(AEMessage* message, AECreateSessionResponse* response); + bool inflateResponse(AEMessage* message, AEInvokeServiceResponse* response); + bool inflateResponse(AEMessage* message, AEExchangeReportResponse* response); + bool inflateResponse(AEMessage* message, AECloseSessionResponse* response); + bool inflateResponse(AEMessage* message, AEGetPsCapResponse* response); + bool inflateResponse(AEMessage* message, AEReportAttestationResponse* response); + + private: + //request inflaters + IAERequest* inflateInitQuoteRequest(aesm::message::Request* reqMsg); + IAERequest* inflateGetQuoteRequest(aesm::message::Request* reqMsg); + IAERequest* inflateCloseSessionRequest(aesm::message::Request* reqMsg); + IAERequest* inflateCreateSessionRequest(aesm::message::Request* reqMsg); + IAERequest* inflateExchangeReportRequest(aesm::message::Request* reqMsg); + IAERequest* inflateGetLaunchTokenRequest(aesm::message::Request* reqMsg); + IAERequest* inflateInvokeServiceRequest(aesm::message::Request* reqMsg); + IAERequest* inflateGetPsCapRequest(aesm::message::Request* reqMsg); + IAERequest* inflateReportAttestationErrorRequest(aesm::message::Request* reqMsg); +}; + +#endif diff --git a/psw/ae/common/inc/SocketTransporter.h b/psw/ae/common/inc/SocketTransporter.h new file mode 100644 index 0000000000..453b97fdb3 --- /dev/null +++ b/psw/ae/common/inc/SocketTransporter.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_UNIX_SOCKET_TRANSPORTER_H +#define __AE_UNIX_SOCKET_TRANSPORTER_H + +#include +#include +#include +#include + +#include + +class ISerializer; +class ICommunicationSocket; + +class SocketTransporter : public ITransporter{ + public: + SocketTransporter(ISocketFactory* socketFactory, ISerializer* serializer); + ~SocketTransporter(); + + uae_oal_status_t transact(IAERequest* request, IAEResponse* response); + + IAERequest* receiveRequest(ICommunicationSocket* sock);// throw(SockDisconnectedException); + uae_oal_status_t sendResponse(IAEResponse* response, ICommunicationSocket* sock); + + protected: + ISocketFactory* mSocketFactory; + ISerializer* mSerializer; + + private: + uae_oal_status_t sendMessage(AEMessage *message, ICommunicationSocket* sock); + AEMessage* receiveMessage(ICommunicationSocket* sock);// throw(SockDisconnectedException); + SocketTransporter& operator=(const SocketTransporter&); + SocketTransporter(const SocketTransporter&); +}; + +#endif diff --git a/psw/ae/common/inc/UnixCommunicationSocket.h b/psw/ae/common/inc/UnixCommunicationSocket.h new file mode 100644 index 0000000000..1c5cbebaea --- /dev/null +++ b/psw/ae/common/inc/UnixCommunicationSocket.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_UNIX_SOCKET_GATEWAY_H +#define __AE_UNIX_SOCKET_GATEWAY_H + +#include +#include + +class UnixCommunicationSocket : public ICommunicationSocket{ + public: + UnixCommunicationSocket(const char* socketbase); + UnixCommunicationSocket(int socket); + + ~UnixCommunicationSocket(); + + virtual bool init(); + virtual ssize_t writeRaw(const char* data, ssize_t length); + virtual char* readRaw(ssize_t length);// throw(SockDisconnectedException); + + void disconnect(); + virtual int getSockDescriptor(); + + //timeout + virtual bool setTimeout(uint32_t timeout_milliseconds); + virtual bool wasTimeoutDetected() { return mWasTimeout; } + protected: + char* mSocketBase; + bool mWasTimeout; + + void MarkStartTime(); + bool CheckForTimeout(); + + struct timeval mStartTime; + uint32_t mTimeoutMseconds; + + private: + //non-copyable + UnixCommunicationSocket(const UnixCommunicationSocket&); + UnixCommunicationSocket& operator=(const UnixCommunicationSocket&); +}; + +#endif diff --git a/psw/ae/common/inc/UnixSocketFactory.h b/psw/ae/common/inc/UnixSocketFactory.h new file mode 100644 index 0000000000..dd4b06e3f3 --- /dev/null +++ b/psw/ae/common/inc/UnixSocketFactory.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_UNIX_SOCKET_FACTORY_H +#define __AE_UNIX_SOCKET_FACTORY_H + +#include + +class UnixSocketFactory : public ISocketFactory +{ +public: + UnixSocketFactory(const char* socketbase); + ~UnixSocketFactory(); + + ICommunicationSocket* NewCommunicationSocket(); + +protected: + char* mSocketBase; +private: + UnixSocketFactory(const UnixSocketFactory&); // Prevent copy-construction + UnixSocketFactory& operator=(const UnixSocketFactory&); // Prevent assignment + +}; + +#endif diff --git a/psw/ae/common/pek_pub_key.cpp b/psw/ae/common/pek_pub_key.cpp new file mode 100644 index 0000000000..59940d5b1c --- /dev/null +++ b/psw/ae/common/pek_pub_key.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "arch.h" +#include "sgx_tcrypto.h" +#include "pek_pub_key.h" +#include "pve_qe_common.h" +#include +#include "peksk_pub.hh" + + +//Function to verify the ECDSA signature of a PEK +//SHA1 value for integrity checking is not verified since the ECDSA verification could make sure the integrity at the sametime. +sgx_status_t check_pek_signature(const signed_pek_t& signed_pek, uint8_t *result) +{ + sgx_status_t status = SGX_SUCCESS; + sgx_ecc_state_handle_t handle= 0; + sgx_ec256_signature_t ec_signature; + status = sgx_ecc256_open_context(&handle); + if(SGX_SUCCESS!=status){ + return status; + } + se_static_assert(sizeof(ec_signature)==sizeof(signed_pek.pek_signature)); + memcpy(&ec_signature, signed_pek.pek_signature, sizeof(signed_pek.pek_signature)); + SWAP_ENDIAN_32B(ec_signature.x); + SWAP_ENDIAN_32B(ec_signature.y); + status = sgx_ecdsa_verify(reinterpret_cast(&signed_pek), + static_cast(sizeof(signed_pek.n)+sizeof(signed_pek.e)), + const_cast(&g_pek_pub_key_little_endian), + &ec_signature, + result, + handle); + (void)sgx_ecc256_close_context(handle); + return status; +} diff --git a/psw/ae/common/proto/Makefile b/psw/ae/common/proto/Makefile new file mode 100644 index 0000000000..bb7b163f30 --- /dev/null +++ b/psw/ae/common/proto/Makefile @@ -0,0 +1,58 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +parent-dir = $(patsubst %/,%,$(dir $(1:%/=%))) +my-dir = $(call parent-dir,$(lastword $(MAKEFILE_LIST))) +################################################################################ + +LOCAL_PATH := $(call my-dir) +BASE_DIR := $(LOCAL_PATH)/../../../.. +ANDROID_DIR := $(BASE_DIR)/android +include $(BASE_DIR)/buildenv.mk +PROTOC := protoc +################################################################################ + +proto_sources := messages.proto +proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) +proto_generated_cc_sources := $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)) +proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources)) + +all: $(proto_generated_headers) + +$(proto_generated_headers): %.pb.h: %.pb.cc + +$(proto_generated_cc_sources): PRIVATE_PROTO_OUT_DIR := $(LOCAL_PATH) +$(proto_generated_cc_sources): PRIVATE_PROTO_PATH_DIR := $(LOCAL_PATH) +$(proto_generated_cc_sources): %.pb.cc: %.proto + $(PROTOC) --cpp_out=$(PRIVATE_PROTO_OUT_DIR) --proto_path=$(PRIVATE_PROTO_PATH_DIR) $^ + +clean:: + rm -f $(proto_generated_cc_sources) $(proto_generated_headers) diff --git a/psw/ae/common/proto/messages.proto b/psw/ae/common/proto/messages.proto new file mode 100644 index 0000000000..3fdc784019 --- /dev/null +++ b/psw/ae/common/proto/messages.proto @@ -0,0 +1,131 @@ +package aesm.message; + +message Request{ + + message InitQuoteRequest{ + optional uint32 timeout = 9; + } + + message GetQuoteRequest{ + required bytes report = 1; + required uint32 quote_type = 2; + required bytes spid = 3; + optional bytes nonce = 4; + optional bytes sig_rl = 5; + required uint32 buf_size = 6; + optional bool qe_report = 7; + optional uint32 timeout = 9; + } + + message GetLaunchTokenRequest{ + required bytes mr_enclave = 1; + required bytes mr_signer = 2; + required bytes se_attributes = 3; + optional uint32 timeout = 9; + } + + message ReportAttestationErrorRequest{ + required bytes platform_info = 1; + required uint32 attestation_error_code = 2; + required uint32 update_info_size =3; + optional uint32 timeout = 9; + } + + //private API + message CreateSessionRequest{ + required uint32 dh_msg1_size = 1; + optional uint32 timeout = 9; + } + + message InvokeServiceRequest{ + required bytes pse_message = 1; + required uint32 pse_resp_size = 2; + optional uint32 timeout = 9; + } + + message ExchangeReportRequest{ + required uint32 session_id = 1; + required bytes se_dh_msg2 = 2; + required uint32 se_dh_msg3_size = 3; + optional uint32 timeout = 9; + } + + message CloseSessionRequest{ + required uint32 session_id = 1; + optional uint32 timeout = 9; + } + + message GetPsCapRequest{ + optional uint32 timeout = 9; + } + + optional InitQuoteRequest initQuoteReq = 1; + optional GetQuoteRequest getQuoteReq = 2; + optional GetLaunchTokenRequest getLicTokenReq = 3; + optional ReportAttestationErrorRequest reportErrReq = 4; + optional CreateSessionRequest createSessionReq = 5; + optional InvokeServiceRequest invokeServiceReq = 6; + optional ExchangeReportRequest exchangeReportReq = 7; + optional CloseSessionRequest closeSessionReq = 8; + optional GetPsCapRequest getPsCapReq = 9; +} + +message Response{ + + message InitQuoteResponse{ + required uint32 errorCode = 1 [default = 1]; + optional bytes targetInfo = 2; + optional bytes gid = 3; + } + + message GetQuoteResponse{ + required uint32 errorCode = 1 [default = 1]; + optional bytes quote = 2; + optional bytes qe_report = 3; + } + + message GetLaunchTokenResponse{ + required uint32 errorCode = 1 [default = 1]; + optional bytes token = 2; + } + + message ReportAttestationErrorResponse{ + required uint32 errorCode = 1 [default = 1]; + optional bytes platform_update_info = 2; + } + + //private API + message CreateSessionResponse{ + required uint32 errorCode = 1 [default = 1]; + optional uint32 session_id = 2; + optional bytes se_dh_msg1 = 3; + } + + message InvokeServiceResponse{ + required uint32 errorCode = 1 [default = 1]; + optional bytes pse_message = 2; + } + + message ExchangeReportResponse{ + required uint32 errorCode = 1 [default = 1]; + optional bytes se_dh_msg3 = 2; + } + + message CloseSessionResponse{ + required uint32 errorCode = 1 [default = 1]; + } + + message GetPsCapResponse{ + required uint32 errorCode = 1 [default = 1]; + optional uint64 ps_cap = 2; + } + optional InitQuoteResponse initQuoteRes = 1; + optional GetQuoteResponse getQuoteRes = 2; + optional GetLaunchTokenResponse getLicTokenRes = 3; + optional ReportAttestationErrorResponse reportErrRes = 4; + optional CreateSessionResponse createSessionRes = 5; + optional InvokeServiceResponse invokeServiceRes = 6; + optional ExchangeReportResponse exchangeReportRes = 7; + optional CloseSessionResponse closeSessionRes = 8; + optional GetPsCapResponse getPsCapRes = 9; +} diff --git a/psw/ae/common/pve_pub_key.cpp b/psw/ae/common/pve_pub_key.cpp new file mode 100644 index 0000000000..19dc02cbfc --- /dev/null +++ b/psw/ae/common/pve_pub_key.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "byte_order.h" +#include "epid_pve_type.h" +#include "sgx_tcrypto.h" +#include "ipp_wrapper.h" + + +static void get_provision_server_rsa_key_little_endian_order(const signed_pek_t& pek, signed_pek_t& little_endian_key) +{ + uint32_t i; + for(i=0;i(little_endian_key.n), + reinterpret_cast(&little_endian_key.e), + rsa_pub_key); + if(status != ippStsNoErr){ + return status; + } + return ippStsNoErr; +} diff --git a/psw/ae/common/se_sig_rl.cpp b/psw/ae/common/se_sig_rl.cpp new file mode 100644 index 0000000000..0702890406 --- /dev/null +++ b/psw/ae/common/se_sig_rl.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "stdint.h" +#include "se_sig_rl.h" +#include "byte_order.h" +#include "sgx_quote.h" +#include "se_quote_internal.h" + +uint64_t se_get_sig_rl_size(const se_sig_rl_t *p_sig_rl) +{ + uint64_t n2 = (p_sig_rl) ? lv_ntohl(p_sig_rl->sig_rl.n2) : 0; + return(sizeof(se_sig_rl_t) - sizeof(p_sig_rl->sig_rl.BK[0]) + + n2 * sizeof(p_sig_rl->sig_rl.BK[0]) + 2 * SE_ECDSA_SIGN_SIZE); +} + +sgx_status_t sgx_get_quote_size(const uint8_t *sig_rl, uint32_t* p_quote_size) +{ + if(!p_quote_size) + return SGX_ERROR_INVALID_PARAMETER; + uint64_t quote_size = 0; + uint64_t sign_size = 0; + uint64_t n2 = 0; + const se_sig_rl_t *p_sig_rl = reinterpret_cast(sig_rl); + + if(sig_rl) + { + if(p_sig_rl->protocol_version != SE_EPID_SIG_RL_VERSION + || p_sig_rl->epid_identifier != SE_EPID_SIG_RL_ID) + { + return SGX_ERROR_INVALID_PARAMETER; + } + } + + n2 = (sig_rl) ? lv_ntohl(p_sig_rl->sig_rl.n2) : 0; + sign_size = sizeof(EPIDSignature) - sizeof(NRProof) + n2*sizeof(NRProof); + quote_size = SE_QUOTE_LENGTH_WITHOUT_SIG + sign_size; + if (quote_size >= 1ull<<32) + { + return SGX_ERROR_INVALID_PARAMETER; + } + *p_quote_size = static_cast(quote_size); + return SGX_SUCCESS; +} + diff --git a/psw/ae/common/src/AECloseSessionRequest.cpp b/psw/ae/common/src/AECloseSessionRequest.cpp new file mode 100644 index 0000000000..f8df312457 --- /dev/null +++ b/psw/ae/common/src/AECloseSessionRequest.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include +#include + +AECloseSessionRequest::AECloseSessionRequest() +:mSessionId(0) +{ +} + +AECloseSessionRequest::AECloseSessionRequest(uint32_t sessionId, uint32_t timeout) +:mSessionId(0) + +{ + CopyFields(sessionId, timeout); +} + +AECloseSessionRequest::AECloseSessionRequest(const AECloseSessionRequest& other) +:IAERequest(other), mSessionId(0) +{ + CopyFields(other.mSessionId, other.mTimeout); +} + +AECloseSessionRequest::~AECloseSessionRequest() +{ + ReleaseMemory(); +} + +void AECloseSessionRequest::ReleaseMemory() +{ + mSessionId = 0; +} + +void AECloseSessionRequest::CopyFields(uint32_t sessionId, uint32_t timeout) +{ + mSessionId = sessionId; + mTimeout = timeout; +} + +AEMessage* AECloseSessionRequest::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +void AECloseSessionRequest::inflateValues(uint32_t sessionId, uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(sessionId, timeout); +} + +bool AECloseSessionRequest::operator==(const AECloseSessionRequest& other) const +{ + if (this == &other) + return true; + + if (mSessionId != other.mSessionId || + mTimeout != other.mTimeout) + return false; + + return true; +} + +AECloseSessionRequest& AECloseSessionRequest::operator=(const AECloseSessionRequest& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mSessionId, other.mTimeout); + + return *this; +} + +bool AECloseSessionRequest::check() +{ + return true; +} + +IAERequest::RequestClass AECloseSessionRequest::getRequestClass() +{ + return PLATFORM_CLASS; +} + +IAEResponse* AECloseSessionRequest::execute(IAESMLogic* aesmLogic) +{ + aesm_error_t result; + result = aesmLogic->closeSession(mSessionId); + + return new AECloseSessionResponse(result); +} + +void AECloseSessionRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitCloseSessionRequest(*this); +} diff --git a/psw/ae/common/src/AECloseSessionResponse.cpp b/psw/ae/common/src/AECloseSessionResponse.cpp new file mode 100644 index 0000000000..52ec5d4d41 --- /dev/null +++ b/psw/ae/common/src/AECloseSessionResponse.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AECloseSessionResponse::AECloseSessionResponse() +{ +} + +AECloseSessionResponse::AECloseSessionResponse(int errorCode) +{ + CopyFields(errorCode); +} + +AECloseSessionResponse::AECloseSessionResponse(const AECloseSessionResponse& other) +{ + CopyFields(other.mErrorCode); +} + +AECloseSessionResponse::~AECloseSessionResponse() +{ + ReleaseMemory(); +} + +void AECloseSessionResponse::ReleaseMemory() +{ +} + +void AECloseSessionResponse::CopyFields(int errorCode) +{ + mErrorCode = errorCode; +} + +AEMessage* AECloseSessionResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AECloseSessionResponse::inflateWithMessage(AEMessage* message, ISerializer* serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AECloseSessionResponse::inflateValues(int errorCode) +{ + ReleaseMemory(); + + CopyFields(errorCode); +} + +bool AECloseSessionResponse::operator==(const AECloseSessionResponse& other) const +{ + if (this == &other) + return true; + + if (mErrorCode != other.mErrorCode) + return false; + + return true; +} + +AECloseSessionResponse& AECloseSessionResponse::operator=(const AECloseSessionResponse& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mErrorCode); + + return *this; +} + +bool AECloseSessionResponse::check() +{ + if (mErrorCode != SGX_SUCCESS) + return false; + return true; +} + +void AECloseSessionResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitCloseSessionResponse(*this); +} diff --git a/psw/ae/common/src/AECreateSessionRequest.cpp b/psw/ae/common/src/AECreateSessionRequest.cpp new file mode 100644 index 0000000000..ca7c30f4fb --- /dev/null +++ b/psw/ae/common/src/AECreateSessionRequest.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include + +AECreateSessionRequest::AECreateSessionRequest() +:mDHMsg1Size(0) +{ +} + +AECreateSessionRequest::AECreateSessionRequest(uint32_t dhMsg1Size, uint32_t timeout) +:mDHMsg1Size(0) +{ + CopyFields(dhMsg1Size, timeout); +} + +AECreateSessionRequest::AECreateSessionRequest(const AECreateSessionRequest& other) +:IAERequest(other), mDHMsg1Size(0) +{ + CopyFields(other.mDHMsg1Size, other.mTimeout); +} + +AECreateSessionRequest::~AECreateSessionRequest() +{ + ReleaseMemory(); +} + +void AECreateSessionRequest::ReleaseMemory() +{ + //none for now +} + +void AECreateSessionRequest::CopyFields(uint32_t dhMsg1Size, uint32_t timeout) +{ + if(dhMsg1Size <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mDHMsg1Size = dhMsg1Size; + mTimeout = timeout; +} + +AEMessage* AECreateSessionRequest::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +void AECreateSessionRequest::inflateValues(uint32_t dhMsg1Size, uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(dhMsg1Size, timeout); +} + +bool AECreateSessionRequest::operator==(const AECreateSessionRequest& other) const +{ + if (this == &other) + return true; + + if (mDHMsg1Size != other.mDHMsg1Size || + mTimeout != other.mTimeout) + return false; + + return true; +} + +AECreateSessionRequest& AECreateSessionRequest::operator=(const AECreateSessionRequest& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mDHMsg1Size, mTimeout); + + return *this; +} + +bool AECreateSessionRequest::check() +{ + if (mValidSizeCheck == false) + return false; + + return true; +} + +IAERequest::RequestClass AECreateSessionRequest::getRequestClass() { + return PLATFORM_CLASS; +} + +IAEResponse* AECreateSessionRequest::execute(IAESMLogic* aesmLogic) { + uint8_t* dh_msg1 = new uint8_t[mDHMsg1Size]; + uint32_t sid = 0; + + aesm_error_t result = aesmLogic->createSession(&sid, dh_msg1, mDHMsg1Size); + + AECreateSessionResponse* sessionResponse = new AECreateSessionResponse(result, sid, mDHMsg1Size, dh_msg1); + delete [] dh_msg1; + return sessionResponse; +} + +void AECreateSessionRequest::visit(IAERequestVisitor& visitor) { + visitor.visitCreateSessionRequest(*this); +} diff --git a/psw/ae/common/src/AECreateSessionResponse.cpp b/psw/ae/common/src/AECreateSessionResponse.cpp new file mode 100644 index 0000000000..0c78e5a18f --- /dev/null +++ b/psw/ae/common/src/AECreateSessionResponse.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AECreateSessionResponse::AECreateSessionResponse() +:mSessionId(0), mDHMsg1Length(0), mDHMsg1(NULL) +{ +} + +AECreateSessionResponse::AECreateSessionResponse(int errorCode, uint32_t sessionId, uint32_t dhMsg1Length, const uint8_t* dhMsg1) +:mSessionId(0), mDHMsg1Length(0), mDHMsg1(NULL) +{ + CopyFields(errorCode, sessionId, dhMsg1Length, dhMsg1); +} + +AECreateSessionResponse::AECreateSessionResponse(const AECreateSessionResponse& other) +:mSessionId(0), mDHMsg1Length(0), mDHMsg1(NULL) +{ + CopyFields(other.mErrorCode, other.mSessionId, other.mDHMsg1Length, other.mDHMsg1); +} + +AECreateSessionResponse::~AECreateSessionResponse() +{ + ReleaseMemory(); +} + +void AECreateSessionResponse::ReleaseMemory() +{ + if (mDHMsg1 != NULL) + { + if (mDHMsg1Length > 0) + memset(mDHMsg1, 0, mDHMsg1Length); + delete [] mDHMsg1; + mDHMsg1 = NULL; + } + mErrorCode = SGX_ERROR_UNEXPECTED; + mDHMsg1Length = 0; + mSessionId = 0; +} + +void AECreateSessionResponse::CopyFields(int errorCode, uint32_t sessionId, uint32_t dhMsg1Length, const uint8_t* dhMsg1) +{ + if(dhMsg1Length <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + + mErrorCode = errorCode; + mSessionId = sessionId; + mDHMsg1Length = dhMsg1Length; + + if (dhMsg1 != NULL && dhMsg1Length > 0) { + mDHMsg1 = new uint8_t[dhMsg1Length]; + memcpy(mDHMsg1, dhMsg1, dhMsg1Length); + } +} + +AEMessage* AECreateSessionResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AECreateSessionResponse::inflateWithMessage(AEMessage* message, ISerializer* serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AECreateSessionResponse::inflateValues(int errorCode, uint32_t sessionId, uint32_t dhMsg1Length, const uint8_t* dhMsg1) +{ + ReleaseMemory(); + + CopyFields(errorCode, sessionId, dhMsg1Length, dhMsg1); +} + +bool AECreateSessionResponse::operator==(const AECreateSessionResponse& other) const +{ + if (this == &other) + return true; + + if (mErrorCode != other.mErrorCode || + mSessionId != other.mSessionId || + mDHMsg1Length != other.mDHMsg1Length) + return false; + + if ((mDHMsg1 != other.mDHMsg1) && + (mDHMsg1 == NULL || other.mDHMsg1 == NULL)) + return false; + + if (mDHMsg1 != NULL && other.mDHMsg1 != NULL && memcmp(mDHMsg1, other.mDHMsg1, other.mDHMsg1Length) != 0) + return false; + + + + return true; +} + +AECreateSessionResponse& AECreateSessionResponse::operator=(const AECreateSessionResponse& other) +{ + if (this == & other) + return *this; + + inflateValues(other.mErrorCode, other.mSessionId, other.mDHMsg1Length, other.mDHMsg1); + + return *this; +} + +bool AECreateSessionResponse::check() +{ + if (mErrorCode != SGX_SUCCESS ) + return false; + + if (mValidSizeCheck == false) + return false; + + if (mDHMsg1 == NULL) + return false; + + return true; +} + +void AECreateSessionResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitCreateSessionResponse(*this); +} diff --git a/psw/ae/common/src/AEExchangeReportRequest.cpp b/psw/ae/common/src/AEExchangeReportRequest.cpp new file mode 100644 index 0000000000..c96698635f --- /dev/null +++ b/psw/ae/common/src/AEExchangeReportRequest.cpp @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include +#include + + +AEExchangeReportRequest::AEExchangeReportRequest() +:mSessionId(0), mDHMsg2Length(0), mDHMsg2(NULL), mDHMsg3Length(0) +{ +} + +AEExchangeReportRequest::AEExchangeReportRequest(uint32_t sessionId, uint32_t dhMsg2Length, const uint8_t* dhMsg2, uint32_t dhMsg3Length, uint32_t timeout) +:mSessionId(0), mDHMsg2Length(0), mDHMsg2(NULL), mDHMsg3Length(0) +{ + CopyFields(sessionId, dhMsg2Length, dhMsg2, dhMsg3Length, timeout); +} + +AEExchangeReportRequest::AEExchangeReportRequest(const AEExchangeReportRequest& other) +:IAERequest(other), mSessionId(0), mDHMsg2Length(0), mDHMsg2(NULL), mDHMsg3Length(0) +{ + CopyFields(other.mSessionId, other.mDHMsg2Length, other.mDHMsg2, other.mDHMsg3Length, other.mTimeout); +} + +AEExchangeReportRequest::~AEExchangeReportRequest() +{ + ReleaseMemory(); +} + +void AEExchangeReportRequest::ReleaseMemory() +{ + if (mDHMsg2 != NULL) + { + if (mDHMsg2Length > 0) + memset(mDHMsg2, 0, mDHMsg2Length); + delete [] mDHMsg2; + mDHMsg2 = NULL; + } + mDHMsg2Length = 0; + mDHMsg3Length = 0; + mSessionId = 0; + mTimeout = 0; +} + +void AEExchangeReportRequest::CopyFields(uint32_t sessionId, uint32_t dhMsg2Length, const uint8_t* dhMsg2, uint32_t dhMsg3Length, uint32_t timeout) +{ + if(dhMsg2Length <= MAX_MEMORY_ALLOCATION && mDHMsg3Length <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mSessionId = sessionId; + mDHMsg2Length = dhMsg2Length; + mDHMsg3Length = dhMsg3Length; + + mTimeout = timeout; + + if (dhMsg2 != NULL && dhMsg2Length > 0) { + mDHMsg2 = new uint8_t[dhMsg2Length]; + memcpy(mDHMsg2, dhMsg2, dhMsg2Length); + } + +} + +AEMessage* AEExchangeReportRequest::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +void AEExchangeReportRequest::inflateValues(uint32_t sessionId, uint32_t dhMsg2Length, const uint8_t* dhMsg2, uint32_t dhMsg3Length, uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(sessionId, dhMsg2Length, dhMsg2, dhMsg3Length, timeout); +} + +bool AEExchangeReportRequest::operator==(const AEExchangeReportRequest& other) const +{ + if (this == &other) + return true; + + if (mSessionId != other.mSessionId || + mDHMsg2Length != other.mDHMsg2Length || + mDHMsg3Length != other.mDHMsg3Length || + mTimeout != other.mTimeout) + return false; + + if ((mDHMsg2 != other.mDHMsg2) && + (mDHMsg2 == NULL || other.mDHMsg2 == NULL)) + return false; + + if (mDHMsg2 != NULL && other.mDHMsg2 != NULL && memcmp(mDHMsg2, other.mDHMsg2, other.mDHMsg2Length) != 0) + return false; + + return true; +} + +AEExchangeReportRequest& AEExchangeReportRequest::operator=(const AEExchangeReportRequest& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mSessionId, other.mDHMsg2Length, other.mDHMsg2, other.mDHMsg3Length, other.mTimeout); + + return *this; +} + +bool AEExchangeReportRequest::check() +{ + if(mValidSizeCheck == false) + return false; + + if (mDHMsg2 == NULL) + return false; + + return true; +} + +IAERequest::RequestClass AEExchangeReportRequest::getRequestClass() { + return PLATFORM_CLASS; +} + +IAEResponse* AEExchangeReportRequest::execute(IAESMLogic* aesmLogic) { + aesm_error_t ret = AESM_UNEXPECTED_ERROR; + uint8_t* dh_msg3 = NULL; + + if (check() == false) + { + ret = AESM_PARAMETER_ERROR; + } + else + { + dh_msg3 = new uint8_t[mDHMsg3Length]; + ret = aesmLogic->exchangeReport(mSessionId, mDHMsg2, mDHMsg2Length, dh_msg3, mDHMsg3Length); + } + + IAEResponse* ae_res = new AEExchangeReportResponse(ret, mDHMsg3Length, dh_msg3); + + if (dh_msg3) + { + delete [] dh_msg3; + } + + return ae_res; +} + +void AEExchangeReportRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitExchangeReportRequest(*this); +} diff --git a/psw/ae/common/src/AEExchangeReportResponse.cpp b/psw/ae/common/src/AEExchangeReportResponse.cpp new file mode 100644 index 0000000000..57d3726367 --- /dev/null +++ b/psw/ae/common/src/AEExchangeReportResponse.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AEExchangeReportResponse::AEExchangeReportResponse() +:mDHMsg3Length(0), mDHMsg3(NULL) +{ +} + +AEExchangeReportResponse::AEExchangeReportResponse(int errorCode, uint32_t dhMsg3Length, const uint8_t* dhMsg3) +:mDHMsg3Length(0), mDHMsg3(NULL) +{ + CopyFields(errorCode, dhMsg3Length, dhMsg3); +} + +AEExchangeReportResponse::AEExchangeReportResponse(const AEExchangeReportResponse& other) +:mDHMsg3Length(0), mDHMsg3(NULL) +{ + CopyFields(other.mErrorCode, other.mDHMsg3Length, other.mDHMsg3); +} + +AEExchangeReportResponse::~AEExchangeReportResponse() +{ + ReleaseMemory(); +} + +void AEExchangeReportResponse::ReleaseMemory() +{ + if (mDHMsg3 != NULL) + { + if (mDHMsg3Length > 0) + memset(mDHMsg3, 0, mDHMsg3Length); + delete [] mDHMsg3; + mDHMsg3 = NULL; + } + mDHMsg3Length = 0; + mErrorCode = SGX_ERROR_UNEXPECTED; +} + +void AEExchangeReportResponse::CopyFields(int errorCode, uint32_t dhMsg3Length,const uint8_t* dhMsg3) +{ + if(dhMsg3Length <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mErrorCode = errorCode; + mDHMsg3Length = dhMsg3Length; + if (dhMsg3 != NULL && dhMsg3Length > 0) { + mDHMsg3 = new uint8_t[dhMsg3Length]; + memcpy(mDHMsg3, dhMsg3, dhMsg3Length); + } +} + +AEMessage* AEExchangeReportResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AEExchangeReportResponse::inflateWithMessage(AEMessage* message, ISerializer* serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AEExchangeReportResponse::inflateValues(int errorCode, uint32_t dhMsg3Length,const uint8_t* dhMsg3) +{ + ReleaseMemory(); + + CopyFields(errorCode, dhMsg3Length, dhMsg3); +} + +bool AEExchangeReportResponse::operator==(const AEExchangeReportResponse& other) const +{ + if (this == &other) + return true; + + if (mErrorCode != other.mErrorCode || + mDHMsg3Length != other.mDHMsg3Length) + return false; + + if ((mDHMsg3 != other.mDHMsg3) && + (mDHMsg3 == NULL || other.mDHMsg3 == NULL)) + return false; + + if (mDHMsg3 != NULL && other.mDHMsg3 != NULL && memcmp(mDHMsg3, other.mDHMsg3, other.mDHMsg3Length) != 0) + return false; + + return true; +} + +AEExchangeReportResponse& AEExchangeReportResponse::operator=(const AEExchangeReportResponse& other) +{ + if (this == &other) + return *this; + + ReleaseMemory(); + + CopyFields(other.mErrorCode, other.mDHMsg3Length, other.mDHMsg3); + + return *this; +} + +bool AEExchangeReportResponse::check() +{ + if (mErrorCode != SGX_SUCCESS) + return false; + + if (mValidSizeCheck == false) + return false; + + if (mDHMsg3 == NULL) + return false; + + return true; +} + +void AEExchangeReportResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitExchangeReportResponse(*this); +} diff --git a/psw/ae/common/src/AEGetLaunchTokenRequest.cpp b/psw/ae/common/src/AEGetLaunchTokenRequest.cpp new file mode 100644 index 0000000000..3c3e811af5 --- /dev/null +++ b/psw/ae/common/src/AEGetLaunchTokenRequest.cpp @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include + +AEGetLaunchTokenRequest::AEGetLaunchTokenRequest() : + mEnclaveMeasurementLength(0), + mEnclaveMeasurement(NULL), + mSigstructLength(0), + mSigstruct(NULL), + mSEAttributesLength(0), + mSEAttributes(NULL) +{ +} + +AEGetLaunchTokenRequest::AEGetLaunchTokenRequest(uint32_t measurementLength, const uint8_t* measurement, + uint32_t sigstructLength, const uint8_t* sigstruct, + uint32_t attributesLength, const uint8_t* attributes, + uint32_t timeout) : + mEnclaveMeasurementLength(0), + mEnclaveMeasurement(NULL), + mSigstructLength(0), + mSigstruct(NULL), + mSEAttributesLength(0), + mSEAttributes(NULL) +{ + CopyFields(measurementLength, measurement, sigstructLength, sigstruct, attributesLength, attributes, timeout); +} + +AEGetLaunchTokenRequest::AEGetLaunchTokenRequest(const AEGetLaunchTokenRequest& other) : + IAERequest(other), + mEnclaveMeasurementLength(0), + mEnclaveMeasurement(NULL), + mSigstructLength(0), + mSigstruct(NULL), + mSEAttributesLength(0), + mSEAttributes(NULL) +{ + CopyFields(other.mEnclaveMeasurementLength, other.mEnclaveMeasurement, other.mSigstructLength, other.mSigstruct, other.mSEAttributesLength, other.mSEAttributes, other.mTimeout); +} + +AEGetLaunchTokenRequest::~AEGetLaunchTokenRequest() +{ + ReleaseMemory(); +} + +void AEGetLaunchTokenRequest::CopyFields(uint32_t measurementLength,const uint8_t* measurement, + uint32_t sigstructLength,const uint8_t* sigstruct, + uint32_t attributesLength,const uint8_t* attributes, + uint32_t timeout) +{ + uint32_t totalSize = measurementLength + sigstructLength + attributesLength; + if (measurementLength <= MAX_MEMORY_ALLOCATION && sigstructLength <= MAX_MEMORY_ALLOCATION && + attributesLength <= MAX_MEMORY_ALLOCATION && totalSize <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mTimeout = timeout; + + if (measurement != NULL && measurementLength > 0) + { + mEnclaveMeasurement = new uint8_t[measurementLength]; + mEnclaveMeasurementLength = measurementLength; + memcpy(mEnclaveMeasurement, measurement, measurementLength); + } + + if (sigstruct != NULL && sigstructLength > 0) + { + mSigstruct = new uint8_t[sigstructLength]; + mSigstructLength = sigstructLength; + memcpy(mSigstruct, sigstruct, sigstructLength); + } + + if (attributes != NULL && attributesLength > 0) + { + mSEAttributes = new uint8_t[attributesLength]; + mSEAttributesLength = attributesLength; + memcpy(mSEAttributes, attributes, attributesLength); + } +} + +void AEGetLaunchTokenRequest::ReleaseMemory() +{ + if (mEnclaveMeasurement != NULL) + { + delete [] mEnclaveMeasurement; + mEnclaveMeasurement = NULL; + } + + if (mSigstruct != NULL) + { + if (mSigstructLength > 0) + { + memset(mSigstruct, 0, mSigstructLength); + } + delete [] mSigstruct; + mSigstruct = NULL; + + } + + if (mSEAttributes != NULL) + { + if (mSEAttributesLength > 0) + { + memset(mSEAttributes, 0, mSEAttributesLength); + } + delete [] mSEAttributes; + mSEAttributes = NULL; + } +} + +AEMessage* AEGetLaunchTokenRequest::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +void AEGetLaunchTokenRequest::inflateValues(uint32_t measurementLength,const uint8_t* measurement, + uint32_t sigstructLength,const uint8_t* sigstruct, + uint32_t attributesLength,const uint8_t* attributes, + uint32_t timeout) +{ + + ReleaseMemory(); + + CopyFields(measurementLength, measurement, sigstructLength, sigstruct, attributesLength, attributes, timeout); +} + +bool AEGetLaunchTokenRequest::check() +{ + if (mValidSizeCheck == false) + return false; + + //memory + if (mEnclaveMeasurement == NULL || mSigstruct == NULL || mSEAttributes == NULL) + return false; + //sizes + if (mEnclaveMeasurementLength == 0 || mSigstructLength == 0 || mSEAttributesLength == 0) + return false; + + return true; +} + +bool AEGetLaunchTokenRequest::operator==(const AEGetLaunchTokenRequest& other) const +{ + if (this == &other) + return true; + + if (mEnclaveMeasurementLength != other.mEnclaveMeasurementLength || + mSigstructLength != other.mSigstructLength || + mSEAttributesLength != other.mSEAttributesLength || + mTimeout != other.mTimeout) + return false; + + if ((mEnclaveMeasurement != other.mEnclaveMeasurement) && + (mEnclaveMeasurement == NULL || other.mEnclaveMeasurement == NULL)) + return false; + + if ((mSigstruct != other.mSigstruct) && + (mSigstruct == NULL || other.mSigstruct == NULL)) + return false; + + if ((mSEAttributes != other.mSEAttributes) && + (mSEAttributes == NULL || other.mSEAttributes == NULL)) + return false; + + if (mEnclaveMeasurement != NULL && memcmp(mEnclaveMeasurement, other.mEnclaveMeasurement, other.mEnclaveMeasurementLength) != 0) + return false; + + if (mSigstruct != NULL && memcmp(mSigstruct, other.mSigstruct, other.mSigstructLength) != 0) + return false; + + if (mSEAttributes != NULL && memcmp(mSEAttributes, other.mSEAttributes, other.mSEAttributesLength) != 0) + return false; + + return true; + +} + +AEGetLaunchTokenRequest& AEGetLaunchTokenRequest::operator=(const AEGetLaunchTokenRequest& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mEnclaveMeasurementLength, other.mEnclaveMeasurement, other.mSigstructLength, other.mSigstruct, other.mSEAttributesLength, other.mSEAttributes, other.mTimeout); + + return *this; +} + +IAERequest::RequestClass AEGetLaunchTokenRequest::getRequestClass() { + return LAUNCH_CLASS; +} + +IAEResponse* AEGetLaunchTokenRequest::execute(IAESMLogic* aesmLogic) { + uint8_t* token; + uint32_t tokenSize; + + aesm_error_t result = aesmLogic->getLaunchToken(mEnclaveMeasurement, mEnclaveMeasurementLength, mSigstruct, mSigstructLength, mSEAttributes, mSEAttributesLength, &token, &tokenSize); + + IAEResponse* response = new AEGetLaunchTokenResponse(result, tokenSize, token); + + //free the buffer before send + delete [] token; + + return response; +} + +void AEGetLaunchTokenRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitGetLaunchTokenRequest(*this); +} diff --git a/psw/ae/common/src/AEGetLaunchTokenResponse.cpp b/psw/ae/common/src/AEGetLaunchTokenResponse.cpp new file mode 100644 index 0000000000..ce8d7bffcd --- /dev/null +++ b/psw/ae/common/src/AEGetLaunchTokenResponse.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AEGetLaunchTokenResponse::AEGetLaunchTokenResponse() : + mTokenLength(0), + mToken(NULL) +{ +} + +AEGetLaunchTokenResponse::AEGetLaunchTokenResponse(int errorCode, uint32_t tokenLength, const uint8_t* token) : + mTokenLength(0), + mToken(NULL) +{ + CopyFields(errorCode, tokenLength, token); +} + +AEGetLaunchTokenResponse::AEGetLaunchTokenResponse(const AEGetLaunchTokenResponse& other) : + mTokenLength(0), + mToken(NULL) +{ + CopyFields(other.mErrorCode, other.mTokenLength, other.mToken); +} + +AEGetLaunchTokenResponse::~AEGetLaunchTokenResponse() +{ + ReleaseMemory(); +} + +AEMessage* AEGetLaunchTokenResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AEGetLaunchTokenResponse::inflateWithMessage(AEMessage* message, ISerializer* serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AEGetLaunchTokenResponse::inflateValues(int errorCode, uint32_t tokenLength,const uint8_t* token) +{ + ReleaseMemory(); + + CopyFields(errorCode, tokenLength, token); +} + + //operators +bool AEGetLaunchTokenResponse::operator==(const AEGetLaunchTokenResponse& other) const +{ + if (this == &other) + return true; + + if (mTokenLength != other.mTokenLength) + return false; + + if (mToken == NULL && mToken != other.mToken) + return false; + + if (mToken != NULL && other.mToken != NULL) + if (memcmp(mToken, other.mToken, other.mTokenLength) != 0) + return false; + + return true; +} + +AEGetLaunchTokenResponse& AEGetLaunchTokenResponse::operator=(const AEGetLaunchTokenResponse& other) +{ + if (this == &other) + return *this; + + ReleaseMemory(); + + CopyFields(other.mErrorCode, other.mTokenLength, other.mToken); + + return *this; +} + + //checks +bool AEGetLaunchTokenResponse::check() +{ + if (mErrorCode != SGX_SUCCESS) + return false; + + //simple size check + if (mValidSizeCheck == false) + return false; + + if (mToken == NULL) + return false; + + return true; +} + +void AEGetLaunchTokenResponse::ReleaseMemory() +{ + if (mToken != NULL) + delete [] mToken; + mToken = NULL; + mTokenLength = 0; + mErrorCode = SGX_ERROR_UNEXPECTED; +} + +void AEGetLaunchTokenResponse::CopyFields(int errorCode, uint32_t tokenLength,const uint8_t* token) +{ + if(tokenLength <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mErrorCode = errorCode; + mTokenLength = tokenLength; + + if (token != NULL && tokenLength > 0) + { + mToken = new uint8_t[tokenLength]; + memcpy(mToken, token, tokenLength); + } +} + +void AEGetLaunchTokenResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitGetLaunchTokenResponse(*this); +} diff --git a/psw/ae/common/src/AEGetPsCapRequest.cpp b/psw/ae/common/src/AEGetPsCapRequest.cpp new file mode 100644 index 0000000000..dac8bee3d6 --- /dev/null +++ b/psw/ae/common/src/AEGetPsCapRequest.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include + +#include + +AEGetPsCapRequest::AEGetPsCapRequest(uint32_t timeout) : IAERequest(timeout) { +} + +AEGetPsCapRequest::AEGetPsCapRequest(const AEGetPsCapRequest& other) +: IAERequest(other) +{ + CopyFields(other.mTimeout); +} + +AEGetPsCapRequest::~AEGetPsCapRequest() +{ + ReleaseMemory(); +} + +void AEGetPsCapRequest::ReleaseMemory() +{ + //empty for now +} + + +void AEGetPsCapRequest::CopyFields(uint32_t timeout) +{ + mTimeout = timeout; +} + +AEMessage* AEGetPsCapRequest::serialize(ISerializer* serializer){ + return serializer->serialize(this); +} + +IAERequest::RequestClass AEGetPsCapRequest::getRequestClass() { + return PLATFORM_CLASS; +} + +void AEGetPsCapRequest::inflateValues(uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(timeout); +} + +bool AEGetPsCapRequest::operator==(const AEGetPsCapRequest& other) const +{ + if (this == &other) + return true; + + if (mTimeout != other.mTimeout) + return false; + + return true; //no members , default to true +} + +AEGetPsCapRequest& AEGetPsCapRequest::operator=(const AEGetPsCapRequest& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mTimeout); + + //do nothing - no members + return *this; +} + +void AEGetPsCapRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitGetPsCapRequest(*this); +} + + +IAEResponse* AEGetPsCapRequest::execute(IAESMLogic* aesmLogic) +{ + uint64_t ps_cap; + + aesm_error_t result = aesmLogic->getPsCap(&ps_cap); + + AEGetPsCapResponse * response = new AEGetPsCapResponse((uint32_t)result, ps_cap); + + return response; +} diff --git a/psw/ae/common/src/AEGetPsCapResponse.cpp b/psw/ae/common/src/AEGetPsCapResponse.cpp new file mode 100644 index 0000000000..fe89c54be9 --- /dev/null +++ b/psw/ae/common/src/AEGetPsCapResponse.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AEGetPsCapResponse::AEGetPsCapResponse() : + mPsCap(-1) +{ +} + +AEGetPsCapResponse::AEGetPsCapResponse(int errorCode, uint64_t ps_cap) : + mPsCap(-1) +{ + CopyFields(errorCode, ps_cap); +} + +AEGetPsCapResponse::AEGetPsCapResponse(const AEGetPsCapResponse& other) : + mPsCap(-1) +{ + CopyFields(other.mErrorCode, other.mPsCap); +} + +AEGetPsCapResponse::~AEGetPsCapResponse() +{ + ReleaseMemory(); +} + +void AEGetPsCapResponse::ReleaseMemory() +{ + mErrorCode = SGX_ERROR_UNEXPECTED; +} + +void AEGetPsCapResponse::CopyFields(int errorCode, uint64_t ps_cap) +{ + mErrorCode = errorCode; + mPsCap = ps_cap; +} + + +AEMessage* AEGetPsCapResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AEGetPsCapResponse::inflateWithMessage(AEMessage* message, ISerializer *serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AEGetPsCapResponse::inflateValues(int errorCode, uint64_t ps_cap) +{ + ReleaseMemory(); + + CopyFields(errorCode, ps_cap); +} + +bool AEGetPsCapResponse::operator==(const AEGetPsCapResponse &other) const +{ + if (this == &other) + return true; + + if (mPsCap!= other.mPsCap) + return false; + return true; +} + +AEGetPsCapResponse & AEGetPsCapResponse::operator=(const AEGetPsCapResponse &other) +{ + if (this == &other) + return *this; + + inflateValues(other.mErrorCode, other.mPsCap); + + return *this; +} + +bool AEGetPsCapResponse::check() +{ + // no MAC to check at this point, but do some generic parameter check + + //impose a limit of 1MB for these messages. If larger then a transmission, or unmarshalling error may have occured + //also a big value here might be an attack + + //first, fail if errorCode is not 0 + if (mErrorCode != SGX_SUCCESS) + return false; + + return true; +} + +void AEGetPsCapResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitGetPsCapResponse(*this); +} + diff --git a/psw/ae/common/src/AEGetQuoteRequest.cpp b/psw/ae/common/src/AEGetQuoteRequest.cpp new file mode 100644 index 0000000000..57cc100586 --- /dev/null +++ b/psw/ae/common/src/AEGetQuoteRequest.cpp @@ -0,0 +1,324 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include "IAESMLogic.h" + +#include + +#include + + AEGetQuoteRequest::AEGetQuoteRequest() +:mReportLength(0), mReport(NULL), mQuoteType(0), mSPIDLength(0), mSPID(NULL), + mNonceLength(0), mNonce(NULL), mSigRLLength(0), mSigRL(NULL), mBufferSize(0), mQEReport(false) +{ + mValidSizeCheck = false; +} + +AEGetQuoteRequest::AEGetQuoteRequest(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, + bool qe_report, + uint32_t timeout) +:mReportLength(0), mReport(NULL), mQuoteType(0), mSPIDLength(0), mSPID(NULL), + mNonceLength(0), mNonce(NULL), mSigRLLength(0), mSigRL(NULL), mBufferSize(0), mQEReport(false) +{ + CopyFields(reportLength, report, quoteType, spidLength, spid, + nonceLength, nonce, sig_rlLength, sig_rl, bufferSize, qe_report, timeout); +} + +AEGetQuoteRequest::AEGetQuoteRequest(const AEGetQuoteRequest& other) +: IAERequest(other) +{ + CopyFields(other.mReportLength, other.mReport, + other.mQuoteType, + other.mSPIDLength, other.mSPID, + other.mNonceLength, other.mNonce, + other.mSigRLLength, other.mSigRL, + other.mBufferSize, + other.mQEReport, + other.mTimeout); +} + +AEGetQuoteRequest::~AEGetQuoteRequest() +{ + ReleaseMemory(); +} + +AEMessage* AEGetQuoteRequest::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +void AEGetQuoteRequest::CopyFields(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, + bool qe_report, + uint32_t timeout) +{ + uint32_t totalAllocation = reportLength + spidLength + nonceLength + sig_rlLength; + if(reportLength <= MAX_MEMORY_ALLOCATION && spidLength <= MAX_MEMORY_ALLOCATION && + nonceLength <= MAX_MEMORY_ALLOCATION && sig_rlLength <= MAX_MEMORY_ALLOCATION && + totalAllocation <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mReport = NULL; + mReportLength = 0; + + mSigRL = NULL; + mSigRLLength = 0; + + mNonce = NULL; + mNonceLength = 0; + + mSPID = NULL; + mSPIDLength = 0; + + mValidSizeCheck = false; + return; + } + + mReportLength = reportLength; + if (reportLength > 0 && report != NULL) + { + mReport = new uint8_t[reportLength]; + memcpy(mReport, report, reportLength); + } + else + mReport = NULL; + + mSigRLLength = sig_rlLength; + if (sig_rl != NULL && sig_rlLength > 0) + { + mSigRL = new uint8_t[sig_rlLength]; + memcpy(mSigRL, sig_rl, sig_rlLength); + } + else + mSigRL = NULL; + + mNonceLength = nonceLength; + if (nonce != NULL && nonceLength > 0) + { + mNonce = new uint8_t[nonceLength]; + memcpy(mNonce, nonce, nonceLength); + } + else + mNonce = NULL; + + mSPIDLength = spidLength; + if (spid != NULL && spidLength > 0) + { + mSPID = new uint8_t[spidLength]; + memcpy(mSPID, spid, spidLength); + } + else + mSPID = NULL; + + mQuoteType = quoteType; + mBufferSize = bufferSize; + mQEReport = qe_report; + mTimeout = timeout; +} + +void AEGetQuoteRequest::inflateValues(uint32_t reportLength, const uint8_t* report, + uint32_t quoteType, + uint32_t spidLength, const uint8_t* spid, + uint32_t nonceLength, const uint8_t* nonce, + uint32_t sig_rlLength, const uint8_t* sig_rl, + uint32_t bufferSize, + bool qe_report, + uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(reportLength, report, quoteType, spidLength, spid, + nonceLength, nonce, sig_rlLength, sig_rl, bufferSize, qe_report, timeout); +} + + +void AEGetQuoteRequest::ReleaseMemory() +{ + if (mReport != NULL) + { + if (mReportLength > 0) + memset(mReport,0,mReportLength); + delete [] mReport; + mReport = NULL; + } + if (mSigRL != NULL) + { + if (mSigRLLength > 0) + memset(mSigRL, 0, mSigRLLength); + delete [] mSigRL; + mSigRL = NULL; + } + if (mNonce != NULL) + { + if (mNonceLength > 0) + memset(mNonce, 0, mNonceLength); + delete [] mNonce; + mNonce = NULL; + } + if (mSPID != NULL) + { + if (mSPIDLength > 0) + memset(mSPID, 0, mSPIDLength); + delete [] mSPID; + mSPID = NULL; + } + + mReportLength = 0; + mSigRLLength = 0; + mNonceLength = 0; + mSPIDLength = 0; + mBufferSize = 0; + mQuoteType = 0; + mQEReport = false; + mTimeout = 0; +} + +bool AEGetQuoteRequest::operator==(const AEGetQuoteRequest& other) const +{ + if (&other == this) + return true; + + if (mReportLength != other.mReportLength || + mSigRLLength != other.mSigRLLength || + mNonceLength != other.mNonceLength || + mSPIDLength != other.mSPIDLength || + mQuoteType != other.mQuoteType || + mBufferSize != other.mBufferSize || + mQEReport != other.mQEReport || + mTimeout != other.mTimeout) + return false; + + if ((mReport != other.mReport) && + (mReport == NULL || other.mReport == NULL)) + return false; + + if ((mSigRL != other.mSigRL) && + (mSigRL == NULL || other.mSigRL == NULL)) + return false; + + if ((mNonce != other.mNonce) && + (mNonce == NULL || other.mNonce == NULL)) + return false; + + if ((mSPID != other.mSPID) && + (mSPID == NULL || other.mSPID == NULL)) + return false; + + if ((mReport != NULL && other.mReport != NULL && memcmp(mReport, other.mReport, mReportLength) != 0) || + (mSigRL != NULL && other.mSigRL != NULL && memcmp(mSigRL, other.mSigRL, mSigRLLength) != 0) || + (mNonce != NULL && other.mNonce != NULL && memcmp(mNonce, other.mNonce, mNonceLength) != 0) || + (mSPID != NULL && other.mSPID != NULL && memcmp(mSPID, other.mSPID, mSPIDLength) !=0 )) + return false; + return true; +} + +AEGetQuoteRequest& AEGetQuoteRequest::operator=(const AEGetQuoteRequest& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mReportLength, other.mReport, + other.mQuoteType, + other.mSPIDLength, other.mSPID, + other.mNonceLength, other.mNonce, + other.mSigRLLength, other.mSigRL, + other.mBufferSize, + other.mQEReport, + other.mTimeout); + + return *this; +} + +bool AEGetQuoteRequest::check() +{ + //maybe TODO - add stronger checks + + if(mValidSizeCheck == false) + return false; + + //allocations - only non optional fields + if (mReport == NULL || mSPID == NULL) + return false; + + return true; +} + +IAERequest::RequestClass AEGetQuoteRequest::getRequestClass() { + return QUOTING_CLASS; +} + +void AEGetQuoteRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitGetQuoteRequest(*this); +} + +IAEResponse* AEGetQuoteRequest::execute(IAESMLogic* aesmLogic) { + aesm_error_t result; + + int32_t qe_report_length = 0; + uint8_t* qe_report = NULL; + if (mQEReport == true) + { + qe_report_length = sizeof(sgx_report_t); + qe_report = new uint8_t[sizeof(sgx_report_t)]; + } + uint8_t* quote = new uint8_t[mBufferSize]; + + result = aesmLogic->getQuote(mReportLength,mReport, + mQuoteType, + mSPIDLength, mSPID, + mNonceLength, mNonce, + mSigRLLength, mSigRL, + mBufferSize, quote, + qe_report_length, qe_report); + + AEGetQuoteResponse* response = new AEGetQuoteResponse(result, mBufferSize, quote, qe_report_length, qe_report); + + //free memory + delete [] quote; + delete [] qe_report; + + return response; +} diff --git a/psw/ae/common/src/AEGetQuoteResponse.cpp b/psw/ae/common/src/AEGetQuoteResponse.cpp new file mode 100644 index 0000000000..d30f179af6 --- /dev/null +++ b/psw/ae/common/src/AEGetQuoteResponse.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AEGetQuoteResponse::AEGetQuoteResponse() : + mQuoteLength(0), + mQuote(NULL), + mQEReportLength(0), + mQEReport(NULL) +{ +} + +AEGetQuoteResponse::AEGetQuoteResponse(int errorCode, uint32_t quoteLength, const uint8_t* quote, + uint32_t qeReportLength, const uint8_t* qeReport) : + mQuoteLength(0), + mQuote(NULL), + mQEReportLength(0), + mQEReport(NULL) +{ + CopyFields(errorCode, quoteLength, quote,qeReportLength, qeReport); +} + +//copy constructor +AEGetQuoteResponse::AEGetQuoteResponse(const AEGetQuoteResponse& other) : + mQuoteLength(0), + mQuote(NULL), + mQEReportLength(0), + mQEReport(NULL) +{ + CopyFields(other.mErrorCode, other.mQuoteLength, other.mQuote, other.mQEReportLength, other.mQEReport); +} + +AEGetQuoteResponse::~AEGetQuoteResponse() +{ + ReleaseMemory(); +} + +void AEGetQuoteResponse::ReleaseMemory() +{ + if (mQuote != NULL) + delete [] mQuote; + if (mQEReport != NULL) + delete [] mQEReport; + mQuote = NULL; + mQEReport = NULL; + mQuoteLength = 0; + mQEReportLength = 0; + mErrorCode = SGX_ERROR_UNEXPECTED; +} + +void AEGetQuoteResponse::CopyFields(int errorCode, uint32_t quoteLength,const uint8_t* quote, + uint32_t qeReportLength, const uint8_t* qeReport) +{ + uint32_t totalSize = qeReportLength + quoteLength; + + if(quoteLength <= MAX_MEMORY_ALLOCATION && qeReportLength <= MAX_MEMORY_ALLOCATION + && totalSize <= MAX_MEMORY_ALLOCATION ) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mErrorCode = errorCode; + mQuoteLength = quoteLength; + mQEReportLength = qeReportLength; + + if (quote != NULL && quoteLength > 0) + { + mQuote = new uint8_t[quoteLength]; + memcpy(mQuote, quote, quoteLength); + } + + if (qeReport != NULL&& qeReportLength > 0) + { + mQEReport = new uint8_t[qeReportLength]; + memcpy(mQEReport, qeReport, qeReportLength); + } +} + +AEMessage* AEGetQuoteResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AEGetQuoteResponse::inflateWithMessage(AEMessage* message, ISerializer* serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AEGetQuoteResponse::inflateValues(int errorCode, uint32_t quoteLength, const uint8_t* quote, + uint32_t qeReportLength, const uint8_t* qeReport) +{ + ReleaseMemory(); + + CopyFields(errorCode, quoteLength, quote, qeReportLength, qeReport); +} + +bool AEGetQuoteResponse::operator==(const AEGetQuoteResponse& other) const +{ + if (this == &other) + return true; + + if (mErrorCode != other.mErrorCode || + mQuoteLength != other.mQuoteLength || + mQEReportLength != other.mQEReportLength) + return false; + + if (mQuote != NULL && other.mQuote != NULL) + if (memcmp(mQuote, other.mQuote, other.mQuoteLength) != 0) + return false; + if (mQEReport != NULL && other.mQEReport != NULL) + if (memcmp(mQEReport, other.mQEReport, other.mQEReportLength) != 0) + return false; + + return true; +} + +AEGetQuoteResponse& AEGetQuoteResponse::operator=(const AEGetQuoteResponse& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mErrorCode, other.mQuoteLength, other.mQuote, other.mQEReportLength, other.mQEReport); + + return *this; +} + +bool AEGetQuoteResponse::check() +{ + if (mValidSizeCheck == false) + return false; + + return true; +} + +void AEGetQuoteResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitGetQuoteResponse(*this); +} diff --git a/psw/ae/common/src/AEInitQuoteRequest.cpp b/psw/ae/common/src/AEInitQuoteRequest.cpp new file mode 100644 index 0000000000..f4c77d8ce4 --- /dev/null +++ b/psw/ae/common/src/AEInitQuoteRequest.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include + +#include + +AEInitQuoteRequest::AEInitQuoteRequest(uint32_t timeout) +{ + inflateValues(timeout); +} + +AEInitQuoteRequest::AEInitQuoteRequest(const AEInitQuoteRequest& other) +:IAERequest(other) +{ + CopyFields(other.mTimeout); +} + +AEInitQuoteRequest::~AEInitQuoteRequest() +{ +} + +void AEInitQuoteRequest::ReleaseMemory() +{ + //empty for now +} + +void AEInitQuoteRequest::CopyFields(uint32_t timeout) +{ + mTimeout = timeout; +} + +AEMessage* AEInitQuoteRequest::serialize(ISerializer* serializer){ + return serializer->serialize(this); +} + +IAERequest::RequestClass AEInitQuoteRequest::getRequestClass() { + return QUOTING_CLASS; +} + +void AEInitQuoteRequest::inflateValues(uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(timeout); +} + +bool AEInitQuoteRequest::operator==(const AEInitQuoteRequest& other) const +{ + if (this == &other) + return true; + + if (mTimeout != other.mTimeout) + return false; + + return true; //no members , default to true +} + +AEInitQuoteRequest& AEInitQuoteRequest::operator=(const AEInitQuoteRequest& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mTimeout); + + //do nothing - no members + return *this; +} + +void AEInitQuoteRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitInitQuoteRequest(*this); +} + + +IAEResponse* AEInitQuoteRequest::execute(IAESMLogic* aesmLogic) { + uint8_t* target_info = new uint8_t[sizeof(sgx_target_info_t)]; + uint8_t* gid = new uint8_t[sizeof(sgx_epid_group_id_t)]; + uint32_t target_info_length=sizeof(sgx_target_info_t); + uint32_t gid_length=sizeof(sgx_epid_group_id_t); + + aesm_error_t result= aesmLogic->initQuote(target_info,target_info_length,gid, gid_length); + + AEInitQuoteResponse * response = new AEInitQuoteResponse((uint32_t)result, gid_length, gid, target_info_length, target_info); + + delete [] target_info; + delete [] gid; + + return response; +} diff --git a/psw/ae/common/src/AEInitQuoteResponse.cpp b/psw/ae/common/src/AEInitQuoteResponse.cpp new file mode 100644 index 0000000000..5fabb98f7f --- /dev/null +++ b/psw/ae/common/src/AEInitQuoteResponse.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AEInitQuoteResponse::AEInitQuoteResponse() : + mGIDLength(0), + mTargetInfoLength(0), + mTargetInfo(NULL), + mGID(NULL) +{ +} + +AEInitQuoteResponse::AEInitQuoteResponse(int errorCode, uint32_t gidLength, const uint8_t* gid, + uint32_t targetInfoLength, const uint8_t* targetInfo) : + mGIDLength(0), + mTargetInfoLength(0), + mTargetInfo(NULL), + mGID(NULL) +{ + CopyFields(errorCode, gidLength, gid, targetInfoLength, targetInfo); +} + +AEInitQuoteResponse::AEInitQuoteResponse(const AEInitQuoteResponse& other) : + mGIDLength(0), + mTargetInfoLength(0), + mTargetInfo(NULL), + mGID(NULL) +{ + CopyFields(other.mErrorCode, other.mGIDLength, other.mGID, other.mTargetInfoLength, other.mTargetInfo); +} + +AEInitQuoteResponse::~AEInitQuoteResponse() +{ + ReleaseMemory(); +} + +void AEInitQuoteResponse::ReleaseMemory() +{ + if (mGID != NULL){ + delete [] mGID; + mGID = NULL; + mGIDLength = 0; + } + + if (mTargetInfo != NULL) + { + delete [] mTargetInfo; + mTargetInfo = NULL; + mTargetInfoLength = 0; + } + + mErrorCode = SGX_ERROR_UNEXPECTED; +} + +void AEInitQuoteResponse::CopyFields(int errorCode, uint32_t gidLength, const uint8_t* gid, + uint32_t targetInfoLength, const uint8_t* targetInfo) +{ + uint32_t totalSize = gidLength + targetInfoLength; + + if(gidLength <= MAX_MEMORY_ALLOCATION && targetInfoLength <= MAX_MEMORY_ALLOCATION + && totalSize <= MAX_MEMORY_ALLOCATION ) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mErrorCode = errorCode; + + mGIDLength = gidLength; + + if (gid == NULL) + mGID = NULL; + else + { + mGID = new uint8_t[mGIDLength]; + memcpy(mGID, gid, mGIDLength); + } + + mTargetInfoLength = targetInfoLength; + mTargetInfo = new uint8_t[mTargetInfoLength]; + memcpy(mTargetInfo, targetInfo, mTargetInfoLength); +} + + +AEMessage* AEInitQuoteResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AEInitQuoteResponse::inflateWithMessage(AEMessage* message, ISerializer *serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AEInitQuoteResponse::inflateValues(int errorCode, uint32_t gidLength, const uint8_t* gid, + uint32_t targetInfoLength, const uint8_t* targetInfo) +{ + ReleaseMemory(); + + CopyFields(errorCode, gidLength, gid, targetInfoLength, targetInfo); +} + +bool AEInitQuoteResponse::operator==(const AEInitQuoteResponse &other) const +{ + if (this == &other) + return true; + + if (mTargetInfoLength != other.mTargetInfoLength || + mGIDLength != other.mGIDLength) + return false; + + if (memcmp(mGID, other.mGID, mGIDLength) != 0) + return false; + + if (memcmp(mTargetInfo, other.mTargetInfo, mTargetInfoLength) != 0) + return false; + + return true; +} + +AEInitQuoteResponse & AEInitQuoteResponse::operator=(const AEInitQuoteResponse &other) +{ + if (this == &other) + return *this; + + inflateValues(other.mErrorCode, other.mGIDLength, other.mGID, other.mTargetInfoLength, other.mTargetInfo); + + return *this; +} + +bool AEInitQuoteResponse::check() +{ + // no MAC to check at this point, but do some generic parameter check + + //first, fail if errorCode is not 0 + if (mErrorCode != SGX_SUCCESS) + return false; + + if (mValidSizeCheck == false) + return false; + + //check memory allocation fail in this object + if (mTargetInfoLength > 0 && mTargetInfo == NULL) + return false; + + if (mGIDLength > 0 && mGID == NULL) + return false; + + return true; +} + +void AEInitQuoteResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitInitQuoteResponse(*this); +} diff --git a/psw/ae/common/src/AEInvokeServiceRequest.cpp b/psw/ae/common/src/AEInvokeServiceRequest.cpp new file mode 100644 index 0000000000..68335e8080 --- /dev/null +++ b/psw/ae/common/src/AEInvokeServiceRequest.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include +#include + + AEInvokeServiceRequest::AEInvokeServiceRequest() +:mPSEMessageLength(0), mPSEMessage(NULL), mResponseSize(0) +{ +} + + AEInvokeServiceRequest::AEInvokeServiceRequest(uint32_t pseMessageLength, const uint8_t* pseMessage, uint32_t pseResponseSize, uint32_t timeout) +:mPSEMessageLength(0), mPSEMessage(NULL), mResponseSize(0) +{ + CopyFields(pseMessageLength, pseMessage, pseResponseSize, timeout); +} + + AEInvokeServiceRequest::AEInvokeServiceRequest(const AEInvokeServiceRequest& other) +:IAERequest(other), mPSEMessageLength(0), mPSEMessage(NULL), mResponseSize(0) +{ + CopyFields(other.mPSEMessageLength, other.mPSEMessage, other.mResponseSize, other.mTimeout); +} + +AEInvokeServiceRequest::~AEInvokeServiceRequest() +{ + ReleaseMemory(); +} + +void AEInvokeServiceRequest::ReleaseMemory() +{ + if (mPSEMessage != NULL) + { + if (mPSEMessageLength > 0) + memset(mPSEMessage, 0, mPSEMessageLength); + delete [] mPSEMessage; + mPSEMessage = NULL; + } + mPSEMessageLength = 0; + mResponseSize = 0; + mTimeout = 0; +} + +void AEInvokeServiceRequest::CopyFields(uint32_t pseMessageLength, const uint8_t* pseMessage, uint32_t pseResponseSize, uint32_t timeout) +{ + if(pseMessageLength <= MAX_MEMORY_ALLOCATION && pseResponseSize <= MAX_MEMORY_ALLOCATION) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mPSEMessageLength = pseMessageLength; + if (pseMessage != NULL && pseMessageLength > 0) + { + mPSEMessage = new uint8_t[pseMessageLength]; + memcpy(mPSEMessage, pseMessage, pseMessageLength); + } + + mTimeout = timeout; + mResponseSize = pseResponseSize; +} + +AEMessage* AEInvokeServiceRequest::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +void AEInvokeServiceRequest::inflateValues(uint32_t pseMessageLength, const uint8_t* pseMessage, uint32_t pseResponseSize, uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(pseMessageLength, pseMessage, pseResponseSize, timeout); +} + +bool AEInvokeServiceRequest::operator==(const AEInvokeServiceRequest& other) const +{ + if (this == & other) + return true; + + if (mPSEMessageLength != other.mPSEMessageLength || + mResponseSize != other.mResponseSize || + mTimeout != other.mTimeout) + return false; + + if ((mPSEMessage != other.mPSEMessage) && + (mPSEMessage == NULL || other.mPSEMessage == NULL)) + return false; + + if (mPSEMessage != NULL && other.mPSEMessage != NULL && memcmp(mPSEMessage, other.mPSEMessage, other.mPSEMessageLength) != 0) + return false; + //NOTE: timeout discarded from test + return true; +} + +AEInvokeServiceRequest& AEInvokeServiceRequest::operator=(const AEInvokeServiceRequest& other) +{ + if (this == &other) + return * this; + + CopyFields(other.mPSEMessageLength, other.mPSEMessage, other.mResponseSize, other.mTimeout); + + return *this; +} + +bool AEInvokeServiceRequest::check() +{ + if(mValidSizeCheck == false) + return false; + + if (mPSEMessage == NULL) + return false; + + return true; +} + +IAERequest::RequestClass AEInvokeServiceRequest::getRequestClass() { + return PLATFORM_CLASS; +} + +IAEResponse* AEInvokeServiceRequest::execute(IAESMLogic* aesmLogic) { + aesm_error_t ret = AESM_UNEXPECTED_ERROR; + uint8_t* response = NULL; + + if (check() == false) + { + ret = AESM_PARAMETER_ERROR; + } + else + { + response = new uint8_t[mResponseSize]; + } + if (response != NULL) + { + ret = aesmLogic->invokeService(mPSEMessage, mPSEMessageLength, response, mResponseSize); + } + + IAEResponse* ae_res= new AEInvokeServiceResponse(ret, mResponseSize, response); + + delete [] response; + + return ae_res; +} + +void AEInvokeServiceRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitInvokeServiceRequest(*this); +} diff --git a/psw/ae/common/src/AEInvokeServiceResponse.cpp b/psw/ae/common/src/AEInvokeServiceResponse.cpp new file mode 100644 index 0000000000..5f384edbd6 --- /dev/null +++ b/psw/ae/common/src/AEInvokeServiceResponse.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + + AEInvokeServiceResponse::AEInvokeServiceResponse() +:mPSEMessageLength(0), mPSEMessage(NULL) +{ +} + + AEInvokeServiceResponse::AEInvokeServiceResponse(int errorCode, uint32_t pseMessageLength, const uint8_t* pseMessage) +:mPSEMessageLength(0), mPSEMessage(NULL) +{ + CopyFields(errorCode, pseMessageLength, pseMessage); +} + + AEInvokeServiceResponse::AEInvokeServiceResponse(const AEInvokeServiceResponse& other) +:mPSEMessageLength(0), mPSEMessage(NULL) +{ + CopyFields(other.mErrorCode, other.mPSEMessageLength, other.mPSEMessage); +} + +AEInvokeServiceResponse::~AEInvokeServiceResponse() +{ + ReleaseMemory(); +} + +void AEInvokeServiceResponse::ReleaseMemory() +{ + if (mPSEMessage != NULL) + { + if (mPSEMessageLength > 0) + memset(mPSEMessage, 0, mPSEMessageLength); + delete [] mPSEMessage; + mPSEMessage = NULL; + } + mErrorCode = SGX_ERROR_UNEXPECTED; + mPSEMessageLength = 0; +} + +void AEInvokeServiceResponse::CopyFields(int errorCode, uint32_t pseMessageLength,const uint8_t* pseMessage) +{ + if(pseMessageLength <= MAX_MEMORY_ALLOCATION ) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mErrorCode = errorCode; + mPSEMessageLength = pseMessageLength; + if (pseMessage != NULL && pseMessageLength > 0) { + mPSEMessage = new uint8_t[pseMessageLength]; + memcpy(mPSEMessage, pseMessage, pseMessageLength); + } +} + +AEMessage* AEInvokeServiceResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AEInvokeServiceResponse::inflateWithMessage(AEMessage* message, ISerializer* serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AEInvokeServiceResponse::inflateValues(int errorCode, uint32_t pseMessageLength,const uint8_t* pseMessage) +{ + ReleaseMemory(); + + CopyFields(errorCode, pseMessageLength, pseMessage); +} + +bool AEInvokeServiceResponse::operator==(const AEInvokeServiceResponse& other) const +{ + if (this == &other) + return true; + + if (mErrorCode != other.mErrorCode || + mPSEMessageLength != other.mPSEMessageLength) + return false; + + if ((mPSEMessage != other.mPSEMessage) && + (mPSEMessage == NULL || other.mPSEMessage == NULL)) + return false; + + if (mPSEMessage != NULL && other.mPSEMessage != NULL && + memcmp(mPSEMessage, other.mPSEMessage, other.mPSEMessageLength) != 0) + return false; + + return true; +} + +AEInvokeServiceResponse& AEInvokeServiceResponse::operator=(const AEInvokeServiceResponse& other) +{ + if (this == &other) + return * this; + + inflateValues(other.mErrorCode, other.mPSEMessageLength, other.mPSEMessage); + + return *this; +} + +bool AEInvokeServiceResponse::check() +{ + if (mErrorCode != SGX_SUCCESS) + return false; + + if (mValidSizeCheck == false) + return false; + + if (mPSEMessage == NULL) + return false; + + return true; +} + +void AEInvokeServiceResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitInvokeServiceResponse(*this); +} diff --git a/psw/ae/common/src/AEReportAttestationRequest.cpp b/psw/ae/common/src/AEReportAttestationRequest.cpp new file mode 100644 index 0000000000..bc90db810c --- /dev/null +++ b/psw/ae/common/src/AEReportAttestationRequest.cpp @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include +#include + +AEReportAttestationRequest::AEReportAttestationRequest() +:mAttestationErrorCode(-1), +mPlatformInfoLength(0), +mPlatformInfo(NULL), +mUpdateInfoLength(0) +{ +} + +AEReportAttestationRequest::AEReportAttestationRequest(uint32_t platformInfoLength, const uint8_t* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout) +:mAttestationErrorCode(-1), +mPlatformInfoLength(0), +mPlatformInfo(NULL), +mUpdateInfoLength(0) + +{ + CopyFields(platformInfoLength, platformInfo, attestation_error_code, updateInfoLength, timeout); +} + +AEReportAttestationRequest::AEReportAttestationRequest(const AEReportAttestationRequest& other) +:IAERequest(other), +mAttestationErrorCode(-1), +mPlatformInfoLength(0), +mPlatformInfo(NULL), +mUpdateInfoLength(0) +{ + CopyFields(other.mPlatformInfoLength, other.mPlatformInfo, other.mAttestationErrorCode, other.mUpdateInfoLength, other.mTimeout); +} + +AEReportAttestationRequest::~AEReportAttestationRequest() +{ + ReleaseMemory(); +} + +void AEReportAttestationRequest::ReleaseMemory() +{ + if (mPlatformInfo != NULL) + { + if (mPlatformInfoLength > 0) + { + memset(mPlatformInfo, 0, mPlatformInfoLength); + } + delete [] mPlatformInfo; + mPlatformInfo = NULL; + } +} + +void AEReportAttestationRequest::CopyFields(uint32_t platformInfoLength, const uint8_t* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout) +{ + if (platformInfoLength <= MAX_MEMORY_ALLOCATION ) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + if (platformInfo != NULL && platformInfoLength > 0) + { + mPlatformInfo = new uint8_t[platformInfoLength]; + mPlatformInfoLength = platformInfoLength; + memcpy(mPlatformInfo, platformInfo, platformInfoLength); + } + mAttestationErrorCode = attestation_error_code; + mUpdateInfoLength = updateInfoLength; + mTimeout = timeout; +} + +AEMessage* AEReportAttestationRequest::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +void AEReportAttestationRequest::inflateValues(uint32_t platformInfoLength, const uint8_t* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout) +{ + ReleaseMemory(); + + CopyFields(platformInfoLength, platformInfo, attestation_error_code, updateInfoLength, timeout); +} + +bool AEReportAttestationRequest::operator==(const AEReportAttestationRequest& other) const +{ + if (this == &other) + return true; + + if (mPlatformInfoLength != other.mPlatformInfoLength || + mTimeout != other.mTimeout) + return false; + + if (mAttestationErrorCode != other.mAttestationErrorCode) + return false; + + if (mUpdateInfoLength!= other.mUpdateInfoLength) + return false; + + + if (mPlatformInfo == other.mPlatformInfo) + return true; + + if (mPlatformInfo == NULL) + return false; //only mPlatformInfo in NULL, because mPlatformInfo != other.mPlatformInfo + + if (other.mPlatformInfo == NULL) + return false; //only other.mPlatformInfo in NULL, because mPlatformInfo != other.mPlatformInfo + + if (memcmp(mPlatformInfo, other.mPlatformInfo, other.mPlatformInfoLength) != 0) + return false; + + return true; +} + +AEReportAttestationRequest& AEReportAttestationRequest::operator=(const AEReportAttestationRequest& other) +{ + if (this == &other) + return *this; + + ReleaseMemory(); + + CopyFields(other.mPlatformInfoLength, other.mPlatformInfo, other.mAttestationErrorCode, other.mUpdateInfoLength, other.mTimeout); + + return *this; +} + +bool AEReportAttestationRequest::check() +{ + if (mValidSizeCheck == false) + return false; + return true; +} + +IAERequest::RequestClass AEReportAttestationRequest::getRequestClass() +{ + return QUOTING_CLASS; +} + +IAEResponse* AEReportAttestationRequest::execute(IAESMLogic* aesmLogic) +{ + aesm_error_t result; + uint8_t* update_info = new uint8_t[mUpdateInfoLength]; + result = aesmLogic->reportAttestationStatus(mPlatformInfo, mPlatformInfoLength, + mAttestationErrorCode, + update_info, mUpdateInfoLength); + + IAEResponse* response = new AEReportAttestationResponse(result, mUpdateInfoLength, update_info); + delete []update_info; + return response; +} + +void AEReportAttestationRequest::visit(IAERequestVisitor& visitor) +{ + visitor.visitReportAttestationRequest(*this); +} + diff --git a/psw/ae/common/src/AEReportAttestationResponse.cpp b/psw/ae/common/src/AEReportAttestationResponse.cpp new file mode 100644 index 0000000000..cf95e70d63 --- /dev/null +++ b/psw/ae/common/src/AEReportAttestationResponse.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +AEReportAttestationResponse::AEReportAttestationResponse() : + mUpdateInfoLength(0), + mUpdateInfo(NULL) +{ +} + +AEReportAttestationResponse::AEReportAttestationResponse(int errorCode, uint32_t updateInfoLength, const uint8_t* updateInfo) : + mUpdateInfoLength(0), + mUpdateInfo(NULL) +{ + CopyFields(errorCode, updateInfoLength, updateInfo); +} + +AEReportAttestationResponse::AEReportAttestationResponse(const AEReportAttestationResponse& other) : + mUpdateInfoLength(0), + mUpdateInfo(NULL) +{ + CopyFields(other.mErrorCode, other.mUpdateInfoLength, other.mUpdateInfo); +} + +AEReportAttestationResponse::~AEReportAttestationResponse() +{ + ReleaseMemory(); +} + +void AEReportAttestationResponse::ReleaseMemory() +{ + if (mUpdateInfo != NULL) + delete [] mUpdateInfo; + mUpdateInfo = NULL; + mUpdateInfoLength = 0; + mErrorCode = SGX_ERROR_UNEXPECTED; +} + +void AEReportAttestationResponse::CopyFields(int errorCode, uint32_t updateInfoLength,const uint8_t* updateInfo) +{ + if(updateInfoLength <= MAX_MEMORY_ALLOCATION ) + { + mValidSizeCheck = true; + } + else + { + mValidSizeCheck = false; + return; + } + + mErrorCode = errorCode; + mUpdateInfoLength = updateInfoLength; + if (updateInfo != NULL && updateInfoLength > 0) + { + mUpdateInfo = new uint8_t[updateInfoLength]; + memcpy(mUpdateInfo, updateInfo, updateInfoLength); + } +} + +AEMessage* AEReportAttestationResponse::serialize(ISerializer* serializer) +{ + return serializer->serialize(this); +} + +bool AEReportAttestationResponse::inflateWithMessage(AEMessage* message, ISerializer* serializer) +{ + return serializer->inflateResponse(message, this); +} + +void AEReportAttestationResponse::inflateValues(int errorCode, uint32_t updateInfoLength, const uint8_t* updateInfo) +{ + ReleaseMemory(); + + CopyFields(errorCode, updateInfoLength, updateInfo); +} + +bool AEReportAttestationResponse::operator==(const AEReportAttestationResponse& other) const +{ + if (this == &other) + return true; + + if (mUpdateInfoLength != other.mUpdateInfoLength) + return false; + + if (mUpdateInfo == NULL && mUpdateInfo != other.mUpdateInfo) + return false; + + if (mUpdateInfo != NULL && other.mUpdateInfo != NULL) + if (memcmp(mUpdateInfo, other.mUpdateInfo, other.mUpdateInfoLength) != 0) + return false; + + return true; +} + +AEReportAttestationResponse& AEReportAttestationResponse::operator=(const AEReportAttestationResponse& other) +{ + if (this == &other) + return *this; + + inflateValues(other.mErrorCode, other.mUpdateInfoLength, other.mUpdateInfo); + + return *this; +} + +//checks +bool AEReportAttestationResponse::check() +{ + if (mErrorCode != SGX_SUCCESS) + return false; + + if (mValidSizeCheck == false) + return false; + + if (mUpdateInfo == NULL) + return false; + + return true; +} + +void AEReportAttestationResponse::visit(IAEResponseVisitor& visitor) +{ + visitor.visitReportAttestationResponse(*this); +} diff --git a/psw/ae/common/src/NonBlockingUnixCommunicationSocket.cpp b/psw/ae/common/src/NonBlockingUnixCommunicationSocket.cpp new file mode 100644 index 0000000000..3fb2bb79e3 --- /dev/null +++ b/psw/ae/common/src/NonBlockingUnixCommunicationSocket.cpp @@ -0,0 +1,445 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +NonBlockingUnixCommunicationSocket::~NonBlockingUnixCommunicationSocket() +{ + if (mEvents != NULL) + delete [] mEvents; + + close(mEpoll); + close(mCommandPipe[0]); + close(mCommandPipe[1]); + +} + +se_static_assert(MAX_EVENTS<=UINT32_MAX/sizeof(struct epoll_event)); +bool NonBlockingUnixCommunicationSocket::init() +{ + //create the epoll structure + mEpoll = epoll_create(1); + if (mEpoll < 0) + return false; + + //create the command pipe + int ret; + ret = pipe(mCommandPipe); + if (ret != 0) + { + close(mEpoll); + return false; + } + + //place one end of the pipe in the epoll list + struct epoll_event event; + event.data.fd = mCommandPipe[0]; + event.events = EPOLLIN | EPOLLET; + int registerCommand = epoll_ctl (mEpoll, EPOLL_CTL_ADD, mCommandPipe[0], &event); + + //connect to the AESM - blocking connect + bool connectInit = UnixCommunicationSocket::init(); + + //register the event + event.data.fd = mSocket; + event.events = EPOLLET; + int registerSocket = epoll_ctl (mEpoll, EPOLL_CTL_ADD, mSocket, &event); + + if (registerCommand != 0 || registerSocket != 0 || connectInit == false) + { + close(mEpoll); + close(mCommandPipe[0]); + close(mCommandPipe[1]); + + return false; + } + + //create events buffer + mEvents = new struct epoll_event[MAX_EVENTS]; + memset((char*)mEvents, 0, MAX_EVENTS * sizeof(struct epoll_event)); + + return MakeNonBlocking(); +} + +char* NonBlockingUnixCommunicationSocket::readRaw(ssize_t length) +{ + if (mSocket == -1) + return NULL; + + // Add read event + struct epoll_event event; + event.data.fd = mSocket; + event.events = EPOLLIN | EPOLLET; + int registerSocket = epoll_ctl (mEpoll, EPOLL_CTL_MOD, mSocket, &event); + if (registerSocket != 0) + { + return NULL; + } + + ssize_t total_read = 0; + ssize_t step = 0; + char * recBuf = NULL; + recBuf = new char[length]; + memset(recBuf, 0, length); + + int32_t epollTimeout = (mTimeoutMseconds > 0 ? mTimeoutMseconds : -1); + int eventNum = 0; + int i = 0; + bool errorDetected = false; + bool cancellationDetected = false; + bool peerSocketClosed = false; + + + MarkStartTime(); + + do{ + //try a direct read (maybe all data is available already) + step = read(mSocket, recBuf, length); + if (step == -1 && errno != EAGAIN) + { + errorDetected = true; + } + else + { + if (step != -1) + { + total_read += step; + } + + if (total_read == length) + { + break; //we are finished here + } + } + + //wait for events + eventNum = epoll_wait(mEpoll, mEvents, MAX_EVENTS, epollTimeout); + if (eventNum == -1) + { + errorDetected = true; + } + + for (i = 0; + CheckForTimeout() == false && //need to be sure to check this first + errorDetected == false && + cancellationDetected == false && + peerSocketClosed == false && + i < eventNum; + i++) + { + if (mEvents[i].events & EPOLLHUP) + { + peerSocketClosed = true; + continue; + } + if ((mEvents[i].events & EPOLLERR) || + (!(mEvents[i].events & EPOLLIN))) + { + //error + errorDetected = true; + } + else + { + if (mEvents[i].data.fd == mCommandPipe[0]) + { + //cancellation -- in the case this logic would complicate by needing more commands, we will detach this into + //a CommandManager of some sort + cancellationDetected = true; + } + else + { + //read data + step = partialRead(recBuf + total_read, length - total_read); + if (step == -1) + { + errorDetected = true; + } + if (step == 0) //peer closed socket + { + //did this happen before getting the entire data ? + if (total_read != length) + errorDetected = true; + } + total_read += step; + } + } + + } + + if (total_read != length) + { + if (errorDetected || cancellationDetected || wasTimeoutDetected()) + { + disconnect(); + delete [] recBuf; + recBuf = NULL; + break; + } + } + + //clear events + memset((char*)mEvents, 0, MAX_EVENTS * sizeof(struct epoll_event)); + + }while (total_read < length); + + event.data.fd = mSocket; + event.events = EPOLLET; + registerSocket = epoll_ctl (mEpoll, EPOLL_CTL_MOD, mSocket, &event); + if (registerSocket != 0) + { + disconnect(); + delete [] recBuf; + return NULL; + } + + return recBuf; +} + +/** +* Read no more than maxLength bytes +*/ +ssize_t NonBlockingUnixCommunicationSocket::partialRead(char* buffer, ssize_t maxLength) +{ + ssize_t step = 0; + ssize_t chunkSize = (maxLength < 512 ? maxLength : 512); + ssize_t totalRead = 0; + ssize_t remaining = maxLength; + + while (totalRead < maxLength) + { + remaining = maxLength - totalRead; + + step = read(mSocket, buffer + totalRead, (remaining > chunkSize ? chunkSize : remaining)); + if (step == -1) + { + if (errno != EAGAIN) + return -1; + break; + } + + totalRead += step; + if (step == 0) + break; + } + return totalRead; +} + +ssize_t NonBlockingUnixCommunicationSocket::writeRaw(const char* data, ssize_t length) +{ + if (mSocket == -1) + return -1; + + ssize_t total_write = 0; + ssize_t step = 0; + + int32_t epollTimeout = (mTimeoutMseconds > 0 ? mTimeoutMseconds : -1); + int eventNum = 0; + int i = 0; + bool errorDetected = false; + bool cancellationDetected = false; + bool peerSocketClosed = false; + + bool lastWriteSuccessful = false; + struct epoll_event event; + int registerSocket; + + MarkStartTime(); + + do + { + step = write(mSocket, data + total_write, length - total_write); + + if (step == -1 && errno != EAGAIN) + { + // an error occured + errorDetected = true; + } + else + { + if (step == -1 && errno == EAGAIN) + { + // the internal buffer is full + + // EPOLLOUT is added so that an event is generated when there is + // empty space in the buffer + lastWriteSuccessful = false; + + event.data.fd = mSocket; + event.events = EPOLLET | EPOLLOUT; + registerSocket = epoll_ctl (mEpoll, EPOLL_CTL_MOD, mSocket, &event); + if (registerSocket != 0) + { + return -1; + } + } + else + { + // the write was successful + + if (!lastWriteSuccessful) + { + // remove EPOLLOUT + lastWriteSuccessful = true; + + event.data.fd = mSocket; + event.events = EPOLLET; + registerSocket = epoll_ctl (mEpoll, EPOLL_CTL_MOD, mSocket, &event); + if (registerSocket != 0) + { + return -1; + } + } + + total_write += step; + + if (total_write == length) + { + break; + } + + continue; + } + } + + eventNum = epoll_wait(mEpoll, mEvents, MAX_EVENTS, epollTimeout); + if (eventNum == -1) + { + errorDetected = true; + } + + for (i = 0; + CheckForTimeout() == false && + errorDetected == false && + cancellationDetected == false && + peerSocketClosed == false && + i < eventNum; + i++) + { + if (mEvents[i].events & EPOLLHUP) + { + // the socket or that pipe have been closed + peerSocketClosed = true; + continue; + } + if ((mEvents[i].events & EPOLLERR) || + (!(mEvents[i].events & EPOLLOUT))) + { + // received an event other than EPOLLOUT + errorDetected = true; + } + else + { + if (mEvents[i].data.fd == mCommandPipe[0]) + { + cancellationDetected = true; + } + } + } + + if (errorDetected || cancellationDetected || wasTimeoutDetected() || peerSocketClosed) + { + disconnect(); + break; + } + + memset((char*)mEvents, 0, MAX_EVENTS * sizeof(struct epoll_event)); + } + while(total_write < length); + + event.data.fd = mSocket; + event.events = EPOLLET; + registerSocket = epoll_ctl (mEpoll, EPOLL_CTL_MOD, mSocket, &event); + if (registerSocket != 0) + { + return -1; + } + + return total_write; +} + +int NonBlockingUnixCommunicationSocket::getSockDescriptor() +{ + return UnixCommunicationSocket::getSockDescriptor(); +} + +bool NonBlockingUnixCommunicationSocket::wasTimeoutDetected() +{ + return UnixCommunicationSocket::wasTimeoutDetected(); +} + +bool NonBlockingUnixCommunicationSocket::setTimeout(uint32_t milliseconds) +{ + mTimeoutMseconds = milliseconds; + return true; +} + +bool NonBlockingUnixCommunicationSocket::MakeNonBlocking() +{ + int flags, ret; + + flags = fcntl (mSocket, F_GETFL, 0); + if (flags == -1) + { + return false; + } + + flags |= (int)O_NONBLOCK; + ret = fcntl (mSocket, F_SETFL, flags); + if (ret == -1) + { + return false; + } + + return true; +} + +void NonBlockingUnixCommunicationSocket::Cancel() const +{ + //write anything on the pipe + char cmd = '1'; + if (write(mCommandPipe[0],&cmd,1) < 0) + { + // do nothing + } +} diff --git a/psw/ae/common/src/NonBlockingUnixSocketFactory.cpp b/psw/ae/common/src/NonBlockingUnixSocketFactory.cpp new file mode 100644 index 0000000000..461e58f765 --- /dev/null +++ b/psw/ae/common/src/NonBlockingUnixSocketFactory.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +ICommunicationSocket* NonBlockingUnixSocketFactory::NewCommunicationSocket() +{ + NonBlockingUnixCommunicationSocket* sock = new NonBlockingUnixCommunicationSocket(mSocketBase); + bool initializationSuccessfull = false; + + if (sock != NULL) + initializationSuccessfull = sock->init(); + + if (initializationSuccessfull == false) + { + delete sock; + sock = NULL; + } + + return sock; + +} diff --git a/psw/ae/common/src/ProtobufSerializer.cpp b/psw/ae/common/src/ProtobufSerializer.cpp new file mode 100644 index 0000000000..aec29bc3b8 --- /dev/null +++ b/psw/ae/common/src/ProtobufSerializer.cpp @@ -0,0 +1,1289 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Implementation of serializer based on google protobufs + */ + +#include +#include +#include + +/* must include this AFTER ProtobufSerializer.h */ +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +using namespace google::protobuf; + +#define UNUSED(val) (void)(val) + +/* + * InitQuote + */ + + +AEMessage* ProtobufSerializer::serialize(AEInitQuoteRequest* request) +{ + //kill the warning + UNUSED(request); + + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::InitQuoteRequest proto_req; + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::InitQuoteRequest* mutableReq = msg.mutable_initquotereq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_initquotereq(); //free the internal object + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.c_str(), ae_msg->size); + } + delete mutableReq; + } + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AEInitQuoteResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::InitQuoteResponse proto_res; + + if (response->GetGID() != NULL) + { + std::string gid((const char*)response->GetGID(), response->GetGIDLength()); + proto_res.set_gid(gid); + } + + if (response->GetTargetInfo() != NULL) + { + std::string target_info((const char*)response->GetTargetInfo(), response->GetTargetInfoLength()); + proto_res.set_targetinfo(target_info); + } + + proto_res.set_errorcode(response->GetErrorCode()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::InitQuoteResponse* mutableRes = msg.mutable_initquoteres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_initquoteres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), data.size()); + } + + delete mutableRes; + } + return ae_msg; +} + +IAERequest* ProtobufSerializer::inflateGetQuoteRequest(aesm::message::Request* reqMsg) +{ + aesm::message::Request::GetQuoteRequest proto_req = reqMsg->getquotereq(); + + uint32_t report_length = 0; + uint8_t* report = NULL; + uint32_t spid_length = 0; + uint8_t* spid = NULL; + uint32_t nonce_length = 0; + uint8_t* nonce = NULL; + uint32_t sig_rl_length = 0; + uint8_t* sig_rl = NULL; + + if (proto_req.has_report()) + { + if(proto_req.report().size() > UINT_MAX) { + return NULL; + } + report_length = (unsigned int) proto_req.report().size(); + report = (uint8_t*)const_cast(proto_req.report().data()); + } + if (proto_req.has_spid()) + { + if(proto_req.spid().size() > UINT_MAX) { + return NULL; + } + spid_length = (unsigned int) proto_req.spid().size(); + spid = (uint8_t*)const_cast(proto_req.spid().data()); + } + if (proto_req.has_nonce()) + { + if(proto_req.nonce().size() > UINT_MAX) { + return NULL; + } + nonce_length = (unsigned int) proto_req.nonce().size(); + nonce = (uint8_t*)const_cast(proto_req.nonce().data()); + } + if (proto_req.has_sig_rl()) + { + if(proto_req.sig_rl().size() > UINT_MAX) { + return NULL; + } + sig_rl_length = (unsigned int) proto_req.sig_rl().size(); + sig_rl = (uint8_t*)const_cast(proto_req.sig_rl().data()); + } + + AEGetQuoteRequest* request = new AEGetQuoteRequest(); + request->inflateValues(report_length, report, + proto_req.quote_type(), + spid_length, spid, + nonce_length, nonce, + sig_rl_length, sig_rl, + proto_req.buf_size(), + proto_req.qe_report(), + proto_req.timeout()); + + return request; +} + +IAERequest* ProtobufSerializer::inflateInitQuoteRequest(aesm::message::Request* reqMsg) +{ + AEInitQuoteRequest* request = new AEInitQuoteRequest(); + aesm::message::Request::InitQuoteRequest proto_req = reqMsg->initquotereq(); + + request->inflateValues(proto_req.timeout()); + return request; +} + +IAERequest* ProtobufSerializer::inflateCloseSessionRequest(aesm::message::Request* reqMsg) +{ + AECloseSessionRequest* request = new AECloseSessionRequest(); + aesm::message::Request::CloseSessionRequest proto_req = reqMsg->closesessionreq(); + + request->inflateValues(proto_req.session_id(), proto_req.timeout()); + return request; +} + +IAERequest* ProtobufSerializer::inflateCreateSessionRequest(aesm::message::Request* reqMsg) +{ + AECreateSessionRequest* request = new AECreateSessionRequest(); + aesm::message::Request::CreateSessionRequest proto_req = reqMsg->createsessionreq(); + + request->inflateValues(proto_req.dh_msg1_size(), proto_req.timeout()); + + return request; +} + +IAERequest* ProtobufSerializer::inflateExchangeReportRequest(aesm::message::Request* reqMsg) +{ + aesm::message::Request::ExchangeReportRequest proto_req = reqMsg->exchangereportreq(); + + uint32_t dh_msg2_length = 0; + uint8_t* dh_msg2 = NULL; + + if (proto_req.has_se_dh_msg2()) + { + if(proto_req.se_dh_msg2().size() > UINT_MAX) { + return NULL; + } + dh_msg2_length = (unsigned int)proto_req.se_dh_msg2().size(); + dh_msg2 = (uint8_t*)const_cast(proto_req.se_dh_msg2().data()); + } + + AEExchangeReportRequest* request = new AEExchangeReportRequest(); + request->inflateValues(proto_req.session_id(), + dh_msg2_length, + dh_msg2, + proto_req.se_dh_msg3_size(), + proto_req.timeout()); + + return request; +} + +IAERequest* ProtobufSerializer::inflateGetLaunchTokenRequest(aesm::message::Request* reqMsg) +{ + aesm::message::Request::GetLaunchTokenRequest proto_req = reqMsg->getlictokenreq(); + + uint32_t mr_enclave_length = 0; + uint8_t* mr_enclave = NULL; + uint32_t mr_signer_length = 0; + uint8_t* mr_signer = NULL; + uint32_t se_attributes_length = 0; + uint8_t* se_attributes = NULL; + + if (proto_req.has_mr_enclave()) + { + if(proto_req.mr_enclave().size() > UINT_MAX) { + return NULL; + } + mr_enclave_length = (unsigned int)proto_req.mr_enclave().size(); + mr_enclave = (uint8_t*)const_cast(proto_req.mr_enclave().data()); + } + if (proto_req.has_mr_signer()) + { + if(proto_req.mr_signer().size() > UINT_MAX) { + return NULL; + } + mr_signer_length = (unsigned int)proto_req.mr_signer().size(); + mr_signer = (uint8_t*)const_cast(proto_req.mr_signer().data()); + } + if (proto_req.has_se_attributes()) + { + if(proto_req.se_attributes().size() > UINT_MAX) { + return NULL; + } + se_attributes_length = (unsigned int)proto_req.se_attributes().size(); + se_attributes = (uint8_t*)const_cast(proto_req.se_attributes().data()); + } + + AEGetLaunchTokenRequest* request = new AEGetLaunchTokenRequest(); + request->inflateValues(mr_enclave_length, mr_enclave, + mr_signer_length, mr_signer, + se_attributes_length, se_attributes, + proto_req.timeout()); + + return request; +} + +IAERequest* ProtobufSerializer::inflateInvokeServiceRequest(aesm::message::Request* reqMsg) +{ + aesm::message::Request::InvokeServiceRequest proto_req = reqMsg->invokeservicereq(); + + uint32_t pse_message_length = 0; + uint8_t* pse_message = NULL; + + if (proto_req.has_pse_message()) + { + if(proto_req.pse_message().size() > UINT_MAX) { + return NULL; + } + pse_message_length = (unsigned int)proto_req.pse_message().size(); + pse_message = (uint8_t*)const_cast(proto_req.pse_message().data()); + } + + AEInvokeServiceRequest* request = new AEInvokeServiceRequest(); + request->inflateValues(pse_message_length, pse_message, proto_req.pse_resp_size(), proto_req.timeout()); + + return request; +} + +IAERequest* ProtobufSerializer::inflateGetPsCapRequest(aesm::message::Request* reqMsg) +{ + AEGetPsCapRequest* request = new AEGetPsCapRequest(); + aesm::message::Request::GetPsCapRequest proto_req = reqMsg->getpscapreq(); + + request->inflateValues(proto_req.timeout()); + return request; +} + +IAERequest* ProtobufSerializer::inflateReportAttestationErrorRequest(aesm::message::Request* reqMsg) +{ + aesm::message::Request::ReportAttestationErrorRequest proto_req = reqMsg->reporterrreq(); + + uint32_t attestation_error_code = -1; + if (proto_req.has_attestation_error_code()) + { + attestation_error_code = proto_req.attestation_error_code(); + } + uint32_t update_info_size = 0; + if (proto_req.has_update_info_size()) + { + update_info_size = proto_req.update_info_size(); + } + uint32_t platform_info_length = 0; + uint8_t* platform_info = NULL; + if (proto_req.has_platform_info()) + { + if(proto_req.platform_info().size() > UINT_MAX) { + return NULL; + } + platform_info_length = (unsigned int)proto_req.platform_info().size(); + platform_info = (uint8_t*)const_cast(proto_req.platform_info().data()); + } + + AEReportAttestationRequest* request = new AEReportAttestationRequest(); + request->inflateValues(platform_info_length, platform_info, attestation_error_code, update_info_size, proto_req.timeout()); + return request; +} + +IAERequest* ProtobufSerializer::inflateRequest(AEMessage* message) { + if (message == NULL || message->data == NULL) + return NULL; + + std::string data((char*)message->data, message->size); + aesm::message::Request* reqMsg = new aesm::message::Request(); + + reqMsg->ParseFromString(data); + IAERequest* request = NULL; + if (reqMsg->has_initquotereq() == true) + request = inflateInitQuoteRequest(reqMsg); + if (reqMsg->has_getquotereq() == true) + request = inflateGetQuoteRequest(reqMsg); + if (reqMsg->has_closesessionreq() == true) + request = inflateCloseSessionRequest(reqMsg); + if (reqMsg->has_createsessionreq() == true) + request = inflateCreateSessionRequest(reqMsg); + if (reqMsg->has_exchangereportreq() == true) + request = inflateExchangeReportRequest(reqMsg); + if (reqMsg->has_getlictokenreq() == true) + request = inflateGetLaunchTokenRequest(reqMsg); + if (reqMsg->has_invokeservicereq() == true) + request = inflateInvokeServiceRequest(reqMsg); + if (reqMsg->has_getpscapreq() == true) + request = inflateGetPsCapRequest(reqMsg); + if (reqMsg->has_reporterrreq() == true) + request = inflateReportAttestationErrorRequest(reqMsg); + delete reqMsg; + return request; +} + +//return false if inflate failed +bool ProtobufSerializer::inflateResponse(AEMessage* message, AEInitQuoteResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_initquoteres() == false) + return false; + + //this is an AEInitQuoteResponse + aesm::message::Response::InitQuoteResponse proto_res = msg.initquoteres(); + + uint32_t gid_length = 0; + uint8_t* gid = NULL; + uint32_t target_info_length = 0; + uint8_t* target_info = NULL; + + if (proto_res.has_gid()) + { + if(proto_res.gid().size() > UINT_MAX) { + return NULL; + } + gid_length = (unsigned int)proto_res.gid().size(); + gid = (uint8_t*)const_cast(proto_res.gid().data()); + } + if (proto_res.has_targetinfo()) + { + if(proto_res.targetinfo().size() > UINT_MAX) { + return NULL; + } + + target_info_length = (unsigned int) proto_res.targetinfo().size(); + target_info = (uint8_t*)const_cast(proto_res.targetinfo().data()); + } + + response->inflateValues(proto_res.errorcode(), + gid_length, gid, + target_info_length, target_info); + + return true; +} + + +/* + * GetQuote + */ + + +AEMessage* ProtobufSerializer::serialize(AEGetQuoteRequest* request) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::GetQuoteRequest proto_req;//= new aesm::message::Response::InitQuoteResponse(); + + if (request->GetReport() != NULL) + { + std::string report((const char*)request->GetReport(), request->GetReportLength()); + proto_req.set_report(report); + } + + if (request->GetSigRL() != NULL) + { + std::string sig_rl((const char*)request->GetSigRL(), request->GetSigRLLength()); + proto_req.set_sig_rl(sig_rl); + } + + if (request->GetNonce() != NULL) + { + std::string nonce((const char*)request->GetNonce(), request->GetNonceLength()); + proto_req.set_nonce(nonce); + } + + if (request->GetSPID() != NULL) + { + std::string spid((const char*)request->GetSPID(), request->GetSPIDLength()); + proto_req.set_spid(spid); + } + + proto_req.set_quote_type(request->GetQuoteType()); + proto_req.set_buf_size(request->GetBufferSize()); + proto_req.set_qe_report(request->GetQEReport()); + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::GetQuoteRequest* mutableReq = msg.mutable_getquotereq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_getquotereq(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.c_str(), ae_msg->size); + } + delete mutableReq; + } + + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AEGetQuoteResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::GetQuoteResponse proto_res;//= new aesm::message::Response::InitQuoteResponse(); + + proto_res.set_errorcode(response->GetErrorCode()); + + if (response->GetQuote() != NULL) + { + std::string quote((const char*)response->GetQuote(), response->GetQuoteLength()); + proto_res.set_quote(quote); + } + + + if (response->GetQEReport() != NULL) + { + std::string qe_report((const char*)response->GetQEReport(), response->GetQEReportLength()); + proto_res.set_qe_report(qe_report); + } + + if (proto_res.IsInitialized()) + { + aesm::message::Response::GetQuoteResponse* mutableRes = msg.mutable_getquoteres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_getquoteres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.c_str(), ae_msg->size); + } + delete mutableRes; + } + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AEGetQuoteResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_getquoteres() == false) + return false; + + //this is an AEInitQuoteResponse + aesm::message::Response::GetQuoteResponse proto_res = msg.getquoteres(); + + uint32_t qe_report_length = 0; + uint8_t* qe_report = NULL; + uint32_t quote_length = 0; + uint8_t* quote = NULL; + uint32_t errorCode = proto_res.errorcode(); + + if (proto_res.has_quote()) + { + if (proto_res.quote().size() > UINT_MAX) { + return false; + } + quote_length = (unsigned int) proto_res.quote().size(); + quote = (uint8_t*)const_cast(proto_res.quote().data()); + } + + if (proto_res.has_qe_report()) + { + if (proto_res.qe_report().size() > UINT_MAX) { + return false; + } + qe_report_length = (unsigned int) proto_res.qe_report().size(); + qe_report = (uint8_t*)const_cast(proto_res.qe_report().data()); + } + + + response->inflateValues(errorCode, + quote_length, + quote, + qe_report_length, + qe_report); + + return true; +} + +/******** + GET Launch Token + ********/ + +AEMessage* ProtobufSerializer::serialize(AEGetLaunchTokenRequest* request) +{ + if (request->check() == false) + return NULL; + + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::GetLaunchTokenRequest proto_req; + + if (request->GetMeasurement() != NULL) + { + std::string mr_enclave((const char*)request->GetMeasurement(), request->GetMeasurementLength()); + proto_req.set_mr_enclave(mr_enclave); + } + + if (request->GetSigstruct() != NULL) + { + std::string mr_signer((const char*)request->GetSigstruct(), request->GetSigstructLength()); + proto_req.set_mr_signer(mr_signer); + } + + if (request->GetAttributes() != NULL) + { + std::string se_attributes((const char*)request->GetAttributes(), request->GetAttributesLength()); + proto_req.set_se_attributes(se_attributes); + } + + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::GetLaunchTokenRequest* mutableReq = msg.mutable_getlictokenreq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_getlictokenreq(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, (const char*)data.data(), ae_msg->size); + } + delete mutableReq; + } + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AEGetLaunchTokenResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::GetLaunchTokenResponse proto_res; + + if (response->GetToken() != NULL) + { + std::string token((const char*)response->GetToken(), response->GetTokenLength()); + proto_res.set_token(token); + } + + proto_res.set_errorcode(response->GetErrorCode()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::GetLaunchTokenResponse* mutableRes = msg.mutable_getlictokenres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_getlictokenres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableRes; + } + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AEGetLaunchTokenResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_getlictokenres() == false) + return false; + + //this is an AEInitQuoteResponse + aesm::message::Response::GetLaunchTokenResponse proto_res = msg.getlictokenres(); + + uint32_t errorCode = proto_res.errorcode(); + uint32_t token_length = 0; + uint8_t* token = NULL; + + if (proto_res.has_token()) + { + if (proto_res.token().size() > UINT_MAX) { + return false; + } + token_length = (unsigned int)proto_res.token().size(); + token = (uint8_t*)const_cast(proto_res.token().data()); + } + + response->inflateValues(errorCode, + token_length, + token); + + return true; +} + +AEMessage* ProtobufSerializer::serialize(AECreateSessionRequest* request){ + + //kill the warning + UNUSED(request); + + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::CreateSessionRequest proto_req; + + proto_req.set_dh_msg1_size(request->GetDHMsg1Size()); + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::CreateSessionRequest* mutableReq = msg.mutable_createsessionreq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_createsessionreq(); //free the internal object + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + + delete mutableReq; + } + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AECreateSessionResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::CreateSessionResponse proto_res; + + if (response->GetDHMsg1() != NULL) + { + std::string se_dh_msg1((const char*)response->GetDHMsg1(), response->GetDHMsg1Length()); + proto_res.set_se_dh_msg1(se_dh_msg1); + } + + proto_res.set_errorcode(response->GetErrorCode()); + proto_res.set_session_id(response->GetSessionId()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::CreateSessionResponse* mutableRes = msg.mutable_createsessionres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_createsessionres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableRes; + } + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AECreateSessionResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_createsessionres() == false) + return false; + + aesm::message::Response::CreateSessionResponse proto_res = msg.createsessionres(); + + uint32_t errorCode = proto_res.errorcode(); + uint32_t session_id = proto_res.session_id(); + uint32_t dh_msg1_length = 0; + uint8_t* dh_msg1 = NULL; + + if (proto_res.has_se_dh_msg1()) + { + if (proto_res.se_dh_msg1().size() > UINT_MAX) { + return false; + } + dh_msg1_length = (unsigned int) proto_res.se_dh_msg1().size(); + dh_msg1 = (uint8_t*)const_cast(proto_res.se_dh_msg1().data()); + } + + response->inflateValues(errorCode, + session_id, + dh_msg1_length, + dh_msg1); + + return true; +} + +/* + * Invoke Service + */ + +AEMessage* ProtobufSerializer::serialize(AEInvokeServiceRequest* request) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::InvokeServiceRequest proto_req; + + if (request->GetPSEMessage() != NULL) + { + std::string pse_message((const char*)request->GetPSEMessage(), request->GetPSEMessageLength()); + proto_req.set_pse_message(pse_message); + } + + proto_req.set_pse_resp_size(request->GetResponseSize()); + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::InvokeServiceRequest* mutableReq = msg.mutable_invokeservicereq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_invokeservicereq(); //free the internal object + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableReq; + } + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AEInvokeServiceResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::InvokeServiceResponse proto_res; + + if (response->GetPSEMessage() != NULL) + { + std::string pse_message((const char*)response->GetPSEMessage(), response->GetPSEMessageLength()); + proto_res.set_pse_message(pse_message); + } + + proto_res.set_errorcode(response->GetErrorCode()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::InvokeServiceResponse* mutableRes = msg.mutable_invokeserviceres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_invokeserviceres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableRes; + } + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AEInvokeServiceResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_invokeserviceres() == false) + return false; + + aesm::message::Response::InvokeServiceResponse proto_res = msg.invokeserviceres(); + + uint32_t errorCode = proto_res.errorcode(); + uint32_t pse_message_length = 0; + uint8_t* pse_message = NULL; + + if (proto_res.has_pse_message()) + { + if (proto_res.pse_message().size() > UINT_MAX) { + return false; + } + pse_message_length = (unsigned int) proto_res.pse_message().size(); + pse_message = (uint8_t*)const_cast(proto_res.pse_message().data()); + } + + response->inflateValues(errorCode, + pse_message_length, + pse_message); + + return true; +} + +/* + * Exchange REPORT + */ + +AEMessage* ProtobufSerializer::serialize(AEExchangeReportRequest* request) +{ + AEMessage* ae_msg = NULL; + + std::string data; + + aesm::message::Request msg; + aesm::message::Request::ExchangeReportRequest proto_req; + + if (request->GetDHMsg2() != NULL) + { + std::string se_dh_msg2((const char*)request->GetDHMsg2(), request->GetDHMsg2Length()); + proto_req.set_se_dh_msg2(se_dh_msg2); + } + + proto_req.set_session_id(request->GetSessionId()); + proto_req.set_se_dh_msg3_size(request->GetDHMsg3Length()); + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::ExchangeReportRequest* mutableReq = msg.mutable_exchangereportreq(); + + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_exchangereportreq(); //free the internal object + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableReq; + + } + + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AEExchangeReportResponse* response) +{ + std::string data; + AEMessage* ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::ExchangeReportResponse proto_res; + + if (response->GetDHMsg3() != NULL) + { + std::string se_dh_msg3((const char*)response->GetDHMsg3(), response->GetDHMsg3Length()); + proto_res.set_se_dh_msg3(se_dh_msg3); + } + + proto_res.set_errorcode(response->GetErrorCode()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::ExchangeReportResponse* mutableRes = msg.mutable_exchangereportres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_exchangereportres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableRes; + } + + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AEExchangeReportResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_exchangereportres() == false) + return false; + + aesm::message::Response::ExchangeReportResponse proto_res = msg.exchangereportres(); + + uint32_t errorCode = proto_res.errorcode(); + uint32_t dh_msg3_length = 0; + uint8_t* dh_msg3 = NULL; + + if (proto_res.has_se_dh_msg3()) + { + if (proto_res.se_dh_msg3().size() > UINT_MAX) { + return false; + } + dh_msg3_length = (unsigned int) proto_res.se_dh_msg3().size(); + dh_msg3 = (uint8_t*)const_cast(proto_res.se_dh_msg3().data()); + } + + + response->inflateValues(errorCode, + dh_msg3_length, + dh_msg3); + + return true; + +} + +/* + * CLOSE SESSION + */ + +AEMessage* ProtobufSerializer::serialize(AECloseSessionRequest* request) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::CloseSessionRequest proto_req; + + proto_req.set_session_id(request->GetSessionId()); + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::CloseSessionRequest* mutableReq = msg.mutable_closesessionreq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_closesessionreq(); //free the internal object + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableReq; + } + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AECloseSessionResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::CloseSessionResponse proto_res; + + proto_res.set_errorcode(response->GetErrorCode()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::CloseSessionResponse* mutableRes = msg.mutable_closesessionres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_closesessionres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), ae_msg->size); + } + delete mutableRes; + } + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AECloseSessionResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_closesessionres() == false) + return false; + + aesm::message::Response::CloseSessionResponse proto_res = msg.closesessionres(); + response->inflateValues(proto_res.errorcode()); + + return true; +} + + +AEMessage* ProtobufSerializer::serialize(AEGetPsCapRequest* request) +{ + //kill the warning + UNUSED(request); + + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::GetPsCapRequest proto_req; + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::GetPsCapRequest* mutableReq = msg.mutable_getpscapreq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_getpscapreq(); //free the internal object + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.c_str(), ae_msg->size); + } + delete mutableReq; + } + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AEGetPsCapResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::GetPsCapResponse proto_res; + + proto_res.set_errorcode(response->GetErrorCode()); + proto_res.set_ps_cap(response->GetPsCap()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::GetPsCapResponse* mutableRes = msg.mutable_getpscapres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_getpscapres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), data.size()); + } + delete mutableRes; + } + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AEGetPsCapResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_getpscapres() == false) + return false; + + aesm::message::Response::GetPsCapResponse proto_res = msg.getpscapres(); + uint32_t errorCode = proto_res.errorcode(); + uint64_t ps_cap = -1; + if (proto_res.has_ps_cap()) + { + ps_cap = proto_res.ps_cap(); + } + response->inflateValues(errorCode, + ps_cap); + + return true; +} + + +AEMessage* ProtobufSerializer::serialize(AEReportAttestationRequest* request) +{ + //kill the warning + UNUSED(request); + + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Request msg; + aesm::message::Request::ReportAttestationErrorRequest proto_req; + if (request->GetPlatformInfo() != NULL) + { + std::string platform_info((const char*)request->GetPlatformInfo(), request->GetPlatformInfoLength()); + proto_req.set_platform_info(platform_info); + } + proto_req.set_attestation_error_code(request->GetAttestationErrorCode()); + proto_req.set_update_info_size(request->GetUpdateInfoLength()); + proto_req.set_timeout(request->GetTimeout()); + + if (proto_req.IsInitialized()) + { + aesm::message::Request::ReportAttestationErrorRequest* mutableReq = msg.mutable_reporterrreq(); + mutableReq->CopyFrom(proto_req); + msg.SerializeToString(&data); + msg.release_reporterrreq(); //free the internal object + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.c_str(), ae_msg->size); + } + delete mutableReq; + } + return ae_msg; +} + +AEMessage* ProtobufSerializer::serialize(AEReportAttestationResponse* response) +{ + std::string data; + AEMessage *ae_msg = NULL; + + aesm::message::Response msg; + aesm::message::Response::ReportAttestationErrorResponse proto_res; + + if (response->GetUpdateInfo() != NULL) + { + std::string platform_update_info((const char*)response->GetUpdateInfo(), response->GetUpdateInfoLength()); + proto_res.set_platform_update_info(platform_update_info); + } + + + proto_res.set_errorcode(response->GetErrorCode()); + + if (proto_res.IsInitialized()) + { + aesm::message::Response::ReportAttestationErrorResponse* mutableRes = msg.mutable_reporterrres(); + mutableRes->CopyFrom(proto_res); + msg.SerializeToString(&data); + msg.release_reporterrres(); + + if (data.size() <= UINT_MAX) { + ae_msg = new AEMessage; + ae_msg->size = (unsigned int) data.size(); + ae_msg->data = new char[ae_msg->size]; + memcpy(ae_msg->data, data.data(), data.size()); + } + delete mutableRes; + } + return ae_msg; +} + +bool ProtobufSerializer::inflateResponse(AEMessage* message, AEReportAttestationResponse* response) +{ + std::string data((char*)message->data, message->size); + aesm::message::Response msg; + + msg.ParseFromString(data); + if (msg.has_reporterrres() == false) + return false; + + aesm::message::Response::ReportAttestationErrorResponse proto_res = msg.reporterrres(); + uint32_t errorCode = proto_res.errorcode(); + uint32_t platform_update_info_length = 0; + uint8_t* platform_update_info = NULL; + + if (proto_res.has_platform_update_info()) + { + if (proto_res.platform_update_info().size() > UINT_MAX) { + return false; + } + platform_update_info_length = (unsigned int) proto_res.platform_update_info().size(); + platform_update_info = (uint8_t*)const_cast(proto_res.platform_update_info().data()); + } + response->inflateValues(errorCode, + platform_update_info_length, + platform_update_info); + + return true; +} diff --git a/psw/ae/common/src/SocketTransporter.cpp b/psw/ae/common/src/SocketTransporter.cpp new file mode 100644 index 0000000000..96c7f621a6 --- /dev/null +++ b/psw/ae/common/src/SocketTransporter.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include + +#include +#include +#include +#include + +#include +#include + +SocketTransporter::SocketTransporter(ISocketFactory* socketFactory, ISerializer* serializer) +:mSocketFactory(NULL), mSerializer(NULL) +{ + mSocketFactory = socketFactory; + mSerializer = serializer; +} + +SocketTransporter::~SocketTransporter() +{ + if (mSocketFactory != NULL) + { + delete mSocketFactory; + mSocketFactory = NULL; + } + if (mSerializer != NULL) + { + delete mSerializer; + mSerializer = NULL; + } +} + +AEMessage* SocketTransporter::receiveMessage(ICommunicationSocket* sock) { + AEMessage * message = new AEMessage; + char* msgSize = NULL; + msgSize = sock->readRaw(sizeof(AEMessage::size)); + if (msgSize != NULL) + { + memcpy((char*)&message->size, msgSize, sizeof(message->size)); + message->data = sock->readRaw(message->size); + delete [] msgSize; + } + return message; +} + +uae_oal_status_t SocketTransporter::sendMessage(AEMessage *message, ICommunicationSocket* sock) { + if ((sock->writeRaw((char*)&message->size, sizeof(message->size))) == -1) + return UAE_OAL_ERROR_UNEXPECTED; + if ((sock->writeRaw(message->data, message->size)) == -1) + return UAE_OAL_ERROR_UNEXPECTED; + return UAE_OAL_SUCCESS; +} + +uae_oal_status_t SocketTransporter::transact(IAERequest* request, IAEResponse* response) +{ + if (request == NULL || response == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + + ICommunicationSocket* communicationSocket = mSocketFactory->NewCommunicationSocket(); + + if (communicationSocket == NULL) + return UAE_OAL_ERROR_AESM_UNAVAILABLE; + + uae_oal_status_t ret = UAE_OAL_ERROR_UNEXPECTED; + + //set the timeout value + if (request->GetTimeout() > 0) + communicationSocket->setTimeout(request->GetTimeout()); + + AEMessage * reqMsg = request->serialize(mSerializer); + + if (reqMsg != NULL) + { + //send the request + ret = sendMessage(reqMsg, communicationSocket); + if (ret == UAE_OAL_SUCCESS) + { + + //read the response + AEMessage * resMsg = receiveMessage(communicationSocket); + + if (communicationSocket->wasTimeoutDetected() == false) + { + if (resMsg != NULL && resMsg->data != NULL) + response->inflateWithMessage(resMsg, mSerializer); + else + ret = UAE_OAL_ERROR_UNEXPECTED; + } + + delete resMsg; + } + } + + if (communicationSocket->wasTimeoutDetected() == true) + ret = UAE_OAL_ERROR_TIMEOUT; + + //free stuff + delete reqMsg; + delete communicationSocket; + + return ret; +} + +IAERequest* SocketTransporter::receiveRequest(ICommunicationSocket* sock) { + AEMessage * msg = receiveMessage(sock); + IAERequest* request = mSerializer->inflateRequest(msg); + delete msg; + return request; +} + +uae_oal_status_t SocketTransporter::sendResponse(IAEResponse* response, ICommunicationSocket* sock) { + AEMessage * message = response->serialize(mSerializer); + uae_oal_status_t retVal = sendMessage(message, sock); + delete message; + return retVal; +} diff --git a/psw/ae/common/src/UnixCommunicationSocket.cpp b/psw/ae/common/src/UnixCommunicationSocket.cpp new file mode 100644 index 0000000000..d261a8b0d6 --- /dev/null +++ b/psw/ae/common/src/UnixCommunicationSocket.cpp @@ -0,0 +1,232 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +UnixCommunicationSocket::UnixCommunicationSocket(const char* socketbase) +:mSocketBase(NULL), mWasTimeout(false), mTimeoutMseconds(0) +{ + //doing all this manually to ensure based memory allocation across the solution + size_t size = strlen(socketbase) + 1; + //ensure a fairly decend size for socketbase is not overflowed + if (size > 255) + return; //a socketbase of more than 255 chars may break the system on connect + + mSocketBase = new char[size]; + memset(mSocketBase, 0, size); + strncpy(mSocketBase, socketbase, size); + + mSocket = -1; + + memset(&mStartTime, 0, sizeof(struct timeval)); +} + +UnixCommunicationSocket::UnixCommunicationSocket(int socket) +:mSocketBase(NULL), mWasTimeout(false), mTimeoutMseconds(0) +{ + mSocket = socket; + + memset(&mStartTime, 0, sizeof(struct timeval)); +} + +UnixCommunicationSocket::~UnixCommunicationSocket() +{ + disconnect(); + if (mSocketBase != NULL) + { + delete [] mSocketBase; + mSocketBase = NULL; + } +} + +void UnixCommunicationSocket::disconnect() +{ + if (mSocket != -1){ + close(mSocket); + mSocket = -1; + } +} + +bool UnixCommunicationSocket::setTimeout(uint32_t timeout_milliseconds) +{ + struct timeval timeout; + + mTimeoutMseconds = timeout_milliseconds; + timeout.tv_sec = timeout_milliseconds / 1000; + + uint32_t millisecondsRemainder = timeout_milliseconds % 1000; + timeout.tv_usec = millisecondsRemainder * 1000; + + int rc = 0; + rc = setsockopt (mSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)); + if (rc < 0) + return false; + + rc = setsockopt (mSocket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)); + if (rc < 0) + return false; + + return true; +} + +void UnixCommunicationSocket::MarkStartTime() +{ + gettimeofday(&mStartTime,NULL); +} + +bool UnixCommunicationSocket::CheckForTimeout() +{ + mWasTimeout = false; + + if (mTimeoutMseconds == 0) + return false; + + struct timeval now; + gettimeofday(&now, NULL); + + uint32_t sec = (uint32_t) (now.tv_sec - mStartTime.tv_sec); + int32_t usec = (int32_t) (now.tv_usec - mStartTime.tv_usec); + + uint32_t delta_msec = (uint32_t) (sec * 1000 + usec / 1000); + + if (delta_msec >= mTimeoutMseconds) + { + mWasTimeout = true; + return true; + } + + return false; +} + +ssize_t UnixCommunicationSocket::writeRaw(const char* data, ssize_t length) +{ + MarkStartTime(); + + if (length > MAX_MEMORY_ALLOCATION) + { + return -1; + } + + if (mSocket == -1) + return -1; + + ssize_t written = 0; + do { + ssize_t step = write(mSocket, data+written, length-written); + + if (step < 0 || CheckForTimeout()) + { + //this connection is probably closed + disconnect(); + break; + } + + written+=step; + } while (written < length); + + return written; +} + +char* UnixCommunicationSocket::readRaw(ssize_t length) +{ + if (mSocket == -1) + return NULL; + + MarkStartTime(); + + ssize_t total_read = 0; + char * recBuf = NULL; + recBuf = new char[length]; + memset(recBuf, 0, length); + + do { + ssize_t step = read(mSocket, recBuf + total_read, length - total_read); + + //check connection closed by peer + if (step <= 0 || CheckForTimeout()) + { + //this connection is probably closed + disconnect(); + delete[] recBuf; + recBuf = NULL; + break; + } + + total_read += step; + } while (total_read < length); + + return recBuf; +} + +//this will connect to the AESM by opening an Unix Socket +bool UnixCommunicationSocket::init() +{ + //init will always return directly with success if object was created with pre-existent socket + if (mSocket == -1) + { + struct sockaddr_un serv_addr; + + mSocket = socket(AF_UNIX, SOCK_STREAM, 0); + if(mSocket < 0) + { + return false; + } + + memset(&serv_addr, 0, sizeof(struct sockaddr_un)); + serv_addr.sun_family = AF_UNIX; + memset(serv_addr.sun_path, 0, sizeof(serv_addr.sun_path)); + // leave the first byte to 0 in order to have an abstract socket address + strncpy(serv_addr.sun_path + 1, mSocketBase, sizeof(serv_addr.sun_path) - 1); + + if( connect(mSocket, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) + { + return false; + } + if (mSocket < 0) + return false; + } + return true; +} + +int UnixCommunicationSocket::getSockDescriptor() { + return mSocket; +} diff --git a/psw/ae/common/src/UnixSocketFactory.cpp b/psw/ae/common/src/UnixSocketFactory.cpp new file mode 100644 index 0000000000..ac4eacf6ae --- /dev/null +++ b/psw/ae/common/src/UnixSocketFactory.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +#define MAX_SIZE 255 + +UnixSocketFactory::UnixSocketFactory(const char* socketbase) +:mSocketBase(NULL) +{ + //doing all this manually to ensure based memory allocation across the solution + ssize_t sizeInBytes = strnlen(socketbase, MAX_SIZE) + 1; + + //ensure a fairly decend size for socketbase is not overflowed + if (sizeInBytes > MAX_SIZE) + return; //a socketbase of more than 255 chars may break the system on connect + + mSocketBase = new char[sizeInBytes]; + strncpy(mSocketBase, socketbase, sizeInBytes); +} + +UnixSocketFactory::~UnixSocketFactory() +{ + if (mSocketBase != NULL) + delete [] mSocketBase; + mSocketBase = NULL; +} + +ICommunicationSocket* UnixSocketFactory::NewCommunicationSocket() +{ + UnixCommunicationSocket* sock = new UnixCommunicationSocket(mSocketBase); + bool initializationSuccessfull = false; + + if (sock != NULL) + initializationSuccessfull = sock->init(); + + if (initializationSuccessfull == false) + { + delete sock; + sock = NULL; + } + + return sock; +} diff --git a/psw/ae/data/constants/linux/ae_debug_flag.hh b/psw/ae/data/constants/linux/ae_debug_flag.hh new file mode 100644 index 0000000000..595f7e83af --- /dev/null +++ b/psw/ae/data/constants/linux/ae_debug_flag.hh @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AE_DEBUG_FLAG_HH_ +#define _AE_DEBUG_FLAG_HH_ + +#define LE_DEBUG_FLAG 0 +#define AE_DEBUG_FLAG 0 + +#endif + diff --git a/psw/ae/data/constants/linux/default_url_info.hh b/psw/ae/data/constants/linux/default_url_info.hh new file mode 100644 index 0000000000..08f6743370 --- /dev/null +++ b/psw/ae/data/constants/linux/default_url_info.hh @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _DEFAULT_URL_HH_ +#define _DEFAULT_URL_HH_ +#define DEFAULT_URL "http://ps.sgx.trustedservices.intel.com:8080/" /*production backend server*/ +#define DEFAULT_PSE_RL_URL "https://trustedservices.intel.com/content/CRL/" +#define DEFAULT_PSE_OCSP_URL "http://trustedservices.intel.com/ocsp" +#endif + diff --git a/psw/ae/data/constants/linux/isk_pub.hh b/psw/ae/data/constants/linux/isk_pub.hh new file mode 100644 index 0000000000..db45bcedea --- /dev/null +++ b/psw/ae/data/constants/linux/isk_pub.hh @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _ISK_PUB_HH_ +#define _ISK_PUB_HH_ +/* This is the x component of production public key used for EC-DSA verify for EPID Signing key. */ +const uint8_t g_sgx_isk_pubkey_x[] = { + 0x26, 0x9c, 0x10, 0x82, 0xe3, 0x5a, 0x78, 0x26, + 0xee, 0x2e, 0xcc, 0x0d, 0x29, 0x50, 0xc9, 0xa4, + 0x7a, 0x21, 0xdb, 0xcf, 0xa7, 0x6a, 0x95, 0x92, + 0xeb, 0x2f, 0xb9, 0x24, 0x89, 0x88, 0xbd, 0xce +}; + +/* This is the y component of production public key used for EC-DSA verify. Same as upper. */ +const uint8_t g_sgx_isk_pubkey_y[] = { + 0xb8, 0xe0, 0xf2, 0x41, 0xc3, 0xe5, 0x35, 0x52, + 0xbc, 0xef, 0x9c, 0x04, 0x02, 0x06, 0x48, 0xa5, + 0x76, 0x10, 0x1b, 0xa4, 0x28, 0xe4, 0x8e, 0xa9, + 0xcf, 0xba, 0x41, 0x75, 0xdf, 0x06, 0x50, 0x62 +}; +#endif + diff --git a/psw/ae/data/constants/linux/launch_enclave_mrsigner.hh b/psw/ae/data/constants/linux/launch_enclave_mrsigner.hh new file mode 100644 index 0000000000..a193713bd2 --- /dev/null +++ b/psw/ae/data/constants/linux/launch_enclave_mrsigner.hh @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _LANCH_ENCLAVE_MRSIGNER_HH_ +#define _LANCH_ENCLAVE_MRSIGNER_HH_ +const sgx_measurement_t g_le_mrsigner[] = +{ + { + { + /* SHA256 of SGXLaunchEnclave release signing key*/ + 0xac, 0xb7, 0x70, 0x12, 0x05, 0x3e, 0x05, 0xa6, + 0x3d, 0x41, 0x3b, 0x8b, 0xba, 0xe8, 0xfb, 0x6c, + 0x5d, 0x73, 0xb3, 0xf2, 0x99, 0x6d, 0x91, 0xc4, + 0x3b, 0xbb, 0xf9, 0x09, 0x59, 0xc0, 0xf8, 0xd4 + } + } +}; +#endif + diff --git a/psw/ae/data/constants/linux/peksk_pub.hh b/psw/ae/data/constants/linux/peksk_pub.hh new file mode 100644 index 0000000000..b7bde511e7 --- /dev/null +++ b/psw/ae/data/constants/linux/peksk_pub.hh @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _PEK_SK_PUB_HH_ +#define _PEK_SK_PUB_HH_ +const sgx_ec256_public_t g_pek_pub_key_little_endian = +{ + { + 0xd3, 0x43, 0x31, 0x3b, 0xf7, 0x3a, 0x1b, 0xa1, + 0xca, 0x47, 0xb2, 0xab, 0xb2, 0xa1, 0x43, 0x4d, + 0x1a, 0xcd, 0x4b, 0xf5, 0x94, 0x77, 0xeb, 0x44, + 0x5a, 0x06, 0x2d, 0x13, 0x4b, 0xe1, 0xc5, 0xa0 + }, + { + 0x33, 0xf8, 0x41, 0x6b, 0xb2, 0x39, 0x45, 0xcc, + 0x8d, 0xcd, 0x81, 0xb4, 0x80, 0xb4, 0xbd, 0x82, + 0x11, 0xf2, 0xdc, 0x9c, 0x0b, 0x4c, 0x8a, 0x28, + 0xb0, 0xaa, 0xca, 0x65, 0x14, 0xd2, 0xc8, 0x62 + } +}; +#endif + diff --git a/psw/ae/data/constants/linux/pibsk_pub.hh b/psw/ae/data/constants/linux/pibsk_pub.hh new file mode 100644 index 0000000000..b3efa94d2c --- /dev/null +++ b/psw/ae/data/constants/linux/pibsk_pub.hh @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PIBSK_PUB_HH_ +#define _PIBSK_PUB_HH_ +const uint8_t s_pib_pub_key_big_endian[] = +{ + 0xe0, 0x16, 0x28, 0x55, 0x98, 0x4e, 0xc7, 0xc5, + 0x01, 0xef, 0x1c, 0xa4, 0xd8, 0x1d, 0x7d, 0x5d, + 0xa6, 0x0f, 0x6e, 0x0e, 0x0d, 0xae, 0xf0, 0x8f, + 0xcd, 0x0c, 0xde, 0x50, 0x27, 0x4c, 0xe3, 0xb3, + 0x17, 0xda, 0x9a, 0x8a, 0x6d, 0x2c, 0x1d, 0xb5, + 0x3a, 0x01, 0x34, 0x99, 0xe4, 0xc8, 0x95, 0xb3, + 0x4d, 0xf3, 0xaf, 0x48, 0xf2, 0xfb, 0x3f, 0xbc, + 0x8b, 0x40, 0x46, 0xe4, 0x52, 0x2e, 0xab, 0xe6 +}; +#endif + diff --git a/psw/ae/data/constants/linux/pse_op_isv_svn_min.hh b/psw/ae/data/constants/linux/pse_op_isv_svn_min.hh new file mode 100644 index 0000000000..6abb70af73 --- /dev/null +++ b/psw/ae/data/constants/linux/pse_op_isv_svn_min.hh @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PSE_OP_ISV_SVN_MIN_HH_ +#define _PSE_OP_ISV_SVN_MIN_HH_ +/* hard-coded minimal isv svn of pse-op accepted. isv svn of production pse-op starts at 3*/ +const sgx_isv_svn_t PSE_ISV_SVN_MIN = 3; +#endif + diff --git a/psw/ae/data/constants/linux/pse_op_prod_id.hh b/psw/ae/data/constants/linux/pse_op_prod_id.hh new file mode 100644 index 0000000000..0110ea238b --- /dev/null +++ b/psw/ae/data/constants/linux/pse_op_prod_id.hh @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PSE_OP_PROD_ID_HH_ +#define _PSE_OP_PROD_ID_HH_ +/*this hard code depends on EncalveConfigure xml of PSE*/ +const sgx_prod_id_t PSE_PROD_ID = 0x2; +#endif + diff --git a/psw/ae/data/constants/linux/qsdk_pub.hh b/psw/ae/data/constants/linux/qsdk_pub.hh new file mode 100644 index 0000000000..35ad80e31b --- /dev/null +++ b/psw/ae/data/constants/linux/qsdk_pub.hh @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _QSDK_PUB_HH_ +#define _QSDK_PUB_HH_ +/* publicexponent = 010001*/ +unsigned int g_qsdk_pub_key_e[] = { + 0x00010001 +}; + +/* modulus = + c3195b35fe43f9e358b1f7ec6456bedc0db2af138f8b9c7d6ac711a5ee824fe8 + 7ac0bee3f829e489f9f79c83b947683805b64950d1eea5fb02ff89a67711e95e + 4f8058d9d24ae34db041c4245c9e3655c118c80ca69895b40ab6d5214bcfa63b + 742b4717c70f72d1415dea1a5844bb6d1635ea2043f4c1b26f6def568003bc37 + 7822bf095b3a7f7f24556dca8e3ed903fd22292ad56370d6f58354635764c298 + fac1c874eb8040c28e28ef14b52198090cedc16c6fe56b221023ee7dcfdd5c82 + 822d7fcdade9835c2fef3964bca24c9ee3672cec403189cadefc0e8f503fefef + 4c21e2c4d9809146f69d2d30219f7d17e93ce010202dacb9bd9505ced2a69adf +*/ +const uint32_t g_qsdk_pub_key_n[] = { + 0xd2a69adf, 0xbd9505ce, 0x202dacb9, 0xe93ce010, 0x219f7d17, + 0xf69d2d30, 0xd9809146, 0x4c21e2c4, 0x503fefef, 0xdefc0e8f, + 0x403189ca, 0xe3672cec, 0xbca24c9e, 0x2fef3964, 0xade9835c, + 0x822d7fcd, 0xcfdd5c82, 0x1023ee7d, 0x6fe56b22, 0x0cedc16c, + 0xb5219809, 0x8e28ef14, 0xeb8040c2, 0xfac1c874, 0x5764c298, + 0xf5835463, 0xd56370d6, 0xfd22292a, 0x8e3ed903, 0x24556dca, + 0x5b3a7f7f, 0x7822bf09, 0x8003bc37, 0x6f6def56, 0x43f4c1b2, + 0x1635ea20, 0x5844bb6d, 0x415dea1a, 0xc70f72d1, 0x742b4717, + 0x4bcfa63b, 0x0ab6d521, 0xa69895b4, 0xc118c80c, 0x5c9e3655, + 0xb041c424, 0xd24ae34d, 0x4f8058d9, 0x7711e95e, 0x02ff89a6, + 0xd1eea5fb, 0x05b64950, 0xb9476838, 0xf9f79c83, 0xf829e489, + 0x7ac0bee3, 0xee824fe8, 0x6ac711a5, 0x8f8b9c7d, 0x0db2af13, + 0x6456bedc, 0x58b1f7ec, 0xfe43f9e3, 0xc3195b35, +}; +#endif + diff --git a/psw/ae/data/constants/linux/service_enclave_mrsigner.hh b/psw/ae/data/constants/linux/service_enclave_mrsigner.hh new file mode 100644 index 0000000000..594b1ada25 --- /dev/null +++ b/psw/ae/data/constants/linux/service_enclave_mrsigner.hh @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SERVICE_ENCLAVE_MRSIGNER_HH_ +#define _SERVICE_ENCLAVE_MRSIGNER_HH_ +/* hard-coded mrsigner is SHA256 of CSS production signing key*/ +const sgx_measurement_t G_SERVICE_ENCLAVE_MRSIGNER[] = +{ + { + { + 0xec, 0x15, 0xb1, 0x07, 0x87, 0xd2, 0xf8, 0x46, + 0x67, 0xce, 0xb0, 0xb5, 0x98, 0xff, 0xc4, 0x4a, + 0x1f, 0x1c, 0xb8, 0x0f, 0x67, 0x0a, 0xae, 0x5d, + 0xf9, 0xe8, 0xfa, 0x9f, 0x63, 0x76, 0xe1, 0xf8 + } + } +}; +#endif + diff --git a/psw/ae/data/constants/linux/wl_pub.hh b/psw/ae/data/constants/linux/wl_pub.hh new file mode 100644 index 0000000000..6d7e662175 --- /dev/null +++ b/psw/ae/data/constants/linux/wl_pub.hh @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _WL_PUB_HH_ +#define _WL_PUB_HH_ +const sgx_ec256_public_t g_wl_root_pubkey = +{ + { + 0x29, 0x39, 0x1e, 0x9b, 0xcb, 0x86, 0xd6, 0xeb, + 0x3c, 0x17, 0x91, 0xc8, 0x8f, 0xc9, 0x5f, 0x8c, + 0xee, 0x0c, 0x1c, 0x75, 0x60, 0x9c, 0x16, 0xc2, + 0x18, 0x6d, 0x67, 0x31, 0x45, 0x5c, 0x36, 0xa9 + }, + { + 0x5f, 0x09, 0x83, 0x0d, 0xe1, 0x22, 0xda, 0xe4, + 0xed, 0x97, 0x54, 0xe6, 0xfe, 0xe2, 0xcc, 0x93, + 0x5e, 0x05, 0x99, 0x84, 0xc9, 0x4f, 0x44, 0x24, + 0x7a, 0x28, 0xcf, 0x81, 0xca, 0x11, 0x7e, 0xb6 + } +}; +#endif + diff --git a/psw/ae/data/prebuilt/le_prod_css.bin b/psw/ae/data/prebuilt/le_prod_css.bin new file mode 100644 index 0000000000..76e8543ec6 Binary files /dev/null and b/psw/ae/data/prebuilt/le_prod_css.bin differ diff --git a/psw/ae/data/prebuilt/white_list_cert_to_be_verify.bin b/psw/ae/data/prebuilt/white_list_cert_to_be_verify.bin new file mode 100644 index 0000000000..d573b1f47f Binary files /dev/null and b/psw/ae/data/prebuilt/white_list_cert_to_be_verify.bin differ diff --git a/psw/ae/inc/aeerror.h b/psw/ae/inc/aeerror.h new file mode 100644 index 0000000000..929dcfddd5 --- /dev/null +++ b/psw/ae/inc/aeerror.h @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _AE_ERROR_H_ +#define _AE_ERROR_H_ + +typedef enum _ae_error_t{ + AE_SUCCESS = 0, + AE_FAILURE = 1, + AE_ENCLAVE_LOST = 2, + + OAL_PARAMETER_ERROR = 3, + OAL_PATHNAME_BUFFER_OVERFLOW_ERROR = 4, + OAL_FILE_ACCESS_ERROR = 5, + OAL_CONFIG_FILE_ERROR = 6, + OAL_NETWORK_UNAVAILABLE_ERROR = 7, + OAL_NETWORK_BUSY = 8, + OAL_NETWORK_RESEND_REQUIRED = 9, + OAL_PROXY_SETTING_ASSIST = 10, + OAL_THREAD_ERROR = 11, + OAL_THREAD_TIMEOUT_ERROR = 12, + + AE_PSVN_UNMATCHED_ERROR = 13, + AE_SERVER_NOT_AVAILABLE = 14, + AE_INVALID_PARAMETER = 15, + AE_READ_RAND_ERROR = 16, + AE_OUT_OF_MEMORY_ERROR = 17, + AE_INSUFFICIENT_DATA_IN_BUFFER = 18, + + /* QUOTING ENCLAVE ERROR CASES*/ + QE_UNEXPECTED_ERROR = 19, + QE_PARAMETER_ERROR = 20, + QE_EPIDBLOB_ERROR = 21, + QE_REVOKED_ERROR = 22, + QE_SIGRL_ERROR = 23, + + /* PROVISIONING ENCLAVE ERROR CASES*/ + PVE_UNEXPECTED_ERROR = 24, + PVE_PARAMETER_ERROR = 25, + PVE_EPIDBLOB_ERROR = 26, + PVE_INSUFFICIENT_MEMORY_ERROR = 27, + PVE_INTEGRITY_CHECK_ERROR = 28, + PVE_SIGRL_INTEGRITY_CHECK_ERROR = 29, + PVE_SERVER_REPORTED_ERROR = 30, + PVE_PEK_SIGN_ERROR = 31, + PVE_MSG_ERROR = 32, + PVE_REVOKED_ERROR = 33, + PVE_SESSION_OUT_OF_ORDER_ERROR = 34, + PVE_SERVER_BUSY_ERROR = 35, + PVE_PERFORMANCE_REKEY_NOT_SUPPORTED = 36, + + /* LICENSING ENCLAVE ERROR CASES*/ + LE_UNEXPECTED_ERROR = 37, + LE_INVALID_PARAMETER = 38, + LE_GET_LICENSE_KEY_ERROR = 39, + LE_INVALID_ATTRIBUTE = 40, + LE_INVALID_PRIVILEGE_ERROR = 41, + LE_WHITELIST_UNINITIALIZED_ERROR = 42, + LE_CALC_LIC_TOKEN_ERROR = 43, + + AESM_NLTP_NO_LTP_BLOB =178, + AESM_NLTP_DONT_NEED_UPDATE_PAIR_LTP =179, + AESM_NLTP_MAY_NEED_UPDATE_LTP =180, + AESM_NLTP_OLD_EPID11_RLS =181, + AESM_PCP_NEED_PSE_UPDATE =182, + AESM_PCP_PSE_CERT_PROVISIONING_ATTESTATION_FAILURE_NEED_EPID_UPDATE =183, + AESM_PCP_PSE_CERT_PROVISIONING_ATTESTATION_FAILURE_MIGHT_NEED_EPID_UPDATE =184, + AESM_PCP_SIMPLE_PSE_CERT_PROVISIONING_ERROR =185, + AESM_PCP_SIMPLE_EPID_PROVISION_ERROR =186, + AESM_NPC_DONT_NEED_PSEP =187, + AESM_NPC_NO_PSE_CERT =188, + AESM_NPC_DONT_NEED_UPDATE_PSEP =189, + AESM_NPC_MAY_NEED_UPDATE_PSEP =190, + AESM_NEP_DONT_NEED_EPID_PROVISIONING =191, + AESM_NEP_DONT_NEED_UPDATE_PVEQE =192, + AESM_NEP_PERFORMANCE_REKEY =193, + AESM_NEP_MAY_NEED_UPDATE =194, + AESM_CP_ATTESTATION_FAILURE =195, + AESM_LTP_PSE_CERT_REVOKED =196, + AESM_LTP_SIMPLE_LTP_ERROR =197, + AESM_PSE_PR_GET_PRIVRL_ERROR =198, + AESM_NETWORK_TIMEOUT =199, + + AE_SERVICE_NOT_AVAILABLE =200, + + PSW_UPDATED_REQUIRED =201 +} ae_error_t; + +#define AE_FAILED(x) (AE_SUCCESS != (x)) +#define AE_SUCCEEDED(x) (AE_SUCCESS == (x)) + +/* These definitions are usable to exit a loop*/ +#define BREAK_IF_TRUE(x, Sts, ErrCode) if (x) { Sts = ErrCode; break; } +#define BREAK_IF_FALSE(x, Sts, ErrCode) if (!(x)) { Sts = ErrCode; break; } +#define BREAK_IF_FAILED(x) if (AE_SUCCESS != (x)) { break; } +#define BREAK_IF_FAILED_ERR(x, ErrCode) if (AE_SUCCESS != (x)) { x = ErrCode; break; } + + +#endif/*_AE_ERROR_H_*/ + diff --git a/psw/ae/inc/byte_order.h b/psw/ae/inc/byte_order.h new file mode 100644 index 0000000000..65c798df40 --- /dev/null +++ b/psw/ae/inc/byte_order.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: byte_order.h + * Description: Header file to convert between host byte order and network byte order + * The file assume the code is running in little endian machine + */ + +#ifndef _BYTE_ORDER_H +#define _BYTE_ORDER_H + +/*macro to get the kth byte of 32 bits integer x + *k should be 0, 1, 2 or 3 + *k equal to 0 means to get the least significant byte + */ +#define GET_BYTE(x, k) (((const unsigned char *)&(x))[k]) + +#define _htonl(x) ((uint32_t)( \ + (((uint32_t)(x) & (uint32_t)0x000000ff) << 24) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x00ff0000) >> 8) | \ + (((uint32_t)(x) & (uint32_t)0xff000000) >> 24))) +#define _htons(x) ((uint16_t)( \ + (((uint16_t)(x) & (uint16_t)0xff00) >> 8) | \ + (((uint16_t)(x) & (uint16_t)0x00ff) << 8))) + +#define lv_htonl(x) ( \ + (((uint32_t)GET_BYTE(x,0))<<24)| \ + (((uint32_t)GET_BYTE(x,1))<<16)| \ + (((uint32_t)GET_BYTE(x,2))<<8)| \ + (((uint32_t)GET_BYTE(x,3))) ) +#define lv_htons(x) (\ + (uint16_t)((((uint16_t)GET_BYTE(x,0))<<8) | \ + (((uint16_t)GET_BYTE(x,1))) )) + +#define _ntohl(u32) _htonl(u32) +#define _ntohs(u16) _htons(u16) +#define lv_ntohl(u32) lv_htonl(u32) +#define lv_ntohs(u16) lv_htons(u16) + +#endif /*_BYTE_ORDER_H*/ + diff --git a/psw/ae/inc/internal/aesm_error.h b/psw/ae/inc/internal/aesm_error.h new file mode 100644 index 0000000000..02b87fe485 --- /dev/null +++ b/psw/ae/inc/internal/aesm_error.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AESM_ERROR_H_ +#define _AESM_ERROR_H_ + +/*File to define aesm error code*/ + +typedef enum _aesm_error_t +{ + AESM_SUCCESS = 0, + AESM_UNEXPECTED_ERROR = 1, + AESM_NO_DEVICE_ERROR = 2, + AESM_PARAMETER_ERROR = 3, + AESM_EPIDBLOB_ERROR = 4, + AESM_EPID_REVOKED_ERROR = 5, + AESM_GET_LICENSETOKEN_ERROR = 6, + AESM_SESSION_INVALID = 7, + AESM_MAX_NUM_SESSION_REACHED = 8, + AESM_PSDA_UNAVAILABLE = 9, + AESM_EPH_SESSION_FAILED = 10, + AESM_LONG_TERM_PAIRING_FAILED = 11, + AESM_NETWORK_ERROR = 12, + AESM_NETWORK_BUSY_ERROR = 13, + AESM_PROXY_SETTING_ASSIST = 14, + AESM_FILE_ACCESS_ERROR = 15, + AESM_SGX_PROVISION_FAILED = 16, + AESM_SERVICE_STOPPED = 17, + AESM_BUSY = 18, + AESM_BACKEND_SERVER_BUSY = 19, + AESM_UPDATE_AVAILABLE = 20, + AESM_OUT_OF_MEMORY_ERROR = 21, + AESM_MSG_ERROR = 22, + AESM_THREAD_ERROR = 23, + AESM_SGX_DEVICE_NOT_AVAILABLE = 24, + AESM_ENABLE_SGX_DEVICE_FAILED = 25, + AESM_PLATFORM_INFO_BLOB_INVALID_SIG = 26, + AESM_SERVICE_NOT_AVAILABLE = 27, + AESM_KDF_MISMATCH = 28, + +} aesm_error_t; +#endif + diff --git a/psw/ae/inc/internal/cipher.h b/psw/ae/inc/internal/cipher.h new file mode 100644 index 0000000000..04efe63282 --- /dev/null +++ b/psw/ae/inc/internal/cipher.h @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: cipher.h + * Description: Header file to wrap cipher related function from IPP for Provision Enclave + * + * Wrap for ipp function like aes-cmac, aes-gcm, rsa-oaep, sha512. + */ + +#ifndef _CIPHER_H +#define _CIPHER_H + +#include "se_cdefs.h" +#include "ae_ipp.h" +#include "sgx_tseal.h" +#include "epid_types.h" +#include "se_types.h" +#include "sgx_key.h" +#include "provision_msg.h" +#include "se_sig_rl.h" + +/*Function to generate a random parameter f (0BE translation of DWORD +#define SwapEndian_DW(dw) ( (((dw) & 0x000000ff) << 24) | (((dw) & 0x0000ff00) << 8) | (((dw) & 0x00ff0000) >> 8) | (((dw) & 0xff000000) >> 24) ) +// LE<->BE translation of 8 byte big number +#define SwapEndian_8B(ptr) \ +{ \ + unsigned int Temp = 0; \ + unsigned int* p = reinterpret_cast(ptr); \ + Temp = SwapEndian_DW(p[0]); \ + p[0] = SwapEndian_DW(p[1]); \ + p[1] = Temp; \ +} \ +// LE<->BE translation of 10 byte (80 bit) big number +#define SwapEndian_10B(ptr) \ +{ \ + unsigned int Temp1 = 0; \ + unsigned int Temp2 = 0; \ + unsigned int* p = reinterpret_cast(ptr); \ + Temp1 = SwapEndian_DW( (unsigned int)( (((unsigned char*)(ptr))[8] << 16 ) | ( ((unsigned char*)(ptr))[9] << 24) ) ); \ + Temp2 = SwapEndian_DW(p[1]); \ + *(reinterpret_cast((unsigned char*)(ptr) + 6)) = SwapEndian_DW(p[0]); \ + *(reinterpret_cast((unsigned char*)(ptr) + 2)) = Temp2; \ + p[0] = (Temp1 & 0x0000ffff) | (p[0] & 0xffff0000); \ +} +// LE<->BE translation of 16 byte (128-bit) big number +#define SwapEndian_16B(ptr) \ +{ \ + unsigned int Temp = 0; \ + unsigned int* p = reinterpret_cast(ptr); \ + Temp = SwapEndian_DW(p[0]); \ + p[0] = SwapEndian_DW(p[3]); \ + p[3] = Temp; \ + Temp = SwapEndian_DW(p[1]); \ + p[1] = SwapEndian_DW(p[2]); \ + p[2] = Temp; \ +} +// LE<->BE translation of 32 byte big number +#define SwapEndian_32B(ptr) \ +{ \ + unsigned int Temp = 0; \ + unsigned int* p = reinterpret_cast(ptr); \ + Temp = SwapEndian_DW(p[0]); \ + p[0] = SwapEndian_DW(p[7]); \ + p[7] = Temp; \ + Temp = SwapEndian_DW(p[1]); \ + p[1] = SwapEndian_DW(p[6]); \ + p[6] = Temp; \ + Temp = SwapEndian_DW(p[2]); \ + p[2] = SwapEndian_DW(p[5]); \ + p[5] = Temp; \ + Temp = SwapEndian_DW(p[3]); \ + p[3] = SwapEndian_DW(p[4]); \ + p[4] = Temp; \ +} +// LE<->BE translation of 64 byte big number +#define SwapEndian_64B(ptr) \ +{ \ + unsigned int Temp = 0; \ + unsigned int* p = reinterpret_cast(ptr); \ + Temp = SwapEndian_DW(p[0]); \ + p[0] = SwapEndian_DW(p[15]); \ + p[15] = Temp; \ + Temp = SwapEndian_DW(p[1]); \ + p[1] = SwapEndian_DW(p[14]); \ + p[14] = Temp; \ + Temp = SwapEndian_DW(p[2]); \ + p[2] = SwapEndian_DW(p[13]); \ + p[13] = Temp; \ + Temp = SwapEndian_DW(p[3]); \ + p[3] = SwapEndian_DW(p[12]); \ + p[12] = Temp; \ + Temp = SwapEndian_DW(p[4]); \ + p[4] = SwapEndian_DW(p[11]); \ + p[11] = Temp; \ + Temp = SwapEndian_DW(p[5]); \ + p[5] = SwapEndian_DW(p[10]); \ + p[10] = Temp; \ + Temp = SwapEndian_DW(p[6]); \ + p[6] = SwapEndian_DW(p[9]); \ + p[9] = Temp; \ + Temp = SwapEndian_DW(p[7]); \ + p[7] = SwapEndian_DW(p[8]); \ + p[8] = Temp; \ +} +// LE<->BE translation of 75 byte (600 bit) big number +#define SwapEndian_75B(ptr) \ +{ \ + unsigned int Temp1 = 0; \ + unsigned int Temp2 = 0; \ + unsigned char i = 0; \ + unsigned int* p = reinterpret_cast(ptr); \ + Temp1 = SwapEndian_DW( (unsigned int)( ( ((unsigned char*)(ptr))[72] << 8 ) | ( ((unsigned char*)(ptr))[73] << 16 ) | ( ((unsigned char*)(ptr))[74] << 24 ) ) ); \ + Temp2 = (p[17] & 0xff000000); \ + *((unsigned int*)((unsigned char*)(ptr) + 71)) = SwapEndian_DW(p[0]); \ + p[0] = Temp1; \ + Temp1 = SwapEndian_DW(p[1]); \ + *((unsigned int*)((unsigned char*)(ptr) + 3 )) = SwapEndian_DW( ( (p[17] & 0x00ffffff) | Temp2 ) ); \ + for(i = 0; i < 8; i++) { \ + Temp2 = (p[16 - i] & 0xff000000); \ + *((unsigned int*)((unsigned char*)(ptr) + 67 - 4*i)) = Temp1; \ + Temp1 = SwapEndian_DW(p[2 + i]); \ + *((unsigned int*)((unsigned char*)(ptr) + 7 + 4*i)) = SwapEndian_DW( ( (p[16 - i] & 0x00ffffff) | Temp2 ) ); \ + } \ +} + +#if defined(DEFINE_GPOINTS_IN_LE2BE_MACROS) + +/* + * Some structures useful during the conversion of SafeId data + */ + +typedef struct _G1Point { + unsigned char x[32]; + unsigned char y[32]; +} G1Point; + +typedef struct _G2Point { + unsigned char x0[32]; + unsigned char x1[32]; + unsigned char x2[32]; + unsigned char y0[32]; + unsigned char y1[32]; + unsigned char y2[32]; +} G2Point; + +typedef G1Point G3Point; + +typedef struct _GTPoint { + unsigned char x0[32]; + unsigned char x1[32]; + unsigned char x2[32]; + unsigned char x3[32]; + unsigned char x4[32]; + unsigned char x5[32]; +} GTPoint; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/psw/ae/inc/internal/pek_pub_key.h b/psw/ae/inc/internal/pek_pub_key.h new file mode 100644 index 0000000000..624fd5e869 --- /dev/null +++ b/psw/ae/inc/internal/pek_pub_key.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _PEK_SIGN_KEY_H_ +#define _PEK_SIGN_KEY_H_ +#include "se_types.h" +#include "sgx_error.h" +#include "epid_pve_type.h" + + +sgx_status_t check_pek_signature(const signed_pek_t& signed_pek, uint8_t *result); +#endif + diff --git a/psw/ae/inc/internal/provision_msg.h b/psw/ae/inc/internal/provision_msg.h new file mode 100644 index 0000000000..33f466d3e8 --- /dev/null +++ b/psw/ae/inc/internal/provision_msg.h @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + /** + * File: provision_msg.h + * Description: Definition for data structure and provision protocol + * + * Definition for data structure and provision protocol + */ + +#ifndef _PVE_MSG_H_ +#define _PVE_MSG_H_ + +#include "epid_pve_type.h" +#include "sgx_tseal.h" + +//error code definition +typedef enum _pve_status_t +{ + PVEC_SUCCESS = 0, + PVEC_PARAMETER_ERROR, + PVEC_INSUFFICIENT_MEMORY_ERROR, + PVEC_READ_RAND_ERROR, + PVEC_SIGRL_INTEGRITY_CHECK_ERROR, + PVEC_MALLOC_ERROR, + PVEC_EPID_BLOB_ERROR, + PVEC_SE_ERROR, + PVEC_IPP_ERROR, + PVEC_MSG_ERROR, + PVEC_PEK_SIGN_ERROR, + PVEC_INTEGER_OVERFLOW_ERROR, + PVEC_SEAL_ERROR, + PVEC_EPID_ERROR, + PVEC_SESSION_OUT_OF_ORDER_ERROR, + PVEC_REVOKED_ERROR, + PVEC_UNSUPPORTED_VERSION_ERROR, + PVEC_INVALID_CPU_ISV_SVN, + PVEC_INVALID_EPID_KEY, + PVEC_UNEXPECTED_ERROR //unknown error which should never happen, it indicates there're internal logical error in PvE's code +}pve_status_t; + +//State inside PvE +typedef enum _prov_stage_t +{ + PVE_STAGE_IDLE, //waiting for ProvMsg1 + PVE_STAGE_WAIT_FOR_GET_EK2, //waiting for get ek2 after processing msg1 + PVE_STAGE_WAIT_FOR_MSG2_OR_MSG4, //waiting for ProvMsg2 or ProvMsg4 after getting ek2 + PVE_STAGE_WAIT_FOR_MSG4, //waiting for ProvMsg4 only +}prov_stage_t; + +#define PVE_RSAOAEP_ENCRYPT_MAXLEN (PVE_RSA_KEY_BYTES - 2*SHA_SIZE_BIT/8 - 2) //190 bytes at most + +//macro definition for RSA-OAE algorithm +//SHA-256 will be used for the hash generation + +#define SHA_SIZE_BIT 256 + +#define MSG1_FIELD1_MAX_PAYLOAD_SIZE (4+PPID_SIZE+FMSP_SIZE+PSVN_SIZE+4+FLAGS_SIZE) +#define HARD_CODED_EPID_BLOB_SIZE (sizeof(sgx_sealed_data_t)+sizeof(se_secret_epid_data_t)+sizeof(se_plaintext_epid_data_t)) +#define pointer_diff_u32(p1, p2) static_cast(p1-p2) +#pragma pack(1) +//output information from PvE for AESM to generated ProvMsg1 +typedef struct _prov_msg1_output_t{ + uint32_t field1_data_size; //size of field1_data, it will be no more than MSG1_FIELD1_MAX_PAYLOAD_SIZE + uint8_t xid[XID_SIZE]; //The random transaction id which will be generated inside Enclave + uint8_t field0[PVE_RSA_KEY_BYTES]; //field0 of Msg1 generated inside PvE encrypted by RSA-OAEP, that's SK TLV:PSID TLV + uint8_t field1_iv[IV_SIZE]; //The random IV used to encrypt field1 of Msg1 by aes-gcm + //field1 before encryption is DeviceIDTlV[:FlagTLV] + uint8_t field1_data[MSG1_FIELD1_MAX_PAYLOAD_SIZE];//The encrypted field1 of Msg1 by aes-gcm, the size in byte is indicated by field1_data + uint8_t field1_mac[MAC_SIZE]; //The generated mac value of field1 of Msg1 by aes-gcm +}prov_msg1_output_t; + +//input information to generate EK2 by PvE +typedef struct _prov_get_ek2_input_t{ + uint8_t xid[XID_SIZE]; //The transaction Id + uint8_t nonce[NONCE_SIZE]; //The nonce_r from ProvMsg2 or ProvMsg4 +}prov_get_ek2_input_t; + +//Ek2 generated by PvE +typedef struct _prov_get_ek2_output_t{ + uint8_t ek2[SK_SIZE]; +}prov_get_ek2_output_t; + +//input information for PvE to decode data from ProvMsg2 +typedef struct _proc_prov_msg2_blob_input_t{ + signed_epid_group_cert_t group_cert; //ECDSA signed EPID Group Public Certificate from Intel decoded from ProvMsg2 + uint8_t challenge_nonce[CHALLENGE_NONCE_SIZE]; //The challenge nonce from ProvMsg2 + psvn_t equivalent_psvn; //The Equivalent PSVN which contains ISVN and Equivalent CPUSVN + psvn_t previous_psvn; //an optional PSVN for Sigrl corresponding to previous EPID (if we upgrade TCB or performance rekey) + fmsp_t fmsp; //fmsp passing in ProvMsg2 from Provisioning Backend server + GroupID previous_gid; //optional previous_gid if previous_psvn is provided + uint8_t old_epid_data_blob[HARD_CODED_EPID_BLOB_SIZE]; //optional old epid data blob corresponding to previous EPID + uint8_t tcb_iv[IV_SIZE]; //The random IV to decode TIK + uint8_t encrypted_tcb[SK_SIZE]; //It's TIK1, the aesm-gcm encrypted TIK by aes-gcm + uint8_t tcb_mac[MAC_SIZE]; //The mac value to check the integrity of TIK1 + uint8_t is_previous_psvn_provided;//both previous_psvn and old_epid_data_blob should be provided if it is true and prev gid must be provided too +}proc_prov_msg2_blob_input_t; + +#define HARD_CODED_JOIN_PROOF_WITH_ESCROW_TLV_SIZE (4+sizeof(join_proof_with_escrow_t)) +#define HARD_CODED_EPID_MEMBER_WITH_ESCROW_TLV_SIZE (4+sizeof(membertship_credential_with_escrow_t)) + +//output information from PvE for AESM to generate ProvMsg3 +typedef struct _gen_prov_msg3_output_t{ + uint8_t field1_iv[IV_SIZE]; //The random generated IV for aes-gcm encryption of join proof and escrow data + uint8_t field1_data[HARD_CODED_JOIN_PROOF_WITH_ESCROW_TLV_SIZE]; //The encrypted join proof and escrow data TLV by aes-gcm + uint8_t field1_mac[MAC_SIZE]; //The corresponding mac value of previous encrypted data + uint8_t epid_sig_iv[IV_SIZE]; //The random generated IV for aes-gcm encryption of EPIDSignature if available + uint8_t epid_sig_mac[MAC_SIZE];//The corresponding mac value for encrypted EPIDSignature if available + uint32_t epid_sig_output_size; //The size of EPIDSignature if available + uint8_t is_join_proof_generated; //boolean value to tell whether join proof and escrow data is generated. The first three fields in this structure will be invalid if this field is false + uint8_t is_epid_sig_generated; //boolean value to tell whether EpidSignature is generated + //If it is false, the epid_sig_iv/mac/output_size are all invalid +}gen_prov_msg3_output_t; + +//input information for PvE to decode data from ProvMsg4 and generate EPID Data Blob +typedef struct _proc_prov_msg4_input_t{ + uint8_t tcb_iv[IV_SIZE]; //The random IV to decode TIK + uint8_t encrypted_tcb[SK_SIZE]; //It's TIK1, the aes-gcm encrypted TIK by aes-gcm + uint8_t tcb_mac[MAC_SIZE]; //The mac value to check the integrity of TIK1 + uint8_t member_credential_iv[IV_SIZE]; //The random IV to decode member credential and escrow data TLV + uint8_t encrypted_member_credential[HARD_CODED_EPID_MEMBER_WITH_ESCROW_TLV_SIZE]; //The encrypted member credential and escrow data TLV by aes-gcm + uint8_t member_credential_mac[MAC_SIZE]; //The mac value of previous field + psvn_t equivalent_psvn; //An equivalent PSVN including ISVN and equivalent CPUSVN + fmsp_t fmsp; //The fmsp from provisioning backend server + signed_epid_group_cert_t group_cert;//ECDSA signed EPID Group Public Certificate from Intel decoded from ProvMsg4 +}proc_prov_msg4_input_t; + +//The EPID Data Blob generated by PvE in processing ProvMsg4 data +typedef struct _proc_prov_msg4_output_t{ + uint8_t truested_epid_blob[HARD_CODED_EPID_BLOB_SIZE]; +}proc_prov_msg4_output_t; + +//output data of PvE to generate End Point Selection TLV +typedef struct _gen_endpoint_selection_output_t{ + uint8_t xid[XID_SIZE]; + uint8_t selector_id; +}gen_endpoint_selection_output_t; +#pragma pack() + +#define PSVN_START_IN_DEVICE_ID sizeof(ppid_t) +#define PPID_START_IN_DEVICE_ID 0 +#define FMSP_START_IN_DEVICE_ID (sizeof(ppid_t)+sizeof(psvn_t)) +#endif diff --git a/psw/ae/inc/internal/pse_inc.h b/psw/ae/inc/internal/pse_inc.h new file mode 100644 index 0000000000..26a4e8775a --- /dev/null +++ b/psw/ae/inc/internal/pse_inc.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef PSE_INC_H_ +#define PSE_INC_H_ + +#include "se_cdefs.h" +#include "ae_ipp.h" +#include "sgx_utils.h" +#include "sgx_trts.h" +#include "string.h" +#include "aeerror.h" + +#endif diff --git a/psw/ae/inc/internal/pse_types.h b/psw/ae/inc/internal/pse_types.h new file mode 100644 index 0000000000..4869da6adf --- /dev/null +++ b/psw/ae/inc/internal/pse_types.h @@ -0,0 +1,464 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _PSE_TYPES_H_ +#define _PSE_TYPES_H_ + +#include "sgx_ecp_types.h" +#include "sgx_report.h" + +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} + +#define EPH_SESSION_NONCE_SIZE 16 +#define EPH_MESSAGE_MAC_SIZE 16 +#define CSE_ID_SIZE 32 +#define EPH_SESSION_TSK_SIZE 16 +#define EPH_SESSION_TMK_SIZE 16 +#define SW_INSTANCE_ID_SIZE 16 + +#define DERIVE_MAC_KEY 0x0 +#define DERIVE_SEAL_KEY 0x1 + +#pragma pack(push, 1) + +typedef struct _pse_dh_msg1_t +{ + sgx_ec256_public_t dh_ga; /* the Endian-ness of Ga is Little-Endian*/ + sgx_target_info_t pse_info; +}pse_dh_msg1_t; + +typedef struct _cse_sec_prop_t +{ + uint32_t sec_info_type; /* MBZ */ + uint32_t gid_cse; /* from PSE-CSE pairing blob */ + uint32_t prvrl_version; /* from PSE-CSE pairing blob */ + uint32_t sigrl_version; /* from PSE-CSE pairing blob */ + uint8_t ca_id_cse[20]; /* from PSE-CSE pairing blob */ + uint8_t sec_info[92]; /* from PSE-CSE pairing blob */ +}cse_sec_prop_t; + +typedef struct _secu_info{ + uint32_t jom_task_id; /* must be the hardcoded value - 8 */ + uint32_t reserved; /* MBZ */ + uint32_t psda_id; /* must be hardcoded value - 1 */ + uint32_t psda_svn; /* from PSE-CSE pairing blob */ + uint8_t reserved2[76]; /* MBZ */ +}secu_info_t; + +typedef struct _pse_dh_msg3_t +{ + uint8_t cmac[EPH_MESSAGE_MAC_SIZE]; + sgx_report_t report; + uint32_t additional_prop_length; + cse_sec_prop_t cse_sec_prop; +}pse_dh_msg3_t; + +/***********************\ +**message handling data** +\***********************/ +#define PSE_TRUSTED_TIME_SERVICE 0 +#define PSE_MC_SERVICE 1 +/*monotonic counter*/ +#define PSE_MC_CREATE 0 +#define PSE_MC_READ 1 +#define PSE_MC_INC 2 +#define PSE_MC_DEL 3 +/*trusted time*/ +#define PSE_TIMER_READ 0 + + +/*VMC creation policy*/ +#define MC_POLICY_SIGNER 0x1 +#define MC_POLICY_ENCLAVE 0x2 + +#define PAYLOAD_IV_SIZE 12 +typedef struct _pse_msssage_t +{ + uint32_t session_id; + uint32_t exp_resp_size; /* 0: response message*/ + uint8_t payload_iv[PAYLOAD_IV_SIZE]; + uint32_t payload_size; + uint8_t payload_tag[SGX_AESGCM_MAC_SIZE]; /* 16: AES-GMAC of the Plain Text, Payload, and the sizes*/ + uint8_t payload[0]; /* encrypted payload*/ +}pse_message_t; + +typedef enum _pse_op_error_t +{ + OP_SUCCESS = 0, + OP_ERROR_INTERNAL, /* Internal errors */ + OP_ERROR_INVALID_PARAMETER, /* Invalid input parameter */ + OP_ERROR_MALLOC, /* malloc() fails */ + OP_ERROR_UNKNOWN_REQUEST, /* Unknown request sent to CSE */ + OP_ERROR_CAP_NOT_AVAILABLE, /* The required service is not available */ + OP_ERROR_MAX_NUM_SESSION_REACHED, /* All session slots are in use and + the least active session does not exceed predefined time */ + OP_ERROR_INVALID_SESSION, /* Create APP Enclave - PSE session failed + or the session indicated by SID is invalid */ + OP_ERROR_DATABASE_FULL, /* No empty vmc nodes left in VMC DB */ + OP_ERROR_DATABASE_OVER_QUOTA, /* The quota for the MRSIGNER is exceeded */ + OP_ERROR_INVALID_EPH_SESSION, /* Ephemeral session is not valid or sequence no overflows. + Need do repairing. */ + OP_ERROR_PSDA_SESSION_LOST, /* CSME session is lost during OCALL */ + OP_ERROR_PSDA_BUSY, /* CSME is busy */ + OP_ERROR_EPH_SESSION_ESTABLISHMENT_INTEGRITY_ERROR, /* Integrity error of ephemeral session message */ + OP_ERROR_SQLITE_INTERNAL, /* SQLite internal errors */ + OP_ERROR_COPY_PREBUILD_DB, /* Copy of prebuilt DB failed */ + OP_ERROR_BACKUP_CURRENT_DB, /* Copy of current DB failed */ + OP_ERROR_INVALID_HW_MC, /* CC_MC > WR_MC or WR_MC > CC_MC + 2 */ + OP_ERROR_INVALID_COUNTER, /* The VMC counter ID passed in is not valid */ + OP_ERROR_INVALID_OWNER, /* owner ID or isv_svn doesn't match */ + OP_ERROR_UNSEAL_PAIRING_BLOB, /* Unsealing LT pairing blob failed */ + OP_ERROR_INVALID_POLICY, /* Invalid owner policy */ + OP_ERROR_INVALID_PAIRING_BLOB, /* LT pairing blob is invalid */ + + /* Errors for internal use. Won't be returned to AESM*/ + OP_ERROR_INVALID_VMC_DB, /* Verification of VMC DB failed. Should re-initialize DB */ + OP_ERROR_DATABASE_FATAL, /* Fatal error returned when opening VMC DB, Should re-initialize DB */ + OP_ERROR_SQLITE_NOT_FOUND, /* Record not found. */ + OP_ERROR_CACHE_MISS, /* The related nodes of a leaf node are not cached */ +}pse_op_error_t; + +typedef enum _pse_service_resp_status_t +{ + PSE_SUCCESS = 0, + PSE_ERROR_UNKNOWN_REQ, + PSE_ERROR_CAP_NOT_AVAILABLE, + PSE_ERROR_INVALID_PARAM, + PSE_ERROR_BUSY, + PSE_ERROR_INTERNAL, + PSE_ERROR_INVALID_POLICY, + PSE_ERROR_QUOTA_EXCEEDED, + PSE_ERROR_MC_NOT_FOUND, + PSE_ERROR_MC_NO_ACCESS_RIGHT, + PSE_ERROR_MC_USED_UP, + PSE_ERROR_MC_OVER_QUOTA +} pse_service_resp_status_t; + +typedef struct _pse_req_hdr_t +{ + uint32_t seq_num; + uint16_t service_id; + uint16_t service_cmd; +}pse_req_hdr_t; + +typedef struct _pse_resp_hdr_t +{ + uint32_t seq_num; + uint16_t service_id; + uint16_t service_cmd; + pse_service_resp_status_t status; +}pse_resp_hdr_t; + +typedef struct _pse_mc_create_req_t +{ + pse_req_hdr_t req_hdr; + uint16_t policy; + uint8_t attr_mask[16]; +}pse_mc_create_req_t; + +typedef struct _pse_mc_create_resp_t +{ + pse_resp_hdr_t resp_hdr; + uint8_t counter_id[3]; + uint8_t nonce[13]; +}pse_mc_create_resp_t; + +typedef struct _pse_mc_read_req_t +{ + pse_req_hdr_t req_hdr; + uint8_t counter_id[3]; + uint8_t nonce[13]; +}pse_mc_read_req_t; + +typedef struct _pse_mc_inc_req_t +{ + pse_req_hdr_t req_hdr; + uint8_t counter_id[3]; + uint8_t nonce[13]; +}pse_mc_inc_req_t; + +typedef struct _pse_mc_del_req_t +{ + pse_req_hdr_t req_hdr; + uint8_t counter_id[3]; + uint8_t nonce[13]; +}pse_mc_del_req_t; + +typedef struct _pse_mc_read_resp_t +{ + pse_resp_hdr_t resp_hdr; + uint32_t counter_value; + uint16_t pse_svn; +}pse_mc_read_resp_t; + +typedef struct _pse_mc_inc_resp_t +{ + pse_resp_hdr_t resp_hdr; + uint32_t counter_value; + uint16_t pse_svn; +}pse_mc_inc_resp_t; + +typedef struct _pse_mc_del_resp_t +{ + pse_resp_hdr_t resp_hdr; +}pse_mc_del_resp_t; + +typedef struct _pse_timer_read_req_t +{ + pse_req_hdr_t req_hdr; +}pse_timer_read_req_t; + +typedef struct _pse_timer_read_resp_t +{ + pse_resp_hdr_t resp_hdr; + uint64_t timestamp; + uint8_t time_source_nonce[32]; +}pse_timer_read_resp_t; + +/*message length*/ +#define PSE_CREATE_MC_REQ_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_create_req_t)) +#define PSE_CREATE_MC_RESP_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_create_resp_t)) +#define PSE_READ_MC_REQ_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_read_req_t)) +#define PSE_READ_MC_RESP_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_read_resp_t)) +#define PSE_INC_MC_REQ_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_inc_req_t)) +#define PSE_INC_MC_RESP_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_inc_resp_t)) +#define PSE_DEL_MC_REQ_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_del_req_t)) +#define PSE_DEL_MC_RESP_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_mc_del_resp_t)) +#define PSE_TIMER_READ_REQ_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_timer_read_req_t)) +#define PSE_TIMER_READ_RESP_SIZE static_cast(sizeof(pse_message_t) + sizeof(pse_timer_read_resp_t)) + +/*********************************************\ +** Define macros for CSE session and messages** +\*********************************************/ +#define PSDA_API_VERSION 1 +#define BE_PSDA_API_VERSION 0x01000000 + +#define PSDA_COMMAND_INFO 0 +#define PSDA_COMMAND_EP 2 +#define PSDA_COMMAND_SERVICE 3 + +#define PSDA_MSG_TYPE_CAP_QUERY 0 +#define PSDA_MSG_TYPE_CAP_RESULT 1 +#define PSDA_MSG_TYPE_CERT_INFO_QUERY 2 +#define PSDA_MSG_TYPE_CERT_INFO_RESULT 3 +#define PSDA_MSG_TYPE_LT_M1 0 +#define PSDA_MSG_TYPE_LT_M2 1 +#define PSDA_MSG_TYPE_LT_M7 2 +#define PSDA_MSG_TYPE_LT_M8 3 +#define PSDA_MSG_TYPE_EP_M1 0 +#define PSDA_MSG_TYPE_EP_M2 1 +#define PSDA_MSG_TYPE_EP_M3 2 +#define PSDA_MSG_TYPE_EP_M4 3 +#define PSDA_MSG_TYPE_SERV_REQ 0 +#define PSDA_MSG_TYPE_SERV_RESP 1 +#define BE_PSDA_MSG_TYPE_SERV_REQ 0x00000000 +#define BE_PSDA_MSG_TYPE_SERV_RESP 0x01000000 + +typedef struct _psda_msg_hdr_t +{ + uint8_t pse_instance_id[SW_INSTANCE_ID_SIZE]; + uint32_t msg_type; + uint32_t msg_len; +}psda_msg_hdr_t; + +typedef struct _psda_info_query_msg_t +{ + psda_msg_hdr_t msg_hdr; +}psda_info_query_msg_t; + +typedef struct _psda_cap_result_msg_t +{ + psda_msg_hdr_t msg_hdr; + uint32_t cap_descriptor_version; + uint32_t cap_descriptor0; + uint32_t cap_descriptor1; +}psda_cap_result_msg_t; + +typedef struct _psda_cert_result_msg_t +{ + psda_msg_hdr_t msg_hdr; + uint8_t cert_info[24]; +}psda_cert_result_msg_t; + +/* messages used for pse-cse ephemeral session establishment */ +typedef struct _pse_cse_msg2_t +{ + uint8_t id_cse[CSE_ID_SIZE]; + uint8_t nonce_r_cse[EPH_SESSION_NONCE_SIZE]; +}pse_cse_msg2_t; + +typedef struct _pse_cse_msg3_t +{ + uint8_t id_pse[CSE_ID_SIZE]; + uint8_t id_cse[CSE_ID_SIZE]; + uint8_t nonce_r_cse[EPH_SESSION_NONCE_SIZE]; + uint8_t nonce_r_pse[EPH_SESSION_NONCE_SIZE]; + uint8_t mac[SGX_SHA256_HASH_SIZE]; +}pse_cse_msg3_t; + +typedef struct _pse_cse_msg4_t +{ + uint8_t id_cse[CSE_ID_SIZE]; + uint8_t nonce_r_pse[EPH_SESSION_NONCE_SIZE]; + uint8_t mac[SGX_SHA256_HASH_SIZE]; +}pse_cse_msg4_t; + +typedef struct _eph_session_m1_t +{ + psda_msg_hdr_t msg_hdr; +}eph_session_m1_t; + +typedef struct _eph_session_m2_t +{ + psda_msg_hdr_t msg_hdr; + pse_cse_msg2_t msg2; +}eph_session_m2_t; + +typedef struct _eph_session_m3_t +{ + psda_msg_hdr_t msg_hdr; + pse_cse_msg3_t msg3; +}eph_session_m3_t; + +typedef struct _eph_session_m4_t +{ + psda_msg_hdr_t msg_hdr; + pse_cse_msg4_t msg4; +}eph_session_m4_t; + +/*********************************\ +**PSDA service message definition** +\*********************************/ +#define PSDA_MC_READ 1 /* Read MC command*/ +#define PSDA_MC_INC 2 /* Incroment MC command*/ +#define PSDA_MESSAGE_IV_SIZE 16 /* IV size*/ +#define PSDA_MESSAGE_MAC_SIZE 32 /* MAC size*/ + + +#define SGX_RPDATA_SIZE 16 /* RPDATA size*/ + +typedef struct _service_message_t +{ + uint32_t version; + uint32_t session_id; + uint32_t msg_type_exp_resp_size; + uint32_t payload_size; + uint8_t payload_iv[PSDA_MESSAGE_IV_SIZE]; + uint8_t payload_mac[PSDA_MESSAGE_MAC_SIZE]; + uint8_t payload[0]; /*encrypted payload*/ +}service_message_t; + +typedef struct _psda_service_message_t +{ + psda_msg_hdr_t msg_hdr; + service_message_t service_message; +}psda_service_message_t; + +typedef struct _psda_req_hdr_t +{ + uint32_t seqnum; + uint16_t service_id; + uint16_t service_cmd; +}psda_req_hdr_t; + +typedef struct _psda_resp_hdr_t +{ + uint32_t seqnum; + uint16_t service_id; + uint16_t service_cmd; + uint32_t status; +}psda_resp_hdr_t; + +typedef struct _cse_mc_read_req_t +{ + psda_req_hdr_t req_hdr; + uint8_t counter_id; +}cse_mc_read_req_t; + +typedef struct _cse_mc_inc_req_t +{ + psda_req_hdr_t req_hdr; + uint8_t counter_id; + uint8_t increase_amount; +}cse_mc_inc_req_t; + +typedef struct _cse_mc_resp_t +{ + psda_resp_hdr_t resp_hdr; + uint32_t counter_value; + uint32_t mc_epoch; +}cse_mc_resp_t; + +typedef struct _cse_rpdata_read_req_t +{ + psda_req_hdr_t req_hdr; +}cse_rpdata_read_req_t; + +typedef struct _cse_rpdata_update_req_t +{ + psda_req_hdr_t req_hdr; + uint8_t rpdata_cur[SGX_RPDATA_SIZE]; + uint8_t rpdata_new[SGX_RPDATA_SIZE]; +}cse_rpdata_update_req_t; + +typedef struct _cse_rpdata_reset_req_t +{ + psda_req_hdr_t req_hdr; + uint8_t rpdata_cur[SGX_RPDATA_SIZE]; +}cse_rpdata_reset_req_t; + +typedef struct _cse_rpdata_resp_t +{ + psda_resp_hdr_t resp_hdr; + uint8_t rpdata[SGX_RPDATA_SIZE]; + uint32_t rp_epoch; +}cse_rpdata_resp_t; + +typedef struct _cse_timer_read_req_t +{ + psda_req_hdr_t req_hdr; +}cse_timer_read_req_t; + +typedef struct _cse_timer_read_resp_t +{ + psda_resp_hdr_t resp_hdr; + uint64_t timestamp; + uint32_t epoch; +}cse_timer_read_resp_t; + +/* Because PSDA requires buffer size to be a multiple of AES_BLOCK_SIZE, add an extra AES_BLOCK_SIZE here + * to make sure response message can be stored in the buffer*/ +#define AES_BLOCK_SIZE 16 + +#pragma pack(pop) +#endif + diff --git a/psw/ae/inc/internal/pve_qe_common.h b/psw/ae/inc/internal/pve_qe_common.h new file mode 100644 index 0000000000..96d5cb9084 --- /dev/null +++ b/psw/ae/inc/internal/pve_qe_common.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _PVE_QE_COMMON_H_ +#define _PVE_QE_COMMON_H_ + +#include "se_types.h" +#include "ae_ipp.h" +#include "sgx_tcrypto.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern const uint8_t g_sgx_isk_pubkey_x[SGX_ECP256_KEY_SIZE]; + +extern const uint8_t g_sgx_isk_pubkey_y[SGX_ECP256_KEY_SIZE]; + +IppStatus new_std_256_ecp(IppsECCPState **pp_new_ecp); + +void secure_free_std_256_ecp(IppsECCPState *p_ecp); + + +int __STDCALL epid_random_func( + unsigned int *p_random_data, + int bits, + void* p_user_data); + + +#ifdef __cplusplus + } +#endif + +#if !defined(SWAP_ENDIAN_DW) +#define SWAP_ENDIAN_DW(dw) ((((dw) & 0x000000ff) << 24) \ + | (((dw) & 0x0000ff00) << 8) \ + | (((dw) & 0x00ff0000) >> 8) \ + | (((dw) & 0xff000000) >> 24)) +#endif + +#if !defined(SWAP_ENDIAN_32B) +#define SWAP_ENDIAN_32B(ptr) \ +{ \ + unsigned int temp = 0; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[0]); \ + ((unsigned int*)(ptr))[0] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[7]); \ + ((unsigned int*)(ptr))[7] = temp; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[1]); \ + ((unsigned int*)(ptr))[1] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[6]); \ + ((unsigned int*)(ptr))[6] = temp; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[2]); \ + ((unsigned int*)(ptr))[2] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[5]); \ + ((unsigned int*)(ptr))[5] = temp; \ + temp = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[3]); \ + ((unsigned int*)(ptr))[3] = SWAP_ENDIAN_DW(((unsigned int*)(ptr))[4]); \ + ((unsigned int*)(ptr))[4] = temp; \ +} +#endif + + +#endif + diff --git a/psw/ae/inc/internal/tlv_common.h b/psw/ae/inc/internal/tlv_common.h new file mode 100644 index 0000000000..ccf193de83 --- /dev/null +++ b/psw/ae/inc/internal/tlv_common.h @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: tlv_common.h + * Description: Header file to define TLV (the Type Length Value) related data or structure which may be commonly used by multiple components + */ + +#ifndef _PVE_TLV_COMMON_H +#define _PVE_TLV_COMMON_H +#include "se_cdefs.h" +#include "se_types.h" +#include "sgx_key.h" +#include "byte_order.h" + +/*enumerate all tlv types, the value of it is not defined in spec yet*/ +typedef enum _tlv_enum_type_t{ + TLV_CIPHER_TEXT=0, + TLV_BLOCK_CIPHER_TEXT, + TLV_BLOCK_CIPHER_INFO, + TLV_MESSAGE_AUTHENTICATION_CODE, + TLV_NONCE, + TLV_EPID_GID, + TLV_EPID_SIG_RL, + TLV_EPID_GROUP_CERT, + /*SE Provisioning Protocol TLVs*/ + TLV_DEVICE_ID, + TLV_PS_ID, + TLV_EPID_JOIN_PROOF, + TLV_EPID_SIG, + TLV_EPID_MEMBERSHIP_CREDENTIAL, + TLV_EPID_PSVN, + /*PSE Provisioning Protocol TLVs*/ + TLV_QUOTE, + TLV_X509_CERT_TLV, + TLV_X509_CSR_TLV, + /*End-point Selection Protocol TLVs*/ + TLV_ES_SELECTOR, + TLV_ES_INFORMATION, + /* EPID Provisioning Protocol TLVs Part 2*/ + TLV_FLAGS, + /* PSE Quote Signature*/ + TLV_QUOTE_SIG, + TLV_PLATFORM_INFO_BLOB, + /* Generic TLVs*/ + TLV_SIGNATURE, + /* End-point Selection Protocol TLVs*/ + TLV_PEK, +}tlv_enum_type_t; + +/*here comes general type and macro definition for AESM related Server URL which will be shared by code in other components*/ +typedef enum _aesm_network_server_enum_type_t{ + SE_EPID_PROVISIONING, + PSE_PROVISIONING, + ENDPOINT_SELECTION, + REVOCATION_LIST_RETRIEVAL, + PSE_OCSP +}aesm_network_server_enum_type_t; + +typedef enum _pve_msg_type_t +{ + TYPE_PROV_MSG1, + TYPE_PROV_MSG2, + TYPE_PROV_MSG3, + TYPE_PROV_MSG4 +}pve_msg_type_t; + +typedef enum _pse_msg_type_t +{ + TYPE_PSE_MSG1, + TYPE_PSE_MSG2, + TYPE_PSE_MSG3, + TYPE_PSE_MSG4 +}pse_msg_type_t; + +typedef enum _es_msg_type_t +{ + TYPE_ES_MSG1, + TYPE_ES_MSG2 +}es_msg_type_t; + +typedef enum _rlr_msg_type_t +{ + TYPE_RLR_MSG1, + TYPE_RLR_MSG2 +}rlr_msg_type_t; + +#include "epid_pve_type.h" + +typedef uint16_t general_response_status_t; +enum _general_response_status_t +{ + GRS_OK, + GRS_SERVER_BUSY, + GRS_INTEGRITY_CHECK_FAIL, + GRS_INCORRECT_SYNTAX, + GRS_INCOMPATIBLE_VERSION, + GRS_TRANSACTION_STATE_LOST, + GRS_PROTOCOL_ERROR, + GRS_INTERNAL_ERROR +}; + +typedef uint16_t se_protocol_response_status_t; + +enum _se_protocol_response_status_t +{ + SE_PRS_OK, + SE_PRS_PLATFORM_REVOKED, + SE_PRS_STATUS_INTEGRITY_FAILED, + SE_PRS_PERFORMANCE_REKEY_NOT_SUPPORTED +}; + +typedef uint16_t pse_protocol_response_status_t; +enum _pse_protocol_response_status_t +{ + PSE_PRS_OK, + PSE_PRS_INVALID_GID, + PSE_PRS_GID_REVOKED, + PSE_PRS_INVALID_QUOTE, + PSE_PRS_INVALID_REQUEST +}; + + +#pragma pack(1) +#define NET_S_OK 0 +typedef struct _provision_request_header_t{ + uint8_t protocol; + uint8_t version; + uint8_t xid[XID_SIZE]; /*transaction id, the unique id from ProvMsg1 to ProvMsg4*/ + uint8_t type; + uint8_t size[4]; /*size of request body*/ +}provision_request_header_t; + +typedef struct _provision_response_header_t{ + uint8_t protocol; + uint8_t version; + uint8_t xid[XID_SIZE]; + uint8_t type; + uint8_t gstatus[2]; + uint8_t pstatus[2]; + uint8_t size[4]; +}provision_response_header_t; + +#pragma pack() + +#define PROVISION_REQUEST_HEADER_SIZE sizeof(provision_request_header_t) +#define PROVISION_RESPONSE_HEADER_SIZE sizeof(provision_response_header_t) +#define GET_BODY_SIZE_FROM_PROVISION_REQUEST(req) lv_ntohl(((const provision_request_header_t *)(req))->size) +#define GET_BODY_SIZE_FROM_PROVISION_RESPONSE(resp) lv_ntohl(((const provision_response_header_t *)(resp))->size) +#define GET_SIZE_FROM_PROVISION_REQUEST(req) (GET_BODY_SIZE_FROM_PROVISION_REQUEST(req)+PROVISION_REQUEST_HEADER_SIZE) +#define GET_SIZE_FROM_PROVISION_RESPONSE(resp) (GET_BODY_SIZE_FROM_PROVISION_RESPONSE(resp)+PROVISION_RESPONSE_HEADER_SIZE) +#define GET_TYPE_FROM_PROVISION_REQUEST(req) (((const provision_request_header_t *)(req))->type) +#define GET_TYPE_FROM_PROVISION_RESPONSE(resp) (((const provision_response_header_t *)(resp))->type) + +#define TLV_VERSION_1 1 + +#endif + diff --git a/psw/ae/inc/internal/utility.h b/psw/ae/inc/internal/utility.h new file mode 100644 index 0000000000..b5ec769cab --- /dev/null +++ b/psw/ae/inc/internal/utility.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ECC_H +#define _ECC_H + +#include "pse_inc.h" +#include "pse_types.h" +#include "stdlib.h" +#include "aeerror.h" +#include "ae_ipp.h" + +#ifndef BREAK_ON_ERROR +#define BREAK_ON_ERROR(x) if(SGX_SUCCESS != x){break;} +#endif + +bool verify_hmac_sha256( + const uint8_t* mac_key, + uint32_t key_len, + const uint8_t* data_buf, + uint32_t buf_size, + const uint8_t* mac_buf); + +ae_error_t error_reinterpret(pse_op_error_t op_error); + +#endif \ No newline at end of file diff --git a/psw/ae/inc/se_sig_rl.h b/psw/ae/inc/se_sig_rl.h new file mode 100644 index 0000000000..f33250cba7 --- /dev/null +++ b/psw/ae/inc/se_sig_rl.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SE_SIG_RL_H_ +#define _SE_SIG_RL_H_ + +#include "se_types.h" +#include "epid_types.h" +#include "sgx_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define SE_EPID_SIG_RL_VERSION 0x200 +#define SE_EPID_SIG_RL_ID 0xE00 +/* This is the size of ECDSA signature appended at the end of SIG-RL, + in bytes. */ +#define SE_ECDSA_SIGN_SIZE 32 + +#pragma pack(push, 1) +typedef struct _se_sig_rl_t { + uint16_t protocol_version; /* Big-endian*/ + uint16_t epid_identifier; /* Big-endian, 14 for sig_rl.*/ + SigRL sig_rl; +}se_sig_rl_t; + +typedef struct _se_ae_ecdsa_hash_t { + uint32_t hash[8]; +}se_ae_ecdsa_hash_t; +#pragma pack(pop) + +uint64_t se_get_sig_rl_size(const se_sig_rl_t *p_sig_rl); + +#ifndef _SGX_UAE_SERVICE_H_ +sgx_status_t sgx_get_quote_size(const uint8_t *sig_rl, uint32_t* p_quote_size); +#endif + +#ifdef __cplusplus + } +#endif + + +#endif + diff --git a/psw/ae/le/Makefile b/psw/ae/le/Makefile new file mode 100644 index 0000000000..53a855dd88 --- /dev/null +++ b/psw/ae/le/Makefile @@ -0,0 +1,77 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR := ../../.. +include ../buildenv.mk + +AENAME = launch_enclave + +CFLAGS += -Werror +CXXFLAGS += -Werror + +INCLUDE += -I$(LINUX_PSW_DIR)/ae/common +INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux + +SRC := $(wildcard *.cpp) version.cpp +OBJ := $(SRC:.cpp=.o) +AENAME_OUT := $(SONAME) #generate $(SONAME) only but do not sign it +LE_COPY_OUT := ../../ae/data/prebuilt/libsgx_le.signed.so ../../ae/data/prebuilt/le_prod_css.bin + +CONFIG := config_linux.xml + +.PHONY: all +all: version $(AENAME_OUT) | $(BUILD_DIR) + @$(CP) $(LE_COPY_OUT) $| + +$(SONAME): $(AENAME)_t.c $(OBJ) + $(CXX) $(CXXFLAGS) -o $@ $(OBJ) -nostdlib -nodefaultlibs -nostartfiles $(LDTFLAGS) + +$(OBJ): %.o:%.cpp + $(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti $(INCLUDE) $(DEFINES) -c $< -o $@ + +$(AENAME)_t.c: $(EDLFILE) + @$(EDGER8R) --trusted $< + +version.o: $(LINUX_PSW_DIR)/ae/common/version.cpp + $(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti $(INCLUDE) $(DEFINES) -c $< -o $@ + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: clean +clean: + @$(RM) *.o + @$(RM) *.so + @$(RM) *.map + @$(RM) *_t.* + +.PHONY: rebuild +rebuild: clean all diff --git a/psw/ae/le/config_debug.xml b/psw/ae/le/config_debug.xml new file mode 100644 index 0000000000..7a66a6d111 --- /dev/null +++ b/psw/ae/le/config_debug.xml @@ -0,0 +1,12 @@ + + 1 + 0 + 1 + 0x20 + 1 + 1 + 1 + 0x2000 + 0xb000 + 0x1 + diff --git a/psw/ae/le/config_linux.xml b/psw/ae/le/config_linux.xml new file mode 100644 index 0000000000..e6c98d43e4 --- /dev/null +++ b/psw/ae/le/config_linux.xml @@ -0,0 +1,13 @@ + + 1 + 0 + 1 + 0x20 + 1 + 1 + 1 + 0x2000 + 0xb000 + 0x1 + 1 + diff --git a/psw/ae/le/launch_enclave.cpp b/psw/ae/le/launch_enclave.cpp new file mode 100644 index 0000000000..75a2cd59d5 --- /dev/null +++ b/psw/ae/le/launch_enclave.cpp @@ -0,0 +1,604 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "launch_enclave.h" +#include "byte_order.h" +#include "sgx_utils.h" + +#include "launch_enclave_t.c" +#include "wl_pub.hh" +#include "launch_enclave_mrsigner.hh" +#include "service_enclave_mrsigner.hh" + +#if !defined(SWAP_ENDIAN_DW) +#define SWAP_ENDIAN_DW(dw) ((((dw) & 0x000000ff) << 24) \ + | (((dw) & 0x0000ff00) << 8) \ + | (((dw) & 0x00ff0000) >> 8) \ + | (((dw) & 0xff000000) >> 24)) +#endif + +#if !defined(SWAP_ENDIAN_32B) +#define SWAP_ENDIAN_8X32B(ptr) \ +{ \ + uint32_t temp = 0; \ + temp = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[0]); \ + ((uint32_t*)(ptr))[0] = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[7]); \ + ((uint32_t*)(ptr))[7] = temp; \ + temp = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[1]); \ + ((uint32_t*)(ptr))[1] = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[6]); \ + ((uint32_t*)(ptr))[6] = temp; \ + temp = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[2]); \ + ((uint32_t*)(ptr))[2] = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[5]); \ + ((uint32_t*)(ptr))[5] = temp; \ + temp = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[3]); \ + ((uint32_t*)(ptr))[3] = SWAP_ENDIAN_DW(((uint32_t*)(ptr))[4]); \ + ((uint32_t*)(ptr))[4] = temp; \ +} +#endif + +#define LE_MAX_MRSIGNER_NUMBER 512 +// Macro used to get mac wl cert size, signature is not included +#define LE_MAX_WL_CERT_SIZE (sizeof(wl_cert_t) + LE_MAX_MRSIGNER_NUMBER \ + * sizeof(sgx_measurement_t)) + +#define WL_CERT_VERSION 0x0100 +#define WL_CERT_TYPE 0x0100 +#define WL_CERT_PROVIDER_ID 0 +#define WL_PROVIDER_CERT_VERSION 0x0100 +#define WL_PROVIDER_CERT_TYPE 0 +#define WL_PROVIDER_CERT_PROVIDER_ID 0 +#define WL_PROVIDER_CERT_ROOT_ID 0 + + +static uint8_t g_wl_cert_buf[LE_MAX_WL_CERT_SIZE] = {0}; + +static void reverse_byte_array(uint8_t *array, size_t size) +{ + size_t i = 0; + for(i = 0; i < size / 2; i++) + { + uint8_t temp = array[i]; + array[i] = array[size - i - 1]; + array[size - i - 1] = temp; + } +} + +//calculate launch token. key_id, attributes_le and then mac is updated. +//return AE_SUCCESS on success +static ae_error_t le_calc_lic_token(token_t* lictoken) +{ + //calculate launch token + + sgx_key_request_t key_request; + sgx_key_128bit_t launch_key; + + if(SGX_SUCCESS != sgx_read_rand((uint8_t*)&lictoken->key_id, + sizeof(sgx_key_id_t))) + { + return LE_UNEXPECTED_ERROR; + } + // Create Key Request + memset(&key_request, 0, sizeof(key_request)); + + //setup key_request parameters to derive launch key + key_request.key_name = SGX_KEYSELECT_LICENSE; + + memcpy(&key_request.key_id, &lictoken->key_id, + sizeof(key_request.key_id)); + + memcpy(&key_request.cpu_svn, &(lictoken->cpu_svn_le), + sizeof(key_request.cpu_svn)); + + memcpy(&key_request.isv_svn, &(lictoken->isv_svn_le), + sizeof(key_request.isv_svn)); + + + key_request.attribute_mask.xfrm = 0; + //0xFFFFFFFFFFFFFFFB: ~SGX_FLAGS_MODE64BIT + key_request.attribute_mask.flags = ~SGX_FLAGS_MODE64BIT; + key_request.misc_mask = 0xFFFFFFFF; + + lictoken->masked_misc_select_le &= key_request.misc_mask; + + + + lictoken->attributes_le.flags = (lictoken->attributes_le.flags) + & (key_request.attribute_mask.flags); + lictoken->attributes_le.xfrm = (lictoken->attributes_le.xfrm) + & (key_request.attribute_mask.xfrm); + + // EGETKEY + sgx_status_t sgx_ret = sgx_get_key(&key_request,&launch_key); + if(SGX_SUCCESS != sgx_ret) + { + return LE_GET_LICENSE_KEY_ERROR; + } + + sgx_cmac_state_handle_t p_cmac_handle = NULL; + do{ + sgx_ret = sgx_cmac128_init(&launch_key, &p_cmac_handle); + if(SGX_SUCCESS != sgx_ret) + { + break; + } + sgx_ret = sgx_cmac128_update((uint8_t*)&lictoken->body, + sizeof(lictoken->body), + p_cmac_handle); + if(SGX_SUCCESS != sgx_ret) + { + break; + } + sgx_ret = sgx_cmac128_final(p_cmac_handle, + (sgx_cmac_128bit_tag_t*)&lictoken->mac); + }while(0); + if (p_cmac_handle != NULL) + { + sgx_cmac128_close(p_cmac_handle); + } + + //clear launch_key after being used + memset_s(launch_key,sizeof(launch_key), 0, sizeof(launch_key)); + if (SGX_SUCCESS != sgx_ret) + { + return AE_FAILURE; + } + + return AE_SUCCESS; +} + + +ae_error_t le_generate_launch_token( + const sgx_measurement_t* mrenclave, + const sgx_measurement_t* mrsigner, + const sgx_attributes_t* se_attributes, + token_t* lictoken) +{ + uint32_t i = 0; + bool is_production = false; + sgx_status_t sgx_ret = SGX_ERROR_UNEXPECTED; + ae_error_t ae_ret = AE_FAILURE; + wl_cert_t *p_wl_cert_cache = (wl_cert_t *)g_wl_cert_buf; + sgx_measurement_t empty_mrsigner; + sgx_report_t report; + + // se_attributes must have no reserved bit set. + // urts(finally EINIT instruction)rejects EINIT Token with SGX_FLAGS_INITTED + // set. So LE doesn't need to check it here. + if((se_attributes->flags) & SGX_FLAGS_RESERVED) + { + return LE_INVALID_ATTRIBUTE; + } + + memset(&report, 0, sizeof(report)); + // Create report to get current cpu_svn and isv_svn. + sgx_ret = sgx_create_report(NULL, NULL, &report); + if(SGX_SUCCESS != sgx_ret) + { + return LE_UNEXPECTED_ERROR; + } + + for(i = 0; i < (sizeof(g_le_mrsigner) / sizeof(g_le_mrsigner[0])); i++) + { + if(0 == memcmp(&(g_le_mrsigner[i]), &(report.body.mr_signer), + sizeof(g_le_mrsigner[0]))) + { + is_production = true; + break; + } + } + + if(true == is_production) + { + // Only Provision Enclave is allowed to be EINITed with the privilege + // to access the PROVISIONKEY, which is signed with fixed signing key + if((se_attributes->flags & SGX_FLAGS_PROVISION_KEY)) + { + for(i = 0; i < (sizeof(G_SERVICE_ENCLAVE_MRSIGNER) / sizeof(G_SERVICE_ENCLAVE_MRSIGNER[0])); + i++) + { + if(0 == memcmp(&G_SERVICE_ENCLAVE_MRSIGNER[i], mrsigner, + sizeof(G_SERVICE_ENCLAVE_MRSIGNER[0]))) + { + break; + } + } + if(i == sizeof(G_SERVICE_ENCLAVE_MRSIGNER) / sizeof(G_SERVICE_ENCLAVE_MRSIGNER[0])) + { + return LE_INVALID_ATTRIBUTE; + } + } + } + + // on "production" system, enclaves to be launched in "non-enclave-debug" + // mode are subjected to Enclave Signing Key White Listing control. + if(((se_attributes->flags & SGX_FLAGS_DEBUG) == 0) + && (true == is_production)) + { + // Check whether the wl is initialized + if(p_wl_cert_cache->version == 0) + { + return LE_WHITELIST_UNINITIALIZED_ERROR; + } + + // Create an empty mrsigner + memset(&empty_mrsigner, 0, sizeof(empty_mrsigner)); + // Check if p_wl_cert_cache->mr_signer_list[0] is empty. + // If mr_signer_list[0] = 0, a "wild card" white list cert is in-use, + // meant to allow any enclave to launch. + if(0 != memcmp(&(p_wl_cert_cache->mr_signer_list[0]), &empty_mrsigner, + sizeof(p_wl_cert_cache->mr_signer_list[0]))) + { + for(i = 0; i < p_wl_cert_cache->entry_number; i++) + { + if(0 == memcmp(&(p_wl_cert_cache->mr_signer_list[i]), + mrsigner, + sizeof(p_wl_cert_cache->mr_signer_list[i]))) + { + break; + } + } + if(i == p_wl_cert_cache->entry_number) + { + return LE_INVALID_PRIVILEGE_ERROR; + } + } + } + + + //initial EINIT Token and set 0 for all reserved area + memset(lictoken, 0, sizeof(*lictoken)); + + //set the EINIT Token valid + lictoken->body.valid = 1; + + //set EINIT Token mrenclave + memcpy(&lictoken->body.mr_enclave, mrenclave, + sizeof(lictoken->body.mr_enclave)); + + //set EINIT Token mrsigner + memcpy(&lictoken->body.mr_signer, mrsigner, + sizeof(lictoken->body.mr_signer)); + + //set EINIT Token attributes + memcpy(&lictoken->body.attributes, se_attributes, + sizeof(lictoken->body.attributes)); + + //set EINIT Token with platform information from ereport of LE + memcpy(&lictoken->cpu_svn_le, &report.body.cpu_svn, sizeof(sgx_cpu_svn_t)); + lictoken->isv_svn_le = report.body.isv_svn; + lictoken->isv_prod_id_le = report.body.isv_prod_id; + + //will mask attributes in le_calc_lic_token + memcpy(&lictoken->attributes_le, &report.body.attributes, + sizeof(lictoken->attributes_le)); + + //will mask misc_select_le in le_calc_lic_token + lictoken->masked_misc_select_le = report.body.misc_select; + + //calculate EINIT Token + ae_ret = le_calc_lic_token(lictoken); + //if failure, clear EINIT Token + if (ae_ret != AE_SUCCESS) + { + memset_s(lictoken,sizeof(*lictoken), 0, sizeof(*lictoken)); + } + return ae_ret; + +} + + +int le_get_launch_token_wrapper( + const sgx_measurement_t* mrenclave, + const sgx_measurement_t* mrsigner, + const sgx_attributes_t* se_attributes, + token_t* lictoken) +{ + // Security assumption is that the edgr8r generated trusted bridge code + // makes sure mrenclave, mrsigner, se_attributes, lictoken buffers are all + // inside enclave. check all input and output pointers, defense in depth + if (NULL == mrenclave || + NULL == mrsigner || + NULL == se_attributes || + NULL == lictoken) + { + return LE_INVALID_PARAMETER; + } + + return le_generate_launch_token(mrenclave, mrsigner, se_attributes, + lictoken); +} + + +/* + * Internal function used to init white list. It will check the content of the + * cert chain, and verify the signature of input cert chains. If no problem, + * it will cache the input white list into EPC. + * + * @param p_wl_cert_chain[in] Pointer to the white list cert chain. + * @param entry_number[in] The entry number within the white list. + * @param wl_cert_chain_size[in] The size of white list cert chain, in bytes. + * @return uint32_t AE_SUCCESS for success, otherwise for errors. + */ +uint32_t le_init_white_list( + const wl_cert_chain_t *p_wl_cert_chain, + uint32_t entry_number, + uint32_t wl_cert_chain_size) +{ + sgx_status_t sgx_ret = SGX_SUCCESS; + uint32_t ret = AE_SUCCESS; + uint32_t new_wl_version = 0; + uint8_t verify_result = 0; + int valid = 0; + const uint8_t *buf = NULL; + uint32_t buf_size = 0; + sgx_prod_id_t wl_prod_id = 0; + sgx_ecc_state_handle_t ecc_handle = NULL; + wl_cert_t *p_wl_cert_cache = (wl_cert_t *)g_wl_cert_buf; + sgx_report_t report; + sgx_ec256_signature_t wl_signature; + sgx_ec256_public_t wl_pubkey; + + + // Check fields of provider cert + // Format version should be 1 (big endian) + if(p_wl_cert_chain->wl_provider_cert.version != WL_PROVIDER_CERT_VERSION) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + // For Enclave Signing Key White List Cert, must be 0 + if(p_wl_cert_chain->wl_provider_cert.cert_type != WL_PROVIDER_CERT_TYPE) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + // only one White List Provider is approved: + // WLProviderID: ISecG = 0 + if(p_wl_cert_chain->wl_provider_cert.provider_id != WL_PROVIDER_CERT_PROVIDER_ID) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + // only one WLRootID is valid: WLRootID-iKGF-Key-0 = 0 + if(p_wl_cert_chain->wl_provider_cert.root_id != WL_PROVIDER_CERT_ROOT_ID) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + + // Check fields of wl cert + // only valid version is 1 + if(p_wl_cert_chain->wl_cert.version != WL_CERT_VERSION) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + // For Enclave Signing Key White List Cert, must be 1 + if(p_wl_cert_chain->wl_cert.cert_type != WL_CERT_TYPE) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + // only one White List Provider is approved: + // WLProviderID: ISecG = 0 + if(p_wl_cert_chain->wl_cert.provider_id != WL_CERT_PROVIDER_ID) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + + // If cache exists + new_wl_version = p_wl_cert_chain->wl_cert.wl_version; + new_wl_version = _ntohl(new_wl_version); + if(p_wl_cert_cache->version != 0) + { + // the logic will be needed to support more than + // one providers in the future. + //if(p_wl_cert_chain->wl_cert.provider_id + // != p_wl_cert_cache->provider_id) + //{ + // ret = LE_INVALID_PARAMETER; + // goto CLEANUP; + //} + if(new_wl_version < p_wl_cert_cache->wl_version) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + } + + sgx_ret = sgx_ecc256_open_context(&ecc_handle); + if (SGX_SUCCESS != sgx_ret) + { + ret = LE_UNEXPECTED_ERROR; + goto CLEANUP; + } + + memset(&wl_signature, 0, sizeof(wl_signature)); + // Convert the signature of provider cert into little endian + memcpy(&wl_signature, + &(p_wl_cert_chain->wl_provider_cert.signature), + sizeof(wl_signature)); + SWAP_ENDIAN_8X32B(wl_signature.x); + SWAP_ENDIAN_8X32B(wl_signature.y); + + // Verify the wl provider cert + buf = (const uint8_t *)&(p_wl_cert_chain->wl_provider_cert); + buf_size = static_cast(sizeof(p_wl_cert_chain->wl_provider_cert) + - sizeof(p_wl_cert_chain->wl_provider_cert.signature)); + sgx_ret = sgx_ecdsa_verify(buf, buf_size, + &g_wl_root_pubkey, + &wl_signature, + &verify_result, + ecc_handle); + if (SGX_SUCCESS != sgx_ret) + { + ret = LE_UNEXPECTED_ERROR; + goto CLEANUP; + } + if(SGX_EC_VALID != verify_result) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + + // Convert the signature of wl cert into little endian + buf = (const uint8_t *)p_wl_cert_chain + wl_cert_chain_size + - sizeof(wl_signature); + memcpy(&wl_signature, buf, sizeof(wl_signature)); + SWAP_ENDIAN_8X32B(wl_signature.x); + SWAP_ENDIAN_8X32B(wl_signature.y); + + // Convert the pubkey into little endian + memset(&wl_pubkey, 0, sizeof(wl_pubkey)); + memcpy(&wl_pubkey, + &(p_wl_cert_chain->wl_provider_cert.pub_key), + sizeof(wl_pubkey)); + reverse_byte_array(wl_pubkey.gx, sizeof(wl_pubkey.gx)); + reverse_byte_array(wl_pubkey.gy, sizeof(wl_pubkey.gy)); + + // Check whether the pubkey is valid first. + sgx_ret = sgx_ecc256_check_point(&wl_pubkey, ecc_handle, &valid); + if(SGX_SUCCESS != sgx_ret) + { + ret = LE_UNEXPECTED_ERROR; + goto CLEANUP; + } + if(!valid) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + + // Verify the wl_cert + buf = (const uint8_t *)&(p_wl_cert_chain->wl_cert); + buf_size = wl_cert_chain_size - static_cast(sizeof(wl_provider_cert_t) + sizeof(sgx_ec256_signature_t)); + sgx_ret = sgx_ecdsa_verify(buf, buf_size, + &wl_pubkey, + &wl_signature, + &verify_result, + ecc_handle); + if (SGX_SUCCESS != sgx_ret) + { + ret = LE_UNEXPECTED_ERROR; + goto CLEANUP; + } + if(SGX_EC_VALID != verify_result) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + + memset(&report, 0, sizeof(report)); + // Create report to get current mrsigner. + sgx_ret = sgx_create_report(NULL, NULL, &report); + if(SGX_SUCCESS != sgx_ret) + { + ret = LE_UNEXPECTED_ERROR; + goto CLEANUP; + } + + // Convert the big endian prod id to little endian. + wl_prod_id = p_wl_cert_chain->wl_cert.le_prod_id; + wl_prod_id = _ntohs(wl_prod_id); + if(report.body.isv_prod_id != wl_prod_id) + { + ret = LE_INVALID_PARAMETER; + goto CLEANUP; + } + + // Cache the wl cert + memset(g_wl_cert_buf, 0, sizeof(g_wl_cert_buf)); + memcpy(g_wl_cert_buf, &(p_wl_cert_chain->wl_cert), buf_size); + // Change entry_number and wl_version to little endian, so we don't need to + // convert them next time. + p_wl_cert_cache->entry_number = entry_number; + p_wl_cert_cache->wl_version = new_wl_version; + +CLEANUP: + if(ecc_handle != NULL) + { + sgx_ecc256_close_context(ecc_handle); + } + return ret; + +} + +/* + * External function used to init white list. It will check whether the input + * buffer is correctly copied into EPC, and check the size of the buffer. + * + * @param wl_cert_chain[in] Pointer to the white list cert chain. + * @param wl_cert_chain_size[in] The size of white list cert chain, in bytes. + * @return uint32_t AE_SUCCESS for success, otherwise for errors. + */ +uint32_t le_init_white_list_wrapper( + const uint8_t *wl_cert_chain, + uint32_t wl_cert_chain_size) +{ + const wl_cert_chain_t *p_wl_cert_chain = NULL; + uint32_t entry_number = 0; + uint32_t temp_size = 0; + + if(wl_cert_chain == NULL) + { + return LE_INVALID_PARAMETER; + } + if(!sgx_is_within_enclave(wl_cert_chain, wl_cert_chain_size)) + return LE_INVALID_PARAMETER; + p_wl_cert_chain = (const wl_cert_chain_t *)wl_cert_chain; + // First compare wl_cert_chain_size with the minimal size of cert chain. + // It should have at least one entry of mrsigner. + if(wl_cert_chain_size < sizeof(wl_cert_chain_t) + + sizeof(sgx_measurement_t) + + sizeof(sgx_ec256_signature_t)) + { + return LE_INVALID_PARAMETER; + } + entry_number = p_wl_cert_chain->wl_cert.entry_number; + entry_number = _ntohl(entry_number); + // limits max MRSIGNER entry number in + // WL Cert to be <= 512 + if(entry_number > LE_MAX_MRSIGNER_NUMBER) + { + return LE_INVALID_PARAMETER; + } + temp_size = static_cast(sizeof(wl_cert_chain_t) + + sizeof(sgx_ec256_signature_t) + + (sizeof(sgx_measurement_t) * entry_number)); + if(wl_cert_chain_size != temp_size) + { + return LE_INVALID_PARAMETER; + } + return le_init_white_list(p_wl_cert_chain, entry_number, wl_cert_chain_size); +} + diff --git a/psw/ae/le/launch_enclave.edl b/psw/ae/le/launch_enclave.edl new file mode 100644 index 0000000000..1624b39bb6 --- /dev/null +++ b/psw/ae/le/launch_enclave.edl @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +enclave { + + include "arch.h" + include "sgx_report.h" + + trusted { + public int le_get_launch_token_wrapper( + [in] const sgx_measurement_t *mrenclave, + [in] const sgx_measurement_t *mrsigner, + [in] const sgx_attributes_t *se_attributes, + [out] token_t * lictoken + ); + + public uint32_t le_init_white_list_wrapper( + [size = wl_cert_chain_size, in] const uint8_t *wl_cert_chain, + uint32_t wl_cert_chain_size + ); + + }; +}; diff --git a/psw/ae/le/launch_enclave.h b/psw/ae/le/launch_enclave.h new file mode 100644 index 0000000000..2118ebf486 --- /dev/null +++ b/psw/ae/le/launch_enclave.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "aeerror.h" +#include "arch.h" +#include "sgx_tcrypto.h" diff --git a/psw/ae/pve/provision_enclave.edl b/psw/ae/pve/provision_enclave.edl new file mode 100644 index 0000000000..356d68888a --- /dev/null +++ b/psw/ae/pve/provision_enclave.edl @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave{ + include "provision_msg.h" + trusted { + public uint32_t gen_prov_msg1_data_wrapper([in]const psvn_t *psvn, + [in]const signed_pek_t *pek, + uint8_t performance_rekey_flag, + [out] prov_msg1_output_t *msg1_output); + + public uint32_t get_ek2_wrapper([in] const prov_get_ek2_input_t *input, + [out] prov_get_ek2_output_t *ek2); + + public uint32_t proc_prov_msg2_data_wrapper([in]const proc_prov_msg2_blob_input_t *msg2_input, + [user_check]const uint8_t *sigrl, uint32_t sigrl_size,//optional input sigrl in external memory + [out] gen_prov_msg3_output_t *msg3_fixed_output, + [user_check]uint8_t *epid_sig, uint32_t epid_sig_buffer_size);//optional output epid signature in external memory directly + + public uint32_t proc_prov_msg4_data_wrapper([in]const proc_prov_msg4_input_t* msg4_input, + [out]proc_prov_msg4_output_t* data_blob); + + public uint32_t gen_es_msg1_data_wrapper([out]gen_endpoint_selection_output_t *es_output); //output one byte selector + }; +}; diff --git a/psw/ae/qe/quoting_enclave.edl b/psw/ae/qe/quoting_enclave.edl new file mode 100644 index 0000000000..426736e6ba --- /dev/null +++ b/psw/ae/qe/quoting_enclave.edl @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +enclave { +include "sgx_report.h" +include "sgx_quote.h" + trusted { + public uint32_t verify_blob([size = blob_size, in, out] uint8_t *p_blob, + uint32_t blob_size, + [out] uint8_t *p_is_resealed); + + public uint32_t get_quote([size = blob_size, in, out] uint8_t *p_blob, + uint32_t blob_size, + [in] const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + [in] const sgx_spid_t *p_spid, + [in] const sgx_quote_nonce_t *p_nonce, + [user_check] const uint8_t *p_sig_rl, // SigRL is relatively big, so we cannot copy it into EPC + uint32_t sig_rl_size, + [out] sgx_report_t *qe_report, + [user_check] uint8_t *p_quote, // Quote is also big, we should output it in piece meal. + uint32_t quote_size); + }; +}; diff --git a/psw/uae_service/config.h b/psw/uae_service/config.h new file mode 100644 index 0000000000..9c705c36c4 --- /dev/null +++ b/psw/uae_service/config.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _CONFIG_H_ +#define _CONFIG_H_ + + +#ifdef _DEBUG +//wait for 10min at most for debug +#define IPC_LATENCY 600000 +#else +//long enough to do IPC and EPID Provisioning +#define IPC_LATENCY 15000 +#endif + +#define LE_RETRY_TIMES 3 +#define QE_RETRY_TIMES 3 +#define PSE_RETRY_TIMES 3 + +#endif diff --git a/psw/uae_service/linux/Makefile b/psw/uae_service/linux/Makefile new file mode 100644 index 0000000000..5771ae8ac9 --- /dev/null +++ b/psw/uae_service/linux/Makefile @@ -0,0 +1,153 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR = ../../.. +include $(TOP_DIR)/buildenv.mk + +IPC_COMMON_DIR := $(TOP_DIR)/psw/ae/common +IPC_COMMON_SRC_DIR := $(IPC_COMMON_DIR)/src +IPC_COMMON_INC_DIR := $(IPC_COMMON_DIR)/inc +IPC_COMMON_PROTO_DIR := $(IPC_COMMON_DIR)/proto +UAE_WRAPPER_DIR := ../uae_wrapper +UAE_SRC_DIR := $(UAE_WRAPPER_DIR)/src +UAE_INC_DIR := $(UAE_WRAPPER_DIR)/inc +AE_COMMON_DIR := $(LINUX_PSW_DIR)/ae/common + +INCLUDE += -I. +INCLUDE += -I$(COMMON_DIR) \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal \ + +INCLUDE += -I$(LINUX_PSW_DIR)/ae/common \ + -I$(LINUX_PSW_DIR)/ae/inc \ + -I$(LINUX_PSW_DIR)/ae/inc/internal \ + -I$(LINUX_SDK_DIR)/tseal + +INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid/inc \ + -I$(IPC_COMMON_INC_DIR) \ + -I$(UAE_INC_DIR) \ + -I$(IPC_COMMON_PROTO_DIR) \ + -I$(LINUX_PSW_DIR)/ae/aesm_service/source + +CXXFLAGS += -fPIC -Werror +PROTPBUF_CXXFLAGS := -fstack-protector -fPIC -Wall -Werror +ifdef DEBUG + PROTPBUF_CXXFLAGS += -ggdb -DDEBUG -UNDEBUG +else + PROTPBUF_CXXFLAGS += -O2 -UDEBUG -DNDEBUG +endif +ifeq ($(ARCH), x86) + PROTPBUF_CXXFLAGS += -m32 +else + PROTPBUF_CXXFLAGS += -m64 +endif + +EXTERNAL_LIB += -lprotobuf + +vpath %.cpp .. $(COMMON_DIR)/src $(IPC_COMMON_SRC_DIR) $(IPC_COMMON_PROTO_DIR) $(UAE_SRC_DIR) $(COMMON_DIR)/src $(AE_COMMON_DIR) + + + +IPC_SRC := AECloseSessionRequest.cpp \ + AEGetQuoteResponse.cpp \ + AECloseSessionResponse.cpp \ + AEInitQuoteRequest.cpp \ + AECreateSessionRequest.cpp \ + AEInitQuoteResponse.cpp \ + AECreateSessionResponse.cpp \ + AEInvokeServiceRequest.cpp \ + AEExchangeReportRequest.cpp \ + AEInvokeServiceResponse.cpp \ + AEExchangeReportResponse.cpp \ + AEGetPsCapRequest.cpp \ + AEGetPsCapResponse.cpp \ + AEReportAttestationRequest.cpp \ + AEReportAttestationResponse.cpp \ + ProtobufSerializer.cpp \ + AEGetLaunchTokenRequest.cpp \ + SocketTransporter.cpp \ + AEGetLaunchTokenResponse.cpp \ + UnixCommunicationSocket.cpp \ + AEGetQuoteRequest.cpp \ + UnixSocketFactory.cpp \ + NonBlockingUnixCommunicationSocket.cpp \ + NonBlockingUnixSocketFactory.cpp + +PROTOBUF_SRC := messages.pb.cc + + +SRC := AEInternalServicesProvider.cpp \ + AEServicesImpl.cpp \ + AEServicesProvider.cpp \ + tae_ocall_api.cpp \ + uae_api.cpp \ + se_sig_rl.cpp \ + sgx_uae_service.cpp \ + uae_service_version.cpp \ + uae_service_assert.cpp + +OBJ := $(SRC:.cpp=.o) $(IPC_SRC:.cpp=.o) $(PROTOBUF_SRC:.cc=.o) + +LDUFLAGS:= -pthread -L$(BUILD_DIR) + +DLLNAME = libsgx_uae_service.so + + +.PHONY: all +all: install_dll + + +.PHONY: install_dll +install_dll: $(DLLNAME)| $(BUILD_DIR) + @$(CP) $^ $| + +$(DLLNAME): $(OBJ) + $(CXX) $(CXXFLAGS) $(OBJ) -shared $(LDUFLAGS) $(EXTERNAL_LIB) -o $@ + +%.o :%.cpp PROTPBUF + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: PROTPBUF +PROTPBUF: + $(MAKE) -C $(IPC_COMMON_PROTO_DIR) + (test -f messages.pb.o) || ($(CXX) $(PROTPBUF_CXXFLAGS) -c $(IPC_COMMON_PROTO_DIR)/messages.pb.cc -o messages.pb.o) + +.PHONY: clean +clean: + $(MAKE) -C $(IPC_COMMON_PROTO_DIR) clean + @$(RM) $(OBJ) + @$(RM) $(DLLNAME) $(BUILD_DIR)/$(DLLNAME) + +.PHONY: rebuild +rebuild: clean all diff --git a/psw/uae_service/sgx_uae_service.cpp b/psw/uae_service/sgx_uae_service.cpp new file mode 100644 index 0000000000..89b5304433 --- /dev/null +++ b/psw/uae_service/sgx_uae_service.cpp @@ -0,0 +1,516 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include "sgx_uae_service.h" +#include "uae_service_internal.h" +#include /*needed to unify default timeout values */ + +#include "stdint.h" +#include "se_sig_rl.h" + +#if !defined(ntohl) +#define ntohl(u32) \ + ((uint32_t)(((((const unsigned char*)&(u32))[0]) << 24) \ + + ((((const unsigned char*)&(u32))[1]) << 16) \ + + ((((const unsigned char*)&(u32))[2]) << 8) \ + + (((const unsigned char*)&(u32))[3]))) +#endif + + +#define GET_LAUNCH_TOKEN_TIMEOUT_MSEC (IPC_LATENCY) +#define SE_INIT_QUOTE_TIMEOUT_MSEC (IPC_LATENCY) +//add 3 millisecond per sig_rl entry +#define SE_GET_QUOTE_TIMEOUT_MSEC(p_sig_rl) (IPC_LATENCY + ((p_sig_rl) ? 3*ntohl(((const se_sig_rl_t*)p_sig_rl)->sig_rl.n2) : 0)) +#define SE_GET_PS_CAP_TIMEOUT_MSEC (IPC_LATENCY) +#define SE_REPORT_REMOTE_ATTESTATION_FAILURE_TIMEOUT_MSEC (IPC_LATENCY) + +extern "C" { + +sgx_status_t get_launch_token( + const enclave_css_t* signature, + const sgx_attributes_t* attribute, + sgx_launch_token_t* launch_token) +{ + if (signature == NULL || attribute == NULL || launch_token == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + aesm_error_t result = AESM_UNEXPECTED_ERROR; + uae_oal_status_t status = oal_get_launch_token(signature, attribute, launch_token, GET_LAUNCH_TOKEN_TIMEOUT_MSEC*1000, &result); + + /*common mappings */ + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_NO_DEVICE_ERROR: + mapped = SGX_ERROR_NO_DEVICE; + break; + case AESM_GET_LICENSETOKEN_ERROR: + mapped = SGX_ERROR_SERVICE_INVALID_PRIVILEGE; + break; + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; +} + +sgx_status_t sgx_init_quote( + sgx_target_info_t *p_target_info, + sgx_epid_group_id_t *p_gid) +{ + if (p_target_info == NULL || p_gid == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + aesm_error_t result = AESM_UNEXPECTED_ERROR; + + uae_oal_status_t status = oal_init_quote(p_target_info, p_gid, SE_INIT_QUOTE_TIMEOUT_MSEC*1000, &result); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_EPIDBLOB_ERROR: + mapped = SGX_ERROR_AE_INVALID_EPIDBLOB; + break; + case AESM_EPID_REVOKED_ERROR: + mapped = SGX_ERROR_EPID_MEMBER_REVOKED; + break; + case AESM_BACKEND_SERVER_BUSY: + mapped = SGX_ERROR_BUSY; + break; + case AESM_SGX_PROVISION_FAILED: + mapped = SGX_ERROR_UNEXPECTED; + break; + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; +} + + +sgx_status_t sgx_get_quote( + const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + const sgx_spid_t *p_spid, + const sgx_quote_nonce_t *p_nonce, + const uint8_t *p_sig_rl, + uint32_t sig_rl_size, + sgx_report_t *p_qe_report, + sgx_quote_t *p_quote, + uint32_t quote_size) +{ + + if (p_report == NULL || p_spid == NULL || p_quote == NULL || quote_size == 0 ) + return SGX_ERROR_INVALID_PARAMETER; + if ((p_sig_rl == NULL && sig_rl_size != 0) || + (p_sig_rl != NULL && sig_rl_size == 0) ) + return SGX_ERROR_INVALID_PARAMETER; + + aesm_error_t result = AESM_UNEXPECTED_ERROR; + + uae_oal_status_t status = oal_get_quote(p_report, quote_type, p_spid, p_nonce, p_sig_rl, sig_rl_size, p_qe_report, + p_quote, quote_size, SE_GET_QUOTE_TIMEOUT_MSEC(p_sig_rl)*1000, &result); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_EPIDBLOB_ERROR: + mapped = SGX_ERROR_AE_INVALID_EPIDBLOB; + break; + case AESM_EPID_REVOKED_ERROR: + mapped = SGX_ERROR_EPID_MEMBER_REVOKED; + break; + case AESM_BACKEND_SERVER_BUSY: + mapped = SGX_ERROR_BUSY; + break; + case AESM_SGX_PROVISION_FAILED: + mapped = SGX_ERROR_UNEXPECTED; + break; + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; + +} + +sgx_status_t sgx_get_ps_cap(sgx_ps_cap_t* p_sgx_ps_cap) +{ + if (p_sgx_ps_cap == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + aesm_error_t result = AESM_UNEXPECTED_ERROR; + uint64_t ps_cap = 0; + + uae_oal_status_t status = oal_get_ps_cap(&ps_cap, SE_GET_PS_CAP_TIMEOUT_MSEC*1000, &result); + p_sgx_ps_cap->ps_cap0 = (uint32_t)ps_cap; + p_sgx_ps_cap->ps_cap1 = (uint32_t)(ps_cap >> 32); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_LONG_TERM_PAIRING_FAILED: + case AESM_EPH_SESSION_FAILED: + case AESM_PSDA_UNAVAILABLE: + mapped = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; + +} + +sgx_status_t sgx_report_attestation_status( + const sgx_platform_info_t* p_platform_info, + int attestation_status, + sgx_update_info_bit_t* p_update_info) +{ + if (p_platform_info == NULL || p_update_info == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + aesm_error_t result = AESM_UNEXPECTED_ERROR; + + uae_oal_status_t status = oal_report_attestation_status(p_platform_info, attestation_status, p_update_info, SE_REPORT_REMOTE_ATTESTATION_FAILURE_TIMEOUT_MSEC*1000, &result); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_BACKEND_SERVER_BUSY: + mapped = SGX_ERROR_BUSY; + break; + case AESM_PLATFORM_INFO_BLOB_INVALID_SIG: + mapped = SGX_ERROR_INVALID_PARAMETER; + break; + case AESM_SGX_PROVISION_FAILED: + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; +} + +sgx_status_t create_session_ocall( + uint32_t *session_id, + uint8_t *se_dh_msg1, + uint32_t dh_msg1_size, + uint32_t timeout) +{ + + if(!session_id || !se_dh_msg1) + return SGX_ERROR_INVALID_PARAMETER; + aesm_error_t result = AESM_UNEXPECTED_ERROR; + uae_oal_status_t status = oal_create_session(session_id, se_dh_msg1, dh_msg1_size, timeout*1000, &result); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_MAX_NUM_SESSION_REACHED: + mapped = SGX_ERROR_BUSY; + break; + case AESM_EPH_SESSION_FAILED: + case AESM_LONG_TERM_PAIRING_FAILED: + case AESM_PSDA_UNAVAILABLE: + case AESM_SERVICE_NOT_AVAILABLE: + mapped = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + case AESM_MSG_ERROR: + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; +} + +sgx_status_t exchange_report_ocall( + uint32_t session_id, + const uint8_t *se_dh_msg2, + uint32_t dh_msg2_size, + uint8_t *se_dh_msg3, + uint32_t dh_msg3_size, + uint32_t timeout) +{ + if (!se_dh_msg2 || !se_dh_msg3) + return SGX_ERROR_INVALID_PARAMETER; + + aesm_error_t result = AESM_UNEXPECTED_ERROR; + uae_oal_status_t status = oal_exchange_report(session_id, se_dh_msg2, dh_msg2_size, se_dh_msg3, dh_msg3_size, timeout*1000, &result); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_SESSION_INVALID: + mapped = SGX_ERROR_AE_SESSION_INVALID; + break; + case AESM_KDF_MISMATCH: + mapped = SGX_ERROR_KDF_MISMATCH; + break; + case AESM_EPH_SESSION_FAILED: + case AESM_LONG_TERM_PAIRING_FAILED: + case AESM_PSDA_UNAVAILABLE: + case AESM_SERVICE_NOT_AVAILABLE: + mapped = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; + +} + +sgx_status_t close_session_ocall( + uint32_t session_id, + uint32_t timeout) +{ + aesm_error_t result = AESM_UNEXPECTED_ERROR; + uae_oal_status_t status = oal_close_session(session_id, timeout*1000, &result); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_SESSION_INVALID: + mapped = SGX_ERROR_AE_SESSION_INVALID; + break; + case AESM_EPH_SESSION_FAILED: + case AESM_LONG_TERM_PAIRING_FAILED: + case AESM_SERVICE_NOT_AVAILABLE: + mapped = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; +} + +sgx_status_t invoke_service_ocall( + const uint8_t *pse_message_req, + uint32_t pse_message_req_size, + uint8_t *pse_message_resp, + uint32_t pse_message_resp_size, + uint32_t timeout) +{ + if (pse_message_req == NULL || pse_message_resp == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + aesm_error_t result = AESM_UNEXPECTED_ERROR; + uae_oal_status_t status = oal_invoke_service(pse_message_req, pse_message_req_size, pse_message_resp, pse_message_resp_size, timeout*1000, &result); + + sgx_status_t mapped = oal_map_status(status); + if (mapped != SGX_SUCCESS) + return mapped; + + mapped = oal_map_result(result); + if (mapped != SGX_SUCCESS) + { + /*operation specific mapping */ + if (mapped == SGX_ERROR_UNEXPECTED && result != AESM_UNEXPECTED_ERROR) + { + switch (result) + { + case AESM_SESSION_INVALID: + mapped = SGX_ERROR_AE_SESSION_INVALID; + break; + case AESM_EPH_SESSION_FAILED: + case AESM_LONG_TERM_PAIRING_FAILED: + case AESM_PSDA_UNAVAILABLE: + case AESM_SERVICE_NOT_AVAILABLE: + mapped = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + case AESM_MSG_ERROR: + default: + mapped = SGX_ERROR_UNEXPECTED; + } + } + } + + return mapped; +} + +// common mapper function for all OAL specific error codes + +sgx_status_t oal_map_status(uae_oal_status_t status) +{ + sgx_status_t retVal; + + switch (status) + { + case UAE_OAL_SUCCESS: + retVal = SGX_SUCCESS; + break; + case UAE_OAL_ERROR_UNEXPECTED: + retVal = SGX_ERROR_UNEXPECTED; + break; + case UAE_OAL_ERROR_AESM_UNAVAILABLE: + retVal = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + case UAE_OAL_ERROR_TIMEOUT: + retVal = SGX_ERROR_SERVICE_TIMEOUT; + break; + default: + retVal = SGX_ERROR_UNEXPECTED; + } + + return retVal; +} + +sgx_status_t oal_map_result(aesm_error_t result) +{ + sgx_status_t retVal = SGX_ERROR_UNEXPECTED; + + switch (result) + { + case AESM_SUCCESS: + retVal = SGX_SUCCESS; + break; + case AESM_UPDATE_AVAILABLE: + retVal = SGX_ERROR_UPDATE_NEEDED; + break; + case AESM_UNEXPECTED_ERROR: + retVal = SGX_ERROR_UNEXPECTED; + break; + case AESM_PARAMETER_ERROR: + retVal = SGX_ERROR_INVALID_PARAMETER; + break; + case AESM_SERVICE_STOPPED: + retVal = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + case AESM_OUT_OF_MEMORY_ERROR: + retVal = SGX_ERROR_OUT_OF_MEMORY; + break; + case AESM_BUSY: + retVal = SGX_ERROR_BUSY; + break; + case AESM_NETWORK_ERROR: + case AESM_NETWORK_BUSY_ERROR: + case AESM_PROXY_SETTING_ASSIST: + retVal = SGX_ERROR_NETWORK_FAILURE; + break; + default: + retVal = SGX_ERROR_UNEXPECTED; + } + + return retVal; + +} + +} /* extern "C" */ diff --git a/psw/uae_service/uae_service_assert.cpp b/psw/uae_service/uae_service_assert.cpp new file mode 100644 index 0000000000..43a301783c --- /dev/null +++ b/psw/uae_service/uae_service_assert.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** +* File: +* uae_service_assert.cpp +* Description: +* do some compile-time checking +*/ + +#include "aeerror.h" +#include "sgx_uae_service.h" +#include "upse/platform_info_blob.h" + +static_assert(sizeof(sgx_platform_info_t)==sizeof(((platform_info_blob_wrapper_t*)0)->platform_info_blob), "size of sgx_platform_info_t is incorret"); diff --git a/psw/uae_service/uae_service_version.cpp b/psw/uae_service/uae_service_version.cpp new file mode 100644 index 0000000000..e4b77c3d74 --- /dev/null +++ b/psw/uae_service/uae_service_version.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" +#include "se_cdefs.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_UAE_SERVICE_VERSION_STR __CONCAT("SGX_UAE_SERVICE_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_uae_service_version = SGX_UAE_SERVICE_VERSION_STR; + +#ifdef __cplusplus +} +#endif + +SGX_ACCESS_VERSION(uae_service, 1) diff --git a/psw/uae_service/uae_wrapper/inc/AEInternalServices.h b/psw/uae_service/uae_wrapper/inc/AEInternalServices.h new file mode 100644 index 0000000000..52329fe220 --- /dev/null +++ b/psw/uae_service/uae_wrapper/inc/AEInternalServices.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_INTERNAL_SERVICES_H +#define __AE_INTERNAL_SERVICES_H + +#include + +class AEInternalServices : public AEServices +{ + public: + virtual ~AEInternalServices() {} + + virtual AttestationInformation* InitQuote(uint32_t timeout_msec=0) = 0; + virtual QuoteInfo* GetQuote(const Report* report, const uint32_t quoteType, const SPID* spid, const Nonce* nonce, + const SignatureRevocationList* sig_rl, const uint32_t bufSize, const bool qe_report, + uint32_t timeout_msec=0) = 0; + + virtual CreateSessionInformation* CreateSession(uint32_t dhMsg1Size, uint32_t timeout = 0) =0; + virtual PSEMessage* InvokeService(PSEMessage* targetServiceMessage, uint32_t pseResponseSize, uint32_t timeout = 0) =0; + virtual PlainData* ExchangeReport(uint32_t sessionId, PlainData* dhMsg, uint32_t pseResponseSize, uint32_t timeout = 0) =0; + virtual PlainData* CloseSession(uint32_t sessionId, uint32_t timeout = 0) =0; + + virtual LaunchToken* GetLaunchToken(EnclaveMeasurement* mr_enclave, Signature* mr_signer, SEAttributes* se_attributes, uint32_t timeout_msec=0) =0; + + virtual PsCap* GetPsCap(uint32_t timeout_msec=0) =0; + virtual AttestationStatus* ReportAttestationError(const PlatformInfo* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout_msec=0) =0; +}; + +#endif diff --git a/psw/uae_service/uae_wrapper/inc/AEInternalServicesProvider.h b/psw/uae_service/uae_wrapper/inc/AEInternalServicesProvider.h new file mode 100644 index 0000000000..a9d64c2606 --- /dev/null +++ b/psw/uae_service/uae_wrapper/inc/AEInternalServicesProvider.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_INTERNAL_SERVICES_PROVIDER_H +#define _AE_INTERNAL_SERVICES_PROVIDER_H + +class AEInternalServices; + +class AEInternalServicesProvider +{ + public: + static AEInternalServices* GetInternalServicesProvider(); + + protected: + AEInternalServicesProvider(); + + static AEInternalServices* mProviderInstance; +}; + +#endif diff --git a/psw/uae_service/uae_wrapper/inc/AEServices.h b/psw/uae_service/uae_wrapper/inc/AEServices.h new file mode 100644 index 0000000000..f688428eb2 --- /dev/null +++ b/psw/uae_service/uae_wrapper/inc/AEServices.h @@ -0,0 +1,262 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_SERVICES_H +#define _AE_SERVICES_H + +#include +#include +#include + +#include +#include +#include +#include + +struct PlainData +{ + uint32_t length; + uint8_t* data; + uint32_t errorCode; + uae_oal_status_t uaeStatus; + +#ifdef __cplusplus + PlainData() : length(0), data(NULL), errorCode(AESM_UNEXPECTED_ERROR), uaeStatus(UAE_OAL_ERROR_UNEXPECTED) {} + ~PlainData(){ + if (data != NULL) delete [] data; + data = NULL; + } + + bool operator==(const PlainData& other) const { + if (this == &other) return true; + if (this == NULL || &other == NULL) return false; + + if (length != other.length || errorCode != other.errorCode) + return false; + if (data == NULL && other.data == NULL) return true; + + if (data != NULL && other.data != NULL) + return (memcmp(data, other.data, other.length) == 0); + else + return false; + } + + void copyFields(const PlainData& other) { + length = other.length; + errorCode = other.errorCode; + + if(other.data == NULL) + data = NULL; + else { + data = new uint8_t[length]; + + memcpy(data, other.data, length); + } + } + + PlainData& operator=(const PlainData& other) { + if (this == &other) + return *this; + + if (data != NULL) + delete [] data; + + copyFields(other); + + return *this; + } + + PlainData(const PlainData& other):length(0), data(NULL), errorCode(AESM_UNEXPECTED_ERROR), uaeStatus(UAE_OAL_ERROR_UNEXPECTED) { + copyFields(other); + } +#endif +}; + +typedef PlainData Quote; +typedef PlainData Report; +typedef PlainData TargetInfo; + +typedef PlainData PlatformGID; +typedef PlainData SignatureRevocationList; +typedef PlainData Nonce; +typedef PlainData SPID; + +typedef PlainData LaunchToken; +typedef PlainData EnclaveMeasurement; +typedef PlainData Signature; +typedef PlainData SEAttributes; +typedef PlainData PSEMessage; + +typedef PlainData PlatformInfo; +typedef PlainData UpdateInfo; + +struct AttestationInformation +{ + uint32_t errorCode; + uae_oal_status_t uaeStatus; + TargetInfo* quotingTarget; + PlatformGID* platformGID; + + AttestationInformation(): errorCode(AESM_UNEXPECTED_ERROR), uaeStatus(UAE_OAL_ERROR_UNEXPECTED), quotingTarget(NULL),platformGID(NULL) {} + ~AttestationInformation() + { + delete quotingTarget; + delete platformGID; + } + + bool operator==(const AttestationInformation& other) const{ + if (this == &other) return true; + if (errorCode != other.errorCode) return false; + if (*quotingTarget == *other.quotingTarget && + *platformGID == *other.platformGID) + return true; + return false; + } + private: + AttestationInformation(const AttestationInformation&); // Prevent copy-construction + AttestationInformation& operator=(const AttestationInformation&); // Prevent assignment + + +}; + +struct QuoteInfo +{ + uint32_t errorCode; + uae_oal_status_t uaeStatus; + Quote* quote; + Report* qeReport; + + QuoteInfo(): errorCode(AESM_UNEXPECTED_ERROR), uaeStatus(UAE_OAL_ERROR_UNEXPECTED), quote(NULL), qeReport(NULL) {} + ~QuoteInfo() + { + delete quote; + delete qeReport; + } + + bool operator==(const QuoteInfo& other) const{ + if (this == &other) return true; + if (errorCode != other.errorCode) return false; + if (*quote == *other.quote && + *qeReport == *other.qeReport) + return true; + return false; + } + private: + QuoteInfo(const QuoteInfo&); // Prevent copy-construction + QuoteInfo& operator=(const QuoteInfo&); // Prevent assignment +}; + +struct CreateSessionInformation +{ + uint32_t errorCode; + uae_oal_status_t uaeStatus; + unsigned int sessionId; + PlainData* dh_msg1; + + CreateSessionInformation(): errorCode(AESM_UNEXPECTED_ERROR), uaeStatus(UAE_OAL_ERROR_UNEXPECTED), sessionId(0),dh_msg1(NULL) {} + ~CreateSessionInformation() + { + delete dh_msg1; + } + + bool operator==(const CreateSessionInformation& other) const + { + if (this == &other) return true; + if (sessionId != other.sessionId || errorCode != other.errorCode) + return false; + return *dh_msg1 == *other.dh_msg1; + } + + private: + CreateSessionInformation(const CreateSessionInformation&); // Prevent copy-construction + CreateSessionInformation& operator=(const CreateSessionInformation&); // Prevent assignment + +}; + +struct PsCap +{ + uint32_t errorCode; + uae_oal_status_t uaeStatus; + uint64_t ps_cap; + + PsCap(): errorCode(AESM_UNEXPECTED_ERROR), uaeStatus(UAE_OAL_ERROR_UNEXPECTED), ps_cap(0){} + ~PsCap() + { + } + + bool operator==(const PsCap& other) const + { + if (this == &other) return true; + return ps_cap == other.ps_cap; + } +}; + + + +struct AttestationStatus +{ + uint32_t errorCode; + uae_oal_status_t uaeStatus; + UpdateInfo* updateInfo; + + AttestationStatus(): errorCode(AESM_UNEXPECTED_ERROR), uaeStatus(UAE_OAL_ERROR_UNEXPECTED), updateInfo(NULL) {} + ~AttestationStatus() + { + delete updateInfo; + } + + bool operator==(const AttestationStatus& other) const{ + if (this == &other) return true; + if (errorCode != other.errorCode) return false; + if (*updateInfo == *other.updateInfo) + return true; + return false; + } + private: + AttestationStatus(const AttestationStatus&); // Prevent copy-construction + AttestationStatus& operator=(const AttestationStatus&); // Prevent assignment +}; + +class AEServices +{ + public: + AEServices() {} + virtual ~AEServices() {} + + virtual AttestationInformation* InitQuote(uint32_t timeout_msec=0) = 0; + virtual QuoteInfo* GetQuote(const Report* report, const uint32_t quoteType, const SPID* spid, const Nonce* nonce, + const SignatureRevocationList* sig_rl, const uint32_t bufSize, const bool qe_report, + uint32_t timeout_msec=0) = 0; + virtual PsCap* GetPsCap(uint32_t timeout_msec=0) = 0; + virtual AttestationStatus* ReportAttestationError(const PlatformInfo* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout_msec=0) = 0; + +}; + +#endif diff --git a/psw/uae_service/uae_wrapper/inc/AEServicesImpl.h b/psw/uae_service/uae_wrapper/inc/AEServicesImpl.h new file mode 100644 index 0000000000..45eac15978 --- /dev/null +++ b/psw/uae_service/uae_wrapper/inc/AEServicesImpl.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __AE_SERVICES_IMPL_H__ +#define __AE_SERVICES_IMPL_H__ + +#include +#include +#include + +class ITransporter; + +class AEServicesImpl : public AEInternalServices{ + public: + ~AEServicesImpl(); + + QuoteInfo* GetQuote(const Report* report, const uint32_t quoteType, const SPID* spid, const Nonce* nonce, + const SignatureRevocationList* sig_rl, const uint32_t bufSize, const bool qe_report, uint32_t timeout_msec=0); + + AttestationInformation* InitQuote(uint32_t timeout_msec=0); + + LaunchToken* GetLaunchToken(EnclaveMeasurement *mr_enclave, + Signature *mr_signer, + SEAttributes *se_attributes, + uint32_t timeout_msec=0); + + CreateSessionInformation* CreateSession(uint32_t dhMsg1Size, uint32_t timeout = 0); + + PSEMessage* InvokeService(PSEMessage* targetServiceMessage, uint32_t pseResponseSize, uint32_t timeout = 0); + + PlainData* ExchangeReport(uint32_t sessionId, PlainData* dhMsg, uint32_t pseResponseSize, uint32_t timeout = 0); + + PlainData* CloseSession(uint32_t sessionId, uint32_t timeout = 0); + + PsCap* GetPsCap(uint32_t timeout_msec=0); + + AttestationStatus* ReportAttestationError(const PlatformInfo* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength,uint32_t timeout_msec=0) ; + + friend AEServices* AEServicesProvider::GetServicesProvider(); + friend AEInternalServices* AEInternalServicesProvider::GetInternalServicesProvider(); + + protected: + AEServicesImpl(const char* socketbase); + static bool mBoundToService; + ITransporter* mTransporter; //the internal interface to the AESM + + private: + AEServicesImpl& operator=(const AEServicesImpl&); + AEServicesImpl(const AEServicesImpl&); +}; + +#endif diff --git a/psw/uae_service/uae_wrapper/inc/AEServicesProvider.h b/psw/uae_service/uae_wrapper/inc/AEServicesProvider.h new file mode 100644 index 0000000000..2a6cc1109a --- /dev/null +++ b/psw/uae_service/uae_wrapper/inc/AEServicesProvider.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AE_SERVICES_PROVIDER_H +#define _AE_SERVICES_PROVIDER_H + + +class AEServices; + +class AEServicesProvider +{ + public: + static AEServices* GetServicesProvider(); + static void FreeServiceProvider(); + + protected: + AEServicesProvider(); + + static AEServices* mProviderInstance; +}; + +#endif diff --git a/psw/uae_service/uae_wrapper/src/AEInternalServicesProvider.cpp b/psw/uae_service/uae_wrapper/src/AEInternalServicesProvider.cpp new file mode 100644 index 0000000000..3914a1d950 --- /dev/null +++ b/psw/uae_service/uae_wrapper/src/AEInternalServicesProvider.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + + +#include + +#ifndef CONFIG_SOCKET_PATH +#error "CONFIG_SOCKET_PATH is not defined" +#endif + +#include + +AEInternalServices* AEInternalServicesProvider::mProviderInstance = NULL; + +AEInternalServicesProvider::AEInternalServicesProvider() { /* empty */ } + +AEInternalServices* AEInternalServicesProvider::GetInternalServicesProvider() +{ + if (mProviderInstance) + return mProviderInstance; + + const char *socketbase = CONFIG_SOCKET_PATH; + + mProviderInstance = new AEServicesImpl(socketbase); + + return mProviderInstance; +} diff --git a/psw/uae_service/uae_wrapper/src/AEServicesImpl.cpp b/psw/uae_service/uae_wrapper/src/AEServicesImpl.cpp new file mode 100644 index 0000000000..4fa0e378b1 --- /dev/null +++ b/psw/uae_service/uae_wrapper/src/AEServicesImpl.cpp @@ -0,0 +1,397 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +AEServicesImpl::AEServicesImpl(const char* socketbase) : + mTransporter(NULL) +{ + ProtobufSerializer * serializer = new ProtobufSerializer(); + NonBlockingUnixSocketFactory *socketFactory = new NonBlockingUnixSocketFactory(socketbase); + mTransporter = new SocketTransporter(socketFactory, serializer); +} + +AEServicesImpl::~AEServicesImpl() +{ + delete mTransporter; +} + +QuoteInfo* AEServicesImpl::GetQuote(const Report* report, const uint32_t quoteType, const SPID* spid, const Nonce* nonce, + const SignatureRevocationList* sig_rl, const uint32_t bufSize, const bool qe_report, + uint32_t timeout_msec) +{ + AEGetQuoteRequest* getQuoteRequest = new AEGetQuoteRequest(report->length, report->data, + quoteType, + spid->length, spid->data, + nonce->length, nonce->data, + sig_rl->length, sig_rl->data, + bufSize, + qe_report, + timeout_msec); + + if(getQuoteRequest->check() == false) + { + delete getQuoteRequest; + QuoteInfo* quoteInfo = new QuoteInfo; + quoteInfo->uaeStatus = UAE_OAL_ERROR_UNEXPECTED; + return quoteInfo; + } + + AEGetQuoteResponse* getQuoteResponse = new AEGetQuoteResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(getQuoteRequest, getQuoteResponse); + + //public exposed quote container + QuoteInfo* quoteInfo = new QuoteInfo; + quoteInfo->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && getQuoteResponse->check() == true) + { + Quote* quote = new Quote; + Report* qeReport = NULL; + + quote->length = getQuoteResponse->GetQuoteLength(); + quote->data = new uint8_t[quote->length]; + memcpy(quote->data, getQuoteResponse->GetQuote(), getQuoteResponse->GetQuoteLength()); + if (getQuoteResponse->GetQEReport() != NULL) //If we have also a report + { + qeReport = new Report; + qeReport->data = new uint8_t[getQuoteResponse->GetQEReportLength()]; + qeReport->length = getQuoteResponse->GetQEReportLength(); + memcpy(qeReport->data, getQuoteResponse->GetQEReport(), qeReport->length); + } + + quoteInfo->quote = quote; + quoteInfo->qeReport = qeReport; + } + + quoteInfo->errorCode = getQuoteResponse->GetErrorCode(); + + delete getQuoteRequest; + delete getQuoteResponse; + + return quoteInfo; +} + +AttestationInformation* AEServicesImpl::InitQuote(uint32_t timeout_msec) +{ + AEInitQuoteResponse* initQuoteResponse = new AEInitQuoteResponse(); /* empty response */ + AEInitQuoteRequest* initQuoteRequest = new AEInitQuoteRequest(timeout_msec); + + uae_oal_status_t ipc_status = mTransporter->transact(initQuoteRequest, initQuoteResponse); + + AttestationInformation* info = new AttestationInformation; + info->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && initQuoteResponse->check() == true) { + /* populate the public exposed data structure */ + + TargetInfo* tInfo = new TargetInfo; + PlatformGID* pGID = new PlatformGID; + + tInfo->length = initQuoteResponse->GetTargetInfoLength(); + pGID->length = initQuoteResponse->GetGIDLength(); + + tInfo->data = new uint8_t[tInfo->length]; + pGID->data = new uint8_t[pGID->length]; + + memcpy(tInfo->data, initQuoteResponse->GetTargetInfo(), tInfo->length); + memcpy(pGID->data, initQuoteResponse->GetGID(), pGID->length); + + info->quotingTarget = tInfo; + info->platformGID = pGID; + } + info->errorCode = initQuoteResponse->GetErrorCode(); + + delete initQuoteRequest; + delete initQuoteResponse; + + return info; +} + +LaunchToken* AEServicesImpl::GetLaunchToken(EnclaveMeasurement* mr_enclave, Signature* mr_signer, SEAttributes* se_attributes, uint32_t timeout_msec) +{ + AEGetLaunchTokenRequest* getLaunchTokenRequest = new AEGetLaunchTokenRequest(mr_enclave->length, + mr_enclave->data, + mr_signer->length, + mr_signer->data, + se_attributes->length, + se_attributes->data, + timeout_msec); + if(getLaunchTokenRequest->check() == false) + { + delete getLaunchTokenRequest; + LaunchToken* token = new LaunchToken; + token->uaeStatus = UAE_OAL_ERROR_UNEXPECTED; + return token; + } + + AEGetLaunchTokenResponse* getLaunchTokenResponse = new AEGetLaunchTokenResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(getLaunchTokenRequest, getLaunchTokenResponse); + + LaunchToken* token = new LaunchToken; + token->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && getLaunchTokenResponse->check() == true ) + { + token->length = getLaunchTokenResponse->GetTokenLength(); + token->data = new uint8_t[token->length]; + + memcpy(token->data, getLaunchTokenResponse->GetToken(), token->length); + } + + token->errorCode = getLaunchTokenResponse->GetErrorCode(); + + delete getLaunchTokenRequest; + delete getLaunchTokenResponse; + + return token; +} + +CreateSessionInformation* AEServicesImpl::CreateSession(uint32_t dhMsg1Size, uint32_t timeout) +{ + AECreateSessionRequest* createSessionRequest = new AECreateSessionRequest(dhMsg1Size, timeout); + AECreateSessionResponse* createSessionResponse = new AECreateSessionResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(createSessionRequest, createSessionResponse); + + CreateSessionInformation* info = new CreateSessionInformation(); + info->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && createSessionResponse->check() == true) + { + info->sessionId = createSessionResponse->GetSessionId(); + info->dh_msg1 = new PlainData; + + info->dh_msg1->length = createSessionResponse->GetDHMsg1Length(); + info->dh_msg1->data = new uint8_t[createSessionResponse->GetDHMsg1Length()]; + + memcpy(info->dh_msg1->data, createSessionResponse->GetDHMsg1(), info->dh_msg1->length); + } + + info->errorCode = createSessionResponse->GetErrorCode(); + + delete createSessionRequest; + delete createSessionResponse; + + return info; +} + +PSEMessage* AEServicesImpl::InvokeService(PSEMessage* targetServiceMessage, uint32_t pseResponseSize,uint32_t timeout) +{ + AEInvokeServiceRequest* invokeServiceRequest = new AEInvokeServiceRequest(targetServiceMessage->length, + targetServiceMessage->data, + pseResponseSize, + timeout); + if(invokeServiceRequest->check() == false) + { + delete invokeServiceRequest; + PSEMessage* msg = new PSEMessage; + msg->uaeStatus = UAE_OAL_ERROR_UNEXPECTED; + return msg; + } + + + AEInvokeServiceResponse* invokeServiceResponse = new AEInvokeServiceResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(invokeServiceRequest, invokeServiceResponse); + + PSEMessage* msg = new PSEMessage; + msg->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && invokeServiceResponse->check()) + { + msg->length = invokeServiceResponse->GetPSEMessageLength(); + if (msg->length > 0) + { + msg->data = new uint8_t[msg->length]; + memcpy(msg->data, invokeServiceResponse->GetPSEMessage(), msg->length); + } + } + + msg->errorCode = invokeServiceResponse->GetErrorCode(); + + delete invokeServiceRequest; + delete invokeServiceResponse; + + return msg; +} + +PlainData* AEServicesImpl::ExchangeReport(uint32_t sessionId, PlainData* dhMsg, uint32_t pseResponseSize, uint32_t timeout) +{ + AEExchangeReportRequest* exchangeReportRequest = new AEExchangeReportRequest(sessionId, dhMsg->length, dhMsg->data, + pseResponseSize, timeout); + + if(exchangeReportRequest->check() == false) + { + delete exchangeReportRequest; + PlainData* dhMsg3 = new PlainData; + dhMsg3->uaeStatus = UAE_OAL_ERROR_UNEXPECTED; + return dhMsg3; + } + + AEExchangeReportResponse* exchangeReportResponse = new AEExchangeReportResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(exchangeReportRequest, exchangeReportResponse); + + PlainData* dhMsg3 = new PlainData; + dhMsg3->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && exchangeReportResponse->check()) + { + dhMsg3->length = exchangeReportResponse->GetDHMsg3Length(); + + if (dhMsg3->length > 0) + { + dhMsg3->data = new uint8_t[dhMsg3->length]; + memcpy(dhMsg3->data, exchangeReportResponse->GetDHMsg3(), dhMsg3->length); + } + } + + dhMsg3->errorCode = exchangeReportResponse->GetErrorCode(); + + delete exchangeReportRequest; + delete exchangeReportResponse; + + return dhMsg3; +} + +PlainData* AEServicesImpl::CloseSession(uint32_t sessionId, uint32_t timeout) +{ + AECloseSessionRequest* closeSessionRequest = new AECloseSessionRequest(sessionId, timeout); + AECloseSessionResponse* closeSessionResponse = new AECloseSessionResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(closeSessionRequest, closeSessionResponse); + + PlainData* res = new PlainData; + + res->errorCode = closeSessionResponse->GetErrorCode(); + res->uaeStatus = ipc_status; + + delete closeSessionRequest; + delete closeSessionResponse; + + return res; +} + +PsCap* AEServicesImpl::GetPsCap(uint32_t timeout_msec) +{ + AEGetPsCapRequest* getPsCapRequest = new AEGetPsCapRequest(timeout_msec); + AEGetPsCapResponse* getPsCapResponse = new AEGetPsCapResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(getPsCapRequest, getPsCapResponse); + + PsCap* ps_cap = new PsCap(); + ps_cap->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && getPsCapResponse->check() == true) + ps_cap->ps_cap= getPsCapResponse->GetPsCap(); + + ps_cap->errorCode = getPsCapResponse->GetErrorCode(); + + delete getPsCapRequest; + delete getPsCapResponse; + + return ps_cap; +} + + +AttestationStatus* AEServicesImpl::ReportAttestationError(const PlatformInfo* platformInfo, uint32_t attestation_error_code, uint32_t updateInfoLength, uint32_t timeout_msec) +{ + AEReportAttestationRequest* reportAttestationErrorRequest = new AEReportAttestationRequest(platformInfo->length, + platformInfo->data, + attestation_error_code, updateInfoLength, timeout_msec); + if(reportAttestationErrorRequest->check() == false) + { + delete reportAttestationErrorRequest; + AttestationStatus* attestationStatus = new AttestationStatus; + attestationStatus->uaeStatus = UAE_OAL_ERROR_UNEXPECTED; + return attestationStatus; + } + AEReportAttestationResponse* reportAttestationErrorResponse = new AEReportAttestationResponse(); + + uae_oal_status_t ipc_status = mTransporter->transact(reportAttestationErrorRequest, reportAttestationErrorResponse); + + AttestationStatus* attestationStatus = new AttestationStatus; + attestationStatus->uaeStatus = ipc_status; + + if (ipc_status == UAE_OAL_SUCCESS && reportAttestationErrorResponse->check()) + { + UpdateInfo* tInfo = new UpdateInfo; + tInfo->length = reportAttestationErrorResponse->GetUpdateInfoLength(); + + tInfo->data = new uint8_t[tInfo->length]; + memcpy(tInfo->data, reportAttestationErrorResponse->GetUpdateInfo(), tInfo->length); + attestationStatus->updateInfo = tInfo; + } + + attestationStatus->errorCode = reportAttestationErrorResponse->GetErrorCode(); + + delete reportAttestationErrorRequest; + delete reportAttestationErrorResponse; + + return attestationStatus; + +} diff --git a/psw/uae_service/uae_wrapper/src/AEServicesProvider.cpp b/psw/uae_service/uae_wrapper/src/AEServicesProvider.cpp new file mode 100644 index 0000000000..bf3142ab42 --- /dev/null +++ b/psw/uae_service/uae_wrapper/src/AEServicesProvider.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + + +#include + +#ifndef CONFIG_SOCKET_PATH +#error "CONFIG_SOCKET_PATH is not defined" +#endif + +#include + +AEServices* AEServicesProvider::mProviderInstance = NULL; + +AEServicesProvider::AEServicesProvider() { } + +AEServices* AEServicesProvider::GetServicesProvider() +{ + if (mProviderInstance) + return mProviderInstance; + + const char *socketbase = CONFIG_SOCKET_PATH; + + mProviderInstance = new AEServicesImpl(socketbase); + + return mProviderInstance; +} + +void AEServicesProvider::FreeServiceProvider() +{ + if(mProviderInstance != NULL) + { + delete mProviderInstance; + mProviderInstance = NULL; + } +} diff --git a/psw/uae_service/uae_wrapper/src/tae_ocall_api.cpp b/psw/uae_service/uae_wrapper/src/tae_ocall_api.cpp new file mode 100644 index 0000000000..c7bfe7e2f8 --- /dev/null +++ b/psw/uae_service/uae_wrapper/src/tae_ocall_api.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +extern "C" +{ + + +uae_oal_status_t oal_create_session( + uint32_t *sid, + uint8_t* dh_msg1, + uint32_t dh_msg1_size, + uint32_t timeout_usec, + aesm_error_t *result) +{ + //get services provider + AEInternalServices* internalServices = AEInternalServicesProvider::GetInternalServicesProvider(); + if (internalServices == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + CreateSessionInformation* info = internalServices->CreateSession(dh_msg1_size, timeout_usec); + + uae_oal_status_t retVal = UAE_OAL_ERROR_UNEXPECTED; + if (info != NULL) + { + *result = (aesm_error_t)info->errorCode; + retVal = info->uaeStatus; + + if (info->dh_msg1 != NULL) + { + *sid = info->sessionId; + if (info->dh_msg1 != NULL && info->dh_msg1->data != NULL) + { + if (dh_msg1_size < info->dh_msg1->length) + retVal = UAE_OAL_ERROR_UNEXPECTED; + else + memcpy(dh_msg1, info->dh_msg1->data, info->dh_msg1->length); + } + } + delete info; + } + return retVal; +} + +uae_oal_status_t oal_close_session(uint32_t sid, + uint32_t timeout_usec, + aesm_error_t *result) +{ + AEInternalServices* internalServices = AEInternalServicesProvider::GetInternalServicesProvider(); + if (internalServices == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + PlainData* info = internalServices->CloseSession(sid, timeout_usec); + + uae_oal_status_t retVal = UAE_OAL_ERROR_UNEXPECTED; + if (info != NULL) + { + *result = (aesm_error_t)info->errorCode; + retVal = info->uaeStatus; + } + + return retVal; +} + +uae_oal_status_t oal_exchange_report(uint32_t sid, + const uint8_t* dh_msg2, + uint32_t dh_msg2_size, + uint8_t* dh_msg3, + uint32_t dh_msg3_size, + uint32_t timeout_usec, + aesm_error_t *result) +{ + + AEInternalServices* internalServices = AEInternalServicesProvider::GetInternalServicesProvider(); + if (internalServices == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + PlainData* dhMsg2 = NULL; + PlainData* msg3 = NULL; + dhMsg2 = new PlainData; + + dhMsg2->length = dh_msg2_size; + dhMsg2->data = new uint8_t[dh_msg2_size]; + memcpy(dhMsg2->data, dh_msg2, dh_msg2_size); + + msg3 = internalServices->ExchangeReport(sid, dhMsg2, dh_msg3_size, timeout_usec); + + uae_oal_status_t retVal = UAE_OAL_ERROR_UNEXPECTED; + + if (msg3 != NULL) + { + *result = (aesm_error_t)msg3->errorCode; + retVal = msg3->uaeStatus; + + if (*result == AESM_SUCCESS) + { + if( msg3->data != NULL) + { + memcpy(dh_msg3, msg3->data, dh_msg3_size); + } + else + retVal = UAE_OAL_ERROR_UNEXPECTED; + } + } + + delete msg3; + delete dhMsg2; + + return retVal; +} + +uae_oal_status_t oal_invoke_service(const uint8_t* pse_message_req, + uint32_t pse_message_req_size, + uint8_t* pse_message_resp, + uint32_t pse_message_resp_size, + uint32_t timeout_usec, + aesm_error_t *result) +{ + AEInternalServices* internalServices = AEInternalServicesProvider::GetInternalServicesProvider(); + if (internalServices == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + PSEMessage* request = new PSEMessage; + + request->length = pse_message_req_size; + request->data = new uint8_t[pse_message_req_size]; + memcpy(request->data, pse_message_req, pse_message_req_size); + + PSEMessage* pse_resp = internalServices->InvokeService(request, pse_message_resp_size, timeout_usec); + + uae_oal_status_t retVal = UAE_OAL_ERROR_UNEXPECTED; + if (pse_resp != NULL) + { + *result = (aesm_error_t)pse_resp->errorCode; + retVal = pse_resp->uaeStatus; + + if (pse_resp->data != NULL) + memcpy(pse_message_resp, pse_resp->data, pse_message_resp_size); + } + + delete request; + delete pse_resp; + + return retVal; +} + +} //end of extern block + diff --git a/psw/uae_service/uae_wrapper/src/uae_api.cpp b/psw/uae_service/uae_wrapper/src/uae_api.cpp new file mode 100644 index 0000000000..fa7588c03d --- /dev/null +++ b/psw/uae_service/uae_wrapper/src/uae_api.cpp @@ -0,0 +1,286 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include +#include + +#include + +////////THE COMMON STUFF aka INTEGRATION with Linux API +#include +#include +#include +#include + +#include + +#include +#include + +/////////////////////////////////////////////////////// + +// NOTE -> uAE works internally with milliseconds and cannot obtain a better resolution for timeout because +// epoll_wait will get the timeout parameter in milliseconds + +extern "C" +uae_oal_status_t oal_get_launch_token(const enclave_css_t* signature, const sgx_attributes_t* attribute, sgx_launch_token_t* launchToken, uint32_t timeout_usec, aesm_error_t *result) +{ + AEInternalServices* servicesProvider = AEInternalServicesProvider::GetInternalServicesProvider(); + if (servicesProvider == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + EnclaveMeasurement* mrenclave = new EnclaveMeasurement; + SEAttributes* attr = new SEAttributes; + Signature* mrsigner = new Signature; + + mrenclave->data = new uint8_t[sizeof(sgx_measurement_t)]; + mrenclave->length = sizeof(sgx_measurement_t); + memcpy(mrenclave->data, &signature->body.enclave_hash, mrenclave->length); + + attr->data = new uint8_t[sizeof(sgx_attributes_t)]; + attr->length = sizeof(sgx_attributes_t); + memcpy(attr->data, attribute, attr->length); + + mrsigner->data = new uint8_t[sizeof(signature->key.modulus)]; + mrsigner->length = sizeof(signature->key.modulus); + memcpy(mrsigner->data, &signature->key.modulus, mrsigner->length); + + LaunchToken* token = servicesProvider->GetLaunchToken(mrenclave, mrsigner, attr, timeout_usec / 1000); + + uae_oal_status_t ret = UAE_OAL_ERROR_UNEXPECTED; + if (token != NULL) + { + *result = (aesm_error_t)token->errorCode; + ret = token->uaeStatus; + + if (*result == AESM_SUCCESS) + memcpy(launchToken, token->data, token->length); + } + + delete mrenclave; + delete mrsigner; + delete attr; + delete token; + + return ret; +} + +/* + QUOTING +*/ + +extern "C" +uae_oal_status_t SGXAPI oal_init_quote(sgx_target_info_t *p_target_info, sgx_epid_group_id_t *p_gid, uint32_t timeout_usec, aesm_error_t *result) +{ + AEServices *servicesProvider = AEServicesProvider::GetServicesProvider(); + if (servicesProvider == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + AttestationInformation* attestationInfo = servicesProvider->InitQuote(timeout_usec / 1000); + + uae_oal_status_t ret = UAE_OAL_ERROR_UNEXPECTED; + if (attestationInfo != NULL) + { + *result = (aesm_error_t)attestationInfo->errorCode; + ret = attestationInfo->uaeStatus; + + if (*result == AESM_SUCCESS) + { + if (p_target_info != NULL) + memcpy(p_target_info, attestationInfo->quotingTarget->data, attestationInfo->quotingTarget->length); + if (p_gid != NULL) + memcpy(p_gid, attestationInfo->platformGID->data, attestationInfo->platformGID->length); + } + delete attestationInfo; + } + return ret; +} + + extern "C" +uae_oal_status_t SGXAPI oal_get_quote( + const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + const sgx_spid_t *p_spid, + const sgx_quote_nonce_t *p_nonce, + const uint8_t *p_sig_rl, + uint32_t sig_rl_size, + sgx_report_t *p_qe_report, + sgx_quote_t *p_quote, + uint32_t quote_size, + uint32_t timeout_usec, + aesm_error_t *result) +{ + + if (quote_size > MAX_MEMORY_ALLOCATION) + { + *result = AESM_PARAMETER_ERROR; + return UAE_OAL_SUCCESS; + } + + AEServices *servicesProvider = AEServicesProvider::GetServicesProvider(); + if (servicesProvider == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + Report* l_report = new Report; + SPID* l_spid = new SPID; + Nonce* l_nonce = new Nonce; + SignatureRevocationList* l_sigRL = new SignatureRevocationList; + + l_report->length = sizeof(sgx_report_t); + l_report->data = new uint8_t[sizeof(sgx_report_t)]; + memcpy(l_report->data, p_report, l_report->length); + + l_spid->length = sizeof(sgx_spid_t); + l_spid->data = new uint8_t[sizeof(sgx_spid_t)]; + memcpy(l_spid->data, p_spid, l_spid->length); + + if (p_nonce != NULL) + { + l_nonce->length = sizeof(sgx_quote_nonce_t); + l_nonce->data = new uint8_t[sizeof(sgx_quote_nonce_t)]; + memcpy(l_nonce->data, p_nonce, l_nonce->length); + } + + if (p_sig_rl != NULL && sig_rl_size > 0) + { + l_sigRL->length = sig_rl_size; + l_sigRL->data = new uint8_t[sig_rl_size]; + memcpy(l_sigRL->data, p_sig_rl, l_sigRL->length); + } + + bool getQEReport = false; + if (p_qe_report != NULL) + getQEReport = true; + + QuoteInfo* quoteInfo = servicesProvider->GetQuote(l_report, quote_type, l_spid, l_nonce, l_sigRL, quote_size, getQEReport, timeout_usec / 1000); + + uae_oal_status_t ret = UAE_OAL_ERROR_UNEXPECTED; + + if (quoteInfo != NULL) + { + ret = quoteInfo->uaeStatus; + *result = (aesm_error_t)quoteInfo->errorCode; + + if (*result == AESM_SUCCESS) + { + Quote* quote = quoteInfo->quote; + if (quote->data != NULL) + memcpy(p_quote, quote->data, quote->length); + //do we have a qe_report? + Report* qeReport = quoteInfo->qeReport; + if (qeReport != NULL) + { + if (p_qe_report == NULL) + { + ret = UAE_OAL_ERROR_UNEXPECTED; + } + else + { + memcpy(p_qe_report, qeReport->data, qeReport->length); + } + } + } + + delete quoteInfo; + } + + //cleanup + delete l_report; + delete l_spid; + delete l_nonce; + delete l_sigRL; + + return ret; +} + + +extern "C" +uae_oal_status_t SGXAPI oal_get_ps_cap(uint64_t* ps_cap, uint32_t timeout_usec, aesm_error_t *result) +{ + AEServices* servicesProvider = AEServicesProvider::GetServicesProvider(); + if (servicesProvider == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + PsCap* cap = servicesProvider->GetPsCap(timeout_usec / 1000); + + uae_oal_status_t ret = UAE_OAL_ERROR_UNEXPECTED; + if (cap != NULL) + { + ret = cap->uaeStatus; + *result = (aesm_error_t)cap->errorCode; + + if (*result == AESM_SUCCESS) + { + *ps_cap = cap->ps_cap; + } + } + delete cap; + return ret; +} + +extern "C" +uae_oal_status_t SGXAPI oal_report_attestation_status( + const sgx_platform_info_t* platform_info, + int attestation_error_code, + sgx_update_info_bit_t* platform_update_info, + uint32_t timeout_usec, + aesm_error_t *result) +{ + AEServices* servicesProvider = AEServicesProvider::GetServicesProvider(); + if (servicesProvider == NULL) + return UAE_OAL_ERROR_UNEXPECTED; + + + PlatformInfo* platformInfo = new PlatformInfo; + + platformInfo->data = new uint8_t[sizeof(sgx_platform_info_t)]; + platformInfo->length = sizeof(sgx_platform_info_t); + memcpy(platformInfo->data, platform_info, platformInfo->length); + + AttestationStatus* attestationStatus = servicesProvider->ReportAttestationError(platformInfo, attestation_error_code,sizeof(sgx_update_info_bit_t), timeout_usec / 1000); + + uae_oal_status_t ret = UAE_OAL_ERROR_UNEXPECTED; + if (attestationStatus != NULL) + { + *result = (aesm_error_t)attestationStatus->errorCode; + ret = attestationStatus->uaeStatus; + + if (*result == AESM_SUCCESS) + memcpy(platform_update_info, attestationStatus->updateInfo->data, attestationStatus->updateInfo->length); + } + + delete attestationStatus; + delete platformInfo; + return ret; +} + diff --git a/psw/urts/cpu_features.cpp b/psw/urts/cpu_features.cpp new file mode 100644 index 0000000000..346a6f0c0e --- /dev/null +++ b/psw/urts/cpu_features.cpp @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "se_cpu_feature_defs.h" +#include "se_types.h" +#include "cpu_features.h" + +void get_cpu_features(uint64_t *__intel_cpu_feature_indicator) +{ + unsigned int cpuid0_eax, cpuid0_ebx, cpuid0_ecx, cpuid0_edx; + unsigned int cpuid1_eax, cpuid1_ebx, cpuid1_ecx, cpuid1_edx; + unsigned int cpuid7_eax, cpuid7_ebx, cpuid7_ecx, cpuid7_edx; + unsigned int ecpuid1_eax, ecpuid1_ebx, ecpuid1_ecx, ecpuid1_edx; + uint64_t cpu_feature_indicator = CPU_FEATURE_GENERIC_IA32; + + sgx_cpuid(0, &cpuid0_eax, &cpuid0_ebx, &cpuid0_ecx, &cpuid0_edx); + if(cpuid0_eax == 0 || + !(cpuid0_ebx == CPU_GENU_VAL && + cpuid0_edx == CPU_INEI_VAL && + cpuid0_ecx == CPU_NTEL_VAL)) + { + *__intel_cpu_feature_indicator = cpu_feature_indicator; + return; + } + + sgx_cpuid(1, &cpuid1_eax, &cpuid1_ebx, &cpuid1_ecx, &cpuid1_edx); + if (CPU_MODEL(cpuid1_eax) == CPU_ATOM1 || + CPU_MODEL(cpuid1_eax) == CPU_ATOM2 || + CPU_MODEL(cpuid1_eax) == CPU_ATOM3) { + cpu_feature_indicator |= CPU_FEATURE_FULL_INORDER; + } + + // Walk through supported features + if (CPU_HAS_FPU(cpuid1_edx)) { + cpu_feature_indicator |= CPU_FEATURE_FPU; + } + + if (CPU_HAS_CMOV(cpuid1_edx)) { + cpu_feature_indicator |= CPU_FEATURE_CMOV; + } + + if (CPU_HAS_MMX(cpuid1_edx)) { + cpu_feature_indicator |= CPU_FEATURE_MMX; + } + + if (CPU_HAS_FXSAVE(cpuid1_edx)) { + cpu_feature_indicator |= CPU_FEATURE_FXSAVE; + + if (CPU_HAS_SSE(cpuid1_edx)) { + cpu_feature_indicator |= CPU_FEATURE_SSE; + } + if (CPU_HAS_SSE2(cpuid1_edx)) { + cpu_feature_indicator |= CPU_FEATURE_SSE2; + } + if (CPU_HAS_SSE3(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_SSE3; + } + + if (CPU_HAS_SSSE3(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_SSSE3; + } + + if (CPU_HAS_MOVBE(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_MOVBE; + } + // + // Penryn is a P6 with SNI support. + // + if (CPU_HAS_SSE4_1(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_SSE4_1; + } + if (CPU_HAS_SSE4_2(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_SSE4_2; + } + + if (CPU_HAS_POPCNT(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_POPCNT; + } + if (CPU_HAS_PCLMULQDQ(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_PCLMULQDQ; + } + + if (CPU_HAS_AES(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_AES; + } + } + + // IvyBridge + if (CPU_HAS_RDRAND(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_RDRND; + } + + sgx_cpuidex(7, 0, &cpuid7_eax, &cpuid7_ebx, &cpuid7_ecx, &cpuid7_edx); + sgx_cpuid(0x80000001, &ecpuid1_eax, &ecpuid1_ebx, &ecpuid1_ecx, &ecpuid1_edx); + + // Haswell + // BMI checks for both ebx[3] and ebx[8] (VEX-encoded instructions) + if (CPU_HAS_BMI(cpuid7_ebx)) { + cpu_feature_indicator |= CPU_FEATURE_BMI; + } + if (CPU_HAS_LZCNT(ecpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_LZCNT; + } + if (CPU_HAS_PREFETCHW(ecpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_PREFETCHW; + } + if (CPU_HAS_HLE(cpuid7_ebx)) { + cpu_feature_indicator |= CPU_FEATURE_HLE; + } + if (CPU_HAS_RTM(cpuid7_ebx)) { + cpu_feature_indicator |= CPU_FEATURE_RTM; + } + if (CPU_HAS_RDSEED(cpuid7_ebx)) { + cpu_feature_indicator |= CPU_FEATURE_RDSEED; + } + if (CPU_HAS_ADCOX(cpuid7_ebx)) { + cpu_feature_indicator |= CPU_FEATURE_ADCOX; + } + + if (CPU_HAS_XSAVE(cpuid1_ecx)) + { + //don't get xcr0_features, tRTS will do it. + if (CPU_HAS_AVX(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_AVX; + } + + // IvyBridge + if (CPU_HAS_F16C(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_F16C; + } + + // Haswell + if (CPU_HAS_AVX2(cpuid7_ebx)) { + cpu_feature_indicator |= CPU_FEATURE_AVX2; + } + if (CPU_HAS_FMA(cpuid1_ecx)) { + cpu_feature_indicator |= CPU_FEATURE_FMA; + } + } + + + *__intel_cpu_feature_indicator = cpu_feature_indicator; +} diff --git a/psw/urts/cpu_features.h b/psw/urts/cpu_features.h new file mode 100644 index 0000000000..bcf51f2362 --- /dev/null +++ b/psw/urts/cpu_features.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _CPU_FEATURES_H_ +#define _CPU_FEATURES_H_ + +#include "cpuid.h" + +void get_cpu_features(uint64_t *__intel_cpu_feature_indicator); + +inline void sgx_cpuid(unsigned int in_eax, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) +{ + int cpu_info[4] = {0}; + __cpuid(cpu_info, in_eax); + *eax = cpu_info[0]; + *ebx = cpu_info[1]; + *ecx = cpu_info[2]; + *edx = cpu_info[3]; +} + +inline void sgx_cpuidex(unsigned int in_eax, unsigned int leaf, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) +{ + int cpu_info[4] = {0}; + __cpuidex(cpu_info, in_eax, leaf); + *eax = cpu_info[0]; + *ebx = cpu_info[1]; + *ecx = cpu_info[2]; + *edx = cpu_info[3]; +} + +#endif diff --git a/psw/urts/create_param.h b/psw/urts/create_param.h new file mode 100644 index 0000000000..e5e5d65002 --- /dev/null +++ b/psw/urts/create_param.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _CREATE_PARAM_H_ +#define _CREATE_PARAM_H_ + +#include "metadata.h" +typedef struct _create_param_t +{ + uint64_t enclave_size; + uint64_t stack_max_size; + uint64_t stack_limit_addr; + uint64_t stack_base_addr; + uint64_t heap_max_size; + uint64_t heap_offset; + uint64_t first_ssa_gpr; + uint64_t td_addr; + uint64_t tls_addr; + uint32_t tcs_max_num; + uint32_t tcs_policy; + uint32_t ssa_frame_size; +} create_param_t; + +#endif diff --git a/psw/urts/enclave.cpp b/psw/urts/enclave.cpp new file mode 100644 index 0000000000..7586b1e87f --- /dev/null +++ b/psw/urts/enclave.cpp @@ -0,0 +1,503 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "enclave.h" +#include "util.h" +#include "se_detect.h" +#include "enclave_creator.h" +#include "sgx_error.h" +#include "se_error_internal.h" +#include "debugger_support.h" +#include "se_memory.h" +#include + +using namespace std; + +int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread); +int do_ocall(const bridge_fn_t bridge, void *ms); + +CEnclave::CEnclave(CLoader &ldr) + : m_loader(ldr) + , m_enclave_id(0) + , m_start_addr(NULL) + , m_size(0) + , m_power_event_flag(0) + , m_ref(0) + , m_zombie(false) + , m_thread_pool(NULL) + , m_dbg_flag(false) + , m_destroyed(false) +{ + memset(&m_enclave_info, 0, sizeof(debug_enclave_info_t)); + se_init_rwlock(&m_rwlock); +} + + +sgx_status_t CEnclave::initialize(const se_file_t& file, const sgx_enclave_id_t enclave_id, void * const start_addr, const uint64_t enclave_size, const uint32_t tcs_policy) +{ + uint32_t name_len = file.name_len; + if (file.unicode) + name_len *= (uint32_t)sizeof(wchar_t); + + const int buf_len = name_len + 4; //+4, because we need copy the charactor of string end ('\0').; + + m_enclave_info.lpFileName = calloc(1, buf_len); + if (m_enclave_info.lpFileName == NULL) + return SGX_ERROR_OUT_OF_MEMORY; + + memcpy_s(m_enclave_info.lpFileName, name_len, file.name, name_len); + m_enclave_info.unicode = file.unicode?0:1; + m_enclave_info.file_name_size = name_len; + + m_enclave_info.struct_version = DEBUG_INFO_STRUCT_VERSION; + + + m_enclave_id = enclave_id; + m_start_addr = start_addr; + m_size = enclave_size; + + if(TCS_POLICY_BIND == tcs_policy) + { + m_thread_pool = new CThreadPoolBindMode(); + } + else if(TCS_POLICY_UNBIND == tcs_policy) + { + //we also set it as bind mode. + m_thread_pool = new CThreadPoolUnBindMode(); + } + else + { + SE_TRACE(SE_TRACE_WARNING, "BUG: unknown tcs policy\n"); + //Should NOT run here, because we have validate the metadata before. + free(m_enclave_info.lpFileName); + m_enclave_info.lpFileName = NULL; + return SGX_ERROR_INVALID_PARAMETER; + } + return SGX_SUCCESS; +} + +CEnclave::~CEnclave() +{ + if (m_thread_pool) + { + delete m_thread_pool; + m_thread_pool = NULL; + } + + destory_debug_info(&m_enclave_info); + se_fini_rwlock(&m_rwlock); +} + +void * CEnclave::get_symbol_address(const char * const symbol) +{ + return m_loader.get_symbol_address(symbol); +} + +sgx_enclave_id_t CEnclave::get_enclave_id() +{ + return m_enclave_id; +} + + +sgx_status_t CEnclave::error_trts2urts(unsigned int trts_error) +{ + if(trts_error == (unsigned int)SE_ERROR_READ_LOCK_FAIL) + { + return SGX_ERROR_ENCLAVE_LOST; + } + + //tRTS may directly return the external error code, so we don't need transfer it. + if(EXTERNAL_ERROR != (trts_error >> MAIN_MOD_SHIFT)) + { + SE_TRACE(SE_TRACE_WARNING, "trts return error %x, it should be urts/trts bug\n", trts_error); + return SGX_ERROR_UNEXPECTED; + } + + return (sgx_status_t)trts_error; +} + +sgx_status_t CEnclave::ecall(const int proc, const void *ocall_table, void *ms) +{ + if(se_try_rdlock(&m_rwlock)) + { + //Maybe the enclave has been destroyed after acquire/release m_rwlock. See CEnclave::destroy() + if(m_destroyed) + { + se_rdunlock(&m_rwlock); + return SGX_ERROR_ENCLAVE_LOST; + } + + //do sgx_ecall + CTrustThread *trust_thread = get_tcs(); + unsigned ret = SGX_ERROR_OUT_OF_TCS; + + { + if(NULL != trust_thread) { + ret = do_ecall(proc, ocall_table, ms, trust_thread); + } + } + { + put_tcs(trust_thread); + + //release the read/write lock, the only exception is enclave already be removed in ocall + if(AbnormalTermination() || ret != SE_ERROR_READ_LOCK_FAIL) + { + se_rdunlock(&m_rwlock); + } + } + return error_trts2urts(ret); + } else { + return SGX_ERROR_ENCLAVE_LOST; + } +} + +int CEnclave::ocall(const unsigned int proc, const sgx_ocall_table_t *ocall_table, void *ms) +{ + int error = SGX_ERROR_UNEXPECTED; + + //validate the proc is within ocall_table; + if(NULL == ocall_table + || proc >= ocall_table->count) + { + return SGX_ERROR_INVALID_FUNCTION; + } + + se_rdunlock(&m_rwlock); + bridge_fn_t bridge = reinterpret_cast(ocall_table->ocall[proc]); + error = do_ocall(bridge, ms); + + if (!se_try_rdlock(&m_rwlock)) + { + //Probablly the enclave has been destroyed, so we can't get the read lock. + error = SE_ERROR_READ_LOCK_FAIL; + } + //We have m_destroyed to determinate if the enclave has been destroyed. + else if(m_destroyed) + { + //Enclave has been destroyed, emulate that we fail to get read lock. + se_rdunlock(&m_rwlock); + error = SE_ERROR_READ_LOCK_FAIL; + } + return error; +} + +const debug_enclave_info_t* CEnclave::get_debug_info() +{ + return &m_enclave_info; +} + + +CTrustThread * CEnclave::get_tcs() +{ + CTrustThread *trust_thread = m_thread_pool->acquire_thread(); + + return trust_thread; +} + +void CEnclave::put_tcs(CTrustThread *trust_thread) +{ + if(NULL == trust_thread) + { + return; + } + + m_thread_pool->release_thread(trust_thread); +} + +void CEnclave::destroy() +{ + se_wtlock(&m_rwlock); + //send debug event to debugger when enclave is debug mode or release mode + debug_enclave_info_t *debug_info = const_cast(get_debug_info()); + generate_enclave_debug_event(URTS_EXCEPTION_PREREMOVEENCLAVE, debug_info); + + get_enclave_creator()->destroy_enclave(ENCLAVE_ID_IOCTL); + + m_destroyed = true; + //We are going to destory m_rwlock. At this point, maybe an ecall is in progress, and try to get m_rwlock. + //To prevent such ecall, we use m_destroyed to identify that the no ecall should going on. See CEnclave::ecall(...). + //For new ecall to the enclave, it will return with SGX_ERROR_INVALID_ENCLAVE_ID immediately. + se_wtunlock(&m_rwlock); + // We should not use loader to destroy encalve because loader has been removed after successful enclave loading + //m_loader.destroy_enclave(); +} + +void CEnclave::add_thread(tcs_t * const tcs) +{ + CTrustThread *trust_thread = m_thread_pool->add_thread(tcs, this); + insert_debug_tcs_info_head(&m_enclave_info, trust_thread->get_debug_info()); +} + +int CEnclave::set_extra_debug_info(secs_t& secs) +{ + void *g_peak_heap_used_addr = get_symbol_address("g_peak_heap_used"); + m_enclave_info.g_peak_heap_used_addr = g_peak_heap_used_addr; + m_enclave_info.start_addr = secs.base; + m_enclave_info.misc_select = secs.misc_select; + + if(g_peak_heap_used_addr == NULL) + { + SE_TRACE(SE_TRACE_DEBUG, "Symbol 'g_peak_heap_used' is not found\n"); + //This error should not break loader and debugger, so the upper layer function will ignore it. + return SGX_ERROR_INVALID_ENCLAVE; + } + return SGX_SUCCESS; +} + +void CEnclave::push_ocall_frame(ocall_frame_t* frame_point, CTrustThread *trust_thread) +{ + if(NULL == trust_thread) + { + return; + } + + trust_thread->push_ocall_frame(frame_point); +} + +void CEnclave::pop_ocall_frame(CTrustThread *trust_thread) +{ + if(NULL == trust_thread) + { + return; + } + + trust_thread->pop_ocall_frame(); +} + +CEnclavePool CEnclavePool::m_instance; +CEnclavePool::CEnclavePool() +{ + m_enclave_list = NULL; + se_mutex_init(&m_enclave_mutex); + SE_TRACE(SE_TRACE_NOTICE, "enter CEnclavePool constructor\n"); +} + +CEnclavePool *CEnclavePool::instance() +{ + return &m_instance; +} + +int CEnclavePool::add_enclave(CEnclave *enclave) +{ + int result = TRUE; + + se_mutex_lock(&m_enclave_mutex); + + if (m_enclave_list == NULL) { + m_enclave_list = new Node(enclave->get_enclave_id(), enclave); + } else { + Node* node = new Node(enclave->get_enclave_id(), enclave); + if (m_enclave_list->InsertNext(node) == false) { + delete node; + SE_TRACE(SE_TRACE_WARNING, "the encalve %llx has already been added\n", enclave->get_enclave_id()); + result = FALSE; + } + } + se_mutex_unlock(&m_enclave_mutex); + return result; +} + +CEnclave * CEnclavePool::get_enclave(const sgx_enclave_id_t enclave_id) +{ + se_mutex_lock(&m_enclave_mutex); + Node* it = m_enclave_list->Find(enclave_id); + if(it != NULL) + { + se_mutex_unlock(&m_enclave_mutex); + return it->value; + } + else + { + se_mutex_unlock(&m_enclave_mutex); + return NULL; + } +} + +CEnclave * CEnclavePool::ref_enclave(const sgx_enclave_id_t enclave_id) +{ + se_mutex_lock(&m_enclave_mutex); + Node* it = m_enclave_list->Find(enclave_id); + if(it != NULL) + { + it->value->atomic_inc_ref(); + se_mutex_unlock(&m_enclave_mutex); + return it->value; + } + else + { + se_mutex_unlock(&m_enclave_mutex); + return NULL; + } +} + +void CEnclavePool::unref_enclave(CEnclave *enclave) +{ + //We use enclave pool lock to protect data, the lock is big, but is more secure. + se_mutex_lock(&m_enclave_mutex); + //The ref is increased in ref_enclave; + uint32_t ref = enclave->atomic_dec_ref(); + + //If the enclave is in zombie state, the HW enclave must have been destroyed. + //And if the enclave is not referenced, the enclave instance will not be referenced any more, + //so we delete the instance. + //Another code path that delete enclave instance is in function "CEnclavePool::remove_enclave" + if(enclave->is_zombie() && !ref) + delete enclave; + + se_mutex_unlock(&m_enclave_mutex); +} + +se_handle_t CEnclavePool::get_event(const void * const tcs) +{ + se_handle_t hevent = NULL; + CEnclave *enclave = NULL; + + assert(tcs != NULL); + se_mutex_lock(&m_enclave_mutex); + + Node* it = m_enclave_list; + for(; it != NULL; it = it->next) + { + void *start = it->value->get_start_address(); + void *end = GET_PTR(void, start, it->value->get_size()); + + /* check start & end */ + if (tcs >= start && tcs < end) { + enclave = it->value; + break; + } + } + + if (NULL != enclave) + { + CTrustThreadPool *pool = enclave->get_thread_pool(); + if (pool != NULL) + { + CTrustThread *thread = pool->get_bound_thread((const tcs_t *)tcs); + if (thread != NULL) + hevent = thread->get_event(); + } + } + + se_mutex_unlock(&m_enclave_mutex); + return hevent; +} + +CEnclave* CEnclavePool::remove_enclave(const sgx_enclave_id_t enclave_id, sgx_status_t &status) +{ + status = SGX_SUCCESS; + se_mutex_lock(&m_enclave_mutex); + + CEnclave *enclave = get_enclave(enclave_id); + if(NULL == enclave) + { + status = SGX_ERROR_INVALID_ENCLAVE_ID; + SE_TRACE(SE_TRACE_WARNING, "remove an unkonwn enclave\n"); + se_mutex_unlock(&m_enclave_mutex); + return enclave; + } + + enclave->destroy(); + //the ref is not 0, maybe some thread is in sgx_ocall, so we can NOT delete enclave instance. + if(enclave->get_ref()) + { + enclave->mark_zombie(); + + /* When destroy the enclave, all threads that are waiting/about to wait + * on untrusted event need to be waked. Otherwise, they will be always + * pending on the untrusted events, and app need to manually kill the threads. + */ + CTrustThreadPool *pool = enclave->get_thread_pool(); + pool->wake_threads(); + + enclave = NULL; + } + Node* it = m_enclave_list->Remove(enclave_id); + if (it == m_enclave_list) + m_enclave_list = it->next; + delete it; + se_mutex_unlock(&m_enclave_mutex); + + return enclave; +} + +void CEnclavePool::notify_debugger() +{ + se_mutex_lock(&m_enclave_mutex); + if(m_enclave_list!= NULL) + { + Node* it = m_enclave_list; + for(; it != NULL; it = it->next) + { + //send debug event to debugger when enclave is debug mode or release mode + debug_enclave_info_t * debug_info = const_cast((it->value)->get_debug_info()); + generate_enclave_debug_event(URTS_EXCEPTION_PREREMOVEENCLAVE, debug_info); + } + } + se_mutex_unlock(&m_enclave_mutex); + +} + +bool CEnclave::update_trust_thread_debug_flag(void* tcs_address, uint8_t debug_flag) +{ + uint64_t debug_flag2 = (uint64_t)debug_flag; + debug_enclave_info_t *debug_info = NULL; + + debug_info = const_cast(get_debug_info()); + + pid_t pid = getpid(); + + if(debug_info->enclave_type == ET_DEBUG) + { + + if(!se_write_process_mem(pid, reinterpret_cast(tcs_address) + sizeof(uint64_t), &debug_flag2, sizeof(uint64_t), NULL)) + return FALSE; + + } + + return TRUE; +} + +bool CEnclave::update_debug_flag(uint8_t debug_flag) +{ + debug_tcs_info_t* tcs_list_entry = m_enclave_info.tcs_list; + + while(tcs_list_entry) + { + if(!update_trust_thread_debug_flag(tcs_list_entry->TCS_address, debug_flag)) + return FALSE; + + tcs_list_entry = tcs_list_entry->next_tcs_info; + } + + return TRUE; +} diff --git a/psw/urts/enclave.h b/psw/urts/enclave.h new file mode 100644 index 0000000000..c6957c0033 --- /dev/null +++ b/psw/urts/enclave.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ENCLAVE_H_ +#define _ENCLAVE_H_ + +#include "se_wrapper.h" +#include "tcs.h" +#include "create_param.h" +#include "sgx_eid.h" +#include "routine.h" +#include "loader.h" +#include "file.h" +#include "uncopyable.h" +#include "node.h" + +class CLoader; + +class CEnclave: private Uncopyable +{ +public: + explicit CEnclave(CLoader &ldr); + ~CEnclave(); + void* get_start_address(){ return m_start_addr;}; + void * get_symbol_address(const char * const symbol); + sgx_enclave_id_t get_enclave_id(); + CTrustThreadPool * get_thread_pool() { return m_thread_pool; } + uint64_t get_size() { return m_size; }; + sgx_status_t ecall(const int proc, const void *ocall_table, void *ms); + int ocall(const unsigned int proc, const sgx_ocall_table_t *ocall_table, void *ms); + void destroy(); + uint32_t atomic_inc_ref() { return se_atomic_inc(&m_ref); } + uint32_t atomic_dec_ref() { return se_atomic_dec(&m_ref); } + uint32_t get_ref() { return m_ref; } + void mark_zombie() { m_zombie = true; } + bool is_zombie() { return m_zombie; } + sgx_status_t initialize(const se_file_t& file, const sgx_enclave_id_t enclave_id, void * const start_addr, const uint64_t enclave_size, const uint32_t tcs_policy); + void add_thread(tcs_t * const tcs); + const debug_enclave_info_t* get_debug_info(); + void set_dbg_flag(bool dbg_flag) { m_dbg_flag = dbg_flag; } + bool get_dbg_flag() { return m_dbg_flag; } + int set_extra_debug_info(secs_t& secs); + //rdunlock is used in signal handler + void rdunlock() { se_rdunlock(&m_rwlock); } + void push_ocall_frame(ocall_frame_t* frame_point, CTrustThread *trust_thread); + void pop_ocall_frame(CTrustThread *trust_thread); + bool update_trust_thread_debug_flag(void*, uint8_t); + bool update_debug_flag(uint8_t); +private: + CTrustThread * get_tcs(); + void put_tcs(CTrustThread *trust_thread); + sgx_status_t error_trts2urts(unsigned int trts_error); + + CLoader &m_loader; + sgx_enclave_id_t m_enclave_id; + void *m_start_addr; + uint64_t m_size; + se_rwlock_t m_rwlock; + uint32_t m_power_event_flag; + uint32_t m_ref; + bool m_zombie; + CTrustThreadPool *m_thread_pool; + debug_enclave_info_t m_enclave_info; + bool m_dbg_flag; + bool m_destroyed; +}; + +class CEnclavePool: private Uncopyable +{ +public: + static CEnclavePool *instance(); + int add_enclave(CEnclave *enclave); + CEnclave * get_enclave(const sgx_enclave_id_t enclave_id); + CEnclave * ref_enclave(const sgx_enclave_id_t enclave_id); + void unref_enclave(CEnclave *enclave); + int get_symbol_ordinal(const sgx_enclave_id_t enclave_id, const char *symbol, int *ordinal); + CEnclave * remove_enclave(const sgx_enclave_id_t enclave_id, sgx_status_t &status); + se_handle_t get_event(const void * const); + void notify_debugger(); +private: + CEnclavePool(); + + Node *m_enclave_list; + se_mutex_t m_enclave_mutex; //sync for add/get/remove enclave. + static CEnclavePool m_instance; +}; + +#define AbnormalTermination() (FALSE) + +#endif diff --git a/psw/urts/enclave_creator_hw.h b/psw/urts/enclave_creator_hw.h new file mode 100644 index 0000000000..db176d976d --- /dev/null +++ b/psw/urts/enclave_creator_hw.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ENCLAVE_CREATOR_H_ +#define _ENCLAVE_CREATOR_H_ + +#include "enclave_creator.h" +#include "sgx_eid.h" +#include "se_types.h" +#include "se_thread.h" +#include "util.h" +#include "se_map.h" +#include "se_error_internal.h" +#include "se_lock.hpp" +#include "file.h" + +// hardware mode +class EnclaveCreatorHW : public EnclaveCreator +{ +public: + EnclaveCreatorHW(); + ~EnclaveCreatorHW(); + int create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae); + int add_enclave_page(sgx_enclave_id_t enclave_id, void *source, uint64_t offset, const sec_info_t &sinfo, uint32_t attr); + int init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, SGXLaunchToken *lc, le_prd_css_file_t *prd_css_file); + int destroy_enclave(sgx_enclave_id_t enclave_id); + int initialize(sgx_enclave_id_t enclave_id); + bool use_se_hw() const; + int get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t flag); + bool get_plat_cap(sgx_misc_attribute_t *se_attr); +private: + virtual bool open_se_device(); + virtual void close_se_device(); + int try_init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, token_t *launch); + int error_driver2urts(int driver_error); + se_file_handle_t m_hdevice; + Mutex m_dev_mutex; + bool m_sig_registered; + se_mutex_t m_sig_mutex; +}; + +#endif diff --git a/psw/urts/enclave_creator_hw_com.cpp b/psw/urts/enclave_creator_hw_com.cpp new file mode 100644 index 0000000000..51f22696df --- /dev/null +++ b/psw/urts/enclave_creator_hw_com.cpp @@ -0,0 +1,230 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#include "enclave.h" +#include "rts.h" +#include "routine.h" +#include "cpu_features.h" +#include "enclave_creator_hw.h" +#include "se_error_internal.h" +#include "prd_css_util.h" +#include "se_memcpy.h" + +bool EnclaveCreatorHW::use_se_hw() const +{ + return true; +} + +int EnclaveCreatorHW::initialize(sgx_enclave_id_t enclave_id) +{ + cpu_sdk_info_t info; + + CEnclave *enclave= CEnclavePool::instance()->get_enclave(enclave_id); + + if(enclave == NULL) + return SGX_ERROR_INVALID_ENCLAVE_ID; + + //Since CPUID instruction is NOT supported within enclave, we enumerate the cpu features here and send to tRTS. + info.cpu_features = 0; + get_cpu_features(&info.cpu_features); + info.version = SDK_VERSION_1_5; + + int status = enclave->ecall(ECMD_INIT_ENCLAVE, NULL, reinterpret_cast(&info)); + //free the tcs used by initialization; + enclave->get_thread_pool()->reset(); + + //Enclave initialization may fail caused by power transition. + //The upper layer code will re-create enclave based on SGX_ERROR_ENCLAVE_LOST. + if(SGX_SUCCESS == status || SGX_ERROR_ENCLAVE_LOST == status) + { + return status; + } + else + { + //For other error code, may be caused by tRTS bug, or caused by attacker, + //so we just return SGX_ERROR_UNEXPECTED. + SE_TRACE(SE_TRACE_WARNING, "initialize enclave failed\n"); + return SGX_ERROR_UNEXPECTED; + } +} + +int EnclaveCreatorHW::get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t debug_flag) +{ + sgx_attributes_t *required_attr = &metadata->attributes; + enclave_css_t *enclave_css = &metadata->enclave_css; + sgx_attributes_t *secs_attr = &sgx_misc_attr->secs_attr; + //fp, sse must be set. + uint64_t tmp = required_attr->xfrm & SGX_XFRM_LEGACY; + + if(SGX_XFRM_LEGACY != tmp) + { + SE_TRACE(SE_TRACE_WARNING, "fp/sse attributes is a must in attributes\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + + //step 1, set enclave properties + sgx_misc_attribute_t se_cap; + if(!get_plat_cap(&se_cap)) + return SGX_ERROR_NO_DEVICE; + + if(debug_flag) + { + //If enclave is signed as product enclave, but is launched as debug enclave, we need report specific error code. + if((enclave_css->body.attribute_mask.flags & SGX_FLAGS_DEBUG) + && !(enclave_css->body.attributes.flags & SGX_FLAGS_DEBUG) + ) + { + return SGX_ERROR_NDEBUG_ENCLAVE; + } + required_attr->flags |= SGX_FLAGS_DEBUG; + } + else + required_attr->flags &= (~SGX_FLAGS_DEBUG); + + secs_attr->flags = required_attr->flags & se_cap.secs_attr.flags; + secs_attr->xfrm = required_attr->xfrm & se_cap.secs_attr.xfrm; + + + + + //step 3, evaluate the encalve attributes in secs. + + //check the signature structure xfrm attribute restrictions. + if((enclave_css->body.attribute_mask.xfrm & secs_attr->xfrm) + != (enclave_css->body.attribute_mask.xfrm & enclave_css->body.attributes.xfrm)) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes.xfrm does NOT match signature attributes.xfrm\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + //Debug bit has been checked before. For other attributes, check the signature structure flags attribute restrictions. + if((enclave_css->body.attribute_mask.flags & secs_attr->flags) + != (enclave_css->body.attribute_mask.flags & enclave_css->body.attributes.flags)) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes.flag does NOT match signature attributes.flag\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + + // Check misc_select/misc_mask + // enclave_css->body.misc_select & enclave_css->body.misc_mask must be a subset of se_cap.misc_select + if(~(se_cap.misc_select) & (enclave_css->body.misc_select & enclave_css->body.misc_mask)) + return SGX_ERROR_INVALID_MISC; + + // try to use maximum ablity of cpu + sgx_misc_attr->misc_select = se_cap.misc_select & enclave_css->body.misc_select; + + if(lc != NULL) + { + // Read launch token from lc + sgx_launch_token_t token; + memset(&token, 0, sizeof(token)); + if(lc->get_launch_token(&token) != SGX_SUCCESS) + return SGX_ERROR_UNEXPECTED; + token_t *launch = (token_t *)token; + if(1 == launch->body.valid) + { + //debug launch enclave cannot launch production enclave + if( !(secs_attr->flags & SGX_FLAGS_DEBUG) + && (launch->attributes_le.flags & SGX_FLAGS_DEBUG) ) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes is non-debug, \n"); + return SE_ERROR_INVALID_LAUNCH_TOKEN; + } + //verify attributes in lictoken are the same as the enclave + if(memcmp(&launch->body.attributes, secs_attr, sizeof(sgx_attributes_t))) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes does NOT match launch token attributes\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + } + } + + return SGX_SUCCESS; +} + +int EnclaveCreatorHW::init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, SGXLaunchToken * lc, le_prd_css_file_t *prd_css_file) +{ + unsigned int ret = 0; + sgx_launch_token_t token; + memset(token, 0, sizeof(sgx_launch_token_t)); + + enclave_css_t css; + memcpy_s(&css, sizeof(enclave_css_t), enclave_css, sizeof(enclave_css_t)); + + for(int i = 0; i < 2; i++) + { + if(SGX_SUCCESS != (ret = lc->get_launch_token(&token))) + return ret; + + ret = try_init_enclave(enclave_id, &css, reinterpret_cast(token)); + + if(i > 0) + return ret; + if(true == is_le(lc, &css)) + { + // LE is loaded with the interface sgx_create_le. + // Read the input prd css file and use it to init again. + if(SGX_ERROR_INVALID_ATTRIBUTE == ret && prd_css_file != NULL) { + if((ret = read_prd_css(prd_css_file->prd_css_name, &css)) != SGX_SUCCESS) + { + return ret; + } + + prd_css_file->is_used = true; + continue; + } + + // LE is loaded with the normal interface, or LE is loaded with sgx_create_le but EINIT returns other error code + // No need to get launch token and retry, so just return error code. + return ret; + } + + //If current launch token does NOT match the platform, then update the launch token. + //If the hash of signer (public key) in signature does not match launch token, EINIT will return SE_INVALID_MEASUREMENT + else if(!lc->is_launch_updated() && (SE_ERROR_INVALID_LAUNCH_TOKEN == ret || SGX_ERROR_INVALID_CPUSVN == ret || SE_ERROR_INVALID_MEASUREMENT == ret || SE_ERROR_INVALID_ISVSVNLE == ret)) + { + if(SGX_SUCCESS != (ret = lc->update_launch_token(true))) + { + return ret; + } + else + { + continue; + } + } + else + break; + } + return ret; + +} + diff --git a/psw/urts/enclave_mutex.cpp b/psw/urts/enclave_mutex.cpp new file mode 100644 index 0000000000..966e3a553a --- /dev/null +++ b/psw/urts/enclave_mutex.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_defs.h" +#include "enclave.h" +#include "se_event.h" + +#include "internal/se_error_internal.h" + +/* wait on untrusted event */ +extern "C" int sgx_thread_wait_untrusted_event_ocall(const void *self) +{ + if (self == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + se_handle_t hevent = CEnclavePool::instance()->get_event(self); + if (hevent == NULL) + return SE_ERROR_MUTEX_GET_EVENT; + + if (SE_MUTEX_SUCCESS != se_event_wait(hevent)) + return SE_ERROR_MUTEX_WAIT_EVENT; + + return SGX_SUCCESS; +} + +/* set untrusted event */ +extern "C" int sgx_thread_set_untrusted_event_ocall(const void *waiter) +{ + if (waiter == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + se_handle_t hevent = CEnclavePool::instance()->get_event(waiter); + if (hevent == NULL) + return SE_ERROR_MUTEX_GET_EVENT; + + if (SE_MUTEX_SUCCESS != se_event_wake(hevent)) + return SE_ERROR_MUTEX_WAKE_EVENT; + + return SGX_SUCCESS; +} + +extern "C" int sgx_thread_set_multiple_untrusted_events_ocall(const void **waiters, size_t total) +{ + if (waiters == NULL || *waiters == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + for (unsigned int i = 0; i < total; i++) { + se_handle_t hevent = CEnclavePool::instance()->get_event(*waiters++); + + if (hevent == NULL) + return SE_ERROR_MUTEX_GET_EVENT; + + if (SE_MUTEX_SUCCESS != se_event_wake(hevent)) + return SE_ERROR_MUTEX_WAKE_EVENT; + } + + return SGX_SUCCESS; +} + +extern "C" int sgx_thread_setwait_untrusted_events_ocall(const void *waiter, const void *self) +{ + int ret = sgx_thread_set_untrusted_event_ocall(waiter); + if (ret != SGX_SUCCESS) return ret; + + return sgx_thread_wait_untrusted_event_ocall(self); +} diff --git a/psw/urts/file.h b/psw/urts/file.h new file mode 100644 index 0000000000..d9ed257208 --- /dev/null +++ b/psw/urts/file.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _FILE_H_ +#define _FILE_H_ + +typedef char* prd_css_path_t; + +typedef struct _se_file_t { + void* name; + uint32_t name_len; + bool unicode; +} se_file_t; + +typedef struct _le_prd_css_file_t +{ + prd_css_path_t prd_css_name; + bool is_used; +} le_prd_css_file_t; + +#endif //_FILE_H_ diff --git a/psw/urts/launch_checker.cpp b/psw/urts/launch_checker.cpp new file mode 100644 index 0000000000..36ae1c2fba --- /dev/null +++ b/psw/urts/launch_checker.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include + +#include "se_memcpy.h" +#include "se_error_internal.h" +#include "uae_service_internal.h" +#include "launch_checker.h" + + +static unsigned int chk_launch_token( + const enclave_css_t *css, + const sgx_attributes_t *secs_attr, + const sgx_launch_token_t *tok) +{ + const token_t *launch = reinterpret_cast(tok); + + // Is it a valid launch_token? 0 = Invalid, 1 = Valid. + if(!launch->body.valid) + { + // For Non-Architectural Enclaves: HWVERSION = 0 + // Anyway, EINIT will return SE_INVALID_LAUNCH_TOKEN if the Enclave + // is not signed by intel key. + if(0 == css->header.hw_version) + { + // If the licese token is invalid, only intel key signed + // enclave can be lauched. + return (unsigned int)SE_ERROR_INVALID_LAUNCH_TOKEN; + } + else + { + // Don't need launch token for intel key signed enclave. + return (unsigned int)SGX_SUCCESS; + } + } + + // The MRENCLAVE should match the one in SIGSTRUCT. We must check + // it here, becaue EINIT will return SE_INVALID_MEASUREMENT for + // this case. + if(memcmp(&launch->body.mr_enclave, &css->body.enclave_hash, sizeof(sgx_measurement_t))) + { + return (unsigned int)SE_ERROR_INVALID_LAUNCH_TOKEN; + } + + // The ATTRIBUTES should match the attributes in SECS. + + + + if(memcmp(&launch->body.attributes, secs_attr, sizeof(sgx_attributes_t))) + { + return (unsigned int)SE_ERROR_INVALID_LAUNCH_TOKEN; + } + + // Other checks are done in get_secs_attr later. + return SGX_SUCCESS; +} + +SGXLaunchToken::SGXLaunchToken( + const enclave_css_t *css, + const sgx_attributes_t *secs_attr, + const sgx_launch_token_t *launch) + :m_css(css), m_secs_attr(secs_attr), m_launch_updated(false) +{ + memcpy_s(m_launch, sizeof(m_launch), launch, sizeof(m_launch)); +} + +bool SGXLaunchToken::is_launch_updated() const +{ + return m_launch_updated; +} + +sgx_status_t SGXLaunchToken::get_launch_token(sgx_launch_token_t *tok) const +{ + if (memcpy_s(tok, sizeof(m_launch), &m_launch, sizeof(m_launch))) + return SGX_ERROR_UNEXPECTED; + return SGX_SUCCESS; +} + +sgx_status_t SGXLaunchToken::update_launch_token( + bool force_update_tok) +{ + sgx_status_t status = SGX_SUCCESS; + + if (force_update_tok || + SE_ERROR_INVALID_LAUNCH_TOKEN == chk_launch_token(m_css, m_secs_attr, &m_launch)) + { + status = ::get_launch_token(m_css, m_secs_attr, &m_launch); + + if (status == SGX_SUCCESS) + m_launch_updated = true; + else + return status; + } + + return status; +} + + diff --git a/psw/urts/launch_checker.h b/psw/urts/launch_checker.h new file mode 100644 index 0000000000..eb592ff4cf --- /dev/null +++ b/psw/urts/launch_checker.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef launch_checker_h__ +#define launch_checker_h__ + +#include "uncopyable.h" +#include "sgx_error.h" +#include "arch.h" +#include "sgx_urts.h" + +class SGXLaunchToken : private Uncopyable { +public: + SGXLaunchToken( + const enclave_css_t *css, + const sgx_attributes_t *secs_attr, + const sgx_launch_token_t *launch); + + sgx_status_t update_launch_token( + bool force_update_tok); + sgx_status_t get_launch_token(sgx_launch_token_t *tok) const; + bool is_launch_updated() const; + +private: + const enclave_css_t *m_css; + const sgx_attributes_t *m_secs_attr; + sgx_launch_token_t m_launch; + bool m_launch_updated; +}; + +#endif + +/* vim: set et ts=4 sw=4 cin: */ diff --git a/psw/urts/linux/Makefile b/psw/urts/linux/Makefile new file mode 100644 index 0000000000..9c9e81cd1b --- /dev/null +++ b/psw/urts/linux/Makefile @@ -0,0 +1,147 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +ifndef DEBUG +CXXFLAGS += -DDISABLE_TRACE +CFLAGS += -DDISABLE_TRACE +endif + +CXXFLAGS += -fPIC -Werror +CXXFLAGS += $(ADDED_INC) + +CFLAGS += -fPIC -Werror +CFLAGS += $(ADDED_INC) + +VTUNE_DIR = $(LINUX_EXTERNAL_DIR)/vtune/linux + +INC += -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc/internal/linux \ + -I$(LINUX_PSW_DIR)/urts/ \ + -I$(LINUX_PSW_DIR)/urts/linux \ + -I$(LINUX_PSW_DIR)/urts/parser \ + -I$(VTUNE_DIR)/include \ + -I$(VTUNE_DIR)/sdk/src/ittnotify + +LDFLAGS := -lwrapper +LDFLAGS += -Wl,-Bdynamic -lsgx_uae_service + +LDFLAGS += -L$(VTUNE_DIR)/sdk/src/ittnotify -littnotify -ldl + +DIR1 := $(LINUX_PSW_DIR)/urts/linux +DIR2 := $(LINUX_PSW_DIR)/urts +DIR3 := $(LINUX_PSW_DIR)/urts/parser +DIR4 := $(LINUX_PSW_DIR)/urts/parser/linux + +LIB += -L$(COMMON_DIR)/se_wrapper \ + -L$(BUILD_DIR) + +OBJ1 := loader.o \ + node.o \ + se_detect.o \ + enclave.o \ + tcs.o \ + enclave_mutex.o \ + routine.o \ + urts_xsave.o \ + se_ocalls.o \ + cpu_features.o \ + launch_checker.o \ + urts_version.o \ + enclave_creator_hw_com.o + +OBJ2 := urts.o \ + enclave_creator_hw.o \ + misc.o \ + sig_handler.o \ + debugger_support.o \ + get_thread_id.o \ + prd_css_util.o + +OBJ3 := enter_enclave.o + +OBJ4 := section.o \ + elfparser.o + +OBJ5 := urts_internal.o + +CPP_OBJ := $(OBJ1) $(OBJ2) $(OBJ4) $(OBJ5) +URTS_OBJ := $(OBJ3) $(OBJ1) $(OBJ2) $(OBJ4) +INTERNAL_OBJ := $(OBJ3) $(CPP_OBJ) + + +vpath %.cpp $(DIR1):$(DIR2):$(DIR3):$(DIR4) + +LIBWRAPPER := libwrapper.a +LIBURTS := libsgx_urts.so +LIBURTS_INTERNAL := liburts_internal.a + +.PHONY: all +all: $(LIBWRAPPER) uae_service ittnotify $(LIBURTS) $(LIBURTS_INTERNAL) | $(BUILD_DIR) + @$(CP) $(LIBURTS) $| + @$(CP) $(LIBURTS_INTERNAL) $| + +$(LIBURTS_INTERNAL): $(INTERNAL_OBJ) + $(CP) $(COMMON_DIR)/se_wrapper/libwrapper.a $@ + $(AR) rcs $@ $^ + +$(LIBURTS): $(URTS_OBJ) + $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$@ $(LIB) -o $@ $^ $(LDFLAGS) + +$(CPP_OBJ): %.o: %.cpp + $(CXX) -c $(CXXFLAGS) $(INC) $< -o $@ + +$(OBJ3): %.o: %.S + $(CC) -c $(CFLAGS) $(INC) $< -o $@ + +$(LIBWRAPPER): + $(MAKE) -C $(COMMON_DIR)/se_wrapper/ + +.PHONY:uae_service +uae_service: + $(MAKE) -C $(LINUX_PSW_DIR)/uae_service/linux + +.PHONY: ittnotify +ittnotify: + $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: clean +clean:: + @$(RM) *.o $(LIBURTS) $(LIBURTS_INTERNAL) + @$(RM) $(BUILD_DIR)/$(LIBURTS) $(BUILD_DIR)/$(LIBURTS_INTERNAL) + $(MAKE) -C $(COMMON_DIR)/se_wrapper/ clean + $(MAKE) -C $(LINUX_PSW_DIR)/uae_service/linux/ clean + $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify clean diff --git a/psw/urts/linux/debugger_support.cpp b/psw/urts/linux/debugger_support.cpp new file mode 100644 index 0000000000..3d91ea569d --- /dev/null +++ b/psw/urts/linux/debugger_support.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "debugger_support.h" +#include "se_trace.h" +#include "util.h" +#include "se_debugger_lib.h" + +#include "rts.h" +#include "thread_data.h" +#include "se_memory.h" +#include "enclave.h" +#include +#include +#include + +#define fastcall __attribute__((regparm(3))) + +extern "C" void fastcall sgx_debug_load_state_add_element(const debug_enclave_info_t *enclave_info, debug_enclave_info_t** g_debug_enclave_info_list); +extern "C" void fastcall sgx_debug_unload_state_remove_element(const debug_enclave_info_t *enclave_info, debug_enclave_info_t** pre_enclave_info, debug_enclave_info_t* next_enclave_info); + +static pthread_mutex_t g_debug_info_mutex = PTHREAD_MUTEX_INITIALIZER; +debug_enclave_info_t *g_debug_enclave_info_list = NULL; + +// There is no need to add lock here: +// This function only be called by CEnclave::add_thread and the enclave_info is a member +// of CEnclave instance. There is no race condition +void insert_debug_tcs_info_head(debug_enclave_info_t* enclave_info, debug_tcs_info_t* tcs_info) +{ + tcs_info->next_tcs_info = enclave_info->tcs_list; + enclave_info->tcs_list = tcs_info; +} + +static void insert_debug_info_head(debug_enclave_info_t *enclave_info) +{ + enclave_info->next_enclave_info = g_debug_enclave_info_list; + //g_debug_enclave_info_list = enclave_info; + //To avoid the race between attach event and load event, we set load event bp at where the list is changed + sgx_debug_load_state_add_element(enclave_info, &g_debug_enclave_info_list); +} + +static void remove_debug_info(debug_enclave_info_t *enclave_info) +{ + debug_enclave_info_t **pre_entry = &g_debug_enclave_info_list; + debug_enclave_info_t *cur = g_debug_enclave_info_list; + + while(cur) + { + if(cur == enclave_info) + { + //*pre_entry = cur->next_enclave_info; + //To avoid the race between attach event and unload event, we set unload event bp at where the list is changed + sgx_debug_unload_state_remove_element(enclave_info, pre_entry, cur->next_enclave_info); + break; + } + pre_entry = &cur->next_enclave_info; + cur = cur->next_enclave_info; + } +} + +void generate_enclave_debug_event(uint32_t code, const debug_enclave_info_t* enclave_info) +{ + if(URTS_EXCEPTION_POSTINITENCLAVE == code) + { + if(pthread_mutex_lock(&g_debug_info_mutex) != 0) + abort(); + insert_debug_info_head(const_cast(enclave_info)); + if(pthread_mutex_unlock(&g_debug_info_mutex) != 0) + abort(); + } + else if(URTS_EXCEPTION_PREREMOVEENCLAVE == code) + { + if(pthread_mutex_lock(&g_debug_info_mutex) != 0) + abort(); + remove_debug_info(const_cast(enclave_info)); + if(pthread_mutex_unlock(&g_debug_info_mutex) != 0) + abort(); + } +} + + +extern "C" void fastcall notify_gdb_to_update(void* base, tcs_t* tcs, uintptr_t of) +{ + UNUSED(base); + UNUSED(tcs); + UNUSED(of); +} + +extern "C" void push_ocall_frame(uintptr_t frame_point, tcs_t* tcs, CTrustThread *trust_thread) +{ + assert(trust_thread != NULL); + CEnclave* enclave = trust_thread->get_enclave(); + assert(enclave != NULL); + enclave->push_ocall_frame(container_of(frame_point, ocall_frame_t, xbp), trust_thread); + notify_gdb_to_update(enclave->get_start_address(), tcs, (uintptr_t)container_of(frame_point, ocall_frame_t, xbp)); +} + +extern "C" void pop_ocall_frame(tcs_t* tcs, CTrustThread *trust_thread) +{ + UNUSED(tcs); + assert(trust_thread != NULL); + CEnclave* enclave = trust_thread->get_enclave(); + assert(enclave != NULL); + enclave->pop_ocall_frame(trust_thread); +} diff --git a/psw/urts/linux/debugger_support.h b/psw/urts/linux/debugger_support.h new file mode 100644 index 0000000000..946012c75e --- /dev/null +++ b/psw/urts/linux/debugger_support.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _DEBUGGER_SUPPORT_H_ +#define _DEBUGGER_SUPPORT_H_ + +#include "se_debugger_lib.h" + + +void insert_debug_tcs_info_head(debug_enclave_info_t*, debug_tcs_info_t*); +void generate_enclave_debug_event(uint32_t code, const debug_enclave_info_t* enclave_info); + +#endif //_DEBUGGER_SUPPORT_H_ diff --git a/psw/urts/linux/enclave_creator_hw.cpp b/psw/urts/linux/enclave_creator_hw.cpp new file mode 100644 index 0000000000..10c80a94a2 --- /dev/null +++ b/psw/urts/linux/enclave_creator_hw.cpp @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "enclave_creator_hw.h" +#include "se_trace.h" +#include "se_page_attr.h" +#include "isgx_user.h" +#include "sig_handler.h" +#include "se_error_internal.h" +#include "se_memcpy.h" +#include "se_atomic.h" +#include "se_detect.h" +#include "cpuid.h" +#include +#include +#include +#include +#include +#include +#include +#include + + +EnclaveCreator* g_enclave_creator = new EnclaveCreatorHW(); +static uint32_t g_eid_low = 0x1; +static uint32_t g_eid_high = 0x0; + +EnclaveCreatorHW::EnclaveCreatorHW(): + m_hdevice(-1), + m_sig_registered(false) +{ + se_mutex_init(&m_sig_mutex); +} + +EnclaveCreatorHW::~EnclaveCreatorHW() +{ + close_se_device(); +} + +int EnclaveCreatorHW::error_driver2urts(int driver_error) +{ + int ret = SGX_ERROR_UNEXPECTED; + + switch(driver_error) + { + case ISGX_ERROR: + if(ENOMEM == errno) + ret = SGX_ERROR_OUT_OF_MEMORY; + else + ret = SGX_ERROR_NO_DEVICE; + break; + case ISGX_INVALID_ATTRIBUTE: + ret = SGX_ERROR_INVALID_ATTRIBUTE; + break; + case ISGX_INVALID_MEASUREMENT: + ret = SE_ERROR_INVALID_MEASUREMENT; + break; + case ISGX_INVALID_SIG_STRUCT: + case ISGX_INVALID_SIGNATIRE: + ret = SGX_ERROR_INVALID_SIGNATURE; + break; + case ISGX_INVALID_LAUNCH_TOKEN: + ret = SE_ERROR_INVALID_LAUNCH_TOKEN; + break; + case ISGX_INVALID_CPUSVN: + ret = SGX_ERROR_INVALID_CPUSVN; + break; + case ISGX_INVALID_ISVSVN: + ret = SGX_ERROR_INVALID_ISVSVN; + break; + case ISGX_UNMASKED_EVENT: + ret = SGX_ERROR_DEVICE_BUSY; + break; + case (int)ISGX_POWER_LOST_ENCLAVE: // [-Wc++11-narrowing] + ret = SGX_ERROR_ENCLAVE_LOST; + break; + default: + SE_TRACE(SE_TRACE_WARNING, "unexpected error %#x from driver, should be uRTS/driver bug\n", ret); + ret = SGX_ERROR_UNEXPECTED; + break; + } + + return ret; +} + +int EnclaveCreatorHW::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae) +{ + assert(secs != NULL && enclave_id != NULL && start_addr != NULL); + UNUSED(ae); + + if (false == open_se_device()) + return SGX_ERROR_NO_DEVICE; + + SE_TRACE(SE_TRACE_DEBUG, "\n secs.attibutes.flags = %llx, secs.attributes.xfrm = %llx \n" + , secs->attributes.flags, secs->attributes.xfrm); + + struct isgx_create_param param = { secs, 0 }; + int ret = ioctl(m_hdevice, ISGX_IOCTL_ENCLAVE_CREATE, ¶m); + if(ret) { + SE_TRACE(SE_TRACE_WARNING, "\nISGX_IOCTL_ENCLAVE_CREATE fails: errno = %x\n", errno); + return error_driver2urts(ret); + } + uint32_t tmp = se_atomic_inc(&g_eid_low); + //32bit overflow + if(0 == tmp) + g_eid_high++; + *enclave_id = ((uint64_t)g_eid_high << 32) | g_eid_low; + *start_addr = secs->base = (void *)param.addr; + + return SGX_SUCCESS; +} + +int EnclaveCreatorHW::add_enclave_page(sgx_enclave_id_t enclave_id, void *src, uint64_t rva, const sec_info_t &sinfo, uint32_t attr) +{ + assert((rva & ((1<(&color_page); + } + + int ret = 0; + struct isgx_add_param addp = { 0, 0, 0, 0 }; + + addp.addr = (unsigned long)enclave_id + (unsigned long)rva; + addp.user_addr = reinterpret_cast(source); + addp.secinfo = (void *)const_cast(&sinfo); + if(!((1<(enclave_css); + //launch should NOT be NULL, because it has been checked in urts_com.h::_create_enclave(...) + assert(launch != NULL); + + initp.einittoken = reinterpret_cast(launch); + ret = ioctl(m_hdevice, ISGX_IOCTL_ENCLAVE_INIT, &initp); + if (ret) { + SE_TRACE(SE_TRACE_WARNING, "\nISGX_IOCTL_ENCLAVE_INIT fails error = %x\n", ret); + return error_driver2urts(ret); + } + + //register signal handler + se_mutex_lock(&m_sig_mutex); + if(false == m_sig_registered) + { + reg_sig_handler(); + m_sig_registered = true; + } + se_mutex_unlock(&m_sig_mutex); + + return SGX_SUCCESS; +} + +int EnclaveCreatorHW::destroy_enclave(sgx_enclave_id_t enclave_id) +{ + int ret = 0; + + isgx_destroy_param param = { (unsigned long)enclave_id }; + ret = ioctl(m_hdevice, ISGX_IOCTL_ENCLAVE_DESTROY, ¶m); + + if (-1 == ret) { + SE_TRACE(SE_TRACE_WARNING, "destroy SGX enclave failed, error = %d\n", errno); + ret = SGX_ERROR_UNEXPECTED; + } + else + { + ret = SGX_SUCCESS; + } + + return ret; +} + +bool EnclaveCreatorHW::get_plat_cap(sgx_misc_attribute_t *misc_attr) +{ + return get_plat_cap_by_cpuid(misc_attr); +} + + + +bool EnclaveCreatorHW::open_se_device() +{ + LockGuard lock(&m_dev_mutex); + int fd = -1; + + if(-1 != m_hdevice) + { + return true; + } + + fd = open("/dev/isgx", O_RDWR); + if (-1 == fd) { + SE_TRACE(SE_TRACE_WARNING, "open isgx device failed\n"); + return false; + } + m_hdevice = fd; + + return true; +} + +void EnclaveCreatorHW::close_se_device() +{ + LockGuard lock(&m_dev_mutex); + + if (m_hdevice != -1) + { + close(m_hdevice); + m_hdevice = -1; + } +} diff --git a/psw/urts/linux/enter_enclave.S b/psw/urts/linux/enter_enclave.S new file mode 100644 index 0000000000..3fb35543bc --- /dev/null +++ b/psw/urts/linux/enter_enclave.S @@ -0,0 +1,284 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "enter_enclave.h" + + +/* int __morestack(const tcs_t *tcs, const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread); */ +.file "enter_enclave.S" +.text +DECLARE_GLOBAL_FUNC __morestack + +__morestack: +EENTER_PROLOG + movl frame_arg1, %edi /* fn */ +#if defined(__x86_64__) + /* we defined fn as int, so we do sign extend.*/ + movslq %edi, %rdi +#endif + mov frame_arg3, %xsi /* ms */ + +.Ldo_eenter: + mov frame_arg0, %xbx /* tcs addr */ + lea_pic .Lasync_exit_pointer, %xcx /* aep addr */ + mov $SE_EENTER, %xax /* EENTER leaf */ + +.Leenter_inst: + ENCLU + +/* + * at this point, we may have returned due to a normal EEXIT, + * or we may have returned due to an OCALL. We differentiate + * by popping the top of the stack. If it is not -1, we have + * an untrusted bridge to call at that address. + */ + +/* We have an ocall. Call our bridge function. */ + + cmp $OCMD_ERET, %xdi + je .Leret + +.Ldo_ocall: +/* call ocall + * int ocall(const unsigned int proc, void *ocall_table, const void *ms, CEnclave *enclave); + * + * When EEXIT'ed from tRTS due to an OCALL, + * - `rdi' holds OCALL index + *- `rsi' holds the pointer to marshalling structure + */ +.type sgx_ocall,@function +.hidden sgx_ocall +#if defined(__i386__) + sub $(3*SE_WORDSIZE), %xsp /* make stack 16 bytes aligned */ + push frame_arg0 + push frame_arg4 + push %esi + push frame_arg2 + push %edi +#endif + +#if defined(__x86_64__) + mov %rsi, %rdx /* param2 */ + /*mov %rdi, %rdi */ /* param0 */ + mov frame_arg2, %rsi /* param1 */ + mov frame_arg4, %rcx /* param3 */ + mov frame_arg0, %r8 /* param4 */ +#endif + + call stack_sticker + cmp $SE_ERROR_READ_LOCK_FAIL, %eax + je .Loret + mov $ECMD_ORET, %xdi /* oret */ + mov %xax, %xsi /* the result of ocall */ + jmp .Ldo_eenter + /* never return here */ + ud2 +.Leret: + mov %xsi, %xax +.Loret: + EENTER_EPILOG + +.Lasync_exit_pointer: + ENCLU + +.size __morestack, .-__morestack + + +DECLARE_GLOBAL_FUNC get_aep + lea_pic .Lasync_exit_pointer, %xax + ret + +DECLARE_GLOBAL_FUNC get_eenterp + lea_pic .Leenter_inst, %xax + ret + +DECLARE_GLOBAL_FUNC get_eretp + lea_pic .Leret, %xax + ret + +/* + * function stack_sticker is the wrapper of ocall, + * before call ocall, update the ret address and frame pointer (BP) on the stack + * + * Stack before: + * |__morestack stack |<--| + * ------------- | + * |return adress | | + * xbp -> | caller xbp | --| + * | | + * xsp -> | | + * ------------- + * + * Stack after: + * |__morestack stack | + * ------------------ + * | __morestack(inside)| + * xbp -> | xbp_t | ---->the frame point of __morestack + * | | + * xsp -> | | + * | | + * ------------------ + * int stack_sticker(unsigned int proc, sgx_ocall_table_t *ocall_table, void *ms, CTrustThread *trust_thread, tcs_t *tcs) + */ +DECLARE_GLOBAL_FUNC stack_sticker +.hidden stack_sticker +.type push_ocall_frame,@function +.hidden push_ocall_frame +.type pop_ocall_frame,@function +.hidden pop_ocall_frame +.cfi_startproc + push %xbp +.cfi_def_cfa_offset 2*SE_WORDSIZE +.cfi_offset xbp,-2*SE_WORDSIZE + mov %xsp, %xbp +.cfi_def_cfa_register xbp +#if defined(__i386__) + sub $(10*SE_WORDSIZE), %xsp /* We should have the stack 16 bytes aligned */ +#elif defined(__x86_64__) + sub $(10*SE_WORDSIZE), %xsp +#endif + + /* save the return address and the frame point */ + mov (0*SE_WORDSIZE)(%xbp), %xax + mov %xax, (4*SE_WORDSIZE)(%xsp) + mov (1*SE_WORDSIZE)(%xbp), %xax + mov %xax, (5*SE_WORDSIZE)(%xsp) + +#if defined(__i386__) + /* save the first 4 parameters */ + mov frame_arg0, %xax + mov %xax, (0*SE_WORDSIZE)(%xsp) + mov frame_arg1, %xax + mov %xax, (1*SE_WORDSIZE)(%xsp) + mov frame_arg2, %xax + mov %xax, (2*SE_WORDSIZE)(%xsp) + mov frame_arg3, %xax + mov %xax, (3*SE_WORDSIZE)(%xsp) + + /* update the frame infomation */ + mov frame_arg3, %xax /* the pointer of trustthread instance */ + push %xax + mov frame_arg4, %xax /* tcs */ + push %xax + push %xbp + /*just for call push_ocall_frame and return, no stack 16 bytes alignment needed */ + call push_ocall_frame + + /* recover parameters */ + add $(3*SE_WORDSIZE), %xsp +#elif defined(__x86_64__) + /* save the first 4 parameters */ + mov %xdi, (0*SE_WORDSIZE)(%xsp) + mov %xsi, (1*SE_WORDSIZE)(%xsp) + mov %xdx, (2*SE_WORDSIZE)(%xsp) + mov %xcx, (3*SE_WORDSIZE)(%xsp) + + /* update the frame infomation */ + mov %xcx, %xdx /* the pointer of trustthread instance */ + mov %r8, %xsi /* tcs */ + mov %xbp, %xdi + call push_ocall_frame + + /* recover parameters */ + mov (0*SE_WORDSIZE)(%xsp), %xdi + mov (1*SE_WORDSIZE)(%xsp), %xsi + mov (2*SE_WORDSIZE)(%xsp), %xdx + mov (3*SE_WORDSIZE)(%xsp), %xcx +#endif + + /* start the ocall */ + call sgx_ocall + + /* save the return value */ + mov %xax, (0*SE_WORDSIZE)(%xsp) + +#if defined(__i386__) + /* pop the frame infomation */ + mov frame_arg3, %xax /* the pointer of trustthread instance */ + push %xax + mov frame_arg4, %xax /* tcs is not used for now */ + push %xax + call pop_ocall_frame + + /* recover parameters */ + add $(2*SE_WORDSIZE), %xsp + +#elif defined(__x86_64__) + /* pop the frame infomation */ + mov (3*SE_WORDSIZE)(%xsp), %xsi /* the pointer of trustthread instance */ + call pop_ocall_frame +#endif + + /* recover the return address and frame point */ + mov (4*SE_WORDSIZE)(%xsp), %xax + mov %xax, (0*SE_WORDSIZE)(%xbp) + mov (5*SE_WORDSIZE)(%xsp), %xax + mov %xax, (1*SE_WORDSIZE)(%xbp) + + /* recover the return value */ + mov (0*SE_WORDSIZE)(%xsp), %xax + + leave + ret + .cfi_endproc + +/* + * void sgx_debug_load_state_add_element(debug_enclave_info_t* new_enclave_info, debug_enclave_info_t** g_debug_enclave_info_list) + * On x86, calling convention is "void sgx_debug_load_state_add_element(eax, edx)" + * On x64, calling convention is "void sgx_debug_load_state_add_element(rdi, rsi)" + * Add an new enclave info to list head and raise enclave load event + */ +DECLARE_GLOBAL_FUNC sgx_debug_load_state_add_element +#if defined(__i386__) + movl %eax, (%edx) +#else + movq %rdi, (%rsi) +#endif + ret + +/* + * void sgx_debug_unload_state_remove_element(debug_enclave_info_t* enclave_info, debug_enclave_info_t** pre_enclave_info, debug_enclave_info_t* next_enclave_info) + * On x86, calling convention is "void se_debug_load_state_remove_element(eax, edx, ecx)" + * On x64, calling convention is "void se_debug_load_state_remove_element(rdi, rsi, rdx)" + * eax is to pass the removed enclave info to debugger. + * Remove an enclave info from list and raise enclave unload event + */ +DECLARE_GLOBAL_FUNC sgx_debug_unload_state_remove_element +#if defined(__i386__) + movl %ecx, (%edx) +#else + movq %rdx, (%rsi) +#endif + ret + +/* We do not need executable stack.*/ +.section .note.GNU-stack,"",@progbits diff --git a/psw/urts/linux/enter_enclave.h b/psw/urts/linux/enter_enclave.h new file mode 100644 index 0000000000..fdd31b997f --- /dev/null +++ b/psw/urts/linux/enter_enclave.h @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* ------------------------------------------------------------ + * Normal function enter/leave wrappers. + * ------------------------------------------------------------ + */ + +#ifndef _ENTER_ENCLAVE_H_ +#define _ENTER_ENCLAVE_H_ + +#include "linux-regs.h" +#include "rts_cmd.h" + +/* macro for enter_enclave + * There is no .cfi_xxx to describe unwind information, because we want c++ exception can't across enclave boundary +*/ +.macro EENTER_PROLOG +push %xbp +mov %xsp, %xbp + +#if defined(__i386__) +push %ebx +push %esi +push %edi + +/* These 3 wordsize buffer are used for paddings, so that the + * stack-boundary can be kept 16-byte aligned. + * + * Note that, by default GCC assumes + * -mpreferred-stack-boundary=4 + * which results to 16 (2^4) byte alignment of stack boundary. + * + * | parameters | <- previous frame + * ==+================+====== + * | return address | ^ + * +----------------+ | + * | ebp | | + * +----------------+ 16 bytes <- current frame + * | ebx | | + * +----------------+ | + * | esi | v + * +----------------+ ---- + * | edi | 4 bytes + * +----------------+ + * | paddings | 3*4 bytes + * ==+================+====== + * | ENCLU | + */ +sub $(3 * SE_WORDSIZE), %esp + +#elif defined(__x86_64__) +push %rbx +push %r12 +push %r13 +push %r14 +push %r15 +/*save 5 parameter*/ +push %r8 +push %rcx +push %rdx +push %rsi +push %rdi +#else +# error unknown platform +#endif +.endm + +.macro EENTER_EPILOG +#if defined(__i386__) +mov -SE_WORDSIZE*1(%ebp), %ebx +mov -SE_WORDSIZE*2(%ebp), %esi +mov -SE_WORDSIZE*3(%ebp), %edi +#elif defined(__x86_64__) +mov -SE_WORDSIZE*1(%rbp), %rbx +mov -SE_WORDSIZE*2(%rbp), %r12 +mov -SE_WORDSIZE*3(%rbp), %r13 +mov -SE_WORDSIZE*4(%rbp), %r14 +mov -SE_WORDSIZE*5(%rbp), %r15 +#else +# error unknown platform +#endif +/* don't need recover rdi, rsi, rdx, rcx */ +mov %xbp, %xsp +pop %xbp +ret +.endm + +#if defined(__i386__) +#define frame_arg0 2*SE_WORDSIZE(%ebp) +#define frame_arg1 3*SE_WORDSIZE(%ebp) +#define frame_arg2 4*SE_WORDSIZE(%ebp) +#define frame_arg3 5*SE_WORDSIZE(%ebp) +#define frame_arg4 6*SE_WORDSIZE(%ebp) +#elif defined(__x86_64__) +#define frame_arg0 -10*SE_WORDSIZE(%rbp) +#define frame_arg1 -9*SE_WORDSIZE(%rbp) +#define frame_arg2 -8*SE_WORDSIZE(%rbp) +#define frame_arg3 -7*SE_WORDSIZE(%rbp) +#define frame_arg4 -6*SE_WORDSIZE(%rbp) +#else +# error unknown platform +#endif + +//refer sgx_error.h +#define SE_ERROR_READ_LOCK_FAIL 0xc0002202 + +#endif diff --git a/psw/urts/linux/get_thread_id.cpp b/psw/urts/linux/get_thread_id.cpp new file mode 100644 index 0000000000..acb760b079 --- /dev/null +++ b/psw/urts/linux/get_thread_id.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_thread.h" +#include + +static pthread_key_t g_tid_key; +static pthread_once_t g_key_once = PTHREAD_ONCE_INIT; + +static void create_key() +{ + pthread_key_create(&g_tid_key, NULL); +} + +se_thread_id_t get_thread_id() +{ + if(pthread_once(&g_key_once, create_key) != 0) + abort(); + + // If the key is invalid, pthread_getspecific will return NULL. + // No need to check the pthread_key_create and pthread_setspecific return value. + se_thread_id_t tid = (se_thread_id_t)(size_t)pthread_getspecific(g_tid_key); + + if( tid == 0) + { + tid = se_get_threadid(); + + // pthread_setspecific() shall fail if insufficient memory exists to associate the value + // with the key or the input key value is invalid. + // Here we don't check the return value. Then if pthread_setspecific fails in one ecall, + // the following ecall would call the syscall gettid to retrive the tid in one thread + // instead of returning SGX_ERROR_OUT_OF_TCS. + pthread_setspecific(g_tid_key, (void*)(size_t)tid); + } + return tid; +} diff --git a/psw/urts/linux/isgx_user.h b/psw/urts/linux/isgx_user.h new file mode 100644 index 0000000000..bee8016bcd --- /dev/null +++ b/psw/urts/linux/isgx_user.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _X86_ISGX_USER_H +#define _X86_ISGX_USER_H + +#include +#include +#include + +#define ISGX_IOCTL_ENCLAVE_CREATE _IOWR('p', 0x02, struct isgx_create_param) +#define ISGX_IOCTL_ENCLAVE_ADD_PAGE _IOW('p', 0x03, struct isgx_add_param) +#define ISGX_IOCTL_ENCLAVE_INIT _IOW('p', 0x04, struct isgx_init_param) +#define ISGX_IOCTL_ENCLAVE_DESTROY _IOW('p', 0x06, struct isgx_destroy_param) + +#define SECS_SIZE_OFFSET 0 +#define SECS_BASE_OFFSET (SECS_SIZE_OFFSET + 8) +#define SECS_FLAGS_OFFSET (SECS_BASE_OFFSET + 8) +#define SECS_SSAFRAMESIZE_OFFSET (SECS_SIZE_OFFSET + 164) + +/* SGX leaf instruction return values */ +#define ISGX_SUCCESS 0 +#define ISGX_ERROR -1 +#define ISGX_INVALID_SIG_STRUCT 0x1 +#define ISGX_INVALID_ATTRIBUTE 0x2 +#define ISGX_INVALID_MEASUREMENT 0x4 +#define ISGX_INVALID_SIGNATIRE 0x8 +#define ISGX_INVALID_LAUNCH_TOKEN 0x10 +#define ISGX_INVALID_CPUSVN 0x20 +#define ISGX_INVALID_ISVSVN 0x40 +#define ISGX_UNMASKED_EVENT 0x80 +#define ISGX_INVALID_KEYNAME 0x100 + +/* IOCTL return values */ +#define ISGX_OUT_OF_EPC_PAGES 0xc0000001 +#define ISGX_POWER_LOST_ENCLAVE 0xc0000002 + +/* SECINFO flags */ +#define ISGX_SECINFO_R 0x1 /* Read Access */ +#define ISGX_SECINFO_W 0x2 /* Write Access */ +#define ISGX_SECINFO_X 0x4 /* Execute Access */ +#define ISGX_SECINFO_SECS 0x000 /* SECS */ +#define ISGX_SECINFO_TCS 0x100 /* TCS */ +#define ISGX_SECINFO_REG 0x200 /* Regular Page */ + +struct isgx_secinfo { + __u64 flags; + __u64 reserved[7]; +}; + +struct isgx_create_param { + void *secs; + unsigned long addr; +}; + +#define ISGX_ADD_SKIP_EEXTEND 0x1 + +struct isgx_add_param { + unsigned long addr; + unsigned long user_addr; + void *secinfo; + unsigned int flags; +}; + +struct isgx_init_param { + unsigned long addr; + void *sigstruct; + void *einittoken; +}; + +struct isgx_destroy_param { + unsigned long addr; +}; + +#endif /* _X86_ISGX_USER_H */ diff --git a/psw/urts/linux/misc.cpp b/psw/urts/linux/misc.cpp new file mode 100644 index 0000000000..37f61318d8 --- /dev/null +++ b/psw/urts/linux/misc.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_wrapper.h" +#include +#include + +using namespace std; + +//get all thread id of current process. +void get_thread_set(vector &thread_vector) +{ + DIR* dir = NULL; + struct dirent* dirent = NULL; + + if(NULL == (dir = opendir("/proc/self/task"))) + { + SE_TRACE(SE_TRACE_WARNING, "Failed to open /proc/slef/task\n"); + } + else + { + while(NULL != (dirent=readdir(dir))) + { + se_thread_id_t tid = (se_thread_id_t)strtol(dirent->d_name, NULL, 10); + + if(!tid) continue; //dir name may be . or .. + thread_vector.push_back(tid); + SE_TRACE(SE_TRACE_DEBUG, "tid = %d\n", (int)tid); + } + closedir(dir); + } +} diff --git a/psw/urts/linux/read_xcr0.h b/psw/urts/linux/read_xcr0.h new file mode 100644 index 0000000000..7b786ea9e3 --- /dev/null +++ b/psw/urts/linux/read_xcr0.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _READ_XCR0_H_ +#define _READ_XCR0_H_ + +static inline uint64_t xgetbv(uint32_t index) +{ + uint32_t eax, edx; + + asm volatile(".byte 0x0f,0x01,0xd0" /* xgetbv */ + : "=a" (eax), "=d" (edx) + : "c" (index)); + return eax + ((uint64_t)edx << 32); +} + +static inline uint64_t read_xcr0() +{ + return xgetbv(0); +} + +#endif diff --git a/psw/urts/linux/sig_handler.cpp b/psw/urts/linux/sig_handler.cpp new file mode 100644 index 0000000000..8651538f2d --- /dev/null +++ b/psw/urts/linux/sig_handler.cpp @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "arch.h" +#include "sgx_error.h" +#include "tcs.h" +#include "se_trace.h" +#include "xsave.h" +#include "rts.h" +#include "enclave.h" +#include +#include +#include +#include + + +typedef struct _ecall_param_t +{ + tcs_t *tcs; + long fn; //long because we need register bandwith align on stack, refer to enter_enclave.h; + void *ocall_table; + void *ms; + CTrustThread *trust_thread; +} ecall_param_t; + +#ifdef __x86_64__ +#define REG_XIP REG_RIP +#define REG_XAX REG_RAX +#define REG_XBX REG_RBX +#define REG_XSI REG_RSI +#define REG_XBP REG_RBP +/* + * refer to enter_enclave.h + * stack high address <------------- + * |rip|rbp|rbx|r10|r13|r14|r15|r8|rcx|rdx|rsi|rdi| + * ^ ^ + * | <-rbp | <-param4 + */ +#define ECALL_PARAM (reinterpret_cast(context->uc_mcontext.gregs[REG_RBP] - 10 * 8)) +#else +#define REG_XIP REG_EIP +#define REG_XAX REG_EAX +#define REG_XBX REG_EBX +#define REG_XSI REG_ESI +#define REG_XBP REG_EBP +/* + * refer to enter_enclave.h + * stack high address <------------- + * |param4|param3|param2|param2|param0|eip|ebp| + * ^ + * | <-ebp + */ +#define ECALL_PARAM (reinterpret_cast(context->uc_mcontext.gregs[REG_EBP] + 2 * 4)) +#endif + +extern "C" void *get_aep(); +extern "C" void *get_eenterp(); +extern "C" void *get_eretp(); +static struct sigaction g_old_sigact[_NSIG]; + +void reg_sig_handler(); + +void sig_handler(int signum, siginfo_t* siginfo, void *priv) +{ + SE_TRACE(SE_TRACE_DEBUG, "signal handler is triggered\n"); + ucontext_t* context = reinterpret_cast(priv); + unsigned int *xip = reinterpret_cast(context->uc_mcontext.gregs[REG_XIP]); + size_t xax = context->uc_mcontext.gregs[REG_XAX]; +#ifndef NDEBUG + /* `xbx' is only used in assertions. */ + size_t xbx = context->uc_mcontext.gregs[REG_XBX]; +#endif + ecall_param_t *param = ECALL_PARAM; + + //the case of exception on ERESUME or within enclave. + //We can't distinguish ERESUME exception from exception within enclave. We assume it is the exception within enclave. + //If it is ERESUME exception, it will raise another exception in ecall and ecall will return error. + if(xip == get_aep() + && SE_ERESUME == xax) + { + assert(ENCLU == (*xip & 0xffffff)); + //suppose the exception is within enclave. + SE_TRACE(SE_TRACE_NOTICE, "exception on ERESUME\n"); + //The ecall looks recursively, but it will not cause infinite call. + //If exception is raised in trts again and again, the SSA will overflow, and finally it is EENTER exception. + assert(reinterpret_cast(xbx) == param->tcs); + CEnclave *enclave = param->trust_thread->get_enclave(); + unsigned int ret = enclave->ecall(ECMD_EXCEPT, param->ocall_table, NULL); + if(SGX_SUCCESS == ret) + { + //ERESUME execute + return; + } + //If the exception is caused by enclave lost or internal stack overrun, then return the error code to ecall caller elegantly. + else if(SGX_ERROR_ENCLAVE_LOST == ret || SGX_ERROR_STACK_OVERRUN == ret) + { + //enter_enlcave function will return with ret which is from tRTS; + context->uc_mcontext.gregs[REG_XIP] = reinterpret_cast(get_eretp()); + context->uc_mcontext.gregs[REG_XSI] = ret; + return; + } + //If we can't fix the exception within enclave, then give the handle to other signal hanlder. + //Call the previous signal handler. The default signal handler should terminate the application. + + enclave->rdunlock(); + CEnclavePool::instance()->unref_enclave(enclave); + } + //the case of exception on EENTER instruction. + else if(xip == get_eenterp() + && SE_EENTER == xax) + { + assert(reinterpret_cast(xbx) == param->tcs); + assert(ENCLU == (*xip & 0xffffff)); + SE_TRACE(SE_TRACE_NOTICE, "exception on EENTER\n"); + //enter_enlcave function will return with SE_ERROR_ENCLAVE_LOST + context->uc_mcontext.gregs[REG_XIP] = reinterpret_cast(get_eretp()); + context->uc_mcontext.gregs[REG_XSI] = SGX_ERROR_ENCLAVE_LOST; + return; + } + + SE_TRACE(SE_TRACE_DEBUG, "NOT enclave signal\n"); + //it is not SE exception. if the old signal handler is default signal handler, we reset signal handler. + //raise the signal again, and the default signal handler will be called. + if(SIG_DFL == g_old_sigact[signum].sa_handler) + { + signal(signum, SIG_DFL); + raise(signum); + } + //if there is old signal handler, we need transfer the signal to the old signal handler; + else + { + if(!(g_old_sigact[signum].sa_flags & SA_NODEFER)) + sigaddset(&g_old_sigact[signum].sa_mask, signum); + + sigset_t cur_set; + pthread_sigmask(SIG_SETMASK, &g_old_sigact[signum].sa_mask, &cur_set); + + if(g_old_sigact[signum].sa_flags & SA_SIGINFO) + { + g_old_sigact[signum].sa_sigaction(signum, siginfo, priv); + } + else + { + g_old_sigact[signum].sa_handler(signum); + } + + pthread_sigmask(SIG_SETMASK, &cur_set, NULL); + + //If the g_old_sigact set SA_RESETHAND, it will break the chain which means + //g_old_sigact->next_old_sigact will not be called. Our signal handler does not + //responsable for that. We just follow what os do on SA_RESETHAND. + if(g_old_sigact[signum].sa_flags & SA_RESETHAND) + g_old_sigact[signum].sa_handler = SIG_DFL; + } +} + +void reg_sig_handler() +{ + int ret = 0; + struct sigaction sig_act; + SE_TRACE(SE_TRACE_DEBUG, "signal handler is registered\n"); + + memset(&sig_act, 0, sizeof(sig_act)); + sig_act.sa_sigaction = sig_handler; + sig_act.sa_flags = SA_SIGINFO | SA_NODEFER | SA_RESTART; + sigemptyset(&sig_act.sa_mask); + if(sigprocmask(SIG_SETMASK, NULL, &sig_act.sa_mask)) + { + SE_TRACE(SE_TRACE_WARNING, "%s\n", strerror(errno)); + } + else + { + sigdelset(&sig_act.sa_mask, SIGSEGV); + sigdelset(&sig_act.sa_mask, SIGFPE); + sigdelset(&sig_act.sa_mask, SIGILL); + sigdelset(&sig_act.sa_mask, SIGBUS); + sigdelset(&sig_act.sa_mask, SIGTRAP); + } + + ret = sigaction(SIGSEGV, &sig_act, &g_old_sigact[SIGSEGV]); + if (0 != ret) abort(); + ret = sigaction(SIGFPE, &sig_act, &g_old_sigact[SIGFPE]); + if (0 != ret) abort(); + ret = sigaction(SIGILL, &sig_act, &g_old_sigact[SIGILL]); + if (0 != ret) abort(); + ret = sigaction(SIGBUS, &sig_act, &g_old_sigact[SIGBUS]); + if (0 != ret) abort(); + ret = sigaction(SIGTRAP, &sig_act, &g_old_sigact[SIGTRAP]); + if (0 != ret) abort(); +} + +//trust_thread is saved at stack for ocall. +#define enter_enclave __morestack + +extern "C" int enter_enclave(const tcs_t *tcs, const long fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread); + +int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread) +{ + int status = SGX_ERROR_UNEXPECTED; + +#ifdef SE_SIM + CEnclave* enclave = trust_thread->get_enclave(); + //check if it is current pid, it is to simulate fork() scenario on HW + sgx_enclave_id_t eid = enclave->get_enclave_id(); + if((pid_t)(eid >> 32) != getpid()) + return SGX_ERROR_ENCLAVE_LOST; +#endif + + tcs_t *tcs = trust_thread->get_tcs(); + //seh_handler.cpp have the same code to save and restore pf register. + //put the save register code here, because we want remind maintainer we should do it near EENTER + uint8_t buffer[FXSAVE_SIZE]; + save_and_clean_xfeature_regs(buffer); + + status = enter_enclave(tcs, fn, ocall_table, ms, trust_thread); + + restore_xfeature_regs(buffer); + + return status; +} + +int do_ocall(const bridge_fn_t bridge, void *ms) +{ + int error = SGX_ERROR_UNEXPECTED; + + error = bridge(ms); + + save_and_clean_xfeature_regs(NULL); + + return error; +} diff --git a/psw/urts/linux/sig_handler.h b/psw/urts/linux/sig_handler.h new file mode 100644 index 0000000000..93acd4261c --- /dev/null +++ b/psw/urts/linux/sig_handler.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SIG_HANDLER_H_ +#define _SIG_HANDLER_H_ + +void reg_sig_handler(); + +#endif diff --git a/psw/urts/linux/urts.cpp b/psw/urts/linux/urts.cpp new file mode 100644 index 0000000000..4c2af4c365 --- /dev/null +++ b/psw/urts/linux/urts.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_error.h" +#include "sgx_urts.h" +#include "se_types.h" +#include +#include +#include + +#include "urts_com.h" +extern "C" sgx_status_t sgx_create_enclave(const char *file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr) +{ + sgx_status_t ret = SGX_SUCCESS; + + //Only true or flase is valid + if(TRUE != debug && FALSE != debug) + return SGX_ERROR_INVALID_PARAMETER; + + int fd = open(file_name, O_RDONLY); + if(-1 == fd) + { + SE_TRACE(SE_TRACE_ERROR, "Couldn't open the enclave file, error = %d\n", errno); + return SGX_ERROR_ENCLAVE_FILE_ACCESS; + } + se_file_t file = {NULL, 0, false}; + char resolved_path[PATH_MAX]; + file.name = realpath(file_name, resolved_path); + file.name_len = (uint32_t)strlen(resolved_path); + + ret = _create_enclave(!!debug, fd, file, NULL, launch_token, launch_token_updated, enclave_id, misc_attr); + close(fd); + + return ret; +} diff --git a/psw/urts/linux/urts_internal.cpp b/psw/urts/linux/urts_internal.cpp new file mode 100644 index 0000000000..60ba21dfda --- /dev/null +++ b/psw/urts/linux/urts_internal.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_error.h" +#include "sgx_urts.h" +#include "se_types.h" +#include +#include +#include +#include "file.h" +#include "se_wrapper.h" +#include "se_map.h" + + +extern sgx_status_t _create_enclave(const bool debug, se_file_handle_t pfile, se_file_t& file, le_prd_css_file_t *prd_css_file, sgx_launch_token_t *launch, int *launch_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr); + +extern "C" sgx_status_t sgx_create_le(const char* file_name, const char* prd_css_file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr, int *production_loaded) +{ + sgx_status_t ret = SGX_SUCCESS; + + //Only true or flase is valid + if(TRUE != debug && FALSE != debug) + return SGX_ERROR_INVALID_PARAMETER; + + int fd = open(file_name, O_RDONLY); + if(-1 == fd) + { + SE_TRACE(SE_TRACE_ERROR, "Couldn't open the enclave file, error = %d\n", errno); + return SGX_ERROR_ENCLAVE_FILE_ACCESS; + } + se_file_t file = {NULL, 0, false}; + char resolved_path[PATH_MAX]; + file.name = realpath(file_name, resolved_path); + file.name_len = (uint32_t)strlen(resolved_path); + + char css_real_path[PATH_MAX]; + + le_prd_css_file_t prd_css_file = {NULL, false}; + prd_css_file.prd_css_name = realpath(prd_css_file_name, css_real_path); + + ret = _create_enclave(!!debug, fd, file, &prd_css_file, launch_token, launch_token_updated, enclave_id, misc_attr); + close(fd); + if(ret == SGX_SUCCESS && production_loaded != NULL) + { + *production_loaded = prd_css_file.is_used ? 1: 0; + } + + return ret; +} diff --git a/psw/urts/loader.cpp b/psw/urts/loader.cpp new file mode 100644 index 0000000000..01b61ce238 --- /dev/null +++ b/psw/urts/loader.cpp @@ -0,0 +1,779 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_wrapper.h" +#include "se_error_internal.h" +#include "arch.h" +#include "util.h" +#include "loader.h" +#include "se_page_attr.h" +#include "enclave.h" +#include "enclave_creator.h" +#include "routine.h" +#include "sgx_attributes.h" +#include "se_vendor.h" +#include "se_detect.h" +#include "binparser.h" +#include +#include +#include +#define __STDC_FORMAT_MACROS +#include +#include + +// enclave creator instance +extern EnclaveCreator* g_enclave_creator; + +EnclaveCreator* get_enclave_creator(void) +{ + return g_enclave_creator; +} + +CLoader::CLoader(uint8_t *mapped_file_base, BinParser &parser) + : m_mapped_file_base(mapped_file_base) + , m_enclave_id(0) + , m_start_addr(NULL) + , m_metadata(NULL) + , m_parser(parser) +{ + memset(&m_secs, 0, sizeof(m_secs)); +} + +CLoader::~CLoader() +{ + +} + +sgx_enclave_id_t CLoader::get_enclave_id() const +{ + return m_enclave_id; +} + +const void* CLoader::get_start_addr() const +{ + return m_start_addr; +} + +const std::vector& CLoader::get_tcs_list() const +{ + return m_tcs_list; +} + +const secs_t& CLoader::get_secs() const +{ + return m_secs; +} + +void* CLoader::get_symbol_address(const char * const symbol) +{ + uint64_t rva = m_parser.get_symbol_rva(symbol); + if(0 == rva) + return NULL; + return GET_PTR(void, m_start_addr, rva); +} + +int CLoader::build_mem_region(const section_info_t * const sec_info) +{ + int ret = SGX_SUCCESS; + uint8_t added_page[SE_PAGE_SIZE]; + uint64_t offset = 0; + uint8_t *raw_ptr = NULL; + uint64_t rva = 0; + sec_info_t sinfo; + memset(&sinfo, 0, sizeof(sinfo)); + + rva = sec_info->rva + offset; + while(offset < TRIM_TO_PAGE(sec_info->raw_data_size)) + { + raw_ptr = sec_info->raw_data + offset; + sinfo.flags = sec_info->flag; + + //check if the page is writable. + if(sec_info->bitmap && sec_info->bitmap->size()) + { + uint64_t page_frame = rva >> SE_PAGE_SHIFT; + + //NOTE: + // Current enclave size is not beyond 64G, so the type-casting from (uint64>>15) to (size_t) is OK. + // In the future, if the max enclave size is extended to beyond (1<<49), this type-casting will not work. + // It only impacts the enclave signing process. (32bit signing tool to sign 64 bit enclaves) + if((*sec_info->bitmap)[(size_t)(page_frame / 8)] & (1 << (page_frame % 8))) + sinfo.flags = sec_info->flag | SI_FLAG_W; + } + //call driver API to add page; raw_ptr needn't be page align, driver will handle page align; + if(SGX_SUCCESS != (ret = get_enclave_creator()->add_enclave_page(ENCLAVE_ID_IOCTL, raw_ptr, rva, sinfo, ADD_EXTEND_PAGE))) + { + //if add page failed , we should remove enclave somewhere; + return ret; + } + offset += SE_PAGE_SIZE; + rva = sec_info->rva + offset; + } + //add the remaider of last page of raw data + if(!IS_PAGE_ALIGNED(sec_info->raw_data_size)) + { + sinfo.flags = sec_info->flag; + //the padding be 0 + memset(added_page, 0, SE_PAGE_SIZE); + raw_ptr = sec_info->raw_data + offset; + rva = sec_info->rva + offset; + memcpy_s(added_page, SE_PAGE_SIZE, raw_ptr, sec_info->raw_data_size & (SE_PAGE_SIZE-1)); + //check if the page is writable. + if(sec_info->bitmap && sec_info->bitmap->size()) + { + uint64_t page_frame = rva >> SE_PAGE_SHIFT; + //NOTE: + // Current enclave size is not beyond 64G, so the type-casting from (uint64>>15) to (size_t) is OK. + // In the future, if the max enclave size is extended to beyond (1<<49), this type-casting will not work. + // It only impacts the enclave signing process. (32bit signing tool to sign 64 bit enclaves) + if((*sec_info->bitmap)[(size_t)(page_frame / 8)] & (1 << (page_frame % 8))) + sinfo.flags = sec_info->flag | SI_FLAG_W; + } + //call driver to add page; + if(SGX_SUCCESS != (ret = get_enclave_creator()->add_enclave_page(ENCLAVE_ID_IOCTL, added_page, rva, sinfo, ADD_EXTEND_PAGE))) + { + //if add page failed , we should remove enclave somewhere; + return ret; + } + rva += SE_PAGE_SIZE; + } + //add unintialized page.If the section have no raw data, the offset should be 0. + if(ROUND_TO_PAGE(sec_info->virtual_size) > ROUND_TO_PAGE(sec_info->raw_data_size)) + { + size_t size = (size_t)(ROUND_TO_PAGE(sec_info->virtual_size) - ROUND_TO_PAGE(sec_info->raw_data_size)); + sinfo.flags = sec_info->flag; + if(SGX_SUCCESS != (ret = build_pages(rva, size, 0, sinfo, ADD_EXTEND_PAGE))) + return ret; + } + + return SGX_SUCCESS; +} + +int CLoader::build_sections(vector *bitmap) +{ + int ret = SGX_SUCCESS; + std::vector sections = m_parser.get_sections(); + + for(unsigned int i = 0; i < sections.size() ; i++) + { + //since build_mem_region require the sec_info.rva be page aligned, we need handle the first page. + //build the first page; + uint64_t offset = (sections[i]->get_rva() & (SE_PAGE_SIZE -1)); + uint64_t size = SE_PAGE_SIZE - offset; + uint8_t first_page[SE_PAGE_SIZE]; + //the raw data may be smaller than the size, we get the min of them + if(sections[i]->raw_data_size() < size) + size = sections[i]->raw_data_size(); + //the padding is '0' + memset(first_page, 0, SE_PAGE_SIZE); + memcpy_s(&first_page[offset], (size_t)size, sections[i]->raw_data(), (size_t)size); + section_info_t sec_info = { first_page, SE_PAGE_SIZE, sections[i]->get_rva() & (~(SE_PAGE_SIZE - 1)), SE_PAGE_SIZE, sections[i]->get_si_flags(), bitmap }; + + if(SGX_SUCCESS != (ret = build_mem_region(&sec_info))) + { + return ret; + } + //if there is more pages, then build the next paged aligned pages + if((sections[i]->virtual_size() + offset) > SE_PAGE_SIZE) + { + sec_info.raw_data = GET_PTR(uint8_t, sections[i]->raw_data(), size); + sec_info.raw_data_size = sections[i]->raw_data_size() - size; + sec_info.rva = sections[i]->get_rva() + (SE_PAGE_SIZE - offset); + assert(0 == (sec_info.rva & (SE_PAGE_SIZE - 1))); + //we need use (SE_PAGE_SIZE - offset), because (SE_PAGE_SIZE - offset) may larger than size + sec_info.virtual_size = sections[i]->virtual_size() - (SE_PAGE_SIZE - offset); + sec_info.flag = sections[i]->get_si_flags(); + sec_info.bitmap = bitmap; + if(SGX_SUCCESS != (ret = build_mem_region(&sec_info))) + { + return ret; + } + } + } + + return SGX_SUCCESS; +} + +int CLoader::build_pages(const uint64_t start_rva, const uint64_t size, void *source, const sec_info_t &sinfo, const uint32_t attr) +{ + int ret = SGX_SUCCESS; + uint64_t offset = 0; + uint64_t rva = start_rva; + + while(offset < size) + { + //call driver to add page; + if(SGX_SUCCESS != (ret = get_enclave_creator()->add_enclave_page(ENCLAVE_ID_IOCTL, source, rva, sinfo, attr))) + { + //if add page failed , we should remove enclave somewhere; + return ret; + } + offset += SE_PAGE_SIZE; + rva += SE_PAGE_SIZE; + } + + return SGX_SUCCESS; +} +int CLoader::build_context(const uint64_t start_rva, layout_entry_t *layout) +{ + int ret = SGX_ERROR_UNEXPECTED; + uint8_t added_page[SE_PAGE_SIZE]; + sec_info_t sinfo; + memset(&sinfo, 0, sizeof(sinfo)); + uint64_t rva = start_rva + layout->rva; + + if (layout->content_offset) + { + // assume TCS is only 1 page + if(layout->si_flags == SI_FLAGS_TCS) + { + memset(added_page, 0, SE_PAGE_SIZE); + memcpy_s(added_page, SE_PAGE_SIZE, GET_PTR(uint8_t, m_metadata, layout->content_offset), layout->content_size); + + tcs_t *ptcs = reinterpret_cast(added_page); + ptcs->ossa += rva; + ptcs->ofs_base += rva; + ptcs->ogs_base += rva; + m_tcs_list.push_back(GET_PTR(tcs_t, m_start_addr, rva)); + sinfo.flags = layout->si_flags; + if(SGX_SUCCESS != (ret = build_pages(rva, layout->page_count << SE_PAGE_SHIFT, added_page, sinfo, layout->attributes))) + { + return ret; + } + } + else // guard page should not have content_offset != 0 + { + section_info_t sec_info = {GET_PTR(uint8_t, m_metadata, layout->content_offset), layout->content_size, rva, layout->page_count << SE_PAGE_SHIFT, layout->si_flags, NULL}; + if(SGX_SUCCESS != (ret = build_mem_region(&sec_info))) + { + return ret; + } + } + } + else if (layout->si_flags != SI_FLAG_NONE) + { + sinfo.flags = layout->si_flags; + + void *source = NULL; + if(layout->content_size) + { + for(uint32_t *p = (uint32_t *)added_page; p < GET_PTR(uint32_t, added_page, SE_PAGE_SIZE); p++) + { + *p = layout->content_size; + } + source = added_page; + } + if(SGX_SUCCESS != (ret = build_pages(rva, layout->page_count << SE_PAGE_SHIFT, source, sinfo, layout->attributes))) + { + return ret; + } + } + return SGX_SUCCESS; +} +int CLoader::build_contexts(layout_t *layout_start, layout_t *layout_end, uint64_t delta) +{ + int ret = SGX_ERROR_UNEXPECTED; + for(layout_t *layout = layout_start; layout < layout_end; layout++) + { + if (!IS_GROUP_ID(layout->group.id)) + { + if(SGX_SUCCESS != (ret = build_context(delta, &layout->entry))) + { + return ret; + } + } + else + { + uint64_t step = 0; + for(uint32_t j = 0; j < layout->group.load_times; j++) + { + step += layout->group.load_step; + if(SGX_SUCCESS != (ret = build_contexts(&layout[-layout->group.entry_count], layout, step))) + { + return ret; + } + } + } + } + return SGX_SUCCESS; +} +int CLoader::build_secs(sgx_attributes_t * const secs_attr, sgx_misc_attribute_t * const misc_attr) +{ + memset(&m_secs, 0, sizeof(secs_t)); //should set resvered field of secs as 0. + //create secs structure. + m_secs.base = 0; //base is allocated by driver. set it as 0 + m_secs.size = m_metadata->enclave_size; + m_secs.misc_select = misc_attr->misc_select; + + memcpy_s(&m_secs.attributes, sizeof(m_secs.attributes), secs_attr, sizeof(m_secs.attributes)); + m_secs.ssa_frame_size = m_metadata->ssa_frame_size; + + EnclaveCreator *enclave_creator = get_enclave_creator(); + if(NULL == enclave_creator) + return SGX_ERROR_UNEXPECTED; + int ret = enclave_creator->create_enclave(&m_secs, &m_enclave_id, &m_start_addr, is_ae(&m_metadata->enclave_css)); + if(SGX_SUCCESS == ret) + { + SE_TRACE(SE_TRACE_NOTICE, "enclave start address = %p, size = %x\n", m_start_addr, m_metadata->enclave_size); + } + return ret; +} +int CLoader::build_image(SGXLaunchToken * const lc, sgx_attributes_t * const secs_attr, le_prd_css_file_t *prd_css_file, sgx_misc_attribute_t * const misc_attr) +{ + int ret = SGX_SUCCESS; + + if(SGX_SUCCESS != (ret = build_secs(secs_attr, misc_attr))) + { + SE_TRACE(SE_TRACE_WARNING, "build secs failed\n"); + return ret; + }; + // read reloc bitmap before patch the enclave file + // If load_enclave_ex try to load the enclave for the 2nd time, + // the enclave image is already patched, and parser cannot read the information. + // For linux, there's no map conflict. We assume load_enclave_ex will not do the retry. + vector bitmap; + if(!m_parser.get_reloc_bitmap(bitmap)) + return SGX_ERROR_INVALID_ENCLAVE; + + // patch enclave file + patch_entry_t *patch_start = GET_PTR(patch_entry_t, m_metadata, m_metadata->dirs[DIR_PATCH].offset); + patch_entry_t *patch_end = GET_PTR(patch_entry_t, m_metadata, m_metadata->dirs[DIR_PATCH].offset + m_metadata->dirs[DIR_PATCH].size); + for(patch_entry_t *patch = patch_start; patch < patch_end; patch++) + { + memcpy_s(GET_PTR(void, m_parser.get_start_addr(), patch->dst), patch->size, GET_PTR(void, m_metadata, patch->src), patch->size); + } + + //build sections, copy export function table as well; + if(SGX_SUCCESS != (ret = build_sections(&bitmap))) + { + SE_TRACE(SE_TRACE_WARNING, "build sections failed\n"); + goto fail; + } + + // build heap/thread context + if (SGX_SUCCESS != (ret = build_contexts(GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset), + GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset + m_metadata->dirs[DIR_LAYOUT].size), + 0))) + { + SE_TRACE(SE_TRACE_WARNING, "build heap/thread context failed\n"); + goto fail; + } + + //initialize Enclave + ret = get_enclave_creator()->init_enclave(ENCLAVE_ID_IOCTL, const_cast(&m_metadata->enclave_css), lc, prd_css_file); + if(SGX_SUCCESS != ret) + { + SE_TRACE(SE_TRACE_WARNING, "init_enclave failed\n"); + goto fail; + } + + return SGX_SUCCESS; + +fail: + get_enclave_creator()->destroy_enclave(ENCLAVE_ID_IOCTL); + + return ret; +} +bool CLoader::is_metadata_buffer(uint32_t offset, uint32_t size) +{ + if((offsetof(metadata_t, data) > offset) || (offset >= m_metadata->size)) + { + return false; + } + uint32_t end = offset + size; + if ((end < offset) || (end < size) || (end > m_metadata->size)) + { + return false; + } + return true; +} +bool CLoader::is_enclave_buffer(uint64_t offset, uint64_t size) +{ + if(offset >= m_metadata->enclave_size) + { + return false; + } + uint64_t end = offset + size; + if ((end < offset) || (end < size) || (end > m_metadata->enclave_size)) + { + return false; + } + return true; +} +int CLoader::validate_layout_table() +{ + layout_t *layout_start = GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset); + layout_t *layout_end = GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset + m_metadata->dirs[DIR_LAYOUT].size); + vector> rva_vector; + for (layout_t *layout = layout_start; layout < layout_end; layout++) + { + if(!IS_GROUP_ID(layout->entry.id)) // layout entry + { + rva_vector.push_back(make_pair(layout->entry.rva, layout->entry.page_count << SE_PAGE_SHIFT)); + if(layout->entry.content_offset) + { + if(false == is_metadata_buffer(layout->entry.content_offset, layout->entry.content_size)) + { + return SGX_ERROR_INVALID_METADATA; + } + } + } + else // layout group + { + if (layout->group.entry_count > (uint32_t)(PTR_DIFF(layout, layout_start)/sizeof(layout_t))) + { + return SGX_ERROR_INVALID_METADATA; + } + uint64_t load_step = 0; + for(uint32_t i = 0; i < layout->group.load_times; i++) + { + load_step += layout->group.load_step; + if(load_step > m_metadata->enclave_size) + { + return SGX_ERROR_INVALID_METADATA; + } + for(layout_entry_t *entry = &layout[-layout->group.entry_count].entry; entry < &layout->entry; entry++) + { + if(IS_GROUP_ID(entry->id)) + { + return SGX_ERROR_INVALID_METADATA; + } + rva_vector.push_back(make_pair(entry->rva + load_step, entry->page_count << SE_PAGE_SHIFT)); + // no need to check integer overflow for entry->rva + load_step, because + // entry->rva and load_step are less than enclave_size, whose size is no more than 37 bit + } + } + } + } + sort(rva_vector.begin(), rva_vector.end()); + for (vector>::iterator it = rva_vector.begin(); it != rva_vector.end(); it++) + { + if(!IS_PAGE_ALIGNED(it->first)) + { + return SGX_ERROR_INVALID_METADATA; + } + if(false == is_enclave_buffer(it->first, it->second)) + { + return SGX_ERROR_INVALID_METADATA; + } + if((it+1) != rva_vector.end()) + { + if((it->first+it->second) > (it+1)->first) + { + return SGX_ERROR_INVALID_METADATA; + } + } + } + return SGX_SUCCESS; +} + +int CLoader::validate_patch_table() +{ + patch_entry_t *patch_start = GET_PTR(patch_entry_t, m_metadata, m_metadata->dirs[DIR_PATCH].offset); + patch_entry_t *patch_end = GET_PTR(patch_entry_t, m_metadata, m_metadata->dirs[DIR_PATCH].offset + m_metadata->dirs[DIR_PATCH].size); + for(patch_entry_t *patch = patch_start; patch < patch_end; patch++) + { + if(false == is_metadata_buffer(patch->src, patch->size)) + { + return SGX_ERROR_INVALID_METADATA; + } + if(false == is_enclave_buffer(patch->dst, patch->size)) + { + return SGX_ERROR_INVALID_METADATA; + } + } + return SGX_SUCCESS; +} +int CLoader::validate_metadata() +{ + if(!m_metadata) + return SGX_ERROR_INVALID_METADATA; + uint64_t version = META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ); + //if the version of metadata does NOT match the version of metadata in urts, we should NOT launch enclave. + if(m_metadata->version != version) + { + SE_TRACE(SE_TRACE_WARNING, "Mismatch between the metadata urts required and the metadata in use.\n"); + return SGX_ERROR_INVALID_VERSION; + } + if(m_metadata->size > sizeof(metadata_t)) + { + return SGX_ERROR_INVALID_METADATA; + } + if(m_metadata->tcs_policy > TCS_POLICY_UNBIND) + return SGX_ERROR_INVALID_METADATA; + if(m_metadata->ssa_frame_size < SSA_FRAME_SIZE_MIN || m_metadata->ssa_frame_size > SSA_FRAME_SIZE_MAX) + return SGX_ERROR_INVALID_METADATA; + uint64_t size = m_metadata->enclave_size; + if(size > m_parser.get_enclave_max_size()) + { + return SGX_ERROR_INVALID_METADATA; + } + while ((size != 0) && ((size & 1) != 1)) + { + size = size >> 1; + } + if(size != 1) + { + return SGX_ERROR_INVALID_METADATA; + } + + // check dirs + for(uint32_t i = 0; i < DIR_NUM; i++) + { + if(false == is_metadata_buffer(m_metadata->dirs[i].offset, m_metadata->dirs[i].size)) + { + return SGX_ERROR_INVALID_METADATA; + } + } + // check layout table + int status = validate_layout_table(); + if(SGX_SUCCESS != status) + { + return status; + } + // check patch table + status = validate_patch_table(); + if(SGX_SUCCESS != status) + { + return status; + } + + return SGX_SUCCESS; +} + +bool CLoader::is_ae(const enclave_css_t *enclave_css) +{ + assert(NULL != enclave_css); + + if(INTEL_VENDOR_ID == enclave_css->header.module_vendor + && AE_PRODUCT_ID == enclave_css->body.isv_prod_id) + return true; + + return false; +} + +int CLoader::load_enclave(SGXLaunchToken *lc, int debug, const metadata_t *metadata, le_prd_css_file_t *prd_css_file, sgx_misc_attribute_t *misc_attr) +{ + int ret = SGX_SUCCESS; + sgx_misc_attribute_t sgx_misc_attr; + memset(&sgx_misc_attr, 0, sizeof(sgx_misc_attribute_t)); + + m_metadata = metadata; + ret = validate_metadata(); + if(SGX_SUCCESS != ret) + { + SE_TRACE(SE_TRACE_ERROR, "The metadata setting is not correct\n"); + return ret; + } + + ret = get_enclave_creator()->get_misc_attr(&sgx_misc_attr, const_cast(m_metadata), lc, debug); + if(SGX_SUCCESS != ret) + { + return ret; + } + + ret = build_image(lc, &sgx_misc_attr.secs_attr, prd_css_file, &sgx_misc_attr); + //return platform capability if fail. Otherwise, return secs.attr. + if(SGX_SUCCESS == ret) + { + if(misc_attr) + { + memcpy_s(misc_attr, sizeof(sgx_misc_attribute_t), &sgx_misc_attr, sizeof(sgx_misc_attribute_t)); + //When run here EINIT success, so SGX_FLAGS_INITTED should be set by ucode. uRTS align it with EINIT instruction. + misc_attr->secs_attr.flags |= SGX_FLAGS_INITTED; + } + } + else + { + if(misc_attr) + { + sgx_misc_attribute_t plat_cap; + memset(&plat_cap, 0, sizeof(plat_cap)); + get_enclave_creator()->get_plat_cap(&plat_cap); + memcpy_s(misc_attr, sizeof(sgx_misc_attribute_t), &plat_cap, sizeof(sgx_misc_attribute_t)); + } + } + + return ret; +} + +int CLoader::load_enclave_ex(SGXLaunchToken *lc, bool debug, const metadata_t *metadata, le_prd_css_file_t *prd_css_file, sgx_misc_attribute_t *misc_attr) +{ + unsigned int ret = SGX_SUCCESS, map_conflict_count = 3; + bool retry = true; + + while (retry) + { + ret = this->load_enclave(lc, debug, metadata, prd_css_file, misc_attr); + switch(ret) + { + //If CreateEnclave failed due to power transition, we retry it. + case SGX_ERROR_ENCLAVE_LOST: //caused by loading enclave while power transition occurs + break; + + //If memroy map conflict occurs, we only retry 3 times. + case SGX_ERROR_MEMORY_MAP_CONFLICT: + if(0 == map_conflict_count) + retry = false; + else + map_conflict_count--; + break; + + //We don't re-load enclave due to other error code. + default: + retry = false; + break; + } + } + + return ret; +} + +int CLoader::destroy_enclave() +{ + return get_enclave_creator()->destroy_enclave(ENCLAVE_ID_IOCTL); +} + +int CLoader::set_memory_protection() +{ + + uint64_t rva = 0; + uint64_t len = 0; + uint64_t last_section_end = 0; + unsigned int i = 0; + int ret = 0; + //for sections + std::vector sections = m_parser.get_sections(); + + for(i = 0; i < sections.size() ; i++) + { + //require the sec_info.rva be page aligned, we need handle the first page. + //the first page; + uint64_t offset = (sections[i]->get_rva() & (SE_PAGE_SIZE -1)); + uint64_t size = SE_PAGE_SIZE - offset; + + //the raw data may be smaller than the size, we get the min of them + if(sections[i]->raw_data_size() < size) + size = sections[i]->raw_data_size(); + + len = SE_PAGE_SIZE; + + //if there is more pages, then calc the next paged aligned pages + if((sections[i]->virtual_size() + offset) > SE_PAGE_SIZE) + { + uint64_t raw_data_size = sections[i]->raw_data_size() - size; + //we need use (SE_PAGE_SIZE - offset), because (SE_PAGE_SIZE - offset) may larger than size + uint64_t virtual_size = sections[i]->virtual_size() - (SE_PAGE_SIZE - offset); + len += ROUND_TO_PAGE(raw_data_size); + + if(ROUND_TO_PAGE(virtual_size) > ROUND_TO_PAGE(raw_data_size)) + { + len += ROUND_TO_PAGE(virtual_size) - ROUND_TO_PAGE(raw_data_size); + } + } + rva = TRIM_TO_PAGE(sections[i]->get_rva()) + (uint64_t)m_start_addr; + ret = mprotect((void*)rva, (size_t)len, (int)(sections[i]->get_si_flags()&SI_MASK_MEM_ATTRIBUTE)); + if(ret != 0) + { + SE_TRACE(SE_TRACE_WARNING, "section[%d]:mprotect(rva=%" PRIu64 ", len=%" PRIu64 ", flags=%" PRIu64 ") failed\n", + i, rva, len, (sections[i]->get_si_flags())); + return SGX_ERROR_UNEXPECTED; + } + //there is a gap between sections, need to set those to NONE access + if(last_section_end != 0) + { + ret = mprotect((void*)last_section_end, (size_t)(rva - last_section_end), (int)(SI_FLAG_NONE & SI_MASK_MEM_ATTRIBUTE)); + if(ret != 0) + { + SE_TRACE(SE_TRACE_WARNING, "set protection for gap before section[%d]:mprotect(rva=%" PRIu64 ", len=%" PRIu64 ", flags=%" PRIu64 ") failed\n", + i, last_section_end, rva - last_section_end, SI_FLAG_NONE); + return SGX_ERROR_UNEXPECTED; + } + } + last_section_end = rva + len; + } + + ret = set_context_protection(GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset), + GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset + m_metadata->dirs[DIR_LAYOUT].size), + 0); + if (SGX_SUCCESS != ret) + { + return ret; + } + + return SGX_SUCCESS; + +} + +int CLoader::set_context_protection(layout_t *layout_start, layout_t *layout_end, uint64_t delta) +{ + int ret = SGX_ERROR_UNEXPECTED; + for(layout_t *layout = layout_start; layout < layout_end; layout++) + { + if (!IS_GROUP_ID(layout->group.id)) + { + int prot = 0 ; + if(layout->entry.attributes == SI_FLAG_NONE) + { + prot = SI_FLAG_NONE & SI_MASK_MEM_ATTRIBUTE; + } + else + { + prot = SI_FLAGS_RW & SI_MASK_MEM_ATTRIBUTE; + } + ret = mprotect(GET_PTR(void, m_start_addr, layout->entry.rva + delta), + (size_t)(layout->entry.page_count << SE_PAGE_SHIFT), + prot); + if(ret != 0) + { + SE_TRACE(SE_TRACE_WARNING, "mprotect(rva=%" PRIu64 ", len=%" PRIu64 ", flags=%d) failed\n", + (uint64_t)m_start_addr + layout->entry.rva + delta, + (uint64_t)(layout->entry.page_count << SE_PAGE_SHIFT), + prot); + return SGX_ERROR_UNEXPECTED; + } + } + else + { + uint64_t step = 0; + for(uint32_t j = 0; j < layout->group.load_times; j++) + { + step += layout->group.load_step; + if(SGX_SUCCESS != (ret = set_context_protection(&layout[-layout->group.entry_count], layout, step))) + { + return ret; + } + } + } + } + return SGX_SUCCESS; +} diff --git a/psw/urts/loader.h b/psw/urts/loader.h new file mode 100644 index 0000000000..77b7c194ed --- /dev/null +++ b/psw/urts/loader.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _LOADER_H_ +#define _LOADER_H_ + +#include "se_wrapper.h" +#include "arch.h" +#include "enclave.h" +#include "enclave_creator.h" +#include "section_info.h" +#include "launch_checker.h" +#include "file.h" + +#define GET_RELOC_FAILED ((uint8_t *)-1) + +#if defined(SE_SIM) +#define ENCLAVE_ID_IOCTL m_enclave_id +#else +//only translate enclave id to start address for linux HW mode. +#define ENCLAVE_ID_IOCTL (sgx_enclave_id_t)m_start_addr +#endif + +class BinParser; + +class CLoader: private Uncopyable +{ +public: + CLoader(uint8_t *mapped_file_base, BinParser &parser); + virtual ~CLoader(); + int load_enclave(SGXLaunchToken *lc, int flag, const metadata_t *metadata, le_prd_css_file_t *prd_css_file = NULL, sgx_misc_attribute_t *misc_attr = NULL); + int load_enclave_ex(SGXLaunchToken *lc, bool is_debug, const metadata_t *metadata, le_prd_css_file_t *prd_css_file = NULL, sgx_misc_attribute_t *misc_attr = NULL); + int destroy_enclave(); + sgx_enclave_id_t get_enclave_id() const; + const void* get_start_addr() const; + const secs_t& get_secs() const; + const std::vector& get_tcs_list() const; + void* get_symbol_address(const char* const sym); + int set_memory_protection(); + +private: + int build_mem_region(const section_info_t * const sec_info); + int build_image(SGXLaunchToken * const lc, sgx_attributes_t * const secs_attr, le_prd_css_file_t *prd_css_file, sgx_misc_attribute_t * const misc_attr); + int build_secs(sgx_attributes_t * const secs_attr, sgx_misc_attribute_t * const misc_attr); + int build_context(const uint64_t start_rva, layout_entry_t *layout); + int build_contexts(layout_t *layout_start, layout_t *layout_end, uint64_t delta); + int build_pages(const uint64_t start_rva, const uint64_t size, void *source, const sec_info_t &sinfo, const uint32_t attr); + + bool is_ae(const enclave_css_t *enclave_css); + bool is_metadata_buffer(uint32_t offset, uint32_t size); + bool is_enclave_buffer(uint64_t offset, uint64_t size); + int validate_layout_table(); + int validate_patch_table(); + int validate_metadata(); + int get_debug_flag(const token_t * const launch); + virtual int build_sections(vector *bitmap); + int set_context_protection(layout_t *layout_start, layout_t *layout_end, uint64_t delta); + + uint8_t *m_mapped_file_base; + sgx_enclave_id_t m_enclave_id; + void *m_start_addr; + + // the TCS list + std::vector m_tcs_list; + // the enclave creation parameters + const metadata_t *m_metadata; + secs_t m_secs; + BinParser &m_parser; +}; + +#endif diff --git a/psw/urts/node.cpp b/psw/urts/node.cpp new file mode 100644 index 0000000000..a31ba9c88e --- /dev/null +++ b/psw/urts/node.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "node.h" +#include +#include "enclave.h" +#include "tcs.h" + +template +Node::Node(const T1& k, const T2& v) +{ + this->key = k; + this->value = v; + this->next = NULL; +} + +template +bool Node::InsertNext(Node *p) +{ + if (this->Find(p->key) != NULL) + return false; + p->next = this->next; + this->next = p; + return true; +} + +template +Node* Node::Remove(const T1& k) +{ + Node *c = this, *p = this; + while (c != NULL) { + if (c->key == k) { + p->next = c->next; + break; + } + p = c; + c = c->next; + } + return c; +} + +template +Node* Node::Find(const T1& k) +{ + Node* c = this; + if (c == NULL) return NULL; + while (c != NULL) { + if (c->key == k) + break; + c = c->next; + } + return c; +} + + +template class Node; +template class Node; diff --git a/psw/urts/node.h b/psw/urts/node.h new file mode 100644 index 0000000000..42b178bf9c --- /dev/null +++ b/psw/urts/node.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef NODE_H +#define NODE_H + +#include "uncopyable.h" + +template +class Node: private Uncopyable +{ +public: + T1 key; + T2 value; + Node * next; + + Node(); + Node(const T1& key, const T2& value); + + bool InsertNext(Node* p); + Node* Find(const T1& key); + Node* Remove(const T1& key); +}; + +#endif // NODE_H diff --git a/psw/urts/parser/Makefile b/psw/urts/parser/Makefile new file mode 100644 index 0000000000..c85dfd6141 --- /dev/null +++ b/psw/urts/parser/Makefile @@ -0,0 +1,57 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +SRCS := $(wildcard *.cpp) +SRCS := $(filter-out elfparser.cpp, $(SRCS)) +OBJS := $(SRCS:.cpp=.o) + +TARGET := libenclaveparser.a + +CXXFLAGS += -fPIC -USE_DEBUG_LEVEL -DSE_DEBUG_LEVEL=SE_TRACE_WARNING + +ifneq ($(HOST_OS), darwin) + CXXFLAGS += -Werror +endif + +CXXFLAGS += -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal \ + -I. \ + -I.. + +.PHONY: all +all: $(OBJS) + $(AR) rcs $(TARGET) $^ + +.PHONY: clean +clean: + $(RM) *~ $(OBJS) $(TARGET) diff --git a/psw/urts/parser/binparser.h b/psw/urts/parser/binparser.h new file mode 100644 index 0000000000..7198c05328 --- /dev/null +++ b/psw/urts/parser/binparser.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _BINPARSER_H_ +#define _BINPARSER_H_ + +#include "section.h" +#include "util.h" +#include "se_memcpy.h" +#include "create_param.h" +#include "sgx_error.h" + +#include +#include +#include +using std::vector; +using std::string; + +#define ENCLAVE_MAX_SIZE_32 0xffffffff +#define ENCLAVE_MAX_SIZE_64 0x1fffffffff + +typedef enum _bin_fmt_t +{ + BF_UNKNOWN = 0, + BF_PE32, + BF_PE64, + BF_ELF32, + BF_ELF64 +} bin_fmt_t; + +typedef struct _enclave_diff_info_t +{ +} enclave_diff_info_t; + +class BinParser { +public: + virtual ~BinParser() {} + + virtual sgx_status_t run_parser() = 0; + + virtual bin_fmt_t get_bin_format() const = 0; + + virtual uint64_t get_enclave_max_size() const = 0; + + virtual uint64_t get_metadata_offset() const = 0; + + virtual uint64_t get_metadata_block_size() const = 0; + + virtual const uint8_t* get_start_addr() const = 0; + + // Get a vector of sections to be loaded + virtual const vector

& get_sections() const = 0; + + // Get the TLS section + virtual const Section* get_tls_section() const = 0; + + virtual uint64_t get_symbol_rva(const char* name) const = 0; + + virtual bool get_reloc_bitmap(vector &bitmap) = 0; + + virtual void get_reloc_entry_offset(const char* sec_name, + vector& offsets) = 0; + + // We need to put this method into BinParser class since + // the `global_data_t' is platform-dependent as the parser. + // c.f. global_data.h for more information. + // + // Unfortunately, although the implementation is the same, + // we can't put them here but into the subclasses - + // ElfParsr and PEParser, since the `global_data_t' for + // them are different in terms of size and layout. + virtual bool update_global_data(const create_param_t* const create_param, + uint8_t *data, + uint32_t *data_size) = 0; + + virtual sgx_status_t modify_info(enclave_diff_info_t *enclave_diff_info) = 0; + + virtual sgx_status_t get_info(enclave_diff_info_t *enclave_diff_info) = 0; +}; + +#endif diff --git a/psw/urts/parser/clearvars.h b/psw/urts/parser/clearvars.h new file mode 100644 index 0000000000..ae023924a0 --- /dev/null +++ b/psw/urts/parser/clearvars.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* Make sure the `elfparser.h' is preprocessed again. */ +#ifdef _ELFPARSER_H_ +#undef _ELFPARSER_H_ +#endif + +/* Anding using the ELF class we want. */ +#ifdef __ELF_NATIVE_CLASS +#undef __ELF_NATIVE_CLASS +#endif + +#ifdef RTS_SYSTEM_WORDSIZE +#undef RTS_SYSTEM_WORDSIZE +#endif + +/* We will rename the class `ElfParser'. */ +#ifdef ElfParser +#undef ElfParser +#endif diff --git a/psw/urts/parser/elf32parser.cpp b/psw/urts/parser/elf32parser.cpp new file mode 100644 index 0000000000..d29d8736f0 --- /dev/null +++ b/psw/urts/parser/elf32parser.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "elf32parser.h" + +#include "elfparser.cpp" diff --git a/psw/urts/parser/elf32parser.h b/psw/urts/parser/elf32parser.h new file mode 100644 index 0000000000..ff72f85802 --- /dev/null +++ b/psw/urts/parser/elf32parser.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef ELF32_PARSER_H_ +#define ELF32_PARSER_H_ + +#include "clearvars.h" + +/* Set the ELF native class to 32-bit. */ +#define __ELF_NATIVE_CLASS 32 + +#ifndef TD_SUPPORT_MULTI_PLATFORM +#define TD_SUPPORT_MULTI_PLATFORM +#endif +#define RTS_SYSTEM_WORDSIZE 32 + +/* Change the generic class name `ElfParser' to `Elf32Parser'. */ +#define ElfParser Elf32Parser +#include "elfparser.h" + +#endif diff --git a/psw/urts/parser/elf64parser.cpp b/psw/urts/parser/elf64parser.cpp new file mode 100644 index 0000000000..e02d91344b --- /dev/null +++ b/psw/urts/parser/elf64parser.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "elf64parser.h" + +#include "elfparser.cpp" diff --git a/psw/urts/parser/elf64parser.h b/psw/urts/parser/elf64parser.h new file mode 100644 index 0000000000..51119c8bc1 --- /dev/null +++ b/psw/urts/parser/elf64parser.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef ELF64_PARSER_H_ +#define ELF64_PARSER_H_ + +#include "clearvars.h" + +/* Set the ELF native class to 64-bit. */ +#define __ELF_NATIVE_CLASS 64 + +#ifndef TD_SUPPORT_MULTI_PLATFORM +#define TD_SUPPORT_MULTI_PLATFORM +#endif +#define RTS_SYSTEM_WORDSIZE 64 + +/* Change the generic class name `ElfParser' to `Elf64Parser'. */ +#define ElfParser Elf64Parser +#include "elfparser.h" + +#endif diff --git a/psw/urts/parser/elfparser.cpp b/psw/urts/parser/elfparser.cpp new file mode 100644 index 0000000000..aa2f7974fc --- /dev/null +++ b/psw/urts/parser/elfparser.cpp @@ -0,0 +1,850 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "elfparser.h" +#include "cpputil.h" +#include "se_trace.h" +#include "se_memcpy.h" +#include "global_data.h" + +#define META_SECTION_ALIGNMENT 1 /*metadata section no alignment*/ + +namespace { +/** the callback function to filter a section. + * + * @shstrtab: the section header string table + * @shdr: the current section header to be examined + * @user_data: user supplied data for the callback + * + * @return: true if current section header is what we are looking for. + */ +typedef bool (* section_filter_f)(const char* shstrtab, + const ElfW(Shdr)* shdr, + const void* user_data); + +bool compare_section_name(const char* shstrtab, + const ElfW(Shdr)* shdr, + const void* user_data) +{ + // `shstrtab + shdr->sh_name' is the section name. + return (!strcmp(shstrtab + shdr->sh_name, (const char*)user_data)); +} + +bool compare_section_addr(const char* shstrtab, + const ElfW(Shdr)* shdr, + const void* user_data) +{ + UNUSED(shstrtab); + return (shdr->sh_addr == (ElfW(Addr))(size_t)user_data); +} + +const ElfW(Shdr)* get_section(const ElfW(Ehdr) *elf_hdr, + section_filter_f f, + const void* user_data) +{ + const ElfW(Shdr) *shdr = GET_PTR(ElfW(Shdr), elf_hdr, elf_hdr->e_shoff); + assert(sizeof(ElfW(Shdr)) == elf_hdr->e_shentsize); + + // section header string table + const char *shstrtab = GET_PTR(char, elf_hdr, shdr[elf_hdr->e_shstrndx].sh_offset); + + for (unsigned idx = 0; idx < elf_hdr->e_shnum; ++idx, ++shdr) + { + SE_TRACE(SE_TRACE_DEBUG, "section [%u] %s: sh_addr = %x, sh_size = %x, sh_offset = %x, sh_name = %x\n", + idx, shstrtab + shdr->sh_name, shdr->sh_addr, shdr->sh_size, shdr->sh_offset, shdr->sh_name); + if (f(shstrtab, shdr, user_data)) + return shdr; + } + + return NULL; +} + +const ElfW(Shdr)* get_section_by_name(const ElfW(Ehdr) *elf_hdr, const char *name) +{ + return get_section(elf_hdr, compare_section_name, name); +} + +const ElfW(Shdr)* get_section_by_addr(const ElfW(Ehdr) *elf_hdr, ElfW(Addr) start_addr) +{ + return get_section(elf_hdr, compare_section_addr, (const void*)(size_t)start_addr); +} + +template +const T* get_section_raw_data(const ElfW(Ehdr) *elf_hdr, ElfW(Addr) start_addr) +{ + const ElfW(Shdr)* shdr = get_section_by_addr(elf_hdr, start_addr); + if (shdr == NULL) + return NULL; + + return GET_PTR(T, elf_hdr, shdr->sh_offset); +} + +bool validate_elf_header(const ElfW(Ehdr) *elf_hdr) +{ + // validate magic number + if (memcmp(&elf_hdr->e_ident, ELFMAG, SELFMAG)) + return false; + +#if RTS_SYSTEM_WORDSIZE == 64 + if (ELFCLASS64 != elf_hdr->e_ident[EI_CLASS]) + return false; +#else + if (ELFCLASS32 != elf_hdr->e_ident[EI_CLASS]) + return false; +#endif + + if (ELFDATA2LSB!= elf_hdr->e_ident[EI_DATA]) + return false; + + if (EV_CURRENT != elf_hdr->e_ident[EI_VERSION]) + return false; + + if (ET_DYN != elf_hdr->e_type) + return false; + + if (sizeof(ElfW(Phdr)) != elf_hdr->e_phentsize) + return false; + + return true; +} + +bool parse_dyn(const ElfW(Ehdr) *elf_hdr, ElfW(Dyn)* dyn_info) +{ + const ElfW(Phdr) *prg_hdr = GET_PTR(ElfW(Phdr), elf_hdr, elf_hdr->e_phoff); + bool has_dyn = false; + + for (unsigned idx = 0; idx < elf_hdr->e_phnum; ++idx, ++prg_hdr) + { + if (PT_DYNAMIC == prg_hdr->p_type) + { + const ElfW(Dyn) *dyn_entry = GET_PTR(ElfW(Dyn), elf_hdr, prg_hdr->p_offset); + + // parse dynamic segment + // An entry with a DT_NULL tag marks the end. + while (dyn_entry->d_tag != DT_NULL) + { + SE_TRACE(SE_TRACE_DEBUG, "dynamic tag = %x, ptr = %x\n", dyn_entry->d_tag, dyn_entry->d_un.d_ptr); + + if (dyn_entry->d_tag < DT_NUM) + { + memcpy_s(&dyn_info[dyn_entry->d_tag], sizeof(ElfW(Dyn)), dyn_entry, sizeof(ElfW(Dyn))); + } + else if (dyn_entry->d_tag > DT_ADDRRNGLO && dyn_entry->d_tag <= DT_ADDRRNGHI) + { + memcpy_s(&dyn_info[DT_ADDRTAGIDX(dyn_entry->d_tag) + DT_NUM], sizeof(ElfW(Dyn)), dyn_entry, sizeof(ElfW(Dyn))); + } + + dyn_entry++; + has_dyn = true; + } + + return has_dyn; + } + } + + return false; +} + +/** Check whether there are undefined symbols and save the address + * for a few reserved symbols. + * + * ELF format defined two symbol tables, `.symtab' and `.dynsym'. + * + * `.symtab' is non-allocable, and might be stripped. + * `.dynsym' is allocable, and only contains global symbols. + * + * We only need to search `.dynsym' for undefined symbols. + */ +bool check_symbol_table(const ElfW(Ehdr) *elf_hdr, const ElfW(Dyn) *dyn_info, + map& sym_table) +{ + const ElfW(Shdr) *sh_symtab = get_section_by_addr(elf_hdr, dyn_info[DT_SYMTAB].d_un.d_ptr); + + if (sh_symtab == NULL) + { + // We must at least have "enclave_entry" + SE_TRACE(SE_TRACE_WARNING, "There is no .dynsym section"); + return false; + } + + if (sh_symtab->sh_entsize == 0) + { + SE_TRACE(SE_TRACE_WARNING, "In section .dynsym, sh_entsize is 0."); + return false; + } + + const ElfW(Sym) *symtab = GET_PTR(ElfW(Sym), elf_hdr, sh_symtab->sh_offset); + uint32_t sym_num = (uint32_t)(sh_symtab->sh_size/sh_symtab->sh_entsize); + const char *strtab = get_section_raw_data(elf_hdr, dyn_info[DT_STRTAB].d_un.d_ptr); + + // We only store "enclave_entry", "g_global_data_sim" and "g_peak_heap_used". + // To export new symbols, add them here. + // + // "g_global_data_sim" is needed so that we can check that whether + // an simulated enclave is given when running an HW loader. + const char* str[] = { "enclave_entry", "g_global_data_sim", "g_peak_heap_used", "g_global_data" }; + + // The first entry is reserved, and must be all zeros + for (uint32_t idx = 1; idx < sym_num; ++idx) + { + // st_name == 0 indicates the symble table entry has no name. + if (symtab[idx].st_name == 0) continue; + + const char* sym = strtab + symtab[idx].st_name; + if (sym == NULL) + { + SE_TRACE(SE_TRACE_WARNING, "Malformed enclave with NULL symbol name\n"); + return false; + } + + if (SHN_UNDEF == symtab[idx].st_shndx + && STB_WEAK != ELFW(ST_BIND)(symtab[idx].st_info)) + { + SE_TRACE(SE_TRACE_WARNING, "symbol '%s' is undefined\n", sym); + return false; + } + +#define SYMBOL_NUM (ARRAY_LENGTH(str)) + for (size_t i = 0; i < SYMBOL_NUM; ++i) + { + if (0 == strcmp(str[i], sym)) + { + sym_table[sym] = (uint64_t)symtab[idx].st_value; + } + } + } + + // If the enclave if compiled/linked with -fpie/-pie, and setting the + // enclave entry to `enclave_entry', the `st_name' for `enclave_entry' + // will be 0 in `.dynsym'. + map::const_iterator it = sym_table.find("enclave_entry"); + if (it == sym_table.end()) + { + sym_table["enclave_entry"] = (uint64_t)elf_hdr->e_entry; + } + + return true; +} + +bool do_validate_reltab(const ElfW(Rel) *reltab, size_t nr_rel) +{ + if (reltab == NULL && nr_rel != 0) return false; + +#if RTS_SYSTEM_WORDSIZE == 64 + const ElfW(Rel) *rela = reltab; + + for (unsigned idx = 0; idx < nr_rel; idx++, rela++) + { + switch (ELF64_R_TYPE(rela->r_info)) + + { + case R_X86_64_RELATIVE: + break; + + case R_X86_64_GLOB_DAT: + case R_X86_64_JUMP_SLOT: + case R_X86_64_64: + break; + + case R_X86_64_NONE: + break; + + case R_X86_64_DTPMOD64: + case R_X86_64_DTPOFF64: + case R_X86_64_TPOFF64: + break; +#else + const ElfW(Rel) *rel = reltab; + + for (unsigned idx = 0; idx < nr_rel; idx++, rel++) + { + switch (ELF32_R_TYPE(rel->r_info)) + { + case R_386_RELATIVE: /* B+A */ + break; + + case R_386_GLOB_DAT: + case R_386_JMP_SLOT: /* S */ + break; + + case R_386_32: /* S+A */ + break; + + case R_386_PC32: /* S+A-P */ + break; + + case R_386_NONE: + break; + + case R_386_TLS_DTPMOD32: + break; + + case R_386_TLS_DTPOFF32: + break; + + case R_386_TLS_TPOFF: + break; + + case R_386_TLS_TPOFF32: + break; +#endif + + default: /* unsupported relocs */ + SE_TRACE(SE_TRACE_WARNING, "unsupported relocation type detected\n"); + return false; + } + } + + return true; +} + +bool validate_reltabs(const ElfW(Ehdr) *elf_hdr, const ElfW(Dyn) *dyn_info) +{ +#if RTS_SYSTEM_WORDSIZE == 64 + // The relocation struct must be rela on x64. + if (dyn_info[DT_REL].d_un.d_ptr) + { + SE_TRACE(SE_TRACE_WARNING, "Rel struct detected on x64\n"); + return false; + } +#else + // The relocation struct must be rel on x86. + if (dyn_info[DT_RELA].d_un.d_ptr) + { + SE_TRACE(SE_TRACE_WARNING, "Rela struct detected on x86\n"); + return false; + } +#endif + + const ElfW(Rel) *reltab = get_section_raw_data(elf_hdr, dyn_info[RTS_DT_REL].d_un.d_ptr); + const ElfW(Word) reltab_sz = (ElfW(Word))dyn_info[RTS_DT_RELSZ].d_un.d_val; + + const ElfW(Rel) *jmpreltab = get_section_raw_data(elf_hdr, dyn_info[DT_JMPREL].d_un.d_ptr); + const ElfW(Word) jmpreltab_sz = (ElfW(Word))dyn_info[DT_PLTRELSZ].d_un.d_val; + + return (do_validate_reltab(reltab, reltab_sz / sizeof(ElfW(Rel))) + && do_validate_reltab(jmpreltab, jmpreltab_sz / sizeof(ElfW(Rel)))); +} + +bool has_ctor_section(const ElfW(Ehdr) *elf_hdr) +{ + const ElfW(Shdr) *shdr = get_section_by_name(elf_hdr, ".ctors"); + if (NULL == shdr) return false; + + se_trace(SE_TRACE_ERROR, "ERROR: .ctors section is found, global initializers will not be invoked correctly!\n"); + return true; +} + +inline bool is_tls_segment(const ElfW(Phdr)* prg_hdr) +{ + return (PT_TLS == prg_hdr->p_type); +} + +bool get_meta_property(const uint8_t *start_addr, const ElfW(Ehdr) *elf_hdr, uint64_t &meta_offset, uint64_t &meta_block_size) +{ + const ElfW(Shdr)* shdr = get_section_by_name(elf_hdr, ".note.sgxmeta"); + if (shdr == NULL) + { + se_trace(SE_TRACE_ERROR, "ERROR: The enclave image should have '.note.sgxmeta' section\n"); + return false; + } + + /* We require that enclaves should have .note.sgxmeta section to store the metadata information + * We limit this section is used for metadata only and ISV should not extend this section. + * + * .note.sgxmeta layout: + * + * | namesz | + * | metadata size | + * | type | + * | name | + * | metadata | + */ + + if (shdr->sh_addralign != META_SECTION_ALIGNMENT) + { + se_trace(SE_TRACE_ERROR, "ERROR: The '.note.sgxmeta' section must be 4byte aligned\n"); + return false; + } + + const ElfW(Note) *note = GET_PTR(ElfW(Note), start_addr, shdr->sh_offset); + assert(note != NULL); + + if (shdr->sh_size != ROUND_TO(sizeof(ElfW(Note)) + note->namesz + note->descsz, META_SECTION_ALIGNMENT)) + { + se_trace(SE_TRACE_ERROR, "ERROR: The '.note.sgxmeta' section size is not correct.\n"); + return false; + } + + if (memcmp(GET_PTR(void, start_addr, shdr->sh_offset + sizeof(ElfW(Note))), "sgx_metadata", note->namesz)) + { + se_trace(SE_TRACE_ERROR, "ERROR: The note in the '.note.sgxmeta' section must be named as \"sgx_metadata\"\n"); + return false; + } + + meta_offset = static_cast(shdr->sh_offset + sizeof(ElfW(Note)) + note->namesz); + meta_block_size = note->descsz; + return true; +} + +bool validate_segment(const ElfW(Ehdr) *elf_hdr, uint64_t len) +{ + const ElfW(Phdr) *prg_hdr = GET_PTR(ElfW(Phdr), elf_hdr, elf_hdr->e_phoff); + assert(sizeof(ElfW(Phdr)) == elf_hdr->e_phentsize); + + std::vector< std::pair > load_seg(elf_hdr->e_phnum, std::make_pair(0, 0)); + int k = 0; + + for (int idx = 0; idx < elf_hdr->e_phnum; idx++, prg_hdr++) + { + /* Validate the size of the buffer */ + if (len < (uint64_t)prg_hdr->p_offset + prg_hdr->p_filesz) + return false; + + if (PT_LOAD == prg_hdr->p_type) + { + // The default align is max page size. On x86-64, the max page size is 2M, but EPC page size is 4K, + // so in x86-64, we just treat it as EPC page size. The (2M - 4K) size is not eadded. We leave it + // as a hole. + if (!IS_PAGE_ALIGNED(prg_hdr->p_align)) + { + SE_TRACE(SE_TRACE_WARNING, "A segment is not PAGE aligned, alignment = %x\n", prg_hdr->p_align); + return false; + } + + // Verify the overlap of segment. we don't verify here, because a well compiled file has no overlapped segment. + load_seg[k].first = prg_hdr->p_vaddr; + load_seg[k].second = prg_hdr->p_vaddr + ROUND_TO(prg_hdr->p_memsz, prg_hdr->p_align) - 1; + + for (int j = 0; j < k; j++) + { + if (is_overlap(load_seg[k], load_seg[j])) + { + SE_TRACE(SE_TRACE_WARNING, "there is overlap segment [%x : %x] [%x : %x]\n", + load_seg[k].first, load_seg[k].second, load_seg[j].first, load_seg[j].second); + return false; + } + + } + + k++; + } + } + return true; +} + +bool get_bin_fmt(const ElfW(Ehdr) *elf_hdr, bin_fmt_t& bf) +{ + switch(elf_hdr->e_machine) + { +#if RTS_SYSTEM_WORDSIZE == 32 + case EM_386: + bf = BF_ELF32; + return true; +#endif + +#if RTS_SYSTEM_WORDSIZE == 64 + case EM_X86_64: + bf = BF_ELF64; + return true; +#endif + } + + return false; +} + +si_flags_t page_attr_to_si_flags(uint32_t page_attr) +{ + si_flags_t res = SI_FLAG_REG; + + if (page_attr & PF_R) + res |= SI_FLAG_R; + + if (page_attr & PF_W) + res |= SI_FLAG_W; + + if (page_attr & PF_X) + res |= SI_FLAG_X; + + return res; +} + +Section* build_section(const uint8_t* raw_data, uint64_t size, uint64_t virtual_size, + uint64_t rva, uint32_t page_attr) +{ + si_flags_t sf = page_attr_to_si_flags(page_attr); + + if (sf != SI_FLAG_REG) + return new Section(raw_data, size, virtual_size, rva, sf); + + return NULL; +} + +bool build_regular_sections(const uint8_t* start_addr, + vector
& sections, + const Section*& tls_sec, + uint64_t& metadata_offset, + uint64_t& metadata_block_size) +{ + const ElfW(Ehdr) *elf_hdr = (const ElfW(Ehdr) *)start_addr; + const ElfW(Phdr) *prg_hdr = GET_PTR(ElfW(Phdr), start_addr, elf_hdr->e_phoff); + uint64_t virtual_size = 0, alignment = 0, aligned_virtual_size = 0; + + if (get_meta_property(start_addr, elf_hdr, metadata_offset, metadata_block_size) == false) + return false; + + for (unsigned idx = 0; idx < elf_hdr->e_phnum; ++idx, ++prg_hdr) + { + Section* sec = NULL; + + switch (prg_hdr->p_type) + { + case PT_LOAD: + sec = build_section(GET_PTR(uint8_t, start_addr, prg_hdr->p_offset), + (uint64_t)prg_hdr->p_filesz, ROUND_TO_PAGE((uint64_t)prg_hdr->p_memsz), + (uint64_t)prg_hdr->p_vaddr, (uint32_t) prg_hdr->p_flags); + break; + + case PT_TLS: + virtual_size = (uint64_t)prg_hdr->p_memsz; + alignment = (uint64_t)prg_hdr->p_align; + + /* according to ELF spec, alignment equals zero or one means no align requirement */ + if (alignment == 0 || alignment == 1) + aligned_virtual_size = virtual_size; + else + aligned_virtual_size = (virtual_size + alignment - 1) & (~(alignment - 1)); + + sec = build_section(GET_PTR(uint8_t, start_addr, prg_hdr->p_offset), + (uint64_t)prg_hdr->p_filesz, aligned_virtual_size, + (uint64_t)prg_hdr->p_vaddr, (uint32_t) prg_hdr->p_flags); + break; + + default: + continue; + } + + if (sec == NULL) + return false; + + /* We've filtered segments that are not of PT_LOAD or PT_TLS type. */ + if (!is_tls_segment(prg_hdr)) + { + /* A PT_LOAD segment. */ + sections.push_back(sec); + continue; + } + + /* It is a TLS segment. */ + tls_sec = sec; + } + + return true; +} + +const Section* get_max_rva_section(const vector sections) +{ + size_t sec_size = sections.size(); + + if (sec_size == 0) + return NULL; + + const Section* psec = sections[0]; + for (size_t idx = 1; idx < sec_size; ++idx) + { + if (sections[idx]->get_rva() > psec->get_rva()) + psec = sections[idx]; + } + + return psec; +} +} + +ElfParser::ElfParser (const uint8_t* start_addr, uint64_t len) + :m_start_addr(start_addr), m_len(len), m_bin_fmt(BF_UNKNOWN), + m_tls_section(NULL), m_metadata_offset(0), m_metadata_block_size(0) +{ + memset(&m_dyn_info, 0, sizeof(m_dyn_info)); +} + +sgx_status_t ElfParser::run_parser() +{ + /* We only need to run the parser once. */ + if (m_sections.size() != 0) return SGX_SUCCESS; + + const ElfW(Ehdr) *elf_hdr = (const ElfW(Ehdr) *)m_start_addr; + if (elf_hdr == NULL || m_len < sizeof(ElfW(Ehdr))) + return SGX_ERROR_INVALID_ENCLAVE; + + /* Check elf header*/ + if (!validate_elf_header(elf_hdr)) + return SGX_ERROR_INVALID_ENCLAVE; + + /* Get and check machine mode */ + if (!get_bin_fmt(elf_hdr, m_bin_fmt)) + return SGX_ERROR_MODE_INCOMPATIBLE; + + /* Check if there is any overlap segment, and make sure the segment is 1 page aligned; + * TLS segment must exist. + */ + if (!validate_segment(elf_hdr, m_len)) + return SGX_ERROR_INVALID_ENCLAVE; + + if (!parse_dyn(elf_hdr, &m_dyn_info[0])) + return SGX_ERROR_INVALID_ENCLAVE; + + /* Check if there is any undefined symbol */ + if (!check_symbol_table(elf_hdr, m_dyn_info, m_sym_table)) + { + return SGX_ERROR_UNDEFINED_SYMBOL; + } + + /* Check if there is unexpected relocation type */ + if (!validate_reltabs(elf_hdr, m_dyn_info)) + return SGX_ERROR_INVALID_ENCLAVE; + + /* Check if there is .ctor section */ + if (has_ctor_section(elf_hdr)) + return SGX_ERROR_INVALID_ENCLAVE; + + /* build regular sections */ + if (build_regular_sections(m_start_addr, m_sections, m_tls_section, m_metadata_offset, m_metadata_block_size)) + return SGX_SUCCESS; + else + return SGX_ERROR_INVALID_ENCLAVE; +} + +ElfParser::~ElfParser() +{ + delete_ptrs_from_container(m_sections); + if (m_tls_section) delete m_tls_section; +} + +bin_fmt_t ElfParser::get_bin_format() const +{ + return m_bin_fmt; +} + +uint64_t ElfParser::get_enclave_max_size() const +{ + if(m_bin_fmt == BF_ELF64) + return ENCLAVE_MAX_SIZE_64; + else + return ENCLAVE_MAX_SIZE_32; +} + +uint64_t ElfParser::get_metadata_offset() const +{ + return m_metadata_offset; +} + +uint64_t ElfParser::get_metadata_block_size() const +{ + return m_metadata_block_size; +} + + +const uint8_t* ElfParser::get_start_addr() const +{ + return m_start_addr; +} + +const vector
& ElfParser::get_sections() const +{ + return m_sections; +} + +const Section* ElfParser::get_tls_section() const +{ + return m_tls_section; +} + +uint64_t ElfParser::get_symbol_rva(const char* name) const +{ + map::const_iterator it = m_sym_table.find(name); + if (it != m_sym_table.end()) + return it->second; + else + return 0; +} + +bool ElfParser::get_reloc_bitmap(vector& bitmap) +{ + // Clear the `bitmap' so that it is in a known state + bitmap.clear(); + + if (!m_dyn_info[DT_TEXTREL].d_tag) + return true; + + const ElfW(Ehdr) *elf_hdr = (const ElfW(Ehdr) *)m_start_addr; + const ElfW(Rel) *rel[4] = { NULL, NULL, NULL, NULL }; + + if (m_dyn_info[DT_JMPREL].d_tag) + { + rel[2] = get_section_raw_data(elf_hdr, m_dyn_info[DT_JMPREL].d_un.d_ptr); + rel[3] = GET_PTR(const ElfW(Rel), rel[2], m_dyn_info[DT_PLTRELSZ].d_un.d_val); + } + + if (m_dyn_info[RTS_DT_REL].d_tag) + { + rel[0] = get_section_raw_data(elf_hdr, m_dyn_info[RTS_DT_REL].d_un.d_ptr); + rel[1] = GET_PTR(const ElfW(Rel), rel[0], m_dyn_info[RTS_DT_RELSZ].d_un.d_val); + assert(sizeof(ElfW(Rel)) == m_dyn_info[RTS_DT_RELENT].d_un.d_val); + } + + // The enclave size mapped in memory is calculated by + // sec->get_rva() + sec->virtual_size(); + // where the `sec' is the section with maximum RVA value. + uint64_t image_size = 0; + const Section* max_rva_sec = get_max_rva_section(this->m_sections); + if (max_rva_sec == NULL) + return false; + + image_size = max_rva_sec->get_rva() + max_rva_sec->virtual_size(); + + // NOTE: + // Current enclave size is not beyond 64G, so the type-casting from (uint64>>15) to (size_t) is OK. + // In the future, if the max enclave size is extended to beyond 1<<49, this type-casting will not work. + // It only impacts the enclave signing process. (32bit signing tool to sign 64 bit enclaves) + + // allocate bitmap + bitmap.resize((size_t)((((image_size + (SE_PAGE_SIZE - 1)) >> SE_PAGE_SHIFT) + 7) / 8)); + + for (unsigned idx = 0; idx < ARRAY_LENGTH(rel); idx += 2) + { + const ElfW(Rel) *rel_entry = rel[idx], *rel_end = rel[idx+1]; + if (NULL == rel_entry) + continue; + + for (; rel_entry < rel_end; rel_entry++) + { +#if RTS_SYSTEM_WORDSIZE == 64 + if (ELF64_R_TYPE(rel_entry->r_info) == R_X86_64_NONE) +#else + if (ELF32_R_TYPE(rel_entry->r_info) == R_386_NONE) +#endif + continue; + + ElfW(Addr) reloc_addr = rel_entry->r_offset; + uint64_t page_frame = (uint64_t)(reloc_addr >> SE_PAGE_SHIFT); + + // NOTE: + // Current enclave size is not beyond 64G, so the type-casting from (uint64>>15) to (size_t) is OK. + // In the future, if the max enclave size is extended to beyond 1<<49, this type-casting will not work. + // It only impacts the enclave signing process. (32bit signing tool to sign 64 bit enclaves) + + // If there is more than one relocation in one page, then "|" works as there + // is only one relocation in one page. + bitmap[(size_t)(page_frame/8)] = (uint8_t)(bitmap[(size_t)(page_frame/8)] | (uint8_t)(1 << (page_frame % 8))); + + // Check if the relocation across boundary + if ((reloc_addr & (SE_PAGE_SIZE - 1)) > (SE_PAGE_SIZE - sizeof(sys_word_t))) + { + page_frame++; + bitmap[(size_t)(page_frame/8)] = (uint8_t)(bitmap[(size_t)(page_frame/8)] | (uint8_t)(1 << (page_frame % 8))); + } + } + } + + return true; +} + +void ElfParser::get_reloc_entry_offset(const char* sec_name, vector& offsets) +{ + if (sec_name == NULL) + return; + + const ElfW(Ehdr) *ehdr = (const ElfW(Ehdr) *)m_start_addr; + const ElfW(Shdr) *shdr = get_section_by_name(ehdr, sec_name); + + if (shdr == NULL) + return; + + /* find the start and end offset of the target section */ + const uint64_t start = shdr->sh_addr; + const uint64_t end = start + shdr->sh_size; + + offsets.clear(); + SE_TRACE(SE_TRACE_DEBUG, "found section '%s' - offset %#lx, size %#lx\n", + sec_name, (long)start, (long)shdr->sh_size); + + /* iterate sections to find the relocs */ + shdr = GET_PTR(ElfW(Shdr), m_start_addr, ehdr->e_shoff); + for (unsigned idx = 0; idx < ehdr->e_shnum; ++idx, ++shdr) + { + if (shdr->sh_type != SHT_RELA && + shdr->sh_type != SHT_REL) + continue; + + uint64_t rel_size = shdr->sh_size; + uint64_t rel_offset = shdr->sh_offset; + uint64_t nr_rel = rel_size / shdr->sh_entsize; + + /* for each reloc, check its target address */ + const ElfW(Rel) *rel = GET_PTR(ElfW(Rel), m_start_addr, rel_offset); + for (; nr_rel > 0; --nr_rel, ++rel) + { + if (rel->r_offset >= start && rel->r_offset < end) + { + uint64_t offset = DIFF64(rel, m_start_addr); + SE_TRACE(SE_TRACE_DEBUG, "found one reloc at offset %#lx\n", offset); + offsets.push_back(offset); + } + } + } +} + +#include "update_global_data.hxx" + +bool ElfParser::update_global_data(const create_param_t* const create_param, + uint8_t *data, + uint32_t *data_size) +{ + if(*data_size < sizeof(global_data_t)) + { + *data_size = sizeof(global_data_t); + return false; + } + do_update_global_data(create_param, (global_data_t *)data); + *data_size = sizeof(global_data_t); + return true; +} + +sgx_status_t ElfParser::modify_info(enclave_diff_info_t *enclave_diff_info) +{ + UNUSED(enclave_diff_info); + return SGX_SUCCESS; +} + +sgx_status_t ElfParser::get_info(enclave_diff_info_t *enclave_diff_info) +{ + UNUSED(enclave_diff_info); + return SGX_SUCCESS; +} diff --git a/psw/urts/parser/elfparser.h b/psw/urts/parser/elfparser.h new file mode 100644 index 0000000000..21f5582b47 --- /dev/null +++ b/psw/urts/parser/elfparser.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _ELFPARSER_H_ +#define _ELFPARSER_H_ + +#include "binparser.h" +#include "elf_util.h" + +#include +#include +#include +#include + +using std::map; +using std::string; + +class ElfParser : public BinParser, private Uncopyable { +public: + // The `start_addr' cannot be NULL + ElfParser(const uint8_t* start_addr, uint64_t len); + ~ElfParser(); + + // Do the parsing job - use it before calling other methods + sgx_status_t run_parser(); + + bin_fmt_t get_bin_format() const; + + uint64_t get_enclave_max_size() const; + + uint64_t get_metadata_offset() const; + + uint64_t get_metadata_block_size() const; + + const uint8_t* get_start_addr() const; + + // The `section' here is a section in PE's concept. + // It is in fact a `segment' in ELF's view. + const vector
& get_sections() const; + const Section* get_tls_section() const; + uint64_t get_symbol_rva(const char* name) const; + + bool get_reloc_bitmap(vector &bitmap); + bool update_global_data(const create_param_t* const create_param, + uint8_t *data, + uint32_t *data_size); + + // Get the offsets (relative to the base address) of the relocation + // entries, of which the relocation address falls into the range of + // section identified by `sec_name'. + // + // The relocation entry is of type: + // - Elf64_Rel on x86_64, + // - Elf32_Rel on x86. + // + // To check whether current enclave has any TEXTREL: + // get_reloc_entry_offset(".text", offsets); + void get_reloc_entry_offset(const char* sec_name, + vector& offsets); + + sgx_status_t modify_info(enclave_diff_info_t *enclave_diff_info); + sgx_status_t get_info(enclave_diff_info_t *enclave_diff_info); + +private: + const uint8_t* m_start_addr; + uint64_t m_len; + bin_fmt_t m_bin_fmt; + vector
m_sections; + const Section* m_tls_section; + uint64_t m_metadata_offset; + uint64_t m_metadata_block_size;/*multiple metadata block size*/ + + ElfW(Dyn) m_dyn_info[DT_NUM + DT_ADDRNUM]; + + // A map from symbol name to its RVA + map m_sym_table; +}; + +#endif diff --git a/psw/urts/parser/parserfactory.cpp b/psw/urts/parser/parserfactory.cpp new file mode 100644 index 0000000000..3e2c7c0c2d --- /dev/null +++ b/psw/urts/parser/parserfactory.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include "parserfactory.h" +#include "util.h" + +#include "elf32parser.h" +#include "elf64parser.h" + +namespace { + bin_fmt_t check_elf_format(const uint8_t* start_addr, uint64_t len) + { + assert(start_addr != NULL); + const Elf32_Ehdr* ehdr = (const Elf32_Ehdr *) start_addr; + + if (len < sizeof(Elf32_Ehdr)) + return BF_UNKNOWN; + + if (strncmp((const char *)ehdr->e_ident, ELFMAG, SELFMAG) != 0) + return BF_UNKNOWN; + + switch (ehdr->e_ident[EI_CLASS]) + { + case ELFCLASS32: return BF_ELF32; + case ELFCLASS64: return BF_ELF64; + default: return BF_UNKNOWN; + } + } +} + +namespace binparser { + /* Note, the `start_addr' should NOT be NULL! */ + BinParser* get_parser(const uint8_t* start_addr, uint64_t len) + { + assert(start_addr != NULL); + + bin_fmt_t bf = BF_UNKNOWN; + + bf = check_elf_format(start_addr, len); + if (bf == BF_ELF64) return new Elf64Parser(start_addr, len); + + /* Doesn't matter whether it is an ELF32 shared library or not, + * here we just make sure that the factory method won't return + * NULL. + */ + return new Elf32Parser(start_addr, len); + } +} diff --git a/psw/urts/parser/parserfactory.h b/psw/urts/parser/parserfactory.h new file mode 100644 index 0000000000..c99a77c4a8 --- /dev/null +++ b/psw/urts/parser/parserfactory.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _PARSER_FACTORY_H_ +#define _PARSER_FACTORY_H_ + +#include "binparser.h" + + +namespace binparser { +// Create a parser instance `p' automatically. +// The caller needs to destroy the instance with `delete p'. +// +// Return NULL if no suitable parser found. +BinParser* get_parser(const uint8_t* start_addr, uint64_t len); +} + +#endif diff --git a/psw/urts/parser/section.cpp b/psw/urts/parser/section.cpp new file mode 100644 index 0000000000..9b2a67be34 --- /dev/null +++ b/psw/urts/parser/section.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "section.h" + +#include +#include + +Section::Section(const uint8_t* start_addr, uint64_t size, uint64_t virt_size, + uint64_t rva, si_flags_t sf) + :m_start_addr(start_addr), m_raw_data_size(size), m_rva(rva), + m_virtual_size(virt_size), m_si_flag(sf) +{} + +Section::~Section() +{ +} + +const uint8_t* Section::raw_data(void) const +{ + return m_start_addr; +} + +uint64_t Section::raw_data_size(void) const +{ + return m_raw_data_size; +} + +uint64_t Section::get_rva(void) const +{ + return m_rva; +} + +uint64_t Section::virtual_size(void) const +{ + return m_virtual_size; +} + +si_flags_t Section::get_si_flags(void) const +{ + return m_si_flag; +} diff --git a/psw/urts/parser/section.h b/psw/urts/parser/section.h new file mode 100644 index 0000000000..c54280e03f --- /dev/null +++ b/psw/urts/parser/section.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SECTION_H_ +#define _SECTION_H_ + +#include "arch.h" // for `si_flag_t' etc. + +#include "uncopyable.h" +#include + +class Section : private Uncopyable +{ +public: + Section(const uint8_t* start_addr, uint64_t size, uint64_t virt_size, + uint64_t rva, si_flags_t sf); + ~Section(); + + const uint8_t* raw_data(void) const; + uint64_t raw_data_size(void) const; + + uint64_t get_rva(void) const; + + // The virtual size is rounded to align with 1-page. + uint64_t virtual_size(void) const; + + si_flags_t get_si_flags(void) const; + +private: + const uint8_t* m_start_addr; + uint64_t m_raw_data_size; + uint64_t m_rva; + uint64_t m_virtual_size; + si_flags_t m_si_flag; +}; + +#endif diff --git a/psw/urts/parser/update_global_data.hxx b/psw/urts/parser/update_global_data.hxx new file mode 100644 index 0000000000..236a3a3d70 --- /dev/null +++ b/psw/urts/parser/update_global_data.hxx @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +namespace { + void do_update_global_data(const create_param_t* const create_param, + global_data_t* global_data) + { + global_data->enclave_size = (sys_word_t)create_param->enclave_size; + global_data->heap_offset = (sys_word_t)create_param->heap_offset; + global_data->heap_size = (sys_word_t)create_param->heap_max_size; + global_data->thread_policy = (uint32_t)create_param->tcs_policy; + thread_data_t *thread_data = &global_data->td_template; + thread_data->stack_base_addr = (sys_word_t)create_param->stack_base_addr; + thread_data->stack_limit_addr = (sys_word_t)create_param->stack_limit_addr; + thread_data->last_sp = thread_data->stack_base_addr; + thread_data->ssa_frame_size = create_param->ssa_frame_size; + thread_data->first_ssa_gpr = (sys_word_t)create_param->first_ssa_gpr; + // TD address relative to TCS + thread_data->self_addr = (sys_word_t)create_param->td_addr; + thread_data->tls_addr = (sys_word_t)create_param->tls_addr; + thread_data->tls_array = thread_data->self_addr + (sys_word_t)offsetof(thread_data_t, tls_addr); + } +} diff --git a/psw/urts/prd_css_util.cpp b/psw/urts/prd_css_util.cpp new file mode 100644 index 0000000000..f6171798dc --- /dev/null +++ b/psw/urts/prd_css_util.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "arch.h" +#include "launch_checker.h" +#include "se_vendor.h" +#include "prd_css_util.h" +#include "se_memcpy.h" + +#include +#include +#include + + + +extern "C" int read_prd_css(const prd_css_path_t prd_css_path, enclave_css_t *css) +{ + assert(css != NULL); + + enclave_css_t prd_css; + memset(&prd_css, 0, sizeof(enclave_css_t)); + + FILE * fp = NULL; + fp = fopen(prd_css_path, "rb"); + if(fp == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + + fseek(fp, 0L, SEEK_END); + if(ftell(fp) != sizeof(enclave_css_t)) + { + fclose(fp); + return SGX_ERROR_INVALID_PARAMETER; + } + fseek(fp, 0L, SEEK_SET); + if(fread(&prd_css, 1, sizeof(enclave_css_t), fp) != sizeof(enclave_css_t)) + { + fclose(fp); + return SGX_ERROR_INVALID_PARAMETER; + } + fclose(fp); + + memcpy_s(css, sizeof(enclave_css_t), &prd_css, sizeof(prd_css)); + return SGX_SUCCESS; +} + +extern "C" bool is_le(SGXLaunchToken *lc, const enclave_css_t *const css) +{ + assert(NULL != css && NULL != lc); + sgx_launch_token_t token; + + lc->get_launch_token(&token); + + token_t *launch = reinterpret_cast(token); + + if(INTEL_VENDOR_ID == css->header.module_vendor + && LE_PROD_ID == css->body.isv_prod_id + && 0 != css->header.hw_version + && 0 == launch->body.valid) + return true; + + return false; +} diff --git a/psw/urts/prd_css_util.h b/psw/urts/prd_css_util.h new file mode 100644 index 0000000000..e0f6075c95 --- /dev/null +++ b/psw/urts/prd_css_util.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _PRD_CSS_UTIL_H_ +#define _PRD_CSS_UTIL_H_ +#include "arch.h" +#include "launch_checker.h" +#include "file.h" +#include + +#define LE_PROD_ID 0x20 + +#ifdef __cplusplus +extern "C" { +#endif + int read_prd_css(const prd_css_path_t prd_css_path, enclave_css_t *css); + bool is_le(SGXLaunchToken *lc, const enclave_css_t *const css); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/psw/urts/routine.cpp b/psw/urts/routine.cpp new file mode 100644 index 0000000000..ed2af060e6 --- /dev/null +++ b/psw/urts/routine.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "enclave.h" +#include "routine.h" +#include "se_error_internal.h" +#include "xsave.h" + +extern "C" +sgx_status_t sgx_ecall(const sgx_enclave_id_t enclave_id, const int proc, const void *ocall_table, void *ms) +{ + if(proc < 0) + return SGX_ERROR_INVALID_FUNCTION; + + CEnclave* enclave = CEnclavePool::instance()->ref_enclave(enclave_id); + + //If we failed to reference enclave, there is no corresponding enclave instance, so we didn't increase the enclave.m_ref; + if(!enclave) + return SGX_ERROR_INVALID_ENCLAVE_ID; + + sgx_status_t result = SGX_ERROR_UNEXPECTED; + { + result = enclave->ecall(proc, ocall_table, ms); + } + { + //This solution seems more readable and easy to validate, but low performace + CEnclavePool::instance()->unref_enclave(enclave); + } + + return result; +} + +extern "C" +int sgx_ocall(const unsigned int proc, const sgx_ocall_table_t *ocall_table, void *ms, CTrustThread *trust_thread) +{ + assert(trust_thread != NULL); + CEnclave* enclave = trust_thread->get_enclave(); + assert(enclave != NULL); + return enclave->ocall(proc, ocall_table, ms); +} diff --git a/psw/urts/se_detect.cpp b/psw/urts/se_detect.cpp new file mode 100644 index 0000000000..621a9eed4a --- /dev/null +++ b/psw/urts/se_detect.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_detect.h" +#include "cpuid.h" + +bool is_se_supported() +{ + int cpu_info[4] = {0, 0, 0, 0}; + __cpuidex(cpu_info, CPUID_FEATURE_FLAGS, 0); + if (!(cpu_info[1] & (1<secs_attr.flags = ((uint64_t)cpu_info[1] << 32) | cpu_info[0]; + + if(false == try_read_xcr0(&se_misc_attr->secs_attr.xfrm)) + { + se_misc_attr->secs_attr.xfrm = SGX_XFRM_LEGACY; + } + //If x-feature is supported and enabled by OS, we need make sure it is also supported in se. + else + { + se_misc_attr->secs_attr.xfrm &= (((uint64_t)cpu_info[3] << 32) | cpu_info[2]); + } + // use cpuid to get the misc_select + __cpuidex(cpu_info, SE_LEAF, 0); + se_misc_attr->misc_select = cpu_info[1]; + + return true; +} + + diff --git a/psw/urts/se_detect.h b/psw/urts/se_detect.h new file mode 100644 index 0000000000..8f2bce746d --- /dev/null +++ b/psw/urts/se_detect.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef SE_DETECT_H_ +#define SE_DETECT_H_ + +#include "se_types.h" +#include "sgx_attributes.h" + +#define SE_LEAF 0x12 +#define CPUID_FEATURE_FLAGS 7 +#define SE_FEATURE_SHIFT 2 +#define SE1_SHIFT 0 + +#define XSAVE_SHIFT 26 +#define OSXSAVE_SHIFT 27 + +bool try_read_xcr0(uint64_t *value); +//bool is_se_debug_supported(); +bool get_plat_cap_by_cpuid(sgx_misc_attribute_t *se_misc_attr); + +#endif diff --git a/psw/urts/se_ocalls.cpp b/psw/urts/se_ocalls.cpp new file mode 100644 index 0000000000..80c84c9384 --- /dev/null +++ b/psw/urts/se_ocalls.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: se_ocalls.cpp + * Description: + * Ocalls required by trusted libraries. + */ + +#include "sgx_defs.h" +#include "cpuid.h" + +extern "C" void sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf) +{ + __cpuidex(cpuinfo, leaf, subleaf); +} diff --git a/psw/urts/section_info.h b/psw/urts/section_info.h new file mode 100644 index 0000000000..f55dafdaf9 --- /dev/null +++ b/psw/urts/section_info.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SECTION_INFO_H_ +#define _SECTION_INFO_H_ + +#include "arch.h" +#include "util.h" +#include + +using namespace std; + +typedef struct _section_info_t +{ + uint8_t *raw_data; //The file pointer to the first page of the section. + uint64_t raw_data_size; //The size of the section or the size of the initialized section on disk. + uint64_t rva; //The address of the first byte of the section relative to the image base when section is loaded into memory. + uint64_t virtual_size; //The total size of the section when loaded into memory. + si_flags_t flag; //the attribute of memory region. + vector *bitmap; //bitmap of the total image page, if bit is 1, the page should be writable. + //the first bit of scetion in the bitmap is bitmap[(rva >> PAGE_SHIFT) / 8] & (1 << ((rva >> PAGE_SHIFT) % 8)) + //if the bitmap is NULL, then no restrict on page attribute. +} section_info_t; + +#endif diff --git a/psw/urts/tcs.cpp b/psw/urts/tcs.cpp new file mode 100644 index 0000000000..4b7fc6b858 --- /dev/null +++ b/psw/urts/tcs.cpp @@ -0,0 +1,352 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "tcs.h" +#include "se_trace.h" +#include "sgx_error.h" +#include "se_memory.h" +#include "se_thread.h" +#include + +extern se_thread_id_t get_thread_id(); + + +CTrustThread::CTrustThread(tcs_t *tcs, CEnclave* enclave) + : m_tcs(tcs) + , m_enclave(enclave) + , m_reference(0) + , m_event(NULL) +{ + memset(&m_tcs_info, 0, sizeof(debug_tcs_info_t)); + m_tcs_info.TCS_address = reinterpret_cast(tcs); + m_tcs_info.ocall_frame = 0; + m_tcs_info.thread_id = 0; +} + +CTrustThread::~CTrustThread() +{ + se_event_destroy(m_event); + m_event = NULL; +} + +se_handle_t CTrustThread::get_event() +{ + if (m_event == NULL) + m_event = se_event_init(); + + return m_event; +} + +void CTrustThread::push_ocall_frame(ocall_frame_t* frame_point) +{ + frame_point->index = this->get_reference(); + frame_point->pre_last_frame = m_tcs_info.ocall_frame; + m_tcs_info.ocall_frame = reinterpret_cast(frame_point); + m_tcs_info.thread_id = get_thread_id(); +} + +void CTrustThread::pop_ocall_frame() +{ + ocall_frame_t* last_ocall_frame = reinterpret_cast(m_tcs_info.ocall_frame); + if (last_ocall_frame) + { + m_tcs_info.ocall_frame = last_ocall_frame->pre_last_frame; + } +} + + +CTrustThreadPool::CTrustThreadPool() +{ + m_thread_list = NULL; +} + +CTrustThreadPool::~CTrustThreadPool() +{ + LockGuard lock(&m_thread_mutex); + //destroy free tcs list + for(vector::iterator it=m_free_thread_vector.begin(); it!=m_free_thread_vector.end(); it++) + { + delete *it; + } + m_free_thread_vector.clear(); + //destroy thread cache + Node* it = m_thread_list, *tmp = NULL; + while (it != NULL) + { + delete it->value; + tmp = it; + it = it->next; + delete tmp; + } + m_thread_list = NULL; +} + +void get_thread_set(vector &thread_vector); +inline int CTrustThreadPool::find_thread(vector &thread_vector, se_thread_id_t thread_id) +{ + for(vector::iterator it=thread_vector.begin(); it!=thread_vector.end(); it++) + if(*it == thread_id) + return TRUE; + return FALSE; +} + +inline CTrustThread * CTrustThreadPool::get_free_thread() +{ + if(true == m_free_thread_vector.empty()) + { + return NULL; + } + //if there is free tcs, remove it from free list + CTrustThread *thread_node = m_free_thread_vector.back(); + m_free_thread_vector.pop_back(); + + return thread_node; +} + +//This tcs policy is bind tcs with one thread. +int CTrustThreadPool::bind_thread(const se_thread_id_t thread_id, CTrustThread * const trust_thread) +{ + if (m_thread_list == NULL) { + m_thread_list = new Node(thread_id, trust_thread); + } else { + Node* it = new Node(thread_id, trust_thread); + if (m_thread_list->InsertNext(it) == false) { + delete it; + SE_TRACE(SE_TRACE_WARNING, "trust thread %x is already added to the list\n", trust_thread); + return FALSE; + } + } + return TRUE; +} + +CTrustThread * CTrustThreadPool::get_bound_thread(const se_thread_id_t thread_id) +{ + CTrustThread *trust_thread = NULL; + + Node* it = m_thread_list->Find(thread_id); + if(it != NULL) + trust_thread = it->value; + + return trust_thread; +} + +CTrustThread * CTrustThreadPool::add_thread(tcs_t * const tcs, CEnclave * const enclave) +{ + CTrustThread *trust_thread = new CTrustThread(tcs, enclave); + LockGuard lock(&m_thread_mutex); + //add tcs to free list + m_free_thread_vector.push_back(trust_thread); + + return trust_thread; +} + +CTrustThread *CTrustThreadPool::get_bound_thread(const tcs_t *tcs) +{ + //Since now this function will be call outside, we need get lock to protect map + LockGuard lock(&m_thread_mutex); + + CTrustThread *trust_thread = NULL; + if (m_thread_list == NULL) + return NULL; + Node* it = m_thread_list; + while (it != NULL) { + trust_thread = it->value; + if(trust_thread->get_tcs() == tcs) { + return trust_thread; + } + it = it->next; + } + return NULL; +} + +void CTrustThreadPool::reset() +{ + //get lock at the begin of list walk. + LockGuard lock(&m_thread_mutex); + + //walk through thread cache to free every element; + Node* it = m_thread_list, *tmp = NULL; + + while(it != NULL) + { + tmp = it; + it = it->next; + CTrustThread *trust_thread = tmp->value; + //remove from thread cache + delete tmp; + trust_thread->reset_ref(); + m_free_thread_vector.push_back(trust_thread); + } + m_thread_list = NULL; + + return; +} + +void CTrustThreadPool::wake_threads() +{ + LockGuard lock(&m_thread_mutex); + Node* it = m_thread_list; + + while (it != NULL) { + CTrustThread *thread = it->value; + se_handle_t event = thread->get_event(); + se_event_wake(event); + it = it->next; + } +} + +CTrustThread * CTrustThreadPool::_acquire_thread() +{ + //try to get tcs from thread cache + se_thread_id_t thread_id = get_thread_id(); + CTrustThread *trust_thread = get_bound_thread(thread_id); + if(NULL != trust_thread) + { + return trust_thread; + } + //try get tcs from free list; + trust_thread = get_free_thread(); + //if there is no free tcs, collect useless tcs. + if(NULL == trust_thread) + { + if(!garbage_collect()) + return NULL; + //get tcs from free list again. + trust_thread = get_free_thread(); + assert(NULL != trust_thread); + } + //we have got a free tcs. add the tcs to thread cache + bind_thread(thread_id, trust_thread); + return trust_thread; +} + +CTrustThread * CTrustThreadPool::acquire_thread() +{ + LockGuard lock(&m_thread_mutex); + CTrustThread *trust_thread = NULL; + + trust_thread = _acquire_thread(); + if(trust_thread) + trust_thread->increase_ref(); + + return trust_thread; +} + +//Do nothing for bind mode, the tcs is always bound to a thread. +void CTrustThreadPool::release_thread(CTrustThread * const trust_thread) +{ + LockGuard lock(&m_thread_mutex); + trust_thread->decrease_ref(); + return; +} + +//The return value stand for the number of free trust thread. +int CThreadPoolBindMode::garbage_collect() +{ + int nr_free = 0; + + //if free list is NULL, recycle tcs. + //get thread id set of current process + vector thread_vector; + get_thread_set(thread_vector); + //walk through thread cache to see if there is any thread that has exited + Node* it = m_thread_list, *pre = NULL, *tmp = NULL; + + while(it != NULL) + { + se_thread_id_t thread_id = it->key; + //if the thread has exited + if(FALSE == find_thread(thread_vector, thread_id)) + { + //if the reference is not 0, there must be some wrong termination, so we can't recycle such trust thread. + //return to free_tcs list + if(0 == it->value->get_reference()) + { + m_free_thread_vector.push_back(it->value); + nr_free++; + } + else + { + //the list only record the pointer of trust thread, so we can delete it first and then erase from map. + delete it->value; + } + tmp = it; + it = it->next; + if (tmp == m_thread_list) + m_thread_list = it; + if (pre != NULL) + pre->next = it; + //remove from thread cache + delete tmp; + } + else + { + pre = it; + it = it->next; + } + } + + return nr_free; +} + +int CThreadPoolUnBindMode::garbage_collect() +{ + int nr_free = 0; + + //walk through to free unused trust thread + Node* it = m_thread_list, *pre = NULL, *tmp = NULL; + while(it != NULL) + { + //if the reference is 0, then the trust thread is not in use, so return to free_tcs list + if(0 == it->value->get_reference()) + { + m_free_thread_vector.push_back(it->value); + nr_free++; + + tmp = it; + it = it->next; + if (tmp == m_thread_list) + m_thread_list = it; + if (pre != NULL) + pre->next = it; + //remove from thread cache + delete tmp; + } + else + { + pre = it; + it = it->next; + } + } + + return nr_free; +} diff --git a/psw/urts/tcs.h b/psw/urts/tcs.h new file mode 100644 index 0000000000..39c3484f13 --- /dev/null +++ b/psw/urts/tcs.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _TCS_H_ +#define _TCS_H_ +#include "arch.h" +#include "se_wrapper.h" +#include "util.h" +#include "sgx_error.h" +#include "se_debugger_lib.h" +#include "se_lock.hpp" +#include +#include "node.h" + +using namespace std; + +typedef int (*bridge_fn_t)(const void*); + +class CEnclave; + +class CTrustThread: private Uncopyable +{ +public: + CTrustThread(tcs_t *tcs, CEnclave* enclave); + ~CTrustThread(); + int get_reference() { return m_reference; } + void increase_ref() { m_reference++; } + void decrease_ref() { m_reference--; } + tcs_t *get_tcs() { return m_tcs; } + CEnclave *get_enclave() { return m_enclave; } + se_handle_t get_event(); + void reset_ref() { m_reference = 0; } + debug_tcs_info_t* get_debug_info(){return &m_tcs_info;} + void push_ocall_frame(ocall_frame_t* frame_point); + void pop_ocall_frame(); +private: + tcs_t *m_tcs; + CEnclave *m_enclave; + int m_reference; //it will increase by 1 before ecall, and decrease after ecall. + se_handle_t m_event; + debug_tcs_info_t m_tcs_info; +}; + +class CTrustThreadPool: private Uncopyable +{ +public: + CTrustThreadPool(); + virtual ~CTrustThreadPool(); + CTrustThread * acquire_thread(); + void release_thread(CTrustThread * const trust_thread); + CTrustThread *add_thread(tcs_t * const tcs, CEnclave * const enclave); + CTrustThread *get_bound_thread(const tcs_t *tcs); + void reset(); + void wake_threads(); +protected: + virtual int garbage_collect() = 0; + inline int find_thread(vector &thread_vector, se_thread_id_t thread_id); + inline CTrustThread * get_free_thread(); + int bind_thread(const se_thread_id_t thread_id, CTrustThread * const trust_thread); + CTrustThread * get_bound_thread(const se_thread_id_t thread_id); + + vector m_free_thread_vector; + Node *m_thread_list; + Mutex m_thread_mutex; //protect both thread_cache list and fress tcs list. The mutex is recursive. + //Thread can operate the two list when it get the mutex +private: + CTrustThread * _acquire_thread(); +}; + +class CThreadPoolBindMode : public CTrustThreadPool +{ +public: + CThreadPoolBindMode():CTrustThreadPool(){} +private: + virtual int garbage_collect(); +}; + +class CThreadPoolUnBindMode : public CTrustThreadPool +{ +public: + CThreadPoolUnBindMode():CTrustThreadPool(){} +private: + virtual int garbage_collect(); +}; +#endif diff --git a/psw/urts/urts_com.h b/psw/urts/urts_com.h new file mode 100644 index 0000000000..ab370bdf60 --- /dev/null +++ b/psw/urts/urts_com.h @@ -0,0 +1,378 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _URTS_COM_H_ +#define _URTS_COM_H_ + + +#include "arch.h" +#include "sgx_error.h" +#include "se_error_internal.h" +#include "se_trace.h" +#include "file.h" +#include "sgx_eid.h" +#include "se_map.h" +#include "launch_checker.h" +#include "debugger_support.h" +#include "loader.h" +#include "binparser.h" +#include "cpuid.h" +#include "se_macro.h" +#include "prd_css_util.h" +#include "se_detect.h" + +#ifndef PARSER +#include "elfparser.h" +#define PARSER ElfParser +#endif + +#include "ittnotify.h" +#include "ittnotify_config.h" +#include "ittnotify_types.h" + +extern "C" int __itt_init_ittlib(const char*, __itt_group_id); +extern "C" __itt_global* __itt_get_ittapi_global(); + + +#define HSW_C0 0x306c3 +#define GPR_A0 0x406e0 +#define GPR_B0 0x406e1 +#define GPR_P0 0x506e0 + +#ifndef SE_SIM +static int validate_platform() +{ + int cpu_info[4] = {0, 0, 0, 0}; + + __cpuid(cpu_info, 1); + + // The compatibility between SDK and PSW is checked by the metadata version. + // Below check the compatibility between the platform and uRTS only. + + + // It is HSW users' responsibility to make the uRTS version to consistent with the HSW patch. + if(cpu_info[0] == HSW_C0) + { + return SGX_SUCCESS; + } + + // GPR region + else if(cpu_info[0] == GPR_A0 || cpu_info[0] == GPR_B0 || cpu_info[0] == GPR_P0) + { + SE_TRACE(SE_TRACE_ERROR, "ERROR: The enclave cannot be launched on current platform.\n"); + return SGX_ERROR_INVALID_VERSION; + } + + return SGX_SUCCESS; +} +#endif + +static sgx_status_t get_metadata(BinParser *parser, const int debug, metadata_t **metadata, sgx_misc_attribute_t *sgx_misc_attr) +{ + assert(parser != NULL && metadata != NULL && sgx_misc_attr != NULL); + uint64_t meta_rva = parser->get_metadata_offset(); + const uint8_t *base_addr = parser->get_start_addr(); + + uint64_t meta_block_size = parser->get_metadata_block_size(); + uint64_t version = META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ); + + //scan multiple metadata list in sgx_metadata section + do{ + *metadata = GET_PTR(metadata_t, base_addr, meta_rva); + + if((*metadata)->magic_num != METADATA_MAGIC) + return SGX_ERROR_INVALID_METADATA; + //check metadata version + if(version == (*metadata)->version) + break; + + if(0 == (*metadata)->size) + { + SE_TRACE(SE_TRACE_ERROR, "ERROR: metadata's size can't be zero.\n"); + return SGX_ERROR_INVALID_METADATA; + } + meta_rva += (*metadata)->size; /*goto next metadata offset*/ + if(meta_rva - (parser->get_metadata_offset()) >= meta_block_size) + { + SE_TRACE(SE_TRACE_ERROR, "ERROR: Exceed metadata block bound.\n"); + return SGX_ERROR_INVALID_METADATA; + } + }while(1); + + return (sgx_status_t)get_enclave_creator()->get_misc_attr(sgx_misc_attr, *metadata, NULL, debug); +} + +static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadata_t *metadata, se_file_t& file, const bool debug, SGXLaunchToken *lc, le_prd_css_file_t *prd_css_file, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr) +{ + // The "parser" will be registered into "loader" and "loader" will be registered into "enclave". + // After enclave is created, "parser" and "loader" are not needed any more. + debug_enclave_info_t *debug_info = NULL; + int ret = SGX_SUCCESS; + CLoader loader(base_addr, parser); + + ret = loader.load_enclave_ex(lc, debug, metadata, prd_css_file, misc_attr); + if (ret != SGX_SUCCESS) + { + return ret; + } + + CEnclave* enclave = new CEnclave(loader); + + // initialize the enclave object + ret = enclave->initialize(file, + loader.get_enclave_id(), + const_cast(loader.get_start_addr()), + metadata->enclave_size, + metadata->tcs_policy); + + if (ret != SGX_SUCCESS) + { + loader.destroy_enclave(); + delete enclave; // The `enclave' object owns the `loader' object. + return ret; + } + + std::vector tcs_list = loader.get_tcs_list(); + for (unsigned idx = 0; idx < tcs_list.size(); ++idx) + { + enclave->add_thread(tcs_list[idx]); + SE_TRACE(SE_TRACE_DEBUG, "add tcs %p\n", tcs_list[idx]); + } + + // It is accurate to get debug flag from secs + enclave->set_dbg_flag(!!(loader.get_secs().attributes.flags & SGX_FLAGS_DEBUG)); + + debug_info = const_cast(enclave->get_debug_info()); + + enclave->set_extra_debug_info(const_cast(loader.get_secs())); + + //add enclave to enclave pool before init_enclave because in simualtion + //mode init_enclave will rely on CEnclavePool to get Enclave instance. + if (FALSE == CEnclavePool::instance()->add_enclave(enclave)) + { + ret = SGX_ERROR_UNEXPECTED; + goto fail; + } + + if(debug) + debug_info->enclave_type |= ET_DEBUG; + if (!(get_enclave_creator()->use_se_hw())) + debug_info->enclave_type |= ET_SIM; + + bool isVTuneProfiling; + + if(debug || !(get_enclave_creator()->use_se_hw())) + { + SE_TRACE(SE_TRACE_DEBUG, "Debug enclave. Checking if VTune is profiling\n"); + + __itt_init_ittlib(NULL, __itt_group_none); + + if(__itt_get_ittapi_global()->api_initialized && __itt_get_ittapi_global()->lib) + isVTuneProfiling = true; + else + isVTuneProfiling = false; + + if(isVTuneProfiling) + { + SE_TRACE(SE_TRACE_DEBUG, "VTune is profiling\n"); + + bool thread_updated; + thread_updated = enclave->update_debug_flag(1); + + if(thread_updated == false) + { + SE_TRACE(SE_TRACE_DEBUG, "Failed to update debug OPTIN bit\n"); + } + else + { + SE_TRACE(SE_TRACE_DEBUG, "Updated debug OPTIN bit\n"); + } + + uint64_t enclave_start_addr; + uint64_t enclave_end_addr; + const char* enclave_path; + enclave_start_addr = (uint64_t) loader.get_start_addr(); + enclave_end_addr = enclave_start_addr + (uint64_t) metadata->enclave_size; + + SE_TRACE(SE_TRACE_DEBUG, "Invoking VTune's module mapping API __itt_module_load \n"); + SE_TRACE(SE_TRACE_DEBUG, "Enclave_start_addr==0x%llx\n", enclave_start_addr); + SE_TRACE(SE_TRACE_DEBUG, "Enclave_end_addr==0x%llx\n", enclave_end_addr); + + enclave_path = (const char*)file.name; + SE_TRACE(SE_TRACE_DEBUG, "Enclave_path==%s\n", enclave_path); + __itt_module_load((void*)enclave_start_addr, (void*) enclave_end_addr, enclave_path); + } + else + { + SE_TRACE(SE_TRACE_DEBUG, "VTune is not profiling. Debug OPTIN bit not set and API to do module mapping not invoked\n"); + } + } + + //send debug event to debugger when enclave is debug mode or release mode + //set struct version + debug_info->struct_version = enclave->get_debug_info()->struct_version; + //generate load debug event after EINIT + generate_enclave_debug_event(URTS_EXCEPTION_POSTINITENCLAVE, debug_info); + + + //call trts to do some intialization + if(SGX_SUCCESS != (ret = get_enclave_creator()->initialize(loader.get_enclave_id()))) + { + sgx_status_t status = SGX_SUCCESS; + CEnclavePool::instance()->remove_enclave(loader.get_enclave_id(), status); + goto fail; + } + + + if(SGX_SUCCESS != (ret = loader.set_memory_protection())) + { + sgx_status_t status = SGX_SUCCESS; + CEnclavePool::instance()->remove_enclave(loader.get_enclave_id(), status); + goto fail; + } + + *enclave_id = loader.get_enclave_id(); + return SGX_SUCCESS; + +fail: + loader.destroy_enclave(); + delete enclave; + return ret; +} + + +sgx_status_t _create_enclave(const bool debug, se_file_handle_t pfile, se_file_t& file, le_prd_css_file_t *prd_css_file, sgx_launch_token_t *launch, int *launch_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr) +{ + unsigned int ret = SGX_SUCCESS; + sgx_status_t lt_result = SGX_SUCCESS; + uint32_t file_size = 0; + map_handle_t* mh = NULL; + sgx_misc_attribute_t sgx_misc_attr; + metadata_t *metadata = NULL; + SGXLaunchToken *lc = NULL; + memset(&sgx_misc_attr, 0, sizeof(sgx_misc_attribute_t)); + + if(NULL == launch || NULL == launch_updated || NULL == enclave_id) + return SGX_ERROR_INVALID_PARAMETER; +#ifndef SE_SIM + ret = validate_platform(); + if(ret != SGX_SUCCESS) + return (sgx_status_t)ret; +#endif + + mh = map_file(pfile, &file_size); + if (!mh) + return SGX_ERROR_OUT_OF_MEMORY; + + PARSER parser(const_cast(mh->base_addr), (uint64_t)(file_size)); + if(SGX_SUCCESS != (ret = parser.run_parser())) + { + goto clean_return; + } + //Make sure HW uRTS won't load simulation enclave and vice verse. + if(get_enclave_creator()->use_se_hw() != (!parser.get_symbol_rva("g_global_data_sim"))) + { + SE_TRACE_WARNING("HW and Simulation mode incompatibility detected. The enclave is linked with the incorrect tRTS library.\n"); + ret = SGX_ERROR_MODE_INCOMPATIBLE; + goto clean_return; + } + + if(SGX_SUCCESS != (ret = get_metadata(&parser, debug, &metadata, &sgx_misc_attr))) + { + goto clean_return; + } + + *launch_updated = FALSE; + + lc = new SGXLaunchToken(&metadata->enclave_css, &sgx_misc_attr.secs_attr, launch); + lt_result = lc->update_launch_token(false); + if(SGX_SUCCESS != lt_result) + { + ret = lt_result; + goto clean_return; + } +#ifndef SE_SIM + // Only LE allows the prd_css_file + if(is_le(lc, &metadata->enclave_css) == false && prd_css_file != NULL) + { + ret = SGX_ERROR_INVALID_PARAMETER; + goto clean_return; + } +#endif + + //Need to set the whole misc_attr instead of just secs_attr. + do { + ret = __create_enclave(parser, mh->base_addr, metadata, file, debug, lc, prd_css_file, enclave_id, + misc_attr); + //SGX_ERROR_ENCLAVE_LOST caused by initializing enclave while power transition occurs + } while(SGX_ERROR_ENCLAVE_LOST == ret); + + if(SE_ERROR_INVALID_LAUNCH_TOKEN == ret || SGX_ERROR_INVALID_CPUSVN == ret) + ret = SGX_ERROR_UNEXPECTED; + + // The launch token is updated, so the SE_INVALID_MEASUREMENT is only caused by signature. + if(SE_ERROR_INVALID_MEASUREMENT == ret) + ret = SGX_ERROR_INVALID_SIGNATURE; + + // The launch token is updated, so the SE_ERROR_INVALID_ISVSVNLE means user needs to update the LE image + if (SE_ERROR_INVALID_ISVSVNLE == ret) + ret = SGX_ERROR_UPDATE_NEEDED; + + if(SGX_SUCCESS != ret) + goto clean_return; + else if(lc->is_launch_updated()) + { + *launch_updated = TRUE; + ret = lc->get_launch_token(launch); + } + + +clean_return: + if(mh != NULL) + unmap_file(mh); + if(lc != NULL) + delete lc; + return (sgx_status_t)ret; +} + +extern "C" sgx_status_t sgx_destroy_enclave(const sgx_enclave_id_t enclave_id) +{ + sgx_status_t status = SGX_SUCCESS; + CEnclave* enclave = CEnclavePool::instance()->remove_enclave(enclave_id, status); + + if (enclave) + { + delete enclave; + } + + return status; +} +#endif diff --git a/psw/urts/urts_version.cpp b/psw/urts/urts_version.cpp new file mode 100644 index 0000000000..68ec6ceedd --- /dev/null +++ b/psw/urts/urts_version.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" +#include "se_cdefs.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_URTS_VERSION_STR __CONCAT("SGX_URTS_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_urts_version = SGX_URTS_VERSION_STR; + +#ifdef __cplusplus +} +#endif + +SGX_ACCESS_VERSION(urts, 1) diff --git a/psw/urts/urts_xsave.cpp b/psw/urts/urts_xsave.cpp new file mode 100644 index 0000000000..71cd646b7d --- /dev/null +++ b/psw/urts/urts_xsave.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "xsave.h" +#include "util.h" +#include "se_detect.h" +#include "sgx_attributes.h" + +#define XFRM_YMM_BITMASK 0x00000004 + +// save_and_clean_xfeature_regs() +// do fwait, fxsave, and then clear the upper bits of YMM regs before executing EENTER. +// Parameters: +// buffer - if the pointer is not NULL, save the CPU state to the buffer +// Return Value: +// none + + + + + + + + +void save_and_clean_xfeature_regs(uint8_t *buffer) +{ + // XCR0 is not supposed to be changed. So query it once. + static uint64_t xcr0 = 0; + if(xcr0 == 0) + { + if(false == try_read_xcr0(&xcr0)) + { + xcr0 = SGX_XFRM_LEGACY; + } + } + + // do fwait to flush the float-point exceptions + do_fwait(); + + // do fxsave to save the CPU state before ecall + // no need to save the CPU state before oret + if(buffer != 0) + { + uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); + do_fxsave(buf); + } + + // clean the upper bits of the YMM regs + if(xcr0 & XFRM_YMM_BITMASK) + { + do_vzeroupper(); + } +} + +void restore_xfeature_regs(const uint8_t *buffer) +{ + if (buffer) + { + uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); + do_fxrstor(buf); + } +} diff --git a/sdk/Makefile b/sdk/Makefile new file mode 100644 index 0000000000..029026880b --- /dev/null +++ b/sdk/Makefile @@ -0,0 +1,222 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +# This Makefile will compile SDK to generate various components +# including: +# - Trusted libraries +# - tstdc: libsgx_tstdc.a +# - tstdcxx: libsgx_tstdcxx.a +# - tservice: libsgx_tservice.a +# - trts: libsgx_trts.a +# - tcrypto: libsgx_tcrypto.a +# - tkey_exchange: libsgx_tkey_exchange.a +# - Untrtusted libraries +# - ukey_exchange: libsgx_ukey_exchange.a +# - ptrace: libsgx_ptrace.so, gdb-sgx-plugin +# - sample_crypto: libsample_crypto.so (for sample code use) +# - Tools +# - signtool: sgx_sign +# - edger8r: sgx_edger8r +# - Simulation libraries and tools +# - simulation: libsgx_trts_sim.a, libsgx_tservice_sim.a, libsgx_urts_sim.a, libsgx_uae_service_sim.a, sgx_config_cpusvn +# +include ../buildenv.mk + +LIBTLIBC := $(BUILD_DIR)/libsgx_tstdc.a +LIBTLIBCXX := $(BUILD_DIR)/libsgx_tstdcxx.a +LIBTSE := $(BUILD_DIR)/libsgx_tservice.a + +.PHONY: all +all: tstdc tstdcxx tservice trts tcrypto tkey_exchange ukey_exchange ptrace sample_crypto simulation signtool edger8r + +# --------------------------------------------------- +# tstdc +# includes: tlibc, libm, tlibthread, compiler-rt +# --------------------------------------------------- +.PHONY: tstdc +tstdc: $(LIBTLIBC) + +$(LIBTLIBC): tlibthread compiler-rt sgx_libm + $(MAKE) -C tlibc/ -j4 2> /dev/null + @$(MKDIR) $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread + @$(RM) -f $(BUILD_DIR)/.libm/* $(BUILD_DIR)/.tlibc/* $(BUILD_DIR)/.tlibthread/* + @cd $(BUILD_DIR)/.libm && $(AR) x $(LINUX_EXTERNAL_DIR)/sgx_libm/libm.a + @cd $(BUILD_DIR)/.tlibc && $(AR) x $(LINUX_SDK_DIR)/tlibc/libtlibc.a + @cd $(BUILD_DIR)/.tlibthread && $(AR) x $(LINUX_SDK_DIR)/tlibthread/libtlibthread.a + $(CP) compiler-rt/libcompiler-rt.a $@ + $(AR) rsD $@ $(BUILD_DIR)/.libm/*.o $(BUILD_DIR)/.tlibc/*.o $(BUILD_DIR)/.tlibthread/*.o + @$(RM) -rf $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread + +.PHONY: tlibthread +tlibthread: + $(MAKE) -C tlibthread/ + +.PHONY: compiler-rt +compiler-rt: + $(MAKE) -C compiler-rt/ 2> /dev/null + +LIBM_PATH = $(LINUX_EXTERNAL_DIR)/sgx_libm/ + +M_ARCH = intel64 +ifneq ($(ARCH), x86_64) + M_ARCH := ia32 +endif + +.PHONY: sgx_libm +sgx_libm: + $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) 2> /dev/null + +# --------------------------------------------------- +# tstdcxx +# includes: cpprt, tlibstdcxx +# --------------------------------------------------- +.PHONY: tstdcxx +tstdcxx: $(LIBTLIBCXX) + +$(LIBTLIBCXX): cpprt tlibstdcxx + @$(MKDIR) $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx + @$(RM) -f $(BUILD_DIR)/.cpprt/* $(BUILD_DIR)/.tlibstdcxx/* + @cd $(BUILD_DIR)/.cpprt && $(AR) x $(LINUX_SDK_DIR)/cpprt/libcpprt.a + @cd $(BUILD_DIR)/.tlibstdcxx && $(AR) x $(LINUX_SDK_DIR)/tlibstdcxx/libtlibstdcxx.a + $(AR) rcsD $@ $(BUILD_DIR)/.cpprt/*.o $(BUILD_DIR)/.tlibstdcxx/*.o + @$(RM) -rf $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx + +.PHONY: cpprt +cpprt: + $(MAKE) -C cpprt + +.PHONY: tlibstdcxx +tlibstdcxx: $(BUILD_DIR) + $(MAKE) -C tlibstdcxx/ 2> /dev/null + $(CP) tlibstdcxx/README.sgx $(BUILD_DIR)/STLport_Changes_SGX.txt + +# --------------------------------------------------- +# tse +# includes: selib, tseal, tae_service, ec_dh_lib +# --------------------------------------------------- +.PHONY: tservice +tservice: $(LIBTSE) + +$(LIBTSE): selib tseal tae_service + @$(MKDIR) $(BUILD_DIR)/.tservice + @$(RM) -f $(BUILD_DIR)/.tservice/* + cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tseal/linux/libtSeal.a + cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tae_service/libtae_service.a + $(CP) $(LINUX_SDK_DIR)/selib/linux/libselib.a $@ + $(AR) rsD $@ $(BUILD_DIR)/.tservice/*.o + @$(RM) -rf $(BUILD_DIR)/.tservice + +.PHONY: selib +selib: + $(MAKE) -C selib/linux/ + +.PHONY: tseal +tseal: + $(MAKE) -C tseal/linux/ + +.PHONY: tae_service +tae_service: + $(MAKE) -C tae_service + +# --------------------------------------------------- +# Other trusted libraries +# --------------------------------------------------- +.PHONY: trts +trts: + $(MAKE) -C trts/ + +.PHONY: tcrypto +tcrypto: + $(MAKE) -C tlibcrypto/ + +.PHONY: tkey_exchange +tkey_exchange: + $(MAKE) -C tkey_exchange + +# --------------------------------------------------- +# Untrusted libraries +# --------------------------------------------------- +.PHONY: ukey_exchange +ukey_exchange: + $(MAKE) -C ukey_exchange + +.PHONY: ptrace +ptrace: + $(MAKE) -C debugger_interface/linux/ + +.PHONY: sample_crypto +sample_crypto: + $(MAKE) -C sample_libcrypto + +# --------------------------------------------------- +# simualtion libraries and tools +# --------------------------------------------------- +.PHONY: simulation +simulation: + $(MAKE) -C simulation/ + +# --------------------------------------------------- +# tools +# --------------------------------------------------- +.PHONY: signtool +signtool: + $(MAKE) -C sign_tool/SignTool/ + +.PHONY: edger8r +edger8r: + $(MAKE) -C edger8r/linux/ + +$(BUILD_DIR): + $(MKDIR) $@ + +clean: + $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) clean + $(MAKE) -C tlibc/ clean + $(MAKE) -C tlibthread/ clean + $(MAKE) -C compiler-rt/ clean + $(MAKE) -C cpprt clean + $(MAKE) -C tlibstdcxx/ clean + $(MAKE) -C tseal/linux/ clean + $(MAKE) -C selib/linux/ clean + $(MAKE) -C tae_service/ clean + $(MAKE) -C trts/ clean + $(MAKE) -C tlibcrypto/ clean + $(MAKE) -C tkey_exchange/ clean + $(MAKE) -C ukey_exchange/ clean + $(MAKE) -C debugger_interface/linux/ clean + $(MAKE) -C sample_libcrypto/ clean + $(MAKE) -C simulation/ clean + $(MAKE) -C sign_tool/SignTool clean + $(MAKE) -C edger8r/linux clean + @$(RM) $(LIBTLIBC) $(LIBTLIBCXX) $(LIBTSE) + @$(RM) $(BUILD_DIR)/STLport_Changes_SGX.txt + +rebuild: clean all diff --git a/sdk/compiler-rt/LICENSE.TXT b/sdk/compiler-rt/LICENSE.TXT new file mode 100644 index 0000000000..488baf5e3a --- /dev/null +++ b/sdk/compiler-rt/LICENSE.TXT @@ -0,0 +1,98 @@ +============================================================================== +compiler_rt License +============================================================================== + +The compiler_rt library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +Copyrights and Licenses for Third Party Software Distributed with LLVM: +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +sysinfo lib/asan/sysinfo +mach_override lib/asan/mach_override diff --git a/sdk/compiler-rt/Makefile b/sdk/compiler-rt/Makefile new file mode 100644 index 0000000000..202a2f6002 --- /dev/null +++ b/sdk/compiler-rt/Makefile @@ -0,0 +1,54 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +CFLAGS += $(ENCLAVE_CFLAGS) +CPPFLAGS += $(ADDED_INC) \ + -I$(COMMON_DIR)/inc/tlibc/ + +SRCS := $(wildcard *.c) +OBJS := $(SRCS:.c=.o) + +TARGET := libcompiler-rt.a + +.PHONY: all +all: $(TARGET) + +$(TARGET): $(OBJS) + $(AR) rcsD $@ $^ + +$(OBJS): %.o: %.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +.PHONY: clean +clean: + @$(RM) $(OBJS) $(TARGET) diff --git a/sdk/compiler-rt/addtf3.c b/sdk/compiler-rt/addtf3.c new file mode 100644 index 0000000000..e4bbe0227a --- /dev/null +++ b/sdk/compiler-rt/addtf3.c @@ -0,0 +1,25 @@ +//===-- lib/addtf3.c - Quad-precision addition --------------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements quad-precision soft-float addition with the IEEE-754 +// default rounding (to nearest, ties to even). +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#include "fp_add_impl.inc" + +COMPILER_RT_ABI long double __addtf3(long double a, long double b){ + return __addXf3__(a, b); +} + +#endif diff --git a/sdk/compiler-rt/ashldi3.c b/sdk/compiler-rt/ashldi3.c new file mode 100644 index 0000000000..eb4698ac51 --- /dev/null +++ b/sdk/compiler-rt/ashldi3.c @@ -0,0 +1,43 @@ +/* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ashldi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a << b */ + +/* Precondition: 0 <= b < bits_in_dword */ + +ARM_EABI_FNALIAS(llsl, ashldi3) + +COMPILER_RT_ABI di_int +__ashldi3(di_int a, si_int b) +{ + const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); + dwords input; + dwords result; + input.all = a; + if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ + { + result.s.low = 0; + result.s.high = input.s.low << (b - bits_in_word); + } + else /* 0 <= b < bits_in_word */ + { + if (b == 0) + return a; + result.s.low = input.s.low << b; + result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b)); + } + return result.all; +} diff --git a/sdk/compiler-rt/ashlti3.c b/sdk/compiler-rt/ashlti3.c new file mode 100644 index 0000000000..638ae845ff --- /dev/null +++ b/sdk/compiler-rt/ashlti3.c @@ -0,0 +1,45 @@ +/* ===-- ashlti3.c - Implement __ashlti3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ashlti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: a << b */ + +/* Precondition: 0 <= b < bits_in_tword */ + +COMPILER_RT_ABI ti_int +__ashlti3(ti_int a, si_int b) +{ + const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT); + twords input; + twords result; + input.all = a; + if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ + { + result.s.low = 0; + result.s.high = input.s.low << (b - bits_in_dword); + } + else /* 0 <= b < bits_in_dword */ + { + if (b == 0) + return a; + result.s.low = input.s.low << b; + result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_dword - b)); + } + return result.all; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/ashrdi3.c b/sdk/compiler-rt/ashrdi3.c new file mode 100644 index 0000000000..14c878bb77 --- /dev/null +++ b/sdk/compiler-rt/ashrdi3.c @@ -0,0 +1,44 @@ +/*===-- ashrdi3.c - Implement __ashrdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ashrdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: arithmetic a >> b */ + +/* Precondition: 0 <= b < bits_in_dword */ + +ARM_EABI_FNALIAS(lasr, ashrdi3) + +COMPILER_RT_ABI di_int +__ashrdi3(di_int a, si_int b) +{ + const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); + dwords input; + dwords result; + input.all = a; + if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ + { + /* result.s.high = input.s.high < 0 ? -1 : 0 */ + result.s.high = input.s.high >> (bits_in_word - 1); + result.s.low = input.s.high >> (b - bits_in_word); + } + else /* 0 <= b < bits_in_word */ + { + if (b == 0) + return a; + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b); + } + return result.all; +} diff --git a/sdk/compiler-rt/ashrti3.c b/sdk/compiler-rt/ashrti3.c new file mode 100644 index 0000000000..f78205d961 --- /dev/null +++ b/sdk/compiler-rt/ashrti3.c @@ -0,0 +1,46 @@ +/* ===-- ashrti3.c - Implement __ashrti3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ashrti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: arithmetic a >> b */ + +/* Precondition: 0 <= b < bits_in_tword */ + +COMPILER_RT_ABI ti_int +__ashrti3(ti_int a, si_int b) +{ + const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT); + twords input; + twords result; + input.all = a; + if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ + { + /* result.s.high = input.s.high < 0 ? -1 : 0 */ + result.s.high = input.s.high >> (bits_in_dword - 1); + result.s.low = input.s.high >> (b - bits_in_dword); + } + else /* 0 <= b < bits_in_dword */ + { + if (b == 0) + return a; + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_dword - b)) | (input.s.low >> b); + } + return result.all; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/clear_cache.c b/sdk/compiler-rt/clear_cache.c new file mode 100644 index 0000000000..e0bd8b045f --- /dev/null +++ b/sdk/compiler-rt/clear_cache.c @@ -0,0 +1,96 @@ +/* ===-- clear_cache.c - Implement __clear_cache ---------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#if __APPLE__ + #include +#endif +#if defined(__NetBSD__) && defined(__arm__) + #include +#endif + +#if defined(ANDROID) && defined(__mips__) + #include +#endif + +#if defined(ANDROID) && defined(__arm__) + #include +#endif + +/* + * The compiler generates calls to __clear_cache() when creating + * trampoline functions on the stack for use with nested functions. + * It is expected to invalidate the instruction cache for the + * specified range. + */ + +void __clear_cache(void *start, void *end) { +#if __i386__ || __x86_64__ +/* + * Intel processors have a unified instruction and data cache + * so there is nothing to do + */ +#elif defined(__arm__) && !defined(__APPLE__) + #if defined(__NetBSD__) + struct arm_sync_icache_args arg; + + arg.addr = (uintptr_t)start; + arg.len = (uintptr_t)end - (uintptr_t)start; + + sysarch(ARM_SYNC_ICACHE, &arg); + #elif defined(ANDROID) + const register int start_reg __asm("r0") = (int) (intptr_t) start; + const register int end_reg __asm("r1") = (int) (intptr_t) end; + const register int flags __asm("r2") = 0; + const register int syscall_nr __asm("r7") = __ARM_NR_cacheflush; + __asm __volatile("svc 0x0" : "=r"(start_reg) + : "r"(syscall_nr), "r"(start_reg), "r"(end_reg), "r"(flags) : "r0"); + if (start_reg != 0) { + compilerrt_abort(); + } + #else + compilerrt_abort(); + #endif +#elif defined(ANDROID) && defined(__mips__) + const uintptr_t start_int = (uintptr_t) start; + const uintptr_t end_int = (uintptr_t) end; + _flush_cache(start, (end_int - start_int), BCACHE); +#elif defined(__aarch64__) && !defined(__APPLE__) + uint64_t xstart = (uint64_t)(uintptr_t) start; + uint64_t xend = (uint64_t)(uintptr_t) end; + + // Get Cache Type Info + uint64_t ctr_el0; + __asm __volatile("mrs %0, ctr_el0" : "=r"(ctr_el0)); + + /* + * dc & ic instructions must use 64bit registers so we don't use + * uintptr_t in case this runs in an IPL32 environment. + */ + const size_t dcache_line_size = 4 << ((ctr_el0 >> 16) & 15); + for (uint64_t addr = xstart; addr < xend; addr += dcache_line_size) + __asm __volatile("dc cvau, %0" :: "r"(addr)); + __asm __volatile("dsb ish"); + + const size_t icache_line_size = 4 << ((ctr_el0 >> 0) & 15); + for (uint64_t addr = xstart; addr < xend; addr += icache_line_size) + __asm __volatile("ic ivau, %0" :: "r"(addr)); + __asm __volatile("isb sy"); +#else + #if __APPLE__ + /* On Darwin, sys_icache_invalidate() provides this functionality */ + sys_icache_invalidate(start, end-start); + #else + compilerrt_abort(); + #endif +#endif +} + diff --git a/sdk/compiler-rt/clzdi2.c b/sdk/compiler-rt/clzdi2.c new file mode 100644 index 0000000000..b9e64da492 --- /dev/null +++ b/sdk/compiler-rt/clzdi2.c @@ -0,0 +1,29 @@ +/* ===-- clzdi2.c - Implement __clzdi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __clzdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: the number of leading 0-bits */ + +/* Precondition: a != 0 */ + +COMPILER_RT_ABI si_int +__clzdi2(di_int a) +{ + dwords x; + x.all = a; + const si_int f = -(x.s.high == 0); + return __builtin_clz((x.s.high & ~f) | (x.s.low & f)) + + (f & ((si_int)(sizeof(si_int) * CHAR_BIT))); +} diff --git a/sdk/compiler-rt/clzsi2.c b/sdk/compiler-rt/clzsi2.c new file mode 100644 index 0000000000..25b8ed2c4c --- /dev/null +++ b/sdk/compiler-rt/clzsi2.c @@ -0,0 +1,53 @@ +/* ===-- clzsi2.c - Implement __clzsi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __clzsi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: the number of leading 0-bits */ + +/* Precondition: a != 0 */ + +COMPILER_RT_ABI si_int +__clzsi2(si_int a) +{ + su_int x = (su_int)a; + si_int t = ((x & 0xFFFF0000) == 0) << 4; /* if (x is small) t = 16 else 0 */ + x >>= 16 - t; /* x = [0 - 0xFFFF] */ + su_int r = t; /* r = [0, 16] */ + /* return r + clz(x) */ + t = ((x & 0xFF00) == 0) << 3; + x >>= 8 - t; /* x = [0 - 0xFF] */ + r += t; /* r = [0, 8, 16, 24] */ + /* return r + clz(x) */ + t = ((x & 0xF0) == 0) << 2; + x >>= 4 - t; /* x = [0 - 0xF] */ + r += t; /* r = [0, 4, 8, 12, 16, 20, 24, 28] */ + /* return r + clz(x) */ + t = ((x & 0xC) == 0) << 1; + x >>= 2 - t; /* x = [0 - 3] */ + r += t; /* r = [0 - 30] and is even */ + /* return r + clz(x) */ +/* switch (x) + * { + * case 0: + * return r + 2; + * case 1: + * return r + 1; + * case 2: + * case 3: + * return r; + * } + */ + return r + ((2 - x) & -((x & 2) == 0)); +} diff --git a/sdk/compiler-rt/clzti2.c b/sdk/compiler-rt/clzti2.c new file mode 100644 index 0000000000..15a7b3c900 --- /dev/null +++ b/sdk/compiler-rt/clzti2.c @@ -0,0 +1,33 @@ +/* ===-- clzti2.c - Implement __clzti2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __clzti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: the number of leading 0-bits */ + +/* Precondition: a != 0 */ + +COMPILER_RT_ABI si_int +__clzti2(ti_int a) +{ + twords x; + x.all = a; + const di_int f = -(x.s.high == 0); + return __builtin_clzll((x.s.high & ~f) | (x.s.low & f)) + + ((si_int)f & ((si_int)(sizeof(di_int) * CHAR_BIT))); +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/cmpdi2.c b/sdk/compiler-rt/cmpdi2.c new file mode 100644 index 0000000000..52634d9c33 --- /dev/null +++ b/sdk/compiler-rt/cmpdi2.c @@ -0,0 +1,51 @@ +/* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __cmpdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: if (a < b) returns 0 +* if (a == b) returns 1 +* if (a > b) returns 2 +*/ + +COMPILER_RT_ABI si_int +__cmpdi2(di_int a, di_int b) +{ + dwords x; + x.all = a; + dwords y; + y.all = b; + if (x.s.high < y.s.high) + return 0; + if (x.s.high > y.s.high) + return 2; + if (x.s.low < y.s.low) + return 0; + if (x.s.low > y.s.low) + return 2; + return 1; +} + +#ifdef __ARM_EABI__ +/* Returns: if (a < b) returns -1 +* if (a == b) returns 0 +* if (a > b) returns 1 +*/ +COMPILER_RT_ABI si_int +__aeabi_lcmp(di_int a, di_int b) +{ + return __cmpdi2(a, b) - 1; +} +#endif + diff --git a/sdk/compiler-rt/cmpti2.c b/sdk/compiler-rt/cmpti2.c new file mode 100644 index 0000000000..2c8b56e29a --- /dev/null +++ b/sdk/compiler-rt/cmpti2.c @@ -0,0 +1,42 @@ +/* ===-- cmpti2.c - Implement __cmpti2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __cmpti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: if (a < b) returns 0 + * if (a == b) returns 1 + * if (a > b) returns 2 + */ + +COMPILER_RT_ABI si_int +__cmpti2(ti_int a, ti_int b) +{ + twords x; + x.all = a; + twords y; + y.all = b; + if (x.s.high < y.s.high) + return 0; + if (x.s.high > y.s.high) + return 2; + if (x.s.low < y.s.low) + return 0; + if (x.s.low > y.s.low) + return 2; + return 1; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/comparetf2.c b/sdk/compiler-rt/comparetf2.c new file mode 100644 index 0000000000..a6436de89e --- /dev/null +++ b/sdk/compiler-rt/comparetf2.c @@ -0,0 +1,133 @@ +//===-- lib/comparetf2.c - Quad-precision comparisons -------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// // This file implements the following soft-float comparison routines: +// +// __eqtf2 __getf2 __unordtf2 +// __letf2 __gttf2 +// __lttf2 +// __netf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __letf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __getf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unordtf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __letf2( ) and __getf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +enum LE_RESULT { + LE_LESS = -1, + LE_EQUAL = 0, + LE_GREATER = 1, + LE_UNORDERED = 1 +}; + +COMPILER_RT_ABI enum LE_RESULT __letf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + // If either a or b is NaN, they are unordered. + if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; + + // If a and b are both zeros, they are equal. + if ((aAbs | bAbs) == 0) return LE_EQUAL; + + // If at least one of a and b is positive, we get the same result comparing + // a and b as signed integers as we would with a floating-point compare. + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } + else { + // Otherwise, both are negative, so we need to flip the sense of the + // comparison to get the correct result. (This assumes a twos- or ones- + // complement integer representation; if integers are represented in a + // sign-magnitude representation, then this flip is incorrect). + if (aInt > bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } +} + +enum GE_RESULT { + GE_LESS = -1, + GE_EQUAL = 0, + GE_GREATER = 1, + GE_UNORDERED = -1 // Note: different from LE_UNORDERED +}; + +COMPILER_RT_ABI enum GE_RESULT __getf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; + if ((aAbs | bAbs) == 0) return GE_EQUAL; + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } else { + if (aInt > bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } +} + +COMPILER_RT_ABI int __unordtf2(fp_t a, fp_t b) { + const rep_t aAbs = toRep(a) & absMask; + const rep_t bAbs = toRep(b) & absMask; + return aAbs > infRep || bAbs > infRep; +} + +// The following are alternative names for the preceding routines. + +COMPILER_RT_ABI enum LE_RESULT __eqtf2(fp_t a, fp_t b) { + return __letf2(a, b); +} + +COMPILER_RT_ABI enum LE_RESULT __lttf2(fp_t a, fp_t b) { + return __letf2(a, b); +} + +COMPILER_RT_ABI enum LE_RESULT __netf2(fp_t a, fp_t b) { + return __letf2(a, b); +} + +COMPILER_RT_ABI enum GE_RESULT __gttf2(fp_t a, fp_t b) { + return __getf2(a, b); +} + +#endif diff --git a/sdk/compiler-rt/ctzdi2.c b/sdk/compiler-rt/ctzdi2.c new file mode 100644 index 0000000000..db3c6fdc08 --- /dev/null +++ b/sdk/compiler-rt/ctzdi2.c @@ -0,0 +1,29 @@ +/* ===-- ctzdi2.c - Implement __ctzdi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ctzdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: the number of trailing 0-bits */ + +/* Precondition: a != 0 */ + +COMPILER_RT_ABI si_int +__ctzdi2(di_int a) +{ + dwords x; + x.all = a; + const si_int f = -(x.s.low == 0); + return __builtin_ctz((x.s.high & f) | (x.s.low & ~f)) + + (f & ((si_int)(sizeof(si_int) * CHAR_BIT))); +} diff --git a/sdk/compiler-rt/ctzsi2.c b/sdk/compiler-rt/ctzsi2.c new file mode 100644 index 0000000000..c69486ea44 --- /dev/null +++ b/sdk/compiler-rt/ctzsi2.c @@ -0,0 +1,57 @@ +/* ===-- ctzsi2.c - Implement __ctzsi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ctzsi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: the number of trailing 0-bits */ + +/* Precondition: a != 0 */ + +COMPILER_RT_ABI si_int +__ctzsi2(si_int a) +{ + su_int x = (su_int)a; + si_int t = ((x & 0x0000FFFF) == 0) << 4; /* if (x has no small bits) t = 16 else 0 */ + x >>= t; /* x = [0 - 0xFFFF] + higher garbage bits */ + su_int r = t; /* r = [0, 16] */ + /* return r + ctz(x) */ + t = ((x & 0x00FF) == 0) << 3; + x >>= t; /* x = [0 - 0xFF] + higher garbage bits */ + r += t; /* r = [0, 8, 16, 24] */ + /* return r + ctz(x) */ + t = ((x & 0x0F) == 0) << 2; + x >>= t; /* x = [0 - 0xF] + higher garbage bits */ + r += t; /* r = [0, 4, 8, 12, 16, 20, 24, 28] */ + /* return r + ctz(x) */ + t = ((x & 0x3) == 0) << 1; + x >>= t; + x &= 3; /* x = [0 - 3] */ + r += t; /* r = [0 - 30] and is even */ + /* return r + ctz(x) */ + +/* The branch-less return statement below is equivalent + * to the following switch statement: + * switch (x) + * { + * case 0: + * return r + 2; + * case 2: + * return r + 1; + * case 1: + * case 3: + * return r; + * } + */ + return r + ((2 - (x >> 1)) & -((x & 1) == 0)); +} diff --git a/sdk/compiler-rt/ctzti2.c b/sdk/compiler-rt/ctzti2.c new file mode 100644 index 0000000000..45de682700 --- /dev/null +++ b/sdk/compiler-rt/ctzti2.c @@ -0,0 +1,33 @@ +/* ===-- ctzti2.c - Implement __ctzti2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ctzti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: the number of trailing 0-bits */ + +/* Precondition: a != 0 */ + +COMPILER_RT_ABI si_int +__ctzti2(ti_int a) +{ + twords x; + x.all = a; + const di_int f = -(x.s.low == 0); + return __builtin_ctzll((x.s.high & f) | (x.s.low & ~f)) + + ((si_int)f & ((si_int)(sizeof(di_int) * CHAR_BIT))); +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/divdi3.c b/sdk/compiler-rt/divdi3.c new file mode 100644 index 0000000000..b8eebcb204 --- /dev/null +++ b/sdk/compiler-rt/divdi3.c @@ -0,0 +1,29 @@ +/* ===-- divdi3.c - Implement __divdi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a / b */ + +COMPILER_RT_ABI di_int +__divdi3(di_int a, di_int b) +{ + const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1; + di_int s_a = a >> bits_in_dword_m1; /* s_a = a < 0 ? -1 : 0 */ + di_int s_b = b >> bits_in_dword_m1; /* s_b = b < 0 ? -1 : 0 */ + a = (a ^ s_a) - s_a; /* negate if s_a == -1 */ + b = (b ^ s_b) - s_b; /* negate if s_b == -1 */ + s_a ^= s_b; /*sign of quotient */ + return (__udivmoddi4(a, b, (du_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */ +} diff --git a/sdk/compiler-rt/divsi3.c b/sdk/compiler-rt/divsi3.c new file mode 100644 index 0000000000..bab4aefda3 --- /dev/null +++ b/sdk/compiler-rt/divsi3.c @@ -0,0 +1,37 @@ +/* ===-- divsi3.c - Implement __divsi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a / b */ + +ARM_EABI_FNALIAS(idiv, divsi3) + +COMPILER_RT_ABI si_int +__divsi3(si_int a, si_int b) +{ + const int bits_in_word_m1 = (int)(sizeof(si_int) * CHAR_BIT) - 1; + si_int s_a = a >> bits_in_word_m1; /* s_a = a < 0 ? -1 : 0 */ + si_int s_b = b >> bits_in_word_m1; /* s_b = b < 0 ? -1 : 0 */ + a = (a ^ s_a) - s_a; /* negate if s_a == -1 */ + b = (b ^ s_b) - s_b; /* negate if s_b == -1 */ + s_a ^= s_b; /* sign of quotient */ + /* + * On CPUs without unsigned hardware division support, + * this calls __udivsi3 (notice the cast to su_int). + * On CPUs with unsigned hardware division support, + * this uses the unsigned division instruction. + */ + return ((su_int)a/(su_int)b ^ s_a) - s_a; /* negate if s_a == -1 */ +} diff --git a/sdk/compiler-rt/divtf3.c b/sdk/compiler-rt/divtf3.c new file mode 100644 index 0000000000..e81dab826b --- /dev/null +++ b/sdk/compiler-rt/divtf3.c @@ -0,0 +1,203 @@ +//===-- lib/divtf3.c - Quad-precision division --------------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements quad-precision soft-float division +// with the IEEE-754 default rounding (to nearest, ties to even). +// +// For simplicity, this implementation currently flushes denormals to zero. +// It should be a fairly straightforward exercise to implement gradual +// underflow with correct rounding. +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +COMPILER_RT_ABI fp_t __divtf3(fp_t a, fp_t b) { + + const unsigned int aExponent = toRep(a) >> significandBits & maxExponent; + const unsigned int bExponent = toRep(b) >> significandBits & maxExponent; + const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit; + + rep_t aSignificand = toRep(a) & significandMask; + rep_t bSignificand = toRep(b) & significandMask; + int scale = 0; + + // Detect if a or b is zero, denormal, infinity, or NaN. + if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) { + + const rep_t aAbs = toRep(a) & absMask; + const rep_t bAbs = toRep(b) & absMask; + + // NaN / anything = qNaN + if (aAbs > infRep) return fromRep(toRep(a) | quietBit); + // anything / NaN = qNaN + if (bAbs > infRep) return fromRep(toRep(b) | quietBit); + + if (aAbs == infRep) { + // infinity / infinity = NaN + if (bAbs == infRep) return fromRep(qnanRep); + // infinity / anything else = +/- infinity + else return fromRep(aAbs | quotientSign); + } + + // anything else / infinity = +/- 0 + if (bAbs == infRep) return fromRep(quotientSign); + + if (!aAbs) { + // zero / zero = NaN + if (!bAbs) return fromRep(qnanRep); + // zero / anything else = +/- zero + else return fromRep(quotientSign); + } + // anything else / zero = +/- infinity + if (!bAbs) return fromRep(infRep | quotientSign); + + // one or both of a or b is denormal, the other (if applicable) is a + // normal number. Renormalize one or both of a and b, and set scale to + // include the necessary exponent adjustment. + if (aAbs < implicitBit) scale += normalize(&aSignificand); + if (bAbs < implicitBit) scale -= normalize(&bSignificand); + } + + // Or in the implicit significand bit. (If we fell through from the + // denormal path it was already set by normalize( ), but setting it twice + // won't hurt anything.) + aSignificand |= implicitBit; + bSignificand |= implicitBit; + int quotientExponent = aExponent - bExponent + scale; + + // Align the significand of b as a Q63 fixed-point number in the range + // [1, 2.0) and get a Q64 approximate reciprocal using a small minimax + // polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This + // is accurate to about 3.5 binary digits. + const uint64_t q63b = bSignificand >> 49; + uint64_t recip64 = UINT64_C(0x7504f333F9DE6484) - q63b; + // 0x7504f333F9DE6484 / 2^64 + 1 = 3/4 + 1/sqrt(2) + + // Now refine the reciprocal estimate using a Newton-Raphson iteration: + // + // x1 = x0 * (2 - x0 * b) + // + // This doubles the number of correct binary digits in the approximation + // with each iteration. + uint64_t correction64; + correction64 = -((rep_t)recip64 * q63b >> 64); + recip64 = (rep_t)recip64 * correction64 >> 63; + correction64 = -((rep_t)recip64 * q63b >> 64); + recip64 = (rep_t)recip64 * correction64 >> 63; + correction64 = -((rep_t)recip64 * q63b >> 64); + recip64 = (rep_t)recip64 * correction64 >> 63; + correction64 = -((rep_t)recip64 * q63b >> 64); + recip64 = (rep_t)recip64 * correction64 >> 63; + correction64 = -((rep_t)recip64 * q63b >> 64); + recip64 = (rep_t)recip64 * correction64 >> 63; + + // recip64 might have overflowed to exactly zero in the preceeding + // computation if the high word of b is exactly 1.0. This would sabotage + // the full-width final stage of the computation that follows, so we adjust + // recip64 downward by one bit. + recip64--; + + // We need to perform one more iteration to get us to 112 binary digits; + // The last iteration needs to happen with extra precision. + const uint64_t q127blo = bSignificand << 15; + rep_t correction, reciprocal; + + // NOTE: This operation is equivalent to __multi3, which is not implemented + // in some architechure + rep_t r64q63, r64q127, r64cH, r64cL, dummy; + wideMultiply((rep_t)recip64, (rep_t)q63b, &dummy, &r64q63); + wideMultiply((rep_t)recip64, (rep_t)q127blo, &dummy, &r64q127); + + correction = -(r64q63 + (r64q127 >> 64)); + + uint64_t cHi = correction >> 64; + uint64_t cLo = correction; + + wideMultiply((rep_t)recip64, (rep_t)cHi, &dummy, &r64cH); + wideMultiply((rep_t)recip64, (rep_t)cLo, &dummy, &r64cL); + + reciprocal = r64cH + (r64cL >> 64); + + // We already adjusted the 64-bit estimate, now we need to adjust the final + // 128-bit reciprocal estimate downward to ensure that it is strictly smaller + // than the infinitely precise exact reciprocal. Because the computation + // of the Newton-Raphson step is truncating at every step, this adjustment + // is small; most of the work is already done. + reciprocal -= 2; + + // The numerical reciprocal is accurate to within 2^-112, lies in the + // interval [0.5, 1.0), and is strictly smaller than the true reciprocal + // of b. Multiplying a by this reciprocal thus gives a numerical q = a/b + // in Q127 with the following properties: + // + // 1. q < a/b + // 2. q is in the interval [0.5, 2.0) + // 3. the error in q is bounded away from 2^-113 (actually, we have a + // couple of bits to spare, but this is all we need). + + // We need a 128 x 128 multiply high to compute q, which isn't a basic + // operation in C, so we need to be a little bit fussy. + rep_t quotient, quotientLo; + wideMultiply(aSignificand << 2, reciprocal, "ient, "ientLo); + + // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0). + // In either case, we are going to compute a residual of the form + // + // r = a - q*b + // + // We know from the construction of q that r satisfies: + // + // 0 <= r < ulp(q)*b + // + // if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we + // already have the correct result. The exact halfway case cannot occur. + // We also take this time to right shift quotient if it falls in the [1,2) + // range and adjust the exponent accordingly. + rep_t residual; + rep_t qb; + + if (quotient < (implicitBit << 1)) { + wideMultiply(quotient, bSignificand, &dummy, &qb); + residual = (aSignificand << 113) - qb; + quotientExponent--; + } else { + quotient >>= 1; + wideMultiply(quotient, bSignificand, &dummy, &qb); + residual = (aSignificand << 112) - qb; + } + + const int writtenExponent = quotientExponent + exponentBias; + + if (writtenExponent >= maxExponent) { + // If we have overflowed the exponent, return infinity. + return fromRep(infRep | quotientSign); + } + else if (writtenExponent < 1) { + // Flush denormals to zero. In the future, it would be nice to add + // code to round them correctly. + return fromRep(quotientSign); + } + else { + const bool round = (residual << 1) >= bSignificand; + // Clear the implicit bit + rep_t absResult = quotient & significandMask; + // Insert the exponent + absResult |= (rep_t)writtenExponent << significandBits; + // Round + absResult += round; + // Insert the sign and return + const long double result = fromRep(absResult | quotientSign); + return result; + } +} + +#endif diff --git a/sdk/compiler-rt/divti3.c b/sdk/compiler-rt/divti3.c new file mode 100644 index 0000000000..c73eae28fe --- /dev/null +++ b/sdk/compiler-rt/divti3.c @@ -0,0 +1,33 @@ +/* ===-- divti3.c - Implement __divti3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: a / b */ + +COMPILER_RT_ABI ti_int +__divti3(ti_int a, ti_int b) +{ + const int bits_in_tword_m1 = (int)(sizeof(ti_int) * CHAR_BIT) - 1; + ti_int s_a = a >> bits_in_tword_m1; /* s_a = a < 0 ? -1 : 0 */ + ti_int s_b = b >> bits_in_tword_m1; /* s_b = b < 0 ? -1 : 0 */ + a = (a ^ s_a) - s_a; /* negate if s_a == -1 */ + b = (b ^ s_b) - s_b; /* negate if s_b == -1 */ + s_a ^= s_b; /* sign of quotient */ + return (__udivmodti4(a, b, (tu_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */ +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/extenddftf2.c b/sdk/compiler-rt/extenddftf2.c new file mode 100644 index 0000000000..86dab8f03a --- /dev/null +++ b/sdk/compiler-rt/extenddftf2.c @@ -0,0 +1,23 @@ +//===-- lib/extenddftf2.c - double -> quad conversion -------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#define SRC_DOUBLE +#define DST_QUAD +#include "fp_extend_impl.inc" + +COMPILER_RT_ABI long double __extenddftf2(double a) { + return __extendXfYf2__(a); +} + +#endif diff --git a/sdk/compiler-rt/extendsftf2.c b/sdk/compiler-rt/extendsftf2.c new file mode 100644 index 0000000000..2eeeba2848 --- /dev/null +++ b/sdk/compiler-rt/extendsftf2.c @@ -0,0 +1,23 @@ +//===-- lib/extendsftf2.c - single -> quad conversion -------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#define SRC_SINGLE +#define DST_QUAD +#include "fp_extend_impl.inc" + +COMPILER_RT_ABI long double __extendsftf2(float a) { + return __extendXfYf2__(a); +} + +#endif diff --git a/sdk/compiler-rt/ffsdi2.c b/sdk/compiler-rt/ffsdi2.c new file mode 100644 index 0000000000..a5ac9900ff --- /dev/null +++ b/sdk/compiler-rt/ffsdi2.c @@ -0,0 +1,33 @@ +/* ===-- ffsdi2.c - Implement __ffsdi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ffsdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: the index of the least significant 1-bit in a, or + * the value zero if a is zero. The least significant bit is index one. + */ + +COMPILER_RT_ABI si_int +__ffsdi2(di_int a) +{ + dwords x; + x.all = a; + if (x.s.low == 0) + { + if (x.s.high == 0) + return 0; + return __builtin_ctz(x.s.high) + (1 + sizeof(si_int) * CHAR_BIT); + } + return __builtin_ctz(x.s.low) + 1; +} diff --git a/sdk/compiler-rt/ffsti2.c b/sdk/compiler-rt/ffsti2.c new file mode 100644 index 0000000000..dcdb3bd7f8 --- /dev/null +++ b/sdk/compiler-rt/ffsti2.c @@ -0,0 +1,37 @@ +/* ===-- ffsti2.c - Implement __ffsti2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ffsti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: the index of the least significant 1-bit in a, or + * the value zero if a is zero. The least significant bit is index one. + */ + +COMPILER_RT_ABI si_int +__ffsti2(ti_int a) +{ + twords x; + x.all = a; + if (x.s.low == 0) + { + if (x.s.high == 0) + return 0; + return __builtin_ctzll(x.s.high) + (1 + sizeof(di_int) * CHAR_BIT); + } + return __builtin_ctzll(x.s.low) + 1; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/fixtfsi.c b/sdk/compiler-rt/fixtfsi.c new file mode 100644 index 0000000000..12b082d252 --- /dev/null +++ b/sdk/compiler-rt/fixtfsi.c @@ -0,0 +1,26 @@ +//===-- lib/fixtfsi.c - Quad-precision -> integer conversion ------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements quad-precision to integer conversion for the +// compiler-rt library. No range checking is performed; the behavior of this +// conversion is undefined for out of range values in the C standard. +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#include "fp_fixsi_impl.inc" + +COMPILER_RT_ABI int __fixtfsi(fp_t a) { + return __fixXsi(a); +} + +#endif diff --git a/sdk/compiler-rt/floatsitf.c b/sdk/compiler-rt/floatsitf.c new file mode 100644 index 0000000000..85346933f8 --- /dev/null +++ b/sdk/compiler-rt/floatsitf.c @@ -0,0 +1,52 @@ +//===-- lib/floatsitf.c - integer -> quad-precision conversion ----*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements integer to quad-precision conversion for the +// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even +// mode. +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +COMPILER_RT_ABI fp_t __floatsitf(int a) { + + const int aWidth = sizeof a * CHAR_BIT; + + // Handle zero as a special case to protect clz + if (a == 0) + return fromRep(0); + + // All other cases begin by extracting the sign and absolute value of a + rep_t sign = 0; + unsigned aAbs = (unsigned)a; + if (a < 0) { + sign = signBit; + aAbs += 0x80000000; + } + + // Exponent of (fp_t)a is the width of abs(a). + const int exponent = (aWidth - 1) - __builtin_clz(a); + rep_t result; + + // Shift a into the significand field and clear the implicit bit. Extra + // cast to unsigned int is necessary to get the correct behavior for + // the input INT_MIN. + const int shift = significandBits - exponent; + result = (rep_t)aAbs << shift ^ implicitBit; + + // Insert the exponent + result += (rep_t)(exponent + exponentBias) << significandBits; + // Insert the sign bit and return + return fromRep(result | sign); +} + +#endif diff --git a/sdk/compiler-rt/floatunsitf.c b/sdk/compiler-rt/floatunsitf.c new file mode 100644 index 0000000000..1cd1842e70 --- /dev/null +++ b/sdk/compiler-rt/floatunsitf.c @@ -0,0 +1,40 @@ +//===-- lib/floatunsitf.c - uint -> quad-precision conversion -----*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements unsigned integer to quad-precision conversion for the +// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even +// mode. +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +COMPILER_RT_ABI fp_t __floatunsitf(unsigned int a) { + + const int aWidth = sizeof a * CHAR_BIT; + + // Handle zero as a special case to protect clz + if (a == 0) return fromRep(0); + + // Exponent of (fp_t)a is the width of abs(a). + const int exponent = (aWidth - 1) - __builtin_clz(a); + rep_t result; + + // Shift a into the significand field and clear the implicit bit. + const int shift = significandBits - exponent; + result = (rep_t)a << shift ^ implicitBit; + + // Insert the exponent + result += (rep_t)(exponent + exponentBias) << significandBits; + return fromRep(result); +} + +#endif diff --git a/sdk/compiler-rt/fp_extend.h b/sdk/compiler-rt/fp_extend.h new file mode 100644 index 0000000000..fff676eeca --- /dev/null +++ b/sdk/compiler-rt/fp_extend.h @@ -0,0 +1,76 @@ +//===-lib/fp_extend.h - low precision -> high precision conversion -*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Set source and destination setting +// +//===----------------------------------------------------------------------===// + +#ifndef FP_EXTEND_HEADER +#define FP_EXTEND_HEADER + +#include "int_lib.h" + +#if defined SRC_SINGLE +typedef float src_t; +typedef uint32_t src_rep_t; +#define SRC_REP_C UINT32_C +static const int srcSigBits = 23; +#define src_rep_t_clz __builtin_clz + +#elif defined SRC_DOUBLE +typedef double src_t; +typedef uint64_t src_rep_t; +#define SRC_REP_C UINT64_C +static const int srcSigBits = 52; +static inline int src_rep_t_clz(src_rep_t a) { +#if defined __LP64__ + return __builtin_clzl(a); +#else + if (a & REP_C(0xffffffff00000000)) + return __builtin_clz(a >> 32); + else + return 32 + __builtin_clz(a & REP_C(0xffffffff)); +#endif +} + +#else +#error Source should be single precision or double precision! +#endif //end source precision + +#if defined DST_DOUBLE +typedef double dst_t; +typedef uint64_t dst_rep_t; +#define DST_REP_C UINT64_C +static const int dstSigBits = 52; + +#elif defined DST_QUAD +typedef long double dst_t; +typedef __uint128_t dst_rep_t; +#define DST_REP_C (__uint128_t) +static const int dstSigBits = 112; + +#else +#error Destination should be double precision or quad precision! +#endif //end destination precision + +// End of specialization parameters. Two helper routines for conversion to and +// from the representation of floating-point data as integer values follow. + +static inline src_rep_t srcToRep(src_t x) { + const union { src_t f; src_rep_t i; } rep = {.f = x}; + return rep.i; +} + +static inline dst_t dstFromRep(dst_rep_t x) { + const union { dst_t f; dst_rep_t i; } rep = {.i = x}; + return rep.f; +} +// End helper routines. Conversion implementation follows. + +#endif //FP_EXTEND_HEADER diff --git a/sdk/compiler-rt/fp_lib.h b/sdk/compiler-rt/fp_lib.h new file mode 100644 index 0000000000..faebb99ecd --- /dev/null +++ b/sdk/compiler-rt/fp_lib.h @@ -0,0 +1,270 @@ +//===-- lib/fp_lib.h - Floating-point utilities -------------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a configuration header for soft-float routines in compiler-rt. +// This file does not provide any part of the compiler-rt interface, but defines +// many useful constants and utility routines that are used in the +// implementation of the soft-float routines in compiler-rt. +// +// Assumes that float, double and long double correspond to the IEEE-754 +// binary32, binary64 and binary 128 types, respectively, and that integer +// endianness matches floating point endianness on the target platform. +// +//===----------------------------------------------------------------------===// + +#ifndef FP_LIB_HEADER +#define FP_LIB_HEADER + +#include +#include +#include +#include "int_lib.h" + +// x86_64 FreeBSD prior v9.3 define fixed-width types incorrectly in +// 32-bit mode. +#if defined(__FreeBSD__) && defined(__i386__) +# include +# if __FreeBSD_version < 903000 // v9.3 +# define uint64_t unsigned long long +# define int64_t long long +# undef UINT64_C +# define UINT64_C(c) (c ## ULL) +# endif +#endif + +#if defined SINGLE_PRECISION + +typedef uint32_t rep_t; +typedef int32_t srep_t; +typedef float fp_t; +#define REP_C UINT32_C +#define significandBits 23 + +static inline int rep_clz(rep_t a) { + return __builtin_clz(a); +} + +// 32x32 --> 64 bit multiply +static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { + const uint64_t product = (uint64_t)a*b; + *hi = product >> 32; + *lo = product; +} +COMPILER_RT_ABI fp_t __addsf3(fp_t a, fp_t b); + +#elif defined DOUBLE_PRECISION + +typedef uint64_t rep_t; +typedef int64_t srep_t; +typedef double fp_t; +#define REP_C UINT64_C +#define significandBits 52 + +static inline int rep_clz(rep_t a) { +#if defined __LP64__ + return __builtin_clzl(a); +#else + if (a & REP_C(0xffffffff00000000)) + return __builtin_clz(a >> 32); + else + return 32 + __builtin_clz(a & REP_C(0xffffffff)); +#endif +} + +#define loWord(a) (a & 0xffffffffU) +#define hiWord(a) (a >> 32) + +// 64x64 -> 128 wide multiply for platforms that don't have such an operation; +// many 64-bit platforms have this operation, but they tend to have hardware +// floating-point, so we don't bother with a special case for them here. +static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { + // Each of the component 32x32 -> 64 products + const uint64_t plolo = loWord(a) * loWord(b); + const uint64_t plohi = loWord(a) * hiWord(b); + const uint64_t philo = hiWord(a) * loWord(b); + const uint64_t phihi = hiWord(a) * hiWord(b); + // Sum terms that contribute to lo in a way that allows us to get the carry + const uint64_t r0 = loWord(plolo); + const uint64_t r1 = hiWord(plolo) + loWord(plohi) + loWord(philo); + *lo = r0 + (r1 << 32); + // Sum terms contributing to hi with the carry from lo + *hi = hiWord(plohi) + hiWord(philo) + hiWord(r1) + phihi; +} +#undef loWord +#undef hiWord + +COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b); + +#elif defined QUAD_PRECISION +#if __LDBL_MANT_DIG__ == 113 +#define CRT_LDBL_128BIT +typedef __uint128_t rep_t; +typedef __int128_t srep_t; +typedef long double fp_t; +#define REP_C (__uint128_t) +// Note: Since there is no explicit way to tell compiler the constant is a +// 128-bit integer, we let the constant be casted to 128-bit integer +#define significandBits 112 + +static inline int rep_clz(rep_t a) { + const union + { + __uint128_t ll; +#if _YUGA_BIG_ENDIAN + struct { uint64_t high, low; } s; +#else + struct { uint64_t low, high; } s; +#endif + } uu = { .ll = a }; + + uint64_t word; + uint64_t add; + + if (uu.s.high){ + word = uu.s.high; + add = 0; + } + else{ + word = uu.s.low; + add = 64; + } + return __builtin_clzll(word) + add; +} + +#define Word_LoMask UINT64_C(0x00000000ffffffff) +#define Word_HiMask UINT64_C(0xffffffff00000000) +#define Word_FullMask UINT64_C(0xffffffffffffffff) +#define Word_1(a) (uint64_t)((a >> 96) & Word_LoMask) +#define Word_2(a) (uint64_t)((a >> 64) & Word_LoMask) +#define Word_3(a) (uint64_t)((a >> 32) & Word_LoMask) +#define Word_4(a) (uint64_t)(a & Word_LoMask) + +// 128x128 -> 256 wide multiply for platforms that don't have such an operation; +// many 64-bit platforms have this operation, but they tend to have hardware +// floating-point, so we don't bother with a special case for them here. +static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { + + const uint64_t product11 = Word_1(a) * Word_1(b); + const uint64_t product12 = Word_1(a) * Word_2(b); + const uint64_t product13 = Word_1(a) * Word_3(b); + const uint64_t product14 = Word_1(a) * Word_4(b); + const uint64_t product21 = Word_2(a) * Word_1(b); + const uint64_t product22 = Word_2(a) * Word_2(b); + const uint64_t product23 = Word_2(a) * Word_3(b); + const uint64_t product24 = Word_2(a) * Word_4(b); + const uint64_t product31 = Word_3(a) * Word_1(b); + const uint64_t product32 = Word_3(a) * Word_2(b); + const uint64_t product33 = Word_3(a) * Word_3(b); + const uint64_t product34 = Word_3(a) * Word_4(b); + const uint64_t product41 = Word_4(a) * Word_1(b); + const uint64_t product42 = Word_4(a) * Word_2(b); + const uint64_t product43 = Word_4(a) * Word_3(b); + const uint64_t product44 = Word_4(a) * Word_4(b); + + const __uint128_t sum0 = (__uint128_t)product44; + const __uint128_t sum1 = (__uint128_t)product34 + + (__uint128_t)product43; + const __uint128_t sum2 = (__uint128_t)product24 + + (__uint128_t)product33 + + (__uint128_t)product42; + const __uint128_t sum3 = (__uint128_t)product14 + + (__uint128_t)product23 + + (__uint128_t)product32 + + (__uint128_t)product41; + const __uint128_t sum4 = (__uint128_t)product13 + + (__uint128_t)product22 + + (__uint128_t)product31; + const __uint128_t sum5 = (__uint128_t)product12 + + (__uint128_t)product21; + const __uint128_t sum6 = (__uint128_t)product11; + + const __uint128_t r0 = (sum0 & Word_FullMask) + + ((sum1 & Word_LoMask) << 32); + const __uint128_t r1 = (sum0 >> 64) + + ((sum1 >> 32) & Word_FullMask) + + (sum2 & Word_FullMask) + + ((sum3 << 32) & Word_HiMask); + + *lo = r0 + (r1 << 64); + *hi = (r1 >> 64) + + (sum1 >> 96) + + (sum2 >> 64) + + (sum3 >> 32) + + sum4 + + (sum5 << 32) + + (sum6 << 64); +} +#undef Word_1 +#undef Word_2 +#undef Word_3 +#undef Word_4 +#undef Word_HiMask +#undef Word_LoMask +#undef Word_FullMask +#endif // __LDBL_MANT_DIG__ == 113 +#else +#error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined. +#endif + +#if defined(SINGLE_PRECISION) || defined(DOUBLE_PRECISION) || defined(CRT_LDBL_128BIT) +#define typeWidth (sizeof(rep_t)*CHAR_BIT) +#define exponentBits (typeWidth - significandBits - 1) +#define maxExponent ((1 << exponentBits) - 1) +#define exponentBias (maxExponent >> 1) + +#define implicitBit (REP_C(1) << significandBits) +#define significandMask (implicitBit - 1U) +#define signBit (REP_C(1) << (significandBits + exponentBits)) +#define absMask (signBit - 1U) +#define exponentMask (absMask ^ significandMask) +#define oneRep ((rep_t)exponentBias << significandBits) +#define infRep exponentMask +#define quietBit (implicitBit >> 1) +#define qnanRep (exponentMask | quietBit) + +static inline rep_t toRep(fp_t x) { + const union { fp_t f; rep_t i; } rep = {.f = x}; + return rep.i; +} + +static inline fp_t fromRep(rep_t x) { + const union { fp_t f; rep_t i; } rep = {.i = x}; + return rep.f; +} + +static inline int normalize(rep_t *significand) { + const int shift = rep_clz(*significand) - rep_clz(implicitBit); + *significand <<= shift; + return 1 - shift; +} + +static inline void wideLeftShift(rep_t *hi, rep_t *lo, int count) { + *hi = *hi << count | *lo >> (typeWidth - count); + *lo = *lo << count; +} + +static inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, unsigned int count) { + if (count < typeWidth) { + const bool sticky = *lo << (typeWidth - count); + *lo = *hi << (typeWidth - count) | *lo >> count | sticky; + *hi = *hi >> count; + } + else if (count < 2*typeWidth) { + const bool sticky = *hi << (2*typeWidth - count) | *lo; + *lo = *hi >> (count - typeWidth) | sticky; + *hi = 0; + } else { + const bool sticky = *hi | *lo; + *lo = sticky; + *hi = 0; + } +} +#endif + +#endif // FP_LIB_HEADER diff --git a/sdk/compiler-rt/fp_trunc.h b/sdk/compiler-rt/fp_trunc.h new file mode 100644 index 0000000000..49a9aebbc6 --- /dev/null +++ b/sdk/compiler-rt/fp_trunc.h @@ -0,0 +1,64 @@ +//=== lib/fp_trunc.h - high precision -> low precision conversion *- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Set source and destination precision setting +// +//===----------------------------------------------------------------------===// + +#ifndef FP_TRUNC_HEADER +#define FP_TRUNC_HEADER + +#include "int_lib.h" + +#if defined SRC_DOUBLE +typedef double src_t; +typedef uint64_t src_rep_t; +#define SRC_REP_C UINT64_C +static const int srcSigBits = 52; + +#elif defined SRC_QUAD +typedef long double src_t; +typedef __uint128_t src_rep_t; +#define SRC_REP_C (__uint128_t) +static const int srcSigBits = 112; + +#else +#error Source should be double precision or quad precision! +#endif //end source precision + +#if defined DST_DOUBLE +typedef double dst_t; +typedef uint64_t dst_rep_t; +#define DST_REP_C UINT64_C +static const int dstSigBits = 52; + +#elif defined DST_SINGLE +typedef float dst_t; +typedef uint32_t dst_rep_t; +#define DST_REP_C UINT32_C +static const int dstSigBits = 23; + +#else +#error Destination should be single precision or double precision! +#endif //end destination precision + +// End of specialization parameters. Two helper routines for conversion to and +// from the representation of floating-point data as integer values follow. + +static inline src_rep_t srcToRep(src_t x) { + const union { src_t f; src_rep_t i; } rep = {.f = x}; + return rep.i; +} + +static inline dst_t dstFromRep(dst_rep_t x) { + const union { dst_t f; dst_rep_t i; } rep = {.i = x}; + return rep.f; +} + +#endif // FP_TRUNC_HEADER diff --git a/sdk/compiler-rt/int_endianness.h b/sdk/compiler-rt/int_endianness.h new file mode 100644 index 0000000000..7ac5056224 --- /dev/null +++ b/sdk/compiler-rt/int_endianness.h @@ -0,0 +1,113 @@ +/* ===-- int_endianness.h - configuration header for compiler-rt ------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file is a configuration header for compiler-rt. + * This file is not part of the interface of this library. + * + * ===----------------------------------------------------------------------=== + */ + +#ifndef INT_ENDIANNESS_H +#define INT_ENDIANNESS_H + +#if defined(__SVR4) && defined(__sun) +#include + +#if defined(_BIG_ENDIAN) +#define _YUGA_LITTLE_ENDIAN 0 +#define _YUGA_BIG_ENDIAN 1 +#elif defined(_LITTLE_ENDIAN) +#define _YUGA_LITTLE_ENDIAN 1 +#define _YUGA_BIG_ENDIAN 0 +#else /* !_LITTLE_ENDIAN */ +#error "unknown endianness" +#endif /* !_LITTLE_ENDIAN */ + +#endif /* Solaris and AuroraUX. */ + +/* .. */ + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ + defined(__minix) +#include + +#if _BYTE_ORDER == _BIG_ENDIAN +#define _YUGA_LITTLE_ENDIAN 0 +#define _YUGA_BIG_ENDIAN 1 +#elif _BYTE_ORDER == _LITTLE_ENDIAN +#define _YUGA_LITTLE_ENDIAN 1 +#define _YUGA_BIG_ENDIAN 0 +#endif /* _BYTE_ORDER */ + +#endif /* *BSD */ + +#if defined(__OpenBSD__) || defined(__Bitrig__) +#include + +#if _BYTE_ORDER == _BIG_ENDIAN +#define _YUGA_LITTLE_ENDIAN 0 +#define _YUGA_BIG_ENDIAN 1 +#elif _BYTE_ORDER == _LITTLE_ENDIAN +#define _YUGA_LITTLE_ENDIAN 1 +#define _YUGA_BIG_ENDIAN 0 +#endif /* _BYTE_ORDER */ + +#endif /* OpenBSD and Bitrig. */ + +/* .. */ + +/* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the + * compiler (at least with GCC) */ +#if defined(__APPLE__) || defined(__ellcc__ ) + +#ifdef __BIG_ENDIAN__ +#if __BIG_ENDIAN__ +#define _YUGA_LITTLE_ENDIAN 0 +#define _YUGA_BIG_ENDIAN 1 +#endif +#endif /* __BIG_ENDIAN__ */ + +#ifdef __LITTLE_ENDIAN__ +#if __LITTLE_ENDIAN__ +#define _YUGA_LITTLE_ENDIAN 1 +#define _YUGA_BIG_ENDIAN 0 +#endif +#endif /* __LITTLE_ENDIAN__ */ + +#endif /* Mac OSX */ + +/* .. */ + +#if defined(__linux__) +#include + +#if __BYTE_ORDER == __BIG_ENDIAN +#define _YUGA_LITTLE_ENDIAN 0 +#define _YUGA_BIG_ENDIAN 1 +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define _YUGA_LITTLE_ENDIAN 1 +#define _YUGA_BIG_ENDIAN 0 +#endif /* __BYTE_ORDER */ + +#endif /* GNU/Linux */ + +#if defined(_WIN32) + +#define _YUGA_LITTLE_ENDIAN 1 +#define _YUGA_BIG_ENDIAN 0 + +#endif /* Windows */ + +/* . */ + +#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN) +#error Unable to determine endian +#endif /* Check we found an endianness correctly. */ + +#endif /* INT_ENDIANNESS_H */ diff --git a/sdk/compiler-rt/int_lib.h b/sdk/compiler-rt/int_lib.h new file mode 100644 index 0000000000..ff314da986 --- /dev/null +++ b/sdk/compiler-rt/int_lib.h @@ -0,0 +1,70 @@ +/* ===-- int_lib.h - configuration header for compiler-rt -----------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file is a configuration header for compiler-rt. + * This file is not part of the interface of this library. + * + * ===----------------------------------------------------------------------=== + */ + +#ifndef INT_LIB_H +#define INT_LIB_H + +/* Assumption: Signed integral is 2's complement. */ +/* Assumption: Right shift of signed negative is arithmetic shift. */ +/* Assumption: Endianness is little or big (not mixed). */ + +/* ABI macro definitions */ + +#if __ARM_EABI__ +# define ARM_EABI_FNALIAS(aeabi_name, name) \ + void __aeabi_##aeabi_name() __attribute__((alias("__" #name))); +# define COMPILER_RT_ABI __attribute__((pcs("aapcs"))) +#else +# define ARM_EABI_FNALIAS(aeabi_name, name) +# define COMPILER_RT_ABI +#endif + +#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) +/* + * Kernel and boot environment can't use normal headers, + * so use the equivalent system headers. + */ +# include +# include +# include +#else +/* Include the standard compiler builtin headers we use functionality from. */ +# include +# include +# include +# include +#endif + +/* Include the commonly used internal type definitions. */ +#include "int_types.h" + +/* Include internal utility function declarations. */ +#include "int_util.h" + +COMPILER_RT_ABI si_int __paritysi2(si_int a); +COMPILER_RT_ABI si_int __paritydi2(di_int a); + +COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b); +COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b); +COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d); + +COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem); +COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem); +#ifdef CRT_HAS_128BIT +COMPILER_RT_ABI si_int __clzti2(ti_int a); +COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); +#endif + +#endif /* INT_LIB_H */ diff --git a/sdk/compiler-rt/int_types.h b/sdk/compiler-rt/int_types.h new file mode 100644 index 0000000000..5107f71550 --- /dev/null +++ b/sdk/compiler-rt/int_types.h @@ -0,0 +1,143 @@ +/* ===-- int_lib.h - configuration header for compiler-rt -----------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file is not part of the interface of this library. + * + * This file defines various standard types, most importantly a number of unions + * used to access parts of larger types. + * + * ===----------------------------------------------------------------------=== + */ + +#ifndef INT_TYPES_H +#define INT_TYPES_H + +#include "int_endianness.h" + +typedef int si_int; +typedef unsigned su_int; + +typedef long long di_int; +typedef unsigned long long du_int; + +typedef union +{ + di_int all; + struct + { +#if _YUGA_LITTLE_ENDIAN + su_int low; + si_int high; +#else + si_int high; + su_int low; +#endif /* _YUGA_LITTLE_ENDIAN */ + }s; +} dwords; + +typedef union +{ + du_int all; + struct + { +#if _YUGA_LITTLE_ENDIAN + su_int low; + su_int high; +#else + su_int high; + su_int low; +#endif /* _YUGA_LITTLE_ENDIAN */ + }s; +} udwords; + +#if __LP64__ +#define CRT_HAS_128BIT +#endif + +#ifdef CRT_HAS_128BIT +typedef int ti_int __attribute__ ((mode (TI))); +typedef unsigned tu_int __attribute__ ((mode (TI))); + +typedef union +{ + ti_int all; + struct + { +#if _YUGA_LITTLE_ENDIAN + du_int low; + di_int high; +#else + di_int high; + du_int low; +#endif /* _YUGA_LITTLE_ENDIAN */ + }s; +} twords; + +typedef union +{ + tu_int all; + struct + { +#if _YUGA_LITTLE_ENDIAN + du_int low; + du_int high; +#else + du_int high; + du_int low; +#endif /* _YUGA_LITTLE_ENDIAN */ + }s; +} utwords; + +static inline ti_int make_ti(di_int h, di_int l) { + twords r; + r.s.high = h; + r.s.low = l; + return r.all; +} + +static inline tu_int make_tu(du_int h, du_int l) { + utwords r; + r.s.high = h; + r.s.low = l; + return r.all; +} + +#endif /* CRT_HAS_128BIT */ + +typedef union +{ + su_int u; + float f; +} float_bits; + +typedef union +{ + udwords u; + double f; +} double_bits; + +typedef struct +{ +#if _YUGA_LITTLE_ENDIAN + udwords low; + udwords high; +#else + udwords high; + udwords low; +#endif /* _YUGA_LITTLE_ENDIAN */ +} uqwords; + +typedef union +{ + uqwords u; + long double f; +} long_double_bits; + +#endif /* INT_TYPES_H */ + diff --git a/sdk/compiler-rt/int_util.h b/sdk/compiler-rt/int_util.h new file mode 100644 index 0000000000..a9b595db8d --- /dev/null +++ b/sdk/compiler-rt/int_util.h @@ -0,0 +1,29 @@ +/* ===-- int_util.h - internal utility functions ----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===-----------------------------------------------------------------------=== + * + * This file is not part of the interface of this library. + * + * This file defines non-inline utilities which are available for use in the + * library. The function definitions themselves are all contained in int_util.c + * which will always be compiled into any compiler-rt library. + * + * ===-----------------------------------------------------------------------=== + */ + +#ifndef INT_UTIL_H +#define INT_UTIL_H + +/** \brief Trigger a program abort (or panic for kernel code). */ +#define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \ + __func__) + +void compilerrt_abort_impl(const char *file, int line, + const char *function) __attribute__((noreturn)); + +#endif /* INT_UTIL_H */ diff --git a/sdk/compiler-rt/lshrdi3.c b/sdk/compiler-rt/lshrdi3.c new file mode 100644 index 0000000000..6b1ea923b7 --- /dev/null +++ b/sdk/compiler-rt/lshrdi3.c @@ -0,0 +1,43 @@ +/* ===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __lshrdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: logical a >> b */ + +/* Precondition: 0 <= b < bits_in_dword */ + +ARM_EABI_FNALIAS(llsr, lshrdi3) + +COMPILER_RT_ABI di_int +__lshrdi3(di_int a, si_int b) +{ + const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); + udwords input; + udwords result; + input.all = a; + if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ + { + result.s.high = 0; + result.s.low = input.s.high >> (b - bits_in_word); + } + else /* 0 <= b < bits_in_word */ + { + if (b == 0) + return a; + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b); + } + return result.all; +} diff --git a/sdk/compiler-rt/lshrti3.c b/sdk/compiler-rt/lshrti3.c new file mode 100644 index 0000000000..e4170ff84a --- /dev/null +++ b/sdk/compiler-rt/lshrti3.c @@ -0,0 +1,45 @@ +/* ===-- lshrti3.c - Implement __lshrti3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __lshrti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: logical a >> b */ + +/* Precondition: 0 <= b < bits_in_tword */ + +COMPILER_RT_ABI ti_int +__lshrti3(ti_int a, si_int b) +{ + const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT); + utwords input; + utwords result; + input.all = a; + if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ + { + result.s.high = 0; + result.s.low = input.s.high >> (b - bits_in_dword); + } + else /* 0 <= b < bits_in_dword */ + { + if (b == 0) + return a; + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_dword - b)) | (input.s.low >> b); + } + return result.all; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/moddi3.c b/sdk/compiler-rt/moddi3.c new file mode 100644 index 0000000000..a04279e387 --- /dev/null +++ b/sdk/compiler-rt/moddi3.c @@ -0,0 +1,30 @@ +/*===-- moddi3.c - Implement __moddi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __moddi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a % b */ + +COMPILER_RT_ABI di_int +__moddi3(di_int a, di_int b) +{ + const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1; + di_int s = b >> bits_in_dword_m1; /* s = b < 0 ? -1 : 0 */ + b = (b ^ s) - s; /* negate if s == -1 */ + s = a >> bits_in_dword_m1; /* s = a < 0 ? -1 : 0 */ + a = (a ^ s) - s; /* negate if s == -1 */ + du_int r; + __udivmoddi4(a, b, &r); + return ((di_int)r ^ s) - s; /* negate if s == -1 */ +} diff --git a/sdk/compiler-rt/modsi3.c b/sdk/compiler-rt/modsi3.c new file mode 100644 index 0000000000..86c73ce137 --- /dev/null +++ b/sdk/compiler-rt/modsi3.c @@ -0,0 +1,23 @@ +/* ===-- modsi3.c - Implement __modsi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __modsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a % b */ + +COMPILER_RT_ABI si_int +__modsi3(si_int a, si_int b) +{ + return a - __divsi3(a, b) * b; +} diff --git a/sdk/compiler-rt/modti3.c b/sdk/compiler-rt/modti3.c new file mode 100644 index 0000000000..d505c07ac1 --- /dev/null +++ b/sdk/compiler-rt/modti3.c @@ -0,0 +1,34 @@ +/* ===-- modti3.c - Implement __modti3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __modti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/*Returns: a % b */ + +COMPILER_RT_ABI ti_int +__modti3(ti_int a, ti_int b) +{ + const int bits_in_tword_m1 = (int)(sizeof(ti_int) * CHAR_BIT) - 1; + ti_int s = b >> bits_in_tword_m1; /* s = b < 0 ? -1 : 0 */ + b = (b ^ s) - s; /* negate if s == -1 */ + s = a >> bits_in_tword_m1; /* s = a < 0 ? -1 : 0 */ + a = (a ^ s) - s; /* negate if s == -1 */ + tu_int r; + __udivmodti4(a, b, &r); + return ((ti_int)r ^ s) - s; /* negate if s == -1 */ +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/muldi3.c b/sdk/compiler-rt/muldi3.c new file mode 100644 index 0000000000..2dae44c11b --- /dev/null +++ b/sdk/compiler-rt/muldi3.c @@ -0,0 +1,56 @@ +/* ===-- muldi3.c - Implement __muldi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __muldi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a * b */ + +static +di_int +__muldsi3(su_int a, su_int b) +{ + dwords r; + const int bits_in_word_2 = (int)(sizeof(si_int) * CHAR_BIT) / 2; + const su_int lower_mask = (su_int)~0 >> bits_in_word_2; + r.s.low = (a & lower_mask) * (b & lower_mask); + su_int t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; + t += (a >> bits_in_word_2) * (b & lower_mask); + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high = t >> bits_in_word_2; + t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; + t += (b >> bits_in_word_2) * (a & lower_mask); + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high += t >> bits_in_word_2; + r.s.high += (a >> bits_in_word_2) * (b >> bits_in_word_2); + return r.all; +} + +/* Returns: a * b */ + +ARM_EABI_FNALIAS(lmul, muldi3) + +COMPILER_RT_ABI di_int +__muldi3(di_int a, di_int b) +{ + dwords x; + x.all = a; + dwords y; + y.all = b; + dwords r; + r.all = __muldsi3(x.s.low, y.s.low); + r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; + return r.all; +} diff --git a/sdk/compiler-rt/multf3.c b/sdk/compiler-rt/multf3.c new file mode 100644 index 0000000000..0b915923ea --- /dev/null +++ b/sdk/compiler-rt/multf3.c @@ -0,0 +1,25 @@ +//===-- lib/multf3.c - Quad-precision multiplication --------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements quad-precision soft-float multiplication +// with the IEEE-754 default rounding (to nearest, ties to even). +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#include "fp_mul_impl.inc" + +COMPILER_RT_ABI fp_t __multf3(fp_t a, fp_t b) { + return __mulXf3__(a, b); +} + +#endif diff --git a/sdk/compiler-rt/multi3.c b/sdk/compiler-rt/multi3.c new file mode 100644 index 0000000000..e0d52d430b --- /dev/null +++ b/sdk/compiler-rt/multi3.c @@ -0,0 +1,58 @@ +/* ===-- multi3.c - Implement __multi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + + * This file implements __multi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: a * b */ + +static +ti_int +__mulddi3(du_int a, du_int b) +{ + twords r; + const int bits_in_dword_2 = (int)(sizeof(di_int) * CHAR_BIT) / 2; + const du_int lower_mask = (du_int)~0 >> bits_in_dword_2; + r.s.low = (a & lower_mask) * (b & lower_mask); + du_int t = r.s.low >> bits_in_dword_2; + r.s.low &= lower_mask; + t += (a >> bits_in_dword_2) * (b & lower_mask); + r.s.low += (t & lower_mask) << bits_in_dword_2; + r.s.high = t >> bits_in_dword_2; + t = r.s.low >> bits_in_dword_2; + r.s.low &= lower_mask; + t += (b >> bits_in_dword_2) * (a & lower_mask); + r.s.low += (t & lower_mask) << bits_in_dword_2; + r.s.high += t >> bits_in_dword_2; + r.s.high += (a >> bits_in_dword_2) * (b >> bits_in_dword_2); + return r.all; +} + +/* Returns: a * b */ + +COMPILER_RT_ABI ti_int +__multi3(ti_int a, ti_int b) +{ + twords x; + x.all = a; + twords y; + y.all = b; + twords r; + r.all = __mulddi3(x.s.low, y.s.low); + r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; + return r.all; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/negdi2.c b/sdk/compiler-rt/negdi2.c new file mode 100644 index 0000000000..3d49ba2899 --- /dev/null +++ b/sdk/compiler-rt/negdi2.c @@ -0,0 +1,26 @@ +/* ===-- negdi2.c - Implement __negdi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __negdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: -a */ + +COMPILER_RT_ABI di_int +__negdi2(di_int a) +{ + /* Note: this routine is here for API compatibility; any sane compiler + * should expand it inline. + */ + return -a; +} diff --git a/sdk/compiler-rt/negti2.c b/sdk/compiler-rt/negti2.c new file mode 100644 index 0000000000..9b00b303f8 --- /dev/null +++ b/sdk/compiler-rt/negti2.c @@ -0,0 +1,30 @@ +/* ===-- negti2.c - Implement __negti2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __negti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: -a */ + +COMPILER_RT_ABI ti_int +__negti2(ti_int a) +{ + /* Note: this routine is here for API compatibility; any sane compiler + * should expand it inline. + */ + return -a; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/paritydi2.c b/sdk/compiler-rt/paritydi2.c new file mode 100644 index 0000000000..8ea5ab4214 --- /dev/null +++ b/sdk/compiler-rt/paritydi2.c @@ -0,0 +1,25 @@ +/* ===-- paritydi2.c - Implement __paritydi2 -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __paritydi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: 1 if number of bits is odd else returns 0 */ + +COMPILER_RT_ABI si_int +__paritydi2(di_int a) +{ + dwords x; + x.all = a; + return __paritysi2(x.s.high ^ x.s.low); +} diff --git a/sdk/compiler-rt/paritysi2.c b/sdk/compiler-rt/paritysi2.c new file mode 100644 index 0000000000..5999846638 --- /dev/null +++ b/sdk/compiler-rt/paritysi2.c @@ -0,0 +1,27 @@ +/* ===-- paritysi2.c - Implement __paritysi2 -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __paritysi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: 1 if number of bits is odd else returns 0 */ + +COMPILER_RT_ABI si_int +__paritysi2(si_int a) +{ + su_int x = (su_int)a; + x ^= x >> 16; + x ^= x >> 8; + x ^= x >> 4; + return (0x6996 >> (x & 0xF)) & 1; +} diff --git a/sdk/compiler-rt/parityti2.c b/sdk/compiler-rt/parityti2.c new file mode 100644 index 0000000000..5a4fe49248 --- /dev/null +++ b/sdk/compiler-rt/parityti2.c @@ -0,0 +1,29 @@ +/* ===-- parityti2.c - Implement __parityti2 -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __parityti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: 1 if number of bits is odd else returns 0 */ + +COMPILER_RT_ABI si_int +__parityti2(ti_int a) +{ + twords x; + x.all = a; + return __paritydi2(x.s.high ^ x.s.low); +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/popcountdi2.c b/sdk/compiler-rt/popcountdi2.c new file mode 100644 index 0000000000..5e8a62f075 --- /dev/null +++ b/sdk/compiler-rt/popcountdi2.c @@ -0,0 +1,36 @@ +/* ===-- popcountdi2.c - Implement __popcountdi2 ----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __popcountdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: count of 1 bits */ + +COMPILER_RT_ABI si_int +__popcountdi2(di_int a) +{ + du_int x2 = (du_int)a; + x2 = x2 - ((x2 >> 1) & 0x5555555555555555uLL); + /* Every 2 bits holds the sum of every pair of bits (32) */ + x2 = ((x2 >> 2) & 0x3333333333333333uLL) + (x2 & 0x3333333333333333uLL); + /* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (16) */ + x2 = (x2 + (x2 >> 4)) & 0x0F0F0F0F0F0F0F0FuLL; + /* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (8) */ + su_int x = (su_int)(x2 + (x2 >> 32)); + /* The lower 32 bits hold four 16 bit sums (5 significant bits). */ + /* Upper 32 bits are garbage */ + x = x + (x >> 16); + /* The lower 16 bits hold two 32 bit sums (6 significant bits). */ + /* Upper 16 bits are garbage */ + return (x + (x >> 8)) & 0x0000007F; /* (7 significant bits) */ +} diff --git a/sdk/compiler-rt/popcountsi2.c b/sdk/compiler-rt/popcountsi2.c new file mode 100644 index 0000000000..44544ff498 --- /dev/null +++ b/sdk/compiler-rt/popcountsi2.c @@ -0,0 +1,33 @@ +/* ===-- popcountsi2.c - Implement __popcountsi2 ---------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __popcountsi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: count of 1 bits */ + +COMPILER_RT_ABI si_int +__popcountsi2(si_int a) +{ + su_int x = (su_int)a; + x = x - ((x >> 1) & 0x55555555); + /* Every 2 bits holds the sum of every pair of bits */ + x = ((x >> 2) & 0x33333333) + (x & 0x33333333); + /* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) */ + x = (x + (x >> 4)) & 0x0F0F0F0F; + /* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) */ + x = (x + (x >> 16)); + /* The lower 16 bits hold two 8 bit sums (5 significant bits).*/ + /* Upper 16 bits are garbage */ + return (x + (x >> 8)) & 0x0000003F; /* (6 significant bits) */ +} diff --git a/sdk/compiler-rt/popcountti2.c b/sdk/compiler-rt/popcountti2.c new file mode 100644 index 0000000000..7451bbb286 --- /dev/null +++ b/sdk/compiler-rt/popcountti2.c @@ -0,0 +1,44 @@ +/* ===-- popcountti2.c - Implement __popcountti2 ----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __popcountti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: count of 1 bits */ + +COMPILER_RT_ABI si_int +__popcountti2(ti_int a) +{ + tu_int x3 = (tu_int)a; + x3 = x3 - ((x3 >> 1) & (((tu_int)0x5555555555555555uLL << 64) | + 0x5555555555555555uLL)); + /* Every 2 bits holds the sum of every pair of bits (64) */ + x3 = ((x3 >> 2) & (((tu_int)0x3333333333333333uLL << 64) | 0x3333333333333333uLL)) + + (x3 & (((tu_int)0x3333333333333333uLL << 64) | 0x3333333333333333uLL)); + /* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (32) */ + x3 = (x3 + (x3 >> 4)) + & (((tu_int)0x0F0F0F0F0F0F0F0FuLL << 64) | 0x0F0F0F0F0F0F0F0FuLL); + /* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (16) */ + du_int x2 = (du_int)(x3 + (x3 >> 64)); + /* Every 8 bits holds the sum of every 8-set of bits (5 significant bits) (8) */ + su_int x = (su_int)(x2 + (x2 >> 32)); + /* Every 8 bits holds the sum of every 8-set of bits (6 significant bits) (4) */ + x = x + (x >> 16); + /* Every 8 bits holds the sum of every 8-set of bits (7 significant bits) (2) */ + /* Upper 16 bits are garbage */ + return (x + (x >> 8)) & 0xFF; /* (8 significant bits) */ +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/stack_chk.c b/sdk/compiler-rt/stack_chk.c new file mode 100644 index 0000000000..27478edb38 --- /dev/null +++ b/sdk/compiler-rt/stack_chk.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "stdlib.h" + +void +__attribute__((noreturn)) +__stack_chk_fail(void) +{ + abort(); +} + +void +__attribute__((noreturn)) +__attribute__((visibility ("hidden"))) +__stack_chk_fail_local (void) +{ + __stack_chk_fail (); +} + +extern void * __intel_security_cookie; + +#ifdef __x86_64__ +void __intel_security_check_cookie(void * cookie) +#else +void __attribute__ ((regparm(1))) __intel_security_check_cookie(void * cookie) +#endif /* __x86_64__ */ +{ + if (cookie == __intel_security_cookie) + return; + abort(); +} + diff --git a/sdk/compiler-rt/subtf3.c b/sdk/compiler-rt/subtf3.c new file mode 100644 index 0000000000..609b816f41 --- /dev/null +++ b/sdk/compiler-rt/subtf3.c @@ -0,0 +1,27 @@ +//===-- lib/subtf3.c - Quad-precision subtraction -----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements quad-precision soft-float subtraction with the +// IEEE-754 default rounding (to nearest, ties to even). +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +COMPILER_RT_ABI fp_t __addtf3(fp_t a, fp_t b); + +// Subtraction; flip the sign bit of b and add. +COMPILER_RT_ABI fp_t +__subtf3(fp_t a, fp_t b) { + return __addtf3(a, fromRep(toRep(b) ^ signBit)); +} + +#endif diff --git a/sdk/compiler-rt/trunctfdf2.c b/sdk/compiler-rt/trunctfdf2.c new file mode 100644 index 0000000000..741a71b33c --- /dev/null +++ b/sdk/compiler-rt/trunctfdf2.c @@ -0,0 +1,22 @@ +//===-- lib/truncdfsf2.c - quad -> double conversion --------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#define SRC_QUAD +#define DST_DOUBLE +#include "fp_trunc_impl.inc" + +COMPILER_RT_ABI double __trunctfdf2(long double a) { + return __truncXfYf2__(a); +} + +#endif diff --git a/sdk/compiler-rt/trunctfsf2.c b/sdk/compiler-rt/trunctfsf2.c new file mode 100644 index 0000000000..de96c1decf --- /dev/null +++ b/sdk/compiler-rt/trunctfsf2.c @@ -0,0 +1,22 @@ +//===-- lib/trunctfsf2.c - quad -> single conversion --------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#define SRC_QUAD +#define DST_SINGLE +#include "fp_trunc_impl.inc" + +COMPILER_RT_ABI float __trunctfsf2(long double a) { + return __truncXfYf2__(a); +} + +#endif diff --git a/sdk/compiler-rt/ucmpdi2.c b/sdk/compiler-rt/ucmpdi2.c new file mode 100644 index 0000000000..40af23613b --- /dev/null +++ b/sdk/compiler-rt/ucmpdi2.c @@ -0,0 +1,51 @@ +/* ===-- ucmpdi2.c - Implement __ucmpdi2 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ucmpdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: if (a < b) returns 0 + * if (a == b) returns 1 + * if (a > b) returns 2 + */ + +COMPILER_RT_ABI si_int +__ucmpdi2(du_int a, du_int b) +{ + udwords x; + x.all = a; + udwords y; + y.all = b; + if (x.s.high < y.s.high) + return 0; + if (x.s.high > y.s.high) + return 2; + if (x.s.low < y.s.low) + return 0; + if (x.s.low > y.s.low) + return 2; + return 1; +} + +#ifdef __ARM_EABI__ +/* Returns: if (a < b) returns -1 +* if (a == b) returns 0 +* if (a > b) returns 1 +*/ +COMPILER_RT_ABI si_int +__aeabi_ulcmp(di_int a, di_int b) +{ + return __ucmpdi2(a, b) - 1; +} +#endif + diff --git a/sdk/compiler-rt/ucmpti2.c b/sdk/compiler-rt/ucmpti2.c new file mode 100644 index 0000000000..bda8083bb2 --- /dev/null +++ b/sdk/compiler-rt/ucmpti2.c @@ -0,0 +1,42 @@ +/* ===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ucmpti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: if (a < b) returns 0 + * if (a == b) returns 1 + * if (a > b) returns 2 + */ + +COMPILER_RT_ABI si_int +__ucmpti2(tu_int a, tu_int b) +{ + utwords x; + x.all = a; + utwords y; + y.all = b; + if (x.s.high < y.s.high) + return 0; + if (x.s.high > y.s.high) + return 2; + if (x.s.low < y.s.low) + return 0; + if (x.s.low > y.s.low) + return 2; + return 1; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/udivdi3.c b/sdk/compiler-rt/udivdi3.c new file mode 100644 index 0000000000..dc68e154b1 --- /dev/null +++ b/sdk/compiler-rt/udivdi3.c @@ -0,0 +1,23 @@ +/* ===-- udivdi3.c - Implement __udivdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a / b */ + +COMPILER_RT_ABI du_int +__udivdi3(du_int a, du_int b) +{ + return __udivmoddi4(a, b, 0); +} diff --git a/sdk/compiler-rt/udivmoddi4.c b/sdk/compiler-rt/udivmoddi4.c new file mode 100644 index 0000000000..0c8b4ff464 --- /dev/null +++ b/sdk/compiler-rt/udivmoddi4.c @@ -0,0 +1,231 @@ +/* ===-- udivmoddi4.c - Implement __udivmoddi4 -----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivmoddi4 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Effects: if rem != 0, *rem = a % b + * Returns: a / b + */ + +/* Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide */ + +COMPILER_RT_ABI du_int +__udivmoddi4(du_int a, du_int b, du_int* rem) +{ + const unsigned n_uword_bits = sizeof(su_int) * CHAR_BIT; + const unsigned n_udword_bits = sizeof(du_int) * CHAR_BIT; + udwords n; + n.all = a; + udwords d; + d.all = b; + udwords q; + udwords r; + unsigned sr; + /* special cases, X is unknown, K != 0 */ + if (n.s.high == 0) + { + if (d.s.high == 0) + { + /* 0 X + * --- + * 0 X + */ + if (rem) + *rem = n.s.low % d.s.low; + return n.s.low / d.s.low; + } + /* 0 X + * --- + * K X + */ + if (rem) + *rem = n.s.low; + return 0; + } + /* n.s.high != 0 */ + if (d.s.low == 0) + { + if (d.s.high == 0) + { + /* K X + * --- + * 0 0 + */ + if (rem) + *rem = n.s.high % d.s.low; + return n.s.high / d.s.low; + } + /* d.s.high != 0 */ + if (n.s.low == 0) + { + /* K 0 + * --- + * K 0 + */ + if (rem) + { + r.s.high = n.s.high % d.s.high; + r.s.low = 0; + *rem = r.all; + } + return n.s.high / d.s.high; + } + /* K K + * --- + * K 0 + */ + if ((d.s.high & (d.s.high - 1)) == 0) /* if d is a power of 2 */ + { + if (rem) + { + r.s.low = n.s.low; + r.s.high = n.s.high & (d.s.high - 1); + *rem = r.all; + } + return n.s.high >> __builtin_ctz(d.s.high); + } + /* K K + * --- + * K 0 + */ + sr = __builtin_clz(d.s.high) - __builtin_clz(n.s.high); + /* 0 <= sr <= n_uword_bits - 2 or sr large */ + if (sr > n_uword_bits - 2) + { + if (rem) + *rem = n.all; + return 0; + } + ++sr; + /* 1 <= sr <= n_uword_bits - 1 */ + /* q.all = n.all << (n_udword_bits - sr); */ + q.s.low = 0; + q.s.high = n.s.low << (n_uword_bits - sr); + /* r.all = n.all >> sr; */ + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); + } + else /* d.s.low != 0 */ + { + if (d.s.high == 0) + { + /* K X + * --- + * 0 K + */ + if ((d.s.low & (d.s.low - 1)) == 0) /* if d is a power of 2 */ + { + if (rem) + *rem = n.s.low & (d.s.low - 1); + if (d.s.low == 1) + return n.all; + sr = __builtin_ctz(d.s.low); + q.s.high = n.s.high >> sr; + q.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); + return q.all; + } + /* K X + * --- + * 0 K + */ + sr = 1 + n_uword_bits + __builtin_clz(d.s.low) - __builtin_clz(n.s.high); + /* 2 <= sr <= n_udword_bits - 1 + * q.all = n.all << (n_udword_bits - sr); + * r.all = n.all >> sr; + */ + if (sr == n_uword_bits) + { + q.s.low = 0; + q.s.high = n.s.low; + r.s.high = 0; + r.s.low = n.s.high; + } + else if (sr < n_uword_bits) // 2 <= sr <= n_uword_bits - 1 + { + q.s.low = 0; + q.s.high = n.s.low << (n_uword_bits - sr); + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); + } + else // n_uword_bits + 1 <= sr <= n_udword_bits - 1 + { + q.s.low = n.s.low << (n_udword_bits - sr); + q.s.high = (n.s.high << (n_udword_bits - sr)) | + (n.s.low >> (sr - n_uword_bits)); + r.s.high = 0; + r.s.low = n.s.high >> (sr - n_uword_bits); + } + } + else + { + /* K X + * --- + * K K + */ + sr = __builtin_clz(d.s.high) - __builtin_clz(n.s.high); + /* 0 <= sr <= n_uword_bits - 1 or sr large */ + if (sr > n_uword_bits - 1) + { + if (rem) + *rem = n.all; + return 0; + } + ++sr; + /* 1 <= sr <= n_uword_bits */ + /* q.all = n.all << (n_udword_bits - sr); */ + q.s.low = 0; + if (sr == n_uword_bits) + { + q.s.high = n.s.low; + r.s.high = 0; + r.s.low = n.s.high; + } + else + { + q.s.high = n.s.low << (n_uword_bits - sr); + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); + } + } + } + /* Not a special case + * q and r are initialized with: + * q.all = n.all << (n_udword_bits - sr); + * r.all = n.all >> sr; + * 1 <= sr <= n_udword_bits - 1 + */ + su_int carry = 0; + for (; sr > 0; --sr) + { + /* r:q = ((r:q) << 1) | carry */ + r.s.high = (r.s.high << 1) | (r.s.low >> (n_uword_bits - 1)); + r.s.low = (r.s.low << 1) | (q.s.high >> (n_uword_bits - 1)); + q.s.high = (q.s.high << 1) | (q.s.low >> (n_uword_bits - 1)); + q.s.low = (q.s.low << 1) | carry; + /* carry = 0; + * if (r.all >= d.all) + * { + * r.all -= d.all; + * carry = 1; + * } + */ + const di_int s = (di_int)(d.all - r.all - 1) >> (n_udword_bits - 1); + carry = s & 1; + r.all -= d.all & s; + } + q.all = (q.all << 1) | carry; + if (rem) + *rem = r.all; + return q.all; +} diff --git a/sdk/compiler-rt/udivmodti4.c b/sdk/compiler-rt/udivmodti4.c new file mode 100644 index 0000000000..803168849c --- /dev/null +++ b/sdk/compiler-rt/udivmodti4.c @@ -0,0 +1,238 @@ +/* ===-- udivmodti4.c - Implement __udivmodti4 -----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivmodti4 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Effects: if rem != 0, *rem = a % b + * Returns: a / b + */ + +/* Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide */ + +COMPILER_RT_ABI tu_int +__udivmodti4(tu_int a, tu_int b, tu_int* rem) +{ + const unsigned n_udword_bits = sizeof(du_int) * CHAR_BIT; + const unsigned n_utword_bits = sizeof(tu_int) * CHAR_BIT; + utwords n; + n.all = a; + utwords d; + d.all = b; + utwords q; + utwords r; + unsigned sr; + /* special cases, X is unknown, K != 0 */ + if (n.s.high == 0) + { + if (d.s.high == 0) + { + /* 0 X + * --- + * 0 X + */ + if (rem) + *rem = n.s.low % d.s.low; + return n.s.low / d.s.low; + } + /* 0 X + * --- + * K X + */ + if (rem) + *rem = n.s.low; + return 0; + } + /* n.s.high != 0 */ + if (d.s.low == 0) + { + if (d.s.high == 0) + { + /* K X + * --- + * 0 0 + */ + if (rem) + *rem = n.s.high % d.s.low; + return n.s.high / d.s.low; + } + /* d.s.high != 0 */ + if (n.s.low == 0) + { + /* K 0 + * --- + * K 0 + */ + if (rem) + { + r.s.high = n.s.high % d.s.high; + r.s.low = 0; + *rem = r.all; + } + return n.s.high / d.s.high; + } + /* K K + * --- + * K 0 + */ + if ((d.s.high & (d.s.high - 1)) == 0) /* if d is a power of 2 */ + { + if (rem) + { + r.s.low = n.s.low; + r.s.high = n.s.high & (d.s.high - 1); + *rem = r.all; + } + return n.s.high >> __builtin_ctzll(d.s.high); + } + /* K K + * --- + * K 0 + */ + sr = __builtin_clzll(d.s.high) - __builtin_clzll(n.s.high); + /* 0 <= sr <= n_udword_bits - 2 or sr large */ + if (sr > n_udword_bits - 2) + { + if (rem) + *rem = n.all; + return 0; + } + ++sr; + /* 1 <= sr <= n_udword_bits - 1 */ + /* q.all = n.all << (n_utword_bits - sr); */ + q.s.low = 0; + q.s.high = n.s.low << (n_udword_bits - sr); + /* r.all = n.all >> sr; */ + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); + } + else /* d.s.low != 0 */ + { + if (d.s.high == 0) + { + /* K X + * --- + * 0 K + */ + if ((d.s.low & (d.s.low - 1)) == 0) /* if d is a power of 2 */ + { + if (rem) + *rem = n.s.low & (d.s.low - 1); + if (d.s.low == 1) + return n.all; + sr = __builtin_ctzll(d.s.low); + q.s.high = n.s.high >> sr; + q.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); + return q.all; + } + /* K X + * --- + * 0 K + */ + sr = 1 + n_udword_bits + __builtin_clzll(d.s.low) + - __builtin_clzll(n.s.high); + /* 2 <= sr <= n_utword_bits - 1 + * q.all = n.all << (n_utword_bits - sr); + * r.all = n.all >> sr; + */ + if (sr == n_udword_bits) + { + q.s.low = 0; + q.s.high = n.s.low; + r.s.high = 0; + r.s.low = n.s.high; + } + else if (sr < n_udword_bits) // 2 <= sr <= n_udword_bits - 1 + { + q.s.low = 0; + q.s.high = n.s.low << (n_udword_bits - sr); + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); + } + else // n_udword_bits + 1 <= sr <= n_utword_bits - 1 + { + q.s.low = n.s.low << (n_utword_bits - sr); + q.s.high = (n.s.high << (n_utword_bits - sr)) | + (n.s.low >> (sr - n_udword_bits)); + r.s.high = 0; + r.s.low = n.s.high >> (sr - n_udword_bits); + } + } + else + { + /* K X + * --- + * K K + */ + sr = __builtin_clzll(d.s.high) - __builtin_clzll(n.s.high); + /*0 <= sr <= n_udword_bits - 1 or sr large */ + if (sr > n_udword_bits - 1) + { + if (rem) + *rem = n.all; + return 0; + } + ++sr; + /* 1 <= sr <= n_udword_bits + * q.all = n.all << (n_utword_bits - sr); + * r.all = n.all >> sr; + */ + q.s.low = 0; + if (sr == n_udword_bits) + { + q.s.high = n.s.low; + r.s.high = 0; + r.s.low = n.s.high; + } + else + { + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); + q.s.high = n.s.low << (n_udword_bits - sr); + } + } + } + /* Not a special case + * q and r are initialized with: + * q.all = n.all << (n_utword_bits - sr); + * r.all = n.all >> sr; + * 1 <= sr <= n_utword_bits - 1 + */ + su_int carry = 0; + for (; sr > 0; --sr) + { + /* r:q = ((r:q) << 1) | carry */ + r.s.high = (r.s.high << 1) | (r.s.low >> (n_udword_bits - 1)); + r.s.low = (r.s.low << 1) | (q.s.high >> (n_udword_bits - 1)); + q.s.high = (q.s.high << 1) | (q.s.low >> (n_udword_bits - 1)); + q.s.low = (q.s.low << 1) | carry; + /* carry = 0; + * if (r.all >= d.all) + * { + * r.all -= d.all; + * carry = 1; + * } + */ + const ti_int s = (ti_int)(d.all - r.all - 1) >> (n_utword_bits - 1); + carry = s & 1; + r.all -= d.all & s; + } + q.all = (q.all << 1) | carry; + if (rem) + *rem = r.all; + return q.all; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/udivsi3.c b/sdk/compiler-rt/udivsi3.c new file mode 100644 index 0000000000..5d0140cc3e --- /dev/null +++ b/sdk/compiler-rt/udivsi3.c @@ -0,0 +1,66 @@ +/* ===-- udivsi3.c - Implement __udivsi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a / b */ + +/* Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide */ + +ARM_EABI_FNALIAS(uidiv, udivsi3) + +/* This function should not call __divsi3! */ +COMPILER_RT_ABI su_int +__udivsi3(su_int n, su_int d) +{ + const unsigned n_uword_bits = sizeof(su_int) * CHAR_BIT; + su_int q; + su_int r; + unsigned sr; + /* special cases */ + if (d == 0) + return 0; /* ?! */ + if (n == 0) + return 0; + sr = __builtin_clz(d) - __builtin_clz(n); + /* 0 <= sr <= n_uword_bits - 1 or sr large */ + if (sr > n_uword_bits - 1) /* d > r */ + return 0; + if (sr == n_uword_bits - 1) /* d == 1 */ + return n; + ++sr; + /* 1 <= sr <= n_uword_bits - 1 */ + /* Not a special case */ + q = n << (n_uword_bits - sr); + r = n >> sr; + su_int carry = 0; + for (; sr > 0; --sr) + { + /* r:q = ((r:q) << 1) | carry */ + r = (r << 1) | (q >> (n_uword_bits - 1)); + q = (q << 1) | carry; + /* carry = 0; + * if (r.all >= d.all) + * { + * r.all -= d.all; + * carry = 1; + * } + */ + const si_int s = (si_int)(d - r - 1) >> (n_uword_bits - 1); + carry = s & 1; + r -= d & s; + } + q = (q << 1) | carry; + return q; +} diff --git a/sdk/compiler-rt/udivti3.c b/sdk/compiler-rt/udivti3.c new file mode 100644 index 0000000000..ec94673e25 --- /dev/null +++ b/sdk/compiler-rt/udivti3.c @@ -0,0 +1,27 @@ +/* ===-- udivti3.c - Implement __udivti3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: a / b */ + +COMPILER_RT_ABI tu_int +__udivti3(tu_int a, tu_int b) +{ + return __udivmodti4(a, b, 0); +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/compiler-rt/umoddi3.c b/sdk/compiler-rt/umoddi3.c new file mode 100644 index 0000000000..d513f080a1 --- /dev/null +++ b/sdk/compiler-rt/umoddi3.c @@ -0,0 +1,25 @@ +/* ===-- umoddi3.c - Implement __umoddi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __umoddi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a % b */ + +COMPILER_RT_ABI du_int +__umoddi3(du_int a, du_int b) +{ + du_int r; + __udivmoddi4(a, b, &r); + return r; +} diff --git a/sdk/compiler-rt/umodsi3.c b/sdk/compiler-rt/umodsi3.c new file mode 100644 index 0000000000..d5fda4a6af --- /dev/null +++ b/sdk/compiler-rt/umodsi3.c @@ -0,0 +1,23 @@ +/* ===-- umodsi3.c - Implement __umodsi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __umodsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: a % b */ + +COMPILER_RT_ABI su_int +__umodsi3(su_int a, su_int b) +{ + return a - __udivsi3(a, b) * b; +} diff --git a/sdk/compiler-rt/umodti3.c b/sdk/compiler-rt/umodti3.c new file mode 100644 index 0000000000..6d1ca7a8cf --- /dev/null +++ b/sdk/compiler-rt/umodti3.c @@ -0,0 +1,29 @@ +/* ===-- umodti3.c - Implement __umodti3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __umodti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +#ifdef CRT_HAS_128BIT + +/* Returns: a % b */ + +COMPILER_RT_ABI tu_int +__umodti3(tu_int a, tu_int b) +{ + tu_int r; + __udivmodti4(a, b, &r); + return r; +} + +#endif /* CRT_HAS_128BIT */ diff --git a/sdk/cpprt/Makefile b/sdk/cpprt/Makefile new file mode 100644 index 0000000000..dbfafaeb72 --- /dev/null +++ b/sdk/cpprt/Makefile @@ -0,0 +1,104 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +LINUXDIR := linux +CPPRT := libcpprt.a + +CFLAGS += $(ENCLAVE_CFLAGS) +CXXFLAGS += $(ENCLAVE_CXXFLAGS) + +CPPFLAGS += -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/inc/stdc++ \ + -I$(COMMON_DIR)/inc/internal \ + +CPPFLAGS += -I$(LINUX_SDK_DIR)/trts \ + -I$(LINUX_SDK_DIR)/trts/linux \ + +CPP_SRCS := $(wildcard memory_manage/new*.cpp) \ + $(wildcard memory_manage/delete*.cpp) +CPP_SRCS += tstdcxx_version.cpp + +CC_SRCS := $(wildcard $(LINUXDIR)/*.cc) +C_SRCS := $(filter-out $(LINUXDIR)/libelftc_dem_gnu3.c, $(wildcard $(LINUXDIR)/*.c)) + +CPP_OBJS := $(CPP_SRCS:.cpp=.o) +CC_OBJS := $(CC_SRCS:.cc=.o) +C_OBJS := $(C_SRCS:.c=.o) + +OBJS := $(CPP_OBJS) $(C_OBJS) $(CC_OBJS) + +$(C_OBJS): %.o: %.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +$(CC_OBJS): %.o: %.cc + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + +$(CPP_OBJS): %.o: %.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + + +.PHONY: all +all: $(CPPRT) + +.PHONY: prepare-libunwind +prepare-libunwind: + $(CP) linux/pthread_compat.h linux/libunwind/include + +$(CPPRT): $(OBJS) prepare-libunwind libunwind + $(CP) linux/libunwind/src/.libs/libunwind.a $(CPPRT) + $(AR) rs $@ $(OBJS) + +$(CPPRT): CC = gcc +$(CPPRT): CXX = g++ + +.PHONY: libunwind +libunwind: + cd linux/libunwind/ && ( test -f Makefile || ./autogen-linux.sh ) && $(MAKE) -j5 + + +.PHONY: clean +clean: + @-$(MAKE) -C linux/libunwind distclean + @$(RM) $(OBJS) $(CPPRT) + @$(RM) -r linux/libunwind/INSTALL \ + linux/libunwind/Makefile.in \ + linux/libunwind/aclocal.m4 \ + linux/libunwind/autom4te.cache/ \ + linux/libunwind/config/ \ + linux/libunwind/configure \ + linux/libunwind/doc/Makefile.in \ + linux/libunwind/include/pthread_compat.h \ + linux/libunwind/include/config.h.in \ + linux/libunwind/src/Makefile.in + diff --git a/sdk/cpprt/linux/abi_namespace.h b/sdk/cpprt/linux/abi_namespace.h new file mode 100644 index 0000000000..dda788da19 --- /dev/null +++ b/sdk/cpprt/linux/abi_namespace.h @@ -0,0 +1,5 @@ +/** + * The namespace used for the ABI declarations. This is currently defined to + * be the same as GNU libsupc++, however this may change in the future. + */ +#define ABI_NAMESPACE __cxxabiv1 diff --git a/sdk/cpprt/linux/atomic.h b/sdk/cpprt/linux/atomic.h new file mode 100644 index 0000000000..8086e66889 --- /dev/null +++ b/sdk/cpprt/linux/atomic.h @@ -0,0 +1,28 @@ +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +/** + * Swap macro that enforces a happens-before relationship with a corresponding + * ATOMIC_LOAD. + */ +#if __has_feature(cxx_atomic) +#define ATOMIC_SWAP(addr, val)\ + __atomic_exchange(addr, val, __ATOMIC_ACQ_REL) +#elif __has_builtin(__sync_swap) +#define ATOMIC_SWAP(addr, val)\ + __sync_swap(addr, val) +#else +#define ATOMIC_SWAP(addr, val)\ + __sync_lock_test_and_set(addr, val) +#endif + +#if __has_feature(cxx_atomic) +#define ATOMIC_LOAD(addr)\ + __atomic_load(addr, __ATOMIC_ACQUIRE) +#else +#define ATOMIC_LOAD(addr)\ + (__sync_synchronize(), *addr) +#endif diff --git a/sdk/cpprt/linux/auxhelper.cc b/sdk/cpprt/linux/auxhelper.cc new file mode 100644 index 0000000000..d7ecfafcd8 --- /dev/null +++ b/sdk/cpprt/linux/auxhelper.cc @@ -0,0 +1,67 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * aux.cc - Compiler helper functions. + * + * The functions declared in this file are intended to be called only by code + * that is automatically generated by C++ compilers for some common cases. + */ + +#include +#include + +/** + * Called to generate a bad cast exception. This function is intended to allow + * compilers to insert code generating this exception without needing to + * duplicate the code for throwing the exception in every call site. + */ +extern "C" void __cxa_bad_cast() +{ + throw std::bad_cast(); +} + +/** + * Called to generate a bad typeid exception. This function is intended to + * allow compilers to insert code generating this exception without needing to + * duplicate the code for throwing the exception in every call site. + */ +extern "C" void __cxa_bad_typeid() +{ + throw std::bad_typeid(); +} + +/** + * Compilers may (but are not required to) set any pure-virtual function's + * vtable entry to this function. This makes debugging slightly easier, as + * users can add a breakpoint on this function to tell if they've accidentally + * called a pure-virtual function. + */ +extern "C" void __cxa_pure_virtual() +{ + abort(); +} + diff --git a/sdk/cpprt/linux/cxa_finalize.c b/sdk/cpprt/linux/cxa_finalize.c new file mode 100644 index 0000000000..d6681c3763 --- /dev/null +++ b/sdk/cpprt/linux/cxa_finalize.c @@ -0,0 +1,8 @@ +void __cxa_finalize(void *d ) { (void)d; }; + +extern void* __dso_handle; + +__attribute((destructor)) +static void cleanup(void) { + __cxa_finalize(&__dso_handle); +} diff --git a/sdk/cpprt/linux/cxxabi.h b/sdk/cpprt/linux/cxxabi.h new file mode 100644 index 0000000000..e1f5054b90 --- /dev/null +++ b/sdk/cpprt/linux/cxxabi.h @@ -0,0 +1,241 @@ +/* + * Copyright 2012 David Chisnall. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * 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 __CXXABI_H_ +#define __CXXABI_H_ +#include +#include "unwind.h" +namespace std +{ + class type_info; +} +/* + * The cxxabi.h header provides a set of public definitions for types and + * functions defined by the Itanium C++ ABI specification. For reference, see + * the ABI specification here: + * + * http://sourcery.mentor.com/public/cxx-abi/abi.html + * + * All deviations from this specification, unless otherwise noted, are + * accidental. + */ + +#ifdef __cplusplus +namespace __cxxabiv1 { +extern "C" { +#endif +/** + * Function type to call when an unexpected exception is encountered. + */ +typedef void (*unexpected_handler)(); +/** + * Function type to call when an unrecoverable condition is encountered. + */ +typedef void (*terminate_handler)(); + + +/** + * Structure used as a header on thrown exceptions. This is the same layout as + * defined by the Itanium ABI spec, so should be interoperable with any other + * implementation of this spec, such as GNU libsupc++. + * + * This structure is allocated when an exception is thrown. Unwinding happens + * in two phases, the first looks for a handler and the second installs the + * context. This structure stores a cache of the handler location between + * phase 1 and phase 2. Unfortunately, cleanup information is not cached, so + * must be looked up in both phases. This happens for two reasons. The first + * is that we don't know how many frames containing cleanups there will be, and + * we should avoid dynamic allocation during unwinding (the exception may be + * reporting that we've run out of memory). The second is that finding + * cleanups is much cheaper than finding handlers, because we don't have to + * look at the type table at all. + * + * Note: Several fields of this structure have not-very-informative names. + * These are taken from the ABI spec and have not been changed to make it + * easier for people referring to to the spec while reading this code. + */ +struct __cxa_exception +{ +#if __LP64__ + /** + * Reference count. Used to support the C++11 exception_ptr class. This + * is prepended to the structure in 64-bit mode and squeezed in to the + * padding left before the 64-bit aligned _Unwind_Exception at the end in + * 32-bit mode. + * + * Note that it is safe to extend this structure at the beginning, rather + * than the end, because the public API for creating it returns the address + * of the end (where the exception object can be stored). + */ + uintptr_t referenceCount; +#endif + /** Type info for the thrown object. */ + std::type_info *exceptionType; + /** Destructor for the object, if one exists. */ + void (*exceptionDestructor) (void *); + /** Handler called when an exception specification is violated. */ + unexpected_handler unexpectedHandler; + /** Hander called to terminate. */ + terminate_handler terminateHandler; + /** + * Next exception in the list. If an exception is thrown inside a catch + * block and caught in a nested catch, this points to the exception that + * will be handled after the inner catch block completes. + */ + __cxa_exception *nextException; + /** + * The number of handlers that currently have references to this + * exception. The top (non-sign) bit of this is used as a flag to indicate + * that the exception is being rethrown, so should not be deleted when its + * handler count reaches 0 (which it doesn't with the top bit set). + */ + int handlerCount; +#ifdef __arm__ + /** + * The ARM EH ABI requires the unwind library to keep track of exceptions + * during cleanups. These support nesting, so we need to keep a list of + * them. + */ + _Unwind_Exception *nextCleanup; + /** + * The number of cleanups that are currently being run on this exception. + */ + int cleanupCount; +#endif + /** + * The selector value to be returned when installing the catch handler. + * Used at the call site to determine which catch() block should execute. + * This is found in phase 1 of unwinding then installed in phase 2. + */ + int handlerSwitchValue; + /** + * The action record for the catch. This is cached during phase 1 + * unwinding. + */ + const char *actionRecord; + /** + * Pointer to the language-specific data area (LSDA) for the handler + * frame. This is unused in this implementation, but set for ABI + * compatibility in case we want to mix code in very weird ways. + */ + const char *languageSpecificData; + /** The cached landing pad for the catch handler.*/ + void *catchTemp; + /** + * The pointer that will be returned as the pointer to the object. When + * throwing a class and catching a virtual superclass (for example), we + * need to adjust the thrown pointer to make it all work correctly. + */ + void *adjustedPtr; +#if !__LP64__ + /** + * Reference count. Used to support the C++11 exception_ptr class. This + * is prepended to the structure in 64-bit mode and squeezed in to the + * padding left before the 64-bit aligned _Unwind_Exception at the end in + * 32-bit mode. + * + * Note that it is safe to extend this structure at the beginning, rather + * than the end, because the public API for creating it returns the address + * of the end (where the exception object can be stored) + */ + uintptr_t referenceCount; +#endif + /** The language-agnostic part of the exception header. */ + _Unwind_Exception unwindHeader; +}; + +/** + * ABI-specified globals structure. Returned by the __cxa_get_globals() + * function and its fast variant. This is a per-thread structure - every + * thread will have one lazily allocated. + * + * This structure is defined by the ABI, so may be used outside of this + * library. + */ +struct __cxa_eh_globals +{ + /** + * A linked list of exceptions that are currently caught. There may be + * several of these in nested catch() blocks. + */ + __cxa_exception *caughtExceptions; + /** + * The number of uncaught exceptions. + */ + unsigned int uncaughtExceptions; +}; +/** + * ABI function returning the __cxa_eh_globals structure. + */ +__cxa_eh_globals *__cxa_get_globals(void); +/** + * Version of __cxa_get_globals() assuming that __cxa_get_globals() has already + * been called at least once by this thread. + */ +__cxa_eh_globals *__cxa_get_globals_fast(void); + +/** + * Throws an exception returned by __cxa_current_primary_exception(). This + * exception may have been caught in another thread. + */ +void __cxa_rethrow_primary_exception(void* thrown_exception); +/** + * Returns the current exception in a form that can be stored in an + * exception_ptr object and then rethrown by a call to + * __cxa_rethrow_primary_exception(). + */ +void *__cxa_current_primary_exception(void); +/** + * Increments the reference count of an exception. Called when an + * exception_ptr is copied. + */ +void __cxa_increment_exception_refcount(void* thrown_exception); +/** + * Decrements the reference count of an exception. Called when an + * exception_ptr is deleted. + */ +void __cxa_decrement_exception_refcount(void* thrown_exception); +/** + * Demangles a C++ symbol or type name. The buffer, if non-NULL, must be + * allocated with malloc() and must be *n bytes or more long. This function + * may call realloc() on the value pointed to by buf, and will return the + * length of the string via *n. + * + * The value pointed to by status is set to one of the following: + * + * 0: success + * -1: memory allocation failure + * -2: invalid mangled name + * -3: invalid arguments + */ +char* __cxa_demangle(const char* mangled_name, + char* buf, + size_t* n, + int* status); +#ifdef __cplusplus +} // extern "C" +} // namespace + +namespace abi = __cxxabiv1; + +#endif /* __cplusplus */ +#endif /* __CXXABI_H_ */ diff --git a/sdk/cpprt/linux/dwarf_eh.h b/sdk/cpprt/linux/dwarf_eh.h new file mode 100644 index 0000000000..21557fc1a8 --- /dev/null +++ b/sdk/cpprt/linux/dwarf_eh.h @@ -0,0 +1,479 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * dwarf_eh.h - Defines some helper functions for parsing DWARF exception + * handling tables. + * + * This file contains various helper functions that are independent of the + * language-specific code. It can be used in any personality function for the + * Itanium ABI. + */ +#include + +// TODO: Factor out Itanium / ARM differences. We probably want an itanium.h +// and arm.h that can be included by this file depending on the target ABI. + +// _GNU_SOURCE must be defined for unwind.h to expose some of the functions +// that we want. If it isn't, then we define it and undefine it to make sure +// that it doesn't impact the rest of the program. +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +# include "unwind.h" +# undef _GNU_SOURCE +#else +# include "unwind.h" +#endif + +#include + +/// Type used for pointers into DWARF data +typedef unsigned char *dw_eh_ptr_t; + +// Flag indicating a signed quantity +#define DW_EH_PE_signed 0x08 +/// DWARF data encoding types. +enum dwarf_data_encoding +{ + /// Unsigned, little-endian, base 128-encoded (variable length). + DW_EH_PE_uleb128 = 0x01, + /// Unsigned 16-bit integer. + DW_EH_PE_udata2 = 0x02, + /// Unsigned 32-bit integer. + DW_EH_PE_udata4 = 0x03, + /// Unsigned 64-bit integer. + DW_EH_PE_udata8 = 0x04, + /// Signed, little-endian, base 128-encoded (variable length) + DW_EH_PE_sleb128 = DW_EH_PE_uleb128 | DW_EH_PE_signed, + /// Signed 16-bit integer. + DW_EH_PE_sdata2 = DW_EH_PE_udata2 | DW_EH_PE_signed, + /// Signed 32-bit integer. + DW_EH_PE_sdata4 = DW_EH_PE_udata4 | DW_EH_PE_signed, + /// Signed 32-bit integer. + DW_EH_PE_sdata8 = DW_EH_PE_udata8 | DW_EH_PE_signed +}; + +/** + * Returns the encoding for a DWARF EH table entry. The encoding is stored in + * the low four of an octet. The high four bits store the addressing mode. + */ +static inline enum dwarf_data_encoding get_encoding(unsigned char x) +{ + return (enum dwarf_data_encoding)(x & 0xf); +} + +/** + * DWARF addressing mode constants. When reading a pointer value from a DWARF + * exception table, you must know how it is stored and what the addressing mode + * is. The low four bits tell you the encoding, allowing you to decode a + * number. The high four bits tell you the addressing mode, allowing you to + * turn that number into an address in memory. + */ +enum dwarf_data_relative +{ + /// Value is omitted + DW_EH_PE_omit = 0xff, + /// Absolute pointer value + DW_EH_PE_absptr = 0x00, + /// Value relative to program counter + DW_EH_PE_pcrel = 0x10, + /// Value relative to the text segment + DW_EH_PE_textrel = 0x20, + /// Value relative to the data segment + DW_EH_PE_datarel = 0x30, + /// Value relative to the start of the function + DW_EH_PE_funcrel = 0x40, + /// Aligned pointer (Not supported yet - are they actually used?) + DW_EH_PE_aligned = 0x50, + /// Pointer points to address of real value + DW_EH_PE_indirect = 0x80 +}; +/** + * Returns the addressing mode component of this encoding. + */ +static inline enum dwarf_data_relative get_base(unsigned char x) +{ + return (enum dwarf_data_relative)(x & 0x70); +} +/** + * Returns whether an encoding represents an indirect address. + */ +static int is_indirect(unsigned char x) +{ + return ((x & DW_EH_PE_indirect) == DW_EH_PE_indirect); +} + +/** + * Returns the size of a fixed-size encoding. This function will abort if + * called with a value that is not a fixed-size encoding. + */ +static inline int dwarf_size_of_fixed_size_field(unsigned char type) +{ + switch (get_encoding(type)) + { + default: abort(); + case DW_EH_PE_sdata2: + case DW_EH_PE_udata2: return 2; + case DW_EH_PE_sdata4: + case DW_EH_PE_udata4: return 4; + case DW_EH_PE_sdata8: + case DW_EH_PE_udata8: return 8; + case DW_EH_PE_absptr: return sizeof(void*); + } +} + +/** + * Read an unsigned, little-endian, base-128, DWARF value. Updates *data to + * point to the end of the value. Stores the number of bits read in the value + * pointed to by b, allowing you to determine the value of the highest bit, and + * therefore the sign of a signed value. + * + * This function is not intended to be called directly. Use read_sleb128() or + * read_uleb128() for reading signed and unsigned versions, respectively. + */ +static uint64_t read_leb128(dw_eh_ptr_t *data, int *b) +{ + uint64_t uleb = 0; + unsigned int bit = 0; + unsigned char digit = 0; + // We have to read at least one octet, and keep reading until we get to one + // with the high bit unset + do + { + // This check is a bit too strict - we should also check the highest + // bit of the digit. + assert(bit < sizeof(uint64_t) * 8); + // Get the base 128 digit + digit = (**data) & 0x7f; + // Add it to the current value + uleb += digit << bit; + // Increase the shift value + bit += 7; + // Proceed to the next octet + (*data)++; + // Terminate when we reach a value that does not have the high bit set + // (i.e. which was not modified when we mask it with 0x7f) + } while ((*(*data - 1)) != digit); + *b = bit; + + return uleb; +} + +/** + * Reads an unsigned little-endian base-128 value starting at the address + * pointed to by *data. Updates *data to point to the next byte after the end + * of the variable-length value. + */ +static int64_t read_uleb128(dw_eh_ptr_t *data) +{ + int b; + return read_leb128(data, &b); +} + +/** + * Reads a signed little-endian base-128 value starting at the address pointed + * to by *data. Updates *data to point to the next byte after the end of the + * variable-length value. + */ +static int64_t read_sleb128(dw_eh_ptr_t *data) +{ + int bits; + // Read as if it's signed + uint64_t uleb = read_leb128(data, &bits); + // If the most significant bit read is 1, then we need to sign extend it + if ((uleb >> (bits-1)) == 1) + { + // Sign extend by setting all bits in front of it to 1 + uleb |= ((int64_t)-1) << bits; + } + return (int64_t)uleb; +} +/** + * Reads a value using the specified encoding from the address pointed to by + * *data. Updates the value of *data to point to the next byte after the end + * of the data. + */ +static uint64_t read_value(char encoding, dw_eh_ptr_t *data) +{ + enum dwarf_data_encoding type = get_encoding(encoding); + uint64_t v; + switch (type) + { + // Read fixed-length types +#define READ(dwarf, type) \ + case dwarf:\ + v = (uint64_t)(*(type*)(*data));\ + *data += sizeof(type);\ + break; + READ(DW_EH_PE_udata2, uint16_t) + READ(DW_EH_PE_udata4, uint32_t) + READ(DW_EH_PE_udata8, uint64_t) + READ(DW_EH_PE_sdata2, int16_t) + READ(DW_EH_PE_sdata4, int32_t) + READ(DW_EH_PE_sdata8, int64_t) + READ(DW_EH_PE_absptr, intptr_t) +#undef READ + // Read variable-length types + case DW_EH_PE_sleb128: + v = read_sleb128(data); + break; + case DW_EH_PE_uleb128: + v = read_uleb128(data); + break; + default: abort(); + } + + return v; +} + +/** + * Resolves an indirect value. This expects an unwind context, an encoding, a + * decoded value, and the start of the region as arguments. The returned value + * is a pointer to the address identified by the encoded value. + * + * If the encoding does not specify an indirect value, then this returns v. + */ +static uint64_t resolve_indirect_value(_Unwind_Context *c, + unsigned char encoding, + int64_t v, + dw_eh_ptr_t start) +{ + switch (get_base(encoding)) + { + case DW_EH_PE_pcrel: + v += (uint64_t)start; + break; + case DW_EH_PE_textrel: + v += (uint64_t)_Unwind_GetTextRelBase(c); + break; + case DW_EH_PE_datarel: + v += (uint64_t)_Unwind_GetDataRelBase(c); + break; + case DW_EH_PE_funcrel: + v += (uint64_t)_Unwind_GetRegionStart(c); + default: + break; + } + // If this is an indirect value, then it is really the address of the real + // value + // TODO: Check whether this should really always be a pointer - it seems to + // be a GCC extensions, so not properly documented... + if (is_indirect(encoding)) + { + v = (uint64_t)(uintptr_t)*(void**)v; + } + return v; +} + + +/** + * Reads an encoding and a value, updating *data to point to the next byte. + */ +static inline void read_value_with_encoding(_Unwind_Context *context, + dw_eh_ptr_t *data, + uint64_t *out) +{ + dw_eh_ptr_t start = *data; + unsigned char encoding = *((*data)++); + // If this value is omitted, skip it and don't touch the output value + if (encoding == DW_EH_PE_omit) { return; } + + *out = read_value(encoding, data); + *out = resolve_indirect_value(context, encoding, *out, start); +} + +/** + * Structure storing a decoded language-specific data area. Use parse_lsda() + * to generate an instance of this structure from the address returned by the + * generic unwind library. + * + * You should not need to inspect the fields of this structure directly if you + * are just using this header. The structure stores the locations of the + * various tables used for unwinding exceptions and is used by the functions + * for reading values from these tables. + */ +struct dwarf_eh_lsda +{ + /// The start of the region. This is a cache of the value returned by + /// _Unwind_GetRegionStart(). + dw_eh_ptr_t region_start; + /// The start of the landing pads table. + dw_eh_ptr_t landing_pads; + /// The start of the type table. + dw_eh_ptr_t type_table; + /// The encoding used for entries in the type tables. + unsigned char type_table_encoding; + /// The location of the call-site table. + dw_eh_ptr_t call_site_table; + /// The location of the action table. + dw_eh_ptr_t action_table; + /// The encoding used for entries in the call-site table. + unsigned char callsite_encoding; +}; + +/** + * Parse the header on the language-specific data area and return a structure + * containing the addresses and encodings of the various tables. + */ +static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context, + unsigned char *data) +{ + struct dwarf_eh_lsda lsda; + + lsda.region_start = (dw_eh_ptr_t)(uintptr_t)_Unwind_GetRegionStart(context); + + // If the landing pads are relative to anything other than the start of + // this region, find out where. This is @LPStart in the spec, although the + // encoding that GCC uses does not quite match the spec. + uint64_t v = (uint64_t)(uintptr_t)lsda.region_start; + read_value_with_encoding(context, &data, &v); + lsda.landing_pads = (dw_eh_ptr_t)(uintptr_t)v; + + // If there is a type table, find out where it is. This is @TTBase in the + // spec. Note: we find whether there is a type table pointer by checking + // whether the leading byte is DW_EH_PE_omit (0xff), which is not what the + // spec says, but does seem to be how G++ indicates this. + lsda.type_table = 0; + lsda.type_table_encoding = *data++; + if (lsda.type_table_encoding != DW_EH_PE_omit) + { + v = read_uleb128(&data); + dw_eh_ptr_t type_table = data; + type_table += v; + lsda.type_table = type_table; + //lsda.type_table = (uintptr_t*)(data + v); + } +#if __arm__ + lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect); +#endif + + lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++)); + + // Action table is immediately after the call site table + lsda.action_table = data; + uintptr_t callsite_size = (uintptr_t)read_uleb128(&data); + lsda.action_table = data + callsite_size; + // Call site table is immediately after the header + lsda.call_site_table = (dw_eh_ptr_t)data; + + + return lsda; +} + +/** + * Structure representing an action to be performed while unwinding. This + * contains the address that should be unwound to and the action record that + * provoked this action. + */ +struct dwarf_eh_action +{ + /** + * The address that this action directs should be the new program counter + * value after unwinding. + */ + dw_eh_ptr_t landing_pad; + /// The address of the action record. + dw_eh_ptr_t action_record; +}; + +/** + * Look up the landing pad that corresponds to the current invoke. + * Returns true if record exists. The context is provided by the generic + * unwind library and the lsda should be the result of a call to parse_lsda(). + * + * The action record is returned via the result parameter. + */ +static bool dwarf_eh_find_callsite(struct _Unwind_Context *context, + struct dwarf_eh_lsda *lsda, + struct dwarf_eh_action *result) +{ + result->action_record = 0; + result->landing_pad = 0; + // The current instruction pointer offset within the region + uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context); + unsigned char *callsite_table = (unsigned char*)lsda->call_site_table; + + while (callsite_table <= lsda->action_table) + { + // Once again, the layout deviates from the spec. + uint64_t call_site_start, call_site_size, landing_pad, action; + call_site_start = read_value(lsda->callsite_encoding, &callsite_table); + call_site_size = read_value(lsda->callsite_encoding, &callsite_table); + + // Call site entries are sorted, so if we find a call site that's after + // the current instruction pointer then there is no action associated + // with this call and we should unwind straight through this frame + // without doing anything. + if (call_site_start > ip) { break; } + + // Read the address of the landing pad and the action from the call + // site table. + landing_pad = read_value(lsda->callsite_encoding, &callsite_table); + action = read_uleb128(&callsite_table); + + // We should not include the call_site_start (beginning of the region) + // address in the ip range. For each call site: + // + // address1: call proc + // address2: next instruction + // + // The call stack contains address2 and not address1, address1 can be + // at the end of another EH region. + if (call_site_start < ip && ip <= call_site_start + call_site_size) + { + if (action) + { + // Action records are 1-biased so both no-record and zeroth + // record can be stored. + result->action_record = lsda->action_table + action - 1; + } + // No landing pad means keep unwinding. + if (landing_pad) + { + // Landing pad is the offset from the value in the header + result->landing_pad = lsda->landing_pads + landing_pad; + } + return true; + } + } + return false; +} + +/// Defines an exception class from 8 bytes (endian independent) +#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \ + (((uint64_t)a << 56) +\ + ((uint64_t)b << 48) +\ + ((uint64_t)c << 40) +\ + ((uint64_t)d << 32) +\ + ((uint64_t)e << 24) +\ + ((uint64_t)f << 16) +\ + ((uint64_t)g << 8) +\ + ((uint64_t)h)) + +#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \ + ((uint32_t)e << 24) +\ + ((uint32_t)f << 16) +\ + ((uint32_t)g << 8) +\ + ((uint32_t)h) diff --git a/sdk/cpprt/linux/dynamic_cast.cc b/sdk/cpprt/linux/dynamic_cast.cc new file mode 100644 index 0000000000..7a07e4c6a7 --- /dev/null +++ b/sdk/cpprt/linux/dynamic_cast.cc @@ -0,0 +1,210 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "typeinfo.h" +#include + +using namespace ABI_NAMESPACE; + +/** + * Vtable header. + */ +struct vtable_header +{ + /** Offset of the leaf object. */ + ptrdiff_t leaf_offset; + /** Type of the object. */ + const __class_type_info *type; +}; + +/** + * Simple macro that does pointer arithmetic in bytes but returns a value of + * the same type as the original. + */ +#define ADD_TO_PTR(x, off) (__typeof__(x))(((char*)x) + off) + +bool std::type_info::__do_catch(std::type_info const *ex_type, + void **exception_object, + unsigned int outer) const +{ + const type_info *type = this; + + if (type == ex_type) + { + return true; + } + if (const __class_type_info *cti = dynamic_cast(type)) + { + return ex_type->__do_upcast(cti, exception_object); + } + return false; +} + +bool __pbase_type_info::__do_catch(std::type_info const *ex_type, + void **exception_object, + unsigned int outer) const +{ + if (ex_type == this) + { + return true; + } + if (!ex_type->__is_pointer_p()) + { + // Can't catch a non-pointer type in a pointer catch + return false; + } + + if (!(outer & 1)) + { + // If the low bit is cleared on this means that we've gone + // through a pointer that is not const qualified. + return false; + } + // Clear the low bit on outer if we're not const qualified. + if (!(__flags & __const_mask)) + { + outer &= ~1; + } + + const __pbase_type_info *ptr_type = + static_cast(ex_type); + + if (ptr_type->__flags & ~__flags) + { + // Handler pointer is less qualified + return false; + } + + // Special case for void* handler. + if(*__pointee == typeid(void)) + { + return true; + } + + return __pointee->__do_catch(ptr_type->__pointee, exception_object, outer); +} + +void *__class_type_info::cast_to(void *obj, const struct __class_type_info *other) const +{ + if (this == other) + { + return obj; + } + return 0; +} + +void *__si_class_type_info::cast_to(void *obj, const struct __class_type_info *other) const +{ + if (this == other) + { + return obj; + } + return __base_type->cast_to(obj, other); +} +bool __si_class_type_info::__do_upcast(const __class_type_info *target, + void **thrown_object) const +{ + if (this == target) + { + return true; + } + return __base_type->__do_upcast(target, thrown_object); +} + +void *__vmi_class_type_info::cast_to(void *obj, const struct __class_type_info *other) const +{ + if (__do_upcast(other, &obj)) + { + return obj; + } + return 0; +} + +bool __vmi_class_type_info::__do_upcast(const __class_type_info *target, + void **thrown_object) const +{ + if (this == target) + { + return true; + } + for (unsigned int i=0 ; i<__base_count ; i++) + { + const __base_class_type_info *info = &__base_info[i]; + ptrdiff_t offset = info->offset(); + // If this is a virtual superclass, the offset is stored in the + // object's vtable at the offset requested; 2.9.5.6.c: + // + // 'For a non-virtual base, this is the offset in the object of the + // base subobject. For a virtual base, this is the offset in the + // virtual table of the virtual base offset for the virtual base + // referenced (negative).' + + void *obj = *thrown_object; + if (info->isVirtual()) + { + // Object's vtable + ptrdiff_t *off = *(ptrdiff_t**)obj; + // Offset location in vtable + off = ADD_TO_PTR(off, offset); + offset = *off; + } + void *cast = ADD_TO_PTR(obj, offset); + + if (info->__base_type == target || + (info->__base_type->__do_upcast(target, &cast))) + { + *thrown_object = cast; + return true; + } + } + return 0; +} + + +/** + * ABI function used to implement the dynamic_cast<> operator. Some cases of + * this operator are implemented entirely in the compiler (e.g. to void*). + * This function implements the dynamic casts of the form dynamic_cast(v). + * This will be translated to a call to this function with the value v as the + * first argument. The type id of the static type of v is the second argument + * and the type id of the destination type (T) is the third argument. + * + * The third argument is a hint about the compiler's guess at the correct + * pointer offset. If this value is negative, then -1 indicates no hint, -2 + * that src is not a public base of dst, and -3 that src is a multiple public + * base type but never a virtual base type + */ +extern "C" void* __dynamic_cast(const void *sub, + const __class_type_info *src, + const __class_type_info *dst, + ptrdiff_t src2dst_offset) +{ + char *vtable_location = *(char**)sub; + const vtable_header *header = + (const vtable_header*)(vtable_location - sizeof(vtable_header)); + void *leaf = ADD_TO_PTR((void*)sub, header->leaf_offset); + return header->type->cast_to(leaf, dst); +} diff --git a/sdk/cpprt/linux/exception.cc b/sdk/cpprt/linux/exception.cc new file mode 100644 index 0000000000..8bf30a26d3 --- /dev/null +++ b/sdk/cpprt/linux/exception.cc @@ -0,0 +1,1419 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include "pthread_compat.h" +#include "typeinfo.h" +#include "dwarf_eh.h" +#include "atomic.h" +#include "cxxabi.h" +#include "thread_data.h" +#include "se_cdefs.h" + +// access the version varible to add a version to tstdcxx lib +SGX_ACCESS_VERSION(tstdcxx, 1) + +using namespace ABI_NAMESPACE; + +/** + * Saves the result of the landing pad that we have found. For ARM, this is + * stored in the generic unwind structure, while on other platforms it is + * stored in the C++ exception. + */ +static void saveLandingPad(struct _Unwind_Context *context, + struct _Unwind_Exception *ucb, + struct __cxa_exception *ex, + int selector, + dw_eh_ptr_t landingPad) +{ +#ifdef __arm__ + // On ARM, we store the saved exception in the generic part of the structure + ucb->barrier_cache.sp = _Unwind_GetGR(context, 13); + ucb->barrier_cache.bitpattern[1] = (uint32_t)selector; + ucb->barrier_cache.bitpattern[3] = (uint32_t)landingPad; +#endif + // Cache the results for the phase 2 unwind, if we found a handler + // and this is not a foreign exception. + if (ex) + { + ex->handlerSwitchValue = selector; + ex->catchTemp = landingPad; + } +} + +/** + * Loads the saved landing pad. Returns 1 on success, 0 on failure. + */ +static int loadLandingPad(struct _Unwind_Context *context, + struct _Unwind_Exception *ucb, + struct __cxa_exception *ex, + unsigned long *selector, + dw_eh_ptr_t *landingPad) +{ +#ifdef __arm__ + *selector = ucb->barrier_cache.bitpattern[1]; + *landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3]; + return 1; +#else + if (ex) + { + *selector = ex->handlerSwitchValue; + *landingPad = (dw_eh_ptr_t)ex->catchTemp; + return 0; + } + return 0; +#endif +} + +static inline _Unwind_Reason_Code continueUnwinding(struct _Unwind_Exception *ex, + struct _Unwind_Context *context) +{ +#ifdef __arm__ + if (__gnu_unwind_frame(ex, context) != _URC_OK) { return _URC_FAILURE; } +#endif + return _URC_CONTINUE_UNWIND; +} + + +extern "C" void __cxa_free_exception(void *thrown_exception); +extern "C" void __cxa_free_dependent_exception(void *thrown_exception); +extern "C" void* __dynamic_cast(const void *sub, + const __class_type_info *src, + const __class_type_info *dst, + ptrdiff_t src2dst_offset); + +/** + * The type of a handler that has been found. + */ +typedef enum +{ + /** No handler. */ + handler_none, + /** + * A cleanup - the exception will propagate through this frame, but code + * must be run when this happens. + */ + handler_cleanup, + /** + * A catch statement. The exception will not propagate past this frame + * (without an explicit rethrow). + */ + handler_catch +} handler_type; + +/** + * Per-thread info required by the runtime. We store a single structure + * pointer in thread-local storage, because this tends to be a scarce resource + * and it's impolite to steal all of it and not leave any for the rest of the + * program. + * + * Instances of this structure are allocated lazily - at most one per thread - + * and are destroyed on thread termination. + */ +struct __cxa_thread_info +{ + /** The termination handler for this thread. */ + terminate_handler terminateHandler; + /** The unexpected exception handler for this thread. */ + unexpected_handler unexpectedHandler; + /** + * The number of emergency buffers held by this thread. This is 0 in + * normal operation - the emergency buffers are only used when malloc() + * fails to return memory for allocating an exception. Threads are not + * permitted to hold more than 4 emergency buffers (as per recommendation + * in ABI spec [3.3.1]). + */ + int emergencyBuffersHeld; + /** + * The exception currently running in a cleanup. + */ + _Unwind_Exception *currentCleanup; + /** + * The public part of this structure, accessible from outside of this + * module. + */ + __cxa_eh_globals globals; +}; +/** + * Dependent exception. This + */ +struct __cxa_dependent_exception +{ +#if __LP64__ + void *primaryException; +#endif + std::type_info *exceptionType; + void (*exceptionDestructor) (void *); + unexpected_handler unexpectedHandler; + terminate_handler terminateHandler; + __cxa_exception *nextException; + int handlerCount; +#ifdef __arm__ + _Unwind_Exception *nextCleanup; + int cleanupCount; +#endif + int handlerSwitchValue; + const char *actionRecord; + const char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; +#if !__LP64__ + void *primaryException; +#endif + _Unwind_Exception unwindHeader; +}; + + +namespace std +{ + void unexpected(); +#if 0 + class exception + { + public: + virtual ~exception() throw(); + virtual const char* what() const throw(); + }; +#endif +} + +extern "C" std::type_info *__cxa_current_exception_type(); + +/** + * Class of exceptions to distinguish between this and other exception types. + * + * The first four characters are the vendor ID. Currently, we use GNUC, + * because we aim for ABI-compatibility with the GNU implementation, and + * various checks may test for equality of the class, which is incorrect. + */ +static const uint64_t exception_class = + EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\0'); +/** + * Class used for dependent exceptions. + */ +static const uint64_t dependent_exception_class = + EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\x01'); +/** + * The low four bytes of the exception class, indicating that we conform to the + * Itanium C++ ABI. This is currently unused, but should be used in the future + * if we change our exception class, to allow this library and libsupc++ to be + * linked to the same executable and both to interoperate. + */ +static const uint32_t abi_exception_class = + GENERIC_EXCEPTION_CLASS('C', '+', '+', '\0'); + +static bool isCXXException(uint64_t cls) +{ + return (cls == exception_class) || (cls == dependent_exception_class); +} + +static bool isDependentException(uint64_t cls) +{ + return cls == dependent_exception_class; +} + +static __cxa_exception *exceptionFromPointer(void *ex) +{ + return (__cxa_exception*)((char*)ex - + offsetof(struct __cxa_exception, unwindHeader)); +} +static __cxa_exception *realExceptionFromException(__cxa_exception *ex) +{ + if (!isDependentException(ex->unwindHeader.exception_class)) { return ex; } + return ((__cxa_exception*)(((__cxa_dependent_exception*)ex)->primaryException))-1; +} + + +namespace std +{ + // Forward declaration of standard library terminate() function used to + // abort execution. + void terminate(void); +} + +using namespace ABI_NAMESPACE; + + + +/** The global termination handler. */ +static terminate_handler terminateHandler = abort; +/** The global unexpected exception handler. */ +static unexpected_handler unexpectedHandler = std::terminate; + + +/** + * Cleanup function, allowing foreign exception handlers to correctly destroy + * this exception if they catch it. + */ +static void exception_cleanup(_Unwind_Reason_Code reason, + struct _Unwind_Exception *ex) +{ + __cxa_free_exception((void*)ex); +} +static void dependent_exception_cleanup(_Unwind_Reason_Code reason, + struct _Unwind_Exception *ex) +{ + + __cxa_free_dependent_exception((void*)ex); +} + +/** + * Recursively walk a list of exceptions and delete them all in post-order. + */ +static void free_exception_list(__cxa_exception *ex) +{ + if (0 != ex->nextException) + { + free_exception_list(ex->nextException); + } + // __cxa_free_exception() expects to be passed the thrown object, which + // immediately follows the exception, not the exception itself + __cxa_free_exception(ex+1); +} + +/** + * We may not be linked against a full pthread implementation. If we're not, + * then we need to fake the thread-local storage by storing 'thread-local' + * things in a global. + */ +static __cxa_thread_info* __get_thread_info_ptr() +{ + thread_data_t* td = get_thread_data(); + return (__cxa_thread_info *)td->cxx_thread_info; +} + +/** + * Returns the thread info structure, creating it if it is not already created. + */ +static __cxa_thread_info *thread_info() +{ + return __get_thread_info_ptr(); +} +/** + * Fast version of thread_info(). May fail if thread_info() is not called on + * this thread at least once already. + */ +static __cxa_thread_info *thread_info_fast() +{ + return __get_thread_info_ptr(); +} +/** + * ABI function returning the __cxa_eh_globals structure. + */ +extern "C" __cxa_eh_globals *ABI_NAMESPACE::__cxa_get_globals(void) +{ + return &(thread_info()->globals); +} +/** + * Version of __cxa_get_globals() assuming that __cxa_get_globals() has already + * been called at least once by this thread. + */ +extern "C" __cxa_eh_globals *ABI_NAMESPACE::__cxa_get_globals_fast(void) +{ + return &(thread_info_fast()->globals); +} + +/** + * An emergency allocation reserved for when malloc fails. This is treated as + * 16 buffers of 1KB each. + */ +static char emergency_buffer[16384]; +/** + * Flag indicating whether each buffer is allocated. + */ +static bool buffer_allocated[16]; +/** + * Lock used to protect emergency allocation. + */ +static pthread_mutex_t emergency_malloc_lock = PTHREAD_MUTEX_INITIALIZER; +/** + * Indicate whether there is chunk in `emergency_buffer available'. + * This variable is also protected by `emergency_malloc_lock'. + */ +static volatile bool buffer_available = true; + +/** + * Allocates size bytes from the emergency allocation mechanism, if possible. + * This function will fail if size is over 1KB or if this thread already has 4 + * emergency buffers. If all emergency buffers are allocated, it will wait + * until one becomes available. + */ +static char *emergency_malloc(size_t size) +{ + if (size > 1024) { return 0; } + + __cxa_thread_info *info = thread_info(); + // Only 4 emergency buffers allowed per thread! + if (info->emergencyBuffersHeld > 3) { return 0; } + + pthread_mutex_lock(&emergency_malloc_lock); + int buffer = -1; + while (buffer < 0) + { + // While we were sleeping on the lock, another thread might have free'd + // enough memory for us to use, so try the allocation again - no point + // using the emergency buffer if there is some real memory that we can + // use... + void *m = calloc(1, size); + if (0 != m) + { + pthread_mutex_unlock(&emergency_malloc_lock); + return (char*)m; + } + for (int i=0 ; i<16 ; i++) + { + if (!buffer_allocated[i]) + { + buffer = i; + buffer_allocated[i] = true; + break; + } + } + // If there still isn't a buffer available ... + if (buffer < 0) + { + // No buffer available, unlock and waiting on `buffer_available'. + buffer_available = false; + pthread_mutex_unlock(&emergency_malloc_lock); + while (!buffer_available) continue; + + // Try to acquire the lock again. + pthread_mutex_lock(&emergency_malloc_lock); + } + } + pthread_mutex_unlock(&emergency_malloc_lock); + info->emergencyBuffersHeld++; + return emergency_buffer + (1024 * buffer); +} + +/** + * Frees a buffer returned by emergency_malloc(). + * + * Note: Neither this nor emergency_malloc() is particularly efficient. This + * should not matter, because neither will be called in normal operation - they + * are only used when the program runs out of memory, which should not happen + * often. + */ +static void emergency_malloc_free(char *ptr) +{ + int buffer = -1; + // Find the buffer corresponding to this pointer. + for (int i=0 ; i<16 ; i++) + { + if (ptr == (void*)(emergency_buffer + (1024 * i))) + { + buffer = i; + break; + } + } + assert(buffer >= 0 && + "Trying to free something that is not an emergency buffer!"); + // emergency_malloc() is expected to return 0-initialized data. We don't + // zero the buffer when allocating it, because the static buffers will + // begin life containing 0 values. + memset((void*)ptr, 0, 1024); + pthread_mutex_lock(&emergency_malloc_lock); + // In theory, we don't need to do this with the lock held. In practice, + // our array of bools will probably be updated using 32-bit or 64-bit + // memory operations, so this update may clobber adjacent values. + if (buffer != -1) + { + buffer_allocated[buffer] = false; + buffer_available = true; + } + pthread_mutex_unlock(&emergency_malloc_lock); +} + +static char *alloc_or_die(size_t size) +{ + char *buffer = (char*)calloc(1, size); + + // If calloc() doesn't want to give us any memory, try using an emergency + // buffer. + if (0 == buffer) + { + buffer = emergency_malloc(size); + // This is only reached if the allocation is greater than 1KB, and + // anyone throwing objects that big really should know better. + if (0 == buffer) + { + //fprintf(stderr, "Out of memory attempting to allocate exception\n"); + std::terminate(); + } + } + return buffer; +} +static void free_exception(char *e) +{ + // If this allocation is within the address range of the emergency buffer, + // don't call free() because it was not allocated with malloc() + if ((e >= emergency_buffer) && + (e < (emergency_buffer + sizeof(emergency_buffer)))) + { + emergency_malloc_free(e); + } + else + { + free(e); + } +} + +/** + * Allocates an exception structure. Returns a pointer to the space that can + * be used to store an object of thrown_size bytes. This function will use an + * emergency buffer if malloc() fails, and may block if there are no such + * buffers available. + */ +extern "C" void *__cxa_allocate_exception(size_t thrown_size) +{ + size_t size = thrown_size + sizeof(__cxa_exception); + char *buffer = alloc_or_die(size); + return buffer+sizeof(__cxa_exception); +} + +extern "C" void *__cxa_allocate_dependent_exception(void) +{ + size_t size = sizeof(__cxa_dependent_exception); + char *buffer = alloc_or_die(size); + return buffer+sizeof(__cxa_dependent_exception); +} + +/** + * __cxa_free_exception() is called when an exception was thrown in between + * calling __cxa_allocate_exception() and actually throwing the exception. + * This happens when the object's copy constructor throws an exception. + * + * In this implementation, it is also called by __cxa_end_catch() and during + * thread cleanup. + */ +extern "C" void __cxa_free_exception(void *thrown_exception) +{ + __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + // Free the object that was thrown, calling its destructor + if (0 != ex->exceptionDestructor) + { + try + { + ex->exceptionDestructor(thrown_exception); + } + catch(...) + { + // FIXME: Check that this is really what the spec says to do. + std::terminate(); + } + } + + free_exception((char*)ex); +} + +static void releaseException(__cxa_exception *exception) +{ + if (isDependentException(exception->unwindHeader.exception_class)) + { + __cxa_free_dependent_exception(exception+1); + return; + } + if (__sync_sub_and_fetch(&exception->referenceCount, 1) == 0) + { + // __cxa_free_exception() expects to be passed the thrown object, + // which immediately follows the exception, not the exception + // itself + __cxa_free_exception(exception+1); + } +} + +void __cxa_free_dependent_exception(void *thrown_exception) +{ + __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)thrown_exception) - 1; + assert(isDependentException(ex->unwindHeader.exception_class)); + if (ex->primaryException) + { + releaseException(realExceptionFromException((__cxa_exception*)ex)); + } + free_exception((char*)ex); +} + +/** + * Callback function used with _Unwind_Backtrace(). + * + * Prints a stack trace. Used only for debugging help. + * + * Note: As of FreeBSD 8.1, dladd() still doesn't work properly, so this only + * correctly prints function names from public, relocatable, symbols. + */ +static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) +{ +#if 0 + Dl_info myinfo; + int mylookup = + dladdr((void*)(uintptr_t)__cxa_current_exception_type, &myinfo); + void *ip = (void*)_Unwind_GetIP(context); + Dl_info info; + if (dladdr(ip, &info) != 0) + { + if (mylookup == 0 || strcmp(info.dli_fname, myinfo.dli_fname) != 0) + { + printf("%p:%s() in %s\n", ip, info.dli_sname, info.dli_fname); + } + } +#endif + return _URC_CONTINUE_UNWIND; +} + +/** + * Report a failure that occurred when attempting to throw an exception. + * + * If the failure happened by falling off the end of the stack without finding + * a handler, prints a back trace before aborting. + */ +static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exception) +{ + switch (err) + { + default: break; + case _URC_FATAL_PHASE1_ERROR: + //fprintf(stderr, "Fatal error during phase 1 unwinding\n"); + break; +#ifndef __arm__ + case _URC_FATAL_PHASE2_ERROR: + //fprintf(stderr, "Fatal error during phase 2 unwinding\n"); + break; +#endif + case _URC_END_OF_STACK: + //fprintf(stderr, "Terminating due to uncaught exception %p", + // (void*)thrown_exception); + thrown_exception = realExceptionFromException(thrown_exception); + static const __class_type_info *e_ti = + static_cast(&typeid(std::exception)); + const __class_type_info *throw_ti = + dynamic_cast(thrown_exception->exceptionType); + if (throw_ti) + { + std::exception *e = + (std::exception*)e_ti->cast_to((void*)(thrown_exception+1), + throw_ti); + if (e) + { + //fprintf(stderr, " '%s'", e->what()); + } + } + +#if 0 + size_t bufferSize = 128; + char *demangled = (char*)malloc(bufferSize); + const char *mangled = thrown_exception->exceptionType->name(); + int status; + demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status); + //fprintf(stderr, " of type %s\n", + // status == 0 ? (const char*)demangled : mangled); + if (status == 0) { free(demangled); } +#endif + // Print a back trace if no handler is found. + // TODO: Make this optional + _Unwind_Backtrace(trace, 0); + break; + } + std::terminate(); +} + +static void throw_exception(__cxa_exception *ex) +{ + __cxa_thread_info *info = thread_info(); + ex->unexpectedHandler = info->unexpectedHandler; + if (0 == ex->unexpectedHandler) + { + ex->unexpectedHandler = unexpectedHandler; + } + ex->terminateHandler = info->terminateHandler; + if (0 == ex->terminateHandler) + { + ex->terminateHandler = terminateHandler; + } + info->globals.uncaughtExceptions++; + + _Unwind_Reason_Code err = _Unwind_RaiseException(&ex->unwindHeader); + // The _Unwind_RaiseException() function should not return, it should + // unwind the stack past this function. If it does return, then something + // has gone wrong. + report_failure(err, ex); +} + + +/** + * ABI function for throwing an exception. Takes the object to be thrown (the + * pointer returned by __cxa_allocate_exception()), the type info for the + * pointee, and the destructor (if there is one) as arguments. + */ +extern "C" void __cxa_throw(void *thrown_exception, + std::type_info *tinfo, + void(*dest)(void*)) +{ + __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + + ex->referenceCount = 1; + ex->exceptionType = tinfo; + + ex->exceptionDestructor = dest; + + ex->unwindHeader.exception_class = exception_class; + ex->unwindHeader.exception_cleanup = exception_cleanup; + + throw_exception(ex); +} + +extern "C" void __cxa_rethrow_primary_exception(void* thrown_exception) +{ + if (NULL == thrown_exception) { return; } + + __cxa_exception *original = exceptionFromPointer(thrown_exception); + __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)__cxa_allocate_dependent_exception())-1; + + ex->primaryException = thrown_exception; + __cxa_increment_exception_refcount(thrown_exception); + + ex->exceptionType = original->exceptionType; + ex->unwindHeader.exception_class = dependent_exception_class; + ex->unwindHeader.exception_cleanup = dependent_exception_cleanup; + + throw_exception((__cxa_exception*)ex); +} + +extern "C" void *__cxa_current_primary_exception(void) +{ + __cxa_eh_globals* globals = __cxa_get_globals(); + __cxa_exception *ex = globals->caughtExceptions; + + if (0 == ex) { return NULL; } + ex = realExceptionFromException(ex); + __sync_fetch_and_add(&ex->referenceCount, 1); + return ex + 1; +} + +extern "C" void __cxa_increment_exception_refcount(void* thrown_exception) +{ + if (NULL == thrown_exception) { return; } + __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + if (isDependentException(ex->unwindHeader.exception_class)) { return; } + __sync_fetch_and_add(&ex->referenceCount, 1); +} +extern "C" void __cxa_decrement_exception_refcount(void* thrown_exception) +{ + if (NULL == thrown_exception) { return; } + __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1; + releaseException(ex); +} + +/** + * ABI function. Rethrows the current exception. Does not remove the + * exception from the stack or decrement its handler count - the compiler is + * expected to set the landing pad for this function to the end of the catch + * block, and then call _Unwind_Resume() to continue unwinding once + * __cxa_end_catch() has been called and any cleanup code has been run. + */ +extern "C" void __cxa_rethrow() +{ + __cxa_eh_globals *globals = __cxa_get_globals(); + // Note: We don't remove this from the caught list here, because + // __cxa_end_catch will be called when we unwind out of the try block. We + // could probably make this faster by providing an alternative rethrow + // function and ensuring that all cleanup code is run before calling it, so + // we can skip the top stack frame when unwinding. + __cxa_exception *ex = globals->caughtExceptions; + + if (0 == ex) + { + //fprintf(stderr, + // "Attempting to rethrow an exception that doesn't exist!\n"); + std::terminate(); + } + + assert(ex->handlerCount > 0 && "Rethrowing uncaught exception!"); + + globals->uncaughtExceptions++; + + // ex->handlerCount will be decremented in __cxa_end_catch in enclosing + // catch block + + // Make handler count negative. This will tell __cxa_end_catch that + // exception was rethrown and exception object should not be destroyed + // when handler count become zero + ex->handlerCount = -ex->handlerCount; + + // Continue unwinding the stack with this exception. This should unwind to + // the place in the caller where __cxa_end_catch() is called. The caller + // will then run cleanup code and bounce the exception back with + // _Unwind_Resume(). + _Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(&ex->unwindHeader); + report_failure(err, ex); +} + +/** + * Returns the type_info object corresponding to the filter. + */ +static std::type_info *get_type_info_entry(_Unwind_Context *context, + dwarf_eh_lsda *lsda, + int filter) +{ + // Get the address of the record in the table. + dw_eh_ptr_t record = lsda->type_table - + dwarf_size_of_fixed_size_field(lsda->type_table_encoding)*filter; + //record -= 4; + dw_eh_ptr_t start = record; + // Read the value, but it's probably an indirect reference... + int64_t offset = read_value(lsda->type_table_encoding, &record); + + // (If the entry is 0, don't try to dereference it. That would be bad.) + if (offset == 0) { return 0; } + + // ...so we need to resolve it + return (std::type_info*)resolve_indirect_value(context, + lsda->type_table_encoding, offset, start); +} + + + +/** + * Checks the type signature found in a handler against the type of the thrown + * object. If ex is 0 then it is assumed to be a foreign exception and only + * matches cleanups. + */ +static bool check_type_signature(__cxa_exception *ex, + const std::type_info *type, + void *&adjustedPtr) +{ + void *exception_ptr = (void*)(ex+1); + const std::type_info *ex_type = NULL; + + if (ex) + { + ex_type = ex->exceptionType; + + bool is_ptr = ex_type->__is_pointer_p(); + if (is_ptr) + { + exception_ptr = *(void**)exception_ptr; + } + } + // Always match a catchall, even with a foreign exception + // + // Note: A 0 here is a catchall, not a cleanup, so we return true to + // indicate that we found a catch. + if (0 == type) + { + if (ex) + { + adjustedPtr = exception_ptr; + } + return true; + } + + if (0 == ex) { return false; } + + // If the types are the same, no casting is needed. + if (*type == *ex_type) + { + adjustedPtr = exception_ptr; + return true; + } + + + if (type->__do_catch(ex_type, &exception_ptr, 1)) + { + adjustedPtr = exception_ptr; + return true; + } + + return false; +} +/** + * Checks whether the exception matches the type specifiers in this action + * record. If the exception only matches cleanups, then this returns false. + * If it matches a catch (including a catchall) then it returns true. + * + * The selector argument is used to return the selector that is passed in the + * second exception register when installing the context. + */ +static handler_type check_action_record(_Unwind_Context *context, + dwarf_eh_lsda *lsda, + dw_eh_ptr_t action_record, + __cxa_exception *ex, + unsigned long *selector, + void *&adjustedPtr) +{ + if (!action_record) { return handler_cleanup; } + handler_type found = handler_none; + while (action_record) + { + int filter = read_sleb128(&action_record); + dw_eh_ptr_t action_record_offset_base = action_record; + int displacement = read_sleb128(&action_record); + action_record = displacement ? + action_record_offset_base + displacement : 0; + // We only check handler types for C++ exceptions - foreign exceptions + // are only allowed for cleanup. + if (filter > 0 && 0 != ex) + { + std::type_info *handler_type = get_type_info_entry(context, lsda, filter); + if (check_type_signature(ex, handler_type, adjustedPtr)) + { + *selector = filter; + return handler_catch; + } + } + else if (filter < 0 && 0 != ex) + { + bool matched = false; + if (found == handler_none) *selector = filter; +#ifdef __arm__ + filter++; + std::type_info *handler_type = get_type_info_entry(context, lsda, filter--); + while (handler_type) + { + if (check_type_signature(ex, handler_type, adjustedPtr)) + { + matched = true; + break; + } + handler_type = get_type_info_entry(context, lsda, filter--); + } +#else + unsigned char *type_index = ((unsigned char*)lsda->type_table - filter - 1); + while (*type_index) + { + std::type_info *handler_type = get_type_info_entry(context, lsda, *(type_index++)); + // If the exception spec matches a permitted throw type for + // this function, don't report a handler - we are allowed to + // propagate this exception out. + if (check_type_signature(ex, handler_type, adjustedPtr)) + { + matched = true; + break; + } + } +#endif + if (matched) { continue; } + // If we don't find an allowed exception spec, we need to install + // the context for this action. The landing pad will then call the + // unexpected exception function. Treat this as a catch + return handler_catch; + } + else if (filter == 0) + { + *selector = filter; + found = handler_cleanup; + } + } + return found; +} + +static void pushCleanupException(_Unwind_Exception *exceptionObject, + __cxa_exception *ex) +{ +#ifdef __arm__ + __cxa_thread_info *info = thread_info_fast(); + if (ex) + { + ex->cleanupCount++; + if (ex->cleanupCount > 1) + { + assert(exceptionObject == info->currentCleanup); + return; + } + ex->nextCleanup = info->currentCleanup; + } + info->currentCleanup = exceptionObject; +#endif +} + +/** + * The exception personality function. This is referenced in the unwinding + * DWARF metadata and is called by the unwind library for each C++ stack frame + * containing catch or cleanup code. + */ +extern "C" +BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) + // This personality function is for version 1 of the ABI. If you use it + // with a future version of the ABI, it won't know what to do, so it + // reports a fatal error and give up before it breaks anything. + if (1 != version) + { + return _URC_FATAL_PHASE1_ERROR; + } + __cxa_exception *ex = 0; + __cxa_exception *realEx = 0; + + // If this exception is throw by something else then we can't make any + // assumptions about its layout beyond the fields declared in + // _Unwind_Exception. + bool foreignException = !isCXXException(exceptionClass); + + // If this isn't a foreign exception, then we have a C++ exception structure + if (!foreignException) + { + ex = exceptionFromPointer(exceptionObject); + realEx = realExceptionFromException(ex); + } + + unsigned char *lsda_addr = + (unsigned char*)_Unwind_GetLanguageSpecificData(context); + + // No LSDA implies no landing pads - try the next frame + if (0 == lsda_addr) { return continueUnwinding(exceptionObject, context); } + + // These two variables define how the exception will be handled. + dwarf_eh_action action = {0}; + unsigned long selector = 0; + + // During the search phase, we do a complete lookup. If we return + // _URC_HANDLER_FOUND, then the phase 2 unwind will call this function with + // a _UA_HANDLER_FRAME action, telling us to install the handler frame. If + // we return _URC_CONTINUE_UNWIND, we may be called again later with a + // _UA_CLEANUP_PHASE action for this frame. + // + // The point of the two-stage unwind allows us to entirely avoid any stack + // unwinding if there is no handler. If there are just cleanups found, + // then we can just panic call an abort function. + // + // Matching a handler is much more expensive than matching a cleanup, + // because we don't need to bother doing type comparisons (or looking at + // the type table at all) for a cleanup. This means that there is no need + // to cache the result of finding a cleanup, because it's (quite) quick to + // look it up again from the action table. + if (actions & _UA_SEARCH_PHASE) + { + struct dwarf_eh_lsda lsda = parse_lsda(context, lsda_addr); + + if (!dwarf_eh_find_callsite(context, &lsda, &action)) + { + // EH range not found. This happens if exception is thrown and not + // caught inside a cleanup (destructor). We should call + // terminate() in this case. The catchTemp (landing pad) field of + // exception object will contain null when personality function is + // called with _UA_HANDLER_FRAME action for phase 2 unwinding. + return _URC_HANDLER_FOUND; + } + + handler_type found_handler = check_action_record(context, &lsda, + action.action_record, realEx, &selector, ex->adjustedPtr); + // If there's no action record, we've only found a cleanup, so keep + // searching for something real + if (found_handler == handler_catch) + { + // Cache the results for the phase 2 unwind, if we found a handler + // and this is not a foreign exception. + if (ex) + { + saveLandingPad(context, exceptionObject, ex, selector, action.landing_pad); + ex->languageSpecificData = (const char*)lsda_addr; + ex->actionRecord = (const char*)action.action_record; + // ex->adjustedPtr is set when finding the action record. + } + return _URC_HANDLER_FOUND; + } + return continueUnwinding(exceptionObject, context); + } + + + // If this is a foreign exception, we didn't have anywhere to cache the + // lookup stuff, so we need to do it again. If this is either a forced + // unwind, a foreign exception, or a cleanup, then we just install the + // context for a cleanup. + if (!(actions & _UA_HANDLER_FRAME)) + { + // cleanup + struct dwarf_eh_lsda lsda = parse_lsda(context, lsda_addr); + dwarf_eh_find_callsite(context, &lsda, &action); + if (0 == action.landing_pad) { return continueUnwinding(exceptionObject, context); } + handler_type found_handler = check_action_record(context, &lsda, + action.action_record, realEx, &selector, ex->adjustedPtr); + // Ignore handlers this time. + if (found_handler != handler_cleanup) { return continueUnwinding(exceptionObject, context); } + pushCleanupException(exceptionObject, ex); + } + else if (foreignException) + { + struct dwarf_eh_lsda lsda = parse_lsda(context, lsda_addr); + dwarf_eh_find_callsite(context, &lsda, &action); + check_action_record(context, &lsda, action.action_record, realEx, + &selector, ex->adjustedPtr); + } + else if (ex->catchTemp == 0) + { + // Uncaught exception in cleanup, calling terminate + std::terminate(); + } + else + { + // Restore the saved info if we saved some last time. + loadLandingPad(context, exceptionObject, ex, &selector, &action.landing_pad); + ex->catchTemp = 0; + ex->handlerSwitchValue = 0; + } + + + _Unwind_SetIP(context, (unsigned long)action.landing_pad); + _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), + (unsigned long)exceptionObject); + _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), selector); + + return _URC_INSTALL_CONTEXT; +} + +/** + * ABI function called when entering a catch statement. The argument is the + * pointer passed out of the personality function. This is always the start of + * the _Unwind_Exception object. The return value for this function is the + * pointer to the caught exception, which is either the adjusted pointer (for + * C++ exceptions) of the unadjusted pointer (for foreign exceptions). + */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +extern "C" void *__cxa_begin_catch(void *e) throw() +#else +extern "C" void *__cxa_begin_catch(void *e) +#endif +{ + // Decrement the uncaught exceptions count + __cxa_eh_globals *globals = __cxa_get_globals(); + globals->uncaughtExceptions--; + _Unwind_Exception *exceptionObject = (_Unwind_Exception*)e; + + if (isCXXException(exceptionObject->exception_class)) + { + __cxa_exception *ex = exceptionFromPointer(exceptionObject); + + if (ex->handlerCount == 0) + { + // Add this to the front of the list of exceptions being handled + // and increment its handler count so that it won't be deleted + // prematurely. + ex->nextException = globals->caughtExceptions; + globals->caughtExceptions = ex; + } + + if (ex->handlerCount < 0) + { + // Rethrown exception is catched before end of catch block. + // Clear the rethrow flag (make value positive) - we are allowed + // to delete this exception at the end of the catch block, as long + // as it isn't thrown again later. + + // Code pattern: + // + // try { + // throw x; + // } + // catch() { + // try { + // throw; + // } + // catch() { + // __cxa_begin_catch() <- we are here + // } + // } + ex->handlerCount = -ex->handlerCount + 1; + } + else + { + ex->handlerCount++; + } + + return ex->adjustedPtr; + } + // exceptionObject is the pointer to the _Unwind_Exception within the + // __cxa_exception. The throw object is after this + return ((char*)exceptionObject + sizeof(_Unwind_Exception)); +} + + + +/** + * ABI function called when exiting a catch block. This will free the current + * exception if it is no longer referenced in other catch blocks. + */ +extern "C" void __cxa_end_catch() +{ + // We can call the fast version here because the slow version is called in + // __cxa_throw(), which must have been called before we end a catch block + __cxa_eh_globals *globals = __cxa_get_globals_fast(); + __cxa_exception *ex = globals->caughtExceptions; + + assert(0 != ex && "Ending catch when no exception is on the stack!"); + + bool deleteException = true; + + if (ex->handlerCount < 0) + { + // exception was rethrown. Exception should not be deleted even if + // handlerCount become zero. + // Code pattern: + // try { + // throw x; + // } + // catch() { + // { + // throw; + // } + // cleanup { + // __cxa_end_catch(); <- we are here + // } + // } + // + + ex->handlerCount++; + deleteException = false; + } + else + { + ex->handlerCount--; + } + + if (ex->handlerCount == 0) + { + globals->caughtExceptions = ex->nextException; + if (deleteException) + { + releaseException(ex); + } + } +} + +/** + * ABI function. Returns the type of the current exception. + */ +extern "C" std::type_info *__cxa_current_exception_type() +{ + __cxa_eh_globals *globals = __cxa_get_globals(); + __cxa_exception *ex = globals->caughtExceptions; + return ex ? ex->exceptionType : 0; +} + +/** + * ABI function, called when an exception specification is violated. + * + * This function does not return. + */ +extern "C" void __cxa_call_unexpected(void*exception) +{ + _Unwind_Exception *exceptionObject = (_Unwind_Exception*)exception; + if (exceptionObject->exception_class == exception_class) + { + __cxa_exception *ex = exceptionFromPointer(exceptionObject); + if (ex->unexpectedHandler) + { + ex->unexpectedHandler(); + // Should not be reached. + abort(); + } + } + std::unexpected(); + // Should not be reached. + abort(); +} + +/** + * ABI function, returns the adjusted pointer to the exception object. + */ +extern "C" void *__cxa_get_exception_ptr(void *exceptionObject) +{ + return exceptionFromPointer(exceptionObject)->adjustedPtr; +} + +/** + * As an extension, we provide the ability for the unexpected and terminate + * handlers to be thread-local. We default to the standards-compliant + * behaviour where they are global. + */ +static bool thread_local_handlers = false; + + +namespace pathscale +{ + /** + * Sets whether unexpected and terminate handlers should be thread-local. + */ + void set_use_thread_local_handlers(bool flag) throw() + { + thread_local_handlers = flag; + } + /** + * Sets a thread-local unexpected handler. + */ + unexpected_handler set_unexpected(unexpected_handler f) throw() + { + static __cxa_thread_info *info = thread_info(); + unexpected_handler old = info->unexpectedHandler; + info->unexpectedHandler = f; + return old; + } + /** + * Sets a thread-local terminate handler. + */ + terminate_handler set_terminate(terminate_handler f) throw() + { + static __cxa_thread_info *info = thread_info(); + terminate_handler old = info->terminateHandler; + info->terminateHandler = f; + return old; + } +} + +namespace std +{ + /** + * Sets the function that will be called when an exception specification is + * violated. + */ + unexpected_handler set_unexpected(unexpected_handler f) throw() + { + if (thread_local_handlers) { return pathscale::set_unexpected(f); } + + return ATOMIC_SWAP(&unexpectedHandler, f); + } + /** + * Sets the function that is called to terminate the program. + */ + terminate_handler set_terminate(terminate_handler f) throw() + { + if (thread_local_handlers) { return pathscale::set_terminate(f); } + + return ATOMIC_SWAP(&terminateHandler, f); + } + /** + * Terminates the program, calling a custom terminate implementation if + * required. + */ + void terminate() + { +// Note, if there is a HW exception raised in the `term_handler', +// the abort() function might possibly be bypassed. +// +// On the other hand, if we disable ECALL before calling into +// the `term_handler', then the user can do only one OCALL in +// the handler (and it will fail when ORET). +#define force_abort(term_handler) do { \ + try { term_handler (); abort(); } \ + catch (...) { abort(); } \ +} while (0) + static __cxa_thread_info *info = thread_info_fast(); + if (0 != info && 0 != info->terminateHandler) + { + force_abort(info->terminateHandler); + // Should not be reached - a terminate handler is not expected to + // return. + } + force_abort(terminateHandler); +#undef force_abort + } + /** + * Called when an unexpected exception is encountered (i.e. an exception + * violates an exception specification). This calls abort() unless a + * custom handler has been set.. + */ + void unexpected() + { + static __cxa_thread_info *info = thread_info_fast(); + if (0 != info && 0 != info->unexpectedHandler) + { + info->unexpectedHandler(); + // Should not be reached - a terminate handler is not expected to + // return. + abort(); + } + unexpectedHandler(); + } + /** + * Returns whether there are any exceptions currently being thrown that + * have not been caught. This can occur inside a nested catch statement. + */ + bool uncaught_exception() throw() + { + __cxa_thread_info *info = thread_info(); + return info->globals.uncaughtExceptions != 0; + } + /** + * Returns the current unexpected handler. + */ + unexpected_handler get_unexpected() throw() + { + __cxa_thread_info *info = thread_info(); + if (info->unexpectedHandler) + { + return info->unexpectedHandler; + } + return ATOMIC_LOAD(&unexpectedHandler); + } + /** + * Returns the current terminate handler. + */ + terminate_handler get_terminate() throw() + { + __cxa_thread_info *info = thread_info(); + if (info->terminateHandler) + { + return info->terminateHandler; + } + return ATOMIC_LOAD(&terminateHandler); + } +} +#ifdef __arm__ +extern "C" _Unwind_Exception *__cxa_get_cleanup(void) +{ + __cxa_thread_info *info = thread_info_fast(); + _Unwind_Exception *exceptionObject = info->currentCleanup; + if (isCXXException(exceptionObject->exception_class)) + { + __cxa_exception *ex = exceptionFromPointer(exceptionObject); + ex->cleanupCount--; + if (ex->cleanupCount == 0) + { + info->currentCleanup = ex->nextCleanup; + ex->nextCleanup = 0; + } + } + else + { + info->currentCleanup = 0; + } + return exceptionObject; +} + +asm ( +".pushsection .text.__cxa_end_cleanup \n" +".global __cxa_end_cleanup \n" +".type __cxa_end_cleanup, \"function\" \n" +"__cxa_end_cleanup: \n" +" push {r1, r2, r3, r4} \n" +" bl __cxa_get_cleanup \n" +" push {r1, r2, r3, r4} \n" +" b _Unwind_Resume \n" +" bl abort \n" +".popsection \n" +); +#endif diff --git a/sdk/cpprt/linux/gcc_personality_v0.c b/sdk/cpprt/linux/gcc_personality_v0.c new file mode 100644 index 0000000000..cde07d7f67 --- /dev/null +++ b/sdk/cpprt/linux/gcc_personality_v0.c @@ -0,0 +1,254 @@ +/* ===-- gcc_personality_v0.c - Implement __gcc_personality_v0 -------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + */ + +#include +#include +#include "se_cdefs.h" + +#define compilerrt_abort abort + +SGX_ACCESS_VERSION(tstdcxx, 2) + + +/* + * _Unwind_* stuff based on C++ ABI public documentation + * http://refspecs.freestandards.org/abi-eh-1.21.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 enum { + _UA_SEARCH_PHASE = 1, + _UA_CLEANUP_PHASE = 2, + _UA_HANDLER_FRAME = 4, + _UA_FORCE_UNWIND = 8, + _UA_END_OF_STACK = 16 +} _Unwind_Action; + +typedef struct _Unwind_Context* _Unwind_Context_t; + +struct _Unwind_Exception { + uint64_t exception_class; + void (*exception_cleanup)(_Unwind_Reason_Code reason, + struct _Unwind_Exception* exc); + uintptr_t private_1; + uintptr_t private_2; +}; + +extern const uint8_t* _Unwind_GetLanguageSpecificData(_Unwind_Context_t c); +extern void _Unwind_SetGR(_Unwind_Context_t c, int i, uintptr_t n); +extern void _Unwind_SetIP(_Unwind_Context_t, uintptr_t new_value); +extern uintptr_t _Unwind_GetIP(_Unwind_Context_t context); +extern uintptr_t _Unwind_GetRegionStart(_Unwind_Context_t context); + + +/* + * Pointer encodings documented at: + * http://refspecs.freestandards.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html + */ + +#define DW_EH_PE_omit 0xff /* no data follows */ + +#define DW_EH_PE_absptr 0x00 +#define DW_EH_PE_uleb128 0x01 +#define DW_EH_PE_udata2 0x02 +#define DW_EH_PE_udata4 0x03 +#define DW_EH_PE_udata8 0x04 +#define DW_EH_PE_sleb128 0x09 +#define DW_EH_PE_sdata2 0x0A +#define DW_EH_PE_sdata4 0x0B +#define DW_EH_PE_sdata8 0x0C + +#define DW_EH_PE_pcrel 0x10 +#define DW_EH_PE_textrel 0x20 +#define DW_EH_PE_datarel 0x30 +#define DW_EH_PE_funcrel 0x40 +#define DW_EH_PE_aligned 0x50 +#define DW_EH_PE_indirect 0x80 /* gcc extension */ + + + +/* read a uleb128 encoded value and advance pointer */ +static uintptr_t readULEB128(const uint8_t** data) +{ + uintptr_t result = 0; + uintptr_t shift = 0; + unsigned char byte; + const uint8_t* p = *data; + do { + byte = *p++; + result |= (byte & 0x7f) << shift; + shift += 7; + } while (byte & 0x80); + *data = p; + return result; +} + +/* read a pointer encoded value and advance pointer */ +static uint64_t readEncodedPointer(const uint8_t** data, uint8_t encoding) +{ + const uint8_t* p = *data; + uint64_t result = 0; + + if ( encoding == DW_EH_PE_omit ) + return 0; + + /* first get value */ + switch (encoding & 0x0F) { + case DW_EH_PE_absptr: + result = *((uintptr_t*)p); + p += sizeof(uintptr_t); + break; + case DW_EH_PE_uleb128: + result = readULEB128(&p); + break; + case DW_EH_PE_udata2: + result = *((uint16_t*)p); + p += sizeof(uint16_t); + break; + case DW_EH_PE_udata4: + result = *((uint32_t*)p); + p += sizeof(uint32_t); + break; + case DW_EH_PE_udata8: + result = *((uint64_t*)p); + p += sizeof(uint64_t); + break; + case DW_EH_PE_sdata2: + result = *((int16_t*)p); + p += sizeof(int16_t); + break; + case DW_EH_PE_sdata4: + result = *((int32_t*)p); + p += sizeof(int32_t); + break; + case DW_EH_PE_sdata8: + result = *((int64_t*)p); + p += sizeof(int64_t); + break; + case DW_EH_PE_sleb128: + default: + /* not supported */ + compilerrt_abort(); + break; + } + + /* then add relative offset */ + switch ( encoding & 0x70 ) { + case DW_EH_PE_absptr: + /* do nothing */ + break; + case DW_EH_PE_pcrel: + result += (uintptr_t)(*data); + break; + case DW_EH_PE_textrel: + case DW_EH_PE_datarel: + case DW_EH_PE_funcrel: + case DW_EH_PE_aligned: + default: + /* not supported */ + compilerrt_abort(); + break; + } + + /* then apply indirection */ + if (encoding & DW_EH_PE_indirect) { + result = *((uintptr_t*)result); + } + + *data = p; + return result; +} + + +/* + * The C compiler makes references to __gcc_personality_v0 in + * the dwarf unwind information for translation units that use + * __attribute__((cleanup(xx))) on local variables. + * This personality routine is called by the system unwinder + * on each frame as the stack is unwound during a C++ exception + * throw through a C function compiled with -fexceptions. + */ +#if __arm__ +// the setjump-longjump based exceptions personality routine has a different name +_Unwind_Reason_Code __gcc_personality_sj0(int version, _Unwind_Action actions, + uint64_t exceptionClass, struct _Unwind_Exception* exceptionObject, + _Unwind_Context_t context) +#else +_Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions, + uint64_t exceptionClass, struct _Unwind_Exception* exceptionObject, + _Unwind_Context_t context) +#endif +{ + /* Since C does not have catch clauses, there is nothing to do during */ + /* phase 1 (the search phase). */ + if ( actions & _UA_SEARCH_PHASE ) + return _URC_CONTINUE_UNWIND; + + /* There is nothing to do if there is no LSDA for this frame. */ + const uint8_t* lsda = _Unwind_GetLanguageSpecificData(context); + if ( lsda == (uint8_t*) 0 ) + return _URC_CONTINUE_UNWIND; + + uintptr_t pc = _Unwind_GetIP(context)-1; + uintptr_t funcStart = _Unwind_GetRegionStart(context); + uintptr_t pcOffset = pc - funcStart; + + /* Parse LSDA header. */ + uint8_t lpStartEncoding = *lsda++; + if (lpStartEncoding != DW_EH_PE_omit) { + readEncodedPointer(&lsda, lpStartEncoding); + } + uint8_t ttypeEncoding = *lsda++; + if (ttypeEncoding != DW_EH_PE_omit) { + readULEB128(&lsda); + } + /* Walk call-site table looking for range that includes current PC. */ + uint8_t callSiteEncoding = *lsda++; + uint32_t callSiteTableLength = readULEB128(&lsda); + const uint8_t* callSiteTableStart = lsda; + const uint8_t* callSiteTableEnd = callSiteTableStart + callSiteTableLength; + const uint8_t* p=callSiteTableStart; + while (p < callSiteTableEnd) { + uint64_t start = readEncodedPointer(&p, callSiteEncoding); + uint64_t length = readEncodedPointer(&p, callSiteEncoding); + uint64_t landingPad = readEncodedPointer(&p, callSiteEncoding); + readULEB128(&p); /* action value not used for C code */ + if ( landingPad == 0 ) + continue; /* no landing pad for this entry */ + if ( (start <= pcOffset) && (pcOffset < (start+length)) ) { + /* Found landing pad for the PC. + * Set Instruction Pointer to so we re-enter function + * at landing pad. The landing pad is created by the compiler + * to take two parameters in registers. + */ + _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), + (uintptr_t)exceptionObject); + _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0); + _Unwind_SetIP(context, funcStart+landingPad); + return _URC_INSTALL_CONTEXT; + } + } + + /* No landing pad found, continue unwinding. */ + return _URC_CONTINUE_UNWIND; +} + diff --git a/sdk/cpprt/linux/guard.cc b/sdk/cpprt/linux/guard.cc new file mode 100644 index 0000000000..bfdf340284 --- /dev/null +++ b/sdk/cpprt/linux/guard.cc @@ -0,0 +1,169 @@ +/* + * Copyright 2010-2012 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * guard.cc: Functions for thread-safe static initialisation. + * + * Static values in C++ can be initialised lazily their first use. This file + * contains functions that are used to ensure that two threads attempting to + * initialize the same static do not call the constructor twice. This is + * important because constructors can have side effects, so calling the + * constructor twice may be very bad. + * + * Statics that require initialisation are protected by a 64-bit value. Any + * platform that can do 32-bit atomic test and set operations can use this + * value as a low-overhead lock. Because statics (in most sane code) are + * accessed far more times than they are initialised, this lock implementation + * is heavily optimised towards the case where the static has already been + * initialised. + */ +#include +#include + +#include "se_cdefs.h" + +SGX_ACCESS_VERSION(tstdcxx, 3) + +#ifdef __arm__ +// ARM ABI - 32-bit guards. + +/** + * Acquires a lock on a guard, returning 0 if the object has already been + * initialised, and 1 if it has not. If the object is already constructed then + * this function just needs to read a byte from memory and return. + */ +extern "C" int __cxa_guard_acquire(volatile int32_t *guard_object) +{ + if ((1<<31) == *guard_object) { return 0; } + // If we can atomically move the value from 0 -> 1, then this is + // uninitialised. + if (__sync_bool_compare_and_swap(guard_object, 0, 1)) + { + return 1; + } + // If the value is not 0, some other thread was initialising this. Spin + // until it's finished. + while (__sync_bool_compare_and_swap(guard_object, (1<<31), (1<<31))) + { + // If the other thread aborted, then we grab the lock + if (__sync_bool_compare_and_swap(guard_object, 0, 1)) + { + return 1; + } + sched_yield(); + } + return 0; +} + +/** + * Releases the lock without marking the object as initialised. This function + * is called if initialising a static causes an exception to be thrown. + */ +extern "C" void __cxa_guard_abort(int32_t *guard_object) +{ + assert(__sync_bool_compare_and_swap(guard_object, 1, 0)); +} +/** + * Releases the guard and marks the object as initialised. This function is + * called after successful initialisation of a static. + */ +extern "C" void __cxa_guard_release(int32_t *guard_object) +{ + assert(__sync_bool_compare_and_swap(guard_object, 1, (1<<31))); +} + + +#else +// Itanium ABI: 64-bit guards + +/** + * Returns a pointer to the low 32 bits in a 64-bit value, respecting the + * platform's byte order. + */ +static int32_t *low_32_bits(volatile int64_t *ptr) +{ + int32_t *low= (int32_t*)ptr; + // Test if the machine is big endian - constant propagation at compile time + // should eliminate this completely. + int one = 1; + if (*(char*)&one != 1) + { + low++; + } + return low; +} + +/** + * Acquires a lock on a guard, returning 0 if the object has already been + * initialised, and 1 if it has not. If the object is already constructed then + * this function just needs to read a byte from memory and return. + */ +extern "C" int __cxa_guard_acquire(volatile int64_t *guard_object) +{ + char first_byte = (*guard_object) >> 56; + if (1 == first_byte) { return 0; } + int32_t *lock = low_32_bits(guard_object); + // Simple spin lock using the low 32 bits. We assume that concurrent + // attempts to initialize statics are very rare, so we don't need to + // optimise for the case where we have lots of threads trying to acquire + // the lock at the same time. + while (!__sync_bool_compare_and_swap_4(lock, 0, 1)) + { + if (1 == ((*guard_object) >> 56)) + { + break; + } + // sched_yield need to be implemented as a OCALL, + // while we try to remove OCALLs in this library. + //sched_yield(); + } + // We have to test the guard again, in case another thread has performed + // the initialisation while we were trying to acquire the lock. + first_byte = (*guard_object) >> 56; + return (1 != first_byte); +} + +/** + * Releases the lock without marking the object as initialised. This function + * is called if initialising a static causes an exception to be thrown. + */ +extern "C" void __cxa_guard_abort(int64_t *guard_object) +{ + int32_t *lock = low_32_bits(guard_object); + *lock = 0; +} +/** + * Releases the guard and marks the object as initialised. This function is + * called after successful initialisation of a static. + */ +extern "C" void __cxa_guard_release(int64_t *guard_object) +{ + // Set the first byte to 1 + *guard_object |= ((int64_t)1) << 56; + __cxa_guard_abort(guard_object); +} + +#endif diff --git a/sdk/cpprt/linux/libelftc_dem_gnu3.c b/sdk/cpprt/linux/libelftc_dem_gnu3.c new file mode 100644 index 0000000000..6d0680be3f --- /dev/null +++ b/sdk/cpprt/linux/libelftc_dem_gnu3.c @@ -0,0 +1,3474 @@ +/*- + * Copyright (c) 2007, 2008 Hyogeol Lee + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @file cpp_demangle.c + * @brief Decode IA-64 C++ ABI style implementation. + * + * IA-64 standard ABI(Itanium C++ ABI) references. + * + * http://www.codesourcery.com/cxx-abi/abi.html#mangling \n + * http://www.codesourcery.com/cxx-abi/abi-mangling.html + */ + +/** @brief Dynamic vector data for string. */ +struct vector_str { + /** Current size */ + size_t size; + /** Total capacity */ + size_t capacity; + /** String array */ + char **container; +}; + +#define BUFFER_GROWFACTOR 1.618 +#define VECTOR_DEF_CAPACITY 8 +#define ELFTC_ISDIGIT(C) (isdigit((C) & 0xFF)) + +enum type_qualifier { + TYPE_PTR, TYPE_REF, TYPE_CMX, TYPE_IMG, TYPE_EXT, TYPE_RST, TYPE_VAT, + TYPE_CST +}; + +struct vector_type_qualifier { + size_t size, capacity; + enum type_qualifier *q_container; + struct vector_str ext_name; +}; + +enum read_cmd { + READ_FAIL, READ_NEST, READ_TMPL, READ_EXPR, READ_EXPL, READ_LOCAL, + READ_TYPE, READ_FUNC, READ_PTRMEM +}; + +struct vector_read_cmd { + size_t size, capacity; + enum read_cmd *r_container; +}; + +struct cpp_demangle_data { + struct vector_str output; /* output string vector */ + struct vector_str output_tmp; + struct vector_str subst; /* substitution string vector */ + struct vector_str tmpl; + struct vector_str class_type; + struct vector_read_cmd cmd; + bool paren; /* parenthesis opened */ + bool pfirst; /* first element of parameter */ + bool mem_rst; /* restrict member function */ + bool mem_vat; /* volatile member function */ + bool mem_cst; /* const member function */ + int func_type; + const char *cur; /* current mangled name ptr */ + const char *last_sname; /* last source name */ + int push_head; +}; + +#define CPP_DEMANGLE_TRY_LIMIT 128 +#define FLOAT_SPRINTF_TRY_LIMIT 5 +#define FLOAT_QUADRUPLE_BYTES 16 +#define FLOAT_EXTENED_BYTES 10 + +#define SIMPLE_HASH(x,y) (64 * x + y) + +static size_t get_strlen_sum(const struct vector_str *v); +static bool vector_str_grow(struct vector_str *v); + +static size_t +get_strlen_sum(const struct vector_str *v) +{ + size_t i, len = 0; + + if (v == NULL) + return (0); + + assert(v->size > 0); + + for (i = 0; i < v->size; ++i) + len += strlen(v->container[i]); + + return (len); +} + +/** + * @brief Deallocate resource in vector_str. + */ +static void +vector_str_dest(struct vector_str *v) +{ + size_t i; + + if (v == NULL) + return; + + for (i = 0; i < v->size; ++i) + free(v->container[i]); + + free(v->container); +} + +/** + * @brief Find string in vector_str. + * @param v Destination vector. + * @param o String to find. + * @param l Length of the string. + * @return -1 at failed, 0 at not found, 1 at found. + */ +static int +vector_str_find(const struct vector_str *v, const char *o, size_t l) +{ + size_t i; + + if (v == NULL || o == NULL) + return (-1); + + for (i = 0; i < v->size; ++i) + if (strncmp(v->container[i], o, l) == 0) + return (1); + + return (0); +} + +/** + * @brief Get new allocated flat string from vector. + * + * If l is not NULL, return length of the string. + * @param v Destination vector. + * @param l Length of the string. + * @return NULL at failed or NUL terminated new allocated string. + */ +static char * +vector_str_get_flat(const struct vector_str *v, size_t *l) +{ + ssize_t elem_pos, elem_size, rtn_size; + size_t i; + char *rtn; + + if (v == NULL || v->size == 0) + return (NULL); + + if ((rtn_size = get_strlen_sum(v)) == 0) + return (NULL); + + if ((rtn = malloc(sizeof(char) * (rtn_size + 1))) == NULL) + return (NULL); + + elem_pos = 0; + for (i = 0; i < v->size; ++i) { + elem_size = strlen(v->container[i]); + + memcpy(rtn + elem_pos, v->container[i], elem_size); + + elem_pos += elem_size; + } + + rtn[rtn_size] = '\0'; + + if (l != NULL) + *l = rtn_size; + + return (rtn); +} + +static bool +vector_str_grow(struct vector_str *v) +{ + size_t i, tmp_cap; + char **tmp_ctn; + + if (v == NULL) + return (false); + + assert(v->capacity > 0); + + tmp_cap = v->capacity * BUFFER_GROWFACTOR; + + assert(tmp_cap > v->capacity); + + if ((tmp_ctn = malloc(sizeof(char *) * tmp_cap)) == NULL) + return (false); + + for (i = 0; i < v->size; ++i) + tmp_ctn[i] = v->container[i]; + + free(v->container); + + v->container = tmp_ctn; + v->capacity = tmp_cap; + + return (true); +} + +/** + * @brief Initialize vector_str. + * @return false at failed, true at success. + */ +static bool +vector_str_init(struct vector_str *v) +{ + + if (v == NULL) + return (false); + + v->size = 0; + v->capacity = VECTOR_DEF_CAPACITY; + + assert(v->capacity > 0); + + if ((v->container = malloc(sizeof(char *) * v->capacity)) == NULL) + return (false); + + assert(v->container != NULL); + + return (true); +} + +/** + * @brief Remove last element in vector_str. + * @return false at failed, true at success. + */ +static bool +vector_str_pop(struct vector_str *v) +{ + + if (v == NULL) + return (false); + + if (v->size == 0) + return (true); + + --v->size; + + free(v->container[v->size]); + v->container[v->size] = NULL; + + return (true); +} + +/** + * @brief Push back string to vector. + * @return false at failed, true at success. + */ +static bool +vector_str_push(struct vector_str *v, const char *str, size_t len) +{ + + if (v == NULL || str == NULL) + return (false); + + if (v->size == v->capacity && vector_str_grow(v) == false) + return (false); + + if ((v->container[v->size] = malloc(sizeof(char) * (len + 1))) == NULL) + return (false); + + snprintf(v->container[v->size], len + 1, "%s", str); + + ++v->size; + + return (true); +} + +/** + * @brief Push front org vector to det vector. + * @return false at failed, true at success. + */ +static bool +vector_str_push_vector_head(struct vector_str *dst, struct vector_str *org) +{ + size_t i, j, tmp_cap; + char **tmp_ctn; + + if (dst == NULL || org == NULL) + return (false); + + tmp_cap = (dst->size + org->size) * BUFFER_GROWFACTOR; + + if ((tmp_ctn = malloc(sizeof(char *) * tmp_cap)) == NULL) + return (false); + + for (i = 0; i < org->size; ++i) + if ((tmp_ctn[i] = strdup(org->container[i])) == NULL) { + for (j = 0; j < i; ++j) + free(tmp_ctn[j]); + + free(tmp_ctn); + + return (false); + } + + for (i = 0; i < dst->size; ++i) + tmp_ctn[i + org->size] = dst->container[i]; + + free(dst->container); + + dst->container = tmp_ctn; + dst->capacity = tmp_cap; + dst->size += org->size; + + return (true); +} + +/** + * @brief Get new allocated flat string from vector between begin and end. + * + * If r_len is not NULL, string length will be returned. + * @return NULL at failed or NUL terminated new allocated string. + */ +static char * +vector_str_substr(const struct vector_str *v, size_t begin, size_t end, + size_t *r_len) +{ + size_t cur, i, len; + char *rtn; + + if (v == NULL || begin > end) + return (NULL); + + len = 0; + for (i = begin; i < end + 1; ++i) + len += strlen(v->container[i]); + + if ((rtn = malloc(sizeof(char) * (len + 1))) == NULL) + return (NULL); + + if (r_len != NULL) + *r_len = len; + + cur = 0; + for (i = begin; i < end + 1; ++i) { + len = strlen(v->container[i]); + memcpy(rtn + cur, v->container[i], len); + cur += len; + } + rtn[cur] = '\0'; + + return (rtn); +} + +static void cpp_demangle_data_dest(struct cpp_demangle_data *); +static int cpp_demangle_data_init(struct cpp_demangle_data *, + const char *); +static int cpp_demangle_get_subst(struct cpp_demangle_data *, size_t); +static int cpp_demangle_get_tmpl_param(struct cpp_demangle_data *, size_t); +static int cpp_demangle_push_fp(struct cpp_demangle_data *, + char *(*)(const char *, size_t)); +static int cpp_demangle_push_str(struct cpp_demangle_data *, const char *, + size_t); +static int cpp_demangle_push_subst(struct cpp_demangle_data *, + const char *, size_t); +static int cpp_demangle_push_subst_v(struct cpp_demangle_data *, + struct vector_str *); +static int cpp_demangle_push_type_qualifier(struct cpp_demangle_data *, + struct vector_type_qualifier *, const char *); +static int cpp_demangle_read_array(struct cpp_demangle_data *); +static int cpp_demangle_read_encoding(struct cpp_demangle_data *); +static int cpp_demangle_read_expr_primary(struct cpp_demangle_data *); +static int cpp_demangle_read_expression(struct cpp_demangle_data *); +static int cpp_demangle_read_expression_binary(struct cpp_demangle_data *, + const char *, size_t); +static int cpp_demangle_read_expression_unary(struct cpp_demangle_data *, + const char *, size_t); +static int cpp_demangle_read_expression_trinary(struct cpp_demangle_data *, + const char *, size_t, const char *, size_t); +static int cpp_demangle_read_function(struct cpp_demangle_data *, int *, + struct vector_type_qualifier *); +static int cpp_demangle_read_local_name(struct cpp_demangle_data *); +static int cpp_demangle_read_name(struct cpp_demangle_data *); +static int cpp_demangle_read_nested_name(struct cpp_demangle_data *); +static int cpp_demangle_read_number(struct cpp_demangle_data *, long *); +static int cpp_demangle_read_nv_offset(struct cpp_demangle_data *); +static int cpp_demangle_read_offset(struct cpp_demangle_data *); +static int cpp_demangle_read_offset_number(struct cpp_demangle_data *); +static int cpp_demangle_read_pointer_to_member(struct cpp_demangle_data *); +static int cpp_demangle_read_sname(struct cpp_demangle_data *); +static int cpp_demangle_read_subst(struct cpp_demangle_data *); +static int cpp_demangle_read_subst_std(struct cpp_demangle_data *); +static int cpp_demangle_read_subst_stdtmpl(struct cpp_demangle_data *, + const char *, size_t); +static int cpp_demangle_read_tmpl_arg(struct cpp_demangle_data *); +static int cpp_demangle_read_tmpl_args(struct cpp_demangle_data *); +static int cpp_demangle_read_tmpl_param(struct cpp_demangle_data *); +static int cpp_demangle_read_type(struct cpp_demangle_data *, int); +static int cpp_demangle_read_uqname(struct cpp_demangle_data *); +static int cpp_demangle_read_v_offset(struct cpp_demangle_data *); +static char *decode_fp_to_double(const char *, size_t); +static char *decode_fp_to_float(const char *, size_t); +static char *decode_fp_to_float128(const char *, size_t); +static char *decode_fp_to_float80(const char *, size_t); +static char *decode_fp_to_long_double(const char *, size_t); +static int hex_to_dec(char); +static void vector_read_cmd_dest(struct vector_read_cmd *); +static int vector_read_cmd_find(struct vector_read_cmd *, enum read_cmd); +static int vector_read_cmd_init(struct vector_read_cmd *); +static int vector_read_cmd_pop(struct vector_read_cmd *); +static int vector_read_cmd_push(struct vector_read_cmd *, enum read_cmd); +static void vector_type_qualifier_dest(struct vector_type_qualifier *); +static int vector_type_qualifier_init(struct vector_type_qualifier *); +static int vector_type_qualifier_push(struct vector_type_qualifier *, + enum type_qualifier); + +/** + * @brief Decode the input string by IA-64 C++ ABI style. + * + * GNU GCC v3 use IA-64 standard ABI. + * @return New allocated demangled string or NULL if failed. + * @todo 1. Testing and more test case. 2. Code cleaning. + */ +char * +__cxa_demangle_gnu3(const char *org) +{ + struct cpp_demangle_data ddata; + ssize_t org_len; + unsigned int limit; + char *rtn = NULL; + + if (org == NULL) + return (NULL); + + // Try demangling as a type for short encodings + if (((org_len = strlen(org)) < 2) || (org[0] != '_' || org[1] != 'Z' )) { + if (!cpp_demangle_data_init(&ddata, org)) + return (NULL); + if (!cpp_demangle_read_type(&ddata, 0)) + goto clean; + rtn = vector_str_get_flat(&ddata.output, (size_t *) NULL); + goto clean; + } + if (org_len > 11 && !strncmp(org, "_GLOBAL__I_", 11)) { + if ((rtn = malloc(org_len + 19)) == NULL) + return (NULL); + snprintf(rtn, org_len + 19, + "global constructors keyed to %s", org + 11); + return (rtn); + } + + + if (!cpp_demangle_data_init(&ddata, org + 2)) + return (NULL); + + if (!cpp_demangle_read_encoding(&ddata)) + goto clean; + + limit = 0; + while (*ddata.cur != '\0') { + /* + * Breaking at some gcc info at tail. e.g) @@GLIBCXX_3.4 + */ + if (*ddata.cur == '@' && *(ddata.cur + 1) == '@') + break; + if (!cpp_demangle_read_type(&ddata, 1)) + goto clean; + if (limit++ > CPP_DEMANGLE_TRY_LIMIT) + goto clean; + } + + if (ddata.output.size == 0) + goto clean; + if (ddata.paren && !vector_str_push(&ddata.output, ")", 1)) + goto clean; + if (ddata.mem_vat && !vector_str_push(&ddata.output, " volatile", 9)) + goto clean; + if (ddata.mem_cst && !vector_str_push(&ddata.output, " const", 6)) + goto clean; + if (ddata.mem_rst && !vector_str_push(&ddata.output, " restrict", 9)) + goto clean; + + rtn = vector_str_get_flat(&ddata.output, (size_t *) NULL); + +clean: + cpp_demangle_data_dest(&ddata); + + return (rtn); +} + +char * +__cxa_demangle(const char*org) __attribute__((weak, alias("__cxa_demangle_gnu3"))); + +static void +cpp_demangle_data_dest(struct cpp_demangle_data *d) +{ + + if (d == NULL) + return; + + vector_read_cmd_dest(&d->cmd); + vector_str_dest(&d->class_type); + vector_str_dest(&d->tmpl); + vector_str_dest(&d->subst); + vector_str_dest(&d->output_tmp); + vector_str_dest(&d->output); +} + +static int +cpp_demangle_data_init(struct cpp_demangle_data *d, const char *cur) +{ + + if (d == NULL || cur == NULL) + return (0); + + if (!vector_str_init(&d->output)) + return (0); + if (!vector_str_init(&d->output_tmp)) + goto clean1; + if (!vector_str_init(&d->subst)) + goto clean2; + if (!vector_str_init(&d->tmpl)) + goto clean3; + if (!vector_str_init(&d->class_type)) + goto clean4; + if (!vector_read_cmd_init(&d->cmd)) + goto clean5; + + assert(d->output.container != NULL); + assert(d->output_tmp.container != NULL); + assert(d->subst.container != NULL); + assert(d->tmpl.container != NULL); + assert(d->class_type.container != NULL); + + d->paren = false; + d->pfirst = false; + d->mem_rst = false; + d->mem_vat = false; + d->mem_cst = false; + d->func_type = 0; + d->cur = cur; + d->last_sname = NULL; + d->push_head = 0; + + return (1); + +clean5: + vector_str_dest(&d->class_type); +clean4: + vector_str_dest(&d->tmpl); +clean3: + vector_str_dest(&d->subst); +clean2: + vector_str_dest(&d->output_tmp); +clean1: + vector_str_dest(&d->output); + + return (0); +} + +static int +cpp_demangle_push_fp(struct cpp_demangle_data *ddata, + char *(*decoder)(const char *, size_t)) +{ + size_t len; + int rtn; + const char *fp; + char *f; + + if (ddata == NULL || decoder == NULL) + return (0); + + fp = ddata->cur; + while (*ddata->cur != 'E') + ++ddata->cur; + ++ddata->cur; + + if ((f = decoder(fp, ddata->cur - fp)) == NULL) + return (0); + + rtn = 0; + if ((len = strlen(f)) > 0 && + cpp_demangle_push_str(ddata, f, len)) + rtn = 1; + + free(f); + + return (rtn); +} + +static int +cpp_demangle_push_str(struct cpp_demangle_data *ddata, const char *str, + size_t len) +{ + + if (ddata == NULL || str == NULL || len == 0) + return (0); + + if (ddata->push_head > 0) + return (vector_str_push(&ddata->output_tmp, str, len)); + + return (vector_str_push(&ddata->output, str, len)); +} + +static int +cpp_demangle_push_subst(struct cpp_demangle_data *ddata, const char *str, + size_t len) +{ + + if (ddata == NULL || str == NULL || len == 0) + return (0); + + if (!vector_str_find(&ddata->subst, str, len)) + return (vector_str_push(&ddata->subst, str, len)); + + return (1); +} + +static int +cpp_demangle_push_subst_v(struct cpp_demangle_data *ddata, struct vector_str *v) +{ + size_t str_len; + int rtn; + char *str; + + if (ddata == NULL || v == NULL) + return (0); + + if ((str = vector_str_get_flat(v, &str_len)) == NULL) + return (0); + + rtn = cpp_demangle_push_subst(ddata, str, str_len); + free(str); + + return (rtn); +} + +static int +cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata, + struct vector_type_qualifier *v, const char *type_str) +{ + struct vector_str subst_v; + size_t idx, e_idx, e_len; + int rtn; + char *buf; + + if (ddata == NULL || v == NULL) + return (0); + + if ((idx = v->size) == 0) + return (1); + + rtn = 0; + if (type_str != NULL) { + if (!vector_str_init(&subst_v)) + return (0); + if (!vector_str_push(&subst_v, type_str, strlen(type_str))) + goto clean; + } + + e_idx = 0; + while (idx > 0) { + switch (v->q_container[idx - 1]) { + case TYPE_PTR: + if (!cpp_demangle_push_str(ddata, "*", 1)) + goto clean; + if (type_str != NULL) { + if (!vector_str_push(&subst_v, "*", 1)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) + goto clean; + } + break; + + case TYPE_REF: + if (!cpp_demangle_push_str(ddata, "&", 1)) + goto clean; + if (type_str != NULL) { + if (!vector_str_push(&subst_v, "&", 1)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) + goto clean; + } + break; + + case TYPE_CMX: + if (!cpp_demangle_push_str(ddata, " complex", 8)) + goto clean; + if (type_str != NULL) { + if (!vector_str_push(&subst_v, " complex", 8)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) + goto clean; + } + break; + + case TYPE_IMG: + if (!cpp_demangle_push_str(ddata, " imaginary", 10)) + goto clean; + if (type_str != NULL) { + if (!vector_str_push(&subst_v, " imaginary", 10)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) + goto clean; + } + break; + + case TYPE_EXT: + if (e_idx > v->ext_name.size - 1) + goto clean; + if ((e_len = strlen(v->ext_name.container[e_idx])) == 0) + goto clean; + if ((buf = malloc(sizeof(char) * (e_len + 1))) == NULL) + goto clean; + + memcpy(buf, " ", 1); + memcpy(buf + 1, v->ext_name.container[e_idx], e_len); + + if (!cpp_demangle_push_str(ddata, buf, e_len + 1)) { + free(buf); + goto clean; + } + + if (type_str != NULL) { + if (!vector_str_push(&subst_v, buf, + e_len + 1)) { + free(buf); + goto clean; + } + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) { + free(buf); + goto clean; + } + } + free(buf); + ++e_idx; + break; + + case TYPE_RST: + if (!cpp_demangle_push_str(ddata, " restrict", 9)) + goto clean; + if (type_str != NULL) { + if (!vector_str_push(&subst_v, " restrict", 9)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) + goto clean; + } + break; + + case TYPE_VAT: + if (!cpp_demangle_push_str(ddata, " volatile", 9)) + goto clean; + if (type_str != NULL) { + if (!vector_str_push(&subst_v, " volatile", 9)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) + goto clean; + } + break; + + case TYPE_CST: + if (!cpp_demangle_push_str(ddata, " const", 6)) + goto clean; + if (type_str != NULL) { + if (!vector_str_push(&subst_v, " const", 6)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &subst_v)) + goto clean; + } + break; + + }; + --idx; + } + + rtn = 1; +clean: + if (type_str != NULL) + vector_str_dest(&subst_v); + + return (rtn); +} + +static int +cpp_demangle_get_subst(struct cpp_demangle_data *ddata, size_t idx) +{ + size_t len; + + if (ddata == NULL || ddata->subst.size <= idx) + return (0); + if ((len = strlen(ddata->subst.container[idx])) == 0) + return (0); + if (!cpp_demangle_push_str(ddata, ddata->subst.container[idx], len)) + return (0); + + /* skip '_' */ + ++ddata->cur; + + return (1); +} + +static int +cpp_demangle_get_tmpl_param(struct cpp_demangle_data *ddata, size_t idx) +{ + size_t len; + + if (ddata == NULL || ddata->tmpl.size <= idx) + return (0); + if ((len = strlen(ddata->tmpl.container[idx])) == 0) + return (0); + if (!cpp_demangle_push_str(ddata, ddata->tmpl.container[idx], len)) + return (0); + + ++ddata->cur; + + return (1); +} + +static int +cpp_demangle_read_array(struct cpp_demangle_data *ddata) +{ + size_t i, num_len, exp_len, p_idx, idx; + const char *num; + char *exp; + + if (ddata == NULL || *(++ddata->cur) == '\0') + return (0); + + if (*ddata->cur == '_') { + if (*(++ddata->cur) == '\0') + return (0); + + if (!cpp_demangle_read_type(ddata, 0)) + return (0); + + if (!cpp_demangle_push_str(ddata, "[]", 2)) + return (0); + } else { + if (ELFTC_ISDIGIT(*ddata->cur) != 0) { + num = ddata->cur; + while (ELFTC_ISDIGIT(*ddata->cur) != 0) + ++ddata->cur; + if (*ddata->cur != '_') + return (0); + num_len = ddata->cur - num; + assert(num_len > 0); + if (*(++ddata->cur) == '\0') + return (0); + if (!cpp_demangle_read_type(ddata, 0)) + return (0); + if (!cpp_demangle_push_str(ddata, "[", 1)) + return (0); + if (!cpp_demangle_push_str(ddata, num, num_len)) + return (0); + if (!cpp_demangle_push_str(ddata, "]", 1)) + return (0); + } else { + p_idx = ddata->output.size; + if (!cpp_demangle_read_expression(ddata)) + return (0); + if ((exp = vector_str_substr(&ddata->output, p_idx, + ddata->output.size - 1, &exp_len)) == NULL) + return (0); + idx = ddata->output.size; + for (i = p_idx; i < idx; ++i) + if (!vector_str_pop(&ddata->output)) { + free(exp); + return (0); + } + if (*ddata->cur != '_') { + free(exp); + return (0); + } + ++ddata->cur; + if (*ddata->cur == '\0') { + free(exp); + return (0); + } + if (!cpp_demangle_read_type(ddata, 0)) { + free(exp); + return (0); + } + if (!cpp_demangle_push_str(ddata, "[", 1)) { + free(exp); + return (0); + } + if (!cpp_demangle_push_str(ddata, exp, exp_len)) { + free(exp); + return (0); + } + if (!cpp_demangle_push_str(ddata, "]", 1)) { + free(exp); + return (0); + } + free(exp); + } + } + + return (1); +} + +static int +cpp_demangle_read_expr_primary(struct cpp_demangle_data *ddata) +{ + const char *num; + + if (ddata == NULL || *(++ddata->cur) == '\0') + return (0); + + if (*ddata->cur == '_' && *(ddata->cur + 1) == 'Z') { + ddata->cur += 2; + if (*ddata->cur == '\0') + return (0); + if (!cpp_demangle_read_encoding(ddata)) + return (0); + ++ddata->cur; + return (1); + } + + switch (*ddata->cur) { + case 'b': + switch (*(++ddata->cur)) { + case '0': + return (cpp_demangle_push_str(ddata, "false", 5)); + case '1': + return (cpp_demangle_push_str(ddata, "true", 4)); + default: + return (0); + }; + + case 'd': + ++ddata->cur; + return (cpp_demangle_push_fp(ddata, decode_fp_to_double)); + + case 'e': + ++ddata->cur; + if (sizeof(long double) == 10) + return (cpp_demangle_push_fp(ddata, + decode_fp_to_double)); + return (cpp_demangle_push_fp(ddata, decode_fp_to_float80)); + + case 'f': + ++ddata->cur; + return (cpp_demangle_push_fp(ddata, decode_fp_to_float)); + + case 'g': + ++ddata->cur; + if (sizeof(long double) == 16) + return (cpp_demangle_push_fp(ddata, + decode_fp_to_double)); + return (cpp_demangle_push_fp(ddata, decode_fp_to_float128)); + + case 'i': + case 'j': + case 'l': + case 'm': + case 'n': + case 's': + case 't': + case 'x': + case 'y': + if (*(++ddata->cur) == 'n') { + if (!cpp_demangle_push_str(ddata, "-", 1)) + return (0); + ++ddata->cur; + } + num = ddata->cur; + while (*ddata->cur != 'E') { + if (!ELFTC_ISDIGIT(*ddata->cur)) + return (0); + ++ddata->cur; + } + ++ddata->cur; + return (cpp_demangle_push_str(ddata, num, ddata->cur - num)); + + default: + return (0); + }; +} + +static int +cpp_demangle_read_expression(struct cpp_demangle_data *ddata) +{ + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { + case SIMPLE_HASH('s', 't'): + ddata->cur += 2; + return (cpp_demangle_read_type(ddata, 0)); + + case SIMPLE_HASH('s', 'r'): + ddata->cur += 2; + if (!cpp_demangle_read_type(ddata, 0)) + return (0); + if (!cpp_demangle_read_uqname(ddata)) + return (0); + if (*ddata->cur == 'I') + return (cpp_demangle_read_tmpl_args(ddata)); + return (1); + + case SIMPLE_HASH('a', 'a'): + /* operator && */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "&&", 2)); + + case SIMPLE_HASH('a', 'd'): + /* operator & (unary) */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "&", 1)); + + case SIMPLE_HASH('a', 'n'): + /* operator & */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "&", 1)); + + case SIMPLE_HASH('a', 'N'): + /* operator &= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "&=", 2)); + + case SIMPLE_HASH('a', 'S'): + /* operator = */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "=", 1)); + + case SIMPLE_HASH('c', 'l'): + /* operator () */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "()", 2)); + + case SIMPLE_HASH('c', 'm'): + /* operator , */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, ",", 1)); + + case SIMPLE_HASH('c', 'o'): + /* operator ~ */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "~", 1)); + + case SIMPLE_HASH('c', 'v'): + /* operator (cast) */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "(cast)", 6)); + + case SIMPLE_HASH('d', 'a'): + /* operator delete [] */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "delete []", 9)); + + case SIMPLE_HASH('d', 'e'): + /* operator * (unary) */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "*", 1)); + + case SIMPLE_HASH('d', 'l'): + /* operator delete */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "delete", 6)); + + case SIMPLE_HASH('d', 'v'): + /* operator / */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "/", 1)); + + case SIMPLE_HASH('d', 'V'): + /* operator /= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "/=", 2)); + + case SIMPLE_HASH('e', 'o'): + /* operator ^ */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "^", 1)); + + case SIMPLE_HASH('e', 'O'): + /* operator ^= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "^=", 2)); + + case SIMPLE_HASH('e', 'q'): + /* operator == */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "==", 2)); + + case SIMPLE_HASH('g', 'e'): + /* operator >= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, ">=", 2)); + + case SIMPLE_HASH('g', 't'): + /* operator > */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, ">", 1)); + + case SIMPLE_HASH('i', 'x'): + /* operator [] */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "[]", 2)); + + case SIMPLE_HASH('l', 'e'): + /* operator <= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "<=", 2)); + + case SIMPLE_HASH('l', 's'): + /* operator << */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "<<", 2)); + + case SIMPLE_HASH('l', 'S'): + /* operator <<= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "<<=", 3)); + + case SIMPLE_HASH('l', 't'): + /* operator < */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "<", 1)); + + case SIMPLE_HASH('m', 'i'): + /* operator - */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "-", 1)); + + case SIMPLE_HASH('m', 'I'): + /* operator -= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "-=", 2)); + + case SIMPLE_HASH('m', 'l'): + /* operator * */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "*", 1)); + + case SIMPLE_HASH('m', 'L'): + /* operator *= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "*=", 2)); + + case SIMPLE_HASH('m', 'm'): + /* operator -- */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "--", 2)); + + case SIMPLE_HASH('n', 'a'): + /* operator new[] */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "new []", 6)); + + case SIMPLE_HASH('n', 'e'): + /* operator != */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "!=", 2)); + + case SIMPLE_HASH('n', 'g'): + /* operator - (unary) */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "-", 1)); + + case SIMPLE_HASH('n', 't'): + /* operator ! */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "!", 1)); + + case SIMPLE_HASH('n', 'w'): + /* operator new */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "new", 3)); + + case SIMPLE_HASH('o', 'o'): + /* operator || */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "||", 2)); + + case SIMPLE_HASH('o', 'r'): + /* operator | */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "|", 1)); + + case SIMPLE_HASH('o', 'R'): + /* operator |= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "|=", 2)); + + case SIMPLE_HASH('p', 'l'): + /* operator + */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "+", 1)); + + case SIMPLE_HASH('p', 'L'): + /* operator += */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "+=", 2)); + + case SIMPLE_HASH('p', 'm'): + /* operator ->* */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "->*", 3)); + + case SIMPLE_HASH('p', 'p'): + /* operator ++ */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "++", 2)); + + case SIMPLE_HASH('p', 's'): + /* operator + (unary) */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "+", 1)); + + case SIMPLE_HASH('p', 't'): + /* operator -> */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "->", 2)); + + case SIMPLE_HASH('q', 'u'): + /* operator ? */ + ddata->cur += 2; + return (cpp_demangle_read_expression_trinary(ddata, "?", 1, + ":", 1)); + + case SIMPLE_HASH('r', 'm'): + /* operator % */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "%", 1)); + + case SIMPLE_HASH('r', 'M'): + /* operator %= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, "%=", 2)); + + case SIMPLE_HASH('r', 's'): + /* operator >> */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, ">>", 2)); + + case SIMPLE_HASH('r', 'S'): + /* operator >>= */ + ddata->cur += 2; + return (cpp_demangle_read_expression_binary(ddata, ">>=", 3)); + + case SIMPLE_HASH('r', 'z'): + /* operator sizeof */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "sizeof", 6)); + + case SIMPLE_HASH('s', 'v'): + /* operator sizeof */ + ddata->cur += 2; + return (cpp_demangle_read_expression_unary(ddata, "sizeof", 6)); + }; + + switch (*ddata->cur) { + case 'L': + return (cpp_demangle_read_expr_primary(ddata)); + case 'T': + return (cpp_demangle_read_tmpl_param(ddata)); + }; + + return (0); +} + +static int +cpp_demangle_read_expression_binary(struct cpp_demangle_data *ddata, + const char *name, size_t len) +{ + + if (ddata == NULL || name == NULL || len == 0) + return (0); + if (!cpp_demangle_read_expression(ddata)) + return (0); + if (!cpp_demangle_push_str(ddata, name, len)) + return (0); + + return (cpp_demangle_read_expression(ddata)); +} + +static int +cpp_demangle_read_expression_unary(struct cpp_demangle_data *ddata, + const char *name, size_t len) +{ + + if (ddata == NULL || name == NULL || len == 0) + return (0); + if (!cpp_demangle_read_expression(ddata)) + return (0); + + return (cpp_demangle_push_str(ddata, name, len)); +} + +static int +cpp_demangle_read_expression_trinary(struct cpp_demangle_data *ddata, + const char *name1, size_t len1, const char *name2, size_t len2) +{ + + if (ddata == NULL || name1 == NULL || len1 == 0 || name2 == NULL || + len2 == 0) + return (0); + + if (!cpp_demangle_read_expression(ddata)) + return (0); + if (!cpp_demangle_push_str(ddata, name1, len1)) + return (0); + if (!cpp_demangle_read_expression(ddata)) + return (0); + if (!cpp_demangle_push_str(ddata, name2, len2)) + return (0); + + return (cpp_demangle_read_expression(ddata)); +} + +static int +cpp_demangle_read_function(struct cpp_demangle_data *ddata, int *ext_c, + struct vector_type_qualifier *v) +{ + size_t class_type_size, class_type_len, limit; + const char *class_type; + + if (ddata == NULL || *ddata->cur != 'F' || v == NULL) + return (0); + + ++ddata->cur; + if (*ddata->cur == 'Y') { + if (ext_c != NULL) + *ext_c = 1; + ++ddata->cur; + } + if (!cpp_demangle_read_type(ddata, 0)) + return (0); + if (*ddata->cur != 'E') { + if (!cpp_demangle_push_str(ddata, "(", 1)) + return (0); + if (vector_read_cmd_find(&ddata->cmd, READ_PTRMEM)) { + if ((class_type_size = ddata->class_type.size) == 0) + return (0); + class_type = + ddata->class_type.container[class_type_size - 1]; + if (class_type == NULL) + return (0); + if ((class_type_len = strlen(class_type)) == 0) + return (0); + if (!cpp_demangle_push_str(ddata, class_type, + class_type_len)) + return (0); + if (!cpp_demangle_push_str(ddata, "::*", 3)) + return (0); + ++ddata->func_type; + } else { + if (!cpp_demangle_push_type_qualifier(ddata, v, + (const char *) NULL)) + return (0); + vector_type_qualifier_dest(v); + if (!vector_type_qualifier_init(v)) + return (0); + } + + if (!cpp_demangle_push_str(ddata, ")(", 2)) + return (0); + + limit = 0; + for (;;) { + if (!cpp_demangle_read_type(ddata, 0)) + return (0); + if (*ddata->cur == 'E') + break; + if (limit++ > CPP_DEMANGLE_TRY_LIMIT) + return (0); + } + + if (vector_read_cmd_find(&ddata->cmd, READ_PTRMEM) == 1) { + if (!cpp_demangle_push_type_qualifier(ddata, v, + (const char *) NULL)) + return (0); + vector_type_qualifier_dest(v); + if (!vector_type_qualifier_init(v)) + return (0); + } + + if (!cpp_demangle_push_str(ddata, ")", 1)) + return (0); + } + + ++ddata->cur; + + return (1); +} + +/* read encoding, encoding are function name, data name, special-name */ +static int +cpp_demangle_read_encoding(struct cpp_demangle_data *ddata) +{ + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + /* special name */ + switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { + case SIMPLE_HASH('G', 'V'): + /* sentry object for 1 time init */ + if (!cpp_demangle_push_str(ddata, "guard variable for ", 20)) + return (0); + ddata->cur += 2; + break; + + case SIMPLE_HASH('T', 'c'): + /* virtual function covariant override thunk */ + if (!cpp_demangle_push_str(ddata, + "virtual function covariant override ", 36)) + return (0); + ddata->cur += 2; + if (*ddata->cur == '\0') + return (0); + if (!cpp_demangle_read_offset(ddata)) + return (0); + if (!cpp_demangle_read_offset(ddata)) + return (0); + return (cpp_demangle_read_encoding(ddata)); + + case SIMPLE_HASH('T', 'D'): + /* typeinfo common proxy */ + break; + + case SIMPLE_HASH('T', 'h'): + /* virtual function non-virtual override thunk */ + if (cpp_demangle_push_str(ddata, + "virtual function non-virtual override ", 38) == 0) + return (0); + ddata->cur += 2; + if (*ddata->cur == '\0') + return (0); + if (!cpp_demangle_read_nv_offset(ddata)) + return (0); + return (cpp_demangle_read_encoding(ddata)); + + case SIMPLE_HASH('T', 'I'): + /* typeinfo structure */ + /* FALLTHROUGH */ + case SIMPLE_HASH('T', 'S'): + /* RTTI name (NTBS) */ + if (!cpp_demangle_push_str(ddata, "typeinfo for ", 14)) + return (0); + ddata->cur += 2; + if (*ddata->cur == '\0') + return (0); + return (cpp_demangle_read_type(ddata, 1)); + + case SIMPLE_HASH('T', 'T'): + /* VTT table */ + if (!cpp_demangle_push_str(ddata, "VTT for ", 8)) + return (0); + ddata->cur += 2; + return (cpp_demangle_read_type(ddata, 1)); + + case SIMPLE_HASH('T', 'v'): + /* virtual function virtual override thunk */ + if (!cpp_demangle_push_str(ddata, + "virtual function virtual override ", 34)) + return (0); + ddata->cur += 2; + if (*ddata->cur == '\0') + return (0); + if (!cpp_demangle_read_v_offset(ddata)) + return (0); + return (cpp_demangle_read_encoding(ddata)); + + case SIMPLE_HASH('T', 'V'): + /* virtual table */ + if (!cpp_demangle_push_str(ddata, "vtable for ", 12)) + return (0); + ddata->cur += 2; + if (*ddata->cur == '\0') + return (0); + return (cpp_demangle_read_type(ddata, 1)); + }; + + return (cpp_demangle_read_name(ddata)); +} + +static int +cpp_demangle_read_local_name(struct cpp_demangle_data *ddata) +{ + size_t limit; + + if (ddata == NULL) + return (0); + if (*(++ddata->cur) == '\0') + return (0); + if (!cpp_demangle_read_encoding(ddata)) + return (0); + + limit = 0; + for (;;) { + if (!cpp_demangle_read_type(ddata, 1)) + return (0); + if (*ddata->cur == 'E') + break; + if (limit++ > CPP_DEMANGLE_TRY_LIMIT) + return (0); + } + if (*(++ddata->cur) == '\0') + return (0); + if (ddata->paren == true) { + if (!cpp_demangle_push_str(ddata, ")", 1)) + return (0); + ddata->paren = false; + } + if (*ddata->cur == 's') + ++ddata->cur; + else { + if (!cpp_demangle_push_str(ddata, "::", 2)) + return (0); + if (!cpp_demangle_read_name(ddata)) + return (0); + } + if (*ddata->cur == '_') { + ++ddata->cur; + while (ELFTC_ISDIGIT(*ddata->cur) != 0) + ++ddata->cur; + } + + return (1); +} + +static int +cpp_demangle_read_name(struct cpp_demangle_data *ddata) +{ + struct vector_str *output, v; + size_t p_idx, subst_str_len; + int rtn; + char *subst_str; + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output; + + subst_str = NULL; + + switch (*ddata->cur) { + case 'S': + return (cpp_demangle_read_subst(ddata)); + case 'N': + return (cpp_demangle_read_nested_name(ddata)); + case 'Z': + return (cpp_demangle_read_local_name(ddata)); + }; + + if (!vector_str_init(&v)) + return (0); + + p_idx = output->size; + rtn = 0; + if (!cpp_demangle_read_uqname(ddata)) + goto clean; + if ((subst_str = vector_str_substr(output, p_idx, output->size - 1, + &subst_str_len)) == NULL) + goto clean; + if (subst_str_len > 8 && strstr(subst_str, "operator") != NULL) { + rtn = 1; + goto clean; + } + if (!vector_str_push(&v, subst_str, subst_str_len)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &v)) + goto clean; + + if (*ddata->cur == 'I') { + p_idx = output->size; + if (!cpp_demangle_read_tmpl_args(ddata)) + goto clean; + free(subst_str); + if ((subst_str = vector_str_substr(output, p_idx, + output->size - 1, &subst_str_len)) == NULL) + goto clean; + if (!vector_str_push(&v, subst_str, subst_str_len)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &v)) + goto clean; + } + + rtn = 1; + +clean: + if (subst_str) free(subst_str); + vector_str_dest(&v); + + return (rtn); +} + +static int +cpp_demangle_read_nested_name(struct cpp_demangle_data *ddata) +{ + struct vector_str *output, v; + size_t limit, p_idx, subst_str_len; + int rtn; + char *subst_str; + + if (ddata == NULL || *ddata->cur != 'N') + return (0); + if (*(++ddata->cur) == '\0') + return (0); + + while (*ddata->cur == 'r' || *ddata->cur == 'V' || + *ddata->cur == 'K') { + switch (*ddata->cur) { + case 'r': + ddata->mem_rst = true; + break; + case 'V': + ddata->mem_vat = true; + break; + case 'K': + ddata->mem_cst = true; + break; + }; + ++ddata->cur; + } + + output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output; + if (!vector_str_init(&v)) + return (0); + + rtn = 0; + limit = 0; + for (;;) { + p_idx = output->size; + switch (*ddata->cur) { + case 'I': + if (!cpp_demangle_read_tmpl_args(ddata)) + goto clean; + break; + case 'S': + if (!cpp_demangle_read_subst(ddata)) + goto clean; + break; + case 'T': + if (!cpp_demangle_read_tmpl_param(ddata)) + goto clean; + break; + default: + if (!cpp_demangle_read_uqname(ddata)) + goto clean; + }; + + if ((subst_str = vector_str_substr(output, p_idx, + output->size - 1, &subst_str_len)) == NULL) + goto clean; + if (!vector_str_push(&v, subst_str, subst_str_len)) { + free(subst_str); + goto clean; + } + free(subst_str); + + if (!cpp_demangle_push_subst_v(ddata, &v)) + goto clean; + if (*ddata->cur == 'E') + break; + else if (*ddata->cur != 'I' && + *ddata->cur != 'C' && *ddata->cur != 'D') { + if (!cpp_demangle_push_str(ddata, "::", 2)) + goto clean; + if (!vector_str_push(&v, "::", 2)) + goto clean; + } + if (limit++ > CPP_DEMANGLE_TRY_LIMIT) + goto clean; + } + + ++ddata->cur; + rtn = 1; + +clean: + vector_str_dest(&v); + + return (rtn); +} + +/* + * read number + * number ::= [n] + */ +static int +cpp_demangle_read_number(struct cpp_demangle_data *ddata, long *rtn) +{ + long len, negative_factor; + + if (ddata == NULL || rtn == NULL) + return (0); + + negative_factor = 1; + if (*ddata->cur == 'n') { + negative_factor = -1; + + ++ddata->cur; + } + if (ELFTC_ISDIGIT(*ddata->cur) == 0) + return (0); + + errno = 0; + if ((len = strtol(ddata->cur, (char **) NULL, 10)) == 0 && + errno != 0) + return (0); + + while (ELFTC_ISDIGIT(*ddata->cur) != 0) + ++ddata->cur; + + assert(len >= 0); + assert(negative_factor == 1 || negative_factor == -1); + + *rtn = len * negative_factor; + + return (1); +} + +static int +cpp_demangle_read_nv_offset(struct cpp_demangle_data *ddata) +{ + + if (ddata == NULL) + return (0); + + if (!cpp_demangle_push_str(ddata, "offset : ", 9)) + return (0); + + return (cpp_demangle_read_offset_number(ddata)); +} + +/* read offset, offset are nv-offset, v-offset */ +static int +cpp_demangle_read_offset(struct cpp_demangle_data *ddata) +{ + + if (ddata == NULL) + return (0); + + if (*ddata->cur == 'h') { + ++ddata->cur; + return (cpp_demangle_read_nv_offset(ddata)); + } else if (*ddata->cur == 'v') { + ++ddata->cur; + return (cpp_demangle_read_v_offset(ddata)); + } + + return (0); +} + +static int +cpp_demangle_read_offset_number(struct cpp_demangle_data *ddata) +{ + bool negative; + const char *start; + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + /* offset could be negative */ + if (*ddata->cur == 'n') { + negative = true; + start = ddata->cur + 1; + } else { + negative = false; + start = ddata->cur; + } + + while (*ddata->cur != '_') + ++ddata->cur; + + if (negative && !cpp_demangle_push_str(ddata, "-", 1)) + return (0); + + assert(start != NULL); + + if (!cpp_demangle_push_str(ddata, start, ddata->cur - start)) + return (0); + if (!cpp_demangle_push_str(ddata, " ", 1)) + return (0); + + ++ddata->cur; + + return (1); +} + +static int +cpp_demangle_read_pointer_to_member(struct cpp_demangle_data *ddata) +{ + size_t class_type_len, i, idx, p_idx; + int p_func_type, rtn; + char *class_type; + + if (ddata == NULL || *ddata->cur != 'M' || *(++ddata->cur) == '\0') + return (0); + + p_idx = ddata->output.size; + if (!cpp_demangle_read_type(ddata, 0)) + return (0); + + if ((class_type = vector_str_substr(&ddata->output, p_idx, + ddata->output.size - 1, &class_type_len)) == NULL) + return (0); + + rtn = 0; + idx = ddata->output.size; + for (i = p_idx; i < idx; ++i) + if (!vector_str_pop(&ddata->output)) + goto clean1; + + if (!vector_read_cmd_push(&ddata->cmd, READ_PTRMEM)) + goto clean1; + + if (!vector_str_push(&ddata->class_type, class_type, class_type_len)) + goto clean2; + + p_func_type = ddata->func_type; + if (!cpp_demangle_read_type(ddata, 0)) + goto clean3; + + if (p_func_type == ddata->func_type) { + if (!cpp_demangle_push_str(ddata, " ", 1)) + goto clean3; + if (!cpp_demangle_push_str(ddata, class_type, class_type_len)) + goto clean3; + if (!cpp_demangle_push_str(ddata, "::*", 3)) + goto clean3; + } + + rtn = 1; +clean3: + if (!vector_str_pop(&ddata->class_type)) + rtn = 0; +clean2: + if (!vector_read_cmd_pop(&ddata->cmd)) + rtn = 0; +clean1: + free(class_type); + + return (rtn); +} + +/* read source-name, source-name is */ +static int +cpp_demangle_read_sname(struct cpp_demangle_data *ddata) +{ + long len; + + if (ddata == NULL || cpp_demangle_read_number(ddata, &len) == 0 || + len <= 0 || cpp_demangle_push_str(ddata, ddata->cur, len) == 0) + return (0); + + assert(ddata->output.size > 0); + if (vector_read_cmd_find(&ddata->cmd, READ_TMPL) == 0) + ddata->last_sname = + ddata->output.container[ddata->output.size - 1]; + + ddata->cur += len; + + return (1); +} + +static int +cpp_demangle_read_subst(struct cpp_demangle_data *ddata) +{ + long nth; + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + /* abbreviations of the form Sx */ + switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { + case SIMPLE_HASH('S', 'a'): + /* std::allocator */ + if (cpp_demangle_push_str(ddata, "std::allocator", 14) == 0) + return (0); + ddata->cur += 2; + if (*ddata->cur == 'I') + return (cpp_demangle_read_subst_stdtmpl(ddata, + "std::allocator", 14)); + return (1); + + case SIMPLE_HASH('S', 'b'): + /* std::basic_string */ + if (!cpp_demangle_push_str(ddata, "std::basic_string", 17)) + return (0); + ddata->cur += 2; + if (*ddata->cur == 'I') + return (cpp_demangle_read_subst_stdtmpl(ddata, + "std::basic_string", 17)); + return (1); + + case SIMPLE_HASH('S', 'd'): + /* std::basic_iostream > */ + if (!cpp_demangle_push_str(ddata, "std::iostream", 19)) + return (0); + ddata->last_sname = "iostream"; + ddata->cur += 2; + if (*ddata->cur == 'I') + return (cpp_demangle_read_subst_stdtmpl(ddata, + "std::iostream", 19)); + return (1); + + case SIMPLE_HASH('S', 'i'): + /* std::basic_istream > */ + if (!cpp_demangle_push_str(ddata, "std::istream", 18)) + return (0); + ddata->last_sname = "istream"; + ddata->cur += 2; + if (*ddata->cur == 'I') + return (cpp_demangle_read_subst_stdtmpl(ddata, + "std::istream", 18)); + return (1); + + case SIMPLE_HASH('S', 'o'): + /* std::basic_ostream > */ + if (!cpp_demangle_push_str(ddata, "std::ostream", 18)) + return (0); + ddata->last_sname = "istream"; + ddata->cur += 2; + if (*ddata->cur == 'I') + return (cpp_demangle_read_subst_stdtmpl(ddata, + "std::ostream", 18)); + return (1); + + case SIMPLE_HASH('S', 's'): + /* + * std::basic_string, + * std::allocator > + * + * a.k.a std::string + */ + if (!cpp_demangle_push_str(ddata, "std::string", 11)) + return (0); + ddata->last_sname = "string"; + ddata->cur += 2; + if (*ddata->cur == 'I') + return (cpp_demangle_read_subst_stdtmpl(ddata, + "std::string", 11)); + return (1); + + case SIMPLE_HASH('S', 't'): + /* std:: */ + return (cpp_demangle_read_subst_std(ddata)); + }; + + if (*(++ddata->cur) == '\0') + return (0); + + /* substitution */ + if (*ddata->cur == '_') + return (cpp_demangle_get_subst(ddata, 0)); + else { + errno = 0; + /* substitution number is base 36 */ + if ((nth = strtol(ddata->cur, (char **) NULL, 36)) == 0 && + errno != 0) + return (0); + + /* first was '_', so increase one */ + ++nth; + + while (*ddata->cur != '_') + ++ddata->cur; + + assert(nth > 0); + + return (cpp_demangle_get_subst(ddata, nth)); + } + + /* NOTREACHED */ + return (0); +} + +static int +cpp_demangle_read_subst_std(struct cpp_demangle_data *ddata) +{ + struct vector_str *output, v; + size_t p_idx, subst_str_len; + int rtn; + char *subst_str; + + if (ddata == NULL) + return (0); + + if (!vector_str_init(&v)) + return (0); + + subst_str = NULL; + rtn = 0; + if (!cpp_demangle_push_str(ddata, "std::", 5)) + goto clean; + + if (!vector_str_push(&v, "std::", 5)) + goto clean; + + ddata->cur += 2; + + output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output; + + p_idx = output->size; + if (!cpp_demangle_read_uqname(ddata)) + goto clean; + + if ((subst_str = vector_str_substr(output, p_idx, output->size - 1, + &subst_str_len)) == NULL) + goto clean; + + if (!vector_str_push(&v, subst_str, subst_str_len)) + goto clean; + + if (!cpp_demangle_push_subst_v(ddata, &v)) + goto clean; + + if (*ddata->cur == 'I') { + p_idx = output->size; + if (!cpp_demangle_read_tmpl_args(ddata)) + goto clean; + free(subst_str); + if ((subst_str = vector_str_substr(output, p_idx, + output->size - 1, &subst_str_len)) == NULL) + goto clean; + if (!vector_str_push(&v, subst_str, subst_str_len)) + goto clean; + if (!cpp_demangle_push_subst_v(ddata, &v)) + goto clean; + } + + rtn = 1; +clean: + if (subst_str) free(subst_str); + vector_str_dest(&v); + + return (rtn); +} + +static int +cpp_demangle_read_subst_stdtmpl(struct cpp_demangle_data *ddata, + const char *str, size_t len) +{ + struct vector_str *output; + size_t p_idx, substr_len; + int rtn; + char *subst_str, *substr; + + if (ddata == NULL || str == NULL || len == 0) + return (0); + + output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output; + + p_idx = output->size; + substr = NULL; + subst_str = NULL; + + if (!cpp_demangle_read_tmpl_args(ddata)) + return (0); + if ((substr = vector_str_substr(output, p_idx, output->size - 1, + &substr_len)) == NULL) + return (0); + + rtn = 0; + if ((subst_str = malloc(sizeof(char) * (substr_len + len + 1))) == + NULL) + goto clean; + + memcpy(subst_str, str, len); + memcpy(subst_str + len, substr, substr_len); + subst_str[substr_len + len] = '\0'; + + if (!cpp_demangle_push_subst(ddata, subst_str, substr_len + len)) + goto clean; + + rtn = 1; +clean: + if (subst_str) free(subst_str); + free(substr); + + return (rtn); +} + +static int +cpp_demangle_read_tmpl_arg(struct cpp_demangle_data *ddata) +{ + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + switch (*ddata->cur) { + case 'L': + return (cpp_demangle_read_expr_primary(ddata)); + case 'X': + return (cpp_demangle_read_expression(ddata)); + }; + + return (cpp_demangle_read_type(ddata, 0)); +} + +static int +cpp_demangle_read_tmpl_args(struct cpp_demangle_data *ddata) +{ + struct vector_str *v; + size_t arg_len, idx, limit, size; + char *arg; + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + ++ddata->cur; + + if (!vector_read_cmd_push(&ddata->cmd, READ_TMPL)) + return (0); + + if (!cpp_demangle_push_str(ddata, "<", 1)) + return (0); + + limit = 0; + v = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output; + for (;;) { + idx = v->size; + if (!cpp_demangle_read_tmpl_arg(ddata)) + return (0); + if ((arg = vector_str_substr(v, idx, v->size - 1, &arg_len)) == + NULL) + return (0); + if (!vector_str_find(&ddata->tmpl, arg, arg_len) && + !vector_str_push(&ddata->tmpl, arg, arg_len)) { + free(arg); + return (0); + } + + free(arg); + + if (*ddata->cur == 'E') { + ++ddata->cur; + size = v->size; + assert(size > 0); + if (!strncmp(v->container[size - 1], ">", 1)) { + if (!cpp_demangle_push_str(ddata, " >", 2)) + return (0); + } else if (!cpp_demangle_push_str(ddata, ">", 1)) + return (0); + break; + } else if (*ddata->cur != 'I' && + !cpp_demangle_push_str(ddata, ", ", 2)) + return (0); + + if (limit++ > CPP_DEMANGLE_TRY_LIMIT) + return (0); + } + + return (vector_read_cmd_pop(&ddata->cmd)); +} + +/* + * Read template parameter that forms in 'T[number]_'. + * This function much like to read_subst but only for types. + */ +static int +cpp_demangle_read_tmpl_param(struct cpp_demangle_data *ddata) +{ + long nth; + + if (ddata == NULL || *ddata->cur != 'T') + return (0); + + ++ddata->cur; + + if (*ddata->cur == '_') + return (cpp_demangle_get_tmpl_param(ddata, 0)); + else { + + errno = 0; + if ((nth = strtol(ddata->cur, (char **) NULL, 36)) == 0 && + errno != 0) + return (0); + + /* T_ is first */ + ++nth; + + while (*ddata->cur != '_') + ++ddata->cur; + + assert(nth > 0); + + return (cpp_demangle_get_tmpl_param(ddata, nth)); + } + + /* NOTREACHED */ + return (0); +} + +static int +cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit) +{ + struct vector_type_qualifier v; + struct vector_str *output; + size_t p_idx, type_str_len; + int extern_c, is_builtin; + long len; + char *type_str; + + if (ddata == NULL) + return (0); + + output = &ddata->output; + if (ddata->output.size > 0 && !strncmp(ddata->output.container[ddata->output.size - 1], ">", 1)) { + ddata->push_head++; + output = &ddata->output_tmp; + } else if (delimit == 1) { + if (ddata->paren == false) { + if (!cpp_demangle_push_str(ddata, "(", 1)) + return (0); + if (ddata->output.size < 2) + return (0); + ddata->paren = true; + ddata->pfirst = true; + /* Need pop function name */ + if (ddata->subst.size == 1 && + !vector_str_pop(&ddata->subst)) + return (0); + } + + if (ddata->pfirst) + ddata->pfirst = false; + else if (*ddata->cur != 'I' && + !cpp_demangle_push_str(ddata, ", ", 2)) + return (0); + } + + assert(output != NULL); + /* + * [r, V, K] [P, R, C, G, U] builtin, function, class-enum, array + * pointer-to-member, template-param, template-template-param, subst + */ + + if (!vector_type_qualifier_init(&v)) + return (0); + + extern_c = 0; + is_builtin = 1; + p_idx = output->size; + type_str = NULL; +again: + /* builtin type */ + switch (*ddata->cur) { + case 'a': + /* signed char */ + if (!cpp_demangle_push_str(ddata, "signed char", 11)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'A': + /* array type */ + if (!cpp_demangle_read_array(ddata)) + goto clean; + is_builtin = 0; + goto rtn; + + case 'b': + /* bool */ + if (!cpp_demangle_push_str(ddata, "bool", 4)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'C': + /* complex pair */ + if (!vector_type_qualifier_push(&v, TYPE_CMX)) + goto clean; + ++ddata->cur; + goto again; + + case 'c': + /* char */ + if (!cpp_demangle_push_str(ddata, "char", 4)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'd': + /* double */ + if (!cpp_demangle_push_str(ddata, "double", 6)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'e': + /* long double */ + if (!cpp_demangle_push_str(ddata, "long double", 11)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'f': + /* float */ + if (!cpp_demangle_push_str(ddata, "float", 5)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'F': + /* function */ + if (!cpp_demangle_read_function(ddata, &extern_c, &v)) + goto clean; + is_builtin = 0; + goto rtn; + + case 'g': + /* __float128 */ + if (!cpp_demangle_push_str(ddata, "__float128", 10)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'G': + /* imaginary */ + if (!vector_type_qualifier_push(&v, TYPE_IMG)) + goto clean; + ++ddata->cur; + goto again; + + case 'h': + /* unsigned char */ + if (!cpp_demangle_push_str(ddata, "unsigned char", 13)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'i': + /* int */ + if (!cpp_demangle_push_str(ddata, "int", 3)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'j': + /* unsigned int */ + if (!cpp_demangle_push_str(ddata, "unsigned int", 12)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'K': + /* const */ + if (!vector_type_qualifier_push(&v, TYPE_CST)) + goto clean; + ++ddata->cur; + goto again; + + case 'l': + /* long */ + if (!cpp_demangle_push_str(ddata, "long", 4)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'm': + /* unsigned long */ + if (!cpp_demangle_push_str(ddata, "unsigned long", 13)) + goto clean; + + ++ddata->cur; + + goto rtn; + case 'M': + /* pointer to member */ + if (!cpp_demangle_read_pointer_to_member(ddata)) + goto clean; + is_builtin = 0; + goto rtn; + + case 'n': + /* __int128 */ + if (!cpp_demangle_push_str(ddata, "__int128", 8)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'o': + /* unsigned __int128 */ + if (!cpp_demangle_push_str(ddata, "unsigned _;int128", 17)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'P': + /* pointer */ + if (!vector_type_qualifier_push(&v, TYPE_PTR)) + goto clean; + ++ddata->cur; + goto again; + + case 'r': + /* restrict */ + if (!vector_type_qualifier_push(&v, TYPE_RST)) + goto clean; + ++ddata->cur; + goto again; + + case 'R': + /* reference */ + if (!vector_type_qualifier_push(&v, TYPE_REF)) + goto clean; + ++ddata->cur; + goto again; + + case 's': + /* short, local string */ + if (!cpp_demangle_push_str(ddata, "short", 5)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'S': + /* substitution */ + if (!cpp_demangle_read_subst(ddata)) + goto clean; + is_builtin = 0; + goto rtn; + + case 't': + /* unsigned short */ + if (!cpp_demangle_push_str(ddata, "unsigned short", 14)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'T': + /* template parameter */ + if (!cpp_demangle_read_tmpl_param(ddata)) + goto clean; + is_builtin = 0; + goto rtn; + + case 'u': + /* vendor extended builtin */ + ++ddata->cur; + if (!cpp_demangle_read_sname(ddata)) + goto clean; + is_builtin = 0; + goto rtn; + + case 'U': + /* vendor extended type qualifier */ + if (!cpp_demangle_read_number(ddata, &len)) + goto clean; + if (len <= 0) + goto clean; + if (!vector_str_push(&v.ext_name, ddata->cur, len)) + goto clean; + ddata->cur += len; + goto again; + + case 'v': + /* void */ + if (!cpp_demangle_push_str(ddata, "void", 4)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'V': + /* volatile */ + if (!vector_type_qualifier_push(&v, TYPE_VAT)) + goto clean; + ++ddata->cur; + goto again; + + case 'w': + /* wchar_t */ + if (!cpp_demangle_push_str(ddata, "wchar_t", 6)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'x': + /* long long */ + if (!cpp_demangle_push_str(ddata, "long long", 9)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'y': + /* unsigned long long */ + if (!cpp_demangle_push_str(ddata, "unsigned long long", 18)) + goto clean; + ++ddata->cur; + goto rtn; + + case 'z': + /* ellipsis */ + if (!cpp_demangle_push_str(ddata, "ellipsis", 8)) + goto clean; + ++ddata->cur; + goto rtn; + }; + + if (!cpp_demangle_read_name(ddata)) + goto clean; + + is_builtin = 0; +rtn: + if ((type_str = vector_str_substr(output, p_idx, output->size - 1, + &type_str_len)) == NULL) + goto clean; + + if (is_builtin == 0) { + if (!vector_str_find(&ddata->subst, type_str, type_str_len) && + !vector_str_push(&ddata->subst, type_str, type_str_len)) + goto clean; + } + + if (!cpp_demangle_push_type_qualifier(ddata, &v, type_str)) + goto clean; + + free(type_str); + vector_type_qualifier_dest(&v); + + if (ddata->push_head > 0) { + if (*ddata->cur == 'I' && cpp_demangle_read_tmpl_args(ddata) + == 0) + return (0); + + if (--ddata->push_head > 0) + return (1); + + if (!vector_str_push(&ddata->output_tmp, " ", 1)) + return (0); + + if (!vector_str_push_vector_head(&ddata->output, + &ddata->output_tmp)) + return (0); + + vector_str_dest(&ddata->output_tmp); + if (!vector_str_init(&ddata->output_tmp)) + return (0); + + if (!cpp_demangle_push_str(ddata, "(", 1)) + return (0); + + ddata->paren = true; + ddata->pfirst = true; + } + + return (1); +clean: + if (type_str) free(type_str); + vector_type_qualifier_dest(&v); + + return (0); +} + +/* + * read unqualified-name, unqualified name are operator-name, ctor-dtor-name, + * source-name + */ +static int +cpp_demangle_read_uqname(struct cpp_demangle_data *ddata) +{ + size_t len; + + if (ddata == NULL || *ddata->cur == '\0') + return (0); + + /* operator name */ + switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { + case SIMPLE_HASH('a', 'a'): + /* operator && */ + if (!cpp_demangle_push_str(ddata, "operator&&", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('a', 'd'): + /* operator & (unary) */ + if (!cpp_demangle_push_str(ddata, "operator&", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('a', 'n'): + /* operator & */ + if (!cpp_demangle_push_str(ddata, "operator&", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('a', 'N'): + /* operator &= */ + if (!cpp_demangle_push_str(ddata, "operator&=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('a', 'S'): + /* operator = */ + if (!cpp_demangle_push_str(ddata, "operator=", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('c', 'l'): + /* operator () */ + if (!cpp_demangle_push_str(ddata, "operator()", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('c', 'm'): + /* operator , */ + if (!cpp_demangle_push_str(ddata, "operator,", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('c', 'o'): + /* operator ~ */ + if (!cpp_demangle_push_str(ddata, "operator~", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('c', 'v'): + /* operator (cast) */ + if (!cpp_demangle_push_str(ddata, "operator(cast)", 14)) + return (0); + ddata->cur += 2; + return (cpp_demangle_read_type(ddata, 1)); + + case SIMPLE_HASH('d', 'a'): + /* operator delete [] */ + if (!cpp_demangle_push_str(ddata, "operator delete []", 18)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('d', 'e'): + /* operator * (unary) */ + if (!cpp_demangle_push_str(ddata, "operator*", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('d', 'l'): + /* operator delete */ + if (!cpp_demangle_push_str(ddata, "operator delete", 15)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('d', 'v'): + /* operator / */ + if (!cpp_demangle_push_str(ddata, "operator/", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('d', 'V'): + /* operator /= */ + if (!cpp_demangle_push_str(ddata, "operator/=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('e', 'o'): + /* operator ^ */ + if (!cpp_demangle_push_str(ddata, "operator^", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('e', 'O'): + /* operator ^= */ + if (!cpp_demangle_push_str(ddata, "operator^=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('e', 'q'): + /* operator == */ + if (!cpp_demangle_push_str(ddata, "operator==", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('g', 'e'): + /* operator >= */ + if (!cpp_demangle_push_str(ddata, "operator>=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('g', 't'): + /* operator > */ + if (!cpp_demangle_push_str(ddata, "operator>", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('i', 'x'): + /* operator [] */ + if (!cpp_demangle_push_str(ddata, "operator[]", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('l', 'e'): + /* operator <= */ + if (!cpp_demangle_push_str(ddata, "operator<=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('l', 's'): + /* operator << */ + if (!cpp_demangle_push_str(ddata, "operator<<", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('l', 'S'): + /* operator <<= */ + if (!cpp_demangle_push_str(ddata, "operator<<=", 11)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('l', 't'): + /* operator < */ + if (!cpp_demangle_push_str(ddata, "operator<", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('m', 'i'): + /* operator - */ + if (!cpp_demangle_push_str(ddata, "operator-", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('m', 'I'): + /* operator -= */ + if (!cpp_demangle_push_str(ddata, "operator-=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('m', 'l'): + /* operator * */ + if (!cpp_demangle_push_str(ddata, "operator*", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('m', 'L'): + /* operator *= */ + if (!cpp_demangle_push_str(ddata, "operator*=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('m', 'm'): + /* operator -- */ + if (!cpp_demangle_push_str(ddata, "operator--", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('n', 'a'): + /* operator new[] */ + if (!cpp_demangle_push_str(ddata, "operator new []", 15)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('n', 'e'): + /* operator != */ + if (!cpp_demangle_push_str(ddata, "operator!=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('n', 'g'): + /* operator - (unary) */ + if (!cpp_demangle_push_str(ddata, "operator-", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('n', 't'): + /* operator ! */ + if (!cpp_demangle_push_str(ddata, "operator!", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('n', 'w'): + /* operator new */ + if (!cpp_demangle_push_str(ddata, "operator new", 12)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('o', 'o'): + /* operator || */ + if (!cpp_demangle_push_str(ddata, "operator||", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('o', 'r'): + /* operator | */ + if (!cpp_demangle_push_str(ddata, "operator|", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('o', 'R'): + /* operator |= */ + if (!cpp_demangle_push_str(ddata, "operator|=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('p', 'l'): + /* operator + */ + if (!cpp_demangle_push_str(ddata, "operator+", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('p', 'L'): + /* operator += */ + if (!cpp_demangle_push_str(ddata, "operator+=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('p', 'm'): + /* operator ->* */ + if (!cpp_demangle_push_str(ddata, "operator->*", 11)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('p', 'p'): + /* operator ++ */ + if (!cpp_demangle_push_str(ddata, "operator++", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('p', 's'): + /* operator + (unary) */ + if (!cpp_demangle_push_str(ddata, "operator+", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('p', 't'): + /* operator -> */ + if (!cpp_demangle_push_str(ddata, "operator->", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('q', 'u'): + /* operator ? */ + if (!cpp_demangle_push_str(ddata, "operator?", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('r', 'm'): + /* operator % */ + if (!cpp_demangle_push_str(ddata, "operator%", 9)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('r', 'M'): + /* operator %= */ + if (!cpp_demangle_push_str(ddata, "operator%=", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('r', 's'): + /* operator >> */ + if (!cpp_demangle_push_str(ddata, "operator>>", 10)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('r', 'S'): + /* operator >>= */ + if (!cpp_demangle_push_str(ddata, "operator>>=", 11)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('r', 'z'): + /* operator sizeof */ + if (!cpp_demangle_push_str(ddata, "operator sizeof ", 16)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('s', 'r'): + /* scope resolution operator */ + if (!cpp_demangle_push_str(ddata, "scope resolution operator ", + 26)) + return (0); + ddata->cur += 2; + return (1); + + case SIMPLE_HASH('s', 'v'): + /* operator sizeof */ + if (!cpp_demangle_push_str(ddata, "operator sizeof ", 16)) + return (0); + ddata->cur += 2; + return (1); + }; + + /* vendor extened operator */ + if (*ddata->cur == 'v' && ELFTC_ISDIGIT(*(ddata->cur + 1))) { + if (!cpp_demangle_push_str(ddata, "vendor extened operator ", + 24)) + return (0); + if (!cpp_demangle_push_str(ddata, ddata->cur + 1, 1)) + return (0); + ddata->cur += 2; + return (cpp_demangle_read_sname(ddata)); + } + + /* ctor-dtor-name */ + switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) { + case SIMPLE_HASH('C', '1'): + /* FALLTHROUGH */ + case SIMPLE_HASH('C', '2'): + /* FALLTHROUGH */ + case SIMPLE_HASH('C', '3'): + if (ddata->last_sname == NULL) + return (0); + if ((len = strlen(ddata->last_sname)) == 0) + return (0); + if (!cpp_demangle_push_str(ddata, "::", 2)) + return (0); + if (!cpp_demangle_push_str(ddata, ddata->last_sname, len)) + return (0); + ddata->cur +=2; + return (1); + + case SIMPLE_HASH('D', '0'): + /* FALLTHROUGH */ + case SIMPLE_HASH('D', '1'): + /* FALLTHROUGH */ + case SIMPLE_HASH('D', '2'): + if (ddata->last_sname == NULL) + return (0); + if ((len = strlen(ddata->last_sname)) == 0) + return (0); + if (!cpp_demangle_push_str(ddata, "::~", 3)) + return (0); + if (!cpp_demangle_push_str(ddata, ddata->last_sname, len)) + return (0); + ddata->cur +=2; + return (1); + }; + + /* source name */ + if (ELFTC_ISDIGIT(*ddata->cur) != 0) + return (cpp_demangle_read_sname(ddata)); + + return (1); +} + +static int +cpp_demangle_read_v_offset(struct cpp_demangle_data *ddata) +{ + + if (ddata == NULL) + return (0); + + if (!cpp_demangle_push_str(ddata, "offset : ", 9)) + return (0); + + if (!cpp_demangle_read_offset_number(ddata)) + return (0); + + if (!cpp_demangle_push_str(ddata, "virtual offset : ", 17)) + return (0); + + return (!cpp_demangle_read_offset_number(ddata)); +} + +/* + * Decode floating point representation to string + * Return new allocated string or NULL + * + * Todo + * Replace these functions to macro. + */ +static char * +decode_fp_to_double(const char *p, size_t len) +{ + double f; + size_t rtn_len, limit, i; + int byte; + char *rtn; + + if (p == NULL || len == 0 || len % 2 != 0 || len / 2 > sizeof(double)) + return (NULL); + + memset(&f, 0, sizeof(double)); + + for (i = 0; i < len / 2; ++i) { + byte = hex_to_dec(p[len - i * 2 - 1]) + + hex_to_dec(p[len - i * 2 - 2]) * 16; + + if (byte < 0 || byte > 255) + return (NULL); + +#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN + ((unsigned char *)&f)[i] = (unsigned char)(byte); +#else /* ELFTC_BYTE_ORDER != ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + ((unsigned char *)&f)[sizeof(double) - i - 1] = + (unsigned char)(byte); +#endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + } + + rtn_len = 64; + limit = 0; +again: + if ((rtn = malloc(sizeof(char) * rtn_len)) == NULL) + return (NULL); + + if (snprintf(rtn, rtn_len, "%fld", f) >= (int)rtn_len) { + free(rtn); + if (limit++ > FLOAT_SPRINTF_TRY_LIMIT) + return (NULL); + rtn_len *= BUFFER_GROWFACTOR; + goto again; + } + + return rtn; +} + +static char * +decode_fp_to_float(const char *p, size_t len) +{ + size_t i, rtn_len, limit; + float f; + int byte; + char *rtn; + + if (p == NULL || len == 0 || len % 2 != 0 || len / 2 > sizeof(float)) + return (NULL); + + memset(&f, 0, sizeof(float)); + + for (i = 0; i < len / 2; ++i) { + byte = hex_to_dec(p[len - i * 2 - 1]) + + hex_to_dec(p[len - i * 2 - 2]) * 16; + if (byte < 0 || byte > 255) + return (NULL); +#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN + ((unsigned char *)&f)[i] = (unsigned char)(byte); +#else /* ELFTC_BYTE_ORDER != ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + ((unsigned char *)&f)[sizeof(float) - i - 1] = + (unsigned char)(byte); +#endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + } + + rtn_len = 64; + limit = 0; +again: + if ((rtn = malloc(sizeof(char) * rtn_len)) == NULL) + return (NULL); + + if (snprintf(rtn, rtn_len, "%ff", f) >= (int)rtn_len) { + free(rtn); + if (limit++ > FLOAT_SPRINTF_TRY_LIMIT) + return (NULL); + rtn_len *= BUFFER_GROWFACTOR; + goto again; + } + + return rtn; +} + +static char * +decode_fp_to_float128(const char *p, size_t len) +{ + long double f; + size_t rtn_len, limit, i; + int byte; + unsigned char buf[FLOAT_QUADRUPLE_BYTES]; + char *rtn; + + switch(sizeof(long double)) { + case FLOAT_QUADRUPLE_BYTES: + return (decode_fp_to_long_double(p, len)); + case FLOAT_EXTENED_BYTES: + if (p == NULL || len == 0 || len % 2 != 0 || + len / 2 > FLOAT_QUADRUPLE_BYTES) + return (NULL); + + memset(buf, 0, FLOAT_QUADRUPLE_BYTES); + + for (i = 0; i < len / 2; ++i) { + byte = hex_to_dec(p[len - i * 2 - 1]) + + hex_to_dec(p[len - i * 2 - 2]) * 16; + if (byte < 0 || byte > 255) + return (NULL); +#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN + buf[i] = (unsigned char)(byte); +#else /* ELFTC_BYTE_ORDER != ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + buf[FLOAT_QUADRUPLE_BYTES - i -1] = + (unsigned char)(byte); +#endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + } + memset(&f, 0, FLOAT_EXTENED_BYTES); + +#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN + memcpy(&f, buf, FLOAT_EXTENED_BYTES); +#else /* ELFTC_BYTE_ORDER != ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + memcpy(&f, buf + 6, FLOAT_EXTENED_BYTES); +#endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + + rtn_len = 256; + limit = 0; +again: + if ((rtn = malloc(sizeof(char) * rtn_len)) == NULL) + return (NULL); + + if (snprintf(rtn, rtn_len, "%Lfd", f) >= (int)rtn_len) { + free(rtn); + if (limit++ > FLOAT_SPRINTF_TRY_LIMIT) + return (NULL); + rtn_len *= BUFFER_GROWFACTOR; + goto again; + } + + return (rtn); + default: + return (NULL); + } +} + +static char * +decode_fp_to_float80(const char *p, size_t len) +{ + long double f; + size_t rtn_len, limit, i; + int byte; + unsigned char buf[FLOAT_EXTENED_BYTES]; + char *rtn; + + switch(sizeof(long double)) { + case FLOAT_QUADRUPLE_BYTES: + if (p == NULL || len == 0 || len % 2 != 0 || + len / 2 > FLOAT_EXTENED_BYTES) + return (NULL); + + memset(buf, 0, FLOAT_EXTENED_BYTES); + + for (i = 0; i < len / 2; ++i) { + byte = hex_to_dec(p[len - i * 2 - 1]) + + hex_to_dec(p[len - i * 2 - 2]) * 16; + + if (byte < 0 || byte > 255) + return (NULL); + +#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN + buf[i] = (unsigned char)(byte); +#else /* ELFTC_BYTE_ORDER != ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + buf[FLOAT_EXTENED_BYTES - i -1] = + (unsigned char)(byte); +#endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + } + + memset(&f, 0, FLOAT_QUADRUPLE_BYTES); + +#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN + memcpy(&f, buf, FLOAT_EXTENED_BYTES); +#else /* ELFTC_BYTE_ORDER != ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + memcpy((unsigned char *)(&f) + 6, buf, FLOAT_EXTENED_BYTES); +#endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + + rtn_len = 256; + limit = 0; +again: + if ((rtn = malloc(sizeof(char) * rtn_len)) == NULL) + return (NULL); + + if (snprintf(rtn, rtn_len, "%Lfd", f) >= (int)rtn_len) { + free(rtn); + if (limit++ > FLOAT_SPRINTF_TRY_LIMIT) + return (NULL); + rtn_len *= BUFFER_GROWFACTOR; + goto again; + } + + return (rtn); + case FLOAT_EXTENED_BYTES: + return (decode_fp_to_long_double(p, len)); + default: + return (NULL); + } +} + +static char * +decode_fp_to_long_double(const char *p, size_t len) +{ + long double f; + size_t rtn_len, limit, i; + int byte; + char *rtn; + + if (p == NULL || len == 0 || len % 2 != 0 || + len / 2 > sizeof(long double)) + return (NULL); + + memset(&f, 0, sizeof(long double)); + + for (i = 0; i < len / 2; ++i) { + byte = hex_to_dec(p[len - i * 2 - 1]) + + hex_to_dec(p[len - i * 2 - 2]) * 16; + + if (byte < 0 || byte > 255) + return (NULL); + +#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN + ((unsigned char *)&f)[i] = (unsigned char)(byte); +#else /* ELFTC_BYTE_ORDER != ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + ((unsigned char *)&f)[sizeof(long double) - i - 1] = + (unsigned char)(byte); +#endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */ + } + + rtn_len = 256; + limit = 0; +again: + if ((rtn = malloc(sizeof(char) * rtn_len)) == NULL) + return (NULL); + + if (snprintf(rtn, rtn_len, "%Lfd", f) >= (int)rtn_len) { + free(rtn); + if (limit++ > FLOAT_SPRINTF_TRY_LIMIT) + return (NULL); + rtn_len *= BUFFER_GROWFACTOR; + goto again; + } + + return (rtn); +} + +/* Simple hex to integer function used by decode_to_* function. */ +static int +hex_to_dec(char c) +{ + + switch (c) { + case '0': + return (0); + case '1': + return (1); + case '2': + return (2); + case '3': + return (3); + case '4': + return (4); + case '5': + return (5); + case '6': + return (6); + case '7': + return (7); + case '8': + return (8); + case '9': + return (9); + case 'a': + return (10); + case 'b': + return (11); + case 'c': + return (12); + case 'd': + return (13); + case 'e': + return (14); + case 'f': + return (15); + default: + return (-1); + }; +} + +static void +vector_read_cmd_dest(struct vector_read_cmd *v) +{ + + if (v == NULL) + return; + + free(v->r_container); +} + +/* return -1 at failed, 0 at not found, 1 at found. */ +static int +vector_read_cmd_find(struct vector_read_cmd *v, enum read_cmd dst) +{ + size_t i; + + if (v == NULL || dst == READ_FAIL) + return (-1); + + for (i = 0; i < v->size; ++i) + if (v->r_container[i] == dst) + return (1); + + return (0); +} + +static int +vector_read_cmd_init(struct vector_read_cmd *v) +{ + + if (v == NULL) + return (0); + + v->size = 0; + v->capacity = VECTOR_DEF_CAPACITY; + + if ((v->r_container = malloc(sizeof(enum read_cmd) * v->capacity)) + == NULL) + return (0); + + return (1); +} + +static int +vector_read_cmd_pop(struct vector_read_cmd *v) +{ + + if (v == NULL || v->size == 0) + return (0); + + --v->size; + v->r_container[v->size] = READ_FAIL; + + return (1); +} + +static int +vector_read_cmd_push(struct vector_read_cmd *v, enum read_cmd cmd) +{ + enum read_cmd *tmp_r_ctn; + size_t tmp_cap; + size_t i; + + if (v == NULL) + return (0); + + if (v->size == v->capacity) { + tmp_cap = v->capacity * BUFFER_GROWFACTOR; + if ((tmp_r_ctn = malloc(sizeof(enum read_cmd) * tmp_cap)) + == NULL) + return (0); + for (i = 0; i < v->size; ++i) + tmp_r_ctn[i] = v->r_container[i]; + free(v->r_container); + v->r_container = tmp_r_ctn; + v->capacity = tmp_cap; + } + + v->r_container[v->size] = cmd; + ++v->size; + + return (1); +} + +static void +vector_type_qualifier_dest(struct vector_type_qualifier *v) +{ + + if (v == NULL) + return; + + free(v->q_container); + vector_str_dest(&v->ext_name); +} + +/* size, capacity, ext_name */ +static int +vector_type_qualifier_init(struct vector_type_qualifier *v) +{ + + if (v == NULL) + return (0); + + v->size = 0; + v->capacity = VECTOR_DEF_CAPACITY; + + if ((v->q_container = malloc(sizeof(enum type_qualifier) * v->capacity)) + == NULL) + return (0); + + assert(v->q_container != NULL); + + if (vector_str_init(&v->ext_name) == false) { + free(v->q_container); + return (0); + } + + return (1); +} + +static int +vector_type_qualifier_push(struct vector_type_qualifier *v, + enum type_qualifier t) +{ + enum type_qualifier *tmp_ctn; + size_t tmp_cap; + size_t i; + + if (v == NULL) + return (0); + + if (v->size == v->capacity) { + tmp_cap = v->capacity * BUFFER_GROWFACTOR; + if ((tmp_ctn = malloc(sizeof(enum type_qualifier) * tmp_cap)) + == NULL) + return (0); + for (i = 0; i < v->size; ++i) + tmp_ctn[i] = v->q_container[i]; + free(v->q_container); + v->q_container = tmp_ctn; + v->capacity = tmp_cap; + } + + v->q_container[v->size] = t; + ++v->size; + + return (1); +} diff --git a/sdk/cpprt/linux/libunwind/AUTHORS b/sdk/cpprt/linux/libunwind/AUTHORS new file mode 100644 index 0000000000..719eee5c85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/AUTHORS @@ -0,0 +1 @@ +David Mosberger diff --git a/sdk/cpprt/linux/libunwind/COPYING b/sdk/cpprt/linux/libunwind/COPYING new file mode 100644 index 0000000000..41e7d8a6fd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/COPYING @@ -0,0 +1,20 @@ +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/sdk/cpprt/linux/libunwind/ChangeLog b/sdk/cpprt/linux/libunwind/ChangeLog new file mode 100644 index 0000000000..dfa24b957c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/ChangeLog @@ -0,0 +1,55 @@ +*********************************************************** + + 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/sdk/cpprt/linux/libunwind/LICENSE b/sdk/cpprt/linux/libunwind/LICENSE new file mode 100644 index 0000000000..c9b44cb8aa --- /dev/null +++ b/sdk/cpprt/linux/libunwind/LICENSE @@ -0,0 +1,18 @@ +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +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/sdk/cpprt/linux/libunwind/Makefile.am b/sdk/cpprt/linux/libunwind/Makefile.am new file mode 100644 index 0000000000..12f514ffdc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/Makefile.am @@ -0,0 +1,75 @@ +include_HEADERS = include/libunwind-dynamic.h \ + include/libunwind-ptrace.h \ + include/libunwind-coredump.h + +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_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 !REMOTE_ONLY +include_HEADERS += include/libunwind.h include/unwind.h +endif + +nodist_include_HEADERS = include/libunwind-common.h + +SUBDIRS = src + +noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \ + include/libunwind_i.h include/mempool.h \ + include/remote.h \ + include/tdep-arm/dwarf-config.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-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/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/sdk/cpprt/linux/libunwind/NEWS b/sdk/cpprt/linux/libunwind/NEWS new file mode 100644 index 0000000000..2cf7184d2b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/NEWS @@ -0,0 +1,221 @@ +-*-Mode: outline-*- + +* 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/sdk/cpprt/linux/libunwind/README b/sdk/cpprt/linux/libunwind/README new file mode 100644 index 0000000000..9f03a1830c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/README @@ -0,0 +1,212 @@ +-*- mode: Outline -*- + +This is version 1.0 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: Fully tested and supported. + Linux/PARISC: Works well, but C library missing unwind-info. + HP-UX/IA-64: Mostly works but known to have some serious limitations. + Linux/PPC64: Newly added. + FreeBSD/i386: Newly added. + FreeBSD/x86-64: Newly added (FreeBSD architecture is known as amd64). + + +* General Build Instructions + +In general, this library can be built and installed with the following +commands: + + $ autoreconf -i # 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: + + Gtest-resume-sig (fails to get SIGUSR2) + Ltest-resume-sig (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 (no _Ux86_getcontext yet) + test-ptrace + +** Expected results on x86-64 Linux + +The following tests are expected to fail on x86-64 Linux: + + Gtest-dyn1 (no dynamic unwind info support yet) + Ltest-dyn1 (no dynamic unwind info support yet) + Gtest-init (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18743) + Ltest-init (likewise) + test-async-sig (crashes due to bad unwind-info?) + test-setjmp (longjmp() not implemented yet) + run-check-namespace (no _Ux86_64_getcontext yet) + run-ptrace-mapper (??? investigate) + 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 diff --git a/sdk/cpprt/linux/libunwind/TODO b/sdk/cpprt/linux/libunwind/TODO new file mode 100644 index 0000000000..8b2e0262b0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/TODO @@ -0,0 +1,97 @@ +- 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/sdk/cpprt/linux/libunwind/acinclude.m4 b/sdk/cpprt/linux/libunwind/acinclude.m4 new file mode 100644 index 0000000000..497f7c2f21 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/acinclude.m4 @@ -0,0 +1,32 @@ +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/sdk/cpprt/linux/libunwind/autogen-linux.sh b/sdk/cpprt/linux/libunwind/autogen-linux.sh new file mode 100755 index 0000000000..b1bbdc1a9c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/autogen-linux.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +set -x + +srcdir=`dirname $0` +[ -z "$srcdir" ] && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +autoreconf -v --install || exit $? +cd $ORIGDIR || exit $? + +CFLAGS="$CFLAGS -std=c99 -fno-builtin -DHAVE_SGX=1 -fPIC -DUNW_LOCAL_ONLY" + +# Remove duplicated compiler options and filter out `-nostdinc' +CFLAGS=`echo $CFLAGS | tr ' ' '\n' | sort | uniq | grep -v nostdinc | tr '\n' ' '` + +HOST_OPT= +if echo $CFLAGS | grep -q -- '-m32'; then + HOST_OPT='--host=i386-linux-gnu' +fi + +# Workaround for icc +# +# If we are running icc on Debian-like system, add +# /usr/include/$(dpkg-architecture -qDEB_BUILD_MULTIARCH) +# to the header search path. +if [ -f /usr/bin/dpkg ]; then + if [ x$CC != x"" ]; then + if $CC -E -dM -xc /dev/null | grep -q __INTEL_COMPILER; then + INCVAR=$(dpkg-architecture -qDEB_BUILD_MULTIARCH) + CFLAGS="$CFLAGS -I/usr/include/$INCVAR" + fi + fi +fi + +export CFLAGS +$srcdir/configure $HOST_OPT --enable-shared=no \ + --disable-block-signals \ + --enable-debug=no \ + --enable-debug-frame=no \ + --enable-cxx-exceptions \ + "$@" diff --git a/sdk/cpprt/linux/libunwind/configure.in b/sdk/cpprt/linux/libunwind/configure.in new file mode 100644 index 0000000000..c25deb1f5f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/configure.in @@ -0,0 +1,308 @@ +define(pkg_major, 1) +define(pkg_minor, 0) +define(pkg_extra, ) +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_SYSTEM +AM_INIT_AUTOMAKE([1.6 subdir-objects]) +AM_MAINTAINER_MODE +AM_CONFIG_HEADER(include/config.h) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AM_PROG_LIBTOOL +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) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIGNAL +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([sighandler_t], [], [], +[$ac_includes_default +#if HAVE_SIGNAL_H +# include +#endif +]) +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_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_FUNC_MEMCMP +AC_TYPE_SIGNAL +AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \ + ttrace mincore) +is_gcc_m64() { + if test `echo $CFLAGS | grep "\-m64" -c` -eq 1 ; then echo ppc64; + else + if test `echo $CC | grep "\-m64" -c` -eq 1 ; then echo ppc64; else echo ppc32; fi; + fi; +} + +is_gcc_altivec() { + if test `echo $CFLAGS | grep "\-maltivec" -c` -eq 1 ; then echo has_altivec; + else + if test `echo $CC | grep "\-maltivec" -c` -eq 1 ; then echo has_altivec; else echo no_altivec; fi; + fi; +} + +AC_MSG_CHECKING([if building with AltiVec]) +use_altivec=`is_gcc_altivec` +AM_CONDITIONAL(USE_ALTIVEC, test x$use_altivec = xhas_altivec) +if test x$use_altivec = xhas_altivec; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +get_arch() { + case "$1" in + arm*) echo arm;; + i?86) echo x86;; + hppa*) echo hppa;; + mips*) echo mips;; + powerpc*) is_gcc_m64;; + amd64) echo x86_64;; + *) echo $1;; + esac +} + +build_arch=`get_arch $build_cpu` +host_arch=`get_arch $host_cpu` +target_arch=`get_arch $target_cpu` + +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(REMOTE_ONLY, test x$target_arch != x$host_arch) +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(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) + +AC_MSG_CHECKING([for ELF helper width]) +case "${target_arch}" in +(arm|hppa|ppc32|x86) use_elf32=yes; AC_MSG_RESULT([32]);; +(ia64|ppc64|x86_64) 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, +[ --enable-debug turn on debug support (slows down execution)], +[enable_debug=$enableval], [enable_debug=no]) +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, +[ --enable-cxx-exceptions use libunwind to handle C++ exceptions], +[enable_cxx_exceptions=$enableval], +[ +# C++ exception handling doesn't work too well on x86 +case $target_arch in + x86*) enable_cxx_exceptions=no;; + arm*) enable_cxx_exceptions=no;; + mips*) 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, +[ --enable-debug-frame Load the ".debug_frame" section if available], +[enable_debug_frame=$enableval], [ +case "${target_arch}" in + (arm) 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, +[ --enable-block-signals Block signals before performing mutex operations], +[enable_block_signals=$enableval], [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, +[ --enable-conservative-checks Validate all memory addresses before use], +[enable_conservative_checks=$enableval], [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, +[ --enable-msabi-support Enables support for Microsoft ABI extensions ], +[enable_msabi_support=$enableval], [enable_msabi_support=no]) +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]) + +LIBUNWIND___THREAD + +AC_MSG_CHECKING([for Intel compiler]) +AC_TRY_COMPILE([], [#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" + LIBCRTS="-lgcc" +fi +AC_MSG_RESULT([$intel_compiler]) + +if test x$intel_compiler = xyes; then + AC_MSG_CHECKING([if linker supports -static-libcxa]) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -static-libcxa" + AC_TRY_LINK([], [], [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 + +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) +AM_CONDITIONAL(HAVE_BACKTRACE, test "x$ac_cv_search_backtrace" != xno) +BACKTRACELIB="$LIBS" +LIBS="$old_LIBS" + +AC_SUBST(build_arch) +AC_SUBST(target_os) +AC_SUBST(arch) +AC_SUBST(ARCH) +AC_SUBST(LDFLAGS_STATIC_LIBCXA) +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_CONFIG_FILES(Makefile src/Makefile + include/libunwind-common.h + include/libunwind.h include/tdep/libunwind_i.h) +AC_OUTPUT diff --git a/sdk/cpprt/linux/libunwind/doc/Makefile.am b/sdk/cpprt/linux/libunwind/doc/Makefile.am new file mode 100644 index 0000000000..4730f9b7f8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/Makefile.am @@ -0,0 +1,71 @@ +# man pages that go into section 3: +man3_MANS = libunwind.man libunwind-dynamic.man libunwind-ia64.man \ + libunwind-ptrace.man libunwind-setjmp.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_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_set_caching_policy.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_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_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/sdk/cpprt/linux/libunwind/doc/NOTES b/sdk/cpprt/linux/libunwind/doc/NOTES new file mode 100644 index 0000000000..3f3caa95bb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/NOTES @@ -0,0 +1,127 @@ +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/sdk/cpprt/linux/libunwind/doc/_U_dyn_cancel.man b/sdk/cpprt/linux/libunwind/doc/_U_dyn_cancel.man new file mode 100644 index 0000000000..a420a6deaf --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/_U_dyn_cancel.man @@ -0,0 +1,66 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/_U_dyn_cancel.tex b/sdk/cpprt/linux/libunwind/doc/_U_dyn_cancel.tex new file mode 100644 index 0000000000..ca5a12a76e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/_U_dyn_cancel.tex @@ -0,0 +1,46 @@ +\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/sdk/cpprt/linux/libunwind/doc/_U_dyn_register.man b/sdk/cpprt/linux/libunwind/doc/_U_dyn_register.man new file mode 100644 index 0000000000..107e5fd0e1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/_U_dyn_register.man @@ -0,0 +1,68 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/_U_dyn_register.tex b/sdk/cpprt/linux/libunwind/doc/_U_dyn_register.tex new file mode 100644 index 0000000000..ab23b5c621 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/_U_dyn_register.tex @@ -0,0 +1,47 @@ +\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/sdk/cpprt/linux/libunwind/doc/common.tex.in b/sdk/cpprt/linux/libunwind/doc/common.tex.in new file mode 100644 index 0000000000..91c96a9df4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/common.tex.in @@ -0,0 +1,11 @@ +\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/sdk/cpprt/linux/libunwind/doc/libunwind-dynamic.man b/sdk/cpprt/linux/libunwind/doc/libunwind-dynamic.man new file mode 100644 index 0000000000..7c7507cb10 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-dynamic.man @@ -0,0 +1,538 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/libunwind-dynamic.tex b/sdk/cpprt/linux/libunwind/doc/libunwind-dynamic.tex new file mode 100644 index 0000000000..21e895a34f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-dynamic.tex @@ -0,0 +1,401 @@ +\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/sdk/cpprt/linux/libunwind/doc/libunwind-ia64.man b/sdk/cpprt/linux/libunwind/doc/libunwind-ia64.man new file mode 100644 index 0000000000..06b141eb3e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-ia64.man @@ -0,0 +1,314 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/libunwind-ia64.tex b/sdk/cpprt/linux/libunwind/doc/libunwind-ia64.tex new file mode 100644 index 0000000000..c08946dc4b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-ia64.tex @@ -0,0 +1,216 @@ +\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/sdk/cpprt/linux/libunwind/doc/libunwind-ptrace.man b/sdk/cpprt/linux/libunwind/doc/libunwind-ptrace.man new file mode 100644 index 0000000000..985fcae275 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-ptrace.man @@ -0,0 +1,220 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/libunwind-ptrace.tex b/sdk/cpprt/linux/libunwind/doc/libunwind-ptrace.tex new file mode 100644 index 0000000000..fe074d8619 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-ptrace.tex @@ -0,0 +1,134 @@ +\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/sdk/cpprt/linux/libunwind/doc/libunwind-setjmp.man b/sdk/cpprt/linux/libunwind/doc/libunwind-setjmp.man new file mode 100644 index 0000000000..e8b9de82c7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-setjmp.man @@ -0,0 +1,132 @@ +'\" 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 +setjmp(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/sdk/cpprt/linux/libunwind/doc/libunwind-setjmp.tex b/sdk/cpprt/linux/libunwind/doc/libunwind-setjmp.tex new file mode 100644 index 0000000000..b31ee9e589 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind-setjmp.tex @@ -0,0 +1,87 @@ +\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{setjmp}(\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/sdk/cpprt/linux/libunwind/doc/libunwind.man b/sdk/cpprt/linux/libunwind/doc/libunwind.man new file mode 100644 index 0000000000..c6046e2833 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind.man @@ -0,0 +1,500 @@ +'\" t +.\" Manual page created with latex2man on Thu Aug 16 09:44:43 MDT 2007 +.\" NOTE: This file is generated, DO NOT EDIT. +.de Vb +.ft CW +.nf +.. +.de Ve +.ft R + +.fi +.. +.TH "LIBUNWIND" "3" "16 August 2007" "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 +.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. +.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_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/sdk/cpprt/linux/libunwind/doc/libunwind.tex b/sdk/cpprt/linux/libunwind/doc/libunwind.tex new file mode 100644 index 0000000000..534bd4db88 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind.tex @@ -0,0 +1,355 @@ +\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{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. + + +\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\_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/sdk/cpprt/linux/libunwind/doc/libunwind.trans b/sdk/cpprt/linux/libunwind/doc/libunwind.trans new file mode 100644 index 0000000000..a514e5a081 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/libunwind.trans @@ -0,0 +1,34 @@ +$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/sdk/cpprt/linux/libunwind/doc/unw_create_addr_space.man b/sdk/cpprt/linux/libunwind/doc/unw_create_addr_space.man new file mode 100644 index 0000000000..4aca13ecd8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_create_addr_space.man @@ -0,0 +1,457 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_create_addr_space.tex b/sdk/cpprt/linux/libunwind/doc/unw_create_addr_space.tex new file mode 100644 index 0000000000..8de0691f3a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_create_addr_space.tex @@ -0,0 +1,265 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_destroy_addr_space.man b/sdk/cpprt/linux/libunwind/doc/unw_destroy_addr_space.man new file mode 100644 index 0000000000..90c9777efb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_destroy_addr_space.man @@ -0,0 +1,57 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_destroy_addr_space.tex b/sdk/cpprt/linux/libunwind/doc/unw_destroy_addr_space.tex new file mode 100644 index 0000000000..a66b10b4b0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_destroy_addr_space.tex @@ -0,0 +1,40 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_flush_cache.man b/sdk/cpprt/linux/libunwind/doc/unw_flush_cache.man new file mode 100644 index 0000000000..2c05bc234a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_flush_cache.man @@ -0,0 +1,92 @@ +'\" 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\\_FLUSH\\_CACHE" "3" "16 August 2007" "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) +.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/sdk/cpprt/linux/libunwind/doc/unw_flush_cache.tex b/sdk/cpprt/linux/libunwind/doc/unw_flush_cache.tex new file mode 100644 index 0000000000..9b61dfc309 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_flush_cache.tex @@ -0,0 +1,57 @@ +\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)} + +\section{Author} + +\noindent +David Mosberger-Tang\\ +Email: \Email{dmosberger@gmail.com}\\ +WWW: \URL{http://www.nongnu.org/libunwind/}. +\LatexManEnd + +\end{document} diff --git a/sdk/cpprt/linux/libunwind/doc/unw_get_accessors.man b/sdk/cpprt/linux/libunwind/doc/unw_get_accessors.man new file mode 100644 index 0000000000..83fe4fcea6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_accessors.man @@ -0,0 +1,79 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_get_accessors.tex b/sdk/cpprt/linux/libunwind/doc/unw_get_accessors.tex new file mode 100644 index 0000000000..bf344a32de --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_accessors.tex @@ -0,0 +1,55 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_get_fpreg.man b/sdk/cpprt/linux/libunwind/doc/unw_get_fpreg.man new file mode 100644 index 0000000000..5e54ca13d3 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_fpreg.man @@ -0,0 +1,111 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_get_fpreg.tex b/sdk/cpprt/linux/libunwind/doc/unw_get_fpreg.tex new file mode 100644 index 0000000000..dd679adc06 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_fpreg.tex @@ -0,0 +1,77 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info.man b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info.man new file mode 100644 index 0000000000..09eadee27a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info.man @@ -0,0 +1,203 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info.tex b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info.tex new file mode 100644 index 0000000000..72621f1a65 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info.tex @@ -0,0 +1,123 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info_by_ip.man b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info_by_ip.man new file mode 100644 index 0000000000..a347a1d008 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info_by_ip.man @@ -0,0 +1,134 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info_by_ip.tex b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info_by_ip.tex new file mode 100644 index 0000000000..5e1d5d247e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_info_by_ip.tex @@ -0,0 +1,91 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_get_proc_name.man b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_name.man new file mode 100644 index 0000000000..bbf350fe7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_name.man @@ -0,0 +1,123 @@ +'\" 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_ENOMME + 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/sdk/cpprt/linux/libunwind/doc/unw_get_proc_name.tex b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_name.tex new file mode 100644 index 0000000000..4a9b5850fb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_proc_name.tex @@ -0,0 +1,82 @@ +\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\_ENOMME}] 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/sdk/cpprt/linux/libunwind/doc/unw_get_reg.man b/sdk/cpprt/linux/libunwind/doc/unw_get_reg.man new file mode 100644 index 0000000000..83e8bb43b6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_reg.man @@ -0,0 +1,112 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_get_reg.tex b/sdk/cpprt/linux/libunwind/doc/unw_get_reg.tex new file mode 100644 index 0000000000..b66e8c0dbb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_get_reg.tex @@ -0,0 +1,77 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_getcontext.man b/sdk/cpprt/linux/libunwind/doc/unw_getcontext.man new file mode 100644 index 0000000000..13725df957 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_getcontext.man @@ -0,0 +1,93 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_getcontext.tex b/sdk/cpprt/linux/libunwind/doc/unw_getcontext.tex new file mode 100644 index 0000000000..fa3eb814b3 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_getcontext.tex @@ -0,0 +1,63 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_init_local.man b/sdk/cpprt/linux/libunwind/doc/unw_init_local.man new file mode 100644 index 0000000000..73b798863a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_init_local.man @@ -0,0 +1,119 @@ +'\" 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\\_LOCAL" "3" "16 August 2007" "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 +.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 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. +From a behavioral point of view, the call: +.PP +.Vb + ret = unw_init_local(&cursor, &ucontext); +.Ve +is equivalent to: +.PP +.Vb + ret = unw_init_remote(&cursor, unw_local_addr_space, + &ucontext); +.Ve +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 +.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/sdk/cpprt/linux/libunwind/doc/unw_init_local.tex b/sdk/cpprt/linux/libunwind/doc/unw_init_local.tex new file mode 100644 index 0000000000..5cea673c8f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_init_local.tex @@ -0,0 +1,81 @@ +\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});\\ + +\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 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. +From a behavioral point of view, the call: + +\begin{verbatim} + ret = unw_init_local(&cursor, &ucontext); +\end{verbatim} +is equivalent to: + +\begin{verbatim} + ret = unw_init_remote(&cursor, unw_local_addr_space, + &ucontext); +\end{verbatim} +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. + +\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/sdk/cpprt/linux/libunwind/doc/unw_init_remote.man b/sdk/cpprt/linux/libunwind/doc/unw_init_remote.man new file mode 100644 index 0000000000..0acdac9617 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_init_remote.man @@ -0,0 +1,123 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_init_remote.tex b/sdk/cpprt/linux/libunwind/doc/unw_init_remote.tex new file mode 100644 index 0000000000..9b4dc7997a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_init_remote.tex @@ -0,0 +1,79 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_is_fpreg.man b/sdk/cpprt/linux/libunwind/doc/unw_is_fpreg.man new file mode 100644 index 0000000000..0c26ec1bc7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_is_fpreg.man @@ -0,0 +1,73 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_is_fpreg.tex b/sdk/cpprt/linux/libunwind/doc/unw_is_fpreg.tex new file mode 100644 index 0000000000..c28cdc9be4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_is_fpreg.tex @@ -0,0 +1,52 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_is_signal_frame.man b/sdk/cpprt/linux/libunwind/doc/unw_is_signal_frame.man new file mode 100644 index 0000000000..d9a7cda7b5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_is_signal_frame.man @@ -0,0 +1,88 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_is_signal_frame.tex b/sdk/cpprt/linux/libunwind/doc/unw_is_signal_frame.tex new file mode 100644 index 0000000000..f262e5600c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_is_signal_frame.tex @@ -0,0 +1,67 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_regname.man b/sdk/cpprt/linux/libunwind/doc/unw_regname.man new file mode 100644 index 0000000000..1e3e2dbc6e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_regname.man @@ -0,0 +1,68 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_regname.tex b/sdk/cpprt/linux/libunwind/doc/unw_regname.tex new file mode 100644 index 0000000000..94b6434194 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_regname.tex @@ -0,0 +1,47 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_resume.man b/sdk/cpprt/linux/libunwind/doc/unw_resume.man new file mode 100644 index 0000000000..1bf38327bf --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_resume.man @@ -0,0 +1,146 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_resume.tex b/sdk/cpprt/linux/libunwind/doc/unw_resume.tex new file mode 100644 index 0000000000..38b18248ab --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_resume.tex @@ -0,0 +1,99 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_set_caching_policy.man b/sdk/cpprt/linux/libunwind/doc/unw_set_caching_policy.man new file mode 100644 index 0000000000..a21d84a6dd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_set_caching_policy.man @@ -0,0 +1,118 @@ +'\" 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\\_CACHING\\_POLICY" "3" "16 August 2007" "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_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/sdk/cpprt/linux/libunwind/doc/unw_set_caching_policy.tex b/sdk/cpprt/linux/libunwind/doc/unw_set_caching_policy.tex new file mode 100644 index 0000000000..a84e0201e0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_set_caching_policy.tex @@ -0,0 +1,80 @@ +\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\_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/sdk/cpprt/linux/libunwind/doc/unw_set_fpreg.man b/sdk/cpprt/linux/libunwind/doc/unw_set_fpreg.man new file mode 100644 index 0000000000..6cefa54623 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_set_fpreg.man @@ -0,0 +1,117 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_set_fpreg.tex b/sdk/cpprt/linux/libunwind/doc/unw_set_fpreg.tex new file mode 100644 index 0000000000..aaf7fb25a7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_set_fpreg.tex @@ -0,0 +1,79 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_set_reg.man b/sdk/cpprt/linux/libunwind/doc/unw_set_reg.man new file mode 100644 index 0000000000..5d57045f74 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_set_reg.man @@ -0,0 +1,117 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_set_reg.tex b/sdk/cpprt/linux/libunwind/doc/unw_set_reg.tex new file mode 100644 index 0000000000..2421846be5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_set_reg.tex @@ -0,0 +1,79 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_step.man b/sdk/cpprt/linux/libunwind/doc/unw_step.man new file mode 100644 index 0000000000..54da1b2f3d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_step.man @@ -0,0 +1,106 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_step.tex b/sdk/cpprt/linux/libunwind/doc/unw_step.tex new file mode 100644 index 0000000000..106bd9ba99 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_step.tex @@ -0,0 +1,68 @@ +\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/sdk/cpprt/linux/libunwind/doc/unw_strerror.man b/sdk/cpprt/linux/libunwind/doc/unw_strerror.man new file mode 100644 index 0000000000..467c44d262 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_strerror.man @@ -0,0 +1,63 @@ +'\" 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/sdk/cpprt/linux/libunwind/doc/unw_strerror.tex b/sdk/cpprt/linux/libunwind/doc/unw_strerror.tex new file mode 100644 index 0000000000..7cad011768 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/doc/unw_strerror.tex @@ -0,0 +1,42 @@ +\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/sdk/cpprt/linux/libunwind/include/dwarf-eh.h b/sdk/cpprt/linux/libunwind/include/dwarf-eh.h new file mode 100644 index 0000000000..405e394a61 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/dwarf-eh.h @@ -0,0 +1,128 @@ +/* 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 dwarf_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_addr; // address of the FDE + } + binary_search_table[fde_count]; */ + }; + +#endif /* dwarf_eh_h */ diff --git a/sdk/cpprt/linux/libunwind/include/dwarf.h b/sdk/cpprt/linux/libunwind/include/dwarf.h new file mode 100644 index 0000000000..4abe6692e4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/dwarf.h @@ -0,0 +1,433 @@ +/* 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 + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_ATOMIC_OPS_H +# include +#endif + +#include + +struct dwarf_cursor; /* forward-declaration */ +struct elf_dyn_info; + +#include "dwarf-config.h" +#ifndef UNW_REMOTE_ONLY +#include +#endif + +#if HAVE_SGX +#include "pthread_compat.h" +#else +#include +#endif + +/* 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 /* GCC emits version 1??? */ + +#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_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_t; + +typedef struct + { + dwarf_where_t where; /* how is the register saved? */ + unw_word_t val; /* where it's saved */ + } +dwarf_save_loc_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_state + { + struct dwarf_reg_state *next; /* for rs_stack */ + dwarf_save_loc_t reg[DWARF_NUM_PRESERVED_REGS + 2]; + unw_word_t ip; /* ip this rs is for */ + unw_word_t ret_addr_column; /* indicates which column in the rule table represents return address */ + unsigned short lru_chain; /* used for least-recently-used chain */ + 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_state_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 ret_addr_column; /* column for return-address */ + 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_LOG_UNW_CACHE_SIZE 7 +#define DWARF_UNW_CACHE_SIZE (1 << DWARF_LOG_UNW_CACHE_SIZE) + +#define DWARF_LOG_UNW_HASH_SIZE (DWARF_LOG_UNW_CACHE_SIZE + 1) +#define DWARF_UNW_HASH_SIZE (1 << DWARF_LOG_UNW_HASH_SIZE) + +typedef unsigned char unw_hash_index_t; + +struct dwarf_rs_cache + { + pthread_mutex_t lock; + unsigned short lru_head; /* index of lead-recently used rs */ + unsigned short lru_tail; /* index of most-recently used rs */ + + /* hash table that maps instruction pointer to rs index: */ + unsigned short hash[DWARF_UNW_HASH_SIZE]; + + uint32_t generation; /* generation number */ + + /* rs cache: */ + dwarf_reg_state_t buckets[DWARF_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; + }; + +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 */ + }; + +/* 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_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_create_state_record UNW_OBJ (dwarf_create_state_record) +#define dwarf_make_proc_info UNW_OBJ (dwarf_make_proc_info) +#define dwarf_read_encoded_pointer UNW_OBJ (dwarf_read_encoded_pointer) +#define dwarf_step UNW_OBJ (dwarf_step) + +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_extract_proc_info_from_fde (unw_addr_space_t as, + unw_accessors_t *a, + unw_word_t *fde_addr, + unw_proc_info_t *pi, + int need_unwind_info, + unw_word_t base, + void *arg); +extern int dwarf_find_save_locs (struct dwarf_cursor *c); +extern int dwarf_create_state_record (struct dwarf_cursor *c, + dwarf_state_record_t *sr); +extern int dwarf_make_proc_info (struct dwarf_cursor *c); +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); + +#endif /* dwarf_h */ diff --git a/sdk/cpprt/linux/libunwind/include/dwarf_i.h b/sdk/cpprt/linux/libunwind/include/dwarf_i.h new file mode 100644 index 0000000000..bc0bc84e09 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/dwarf_i.h @@ -0,0 +1,490 @@ +#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 + +#define dwarf_to_unw_regnum_map UNW_OBJ (dwarf_to_unw_regnum_map) + +extern 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) + +#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. */ + +union __attribute__ ((packed)) _dwarf_misaligned_value_t + { + 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; + }; +typedef union _dwarf_misaligned_value_t 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; + int32_t sval32; + int64_t sval64; + 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/sdk/cpprt/linux/libunwind/include/libunwind-arm.h b/sdk/cpprt/linux/libunwind/include/libunwind-arm.h new file mode 100644 index 0000000000..cba380f2e4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-arm.h @@ -0,0 +1,302 @@ +/* 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]" \ + : [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/sdk/cpprt/linux/libunwind/include/libunwind-common.h.in b/sdk/cpprt/linux/libunwind/include/libunwind-common.h.in new file mode 100644 index 0000000000..fa753ba153 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-common.h.in @@ -0,0 +1,257 @@ +/* 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 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 */ + 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; + +/* 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_init_local UNW_OBJ(init_local) +#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_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_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 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 const char *unw_regname (unw_regnum_t); + +extern int unw_init_local (unw_cursor_t *, unw_context_t *); +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_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/sdk/cpprt/linux/libunwind/include/libunwind-coredump.h b/sdk/cpprt/linux/libunwind/include/libunwind-coredump.h new file mode 100644 index 0000000000..d2b05e71c2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-coredump.h @@ -0,0 +1,73 @@ +/* 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/sdk/cpprt/linux/libunwind/include/libunwind-dynamic.h b/sdk/cpprt/linux/libunwind/include/libunwind-dynamic.h new file mode 100644 index 0000000000..584f392c56 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-dynamic.h @@ -0,0 +1,210 @@ +/* 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_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/sdk/cpprt/linux/libunwind/include/libunwind-hppa.h b/sdk/cpprt/linux/libunwind/include/libunwind-hppa.h new file mode 100644 index 0000000000..74ea70da6c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-hppa.h @@ -0,0 +1,125 @@ +/* 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/sdk/cpprt/linux/libunwind/include/libunwind-ia64.h b/sdk/cpprt/linux/libunwind/include/libunwind-ia64.h new file mode 100644 index 0000000000..fb2fbfe520 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-ia64.h @@ -0,0 +1,194 @@ +/* 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/sdk/cpprt/linux/libunwind/include/libunwind-mips.h b/sdk/cpprt/linux/libunwind/include/libunwind-mips.h new file mode 100644 index 0000000000..91f70015b1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-mips.h @@ -0,0 +1,155 @@ +/* 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. To allow a single library to support + multiple ABIs, and to support N32 at all, we must use a 64-bit type + even when addresses are only 32 bits. */ +typedef uint64_t unw_word_t; +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, + + /* 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_R31, + + 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/sdk/cpprt/linux/libunwind/include/libunwind-ppc32.h b/sdk/cpprt/linux/libunwind/include/libunwind-ppc32.h new file mode 100644 index 0000000000..b40a84ef16 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-ppc32.h @@ -0,0 +1,207 @@ +/* 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 200 + +#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/sdk/cpprt/linux/libunwind/include/libunwind-ppc64.h b/sdk/cpprt/linux/libunwind/include/libunwind-ppc64.h new file mode 100644 index 0000000000..66420b33ff --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-ppc64.h @@ -0,0 +1,264 @@ +/* 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; + +/* + * 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/sdk/cpprt/linux/libunwind/include/libunwind-ptrace.h b/sdk/cpprt/linux/libunwind/include/libunwind-ptrace.h new file mode 100644 index 0000000000..7fca205e50 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-ptrace.h @@ -0,0 +1,63 @@ +/* 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/sdk/cpprt/linux/libunwind/include/libunwind-x86.h b/sdk/cpprt/linux/libunwind/include/libunwind-x86.h new file mode 100644 index 0000000000..32533df976 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-x86.h @@ -0,0 +1,187 @@ +/* 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/sdk/cpprt/linux/libunwind/include/libunwind-x86_64.h b/sdk/cpprt/linux/libunwind/include/libunwind-x86_64.h new file mode 100644 index 0000000000..526b1ea327 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind-x86_64.h @@ -0,0 +1,139 @@ +/* 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. */ + } +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 */ + } +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/sdk/cpprt/linux/libunwind/include/libunwind.h.in b/sdk/cpprt/linux/libunwind/include/libunwind.h.in new file mode 100644 index 0000000000..6ed4725293 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind.h.in @@ -0,0 +1,30 @@ +/* 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 __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 __i386__ +# include "libunwind-x86.h" +#elif defined __x86_64__ +# include "libunwind-x86_64.h" +#else +# error "Unsupported arch" +#endif + +#else /* UNW_REMOTE_ONLY */ + +# include "libunwind-@arch@.h" + +#endif /* UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/include/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/libunwind_i.h new file mode 100644 index 0000000000..079e805bb5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/libunwind_i.h @@ -0,0 +1,377 @@ +/* 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 + +#ifdef HAVE___THREAD + /* For now, turn off per-thread caching. It uses up too much TLS + memory per thread even when the thread never uses libunwind at + all. */ +# undef HAVE___THREAD +#endif + +/* Platform-independent libunwind-internal declarations. */ + +#include /* HP-UX needs this before include of pthread.h */ + +#include +#include + +#if HAVE_SGX +#include "pthread_compat.h" +#else +#include +#include +#endif + +#include +#include +#include +#include +#include + +#if defined(HAVE_ENDIAN_H) +# include +#elif defined(HAVE_SYS_ENDIAN_H) +# include +#else +# define __LITTLE_ENDIAN 1234 +# define __BIG_ENDIAN 4321 +# if defined(__hpux) +# define __BYTE_ORDER __BIG_ENDIAN +# else +# error Host has unknown byte-order. +# endif +#endif + +#ifdef __GNUC__ +# define UNUSED __attribute__((unused)) +# define NORETURN __attribute__((noreturn)) +# define ALIAS(name) __attribute__((alias (#name))) +# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 2) +# define ALWAYS_INLINE inline __attribute__((always_inline)) +# define HIDDEN __attribute__((visibility ("hidden"))) +# define PROTECTED __attribute__((visibility ("protected"))) +# else +# define ALWAYS_INLINE +# define HIDDEN +# define PROTECTED +# endif +# 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 ALWAYS_INLINE +# define UNUSED +# define NORETURN +# define ALIAS(name) +# define HIDDEN +# define PROTECTED +# define likely(x) (x) +# define unlikely(x) (x) +#endif + +#ifdef DEBUG +# define UNW_DEBUG 1 +#else +# define UNW_DEBUG 0 +#endif + +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) + +/* 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. */ + +#if HAVE_SGX +#define mutex_init(l) do { *l = PTHREAD_MUTEX_INITIALIZER; } while(0) +#define mutex_lock(l) do { if (pthread_mutex_lock ((l)) != 0) abort(); } while(0) +#define mutex_unlock(l) do { if (pthread_mutex_unlock ((l)) != 0) abort(); } while(0) +#else +#pragma weak pthread_mutex_init +#pragma weak pthread_mutex_lock +#pragma weak pthread_mutex_unlock + +#define mutex_init(l) \ + (pthread_mutex_init != 0 ? pthread_mutex_init ((l), 0) : 0) +#define mutex_lock(l) \ + (pthread_mutex_lock != 0 ? pthread_mutex_lock (l) : 0) +#define mutex_unlock(l) \ + (pthread_mutex_unlock != 0 ? pthread_mutex_unlock (l) : 0) +#endif + +#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) + /* 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_ADD1 +#else +# ifdef HAVE_IA64INTRIN_H +# include +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 HAVE_CMPXCHG +# define HAVE_FETCH_AND_ADD1 +# endif +#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) { +} + +#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 + +#define define_lock(name) \ + pthread_mutex_t name = 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 */ + +#if HAVE_SGX /* Running inside Enclave */ +#define GET_MEMORY(mem, size) do { mem = malloc(size); } while (0) +#else /* Normal application */ +#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 (0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, \ + -1, 0); \ + if (mem == MAP_FAILED) \ + mem = NULL; \ +} while (0) +#endif + +#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 && !HAVE_SGX +#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) +# ifdef __GNUC__ +# undef inline +# define inline UNUSED +# endif +#else +# define Debug(level,format...) +# define Dprintf(format...) +#endif + +static ALWAYS_INLINE void +print_error (const char *string) +{ +#if !HAVE_SGX + write (2, string, strlen (string)); +#endif +} + +#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 void inline invalidate_edi (struct elf_dyn_info *edi) +{ + if (edi->ei.image) +#if !HAVE_SGX + munmap (edi->ei.image, edi->ei.size); +#else /* to align with GET_MEMORY() */ + free(edi->ei.image); +#endif + 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 + +#endif /* libunwind_i_h */ diff --git a/sdk/cpprt/linux/libunwind/include/mempool.h b/sdk/cpprt/linux/libunwind/include/mempool.h new file mode 100644 index 0000000000..4b55974ffd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/mempool.h @@ -0,0 +1,89 @@ +/* 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/sdk/cpprt/linux/libunwind/include/remote.h b/sdk/cpprt/linux/libunwind/include/remote.h new file mode 100644 index 0000000000..9fb90c3dc6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/remote.h @@ -0,0 +1,127 @@ +#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; + + assert ((off & 0x1) == 0); + + *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; + + assert ((off & 0x3) == 0); + + *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/sdk/cpprt/linux/libunwind/include/tdep-arm/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep-arm/dwarf-config.h new file mode 100644 index 0000000000..455d15f436 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-arm/dwarf-config.h @@ -0,0 +1,51 @@ +/* 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 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 + +/* FIXME: Probably unnecessary on ARM. See arm/Gglobal.c. */ +#define DWARF_REGNUM_MAP_LENGTH 16 + +/* 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/sdk/cpprt/linux/libunwind/include/tdep-arm/ex_tables.h b/sdk/cpprt/linux/libunwind/include/tdep-arm/ex_tables.h new file mode 100644 index 0000000000..8906f13a22 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-arm/ex_tables.h @@ -0,0 +1,55 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-arm/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-arm/jmpbuf.h new file mode 100644 index 0000000000..499e7deb79 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-arm/jmpbuf.h @@ -0,0 +1,32 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-arm/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-arm/libunwind_i.h new file mode 100644 index 0000000000..af92f413f8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-arm/libunwind_i.h @@ -0,0 +1,298 @@ +/* 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 struct + { + /* no arm-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 + { + 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 */ + } + 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_needs_initialization UNW_OBJ(needs_initialization) +#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_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,rs) do {} while(0) +#define tdep_reuse_frame(c,rs) 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) \ + 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_needs_initialization; + +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 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); + +/* 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/sdk/cpprt/linux/libunwind/include/tdep-hppa/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep-hppa/dwarf-config.h new file mode 100644 index 0000000000..29f9eee4b5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-hppa/dwarf-config.h @@ -0,0 +1,54 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-hppa/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-hppa/jmpbuf.h new file mode 100644 index 0000000000..6735b21aff --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-hppa/jmpbuf.h @@ -0,0 +1,33 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-hppa/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-hppa/libunwind_i.h new file mode 100644 index 0000000000..f2168499af --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-hppa/libunwind_i.h @@ -0,0 +1,275 @@ +/* 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 "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 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_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_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,rs) do {} while(0) +#define tdep_reuse_frame(c,rs) 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(c,pi) \ + dwarf_put_unwind_info((c)->as, (pi), (c)->as_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(c,pi) \ + (*(c)->as->acc.put_unwind_info)((c)->as, (pi), (c)->as_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_needs_initialization; + +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 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/sdk/cpprt/linux/libunwind/include/tdep-ia64/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-ia64/jmpbuf.h new file mode 100644 index 0000000000..faa1f34407 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ia64/jmpbuf.h @@ -0,0 +1,32 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-ia64/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-ia64/libunwind_i.h new file mode 100644 index 0000000000..71e4310ba6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ia64/libunwind_i.h @@ -0,0 +1,275 @@ +/* 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 needs_initialization; + + /* 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_needs_initialization unw.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 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_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,rs) do {} while(0) +#define tdep_reuse_frame(c,rs) 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/PROTECTED. */ +#define unw UNW_OBJ(data) + +extern void tdep_init (void); +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 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/sdk/cpprt/linux/libunwind/include/tdep-ia64/rse.h b/sdk/cpprt/linux/libunwind/include/tdep-ia64/rse.h new file mode 100644 index 0000000000..c5fe4b5894 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ia64/rse.h @@ -0,0 +1,67 @@ +/* + * 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/sdk/cpprt/linux/libunwind/include/tdep-ia64/script.h b/sdk/cpprt/linux/libunwind/include/tdep-ia64/script.h new file mode 100644 index 0000000000..48a9fe561f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ia64/script.h @@ -0,0 +1,85 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-mips/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep-mips/dwarf-config.h new file mode 100644 index 0000000000..250746f56a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-mips/dwarf-config.h @@ -0,0 +1,54 @@ +/* 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 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 + +/* FIXME: Probably unnecessary on MIPS. See mips/Gglobal.c. */ +#define DWARF_REGNUM_MAP_LENGTH 32 + +/* 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/sdk/cpprt/linux/libunwind/include/tdep-mips/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-mips/jmpbuf.h new file mode 100644 index 0000000000..1adb2bca42 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-mips/jmpbuf.h @@ -0,0 +1,32 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-mips/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-mips/libunwind_i.h new file mode 100644 index 0000000000..f2bc893666 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-mips/libunwind_i.h @@ -0,0 +1,329 @@ +/* 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_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_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,rs) do {} while(0) +#define tdep_reuse_frame(c,rs) 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_needs_initialization; + +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 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/sdk/cpprt/linux/libunwind/include/tdep-ppc32/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep-ppc32/dwarf-config.h new file mode 100644 index 0000000000..e2676a824f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ppc32/dwarf-config.h @@ -0,0 +1,56 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-ppc32/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-ppc32/jmpbuf.h new file mode 100644 index 0000000000..3780d5b5e7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ppc32/jmpbuf.h @@ -0,0 +1,37 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-ppc32/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-ppc32/libunwind_i.h new file mode 100644 index 0000000000..7e66997770 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ppc32/libunwind_i.h @@ -0,0 +1,312 @@ +/* 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_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_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,rs) do {} while(0) +#define tdep_reuse_frame(c,rs) 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_needs_initialization; + +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 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/sdk/cpprt/linux/libunwind/include/tdep-ppc64/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep-ppc64/dwarf-config.h new file mode 100644 index 0000000000..e2676a824f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ppc64/dwarf-config.h @@ -0,0 +1,56 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-ppc64/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-ppc64/jmpbuf.h new file mode 100644 index 0000000000..3780d5b5e7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ppc64/jmpbuf.h @@ -0,0 +1,37 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-ppc64/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-ppc64/libunwind_i.h new file mode 100644 index 0000000000..aa979b9641 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-ppc64/libunwind_i.h @@ -0,0 +1,312 @@ +/* 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; + 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_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_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,rs) do {} while(0) +#define tdep_reuse_frame(c,rs) 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_needs_initialization; + +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 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/sdk/cpprt/linux/libunwind/include/tdep-x86/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep-x86/dwarf-config.h new file mode 100644 index 0000000000..898ab796a9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-x86/dwarf-config.h @@ -0,0 +1,52 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-x86/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-x86/jmpbuf.h new file mode 100644 index 0000000000..561495098b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-x86/jmpbuf.h @@ -0,0 +1,42 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-x86/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-x86/libunwind_i.h new file mode 100644 index 0000000000..ddcdc10b19 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-x86/libunwind_i.h @@ -0,0 +1,291 @@ +/* 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_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_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,rs) do {} while(0) +#define tdep_reuse_frame(c,rs) 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_needs_initialization; + +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 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/sdk/cpprt/linux/libunwind/include/tdep-x86_64/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep-x86_64/dwarf-config.h new file mode 100644 index 0000000000..d3cbe7c27a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-x86_64/dwarf-config.h @@ -0,0 +1,59 @@ +/* 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; +#ifndef UNW_LOCAL_ONLY + unw_word_t type; /* see X86_LOC_TYPE_* macros. */ +#endif + } +dwarf_loc_t; + +#endif /* dwarf_config_h */ diff --git a/sdk/cpprt/linux/libunwind/include/tdep-x86_64/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep-x86_64/jmpbuf.h new file mode 100644 index 0000000000..44fcd69bee --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-x86_64/jmpbuf.h @@ -0,0 +1,43 @@ +/* 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/sdk/cpprt/linux/libunwind/include/tdep-x86_64/libunwind_i.h b/sdk/cpprt/linux/libunwind/include/tdep-x86_64/libunwind_i.h new file mode 100644 index 0000000000..29c1bb0eb6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep-x86_64/libunwind_i.h @@ -0,0 +1,259 @@ +/* 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_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 : 2; /* 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 : 30; /* 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) + +#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) \ + x86_64_r_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) \ + x86_64_r_uc_addr(dwarf_get_uc(c), (r)), 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)) + +#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); + 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 (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_needs_initialization UNW_OBJ(needs_initialization) +#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_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,rs) do {} while(0) +# define tdep_reuse_frame(c,rs) do {} while(0) +#endif +#define tdep_stash_frame UNW_OBJ(stash_frame) +#if HAVE_SGX +#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) +#else +#define tdep_trace UNW_OBJ(tdep_trace) +#endif +#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_needs_initialization; + +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 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 void tdep_cache_frame (struct dwarf_cursor *c, + struct dwarf_reg_state *rs); +extern void tdep_reuse_frame (struct dwarf_cursor *c, + struct dwarf_reg_state *rs); +extern void tdep_stash_frame (struct dwarf_cursor *c, + struct dwarf_reg_state *rs); +#endif + +extern int tdep_getcontext_trace (unw_tdep_context_t *); + +#if (!HAVE_SGX) +extern int tdep_trace (unw_cursor_t *cursor, void **addresses, int *n); +#endif + +#endif /* X86_64_LIBUNWIND_I_H */ diff --git a/sdk/cpprt/linux/libunwind/include/tdep/dwarf-config.h b/sdk/cpprt/linux/libunwind/include/tdep/dwarf-config.h new file mode 100644 index 0000000000..ff5715f623 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep/dwarf-config.h @@ -0,0 +1,22 @@ +/* Provide a real file - not a symlink - as it would cause multiarch conflicts + when multiple different arch releases are installed simultaneously. */ + +#if 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 __i386__ +# include "tdep-x86/dwarf-config.h" +#elif defined __x86_64__ || defined __amd64__ +# include "tdep-x86_64/dwarf-config.h" +#else +# error "Unsupported arch" +#endif diff --git a/sdk/cpprt/linux/libunwind/include/tdep/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/tdep/jmpbuf.h new file mode 100644 index 0000000000..7d04a42c47 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep/jmpbuf.h @@ -0,0 +1,26 @@ +/* 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 __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" +#else +# error "Unsupported arch" +#endif + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/include/tdep/libunwind_i.h.in b/sdk/cpprt/linux/libunwind/include/tdep/libunwind_i.h.in new file mode 100644 index 0000000000..96f49fb26e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/tdep/libunwind_i.h.in @@ -0,0 +1,31 @@ +/* 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 __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 __i386__ +# include "tdep-x86/libunwind_i.h" +#elif defined __x86_64__ +# include "tdep-x86_64/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/sdk/cpprt/linux/libunwind/include/unwind.h b/sdk/cpprt/linux/libunwind/include/unwind.h new file mode 100644 index 0000000000..f8d43d0d0e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/unwind.h @@ -0,0 +1,154 @@ +/* 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/sdk/cpprt/linux/libunwind/include/x86/jmpbuf.h b/sdk/cpprt/linux/libunwind/include/x86/jmpbuf.h new file mode 100644 index 0000000000..a0eb072ee1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/include/x86/jmpbuf.h @@ -0,0 +1,31 @@ +/* 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/sdk/cpprt/linux/libunwind/scripts/kernel-diff.sh b/sdk/cpprt/linux/libunwind/scripts/kernel-diff.sh new file mode 100755 index 0000000000..459194e15a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/scripts/kernel-diff.sh @@ -0,0 +1,10 @@ +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/sdk/cpprt/linux/libunwind/scripts/kernel-files.txt b/sdk/cpprt/linux/libunwind/scripts/kernel-files.txt new file mode 100644 index 0000000000..d79e453a33 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/scripts/kernel-files.txt @@ -0,0 +1,19 @@ +$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/sdk/cpprt/linux/libunwind/scripts/make-L-files b/sdk/cpprt/linux/libunwind/scripts/make-L-files new file mode 100755 index 0000000000..8280e3d76a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/scripts/make-L-files @@ -0,0 +1,30 @@ +#!/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/sdk/cpprt/linux/libunwind/src/Makefile.am b/sdk/cpprt/linux/libunwind/src/Makefile.am new file mode 100644 index 0000000000..243ab08fdc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/Makefile.am @@ -0,0 +1,565 @@ +SOVERSION=8:0:0 # See comments at end of file. +SETJMP_SO_VERSION=0:0:0 +# +# Don't link with start-files since we don't use any constructors/destructors: +# +COMMON_SO_LDFLAGS = -XCClinker -nostartfiles + +lib_LIBRARIES = +lib_LTLIBRARIES = +if !REMOTE_ONLY +#lib_LIBRARIES += libunwind-ptrace.a libunwind-coredump.a +lib_LTLIBRARIES += libunwind.la +endif + +noinst_HEADERS = +noinst_LTLIBRARIES = + +### libunwind-ptrace: +libunwind_ptrace_a_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_a_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 +noinst_HEADERS += coredump/_UCD_internal.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/Gget_accessors.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 + +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-info-list.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 + +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_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/Lstep.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/Gstep.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 = se-libc-stubs.c se-iterate-phdr.c +libunwind_elf64_la_SOURCES = se-libc-stubs.c se-iterate-phdr.c +libunwind_elfxx_la_SOURCES = elfxx.c + +noinst_LTLIBRARIES += $(LIBUNWIND_ELF) +libunwind_la_LIBADD += $(LIBUNWIND_ELF) + +# 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 \ + arm/ex_tables.h + +# The list of files that go into libunwind: +libunwind_la_SOURCES_arm = $(libunwind_la_SOURCES_arm_common) \ + $(libunwind_la_SOURCES_local) \ + arm/getcontext.S \ + 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/Lis_signal_frame.c arm/Lregs.c arm/Lresume.c arm/Lstep.c \ + arm/Lex_tables.c + +libunwind_arm_la_SOURCES_arm = $(libunwind_la_SOURCES_arm_common) \ + $(libunwind_la_SOURCES_generic) \ + 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/Gis_signal_frame.c arm/Gregs.c arm/Gresume.c arm/Gstep.c \ + arm/Gex_tables.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/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/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/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/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 +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/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/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 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/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/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/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/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/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 + +# The list of local files that go to Power 64 and 32: +libunwind_la_SOURCES_ppc = ppc/Lcreate_addr_space.c \ + 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/Gcreate_addr_space.c \ + 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/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/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/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/Gglobal.c ppc64/Ginit.c \ + ppc64/Gregs.c ppc64/Gresume.c ppc64/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: + $(LN_S) -f libunwind-$(arch).a $(DESTDIR)$(libdir)/libunwind-generic.a + if test -f $(DESTDIR)$(libdir)/libunwind-$(arch).so; then \ + $(LN_S) -f libunwind-$(arch).so \ + $(DESTDIR)$(libdir)/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_coredump_a_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_coredump_a_SOURCES += coredump/_UCD_access_reg_freebsd.c +endif + +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 + ia64_mk_Gcursor_i_SOURCES = ia64/mk_Gcursor_i.c + ia64_mk_Lcursor_i_SOURCES = ia64/mk_Lcursor_i.c + noinst_PROGRAMS = ia64/mk_Gcursor_i ia64/mk_Lcursor_i + BUILT_SOURCES = Gcursor_i.h Lcursor_i.h +Gcursor_i.h: ia64/mk_Gcursor_i + ia64/mk_Gcursor_i > $@ +Lcursor_i.h: ia64/mk_Lcursor_i + ia64/mk_Lcursor_i > $@ + + 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_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 + +endif # ARCH_PPC64 +endif # ARCH_PPC32 +endif # ARCH_X86_64 +endif # ARCH_X86 +endif # ARCH_MIPS +endif # ARCH_HPPA +endif # ARCH_IA64 +endif # ARCH_ARM + +# libunwind-setjmp depends on libunwind-$(arch). Therefore must be added +# at the end. +if !REMOTE_ONLY +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) + +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/tdep-$(arch) -I. +AM_CPPFLAGS+= -I../../../../../common/inc/ -I../../../../../sdk/trts/ +AM_CPPFLAGS+= -I../../../../../common/inc/internal +AM_CCASFLAGS = $(AM_CPPFLAGS) +noinst_HEADERS += unwind/unwind-internal.h + +EXTRA_DIST = $(libunwind_la_SOURCES_arm) \ + $(libunwind_la_SOURCES_hppa) \ + $(libunwind_la_SOURCES_ia64) \ + $(libunwind_la_SOURCES_mips) \ + $(libunwind_la_SOURCES_x86) \ + $(libunwind_la_SOURCES_os_freebsd) \ + $(libunwind_la_SOURCES_os_linux) \ + $(libunwind_la_SOURCES_os_hpux) \ + $(libunwind_la_SOURCES_common) \ + $(libunwind_la_SOURCES_local) \ + $(libunwind_la_SOURCES_generic) \ + $(libunwind_arm_la_SOURCES_arm) \ + $(libunwind_hppa_la_SOURCES_hppa) \ + $(libunwind_ia64_la_SOURCES_ia64) \ + $(libunwind_mips_la_SOURCES_mips) \ + $(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/sdk/cpprt/linux/libunwind/src/arm/Gcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/arm/Gcreate_addr_space.c new file mode 100644 index 0000000000..537464919a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gcreate_addr_space.c @@ -0,0 +1,62 @@ +/* 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" + +PROTECTED 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; + + /* + * ARM supports little-endian and big-endian. + */ + if (byte_order != 0 && byte_order != __LITTLE_ENDIAN + && byte_order != __BIG_ENDIAN) + { + free(as); + return NULL; + } + + /* 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/sdk/cpprt/linux/libunwind/src/arm/Gex_tables.c b/sdk/cpprt/linux/libunwind/src/arm/Gex_tables.c new file mode 100644 index 0000000000..d78fbaf482 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gex_tables.c @@ -0,0 +1,569 @@ +/* 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 +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; +} + +PROTECTED 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) + { + /* 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; + } + 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)) + { + struct dwarf_callback_data cb_data; + + 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 (cb_data.single_fde) + /* already got the result in *pi */ + return 0; + + if (cb_data.di_debug.format != -1) + ret = tdep_search_unwind_table (as, ip, &cb_data.di_debug, pi, + need_unwind_info, arg); + else + ret = -UNW_ENOINFO; + } + + 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 = tdep_search_unwind_table (as, ip, &cb_data.di, pi, + need_unwind_info, arg); + else + ret = -UNW_ENOINFO; + } + + if (ret < 0) + Debug (14, "IP=0x%lx not found\n", (long) ip); + + 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/sdk/cpprt/linux/libunwind/src/arm/Gget_proc_info.c b/sdk/cpprt/linux/libunwind/src/arm/Gget_proc_info.c new file mode 100644 index 0000000000..acb78a4644 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gget_proc_info.c @@ -0,0 +1,41 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/arm/Gget_save_loc.c b/sdk/cpprt/linux/libunwind/src/arm/Gget_save_loc.c new file mode 100644 index 0000000000..151ba0f9d2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gget_save_loc.c @@ -0,0 +1,81 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/arm/Gglobal.c b/sdk/cpprt/linux/libunwind/src/arm/Gglobal.c new file mode 100644 index 0000000000..54dcd9d5fe --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gglobal.c @@ -0,0 +1,76 @@ +/* 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 pthread_mutex_t arm_lock = PTHREAD_MUTEX_INITIALIZER; +HIDDEN int tdep_needs_initialization = 1; + +/* Unwinding methods to use. See UNW_METHOD_ enums */ +HIDDEN int unwi_unwind_method = UNW_ARM_METHOD_ALL; + +/* FIXME: I'm pretty sure we don't need this at all for ARM, but "generic" + code (include/dwarf_i.h) seems to expect it to be here at present. */ + +HIDDEN uint8_t dwarf_to_unw_regnum_map[16] = + { + /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 */ + 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 + }; + +HIDDEN void +tdep_init (void) +{ + intrmask_t saved_mask; + + sigfillset (&unwi_full_mask); + + lock_acquire (&arm_lock, saved_mask); + { + if (!tdep_needs_initialization) + /* 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_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&arm_lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/arm/Ginit.c b/sdk/cpprt/linux/libunwind/src/arm/Ginit.c new file mode 100644 index 0000000000..b6fabca6a1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Ginit.c @@ -0,0 +1,180 @@ +/* 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. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED 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; +} + +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; + 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 = UNW_CACHE_GLOBAL; + 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/sdk/cpprt/linux/libunwind/src/arm/Ginit_local.c b/sdk/cpprt/linux/libunwind/src/arm/Ginit_local.c new file mode 100644 index 0000000000..87d07a3728 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Ginit_local.c @@ -0,0 +1,55 @@ +/* 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 + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) +{ + return -UNW_EINVAL; +} + +#else /* !UNW_REMOTE_ONLY */ + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) +{ + struct cursor *c = (struct cursor *) cursor; + + if (tdep_needs_initialization) + tdep_init (); + + Debug (1, "(cursor=%p)\n", c); + + c->dwarf.as = unw_local_addr_space; + c->dwarf.as_arg = uc; + + return common_init (c, 1); +} + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/src/arm/Ginit_remote.c b/sdk/cpprt/linux/libunwind/src/arm/Ginit_remote.c new file mode 100644 index 0000000000..854f3b62f0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Ginit_remote.c @@ -0,0 +1,45 @@ +/* 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" + +PROTECTED 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_needs_initialization) + 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/sdk/cpprt/linux/libunwind/src/arm/Gis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/arm/Gis_signal_frame.c new file mode 100644 index 0000000000..e2e8cd673a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gis_signal_frame.c @@ -0,0 +1,84 @@ +/* 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 +#include "unwind_i.h" + +#ifdef __linux__ +#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) +#endif /* __linux__ */ + +/* Returns 1 in case of a non-RT signal frame and 2 in case of a RT signal + frame. */ +PROTECTED 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 (as); + arg = c->dwarf.as_arg; + + ip = c->dwarf.ip; + + 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) + 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) + return 2; + + return 0; +#else + printf ("%s: implement me\n", __FUNCTION__); + return -UNW_ENOINFO; +#endif +} diff --git a/sdk/cpprt/linux/libunwind/src/arm/Gregs.c b/sdk/cpprt/linux/libunwind/src/arm/Gregs.c new file mode 100644 index 0000000000..03693a27c8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gregs.c @@ -0,0 +1,81 @@ +/* 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_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: + case UNW_ARM_R15: + 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/sdk/cpprt/linux/libunwind/src/arm/Gresume.c b/sdk/cpprt/linux/libunwind/src/arm/Gresume.c new file mode 100644 index 0000000000..da45dec820 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gresume.c @@ -0,0 +1,147 @@ +/* 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 "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 */ + + asm __volatile__ ( + "ldmia %0, {r4-r12, lr}\n" + "mov sp, r12\n" + "bx lr\n" + : : "r" (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) + ); + } +#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); + } + } +} + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/arm/Gstep.c b/sdk/cpprt/linux/libunwind/src/arm/Gstep.c new file mode 100644 index 0000000000..3b7bdbe8d5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Gstep.c @@ -0,0 +1,264 @@ +/* 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 "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; + + if ((ret = tdep_find_proc_info (&c->dwarf, 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; + } + + return (c->dwarf.ip == 0) ? 0 : 1; +} + +PROTECTED int +unw_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; + } + c->sigcontext_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; + c->sigcontext_addr = sp_addr + 8 + sizeof (siginfo_t); + } + else + { + c->sigcontext_format = ARM_SCF_LINUX_RT_SIGFRAME; + c->sigcontext_addr = sp_addr + sizeof (siginfo_t); + } + sc_addr = c->sigcontext_addr + LINUX_UC_MCONTEXT_OFF; + } + else + return -UNW_EUNSPEC; + + /* 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); + + return 1; +} + +PROTECTED 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)) + return unw_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. */ + if (unlikely (ret < 0)) + { + if (UNW_TRY_METHOD(UNW_ARM_METHOD_FRAME)) + { + ret = UNW_ESUCCESS; + /* DWARF unwinding failed, try to follow APCS/optimized APCS frame chain */ + unw_word_t instr, i; + Debug (13, "dwarf_step() failed (ret=%d), trying frame-chain\n", ret); + 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; + Debug(15, "ip=%lx\n", c->dwarf.ip); + } + else + { + ret = -UNW_ENOINFO; + } + } + } + return ret == -UNW_ENOINFO ? 0 : 1; +} diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/arm/Lcreate_addr_space.c new file mode 100644 index 0000000000..0f2dc6be90 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lcreate_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gcreate_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lex_tables.c b/sdk/cpprt/linux/libunwind/src/arm/Lex_tables.c new file mode 100644 index 0000000000..4a4f925c9c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lex_tables.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gex_tables.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lget_proc_info.c b/sdk/cpprt/linux/libunwind/src/arm/Lget_proc_info.c new file mode 100644 index 0000000000..69028b019f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lget_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lget_save_loc.c b/sdk/cpprt/linux/libunwind/src/arm/Lget_save_loc.c new file mode 100644 index 0000000000..9ea048a907 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lget_save_loc.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_save_loc.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lglobal.c b/sdk/cpprt/linux/libunwind/src/arm/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Linit.c b/sdk/cpprt/linux/libunwind/src/arm/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Linit_local.c b/sdk/cpprt/linux/libunwind/src/arm/Linit_local.c new file mode 100644 index 0000000000..68a1687e85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Linit_local.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_local.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Linit_remote.c b/sdk/cpprt/linux/libunwind/src/arm/Linit_remote.c new file mode 100644 index 0000000000..58cb04ab7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Linit_remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/arm/Lis_signal_frame.c new file mode 100644 index 0000000000..b9a7c4f51a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lis_signal_frame.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gis_signal_frame.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lregs.c b/sdk/cpprt/linux/libunwind/src/arm/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lresume.c b/sdk/cpprt/linux/libunwind/src/arm/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/Lstep.c b/sdk/cpprt/linux/libunwind/src/arm/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/gen-offsets.c b/sdk/cpprt/linux/libunwind/src/arm/gen-offsets.c new file mode 100644 index 0000000000..7d6bf2f1c5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/gen-offsets.c @@ -0,0 +1,54 @@ +#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/sdk/cpprt/linux/libunwind/src/arm/getcontext.S b/sdk/cpprt/linux/libunwind/src/arm/getcontext.S new file mode 100644 index 0000000000..c52992bfb9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/getcontext.S @@ -0,0 +1,56 @@ +/* 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 + str r0, [r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF] + add r0, r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF + @ 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 +#ifdef __linux__ + /* We do not need executable stack. */ + .section .note.GNU-stack,"",%progbits +#endif diff --git a/sdk/cpprt/linux/libunwind/src/arm/init.h b/sdk/cpprt/linux/libunwind/src/arm/init.h new file mode 100644 index 0000000000..676c34072d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/init.h @@ -0,0 +1,78 @@ +/* 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.ret_addr_column = 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/sdk/cpprt/linux/libunwind/src/arm/is_fpreg.c b/sdk/cpprt/linux/libunwind/src/arm/is_fpreg.c new file mode 100644 index 0000000000..d8b17ae781 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/is_fpreg.c @@ -0,0 +1,39 @@ +/* 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. */ + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/arm/offsets.h b/sdk/cpprt/linux/libunwind/src/arm/offsets.h new file mode 100644 index 0000000000..0593685ce3 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/offsets.h @@ -0,0 +1,36 @@ +/* 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 diff --git a/sdk/cpprt/linux/libunwind/src/arm/regname.c b/sdk/cpprt/linux/libunwind/src/arm/regname.c new file mode 100644 index 0000000000..474337a568 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/regname.c @@ -0,0 +1,90 @@ +#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", + }; + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) + return regname[reg]; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/arm/siglongjmp.S b/sdk/cpprt/linux/libunwind/src/arm/siglongjmp.S new file mode 100644 index 0000000000..4df0736683 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/siglongjmp.S @@ -0,0 +1,12 @@ + /* 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/sdk/cpprt/linux/libunwind/src/arm/unwind_i.h b/sdk/cpprt/linux/libunwind/src/arm/unwind_i.h new file mode 100644 index 0000000000..61ab54521c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/arm/unwind_i.h @@ -0,0 +1,43 @@ +/* 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 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); + +#endif /* unwind_i_h */ diff --git a/sdk/cpprt/linux/libunwind/src/coredump/README b/sdk/cpprt/linux/libunwind/src/coredump/README new file mode 100644 index 0000000000..204493c93e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/README @@ -0,0 +1,8 @@ +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/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_mem.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_mem.c new file mode 100644 index 0000000000..a58e5599bb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_mem.c @@ -0,0 +1,102 @@ +/* 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, "%s: write is not supported\n", __func__); + 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, "%s: addr 0x%llx is unmapped\n", + __func__, (unsigned long long)addr + ); + return -UNW_EINVAL; + + found: ; + + const char *filename; + 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, "%s: access to not-present data in phdr[%d]: addr:0x%llx\n", + __func__, 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, "%s: 0x%llx <- [addr:0x%llx fileofs:0x%llx]\n", + __func__, + (unsigned long long)(*val), + (unsigned long long)addr, + (unsigned long long)fileofs + ); + return 0; + + read_error: + Debug(1, "%s: access out of file: addr:0x%llx fileofs:%llx file:'%s'\n", + __func__, + (unsigned long long)addr, + (unsigned long long)fileofs, + filename + ); + return -UNW_EINVAL; +} diff --git a/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_reg_freebsd.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_reg_freebsd.c new file mode 100644 index 0000000000..d5b4e74f7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_reg_freebsd.c @@ -0,0 +1,118 @@ +/* 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, "%s: write is not supported\n", __func__); + 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, "%s: bad regnum:%d\n", __func__, 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, "%s: bad regnum:%d\n", __func__, regnum); + return -UNW_EINVAL; + }; +#else +#error Port me +#endif + + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_reg_linux.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_reg_linux.c new file mode 100644 index 0000000000..72b6e2299d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_access_reg_linux.c @@ -0,0 +1,90 @@ +/* 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, "%s: write is not supported\n", __func__); + return -UNW_EINVAL; + } + +#if 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 + + struct UCD_info *ui = arg; + if (regnum < 0 || regnum >= (unw_regnum_t)ARRAY_SIZE(remap_regs)) + { + Debug(0, "%s: bad regnum:%d\n", __func__, regnum); + return -UNW_EINVAL; + } + regnum = remap_regs[regnum]; + + /* pr_reg is a long[] array, but it contains struct user_regs_struct's + * image. + */ + Debug(1, "pr_reg[%d]:%ld (0x%lx)", regnum, + (long)ui->prstatus->pr_reg[regnum], + (long)ui->prstatus->pr_reg[regnum] + ); + *valp = ui->prstatus->pr_reg[regnum]; + + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/coredump/_UCD_accessors.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_accessors.c new file mode 100644 index 0000000000..9bbe34e1b2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_accessors.c @@ -0,0 +1,36 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/coredump/_UCD_create.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_create.c new file mode 100644 index 0000000000..0f791af860 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_create.c @@ -0,0 +1,417 @@ +/* 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) + ALIGN((_hdr)->n_namesz, 4)) +#define NOTE_SIZE(_hdr) (sizeof (Elf32_Nhdr) + ALIGN((_hdr)->n_namesz, 4) + (_hdr)->n_descsz) +#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, "\x7f""ELF", 4) != 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/sdk/cpprt/linux/libunwind/src/coredump/_UCD_destroy.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_destroy.c new file mode 100644 index 0000000000..5aff989ccc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_destroy.c @@ -0,0 +1,50 @@ +/* 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->note_phdr); + + free(ui); +} diff --git a/sdk/cpprt/linux/libunwind/src/coredump/_UCD_elf_map_image.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_elf_map_image.c new file mode 100644 index 0000000000..63eb22a918 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_elf_map_image.c @@ -0,0 +1,98 @@ +/* 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/sdk/cpprt/linux/libunwind/src/coredump/_UCD_find_proc_info.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_find_proc_info.c new file mode 100644 index 0000000000..b727ea9073 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_find_proc_info.c @@ -0,0 +1,163 @@ +/* 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, "%s returns error: _UCD_get_elf_image failed\n", __func__); + 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 (dwarf_find_unwind_table(&ui->edi, as, phdr->backing_filename, segbase, mapoff, ip) < 0) + { + Debug(1, "%s returns error: dwarf_find_unwind_table failed\n", __func__); + 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, "%s returns error: all formats are -1\n", __func__); + return -UNW_ENOINFO; + } + + Debug(1, "%s returns success\n", __func__); + 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, "%s: entering\n", __func__); + + int ret = -UNW_ENOINFO; + + if (get_unwind_info(ui, as, ip) < 0) { + Debug(1, "%s returns error: get_unwind_info failed\n", __func__); + 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, "%s: returns %d\n", __func__, ret); + + return ret; +} diff --git a/sdk/cpprt/linux/libunwind/src/coredump/_UCD_get_proc_name.c b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_get_proc_name.c new file mode 100644 index 0000000000..b13cd932f4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_get_proc_name.c @@ -0,0 +1,70 @@ +/* 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, "%s returns error: _UCD_get_elf_image failed\n", __func__); + 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/sdk/cpprt/linux/libunwind/src/coredump/_UCD_internal.h b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_internal.h new file mode 100644 index 0000000000..5e92777503 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_internal.h @@ -0,0 +1,106 @@ +/* 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 ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL)) +#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/sdk/cpprt/linux/libunwind/src/coredump/_UCD_lib.h b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_lib.h new file mode 100644 index 0000000000..22be32ed1e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UCD_lib.h @@ -0,0 +1,57 @@ +/* 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/sdk/cpprt/linux/libunwind/src/coredump/_UPT_access_fpreg.c b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_access_fpreg.c new file mode 100644 index 0000000000..a578af1703 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_access_fpreg.c @@ -0,0 +1,34 @@ +/* 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/sdk/cpprt/linux/libunwind/src/coredump/_UPT_elf.c b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_elf.c new file mode 100644 index 0000000000..8f30c695f0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_elf.c @@ -0,0 +1,5 @@ +/* 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/sdk/cpprt/linux/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c new file mode 100644 index 0000000000..f1e6568199 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c @@ -0,0 +1,108 @@ +/* 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 = dwarf_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/sdk/cpprt/linux/libunwind/src/coredump/_UPT_put_unwind_info.c b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_put_unwind_info.c new file mode 100644 index 0000000000..2f5a6476ba --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_put_unwind_info.c @@ -0,0 +1,36 @@ +/* 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/sdk/cpprt/linux/libunwind/src/coredump/_UPT_resume.c b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_resume.c new file mode 100644 index 0000000000..368aae112c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/coredump/_UPT_resume.c @@ -0,0 +1,35 @@ +/* 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/sdk/cpprt/linux/libunwind/src/dwarf/Gexpr.c b/sdk/cpprt/linux/libunwind/src/dwarf/Gexpr.c new file mode 100644 index 0000000000..4a01215825 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Gexpr.c @@ -0,0 +1,647 @@ +/* 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 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_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, 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 { \ + 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 (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"); + 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, tmp1) <= sword (as, tmp2)); + break; + + case DW_OP_ge: + Debug (15, "OP_ge\n"); + tmp1 = pop (); + tmp2 = pop (); + push (sword (as, tmp1) >= sword (as, tmp2)); + break; + + case DW_OP_eq: + Debug (15, "OP_eq\n"); + tmp1 = pop (); + tmp2 = pop (); + push (sword (as, tmp1) == sword (as, tmp2)); + break; + + case DW_OP_lt: + Debug (15, "OP_lt\n"); + tmp1 = pop (); + tmp2 = pop (); + push (sword (as, tmp1) < sword (as, tmp2)); + break; + + case DW_OP_gt: + Debug (15, "OP_gt\n"); + tmp1 = pop (); + tmp2 = pop (); + push (sword (as, tmp1) > sword (as, tmp2)); + break; + + case DW_OP_ne: + Debug (15, "OP_ne\n"); + tmp1 = pop (); + tmp2 = pop (); + push (sword (as, tmp1) != sword (as, tmp2)); + 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/sdk/cpprt/linux/libunwind/src/dwarf/Gfde.c b/sdk/cpprt/linux/libunwind/src/dwarf/Gfde.c new file mode 100644 index 0000000000..8659624b03 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Gfde.c @@ -0,0 +1,357 @@ +/* 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, + unw_word_t base, 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 = (base) ? 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 = (base) ? 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; + + if (version != 1 && version != DWARF_CIE_VERSION) + { + Debug (1, "Got CIE version %u, expected version 1 or " + STR (DWARF_CIE_VERSION) "\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, + int need_unwind_info, unw_word_t base, + 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; + + /* 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, base != 0)) + /* ignore CIEs (happens during linear searches) */ + return 0; + + if (base != 0) + 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; + + /* 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, base != 0)) + /* ignore CIEs (happens during linear searches) */ + return 0; + + if (base != 0) + 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, base, 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/sdk/cpprt/linux/libunwind/src/dwarf/Gfind_proc_info-lsb.c b/sdk/cpprt/linux/libunwind/src/dwarf/Gfind_proc_info-lsb.c new file mode 100644 index 0000000000..bdce9efafc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Gfind_proc_info-lsb.c @@ -0,0 +1,942 @@ +/* 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/). */ + +#ifndef UNW_REMOTE_ONLY +#include +#endif /* !UNW_REMOTE_ONLY */ +#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 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 (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, 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, + 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; or + -1 for recursive calls following .gnu_debuglink. 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) +{ + FILE *f; + Elf_W (Ehdr) ehdr; + Elf_W (Half) shstrndx; + Elf_W (Shdr) *sec_hdrs = NULL; + char *stringtab = NULL; + unsigned int i; + size_t linksize = 0; + char *linkbuf = NULL; + + *buf = NULL; + *bufsize = 0; + + f = fopen (file, "r"); + + if (!f) + return 1; + + if (fread (&ehdr, sizeof (Elf_W (Ehdr)), 1, f) != 1) + goto file_error; + + shstrndx = ehdr.e_shstrndx; + + Debug (4, "opened file '%s'. Section header at offset %d\n", + file, (int) ehdr.e_shoff); + + fseek (f, ehdr.e_shoff, SEEK_SET); + sec_hdrs = calloc (ehdr.e_shnum, sizeof (Elf_W (Shdr))); + if (fread (sec_hdrs, sizeof (Elf_W (Shdr)), ehdr.e_shnum, f) != ehdr.e_shnum) + goto file_error; + + Debug (4, "loading string table of size %zd\n", + sec_hdrs[shstrndx].sh_size); + stringtab = malloc (sec_hdrs[shstrndx].sh_size); + fseek (f, sec_hdrs[shstrndx].sh_offset, SEEK_SET); + if (fread (stringtab, 1, sec_hdrs[shstrndx].sh_size, f) != sec_hdrs[shstrndx].sh_size) + goto file_error; + + for (i = 1; i < ehdr.e_shnum && *buf == NULL; i++) + { + char *secname = &stringtab[sec_hdrs[i].sh_name]; + + if (strcmp (secname, ".debug_frame") == 0) + { + *bufsize = sec_hdrs[i].sh_size; + *buf = malloc (*bufsize); + + fseek (f, sec_hdrs[i].sh_offset, SEEK_SET); + if (fread (*buf, 1, *bufsize, f) != *bufsize) + goto file_error; + + Debug (4, "read %zd bytes of .debug_frame from offset %zd\n", + *bufsize, sec_hdrs[i].sh_offset); + } + else if (strcmp (secname, ".gnu_debuglink") == 0) + { + linksize = sec_hdrs[i].sh_size; + linkbuf = malloc (linksize); + + fseek (f, sec_hdrs[i].sh_offset, SEEK_SET); + if (fread (linkbuf, 1, linksize, f) != linksize) + goto file_error; + + Debug (4, "read %zd bytes of .gnu_debuglink from offset %zd\n", + linksize, sec_hdrs[i].sh_offset); + } + } + + free (stringtab); + free (sec_hdrs); + + fclose (f); + + /* Ignore separate debug files which contain a .gnu_debuglink section. */ + if (linkbuf && is_local == -1) + { + free (linkbuf); + return 1; + } + + if (*buf == NULL && linkbuf != NULL && memchr (linkbuf, 0, linksize) != NULL) + { + char *newname, *basedir, *p; + static const char *debugdir = "/usr/lib/debug"; + int ret; + + /* XXX: Don't bother with the checksum; just search for the file. */ + basedir = malloc (strlen (file) + 1); + newname = malloc (strlen (linkbuf) + strlen (debugdir) + + strlen (file) + 9); + + 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 = load_debug_frame (newname, buf, bufsize, -1); + + if (ret == 1) + { + strcpy (newname, basedir); + strcat (newname, "/.debug/"); + strcat (newname, linkbuf); + ret = load_debug_frame (newname, buf, bufsize, -1); + } + + if (ret == 1 && is_local == 1) + { + strcpy (newname, debugdir); + strcat (newname, basedir); + strcat (newname, "/"); + strcat (newname, linkbuf); + ret = load_debug_frame (newname, buf, bufsize, -1); + } + + free (basedir); + free (newname); + } + free (linkbuf); + + return 0; + +/* An error reading image file. Release resources and return error code */ +file_error: + if (stringtab) free(stringtab); + if (sec_hdrs) free(sec_hdrs); + if (linkbuf) free(linkbuf); + fclose(f); + + return 1; +} + +/* 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) && (!HAVE_SGX) + struct map_iterator mi; + int found = 0; + int pid = getpid (); + unsigned long segbase, mapoff, hi; + + maps_init (&mi, pid); + 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 struct debug_frame_tab * +debug_frame_tab_new (unsigned int base_size) +{ + struct debug_frame_tab *tab = malloc (sizeof (struct debug_frame_tab)); + + tab->tab = calloc (base_size, sizeof (struct table_entry)); + tab->length = 0; + tab->size = base_size; + + return tab; +} + +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; +} + +PROTECTED 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 (unw_local_addr_space); + + /* Find all FDE entries in debug_frame, and make into a sorted + index. */ + + tab = debug_frame_tab_new (16); + + 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, 0, + (uintptr_t) buf, + 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; + free (tab); + } + + 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 + +/* 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; + unw_accessors_t *a; + long n; + int found = 0; +#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) + { + 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; + + hdr = (struct dwarf_eh_frame_hdr *) (p_eh_hdr->p_vaddr + load_base); + 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 (unw_local_addr_space); + addr = (unw_word_t) (uintptr_t) (hdr + 1); + + /* (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 (); + + /* XXX we know how to build a local binary search table for + .debug_frame, so we could do that here too. */ + cb_data->single_fde = 1; + 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 + { + 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) + { + Debug (14, "IP=0x%lx not found\n", (long) ip); + return -UNW_ENOINFO; + } + + 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 (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 (as, ip, &cb_data.di_debug, pi, + need_unwind_info, arg); + 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 = 0; + 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, void *arg) +{ + unsigned long table_len = table_size / sizeof (struct table_entry); + unw_accessors_t *a = unw_get_accessors (as); + unsigned long lo, hi, mid; + unw_word_t e_addr = 0; + int32_t start; + 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) + return ret; + return 1; +} + +#endif /* !UNW_LOCAL_ONLY */ + +PROTECTED 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 segbase = 0, 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 (di->format == UNW_INFO_FORMAT_REMOTE_TABLE); +#else + assert (di->format == UNW_INFO_FORMAT_REMOTE_TABLE + || di->format == UNW_INFO_FORMAT_TABLE); +#endif + assert (ip >= di->start_ip && ip < di->end_ip); + + if (di->format == UNW_INFO_FORMAT_REMOTE_TABLE) + { + 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 + { +#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 (as); + +#ifndef UNW_REMOTE_ONLY + if (as == unw_local_addr_space) + { + segbase = di->u.rti.segbase; + e = lookup (table, table_len, ip - segbase); + } + else +#endif + { +#ifndef UNW_LOCAL_ONLY + segbase = di->u.rti.segbase; + if ((ret = remote_lookup (as, (uintptr_t) table, table_len, + ip - segbase, &ent, arg)) < 0) + return ret; + if (ret) + e = &ent; + 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, + need_unwind_info, + debug_frame_base, 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 (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/sdk/cpprt/linux/libunwind/src/dwarf/Gfind_unwind_table.c b/sdk/cpprt/linux/libunwind/src/dwarf/Gfind_unwind_table.c new file mode 100644 index 0000000000..ae70fc1b97 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Gfind_unwind_table.c @@ -0,0 +1,228 @@ +/* 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 "dwarf-eh.h" +#include "dwarf_i.h" + +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 = (unw_word_t) -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 (unw_local_addr_space); + addr = (unw_word_t) (hdr + 1); + + /* 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 - (unw_word_t) 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) + + ((unw_word_t) hdr - (unw_word_t) 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 = (unw_word_t) 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->edi.di_debug, ip, segbase, path, + start_ip, end_ip); +#endif + + return found; +} diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Gparser.c b/sdk/cpprt/linux/libunwind/src/dwarf/Gparser.c new file mode 100644 index 0000000000..ca26afb56c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Gparser.c @@ -0,0 +1,908 @@ +/* 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 +#include "dwarf_i.h" +#include "libunwind_i.h" + +#define alloc_reg_state() (mempool_alloc (&dwarf_reg_state_pool)) +#define free_reg_state(rs) (mempool_free (&dwarf_reg_state_pool, rs)) + +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[regnum].where = where; + sr->rs_current.reg[regnum].val = val; +} + +/* 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 *addr, unw_word_t end_addr, + struct dwarf_cie_info *dci) +{ + unw_word_t curr_ip, operand = 0, regnum, val, len, fde_encoding; + dwarf_reg_state_t *rs_stack = NULL, *new_rs, *old_rs; + unw_addr_space_t as; + unw_accessors_t *a; + uint8_t u8, op; + uint16_t u16; + uint32_t u32; + void *arg; + int ret; + + as = c->as; + arg = c->as_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; + } + a = unw_get_accessors (as); + curr_ip = c->pi.start_ip; + + /* Process everything up to and including the current 'ip', + including all the DW_CFA_advance_loc instructions. See + 'c->use_prev_instr' use in 'fetch_proc_info' for details. */ + while (curr_ip <= ip && *addr < end_addr) + { + if ((ret = dwarf_readu8 (as, a, addr, &op, arg)) < 0) + return ret; + + 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: + curr_ip += operand * dci->code_align; + Debug (15, "CFA_advance_loc to 0x%lx\n", (long) curr_ip); + break; + + case DW_CFA_advance_loc1: + if ((ret = dwarf_readu8 (as, a, addr, &u8, arg)) < 0) + goto fail; + curr_ip += u8 * dci->code_align; + Debug (15, "CFA_advance_loc1 to 0x%lx\n", (long) curr_ip); + break; + + case DW_CFA_advance_loc2: + if ((ret = dwarf_readu16 (as, a, addr, &u16, arg)) < 0) + goto fail; + curr_ip += u16 * dci->code_align; + Debug (15, "CFA_advance_loc2 to 0x%lx\n", (long) curr_ip); + break; + + case DW_CFA_advance_loc4: + if ((ret = dwarf_readu32 (as, a, addr, &u32, arg)) < 0) + goto fail; + curr_ip += u32 * dci->code_align; + Debug (15, "CFA_advance_loc4 to 0x%lx\n", (long) curr_ip); + break; + + case DW_CFA_MIPS_advance_loc8: +#ifdef UNW_TARGET_MIPS + { + uint64_t u64; + + if ((ret = dwarf_readu64 (as, a, addr, &u64, arg)) < 0) + goto fail; + curr_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; + goto fail; +#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; + goto fail; + } + if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) + goto fail; + 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)) + goto fail; + 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)) + goto fail; + 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; + goto fail; + } + sr->rs_current.reg[regnum] = sr->rs_initial.reg[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) + goto fail; + if (regnum >= DWARF_NUM_PRESERVED_REGS) + { + Debug (1, "Invalid register number %u in " + "DW_CFA_restore_extended\n", (unsigned int) regnum); + ret = -UNW_EINVAL; + goto fail; + } + sr->rs_current.reg[regnum] = sr->rs_initial.reg[regnum]; + Debug (15, "CFA_restore_extended r%lu\n", (long) regnum); + break; + + case DW_CFA_nop: + break; + + case DW_CFA_set_loc: + fde_encoding = dci->fde_encoding; + if ((ret = dwarf_read_encoded_pointer (as, a, addr, fde_encoding, + &c->pi, &curr_ip, + arg)) < 0) + goto fail; + Debug (15, "CFA_set_loc to 0x%lx\n", (long) curr_ip); + break; + + case DW_CFA_undefined: + if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0) + goto fail; + 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) + goto fail; + 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)) + goto fail; + 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: + new_rs = alloc_reg_state (); + if (!new_rs) + { + Debug (1, "Out of memory in DW_CFA_remember_state\n"); + ret = -UNW_ENOMEM; + goto fail; + } + + memcpy (new_rs->reg, sr->rs_current.reg, sizeof (new_rs->reg)); + new_rs->next = rs_stack; + rs_stack = new_rs; + 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; + goto fail; + } + memcpy (&sr->rs_current.reg, &rs_stack->reg, sizeof (rs_stack->reg)); + old_rs = rs_stack; + rs_stack = rs_stack->next; + free_reg_state (old_rs); + 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)) + goto fail; + 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)) + goto fail; + 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) + goto fail; + 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) + goto fail; + 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) + goto fail; + 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) + goto fail; + + 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) + goto fail; + + /* 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) + goto fail; + + Debug (15, "CFA_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) + goto fail; + 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)) + goto fail; + 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; + goto fail; + } + } + ret = 0; + + fail: + /* Free the register-state stack, if not empty already. */ + while (rs_stack) + { + old_rs = rs_stack; + rs_stack = rs_stack->next; + free_reg_state (old_rs); + } + return ret; +} + +static int +fetch_proc_info (struct dwarf_cursor *c, unw_word_t ip, int need_unwind_info) +{ + 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 execution resume, 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; + + if (c->pi_valid && !need_unwind_info) + return 0; + + 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, need_unwind_info, + c->as_arg); + if (ret == -UNW_ENOINFO) + { + dynamic = 0; + if ((ret = tdep_find_proc_info (c, ip, need_unwind_info)) < 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, need_unwind_info); + + /* Update use_prev_instr for the next frame. */ + if (need_unwind_info) + { + assert(c->pi.unwind_info); + struct dwarf_cie_info *dci = c->pi.unwind_info; + c->use_prev_instr = ! dci->signal_frame; + } + + 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"); +#if 0 + /* Don't forget to set the ret_addr_column! */ + c->ret_addr_column = XXX; +#endif + return -UNW_ENOINFO; +} + +static inline void +put_unwind_info (struct dwarf_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 if (pi->unwind_info) + { + mempool_free (&dwarf_cie_info_pool, pi->unwind_info); + pi->unwind_info = NULL; + } +} + +static inline int +parse_fde (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr) +{ + struct dwarf_cie_info *dci; + unw_word_t addr; + int ret; + + dci = c->pi.unwind_info; + c->ret_addr_column = dci->ret_addr_column; + + addr = dci->cie_instr_start; + if ((ret = run_cfi_program (c, sr, ~(unw_word_t) 0, &addr, + dci->cie_instr_end, dci)) < 0) + return ret; + + memcpy (&sr->rs_initial, &sr->rs_current, sizeof (sr->rs_initial)); + + addr = dci->fde_instr_start; + if ((ret = run_cfi_program (c, sr, ip, &addr, dci->fde_instr_end, dci)) < 0) + return ret; + + return 0; +} + +static inline void +flush_rs_cache (struct dwarf_rs_cache *cache) +{ + int i; + + cache->lru_head = DWARF_UNW_CACHE_SIZE - 1; + cache->lru_tail = 0; + + for (i = 0; i < DWARF_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; + cache->buckets[i].valid = 0; + } + for (i = 0; ihash[i] = -1; +} + +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 (likely (caching == UNW_CACHE_GLOBAL)) + { + Debug (16, "%s: acquiring lock\n", __FUNCTION__); + lock_acquire (&cache->lock, *saved_maskp); + } + + if (atomic_read (&as->cache_generation) != atomic_read (&cache->generation)) + { + flush_rs_cache (cache); + 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 +hash (unw_word_t ip) +{ + /* based on (sqrt(5)/2-1)*2^64 */ +# define magic ((unw_word_t) 0x9e3779b97f4a7c16ULL) + + return ip * magic >> ((sizeof(unw_word_t) * 8) - DWARF_LOG_UNW_HASH_SIZE); +} + +static inline long +cache_match (dwarf_reg_state_t *rs, unw_word_t ip) +{ + if (rs->valid && (ip == rs->ip)) + return 1; + return 0; +} + +static dwarf_reg_state_t * +rs_lookup (struct dwarf_rs_cache *cache, struct dwarf_cursor *c) +{ + dwarf_reg_state_t *rs = cache->buckets + c->hint; + unsigned short index; + unw_word_t ip; + + ip = c->ip; + + if (cache_match (rs, ip)) + return rs; + + index = cache->hash[hash (ip)]; + if (index >= DWARF_UNW_CACHE_SIZE) + return 0; + + rs = cache->buckets + index; + while (1) + { + if (cache_match (rs, ip)) + { + /* update hint; no locking needed: single-word writes are atomic */ + c->hint = cache->buckets[c->prev_rs].hint = + (rs - cache->buckets); + return rs; + } + if (rs->coll_chain >= DWARF_UNW_HASH_SIZE) + return 0; + rs = cache->buckets + rs->coll_chain; + } +} + +static inline dwarf_reg_state_t * +rs_new (struct dwarf_rs_cache *cache, struct dwarf_cursor * c) +{ + dwarf_reg_state_t *rs, *prev, *tmp; + unw_hash_index_t index; + unsigned short head; + + head = cache->lru_head; + rs = cache->buckets + head; + cache->lru_head = rs->lru_chain; + + /* re-insert rs at the tail of the LRU chain: */ + cache->buckets[cache->lru_tail].lru_chain = head; + cache->lru_tail = head; + + /* remove the old rs from the hash table (if it's there): */ + if (rs->ip) + { + index = hash (rs->ip); + tmp = cache->buckets + cache->hash[index]; + prev = 0; + while (1) + { + if (tmp == rs) + { + if (prev) + prev->coll_chain = tmp->coll_chain; + else + cache->hash[index] = tmp->coll_chain; + break; + } + else + prev = tmp; + if (tmp->coll_chain >= DWARF_UNW_CACHE_SIZE) + /* old rs wasn't in the hash-table */ + break; + tmp = cache->buckets + tmp->coll_chain; + } + } + + /* enter new rs in the hash table */ + index = hash (c->ip); + rs->coll_chain = cache->hash[index]; + cache->hash[index] = rs - cache->buckets; + + rs->hint = 0; + rs->ip = c->ip; + rs->valid = 1; + rs->ret_addr_column = c->ret_addr_column; + rs->signal_frame = 0; + tdep_cache_frame (c, rs); + + return rs; +} + +static int +create_state_record_for (struct dwarf_cursor *c, dwarf_state_record_t *sr, + unw_word_t ip) +{ + 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); + + switch (c->pi.format) + { + case UNW_INFO_FORMAT_TABLE: + case UNW_INFO_FORMAT_REMOTE_TABLE: + 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 (as); + + /* Evaluate the CFA first, because it may be referred to by other + expressions. */ + + if (rs->reg[DWARF_CFA_REG_COLUMN].where == 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[DWARF_CFA_REG_COLUMN].val == UNW_TDEP_SP) + && (UNW_TDEP_SP < ARRAY_SIZE(rs->reg)) + && (rs->reg[UNW_TDEP_SP].where == DWARF_WHERE_SAME)) + cfa = c->cfa; + else + { + regnum = dwarf_to_unw_regnum (rs->reg[DWARF_CFA_REG_COLUMN].val); + if ((ret = unw_get_reg ((unw_cursor_t *) c, regnum, &cfa)) < 0) + return ret; + } + cfa += rs->reg[DWARF_CFA_OFF_COLUMN].val; + } + else + { + /* CFA is equal to EXPR: */ + + assert (rs->reg[DWARF_CFA_REG_COLUMN].where == DWARF_WHERE_EXPR); + + addr = rs->reg[DWARF_CFA_REG_COLUMN].val; + 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); + } + + for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) + { + switch ((dwarf_where_t) rs->reg[i].where) + { + case DWARF_WHERE_UNDEF: + c->loc[i] = DWARF_NULL_LOC; + break; + + case DWARF_WHERE_SAME: + break; + + case DWARF_WHERE_CFAREL: + c->loc[i] = DWARF_MEM_LOC (c, cfa + rs->reg[i].val); + break; + + case DWARF_WHERE_REG: + c->loc[i] = DWARF_REG_LOC (c, dwarf_to_unw_regnum (rs->reg[i].val)); + break; + + case DWARF_WHERE_EXPR: + addr = rs->reg[i].val; + if ((ret = eval_location_expr (c, as, a, addr, c->loc + i, arg)) < 0) + return ret; + break; + } + } + + c->cfa = cfa; + /* DWARF spec says undefined return address location means end of stack. */ + if (DWARF_IS_NULL_LOC (c->loc[c->ret_addr_column])) + c->ip = 0; + else + { + ret = dwarf_get (c, c->loc[c->ret_addr_column], &ip); + if (ret < 0) + return ret; + c->ip = ip; + } + + /* 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 0; +} + +static int +uncached_dwarf_find_save_locs (struct dwarf_cursor *c) +{ + dwarf_state_record_t sr; + int ret; + + if ((ret = fetch_proc_info (c, c->ip, 1)) < 0) + return ret; + + if ((ret = create_state_record_for (c, &sr, c->ip)) < 0) + return ret; + + if ((ret = apply_reg_state (c, &sr.rs_current)) < 0) + return ret; + + put_unwind_info (c, &c->pi); + return 0; +} + +/* The function finds the saved locations and applies the register + state as well. */ +HIDDEN int +dwarf_find_save_locs (struct dwarf_cursor *c) +{ + dwarf_state_record_t sr; + dwarf_reg_state_t *rs, rs_copy; + struct dwarf_rs_cache *cache; + int ret = 0; + intrmask_t saved_mask; + + if (c->as->caching_policy == UNW_CACHE_NONE) + return uncached_dwarf_find_save_locs (c); + + cache = get_rs_cache(c->as, &saved_mask); + rs = rs_lookup(cache, c); + + if (rs) + { + c->ret_addr_column = rs->ret_addr_column; + c->use_prev_instr = ! rs->signal_frame; + } + else + { + if ((ret = fetch_proc_info (c, c->ip, 1)) < 0 || + (ret = create_state_record_for (c, &sr, c->ip)) < 0) + { + put_rs_cache (c->as, cache, &saved_mask); + return ret; + } + + rs = rs_new (cache, c); + memcpy(rs, &sr.rs_current, offsetof(struct dwarf_reg_state, ip)); + cache->buckets[c->prev_rs].hint = rs - cache->buckets; + + c->hint = rs->hint; + c->prev_rs = rs - cache->buckets; + + put_unwind_info (c, &c->pi); + } + + memcpy (&rs_copy, rs, sizeof (rs_copy)); + put_rs_cache (c->as, cache, &saved_mask); + + tdep_reuse_frame (c, &rs_copy); + if ((ret = apply_reg_state (c, &rs_copy)) < 0) + return ret; + + return 0; +} + +/* The proc-info must be valid for IP before this routine can be + called. */ +HIDDEN int +dwarf_create_state_record (struct dwarf_cursor *c, dwarf_state_record_t *sr) +{ + return create_state_record_for (c, sr, c->ip); +} + +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 + /* Lookup it up the slow way... */ + return fetch_proc_info (c, c->ip, 0); + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Gpe.c b/sdk/cpprt/linux/libunwind/src/dwarf/Gpe.c new file mode 100644 index 0000000000..c271d76343 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Gpe.c @@ -0,0 +1,39 @@ +/* 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/sdk/cpprt/linux/libunwind/src/dwarf/Gstep.c b/sdk/cpprt/linux/libunwind/src/dwarf/Gstep.c new file mode 100644 index 0000000000..7d899ded1c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Gstep.c @@ -0,0 +1,41 @@ +/* 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.h" +#include "libunwind_i.h" + +HIDDEN int +dwarf_step (struct dwarf_cursor *c) +{ + int ret; + + if ((ret = dwarf_find_save_locs (c)) >= 0) { + c->pi_valid = 0; + ret = 1; + } + + Debug (15, "returning %d\n", ret); + return ret; +} diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Lexpr.c b/sdk/cpprt/linux/libunwind/src/dwarf/Lexpr.c new file mode 100644 index 0000000000..245970c9e3 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Lexpr.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gexpr.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Lfde.c b/sdk/cpprt/linux/libunwind/src/dwarf/Lfde.c new file mode 100644 index 0000000000..e779e8f192 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Lfde.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gfde.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Lfind_proc_info-lsb.c b/sdk/cpprt/linux/libunwind/src/dwarf/Lfind_proc_info-lsb.c new file mode 100644 index 0000000000..27a5eeac18 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Lfind_proc_info-lsb.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gfind_proc_info-lsb.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Lfind_unwind_table.c b/sdk/cpprt/linux/libunwind/src/dwarf/Lfind_unwind_table.c new file mode 100644 index 0000000000..68e269f1d7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Lfind_unwind_table.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gfind_unwind_table.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Lparser.c b/sdk/cpprt/linux/libunwind/src/dwarf/Lparser.c new file mode 100644 index 0000000000..f23aaf48e9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Lparser.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gparser.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Lpe.c b/sdk/cpprt/linux/libunwind/src/dwarf/Lpe.c new file mode 100644 index 0000000000..a672358f06 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Lpe.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gpe.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/Lstep.c b/sdk/cpprt/linux/libunwind/src/dwarf/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/dwarf/global.c b/sdk/cpprt/linux/libunwind/src/dwarf/global.c new file mode 100644 index 0000000000..4658ccfe88 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/dwarf/global.c @@ -0,0 +1,37 @@ +/* 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_reg_state_t), 0); + mempool_init (&dwarf_cie_info_pool, sizeof (struct dwarf_cie_info), 0); + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/elf32.c b/sdk/cpprt/linux/libunwind/src/elf32.c new file mode 100644 index 0000000000..a70bb58f24 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/elf32.c @@ -0,0 +1,4 @@ +#ifndef UNW_REMOTE_ONLY +# include "elf32.h" +# include "elfxx.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/elf32.h b/sdk/cpprt/linux/libunwind/src/elf32.h new file mode 100644 index 0000000000..63fef83637 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/elf32.h @@ -0,0 +1,9 @@ +#ifndef elf32_h +#define elf32_h + +#ifndef ELF_CLASS +#define ELF_CLASS ELFCLASS32 +#endif +#include "elfxx.h" + +#endif /* elf32_h */ diff --git a/sdk/cpprt/linux/libunwind/src/elf64.c b/sdk/cpprt/linux/libunwind/src/elf64.c new file mode 100644 index 0000000000..195b887948 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/elf64.c @@ -0,0 +1,4 @@ +#ifndef UNW_REMOTE_ONLY +# include "elf64.h" +# include "elfxx.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/elf64.h b/sdk/cpprt/linux/libunwind/src/elf64.h new file mode 100644 index 0000000000..fd10ed824c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/elf64.h @@ -0,0 +1,9 @@ +#ifndef elf64_h +#define elf64_h + +#ifndef ELF_CLASS +#define ELF_CLASS ELFCLASS64 +#endif +#include "elfxx.h" + +#endif /* elf64_h */ diff --git a/sdk/cpprt/linux/libunwind/src/elfxx.c b/sdk/cpprt/linux/libunwind/src/elfxx.c new file mode 100644 index 0000000000..844cc1c98a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/elfxx.c @@ -0,0 +1,174 @@ +/* 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 "libunwind_i.h" + +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, unw_word_t *offp) +{ + size_t syment_size; + Elf_W (Ehdr) *ehdr = ei->image; + Elf_W (Sym) *sym, *symtab, *symtab_end; + Elf_W (Off) soff, str_soff; + Elf_W (Shdr) *shdr, *str_shdr; + Elf_W (Addr) val, min_dist = ~(Elf_W (Addr))0; + int i, ret = 0; + char *strtab; + + if (!elf_w (valid_object) (ei)) + return -UNW_ENOINFO; + + 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 -UNW_ENOINFO; + } + + shdr = (Elf_W (Shdr) *) ((char *) ei->image + soff); + + 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; + + str_soff = soff + (shdr->sh_link * ehdr->e_shentsize); + if (str_soff + ehdr->e_shentsize >= ei->size) + { + Debug (1, "string table outside of image? (%lu >= %lu)\n", + (unsigned long) (str_soff + ehdr->e_shentsize), + (unsigned long) ei->size); + break; + } + str_shdr = (Elf_W (Shdr) *) ((char *) ei->image + str_soff); + strtab = (char *) ei->image + str_shdr->sh_offset; + + Debug (16, "symtab=0x%lx[%d], strtab=0x%lx\n", + (long) shdr->sh_offset, shdr->sh_type, + (long) str_shdr->sh_offset); + + 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) + { + if (tdep_get_func_addr (as, sym->st_value, &val) < 0) + continue; + if (sym->st_shndx != SHN_ABS) + val += load_offset; + 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'; + if (strlen (strtab + sym->st_name) >= buf_len) + ret = -UNW_ENOMEM; + } + } + } + break; + + default: + break; + } + shdr = (Elf_W (Shdr) *) (((char *) shdr) + ehdr->e_shentsize); + } + if (min_dist >= ei->size) + return -UNW_ENOINFO; /* not found */ + if (offp) + *offp = min_dist; + return ret; +} + +/* 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 = 0; + Elf_W (Ehdr) *ehdr; + Elf_W (Phdr) *phdr; + int i, ret; + + 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) + { + load_offset = segbase - phdr[i].p_vaddr; + break; + } + + ret = elf_w (lookup_symbol) (as, ip, ei, load_offset, buf, buf_len, offp); + + 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; + + ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, NULL, 0); + 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; +} diff --git a/sdk/cpprt/linux/libunwind/src/elfxx.h b/sdk/cpprt/linux/libunwind/src/elfxx.h new file mode 100644 index 0000000000..fd4ef4d926 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/elfxx.h @@ -0,0 +1,108 @@ +/* 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 + +#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 + +#include "libunwind_i.h" + +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 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); + +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) +{ +#if HAVE_SGX + return -1; +#else + 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; +#endif +} diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Gcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/hppa/Gcreate_addr_space.c new file mode 100644 index 0000000000..8f4301feb6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gcreate_addr_space.c @@ -0,0 +1,52 @@ +/* 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" + +PROTECTED 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; + + /* + * hppa supports only big-endian. + */ + if (byte_order != 0 && byte_order != __BIG_ENDIAN) + return NULL; + return as; +#endif +} diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Gget_proc_info.c b/sdk/cpprt/linux/libunwind/src/hppa/Gget_proc_info.c new file mode 100644 index 0000000000..8d2c1fd9df --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gget_proc_info.c @@ -0,0 +1,46 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/hppa/Gget_save_loc.c b/sdk/cpprt/linux/libunwind/src/hppa/Gget_save_loc.c new file mode 100644 index 0000000000..1b2191911a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gget_save_loc.c @@ -0,0 +1,59 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/hppa/Gglobal.c b/sdk/cpprt/linux/libunwind/src/hppa/Gglobal.c new file mode 100644 index 0000000000..f453a43b96 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gglobal.c @@ -0,0 +1,55 @@ +/* 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 pthread_mutex_t hppa_lock = PTHREAD_MUTEX_INITIALIZER; +HIDDEN int tdep_needs_initialization = 1; + +HIDDEN void +tdep_init (void) +{ + intrmask_t saved_mask; + + sigfillset (&unwi_full_mask); + + lock_acquire (&hppa_lock, saved_mask); + { + if (!tdep_needs_initialization) + /* another thread else beat us to it... */ + goto out; + + mi_init (); + + dwarf_init (); + +#ifndef UNW_REMOTE_ONLY + hppa_local_addr_space_init (); +#endif + tdep_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&hppa_lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Ginit.c b/sdk/cpprt/linux/libunwind/src/hppa/Ginit.c new file mode 100644 index 0000000000..5326b82985 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Ginit.c @@ -0,0 +1,194 @@ +/* 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. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED 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 = UNW_CACHE_GLOBAL; + 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/sdk/cpprt/linux/libunwind/src/hppa/Ginit_local.c b/sdk/cpprt/linux/libunwind/src/hppa/Ginit_local.c new file mode 100644 index 0000000000..6d4dd3df92 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Ginit_local.c @@ -0,0 +1,54 @@ +/* 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 + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + return -UNW_EINVAL; +} + +#else /* !UNW_REMOTE_ONLY */ + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + struct cursor *c = (struct cursor *) cursor; + + if (tdep_needs_initialization) + tdep_init (); + + Debug (1, "(cursor=%p)\n", c); + + c->dwarf.as = unw_local_addr_space; + c->dwarf.as_arg = uc; + return common_init (c, 1); +} + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Ginit_remote.c b/sdk/cpprt/linux/libunwind/src/hppa/Ginit_remote.c new file mode 100644 index 0000000000..bd6093f10f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Ginit_remote.c @@ -0,0 +1,46 @@ +/* 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" + +PROTECTED 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_needs_initialization) + 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/sdk/cpprt/linux/libunwind/src/hppa/Gis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/hppa/Gis_signal_frame.c new file mode 100644 index 0000000000..202b570332 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gis_signal_frame.c @@ -0,0 +1,74 @@ +/* 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" + +PROTECTED 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 (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/sdk/cpprt/linux/libunwind/src/hppa/Gregs.c b/sdk/cpprt/linux/libunwind/src/hppa/Gregs.c new file mode 100644 index 0000000000..e6d84e32a2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gregs.c @@ -0,0 +1,87 @@ +/* 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/sdk/cpprt/linux/libunwind/src/hppa/Gresume.c b/sdk/cpprt/linux/libunwind/src/hppa/Gresume.c new file mode 100644 index 0000000000..92d506dcea --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gresume.c @@ -0,0 +1,145 @@ +/* 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; +} + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/hppa/Gstep.c b/sdk/cpprt/linux/libunwind/src/hppa/Gstep.c new file mode 100644 index 0000000000..abff456912 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Gstep.c @@ -0,0 +1,96 @@ +/* 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" + +PROTECTED 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; + c->dwarf.ret_addr_column = UNW_HPPA_RP; + + 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/sdk/cpprt/linux/libunwind/src/hppa/Lcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/hppa/Lcreate_addr_space.c new file mode 100644 index 0000000000..0f2dc6be90 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lcreate_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gcreate_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Lget_proc_info.c b/sdk/cpprt/linux/libunwind/src/hppa/Lget_proc_info.c new file mode 100644 index 0000000000..69028b019f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lget_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Lget_save_loc.c b/sdk/cpprt/linux/libunwind/src/hppa/Lget_save_loc.c new file mode 100644 index 0000000000..9ea048a907 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lget_save_loc.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_save_loc.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Lglobal.c b/sdk/cpprt/linux/libunwind/src/hppa/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Linit.c b/sdk/cpprt/linux/libunwind/src/hppa/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Linit_local.c b/sdk/cpprt/linux/libunwind/src/hppa/Linit_local.c new file mode 100644 index 0000000000..68a1687e85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Linit_local.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_local.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Linit_remote.c b/sdk/cpprt/linux/libunwind/src/hppa/Linit_remote.c new file mode 100644 index 0000000000..58cb04ab7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Linit_remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Lis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/hppa/Lis_signal_frame.c new file mode 100644 index 0000000000..b9a7c4f51a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lis_signal_frame.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gis_signal_frame.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Lregs.c b/sdk/cpprt/linux/libunwind/src/hppa/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Lresume.c b/sdk/cpprt/linux/libunwind/src/hppa/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/Lstep.c b/sdk/cpprt/linux/libunwind/src/hppa/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/hppa/get_accessors.c b/sdk/cpprt/linux/libunwind/src/hppa/get_accessors.c new file mode 100644 index 0000000000..b6bd49a767 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/get_accessors.c @@ -0,0 +1,37 @@ +/* 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" + +PROTECTED unw_accessors_t * +unw_get_accessors (unw_addr_space_t as) +{ + if (hppa_needs_initialization) + { + hppa_needs_initialization = 0; + hppa_init (); + } + return &as->acc; +} diff --git a/sdk/cpprt/linux/libunwind/src/hppa/getcontext.S b/sdk/cpprt/linux/libunwind/src/hppa/getcontext.S new file mode 100644 index 0000000000..ec7554a025 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/getcontext.S @@ -0,0 +1,74 @@ +/* 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/sdk/cpprt/linux/libunwind/src/hppa/init.h b/sdk/cpprt/linux/libunwind/src/hppa/init.h new file mode 100644 index 0000000000..6fabb1543e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/init.h @@ -0,0 +1,47 @@ +/* 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->ip_loc = HPPA_REG_LOC (c, UNW_HPPA_IP); + c->sp_loc = HPPA_REG_LOC (c, UNW_HPPA_SP); + + ret = hppa_get (c, c->ip_loc, &c->ip); + if (ret < 0) + return ret; + + ret = hppa_get (c, HPPA_REG_LOC (c, UNW_HPPA_SP), &c->sp); + if (ret < 0) + return ret; + + c->dwarf.stash_frames = 0; + c->dwarf.use_prev_instr = use_prev_instr; + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/hppa/offsets.h b/sdk/cpprt/linux/libunwind/src/hppa/offsets.h new file mode 100644 index 0000000000..d824770b4a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/offsets.h @@ -0,0 +1,17 @@ +#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/sdk/cpprt/linux/libunwind/src/hppa/regname.c b/sdk/cpprt/linux/libunwind/src/hppa/regname.c new file mode 100644 index 0000000000..07cae8ed82 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/regname.c @@ -0,0 +1,50 @@ +/* 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" + }; + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) + return regname[reg]; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/hppa/setcontext.S b/sdk/cpprt/linux/libunwind/src/hppa/setcontext.S new file mode 100644 index 0000000000..a36ea35cc6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/setcontext.S @@ -0,0 +1,77 @@ +/* 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/sdk/cpprt/linux/libunwind/src/hppa/siglongjmp.S b/sdk/cpprt/linux/libunwind/src/hppa/siglongjmp.S new file mode 100644 index 0000000000..34878dbe8f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/siglongjmp.S @@ -0,0 +1,16 @@ + /* 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/sdk/cpprt/linux/libunwind/src/hppa/tables.c b/sdk/cpprt/linux/libunwind/src/hppa/tables.c new file mode 100644 index 0000000000..383b4495c9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/tables.c @@ -0,0 +1,43 @@ +#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/sdk/cpprt/linux/libunwind/src/hppa/unwind_i.h b/sdk/cpprt/linux/libunwind/src/hppa/unwind_i.h new file mode 100644 index 0000000000..d3c11be86f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/hppa/unwind_i.h @@ -0,0 +1,48 @@ +/* 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 + +#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/sdk/cpprt/linux/libunwind/src/ia64/Gcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/ia64/Gcreate_addr_space.c new file mode 100644 index 0000000000..a3524a0ae9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gcreate_addr_space.c @@ -0,0 +1,63 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ia64/Gfind_unwind_table.c b/sdk/cpprt/linux/libunwind/src/ia64/Gfind_unwind_table.c new file mode 100644 index 0000000000..f7d3168870 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gfind_unwind_table.c @@ -0,0 +1,143 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/Gget_proc_info.c b/sdk/cpprt/linux/libunwind/src/ia64/Gget_proc_info.c new file mode 100644 index 0000000000..21015d4249 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gget_proc_info.c @@ -0,0 +1,38 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ia64/Gget_save_loc.c b/sdk/cpprt/linux/libunwind/src/ia64/Gget_save_loc.c new file mode 100644 index 0000000000..49bdaba1bf --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gget_save_loc.c @@ -0,0 +1,168 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ia64/Gglobal.c b/sdk/cpprt/linux/libunwind/src/ia64/Gglobal.c new file mode 100644 index 0000000000..b04a5783f4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gglobal.c @@ -0,0 +1,123 @@ +/* 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 = + { + .needs_initialization = 1, + .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) +{ + uint8_t f1_bytes[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + uint8_t nat_val_bytes[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfe, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + 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_needs_initialization) + /* 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_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&unw.lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Ginit.c b/sdk/cpprt/linux/libunwind/src/ia64/Ginit.c new file mode 100644 index 0000000000..5afa9ab19b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Ginit.c @@ -0,0 +1,505 @@ +/* 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. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED 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 = UNW_CACHE_GLOBAL; + 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/sdk/cpprt/linux/libunwind/src/ia64/Ginit_local.c b/sdk/cpprt/linux/libunwind/src/ia64/Ginit_local.c new file mode 100644 index 0000000000..42f8b1f069 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Ginit_local.c @@ -0,0 +1,110 @@ +/* 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 + +PROTECTED 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; +} + +PROTECTED 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_needs_initialization) + 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/sdk/cpprt/linux/libunwind/src/ia64/Ginit_remote.c b/sdk/cpprt/linux/libunwind/src/ia64/Ginit_remote.c new file mode 100644 index 0000000000..ae0b718c04 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Ginit_remote.c @@ -0,0 +1,61 @@ +/* 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" + +PROTECTED 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_needs_initialization) + 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/sdk/cpprt/linux/libunwind/src/ia64/Ginstall_cursor.S b/sdk/cpprt/linux/libunwind/src/ia64/Ginstall_cursor.S new file mode 100644 index 0000000000..6fb4401faa --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Ginstall_cursor.S @@ -0,0 +1,348 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/Gis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/ia64/Gis_signal_frame.c new file mode 100644 index 0000000000..cc69bd6336 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gis_signal_frame.c @@ -0,0 +1,54 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ia64/Gparser.c b/sdk/cpprt/linux/libunwind/src/ia64/Gparser.c new file mode 100644 index 0000000000..88ea90f40a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gparser.c @@ -0,0 +1,1131 @@ +/* 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 __attribute__ ((const)) +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/sdk/cpprt/linux/libunwind/src/ia64/Grbs.c b/sdk/cpprt/linux/libunwind/src/ia64/Grbs.c new file mode 100644 index 0000000000..4230cf303e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Grbs.c @@ -0,0 +1,319 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/Gregs.c b/sdk/cpprt/linux/libunwind/src/ia64/Gregs.c new file mode 100644 index 0000000000..f3e40753af --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gregs.c @@ -0,0 +1,612 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/Gresume.c b/sdk/cpprt/linux/libunwind/src/ia64/Gresume.c new file mode 100644 index 0000000000..fe23f76651 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gresume.c @@ -0,0 +1,274 @@ +/* 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 */ + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ia64/Gscript.c b/sdk/cpprt/linux/libunwind/src/ia64/Gscript.c new file mode 100644 index 0000000000..b3e8ef6ebc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gscript.c @@ -0,0 +1,765 @@ +/* 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 */ + }; + +#ifdef 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 +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 +# ifdef 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, "%s: acquiring lock\n", __FUNCTION__); + 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/sdk/cpprt/linux/libunwind/src/ia64/Gstep.c b/sdk/cpprt/linux/libunwind/src/ia64/Gstep.c new file mode 100644 index 0000000000..e63291078e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gstep.c @@ -0,0 +1,359 @@ +/* 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; +} + + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ia64/Gtables.c b/sdk/cpprt/linux/libunwind/src/ia64/Gtables.c new file mode 100644 index 0000000000..5ed72f0a9f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Gtables.c @@ -0,0 +1,729 @@ +/* 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 (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 (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; + } +} + +PROTECTED 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 (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; +} + +PROTECTED 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; + struct ia64_table_entry ent; + int ret, is_local; + + 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. */ +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ia64/Lcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/ia64/Lcreate_addr_space.c new file mode 100644 index 0000000000..0f2dc6be90 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lcreate_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gcreate_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lfind_unwind_table.c b/sdk/cpprt/linux/libunwind/src/ia64/Lfind_unwind_table.c new file mode 100644 index 0000000000..68e269f1d7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lfind_unwind_table.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gfind_unwind_table.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lget_proc_info.c b/sdk/cpprt/linux/libunwind/src/ia64/Lget_proc_info.c new file mode 100644 index 0000000000..69028b019f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lget_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lget_save_loc.c b/sdk/cpprt/linux/libunwind/src/ia64/Lget_save_loc.c new file mode 100644 index 0000000000..9ea048a907 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lget_save_loc.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_save_loc.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lglobal.c b/sdk/cpprt/linux/libunwind/src/ia64/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Linit.c b/sdk/cpprt/linux/libunwind/src/ia64/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Linit_local.c b/sdk/cpprt/linux/libunwind/src/ia64/Linit_local.c new file mode 100644 index 0000000000..68a1687e85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Linit_local.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_local.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Linit_remote.c b/sdk/cpprt/linux/libunwind/src/ia64/Linit_remote.c new file mode 100644 index 0000000000..58cb04ab7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Linit_remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Linstall_cursor.S b/sdk/cpprt/linux/libunwind/src/ia64/Linstall_cursor.S new file mode 100644 index 0000000000..8c72339725 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Linstall_cursor.S @@ -0,0 +1,6 @@ +#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/sdk/cpprt/linux/libunwind/src/ia64/Lis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/ia64/Lis_signal_frame.c new file mode 100644 index 0000000000..b9a7c4f51a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lis_signal_frame.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gis_signal_frame.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lparser.c b/sdk/cpprt/linux/libunwind/src/ia64/Lparser.c new file mode 100644 index 0000000000..f23aaf48e9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lparser.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gparser.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lrbs.c b/sdk/cpprt/linux/libunwind/src/ia64/Lrbs.c new file mode 100644 index 0000000000..a91b5f2979 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lrbs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Grbs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lregs.c b/sdk/cpprt/linux/libunwind/src/ia64/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lresume.c b/sdk/cpprt/linux/libunwind/src/ia64/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lscript.c b/sdk/cpprt/linux/libunwind/src/ia64/Lscript.c new file mode 100644 index 0000000000..57b926bf80 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lscript.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gscript.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Lstep.c b/sdk/cpprt/linux/libunwind/src/ia64/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/Ltables.c b/sdk/cpprt/linux/libunwind/src/ia64/Ltables.c new file mode 100644 index 0000000000..876b0aac03 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/Ltables.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gtables.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ia64/NOTES b/sdk/cpprt/linux/libunwind/src/ia64/NOTES new file mode 100644 index 0000000000..a5805e8345 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/NOTES @@ -0,0 +1,65 @@ +- 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/sdk/cpprt/linux/libunwind/src/ia64/dyn_info_list.S b/sdk/cpprt/linux/libunwind/src/ia64/dyn_info_list.S new file mode 100644 index 0000000000..31265f66a0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/dyn_info_list.S @@ -0,0 +1,26 @@ +#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/sdk/cpprt/linux/libunwind/src/ia64/getcontext.S b/sdk/cpprt/linux/libunwind/src/ia64/getcontext.S new file mode 100644 index 0000000000..d8da732acc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/getcontext.S @@ -0,0 +1,177 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/init.h b/sdk/cpprt/linux/libunwind/src/ia64/init.h new file mode 100644 index 0000000000..d6a1b2277f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/init.h @@ -0,0 +1,134 @@ +/* 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; + uint8_t *natp; + 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); + + natp = c->nat_bitnr; + c->loc[IA64_REG_NAT4] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 4, &natp[0]); + c->loc[IA64_REG_NAT5] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 5, &natp[1]); + c->loc[IA64_REG_NAT6] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 6, &natp[2]); + c->loc[IA64_REG_NAT7] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 7, &natp[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/sdk/cpprt/linux/libunwind/src/ia64/longjmp.S b/sdk/cpprt/linux/libunwind/src/ia64/longjmp.S new file mode 100644 index 0000000000..2a2f286594 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/longjmp.S @@ -0,0 +1,42 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/mk_Gcursor_i.c b/sdk/cpprt/linux/libunwind/src/ia64/mk_Gcursor_i.c new file mode 100644 index 0000000000..51cb0f4088 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/mk_Gcursor_i.c @@ -0,0 +1,106 @@ +/* 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. */ + +/* Utility to generate cursor_i.h. */ + +#include + +#include "libunwind_i.h" + +#ifdef offsetof +# undef offsetof +#endif + +#define offsetof(type,field) ((char *) &((type *) 0)->field - (char *) 0) + +static struct + { + const char name[256]; + unsigned long value; + } +tab[] = + { + { "IP_OFF", offsetof (struct cursor, ip) }, + { "PR_OFF", offsetof (struct cursor, pr) }, + { "BSP_OFF", offsetof (struct cursor, bsp) }, + { "PSP_OFF", offsetof (struct cursor, psp) }, + { "PFS_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_PFS]) }, + { "RNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_RNAT]) }, + { "UNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_UNAT]) }, + { "LC_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_LC]) }, + { "FPSR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_FPSR]) }, + { "B1_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B1]) }, + { "B2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B2]) }, + { "B3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B3]) }, + { "B4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B4]) }, + { "B5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B5]) }, + { "F2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F2]) }, + { "F3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F3]) }, + { "F4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F4]) }, + { "F5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F5]) }, + { "FR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F16]) }, + { "LOC_SIZE", + (offsetof (struct cursor, loc[1]) - offsetof (struct cursor, loc[0])) + }, + { "SIGCONTEXT_ADDR_OFF", offsetof (struct cursor, sigcontext_addr) }, +}; + +static const char *tabs = "\t\t\t\t\t\t\t\t\t\t"; + +int +main (int argc, char **argv) +{ + const char *space; + int i, num_tabs; + size_t len; + + printf ("#ifndef cursor_i_h\n"); + printf ("#define cursor_i_h\n\n"); + + printf ("/*\n * DO NOT MODIFY\n *\n * This file was generated by " + "%s.\n *\n */\n\n", argv[0]); + + for (i = 0; i < (int) (sizeof (tab) / sizeof (tab[0])); ++i) + { + if (tab[i].name[0] == '\0') + printf ("\n"); + else + { + len = strlen (tab[i].name); + + num_tabs = (40 - len) / 8; + if (num_tabs <= 0) + space = " "; + else + space = strchr(tabs, '\0') - (40 - len) / 8; + + printf ("#define %s%s%lu\t/* 0x%lx */\n", + tab[i].name, space, tab[i].value, tab[i].value); + } + } + + printf ("\n#endif /* cursor_i_h */\n"); + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/ia64/mk_Lcursor_i.c b/sdk/cpprt/linux/libunwind/src/ia64/mk_Lcursor_i.c new file mode 100644 index 0000000000..aee2e7eeb8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/mk_Lcursor_i.c @@ -0,0 +1,2 @@ +#define UNW_LOCAL_ONLY +#include "mk_Gcursor_i.c" diff --git a/sdk/cpprt/linux/libunwind/src/ia64/offsets.h b/sdk/cpprt/linux/libunwind/src/ia64/offsets.h new file mode 100644 index 0000000000..b169933b8d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/offsets.h @@ -0,0 +1,137 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/regname.c b/sdk/cpprt/linux/libunwind/src/ia64/regname.c new file mode 100644 index 0000000000..4936a3d20e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/regname.c @@ -0,0 +1,189 @@ +/* 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) + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < NREGS) + return regname_str + reg * regname_len; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/ia64/regs.h b/sdk/cpprt/linux/libunwind/src/ia64/regs.h new file mode 100644 index 0000000000..1e748bbe13 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/regs.h @@ -0,0 +1,73 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/setjmp.S b/sdk/cpprt/linux/libunwind/src/ia64/setjmp.S new file mode 100644 index 0000000000..384615b840 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/setjmp.S @@ -0,0 +1,51 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/siglongjmp.S b/sdk/cpprt/linux/libunwind/src/ia64/siglongjmp.S new file mode 100644 index 0000000000..d77b43753b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/siglongjmp.S @@ -0,0 +1,69 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/sigsetjmp.S b/sdk/cpprt/linux/libunwind/src/ia64/sigsetjmp.S new file mode 100644 index 0000000000..02f7af4b37 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/sigsetjmp.S @@ -0,0 +1,69 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/ucontext_i.h b/sdk/cpprt/linux/libunwind/src/ia64/ucontext_i.h new file mode 100644 index 0000000000..34171fdf58 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/ucontext_i.h @@ -0,0 +1,68 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/unwind_decoder.h b/sdk/cpprt/linux/libunwind/src/ia64/unwind_decoder.h new file mode 100644 index 0000000000..f12c21d1b0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/unwind_decoder.h @@ -0,0 +1,477 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ia64/unwind_i.h b/sdk/cpprt/linux/libunwind/src/ia64/unwind_i.h new file mode 100644 index 0000000000..4643975227 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ia64/unwind_i.h @@ -0,0 +1,633 @@ +/* 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/sdk/cpprt/linux/libunwind/src/mi/Gdestroy_addr_space.c b/sdk/cpprt/linux/libunwind/src/mi/Gdestroy_addr_space.c new file mode 100644 index 0000000000..83a01b9204 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gdestroy_addr_space.c @@ -0,0 +1,37 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/mi/Gdyn-extract.c b/sdk/cpprt/linux/libunwind/src/mi/Gdyn-extract.c new file mode 100644 index 0000000000..5258839f28 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gdyn-extract.c @@ -0,0 +1,62 @@ +/* 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: +#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/sdk/cpprt/linux/libunwind/src/mi/Gdyn-remote.c b/sdk/cpprt/linux/libunwind/src/mi/Gdyn-remote.c new file mode 100644 index 0000000000..2bb5474557 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gdyn-remote.c @@ -0,0 +1,330 @@ +/* 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 (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) + break; + + 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)); + if (!di) + return -UNW_ENOMEM; + } + + 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) + break; + } + 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 (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/sdk/cpprt/linux/libunwind/src/mi/Gfind_dynamic_proc_info.c b/sdk/cpprt/linux/libunwind/src/mi/Gfind_dynamic_proc_info.c new file mode 100644 index 0000000000..6cf3b4273d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gfind_dynamic_proc_info.c @@ -0,0 +1,91 @@ +/* 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/sdk/cpprt/linux/libunwind/src/mi/Gget_accessors.c b/sdk/cpprt/linux/libunwind/src/mi/Gget_accessors.c new file mode 100644 index 0000000000..fb256d7094 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gget_accessors.c @@ -0,0 +1,34 @@ +/* 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" + +PROTECTED unw_accessors_t * +unw_get_accessors (unw_addr_space_t as) +{ + if (tdep_needs_initialization) + tdep_init (); + return &as->acc; +} diff --git a/sdk/cpprt/linux/libunwind/src/mi/Gget_fpreg.c b/sdk/cpprt/linux/libunwind/src/mi/Gget_fpreg.c new file mode 100644 index 0000000000..a9ae9bf6dd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gget_fpreg.c @@ -0,0 +1,34 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/mi/Gget_proc_info_by_ip.c b/sdk/cpprt/linux/libunwind/src/mi/Gget_proc_info_by_ip.c new file mode 100644 index 0000000000..4c9de7702a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gget_proc_info_by_ip.c @@ -0,0 +1,39 @@ +/* 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" + +PROTECTED 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 (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/sdk/cpprt/linux/libunwind/src/mi/Gget_proc_name.c b/sdk/cpprt/linux/libunwind/src/mi/Gget_proc_name.c new file mode 100644 index 0000000000..7251c5910d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gget_proc_name.c @@ -0,0 +1,106 @@ +/* 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 (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; +} + +PROTECTED 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; + + return get_proc_name (tdep_get_as (c), tdep_get_ip (c), buf, buf_len, offp, + tdep_get_as_arg (c)); +} diff --git a/sdk/cpprt/linux/libunwind/src/mi/Gget_reg.c b/sdk/cpprt/linux/libunwind/src/mi/Gget_reg.c new file mode 100644 index 0000000000..021d913e73 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gget_reg.c @@ -0,0 +1,41 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/mi/Gput_dynamic_unwind_info.c b/sdk/cpprt/linux/libunwind/src/mi/Gput_dynamic_unwind_info.c new file mode 100644 index 0000000000..13a9c1abfc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gput_dynamic_unwind_info.c @@ -0,0 +1,55 @@ +/* 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/sdk/cpprt/linux/libunwind/src/mi/Gset_caching_policy.c b/sdk/cpprt/linux/libunwind/src/mi/Gset_caching_policy.c new file mode 100644 index 0000000000..52fc7e54e2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gset_caching_policy.c @@ -0,0 +1,46 @@ +/* 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" + +PROTECTED int +unw_set_caching_policy (unw_addr_space_t as, unw_caching_policy_t policy) +{ + if (tdep_needs_initialization) + tdep_init (); + +#ifndef 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/sdk/cpprt/linux/libunwind/src/mi/Gset_fpreg.c b/sdk/cpprt/linux/libunwind/src/mi/Gset_fpreg.c new file mode 100644 index 0000000000..d3b202de1a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gset_fpreg.c @@ -0,0 +1,34 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/mi/Gset_reg.c b/sdk/cpprt/linux/libunwind/src/mi/Gset_reg.c new file mode 100644 index 0000000000..09fa09a39f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Gset_reg.c @@ -0,0 +1,34 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/mi/Ldestroy_addr_space.c b/sdk/cpprt/linux/libunwind/src/mi/Ldestroy_addr_space.c new file mode 100644 index 0000000000..5bf9364bc7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Ldestroy_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gdestroy_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Ldyn-extract.c b/sdk/cpprt/linux/libunwind/src/mi/Ldyn-extract.c new file mode 100644 index 0000000000..1802f865f7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Ldyn-extract.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gdyn-extract.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Ldyn-remote.c b/sdk/cpprt/linux/libunwind/src/mi/Ldyn-remote.c new file mode 100644 index 0000000000..260722a04b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Ldyn-remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gdyn-remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lfind_dynamic_proc_info.c b/sdk/cpprt/linux/libunwind/src/mi/Lfind_dynamic_proc_info.c new file mode 100644 index 0000000000..bc88e1c53f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lfind_dynamic_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gfind_dynamic_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lget_accessors.c b/sdk/cpprt/linux/libunwind/src/mi/Lget_accessors.c new file mode 100644 index 0000000000..555e37f30d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lget_accessors.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_accessors.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lget_fpreg.c b/sdk/cpprt/linux/libunwind/src/mi/Lget_fpreg.c new file mode 100644 index 0000000000..e3be441437 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lget_fpreg.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_fpreg.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lget_proc_info_by_ip.c b/sdk/cpprt/linux/libunwind/src/mi/Lget_proc_info_by_ip.c new file mode 100644 index 0000000000..96910d83e4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lget_proc_info_by_ip.c @@ -0,0 +1,5 @@ +#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/sdk/cpprt/linux/libunwind/src/mi/Lget_proc_name.c b/sdk/cpprt/linux/libunwind/src/mi/Lget_proc_name.c new file mode 100644 index 0000000000..378097b57a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lget_proc_name.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_name.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lget_reg.c b/sdk/cpprt/linux/libunwind/src/mi/Lget_reg.c new file mode 100644 index 0000000000..effe8a8063 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lget_reg.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_reg.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lput_dynamic_unwind_info.c b/sdk/cpprt/linux/libunwind/src/mi/Lput_dynamic_unwind_info.c new file mode 100644 index 0000000000..99597cd5fa --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lput_dynamic_unwind_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gput_dynamic_unwind_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lset_caching_policy.c b/sdk/cpprt/linux/libunwind/src/mi/Lset_caching_policy.c new file mode 100644 index 0000000000..cc18816b37 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lset_caching_policy.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gset_caching_policy.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lset_fpreg.c b/sdk/cpprt/linux/libunwind/src/mi/Lset_fpreg.c new file mode 100644 index 0000000000..2497d404f4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lset_fpreg.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gset_fpreg.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/Lset_reg.c b/sdk/cpprt/linux/libunwind/src/mi/Lset_reg.c new file mode 100644 index 0000000000..c7a872b016 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/Lset_reg.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gset_reg.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mi/_ReadSLEB.c b/sdk/cpprt/linux/libunwind/src/mi/_ReadSLEB.c new file mode 100644 index 0000000000..ce08f3399d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/_ReadSLEB.c @@ -0,0 +1,25 @@ +#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/sdk/cpprt/linux/libunwind/src/mi/_ReadULEB.c b/sdk/cpprt/linux/libunwind/src/mi/_ReadULEB.c new file mode 100644 index 0000000000..8952e6357d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/_ReadULEB.c @@ -0,0 +1,20 @@ +#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/sdk/cpprt/linux/libunwind/src/mi/backtrace.c b/sdk/cpprt/linux/libunwind/src/mi/backtrace.c new file mode 100644 index 0000000000..bd748aac18 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/backtrace.c @@ -0,0 +1,81 @@ +/* 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) + __attribute__((weak, alias("unw_backtrace"))); + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/src/mi/dyn-cancel.c b/sdk/cpprt/linux/libunwind/src/mi/dyn-cancel.c new file mode 100644 index 0000000000..e784317fc7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/dyn-cancel.c @@ -0,0 +1,46 @@ +/* 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/sdk/cpprt/linux/libunwind/src/mi/dyn-info-list.c b/sdk/cpprt/linux/libunwind/src/mi/dyn-info-list.c new file mode 100644 index 0000000000..5a5e30ee0f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/dyn-info-list.c @@ -0,0 +1,34 @@ +/* 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; + +PROTECTED unw_word_t +_U_dyn_info_list_addr (void) +{ + return (unw_word_t) (uintptr_t) &_U_dyn_info_list; +} diff --git a/sdk/cpprt/linux/libunwind/src/mi/dyn-register.c b/sdk/cpprt/linux/libunwind/src/mi/dyn-register.c new file mode 100644 index 0000000000..a62d696eb7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/dyn-register.c @@ -0,0 +1,44 @@ +/* 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 pthread_mutex_t _U_dyn_info_list_lock = PTHREAD_MUTEX_INITIALIZER; + +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/sdk/cpprt/linux/libunwind/src/mi/flush_cache.c b/sdk/cpprt/linux/libunwind/src/mi/flush_cache.c new file mode 100644 index 0000000000..c5650ba874 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/flush_cache.c @@ -0,0 +1,59 @@ +/* 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" + +PROTECTED 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_ADD1 + 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/sdk/cpprt/linux/libunwind/src/mi/init.c b/sdk/cpprt/linux/libunwind/src/mi/init.c new file mode 100644 index 0000000000..3bdf74b593 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/init.c @@ -0,0 +1,62 @@ +/* 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/PROTECTED 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 !HAVE_SGX +#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 +#endif + + assert (sizeof (struct cursor) <= sizeof (unw_cursor_t)); +} diff --git a/sdk/cpprt/linux/libunwind/src/mi/mempool.c b/sdk/cpprt/linux/libunwind/src/mi/mempool.c new file mode 100644 index 0000000000..ef891bf6a6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/mempool.c @@ -0,0 +1,176 @@ +/* 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 "libunwind_i.h" + +#define MAX_ALIGN (sizeof (long double)) + +static char sos_memory[SOS_MEMORY_SIZE]; +static char *sos_memp; +static size_t pg_size; + +HIDDEN void * +sos_alloc (size_t size) +{ + char *mem; + +#ifdef HAVE_CMPXCHG + char *old_mem; + + size = (size + MAX_ALIGN - 1) & -MAX_ALIGN; + if (!sos_memp) + cmpxchg_ptr (&sos_memp, 0, sos_memory); + do + { + old_mem = sos_memp; + + mem = (char *) (((unsigned long) old_mem + MAX_ALIGN - 1) & -MAX_ALIGN); + mem += size; + assert (mem < sos_memory + sizeof (sos_memory)); + } + while (!cmpxchg_ptr (&sos_memp, old_mem, mem)); +#else + static define_lock (sos_lock); + intrmask_t saved_mask; + + size = (size + MAX_ALIGN - 1) & -MAX_ALIGN; + + lock_acquire (&sos_lock, saved_mask); + { + if (!sos_memp) + sos_memp = sos_memory; + + mem = (char *) (((unsigned long) sos_memp + MAX_ALIGN - 1) & -MAX_ALIGN); + mem += size; + assert (mem < sos_memory + sizeof (sos_memory)); + sos_memp = mem; + } + lock_release (&sos_lock, saved_mask); +#endif + return mem; +} + +/* 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 = (pool->obj_size + pg_size - 1) & -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 = (obj_size + MAX_ALIGN - 1) & -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 = (2*reserve*obj_size + pg_size - 1) & -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/sdk/cpprt/linux/libunwind/src/mi/strerror.c b/sdk/cpprt/linux/libunwind/src/mi/strerror.c new file mode 100644 index 0000000000..ef647160b0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mi/strerror.c @@ -0,0 +1,51 @@ +/* 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/sdk/cpprt/linux/libunwind/src/mips/Gcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/mips/Gcreate_addr_space.c new file mode 100644 index 0000000000..af084ef0e4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gcreate_addr_space.c @@ -0,0 +1,65 @@ +/* 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" + +PROTECTED 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; + + /* + * 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; + + 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/sdk/cpprt/linux/libunwind/src/mips/Gget_proc_info.c b/sdk/cpprt/linux/libunwind/src/mips/Gget_proc_info.c new file mode 100644 index 0000000000..973ddd979b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gget_proc_info.c @@ -0,0 +1,41 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/mips/Gget_save_loc.c b/sdk/cpprt/linux/libunwind/src/mips/Gget_save_loc.c new file mode 100644 index 0000000000..262e23ec06 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gget_save_loc.c @@ -0,0 +1,99 @@ +/* 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. */ + +PROTECTED 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: + 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/sdk/cpprt/linux/libunwind/src/mips/Gglobal.c b/sdk/cpprt/linux/libunwind/src/mips/Gglobal.c new file mode 100644 index 0000000000..1aa77eacbc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gglobal.c @@ -0,0 +1,64 @@ +/* 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 pthread_mutex_t mips_lock = PTHREAD_MUTEX_INITIALIZER; +HIDDEN int tdep_needs_initialization = 1; + +/* FIXME: I'm pretty sure we don't need this at all for MIPS, but "generic" + code (include/dwarf_i.h) seems to expect it to be here at present. */ + +HIDDEN 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 + }; + +HIDDEN void +tdep_init (void) +{ + intrmask_t saved_mask; + + sigfillset (&unwi_full_mask); + + lock_acquire (&mips_lock, saved_mask); + { + if (!tdep_needs_initialization) + /* another thread else beat us to it... */ + goto out; + + mi_init (); + + dwarf_init (); + +#ifndef UNW_REMOTE_ONLY + mips_local_addr_space_init (); +#endif + tdep_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&mips_lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/mips/Ginit.c b/sdk/cpprt/linux/libunwind/src/mips/Ginit.c new file mode 100644 index 0000000000..6ffeabfaa0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Ginit.c @@ -0,0 +1,208 @@ +/* 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. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED 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 + 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 + && 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 = UNW_CACHE_GLOBAL; + 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 = 0; /* 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/sdk/cpprt/linux/libunwind/src/mips/Ginit_local.c b/sdk/cpprt/linux/libunwind/src/mips/Ginit_local.c new file mode 100644 index 0000000000..debf5bb58f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Ginit_local.c @@ -0,0 +1,53 @@ +/* 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 + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + return -UNW_EINVAL; +} + +#else /* !UNW_REMOTE_ONLY */ + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + struct cursor *c = (struct cursor *) cursor; + + if (tdep_needs_initialization) + tdep_init (); + + Debug (1, "(cursor=%p)\n", c); + + c->dwarf.as = unw_local_addr_space; + c->dwarf.as_arg = uc; + return common_init (c, 1); +} + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/src/mips/Ginit_remote.c b/sdk/cpprt/linux/libunwind/src/mips/Ginit_remote.c new file mode 100644 index 0000000000..854f3b62f0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Ginit_remote.c @@ -0,0 +1,45 @@ +/* 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" + +PROTECTED 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_needs_initialization) + 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/sdk/cpprt/linux/libunwind/src/mips/Gis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/mips/Gis_signal_frame.c new file mode 100644 index 0000000000..fef542b1b9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gis_signal_frame.c @@ -0,0 +1,35 @@ +/* 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 + +/* FIXME for MIPS. */ + +PROTECTED int +unw_is_signal_frame (unw_cursor_t *cursor) +{ + printf ("%s: implement me\n", __FUNCTION__); + return -UNW_ENOINFO; +} diff --git a/sdk/cpprt/linux/libunwind/src/mips/Gregs.c b/sdk/cpprt/linux/libunwind/src/mips/Gregs.c new file mode 100644 index 0000000000..9f37299ce0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gregs.c @@ -0,0 +1,99 @@ +/* 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_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/sdk/cpprt/linux/libunwind/src/mips/Gresume.c b/sdk/cpprt/linux/libunwind/src/mips/Gresume.c new file mode 100644 index 0000000000..b822e24b0c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gresume.c @@ -0,0 +1,45 @@ +/* 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 */ + +PROTECTED int +unw_resume (unw_cursor_t *cursor) +{ + return -UNW_EINVAL; +} diff --git a/sdk/cpprt/linux/libunwind/src/mips/Gstep.c b/sdk/cpprt/linux/libunwind/src/mips/Gstep.c new file mode 100644 index 0000000000..bafeef1fc1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Gstep.c @@ -0,0 +1,48 @@ +/* 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 "offsets.h" + +PROTECTED int +unw_step (unw_cursor_t *cursor) +{ + struct cursor *c = (struct cursor *) cursor; + int ret; + + Debug (1, "(cursor=%p)\n", c); + + /* Try DWARF-based unwinding... this is the only method likely to work for + MIPS. */ + 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/sdk/cpprt/linux/libunwind/src/mips/Lcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/mips/Lcreate_addr_space.c new file mode 100644 index 0000000000..0f2dc6be90 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lcreate_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gcreate_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Lget_proc_info.c b/sdk/cpprt/linux/libunwind/src/mips/Lget_proc_info.c new file mode 100644 index 0000000000..69028b019f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lget_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Lget_save_loc.c b/sdk/cpprt/linux/libunwind/src/mips/Lget_save_loc.c new file mode 100644 index 0000000000..9ea048a907 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lget_save_loc.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_save_loc.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Lglobal.c b/sdk/cpprt/linux/libunwind/src/mips/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Linit.c b/sdk/cpprt/linux/libunwind/src/mips/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Linit_local.c b/sdk/cpprt/linux/libunwind/src/mips/Linit_local.c new file mode 100644 index 0000000000..68a1687e85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Linit_local.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_local.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Linit_remote.c b/sdk/cpprt/linux/libunwind/src/mips/Linit_remote.c new file mode 100644 index 0000000000..58cb04ab7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Linit_remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Lis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/mips/Lis_signal_frame.c new file mode 100644 index 0000000000..b9a7c4f51a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lis_signal_frame.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gis_signal_frame.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Lregs.c b/sdk/cpprt/linux/libunwind/src/mips/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Lresume.c b/sdk/cpprt/linux/libunwind/src/mips/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/Lstep.c b/sdk/cpprt/linux/libunwind/src/mips/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/elfxx.c b/sdk/cpprt/linux/libunwind/src/mips/elfxx.c new file mode 100644 index 0000000000..07d3d12b94 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/elfxx.c @@ -0,0 +1,27 @@ +/* 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/sdk/cpprt/linux/libunwind/src/mips/gen-offsets.c b/sdk/cpprt/linux/libunwind/src/mips/gen-offsets.c new file mode 100644 index 0000000000..448f694532 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/gen-offsets.c @@ -0,0 +1,30 @@ +#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/sdk/cpprt/linux/libunwind/src/mips/getcontext.S b/sdk/cpprt/linux/libunwind/src/mips/getcontext.S new file mode 100644 index 0000000000..ad9e1f00a1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/getcontext.S @@ -0,0 +1,85 @@ +/* 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" +#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) +#else +# define SREG(X) sd $X, (LINUX_UC_MCONTEXT_GREGS + 8 * X) ($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) + li $2, 0 + j $31 + + .size _Umips_getcontext, .-_Umips_getcontext diff --git a/sdk/cpprt/linux/libunwind/src/mips/init.h b/sdk/cpprt/linux/libunwind/src/mips/init.h new file mode 100644 index 0000000000..3a4bb00859 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/init.h @@ -0,0 +1,58 @@ +/* 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; + + ret = dwarf_get (&c->dwarf, c->dwarf.loc[31], &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.ret_addr_column = 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/sdk/cpprt/linux/libunwind/src/mips/is_fpreg.c b/sdk/cpprt/linux/libunwind/src/mips/is_fpreg.c new file mode 100644 index 0000000000..3acc6967a2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/is_fpreg.c @@ -0,0 +1,35 @@ +/* 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. */ + +PROTECTED int +unw_is_fpreg (int regnum) +{ + /* FIXME: Support FP. */ + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/mips/offsets.h b/sdk/cpprt/linux/libunwind/src/mips/offsets.h new file mode 100644 index 0000000000..8040f6a51b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/offsets.h @@ -0,0 +1,39 @@ +/* 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": */ + +#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_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_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_GREGS 0x28 + +#endif diff --git a/sdk/cpprt/linux/libunwind/src/mips/regname.c b/sdk/cpprt/linux/libunwind/src/mips/regname.c new file mode 100644 index 0000000000..94000d496d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/regname.c @@ -0,0 +1,46 @@ +/* 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", + }; + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) + return regname[reg]; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/mips/siglongjmp.S b/sdk/cpprt/linux/libunwind/src/mips/siglongjmp.S new file mode 100644 index 0000000000..9cbcf3dc01 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/siglongjmp.S @@ -0,0 +1,8 @@ + /* Dummy implementation for now. */ + + .globl _UI_siglongjmp_cont + .globl _UI_longjmp_cont + +_UI_siglongjmp_cont: +_UI_longjmp_cont: + j $31 diff --git a/sdk/cpprt/linux/libunwind/src/mips/unwind_i.h b/sdk/cpprt/linux/libunwind/src/mips/unwind_i.h new file mode 100644 index 0000000000..faf3237ffe --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/mips/unwind_i.h @@ -0,0 +1,48 @@ +/* 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 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) + +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 void mips_local_addr_space_init (void); + +#endif /* unwind_i_h */ diff --git a/sdk/cpprt/linux/libunwind/src/os-freebsd.c b/sdk/cpprt/linux/libunwind/src/os-freebsd.c new file mode 100644 index 0000000000..76cdd23cc2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/os-freebsd.c @@ -0,0 +1,145 @@ +/* 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; + int 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); +} + +PROTECTED 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); +} diff --git a/sdk/cpprt/linux/libunwind/src/os-hpux.c b/sdk/cpprt/linux/libunwind/src/os-hpux.c new file mode 100644 index 0000000000..11b1177cf6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/os-hpux.c @@ -0,0 +1,67 @@ +/* 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); +} diff --git a/sdk/cpprt/linux/libunwind/src/os-linux.c b/sdk/cpprt/linux/libunwind/src/os-linux.c new file mode 100644 index 0000000000..3a552608ba --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/os-linux.c @@ -0,0 +1,67 @@ +/* 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" + +PROTECTED 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) +{ +#if HAVE_SGX + return -1; +#else + 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; +#endif +} diff --git a/sdk/cpprt/linux/libunwind/src/os-linux.h b/sdk/cpprt/linux/libunwind/src/os-linux.h new file mode 100644 index 0000000000..26b6cb3cfd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/os-linux.h @@ -0,0 +1,302 @@ +/* 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) +{ +#if !HAVE_SGX + 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 (0, 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; + } + } +#else + return -1; +#endif +} + +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 !HAVE_SGX + 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 = 0; + } +#endif +} + +#endif /* os_linux_h */ diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Gcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/ppc/Gcreate_addr_space.c new file mode 100644 index 0000000000..21ec10fcd8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Gcreate_addr_space.c @@ -0,0 +1,54 @@ +/* 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 + +PROTECTED 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; + + /* + * Linux ppc64 supports only big-endian. + */ + if (byte_order != 0 && byte_order != __BIG_ENDIAN) + return NULL; + return as; +#endif +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Gget_proc_info.c b/sdk/cpprt/linux/libunwind/src/ppc/Gget_proc_info.c new file mode 100644 index 0000000000..21be70c43a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Gget_proc_info.c @@ -0,0 +1,34 @@ +/* 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 + +PROTECTED int +unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) +{ + /* XXX: empty stub. */ + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Gget_save_loc.c b/sdk/cpprt/linux/libunwind/src/ppc/Gget_save_loc.c new file mode 100644 index 0000000000..c5beb81d7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Gget_save_loc.c @@ -0,0 +1,34 @@ +/* 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 + +PROTECTED int +unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) +{ + /* XXX: empty stub. */ + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Ginit_local.c b/sdk/cpprt/linux/libunwind/src/ppc/Ginit_local.c new file mode 100644 index 0000000000..b931b5b6a8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Ginit_local.c @@ -0,0 +1,65 @@ +/* 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 + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + /* XXX: empty stub. */ + return -UNW_EINVAL; +} + +#else /* !UNW_REMOTE_ONLY */ + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + struct cursor *c = (struct cursor *) cursor; + + if (tdep_needs_initialization) + 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, 1); + #else + return common_init_ppc32 (c, 1); + #endif +} + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Ginit_remote.c b/sdk/cpprt/linux/libunwind/src/ppc/Ginit_remote.c new file mode 100644 index 0000000000..0f4b0fdb35 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Ginit_remote.c @@ -0,0 +1,60 @@ +/* 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 + +PROTECTED 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_needs_initialization) + 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/sdk/cpprt/linux/libunwind/src/ppc/Gis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/ppc/Gis_signal_frame.c new file mode 100644 index 0000000000..4154429013 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Gis_signal_frame.c @@ -0,0 +1,66 @@ +/* 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 + +PROTECTED 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; + 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 (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; + w1 >>= 32; + return (w0 == 0x38210080380000ac && w1 == 0x44000002); + +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Lcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/ppc/Lcreate_addr_space.c new file mode 100644 index 0000000000..0f2dc6be90 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Lcreate_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gcreate_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Lget_proc_info.c b/sdk/cpprt/linux/libunwind/src/ppc/Lget_proc_info.c new file mode 100644 index 0000000000..69028b019f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Lget_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Lget_save_loc.c b/sdk/cpprt/linux/libunwind/src/ppc/Lget_save_loc.c new file mode 100644 index 0000000000..9ea048a907 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Lget_save_loc.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_save_loc.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Linit_local.c b/sdk/cpprt/linux/libunwind/src/ppc/Linit_local.c new file mode 100644 index 0000000000..68a1687e85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Linit_local.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_local.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Linit_remote.c b/sdk/cpprt/linux/libunwind/src/ppc/Linit_remote.c new file mode 100644 index 0000000000..58cb04ab7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Linit_remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc/Lis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/ppc/Lis_signal_frame.c new file mode 100644 index 0000000000..b9a7c4f51a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/Lis_signal_frame.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gis_signal_frame.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc/longjmp.S b/sdk/cpprt/linux/libunwind/src/ppc/longjmp.S new file mode 100644 index 0000000000..d363aef222 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/longjmp.S @@ -0,0 +1,36 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ppc/siglongjmp.S b/sdk/cpprt/linux/libunwind/src/ppc/siglongjmp.S new file mode 100644 index 0000000000..64be36ce17 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc/siglongjmp.S @@ -0,0 +1,31 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ppc32/Gglobal.c b/sdk/cpprt/linux/libunwind/src/ppc32/Gglobal.c new file mode 100644 index 0000000000..b7cebff51f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Gglobal.c @@ -0,0 +1,135 @@ +/* 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 pthread_mutex_t ppc32_lock = PTHREAD_MUTEX_INITIALIZER; +HIDDEN int tdep_needs_initialization = 1; + +/* The API register numbers are exactly the same as the .eh_frame + registers, for now at least. */ +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_needs_initialization) + /* another thread else beat us to it... */ + goto out; + + mi_init (); + + dwarf_init (); + +#ifndef UNW_REMOTE_ONLY + ppc32_local_addr_space_init (); +#endif + tdep_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&ppc32_lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/Ginit.c b/sdk/cpprt/linux/libunwind/src/ppc32/Ginit.c new file mode 100644 index 0000000000..47c66f1195 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Ginit.c @@ -0,0 +1,221 @@ +/* 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. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED unw_addr_space_t unw_local_addr_space = &local_addr_space; + + +#define PAGE_SIZE 4096 +#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) + + +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 = UNW_CACHE_GLOBAL; + 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/sdk/cpprt/linux/libunwind/src/ppc32/Gregs.c b/sdk/cpprt/linux/libunwind/src/ppc32/Gregs.c new file mode 100644 index 0000000000..92be32164a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Gregs.c @@ -0,0 +1,90 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ppc32/Gresume.c b/sdk/cpprt/linux/libunwind/src/ppc32/Gresume.c new file mode 100644 index 0000000000..5446c9805c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Gresume.c @@ -0,0 +1,77 @@ +/* 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; +} + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ppc32/Gstep.c b/sdk/cpprt/linux/libunwind/src/ppc32/Gstep.c new file mode 100644 index 0000000000..d146e82dde --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Gstep.c @@ -0,0 +1,309 @@ +/* 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; + + +PROTECTED 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))) + { + /* 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 + ("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 + ("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/sdk/cpprt/linux/libunwind/src/ppc32/Lglobal.c b/sdk/cpprt/linux/libunwind/src/ppc32/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/Linit.c b/sdk/cpprt/linux/libunwind/src/ppc32/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/Lregs.c b/sdk/cpprt/linux/libunwind/src/ppc32/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/Lresume.c b/sdk/cpprt/linux/libunwind/src/ppc32/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/Lstep.c b/sdk/cpprt/linux/libunwind/src/ppc32/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/Make-arch.in b/sdk/cpprt/linux/libunwind/src/ppc32/Make-arch.in new file mode 100644 index 0000000000..947dd5fa03 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/Make-arch.in @@ -0,0 +1,11 @@ +# 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/sdk/cpprt/linux/libunwind/src/ppc32/get_func_addr.c b/sdk/cpprt/linux/libunwind/src/ppc32/get_func_addr.c new file mode 100644 index 0000000000..14797c9bdf --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/get_func_addr.c @@ -0,0 +1,36 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ppc32/init.h b/sdk/cpprt/linux/libunwind/src/ppc32/init.h new file mode 100644 index 0000000000..4cb919205d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/init.h @@ -0,0 +1,73 @@ +/* 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.ret_addr_column = 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/sdk/cpprt/linux/libunwind/src/ppc32/is_fpreg.c b/sdk/cpprt/linux/libunwind/src/ppc32/is_fpreg.c new file mode 100644 index 0000000000..cccc5112bc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/is_fpreg.c @@ -0,0 +1,34 @@ +/* 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" + +PROTECTED int +unw_is_fpreg (int regnum) +{ + return (regnum >= UNW_PPC32_F0 && regnum <= UNW_PPC32_F31); +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/regname.c b/sdk/cpprt/linux/libunwind/src/ppc32/regname.c new file mode 100644 index 0000000000..79ba88aa56 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/regname.c @@ -0,0 +1,112 @@ +/* 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" +}; + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) + return regname[reg]; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/setcontext.S b/sdk/cpprt/linux/libunwind/src/ppc32/setcontext.S new file mode 100644 index 0000000000..b54378a9dc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/setcontext.S @@ -0,0 +1,9 @@ + .global _UI_setcontext + +_UI_setcontext: + retq + +#ifdef __linux__ + /* We do not need executable stack. */ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc32/ucontext_i.h b/sdk/cpprt/linux/libunwind/src/ppc32/ucontext_i.h new file mode 100644 index 0000000000..52c3dc7e23 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/ucontext_i.h @@ -0,0 +1,128 @@ +/* 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 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; +static vrregset_t dmy_vrregset; + +#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/sdk/cpprt/linux/libunwind/src/ppc32/unwind_i.h b/sdk/cpprt/linux/libunwind/src/ppc32/unwind_i.h new file mode 100644 index 0000000000..c3c3a57f76 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc32/unwind_i.h @@ -0,0 +1,47 @@ +/* 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 +#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/sdk/cpprt/linux/libunwind/src/ppc64/Gglobal.c b/sdk/cpprt/linux/libunwind/src/ppc64/Gglobal.c new file mode 100644 index 0000000000..64813571b9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Gglobal.c @@ -0,0 +1,182 @@ +/* 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 pthread_mutex_t ppc64_lock = PTHREAD_MUTEX_INITIALIZER; +HIDDEN int tdep_needs_initialization = 1; + +/* The API register numbers are exactly the same as the .eh_frame + registers, for now at least. */ +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_needs_initialization) + /* another thread else beat us to it... */ + goto out; + + mi_init (); + + dwarf_init (); + +#ifndef UNW_REMOTE_ONLY + ppc64_local_addr_space_init (); +#endif + tdep_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&ppc64_lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/Ginit.c b/sdk/cpprt/linux/libunwind/src/ppc64/Ginit.c new file mode 100644 index 0000000000..97c9d78cbd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Ginit.c @@ -0,0 +1,230 @@ +/* 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. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED unw_addr_space_t unw_local_addr_space = &local_addr_space; + + +#define PAGE_SIZE 4096 +#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) + + +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 ((unsigned int) (reg - UNW_PPC64_F0) < 32) + goto badreg; + if ((unsigned int) (reg - UNW_PPC64_V0) < 32) + 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_PPC64_F0) < 0) + goto badreg; + + if ((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.caching_policy = UNW_CACHE_GLOBAL; + 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/sdk/cpprt/linux/libunwind/src/ppc64/Gregs.c b/sdk/cpprt/linux/libunwind/src/ppc64/Gregs.c new file mode 100644 index 0000000000..b044504b44 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Gregs.c @@ -0,0 +1,100 @@ +/* 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_PPC64_F0)) <= 31) || + (((unsigned) (reg - UNW_PPC64_V0)) <= 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_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/sdk/cpprt/linux/libunwind/src/ppc64/Gresume.c b/sdk/cpprt/linux/libunwind/src/ppc64/Gresume.c new file mode 100644 index 0000000000..893ea63c50 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Gresume.c @@ -0,0 +1,77 @@ +/* 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) +{ + /* 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; +} + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ppc64/Gstep.c b/sdk/cpprt/linux/libunwind/src/ppc64/Gstep.c new file mode 100644 index 0000000000..20b22b51cc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Gstep.c @@ -0,0 +1,436 @@ +/* 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 cr_save; + long unsigned lr_save; + /* many more fields here, but they are unused by this code */ +} stack_frame_t; + + +PROTECTED 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; + + 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))) + { + /* 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 + ("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 + ("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_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; + } + } + return ret; +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/Lglobal.c b/sdk/cpprt/linux/libunwind/src/ppc64/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/Linit.c b/sdk/cpprt/linux/libunwind/src/ppc64/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/Lregs.c b/sdk/cpprt/linux/libunwind/src/ppc64/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/Lresume.c b/sdk/cpprt/linux/libunwind/src/ppc64/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/Lstep.c b/sdk/cpprt/linux/libunwind/src/ppc64/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/get_func_addr.c b/sdk/cpprt/linux/libunwind/src/ppc64/get_func_addr.c new file mode 100644 index 0000000000..a9c828dc3e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/get_func_addr.c @@ -0,0 +1,45 @@ +/* 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) +{ + unw_accessors_t *a; + int ret; + + a = unw_get_accessors (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; + return 0; +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/init.h b/sdk/cpprt/linux/libunwind/src/ppc64/init.h new file mode 100644 index 0000000000..7503a7c70c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/init.h @@ -0,0 +1,83 @@ +/* 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.ret_addr_column = 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/sdk/cpprt/linux/libunwind/src/ppc64/is_fpreg.c b/sdk/cpprt/linux/libunwind/src/ppc64/is_fpreg.c new file mode 100644 index 0000000000..b34bf8715c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/is_fpreg.c @@ -0,0 +1,34 @@ +/* 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" + +PROTECTED int +unw_is_fpreg (int regnum) +{ + return (regnum >= UNW_PPC64_F0 && regnum <= UNW_PPC64_F31); +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/regname.c b/sdk/cpprt/linux/libunwind/src/ppc64/regname.c new file mode 100644 index 0000000000..7d648347e2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/regname.c @@ -0,0 +1,161 @@ +/* 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", + + }; + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) + return regname[reg]; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/setcontext.S b/sdk/cpprt/linux/libunwind/src/ppc64/setcontext.S new file mode 100644 index 0000000000..b54378a9dc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/setcontext.S @@ -0,0 +1,9 @@ + .global _UI_setcontext + +_UI_setcontext: + retq + +#ifdef __linux__ + /* We do not need executable stack. */ + .section .note.GNU-stack,"",@progbits +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ppc64/ucontext_i.h b/sdk/cpprt/linux/libunwind/src/ppc64/ucontext_i.h new file mode 100644 index 0000000000..245d66768b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/ucontext_i.h @@ -0,0 +1,173 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ppc64/unwind_i.h b/sdk/cpprt/linux/libunwind/src/ppc64/unwind_i.h new file mode 100644 index 0000000000..056dc166b1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ppc64/unwind_i.h @@ -0,0 +1,53 @@ +/* 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 +#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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_fpreg.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_fpreg.c new file mode 100644 index 0000000000..283dcd4f61 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_fpreg.c @@ -0,0 +1,105 @@ +/* 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 >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0])) + 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 ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0])) + 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)); +#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)); +#else +#error Fix me +#endif + return 0; +} +#else +#error Fix me +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_mem.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_mem.c new file mode 100644 index 0000000000..b0c2ef04d5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_mem.c @@ -0,0 +1,85 @@ +/* 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; + pid_t pid = ui->pid; + + errno = 0; + if (write) + { + Debug (16, "mem[%lx] <- %lx\n", (long) addr, (long) *val); +#ifdef HAVE_TTRACE +# warning No support for ttrace() yet. +#else + ptrace (PTRACE_POKEDATA, pid, addr, *val); + if (errno) + return -UNW_EINVAL; +#endif + } + else + { +#ifdef HAVE_TTRACE +# warning No support for ttrace() yet. +#else + *val = ptrace (PTRACE_PEEKDATA, pid, addr, 0); + if (errno) + return -UNW_EINVAL; +#endif + Debug (16, "mem[%lx] -> %lx\n", (long) addr, (long) *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; + 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_reg.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_reg.c new file mode 100644 index 0000000000..00ba0cc71c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_access_reg.c @@ -0,0 +1,293 @@ +/* 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_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 + 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 + + if ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0])) + { + 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 + *val = ptrace (PTRACE_PEEKUSER, pid, _UPT_reg_offset[reg], 0); + if (errno) + goto badreg; +#endif + +#ifdef UNW_TARGET_IA64 + out: +#endif +#if UNW_DEBUG + if (!write) + Debug (16, "%s -> %lx\n", unw_regname (reg), (long) *val); +#endif + return 0; + + badreg: + Debug (1, "bad register number %u (error: %s)\n", 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 + if (write) + Debug (16, "%s <- %lx\n", unw_regname (reg), (long) *val); +#endif + if ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0])) + { + 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 number %u (error: %s)\n", reg, strerror (errno)); + return -UNW_EBADREG; +} +#else +#error Port me +#endif diff --git a/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_accessors.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_accessors.c new file mode 100644 index 0000000000..3feb60bc56 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_accessors.c @@ -0,0 +1,38 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_create.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_create.c new file mode 100644 index 0000000000..f6a4158365 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_create.c @@ -0,0 +1,46 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_destroy.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_destroy.c new file mode 100644 index 0000000000..04ea22d2ba --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_destroy.c @@ -0,0 +1,34 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_elf.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_elf.c new file mode 100644 index 0000000000..cf0480f2a5 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_elf.c @@ -0,0 +1,5 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_find_proc_info.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_find_proc_info.c new file mode 100644 index 0000000000..53dd1e7fcb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_find_proc_info.c @@ -0,0 +1,145 @@ +/* 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 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); + + return ret; +} diff --git a/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c new file mode 100644 index 0000000000..edc998fd6a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c @@ -0,0 +1,105 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_get_proc_name.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_get_proc_name.c new file mode 100644 index 0000000000..6ac85a0aa7 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_get_proc_name.c @@ -0,0 +1,42 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_internal.h b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_internal.h new file mode 100644 index 0000000000..27149d36a4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_internal.h @@ -0,0 +1,59 @@ +/* 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 int _UPT_reg_offset[UNW_REG_LAST + 1]; + +#endif /* _UPT_internal_h */ diff --git a/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_put_unwind_info.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_put_unwind_info.c new file mode 100644 index 0000000000..852dd86817 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_put_unwind_info.c @@ -0,0 +1,35 @@ +/* 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/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_reg_offset.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_reg_offset.c new file mode 100644 index 0000000000..d6e1274194 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_reg_offset.c @@ -0,0 +1,361 @@ +/* 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 "_UPT_internal.h" + +#include + +#ifdef HAVE_ASM_PTRACE_OFFSETS_H +# include +#endif + +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) +#elif defined(UNW_TARGET_PPC64) +#elif defined(UNW_TARGET_ARM) + [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, +#elif defined(UNW_TARGET_MIPS) +#else +# error Fix me. +#endif + }; diff --git a/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_resume.c b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_resume.c new file mode 100644 index 0000000000..f419fed3a9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/ptrace/_UPT_resume.c @@ -0,0 +1,40 @@ +/* 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/sdk/cpprt/linux/libunwind/src/se-iterate-phdr.c b/sdk/cpprt/linux/libunwind/src/se-iterate-phdr.c new file mode 100644 index 0000000000..519a57a26d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/se-iterate-phdr.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifdef HAVE_SGX + +#include "global_data.h" +#include + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include + +/** + * This function is commonly provided by glibc for application to walk + * through list of shared objects. It is needed inside Enclave so that + * the libunwind code can work correctly. + */ +int dl_iterate_phdr( + int (*callback) (struct dl_phdr_info *info, + size_t size, void *data), + void *data) +{ + struct dl_phdr_info info; + ElfW(Ehdr) *ehdr; + + memset(&info, 0, sizeof(info)); + ehdr = (ElfW(Ehdr) *) &__ImageBase; + + info.dlpi_addr = (ElfW(Addr)) ehdr; + info.dlpi_name = ""; + info.dlpi_phdr = (ElfW(Phdr) *) ((char *)ehdr + ehdr->e_phoff); + info.dlpi_phnum = ehdr->e_phnum; + + /* No iteration here - the Enclave is merely one shared object. */ + return callback(&info, sizeof(info), data); +} + +#endif diff --git a/sdk/cpprt/linux/libunwind/src/se-libc-stubs.c b/sdk/cpprt/linux/libunwind/src/se-libc-stubs.c new file mode 100644 index 0000000000..40bf414778 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/se-libc-stubs.c @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifdef HAVE_SGX + +#ifdef _GNU_SOURCE +#undef _GNU_SOURCE +#endif + +#include "arch.h" +#include "sgx_trts.h" + +#include +#include +#include +#include +#include + + +/** + * In SE, the page size is defined by macro `SE_PAGE_SIZE'. + */ +int getpagesize(void) +{ + return SE_PAGE_SIZE; +} + +int mincore(void *addr, size_t length, unsigned char *vec) +{ + assert(sgx_is_within_enclave(addr, length)); + + return 0; +} + +char *strdup(const char *s) +{ + size_t len = strlen(s) + 1; + void *mem = malloc(len); + + if (mem == NULL) + return mem; + + return memcpy(mem, s, len); +} + +/* When optimization is turned on (even with -O), a call to + * strdup() will be replaced by __strdup(), wich GCC. + */ +char * +__strdup(const char* s) __attribute__((weak, alias("strdup"))); + +#if defined(__x86_64__) || defined(__x86_64) || defined(__amd64) +int msync(void *addr, size_t length, int flags) +{ + return 0; +} +#endif + +#ifndef NDEBUG +/* FIXME: remove __assert_fail() + * Currently libunwind is built with glibc headers, to improve it + * we need to build it with SE tlibc headers. + */ +void __assert_fail (const char *__assertion, const char *__file, + unsigned int __line, __const char *__function) +{ + abort(); +} +#endif + +#endif +/* vim: set ts=4 sw=4 cin et: */ diff --git a/sdk/cpprt/linux/libunwind/src/setjmp/longjmp.c b/sdk/cpprt/linux/libunwind/src/setjmp/longjmp.c new file mode 100644 index 0000000000..97dcdff093 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/setjmp/longjmp.c @@ -0,0 +1,115 @@ +/* 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/sdk/cpprt/linux/libunwind/src/setjmp/setjmp.c b/sdk/cpprt/linux/libunwind/src/setjmp/setjmp.c new file mode 100644 index 0000000000..feb83f7722 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/setjmp/setjmp.c @@ -0,0 +1,49 @@ +/* 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/sdk/cpprt/linux/libunwind/src/setjmp/setjmp_i.h b/sdk/cpprt/linux/libunwind/src/setjmp/setjmp_i.h new file mode 100644 index 0000000000..1d7ca1584f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/setjmp/setjmp_i.h @@ -0,0 +1,118 @@ +/* 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/sdk/cpprt/linux/libunwind/src/setjmp/siglongjmp.c b/sdk/cpprt/linux/libunwind/src/setjmp/siglongjmp.c new file mode 100644 index 0000000000..4fee4010ae --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/setjmp/siglongjmp.c @@ -0,0 +1,127 @@ +/* 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); +#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/sdk/cpprt/linux/libunwind/src/setjmp/sigsetjmp.c b/sdk/cpprt/linux/libunwind/src/setjmp/sigsetjmp.c new file mode 100644 index 0000000000..87df5ed8a0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/setjmp/sigsetjmp.c @@ -0,0 +1,50 @@ +/* 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/sdk/cpprt/linux/libunwind/src/unwind/Backtrace.c b/sdk/cpprt/linux/libunwind/src/unwind/Backtrace.c new file mode 100644 index 0000000000..99c20fcc29 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/Backtrace.c @@ -0,0 +1,56 @@ +/* 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" + +PROTECTED _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/sdk/cpprt/linux/libunwind/src/unwind/DeleteException.c b/sdk/cpprt/linux/libunwind/src/unwind/DeleteException.c new file mode 100644 index 0000000000..5104b73bd3 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/DeleteException.c @@ -0,0 +1,38 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/FindEnclosingFunction.c b/sdk/cpprt/linux/libunwind/src/unwind/FindEnclosingFunction.c new file mode 100644 index 0000000000..e639894cd1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/FindEnclosingFunction.c @@ -0,0 +1,42 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/ForcedUnwind.c b/sdk/cpprt/linux/libunwind/src/unwind/ForcedUnwind.c new file mode 100644 index 0000000000..bd334d35bb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/ForcedUnwind.c @@ -0,0 +1,52 @@ +/* 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" + +PROTECTED _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/sdk/cpprt/linux/libunwind/src/unwind/GetBSP.c b/sdk/cpprt/linux/libunwind/src/unwind/GetBSP.c new file mode 100644 index 0000000000..d53e40112c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetBSP.c @@ -0,0 +1,42 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetCFA.c b/sdk/cpprt/linux/libunwind/src/unwind/GetCFA.c new file mode 100644 index 0000000000..bd8559b8cc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetCFA.c @@ -0,0 +1,38 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetDataRelBase.c b/sdk/cpprt/linux/libunwind/src/unwind/GetDataRelBase.c new file mode 100644 index 0000000000..cb604766e2 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetDataRelBase.c @@ -0,0 +1,39 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetGR.c b/sdk/cpprt/linux/libunwind/src/unwind/GetGR.c new file mode 100644 index 0000000000..3a875e808c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetGR.c @@ -0,0 +1,43 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetIP.c b/sdk/cpprt/linux/libunwind/src/unwind/GetIP.c new file mode 100644 index 0000000000..6fd48a2edb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetIP.c @@ -0,0 +1,38 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetIPInfo.c b/sdk/cpprt/linux/libunwind/src/unwind/GetIPInfo.c new file mode 100644 index 0000000000..b885ede237 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetIPInfo.c @@ -0,0 +1,42 @@ +/* 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. */ + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetLanguageSpecificData.c b/sdk/cpprt/linux/libunwind/src/unwind/GetLanguageSpecificData.c new file mode 100644 index 0000000000..eefcec75a8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetLanguageSpecificData.c @@ -0,0 +1,40 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetRegionStart.c b/sdk/cpprt/linux/libunwind/src/unwind/GetRegionStart.c new file mode 100644 index 0000000000..11c346054b --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetRegionStart.c @@ -0,0 +1,39 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/GetTextRelBase.c b/sdk/cpprt/linux/libunwind/src/unwind/GetTextRelBase.c new file mode 100644 index 0000000000..a53ca9b1fb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/GetTextRelBase.c @@ -0,0 +1,35 @@ +/* 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" + +PROTECTED unsigned long +_Unwind_GetTextRelBase (struct _Unwind_Context *context) +{ + return 0; +} + +unsigned long __libunwind_Unwind_GetTextRelBase (struct _Unwind_Context *) + ALIAS (_Unwind_GetTextRelBase); diff --git a/sdk/cpprt/linux/libunwind/src/unwind/RaiseException.c b/sdk/cpprt/linux/libunwind/src/unwind/RaiseException.c new file mode 100644 index 0000000000..66a681dbeb --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/RaiseException.c @@ -0,0 +1,103 @@ +/* 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" + +PROTECTED _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/sdk/cpprt/linux/libunwind/src/unwind/Resume.c b/sdk/cpprt/linux/libunwind/src/unwind/Resume.c new file mode 100644 index 0000000000..ddf9d2ccaa --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/Resume.c @@ -0,0 +1,42 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/Resume_or_Rethrow.c b/sdk/cpprt/linux/libunwind/src/unwind/Resume_or_Rethrow.c new file mode 100644 index 0000000000..ece0ced395 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/Resume_or_Rethrow.c @@ -0,0 +1,47 @@ +/* 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" + +PROTECTED _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/sdk/cpprt/linux/libunwind/src/unwind/SetGR.c b/sdk/cpprt/linux/libunwind/src/unwind/SetGR.c new file mode 100644 index 0000000000..965336436e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/SetGR.c @@ -0,0 +1,47 @@ +/* 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 + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/SetIP.c b/sdk/cpprt/linux/libunwind/src/unwind/SetIP.c new file mode 100644 index 0000000000..0652a14a99 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/SetIP.c @@ -0,0 +1,35 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/unwind/unwind-internal.h b/sdk/cpprt/linux/libunwind/src/unwind/unwind-internal.h new file mode 100644 index 0000000000..130cb81ab1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/unwind/unwind-internal.h @@ -0,0 +1,140 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86/Gcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/x86/Gcreate_addr_space.c new file mode 100644 index 0000000000..f7cea64a09 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gcreate_addr_space.c @@ -0,0 +1,58 @@ +/* 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 + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86/Gget_proc_info.c b/sdk/cpprt/linux/libunwind/src/x86/Gget_proc_info.c new file mode 100644 index 0000000000..a53348303c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gget_proc_info.c @@ -0,0 +1,45 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86/Gget_save_loc.c b/sdk/cpprt/linux/libunwind/src/x86/Gget_save_loc.c new file mode 100644 index 0000000000..e8cc79eefa --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gget_save_loc.c @@ -0,0 +1,133 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86/Gglobal.c b/sdk/cpprt/linux/libunwind/src/x86/Gglobal.c new file mode 100644 index 0000000000..fbb848be0e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gglobal.c @@ -0,0 +1,69 @@ +/* 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 pthread_mutex_t x86_lock = PTHREAD_MUTEX_INITIALIZER; +HIDDEN int tdep_needs_initialization = 1; + +/* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ + +HIDDEN 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; + +#if (!HAVE_SGX) + sigfillset (&unwi_full_mask); +#endif + + lock_acquire (&x86_lock, saved_mask); + { + if (!tdep_needs_initialization) + /* another thread else beat us to it... */ + goto out; + + mi_init (); + + dwarf_init (); + +#ifndef UNW_REMOTE_ONLY + x86_local_addr_space_init (); +#endif + tdep_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&x86_lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/x86/Ginit.c b/sdk/cpprt/linux/libunwind/src/x86/Ginit.c new file mode 100644 index 0000000000..b9d5c5c15a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Ginit.c @@ -0,0 +1,248 @@ +/* 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. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED 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; +} + +#undef PAGE_SIZE +#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) +{ +#if HAVE_SGX + return -1; +#else + return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp); +#endif +} + +HIDDEN void +x86_local_addr_space_init (void) +{ + memset (&local_addr_space, 0, sizeof (local_addr_space)); + local_addr_space.caching_policy = UNW_CACHE_GLOBAL; + 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/sdk/cpprt/linux/libunwind/src/x86/Ginit_local.c b/sdk/cpprt/linux/libunwind/src/x86/Ginit_local.c new file mode 100644 index 0000000000..5e8b697250 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Ginit_local.c @@ -0,0 +1,56 @@ +/* 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 + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + return -UNW_EINVAL; +} + +#else /* !UNW_REMOTE_ONLY */ + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + struct cursor *c = (struct cursor *) cursor; + + if (tdep_needs_initialization) + 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, 1); +} + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/src/x86/Ginit_remote.c b/sdk/cpprt/linux/libunwind/src/x86/Ginit_remote.c new file mode 100644 index 0000000000..aa92405286 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Ginit_remote.c @@ -0,0 +1,56 @@ +/* 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" + +PROTECTED 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_needs_initialization) + 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/sdk/cpprt/linux/libunwind/src/x86/Gos-freebsd.c b/sdk/cpprt/linux/libunwind/src/x86/Gos-freebsd.c new file mode 100644 index 0000000000..247c35fafc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gos-freebsd.c @@ -0,0 +1,364 @@ +/* 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" + +PROTECTED 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 (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; + } + Debug (16, "returning %d\n", ret); + c->sigcontext_format = ret; + return (ret); +} + +PROTECTED int +unw_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 { + 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/sdk/cpprt/linux/libunwind/src/x86/Gos-linux.c b/sdk/cpprt/linux/libunwind/src/x86/Gos-linux.c new file mode 100644 index 0000000000..aceced5aef --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gos-linux.c @@ -0,0 +1,309 @@ +/* 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" + +PROTECTED 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 (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 ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0 + || (ret = (*a->access_mem) (as, ip + 4, &w1, 0, arg)) < 0) + return ret; + ret = ((w0 == 0x0077b858 && w1 == 0x80cd0000) + || (w0 == 0x0000adb8 && (w1 & 0xffffff) == 0x80cd00)); + Debug (16, "returning %d\n", ret); + return ret; +} + +PROTECTED int +unw_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)) + { +#if (!HAVE_SGX) + struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; + + Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc); + sigreturn (sc); +#endif + } + else + { + Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip); + setcontext (uc); + } + return -UNW_EINVAL; +} +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Gregs.c b/sdk/cpprt/linux/libunwind/src/x86/Gregs.c new file mode 100644 index 0000000000..05bc1a309e --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gregs.c @@ -0,0 +1,178 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86/Gresume.c b/sdk/cpprt/linux/libunwind/src/x86/Gresume.c new file mode 100644 index 0000000000..c39c58843a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gresume.c @@ -0,0 +1,82 @@ +/* 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); + } + } + return 0; +} + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86/Gstep.c b/sdk/cpprt/linux/libunwind/src/x86/Gstep.c new file mode 100644 index 0000000000..0965db2fde --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Gstep.c @@ -0,0 +1,115 @@ +/* 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" + +PROTECTED 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)) + { + ret = unw_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.ret_addr_column = EIP; + + 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/sdk/cpprt/linux/libunwind/src/x86/Lcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/x86/Lcreate_addr_space.c new file mode 100644 index 0000000000..0f2dc6be90 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Lcreate_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gcreate_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Lget_proc_info.c b/sdk/cpprt/linux/libunwind/src/x86/Lget_proc_info.c new file mode 100644 index 0000000000..69028b019f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Lget_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Lget_save_loc.c b/sdk/cpprt/linux/libunwind/src/x86/Lget_save_loc.c new file mode 100644 index 0000000000..9ea048a907 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Lget_save_loc.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_save_loc.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Lglobal.c b/sdk/cpprt/linux/libunwind/src/x86/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Linit.c b/sdk/cpprt/linux/libunwind/src/x86/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Linit_local.c b/sdk/cpprt/linux/libunwind/src/x86/Linit_local.c new file mode 100644 index 0000000000..68a1687e85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Linit_local.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_local.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Linit_remote.c b/sdk/cpprt/linux/libunwind/src/x86/Linit_remote.c new file mode 100644 index 0000000000..58cb04ab7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Linit_remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Los-freebsd.c b/sdk/cpprt/linux/libunwind/src/x86/Los-freebsd.c new file mode 100644 index 0000000000..a75a205df1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Los-freebsd.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gos-freebsd.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Los-linux.c b/sdk/cpprt/linux/libunwind/src/x86/Los-linux.c new file mode 100644 index 0000000000..3cc18aabcc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Los-linux.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gos-linux.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Lregs.c b/sdk/cpprt/linux/libunwind/src/x86/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Lresume.c b/sdk/cpprt/linux/libunwind/src/x86/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/Lstep.c b/sdk/cpprt/linux/libunwind/src/x86/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86/getcontext-freebsd.S b/sdk/cpprt/linux/libunwind/src/x86/getcontext-freebsd.S new file mode 100644 index 0000000000..670eff1ae1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/getcontext-freebsd.S @@ -0,0 +1,112 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86/getcontext-linux.S b/sdk/cpprt/linux/libunwind/src/x86/getcontext-linux.S new file mode 100644 index 0000000000..c469dadbac --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/getcontext-linux.S @@ -0,0 +1,74 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86/init.h b/sdk/cpprt/linux/libunwind/src/x86/init.h new file mode 100644 index 0000000000..f35387d48a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/init.h @@ -0,0 +1,70 @@ +/* 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.ret_addr_column = 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/sdk/cpprt/linux/libunwind/src/x86/is_fpreg.c b/sdk/cpprt/linux/libunwind/src/x86/is_fpreg.c new file mode 100644 index 0000000000..8f1536d1e9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/is_fpreg.c @@ -0,0 +1,34 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86/longjmp.S b/sdk/cpprt/linux/libunwind/src/x86/longjmp.S new file mode 100644 index 0000000000..05173d0c10 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/longjmp.S @@ -0,0 +1,39 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86/offsets.h b/sdk/cpprt/linux/libunwind/src/x86/offsets.h new file mode 100644 index 0000000000..538f8f5627 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/offsets.h @@ -0,0 +1,142 @@ +/* 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_FPREGS_PTR_OFF 0x60 // LINUX_UC_MCONTEXT_OFF + sizeof(gregset_t) +#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/sdk/cpprt/linux/libunwind/src/x86/regname.c b/sdk/cpprt/linux/libunwind/src/x86/regname.c new file mode 100644 index 0000000000..2228510a21 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/regname.c @@ -0,0 +1,27 @@ +#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", + }; + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) + return regname[reg]; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/x86/siglongjmp.S b/sdk/cpprt/linux/libunwind/src/x86/siglongjmp.S new file mode 100644 index 0000000000..32bba3b3b6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/siglongjmp.S @@ -0,0 +1,92 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86/unwind_i.h b/sdk/cpprt/linux/libunwind/src/x86/unwind_i.h new file mode 100644 index 0000000000..6d1d5e9f94 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86/unwind_i.h @@ -0,0 +1,64 @@ +/* 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 + +#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) + +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); + +#endif /* unwind_i_h */ diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Gcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gcreate_addr_space.c new file mode 100644 index 0000000000..fbdb1e8758 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gcreate_addr_space.c @@ -0,0 +1,59 @@ +/* libunwind - a platform-independent unwind library + Copyright (C) 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 + +#include "unwind_i.h" + +#if defined(_LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN) +#define __LITTLE_ENDIAN _LITTLE_ENDIAN +#endif + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86_64/Gget_proc_info.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gget_proc_info.c new file mode 100644 index 0000000000..213666e0ff --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gget_proc_info.c @@ -0,0 +1,48 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86_64/Gget_save_loc.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gget_save_loc.c new file mode 100644 index 0000000000..20b14a5b10 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gget_save_loc.c @@ -0,0 +1,73 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86_64/Gglobal.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gglobal.c new file mode 100644 index 0000000000..6d28b75021 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gglobal.c @@ -0,0 +1,103 @@ +/* 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 "unwind_i.h" +#include "dwarf_i.h" + +HIDDEN pthread_mutex_t x86_64_lock = PTHREAD_MUTEX_INITIALIZER; +HIDDEN int tdep_needs_initialization = 1; + +/* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ + +HIDDEN 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; + +#if (!HAVE_SGX) + sigfillset (&unwi_full_mask); +#endif + + lock_acquire (&x86_64_lock, saved_mask); + { + if (!tdep_needs_initialization) + /* 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_needs_initialization = 0; /* signal that we're initialized... */ + } + out: + lock_release (&x86_64_lock, saved_mask); +} diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Ginit.c b/sdk/cpprt/linux/libunwind/src/x86_64/Ginit.c new file mode 100644 index 0000000000..f9eceaa3da --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Ginit.c @@ -0,0 +1,273 @@ +/* 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 "unwind_i.h" + +#ifdef UNW_REMOTE_ONLY + +/* unw_local_addr_space is a NULL pointer in this case. */ +PROTECTED unw_addr_space_t unw_local_addr_space; + +#else /* !UNW_REMOTE_ONLY */ + +static struct unw_addr_space local_addr_space; + +PROTECTED 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_func) (void *addr, size_t len); +static int msync_validate (void *addr, size_t len) +{ + return msync (addr, len, MS_ASYNC); +} + +#ifdef HAVE_MINCORE +static int mincore_validate (void *addr, size_t len) +{ + unsigned char mvec[2]; /* Unaligned access may cross page boundary */ + return mincore (addr, len, mvec); +} +#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) +{ +#ifdef HAVE_MINCORE + unsigned char present = 1; + if (mincore (&present, 1, &present) == 0) + { + 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 != 0) && unlikely (c->validate) + && unlikely (validate_mem (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) +{ +#if HAVE_SGX + return -1; +#else + return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp); +#endif +} + +HIDDEN void +x86_64_local_addr_space_init (void) +{ + memset (&local_addr_space, 0, sizeof (local_addr_space)); + local_addr_space.caching_policy = UNW_CACHE_GLOBAL; + 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/sdk/cpprt/linux/libunwind/src/x86_64/Ginit_local.c b/sdk/cpprt/linux/libunwind/src/x86_64/Ginit_local.c new file mode 100644 index 0000000000..54b4fcdb74 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Ginit_local.c @@ -0,0 +1,58 @@ +/* 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 + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + return -UNW_EINVAL; +} + +#else /* !UNW_REMOTE_ONLY */ + +PROTECTED int +unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) +{ + struct cursor *c = (struct cursor *) cursor; + + if (unlikely (tdep_needs_initialization)) + 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, 1); +} + +#endif /* !UNW_REMOTE_ONLY */ diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Ginit_remote.c b/sdk/cpprt/linux/libunwind/src/x86_64/Ginit_remote.c new file mode 100644 index 0000000000..25dd686000 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Ginit_remote.c @@ -0,0 +1,57 @@ +/* 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" + +PROTECTED 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_needs_initialization) + 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 = 0; + } + return common_init (c, 0); +#endif /* !UNW_LOCAL_ONLY */ +} diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Gos-freebsd.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gos-freebsd.c new file mode 100644 index 0000000000..71695c6588 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gos-freebsd.c @@ -0,0 +1,199 @@ +/* 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" + +PROTECTED 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 (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); +} + +PROTECTED int +unw_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; + 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)); + + Debug (8, "resuming at ip=%llx via sigreturn(%p)\n", + (unsigned long long) c->dwarf.ip, uc); + sigreturn(uc); + abort(); +} +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Gos-linux.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gos-linux.c new file mode 100644 index 0000000000..a0ecce2217 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gos-linux.c @@ -0,0 +1,154 @@ +/* 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 void +tdep_cache_frame (struct dwarf_cursor *dw, struct dwarf_reg_state *rs) +{ + struct cursor *c = (struct cursor *) dw; + rs->signal_frame = c->sigcontext_format; + + Debug(5, "cache frame ip=0x%lx cfa=0x%lx format=%d\n", + dw->ip, dw->cfa, c->sigcontext_format); +} + +HIDDEN void +tdep_reuse_frame (struct dwarf_cursor *dw, struct dwarf_reg_state *rs) +{ + struct cursor *c = (struct cursor *) dw; + c->sigcontext_format = rs->signal_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; + } + else + c->sigcontext_addr = 0; + + 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)); +} + +PROTECTED int +unw_is_signal_frame (unw_cursor_t *cursor) +{ + struct cursor *c = (struct cursor *) cursor; + return c->sigcontext_format != X86_64_SCF_NONE; +} + +PROTECTED int +unw_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; + + 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/sdk/cpprt/linux/libunwind/src/x86_64/Gregs.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gregs.c new file mode 100644 index 0000000000..5dd7b0b6bd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gregs.c @@ -0,0 +1,138 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86_64/Gresume.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gresume.c new file mode 100644 index 0000000000..d5239fc150 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gresume.c @@ -0,0 +1,114 @@ +/* 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_format != 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); + } + } + return 0; +} + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86_64/Gstash_frame.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gstash_frame.c new file mode 100644 index 0000000000..962b103f95 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gstash_frame.c @@ -0,0 +1,98 @@ +/* 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[DWARF_CFA_REG_COLUMN].where, + rs->reg[DWARF_CFA_REG_COLUMN].val, + rs->reg[DWARF_CFA_OFF_COLUMN].val, + DWARF_GET_LOC(d->loc[d->ret_addr_column]), + rs->reg[RBP].where, rs->reg[RBP].val, DWARF_GET_LOC(d->loc[RBP]), + rs->reg[RSP].where, rs->reg[RSP].val, DWARF_GET_LOC(d->loc[RSP])); + + /* 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[DWARF_CFA_REG_COLUMN].where == DWARF_WHERE_REG) + && (rs->reg[DWARF_CFA_REG_COLUMN].val == RBP + || rs->reg[DWARF_CFA_REG_COLUMN].val == RSP) + && labs(rs->reg[DWARF_CFA_OFF_COLUMN].val) < (1 << 29) + && DWARF_GET_LOC(d->loc[d->ret_addr_column]) == d->cfa-8 + && (rs->reg[RBP].where == DWARF_WHERE_UNDEF + || rs->reg[RBP].where == DWARF_WHERE_SAME + || (rs->reg[RBP].where == DWARF_WHERE_CFAREL + && labs(rs->reg[RBP].val) < (1 << 14) + && rs->reg[RBP].val+1 != 0)) + && (rs->reg[RSP].where == DWARF_WHERE_UNDEF + || rs->reg[RSP].where == DWARF_WHERE_SAME + || (rs->reg[RSP].where == DWARF_WHERE_CFAREL + && labs(rs->reg[RSP].val) < (1 << 14) + && rs->reg[RSP].val+1 != 0))) + { + /* Save information for a standard frame. */ + f->frame_type = UNW_X86_64_FRAME_STANDARD; + f->cfa_reg_rsp = (rs->reg[DWARF_CFA_REG_COLUMN].val == RSP); + f->cfa_reg_offset = rs->reg[DWARF_CFA_OFF_COLUMN].val; + if (rs->reg[RBP].where == DWARF_WHERE_CFAREL) + f->rbp_cfa_offset = rs->reg[RBP].val; + if (rs->reg[RSP].where == DWARF_WHERE_CFAREL) + f->rsp_cfa_offset = rs->reg[RSP].val; + 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"); + } + + /* PLT and guessed RBP-walked frames are handled in unw_step(). */ + else + Debug (4, " unusual frame\n"); +} diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Gstep.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gstep.c new file mode 100644 index 0000000000..e05fcae34c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gstep.c @@ -0,0 +1,222 @@ +/* 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 (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; +} + +PROTECTED 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. */ + 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)) + { + ret = unw_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.ret_addr_column = RIP; + + 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/sdk/cpprt/linux/libunwind/src/x86_64/Gtrace.c b/sdk/cpprt/linux/libunwind/src/x86_64/Gtrace.c new file mode 100644 index 0000000000..446610cbdf --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Gtrace.c @@ -0,0 +1,533 @@ +/* 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 pthread_mutex_t trace_init_lock = PTHREAD_MUTEX_INITIALIZER; +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 != 0)) + 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 = 0; + 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 != 0)) + { + 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; + + 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/sdk/cpprt/linux/libunwind/src/x86_64/Lcreate_addr_space.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lcreate_addr_space.c new file mode 100644 index 0000000000..0f2dc6be90 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lcreate_addr_space.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gcreate_addr_space.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lget_proc_info.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lget_proc_info.c new file mode 100644 index 0000000000..69028b019f --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lget_proc_info.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_proc_info.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lget_save_loc.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lget_save_loc.c new file mode 100644 index 0000000000..9ea048a907 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lget_save_loc.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gget_save_loc.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lglobal.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lglobal.c new file mode 100644 index 0000000000..6d7b489e14 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lglobal.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gglobal.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Linit.c b/sdk/cpprt/linux/libunwind/src/x86_64/Linit.c new file mode 100644 index 0000000000..e9abfdd46a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Linit.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Linit_local.c b/sdk/cpprt/linux/libunwind/src/x86_64/Linit_local.c new file mode 100644 index 0000000000..68a1687e85 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Linit_local.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_local.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Linit_remote.c b/sdk/cpprt/linux/libunwind/src/x86_64/Linit_remote.c new file mode 100644 index 0000000000..58cb04ab7c --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Linit_remote.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Ginit_remote.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lis_signal_frame.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lis_signal_frame.c new file mode 100644 index 0000000000..b9a7c4f51a --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lis_signal_frame.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gis_signal_frame.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Los-freebsd.c b/sdk/cpprt/linux/libunwind/src/x86_64/Los-freebsd.c new file mode 100644 index 0000000000..a75a205df1 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Los-freebsd.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gos-freebsd.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Los-linux.c b/sdk/cpprt/linux/libunwind/src/x86_64/Los-linux.c new file mode 100644 index 0000000000..3cc18aabcc --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Los-linux.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gos-linux.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lregs.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lregs.c new file mode 100644 index 0000000000..2c9c75cd7d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lregs.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gregs.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lresume.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lresume.c new file mode 100644 index 0000000000..41a8cf003d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lresume.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gresume.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lstash_frame.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lstash_frame.c new file mode 100644 index 0000000000..77587803d0 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lstash_frame.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstash_frame.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Lstep.c b/sdk/cpprt/linux/libunwind/src/x86_64/Lstep.c new file mode 100644 index 0000000000..c1ac3c7547 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Lstep.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gstep.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/Ltrace.c b/sdk/cpprt/linux/libunwind/src/x86_64/Ltrace.c new file mode 100644 index 0000000000..fcd3f239c9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/Ltrace.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) +#include "Gtrace.c" +#endif diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/getcontext.S b/sdk/cpprt/linux/libunwind/src/x86_64/getcontext.S new file mode 100644 index 0000000000..7a8b5664bd --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/getcontext.S @@ -0,0 +1,134 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86_64/init.h b/sdk/cpprt/linux/libunwind/src/x86_64/init.h new file mode 100644 index 0000000000..e80e553331 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/init.h @@ -0,0 +1,89 @@ +/* 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.ret_addr_column = RIP; + 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/sdk/cpprt/linux/libunwind/src/x86_64/is_fpreg.c b/sdk/cpprt/linux/libunwind/src/x86_64/is_fpreg.c new file mode 100644 index 0000000000..030dd71214 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/is_fpreg.c @@ -0,0 +1,38 @@ +/* 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" + +PROTECTED 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/sdk/cpprt/linux/libunwind/src/x86_64/longjmp.S b/sdk/cpprt/linux/libunwind/src/x86_64/longjmp.S new file mode 100644 index 0000000000..274778fd80 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/longjmp.S @@ -0,0 +1,34 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86_64/offsets.h b/sdk/cpprt/linux/libunwind/src/x86_64/offsets.h new file mode 100644 index 0000000000..80cfe3617d --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/offsets.h @@ -0,0 +1,3 @@ +/* FreeBSD specific definitions */ + +#define FREEBSD_UC_MCONTEXT_OFF 0x10 diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/regname.c b/sdk/cpprt/linux/libunwind/src/x86_64/regname.c new file mode 100644 index 0000000000..6c0e2f35e4 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/regname.c @@ -0,0 +1,56 @@ +/* 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", + }; + +PROTECTED const char * +unw_regname (unw_regnum_t reg) +{ + if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) + return regname[reg]; + else + return "???"; +} diff --git a/sdk/cpprt/linux/libunwind/src/x86_64/siglongjmp.S b/sdk/cpprt/linux/libunwind/src/x86_64/siglongjmp.S new file mode 100644 index 0000000000..32489e53a9 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/siglongjmp.S @@ -0,0 +1,32 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86_64/ucontext_i.h b/sdk/cpprt/linux/libunwind/src/x86_64/ucontext_i.h new file mode 100644 index 0000000000..c1249bf6b8 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/ucontext_i.h @@ -0,0 +1,82 @@ +/* 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/sdk/cpprt/linux/libunwind/src/x86_64/unwind_i.h b/sdk/cpprt/linux/libunwind/src/x86_64/unwind_i.h new file mode 100644 index 0000000000..1e55a766c6 --- /dev/null +++ b/sdk/cpprt/linux/libunwind/src/x86_64/unwind_i.h @@ -0,0 +1,92 @@ +/* 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 + +#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); + +#endif /* unwind_i_h */ diff --git a/sdk/cpprt/linux/pthread_compat.h b/sdk/cpprt/linux/pthread_compat.h new file mode 100644 index 0000000000..e9ea3590cb --- /dev/null +++ b/sdk/cpprt/linux/pthread_compat.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +// file: pthread_compat.h +// +// This header file serves as an abstraction layer for compatibility. + +#ifndef PTHREAD_COMPAT_H +#define PTHREAD_COMPAT_H + +#include "sgx_spinlock.h" + +#define pthread_mutex_t sgx_spinlock_t +#define PTHREAD_MUTEX_INITIALIZER SGX_SPINLOCK_INITIALIZER + +#define pthread_mutex_lock sgx_spin_lock +#define pthread_mutex_unlock sgx_spin_unlock + +#if 0 +#define pthread_mutex_init sgx_thread_mutex_init + +#define pthread_cond_t sgx_thread_cond_t +#define PTHREAD_COND_INITIALIZER SGX_THREAD_COND_INITIALIZER + +#define pthread_cond_wait sgx_thread_cond_wait +#define pthread_cond_signal sgx_thread_cond_signal +#endif + +#endif diff --git a/sdk/cpprt/linux/stdexcept.cc b/sdk/cpprt/linux/stdexcept.cc new file mode 100644 index 0000000000..6b63ad48d0 --- /dev/null +++ b/sdk/cpprt/linux/stdexcept.cc @@ -0,0 +1,96 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * stdexcept.cc - provides stub implementations of the exceptions required by the runtime. + */ +#include +#include +#include "se_cdefs.h" + +SGX_ACCESS_VERSION(tstdcxx, 5) + +namespace std { + +exception::exception() throw() {} +exception::~exception() {} +exception::exception(const exception&) throw() {} +exception& exception::operator=(const exception&) throw() +{ + return *this; +} +const char* exception::what() const throw() +{ + return "std::exception"; +} + +bad_exception::bad_exception() throw() {} +bad_exception::~bad_exception() throw() {} +const char* bad_exception::what() const throw() +{ + return "std::bad_exception"; +} + +bad_alloc::bad_alloc() throw() {} +bad_alloc::~bad_alloc() {} +bad_alloc::bad_alloc(const bad_alloc&) throw() {} +bad_alloc& bad_alloc::operator=(const bad_alloc&) throw() +{ + return *this; +} +const char* bad_alloc::what() const throw() +{ + return "cxxrt::bad_alloc"; +} + +bad_cast::bad_cast() throw() {} +bad_cast::~bad_cast() {} +bad_cast::bad_cast(const bad_cast&) throw() {} +bad_cast& bad_cast::operator=(const bad_cast&) throw() +{ + return *this; +} + +const char* bad_cast::what() const throw() +{ + return "std::bad_cast"; +} + +bad_typeid::bad_typeid() throw() {} +bad_typeid::~bad_typeid() {} +bad_typeid::bad_typeid(const bad_typeid &__rhs) throw() {} +bad_typeid& bad_typeid::operator=(const bad_typeid &__rhs) throw() +{ + return *this; +} + +const char* bad_typeid::what() const throw() +{ + return "std::bad_typeid"; +} + +} // namespace std + diff --git a/sdk/cpprt/linux/terminate.cc b/sdk/cpprt/linux/terminate.cc new file mode 100644 index 0000000000..2f0fa67eca --- /dev/null +++ b/sdk/cpprt/linux/terminate.cc @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "se_cdefs.h" + +SGX_ACCESS_VERSION(tstdcxx, 6) + +namespace std +{ + /** + * Stub implementation of std::terminate. Used when the STL implementation + * doesn't provide one. + */ + __attribute__((weak)) + void terminate() + { + abort(); + } +} diff --git a/sdk/cpprt/linux/typeinfo.cc b/sdk/cpprt/linux/typeinfo.cc new file mode 100644 index 0000000000..0d28e6d431 --- /dev/null +++ b/sdk/cpprt/linux/typeinfo.cc @@ -0,0 +1,126 @@ +/* + * Copyright 2010-2012 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "typeinfo.h" +#include +#include +#include +#include "se_cdefs.h" + +SGX_ACCESS_VERSION(tstdcxx, 4) + +using std::type_info; + +type_info::~type_info() {} + +bool type_info::operator==(const type_info &other) const +{ + return __type_name == other.__type_name; +} +bool type_info::operator!=(const type_info &other) const +{ + return __type_name != other.__type_name; +} +bool type_info::before(const type_info &other) const +{ + return __type_name < other.__type_name; +} +const char* type_info::name() const +{ + return __type_name; +} +type_info::type_info (const type_info& rhs) +{ + __type_name = rhs.__type_name; +} +type_info& type_info::operator= (const type_info& rhs) +{ + return *new type_info(rhs); +} + +__cxxabiv1::__fundamental_type_info::~__fundamental_type_info() {} +__cxxabiv1::__array_type_info::~__array_type_info() {} +__cxxabiv1::__function_type_info::~__function_type_info() {} +__cxxabiv1::__enum_type_info::~__enum_type_info() {} +__cxxabiv1::__class_type_info::~__class_type_info() {} +__cxxabiv1::__si_class_type_info::~__si_class_type_info() {} +__cxxabiv1::__vmi_class_type_info::~__vmi_class_type_info() {} +__cxxabiv1::__pbase_type_info::~__pbase_type_info() {} +__cxxabiv1::__pointer_type_info::~__pointer_type_info() {} +__cxxabiv1::__pointer_to_member_type_info::~__pointer_to_member_type_info() {} + +#if 0 +// From libelftc +extern "C" char *__cxa_demangle_gnu3(const char *); + +extern "C" char* __cxa_demangle(const char* mangled_name, + char* buf, + size_t* n, + int* status) +{ + // TODO: We should probably just be linking against libelf-tc, rather than + // copying their code. This requires them to do an actual release, + // however, and for our changes to be pushed upstream. We also need to + // call a different demangling function here depending on the ABI (e.g. + // ARM). + char *demangled = __cxa_demangle_gnu3(mangled_name); + if (NULL != demangled) + { + size_t len = strlen(demangled); + buf = (char*)realloc(buf, len+1); + if (0 != buf) + { + memcpy(buf, demangled, len); + buf[len] = 0; + if (n) + { + *n = len; + } + if (status) + { + *status = 0; + } + } + else + { + if (status) + { + *status = -1; + } + } + free(demangled); + } + else + { + if (status) + { + *status = -2; + } + return NULL; + } + return buf; +} +#endif diff --git a/sdk/cpprt/linux/typeinfo.h b/sdk/cpprt/linux/typeinfo.h new file mode 100644 index 0000000000..b3d19c703d --- /dev/null +++ b/sdk/cpprt/linux/typeinfo.h @@ -0,0 +1,234 @@ +/* + * Copyright 2010-2011 PathScale, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "abi_namespace.h" + +namespace ABI_NAMESPACE +{ + /** + * Primitive type info, for intrinsic types. + */ + struct __fundamental_type_info : public std::type_info + { + virtual ~__fundamental_type_info(); + }; + /** + * Type info for arrays. + */ + struct __array_type_info : public std::type_info + { + virtual ~__array_type_info(); + }; + /** + * Type info for functions. + */ + struct __function_type_info : public std::type_info + { + virtual ~__function_type_info(); + virtual bool __is_function_p() const { return true; } + }; + /** + * Type info for enums. + */ + struct __enum_type_info : public std::type_info + { + virtual ~__enum_type_info(); + }; + + /** + * Base class for class type info. Used only for tentative definitions. + */ + struct __class_type_info : public std::type_info + { + virtual ~__class_type_info(); + /** + * Function implementing dynamic casts. + */ + virtual void *cast_to(void *obj, const struct __class_type_info *other) const; + virtual bool __do_upcast(const ABI_NAMESPACE:: + __class_type_info *target, + void **thrown_object) const + { + return this == target; + } + }; + + /** + * Single-inheritance class type info. This is used for classes containing + * a single non-virtual base class at offset 0. + */ + struct __si_class_type_info : public __class_type_info + { + virtual ~__si_class_type_info(); + const __class_type_info *__base_type; + virtual bool __do_upcast( + const __cxxabiv1::__class_type_info *target, + void **thrown_object) const; + virtual void *cast_to(void *obj, const struct __class_type_info *other) const; + }; + + /** + * Type info for base classes. Classes with multiple bases store an array + * of these, one for each superclass. + */ + struct __base_class_type_info + { + const __class_type_info *__base_type; + private: + /** + * The high __offset_shift bits of this store the (signed) offset + * of the base class. The low bits store flags from + * __offset_flags_masks. + */ + long __offset_flags; + /** + * Flags used in the low bits of __offset_flags. + */ + enum __offset_flags_masks + { + /** This base class is virtual. */ + __virtual_mask = 0x1, + /** This base class is public. */ + __public_mask = 0x2, + /** The number of bits reserved for flags. */ + __offset_shift = 8 + }; + public: + /** + * Returns the offset of the base class. + */ + long offset() const + { + return __offset_flags >> __offset_shift; + } + /** + * Returns the flags. + */ + long flags() const + { + return __offset_flags & ((1 << __offset_shift) - 1); + } + /** + * Returns whether this is a public base class. + */ + bool isPublic() const { return flags() & __public_mask; } + /** + * Returns whether this is a virtual base class. + */ + bool isVirtual() const { return flags() & __virtual_mask; } + }; + + /** + * Type info for classes with virtual bases or multiple superclasses. + */ + struct __vmi_class_type_info : public __class_type_info + { + virtual ~__vmi_class_type_info(); + /** Flags describing this class. Contains values from __flags_masks. */ + unsigned int __flags; + /** The number of base classes. */ + unsigned int __base_count; + /** + * Array of base classes - this actually has __base_count elements, not + * 1. + */ + __base_class_type_info __base_info[1]; + + /** + * Flags used in the __flags field. + */ + enum __flags_masks + { + /** The class has non-diamond repeated inheritance. */ + __non_diamond_repeat_mask = 0x1, + /** The class is diamond shaped. */ + __diamond_shaped_mask = 0x2 + }; + virtual bool __do_upcast( + const __cxxabiv1::__class_type_info *target, + void **thrown_object) const; + virtual void *cast_to(void *obj, const struct __class_type_info *other) const; + }; + + /** + * Base class used for both pointer and pointer-to-member type info. + */ + struct __pbase_type_info : public std::type_info + { + virtual ~__pbase_type_info(); + /** + * Flags. Values from __masks. + */ + unsigned int __flags; + /** + * The type info for the pointee. + */ + const std::type_info *__pointee; + + /** + * Masks used for qualifiers on the pointer. + */ + enum __masks + { + /** Pointer has const qualifier. */ + __const_mask = 0x1, + /** Pointer has volatile qualifier. */ + __volatile_mask = 0x2, + /** Pointer has restrict qualifier. */ + __restrict_mask = 0x4, + /** Pointer points to an incomplete type. */ + __incomplete_mask = 0x8, + /** Pointer is a pointer to a member of an incomplete class. */ + __incomplete_class_mask = 0x10 + }; + virtual bool __is_pointer_p() const { return true; } + virtual bool __do_catch(const type_info *thrown_type, + void **thrown_object, + unsigned outer) const; + }; + + /** + * Pointer type info. + */ + struct __pointer_type_info : public __pbase_type_info + { + virtual ~__pointer_type_info(); + }; + + /** + * Pointer to member type info. + */ + struct __pointer_to_member_type_info : public __pbase_type_info + { + virtual ~__pointer_to_member_type_info(); + /** + * Pointer to the class containing this member. + */ + const __class_type_info *__context; + }; + +} diff --git a/sdk/cpprt/linux/unwind-arm.h b/sdk/cpprt/linux/unwind-arm.h new file mode 100644 index 0000000000..8c1fa16263 --- /dev/null +++ b/sdk/cpprt/linux/unwind-arm.h @@ -0,0 +1,223 @@ +/* + * Copyright 2012 David Chisnall. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * ARM-specific unwind definitions. These are taken from the ARM EHABI + * specification. + */ + typedef enum +{ + _URC_OK = 0, /* operation completed successfully */ + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8, + _URC_FAILURE = 9, /* unspecified failure of some kind */ + _URC_FATAL_PHASE1_ERROR = _URC_FAILURE +} _Unwind_Reason_Code; + +typedef uint32_t _Unwind_State; +#ifdef __clang__ +static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; +static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1; +static const _Unwind_State _US_UNWIND_FRAME_RESUME = 2; +#else // GCC fails at knowing what a constant expression is +# define _US_VIRTUAL_UNWIND_FRAME 0 +# define _US_UNWIND_FRAME_STARTING 1 +# define _US_UNWIND_FRAME_RESUME 2 +#endif + +typedef struct _Unwind_Context _Unwind_Context; + +typedef uint32_t _Unwind_EHT_Header; + +struct _Unwind_Exception +{ + uint64_t exception_class; + void (*exception_cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception *); + /* Unwinder cache, private fields for the unwinder's use */ + struct + { + uint32_t reserved1; + uint32_t reserved2; + uint32_t reserved3; + uint32_t reserved4; + uint32_t reserved5; + /* init reserved1 to 0, then don't touch */ + } unwinder_cache; + /* Propagation barrier cache (valid after phase 1): */ + struct + { + uint32_t sp; + uint32_t bitpattern[5]; + } barrier_cache; + /* Cleanup cache (preserved over cleanup): */ + struct + { + uint32_t bitpattern[4]; + } cleanup_cache; + /* Pr cache (for pr's benefit): */ + struct + { + /** function start address */ + uint32_t fnstart; + /** pointer to EHT entry header word */ + _Unwind_EHT_Header *ehtp; + /** additional data */ + uint32_t additional; + uint32_t reserved1; + } pr_cache; + /** Force alignment of next item to 8-byte boundary */ + long long int :0; +}; + +/* Unwinding functions */ +_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *ucbp); +void _Unwind_Resume(struct _Unwind_Exception *ucbp); +void _Unwind_Complete(struct _Unwind_Exception *ucbp); +void _Unwind_DeleteException(struct _Unwind_Exception *ucbp); +void *_Unwind_GetLanguageSpecificData(struct _Unwind_Context*); + +typedef enum +{ + _UVRSR_OK = 0, + _UVRSR_NOT_IMPLEMENTED = 1, + _UVRSR_FAILED = 2 +} _Unwind_VRS_Result; +typedef enum +{ + _UVRSC_CORE = 0, + _UVRSC_VFP = 1, + _UVRSC_WMMXD = 3, + _UVRSC_WMMXC = 4 +} _Unwind_VRS_RegClass; +typedef enum +{ + _UVRSD_UINT32 = 0, + _UVRSD_VFPX = 1, + _UVRSD_UINT64 = 3, + _UVRSD_FLOAT = 4, + _UVRSD_DOUBLE = 5 +} _Unwind_VRS_DataRepresentation; + +_Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *context, + _Unwind_VRS_RegClass regclass, + uint32_t regno, + _Unwind_VRS_DataRepresentation representation, + void *valuep); +_Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *context, + _Unwind_VRS_RegClass regclass, + uint32_t regno, + _Unwind_VRS_DataRepresentation representation, + void *valuep); + +/* 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 *); +extern unsigned long _Unwind_GetRegionStart(struct _Unwind_Context *); + +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *, + void *); +extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *); +extern _Unwind_Reason_Code + _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *); + +/** + * The next set of functions are compatibility extensions, implementing Itanium + * ABI functions on top of ARM ones. + */ + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 + +static inline unsigned long _Unwind_GetGR(struct _Unwind_Context *context, int reg) +{ + unsigned long val; + _Unwind_VRS_Get(context, _UVRSC_CORE, reg, _UVRSD_UINT32, &val); + return val; +} +static inline void _Unwind_SetGR(struct _Unwind_Context *context, int reg, unsigned long val) +{ + _Unwind_VRS_Set(context, _UVRSC_CORE, reg, _UVRSD_UINT32, &val); +} +static inline unsigned long _Unwind_GetIP(_Unwind_Context *context) +{ + // Low bit store the thumb state - discard it + return _Unwind_GetGR(context, 15) & ~1; +} +static inline void _Unwind_SetIP(_Unwind_Context *context, unsigned long val) +{ + // The lowest bit of the instruction pointer indicates whether we're in + // thumb or ARM mode. This is assumed to be fixed throughout a function, + // so must be propagated when setting the program counter. + unsigned long thumbState = _Unwind_GetGR(context, 15) & 1; + _Unwind_SetGR(context, 15, (val | thumbState)); +} + +/** GNU API function that unwinds the frame */ +_Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception*, struct _Unwind_Context*); + + +#define DECLARE_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(_Unwind_State state,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context); + +#define BEGIN_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(_Unwind_State state,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context)\ +{\ + int version = 1;\ + uint64_t exceptionClass = exceptionObject->exception_class;\ + int actions;\ + switch (state)\ + {\ + default: return _URC_FAILURE;\ + case _US_VIRTUAL_UNWIND_FRAME:\ + {\ + actions = _UA_SEARCH_PHASE;\ + break;\ + }\ + case _US_UNWIND_FRAME_STARTING:\ + {\ + actions = _UA_CLEANUP_PHASE;\ + if (exceptionObject->barrier_cache.sp == _Unwind_GetGR(context, 13))\ + {\ + actions |= _UA_HANDLER_FRAME;\ + }\ + break;\ + }\ + case _US_UNWIND_FRAME_RESUME:\ + {\ + return continueUnwinding(exceptionObject, context);\ + break;\ + }\ + }\ + _Unwind_SetGR (context, 12, (unsigned long)exceptionObject);\ + +#define CALL_PERSONALITY_FUNCTION(name) name(state,exceptionObject,context) diff --git a/sdk/cpprt/linux/unwind-itanium.h b/sdk/cpprt/linux/unwind-itanium.h new file mode 100644 index 0000000000..16b3eed6d7 --- /dev/null +++ b/sdk/cpprt/linux/unwind-itanium.h @@ -0,0 +1,170 @@ +/* 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 */ + +#define DECLARE_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(int version,\ + _Unwind_Action actions,\ + uint64_t exceptionClass,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context); +#define BEGIN_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(int version,\ + _Unwind_Action actions,\ + uint64_t exceptionClass,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context)\ +{ + +#define CALL_PERSONALITY_FUNCTION(name) name(version, actions, exceptionClass, exceptionObject, context) + +#ifdef __cplusplus +} +#endif + +#endif /* _UNWIND_H */ diff --git a/sdk/cpprt/linux/unwind.h b/sdk/cpprt/linux/unwind.h new file mode 100644 index 0000000000..e463a2a781 --- /dev/null +++ b/sdk/cpprt/linux/unwind.h @@ -0,0 +1,40 @@ +/* + * Copyright 2012 David Chisnall. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * 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_INCLUDED +#define UNWIND_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __arm__ +#include "unwind-arm.h" +#else +#include "unwind-itanium.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/cpprt/memory_manage/delete1.cpp b/sdk/cpprt/memory_manage/delete1.cpp new file mode 100644 index 0000000000..b5c62f2c8f --- /dev/null +++ b/sdk/cpprt/memory_manage/delete1.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/se_cdefs.h" + +//deallocate the memory block pointed by ptr (if not-null) +SGX_WEAK void SGXAPI operator delete (void* ptr) throw () +{ + free(ptr); +} diff --git a/sdk/cpprt/memory_manage/delete2.cpp b/sdk/cpprt/memory_manage/delete2.cpp new file mode 100644 index 0000000000..81fc388f1f --- /dev/null +++ b/sdk/cpprt/memory_manage/delete2.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/util.h" + +SGX_WEAK void SGXAPI operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw() +{ + UNUSED(nothrow_constant); + + free(ptr); +} diff --git a/sdk/cpprt/memory_manage/delete3.cpp b/sdk/cpprt/memory_manage/delete3.cpp new file mode 100644 index 0000000000..bb80ddba72 --- /dev/null +++ b/sdk/cpprt/memory_manage/delete3.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/util.h" + +SGX_WEAK void SGXAPI operator delete (void* ptr, void* voidptr2) throw() +{ + UNUSED(ptr); + UNUSED(voidptr2); + //doing nothing here +} diff --git a/sdk/cpprt/memory_manage/delete4.cpp b/sdk/cpprt/memory_manage/delete4.cpp new file mode 100644 index 0000000000..b8a7d713b8 --- /dev/null +++ b/sdk/cpprt/memory_manage/delete4.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/se_cdefs.h" + +//Deallocate storage space of array +SGX_WEAK void SGXAPI operator delete[] (void* ptr) throw () +{ + operator delete(ptr); +} diff --git a/sdk/cpprt/memory_manage/delete5.cpp b/sdk/cpprt/memory_manage/delete5.cpp new file mode 100644 index 0000000000..8194c03ba1 --- /dev/null +++ b/sdk/cpprt/memory_manage/delete5.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/se_cdefs.h" + +SGX_WEAK void SGXAPI operator delete[] (void* ptr, const std::nothrow_t& nothrow_constant) throw() +{ + operator delete(ptr, nothrow_constant); +} diff --git a/sdk/cpprt/memory_manage/delete6.cpp b/sdk/cpprt/memory_manage/delete6.cpp new file mode 100644 index 0000000000..ace2c7473c --- /dev/null +++ b/sdk/cpprt/memory_manage/delete6.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/util.h" + +SGX_WEAK void SGXAPI operator delete[] (void* ptr, void* voidptr2) throw() +{ + UNUSED(ptr); + UNUSED(voidptr2); + //doing nothing here +} diff --git a/sdk/cpprt/memory_manage/new1.cpp b/sdk/cpprt/memory_manage/new1.cpp new file mode 100644 index 0000000000..3b52133fc2 --- /dev/null +++ b/sdk/cpprt/memory_manage/new1.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/se_cdefs.h" +#include "internal/cpprt_internal.h" + +//allocates size bytes of storage space. +//aligned to represent an object of that size +//and returns a non-null pointer to the first byte of this block. +//On failure, it throws a bad_alloc exception. +SGX_WEAK void* SGXAPI operator new(size_t dwBytes) throw(std::bad_alloc) +{ + void* address = malloc(dwBytes); + while ( address == NULL ){ + if ( !call_newh() ){ + throw std::bad_alloc(); + } + address = malloc(dwBytes); + } + return address; +} diff --git a/sdk/cpprt/memory_manage/new2.cpp b/sdk/cpprt/memory_manage/new2.cpp new file mode 100644 index 0000000000..2851882a11 --- /dev/null +++ b/sdk/cpprt/memory_manage/new2.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/util.h" +#include "internal/cpprt_internal.h" + +//nothrow version. +//on failure it returns a null pointer instead of throwing an exception. +SGX_WEAK void* SGXAPI operator new (size_t dwBytes, const std::nothrow_t& nothrow_constant) throw() +{ + UNUSED(nothrow_constant); + + void* address = malloc(dwBytes); + while( address == NULL ){ + try { + if ( !call_newh() ){ + return NULL; + } + }catch(...){ + return NULL; + } + address = malloc(dwBytes); + } + return address; +} diff --git a/sdk/cpprt/memory_manage/new3.cpp b/sdk/cpprt/memory_manage/new3.cpp new file mode 100644 index 0000000000..580284c217 --- /dev/null +++ b/sdk/cpprt/memory_manage/new3.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/util.h" + +//placement version +//that does not allocate memory - it simply returns ptr. +//Notice though that the constructor for the object (if any) will still be called by the operator expression. +SGX_WEAK void* SGXAPI operator new (size_t dwBytes, void* ptr) throw() +{ + if( !sgx_is_within_enclave(ptr, dwBytes) ){ + //compiler will check the pointer before call object construct, so it is OK to return NULL here + return NULL; + } + return ptr; +} diff --git a/sdk/cpprt/memory_manage/new4.cpp b/sdk/cpprt/memory_manage/new4.cpp new file mode 100644 index 0000000000..73f5e589b7 --- /dev/null +++ b/sdk/cpprt/memory_manage/new4.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/se_cdefs.h" + +//Allocate storage space for array +SGX_WEAK void* SGXAPI operator new[](size_t dwBytes) throw(std::bad_alloc) +{ + return operator new(dwBytes); +} diff --git a/sdk/cpprt/memory_manage/new5.cpp b/sdk/cpprt/memory_manage/new5.cpp new file mode 100644 index 0000000000..8588534912 --- /dev/null +++ b/sdk/cpprt/memory_manage/new5.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/se_cdefs.h" + +SGX_WEAK void* SGXAPI operator new[] (size_t dwBytes, const std::nothrow_t& nothrow_constant) throw() +{ + return operator new(dwBytes, nothrow_constant); +} diff --git a/sdk/cpprt/memory_manage/new6.cpp b/sdk/cpprt/memory_manage/new6.cpp new file mode 100644 index 0000000000..c477133480 --- /dev/null +++ b/sdk/cpprt/memory_manage/new6.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_defs.h" +#include "sgx_trts.h" +#include "internal/util.h" + +SGX_WEAK void* SGXAPI operator new[] (size_t dwBytes, void* ptr) throw() +{ + if( !sgx_is_within_enclave(ptr, dwBytes) ){ + //compiler will check the pointer before call object construct, so it is OK to return NULL here + return NULL; + } + return ptr; +} diff --git a/sdk/cpprt/memory_manage/new_handler.cpp b/sdk/cpprt/memory_manage/new_handler.cpp new file mode 100644 index 0000000000..2e82c8ba2f --- /dev/null +++ b/sdk/cpprt/memory_manage/new_handler.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include "sgx_trts.h" +#include "sgx_spinlock.h" +#include "internal/se_cdefs.h" + +namespace std{ + static sgx_spinlock_t handler_lock = SGX_SPINLOCK_INITIALIZER; + //default hanlder is NULL + static new_handler new_handl = NULL; + + // set_new_handler() + // Sets new_p as the new handler function. + // The new handler function is the function that is called by functions + // operator new or operator new[] when they are not successful + // in an attempt to allocate memory. + // Parameter + // handler - a pointer to the handler to be called. + // The function can make more storage available or throw an exception or terminate the program. + // new_handler is a function pointer type taking no parameters and returning void. + // Return Value + // new_handler - The value of the current new_handler function if this has been previously set by this function + // NULL -if this is the first call to set_new_handler + new_handler set_new_handler(new_handler handle) throw() + { + sgx_spin_lock(&handler_lock); + new_handler retHandle = new_handl; + if ( handle == NULL ){ + new_handl = NULL; + } else if ( sgx_is_within_enclave((void *)handle, 0) ){ + //only set the handler when handler address is inside enclave + new_handl = handle; + } + sgx_spin_unlock(&handler_lock); + return retHandle; + } +}; + +using namespace std; + +//call new_handl function when new memory failed +int call_newh() +{ + int ret = 0; + sgx_spin_lock(&handler_lock); + new_handler handler = new_handl; + //unlock the handler here because new_handl may call set_new_handler again, will cause dead lock. + sgx_spin_unlock(&handler_lock); + + // call new handler + if ( handler != NULL ){ + handler(); + ret = 1; + } + + return ret; +} diff --git a/sdk/cpprt/tstdcxx_version.cpp b/sdk/cpprt/tstdcxx_version.cpp new file mode 100644 index 0000000000..3d04efd5c6 --- /dev/null +++ b/sdk/cpprt/tstdcxx_version.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_TSTDCXX_VERSION_STR __CONCAT("SGX_TSTDCXX_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_tstdcxx_version = SGX_TSTDCXX_VERSION_STR; + +#ifdef __cplusplus +} +#endif diff --git a/sdk/debugger_interface/linux/Makefile b/sdk/debugger_interface/linux/Makefile new file mode 100644 index 0000000000..0c4acbba7b --- /dev/null +++ b/sdk/debugger_interface/linux/Makefile @@ -0,0 +1,89 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +#Don't CFLAGS +=, because it depend on gdb is m32 or m64 +CFLAGS := + +CPPFLAGS += -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal/ + +CFLAGS += -W -Wall -Werror -D_GNU_SOURCE -fpic -fstack-protector +LDLIBS += -ldl + +ifdef DEBUG + CFLAGS += -g -DSE_DEBUG=1 +endif + +OBJ1 := se_memory.o se_trace.o +OBJ2 := se_ptrace.o ptrace_version.o + +OBJS := $(OBJ1) $(OBJ2) + + +GDB_PLUGINS_FILES := gdb-sgx-plugin/sgx_emmt.py \ + gdb-sgx-plugin/gdb_sgx_cmd \ + gdb-sgx-plugin/gdb_sgx_plugin.py \ + gdb-sgx-plugin/load_symbol_cmd.py \ + gdb-sgx-plugin/readelf.py + +GDB_OUT_DIR := $(BUILD_DIR)/gdb-sgx-plugin +TARGET := libsgx_ptrace.so + + +.PHONY: all +all: $(TARGET) install + +.PHONY:install +install: | $(GDB_OUT_DIR) $(GDB_PLUGINS_FILES) + $(CP) $(GDB_PLUGINS_FILES) $(GDB_OUT_DIR) + $(CP) $(TARGET) $(BUILD_DIR) + +$(TARGET): $(OBJS) + $(CC) -shared -o $@ $^ $(LDLIBS) $(CFLAGS) + +$(OBJ1): %.o: $(COMMON_DIR)/src/%.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +$(OBJ2): %.o: %.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +$(GDB_OUT_DIR): + @$(MKDIR) $@ + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: clean +clean: + @$(RM) $(TARGET) $(OBJS) $(BUILD_DIR)/$(TARGET) + @$(RM) -r $(GDB_OUT_DIR) diff --git a/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_cmd b/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_cmd new file mode 100644 index 0000000000..46f0488b36 --- /dev/null +++ b/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_cmd @@ -0,0 +1,35 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +# the path can be specified by directory command +define hook-detach +detach_enclaves +end diff --git a/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py b/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py new file mode 100755 index 0000000000..77f35f3ae5 --- /dev/null +++ b/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py @@ -0,0 +1,597 @@ +#!/usr/bin/env python +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +from __future__ import print_function +import gdb +import struct +import os.path +from ctypes import create_string_buffer +import load_symbol_cmd +import sgx_emmt + +# Calculate the bit mode of current debuggee project +SIZE = gdb.parse_and_eval("sizeof(long)") + +ET_SIM = 0x1 +ET_DEBUG = 0x2 +PAGE_SIZE = 0x1000 +# The following definitions should strictly align with the structure of +# debug_enclave_info_t in uRTS. +# Here we only care about the first 7 items in the structure. +# pointer: next_enclave_info, start_addr, tcs_list, lpFileName, +# g_peak_heap_used_addr +# int32_t: enclave_type, file_name_size +ENCLAVE_INFO_SIZE = 5 * 8 + 2 * 4 +INFO_FMT = 'QQQIIQQ' +ENCLAVES_ADDR = {} + +# The following definitions should strictly align with the struct of +# tcs_t +# Here we only care about the first 8 items in the structure +# uint64_t: state, flags, ossa, oentry, aep, ofs_base +# uint32_t: nssa, cssa +ENCLAVE_TCS_INFO_SIZE = 6*8 + 2*4 +TCS_INFO_FMT = 'QQQIIQQQ' + +def get_inferior(): + """Get current inferior""" + try: + if len(gdb.inferiors()) == 0: + print ("No gdb inferior could be found.") + return -1 + else: + inferior = gdb.inferiors()[0] + return inferior + except AttributeError: + print ("This gdb's python support is too old, please update first.") + exit() + +def read_from_memory(addr, size): + """Read data with specified size from the specified meomory""" + inferior = get_inferior() + # actually we can check the addr more securely + # ( check the address is inside the enclave) + if inferior == -1 or addr == 0: + print ("Error happens in read_from_memory: addr = {0:x}".format(int(addr))) + return None + try: + string = inferior.read_memory(addr, size) + return string + except gdb.MemoryError: + print ("Can't access memory at {0:x}.".format(int(addr))) + return None + +def write_to_memory(addr, buf): + """Write a specified buffer to the specified memory""" + inferior = get_inferior() + if inferior == -1 or addr == 0: + print ("Error happens in write_to_memory: addr = {0:x}".format(int(addr))) + return -1 + try: + inferior.write_memory(addr, buf) + return 0 + except gdb.MemoryError: + print ("Can't access memory at {0:x}.".format(int(addr))) + return -1 + +def target_path_to_host_path(target_path): + so_name = os.path.basename(target_path) + strpath = gdb.execute("show solib-search-path", False, True) + path = strpath.split()[-1] + strlen = len(path) + path = path[0:strlen-1] + host_path = path + "/" + so_name + #strlen = len(host_path) + #host_path = host_path[0:strlen-7] + return host_path + +class enclave_info: + """Class to contain the enclave inforation, + such as start address, stack addresses, stack size, etc. + The enclave information is for one enclave.""" + def __init__(self, _next_ei, _start_addr, _enclave_type, _stack_addr_list, \ + _stack_size, _enclave_path, _heap_addr, _tcs_addr_list): + self.next_ei = _next_ei + self.start_addr = _start_addr + self.enclave_type = _enclave_type + self.stack_addr_list = _stack_addr_list + self.stack_size = _stack_size + self.enclave_path = _enclave_path + self.heap_addr = _heap_addr + self.tcs_addr_list = _tcs_addr_list + def __str__(self): + print ("stack address list = {0:s}".format(self.stack_addr_list)) + return "start_addr = %#x, enclave_path = \"%s\", stack_size = %d" \ + % (self.start_addr, self.enclave_path, self.stack_size) + def __eq__(self, other): + if other == None: + return False + if self.start_addr == other.start_addr: + return True + else: + return False + def init_enclave_debug(self): + # Only product HW enclave can't be debugged + if (self.enclave_type & ET_SIM) != ET_SIM and (self.enclave_type & ET_DEBUG) != ET_DEBUG: + print ('Warning: {0:s} is a product hardware enclave. It can\'t be debugged and sgx_emmt doesn\'t work'.format(self.enclave_path)) + return -1 + # set TCS debug flag + for tcs_addr in self.tcs_addr_list: + string = read_from_memory(tcs_addr + 8, 4) + if string == None: + return 0 + flag = struct.unpack('I', string)[0] + flag |= 1 + gdb_cmd = "set *(unsigned int *)%#x = %#x" %(tcs_addr + 8, flag) + gdb.execute(gdb_cmd, False, True) + #If it is a product enclave, won't reach here. + #load enclave symbol + if os.path.exists(self.enclave_path) == True: + enclave_path = self.enclave_path + else: + enclave_path = target_path_to_host_path(self.enclave_path) + gdb_cmd = load_symbol_cmd.GetLoadSymbolCommand(enclave_path, str(self.start_addr)) + if gdb_cmd == -1: + return 0 + print (gdb_cmd) + gdb.execute(gdb_cmd, False, True) + global ENCLAVES_ADDR + ENCLAVES_ADDR[self.start_addr] = gdb_cmd.split()[2] + return 0 + + def get_peak_heap_used(self): + """Get the peak value of the heap used""" + if self.heap_addr == 0: + return -2 + # read the peak_heap_used value + string = read_from_memory(self.heap_addr, SIZE) + if string == None: + return -1 + if SIZE == 4: + fmt = 'I' + elif SIZE == 8: + fmt = "Q" + peak_heap_used = struct.unpack(fmt, string)[0] + return peak_heap_used + + def internal_compare (self, a, b): + return (a > b) - (a < b) + + def find_boundary_page_index(self, stack_addr, stack_size): + """Find the unused page index of the boundary for the used and unused pages + with the binary search algorithm""" + page_index = -1 #record the last unused page index + low = 0 + high = (stack_size>>12) - 1 + mid = 0 + # Read the mid page and check if it is used or not + # If the mid page is used, then continue to search [mid+1, high] + while low <= high: + #print "low = %x, high = %x, mid = %x" % (low, high, mid) + mid = (low + high)>>1 + string = read_from_memory(stack_addr + mid*PAGE_SIZE + (PAGE_SIZE>>1), PAGE_SIZE>>1) + if string == None: + return -2 + dirty_flag = 0 + for i in range(0, PAGE_SIZE>>4): + temp = struct.unpack_from("Q", string, ((PAGE_SIZE>>4) - 1 - i)*8)[0] + if (self.internal_compare(temp, 0xcccccccccccccccc)) != 0: + dirty_flag = 1 + break + if dirty_flag == 0: + low = mid + 1 + page_index = mid + else: + high = mid -1 + return page_index + + + def get_peak_stack_used(self): + """Get the peak value of the stack used""" + peak_stack_used = 0 + for stack_addr in self.stack_addr_list: + page_index = self.find_boundary_page_index(stack_addr, self.stack_size) + if page_index == (self.stack_size)/PAGE_SIZE - 1: + continue + elif page_index == -2: + return -1 + else: + string = read_from_memory(stack_addr + (page_index+1) * PAGE_SIZE, PAGE_SIZE) + if string == None: + return -1 + for i in range(0, len(string)): + temp = struct.unpack_from("B", string, i)[0] + if (self.internal_compare(temp, 0xcc)) != 0: + if peak_stack_used < (self.stack_size - (page_index+1) * PAGE_SIZE - i): + peak_stack_used = self.stack_size- (page_index+1) * PAGE_SIZE - i + break # go to the top for loop + return peak_stack_used + + def show_emmt(self): + ret = gdb.execute("show sgx_emmt", False, True) + if ret.strip() == "sgx_emmt enabled": + print ("Enclave: \"{0:s}\"".format(self.enclave_path)) + peak_stack_used = self.get_peak_stack_used() + if peak_stack_used == -1: + print ("Failed to collect the stack usage information for \"{0:s}\"".format(self.enclave_path)) + else: + print (" [Peak stack used]: {0:x}".format(peak_stack_used)) + peak_heap_used = self.get_peak_heap_used() + if peak_heap_used == -1: + print ("Failed to collect the heap usage information for \"{0:s}\"".format(self.enclave_path)) + elif peak_heap_used == -2: + print (" [Can't get peak heap used]: You may use version script to control symbol export. Please export \'g_peak_heap_used\' in your version script.") + else: + print (" [Peak heap used]: {0:x}".format(peak_heap_used)) + + def fini_enclave_debug(self): + # If it is HW product enclave, nothing to do + if (self.enclave_type & ET_SIM) != ET_SIM and (self.enclave_type & ET_DEBUG) != ET_DEBUG: + return -2 + self.show_emmt() + try: + # clear TCS debug flag + for tcs_addr in self.tcs_addr_list: + string = read_from_memory(tcs_addr + 8, 4) + if string == None: + return -2 + flag = struct.unpack('I', string)[0] + flag &= (~1) + gdb_cmd = "set *(unsigned int *)%#x = %#x" %(tcs_addr + 8, flag) + gdb.execute(gdb_cmd, False, True) + #unload symbol + if os.path.exists(self.enclave_path) == True: + enclave_path = self.enclave_path + else: + enclave_path = target_path_to_host_path(self.enclave_path) + gdb_cmd = load_symbol_cmd.GetUnloadSymbolCommand(enclave_path, str(self.start_addr)) + if gdb_cmd == -1: + return -1 + print (gdb_cmd) + try: + gdb.execute(gdb_cmd, False, True) + global ENCLAVES_ADDR + del ENCLAVES_ADDR[self.start_addr] + except gdb.error: + print ("Old gdb doesn't support remove-file-symbol command") + return 0 + ##It is possible enclave has been destroyed, so may raise exception on memory access + except gdb.MemoryError: + return -1 + except: + return -1 + +def retrieve_enclave_info(info_addr = 0): + """retrieve one enclave info""" + # Step 1: find the enclave info address + if info_addr == 0: + if SIZE == 4: + info_addr = gdb.parse_and_eval("$eax") + elif SIZE == 8: + info_addr = gdb.parse_and_eval("$rdi") + + # Step 2: retrieve the enclave info + info_str = read_from_memory(info_addr, ENCLAVE_INFO_SIZE) + if info_str == None: + return None + info_tuple = struct.unpack_from(INFO_FMT, info_str, 0) + # (next_enclave_info,start_addr,tcs_list,enclave_type,file_name_size, + # lpFileName,g_peak_heap_used_addr) + #print "next_addr: %#x, start_addr: %#x, tcs_list: %#x, enclave_type:%#x, file_name_size: %#x," \ + # % (info_tuple[0], info_tuple[1], info_tuple[2], info_tuple[3], info_tuple[4]) + #print "name_addr: %#x, peak_heap_used_addr: %#x" \ + # % (info_tuple[5], info_tuple[6]) + #get enclave path + name_str = read_from_memory(info_tuple[5], info_tuple[4]) + if name_str == None: + return None + fmt = str(info_tuple[4]) + 's' + enclave_path = struct.unpack_from(fmt, name_str)[0].decode(encoding='UTF-8') + # get the stack addr list + stack_addr_list = [] + tcs_addr_list = [] + if SIZE == 4: + fmt = '3I' + elif SIZE == 8: + fmt = '3Q' + tcs_info_addr = info_tuple[2] + if tcs_info_addr == 0: + print ("Error: tcs info address = {0:x}".format(tcs_info_addr)) + return None + + while tcs_info_addr is not 0: + tcs_info_str = read_from_memory(tcs_info_addr, 3*SIZE) + if tcs_info_str == None: + return None + tcs_info_tuple = struct.unpack_from(fmt, tcs_info_str) + + #get tcs struct data + tcs_t_str = read_from_memory(tcs_info_tuple[1], ENCLAVE_TCS_INFO_SIZE) + if tcs_t_str == None: + return None + tcs_t_tuple = struct.unpack_from(TCS_INFO_FMT, tcs_t_str) + + if SIZE == 4: + td_fmt = '4I' + elif SIZE == 8: + td_fmt = '4Q' + + #get thread_data_t address + td_addr = tcs_t_tuple[7] + info_tuple[1] #thread_data_t = tcs.of_base + debug_enclave_info.start_addr + td_str = read_from_memory(td_addr, (4*SIZE)) + if td_str == None: + return None + td_tuple = struct.unpack_from(td_fmt, td_str) + #print ("thread_info:%#x, last_sp:%#x, stack_base_addr:%#x, stack_limit_addr:%#x" \ + # % (td_tuple[0], td_tuple[1], td_tuple[2], td_tuple[3])); + + stacksize = td_tuple[2] - td_tuple[3] #stack size = stack_base_addr - stack_limit_addr + stack_addr_list.append(td_tuple[3]) #use stack limit addr as stack base address + tcs_addr_list.append(tcs_info_tuple[1]) + tcs_info_addr = tcs_info_tuple[0] + + last_ocall_frame = tcs_info_tuple[2] + last_frame = last_ocall_frame + + #print ("last_ocall_frame = {0:x}".format(last_ocall_frame)) + + while last_ocall_frame is not 0: + if SIZE == 4: + of_fmt = '4I' + elif SIZE == 8: + of_fmt = '4Q' + + ocall_frame = read_from_memory(last_ocall_frame, 4*SIZE) + + if ocall_frame == None: + return None + ocall_frame_tuple = struct.unpack_from(of_fmt, ocall_frame) + last_frame = ocall_frame_tuple[0] + + last_trusted_ocall_frame = td_tuple[1] + #print ("last_trusted_ocall_frame = {0:x}".format(last_trusted_ocall_frame)) + #print ("td_tuple[2] = {0:x}".format(td_tuple[2])) + #break + + while last_trusted_ocall_frame != td_tuple[2]: + if SIZE == 4: + oc_fmt = '20I' + elif SIZE == 8: + oc_fmt = '20Q' + + oc_str = read_from_memory(last_trusted_ocall_frame, 20*SIZE) + if oc_str == None: + return None + oc_tuple = struct.unpack_from(oc_fmt, oc_str) + + last_trusted_ocall_frame = oc_tuple[6] + + #print ("last_trusted_ocall_frame = {0:x}".format(last_trusted_ocall_frame)) + #print ("ocall_frame_tuple[1] = {0:x}".format(ocall_frame_tuple[1])) + #print ("oc_tuple[18] = {0:x}".format(oc_tuple[18])) + #break + + if ocall_frame_tuple[1] == oc_tuple[18]: + #ocall_frame.pre_last_frame = 0 + #ocall_frame.ret = ocall_context.ocall_ret + #ocall_frame.xbp = ocall_context.xbp + gdb_cmd = "set *(uintptr_t *)%#x = 0" %(last_ocall_frame) + gdb.execute(gdb_cmd, False, True) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(last_ocall_frame+(2*SIZE), oc_tuple[11]) + gdb.execute(gdb_cmd, False, True) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(last_ocall_frame+(3*SIZE), oc_tuple[19]) + gdb.execute(gdb_cmd, False, True) + break + + last_ocall_frame = last_frame + + node = enclave_info(info_tuple[0], info_tuple[1], info_tuple[3], stack_addr_list, \ + stacksize, enclave_path, info_tuple[6], tcs_addr_list) + return node + +def handle_load_event(): + """Handle the enclave loading event. + Firstly, retrieve the enclave info node from register + """ + node = retrieve_enclave_info() + if node != None: + node.init_enclave_debug() + else: + return + +def handle_unload_event(): + node = retrieve_enclave_info() + if node != None: + node.fini_enclave_debug() + else: + return + +def is_bp_in_urts(): + try: + ip = gdb.parse_and_eval("$pc") + solib_name = gdb.solib_name(int(str(ip).split()[0], 16)) + if(solib_name.find("libsgx_urts.so") == -1 and solib_name.find("libsgx_urts_sim.so") == -1 and solib_name.find("libsgx_aesm_service.so") == -1): + return False + else: + return True + #If exception happens, just assume it is bp in uRTS. + except: + return True + +def init_enclaves_debug(): + enclave_info_addr = gdb.parse_and_eval("*(void**)&g_debug_enclave_info_list") + while enclave_info_addr != 0: + node = retrieve_enclave_info(enclave_info_addr) + if node != None: + node.init_enclave_debug() + else: + return + enclave_info_addr = node.next_ei + return + +class detach_enclaves (gdb.Command): + def __init__ (self): + gdb.Command.__init__ (self, "detach_enclaves", gdb.COMMAND_NONE) + + def invoke (self, arg, from_tty): + #We reject the command from the input of terminal + if from_tty == True: + return + try: + enclave_info_addr = gdb.parse_and_eval("*(void**)&g_debug_enclave_info_list") + except: + return + while enclave_info_addr != 0: + node = retrieve_enclave_info(enclave_info_addr) + if node != None: + node.fini_enclave_debug() + else: + return + enclave_info_addr = node.next_ei + +class UpdateOcallFrame(gdb.Breakpoint): + def __init__(self): + gdb.Breakpoint.__init__ (self, spec="notify_gdb_to_update", internal=1) + + def stop(self): + bp_in_urts = is_bp_in_urts() + + if bp_in_urts == True: + + if SIZE == 4: + base_addr = gdb.parse_and_eval("base") + tcs_addr = gdb.parse_and_eval("tcs") + ocall_frame = gdb.parse_and_eval("of") + elif SIZE == 8: + base_addr = gdb.parse_and_eval("$rdi") + tcs_addr = gdb.parse_and_eval("$rsi") + ocall_frame = gdb.parse_and_eval("$rdx") + + #print ("base_addr = {0:x}".format(int(base_addr))) + #print ("tcs_addr = {0:x}".format(int(tcs_addr))) + #print ("ocall_frame = {0:x}".format(int(ocall_frame))) + + tcs_str = read_from_memory(tcs_addr, ENCLAVE_TCS_INFO_SIZE) + if tcs_str == None: + return False + tcs_tuple = struct.unpack_from(TCS_INFO_FMT, tcs_str) + offset = tcs_tuple[7] + + if SIZE == 4: + td_fmt = '4I' + elif SIZE == 8: + td_fmt = '4Q' + + td_str = read_from_memory(base_addr+offset, (4*SIZE)) + if td_str == None: + return False + td_tuple = struct.unpack_from(td_fmt, td_str) + + if SIZE == 4: + trusted_of_fmt = '20I' + elif SIZE == 8: + trusted_of_fmt = '20Q' + + last_sp = td_tuple[1] + + trusted_ocall_frame = read_from_memory(last_sp, (20*SIZE)) + if trusted_ocall_frame == None: + return False + trusted_ocall_frame_tuple = struct.unpack_from(trusted_of_fmt, trusted_ocall_frame) + + gdb_cmd = "set *(uintptr_t *)%#x = 0" %(ocall_frame) + gdb.execute(gdb_cmd, False, True) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(ocall_frame+(2*SIZE), trusted_ocall_frame_tuple[11]) + gdb.execute(gdb_cmd, False, True) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(ocall_frame+(3*SIZE), trusted_ocall_frame_tuple[19]) + gdb.execute(gdb_cmd, False, True) + + return False + +class LoadEventBreakpoint(gdb.Breakpoint): + def __init__(self): + gdb.Breakpoint.__init__ (self, spec="sgx_debug_load_state_add_element", internal=1) + + def stop(self): + bp_in_urts = is_bp_in_urts() + + if bp_in_urts == True: + handle_load_event() + return False + +class UnloadEventBreakpoint(gdb.Breakpoint): + def __init__(self): + gdb.Breakpoint.__init__ (self, spec="sgx_debug_unload_state_remove_element", internal=1) + + def stop(self): + bp_in_urts = is_bp_in_urts() + + if bp_in_urts == True: + handle_unload_event() + return False + +def sgx_debugger_init(): + print ("detect urts is loaded, initializing") + global SIZE + SIZE = gdb.parse_and_eval("sizeof(long)") + inited = 0 + bps = gdb.breakpoints() + if None != bps: + for bp in bps: + if bp.location == "sgx_debug_load_state_add_element": + inited = 1 + break + if inited == 0: + detach_enclaves() + gdb.execute("source gdb_sgx_cmd", False, True) + UpdateOcallFrame() + LoadEventBreakpoint() + UnloadEventBreakpoint() + gdb.events.exited.connect(exit_handler) + init_enclaves_debug() + + +def exit_handler(event): + # When the inferior exited, remove all enclave symbol + for key in ENCLAVES_ADDR.keys(): + gdb.execute("remove-symbol-file -a %s" % (ENCLAVES_ADDR[key]), False, True) + ENCLAVES_ADDR.clear() + +def newobj_handler(event): + solib_name = os.path.basename(event.new_objfile.filename) + if solib_name == 'libsgx_urts.so' or solib_name == 'libsgx_urts_sim.so' or solib_name == 'libsgx_aesm_service.so': + sgx_debugger_init() + return + +if __name__ == "__main__": + gdb.events.new_objfile.connect(newobj_handler) + sgx_emmt.init_emmt() diff --git a/sdk/debugger_interface/linux/gdb-sgx-plugin/load_symbol_cmd.py b/sdk/debugger_interface/linux/gdb-sgx-plugin/load_symbol_cmd.py new file mode 100755 index 0000000000..9909a5a514 --- /dev/null +++ b/sdk/debugger_interface/linux/gdb-sgx-plugin/load_symbol_cmd.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO + +import traceback, errno, string, re, sys, time, readelf; + +def GetLoadSymbolCommand(EnclaveFile, Base): + text = readelf.ReadElf(EnclaveFile) + if text == None: + return -1 + SegsFile = StringIO(text) + + try: + FileList = SegsFile.readlines() + n=4; + m=100; + Out = [[[] for ni in range(n)] for mi in range(m)] + i=0; + Out[99][2] = '0'; + # Parse the readelf output file to extract the section names and + # their offsets and add the Proj base address. + for line in FileList: + list = line.split(); + if(len(list) > 0): + SegOffset = -1; + # The readelf will put a space after the open bracket for single + # digit section numbers. This causes the line.split to create + # an extra element in the array for these lines. + if(re.match('\[\s*[0-9]+\]',list[0])): + SegOffset = 0; + if(re.match('\s*[0-9]+\]',list[1])): + SegOffset = 1; + + if(SegOffset != -1): + if (list[SegOffset+1][0] == '.'): + # If it is the .text section, put it in a special place in the array + # because the 'add-symbol-file' command treats it differently. + #print "%#08x" % (int(list[SegOffset+3], 16)) + if(list[SegOffset+1].find(".text") != -1): + Out[99][0] = "-s"; + Out[99][1] = list[SegOffset+1]; + Out[99][2] = str(int(list[SegOffset+3], 16) + int(Base, 10)); + Out[99][3] = " "; + elif(int(list[SegOffset+3], 16) != 0): + Out[i][0] = "-s"; + Out[i][1] = list[SegOffset+1]; + Out[i][2] = str(int(list[SegOffset+3], 16) + int(Base, 10)); + Out[i][3] = " "; + i = i+1; + if('0' != Out[99][2]): + # The last section must not have the '\' line continuation character. + Out[i-1][3] = ''; + + # Write the GDB 'add-symbol-file' command with all the arguments to the setup GDB command file. + # Note: The mandatory argument for the 'add-symbol-file' command is the .text section without a + # '-s .SectionName'. All other sections need the '-s .SectionName'. + gdbcmd = "add-symbol-file '" + EnclaveFile + "' " + '%(Location)#08x' % {'Location':int(Out[99][2])} + " -readnow " + for j in range(i): + gdbcmd += Out[j][0] + " " + Out[j][1] + " " + '%(Location)#08x' % {'Location' : int(Out[j][2])} + " " + Out[j][3] + else: + return -1 + + return gdbcmd + + except: + print ("Error parsing enclave file. Check format of file.") + return -1 + +def GetUnloadSymbolCommand(EnclaveFile, Base): + text = readelf.ReadElf(EnclaveFile) + if text == None: + return -1 + SegsFile = StringIO(text) + + try: + FileList = SegsFile.readlines() + # Parse the readelf output file to extract the section names and + # their offsets and add the Proj base address. + for line in FileList: + list = line.split(); + if(len(list) > 0): + SegOffset = -1; + # The readelf will put a space after the open bracket for single + # digit section numbers. This causes the line.split to create + # an extra element in the array for these lines. + if(re.match('\[\s*[0-9]+\]',list[0])): + SegOffset = 0; + if(re.match('\s*[0-9]+\]',list[1])): + SegOffset = 1; + + if(SegOffset != -1): + if (list[SegOffset+1][0] == '.'): + # If it is the .text section, get the .text start address and plus enclave start address + if(list[SegOffset+1].find(".text") != -1): + return "remove-symbol-file -a " + str(int(list[SegOffset+3], 16) + int(Base, 10)) + + except: + print ("Error parsing enclave file. Check format of file.") + return -1 diff --git a/sdk/debugger_interface/linux/gdb-sgx-plugin/readelf.py b/sdk/debugger_interface/linux/gdb-sgx-plugin/readelf.py new file mode 100755 index 0000000000..48c62e9fe2 --- /dev/null +++ b/sdk/debugger_interface/linux/gdb-sgx-plugin/readelf.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +import gdb, subprocess +def ReadElf(EnclaveFile): + prefix = gdb.execute("get_tc_prefix", False, True) + readelf_cmd = 'readelf' + + if prefix.strip() != 'None': + readelf_cmd = prefix.strip() + 'readelf' + try: + text = subprocess.check_output([readelf_cmd, + '-W', + '-S', + EnclaveFile], + universal_newlines=True + ) + except subprocess.CalledProcessError as e: + text = None + + return text diff --git a/sdk/debugger_interface/linux/gdb-sgx-plugin/sgx_emmt.py b/sdk/debugger_interface/linux/gdb-sgx-plugin/sgx_emmt.py new file mode 100755 index 0000000000..ac3098f0e7 --- /dev/null +++ b/sdk/debugger_interface/linux/gdb-sgx-plugin/sgx_emmt.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +import gdb + +ENABLE_EMMT = 0 +TC_PREFIX = None +TC_PREFIX_DONE = False + +class enable_emmt (gdb.Command): + def __init__ (self): + gdb.Command.__init__ (self, "enable sgx_emmt", gdb.COMMAND_RUNNING) + + def invoke (self, arg, from_tty): + global ENABLE_EMMT + ENABLE_EMMT = 1 + +class disable_emmt (gdb.Command): + def __init__ (self): + gdb.Command.__init__ (self, "disable sgx_emmt", gdb.COMMAND_RUNNING) + + def invoke (self, arg, from_tty): + global ENABLE_EMMT + ENABLE_EMMT = 0 + +class show_emmt (gdb.Command): + def __init__ (self): + gdb.Command.__init__ (self, "show sgx_emmt", gdb.COMMAND_RUNNING) + + def invoke (self, arg, from_tty): + global ENABLE_EMMT + if ENABLE_EMMT == 1: + print ("sgx_emmt enabled") + if ENABLE_EMMT == 0: + print ("sgx_emmt disabled") + +class set_tc_prefix(gdb.Command): + def __init__ (self): + gdb.Command.__init__ (self, "set_tc_prefix", gdb.COMMAND_NONE) + + def invoke (self, arg, from_tty): + global TC_PREFIX, TC_PREFIX_DONE + #For internal use, and don't allow input by gdb user + if TC_PREFIX_DONE == True: + return + TC_PREFIX = arg + TC_PREFIX_DONE = True + +class get_tc_prefix(gdb.Command): + def __init__ (self): + gdb.Command.__init__ (self, "get_tc_prefix", gdb.COMMAND_NONE) + + def invoke (self, arg, from_tty): + global TC_PREFIX + #For internal use, and don't allow output to tty + if from_tty == True: + return + print (TC_PREFIX) + +def init_emmt(): + enable_emmt() + disable_emmt() + show_emmt() + set_tc_prefix() + get_tc_prefix() diff --git a/sdk/debugger_interface/linux/ptrace_version.c b/sdk/debugger_interface/linux/ptrace_version.c new file mode 100644 index 0000000000..ff37115de7 --- /dev/null +++ b/sdk/debugger_interface/linux/ptrace_version.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" +#include "se_cdefs.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_PTRACE_VERSION_STR __CONCAT("SGX_PTRACE_VERSION_", STRFILEVER) + +__attribute__((visibility("default"))) +const char * sgx_ptrace_version = SGX_PTRACE_VERSION_STR; + + +SGX_ACCESS_VERSION(ptrace, 1) diff --git a/sdk/debugger_interface/linux/se_ptrace.c b/sdk/debugger_interface/linux/se_ptrace.c new file mode 100644 index 0000000000..6d23bd989c --- /dev/null +++ b/sdk/debugger_interface/linux/se_ptrace.c @@ -0,0 +1,594 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "arch.h" +#include "thread_data.h" +#include "util.h" +#include "se_trace.h" +#include "se_memory.h" +#include +#include +#include +#include +#include +#include + #include + #include +#include +#include +#include +#include +#include + +//NOTE: Need align with thread_data_t in RTS. +#define ELF32_SSA_FS_OFFSET 0x34 + +#ifdef __x86_64__ +#define SSA2USER_REG(to, from, name) to->r##name = from.r##name +#define USER_REG2SSA(to, from, name) to.r##name = from->r##name +#else +#define SSA2USER_REG(to, from, name) to->e##name = from.e##name +#define USER_REG2SSA(to, from, name) to.e##name = from->e##name +#endif + +#define XSTATE_MAX_SIZE 832 + +typedef enum _direction_t +{ + FORWARD, + BACKWARD +} direction_t; + + +typedef long int (* ptrace_t)(enum __ptrace_request request, pid_t pid, + void *addr, void *data); + +static ptrace_t g_sys_ptrace = NULL; +__attribute__((constructor)) void init() +{ + g_sys_ptrace = (ptrace_t)dlsym(RTLD_NEXT, "ptrace"); +} + +#ifdef SE_DEBUG +static void dump_ssa_gregs(ssa_gpr_t* gpr) __attribute__((unused)); +void dump_ssa_gregs(ssa_gpr_t* gpr) +{ + SE_TRACE(SE_TRACE_DEBUG, "ssa generic registers:\n"); + SE_TRACE(SE_TRACE_DEBUG, "xbx = %#lx\t", gpr->REG(bx)); + SE_TRACE(SE_TRACE_DEBUG, "xcx = %#lx\t", gpr->REG(cx)); + SE_TRACE(SE_TRACE_DEBUG, "xdx = %#lx\t", gpr->REG(dx)); + SE_TRACE(SE_TRACE_DEBUG, "xsi = %#lx\t", gpr->REG(si)); + SE_TRACE(SE_TRACE_DEBUG, "xdi = %#lx\t", gpr->REG(di)); + SE_TRACE(SE_TRACE_DEBUG, "xbp = %#lx\t", gpr->REG(bp)); + SE_TRACE(SE_TRACE_DEBUG, "xax = %#lx\t", gpr->REG(ax)); + SE_TRACE(SE_TRACE_DEBUG, "xip = %#lx\t", gpr->REG(ip)); + SE_TRACE(SE_TRACE_DEBUG, "xflags = %#lx\t", gpr->REG(flags)); + SE_TRACE(SE_TRACE_DEBUG, "xsp = %#lx\t", gpr->REG(sp)); +} + +static void dump_regs(struct user_regs_struct *regs) __attribute__((unused)); +void dump_regs(struct user_regs_struct *regs) +{ + SE_TRACE(SE_TRACE_DEBUG, "user regisers:\n"); + SE_TRACE(SE_TRACE_DEBUG, "xbx = %#x\t", regs->REG(bx)); + SE_TRACE(SE_TRACE_DEBUG, "xcx = %#x\t", regs->REG(cx)); + SE_TRACE(SE_TRACE_DEBUG, "xdx = %#x\t", regs->REG(dx)); + SE_TRACE(SE_TRACE_DEBUG, "xsi = %#x\t", regs->REG(si)); + SE_TRACE(SE_TRACE_DEBUG, "xdi = %#x\t", regs->REG(di)); + SE_TRACE(SE_TRACE_DEBUG, "xbp = %#x\t", regs->REG(bp)); + SE_TRACE(SE_TRACE_DEBUG, "xax = %#x\t", regs->REG(ax)); + SE_TRACE(SE_TRACE_DEBUG, "xip = %#x\t", regs->REG(ip)); + SE_TRACE(SE_TRACE_DEBUG, "xflags = %#x\t", regs->eflags); + SE_TRACE(SE_TRACE_DEBUG, "xsp = %#x\t", regs->REG(sp)); +} + +#else + +#define dump_ssa_gregs(gpr) +#define dump_regs(regs) + +#endif + +#ifdef __x86_64__ +static int get_exec_class(pid_t pid) +{ + char filename[64]; + int fd = -1; + unsigned char e_ident[EI_NIDENT]; + + snprintf(filename, 64, "/proc/%d/exe", pid); + fd = open(filename, O_RDONLY | O_LARGEFILE); + if(fd == -1) + return ELFCLASSNONE; + if(-1 == read(fd, e_ident, EI_NIDENT)) + { + return ELFCLASSNONE; + } + + close(fd); + + return e_ident[EI_CLASS]; +} +#endif + +static inline uint32_t get_ssa_frame_size(pid_t pid, thread_data_t* td) +{ + uint32_t ssa_frame_size = td->ssa_frame_size; +#ifdef __x86_64__ + //on x64, we may debug elf32 enclave, we need refer to different offset in td field. + if(ELFCLASS32 == get_exec_class(pid)) + { + ssa_frame_size = *GET_PTR(uint32_t, td, ELF32_SSA_FS_OFFSET); + } +#else + UNUSED(pid); +#endif + + //When debug trts, ssa_frame_size in TD is not initialized, so the value will be 0. + //It is a limitation to debug trts. As work around, the default size is 1 page, so + //we can debug enclave from the start of enclave_entry. + if(0 == ssa_frame_size) + ssa_frame_size = 1; + + return ssa_frame_size; +} + +/* + *This function get the position/offset with SSA + * @pid, process id + * @tcs_addr, TCS start address + * @dir, calculate the position from start of SSA or from the end of SSA + * @offset, offset from the start + * @size, size of data from the postion that is going to be accessed + * @pos, the result of postion that the function output + * @return, TRUE on success, FALSE on fail. The result is copied to parameter pos + * */ +static int get_ssa_pos(pid_t pid, long tcs_addr, direction_t dir, long offset, long size, long *pos) +{ + tcs_t tcs; + thread_data_t td; + uint32_t ssa_frame_size = 0; + long addr = 0; + + //read TCS; + if(!se_read_process_mem(pid, (void *)tcs_addr, (void *)&tcs, 72, NULL)) + return FALSE; + + //Align with RTS. We assume TD is next to TCS + long ssa_start = tcs_addr + TCS_SIZE; + //ossa point to the start address of SSA, and fs/gs point to the start address of TD. + long td_start = ssa_start - tcs.ossa + tcs.ofs_base; + //Read thread data; On x64, sizeof(thread_data_t) of elf64 is larger than elf32, + //so it won't miss any field if it is elf32 executable; + if(!se_read_process_mem(pid, (void *)td_start, (void *)&td, sizeof(thread_data_t), NULL)) + return FALSE; + ssa_frame_size = get_ssa_frame_size(pid, &td); + //The request should not exceed ssa frame boundary. + if((offset + size) > (long)ssa_frame_size * SE_PAGE_SIZE) + return FALSE; + + assert(tcs.cssa > 0); + //If it is required to calculate from the start of SSA + if(FORWARD == dir) + { + addr = ssa_start + (tcs.cssa - 1) * ssa_frame_size * SE_PAGE_SIZE + offset; + + } + //If it is required to calculate from the end of SSA + else if(BACKWARD == dir) + { + addr = ssa_start + tcs.cssa * ssa_frame_size * SE_PAGE_SIZE - offset; + } + else + return FALSE; + + *pos = addr; + return TRUE; +} + +static inline int read_ssa(pid_t pid, long tcs_addr, direction_t dir, long offset, long size, void *buf) +{ + long addr = 0; + + if(!get_ssa_pos(pid, tcs_addr, dir, offset, size, &addr)) + return FALSE; + + //read the content of ssa + if(!se_read_process_mem(pid, (void *)addr, buf, size, NULL)) + return FALSE; + + return TRUE; +} + +static inline int write_ssa(pid_t pid, long tcs_addr, direction_t dir, long offset, long size, void *buf) +{ + long addr = 0; + + if(!get_ssa_pos(pid, tcs_addr, dir, offset, size, &addr)) + return FALSE; + + //write the content of ssa + if(!se_write_process_mem(pid, (void *)addr, buf, size, NULL)) + return FALSE; + + return TRUE; +} + +static inline int get_ssa_gpr(pid_t pid, long tcs_addr, ssa_gpr_t* gpr) +{ + //read general registers. ssa_gpr_t is elf32/elf64 independent. + return read_ssa(pid, tcs_addr, BACKWARD, sizeof(ssa_gpr_t), sizeof(ssa_gpr_t), (void *)gpr); +} + +static inline int set_ssa_gpr(pid_t pid, long tcs_addr, ssa_gpr_t* gpr) +{ + //read general registers. ssa_gpr_t is elf32/elf64 independent. + return write_ssa(pid, tcs_addr, BACKWARD, sizeof(ssa_gpr_t), sizeof(ssa_gpr_t), (void *)gpr); +} + +static inline int get_ssa_fpregs(pid_t pid, long tcs_addr, struct user_fpregs_struct* fpregs) +{ + return read_ssa(pid, tcs_addr, FORWARD, 0, sizeof(struct user_fpregs_struct), (void *)fpregs); +} + +static inline int set_ssa_fpregs(pid_t pid, long tcs_addr, struct user_fpregs_struct* fpregs) +{ + return write_ssa(pid, tcs_addr, FORWARD, 0, sizeof(struct user_fpregs_struct), (void *)fpregs); +} + +#if !defined(__x86_64__) && !defined(__x86_64) +static inline int get_ssa_fpxregs(pid_t pid, long tcs_addr, struct user_fpxregs_struct* fpxregs) +{ + return read_ssa(pid, tcs_addr, FORWARD, 0, sizeof(struct user_fpxregs_struct), (void *)fpxregs); +} + +static inline int set_ssa_fpxregs(pid_t pid, long tcs_addr, struct user_fpxregs_struct* fpxregs) +{ + return write_ssa(pid, tcs_addr, FORWARD, 0, sizeof(struct user_fpxregs_struct), (void *)fpxregs); +} +#else +#define get_ssa_fpxregs get_ssa_fpregs +#define set_ssa_fpxregs set_ssa_fpregs +#define user_fpxregs_struct user_fpregs_struct +#endif + +static inline int get_ssa_xstate(pid_t pid, long tcs_addr, int len, char *buf) +{ + return read_ssa(pid, tcs_addr, FORWARD, 0, len, buf); +} + +static inline int set_ssa_xstate(pid_t pid, long tcs_addr, int len, char *buf) +{ + return write_ssa(pid, tcs_addr, FORWARD, 0, len, buf); +} + +static int get_enclave_gregs(pid_t pid, struct user_regs_struct *regs, long tcs_addr) +{ + ssa_gpr_t gpr; + if(!get_ssa_gpr(pid, tcs_addr, &gpr)) + return -1; + + //convert gpr to user_regs_struct. + SSA2USER_REG(regs, gpr, bx); + SSA2USER_REG(regs, gpr, cx); + SSA2USER_REG(regs, gpr, dx); + SSA2USER_REG(regs, gpr, si); + SSA2USER_REG(regs, gpr, di); + SSA2USER_REG(regs, gpr, bp); + SSA2USER_REG(regs, gpr, ax); + SSA2USER_REG(regs, gpr, ip); + regs->eflags = gpr.REG(flags); + SSA2USER_REG(regs, gpr, sp); +#ifdef __x86_64__ + SSA2USER_REG(regs, gpr, 8); + SSA2USER_REG(regs, gpr, 9); + SSA2USER_REG(regs, gpr, 10); + SSA2USER_REG(regs, gpr, 11); + SSA2USER_REG(regs, gpr, 12); + SSA2USER_REG(regs, gpr, 13); + SSA2USER_REG(regs, gpr, 14); + SSA2USER_REG(regs, gpr, 15); +#endif + return 0; +} + +static int set_enclave_gregs(pid_t pid, struct user_regs_struct *regs, long tcs_addr) +{ + ssa_gpr_t gpr; + + //Since there is some field won't be written, we need save it first + if(!get_ssa_gpr(pid, tcs_addr, &gpr)) + return -1; + + //convert gpr to user_regs_struct. + USER_REG2SSA(gpr, regs, bx); + USER_REG2SSA(gpr, regs, cx); + USER_REG2SSA(gpr, regs, dx); + USER_REG2SSA(gpr, regs, si); + USER_REG2SSA(gpr, regs, di); + USER_REG2SSA(gpr, regs, bp); + USER_REG2SSA(gpr, regs, ax); + USER_REG2SSA(gpr, regs, ip); + gpr.REG(flags) = regs->eflags; + USER_REG2SSA(gpr, regs, sp); +#ifdef __x86_64__ + USER_REG2SSA(gpr, regs, 8); + USER_REG2SSA(gpr, regs, 9); + USER_REG2SSA(gpr, regs, 10); + USER_REG2SSA(gpr, regs, 11); + USER_REG2SSA(gpr, regs, 12); + USER_REG2SSA(gpr, regs, 13); + USER_REG2SSA(gpr, regs, 14); + USER_REG2SSA(gpr, regs, 15); +#endif + + //write general registers to ssa + if(!set_ssa_gpr(pid, tcs_addr, &gpr)) + return -1; + + return 0; +} + +static int is_eresume(pid_t pid, struct user_regs_struct *regs) +{ + unsigned int instr; + + if(!se_read_process_mem(pid, (void *)regs->REG(ip), (char *)&instr, sizeof(instr), NULL)) + return FALSE; + if((ENCLU == (instr & 0xffffff)) + && (SE_ERESUME == regs->REG(ax))) + return TRUE; + return FALSE; +} + +static long int get_regs(pid_t pid, void* addr, void* data) +{ + int ret = 0; + + if(!data) + return -1; + struct user_regs_struct *regs = (struct user_regs_struct *)data; + if(-1 == (ret = g_sys_ptrace(PTRACE_GETREGS, pid, addr, data))) + return -1; + if(is_eresume(pid, regs)) + { + //If it is ERESUME instruction, set the real register value + if(-1 == get_enclave_gregs(pid, regs, regs->REG(bx))) + return -1; + else + { + return ret; + } + } + + return ret; +} + +static long int set_regs(pid_t pid, void* addr, void* data) +{ + int ret = 0; + struct user_regs_struct aep_regs; + + if(!data) + return -1; + if(-1 == g_sys_ptrace(PTRACE_GETREGS, pid, 0, (void*)&aep_regs)) + return -1; + if(is_eresume(pid, &aep_regs)) + { + struct user_regs_struct *regs = (struct user_regs_struct *)data; + //get tcs address + if(-1 == (ret = set_enclave_gregs(pid, regs, aep_regs.REG(bx)))) + return -1; + else + return ret; + } + else + { + return g_sys_ptrace(PTRACE_SETREGS, pid, addr, data); + } +} + +static long int get_fpregs(pid_t pid, void* addr, void* data, int extend) +{ + int ret = 0; + + if(!data) + return -1; + struct user_regs_struct regs; + if(-1 == (ret = g_sys_ptrace(PTRACE_GETREGS, pid, 0, ®s))) + return -1; + if(is_eresume(pid, ®s)) + { + if(extend) + ret = get_ssa_fpxregs(pid, regs.REG(bx), (struct user_fpxregs_struct *)data); + else + ret = get_ssa_fpregs(pid, regs.REG(bx), (struct user_fpregs_struct *)data); + if(ret) + return 0; + else + return -1; + } + else + { + return g_sys_ptrace(PTRACE_GETFPREGS, pid, addr, data); + } +} + +static long int set_fpregs(pid_t pid, void* addr, void* data, int extend) +{ + int ret = 0; + + if(!data) + return -1; + struct user_regs_struct regs; + if(-1 == (ret = g_sys_ptrace(PTRACE_GETREGS, pid, 0, ®s))) + return -1; + if(is_eresume(pid, ®s)) + { + if(extend) + ret = set_ssa_fpxregs(pid, regs.REG(bx), (struct user_fpxregs_struct *)data); + else + ret = set_ssa_fpregs(pid, regs.REG(bx), (struct user_fpregs_struct *)data); + if(ret) + return 0; + else + return -1; + } + else + { + return g_sys_ptrace(PTRACE_GETFPREGS, pid, addr, data); + } +} + +static long int get_regset(pid_t pid, void* addr, void* data) +{ + int ret = 0; + unsigned long type = (unsigned long)addr; + + if(!data) + return -1; + struct user_regs_struct regs; + if(-1 == (ret = g_sys_ptrace(PTRACE_GETREGS, pid, 0, ®s))) + return -1; + + if(is_eresume(pid, ®s)) + { + if(NT_X86_XSTATE != type) + { + SE_TRACE(SE_TRACE_WARNING, "unexpected type for PTRACE_GETREGSET\n"); + return -1; + } + struct iovec *iov = (struct iovec *)data; + if(iov->iov_base && iov->iov_len + && get_ssa_xstate(pid, regs.REG(bx), iov->iov_len, (char *)iov->iov_base)) + { + return 0; + } + else + return -1; + } + else + { + return g_sys_ptrace(PTRACE_GETREGSET, pid, addr, data); + } +} + +static long int set_regset(pid_t pid, void* addr, void* data) +{ + int ret = 0; + unsigned long type = (unsigned long)addr; + + if(!data) + return -1; + struct user_regs_struct regs; + if(-1 == (ret = g_sys_ptrace(PTRACE_GETREGS, pid, 0, ®s))) + return -1; + + if(is_eresume(pid, ®s)) + { + if(NT_X86_XSTATE != type) + { + SE_TRACE(SE_TRACE_WARNING, "unexpected type for PTRACE_SETREGSET\n"); + return -1; + } + struct iovec *iov = (struct iovec *)data; + if(iov->iov_base && iov->iov_len + && set_ssa_xstate(pid, regs.REG(bx), iov->iov_len, (char *)iov->iov_base)) + { + return 0; + } + else + return -1; + } + else + { + return g_sys_ptrace(PTRACE_SETREGSET, pid, addr, data); + } +} + +long int ptrace (enum __ptrace_request __request, ...) +{ + pid_t pid; + void *addr, *data; + va_list ap; + + va_start(ap, __request); + pid = va_arg(ap, pid_t); + addr = va_arg(ap, void *); + data = va_arg(ap, void *); + va_end(ap); + + if(__request == PTRACE_GETREGS) + { + return get_regs(pid, addr, data); + } + else if(__request == PTRACE_SETREGS) + { + return set_regs(pid, addr, data); + } +#if 0 + //some old system may require this command to get register + else if(__request == PTRACE_PEEKUSER) + { + + } +#endif + else if(__request == PTRACE_GETFPREGS) + { + return get_fpregs(pid, addr, data, FALSE); + } + else if(__request == PTRACE_SETFPREGS) + { + return set_fpregs(pid, addr, data, FALSE); + + } + else if(__request == PTRACE_GETFPXREGS) + { + return get_fpregs(pid, addr, data, TRUE); + } + else if(__request == PTRACE_SETFPXREGS) + { + return set_fpregs(pid, addr, data, TRUE); + } + + //xstave for avx + else if(__request == PTRACE_GETREGSET) + { + return get_regset(pid, addr, data); + } + else if(__request == PTRACE_SETREGSET) + { + return set_regset(pid, addr, data); + } + //For other request just forward it to real ptrace call; + return g_sys_ptrace(__request, pid, addr, data); +} diff --git a/sdk/ec_dh_lib/Makefile b/sdk/ec_dh_lib/Makefile new file mode 100644 index 0000000000..f552dcd72a --- /dev/null +++ b/sdk/ec_dh_lib/Makefile @@ -0,0 +1,67 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR := ../.. +include $(TOP_DIR)/buildenv.mk + +CFLAGS += -Werror +CXXFLAGS += -Werror + +INCLUDE += -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc + +vpath %.cpp $(COMMON_DIR)/src + +CXXFLAGS += -fno-exceptions -fno-rtti $(ENCLAVE_CXXFLAGS) + +SRC := ec_dh.cpp \ + ecp.cpp + +OBJ := $(SRC:.cpp=.o) + +LIBNAME := libsgx_dh.a + +.PHONY: all + +all: $(OBJ) + $(AR) rcs $(LIBNAME) $^ + +$(OBJ): %.o :%.cpp + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ + +.PHONY: clean +clean: + @$(RM) *.o + @$(RM) $(LIBNAME) + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/ec_dh_lib/ec_dh.cpp b/sdk/ec_dh_lib/ec_dh.cpp new file mode 100644 index 0000000000..11b39a0bfc --- /dev/null +++ b/sdk/ec_dh_lib/ec_dh.cpp @@ -0,0 +1,821 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "stdlib.h" +#include "string.h" +#include "sgx.h" +#include "sgx_defs.h" +#include "sgx_utils.h" +#include "sgx_ecp_types.h" +#include "sgx_key.h" +#include "sgx_report.h" +#include "sgx_attributes.h" +#include "sgx_trts.h" +#include "ecp_interface.h" +#include "sgx_dh_internal.h" + +#define NONCE_SIZE 16 +#define MSG_BUF_LEN (static_cast(sizeof(sgx_ec256_public_t)*2)) +#define MSG_HASH_SZ 32 + +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} +#endif + +static sgx_status_t verify_cmac128( + const sgx_ec_key_128bit_t mac_key, + const uint8_t* data_buf, + uint32_t buf_size, + const uint8_t* mac_buf) +{ + uint8_t data_mac[SGX_CMAC_MAC_SIZE]; + sgx_status_t se_ret = SGX_SUCCESS; + + if(!data_buf || !mac_buf || !mac_key) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + se_ret = sgx_rijndael128_cmac_msg((const sgx_cmac_128bit_key_t*)mac_key, + data_buf, + buf_size, + (sgx_cmac_128bit_tag_t *)data_mac); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + if(consttime_memequal(mac_buf, data_mac, SGX_CMAC_MAC_SIZE) == 0) + { + return SGX_ERROR_MAC_MISMATCH; + } + + return se_ret; +} + +static sgx_status_t dh_generate_message1(sgx_dh_msg1_t *msg1, sgx_internal_dh_session_t *context) +{ + sgx_report_t temp_report; + sgx_report_data_t report_data = {{0}}; + sgx_target_info_t target; + sgx_status_t se_ret; + sgx_ecc_state_handle_t ecc_state = NULL; + + if(!msg1 || !context) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + memset(&temp_report, 0, sizeof(temp_report)); + memset(&target, 0, sizeof(target)); + + //Create Report to get target info which targeted towards the initiator of the session + se_ret = sgx_create_report(&target, &report_data,&temp_report); + if(se_ret != SGX_SUCCESS) + { + return se_ret; + } + + memcpy(&msg1->target.mr_enclave, + &temp_report.body.mr_enclave, + sizeof(sgx_measurement_t)); + memcpy(&msg1->target.attributes, + &temp_report.body.attributes, + sizeof(sgx_attributes_t)); + msg1->target.misc_select = temp_report.body.misc_select; + + //Initialize ECC context to prepare for creating key pair + se_ret = sgx_ecc256_open_context(&ecc_state); + if(se_ret != SGX_SUCCESS) + { + return se_ret; + } + //Generate the public key private key pair for Session Responder + se_ret = sgx_ecc256_create_key_pair((sgx_ec256_private_t*)&context->responder.prv_key, + (sgx_ec256_public_t*)&context->responder.pub_key, + ecc_state); + if(se_ret != SGX_SUCCESS) + { + sgx_ecc256_close_context(ecc_state); + return se_ret; + } + + //Copying public key to g^a + memcpy(&msg1->g_a, + &context->responder.pub_key, + sizeof(sgx_ec256_public_t)); + + se_ret = sgx_ecc256_close_context(ecc_state); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + return SGX_SUCCESS; +} + +static sgx_status_t dh_generate_message2(const sgx_dh_msg1_t *msg1, + const sgx_ec256_public_t *g_b, + const sgx_key_128bit_t *dh_smk, + sgx_dh_msg2_t *msg2) +{ + sgx_report_t temp_report; + sgx_report_data_t report_data; + + sgx_status_t se_ret; + + uint8_t msg_buf[MSG_BUF_LEN] = {0}; + uint8_t msg_hash[MSG_HASH_SZ] = {0}; + + if(!msg1 || !g_b || !dh_smk || !msg2) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + memset(msg2, 0, sizeof(sgx_dh_msg2_t)); + memcpy(&msg2->g_b, g_b, sizeof(sgx_ec256_public_t)); + + memcpy(msg_buf, + &msg1->g_a, + sizeof(sgx_ec256_public_t)); + memcpy(msg_buf + sizeof(sgx_ec256_public_t), + &msg2->g_b, + sizeof(sgx_ec256_public_t)); + + se_ret = sgx_sha256_msg(msg_buf, + MSG_BUF_LEN, + (sgx_sha256_hash_t *)msg_hash); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + // Get REPORT with sha256(msg1->g_a | msg2->g_b) || kdf_id as user data + // 2-byte little-endian KDF-ID: 0x0001 AES-CMAC Entropy Extraction and Key Derivation + memset(&report_data, 0, sizeof(sgx_report_data_t)); + memcpy(&report_data, &msg_hash, sizeof(msg_hash)); + + uint16_t *kdf_id = (uint16_t *)&report_data.d[sizeof(msg_hash)]; + *kdf_id = AES_CMAC_KDF_ID; + + // Generate Report targeted towards Session Responder + se_ret = sgx_create_report(&msg1->target, &report_data, &temp_report); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + memcpy(&msg2->report, &temp_report, sizeof(sgx_report_t)); + + //Calculate the MAC for Message 2 + se_ret = sgx_rijndael128_cmac_msg(dh_smk, + (uint8_t *)(&msg2->report), + sizeof(sgx_report_t), + (sgx_cmac_128bit_tag_t *)msg2->cmac); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + return SGX_SUCCESS; +} + +static sgx_status_t dh_verify_message2(const sgx_dh_msg2_t *msg2, + const sgx_ec256_public_t *g_a, + const sgx_key_128bit_t *dh_smk) +{ + sgx_report_t temp_report; + sgx_status_t se_ret; + + uint8_t msg_buf[MSG_BUF_LEN] = {0}; + uint8_t msg_hash[MSG_HASH_SZ] = {0}; + + if(!msg2 || !g_a || !dh_smk) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + /* report_data = SHA256(g_a || g_b) || kdf_id + * Verify kdf_id first. + * 2-byte little-endian KDF-ID: 0x0001 AES-CMAC Entropy Extraction and Key Derivation + */ + uint16_t *kdf_id = (uint16_t *)&msg2->report.body.report_data.d[sizeof(msg_hash)]; + if (*kdf_id != AES_CMAC_KDF_ID) + { + return SGX_ERROR_KDF_MISMATCH; + } + + //Verify the MAC of message 2 obtained from the Session Initiator + se_ret = verify_cmac128((const uint8_t*)dh_smk, (const uint8_t*)(&msg2->report), sizeof(sgx_report_t), msg2->cmac); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + memcpy(&temp_report,&msg2->report,sizeof(sgx_report_t)); + + // Verify message 2 report obtained from the Session Initiator + se_ret = sgx_verify_report(&temp_report); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + memcpy(msg_buf, g_a, sizeof(sgx_ec256_public_t)); + memcpy(msg_buf + sizeof(sgx_ec256_public_t), &msg2->g_b, sizeof(sgx_ec256_public_t)); + + se_ret = sgx_sha256_msg(msg_buf, + MSG_BUF_LEN, + (sgx_sha256_hash_t *)msg_hash); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + // report_data = SHA256(g_a || g_b) || kdf_id + // Verify SHA256(g_a || g_b) + if (0 != memcmp(msg_hash, + &msg2->report.body.report_data, + sizeof(msg_hash))) + { + return SGX_ERROR_MAC_MISMATCH; + } + + return SGX_SUCCESS; +} + +static sgx_status_t dh_generate_message3(const sgx_dh_msg2_t *msg2, + const sgx_ec256_public_t *g_a, + const sgx_key_128bit_t *dh_smk, + sgx_dh_msg3_t *msg3, + uint32_t msg3_additional_prop_len) +{ + sgx_report_t temp_report; + sgx_report_data_t report_data; + sgx_status_t se_ret = SGX_SUCCESS; + uint32_t maced_size; + + uint8_t msg_buf[MSG_BUF_LEN] = {0}; + uint8_t msg_hash[MSG_HASH_SZ] = {0}; + + sgx_target_info_t target; + + if(!msg2 || !g_a || !dh_smk || !msg3) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + maced_size = static_cast(sizeof(sgx_dh_msg3_body_t)) + msg3_additional_prop_len; + + memset(msg3, 0, sizeof(sgx_dh_msg3_t)); // Don't clear the additional property since the content of the property is provided by caller. + + memcpy(msg_buf, &msg2->g_b, sizeof(sgx_ec256_public_t)); + memcpy(msg_buf + sizeof(sgx_ec256_public_t), g_a, sizeof(sgx_ec256_public_t)); + + se_ret = sgx_sha256_msg(msg_buf, + MSG_BUF_LEN, + (sgx_sha256_hash_t *)msg_hash); + if(se_ret != SGX_SUCCESS) + { + return se_ret; + } + + memset(&target, 0, sizeof(sgx_target_info_t)); + + // Get REPORT with SHA256(g_b||g_a) as user data + memset(&report_data, 0, sizeof(sgx_report_data_t)); + memcpy(&report_data, &msg_hash, sizeof(msg_hash)); + + memcpy(&target.attributes, + &msg2->report.body.attributes, + sizeof(sgx_attributes_t)); + memcpy(&target.mr_enclave, + &msg2->report.body.mr_enclave, + sizeof(sgx_measurement_t)); + target.misc_select = msg2->report.body.misc_select; + + // Generate Report targeted towards Session Initiator + se_ret = sgx_create_report(&target, &report_data, &temp_report); + if(se_ret != SGX_SUCCESS) + { + return se_ret; + } + + memcpy(&msg3->msg3_body.report, + &temp_report, + sizeof(sgx_report_t)); + + msg3->msg3_body.additional_prop_length = msg3_additional_prop_len; + + //Calculate the MAC for Message 3 + se_ret = sgx_rijndael128_cmac_msg(dh_smk, + (uint8_t *)&msg3->msg3_body, + maced_size, + (sgx_cmac_128bit_tag_t *)msg3->cmac); + if(se_ret != SGX_SUCCESS) + { + return se_ret; + } + + return SGX_SUCCESS; +} + +static sgx_status_t dh_verify_message3(const sgx_dh_msg3_t *msg3, + const sgx_ec256_public_t *g_a, + const sgx_ec256_public_t *g_b, + const sgx_key_128bit_t *dh_smk) +{ + sgx_report_t temp_report; + uint32_t maced_size; + sgx_status_t se_ret; + + uint8_t msg_buf[MSG_BUF_LEN] = {0}; + uint8_t msg_hash[MSG_HASH_SZ] = {0}; + + if(!msg3 || !g_a || !g_b || !dh_smk) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + maced_size = static_cast(sizeof(sgx_dh_msg3_body_t)) + msg3->msg3_body.additional_prop_length; + + //Verify the MAC of message 3 obtained from the Session Responder + se_ret = verify_cmac128((const uint8_t*)dh_smk, (const uint8_t*)&msg3->msg3_body, maced_size, msg3->cmac); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + memcpy(&temp_report, &msg3->msg3_body.report, sizeof(sgx_report_t)); + + // Verify message 3 report + se_ret = sgx_verify_report(&temp_report); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + memcpy(msg_buf, + g_b, + sizeof(sgx_ec256_public_t)); + memcpy(msg_buf + sizeof(sgx_ec256_public_t), + g_a, + sizeof(sgx_ec256_public_t)); + + se_ret = sgx_sha256_msg(msg_buf, + MSG_BUF_LEN, + (sgx_sha256_hash_t *)msg_hash); + if(SGX_SUCCESS != se_ret) + { + return se_ret; + } + + // Verify message 3 report data + if (0 != memcmp(msg_hash, + &msg3->msg3_body.report.body.report_data, + sizeof(msg_hash))) + { + return SGX_ERROR_MAC_MISMATCH; + } + + return SGX_SUCCESS; +} + +// sgx_status_t sgx_dh_init_session() +// @role indicates whether the caller is a Initiator (starting the session negotiation) or a Responder (responding to the intial session negotiation request). +// @sgx_dh_session is the context of the session. +sgx_status_t sgx_dh_init_session(sgx_dh_session_role_t role, sgx_dh_session_t* sgx_dh_session) +{ + sgx_internal_dh_session_t* session = (sgx_internal_dh_session_t*)sgx_dh_session; + + if(!session || 0 == sgx_is_within_enclave(session, sizeof(sgx_internal_dh_session_t))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + if(SGX_DH_SESSION_INITIATOR != role && SGX_DH_SESSION_RESPONDER != role) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + + if(SGX_DH_SESSION_INITIATOR == role) + { + session->initiator.state = SGX_DH_SESSION_INITIATOR_WAIT_M1; + } + else + { + session->responder.state = SGX_DH_SESSION_STATE_RESET; + } + + session->role = role; + + return SGX_SUCCESS; +} + + +// Function sgx_dh_responder_gen_msg1 generates M1 message and makes update to the context of the session. +sgx_status_t sgx_dh_responder_gen_msg1(sgx_dh_msg1_t* msg1, sgx_dh_session_t* sgx_dh_session) +{ + sgx_status_t se_ret; + sgx_internal_dh_session_t* session = (sgx_internal_dh_session_t*)sgx_dh_session; + + // validate session + if(!session || + 0 == sgx_is_within_enclave(session, sizeof(sgx_internal_dh_session_t))) // session must be in enclave + { + return SGX_ERROR_INVALID_PARAMETER; + } + + if(!msg1 || + 0 == sgx_is_within_enclave(msg1, sizeof(sgx_dh_msg1_t)) || + SGX_DH_SESSION_RESPONDER != session->role) + { + se_ret = SGX_ERROR_INVALID_PARAMETER; + goto error; + } + + if(SGX_DH_SESSION_STATE_RESET != session->responder.state) + { + se_ret = SGX_ERROR_INVALID_STATE; + goto error; + } + + se_ret = dh_generate_message1(msg1, session); + if(SGX_SUCCESS != se_ret) + { + // return selected error to upper layer + INTERNAL_SGX_ERROR_CODE_CONVERTOR(se_ret) + goto error; + } + + session->responder.state = SGX_DH_SESSION_RESPONDER_WAIT_M2; + + return SGX_SUCCESS; +error: + // clear session + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->responder.state = SGX_DH_SESSION_STATE_ERROR; + return se_ret; +} + +//sgx_dh_initiator_proc_msg1 processes M1 message, generates M2 message and makes update to the context of the session. +sgx_status_t sgx_dh_initiator_proc_msg1(const sgx_dh_msg1_t* msg1, sgx_dh_msg2_t* msg2, sgx_dh_session_t* sgx_dh_session) +{ + sgx_status_t se_ret; + + sgx_ec256_public_t pub_key; + sgx_ec256_private_t priv_key; + sgx_ec256_dh_shared_t shared_key; + sgx_key_128bit_t dh_smk; + + sgx_internal_dh_session_t* session = (sgx_internal_dh_session_t*) sgx_dh_session; + + // validate session + if(!session || + 0 == sgx_is_within_enclave(session, sizeof(sgx_internal_dh_session_t))) // session must be in enclave + { + return SGX_ERROR_INVALID_PARAMETER; + } + + if( !msg1 || + !msg2 || + 0 == sgx_is_within_enclave(msg1, sizeof(sgx_dh_msg1_t)) || + 0 == sgx_is_within_enclave(msg2, sizeof(sgx_dh_msg2_t)) || + SGX_DH_SESSION_INITIATOR != session->role) + { + // clear secret when encounter error + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->initiator.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_INVALID_PARAMETER; + } + + if(SGX_DH_SESSION_INITIATOR_WAIT_M1 != session->initiator.state) + { + // clear secret + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->initiator.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_INVALID_STATE; + } + + //create ECC context + sgx_ecc_state_handle_t ecc_state = NULL; + se_ret = sgx_ecc256_open_context(&ecc_state); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + // generate private key and public key + se_ret = sgx_ecc256_create_key_pair((sgx_ec256_private_t*)&priv_key, + (sgx_ec256_public_t*)&pub_key, + ecc_state); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + //generate shared_key + se_ret = sgx_ecc256_compute_shared_dhkey( + (sgx_ec256_private_t *)const_cast(&priv_key), + (sgx_ec256_public_t *)const_cast(&msg1->g_a), + (sgx_ec256_dh_shared_t *)&shared_key, + ecc_state); + + // clear private key for defense in depth + memset_s(&priv_key, sizeof(sgx_ec256_private_t), 0, sizeof(sgx_ec256_private_t)); + + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + se_ret = derive_key(&shared_key, "SMK", (uint32_t)(sizeof("SMK") -1), &dh_smk); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + se_ret = dh_generate_message2(msg1, &pub_key, &dh_smk, msg2); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + memcpy(&session->initiator.pub_key, &pub_key, sizeof(sgx_ec256_public_t)); + memcpy(&session->initiator.peer_pub_key, &msg1->g_a, sizeof(sgx_ec256_public_t)); + memcpy(&session->initiator.smk_aek, &dh_smk, sizeof(sgx_key_128bit_t)); + memcpy(&session->initiator.shared_key, &shared_key, sizeof(sgx_ec256_dh_shared_t)); + // clear shared key and SMK + memset_s(&shared_key, sizeof(sgx_ec256_dh_shared_t), 0, sizeof(sgx_ec256_dh_shared_t)); + memset_s(&dh_smk, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + + if(SGX_SUCCESS != sgx_ecc256_close_context(ecc_state)) + { + // clear session + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + // set error state + session->initiator.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_UNEXPECTED; + } + + session->initiator.state = SGX_DH_SESSION_INITIATOR_WAIT_M3; + return SGX_SUCCESS; + +error: + sgx_ecc256_close_context(ecc_state); + + // clear shared key and SMK + memset_s(&shared_key, sizeof(sgx_ec256_dh_shared_t), 0, sizeof(sgx_ec256_dh_shared_t)); + memset_s(&dh_smk, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->initiator.state = SGX_DH_SESSION_STATE_ERROR; + + // return selected error to upper layer + INTERNAL_SGX_ERROR_CODE_CONVERTOR(se_ret) + + return se_ret; +} + +//sgx_dh_responder_proc_msg2 processes M2 message, generates M3 message, and returns the session key AEK. +sgx_status_t sgx_dh_responder_proc_msg2(const sgx_dh_msg2_t* msg2, + sgx_dh_msg3_t* msg3, + sgx_dh_session_t* sgx_dh_session, + sgx_key_128bit_t* aek, + sgx_dh_session_enclave_identity_t* initiator_identity) +{ + sgx_status_t se_ret; + + sgx_ec256_dh_shared_t shared_key; + sgx_key_128bit_t dh_smk; + + sgx_internal_dh_session_t* session = (sgx_internal_dh_session_t*)sgx_dh_session; + + // validate session + if(!session || + 0 == sgx_is_within_enclave(session, sizeof(sgx_internal_dh_session_t))) // session must be in enclave + { + return SGX_ERROR_INVALID_PARAMETER; + } + + if(!msg3 || + msg3->msg3_body.additional_prop_length > (UINT_MAX - sizeof(sgx_dh_msg3_t)) || // check msg3 length overflow + 0 == sgx_is_within_enclave(msg3, (sizeof(sgx_dh_msg3_t)+msg3->msg3_body.additional_prop_length)) || // must be in enclave + !msg2 || + 0 == sgx_is_within_enclave(msg2, sizeof(sgx_dh_msg2_t)) || // must be in enclave + !aek || + 0 == sgx_is_within_enclave(aek, sizeof(sgx_key_128bit_t)) || // must be in enclave + !initiator_identity || + 0 == sgx_is_within_enclave(initiator_identity, sizeof(sgx_dh_session_enclave_identity_t)) || // must be in enclave + SGX_DH_SESSION_RESPONDER != session->role) + { + // clear secret when encounter error + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->responder.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_INVALID_PARAMETER; + } + + if(SGX_DH_SESSION_RESPONDER_WAIT_M2 != session->responder.state) // protocol state must be SGX_DH_SESSION_RESPONDER_WAIT_M2 + { + // clear secret + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->responder.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_INVALID_STATE; + } + + //create ECC context, and the ECC parameter is + //NIST standard P-256 elliptic curve. + sgx_ecc_state_handle_t ecc_state = NULL; + se_ret = sgx_ecc256_open_context(&ecc_state); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + //generate shared key, which should be identical with enclave side, + //from PSE private key and enclave public key + se_ret = sgx_ecc256_compute_shared_dhkey((sgx_ec256_private_t *)&session->responder.prv_key, + (sgx_ec256_public_t *)const_cast(&msg2->g_b), + (sgx_ec256_dh_shared_t *)&shared_key, + ecc_state); + + // For defense-in-depth purpose, responder clears its private key from its enclave memory, as it's not needed anymore. + memset_s(&session->responder.prv_key, sizeof(sgx_ec256_private_t), 0, sizeof(sgx_ec256_private_t)); + + if(se_ret != SGX_SUCCESS) + { + goto error; + } + + + //derive keys from session shared key + se_ret = derive_key(&shared_key, "SMK", (uint32_t)(sizeof("SMK") -1), &dh_smk); + if(se_ret != SGX_SUCCESS) + { + goto error; + } + // Verify message 2 from Session Initiator and also Session Initiator's identity + se_ret = dh_verify_message2(msg2, &session->responder.pub_key, &dh_smk); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + initiator_identity->isv_svn = msg2->report.body.isv_svn; + initiator_identity->isv_prod_id = msg2->report.body.isv_prod_id; + memcpy(&initiator_identity->attributes, &msg2->report.body.attributes, sizeof(sgx_attributes_t)); + memcpy(&initiator_identity->mr_signer, &msg2->report.body.mr_signer, sizeof(sgx_measurement_t)); + memcpy(&initiator_identity->mr_enclave, &msg2->report.body.mr_enclave, sizeof(sgx_measurement_t)); + + // Generate message 3 to send back to initiator + se_ret = dh_generate_message3(msg2, + &session->responder.pub_key, + &dh_smk, + msg3, + msg3->msg3_body.additional_prop_length); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + // derive session key + se_ret = derive_key(&shared_key, "AEK", (uint32_t)(sizeof("AEK") -1), aek); + if(se_ret != SGX_SUCCESS) + { + goto error; + } + + // clear secret + memset_s(&shared_key, sizeof(sgx_ec256_dh_shared_t), 0, sizeof(sgx_ec256_dh_shared_t)); + memset_s(&dh_smk, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + // clear session + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + + se_ret = sgx_ecc256_close_context(ecc_state); + if(SGX_SUCCESS != se_ret) + { + // set error state + session->responder.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_UNEXPECTED; + } + + // set state + session->responder.state = SGX_DH_SESSION_ACTIVE; + + return SGX_SUCCESS; + +error: + sgx_ecc256_close_context(ecc_state); + // clear secret + memset_s(&shared_key, sizeof(sgx_ec256_dh_shared_t), 0, sizeof(sgx_ec256_dh_shared_t)); + memset_s(&dh_smk, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + // set error state + session->responder.state = SGX_DH_SESSION_STATE_ERROR; + // return selected error to upper layer + if (se_ret != SGX_ERROR_OUT_OF_MEMORY && + se_ret != SGX_ERROR_KDF_MISMATCH) + { + se_ret = SGX_ERROR_UNEXPECTED; + } + return se_ret; +} + +//sgx_dh_initiator_proc_msg3 processes M3 message, and returns the session key AEK. +sgx_status_t sgx_dh_initiator_proc_msg3(const sgx_dh_msg3_t* msg3, + sgx_dh_session_t* sgx_dh_session, + sgx_key_128bit_t* aek, + sgx_dh_session_enclave_identity_t* responder_identity) +{ + sgx_status_t se_ret; + sgx_internal_dh_session_t* session = (sgx_internal_dh_session_t*)sgx_dh_session; + + // validate session + if(!session || + 0 == sgx_is_within_enclave(session, sizeof(sgx_internal_dh_session_t))) // session must be in enclave + { + return SGX_ERROR_INVALID_PARAMETER; + } + + if(!msg3 || + msg3->msg3_body.additional_prop_length > (UINT_MAX - sizeof(sgx_dh_msg3_t)) || // check msg3 length overflow + 0 == sgx_is_within_enclave(msg3, (sizeof(sgx_dh_msg3_t)+msg3->msg3_body.additional_prop_length)) || // msg3 buffer must be in enclave + !aek || + 0 == sgx_is_within_enclave(aek, sizeof(sgx_key_128bit_t)) || // aek buffer must be in enclave + !responder_identity || + 0 == sgx_is_within_enclave(responder_identity, sizeof(sgx_dh_session_enclave_identity_t)) || // responder_identity buffer must be in enclave + SGX_DH_SESSION_INITIATOR != session->role) // role must be SGX_DH_SESSION_INITIATOR + { + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->initiator.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_INVALID_PARAMETER; + } + + if(SGX_DH_SESSION_INITIATOR_WAIT_M3 != session->initiator.state) // protocol state must be SGX_DH_SESSION_INITIATOR_WAIT_M3 + { + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->initiator.state = SGX_DH_SESSION_STATE_ERROR; + return SGX_ERROR_INVALID_STATE; + } + + se_ret = dh_verify_message3(msg3, + &session->initiator.peer_pub_key, + &session->initiator.pub_key, + &session->initiator.smk_aek); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + // derive AEK + se_ret = derive_key(&session->initiator.shared_key, "AEK", (uint32_t)(sizeof("AEK") -1), aek); + if(SGX_SUCCESS != se_ret) + { + goto error; + } + + // clear session + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->initiator.state = SGX_DH_SESSION_ACTIVE; + + // copy the common fields between REPORT and the responder enclave identity + memcpy(responder_identity, &msg3->msg3_body.report.body, sizeof(sgx_dh_session_enclave_identity_t)); + + return SGX_SUCCESS; + +error: + memset_s(session, sizeof(sgx_internal_dh_session_t), 0, sizeof(sgx_internal_dh_session_t)); + session->initiator.state = SGX_DH_SESSION_STATE_ERROR; + INTERNAL_SGX_ERROR_CODE_CONVERTOR(se_ret) + return se_ret; +} + diff --git a/sdk/ec_dh_lib/sgx_dh_internal.h b/sdk/ec_dh_lib/sgx_dh_internal.h new file mode 100644 index 0000000000..66c7af67c9 --- /dev/null +++ b/sdk/ec_dh_lib/sgx_dh_internal.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SGX_DH_INTERNAL_H_ +#define _SGX_DH_INTERNAL_H_ + +#include "sgx.h" +#include "sgx_defs.h" +#include "sgx_ecp_types.h" +#include "sgx_dh.h" + +#pragma pack(push, 1) + +typedef enum _sgx_dh_session_state_t +{ + SGX_DH_SESSION_STATE_ERROR, + SGX_DH_SESSION_STATE_RESET, + SGX_DH_SESSION_RESPONDER_WAIT_M2, + SGX_DH_SESSION_INITIATOR_WAIT_M1, + SGX_DH_SESSION_INITIATOR_WAIT_M3, + SGX_DH_SESSION_ACTIVE +} sgx_dh_session_state_t; + +typedef struct _sgx_dh_responder_t{ + sgx_dh_session_state_t state; /*Responder State Machine State */ + sgx_ec256_private_t prv_key; /* 256bit EC private key */ + sgx_ec256_public_t pub_key; /* 512 bit EC public key */ +} sgx_dh_responder_t; + +typedef struct _sgx_dh_initator_t{ + sgx_dh_session_state_t state; /* Initiator State Machine State */ + union{ + sgx_ec256_private_t prv_key; /* 256bit EC private key */ + sgx_key_128bit_t smk_aek; /* 128bit SMK or AEK. Depending on the State */ + }; + sgx_ec256_public_t pub_key; /* 512 bit EC public key */ + sgx_ec256_public_t peer_pub_key; /* 512 bit EC public key from the Responder */ + sgx_ec256_dh_shared_t shared_key; +} sgx_dh_initator_t; + +typedef struct _sgx_internal_dh_session_t{ + sgx_dh_session_role_t role; /* Initiator or Responder */ + union{ + sgx_dh_responder_t responder; + sgx_dh_initator_t initiator; + }; +} sgx_internal_dh_session_t; + +static_assert(sizeof(sgx_internal_dh_session_t) == SGX_DH_SESSION_DATA_SIZE, "size mismatch on sgx_internal_dh_session_t and sgx_dh_session_t"); + +#pragma pack(pop) + +#endif + + + diff --git a/sdk/edger8r/linux/Ast.ml b/sdk/edger8r/linux/Ast.ml new file mode 100644 index 0000000000..3bc15aae27 --- /dev/null +++ b/sdk/edger8r/linux/Ast.ml @@ -0,0 +1,251 @@ +(* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *) + +(* Available types. *) +type signedness = Signed | Unsigned +type shortness = IShort | ILong | INone + +type int_attr = { + ia_signedness : signedness; + ia_shortness : shortness; +} + +type atype = + | Char of signedness + | Long of signedness + | LLong of signedness + | Int of int_attr + | Float | Double | LDouble + | Int8 | Int16 | Int32 | Int64 + | UInt8 | UInt16 | UInt32 | UInt64 + | Void | WChar | SizeT + | Struct of string + | Union of string + | Enum of string + | Foreign of string + | Ptr of atype + +(* Pointer parameter direction *) +type ptr_direction = + | PtrIn | PtrOut | PtrInOut | PtrNoDirection + +(* It holds possible values for a given attribute. *) +type attr_value = + | AString of string + | ANumber of int + +type ptr_size = { + ps_size : attr_value option; + ps_sizefunc : string option; + ps_count : attr_value option; +} + +let empty_ptr_size = { + ps_size = None; + ps_sizefunc = None; + ps_count = None; +} + +(* Pointers have several special attributes. *) +type ptr_attr = { + pa_direction : ptr_direction; + pa_size : ptr_size; + pa_isptr : bool; (* If a foreign type is a pointer type *) + pa_isary : bool; (* If a foreign type is an array *) + pa_isstr : bool; + pa_iswstr : bool; + pa_rdonly : bool; (* If the pointer is 'const' qualified *) + pa_chkptr : bool; (* Whether to generate code to check pointer *) +} + +(* parameter type *) +type parameter_type = + | PTVal of atype (* Passed by value *) + | PTPtr of atype * ptr_attr (* Passed by address *) + +type call_conv = CC_CDECL | CC_STDCALL | CC_FASTCALL | CC_NONE + +let get_call_conv_str (cc: call_conv) = + match cc with + CC_CDECL -> "CDECL" + | CC_STDCALL -> "STDCALL" + | CC_FASTCALL -> "FASTCALL" + | CC_NONE -> "NOCONVENTION" + +(* function attribute - only for untrusted functions *) +type func_attr = { + fa_dllimport : bool; (* use 'dllimport'? *) + fa_convention: call_conv; (* the calling convention *) +} + +(* A declarator can be an identifier or an identifier with array form. + * For a simlpe identifier, the `array_dims' is an empty list `[]'. + * A dimension with size -1 means that user explicitly declared `ary[]'. + *) +type declarator = { + identifier : string; + array_dims : int list; +} + +let is_array (declr: declarator) = declr.array_dims <> [] + +(* Parameter declaration. *) +type pdecl = parameter_type * declarator + +(* Structure member declaration *) +type mdecl = atype * declarator + +(* Definition of a struct or union *) +type struct_def = { + sname : string; (* structure name. *) + mlist : mdecl list; (* structure members. *) +} + +(* Definition of a enum *) +type enum_val = EnumValNone | EnumVal of attr_value +type enum_ele = string * enum_val + +type enum_def = { + enname: string; (* enum name - "" for anonymous enum *) + enbody: enum_ele list; (* elements of enum *) +} + +(* Composite type - the form for struct/union definition are the same. *) +type composite_type = + StructDef of struct_def + | UnionDef of struct_def + | EnumDef of enum_def + +(* Function declaration. *) +type func_decl = { + fname : string; (* function name. *) + rtype : atype; (* return type. *) + plist : pdecl list; (* parameter list. *) +} + +(* The untrusted functions might have a string list that specifying + * trusted ECALLs possibly to be made. While the trusted functions + * have a bool tag to identify whether it is private or not (private + * means it can only be accessed by an OCALL). + *) +type trusted_func = { + tf_fdecl : func_decl; + tf_is_priv : bool; +} + +type untrusted_func = { + uf_fdecl : func_decl; + uf_fattr : func_attr; + uf_allow_list : string list; + uf_propagate_errno : bool; +} + +type enclave_func = + | Trusted of trusted_func + | Untrusted of untrusted_func + +(* Module import declaration. *) +type import_decl = { + mname : string; (* from which to import functions. *) + flist : string list; (* a list of functions to be imported. *) +} + +(* All valid expressions. *) +type expr = + | Interface of enclave_func list + | Composite of composite_type + | Importing of import_decl + | Include of string + +(* The definition of an Enclave *) +type enclave = { + ename : string; (* enclave name. *) + eexpr : expr list; (* expressions inside enclave. *) +} + +(* ------------------------------------------------------------------- + * Some utility function to manupulate types defined in AST. + * ------------------------------------------------------------------- + *) + +(* Get the string representation of a type. *) +let rec get_tystr (ty: atype) = + match ty with + | Char sn -> + (match sn with + Signed -> "char" + | Unsigned -> "unsigned char") + | Long sn -> + (match sn with + Signed -> "long" + | Unsigned -> "unsigned long") + | LLong sn -> + (match sn with + Signed -> "long long" + | Unsigned -> "unsigned long long") + | Int ia -> + Printf.sprintf "%s%sint" + (if ia.ia_signedness = Unsigned then "unsigned " else "") + (match ia.ia_shortness with + IShort -> "short " + | ILong -> "long " + | INone -> "") + | Float -> "float" + | Double -> "double" + | LDouble -> "long double" + | Int8 -> "int8_t" + | Int16 -> "int16_t" + | Int32 -> "int32_t" + | Int64 -> "int64_t" + | UInt8 -> "uint8_t" + | UInt16 -> "uint16_t" + | UInt32 -> "uint32_t" + | UInt64 -> "uint64_t" + | Void -> "void" + | SizeT -> "size_t" + | WChar -> "wchar_t" + | Struct id -> "struct " ^ id + | Union id -> "union " ^ id + | Enum id -> "enum " ^ id + | Foreign s -> s + | Ptr ty -> get_tystr(ty) ^ "*" + +(* Get the plain `atype' from a `parameter_type'. *) +let get_param_atype (pt: parameter_type) = + match pt with + | PTVal t -> t + | PTPtr (t, _) -> t + +(* Convert attr_value to string *) +let attr_value_to_string (attr: attr_value) = + match attr with + ANumber n -> Printf.sprintf "%d" n + | AString s -> s diff --git a/sdk/edger8r/linux/CodeGen.ml b/sdk/edger8r/linux/CodeGen.ml new file mode 100644 index 0000000000..f7e2074aad --- /dev/null +++ b/sdk/edger8r/linux/CodeGen.ml @@ -0,0 +1,1552 @@ +(* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *) + +open Printf +open Util (* for failwithf *) + +(* -------------------------------------------------------------------- + * We first introduce a `parse_enclave_ast' function (see below) to + * parse a value of type `Ast.enclave' into a `enclave_content' record. + * -------------------------------------------------------------------- + *) + +(* This record type is used to better organize a value of Ast.enclave *) +type enclave_content = { + file_shortnm : string; (* the short name of original EDL file *) + enclave_name : string; (* the normalized C identifier *) + + include_list : string list; + import_exprs : Ast.import_decl list; + comp_defs : Ast.composite_type list; + tfunc_decls : Ast.trusted_func list; + ufunc_decls : Ast.untrusted_func list; +} + +(* Whether to prefix untrusted proxy with Enclave name *) +let g_use_prefix = ref false +let g_untrusted_dir = ref "." +let g_trusted_dir = ref "." + +let empty_ec = + { file_shortnm = ""; + enclave_name = ""; + include_list = []; + import_exprs = []; + comp_defs = []; + tfunc_decls = []; + ufunc_decls = []; } + +let get_tf_fname (tf: Ast.trusted_func) = + tf.Ast.tf_fdecl.Ast.fname + +let is_priv_ecall (tf: Ast.trusted_func) = + tf.Ast.tf_is_priv + +let get_uf_fname (uf: Ast.untrusted_func) = + uf.Ast.uf_fdecl.Ast.fname + +let get_trusted_func_names (ec: enclave_content) = + List.map get_tf_fname ec.tfunc_decls + +let get_untrusted_func_names (ec: enclave_content) = + List.map get_uf_fname ec.ufunc_decls + +let tf_list_to_fd_list (tfs: Ast.trusted_func list) = + List.map (fun (tf: Ast.trusted_func) -> tf.Ast.tf_fdecl) tfs + +let tf_list_to_priv_list (tfs: Ast.trusted_func list) = + List.map is_priv_ecall tfs + +(* Get a list of names of all private ECALLs *) +let get_priv_ecall_names (tfs: Ast.trusted_func list) = + List.filter is_priv_ecall tfs |> List.map get_tf_fname + +let uf_list_to_fd_list (ufs: Ast.untrusted_func list) = + List.map (fun (uf: Ast.untrusted_func) -> uf.Ast.uf_fdecl) ufs + +(* Get a list of names of all allowed ECALLs from `allow(...)' *) +let get_allowed_names (ufs: Ast.untrusted_func list) = + let allow_lists = + List.map (fun (uf: Ast.untrusted_func) -> uf.Ast.uf_allow_list) ufs + in + List.flatten allow_lists |> dedup_list + +(* With `parse_enclave_ast', each enclave AST is traversed only once. *) +let parse_enclave_ast (e: Ast.enclave) = + let ac_include_list = ref [] in + let ac_import_exprs = ref [] in + let ac_comp_defs = ref [] in + let ac_tfunc_decls = ref [] in + let ac_ufunc_decls = ref [] in + List.iter (fun ex -> + match ex with + Ast.Composite x -> ac_comp_defs := x :: !ac_comp_defs + | Ast.Include x -> ac_include_list := x :: !ac_include_list + | Ast.Importing x -> ac_import_exprs := x :: !ac_import_exprs + | Ast.Interface xs -> + List.iter (fun ef -> + match ef with + Ast.Trusted f -> + ac_tfunc_decls := f :: !ac_tfunc_decls + | Ast.Untrusted f -> + ac_ufunc_decls := f :: !ac_ufunc_decls) xs + ) e.Ast.eexpr; + { file_shortnm = e.Ast.ename; + enclave_name = Util.to_c_identifier e.Ast.ename; + include_list = List.rev !ac_include_list; + import_exprs = List.rev !ac_import_exprs; + comp_defs = List.rev !ac_comp_defs; + tfunc_decls = List.rev !ac_tfunc_decls; + ufunc_decls = List.rev !ac_ufunc_decls; } + +let is_foreign_array (pt: Ast.parameter_type) = + match pt with + Ast.PTVal _ -> false + | Ast.PTPtr(t, a) -> + match t with + Ast.Foreign _ -> a.Ast.pa_isary + | _ -> false + +(* A naked function has neither parameters nor return value. *) +let is_naked_func (fd: Ast.func_decl) = + fd.Ast.rtype = Ast.Void && fd.Ast.plist = [] + +(* + * If user only defined a trusted function w/o neither parameter nor + * return value, the generated trusted bridge will not call any tRTS + * routines. If the real trusted function doesn't call tRTS function + * either (highly possible), then the MSVC linker will not link tRTS + * into the result enclave. + *) +let tbridge_gen_dummy_variable (ec: enclave_content) = + let _dummy_variable = + sprintf "\n#ifdef _MSC_VER\n\ +\t/* In case enclave `%s' doesn't call any tRTS function. */\n\ +\tvolatile int force_link_trts = sgx_is_within_enclave(NULL, 0);\n\ +\t(void) force_link_trts; /* avoid compiler warning */\n\ +#endif\n\n" ec.enclave_name + in + if ec.ufunc_decls <> [] then "" + else + if List.for_all (fun tfd -> is_naked_func tfd.Ast.tf_fdecl) ec.tfunc_decls + then _dummy_variable + else "" + +(* This function is used to convert Array form into Pointer form. + * e.g.: int array[10][20] => [count = 200] int* array + * + * This function is called when generating proxy/bridge code and + * the marshaling structure. + *) +let conv_array_to_ptr (pd: Ast.pdecl): Ast.pdecl = + let (pt, declr) = pd in + let get_count_attr ilist = + (* XXX: assume the size of each dimension will be > 0. *) + Ast.ANumber (List.fold_left (fun acc i -> acc*i) 1 ilist) + in + match pt with + Ast.PTVal _ -> (pt, declr) + | Ast.PTPtr(aty, pa) -> + if Ast.is_array declr then + let tmp_declr = { declr with Ast.array_dims = [] } in + let tmp_aty = Ast.Ptr aty in + let tmp_cnt = get_count_attr declr.Ast.array_dims in + let tmp_pa = { pa with Ast.pa_size = { Ast.empty_ptr_size with Ast.ps_count = Some tmp_cnt } } + in (Ast.PTPtr(tmp_aty, tmp_pa), tmp_declr) + else (pt, declr) + +(* ------------------------------------------------------------------ + * Code generation for edge-routines. + * ------------------------------------------------------------------ + *) + +(* Little functions for naming of a struct and its members etc *) +let retval_name = "retval" +let retval_declr = { Ast.identifier = retval_name; Ast.array_dims = []; } +let eid_name = "eid" +let ms_ptr_name = "pms" +let ms_struct_val = "ms" +let mk_ms_member_name (pname: string) = "ms_" ^ pname +let mk_ms_struct_name (fname: string) = "ms_" ^ fname ^ "_t" +let ms_retval_name = mk_ms_member_name retval_name +let mk_tbridge_name (fname: string) = "sgx_" ^ fname +let mk_parm_accessor name = sprintf "%s->%s" ms_struct_val (mk_ms_member_name name) +let mk_tmp_var name = "_tmp_" ^ name +let mk_len_var name = "_len_" ^ name +let mk_in_var name = "_in_" ^ name +let mk_ocall_table_name enclave_name = "ocall_table_" ^ enclave_name + +(* Un-trusted bridge name is prefixed with enclave file short name. *) +let mk_ubridge_name (file_shortnm: string) (funcname: string) = + sprintf "%s_%s" file_shortnm funcname + +let mk_ubridge_proto (file_shortnm: string) (funcname: string) = + sprintf "static sgx_status_t SGX_CDECL %s(void* %s)" + (mk_ubridge_name file_shortnm funcname) ms_ptr_name + +(* Common macro definitions. *) +let common_macros = "#include /* for size_t */\n\n\ +#define SGX_CAST(type, item) ((type)(item))\n\n\ +#ifdef __cplusplus\n\ +extern \"C\" {\n\ +#endif\n" + +(* Header footer *) +let header_footer = "\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n" + +(* Little functions for generating file names. *) +let get_uheader_short_name (file_shortnm: string) = file_shortnm ^ "_u.h" +let get_uheader_name (file_shortnm: string) = + !g_untrusted_dir ^ separator_str ^ (get_uheader_short_name file_shortnm) + +let get_usource_name (file_shortnm: string) = + !g_untrusted_dir ^ separator_str ^ file_shortnm ^ "_u.c" + +let get_theader_short_name (file_shortnm: string) = file_shortnm ^ "_t.h" +let get_theader_name (file_shortnm: string) = + !g_trusted_dir ^ separator_str ^ (get_theader_short_name file_shortnm) + +let get_tsource_name (file_shortnm: string) = + !g_trusted_dir ^ separator_str ^ file_shortnm ^ "_t.c" + +(* Construct the string of structure definition *) +let mk_struct_decl (fs: string) (name: string) = + sprintf "typedef struct %s {\n%s} %s;\n" name fs name + +(* Construct the string of union definition *) +let mk_union_decl (fs: string) (name: string) = + sprintf "typedef union %s {\n%s} %s;\n" name fs name + +(* Generate a definition of enum *) +let mk_enum_def (e: Ast.enum_def) = + let gen_enum_ele_str (ele: Ast.enum_ele) = + let k, v = ele in + match v with + Ast.EnumValNone -> k + | Ast.EnumVal ev -> sprintf "%s = %s" k (Ast.attr_value_to_string ev) + in + let enname = e.Ast.enname in + let enbody = e.Ast.enbody in + let enbody_str = + if enbody = [] then "" + else List.fold_left (fun acc ele -> + acc ^ "\t" ^ gen_enum_ele_str ele ^ ",\n") "" enbody + in + if enname = "" then sprintf "enum {\n%s};\n" enbody_str + else sprintf "typedef enum %s {\n%s} %s;\n" enname enbody_str enname + +let get_array_dims (ns: int list) = + (* Get the array declaration from a list of array dimensions. + * Empty `ns' indicates the corresponding declarator is a simple identifier. + * Element of value -1 means that user does not specify the dimension size. + *) + let get_dim n = if n = -1 then "[]" else sprintf "[%d]" n + in + if ns = [] then "" + else List.fold_left (fun acc n -> acc ^ get_dim n) "" ns + +let get_typed_declr_str (ty: Ast.atype) (declr: Ast.declarator) = + let tystr = Ast.get_tystr ty in + let dmstr = get_array_dims declr.Ast.array_dims in + sprintf "%s %s%s" tystr declr.Ast.identifier dmstr + +(* Construct a member declaration string *) +let mk_member_decl (ty: Ast.atype) (declr: Ast.declarator) = + sprintf "\t%s;\n" (get_typed_declr_str ty declr) + +(* Note that, for a foreign array type `foo_array_t' we will generate + * foo_array_t* ms_field; + * in the marshaling data structure to keep the pass-by-address scheme + * as in the C programming language. +*) +let mk_ms_member_decl (pt: Ast.parameter_type) (declr: Ast.declarator) = + let aty = Ast.get_param_atype pt in + let tystr = Ast.get_tystr aty in + let ptr = if is_foreign_array pt then "* " else "" in + let field = mk_ms_member_name declr.Ast.identifier in + let dmstr = get_array_dims declr.Ast.array_dims in + sprintf "\t%s%s %s%s;\n" tystr ptr field dmstr + +(* Generate data structure definition *) +let gen_comp_def (st: Ast.composite_type) = + let gen_member_list mlist = + List.fold_left (fun acc (ty, declr) -> + acc ^ mk_member_decl ty declr) "" mlist + in + match st with + Ast.StructDef s -> mk_struct_decl (gen_member_list s.Ast.mlist) s.Ast.sname + | Ast.UnionDef u -> mk_union_decl (gen_member_list u.Ast.mlist) u.Ast.sname + | Ast.EnumDef e -> mk_enum_def e + +(* Generate a list of '#include' *) +let gen_include_list (xs: string list) = + List.fold_left (fun acc s -> acc ^ sprintf "#include \"%s\"\n" s) "" xs + +(* Get the type string from 'parameter_type' *) +let get_param_tystr (pt: Ast.parameter_type) = + Ast.get_tystr (Ast.get_param_atype pt) + +(* Generate marshaling structure definition *) +let gen_marshal_struct (fd: Ast.func_decl) (errno: string) = + let member_list_str = errno ^ + let new_param_list = List.map conv_array_to_ptr fd.Ast.plist in + List.fold_left (fun acc (pt, declr) -> + acc ^ mk_ms_member_decl pt declr) "" new_param_list in + let struct_name = mk_ms_struct_name fd.Ast.fname in + match fd.Ast.rtype with + (* A function w/o return value and parameters doesn't need + a marshaling struct. *) + Ast.Void -> if fd.Ast.plist = [] && errno = "" then "" + else mk_struct_decl member_list_str struct_name + | _ -> let rv_str = mk_ms_member_decl (Ast.PTVal fd.Ast.rtype) retval_declr + in mk_struct_decl (rv_str ^ member_list_str) struct_name + +let gen_ecall_marshal_struct (tf: Ast.trusted_func) = + gen_marshal_struct tf.Ast.tf_fdecl "" + +let gen_ocall_marshal_struct (uf: Ast.untrusted_func) = + let errno_decl = if uf.Ast.uf_propagate_errno then "\tint ocall_errno;\n" else "" in + gen_marshal_struct uf.Ast.uf_fdecl errno_decl + +(* Check whether given parameter is `const' specified. *) +let is_const_ptr (pt: Ast.parameter_type) = + let aty = Ast.get_param_atype pt in + match pt with + Ast.PTVal _ -> false + | Ast.PTPtr(_, pa) -> + if not pa.Ast.pa_rdonly then false + else + match aty with + Ast.Foreign _ -> false + | _ -> true + +(* Generate parameter representation. *) +let gen_parm_str (p: Ast.pdecl) = + let (pt, (declr : Ast.declarator)) = p in + let aty = Ast.get_param_atype pt in + let str = get_typed_declr_str aty declr in + if is_const_ptr pt then "const " ^ str else str + +(* Generate parameter representation of return value. *) +let gen_parm_retval (rt: Ast.atype) = + if rt = Ast.Void then "" + else Ast.get_tystr rt ^ "* " ^ retval_name + +(* ---------------------------------------------------------------------- *) + +(* `gen_ecall_table' is used to generate ECALL table with the following form: + SGX_EXTERNC const struct { + size_t nr_ecall; /* number of ECALLs */ + struct { + void *ecall_addr; + uint8_t is_priv; + } ecall_table [nr_ecall]; + } g_ecall_table = { + 2, { {sgx_foo, 1}, {sgx_bar, 0} } + }; +*) +let gen_ecall_table (tfs: Ast.trusted_func list) = + let ecall_table_name = "g_ecall_table" in + let ecall_table_size = List.length tfs in + let trusted_fds = tf_list_to_fd_list tfs in + let priv_bits = tf_list_to_priv_list tfs in + let tbridge_names = List.map (fun (fd: Ast.func_decl) -> + mk_tbridge_name fd.Ast.fname) trusted_fds in + let ecall_table = + let bool_to_int b = if b then 1 else 0 in + let inner_table = + List.fold_left2 (fun acc s b -> + sprintf "%s\t\t{(void*)(uintptr_t)%s, %d},\n" acc s (bool_to_int b)) "" tbridge_names priv_bits + in "\t{\n" ^ inner_table ^ "\t}\n" + in + sprintf "SGX_EXTERNC const struct {\n\ +\tsize_t nr_ecall;\n\ +\tstruct {void* ecall_addr; uint8_t is_priv;} ecall_table[%d];\n\ +} %s = {\n\ +\t%d,\n\ +%s};\n" ecall_table_size + ecall_table_name + ecall_table_size + (if ecall_table_size = 0 then "" else ecall_table) + +(* `gen_entry_table' is used to generate Dynamic Entry Table with the form: + SGX_EXTERNC const struct { + /* number of OCALLs (number of ECALLs can be found in ECALL table) */ + size_t nr_ocall; + + /* entry_table[m][n] = 1 iff. ECALL n is allowed in the OCALL m. */ + uint8_t entry_table[NR_OCALL][NR_ECALL]; + } g_dyn_entry_table = { + 3, {{0, 0}, {0, 1}, {1, 0}} + }; +*) +let gen_entry_table (ec: enclave_content) = + let dyn_entry_table_name = "g_dyn_entry_table" in + let ocall_table_size = List.length ec.ufunc_decls in + let trusted_func_names = get_trusted_func_names ec in + let ecall_table_size = List.length trusted_func_names in + let get_entry_array (allowed_ecalls: string list) = + List.fold_left (fun acc name -> + acc ^ (if List.exists (fun x -> x=name) allowed_ecalls + then "1" + else "0") ^ ", ") "" trusted_func_names in + let entry_table = + let inner_table = + List.fold_left (fun acc (uf: Ast.untrusted_func) -> + let entry_array = get_entry_array uf.Ast.uf_allow_list + in acc ^ "\t\t{" ^ entry_array ^ "},\n") "" ec.ufunc_decls + in + "\t{\n" ^ inner_table ^ "\t}\n" + in + (* Generate dynamic entry table iff. both sgx_ecall/ocall_table_size > 0 *) + let gen_table_p = (ecall_table_size > 0) && (ocall_table_size > 0) in + (* When NR_ECALL is 0, or NR_OCALL is 0, there will be no entry table field. *) + let entry_table_field = + if gen_table_p then + sprintf "\tuint8_t entry_table[%d][%d];\n" ocall_table_size ecall_table_size + else + "" + in + sprintf "SGX_EXTERNC const struct {\n\ +\tsize_t nr_ocall;\n%s\ +} %s = {\n\ +\t%d,\n\ +%s};\n" entry_table_field + dyn_entry_table_name + ocall_table_size + (if gen_table_p then entry_table else "") + +(* ---------------------------------------------------------------------- *) + +(* Generate the function prototype for untrusted proxy in COM style. + * For example, un-trusted functions + * int foo(double d); + * void bar(float f); + * + * will have an untrusted proxy like below: + * sgx_status_t foo(int* retval, double d); + * sgx_status_t bar(float f); + *) +let gen_tproxy_proto (fd: Ast.func_decl) = + let parm_list = + match fd.Ast.plist with + [] -> "" + | x :: xs -> + List.fold_left (fun acc pd -> + acc ^ ", " ^ gen_parm_str pd) (gen_parm_str x) xs + in + let retval_parm_str = gen_parm_retval fd.Ast.rtype in + if fd.Ast.plist = [] then + sprintf "sgx_status_t SGX_CDECL %s(%s)" fd.Ast.fname retval_parm_str + else if fd.Ast.rtype = Ast.Void then + sprintf "sgx_status_t SGX_CDECL %s(%s)" fd.Ast.fname parm_list + else + sprintf "sgx_status_t SGX_CDECL %s(%s, %s)" fd.Ast.fname retval_parm_str parm_list + +(* Generate the function prototype for untrusted proxy in COM style. + * For example, trusted functions + * int foo(double d); + * void bar(float f); + * + * will have an untrusted proxy like below: + * sgx_status_t foo(sgx_enclave_id_t eid, int* retval, double d); + * sgx_status_t foo(sgx_enclave_id_t eid, float f); + * + * When `g_use_prefix' is true, the untrusted proxy name is prefixed + * with the `prefix' parameter. + * + *) +let gen_uproxy_com_proto (fd: Ast.func_decl) (prefix: string) = + let retval_parm_str = gen_parm_retval fd.Ast.rtype in + + let eid_parm_str = + if fd.Ast.rtype = Ast.Void then sprintf "(sgx_enclave_id_t %s" eid_name + else sprintf "(sgx_enclave_id_t %s, " eid_name in + let parm_list = + List.fold_left (fun acc pd -> acc ^ ", " ^ gen_parm_str pd) + retval_parm_str fd.Ast.plist in + let fname = + if !g_use_prefix then sprintf "%s_%s" prefix fd.Ast.fname + else fd.Ast.fname + in "sgx_status_t " ^ fname ^ eid_parm_str ^ parm_list ^ ")" + +let get_ret_tystr (fd: Ast.func_decl) = Ast.get_tystr fd.Ast.rtype +let get_plist_str (fd: Ast.func_decl) = + if fd.Ast.plist = [] then "" + else List.fold_left (fun acc pd -> acc ^ ", " ^ gen_parm_str pd) + (gen_parm_str (List.hd fd.Ast.plist)) + (List.tl fd.Ast.plist) + +(* Generate the function prototype as is. *) +let gen_func_proto (fd: Ast.func_decl) = + let ret_tystr = get_ret_tystr fd in + let plist_str = get_plist_str fd in + sprintf "%s %s(%s)" ret_tystr fd.Ast.fname plist_str + +(* Generate prototypes for untrusted function. *) +let gen_ufunc_proto (uf: Ast.untrusted_func) = + let dllimport = if uf.Ast.uf_fattr.Ast.fa_dllimport then "SGX_DLLIMPORT " else "" in + let ret_tystr = get_ret_tystr uf.Ast.uf_fdecl in + let cconv_str = "SGX_" ^ Ast.get_call_conv_str uf.Ast.uf_fattr.Ast.fa_convention in + let func_name = uf.Ast.uf_fdecl.Ast.fname in + let plist_str = get_plist_str uf.Ast.uf_fdecl in + sprintf "%s%s SGX_UBRIDGE(%s, %s, (%s))" + dllimport ret_tystr cconv_str func_name plist_str + +(* The preemble contains common include expressions. *) +let gen_uheader_preemble (guard: string) (inclist: string)= + let grd_hdr = sprintf "#ifndef %s\n#define %s\n\n" guard guard in + let inc_exp = "#include \n\ +#include \n\ +#include \n\ +#include \n\ +#include \"sgx_edger8r.h\" /* for sgx_satus_t etc. */\n" in + grd_hdr ^ inc_exp ^ "\n" ^ inclist ^ "\n" ^ common_macros + +let ms_writer out_chan ec = + let ms_struct_ecall = List.map gen_ecall_marshal_struct ec.tfunc_decls in + let ms_struct_ocall = List.map gen_ocall_marshal_struct ec.ufunc_decls in + List.iter (fun s -> output_string out_chan (s ^ "\n")) ms_struct_ecall; + List.iter (fun s -> output_string out_chan (s ^ "\n")) ms_struct_ocall + + +(* Generate untrusted header for enclave *) +let gen_untrusted_header (ec: enclave_content) = + let header_fname = get_uheader_name ec.file_shortnm in + let guard_macro = sprintf "%s_U_H__" (String.uppercase ec.enclave_name) in + let preemble_code = + let include_list = gen_include_list (ec.include_list @ !untrusted_headers) in + gen_uheader_preemble guard_macro include_list + in + let comp_def_list = List.map gen_comp_def ec.comp_defs in + let func_proto_ufunc = List.map gen_ufunc_proto ec.ufunc_decls in + let uproxy_com_proto = + List.map (fun (tf: Ast.trusted_func) -> + gen_uproxy_com_proto tf.Ast.tf_fdecl ec.enclave_name) + ec.tfunc_decls + in + let out_chan = open_out header_fname in + output_string out_chan (preemble_code ^ "\n"); + List.iter (fun s -> output_string out_chan (s ^ "\n")) comp_def_list; + List.iter (fun s -> output_string out_chan (s ^ ";\n")) func_proto_ufunc; + output_string out_chan "\n"; + List.iter (fun s -> output_string out_chan (s ^ ";\n")) uproxy_com_proto; + output_string out_chan header_footer; + close_out out_chan + +(* It generates preemble for trusted header file. *) +let gen_theader_preemble (guard: string) (inclist: string) = + let grd_hdr = sprintf "#ifndef %s\n#define %s\n\n" guard guard in + let inc_exp = "#include \n\ +#include \n\ +#include \n\ +#include \"sgx_edger8r.h\" /* for sgx_ocall etc. */\n\n" in + grd_hdr ^ inc_exp ^ inclist ^ "\n" ^ common_macros + + +(* Generate function prototype for functions used by `sizefunc' attribute. *) +let gen_sizefunc_proto out_chan (ec: enclave_content) = + let tfunc_decls = tf_list_to_fd_list ec.tfunc_decls in + let ufunc_decls = uf_list_to_fd_list ec.ufunc_decls in + + let dict = Hashtbl.create 4 in + let get_sizefunc_proto s = + let (pt, ns) = Hashtbl.find dict s in + let tmpdeclr = { Ast.identifier = "val"; Ast.array_dims = ns; } in + sprintf "size_t %s(const %s);\n" s (get_typed_declr_str pt tmpdeclr) + in + + let add_item (fname: string) (ty: Ast.atype * int list) = + try + let v = Hashtbl.find dict fname + in + if v <> ty then + failwithf "`%s' requires different parameter types" fname + with Not_found -> Hashtbl.add dict fname ty + in + let fill_dict (pd: Ast.pdecl) = + let (pt, declr) = pd in + match pt with + Ast.PTVal _ -> () + | Ast.PTPtr(aty, pattr) -> + match pattr.Ast.pa_size.Ast.ps_sizefunc with + Some s -> add_item s (aty, declr.Ast.array_dims) + | _ -> () + in + List.iter (fun (fd: Ast.func_decl) -> + List.iter fill_dict fd.Ast.plist) (tfunc_decls @ ufunc_decls); + Hashtbl.iter (fun x y -> + output_string out_chan (get_sizefunc_proto x)) dict; + output_string out_chan "\n" + +(* Generate trusted header for enclave *) +let gen_trusted_header (ec: enclave_content) = + let header_fname = get_theader_name ec.file_shortnm in + let guard_macro = sprintf "%s_T_H__" (String.uppercase ec.enclave_name) in + let guard_code = + let include_list = gen_include_list (ec.include_list @ !trusted_headers) in + gen_theader_preemble guard_macro include_list in + let comp_def_list = List.map gen_comp_def ec.comp_defs in + let func_proto_list = List.map gen_func_proto (tf_list_to_fd_list ec.tfunc_decls) in + let func_tproxy_list= List.map gen_tproxy_proto (uf_list_to_fd_list ec.ufunc_decls) in + + let out_chan = open_out header_fname in + output_string out_chan (guard_code ^ "\n"); + List.iter (fun s -> output_string out_chan (s ^ "\n")) comp_def_list; + gen_sizefunc_proto out_chan ec; + List.iter (fun s -> output_string out_chan (s ^ ";\n")) func_proto_list; + output_string out_chan "\n"; + List.iter (fun s -> output_string out_chan (s ^ ";\n")) func_tproxy_list; + output_string out_chan header_footer; + close_out out_chan + +(* It generates function invocation expression. *) +let mk_parm_name_raw (pt: Ast.parameter_type) (declr: Ast.declarator) = + let cast_expr = + if Ast.is_array declr && List.length declr.Ast.array_dims > 1 + then + let tystr = get_param_tystr pt in + let dims = get_array_dims (List.tl declr.Ast.array_dims) in + sprintf "(%s (*)%s)" tystr dims + else "" + in + cast_expr ^ mk_parm_accessor declr.Ast.identifier + +(* We passed foreign array `foo_array_t foo' as `&foo[0]', thus we + * need to get back `foo' by '* array_ptr' where + * array_ptr = &foo[0] +*) +let add_foreign_array_ptrref + (f: Ast.parameter_type -> Ast.declarator -> string) + (pt: Ast.parameter_type) + (declr: Ast.declarator) = + let arg = f pt declr in + if is_foreign_array pt + then sprintf "(%s != NULL) ? (*%s) : NULL" arg arg + else arg + +let mk_parm_name_ubridge (pt: Ast.parameter_type) (declr: Ast.declarator) = + add_foreign_array_ptrref mk_parm_name_raw pt declr + +let mk_parm_name_ext (pt: Ast.parameter_type) (declr: Ast.declarator) = + let name = declr.Ast.identifier in + match pt with + Ast.PTVal _ -> mk_parm_name_raw pt declr + | Ast.PTPtr (_, attr) -> + match attr.Ast.pa_direction with + | Ast.PtrNoDirection -> mk_parm_name_raw pt declr + | _ -> mk_in_var name + +let gen_func_invoking (fd: Ast.func_decl) + (mk_parm_name: Ast.parameter_type -> Ast.declarator -> string) = + let gen_parm_str pt declr = + let parm_name = mk_parm_name pt declr in + let tystr = get_param_tystr pt in + if is_const_ptr pt then sprintf "(const %s)%s" tystr parm_name else parm_name + in + match fd.Ast.plist with + [] -> sprintf "%s();" fd.Ast.fname + | (pt, (declr : Ast.declarator)) :: ps -> + sprintf "%s(%s);" + fd.Ast.fname + (let p0 = gen_parm_str pt declr in + List.fold_left (fun acc (pty, dlr) -> + acc ^ ", " ^ gen_parm_str pty dlr) p0 ps) + +(* Generate untrusted bridge code for a given untrusted function. *) +let gen_func_ubridge (file_shortnm: string) (ufunc: Ast.untrusted_func) = + let fd = ufunc.Ast.uf_fdecl in + let propagate_errno = ufunc.Ast.uf_propagate_errno in + let func_open = sprintf "%s\n{\n" (mk_ubridge_proto file_shortnm fd.Ast.fname) in + let func_close = "\treturn SGX_SUCCESS;\n}\n" in + let set_errno = if propagate_errno then "\tms->ocall_errno = errno;" else "" in + let ms_struct_name = mk_ms_struct_name fd.Ast.fname in + let declare_ms_ptr = sprintf "%s* %s = SGX_CAST(%s*, %s);" + ms_struct_name + ms_struct_val + ms_struct_name + ms_ptr_name in + let call_with_pms = + let invoke_func = gen_func_invoking fd mk_parm_name_ubridge in + if fd.Ast.rtype = Ast.Void then invoke_func + else sprintf "%s = %s" (mk_parm_accessor retval_name) invoke_func + in + if (is_naked_func fd) && (propagate_errno = false) then + let check_pms = + sprintf "if (%s != NULL) return SGX_ERROR_INVALID_PARAMETER;" ms_ptr_name + in + sprintf "%s\t%s\n\t%s\n%s" func_open check_pms call_with_pms func_close + else + sprintf "%s\t%s\n\t%s\n%s\n%s" func_open declare_ms_ptr call_with_pms set_errno func_close + +let fill_ms_field (isptr: bool) (pd: Ast.pdecl) = + let accessor = if isptr then "->" else "." in + let (pt, declr) = pd in + let param_name = declr.Ast.identifier in + let ms_member_name = mk_ms_member_name param_name in + let assignment_str (use_cast: bool) (aty: Ast.atype) = + let cast_str = if use_cast then sprintf "(%s)" (Ast.get_tystr aty) else "" + in + sprintf "%s%s%s = %s%s;" ms_struct_val accessor ms_member_name cast_str param_name + in + let gen_setup_foreign_array aty = + sprintf "%s%s%s = (%s *)&%s[0];" + ms_struct_val accessor ms_member_name (Ast.get_tystr aty) param_name + in + if declr.Ast.array_dims = [] then + match pt with + Ast.PTVal(aty) -> assignment_str false aty + | Ast.PTPtr(aty, pattr) -> + if pattr.Ast.pa_isary + then gen_setup_foreign_array aty + else + if pattr.Ast.pa_rdonly then assignment_str true aty + else assignment_str false aty + else + (* Arrays are passed by address. *) + let tystr = Ast.get_tystr (Ast.Ptr (Ast.get_param_atype pt)) in + sprintf "%s%s%s = (%s)%s;" ms_struct_val accessor ms_member_name tystr param_name + +(* Generate untrusted proxy code for a given trusted function. *) +let gen_func_uproxy (fd: Ast.func_decl) (idx: int) (ec: enclave_content) = + let func_open = + gen_uproxy_com_proto fd ec.enclave_name ^ + "\n{\n\tsgx_status_t status;\n" + in + let func_close = "\treturn status;\n}\n" in + let ocall_table_name = mk_ocall_table_name ec.enclave_name in + let ms_struct_name = mk_ms_struct_name fd.Ast.fname in + let declare_ms_expr = sprintf "%s %s;" ms_struct_name ms_struct_val in + let ocall_table_ptr = + sprintf "&%s" ocall_table_name in + + (* Normal case - do ECALL with marshaling structure*) + let ecall_with_ms = sprintf "status = sgx_ecall(%s, %d, %s, &%s);" + eid_name idx ocall_table_ptr ms_struct_val in + + (* Rare case - the trusted function doesn't have parameter nor return value. + * In this situation, no marshaling structure is required - passing in NULL. + *) + let ecall_null = sprintf "status = sgx_ecall(%s, %d, %s, NULL);" + eid_name idx ocall_table_ptr + in + let update_retval = sprintf "if (status == SGX_SUCCESS && %s) *%s = %s.%s;" + retval_name retval_name ms_struct_val ms_retval_name in + let func_body = ref [] in + if is_naked_func fd then + sprintf "%s\t%s\n%s" func_open ecall_null func_close + else + begin + func_body := declare_ms_expr :: !func_body; + List.iter (fun pd -> func_body := fill_ms_field false pd :: !func_body) fd.Ast.plist; + func_body := ecall_with_ms :: !func_body; + if fd.Ast.rtype <> Ast.Void then func_body := update_retval :: !func_body; + List.fold_left (fun acc s -> acc ^ "\t" ^ s ^ "\n") func_open (List.rev !func_body) ^ func_close + end + +(* Generate an expression to check the pointers. *) +let mk_check_ptr (name: string) (lenvar: string) = + let checker = "CHECK_UNIQUE_POINTER" + in sprintf "\t%s(%s, %s);\n" checker name lenvar + +(* Pointer to marshaling structure should never be NULL. *) +let mk_check_pms (fname: string) = + let lenvar = sprintf "sizeof(%s)" (mk_ms_struct_name fname) + in sprintf "\t%s(%s, %s);\n" "CHECK_REF_POINTER" ms_ptr_name lenvar + +(* Generate code to get the size of the pointer. *) +let gen_ptr_size (ty: Ast.atype) (pattr: Ast.ptr_attr) (name: string) (get_parm: string -> string) = + let len_var = mk_len_var name in + let parm_name = get_parm name in + + let mk_len_size v = + match v with + Ast.AString s -> get_parm s + | Ast.ANumber n -> sprintf "%d" n in + + let mk_len_count v size_str = + match v with + Ast.AString s -> sprintf "%s * %s" (get_parm s) size_str + | Ast.ANumber n -> sprintf "%d * %s" n size_str in + + let mk_len_sizefunc s = sprintf "((%s) ? %s(%s) : 0)" parm_name s parm_name in + + (* Note, during the parsing stage, we already eliminated the case that + * user specified both 'size' and 'sizefunc' attribute. + *) + let do_attribute (pattr: Ast.ptr_attr) = + let do_ps_attribute (sattr: Ast.ptr_size) = + let size_str = + match sattr.Ast.ps_size with + Some a -> mk_len_size a + | None -> + match sattr.Ast.ps_sizefunc with + None -> sprintf "sizeof(*%s)" parm_name + | Some a -> mk_len_sizefunc a + in + match sattr.Ast.ps_count with + None -> size_str + | Some a -> mk_len_count a size_str + in + if pattr.Ast.pa_isstr then + sprintf "%s ? strlen(%s) + 1 : 0" parm_name parm_name + else if pattr.Ast.pa_iswstr then + sprintf "%s ? (wcslen(%s) + 1) * sizeof(wchar_t) : 0" parm_name parm_name + else + do_ps_attribute pattr.Ast.pa_size + in + sprintf "size_t %s = %s;\n" + len_var + (if pattr.Ast.pa_isary + then sprintf "sizeof(%s)" (Ast.get_tystr ty) + else do_attribute pattr) + +(* Find the data type of a parameter. *) +let find_param_type (name: string) (plist: Ast.pdecl list) = + try + let (pt, _) = List.find (fun (pd: Ast.pdecl) -> + let (pt, declr) = pd + in declr.Ast.identifier = name) plist + in get_param_tystr pt + with + Not_found -> failwithf "parameter `%s' not found." name + +(* Generate code to check the length of buffers. *) +let gen_check_tbridge_length_overflow (plist: Ast.pdecl list) = + let gen_check_length (ty: Ast.atype) (attr: Ast.ptr_attr) (declr: Ast.declarator) = + let name = declr.Ast.identifier in + let tmp_ptr_name= mk_tmp_var name in + + let mk_len_size v = + match v with + Ast.AString s -> mk_tmp_var s + | Ast.ANumber n -> sprintf "%d" n in + + let mk_len_sizefunc s = sprintf "((%s) ? %s(%s) : 0)" tmp_ptr_name s tmp_ptr_name in + + let gen_check_overflow cnt size_str = + let if_statement = + match cnt with + Ast.AString s -> sprintf "\tif ((size_t)%s > (SIZE_MAX / %s)) {\n" (mk_tmp_var s) size_str + | Ast.ANumber n -> sprintf "\tif (%d > (SIZE_MAX / %s)) {\n" n size_str + in + sprintf "%s\t\tstatus = SGX_ERROR_INVALID_PARAMETER;\n\t\tgoto err;\n\t}" if_statement + in + let size_str = + match attr.Ast.pa_size.Ast.ps_size with + Some a -> mk_len_size a + | None -> + match attr.Ast.pa_size.Ast.ps_sizefunc with + None -> sprintf "sizeof(*%s)" tmp_ptr_name + | Some a -> mk_len_sizefunc a + in + match attr.Ast.pa_size.Ast.ps_count with + None -> "" + | Some a -> sprintf "%s\n\n" (gen_check_overflow a size_str) + in + List.fold_left + (fun acc (pty, declr) -> + match pty with + Ast.PTVal _ -> acc + | Ast.PTPtr(ty, attr) -> acc ^ gen_check_length ty attr declr) "" plist + +(* Generate code to check all function parameters which are pointers. *) +let gen_check_tbridge_ptr_parms (plist: Ast.pdecl list) = + let gen_check_ptr (ty: Ast.atype) (pattr: Ast.ptr_attr) (declr: Ast.declarator) = + if not pattr.Ast.pa_chkptr then "" + else + let name = declr.Ast.identifier in + let len_var = mk_len_var name in + let parm_name = mk_tmp_var name in + if pattr.Ast.pa_chkptr + then mk_check_ptr parm_name len_var + else "" + in + let new_param_list = List.map conv_array_to_ptr plist + in + List.fold_left + (fun acc (pty, declr) -> + match pty with + Ast.PTVal _ -> acc + | Ast.PTPtr(ty, attr) -> acc ^ gen_check_ptr ty attr declr) "" new_param_list + +(* If a foreign type is a readonly pointer, we cast it to 'void*' for memcpy() and free() *) +let mk_in_ptr_dst_name (rdonly: bool) (ptr_name: string) = + if rdonly then "(void*)" ^ ptr_name + else ptr_name + +(* Generate the code to handle function pointer parameter direction, + * which is to be inserted before actually calling the trusted function. + *) +let gen_parm_ptr_direction_pre (plist: Ast.pdecl list) = + let clone_in_ptr (ty: Ast.atype) (attr: Ast.ptr_attr) (declr: Ast.declarator) = + let name = declr.Ast.identifier in + let is_ary = (Ast.is_array declr || attr.Ast.pa_isary) in + let in_ptr_name = mk_in_var name in + let in_ptr_type = sprintf "%s%s" (Ast.get_tystr ty) (if is_ary then "*" else "") in + let len_var = mk_len_var name in + let in_ptr_dst_name = mk_in_ptr_dst_name attr.Ast.pa_rdonly in_ptr_name in + let tmp_ptr_name= mk_tmp_var name in + + let check_sizefunc_ptr (fn: string) = + sprintf "\t\t/* check whether the pointer is modified. */\n\ +\t\tif (%s(%s) != %s) {\n\ +\t\t\tstatus = SGX_ERROR_INVALID_PARAMETER;\n\ +\t\t\tgoto err;\n\ +\t\t}" fn in_ptr_name len_var + in + let malloc_and_copy pre_indent = + match attr.Ast.pa_direction with + Ast.PtrIn | Ast.PtrInOut -> + let code_template = [ + sprintf "if (%s != NULL) {" tmp_ptr_name; + sprintf "\t%s = (%s)malloc(%s);" in_ptr_name in_ptr_type len_var; + sprintf "\tif (%s == NULL) {" in_ptr_name; + "\t\tstatus = SGX_ERROR_OUT_OF_MEMORY;"; + "\t\tgoto err;"; + "\t}\n"; + sprintf "\tmemcpy(%s, %s, %s);" in_ptr_dst_name tmp_ptr_name len_var; + ] + in + let s1 = List.fold_left (fun acc s -> acc ^ pre_indent ^ s ^ "\n") "" code_template in + let s2 = + if attr.Ast.pa_isstr + then sprintf "%s\t\t%s[%s - 1] = '\\0';\n" s1 in_ptr_name len_var + else if attr.Ast.pa_iswstr + then sprintf "%s\t\t%s[(%s - sizeof(wchar_t))/sizeof(wchar_t)] = (wchar_t)0;\n" s1 in_ptr_name len_var + else s1 in + let s3 = + match attr.Ast.pa_size.Ast.ps_sizefunc with + None -> s2 + | Some s -> sprintf "%s\n%s\n" s2 (check_sizefunc_ptr(s)) + in sprintf "%s\t}\n" s3 + | Ast.PtrOut -> + let code_template = [ + sprintf "if (%s != NULL) {" tmp_ptr_name; + sprintf "\tif ((%s = (%s)malloc(%s)) == NULL) {" in_ptr_name in_ptr_type len_var; + "\t\tstatus = SGX_ERROR_OUT_OF_MEMORY;"; + "\t\tgoto err;"; + "\t}\n"; + sprintf "\tmemset((void*)%s, 0, %s);" in_ptr_name len_var; + "}"] + in + List.fold_left (fun acc s -> acc ^ pre_indent ^ s ^ "\n") "" code_template + | _ -> "" + in + malloc_and_copy "\t" + in List.fold_left + (fun acc (pty, declr) -> + match pty with + Ast.PTVal _ -> acc + | Ast.PTPtr (ty, attr) -> acc ^ clone_in_ptr ty attr declr) "" plist + +(* Generate the code to handle function pointer parameter direction, + * which is to be inserted after finishing calling the trusted function. + *) +let gen_parm_ptr_direction_post (plist: Ast.pdecl list) = + let copy_and_free (attr: Ast.ptr_attr) (declr: Ast.declarator) = + let name = declr.Ast.identifier in + let in_ptr_name = mk_in_var name in + let len_var = mk_len_var name in + let in_ptr_dst_name = mk_in_ptr_dst_name attr.Ast.pa_rdonly in_ptr_name in + match attr.Ast.pa_direction with + Ast.PtrIn -> sprintf "\tif (%s) free(%s);\n" in_ptr_name in_ptr_dst_name + | Ast.PtrInOut | Ast.PtrOut -> + sprintf "\tif (%s) {\n\t\tmemcpy(%s, %s, %s);\n\t\tfree(%s);\n\t}\n" + in_ptr_name + (mk_tmp_var name) + in_ptr_name + len_var + in_ptr_name + | _ -> "" + in List.fold_left + (fun acc (pty, declr) -> + match pty with + Ast.PTVal _ -> acc + | Ast.PTPtr (ty, attr) -> acc ^ copy_and_free attr declr) "" plist + + +(* Generate an "err:" goto mark if necessary. *) +let gen_err_mark (plist: Ast.pdecl list) = + let has_inout_p (attr: Ast.ptr_attr): bool = + attr.Ast.pa_direction <> Ast.PtrNoDirection + in + if List.exists (fun (pt, name) -> + match pt with + Ast.PTVal _ -> false + | Ast.PTPtr(_, attr) -> has_inout_p attr) plist + then "err:" + else "" + +(* It is used to save the parameters used as the value of size/count attribute. *) +let param_cache = Hashtbl.create 1 +let is_in_param_cache s = Hashtbl.mem param_cache s + +(* Try to generate a temporary value to save the size of the buffer. *) +let gen_tmp_size (pattr: Ast.ptr_attr) (plist: Ast.pdecl list) = + let do_gen_temp_var (s: string) = + if is_in_param_cache s then "" + else + let param_tystr = find_param_type s plist in + let tmp_var = mk_tmp_var s in + let parm_str = mk_parm_accessor s in + Hashtbl.add param_cache s true; + sprintf "\t%s %s = %s;\n" param_tystr tmp_var parm_str + in + let gen_temp_var (v: Ast.attr_value) = + match v with + Ast.ANumber _ -> "" + | Ast.AString s -> do_gen_temp_var s + in + let tmp_size_str = + match pattr.Ast.pa_size.Ast.ps_size with + Some v -> gen_temp_var v + | None -> "" + in + let tmp_count_str = + match pattr.Ast.pa_size.Ast.ps_count with + Some v -> gen_temp_var v + | None -> "" + in + sprintf "%s%s" tmp_size_str tmp_count_str + +let is_ptr (pt: Ast.parameter_type) = + match pt with + Ast.PTVal _ -> false + | Ast.PTPtr _ -> true + +let is_ptr_type (aty: Ast.atype) = + match aty with + Ast.Ptr _ -> true + | _ -> false + +let ptr_has_direction (pt: Ast.parameter_type) = + match pt with + Ast.PTVal _ -> false + | Ast.PTPtr(_, a) -> a.Ast.pa_direction <> Ast.PtrNoDirection + +let tbridge_mk_parm_name_ext (pt: Ast.parameter_type) (declr: Ast.declarator) = + if is_in_param_cache declr.Ast.identifier || (is_ptr pt && (not (is_foreign_array pt))) + then + if ptr_has_direction pt + then mk_in_var declr.Ast.identifier + else mk_tmp_var declr.Ast.identifier + else mk_parm_name_ext pt declr + +let mk_parm_name_tbridge (pt: Ast.parameter_type) (declr: Ast.declarator) = + add_foreign_array_ptrref tbridge_mk_parm_name_ext pt declr + +(* Generate local variables required for the trusted bridge. *) +let gen_tbridge_local_vars (plist: Ast.pdecl list) = + let status_var = "\tsgx_status_t status = SGX_SUCCESS;\n" in + let do_gen_local_var (ty: Ast.atype) (attr: Ast.ptr_attr) (name: string) = + let tmp_var = + (* Save a copy of pointer in case it might be modified in the marshaling structure. *) + sprintf "\t%s %s = %s;\n" (Ast.get_tystr ty) (mk_tmp_var name) (mk_parm_accessor name) + in + let len_var = + if not attr.Ast.pa_chkptr then "" + else gen_tmp_size attr plist ^ "\t" ^ gen_ptr_size ty attr name mk_tmp_var in + let in_ptr = + match attr.Ast.pa_direction with + Ast.PtrNoDirection -> "" + | _ -> sprintf "\t%s %s = NULL;\n" (Ast.get_tystr ty) (mk_in_var name) + in + tmp_var ^ len_var ^ in_ptr + in + let gen_local_var_for_foreign_array (ty: Ast.atype) (attr: Ast.ptr_attr) (name: string) = + let tystr = Ast.get_tystr ty in + let tmp_var = + sprintf "\t%s* %s = %s;\n" tystr (mk_tmp_var name) (mk_parm_accessor name) + in + let len_var = sprintf "\tsize_t %s = sizeof(%s);\n" (mk_len_var name) tystr + in + let in_ptr = sprintf "\t%s* %s = NULL;\n" tystr (mk_in_var name) + in + match attr.Ast.pa_direction with + Ast.PtrNoDirection -> "" + | _ -> tmp_var ^ len_var ^ in_ptr + in + let gen_local_var (pd: Ast.pdecl) = + let (pty, declr) = pd in + match pty with + Ast.PTVal _ -> "" + | Ast.PTPtr (ty, attr) -> + if is_foreign_array pty + then gen_local_var_for_foreign_array ty attr declr.Ast.identifier + else do_gen_local_var ty attr declr.Ast.identifier + in + let new_param_list = List.map conv_array_to_ptr plist + in + Hashtbl.clear param_cache; + List.fold_left (fun acc pd -> acc ^ gen_local_var pd) status_var new_param_list + +(* It generates trusted bridge code for a trusted function. *) +let gen_func_tbridge (fd: Ast.func_decl) (dummy_var: string) = + let func_open = sprintf "static sgx_status_t SGX_CDECL %s(void* %s)\n{\n" + (mk_tbridge_name fd.Ast.fname) + ms_ptr_name in + let local_vars = gen_tbridge_local_vars fd.Ast.plist in + let func_close = "\treturn status;\n}\n" in + + let ms_struct_name = mk_ms_struct_name fd.Ast.fname in + let declare_ms_ptr = sprintf "%s* %s = SGX_CAST(%s*, %s);" + ms_struct_name + ms_struct_val + ms_struct_name + ms_ptr_name in + + let invoke_func = gen_func_invoking fd mk_parm_name_tbridge in + let update_retval = sprintf "%s = %s" + (mk_parm_accessor retval_name) + invoke_func in + + if is_naked_func fd then + let check_pms = + sprintf "if (%s != NULL) return SGX_ERROR_INVALID_PARAMETER;" ms_ptr_name + in + sprintf "%s%s%s\t%s\n\t%s\n%s" func_open local_vars dummy_var check_pms invoke_func func_close + else + sprintf "%s\t%s\n%s\n%s%s%s\n%s\t%s\n%s\n%s\n%s" + func_open + declare_ms_ptr + local_vars + (gen_check_tbridge_length_overflow fd.Ast.plist) + (mk_check_pms fd.Ast.fname) + (gen_check_tbridge_ptr_parms fd.Ast.plist) + (gen_parm_ptr_direction_pre fd.Ast.plist) + (if fd.Ast.rtype <> Ast.Void then update_retval else invoke_func) + (gen_err_mark fd.Ast.plist) + (gen_parm_ptr_direction_post fd.Ast.plist) + func_close + +let tproxy_fill_ms_field (pd: Ast.pdecl) = + let (pt, declr) = pd in + let name = declr.Ast.identifier in + let len_var = mk_len_var name in + let parm_accessor = mk_parm_accessor name in + match pt with + Ast.PTVal _ -> fill_ms_field true pd + | Ast.PTPtr(ty, attr) -> + let is_ary = (Ast.is_array declr || attr.Ast.pa_isary) in + let tystr = sprintf "%s%s" (get_param_tystr pt) (if is_ary then "*" else "") in + if is_ary && is_ptr_type ty then + sprintf "\n#pragma message(\"Pointer array `%s' in trusted proxy `\"\ + __FUNCTION__ \"' is dangerous. No code generated.\")\n" name + else + let in_ptr_dst_name = mk_in_ptr_dst_name attr.Ast.pa_rdonly parm_accessor in + if not attr.Ast.pa_chkptr (* [user_check] specified *) + then sprintf "%s = SGX_CAST(%s, %s);" parm_accessor tystr name + else + match attr.Ast.pa_direction with + Ast.PtrOut -> + let code_template = + [sprintf "if (%s != NULL && sgx_is_within_enclave(%s, %s)) {" name name len_var; + sprintf "\t%s = (%s)__tmp;" parm_accessor tystr; + sprintf "\t__tmp = (void *)((size_t)__tmp + %s);" len_var; + sprintf "\tmemset(%s, 0, %s);" in_ptr_dst_name len_var; + sprintf "} else if (%s == NULL) {" name; + sprintf "\t%s = NULL;" parm_accessor; + "} else {"; + "\tsgx_ocfree();"; + "\treturn SGX_ERROR_INVALID_PARAMETER;"; + "}" + ] + in List.fold_left (fun acc s -> acc ^ s ^ "\n\t") "" code_template + | _ -> + let code_template = + [sprintf "if (%s != NULL && sgx_is_within_enclave(%s, %s)) {" name name len_var; + sprintf "\t%s = (%s)__tmp;" parm_accessor tystr; + sprintf "\t__tmp = (void *)((size_t)__tmp + %s);" len_var; + sprintf "\tmemcpy(%s, %s, %s);" in_ptr_dst_name name len_var; + sprintf "} else if (%s == NULL) {" name; + sprintf "\t%s = NULL;" parm_accessor; + "} else {"; + "\tsgx_ocfree();"; + "\treturn SGX_ERROR_INVALID_PARAMETER;"; + "}" + ] + in List.fold_left (fun acc s -> acc ^ s ^ "\n\t") "" code_template + +(* Generate local variables required for the trusted proxy. *) +let gen_tproxy_local_vars (plist: Ast.pdecl list) = + let status_var = "sgx_status_t status = SGX_SUCCESS;\n" in + let do_gen_local_var (ty: Ast.atype) (attr: Ast.ptr_attr) (name: string) = + if not attr.Ast.pa_chkptr then "" + else "\t" ^ gen_ptr_size ty attr name (fun x -> x) + in + let gen_local_var (pd: Ast.pdecl) = + let (pty, declr) = pd in + match pty with + Ast.PTVal _ -> "" + | Ast.PTPtr (ty, attr) -> do_gen_local_var ty attr declr.Ast.identifier + in + let new_param_list = List.map conv_array_to_ptr plist + in + List.fold_left (fun acc pd -> acc ^ gen_local_var pd) status_var new_param_list + +(* Generate only one ocalloc block required for the trusted proxy. *) +let gen_ocalloc_block (fname: string) (plist: Ast.pdecl list) = + let ms_struct_name = mk_ms_struct_name fname in + let local_vars_block = sprintf "%s* %s = NULL;\n\tsize_t ocalloc_size = sizeof(%s);\n\tvoid *__tmp = NULL;\n\n" ms_struct_name ms_struct_val ms_struct_name in + let count_ocalloc_size (ty: Ast.atype) (attr: Ast.ptr_attr) (name: string) = + if not attr.Ast.pa_chkptr then "" + else sprintf "\tocalloc_size += (%s != NULL && sgx_is_within_enclave(%s, %s)) ? %s : 0;\n" name name (mk_len_var name) (mk_len_var name) + in + let do_count_ocalloc_size (pd: Ast.pdecl) = + let (pty, declr) = pd in + match pty with + Ast.PTVal _ -> "" + | Ast.PTPtr (ty, attr) -> count_ocalloc_size ty attr declr.Ast.identifier + in + let do_gen_ocalloc_block = [ + "\n\t__tmp = sgx_ocalloc(ocalloc_size);\n"; + "\tif (__tmp == NULL) {\n"; + "\t\tsgx_ocfree();\n"; + "\t\treturn SGX_ERROR_UNEXPECTED;\n"; + "\t}\n"; + sprintf "\t%s = (%s*)__tmp;\n" ms_struct_val ms_struct_name; + sprintf "\t__tmp = (void *)((size_t)__tmp + sizeof(%s));\n" ms_struct_name; + ] + in + let new_param_list = List.map conv_array_to_ptr plist + in + let s1 = List.fold_left (fun acc pd -> acc ^ do_count_ocalloc_size pd) local_vars_block new_param_list in + List.fold_left (fun acc s -> acc ^ s) s1 do_gen_ocalloc_block + +(* Generate trusted proxy code for a given untrusted function. *) +let gen_func_tproxy (ufunc: Ast.untrusted_func) (idx: int) = + let fd = ufunc.Ast.uf_fdecl in + let propagate_errno = ufunc.Ast.uf_propagate_errno in + let func_open = sprintf "%s\n{\n" (gen_tproxy_proto fd) in + let local_vars = gen_tproxy_local_vars fd.Ast.plist in + let ocalloc_ms_struct = gen_ocalloc_block fd.Ast.fname fd.Ast.plist in + let gen_ocfree rtype plist = + if rtype = Ast.Void && plist = [] then "" else "\tsgx_ocfree();\n" + in + let handle_out_ptr plist = + let copy_memory (attr: Ast.ptr_attr) (declr: Ast.declarator) = + let name = declr.Ast.identifier in + match attr.Ast.pa_direction with + Ast.PtrInOut | Ast.PtrOut -> + sprintf "\tif (%s) memcpy((void*)%s, %s, %s);\n" name name (mk_parm_accessor name) (mk_len_var name) + | _ -> "" + in List.fold_left (fun acc (pty, declr) -> + match pty with + Ast.PTVal _ -> acc + | Ast.PTPtr(ty, attr) -> acc ^ copy_memory attr declr) "" plist in + + let set_errno = if propagate_errno then "\terrno = ms->ocall_errno;" else "" in + let func_close = sprintf "%s%s\n%s%s\n" + (handle_out_ptr fd.Ast.plist) + set_errno + (gen_ocfree fd.Ast.rtype fd.Ast.plist) + "\treturn status;\n}" in + let ocall_null = sprintf "status = sgx_ocall(%d, NULL);\n" idx in + let ocall_with_ms = sprintf "status = sgx_ocall(%d, %s);\n" + idx ms_struct_val in + let update_retval = sprintf "if (%s) *%s = %s;" + retval_name retval_name (mk_parm_accessor retval_name) in + let func_body = ref [] in + if (is_naked_func fd) && (propagate_errno = false) then + sprintf "%s\t%s\t%s%s" func_open local_vars ocall_null func_close + else + begin + func_body := local_vars :: !func_body; + func_body := ocalloc_ms_struct:: !func_body; + List.iter (fun pd -> func_body := tproxy_fill_ms_field pd :: !func_body) fd.Ast.plist; + func_body := ocall_with_ms :: !func_body; + if fd.Ast.rtype <> Ast.Void then func_body := update_retval :: !func_body; + List.fold_left (fun acc s -> acc ^ "\t" ^ s ^ "\n") func_open (List.rev !func_body) ^ func_close + end + +(* It generates OCALL table and the untrusted proxy to setup OCALL table. *) +let gen_ocall_table (ec: enclave_content) = + let func_proto_ubridge = List.map (fun (uf: Ast.untrusted_func) -> + let fd : Ast.func_decl = uf.Ast.uf_fdecl in + mk_ubridge_name ec.file_shortnm fd.Ast.fname) + ec.ufunc_decls in + let nr_ocall = List.length ec.ufunc_decls in + let ocall_table_name = mk_ocall_table_name ec.enclave_name in + let ocall_table = + let ocall_members = + List.fold_left + (fun acc proto -> acc ^ "\t\t(void*)" ^ proto ^ ",\n") "" func_proto_ubridge + in "\t{\n" ^ ocall_members ^ "\t}\n" + in + sprintf "static const struct {\n\ +\tsize_t nr_ocall;\n\ +\tvoid * table[%d];\n\ +} %s = {\n\ +\t%d,\n\ +%s};\n" (max nr_ocall 1) + ocall_table_name + nr_ocall + (if nr_ocall <> 0 then ocall_table else "\t{ NULL },\n") + +(* It generates untrusted code to be saved in a `.c' file. *) +let gen_untrusted_source (ec: enclave_content) = + let code_fname = get_usource_name ec.file_shortnm in + let include_hd = "#include \"" ^ get_uheader_short_name ec.file_shortnm ^ "\"\n" in + let include_errno = "#include \n" in + let uproxy_list = + List.map2 (fun fd ecall_idx -> gen_func_uproxy fd ecall_idx ec) + (tf_list_to_fd_list ec.tfunc_decls) + (Util.mk_seq 0 (List.length ec.tfunc_decls - 1)) + in + let ubridge_list = + List.map (fun fd -> gen_func_ubridge ec.file_shortnm fd) + (ec.ufunc_decls) in + let out_chan = open_out code_fname in + output_string out_chan (include_hd ^ include_errno ^ "\n"); + ms_writer out_chan ec; + List.iter (fun s -> output_string out_chan (s ^ "\n")) ubridge_list; + output_string out_chan (gen_ocall_table ec); + List.iter (fun s -> output_string out_chan (s ^ "\n")) uproxy_list; + close_out out_chan + +(* It generates trusted code to be saved in a `.c' file. *) +let gen_trusted_source (ec: enclave_content) = + let code_fname = get_tsource_name ec.file_shortnm in + let include_hd = "#include \"" ^ get_theader_short_name ec.file_shortnm ^ "\"\n\n\ +#include \"sgx_trts.h\" /* for sgx_ocalloc, sgx_is_outside_enclave */\n\n\ +#include \n\ +#include /* for memcpy etc */\n\ +#include /* for malloc/free etc */\n\ +\n\ +#define CHECK_REF_POINTER(ptr, siz) do {\t\\\n\ +\tif (!(ptr) || ! sgx_is_outside_enclave((ptr), (siz)))\t\\\n\ +\t\treturn SGX_ERROR_INVALID_PARAMETER;\\\n\ +} while (0)\n\ +\n\ +#define CHECK_UNIQUE_POINTER(ptr, siz) do {\t\\\n\ +\tif ((ptr) && ! sgx_is_outside_enclave((ptr), (siz)))\t\\\n\ +\t\treturn SGX_ERROR_INVALID_PARAMETER;\\\n\ +} while (0)\n\ +\n" in + let trusted_fds = tf_list_to_fd_list ec.tfunc_decls in + let tbridge_list = + let dummy_var = tbridge_gen_dummy_variable ec in + List.map (fun tfd -> gen_func_tbridge tfd dummy_var) trusted_fds in + let ecall_table = gen_ecall_table ec.tfunc_decls in + let entry_table = gen_entry_table ec in + let tproxy_list = List.map2 + (fun fd idx -> gen_func_tproxy fd idx) + (ec.ufunc_decls) + (Util.mk_seq 0 (List.length ec.ufunc_decls - 1)) in + let out_chan = open_out code_fname in + output_string out_chan (include_hd ^ "\n"); + ms_writer out_chan ec; + List.iter (fun s -> output_string out_chan (s ^ "\n")) tbridge_list; + output_string out_chan (ecall_table ^ "\n"); + output_string out_chan (entry_table ^ "\n"); + output_string out_chan "\n"; + List.iter (fun s -> output_string out_chan (s ^ "\n")) tproxy_list; + close_out out_chan + +(* We use a stack to keep record of imported files. + * + * A file will be pushed to the stack before we parsing it, + * and we will pop the stack after each `parse_import_file'. + *) +let already_read = SimpleStack.create () +let save_file fullpath = + if SimpleStack.mem fullpath already_read + then failwithf "detected circled import for `%s'" fullpath + else SimpleStack.push fullpath already_read + +(* The entry point of the Edger8r parser front-end. + * ------------------------------------------------ + *) +let start_parsing (fname: string) : Ast.enclave = + let set_initial_pos lexbuf filename = + lexbuf.Lexing.lex_curr_p <- { + lexbuf.Lexing.lex_curr_p with Lexing.pos_fname = fname; + } + in + try + let chan = + let fullpath = Util.get_file_path fname + in save_file fullpath; open_in fullpath in + let lexbuf = Lexing.from_channel chan in + try + set_initial_pos lexbuf fname; + let e : Ast.enclave = Parser.start_parsing Lexer.tokenize lexbuf in + let short_name = Util.get_short_name fname in + if short_name = "" + then (eprintf "error: %s: file short name is empty\n" fname; exit 1;) + else + let res = { e with Ast.ename = short_name } in + if Util.is_c_identifier short_name then res + else (eprintf "warning: %s: file short name `%s' is not a valid C identifier\n" fname short_name; res) + with exn -> close_in chan; + begin match exn with + | Parsing.Parse_error -> + let curr = lexbuf.Lexing.lex_curr_p in + let line = curr.Lexing.pos_lnum in + let cnum = curr.Lexing.pos_cnum - curr.Lexing.pos_bol in + let tok = Lexing.lexeme lexbuf in + failwithf "%s:%d:%d: unexpected token: %s\n" fname line cnum tok + | _ -> raise exn + end + with Sys_error s -> failwithf "%s\n" s + +(* Check duplicated ECALL/OCALL names. + * + * This is a pretty simple implementation - to improve it, the + * location information of each token should be carried to AST. + *) +let check_duplication (ec: enclave_content) = + let dict = Hashtbl.create 10 in + let trusted_fds = tf_list_to_fd_list ec.tfunc_decls in + let untrusted_fds = uf_list_to_fd_list ec.ufunc_decls in + let check_and_add fname = + if Hashtbl.mem dict fname then + failwithf "Multiple definition of function \"%s\" detected." fname + else + Hashtbl.add dict fname true + in + List.iter (fun (fd: Ast.func_decl) -> + check_and_add fd.Ast.fname) (trusted_fds @ untrusted_fds) + +(* For each untrusted functions, check that allowed ECALL does exist. *) +let check_allow_list (ec: enclave_content) = + let trusted_func_names = get_trusted_func_names ec in + let do_check_allow_list fname allowed_ecalls = + List.iter (fun trusted_func -> + if List.exists (fun x -> x = trusted_func) trusted_func_names + then () + else + failwithf "\"%s\" declared to allow unknown function \"%s\"." + fname trusted_func) allowed_ecalls + in + List.iter (fun (uf: Ast.untrusted_func) -> + let fd = uf.Ast.uf_fdecl in + let allowed_ecalls = uf.Ast.uf_allow_list in + do_check_allow_list fd.Ast.fname allowed_ecalls) ec.ufunc_decls + +(* Report private ECALL not used in any "allow(...)" expression. *) +let report_orphaned_priv_ecall (ec: enclave_content) = + let priv_ecall_names = get_priv_ecall_names ec.tfunc_decls in + let allowed_names = get_allowed_names ec.ufunc_decls in + let check_ecall n = if List.mem n allowed_names then () + else eprintf "warning: private ECALL `%s' is not used by any OCALL\n" n + in + List.iter check_ecall priv_ecall_names + +(* Check that there is at least one public ECALL function. *) +let check_priv_funcs (ec: enclave_content) = + let priv_bits = tf_list_to_priv_list ec.tfunc_decls in + if List.for_all (fun is_priv -> is_priv) priv_bits + then failwithf "the enclave `%s' contains no public root ECALL.\n" ec.file_shortnm + else report_orphaned_priv_ecall ec + +(* When generating edge-routines, it need first to check whether there + * are `import' expressions inside EDL. If so, it will parse the given + * importing file to get an `enclave_content' record, recursively. + * + * `ec' is the toplevel `enclave_content' record. + + * Here, a tree reduce algorithm is used. `ec' is the root-node, each + * `import' expression is considerred as a children. + *) +let reduce_import (ec: enclave_content) = + let combine (ec1: enclave_content) (ec2: enclave_content) = + { ec1 with + include_list = ec1.include_list @ ec2.include_list; + import_exprs = []; + comp_defs = ec1.comp_defs @ ec2.comp_defs; + tfunc_decls = ec1.tfunc_decls @ ec2.tfunc_decls; + ufunc_decls = ec1.ufunc_decls @ ec2.ufunc_decls; } + in + let parse_import_file fname = + let ec = parse_enclave_ast (start_parsing fname) + in + match ec.import_exprs with + [] -> (SimpleStack.pop already_read |> ignore; ec ) + | _ -> ec + in + let check_funs funcs (ec: enclave_content) = + (* Check whether `funcs' are listed in `ec'. It returns a + production (x, y), where: + x - functions not listed in `ec'; + y - a new `ec' that contains functions from `funcs' listed in `ec'. + *) + let enclave_funcs = + let trusted_func_names = get_trusted_func_names ec in + let untrusted_func_names = get_untrusted_func_names ec in + trusted_func_names @ untrusted_func_names + in + let in_ec_def name = List.exists (fun x -> x = name) enclave_funcs in + let in_import_list name = List.exists (fun x -> x = name) funcs in + let x = List.filter (fun name -> not (in_ec_def name)) funcs in + let y = + { empty_ec with + tfunc_decls = List.filter (fun tf -> + in_import_list (get_tf_fname tf)) ec.tfunc_decls; + ufunc_decls = List.filter (fun uf -> + in_import_list (get_uf_fname uf)) ec.ufunc_decls; } + in (x, y) + in + (* Import functions listed in `funcs' from `importee'. *) + let rec import_funcs (funcs: string list) (importee: enclave_content) = + (* A `*' means importing all the functions. *) + if List.exists (fun x -> x = "*") funcs + then + List.fold_left (fun acc (ipd: Ast.import_decl) -> + let next_ec = parse_import_file ipd.Ast.mname + in combine acc (import_funcs ipd.Ast.flist next_ec)) importee importee.import_exprs + else + let (x, y) = check_funs funcs importee + in + if x = [] then y (* Resolved all importings *) + else + match importee.import_exprs with + [] -> failwithf "import failed - functions `%s' not found" (List.hd x) + | ex -> List.fold_left (fun acc (ipd: Ast.import_decl) -> + let next_ec = parse_import_file ipd.Ast.mname + in combine acc (import_funcs x next_ec)) y ex + in + import_funcs ["*"] ec + +(* Generate the Enclave code. *) +let gen_enclave_code (e: Ast.enclave) (ep: edger8r_params) = + let ec = reduce_import (parse_enclave_ast e) in + g_use_prefix := ep.use_prefix; + g_untrusted_dir := ep.untrusted_dir; + g_trusted_dir := ep.trusted_dir; + create_dir ep.untrusted_dir; + create_dir ep.trusted_dir; + check_duplication ec; + check_allow_list ec; + (if not ep.header_only then check_priv_funcs ec); + (if ep.gen_untrusted then (gen_untrusted_header ec; if not ep.header_only then gen_untrusted_source ec)); + (if ep.gen_trusted then (gen_trusted_header ec; if not ep.header_only then gen_trusted_source ec)) diff --git a/sdk/edger8r/linux/Edger8r.ml b/sdk/edger8r/linux/Edger8r.ml new file mode 100644 index 0000000000..76d587e309 --- /dev/null +++ b/sdk/edger8r/linux/Edger8r.ml @@ -0,0 +1,46 @@ +(* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *) + + +let _ = + let progname = Sys.argv.(0) in + let argc = Array.length Sys.argv in + let args = if argc = 1 then [||] else Array.sub Sys.argv 1 (argc-1) in + let cmd_params = Util.parse_cmdline progname (Array.to_list args) in + + let real_ast_handler fname = + try + CodeGen.gen_enclave_code (CodeGen.start_parsing fname) cmd_params + with + Failure s -> (Printf.eprintf "error: %s\n" s; exit (-1)) + in + if cmd_params.Util.input_files = [] then Util.usage progname + else List.iter real_ast_handler cmd_params.Util.input_files diff --git a/sdk/edger8r/linux/Lexer.mll b/sdk/edger8r/linux/Lexer.mll new file mode 100644 index 0000000000..0eb7c16ec2 --- /dev/null +++ b/sdk/edger8r/linux/Lexer.mll @@ -0,0 +1,124 @@ +(* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *) + +{ +open Parser + +let string_to_int32 s = int_of_string s +} + +(* These are some regular expression definitions *) +let open_comment = "/*" +let close_comment = "*/" +let line_comment = "//" + +let space = [' ' '\t'] +let newline = ('\n' | '\r' '\n') +let digit = ['0' - '9'] +let ident = ['_' 'a' - 'z' 'A' - 'Z'] +let identifier = ident(ident|digit)* +let number = digit+ +let string = '"' [^'"']* '"' (* No embedded '\"' *) + +rule tokenize = parse + (* space and newline *) + | space { tokenize lexbuf } + | newline { Lexing.new_line lexbuf; tokenize lexbuf } + + (* data types *) + | "char" { Tchar } + | "short" { Tshort } + | "unsigned" { Tunsigned } + | "int" { Tint } + | "float" { Tfloat } + | "double" { Tdouble } + + | "int8_t" { Tint8 } + | "int16_t" { Tint16 } + | "int32_t" { Tint32 } + | "int64_t" { Tint64 } + + | "uint8_t" { Tuint8 } + | "uint16_t" { Tuint16 } + | "uint32_t" { Tuint32 } + | "uint64_t" { Tuint64 } + + | "size_t" { Tsizet } + | "wchar_t" { Twchar } + | "long" { Tlong } + | "void" { Tvoid } + + | "struct" { Tstruct } + | "union" { Tunion } + | "enum" { Tenum } + + (* specifier *) + | "enclave" { Tenclave } + | "trusted" { Ttrusted } + | "untrusted" { Tuntrusted } + | "from" { Tfrom } + | "import" { Timport } + | "allow" { Tallow } + | "public" { Tpublic } + | "include" { Tinclude } + | "propagate_errno" { Tpropagate_errno } + + (* Type qualifier *) + | "const" { Tconst } + + (* symbols *) + | '{' { TLBrace } + | '}' { TRBrace } + | '(' { TLParen } + | ')' { TRParen } + | '[' { TLBrack } + | ']' { TRBrack } + | '*' { TPtr } + | '.' { TDot } + | ',' { TComma } + | ';' { TSemicolon } + | '=' { TEqual } + | identifier { Tidentifier(Lexing.lexeme lexbuf) } + | number { Tnumber(string_to_int32(Lexing.lexeme lexbuf)) } + | string { let s = Lexing.lexeme lexbuf in Tstring(String.sub s 1 (String.length s - 2)) } + + (* comments *) + | line_comment { eat_until_nl lexbuf } + | open_comment { comment lexbuf } + | eof { EOF } + | _ { failwith ("Invalid token: " ^ Lexing.lexeme(lexbuf)) } +and eat_until_nl = parse + | newline { Lexing.new_line lexbuf; tokenize lexbuf } + | _ { eat_until_nl lexbuf } +and comment = parse (* comments can't be nested *) + close_comment { tokenize lexbuf } + | newline { Lexing.new_line lexbuf; comment lexbuf } + | _ { comment lexbuf } diff --git a/sdk/edger8r/linux/Makefile b/sdk/edger8r/linux/Makefile new file mode 100644 index 0000000000..007117b2be --- /dev/null +++ b/sdk/edger8r/linux/Makefile @@ -0,0 +1,48 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +.PHONY: all +all: build | $(BUILD_DIR) + @$(CP) $(CUR_DIR)/_build/Edger8r.native $(BUILD_DIR)/sgx_edger8r + +.PHONY: build +build: + ocamlbuild -no-links -libs str,unix Edger8r.native + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: +clean: + @ocamlbuild Edger8r.native -clean + @$(RM) $(BUILD_DIR)/sgx_edger8r diff --git a/sdk/edger8r/linux/Parser.mly b/sdk/edger8r/linux/Parser.mly new file mode 100644 index 0000000000..a5dabc3368 --- /dev/null +++ b/sdk/edger8r/linux/Parser.mly @@ -0,0 +1,606 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +%{ +open Util (* for failwithf *) + +(* Here we defined some helper routines to check attributes. + * + * An alternative approach is to code these rules in Lexer/Parser but + * it has several drawbacks: + * + * 1. Bad extensibility; + * 2. It grows the table size and down-graded the parsing time; + * 3. It makes error reporting rigid this way. + *) + +let get_string_from_attr (v: Ast.attr_value) (err_func: int -> string) = + match v with + Ast.AString s -> s + | Ast.ANumber n -> err_func n + +(* Check whether 'size' or 'sizefunc' is specified. *) +let has_size (sattr: Ast.ptr_size) = + sattr.Ast.ps_size <> None || sattr.Ast.ps_sizefunc <> None + +(* Pointers can have the following attributes: + * + * 'size' - specifies the size of the pointer. + * e.g. size = 4, size = val ('val' is a parameter); + * + * 'count' - indicates how many of items is managed by the pointer + * e.g. count = 100, count = n ('n' is a parameter); + * + * 'sizefunc' - use a function to compute the size of the pointer. + * e.g. sizefunc = get_ptr_size + * + * 'string' - indicate the pointer is managing a C string; + * 'wstring' - indicate the pointer is managing a wide char string. + * + * 'isptr' - to specify that the foreign type is a pointer. + * 'isary' - to specify that the foreign type is an array. + * 'readonly' - to specify that the foreign type has a 'const' qualifier. + * + * 'user_check' - inhibit Edger8r from generating code to check the pointer. + * + * 'in' - the pointer is used as input + * 'out' - the pointer is used as output + * + * Note that 'size' and 'sizefunc' are mutual exclusive (but they can + * be used together with 'count'. 'string' and 'wstring' indicates 'isptr', + * and they cannot use with only an 'out' attribute. + *) +let get_ptr_attr (attr_list: (string * Ast.attr_value) list) = + let get_new_dir (cds: string) (cda: Ast.ptr_direction) (old: Ast.ptr_direction) = + if old = Ast.PtrNoDirection then cda + else if old = Ast.PtrInOut then failwithf "duplicated attribute: `%s'" cds + else if old = cda then failwithf "duplicated attribute: `%s'" cds + else Ast.PtrInOut + in + let update_attr (key: string) (value: Ast.attr_value) (res: Ast.ptr_attr) = + match key with + "size" -> + { res with Ast.pa_size = { res.Ast.pa_size with Ast.ps_size = Some value }} + | "count" -> + { res with Ast.pa_size = { res.Ast.pa_size with Ast.ps_count = Some value }} + | "sizefunc" -> + let efn n = failwithf "invalid function name (%d) for `sizefunc'" n in + let funcname = get_string_from_attr value efn + in { res with Ast.pa_size = + { res.Ast.pa_size with Ast.ps_sizefunc = Some funcname }} + | "string" -> { res with Ast.pa_isptr = true; Ast.pa_isstr = true; } + | "wstring" -> { res with Ast.pa_isptr = true; Ast.pa_iswstr = true; } + | "isptr" -> { res with Ast.pa_isptr = true } + | "isary" -> { res with Ast.pa_isary = true } + + | "readonly" -> { res with Ast.pa_rdonly = true } + | "user_check" -> { res with Ast.pa_chkptr = false } + + | "in" -> + let newdir = get_new_dir "in" Ast.PtrIn res.Ast.pa_direction + in { res with Ast.pa_direction = newdir } + | "out" -> + let newdir = get_new_dir "out" Ast.PtrOut res.Ast.pa_direction + in { res with Ast.pa_direction = newdir } + | _ -> failwithf "unknown attribute: %s" key + in + let rec do_get_ptr_attr alist res_attr = + match alist with + [] -> res_attr + | (k,v) :: xs -> do_get_ptr_attr xs (update_attr k v res_attr) + in + let has_str_attr (pattr: Ast.ptr_attr) = + if pattr.Ast.pa_isstr && pattr.Ast.pa_iswstr + then failwith "`string' and `wstring' are mutual exclusive" + else (pattr.Ast.pa_isstr || pattr.Ast.pa_iswstr) + in + let check_invalid_ptr_size (pattr: Ast.ptr_attr) = + let ps = pattr.Ast.pa_size in + if ps.Ast.ps_size <> None && ps.Ast.ps_sizefunc <> None + then failwith "`size' and `sizefunc' cannot be used at the same time" + else + if ps <> Ast.empty_ptr_size && has_str_attr pattr + then failwith "size attributes are mutual exclusive with (w)string attribute" + else + if (ps <> Ast.empty_ptr_size || has_str_attr pattr) && + pattr.Ast.pa_direction = Ast.PtrNoDirection + then failwith "size/string attributes must be used with pointer direction" + else pattr + in + let check_ptr_dir (pattr: Ast.ptr_attr) = + if pattr.Ast.pa_direction <> Ast.PtrNoDirection && pattr.Ast.pa_chkptr = false + then failwith "pointer direction and `user_check' are mutual exclusive" + else + if pattr.Ast.pa_direction = Ast.PtrNoDirection && pattr.Ast.pa_chkptr + then failwith "pointer/array should have direction attribute or `user_check'" + else + if pattr.Ast.pa_direction = Ast.PtrOut && (has_str_attr pattr || pattr.Ast.pa_size.Ast.ps_sizefunc <> None) + then failwith "string/wstring/sizefunc should be used with an `in' attribute" + else pattr + in + let check_invalid_ary_attr (pattr: Ast.ptr_attr) = + if pattr.Ast.pa_size <> Ast.empty_ptr_size + then failwith "Pointer size attributes cannot be used with foreign array" + else + if not pattr.Ast.pa_isptr + then + (* 'pa_chkptr' is default to true unless user specifies 'user_check' *) + if pattr.Ast.pa_chkptr && pattr.Ast.pa_direction = Ast.PtrNoDirection + then failwith "array must have direction attribute or `user_check'" + else pattr + else + if has_str_attr pattr + then failwith "`isary' cannot be used with `string/wstring' together" + else failwith "`isary' cannot be used with `isptr' together" + in + let pattr = do_get_ptr_attr attr_list { Ast.pa_direction = Ast.PtrNoDirection; + Ast.pa_size = Ast.empty_ptr_size; + Ast.pa_isptr = false; + Ast.pa_isary = false; + Ast.pa_isstr = false; + Ast.pa_iswstr = false; + Ast.pa_rdonly = false; + Ast.pa_chkptr = true; + } + in + if pattr.Ast.pa_isary + then check_invalid_ary_attr pattr + else check_invalid_ptr_size pattr |> check_ptr_dir + +(* Untrusted functions can have these attributes: + * + * a. 3 mutual exclusive calling convention specifier: + * 'stdcall', 'fastcall', 'cdecl'. + * + * b. 'dllimport' - to import a public symbol. + *) +let get_func_attr (attr_list: (string * Ast.attr_value) list) = + let get_new_callconv (key: string) (cur: Ast.call_conv) (old: Ast.call_conv) = + if old <> Ast.CC_NONE then + failwithf "unexpected `%s', conflict with `%s'." key (Ast.get_call_conv_str old) + else cur + in + let update_attr (key: string) (value: Ast.attr_value) (res: Ast.func_attr) = + match key with + | "stdcall" -> + let callconv = get_new_callconv key Ast.CC_STDCALL res.Ast.fa_convention + in { res with Ast.fa_convention = callconv} + | "fastcall" -> + let callconv = get_new_callconv key Ast.CC_FASTCALL res.Ast.fa_convention + in { res with Ast.fa_convention = callconv} + | "cdecl" -> + let callconv = get_new_callconv key Ast.CC_CDECL res.Ast.fa_convention + in { res with Ast.fa_convention = callconv} + | "dllimport" -> + if res.Ast.fa_dllimport then failwith "duplicated attribute: `dllimport'" + else { res with Ast.fa_dllimport = true } + | _ -> failwithf "invalid function attribute: %s" key + in + let rec do_get_func_attr alist res_attr = + match alist with + [] -> res_attr + | (k,v) :: xs -> do_get_func_attr xs (update_attr k v res_attr) + in do_get_func_attr attr_list { Ast.fa_dllimport = false; + Ast.fa_convention= Ast.CC_NONE; + } + +(* Some syntax checking against pointer attributes. + * range: (Lexing.position * Lexing.position) + *) +let check_ptr_attr (fd: Ast.func_decl) range = + let fname = fd.Ast.fname in + let check_const (pattr: Ast.ptr_attr) (identifier: string) = + let raise_err_direction (direction:string) = + failwithf "`%s': `%s' is readonly - cannot be used with `%s'" + fname identifier direction + in + if pattr.Ast.pa_rdonly + then + match pattr.Ast.pa_direction with + Ast.PtrOut | Ast.PtrInOut -> raise_err_direction "out" + | _ -> () + else () + in + let check_void_ptr_size (pattr: Ast.ptr_attr) (identifier: string) = + if pattr.Ast.pa_chkptr && (not (has_size pattr.Ast.pa_size)) + then failwithf "`%s': void pointer `%s' - buffer size unknown" fname identifier + else () + in + let checker (pd: Ast.pdecl) = + let pt, declr = pd in + let identifier = declr.Ast.identifier in + match pt with + Ast.PTVal _ -> () + | Ast.PTPtr(atype, pattr) -> + if atype <> Ast.Ptr(Ast.Void) then check_const pattr identifier + else (* 'void' pointer, check there is a size or 'user_check' *) + check_void_ptr_size pattr identifier + in + List.iter checker fd.Ast.plist +%} + +%token EOF +%token TDot TComma TSemicolon TPtr TEqual +%token TLParen TRParen +%token TLBrace TRBrace +%token TLBrack TRBrack +%token Tpublic +%token Tinclude +%token Tconst +%token Tidentifier +%token Tnumber +%token Tstring +%token Tchar Tshort Tunsigned Tint Tfloat Tdouble + Tint8 Tint16 Tint32 Tint64 + Tuint8 Tuint16 Tuint32 Tuint64 + Tsizet Twchar Tvoid Tlong Tstruct Tunion Tenum +%token Tenclave Tfrom Timport Ttrusted Tuntrusted Tallow Tpropagate_errno + +%start start_parsing +%type start_parsing + +/* Grammar follows */ +%% + +/* Type definitions + * ------------------------------------------------------------------------ + */ +char_type: Tchar { Ast.Char Ast.Signed } + | Tunsigned Tchar { Ast.Char Ast.Unsigned } + ; + +/* Explicit shortness. */ +ex_shortness: Tshort { Ast.IShort } + | Tlong { Ast.ILong } + ; + +longlong: Tlong Tlong { Ast.LLong Ast.Signed } + | Tunsigned Tlong Tlong { Ast.LLong Ast.Unsigned } + +shortness: /* empty */ { Ast.INone } + | ex_shortness { $1 } + ; + +int_type: shortness Tint { + Ast.Int { Ast.ia_signedness = Ast.Signed; Ast.ia_shortness = $1 } + } + | Tunsigned shortness Tint { + Ast.Int { Ast.ia_signedness = Ast.Unsigned; Ast.ia_shortness = $2 } + } + | Tunsigned shortness { + Ast.Int { Ast.ia_signedness = Ast.Unsigned; Ast.ia_shortness = $2 } + } + | longlong { $1 } + | ex_shortness { + Ast.Int { Ast.ia_signedness = Ast.Signed; Ast.ia_shortness = $1 } + } + ; + +type_spec: + char_type { $1 } + | int_type { $1 } + + | Tfloat { Ast.Float } + | Tdouble { Ast.Double } + | Tlong Tdouble { Ast.LDouble } + + | Tint8 { Ast.Int8 } + | Tint16 { Ast.Int16 } + | Tint32 { Ast.Int32 } + | Tint64 { Ast.Int64 } + | Tuint8 { Ast.UInt8 } + | Tuint16 { Ast.UInt16 } + | Tuint32 { Ast.UInt32 } + | Tuint64 { Ast.UInt64 } + | Tsizet { Ast.SizeT } + | Twchar { Ast.WChar } + | Tvoid { Ast.Void } + + | struct_specifier { $1 } + | union_specifier { $1 } + | enum_specifier { $1 } + | Tidentifier { Ast.Foreign($1) } /* User defined types in C header */ + ; + +pointer: TPtr { fun ii -> Ast.Ptr(ii) } + | pointer TPtr { fun ii -> Ast.Ptr($1 ii) } + ; + +empty_dimension: TLBrack TRBrack { failwith "Flexible array is not supported." } +fixed_dimension: TLBrack Tnumber TRBrack { if $2 <> 0 then [$2] + else failwith "Zero-length array is not supported." } + +fixed_size_array: fixed_dimension { $1 } + | fixed_size_array fixed_dimension { $1 @ $2 } + ; + +array_size: fixed_size_array { $1 } + | empty_dimension { $1 } + | empty_dimension fixed_size_array { $1 @ $2 } + ; + +all_type: type_spec { $1 } + | type_spec pointer { $2 $1 } + ; + +declarator: Tidentifier { { Ast.identifier = $1; Ast.array_dims = []; } } + | Tidentifier array_size { { Ast.identifier = $1; Ast.array_dims = $2; } } + ; + +/* Available types as parameter. + * + * Instead of returning an value of 'Ast.parameter_type', we return + * a lambda which wraps the actual type since so far there is no way + * to tell whether the identifier is followed by array dimensions. +*/ +param_type: attr_block all_type { + match $2 with + Ast.Ptr _ -> fun x -> Ast.PTPtr($2, get_ptr_attr $1) + | _ -> + if $1 <> [] then + let attr = get_ptr_attr $1 in + match $2 with + Ast.Foreign s -> + if attr.Ast.pa_isptr || attr.Ast.pa_isary then fun x -> Ast.PTPtr($2, attr) + else + (* thinking about 'user_defined_type var[4]' *) + fun is_ary -> + if is_ary then Ast.PTPtr($2, attr) + else failwithf "`%s' is considerred plain type but decorated with pointer attributes" s + | _ -> + fun is_ary -> + if is_ary then Ast.PTPtr($2, attr) + else failwithf "unexpected pointer attributes for `%s'" (Ast.get_tystr $2) + else + fun is_ary -> + if is_ary then Ast.PTPtr($2, get_ptr_attr []) + else Ast.PTVal $2 + } + | all_type { + match $1 with + Ast.Ptr _ -> fun x -> Ast.PTPtr($1, get_ptr_attr []) + | _ -> + fun is_ary -> + if is_ary then Ast.PTPtr($1, get_ptr_attr []) + else Ast.PTVal $1 + } + | attr_block Tconst type_spec pointer { + let attr = get_ptr_attr $1 + in fun x -> Ast.PTPtr($4 $3, { attr with Ast.pa_rdonly = true }) + } + | Tconst type_spec pointer { + let attr = get_ptr_attr [] + in fun x -> Ast.PTPtr($3 $2, { attr with Ast.pa_rdonly = true }) + } + ; + + +attr_block: TLBrack TRBrack { failwith "no attribute specified." } + | TLBrack key_val_pairs TRBrack { $2 } + ; + +key_val_pairs: key_val_pair { [$1] } + | key_val_pairs TComma key_val_pair { $3 :: $1 } + ; + +key_val_pair: Tidentifier TEqual Tidentifier { ($1, Ast.AString($3)) } + | Tidentifier TEqual Tnumber { ($1, Ast.ANumber($3)) } + | Tidentifier { ($1, Ast.AString("")) } + ; + +struct_specifier: Tstruct Tidentifier { Ast.Struct($2) } +union_specifier: Tunion Tidentifier { Ast.Union($2) } +enum_specifier: Tenum Tidentifier { Ast.Enum($2) } + +struct_definition: struct_specifier TLBrace member_list TRBrace { + let s = { Ast.sname = (match $1 with Ast.Struct s -> s | _ -> ""); + Ast.mlist = List.rev $3; } + in Ast.StructDef(s) + } + +union_definition: union_specifier TLBrace member_list TRBrace { + let s = { Ast.sname = (match $1 with Ast.Union s -> s | _ -> ""); + Ast.mlist = List.rev $3; } + in Ast.UnionDef(s) + } + +/* enum can be anonymous. */ +enum_definition: Tenum TLBrace enum_body TRBrace { + let e = { Ast.enname = ""; Ast.enbody = $3; } + in Ast.EnumDef(e) + } + | enum_specifier TLBrace enum_body TRBrace { + let e = { Ast.enname = (match $1 with Ast.Enum s -> s | _ -> ""); + Ast.enbody = $3; } + in Ast.EnumDef(e) + } + ; + +enum_body: /* empty */ { [] } + | enum_eles { List.rev $1 } + ; + +enum_eles: enum_ele { [$1] } + | enum_eles TComma enum_ele { $3 :: $1 } + ; + +enum_ele: Tidentifier { ($1, Ast.EnumValNone) } + | Tidentifier TEqual Tidentifier { ($1, Ast.EnumVal (Ast.AString $3)) } + | Tidentifier TEqual Tnumber { ($1, Ast.EnumVal (Ast.ANumber $3)) } + ; + +composite_defs: struct_definition { $1 } + | union_definition { $1 } + | enum_definition { $1 } + ; + +member_list: member_def TSemicolon { [$1] } + | member_list member_def TSemicolon { $2 :: $1 } + ; + +member_def: all_type declarator { ($1, $2) } + +/* Importing declarations. + * ------------------------------------------------------------------------ + */ +func_list: Tidentifier { [$1] } + | func_list TComma Tidentifier { $3 :: $1 } + ; + +module_path: Tstring { $1 } + +import_declaration: Tfrom module_path Timport func_list { + { Ast.mname = $2; Ast.flist = List.rev $4; } + } + | Tfrom module_path Timport TPtr { + { Ast.mname = $2; Ast.flist = ["*"]; } + } + ; + +include_declaration: Tinclude Tstring { $2 } + +include_declarations: include_declaration { [$1] } + | include_declarations include_declaration { $2 :: $1 } + ; + +/* Enclave function declarations. + * ------------------------------------------------------------------------ + */ +enclave_functions: Ttrusted TLBrace trusted_block TRBrace TSemicolon { + List.rev $3 + } + | Tuntrusted TLBrace untrusted_block TRBrace TSemicolon { + List.rev $3 + } + ; + +trusted_block: trusted_functions { $1 } + | include_declarations trusted_functions { + trusted_headers := !trusted_headers @ List.rev $1; $2 + } + ; + +untrusted_block: untrusted_functions { $1 } + | include_declarations untrusted_functions { + untrusted_headers := !untrusted_headers @ List.rev $1; $2 + } + ; + +/* is_priv? Default to true. */ +access_modifier: /* nothing */ { true } + | Tpublic { false } + ; + +trusted_functions: /* nothing */ { [] } + | trusted_functions access_modifier func_def TSemicolon { + check_ptr_attr $3 (symbol_start_pos(), symbol_end_pos()); + Ast.Trusted { Ast.tf_fdecl = $3; Ast.tf_is_priv = $2 } :: $1 + } + ; + +untrusted_functions: /* nothing */ { [] } + | untrusted_functions untrusted_func_def TSemicolon { $2 :: $1 } + ; + +func_def: all_type Tidentifier parameter_list { + { Ast.fname = $2; Ast.rtype = $1; Ast.plist = List.rev $3 ; } + } + | all_type array_size Tidentifier parameter_list { + failwithf "%s: returning an array is not supported - use pointer instead." $3 + } + ; + +parameter_list: TLParen TRParen { [] } + | TLParen Tvoid TRParen { [] } /* Make C programers comfortable */ + | TLParen parameter_defs TRParen { $2 } + ; + +parameter_defs: parameter_def { [$1] } + | parameter_defs TComma parameter_def { $3 :: $1 } + ; + +parameter_def: param_type declarator { + let pt = $1 (Ast.is_array $2) in + let is_void = + match pt with + Ast.PTVal v -> v = Ast.Void + | _ -> false + in + if is_void then + failwithf "parameter `%s' has `void' type." $2.Ast.identifier + else + (pt, $2) + } + +/* propagate_errno? Default to false. */ +propagate_errno: /* nothing */ { false } + | Tpropagate_errno { true } + ; + +untrusted_func_def: attr_block func_def allow_list propagate_errno { + check_ptr_attr $2 (symbol_start_pos(), symbol_end_pos()); + let fattr = get_func_attr $1 in + Ast.Untrusted { Ast.uf_fdecl = $2; Ast.uf_fattr = fattr; Ast.uf_allow_list = $3; Ast.uf_propagate_errno = $4 } + } + | func_def allow_list propagate_errno { + check_ptr_attr $1 (symbol_start_pos(), symbol_end_pos()); + let fattr = get_func_attr [] in + Ast.Untrusted { Ast.uf_fdecl = $1; Ast.uf_fattr = fattr; Ast.uf_allow_list = $2; Ast.uf_propagate_errno = $3 } + } + ; + +allow_list: /* nothing */ { [] } + | Tallow TLParen TRParen { [] } + | Tallow TLParen func_list TRParen { $3 } + ; + +/* Enclave definition + * ------------------------------------------------------------------------ + */ +expressions: /* nothing */ { [] } + | expressions include_declaration { Ast.Include($2) :: $1 } + | expressions import_declaration TSemicolon { Ast.Importing($2) :: $1 } + | expressions composite_defs TSemicolon { Ast.Composite($2) :: $1 } + | expressions enclave_functions { Ast.Interface($2) :: $1 } + ; + +enclave_def: Tenclave TLBrace expressions TRBrace { + { Ast.ename = ""; + Ast.eexpr = List.rev $3 } + } + ; + +/* The entry point of parser. + * ------------------------------------------------------------------------ + */ +start_parsing: enclave_def TSemicolon EOF { $1 } + +%% diff --git a/sdk/edger8r/linux/SimpleStack.ml b/sdk/edger8r/linux/SimpleStack.ml new file mode 100644 index 0000000000..07806c1b51 --- /dev/null +++ b/sdk/edger8r/linux/SimpleStack.ml @@ -0,0 +1,40 @@ +(* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *) + +type 'a t = { mutable c : 'a list } +exception Empty +let create () = { c = [] } +let push x s = s.c <- x :: s.c +let pop s = + match s.c with + hd::tl -> s.c <- tl; hd + | [] -> raise Empty +let mem x s = List.mem x s.c diff --git a/sdk/edger8r/linux/Util.ml b/sdk/edger8r/linux/Util.ml new file mode 100644 index 0000000000..0c01f41ed5 --- /dev/null +++ b/sdk/edger8r/linux/Util.ml @@ -0,0 +1,308 @@ +(* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *) + +open Printf + +(* It contains some utility functions. *) +let failwithf fmt = kprintf failwith fmt;; +let splitwith chr = Str.split (Str.regexp_string (Char.escaped chr)) + +(* For compatibility with F#. *) +let (|>) a f = f a + +(* Generate a list of sequent number. + * ---------------------------------- + * + * mk_seq 1 0 -> [] + * mk_seq 1 1 -> [1] + * mk_seq 1 5 -> [1; 2; 3; 4; 5] + *) +let rec mk_seq from_num to_num = + if from_num > to_num then [] + else from_num :: mk_seq (from_num + 1) to_num + +(* Return a list without duplicated elements. *) +let dedup_list lst = + let rec do_dedup acc rst = + match rst with + [] -> acc + | h::t -> if List.mem h acc then do_dedup acc t + else do_dedup (h :: acc) t + in do_dedup [] lst + +(* Print the usage of this program. *) +let usage (progname: string) = + eprintf "usage: %s [options] ...\n" progname; + eprintf "\n[options]\n\ +--search-path Specify the search path of EDL files\n\ +--use-prefix Prefix untrusted proxy with Enclave name\n\ +--header-only Only generate header files\n\ +--untrusted Generate untrusted proxy and bridge\n\ +--trusted Generate trusted proxy and bridge\n\ +--untrusted-dir Specify the directory for saving untrusted code\n\ +--trusted-dir Specify the directory for saving trusted code\n\ +--help Print this help message\n"; + eprintf "\n\ +If neither `--untrusted' nor `--trusted' is specified, generate both.\n"; + exit 1 + + +(* Command line parsing facilities. *) +type edger8r_params = { + input_files : string list; + use_prefix : bool; + header_only : bool; + gen_untrusted : bool; (* User specified `--untrusted' *) + gen_trusted : bool; (* User specified `--trusted' *) + untrusted_dir : string; (* Directory to save untrusted code *) + trusted_dir : string; (* Directory to save trusted code *) +} + +(* The search paths are recored in the array below. + * W/o extra search paths specified, edger8r searchs from current directory. + *) +let search_paths = ref [|"."|] + +(* The path separator is usually ':' on Linux and ';' on Windows. + * Concerning that we might compile this code with OCaml on Windows, + * we'd better don't assume that ':' is always used. + *) +let path_separator : char = + match Sys.os_type with + "Win32" -> ';' + | _ -> ':' (* "Unix" or "Cygwin" *) + +(* Parse the command line and return a record of `edger8r_params'. *) +let rec parse_cmdline (progname: string) (cmdargs: string list) = + let use_pref = ref false in + let hd_only = ref false in + let untrusted= ref false in + let trusted = ref false in + let u_dir = ref "." in + let t_dir = ref "." in + let files = ref [] in + + let rec local_parser (args: string list) = + match args with + [] -> () + | op :: ops -> + match String.lowercase op with + "--use-prefix" -> use_pref := true; local_parser ops + | "--header-only"-> hd_only := true; local_parser ops + | "--untrusted" -> untrusted := true; local_parser ops + | "--trusted" -> trusted := true; local_parser ops + | "--untrusted-dir" -> + (match ops with + [] -> usage progname + | x::xs -> u_dir := x; local_parser xs) + | "--trusted-dir" -> + (match ops with + [] -> usage progname + | x::xs -> t_dir := x; local_parser xs) + | "--help" -> usage progname + | "--search-path" -> + if ops = [] then usage progname + else + let search_path_str = List.hd ops in + let extra_paths = splitwith path_separator search_path_str in + let extra_path_arry = Array.of_list extra_paths in + search_paths := Array.append extra_path_arry !search_paths; + local_parser (List.tl ops) + | _ -> files := op :: !files; local_parser ops + in + local_parser cmdargs; + let opt = + { input_files = List.rev !files; use_prefix = !use_pref; + header_only = !hd_only; gen_untrusted = true; gen_trusted = true; + untrusted_dir = !u_dir; trusted_dir = !t_dir; + } + in + if !untrusted || !trusted (* User specified '--untrusted' or '--trusted' *) + then { opt with gen_trusted = !trusted; gen_untrusted = !untrusted } + else opt + +let separator_str : string = Filename.dir_sep + +(* Search the file within given search pathes. + * ------------------------------------------- + * + * The second parameter is read from the global variable `search_paths'. + * + * get_file_path "Util.fs" [|"."|] -> "./Ast.fs" + * get_file_path "Util.fs" [|"misc/dir"; "../Edger8r"|] -> "../Edger8r/Ast.fs" + * get_file_path "Util.fs" [|"misc/dir"; "another/dir"|] -> Not_found + *) +let get_file_path (fname: string) = + let get_full_name path = + if Filename.is_relative fname then path ^ separator_str ^ fname + else fname + in + let targets = Array.map get_full_name !search_paths in + let fn_list = Array.to_list targets in + try + List.find Sys.file_exists fn_list + with + Not_found -> failwithf "File not found within search paths: %s\n" fname + +(* Get the short name of the given file name. + * ------------------------------------------ + * + * get_short_name "Util.fs" -> "Util" + * get_short_name "./Util.fs" -> "Util" + * get_short_name "misc/Util.fs" -> "Util" + *) +let get_short_name (fname: string) = + let bn = Filename.basename fname in + try Filename.chop_extension bn + with Invalid_argument _ -> bn + +(* Helper functions that are not contained in OCaml standard library *) +let isdigit = function '0' | '1' .. '9' -> true | _ -> false +let isalpha = function 'a' .. 'z' | 'A' .. 'Z' -> true | _ -> false +let isalnum c = isdigit c || isalpha c + +let str_map f s = + let len = String.length s in + let res = String.create len in + for i = 0 to len - 1 do + String.set res i (f (String.get s i)) + done; + res + +let str_to_list s = + let rec iter i lst = + if i < 0 then lst else iter (i - 1) (s.[i] :: lst) + in + iter (String.length s - 1) [] + +let str_forall p s = List.for_all p (str_to_list s) + +(* Compute a string that conforms to C identifier. + * + * to_c_identifier "this foo" => "this_foo" + * to_c_identifier "3this" => "_this" + * + * The algorithm is simple, filter invalid characters to `_'. +*) +let to_c_identifier (s: string) = + let convert_char ch = + if isalnum ch then ch else '_' + in + let first_ch = + let ch = s.[0] in + if isalnum ch then ch else '_' + in + let rest_str = + String.sub s 1 (String.length s - 1) + in + Char.escaped first_ch ^ str_map convert_char rest_str + + +(* Check whether given string is a valid C identifier. + * + * is_c_identifier "this foo" => false + * is_c_identifier "3this" => false + * is_c_identifier "_this" => true +*) +let is_c_identifier(s: string) = + let first_ch = s.[0] in + let rest_str = String.sub s 1 (String.length s - 1) in + if isalpha first_ch || first_ch = '_' + then str_forall (fun ch -> isalnum ch || ch = '_') rest_str + else false + +(* ocamlyacc doesn't expose definitions in header section, + * as a quick work-around, we put them here. + *) +let trusted_headers : string list ref = ref [] +let untrusted_headers: string list ref = ref [] + +(* Create directory specified by `d'. *) +let create_dir (d: string) = + let curr_dir = Unix.getcwd () in + + (* `get_root_dir' will be called with the head element of a list of + * sub-directories starting from root directory. + * The list will look like - + * ["home", "guest", ...] on Linux, while + * ["c:\\", "Users", ...] on Windows. + *) + let get_root_dir (dirs: string list) = + match Sys.os_type with + "Win32" -> List.hd dirs + | _ -> Filename.dir_sep + in + (* If we have a directory list like ["c:", ...], change the first element + * to "c:\\". Due to the fact that: + * Sys.file_exists "c:" => false + * Sys.file_exists "c:\\" => true + *) + let normalize (ds: string list) = + if Sys.os_type <> "Win32" then ds + else + let d = List.hd ds in + if String.length d = 2 && d.[1] = ':' + then (d ^ Filename.dir_sep) :: List.tl ds + else ds + in + let dir_exist_p dir = + if Sys.file_exists dir then + let stats = Unix.stat dir in + match stats.Unix.st_kind with + | Unix.S_DIR -> true + (* No need handle S_LNK because 'stat' will follow link. *) + | _ -> false + else false + in + let __do_create_and_goto_dir dir = + (if dir_exist_p dir then () else Unix.mkdir dir 0o755); + Unix.chdir dir + in + let do_create_dir () = + let rec do_create_dir_recursively dirs = + match dirs with + [] -> () + | x::xs -> + __do_create_and_goto_dir x; do_create_dir_recursively xs + in + (* After splitting, we will get a list of all sub-directories. + * "/home/guest/some/path" -> ["home", "guest", "some", "path"]; + * "c:\Users\guest\some\path" -> ["c:", "Users", "guest", "some", "path"]. + *) + let dirs = normalize (Str.split (Str.regexp separator_str) d) in + let start_dir = if Filename.is_relative d then curr_dir else get_root_dir dirs in + Unix.chdir start_dir; + (* In case of continuous dir_sep in path string, we filter out empty strings. *) + do_create_dir_recursively (List.filter (fun s -> s <> "") dirs); + Unix.chdir curr_dir; + in + try do_create_dir () + with exn -> (eprintf "error: failed to create directory: `%s'\n" d; exit 1) diff --git a/sdk/sample_libcrypto/Makefile b/sdk/sample_libcrypto/Makefile new file mode 100644 index 0000000000..7b113c203f --- /dev/null +++ b/sdk/sample_libcrypto/Makefile @@ -0,0 +1,73 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +include ../../buildenv.mk + +CRYPTO_PATH = $(LINUX_EXTERNAL_DIR)/crypto_px + +CXXFLAGS += -Werror -fno-rtti -fno-exceptions -fPIC + +CPPFLAGS := -isystem $(CRYPTO_PATH)/include \ + -I$(COMMON_DIR)/inc/internal/ + +IPPFLAGS := -Wl,--start-group \ + $(CRYPTO_PATH)/libcrypto_px.a \ + -Wl,--end-group + +OBJS := sample_libcrypto.o + +LIBSAMPLECRYPTO := libsample_libcrypto.so + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: all +all: $(LIBSAMPLECRYPTO) | $(BUILD_DIR) + @$(CP) $< $| + +libcrypto_px: + $(MAKE) -C $(CRYPTO_PATH) + +# It's important that the IPPFLAGS go AFTER the .o / .cpp file(s) +$(LIBSAMPLECRYPTO): $(OBJS) libcrypto_px + $(CXX) $(CXXFLAGS) -shared -Bdynamic -Wl,-soname,$(LIBSAMPLECRYPTO) $< -o $@ $(IPPFLAGS) -Wl,--version-script,sample_libcrypto.lds + +$(OBJS): %.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + $(MAKE) -C $(CRYPTO_PATH) clean + @$(RM) $(OBJS) $(LIBSAMPLECRYPTO) $(BUILD_DIR)/$(LIBSAMPLECRYPTO) + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/sample_libcrypto/sample_libcrypto.cpp b/sdk/sample_libcrypto/sample_libcrypto.cpp new file mode 100644 index 0000000000..4b6b6f18e9 --- /dev/null +++ b/sdk/sample_libcrypto/sample_libcrypto.cpp @@ -0,0 +1,931 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* + * This sample cryptopgraphy library was intended to be used in a limited + * manner. Its cryptographic strength is very weak. It should not be + * used by any production code. Its scope is limited to assist in the + * development of the remote attestation sample application. +**/ + +#include +#include +#include + +#include "ippcp.h" + + +#include "sgx_memset_s.h" +#include "se_memcpy.h" + +#include "sample_libcrypto.h" +#include + +#ifdef __linux__ +/* + * __memset_vp is a volatile pointer to a function. + * It is initialised to point to memset, and should never be changed. + */ +static void * (* const volatile __memset_vp)(void *, int, size_t) + = (memset); + +#undef memset_s /* in case it was defined as a macro */ + +extern "C" int memset_s(void *s, size_t smax, int c, size_t n) +{ + int err = 0; + + if (s == NULL) { + err = EINVAL; + goto out; + } + + if (n > smax) { + err = EOVERFLOW; + n = smax; + } + + /* Calling through a volatile pointer should never be optimised away. */ + (*__memset_vp)(s, c, n); + + out: + if (err == 0) + return 0; + else { + errno = err; + /* XXX call runtime-constraint handler */ + return err; + } +} +#endif + +#ifndef ERROR_BREAK +#define ERROR_BREAK(x) if(x){break;} +#endif + +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr) = NULL;}} +#endif + +#ifndef ROUND_TO +#define ROUND_TO(x, align) (((x) + (align-1)) & ~(align-1)) +#endif + +#ifndef UNUSED +#define UNUSED(val) (void)(val) +#endif + + +// We are using this very non-random definition for reproducibility / debugging purposes. +static uint32_t seed = (uint32_t)(9); + +static inline sample_status_t __do_get_rand32(uint32_t* rand_num) +{ + // A better source of entropy would be the "time" function or something like that + *rand_num = seed; + return SAMPLE_SUCCESS; +} + +static inline IppStatus check_copy_size(size_t target_size, size_t source_size) +{ + if(target_size < source_size) + return ippStsSizeErr; + return ippStsNoErr; +} + +/* The function should generate a random number properly, and the pseudo-rand + implementation is only for demo purpose. */ +sample_status_t sample_read_rand(unsigned char *rand, size_t length_in_bytes) +{ + // check parameters + if(!rand || !length_in_bytes) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + // loop to rdrand + while(length_in_bytes > 0) + { + uint32_t rand_num = 0; + sample_status_t status = __do_get_rand32(&rand_num); + if(status != SAMPLE_SUCCESS) + { + return status; + } + size_t size = (length_in_bytes < sizeof(rand_num)) + ? length_in_bytes : sizeof(rand_num); + if(memcpy_s(rand, size, &rand_num, size)) + { + return status; + } + + rand += size; + length_in_bytes -= size; + } + return SAMPLE_SUCCESS; +} + +static IppStatus sgx_ipp_newBN(const Ipp32u *p_data, int size_in_bytes, IppsBigNumState **p_new_BN) +{ + IppsBigNumState *pBN=0; + int bn_size = 0; + + if(p_new_BN == NULL || (size_in_bytes <= 0) || ((size_in_bytes % sizeof(Ipp32u)) != 0)) + return ippStsBadArgErr; + + // Get the size of the IppsBigNumState context in bytes + IppStatus error_code = ippsBigNumGetSize(size_in_bytes/(int)sizeof(Ipp32u), &bn_size); + if(error_code != ippStsNoErr) + { + *p_new_BN = 0; + return error_code; + } + pBN = (IppsBigNumState *) malloc(bn_size); + if(!pBN) + { + error_code = ippStsMemAllocErr; + *p_new_BN = 0; + return error_code; + } + // Initialize context and partition allocated buffer + error_code = ippsBigNumInit(size_in_bytes/(int)sizeof(Ipp32u), pBN); + if(error_code != ippStsNoErr) + { + free(pBN); + *p_new_BN = 0; + return error_code; + } + if(p_data) + { + error_code = ippsSet_BN(IppsBigNumPOS, size_in_bytes/(int)sizeof(Ipp32u), p_data, pBN); + if(error_code != ippStsNoErr) + { + *p_new_BN = 0; + free(pBN); + return error_code; + } + } + + + *p_new_BN = pBN; + return error_code; +} + +static void sample_ipp_secure_free_BN(IppsBigNumState *pBN, int size_in_bytes) +{ + if(pBN == NULL || size_in_bytes <= 0 || size_in_bytes/sizeof(Ipp32u) <= 0) + { + if(pBN) + { + free(pBN); + } + return; + } + int bn_size = 0; + + // Get the size of the IppsBigNumState context in bytes + // Since we have checked the size_in_bytes before and the &bn_size is not NULL, ippsBigNumGetSize never returns failure + ippsBigNumGetSize(size_in_bytes/(int)sizeof(Ipp32u), &bn_size); + if (bn_size <= 0) + { + free(pBN); + return; + } + // Clear the buffer before free. + memset_s(pBN, bn_size, 0, bn_size); + free(pBN); + return; +} + +IppStatus __STDCALL sample_ipp_DRNGen(Ipp32u* pRandBNU, int nBits, void* pCtx_unused) +{ + sample_status_t sample_ret; + UNUSED(pCtx_unused); + + if(0 != nBits%8) + { + // Must be byte aligned + return ippStsSizeErr; + } + + if(!pRandBNU) + { + return ippStsNullPtrErr; + } + sample_ret = sample_read_rand((uint8_t*)pRandBNU, (uint32_t)nBits/8); + if(SAMPLE_SUCCESS != sample_ret) + { + return ippStsErr; + } + return ippStsNoErr; +} + + + +/* Rijndael AES-GCM +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_aes_gcm_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be encrypted/decrypted +* uint32_t src_len - Length of input stream to be encrypted/decrypted +* uint8_t *p_iv - Pointer to initialization vector to use +* uint32_t iv_len - Length of initialization vector +* uint8_t *p_aad - Pointer to input stream of additional authentication data +* uint32_t aad_len - Length of additional authentication data stream +* sample_aes_gcm_128bit_tag_t *p_in_mac - Pointer to expected MAC in decryption process +* Output: uint8_t *p_dst - Pointer to cipher text. Size of buffer should be >= src_len. +* sample_aes_gcm_128bit_tag_t *p_out_mac - Pointer to MAC generated from encryption process +* NOTE: Wrapper is responsible for confirming decryption tag matches encryption tag */ +sample_status_t sample_rijndael128GCM_encrypt(const sample_aes_gcm_128bit_key_t *p_key, const uint8_t *p_src, uint32_t src_len, + uint8_t *p_dst, const uint8_t *p_iv, uint32_t iv_len, const uint8_t *p_aad, uint32_t aad_len, + sample_aes_gcm_128bit_tag_t *p_out_mac) +{ + IppStatus error_code = ippStsNoErr; + IppsAES_GCMState* pState = NULL; + int ippStateSize = 0; + + if ((p_key == NULL) || ((src_len > 0) && (p_dst == NULL)) || ((src_len > 0) && (p_src == NULL)) + || (p_out_mac == NULL) || (iv_len != SAMPLE_AESGCM_IV_SIZE) || ((aad_len > 0) && (p_aad == NULL)) + || (p_iv == NULL) || ((p_src == NULL) && (p_aad == NULL))) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + error_code = ippsAES_GCMGetSize(&ippStateSize); + if (error_code != ippStsNoErr) + { + return SAMPLE_ERROR_UNEXPECTED; + } + pState = (IppsAES_GCMState*)malloc(ippStateSize); + if(pState == NULL) + { + return SAMPLE_ERROR_OUT_OF_MEMORY; + } + error_code = ippsAES_GCMInit((const Ipp8u *)p_key, SAMPLE_AESGCM_KEY_SIZE, pState, ippStateSize); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsMemAllocErr: return SAMPLE_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + error_code = ippsAES_GCMStart(p_iv, SAMPLE_AESGCM_IV_SIZE, p_aad, aad_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + if (src_len > 0) { + error_code = ippsAES_GCMEncrypt(p_src, p_dst, src_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + } + error_code = ippsAES_GCMGetTag((Ipp8u *)p_out_mac, SAMPLE_AESGCM_MAC_SIZE, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + return SAMPLE_SUCCESS; +} + + +/* Message Authentication - Rijndael 128 CMAC +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_cmac_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be MACed +* uint32_t src_len - Length of input stream to be MACed +* Output: sample_cmac_gcm_128bit_tag_t *p_mac - Pointer to resultant MAC */ +sample_status_t sample_rijndael128_cmac_msg(const sample_cmac_128bit_key_t *p_key, const uint8_t *p_src, + uint32_t src_len, sample_cmac_128bit_tag_t *p_mac) +{ + IppsAES_CMACState* pState = NULL; + int ippStateSize = 0; + IppStatus error_code = ippStsNoErr; + + if ((p_key == NULL) || (p_src == NULL) || (p_mac == NULL)) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + error_code = ippsAES_CMACGetSize(&ippStateSize); + if (error_code != ippStsNoErr) + { + return SAMPLE_ERROR_UNEXPECTED; + } + pState = (IppsAES_CMACState*)malloc(ippStateSize); + if(pState == NULL) + { + return SAMPLE_ERROR_OUT_OF_MEMORY; + } + error_code = ippsAES_CMACInit((const Ipp8u *)p_key, SAMPLE_CMAC_KEY_SIZE, pState, ippStateSize); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsMemAllocErr: return SAMPLE_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + error_code = ippsAES_CMACUpdate((const Ipp8u *)p_src, src_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + error_code = ippsAES_CMACFinal((Ipp8u *)p_mac, SAMPLE_CMAC_MAC_SIZE, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + return SAMPLE_SUCCESS; +} + +extern "C" int some_function() +{ + return 1234; +} + +/* +* Elliptic Curve Crytpography - Based on GF(p), 256 bit +*/ +/* Allocates and initializes ecc context +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Output: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system */ +sample_status_t sample_ecc256_open_context(sample_ecc_state_handle_t* ecc_handle) +{ + IppStatus ipp_ret = ippStsNoErr; + IppsECCPState* p_ecc_state = NULL; + // default use 256r1 parameter + int ctx_size = 0; + + if (ecc_handle == NULL) + return SAMPLE_ERROR_INVALID_PARAMETER; + ipp_ret = ippsECCPGetSize(256, &ctx_size); + if (ipp_ret != ippStsNoErr) + return SAMPLE_ERROR_UNEXPECTED; + p_ecc_state = (IppsECCPState*)(malloc(ctx_size)); + if (p_ecc_state == NULL) + return SAMPLE_ERROR_OUT_OF_MEMORY; + ipp_ret = ippsECCPInit(256, p_ecc_state); + if (ipp_ret != ippStsNoErr) + { + SAFE_FREE(p_ecc_state); + *ecc_handle = NULL; + return SAMPLE_ERROR_UNEXPECTED; + } + ipp_ret = ippsECCPSetStd(IppECCPStd256r1, p_ecc_state); + if (ipp_ret != ippStsNoErr) + { + SAFE_FREE(p_ecc_state); + *ecc_handle = NULL; + return SAMPLE_ERROR_UNEXPECTED; + } + *ecc_handle = p_ecc_state; + return SAMPLE_SUCCESS; +} + +/* Cleans up ecc context +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Output: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system */ +sample_status_t sample_ecc256_close_context(sample_ecc_state_handle_t ecc_handle) +{ + if (ecc_handle == NULL) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + int ctx_size = 0; + IppStatus ipp_ret = ippsECCPGetSize(256, &ctx_size); + if (ipp_ret != ippStsNoErr) + { + free(p_ecc_state); + return SAMPLE_SUCCESS; + } + memset_s(p_ecc_state, ctx_size, 0, ctx_size); + free(p_ecc_state); + return SAMPLE_SUCCESS; +} + +/* Populates private/public key pair - caller code allocates memory +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* Outputs: sample_ec256_private_t *p_private - Pointer to the private key +* sample_ec256_public_t *p_public - Pointer to the public key */ +sample_status_t sample_ecc256_create_key_pair(sample_ec256_private_t *p_private, + sample_ec256_public_t *p_public, + sample_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private == NULL) || (p_public == NULL)) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + + IppsBigNumState* dh_priv_BN = NULL; + IppsECCPPointState* point_pub = NULL; + IppsBigNumState* pub_gx = NULL; + IppsBigNumState* pub_gy = NULL; + IppStatus ipp_ret = ippStsNoErr; + int ecPointSize = 0; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + + do + { + //init eccp point + ipp_ret = ippsECCPPointGetSize(256, &ecPointSize); + ERROR_BREAK(ipp_ret); + point_pub = (IppsECCPPointState*)( malloc(ecPointSize) ); + if(!point_pub) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, point_pub); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, SAMPLE_ECP256_KEY_SIZE, &dh_priv_BN); + ERROR_BREAK(ipp_ret); + // Use the true random number (DRNG) + ipp_ret = ippsECCPGenKeyPair(dh_priv_BN, point_pub, p_ecc_state, (IppBitSupplier)sample_ipp_DRNGen, NULL); + ERROR_BREAK(ipp_ret); + + //convert point_result to oct string + ipp_ret = sgx_ipp_newBN(NULL, SAMPLE_ECP256_KEY_SIZE, &pub_gx); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(NULL, SAMPLE_ECP256_KEY_SIZE, &pub_gy); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPGetPoint(pub_gx, pub_gy, point_pub, p_ecc_state); + ERROR_BREAK(ipp_ret); + + IppsBigNumSGN sgn = IppsBigNumPOS; + Ipp32u *pdata = NULL; + // ippsRef_BN is in bits not bytes (versus old ippsGet_BN) + int length = 0; + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, pub_gx); + ERROR_BREAK(ipp_ret); + memset(p_public->gx, 0, sizeof(p_public->gx)); + ipp_ret = check_copy_size(sizeof(p_public->gx), ROUND_TO(length, 8)/8); + ERROR_BREAK(ipp_ret); + memcpy(p_public->gx, pdata, ROUND_TO(length, 8)/8); + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, pub_gy); + ERROR_BREAK(ipp_ret); + memset(p_public->gy, 0, sizeof(p_public->gy)); + ipp_ret = check_copy_size(sizeof(p_public->gy), ROUND_TO(length, 8)/8); + ERROR_BREAK(ipp_ret); + memcpy(p_public->gy, pdata, ROUND_TO(length, 8)/8); + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, dh_priv_BN); + ERROR_BREAK(ipp_ret); + memset(p_private->r, 0, sizeof(p_private->r)); + ipp_ret = check_copy_size(sizeof(p_private->r), ROUND_TO(length, 8)/8); + ERROR_BREAK(ipp_ret); + memcpy(p_private->r, pdata, ROUND_TO(length, 8)/8); + }while(0); + + //Clear temp buffer before free. + if(point_pub) memset_s(point_pub, ecPointSize, 0, ecPointSize); + SAFE_FREE(point_pub); + sample_ipp_secure_free_BN(pub_gx, SAMPLE_ECP256_KEY_SIZE); + sample_ipp_secure_free_BN(pub_gy, SAMPLE_ECP256_KEY_SIZE); + sample_ipp_secure_free_BN(dh_priv_BN, SAMPLE_ECP256_KEY_SIZE); + + switch (ipp_ret) + { + case ippStsNoErr: return SAMPLE_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SAMPLE_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } +} + + + + +/* Computes DH shared key based on private B key (local) and remote public Ga Key +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sample_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN +* sample_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN +* Output: sample_ec256_dh_shared_t *p_shared_key - Pointer to the shared DH key - LITTLE ENDIAN +*x-coordinate of (privKeyB - pubKeyA) */ +sample_status_t sample_ecc256_compute_shared_dhkey(sample_ec256_private_t *p_private_b, + sample_ec256_public_t *p_public_ga, + sample_ec256_dh_shared_t *p_shared_key, + sample_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private_b == NULL) || (p_public_ga == NULL) || (p_shared_key == NULL)) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + + IppsBigNumState* BN_dh_privB = NULL; + IppsBigNumState* BN_dh_share = NULL; + IppsBigNumState* pubA_gx = NULL; + IppsBigNumState* pubA_gy = NULL; + IppsECCPPointState* point_pubA = NULL; + IppStatus ipp_ret = ippStsNoErr; + int ecPointSize = 0; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + IppECResult ipp_result = ippECValid; + + do + { + ipp_ret = sgx_ipp_newBN((Ipp32u*)p_private_b->r, sizeof(sample_ec256_private_t), &BN_dh_privB); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((uint32_t*)p_public_ga->gx, sizeof(p_public_ga->gx), &pubA_gx); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((uint32_t*)p_public_ga->gy, sizeof(p_public_ga->gy), &pubA_gy); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPPointGetSize(256, &ecPointSize); + ERROR_BREAK(ipp_ret); + point_pubA = (IppsECCPPointState*)( malloc(ecPointSize) ); + if(!point_pubA) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, point_pubA); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPSetPoint(pubA_gx, pubA_gy, point_pubA, p_ecc_state); + ERROR_BREAK(ipp_ret); + + // Check to see if the point is a valid point on the Elliptic curve and is not infinity + ipp_ret = ippsECCPCheckPoint(point_pubA, &ipp_result, p_ecc_state); + if (ipp_result != ippECValid) + { + break; + } + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, sizeof(sample_ec256_dh_shared_t), &BN_dh_share); + ERROR_BREAK(ipp_ret); + /* This API generates shareA = x-coordinate of (privKeyB - pubKeyA) */ + ipp_ret = ippsECCPSharedSecretDH(BN_dh_privB, point_pubA, BN_dh_share, p_ecc_state); + ERROR_BREAK(ipp_ret); + IppsBigNumSGN sgn = IppsBigNumPOS; + int length = 0; + Ipp32u * pdata = NULL; + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_share); + ERROR_BREAK(ipp_ret); + memset(p_shared_key->s, 0, sizeof(p_shared_key->s)); + ipp_ret = check_copy_size(sizeof(p_shared_key->s), ROUND_TO(length, 8)/8); + ERROR_BREAK(ipp_ret); + memcpy(p_shared_key->s, pdata, ROUND_TO(length, 8)/8); + }while(0); + + // Clear temp buffer before free. + if(point_pubA) + memset_s(point_pubA, ecPointSize, 0, ecPointSize); + SAFE_FREE(point_pubA); + sample_ipp_secure_free_BN(pubA_gx, sizeof(p_public_ga->gx)); + sample_ipp_secure_free_BN(pubA_gy, sizeof(p_public_ga->gy)); + sample_ipp_secure_free_BN(BN_dh_privB, sizeof(sample_ec256_private_t)); + sample_ipp_secure_free_BN(BN_dh_share, sizeof(sample_ec256_dh_shared_t)); + + + if (ipp_result != ippECValid) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + switch (ipp_ret) + { + case ippStsNoErr: return SAMPLE_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SAMPLE_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } +} + + +const uint32_t sample_nistp256_r[] = { + 0xFC632551, 0xF3B9CAC2, 0xA7179E84, 0xBCE6FAAD, 0xFFFFFFFF, 0xFFFFFFFF, + 0x00000000, 0xFFFFFFFF}; + +#include + +/* Computes signature for data based on private key +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS, SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sample_ec256_private_t *p_private - Pointer to the private key - LITTLE ENDIAN +* sample_uint8_t *p_data - Pointer to the data to be signed +* uint32_t data_size - Size of the data to be signed +* Output: sample_ec256_signature_t *p_signature - Pointer to the signature - LITTLE ENDIAN */ +sample_status_t sample_ecdsa_sign(const uint8_t *p_data, + uint32_t data_size, + sample_ec256_private_t *p_private, + sample_ec256_signature_t *p_signature, + sample_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private == NULL) || (p_signature == NULL) || (p_data == NULL) || (data_size < 1)) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + + IppStatus ipp_ret = ippStsNoErr; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + IppsBigNumState* p_ecp_order = NULL; + IppsBigNumState* p_hash_bn = NULL; + IppsBigNumState* p_msg_bn = NULL; + IppsBigNumState* p_eph_priv_bn = NULL; + IppsECCPPointState* p_eph_pub = NULL; + IppsBigNumState* p_reg_priv_bn = NULL; + IppsBigNumState* p_signx_bn = NULL; + IppsBigNumState* p_signy_bn = NULL; + Ipp32u *p_sigx = NULL; + Ipp32u *p_sigy = NULL; + int ecp_size = 0; + const int order_size = sizeof(sample_nistp256_r); + uint32_t hash[8] = {0}; + + do + { + + ipp_ret = sgx_ipp_newBN(sample_nistp256_r, order_size, &p_ecp_order); + ERROR_BREAK(ipp_ret); + + // Prepare the message used to sign. + ipp_ret = ippsHashMessage(p_data, data_size, (Ipp8u*)hash, IPP_ALG_HASH_SHA256); + ERROR_BREAK(ipp_ret); + /* Byte swap in creation of Big Number from SHA256 hash output */ + ipp_ret = sgx_ipp_newBN(NULL, sizeof(hash), &p_hash_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsSetOctString_BN((Ipp8u*)hash, sizeof(hash), p_hash_bn); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_msg_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsMod_BN(p_hash_bn, p_ecp_order, p_msg_bn); + ERROR_BREAK(ipp_ret); + + // Get ephemeral key pair. + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_eph_priv_bn); + ERROR_BREAK(ipp_ret); + //init eccp point + ipp_ret = ippsECCPPointGetSize(256, &ecp_size); + ERROR_BREAK(ipp_ret); + p_eph_pub = (IppsECCPPointState*)(malloc(ecp_size)); + if(!p_eph_pub) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, p_eph_pub); + ERROR_BREAK(ipp_ret); + // generate ephemeral key pair for signing operation + ipp_ret = ippsECCPGenKeyPair(p_eph_priv_bn, p_eph_pub, p_ecc_state, + (IppBitSupplier)sample_ipp_DRNGen, NULL); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPSetKeyPair(p_eph_priv_bn, p_eph_pub, ippFalse, p_ecc_state); + ERROR_BREAK(ipp_ret); + + // Set the regular private key. + ipp_ret = sgx_ipp_newBN((uint32_t *)p_private->r, sizeof(p_private->r), + &p_reg_priv_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_signx_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_signy_bn); + ERROR_BREAK(ipp_ret); + + // Sign the message. + ipp_ret = ippsECCPSignDSA(p_msg_bn, p_reg_priv_bn, p_signx_bn, p_signy_bn, + p_ecc_state); + ERROR_BREAK(ipp_ret); + + IppsBigNumSGN sign; + int length; + ipp_ret = ippsRef_BN(&sign, &length,(Ipp32u**) &p_sigx, p_signx_bn); + ERROR_BREAK(ipp_ret); + memset(p_signature->x, 0, sizeof(p_signature->x)); + ipp_ret = check_copy_size(sizeof(p_signature->x), ROUND_TO(length, 8)/8); + ERROR_BREAK(ipp_ret); + memcpy(p_signature->x, p_sigx, ROUND_TO(length, 8)/8); + memset_s(p_sigx, sizeof(p_signature->x), 0, ROUND_TO(length, 8)/8); + ipp_ret = ippsRef_BN(&sign, &length,(Ipp32u**) &p_sigy, p_signy_bn); + ERROR_BREAK(ipp_ret); + memset(p_signature->y, 0, sizeof(p_signature->y)); + ipp_ret = check_copy_size(sizeof(p_signature->y), ROUND_TO(length, 8)/8); + ERROR_BREAK(ipp_ret); + memcpy(p_signature->y, p_sigy, ROUND_TO(length, 8)/8); + memset_s(p_sigy, sizeof(p_signature->y), 0, ROUND_TO(length, 8)/8); + + }while(0); + + // Clear buffer before free. + if(p_eph_pub) + memset_s(p_eph_pub, ecp_size, 0, ecp_size); + SAFE_FREE(p_eph_pub); + sample_ipp_secure_free_BN(p_ecp_order, order_size); + sample_ipp_secure_free_BN(p_hash_bn, sizeof(hash)); + sample_ipp_secure_free_BN(p_msg_bn, order_size); + sample_ipp_secure_free_BN(p_eph_priv_bn, order_size); + sample_ipp_secure_free_BN(p_reg_priv_bn, sizeof(p_private->r)); + sample_ipp_secure_free_BN(p_signx_bn, order_size); + sample_ipp_secure_free_BN(p_signy_bn, order_size); + + switch (ipp_ret) + { + case ippStsNoErr: return SAMPLE_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SAMPLE_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } +} + +/* Allocates and initializes sha256 state +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Output: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state */ +sample_status_t sample_sha256_init(sample_sha_state_handle_t* p_sha_handle) +{ + IppStatus ipp_ret = ippStsNoErr; + IppsHashState* p_temp_state = NULL; + + if (p_sha_handle == NULL) + return SAMPLE_ERROR_INVALID_PARAMETER; + + int ctx_size = 0; + ipp_ret = ippsHashGetSize(&ctx_size); + if (ipp_ret != ippStsNoErr) + return SAMPLE_ERROR_UNEXPECTED; + p_temp_state = (IppsHashState*)(malloc(ctx_size)); + if (p_temp_state == NULL) + return SAMPLE_ERROR_OUT_OF_MEMORY; + ipp_ret = ippsHashInit(p_temp_state, IPP_ALG_HASH_SHA256); + if (ipp_ret != ippStsNoErr) + { + SAFE_FREE(p_temp_state); + *p_sha_handle = NULL; + switch (ipp_ret) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } + } + + *p_sha_handle = p_temp_state; + return SAMPLE_SUCCESS; +} + +/* Updates sha256 has calculation based on the input message +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Input: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state +* uint8_t *p_src - Pointer to the input stream to be hashed +* uint32_t src_len - Length of the input stream to be hashed */ +sample_status_t sample_sha256_update(const uint8_t *p_src, uint32_t src_len, sample_sha_state_handle_t sha_handle) +{ + if ((p_src == NULL) || (sha_handle == NULL)) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + IppStatus ipp_ret = ippStsNoErr; + ipp_ret = ippsHashUpdate(p_src, src_len, (IppsHashState*)sha_handle); + switch (ipp_ret) + { + case ippStsNoErr: return SAMPLE_SUCCESS; + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } +} + +/* Returns Hash calculation +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Input: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state +* Output: sample_sha256_hash_t *p_hash - Resultant hash from operation */ +sample_status_t sample_sha256_get_hash(sample_sha_state_handle_t sha_handle, sample_sha256_hash_t *p_hash) +{ + if ((sha_handle == NULL) || (p_hash == NULL)) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + IppStatus ipp_ret = ippStsNoErr; + ipp_ret = ippsHashGetTag((Ipp8u*)p_hash, SAMPLE_SHA256_HASH_SIZE, (IppsHashState*)sha_handle); + switch (ipp_ret) + { + case ippStsNoErr: return SAMPLE_SUCCESS; + case ippStsNullPtrErr: + case ippStsLengthErr: return SAMPLE_ERROR_INVALID_PARAMETER; + default: return SAMPLE_ERROR_UNEXPECTED; + } +} + +/* Cleans up sha state +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Input: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state */ +sample_status_t sample_sha256_close(sample_sha_state_handle_t sha_handle) +{ + if (sha_handle == NULL) + { + return SAMPLE_ERROR_INVALID_PARAMETER; + } + SAFE_FREE(sha_handle); + return SAMPLE_SUCCESS; +} + + diff --git a/sdk/sample_libcrypto/sample_libcrypto.h b/sdk/sample_libcrypto/sample_libcrypto.h new file mode 100644 index 0000000000..bd907cf9b9 --- /dev/null +++ b/sdk/sample_libcrypto/sample_libcrypto.h @@ -0,0 +1,238 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** +* File: sample_libcrypto.h +* Description: +* Interface for generic crypto library APIs. This library does NOT have +* production quality crypto implementations. +* Some methods have been constructed to facilitate reproduceable results to +* aid in the debugging of the sample application. +*/ + +#ifndef SAMPLE_LIBCRYPTO_H +#define SAMPLE_LIBCRYPTO_H + +#include + +typedef enum sample_status_t +{ + SAMPLE_SUCCESS = 0, + + SAMPLE_ERROR_UNEXPECTED , // Unexpected error + SAMPLE_ERROR_INVALID_PARAMETER , // The parameter is incorrect + SAMPLE_ERROR_OUT_OF_MEMORY , // Not enough memory is available to complete this operation + +} sample_status_t; + +#define SAMPLE_SHA256_HASH_SIZE 32 +#define SAMPLE_ECP256_KEY_SIZE 32 +#define SAMPLE_NISTP_ECP256_KEY_SIZE (SAMPLE_ECP256_KEY_SIZE/sizeof(uint32_t)) +#define SAMPLE_AESGCM_IV_SIZE 12 +#define SAMPLE_AESGCM_KEY_SIZE 16 +#define SAMPLE_AESGCM_MAC_SIZE 16 +#define SAMPLE_CMAC_KEY_SIZE 16 +#define SAMPLE_CMAC_MAC_SIZE 16 +#define SAMPLE_AESCTR_KEY_SIZE 16 + +typedef struct sample_ec256_dh_shared_t +{ + uint8_t s[SAMPLE_ECP256_KEY_SIZE]; +} sample_ec256_dh_shared_t; + +typedef struct sample_ec256_private_t +{ + uint8_t r[SAMPLE_ECP256_KEY_SIZE]; +} sample_ec256_private_t; + +typedef struct sample_ec256_public_t +{ + uint8_t gx[SAMPLE_ECP256_KEY_SIZE]; + uint8_t gy[SAMPLE_ECP256_KEY_SIZE]; +} sample_ec256_public_t; + +typedef struct sample_ec256_signature_t +{ + uint32_t x[SAMPLE_NISTP_ECP256_KEY_SIZE]; + uint32_t y[SAMPLE_NISTP_ECP256_KEY_SIZE]; +} sample_ec256_signature_t; + +typedef void* sample_sha_state_handle_t; +typedef void* sample_cmac_state_handle_t; +typedef void* sample_ecc_state_handle_t; + +typedef uint8_t sample_sha256_hash_t[SAMPLE_SHA256_HASH_SIZE]; + +typedef uint8_t sample_aes_gcm_128bit_key_t[SAMPLE_AESGCM_KEY_SIZE]; +typedef uint8_t sample_aes_gcm_128bit_tag_t[SAMPLE_AESGCM_MAC_SIZE]; +typedef uint8_t sample_cmac_128bit_key_t[SAMPLE_CMAC_KEY_SIZE]; +typedef uint8_t sample_cmac_128bit_tag_t[SAMPLE_CMAC_MAC_SIZE]; +typedef uint8_t sample_aes_ctr_128bit_key_t[SAMPLE_AESCTR_KEY_SIZE]; + +#ifdef __cplusplus + #define EXTERN_C extern "C" +#else + #define EXTERN_C +#endif + + #define SAMPLE_LIBCRYPTO_API EXTERN_C + +/* Rijndael AES-GCM +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_aes_gcm_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be encrypted/decrypted +* uint32_t src_len - Length of input stream to be encrypted/decrypted +* uint8_t *p_iv - Pointer to initialization vector to use +* uint32_t iv_len - Length of initialization vector +* uint8_t *p_aad - Pointer to input stream of additional authentication data +* uint32_t aad_len - Length of additional authentication data stream +* sample_aes_gcm_128bit_tag_t *p_in_mac - Pointer to expected MAC in decryption process +* Output: uint8_t *p_dst - Pointer to cipher text. Size of buffer should be >= src_len. +* sample_aes_gcm_128bit_tag_t *p_out_mac - Pointer to MAC generated from encryption process +* NOTE: Wrapper is responsible for confirming decryption tag matches encryption tag */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_rijndael128GCM_encrypt(const sample_aes_gcm_128bit_key_t *p_key, const uint8_t *p_src, uint32_t src_len, + uint8_t *p_dst, const uint8_t *p_iv, uint32_t iv_len, const uint8_t *p_aad, uint32_t aad_len, + sample_aes_gcm_128bit_tag_t *p_out_mac); + +/* Message Authentication - Rijndael 128 CMAC +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_cmac_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be MAC +* uint32_t src_len - Length of input stream to be MAC +* Output: sample_cmac_gcm_128bit_tag_t *p_mac - Pointer to resultant MAC */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_rijndael128_cmac_msg(const sample_cmac_128bit_key_t *p_key, const uint8_t *p_src, + uint32_t src_len, sample_cmac_128bit_tag_t *p_mac); + + + +/* +* Elliptic Curve Crytpography - Based on GF(p), 256 bit +*/ +/* Allocates and initializes ecc context +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS or failure as defined SAMPLE_Error.h. +* Output: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_ecc256_open_context(sample_ecc_state_handle_t* ecc_handle); + +/* Cleans up ecc context +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS or failure as defined SAMPLE_Error.h. +* Output: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_ecc256_close_context(sample_ecc_state_handle_t ecc_handle); + +/* Populates private/public key pair - caller code allocates memory +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* Outputs: sample_ec256_private_t *p_private - Pointer to the private key +* sample_ec256_public_t *p_public - Pointer to the public key */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_ecc256_create_key_pair(sample_ec256_private_t *p_private, + sample_ec256_public_t *p_public, + sample_ecc_state_handle_t ecc_handle); + +/* Computes DH shared key based on private B key (local) and remote public Ga Key +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Inputs: sample_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sample_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN +* sample_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN +* Output: sample_ec256_dh_shared_t *p_shared_key - Pointer to the shared DH key - LITTLE ENDIAN +x-coordinate of (privKeyB - pubKeyA) */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_ecc256_compute_shared_dhkey(sample_ec256_private_t *p_private_b, + sample_ec256_public_t *p_public_ga, + sample_ec256_dh_shared_t *p_shared_key, + sample_ecc_state_handle_t ecc_handle); + + +/* Computes signature for data based on private key +* +* A message digest is a fixed size number derived from the original message with +* an applied hash function over the binary code of the message. (SHA256 in this case) +* The signer's private key and the message digest are used to create a signature. +* +* A digital signature over a message consists of a pair of large numbers, 256-bits each, +* which the given function computes. +* +* The scheme used for computing a digital signature is of the ECDSA scheme, +* an elliptic curve of the DSA scheme. +* +* The keys can be generated and set up by the function: sgx_ecc256_create_key_pair. +* +* The elliptic curve domain parameters must be created by function: +* sample_ecc256_open_context +* +* Return: If context, private key, signature or data pointer is NULL, +* SAMPLE_ERROR_INVALID_PARAMETER is returned. +* If the signature creation process fails then SAMPLE_ERROR_UNEXPECTED is returned. +* +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS, success, error code otherwise. +* Inputs: sample_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system +* sample_ec256_private_t *p_private - Pointer to the private key - LITTLE ENDIAN +* uint8_t *p_data - Pointer to the data to be signed +* uint32_t data_size - Size of the data to be signed +* Output: ec256_signature_t *p_signature - Pointer to the signature - LITTLE ENDIAN */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_ecdsa_sign(const uint8_t *p_data, + uint32_t data_size, + sample_ec256_private_t *p_private, + sample_ec256_signature_t *p_signature, + sample_ecc_state_handle_t ecc_handle); + +/* Allocates and initializes sha256 state +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Output: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_sha256_init(sample_sha_state_handle_t* p_sha_handle); + +/* Updates sha256 has calculation based on the input message +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS or failure. +* Input: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state +* uint8_t *p_src - Pointer to the input stream to be hashed +* uint32_t src_len - Length of the input stream to be hashed */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_sha256_update(const uint8_t *p_src, uint32_t src_len, sample_sha_state_handle_t sha_handle); + +/* Returns Hash calculation +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Input: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state +* Output: sample_sha256_hash_t *p_hash - Resultant hash from operation */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_sha256_get_hash(sample_sha_state_handle_t sha_handle, sample_sha256_hash_t *p_hash); + +/* Cleans up sha state +* Parameters: +* Return: sample_status_t - SAMPLE_SUCCESS on success, error code otherwise. +* Input: sample_sha_state_handle_t sha_handle - Handle to the SHA256 state */ +SAMPLE_LIBCRYPTO_API sample_status_t sample_sha256_close(sample_sha_state_handle_t sha_handle); + +#endif diff --git a/sdk/sample_libcrypto/sample_libcrypto.lds b/sdk/sample_libcrypto/sample_libcrypto.lds new file mode 100644 index 0000000000..87ca100760 --- /dev/null +++ b/sdk/sample_libcrypto/sample_libcrypto.lds @@ -0,0 +1,23 @@ +/*** +* See http://sourceware.org/binutils/docs/ld/VERSION.html#VERSION for more info. +* // Comments don't work in this file. +***/ + +{ +global: + sample_ecc256_close_context; + sample_ecc256_compute_shared_dhkey; + sample_ecc256_create_key_pair; + sample_ecc256_open_context; + sample_ecdsa_sign; + sample_rijndael128GCM_encrypt; + sample_rijndael128_cmac_msg; + sample_sha256_close; + sample_sha256_get_hash; + sample_sha256_init; + sample_sha256_update; + +local: + *; +}; + diff --git a/sdk/selib/linux/Makefile b/sdk/selib/linux/Makefile new file mode 100644 index 0000000000..49aa5dbbc7 --- /dev/null +++ b/sdk/selib/linux/Makefile @@ -0,0 +1,61 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-rtti -fno-exceptions + +CPPLAGS += -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal/ \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(LINUX_SDK_DIR)/selib + + +SRC := $(wildcard ../*.cpp) +OBJS := $(SRC:.cpp=.o) + +LIBSELIB := libselib.a + +.PHONY: all +all: $(LIBSELIB) + +$(LIBSELIB): $(OBJS) + $(AR) rcsD $@ $^ + +$(OBJS): %.o:%.cpp + $(CXX) -c $(CXXFLAGS) $(CPPLAGS) $< -o $@ + +.PHONY: clean +clean: + @$(RM) $(OBJS) $(LIBSELIB) + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/selib/sgx_create_report.cpp b/sdk/selib/sgx_create_report.cpp new file mode 100644 index 0000000000..6d4e9e9f97 --- /dev/null +++ b/sdk/selib/sgx_create_report.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: sgx_create_report.cpp + * Description: + * Wrapper for EREPORT instruction + */ + +#include "sgx_utils.h" +#include "util.h" +#include +#include +#include "se_memcpy.h" +#include "sgx_trts.h" +#include "trts_inst.h" +#include "se_cdefs.h" + +// add a version to tservice. +SGX_ACCESS_VERSION(tservice, 1) + +sgx_status_t sgx_create_report(const sgx_target_info_t *target_info, const sgx_report_data_t *report_data, sgx_report_t *report) +{ + int i = 0; + // check parameters + // + // target_info is allowed to be NULL, but if it is not NULL, it must be within the enclave + if(target_info) + { + if (!sgx_is_within_enclave(target_info, sizeof(*target_info))) + return SGX_ERROR_INVALID_PARAMETER; + + for(i=0; ireserved1[i] != 0) + return SGX_ERROR_INVALID_PARAMETER; + } + + for(i=0; ireserved2[i] != 0) + return SGX_ERROR_INVALID_PARAMETER; + } + } + // report_data is allowed to be NULL, but if it is not NULL, it must be within the enclave + if(report_data && !sgx_is_within_enclave(report_data, sizeof(*report_data))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // report must be within the enclave + if(!report || !sgx_is_within_enclave(report, sizeof(*report))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // allocate memory + // + // To minimize the effort of memory management, the three elements allocation + // are combined in a single malloc. The calculation for the required size has + // an assumption, that + // the elements should be allocated in descending order of the alignment size. + // + // If the alignment requirements are changed, the allocation order needs to + // change accordingly. + // + // Current allocation order is: + // report -> target_info -> report_data + // + // target_info: 512-byte aligned, 512-byte length + // report_data: 128-byte aligned, 64-byte length + // report: 512-byte aligned, 432-byte length + // + size_t size = ROUND_TO(sizeof(sgx_target_info_t), TARGET_INFO_ALIGN_SIZE) + + ROUND_TO(sizeof(sgx_report_data_t), REPORT_DATA_ALIGN_SIZE) + + ROUND_TO(sizeof(sgx_report_t), REPORT_ALIGN_SIZE); + size += MAX(MAX(TARGET_INFO_ALIGN_SIZE, REPORT_DATA_ALIGN_SIZE), REPORT_ALIGN_SIZE) - 1; + + void *buffer = malloc(size); + if(buffer == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(buffer, 0, size); + size_t buf_ptr = reinterpret_cast(buffer); + + buf_ptr = ROUND_TO(buf_ptr, REPORT_ALIGN_SIZE); + sgx_report_t *tmp_report = reinterpret_cast(buf_ptr); + buf_ptr += sizeof(*tmp_report); + + buf_ptr = ROUND_TO(buf_ptr, TARGET_INFO_ALIGN_SIZE); + sgx_target_info_t *tmp_target_info = reinterpret_cast(buf_ptr); + buf_ptr += sizeof(*tmp_target_info); + + buf_ptr = ROUND_TO(buf_ptr, REPORT_DATA_ALIGN_SIZE); + sgx_report_data_t *tmp_report_data = reinterpret_cast(buf_ptr); + + // Copy data from user buffer to the aligned memory + if(target_info) + { + memcpy_s(tmp_target_info, sizeof(*tmp_target_info), target_info, sizeof(*target_info)); + } + if(report_data) + { + memcpy_s(tmp_report_data, sizeof(*tmp_report_data), report_data, sizeof(*report_data)); + } + + // Do EREPORT + do_ereport(tmp_target_info, tmp_report_data, tmp_report); + + // Copy data to the user buffer + memcpy_s(report, sizeof(*report), tmp_report, sizeof(*tmp_report)); + + // cleanup + memset_s(buffer, size, 0, size); + free(buffer); + + return SGX_SUCCESS; +} + + + diff --git a/sdk/selib/sgx_get_key.cpp b/sdk/selib/sgx_get_key.cpp new file mode 100644 index 0000000000..f1c8d8d5ab --- /dev/null +++ b/sdk/selib/sgx_get_key.cpp @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: sgx_get_key.cpp + * Description: + * Wrapper for EGETKEY instruction + */ + +#include "sgx_utils.h" +#include "util.h" +#include +#include +#include "se_memcpy.h" +#include "trts_inst.h" +#include "sgx_trts.h" +#include "se_cdefs.h" + +// add a version to tservice. +SGX_ACCESS_VERSION(tservice, 2) + +sgx_status_t sgx_get_key(const sgx_key_request_t *key_request, sgx_key_128bit_t *key) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + void *buffer = NULL; + size_t size = 0, buf_ptr =0; + sgx_key_request_t *tmp_key_request = NULL; + sgx_key_128bit_t *tmp_key = NULL; + egetkey_status_t egetkey_status = EGETKEY_SUCCESS; + int i = 0; + + // check parameters + // + // key_request must be within the enclave + if(!key_request || !sgx_is_within_enclave(key_request, sizeof(*key_request))) + { + err = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + + if (key_request->reserved1 != 0) + { + err = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + + for (i=0; ireserved2[i] != 0) + { + err = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + } + + // key must be within the enclave + if(!key || !sgx_is_within_enclave(key, sizeof(*key))) + { + err = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + // check key_request->key_policy reserved bits + if(key_request->key_policy & ~(SGX_KEYPOLICY_MRENCLAVE | SGX_KEYPOLICY_MRSIGNER)) + { + err = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + + // allocate memory + // + // To minimize the effort of memory management, the two elements allocation + // are combined in a single malloc. The calculation for the required size has + // an assumption, that + // the elements should be allocated in descending order of the alignment size. + // + // If the alignment requirements are changed, the allocation order needs to + // change accordingly. + // + // Current allocation order is: + // key_request -> key + // + // key_request: 512-byte aligned, 512-byte length + // key: 16-byte aligned, 16-byte length + size = ROUND_TO(sizeof(*key_request), KEY_REQUEST_ALIGN_SIZE) + ROUND_TO(sizeof(*key), KEY_ALIGN_SIZE); + size += MAX(KEY_REQUEST_ALIGN_SIZE, KEY_ALIGN_SIZE) - 1; + + buffer = malloc(size); + if(buffer == NULL) + { + err = SGX_ERROR_OUT_OF_MEMORY; + goto CLEANUP; + } + memset(buffer, 0, size); + buf_ptr = reinterpret_cast(buffer); + + buf_ptr = ROUND_TO(buf_ptr, KEY_REQUEST_ALIGN_SIZE); + tmp_key_request = reinterpret_cast(buf_ptr); + buf_ptr += sizeof(*tmp_key_request); + + buf_ptr = ROUND_TO(buf_ptr, KEY_ALIGN_SIZE); + tmp_key = reinterpret_cast(buf_ptr); + + // Copy data from user buffer to the aligned memory + memcpy_s(tmp_key_request, sizeof(*tmp_key_request), key_request, sizeof(*key_request)); + + // Do EGETKEY + egetkey_status = (egetkey_status_t) do_egetkey(tmp_key_request, tmp_key); + switch(egetkey_status) + { + case EGETKEY_SUCCESS: + err = SGX_SUCCESS; + break; + case EGETKEY_INVALID_ATTRIBUTE: + err = SGX_ERROR_INVALID_ATTRIBUTE; + break; + case EGETKEY_INVALID_CPUSVN: + err = SGX_ERROR_INVALID_CPUSVN; + break; + case EGETKEY_INVALID_ISVSVN: + err = SGX_ERROR_INVALID_ISVSVN; + break; + case EGETKEY_INVALID_KEYNAME: + err = SGX_ERROR_INVALID_KEYNAME; + break; + default: + err = SGX_ERROR_UNEXPECTED; + break; + } + + +CLEANUP: + if((SGX_SUCCESS != err) && (NULL != key)) + { + // The key buffer should be filled with random number. + // If sgx_read_rand returns failure, let the key buffer untouched + sgx_read_rand(reinterpret_cast(key), sizeof(*key)); + } + else if(NULL != key) + { + // Copy data to the user buffer + memcpy_s(key, sizeof(*key), tmp_key, sizeof(*tmp_key)); + } + + // cleanup + if(buffer) + { + memset_s(buffer, size, 0, size); + free(buffer); + } + + return err; +} diff --git a/sdk/selib/sgx_verify_report.cpp b/sdk/selib/sgx_verify_report.cpp new file mode 100644 index 0000000000..1828d8a7ae --- /dev/null +++ b/sdk/selib/sgx_verify_report.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: sgx_verify_report.cpp + * Description: + * API for report verification + */ + +#include "sgx_utils.h" +#include "util.h" +#include +#include +#include "se_memcpy.h" +#include "sgx_trts.h" +#include "sgx_tcrypto.h" +#include "se_cdefs.h" + +// add a version to tservice. +SGX_ACCESS_VERSION(tservice, 3) + +sgx_status_t sgx_verify_report(const sgx_report_t *report) +{ + sgx_mac_t mac; + sgx_key_request_t key_request; + sgx_key_128bit_t key; + sgx_status_t err = SGX_ERROR_UNEXPECTED; + //check parameter + if(!report||!sgx_is_within_enclave(report, sizeof(*report))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + memset(&mac, 0, sizeof(sgx_mac_t)); + memset(&key_request, 0, sizeof(sgx_key_request_t)); + memset(&key, 0, sizeof(sgx_key_128bit_t)); + + //prepare the key_request + key_request.key_name = SGX_KEYSELECT_REPORT; + memcpy_s(&key_request.key_id, sizeof(key_request.key_id), &report->key_id, sizeof(report->key_id)); + + //get the report key + // Since the key_request is not an input parameter by caller, + // we suppose sgx_get_key would never return the following error code: + // SGX_ERROR_INVALID_PARAMETER + // SGX_ERROR_INVALID_ATTRIBUTE + // SGX_ERROR_INVALID_CPUSVN + // SGX_ERROR_INVALID_ISVSVN + // SGX_ERROR_INVALID_KEYNAME + err = sgx_get_key(&key_request, &key); + if(err != SGX_SUCCESS) + { + return err; // err must be SGX_ERROR_OUT_OF_MEMORY or SGX_ERROR_UNEXPECTED + } + //get the report mac + err = sgx_rijndael128_cmac_msg((sgx_cmac_128bit_key_t*)&key, (const uint8_t *)(&report->body), sizeof(sgx_report_body_t), &mac); + memset_s (&key, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + if (SGX_SUCCESS != err) + { + if(err != SGX_ERROR_OUT_OF_MEMORY) + err = SGX_ERROR_UNEXPECTED; + return err; + } + if(consttime_memequal(mac, report->mac, sizeof(sgx_mac_t)) == 0) + { + return SGX_ERROR_MAC_MISMATCH; + } + else + { + return SGX_SUCCESS; + } +} diff --git a/sdk/selib/tservice_version.cpp b/sdk/selib/tservice_version.cpp new file mode 100644 index 0000000000..643c51902e --- /dev/null +++ b/sdk/selib/tservice_version.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_TSERVICE_VERSION_STR __CONCAT("SGX_TSERVICE_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_tservice_version = SGX_TSERVICE_VERSION_STR; + +#ifdef __cplusplus +} +#endif diff --git a/sdk/sign_tool/SignTool/Makefile b/sdk/sign_tool/SignTool/Makefile new file mode 100644 index 0000000000..5797756cb0 --- /dev/null +++ b/sdk/sign_tool/SignTool/Makefile @@ -0,0 +1,109 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +CXXFLAGS += -Werror +CFLAGS += -Werror + +CXXFLAGS += $(ADDED_INC) +CPPFLAGS += -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc/internal/linux/ \ + -I$(LINUX_PSW_DIR)/urts \ + -I$(LINUX_PSW_DIR)/urts/linux \ + -I$(LINUX_EXTERNAL_DIR)/tinyxml \ + -I$(LINUX_EXTERNAL_DIR)/crypto_px/include \ + -I$(LINUX_PSW_DIR)/urts/parser + +IPP_LIBS := -lcrypto_px +IPP_PATH := -L$(LINUX_EXTERNAL_DIR)/crypto_px + +DIR1 := $(LINUX_EXTERNAL_DIR)/tinyxml/ +DIR2 := $(COMMON_DIR)/src/ +DIR3 := $(LINUX_PSW_DIR)/urts/ +DIR4 := $(LINUX_PSW_DIR)/urts/linux +DIR5 := $(LINUX_PSW_DIR)/urts/parser +DIR6 := $(LINUX_PSW_DIR)/psw/urts/parser/linux + +OBJ1 := manage_metadata.o \ + enclave_creator_sign.o \ + sign_tool.o \ + parse_key_file.o \ + util_st.o + +OBJ2 := ipp_bn.o ipp_rsa_key.o ipp_rsa_pub_key.o sgx_memset_s.o + +OBJ3 := tinystr.o \ + tinyxml.o \ + tinyxmlerror.o \ + tinyxmlparser.o + +OBJ4 := loader.o \ + se_detect.o + +CPP_OBJS := $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) +C_OBJS := se_trace.o se_map.o +OBJS := $(CPP_OBJS) $(C_OBJS) + +vpath %.cpp $(DIR1):$(DIR2):$(DIR3):$(DIR4):$(DIR5):$(DIR6) + +.PHONY: all +all: sgx_sign | $(BUILD_DIR) + @$(CP) $< $| + +$(BUILD_DIR): + @$(MKDIR) $@ + +sgx_sign: PRIVATE_LDLIBS := $(IPP_LIBS) -lpthread -lenclaveparser +sgx_sign: PRIVATE_LDFLAGS := $(IPP_PATH) -L$(LINUX_PSW_DIR)/urts/parser +sgx_sign: $(OBJS) enclaveparser libcrypto_px + $(CXX) $(CXXFLAGS) $(OBJS) $(PRIVATE_LDFLAGS) $(PRIVATE_LDLIBS) -o $@ + +$(CPP_OBJS): %.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + +$(C_OBJS): %.o: $(DIR2)%.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + $(RM) *~ *.o sgx_sign $(BUILD_DIR)/sgx_sign + $(MAKE) -C $(LINUX_PSW_DIR)/urts/parser/ clean + $(MAKE) -C $(LINUX_EXTERNAL_DIR)/crypto_px/ clean + +.PHONY: enclaveparser +enclaveparser: + $(MAKE) -C $(LINUX_PSW_DIR)/urts/parser/ + +.PHONY: libcrypto_px +libcrypto_px: + $(MAKE) -C $(LINUX_EXTERNAL_DIR)/crypto_px/ diff --git a/sdk/sign_tool/SignTool/README.txt b/sdk/sign_tool/SignTool/README.txt new file mode 100644 index 0000000000..8007090bdf --- /dev/null +++ b/sdk/sign_tool/SignTool/README.txt @@ -0,0 +1,27 @@ +The sgx_sign generates the enclave signature and meta-data, and inserts the +information into the enclave file. +Meanwhile, the sgx_sign checks the enclave compatibility and provides the detail +information to users. + +Usage: + sgx_sign [options] file... + Commands: + sign Sign the enclave using the private key. + gendata Generate enclave signing material to be signed. + catsig Generate the signed enclave with the input signature + file, the public key and the enclave signing material. + Options: + -enclave Specify the enclave file to be signed. + It is a required option for the listed sgx_sign commands. + -key Specify the key file. + It is a required option for the sign and catsig commands. + -config Specify the configuration for the enclave. + -out Specify the output file. + It is a required option for the listed sgx_sign commands. + -sig Specify the signature file for the enclave signing + material. + It is a required option for the catsig command. + -unsigned Specify the enclave signing material generated by the + gendata command. + It is a required option for the catsig command. + diff --git a/sdk/sign_tool/SignTool/elf_helper.h b/sdk/sign_tool/SignTool/elf_helper.h new file mode 100644 index 0000000000..0f3bc05aef --- /dev/null +++ b/sdk/sign_tool/SignTool/elf_helper.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ELF_HELPER_H_ +#define _ELF_HELPER_H_ + +#include +#include + +#include "elf32parser.h" +#include "elf64parser.h" + +static void dump_textrel(const uint64_t& offset) +{ + using namespace std; + + cerr << "warning: TEXTRELs found at offset: " + << hex << showbase /* show the '0x' prefix */ + << offset << endl; +} + +template +struct ParserType +{ +}; + +template <> +struct ParserType<32> +{ + typedef Elf32Parser elf_parser_t; + typedef Elf32_Rel elf_rel_t; +}; + +template <> +struct ParserType<64> +{ + typedef Elf64Parser elf_parser_t; + typedef Elf64_Rela elf_rel_t; +}; + +template +class ElfHelper +{ + typedef typename ParserType::elf_parser_t elf_parser_t; + typedef typename ParserType::elf_rel_t elf_rel_t; + +public: + +#define get_rel_entry_addr(p, rel_entry_offset) \ + ((elf_rel_t *)const_cast(p->get_start_addr() + rel_entry_offset)) + + static uint64_t get_r_offset_from_entry(const elf_parser_t* p, + uint64_t offsets) + { + const elf_rel_t *rel = get_rel_entry_addr(p, offsets); + return (uint64_t)rel->r_offset; + } + + static void dump_textrels(BinParser *bp) + { + vector offsets; + + /* The dynamic_cast<> shouldn't fail. */ + elf_parser_t * p = dynamic_cast(bp); + if (p == NULL) + return; + + /* Warn user of TEXTRELs */ + p->get_reloc_entry_offset(".text", offsets); + for (size_t idx = 0; idx < offsets.size(); ++idx) + { + dump_textrel(get_r_offset_from_entry(p, offsets[idx])); + } + } +}; + +#endif diff --git a/sdk/sign_tool/SignTool/enclave_creator_sign.cpp b/sdk/sign_tool/SignTool/enclave_creator_sign.cpp new file mode 100644 index 0000000000..ebd6ac3fb7 --- /dev/null +++ b/sdk/sign_tool/SignTool/enclave_creator_sign.cpp @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** +* File: +* enclave_creator_sign.cpp +* Description: +* Measure the necessary information of the enclave +* to calculate the HASH value using SHA256 algorithm. +*/ + +#include "enclave_creator.h" +#include "sgx_eid.h" +#include "enclave_creator_sign.h" +#include "ipp_wrapper.h" +#include "se_trace.h" +#include "sgx_error.h" +#include "util_st.h" +#include "util.h" +#include "se_page_attr.h" + +#include +#include +#include + +#define DATA_BLOCK_SIZE 64 +#define EID 0x44444444 + +EnclaveCreatorST::EnclaveCreatorST() +{ + m_hash_valid_flag = false; + memset(m_enclave_hash, 0, SGX_HASH_SIZE); + m_ctx = NULL; + m_eid = EID; +} + +EnclaveCreatorST::~EnclaveCreatorST() +{ + SAFE_FREE_MM(m_ctx); +} + +int EnclaveCreatorST::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae) +{ + if(!secs || !enclave_id || !start_addr) + { + se_trace(SE_TRACE_DEBUG, "ERROR: Bad pointer.\n"); + return SGX_ERROR_UNEXPECTED; + } + + UNUSED(ae); + + memset(m_enclave_hash, 0, SGX_HASH_SIZE); + int size_in_byte = 0; + IppStatus error_code = ippsHashGetSize(&size_in_byte); + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashGetSize() failed in the enclave measurement process.\n"); + return SGX_ERROR_UNEXPECTED; + } + m_ctx = (IppsHashState *)malloc(size_in_byte); + if(m_ctx == NULL) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); + return SGX_ERROR_OUT_OF_MEMORY; + } + error_code = ippsHashInit(m_ctx, IPP_ALG_HASH_SHA256); + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashInit() failed in the enclave measurement process.\n"); + return SGX_ERROR_UNEXPECTED; + } + uint8_t ecreat_val[SIZE_NAMED_VALUE] = "ECREATE"; + + uint8_t data_block[DATA_BLOCK_SIZE]; + size_t offset = 0; + memset(data_block, 0, DATA_BLOCK_SIZE); + memcpy_s(data_block, sizeof(data_block), ecreat_val, SIZE_NAMED_VALUE); + offset += SIZE_NAMED_VALUE; + memcpy_s(&data_block[offset], sizeof(data_block)-offset, &secs->ssa_frame_size, sizeof(secs->ssa_frame_size)); + offset += sizeof(secs->ssa_frame_size); + memcpy_s(&data_block[offset], sizeof(data_block)-offset, &secs->size, sizeof(secs->size)); + error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashUpdate() failed in the enclave measurement(ECREATE) process.\n"); + return SGX_ERROR_UNEXPECTED; + } + + *enclave_id = m_eid; + *start_addr = secs->base; + return SGX_SUCCESS; +} + +int EnclaveCreatorST::add_enclave_page(sgx_enclave_id_t enclave_id, void *src, uint64_t offset, const sec_info_t &sinfo, uint32_t attr) +{ + assert(m_ctx!=NULL); + UNUSED(enclave_id); + void* source = src; + uint8_t color_page[SE_PAGE_SIZE]; + if(!source) + { + memset(color_page, 0, SE_PAGE_SIZE); + source = reinterpret_cast(&color_page); + } + + for(unsigned int i = 0; i< sizeof(sinfo.reserved)/sizeof(sinfo.reserved[0]); i++) + { + if(sinfo.reserved[i] != 0) + return SGX_ERROR_UNEXPECTED; + } + /* sinfo.flags[64:16] should be 0 */ + if((sinfo.flags & (~SI_FLAGS_EXTERNAL)) != 0) + { + return SGX_ERROR_UNEXPECTED; + } + + /* Check the page attributes: must be ADD only or ADD+EXTEND */ + if (!(attr & (ADD_PAGE_ONLY)) || (attr & (~(ADD_EXTEND_PAGE)))) + { + return SGX_ERROR_UNEXPECTED; + } + + uint64_t page_offset = (uint64_t)offset; + uint8_t eadd_val[SIZE_NAMED_VALUE] = "EADD\0\0\0"; + + uint8_t data_block[DATA_BLOCK_SIZE]; + size_t db_offset = 0; + memset(data_block, 0, DATA_BLOCK_SIZE); + memcpy_s(data_block, sizeof(data_block), eadd_val, SIZE_NAMED_VALUE); + db_offset += SIZE_NAMED_VALUE; + memcpy_s(data_block+db_offset, sizeof(data_block)-db_offset, &page_offset, sizeof(page_offset)); + db_offset += sizeof(page_offset); + memcpy_s(data_block+db_offset, sizeof(data_block)-db_offset, &sinfo, sizeof(data_block)-db_offset); + IppStatus error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ERROR::ippsHashUpdate() failed in the enclave measurement(EADD) process.\n"); + return SGX_ERROR_UNEXPECTED; + } + + /* If the page need to eextend, do eextend. */ + if((attr & ADD_EXTEND_PAGE) == ADD_EXTEND_PAGE) + { + uint8_t *pdata = (uint8_t *)source; + uint8_t eextend_val[SIZE_NAMED_VALUE] = "EEXTEND"; + +#define EEXTEND_TIME 4 + for(int i = 0; i < SE_PAGE_SIZE; i += (DATA_BLOCK_SIZE * EEXTEND_TIME)) + { + db_offset = 0; + memset(data_block, 0, DATA_BLOCK_SIZE); + memcpy_s(data_block, sizeof(data_block), eextend_val, SIZE_NAMED_VALUE); + db_offset += SIZE_NAMED_VALUE; + memcpy_s(data_block+db_offset, sizeof(data_block)-db_offset, &page_offset, sizeof(page_offset)); + + error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashUpdate() failed in the enclave measurement(EEXTEND) process.\n"); + return SGX_ERROR_UNEXPECTED; + } + + for(int j = 0; j < EEXTEND_TIME; j++) + { + memcpy_s(data_block, sizeof(data_block), pdata, DATA_BLOCK_SIZE); + error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashUpdate() failed in the enclave measurement(EEXTEND) process.\n"); + return SGX_ERROR_UNEXPECTED; + } + pdata += DATA_BLOCK_SIZE; + page_offset += DATA_BLOCK_SIZE; + } + } + } + return SGX_SUCCESS; +} + +int EnclaveCreatorST::init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, SGXLaunchToken *lc, le_prd_css_file_t *prd_css_file) +{ + assert(m_ctx != NULL); + UNUSED(enclave_id), UNUSED(enclave_css), UNUSED(lc), UNUSED(prd_css_file); + + uint8_t temp_hash[SGX_HASH_SIZE]; + memset(temp_hash, 0, SGX_HASH_SIZE); + + /* Complete computation of the SHA256 digest and store the result into the hash. */ + IppStatus error_code = ippsHashFinal((Ipp8u *)temp_hash, m_ctx); + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashFinal() failed in the enclave measurement process.\n"); + return SGX_ERROR_UNEXPECTED; + } + + for (int i = 0; i< SGX_HASH_SIZE; i++) + { + m_enclave_hash[i] = temp_hash[i]; + } + m_hash_valid_flag = true; + return SGX_SUCCESS; +} + +int EnclaveCreatorST::get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t flag) +{ + UNUSED(metadata), UNUSED(lc), UNUSED(flag); + memset(sgx_misc_attr, 0, sizeof(sgx_misc_attribute_t)); + return SGX_SUCCESS; +} + +int EnclaveCreatorST::destroy_enclave(sgx_enclave_id_t enclave_id) +{ + UNUSED(enclave_id); + SAFE_FREE_MM(m_ctx); + return SGX_SUCCESS; +} + +bool EnclaveCreatorST::get_plat_cap(sgx_misc_attribute_t *se_attr) +{ + UNUSED(se_attr); + return false; +} + +int EnclaveCreatorST::initialize(sgx_enclave_id_t enclave_id) +{ + UNUSED(enclave_id); + return SGX_SUCCESS; +} + +bool EnclaveCreatorST::use_se_hw() const +{ + return false; +} + +int EnclaveCreatorST::get_enclave_info(uint8_t *hash, int size) +{ + if(hash == NULL || size != SGX_HASH_SIZE || m_hash_valid_flag == false) + { + se_trace(SE_TRACE_DEBUG, "ERROR: something went wrong in the function get_enclave_hash().\n"); + return SGX_ERROR_UNEXPECTED; + } + else + { + memcpy_s(hash, size, m_enclave_hash, SGX_HASH_SIZE); + } + return SGX_SUCCESS; +} + +static EnclaveCreatorST g_enclave_creator_st; +EnclaveCreator* g_enclave_creator = &g_enclave_creator_st; diff --git a/sdk/sign_tool/SignTool/enclave_creator_sign.h b/sdk/sign_tool/SignTool/enclave_creator_sign.h new file mode 100644 index 0000000000..64fe6ea589 --- /dev/null +++ b/sdk/sign_tool/SignTool/enclave_creator_sign.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _ENCLAVE_CREATOR_SIGN_H_ +#define _ENCLAVE_CREATOR_SIGN_H_ + +#include "ippcp.h" + +#include "enclave_creator.h" +#include "sgx_eid.h" + +#define SIZE_NAMED_VALUE 8 + +class EnclaveCreatorST : public EnclaveCreator +{ +public: + EnclaveCreatorST(); + virtual ~EnclaveCreatorST(); + int create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae); + int add_enclave_page(sgx_enclave_id_t enclave_id, void *source, uint64_t offset, const sec_info_t &sinfo, uint32_t attr); + int init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, SGXLaunchToken *lc, le_prd_css_file_t *prd_css_file); + int get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t flag); + bool get_plat_cap(sgx_misc_attribute_t *se_attr); + int destroy_enclave(sgx_enclave_id_t enclave_id); + int initialize(sgx_enclave_id_t enclave_id); + bool use_se_hw() const; + + int get_enclave_info(uint8_t *hash, int size); + +private: + uint8_t m_enclave_hash[SGX_HASH_SIZE]; + IppsHashState *m_ctx; + bool m_hash_valid_flag; + sgx_enclave_id_t m_eid; +}; + +#endif diff --git a/sdk/sign_tool/SignTool/manage_metadata.cpp b/sdk/sign_tool/SignTool/manage_metadata.cpp new file mode 100644 index 0000000000..7ae747d4af --- /dev/null +++ b/sdk/sign_tool/SignTool/manage_metadata.cpp @@ -0,0 +1,662 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** +* File: +* manage_metadata.cpp +* Description: +* Parse the xml file to get the metadata and generate the output DLL +* with metadata. +*/ + +#include "metadata.h" +#include "tinyxml.h" +#include "manage_metadata.h" +#include "se_trace.h" +#include "util_st.h" +#include "section.h" +#include "se_page_attr.h" +#include "elf_util.h" + +#include +#include +#include +#include +#include + + +#define ALIGN_SIZE 0x1000 + +static bool traverser_parameter(const char *temp_name, const char *temp_text, xml_parameter_t *parameter, int parameter_count) +{ + assert(temp_name != NULL && parameter != NULL); + uint32_t temp_value=0; + if(temp_text == NULL) + { + se_trace(SE_TRACE_ERROR, LACK_VALUE_FOR_ELEMENT_ERROR, temp_name); + return false; + } + else + { + if(strchr(temp_text, '-')) + { + se_trace(SE_TRACE_ERROR, INVALID_VALUE_FOR_ELEMENT_ERROR, temp_name); + return false; + } + + errno = 0; + char* endptr = NULL; + temp_value = (uint32_t)strtoul(temp_text, &endptr, 0); + if(*endptr!='\0'||errno!=0) //Invalid value or valid value but out of the representable range + { + se_trace(SE_TRACE_ERROR, INVALID_VALUE_FOR_ELEMENT_ERROR, temp_name); + return false; + } + } + + //Look for the matched one + int i=0; + for(;i=parameter_count) //no matched, return false + { + se_trace(SE_TRACE_ERROR, UNREC_ELEMENT_ERROR, temp_name); + return false; + } + //found one matched + if(parameter[i].flag==1) //repeated definition of XML element, return false + { + se_trace(SE_TRACE_ERROR, REPEATED_DEFINE_ERROR, temp_name); + return false; + } + parameter[i].flag = 1; + if((temp_valueparameter[i].max_value)) // the value is invalid, return false + { + se_trace(SE_TRACE_ERROR, VALUE_OUT_OF_RANGE_ERROR, temp_name); + return false; + } + parameter[i].value = temp_value; + return true; +} + +bool parse_metadata_file(const char *xmlpath, xml_parameter_t *parameter, int parameter_count) +{ + const char* temp_name=NULL; + + assert(parameter != NULL); + if(xmlpath == NULL) // user didn't define the metadata xml file. + { + se_trace(SE_TRACE_NOTICE, "Use default metadata...\n"); + return true; + } + //use the metadata file that user gives us. parse xml file + TiXmlDocument doc(xmlpath); + bool loadOkay = doc.LoadFile(); + if(!loadOkay) + { + if(doc.ErrorId() == TiXmlBase::TIXML_ERROR_OPENING_FILE) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, xmlpath); + } + else + { + se_trace(SE_TRACE_ERROR, XML_FORMAT_ERROR); + } + return false; + } + doc.Print();//Write the document to standard out using formatted printing ("pretty print"). + + TiXmlNode *pmetadata_node = doc.FirstChild("EnclaveConfiguration"); + if(!pmetadata_node) + { + se_trace(SE_TRACE_ERROR, XML_FORMAT_ERROR); + return false; + } + TiXmlNode *sub_node = NULL; + sub_node = pmetadata_node->FirstChild(); + const char *temp_text = NULL; + + while(sub_node)//parse xml node + { + switch(sub_node->Type()) + { + case TiXmlNode::TINYXML_ELEMENT: + if(sub_node->ToElement()->FirstAttribute() != NULL) + { + se_trace(SE_TRACE_ERROR, XML_FORMAT_ERROR); + return false; + } + + temp_name = sub_node->ToElement()->Value(); + temp_text = sub_node->ToElement()->GetText(); + + //traverse every node. Compare with the default value. + if(traverser_parameter(temp_name, temp_text, parameter, parameter_count) == false) + { + se_trace(SE_TRACE_ERROR, XML_FORMAT_ERROR); + return false; + } + break; + case TiXmlNode::TINYXML_DECLARATION: + case TiXmlNode::TINYXML_COMMENT: + break; + + default: + se_trace(SE_TRACE_ERROR, XML_FORMAT_ERROR); + return false; + } + sub_node=pmetadata_node->IterateChildren(sub_node); + } + + return true; +} + +CMetadata::CMetadata(metadata_t *metadata, BinParser *parser) + : m_metadata(metadata) + , m_parser(parser) +{ + memset(m_metadata, 0, sizeof(metadata_t)); + memset(&m_create_param, 0, sizeof(m_create_param)); +} +CMetadata::~CMetadata() +{ +} +bool CMetadata::build_metadata(const xml_parameter_t *parameter) +{ + if(!modify_metadata(parameter)) + { + return false; + } + // layout table + if(!build_layout_table()) + { + return false; + } + // patch table + if(!build_patch_table()) + { + return false; + } + return true; +} +bool CMetadata::modify_metadata(const xml_parameter_t *parameter) +{ + assert(parameter != NULL); + m_metadata->version = META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ); + m_metadata->size = offsetof(metadata_t, data); + m_metadata->tcs_policy = parameter[TCSPOLICY].value; + m_metadata->ssa_frame_size = SSA_FRAME_SIZE; + //stack/heap must be page-align + if(parameter[STACKMAXSIZE].value % ALIGN_SIZE) + { + se_trace(SE_TRACE_ERROR, SET_STACK_SIZE_ERROR); + return false; + } + if(parameter[HEAPMAXSIZE].value % ALIGN_SIZE) + { + se_trace(SE_TRACE_ERROR, SET_HEAP_SIZE_ERROR); + return false; + } + // LE setting: HW != 0, Licensekey = 1 + // Other enclave setting: HW = 0, Licensekey = 0 + if((parameter[HW].value == 0 && parameter[LAUNCHKEY].value != 0) || + (parameter[HW].value != 0 && parameter[LAUNCHKEY].value == 0)) + { + se_trace(SE_TRACE_ERROR, SET_HW_LE_ERROR); + return false; + } + + m_metadata->max_save_buffer_size = MAX_SAVE_BUF_SIZE; + m_metadata->magic_num = METADATA_MAGIC; + m_metadata->desired_misc_select = 0; + m_metadata->enclave_css.body.misc_select = parameter[MISCSELECT].value; + m_metadata->enclave_css.body.misc_mask = parameter[MISCMASK].value; + + m_create_param.heap_max_size = parameter[HEAPMAXSIZE].value; + m_create_param.ssa_frame_size = SSA_FRAME_SIZE; + m_create_param.stack_max_size = parameter[STACKMAXSIZE].value; + m_create_param.tcs_max_num = parameter[TCSNUM].value; + m_create_param.tcs_policy = m_metadata->tcs_policy; + return true; +} + +void *CMetadata::alloc_buffer_from_metadata(uint32_t size) +{ + void *addr = GET_PTR(void, m_metadata, m_metadata->size); + m_metadata->size += size; + if((m_metadata->size < size) || (m_metadata->size > METADATA_SIZE)) + { + return NULL; + } + return addr; +} + +bool CMetadata::build_layout_entries(vector &layouts) +{ + uint32_t size = (uint32_t)(layouts.size() * sizeof(layout_t)); + layout_t *layout_table = (layout_t *) alloc_buffer_from_metadata(size); + if(layout_table == NULL) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + m_metadata->dirs[DIR_LAYOUT].offset = (uint32_t)PTR_DIFF(layout_table, m_metadata); + m_metadata->dirs[DIR_LAYOUT].size = size; + + uint64_t rva = calculate_sections_size(); + for(uint32_t i = 0; i < layouts.size(); i++) + { + memcpy_s(layout_table, sizeof(layout_t), &layouts[i], sizeof(layout_t)); + + if(!IS_GROUP_ID(layouts[i].entry.id)) + { + layout_table->entry.rva = rva; + rva += (uint64_t)(layouts[i].entry.page_count << SE_PAGE_SHIFT); + } + else + { + for (uint32_t j = 0; j < layouts[i].group.entry_count; j++) + { + layout_table->group.load_step += layouts[i-j-1].entry.page_count << SE_PAGE_SHIFT; + } + rva += layouts[i].group.load_times * layout_table->group.load_step; + } + layout_table++; + } + // enclave virtual size + m_metadata->enclave_size = calculate_enclave_size(rva); + if(m_metadata->enclave_size == (uint64_t)-1) + { + se_trace(SE_TRACE_ERROR, OUT_OF_EPC_ERROR); + return false; + } + // the last guard page entry to round the enclave size to power of 2 + if(m_metadata->enclave_size - rva > 0) + { + layout_table = (layout_t *)alloc_buffer_from_metadata(sizeof(layout_t)); + if(layout_table == NULL) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + layout_table->entry.id = LAYOUT_ID_GUARD; + layout_table->entry.rva = rva; + layout_table->entry.page_count = (uint32_t)((m_metadata->enclave_size - rva) >> SE_PAGE_SHIFT); + m_metadata->dirs[DIR_LAYOUT].size += (uint32_t)sizeof(layout_t); + } + return true; +} + +bool CMetadata::build_layout_table() +{ + vector layouts; + layout_t layout; + memset(&layout, 0, sizeof(layout)); + + layout_t guard_page; + memset(&guard_page, 0, sizeof(guard_page)); + guard_page.entry.id = LAYOUT_ID_GUARD; + guard_page.entry.page_count = SE_GUARD_PAGE_SIZE >> SE_PAGE_SHIFT; + + // heap + layout.entry.id = LAYOUT_ID_HEAP; + layout.entry.page_count = (uint32_t)(m_create_param.heap_max_size >> SE_PAGE_SHIFT); + layout.entry.attributes = ADD_PAGE_ONLY; + layout.entry.si_flags = SI_FLAGS_RW; + layouts.push_back(layout); + + // thread context memory layout + // guard page | stack | TCS | SSA | guard page | TLS + + // guard page + layouts.push_back(guard_page); + + // stack + layout.entry.id = LAYOUT_ID_STACK; + layout.entry.page_count = (uint32_t)(m_create_param.stack_max_size >> SE_PAGE_SHIFT); + layout.entry.attributes = ADD_EXTEND_PAGE; + layout.entry.si_flags = SI_FLAGS_RW; + layout.entry.content_size = 0xCCCCCCCC; + layouts.push_back(layout); + + // guard page + layouts.push_back(guard_page); + + // tcs + layout.entry.id = LAYOUT_ID_TCS; + layout.entry.page_count = TCS_SIZE >> SE_PAGE_SHIFT; + layout.entry.attributes = ADD_EXTEND_PAGE; + layout.entry.si_flags = SI_FLAGS_TCS; + tcs_t *tcs_template = (tcs_t *) alloc_buffer_from_metadata(TCS_TEMPLATE_SIZE); + if(tcs_template == NULL) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + layout.entry.content_offset = (uint32_t)PTR_DIFF(tcs_template, m_metadata), + layout.entry.content_size = TCS_TEMPLATE_SIZE; + layouts.push_back(layout); + memset(&layout, 0, sizeof(layout)); + + // ssa + layout.entry.id = LAYOUT_ID_SSA; + layout.entry.page_count = SSA_FRAME_SIZE * SSA_NUM; + layout.entry.attributes = ADD_EXTEND_PAGE; + layout.entry.si_flags = SI_FLAGS_RW; + layouts.push_back(layout); + + // guard page + layouts.push_back(guard_page); + + // td + layout.entry.id = LAYOUT_ID_TD; + layout.entry.page_count = 1; + const Section *section = m_parser->get_tls_section(); + if(section) + { + layout.entry.page_count += (uint32_t)(ROUND_TO_PAGE(section->virtual_size()) >> SE_PAGE_SHIFT); + } + layout.entry.attributes = ADD_EXTEND_PAGE; + layout.entry.si_flags = SI_FLAGS_RW; + layouts.push_back(layout); + + // group for thread context + if (m_create_param.tcs_max_num > 1) + { + memset(&layout, 0, sizeof(layout)); + layout.group.id = LAYOUT_ID_THREAD_GROUP; + layout.group.entry_count = (uint16_t) (layouts.size() - 1); + layout.group.load_times = m_create_param.tcs_max_num-1; + layouts.push_back(layout); + } + // build layout table + if(false == build_layout_entries(layouts)) + { + return false; + } + + // tcs template + if(false == build_tcs_template(tcs_template)) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + return true; +} +bool CMetadata::build_patch_entries(vector &patches) +{ + uint32_t size = (uint32_t)(patches.size() * sizeof(patch_entry_t)); + patch_entry_t *patch_table = (patch_entry_t *) alloc_buffer_from_metadata(size); + if(patch_table == NULL) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + m_metadata->dirs[DIR_PATCH].offset = (uint32_t)PTR_DIFF(patch_table, m_metadata); + m_metadata->dirs[DIR_PATCH].size = size; + + for(uint32_t i = 0; i < patches.size(); i++) + { + memcpy_s(patch_table, sizeof(patch_entry_t), &patches[i], sizeof(patch_entry_t)); + patch_table++; + } + return true; +} +bool CMetadata::build_patch_table() +{ + const uint8_t *base_addr = (const uint8_t *)m_parser->get_start_addr(); + vector patches; + patch_entry_t patch; + memset(&patch, 0, sizeof(patch)); + + // td template + uint8_t buf[200]; + uint32_t size = 200; + memset(buf, 0, size); + if(false == build_gd_template(buf, &size)) + { + return false; + } + uint8_t *gd_template = (uint8_t *)alloc_buffer_from_metadata(size); + if(gd_template == NULL) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + memcpy_s(gd_template, size, buf, size); + + uint64_t rva = m_parser->get_symbol_rva("g_global_data"); + if(0 == rva) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + + patch.dst = (uint64_t)PTR_DIFF(get_rawdata_by_rva(rva), base_addr); + patch.src = (uint32_t)PTR_DIFF(gd_template, m_metadata); + patch.size = size; + patches.push_back(patch); + + // patch the image header + uint64_t *zero = (uint64_t *)alloc_buffer_from_metadata(sizeof(*zero)); + if(zero == NULL) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + *zero = 0; + bin_fmt_t bf = m_parser->get_bin_format(); + if(bf == BF_ELF32) + { + Elf32_Ehdr *elf_hdr = (Elf32_Ehdr *)base_addr; + patch.dst = (uint64_t)PTR_DIFF(&elf_hdr->e_shnum, base_addr); + patch.src = (uint32_t)PTR_DIFF(zero, m_metadata); + patch.size = (uint32_t)sizeof(elf_hdr->e_shnum); + patches.push_back(patch); + + patch.dst = (uint64_t)PTR_DIFF(&elf_hdr->e_shoff, base_addr); + patch.src = (uint32_t)PTR_DIFF(zero, m_metadata); + patch.size = (uint32_t)sizeof(elf_hdr->e_shoff); + patches.push_back(patch); + + patch.dst = (uint64_t)PTR_DIFF(&elf_hdr->e_shstrndx, base_addr); + patch.src = (uint32_t)PTR_DIFF(zero, m_metadata); + patch.size = (uint32_t)sizeof(elf_hdr->e_shstrndx); + patches.push_back(patch); + + // Modify GNU_RELRO info to eliminate the impact of enclave measurement. + Elf32_Phdr *prg_hdr = GET_PTR(Elf32_Phdr, base_addr, elf_hdr->e_phoff); + for (unsigned idx = 0; idx < elf_hdr->e_phnum; ++idx, ++prg_hdr) + { + if(prg_hdr->p_type == PT_GNU_RELRO) + { + patch.dst = (uint64_t)PTR_DIFF(prg_hdr, base_addr); + patch.src = (uint32_t)PTR_DIFF(zero, m_metadata); + patch.size = (uint32_t)sizeof(Elf32_Phdr); + patches.push_back(patch); + break; + } + } + } + else if(bf == BF_ELF64) + { + Elf64_Ehdr *elf_hdr = (Elf64_Ehdr *)base_addr; + + patch.dst = (uint64_t)PTR_DIFF(&elf_hdr->e_shnum, base_addr); + patch.src = (uint32_t)PTR_DIFF(zero, m_metadata); + patch.size = (uint32_t)sizeof(elf_hdr->e_shnum); + patches.push_back(patch); + + patch.dst = (uint64_t)PTR_DIFF(&elf_hdr->e_shoff, base_addr); + patch.src = (uint32_t)PTR_DIFF(zero, m_metadata); + patch.size = (uint32_t)sizeof(elf_hdr->e_shoff); + patches.push_back(patch); + + patch.dst = (uint64_t)PTR_DIFF(&elf_hdr->e_shstrndx, base_addr); + patch.src = (uint32_t)PTR_DIFF(zero, m_metadata); + patch.size = (uint32_t)sizeof(elf_hdr->e_shstrndx); + patches.push_back(patch); + } + if(false == build_patch_entries(patches)) + { + return false; + } + return true; +} +layout_entry_t *CMetadata::get_entry_by_id(uint16_t id) +{ + layout_entry_t *layout_start = GET_PTR(layout_entry_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset); + layout_entry_t *layout_end = GET_PTR(layout_entry_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset + m_metadata->dirs[DIR_LAYOUT].size); + for (layout_entry_t *layout = layout_start; layout < layout_end; layout++) + { + if(layout->id == id) + return layout; + } + assert(false); + return NULL; +} +bool CMetadata::build_gd_template(uint8_t *data, uint32_t *data_size) +{ + m_create_param.stack_limit_addr = get_entry_by_id(LAYOUT_ID_STACK)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva; + m_create_param.stack_base_addr = (get_entry_by_id(LAYOUT_ID_STACK)->page_count << SE_PAGE_SHIFT) + m_create_param.stack_limit_addr; + m_create_param.first_ssa_gpr = get_entry_by_id(LAYOUT_ID_SSA)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva + + SSA_FRAME_SIZE * SE_PAGE_SIZE - (uint64_t)sizeof(ssa_gpr_t); + m_create_param.enclave_size = m_metadata->enclave_size; + m_create_param.heap_offset = get_entry_by_id(LAYOUT_ID_HEAP)->rva; + + uint64_t tmp_tls_addr = get_entry_by_id(LAYOUT_ID_TD)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva; + m_create_param.td_addr = tmp_tls_addr + ((get_entry_by_id(LAYOUT_ID_TD)->page_count - 1) << SE_PAGE_SHIFT); + + const Section *section = m_parser->get_tls_section(); + if(section) + { + /* adjust the tls_addr to be the pointer to the actual TLS data area */ + m_create_param.tls_addr = m_create_param.td_addr - section->virtual_size(); + assert(TRIM_TO_PAGE(m_create_param.tls_addr) == tmp_tls_addr); + } + else + m_create_param.tls_addr = tmp_tls_addr; + + if(false == m_parser->update_global_data(&m_create_param, data, data_size)) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); // metadata structure doesnot have enough memory for global_data template + return false; + } + return true; +} + +bool CMetadata::build_tcs_template(tcs_t *tcs) +{ + tcs->oentry = m_parser->get_symbol_rva("enclave_entry"); + if(tcs->oentry == 0) + { + return false; + } + tcs->nssa = SSA_NUM; + tcs->cssa = 0; + tcs->ossa = get_entry_by_id(LAYOUT_ID_SSA)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva; + //fs/gs pointer at TLS/TD + tcs->ofs_base = tcs->ogs_base = get_entry_by_id(LAYOUT_ID_TD)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva + (uint64_t)((get_entry_by_id(LAYOUT_ID_TD)->page_count - 1) << SE_PAGE_SHIFT); + tcs->ofs_limit = tcs->ogs_limit = (uint32_t)-1; + return true; +} + +void* CMetadata::get_rawdata_by_rva(uint64_t rva) +{ + std::vector sections = m_parser->get_sections(); + + for(unsigned int i = 0; i < sections.size() ; i++) + { + uint64_t start_rva = TRIM_TO_PAGE(sections[i]->get_rva()); + uint64_t end_rva = ROUND_TO_PAGE(sections[i]->get_rva() + sections[i]->virtual_size()); + if(start_rva <= rva && rva < end_rva) + { + uint64_t offset = rva - sections[i]->get_rva(); + if (offset > sections[i]->raw_data_size()) + { + return 0; + } + return GET_PTR(void, sections[i]->raw_data(), offset); + } + } + + return 0; +} + +uint64_t CMetadata::calculate_sections_size() +{ + std::vector sections = m_parser->get_sections(); + uint64_t max_rva = 0; + Section *last_section = NULL; + + for(unsigned int i = 0; i < sections.size() ; i++) + { + if(sections[i]->get_rva() > max_rva) { + max_rva = sections[i]->get_rva(); + last_section = sections[i]; + } + } + + uint64_t size = (NULL == last_section) ? (0) : (last_section->get_rva() + last_section->virtual_size()); + size = ROUND_TO_PAGE(size); + + return size; +} + +uint64_t CMetadata::calculate_enclave_size(uint64_t size) +{ + uint64_t enclave_max_size = m_parser->get_enclave_max_size(); + + if(size > enclave_max_size) + return (uint64_t)-1; + + uint64_t round_size = 1; + while (round_size < size) + { + round_size <<=1; + if(!round_size) + return (uint64_t)-1; + } + + if(round_size > enclave_max_size) + return (uint64_t)-1; + + return round_size; +} + +bool update_metadata(const char *path, const metadata_t *metadata, uint64_t meta_offset) +{ + assert(path != NULL && metadata != NULL); + + return write_data_to_file(path, std::ios::in | std::ios::binary| std::ios::out, + reinterpret_cast(const_cast( metadata)), metadata->size, (long)meta_offset); +} + diff --git a/sdk/sign_tool/SignTool/manage_metadata.h b/sdk/sign_tool/SignTool/manage_metadata.h new file mode 100644 index 0000000000..b6033fd0a7 --- /dev/null +++ b/sdk/sign_tool/SignTool/manage_metadata.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _MANAGE_METADATA_H_ +#define _MANAGE_METADATA_H_ + +#include "metadata.h" +#include "uncopyable.h" +#include "loader.h" +#include "binparser.h" + +#define MAX_BUFFER_SIZE 4096 +#define TCS_TEMPLATE_SIZE 72 + +#define STRCMP strcmp +#define STRNCMP strncmp + +#define SSA_NUM 2 +#define SSA_FRAME_SIZE 1 + +typedef enum _para_type_t +{ + PRODID = 0, + ISVSVN, + RELEASETYPE, + INTELSIGNED, + PROVISIONKEY, + LAUNCHKEY, + DISABLEDEBUG, + HW, + TCSNUM, + TCSPOLICY, + STACKMAXSIZE, + HEAPMAXSIZE, + MISCSELECT, + MISCMASK +} para_type_t; + +typedef struct _xml_parameter_t +{ + const char* name; //the element name + uint32_t max_value; + uint32_t min_value; + uint32_t value; //parameter value. Initialized with the default value. + uint32_t flag; //Show whether it has been matched +} xml_parameter_t; + + +bool parse_metadata_file(const char *xmlpath, xml_parameter_t *parameter, int parameter_count); +bool update_metadata(const char *path, const metadata_t *metadata, uint64_t meta_offset); + +class CMetadata: private Uncopyable +{ +public: + CMetadata(metadata_t *metadata, BinParser *parser); + ~CMetadata(); + bool build_metadata(const xml_parameter_t *parameter); +private: + bool modify_metadata(const xml_parameter_t *parameter); + void *alloc_buffer_from_metadata(uint32_t size); + bool build_layout_table(); + bool build_patch_table(); + bool build_layout_entries(vector &layouts); + bool build_patch_entries(vector &patches); + + layout_entry_t *get_entry_by_id(uint16_t id); + bool build_tcs_template(tcs_t *tcs); + bool build_gd_template(uint8_t *data, uint32_t *data_size); + + uint64_t calculate_sections_size(); + uint64_t calculate_enclave_size(uint64_t size); + void* get_rawdata_by_rva(uint64_t rva); + + metadata_t *m_metadata; + BinParser *m_parser; + create_param_t m_create_param; +}; +#endif diff --git a/sdk/sign_tool/SignTool/parse_key_file.cpp b/sdk/sign_tool/SignTool/parse_key_file.cpp new file mode 100644 index 0000000000..bc8aa45f0b --- /dev/null +++ b/sdk/sign_tool/SignTool/parse_key_file.cpp @@ -0,0 +1,517 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** +* File: +* parse_key_file.cpp +* Description: +* Parse the RSA key file that user inputs +* to get the key type and rsa structure. +*/ + +#include "parse_key_file.h" +#include "se_trace.h" +#include "arch.h" +#include "util_st.h" + +#include +#include +#include +#include + +#include +#include +#include + + +//N_SIZE+E_SIZE+D_SIZE+P_SIZE+Q_SIZE+DMP1_SIZE+DMQ1_SIZE+sizeof(inverseQ) +#define PRI_COMPONENTS_SIZE (N_SIZE_IN_BYTES + E_SIZE_IN_BYTES + D_SIZE_IN_BYTES + P_SIZE_IN_BYTES *5) +#define PUB_CONPONENTS_SIZE (N_SIZE_IN_BYTES + E_SIZE_IN_BYTES) //N_SIZE+E_SIZE + + +#define CHECK_RETRUN(value) {if(0 == (value)) return 0;} + + +//base64Decode +// to decode the base64 string and put it to the result. +//Parameters +// [IN] aSrc: the source string coded in base64 +// srcLen: length of the source string +// [OUT] result: point to the decoded string +//Return Value +// int---The length of the decoded string +static int base64_decode(const unsigned char* aSrc, size_t srcLen, unsigned char* result) +{ + static char index_64[256] = { + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, + 64, 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, 64, 64, 64, 64, 64, + 64, 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, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 + }; + + CHECK_RETRUN(aSrc); + CHECK_RETRUN(srcLen); + CHECK_RETRUN(result); + + + unsigned char ch1 = 0, ch2 = 0, ch3 = 0, ch4 = 0; + unsigned char *ptr = result; + + for (unsigned int i = 0; i < srcLen; ++i) + { + ch1 = index_64[aSrc[i]]; + if(ch1 == 64) + continue; + ch2 = index_64[aSrc[++i]]; + if(ch2 == 64) + continue; + *(ptr++) = (unsigned char)(ch1<<2 | ch2>>4); + ch3 = index_64[aSrc[++i]]; + if(aSrc[i] == '=' || ch3 == 64) + continue; + *(ptr++) = (unsigned char)(ch2<<4 | ch3>>2); + ch4 = index_64[aSrc[++i]]; + if(aSrc[i] == '=' || ch4 == 64) + continue; + *(ptr++) = (unsigned char)(ch3<<6 | ch4); + } + return (int)(ptr - result); +} + +static void convert_string(unsigned char *str, int len) +{ + assert(str != NULL&&len>0); + char temp = 0; + for(int i=0; in, sizeof(rsa->n), psrc+index, N_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->n, sizeof(rsa->n)); + + //get EXPONENT + index += N_SIZE_IN_BYTES; + if(!((unsigned int)psrc[index] == 0x02 &&(unsigned int)psrc[index+1] == 0x01)) //"0x01" indicates the size of e is 1 byte + { + se_trace(SE_TRACE_ERROR, "Only '3' is accepted as the Exponent value.\n"); + return false; + } + index += 2; + unsigned int temp = *(psrc+index); + if(temp != 0x03) + { + se_trace(SE_TRACE_ERROR, "Key Exponent is %#x. Only '3' is accepted as the Exponent value.\n", temp); + return false; + } + temp = temp&0x0f; + memcpy_s(rsa->e, sizeof(rsa->e), &temp, sizeof(unsigned int)); + + //get D + index += 1; + if((unsigned int)psrc[index]!=0x02) + { + return false; + } + + index = index+4; + if((int)psrc[index] == 0) + index += 1; + memcpy_s(rsa->d, sizeof(rsa->d), psrc+index, D_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->d, sizeof(rsa->d)); + + //get P + index += D_SIZE_IN_BYTES; + if((unsigned int)psrc[index]!=0x02) + { + return false; + } + index = index+4; + if((int)psrc[index] == 0) + index += 1; + memcpy_s(rsa->p, sizeof(rsa->p), psrc+index, P_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->p, sizeof(rsa->p)); + + //get Q + index += P_SIZE_IN_BYTES; + if((unsigned int)psrc[index]!=0x02) + { + return false; + } + + index = index+4; + if((int)psrc[index] == 0) + index += 1; + memcpy_s(rsa->q, sizeof(rsa->q), psrc+index, Q_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->q, sizeof(rsa->q)); + + //get DMP1 + index += Q_SIZE_IN_BYTES; + if((unsigned int)psrc[index]!=0x02) + { + return false; + } + index += 4; + if((int)psrc[index] == 0) + index += 1; + memcpy_s(rsa->dmp1, sizeof(rsa->dmp1), psrc+index, DMP1_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->dmp1, sizeof(rsa->dmp1)); + + //get DMQ1 + index += DMP1_SIZE_IN_BYTES; + if((unsigned int)psrc[index]!=0x02) + { + return false; + } + index += 4; + if((int)psrc[index] == 0) + index += 1; + memcpy_s(rsa->dmq1, sizeof(rsa->dmq1), psrc+index, DMQ1_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->dmq1, sizeof(rsa->dmq1)); + + //get IQMP + index += DMQ1_SIZE_IN_BYTES; + if((unsigned int)psrc[index]!=0x02) + { + return false; + } + index += 3; + if((int)psrc[index] == 0) + index += 1; + memcpy_s(rsa->iqmp, sizeof(rsa->iqmp), psrc+index, IQMP_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->iqmp, sizeof(rsa->iqmp)); + + return true; +} + +static bool convert_from_pub_key(const unsigned char *psrc, unsigned int slen, rsa_params_t *rsa) +{ + assert(NULL != psrc && NULL != rsa); + if(slenn, sizeof(rsa->n), psrc+index, N_SIZE_IN_BYTES); + convert_string((unsigned char *)rsa->n, sizeof(rsa->n)); + + //get EXPONENT + index += N_SIZE_IN_BYTES; + if(!((unsigned int)psrc[index] == 0x02 &&(unsigned int)psrc[index+1] == 0x01)) //"0x01" indicates the size of e is 1 byte + { + se_trace(SE_TRACE_ERROR, "Only '3' is accepted as the Exponent value.\n"); + return false; + } + index += 2; + unsigned int temp = *(psrc+index); + if(temp != 0x03) + { + se_trace(SE_TRACE_ERROR, "Key Exponent is %#x. Only '3' is accepted as the Exponent value.\n", temp); + return false; + } + temp = temp&0x0f; + memcpy_s(rsa->e, sizeof(rsa->e), &temp, sizeof(unsigned int)); + return true; +} + +static unsigned char* decode_key_body(unsigned char *buffer, size_t slen, int *key_type, int *rlen) +{ + assert(buffer!=NULL && key_type!=NULL && rlen!=NULL); + + const char pri_key_header[] = "-----BEGINRSAPRIVATEKEY-----" ; + const char pri_key_end[] = "-----ENDRSAPRIVATEKEY-----\n"; + const char pub_key_header[] = "-----BEGINPUBLICKEY-----"; + const char pub_key_end[] = "-----ENDPUBLICKEY-----\n"; + + int ktype = UNIDENTIFIABLE_KEY; + int offset_pri = (int)(slen - strlen(pri_key_end)); + int offset_pub = (int)(slen - strlen(pub_key_end)); + + if(offset_pub<=0 || offset_pri<=0) + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + *key_type = UNIDENTIFIABLE_KEY; + return NULL; + } + + //check the file header and footer to get the key type + if(!strncmp((const char *)buffer, pri_key_header, strlen(pri_key_header))) + { + //make sure the key file isn't an emcrypted PEM private key file. + if((!strncmp((const char *)(buffer+offset_pri), pri_key_end, strlen(pri_key_end))) && + !strstr((const char *)buffer, "Proc-Type: 4, ENCRYPTED")) + { + *(buffer+offset_pri-1) = '\0'; //remove the pri_key_end string + ktype = PRIVATE_KEY; + } + else + { + ktype = UNIDENTIFIABLE_KEY; + } + } + else if(!strncmp((const char *)buffer, pub_key_header, strlen(pub_key_header))) + { + if(!strncmp((const char *)(buffer+offset_pub), pub_key_end, strlen(pub_key_end))) + { + *(buffer + offset_pub-1) = '\0'; + ktype = PUBLIC_KEY; + } + else + { + ktype = UNIDENTIFIABLE_KEY; + } + } + else + { + ktype = UNIDENTIFIABLE_KEY; + } + //get the body contents of the key file + size_t body_size = 0, body_offset = 0; + if(ktype == PRIVATE_KEY) + { + body_size = strlen((const char *)buffer) - strlen(pri_key_header); + body_offset = strlen(pri_key_header)+1; + } + else if(ktype == PUBLIC_KEY) + { + body_size = strlen((const char *)buffer) - strlen(pub_key_header); + body_offset = strlen(pub_key_header)+1; + } + else + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + *key_type = ktype; + return NULL; + } + unsigned char *decoded_string = (unsigned char *)malloc(sizeof(char)*body_size); + if(!decoded_string) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); + *key_type = ktype; + return NULL; + } + memset(decoded_string, 0, body_size); + int retlen = base64_decode(buffer+body_offset, body_size, decoded_string); + if(retlen == 0) + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + *key_type = ktype; + free(decoded_string); + return NULL; + } + *key_type = ktype; + *rlen = retlen; + return decoded_string; +} + +//read_key_file +// read the input file line by line and trim the blank characters for each line +//Parameters +// [IN] key_path: the file required to be read +static std::string read_key_file(const char *key_path) +{ + assert(key_path != NULL); + + std::ifstream ifs(key_path, std::ios::in | std::ios::binary); + if(!ifs.good()) + { + se_trace(SE_TRACE_ERROR, READ_FILE_ERROR, key_path); + return ""; + } + std::string file_content; + std::string str; + while(std::getline(ifs, str)) + { + str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end()); + if(str.length() != 0) + { + file_content += str; + file_content += "\n"; // Add '\n' for each line + } + } + ifs.close(); + return file_content; +} + +//parse_key_file(): +// parse the RSA key file +//Parameters: +// [IN] key_path: the key file name user inputs +// [OUT] prsa: the rsa structure parsed from the key file +// pkey_type: the key type +//Return Value: +// true: success +// false: fail +bool parse_key_file(const char *key_path, rsa_params_t *prsa, int *pkey_type) +{ + assert(prsa != NULL && pkey_type != NULL); + + if(key_path == NULL) + { + *pkey_type = NO_KEY; + return false; + } + + //read and trim the file content + std::string file_content = read_key_file(key_path); + if(file_content.empty() == true) + { + *pkey_type = UNIDENTIFIABLE_KEY; + return false; + } + const unsigned char *buffer = (const unsigned char *)file_content.c_str(); + + //decode the buffer to decoded_string + size_t result = strlen((const char *)buffer); + int retlen = 0; + int key_type = UNIDENTIFIABLE_KEY; + unsigned char *decoded_string = decode_key_body(const_cast(buffer), result, &key_type, &retlen); + if(!decoded_string) + { + *pkey_type = key_type; + return false; + } + + //get RSA from the decoded string + bool ret = false; + if(key_type == PRIVATE_KEY) + { + ret = convert_from_pri_key(decoded_string, retlen, prsa); + } + else + { + ret = convert_from_pub_key(decoded_string, retlen, prsa); + } + if(ret == false) + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + free(decoded_string); + *pkey_type = key_type; + return false; + } + else + { + se_trace(SE_TRACE_DEBUG, "Parsing key file is OK.\n"); + } + + *pkey_type = key_type; + free(decoded_string); + return true; +} diff --git a/sdk/sign_tool/SignTool/parse_key_file.h b/sdk/sign_tool/SignTool/parse_key_file.h new file mode 100644 index 0000000000..aca34c204e --- /dev/null +++ b/sdk/sign_tool/SignTool/parse_key_file.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef _PARSE_KEY_FILE_H_ +#define _PARSE_KEY_FILE_H_ + + +#define N_SIZE_IN_BYTES 384 +#define E_SIZE_IN_BYTES 4 +#define D_SIZE_IN_BYTES 384 +#define P_SIZE_IN_BYTES 192 +#define Q_SIZE_IN_BYTES 192 +#define DMP1_SIZE_IN_BYTES 192 +#define DMQ1_SIZE_IN_BYTES 192 +#define IQMP_SIZE_IN_BYTES 192 + +#define N_SIZE_IN_UINT N_SIZE_IN_BYTES/sizeof(unsigned int) +#define E_SIZE_IN_UINT E_SIZE_IN_BYTES/sizeof(unsigned int) +#define D_SIZE_IN_UINT D_SIZE_IN_BYTES/sizeof(unsigned int) +#define P_SIZE_IN_UINT P_SIZE_IN_BYTES/sizeof(unsigned int) +#define Q_SIZE_IN_UINT Q_SIZE_IN_BYTES/sizeof(unsigned int) +#define DMP1_SIZE_IN_UINT DMP1_SIZE_IN_BYTES/sizeof(unsigned int) +#define DMQ1_SIZE_IN_UINT DMQ1_SIZE_IN_BYTES/sizeof(unsigned int) +#define IQMP_SIZE_IN_UINT IQMP_SIZE_IN_BYTES/sizeof(unsigned int) + +typedef enum _key_type_t +{ + UNIDENTIFIABLE_KEY = -1, + NO_KEY = 0, + PRIVATE_KEY, + PUBLIC_KEY +} key_type_t; + +typedef struct _rsa_params_t +{ + unsigned int n[N_SIZE_IN_UINT]; + unsigned int e[E_SIZE_IN_UINT]; + unsigned int d[D_SIZE_IN_UINT]; + unsigned int p[P_SIZE_IN_UINT]; + unsigned int q[Q_SIZE_IN_UINT]; + unsigned int dmp1[DMP1_SIZE_IN_UINT]; + unsigned int dmq1[DMQ1_SIZE_IN_UINT]; + unsigned int iqmp[IQMP_SIZE_IN_UINT]; +}rsa_params_t; + + +bool parse_key_file(const char *key_path, rsa_params_t *prsa, int *pkey_type); + +#endif diff --git a/sdk/sign_tool/SignTool/sign_tool.cpp b/sdk/sign_tool/SignTool/sign_tool.cpp new file mode 100644 index 0000000000..5f6d66e93b --- /dev/null +++ b/sdk/sign_tool/SignTool/sign_tool.cpp @@ -0,0 +1,1177 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// SignTool.cpp : Defines the entry point for the console application. +// + +/** +* File: +* sign_tool.cpp +*Description: +* Defines the entry point for the application. +* +*/ + +#include "ippcp.h" +#include "ippcore.h" + +#include "metadata.h" +#include "manage_metadata.h" +#include "ipp_wrapper.h" +#include "parse_key_file.h" +#include "enclave_creator_sign.h" +#include "util_st.h" + +#include "se_trace.h" +#include "sgx_error.h" + +#include "se_map.h" +#include "loader.h" +#include "parserfactory.h" +#include "elf_helper.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#define SIGNATURE_SIZE 384 + +typedef enum _command_mode_t +{ + SIGN = 0, + GENDATA, + CATSIG, + COMPARE +} command_mode_t; + +typedef enum _file_path_t +{ + DLL = 0, + XML = 1, + KEY, + OUTPUT, + SIG, + UNSIGNED, + REVIEW_ENCLAVE +} file_path_t; + +static bool get_time(uint32_t *date) +{ + assert(date != NULL); + + time_t rawtime = 0; + if(time( &rawtime) == -1) + return false; + struct tm *timeinfo = gmtime(&rawtime); + if(timeinfo == NULL) + return false; + uint32_t tmp_date = (timeinfo->tm_year+1900)*10000 + (timeinfo->tm_mon+1)*100 + timeinfo->tm_mday; + stringstream ss; + ss<<"0x"<>hex>>tmp_date; + *date = tmp_date; + return true; +} + +static int load_enclave(BinParser *parser, metadata_t *metadata) +{ + std::unique_ptr ploader(new CLoader(const_cast(parser->get_start_addr()), *parser)); + return ploader->load_enclave_ex(NULL, 0, metadata, NULL); +} + + +#define THE_INVALID_HANDLE (-1) + +static int open_file(const char* dllpath) +{ + FILE *fp = fopen(dllpath, "rb"); + if (fp == NULL) + return THE_INVALID_HANDLE; + + return fileno(fp); +} + +static void close_handle(int fd) +{ + close(fd); +} + + +static bool get_enclave_info(BinParser *parser, bin_fmt_t *bf, uint64_t * meta_offset) +{ + uint64_t meta_rva = parser->get_metadata_offset(); + const uint8_t *base_addr = parser->get_start_addr(); + metadata_t *metadata = GET_PTR(metadata_t, base_addr, meta_rva); + + if(metadata->magic_num == METADATA_MAGIC) + { + se_trace(SE_TRACE_ERROR, ENCLAVE_ALREADY_SIGNED_ERROR); + return false; + } + + *bf = parser->get_bin_format(); + *meta_offset = meta_rva; + return true; +} + +// measure_enclave(): +// 1. Get the enclave hash by loading enclave +// 2. Get the enclave info - metadata offset and enclave file format +static bool measure_enclave(uint8_t *hash, const char *dllpath, const xml_parameter_t *parameter, metadata_t *metadata, bin_fmt_t *bin_fmt, uint64_t *meta_offset) +{ + assert(hash && dllpath && metadata && bin_fmt && meta_offset); + bool res = false; + uint32_t file_size = 0; + + se_file_handle_t fh = open_file(dllpath); + if (fh == THE_INVALID_HANDLE) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, dllpath); + return false; + } + + // Probably we can use `decltype' if all major supported compilers support that. + std::unique_ptr mh(map_file(fh, &file_size), unmap_file); + if (!mh) + { + close_handle(fh); + return false; + } + // Parse enclave + std::unique_ptr parser(binparser::get_parser(mh->base_addr, (size_t)file_size)); + assert(parser != NULL); + + sgx_status_t status = parser->run_parser(); + if (status != SGX_SUCCESS) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + close_handle(fh); + return false; + } + + // generate metadata + CMetadata meta(metadata, parser.get()); + if(meta.build_metadata(parameter) == false) + { + close_handle(fh); + return false; + } + + // Collect enclave info + if(get_enclave_info(parser.get(), bin_fmt, meta_offset) == false) + { + close_handle(fh); + return false; + } + + if (*bin_fmt == BF_ELF64) + { + ElfHelper<64>::dump_textrels(parser.get()); + } + else if (*bin_fmt == BF_ELF32) + { + ElfHelper<32>::dump_textrels(parser.get()); + } + + // Load enclave to get enclave hash + int ret = load_enclave(parser.release(), metadata); + close_handle(fh); + + switch(ret) + { + case SGX_ERROR_INVALID_METADATA: + se_trace(SE_TRACE_ERROR, OUT_OF_EPC_ERROR); + res = false; + break; + case SGX_ERROR_INVALID_VERSION: + se_trace(SE_TRACE_ERROR, META_VERSION_ERROR); + res = false; + break; + case SGX_ERROR_INVALID_ENCLAVE: + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + res = false; + break; + case SGX_SUCCESS: + ret = dynamic_cast(get_enclave_creator())->get_enclave_info(hash, SGX_HASH_SIZE); + if(ret != SGX_SUCCESS) + { + res = false; + break; + } + res = true; + break; + default: + res = false; + break; + } + + return res; +} + +static void set_meta_attributes(metadata_t *meta) +{ + assert(meta != NULL); + //set metadata.attributes + //low 64 bit: it's the same as enclave_css + memset(&meta->attributes, 0, sizeof(sgx_attributes_t)); + meta->attributes.flags = meta->enclave_css.body.attributes.flags; + //high 64 bit + //set bits that will not be checked + meta->attributes.xfrm = ~meta->enclave_css.body.attribute_mask.xfrm; + //set bits that have been set '1' and need to be checked + meta->attributes.xfrm |= (meta->enclave_css.body.attributes.xfrm & meta->enclave_css.body.attribute_mask.xfrm); + return; +} + +//fill_enclave_css() +// file the enclave_css_t structure with the parameter, enclave_hash +// If the RSA_key is not null, fill the key part +// If RSA_key == NULL, fill the header and body(GENDATA mode) +// If the path[UNSIGNED] != NULL, update the header.date(CATSIG mode) +static bool fill_enclave_css(const IppsRSAPublicKeyState *pub_key, const xml_parameter_t *para, const uint8_t *enclave_hash, + const char **path, enclave_css_t *css, bin_fmt_t bf) +{ + assert(para != NULL && enclave_hash != NULL && path != NULL && css != NULL); + + enclave_css_t enclave_css; + memset(&enclave_css, 0, sizeof(enclave_css_t)); + + uint32_t date = 0; + if(false == get_time(&date)) + return false; + + //*****fill the header******************* + uint8_t header[12] = {6, 0, 0, 0, 0xE1, 0, 0, 0, 0, 0, 1, 0}; + uint8_t header2[16] = {1, 1, 0, 0, 0x60, 0, 0, 0, 0x60, 0, 0, 0, 1, 0, 0, 0}; + memcpy_s(&enclave_css.header.header, sizeof(enclave_css.header.header), &header, sizeof(header)); + memcpy_s(&enclave_css.header.header2, sizeof(enclave_css.header.header2), &header2, sizeof(header2)); + + // For 'type', signing tool clears the bit 31 for product enclaves + // and set the bit 31 for debug enclaves + enclave_css.header.type = (para[RELEASETYPE].value & 0x01) ? (1<<31) : 0; + enclave_css.header.module_vendor = (para[INTELSIGNED].value&0x01) ? 0x8086 : 0; + enclave_css.header.date = date; + + //if pub_key is not NULL, fill the key part + if(pub_key) + { + int exponent_size = 0; + int modulus_size = 0; + IppStatus error_code = get_pub_key(pub_key, &exponent_size, + (Ipp32u *)&enclave_css.key.exponent, + &modulus_size, + (Ipp32u *)&enclave_css.key.modulus); + if(error_code != ippStsNoErr) + { + return false; + } + exponent_size = (uint32_t)(ROUND_TO(exponent_size, sizeof(Ipp32u)) / sizeof(Ipp32u)); + modulus_size = (uint32_t)(ROUND_TO(modulus_size, sizeof(Ipp32u)) / sizeof(Ipp32u)); + assert(enclave_css.key.exponent[0] == 0x03); + assert(exponent_size == 0x1); + assert(modulus_size == 0x60); + } + + //hardware version + enclave_css.header.hw_version = para[HW].value; + + //****************************fill the body*********************** + // Misc_select/Misc_mask + enclave_css.body.misc_select = para[MISCSELECT].value; + enclave_css.body.misc_mask = para[MISCMASK].value; + //low 64 bit + enclave_css.body.attributes.flags = 0; + enclave_css.body.attribute_mask.flags = ~SGX_FLAGS_DEBUG; + if(para[DISABLEDEBUG].value == 1) + { + enclave_css.body.attributes.flags &= ~SGX_FLAGS_DEBUG; + enclave_css.body.attribute_mask.flags |= SGX_FLAGS_DEBUG; + } + if(para[PROVISIONKEY].value == 1) + { + enclave_css.body.attributes.flags |= SGX_FLAGS_PROVISION_KEY; + enclave_css.body.attribute_mask.flags |= SGX_FLAGS_PROVISION_KEY; + } + if(para[LAUNCHKEY].value == 1) + { + enclave_css.body.attributes.flags |= SGX_FLAGS_LICENSE_KEY; + enclave_css.body.attribute_mask.flags |= SGX_FLAGS_LICENSE_KEY; + } + if(bf == BF_PE64 || bf == BF_ELF64) + { + enclave_css.body.attributes.flags |= SGX_FLAGS_MODE64BIT; + enclave_css.body.attribute_mask.flags |= SGX_FLAGS_MODE64BIT; + } + // high 64 bit + //default setting + enclave_css.body.attributes.xfrm = SGX_XFRM_LEGACY; + enclave_css.body.attribute_mask.xfrm = SGX_XFRM_LEGACY | SGX_XFRM_RESERVED; // LEGACY and reserved bits would be checked. + + memcpy_s(&enclave_css.body.enclave_hash, sizeof(enclave_css.body.enclave_hash), enclave_hash, SGX_HASH_SIZE); + enclave_css.body.isv_prod_id = (uint16_t)para[PRODID].value; + enclave_css.body.isv_svn = (uint16_t)para[ISVSVN].value; + + //Copy the css to output css buffer + memcpy_s(css, sizeof(enclave_css_t), &enclave_css, sizeof(enclave_css_t)); + + if(path[UNSIGNED] != NULL) + { + // In catsig mode, update the header.date as the time when the unsigned file is generated. + memset(&enclave_css, 0, sizeof(enclave_css)); + size_t fsize = get_file_size(path[UNSIGNED]); + if(fsize != sizeof(enclave_css.header) + sizeof(enclave_css.body)) + { + se_trace(SE_TRACE_ERROR, UNSIGNED_FILE_ERROR, path[UNSIGNED]); + return false; + } + uint8_t *buf = new uint8_t[fsize]; + memset(buf, 0, fsize); + if(read_file_to_buf(path[UNSIGNED], buf, fsize) == false) + { + se_trace(SE_TRACE_ERROR, READ_FILE_ERROR, path[UNSIGNED]); + return false; + } + memcpy_s(&enclave_css.header, sizeof(enclave_css.header), buf, sizeof(enclave_css.header)); + memcpy_s(&enclave_css.body, sizeof(enclave_css.body), buf + sizeof(enclave_css.header), fsize - sizeof(enclave_css.header)); + delete [] buf; + css->header.date = enclave_css.header.date; + // Verify the header and body read from the unsigned file to make sure it's the same as that generated from xml file + if(memcmp(&enclave_css.header, &css->header, sizeof(enclave_css.header)) || memcmp(&enclave_css.body, &css->body, sizeof(enclave_css.body))) + { + se_trace(SE_TRACE_ERROR, UNSIGNED_FILE_XML_MISMATCH); + return false; + } + } + return true; +} + +static IppStatus calc_RSAq1q2(int length_s, const Ipp32u *data_s, int length_m, const Ipp32u *data_m, + int *length_q1, Ipp32u *data_q1, int *length_q2, Ipp32u *data_q2) +{ + IppStatus error_code = ippStsSAReservedErr1; + IppsBigNumState *pM=0, *pS=0, *pQ1=0, *pQ2=0, *ptemp1=0, *ptemp2=0; + IppsBigNumSGN sgn = IppsBigNumPOS; + int length_in_bit = 0; + Ipp32u *pdata = NULL; + + //create 6 big number + + if(!data_s || !data_m || !length_q1 || !data_q1 || !length_q2 + || !data_q2 || length_s <= 0 || length_m <= 0) + { + error_code = ippStsBadArgErr; + goto clean_return; + } + + error_code = newBN(data_s, length_s, &pS); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + error_code = newBN(data_m, length_m, &pM); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + error_code = newBN(0, length_m, &pQ1); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + error_code = newBN(0, length_m, &pQ2); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + error_code = newBN(0, length_m*2, &ptemp1); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + error_code = newBN(0, length_m, &ptemp2); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + + //signed big number operation + //multiplies pS and pS, ptemp1 is the multiplication result + error_code = ippsMul_BN(pS, pS, ptemp1); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + + //ptemp1: dividend, pM: divisor, pQ1: qutient, ptemp2: remainder + error_code = ippsDiv_BN(ptemp1, pM, pQ1, ptemp2); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + error_code = ippsMul_BN(pS, ptemp2, ptemp1); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + error_code = ippsDiv_BN(ptemp1, pM, pQ2, ptemp2); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + //extract the sign and value of the integer big number from the input structure(pQ1) + + error_code = ippsRef_BN(&sgn, &length_in_bit, &pdata, pQ1); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + *length_q1 = ROUND_TO(length_in_bit, 8)/8; + memset(data_q1, 0, *length_q1); + memcpy_s(data_q1, *length_q1, pdata, *length_q1); + + error_code = ippsRef_BN(&sgn, &length_in_bit, &pdata, pQ2); + if(error_code != ippStsNoErr) + { + goto clean_return; + } + *length_q2 = ROUND_TO(length_in_bit, 8)/8; + memset(data_q2, 0, *length_q2); + memcpy_s(data_q2, *length_q2, pdata, *length_q2); + goto clean_return; + +clean_return: + secure_free_BN(pM, length_m); + secure_free_BN(pS, length_s); + secure_free_BN(pQ1, length_m); + secure_free_BN(pQ2, length_m); + secure_free_BN(ptemp1, length_m*2); + secure_free_BN(ptemp2, length_m); + + return error_code; +} + +static bool create_signature(const IppsRSAPrivateKeyState *pri_key1, const char *sigpath, enclave_css_t *enclave_css) +{ + IppStatus error_code = ippStsNoErr; + assert(enclave_css != NULL); + assert(!(pri_key1 == NULL && sigpath == NULL) && !(pri_key1 != NULL && sigpath != NULL)); + + uint8_t signature[SIGNATURE_SIZE]; // keep the signature in big endian + memset(signature, 0, SIGNATURE_SIZE); + //**********get the signature********* + if(sigpath != NULL)//CATSIG mode + { + if(get_file_size(sigpath) != SIGNATURE_SIZE) + { + se_trace(SE_TRACE_ERROR, SIG_FILE_ERROR, sigpath); + return false; + } + if(read_file_to_buf(sigpath, signature, SIGNATURE_SIZE) == false) + { + se_trace(SE_TRACE_ERROR, READ_FILE_ERROR, sigpath); + return false; + } + } + else //SIGN mode + { + size_t buffer_size = sizeof(enclave_css->header) + sizeof(enclave_css->body); + Ipp8u * temp_buffer = (Ipp8u *)malloc(buffer_size * sizeof(char)); + if(NULL == temp_buffer) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); + return false; + } + memcpy_s(temp_buffer, buffer_size, &enclave_css->header, sizeof(enclave_css->header)); + memcpy_s(temp_buffer + sizeof(enclave_css->header), buffer_size - sizeof(enclave_css->header), + &enclave_css->body, sizeof(enclave_css->body)); + int pri1_size = 0; + if(ippsRSA_GetBufferSizePrivateKey(&pri1_size, pri_key1) != ippStsNoErr) + { + free(temp_buffer); + return false; + } + Ipp8u *scratch_buf = (Ipp8u *)malloc(pri1_size); + if(NULL == scratch_buf) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); + free(temp_buffer); + return false; + } + memset(scratch_buf, 0, pri1_size); + error_code = ippsRSASign_PKCS1v15((const Ipp8u *)temp_buffer, (int)buffer_size, (Ipp8u *)signature, pri_key1, NULL, ippHashAlg_SHA256, scratch_buf); + free(scratch_buf); + free(temp_buffer); + + if(error_code != ippStsNoErr) + { + return false; + } + } + for(int i = 0; ikey.signature)[i] = signature[SIGNATURE_SIZE-1-i]; + } + //************************calculate q1 and q2********************* + int length_q1 = 0, length_q2 = 0; + error_code = calc_RSAq1q2(sizeof(enclave_css->key.signature), + (Ipp32u *)&enclave_css->key.signature, + sizeof(enclave_css->key.modulus), + (Ipp32u *)&enclave_css->key.modulus, + &length_q1, + (Ipp32u *)&enclave_css->buffer.q1, + &length_q2, + (Ipp32u *)&enclave_css->buffer.q2); + if(error_code != ippStsNoErr) + { + return false; + } + return true; +} + +static bool verify_signature(const rsa_params_t *rsa, const enclave_css_t *enclave_css, int *signature_verified) +{ + assert(rsa != NULL && enclave_css != NULL && signature_verified != NULL); + IppsRSAPublicKeyState *pub_key = NULL; + IppStatus error_code = create_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, rsa->n, rsa->e, &pub_key); + if(error_code != ippStsNoErr) + { + return false; + } + size_t buffer_size = sizeof(enclave_css->header) + sizeof(enclave_css->body); + Ipp8u * temp_buffer = (Ipp8u *)malloc(buffer_size * sizeof(char)); + if(NULL == temp_buffer) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + return false; + } + memcpy_s(temp_buffer, buffer_size, &enclave_css->header, sizeof(enclave_css->header)); + memcpy_s(temp_buffer + sizeof(enclave_css->header), buffer_size-sizeof(enclave_css->header), + &enclave_css->body, sizeof(enclave_css->body)); + uint8_t signature[SIGNATURE_SIZE]; + for(int i=0; ikey.signature[SIGNATURE_SIZE-1-i]; + } + int pub_size = 0; + if(ippsRSA_GetBufferSizePublicKey(&pub_size, pub_key) != ippStsNoErr) + { + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + free(temp_buffer); + return false; + } + Ipp8u *scratch_buf = (Ipp8u *)malloc(pub_size); + if(NULL == scratch_buf) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + free(temp_buffer); + return false; + } + memset(scratch_buf, 0, pub_size); + error_code = ippsRSAVerify_PKCS1v15((const Ipp8u *)temp_buffer, (int)buffer_size, (Ipp8u *)signature, signature_verified, pub_key, ippHashAlg_SHA256, scratch_buf); + free(temp_buffer); + free(scratch_buf); + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + + if(error_code != ippStsNoErr) + { + se_trace(SE_TRACE_DEBUG, "ippsRSASSAVerify_SHA256_PKCSv15() returns failure. The ipperrorCode is %d \n", error_code); + return false; + } + else + { + se_trace(SE_TRACE_DEBUG, "RSAVerify() returns success. The signature_verified is %d\n", *signature_verified); + return true; + } +} + +static bool gen_enclave_signing_file(const enclave_css_t *enclave_css, const char *outpath) +{ + assert(enclave_css != NULL); + size_t size = sizeof(enclave_css->header) + sizeof(enclave_css->body); + uint8_t *buffer = (uint8_t *)malloc(size); + if(buffer == NULL) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); + return false; + } + memcpy_s(buffer, sizeof(enclave_css->header), &enclave_css->header, sizeof(enclave_css->header)); + memcpy_s(buffer + sizeof(enclave_css->header), sizeof(enclave_css->body), &enclave_css->body, sizeof(enclave_css->body)); + + if(write_data_to_file(outpath, std::ios::out|std::ios::binary, buffer, size) == false) + { + free(buffer); + return false; + } + free(buffer); + return true; +} + +static bool cmdline_parse(unsigned int argc, char *argv[], int *mode, const char **path) +{ + assert(mode!=NULL && path != NULL); + if(argc<2) + { + se_trace(SE_TRACE_ERROR, LACK_PARA_ERROR); + return false; + } + if(argc == 2 && !STRCMP(argv[1], "-help")) + { + se_trace(SE_TRACE_ERROR, USAGE_STRING); + *mode = -1; + return true; + } + + enum { PAR_REQUIRED, PAR_OPTIONAL, PAR_INVALID }; + typedef struct _param_struct_{ + const char *name; //options + char *value; //keep the path + int flag; //indicate this parameter is required(0), optional(1) or invalid(2) + }param_struct_t; //keep the parameter pairs + + param_struct_t params_sign[] = { + {"-enclave", NULL, PAR_REQUIRED}, + {"-config", NULL, PAR_OPTIONAL}, + {"-key", NULL, PAR_REQUIRED}, + {"-out", NULL, PAR_REQUIRED}, + {"-sig", NULL, PAR_INVALID}, + {"-unsigned", NULL, PAR_INVALID}, + {"-review_enclave", NULL, PAR_INVALID}}; + param_struct_t params_gendata[] = { + {"-enclave", NULL, PAR_REQUIRED}, + {"-config", NULL, PAR_OPTIONAL}, + {"-key", NULL, PAR_INVALID}, + {"-out", NULL, PAR_REQUIRED}, + {"-sig", NULL, PAR_INVALID}, + {"-unsigned", NULL, PAR_INVALID}, + {"-review_enclave", NULL, PAR_INVALID}}; + param_struct_t params_catsig[] = { + {"-enclave", NULL, PAR_REQUIRED}, + {"-config", NULL, PAR_OPTIONAL}, + {"-key", NULL, PAR_REQUIRED}, + {"-out", NULL, PAR_REQUIRED}, + {"-sig", NULL, PAR_REQUIRED}, + {"-unsigned", NULL, PAR_REQUIRED}, + {"-review_enclave", NULL, PAR_INVALID}}; + param_struct_t params_compare[] = { + {"-enclave", NULL, PAR_REQUIRED}, + {"-config", NULL, PAR_OPTIONAL}, + {"-key", NULL, PAR_INVALID}, + {"-out", NULL, PAR_INVALID}, + {"-sig", NULL, PAR_INVALID}, + {"-unsigned", NULL, PAR_REQUIRED}, + {"-review_enclave", NULL, PAR_REQUIRED}}; + + + const char *mode_m[] ={"sign", "gendata","catsig", "compare"}; + param_struct_t *params[] = {params_sign, params_gendata, params_catsig, params_compare}; + unsigned int tempidx=0; + for(; tempidx=sizeof(mode_m)/sizeof(mode_m[0])) + { + se_trace(SE_TRACE_ERROR, UNREC_CMD_ERROR, argv[1]); + return false; + } + + unsigned int params_count = (unsigned)(sizeof(params_sign)/sizeof(params_sign[0])); + unsigned int params_count_min = 0; + unsigned int params_count_max =0; + for(unsigned int i=0; i< params_count; i++) + { + params_count_max ++; + if(params[tempmode][i].flag == PAR_REQUIRED) + params_count_min ++; + } + unsigned int additional_param = 2; + if(argcparams_count_max * 2 + additional_param) + return false; + + for(unsigned int i=2; i=params_count_max) + { + return false; + } + } + for(unsigned int i = 0; i < params_count; i ++) + { + if(params[tempmode][i].flag == PAR_REQUIRED && params[tempmode][i].value == NULL) + { + se_trace(SE_TRACE_ERROR, LACK_REQUIRED_OPTION_ERROR, params[tempmode][i].name, mode_m[tempmode]); + return false; + } + if(params[tempmode][i].flag == PAR_INVALID && params[tempmode][i].value != NULL) + { + se_trace(SE_TRACE_ERROR, GIVE_INVALID_OPTION_ERROR, params[tempmode][i].name, mode_m[tempmode]); + return false; + } + } + for(unsigned int i = 0; i < params_count; i++) + { + path[i] = params[tempmode][i].value; + } + *mode = tempmode; + return true; + +} + +static bool fill_meta_without_signature(const IppsRSAPublicKeyState *pub_key, const char **path, const uint8_t *enclave_hash, + const xml_parameter_t *para, metadata_t *metadata, bin_fmt_t bf) +{ + assert(path && enclave_hash && para && metadata); + if(false == fill_enclave_css(pub_key, para, enclave_hash, path, &metadata->enclave_css, bf)) + { + return false; + } + set_meta_attributes(metadata); + + return true; +} + +//generate_output: +// To generate the final output file +// SIGN- need to fill the enclave_css_t(key part included), sign the header and body and +// update the metadata in the out file +// GENDATA- need to fill the enclave_css_t(key part excluded), get the body and header, +// and then write the whole out file with body+header+hash +// CATSIG- need to fill the enclave_css_t(include key), read the signature from the sigpath, +// and then update the metadata in the out file +static bool generate_output(int mode, int ktype, const uint8_t *enclave_hash, const xml_parameter_t *para, const rsa_params_t *rsa, metadata_t *metadata, + const char **path, bin_fmt_t bf, uint64_t meta_offset) +{ + assert(enclave_hash != NULL && para != NULL && metadata != NULL && path != NULL && rsa != NULL); + IppsRSAPrivateKeyState *pri_key1 = NULL; + IppsRSAPublicKeyState *pub_key = NULL; + int validate_result = IS_INVALID_KEY; + IppStatus error_code = ippStsNoErr; + + switch(mode) + { + case SIGN: + { + if(ktype != PRIVATE_KEY) + { + se_trace(SE_TRACE_ERROR, LACK_PRI_KEY_ERROR); + return false; + } + + error_code = create_validate_rsa_key_pair(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, rsa->n, rsa->d, rsa->e, + rsa->p, rsa->q, rsa->dmp1, rsa->dmq1, rsa->iqmp, &pri_key1, &pub_key, &validate_result); + if(error_code != ippStsNoErr || validate_result != IS_VALID_KEY) + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + return false; + } + + if(false == fill_meta_without_signature(pub_key, path, enclave_hash, para, metadata, bf)) + { + secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + return false; + } + if(false == create_signature(pri_key1, NULL, &(metadata->enclave_css))) + { + secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + return false; + } + secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + + if(false == update_metadata(path[OUTPUT], metadata, meta_offset)) + { + return false; + } + break; + } + case GENDATA: + { + if(false == fill_meta_without_signature(NULL, path, enclave_hash, para, metadata, bf)) + { + return false; + } + if(false == gen_enclave_signing_file(&(metadata->enclave_css), path[OUTPUT])) + { + return false; + } + break; + } + case CATSIG: + { + if(ktype != PUBLIC_KEY) + { + se_trace(SE_TRACE_ERROR, LACK_PUB_KEY_ERROR); + return false; + } + + if(create_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, rsa->n, rsa->e, &pub_key) != ippStsNoErr) + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + return false; + } + if(false == fill_meta_without_signature(pub_key, path, enclave_hash, para, metadata, bf)) + { + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + return false; + } + secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); + + if(false == create_signature(NULL, path[SIG], &(metadata->enclave_css))) + { + return false; + } + if(false == update_metadata(path[OUTPUT], metadata, meta_offset)) + { + return false; + } + break; + } + default: + { + return false; + } + } + return true; +} +//compare two enclaves +static bool compare_enclave(const char **path, const xml_parameter_t *para) +{ + assert(path != NULL && para != NULL); + bool res = false; + int ret = SGX_SUCCESS; + sgx_status_t status1 = SGX_SUCCESS, status2 = SGX_SUCCESS; + uint32_t file_size1 =0 , file_size2 = 0; + size_t file_size = 0; + bin_fmt_t bin_fmt1 = BF_UNKNOWN, bin_fmt2 = BF_UNKNOWN; + uint8_t enclave_hash[SGX_HASH_SIZE] = {0}; + uint8_t *buf = NULL; + CMetadata *meta = NULL; + metadata_t metadata; + enclave_diff_info_t enclave_diff_info1, enclave_diff_info2; + enclave_css_t enclave_css; + memset(&enclave_css, 0, sizeof(enclave_css_t)); + memset(&enclave_diff_info1, 0, sizeof(enclave_diff_info_t)); + memset(&enclave_diff_info2, 0, sizeof(enclave_diff_info_t)); + memset(&metadata, 0, sizeof(metadata_t)); + + se_file_handle_t fh1 = open_file(path[DLL]); + if (fh1 == THE_INVALID_HANDLE) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, path[DLL]); + return false; + } + + se_file_handle_t fh2 = open_file(path[REVIEW_ENCLAVE]); + if (fh2 == THE_INVALID_HANDLE) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, path[REVIEW_ENCLAVE]); + close_handle(fh1); + return false; + } + + + std::unique_ptr mh1(map_file(fh1, &file_size1), unmap_file); + if (!mh1) + { + close_handle(fh1); + close_handle(fh2); + return false; + } + std::unique_ptr mh2(map_file(fh2, &file_size2), unmap_file); + if (!mh2) + { + close_handle(fh1); + close_handle(fh2); + return false; + } + + //check if file_size is the same + if(file_size1 != file_size2) + { + close_handle(fh1); + close_handle(fh2); + return false; + } + + // Parse enclave + std::unique_ptr parser1(binparser::get_parser(mh1->base_addr, (size_t)file_size1)); + assert(parser1 != NULL); + std::unique_ptr parser2(binparser::get_parser(mh2->base_addr, (size_t)file_size2)); + assert(parser2 != NULL); + + status1 = parser1->run_parser(); + if (status1 != SGX_SUCCESS) + { + goto clear_return; + } + + status2 = parser2->run_parser(); + if (status2 != SGX_SUCCESS) + { + goto clear_return; + } + + // Collect enclave info + bin_fmt1 = parser1->get_bin_format(); + bin_fmt2 = parser2->get_bin_format(); + //two enclave should have same format + if(bin_fmt1 != bin_fmt2) + { + goto clear_return; + } + + //modify some info of enclave: timestamp etc. + status1 = parser1->get_info(&enclave_diff_info1); + if(status1 != SGX_SUCCESS) + { + goto clear_return; + } + status2 = parser2->get_info(&enclave_diff_info2); + if(status2 != SGX_SUCCESS) + { + goto clear_return; + } + status2 = parser2->modify_info(&enclave_diff_info1); + if(status2 != SGX_SUCCESS) + { + goto clear_return; + } + + //get enclave hash from unsigned file + file_size = get_file_size(path[UNSIGNED]); + if (file_size != sizeof(enclave_css.header) + sizeof(enclave_css.body) && + file_size != sizeof(enclave_css.header) + sizeof(enclave_css.body) + sizeof(enclave_css.key)) + { + goto clear_return; + } + + buf = (uint8_t *)malloc(file_size); + if (buf == NULL) + { + goto clear_return; + } + memset(buf, 0, file_size); + if(read_file_to_buf(path[UNSIGNED], buf, file_size) == false) + { + free(buf); + goto clear_return; + } + memcpy_s(&enclave_css.header, sizeof(enclave_css.header), buf, sizeof(enclave_css.header)); + memcpy_s(&enclave_css.body, sizeof(enclave_css.body), buf + (file_size - sizeof(enclave_css.body)), sizeof(enclave_css.body)); + free(buf); + + // Load enclave to get enclave hash + meta = new CMetadata(&metadata, parser2.get()); + if(meta->build_metadata(para) == false) + { + delete meta; + goto clear_return; + } + delete meta; + + ret = load_enclave(parser2.release(), &metadata); + if(ret != SGX_SUCCESS) + { + goto clear_return; + } + ret = dynamic_cast(get_enclave_creator())->get_enclave_info(enclave_hash, SGX_HASH_SIZE); + if(ret != SGX_SUCCESS) + { + goto clear_return; + } + + //make path[UNSIGNED] = NULL, so fill_meta_without_signature won't treat it as catsig + path[UNSIGNED] = NULL; + if(false == fill_meta_without_signature(NULL, path, enclave_hash, para, &metadata, bin_fmt2)) + { + goto clear_return; + } + + //compare + metadata.enclave_css.header.date = 0; + enclave_css.header.date = 0; + if(memcmp(&metadata.enclave_css.header, &enclave_css.header, sizeof(enclave_css.header)) != 0) + { + goto clear_return; + } + if(memcmp(&metadata.enclave_css.body, &enclave_css.body, sizeof(enclave_css.body)) != 0) + { + goto clear_return; + } + + res = true; +clear_return: + close_handle(fh1); + close_handle(fh2); + return res; +} + +int main(int argc, char* argv[]) +{ + xml_parameter_t parameter[] = {{"ProdID", 0xFFFF, 0, 0, 0}, + {"ISVSVN", 0xFFFF, 0, 0, 0}, + {"ReleaseType", 1, 0, 0, 0}, + {"IntelSigned", 1, 0, 0, 0}, + {"ProvisionKey",1,0,0,0}, + {"LaunchKey",1,0,0,0}, + {"DisableDebug",1,0,0,0}, + {"HW", 0x10,0,0,0}, + {"TCSNum",0xFFFFFFFF,TCS_NUM_MIN,1,0}, + {"TCSPolicy",TCS_POLICY_UNBIND,TCS_POLICY_BIND,TCS_POLICY_UNBIND,0}, + {"StackMaxSize",0xFFFFFFFF,STACK_SIZE_MIN,0x40000,0}, + {"HeapMaxSize",0xFFFFFFFF,HEAP_SIZE_MIN,0x100000,0}, + {"MiscSelect", 0xFFFFFFFF, 0, DEFAULT_MISC_SELECT, 0}, + {"MiscMask", 0xFFFFFFFF, 0, DEFAULT_MISC_MASK, 0}}; + + const char *path[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + uint8_t enclave_hash[SGX_HASH_SIZE] = {0}; + metadata_t metadata; + int res = -1, mode = -1; + int key_type = UNIDENTIFIABLE_KEY; //indicate the type of the input key file + size_t parameter_count = sizeof(parameter)/sizeof(parameter[0]); + bin_fmt_t bin_fmt = BF_UNKNOWN; + uint64_t meta_offset = 0; + rsa_params_t rsa; + + memset(&rsa, 0, sizeof(rsa)); + memset(&metadata, 0, sizeof(metadata)); + + + //Parse command line + if(cmdline_parse(argc, argv, &mode, path) == false) + { + se_trace(SE_TRACE_ERROR, USAGE_STRING); + goto clear_return; + } + if(mode == -1) // User only wants to get the help info + { + return 0; + } + + //Parse the xml file to get the metadata + if(parse_metadata_file(path[XML], parameter, (int)parameter_count) == false) + { + goto clear_return; + } + //Parse the key file + if(parse_key_file(path[KEY], &rsa, &key_type) == false && key_type != NO_KEY) + { + goto clear_return; + } + //compare two enclave + if(mode == COMPARE) + { + if(compare_enclave(path, parameter) == false) + { + se_trace(SE_TRACE_ERROR, "The two enclaves are not matched\n"); + return -1; + } + se_trace(SE_TRACE_ERROR, "The two enclaves are matched\n"); + return 0; + } + if(copy_file(path[DLL], path[OUTPUT]) == false) + { + se_trace(SE_TRACE_ERROR, OVERALL_ERROR); + goto clear_return; + } + + if(measure_enclave(enclave_hash, path[OUTPUT], parameter, &metadata, &bin_fmt, &meta_offset) == false) + { + se_trace(SE_TRACE_ERROR, OVERALL_ERROR); + goto clear_return; + } + + if((generate_output(mode, key_type, enclave_hash, parameter, &rsa, &metadata, path, bin_fmt, meta_offset)) == false) + { + se_trace(SE_TRACE_ERROR, OVERALL_ERROR); + goto clear_return; + } + //to verify + if(mode == SIGN || mode == CATSIG) + { + int signature_verified = ippFalse; + if(verify_signature(&rsa, &(metadata.enclave_css), &signature_verified) == false || signature_verified != ippTrue) + { + se_trace(SE_TRACE_ERROR, OVERALL_ERROR); + goto clear_return; + } + } + + se_trace(SE_TRACE_ERROR, SUCCESS_EXIT); + res = 0; + +clear_return: + if(res == -1 && path[OUTPUT]) + remove(path[OUTPUT]); + return res; +} diff --git a/sdk/sign_tool/SignTool/util_st.cpp b/sdk/sign_tool/SignTool/util_st.cpp new file mode 100644 index 0000000000..95816ec93d --- /dev/null +++ b/sdk/sign_tool/SignTool/util_st.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "util_st.h" +#include "se_trace.h" +#include +#include + +extern "C" bool write_data_to_file(const char *filename, std::ios_base::openmode mode, + uint8_t *buf, size_t bsize, long offset) +{ + if(filename == NULL || (buf == NULL && bsize != 0) || (buf != NULL && bsize == 0)) + return false; + std::ofstream ofs(filename, mode); + if(!ofs.good()) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, filename); + return false; + } + ofs.seekp(offset, std::ios::beg); + ofs.write(reinterpret_cast(buf), bsize); + if(ofs.fail()) + { + se_trace(SE_TRACE_ERROR, WRITE_FILE_ERROR, filename); + return false; + } + return true; +} + +extern "C" long get_file_size(const char *filename) +{ + std::ifstream ifs(filename, std::ios::in | std::ios::binary); + if(!ifs.good()) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, filename); + return -1; + } + ifs.seekg(0, std::ios::end); + size_t size = (size_t)ifs.tellg(); + return size; +} + +extern "C" bool read_file_to_buf(const char *filename, uint8_t *buf, size_t bsize) +{ + if(filename == NULL || buf == NULL || bsize == 0) + return false; + std::ifstream ifs(filename, std::ios::binary|std::ios::in); + if(!ifs.good()) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, filename); + return false; + } + ifs.read(reinterpret_cast (buf), bsize); + if(ifs.fail()) + { + return false; + } + return true; + +} + +extern "C" bool copy_file(const char *source_path, const char *dest_path) +{ + std::ifstream ifs(source_path, std::ios::binary|std::ios::in); + if(!ifs.good()) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, source_path); + return false; + } + + std::ofstream ofs(dest_path, std::ios::binary|std::ios::out); + if(!ofs.good()) + { + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, dest_path); + return false; + } + ofs << ifs.rdbuf(); + return true; +} + diff --git a/sdk/sign_tool/SignTool/util_st.h b/sdk/sign_tool/SignTool/util_st.h new file mode 100644 index 0000000000..78912c165f --- /dev/null +++ b/sdk/sign_tool/SignTool/util_st.h @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _UTIL_ST_H_ +#define _UTIL_ST_H_ + +#include "se_cdefs.h" +#include "se_memcpy.h" +#include + + +#define USAGE_STRING \ + "Usage: sgx_sign [options] file...\n"\ + "Commands:\n"\ + " sign Sign the enclave using the private key\n"\ + " gendata Generate enclave signing material to be signed\n"\ + " catsig Generate the signed enclave with the input signature file, the\n"\ + " public key and the enclave signing material\n"\ + "Options:\n"\ + " -enclave Specify the enclave file to be signed\n"\ + " It is a required option for the three commands\n"\ + " -key Specify the key file\n"\ + " It is a required option for \"sign\" and \"catsig\"\n"\ + " -config Specify the configuration for the enclave\n"\ + " -out Specify the output file\n"\ + " It is a required option for the three commands\n"\ + " -sig Specify the signature file for the enclave signing material\n" \ + " It is a required option for \"catsig\"\n"\ + " -unsigned Specify the enclave signing material generated by \"gendata\"\n" \ + " It is a required option for \"catsig\"\n" + +// General error message +#define OVERALL_ERROR "Error happened while signing the enclave.\n" +#define KEY_FORMAT_ERROR "Key file format is not correct.\n" +#define XML_FORMAT_ERROR "Configure file format is not correct.\n" +#define NO_MEMORY_ERROR "Out of memory.\n" +#define OPEN_FILE_ERROR "Failed to open file \"%s\".\n" +#define READ_FILE_ERROR "Failed to read file \"%s\".\n" +#define WRITE_FILE_ERROR "Failed to write file \"%s\".\n" + +// error message for measure_enclave() +#define OUT_OF_EPC_ERROR "The required memory is too large. Please check TCSNum/HeapMaxSize/StackMaxSize.\n" +#define META_VERSION_ERROR "Metadata version is mismatched between uRTS and sgx_sign.\n" +#define INVALID_ENCLAVE_ERROR "The input enclave file is not correct.\n" +#define REQUIRED_ENCLAVE_SIZE "The required memory is 0x%x.\n" + +// error message for fill_enclave_css() +#define UNSIGNED_FILE_ERROR "The unsigned file \"%s\" is not correct.\n" +#define UNSIGNED_FILE_XML_MISMATCH "The unsigned file content doesn't match the configuration file.\n" + +// error message for create_signature() +#define SIG_FILE_ERROR "The signature file \"%s\" is not correct.\n" + +// error message for cmdline_parse() +#define LACK_PARA_ERROR "Lack of parameters.\n" +#define UNREC_CMD_ERROR "Cannot recognize the command \"%s\".\nCommand \"sign/gendata/catsig\" is required.\n" +#define REPEAT_OPTION_ERROR "Repeatly specified \"%s\" option.\n" +#define INVALID_FILE_NAME_ERROR "The File name is not correct for \"%s\" option.\n" +#define LACK_REQUIRED_OPTION_ERROR "Option \"%s\" is required for the command \"%s\".\n" +#define GIVE_INVALID_OPTION_ERROR "Option \"%s\" is invalid for the command \"%s\".\n" + +// error message for generate_output() +#define LACK_PRI_KEY_ERROR "Private key is required for the \"sign\" command.\n" +#define LACK_PUB_KEY_ERROR "Public key is required for the \"catsig\" command.\n" + +// error message for main() +#define INIT_IPP_LIBRARY_ERROR "Failed to initialize the IPP library.\n" +#define ENCLAVE_ALREADY_SIGNED_ERROR "The enclave has been signed already.\n" +#define SUCCESS_EXIT "Succeed.\n" + +// error message for traverser_parameter() +#define LACK_VALUE_FOR_ELEMENT_ERROR "No value for the element \"%s\".\n" +#define INVALID_VALUE_FOR_ELEMENT_ERROR "Invalid value for the element\"%s\".\n" +#define UNREC_ELEMENT_ERROR "Element is not recognized - \"%s\".\n" +#define REPEATED_DEFINE_ERROR "Defined \"%s\" too many times.\n" +#define VALUE_OUT_OF_RANGE_ERROR "The value of \"%s\" is out of range.\n" + +// error message for modify_metadata() +#define SET_STACK_SIZE_ERROR "Stack size setting is not correct.\n" +#define SET_HEAP_SIZE_ERROR "Heap size setting is not correct.\n" +#define SET_HW_LE_ERROR "Conflicting setting between the 'HW' and 'LaunchKey'.\n" + +// error message for compare_enclave() +#define PDB_PATH_ERROR "The two enclaves' pdb path are not equal. The pdb path of \"%s\" is \"%s\", while the pdb path of \"%s\" is \"%s\".\n" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +long get_file_size(const char *filename); +bool read_file_to_buf(const char *filename, uint8_t *buffer, size_t bsize); +bool write_data_to_file(const char *filename, std::ios_base::openmode mode, uint8_t *buf, size_t bsize, long offset = 0); +bool copy_file(const char *source_path, const char *dest_path); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/Makefile b/sdk/simulation/Makefile new file mode 100644 index 0000000000..9507f62061 --- /dev/null +++ b/sdk/simulation/Makefile @@ -0,0 +1,54 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +DIRS := assembly \ + uinst \ + tinst \ + driver_api \ + tae_service_sim \ + uae_service_sim/linux \ + urtssim \ + trtssim \ + SEConfigureCPUSVN/linux + +TARGETS := all clean +.PHONY: $(TARGETS) + +$(TARGETS): $(DIRS) + +all: TARGET := all +clean: TARGET := clean + +.PHONY: $(DIRS) +$(DIRS): + $(MAKE) -C $@ $(TARGET) diff --git a/sdk/simulation/SEConfigureCPUSVN/linux/Makefile b/sdk/simulation/SEConfigureCPUSVN/linux/Makefile new file mode 100644 index 0000000000..9354fb27f9 --- /dev/null +++ b/sdk/simulation/SEConfigureCPUSVN/linux/Makefile @@ -0,0 +1,72 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../../buildenv.mk + +SIM_DIR := $(CUR_DIR)/../.. + +CXXFLAGS += -Werror +CPPFLAGS := -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(SIM_DIR)/urtssim \ + -I$(SIM_DIR)/tinst + +SRCS := $(wildcard ./*.cpp) +SRCS += $(SIM_DIR)/urtssim/cpusvn_util.cpp + +OBJS := $(SRCS:.cpp=.o) + +WRAPPER_LIB_DIR := $(COMMON_DIR)/se_wrapper +LDFLAGS := -L$(WRAPPER_LIB_DIR) +LDLIBS := -lwrapper + +TARGET := sgx_config_cpusvn + +.PHONY: all +all: $(TARGET) | $(BUILD_DIR) + @$(CP) $< $| + +$(TARGET): $(OBJS) $(LDLIBS) + $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) + +$(OBJS): %.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + +$(LDLIBS): + $(MAKE) -C $(WRAPPER_LIB_DIR) + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: clean +clean: + $(MAKE) -C $(WRAPPER_LIB_DIR) clean + @$(RM) $(TARGET) $(BUILD_DIR)/$(TARGET) $(OBJS) diff --git a/sdk/simulation/SEConfigureCPUSVN/linux/config_cpusvn.cpp b/sdk/simulation/SEConfigureCPUSVN/linux/config_cpusvn.cpp new file mode 100644 index 0000000000..a352d76286 --- /dev/null +++ b/sdk/simulation/SEConfigureCPUSVN/linux/config_cpusvn.cpp @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** +* File: config_cpusvn.cpp +* Description: +* Implemente the CPUSVN upgrade/downgrade/reset simulation +*/ + +#include "cpusvn_helper.h" +#include "cpusvn_util.h" +#include "se_trace.h" +#include "rts_sim.h" +#include "se_wrapper.h" + +#include +#include +#include +#include +#include +#include + +using namespace std; + +static void convert_cpusvn_to_string(sgx_cpu_svn_t &cpusvn, string &str) +{ + uint32_t buffer[4]; + memcpy_s(&buffer, sizeof(uint32_t)*4, &cpusvn, sizeof(sgx_cpu_svn_t)); + stringstream ss; + for(int i=0; i<4; i++) + { + buffer[i] = __builtin_bswap32(buffer[i]); + ss<\n" \ + "command:\n" \ + " -upgrade: Simulate CPUSVN upgrade\n"\ + " -downgrade: Simulate CPUSVN downgrade\n" \ + " -reset: Restore CPUSVN to the default value\n" \ + " -help: Print this help message\n" + +#endif + diff --git a/sdk/simulation/assembly/Makefile b/sdk/simulation/assembly/Makefile new file mode 100644 index 0000000000..7be00c3675 --- /dev/null +++ b/sdk/simulation/assembly/Makefile @@ -0,0 +1,38 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +.PHONY: all +all: + $(MAKE) -C linux + +.PHONY: clean +clean: + $(MAKE) -C linux clean diff --git a/sdk/simulation/assembly/linux/Makefile b/sdk/simulation/assembly/linux/Makefile new file mode 100644 index 0000000000..ace98da30f --- /dev/null +++ b/sdk/simulation/assembly/linux/Makefile @@ -0,0 +1,42 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../../buildenv.mk + +ASFLAGS += -Werror $(CFLAGS) +CPPFLAGS += -Werror -I$(COMMON_DIR)/inc/internal + +.PHONY: all +all: lowlib.o sgxsim.o + +.PHONY: clean +clean: + @$(RM) *.o diff --git a/sdk/simulation/assembly/linux/gnu_tls.h b/sdk/simulation/assembly/linux/gnu_tls.h new file mode 100644 index 0000000000..4539eece66 --- /dev/null +++ b/sdk/simulation/assembly/linux/gnu_tls.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef GNU_TLS_H__ +#define GNU_TLS_H__ + +#include + + +/* Type for the dtv. */ +typedef union +{ + size_t counter; + struct + { + void *val; + int is_static; + } pointer; +} dtv_t; + + +typedef struct +{ + void *tcb; /* Pointer to the TCB. Not necessarily the + thread descriptor used by libpthread. */ + dtv_t *dtv; + void *self; /* Pointer to the thread descriptor. */ + + /* We are not interested in the other fields. */ +} tcbhead_t; + +/* ------------------------------------------------------------ */ + +#if defined(__amd64) || defined(__amd64__) || defined (__x86_64) +/* x86_64 uses %fs as the thread register */ +#define GET_DTV() \ + ({ dtv_t* __dtv; \ + asm ("mov %%fs:%c1, %0" : "=r"(__dtv) \ + : "i" (offsetof (tcbhead_t, dtv))); \ + __dtv; }) + +#define GET_FS_GS_0() \ + ({ uintptr_t __orig; \ + asm volatile ("mov %%fs:0x0, %0" : "=r"(__orig)); \ + __orig; }) + +#define SET_FS_GS_0(val) \ + ({ asm volatile ("mov %0, %%fs:0x0" : :"r"(val));}) + +#elif defined(__i386) || defined(__i386__) +/* IA32 uses %gs as the thread register */ +#define GET_DTV() \ + ({ dtv_t* __dtv; \ + asm ("mov %%gs:%c1, %0" : "=r"(__dtv) \ + : "i" (offsetof (tcbhead_t, dtv))); \ + __dtv; }) + +#define GET_FS_GS_0() \ + ({ uintptr_t __orig; \ + asm volatile ("mov %%gs:0x0, %0" : "=r"(__orig)); \ + __orig; }) + +#define SET_FS_GS_0(val) \ + ({ asm volatile ("mov %0, %%gs:0x0" : :"r"(val));}) + +#endif + +#define read_dtv_val(dtv) (dtv->pointer.val) +#define set_dtv_val(dtv, v) \ + do { dtv->pointer.val = (void*)(size_t)v; } while (0) + + +#endif /* !GNU_TLS_H__ */ diff --git a/sdk/simulation/assembly/linux/lowlib.S b/sdk/simulation/assembly/linux/lowlib.S new file mode 100644 index 0000000000..def050a024 --- /dev/null +++ b/sdk/simulation/assembly/linux/lowlib.S @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "linux/linux-regs.h" + + .file "lowlib.S" + + .text + +DECLARE_LOCAL_FUNC get_bp + mov %xbp, %xax + ret + +#define reg_xax (0 * SE_WORDSIZE) +#define reg_xbx (1 * SE_WORDSIZE) +#define reg_xcx (2 * SE_WORDSIZE) +#define reg_xdx (3 * SE_WORDSIZE) +#define reg_xsi (4 * SE_WORDSIZE) +#define reg_xdi (5 * SE_WORDSIZE) +#define reg_xbp (6 * SE_WORDSIZE) +#define reg_xsp (7 * SE_WORDSIZE) +#define reg_xip (8 * SE_WORDSIZE) + +DECLARE_LOCAL_FUNC load_regs + mov naked_arg0, %xdx + mov reg_xax(%xdx), %xax + mov reg_xbx(%xdx), %xbx + mov reg_xcx(%xdx), %xcx + mov reg_xsi(%xdx), %xsi + mov reg_xdi(%xdx), %xdi + mov reg_xbp(%xdx), %xbp + mov reg_xsp(%xdx), %xsp + mov reg_xax(%xdx), %xax + push reg_xip(%xdx) + mov reg_xdx(%xdx), %xdx + ret diff --git a/sdk/simulation/assembly/linux/sgxsim.S b/sdk/simulation/assembly/linux/sgxsim.S new file mode 100644 index 0000000000..25901e501c --- /dev/null +++ b/sdk/simulation/assembly/linux/sgxsim.S @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sw_emu.h" + + .file "sgxsim.S" + + .text + +/* DoECREATE_SW, DoEADD_SW, DoEINIT_SW, DoEREMOVE, ... */ +DoSW ECREATE +DoSW EADD +DoSW EINIT +DoSW EREMOVE diff --git a/sdk/simulation/assembly/linux/sw_emu.h b/sdk/simulation/assembly/linux/sw_emu.h new file mode 100644 index 0000000000..e46a1fb25d --- /dev/null +++ b/sdk/simulation/assembly/linux/sw_emu.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: sw_emu.h + * Description: + * This file defined macros which hide hardware differences. + */ + +#ifndef _SW_EMU_H_ +#define _SW_EMU_H_ + +#include "linux/linux-regs.h" + +/*******************************************************************/ + +#define SE0func _SE0 +.type SE0func, @function +.protected SE0func + +#if defined LINUX64 + +.macro SE0_SW leafcode + movabsq $\leafcode, %rax + + pushq %rax + pushq %rbx + pushq %rcx + pushq %rdx + pushq %rsi + pushq %rdi + + /* 64bit ABI: parameter passing with registers */ + popq %r9 + popq %r8 + popq %rcx + popq %rdx + popq %rsi + popq %rdi + + call SE0func +.endm + +#elif defined LINUX32 + +.macro SE0_SW leafcode + movl $\leafcode, %eax + + pushl %edi + pushl %esi + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + + call SE0func + add $(SE_WORDSIZE * 6), %esp +.endm + +#endif + +/*******************************************************************/ + +.macro ECREATE_SW + SE0_SW SE_ECREATE +.endm + +.macro EADD_SW + SE0_SW SE_EADD +.endm + +.macro EINIT_SW + SE0_SW SE_EINIT +.endm + +.macro EREMOVE_SW + SE0_SW SE_EREMOVE +.endm + +/*******************************************************************/ + +/* This macro is used to generate simulation functions like: + * DoECREATE_SW, DoEADD_SW, ... +*/ +.macro DoSW inst +DECLARE_LOCAL_FUNC Do\()\inst\()_SW + SE_PROLOG + \inst\()_SW + SE_EPILOG +.endm + +#endif diff --git a/sdk/simulation/assembly/lowlib.h b/sdk/simulation/assembly/lowlib.h new file mode 100644 index 0000000000..4051b90f63 --- /dev/null +++ b/sdk/simulation/assembly/lowlib.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: lowlib.h + * Description: + * This file declared some functions written in assembly. + */ +#ifndef _LOW_LIB_H_ +#define _LOW_LIB_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +uintptr_t get_bp(void); + +typedef struct _enclu_regs_t +{ + uintptr_t xax; + uintptr_t xbx; + uintptr_t xcx; + uintptr_t xdx; + uintptr_t xsi; + uintptr_t xdi; + uintptr_t xbp; + uintptr_t xsp; + uintptr_t xip; +} enclu_regs_t; + +void load_regs(enclu_regs_t *regs); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/assembly/sgxsim.h b/sdk/simulation/assembly/sgxsim.h new file mode 100644 index 0000000000..99d3652f03 --- /dev/null +++ b/sdk/simulation/assembly/sgxsim.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: sgxsim.h + * Description: + * This file declared simulation routines written in assembly (for uRTS). + */ +#ifndef _SGX_SIM_H_ +#define _SGX_SIM_H_ + +#include "arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uintptr_t DoECREATE_SW(const page_info_t* pinfo); + +uintptr_t DoEADD_SW(const page_info_t* pi, void *epc_lin_addr); + +uintptr_t DoEINIT_SW(secs_t* secs, enclave_css_t *css, + token_t *launch); + +uintptr_t DoEREMOVE_SW(uintptr_t unused_xbx, void* epc_lin_addr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/driver_api/Makefile b/sdk/simulation/driver_api/Makefile new file mode 100644 index 0000000000..f6578dd84e --- /dev/null +++ b/sdk/simulation/driver_api/Makefile @@ -0,0 +1,52 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +SIM_DIR := $(CUR_DIR)/.. + +CPPFLAGS += $(ADDED_INC) +CPPFLAGS += -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal \ + -I$(SIM_DIR)/assembly/ \ + -I$(SIM_DIR)/uinst \ + -I$(SIM_DIR)/urtssim \ + -I$(SIM_DIR)/tinst \ + -I$(LINUX_PSW_DIR)/urts + +CXXFLAGS += -fPIC -Werror + +.PHONY: all +all: driver_api.o + +.PHONY: clean +clean: + @$(RM) *.o diff --git a/sdk/simulation/driver_api/driver_api.cpp b/sdk/simulation/driver_api/driver_api.cpp new file mode 100644 index 0000000000..45626b6e65 --- /dev/null +++ b/sdk/simulation/driver_api/driver_api.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include + +#include "se_wrapper.h" +#include "util.h" +#include "enclave.h" + +#include "enclave_mngr.h" +#include "sgxsim.h" +#include "driver_api.h" + +#define TO_STR(e) #e + +#define BUG_ON(cond, rv) do { \ + if (cond) { \ + SE_TRACE(SE_TRACE_DEBUG, "*** BUG ***: %s\n", TO_STR(cond)); \ + return rv; \ + } \ +} while (0) + + +/* Allocate linear address space. */ +int create_enclave(secs_t *secs, + sgx_enclave_id_t *enclave_id, + void **start_addr) +{ + CEnclaveSim *ce; + sec_info_t sinfo; + page_info_t pinfo; + + BUG_ON(secs == NULL, SGX_ERROR_UNEXPECTED); + BUG_ON(enclave_id == NULL, SGX_ERROR_UNEXPECTED); + BUG_ON(start_addr == NULL, SGX_ERROR_UNEXPECTED); + + memset(&sinfo, 0, sizeof(sinfo)); + sinfo.flags = SI_FLAGS_SECS; + + memset(&pinfo, 0, sizeof(pinfo)); + pinfo.src_page = secs; + pinfo.sec_info = &sinfo; + + ce = reinterpret_cast(DoECREATE_SW(&pinfo)); + if (ce == NULL) { + SE_TRACE(SE_TRACE_DEBUG, "out of memory.\n"); + return SGX_ERROR_OUT_OF_MEMORY; + } + + *start_addr = ce->get_secs()->base; + *enclave_id = ce->get_enclave_id(); + secs->base = *start_addr; + + return SGX_SUCCESS; +} + +int add_enclave_page(sgx_enclave_id_t enclave_id, + void *source, + size_t offset, + const sec_info_t &secinfo, + uint32_t attr) +{ + sec_info_t sinfo; + page_info_t pinfo; + CEnclaveMngr *mngr; + CEnclaveSim *ce; + + UNUSED(attr); + + mngr = CEnclaveMngr::get_instance(); + ce = mngr->get_enclave(enclave_id); + if (ce == NULL) { + SE_TRACE(SE_TRACE_DEBUG, + "enclave (id = %llu) not found.\n", + enclave_id); + return SGX_ERROR_INVALID_ENCLAVE_ID; + } + memset(&sinfo, 0, sizeof(sec_info_t)); + sinfo.flags = secinfo.flags; + if(memcmp(&sinfo, &secinfo, sizeof(sec_info_t))) + return SGX_ERROR_UNEXPECTED; + + memset(&pinfo, 0, sizeof(pinfo)); + pinfo.secs = ce->get_secs(); + pinfo.lin_addr = (char*)ce->get_secs()->base + offset; + pinfo.src_page = source; + pinfo.sec_info = &sinfo; + + /* Passing NULL here when there is no EPC mgmt. */ + return (int)DoEADD_SW(&pinfo, GET_PTR(void, ce->get_secs()->base, offset)); +} + +int init_enclave(sgx_enclave_id_t enclave_id, + enclave_css_t *enclave_css, + token_t *launch) +{ + CEnclaveMngr* mngr = CEnclaveMngr::get_instance(); + CEnclaveSim* ce = mngr->get_enclave(enclave_id); + + if (ce == NULL) { + SE_TRACE(SE_TRACE_DEBUG, + "enclave (id = %llu) not found.\n", + enclave_id); + return SGX_ERROR_INVALID_ENCLAVE_ID; + } + + return (int)DoEINIT_SW(ce->get_secs(), enclave_css, launch); +} + +int destroy_enclave(sgx_enclave_id_t enclave_id) +{ + CEnclaveMngr* mngr = CEnclaveMngr::get_instance(); + CEnclaveSim* ce = mngr->get_enclave(enclave_id); + if (ce == NULL) { + SE_TRACE(SE_TRACE_DEBUG, + "enclave (id = %llu) not found.\n", + enclave_id); + return SGX_ERROR_INVALID_ENCLAVE_ID; + } + + /* In simulation mode, all allocated pages will be freed upon the later + `delete ce'. Just remove the first page here. */ + DoEREMOVE_SW(0, ce->get_secs()->base); + + mngr->remove(ce); + delete ce; + + return SGX_SUCCESS; +} diff --git a/sdk/simulation/tae_service_sim/Makefile b/sdk/simulation/tae_service_sim/Makefile new file mode 100644 index 0000000000..d99e1faff5 --- /dev/null +++ b/sdk/simulation/tae_service_sim/Makefile @@ -0,0 +1,122 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR := ../../.. +include $(TOP_DIR)/buildenv.mk + +CFLAGS += -Werror $(ENCLAVE_CFLAGS) +CXXFLAGS += -Werror $(ENCLAVE_CXXFLAGS) + +INCLUDE += -I$(COMMON_DIR) \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(LINUX_EXTERNAL_DIR)/crypto_px/include \ + -I$(LINUX_PSW_DIR)/ae/inc \ + -I$(LINUX_PSW_DIR)/ae/inc/internal \ + -I$(TOP_DIR)/common/inc \ + -I$(TOP_DIR)/common/inc/internal + +TSERVICE_SIM_LIB := libsgx_tservice_sim.a +TAE_SERVICE_SIM_LIB := libtae_service_sim.a +EDLFILE := $(TOP_DIR)/common/inc/sgx_tae_service.edl + +TSEAL_LIB_DIR := $(LINUX_SDK_DIR)/tseal/linux +TSEAL_LIB := $(TSEAL_LIB_DIR)/libtSeal.a + +SE_LIB_DIR := $(LINUX_SDK_DIR)/selib/linux +SE_LIB := $(SE_LIB_DIR)/libselib.a + +EC_DH_LIB_DIR := $(LINUX_SDK_DIR)/ec_dh_lib +EC_DH_LIB := $(EC_DH_LIB_DIR)/libsgx_dh.a + +EDGER8R_DIR := $(LINUX_SDK_DIR)/edger8r/linux +EDGER8R := $(EDGER8R_DIR)/_build/Edger8r.native + +SRC := $(wildcard *.cpp) +SRC += $(TOP_DIR)/common/src/dh.cpp +C_OBJ := $(OBJ:.c=.o) +CXX_OBJ := $(SRC:.cpp=.o) + +OBJS := $(CXX_OBJ) $(C_OBJ) + +.PHONY: all +all: $(TSERVICE_SIM_LIB) | $(BUILD_DIR) + $(CP) $^ $| + +$(TAE_SERVICE_SIM_LIB): sgx_tae_service_t.h $(OBJS) + $(AR) rcsD $@ $(OBJS) + +$(TSERVICE_SIM_LIB): $(TAE_SERVICE_SIM_LIB) $(EC_DH_LIB) $(TSEAL_LIB) $(SE_LIB) + @$(MKDIR) $(BUILD_DIR)/.tservice_sim + @$(RM) -f $(BUILD_DIR)/.tservice_sim/* + cd $(BUILD_DIR)/.tservice_sim && $(AR) x $(EC_DH_LIB) + cd $(BUILD_DIR)/.tservice_sim && $(AR) x $(TSEAL_LIB) + cd $(BUILD_DIR)/.tservice_sim && $(AR) x $(SE_LIB) + cp $(TAE_SERVICE_SIM_LIB) $@ + $(AR) rsD $@ $(BUILD_DIR)/.tservice_sim/*.o + @$(RM) -rf $(BUILD_DIR)/.tservice_sim + +sgx_tae_service_t.h: $(EDLFILE) $(EDGER8R) + $(EDGER8R) --trusted --header-only --search-path $(TOP_DIR)/common/inc $< + +$(CXX_OBJ): %.o: %.cpp + $(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti $(INCLUDE) $(DEFINES) -c $< -o $@ + +$(C_OBJ): %.o: %.c + $(CC) $(CFLAGS) $(INCLUDE) $(DEFINES) -c $< -o $@ + +$(EDGER8R): + $(MAKE) -C $(EDGER8R_DIR) + +$(EC_DH_LIB): + $(MAKE) -C $(EC_DH_LIB_DIR) + +$(TSEAL_LIB): + $(MAKE) -C $(TSEAL_LIB_DIR) + +$(SE_LIB): + $(MAKE) -C $(SE_LIB_DIR) + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: clean +clean: + $(MAKE) -C $(EDGER8R_DIR) clean + $(MAKE) -C $(EC_DH_LIB_DIR) clean + $(MAKE) -C $(TSEAL_LIB_DIR) clean + $(MAKE) -C $(SE_LIB_DIR) clean + @$(RM) *.o $(TSERVICE_SIM_LIB) $(TAE_SERVICE_SIM_LIB) $(BUILD_DIR)/$(TSERVICE_SIM_LIB) + @$(RM) $(COMMON_DIR)/src/*.o + @$(RM) sgx_tae_service_*.c + @$(RM) sgx_tae_service_*.h + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/simulation/tae_service_sim/tae_service_sim.cpp b/sdk/simulation/tae_service_sim/tae_service_sim.cpp new file mode 100644 index 0000000000..ab2f45acaa --- /dev/null +++ b/sdk/simulation/tae_service_sim/tae_service_sim.cpp @@ -0,0 +1,485 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +//tae_service_sim.cpp : Defines the exported functions +// + +#include "sgx_tae_service.h" +#include "tae_service_internal.h" +#include "pse_types.h" +#include "stdlib.h" +#include "string.h" +#include "sgx_spinlock.h" +#include "sgx_tae_service_t.h" + +#define RETRY_TIMES 2 +#define DEFAULT_VMC_ATTRIBUTE_MASK 0xFFFFFFFFFFFFFFCB +#define DEFAULT_VMC_XFRM_MASK 0x0 + +#ifdef _DEBUG +//wait for 10min at most for debug +#define DEFAULT_AESM_TIMEOUT 600000 +#else +//wait for 10sec at most +#define DEFAULT_AESM_TIMEOUT 10000 +#endif + +static sgx_spinlock_t g_spin_lock; +static bool g_b_session_established = false; + +sgx_status_t sgx_create_pse_session() +{ + sgx_spin_lock(&g_spin_lock); + if(!g_b_session_established) + g_b_session_established = true; + sgx_spin_unlock(&g_spin_lock); + return SGX_SUCCESS; +} + +sgx_status_t sgx_close_pse_session() +{ + sgx_spin_lock(&g_spin_lock); + if(g_b_session_established) + g_b_session_established = false; + sgx_spin_unlock(&g_spin_lock); + return SGX_SUCCESS; +} + +sgx_status_t sgx_get_ps_sec_prop(sgx_ps_sec_prop_desc_t *p_security_property) +{ + sgx_status_t ret = SGX_SUCCESS; + if(!p_security_property) + return SGX_ERROR_INVALID_PARAMETER; + if (!g_b_session_established){ + return SGX_ERROR_AE_SESSION_INVALID; + } + else + { + se_ps_sec_prop_desc_internal_t *p_security_property_internal = (se_ps_sec_prop_desc_internal_t*)p_security_property; + p_security_property_internal->desc_type = 0; + p_security_property_internal->pse_miscselect = 0; + p_security_property_internal->reserved1 = 0; + memset(p_security_property_internal->reserved2, 0, sizeof(p_security_property_internal->reserved2)); + p_security_property_internal->pse_prod_id = 2; + p_security_property_internal->pse_isvsvn = 1; + p_security_property_internal->pse_attributes.flags = SGX_FLAGS_INITTED; + p_security_property_internal->pse_attributes.xfrm = SGX_XFRM_LEGACY; + memset(&(p_security_property_internal->pse_mr_signer), 0xEE, + sizeof(p_security_property_internal->pse_mr_signer)); + p_security_property_internal->cse_sec_prop.gid_cse = 0; + p_security_property_internal->cse_sec_prop.prvrl_version = 1; + p_security_property_internal->cse_sec_prop.sigrl_version = 1; + p_security_property_internal->cse_sec_prop.sec_info_type = 0; + memset(&p_security_property_internal->cse_sec_prop.ca_id_cse, 0, sizeof(p_security_property_internal->cse_sec_prop.ca_id_cse)); + memset(&p_security_property_internal->cse_sec_prop.sec_info, 0, sizeof(p_security_property_internal->cse_sec_prop.sec_info)); + } + return ret; +} + +sgx_status_t sgx_get_trusted_time +( + sgx_time_t *p_current_time, + sgx_time_source_nonce_t *p_time_source_nonce) +{ + if(!p_current_time || !p_time_source_nonce) + return SGX_ERROR_INVALID_PARAMETER; + if (!g_b_session_established){ + return SGX_ERROR_AE_SESSION_INVALID; + } + + pse_message_t *p_req_msg = + (pse_message_t *)malloc(PSE_TIMER_READ_REQ_SIZE); + if(!p_req_msg){ + return SGX_ERROR_OUT_OF_MEMORY; + } + pse_message_t *p_resp_msg = + (pse_message_t *)malloc(PSE_TIMER_READ_RESP_SIZE); + if(!p_resp_msg){ + free(p_req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + p_req_msg->exp_resp_size = sizeof(pse_timer_read_resp_t); + p_req_msg->payload_size = sizeof(pse_timer_read_req_t); + + pse_timer_read_req_t *p_timer_req + = (pse_timer_read_req_t *)p_req_msg->payload; + p_timer_req->req_hdr.service_id = PSE_TRUSTED_TIME_SERVICE; + p_timer_req->req_hdr.service_cmd = PSE_TIMER_READ; + + pse_timer_read_resp_t *p_timer_resp + = (pse_timer_read_resp_t *)p_resp_msg->payload; + + sgx_status_t status = SGX_SUCCESS; + sgx_status_t ret = SGX_SUCCESS; + int retry = RETRY_TIMES; + do { + status = invoke_service_ocall(&ret, + (uint8_t *)p_req_msg, + PSE_TIMER_READ_REQ_SIZE, + (uint8_t *)p_resp_msg, + PSE_TIMER_READ_RESP_SIZE, + DEFAULT_AESM_TIMEOUT); + if(status != SGX_SUCCESS || ret != SGX_SUCCESS){ + status = SGX_ERROR_UNEXPECTED; + continue; + } + + if(p_timer_resp->resp_hdr.service_id != PSE_TRUSTED_TIME_SERVICE + || p_timer_resp->resp_hdr.service_cmd != PSE_TIMER_READ + || p_timer_resp->resp_hdr.status != PSE_SUCCESS){ + status = SGX_ERROR_UNEXPECTED; + } else { + memcpy(p_current_time, &p_timer_resp->timestamp, sizeof(sgx_time_t)); + memcpy(p_time_source_nonce, p_timer_resp->time_source_nonce, + sizeof(sgx_time_source_nonce_t)); + status = SGX_SUCCESS; + break; + } + } while(retry--); + free(p_req_msg); + free(p_resp_msg); + return status; +} + +sgx_status_t sgx_create_monotonic_counter_ex( + uint16_t owner_policy, + const sgx_attributes_t* owner_attribute_mask, + sgx_mc_uuid_t *p_counter_uuid, + uint32_t *p_counter_value) +{ + if(!p_counter_value || !p_counter_uuid || !owner_attribute_mask){ + return SGX_ERROR_INVALID_PARAMETER; + } + if (0!= (~(MC_POLICY_SIGNER | MC_POLICY_ENCLAVE) & owner_policy) + || 0 == ((MC_POLICY_SIGNER | MC_POLICY_ENCLAVE)& owner_policy)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if (!g_b_session_established){ + return SGX_ERROR_AE_SESSION_INVALID; + } + + pse_message_t *p_req_msg = (pse_message_t *)malloc(PSE_CREATE_MC_REQ_SIZE); + if(!p_req_msg){ + return SGX_ERROR_OUT_OF_MEMORY; + } + pse_message_t *p_resp_msg = (pse_message_t *)malloc(PSE_CREATE_MC_RESP_SIZE); + if(!p_resp_msg){ + free(p_req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + p_req_msg->exp_resp_size = sizeof(pse_mc_create_resp_t); + p_req_msg->payload_size = sizeof(pse_mc_create_req_t); + + pse_mc_create_req_t *p_mc_req + = (pse_mc_create_req_t *)p_req_msg->payload; + p_mc_req->req_hdr.service_id = PSE_MC_SERVICE; + p_mc_req->req_hdr.service_cmd = PSE_MC_CREATE; + p_mc_req->policy = owner_policy; + memcpy(p_mc_req->attr_mask , owner_attribute_mask, sizeof(p_mc_req->attr_mask)); + + pse_mc_create_resp_t *p_mc_resp + = (pse_mc_create_resp_t *)p_resp_msg->payload; + + sgx_status_t status = SGX_SUCCESS; + sgx_status_t ret = SGX_SUCCESS; + int retry = RETRY_TIMES; + do { + sgx_spin_lock(&g_spin_lock); + status = invoke_service_ocall(&ret, + (uint8_t *)p_req_msg, + PSE_CREATE_MC_REQ_SIZE, + (uint8_t *)p_resp_msg, + PSE_CREATE_MC_RESP_SIZE, + DEFAULT_AESM_TIMEOUT); + sgx_spin_unlock(&g_spin_lock); + if(status != SGX_SUCCESS || ret != SGX_SUCCESS){ + status = SGX_ERROR_UNEXPECTED; + continue; + } + + if(p_mc_resp->resp_hdr.service_id != PSE_MC_SERVICE + || p_mc_resp->resp_hdr.service_cmd != PSE_MC_CREATE + || p_mc_resp->resp_hdr.status != PSE_SUCCESS){ + status = SGX_ERROR_UNEXPECTED; + } else { + memcpy(p_counter_uuid->counter_id, + &p_mc_resp->counter_id, + sizeof(p_counter_uuid->counter_id)); + memcpy(p_counter_uuid->nonce, + &p_mc_resp->nonce, + sizeof(p_counter_uuid->nonce)); + *p_counter_value = 0; + status = SGX_SUCCESS; + break; + } + } while(retry--); + free(p_req_msg); + free(p_resp_msg); + return status; +} + +sgx_status_t sgx_increment_monotonic_counter( + const sgx_mc_uuid_t *p_counter_uuid, + uint32_t *p_counter_value) +{ + if(!p_counter_value || !p_counter_uuid ){ + return SGX_ERROR_INVALID_PARAMETER; + } + if (!g_b_session_established){ + return SGX_ERROR_AE_SESSION_INVALID; + } + + pse_message_t *p_req_msg = (pse_message_t *)malloc(PSE_INC_MC_REQ_SIZE); + if(!p_req_msg){ + return SGX_ERROR_OUT_OF_MEMORY; + } + pse_message_t *p_resp_msg = (pse_message_t *)malloc(PSE_INC_MC_RESP_SIZE); + if(!p_resp_msg){ + free(p_req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + p_req_msg->exp_resp_size = sizeof(pse_mc_inc_resp_t); + p_req_msg->payload_size = sizeof(pse_mc_inc_req_t); + + pse_mc_inc_req_t *p_mc_req + = (pse_mc_inc_req_t *)p_req_msg->payload; + memcpy(p_mc_req->counter_id, + p_counter_uuid->counter_id, + sizeof(p_mc_req->counter_id)); + memcpy(p_mc_req->nonce, + p_counter_uuid->nonce, + sizeof(p_mc_req->nonce)); + p_mc_req->req_hdr.service_id = PSE_MC_SERVICE; + p_mc_req->req_hdr.service_cmd = PSE_MC_INC; + + pse_mc_inc_resp_t *p_mc_resp + = (pse_mc_inc_resp_t *)p_resp_msg->payload; + + sgx_status_t status = SGX_SUCCESS; + sgx_status_t ret = SGX_SUCCESS; + int retry = RETRY_TIMES; + do { + sgx_spin_lock(&g_spin_lock); + status = invoke_service_ocall(&ret, + (uint8_t *)p_req_msg, + PSE_INC_MC_REQ_SIZE, + (uint8_t *)p_resp_msg, + PSE_INC_MC_RESP_SIZE, + DEFAULT_AESM_TIMEOUT); + sgx_spin_unlock(&g_spin_lock); + if(status != SGX_SUCCESS || ret != SGX_SUCCESS){ + if(SGX_ERROR_MC_NOT_FOUND != ret) + status = SGX_ERROR_UNEXPECTED; + else + status = SGX_ERROR_MC_NOT_FOUND; + continue; + } + + if(p_mc_resp->resp_hdr.service_id != PSE_MC_SERVICE + || p_mc_resp->resp_hdr.service_cmd != PSE_MC_INC + || p_mc_resp->resp_hdr.status != PSE_SUCCESS){ + if(PSE_ERROR_MC_NOT_FOUND == p_mc_resp->resp_hdr.status) + status = SGX_ERROR_MC_NOT_FOUND; + else + status = SGX_ERROR_UNEXPECTED; + } else + { + *p_counter_value = p_mc_resp->counter_value; + status = SGX_SUCCESS; + break; + } + } while(retry--); + free(p_req_msg); + free(p_resp_msg); + return status; +} + +sgx_status_t sgx_read_monotonic_counter( + const sgx_mc_uuid_t *p_counter_uuid, + uint32_t *p_counter_value) +{ + if(!p_counter_value || !p_counter_uuid){ + return SGX_ERROR_INVALID_PARAMETER; + } + if (!g_b_session_established){ + return SGX_ERROR_AE_SESSION_INVALID; + } + + pse_message_t *p_req_msg = (pse_message_t *)malloc(PSE_READ_MC_REQ_SIZE); + if(!p_req_msg){ + return SGX_ERROR_OUT_OF_MEMORY; + } + pse_message_t *p_resp_msg = (pse_message_t *)malloc(PSE_READ_MC_RESP_SIZE); + if(!p_resp_msg){ + free(p_req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + p_req_msg->exp_resp_size = sizeof(pse_mc_read_resp_t); + p_req_msg->payload_size = sizeof(pse_mc_read_req_t); + + pse_mc_read_req_t *p_mc_req + = (pse_mc_read_req_t *)p_req_msg->payload; + memcpy(p_mc_req->counter_id, + p_counter_uuid->counter_id, + sizeof(p_mc_req->counter_id)); + memcpy(p_mc_req->nonce, + p_counter_uuid->nonce, + sizeof(p_mc_req->nonce)); + p_mc_req->req_hdr.service_id = PSE_MC_SERVICE; + p_mc_req->req_hdr.service_cmd = PSE_MC_READ; + + pse_mc_read_resp_t *p_mc_resp + = (pse_mc_read_resp_t *)p_resp_msg->payload; + + sgx_status_t status = SGX_SUCCESS; + sgx_status_t ret = SGX_SUCCESS; + int retry = RETRY_TIMES; + do { + sgx_spin_lock(&g_spin_lock); + status = invoke_service_ocall(&ret, + (uint8_t *)p_req_msg, + PSE_READ_MC_REQ_SIZE, + (uint8_t *)p_resp_msg, + PSE_READ_MC_RESP_SIZE, + DEFAULT_AESM_TIMEOUT); + sgx_spin_unlock(&g_spin_lock); + if(status != SGX_SUCCESS || ret != SGX_SUCCESS){ + if(SGX_ERROR_MC_NOT_FOUND != ret) + status = SGX_ERROR_UNEXPECTED; + else + status = SGX_ERROR_MC_NOT_FOUND; + continue; + } + + if(p_mc_resp->resp_hdr.service_id != PSE_MC_SERVICE + || p_mc_resp->resp_hdr.service_cmd != PSE_MC_READ + || p_mc_resp->resp_hdr.status != PSE_SUCCESS){ + if(PSE_ERROR_MC_NOT_FOUND == p_mc_resp->resp_hdr.status) + status = SGX_ERROR_MC_NOT_FOUND; + else + status = SGX_ERROR_UNEXPECTED; + } else { + *p_counter_value = p_mc_resp->counter_value; + status = SGX_SUCCESS; + break; + } + } while(retry--); + free(p_req_msg); + free(p_resp_msg); + return status; +} + +sgx_status_t sgx_create_monotonic_counter( + sgx_mc_uuid_t *p_counter_uuid, + uint32_t *p_counter_value) +{ + //Default attribute mask + sgx_attributes_t attr_mask; + attr_mask.flags = DEFAULT_VMC_ATTRIBUTE_MASK; + attr_mask.xfrm = DEFAULT_VMC_XFRM_MASK; + + return sgx_create_monotonic_counter_ex(MC_POLICY_SIGNER, + &attr_mask, + p_counter_uuid, + p_counter_value); +} + +sgx_status_t sgx_destroy_monotonic_counter(const sgx_mc_uuid_t *p_counter_uuid) +{ + if(!p_counter_uuid){ + return SGX_ERROR_INVALID_PARAMETER; + } + if (!g_b_session_established){ + return SGX_ERROR_AE_SESSION_INVALID; + } + + pse_message_t *p_req_msg = (pse_message_t *)malloc(PSE_DEL_MC_REQ_SIZE); + if(!p_req_msg){ + return SGX_ERROR_OUT_OF_MEMORY; + } + pse_message_t *p_resp_msg = (pse_message_t *)malloc(PSE_DEL_MC_RESP_SIZE); + if(!p_resp_msg){ + free(p_req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + p_req_msg->exp_resp_size = sizeof(pse_mc_del_resp_t); + p_req_msg->payload_size = sizeof(pse_mc_del_req_t); + + pse_mc_del_req_t *p_mc_req + = (pse_mc_del_req_t *)p_req_msg->payload; + memcpy(p_mc_req->counter_id, + p_counter_uuid->counter_id, + sizeof(p_mc_req->counter_id)); + memcpy(p_mc_req->nonce, + p_counter_uuid->nonce, + sizeof(p_mc_req->nonce)); + p_mc_req->req_hdr.service_id = PSE_MC_SERVICE; + p_mc_req->req_hdr.service_cmd = PSE_MC_DEL; + + pse_mc_del_resp_t *p_mc_resp + = (pse_mc_del_resp_t *)p_resp_msg->payload; + + sgx_status_t status = SGX_SUCCESS; + sgx_status_t ret = SGX_SUCCESS; + int retry = RETRY_TIMES; + do { + status = invoke_service_ocall(&ret, + (uint8_t *)p_req_msg, + PSE_DEL_MC_REQ_SIZE, + (uint8_t *)p_resp_msg, + PSE_DEL_MC_RESP_SIZE, + DEFAULT_AESM_TIMEOUT); + if(status != SGX_SUCCESS || ret != SGX_SUCCESS){ + if(SGX_ERROR_MC_NOT_FOUND != ret) + status = SGX_ERROR_UNEXPECTED; + else + status = SGX_ERROR_MC_NOT_FOUND; + continue; + } + + if(p_mc_resp->resp_hdr.service_id != PSE_MC_SERVICE + || p_mc_resp->resp_hdr.service_cmd != PSE_MC_DEL + || p_mc_resp->resp_hdr.status != PSE_SUCCESS){ + if(PSE_ERROR_MC_NOT_FOUND == p_mc_resp->resp_hdr.status) + status = SGX_ERROR_MC_NOT_FOUND; + else + status = SGX_ERROR_UNEXPECTED; + } else { + status = SGX_SUCCESS; + break; + } + } while(retry--); + free(p_req_msg); + free(p_resp_msg); + return status; +} + diff --git a/sdk/simulation/tinst/Makefile b/sdk/simulation/tinst/Makefile new file mode 100644 index 0000000000..8b45aa092e --- /dev/null +++ b/sdk/simulation/tinst/Makefile @@ -0,0 +1,63 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +SIM_DIR := $(CUR_DIR)/.. + +CPPFLAGS += $(ADDED_INC) # for unbuntu 11 and later version +CPPFLAGS += -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(SIM_DIR)/assembly/ \ + -I$(SIM_DIR)/assembly/linux \ + -I$(SIM_DIR)/uinst/ \ + -I$(LINUX_SDK_DIR)/selib + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-exceptions -fno-rtti + +LIBSESIMU_T := libsesimu_t.a + +OBJS := deriv.o t_instructions.o + +.PHONY:all +all: $(LIBSESIMU_T) + +$(LIBSESIMU_T): $(OBJS) + $(AR) rcs $@ $^ + +# Explicitly disable optimization for 't_instructions.cpp', +# since the '_SE3' function has assumptions on stack layout. +t_instructions.o: CXXFLAGS += -O0 + +.PHONY: clean +clean: + @$(RM) $(OBJS) $(LIBSESIMU_T) diff --git a/sdk/simulation/tinst/deriv.cpp b/sdk/simulation/tinst/deriv.cpp new file mode 100644 index 0000000000..de2425911d --- /dev/null +++ b/sdk/simulation/tinst/deriv.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "deriv.h" +#include "sgx_tcrypto.h" + +// The built-in seal key in simulation mode +static const uint8_t BASE_SEAL_KEY[] = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, +}; + +// The built-in report key in simulation mode +static const uint8_t BASE_REPORT_KEY[] = { + 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, + 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, +}; + +// The built-in license key in simulation mode +static const uint8_t BASE_LICENSE_KEY[] = { + 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, + 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, +}; + +// The built-in provision key in simulation mode +static const uint8_t BASE_PROVISION_KEY[] = { + 0xbb, 0xaa, 0xbb, 0xee, 0xff, 0x00, 0x00, 0xdd, + 0xbb, 0xaa, 0xbb, 0xee, 0xff, 0x00, 0x00, 0xdd, +}; + +// The built-in provision-seal key in simulation mode +static const uint8_t BASE_PROV_SEAL_KEY[] = { + 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, + 0x4e, 0x53, 0x45, 0x41, 0x4c, 0x4b, 0x45, 0x59, +}; + +const uint8_t* get_base_key(uint16_t key_name) +{ + switch (key_name) { + case SGX_KEYSELECT_SEAL: return BASE_SEAL_KEY; + case SGX_KEYSELECT_REPORT: return BASE_REPORT_KEY; + case SGX_KEYSELECT_LICENSE: return BASE_LICENSE_KEY; + case SGX_KEYSELECT_PROVISION: return BASE_PROVISION_KEY; + case SGX_KEYSELECT_PROVISION_SEAL: return BASE_PROV_SEAL_KEY; + } + + // Should not come here - error should have been reported + // when the key name is not supported in the caller. + return (uint8_t*)0; +} + +// Compute the CMAC of derivation data with corresponding base key +// and save it to `okey'. +void derive_key(const derivation_data_t* dd, sgx_key_128bit_t okey) +{ + sgx_rijndael128_cmac_msg((const sgx_cmac_128bit_key_t*)(get_base_key(dd->key_name)), + dd->ddbuf, dd->size, (sgx_cmac_128bit_tag_t*)okey); +} + +// Compute the CMAC of a `buf' with a given `key'. +void cmac(const sgx_key_128bit_t *key, const uint8_t* buf, int buf_len, sgx_mac_t* cmac) +{ + sgx_rijndael128_cmac_msg((const sgx_cmac_128bit_key_t*)key, buf, buf_len, cmac); +} diff --git a/sdk/simulation/tinst/deriv.h b/sdk/simulation/tinst/deriv.h new file mode 100644 index 0000000000..ca629a7deb --- /dev/null +++ b/sdk/simulation/tinst/deriv.h @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* deriv.h - it defines C++ interfaces for derivation data. */ +#ifndef DERIVE_H__ +#define DERIVE_H__ + +#include "arch.h" +#include "sgx_key.h" +#include "sgx_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define OWNEREPOCH_SIZE 16 +typedef uint8_t se_owner_epoch_t[OWNEREPOCH_SIZE]; + +/* Derive data for seal key */ +typedef struct { + uint16_t key_name; /* should always be 'SGX_KEYSELECT_SEAL' */ + sgx_attributes_t tmp_attr; + sgx_attributes_t attribute_mask; /* attribute mask from KEYREQUEST */ + se_owner_epoch_t csr_owner_epoch; + sgx_cpu_svn_t cpu_svn; /* CPUSVN from KEYREQUEST */ + sgx_isv_svn_t isv_svn; /* ISVSVN from KEYREQUEST */ + sgx_prod_id_t isv_prod_id; /* ISV PRODID from SECS */ + sgx_measurement_t mrenclave; + sgx_measurement_t mrsigner; + sgx_key_id_t key_id; /* KEYID from KEYREQUEST */ +} dd_seal_key_t; + +/* Derive data for report key */ +typedef struct { + uint16_t key_name; /* should always be 'SGX_KEYSELECT_REPORT' */ + sgx_attributes_t attributes; /* attributes from SECS */ + se_owner_epoch_t csr_owner_epoch; + sgx_measurement_t mrenclave; + sgx_cpu_svn_t cpu_svn; /* CPUSVN from CPUSVN register */ + sgx_key_id_t key_id; /* KEYID from KEYREQUEST */ +} dd_report_key_t; + +/* Derive data for license key */ +typedef struct { + uint16_t key_name; /* should always be 'SGX_KEYSELECT_LICENSE' */ + sgx_attributes_t attributes; /* attributes from SECS */ + se_owner_epoch_t csr_owner_epoch; + sgx_cpu_svn_t cpu_svn; /* CPUSVN from KEYREQUEST */ + sgx_isv_svn_t isv_svn; /* ISVSVN from KEYREQUEST */ + sgx_prod_id_t isv_prod_id; /* ISV PRODID from SECS */ + sgx_key_id_t key_id; /* KEYID from KEYREQUEST */ +} dd_license_key_t; + +/* Derive data for provision key */ +typedef struct { + uint16_t key_name; /* should always be 'SGX_KEYSELECT_PROVISION' */ + sgx_attributes_t tmp_attr; + sgx_attributes_t attribute_mask; /* attribute mask from KEYREQUEST */ + sgx_cpu_svn_t cpu_svn; /* CPUSVN from KEYREQUEST */ + sgx_isv_svn_t isv_svn; /* ISVSVN from KEYREQUEST */ + sgx_prod_id_t isv_prod_id; /* ISV PRODID from SECS */ + sgx_measurement_t mrsigner; +} dd_provision_key_t; + +/* The derivation data. */ +typedef struct { + int size; /* the size of derivation data */ + + union { + /* key_name is the first field of all the following derivation data */ + uint16_t key_name; + uint8_t ddbuf[1]; + + dd_seal_key_t ddsk; + dd_report_key_t ddrk; + dd_license_key_t ddlk; + dd_provision_key_t ddpk; + }; +} derivation_data_t; + +/** + * Get the internal CPU keys. + * + * @param key_name - the key name + * @return NULL for invalid key name. + */ +const uint8_t* get_base_key(uint16_t key_name); + +/** The internal routine to derive requested key. Parameter checking + * is done in the caller. + * + * @param dd - the pointer to derive data + * @param okey - the output derived key + */ +void derive_key(const derivation_data_t* dd, sgx_key_128bit_t okey); + +/** Compute the CMAC of a buffer. + * @param key - the key used to compute the CMAC + * @param buf - the buf to be digested + * @param buf_len - length of the buffer in Bytes + * @param cmac - the pointer to the output buffer to store CMAC + */ +void cmac(const sgx_key_128bit_t *key, const uint8_t* buf, int buf_len, sgx_mac_t* cmac); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/tinst/rts_sim.h b/sdk/simulation/tinst/rts_sim.h new file mode 100644 index 0000000000..a9c56eeb94 --- /dev/null +++ b/sdk/simulation/tinst/rts_sim.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _RTS_SIM_H_ +#define _RTS_SIM_H_ + +#include "arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +const sgx_cpu_svn_t DEFAULT_CPUSVN = { + { + 0x48, 0x20, 0xf3, 0x37, 0x6a, 0xe6, 0xb2, 0xf2, + 0x03, 0x4d, 0x3b, 0x7a, 0x4b, 0x48, 0xa7, 0x78 + } +}; +const sgx_cpu_svn_t UPGRADED_CPUSVN = { + { + 0x53, 0x39, 0xae, 0x8c, 0x93, 0xae, 0x8f, 0x3c, + 0xe4, 0x32, 0xdb, 0x92, 0x4d, 0x0f, 0x07, 0x33 + } +}; + +const sgx_cpu_svn_t DOWNGRADED_CPUSVN = { + { + 0x64, 0xea, 0x4f, 0x3f, 0xa0, 0x03, 0x0c, 0x36, + 0x38, 0x3c, 0x32, 0x2d, 0x4f, 0x3a, 0x8d, 0x4f + } +}; + + +typedef struct _global_data_sim_t +{ + secs_t* secs_ptr; + sgx_cpu_svn_t cpusvn_sim; + uint32_t seed; /* to initialize the PRNG */ +} global_data_sim_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/tinst/t_instructions.cpp b/sdk/simulation/tinst/t_instructions.cpp new file mode 100644 index 0000000000..8e5c861220 --- /dev/null +++ b/sdk/simulation/tinst/t_instructions.cpp @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// t_instructions.cpp -- It simulates Enclave instructions. +#include +#include + +#include "arch.h" +#include "util.h" +#include "lowlib.h" +#include "sgx_trts.h" +#include "trts_inst.h" + +#include "deriv.h" +#include "t_instructions.h" +#include "td_mngr.h" + +//////////////////////////////////////////////////////////////////////// +global_data_sim_t g_global_data_sim = {NULL, {{0}}, 0}; + +#define GP() abort() +#define GP_ON(cond) do { if (unlikely(cond)) GP(); } while (0) + +//////////////////////////////////////////////////////////////////////// +// Simulation for EGETKEY +//////////////////////////////////////////////////////////////////////// + +// The hard-coded OwnerEpoch. +static const se_owner_epoch_t SIMU_OWNER_EPOCH_MSR = { + 0x54, 0x48, 0x49, 0x53, 0x49, 0x53, 0x4f, 0x57, + 0x4e, 0x45, 0x52, 0x45, 0x50, 0x4f, 0x43, 0x48, +}; + + +#define check_cpu_svn(kr) do { \ + if(memcmp(&kr->cpu_svn, &UPGRADED_CPUSVN, sizeof(UPGRADED_CPUSVN)) && \ + memcmp(&kr->cpu_svn, &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)) && \ + memcmp(&kr->cpu_svn, &DOWNGRADED_CPUSVN, sizeof(DOWNGRADED_CPUSVN))){ \ + return EGETKEY_INVALID_CPUSVN; \ + } \ + if ( (!memcmp(&g_global_data_sim.cpusvn_sim, &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)) && \ + !memcmp(&kr->cpu_svn, &UPGRADED_CPUSVN, sizeof(UPGRADED_CPUSVN))) || \ + (!memcmp(&g_global_data_sim.cpusvn_sim, &DOWNGRADED_CPUSVN, sizeof(DOWNGRADED_CPUSVN)) && \ + memcmp(&kr->cpu_svn, &DOWNGRADED_CPUSVN, sizeof(DOWNGRADED_CPUSVN)))){ \ + return EGETKEY_INVALID_CPUSVN; \ + } \ + } while(0) + +#define check_isv_svn(kr, secs) do { \ + if (kr->isv_svn > secs->isv_svn) { \ + return EGETKEY_INVALID_ISVSVN; \ + } \ +} while(0) + +#define check_attr_flag(secs, flag) do { \ + if ((secs->attributes.flags & flag) == 0) { \ + return EGETKEY_INVALID_ATTRIBUTE; \ + } \ +} while(0) + + +// The hardware EGETKEY instruction will set ZF on failure. +// +// In simulation mode, we can not guarentee that the ZF is always set +// between _EGETKEY ending its life and tRTS testing ZF. Since there +// are additional assembly code in between. +// +// In simulation mode, we check return code instead of ZF. +// c.f. do_egetkey() in trts/linux/trts_pic.S + +static int _EGETKEY(sgx_key_request_t* kr, sgx_key_128bit_t okey) +{ + // check alignment of KEYREQUEST + GP_ON(((size_t)kr & (KEY_REQUEST_ALIGN_SIZE - 1)) != 0); + + // check to see if KEYREQEUST is inside the current enclave + GP_ON(!sgx_is_within_enclave(kr, sizeof(sgx_key_request_t))); + + // check alignment of OUTPUTDATA + GP_ON(((size_t)okey & (KEY_ALIGN_SIZE - 1)) != 0); + + // check to see if OUTPUTDATA is inside the current enclave + GP_ON(!sgx_is_within_enclave(okey, sizeof(sgx_key_128bit_t))); + + // check reserved bits are not set + GP_ON((kr->key_policy & ~(SGX_KEYPOLICY_MRENCLAVE | SGX_KEYPOLICY_MRSIGNER)) != 0); + + // check to see if reserved space in KEYREQUEST are valid + const uint8_t* u8ptr = (uint8_t *)(&(kr->reserved1)); + for (unsigned i = 0; i < sizeof(kr->reserved1); ++i) + GP_ON(u8ptr[i] != (uint8_t)0); + + u8ptr = (uint8_t *)(&(kr->reserved2)); + for (unsigned i = 0; i < sizeof(kr->reserved2); ++i) + GP_ON(u8ptr[i] != (uint8_t)0); + + secs_t* cur_secs = g_global_data_sim.secs_ptr; + sgx_attributes_t tmp_attr; + derivation_data_t dd; + + memset(&dd, 0, sizeof(dd)); + dd.key_name = kr->key_name; + + // Determine which enclave attributes that must be included in the key. + // Attributes that must always be included INIT & DEBUG. + memset(&tmp_attr, 0, sizeof(tmp_attr)); + tmp_attr.flags = kr->attribute_mask.flags | SGX_FLAGS_INITTED | SGX_FLAGS_DEBUG; + tmp_attr.flags &= cur_secs->attributes.flags; + tmp_attr.xfrm = kr->attribute_mask.xfrm & cur_secs->attributes.xfrm; + // HW supports CPUSVN to be set as 0. + // To be consistent with HW behaviour, we replace the cpusvn as DEFAULT_CPUSVN if the input cpusvn is 0. + if(!memcmp(&kr->cpu_svn, &dd.ddpk.cpu_svn, sizeof(sgx_cpu_svn_t))) + { + memcpy(&kr->cpu_svn, &DEFAULT_CPUSVN, sizeof(sgx_cpu_svn_t)); + } + + switch (kr->key_name) { + case SGX_KEYSELECT_SEAL: + check_isv_svn(kr, cur_secs); + check_cpu_svn(kr); + + // assemble derivation data + dd.size = sizeof(dd_seal_key_t); + if (kr->key_policy & SGX_KEYPOLICY_MRENCLAVE) { + memcpy(&dd.ddsk.mrenclave, &cur_secs->mr_enclave, sizeof(sgx_measurement_t)); + } + + if (kr->key_policy & SGX_KEYPOLICY_MRSIGNER) { + memcpy(&dd.ddsk.mrsigner, &cur_secs->mr_signer, sizeof(sgx_measurement_t)); + } + + memcpy(&dd.ddsk.tmp_attr, &tmp_attr, sizeof(sgx_attributes_t)); + memcpy(&dd.ddsk.attribute_mask, &kr->attribute_mask, sizeof(sgx_attributes_t)); + memcpy(dd.ddsk.csr_owner_epoch, SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t)); + memcpy(&dd.ddsk.cpu_svn,&kr->cpu_svn,sizeof(sgx_cpu_svn_t)); + dd.ddsk.isv_svn = kr->isv_svn; + dd.ddsk.isv_prod_id = cur_secs->isv_prod_id; + memcpy(&dd.ddsk.key_id, &kr->key_id, sizeof(sgx_key_id_t)); + break; + + case SGX_KEYSELECT_REPORT: + // assemble derivation data + dd.size = sizeof(dd_report_key_t); + memcpy(&dd.ddrk.attributes, &cur_secs->attributes, sizeof(sgx_attributes_t)); + memcpy(dd.ddrk.csr_owner_epoch, SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t)); + memcpy(&dd.ddrk.cpu_svn,&(g_global_data_sim.cpusvn_sim),sizeof(sgx_cpu_svn_t)); + memcpy(&dd.ddrk.mrenclave, &cur_secs->mr_enclave, sizeof(sgx_measurement_t)); + memcpy(&dd.ddrk.key_id, &kr->key_id, sizeof(sgx_key_id_t)); + break; + + case SGX_KEYSELECT_LICENSE: + check_attr_flag(cur_secs, SGX_FLAGS_LICENSE_KEY); + check_isv_svn(kr, cur_secs); + check_cpu_svn(kr); + + // assemble derivation data + dd.size = sizeof(dd_license_key_t); + memcpy(&dd.ddlk.attributes, &cur_secs->attributes, sizeof(sgx_attributes_t)); + memcpy(dd.ddlk.csr_owner_epoch, SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t)); + memcpy(&dd.ddlk.cpu_svn,&kr->cpu_svn,sizeof(sgx_cpu_svn_t)); + dd.ddlk.isv_svn = kr->isv_svn; + dd.ddlk.isv_prod_id = cur_secs->isv_prod_id; + memcpy(&dd.ddlk.key_id, &kr->key_id, sizeof(sgx_key_id_t)); + break; + + case SGX_KEYSELECT_PROVISION: // Pass through. Only key_name differs. + case SGX_KEYSELECT_PROVISION_SEAL: + check_attr_flag(cur_secs, SGX_FLAGS_PROVISION_KEY); + check_isv_svn(kr, cur_secs); + check_cpu_svn(kr); + + // assemble derivation data + dd.size = sizeof(dd_provision_key_t); + memcpy(&dd.ddpk.tmp_attr, &tmp_attr, sizeof(sgx_attributes_t)); + memcpy(&dd.ddpk.attribute_mask, &kr->attribute_mask, sizeof(sgx_attributes_t)); + memcpy(&dd.ddpk.cpu_svn,&kr->cpu_svn,sizeof(sgx_cpu_svn_t)); + dd.ddpk.isv_svn = kr->isv_svn; + dd.ddpk.isv_prod_id = cur_secs->isv_prod_id; + memcpy(&dd.ddpk.mrsigner, &cur_secs->mr_signer, sizeof(sgx_measurement_t)); + break; + + default: + return EGETKEY_INVALID_KEYNAME; + } + + derive_key(&dd, okey); + return 0; +} + +//////////////////////////////////////////////////////////////////////// +// Simulation for EREPORT +//////////////////////////////////////////////////////////////////////// + +static void _EREPORT(const sgx_target_info_t* ti, const sgx_report_data_t* rd, sgx_report_t* report) +{ + // check alignment of TARGETINFO + GP_ON(((size_t)ti & (TARGET_INFO_ALIGN_SIZE - 1)) != 0); + + // check to see if TARGETINFO is inside the current enclave + GP_ON(!sgx_is_within_enclave(ti, sizeof(sgx_target_info_t))); + + // check alignment of REPORTDATA + GP_ON(((size_t)rd & (REPORT_DATA_ALIGN_SIZE - 1)) != 0); + + // check to see if REPORTDATA is inside the current enclave + GP_ON(!sgx_is_within_enclave(rd, sizeof(sgx_report_data_t))); + + // check alignment of OUTPUTDATA + GP_ON(((size_t)report & (REPORT_ALIGN_SIZE - 1)) != 0); + + // check to see if OUTPUTDATA is inside the current enclave + GP_ON(!sgx_is_within_enclave(report, sizeof(sgx_report_t))); + + secs_t* cur_secs = g_global_data_sim.secs_ptr; + SE_DECLSPEC_ALIGN(REPORT_ALIGN_SIZE) sgx_report_t tmp_report; + + // assemble REPORT Data + memset(&tmp_report, 0, sizeof(tmp_report)); + memcpy(&tmp_report.body.cpu_svn,&(g_global_data_sim.cpusvn_sim),sizeof(sgx_cpu_svn_t)); + tmp_report.body.isv_prod_id = cur_secs->isv_prod_id; + tmp_report.body.isv_svn = cur_secs->isv_svn; + memcpy(&tmp_report.body.attributes, &cur_secs->attributes, sizeof(sgx_attributes_t)); + memcpy(&tmp_report.body.report_data, rd, sizeof(sgx_report_data_t)); + memcpy(&tmp_report.body.mr_enclave, &cur_secs->mr_enclave, sizeof(sgx_measurement_t)); + memcpy(&tmp_report.body.mr_signer, &cur_secs->mr_signer, sizeof(sgx_measurement_t)); + memcpy(&tmp_report.key_id, get_base_key(SGX_KEYSELECT_REPORT), sizeof(sgx_key_id_t)/2); + + // derive the report key + derivation_data_t dd; + memset(&dd, 0, sizeof(dd)); + dd.size = sizeof(dd_report_key_t); + + dd.key_name = SGX_KEYSELECT_REPORT; + memcpy(&dd.ddrk.mrenclave, &ti->mr_enclave, sizeof(sgx_measurement_t)); + memcpy(&dd.ddrk.attributes, &ti->attributes, sizeof(sgx_attributes_t)); + memcpy(dd.ddrk.csr_owner_epoch, SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t)); + memcpy(&dd.ddrk.cpu_svn,&(g_global_data_sim.cpusvn_sim),sizeof(sgx_cpu_svn_t)); + memcpy(&dd.ddrk.key_id, &tmp_report.key_id, sizeof(sgx_key_id_t)); + + // calculate the derived key + sgx_key_128bit_t tmp_report_key; + memset(tmp_report_key, 0, sizeof(tmp_report_key)); + + derive_key(&dd, tmp_report_key); + + // call cryptographic CMAC function + // CMAC data are *NOT* including MAC and KEYID + cmac(&tmp_report_key, reinterpret_cast(&tmp_report.body), + sizeof(tmp_report.body), &tmp_report.mac); + + memcpy(report, &tmp_report, sizeof(sgx_report_t)); +} + +//////////////////////////////////////////////////////////////////////// + + +static void +_EEXIT(uintptr_t dest, uintptr_t xcx, uintptr_t xdx, uintptr_t xsi, uintptr_t xdi) +{ + // By simulator convention, XDX contains XBP and XCX contains XSP. + + enclu_regs_t regs; + // when the code jump back to the ip after EENTER, the simulation code unwind the stack + // by adding 6*sizeof(uintptr_t), so we substract it in advance. + regs.xsp = xcx - 6 * sizeof(uintptr_t); + regs.xbp = xdx; + regs.xip = dest; + + tcs_t *tcs = GET_TCS_PTR(xdx); + GP_ON(tcs == NULL); + + // restore the used _tls_array + GP_ON(td_mngr_restore_td(tcs) == false); + + // check thread is in use or not + tcs_sim_t *tcs_sim = reinterpret_cast(tcs->reserved); + GP_ON(tcs_sim->tcs_state != TCS_STATE_ACTIVE); + tcs_sim->tcs_state = TCS_STATE_INACTIVE; + + regs.xax = 0; + regs.xbx = dest; + regs.xcx = tcs_sim->saved_aep; + regs.xsi = xsi; + regs.xdi = xdi; + + load_regs(®s); + + // Never returns..... +} + + +// Master entry functions + +#pragma GCC push_options +#pragma GCC optimize ("O0") + +uintptr_t _SE3(uintptr_t xax, uintptr_t xbx, uintptr_t xcx, + uintptr_t xdx, uintptr_t xsi, uintptr_t xdi) +{ + switch (xax) + { + case SE_EEXIT: + _EEXIT(xbx, xcx, xdx, xsi, xdi); + // never reach here + return 0; + + case SE_EGETKEY: + return _EGETKEY(reinterpret_cast(xbx), + reinterpret_cast(xcx)); + + case SE_EREPORT: + _EREPORT(reinterpret_cast(xbx), + reinterpret_cast(xcx), + reinterpret_cast(xdx)); + return 0; + } + + GP(); + return (uintptr_t)-1; +} + +#pragma GCC pop_options diff --git a/sdk/simulation/tinst/t_instructions.h b/sdk/simulation/tinst/t_instructions.h new file mode 100644 index 0000000000..05ad132884 --- /dev/null +++ b/sdk/simulation/tinst/t_instructions.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _TINSTRUCTIONS_H +#define _TINSTRUCTIONS_H + +#include "se_types.h" +#include "rts_sim.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern SE_DECLSPEC_EXPORT global_data_sim_t g_global_data_sim; + +uintptr_t _SE3(uintptr_t xax, uintptr_t xbx, uintptr_t xcx, + uintptr_t xdx, uintptr_t xsi, uintptr_t xdi); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/trtssim/Makefile b/sdk/simulation/trtssim/Makefile new file mode 100644 index 0000000000..5e02f9ac6c --- /dev/null +++ b/sdk/simulation/trtssim/Makefile @@ -0,0 +1,37 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +.PHONY: all clean +all: + $(MAKE) -C linux + +clean: + $(MAKE) -C linux clean diff --git a/sdk/simulation/trtssim/linux/Makefile b/sdk/simulation/trtssim/linux/Makefile new file mode 100644 index 0000000000..fc11d1599a --- /dev/null +++ b/sdk/simulation/trtssim/linux/Makefile @@ -0,0 +1,134 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../../buildenv.mk + +CPPFLAGS += -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/tlibc/ \ + -I$(COMMON_DIR)/inc/internal \ + -I$(LINUX_SDK_DIR)/trts/ + +CFLAGS += $(ENCLAVE_CFLAGS) +ASFLAGS := -DSE_SIM -Werror $(CFLAGS) +CFLAGS += -DSE_SIM -Werror -fasynchronous-unwind-tables +CXXFLAGS += -DSE_SIM -Werror $(ENCLAVE_CXXFLAGS)\ + -fno-exceptions -fno-rtti + + +SIM_DIR := $(CUR_DIR)/../.. +# The sources from tRTS - shared by both Sim/HW mode +TRTS_DIR := $(LINUX_SDK_DIR)/trts/ +# The sources for SE0 instruction simulation +TINST_DIR := $(SIM_DIR)/tinst/ +# The sources for low-level API used by instruction simulation +LOWLIB_DIR := $(SIM_DIR)/assembly/linux/ +# The sources for TLS support +TLS_DIR := $(SIM_DIR)/uinst/linux/ +# The source for trusted loader +TLDR_DIR := $(LINUX_SDK_DIR)/trts/linux/ +# Support for platform dependent 'setcontext' +SC_DIR := $(LINUX_SDK_DIR)/trts/linux/$(ARCH)/ + +TRTS_OBJS := init_enclave.o \ + trts.o \ + trts_ecall.o \ + trts_ocall.o \ + trts_util.o \ + trts_veh.o \ + trts_xsave.o \ + init_optimized_lib.o + +TINST_OBJS := t_instructions.o \ + deriv.o + +LOWLIB_OBJS := lowlib.o + +TLS_OBJS := get_tcs.o \ + restore_tls.o + +TLDR_ASM_OBJS := trts_pic.o \ + metadata_sec.o + +TLDR_C_OBJS := elf_parser.o \ + global_init.o \ + tls_support.o + +TLDR_OBJS := $(TLDR_ASM_OBJS) $(TLDR_C_OBJS) + +SC_OBJ := setcontext.o + +LIBTRTS := libsgx_trts_sim.a + +vpath %.cpp $(TRTS_DIR):$(TINST_DIR) +vpath %.S $(LOWLIB_DIR):$(TLDR_DIR):$(SC_DIR) +vpath %.c $(TLS_DIR):$(TLDR_DIR) + +# ------------------------------------------------------------ +.PHONY: all +all: $(LIBTRTS) | $(BUILD_DIR) + $(CP) $< $| + +$(LIBTRTS): $(TRTS_OBJS) $(TINST_OBJS) $(LOWLIB_OBJS) $(TLS_OBJS) $(TLDR_OBJS) $(SC_OBJ) + $(AR) rcsD $@ $(TRTS_OBJS) $(TINST_OBJS) $(LOWLIB_OBJS) $(TLS_OBJS) $(TLDR_OBJS) $(SC_OBJ) + +# ------------------------------------------------------------ +$(TRTS_OBJS): CPPFLAGS += -I$(COMMON_DIR)/inc/tlibc \ + -I$(SIM_DIR)/tinst/ + +# Explicitly disable optimization for tRTS simulation library, +# since the '_SE3' function has assumptions on stack layout. +# c.f. ../../tinst/Makefile +$(TINST_OBJS): CPPFLAGS += -I$(SIM_DIR)/assembly/ \ + -I$(SIM_DIR)/assembly/linux \ + -I$(SIM_DIR)/uinst/ \ + -I$(LINUX_SDK_DIR)/selib/ \ + -O0 + +$(TLS_OBJS): CPPFLAGS += -I$(SIM_DIR)/assembly/ \ + -I$(SIM_DIR)/assembly/linux \ + -I$(SIM_DIR)/uinst/ + +$(TLDR_C_OBJS): CPPFLAGS += -I$(COMMON_DIR)/inc/internal/linux/ \ + -I$(SIM_DIR)/assembly/ + +$(TLDR_ASM_OBJS): ASFLAGS += -I$(SIM_DIR)/assembly/ + +$(SC_OBJ): ASFLAGS += -I$(LINUX_SDK_DIR)/cpprt/linux/libunwind/src/$(ARCH) -DISE=1 + +$(BUILD_DIR): + $(MKDIR) $@ + +.PHONY: clean +clean: + @$(RM) *.o $(LIBTRTS) $(BUILD_DIR)/$(LIBTRTS) + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/simulation/uae_service_sim/licensing_sim.cpp b/sdk/simulation/uae_service_sim/licensing_sim.cpp new file mode 100644 index 0000000000..c12d3b0196 --- /dev/null +++ b/sdk/simulation/uae_service_sim/licensing_sim.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "ae_ipp.h" +#include "se_memcpy.h" +#include "util.h" +#include "uae_service_internal.h" + +/* This hard code depends on enclaveSinger private key of PvE, an Intel Generic +Enclave Signing Key currently: +trunk/psw/ae/common/sgx_qe_pve_private_key.pem */ +static const uint8_t PVE_PUBLIC_KEY[] = { + 0XAB, 0X93, 0XBB, 0XF7, 0X4A, 0XA2, 0XDF, 0X51, + 0X91, 0X46, 0X57, 0X93, 0X1D, 0XB0, 0XC, 0XDB, + 0X24, 0X1E, 0XF4, 0X91, 0X38, 0X3F, 0X83, 0X4D, + 0X71, 0XB7, 0X3D, 0X2F, 0X4E, 0X8F, 0X1D, 0X7C, + 0X68, 0X4C, 0X75, 0XEF, 0X4D, 0XFE, 0X72, 0XE3, + 0X42, 0X5, 0X99, 0X8D, 0X66, 0X94, 0X1D, 0XC3, + 0X16, 0X24, 0XB8, 0XA6, 0XC8, 0XBB, 0X3E, 0XB7, + 0X14, 0XC7, 0X9E, 0X5E, 0X50, 0X1F, 0X1, 0X34, + 0X2, 0X17, 0XD7, 0X12, 0XBE, 0XA6, 0XCD, 0XD2, + 0XF8, 0X58, 0XE4, 0X9B, 0XEB, 0XDC, 0X96, 0XE, + 0XF1, 0XAB, 0X83, 0XD1, 0XF1, 0X43, 0XB4, 0X67, + 0XC6, 0XDF, 0XC1, 0X94, 0X9F, 0X88, 0X21, 0XE7, + 0X55, 0XA5, 0X18, 0X9D, 0XC3, 0X79, 0X7C, 0X26, + 0XA0, 0X3B, 0X46, 0X15, 0XCF, 0X2E, 0X69, 0X81, + 0X8F, 0XCD, 0XD0, 0X98, 0X37, 0X2A, 0X27, 0X1, + 0XEC, 0X95, 0X2A, 0X7F, 0XE8, 0XC6, 0XCA, 0X8D, + 0XCA, 0XA2, 0XCB, 0X6A, 0X37, 0XD4, 0XDC, 0X7E, + 0X4F, 0XC6, 0X2A, 0XAF, 0X7B, 0X52, 0XEF, 0X93, + 0X58, 0X72, 0X2A, 0XFA, 0X2, 0XEE, 0XBA, 0XC4, + 0XFA, 0X52, 0XD8, 0XA2, 0XFA, 0X1, 0X83, 0XE3, + 0XA6, 0X5D, 0X87, 0X60, 0XCD, 0XA, 0X62, 0X9D, + 0X28, 0X8, 0X2C, 0X72, 0X36, 0XC9, 0X2E, 0XF6, + 0X9F, 0X96, 0X84, 0X60, 0XE9, 0X8E, 0X72, 0XE9, + 0X83, 0XD8, 0X25, 0XDD, 0X27, 0X74, 0X32, 0X26, + 0XAD, 0X98, 0XB7, 0X8B, 0X6, 0X45, 0X9C, 0X75, + 0X10, 0XA6, 0X2C, 0XFF, 0X60, 0X83, 0XFF, 0XE, + 0XB4, 0X88, 0X20, 0X4E, 0XB2, 0X59, 0XE7, 0XEC, + 0XA1, 0X5F, 0X10, 0XBF, 0X94, 0X2C, 0XF9, 0X26, + 0X80, 0X64, 0X7E, 0X1F, 0XAA, 0X6E, 0X28, 0X7B, + 0XC, 0XD7, 0X7E, 0XA, 0X89, 0X9D, 0X4E, 0XDB, + 0XED, 0X60, 0XFF, 0X2, 0XE, 0XA7, 0XD0, 0X7C, + 0X5D, 0X2, 0XDA, 0X15, 0X72, 0XD6, 0X95, 0X97, + 0XF, 0X49, 0X58, 0XCA, 0XBC, 0X6D, 0X94, 0XED, + 0X6, 0XE1, 0XD8, 0XC8, 0X3, 0XD3, 0X4C, 0XB5, + 0X72, 0X28, 0X5E, 0X10, 0XB4, 0X6E, 0XAF, 0X4A, + 0X6E, 0X81, 0X66, 0XF6, 0XED, 0XE9, 0X1E, 0X69, + 0XDE, 0X9B, 0XDC, 0X33, 0X62, 0X9D, 0X2F, 0X5, + 0X6A, 0X74, 0X2B, 0XCF, 0X1E, 0XDE, 0XDB, 0X32, + 0X63, 0X4C, 0XE7, 0XC5, 0XDC, 0XCD, 0X31, 0X21, + 0X5A, 0X5D, 0XFD, 0XDD, 0XA1, 0XBC, 0X3C, 0X40, + 0X6E, 0X37, 0X51, 0XBC, 0X1, 0X5B, 0X49, 0XCA, + 0XAE, 0X9B, 0X38, 0XF4, 0X74, 0X8D, 0X6B, 0X58, + 0XDC, 0XDF, 0XE1, 0X68, 0X8A, 0X43, 0XB4, 0XFE, + 0X98, 0X7F, 0X1D, 0X4A, 0XB0, 0X4D, 0XF5, 0X28, + 0X6F, 0XBE, 0XE4, 0X93, 0X30, 0XC8, 0XDB, 0X6A, + 0X1C, 0X84, 0X44, 0X18, 0X8D, 0X3F, 0XC, 0XCE, + 0X50, 0X4E, 0XBE, 0XF0, 0X75, 0XE1, 0X7F, 0XBC, + 0X4F, 0X4E, 0X9, 0X60, 0XF4, 0XC3, 0XFC, 0XC2 +}; + + +static sgx_status_t get_launch_token_internal( + const enclave_css_t *p_signature, + const sgx_attributes_t *p_attributes, + token_t *p_token) +{ + memset(p_token, 0xEE, sizeof(token_t)); + memset(&(p_token->body.reserved1), 0, + sizeof(p_token->body.reserved1)); + memset(&(p_token->reserved2), 0, + sizeof(p_token->reserved2)); + + p_token->body.valid = 1; + // In spec, lic_token.cpu_svn = 1, which 1 should be the least significate one. + memset(&p_token->cpu_svn_le, 0, sizeof(p_token->cpu_svn_le)); + memset(&p_token->cpu_svn_le, 1, 1); + p_token->isv_svn_le = 1; + if(memcpy_s(&(p_token->body.attributes), + sizeof(p_token->body.attributes), + p_attributes, + sizeof(sgx_attributes_t))){ + return SGX_ERROR_UNEXPECTED; + } + if(memcpy_s(&(p_token->body.mr_enclave), + sizeof(p_token->body.mr_enclave), + &(p_signature->body.enclave_hash), + sizeof(p_signature->body.enclave_hash))){ + return SGX_ERROR_UNEXPECTED; + } + p_token->attributes_le.flags = SGX_FLAGS_INITTED; + p_token->attributes_le.xfrm = SGX_XFRM_LEGACY; + + IppStatus ipp_ret = ippStsNoErr; + ipp_ret = ippsHashMessage((const Ipp8u *)&(p_signature->key.modulus), + sizeof(p_signature->key.modulus), + (Ipp8u *)&(p_token->body.mr_signer), IPP_ALG_HASH_SHA256); + if(ipp_ret != ippStsNoErr){ + return SGX_ERROR_UNEXPECTED; + } + + return SGX_SUCCESS; +} + +sgx_status_t get_launch_token( + const enclave_css_t *p_signature, + const sgx_attributes_t *p_attribute, + sgx_launch_token_t *p_launch_token) +{ + if(!p_signature || !p_attribute || !p_launch_token){ + return SGX_ERROR_INVALID_PARAMETER; + } + + if(((p_attribute->flags) & SGX_FLAGS_PROVISION_KEY) && + memcmp(PVE_PUBLIC_KEY, &p_signature->key.modulus, + sizeof(PVE_PUBLIC_KEY))) + return SGX_ERROR_SERVICE_INVALID_PRIVILEGE; + + return get_launch_token_internal(p_signature, + p_attribute, + (token_t *)p_launch_token); +} diff --git a/sdk/simulation/uae_service_sim/linux/Makefile b/sdk/simulation/uae_service_sim/linux/Makefile new file mode 100644 index 0000000000..24d931f4e7 --- /dev/null +++ b/sdk/simulation/uae_service_sim/linux/Makefile @@ -0,0 +1,124 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR = ../../../.. +include $(TOP_DIR)/buildenv.mk + +INCLUDES := -I.. \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(LINUX_SDK_DIR)/tseal \ + -I$(LINUX_SDK_DIR)/simulation/tinst \ + -I$(LINUX_SDK_DIR)/simulation/urtssim \ + -I$(LINUX_EXTERNAL_DIR)/crypto_px/include \ + -I$(LINUX_EXTERNAL_DIR)/epid/inc \ + -I$(LINUX_EXTERNAL_DIR)/rdrand/ \ + -I$(LINUX_PSW_DIR)/ae/inc \ + -I$(LINUX_PSW_DIR)/ae/inc/internal \ + -I$(LINUX_PSW_DIR)/ae/common + +CXXFLAGS += -Wall -fPIC $(INCLUDES) -Werror +CFLAGS := $(filter-out -fPIC -Werror, $(CFLAGS)) -Wall $(INCLUDES) + +VERSION_SCRIPT = $(shell pwd)/uae_service_sim.linux.version +LD_OPT_WITHVER = -Wl,--version-script=$(VERSION_SCRIPT) + +IPP_LIBDIR := $(LINUX_EXTERNAL_DIR)/crypto_px/ +RDRAND_LIBDIR := $(LINUX_EXTERNAL_DIR)/rdrand/src +RDRAND_MAKEFILE := $(RDRAND_LIBDIR)/Makefile + +EXTERNAL_LIB += -L$(IPP_LIBDIR) -lcrypto_px +EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrdrand +EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrt +EXTERNAL_LIB += -ldl + +vpath %.cpp $(LINUX_PSW_DIR)/ae/common \ + $(LINUX_SDK_DIR)/simulation/urtssim \ + $(COMMON_DIR)/src + +vpath %.c $(COMMON_DIR)/src + +CPP_SRC := $(wildcard *.cpp ../*.cpp) se_sig_rl.cpp cpusvn_util.cpp sgx_read_rand.cpp +C_SRC := se_trace.c se_thread.c + +OBJ := $(CPP_SRC:.cpp=.o) \ + $(C_SRC:.c=.o) + +DLLNAME = libsgx_uae_service_sim.so +LIBUAE_SERVICE_DEPLOY := libsgx_uae_service_deploy.so + +.PHONY: all +all: $(DLLNAME) $(LIBUAE_SERVICE_DEPLOY) | $(BUILD_DIR) + $(CP) $(DLLNAME) $| + $(CP) $(LIBUAE_SERVICE_DEPLOY) $| + +$(DLLNAME): $(OBJ) -lrdrand -lcrypto_px + $(CXX) $(CXXFLAGS) $(OBJ) -shared $(EXTERNAL_LIB) -o $@ $(LD_OPT_WITHVER) + +%.o: %.c + $(CC) $(CFLAGS) -Werror -fPIC -c $< -o $@ + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + +-lcrypto_px: + $(MAKE) -C $(IPP_LIBDIR) + +-lrdrand: $(RDRAND_MAKEFILE) + $(MAKE) -C $(RDRAND_LIBDIR) + + +$(RDRAND_MAKEFILE): +ifeq ($(ARCH), x86) + @cd $(RDRAND_LIBDIR);./configure +else + @cd $(RDRAND_LIBDIR);./configure CFLAGS=-fPIC +endif + +$(LIBUAE_SERVICE_DEPLOY): ../uae_service_deploy.c + $(CC) -shared -Wl,-soname=libsgx_uae_service.so $< -o $@ + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: clean +clean: + @$(RM) *.o + @$(RM) ../*.o + @$(RM) $(DLLNAME) $(BUILD_DIR)/$(DLLNAME) + @$(RM) $(LIBUAE_SERVICE_DEPLOY) $(BUILD_DIR)/$(LIBUAE_SERVICE_DEPLOY) + @$(MAKE) -C $(IPP_LIBDIR) clean +ifeq ($(RDRAND_MAKEFILE), $(wildcard $(RDRAND_MAKEFILE))) + @$(MAKE) distclean -C $(RDRAND_LIBDIR) +endif + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/simulation/uae_service_sim/linux/platform_service_sim.cpp b/sdk/simulation/uae_service_sim/linux/platform_service_sim.cpp new file mode 100644 index 0000000000..c9608026dc --- /dev/null +++ b/sdk/simulation/uae_service_sim/linux/platform_service_sim.cpp @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "../uae_service_sim.h" + +#define SE_DATA_FOLDER1 "intel/" +#define SE_DATA_FOLDER2 "intelsgxpsw/" +#define MAX_PATH 260 +#include +#include +#include +#include +#define __STDC_FORMAT_MACROS +#include +#include "ae_ipp.h" + +static Mutex g_pse_sim_lock; + +__attribute__((constructor)) +// Initializer of the uae_service_sim. +static void init_ipp(void) +{ +} + +static char g_vmc_base_path[] = "/var/tmp/"; + + +sgx_status_t get_counter_id(vmc_sim_t *p_vmc_sim) +{ + uint32_t i = 0; + int random_int = 0; + unsigned int a, d; + asm volatile("rdtsc" : "=a" (a), "=d" (d)); + for(i = 0; i < sizeof(p_vmc_sim->counter_id); i++, random_int >>= 8) + { + if(!(i % 4)) + { + random_int = rand_r(&a); + } + p_vmc_sim->counter_id[i] = (uint8_t)(random_int & 0xFF); + } + for(i = 0; i < sizeof(p_vmc_sim->nonce); i++, random_int >>= 8) + { + if(!(i % 4)) + { + random_int = rand_r(&a); + } + p_vmc_sim->nonce[i] = (uint8_t)(random_int & 0xFF); + } + return SGX_SUCCESS; +} + +sgx_status_t del_vmc_sim(const vmc_sim_t *p_vmc_sim) +{ + char path[MAX_PATH] = {0}; + int ret = 0; + + uint64_t temp_value = 0; + memcpy_s(&temp_value, sizeof(temp_value), + p_vmc_sim->nonce, sizeof(temp_value)); + + char *p_buf = g_vmc_base_path; + + ret = snprintf(path, sizeof(path), "%s%s%s%" PRIx64".dat", + p_buf, SE_DATA_FOLDER1, SE_DATA_FOLDER2, temp_value); + if(-1 == ret){ + return SGX_ERROR_UNEXPECTED; + } + if(remove(path)){ + return SGX_ERROR_MC_NOT_FOUND; + } + + return SGX_SUCCESS; +} + +sgx_status_t store_vmc_sim(const vmc_sim_t *p_vmc_sim) +{ + char path[MAX_PATH] = {0}; + int ret = 0; + + uint64_t temp_value = 0; + memcpy_s(&temp_value, sizeof(temp_value), + p_vmc_sim->nonce, sizeof(temp_value)); + + char *p_buf = g_vmc_base_path; + + ret = snprintf(path, sizeof(path), "%s%s", + p_buf, + SE_DATA_FOLDER1); + if(-1 == ret){ + return SGX_ERROR_UNEXPECTED; + } + + g_pse_sim_lock.lock(); + ret = mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR); + if(0 == ret){ + ret = chmod(path, S_IRUSR|S_IWUSR|S_IXUSR + |S_IRGRP|S_IWGRP|S_IXGRP + |S_IROTH|S_IWOTH|S_IXOTH); + if(0 != ret){ + g_pse_sim_lock.unlock(); + return SGX_ERROR_UNEXPECTED; + } + }else if(EEXIST != errno){ + g_pse_sim_lock.unlock(); + return SGX_ERROR_UNEXPECTED; + } + g_pse_sim_lock.unlock(); + + ret = snprintf(path, sizeof(path), "%s%s%s", + p_buf, + SE_DATA_FOLDER1, + SE_DATA_FOLDER2); + if(-1 == ret){ + return SGX_ERROR_UNEXPECTED; + } + + g_pse_sim_lock.lock(); + ret = mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR); + if(0 == ret){ + ret = chmod(path, S_IRUSR|S_IWUSR|S_IXUSR + |S_IRGRP|S_IWGRP|S_IXGRP + |S_IROTH|S_IWOTH|S_IXOTH); + if(0 != ret){ + g_pse_sim_lock.unlock(); + return SGX_ERROR_UNEXPECTED; + } + }else if(EEXIST != errno){ + g_pse_sim_lock.unlock(); + return SGX_ERROR_UNEXPECTED; + } + g_pse_sim_lock.unlock(); + + ret = snprintf(path, sizeof(path), "%s%s%s%" PRIx64".dat", + p_buf, SE_DATA_FOLDER1, SE_DATA_FOLDER2, temp_value); + if(-1 == ret){ + return SGX_ERROR_UNEXPECTED; + } + FILE *fp = NULL; + fp = fopen(path, "wb"); + if(!fp){ + return SGX_ERROR_MC_NOT_FOUND; + } + size_t wt_count = 0; + wt_count = fwrite(p_vmc_sim, sizeof(vmc_sim_t), 1, fp); + if(!wt_count){ + fclose(fp); + return SGX_ERROR_UNEXPECTED; + } + fclose(fp); + return SGX_SUCCESS; +} + +sgx_status_t load_vmc_sim(vmc_sim_t *p_vmc_sim) +{ + char path[MAX_PATH] = {0}; + int ret = 0; + + uint64_t temp_value = 0; + memcpy_s(&temp_value, sizeof(temp_value), + p_vmc_sim->nonce, sizeof(temp_value)); + + char *p_buf = g_vmc_base_path; + + ret = snprintf(path, sizeof(path), "%s%s%s%" PRIx64".dat", + p_buf, SE_DATA_FOLDER1, SE_DATA_FOLDER2, temp_value); + if(-1 == ret){ + return SGX_ERROR_UNEXPECTED; + } + FILE *fp = NULL; + fp = fopen(path, "rb"); + if(!fp){ + return SGX_ERROR_MC_NOT_FOUND; + } + size_t rd_count = 0; + rd_count = fread(p_vmc_sim, sizeof(vmc_sim_t), 1, fp); + if(!rd_count){ + fclose(fp); + return SGX_ERROR_UNEXPECTED; + } + fclose(fp); + return SGX_SUCCESS; +} diff --git a/sdk/simulation/uae_service_sim/linux/uae_service_sim.linux.version b/sdk/simulation/uae_service_sim/linux/uae_service_sim.linux.version new file mode 100644 index 0000000000..c31c0ded9d --- /dev/null +++ b/sdk/simulation/uae_service_sim/linux/uae_service_sim.linux.version @@ -0,0 +1,15 @@ +{ +global: + get_launch_token; + sgx_init_quote; + sgx_get_quote_size; + sgx_get_quote; + sgx_get_ps_cap; + sgx_report_attestation_status; + create_session_ocall; + exchange_report_ocall; + close_session_ocall; + invoke_service_ocall; +local: + *; +}; diff --git a/sdk/simulation/uae_service_sim/platform_service_sim_com.cpp b/sdk/simulation/uae_service_sim/platform_service_sim_com.cpp new file mode 100644 index 0000000000..64fdad5a10 --- /dev/null +++ b/sdk/simulation/uae_service_sim/platform_service_sim_com.cpp @@ -0,0 +1,363 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "uae_service_sim.h" + +#ifdef __cplusplus +extern "C" { +#endif + +static const uint8_t TIME_SOURCE_NONCE_SIM[32] = { + 0x9d, 0x7c, 0x25, 0x07, 0x38, 0x53, 0x23, 0xb1, + 0x9f, 0xba, 0xc8, 0x7b, 0xc0, 0x89, 0xde, 0x2d, + 0x2b, 0x5f, 0x34, 0x6d, 0x9c, 0x35, 0xf5, 0xbc, + 0xcd, 0x34, 0x7f, 0x75, 0x96, 0xc8, 0x27, 0xcc}; + +sgx_status_t pse_mc_create_sim( + uint8_t *p_req_payload, + uint8_t *p_resp_payload) +{ + UNUSED(p_req_payload); + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + pse_mc_create_resp_t *p_create_resp + = (pse_mc_create_resp_t *)p_resp_payload; + + //initial create_resp + p_create_resp->resp_hdr.service_id = PSE_MC_SERVICE; + p_create_resp->resp_hdr.service_cmd = PSE_MC_CREATE; + p_create_resp->resp_hdr.status = PSE_ERROR_INTERNAL; + memset(p_create_resp->counter_id, 0xFF, sizeof(p_create_resp->counter_id)); + memset(p_create_resp->nonce, 0xFF, sizeof(p_create_resp->nonce)); + + vmc_sim_t temp_vmc = {{0}, {0}, 0}; + ret = get_counter_id(&temp_vmc); + if(SGX_SUCCESS != ret){ + return ret; + } + ret = store_vmc_sim(&temp_vmc); + if(SGX_SUCCESS != ret){ + return ret; + } + + p_create_resp->resp_hdr.status = PSE_SUCCESS; + if(memcpy_s(p_create_resp->counter_id, + sizeof(p_create_resp->counter_id), + temp_vmc.counter_id, + sizeof(temp_vmc.counter_id))){ + return SGX_ERROR_UNEXPECTED; + } + if(memcpy_s(p_create_resp->nonce, + sizeof(p_create_resp->nonce), + temp_vmc.nonce, + sizeof(temp_vmc.nonce))){ + return SGX_ERROR_UNEXPECTED; + } + + return ret; +} + +sgx_status_t pse_mc_read_sim( + uint8_t *p_req_payload, + uint8_t *p_resp_payload) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + pse_mc_read_req_t *p_read_req = (pse_mc_read_req_t *)p_req_payload; + pse_mc_read_resp_t *p_read_resp = (pse_mc_read_resp_t *)p_resp_payload; + + //initial create_resp + p_read_resp->counter_value = 0; + p_read_resp->resp_hdr.service_id = PSE_MC_SERVICE; + p_read_resp->resp_hdr.service_cmd = PSE_MC_READ; + p_read_resp->resp_hdr.status = PSE_ERROR_INTERNAL; + + vmc_sim_t temp_vmc = {{0}, {0}, 0}; + if(memcpy_s(&temp_vmc.counter_id, + sizeof(temp_vmc.counter_id), + p_read_req->counter_id, + sizeof(p_read_req->counter_id))){ + return SGX_ERROR_UNEXPECTED; + } + if(memcpy_s(&temp_vmc.nonce, + sizeof(temp_vmc.nonce), + p_read_req->nonce, + sizeof(p_read_req->nonce))){ + return SGX_ERROR_UNEXPECTED; + } + ret = load_vmc_sim(&temp_vmc); + if(SGX_SUCCESS != ret){ + memset(&p_read_resp->counter_value, 0xFF, + sizeof(p_read_resp->counter_value)); + return ret; + } + + p_read_resp->resp_hdr.status = PSE_SUCCESS; + if(memcpy_s(&p_read_resp->counter_value, + sizeof(p_read_resp->counter_value), + &temp_vmc.counter_value, + sizeof(temp_vmc.counter_value))){ + return SGX_ERROR_UNEXPECTED; + } + + return ret; +} + +sgx_status_t pse_mc_inc_sim( + uint8_t *p_req_payload, + uint8_t *p_resp_payload) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + pse_mc_inc_req_t *p_inc_req = (pse_mc_inc_req_t *)p_req_payload; + pse_mc_inc_resp_t *p_inc_resp = (pse_mc_inc_resp_t *)p_resp_payload; + + //initial create_resp + p_inc_resp->counter_value = 0; + p_inc_resp->resp_hdr.service_id = PSE_MC_SERVICE; + p_inc_resp->resp_hdr.service_cmd = PSE_MC_INC; + p_inc_resp->resp_hdr.status = PSE_ERROR_INTERNAL; + + vmc_sim_t temp_vmc = {{0}, {0}, 0}; + if(memcpy_s(&temp_vmc.counter_id, + sizeof(temp_vmc.counter_id), + p_inc_req->counter_id, + sizeof(p_inc_req->counter_id))){ + return SGX_ERROR_UNEXPECTED; + } + if(memcpy_s(&temp_vmc.nonce, + sizeof(temp_vmc.nonce), + p_inc_req->nonce, + sizeof(p_inc_req->nonce))){ + return SGX_ERROR_UNEXPECTED; + } + ret = load_vmc_sim(&temp_vmc); + if(SGX_SUCCESS != ret){ + return ret; + } + temp_vmc.counter_value++; + ret = store_vmc_sim(&temp_vmc); + if(SGX_SUCCESS != ret){ + return ret; + } + + p_inc_resp->resp_hdr.status = PSE_SUCCESS; + if(memcpy_s(&p_inc_resp->counter_value, + sizeof(p_inc_resp->counter_value), + &temp_vmc.counter_value, + sizeof(temp_vmc.counter_value))){ + return SGX_ERROR_UNEXPECTED; + } + + return ret; +} + +sgx_status_t pse_mc_del_sim( + uint8_t *p_req_payload, + uint8_t *p_resp_payload) +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + pse_mc_del_req_t *p_del_req = (pse_mc_del_req_t *)p_req_payload; + pse_mc_del_resp_t *p_del_resp = (pse_mc_del_resp_t *)p_resp_payload; + + //initial create_resp + p_del_resp->resp_hdr.service_id = PSE_MC_SERVICE; + p_del_resp->resp_hdr.service_cmd = PSE_MC_DEL; + p_del_resp->resp_hdr.status = PSE_ERROR_INTERNAL; + + vmc_sim_t temp_vmc = {{0}, {0}, 0}; + if(memcpy_s(&temp_vmc.counter_id, + sizeof(temp_vmc.counter_id), + p_del_req->counter_id, + sizeof(p_del_req->counter_id))){ + return SGX_ERROR_UNEXPECTED; + } + if(memcpy_s(&temp_vmc.nonce, + sizeof(temp_vmc.nonce), + p_del_req->nonce, + sizeof(p_del_req->nonce))){ + return SGX_ERROR_UNEXPECTED; + } + ret = del_vmc_sim(&temp_vmc); + if(SGX_SUCCESS != ret){ + return ret; + } + + p_del_resp->resp_hdr.status = PSE_SUCCESS; + return ret; +} + +sgx_status_t pse_read_timer_sim( + uint8_t *p_req_payload, + uint8_t *p_resp_payload) +{ + UNUSED(p_req_payload); + pse_timer_read_resp_t *p_time_resp + = (pse_timer_read_resp_t *)p_resp_payload; + + time_t t = time(0); + p_time_resp->resp_hdr.service_id = PSE_TRUSTED_TIME_SERVICE; + p_time_resp->resp_hdr.service_cmd = PSE_TIMER_READ; + p_time_resp->timestamp = (uint64_t)t; + if(memcpy_s(p_time_resp->time_source_nonce, + sizeof(p_time_resp->time_source_nonce), + TIME_SOURCE_NONCE_SIM, sizeof(p_time_resp->time_source_nonce))){ + return SGX_ERROR_UNEXPECTED; + } + p_time_resp->resp_hdr.status = PSE_SUCCESS; + return SGX_SUCCESS; +} + +typedef sgx_status_t (*srv_pfn_t)(uint8_t *, uint8_t *); +static const struct service_handler_t { + uint16_t service_id; + uint16_t service_cmd; + uint16_t req_msg_size; + uint16_t resp_msg_size; + srv_pfn_t srv_pfn; +} SERVICE_HANDLER[] = { + {PSE_MC_SERVICE, PSE_MC_CREATE, sizeof(pse_mc_create_req_t), + sizeof(pse_mc_create_resp_t), pse_mc_create_sim}, + {PSE_MC_SERVICE, PSE_MC_READ, sizeof(pse_mc_read_req_t), + sizeof(pse_mc_read_resp_t), pse_mc_read_sim}, + {PSE_MC_SERVICE, PSE_MC_INC, sizeof(pse_mc_inc_req_t), + sizeof(pse_mc_inc_resp_t), pse_mc_inc_sim}, + {PSE_MC_SERVICE, PSE_MC_DEL, sizeof(pse_mc_del_req_t), + sizeof(pse_mc_del_resp_t), pse_mc_del_sim}, + {PSE_TRUSTED_TIME_SERVICE, PSE_TIMER_READ, sizeof(pse_timer_read_req_t), + sizeof(pse_timer_read_resp_t), pse_read_timer_sim} +}; + +static sgx_status_t invoke_service( + const uint8_t *p_pse_message_req, + size_t pse_message_req_size, + uint8_t *p_pse_message_resp, + size_t pse_message_resp_size, + unsigned long timeout) +{ + UNUSED(timeout); + sgx_status_t ret = SGX_SUCCESS; + if(!p_pse_message_req || !p_pse_message_resp){ + return SGX_ERROR_INVALID_PARAMETER; + } + + const pse_message_t *p_req_msg = (const pse_message_t *)p_pse_message_req; + pse_message_t *p_resp_msg = (pse_message_t *)p_pse_message_resp; + + if(pse_message_req_size != sizeof(pse_message_t) + + p_req_msg->payload_size){ + return SGX_ERROR_INVALID_PARAMETER; + } + if(pse_message_resp_size < sizeof(pse_message_t) + + p_resp_msg->exp_resp_size){ + return SGX_ERROR_INVALID_PARAMETER; + } + + const uint8_t *p_req_payload = p_req_msg->payload; + uint8_t *p_resp_payload = p_resp_msg->payload; + const pse_req_hdr_t *p_req_hdr = (const pse_req_hdr_t *)p_req_payload; + for(unsigned int i = 0; + i < sizeof(SERVICE_HANDLER) / sizeof(service_handler_t); i++) + { + if(p_req_hdr->service_id == SERVICE_HANDLER[i].service_id + && p_req_hdr->service_cmd == SERVICE_HANDLER[i].service_cmd){ + if(p_req_msg->payload_size != SERVICE_HANDLER[i].req_msg_size + || p_req_msg->exp_resp_size != SERVICE_HANDLER[i].resp_msg_size) + { + ret = SGX_ERROR_UNEXPECTED; + break; + } + + memset(p_resp_payload, 0, p_req_msg->exp_resp_size); + ret = SERVICE_HANDLER[i].srv_pfn(const_cast(p_req_payload), p_resp_payload); + + p_resp_msg->payload_size = p_req_msg->exp_resp_size; + break; + } + } + + return ret; +} + +sgx_status_t create_session_ocall(uint32_t *p_sid, uint8_t *p_dh_msg1, + uint32_t dh_msg1_size, uint32_t timeout) +{ + UNUSED(p_sid); + UNUSED(p_dh_msg1); + UNUSED(dh_msg1_size); + UNUSED(timeout); + return SGX_SUCCESS; +} + +sgx_status_t exchange_report_ocall(uint32_t sid, + const uint8_t *p_dh_msg2, + uint32_t dh_msg2_size, + uint8_t *p_dh_msg3, + uint32_t dh_msg3_size, + uint32_t timeout) +{ + UNUSED(sid); + UNUSED(p_dh_msg2); + UNUSED(dh_msg2_size); + UNUSED(p_dh_msg3); + UNUSED(dh_msg3_size); + UNUSED(timeout); + return SGX_SUCCESS; +} + +sgx_status_t close_session_ocall(uint32_t sid, uint32_t timeout) +{ + UNUSED(sid); + UNUSED(timeout); + return SGX_SUCCESS; +} + +sgx_status_t invoke_service_ocall( + const uint8_t* pse_message_req, uint32_t pse_message_req_size, + uint8_t* pse_message_resp, uint32_t pse_message_resp_size, + uint32_t timeout + ) +{ + return invoke_service(pse_message_req, pse_message_req_size, + pse_message_resp, pse_message_resp_size, timeout); +} + +sgx_status_t sgx_get_ps_cap( + sgx_ps_cap_t* p_sgx_ps_cap) +{ + if (!p_sgx_ps_cap) + return SGX_ERROR_INVALID_PARAMETER; + + p_sgx_ps_cap->ps_cap0 = 0x7; + p_sgx_ps_cap->ps_cap1 = 0; + return SGX_SUCCESS; +} + +#ifdef __cplusplus +} +#endif diff --git a/sdk/simulation/uae_service_sim/quoting_sim.cpp b/sdk/simulation/uae_service_sim/quoting_sim.cpp new file mode 100644 index 0000000000..0a918fefb9 --- /dev/null +++ b/sdk/simulation/uae_service_sim/quoting_sim.cpp @@ -0,0 +1,462 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include "uae_service_sim.h" +#include "epid_types.h" +#include "se_sig_rl.h" +#include "se_quote_internal.h" +#include "ippcp.h" +#include "deriv.h" +#include "cpusvn_util.h" + +/* The EPID group certificate */ +static const uint8_t EPID_GROUP_CERT[] = { + 0x00, 0x00, 0x00, 0x0B, 0xB3, 0x6F, 0xFF, 0x81, 0xE2, 0x1B, 0x17, 0xEB, + 0x3D, 0x75, 0x3D, 0x61, 0x7E, 0x27, 0xB0, 0xCB, 0xD0, 0x6D, 0x8F, 0x9D, + 0x64, 0xCE, 0xE3, 0xCE, 0x43, 0x4C, 0x62, 0xFD, 0xB5, 0x80, 0xE0, 0x99, + 0x3A, 0x07, 0x56, 0x80, 0xE0, 0x88, 0x59, 0xA4, 0xFD, 0xB5, 0xB7, 0x9D, + 0xE9, 0x4D, 0xAE, 0x9C, 0xEE, 0x3D, 0x66, 0x42, 0x82, 0x45, 0x7E, 0x7F, + 0xD8, 0x69, 0x3E, 0xA1, 0x74, 0xF4, 0x59, 0xEE, 0xD2, 0x74, 0x2E, 0x9F, + 0x63, 0xC2, 0x51, 0x8E, 0xD5, 0xDB, 0xCA, 0x1C, 0x54, 0x74, 0x10, 0x7B, + 0xDC, 0x99, 0xED, 0x42, 0xD5, 0x5B, 0xA7, 0x04, 0x29, 0x66, 0x61, 0x63, + 0xBC, 0xDD, 0x7F, 0xE1, 0x76, 0x5D, 0xC0, 0x6E, 0xE3, 0x14, 0xAC, 0x72, + 0x48, 0x12, 0x0A, 0xA6, 0xE8, 0x5B, 0x08, 0x7B, 0xDA, 0x3F, 0x51, 0x7D, + 0xDE, 0x4C, 0xEA, 0xCB, 0x93, 0xA5, 0x6E, 0xCC, 0xE7, 0x8E, 0x10, 0x84, + 0xBD, 0x19, 0x5A, 0x95, 0xE2, 0x0F, 0xCA, 0x1C, 0x50, 0x71, 0x94, 0x51, + 0x40, 0x1B, 0xA5, 0xB6, 0x78, 0x87, 0x53, 0xF6, 0x6A, 0x95, 0xCA, 0xC6, + 0x8D, 0xCD, 0x36, 0x88, 0x07, 0x28, 0xE8, 0x96, 0xCA, 0x78, 0x11, 0x5B, + 0xB8, 0x6A, 0xE7, 0xE5, 0xA6, 0x65, 0x7A, 0x68, 0x15, 0xD7, 0x75, 0xF8, + 0x24, 0x14, 0xCF, 0xD1, 0x0F, 0x6C, 0x56, 0xF5, 0x22, 0xD9, 0xFD, 0xE0, + 0xE2, 0xF4, 0xB3, 0xA1, 0x90, 0x21, 0xA7, 0xE0, 0xE8, 0xB3, 0xC7, 0x25, + 0xBC, 0x07, 0x72, 0x30, 0x5D, 0xEE, 0xF5, 0x6A, 0x89, 0x88, 0x46, 0xDD, + 0x89, 0xC2, 0x39, 0x9C, 0x0A, 0x3B, 0x58, 0x96, 0x57, 0xE4, 0xF3, 0x3C, + 0x79, 0x51, 0x69, 0x36, 0x1B, 0xB6, 0xF7, 0x05, 0x5D, 0x0A, 0x88, 0xDB, + 0x1F, 0x3D, 0xEA, 0xA2, 0xBA, 0x6B, 0xF0, 0xDA, 0x8E, 0x25, 0xC6, 0xAD, + 0x83, 0x7D, 0x3E, 0x31, 0xEE, 0x11, 0x40, 0xA9 +}; + +/* The report key is the same as BASE_REPORT_KEY in + /trunk/sdk/simulation/tinst/deriv.cpp, which is used in simulation + create_report and verify_report. deriv.cpp is used inside enclave. + So only import this structure. */ +static const uint8_t BASE_REPORT_KEY[] = { + 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, + 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, +}; +// The hard-coded OwnerEpoch. +static const se_owner_epoch_t SIMU_OWNER_EPOCH_MSR = { + 0x54, 0x48, 0x49, 0x53, 0x49, 0x53, 0x4f, 0x57, + 0x4e, 0x45, 0x52, 0x45, 0x50, 0x4f, 0x43, 0x48, +}; + +//simulated QE ISVSVN +static const sgx_isv_svn_t QE_ISVSVN = 1; + +#if !defined(ntohl) +#define ntohl(u32) \ + ((uint32_t)(((((unsigned char*)&(u32))[0]) << 24) \ + + ((((unsigned char*)&(u32))[1]) << 16) \ + + ((((unsigned char*)&(u32))[2]) << 8) \ + + (((unsigned char*)&(u32))[3]))) +#endif + + +sgx_status_t sgx_init_quote( + sgx_target_info_t *p_target_info, + sgx_epid_group_id_t *p_gid) +{ + if(!p_target_info || !p_gid){ + return SGX_ERROR_INVALID_PARAMETER; + } + + p_target_info->attributes.flags = SGX_FLAGS_INITTED; + p_target_info->attributes.xfrm = SGX_XFRM_LEGACY; + memset(&(p_target_info->mr_enclave), 0xEE, sizeof(sgx_measurement_t)); + + //Make sure the size of prebuilt data are the same with target buffer. + static_assert(sizeof(EPID_GROUP_CERT) == sizeof(GroupPubKey), + "Group cert size changed!"); + + //Copy hard coded gid into output buffer. + GroupPubKey *p_epid_group_cert = (GroupPubKey *)const_cast(EPID_GROUP_CERT); + + ((uint8_t *)p_gid)[0] = p_epid_group_cert->gid.data[3]; + ((uint8_t *)p_gid)[1] = p_epid_group_cert->gid.data[2]; + ((uint8_t *)p_gid)[2] = p_epid_group_cert->gid.data[1]; + ((uint8_t *)p_gid)[3] = p_epid_group_cert->gid.data[0]; + + return SGX_SUCCESS; +} + +static sgx_status_t create_qe_report(const sgx_report_t *p_report, + const sgx_quote_nonce_t* p_quote_nonce, + const uint8_t* p_quote, + uint32_t quote_size, + const sgx_cpu_svn_t* cpusvn, + sgx_report_t *p_qe_report) +{ + sgx_report_t temp_qe_report; + // assemble REPORT + memset(&temp_qe_report, 0, sizeof(sgx_report_t)); + //QE_REPORT.BODY.CPUSVN = CPUSVN + if(memcpy_s(&temp_qe_report.body.cpu_svn, + sizeof(temp_qe_report.body.cpu_svn), + cpusvn, sizeof(sgx_cpu_svn_t))) + return SGX_ERROR_UNEXPECTED; + //ProdID same as QE + temp_qe_report.body.isv_prod_id = 1; + //set ISVSVN + temp_qe_report.body.isv_svn = QE_ISVSVN; + //QE_REPORT.BODY.ATTRIBUTES = 0x30000000000000001 + temp_qe_report.body.attributes.flags = SGX_FLAGS_INITTED; + temp_qe_report.body.attributes.xfrm = SGX_XFRM_LEGACY; + //QE_REPORT.BODY.MRENCLAVE = 64 0xEE bytes + memset(&temp_qe_report.body.mr_enclave, 0xEE, sizeof(sgx_measurement_t)); + //QE_REPORT.BODY.MRSIGNER = random value + if(SGX_SUCCESS != sgx_read_rand((uint8_t *)(&temp_qe_report.body.mr_signer), + sizeof(sgx_measurement_t))) + return SGX_ERROR_UNEXPECTED; + //QE_REPORT.KEYID = + if(SGX_SUCCESS != sgx_read_rand((unsigned char *)&temp_qe_report.key_id, + sizeof(sgx_key_id_t))) + return SGX_ERROR_UNEXPECTED; + + //QE_REPORT.BODY.REPORTDATA = SHA256(NONCE || QUOTE) + int sha256_size = 0; + IppsHashState *p_sha_state = NULL; + sgx_status_t sgx_ret = SGX_ERROR_UNEXPECTED; + IppsAES_CMACState* p_cmac_state = NULL; + int ippStateSize = 0; + IppStatus ipp_ret = ippStsNoErr; + + //prepare reprot_data + do + { + IppStatus ret; + ret = ippsHashGetSize(&sha256_size); + if(ret)break; + // p_sha_state need to be freed when exit. + p_sha_state = (IppsHashState *)malloc(sha256_size); + if(!p_sha_state) + { + sgx_ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + ret = ippsHashInit(p_sha_state, IPP_ALG_HASH_SHA256); + if(ret)break; + ret = ippsHashUpdate((uint8_t *)const_cast(p_quote_nonce), + sizeof(sgx_quote_nonce_t), + p_sha_state); + if(ret)break; + + ret = ippsHashUpdate(p_quote, + quote_size, + p_sha_state); + if(ret)break; + + //sha256 final, QE_REPORT.BODY.REPORTDATA = SHA256(NONCE || QUOTE) + ret = ippsHashFinal((uint8_t*)&temp_qe_report.body.report_data, + p_sha_state); + if(ret)break; + + /* calculate CMAC using the report key, same as BASE_REPORT_KEY in + sdk/simulation/tinst/deriv.cpp */ + derivation_data_t dd; + memset(&dd, 0, sizeof(dd)); + dd.size = sizeof(dd_report_key_t); + + dd.key_name = SGX_KEYSELECT_REPORT; + if(memcpy_s(&dd.ddrk.mrenclave,sizeof(dd.ddrk.mrenclave), + &p_report->body.mr_enclave, sizeof(sgx_measurement_t))) + break; + if(memcpy_s(&dd.ddrk.attributes, sizeof(dd.ddrk.attributes), + &p_report->body.attributes, sizeof(sgx_attributes_t))) + break; + if(memcpy_s(&dd.ddrk.csr_owner_epoch, sizeof(dd.ddrk.csr_owner_epoch), + SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t))) + break; + if(memcpy_s(&dd.ddrk.cpu_svn, sizeof(dd.ddrk.cpu_svn), + cpusvn, sizeof(sgx_cpu_svn_t))) + break; + if(memcpy_s(&dd.ddrk.key_id, sizeof(dd.ddrk.key_id), + &temp_qe_report.key_id, sizeof(sgx_key_id_t))) + break; + + ipp_ret = ippsAES_CMACGetSize(&ippStateSize); + if(ipp_ret != ippStsNoErr)break; + + p_cmac_state = (IppsAES_CMACState*)malloc(ippStateSize); + if(p_cmac_state == NULL) + { + sgx_ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // calculate the derived key + ipp_ret = ippsAES_CMACInit((const Ipp8u *)BASE_REPORT_KEY, 16, + p_cmac_state, ippStateSize); + if(ipp_ret != ippStsNoErr) + { + if(ipp_ret == ippStsMemAllocErr) + { + sgx_ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + else + { + sgx_ret = SGX_ERROR_UNEXPECTED; + break; + } + } + + ipp_ret = ippsAES_CMACUpdate((const Ipp8u *)dd.ddbuf, + dd.size, p_cmac_state); + if(ipp_ret != ippStsNoErr)break; + + sgx_key_128bit_t tmp_report_key; + memset(tmp_report_key, 0, sizeof(tmp_report_key)); + ipp_ret = ippsAES_CMACFinal((Ipp8u *)&tmp_report_key, + sizeof(tmp_report_key), p_cmac_state); + if(ipp_ret != ippStsNoErr)break; + + // call cryptographic CMAC function + // CMAC data are *NOT* including MAC and KEYID + ipp_ret = ippsAES_CMACInit((const Ipp8u *)tmp_report_key, 16, + p_cmac_state, ippStateSize); + if(ipp_ret != ippStsNoErr) + { + if(ipp_ret == ippStsMemAllocErr) + { + sgx_ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + else + { + sgx_ret = SGX_ERROR_UNEXPECTED; + break; + } + } + + ipp_ret = ippsAES_CMACUpdate((const Ipp8u *)&temp_qe_report.body, + sizeof(temp_qe_report.body), + p_cmac_state); + if(ipp_ret != ippStsNoErr)break; + + ipp_ret = ippsAES_CMACFinal((Ipp8u *)&temp_qe_report.mac, + sizeof(temp_qe_report.mac), p_cmac_state); + if(ipp_ret != ippStsNoErr)break; + + if(memcpy_s(p_qe_report, sizeof(*p_qe_report), + &temp_qe_report, sizeof(temp_qe_report))) + break; + sgx_ret = SGX_SUCCESS; + }while(0); + if (p_cmac_state) + free(p_cmac_state); + if(p_sha_state) + free(p_sha_state); + return sgx_ret; +} + + +/* +* For quote with SIG-RL +* |--------------------------------------------------------------------| +* |sgx_quote_t|wrap_key_t|iv|payload_size|basic_sig|rl_ver|n2|nrp..|mac| +* |--------------------------------------------------------------------| +* For quote without SIG-RL +* |--------------------------------------------------------------| +* |sgx_quote_t|wrap_key_t|iv|payload_size|basic_sig|rl_ver|n2|mac| +* |--------------------------------------------------------------| +*/ +sgx_status_t sgx_get_quote( + const sgx_report_t *p_report, + sgx_quote_sign_type_t quote_type, + const sgx_spid_t *p_spid, + const sgx_quote_nonce_t *p_nonce, + const uint8_t *p_sig_rl, + uint32_t sig_rl_size, + sgx_report_t *p_qe_report, + sgx_quote_t *p_quote, + uint32_t quote_size) +{ + sgx_status_t ret = SGX_SUCCESS; + GroupPubKey *p_epid_group_cert = (GroupPubKey *)const_cast(EPID_GROUP_CERT); + unsigned int rl_entry_count = 0; + sgx_basename_t basename = {{0}}; + uint64_t required_buffer_size = 0; + se_encrypted_sign_t *p_signature = NULL; + sgx_cpu_svn_t cpusvn = {{0}}; + uint8_t *p_mac = NULL; + + + if(!p_report || !p_spid || !p_quote || !quote_size) + return SGX_ERROR_INVALID_PARAMETER; + if(!p_nonce && p_qe_report) + return SGX_ERROR_INVALID_PARAMETER; + if(p_nonce && !p_qe_report) + return SGX_ERROR_INVALID_PARAMETER; + if(p_sig_rl && sig_rl_size < sizeof(se_sig_rl_t)) + return SGX_ERROR_INVALID_PARAMETER; + if(!p_sig_rl && sig_rl_size) + return SGX_ERROR_INVALID_PARAMETER; + if(quote_type != SGX_UNLINKABLE_SIGNATURE + && quote_type != SGX_LINKABLE_SIGNATURE) + return SGX_ERROR_INVALID_PARAMETER; + + if(p_sig_rl){ + //Check the size of SIG-RL. + se_sig_rl_t *p_sig_rl_temp = (se_sig_rl_t *)const_cast(p_sig_rl); + uint64_t required_sig_rl_size = se_get_sig_rl_size(p_sig_rl_temp); + rl_entry_count = ntohl(p_sig_rl_temp->sig_rl.n2); + if(required_sig_rl_size > sig_rl_size) + { + ret = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + } + + se_static_assert(sizeof(basename) > sizeof(sgx_spid_t)); + /* Because basename has already been zerod, + so we don't need to concatenating with 0s.*/ + if(memcpy_s(&basename, sizeof(basename), p_spid, sizeof(sgx_spid_t))) + { + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + if(SGX_UNLINKABLE_SIGNATURE == quote_type) + { + uint8_t *p = (uint8_t *)&basename + sizeof(sgx_spid_t); + if(SGX_SUCCESS != sgx_read_rand(p, + sizeof(basename) - sizeof(sgx_spid_t))) + { + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + } + + /* sign_size returned from epidMember_signMessage including the RLver + and n2. */ + required_buffer_size = sizeof(sgx_quote_t) + + sizeof(se_wrap_key_t) + + 12 // size of payload_iv + + 4 // size of payload_size + + sizeof(BasicSignature) + + sizeof(RLver_t) + + sizeof(RLCount) + + 16; // size of payload_mac + if(p_sig_rl){ + required_buffer_size += (sizeof(NRProof) * rl_entry_count); + } + + /* If the p_quote is not NULL, then we should make sure the buffer size is + * correct. */ + if(quote_size < required_buffer_size){ + ret = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + + if(SGX_SUCCESS != get_cpusvn(&cpusvn)) + { + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + if(memcmp(&cpusvn, &((const sgx_report_t *)p_report)->body.cpu_svn, + sizeof(sgx_cpu_svn_t))) + { + ret = SGX_ERROR_INVALID_PARAMETER; + goto CLEANUP; + } + + /* Copy the data in the report into quote body. */ + memset(p_quote, 0xEE, quote_size); + p_quote->version = 1; + p_quote->sign_type = (uint16_t)quote_type; + + p_quote->epid_group_id[0] = p_epid_group_cert->gid.data[3]; + p_quote->epid_group_id[1] = p_epid_group_cert->gid.data[2]; + p_quote->epid_group_id[2] = p_epid_group_cert->gid.data[1]; + p_quote->epid_group_id[3] = p_epid_group_cert->gid.data[0]; + + p_quote->qe_svn = QE_ISVSVN; + if(memcpy_s(&p_quote->basename, sizeof(sgx_basename_t), + &basename, sizeof(basename))){ + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + if(memcpy_s(&p_quote->report_body, sizeof(p_quote->report_body), + &((const sgx_report_t *)p_report)->body, sizeof(sgx_report_body_t))) + { + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + p_quote->signature_len = (uint32_t)(required_buffer_size - sizeof(sgx_quote_t)); + + // Set the payload_size + p_signature = (se_encrypted_sign_t *)(p_quote->signature); + p_signature->payload_size = (uint32_t)(sizeof(BasicSignature) + + sizeof(RLver_t) + + sizeof(RLCount) + + (sizeof(NRProof) * rl_entry_count)); + + if(SGX_SUCCESS != sgx_read_rand(p_signature->iv, sizeof(p_signature->iv))) + { + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + p_mac = (uint8_t *)(&p_signature->basic_sign) + p_signature->payload_size; + if(SGX_SUCCESS != sgx_read_rand(p_mac, 16)) + { + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + + if(p_qe_report) + ret = create_qe_report(p_report, p_nonce, (uint8_t*)p_quote, + quote_size, &cpusvn, p_qe_report); + +CLEANUP: + return ret; +} //sgx_get_quote + +sgx_status_t SGXAPI sgx_report_attestation_status( + const sgx_platform_info_t *p_platform_info, + int attestation_status, + sgx_update_info_bit_t *p_update_info) +{ + UNUSED(p_platform_info); + UNUSED(attestation_status); + memset(p_update_info, 0, sizeof(sgx_update_info_bit_t)); + return SGX_SUCCESS; +} + diff --git a/sdk/simulation/uae_service_sim/uae_service_deploy.c b/sdk/simulation/uae_service_sim/uae_service_deploy.c new file mode 100644 index 0000000000..ddb7b05e54 --- /dev/null +++ b/sdk/simulation/uae_service_sim/uae_service_deploy.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +void Java_com_voidel_security_sgx_uae_SGX_1AEServices_initializeNativeAEServices(){} +void sgx_get_quote(){} +void sgx_get_quote_size(){} +void sgx_init_quote(){} +void get_launch_token(){} +void close_session_ocall(){} +void create_session_ocall(){} +void exchange_report_ocall(){} +void invoke_service_ocall(){} +void sgx_report_remote_attestation_failure(){} +void sgx_get_ps_cap(){} diff --git a/sdk/simulation/uae_service_sim/uae_service_sim.h b/sdk/simulation/uae_service_sim/uae_service_sim.h new file mode 100644 index 0000000000..a85827eaf6 --- /dev/null +++ b/sdk/simulation/uae_service_sim/uae_service_sim.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef UAE_SERVICE_SIM_H +#define UAE_SERVICE_SIM_H + +#include +#include +#include +#include + +#include "arch.h" +#include "sgx_uae_service.h" +#include "uae_service_internal.h" +#include "pse_types.h" +#include "sgx_tseal.h" +#include "util.h" +#include "se_memcpy.h" +#include "sgx_dh.h" +#include "sgx_read_rand.h" +#include "se_lock.hpp" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _vmc_sim_t { + uint8_t counter_id[3]; + uint8_t nonce[13]; + uint32_t counter_value; +} vmc_sim_t; + +sgx_status_t get_counter_id(vmc_sim_t *p_vmc_sim); +sgx_status_t del_vmc_sim(const vmc_sim_t *p_vmc_sim); + +sgx_status_t store_vmc_sim(const vmc_sim_t *p_vmc_sim); + +sgx_status_t load_vmc_sim(vmc_sim_t *p_vmc_sim); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/sdk/simulation/uinst/Makefile b/sdk/simulation/uinst/Makefile new file mode 100644 index 0000000000..77b45f4b2f --- /dev/null +++ b/sdk/simulation/uinst/Makefile @@ -0,0 +1,77 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +SIM_DIR := $(CUR_DIR)/.. + +ifndef DEBUG +CXXFLAGS += -DDISABLE_TRACE +CFLAGS += -DDISABLE_TRACE +endif + +CPPFLAGS += $(ADDED_INC) +CPPFLAGS += -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal \ + -I$(SIM_DIR)/assembly/ \ + -I$(SIM_DIR)/assembly/linux \ + -I$(LINUX_PSW_DIR)/urts \ + -I$(LINUX_EXTERNAL_DIR)/crypto_px/include + +CXXFLAGS += -Werror -fPIC + +OBJ1 := linux/set_tls.o \ + linux/restore_tls.o + +LIBSESIMU_U := libsesimu_u.a + +.PHONY:all +all: $(LIBSESIMU_U) + +enclave_mngr.o: enclave_mngr.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + +# Explicitly disable optimization for 'u_instructions.cpp', +# since the '_SE3' function has assumptions on stack layout. +# +u_instructions.o: u_instructions.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -O0 -c $< -o $@ + +$(LIBSESIMU_U): u_instructions.o enclave_mngr.o $(OBJ1) + $(AR) rcs $@ $^ + +$(OBJ1): + $(MAKE) -C linux + +.PHONY: clean +clean: + $(MAKE) -C linux clean + @$(RM) *.o *.a *.so diff --git a/sdk/simulation/uinst/enclave_mngr.cpp b/sdk/simulation/uinst/enclave_mngr.cpp new file mode 100644 index 0000000000..c41ea62d5c --- /dev/null +++ b/sdk/simulation/uinst/enclave_mngr.cpp @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include "se_memory.h" +#include "se_memcpy.h" +#include "util.h" +#include "enclave_mngr.h" +#include "se_atomic.h" + + +static uint32_t atomic_inc32(uint32_t volatile *val) +{ + return se_atomic_inc(val); +} + +uint32_t CEnclaveSim::m_counter = 1; + +sgx_enclave_id_t CEnclaveSim::gen_enclave_id(void) +{ + //getpid() is to simulate fork() scenario, refer to do_ecall in sig_handler.cpp + sgx_enclave_id_t id = ((uint64_t)getpid() << 32) | atomic_inc32(&m_counter); + return id; +} + +CEnclaveSim::CEnclaveSim(const secs_t* secs) +{ + m_cpages = static_cast(secs->size >> SE_PAGE_SHIFT); + m_flags = new si_flags_t[m_cpages]; + + // pages flags are initialized to -1 + memset(m_flags, 0xff, m_cpages * sizeof(si_flags_t)); + + memcpy_s(&m_secs, sizeof(m_secs), secs, sizeof(*secs)); + + m_enclave_id = gen_enclave_id(); +} + +CEnclaveSim::~CEnclaveSim() +{ + delete[] m_flags; + se_virtual_free(m_secs.base, (size_t)m_secs.size, MEM_RELEASE); +} + +sgx_enclave_id_t CEnclaveSim::get_enclave_id() const +{ + return m_enclave_id; +} + +secs_t* CEnclaveSim::get_secs() +{ + return &m_secs; +} + +size_t CEnclaveSim::get_pg_idx(const void* pgaddr) const +{ + return PTR_DIFF(pgaddr, m_secs.base) >> SE_PAGE_SHIFT; +} + + +bool CEnclaveSim::validate_pg_and_flags(const void* addr, si_flags_t flags) +{ + // Must be page aligned + if (!IS_PAGE_ALIGNED(addr)) + return false; + + size_t page_idx = get_pg_idx(addr); + // Must be within enclave address space + + if (page_idx >= m_cpages) + return false; + + // Requested flags should only set those visible by instuctions + if ((flags & (~SI_FLAGS_EXTERNAL))) + return false; + + return true; +} + + +bool CEnclaveSim::add_page(const void* addr, si_flags_t flags) +{ + if (!validate_pg_and_flags(addr, flags)) + return false; + + // We only deal with these flags + flags &= static_cast(SI_FLAGS_EXTERNAL); + + // Must not have been added yet + size_t page_idx = get_pg_idx(addr); + + if (m_flags[page_idx] != (si_flags_t)-1) + return false; + + m_flags[page_idx] = flags; + + return true; +} + +bool CEnclaveSim::remove_page(const void* epc_lin_addr) +{ + size_t page_idx = get_pg_idx(epc_lin_addr); + + if (m_flags[page_idx] != (si_flags_t)-1) { + m_flags[page_idx] = (si_flags_t)-1; + return true; + } + + return false; +} +bool CEnclaveSim::is_tcs_page(const void* addr) const +{ + // Must be page aligned + if (!IS_PAGE_ALIGNED(addr)) + return false; + + size_t page_idx = get_pg_idx(addr); + + // Must be within enclave address space + if (page_idx >= m_cpages) + return false; + + return (m_flags[page_idx] & SI_FLAG_PT_MASK) == SI_FLAG_TCS; +} + + +////////////////////////////////////////////////////////////////////// +CEnclaveMngr::CEnclaveMngr() +{ + se_mutex_init(&m_list_lock); +} + +CEnclaveMngr::~CEnclaveMngr() +{ + se_mutex_destroy(&m_list_lock); + + std::list::iterator it = m_enclave_list.begin(); + for (; it != m_enclave_list.end(); ++it) + { + delete (*it); + } +} + +// Note: this singleton implemenation is not multi-threading safe. +CEnclaveMngr* CEnclaveMngr::get_instance() +{ + static CEnclaveMngr mngr; + return &mngr; +} + +// Use constructor attribute to make sure that the later calling of +// CEnclaveMngr::get_instance() is MT-safe. +__attribute__ ((__constructor__)) static void build_mngr_instance() +{ + CEnclaveMngr::get_instance(); +} + +void CEnclaveMngr::add(CEnclaveSim* ce) +{ + if (ce != NULL) + { + se_mutex_lock(&m_list_lock); + m_enclave_list.push_back(ce); + se_mutex_unlock(&m_list_lock); + } +} + +void CEnclaveMngr::remove(CEnclaveSim* ce) +{ + if (ce != NULL) + { + se_mutex_lock(&m_list_lock); + m_enclave_list.remove(ce); + se_mutex_unlock(&m_list_lock); + } +} + +CEnclaveSim* CEnclaveMngr::get_enclave(const sgx_enclave_id_t id) +{ + CEnclaveSim* ce = NULL; + + se_mutex_lock(&m_list_lock); + + std::list::iterator it = m_enclave_list.begin(); + for (; it != m_enclave_list.end(); ++it) + { + if ((*it)->get_enclave_id() == id) + { + ce = *it; + break; + } + } + + se_mutex_unlock(&m_list_lock); + return ce; +} + +CEnclaveSim* CEnclaveMngr::get_enclave(const void* base_addr) +{ + CEnclaveSim* ce = NULL; + + se_mutex_lock(&m_list_lock); + + std::list::iterator it = m_enclave_list.begin(); + for (; it != m_enclave_list.end(); ++it) + { + secs_t* secs = (*it)->get_secs(); + if (base_addr >= secs->base && + PTR_DIFF(base_addr, secs->base) < secs->size) + { + ce = *it; + break; + } + } + + se_mutex_unlock(&m_list_lock); + return ce; +} + +CEnclaveSim* CEnclaveMngr::get_enclave(const secs_t* secs) +{ + // The pEnclaveSECS field might not have been initialized yet. + return get_enclave(secs->base); +} diff --git a/sdk/simulation/uinst/enclave_mngr.h b/sdk/simulation/uinst/enclave_mngr.h new file mode 100644 index 0000000000..2e7cde5114 --- /dev/null +++ b/sdk/simulation/uinst/enclave_mngr.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SE_ENCLAVE_MNGR_H_ +#define _SE_ENCLAVE_MNGR_H_ + +#include + +#include "arch.h" +#include "sgx_eid.h" +#include "se_thread.h" + +class CEnclaveSim +{ +public: + CEnclaveSim(const secs_t* secs); + virtual ~CEnclaveSim(void); + + // The following functions are declared virtual so that they can + // be called from the tRTS instruction simulation functions. + + virtual sgx_enclave_id_t get_enclave_id() const; + virtual secs_t* get_secs(); + + virtual size_t get_pg_idx(const void* pgaddr) const; + virtual bool add_page(const void* pgaddr, si_flags_t flags); + virtual bool remove_page(const void* epc_lin_addr); + virtual bool is_tcs_page(const void* pgaddr) const; + +private: + secs_t m_secs; + si_flags_t* m_flags; // memory managed by CEnclaveSim + size_t m_cpages; // page count + + sgx_enclave_id_t m_enclave_id; // an unique Id for the enclave + static uint32_t m_counter; // enclave counter + + sgx_enclave_id_t gen_enclave_id(void); + bool validate_pg_and_flags(const void* pgaddr, si_flags_t flags); + + CEnclaveSim(const CEnclaveSim& es); + CEnclaveSim& operator=(const CEnclaveSim& es); +}; + + +class CEnclaveMngr +{ +public: + + // The factory method for CEnclaveMngr. + // + // Note: this factory is not thread-safe. + + static CEnclaveMngr* get_instance(); + ~CEnclaveMngr(); + + void add(CEnclaveSim* ce); + void remove(CEnclaveSim* ce); + + CEnclaveSim* get_enclave(const sgx_enclave_id_t id); + CEnclaveSim* get_enclave(const secs_t* secs); + CEnclaveSim* get_enclave(const void* base_addr); + +private: + std::list m_enclave_list; + + // to protect the access to m_enclave_list + se_mutex_t m_list_lock; + + CEnclaveMngr(); + CEnclaveMngr(const CEnclaveMngr& em); + CEnclaveMngr& operator=(const CEnclaveMngr& em); +}; + +#endif diff --git a/sdk/simulation/uinst/linux/Makefile b/sdk/simulation/uinst/linux/Makefile new file mode 100644 index 0000000000..6e5eaa9b79 --- /dev/null +++ b/sdk/simulation/uinst/linux/Makefile @@ -0,0 +1,58 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../../buildenv.mk + +SIM_DIR := $(CUR_DIR)/../.. + +ifndef DEBUG +CXXFLAGS += -DDISABLE_TRACE +CFLAGS += -DDISABLE_TRACE +endif + +CFLAGS += -Werror -fPIC + +CPPFLAGS += $(ADDED_INC) # for ubuntu 11 and later version +CPPFLAGS += -I.. \ + -I$(SIM_DIR)/assembly \ + -I$(SIM_DIR)/assembly/linux \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal + +SOURCE := $(wildcard *.c) +OBJECT := $(SOURCE:.c=.o) + +.PHONY: all +all: $(OBJECT) + +.PHONY: clean +clean: + @$(RM) *.o *~ diff --git a/sdk/simulation/uinst/linux/get_tcs.c b/sdk/simulation/uinst/linux/get_tcs.c new file mode 100644 index 0000000000..3b85097c00 --- /dev/null +++ b/sdk/simulation/uinst/linux/get_tcs.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "td_mngr.h" + +/* + * Get the TD address - this function needs to be called + * when the DTV value has not been restored yet. + */ +void* get_td_addr(void) +{ + dtv_t* dtv = GET_DTV(); + return read_dtv_val(dtv); +} + +/* vim: set ts=4 sw=4 cin et: */ + diff --git a/sdk/simulation/uinst/linux/restore_tls.c b/sdk/simulation/uinst/linux/restore_tls.c new file mode 100644 index 0000000000..329682ffd0 --- /dev/null +++ b/sdk/simulation/uinst/linux/restore_tls.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * restore_tls.c + * Implemente the TLS support in simulation mode + */ + +#include "td_mngr.h" + +/* + * Restore the old DTV value. + */ +int td_mngr_restore_td(tcs_t *tcs) +{ + dtv_t* dtv __attribute__((unused)); + tcs_sim_t *tcs_sim; + + if (!tcs) + return 0; + + dtv = GET_DTV(); + tcs_sim = (tcs_sim_t *)tcs->reserved; + set_dtv_val(dtv, tcs_sim->saved_dtv); + SET_FS_GS_0(tcs_sim->saved_fs_gs_0); + return 1; +} + +/* vim: set ts=4 sw=4 cin et: */ diff --git a/sdk/simulation/uinst/linux/set_tls.c b/sdk/simulation/uinst/linux/set_tls.c new file mode 100644 index 0000000000..3bd5134ccd --- /dev/null +++ b/sdk/simulation/uinst/linux/set_tls.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * set_tls.c + * Implemente the TLS support in simulation mode + */ + +#include "td_mngr.h" +#include "util.h" + +int td_mngr_set_td(void *enclave_base, tcs_t *tcs) +{ + dtv_t* dtv; + tcs_sim_t *tcs_sim; + + if (!tcs) + return 0; + + /* save the old DTV[0].pointer->val */ + dtv = GET_DTV(); + tcs_sim = (tcs_sim_t *)tcs->reserved; + tcs_sim->saved_dtv = (uintptr_t)read_dtv_val(dtv); + + /* save the old fs:0x0 or gs:0x0 value */ + tcs_sim->saved_fs_gs_0 = GET_FS_GS_0(); + + /* set the DTV[0].pointer->val to TLS address */ + uintptr_t *tib = GET_PTR(uintptr_t, enclave_base, tcs->ofs_base); + set_dtv_val(dtv, tib); + + /* set the fs:0x0 or gs:0x0 to TLS address */ + SET_FS_GS_0(tib); + return 1; +} + +/* vim: set ts=4 sw=4 cin et: */ diff --git a/sdk/simulation/uinst/td_mngr.h b/sdk/simulation/uinst/td_mngr.h new file mode 100644 index 0000000000..336023df8e --- /dev/null +++ b/sdk/simulation/uinst/td_mngr.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _TD_MNGR_H_ +#define _TD_MNGR_H_ + +#include "arch.h" +#include "rts.h" + +// use tcs->reserved field to save some information +typedef struct _tcs_sim_t +{ + uintptr_t saved_aep; + size_t tcs_state; + uintptr_t saved_dtv; + uintptr_t saved_fs_gs_0; +} tcs_sim_t; + +#define TCS_STATE_INACTIVE 0 //The TCS is available for a normal EENTER +#define TCS_STATE_ACTIVE 1 //A Processor is currently executing in the context of this TCS + +// The 1st parameter of enter_enclave function (enclave_enclave.S) is tcs. +// If the parameter is changed, or EENTER_PROLOG is changed, the macro should be updated accordingly. +#ifdef SE_GNU64 +#define GET_TCS_PTR(xbp) (tcs_t *)(*(uintptr_t *)((size_t)(xbp) - 10 * sizeof(uintptr_t))) +#else +#define GET_TCS_PTR(xbp) (tcs_t *)(*(uintptr_t *)((size_t)(xbp) + 2 * sizeof(uintptr_t))) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +//Add the implementation to get the _tls_array pointer in GNU here. +#include "gnu_tls.h" +extern uint8_t __ImageBase; +int td_mngr_set_td(void *enclave_base, tcs_t *tcs); +int td_mngr_restore_td(tcs_t *tcs); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/uinst/u_instructions.cpp b/sdk/simulation/uinst/u_instructions.cpp new file mode 100644 index 0000000000..c7a438af6d --- /dev/null +++ b/sdk/simulation/uinst/u_instructions.cpp @@ -0,0 +1,320 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// u_instructions.cpp -- It simulates Enclave instructions. +#include +#include + +#include +#include + +#include "arch.h" +#include "util.h" +#include "se_memory.h" +#include "se_memcpy.h" +#include "se_trace.h" +#include "enclave.h" +#include "td_mngr.h" + +#include "lowlib.h" +#include "sgxsim.h" +#include "enclave_mngr.h" +#include "u_instructions.h" + +#include "ippcp.h" + + +static uintptr_t _EINIT(secs_t* secs, enclave_css_t* css, token_t* launch); +static uintptr_t _ECREATE (page_info_t* pi); +static uintptr_t _EADD (page_info_t* pi, void* epc_lin_addr); +static uintptr_t _EREMOVE(const void* epc_lin_addr); + +//////////////////////////////////////////////////////////////////////// +#define __GP__() exit(EXIT_FAILURE) + +#define GP() do { \ + SE_TRACE(SE_TRACE_DEBUG, "#GP on %s, line: %d\n", __FILE__, __LINE__); \ + __GP__(); \ + } while (0) + +#define GP_ON(cond) if (cond) GP() + +#define GP_ON_EENTER GP_ON + +#define mcp_same_size(dst_ptr, src_ptr, size) memcpy_s(dst_ptr, size, src_ptr, size) + +uintptr_t _EINIT(secs_t* secs, enclave_css_t *css, token_t *launch) +{ + CEnclaveMngr *mngr = CEnclaveMngr::get_instance(); + assert(mngr != NULL); + + CEnclaveSim* ce = mngr->get_enclave(secs); + GP_ON(ce == NULL); + + GP_ON((ce->get_secs()->attributes.flags & SGX_FLAGS_INITTED) != 0); + + // Fill MREnclave, MRSigner, ISVPRODID, ISVSVN + secs_t* this_secs = ce->get_secs(); + if (css != NULL) { + // Check signature + if ((css->body.attribute_mask.xfrm & this_secs->attributes.xfrm) + != (css->body.attribute_mask.xfrm & css->body.attributes.xfrm)) + { + SE_TRACE(SE_TRACE_DEBUG, + "SECS attributes.xfrm does NOT match signature attributes.xfrm\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + + if ((css->body.attribute_mask.flags & this_secs->attributes.flags) + != (css->body.attribute_mask.flags & css->body.attributes.flags)) + { + SE_TRACE(SE_TRACE_DEBUG, + "SECS attributes.flag does NOT match signature attributes.flag\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + + mcp_same_size(&this_secs->mr_enclave, &css->body.enclave_hash, sizeof(sgx_measurement_t)); + this_secs->isv_prod_id = css->body.isv_prod_id; + this_secs->isv_svn = css->body.isv_svn; + + ippsHashMessage(css->key.modulus, SE_KEY_SIZE, (Ipp8u*)&this_secs->mr_signer, IPP_ALG_HASH_SHA256); + } + + // Check launch token + if (launch != NULL && launch->body.valid) { + if (memcmp(&launch->body.attributes, &this_secs->attributes, sizeof(sgx_attributes_t))) + { + SE_TRACE(SE_TRACE_DEBUG, + "SECS attributes does NOT match launch token attribuets\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + } + + // Mark it initialized + this_secs->attributes.flags |= SGX_FLAGS_INITTED; + + return SGX_SUCCESS; +} + +static inline bool is_power_of_two(size_t n) +{ + return (n != 0) && (!(n & (n - 1))); +} + +// Returns the pointer to the Enclave instance on success. +uintptr_t _ECREATE(page_info_t* pi) +{ + secs_t* secs = reinterpret_cast(pi->src_page); + + // Enclave size must be at least 2 pages and a power of 2. + GP_ON(!is_power_of_two((size_t)secs->size)); + GP_ON(secs->size < (SE_PAGE_SIZE << 1)); + + CEnclaveSim* ce = new CEnclaveSim(secs); + void* addr; + + // `ce' is not checked against NULL, since it is not + // allocated with new(std::no_throw). + addr = se_virtual_alloc(NULL, (size_t)secs->size, MEM_COMMIT); + if (addr == NULL) { + delete ce; + return 0; + } + + // Mark all the memory inaccessible. + se_virtual_protect(addr, (size_t)secs->size, SGX_PROT_NONE); + ce->get_secs()->base = addr; + + CEnclaveMngr::get_instance()->add(ce); + return reinterpret_cast(ce); +} + +uintptr_t _EADD(page_info_t* pi, void *epc_lin_addr) +{ + void *src_page = pi->src_page; + CEnclaveMngr *mngr = CEnclaveMngr::get_instance(); + CEnclaveSim *ce = mngr->get_enclave(pi->lin_addr); + + if (ce == NULL) { + SE_TRACE(SE_TRACE_DEBUG, "failed to get enclave instance\n"); + return SGX_ERROR_UNEXPECTED; + } + + GP_ON(!IS_PAGE_ALIGNED(epc_lin_addr)); + GP_ON((ce->get_secs()->attributes.flags & SGX_FLAGS_INITTED) != 0); + + // Make the page writable before doing memcpy() + se_virtual_protect(epc_lin_addr, SE_PAGE_SIZE, SI_FLAGS_RW); + + mcp_same_size(epc_lin_addr, src_page, SE_PAGE_SIZE); + + se_virtual_protect(epc_lin_addr, SE_PAGE_SIZE, (uint32_t)pi->sec_info->flags); + + GP_ON(!ce->add_page(pi->lin_addr, pi->sec_info->flags)); + return SGX_SUCCESS; +} + +uintptr_t _EREMOVE(const void *epc_lin_addr) +{ + CEnclaveMngr *mngr = CEnclaveMngr::get_instance(); + CEnclaveSim *ce = mngr->get_enclave(epc_lin_addr); + + GP_ON(!ce); + GP_ON(!IS_PAGE_ALIGNED(epc_lin_addr)); + + return ce->remove_page(epc_lin_addr) ? 0 : -1; +} + +//////////////////////////////////////////////////////////////////////// + +// Master entry functions + + +void _SE3(uintptr_t xax, uintptr_t xbx, + uintptr_t xcx, uintptr_t xdx, + uintptr_t xsi, uintptr_t xdi) +{ + UNUSED(xdx); + + switch (xax) + { + case SE_EENTER: + uintptr_t xip; + void * enclave_base_addr; + se_pt_regs_t* p_pt_regs; + tcs_t* tcs; + tcs_sim_t* tcs_sim; + ssa_gpr_t* p_ssa_gpr; + secs_t* secs; + CEnclaveMngr* mngr; + CEnclaveSim* ce; + + // xbx contains the address of a TCS + tcs = reinterpret_cast(xbx); + + // Is TCS pointer page-aligned? + GP_ON_EENTER(!IS_PAGE_ALIGNED(tcs)); + + mngr = CEnclaveMngr::get_instance(); + assert(mngr != NULL); + + // Is it really a TCS? + ce = mngr->get_enclave(tcs); + GP_ON_EENTER(ce == NULL); + GP_ON_EENTER(!ce->is_tcs_page(tcs)); + + // Check the EntryReason + tcs_sim = reinterpret_cast(tcs->reserved); + GP_ON_EENTER(tcs_sim->tcs_state != TCS_STATE_INACTIVE); + GP_ON_EENTER(tcs->cssa >= tcs->nssa); + + secs = ce->get_secs(); + enclave_base_addr = secs->base; + + p_ssa_gpr = reinterpret_cast(reinterpret_cast(enclave_base_addr) + static_cast(tcs->ossa) + + secs->ssa_frame_size * SE_PAGE_SIZE + - sizeof(ssa_gpr_t)); + + tcs_sim->saved_aep = xcx; + + p_pt_regs = reinterpret_cast(get_bp()); + p_ssa_gpr->REG(bp_u) = p_pt_regs->xbp; + + p_ssa_gpr->REG(sp_u) = reinterpret_cast(p_pt_regs + 1); + xcx = p_pt_regs->xip; + + xip = reinterpret_cast(enclave_base_addr); + GP_ON_EENTER(xip == 0); + + //set the _tls_array to point to the self_addr of TLS section inside the enclave + GP_ON_EENTER(td_mngr_set_td(enclave_base_addr, tcs) == false); + + // Destination depends on STATE + xip += (uintptr_t)tcs->oentry; + tcs_sim->tcs_state = TCS_STATE_ACTIVE; + + // Link the TCS to the thread + GP_ON_EENTER((secs->attributes.flags & SGX_FLAGS_INITTED) == 0); + + // Replace the return address on the stack with the enclave entry, + // so that when we return from this function, we'll enter the enclave. + enclu_regs_t regs; + regs.xax = tcs->cssa; + regs.xbx = reinterpret_cast(tcs); + regs.xcx = xcx; + regs.xdx = 0; + regs.xsi = xsi; + regs.xdi = xdi; + regs.xbp = p_ssa_gpr->REG(bp_u); + regs.xsp = p_ssa_gpr->REG(sp_u); + regs.xip = xip; + + load_regs(®s); + + // Returning from this function enters the enclave + return; + default: + // There's only 1 ring 3 instruction outside the enclave: EENTER. + GP(); + } +} + +uintptr_t _SE0(uintptr_t xax, uintptr_t xbx, + uintptr_t xcx, uintptr_t xdx, + uintptr_t xsi, uintptr_t xdi) +{ + UNUSED(xsi), UNUSED(xdi); + + switch (xax) + { + case SE_ECREATE: + return _ECREATE(reinterpret_cast(xbx)); + + case SE_EADD: + return _EADD(reinterpret_cast(xbx), + reinterpret_cast(xcx)); + + case SE_EINIT: + return _EINIT(reinterpret_cast(xbx), + reinterpret_cast(xcx), + reinterpret_cast(xdx)); + + case SE_EREMOVE: + return _EREMOVE(reinterpret_cast(xcx)); + + default: + GP(); + } + + return 0; +} + diff --git a/sdk/simulation/uinst/u_instructions.h b/sdk/simulation/uinst/u_instructions.h new file mode 100644 index 0000000000..a35a9a1201 --- /dev/null +++ b/sdk/simulation/uinst/u_instructions.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _UINSTRUCTIONS_H__ +#define _UINSTRUCTIONS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// this struct defines the way the registers are stored on the +// stack during an EENTER. +typedef struct _se_pt_regs_t { +#if defined(__x86_64__) + uintptr_t xbp; + uintptr_t xip; +#else + uintptr_t xbp; + uintptr_t xip; + uintptr_t xax; + uintptr_t xbx; + uintptr_t xcx; + uintptr_t xdx; + uintptr_t xsi; + uintptr_t xdi; +#endif +} se_pt_regs_t; + +uintptr_t _SE0(uintptr_t xax, uintptr_t xbx, + uintptr_t xcx, uintptr_t xdx, + uintptr_t xsi, uintptr_t xdi); + +void _SE3(uintptr_t xax, uintptr_t xbx, + uintptr_t xcx, uintptr_t xdx, + uintptr_t xsi, uintptr_t xdi); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/urtssim/Makefile b/sdk/simulation/urtssim/Makefile new file mode 100644 index 0000000000..5e02f9ac6c --- /dev/null +++ b/sdk/simulation/urtssim/Makefile @@ -0,0 +1,37 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +.PHONY: all clean +all: + $(MAKE) -C linux + +clean: + $(MAKE) -C linux clean diff --git a/sdk/simulation/urtssim/cpusvn_util.cpp b/sdk/simulation/urtssim/cpusvn_util.cpp new file mode 100644 index 0000000000..4669888fba --- /dev/null +++ b/sdk/simulation/urtssim/cpusvn_util.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "cpusvn_util.h" +#include "se_wrapper.h" +#include "sgx_error.h" +#include "rts_sim.h" + +#include +#include +#include +#include +#include +#include + +#define MAX_FILE_PATH 260 + +extern "C" bool get_file_path(char *config_path, uint32_t length) +{ + if(config_path == NULL || length == 0) + { + return false; + } + + char *local_path = getenv(ENV_PAR); + if(local_path == NULL) + return false; + snprintf(config_path, length, "%s%s", local_path, FILE_NAME); + + return true; +} + + +extern "C" bool write_cpusvn_file(const char *file_path, const sgx_cpu_svn_t *cpusvn) +{ + if(file_path == NULL || cpusvn == NULL) + { + return false; + } + FILE *fp = NULL; + if(NULL == (fp = fopen(file_path, "wb"))) + { + return false; + } + if(fwrite(cpusvn, 1, sizeof(sgx_cpu_svn_t), fp) != sizeof(sgx_cpu_svn_t)) + { + fclose(fp); + return false; + } + fclose(fp); + return true; +} + + +extern "C" bool read_cpusvn_file(const char *config_path, sgx_cpu_svn_t *cpusvn_ptr) +{ + if(config_path == NULL || cpusvn_ptr == NULL) + return false; + + FILE *fp = NULL; + long fsize = 0; + sgx_cpu_svn_t temp_cpusvn = {{0}}; + size_t result = 0; + + if(NULL == (fp = fopen(config_path, "rb"))) + { + SE_TRACE(SE_TRACE_DEBUG, "Couldn't find/open the configuration file %s.\n", config_path); + memcpy_s(cpusvn_ptr, sizeof(sgx_cpu_svn_t), &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)); + return true; + } + + //check and read configure file format + if(fseek(fp, 0, SEEK_END)) + { + memcpy_s(&temp_cpusvn, sizeof(temp_cpusvn), &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)); + goto clean_return; + } + + fsize = ftell(fp); + rewind(fp); + + if(fsize != sizeof(sgx_cpu_svn_t)) + { + SE_TRACE(SE_TRACE_DEBUG, "The configuration file format is not correct. Using default CPUSVN value.\n"); + memcpy_s(&temp_cpusvn, sizeof(temp_cpusvn), &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)); + goto clean_return; + } + + result = fread(&temp_cpusvn, 1, fsize, fp); + if(result != (size_t)fsize) + { + SE_TRACE(SE_TRACE_DEBUG, "Failed to read configuration file. Using default CPUSVN value.\n"); + memcpy_s(&temp_cpusvn, sizeof(temp_cpusvn), &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)); + goto clean_return; + } + + if(memcmp(&temp_cpusvn, &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)) && + memcmp(&temp_cpusvn, &UPGRADED_CPUSVN, sizeof(UPGRADED_CPUSVN)) && + memcmp(&temp_cpusvn, &DOWNGRADED_CPUSVN, sizeof(DOWNGRADED_CPUSVN))) + { + SE_TRACE(SE_TRACE_DEBUG, "The configuration file format is not correct. Using default CPUSVN value.\n"); + memcpy_s(&temp_cpusvn, sizeof(temp_cpusvn), &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)); + goto clean_return; + } + +clean_return: + fclose(fp); + memcpy_s(cpusvn_ptr, sizeof(*cpusvn_ptr), &temp_cpusvn, sizeof(temp_cpusvn)); + return true; + } + + +extern "C" int get_cpusvn(sgx_cpu_svn_t *cpu_svn) +{ + if( cpu_svn == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + sgx_cpu_svn_t temp_cpusvn = {{0}}; + + char config_path[MAX_FILE_PATH]; + memset(config_path, 0, MAX_FILE_PATH); + + if((get_file_path(config_path, MAX_FILE_PATH)) == false) + { + SE_TRACE(SE_TRACE_DEBUG, "Get configuration file path failed. Using default CPUSVN value\n"); + memcpy_s(cpu_svn, sizeof(*cpu_svn), &DEFAULT_CPUSVN, sizeof(DEFAULT_CPUSVN)); + return SGX_SUCCESS; + } + + bool r = read_cpusvn_file(config_path, &temp_cpusvn); + (void)r, assert (r); + + memcpy_s(cpu_svn, sizeof(*cpu_svn), &temp_cpusvn, sizeof(temp_cpusvn)); + + return SGX_SUCCESS; +} + diff --git a/sdk/simulation/urtssim/cpusvn_util.h b/sdk/simulation/urtssim/cpusvn_util.h new file mode 100644 index 0000000000..4284671ce5 --- /dev/null +++ b/sdk/simulation/urtssim/cpusvn_util.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef CPUSVN_UTIL_H_ +#define CPUSVN_UTIL_H_ + +#include "arch.h" + +#define ENV_PAR "HOME" +#define FILE_NAME "/.cpusvn.conf" + +#ifdef __cplusplus +extern "C" { +#endif + +bool get_file_path(char *config_path, uint32_t length); +bool write_cpusvn_file(const char *config_path, const sgx_cpu_svn_t *cpusvn); +bool read_cpusvn_file(const char *config_path, sgx_cpu_svn_t *cpusvn_ptr); +int get_cpusvn(sgx_cpu_svn_t *cpu_svn); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/simulation/urtssim/enclave_creator_sim.cpp b/sdk/simulation/urtssim/enclave_creator_sim.cpp new file mode 100644 index 0000000000..3f92291f24 --- /dev/null +++ b/sdk/simulation/urtssim/enclave_creator_sim.cpp @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "enclave_creator_sim.h" +#include "enclave_mngr.h" +#include "se_detect.h" +#include "driver_api.h" +#include "enclave.h" +#include "rts.h" +#include "routine.h" +#include "cpu_features.h" +#include "se_error_internal.h" +#include "util.h" +#include "cpusvn_util.h" +#include "rts_sim.h" +#include +#include + +EnclaveCreator* g_enclave_creator = new EnclaveCreatorSim(); + +int EnclaveCreatorSim::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae) +{ + UNUSED(ae); + return ::create_enclave(secs, enclave_id, start_addr); +} +int EnclaveCreatorSim::add_enclave_page(sgx_enclave_id_t enclave_id, void *src, uint64_t offset, const sec_info_t &sinfo, uint32_t attr) +{ + void* source = src; + uint8_t color_page[SE_PAGE_SIZE]; + if(!source) + { + memset(color_page, 0, SE_PAGE_SIZE); + source = reinterpret_cast(&color_page); + } + return ::add_enclave_page(enclave_id, source, (size_t)offset, sinfo, attr); +} +int EnclaveCreatorSim::init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, SGXLaunchToken *lc, le_prd_css_file_t *prd_css_file) +{ + UNUSED(prd_css_file); + sgx_launch_token_t token; + memset(token, 0, sizeof(sgx_launch_token_t)); + + int ret = lc->get_launch_token(&token); + if(ret != SGX_SUCCESS) + return ret; + + return ::init_enclave(enclave_id, enclave_css, reinterpret_cast(token)); +} + +int EnclaveCreatorSim::get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t debug_flag) +{ + sgx_attributes_t *required_attr; + enclave_css_t *enclave_css; + sgx_attributes_t *secs_attr; + uint64_t xcr0 = 0; + + assert(sgx_misc_attr != NULL); + assert(metadata != NULL); + + required_attr = &metadata->attributes; + enclave_css = &metadata->enclave_css; + secs_attr = &sgx_misc_attr->secs_attr; + + // Make sure that FP/SSE is set. + if (SGX_XFRM_LEGACY != (required_attr->xfrm & SGX_XFRM_LEGACY)) + { + SE_TRACE(SE_TRACE_WARNING, "FP/SSE are must-have attributes\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + + if (debug_flag) + { + //If enclave is signed as product enclave, but is launched as debug enclave, we need report specific error code. + if((enclave_css->body.attribute_mask.flags & SGX_FLAGS_DEBUG) + && !(enclave_css->body.attributes.flags & SGX_FLAGS_DEBUG) + ) + { + return SGX_ERROR_NDEBUG_ENCLAVE; + } + required_attr->flags |= SGX_FLAGS_DEBUG; + } + else + required_attr->flags &= (~SGX_FLAGS_DEBUG); + + secs_attr->flags = required_attr->flags; + if (! try_read_xcr0(&xcr0)) + { + // read_xcr0() failed + secs_attr->xfrm = SGX_XFRM_LEGACY; + } + else + { + secs_attr->xfrm = xcr0 & required_attr->xfrm; + } + + // Check the signature structure xfrm attribute restrictions. + if((enclave_css->body.attribute_mask.xfrm & secs_attr->xfrm) + != (enclave_css->body.attribute_mask.xfrm & enclave_css->body.attributes.xfrm)) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes.xfrm does NOT match signature attributes.xfrm\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + + // Check the signature structure flags attribute restrictions. + if((enclave_css->body.attribute_mask.flags & secs_attr->flags) + != (enclave_css->body.attribute_mask.flags & enclave_css->body.attributes.flags)) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes.flag does NOT match signature attributes.flag\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + + if(lc != NULL) + { + sgx_launch_token_t token; + memset(&token, 0, sizeof(token)); + if(lc->get_launch_token(&token) != SGX_SUCCESS) + return SGX_ERROR_UNEXPECTED; + token_t *launch = (token_t *)token; + + if( 1 == launch->body.valid) + { + // Debug launch enclave cannot launch production enclave + if( !(secs_attr->flags & SGX_FLAGS_DEBUG) + && (launch->attributes_le.flags & SGX_FLAGS_DEBUG) ) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes is non-debug, \n"); + return SE_ERROR_INVALID_LAUNCH_TOKEN; + } + + // Verify attributes in lictoken are the same as the enclave + if(memcmp(&launch->body.attributes, secs_attr, sizeof(sgx_attributes_t))) + { + SE_TRACE(SE_TRACE_WARNING, "secs attributes does NOT match launch token attributes\n"); + return SGX_ERROR_INVALID_ATTRIBUTE; + } + } + } + return SGX_SUCCESS; +} + +int EnclaveCreatorSim::destroy_enclave(sgx_enclave_id_t enclave_id) +{ + CEnclave *enclave = CEnclavePool::instance()->get_enclave(enclave_id); + + if(enclave == NULL) + return SGX_ERROR_INVALID_ENCLAVE_ID; + + return ::destroy_enclave(enclave_id); +} + +int EnclaveCreatorSim::initialize(sgx_enclave_id_t enclave_id) +{ + CEnclave *enclave = CEnclavePool::instance()->get_enclave(enclave_id); + + if(enclave == NULL) + { + SE_TRACE(SE_TRACE_WARNING, "enclave (id = %llu) not found.\n", enclave_id); + return SGX_ERROR_INVALID_ENCLAVE_ID; + } + + // Save the SECS address (EGETKEY/EREPORT needs to know SECS). + CEnclaveMngr *mngr = CEnclaveMngr::get_instance(); + CEnclaveSim *ce = mngr->get_enclave(enclave_id); + if (ce == NULL) + { + SE_TRACE(SE_TRACE_WARNING, "enclave (id = %llu) not found.\n", enclave_id); + return SGX_ERROR_INVALID_ENCLAVE_ID; + } + + global_data_sim_t *global_data_sim_ptr = (global_data_sim_t *)enclave->get_symbol_address("g_global_data_sim"); + //We have check the symbol of "g_global_data_sim" in urts_com.h::_create_enclave(), so here global_data_sim_ptr won't be NULL. + assert(global_data_sim_ptr != NULL); + + // Initialize the `seed' to `g_global_data_sim'. + global_data_sim_ptr->seed = (uint32_t)time(NULL); + + global_data_sim_ptr->secs_ptr = ce->get_secs(); + sgx_cpu_svn_t temp_cpusvn = {{0}}; + + int status = get_cpusvn(&temp_cpusvn); + assert(status == SGX_SUCCESS); + + memcpy_s(&(global_data_sim_ptr->cpusvn_sim),sizeof(global_data_sim_ptr->cpusvn_sim), &temp_cpusvn, sizeof(temp_cpusvn)); + + + //Since CPUID instruction is NOT supported within enclave, we emuerate the cpu features here and send to tRTS. + cpu_sdk_info_t info; + info.cpu_features = 0; + get_cpu_features(&info.cpu_features); + info.version = SDK_VERSION_1_5; + status = enclave->ecall(ECMD_INIT_ENCLAVE, NULL, reinterpret_cast(&info)); + //free the tcs used by initialization; + enclave->get_thread_pool()->reset(); + if(SGX_SUCCESS == status) + { + return SGX_SUCCESS; + } + else + { + SE_TRACE(SE_TRACE_WARNING, "initialize enclave failed\n"); + return SGX_ERROR_UNEXPECTED; + } +} + +bool EnclaveCreatorSim::use_se_hw() const +{ + return false; +} + +bool EnclaveCreatorSim::get_plat_cap(sgx_misc_attribute_t *se_attr) +{ + UNUSED(se_attr); + return false; +} diff --git a/sdk/simulation/urtssim/enclave_creator_sim.h b/sdk/simulation/urtssim/enclave_creator_sim.h new file mode 100644 index 0000000000..4732183dda --- /dev/null +++ b/sdk/simulation/urtssim/enclave_creator_sim.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _ENCLAVE_CREATOR_H_ +#define _ENCLAVE_CREATOR_H_ + +#include "enclave_creator.h" +#include "sgx_eid.h" + +// simulation mode +class EnclaveCreatorSim : public EnclaveCreator +{ +public: + int create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae); + int add_enclave_page(sgx_enclave_id_t enclave_id, void *source, uint64_t offset, const sec_info_t &sinfo, uint32_t attr); + int init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, SGXLaunchToken *launch, le_prd_css_file_t *prd_css_file); + virtual int destroy_enclave(sgx_enclave_id_t enclave_id); + int get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t flag); + bool get_plat_cap(sgx_misc_attribute_t *se_attr); + int initialize(sgx_enclave_id_t enclave_id); + bool use_se_hw() const; +}; + +#endif diff --git a/sdk/simulation/urtssim/linux/Makefile b/sdk/simulation/urtssim/linux/Makefile new file mode 100644 index 0000000000..780fbb8343 --- /dev/null +++ b/sdk/simulation/urtssim/linux/Makefile @@ -0,0 +1,173 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../../buildenv.mk + +SIM_DIR := $(LINUX_SDK_DIR)/simulation +VTUNE_DIR = $(LINUX_EXTERNAL_DIR)/vtune/linux + +ifndef DEBUG +CXXFLAGS += -DDISABLE_TRACE +CFLAGS += -DDISABLE_TRACE +endif + +CXXFLAGS += -fPIC -DSE_SIM -Werror +CFLAGS += -fPIC -DSE_SIM -Werror + +CPPFLAGS += $(ADDED_INC) #for ubuntu 11 and later version +CPPFLAGS += -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal/linux \ + -I$(LINUX_PSW_DIR)/urts \ + -I$(LINUX_PSW_DIR)/urts/parser \ + -I$(VTUNE_DIR)/include \ + -I$(VTUNE_DIR)/sdk/src/ittnotify + +CPPFLAGS += -I$(COMMON_DIR)/inc/internal \ + -I$(LINUX_PSW_DIR)/urts/linux \ + -I$(SIM_DIR)/tinst \ + -I$(SIM_DIR)/uinst + +DIR1 := $(LINUX_PSW_DIR)/urts/ +DIR2 := $(LINUX_PSW_DIR)/urts/linux/ +DIR3 := $(LINUX_PSW_DIR)/urts/parser/ +DIR4 := ../ + +LDFLAGS += -L$(COMMON_DIR)/se_wrapper \ + -L$(SIM_DIR)/uae_service_sim/linux + +LDFLAGS += -L$(VTUNE_DIR)/sdk/src/ittnotify/ -littnotify -ldl + +OBJ1 := enclave.o \ + tcs.o \ + loader.o \ + se_detect.o \ + enclave_mutex.o \ + routine.o \ + urts_xsave.o \ + se_ocalls.o \ + cpu_features.o \ + node.o \ + launch_checker.o + +OBJ2 := urts.o \ + misc.o \ + sig_handler.o \ + debugger_support.o \ + get_thread_id.o + +OBJ3 := section.o \ + elfparser.o + +OBJ4 := enter_enclave.o + +OBJ5 := enclave_creator_sim.o \ + cpusvn_util.o + +OBJ6 := $(SIM_DIR)/driver_api/driver_api.o \ + $(SIM_DIR)/assembly/linux/lowlib.o \ + $(SIM_DIR)/assembly/linux/sgxsim.o \ + $(SIM_DIR)/uinst/u_instructions.o \ + $(SIM_DIR)/uinst/enclave_mngr.o \ + $(SIM_DIR)/uinst/linux/set_tls.o \ + $(SIM_DIR)/uinst/linux/restore_tls.o + +CPP_OBJ := $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ5) +OBJ := $(CPP_OBJ) $(OBJ4) + +vpath %.cpp .:$(DIR1):$(DIR2):$(DIR3):$(DIR4) + +LDFLAGS += -L$(LINUX_EXTERNAL_DIR)/crypto_px + +LIBURTSSIM_SHARED := libsgx_urts_sim.so +LIBURTS_DEPLOY := libsgx_urts_deploy.so + +LDLIBS += -lwrapper -lcrypto_px -Wl,-Bdynamic -Wl,-Bsymbolic -lsgx_uae_service_sim +SONAME = $(LIBURTSSIM_SHARED) + +.PHONY: all +all: $(LIBURTSSIM_SHARED) $(LIBURTS_DEPLOY)| $(BUILD_DIR) + $(CP) $^ $| + + +$(LIBURTSSIM_SHARED): simasm uinst driver_api wrapper uae_service_sim $(OBJ) $(OBJ6) -lcrypto_px ittnotify + $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$(SONAME) $(OBJ) $(OBJ6) $(LDFLAGS) $(LDLIBS) -o $@ + + +$(BUILD_DIR): + @$(MKDIR) $@ + +$(OBJ4): %.o: $(DIR2)/%.S + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +$(CPP_OBJ): %.o: %.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + +-lcrypto_px: + $(MAKE) -C $(LINUX_EXTERNAL_DIR)/crypto_px + +.PHONY: wrapper +wrapper: + $(MAKE) -C $(COMMON_DIR)/se_wrapper/ + +.PHONY: driver_api +driver_api: + $(MAKE) -C $(SIM_DIR)/driver_api/ + +.PHONY: simasm +simasm: + $(MAKE) -C $(SIM_DIR)/assembly/ + +.PHONY: uinst +uinst: + $(MAKE) -C $(SIM_DIR)/uinst/ + +.PHONY: uae_service_sim +uae_service_sim: + $(MAKE) -C $(SIM_DIR)/uae_service_sim/linux + +.PHONY: ittnotify +ittnotify: + $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify/ + +$(LIBURTS_DEPLOY):../urts_deploy.c + $(CC) -I$(COMMON_DIR)/inc -shared -fPIC -Wl,-soname=libsgx_urts.so $< -o $@ + +.PHONY: clean +clean:: + @$(RM) *.o $(LIBURTSSIM_SHARED) $(LIBURTS_DEPLOY) + @$(RM) $(BUILD_DIR)/$(LIBURTSSIM_SHARED) $(BUILD_DIR)/$(LIBURTS_DEPLOY) + $(MAKE) -C $(COMMON_DIR)/se_wrapper clean + $(MAKE) -C $(SIM_DIR)/driver_api/ clean + $(MAKE) -C $(SIM_DIR)/assembly/ clean + $(MAKE) -C $(SIM_DIR)/uinst/ clean + $(MAKE) -C $(SIM_DIR)/uae_service_sim/linux clean + $(MAKE) -C $(LINUX_EXTERNAL_DIR)/crypto_px clean + $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify/ clean diff --git a/sdk/simulation/urtssim/urts_deploy.c b/sdk/simulation/urtssim/urts_deploy.c new file mode 100644 index 0000000000..e58ee6c505 --- /dev/null +++ b/sdk/simulation/urtssim/urts_deploy.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "sgx_error.h" + +sgx_status_t sgx_create_enclave() +{ + printf("Please use the correct uRTS library from PSW package.\n"); + return SGX_ERROR_UNEXPECTED; +} + +void sgx_debug_load_state_add_element(){}; +void sgx_debug_unload_state_remove_element(){}; +void sgx_destroy_enclave(){}; +void sgx_ecall(){}; +void sgx_oc_cpuidex(){}; +void sgx_ocall(){}; +void sgx_thread_set_multiple_untrusted_events_ocall(){}; +void sgx_thread_set_untrusted_event_ocall(){}; +void sgx_thread_setwait_untrusted_events_ocall(){}; +void sgx_thread_wait_untrusted_event_ocall(){}; + diff --git a/sdk/simulation/urtssim/urts_sim.h b/sdk/simulation/urtssim/urts_sim.h new file mode 100644 index 0000000000..46c7c65981 --- /dev/null +++ b/sdk/simulation/urtssim/urts_sim.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _URTS_SIM_H_ +#define _URTS_SIM_H_ +#include "sgx_urts.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +uint64_t get_urts_version(); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/sdk/tae_service/Makefile b/sdk/tae_service/Makefile new file mode 100644 index 0000000000..3d06fb8bd8 --- /dev/null +++ b/sdk/tae_service/Makefile @@ -0,0 +1,97 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR = ../.. +include $(TOP_DIR)/buildenv.mk + +AENAME = sgx_tae_service +EDLFILE = $(TOP_DIR)/common/inc/$(AENAME).edl + +INCLUDE += -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc + +INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux + +INCLUDE += -I$(LINUX_PSW_DIR)/ae/common \ + -I$(LINUX_PSW_DIR)/ae/inc \ + -I$(LINUX_PSW_DIR)/ae/inc/internal +# -I$(LINUX_PSW_DIR)/ae/pse/pse_op + +INCLUDE += -I$(LINUX_EXTERNAL_DIR)/crypto_px/include + +vpath %.cpp $(COMMON_DIR)/src:\ + $(LINUX_PSW_DIR)/ae/common:\ + $(TOP_DIR)/src + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) + +EDGER8R_DIR := $(LINUX_SDK_DIR)/edger8r/linux +EDGER8R := $(EDGER8R_DIR)/_build/Edger8r.native + +EC_DH_LIB_DIR := $(TOP_DIR)/sdk/ec_dh_lib +EC_DH_LIB := $(EC_DH_LIB_DIR)/libsgx_dh.a + +SRC := $(wildcard *.cpp) +SRC += dh.cpp + +OBJ := $(SRC:.cpp=.o) + +LIBNAME := libtae_service.a + +.PHONY: all +all: $(LIBNAME) + +$(AENAME)_t.h: $(EDLFILE) $(EDGER8R) + $(EDGER8R) --trusted --header-only --search-path $(TOP_DIR)/common/inc $< + +$(EDGER8R): + $(MAKE) -C $(EDGER8R_DIR) + +$(LIBNAME): $(AENAME)_t.h $(OBJ) + $(MAKE) -C $(EC_DH_LIB_DIR) + $(CP) $(EC_DH_LIB) $@ + $(AR) rs $@ $(OBJ) + +$(OBJ): %.o :%.cpp + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ + +.PHONY: clean +clean: + @$(RM) *.o + @$(RM) $(COMMON_DIR)/src/*.o + @$(RM) *_t.* *_u.* + @$(RM) $(LIBNAME) + $(MAKE) -C $(EC_DH_LIB_DIR) clean + $(MAKE) -C $(EDGER8R_DIR) clean + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/tae_service/tae_config.h b/sdk/tae_service/tae_config.h new file mode 100644 index 0000000000..99f4b172ef --- /dev/null +++ b/sdk/tae_service/tae_config.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _TAE_CONFIG_H_ +#define _TAE_CONFIG_H_ + +#include "sgx.h" + +#ifdef _DEBUG +//wait for 10min at most for debug +#define SGX_PSE_LATENCY 600000 +#else +//long enough to do long-term pairing, PSE Provisioning, update RPDATA and commit the VMC database +#define SGX_PSE_LATENCY 20000 +#endif + + +#define SE_CREATE_SESSION_TIMEOUT_MSEC (SGX_PSE_LATENCY) +#define SE_EXCHANGE_REPORT_TIMEOUT_MSEC (SGX_PSE_LATENCY) +#define SE_CLOSE_SESSION_TIMEOUT_MSEC (SGX_PSE_LATENCY) +#define SE_GET_TRUSTED_TIME_TIMEOUT_MSEC (SGX_PSE_LATENCY) +#define SE_CREATE_MONOTONIC_COUNTER_TIMEOUT_MSEC (SGX_PSE_LATENCY) +#define SE_READ_MONOTONIC_COUNTER_TIMEOUT_MSEC (SGX_PSE_LATENCY) +#define SE_INCREMENT_MONOTONIC_COUNTER_TIMEOUT_MSEC (SGX_PSE_LATENCY) +#define SE_DESTROY_MONOTONIC_COUNTER_TIMEOUT_MSEC (SGX_PSE_LATENCY) + +#define RETRY_TIMES 2 +#define DEFAULT_VMC_ATTRIBUTE_MASK 0xFFFFFFFFFFFFFFCB +#define DEFAULT_VMC_XFRM_MASK 0x0 + +#include "service_enclave_mrsigner.hh" +#include "pse_op_prod_id.hh" +#include "pse_op_isv_svn_min.hh" +#endif diff --git a/sdk/tae_service/tae_service.cpp b/sdk/tae_service/tae_service.cpp new file mode 100644 index 0000000000..b7d0669d9b --- /dev/null +++ b/sdk/tae_service/tae_service.cpp @@ -0,0 +1,729 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_types.h" +#include "sgx_trts.h" +#include "sgx_utils.h" +#include "arch.h" +#include "sgx_tae_service.h" +#include "tae_service_internal.h" +#include "dh.h" +#include "sgx_dh.h" +#include "sgx_spinlock.h" +#include "sgx_thread.h" +#include "uncopyable.h" + +#include "tae_config.h" + +#include "sgx_tae_service_t.h" + +#define ERROR_BREAK(x) if(SGX_SUCCESS != (x)){break;} +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} + +#define INVALID_SESSION_ID (-1U) + +typedef struct _session_t +{ + uint32_t session_id; + sgx_key_128bit_t authenticated_encryption_key; + se_ps_sec_prop_desc_internal_t ps_security_property;//!ref i205169 + uint32_t transaction_number;//valid transaction_number is from 0 to 0x7FFFFFFF + //seq_num in request message is transaction_number*2 and seq_num in response message is expected to be transaction_number*2+1 + bool session_inited; +}session_t; + +static session_t g_pse_session; + +class Mutex :private Uncopyable{ +public: + Mutex() {sgx_thread_mutex_init(&m_mutex, NULL);} + ~Mutex() { sgx_thread_mutex_destroy(&m_mutex);} + void lock() { sgx_thread_mutex_lock(&m_mutex); } + void unlock() { sgx_thread_mutex_unlock(&m_mutex); } +private: + sgx_thread_mutex_t m_mutex; +}; +//mutex for change g_pse_session, create_pse_session, close_pse_session and crypt_invoke locks it. +static Mutex g_session_mutex; + +static sgx_status_t uae_create_session( + uint32_t* session_id, + sgx_dh_msg1_t* se_dh_msg1, + uint32_t timeout + ) +{ + sgx_status_t status; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + status = create_session_ocall(&ret, session_id, (uint8_t*)se_dh_msg1, sizeof(sgx_dh_msg1_t), timeout); + if (status!=SGX_SUCCESS) + return status; + return ret; +} + +static sgx_status_t uae_close_session( + uint32_t session_id, + uint32_t timeout + ) +{ + sgx_status_t status; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + status = close_session_ocall(&ret, session_id, timeout); + if (status!=SGX_SUCCESS) + return status; + return ret; +} + +static sgx_status_t uae_exchange_report( + uint32_t session_id, + sgx_dh_msg2_t* se_dh_msg2, + sgx_dh_msg3_t* se_dh_msg3, + uint32_t timeout + ) +{ + sgx_status_t status; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + status = exchange_report_ocall(&ret, session_id, (uint8_t*)se_dh_msg2, static_cast(sizeof(sgx_dh_msg2_t)), + (uint8_t*)se_dh_msg3, static_cast(sizeof(sgx_dh_msg3_t)+sizeof(cse_sec_prop_t)),timeout); + if (status!=SGX_SUCCESS) + return status; + return ret; +} + +static sgx_status_t uae_invoke_service( + uint8_t* pse_message_req, uint32_t pse_message_req_size, + uint8_t* pse_message_resp, uint32_t pse_message_resp_size, + uint32_t timeout + ) +{ + sgx_status_t status; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + status = invoke_service_ocall(&ret, pse_message_req, pse_message_req_size, pse_message_resp, pse_message_resp_size, timeout); + if (status!=SGX_SUCCESS) + return status; + return ret; +} + +static sgx_status_t close_pse_session_within_mutex() +{ + sgx_status_t status = SGX_SUCCESS; + if (g_pse_session.session_inited) + { + g_pse_session.session_inited = false; + memset_s(&g_pse_session.authenticated_encryption_key,sizeof(&g_pse_session.authenticated_encryption_key), 0, sizeof(sgx_key_128bit_t)); + uint32_t session_id = g_pse_session.session_id; + //Ocall uae_service close_session + status = uae_close_session(session_id, SE_CLOSE_SESSION_TIMEOUT_MSEC); + + if (status == SGX_ERROR_AE_SESSION_INVALID) + { + //means session is closed by PSE, it's acceptable + status = SGX_SUCCESS; + } + } + return status; +} + +sgx_status_t sgx_close_pse_session() +{ + sgx_status_t status = SGX_SUCCESS; + g_session_mutex.lock(); + //check session status again after mutex lock got. + status = close_pse_session_within_mutex(); + g_session_mutex.unlock(); + return status; +} + +static sgx_status_t verify_pse(sgx_dh_session_enclave_identity_t* dh_id) +{ + + //verify dh_id->mr_signer same as hard-coded PSE MRSIGNER. + if(0!=memcmp(&dh_id->mr_signer, &G_SERVICE_ENCLAVE_MRSIGNER, sizeof(sgx_measurement_t))) + { + return SGX_ERROR_UNEXPECTED; + } + //verify dh_id->isv_prod_id same as hard-coded prod_id of PSE. + if(PSE_PROD_ID != dh_id->isv_prod_id) + { + return SGX_ERROR_UNEXPECTED; + } + //verify dh_id->isv_svn bigger or same as hard-coded minimal value if minimal value is not zero + //check PSE_ISV_SVN_MIN against 0 first to avoid "pointless comparison of unsigned integer with zero" + //compiler error on Windows and Linux + if(PSE_ISV_SVN_MIN != 0 && !(dh_id->isv_svn >= PSE_ISV_SVN_MIN)) + { + return SGX_ERROR_UNEXPECTED; + } + //make sure debug flag is not set + if(dh_id->attributes.flags & SGX_FLAGS_DEBUG) + { + return SGX_ERROR_UNEXPECTED; + } + return SGX_SUCCESS; +} +static sgx_status_t create_pse_session_within_mutex() +{ + if (g_pse_session.session_inited) + { + return SGX_SUCCESS; + } + + sgx_dh_msg3_t* se_dh_msg3 = NULL; + //set invalid session id + uint32_t session_id = INVALID_SESSION_ID; + sgx_status_t status = SGX_ERROR_UNEXPECTED; + + //for pse session + sgx_dh_msg1_t se_dh_msg1; + sgx_dh_msg2_t se_dh_msg2; + + //for dh session + sgx_dh_session_t dh_session_context; + sgx_key_128bit_t dh_aek; + sgx_dh_session_enclave_identity_t dh_id; + + + //set start status + status = sgx_dh_init_session(SGX_DH_SESSION_INITIATOR, &dh_session_context); + if (SGX_ERROR_OUT_OF_MEMORY == status) + return SGX_ERROR_OUT_OF_MEMORY; + if(status!=SGX_SUCCESS) + return SGX_ERROR_UNEXPECTED; + + se_dh_msg3 = (sgx_dh_msg3_t*)malloc(sizeof(sgx_dh_msg3_t)+sizeof(cse_sec_prop_t)); + if(!se_dh_msg3) + return SGX_ERROR_OUT_OF_MEMORY; + + do{ + //Ocall uae_service create_session, get session_id and se_dh_msg1 from PSE + status = uae_create_session(&session_id,&se_dh_msg1, SE_CREATE_SESSION_TIMEOUT_MSEC); + if (SGX_ERROR_INVALID_PARAMETER == status) + status = SGX_ERROR_UNEXPECTED; + ERROR_BREAK(status); + + //process msg1 and generate msg2 + status = sgx_dh_initiator_proc_msg1(&se_dh_msg1, &se_dh_msg2, &dh_session_context); + if (SGX_ERROR_OUT_OF_MEMORY == status) + break; + if(status!=SGX_SUCCESS) + { + status = SGX_ERROR_UNEXPECTED; + break; + } + + //Ocall uae_service exchange_report, give se_dh_msg2, get se_dh_msg3 + status = uae_exchange_report(session_id,&se_dh_msg2, se_dh_msg3, SE_EXCHANGE_REPORT_TIMEOUT_MSEC); + if (SGX_ERROR_INVALID_PARAMETER == status) + status = SGX_ERROR_UNEXPECTED; + ERROR_BREAK(status); + + //proc msg3 to get AEK + status = sgx_dh_initiator_proc_msg3(se_dh_msg3, &dh_session_context, &dh_aek, &dh_id); + if (SGX_ERROR_OUT_OF_MEMORY == status) + break; + if(status!=SGX_SUCCESS) + { + status = SGX_ERROR_UNEXPECTED; + break; + } + + //verify PSE same as hard-coded attributes + status = verify_pse(&dh_id); + ERROR_BREAK(status); + + status = sgx_verify_report(&se_dh_msg3->msg3_body.report); + if (SGX_ERROR_OUT_OF_MEMORY == status) + break; + if(status!=SGX_SUCCESS) + { + status = SGX_ERROR_UNEXPECTED; + break; + } + + + //fill g_pse_session + g_pse_session.session_id = session_id; + memcpy(&g_pse_session.authenticated_encryption_key , &dh_aek, sizeof(sgx_key_128bit_t)); + g_pse_session.ps_security_property.pse_miscselect = dh_id.misc_select; + g_pse_session.ps_security_property.reserved1 = 0; + memset(g_pse_session.ps_security_property.reserved2, 0, sizeof(g_pse_session.ps_security_property.reserved2)); + memcpy(&g_pse_session.ps_security_property.pse_attributes, &dh_id.attributes, sizeof(sgx_attributes_t)); + memcpy(&g_pse_session.ps_security_property.pse_isvsvn, &dh_id.isv_svn, sizeof(sgx_isv_svn_t)); + memcpy(&g_pse_session.ps_security_property.pse_mr_signer, &dh_id.mr_signer, sizeof(sgx_measurement_t)); + memcpy(&g_pse_session.ps_security_property.pse_prod_id, &dh_id.isv_prod_id, sizeof(sgx_prod_id_t)); + //copy CSE_SEC_PROP of SE_DH_MSG3 to g_pse_session.ps_security_property + pse_dh_msg3_t* pse_dh_msg3 = (pse_dh_msg3_t*)se_dh_msg3; + memcpy(&g_pse_session.ps_security_property.cse_sec_prop, &pse_dh_msg3->cse_sec_prop, sizeof(cse_sec_prop_t)); + g_pse_session.session_inited = true; + //reset transaction_number to 0 + g_pse_session.transaction_number = 0; + status = SGX_SUCCESS; + break; + }while(0); + SAFE_FREE(se_dh_msg3); + if(status != SGX_SUCCESS && session_id != INVALID_SESSION_ID) + uae_close_session(session_id, SE_CLOSE_SESSION_TIMEOUT_MSEC);//we can do nothing if close_session fails + return status; +} + +sgx_status_t sgx_create_pse_session() +{ + sgx_status_t status= SGX_ERROR_UNEXPECTED; + //lock mutex, only one thread can create session, others must wait. + g_session_mutex.lock(); + status = create_pse_session_within_mutex(); + //unlock the session mutex + g_session_mutex.unlock(); + return status; +} + +sgx_status_t sgx_get_ps_sec_prop(sgx_ps_sec_prop_desc_t* ps_security_property) +{ + sgx_status_t ret; + if(!ps_security_property) + return SGX_ERROR_INVALID_PARAMETER; + //lock mutex to read session status + g_session_mutex.lock(); + if (g_pse_session.session_inited == true) + { + memcpy(ps_security_property,&g_pse_session.ps_security_property,sizeof(sgx_ps_sec_prop_desc_t)); + ret = SGX_SUCCESS; + } + else + ret = SGX_ERROR_AE_SESSION_INVALID; + //unlock the session mutex + g_session_mutex.unlock(); + return ret; +} + +static sgx_status_t verify_msg_hdr(pse_req_hdr_t* req_payload_hdr, pse_resp_hdr_t* resp_payload_hdr) +{ + sgx_status_t ret = SGX_SUCCESS; + if(resp_payload_hdr->service_id != req_payload_hdr->service_id || + resp_payload_hdr->service_cmd != req_payload_hdr->service_cmd || + //resp seq_num increases one by PSE + resp_payload_hdr->seq_num != req_payload_hdr->seq_num+1|| + //transaction_number has increase one after setting seq_num + g_pse_session.transaction_number != resp_payload_hdr->seq_num/2 +1) + { + ret = SGX_ERROR_UNEXPECTED; + } + else if(resp_payload_hdr->status != PSE_SUCCESS) + { + switch (resp_payload_hdr->status) + { + case PSE_ERROR_INTERNAL: + ret = SGX_ERROR_UNEXPECTED; + break; + case PSE_ERROR_BUSY: + ret = SGX_ERROR_BUSY; + break; + case PSE_ERROR_MC_NOT_FOUND: + ret = SGX_ERROR_MC_NOT_FOUND; + break; + case PSE_ERROR_MC_NO_ACCESS_RIGHT: + ret = SGX_ERROR_MC_NO_ACCESS_RIGHT; + break; + case PSE_ERROR_UNKNOWN_REQ: + ret = SGX_ERROR_INVALID_PARAMETER; + break; + case PSE_ERROR_CAP_NOT_AVAILABLE: + ret = SGX_ERROR_SERVICE_UNAVAILABLE; + break; + case PSE_ERROR_MC_USED_UP: + ret = SGX_ERROR_MC_USED_UP; + break; + case PSE_ERROR_MC_OVER_QUOTA: + ret = SGX_ERROR_MC_OVER_QUOTA; + break; + case PSE_ERROR_INVALID_POLICY: + ret = SGX_ERROR_INVALID_PARAMETER; + break; + default: + ret = SGX_ERROR_UNEXPECTED; + break; + } + } + return ret; +} + +//increase nonce, build msg, encrypt msg, call invoke_service, decrypt msg, verify msg format +static sgx_status_t crypt_invoke(pse_message_t* req_msg, uint32_t req_msg_size, + pse_req_hdr_t* req_payload_hdr, + uint32_t timeout, + pse_message_t* resp_msg, uint32_t resp_msg_size, + pse_resp_hdr_t* resp_payload_hdr + ) +{ + + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + int retry = RETRY_TIMES; + //lock transaction_number + g_session_mutex.lock(); + //don't need to lock g_pse_session.sgx_spin_lock, g_pse_session only changes when g_session_mutex is locked. + if (!g_pse_session.session_inited) + { + g_session_mutex.unlock(); + return SGX_ERROR_AE_SESSION_INVALID; + } + //retry only when return value of uae_invoke_service is SGX_ERROR_AE_SESSION_INVALID, + //which means that session is closed by PSE or transaction_number is out of order. + //In these situation, session needs to reestablish and retry the invoke_service. + while(retry --) + { + //prevent transaction_number from rolling over. 0x7fffffff and below is valid + if(g_pse_session.transaction_number > 0x7fffffff){ + //if unexpected failure of following close_pse_session_within_mutex() and create_pse_session_within_mutex() + //return SGX_ERROR_AE_SESSION_INVALID to user + ret = SGX_ERROR_AE_SESSION_INVALID; + //need to close current session and create a new session + //create_pse_session_within_mutex will reset the g_pse_session.transaction_number + //close_session failure will always return SGX_ERROR_AE_SESSION_INVALID + ERROR_BREAK(close_pse_session_within_mutex()); + //create_session failure will return SGX_ERROR_BUSY on SGX_ERROR_BUSY, SGX_ERROR_OUT_OF_MEMORY on SGX_ERROR_OUT_OF_MEMORY, + //and SGX_ERROR_AE_SESSION_INVALID on other error code + sgx_status_t aesm_status = create_pse_session_within_mutex(); + switch (aesm_status) + { + case SGX_ERROR_BUSY: + ret = SGX_ERROR_BUSY; + break; + case SGX_ERROR_OUT_OF_MEMORY: + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + default: + break; + } + ERROR_BREAK(aesm_status); + } + //set seq_num + req_payload_hdr->seq_num = g_pse_session.transaction_number*2; + //increase transaction_number + g_pse_session.transaction_number++; + + //set request message session id + req_msg->session_id = g_pse_session.session_id; + + + //encrypt_msg with authenticated_encryption_key of the session + if (!encrypt_msg(req_msg, (uint8_t*)req_payload_hdr, &g_pse_session.authenticated_encryption_key)) + { + ret = SGX_ERROR_UNEXPECTED; + break; + } + //ocall invoke_service + ret = uae_invoke_service((uint8_t*)req_msg, (req_msg_size), + (uint8_t*)resp_msg, resp_msg_size, timeout); + if (SGX_ERROR_AE_SESSION_INVALID == ret) + { + //close_session failure will always return SGX_ERROR_AE_SESSION_INVALID + ERROR_BREAK(close_pse_session_within_mutex()); + //recreating session + sgx_status_t aesm_status = create_pse_session_within_mutex(); + if(SGX_SUCCESS == aesm_status) + continue; + switch (aesm_status) + { + case SGX_ERROR_BUSY: + ret = SGX_ERROR_BUSY; + break; + case SGX_ERROR_OUT_OF_MEMORY: + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + default: + break; + } + } + ERROR_BREAK(ret); + //decrypt_msg with authenticated_encryption_key of the session + if(!decrypt_msg(resp_msg, (uint8_t*)resp_payload_hdr, &g_pse_session.authenticated_encryption_key)) + { + ret = SGX_ERROR_UNEXPECTED; + break; + } + ret = verify_msg_hdr(req_payload_hdr,resp_payload_hdr); + break; + } + g_session_mutex.unlock(); + return ret; +} + + + +sgx_status_t sgx_get_trusted_time( + sgx_time_t* current_time, + sgx_time_source_nonce_t* time_source_nonce + ) +{ + if(!current_time || !time_source_nonce) + return SGX_ERROR_INVALID_PARAMETER; + + pse_message_t* req_msg = (pse_message_t*)malloc(PSE_TIMER_READ_REQ_SIZE); + if (!req_msg) + return SGX_ERROR_OUT_OF_MEMORY; + pse_message_t* resp_msg = (pse_message_t*)malloc(PSE_TIMER_READ_RESP_SIZE); + if (!resp_msg) + { + free(req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(req_msg, 0, PSE_TIMER_READ_REQ_SIZE); + memset(resp_msg, 0, PSE_TIMER_READ_RESP_SIZE); + req_msg->exp_resp_size = sizeof(pse_timer_read_resp_t); + req_msg->payload_size = sizeof(pse_timer_read_req_t); + + pse_timer_read_req_t timer_req; + timer_req.req_hdr.service_id = PSE_TRUSTED_TIME_SERVICE; + timer_req.req_hdr.service_cmd = PSE_TIMER_READ; + + pse_timer_read_resp_t timer_resp; + memset(&timer_resp, 0, sizeof(pse_timer_read_resp_t)); + + sgx_status_t status; + status = crypt_invoke(req_msg, PSE_TIMER_READ_REQ_SIZE, &timer_req.req_hdr, SE_GET_TRUSTED_TIME_TIMEOUT_MSEC, + resp_msg, PSE_TIMER_READ_RESP_SIZE, &timer_resp.resp_hdr); + if (status==SGX_SUCCESS) + { + memcpy(current_time, &timer_resp.timestamp, sizeof(sgx_time_t)); + memcpy(time_source_nonce,timer_resp.time_source_nonce,sizeof(sgx_time_source_nonce_t)); + } + //error condition + free(req_msg); + free(resp_msg); + return status; +} + +se_static_assert(SGX_MC_POLICY_SIGNER == MC_POLICY_SIGNER); +se_static_assert(SGX_MC_POLICY_ENCLAVE == MC_POLICY_ENCLAVE); +sgx_status_t sgx_create_monotonic_counter_ex( + uint16_t owner_policy, + const sgx_attributes_t* owner_attribute_mask, + sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ) +{ + if (!counter_value || !counter_uuid || !owner_attribute_mask) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ( 0!= (~(MC_POLICY_SIGNER | MC_POLICY_ENCLAVE) & owner_policy) || + 0 == ((MC_POLICY_SIGNER | MC_POLICY_ENCLAVE)& owner_policy)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + pse_message_t* req_msg = (pse_message_t*)malloc(PSE_CREATE_MC_REQ_SIZE); + if (!req_msg) + return SGX_ERROR_OUT_OF_MEMORY; + pse_message_t* resp_msg = (pse_message_t*)malloc(PSE_CREATE_MC_RESP_SIZE); + if (!resp_msg) + { + free(req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(req_msg, 0, PSE_CREATE_MC_REQ_SIZE); + memset(resp_msg, 0, PSE_CREATE_MC_RESP_SIZE); + req_msg->exp_resp_size = sizeof(pse_mc_create_resp_t); + req_msg->payload_size = sizeof(pse_mc_create_req_t); + + pse_mc_create_req_t mc_req; + mc_req.req_hdr.service_id = PSE_MC_SERVICE; + mc_req.req_hdr.service_cmd = PSE_MC_CREATE; + mc_req.policy = owner_policy; + memcpy(mc_req.attr_mask, owner_attribute_mask, sizeof(mc_req.attr_mask)); + + pse_mc_create_resp_t mc_resp; + memset(&mc_resp, 0, sizeof(pse_mc_create_resp_t)); + + sgx_status_t status; + status = crypt_invoke(req_msg, PSE_CREATE_MC_REQ_SIZE, &mc_req.req_hdr, SE_CREATE_MONOTONIC_COUNTER_TIMEOUT_MSEC, + resp_msg, PSE_CREATE_MC_RESP_SIZE, &mc_resp.resp_hdr); + if (status == SGX_SUCCESS) + { + memcpy(counter_uuid->counter_id, &mc_resp.counter_id,sizeof(counter_uuid->counter_id)); + memcpy(counter_uuid->nonce, &mc_resp.nonce,sizeof(counter_uuid->nonce)); + //align with initial counter_value hard-coded in PSE + *counter_value = 0; + } + //error condition + free(req_msg); + free(resp_msg); + return status; +} + +sgx_status_t sgx_create_monotonic_counter( + sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ) +{ + // Default attribute mask + sgx_attributes_t attr_mask; + attr_mask.flags = DEFAULT_VMC_ATTRIBUTE_MASK; + attr_mask.xfrm = DEFAULT_VMC_XFRM_MASK; + + return sgx_create_monotonic_counter_ex(MC_POLICY_SIGNER, + &attr_mask, + counter_uuid, + counter_value + ); +} + +sgx_status_t sgx_destroy_monotonic_counter(const sgx_mc_uuid_t* counter_uuid) +{ + if (!counter_uuid) + { + return SGX_ERROR_INVALID_PARAMETER; + } + pse_message_t* req_msg = (pse_message_t*)malloc(PSE_DEL_MC_REQ_SIZE); + if (!req_msg) + return SGX_ERROR_OUT_OF_MEMORY; + pse_message_t* resp_msg = (pse_message_t*)malloc(PSE_DEL_MC_RESP_SIZE); + if (!resp_msg) + { + free(req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(req_msg, 0, PSE_DEL_MC_REQ_SIZE); + memset(resp_msg, 0, PSE_DEL_MC_RESP_SIZE); + req_msg->exp_resp_size = sizeof(pse_mc_del_resp_t); + req_msg->payload_size = sizeof(pse_mc_del_req_t); + + pse_mc_del_req_t mc_req; + memcpy(mc_req.counter_id, counter_uuid->counter_id, sizeof(mc_req.counter_id)); + memcpy(mc_req.nonce, counter_uuid->nonce, sizeof(mc_req.nonce)); + mc_req.req_hdr.service_id = PSE_MC_SERVICE; + mc_req.req_hdr.service_cmd = PSE_MC_DEL; + + pse_mc_del_resp_t mc_resp; + memset(&mc_resp, 0, sizeof(pse_mc_del_resp_t)); + + sgx_status_t status; + status = crypt_invoke(req_msg, PSE_DEL_MC_REQ_SIZE, &mc_req.req_hdr, SE_DESTROY_MONOTONIC_COUNTER_TIMEOUT_MSEC, + resp_msg, PSE_DEL_MC_RESP_SIZE, &mc_resp.resp_hdr); + //error condition + free(req_msg); + free(resp_msg); + return status; +} + + +sgx_status_t sgx_increment_monotonic_counter( + const sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ) +{ + if (!counter_value || !counter_uuid) + { + return SGX_ERROR_INVALID_PARAMETER; + } + pse_message_t* req_msg = (pse_message_t*)malloc(PSE_INC_MC_REQ_SIZE); + if (!req_msg) + return SGX_ERROR_OUT_OF_MEMORY; + pse_message_t* resp_msg = (pse_message_t*)malloc(PSE_INC_MC_RESP_SIZE); + if (!resp_msg) + { + free(req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(req_msg, 0, PSE_INC_MC_REQ_SIZE); + memset(resp_msg, 0, PSE_INC_MC_RESP_SIZE); + req_msg->exp_resp_size = sizeof(pse_mc_inc_resp_t); + req_msg->payload_size = sizeof(pse_mc_inc_req_t); + + pse_mc_inc_req_t mc_req; + memcpy(mc_req.counter_id, counter_uuid->counter_id, sizeof(mc_req.counter_id)); + memcpy(mc_req.nonce, counter_uuid->nonce, sizeof(mc_req.nonce)); + mc_req.req_hdr.service_id = PSE_MC_SERVICE; + mc_req.req_hdr.service_cmd = PSE_MC_INC; + + pse_mc_inc_resp_t mc_resp; + memset(&mc_resp, 0, sizeof(pse_mc_inc_resp_t)); + + sgx_status_t status; + status = crypt_invoke(req_msg, PSE_INC_MC_REQ_SIZE, &mc_req.req_hdr, SE_INCREMENT_MONOTONIC_COUNTER_TIMEOUT_MSEC, + resp_msg, PSE_INC_MC_RESP_SIZE, &mc_resp.resp_hdr); + if (status == SGX_SUCCESS) + { + *counter_value = mc_resp.counter_value; + } + //error condition + free(req_msg); + free(resp_msg); + return status; +} + + +sgx_status_t sgx_read_monotonic_counter( + const sgx_mc_uuid_t* counter_uuid, + uint32_t* counter_value + ) +{ + if (!counter_value || !counter_uuid) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + pse_message_t* req_msg = (pse_message_t*)malloc(PSE_READ_MC_REQ_SIZE); + if (!req_msg) + return SGX_ERROR_OUT_OF_MEMORY; + pse_message_t* resp_msg = (pse_message_t*)malloc(PSE_READ_MC_RESP_SIZE); + if (!resp_msg) + { + free(req_msg); + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(req_msg, 0, PSE_READ_MC_REQ_SIZE); + memset(resp_msg, 0, PSE_READ_MC_RESP_SIZE); + req_msg->exp_resp_size = sizeof(pse_mc_read_resp_t); + req_msg->payload_size = sizeof(pse_mc_read_req_t); + + pse_mc_read_req_t mc_req; + memcpy(mc_req.counter_id, counter_uuid->counter_id, sizeof(mc_req.counter_id)); + memcpy(mc_req.nonce, counter_uuid->nonce, sizeof(mc_req.nonce)); + mc_req.req_hdr.service_id = PSE_MC_SERVICE; + mc_req.req_hdr.service_cmd = PSE_MC_READ; + + pse_mc_read_resp_t mc_resp; + memset(&mc_resp, 0, sizeof(pse_mc_read_resp_t)); + + sgx_status_t status; + status = crypt_invoke(req_msg, PSE_READ_MC_REQ_SIZE, &mc_req.req_hdr, SE_READ_MONOTONIC_COUNTER_TIMEOUT_MSEC, + resp_msg, PSE_READ_MC_RESP_SIZE, &mc_resp.resp_hdr); + if (status == SGX_SUCCESS) + { + *counter_value = mc_resp.counter_value; + } + //error condition + free(req_msg); + free(resp_msg); + return status; +} + diff --git a/sdk/tkey_exchange/Makefile b/sdk/tkey_exchange/Makefile new file mode 100644 index 0000000000..a4bddc27b2 --- /dev/null +++ b/sdk/tkey_exchange/Makefile @@ -0,0 +1,94 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR = ../.. +include $(TOP_DIR)/buildenv.mk + +CFLAGS += -Werror +CXXFLAGS += -Werror + +INCLUDE += -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc + +INCLUDE += -I$(LINUX_PSW_DIR)/ae/inc \ + -I$(LINUX_PSW_DIR)/ae/inc/internal \ + -I$(LINUX_PSW_DIR)/ae/common \ + -I$(LINUX_PSW_DIR)/ae/ + +INCLUDE += -I$(LINUX_EXTERNAL_DIR)/crypto_px/include \ + -I$(LINUX_EXTERNAL_DIR)/epid/inc + +INCLUDE += -I$(LINUX_SDK_DIR)/tlibstdcxx/stlport + +vpath %.cpp $(COMMON_DIR)/src:$(LINUX_PSW_DIR)/ae/common +vpath %.edl $(COMMON_DIR)/inc + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) + +SRC := $(wildcard *.cpp) +SRC += ecp.cpp + +OBJ := $(SRC:.cpp=.o) + +EDGER8R = $(LINUX_SDK_DIR)/edger8r/linux/_build/Edger8r.native +LIBNAME := libsgx_tkey_exchange.a + +.PHONY: all +all: $(LIBNAME) | $(BUILD_DIR) + @$(CP) $< $| + @$(CP) sgx_tkey_exchange_t.h sgx_tkey_exchange_u.h $(COMMON_DIR)/inc/ + @$(CP) sgx_tkey_exchange_t.c sgx_tkey_exchange_u.c $(COMMON_DIR)/src/ + +$(LIBNAME): $(OBJ) + $(AR) rcsD $@ $^ + +tkey_exchange.o: $(COMMON_DIR)/inc/sgx_tkey_exchange_t.h + +$(COMMON_DIR)/inc/sgx_tkey_exchange_t.h: $(COMMON_DIR)/inc/sgx_tkey_exchange.edl + $(EDGER8R) --search-path $(TOP_DIR)/common/inc sgx_tkey_exchange.edl + +$(OBJ): %.o :%.cpp + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ + +$(BUILD_DIR): + @$(MKDIR) $(BUILD_DIR) + +.PHONY: clean +clean: + @$(RM) $(OBJ) + @$(RM) $(LIBNAME) $(BUILD_DIR)/$(LIBNAME) + @$(RM) $(COMMON_DIR)/inc/sgx_tkey_exchange_t.h $(COMMON_DIR)/inc/sgx_tkey_exchange_u.h + @$(RM) $(COMMON_DIR)/src/sgx_tkey_exchange_t.c $(COMMON_DIR)/src/sgx_tkey_exchange_u.c + @$(RM) sgx_tkey_exchange_t.* sgx_tkey_exchange_u.* + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/tkey_exchange/simple_vector.cpp b/sdk/tkey_exchange/simple_vector.cpp new file mode 100644 index 0000000000..12c8150e61 --- /dev/null +++ b/sdk/tkey_exchange/simple_vector.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include +#include "simple_vector.h" + +//initial vector capacity when fisrt item is added to vector +#define INIT_SIZE 10 + +//max vector capacity of a vector +#define MAX_SIZE 10000 + +//init vector to all zero +void vector_init(simple_vector* v) +{ + if (v) + { + v->size = 0; + v->capacity = 0; + v->data = NULL; + } +} + +//return current number of items the vector holds +uint32_t vector_size(const simple_vector* v) +{ + if (v) + return v->size; + else + return 0; +} + +//push a pointer to the end of the vector +//return 0 if success, return 1 if memory malloc failure. +errno_t vector_push_back(simple_vector* v, const void* data) +{ + if (v) + { + if (v->capacity == 0) { + //first item + v->data = (void**)malloc(sizeof(void*) * INIT_SIZE); + if (v->data ==NULL) + return 1; + v->capacity = INIT_SIZE; + memset(v->data, '\0', sizeof(void*) * INIT_SIZE); + } + else if (v->size == v->capacity) { + void** new_data; + if( v->capacity >= MAX_SIZE - INIT_SIZE) + return 1; + //increate size by INIT_SIZE + new_data = (void**)realloc(v->data, sizeof(void*) *( v->capacity + INIT_SIZE)); + if (new_data ==NULL) + return 1; + memset(&new_data[v->capacity], '\0', sizeof(void*) * INIT_SIZE); + v->data = new_data; + v->capacity += INIT_SIZE; + } + //assign new item + v->data[v->size] = const_cast(data); + v->size++; + return 0; + } + return 1; +} + +//get the item pointer in the vector +//return 0 if success, return 1 if index is out of range or data pointer is invalid. +errno_t vector_get(const simple_vector* v, uint32_t index, void** data) +{ + if (!v || index >= v->size || !data) + return 1; + *data = v->data[index]; + return 0; +} + +//set the pointer in the vector +//return 0 if success, return 1 if index is out of range. +errno_t vector_set(simple_vector* v, uint32_t index, const void* data) +{ + if (!v || index >= v->size) + return 1; + v->data[index] = const_cast(data); + return 0; +} + +//release memory used by the vector +void vector_free(simple_vector* v) +{ + if (v) + { + v->size = 0; + v->capacity = 0; + if(v->data) + { + free(v->data); + v->data = NULL; + } + } +} diff --git a/sdk/tkey_exchange/simple_vector.h b/sdk/tkey_exchange/simple_vector.h new file mode 100644 index 0000000000..d1da3b33b1 --- /dev/null +++ b/sdk/tkey_exchange/simple_vector.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SIMPLE_VECOTR_H +#define _SIMPLE_VECOTR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _simple_vector +{ + uint32_t size; + uint32_t capacity; + void** data; +}simple_vector; + +//call vector_init first or set all field to 0 to use a simple_vector +void vector_init(simple_vector* vector); + +//get number of elements in simple_vector +uint32_t vector_size(const simple_vector* vector); + +//insert an element to the end of simple_vector, the element can only be pointer +errno_t vector_push_back(simple_vector* vector, const void* data); + +//get an element +errno_t vector_get(const simple_vector* v, uint32_t index, void** data); + +//set an element content +errno_t vector_set(simple_vector* v, uint32_t index, const void* data); + +//free the simple_vector allocated memory +void vector_free(simple_vector* vector); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/tkey_exchange/tkey_exchange.cpp b/sdk/tkey_exchange/tkey_exchange.cpp new file mode 100644 index 0000000000..32681d263d --- /dev/null +++ b/sdk/tkey_exchange/tkey_exchange.cpp @@ -0,0 +1,698 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "sgx_tkey_exchange.h" +#include "sgx_trts.h" +#include "sgx_utils.h" +#include "ecp_interface.h" +#include "util.h" +#include "string.h" +#include "stdlib.h" +#include "sgx_spinlock.h" +#include "sgx_tkey_exchange_t.h" +#include "simple_vector.h" +#include "se_cdefs.h" + +// Add a version to tkey_exchange. +SGX_ACCESS_VERSION(tkey_exchange, 1) + +#define ERROR_BREAK(sgx_status) if(SGX_SUCCESS!=sgx_status){break;} +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} + +#pragma pack(push, 1) + +// any call to sgx_ra_init will reset the input pubkey related ra_db_item_t.ra_state to ra_inited +// only sgx_ra_get_ga can change ra_inited to ra_get_gaed +// only sgx_ra_proc_msg2_trusted can change ra_get_gaed to ra_proc_msg2ed +// sgx_ra_get_msg3_trusted and sgx_ra_get_keys will check ra_state whether to be ra_proc_msg2ed + +typedef enum _ra_state +{ + ra_inited= 0, + ra_get_gaed, + ra_proc_msg2ed +}ra_state; + +typedef struct _ra_db_item_t +{ + sgx_ec256_public_t g_a; + sgx_ec256_public_t g_b; + sgx_ec_key_128bit_t vk_key; + sgx_ec256_public_t sp_pubkey; + sgx_ec256_private_t a; + sgx_ps_sec_prop_desc_t ps_sec_prop; + sgx_ec_key_128bit_t mk_key; + sgx_ec_key_128bit_t sk_key; + sgx_ec_key_128bit_t smk_key; + sgx_quote_nonce_t quote_nonce; //to verify quote report data + sgx_target_info_t qe_target; //to verify quote report + ra_state state; + sgx_spinlock_t item_lock; +}ra_db_item_t; + +#pragma pack(pop) + +static simple_vector g_ra_db = {0, 0, NULL}; +static sgx_spinlock_t g_ra_db_lock; + +extern "C" sgx_status_t sgx_ra_get_ga( + sgx_ra_context_t context, + sgx_ec256_public_t *g_a) +{ + sgx_status_t se_ret; + if(vector_size(&g_ra_db) <= context||!g_a) + return SGX_ERROR_INVALID_PARAMETER; + ra_db_item_t* item = NULL; + if(0 != vector_get(&g_ra_db, context, reinterpret_cast(&item)) || item == NULL ) + return SGX_ERROR_INVALID_PARAMETER; + + + sgx_ecc_state_handle_t ecc_state = NULL; + sgx_ec256_public_t pub_key; + sgx_ec256_private_t priv_key; + + memset(&pub_key, 0, sizeof(pub_key)); + memset(&priv_key, 0, sizeof(priv_key)); + + + sgx_spin_lock(&item->item_lock); + do + { + //sgx_ra_init must have been called + if (item->state != ra_inited) + { + se_ret = SGX_ERROR_INVALID_STATE; + break; + } + // ecc_state should be closed when exit. + se_ret = sgx_ecc256_open_context(&ecc_state); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + se_ret = sgx_ecc256_create_key_pair(&priv_key, &pub_key, ecc_state); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + memcpy(&item->a, &priv_key, sizeof(item->a)); + memcpy(&item->g_a, &pub_key, sizeof(item->g_a)); + memcpy(g_a, &pub_key, sizeof(sgx_ec256_public_t)); + item->state = ra_get_gaed; + //clear local private key to defense in depth + memset_s(&priv_key,sizeof(priv_key),0,sizeof(sgx_ec256_private_t)); + }while(0); + sgx_spin_unlock(&item->item_lock); + if(ecc_state!=NULL) + sgx_ecc256_close_context(ecc_state); + return se_ret; +} + +extern "C" sgx_status_t sgx_ra_proc_msg2_trusted( + sgx_ra_context_t context, + const sgx_ra_msg2_t *p_msg2, //(g_b||spid||quote_type|| KDF_ID ||sign_gb_ga||cmac||sig_rl_size||sig_rl) + const sgx_target_info_t *p_qe_target, + sgx_report_t *p_report, + sgx_quote_nonce_t* p_nonce) +{ + sgx_status_t se_ret = SGX_ERROR_UNEXPECTED; + //p_msg2[in] p_qe_target[in] p_report[out] p_nonce[out] in EDL file + if(vector_size(&g_ra_db) <= context + || !p_msg2 + || !p_qe_target + || !p_report + || !p_nonce) + return SGX_ERROR_INVALID_PARAMETER; + + ra_db_item_t* item = NULL; + if(0 != vector_get(&g_ra_db, context, reinterpret_cast(&item)) || item == NULL ) + return SGX_ERROR_INVALID_PARAMETER; + + sgx_ec256_private_t a; + memset(&a, 0, sizeof(a)); + // Create gb_ga + sgx_ec256_public_t gb_ga[2]; + sgx_ec256_public_t sp_pubkey; + memset(&gb_ga[0], 0, sizeof(gb_ga)); + sgx_spin_lock(&item->item_lock); + //sgx_ra_get_ga must have been called + if (item->state != ra_get_gaed) + { + sgx_spin_unlock(&item->item_lock); + return SGX_ERROR_INVALID_STATE; + } + memcpy(&a, &item->a, sizeof(a)); + memcpy(&gb_ga[1], &item->g_a, sizeof(gb_ga[1])); + memcpy(&sp_pubkey, &item->sp_pubkey, sizeof(sp_pubkey)); + sgx_spin_unlock(&item->item_lock); + memcpy(&gb_ga[0], &p_msg2->g_b, sizeof(gb_ga[0])); + + sgx_ecc_state_handle_t ecc_state = NULL; + + // ecc_state need to be freed when exit. + se_ret = sgx_ecc256_open_context(&ecc_state); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + return se_ret; + } + + sgx_ec256_dh_shared_t dh_key; + memset(&dh_key, 0, sizeof(dh_key)); + sgx_ec256_public_t* p_msg2_g_b = const_cast(&p_msg2->g_b); + se_ret = sgx_ecc256_compute_shared_dhkey(&a, + (sgx_ec256_public_t*)p_msg2_g_b, + (sgx_ec256_dh_shared_t*)&dh_key, ecc_state); + if(SGX_SUCCESS != se_ret) + { + if (SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + sgx_ecc256_close_context(ecc_state); + return se_ret; + } + // Verify signature of gb_ga + uint8_t result; + sgx_ec256_signature_t* p_msg2_sign_gb_ga = const_cast(&p_msg2->sign_gb_ga); + se_ret = sgx_ecdsa_verify((uint8_t *)&gb_ga, sizeof(gb_ga), + &sp_pubkey, + p_msg2_sign_gb_ga, + &result, ecc_state); + if(SGX_SUCCESS != se_ret) + { + if (SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + sgx_ecc256_close_context(ecc_state); + return se_ret; + } + if(SGX_EC_VALID != result) + { + sgx_ecc256_close_context(ecc_state); + return SGX_ERROR_INVALID_SIGNATURE; + } + sgx_ec_key_128bit_t smkey = {0}; + sgx_ec_key_128bit_t skey = {0}; + sgx_ec_key_128bit_t mkey = {0}; + sgx_ec_key_128bit_t vkey = {0}; + do + { + if (p_msg2->kdf_id == 0x0001) + { + se_ret = derive_key(&dh_key, "SMK", (uint32_t)(sizeof("SMK") -1), &smkey); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + sgx_cmac_128bit_tag_t mac; + uint32_t maced_size = offsetof(sgx_ra_msg2_t, mac); + + se_ret = sgx_rijndael128_cmac_msg(&smkey, (const uint8_t *)p_msg2, maced_size, &mac); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + //Check mac + if(0 == consttime_memequal(mac, p_msg2->mac, sizeof(mac))) + { + se_ret = SGX_ERROR_MAC_MISMATCH; + break; + } + + se_ret = derive_key((sgx_ec256_dh_shared_t*)&dh_key, "SK", (uint32_t )(sizeof("SK") -1), &skey); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + se_ret = derive_key((sgx_ec256_dh_shared_t*)&dh_key, "MK", (uint32_t)(sizeof("MK") -1), &mkey); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + se_ret = derive_key((sgx_ec256_dh_shared_t*)&dh_key, "VK", (uint32_t)(sizeof("VK") -1), &vkey); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + break; + } + } + else + { + se_ret = SGX_ERROR_KDF_MISMATCH; + break; + } + + //create a random nonce + se_ret =sgx_read_rand((uint8_t*)p_nonce, sizeof(sgx_quote_nonce_t)); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + sgx_spin_lock(&item->item_lock); + //sgx_ra_get_ga must have been called + if (item->state != ra_get_gaed) + { + se_ret = SGX_ERROR_INVALID_STATE; + sgx_spin_unlock(&item->item_lock); + break; + } + memcpy(&item->g_b, &p_msg2->g_b, sizeof(item->g_b)); + memcpy(&item->smk_key, smkey, sizeof(item->smk_key)); + memcpy(&item->sk_key, skey, sizeof(item->sk_key)); + memcpy(&item->mk_key, mkey, sizeof(item->mk_key)); + memcpy(&item->vk_key, vkey, sizeof(item->vk_key)); + memcpy(&item->qe_target, p_qe_target, sizeof(sgx_target_info_t)); + memcpy(&item->quote_nonce, p_nonce, sizeof(sgx_quote_nonce_t)); + sgx_report_data_t report_data = {{0}}; + se_static_assert(sizeof(sgx_report_data_t)>=sizeof(sgx_sha256_hash_t)); + // H = SHA256(ga || gb || VK_CMAC) + uint32_t sha256ed_size = offsetof(ra_db_item_t, sp_pubkey); + //report_data is 512bits, H is 256bits. The H is in the lower 256 bits of report data while the higher 256 bits are all zeros. + se_ret = sgx_sha256_msg((uint8_t *)&item->g_a, sha256ed_size, + (sgx_sha256_hash_t *)&report_data); + if(SGX_SUCCESS != se_ret) + { + if (SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + sgx_spin_unlock(&item->item_lock); + break; + } + //REPORTDATA = H + se_ret = sgx_create_report(p_qe_target, &report_data, p_report); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + sgx_spin_unlock(&item->item_lock); + break; + } + item->state = ra_proc_msg2ed; + sgx_spin_unlock(&item->item_lock); + }while(0); + memset_s(&dh_key, sizeof(dh_key), 0, sizeof(dh_key)); + sgx_ecc256_close_context(ecc_state); + memset_s(&a, sizeof(sgx_ec256_private_t),0, sizeof(sgx_ec256_private_t)); + memset_s(smkey, sizeof(sgx_ec_key_128bit_t),0, sizeof(sgx_ec_key_128bit_t)); + memset_s(skey, sizeof(sgx_ec_key_128bit_t),0, sizeof(sgx_ec_key_128bit_t)); + memset_s(mkey, sizeof(sgx_ec_key_128bit_t),0, sizeof(sgx_ec_key_128bit_t)); + memset_s(vkey, sizeof(sgx_ec_key_128bit_t),0, sizeof(sgx_ec_key_128bit_t)); + return se_ret; +} + + +/* the caller is supposed to fill the quote field in emp_msg3 before calling + * this function.*/ +extern "C" sgx_status_t sgx_ra_get_msg3_trusted( + sgx_ra_context_t context, + uint32_t quote_size, + sgx_report_t* qe_report, + sgx_ra_msg3_t *emp_msg3, //(mac||g_a||ps_sec_prop||quote) + uint32_t msg3_size) +{ + if(vector_size(&g_ra_db) <= context ||!quote_size || !qe_report || !emp_msg3) + return SGX_ERROR_INVALID_PARAMETER; + + ra_db_item_t* item = NULL; + if(0 != vector_get(&g_ra_db, context, reinterpret_cast(&item)) || item == NULL ) + return SGX_ERROR_INVALID_PARAMETER; + + //check integer overflow of msg3_size and quote_size + if (UINTPTR_MAX - reinterpret_cast(emp_msg3) < msg3_size || + UINT32_MAX - quote_size < sizeof(sgx_ra_msg3_t) || + sizeof(sgx_ra_msg3_t) + quote_size != msg3_size) + return SGX_ERROR_INVALID_PARAMETER; + + if (!sgx_is_outside_enclave(emp_msg3, msg3_size)) + return SGX_ERROR_INVALID_PARAMETER; + + sgx_status_t se_ret = SGX_ERROR_UNEXPECTED; + + //verify qe report + se_ret = sgx_verify_report(qe_report); + if(se_ret != SGX_SUCCESS) + { + if (SGX_ERROR_MAC_MISMATCH != se_ret && + SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + return se_ret; + } + + sgx_spin_lock(&item->item_lock); + //sgx_ra_proc_msg2_trusted must have been called + if (item->state != ra_proc_msg2ed) + { + sgx_spin_unlock(&item->item_lock); + return SGX_ERROR_INVALID_STATE; + } + //verify qe_report attributes and mr_enclave same as quoting enclave + if( memcmp( &qe_report->body.attributes, &item->qe_target.attributes, sizeof(sgx_attributes_t)) || + memcmp( &qe_report->body.mr_enclave, &item->qe_target.mr_enclave, sizeof(sgx_measurement_t)) ) + { + sgx_spin_unlock(&item->item_lock); + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_ra_msg3_t msg3_except_quote_in; + sgx_cmac_128bit_key_t smk_key; + memcpy(&msg3_except_quote_in.g_a, &item->g_a, sizeof(msg3_except_quote_in.g_a)); + memcpy(&msg3_except_quote_in.ps_sec_prop, &item->ps_sec_prop, + sizeof(msg3_except_quote_in.ps_sec_prop)); + memcpy(&smk_key, &item->smk_key, sizeof(smk_key)); + sgx_spin_unlock(&item->item_lock); + + sgx_sha_state_handle_t sha_handle = NULL; + sgx_cmac_state_handle_t cmac_handle = NULL; + + + //SHA256(NONCE || emp_quote) + sgx_sha256_hash_t hash = {0}; + se_ret = sgx_sha256_init(&sha_handle); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + return se_ret; + } + if (NULL == sha_handle) + { + return SGX_ERROR_UNEXPECTED; + } + do + { + se_ret = sgx_sha256_update((uint8_t *)&item->quote_nonce, + sizeof(item->quote_nonce), + sha_handle); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + //cmac M := ga || PS_SEC_PROP_DESC(all zero if unused) ||emp_quote + sgx_cmac_128bit_tag_t mac; + se_ret = sgx_cmac128_init(&smk_key, &cmac_handle); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + if (NULL == cmac_handle) + { + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + se_ret = sgx_cmac128_update((uint8_t*)&msg3_except_quote_in.g_a, + sizeof(msg3_except_quote_in.g_a), cmac_handle); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + se_ret = sgx_cmac128_update((uint8_t*)&msg3_except_quote_in.ps_sec_prop, + sizeof(msg3_except_quote_in.ps_sec_prop), cmac_handle); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + // sha256 and cmac quote + uint8_t quote_piece[32]; + const uint8_t* emp_quote_piecemeal = emp_msg3->quote; + uint32_t quote_piece_size = static_cast(sizeof(quote_piece)); + + while (emp_quote_piecemeal < emp_msg3->quote + quote_size) + { + //caculate size of one piece, the size of them are sizeof(quote_piece) except for the last one. + if (static_cast(emp_msg3->quote + quote_size - emp_quote_piecemeal) < quote_piece_size) + quote_piece_size = static_cast(emp_msg3->quote - emp_quote_piecemeal) + quote_size ; + memcpy(quote_piece, emp_quote_piecemeal, quote_piece_size); + se_ret = sgx_sha256_update(quote_piece, + quote_piece_size, + sha_handle); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + se_ret = sgx_cmac128_update(quote_piece, + quote_piece_size, + cmac_handle); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + emp_quote_piecemeal += sizeof(quote_piece); + } + ERROR_BREAK(se_ret); + + //get sha256 hash value + se_ret = sgx_sha256_get_hash(sha_handle, &hash); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + //get cmac value + se_ret = sgx_cmac128_final(cmac_handle, &mac); + if (SGX_SUCCESS != se_ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != se_ret) + se_ret = SGX_ERROR_UNEXPECTED; + break; + } + + //verify qe_report->body.report_data == SHA256(NONCE || emp_quote) + if(0 != memcmp(&qe_report->body.report_data, &hash, sizeof(hash))) + { + se_ret = SGX_ERROR_MAC_MISMATCH; + break; + } + + memcpy(&msg3_except_quote_in.mac, mac, sizeof(mac)); + memcpy(emp_msg3, &msg3_except_quote_in, offsetof(sgx_ra_msg3_t, quote)); + se_ret = SGX_SUCCESS; + }while(0); + memset_s(&smk_key, sizeof(smk_key), 0, sizeof(smk_key)); + (void)sgx_sha256_close(sha_handle); + if(cmac_handle != NULL) + sgx_cmac128_close(cmac_handle); + return se_ret; +} + +// TKE interface for isv enclaves +sgx_status_t sgx_ra_init( + const sgx_ec256_public_t *p_pub_key, + int b_pse, + sgx_ra_context_t *p_context) +{ + int valid = 0; + sgx_status_t ret = SGX_SUCCESS; + sgx_ecc_state_handle_t ecc_state = NULL; + + if(!p_pub_key || !p_context) + return SGX_ERROR_INVALID_PARAMETER; + + if(!sgx_is_within_enclave(p_pub_key, sizeof(sgx_ec256_public_t))) + return SGX_ERROR_INVALID_PARAMETER; + + ret = sgx_ecc256_open_context(&ecc_state); + if(SGX_SUCCESS != ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != ret) + ret = SGX_ERROR_UNEXPECTED; + return ret; + } + + ret = sgx_ecc256_check_point((const sgx_ec256_public_t *)p_pub_key, + ecc_state, &valid); + if(SGX_SUCCESS != ret) + { + if(SGX_ERROR_OUT_OF_MEMORY != ret) + ret = SGX_ERROR_UNEXPECTED; + sgx_ecc256_close_context(ecc_state); + return ret; + } + if(!valid) + { + sgx_ecc256_close_context(ecc_state); + return SGX_ERROR_INVALID_PARAMETER; + } + sgx_ecc256_close_context(ecc_state); + + //add new item to g_ra_db + ra_db_item_t* new_item = (ra_db_item_t*)malloc(sizeof(ra_db_item_t)); + if (!new_item) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + memset(new_item,0, sizeof(ra_db_item_t)); + memcpy(&new_item->sp_pubkey, p_pub_key, sizeof(new_item->sp_pubkey)); + if(b_pse) + { + //sgx_create_pse_session() must have been called + ret = sgx_get_ps_sec_prop(&new_item->ps_sec_prop); + if (ret!=SGX_SUCCESS) + { + SAFE_FREE(new_item); + return ret; + } + } + new_item->state = ra_inited; + + //find first empty slot in g_ra_db + int first_empty = -1; + ra_db_item_t* item = NULL; + sgx_spin_lock(&g_ra_db_lock); + uint32_t size = vector_size(&g_ra_db); + for (uint32_t i = 0; i < size; i++) + { + if(0 != vector_get(&g_ra_db, i, reinterpret_cast(&item))) + { + sgx_spin_unlock(&g_ra_db_lock); + SAFE_FREE(new_item); + return SGX_ERROR_UNEXPECTED; + } + if(item == NULL) + { + first_empty = i; + break; + } + } + //if there is a empty slot, use it + if (first_empty >= 0) + { + errno_t vret = vector_set(&g_ra_db, first_empty, new_item); + UNUSED(vret); + assert(vret == 0); + *p_context = first_empty; + } + //if there are no empty slots, add a new item to g_ra_db + else + { + if(size >= INT32_MAX) + { + //overflow + sgx_spin_unlock(&g_ra_db_lock); + SAFE_FREE(new_item); + return SGX_ERROR_OUT_OF_MEMORY; + } + if(0 != vector_push_back(&g_ra_db, new_item)) + { + sgx_spin_unlock(&g_ra_db_lock); + SAFE_FREE(new_item); + return SGX_ERROR_OUT_OF_MEMORY; + } + *p_context = size; + } + sgx_spin_unlock(&g_ra_db_lock); + return SGX_SUCCESS; +} + +// TKE interface for isv enclaves +sgx_status_t sgx_ra_get_keys( + sgx_ra_context_t context, + sgx_ra_key_type_t type, + sgx_ra_key_128_t *p_key) +{ + if(vector_size(&g_ra_db) <= context || !p_key) + return SGX_ERROR_INVALID_PARAMETER; + ra_db_item_t* item = NULL; + if(0 != vector_get(&g_ra_db, context, reinterpret_cast(&item)) || item == NULL ) + return SGX_ERROR_INVALID_PARAMETER; + + if(!sgx_is_within_enclave(p_key, sizeof(sgx_ra_key_128_t))) + return SGX_ERROR_INVALID_PARAMETER; + + sgx_status_t ret = SGX_SUCCESS; + sgx_spin_lock(&item->item_lock); + //sgx_ra_proc_msg2_trusted fill the keys, so keys are available after it's called. + if (item->state != ra_proc_msg2ed) + ret = SGX_ERROR_INVALID_STATE; + else if(SGX_RA_KEY_MK == type) + memcpy(p_key, item->mk_key, sizeof(sgx_ra_key_128_t)); + else if(SGX_RA_KEY_SK == type) + memcpy(p_key, item->sk_key, sizeof(sgx_ra_key_128_t)); + else + ret = SGX_ERROR_INVALID_PARAMETER; + sgx_spin_unlock(&item->item_lock); + return ret; +} + + +// TKE interface for isv enclaves +sgx_status_t SGXAPI sgx_ra_close( + sgx_ra_context_t context) +{ + if(vector_size(&g_ra_db) <= context) + return SGX_ERROR_INVALID_PARAMETER; + ra_db_item_t* item = NULL; + if(0 != vector_get(&g_ra_db, context, reinterpret_cast(&item)) || item == NULL ) + return SGX_ERROR_INVALID_PARAMETER; + sgx_spin_lock(&g_ra_db_lock); + //safe clear private key and RA key before free memory to defense in depth + memset_s(&item->a,sizeof(item->a),0,sizeof(sgx_ec256_private_t)); + memset_s(&item->vk_key,sizeof(item->vk_key),0,sizeof(sgx_ec_key_128bit_t)); + memset_s(&item->mk_key,sizeof(item->mk_key),0,sizeof(sgx_ec_key_128bit_t)); + memset_s(&item->sk_key,sizeof(item->sk_key),0,sizeof(sgx_ec_key_128bit_t)); + memset_s(&item->smk_key,sizeof(item->smk_key),0,sizeof(sgx_ec_key_128bit_t)); + SAFE_FREE(item); + vector_set(&g_ra_db, context, NULL); + sgx_spin_unlock(&g_ra_db_lock); + return SGX_SUCCESS; +} diff --git a/sdk/tkey_exchange/tkey_exchange_version.cpp b/sdk/tkey_exchange/tkey_exchange_version.cpp new file mode 100644 index 0000000000..04273263e0 --- /dev/null +++ b/sdk/tkey_exchange/tkey_exchange_version.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_TKEY_EXCHANGE_VERSION_STR __CONCAT("SGX_TKEY_EXCHANGE_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_tkey_exchange_version = SGX_TKEY_EXCHANGE_VERSION_STR; + +#ifdef __cplusplus +} +#endif diff --git a/sdk/tlibc/Makefile b/sdk/tlibc/Makefile new file mode 100644 index 0000000000..bada08a704 --- /dev/null +++ b/sdk/tlibc/Makefile @@ -0,0 +1,77 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +CFLAGS += $(ENCLAVE_CFLAGS) +ASFLAGS := $(CFLAGS) +CFLAGS += -std=c99 +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -fno-exceptions -fno-rtti + +CPPFLAGS += -I. \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(LINUX_SDK_DIR)/trts \ + -I./gdtoa \ + +LIBC_C_SRCS := $(wildcard gen/*.c gdtoa/*.c locale/*.c math/*.c stdlib/*.c string/*.c stdio/*.c time/*.c) + +LIBC_CPP_SRCS := $(wildcard gen/*.cpp) tstdc_version.cpp +LIBC_ASM_SRCS := $(wildcard gen/*.S) + +LIBC_OBJS := $(LIBC_C_SRCS:.c=.o) +LIBC_OBJS += $(LIBC_CPP_SRCS:.cpp=.o) +LIBC_OBJS += $(LIBC_ASM_SRCS:.S=.o) + +LIBC_NAME := libtlibc.a + +.PHONY: all +all: $(LIBC_NAME) + +$(LIBC_NAME): $(LIBC_OBJS) + $(AR) rcs $@ $^ + +string/consttime_memequal.o: string/consttime_memequal.c + $(CC) $(filter-out -O2,$(CFLAGS)) -O1 $(CPPFLAGS) -c $< -o $@ + +%.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + +%.o: %.S + $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + @$(RM) $(LIBC_NAME) $(LIBC_OBJS) diff --git a/sdk/tlibc/gdtoa/arith.h b/sdk/tlibc/gdtoa/arith.h new file mode 100644 index 0000000000..e6db1fa834 --- /dev/null +++ b/sdk/tlibc/gdtoa/arith.h @@ -0,0 +1,16 @@ +#define IEEE_8087 +#define Arith_Kind_ASL 1 +//#define Bad_float_h + +#ifdef __x86_64__ +#define Long int +#define Intcast (int)(long) +#define Double_Align +#define X64_bit_pointers +#endif + +#define INFNAN_CHECK +#define MULTIPLE_THREADS +#define NO_FENV_H +//#define USE_LOCALE +#define NO_LONG_LONG diff --git a/sdk/tlibc/gdtoa/dmisc.c b/sdk/tlibc/gdtoa/dmisc.c new file mode 100644 index 0000000000..a5795cfb79 --- /dev/null +++ b/sdk/tlibc/gdtoa/dmisc.c @@ -0,0 +1,224 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + +#ifndef MULTIPLE_THREADS + char *dtoa_result; +#endif + + char * +#ifdef KR_headers +rv_alloc(i) int i; +#else +rv_alloc(int i) +#endif +{ + int j, k, *r; + + j = sizeof(ULong); + for(k = 0; + sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; + j <<= 1) + k++; + r = (int*)Balloc(k); + if (r == NULL) + return ( +#ifndef MULTIPLE_THREADS + dtoa_result = +#endif + NULL); + *r = k; + return +#ifndef MULTIPLE_THREADS + dtoa_result = +#endif + (char *)(r+1); + } + + char * +#ifdef KR_headers +nrv_alloc(s, rve, n) char *s, **rve; int n; +#else +nrv_alloc(char *s, char **rve, int n) +#endif +{ + char *rv, *t; + + t = rv = rv_alloc(n); + if (t == NULL) + return (NULL); + while((*t = *s++) !=0) + t++; + if (rve) + *rve = t; + return rv; + } + +/* freedtoa(s) must be used to free values s returned by dtoa + * when MULTIPLE_THREADS is #defined. It should be used in all cases, + * but for consistency with earlier versions of dtoa, it is optional + * when MULTIPLE_THREADS is not defined. + */ + + void +#ifdef KR_headers +freedtoa(s) char *s; +#else +freedtoa(char *s) +#endif +{ + Bigint *b = (Bigint *)((int *)s - 1); + b->maxwds = 1 << (b->k = *(int*)b); + Bfree(b); +#ifndef MULTIPLE_THREADS + if (s == dtoa_result) + dtoa_result = 0; +#endif + } + + int +quorem +#ifdef KR_headers + (b, S) Bigint *b, *S; +#else + (Bigint *b, Bigint *S) +#endif +{ + int n; + ULong *bx, *bxe, q, *sx, *sxe; +#ifdef ULLong + ULLong borrow, carry, y, ys; +#else + ULong borrow, carry, y, ys; +#ifdef Pack_32 + ULong si, z, zs; +#endif +#endif + + n = S->wds; +#ifdef DEBUG + /*debug*/ if (b->wds > n) + /*debug*/ Bug("oversize b in quorem"); +#endif + if (b->wds < n) + return 0; + sx = S->x; + sxe = sx + --n; + bx = b->x; + bxe = bx + n; + q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ +#ifdef DEBUG + /*debug*/ if (q > 9) + /*debug*/ Bug("oversized quotient in quorem"); +#endif + if (q) { + borrow = 0; + carry = 0; + do { +#ifdef ULLong + ys = *sx++ * (ULLong)q + carry; + carry = ys >> 32; + y = *bx - (ys & 0xffffffffUL) - borrow; + borrow = y >> 32 & 1UL; + *bx++ = y & 0xffffffffUL; +#else +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) * q + carry; + zs = (si >> 16) * q + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#else + ys = *sx++ * q + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + *bx++ = y & 0xffff; +#endif +#endif + } + while(sx <= sxe); + if (!*bxe) { + bx = b->x; + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + if (cmp(b, S) >= 0) { + q++; + borrow = 0; + carry = 0; + bx = b->x; + sx = S->x; + do { +#ifdef ULLong + ys = *sx++ + carry; + carry = ys >> 32; + y = *bx - (ys & 0xffffffffUL) - borrow; + borrow = y >> 32 & 1UL; + *bx++ = y & 0xffffffffUL; +#else +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) + carry; + zs = (si >> 16) + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#else + ys = *sx++ + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + *bx++ = y & 0xffff; +#endif +#endif + } + while(sx <= sxe); + bx = b->x; + bxe = bx + n; + if (!*bxe) { + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + return q; + } diff --git a/sdk/tlibc/gdtoa/dtoa.c b/sdk/tlibc/gdtoa/dtoa.c new file mode 100644 index 0000000000..668f7b50b2 --- /dev/null +++ b/sdk/tlibc/gdtoa/dtoa.c @@ -0,0 +1,839 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 1999 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the Long + * calculation. + */ + +#ifdef Honor_FLT_ROUNDS +#undef Check_FLT_ROUNDS +#define Check_FLT_ROUNDS +#else +#define Rounding Flt_Rounds +#endif + + char * +dtoa +#ifdef KR_headers + (d0, mode, ndigits, decpt, sign, rve) + double d0; int mode, ndigits, *decpt, *sign; char **rve; +#else + (double d0, int mode, int ndigits, int *decpt, int *sign, char **rve) +#endif +{ + /* Arguments ndigits, decpt, sign are similar to those + of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4,5 ==> similar to 2 and 3, respectively, but (in + round-nearest mode) with the tests of mode 0 to + possibly return a shorter string that rounds to d. + With IEEE arithmetic and compilation with + -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same + as modes 2 and 3 when FLT_ROUNDS != 1. + 6-9 ==> Debugging modes similar to mode - 4: don't try + fast floating-point estimate (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, + j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, + spec_case, try_quick; + Long L; +#ifndef Sudden_Underflow + int denorm; + ULong x; +#endif + Bigint *b, *b1, *delta, *mlo, *mhi, *S; + U d, d2, eps; + double ds; + char *s, *s0; +#ifdef SET_INEXACT + int inexact, oldinexact; +#endif +#ifdef Honor_FLT_ROUNDS /*{*/ + int Rounding; +#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ + Rounding = Flt_Rounds; +#else /*}{*/ + Rounding = 1; + switch(fegetround()) { + case FE_TOWARDZERO: Rounding = 0; break; + case FE_UPWARD: Rounding = 2; break; + case FE_DOWNWARD: Rounding = 3; + } +#endif /*}}*/ +#endif /*}*/ + +#ifndef MULTIPLE_THREADS + if (dtoa_result) { + freedtoa(dtoa_result); + dtoa_result = 0; + } +#endif + d.d = d0; + if (word0(&d) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + word0(&d) &= ~Sign_bit; /* clear sign bit */ + } + else + *sign = 0; + +#if defined(IEEE_Arith) + defined(VAX) +#ifdef IEEE_Arith + if ((word0(&d) & Exp_mask) == Exp_mask) +#else + if (word0(&d) == 0x8000) +#endif + { + /* Infinity or NaN */ + *decpt = 9999; +#ifdef IEEE_Arith + if (!word1(&d) && !(word0(&d) & 0xfffff)) + return nrv_alloc("Infinity", rve, 8); +#endif + return nrv_alloc("NaN", rve, 3); + } +#endif +#ifdef IBM + dval(&d) += 0; /* normalize */ +#endif + if (!dval(&d)) { + *decpt = 1; + return nrv_alloc("0", rve, 1); + } + +#ifdef SET_INEXACT + try_quick = oldinexact = get_inexact(); + inexact = 1; +#endif +#ifdef Honor_FLT_ROUNDS + if (Rounding >= 2) { + if (*sign) + Rounding = Rounding == 2 ? 0 : 2; + else + if (Rounding != 2) + Rounding = 0; + } +#endif + + b = d2b(dval(&d), &be, &bbits); + if (b == NULL) + return (NULL); +#ifdef Sudden_Underflow + i = (int)(word0(&d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); +#else + if (( i = (int)(word0(&d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)) )!=0) { +#endif + dval(&d2) = dval(&d); + word0(&d2) &= Frac_mask1; + word0(&d2) |= Exp_11; +#ifdef IBM + if (( j = 11 - hi0bits(word0(&d2) & Frac_mask) )!=0) + dval(&d2) /= 1 << j; +#endif + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(&d) = (i-Bias)*log(2)/log(10) + log10(&d2) + * + * This suggests computing an approximation k to log10(&d) by + * + * k = (i - Bias)*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ + + i -= Bias; +#ifdef IBM + i <<= 2; + i += j; +#endif +#ifndef Sudden_Underflow + denorm = 0; + } + else { + /* d is denormalized */ + + i = bbits + be + (Bias + (P-1) - 1); + x = i > 32 ? word0(&d) << (64 - i) | word1(&d) >> (i - 32) + : word1(&d) << (32 - i); + dval(&d2) = x; + word0(&d2) -= 31*Exp_msk1; /* adjust exponent */ + i -= (Bias + (P-1) - 1) + 1; + denorm = 1; + } +#endif + ds = (dval(&d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; + if (k >= 0 && k <= Ten_pmax) { + if (dval(&d) < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + +#ifndef SET_INEXACT +#ifdef Check_FLT_ROUNDS + try_quick = Rounding == 1; +#else + try_quick = 1; +#endif +#endif /*SET_INEXACT*/ + + if (mode > 5) { + mode -= 4; + try_quick = 0; + } + leftright = 1; + ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ + /* silence erroneous "gcc -Wall" warning. */ + switch(mode) { + case 0: + case 1: + i = 18; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + s = s0 = rv_alloc(i); + if (s == NULL) + return (NULL); + +#ifdef Honor_FLT_ROUNDS + if (mode > 1 && Rounding != 1) + leftright = 0; +#endif + + if (ilim >= 0 && ilim <= Quick_max && try_quick) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + dval(&d2) = dval(&d); + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + dval(&d) /= bigtens[n_bigtens-1]; + ieps++; + } + for(; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + dval(&d) /= ds; + } + else if (( j1 = -k )!=0) { + dval(&d) *= tens[j1 & 0xf]; + for(j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + dval(&d) *= bigtens[i]; + } + } + if (k_check && dval(&d) < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + dval(&d) *= 10.; + ieps++; + } + dval(&eps) = ieps*dval(&d) + 7.; + word0(&eps) -= (P-1)*Exp_msk1; + if (ilim == 0) { + S = mhi = 0; + dval(&d) -= 5.; + if (dval(&d) > dval(&eps)) + goto one_digit; + if (dval(&d) < -dval(&eps)) + goto no_digits; + goto fast_failed; + } +#ifndef No_leftright + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + dval(&eps) = 0.5/tens[ilim-1] - dval(&eps); + for(i = 0;;) { + L = dval(&d); + dval(&d) -= L; + *s++ = '0' + (int)L; + if (dval(&d) < dval(&eps)) + goto ret1; + if (1. - dval(&d) < dval(&eps)) + goto bump_up; + if (++i >= ilim) + break; + dval(&eps) *= 10.; + dval(&d) *= 10.; + } + } + else { +#endif + /* Generate ilim digits, then fix them up. */ + dval(&eps) *= tens[ilim-1]; + for(i = 1;; i++, dval(&d) *= 10.) { + L = (Long)(dval(&d)); + if (!(dval(&d) -= L)) + ilim = i; + *s++ = '0' + (int)L; + if (i == ilim) { + if (dval(&d) > 0.5 + dval(&eps)) + goto bump_up; + else if (dval(&d) < 0.5 - dval(&eps)) { + while(*--s == '0'); + s++; + goto ret1; + } + break; + } + } +#ifndef No_leftright + } +#endif + fast_failed: + s = s0; + dval(&d) = dval(&d2); + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + S = mhi = 0; + if (ilim < 0 || dval(&d) <= 5*ds) + goto no_digits; + goto one_digit; + } + for(i = 1;; i++, dval(&d) *= 10.) { + L = (Long)(dval(&d) / ds); + dval(&d) -= L*ds; +#ifdef Check_FLT_ROUNDS + /* If FLT_ROUNDS == 2, L will usually be high by 1 */ + if (dval(&d) < 0) { + L--; + dval(&d) += ds; + } +#endif + *s++ = '0' + (int)L; + if (!dval(&d)) { +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + if (i == ilim) { +#ifdef Honor_FLT_ROUNDS + if (mode > 1) + switch(Rounding) { + case 0: goto ret1; + case 2: goto bump_up; + } +#endif + dval(&d) += dval(&d); +#ifdef ROUND_BIASED + if (dval(&d) >= ds) +#else + if (dval(&d) > ds || (dval(&d) == ds && L & 1)) +#endif + { + bump_up: + while(*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + break; + } + } + goto ret1; + } + + m2 = b2; + m5 = b5; + mhi = mlo = 0; + if (leftright) { + i = +#ifndef Sudden_Underflow + denorm ? be + (Bias + (P-1) - 1 + 1) : +#endif +#ifdef IBM + 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); +#else + 1 + P - bbits; +#endif + b2 += i; + s2 += i; + mhi = i2b(1); + if (mhi == NULL) + return (NULL); + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + mhi = pow5mult(mhi, m5); + if (mhi == NULL) + return (NULL); + b1 = mult(mhi, b); + if (b1 == NULL) + return (NULL); + Bfree(b); + b = b1; + } + if (( j = b5 - m5 )!=0) { + b = pow5mult(b, j); + if (b == NULL) + return (NULL); + } + } + else { + b = pow5mult(b, b5); + if (b == NULL) + return (NULL); + } + } + S = i2b(1); + if (S == NULL) + return (NULL); + if (s5 > 0) { + S = pow5mult(S, s5); + if (S == NULL) + return (NULL); + } + + /* Check for special case that d is a normalized power of 2. */ + + spec_case = 0; + if ((mode < 2 || leftright) +#ifdef Honor_FLT_ROUNDS + && Rounding == 1 +#endif + ) { + if (!word1(&d) && !(word0(&d) & Bndry_mask) +#ifndef Sudden_Underflow + && word0(&d) & (Exp_mask & ~Exp_msk1) +#endif + ) { + /* The special case */ + b2 += Log2P; + s2 += Log2P; + spec_case = 1; + } + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ +#ifdef Pack_32 + if (( i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f )!=0) + i = 32 - i; +#else + if (( i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf )!=0) + i = 16 - i; +#endif + if (i > 4) { + i -= 4; + b2 += i; + m2 += i; + s2 += i; + } + else if (i < 4) { + i += 28; + b2 += i; + m2 += i; + s2 += i; + } + if (b2 > 0) { + b = lshift(b, b2); + if (b == NULL) + return (NULL); + } + if (s2 > 0) { + S = lshift(S, s2); + if (S == NULL) + return (NULL); + } + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (b == NULL) + return (NULL); + if (leftright) { + mhi = multadd(mhi, 10, 0); + if (mhi == NULL) + return (NULL); + } + ilim = ilim1; + } + } + if (ilim <= 0 && (mode == 3 || mode == 5)) { + S = multadd(S,5,0); + if (S == NULL) + return (NULL); + if (ilim < 0 || cmp(b,S) <= 0) { + /* no digits, fcvt style */ + no_digits: + k = -1 - ndigits; + goto ret; + } + one_digit: + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) { + mhi = lshift(mhi, m2); + if (mhi == NULL) + return (NULL); + } + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + mlo = mhi; + if (spec_case) { + mhi = Balloc(mhi->k); + if (mhi == NULL) + return (NULL); + Bcopy(mhi, mlo); + mhi = lshift(mhi, Log2P); + if (mhi == NULL) + return (NULL); + } + + for(i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + delta = diff(S, mhi); + if (delta == NULL) + return (NULL); + j1 = delta->sign ? 1 : cmp(b, delta); + Bfree(delta); +#ifndef ROUND_BIASED + if (j1 == 0 && mode != 1 && !(word1(&d) & 1) +#ifdef Honor_FLT_ROUNDS + && Rounding >= 1 +#endif + ) { + if (dig == '9') + goto round_9_up; + if (j > 0) + dig++; +#ifdef SET_INEXACT + else if (!b->x[0] && b->wds <= 1) + inexact = 0; +#endif + *s++ = dig; + goto ret; + } +#endif + if (j < 0 || (j == 0 && mode != 1 +#ifndef ROUND_BIASED + && !(word1(&d) & 1) +#endif + )) { + if (!b->x[0] && b->wds <= 1) { +#ifdef SET_INEXACT + inexact = 0; +#endif + goto accept_dig; + } +#ifdef Honor_FLT_ROUNDS + if (mode > 1) + switch(Rounding) { + case 0: goto accept_dig; + case 2: goto keep_dig; + } +#endif /*Honor_FLT_ROUNDS*/ + if (j1 > 0) { + b = lshift(b, 1); + if (b == NULL) + return (NULL); + j1 = cmp(b, S); +#ifdef ROUND_BIASED + if (j1 >= 0 /*)*/ +#else + if ((j1 > 0 || (j1 == 0 && dig & 1)) +#endif + && dig++ == '9') + goto round_9_up; + } + accept_dig: + *s++ = dig; + goto ret; + } + if (j1 > 0) { +#ifdef Honor_FLT_ROUNDS + if (!Rounding) + goto accept_dig; +#endif + if (dig == '9') { /* possible if i == 1 */ + round_9_up: + *s++ = '9'; + goto roundoff; + } + *s++ = dig + 1; + goto ret; + } +#ifdef Honor_FLT_ROUNDS + keep_dig: +#endif + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (b == NULL) + return (NULL); + if (mlo == mhi) { + mlo = mhi = multadd(mhi, 10, 0); + if (mlo == NULL) + return (NULL); + } + else { + mlo = multadd(mlo, 10, 0); + if (mlo == NULL) + return (NULL); + mhi = multadd(mhi, 10, 0); + if (mhi == NULL) + return (NULL); + } + } + } + else + for(i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (!b->x[0] && b->wds <= 1) { +#ifdef SET_INEXACT + inexact = 0; +#endif + goto ret; + } + if (i >= ilim) + break; + b = multadd(b, 10, 0); + if (b == NULL) + return (NULL); + } + + /* Round off last digit */ + +#ifdef Honor_FLT_ROUNDS + switch(Rounding) { + case 0: goto trimzeros; + case 2: goto roundoff; + } +#endif + b = lshift(b, 1); + if (b == NULL) + return (NULL); + j = cmp(b, S); +#ifdef ROUND_BIASED + if (j >= 0) +#else + if (j > 0 || (j == 0 && dig & 1)) +#endif + { + roundoff: + while(*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + ++*s++; + } + else { +#ifdef Honor_FLT_ROUNDS + trimzeros: +#endif + while(*--s == '0'); + s++; + } + ret: + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } + ret1: +#ifdef SET_INEXACT + if (inexact) { + if (!oldinexact) { + word0(&d) = Exp_1 + (70 << Exp_shift); + word1(&d) = 0; + dval(&d) += 1.; + } + } + else if (!oldinexact) + clear_inexact(); +#endif + Bfree(b); + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + return s0; + } diff --git a/sdk/tlibc/gdtoa/gd_qnan.h b/sdk/tlibc/gdtoa/gd_qnan.h new file mode 100644 index 0000000000..87eba8fb31 --- /dev/null +++ b/sdk/tlibc/gdtoa/gd_qnan.h @@ -0,0 +1,12 @@ +#define f_QNAN 0xffc00000 +#define d_QNAN0 0x0 +#define d_QNAN1 0xfff80000 +#define ld_QNAN0 0x0 +#define ld_QNAN1 0xc0000000 +#define ld_QNAN2 0xffff +#define ld_QNAN3 0x0 +#define ldus_QNAN0 0x0 +#define ldus_QNAN1 0x0 +#define ldus_QNAN2 0x0 +#define ldus_QNAN3 0xc000 +#define ldus_QNAN4 0xffff diff --git a/sdk/tlibc/gdtoa/gdtoa.c b/sdk/tlibc/gdtoa/gdtoa.c new file mode 100644 index 0000000000..fd11de5600 --- /dev/null +++ b/sdk/tlibc/gdtoa/gdtoa.c @@ -0,0 +1,829 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 1999 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + static Bigint * +#ifdef KR_headers +bitstob(bits, nbits, bbits) ULong *bits; int nbits; int *bbits; +#else +bitstob(ULong *bits, int nbits, int *bbits) +#endif +{ + int i, k; + Bigint *b; + ULong *be, *x, *x0; + + i = ULbits; + k = 0; + while(i < nbits) { + i <<= 1; + k++; + } +#ifndef Pack_32 + if (!k) + k = 1; +#endif + b = Balloc(k); + if (b == NULL) + return (NULL); + be = bits + ((nbits - 1) >> kshift); + x = x0 = b->x; + do { + *x++ = *bits & ALL_ON; +#ifdef Pack_16 + *x++ = (*bits >> 16) & ALL_ON; +#endif + } while(++bits <= be); + i = x - x0; + while(!x0[--i]) + if (!i) { + b->wds = 0; + *bbits = 0; + goto ret; + } + b->wds = i + 1; + *bbits = i*ULbits + 32 - hi0bits(b->x[i]); + ret: + return b; + } + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the Long + * calculation. + */ + + char * +gdtoa +#ifdef KR_headers + (fpi, be, bits, kindp, mode, ndigits, decpt, rve) + FPI *fpi; int be; ULong *bits; + int *kindp, mode, ndigits, *decpt; char **rve; +#else + (FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve) +#endif +{ + /* Arguments ndigits and decpt are similar to the second and third + arguments of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + be = exponent: value = (integer represented by bits) * (2 to the power of be). + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4-9 should give the same return values as 2-3, i.e., + 4 <= mode <= 9 ==> same return as mode + 2 + (mode & 1). These modes are mainly for + debugging; often they run slower but sometimes + faster than modes 2-3. + 4,5,8,9 ==> left-to-right digit generation. + 6-9 ==> don't try fast floating-point estimate + (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + int bbits, b2, b5, be0, dig, i, ieps, ilim, ilim0, ilim1, inex; + int j, j1, k, k0, k_check, kind, leftright, m2, m5, nbits; + int rdir, s2, s5, spec_case, try_quick; + Long L; + Bigint *b, *b1, *delta, *mlo, *mhi, *mhi1, *S; + double d2, ds; + char *s, *s0; + U d, eps; + +#ifndef MULTIPLE_THREADS + if (dtoa_result) { + freedtoa(dtoa_result); + dtoa_result = 0; + } +#endif + inex = 0; + kind = *kindp &= ~STRTOG_Inexact; + switch(kind & STRTOG_Retmask) { + case STRTOG_Zero: + goto ret_zero; + case STRTOG_Normal: + case STRTOG_Denormal: + break; + case STRTOG_Infinite: + *decpt = -32768; + return nrv_alloc("Infinity", rve, 8); + case STRTOG_NaN: + *decpt = -32768; + return nrv_alloc("NaN", rve, 3); + default: + return 0; + } + b = bitstob(bits, nbits = fpi->nbits, &bbits); + if (b == NULL) + return (NULL); + be0 = be; + if ( (i = trailz(b)) !=0) { + rshift(b, i); + be += i; + bbits -= i; + } + if (!b->wds) { + Bfree(b); + ret_zero: + *decpt = 1; + return nrv_alloc("0", rve, 1); + } + + dval(&d) = b2d(b, &i); + i = be + bbits - 1; + word0(&d) &= Frac_mask1; + word0(&d) |= Exp_11; +#ifdef IBM + if ( (j = 11 - hi0bits(word0(&d) & Frac_mask)) !=0) + dval(&d) /= 1 << j; +#endif + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(&d) = (i-Bias)*log(2)/log(10) + log10(d2) + * + * This suggests computing an approximation k to log10(&d) by + * + * k = (i - Bias)*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ +#ifdef IBM + i <<= 2; + i += j; +#endif + ds = (dval(&d)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + + /* correct assumption about exponent range */ + if ((j = i) < 0) + j = -j; + if ((j -= 1077) > 0) + ds += j * 7e-17; + + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; +#ifdef IBM + j = be + bbits - 1; + if ( (j1 = j & 3) !=0) + dval(&d) *= 1 << j1; + word0(&d) += j << Exp_shift - 2 & Exp_mask; +#else + word0(&d) += (be + bbits - 1) << Exp_shift; +#endif + if (k >= 0 && k <= Ten_pmax) { + if (dval(&d) < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + try_quick = 1; + if (mode > 5) { + mode -= 4; + try_quick = 0; + } + else if (i >= -4 - Emin || i < Emin) + try_quick = 0; + leftright = 1; + ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ + /* silence erroneous "gcc -Wall" warning. */ + switch(mode) { + case 0: + case 1: + i = (int)(nbits * .30103) + 3; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + s = s0 = rv_alloc(i); + if (s == NULL) + return (NULL); + + if ( (rdir = fpi->rounding - 1) !=0) { + if (rdir < 0) + rdir = 2; + if (kind & STRTOG_Neg) + rdir = 3 - rdir; + } + + /* Now rdir = 0 ==> round near, 1 ==> round up, 2 ==> round down. */ + + if (ilim >= 0 && ilim <= Quick_max && try_quick && !rdir +#ifndef IMPRECISE_INEXACT + && k == 0 +#endif + ) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + d2 = dval(&d); +#ifdef IBM + if ( (j = 11 - hi0bits(word0(&d) & Frac_mask)) !=0) + dval(&d) /= 1 << j; +#endif + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + dval(&d) /= bigtens[n_bigtens-1]; + ieps++; + } + for(; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + } + else { + ds = 1.; + if ( (j1 = -k) !=0) { + dval(&d) *= tens[j1 & 0xf]; + for(j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + dval(&d) *= bigtens[i]; + } + } + } + if (k_check && dval(&d) < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + dval(&d) *= 10.; + ieps++; + } + dval(&eps) = ieps*dval(&d) + 7.; + word0(&eps) -= (P-1)*Exp_msk1; + if (ilim == 0) { + S = mhi = 0; + dval(&d) -= 5.; + if (dval(&d) > dval(&eps)) + goto one_digit; + if (dval(&d) < -dval(&eps)) + goto no_digits; + goto fast_failed; + } +#ifndef No_leftright + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + dval(&eps) = ds*0.5/tens[ilim-1] - dval(&eps); + for(i = 0;;) { + L = (Long)(dval(&d)/ds); + dval(&d) -= L*ds; + *s++ = '0' + (int)L; + if (dval(&d) < dval(&eps)) { + if (dval(&d)) + inex = STRTOG_Inexlo; + goto ret1; + } + if (ds - dval(&d) < dval(&eps)) + goto bump_up; + if (++i >= ilim) + break; + dval(&eps) *= 10.; + dval(&d) *= 10.; + } + } + else { +#endif + /* Generate ilim digits, then fix them up. */ + dval(&eps) *= tens[ilim-1]; + for(i = 1;; i++, dval(&d) *= 10.) { + if ( (L = (Long)(dval(&d)/ds)) !=0) + dval(&d) -= L*ds; + *s++ = '0' + (int)L; + if (i == ilim) { + ds *= 0.5; + if (dval(&d) > ds + dval(&eps)) + goto bump_up; + else if (dval(&d) < ds - dval(&eps)) { + if (dval(&d)) + inex = STRTOG_Inexlo; + goto clear_trailing0; + } + break; + } + } +#ifndef No_leftright + } +#endif + fast_failed: + s = s0; + dval(&d) = d2; + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + S = mhi = 0; + if (ilim < 0 || dval(&d) <= 5*ds) + goto no_digits; + goto one_digit; + } + for(i = 1;; i++, dval(&d) *= 10.) { + L = dval(&d) / ds; + dval(&d) -= L*ds; +#ifdef Check_FLT_ROUNDS + /* If FLT_ROUNDS == 2, L will usually be high by 1 */ + if (dval(&d) < 0) { + L--; + dval(&d) += ds; + } +#endif + *s++ = '0' + (int)L; + if (dval(&d) == 0.) + break; + if (i == ilim) { + if (rdir) { + if (rdir == 1) + goto bump_up; + inex = STRTOG_Inexlo; + goto ret1; + } + dval(&d) += dval(&d); +#ifdef ROUND_BIASED + if (dval(&d) >= ds) +#else + if (dval(&d) > ds || (dval(&d) == ds && L & 1)) +#endif + { + bump_up: + inex = STRTOG_Inexhi; + while(*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + else { + inex = STRTOG_Inexlo; + clear_trailing0: + while(*--s == '0'){} + ++s; + } + break; + } + } + goto ret1; + } + + m2 = b2; + m5 = b5; + mhi = mlo = 0; + if (leftright) { + i = nbits - bbits; + if (be - i++ < fpi->emin && mode != 3 && mode != 5) { + /* denormal */ + i = be - fpi->emin + 1; + if (mode >= 2 && ilim > 0 && ilim < i) + goto small_ilim; + } + else if (mode >= 2) { + small_ilim: + j = ilim - 1; + if (m5 >= j) + m5 -= j; + else { + s5 += j -= m5; + b5 += j; + m5 = 0; + } + if ((i = ilim) < 0) { + m2 -= i; + i = 0; + } + } + b2 += i; + s2 += i; + mhi = i2b(1); + if (mhi == NULL) + return (NULL); + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + mhi = pow5mult(mhi, m5); + if (mhi == NULL) + return (NULL); + b1 = mult(mhi, b); + if (b1 == NULL) + return (NULL); + Bfree(b); + b = b1; + } + if ( (j = b5 - m5) !=0) { + b = pow5mult(b, j); + if (b == NULL) + return (NULL); + } + } + else { + b = pow5mult(b, b5); + if (b == NULL) + return (NULL); + } + } + S = i2b(1); + if (S == NULL) + return (NULL); + if (s5 > 0) { + S = pow5mult(S, s5); + if (S == NULL) + return (NULL); + } + + /* Check for special case that d is a normalized power of 2. */ + + spec_case = 0; + if (mode < 2) { + if (bbits == 1 && be0 > fpi->emin + 1) { + /* The special case */ + b2++; + s2++; + spec_case = 1; + } + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ + i = ((s5 ? hi0bits(S->x[S->wds-1]) : ULbits - 1) - s2 - 4) & kmask; + m2 += i; + if ((b2 += i) > 0) { + b = lshift(b, b2); + if (b == NULL) + return (NULL); + } + if ((s2 += i) > 0) { + S = lshift(S, s2); + if (S == NULL) + return (NULL); + } + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (b == NULL) + return (NULL); + if (leftright) { + mhi = multadd(mhi, 10, 0); + if (mhi == NULL) + return (NULL); + } + ilim = ilim1; + } + } + if (ilim <= 0 && mode > 2) { + S = multadd(S,5,0); + if (S == NULL) + return (NULL); + if (ilim < 0 || cmp(b,S) <= 0) { + /* no digits, fcvt style */ + no_digits: + k = -1 - ndigits; + inex = STRTOG_Inexlo; + goto ret; + } + one_digit: + inex = STRTOG_Inexhi; + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) { + mhi = lshift(mhi, m2); + if (mhi == NULL) + return (NULL); + } + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + mlo = mhi; + if (spec_case) { + mhi = Balloc(mhi->k); + if (mhi == NULL) + return (NULL); + Bcopy(mhi, mlo); + mhi = lshift(mhi, 1); + if (mhi == NULL) + return (NULL); + } + + for(i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + delta = diff(S, mhi); + if (delta == NULL) + return (NULL); + j1 = delta->sign ? 1 : cmp(b, delta); + Bfree(delta); +#ifndef ROUND_BIASED + if (j1 == 0 && !mode && !(bits[0] & 1) && !rdir) { + if (dig == '9') + goto round_9_up; + if (j <= 0) { + if (b->wds > 1 || b->x[0]) + inex = STRTOG_Inexlo; + } + else { + dig++; + inex = STRTOG_Inexhi; + } + *s++ = dig; + goto ret; + } +#endif + if (j < 0 || (j == 0 && !mode +#ifndef ROUND_BIASED + && !(bits[0] & 1) +#endif + )) { + if (rdir && (b->wds > 1 || b->x[0])) { + if (rdir == 2) { + inex = STRTOG_Inexlo; + goto accept; + } + while (cmp(S,mhi) > 0) { + *s++ = dig; + mhi1 = multadd(mhi, 10, 0); + if (mhi1 == NULL) + return (NULL); + if (mlo == mhi) + mlo = mhi1; + mhi = mhi1; + b = multadd(b, 10, 0); + if (b == NULL) + return (NULL); + dig = quorem(b,S) + '0'; + } + if (dig++ == '9') + goto round_9_up; + inex = STRTOG_Inexhi; + goto accept; + } + if (j1 > 0) { + b = lshift(b, 1); + if (b == NULL) + return (NULL); + j1 = cmp(b, S); +#ifdef ROUND_BIASED + if (j1 >= 0 /*)*/ +#else + if ((j1 > 0 || (j1 == 0 && dig & 1)) +#endif + && dig++ == '9') + goto round_9_up; + inex = STRTOG_Inexhi; + } + if (b->wds > 1 || b->x[0]) + inex = STRTOG_Inexlo; + accept: + *s++ = dig; + goto ret; + } + if (j1 > 0 && rdir != 2) { + if (dig == '9') { /* possible if i == 1 */ + round_9_up: + *s++ = '9'; + inex = STRTOG_Inexhi; + goto roundoff; + } + inex = STRTOG_Inexhi; + *s++ = dig + 1; + goto ret; + } + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (b == NULL) + return (NULL); + if (mlo == mhi) { + mlo = mhi = multadd(mhi, 10, 0); + if (mlo == NULL) + return (NULL); + } + else { + mlo = multadd(mlo, 10, 0); + if (mlo == NULL) + return (NULL); + mhi = multadd(mhi, 10, 0); + if (mhi == NULL) + return (NULL); + } + } + } + else + for(i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (i >= ilim) + break; + b = multadd(b, 10, 0); + if (b == NULL) + return (NULL); + } + + /* Round off last digit */ + + if (rdir) { + if (rdir == 2 || (b->wds <= 1 && !b->x[0])) + goto chopzeros; + goto roundoff; + } + b = lshift(b, 1); + if (b == NULL) + return (NULL); + j = cmp(b, S); +#ifdef ROUND_BIASED + if (j >= 0) +#else + if (j > 0 || (j == 0 && dig & 1)) +#endif + { + roundoff: + inex = STRTOG_Inexhi; + while(*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + ++*s++; + } + else { + chopzeros: + if (b->wds > 1 || b->x[0]) + inex = STRTOG_Inexlo; + while(*--s == '0'){} + ++s; + } + ret: + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } + ret1: + Bfree(b); + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + *kindp |= inex; + return s0; + } diff --git a/sdk/tlibc/gdtoa/gdtoa.h b/sdk/tlibc/gdtoa/gdtoa.h new file mode 100644 index 0000000000..d587bcba49 --- /dev/null +++ b/sdk/tlibc/gdtoa/gdtoa.h @@ -0,0 +1,118 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#ifndef GDTOA_H_INCLUDED +#define GDTOA_H_INCLUDED + +#include "arith.h" +#include /* for size_t */ + +#ifndef Long +#define Long int +#endif +#ifndef ULong +typedef unsigned Long ULong; +#endif +#ifndef UShort +typedef unsigned short UShort; +#endif + +#ifndef ANSI +#ifdef KR_headers +#define ANSI(x) () +#define Void /*nothing*/ +#else +#define ANSI(x) x +#define Void void +#endif +#endif /* ANSI */ + +#ifndef CONST +#ifdef KR_headers +#define CONST /* blank */ +#else +#define CONST const +#endif +#endif /* CONST */ + + enum { /* return values from strtodg */ + STRTOG_Zero = 0x000, + STRTOG_Normal = 0x001, + STRTOG_Denormal = 0x002, + STRTOG_Infinite = 0x003, + STRTOG_NaN = 0x004, + STRTOG_NaNbits = 0x005, + STRTOG_NoNumber = 0x006, + STRTOG_NoMemory = 0x007, + STRTOG_Retmask = 0x00f, + + /* The following may be or-ed into one of the above values. */ + + STRTOG_Inexlo = 0x010, /* returned result rounded toward zero */ + STRTOG_Inexhi = 0x020, /* returned result rounded away from zero */ + STRTOG_Inexact = 0x030, + STRTOG_Underflow= 0x040, + STRTOG_Overflow = 0x080, + STRTOG_Neg = 0x100 /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */ + }; + + typedef struct +FPI { + int nbits; + int emin; + int emax; + int rounding; + int sudden_underflow; + } FPI; + +enum { /* FPI.rounding values: same as FLT_ROUNDS */ + FPI_Round_zero = 0, + FPI_Round_near = 1, + FPI_Round_up = 2, + FPI_Round_down = 3 + }; + +#ifdef __cplusplus +extern "C" { +#endif + +extern char* __dtoa ANSI((double d, int mode, int ndigits, int *decpt, + int *sign, char **rve)); +extern char* __gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, + int mode, int ndigits, int *decpt, char **rve)); +extern void __freedtoa ANSI((char*)); +extern int __strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*)); +extern int __strtorx ANSI((CONST char*, char**, int, void*)); + +#ifdef __cplusplus +} +#endif +#endif /* GDTOA_H_INCLUDED */ diff --git a/sdk/tlibc/gdtoa/gdtoaimp.h b/sdk/tlibc/gdtoa/gdtoaimp.h new file mode 100644 index 0000000000..a309ee65db --- /dev/null +++ b/sdk/tlibc/gdtoa/gdtoaimp.h @@ -0,0 +1,627 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998-2000 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* This is a variation on dtoa.c that converts arbitary binary + floating-point formats to and from decimal notation. It uses + double-precision arithmetic internally, so there are still + various #ifdefs that adapt the calculations to the native + double-precision arithmetic (any of IEEE, VAX D_floating, + or IBM mainframe arithmetic). + + Please send bug reports to David M. Gay (dmg at acm dot org, + with " at " changed at "@" and " dot " changed to "."). + */ + +/* On a machine with IEEE extended-precision registers, it is + * necessary to specify double-precision (53-bit) rounding precision + * before invoking strtod or dtoa. If the machine uses (the equivalent + * of) Intel 80x87 arithmetic, the call + * _control87(PC_53, MCW_PC); + * does this with many compilers. Whether this or another call is + * appropriate depends on the compiler; for this to work, it may be + * necessary to #include "float.h" or another system-dependent header + * file. + */ + +/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. + * + * This strtod returns a nearest machine number to the input decimal + * string (or sets errno to ERANGE). With IEEE arithmetic, ties are + * broken by the IEEE round-even rule. Otherwise ties are broken by + * biased rounding (add half and chop). + * + * Inspired loosely by William D. Clinger's paper "How to Read Floating + * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 112-126]. + * + * Modifications: + * + * 1. We only require IEEE, IBM, or VAX double-precision + * arithmetic (not IEEE double-extended). + * 2. We get by with floating-point arithmetic in a case that + * Clinger missed -- when we're computing d * 10^n + * for a small integer d and the integer n is not too + * much larger than 22 (the maximum integer k for which + * we can represent 10^k exactly), we may be able to + * compute (d*10^k) * 10^(e-k) with just one roundoff. + * 3. Rather than a bit-at-a-time adjustment of the binary + * result in the hard case, we use floating-point + * arithmetic to determine the adjustment to within + * one bit; only in really hard cases do we need to + * compute a second residual. + * 4. Because of 3., we don't need a large table of powers of 10 + * for ten-to-e (just some small tables, e.g. of 10^k + * for 0 <= k <= 22). + */ + +/* + * #define IEEE_8087 for IEEE-arithmetic machines where the least + * significant byte has the lowest address. + * #define IEEE_MC68k for IEEE-arithmetic machines where the most + * significant byte has the lowest address. + * #define Long int on machines with 32-bit ints and 64-bit longs. + * #define Sudden_Underflow for IEEE-format machines without gradual + * underflow (i.e., that flush to zero on underflow). + * #define IBM for IBM mainframe-style floating-point arithmetic. + * #define VAX for VAX-style floating-point arithmetic (D_floating). + * #define No_leftright to omit left-right logic in fast floating-point + * computation of dtoa and gdtoa. This will cause modes 4 and 5 to be + * treated the same as modes 2 and 3 for some inputs. + * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. + * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines + * that use extended-precision instructions to compute rounded + * products and quotients) with IBM. + * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic + * that rounds toward +Infinity. + * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased + * rounding when the underlying floating-point arithmetic uses + * unbiased rounding. This prevent using ordinary floating-point + * arithmetic when the result could be computed with one rounding error. + * #define Inaccurate_Divide for IEEE-format with correctly rounded + * products but inaccurate quotients, e.g., for Intel i860. + * #define NO_LONG_LONG on machines that do not have a "long long" + * integer type (of >= 64 bits). On such machines, you can + * #define Just_16 to store 16 bits per 32-bit Long when doing + * high-precision integer arithmetic. Whether this speeds things + * up or slows things down depends on the machine and the number + * being converted. If long long is available and the name is + * something other than "long long", #define Llong to be the name, + * and if "unsigned Llong" does not work as an unsigned version of + * Llong, #define #ULLong to be the corresponding unsigned type. + * #define KR_headers for old-style C function headers. + * #define Bad_float_h if your system lacks a float.h or if it does not + * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, + * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. + * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) + * if memory is available and otherwise does something you deem + * appropriate. If MALLOC is undefined, malloc will be invoked + * directly -- and assumed always to succeed. Similarly, if you + * want something other than the system's free() to be called to + * recycle memory acquired from MALLOC, #define FREE to be the + * name of the alternate routine. (FREE or free is only called in + * pathological cases, e.g., in a gdtoa call after a gdtoa return in + * mode 3 with thousands of digits requested.) + * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making + * memory allocations from a private pool of memory when possible. + * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, + * unless #defined to be a different length. This default length + * suffices to get rid of MALLOC calls except for unusual cases, + * such as decimal-to-binary conversion of a very long string of + * digits. When converting IEEE double precision values, the + * longest string gdtoa can return is about 751 bytes long. For + * conversions by strtod of strings of 800 digits and all gdtoa + * conversions of IEEE doubles in single-threaded executions with + * 8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with + * 4-byte pointers, PRIVATE_MEM >= 7112 appears adequate. + * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK + * #defined automatically on IEEE systems. On such systems, + * when INFNAN_CHECK is #defined, strtod checks + * for Infinity and NaN (case insensitively). + * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, + * strtodg also accepts (case insensitively) strings of the form + * NaN(x), where x is a string of hexadecimal digits (optionally + * preceded by 0x or 0X) and spaces; if there is only one string + * of hexadecimal digits, it is taken for the fraction bits of the + * resulting NaN; if there are two or more strings of hexadecimal + * digits, each string is assigned to the next available sequence + * of 32-bit words of fractions bits (starting with the most + * significant), right-aligned in each sequence. + * Unless GDTOA_NON_PEDANTIC_NANCHECK is #defined, input "NaN(...)" + * is consumed even when ... has the wrong form (in which case the + * "(...)" is consumed but ignored). + * #define MULTIPLE_THREADS if the system offers preemptively scheduled + * multiple threads. In this case, you must provide (or suitably + * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed + * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed + * in pow5mult, ensures lazy evaluation of only one copy of high + * powers of 5; omitting this lock would introduce a small + * probability of wasting memory, but would otherwise be harmless.) + * You must also invoke freedtoa(s) to free the value s returned by + * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. + * #define IMPRECISE_INEXACT if you do not care about the setting of + * the STRTOG_Inexact bits in the special case of doing IEEE double + * precision conversions (which could also be done by the strtod in + * dtoa.c). + * #define NO_HEX_FP to disable recognition of C9x's hexadecimal + * floating-point constants. + * #define -DNO_ERRNO to suppress setting errno (in strtod.c and + * strtodg.c). + * #define NO_STRING_H to use private versions of memcpy. + * On some K&R systems, it may also be necessary to + * #define DECLARE_SIZE_T in this case. + * #define USE_LOCALE to use the current locale's decimal_point value. + */ + +#ifndef GDTOAIMP_H_INCLUDED +#define GDTOAIMP_H_INCLUDED +#include "gdtoa.h" +#include "gd_qnan.h" +#ifdef Honor_FLT_ROUNDS +#include +#endif + +#ifdef DEBUG +#include "stdio.h" +#define Bug(x) //{fprintf(stderr, "%s\n", x); exit(1);} +#endif + +#include "stdlib.h" +#include "string.h" + +#ifdef KR_headers +#define Char char +#else +#define Char void +#endif + +#ifdef MALLOC +extern Char *MALLOC ANSI((size_t)); +#else +#define MALLOC malloc +#endif + +#undef IEEE_Arith +#undef Avoid_Underflow +#ifdef IEEE_MC68k +#define IEEE_Arith +#endif +#ifdef IEEE_8087 +#define IEEE_Arith +#endif + +#include "errno.h" +#ifdef Bad_float_h + +#ifdef IEEE_Arith +#define DBL_DIG 15 +#define DBL_MAX_10_EXP 308 +#define DBL_MAX_EXP 1024 +#define FLT_RADIX 2 +#define DBL_MAX 1.7976931348623157e+308 +#endif + +#ifdef IBM +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 75 +#define DBL_MAX_EXP 63 +#define FLT_RADIX 16 +#define DBL_MAX 7.2370055773322621e+75 +#endif + +#ifdef VAX +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 38 +#define DBL_MAX_EXP 127 +#define FLT_RADIX 2 +#define DBL_MAX 1.7014118346046923e+38 +#define n_bigtens 2 +#endif + +#ifndef LONG_MAX +#define LONG_MAX 2147483647 +#endif + +#else /* ifndef Bad_float_h */ +#include "float.h" +#endif /* Bad_float_h */ + +#ifdef IEEE_Arith +#define Scale_Bit 0x10 +#define n_bigtens 5 +#endif + +#ifdef IBM +#define n_bigtens 3 +#endif + +#ifdef VAX +#define n_bigtens 2 +#endif + +#ifndef __MATH_H__ +#include "math.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 +Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. +#endif + +typedef union { double d; ULong L[2]; } U; + +#ifdef IEEE_8087 +#define word0(x) (x)->L[1] +#define word1(x) (x)->L[0] +#else +#define word0(x) (x)->L[0] +#define word1(x) (x)->L[1] +#endif +#define dval(x) (x)->d + +/* The following definition of Storeinc is appropriate for MIPS processors. + * An alternative that might be better on some machines is + * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) + */ +#if defined(IEEE_8087) + defined(VAX) +#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ +((unsigned short *)a)[0] = (unsigned short)c, a++) +#else +#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ +((unsigned short *)a)[1] = (unsigned short)c, a++) +#endif + +/* #define P DBL_MANT_DIG */ +/* Ten_pmax = floor(P*log(2)/log(5)) */ +/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ +/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ +/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ + +#ifdef IEEE_Arith +#define Exp_shift 20 +#define Exp_shift1 20 +#define Exp_msk1 0x100000 +#define Exp_msk11 0x100000 +#define Exp_mask 0x7ff00000 +#define P 53 +#define Bias 1023 +#define Emin (-1022) +#define Exp_1 0x3ff00000 +#define Exp_11 0x3ff00000 +#define Ebits 11 +#define Frac_mask 0xfffff +#define Frac_mask1 0xfffff +#define Ten_pmax 22 +#define Bletch 0x10 +#define Bndry_mask 0xfffff +#define Bndry_mask1 0xfffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 1 +#define Tiny0 0 +#define Tiny1 1 +#define Quick_max 14 +#define Int_max 14 + +#ifndef Flt_Rounds +#ifdef FLT_ROUNDS +#define Flt_Rounds FLT_ROUNDS +#else +#define Flt_Rounds 1 +#endif +#endif /*Flt_Rounds*/ + +#else /* ifndef IEEE_Arith */ +#undef Sudden_Underflow +#define Sudden_Underflow +#ifdef IBM +#undef Flt_Rounds +#define Flt_Rounds 0 +#define Exp_shift 24 +#define Exp_shift1 24 +#define Exp_msk1 0x1000000 +#define Exp_msk11 0x1000000 +#define Exp_mask 0x7f000000 +#define P 14 +#define Bias 65 +#define Exp_1 0x41000000 +#define Exp_11 0x41000000 +#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ +#define Frac_mask 0xffffff +#define Frac_mask1 0xffffff +#define Bletch 4 +#define Ten_pmax 22 +#define Bndry_mask 0xefffff +#define Bndry_mask1 0xffffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 4 +#define Tiny0 0x100000 +#define Tiny1 0 +#define Quick_max 14 +#define Int_max 15 +#else /* VAX */ +#undef Flt_Rounds +#define Flt_Rounds 1 +#define Exp_shift 23 +#define Exp_shift1 7 +#define Exp_msk1 0x80 +#define Exp_msk11 0x800000 +#define Exp_mask 0x7f80 +#define P 56 +#define Bias 129 +#define Emin (-127) +#define Exp_1 0x40800000 +#define Exp_11 0x4080 +#define Ebits 8 +#define Frac_mask 0x7fffff +#define Frac_mask1 0xffff007f +#define Ten_pmax 24 +#define Bletch 2 +#define Bndry_mask 0xffff007f +#define Bndry_mask1 0xffff007f +#define LSB 0x10000 +#define Sign_bit 0x8000 +#define Log2P 1 +#define Tiny0 0x80 +#define Tiny1 0 +#define Quick_max 15 +#define Int_max 15 +#endif /* IBM, VAX */ +#endif /* IEEE_Arith */ + +#ifndef IEEE_Arith +#define ROUND_BIASED +#else +#ifdef ROUND_BIASED_without_Round_Up +#undef ROUND_BIASED +#define ROUND_BIASED +#endif +#endif + +#ifdef RND_PRODQUOT +#define rounded_product(a,b) a = rnd_prod(a, b) +#define rounded_quotient(a,b) a = rnd_quot(a, b) +#ifdef KR_headers +extern double rnd_prod(), rnd_quot(); +#else +extern double rnd_prod(double, double), rnd_quot(double, double); +#endif +#else +#define rounded_product(a,b) a *= b +#define rounded_quotient(a,b) a /= b +#endif + +#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) +#define Big1 0xffffffff + +#undef Pack_16 +#ifndef Pack_32 +#define Pack_32 +#endif + +#ifdef NO_LONG_LONG +#undef ULLong +#ifdef Just_16 +#undef Pack_32 +#define Pack_16 +/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. + * This makes some inner loops simpler and sometimes saves work + * during multiplications, but it often seems to make things slightly + * slower. Hence the default is now to store 32 bits per Long. + */ +#endif +#else /* long long available */ +#ifndef Llong +#define Llong long long +#endif +#ifndef ULLong +#define ULLong unsigned Llong +#endif +#endif /* NO_LONG_LONG */ + +#ifdef Pack_32 +#define ULbits 32 +#define kshift 5 +#define kmask 31 +#define ALL_ON 0xffffffff +#else +#define ULbits 16 +#define kshift 4 +#define kmask 15 +#define ALL_ON 0xffff +#endif + +#ifndef MULTIPLE_THREADS +#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ +#define FREE_DTOA_LOCK(n) /*nothing*/ +#else +#include "sgx_spinlock.h" +extern sgx_spinlock_t __dtoa_locks[]; +#define ACQUIRE_DTOA_LOCK(n) sgx_spin_lock(&__dtoa_locks[n]) +#define FREE_DTOA_LOCK(n) sgx_spin_unlock(&__dtoa_locks[n]) +#endif + +#define Kmax 9 + + struct +Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; + }; + + typedef struct Bigint Bigint; + +#ifdef NO_STRING_H +#ifdef DECLARE_SIZE_T +typedef unsigned int size_t; +#endif +extern void memcpy_D2A ANSI((void*, const void*, size_t)); +#define Bcopy(x,y) memcpy_D2A(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) +#else /* !NO_STRING_H */ +#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) +#endif /* NO_STRING_H */ + +#define dtoa __dtoa +#define gdtoa __gdtoa +#define freedtoa __freedtoa +#define strtodg __strtodg +#define strtorx __strtorx + +#define Balloc __Balloc_D2A +#define Bfree __Bfree_D2A +#define ULtod __ULtod_D2A +#define ULtox __ULtox_D2A +#define any_on __any_on_D2A +#define b2d __b2d_D2A +#define bigtens __bigtens_D2A +#define cmp __cmp_D2A +#define copybits __copybits_D2A +#define d2b __d2b_D2A +#define decrement __decrement_D2A +#define diff __diff_D2A +#define dtoa_result __dtoa_result_D2A +#define gethex __gethex_D2A +#define hexdig __hexdig_D2A +#define hexnan __hexnan_D2A +#define hi0bits(x) __hi0bits_D2A((ULong)(x)) +#define hi0bits_D2A __hi0bits_D2A +#define i2b __i2b_D2A +#define increment __increment_D2A +#define lo0bits __lo0bits_D2A +#define lshift __lshift_D2A +#define match __match_D2A +#define mult __mult_D2A +#define multadd __multadd_D2A +#define nrv_alloc __nrv_alloc_D2A +#define pow5mult __pow5mult_D2A +#define quorem __quorem_D2A +#define ratio __ratio_D2A +#define rshift __rshift_D2A +#define rv_alloc __rv_alloc_D2A +#define s2b __s2b_D2A +#define set_ones __set_ones_D2A +#define sum __sum_D2A +#define tens __tens_D2A +#define tinytens __tinytens_D2A +#define trailz __trailz_D2A +#define ulp __ulp_D2A + + extern char *dtoa_result; + extern CONST double bigtens[], tens[], tinytens[]; + extern unsigned char hexdig[]; + + extern Bigint *Balloc ANSI((int)); + extern void Bfree ANSI((Bigint*)); + extern void ULtod ANSI((ULong*, ULong*, Long, int)); + extern void ULtox ANSI((UShort*, ULong*, Long, int)); + extern ULong any_on ANSI((Bigint*, int)); + extern double b2d ANSI((Bigint*, int*)); + extern int cmp ANSI((Bigint*, Bigint*)); + extern void copybits ANSI((ULong*, int, Bigint*)); + extern Bigint *d2b ANSI((double, int*, int*)); + extern void decrement ANSI((Bigint*)); + extern Bigint *diff ANSI((Bigint*, Bigint*)); + extern char *dtoa ANSI((double d, int mode, int ndigits, + int *decpt, int *sign, char **rve)); + extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int)); + extern void hexdig_init_D2A(Void); + extern int hexnan ANSI((CONST char**, FPI*, ULong*)); + extern int hi0bits_D2A ANSI((ULong)); + extern Bigint *i2b ANSI((int)); + extern Bigint *increment ANSI((Bigint*)); + extern int lo0bits ANSI((ULong*)); + extern Bigint *lshift ANSI((Bigint*, int)); + extern int match ANSI((CONST char**, char*)); + extern Bigint *mult ANSI((Bigint*, Bigint*)); + extern Bigint *multadd ANSI((Bigint*, int, int)); + extern char *nrv_alloc ANSI((char*, char **, int)); + extern Bigint *pow5mult ANSI((Bigint*, int)); + extern int quorem ANSI((Bigint*, Bigint*)); + extern double ratio ANSI((Bigint*, Bigint*)); + extern void rshift ANSI((Bigint*, int)); + extern char *rv_alloc ANSI((int)); + extern Bigint *s2b ANSI((CONST char*, int, int, ULong, int)); + extern Bigint *set_ones ANSI((Bigint*, int)); + extern double strtod ANSI((const char *s00, char **se)); + extern Bigint *sum ANSI((Bigint*, Bigint*)); + extern int trailz ANSI((Bigint*)); + extern double ulp ANSI((U*)); + +#ifdef __cplusplus +} +#endif +/* + * NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to + * 20050115, they used to be hard-wired here (to 0x7ff80000 and 0, + * respectively), but now are determined by compiling and running + * qnan.c to generate gd_qnan.h, which specifies d_QNAN0 and d_QNAN1. + * Formerly gdtoaimp.h recommended supplying suitable -DNAN_WORD0=... + * and -DNAN_WORD1=... values if necessary. This should still work. + * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) + */ +#ifdef IEEE_Arith +#ifndef NO_INFNAN_CHECK +#undef INFNAN_CHECK +#define INFNAN_CHECK +#endif +#ifdef IEEE_MC68k +#define _0 0 +#define _1 1 +#ifndef NAN_WORD0 +#define NAN_WORD0 d_QNAN0 +#endif +#ifndef NAN_WORD1 +#define NAN_WORD1 d_QNAN1 +#endif +#else +#define _0 1 +#define _1 0 +#ifndef NAN_WORD0 +#define NAN_WORD0 d_QNAN1 +#endif +#ifndef NAN_WORD1 +#define NAN_WORD1 d_QNAN0 +#endif +#endif +#else +#undef INFNAN_CHECK +#endif + +#undef SI +#ifdef Sudden_Underflow +#define SI 1 +#else +#define SI 0 +#endif + +/* Disable warnings */ + +#endif /* GDTOAIMP_H_INCLUDED */ diff --git a/sdk/tlibc/gdtoa/gethex.c b/sdk/tlibc/gdtoa/gethex.c new file mode 100644 index 0000000000..7ace0fa4cd --- /dev/null +++ b/sdk/tlibc/gdtoa/gethex.c @@ -0,0 +1,360 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + +#ifdef USE_LOCALE +#include "locale.h" +#endif + + int +#ifdef KR_headers +gethex(sp, fpi, exp, bp, sign) + CONST char **sp; FPI *fpi; Long *exp; Bigint **bp; int sign; +#else +gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign) +#endif +{ + Bigint *b; + CONST unsigned char *decpt, *s0, *s, *s1; + int big, esign, havedig, irv, j, k, n, n0, nbits, up, zret; + ULong L, lostbits, *x; + Long e, e1; +#ifdef USE_LOCALE + int i; +#ifdef NO_LOCALE_CACHE + const unsigned char *decimalpoint = (unsigned char*)localeconv()->decimal_point; +#else + const unsigned char *decimalpoint; + static unsigned char *decimalpoint_cache; + if (!(s0 = decimalpoint_cache)) { + s0 = (unsigned char*)localeconv()->decimal_point; + if ((decimalpoint_cache = (char*)MALLOC(strlen(s0) + 1))) { + strlcpy(decimalpoint_cache, s0, strlen(s0) + 1); + s0 = decimalpoint_cache; + } + } + decimalpoint = s0; +#endif +#endif + + if (!hexdig['0']) + hexdig_init_D2A(); + *bp = 0; + havedig = 0; + s0 = *(CONST unsigned char **)sp + 2; + while(s0[havedig] == '0') + havedig++; + s0 += havedig; + s = s0; + decpt = 0; + zret = 0; + e = 0; + if (hexdig[*s]) + havedig++; + else { + zret = 1; +#ifdef USE_LOCALE + for(i = 0; decimalpoint[i]; ++i) { + if (s[i] != decimalpoint[i]) + goto pcheck; + } + decpt = s += i; +#else + if (*s != '.') + goto pcheck; + decpt = ++s; +#endif + if (!hexdig[*s]) + goto pcheck; + while(*s == '0') + s++; + if (hexdig[*s]) + zret = 0; + havedig = 1; + s0 = s; + } + while(hexdig[*s]) + s++; +#ifdef USE_LOCALE + if (*s == *decimalpoint && !decpt) { + for(i = 1; decimalpoint[i]; ++i) { + if (s[i] != decimalpoint[i]) + goto pcheck; + } + decpt = s += i; +#else + if (*s == '.' && !decpt) { + decpt = ++s; +#endif + while(hexdig[*s]) + s++; + }/*}*/ + if (decpt) + e = -(((Long)(s-decpt)) << 2); + pcheck: + s1 = s; + big = esign = 0; + switch(*s) { + case 'p': + case 'P': + switch(*++s) { + case '-': + esign = 1; + /* no break */ + case '+': + s++; + } + if ((n = hexdig[*s]) == 0 || n > 0x19) { + s = s1; + break; + } + e1 = n - 0x10; + while((n = hexdig[*++s]) !=0 && n <= 0x19) { + if (e1 & 0xf8000000) + big = 1; + e1 = 10*e1 + n - 0x10; + } + if (esign) + e1 = -e1; + e += e1; + } + *sp = (char*)s; + if (!havedig) + *sp = (char*)s0 - 1; + if (zret) + return STRTOG_Zero; + if (big) { + if (esign) { + switch(fpi->rounding) { + case FPI_Round_up: + if (sign) + break; + goto ret_tiny; + case FPI_Round_down: + if (!sign) + break; + goto ret_tiny; + } + goto retz; + ret_tiny: + b = Balloc(0); + if (b == NULL) + return (STRTOG_NoMemory); + b->wds = 1; + b->x[0] = 1; + goto dret; + } + switch(fpi->rounding) { + case FPI_Round_near: + goto ovfl1; + case FPI_Round_up: + if (!sign) + goto ovfl1; + goto ret_big; + case FPI_Round_down: + if (sign) + goto ovfl1; + goto ret_big; + } + ret_big: + nbits = fpi->nbits; + n0 = n = nbits >> kshift; + if (nbits & kmask) + ++n; + for(j = n, k = 0; j >>= 1; ++k); + *bp = b = Balloc(k); + if (*bp == NULL) + return (STRTOG_NoMemory); + b->wds = n; + for(j = 0; j < n0; ++j) + b->x[j] = ALL_ON; + if (n > n0) + b->x[j] = ULbits >> (ULbits - (nbits & kmask)); + *exp = fpi->emin; + return STRTOG_Normal | STRTOG_Inexlo; + } + n = s1 - s0 - 1; + for(k = 0; n > (1 << (kshift-2)) - 1; n >>= 1) + k++; + b = Balloc(k); + if (b == NULL) + return (STRTOG_NoMemory); + x = b->x; + n = 0; + L = 0; +#ifdef USE_LOCALE + for(i = 0; decimalpoint[i+1]; ++i); +#endif + while(s1 > s0) { +#ifdef USE_LOCALE + if (*--s1 == decimalpoint[i]) { + s1 -= i; + continue; + } +#else + if (*--s1 == '.') + continue; +#endif + if (n == ULbits) { + *x++ = L; + L = 0; + n = 0; + } + L |= (hexdig[*s1] & 0x0f) << n; + n += 4; + } + *x++ = L; + b->wds = n = x - b->x; + n = ULbits*n - hi0bits(L); + nbits = fpi->nbits; + lostbits = 0; + x = b->x; + if (n > nbits) { + n -= nbits; + if (any_on(b,n)) { + lostbits = 1; + k = n - 1; + if (x[k>>kshift] & 1 << (k & kmask)) { + lostbits = 2; + if (k > 0 && any_on(b,k)) + lostbits = 3; + } + } + rshift(b, n); + e += n; + } + else if (n < nbits) { + n = nbits - n; + b = lshift(b, n); + if (b == NULL) + return (STRTOG_NoMemory); + e -= n; + x = b->x; + } + if (e > fpi->emax) { + ovfl: + Bfree(b); + ovfl1: +#ifndef NO_ERRNO + errno = ERANGE; +#endif + return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; + } + irv = STRTOG_Normal; + if (e < fpi->emin) { + irv = STRTOG_Denormal; + n = fpi->emin - e; + if (n >= nbits) { + switch (fpi->rounding) { + case FPI_Round_near: + if (n == nbits && (n < 2 || any_on(b,n-1))) + goto one_bit; + break; + case FPI_Round_up: + if (!sign) + goto one_bit; + break; + case FPI_Round_down: + if (sign) { + one_bit: + x[0] = b->wds = 1; + dret: + *bp = b; + *exp = fpi->emin; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + return STRTOG_Denormal | STRTOG_Inexhi + | STRTOG_Underflow; + } + } + Bfree(b); + retz: +#ifndef NO_ERRNO + errno = ERANGE; +#endif + return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow; + } + k = n - 1; + if (lostbits) + lostbits = 1; + else if (k > 0) + lostbits = any_on(b,k); + if (x[k>>kshift] & 1 << (k & kmask)) + lostbits |= 2; + nbits -= n; + rshift(b,n); + e = fpi->emin; + } + if (lostbits) { + up = 0; + switch(fpi->rounding) { + case FPI_Round_zero: + break; + case FPI_Round_near: + if (lostbits & 2 + && (lostbits | x[0]) & 1) + up = 1; + break; + case FPI_Round_up: + up = 1 - sign; + break; + case FPI_Round_down: + up = sign; + } + if (up) { + k = b->wds; + b = increment(b); + if (b == NULL) + return (STRTOG_NoMemory); + x = b->x; + if (irv == STRTOG_Denormal) { + if (nbits == fpi->nbits - 1 + && x[nbits >> kshift] & 1 << (nbits & kmask)) + irv = STRTOG_Normal; + } + else if (b->wds > k + || ((n = nbits & kmask) !=0 + && hi0bits(x[k-1]) < 32-n)) { + rshift(b,1); + if (++e > fpi->emax) + goto ovfl; + } + irv |= STRTOG_Inexhi; + } + else + irv |= STRTOG_Inexlo; + } + *bp = b; + *exp = e; + return irv; + } diff --git a/sdk/tlibc/gdtoa/gmisc.c b/sdk/tlibc/gdtoa/gmisc.c new file mode 100644 index 0000000000..8270ef9447 --- /dev/null +++ b/sdk/tlibc/gdtoa/gmisc.c @@ -0,0 +1,86 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + void +#ifdef KR_headers +rshift(b, k) Bigint *b; int k; +#else +rshift(Bigint *b, int k) +#endif +{ + ULong *x, *x1, *xe, y; + int n; + + x = x1 = b->x; + n = k >> kshift; + if (n < b->wds) { + xe = x + b->wds; + x += n; + if (k &= kmask) { + n = ULbits - k; + y = *x++ >> k; + while(x < xe) { + *x1++ = (y | (*x << n)) & ALL_ON; + y = *x++ >> k; + } + if ((*x1 = y) !=0) + x1++; + } + else + while(x < xe) + *x1++ = *x++; + } + if ((b->wds = x1 - b->x) == 0) + b->x[0] = 0; + } + + int +#ifdef KR_headers +trailz(b) Bigint *b; +#else +trailz(Bigint *b) +#endif +{ + ULong L, *x, *xe; + int n = 0; + + x = b->x; + xe = x + b->wds; + for(n = 0; x < xe && !*x; x++) + n += ULbits; + if (x < xe) { + L = *x; + n += lo0bits(&L); + } + return n; + } diff --git a/sdk/tlibc/gdtoa/hd_init.c b/sdk/tlibc/gdtoa/hd_init.c new file mode 100644 index 0000000000..fa6e18dee8 --- /dev/null +++ b/sdk/tlibc/gdtoa/hd_init.c @@ -0,0 +1,55 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 2000 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + unsigned char hexdig[256]; + + static void +#ifdef KR_headers +htinit(h, s, inc) unsigned char *h; unsigned char *s; int inc; +#else +htinit(unsigned char *h, unsigned char *s, int inc) +#endif +{ + int i, j; + for(i = 0; (j = s[i]) !=0; i++) + h[j] = i + inc; + } + + void +hexdig_init_D2A(Void) +{ +#define USC (unsigned char *) + htinit(hexdig, USC "0123456789", 0x10); + htinit(hexdig, USC "abcdef", 0x10 + 10); + htinit(hexdig, USC "ABCDEF", 0x10 + 10); + } diff --git a/sdk/tlibc/gdtoa/hdtoa.c b/sdk/tlibc/gdtoa/hdtoa.c new file mode 100644 index 0000000000..07181a3d10 --- /dev/null +++ b/sdk/tlibc/gdtoa/hdtoa.c @@ -0,0 +1,332 @@ +/* $OpenBSD: hdtoa.c,v 1.2 2009/10/16 12:15:03 martynas Exp $ */ +/*- + * Copyright (c) 2004, 2005 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include + +#include "gdtoaimp.h" + +/* Strings values used by dtoa() */ +#define INFSTR "Infinity" +#define NANSTR "NaN" + +#define DBL_ADJ (DBL_MAX_EXP - 2 + ((DBL_MANT_DIG - 1) % 4)) +#define LDBL_ADJ (LDBL_MAX_EXP - 2 + ((LDBL_MANT_DIG - 1) % 4)) + +/* + * Round up the given digit string. If the digit string is fff...f, + * this procedure sets it to 100...0 and returns 1 to indicate that + * the exponent needs to be bumped. Otherwise, 0 is returned. + */ +static int +roundup(char *s0, int ndigits) +{ + char *s; + + for (s = s0 + ndigits - 1; *s == 0xf; s--) { + if (s == s0) { + *s = 1; + return (1); + } + *s = 0; + } + ++*s; + return (0); +} + +/* + * Round the given digit string to ndigits digits according to the + * current rounding mode. Note that this could produce a string whose + * value is not representable in the corresponding floating-point + * type. The exponent pointed to by decpt is adjusted if necessary. + */ +static void +dorounding(char *s0, int ndigits, int sign, int *decpt) +{ + int adjust = 0; /* do we need to adjust the exponent? */ + + switch (FLT_ROUNDS) { + case 0: /* toward zero */ + default: /* implementation-defined */ + break; + case 1: /* to nearest, halfway rounds to even */ + if ((s0[ndigits] > 8) || + (s0[ndigits] == 8 && s0[ndigits + 1] & 1)) + adjust = roundup(s0, ndigits); + break; + case 2: /* toward +inf */ + if (sign == 0) + adjust = roundup(s0, ndigits); + break; + case 3: /* toward -inf */ + if (sign != 0) + adjust = roundup(s0, ndigits); + break; + } + + if (adjust) + *decpt += 4; +} + +/* + * This procedure converts a double-precision number in IEEE format + * into a string of hexadecimal digits and an exponent of 2. Its + * behavior is bug-for-bug compatible with dtoa() in mode 2, with the + * following exceptions: + * + * - An ndigits < 0 causes it to use as many digits as necessary to + * represent the number exactly. + * - The additional xdigs argument should point to either the string + * "0123456789ABCDEF" or the string "0123456789abcdef", depending on + * which case is desired. + * - This routine does not repeat dtoa's mistake of setting decpt + * to 9999 in the case of an infinity or NaN. INT_MAX is used + * for this purpose instead. + * + * Note that the C99 standard does not specify what the leading digit + * should be for non-zero numbers. For instance, 0x1.3p3 is the same + * as 0x2.6p2 is the same as 0x4.cp3. This implementation chooses the + * first digit so that subsequent digits are aligned on nibble + * boundaries (before rounding). + * + * Inputs: d, xdigs, ndigits + * Outputs: decpt, sign, rve + */ +char * +__hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, + char **rve) +{ + static const int sigfigs = (DBL_MANT_DIG + 3) / 4; + struct ieee_double *p = (struct ieee_double *)&d; + char *s, *s0; + int bufsize; + + *sign = p->dbl_sign; + + switch (fpclassify(d)) { + case FP_NORMAL: + *decpt = p->dbl_exp - DBL_ADJ; + break; + case FP_ZERO: + *decpt = 1; + return (nrv_alloc("0", rve, 1)); + case FP_SUBNORMAL: + d *= 5.363123171977039e+154; /* = 0x1p514 */ + *decpt = p->dbl_exp - (514 + DBL_ADJ); + break; + case FP_INFINITE: + *decpt = INT_MAX; + return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1)); + case FP_NAN: + *decpt = INT_MAX; + return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1)); + default: + abort(); + } + + /* FP_NORMAL or FP_SUBNORMAL */ + + if (ndigits == 0) /* dtoa() compatibility */ + ndigits = 1; + + /* + * For simplicity, we generate all the digits even if the + * caller has requested fewer. + */ + bufsize = (sigfigs > ndigits) ? sigfigs : ndigits; + s0 = rv_alloc(bufsize); + if (s0 == NULL) + return (NULL); + + /* + * We work from right to left, first adding any requested zero + * padding, then the least significant portion of the + * mantissa, followed by the most significant. The buffer is + * filled with the byte values 0x0 through 0xf, which are + * converted to xdigs[0x0] through xdigs[0xf] after the + * rounding phase. + */ + for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--) + *s = 0; + for (; s > s0 + sigfigs - (DBL_FRACLBITS / 4) - 1 && s > s0; s--) { + *s = p->dbl_fracl & 0xf; + p->dbl_fracl >>= 4; + } + for (; s > s0; s--) { + *s = p->dbl_frach & 0xf; + p->dbl_frach >>= 4; + } + + /* + * At this point, we have snarfed all the bits in the + * mantissa, with the possible exception of the highest-order + * (partial) nibble, which is dealt with by the next + * statement. We also tack on the implicit normalization bit. + */ + *s = p->dbl_frach | (1U << ((DBL_MANT_DIG - 1) % 4)); + + /* If ndigits < 0, we are expected to auto-size the precision. */ + if (ndigits < 0) { + for (ndigits = sigfigs; s0[ndigits - 1] == 0; ndigits--) + ; + } + + if (sigfigs > ndigits && s0[ndigits] != 0) + dorounding(s0, ndigits, p->dbl_sign, decpt); + + s = s0 + ndigits; + if (rve != NULL) + *rve = s; + *s-- = '\0'; + for (; s >= s0; s--) + *s = xdigs[(unsigned int)*s]; + + return (s0); +} + +#if (LDBL_MANT_DIG > DBL_MANT_DIG) + +/* + * This is the long double version of __hdtoa(). + */ +char * +__hldtoa(long double e, const char *xdigs, int ndigits, int *decpt, int *sign, + char **rve) +{ + static const int sigfigs = (LDBL_MANT_DIG + 3) / 4; + struct ieee_ext *p = (struct ieee_ext *)&e; + char *s, *s0; + int bufsize; + + *sign = p->ext_sign; + + switch (fpclassify(e)) { + case FP_NORMAL: + *decpt = p->ext_exp - LDBL_ADJ; + break; + case FP_ZERO: + *decpt = 1; + return (nrv_alloc("0", rve, 1)); + case FP_SUBNORMAL: + e *= 0x1p514L; + *decpt = p->ext_exp - (514 + LDBL_ADJ); + break; + case FP_INFINITE: + *decpt = INT_MAX; + return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1)); + case FP_NAN: + *decpt = INT_MAX; + return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1)); + default: + abort(); + } + + /* FP_NORMAL or FP_SUBNORMAL */ + + if (ndigits == 0) /* dtoa() compatibility */ + ndigits = 1; + + /* + * For simplicity, we generate all the digits even if the + * caller has requested fewer. + */ + bufsize = (sigfigs > ndigits) ? sigfigs : ndigits; + s0 = rv_alloc(bufsize); + if (s0 == NULL) + return (NULL); + + /* + * We work from right to left, first adding any requested zero + * padding, then the least significant portion of the + * mantissa, followed by the most significant. The buffer is + * filled with the byte values 0x0 through 0xf, which are + * converted to xdigs[0x0] through xdigs[0xf] after the + * rounding phase. + */ + for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--) + *s = 0; + for (; s > s0 + sigfigs - (EXT_FRACLBITS / 4) - 1 && s > s0; s--) { + *s = p->ext_fracl & 0xf; + p->ext_fracl >>= 4; + } +#ifdef EXT_FRACHMBITS + for (; s > s0; s--) { + *s = p->ext_frachm & 0xf; + p->ext_frachm >>= 4; + } +#endif +#ifdef EXT_FRACLMBITS + for (; s > s0; s--) { + *s = p->ext_fraclm & 0xf; + p->ext_fraclm >>= 4; + } +#endif + for (; s > s0; s--) { + *s = p->ext_frach & 0xf; + p->ext_frach >>= 4; + } + + /* + * At this point, we have snarfed all the bits in the + * mantissa, with the possible exception of the highest-order + * (partial) nibble, which is dealt with by the next + * statement. We also tack on the implicit normalization bit. + */ + *s = p->ext_frach | (1U << ((LDBL_MANT_DIG - 1) % 4)); + + /* If ndigits < 0, we are expected to auto-size the precision. */ + if (ndigits < 0) { + for (ndigits = sigfigs; s0[ndigits - 1] == 0; ndigits--) + ; + } + + if (sigfigs > ndigits && s0[ndigits] != 0) + dorounding(s0, ndigits, p->ext_sign, decpt); + + s = s0 + ndigits; + if (rve != NULL) + *rve = s; + *s-- = '\0'; + for (; s >= s0; s--) + *s = xdigs[(unsigned int)*s]; + + return (s0); +} + +#else /* (LDBL_MANT_DIG == DBL_MANT_DIG) */ + +char * +__hldtoa(long double e, const char *xdigs, int ndigits, int *decpt, int *sign, + char **rve) +{ + return (__hdtoa((double)e, xdigs, ndigits, decpt, sign, rve)); +} + +#endif /* (LDBL_MANT_DIG == DBL_MANT_DIG) */ diff --git a/sdk/tlibc/gdtoa/hexnan.c b/sdk/tlibc/gdtoa/hexnan.c new file mode 100644 index 0000000000..a443721f52 --- /dev/null +++ b/sdk/tlibc/gdtoa/hexnan.c @@ -0,0 +1,150 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 2000 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + static void +#ifdef KR_headers +L_shift(x, x1, i) ULong *x; ULong *x1; int i; +#else +L_shift(ULong *x, ULong *x1, int i) +#endif +{ + int j; + + i = 8 - i; + i <<= 2; + j = ULbits - i; + do { + *x |= x[1] << j; + x[1] >>= i; + } while(++x < x1); + } + + int +#ifdef KR_headers +hexnan(sp, fpi, x0) + CONST char **sp; FPI *fpi; ULong *x0; +#else +hexnan( CONST char **sp, FPI *fpi, ULong *x0) +#endif +{ + ULong c, h, *x, *x1, *xe; + CONST char *s; + int havedig, hd0, i, nbits; + + if (!hexdig['0']) + hexdig_init_D2A(); + nbits = fpi->nbits; + x = x0 + (nbits >> kshift); + if (nbits & kmask) + x++; + *--x = 0; + x1 = xe = x; + havedig = hd0 = i = 0; + s = *sp; + /* allow optional initial 0x or 0X */ + while((c = *(CONST unsigned char*)(s+1)) && c <= ' ') + ++s; + if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X') + && *(CONST unsigned char*)(s+3) > ' ') + s += 2; + while((c = *(CONST unsigned char*)++s)) { + if (!(h = hexdig[c])) { + if (c <= ' ') { + if (hd0 < havedig) { + if (x < x1 && i < 8) + L_shift(x, x1, i); + if (x <= x0) { + i = 8; + continue; + } + hd0 = havedig; + *--x = 0; + x1 = x; + i = 0; + } + while(*(CONST unsigned char*)(s+1) <= ' ') + ++s; + if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X') + && *(CONST unsigned char*)(s+3) > ' ') + s += 2; + continue; + } + if (/*(*/ c == ')' && havedig) { + *sp = s + 1; + break; + } +#ifndef GDTOA_NON_PEDANTIC_NANCHECK + do { + if (/*(*/ c == ')') { + *sp = s + 1; + break; + } + } while((c = *++s)); +#endif + return STRTOG_NaN; + } + havedig++; + if (++i > 8) { + if (x <= x0) + continue; + i = 1; + *--x = 0; + } + *x = (*x << 4) | (h & 0xf); + } + if (!havedig) + return STRTOG_NaN; + if (x < x1 && i < 8) + L_shift(x, x1, i); + if (x > x0) { + x1 = x0; + do *x1++ = *x++; + while(x <= xe); + do *x1++ = 0; + while(x1 <= xe); + } + else { + /* truncate high-order word if necessary */ + if ( (i = nbits & (ULbits-1)) !=0) + *xe &= ((ULong)0xffffffff) >> (ULbits - i); + } + for(x1 = xe;; --x1) { + if (*x1 != 0) + break; + if (x1 == x0) { + *x1 = 1; + break; + } + } + return STRTOG_NaNbits; + } diff --git a/sdk/tlibc/gdtoa/ldtoa.c b/sdk/tlibc/gdtoa/ldtoa.c new file mode 100644 index 0000000000..67d920587e --- /dev/null +++ b/sdk/tlibc/gdtoa/ldtoa.c @@ -0,0 +1,124 @@ +/* $OpenBSD: ldtoa.c,v 1.1 2008/09/07 20:36:08 martynas Exp $ */ +/*- + * Copyright (c) 2003 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#ifndef __vax__ +#include +#endif /* !__vax__ */ +#include +#include +#include +#include +#include +#include "gdtoaimp.h" + +#if (LDBL_MANT_DIG > DBL_MANT_DIG) + +/* + * ldtoa() is a wrapper for gdtoa() that makes it smell like dtoa(), + * except that the floating point argument is passed by reference. + * When dtoa() is passed a NaN or infinity, it sets expt to 9999. + * However, a long double could have a valid exponent of 9999, so we + * use INT_MAX in ldtoa() instead. + */ +char * +__ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign, + char **rve) +{ + FPI fpi = { + LDBL_MANT_DIG, /* nbits */ + LDBL_MIN_EXP - LDBL_MANT_DIG, /* emin */ + LDBL_MAX_EXP - LDBL_MANT_DIG, /* emax */ + FLT_ROUNDS, /* rounding */ +#ifdef Sudden_Underflow /* unused, but correct anyway */ + 1 +#else + 0 +#endif + }; + int be, kind; + char *ret; + struct ieee_ext *p = (struct ieee_ext *)ld; + uint32_t bits[(LDBL_MANT_DIG + 31) / 32]; + void *vbits = bits; + + /* + * gdtoa doesn't know anything about the sign of the number, so + * if the number is negative, we need to swap rounding modes of + * 2 (upwards) and 3 (downwards). + */ + *sign = p->ext_sign; + fpi.rounding ^= (fpi.rounding >> 1) & p->ext_sign; + + be = p->ext_exp - (LDBL_MAX_EXP - 1) - (LDBL_MANT_DIG - 1); + EXT_TO_ARRAY32(p, bits); + + switch (fpclassify(*ld)) { + case FP_NORMAL: + kind = STRTOG_Normal; +#ifdef EXT_IMPLICIT_NBIT + bits[LDBL_MANT_DIG / 32] |= 1 << ((LDBL_MANT_DIG - 1) % 32); +#endif /* EXT_IMPLICIT_NBIT */ + break; + case FP_ZERO: + kind = STRTOG_Zero; + break; + case FP_SUBNORMAL: + kind = STRTOG_Denormal; + be++; + break; + case FP_INFINITE: + kind = STRTOG_Infinite; + break; + case FP_NAN: + kind = STRTOG_NaN; + break; + default: + abort(); + } + + ret = gdtoa(&fpi, be, vbits, &kind, mode, ndigits, decpt, rve); + if (*decpt == -32768) + *decpt = INT_MAX; + return ret; +} + +#else /* (LDBL_MANT_DIG == DBL_MANT_DIG) */ + +char * +__ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign, + char **rve) +{ + char *ret; + + ret = dtoa((double)*ld, mode, ndigits, decpt, sign, rve); + if (*decpt == 9999) + *decpt = INT_MAX; + return ret; +} + +#endif /* (LDBL_MANT_DIG == DBL_MANT_DIG) */ diff --git a/sdk/tlibc/gdtoa/locks.c b/sdk/tlibc/gdtoa/locks.c new file mode 100644 index 0000000000..c59a620ab1 --- /dev/null +++ b/sdk/tlibc/gdtoa/locks.c @@ -0,0 +1,7 @@ +/* $OpenBSD: locks.c,v 1.1 2008/09/07 20:36:08 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +sgx_spinlock_t __dtoa_locks[] = { SGX_SPINLOCK_INITIALIZER, SGX_SPINLOCK_INITIALIZER }; diff --git a/sdk/tlibc/gdtoa/misc.c b/sdk/tlibc/gdtoa/misc.c new file mode 100644 index 0000000000..364de38a0d --- /dev/null +++ b/sdk/tlibc/gdtoa/misc.c @@ -0,0 +1,895 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 1999 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + static Bigint *freelist[Kmax+1]; +#ifndef Omit_Private_Memory +#ifndef PRIVATE_MEM +#define PRIVATE_MEM 2304 +#endif +#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) +static double private_mem[PRIVATE_mem], *pmem_next = private_mem; +#endif + + Bigint * +Balloc +#ifdef KR_headers + (k) int k; +#else + (int k) +#endif +{ + int x; + Bigint *rv; +#ifndef Omit_Private_Memory + unsigned int len; +#endif + + ACQUIRE_DTOA_LOCK(0); + /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ + /* but this case seems very unlikely. */ + if (k <= Kmax && (rv = freelist[k]) !=0) { + freelist[k] = rv->next; + } + else { + x = 1 << k; +#ifdef Omit_Private_Memory + rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); + if (rv == NULL) + return (NULL); +#else + len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) + /sizeof(double); + if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { + rv = (Bigint*)pmem_next; + pmem_next += len; + } + else { + rv = (Bigint*)MALLOC(len*sizeof(double)); + if (rv == NULL) + return (NULL); + } +#endif + rv->k = k; + rv->maxwds = x; + } + FREE_DTOA_LOCK(0); + rv->sign = rv->wds = 0; + return rv; + } + + void +Bfree +#ifdef KR_headers + (v) Bigint *v; +#else + (Bigint *v) +#endif +{ + if (v) { + if (v->k > Kmax) +#ifdef FREE + FREE((void*)v); +#else + free((void*)v); +#endif + else { + ACQUIRE_DTOA_LOCK(0); + v->next = freelist[v->k]; + freelist[v->k] = v; + FREE_DTOA_LOCK(0); + } + } + } + + int +lo0bits +#ifdef KR_headers + (y) ULong *y; +#else + (ULong *y) +#endif +{ + int k; + ULong x = *y; + + if (x & 7) { + if (x & 1) + return 0; + if (x & 2) { + *y = x >> 1; + return 1; + } + *y = x >> 2; + return 2; + } + k = 0; + if (!(x & 0xffff)) { + k = 16; + x >>= 16; + } + if (!(x & 0xff)) { + k += 8; + x >>= 8; + } + if (!(x & 0xf)) { + k += 4; + x >>= 4; + } + if (!(x & 0x3)) { + k += 2; + x >>= 2; + } + if (!(x & 1)) { + k++; + x >>= 1; + if (!x) + return 32; + } + *y = x; + return k; + } + + Bigint * +multadd +#ifdef KR_headers + (b, m, a) Bigint *b; int m, a; +#else + (Bigint *b, int m, int a) /* multiply by m and add a */ +#endif +{ + int i, wds; +#ifdef ULLong + ULong *x; + ULLong carry, y; +#else + ULong carry, *x, y; +#ifdef Pack_32 + ULong xi, z; +#endif +#endif + Bigint *b1; + + wds = b->wds; + x = b->x; + i = 0; + carry = a; + do { +#ifdef ULLong + y = *x * (ULLong)m + carry; + carry = y >> 32; + *x++ = y & 0xffffffffUL; +#else +#ifdef Pack_32 + xi = *x; + y = (xi & 0xffff) * m + carry; + z = (xi >> 16) * m + (y >> 16); + carry = z >> 16; + *x++ = (z << 16) + (y & 0xffff); +#else + y = *x * m + carry; + carry = y >> 16; + *x++ = y & 0xffff; +#endif +#endif + } + while(++i < wds); + if (carry) { + if (wds >= b->maxwds) { + b1 = Balloc(b->k+1); + if (b1 == NULL) + return (NULL); + Bcopy(b1, b); + Bfree(b); + b = b1; + } + b->x[wds++] = carry; + b->wds = wds; + } + return b; + } + + int +hi0bits_D2A +#ifdef KR_headers + (x) ULong x; +#else + (ULong x) +#endif +{ + int k = 0; + + if (!(x & 0xffff0000)) { + k = 16; + x <<= 16; + } + if (!(x & 0xff000000)) { + k += 8; + x <<= 8; + } + if (!(x & 0xf0000000)) { + k += 4; + x <<= 4; + } + if (!(x & 0xc0000000)) { + k += 2; + x <<= 2; + } + if (!(x & 0x80000000)) { + k++; + if (!(x & 0x40000000)) + return 32; + } + return k; + } + + Bigint * +i2b +#ifdef KR_headers + (i) int i; +#else + (int i) +#endif +{ + Bigint *b; + + b = Balloc(1); + if (b == NULL) + return (NULL); + b->x[0] = i; + b->wds = 1; + return b; + } + + Bigint * +mult +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + Bigint *c; + int k, wa, wb, wc; + ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; + ULong y; +#ifdef ULLong + ULLong carry, z; +#else + ULong carry, z; +#ifdef Pack_32 + ULong z2; +#endif +#endif + + if (a->wds < b->wds) { + c = a; + a = b; + b = c; + } + k = a->k; + wa = a->wds; + wb = b->wds; + wc = wa + wb; + if (wc > a->maxwds) + k++; + c = Balloc(k); + if (c == NULL) + return (NULL); + for(x = c->x, xa = x + wc; x < xa; x++) + *x = 0; + xa = a->x; + xae = xa + wa; + xb = b->x; + xbe = xb + wb; + xc0 = c->x; +#ifdef ULLong + for(; xb < xbe; xc0++) { + if ( (y = *xb++) !=0) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * (ULLong)y + *xc + carry; + carry = z >> 32; + *xc++ = z & 0xffffffffUL; + } + while(x < xae); + *xc = carry; + } + } +#else +#ifdef Pack_32 + for(; xb < xbe; xb++, xc0++) { + if ( (y = *xb & 0xffff) !=0) { + x = xa; + xc = xc0; + carry = 0; + do { + z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; + carry = z >> 16; + z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; + carry = z2 >> 16; + Storeinc(xc, z2, z); + } + while(x < xae); + *xc = carry; + } + if ( (y = *xb >> 16) !=0) { + x = xa; + xc = xc0; + carry = 0; + z2 = *xc; + do { + z = (*x & 0xffff) * y + (*xc >> 16) + carry; + carry = z >> 16; + Storeinc(xc, z, z2); + z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; + carry = z2 >> 16; + } + while(x < xae); + *xc = z2; + } + } +#else + for(; xb < xbe; xc0++) { + if ( (y = *xb++) !=0) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * y + *xc + carry; + carry = z >> 16; + *xc++ = z & 0xffff; + } + while(x < xae); + *xc = carry; + } + } +#endif +#endif + for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; + c->wds = wc; + return c; + } + + static Bigint *p5s; + + Bigint * +pow5mult +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + Bigint *b1, *p5, *p51; + int i; + static int p05[3] = { 5, 25, 125 }; + + if ( (i = k & 3) !=0) { + b = multadd(b, p05[i-1], 0); + if (b == NULL) + return (NULL); + } + + if (!(k >>= 2)) + return b; + if ((p5 = p5s) == 0) { + /* first time */ +#ifdef MULTIPLE_THREADS + ACQUIRE_DTOA_LOCK(1); + if (!(p5 = p5s)) { + p5 = p5s = i2b(625); + if (p5 == NULL) + return (NULL); + p5->next = 0; + } + FREE_DTOA_LOCK(1); +#else + p5 = p5s = i2b(625); + if (p5 == NULL) + return (NULL); + p5->next = 0; +#endif + } + for(;;) { + if (k & 1) { + b1 = mult(b, p5); + if (b1 == NULL) + return (NULL); + Bfree(b); + b = b1; + } + if (!(k >>= 1)) + break; + if ((p51 = p5->next) == 0) { +#ifdef MULTIPLE_THREADS + ACQUIRE_DTOA_LOCK(1); + if (!(p51 = p5->next)) { + p51 = p5->next = mult(p5,p5); + if (p51 == NULL) + return (NULL); + p51->next = 0; + } + FREE_DTOA_LOCK(1); +#else + p51 = p5->next = mult(p5,p5); + if (p51 == NULL) + return (NULL); + p51->next = 0; +#endif + } + p5 = p51; + } + return b; + } + + Bigint * +lshift +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + int i, k1, n, n1; + Bigint *b1; + ULong *x, *x1, *xe, z; + + n = k >> kshift; + k1 = b->k; + n1 = n + b->wds + 1; + for(i = b->maxwds; n1 > i; i <<= 1) + k1++; + b1 = Balloc(k1); + if (b1 == NULL) + return (NULL); + x1 = b1->x; + for(i = 0; i < n; i++) + *x1++ = 0; + x = b->x; + xe = x + b->wds; + if (k &= kmask) { +#ifdef Pack_32 + k1 = 32 - k; + z = 0; + do { + *x1++ = *x << k | z; + z = *x++ >> k1; + } + while(x < xe); + if ((*x1 = z) !=0) + ++n1; +#else + k1 = 16 - k; + z = 0; + do { + *x1++ = *x << k & 0xffff | z; + z = *x++ >> k1; + } + while(x < xe); + if (*x1 = z) + ++n1; +#endif + } + else do + *x1++ = *x++; + while(x < xe); + b1->wds = n1 - 1; + Bfree(b); + return b1; + } + + int +cmp +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + ULong *xa, *xa0, *xb, *xb0; + int i, j; + + i = a->wds; + j = b->wds; +#ifdef DEBUG + if (i > 1 && !a->x[i-1]) + Bug("cmp called with a->x[a->wds-1] == 0"); + if (j > 1 && !b->x[j-1]) + Bug("cmp called with b->x[b->wds-1] == 0"); +#endif + if (i -= j) + return i; + xa0 = a->x; + xa = xa0 + j; + xb0 = b->x; + xb = xb0 + j; + for(;;) { + if (*--xa != *--xb) + return *xa < *xb ? -1 : 1; + if (xa <= xa0) + break; + } + return 0; + } + + Bigint * +diff +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + Bigint *c; + int i, wa, wb; + ULong *xa, *xae, *xb, *xbe, *xc; +#ifdef ULLong + ULLong borrow, y; +#else + ULong borrow, y; +#ifdef Pack_32 + ULong z; +#endif +#endif + + i = cmp(a,b); + if (!i) { + c = Balloc(0); + if (c == NULL) + return (NULL); + c->wds = 1; + c->x[0] = 0; + return c; + } + if (i < 0) { + c = a; + a = b; + b = c; + i = 1; + } + else + i = 0; + c = Balloc(a->k); + if (c == NULL) + return (NULL); + c->sign = i; + wa = a->wds; + xa = a->x; + xae = xa + wa; + wb = b->wds; + xb = b->x; + xbe = xb + wb; + xc = c->x; + borrow = 0; +#ifdef ULLong + do { + y = (ULLong)*xa++ - *xb++ - borrow; + borrow = y >> 32 & 1UL; + *xc++ = y & 0xffffffffUL; + } + while(xb < xbe); + while(xa < xae) { + y = *xa++ - borrow; + borrow = y >> 32 & 1UL; + *xc++ = y & 0xffffffffUL; + } +#else +#ifdef Pack_32 + do { + y = (*xa & 0xffff) - (*xb & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - (*xb++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } + while(xb < xbe); + while(xa < xae) { + y = (*xa & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } +#else + do { + y = *xa++ - *xb++ - borrow; + borrow = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } + while(xb < xbe); + while(xa < xae) { + y = *xa++ - borrow; + borrow = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } +#endif +#endif + while(!*--xc) + wa--; + c->wds = wa; + return c; + } + + double +b2d +#ifdef KR_headers + (a, e) Bigint *a; int *e; +#else + (Bigint *a, int *e) +#endif +{ + ULong *xa, *xa0, w, y, z; + int k; + U d; +#ifdef VAX + ULong d0, d1; +#else +#define d0 word0(&d) +#define d1 word1(&d) +#endif + + xa0 = a->x; + xa = xa0 + a->wds; + y = *--xa; +#ifdef DEBUG + if (!y) Bug("zero y in b2d"); +#endif + k = hi0bits(y); + *e = 32 - k; +#ifdef Pack_32 + if (k < Ebits) { + d0 = Exp_1 | y >> (Ebits - k); + w = xa > xa0 ? *--xa : 0; + d1 = y << ((32-Ebits) + k) | w >> (Ebits - k); + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + d0 = Exp_1 | y << k | z >> (32 - k); + y = xa > xa0 ? *--xa : 0; + d1 = z << k | y >> (32 - k); + } + else { + d0 = Exp_1 | y; + d1 = z; + } +#else + if (k < Ebits + 16) { + z = xa > xa0 ? *--xa : 0; + d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; + w = xa > xa0 ? *--xa : 0; + y = xa > xa0 ? *--xa : 0; + d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + w = xa > xa0 ? *--xa : 0; + k -= Ebits + 16; + d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; + y = xa > xa0 ? *--xa : 0; + d1 = w << k + 16 | y << k; +#endif + ret_d: +#ifdef VAX + word0(&d) = d0 >> 16 | d0 << 16; + word1(&d) = d1 >> 16 | d1 << 16; +#endif + return dval(&d); + } +#undef d0 +#undef d1 + + Bigint * +d2b +#ifdef KR_headers + (dd, e, bits) double dd; int *e, *bits; +#else + (double dd, int *e, int *bits) +#endif +{ + Bigint *b; + U d; +#ifndef Sudden_Underflow + int i; +#endif + int de, k; + ULong *x, y, z; +#ifdef VAX + ULong d0, d1; +#else +#define d0 word0(&d) +#define d1 word1(&d) +#endif + d.d = dd; +#ifdef VAX + d0 = word0(&d) >> 16 | word0(&d) << 16; + d1 = word1(&d) >> 16 | word1(&d) << 16; +#endif + +#ifdef Pack_32 + b = Balloc(1); +#else + b = Balloc(2); +#endif + if (b == NULL) + return (NULL); + x = b->x; + + z = d0 & Frac_mask; + d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ +#ifdef Sudden_Underflow + de = (int)(d0 >> Exp_shift); +#ifndef IBM + z |= Exp_msk11; +#endif +#else + if ( (de = (int)(d0 >> Exp_shift)) !=0) + z |= Exp_msk1; +#endif +#ifdef Pack_32 + if ( (y = d1) !=0) { + if ( (k = lo0bits(&y)) !=0) { + x[0] = y | z << (32 - k); + z >>= k; + } + else + x[0] = y; +#ifndef Sudden_Underflow + i = +#endif + b->wds = (x[1] = z) !=0 ? 2 : 1; + } + else { + k = lo0bits(&z); + x[0] = z; +#ifndef Sudden_Underflow + i = +#endif + b->wds = 1; + k += 32; + } +#else + if ( (y = d1) !=0) { + if ( (k = lo0bits(&y)) !=0) + if (k >= 16) { + x[0] = y | z << 32 - k & 0xffff; + x[1] = z >> k - 16 & 0xffff; + x[2] = z >> k; + i = 2; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16 | z << 16 - k & 0xffff; + x[2] = z >> k & 0xffff; + x[3] = z >> k+16; + i = 3; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16; + x[2] = z & 0xffff; + x[3] = z >> 16; + i = 3; + } + } + else { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + if (k >= 16) { + x[0] = z; + i = 0; + } + else { + x[0] = z & 0xffff; + x[1] = z >> 16; + i = 1; + } + k += 32; + } + while(!x[i]) + --i; + b->wds = i + 1; +#endif +#ifndef Sudden_Underflow + if (de) { +#endif +#ifdef IBM + *e = (de - Bias - (P-1) << 2) + k; + *bits = 4*P + 8 - k - hi0bits(word0(&d) & Frac_mask); +#else + *e = de - Bias - (P-1) + k; + *bits = P - k; +#endif +#ifndef Sudden_Underflow + } + else { + *e = de - Bias - (P-1) + 1 + k; +#ifdef Pack_32 + *bits = 32*i - hi0bits(x[i-1]); +#else + *bits = (i+2)*16 - hi0bits(x[i]); +#endif + } +#endif + return b; + } +#undef d0 +#undef d1 + + CONST double +#ifdef IEEE_Arith +bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; +CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 + }; +#else +#ifdef IBM +bigtens[] = { 1e16, 1e32, 1e64 }; +CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 }; +#else +bigtens[] = { 1e16, 1e32 }; +CONST double tinytens[] = { 1e-16, 1e-32 }; +#endif +#endif + + CONST double +tens[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22 +#ifdef VAX + , 1e23, 1e24 +#endif + }; + +#ifdef NO_STRING_H + + Char * +#ifdef KR_headers +memcpy_D2A(a, b, len) Char *a; Char *b; size_t len; +#else +memcpy_D2A(void *a1, void *b1, size_t len) +#endif +{ + char *a = (char*)a1, *ae = a + len; + char *b = (char*)b1, *a0 = a; + while(a < ae) + *a++ = *b++; + return a0; + } + +#endif /* NO_STRING_H */ diff --git a/sdk/tlibc/gdtoa/smisc.c b/sdk/tlibc/gdtoa/smisc.c new file mode 100644 index 0000000000..d063a38db2 --- /dev/null +++ b/sdk/tlibc/gdtoa/smisc.c @@ -0,0 +1,201 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 1999 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + Bigint * +s2b +#ifdef KR_headers + (s, nd0, nd, y9, dplen) CONST char *s; int dplen, nd0, nd; ULong y9; +#else + (CONST char *s, int nd0, int nd, ULong y9, int dplen) +#endif +{ + Bigint *b; + int i, k; + Long x, y; + + x = (nd + 8) / 9; + for(k = 0, y = 1; x > y; y <<= 1, k++) ; +#ifdef Pack_32 + b = Balloc(k); + if (b == NULL) + return (NULL); + b->x[0] = y9; + b->wds = 1; +#else + b = Balloc(k+1); + if (b == NULL) + return (NULL); + b->x[0] = y9 & 0xffff; + b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; +#endif + + i = 9; + if (9 < nd0) { + s += 9; + do { + b = multadd(b, 10, *s++ - '0'); + if (b == NULL) + return (NULL); + } while(++i < nd0); + s += dplen; + } + else + s += dplen + 9; + for(; i < nd; i++) { + b = multadd(b, 10, *s++ - '0'); + if (b == NULL) + return (NULL); + } + return b; + } + + double +ratio +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + U da, db; + int k, ka, kb; + + dval(&da) = b2d(a, &ka); + dval(&db) = b2d(b, &kb); + k = ka - kb + ULbits*(a->wds - b->wds); +#ifdef IBM + if (k > 0) { + word0(&da) += (k >> 2)*Exp_msk1; + if (k &= 3) + dval(&da) *= 1 << k; + } + else { + k = -k; + word0(&db) += (k >> 2)*Exp_msk1; + if (k &= 3) + dval(&db) *= 1 << k; + } +#else + if (k > 0) + word0(&da) += k*Exp_msk1; + else { + k = -k; + word0(&db) += k*Exp_msk1; + } +#endif + return dval(&da) / dval(&db); + } + +#ifdef INFNAN_CHECK + + int +match +#ifdef KR_headers + (sp, t) char **sp, *t; +#else + (CONST char **sp, char *t) +#endif +{ + int c, d; + CONST char *s = *sp; + + while( (d = *t++) !=0) { + if ((c = *++s) >= 'A' && c <= 'Z') + c += 'a' - 'A'; + if (c != d) + return 0; + } + *sp = s + 1; + return 1; + } +#endif /* INFNAN_CHECK */ + + void +#ifdef KR_headers +copybits(c, n, b) ULong *c; int n; Bigint *b; +#else +copybits(ULong *c, int n, Bigint *b) +#endif +{ + ULong *ce, *x, *xe; +#ifdef Pack_16 + int nw, nw1; +#endif + + ce = c + ((n-1) >> kshift) + 1; + x = b->x; +#ifdef Pack_32 + xe = x + b->wds; + while(x < xe) + *c++ = *x++; +#else + nw = b->wds; + nw1 = nw & 1; + for(xe = x + (nw - nw1); x < xe; x += 2) + Storeinc(c, x[1], x[0]); + if (nw1) + *c++ = *x; +#endif + while(c < ce) + *c++ = 0; + } + + ULong +#ifdef KR_headers +any_on(b, k) Bigint *b; int k; +#else +any_on(Bigint *b, int k) +#endif +{ + int n, nwds; + ULong *x, *x0, x1, x2; + + x = b->x; + nwds = b->wds; + n = k >> kshift; + if (n > nwds) + n = nwds; + else if (n < nwds && (k &= kmask)) { + x1 = x2 = x[n]; + x1 >>= k; + x1 <<= k; + if (x1 != x2) + return 1; + } + x0 = x; + x += n; + while(x > x0) + if (*--x) + return 1; + return 0; + } diff --git a/sdk/tlibc/gdtoa/strtod.c b/sdk/tlibc/gdtoa/strtod.c new file mode 100644 index 0000000000..ded47d8624 --- /dev/null +++ b/sdk/tlibc/gdtoa/strtod.c @@ -0,0 +1,1105 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998-2001 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" +#ifndef NO_FENV_H +#include +#endif + +#ifdef USE_LOCALE +#include "locale.h" +#endif + +#ifdef IEEE_Arith +#ifndef NO_IEEE_Scale +#define Avoid_Underflow +#undef tinytens +/* The factor of 2^106 in tinytens[4] helps us avoid setting the underflow */ +/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ +static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, + 9007199254740992.*9007199254740992.e-256 + }; +#endif +#endif + +#ifdef Honor_FLT_ROUNDS +#undef Check_FLT_ROUNDS +#define Check_FLT_ROUNDS +#else +#define Rounding Flt_Rounds +#endif + +#ifdef Avoid_Underflow /*{*/ + static double +sulp +#ifdef KR_headers + (x, scale) U *x; int scale; +#else + (U *x, int scale) +#endif +{ + U u; + double rv; + int i; + + rv = ulp(x); + if (!scale || (i = 2*P + 1 - ((word0(x) & Exp_mask) >> Exp_shift)) <= 0) + return rv; /* Is there an example where i <= 0 ? */ + word0(&u) = Exp_1 + (i << Exp_shift); + word1(&u) = 0; + return rv * u.d; + } +#endif /*}*/ + + double +strtod +#ifdef KR_headers + (s00, se) CONST char *s00; char **se; +#else + (CONST char *s00, char **se) +#endif +{ +#ifdef Avoid_Underflow + int scale; +#endif + int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign, + e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; + CONST char *s, *s0, *s1; + double aadj; + Long L; + U adj, aadj1, rv, rv0; + ULong y, z; + Bigint *bb = NULL, *bb1, *bd = NULL, *bd0 = NULL, *bs = NULL, *delta = NULL; +#ifdef Avoid_Underflow + ULong Lsb, Lsb1; +#endif +#ifdef SET_INEXACT + int inexact, oldinexact; +#endif +#ifdef USE_LOCALE /*{{*/ +#ifdef NO_LOCALE_CACHE + char *decimalpoint = localeconv()->decimal_point; + int dplen = strlen(decimalpoint); +#else + char *decimalpoint; + static char *decimalpoint_cache; + static int dplen; + if (!(s0 = decimalpoint_cache)) { + s0 = localeconv()->decimal_point; + if ((decimalpoint_cache = (char*)MALLOC(strlen(s0) + 1))) { + strlcpy(decimalpoint_cache, s0, strlen(s0) + 1); + s0 = decimalpoint_cache; + } + dplen = strlen(s0); + } + decimalpoint = (char*)s0; +#endif /*NO_LOCALE_CACHE*/ +#else /*USE_LOCALE}{*/ +#define dplen 1 +#endif /*USE_LOCALE}}*/ + +#ifdef Honor_FLT_ROUNDS /*{*/ + int Rounding; +#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ + Rounding = Flt_Rounds; +#else /*}{*/ + Rounding = 1; + switch(fegetround()) { + case FE_TOWARDZERO: Rounding = 0; break; + case FE_UPWARD: Rounding = 2; break; + case FE_DOWNWARD: Rounding = 3; + } +#endif /*}}*/ +#endif /*}*/ + + sign = nz0 = nz = decpt = 0; + dval(&rv) = 0.; + for(s = s00;;s++) switch(*s) { + case '-': + sign = 1; + /* no break */ + case '+': + if (*++s) + goto break2; + /* no break */ + case 0: + goto ret0; + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case ' ': + continue; + default: + goto break2; + } + break2: + if (*s == '0') { +#ifndef NO_HEX_FP /*{*/ + { + static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; + Long exp; + ULong bits[2]; + switch(s[1]) { + case 'x': + case 'X': + { +#ifdef Honor_FLT_ROUNDS + FPI fpi1 = fpi; + fpi1.rounding = Rounding; +#else +#define fpi1 fpi +#endif + switch((i = gethex(&s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) { + case STRTOG_NoMemory: + goto ovfl; + case STRTOG_NoNumber: + s = s00; + sign = 0; + case STRTOG_Zero: + break; + default: + if (bb) { + copybits(bits, fpi.nbits, bb); + Bfree(bb); + } + ULtod(((U*)&rv)->L, bits, exp, i); + }} + goto ret; + } + } +#endif /*}*/ + nz0 = 1; + while(*++s == '0') ; + if (!*s) + goto ret; + } + s0 = s; + y = z = 0; + for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < 16) + z = 10*z + c - '0'; + nd0 = nd; +#ifdef USE_LOCALE + if (c == *decimalpoint) { + for(i = 1; decimalpoint[i]; ++i) + if (s[i] != decimalpoint[i]) + goto dig_done; + s += i; + c = *s; +#else + if (c == '.') { + c = *++s; +#endif + decpt = 1; + if (!nd) { + for(; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for(; c >= '0' && c <= '9'; c = *++s) { + have_dig: + nz++; + if (c -= '0') { + nf += nz; + for(i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 1) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 1) + z = 10*z + c; + nz = 0; + } + } + }/*}*/ + dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + goto ret0; + } + s00 = s; + esign = 0; + switch(c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while(c == '0') + c = *++s; + if (c > '0' && c <= '9') { + L = c - '0'; + s1 = s; + while((c = *++s) >= '0' && c <= '9') + L = 10*L + c - '0'; + if (s - s1 > 8 || L > 19999) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 19999; /* safe for 16 bit ints */ + else + e = (int)L; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) { +#ifdef INFNAN_CHECK + /* Check for Nan and Infinity */ + ULong bits[2]; + static FPI fpinan = /* only 52 explicit bits */ + { 52, 1-1023-53+1, 2046-1023-53+1, 1, SI }; + if (!decpt) + switch(c) { + case 'i': + case 'I': + if (match(&s,"nf")) { + --s; + if (!match(&s,"inity")) + ++s; + word0(&rv) = 0x7ff00000; + word1(&rv) = 0; + goto ret; + } + break; + case 'n': + case 'N': + if (match(&s, "an")) { +#ifndef No_Hex_NaN + if (*s == '(' /*)*/ + && hexnan(&s, &fpinan, bits) + == STRTOG_NaNbits) { + word0(&rv) = 0x7ff00000 | bits[1]; + word1(&rv) = bits[0]; + } + else { +#endif + word0(&rv) = NAN_WORD0; + word1(&rv) = NAN_WORD1; +#ifndef No_Hex_NaN + } +#endif + goto ret; + } + } +#endif /* INFNAN_CHECK */ + ret0: + s = s00; + sign = 0; + } + goto ret; + } + e1 = e -= nf; + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; + dval(&rv) = y; + if (k > 9) { +#ifdef SET_INEXACT + if (k > DBL_DIG) + oldinexact = get_inexact(); +#endif + dval(&rv) = tens[k - 9] * dval(&rv) + z; + } + if (nd <= DBL_DIG +#ifndef RND_PRODQUOT +#ifndef Honor_FLT_ROUNDS + && Flt_Rounds == 1 +#endif +#endif + ) { + if (!e) + goto ret; +#ifndef ROUND_BIASED_without_Round_Up + if (e > 0) { + if (e <= Ten_pmax) { +#ifdef VAX + goto vax_ovfl_check; +#else +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + rv.d = -rv.d; + sign = 0; + } +#endif + /* rv = */ rounded_product(dval(&rv), tens[e]); + goto ret; +#endif + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + rv.d = -rv.d; + sign = 0; + } +#endif + e -= i; + dval(&rv) *= tens[i]; +#ifdef VAX + /* VAX exponent range is so narrow we must + * worry about overflow here... + */ + vax_ovfl_check: + word0(&rv) -= P*Exp_msk1; + /* rv = */ rounded_product(dval(&rv), tens[e]); + if ((word0(&rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) + goto ovfl; + word0(&rv) += P*Exp_msk1; +#else + /* rv = */ rounded_product(dval(&rv), tens[e]); +#endif + goto ret; + } + } +#ifndef Inaccurate_Divide + else if (e >= -Ten_pmax) { +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + rv.d = -rv.d; + sign = 0; + } +#endif + /* rv = */ rounded_quotient(dval(&rv), tens[-e]); + goto ret; + } +#endif +#endif /* ROUND_BIASED_without_Round_Up */ + } + e1 += nd - k; + +#ifdef IEEE_Arith +#ifdef SET_INEXACT + inexact = 1; + if (k <= DBL_DIG) + oldinexact = get_inexact(); +#endif +#ifdef Avoid_Underflow + scale = 0; +#endif +#ifdef Honor_FLT_ROUNDS + if (Rounding >= 2) { + if (sign) + Rounding = Rounding == 2 ? 0 : 2; + else + if (Rounding != 2) + Rounding = 0; + } +#endif +#endif /*IEEE_Arith*/ + + /* Get starting approximation = rv * 10**e1 */ + + if (e1 > 0) { + if ( (i = e1 & 15) !=0) + dval(&rv) *= tens[i]; + if (e1 &= ~15) { + if (e1 > DBL_MAX_10_EXP) { + ovfl: + /* Can't trust HUGE_VAL */ +#ifdef IEEE_Arith +#ifdef Honor_FLT_ROUNDS + switch(Rounding) { + case 0: /* toward 0 */ + case 3: /* toward -infinity */ + word0(&rv) = Big0; + word1(&rv) = Big1; + break; + default: + word0(&rv) = Exp_mask; + word1(&rv) = 0; + } +#else /*Honor_FLT_ROUNDS*/ + word0(&rv) = Exp_mask; + word1(&rv) = 0; +#endif /*Honor_FLT_ROUNDS*/ +#ifdef SET_INEXACT + /* set overflow bit */ + dval(&rv0) = 1e300; + dval(&rv0) *= dval(&rv0); +#endif +#else /*IEEE_Arith*/ + word0(&rv) = Big0; + word1(&rv) = Big1; +#endif /*IEEE_Arith*/ + range_err: + if (bd0) { + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); + } +#ifndef NO_ERRNO + errno = ERANGE; +#endif + goto ret; + } + e1 >>= 4; + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + dval(&rv) *= bigtens[j]; + /* The last multiplication could overflow. */ + word0(&rv) -= P*Exp_msk1; + dval(&rv) *= bigtens[j]; + if ((z = word0(&rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-P)) + goto ovfl; + if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { + /* set to largest number */ + /* (Can't trust DBL_MAX) */ + word0(&rv) = Big0; + word1(&rv) = Big1; + } + else + word0(&rv) += P*Exp_msk1; + } + } + else if (e1 < 0) { + e1 = -e1; + if ( (i = e1 & 15) !=0) + dval(&rv) /= tens[i]; + if (e1 >>= 4) { + if (e1 >= 1 << n_bigtens) + goto undfl; +#ifdef Avoid_Underflow + if (e1 & Scale_Bit) + scale = 2*P; + for(j = 0; e1 > 0; j++, e1 >>= 1) + if (e1 & 1) + dval(&rv) *= tinytens[j]; + if (scale && (j = 2*P + 1 - ((word0(&rv) & Exp_mask) + >> Exp_shift)) > 0) { + /* scaled rv is denormal; zap j low bits */ + if (j >= 32) { + word1(&rv) = 0; + if (j >= 53) + word0(&rv) = (P+2)*Exp_msk1; + else + word0(&rv) &= 0xffffffff << (j-32); + } + else + word1(&rv) &= 0xffffffff << j; + } +#else + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + dval(&rv) *= tinytens[j]; + /* The last multiplication could underflow. */ + dval(&rv0) = dval(&rv); + dval(&rv) *= tinytens[j]; + if (!dval(&rv)) { + dval(&rv) = 2.*dval(&rv0); + dval(&rv) *= tinytens[j]; +#endif + if (!dval(&rv)) { + undfl: + dval(&rv) = 0.; + goto range_err; + } +#ifndef Avoid_Underflow + word0(&rv) = Tiny0; + word1(&rv) = Tiny1; + /* The refinement below will clean + * this approximation up. + */ + } +#endif + } + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bd0 = s2b(s0, nd0, nd, y, dplen); + if (bd0 == NULL) + goto ovfl; + + for(;;) { + bd = Balloc(bd0->k); + if (bd == NULL) + goto ovfl; + Bcopy(bd, bd0); + bb = d2b(dval(&rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ + if (bb == NULL) + goto ovfl; + bs = i2b(1); + if (bs == NULL) + goto ovfl; + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; +#ifdef Honor_FLT_ROUNDS + if (Rounding != 1) + bs2++; +#endif +#ifdef Avoid_Underflow + Lsb = LSB; + Lsb1 = 0; + j = bbe - scale; + i = j + bbbits - 1; /* logb(rv) */ + j = P + 1 - bbbits; + if (i < Emin) { /* denormal */ + i = Emin - i; + j -= i; + if (i < 32) + Lsb <<= i; + else + Lsb1 = Lsb << (i-32); + } +#else /*Avoid_Underflow*/ +#ifdef Sudden_Underflow +#ifdef IBM + j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); +#else + j = P + 1 - bbbits; +#endif +#else /*Sudden_Underflow*/ + j = bbe; + i = j + bbbits - 1; /* logb(&rv) */ + if (i < Emin) /* denormal */ + j += P - Emin; + else + j = P + 1 - bbbits; +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + bb2 += j; + bd2 += j; +#ifdef Avoid_Underflow + bd2 += scale; +#endif + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + bs = pow5mult(bs, bb5); + if (bs == NULL) + goto ovfl; + bb1 = mult(bs, bb); + if (bb1 == NULL) + goto ovfl; + Bfree(bb); + bb = bb1; + } + if (bb2 > 0) { + bb = lshift(bb, bb2); + if (bb == NULL) + goto ovfl; + } + if (bd5 > 0) { + bd = pow5mult(bd, bd5); + if (bd == NULL) + goto ovfl; + } + if (bd2 > 0) { + bd = lshift(bd, bd2); + if (bd == NULL) + goto ovfl; + } + if (bs2 > 0) { + bs = lshift(bs, bs2); + if (bs == NULL) + goto ovfl; + } + delta = diff(bb, bd); + if (delta == NULL) + goto ovfl; + dsign = delta->sign; + delta->sign = 0; + i = cmp(delta, bs); +#ifdef Honor_FLT_ROUNDS + if (Rounding != 1) { + if (i < 0) { + /* Error is less than an ulp */ + if (!delta->x[0] && delta->wds <= 1) { + /* exact */ +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + if (Rounding) { + if (dsign) { + dval(&adj) = 1.; + goto apply_adj; + } + } + else if (!dsign) { + dval(&adj) = -1.; + if (!word1(&rv) + && !(word0(&rv) & Frac_mask)) { + y = word0(&rv) & Exp_mask; +#ifdef Avoid_Underflow + if (!scale || y > 2*P*Exp_msk1) +#else + if (y) +#endif + { + delta = lshift(delta,Log2P); + if (delta == NULL) + goto ovfl; + if (cmp(delta, bs) <= 0) + dval(&adj) = -0.5; + } + } + apply_adj: +#ifdef Avoid_Underflow + if (scale && (y = word0(&rv) & Exp_mask) + <= 2*P*Exp_msk1) + word0(&adj) += (2*P+1)*Exp_msk1 - y; +#else +#ifdef Sudden_Underflow + if ((word0(&rv) & Exp_mask) <= + P*Exp_msk1) { + word0(&rv) += P*Exp_msk1; + dval(&rv) += adj*ulp(&rv); + word0(&rv) -= P*Exp_msk1; + } + else +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + dval(&rv) += adj.d*ulp(&rv); + } + break; + } + dval(&adj) = ratio(delta, bs); + if (adj.d < 1.) + dval(&adj) = 1.; + if (adj.d <= 0x7ffffffe) { + /* dval(&adj) = Rounding ? ceil(&adj) : floor(&adj); */ + y = adj.d; + if (y != adj.d) { + if (!((Rounding>>1) ^ dsign)) + y++; + dval(&adj) = y; + } + } +#ifdef Avoid_Underflow + if (scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1) + word0(&adj) += (2*P+1)*Exp_msk1 - y; +#else +#ifdef Sudden_Underflow + if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) { + word0(&rv) += P*Exp_msk1; + dval(&adj) *= ulp(&rv); + if (dsign) + dval(&rv) += adj; + else + dval(&rv) -= adj; + word0(&rv) -= P*Exp_msk1; + goto cont; + } +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + dval(&adj) *= ulp(&rv); + if (dsign) { + if (word0(&rv) == Big0 && word1(&rv) == Big1) + goto ovfl; + dval(&rv) += adj.d; + } + else + dval(&rv) -= adj.d; + goto cont; + } +#endif /*Honor_FLT_ROUNDS*/ + + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + if (dsign || word1(&rv) || word0(&rv) & Bndry_mask +#ifdef IEEE_Arith +#ifdef Avoid_Underflow + || (word0(&rv) & Exp_mask) <= (2*P+1)*Exp_msk1 +#else + || (word0(&rv) & Exp_mask) <= Exp_msk1 +#endif +#endif + ) { +#ifdef SET_INEXACT + if (!delta->x[0] && delta->wds <= 1) + inexact = 0; +#endif + break; + } + if (!delta->x[0] && delta->wds <= 1) { + /* exact result */ +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + delta = lshift(delta,Log2P); + if (delta == NULL) + goto ovfl; + if (cmp(delta, bs) > 0) + goto drop_down; + break; + } + if (i == 0) { + /* exactly half-way between */ + if (dsign) { + if ((word0(&rv) & Bndry_mask1) == Bndry_mask1 + && word1(&rv) == ( +#ifdef Avoid_Underflow + (scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1) + ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : +#endif + 0xffffffff)) { + /*boundary case -- increment exponent*/ + if (word0(&rv) == Big0 && word1(&rv) == Big1) + goto ovfl; + word0(&rv) = (word0(&rv) & Exp_mask) + + Exp_msk1 +#ifdef IBM + | Exp_msk1 >> 4 +#endif + ; + word1(&rv) = 0; +#ifdef Avoid_Underflow + dsign = 0; +#endif + break; + } + } + else if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) { + drop_down: + /* boundary case -- decrement exponent */ +#ifdef Sudden_Underflow /*{{*/ + L = word0(&rv) & Exp_mask; +#ifdef IBM + if (L < Exp_msk1) +#else +#ifdef Avoid_Underflow + if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) +#else + if (L <= Exp_msk1) +#endif /*Avoid_Underflow*/ +#endif /*IBM*/ + goto undfl; + L -= Exp_msk1; +#else /*Sudden_Underflow}{*/ +#ifdef Avoid_Underflow + if (scale) { + L = word0(&rv) & Exp_mask; + if (L <= (2*P+1)*Exp_msk1) { + if (L > (P+2)*Exp_msk1) + /* round even ==> */ + /* accept rv */ + break; + /* rv = smallest denormal */ + goto undfl; + } + } +#endif /*Avoid_Underflow*/ + L = (word0(&rv) & Exp_mask) - Exp_msk1; +#endif /*Sudden_Underflow}}*/ + word0(&rv) = L | Bndry_mask1; + word1(&rv) = 0xffffffff; +#ifdef IBM + goto cont; +#else + break; +#endif + } +#ifndef ROUND_BIASED +#ifdef Avoid_Underflow + if (Lsb1) { + if (!(word0(&rv) & Lsb1)) + break; + } + else if (!(word1(&rv) & Lsb)) + break; +#else + if (!(word1(&rv) & LSB)) + break; +#endif +#endif + if (dsign) +#ifdef Avoid_Underflow + dval(&rv) += sulp(&rv, scale); +#else + dval(&rv) += ulp(&rv); +#endif +#ifndef ROUND_BIASED + else { +#ifdef Avoid_Underflow + dval(&rv) -= sulp(&rv, scale); +#else + dval(&rv) -= ulp(&rv); +#endif +#ifndef Sudden_Underflow + if (!dval(&rv)) + goto undfl; +#endif + } +#ifdef Avoid_Underflow + dsign = 1 - dsign; +#endif +#endif + break; + } + if ((aadj = ratio(delta, bs)) <= 2.) { + if (dsign) + aadj = dval(&aadj1) = 1.; + else if (word1(&rv) || word0(&rv) & Bndry_mask) { +#ifndef Sudden_Underflow + if (word1(&rv) == Tiny1 && !word0(&rv)) + goto undfl; +#endif + aadj = 1.; + dval(&aadj1) = -1.; + } + else { + /* special case -- power of FLT_RADIX to be */ + /* rounded down... */ + + if (aadj < 2./FLT_RADIX) + aadj = 1./FLT_RADIX; + else + aadj *= 0.5; + dval(&aadj1) = -aadj; + } + } + else { + aadj *= 0.5; + dval(&aadj1) = dsign ? aadj : -aadj; +#ifdef Check_FLT_ROUNDS + switch(Rounding) { + case 2: /* towards +infinity */ + dval(&aadj1) -= 0.5; + break; + case 0: /* towards 0 */ + case 3: /* towards -infinity */ + dval(&aadj1) += 0.5; + } +#else + if (Flt_Rounds == 0) + dval(&aadj1) += 0.5; +#endif /*Check_FLT_ROUNDS*/ + } + y = word0(&rv) & Exp_mask; + + /* Check for overflow */ + + if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { + dval(&rv0) = dval(&rv); + word0(&rv) -= P*Exp_msk1; + dval(&adj) = dval(&aadj1) * ulp(&rv); + dval(&rv) += dval(&adj); + if ((word0(&rv) & Exp_mask) >= + Exp_msk1*(DBL_MAX_EXP+Bias-P)) { + if (word0(&rv0) == Big0 && word1(&rv0) == Big1) + goto ovfl; + word0(&rv) = Big0; + word1(&rv) = Big1; + goto cont; + } + else + word0(&rv) += P*Exp_msk1; + } + else { +#ifdef Avoid_Underflow + if (scale && y <= 2*P*Exp_msk1) { + if (aadj <= 0x7fffffff) { + if ((z = aadj) <= 0) + z = 1; + aadj = z; + dval(&aadj1) = dsign ? aadj : -aadj; + } + word0(&aadj1) += (2*P+1)*Exp_msk1 - y; + } + dval(&adj) = dval(&aadj1) * ulp(&rv); + dval(&rv) += dval(&adj); +#else +#ifdef Sudden_Underflow + if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) { + dval(&rv0) = dval(&rv); + word0(&rv) += P*Exp_msk1; + dval(&adj) = dval(&aadj1) * ulp(&rv); + dval(&rv) += dval(&adj); +#ifdef IBM + if ((word0(&rv) & Exp_mask) < P*Exp_msk1) +#else + if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) +#endif + { + if (word0(&rv0) == Tiny0 + && word1(&rv0) == Tiny1) + goto undfl; + word0(&rv) = Tiny0; + word1(&rv) = Tiny1; + goto cont; + } + else + word0(&rv) -= P*Exp_msk1; + } + else { + dval(&adj) = dval(&aadj1) * ulp(&rv); + dval(&rv) += dval(&adj); + } +#else /*Sudden_Underflow*/ + /* Compute dval(&adj) so that the IEEE rounding rules will + * correctly round rv + dval(&adj) in some half-way cases. + * If rv * ulp(&rv) is denormalized (i.e., + * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid + * trouble from bits lost to denormalization; + * example: 1.2e-307 . + */ + if (y <= (P-1)*Exp_msk1 && aadj > 1.) { + dval(&aadj1) = (double)(int)(aadj + 0.5); + if (!dsign) + dval(&aadj1) = -dval(&aadj1); + } + dval(&adj) = dval(&aadj1) * ulp(&rv); + dval(&rv) += adj; +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + } + z = word0(&rv) & Exp_mask; +#ifndef SET_INEXACT +#ifdef Avoid_Underflow + if (!scale) +#endif + if (y == z) { + /* Can we stop now? */ + L = (Long)aadj; + aadj -= L; + /* The tolerances below are conservative. */ + if (dsign || word1(&rv) || word0(&rv) & Bndry_mask) { + if (aadj < .4999999 || aadj > .5000001) + break; + } + else if (aadj < .4999999/FLT_RADIX) + break; + } +#endif + cont: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(delta); + } + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); +#ifdef SET_INEXACT + if (inexact) { + if (!oldinexact) { + word0(&rv0) = Exp_1 + (70 << Exp_shift); + word1(&rv0) = 0; + dval(&rv0) += 1.; + } + } + else if (!oldinexact) + clear_inexact(); +#endif +#ifdef Avoid_Underflow + if (scale) { + word0(&rv0) = Exp_1 - 2*P*Exp_msk1; + word1(&rv0) = 0; + dval(&rv) *= dval(&rv0); +#ifndef NO_ERRNO + /* try to avoid the bug of testing an 8087 register value */ +#ifdef IEEE_Arith + if (!(word0(&rv) & Exp_mask)) +#else + if (word0(&rv) == 0 && word1(&rv) == 0) +#endif + errno = ERANGE; +#endif + } +#endif /* Avoid_Underflow */ +#ifdef SET_INEXACT + if (inexact && !(word0(&rv) & Exp_mask)) { + /* set underflow bit */ + dval(&rv0) = 1e-300; + dval(&rv0) *= dval(&rv0); + } +#endif + ret: + if (se) + *se = (char *)s; + return sign ? -dval(&rv) : dval(&rv); + } + diff --git a/sdk/tlibc/gdtoa/strtodg.c b/sdk/tlibc/gdtoa/strtodg.c new file mode 100644 index 0000000000..8542a222e9 --- /dev/null +++ b/sdk/tlibc/gdtoa/strtodg.c @@ -0,0 +1,1156 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998-2001 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + +#ifdef USE_LOCALE +#include "locale.h" +#endif + + static CONST int +fivesbits[] = { 0, 3, 5, 7, 10, 12, 14, 17, 19, 21, + 24, 26, 28, 31, 33, 35, 38, 40, 42, 45, + 47, 49, 52 +#ifdef VAX + , 54, 56 +#endif + }; + + Bigint * +#ifdef KR_headers +increment(b) Bigint *b; +#else +increment(Bigint *b) +#endif +{ + ULong *x, *xe; + Bigint *b1; +#ifdef Pack_16 + ULong carry = 1, y; +#endif + + x = b->x; + xe = x + b->wds; +#ifdef Pack_32 + do { + if (*x < (ULong)0xffffffffL) { + ++*x; + return b; + } + *x++ = 0; + } while(x < xe); +#else + do { + y = *x + carry; + carry = y >> 16; + *x++ = y & 0xffff; + if (!carry) + return b; + } while(x < xe); + if (carry) +#endif + { + if (b->wds >= b->maxwds) { + b1 = Balloc(b->k+1); + if (b1 == NULL) + return (NULL); + Bcopy(b1,b); + Bfree(b); + b = b1; + } + b->x[b->wds++] = 1; + } + return b; + } + + void +#ifdef KR_headers +decrement(b) Bigint *b; +#else +decrement(Bigint *b) +#endif +{ + ULong *x, *xe; +#ifdef Pack_16 + ULong borrow = 1, y; +#endif + + x = b->x; + xe = x + b->wds; +#ifdef Pack_32 + do { + if (*x) { + --*x; + break; + } + *x++ = 0xffffffffL; + } + while(x < xe); +#else + do { + y = *x - borrow; + borrow = (y & 0x10000) >> 16; + *x++ = y & 0xffff; + } while(borrow && x < xe); +#endif + } + + static int +#ifdef KR_headers +all_on(b, n) Bigint *b; int n; +#else +all_on(Bigint *b, int n) +#endif +{ + ULong *x, *xe; + + x = b->x; + xe = x + (n >> kshift); + while(x < xe) + if ((*x++ & ALL_ON) != ALL_ON) + return 0; + if (n &= kmask) + return ((*x | (ALL_ON << n)) & ALL_ON) == ALL_ON; + return 1; + } + + Bigint * +#ifdef KR_headers +set_ones(b, n) Bigint *b; int n; +#else +set_ones(Bigint *b, int n) +#endif +{ + int k; + ULong *x, *xe; + + k = (n + ((1 << kshift) - 1)) >> kshift; + if (b->k < k) { + Bfree(b); + b = Balloc(k); + if (b == NULL) + return (NULL); + } + k = n >> kshift; + if (n &= kmask) + k++; + b->wds = k; + x = b->x; + xe = x + k; + while(x < xe) + *x++ = ALL_ON; + if (n) + x[-1] >>= ULbits - n; + return b; + } + + static int +rvOK +#ifdef KR_headers + (d, fpi, exp, bits, exact, rd, irv) + U *d; FPI *fpi; Long *exp; ULong *bits; int exact, rd, *irv; +#else + (U *d, FPI *fpi, Long *exp, ULong *bits, int exact, int rd, int *irv) +#endif +{ + Bigint *b; + ULong carry, inex, lostbits; + int bdif, e, j, k, k1, nb, rv; + + carry = rv = 0; + b = d2b(dval(d), &e, &bdif); + if (b == NULL) { + *irv = STRTOG_NoMemory; + return (1); + } + bdif -= nb = fpi->nbits; + e += bdif; + if (bdif <= 0) { + if (exact) + goto trunc; + goto ret; + } + if (P == nb) { + if ( +#ifndef IMPRECISE_INEXACT + exact && +#endif + fpi->rounding == +#ifdef RND_PRODQUOT + FPI_Round_near +#else + Flt_Rounds +#endif + ) goto trunc; + goto ret; + } + switch(rd) { + case 1: /* round down (toward -Infinity) */ + goto trunc; + case 2: /* round up (toward +Infinity) */ + break; + default: /* round near */ + k = bdif - 1; + if (k < 0) + goto trunc; + if (!k) { + if (!exact) + goto ret; + if (b->x[0] & 2) + break; + goto trunc; + } + if (b->x[k>>kshift] & ((ULong)1 << (k & kmask))) + break; + goto trunc; + } + /* "break" cases: round up 1 bit, then truncate; bdif > 0 */ + carry = 1; + trunc: + inex = lostbits = 0; + if (bdif > 0) { + if ( (lostbits = any_on(b, bdif)) !=0) + inex = STRTOG_Inexlo; + rshift(b, bdif); + if (carry) { + inex = STRTOG_Inexhi; + b = increment(b); + if (b == NULL) { + *irv = STRTOG_NoMemory; + return (1); + } + if ( (j = nb & kmask) !=0) + j = ULbits - j; + if (hi0bits(b->x[b->wds - 1]) != j) { + if (!lostbits) + lostbits = b->x[0] & 1; + rshift(b, 1); + e++; + } + } + } + else if (bdif < 0) { + b = lshift(b, -bdif); + if (b == NULL) { + *irv = STRTOG_NoMemory; + return (1); + } + } + if (e < fpi->emin) { + k = fpi->emin - e; + e = fpi->emin; + if (k > nb || fpi->sudden_underflow) { + b->wds = inex = 0; + *irv = STRTOG_Underflow | STRTOG_Inexlo; + } + else { + k1 = k - 1; + if (k1 > 0 && !lostbits) + lostbits = any_on(b, k1); + if (!lostbits && !exact) + goto ret; + lostbits |= + carry = b->x[k1>>kshift] & (1 << (k1 & kmask)); + rshift(b, k); + *irv = STRTOG_Denormal; + if (carry) { + b = increment(b); + if (b == NULL) { + *irv = STRTOG_NoMemory; + return (1); + } + inex = STRTOG_Inexhi | STRTOG_Underflow; + } + else if (lostbits) + inex = STRTOG_Inexlo | STRTOG_Underflow; + } + } + else if (e > fpi->emax) { + e = fpi->emax + 1; + *irv = STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + b->wds = inex = 0; + } + *exp = e; + copybits(bits, nb, b); + *irv |= inex; + rv = 1; + ret: + Bfree(b); + return rv; + } + + static int +#ifdef KR_headers +mantbits(d) U *d; +#else +mantbits(U *d) +#endif +{ + ULong L; +#ifdef VAX + L = word1(d) << 16 | word1(d) >> 16; + if (L) +#else + if ( (L = word1(d)) !=0) +#endif + return P - lo0bits(&L); +#ifdef VAX + L = word0(d) << 16 | word0(d) >> 16 | Exp_msk11; +#else + L = word0(d) | Exp_msk1; +#endif + return P - 32 - lo0bits(&L); + } + + int +strtodg +#ifdef KR_headers + (s00, se, fpi, exp, bits) + CONST char *s00; char **se; FPI *fpi; Long *exp; ULong *bits; +#else + (CONST char *s00, char **se, FPI *fpi, Long *exp, ULong *bits) +#endif +{ + int abe, abits, asub; + int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, denorm; + int dsign, e, e1, e2, emin, esign, finished, i, inex, irv; + int j, k, nbits, nd, nd0, nf, nz, nz0, rd, rvbits, rve, rve1, sign; + int sudden_underflow; + CONST char *s, *s0, *s1; + double adj0, tol; + Long L; + U adj, rv; + ULong *b, *be, y, z; + Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0; +#ifdef USE_LOCALE /*{{*/ +#ifdef NO_LOCALE_CACHE + char *decimalpoint = localeconv()->decimal_point; + int dplen = strlen(decimalpoint); +#else + char *decimalpoint; + static char *decimalpoint_cache; + static int dplen; + if (!(s0 = decimalpoint_cache)) { + s0 = localeconv()->decimal_point; + if ((decimalpoint_cache = (char*)MALLOC(strlen(s0) + 1))) { + strlcpy(decimalpoint_cache, s0, strlen(s0) + 1); + s0 = decimalpoint_cache; + } + dplen = strlen(s0); + } + decimalpoint = (char*)s0; +#endif /*NO_LOCALE_CACHE*/ +#else /*USE_LOCALE}{*/ +#define dplen 1 +#endif /*USE_LOCALE}}*/ + + irv = STRTOG_Zero; + denorm = sign = nz0 = nz = 0; + dval(&rv) = 0.; + rvb = 0; + nbits = fpi->nbits; + for(s = s00;;s++) switch(*s) { + case '-': + sign = 1; + /* no break */ + case '+': + if (*++s) + goto break2; + /* no break */ + case 0: + sign = 0; + irv = STRTOG_NoNumber; + s = s00; + goto ret; + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case ' ': + continue; + default: + goto break2; + } + break2: + if (*s == '0') { +#ifndef NO_HEX_FP + switch(s[1]) { + case 'x': + case 'X': + irv = gethex(&s, fpi, exp, &rvb, sign); + if (irv == STRTOG_NoMemory) + return (STRTOG_NoMemory); + if (irv == STRTOG_NoNumber) { + s = s00; + sign = 0; + } + goto ret; + } +#endif + nz0 = 1; + while(*++s == '0') ; + if (!*s) + goto ret; + } + sudden_underflow = fpi->sudden_underflow; + s0 = s; + y = z = 0; + for(decpt = nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < 16) + z = 10*z + c - '0'; + nd0 = nd; +#ifdef USE_LOCALE + if (c == *decimalpoint) { + for(i = 1; decimalpoint[i]; ++i) + if (s[i] != decimalpoint[i]) + goto dig_done; + s += i; + c = *s; +#else + if (c == '.') { + c = *++s; +#endif + decpt = 1; + if (!nd) { + for(; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for(; c >= '0' && c <= '9'; c = *++s) { + have_dig: + nz++; + if (c -= '0') { + nf += nz; + for(i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 1) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 1) + z = 10*z + c; + nz = 0; + } + } + }/*}*/ + dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + irv = STRTOG_NoNumber; + s = s00; + goto ret; + } + s00 = s; + esign = 0; + switch(c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while(c == '0') + c = *++s; + if (c > '0' && c <= '9') { + L = c - '0'; + s1 = s; + while((c = *++s) >= '0' && c <= '9') + L = 10*L + c - '0'; + if (s - s1 > 8 || L > 19999) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 19999; /* safe for 16 bit ints */ + else + e = (int)L; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) { +#ifdef INFNAN_CHECK + /* Check for Nan and Infinity */ + if (!decpt) + switch(c) { + case 'i': + case 'I': + if (match(&s,"nf")) { + --s; + if (!match(&s,"inity")) + ++s; + irv = STRTOG_Infinite; + goto infnanexp; + } + break; + case 'n': + case 'N': + if (match(&s, "an")) { + irv = STRTOG_NaN; + *exp = fpi->emax + 1; +#ifndef No_Hex_NaN + if (*s == '(') /*)*/ + irv = hexnan(&s, fpi, bits); +#endif + goto infnanexp; + } + } +#endif /* INFNAN_CHECK */ + irv = STRTOG_NoNumber; + s = s00; + } + goto ret; + } + + irv = STRTOG_Normal; + e1 = e -= nf; + rd = 0; + switch(fpi->rounding & 3) { + case FPI_Round_up: + rd = 2 - sign; + break; + case FPI_Round_zero: + rd = 1; + break; + case FPI_Round_down: + rd = 1 + sign; + } + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; + dval(&rv) = y; + if (k > 9) + dval(&rv) = tens[k - 9] * dval(&rv) + z; + bd0 = 0; + if (nbits <= P && nd <= DBL_DIG) { + if (!e) { + if (rvOK(&rv, fpi, exp, bits, 1, rd, &irv)) { + if (irv == STRTOG_NoMemory) + return (STRTOG_NoMemory); + goto ret; + } + } + else if (e > 0) { + if (e <= Ten_pmax) { +#ifdef VAX + goto vax_ovfl_check; +#else + i = fivesbits[e] + mantbits(&rv) <= P; + /* rv = */ rounded_product(dval(&rv), tens[e]); + if (rvOK(&rv, fpi, exp, bits, i, rd, &irv)) { + if (irv == STRTOG_NoMemory) + return (STRTOG_NoMemory); + goto ret; + } + e1 -= e; + goto rv_notOK; +#endif + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ + e2 = e - i; + e1 -= i; + dval(&rv) *= tens[i]; +#ifdef VAX + /* VAX exponent range is so narrow we must + * worry about overflow here... + */ + vax_ovfl_check: + dval(&adj) = dval(&rv); + word0(&adj) -= P*Exp_msk1; + /* adj = */ rounded_product(dval(&adj), tens[e2]); + if ((word0(&adj) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) + goto rv_notOK; + word0(&adj) += P*Exp_msk1; + dval(&rv) = dval(&adj); +#else + /* rv = */ rounded_product(dval(&rv), tens[e2]); +#endif + if (rvOK(&rv, fpi, exp, bits, 0, rd, &irv)) { + if (irv == STRTOG_NoMemory) + return (STRTOG_NoMemory); + goto ret; + } + e1 -= e2; + } + } +#ifndef Inaccurate_Divide + else if (e >= -Ten_pmax) { + /* rv = */ rounded_quotient(dval(&rv), tens[-e]); + if (rvOK(&rv, fpi, exp, bits, 0, rd, &irv)) { + if (irv == STRTOG_NoMemory) + return (STRTOG_NoMemory); + goto ret; + } + e1 -= e; + } +#endif + } + rv_notOK: + e1 += nd - k; + + /* Get starting approximation = rv * 10**e1 */ + + e2 = 0; + if (e1 > 0) { + if ( (i = e1 & 15) !=0) + dval(&rv) *= tens[i]; + if (e1 &= ~15) { + e1 >>= 4; + while(e1 >= (1 << (n_bigtens-1))) { + e2 += ((word0(&rv) & Exp_mask) + >> Exp_shift1) - Bias; + word0(&rv) &= ~Exp_mask; + word0(&rv) |= Bias << Exp_shift1; + dval(&rv) *= bigtens[n_bigtens-1]; + e1 -= 1 << (n_bigtens-1); + } + e2 += ((word0(&rv) & Exp_mask) >> Exp_shift1) - Bias; + word0(&rv) &= ~Exp_mask; + word0(&rv) |= Bias << Exp_shift1; + for(j = 0; e1 > 0; j++, e1 >>= 1) + if (e1 & 1) + dval(&rv) *= bigtens[j]; + } + } + else if (e1 < 0) { + e1 = -e1; + if ( (i = e1 & 15) !=0) + dval(&rv) /= tens[i]; + if (e1 &= ~15) { + e1 >>= 4; + while(e1 >= (1 << (n_bigtens-1))) { + e2 += ((word0(&rv) & Exp_mask) + >> Exp_shift1) - Bias; + word0(&rv) &= ~Exp_mask; + word0(&rv) |= Bias << Exp_shift1; + dval(&rv) *= tinytens[n_bigtens-1]; + e1 -= 1 << (n_bigtens-1); + } + e2 += ((word0(&rv) & Exp_mask) >> Exp_shift1) - Bias; + word0(&rv) &= ~Exp_mask; + word0(&rv) |= Bias << Exp_shift1; + for(j = 0; e1 > 0; j++, e1 >>= 1) + if (e1 & 1) + dval(&rv) *= tinytens[j]; + } + } +#ifdef IBM + /* e2 is a correction to the (base 2) exponent of the return + * value, reflecting adjustments above to avoid overflow in the + * native arithmetic. For native IBM (base 16) arithmetic, we + * must multiply e2 by 4 to change from base 16 to 2. + */ + e2 <<= 2; +#endif + rvb = d2b(dval(&rv), &rve, &rvbits); /* rv = rvb * 2^rve */ + if (rvb == NULL) + return (STRTOG_NoMemory); + rve += e2; + if ((j = rvbits - nbits) > 0) { + rshift(rvb, j); + rvbits = nbits; + rve += j; + } + bb0 = 0; /* trailing zero bits in rvb */ + e2 = rve + rvbits - nbits; + if (e2 > fpi->emax + 1) + goto huge; + rve1 = rve + rvbits - nbits; + if (e2 < (emin = fpi->emin)) { + denorm = 1; + j = rve - emin; + if (j > 0) { + rvb = lshift(rvb, j); + if (rvb == NULL) + return (STRTOG_NoMemory); + rvbits += j; + } + else if (j < 0) { + rvbits += j; + if (rvbits <= 0) { + if (rvbits < -1) { + ufl: + rvb->wds = 0; + rvb->x[0] = 0; + *exp = emin; + irv = STRTOG_Underflow | STRTOG_Inexlo; + goto ret; + } + rvb->x[0] = rvb->wds = rvbits = 1; + } + else + rshift(rvb, -j); + } + rve = rve1 = emin; + if (sudden_underflow && e2 + 1 < emin) + goto ufl; + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bd0 = s2b(s0, nd0, nd, y, dplen); + if (bd0 == NULL) + return (STRTOG_NoMemory); + + for(;;) { + bd = Balloc(bd0->k); + if (bd == NULL) + return (STRTOG_NoMemory); + Bcopy(bd, bd0); + bb = Balloc(rvb->k); + if (bb == NULL) + return (STRTOG_NoMemory); + Bcopy(bb, rvb); + bbbits = rvbits - bb0; + bbe = rve + bb0; + bs = i2b(1); + if (bs == NULL) + return (STRTOG_NoMemory); + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; + j = nbits + 1 - bbbits; + i = bbe + bbbits - nbits; + if (i < emin) /* denormal */ + j += i - emin; + bb2 += j; + bd2 += j; + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + bs = pow5mult(bs, bb5); + if (bs == NULL) + return (STRTOG_NoMemory); + bb1 = mult(bs, bb); + if (bb1 == NULL) + return (STRTOG_NoMemory); + Bfree(bb); + bb = bb1; + } + bb2 -= bb0; + if (bb2 > 0) { + bb = lshift(bb, bb2); + if (bb == NULL) + return (STRTOG_NoMemory); + } + else if (bb2 < 0) + rshift(bb, -bb2); + if (bd5 > 0) { + bd = pow5mult(bd, bd5); + if (bd == NULL) + return (STRTOG_NoMemory); + } + if (bd2 > 0) { + bd = lshift(bd, bd2); + if (bd == NULL) + return (STRTOG_NoMemory); + } + if (bs2 > 0) { + bs = lshift(bs, bs2); + if (bs == NULL) + return (STRTOG_NoMemory); + } + asub = 1; + inex = STRTOG_Inexhi; + delta = diff(bb, bd); + if (delta == NULL) + return (STRTOG_NoMemory); + if (delta->wds <= 1 && !delta->x[0]) + break; + dsign = delta->sign; + delta->sign = finished = 0; + L = 0; + i = cmp(delta, bs); + if (rd && i <= 0) { + irv = STRTOG_Normal; + if ( (finished = dsign ^ (rd&1)) !=0) { + if (dsign != 0) { + irv |= STRTOG_Inexhi; + goto adj1; + } + irv |= STRTOG_Inexlo; + if (rve1 == emin) + goto adj1; + for(i = 0, j = nbits; j >= ULbits; + i++, j -= ULbits) { + if (rvb->x[i] & ALL_ON) + goto adj1; + } + if (j > 1 && lo0bits(rvb->x + i) < j - 1) + goto adj1; + rve = rve1 - 1; + rvb = set_ones(rvb, rvbits = nbits); + if (rvb == NULL) + return (STRTOG_NoMemory); + break; + } + irv |= dsign ? STRTOG_Inexlo : STRTOG_Inexhi; + break; + } + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + irv = dsign + ? STRTOG_Normal | STRTOG_Inexlo + : STRTOG_Normal | STRTOG_Inexhi; + if (dsign || bbbits > 1 || denorm || rve1 == emin) + break; + delta = lshift(delta,1); + if (delta == NULL) + return (STRTOG_NoMemory); + if (cmp(delta, bs) > 0) { + irv = STRTOG_Normal | STRTOG_Inexlo; + goto drop_down; + } + break; + } + if (i == 0) { + /* exactly half-way between */ + if (dsign) { + if (denorm && all_on(rvb, rvbits)) { + /*boundary case -- increment exponent*/ + rvb->wds = 1; + rvb->x[0] = 1; + rve = emin + nbits - (rvbits = 1); + irv = STRTOG_Normal | STRTOG_Inexhi; + denorm = 0; + break; + } + irv = STRTOG_Normal | STRTOG_Inexlo; + } + else if (bbbits == 1) { + irv = STRTOG_Normal; + drop_down: + /* boundary case -- decrement exponent */ + if (rve1 == emin) { + irv = STRTOG_Normal | STRTOG_Inexhi; + if (rvb->wds == 1 && rvb->x[0] == 1) + sudden_underflow = 1; + break; + } + rve -= nbits; + rvb = set_ones(rvb, rvbits = nbits); + if (rvb == NULL) + return (STRTOG_NoMemory); + break; + } + else + irv = STRTOG_Normal | STRTOG_Inexhi; + if ((bbbits < nbits && !denorm) || !(rvb->x[0] & 1)) + break; + if (dsign) { + rvb = increment(rvb); + if (rvb == NULL) + return (STRTOG_NoMemory); + j = kmask & (ULbits - (rvbits & kmask)); + if (hi0bits(rvb->x[rvb->wds - 1]) != j) + rvbits++; + irv = STRTOG_Normal | STRTOG_Inexhi; + } + else { + if (bbbits == 1) + goto undfl; + decrement(rvb); + irv = STRTOG_Normal | STRTOG_Inexlo; + } + break; + } + if ((dval(&adj) = ratio(delta, bs)) <= 2.) { + adj1: + inex = STRTOG_Inexlo; + if (dsign) { + asub = 0; + inex = STRTOG_Inexhi; + } + else if (denorm && bbbits <= 1) { + undfl: + rvb->wds = 0; + rve = emin; + irv = STRTOG_Underflow | STRTOG_Inexlo; + break; + } + adj0 = dval(&adj) = 1.; + } + else { + adj0 = dval(&adj) *= 0.5; + if (dsign) { + asub = 0; + inex = STRTOG_Inexlo; + } + if (dval(&adj) < 2147483647.) { + L = adj0; + adj0 -= L; + switch(rd) { + case 0: + if (adj0 >= .5) + goto inc_L; + break; + case 1: + if (asub && adj0 > 0.) + goto inc_L; + break; + case 2: + if (!asub && adj0 > 0.) { + inc_L: + L++; + inex = STRTOG_Inexact - inex; + } + } + dval(&adj) = L; + } + } + y = rve + rvbits; + + /* adj *= ulp(dval(&rv)); */ + /* if (asub) rv -= adj; else rv += adj; */ + + if (!denorm && rvbits < nbits) { + rvb = lshift(rvb, j = nbits - rvbits); + if (rvb == NULL) + return (STRTOG_NoMemory); + rve -= j; + rvbits = nbits; + } + ab = d2b(dval(&adj), &abe, &abits); + if (ab == NULL) + return (STRTOG_NoMemory); + if (abe < 0) + rshift(ab, -abe); + else if (abe > 0) { + ab = lshift(ab, abe); + if (ab == NULL) + return (STRTOG_NoMemory); + } + rvb0 = rvb; + if (asub) { + /* rv -= adj; */ + j = hi0bits(rvb->x[rvb->wds-1]); + rvb = diff(rvb, ab); + if (rvb == NULL) + return (STRTOG_NoMemory); + k = rvb0->wds - 1; + if (denorm) + /* do nothing */; + else if (rvb->wds <= k + || hi0bits( rvb->x[k]) > + hi0bits(rvb0->x[k])) { + /* unlikely; can only have lost 1 high bit */ + if (rve1 == emin) { + --rvbits; + denorm = 1; + } + else { + rvb = lshift(rvb, 1); + if (rvb == NULL) + return (STRTOG_NoMemory); + --rve; + --rve1; + L = finished = 0; + } + } + } + else { + rvb = sum(rvb, ab); + if (rvb == NULL) + return (STRTOG_NoMemory); + k = rvb->wds - 1; + if (k >= rvb0->wds + || hi0bits(rvb->x[k]) < hi0bits(rvb0->x[k])) { + if (denorm) { + if (++rvbits == nbits) + denorm = 0; + } + else { + rshift(rvb, 1); + rve++; + rve1++; + L = 0; + } + } + } + Bfree(ab); + Bfree(rvb0); + if (finished) + break; + + z = rve + rvbits; + if (y == z && L) { + /* Can we stop now? */ + tol = dval(&adj) * 5e-16; /* > max rel error */ + dval(&adj) = adj0 - .5; + if (dval(&adj) < -tol) { + if (adj0 > tol) { + irv |= inex; + break; + } + } + else if (dval(&adj) > tol && adj0 < 1. - tol) { + irv |= inex; + break; + } + } + bb0 = denorm ? 0 : trailz(rvb); + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(delta); + } + if (!denorm && (j = nbits - rvbits)) { + if (j > 0) { + rvb = lshift(rvb, j); + if (rvb == NULL) + return (STRTOG_NoMemory); + } + else + rshift(rvb, -j); + rve -= j; + } + *exp = rve; + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); + if (rve > fpi->emax) { + switch(fpi->rounding & 3) { + case FPI_Round_near: + goto huge; + case FPI_Round_up: + if (!sign) + goto huge; + break; + case FPI_Round_down: + if (sign) + goto huge; + } + /* Round to largest representable magnitude */ + Bfree(rvb); + rvb = 0; + irv = STRTOG_Normal | STRTOG_Inexlo; + *exp = fpi->emax; + b = bits; + be = b + ((fpi->nbits + 31) >> 5); + while(b < be) + *b++ = -1; + if ((j = fpi->nbits & 0x1f)) + *--be >>= (32 - j); + goto ret; + huge: + rvb->wds = 0; + irv = STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + infnanexp: + *exp = fpi->emax + 1; + } + ret: + if (denorm) { + if (sudden_underflow) { + if (!rvb) abort(); + rvb->wds = 0; + irv = STRTOG_Underflow | STRTOG_Inexlo; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + } + else { + if (!rvb) abort(); + irv = (irv & ~STRTOG_Retmask) | + (rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero); + if (irv & STRTOG_Inexact) { + irv |= STRTOG_Underflow; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + } + } + } + if (se) + *se = (char *)s; + if (sign) + irv |= STRTOG_Neg; + if (rvb) { + copybits(bits, nbits, rvb); + Bfree(rvb); + } + return irv; + } diff --git a/sdk/tlibc/gdtoa/strtof.c b/sdk/tlibc/gdtoa/strtof.c new file mode 100644 index 0000000000..224491b50f --- /dev/null +++ b/sdk/tlibc/gdtoa/strtof.c @@ -0,0 +1,81 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 2000 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + float +#ifdef KR_headers +strtof(s, sp) CONST char *s; char **sp; +#else +strtof(CONST char *s, char **sp) +#endif +{ + static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI }; + ULong bits[1]; + Long exp; + int k; + union { ULong L[1]; float f; } u; +#ifdef Honor_FLT_ROUNDS +#include "gdtoa_fltrnds.h" +#else +#define fpi &fpi0 +#endif + + k = strtodg(s, sp, fpi, &exp, bits); + switch(k & STRTOG_Retmask) { + case STRTOG_NoNumber: + case STRTOG_Zero: + u.L[0] = 0; + break; + + case STRTOG_Normal: + case STRTOG_NaNbits: + u.L[0] = (bits[0] & 0x7fffff) | ((exp + 0x7f + 23) << 23); + break; + + case STRTOG_Denormal: + u.L[0] = bits[0]; + break; + + case STRTOG_NoMemory: + errno = ERANGE; + /* FALLTHROUGH */ + case STRTOG_Infinite: + u.L[0] = 0x7f800000; + break; + + case STRTOG_NaN: + u.L[0] = f_QNAN; + } + if (k & STRTOG_Neg) + u.L[0] |= 0x80000000L; + return u.f; + } diff --git a/sdk/tlibc/gdtoa/strtold.c b/sdk/tlibc/gdtoa/strtold.c new file mode 100644 index 0000000000..0de6d88c00 --- /dev/null +++ b/sdk/tlibc/gdtoa/strtold.c @@ -0,0 +1,40 @@ +/* $OpenBSD: strtold.c,v 1.1 2008/09/07 20:36:08 martynas Exp $ */ +/*- + * Copyright (c) 2003 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Machine-dependent glue to integrate David Gay's gdtoa + * package into libc for architectures where a long double + * is the same as a double, such as the Alpha. + */ + +#include "gdtoaimp.h" + +long double +strtold(const char * __restrict s, char ** __restrict sp) +{ + return strtod(s, sp); +} diff --git a/sdk/tlibc/gdtoa/strtord.c b/sdk/tlibc/gdtoa/strtord.c new file mode 100644 index 0000000000..dd22fb51a6 --- /dev/null +++ b/sdk/tlibc/gdtoa/strtord.c @@ -0,0 +1,73 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 2000 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + void +#ifdef KR_headers +ULtod(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k; +#else +ULtod(ULong *L, ULong *bits, Long exp, int k) +#endif +{ + switch(k & STRTOG_Retmask) { + case STRTOG_NoNumber: + case STRTOG_Zero: + L[0] = L[1] = 0; + break; + + case STRTOG_Denormal: + L[_1] = bits[0]; + L[_0] = bits[1]; + break; + + case STRTOG_Normal: + case STRTOG_NaNbits: + L[_1] = bits[0]; + L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20); + break; + + case STRTOG_NoMemory: + errno = ERANGE; + /* FALLTHROUGH */ + case STRTOG_Infinite: + L[_0] = 0x7ff00000; + L[_1] = 0; + break; + + case STRTOG_NaN: + L[0] = d_QNAN0; + L[1] = d_QNAN1; + } + if (k & STRTOG_Neg) + L[_0] |= 0x80000000L; + } + diff --git a/sdk/tlibc/gdtoa/strtorx.c b/sdk/tlibc/gdtoa/strtorx.c new file mode 100644 index 0000000000..473642cfa0 --- /dev/null +++ b/sdk/tlibc/gdtoa/strtorx.c @@ -0,0 +1,123 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 2000 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + +#undef _0 +#undef _1 + +/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */ + +#ifdef IEEE_MC68k +#define _0 0 +#define _1 1 +#define _2 2 +#define _3 3 +#define _4 4 +#endif +#ifdef IEEE_8087 +#define _0 4 +#define _1 3 +#define _2 2 +#define _3 1 +#define _4 0 +#endif + + void +#ifdef KR_headers +ULtox(L, bits, exp, k) UShort *L; ULong *bits; Long exp; int k; +#else +ULtox(UShort *L, ULong *bits, Long exp, int k) +#endif +{ + switch(k & STRTOG_Retmask) { + case STRTOG_NoNumber: + case STRTOG_Zero: + L[0] = L[1] = L[2] = L[3] = L[4] = 0; + break; + + case STRTOG_Denormal: + L[_0] = 0; + goto normal_bits; + + case STRTOG_Normal: + case STRTOG_NaNbits: + L[_0] = exp + 0x3fff + 63; + normal_bits: + L[_4] = (UShort)bits[0]; + L[_3] = (UShort)(bits[0] >> 16); + L[_2] = (UShort)bits[1]; + L[_1] = (UShort)(bits[1] >> 16); + break; + + case STRTOG_NoMemory: + errno = ERANGE; + /* FALLTHROUGH */ + case STRTOG_Infinite: + L[_0] = 0x7fff; + L[_1] = 0x8000; + L[_2] = L[_3] = L[_4] = 0; + break; + + case STRTOG_NaN: + L[0] = ldus_QNAN0; + L[1] = ldus_QNAN1; + L[2] = ldus_QNAN2; + L[3] = ldus_QNAN3; + L[4] = ldus_QNAN4; + } + if (k & STRTOG_Neg) + L[_0] |= 0x8000; + } + + int +#ifdef KR_headers +strtorx(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L; +#else +strtorx(CONST char *s, char **sp, int rounding, void *L) +#endif +{ + static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; + FPI *fpi, fpi1; + ULong bits[2]; + Long exp; + int k; + + fpi = &fpi0; + if (rounding != FPI_Round_near) { + fpi1 = fpi0; + fpi1.rounding = rounding; + fpi = &fpi1; + } + k = strtodg(s, sp, fpi, &exp, bits); + ULtox((UShort*)L, bits, exp, k); + return k; + } diff --git a/sdk/tlibc/gdtoa/sum.c b/sdk/tlibc/gdtoa/sum.c new file mode 100644 index 0000000000..c6eb954f04 --- /dev/null +++ b/sdk/tlibc/gdtoa/sum.c @@ -0,0 +1,102 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + Bigint * +#ifdef KR_headers +sum(a, b) Bigint *a; Bigint *b; +#else +sum(Bigint *a, Bigint *b) +#endif +{ + Bigint *c; + ULong carry, *xc, *xa, *xb, *xe, y; +#ifdef Pack_32 + ULong z; +#endif + + if (a->wds < b->wds) { + c = b; b = a; a = c; + } + c = Balloc(a->k); + if (c == NULL) + return (NULL); + c->wds = a->wds; + carry = 0; + xa = a->x; + xb = b->x; + xc = c->x; + xe = xc + b->wds; +#ifdef Pack_32 + do { + y = (*xa & 0xffff) + (*xb & 0xffff) + carry; + carry = (y & 0x10000) >> 16; + z = (*xa++ >> 16) + (*xb++ >> 16) + carry; + carry = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } + while(xc < xe); + xe += a->wds - b->wds; + while(xc < xe) { + y = (*xa & 0xffff) + carry; + carry = (y & 0x10000) >> 16; + z = (*xa++ >> 16) + carry; + carry = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } +#else + do { + y = *xa++ + *xb++ + carry; + carry = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } + while(xc < xe); + xe += a->wds - b->wds; + while(xc < xe) { + y = *xa++ + carry; + carry = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } +#endif + if (carry) { + if (c->wds == c->maxwds) { + b = Balloc(c->k + 1); + if (b == NULL) + return (NULL); + Bcopy(b, c); + Bfree(c); + c = b; + } + c->x[c->wds++] = 1; + } + return c; + } diff --git a/sdk/tlibc/gdtoa/ulp.c b/sdk/tlibc/gdtoa/ulp.c new file mode 100644 index 0000000000..17e9f862c4 --- /dev/null +++ b/sdk/tlibc/gdtoa/ulp.c @@ -0,0 +1,70 @@ +/**************************************************************** + +The author of this software is David M. Gay. + +Copyright (C) 1998, 1999 by Lucent Technologies +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of Lucent or any of its entities +not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +****************************************************************/ + +/* Please send bug reports to David M. Gay (dmg at acm dot org, + * with " at " changed at "@" and " dot " changed to "."). */ + +#include "gdtoaimp.h" + + double +ulp +#ifdef KR_headers + (x) U *x; +#else + (U *x) +#endif +{ + Long L; + U a; + + L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; +#ifndef Sudden_Underflow + if (L > 0) { +#endif +#ifdef IBM + L |= Exp_msk1 >> 4; +#endif + word0(&a) = L; + word1(&a) = 0; +#ifndef Sudden_Underflow + } + else { + L = -L >> Exp_shift; + if (L < Exp_shift) { + word0(&a) = 0x80000 >> L; + word1(&a) = 0; + } + else { + word0(&a) = 0; + L -= Exp_shift; + word1(&a) = L >= 31 ? 1 : 1 << (31 - L); + } + } +#endif + return dval(&a); + } diff --git a/sdk/tlibc/gen/__memcpy_chk.cpp b/sdk/tlibc/gen/__memcpy_chk.cpp new file mode 100644 index 0000000000..6bffe1b514 --- /dev/null +++ b/sdk/tlibc/gen/__memcpy_chk.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __memcpy_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" void *__memcpy_chk(void *dest, const void *src, + size_t copy_amount, size_t dest_len) +{ + if (__predict_false(copy_amount > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return memcpy(dest, src, copy_amount); +} diff --git a/sdk/tlibc/gen/__memmove_chk.cpp b/sdk/tlibc/gen/__memmove_chk.cpp new file mode 100644 index 0000000000..6b3dbad063 --- /dev/null +++ b/sdk/tlibc/gen/__memmove_chk.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____memmove_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" void *__memmove_chk (void *dest, const void *src, + size_t len, size_t dest_len) +{ + if (__predict_false(len > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return memmove(dest, src, len); +} diff --git a/sdk/tlibc/gen/__mempcpy_chk.cpp b/sdk/tlibc/gen/__mempcpy_chk.cpp new file mode 100644 index 0000000000..4842ad4a5f --- /dev/null +++ b/sdk/tlibc/gen/__mempcpy_chk.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __mempcpy_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" void *__mempcpy_chk(void *dest, const void *src, + size_t copy_amount, size_t dest_len) +{ + if (__predict_false(copy_amount > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return mempcpy(dest, src, copy_amount); +} diff --git a/sdk/tlibc/gen/__memset_chk.cpp b/sdk/tlibc/gen/__memset_chk.cpp new file mode 100644 index 0000000000..399ebbd646 --- /dev/null +++ b/sdk/tlibc/gen/__memset_chk.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____memset_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" void *__memset_chk (void *dest, int c, size_t n, size_t dest_len) +{ + if (__predict_false(n > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return memset(dest, c, n); +} diff --git a/sdk/tlibc/gen/__stpcpy_chk.cpp b/sdk/tlibc/gen/__stpcpy_chk.cpp new file mode 100644 index 0000000000..07717acc28 --- /dev/null +++ b/sdk/tlibc/gen/__stpcpy_chk.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____stpcpy_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" char *__stpcpy_chk (char *dest, const char *src, size_t dest_len) { + // TODO: optimize so we don't scan src twice. + size_t src_len = strlen(src) + 1; + if (__predict_false(src_len > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return stpncpy(dest, src, src_len-1); +} diff --git a/sdk/tlibc/gen/__stpncpy_chk.cpp b/sdk/tlibc/gen/__stpncpy_chk.cpp new file mode 100644 index 0000000000..256c320c0f --- /dev/null +++ b/sdk/tlibc/gen/__stpncpy_chk.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____stpncpy_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" char *__stpncpy_chk (char *dest, const char *src, + size_t len, size_t dest_len) +{ + if (__predict_false(len > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return stpncpy(dest, src, len); +} diff --git a/sdk/tlibc/gen/__strcat_chk.cpp b/sdk/tlibc/gen/__strcat_chk.cpp new file mode 100644 index 0000000000..729250c770 --- /dev/null +++ b/sdk/tlibc/gen/__strcat_chk.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____strcat_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" size_t __strlen_chk(const char *s, size_t s_len); +extern "C" char *__strcat_chk (char *dest, const char *src, size_t dest_buf_size) { + char* save = dest; + size_t dest_len = __strlen_chk(dest, dest_buf_size); + + dest += dest_len; + dest_buf_size -= dest_len; + + while ((*dest++ = *src++) != '\0') { + dest_buf_size--; + if (__predict_false(dest_buf_size == 0)) { + /* TODO: add runtime error massage */ + abort(); + } + } + + return save; +} diff --git a/sdk/tlibc/gen/__strcpy_chk.cpp b/sdk/tlibc/gen/__strcpy_chk.cpp new file mode 100644 index 0000000000..ab30e4accd --- /dev/null +++ b/sdk/tlibc/gen/__strcpy_chk.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____strcpy_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" char *__strcpy_chk (char *dest, const char *src, size_t dest_len) { + // TODO: optimize so we don't scan src twice. + size_t src_len = strlen(src) + 1; + if (__predict_false(src_len > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return strncpy(dest, src, src_len-1); +} diff --git a/sdk/tlibc/gen/__strlen_chk.cpp b/sdk/tlibc/gen/__strlen_chk.cpp new file mode 100644 index 0000000000..2d11eb5230 --- /dev/null +++ b/sdk/tlibc/gen/__strlen_chk.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __strlen_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + * This strlen check is called if _FORTIFY_SOURCE is defined and + * greater than 0. + * + * This test is designed to detect code such as: + * + * int main() { + * char buf[10]; + * memcpy(buf, "1234567890", sizeof(buf)); + * size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE + * printf("%d\n", len); + * return 0; + * } + * + * or anytime strlen reads beyond an object boundary. + */ +extern "C" size_t __strlen_chk(const char *s, size_t s_len) { + size_t ret = strlen(s); + + if (__predict_false(ret >= s_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return ret; +} \ No newline at end of file diff --git a/sdk/tlibc/gen/__strncat_chk.cpp b/sdk/tlibc/gen/__strncat_chk.cpp new file mode 100644 index 0000000000..ac3e72f335 --- /dev/null +++ b/sdk/tlibc/gen/__strncat_chk.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____strncat_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" size_t __strlen_chk(const char *s, size_t s_len); +extern "C" char *__strncat_chk (char *dest, const char *src, + size_t len, size_t dest_buf_size) +{ + if (len == 0) { + return dest; + } + + size_t dest_len = __strlen_chk(dest, dest_buf_size); + char *d = dest + dest_len; + dest_buf_size -= dest_len; + + while (*src != '\0') { + *d++ = *src++; + len--; dest_buf_size--; + + if (__predict_false(dest_buf_size == 0)) { + /* TODO: add runtime error massage */ + abort(); + } + + if (len == 0) { + break; + } + } + + *d = '\0'; + return dest; +} diff --git a/sdk/tlibc/gen/__strncpy_chk.cpp b/sdk/tlibc/gen/__strncpy_chk.cpp new file mode 100644 index 0000000000..306f4bdd20 --- /dev/null +++ b/sdk/tlibc/gen/__strncpy_chk.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Runtime implementation of __builtin____strncpy_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" char *__strncpy_chk (char *dest, const char *src, + size_t len, size_t dest_len) +{ + if (__predict_false(len > dest_len)) { + /* TODO: add runtime error massage */ + abort(); + } + + return strncpy(dest, src, len); +} diff --git a/sdk/tlibc/gen/__vsnprintf_chk.cpp b/sdk/tlibc/gen/__vsnprintf_chk.cpp new file mode 100644 index 0000000000..02c72cd116 --- /dev/null +++ b/sdk/tlibc/gen/__vsnprintf_chk.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +/* + * Runtime implementation of __builtin____vsnprintf_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" int __vsnprintf_chk( + char *dest, + size_t supplied_size, + int /*flags*/, + size_t dest_len_from_compiler, + const char *format, + va_list va) +{ + if (__predict_false(supplied_size > dest_len_from_compiler)) { + /* TODO: add runtime error massage */ + abort(); + } + + return vsnprintf(dest, supplied_size, format, va); +} + +/* + * Runtime implementation of __builtin____snprintf_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" int __snprintf_chk( + char *dest, + size_t supplied_size, + int flags, + size_t dest_len_from_compiler, + const char *format, ...) +{ + va_list va; + int retval; + + va_start(va, format); + retval = __vsnprintf_chk(dest, supplied_size, flags, + dest_len_from_compiler, format, va); + va_end(va); + + return retval; +} diff --git a/sdk/tlibc/gen/__vsprintf_chk.cpp b/sdk/tlibc/gen/__vsprintf_chk.cpp new file mode 100644 index 0000000000..68e65d06ef --- /dev/null +++ b/sdk/tlibc/gen/__vsprintf_chk.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +/* + * Runtime implementation of __builtin____vsprintf_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" int __vsprintf_chk( + char *dest, + int /*flags*/, + size_t dest_len_from_compiler, + const char *format, + va_list va) +{ + int ret = vsnprintf(dest, dest_len_from_compiler, format, va); + + if ((size_t) ret >= dest_len_from_compiler) { + /* TODO: add runtime error massage */ + abort(); + } + + return ret; +} + +/* + * Runtime implementation of __builtin____sprintf_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + */ +extern "C" int __sprintf_chk( + char *dest, + int flags, + size_t dest_len_from_compiler, + const char *format, ...) +{ + va_list va; + int retval; + + va_start(va, format); + retval = __vsprintf_chk(dest, flags, + dest_len_from_compiler, format, va); + va_end(va); + + return retval; +} diff --git a/sdk/tlibc/gen/alloca.S b/sdk/tlibc/gen/alloca.S new file mode 100644 index 0000000000..255e604f24 --- /dev/null +++ b/sdk/tlibc/gen/alloca.S @@ -0,0 +1,67 @@ +/* $OpenBSD: alloca.S,v 1.6 2005/08/07 11:30:38 espie Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* like alloc, but automatic free in return */ + +#define _C_LABEL(x) x +#ifdef __i386__ +#define _ALIGN_TEXT .align 2, 0x90 +#else /* __x86_64__ */ +#define _ALIGN_TEXT .align 16, 0x90 +#endif +#define _ENTRY(x) .text; _ALIGN_TEXT; .globl x; .type x,@function; x: +#define ENTRY(y) _ENTRY(_C_LABEL(y)); + +ENTRY(alloca) +#ifdef __i386__ + popl %edx /* pop return addr */ + popl %eax /* pop amount to allocate */ + movl %esp,%ecx + addl $3,%eax /* round up to next word */ + andl $-4,%eax + subl %eax,%esp + movl %esp,%eax /* base of newly allocated space */ + pushl 8(%ecx) /* copy possible saved registers */ + pushl 4(%ecx) + pushl 0(%ecx) + pushl %eax /* dummy to pop at callsite */ + jmp *%edx /* "return" */ +#else /* __x86_64__ */ + popq %rdx + movq %rsp,%rcx + addq $15,%rdi /* round up to 16 bytes */ + andq $~15,%rdi + subq %rdi,%rsp + movq %rsp,%rax + jmp *%rdx +#endif diff --git a/sdk/tlibc/gen/assert.c b/sdk/tlibc/gen/assert.c new file mode 100644 index 0000000000..06a6b79b15 --- /dev/null +++ b/sdk/tlibc/gen/assert.c @@ -0,0 +1,52 @@ +/* $OpenBSD: assert.c,v 1.8 2005/08/08 08:05:33 espie Exp $ */ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +void +__assert(const char *file, int line, const char *func, const char *failedexpr) +{ +#if 0 + (void)fprintf(stderr, + "assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n", + failedexpr, file, line, func); +#else + (void)(file); + (void)(line); + (void)(func); + (void)(failedexpr); +#endif + + abort(); + /* NOTREACHED */ +} diff --git a/sdk/tlibc/gen/ctype_.c b/sdk/tlibc/gen/ctype_.c new file mode 100644 index 0000000000..378d9db911 --- /dev/null +++ b/sdk/tlibc/gen/ctype_.c @@ -0,0 +1,77 @@ +/* $OpenBSD: ctype_.c,v 1.10 2011/09/22 09:06:10 stsp Exp $ */ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include "ctype_private.h" + + +const char _C_ctype_[1 + CTYPE_NUM_CHARS] = { + 0, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|(char)_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _N, _N, _N, _N, _N, _N, _N, _N, + _N, _N, _P, _P, _P, _P, _P, _P, + _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _P, _P, _P, _P, _P, + _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _P, _P, _P, _P, _C, + + 0, 0, 0, 0, 0, 0, 0, 0, /* 80 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 88 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 90 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 98 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* A0 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* A8 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* B0 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* B8 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* C0 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* C8 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* D0 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* D8 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* E0 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* E8 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* F0 */ + 0, 0, 0, 0, 0, 0, 0, 0 /* F8 */ +}; + +const char *_ctype_ = _C_ctype_; diff --git a/sdk/tlibc/gen/ctype_private.h b/sdk/tlibc/gen/ctype_private.h new file mode 100644 index 0000000000..516e79e666 --- /dev/null +++ b/sdk/tlibc/gen/ctype_private.h @@ -0,0 +1,21 @@ +/* $OpenBSD: ctype_private.h,v 1.1 2005/08/08 05:53:00 espie Exp $ */ +/* Written by Marc Espie, public domain */ + +#define _U 0x01 +#define _L 0x02 +#define _N 0x04 +#define _S 0x08 +#define _P 0x10 +#define _C 0x20 +#define _X 0x40 +#define _B 0x80 + +#define CTYPE_NUM_CHARS 256 +extern const char _C_ctype_[]; +extern const short _C_toupper_[]; +extern const short _C_tolower_[]; + +extern const char *_ctype_; +extern const short *_tolower_tab_; +extern const short *_toupper_tab_; + diff --git a/sdk/tlibc/gen/errlist.c b/sdk/tlibc/gen/errlist.c new file mode 100644 index 0000000000..2852d1fc52 --- /dev/null +++ b/sdk/tlibc/gen/errlist.c @@ -0,0 +1,148 @@ +/* $OpenBSD: errlist.c,v 1.14 2009/11/24 09:22:22 guenther Exp $ */ +/* + * Copyright (c) 1982, 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define _sys_errlist sys_errlist +#define _sys_nerr sys_nerr + +const char *const + _sys_errlist[] = { + "Undefined error: 0", /* 0 - ENOERROR */ + "Operation not permitted", /* 1 - EPERM */ + "No such file or directory", /* 2 - ENOENT */ + "No such process", /* 3 - ESRCH */ + "Interrupted system call", /* 4 - EINTR */ + "Input/output error", /* 5 - EIO */ + "Device not configured", /* 6 - ENXIO */ + "Argument list too long", /* 7 - E2BIG */ + "Exec format error", /* 8 - ENOEXEC */ + "Bad file descriptor", /* 9 - EBADF */ + "No child processes", /* 10 - ECHILD */ + "Resource deadlock avoided", /* 11 - EDEADLK */ + "Cannot allocate memory", /* 12 - ENOMEM */ + "Permission denied", /* 13 - EACCES */ + "Bad address", /* 14 - EFAULT */ + "Block device required", /* 15 - ENOTBLK */ + "Device busy", /* 16 - EBUSY */ + "File exists", /* 17 - EEXIST */ + "Cross-device link", /* 18 - EXDEV */ + "Operation not supported by device", /* 19 - ENODEV */ + "Not a directory", /* 20 - ENOTDIR */ + "Is a directory", /* 21 - EISDIR */ + "Invalid argument", /* 22 - EINVAL */ + "Too many open files in system", /* 23 - ENFILE */ + "Too many open files", /* 24 - EMFILE */ + "Inappropriate ioctl for device", /* 25 - ENOTTY */ + "Text file busy", /* 26 - ETXTBSY */ + "File too large", /* 27 - EFBIG */ + "No space left on device", /* 28 - ENOSPC */ + "Illegal seek", /* 29 - ESPIPE */ + "Read-only file system", /* 30 - EROFS */ + "Too many links", /* 31 - EMLINK */ + "Broken pipe", /* 32 - EPIPE */ + +/* math software */ + "Numerical argument out of domain", /* 33 - EDOM */ + "Result too large", /* 34 - ERANGE */ + +/* non-blocking and interrupt i/o */ + "Resource temporarily unavailable", /* 35 - EAGAIN */ + /* 35 - EWOULDBLOCK */ + "Operation now in progress", /* 36 - EINPROGRESS */ + "Operation already in progress", /* 37 - EALREADY */ + +/* ipc/network software -- argument errors */ + "Socket operation on non-socket", /* 38 - ENOTSOCK */ + "Destination address required", /* 39 - EDESTADDRREQ */ + "Message too long", /* 40 - EMSGSIZE */ + "Protocol wrong type for socket", /* 41 - EPROTOTYPE */ + "Protocol not available", /* 42 - ENOPROTOOPT */ + "Protocol not supported", /* 43 - EPROTONOSUPPORT */ + "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */ + "Operation not supported", /* 45 - EOPNOTSUPP */ + "Protocol family not supported", /* 46 - EPFNOSUPPORT */ + /* 47 - EAFNOSUPPORT */ + "Address family not supported by protocol family", + "Address already in use", /* 48 - EADDRINUSE */ + "Can't assign requested address", /* 49 - EADDRNOTAVAIL */ + +/* ipc/network software -- operational errors */ + "Network is down", /* 50 - ENETDOWN */ + "Network is unreachable", /* 51 - ENETUNREACH */ + "Network dropped connection on reset", /* 52 - ENETRESET */ + "Software caused connection abort", /* 53 - ECONNABORTED */ + "Connection reset by peer", /* 54 - ECONNRESET */ + "No buffer space available", /* 55 - ENOBUFS */ + "Socket is already connected", /* 56 - EISCONN */ + "Socket is not connected", /* 57 - ENOTCONN */ + "Can't send after socket shutdown", /* 58 - ESHUTDOWN */ + "Too many references: can't splice", /* 59 - ETOOMANYREFS */ + "Operation timed out", /* 60 - ETIMEDOUT */ + "Connection refused", /* 61 - ECONNREFUSED */ + + "Too many levels of symbolic links", /* 62 - ELOOP */ + "File name too long", /* 63 - ENAMETOOLONG */ + +/* should be rearranged */ + "Host is down", /* 64 - EHOSTDOWN */ + "No route to host", /* 65 - EHOSTUNREACH */ + "Directory not empty", /* 66 - ENOTEMPTY */ + +/* quotas & mush */ + "Too many processes", /* 67 - EPROCLIM */ + "Too many users", /* 68 - EUSERS */ + "Disk quota exceeded", /* 69 - EDQUOT */ + +/* Network File System */ + "Stale NFS file handle", /* 70 - ESTALE */ + "Too many levels of remote in path", /* 71 - EREMOTE */ + "RPC struct is bad", /* 72 - EBADRPC */ + "RPC version wrong", /* 73 - ERPCMISMATCH */ + "RPC prog. not avail", /* 74 - EPROGUNAVAIL */ + "Program version wrong", /* 75 - EPROGMISMATCH */ + "Bad procedure for program", /* 76 - EPROCUNAVAIL */ + + "No locks available", /* 77 - ENOLCK */ + "Function not implemented", /* 78 - ENOSYS */ + "Inappropriate file type or format", /* 79 - EFTYPE */ + "Authentication error", /* 80 - EAUTH */ + "Need authenticator", /* 81 - ENEEDAUTH */ + "IPsec processing failure", /* 82 - EIPSEC */ + "Attribute not found", /* 83 - ENOATTR */ + "Illegal byte sequence", /* 84 - EILSEQ */ + "No medium found", /* 85 - ENOMEDIUM */ + "Wrong medium type", /* 86 - EMEDIUMTYPE */ + /* 87 - EOVERFLOW */ + "Value too large to be stored in data type", + "Operation canceled", /* 88 - ECANCELED */ + "Identifier removed", /* 89 - EIDRM */ + "No message of desired type", /* 90 - ENOMSG */ + "Not supported", /* 91 - ENOTSUP */ +}; +int _sys_nerr = { sizeof _sys_errlist/sizeof _sys_errlist[0] }; diff --git a/sdk/tlibc/gen/errno.c b/sdk/tlibc/gen/errno.c new file mode 100644 index 0000000000..9dc338d2e5 --- /dev/null +++ b/sdk/tlibc/gen/errno.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +extern int *get_errno_addr(void); + +int *__errno(void) +{ +/* + * get errno's address from TD section. + */ + return get_errno_addr(); +} + +#define __weak_alias(alias,sym) \ + __asm__(".weak " __STRING(alias) " ; " \ + __STRING(alias) " = " __STRING(sym)) +__weak_alias(__errno_location, __errno); diff --git a/sdk/tlibc/gen/infinity.c b/sdk/tlibc/gen/infinity.c new file mode 100644 index 0000000000..9a792d837a --- /dev/null +++ b/sdk/tlibc/gen/infinity.c @@ -0,0 +1,8 @@ +/* $OpenBSD: infinity.c,v 1.4 2005/08/07 11:30:38 espie Exp $ */ +/* infinity.c */ + +#include + +/* bytes for +Infinity on a 387 */ +char __infinity[] __attribute__((__aligned__(sizeof(double)))) = + { 0, 0, 0, 0, 0, 0, (char)0xf0, 0x7f }; diff --git a/sdk/tlibc/gen/isctype.c b/sdk/tlibc/gen/isctype.c new file mode 100644 index 0000000000..667987434e --- /dev/null +++ b/sdk/tlibc/gen/isctype.c @@ -0,0 +1,124 @@ +/* $OpenBSD: isctype.c,v 1.11 2005/08/08 08:05:34 espie Exp $ */ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +#include "ctype_private.h" + +#undef isalnum +int +isalnum(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L|_N))); +} + +#undef isalpha +int +isalpha(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L))); +} + +#undef isblank +int +isblank(int c) +{ + return (c == ' ' || c == '\t'); +} + +#undef iscntrl +int +iscntrl(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _C)); +} + +#undef isdigit +int +isdigit(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _N)); +} + +#undef isgraph +int +isgraph(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N))); +} + +#undef islower +int +islower(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _L)); +} + +#undef isprint +int +isprint(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N|_B))); +} + +#undef ispunct +int +ispunct(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _P)); +} + +#undef isspace +int +isspace(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _S)); +} + +#undef isupper +int +isupper(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _U)); +} + +#undef isxdigit +int +isxdigit(int c) +{ + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_N|_X))); +} + diff --git a/sdk/tlibc/gen/nan.c b/sdk/tlibc/gen/nan.c new file mode 100644 index 0000000000..e0bcb52834 --- /dev/null +++ b/sdk/tlibc/gen/nan.c @@ -0,0 +1,9 @@ +/* $OpenBSD: nan.c,v 1.1 2008/07/24 09:31:06 martynas Exp $ */ + +/* Written by Martynas Venckus. Public Domain. */ + +#include + +/* bytes for qNaN on an i386/amd64 (IEEE single format) */ +char __nan[] __attribute__((__aligned__(sizeof(float)))) = + { 0, 0, 0xc0, 0x7f }; diff --git a/sdk/tlibc/gen/sbrk.c b/sdk/tlibc/gen/sbrk.c new file mode 100644 index 0000000000..ac632438b0 --- /dev/null +++ b/sdk/tlibc/gen/sbrk.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include "trts_util.h" + + +SE_DECLSPEC_EXPORT size_t g_peak_heap_used = 0; +/* Please be aware of: sbrk is not thread safe by default. */ + +void* sbrk(intptr_t n) +{ + static size_t heap_used; + void *heap_ptr = NULL; + + void *heap_base = get_heap_base(); + size_t heap_size = get_heap_size(); + + if (!heap_base) + return (void *)(~(size_t)0); + + /* shrink the heap */ + if (n < 0) { + + if (heap_used <= INTPTR_MAX && ((intptr_t)heap_used + n) < 0) + return (void *)(~(size_t)0); + + heap_used += n; + heap_ptr = (void *)((size_t)heap_base + (size_t)heap_used); + + return heap_ptr; + } + + /* extend the heap */ + if ((heap_used + n) > heap_size) + return (void *)(~(size_t)0); + + heap_ptr = (void *)((size_t)heap_base + (size_t)heap_used); + heap_used += n; + + /* update g_peak_heap_used */ + g_peak_heap_used = (g_peak_heap_used < heap_used) ? heap_used : g_peak_heap_used; + + return heap_ptr; +} diff --git a/sdk/tlibc/gen/se_cpuid.c b/sdk/tlibc/gen/se_cpuid.c new file mode 100644 index 0000000000..d1255bdfd2 --- /dev/null +++ b/sdk/tlibc/gen/se_cpuid.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * File: sgx_cpuid.c + * Description: + * Get CPU info via Ocalls. + */ + +#include +#include + +#include "sgx_trts.h" +#include "sgx_cpuid.h" +#include "sgx_error.h" + +sgx_status_t sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf); + +sgx_status_t sgx_cpuidex(int cpuinfo[4], int leaf, int subleaf) +{ + if (cpuinfo == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + return sgx_oc_cpuidex(cpuinfo, leaf, subleaf); +} + +sgx_status_t sgx_cpuid(int cpuinfo[4], int leaf) +{ + return sgx_cpuidex(cpuinfo, leaf, 0); +} diff --git a/sdk/tlibc/gen/spinlock.c b/sdk/tlibc/gen/spinlock.c new file mode 100644 index 0000000000..8eb1799769 --- /dev/null +++ b/sdk/tlibc/gen/spinlock.c @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +static inline void _mm_pause(void) __attribute__((always_inline)); +static inline int _InterlockedExchange(int volatile * dst, int val) __attribute__((always_inline)); + +static inline void _mm_pause(void) +{ + __asm __volatile( + "pause" + ); +} + +static inline int _InterlockedExchange(int volatile * dst, int val) +{ + int res; + + __asm __volatile( + "lock xchg %2, %1;" + "mov %2, %0" + : "=m" (res) + : "m" (*dst), + "r" (val) + : "memory" + ); + + return (res); + +} + +uint32_t sgx_spin_lock(sgx_spinlock_t *lock) +{ + while(_InterlockedExchange((volatile int *)lock, 1) != 0) { + while (*lock) { + /* tell cpu we are spinning */ + _mm_pause(); + } + } + + return (0); +} + +uint32_t sgx_spin_unlock(sgx_spinlock_t *lock) +{ + *lock = 0; + + return (0); +} + diff --git a/sdk/tlibc/gen/tolower_.c b/sdk/tlibc/gen/tolower_.c new file mode 100644 index 0000000000..c48cd0ceb1 --- /dev/null +++ b/sdk/tlibc/gen/tolower_.c @@ -0,0 +1,56 @@ +/* $OpenBSD: tolower_.c,v 1.9 2005/08/08 08:05:34 espie Exp $ */ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include +#include +#include "ctype_private.h" + +const short _C_tolower_[1 + CTYPE_NUM_CHARS] = { + EOF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; + +const short *_tolower_tab_ = _C_tolower_; + +#undef tolower +int +tolower(int c) +{ + if ((unsigned int)c > 255) + return(c); + return((_tolower_tab_ + 1)[c]); +} diff --git a/sdk/tlibc/gen/toupper_.c b/sdk/tlibc/gen/toupper_.c new file mode 100644 index 0000000000..759404d99b --- /dev/null +++ b/sdk/tlibc/gen/toupper_.c @@ -0,0 +1,57 @@ +/* $OpenBSD: toupper_.c,v 1.10 2005/08/09 08:36:48 kevlo Exp $ */ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include +#include + +#include "ctype_private.h" + +const short _C_toupper_[1 + CTYPE_NUM_CHARS] = { + EOF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; + +const short *_toupper_tab_ = _C_toupper_; + +#undef toupper +int +toupper(int c) +{ + if ((unsigned int)c > 255) + return(c); + return((_toupper_tab_ + 1)[c]); +} diff --git a/sdk/tlibc/locale/btowc.c b/sdk/tlibc/locale/btowc.c new file mode 100644 index 0000000000..d6c1c195d8 --- /dev/null +++ b/sdk/tlibc/locale/btowc.c @@ -0,0 +1,54 @@ +/* $OpenBSD: btowc.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ + +/*- + * Copyright (c) 2002, 2003 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include + +wint_t btowc(int c) +{ + mbstate_t mbs; + char cc; + wchar_t wc; + + /* align with actual outputs of glibc btowc */ + if (c < 0 || c > SCHAR_MAX || c == EOF) + return (WEOF); + /* + * We expect mbrtowc() to return 0 or 1, hence the check for n > 1 + * which detects error return values as well as "impossible" byte + * counts. + */ + memset(&mbs, 0, sizeof(mbs)); + cc = (char)c; + if (mbrtowc(&wc, &cc, 1, &mbs) > 1) + return (WEOF); + return (wc); +} diff --git a/sdk/tlibc/locale/mblen.c b/sdk/tlibc/locale/mblen.c new file mode 100644 index 0000000000..259e8f582e --- /dev/null +++ b/sdk/tlibc/locale/mblen.c @@ -0,0 +1,48 @@ +/* $OpenBSD: mblen.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ + +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +int +mblen(const char *s, size_t n) +{ + static mbstate_t mbs; + size_t rval; + + if (s == NULL) { + /* No support for state dependent encodings. */ + memset(&mbs, 0, sizeof(mbs)); + return (0); + } + rval = mbrtowc(NULL, s, n, &mbs); + if (rval == (size_t)-1 || rval == (size_t)-2) + return (-1); + return ((int)rval); +} diff --git a/sdk/tlibc/locale/mbrlen.c b/sdk/tlibc/locale/mbrlen.c new file mode 100644 index 0000000000..0f05bd0721 --- /dev/null +++ b/sdk/tlibc/locale/mbrlen.c @@ -0,0 +1,39 @@ +/* $OpenBSD: mbrlen.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ + +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +size_t +mbrlen(const char * __restrict s, size_t n, mbstate_t * __restrict ps) +{ + static mbstate_t mbs; + + if (ps == NULL) + ps = &mbs; + return (mbrtowc(NULL, s, n, ps)); +} diff --git a/sdk/tlibc/locale/mbstowcs.c b/sdk/tlibc/locale/mbstowcs.c new file mode 100644 index 0000000000..b3699361f0 --- /dev/null +++ b/sdk/tlibc/locale/mbstowcs.c @@ -0,0 +1,43 @@ +/* $OpenBSD: mbstowcs.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ + +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +size_t +mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n) +{ + mbstate_t mbs; + const char *sp; + + memset(&mbs, 0, sizeof(mbs)); + sp = s; + return (mbsrtowcs(pwcs, &sp, n, &mbs)); +} diff --git a/sdk/tlibc/locale/mbtowc.c b/sdk/tlibc/locale/mbtowc.c new file mode 100644 index 0000000000..e2e6300fa8 --- /dev/null +++ b/sdk/tlibc/locale/mbtowc.c @@ -0,0 +1,49 @@ +/* $OpenBSD: mbtowc.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ + +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +int +mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n) +{ + static mbstate_t mbs; + size_t rval; + + if (s == NULL) { + /* No support for state dependent encodings. */ + memset(&mbs, 0, sizeof(mbs)); + return (0); + } + rval = mbrtowc(pwc, s, n, &mbs); + if (rval == (size_t)-1 || rval == (size_t)-2) + return (-1); + return ((int)rval); +} diff --git a/sdk/tlibc/locale/multibyte_citrus_none.c b/sdk/tlibc/locale/multibyte_citrus_none.c new file mode 100644 index 0000000000..d0f80509cb --- /dev/null +++ b/sdk/tlibc/locale/multibyte_citrus_none.c @@ -0,0 +1,179 @@ +/* $OpenBSD: multibyte_citrus.c,v 1.4 2012/12/05 23:20:00 deraadt Exp $ */ +/* $NetBSD: multibyte_amd1.c,v 1.7 2009/01/11 02:46:28 christos Exp $ */ +/* $OpenBSD: citrus_none.c,v 1.5 2013/03/07 18:12:31 stsp Exp $ */ +/* $NetBSD: citrus_none.c,v 1.18 2008/06/14 16:01:07 tnozaki Exp $ */ + +/*- + * Copyright (c)2002 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "internal/util.h" + +size_t mbsnrtowcs(wchar_t *, const char **, size_t, size_t, mbstate_t *); +size_t wcsnrtombs(char *, const wchar_t **, size_t, size_t, mbstate_t *); + +/* + * Convert an unsigned char value into a char value without relying on + * signed overflow behavior. + */ +static __inline char +wrapv(unsigned char ch) +{ + if (ch >= 0x80) + return ((int)ch - 0x100); + else + return (ch); +} + +int +mbsinit(const mbstate_t *ps) +{ + UNUSED(ps); + return (1); /* always initial state */ +} + +size_t +mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) +{ + /* pwc may be NULL */ + /* s may be NULL */ + /* ps appears to be unused */ + + UNUSED(ps); + + if (s == NULL) + return 0; + if (n == 0) + return (size_t)-2; + if (pwc) + *pwc = (wchar_t)(unsigned char)*s; + return (*s != '\0'); +} + +size_t +mbsrtowcs(wchar_t *dst, const char **src, size_t len, mbstate_t *ps) +{ + return (mbsnrtowcs(dst, src, SIZE_MAX, len, ps)); +} + +size_t +mbsnrtowcs(wchar_t *dst, const char **src, size_t nmc, size_t len, + mbstate_t *ps) +{ + size_t i; + + /* dst may be NULL */ + /* ps appears to be unused */ + + UNUSED(ps); + + if (dst == NULL) + return strnlen(*src, nmc); + + for (i = 0; i < nmc && i < len; i++) + if ((dst[i] = (wchar_t)(unsigned char)(*src)[i]) == L'\0') { + *src = NULL; + return (i); + } + + *src += i; + return (i); +} + +size_t +wcrtomb(char *s, wchar_t wc, mbstate_t *ps) +{ + /* s may be NULL */ + /* ps appears to be unused */ + + UNUSED(ps); + + if (s == NULL) + return (1); + + if (wc < 0 || wc > 0xff) { + errno = EILSEQ; + return (-1); + } + + *s = wrapv(wc); + return (1); +} + +size_t +wcsrtombs(char *dst, const wchar_t **src, size_t len, mbstate_t *ps) +{ + return (wcsnrtombs(dst, src, SIZE_MAX, len, ps)); +} + +size_t +wcsnrtombs(char *dst, const wchar_t **src, size_t nwc, size_t len, + mbstate_t *ps) +{ + size_t i; + + /* dst may be NULL */ + /* ps appears to be unused */ + + UNUSED(ps); + + if (dst == NULL) { + for (i = 0; i < nwc; i++) { + wchar_t wc = (*src)[i]; + if (wc < 0 || wc > 0xff) { + errno = EILSEQ; + return (-1); + } + if (wc == L'\0') + return (i); + } + return (i); + } + + for (i = 0; i < nwc && i < len; i++) { + wchar_t wc = (*src)[i]; + if (wc < 0 || wc > 0xff) { + *src += i; + errno = EILSEQ; + return (-1); + } + dst[i] = wrapv(wc); + if (wc == L'\0') { + *src = NULL; + return (i); + } + } + *src += i; + return (i); +} diff --git a/sdk/tlibc/locale/runetype.h b/sdk/tlibc/locale/runetype.h new file mode 100644 index 0000000000..8c362fe927 --- /dev/null +++ b/sdk/tlibc/locale/runetype.h @@ -0,0 +1,45 @@ +#ifndef _NB_RUNETYPE_H_ +#define _NB_RUNETYPE_H_ + +/* $OpenBSD: runetype.h,v 1.7 2012/12/05 23:20:00 deraadt Exp $ */ +/* $NetBSD: runetype.h,v 1.18 2003/08/07 16:43:04 agc Exp $ */ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)runetype.h 8.1 (Berkeley) 6/2/93 + */ + +#include + +typedef uint32_t rune_t; + + +#endif diff --git a/sdk/tlibc/locale/wcscoll.c b/sdk/tlibc/locale/wcscoll.c new file mode 100644 index 0000000000..a898e433ec --- /dev/null +++ b/sdk/tlibc/locale/wcscoll.c @@ -0,0 +1,41 @@ +/* $OpenBSD: wcscoll.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ +/* $NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $ */ + +/*- + * Copyright (c)2003 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Compare strings with using collating information. + */ +int +wcscoll(const wchar_t *s1, const wchar_t *s2) +{ + /* XXX: LC_COLLATE should be implemented. */ + return (wcscmp(s1, s2)); +} diff --git a/sdk/tlibc/locale/wcstombs.c b/sdk/tlibc/locale/wcstombs.c new file mode 100644 index 0000000000..e8054c401b --- /dev/null +++ b/sdk/tlibc/locale/wcstombs.c @@ -0,0 +1,43 @@ +/* $OpenBSD: wcstombs.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ + +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +size_t +wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n) +{ + mbstate_t mbs; + const wchar_t *pwcsp; + + memset(&mbs, 0, sizeof(mbs)); + pwcsp = pwcs; + return (wcsrtombs(s, &pwcsp, n, &mbs)); +} diff --git a/sdk/tlibc/locale/wcsxfrm.c b/sdk/tlibc/locale/wcsxfrm.c new file mode 100644 index 0000000000..ab1bfdf2d5 --- /dev/null +++ b/sdk/tlibc/locale/wcsxfrm.c @@ -0,0 +1,44 @@ +/* $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ +/* $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ +/* $NetBSD: multibyte_sb.c,v 1.4 2003/08/07 16:43:04 agc Exp $ */ + +/* + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +extern size_t wcslcpy(wchar_t *, const wchar_t *, size_t); + +size_t +wcsxfrm(wchar_t *dest, const wchar_t *src, size_t n) +{ + if (n == 0) + return wcslen(src); + return wcslcpy(dest, src, n); +} diff --git a/sdk/tlibc/locale/wctob.c b/sdk/tlibc/locale/wctob.c new file mode 100644 index 0000000000..ea1f40c58a --- /dev/null +++ b/sdk/tlibc/locale/wctob.c @@ -0,0 +1,43 @@ +/* $OpenBSD: wctob.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +int +wctob(wint_t c) +{ + mbstate_t mbs; + char buf[MB_LEN_MAX]; + + memset(&mbs, 0, sizeof(mbs)); + if (c == WEOF || wcrtomb(buf, c, &mbs) != 1) + return (EOF); + return ((unsigned char)*buf); +} diff --git a/sdk/tlibc/locale/wctomb.c b/sdk/tlibc/locale/wctomb.c new file mode 100644 index 0000000000..39f7a7c769 --- /dev/null +++ b/sdk/tlibc/locale/wctomb.c @@ -0,0 +1,47 @@ +/* $OpenBSD: wctomb.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */ + +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +int +wctomb(char *s, wchar_t wchar) +{ + static mbstate_t mbs; + size_t rval; + + if (s == NULL) { + /* No support for state dependent encodings. */ + memset(&mbs, 0, sizeof(mbs)); + return (0); + } + if ((rval = wcrtomb(s, wchar, &mbs)) == (size_t)-1) + return (-1); + return ((int)rval); +} diff --git a/sdk/tlibc/math/w_drem.c b/sdk/tlibc/math/w_drem.c new file mode 100644 index 0000000000..5038f5c409 --- /dev/null +++ b/sdk/tlibc/math/w_drem.c @@ -0,0 +1,14 @@ +/* + * drem() wrapper for remainder(). + * + * Written by J.T. Conklin, + * Placed into the Public Domain, 1994. + */ + +#include + +double +drem(double x, double y) +{ + return remainder(x, y); +} diff --git a/sdk/tlibc/math/w_dremf.c b/sdk/tlibc/math/w_dremf.c new file mode 100644 index 0000000000..f14d98f840 --- /dev/null +++ b/sdk/tlibc/math/w_dremf.c @@ -0,0 +1,14 @@ +/* + * dremf() wrapper for remainderf(). + * + * Written by J.T. Conklin, + * Placed into the Public Domain, 1994. + */ + +#include "math.h" + +float +dremf(float x, float y) +{ + return remainderf(x, y); +} diff --git a/sdk/tlibc/math/w_dreml.c b/sdk/tlibc/math/w_dreml.c new file mode 100644 index 0000000000..5537f164cd --- /dev/null +++ b/sdk/tlibc/math/w_dreml.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#if (LDBL_MANT_DIG > DBL_MANT_DIG) + +long double dreml(long double x, long double y) +{ + return remainderl(x, y); +} + +#endif diff --git a/sdk/tlibc/math/w_pow10.c b/sdk/tlibc/math/w_pow10.c new file mode 100644 index 0000000000..cc63e92e58 --- /dev/null +++ b/sdk/tlibc/math/w_pow10.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +double +pow10(double x) +{ + return pow(10, x); +} + diff --git a/sdk/tlibc/math/w_pow10f.c b/sdk/tlibc/math/w_pow10f.c new file mode 100644 index 0000000000..eb335fefdd --- /dev/null +++ b/sdk/tlibc/math/w_pow10f.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +float +pow10f(float x) +{ + return powf(10, x); +} + diff --git a/sdk/tlibc/math/w_pow10l.c b/sdk/tlibc/math/w_pow10l.c new file mode 100644 index 0000000000..f191c5155f --- /dev/null +++ b/sdk/tlibc/math/w_pow10l.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#if (LDBL_MANT_DIG > DBL_MANT_DIG) + +long double pow10l(long double x) +{ + return powl(10, x); +} + +#endif diff --git a/sdk/tlibc/stdio/fileext.h b/sdk/tlibc/stdio/fileext.h new file mode 100644 index 0000000000..2d07043024 --- /dev/null +++ b/sdk/tlibc/stdio/fileext.h @@ -0,0 +1,54 @@ +/* $OpenBSD: fileext.h,v 1.2 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: fileext.h,v 1.5 2003/07/18 21:46:41 nathanw Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +/* + * file extension + */ +struct __sfileext { + struct __sbuf _ub; /* ungetc buffer */ + struct wchar_io_data _wcio; /* wide char io status */ +}; + +#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base)) +#define _UB(fp) _EXT(fp)->_ub + +#define _FILEEXT_INIT(fp) \ +do { \ + _UB(fp)._base = NULL; \ + _UB(fp)._size = 0; \ + WCIO_INIT(fp); \ +} while (0) + +#define _FILEEXT_SETUP(f, fext) \ +do { \ + (f)->_ext._base = (unsigned char *)(fext); \ + _FILEEXT_INIT(f); \ +} while (0) diff --git a/sdk/tlibc/stdio/floatio.h b/sdk/tlibc/stdio/floatio.h new file mode 100644 index 0000000000..9769030844 --- /dev/null +++ b/sdk/tlibc/stdio/floatio.h @@ -0,0 +1,58 @@ +/* $OpenBSD: floatio.h,v 1.4 2008/09/07 20:36:08 martynas Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Floating point scanf/printf (input/output) definitions. + */ + +/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ +#define MAXEXP 308 +/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ +#define MAXFRACT 39 + +/* + * MAXEXPDIG is the maximum number of decimal digits needed to store a + * floating point exponent in the largest supported format. It should + * be ceil(log10(LDBL_MAX_10_EXP)) or, if hexadecimal floating point + * conversions are supported, ceil(log10(LDBL_MAX_EXP)). But since it + * is presently never greater than 5 in practice, we fudge it. + */ +#define MAXEXPDIG 6 +#if LDBL_MAX_EXP > 999999 +#error "floating point buffers too small" +#endif + +char *__hdtoa(double, const char *, int, int *, int *, char **); +char *__hldtoa(long double, const char *, int, int *, int *, char **); +char *__ldtoa(long double *, int, int, int *, int *, char **); diff --git a/sdk/tlibc/stdio/fvwrite.c b/sdk/tlibc/stdio/fvwrite.c new file mode 100644 index 0000000000..ff4dfaaed9 --- /dev/null +++ b/sdk/tlibc/stdio/fvwrite.c @@ -0,0 +1,217 @@ +/* $OpenBSD: fvwrite.c,v 1.17 2009/11/09 00:18:27 kurt Exp $ */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include "local.h" +#include "fvwrite.h" + +/* + * Write some memory regions. Return zero on success, EOF on error. + * + * This routine is large and unsightly, but most of the ugliness due + * to the three different kinds of output buffering is handled here. + */ +int +__sfvwrite(FILE *fp, struct __suio *uio) +{ + size_t len; + char *p; + struct __siov *iov; + int w, s; + char *nl; + int nlknown, nldist; + + if ((len = uio->uio_resid) == 0) + return (0); + /* make sure we can write */ + if (cantwrite(fp)) { + errno = EBADF; + return (EOF); + } + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n)) + + iov = uio->uio_iov; + p = iov->iov_base; + len = iov->iov_len; + iov++; +#define GETIOV(extra_work) \ + while (len == 0) { \ + extra_work; \ + p = iov->iov_base; \ + len = iov->iov_len; \ + iov++; \ + } + if (fp->_flags & __SNBF) { + goto err; + #if 0 + /* + * Unbuffered: write up to BUFSIZ bytes at a time. + */ + do { + GETIOV(;); + w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ)); + if (w <= 0) + goto err; + p += w; + len -= w; + } while ((uio->uio_resid -= w) != 0); + #endif + } else if ((fp->_flags & __SLBF) == 0) { + /* + * Fully buffered: fill partially full buffer, if any, + * and then flush. If there is no partial buffer, write + * one _bf._size byte chunk directly (without copying). + * + * String output is a special case: write as many bytes + * as fit, but pretend we wrote everything. This makes + * snprintf() return the number of bytes needed, rather + * than the number used, and avoids its write function + * (so that the write function can be invalid). + */ + do { + GETIOV(;); + if ((fp->_flags & (__SALC | __SSTR)) == + (__SALC | __SSTR) && fp->_w < len) { + size_t blen = fp->_p - fp->_bf._base; + unsigned char *_base; + int _size; + + /* Allocate space exponentially. */ + _size = fp->_bf._size; + do { + _size = (_size << 1) + 1; + } while (_size < blen + len); + _base = realloc(fp->_bf._base, _size + 1); + if (_base == NULL) + goto err; + fp->_w += _size - fp->_bf._size; + fp->_bf._base = _base; + fp->_bf._size = _size; + fp->_p = _base + blen; + } + w = fp->_w; + if (fp->_flags & __SSTR) { + if (len < w) + w = len; + COPY(w); /* copy MIN(fp->_w,len), */ + fp->_w -= w; + fp->_p += w; + w = len; /* but pretend copied all */ + } else if (fp->_p > fp->_bf._base && len > w) { + #if 0 + /* fill and flush */ + COPY(w); + /* fp->_w -= w; */ /* unneeded */ + fp->_p += w; + if (__sflush(fp)) + #endif + goto err; + } else if (len >= (w = fp->_bf._size)) { + #if 0 + /* write directly */ + w = (*fp->_write)(fp->_cookie, p, w); + if (w <= 0) + #endif + goto err; + } else { + /* fill and done */ + w = len; + COPY(w); + fp->_w -= w; + fp->_p += w; + } + p += w; + len -= w; + } while ((uio->uio_resid -= w) != 0); + } else { + /* + * Line buffered: like fully buffered, but we + * must check for newlines. Compute the distance + * to the first newline (including the newline), + * or `infinity' if there is none, then pretend + * that the amount to write is MIN(len,nldist). + */ + nlknown = 0; + nldist = 0; /* XXX just to keep gcc happy */ + do { + GETIOV(nlknown = 0); + if (!nlknown) { + nl = memchr((void *)p, '\n', len); + nldist = nl ? nl + 1 - p : len + 1; + nlknown = 1; + } + s = MIN(len, nldist); + w = fp->_w + fp->_bf._size; + if (fp->_p > fp->_bf._base && s > w) { + #if 0 + COPY(w); + /* fp->_w -= w; */ + fp->_p += w; + if (__sflush(fp)) + #endif + goto err; + } else if (s >= (w = fp->_bf._size)) { + #if 0 + w = (*fp->_write)(fp->_cookie, p, w); + if (w <= 0) + #endif + goto err; + } else { + w = s; + COPY(w); + fp->_w -= w; + fp->_p += w; + } + if ((nldist -= w) == 0) { + #if 0 + /* copied the newline: flush and forget */ + if (__sflush(fp)) + #endif + goto err; + //nlknown = 0; + } + p += w; + len -= w; + } while ((uio->uio_resid -= w) != 0); + } + return (0); + +err: + fp->_flags |= __SERR; + return (EOF); +} diff --git a/sdk/tlibc/stdio/fvwrite.h b/sdk/tlibc/stdio/fvwrite.h new file mode 100644 index 0000000000..928414e004 --- /dev/null +++ b/sdk/tlibc/stdio/fvwrite.h @@ -0,0 +1,49 @@ +/* $OpenBSD: fvwrite.h,v 1.6 2013/11/12 07:04:35 deraadt Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * I/O descriptors for __sfvwrite(). + */ +struct __siov { + void *iov_base; + size_t iov_len; +}; +struct __suio { + struct __siov *uio_iov; + int uio_iovcnt; + int uio_resid; +}; + +extern int __sfvwrite(FILE *, struct __suio *); + diff --git a/sdk/tlibc/stdio/local.h b/sdk/tlibc/stdio/local.h new file mode 100644 index 0000000000..39c52d0e3e --- /dev/null +++ b/sdk/tlibc/stdio/local.h @@ -0,0 +1,102 @@ +/* $OpenBSD: local.h,v 1.20 2011/11/08 18:30:42 guenther Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Information local to this implementation of stdio, + * in particular, macros and private variables. + */ + +#include +#include "wcio.h" + +#include "internal/arch.h" /* for SE_PAGE_SIZE */ + +#define FLOATING_POINT 1 +#define PRINTF_WIDE_CHAR 1 + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + +/* + * stdio state variables. + */ +typedef struct __sFILE { + unsigned char *_p; /* current position in (some) buffer */ + int _r; /* read space left for getc() */ + int _w; /* write space left for putc() */ + short _flags; /* flags, below; this FILE is free if 0 */ + short _file; /* fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ + + /* operations */ + int (*_read)(void *, char *, int); /* may for sscanf */ + + /* extension data, to avoid further ABI breakage */ + struct __sbuf _ext; +} FILE; + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ +/* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SALC 0x4000 /* allocate string space dynamically */ + +#include "fileext.h" + +int __vfprintf(FILE *, const char *, __va_list); +int __vfwprintf(FILE *, const wchar_t *, __va_list); + +#define __sferror(p) (((p)->_flags & __SERR) != 0) + +/* + * Return true if the given FILE cannot be written now. + */ +#define cantwrite(fp) 0 /* alreays writable for char array APIs */ + +/* Disable warnings */ diff --git a/sdk/tlibc/stdio/snprintf.c b/sdk/tlibc/stdio/snprintf.c new file mode 100644 index 0000000000..7b087e95dd --- /dev/null +++ b/sdk/tlibc/stdio/snprintf.c @@ -0,0 +1,68 @@ +/* $OpenBSD: snprintf.c,v 1.18 2011/05/30 18:48:33 martynas Exp $ */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include "local.h" + +/* PRINTFLIKE3 */ +int +snprintf(char *str, size_t n, const char *fmt, ...) +{ + va_list ap; + int ret; + char dummy; + FILE f; + struct __sfileext fext; + + /* While snprintf(3) specifies size_t stdio uses an int internally */ + if (n > INT_MAX) + n = INT_MAX; + /* Stdio internals do not deal correctly with zero length buffer */ + if (n == 0) { + str = &dummy; + n = 1; + } + _FILEEXT_SETUP(&f, &fext); + f._file = -1; + f._flags = __SWR | __SSTR; + f._bf._base = f._p = (unsigned char *)str; + f._bf._size = f._w = n - 1; + va_start(ap, fmt); + ret = __vfprintf(&f, fmt, ap); + va_end(ap); + *f._p = '\0'; + return (ret); +} diff --git a/sdk/tlibc/stdio/swprintf.c b/sdk/tlibc/stdio/swprintf.c new file mode 100644 index 0000000000..c3480436ef --- /dev/null +++ b/sdk/tlibc/stdio/swprintf.c @@ -0,0 +1,45 @@ +/* $OpenBSD: swprintf.c,v 1.5 2012/12/05 23:20:01 deraadt Exp $ */ +/* $NetBSD: swprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */ + +/*- + * Copyright (c) 2002 Tim J. Robbins + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +int +swprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt, ...) +{ + int ret; + va_list ap; + + va_start(ap, fmt); + ret = vswprintf(s, n, fmt, ap); + va_end(ap); + + return (ret); +} diff --git a/sdk/tlibc/stdio/vfprintf.c b/sdk/tlibc/stdio/vfprintf.c new file mode 100644 index 0000000000..1cfc2168e6 --- /dev/null +++ b/sdk/tlibc/stdio/vfprintf.c @@ -0,0 +1,1517 @@ +/* $OpenBSD: vfprintf.c,v 1.64 2013/11/01 19:05:10 guenther Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Actual printf innards. + * + * This code is large and complicated... + */ + +#include +//#include + +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "local.h" +#include "fvwrite.h" + +union arg { + int intarg; + unsigned int uintarg; + long longarg; + unsigned long ulongarg; + long long longlongarg; + unsigned long long ulonglongarg; + ptrdiff_t ptrdiffarg; + size_t sizearg; + ssize_t ssizearg; + intmax_t intmaxarg; + uintmax_t uintmaxarg; + void *pvoidarg; + char *pchararg; + signed char *pschararg; + short *pshortarg; + int *pintarg; + long *plongarg; + long long *plonglongarg; + ptrdiff_t *pptrdiffarg; + ssize_t *pssizearg; + intmax_t *pintmaxarg; +#ifdef FLOATING_POINT + double doublearg; + long double longdoublearg; +#endif +#ifdef PRINTF_WIDE_CHAR + wint_t wintarg; + wchar_t *pwchararg; +#endif +}; + +static int __find_arguments(const char *fmt0, va_list ap, union arg **argtable, + size_t *argtablesiz); +static int __grow_type_table(unsigned char **typetable, int *tablesize); + +/* + * Flush out all the vectors defined by the given uio, + * then reset it so that it can be reused. + */ +static int +__sprint(FILE *fp, struct __suio *uio) +{ + int err; + + if (uio->uio_resid == 0) { + uio->uio_iovcnt = 0; + return (0); + } + err = __sfvwrite(fp, uio); + uio->uio_resid = 0; + uio->uio_iovcnt = 0; + return (err); +} + +#ifdef PRINTF_WIDE_CHAR +/* + * Convert a wide character string argument for the %ls format to a multibyte + * string representation. If not -1, prec specifies the maximum number of + * bytes to output, and also means that we can't assume that the wide char + * string is null-terminated. + */ +static char * +__wcsconv(wchar_t *wcsarg, int prec) +{ + mbstate_t mbs; + char buf[MB_LEN_MAX]; + wchar_t *p; + char *convbuf; + size_t clen, nbytes; + + /* Allocate space for the maximum number of bytes we could output. */ + if (prec < 0) { + memset(&mbs, 0, sizeof(mbs)); + p = wcsarg; + nbytes = wcsrtombs(NULL, (const wchar_t **)&p, 0, &mbs); + if (nbytes == (size_t)-1) { + errno = EILSEQ; + return (NULL); + } + } else { + /* + * Optimisation: if the output precision is small enough, + * just allocate enough memory for the maximum instead of + * scanning the string. + */ + if (prec < 128) + nbytes = prec; + else { + nbytes = 0; + p = wcsarg; + memset(&mbs, 0, sizeof(mbs)); + for (;;) { + clen = wcrtomb(buf, *p++, &mbs); + if (clen == 0 || clen == (size_t)-1 || + nbytes + clen > (size_t)prec) + break; + nbytes += clen; + } + if (clen == (size_t)-1) { + errno = EILSEQ; + return (NULL); + } + } + } + if ((convbuf = (char *)malloc(nbytes + 1)) == NULL) + return (NULL); + + /* Fill the output buffer. */ + p = wcsarg; + memset(&mbs, 0, sizeof(mbs)); + if ((nbytes = wcsrtombs(convbuf, (const wchar_t **)&p, + nbytes, &mbs)) == (size_t)-1) { + free(convbuf); + errno = EILSEQ; + return (NULL); + } + convbuf[nbytes] = '\0'; + return (convbuf); +} +#endif + +#ifdef FLOATING_POINT +#include +//#include +#include +#include "floatio.h" + +#define DEFPREC 6 + +extern char *__dtoa(double, int, int, int *, int *, char **); +extern void __freedtoa(char *); +static int exponent(char *, int, int); +#endif /* FLOATING_POINT */ + +/* + * The size of the buffer we use as scratch space for integer + * conversions, among other things. Technically, we would need the + * most space for base 10 conversions with thousands' grouping + * characters between each pair of digits. 100 bytes is a + * conservative overestimate even for a 128-bit uintmax_t. + */ +#define BUF 100 + +#define STATIC_ARG_TBL_SIZE 8 /* Size of static argument table. */ + + +/* + * Macros for converting digits to letters and vice versa + */ +#define to_digit(c) ((c) - '0') +#define is_digit(c) ((unsigned)to_digit(c) <= 9) +#define to_char(n) ((n) + '0') + +/* + * Flags used during conversion. + */ +#define ALT 0x0001 /* alternate form */ +#define LADJUST 0x0004 /* left adjustment */ +#define LONGDBL 0x0008 /* long double */ +#define LONGINT 0x0010 /* long integer */ +#define LLONGINT 0x0020 /* long long integer */ +#define SHORTINT 0x0040 /* short integer */ +#define ZEROPAD 0x0080 /* zero (as opposed to blank) pad */ +#define FPT 0x0100 /* Floating point number */ +#define PTRINT 0x0200 /* (unsigned) ptrdiff_t */ +#define SIZEINT 0x0400 /* (signed) size_t */ +#define CHARINT 0x0800 /* 8 bit integer */ +#define MAXINT 0x1000 /* largest integer size (intmax_t) */ + +int +__vfprintf(FILE *fp, const char *fmt0, __va_list ap) +{ + char *fmt; /* format string */ + int ch; /* character from fmt */ + int n, n2; /* handy integers (short term usage) */ + char *cp; /* handy char pointer (short term usage) */ + struct __siov *iovp; /* for PRINT macro */ + int flags; /* flags as above */ + int ret; /* return value accumulator */ + int width; /* width from format (%8d), or 0 */ + int prec; /* precision from format; <0 for N/A */ + char sign; /* sign prefix (' ', '+', '-', or \0) */ + wchar_t wc; + mbstate_t ps; +#ifdef FLOATING_POINT + /* + * We can decompose the printed representation of floating + * point numbers into several parts, some of which may be empty: + * + * [+|-| ] [0x|0X] MMM . NNN [e|E|p|P] [+|-] ZZ + * A B ---C--- D E F + * + * A: 'sign' holds this value if present; '\0' otherwise + * B: ox[1] holds the 'x' or 'X'; '\0' if not hexadecimal + * C: cp points to the string MMMNNN. Leading and trailing + * zeros are not in the string and must be added. + * D: expchar holds this character; '\0' if no exponent, e.g. %f + * F: at least two digits for decimal, at least one digit for hex + */ + char *decimal_point = "."; + int signflag; /* true if float is negative */ + union { /* floating point arguments %[aAeEfFgG] */ + double dbl; + long double ldbl; + } fparg; + int expt; /* integer value of exponent */ + char expchar; /* exponent character: [eEpP\0] */ + char *dtoaend; /* pointer to end of converted digits */ + int expsize; /* character count for expstr */ + int lead; /* sig figs before decimal or group sep */ + int ndig; /* actual number of digits returned by dtoa */ + char expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */ + char *dtoaresult = NULL; +#endif + + uintmax_t _umax; /* integer arguments %[diouxX] */ + enum { OCT, DEC, HEX } base; /* base for %[diouxX] conversion */ + int dprec; /* a copy of prec if %[diouxX], 0 otherwise */ + int realsz; /* field size expanded by dprec */ + int size; /* size of converted field or string */ + const char *xdigs; /* digits for %[xX] conversion */ +#define NIOV 8 + struct __suio uio; /* output information: summary */ + struct __siov iov[NIOV];/* ... and individual io vectors */ + char buf[BUF]; /* buffer with space for digits of uintmax_t */ + char ox[2]; /* space for 0x; ox[1] is either x, X, or \0 */ + union arg *argtable; /* args, built due to positional arg */ + union arg statargtable[STATIC_ARG_TBL_SIZE]; + size_t argtablesiz; + int nextarg; /* 1-based argument index */ + va_list orgap; /* original argument pointer */ +#ifdef PRINTF_WIDE_CHAR + char *convbuf; /* buffer for wide to multi-byte conversion */ +#endif + + /* + * Choose PADSIZE to trade efficiency vs. size. If larger printf + * fields occur frequently, increase PADSIZE and make the initialisers + * below longer. + */ +#define PADSIZE 16 /* pad chunk size */ + static char blanks[PADSIZE] = + {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; + static char zeroes[PADSIZE] = + {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; + + static const char xdigs_lower[16] = "0123456789abcdef"; + static const char xdigs_upper[16] = "0123456789ABCDEF"; + + /* + * BEWARE, these `goto error' on error, and PAD uses `n'. + */ +#define PRINT(ptr, len) do { \ + iovp->iov_base = (ptr); \ + iovp->iov_len = (len); \ + uio.uio_resid += (len); \ + iovp++; \ + if (++uio.uio_iovcnt >= NIOV) { \ + if (__sprint(fp, &uio)) \ + goto error; \ + iovp = iov; \ + } \ +} while (0) +#define PAD(howmany, with) do { \ + if ((n = (howmany)) > 0) { \ + while (n > PADSIZE) { \ + PRINT(with, PADSIZE); \ + n -= PADSIZE; \ + } \ + PRINT(with, n); \ + } \ +} while (0) +#define PRINTANDPAD(p, ep, len, with) do { \ + n2 = (ep) - (p); \ + if (n2 > (len)) \ + n2 = (len); \ + if (n2 > 0) \ + PRINT((p), n2); \ + PAD((len) - (n2 > 0 ? n2 : 0), (with)); \ +} while(0) +#define FLUSH() do { \ + if (uio.uio_resid && __sprint(fp, &uio)) \ + goto error; \ + uio.uio_iovcnt = 0; \ + iovp = iov; \ +} while (0) + + /* + * To extend shorts properly, we need both signed and unsigned + * argument extraction methods. + */ +#define SARG() \ + ((intmax_t)(flags&MAXINT ? GETARG(intmax_t) : \ + flags&LLONGINT ? GETARG(long long) : \ + flags&LONGINT ? GETARG(long) : \ + flags&PTRINT ? GETARG(ptrdiff_t) : \ + flags&SIZEINT ? GETARG(ssize_t) : \ + flags&SHORTINT ? (short)GETARG(int) : \ + flags&CHARINT ? (signed char)GETARG(int) : \ + GETARG(int))) +#define UARG() \ + ((uintmax_t)(flags&MAXINT ? GETARG(uintmax_t) : \ + flags&LLONGINT ? GETARG(unsigned long long) : \ + flags&LONGINT ? GETARG(unsigned long) : \ + flags&PTRINT ? (uintptr_t)GETARG(ptrdiff_t) : /* XXX */ \ + flags&SIZEINT ? GETARG(size_t) : \ + flags&SHORTINT ? (unsigned short)GETARG(int) : \ + flags&CHARINT ? (unsigned char)GETARG(int) : \ + GETARG(unsigned int))) + + /* + * Append a digit to a value and check for overflow. + */ +#define APPEND_DIGIT(val, dig) do { \ + if ((val) > INT_MAX / 10) \ + goto overflow; \ + (val) *= 10; \ + if ((val) > INT_MAX - to_digit((dig))) \ + goto overflow; \ + (val) += to_digit((dig)); \ +} while (0) + + /* + * Get * arguments, including the form *nn$. Preserve the nextarg + * that the argument can be gotten once the type is determined. + */ +#define GETASTER(val) \ + n2 = 0; \ + cp = fmt; \ + while (is_digit(*cp)) { \ + APPEND_DIGIT(n2, *cp); \ + cp++; \ + } \ + if (*cp == '$') { \ + int hold = nextarg; \ + if (argtable == NULL) { \ + argtable = statargtable; \ + __find_arguments(fmt0, orgap, &argtable, &argtablesiz); \ + } \ + nextarg = n2; \ + val = GETARG(int); \ + nextarg = hold; \ + fmt = ++cp; \ + } else { \ + val = GETARG(int); \ + } + +/* +* Get the argument indexed by nextarg. If the argument table is +* built, use it to get the argument. If its not, get the next +* argument (and arguments must be gotten sequentially). +*/ +#define GETARG(type) \ + ((argtable != NULL) ? *((type*)(&argtable[nextarg++])) : \ + (nextarg++, va_arg(ap, type))) + + _SET_ORIENTATION(fp, -1); + /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ + if (cantwrite(fp)) { + errno = EBADF; + return (EOF); + } + + /* optimise fprintf(stderr) (and other unbuffered Unix files) */ + if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && + fp->_file >= 0) { + //return (__sbprintf(fp, fmt0, ap)); + errno = EBADF; + return (EOF); + } + + fmt = (char *)fmt0; + argtable = NULL; + nextarg = 1; + va_copy(orgap, ap); + uio.uio_iov = iovp = iov; + uio.uio_resid = 0; + uio.uio_iovcnt = 0; + ret = 0; +#ifdef PRINTF_WIDE_CHAR + convbuf = NULL; +#endif + + memset(&ps, 0, sizeof(ps)); + /* + * Scan the format for conversions (`%' character). + */ + for (;;) { + cp = fmt; + while ((n = mbrtowc(&wc, fmt, MB_CUR_MAX, &ps)) > 0) { + fmt += n; + if (wc == '%') { + fmt--; + break; + } + } + if (fmt != cp) { + ptrdiff_t m = fmt - cp; + if (m < 0 || m > INT_MAX - ret) + goto overflow; + PRINT(cp, m); + ret += m; + } + if (n <= 0) + goto done; + fmt++; /* skip over '%' */ + + flags = 0; + dprec = 0; + width = 0; + prec = -1; + sign = '\0'; + ox[1] = '\0'; + +rflag: ch = *fmt++; +reswitch: switch (ch) { + case ' ': + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (!sign) + sign = ' '; + goto rflag; + case '#': + flags |= ALT; + goto rflag; + case '\'': + /* grouping not implemented */ + goto rflag; + case '*': + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + GETASTER(width); + if (width >= 0) + goto rflag; + if (width == INT_MIN) + goto overflow; + width = -width; + /* FALLTHROUGH */ + case '-': + flags |= LADJUST; + goto rflag; + case '+': + sign = '+'; + goto rflag; + case '.': + if ((ch = *fmt++) == '*') { + GETASTER(n); + prec = n < 0 ? -1 : n; + goto rflag; + } + n = 0; + while (is_digit(ch)) { + APPEND_DIGIT(n, ch); + ch = *fmt++; + } + if (ch == '$') { + nextarg = n; + if (argtable == NULL) { + argtable = statargtable; + __find_arguments(fmt0, orgap, + &argtable, &argtablesiz); + } + goto rflag; + } + prec = n; + goto reswitch; + case '0': + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + flags |= ZEROPAD; + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + APPEND_DIGIT(n, ch); + ch = *fmt++; + } while (is_digit(ch)); + if (ch == '$') { + nextarg = n; + if (argtable == NULL) { + argtable = statargtable; + __find_arguments(fmt0, orgap, + &argtable, &argtablesiz); + } + goto rflag; + } + width = n; + goto reswitch; +#ifdef FLOATING_POINT + case 'L': + flags |= LONGDBL; + goto rflag; +#endif + case 'h': + if (*fmt == 'h') { + fmt++; + flags |= CHARINT; + } else { + flags |= SHORTINT; + } + goto rflag; + case 'j': + flags |= MAXINT; + goto rflag; + case 'l': + if (*fmt == 'l') { + fmt++; + flags |= LLONGINT; + } else { + flags |= LONGINT; + } + goto rflag; + case 'q': + flags |= LLONGINT; + goto rflag; + case 't': + flags |= PTRINT; + goto rflag; + case 'z': + flags |= SIZEINT; + goto rflag; + case 'c': +#ifdef PRINTF_WIDE_CHAR + if (flags & LONGINT) { + mbstate_t mbs; + size_t mbseqlen; + + memset(&mbs, 0, sizeof(mbs)); + mbseqlen = wcrtomb(buf, + (wchar_t)GETARG(wint_t), &mbs); + if (mbseqlen == (size_t)-1) { + fp->_flags |= __SERR; + errno = EILSEQ; + goto error; + } + cp = buf; + size = (int)mbseqlen; + } else { +#endif + *(cp = buf) = GETARG(int); + size = 1; +#ifdef PRINTF_WIDE_CHAR + } +#endif + sign = '\0'; + break; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + _umax = SARG(); + if ((intmax_t)_umax < 0) { + _umax = -_umax; + sign = '-'; + } + base = DEC; + goto number; +#ifdef FLOATING_POINT + case 'a': + case 'A': + if (ch == 'a') { + ox[1] = 'x'; + xdigs = xdigs_lower; + expchar = 'p'; + } else { + ox[1] = 'X'; + xdigs = xdigs_upper; + expchar = 'P'; + } + if (prec >= 0) + prec++; + if (dtoaresult) + __freedtoa(dtoaresult); + if (flags & LONGDBL) { + fparg.ldbl = GETARG(long double); + dtoaresult = cp = + __hldtoa(fparg.ldbl, xdigs, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + } else { + fparg.dbl = GETARG(double); + dtoaresult = cp = + __hdtoa(fparg.dbl, xdigs, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + } + if (prec < 0) + prec = dtoaend - cp; + if (expt == INT_MAX) + ox[1] = '\0'; + goto fp_common; + case 'e': + case 'E': + expchar = ch; + if (prec < 0) /* account for digit before decpt */ + prec = DEFPREC + 1; + else + prec++; + goto fp_begin; + case 'f': + case 'F': + expchar = '\0'; + goto fp_begin; + case 'g': + case 'G': + expchar = ch - ('g' - 'e'); + if (prec == 0) + prec = 1; +fp_begin: + if (prec < 0) + prec = DEFPREC; + if (dtoaresult) + __freedtoa(dtoaresult); + if (flags & LONGDBL) { + fparg.ldbl = GETARG(long double); + dtoaresult = cp = + __ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + } else { + fparg.dbl = GETARG(double); + dtoaresult = cp = + __dtoa(fparg.dbl, expchar ? 2 : 3, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + if (expt == 9999) + expt = INT_MAX; + } +fp_common: + if (signflag) + sign = '-'; + if (expt == INT_MAX) { /* inf or nan */ + if (*cp == 'N') { + cp = (ch >= 'a') ? "nan" : "NAN"; + sign = '\0'; + } else + cp = (ch >= 'a') ? "inf" : "INF"; + size = 3; + flags &= ~ZEROPAD; + break; + } + flags |= FPT; + ndig = dtoaend - cp; + if (ch == 'g' || ch == 'G') { + if (expt > -4 && expt <= prec) { + /* Make %[gG] smell like %[fF] */ + expchar = '\0'; + if (flags & ALT) + prec -= expt; + else + prec = ndig - expt; + if (prec < 0) + prec = 0; + } else { + /* + * Make %[gG] smell like %[eE], but + * trim trailing zeroes if no # flag. + */ + if (!(flags & ALT)) + prec = ndig; + } + } + if (expchar) { + expsize = exponent(expstr, expt - 1, expchar); + size = expsize + prec; + if (prec > 1 || flags & ALT) + ++size; + } else { + /* space for digits before decimal point */ + if (expt > 0) + size = expt; + else /* "0" */ + size = 1; + /* space for decimal pt and following digits */ + if (prec || flags & ALT) + size += prec + 1; + lead = expt; + } + break; +#endif /* FLOATING_POINT */ + case 'n': + abort(); +#if 0 + if (flags & LLONGINT) + *GETARG(long long *) = ret; + else if (flags & LONGINT) + *GETARG(long *) = ret; + else if (flags & SHORTINT) + *GETARG(short *) = ret; + else if (flags & CHARINT) + *GETARG(signed char *) = ret; + else if (flags & PTRINT) + *GETARG(ptrdiff_t *) = ret; + else if (flags & SIZEINT) + *GETARG(ssize_t *) = ret; + else if (flags & MAXINT) + *GETARG(intmax_t *) = ret; + else + *GETARG(int *) = ret; + continue; /* no output */ +#endif + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + _umax = UARG(); + base = OCT; + goto nosign; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + /* NOSTRICT */ + _umax = (size_t)GETARG(void *); + base = HEX; + xdigs = xdigs_lower; + ox[1] = 'x'; + goto nosign; + case 's': +#ifdef PRINTF_WIDE_CHAR + if (flags & LONGINT) { + wchar_t *wcp; + + if (convbuf != NULL) { + free(convbuf); + convbuf = NULL; + } + if ((wcp = GETARG(wchar_t *)) == NULL) { + cp = "(null)"; + } else { + convbuf = __wcsconv(wcp, prec); + if (convbuf == NULL) { + fp->_flags = __SERR; + goto error; + } + cp = convbuf; + } + } else +#endif /* PRINTF_WIDE_CHAR */ + if ((cp = GETARG(char *)) == NULL) + cp = "(null)"; + if (prec >= 0) { + /* + * can't use strlen; can only look for the + * NUL in the first `prec' characters, and + * strlen() will go further. + */ + char *p = (char *)memchr(cp, 0, prec); + + size = p ? (p - cp) : prec; + } else { + size_t len; + + if ((len = strlen(cp)) > INT_MAX) + goto overflow; + size = (int)len; + } + sign = '\0'; + break; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + _umax = UARG(); + base = DEC; + goto nosign; + case 'X': + xdigs = xdigs_upper; + goto hex; + case 'x': + xdigs = xdigs_lower; +hex: _umax = UARG(); + base = HEX; + /* leading 0x/X only if non-zero */ + if (flags & ALT && _umax != 0) + ox[1] = ch; + + /* unsigned conversions */ +nosign: sign = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ +number: if ((dprec = prec) >= 0) + flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + cp = buf + BUF; + if (_umax != 0 || prec != 0) { + /* + * Unsigned mod is hard, and unsigned mod + * by a constant is easier than that by + * a variable; hence this switch. + */ + switch (base) { + case OCT: + do { + *--cp = to_char(_umax & 7); + _umax >>= 3; + } while (_umax); + /* handle octal leading 0 */ + if (flags & ALT && *cp != '0') + *--cp = '0'; + break; + + case DEC: + /* many numbers are 1 digit */ + while (_umax >= 10) { + *--cp = to_char(_umax % 10); + _umax /= 10; + } + *--cp = to_char(_umax); + break; + + case HEX: + do { + *--cp = xdigs[_umax & 15]; + _umax >>= 4; + } while (_umax); + break; + + default: + cp = "bug in vfprintf: bad base"; + size = strlen(cp); + goto skipsize; + } + } + size = buf + BUF - cp; + if (size > BUF) /* should never happen */ + abort(); + skipsize: + break; + default: /* "%?" prints ?, unless ? is NUL */ + if (ch == '\0') + goto done; + /* pretend it was %c with argument ch */ + cp = buf; + *cp = ch; + size = 1; + sign = '\0'; + break; + } + + /* + * All reasonable formats wind up here. At this point, `cp' + * points to a string which (if not flags&LADJUST) should be + * padded out to `width' places. If flags&ZEROPAD, it should + * first be prefixed by any sign or other prefix; otherwise, + * it should be blank padded before the prefix is emitted. + * After any left-hand padding and prefixing, emit zeroes + * required by a decimal %[diouxX] precision, then print the + * string proper, then emit zeroes required by any leftover + * floating precision; finally, if LADJUST, pad with blanks. + * + * Compute actual size, so we know how much to pad. + * size excludes decimal prec; realsz includes it. + */ + realsz = dprec > size ? dprec : size; + if (sign) + realsz++; + if (ox[1]) + realsz+= 2; + + /* right-adjusting blank padding */ + if ((flags & (LADJUST|ZEROPAD)) == 0) + PAD(width - realsz, blanks); + + /* prefix */ + if (sign) + PRINT(&sign, 1); + if (ox[1]) { /* ox[1] is either x, X, or \0 */ + ox[0] = '0'; + PRINT(ox, 2); + } + + /* right-adjusting zero padding */ + if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) + PAD(width - realsz, zeroes); + + /* leading zeroes from decimal precision */ + PAD(dprec - size, zeroes); + + /* the string or number proper */ +#ifdef FLOATING_POINT + if ((flags & FPT) == 0) { + PRINT(cp, size); + } else { /* glue together f_p fragments */ + if (!expchar) { /* %[fF] or sufficiently short %[gG] */ + if (expt <= 0) { + PRINT(zeroes, 1); + if (prec || flags & ALT) + PRINT(decimal_point, 1); + PAD(-expt, zeroes); + /* already handled initial 0's */ + prec += expt; + } else { + PRINTANDPAD(cp, dtoaend, lead, zeroes); + cp += lead; + if (prec || flags & ALT) + PRINT(decimal_point, 1); + } + PRINTANDPAD(cp, dtoaend, prec, zeroes); + } else { /* %[eE] or sufficiently long %[gG] */ + if (prec > 1 || flags & ALT) { + buf[0] = *cp++; + buf[1] = *decimal_point; + PRINT(buf, 2); + PRINT(cp, ndig-1); + PAD(prec - ndig, zeroes); + } else { /* XeYYY */ + PRINT(cp, 1); + } + PRINT(expstr, expsize); + } + } +#else + PRINT(cp, size); +#endif + /* left-adjusting padding (always blank) */ + if (flags & LADJUST) + PAD(width - realsz, blanks); + + /* finally, adjust ret */ + if (width < realsz) + width = realsz; + if (width > INT_MAX - ret) + goto overflow; + ret += width; + + FLUSH(); /* copy out the I/O vectors */ + } +done: + FLUSH(); +error: + va_end(orgap); + if (__sferror(fp)) + ret = -1; + goto finish; + +overflow: + errno = ENOMEM; + ret = -1; + +finish: +#ifdef PRINTF_WIDE_CHAR + if (convbuf) + free(convbuf); +#endif +#ifdef FLOATING_POINT + if (dtoaresult) + __freedtoa(dtoaresult); +#endif + if (argtable != NULL && argtable != statargtable) { + free(argtable); + argtable = NULL; + } + return (ret); +} + +/* + * Type ids for argument type table. + */ +#define T_UNUSED 0 +#define T_SHORT 1 +#define T_U_SHORT 2 +#define TP_SHORT 3 +#define T_INT 4 +#define T_U_INT 5 +#define TP_INT 6 +#define T_LONG 7 +#define T_U_LONG 8 +#define TP_LONG 9 +#define T_LLONG 10 +#define T_U_LLONG 11 +#define TP_LLONG 12 +#define T_DOUBLE 13 +#define T_LONG_DOUBLE 14 +#define TP_CHAR 15 +#define TP_VOID 16 +#define T_PTRINT 17 +#define TP_PTRINT 18 +#define T_SIZEINT 19 +#define T_SSIZEINT 20 +#define TP_SSIZEINT 21 +#define T_MAXINT 22 +#define T_MAXUINT 23 +#define TP_MAXINT 24 +#define T_CHAR 25 +#define T_U_CHAR 26 +#define T_WINT 27 +#define TP_WCHAR 28 + +/* + * Find all arguments when a positional parameter is encountered. Returns a + * table, indexed by argument number, of pointers to each arguments. The + * initial argument table should be an array of STATIC_ARG_TBL_SIZE entries. + * It will be replaced with a mmap-ed one if it overflows (malloc cannot be + * used since we are attempting to make snprintf thread safe, and alloca is + * problematic since we have nested functions..) + */ +static int +__find_arguments(const char *fmt0, va_list ap, union arg **argtable, + size_t *argtablesiz) +{ + char *fmt; /* format string */ + int ch; /* character from fmt */ + int n, n2; /* handy integer (short term usage) */ + char *cp; /* handy char pointer (short term usage) */ + int flags; /* flags as above */ + unsigned char *typetable; /* table of types */ + unsigned char stattypetable[STATIC_ARG_TBL_SIZE]; + int tablesize; /* current size of type table */ + int tablemax; /* largest used index in table */ + int nextarg; /* 1-based argument index */ + int ret = 0; /* return value */ + int rc = 0; /* save return code from __grow_type_table */ + wchar_t wc; + mbstate_t ps; + +#define check_rc(rc) if (rc == -1) goto overflow + + /* + * Add an argument type to the table, expanding if necessary. + */ +#define ADDTYPE(type) \ + ((nextarg >= tablesize) ? \ + rc = __grow_type_table(&typetable, &tablesize) : 0, \ + (nextarg > tablemax) ? tablemax = nextarg : 0, \ + rc == -1 ? 0 : (typetable[nextarg++] = type)) + +#define ADDTYPE_CHECK(type) \ + ADDTYPE(type); check_rc(rc) + +#define ADDSARG() \ + ((flags&MAXINT) ? ADDTYPE(T_MAXINT) : \ + ((flags&PTRINT) ? ADDTYPE(T_PTRINT) : \ + ((flags&SIZEINT) ? ADDTYPE(T_SSIZEINT) : \ + ((flags&LLONGINT) ? ADDTYPE(T_LLONG) : \ + ((flags&LONGINT) ? ADDTYPE(T_LONG) : \ + ((flags&SHORTINT) ? ADDTYPE(T_SHORT) : \ + ((flags&CHARINT) ? ADDTYPE(T_CHAR) : ADDTYPE(T_INT)))))))); \ + check_rc(rc); + +#define ADDUARG() \ + ((flags&MAXINT) ? ADDTYPE(T_MAXUINT) : \ + ((flags&PTRINT) ? ADDTYPE(T_PTRINT) : \ + ((flags&SIZEINT) ? ADDTYPE(T_SIZEINT) : \ + ((flags&LLONGINT) ? ADDTYPE(T_U_LLONG) : \ + ((flags&LONGINT) ? ADDTYPE(T_U_LONG) : \ + ((flags&SHORTINT) ? ADDTYPE(T_U_SHORT) : \ + ((flags&CHARINT) ? ADDTYPE(T_U_CHAR) : ADDTYPE(T_U_INT)))))))); \ + check_rc(rc); + + /* + * Add * arguments to the type array. + */ +#define ADDASTER() \ + n2 = 0; \ + cp = fmt; \ + while (is_digit(*cp)) { \ + APPEND_DIGIT(n2, *cp); \ + cp++; \ + } \ + if (*cp == '$') { \ + int hold = nextarg; \ + nextarg = n2; \ + ADDTYPE_CHECK(T_INT); \ + nextarg = hold; \ + fmt = ++cp; \ + } else { \ + ADDTYPE_CHECK(T_INT); \ + } + fmt = (char *)fmt0; + typetable = stattypetable; + tablesize = STATIC_ARG_TBL_SIZE; + tablemax = 0; + nextarg = 1; + memset(typetable, T_UNUSED, STATIC_ARG_TBL_SIZE); + memset(&ps, 0, sizeof(ps)); + + /* + * Scan the format for conversions (`%' character). + */ + for (;;) { + cp = fmt; + while ((n = mbrtowc(&wc, fmt, MB_CUR_MAX, &ps)) > 0) { + fmt += n; + if (wc == '%') { + fmt--; + break; + } + } + if (n <= 0) + goto done; + fmt++; /* skip over '%' */ + + flags = 0; + +rflag: ch = *fmt++; +reswitch: switch (ch) { + case ' ': + case '#': + case '\'': + goto rflag; + case '*': + ADDASTER(); + goto rflag; + case '-': + case '+': + goto rflag; + case '.': + if ((ch = *fmt++) == '*') { + ADDASTER(); + goto rflag; + } + while (is_digit(ch)) { + ch = *fmt++; + } + goto reswitch; + case '0': + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + APPEND_DIGIT(n ,ch); + ch = *fmt++; + } while (is_digit(ch)); + if (ch == '$') { + nextarg = n; + goto rflag; + } + goto reswitch; +#ifdef FLOATING_POINT + case 'L': + flags |= LONGDBL; + goto rflag; +#endif + case 'h': + if (*fmt == 'h') { + fmt++; + flags |= CHARINT; + } else { + flags |= SHORTINT; + } + goto rflag; + case 'j': + flags |= MAXINT; + goto rflag; + case 'l': + if (*fmt == 'l') { + fmt++; + flags |= LLONGINT; + } else { + flags |= LONGINT; + } + goto rflag; + case 'q': + flags |= LLONGINT; + goto rflag; + case 't': + flags |= PTRINT; + goto rflag; + case 'z': + flags |= SIZEINT; + goto rflag; + case 'c': +#ifdef PRINTF_WIDE_CHAR + if (flags & LONGINT) + ADDTYPE_CHECK(T_WINT); + else +#endif + ADDTYPE_CHECK(T_INT); + break; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + ADDSARG(); + break; +#ifdef FLOATING_POINT + case 'a': + case 'A': + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + if (flags & LONGDBL) + ADDTYPE_CHECK(T_LONG_DOUBLE); + else + ADDTYPE_CHECK(T_DOUBLE); + break; +#endif /* FLOATING_POINT */ + case 'n': + if (flags & LLONGINT) + ADDTYPE_CHECK(TP_LLONG); + else if (flags & LONGINT) + ADDTYPE_CHECK(TP_LONG); + else if (flags & SHORTINT) + ADDTYPE_CHECK(TP_SHORT); + else if (flags & PTRINT) + ADDTYPE_CHECK(TP_PTRINT); + else if (flags & SIZEINT) + ADDTYPE_CHECK(TP_SSIZEINT); + else if (flags & MAXINT) + ADDTYPE_CHECK(TP_MAXINT); + else + ADDTYPE_CHECK(TP_INT); + continue; /* no output */ + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + ADDUARG(); + break; + case 'p': + ADDTYPE_CHECK(TP_VOID); + break; + case 's': +#ifdef PRINTF_WIDE_CHAR + if (flags & LONGINT) + ADDTYPE_CHECK(TP_WCHAR); + else +#endif + ADDTYPE_CHECK(TP_CHAR); + break; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + case 'X': + case 'x': + ADDUARG(); + break; + default: /* "%?" prints ?, unless ? is NUL */ + if (ch == '\0') + goto done; + break; + } + } +done: + /* + * Build the argument table. + */ + if (tablemax >= STATIC_ARG_TBL_SIZE) { + *argtablesiz = sizeof(union arg) * (tablemax + 1); + *argtable = (union arg *)malloc(*argtablesiz); + if (*argtable == NULL) + goto overflow; //return (-1); + } + +#if 0 + /* XXX is this required? */ + (*argtable)[0].intarg = 0; +#endif + for (n = 1; n <= tablemax; n++) { + switch (typetable[n]) { + case T_UNUSED: + case T_CHAR: + case T_U_CHAR: + case T_SHORT: + case T_U_SHORT: + case T_INT: + (*argtable)[n].intarg = va_arg(ap, int); + break; + case TP_SHORT: + (*argtable)[n].pshortarg = va_arg(ap, short *); + break; + case T_U_INT: + (*argtable)[n].uintarg = va_arg(ap, unsigned int); + break; + case TP_INT: + (*argtable)[n].pintarg = va_arg(ap, int *); + break; + case T_LONG: + (*argtable)[n].longarg = va_arg(ap, long); + break; + case T_U_LONG: + (*argtable)[n].ulongarg = va_arg(ap, unsigned long); + break; + case TP_LONG: + (*argtable)[n].plongarg = va_arg(ap, long *); + break; + case T_LLONG: + (*argtable)[n].longlongarg = va_arg(ap, long long); + break; + case T_U_LLONG: + (*argtable)[n].ulonglongarg = va_arg(ap, unsigned long long); + break; + case TP_LLONG: + (*argtable)[n].plonglongarg = va_arg(ap, long long *); + break; +#ifdef FLOATING_POINT + case T_DOUBLE: + (*argtable)[n].doublearg = va_arg(ap, double); + break; + case T_LONG_DOUBLE: + (*argtable)[n].longdoublearg = va_arg(ap, long double); + break; +#endif + case TP_CHAR: + (*argtable)[n].pchararg = va_arg(ap, char *); + break; + case TP_VOID: + (*argtable)[n].pvoidarg = va_arg(ap, void *); + break; + case T_PTRINT: + (*argtable)[n].ptrdiffarg = va_arg(ap, ptrdiff_t); + break; + case TP_PTRINT: + (*argtable)[n].pptrdiffarg = va_arg(ap, ptrdiff_t *); + break; + case T_SIZEINT: + (*argtable)[n].sizearg = va_arg(ap, size_t); + break; + case T_SSIZEINT: + (*argtable)[n].ssizearg = va_arg(ap, ssize_t); + break; + case TP_SSIZEINT: + (*argtable)[n].pssizearg = va_arg(ap, ssize_t *); + break; + case T_MAXINT: + (*argtable)[n].intmaxarg = va_arg(ap, intmax_t); + break; + case T_MAXUINT: + (*argtable)[n].uintmaxarg = va_arg(ap, uintmax_t); + break; + case TP_MAXINT: + (*argtable)[n].pintmaxarg = va_arg(ap, intmax_t *); + break; +#ifdef PRINTF_WIDE_CHAR + case T_WINT: + (*argtable)[n].wintarg = va_arg(ap, wint_t); + break; + case TP_WCHAR: + (*argtable)[n].pwchararg = va_arg(ap, wchar_t *); + break; +#endif + } + } + goto finish; + +overflow: + errno = ENOMEM; + ret = -1; + +finish: + if (typetable != NULL && typetable != stattypetable) { + free(typetable); + typetable = NULL; + } + return (ret); +} + +/* + * Increase the size of the type table. + */ +static int +__grow_type_table(unsigned char **typetable, int *tablesize) +{ + unsigned char *oldtable = *typetable; + int newsize = *tablesize * 2; + + if (newsize < SE_PAGE_SIZE) + newsize = SE_PAGE_SIZE; + + if (*tablesize == STATIC_ARG_TBL_SIZE) { + *typetable = (unsigned char *)malloc(newsize); + if (*typetable == NULL) + return (-1); + memmove(*typetable, oldtable, *tablesize); + } else { + unsigned char *new1 = (unsigned char *)malloc(newsize); + if (new1 == NULL) + return (-1); + memmove(new1, *typetable, *tablesize); + free(*typetable); + *typetable = new1; + } + memset(*typetable + *tablesize, T_UNUSED, (newsize - *tablesize)); + + *tablesize = newsize; + return (0); +} + + +#ifdef FLOATING_POINT +static int +exponent(char *p0, int exp, int fmtch) +{ + char *p, *t; + char expbuf[MAXEXPDIG]; + + p = p0; + *p++ = fmtch; + if (exp < 0) { + exp = -exp; + *p++ = '-'; + } else + *p++ = '+'; + t = expbuf + MAXEXPDIG; + if (exp > 9) { + do { + *--t = to_char(exp % 10); + } while ((exp /= 10) > 9); + *--t = to_char(exp); + for (; t < expbuf + MAXEXPDIG; *p++ = *t++) + /* nothing */; + } else { + /* + * Exponents for decimal floating point conversions + * (%[eEgG]) must be at least two characters long, + * whereas exponents for hexadecimal conversions can + * be only one character long. + */ + if (fmtch == 'e' || fmtch == 'E') + *p++ = '0'; + *p++ = to_char(exp); + } + return (p - p0); +} +#endif /* FLOATING_POINT */ diff --git a/sdk/tlibc/stdio/vfwprintf.c b/sdk/tlibc/stdio/vfwprintf.c new file mode 100644 index 0000000000..4526680ed1 --- /dev/null +++ b/sdk/tlibc/stdio/vfwprintf.c @@ -0,0 +1,1487 @@ +/* $OpenBSD: vfwprintf.c,v 1.8 2013/11/12 07:04:35 deraadt Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Actual wprintf innards. + * + * This code is large and complicated... + */ + +#include +//#include + +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "local.h" +#include "fvwrite.h" + +union arg { + int intarg; + unsigned int uintarg; + long longarg; + unsigned long ulongarg; + long long longlongarg; + unsigned long long ulonglongarg; + ptrdiff_t ptrdiffarg; + size_t sizearg; + ssize_t ssizearg; + intmax_t intmaxarg; + uintmax_t uintmaxarg; + void *pvoidarg; + char *pchararg; + signed char *pschararg; + short *pshortarg; + int *pintarg; + long *plongarg; + long long *plonglongarg; + ptrdiff_t *pptrdiffarg; + ssize_t *pssizearg; + intmax_t *pintmaxarg; +#ifdef FLOATING_POINT + double doublearg; + long double longdoublearg; +#endif + wint_t wintarg; + wchar_t *pwchararg; +}; + +static int __find_arguments(const wchar_t *fmt0, va_list ap, union arg **argtable, + size_t *argtablesiz); +static int __grow_type_table(unsigned char **typetable, int *tablesize); + +/* + * Like __fputwc_unlock, but handles fake string (__SSTR) files properly. + * File must already be locked. + */ +static wint_t +__xfputwc(wchar_t wc, FILE *fp) +{ + mbstate_t mbs; + char buf[MB_LEN_MAX]; + struct __suio uio; + struct __siov iov; + size_t len; + + //if ((fp->_flags & __SSTR) == 0) + // return (__fputwc_unlock(wc, fp)); + + memset(&mbs, 0x0, sizeof(mbs)); + len = wcrtomb(buf, wc, &mbs); + if (len == (size_t)-1) { + fp->_flags |= __SERR; + errno = EILSEQ; + return (WEOF); + } + uio.uio_iov = &iov; + uio.uio_resid = len; + uio.uio_iovcnt = 1; + iov.iov_base = buf; + iov.iov_len = len; + return (__sfvwrite(fp, &uio) != EOF ? (wint_t)wc : WEOF); +} + +/* + * Convert a multibyte character string argument for the %s format to a wide + * string representation. ``prec'' specifies the maximum number of bytes + * to output. If ``prec'' is greater than or equal to zero, we can't assume + * that the multibyte character string ends in a null character. + * + * Returns NULL on failure. + * To find out what happened check errno for ENOMEM, EILSEQ and EINVAL. + */ +static wchar_t * +__mbsconv(char *mbsarg, int prec) +{ + mbstate_t mbs; + wchar_t *convbuf, *wcp; + const char *p; + size_t insize, nchars, nconv; + + if (mbsarg == NULL) + return (NULL); + + /* + * Supplied argument is a multibyte string; convert it to wide + * characters first. + */ + if (prec >= 0) { + /* + * String is not guaranteed to be NUL-terminated. Find the + * number of characters to print. + */ + p = mbsarg; + insize = nchars = nconv = 0; + memset(&mbs, 0x0, sizeof(mbs)); + while (nchars != (size_t)prec) { + nconv = mbrlen(p, MB_CUR_MAX, &mbs); + if (nconv == (size_t)0 || nconv == (size_t)-1 || + nconv == (size_t)-2) + break; + p += nconv; + nchars++; + insize += nconv; + } + if (nconv == (size_t)-1 || nconv == (size_t)-2) + return (NULL); + } else + insize = strlen(mbsarg); + + /* + * Allocate buffer for the result and perform the conversion, + * converting at most `size' bytes of the input multibyte string to + * wide characters for printing. + */ + convbuf = calloc(insize + 1, sizeof(*convbuf)); + if (convbuf == NULL) + return (NULL); + wcp = convbuf; + p = mbsarg; + memset(&mbs, 0x0, sizeof(mbs)); + nconv = 0; + while (insize != 0) { + nconv = mbrtowc(wcp, p, insize, &mbs); + if (nconv == 0 || nconv == (size_t)-1 || nconv == (size_t)-2) + break; + wcp++; + p += nconv; + insize -= nconv; + } + if (nconv == (size_t)-1 || nconv == (size_t)-2) { + free(convbuf); + return (NULL); + } + *wcp = '\0'; + + return (convbuf); +} + +#ifdef FLOATING_POINT +#include +//#include +#include +#include "floatio.h" +#include "gdtoa.h" + +#define DEFPREC 6 + +static int exponent(wchar_t *, int, int); +#endif /* FLOATING_POINT */ + +/* + * The size of the buffer we use as scratch space for integer + * conversions, among other things. Technically, we would need the + * most space for base 10 conversions with thousands' grouping + * characters between each pair of digits. 100 bytes is a + * conservative overestimate even for a 128-bit uintmax_t. + */ +#define BUF 100 + +#define STATIC_ARG_TBL_SIZE 8 /* Size of static argument table. */ + + +/* + * Macros for converting digits to letters and vice versa + */ +#define to_digit(c) ((c) - '0') +#define is_digit(c) ((unsigned)to_digit(c) <= 9) +#define to_char(n) ((wchar_t)((n) + '0')) + +/* + * Flags used during conversion. + */ +#define ALT 0x0001 /* alternate form */ +#define LADJUST 0x0004 /* left adjustment */ +#define LONGDBL 0x0008 /* long double */ +#define LONGINT 0x0010 /* long integer */ +#define LLONGINT 0x0020 /* long long integer */ +#define SHORTINT 0x0040 /* short integer */ +#define ZEROPAD 0x0080 /* zero (as opposed to blank) pad */ +#define FPT 0x0100 /* Floating point number */ +#define PTRINT 0x0200 /* (unsigned) ptrdiff_t */ +#define SIZEINT 0x0400 /* (signed) size_t */ +#define CHARINT 0x0800 /* 8 bit integer */ +#define MAXINT 0x1000 /* largest integer size (intmax_t) */ + +int +__vfwprintf(FILE * __restrict fp, const wchar_t * __restrict fmt0, __va_list ap) +{ + wchar_t *fmt; /* format string */ + wchar_t ch; /* character from fmt */ + int n, n2, n3; /* handy integers (short term usage) */ + wchar_t *cp; /* handy char pointer (short term usage) */ + int flags; /* flags as above */ + int ret; /* return value accumulator */ + int width; /* width from format (%8d), or 0 */ + int prec; /* precision from format; <0 for N/A */ + wchar_t sign; /* sign prefix (' ', '+', '-', or \0) */ +#ifdef FLOATING_POINT + /* + * We can decompose the printed representation of floating + * point numbers into several parts, some of which may be empty: + * + * [+|-| ] [0x|0X] MMM . NNN [e|E|p|P] [+|-] ZZ + * A B ---C--- D E F + * + * A: 'sign' holds this value if present; '\0' otherwise + * B: ox[1] holds the 'x' or 'X'; '\0' if not hexadecimal + * C: cp points to the string MMMNNN. Leading and trailing + * zeros are not in the string and must be added. + * D: expchar holds this character; '\0' if no exponent, e.g. %f + * F: at least two digits for decimal, at least one digit for hex + */ + char *decimal_point = "."; + int signflag; /* true if float is negative */ + union { /* floating point arguments %[aAeEfFgG] */ + double dbl; + long double ldbl; + } fparg; + int expt; /* integer value of exponent */ + char expchar; /* exponent character: [eEpP\0] */ + char *dtoaend; /* pointer to end of converted digits */ + int expsize; /* character count for expstr */ + int lead; /* sig figs before decimal or group sep */ + int ndig; /* actual number of digits returned by dtoa */ + wchar_t expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */ + char *dtoaresult = NULL; +#endif + + uintmax_t _umax; /* integer arguments %[diouxX] */ + enum { OCT, DEC, HEX } base; /* base for %[diouxX] conversion */ + int dprec; /* a copy of prec if %[diouxX], 0 otherwise */ + int realsz; /* field size expanded by dprec */ + int size; /* size of converted field or string */ + const char *xdigs; /* digits for %[xX] conversion */ +#define NIOV 8 + struct __suio uio; /* output information: summary */ + struct __siov iov[NIOV];/* ... and individual io vectors */ + wchar_t buf[BUF]; /* buffer with space for digits of uintmax_t */ + wchar_t ox[2]; /* space for 0x; ox[1] is either x, X, or \0 */ + union arg *argtable; /* args, built due to positional arg */ + union arg statargtable[STATIC_ARG_TBL_SIZE]; + size_t argtablesiz; + int nextarg; /* 1-based argument index */ + va_list orgap; /* original argument pointer */ + wchar_t *convbuf; /* buffer for multibyte to wide conversion */ + + /* + * Choose PADSIZE to trade efficiency vs. size. If larger printf + * fields occur frequently, increase PADSIZE and make the initialisers + * below longer. + */ +#define PADSIZE 16 /* pad chunk size */ + static wchar_t blanks[PADSIZE] = + {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; + static wchar_t zeroes[PADSIZE] = + {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; + + static const char xdigs_lower[16] = "0123456789abcdef"; + static const char xdigs_upper[16] = "0123456789ABCDEF"; + + /* + * BEWARE, these `goto error' on error, PRINT uses 'n3', + * PAD uses `n' and 'n3', and PRINTANDPAD uses 'n', 'n2', and 'n3'. + */ +#define PRINT(ptr, len) do { \ + for (n3 = 0; n3 < (len); n3++) { \ + if ((__xfputwc((ptr)[n3], fp)) == WEOF) \ + goto error; \ + } \ +} while (0) +#define PAD(howmany, with) do { \ + if ((n = (howmany)) > 0) { \ + while (n > PADSIZE) { \ + PRINT(with, PADSIZE); \ + n -= PADSIZE; \ + } \ + PRINT(with, n); \ + } \ +} while (0) +#define PRINTANDPAD(p, ep, len, with) do { \ + n2 = (ep) - (p); \ + if (n2 > (len)) \ + n2 = (len); \ + if (n2 > 0) \ + PRINT((p), n2); \ + PAD((len) - (n2 > 0 ? n2 : 0), (with)); \ +} while(0) + + /* + * To extend shorts properly, we need both signed and unsigned + * argument extraction methods. + */ +#define SARG() \ + ((intmax_t)(flags&MAXINT ? GETARG(intmax_t) : \ + flags&LLONGINT ? GETARG(long long) : \ + flags&LONGINT ? GETARG(long) : \ + flags&PTRINT ? GETARG(ptrdiff_t) : \ + flags&SIZEINT ? GETARG(ssize_t) : \ + flags&SHORTINT ? (short)GETARG(int) : \ + flags&CHARINT ? (signed char)GETARG(int) : \ + GETARG(int))) +#define UARG() \ + ((uintmax_t)(flags&MAXINT ? GETARG(uintmax_t) : \ + flags&LLONGINT ? GETARG(unsigned long long) : \ + flags&LONGINT ? GETARG(unsigned long) : \ + flags&PTRINT ? (uintptr_t)GETARG(ptrdiff_t) : /* XXX */ \ + flags&SIZEINT ? GETARG(size_t) : \ + flags&SHORTINT ? (unsigned short)GETARG(int) : \ + flags&CHARINT ? (unsigned char)GETARG(int) : \ + GETARG(unsigned int))) + + /* + * Append a digit to a value and check for overflow. + */ +#define APPEND_DIGIT(val, dig) do { \ + if ((val) > INT_MAX / 10) \ + goto overflow; \ + (val) *= 10; \ + if ((val) > INT_MAX - to_digit((dig))) \ + goto overflow; \ + (val) += to_digit((dig)); \ +} while (0) + + /* + * Get * arguments, including the form *nn$. Preserve the nextarg + * that the argument can be gotten once the type is determined. + */ +#define GETASTER(val) \ + n2 = 0; \ + cp = fmt; \ + while (is_digit(*cp)) { \ + APPEND_DIGIT(n2, *cp); \ + cp++; \ + } \ + if (*cp == '$') { \ + int hold = nextarg; \ + if (argtable == NULL) { \ + argtable = statargtable; \ + __find_arguments(fmt0, orgap, &argtable, &argtablesiz); \ + } \ + nextarg = n2; \ + val = GETARG(int); \ + nextarg = hold; \ + fmt = ++cp; \ + } else { \ + val = GETARG(int); \ + } + +/* +* Get the argument indexed by nextarg. If the argument table is +* built, use it to get the argument. If its not, get the next +* argument (and arguments must be gotten sequentially). +*/ +#define GETARG(type) \ + ((argtable != NULL) ? *((type*)(&argtable[nextarg++])) : \ + (nextarg++, va_arg(ap, type))) + + _SET_ORIENTATION(fp, 1); + /* sorry, fwprintf(read_only_file, "") returns EOF, not 0 */ + if (cantwrite(fp)) { + errno = EBADF; + return (EOF); + } + + /* optimise fwprintf(stderr) (and other unbuffered Unix files) */ + if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && + fp->_file >= 0) { + //return (__sbprintf(fp, fmt0, ap)); + errno = EBADF; + return (EOF); + } + + fmt = (wchar_t *)fmt0; + argtable = NULL; + nextarg = 1; + va_copy(orgap, ap); + uio.uio_iov = iov; + uio.uio_resid = 0; + uio.uio_iovcnt = 0; + ret = 0; + convbuf = NULL; + + /* + * Scan the format for conversions (`%' character). + */ + for (;;) { + for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++) + continue; + if (fmt != cp) { + ptrdiff_t m = fmt - cp; + if (m < 0 || m > INT_MAX - ret) + goto overflow; + PRINT(cp, m); + ret += m; + } + if (ch == '\0') + goto done; + fmt++; /* skip over '%' */ + + flags = 0; + dprec = 0; + width = 0; + prec = -1; + sign = '\0'; + ox[1] = '\0'; + +rflag: ch = *fmt++; +reswitch: switch (ch) { + case ' ': + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (!sign) + sign = ' '; + goto rflag; + case '#': + flags |= ALT; + goto rflag; + case '\'': + /* grouping not implemented */ + goto rflag; + case '*': + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + GETASTER(width); + if (width >= 0) + goto rflag; + if (width == INT_MIN) + goto overflow; + width = -width; + /* FALLTHROUGH */ + case '-': + flags |= LADJUST; + goto rflag; + case '+': + sign = '+'; + goto rflag; + case '.': + if ((ch = *fmt++) == '*') { + GETASTER(n); + prec = n < 0 ? -1 : n; + goto rflag; + } + n = 0; + while (is_digit(ch)) { + APPEND_DIGIT(n, ch); + ch = *fmt++; + } + if (ch == '$') { + nextarg = n; + if (argtable == NULL) { + argtable = statargtable; + __find_arguments(fmt0, orgap, + &argtable, &argtablesiz); + } + goto rflag; + } + prec = n; + goto reswitch; + case '0': + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + flags |= ZEROPAD; + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + APPEND_DIGIT(n, ch); + ch = *fmt++; + } while (is_digit(ch)); + if (ch == '$') { + nextarg = n; + if (argtable == NULL) { + argtable = statargtable; + __find_arguments(fmt0, orgap, + &argtable, &argtablesiz); + } + goto rflag; + } + width = n; + goto reswitch; +#ifdef FLOATING_POINT + case 'L': + flags |= LONGDBL; + goto rflag; +#endif + case 'h': + if (*fmt == 'h') { + fmt++; + flags |= CHARINT; + } else { + flags |= SHORTINT; + } + goto rflag; + case 'j': + flags |= MAXINT; + goto rflag; + case 'l': + if (*fmt == 'l') { + fmt++; + flags |= LLONGINT; + } else { + flags |= LONGINT; + } + goto rflag; + case 'q': + flags |= LLONGINT; + goto rflag; + case 't': + flags |= PTRINT; + goto rflag; + case 'z': + flags |= SIZEINT; + goto rflag; + case 'C': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'c': + if (flags & LONGINT) + *(cp = buf) = (wchar_t)GETARG(wint_t); + else + *(cp = buf) = (wchar_t)btowc(GETARG(int)); + size = 1; + sign = '\0'; + break; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + _umax = SARG(); + if ((intmax_t)_umax < 0) { + _umax = -_umax; + sign = '-'; + } + base = DEC; + goto number; +#ifdef FLOATING_POINT + case 'a': + case 'A': + if (ch == 'a') { + ox[1] = 'x'; + xdigs = xdigs_lower; + expchar = 'p'; + } else { + ox[1] = 'X'; + xdigs = xdigs_upper; + expchar = 'P'; + } + if (prec >= 0) + prec++; + if (dtoaresult) + __freedtoa(dtoaresult); + if (flags & LONGDBL) { + fparg.ldbl = GETARG(long double); + dtoaresult = + __hldtoa(fparg.ldbl, xdigs, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + } else { + fparg.dbl = GETARG(double); + dtoaresult = + __hdtoa(fparg.dbl, xdigs, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + } + if (prec < 0) + prec = dtoaend - dtoaresult; + if (expt == INT_MAX) + ox[1] = '\0'; + if (convbuf) { + free(convbuf); + convbuf = NULL; + } + cp = convbuf = __mbsconv(dtoaresult, -1); + if (cp == NULL) + goto error; + ndig = dtoaend - dtoaresult; + goto fp_common; + case 'e': + case 'E': + expchar = ch; + if (prec < 0) /* account for digit before decpt */ + prec = DEFPREC + 1; + else + prec++; + goto fp_begin; + case 'f': + case 'F': + expchar = '\0'; + goto fp_begin; + case 'g': + case 'G': + expchar = ch - ('g' - 'e'); + if (prec == 0) + prec = 1; +fp_begin: + if (prec < 0) + prec = DEFPREC; + if (dtoaresult) + __freedtoa(dtoaresult); + if (flags & LONGDBL) { + fparg.ldbl = GETARG(long double); + dtoaresult = + __ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + } else { + fparg.dbl = GETARG(double); + dtoaresult = + __dtoa(fparg.dbl, expchar ? 2 : 3, prec, + &expt, &signflag, &dtoaend); + if (dtoaresult == NULL) { + errno = ENOMEM; + goto error; + } + if (expt == 9999) + expt = INT_MAX; + } + if (convbuf) { + free(convbuf); + convbuf = NULL; + } + cp = convbuf = __mbsconv(dtoaresult, -1); + if (cp == NULL) + goto error; + ndig = dtoaend - dtoaresult; +fp_common: + if (signflag) + sign = '-'; + if (expt == INT_MAX) { /* inf or nan */ + if (*cp == 'N') { + cp = (ch >= 'a') ? L"nan" : L"NAN"; + sign = '\0'; + } else + cp = (ch >= 'a') ? L"inf" : L"INF"; + size = 3; + flags &= ~ZEROPAD; + break; + } + flags |= FPT; + if (ch == 'g' || ch == 'G') { + if (expt > -4 && expt <= prec) { + /* Make %[gG] smell like %[fF] */ + expchar = '\0'; + if (flags & ALT) + prec -= expt; + else + prec = ndig - expt; + if (prec < 0) + prec = 0; + } else { + /* + * Make %[gG] smell like %[eE], but + * trim trailing zeroes if no # flag. + */ + if (!(flags & ALT)) + prec = ndig; + } + } + if (expchar) { + expsize = exponent(expstr, expt - 1, expchar); + size = expsize + prec; + if (prec > 1 || flags & ALT) + ++size; + } else { + /* space for digits before decimal point */ + if (expt > 0) + size = expt; + else /* "0" */ + size = 1; + /* space for decimal pt and following digits */ + if (prec || flags & ALT) + size += prec + 1; + lead = expt; + } + break; +#endif /* FLOATING_POINT */ + case 'n': + abort(); +#if 0 + if (flags & LLONGINT) + *GETARG(long long *) = ret; + else if (flags & LONGINT) + *GETARG(long *) = ret; + else if (flags & SHORTINT) + *GETARG(short *) = ret; + else if (flags & CHARINT) + *GETARG(signed char *) = ret; + else if (flags & PTRINT) + *GETARG(ptrdiff_t *) = ret; + else if (flags & SIZEINT) + *GETARG(ssize_t *) = ret; + else if (flags & MAXINT) + *GETARG(intmax_t *) = ret; + else + *GETARG(int *) = ret; + continue; /* no output */ +#endif + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + _umax = UARG(); + base = OCT; + goto nosign; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + /* NOSTRICT */ + _umax = (size_t)GETARG(void *); + base = HEX; + xdigs = xdigs_lower; + ox[1] = 'x'; + goto nosign; + case 'S': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 's': + if (flags & LONGINT) { + if ((cp = GETARG(wchar_t *)) == NULL) + cp = L"(null)"; + } else { + char *mbsarg; + if ((mbsarg = GETARG(char *)) == NULL) + mbsarg = "(null)"; + if (convbuf) { + free(convbuf); + convbuf = NULL; + } + convbuf = __mbsconv(mbsarg, prec); + if (convbuf == NULL) { + fp->_flags |= __SERR; + goto error; + } else + cp = convbuf; + } + if (prec >= 0) { + /* + * can't use wcslen; can only look for the + * NUL in the first `prec' characters, and + * wcslen() will go further. + */ + wchar_t *p = wmemchr(cp, 0, prec); + + size = p ? (p - cp) : prec; + } else { + size_t len; + + if ((len = wcslen(cp)) > INT_MAX) + goto overflow; + size = (int)len; + } + sign = '\0'; + break; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + _umax = UARG(); + base = DEC; + goto nosign; + case 'X': + xdigs = xdigs_upper; + goto hex; + case 'x': + xdigs = xdigs_lower; +hex: _umax = UARG(); + base = HEX; + /* leading 0x/X only if non-zero */ + if (flags & ALT && _umax != 0) + ox[1] = ch; + + /* unsigned conversions */ +nosign: sign = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ +number: if ((dprec = prec) >= 0) + flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + cp = buf + BUF; + if (_umax != 0 || prec != 0) { + /* + * Unsigned mod is hard, and unsigned mod + * by a constant is easier than that by + * a variable; hence this switch. + */ + switch (base) { + case OCT: + do { + *--cp = to_char(_umax & 7); + _umax >>= 3; + } while (_umax); + /* handle octal leading 0 */ + if (flags & ALT && *cp != '0') + *--cp = '0'; + break; + + case DEC: + /* many numbers are 1 digit */ + while (_umax >= 10) { + *--cp = to_char(_umax % 10); + _umax /= 10; + } + *--cp = to_char(_umax); + break; + + case HEX: + do { + *--cp = xdigs[_umax & 15]; + _umax >>= 4; + } while (_umax); + break; + + default: + cp = L"bug in vfwprintf: bad base"; + size = wcslen(cp); + goto skipsize; + } + } + size = buf + BUF - cp; + if (size > BUF) /* should never happen */ + abort(); + skipsize: + break; + default: /* "%?" prints ?, unless ? is NUL */ + if (ch == '\0') + goto done; + /* pretend it was %c with argument ch */ + cp = buf; + *cp = ch; + size = 1; + sign = '\0'; + break; + } + + /* + * All reasonable formats wind up here. At this point, `cp' + * points to a string which (if not flags&LADJUST) should be + * padded out to `width' places. If flags&ZEROPAD, it should + * first be prefixed by any sign or other prefix; otherwise, + * it should be blank padded before the prefix is emitted. + * After any left-hand padding and prefixing, emit zeroes + * required by a decimal %[diouxX] precision, then print the + * string proper, then emit zeroes required by any leftover + * floating precision; finally, if LADJUST, pad with blanks. + * + * Compute actual size, so we know how much to pad. + * size excludes decimal prec; realsz includes it. + */ + realsz = dprec > size ? dprec : size; + if (sign) + realsz++; + if (ox[1]) + realsz+= 2; + + /* right-adjusting blank padding */ + if ((flags & (LADJUST|ZEROPAD)) == 0) + PAD(width - realsz, blanks); + + /* prefix */ + if (sign) + PRINT(&sign, 1); + if (ox[1]) { /* ox[1] is either x, X, or \0 */ + ox[0] = '0'; + PRINT(ox, 2); + } + + /* right-adjusting zero padding */ + if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) + PAD(width - realsz, zeroes); + + /* leading zeroes from decimal precision */ + PAD(dprec - size, zeroes); + + /* the string or number proper */ +#ifdef FLOATING_POINT + if ((flags & FPT) == 0) { + PRINT(cp, size); + } else { /* glue together f_p fragments */ + if (!expchar) { /* %[fF] or sufficiently short %[gG] */ + if (expt <= 0) { + PRINT(zeroes, 1); + if (prec || flags & ALT) + PRINT(decimal_point, 1); + PAD(-expt, zeroes); + /* already handled initial 0's */ + prec += expt; + } else { + PRINTANDPAD(cp, convbuf + ndig, + lead, zeroes); + cp += lead; + if (prec || flags & ALT) + PRINT(decimal_point, 1); + } + PRINTANDPAD(cp, convbuf + ndig, prec, zeroes); + } else { /* %[eE] or sufficiently long %[gG] */ + if (prec > 1 || flags & ALT) { + buf[0] = *cp++; + buf[1] = *decimal_point; + PRINT(buf, 2); + PRINT(cp, ndig-1); + PAD(prec - ndig, zeroes); + } else { /* XeYYY */ + PRINT(cp, 1); + } + PRINT(expstr, expsize); + } + } +#else + PRINT(cp, size); +#endif + /* left-adjusting padding (always blank) */ + if (flags & LADJUST) + PAD(width - realsz, blanks); + + /* finally, adjust ret */ + if (width < realsz) + width = realsz; + if (width > INT_MAX - ret) + goto overflow; + ret += width; + } +done: +error: + va_end(orgap); + if (__sferror(fp)) + ret = -1; + goto finish; + +overflow: + errno = ENOMEM; + ret = -1; + +finish: + if (convbuf) + free(convbuf); +#ifdef FLOATING_POINT + if (dtoaresult) + __freedtoa(dtoaresult); +#endif + if (argtable != NULL && argtable != statargtable) { + free(argtable); + argtable = NULL; + } + return (ret); +} + +/* + * Type ids for argument type table. + */ +#define T_UNUSED 0 +#define T_SHORT 1 +#define T_U_SHORT 2 +#define TP_SHORT 3 +#define T_INT 4 +#define T_U_INT 5 +#define TP_INT 6 +#define T_LONG 7 +#define T_U_LONG 8 +#define TP_LONG 9 +#define T_LLONG 10 +#define T_U_LLONG 11 +#define TP_LLONG 12 +#define T_DOUBLE 13 +#define T_LONG_DOUBLE 14 +#define TP_CHAR 15 +#define TP_VOID 16 +#define T_PTRINT 17 +#define TP_PTRINT 18 +#define T_SIZEINT 19 +#define T_SSIZEINT 20 +#define TP_SSIZEINT 21 +#define T_MAXINT 22 +#define T_MAXUINT 23 +#define TP_MAXINT 24 +#define T_CHAR 25 +#define T_U_CHAR 26 +#define T_WINT 27 +#define TP_WCHAR 28 + +/* + * Find all arguments when a positional parameter is encountered. Returns a + * table, indexed by argument number, of pointers to each arguments. The + * initial argument table should be an array of STATIC_ARG_TBL_SIZE entries. + * It will be replaced with a mmap-ed one if it overflows (malloc cannot be + * used since we are attempting to make snprintf thread safe, and alloca is + * problematic since we have nested functions..) + */ +static int +__find_arguments(const wchar_t *fmt0, va_list ap, union arg **argtable, + size_t *argtablesiz) +{ + wchar_t *fmt; /* format string */ + int ch; /* character from fmt */ + int n, n2; /* handy integer (short term usage) */ + wchar_t *cp; /* handy char pointer (short term usage) */ + int flags; /* flags as above */ + unsigned char *typetable; /* table of types */ + unsigned char stattypetable[STATIC_ARG_TBL_SIZE]; + int tablesize; /* current size of type table */ + int tablemax; /* largest used index in table */ + int nextarg; /* 1-based argument index */ + int ret = 0; /* return value */ + int rc = 0; /* save return code from __grow_type_table */ + +#define check_rc(rc) if (rc == -1) goto overflow + + /* + * Add an argument type to the table, expanding if necessary. + */ +#define ADDTYPE(type) \ + ((nextarg >= tablesize) ? \ + rc = __grow_type_table(&typetable, &tablesize) : 0, \ + (nextarg > tablemax) ? tablemax = nextarg : 0, \ + rc == -1 ? 0 : (typetable[nextarg++] = type)) + +#define ADDTYPE_CHECK(type) \ + ADDTYPE(type); check_rc(rc) + +#define ADDSARG() \ + ((flags&MAXINT) ? ADDTYPE(T_MAXINT) : \ + ((flags&PTRINT) ? ADDTYPE(T_PTRINT) : \ + ((flags&SIZEINT) ? ADDTYPE(T_SSIZEINT) : \ + ((flags&LLONGINT) ? ADDTYPE(T_LLONG) : \ + ((flags&LONGINT) ? ADDTYPE(T_LONG) : \ + ((flags&SHORTINT) ? ADDTYPE(T_SHORT) : \ + ((flags&CHARINT) ? ADDTYPE(T_CHAR) : ADDTYPE(T_INT)))))))); \ + check_rc(rc); + +#define ADDUARG() \ + ((flags&MAXINT) ? ADDTYPE(T_MAXUINT) : \ + ((flags&PTRINT) ? ADDTYPE(T_PTRINT) : \ + ((flags&SIZEINT) ? ADDTYPE(T_SIZEINT) : \ + ((flags&LLONGINT) ? ADDTYPE(T_U_LLONG) : \ + ((flags&LONGINT) ? ADDTYPE(T_U_LONG) : \ + ((flags&SHORTINT) ? ADDTYPE(T_U_SHORT) : \ + ((flags&CHARINT) ? ADDTYPE(T_U_CHAR) : ADDTYPE(T_U_INT)))))))); \ + check_rc(rc); + + /* + * Add * arguments to the type array. + */ +#define ADDASTER() \ + n2 = 0; \ + cp = fmt; \ + while (is_digit(*cp)) { \ + APPEND_DIGIT(n2, *cp); \ + cp++; \ + } \ + if (*cp == '$') { \ + int hold = nextarg; \ + nextarg = n2; \ + ADDTYPE_CHECK(T_INT); \ + nextarg = hold; \ + fmt = ++cp; \ + } else { \ + ADDTYPE_CHECK(T_INT); \ + } + fmt = (wchar_t *)fmt0; + typetable = stattypetable; + tablesize = STATIC_ARG_TBL_SIZE; + tablemax = 0; + nextarg = 1; + memset(typetable, T_UNUSED, STATIC_ARG_TBL_SIZE); + + /* + * Scan the format for conversions (`%' character). + */ + for (;;) { + for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++) + continue; + if (ch == '\0') + goto done; + fmt++; /* skip over '%' */ + + flags = 0; + +rflag: ch = *fmt++; +reswitch: switch (ch) { + case ' ': + case '#': + case '\'': + goto rflag; + case '*': + ADDASTER(); + goto rflag; + case '-': + case '+': + goto rflag; + case '.': + if ((ch = *fmt++) == '*') { + ADDASTER(); + goto rflag; + } + while (is_digit(ch)) { + ch = *fmt++; + } + goto reswitch; + case '0': + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + APPEND_DIGIT(n ,ch); + ch = *fmt++; + } while (is_digit(ch)); + if (ch == '$') { + nextarg = n; + goto rflag; + } + goto reswitch; +#ifdef FLOATING_POINT + case 'L': + flags |= LONGDBL; + goto rflag; +#endif + case 'h': + if (*fmt == 'h') { + fmt++; + flags |= CHARINT; + } else { + flags |= SHORTINT; + } + goto rflag; + case 'l': + if (*fmt == 'l') { + fmt++; + flags |= LLONGINT; + } else { + flags |= LONGINT; + } + goto rflag; + case 'q': + flags |= LLONGINT; + goto rflag; + case 't': + flags |= PTRINT; + goto rflag; + case 'z': + flags |= SIZEINT; + goto rflag; + case 'C': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'c': + if (flags & LONGINT) + ADDTYPE_CHECK(T_WINT); + else + ADDTYPE_CHECK(T_INT); + break; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + ADDSARG(); + break; +#ifdef FLOATING_POINT + case 'a': + case 'A': + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + if (flags & LONGDBL) + ADDTYPE_CHECK(T_LONG_DOUBLE); + else + ADDTYPE_CHECK(T_DOUBLE); + break; +#endif /* FLOATING_POINT */ + case 'n': + if (flags & LLONGINT) + ADDTYPE_CHECK(TP_LLONG); + else if (flags & LONGINT) + ADDTYPE_CHECK(TP_LONG); + else if (flags & SHORTINT) + ADDTYPE_CHECK(TP_SHORT); + else if (flags & PTRINT) + ADDTYPE_CHECK(TP_PTRINT); + else if (flags & SIZEINT) + ADDTYPE_CHECK(TP_SSIZEINT); + else if (flags & MAXINT) + ADDTYPE_CHECK(TP_MAXINT); + else + ADDTYPE_CHECK(TP_INT); + continue; /* no output */ + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + ADDUARG(); + break; + case 'p': + ADDTYPE_CHECK(TP_VOID); + break; + case 'S': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 's': + if (flags & LONGINT) + ADDTYPE_CHECK(TP_CHAR); + else + ADDTYPE_CHECK(TP_WCHAR); + break; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + case 'X': + case 'x': + ADDUARG(); + break; + default: /* "%?" prints ?, unless ? is NUL */ + if (ch == '\0') + goto done; + break; + } + } +done: + /* + * Build the argument table. + */ + if (tablemax >= STATIC_ARG_TBL_SIZE) { + *argtablesiz = sizeof(union arg) * (tablemax + 1); + *argtable = (union arg *)malloc(*argtablesiz); + if (*argtable == NULL) + goto overflow; //return (-1); + } + +#if 0 + /* XXX is this required? */ + (*argtable)[0].intarg = 0; +#endif + for (n = 1; n <= tablemax; n++) { + switch (typetable[n]) { + case T_UNUSED: + case T_CHAR: + case T_U_CHAR: + case T_SHORT: + case T_U_SHORT: + case T_INT: + (*argtable)[n].intarg = va_arg(ap, int); + break; + case TP_SHORT: + (*argtable)[n].pshortarg = va_arg(ap, short *); + break; + case T_U_INT: + (*argtable)[n].uintarg = va_arg(ap, unsigned int); + break; + case TP_INT: + (*argtable)[n].pintarg = va_arg(ap, int *); + break; + case T_LONG: + (*argtable)[n].longarg = va_arg(ap, long); + break; + case T_U_LONG: + (*argtable)[n].ulongarg = va_arg(ap, unsigned long); + break; + case TP_LONG: + (*argtable)[n].plongarg = va_arg(ap, long *); + break; + case T_LLONG: + (*argtable)[n].longlongarg = va_arg(ap, long long); + break; + case T_U_LLONG: + (*argtable)[n].ulonglongarg = va_arg(ap, unsigned long long); + break; + case TP_LLONG: + (*argtable)[n].plonglongarg = va_arg(ap, long long *); + break; +#ifdef FLOATING_POINT + case T_DOUBLE: + (*argtable)[n].doublearg = va_arg(ap, double); + break; + case T_LONG_DOUBLE: + (*argtable)[n].longdoublearg = va_arg(ap, long double); + break; +#endif + case TP_CHAR: + (*argtable)[n].pchararg = va_arg(ap, char *); + break; + case TP_VOID: + (*argtable)[n].pvoidarg = va_arg(ap, void *); + break; + case T_PTRINT: + (*argtable)[n].ptrdiffarg = va_arg(ap, ptrdiff_t); + break; + case TP_PTRINT: + (*argtable)[n].pptrdiffarg = va_arg(ap, ptrdiff_t *); + break; + case T_SIZEINT: + (*argtable)[n].sizearg = va_arg(ap, size_t); + break; + case T_SSIZEINT: + (*argtable)[n].ssizearg = va_arg(ap, ssize_t); + break; + case TP_SSIZEINT: + (*argtable)[n].pssizearg = va_arg(ap, ssize_t *); + break; + case TP_MAXINT: + (*argtable)[n].intmaxarg = va_arg(ap, intmax_t); + break; + case T_WINT: + (*argtable)[n].wintarg = va_arg(ap, wint_t); + break; + case TP_WCHAR: + (*argtable)[n].pwchararg = va_arg(ap, wchar_t *); + break; + } + } + goto finish; + +overflow: + errno = ENOMEM; + ret = -1; + +finish: + if (typetable != NULL && typetable != stattypetable) { + free(typetable); + typetable = NULL; + } + return (ret); +} + +/* + * Increase the size of the type table. + */ +static int +__grow_type_table(unsigned char **typetable, int *tablesize) +{ + unsigned char *oldtable = *typetable; + int newsize = *tablesize * 2; + + if (newsize < SE_PAGE_SIZE) + newsize = SE_PAGE_SIZE; + + if (*tablesize == STATIC_ARG_TBL_SIZE) { + *typetable = (unsigned char *)malloc(newsize); + if (*typetable == NULL) + return (-1); + memmove(*typetable, oldtable, *tablesize); + } else { + unsigned char *new1 = (unsigned char *)malloc(newsize); + if (new1 == NULL) + return (-1); + memmove(new1, *typetable, *tablesize); + free(*typetable); + *typetable = new1; + } + memset(*typetable + *tablesize, T_UNUSED, (newsize - *tablesize)); + + *tablesize = newsize; + return (0); +} + + +#ifdef FLOATING_POINT +static int +exponent(wchar_t *p0, int exp, int fmtch) +{ + wchar_t *p, *t; + wchar_t expbuf[MAXEXPDIG]; + + p = p0; + *p++ = fmtch; + if (exp < 0) { + exp = -exp; + *p++ = '-'; + } else + *p++ = '+'; + t = expbuf + MAXEXPDIG; + if (exp > 9) { + do { + *--t = to_char(exp % 10); + } while ((exp /= 10) > 9); + *--t = to_char(exp); + for (; t < expbuf + MAXEXPDIG; *p++ = *t++) + /* nothing */; + } else { + /* + * Exponents for decimal floating point conversions + * (%[eEgG]) must be at least two characters long, + * whereas exponents for hexadecimal conversions can + * be only one character long. + */ + if (fmtch == 'e' || fmtch == 'E') + *p++ = '0'; + *p++ = to_char(exp); + } + return (p - p0); +} +#endif /* FLOATING_POINT */ diff --git a/sdk/tlibc/stdio/vsnprintf.c b/sdk/tlibc/stdio/vsnprintf.c new file mode 100644 index 0000000000..8b1a088da8 --- /dev/null +++ b/sdk/tlibc/stdio/vsnprintf.c @@ -0,0 +1,64 @@ +/* $OpenBSD: vsnprintf.c,v 1.15 2009/11/09 00:18:28 kurt Exp $ */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include "local.h" + +int +vsnprintf(char *str, size_t n, const char *fmt, __va_list ap) +{ + int ret; + char dummy; + FILE f; + struct __sfileext fext; + + _FILEEXT_SETUP(&f, &fext); + + /* While snprintf(3) specifies size_t stdio uses an int internally */ + if (n > INT_MAX) + n = INT_MAX; + /* Stdio internals do not deal correctly with zero length buffer */ + if (n == 0) { + str = &dummy; + n = 1; + } + f._file = -1; + f._flags = __SWR | __SSTR; + f._bf._base = f._p = (unsigned char *)str; + f._bf._size = f._w = n - 1; + ret = __vfprintf(&f, fmt, ap); + *f._p = '\0'; + return (ret); +} diff --git a/sdk/tlibc/stdio/vswprintf.c b/sdk/tlibc/stdio/vswprintf.c new file mode 100644 index 0000000000..28a6b0912e --- /dev/null +++ b/sdk/tlibc/stdio/vswprintf.c @@ -0,0 +1,97 @@ +/* $OpenBSD: vswprintf.c,v 1.3 2011/04/28 17:38:46 stsp Exp $ */ +/* $NetBSD: vswprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */ + +/* + * Copyright (c) 1997 Todd C. Miller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "local.h" + +int +vswprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt, + __va_list ap) +{ + mbstate_t mbs; + FILE f; + char *mbp; + int ret, sverrno; + size_t nwc; + struct __sfileext fext; + + if (n == 0) { + errno = EINVAL; + return (-1); + } + + _FILEEXT_SETUP(&f, &fext); + f._file = -1; + f._flags = __SWR | __SSTR | __SALC; + f._bf._base = f._p = (unsigned char *)malloc(128); + if (f._bf._base == NULL) { + errno = ENOMEM; + return (-1); + } + f._bf._size = f._w = 127; /* Leave room for the NUL */ + ret = __vfwprintf(&f, fmt, ap); + if (ret < 0) { + sverrno = errno; + free(f._bf._base); + errno = sverrno; + return (-1); + } + if (ret == 0) { + s[0] = L'\0'; + free(f._bf._base); + return (0); + } + *f._p = '\0'; + mbp = (char *)f._bf._base; + /* + * XXX Undo the conversion from wide characters to multibyte that + * fputwc() did in __vfwprintf(). + */ + memset(&mbs, 0x0, sizeof(mbs)); + nwc = mbsrtowcs(s, (const char **)&mbp, n, &mbs); + free(f._bf._base); + if (nwc == (size_t)-1) { + errno = EILSEQ; + return (-1); + } + if (nwc == n) { + s[n - 1] = L'\0'; + errno = EOVERFLOW; + return (-1); + } + + return (ret); +} diff --git a/sdk/tlibc/stdio/wcio.h b/sdk/tlibc/stdio/wcio.h new file mode 100644 index 0000000000..4462528da5 --- /dev/null +++ b/sdk/tlibc/stdio/wcio.h @@ -0,0 +1,61 @@ +/* $OpenBSD: wcio.h,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: wcio.h,v 1.3 2003/01/18 11:30:00 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#ifndef _WCIO_H_ +#define _WCIO_H_ + +/* minimal requirement of SUSv2 */ +#define WCIO_UNGETWC_BUFSIZE 1 + +struct wchar_io_data { + mbstate_t wcio_mbstate_in; + mbstate_t wcio_mbstate_out; + + wchar_t wcio_ungetwc_buf[WCIO_UNGETWC_BUFSIZE]; + size_t wcio_ungetwc_inbuf; + + int wcio_mode; /* orientation */ +}; + +#define WCIO_GET(fp) \ + (_EXT(fp) ? &(_EXT(fp)->_wcio) : (struct wchar_io_data *)0) + +#define _SET_ORIENTATION(fp, mode) \ +do {\ + struct wchar_io_data *_wcio = WCIO_GET(fp); \ + if (_wcio && _wcio->wcio_mode == 0) \ + _wcio->wcio_mode = (mode);\ +} while (0) + +#define WCIO_INIT(fp) \ + memset(WCIO_GET(fp), 0, sizeof(struct wchar_io_data)) + +#endif /*_WCIO_H_*/ diff --git a/sdk/tlibc/stdlib/abs.c b/sdk/tlibc/stdlib/abs.c new file mode 100644 index 0000000000..5d2fbae69f --- /dev/null +++ b/sdk/tlibc/stdlib/abs.c @@ -0,0 +1,37 @@ +/* $OpenBSD: abs.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +int +abs(int j) +{ + return(j < 0 ? -j : j); +} diff --git a/sdk/tlibc/stdlib/atof.c b/sdk/tlibc/stdlib/atof.c new file mode 100644 index 0000000000..d14b58b070 --- /dev/null +++ b/sdk/tlibc/stdlib/atof.c @@ -0,0 +1,37 @@ +/* $OpenBSD: atof.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +double +atof(const char *ascii) +{ + return(strtod(ascii, (char **)NULL)); +} diff --git a/sdk/tlibc/stdlib/atoi.c b/sdk/tlibc/stdlib/atoi.c new file mode 100644 index 0000000000..b0842678e2 --- /dev/null +++ b/sdk/tlibc/stdlib/atoi.c @@ -0,0 +1,37 @@ +/* $OpenBSD: atoi.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +int +atoi(const char *str) +{ + return((int)strtol(str, (char **)NULL, 10)); +} diff --git a/sdk/tlibc/stdlib/atol.c b/sdk/tlibc/stdlib/atol.c new file mode 100644 index 0000000000..1970804401 --- /dev/null +++ b/sdk/tlibc/stdlib/atol.c @@ -0,0 +1,37 @@ +/* $OpenBSD: atol.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +long +atol(const char *str) +{ + return(strtol(str, (char **)NULL, 10)); +} diff --git a/sdk/tlibc/stdlib/atoll.c b/sdk/tlibc/stdlib/atoll.c new file mode 100644 index 0000000000..7dad703ffa --- /dev/null +++ b/sdk/tlibc/stdlib/atoll.c @@ -0,0 +1,37 @@ +/* $OpenBSD: atoll.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +long long +atoll(const char *str) +{ + return(strtoll(str, (char **)NULL, 10)); +} diff --git a/sdk/tlibc/stdlib/bsearch.c b/sdk/tlibc/stdlib/bsearch.c new file mode 100644 index 0000000000..2d4dbbe5c6 --- /dev/null +++ b/sdk/tlibc/stdlib/bsearch.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * Perform a binary search. + * + * The code below is a bit sneaky. After a comparison fails, we + * divide the work in half by moving either left or right. If lim + * is odd, moving left simply involves halving lim: e.g., when lim + * is 5 we look at item 2, so we change lim to 2 so that we will + * look at items 0 & 1. If lim is even, the same applies. If lim + * is odd, moving right again involves halving lim, this time moving + * the base up one item past p: e.g., when lim is 5 we change base + * to item 3 and make lim 2 so that we will look at items 3 and 4. + * If lim is even, however, we have to shrink it by one before + * halving: e.g., when lim is 4, we still looked at item 2, so we + * have to make lim 3, then halve, obtaining 1, so that we will only + * look at item 3. + */ + +/* Disable warnings */ + +void * +bsearch(const void *key, const void *base0, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) +{ + const char *base = (const char *)base0; + size_t lim; + int cmp; + const void *p; + + for (lim = nmemb; lim != 0; lim >>= 1) { + p = base + (lim >> 1) * size; + cmp = (*compar)(key, p); + if (cmp == 0) + return ((void *)p); + if (cmp > 0) { /* key > p: move right */ + base = (char *)p + size; + lim--; + } /* else move left */ + } + return (NULL); +} diff --git a/sdk/tlibc/stdlib/div.c b/sdk/tlibc/stdlib/div.c new file mode 100644 index 0000000000..f7ac2db4b0 --- /dev/null +++ b/sdk/tlibc/stdlib/div.c @@ -0,0 +1,71 @@ +/* $OpenBSD: div.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include /* div_t */ + +div_t +div(int num, int denom) +{ + div_t r; + + r.quot = num / denom; + r.rem = num % denom; + /* + * The ANSI standard says that |r.quot| <= |n/d|, where + * n/d is to be computed in infinite precision. In other + * words, we should always truncate the quotient towards + * 0, never -infinity. + * + * Machine division and remainer may work either way when + * one or both of n or d is negative. If only one is + * negative and r.quot has been truncated towards -inf, + * r.rem will have the same sign as denom and the opposite + * sign of num; if both are negative and r.quot has been + * truncated towards -inf, r.rem will be positive (will + * have the opposite sign of num). These are considered + * `wrong'. + * + * If both are num and denom are positive, r will always + * be positive. + * + * This all boils down to: + * if num >= 0, but r.rem < 0, we got the wrong answer. + * In that case, to get the right answer, add 1 to r.quot and + * subtract denom from r.rem. + */ + if (num >= 0 && r.rem < 0) { + r.quot++; + r.rem -= denom; + } + return (r); +} diff --git a/sdk/tlibc/stdlib/imaxabs.c b/sdk/tlibc/stdlib/imaxabs.c new file mode 100644 index 0000000000..b7e910eefd --- /dev/null +++ b/sdk/tlibc/stdlib/imaxabs.c @@ -0,0 +1,38 @@ +/* $OpenBSD: imaxabs.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +intmax_t +imaxabs(intmax_t j) +{ + return (j < 0 ? -j : j); +} diff --git a/sdk/tlibc/stdlib/imaxdiv.c b/sdk/tlibc/stdlib/imaxdiv.c new file mode 100644 index 0000000000..0515a94b96 --- /dev/null +++ b/sdk/tlibc/stdlib/imaxdiv.c @@ -0,0 +1,50 @@ +/* $OpenBSD: imaxdiv.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include /* imaxdiv_t */ + +imaxdiv_t +imaxdiv(intmax_t num, intmax_t denom) +{ + imaxdiv_t r; + + /* see div.c for comments */ + + r.quot = num / denom; + r.rem = num % denom; + if (num >= 0 && r.rem < 0) { + r.quot++; + r.rem -= denom; + } + return (r); +} diff --git a/sdk/tlibc/stdlib/labs.c b/sdk/tlibc/stdlib/labs.c new file mode 100644 index 0000000000..ca60b9aba2 --- /dev/null +++ b/sdk/tlibc/stdlib/labs.c @@ -0,0 +1,37 @@ +/* $OpenBSD: labs.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +long +labs(long j) +{ + return(j < 0 ? -j : j); +} diff --git a/sdk/tlibc/stdlib/ldiv.c b/sdk/tlibc/stdlib/ldiv.c new file mode 100644 index 0000000000..775065f525 --- /dev/null +++ b/sdk/tlibc/stdlib/ldiv.c @@ -0,0 +1,50 @@ +/* $OpenBSD: ldiv.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include /* ldiv_t */ + +ldiv_t +ldiv(long num, long denom) +{ + ldiv_t r; + + /* see div.c for comments */ + + r.quot = num / denom; + r.rem = num % denom; + if (num >= 0 && r.rem < 0) { + r.quot++; + r.rem -= denom; + } + return (r); +} diff --git a/sdk/tlibc/stdlib/llabs.c b/sdk/tlibc/stdlib/llabs.c new file mode 100644 index 0000000000..fc2cd8261c --- /dev/null +++ b/sdk/tlibc/stdlib/llabs.c @@ -0,0 +1,38 @@ +/* $OpenBSD: llabs.c,v 1.3 2007/01/08 19:39:25 deraadt Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +long long +llabs(long long j) +{ + return (j < 0 ? -j : j); +} diff --git a/sdk/tlibc/stdlib/lldiv.c b/sdk/tlibc/stdlib/lldiv.c new file mode 100644 index 0000000000..e8d6c978b3 --- /dev/null +++ b/sdk/tlibc/stdlib/lldiv.c @@ -0,0 +1,50 @@ +/* $OpenBSD: lldiv.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include /* lldiv_t */ + +lldiv_t +lldiv(long long num, long long denom) +{ + lldiv_t r; + + /* see div.c for comments */ + + r.quot = num / denom; + r.rem = num % denom; + if (num >= 0 && r.rem < 0) { + r.quot++; + r.rem -= denom; + } + return (r); +} diff --git a/sdk/tlibc/stdlib/malloc.c b/sdk/tlibc/stdlib/malloc.c new file mode 100755 index 0000000000..c222e6553b --- /dev/null +++ b/sdk/tlibc/stdlib/malloc.c @@ -0,0 +1,6363 @@ +/* + This is a version (aka dlmalloc) of malloc/free/realloc written by + Doug Lea and released to the public domain, as explained at + http://creativecommons.org/publicdomain/zero/1.0/ Send questions, + comments, complaints, performance data, etc to dl@cs.oswego.edu + +* Version 2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea + Note: There may be an updated version of this malloc obtainable at + ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + +* Quickstart + + This library is all in one file to simplify the most common usage: + ftp it, compile it (-O3), and link it into another program. All of + the compile-time options default to reasonable values for use on + most platforms. You might later want to step through various + compile-time and dynamic tuning options. + + For convenience, an include file for code using this malloc is at: + ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.6.h + You don't really need this .h file unless you call functions not + defined in your system include files. The .h file contains only the + excerpts from this file needed for using this malloc on ANSI C/C++ + systems, so long as you haven't changed compile-time options about + naming and tuning parameters. If you do, then you can create your + own malloc.h that does include all settings by cutting at the point + indicated below. Note that you may already by default be using a C + library containing a malloc that is based on some version of this + malloc (for example in linux). You might still want to use the one + in this file to customize settings or to avoid overheads associated + with library versions. + +* Vital statistics: + + Supported pointer/size_t representation: 4 or 8 bytes + size_t MUST be an unsigned type of the same width as + pointers. (If you are using an ancient system that declares + size_t as a signed type, or need it to be a different width + than pointers, you can use a previous release of this malloc + (e.g. 2.7.2) supporting these.) + + Alignment: 8 bytes (minimum) + This suffices for nearly all current machines and C compilers. + However, you can define MALLOC_ALIGNMENT to be wider than this + if necessary (up to 128bytes), at the expense of using more space. + + Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes) + 8 or 16 bytes (if 8byte sizes) + Each malloced chunk has a hidden word of overhead holding size + and status information, and additional cross-check word + if FOOTERS is defined. + + Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead) + 8-byte ptrs: 32 bytes (including overhead) + + Even a request for zero bytes (i.e., malloc(0)) returns a + pointer to something of the minimum allocatable size. + The maximum overhead wastage (i.e., number of extra bytes + allocated than were requested in malloc) is less than or equal + to the minimum size, except for requests >= mmap_threshold that + are serviced via mmap(), where the worst case wastage is about + 32 bytes plus the remainder from a system page (the minimal + mmap unit); typically 4096 or 8192 bytes. + + Security: static-safe; optionally more or less + The "security" of malloc refers to the ability of malicious + code to accentuate the effects of errors (for example, freeing + space that is not currently malloc'ed or overwriting past the + ends of chunks) in code that calls malloc. This malloc + guarantees not to modify any memory locations below the base of + heap, i.e., static variables, even in the presence of usage + errors. The routines additionally detect most improper frees + and reallocs. All this holds as long as the static bookkeeping + for malloc itself is not corrupted by some other means. This + is only one aspect of security -- these checks do not, and + cannot, detect all possible programming errors. + + If FOOTERS is defined nonzero, then each allocated chunk + carries an additional check word to verify that it was malloced + from its space. These check words are the same within each + execution of a program using malloc, but differ across + executions, so externally crafted fake chunks cannot be + freed. This improves security by rejecting frees/reallocs that + could corrupt heap memory, in addition to the checks preventing + writes to statics that are always on. This may further improve + security at the expense of time and space overhead. (Note that + FOOTERS may also be worth using with MSPACES.) + + By default detected errors cause the program to abort (calling + "abort()"). You can override this to instead proceed past + errors by defining PROCEED_ON_ERROR. In this case, a bad free + has no effect, and a malloc that encounters a bad address + caused by user overwrites will ignore the bad address by + dropping pointers and indices to all known memory. This may + be appropriate for programs that should continue if at all + possible in the face of programming errors, although they may + run out of memory because dropped memory is never reclaimed. + + If you don't like either of these options, you can define + CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything + else. And if if you are sure that your program using malloc has + no errors or vulnerabilities, you can define INSECURE to 1, + which might (or might not) provide a small performance improvement. + + It is also possible to limit the maximum total allocatable + space, using malloc_set_footprint_limit. This is not + designed as a security feature in itself (calls to set limits + are not screened or privileged), but may be useful as one + aspect of a secure implementation. + + Thread-safety: NOT thread-safe unless USE_LOCKS defined non-zero + When USE_LOCKS is defined, each public call to malloc, free, + etc is surrounded with a lock. By default, this uses a plain + pthread mutex, win32 critical section, or a spin-lock if if + available for the platform and not disabled by setting + USE_SPIN_LOCKS=0. However, if USE_RECURSIVE_LOCKS is defined, + recursive versions are used instead (which are not required for + base functionality but may be needed in layered extensions). + Using a global lock is not especially fast, and can be a major + bottleneck. It is designed only to provide minimal protection + in concurrent environments, and to provide a basis for + extensions. If you are using malloc in a concurrent program, + consider instead using nedmalloc + (http://www.nedprod.com/programs/portable/nedmalloc/) or + ptmalloc (See http://www.malloc.de), which are derived from + versions of this malloc. + + System requirements: Any combination of MORECORE and/or MMAP/MUNMAP + This malloc can use unix sbrk or any emulation (invoked using + the CALL_MORECORE macro) and/or mmap/munmap or any emulation + (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system + memory. On most unix systems, it tends to work best if both + MORECORE and MMAP are enabled. On Win32, it uses emulations + based on VirtualAlloc. It also uses common C library functions + like memset. + + Compliance: I believe it is compliant with the Single Unix Specification + (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably + others as well. + +* Overview of algorithms + + This is not the fastest, most space-conserving, most portable, or + most tunable malloc ever written. However it is among the fastest + while also being among the most space-conserving, portable and + tunable. Consistent balance across these factors results in a good + general-purpose allocator for malloc-intensive programs. + + In most ways, this malloc is a best-fit allocator. Generally, it + chooses the best-fitting existing chunk for a request, with ties + broken in approximately least-recently-used order. (This strategy + normally maintains low fragmentation.) However, for requests less + than 256bytes, it deviates from best-fit when there is not an + exactly fitting available chunk by preferring to use space adjacent + to that used for the previous small request, as well as by breaking + ties in approximately most-recently-used order. (These enhance + locality of series of small allocations.) And for very large requests + (>= 256Kb by default), it relies on system memory mapping + facilities, if supported. (This helps avoid carrying around and + possibly fragmenting memory used only for large chunks.) + + All operations (except malloc_stats and mallinfo) have execution + times that are bounded by a constant factor of the number of bits in + a size_t, not counting any clearing in calloc or copying in realloc, + or actions surrounding MORECORE and MMAP that have times + proportional to the number of non-contiguous regions returned by + system allocation routines, which is often just 1. In real-time + applications, you can optionally suppress segment traversals using + NO_SEGMENT_TRAVERSAL, which assures bounded execution even when + system allocators return non-contiguous spaces, at the typical + expense of carrying around more memory and increased fragmentation. + + The implementation is not very modular and seriously overuses + macros. Perhaps someday all C compilers will do as good a job + inlining modular code as can now be done by brute-force expansion, + but now, enough of them seem not to. + + Some compilers issue a lot of warnings about code that is + dead/unreachable only on some platforms, and also about intentional + uses of negation on unsigned types. All known cases of each can be + ignored. + + For a longer but out of date high-level description, see + http://gee.cs.oswego.edu/dl/html/malloc.html + +* MSPACES + If MSPACES is defined, then in addition to malloc, free, etc., + this file also defines mspace_malloc, mspace_free, etc. These + are versions of malloc routines that take an "mspace" argument + obtained using create_mspace, to control all internal bookkeeping. + If ONLY_MSPACES is defined, only these versions are compiled. + So if you would like to use this allocator for only some allocations, + and your system malloc for others, you can compile with + ONLY_MSPACES and then do something like... + static mspace mymspace = create_mspace(0,0); // for example + #define mymalloc(bytes) mspace_malloc(mymspace, bytes) + + (Note: If you only need one instance of an mspace, you can instead + use "USE_DL_PREFIX" to relabel the global malloc.) + + You can similarly create thread-local allocators by storing + mspaces as thread-locals. For example: + static __thread mspace tlms = 0; + void* tlmalloc(size_t bytes) { + if (tlms == 0) tlms = create_mspace(0, 0); + return mspace_malloc(tlms, bytes); + } + void tlfree(void* mem) { mspace_free(tlms, mem); } + + Unless FOOTERS is defined, each mspace is completely independent. + You cannot allocate from one and free to another (although + conformance is only weakly checked, so usage errors are not always + caught). If FOOTERS is defined, then each chunk carries around a tag + indicating its originating mspace, and frees are directed to their + originating spaces. Normally, this requires use of locks. + + ------------------------- Compile-time options --------------------------- + +Be careful in setting #define values for numerical constants of type +size_t. On some systems, literal values are not automatically extended +to size_t precision unless they are explicitly casted. You can also +use the symbolic values MAX_SIZE_T, SIZE_T_ONE, etc below. + +WIN32 default: defined if _WIN32 defined + Defining WIN32 sets up defaults for MS environment and compilers. + Otherwise defaults are for unix. Beware that there seem to be some + cases where this malloc might not be a pure drop-in replacement for + Win32 malloc: Random-looking failures from Win32 GDI API's (eg; + SetDIBits()) may be due to bugs in some video driver implementations + when pixel buffers are malloc()ed, and the region spans more than + one VirtualAlloc()ed region. Because dlmalloc uses a small (64Kb) + default granularity, pixel buffers may straddle virtual allocation + regions more often than when using the Microsoft allocator. You can + avoid this by using VirtualAlloc() and VirtualFree() for all pixel + buffers rather than using malloc(). If this is not possible, + recompile this malloc with a larger DEFAULT_GRANULARITY. Note: + in cases where MSC and gcc (cygwin) are known to differ on WIN32, + conditions use _MSC_VER to distinguish them. + +DLMALLOC_EXPORT default: extern + Defines how public APIs are declared. If you want to export via a + Windows DLL, you might define this as + #define DLMALLOC_EXPORT extern __declspec(dllexport) + If you want a POSIX ELF shared object, you might use + #define DLMALLOC_EXPORT extern __attribute__((visibility("default"))) + +MALLOC_ALIGNMENT default: (size_t)(2 * sizeof(void *)) + Controls the minimum alignment for malloc'ed chunks. It must be a + power of two and at least 8, even on machines for which smaller + alignments would suffice. It may be defined as larger than this + though. Note however that code and data structures are optimized for + the case of 8-byte alignment. + +MSPACES default: 0 (false) + If true, compile in support for independent allocation spaces. + This is only supported if HAVE_MMAP is true. + +ONLY_MSPACES default: 0 (false) + If true, only compile in mspace versions, not regular versions. + +USE_LOCKS default: 0 (false) + Causes each call to each public routine to be surrounded with + pthread or WIN32 mutex lock/unlock. (If set true, this can be + overridden on a per-mspace basis for mspace versions.) If set to a + non-zero value other than 1, locks are used, but their + implementation is left out, so lock functions must be supplied manually, + as described below. + +USE_SPIN_LOCKS default: 1 iff USE_LOCKS and spin locks available + If true, uses custom spin locks for locking. This is currently + supported only gcc >= 4.1, older gccs on x86 platforms, and recent + MS compilers. Otherwise, posix locks or win32 critical sections are + used. + +USE_RECURSIVE_LOCKS default: not defined + If defined nonzero, uses recursive (aka reentrant) locks, otherwise + uses plain mutexes. This is not required for malloc proper, but may + be needed for layered allocators such as nedmalloc. + +LOCK_AT_FORK default: not defined + If defined nonzero, performs pthread_atfork upon initialization + to initialize child lock while holding parent lock. The implementation + assumes that pthread locks (not custom locks) are being used. In other + cases, you may need to customize the implementation. + +FOOTERS default: 0 + If true, provide extra checking and dispatching by placing + information in the footers of allocated chunks. This adds + space and time overhead. + +INSECURE default: 0 + If true, omit checks for usage errors and heap space overwrites. + +USE_DL_PREFIX default: NOT defined + Causes compiler to prefix all public routines with the string 'dl'. + This can be useful when you only want to use this malloc in one part + of a program, using your regular system malloc elsewhere. + +MALLOC_INSPECT_ALL default: NOT defined + If defined, compiles malloc_inspect_all and mspace_inspect_all, that + perform traversal of all heap space. Unless access to these + functions is otherwise restricted, you probably do not want to + include them in secure implementations. + +ABORT default: defined as abort() + Defines how to abort on failed checks. On most systems, a failed + check cannot die with an "assert" or even print an informative + message, because the underlying print routines in turn call malloc, + which will fail again. Generally, the best policy is to simply call + abort(). It's not very useful to do more than this because many + errors due to overwriting will show up as address faults (null, odd + addresses etc) rather than malloc-triggered checks, so will also + abort. Also, most compilers know that abort() does not return, so + can better optimize code conditionally calling it. + +PROCEED_ON_ERROR default: defined as 0 (false) + Controls whether detected bad addresses cause them to bypassed + rather than aborting. If set, detected bad arguments to free and + realloc are ignored. And all bookkeeping information is zeroed out + upon a detected overwrite of freed heap space, thus losing the + ability to ever return it from malloc again, but enabling the + application to proceed. If PROCEED_ON_ERROR is defined, the + static variable malloc_corruption_error_count is compiled in + and can be examined to see if errors have occurred. This option + generates slower code than the default abort policy. + +DEBUG default: NOT defined + The DEBUG setting is mainly intended for people trying to modify + this code or diagnose problems when porting to new platforms. + However, it may also be able to better isolate user errors than just + using runtime checks. The assertions in the check routines spell + out in more detail the assumptions and invariants underlying the + algorithms. The checking is fairly extensive, and will slow down + execution noticeably. Calling malloc_stats or mallinfo with DEBUG + set will attempt to check every non-mmapped allocated and free chunk + in the course of computing the summaries. + +ABORT_ON_ASSERT_FAILURE default: defined as 1 (true) + Debugging assertion failures can be nearly impossible if your + version of the assert macro causes malloc to be called, which will + lead to a cascade of further failures, blowing the runtime stack. + ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(), + which will usually make debugging easier. + +MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32 + The action to take before "return 0" when malloc fails to be able to + return memory because there is none available. + +HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES + True if this system supports sbrk or an emulation of it. + +MORECORE default: sbrk + The name of the sbrk-style system routine to call to obtain more + memory. See below for guidance on writing custom MORECORE + functions. The type of the argument to sbrk/MORECORE varies across + systems. It cannot be size_t, because it supports negative + arguments, so it is normally the signed type of the same width as + size_t (sometimes declared as "intptr_t"). It doesn't much matter + though. Internally, we only call it with arguments less than half + the max value of a size_t, which should work across all reasonable + possibilities, although sometimes generating compiler warnings. + +MORECORE_CONTIGUOUS default: 1 (true) if HAVE_MORECORE + If true, take advantage of fact that consecutive calls to MORECORE + with positive arguments always return contiguous increasing + addresses. This is true of unix sbrk. It does not hurt too much to + set it true anyway, since malloc copes with non-contiguities. + Setting it false when definitely non-contiguous saves time + and possibly wasted space it would take to discover this though. + +MORECORE_CANNOT_TRIM default: NOT defined + True if MORECORE cannot release space back to the system when given + negative arguments. This is generally necessary only if you are + using a hand-crafted MORECORE function that cannot handle negative + arguments. + +NO_SEGMENT_TRAVERSAL default: 0 + If non-zero, suppresses traversals of memory segments + returned by either MORECORE or CALL_MMAP. This disables + merging of segments that are contiguous, and selectively + releasing them to the OS if unused, but bounds execution times. + +HAVE_MMAP default: 1 (true) + True if this system supports mmap or an emulation of it. If so, and + HAVE_MORECORE is not true, MMAP is used for all system + allocation. If set and HAVE_MORECORE is true as well, MMAP is + primarily used to directly allocate very large blocks. It is also + used as a backup strategy in cases where MORECORE fails to provide + space from system. Note: A single call to MUNMAP is assumed to be + able to unmap memory that may have be allocated using multiple calls + to MMAP, so long as they are adjacent. + +HAVE_MREMAP default: 1 on linux, else 0 + If true realloc() uses mremap() to re-allocate large blocks and + extend or shrink allocation spaces. + +MMAP_CLEARS default: 1 except on WINCE. + True if mmap clears memory so calloc doesn't need to. This is true + for standard unix mmap using /dev/zero and on WIN32 except for WINCE. + +USE_BUILTIN_FFS default: 0 (i.e., not used) + Causes malloc to use the builtin ffs() function to compute indices. + Some compilers may recognize and intrinsify ffs to be faster than the + supplied C version. Also, the case of x86 using gcc is special-cased + to an asm instruction, so is already as fast as it can be, and so + this setting has no effect. Similarly for Win32 under recent MS compilers. + (On most x86s, the asm version is only slightly faster than the C version.) + +malloc_getpagesize default: derive from system includes, or 4096. + The system page size. To the extent possible, this malloc manages + memory from the system in page-size units. This may be (and + usually is) a function rather than a constant. This is ignored + if WIN32, where page size is determined using getSystemInfo during + initialization. + +USE_DEV_RANDOM default: 0 (i.e., not used) + Causes malloc to use /dev/random to initialize secure magic seed for + stamping footers. Otherwise, the current time is used. + +NO_MALLINFO default: 0 + If defined, don't compile "mallinfo". This can be a simple way + of dealing with mismatches between system declarations and + those in this file. + +MALLINFO_FIELD_TYPE default: size_t + The type of the fields in the mallinfo struct. This was originally + defined as "int" in SVID etc, but is more usefully defined as + size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set + +NO_MALLOC_STATS default: 0 + If defined, don't compile "malloc_stats". This avoids calls to + fprintf and bringing in stdio dependencies you might not want. + +REALLOC_ZERO_BYTES_FREES default: not defined + This should be set if a call to realloc with zero bytes should + be the same as a call to free. Some people think it should. Otherwise, + since this malloc returns a unique pointer for malloc(0), so does + realloc(p, 0). + +LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H +LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H +LACKS_STDLIB_H LACKS_SCHED_H LACKS_TIME_H default: NOT defined unless on WIN32 + Define these if your system does not have these header files. + You might need to manually insert some of the declarations they provide. + +DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS, + system_info.dwAllocationGranularity in WIN32, + otherwise 64K. + Also settable using mallopt(M_GRANULARITY, x) + The unit for allocating and deallocating memory from the system. On + most systems with contiguous MORECORE, there is no reason to + make this more than a page. However, systems with MMAP tend to + either require or encourage larger granularities. You can increase + this value to prevent system allocation functions to be called so + often, especially if they are slow. The value must be at least one + page and must be a power of two. Setting to 0 causes initialization + to either page size or win32 region size. (Note: In previous + versions of malloc, the equivalent of this option was called + "TOP_PAD") + +DEFAULT_TRIM_THRESHOLD default: 2MB + Also settable using mallopt(M_TRIM_THRESHOLD, x) + The maximum amount of unused top-most memory to keep before + releasing via malloc_trim in free(). Automatic trimming is mainly + useful in long-lived programs using contiguous MORECORE. Because + trimming via sbrk can be slow on some systems, and can sometimes be + wasteful (in cases where programs immediately afterward allocate + more large chunks) the value should be high enough so that your + overall system performance would improve by releasing this much + memory. As a rough guide, you might set to a value close to the + average size of a process (program) running on your system. + Releasing this much memory would allow such a process to run in + memory. Generally, it is worth tuning trim thresholds when a + program undergoes phases where several large chunks are allocated + and released in ways that can reuse each other's storage, perhaps + mixed with phases where there are no such chunks at all. The trim + value must be greater than page size to have any useful effect. To + disable trimming completely, you can set to MAX_SIZE_T. Note that the trick + some people use of mallocing a huge space and then freeing it at + program startup, in an attempt to reserve system memory, doesn't + have the intended effect under automatic trimming, since that memory + will immediately be returned to the system. + +DEFAULT_MMAP_THRESHOLD default: 256K + Also settable using mallopt(M_MMAP_THRESHOLD, x) + The request size threshold for using MMAP to directly service a + request. Requests of at least this size that cannot be allocated + using already-existing space will be serviced via mmap. (If enough + normal freed space already exists it is used instead.) Using mmap + segregates relatively large chunks of memory so that they can be + individually obtained and released from the host system. A request + serviced through mmap is never reused by any other request (at least + not directly; the system may just so happen to remap successive + requests to the same locations). Segregating space in this way has + the benefits that: Mmapped space can always be individually released + back to the system, which helps keep the system level memory demands + of a long-lived program low. Also, mapped memory doesn't become + `locked' between other chunks, as can happen with normally allocated + chunks, which means that even trimming via malloc_trim would not + release them. However, it has the disadvantage that the space + cannot be reclaimed, consolidated, and then used to service later + requests, as happens with normal chunks. The advantages of mmap + nearly always outweigh disadvantages for "large" chunks, but the + value of "large" may vary across systems. The default is an + empirically derived value that works well in most systems. You can + disable mmap by setting to MAX_SIZE_T. + +MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP + The number of consolidated frees between checks to release + unused segments when freeing. When using non-contiguous segments, + especially with multiple mspaces, checking only for topmost space + doesn't always suffice to trigger trimming. To compensate for this, + free() will, with a period of MAX_RELEASE_CHECK_RATE (or the + current number of segments, if greater) try to release unused + segments to the OS when freeing chunks that result in + consolidation. The best value for this parameter is a compromise + between slowing down frees with relatively costly checks that + rarely trigger versus holding on to unused memory. To effectively + disable, set to MAX_SIZE_T. This may lead to a very slight speed + improvement at the expense of carrying around more memory. +*/ + +/* Version identifier to allow people to support multiple versions */ +#ifndef DLMALLOC_VERSION +#define DLMALLOC_VERSION 20806 +#endif /* DLMALLOC_VERSION */ + +#ifndef DLMALLOC_EXPORT +#define DLMALLOC_EXPORT extern +#endif + +#ifndef _TLIBC_ +#define _TLIBC_ +#endif + +#ifdef _TLIBC_ /* tlibc configurations */ +#define HAVE_MMAP 0 +#define HAVE_MREMAP 0 +#define HAVE_MORECORE 1 +#define MMAP_CLEARS 0 +#define MALLOC_ALIGNMENT ((size_t)8U) +#define LACKS_TIME_H +#define LACKS_SYS_PARAM_H +#define LACKS_SYS_MMAN_H +#define LACKS_STRINGS_H +#define LACKS_SCHED_H +#ifdef _MSC_VER +typedef unsigned long DWORD; +typedef int LONG; +#endif +#define USE_LOCKS 1 +#define USE_SPIN_LOCKS 1 +#define FOOTERS 1 +#define REALLOC_ZERO_BYTES_FREES 1 +#include "sgx_trts.h" /* sgx_read_rand */ +#include "sgx_error.h" /* SGX_SUCCESS */ +#endif /* _TLIBC_ */ + +#ifndef WIN32 +#ifdef _WIN32 +#define WIN32 1 +#endif /* _WIN32 */ +#ifdef _WIN32_WCE +#define LACKS_FCNTL_H +#define WIN32 1 +#endif /* _WIN32_WCE */ +#endif /* WIN32 */ +#if defined(WIN32) && !defined(_TLIBC_) +#define WIN32_LEAN_AND_MEAN +#include +#include +#define HAVE_MMAP 1 +#define HAVE_MORECORE 0 +#define LACKS_UNISTD_H +#define LACKS_SYS_PARAM_H +#define LACKS_SYS_MMAN_H +#define LACKS_STRING_H +#define LACKS_STRINGS_H +#define LACKS_SYS_TYPES_H +#define LACKS_ERRNO_H +#define LACKS_SCHED_H +#ifndef MALLOC_FAILURE_ACTION +#define MALLOC_FAILURE_ACTION +#endif /* MALLOC_FAILURE_ACTION */ +#ifndef MMAP_CLEARS +#ifdef _WIN32_WCE /* WINCE reportedly does not clear */ +#define MMAP_CLEARS 0 +#else +#define MMAP_CLEARS 1 +#endif /* _WIN32_WCE */ +#endif /*MMAP_CLEARS */ +#endif /* WIN32 && !_TLIBC_*/ + +#if defined(DARWIN) || defined(_DARWIN) +/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ +#ifndef HAVE_MORECORE +#define HAVE_MORECORE 0 +#define HAVE_MMAP 1 +/* OSX allocators provide 16 byte alignment */ +#ifndef MALLOC_ALIGNMENT +#define MALLOC_ALIGNMENT ((size_t)16U) +#endif +#endif /* HAVE_MORECORE */ +#endif /* DARWIN */ + +#ifndef LACKS_SYS_TYPES_H +#include /* For size_t */ +#endif /* LACKS_SYS_TYPES_H */ + +/* The maximum possible size_t value has all bits set */ +#define MAX_SIZE_T (~(size_t)0) + +#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ +#define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ + (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) +#endif /* USE_LOCKS */ + +#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ +#if ((defined(__GNUC__) && \ + ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ + defined(__i386__) || defined(__x86_64__))) || \ + (defined(_MSC_VER) && _MSC_VER>=1310)) +#ifndef USE_SPIN_LOCKS +#define USE_SPIN_LOCKS 1 +#endif /* USE_SPIN_LOCKS */ +#elif USE_SPIN_LOCKS +#error "USE_SPIN_LOCKS defined without implementation" +#endif /* ... locks available... */ +#elif !defined(USE_SPIN_LOCKS) +#define USE_SPIN_LOCKS 0 +#endif /* USE_LOCKS */ + +#ifndef ONLY_MSPACES +#define ONLY_MSPACES 0 +#endif /* ONLY_MSPACES */ +#ifndef MSPACES +#if ONLY_MSPACES +#define MSPACES 1 +#else /* ONLY_MSPACES */ +#define MSPACES 0 +#endif /* ONLY_MSPACES */ +#endif /* MSPACES */ +#ifndef MALLOC_ALIGNMENT +#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) +#endif /* MALLOC_ALIGNMENT */ +#ifndef FOOTERS +#define FOOTERS 0 +#endif /* FOOTERS */ +#ifndef ABORT +#define ABORT abort() +#endif /* ABORT */ +#ifndef ABORT_ON_ASSERT_FAILURE +#define ABORT_ON_ASSERT_FAILURE 1 +#endif /* ABORT_ON_ASSERT_FAILURE */ +#ifndef PROCEED_ON_ERROR +#define PROCEED_ON_ERROR 0 +#endif /* PROCEED_ON_ERROR */ + +#ifndef INSECURE +#define INSECURE 0 +#endif /* INSECURE */ +#ifndef MALLOC_INSPECT_ALL +#define MALLOC_INSPECT_ALL 0 +#endif /* MALLOC_INSPECT_ALL */ +#ifndef HAVE_MMAP +#define HAVE_MMAP 1 +#endif /* HAVE_MMAP */ +#ifndef MMAP_CLEARS +#define MMAP_CLEARS 1 +#endif /* MMAP_CLEARS */ +#ifndef HAVE_MREMAP +#ifdef linux +#define HAVE_MREMAP 1 +#define _GNU_SOURCE /* Turns on mremap() definition */ +#else /* linux */ +#define HAVE_MREMAP 0 +#endif /* linux */ +#endif /* HAVE_MREMAP */ +#ifndef MALLOC_FAILURE_ACTION +#define MALLOC_FAILURE_ACTION errno = ENOMEM; +#endif /* MALLOC_FAILURE_ACTION */ +#ifndef HAVE_MORECORE +#if ONLY_MSPACES +#define HAVE_MORECORE 0 +#else /* ONLY_MSPACES */ +#define HAVE_MORECORE 1 +#endif /* ONLY_MSPACES */ +#endif /* HAVE_MORECORE */ +#if !HAVE_MORECORE +#define MORECORE_CONTIGUOUS 0 +#else /* !HAVE_MORECORE */ +#define MORECORE_DEFAULT sbrk +#ifndef MORECORE_CONTIGUOUS +#define MORECORE_CONTIGUOUS 1 +#endif /* MORECORE_CONTIGUOUS */ +#endif /* HAVE_MORECORE */ +#ifndef DEFAULT_GRANULARITY +#if (MORECORE_CONTIGUOUS || defined(WIN32)) +#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ +#else /* MORECORE_CONTIGUOUS */ +#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) +#endif /* MORECORE_CONTIGUOUS */ +#endif /* DEFAULT_GRANULARITY */ +#ifndef DEFAULT_TRIM_THRESHOLD +#ifndef MORECORE_CANNOT_TRIM +#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) +#else /* MORECORE_CANNOT_TRIM */ +#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T +#endif /* MORECORE_CANNOT_TRIM */ +#endif /* DEFAULT_TRIM_THRESHOLD */ +#ifndef DEFAULT_MMAP_THRESHOLD +#if HAVE_MMAP +#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) +#else /* HAVE_MMAP */ +#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T +#endif /* HAVE_MMAP */ +#endif /* DEFAULT_MMAP_THRESHOLD */ +#ifndef MAX_RELEASE_CHECK_RATE +#if HAVE_MMAP +#define MAX_RELEASE_CHECK_RATE 4095 +#else +#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T +#endif /* HAVE_MMAP */ +#endif /* MAX_RELEASE_CHECK_RATE */ +#ifndef USE_BUILTIN_FFS +#define USE_BUILTIN_FFS 0 +#endif /* USE_BUILTIN_FFS */ +#ifndef USE_DEV_RANDOM +#define USE_DEV_RANDOM 0 +#endif /* USE_DEV_RANDOM */ +#ifndef NO_MALLINFO +#define NO_MALLINFO 0 +#endif /* NO_MALLINFO */ +#ifndef MALLINFO_FIELD_TYPE +#define MALLINFO_FIELD_TYPE size_t +#endif /* MALLINFO_FIELD_TYPE */ +#ifndef NO_MALLOC_STATS +#define NO_MALLOC_STATS 0 +#endif /* NO_MALLOC_STATS */ +#ifndef NO_SEGMENT_TRAVERSAL +#define NO_SEGMENT_TRAVERSAL 0 +#endif /* NO_SEGMENT_TRAVERSAL */ + +/* + mallopt tuning options. SVID/XPG defines four standard parameter + numbers for mallopt, normally defined in malloc.h. None of these + are used in this malloc, so setting them has no effect. But this + malloc does support the following options. +*/ + +#define M_TRIM_THRESHOLD (-1) +#define M_GRANULARITY (-2) +#define M_MMAP_THRESHOLD (-3) + +/* ------------------------ Mallinfo declarations ------------------------ */ + +#if !NO_MALLINFO +/* + This version of malloc supports the standard SVID/XPG mallinfo + routine that returns a struct containing usage properties and + statistics. It should work on any system that has a + /usr/include/malloc.h defining struct mallinfo. The main + declaration needed is the mallinfo struct that is returned (by-copy) + by mallinfo(). The malloinfo struct contains a bunch of fields that + are not even meaningful in this version of malloc. These fields are + are instead filled by mallinfo() with other numbers that might be of + interest. + + HAVE_USR_INCLUDE_MALLOC_H should be set if you have a + /usr/include/malloc.h file that includes a declaration of struct + mallinfo. If so, it is included; else a compliant version is + declared below. These must be precisely the same for mallinfo() to + work. The original SVID version of this struct, defined on most + systems with mallinfo, declares all fields as ints. But some others + define as unsigned long. If your system defines the fields using a + type of different width than listed here, you MUST #include your + system version and #define HAVE_USR_INCLUDE_MALLOC_H. +*/ + +/* #define HAVE_USR_INCLUDE_MALLOC_H */ + +#ifdef HAVE_USR_INCLUDE_MALLOC_H +#include "/usr/include/malloc.h" +#else /* HAVE_USR_INCLUDE_MALLOC_H */ +#ifndef STRUCT_MALLINFO_DECLARED +/* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */ +#define _STRUCT_MALLINFO +#define STRUCT_MALLINFO_DECLARED 1 +struct mallinfo { + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ +}; +#endif /* STRUCT_MALLINFO_DECLARED */ +#endif /* HAVE_USR_INCLUDE_MALLOC_H */ +#endif /* NO_MALLINFO */ + +/* + Try to persuade compilers to inline. The most critical functions for + inlining are defined as macros, so these aren't used for them. +*/ + +#ifndef FORCEINLINE + #if defined(__GNUC__) +#define FORCEINLINE __inline __attribute__ ((always_inline)) + #elif defined(_MSC_VER) + #define FORCEINLINE __forceinline + #endif +#endif +#ifndef NOINLINE + #if defined(__GNUC__) + #define NOINLINE __attribute__ ((noinline)) + #elif defined(_MSC_VER) + #define NOINLINE __declspec(noinline) + #else + #define NOINLINE + #endif +#endif + +#ifdef __cplusplus +extern "C" { +#ifndef FORCEINLINE + #define FORCEINLINE inline +#endif +#endif /* __cplusplus */ +#ifndef FORCEINLINE + #define FORCEINLINE +#endif + +#if !ONLY_MSPACES + +/* ------------------- Declarations of public routines ------------------- */ + +#ifndef USE_DL_PREFIX +#define dlcalloc calloc +#define dlfree free +#define dlmalloc malloc +#define dlmemalign memalign +#define dlrealloc realloc +#define dlmallinfo mallinfo +#ifdef USE_MALLOC_DEPRECATED +#define dlposix_memalign posix_memalign +#define dlrealloc_in_place realloc_in_place +#define dlvalloc valloc +#define dlpvalloc pvalloc +#define dlmallopt mallopt +#define dlmalloc_trim malloc_trim +#define dlmalloc_stats malloc_stats +#define dlmalloc_usable_size malloc_usable_size +#define dlmalloc_footprint malloc_footprint +#define dlmalloc_max_footprint malloc_max_footprint +#define dlmalloc_footprint_limit malloc_footprint_limit +#define dlmalloc_set_footprint_limit malloc_set_footprint_limit +#define dlmalloc_inspect_all malloc_inspect_all +#define dlindependent_calloc independent_calloc +#define dlindependent_comalloc independent_comalloc +#define dlbulk_free bulk_free +#endif /* USE_MALLOC_DEPRECATED */ +#endif /* USE_DL_PREFIX */ + +/* + malloc(size_t n) + Returns a pointer to a newly allocated chunk of at least n bytes, or + null if no space is available, in which case errno is set to ENOMEM + on ANSI C systems. + + If n is zero, malloc returns a minimum-sized chunk. (The minimum + size is 16 bytes on most 32bit systems, and 32 bytes on 64bit + systems.) Note that size_t is an unsigned type, so calls with + arguments that would be negative if signed are interpreted as + requests for huge amounts of space, which will often fail. The + maximum supported value of n differs across systems, but is in all + cases less than the maximum representable value of a size_t. +*/ +DLMALLOC_EXPORT void* dlmalloc(size_t); + +/* + free(void* p) + Releases the chunk of memory pointed to by p, that had been previously + allocated using malloc or a related routine such as realloc. + It has no effect if p is null. If p was not malloced or already + freed, free(p) will by default cause the current program to abort. +*/ +DLMALLOC_EXPORT void dlfree(void*); + +/* + calloc(size_t n_elements, size_t element_size); + Returns a pointer to n_elements * element_size bytes, with all locations + set to zero. +*/ +DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); + +/* + realloc(void* p, size_t n) + Returns a pointer to a chunk of size n that contains the same data + as does chunk p up to the minimum of (n, p's size) bytes, or null + if no space is available. + + The returned pointer may or may not be the same as p. The algorithm + prefers extending p in most cases when possible, otherwise it + employs the equivalent of a malloc-copy-free sequence. + + If p is null, realloc is equivalent to malloc. + + If space is not available, realloc returns null, errno is set (if on + ANSI) and p is NOT freed. + + if n is for fewer bytes than already held by p, the newly unused + space is lopped off and freed if possible. realloc with a size + argument of zero (re)allocates a minimum-sized chunk. + + The old unix realloc convention of allowing the last-free'd chunk + to be used as an argument to realloc is not supported. +*/ +DLMALLOC_EXPORT void* dlrealloc(void*, size_t); + +#ifdef USE_MALLOC_DEPRECATED +/* + realloc_in_place(void* p, size_t n) + Resizes the space allocated for p to size n, only if this can be + done without moving p (i.e., only if there is adjacent space + available if n is greater than p's current allocated size, or n is + less than or equal to p's size). This may be used instead of plain + realloc if an alternative allocation strategy is needed upon failure + to expand space; for example, reallocation of a buffer that must be + memory-aligned or cleared. You can use realloc_in_place to trigger + these alternatives only when needed. + + Returns p if successful; otherwise null. +*/ +DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); +#endif + +/* + memalign(size_t alignment, size_t n); + Returns a pointer to a newly allocated chunk of n bytes, aligned + in accord with the alignment argument. + + The alignment argument should be a power of two. If the argument is + not a power of two, the nearest greater power is used. + 8-byte alignment is guaranteed by normal malloc calls, so don't + bother calling memalign with an argument of 8 or less. + + Overreliance on memalign is a sure way to fragment space. +*/ +DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); + +#ifdef USE_MALLOC_DEPRECATED +/* + int posix_memalign(void** pp, size_t alignment, size_t n); + Allocates a chunk of n bytes, aligned in accord with the alignment + argument. Differs from memalign only in that it (1) assigns the + allocated memory to *pp rather than returning it, (2) fails and + returns EINVAL if the alignment is not a power of two (3) fails and + returns ENOMEM if memory cannot be allocated. +*/ +DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t); + +/* + valloc(size_t n); + Equivalent to memalign(pagesize, n), where pagesize is the page + size of the system. If the pagesize is unknown, 4096 is used. +*/ +DLMALLOC_EXPORT void* dlvalloc(size_t); + +/* + mallopt(int parameter_number, int parameter_value) + Sets tunable parameters The format is to provide a + (parameter-number, parameter-value) pair. mallopt then sets the + corresponding parameter to the argument value if it can (i.e., so + long as the value is meaningful), and returns 1 if successful else + 0. To workaround the fact that mallopt is specified to use int, + not size_t parameters, the value -1 is specially treated as the + maximum unsigned size_t value. + + SVID/XPG/ANSI defines four standard param numbers for mallopt, + normally defined in malloc.h. None of these are use in this malloc, + so setting them has no effect. But this malloc also supports other + options in mallopt. See below for details. Briefly, supported + parameters are as follows (listed defaults are for "typical" + configurations). + + Symbol param # default allowed param values + M_TRIM_THRESHOLD -1 2*1024*1024 any (-1 disables) + M_GRANULARITY -2 page size any power of 2 >= page size + M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) +*/ +DLMALLOC_EXPORT int dlmallopt(int, int); + +/* + malloc_footprint(); + Returns the number of bytes obtained from the system. The total + number of bytes allocated by malloc, realloc etc., is less than this + value. Unlike mallinfo, this function returns only a precomputed + result, so can be called frequently to monitor memory consumption. + Even if locks are otherwise defined, this function does not use them, + so results might not be up to date. +*/ +DLMALLOC_EXPORT size_t dlmalloc_footprint(void); + +/* + malloc_max_footprint(); + Returns the maximum number of bytes obtained from the system. This + value will be greater than current footprint if deallocated space + has been reclaimed by the system. The peak number of bytes allocated + by malloc, realloc etc., is less than this value. Unlike mallinfo, + this function returns only a precomputed result, so can be called + frequently to monitor memory consumption. Even if locks are + otherwise defined, this function does not use them, so results might + not be up to date. +*/ +DLMALLOC_EXPORT size_t dlmalloc_max_footprint(void); + +/* + malloc_footprint_limit(); + Returns the number of bytes that the heap is allowed to obtain from + the system, returning the last value returned by + malloc_set_footprint_limit, or the maximum size_t value if + never set. The returned value reflects a permission. There is no + guarantee that this number of bytes can actually be obtained from + the system. +*/ +DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(); + +/* + malloc_set_footprint_limit(); + Sets the maximum number of bytes to obtain from the system, causing + failure returns from malloc and related functions upon attempts to + exceed this value. The argument value may be subject to page + rounding to an enforceable limit; this actual value is returned. + Using an argument of the maximum possible size_t effectively + disables checks. If the argument is less than or equal to the + current malloc_footprint, then all future allocations that require + additional system memory will fail. However, invocation cannot + retroactively deallocate existing used memory. +*/ +DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); + +#if MALLOC_INSPECT_ALL +/* + malloc_inspect_all(void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg); + Traverses the heap and calls the given handler for each managed + region, skipping all bytes that are (or may be) used for bookkeeping + purposes. Traversal does not include include chunks that have been + directly memory mapped. Each reported region begins at the start + address, and continues up to but not including the end address. The + first used_bytes of the region contain allocated data. If + used_bytes is zero, the region is unallocated. The handler is + invoked with the given callback argument. If locks are defined, they + are held during the entire traversal. It is a bad idea to invoke + other malloc functions from within the handler. + + For example, to count the number of in-use chunks with size greater + than 1000, you could write: + static int count = 0; + void count_chunks(void* start, void* end, size_t used, void* arg) { + if (used >= 1000) ++count; + } + then: + malloc_inspect_all(count_chunks, NULL); + + malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined. +*/ +DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), + void* arg); + +#endif /* MALLOC_INSPECT_ALL */ + +#endif /* USE_MALLOC_DEPRECATED */ + +#if !NO_MALLINFO +/* + mallinfo() + Returns (by copy) a struct containing various summary statistics: + + arena: current total non-mmapped bytes allocated from system + ordblks: the number of free chunks + smblks: always zero. + hblks: current number of mmapped regions + hblkhd: total bytes held in mmapped regions + usmblks: the maximum total allocated space. This will be greater + than current total if trimming has occurred. + fsmblks: always zero + uordblks: current total allocated space (normal or mmapped) + fordblks: total free space + keepcost: the maximum number of bytes that could ideally be released + back to system via malloc_trim. ("ideally" means that + it ignores page restrictions etc.) + + Because these fields are ints, but internal bookkeeping may + be kept as longs, the reported values may wrap around zero and + thus be inaccurate. +*/ +DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); +#endif /* NO_MALLINFO */ + +#ifdef USE_MALLOC_DEPRECATED +/* + independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); + + independent_calloc is similar to calloc, but instead of returning a + single cleared space, it returns an array of pointers to n_elements + independent elements that can hold contents of size elem_size, each + of which starts out cleared, and can be independently freed, + realloc'ed etc. The elements are guaranteed to be adjacently + allocated (this is not guaranteed to occur with multiple callocs or + mallocs), which may also improve cache locality in some + applications. + + The "chunks" argument is optional (i.e., may be null, which is + probably the most typical usage). If it is null, the returned array + is itself dynamically allocated and should also be freed when it is + no longer needed. Otherwise, the chunks array must be of at least + n_elements in length. It is filled in with the pointers to the + chunks. + + In either case, independent_calloc returns this pointer array, or + null if the allocation failed. If n_elements is zero and "chunks" + is null, it returns a chunk representing an array with zero elements + (which should be freed if not wanted). + + Each element must be freed when it is no longer needed. This can be + done all at once using bulk_free. + + independent_calloc simplifies and speeds up implementations of many + kinds of pools. It may also be useful when constructing large data + structures that initially have a fixed number of fixed-sized nodes, + but the number is not known at compile time, and some of the nodes + may later need to be freed. For example: + + struct Node { int item; struct Node* next; }; + + struct Node* build_list() { + struct Node** pool; + int n = read_number_of_nodes_needed(); + if (n <= 0) return 0; + pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); + if (pool == 0) die(); + // organize into a linked list... + struct Node* first = pool[0]; + for (i = 0; i < n-1; ++i) + pool[i]->next = pool[i+1]; + free(pool); // Can now free the array (or not, if it is needed later) + return first; + } +*/ +DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); + +/* + independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); + + independent_comalloc allocates, all at once, a set of n_elements + chunks with sizes indicated in the "sizes" array. It returns + an array of pointers to these elements, each of which can be + independently freed, realloc'ed etc. The elements are guaranteed to + be adjacently allocated (this is not guaranteed to occur with + multiple callocs or mallocs), which may also improve cache locality + in some applications. + + The "chunks" argument is optional (i.e., may be null). If it is null + the returned array is itself dynamically allocated and should also + be freed when it is no longer needed. Otherwise, the chunks array + must be of at least n_elements in length. It is filled in with the + pointers to the chunks. + + In either case, independent_comalloc returns this pointer array, or + null if the allocation failed. If n_elements is zero and chunks is + null, it returns a chunk representing an array with zero elements + (which should be freed if not wanted). + + Each element must be freed when it is no longer needed. This can be + done all at once using bulk_free. + + independent_comallac differs from independent_calloc in that each + element may have a different size, and also that it does not + automatically clear elements. + + independent_comalloc can be used to speed up allocation in cases + where several structs or objects must always be allocated at the + same time. For example: + + struct Head { ... } + struct Foot { ... } + + void send_message(char* msg) { + int msglen = strlen(msg); + size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; + void* chunks[3]; + if (independent_comalloc(3, sizes, chunks) == 0) + die(); + struct Head* head = (struct Head*)(chunks[0]); + char* body = (char*)(chunks[1]); + struct Foot* foot = (struct Foot*)(chunks[2]); + // ... + } + + In general though, independent_comalloc is worth using only for + larger values of n_elements. For small values, you probably won't + detect enough difference from series of malloc calls to bother. + + Overuse of independent_comalloc can increase overall memory usage, + since it cannot reuse existing noncontiguous small chunks that + might be available for some of the elements. +*/ +DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); + +/* + bulk_free(void* array[], size_t n_elements) + Frees and clears (sets to null) each non-null pointer in the given + array. This is likely to be faster than freeing them one-by-one. + If footers are used, pointers that have been allocated in different + mspaces are not freed or cleared, and the count of all such pointers + is returned. For large arrays of pointers with poor locality, it + may be worthwhile to sort this array before calling bulk_free. +*/ +DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements); + +/* + pvalloc(size_t n); + Equivalent to valloc(minimum-page-that-holds(n)), that is, + round up n to nearest pagesize. + */ +DLMALLOC_EXPORT void* dlpvalloc(size_t); + +/* + malloc_trim(size_t pad); + + If possible, gives memory back to the system (via negative arguments + to sbrk) if there is unused memory at the `high' end of the malloc + pool or in unused MMAP segments. You can call this after freeing + large blocks of memory to potentially reduce the system-level memory + requirements of a program. However, it cannot guarantee to reduce + memory. Under some allocation patterns, some large free blocks of + memory will be locked between two used chunks, so they cannot be + given back to the system. + + The `pad' argument to malloc_trim represents the amount of free + trailing space to leave untrimmed. If this argument is zero, only + the minimum amount of memory to maintain internal data structures + will be left. Non-zero arguments can be supplied to maintain enough + trailing space to service future expected allocations without having + to re-obtain memory from the system. + + Malloc_trim returns 1 if it actually released any memory, else 0. +*/ +DLMALLOC_EXPORT int dlmalloc_trim(size_t); + +/* + malloc_stats(); + Prints on stderr the amount of space obtained from the system (both + via sbrk and mmap), the maximum amount (which may be more than + current if malloc_trim and/or munmap got called), and the current + number of bytes allocated via malloc (or realloc, etc) but not yet + freed. Note that this is the number of bytes allocated, not the + number requested. It will be larger than the number requested + because of alignment and bookkeeping overhead. Because it includes + alignment wastage as being in use, this figure may be greater than + zero even when no user-level chunks are allocated. + + The reported current and maximum system memory can be inaccurate if + a program makes other calls to system memory allocation functions + (normally sbrk) outside of malloc. + + malloc_stats prints only the most commonly interesting statistics. + More information can be obtained by calling mallinfo. +*/ +DLMALLOC_EXPORT void dlmalloc_stats(void); + +/* + malloc_usable_size(void* p); + + Returns the number of bytes you can actually use in + an allocated chunk, which may be more than you requested (although + often not) due to alignment and minimum size constraints. + You can use this many bytes without worrying about + overwriting other allocated objects. This is not a particularly great + programming practice. malloc_usable_size can be more useful in + debugging and assertions, for example: + + p = malloc(n); + assert(malloc_usable_size(p) >= 256); +*/ +size_t dlmalloc_usable_size(void*); + +#endif /* USE_MALLOC_DEPRECATED */ + +#endif /* ONLY_MSPACES */ + +#if MSPACES + +/* + mspace is an opaque type representing an independent + region of space that supports mspace_malloc, etc. +*/ +typedef void* mspace; + +/* + create_mspace creates and returns a new independent space with the + given initial capacity, or, if 0, the default granularity size. It + returns null if there is no system memory available to create the + space. If argument locked is non-zero, the space uses a separate + lock to control access. The capacity of the space will grow + dynamically as needed to service mspace_malloc requests. You can + control the sizes of incremental increases of this space by + compiling with a different DEFAULT_GRANULARITY or dynamically + setting with mallopt(M_GRANULARITY, value). +*/ +DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked); + +/* + destroy_mspace destroys the given space, and attempts to return all + of its memory back to the system, returning the total number of + bytes freed. After destruction, the results of access to all memory + used by the space become undefined. +*/ +DLMALLOC_EXPORT size_t destroy_mspace(mspace msp); + +/* + create_mspace_with_base uses the memory supplied as the initial base + of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this + space is used for bookkeeping, so the capacity must be at least this + large. (Otherwise 0 is returned.) When this initial space is + exhausted, additional memory will be obtained from the system. + Destroying this space will deallocate all additionally allocated + space (if possible) but not the initial base. +*/ +DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked); + +/* + mspace_track_large_chunks controls whether requests for large chunks + are allocated in their own untracked mmapped regions, separate from + others in this mspace. By default large chunks are not tracked, + which reduces fragmentation. However, such chunks are not + necessarily released to the system upon destroy_mspace. Enabling + tracking by setting to true may increase fragmentation, but avoids + leakage when relying on destroy_mspace to release all memory + allocated using this space. The function returns the previous + setting. +*/ +DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable); + + +/* + mspace_malloc behaves as malloc, but operates within + the given space. +*/ +DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); + +/* + mspace_free behaves as free, but operates within + the given space. + + If compiled with FOOTERS==1, mspace_free is not actually needed. + free may be called instead of mspace_free because freed chunks from + any space are handled by their originating spaces. +*/ +DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); + +/* + mspace_realloc behaves as realloc, but operates within + the given space. + + If compiled with FOOTERS==1, mspace_realloc is not actually + needed. realloc may be called instead of mspace_realloc because + realloced chunks from any space are handled by their originating + spaces. +*/ +DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize); + +/* + mspace_calloc behaves as calloc, but operates within + the given space. +*/ +DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); + +/* + mspace_memalign behaves as memalign, but operates within + the given space. +*/ +DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); + +/* + mspace_independent_calloc behaves as independent_calloc, but + operates within the given space. +*/ +DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]); + +/* + mspace_independent_comalloc behaves as independent_comalloc, but + operates within the given space. +*/ +DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]); + +/* + mspace_footprint() returns the number of bytes obtained from the + system for this space. +*/ +DLMALLOC_EXPORT size_t mspace_footprint(mspace msp); + +/* + mspace_max_footprint() returns the peak number of bytes obtained from the + system for this space. +*/ +DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp); + + +#if !NO_MALLINFO +/* + mspace_mallinfo behaves as mallinfo, but reports properties of + the given space. +*/ +DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp); +#endif /* NO_MALLINFO */ + +/* + malloc_usable_size(void* p) behaves the same as malloc_usable_size; +*/ +DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem); + +/* + mspace_malloc_stats behaves as malloc_stats, but reports + properties of the given space. +*/ +DLMALLOC_EXPORT void mspace_malloc_stats(mspace msp); + +/* + mspace_trim behaves as malloc_trim, but + operates within the given space. +*/ +DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad); + +/* + An alias for mallopt. +*/ +DLMALLOC_EXPORT int mspace_mallopt(int, int); + +#endif /* MSPACES */ + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif /* __cplusplus */ + +/* + ======================================================================== + To make a fully customizable malloc.h header file, cut everything + above this line, put into file malloc.h, edit to suit, and #include it + on the next line, as well as in programs that use this malloc. + ======================================================================== +*/ + +/* #include "malloc.h" */ + +/*------------------------------ internal #includes ---------------------- */ + +#ifdef _MSC_VER +#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ +#endif /* _MSC_VER */ +#if !NO_MALLOC_STATS +#include /* for printing in malloc_stats */ +#endif /* NO_MALLOC_STATS */ +#ifndef LACKS_ERRNO_H +#include /* for MALLOC_FAILURE_ACTION */ +#endif /* LACKS_ERRNO_H */ +#ifdef DEBUG +#if ABORT_ON_ASSERT_FAILURE +#undef assert +#define assert(x) if(!(x)) ABORT +#else /* ABORT_ON_ASSERT_FAILURE */ +#include +#endif /* ABORT_ON_ASSERT_FAILURE */ +#else /* DEBUG */ +#ifndef assert +#define assert(x) +#endif +#define DEBUG 0 +#endif /* DEBUG */ +#if !defined(WIN32) && !defined(LACKS_TIME_H) +#include /* for magic initialization */ +#endif /* WIN32 */ +#ifndef LACKS_STDLIB_H +#include /* for abort() */ +#endif /* LACKS_STDLIB_H */ +#ifndef LACKS_STRING_H +#include /* for memset etc */ +#endif /* LACKS_STRING_H */ +#if USE_BUILTIN_FFS +#ifndef LACKS_STRINGS_H +#include /* for ffs */ +#endif /* LACKS_STRINGS_H */ +#endif /* USE_BUILTIN_FFS */ +#if HAVE_MMAP +#ifndef LACKS_SYS_MMAN_H +/* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ +#if (defined(linux) && !defined(__USE_GNU)) +#define __USE_GNU 1 +#include /* for mmap */ +#undef __USE_GNU +#else +#include /* for mmap */ +#endif /* linux */ +#endif /* LACKS_SYS_MMAN_H */ +#ifndef LACKS_FCNTL_H +#include +#endif /* LACKS_FCNTL_H */ +#endif /* HAVE_MMAP */ +#ifndef LACKS_UNISTD_H +#include /* for sbrk, sysconf */ +#else /* LACKS_UNISTD_H */ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +extern void* sbrk(ptrdiff_t); +#endif /* FreeBSD etc */ +#endif /* LACKS_UNISTD_H */ + +/* Declarations for locking */ +#if USE_LOCKS +#ifndef WIN32 +#if defined (__SVR4) && defined (__sun) /* solaris */ +#include +#elif !defined(LACKS_SCHED_H) +#include +#endif /* solaris or LACKS_SCHED_H */ +#if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS +#include +#endif /* USE_RECURSIVE_LOCKS ... */ +#elif defined(_MSC_VER) +#ifndef _M_AMD64 +/* These are already defined on AMD64 builds */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp); +LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _M_AMD64 */ +#ifndef __ICL +#pragma intrinsic (_InterlockedCompareExchange) +#pragma intrinsic (_InterlockedExchange) +#endif /* __ICL */ +#define interlockedcompareexchange _InterlockedCompareExchange +#define interlockedexchange _InterlockedExchange +#elif defined(WIN32) && defined(__GNUC__) +#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) +#define interlockedexchange __sync_lock_test_and_set +#endif /* Win32 */ +#else /* USE_LOCKS */ +#endif /* USE_LOCKS */ + +#ifndef LOCK_AT_FORK +#define LOCK_AT_FORK 0 +#endif + +/* Declarations for bit scanning on win32 */ +#if defined(_MSC_VER) && _MSC_VER>=1300 +#ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +unsigned char _BitScanForward(unsigned long *index, unsigned long mask); +unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define BitScanForward _BitScanForward +#define BitScanReverse _BitScanReverse +#ifndef __ICL +#pragma intrinsic(_BitScanForward) +#pragma intrinsic(_BitScanReverse) +#endif /* __ICL */ +#endif /* BitScanForward */ +#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ + +#ifdef _TLIBC_ +#include "internal/arch.h" +# define malloc_getpagesize ((size_t)TCS_SIZE) +#else +#ifndef WIN32 +#ifndef malloc_getpagesize +# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ +# ifndef _SC_PAGE_SIZE +# define _SC_PAGE_SIZE _SC_PAGESIZE +# endif +# endif +# ifdef _SC_PAGE_SIZE +# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) +# else +# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) + extern size_t getpagesize(); +# define malloc_getpagesize getpagesize() +# else +# ifdef WIN32 /* use supplied emulation of getpagesize */ +# define malloc_getpagesize getpagesize() +# else +# ifndef LACKS_SYS_PARAM_H +# include +# endif +# ifdef EXEC_PAGESIZE +# define malloc_getpagesize EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define malloc_getpagesize NBPG +# else +# define malloc_getpagesize (NBPG * CLSIZE) +# endif +# else +# ifdef NBPC +# define malloc_getpagesize NBPC +# else +# ifdef PAGESIZE +# define malloc_getpagesize PAGESIZE +# else /* just guess */ +# define malloc_getpagesize ((size_t)4096U) +# endif +# endif +# endif +# endif +# endif +# endif +# endif +#endif +#endif +#endif /* _TLIBC_ */ + +/* ------------------- size_t and alignment properties -------------------- */ + +/* The byte and bit size of a size_t */ +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) + +/* Some constants coerced to size_t */ +/* Annoying but necessary to avoid errors on some platforms */ +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define SIZE_T_FOUR ((size_t)4) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) +#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) + +/* The bit mask value corresponding to MALLOC_ALIGNMENT */ +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) + +/* True if address a has acceptable alignment */ +#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) + +/* the number of bytes to offset an address to align it */ +#define align_offset(A)\ + ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ + ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) + +/* -------------------------- MMAP preliminaries ------------------------- */ + +/* + If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and + checks to fail so compiler optimizer can delete code rather than + using so many "#if"s. +*/ + + +/* MORECORE and MMAP must return MFAIL on failure */ +#define MFAIL ((void*)(MAX_SIZE_T)) +#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ + +#if HAVE_MMAP + +#ifndef WIN32 +#define MUNMAP_DEFAULT(a, s) munmap((a), (s)) +#define MMAP_PROT (PROT_READ|PROT_WRITE) +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif /* MAP_ANON */ +#ifdef MAP_ANONYMOUS +#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) +#define MMAP_DEFAULT(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) +#else /* MAP_ANONYMOUS */ +/* + Nearly all versions of mmap support MAP_ANONYMOUS, so the following + is unlikely to be needed, but is supplied just in case. +*/ +#define MMAP_FLAGS (MAP_PRIVATE) +static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ +#define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \ + (dev_zero_fd = open("/dev/zero", O_RDWR), \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) +#endif /* MAP_ANONYMOUS */ + +#define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) + +#else /* WIN32 */ + +/* Win32 MMAP via VirtualAlloc */ +static FORCEINLINE void* win32mmap(size_t size) { + void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + return (ptr != 0)? ptr: MFAIL; +} + +/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ +static FORCEINLINE void* win32direct_mmap(size_t size) { + void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, + PAGE_READWRITE); + return (ptr != 0)? ptr: MFAIL; +} + +/* This function supports releasing coalesed segments */ +static FORCEINLINE int win32munmap(void* ptr, size_t size) { + MEMORY_BASIC_INFORMATION minfo; + char* cptr = (char*)ptr; + while (size) { + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) + return -1; + if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || + minfo.State != MEM_COMMIT || minfo.RegionSize > size) + return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) + return -1; + cptr += minfo.RegionSize; + size -= minfo.RegionSize; + } + return 0; +} + +#define MMAP_DEFAULT(s) win32mmap(s) +#define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) +#define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) +#endif /* WIN32 */ +#endif /* HAVE_MMAP */ + +#if HAVE_MREMAP +#ifndef WIN32 +#define MREMAP_DEFAULT(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) +#endif /* WIN32 */ +#endif /* HAVE_MREMAP */ + +/** + * Define CALL_MORECORE + */ +#if HAVE_MORECORE + #ifdef MORECORE + #define CALL_MORECORE(S) MORECORE(S) + #else /* MORECORE */ + #define CALL_MORECORE(S) MORECORE_DEFAULT(S) + #endif /* MORECORE */ +#else /* HAVE_MORECORE */ + #define CALL_MORECORE(S) MFAIL +#endif /* HAVE_MORECORE */ + +/** + * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP + */ +#if HAVE_MMAP + #define USE_MMAP_BIT (SIZE_T_ONE) + + #ifdef MMAP + #define CALL_MMAP(s) MMAP(s) + #else /* MMAP */ + #define CALL_MMAP(s) MMAP_DEFAULT(s) + #endif /* MMAP */ + #ifdef MUNMAP + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) + #else /* MUNMAP */ + #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) + #endif /* MUNMAP */ + #ifdef DIRECT_MMAP + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #else /* DIRECT_MMAP */ + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) + #endif /* DIRECT_MMAP */ +#else /* HAVE_MMAP */ + #define USE_MMAP_BIT (SIZE_T_ZERO) + + #define MMAP(s) MFAIL + #define MUNMAP(a, s) (-1) + #define DIRECT_MMAP(s) MFAIL + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #define CALL_MMAP(s) MMAP(s) + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) +#endif /* HAVE_MMAP */ + +/** + * Define CALL_MREMAP + */ +#if HAVE_MMAP && HAVE_MREMAP + #ifdef MREMAP + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) + #else /* MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) + #endif /* MREMAP */ +#else /* HAVE_MMAP && HAVE_MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL +#endif /* HAVE_MMAP && HAVE_MREMAP */ + +/* mstate bit set if continguous morecore disabled or failed */ +#define USE_NONCONTIGUOUS_BIT (4U) + +/* segment bit set in create_mspace_with_base */ +#define EXTERN_BIT (8U) + + +/* --------------------------- Lock preliminaries ------------------------ */ + +/* + When locks are defined, there is one global lock, plus + one per-mspace lock. + + The global lock_ensures that mparams.magic and other unique + mparams values are initialized only once. It also protects + sequences of calls to MORECORE. In many cases sys_alloc requires + two calls, that should not be interleaved with calls by other + threads. This does not protect against direct calls to MORECORE + by other threads not using this lock, so there is still code to + cope the best we can on interference. + + Per-mspace locks surround calls to malloc, free, etc. + By default, locks are simple non-reentrant mutexes. + + Because lock-protected regions generally have bounded times, it is + OK to use the supplied simple spinlocks. Spinlocks are likely to + improve performance for lightly contended applications, but worsen + performance under heavy contention. + + If USE_LOCKS is > 1, the definitions of lock routines here are + bypassed, in which case you will need to define the type MLOCK_T, + and at least INITIAL_LOCK, DESTROY_LOCK, ACQUIRE_LOCK, RELEASE_LOCK + and TRY_LOCK. You must also declare a + static MLOCK_T malloc_global_mutex = { initialization values };. + +*/ + +#if !USE_LOCKS +#define USE_LOCK_BIT (0U) +#define INITIAL_LOCK(l) (0) +#define DESTROY_LOCK(l) (0) +#define ACQUIRE_MALLOC_GLOBAL_LOCK() +#define RELEASE_MALLOC_GLOBAL_LOCK() + +#else +#if USE_LOCKS > 1 +/* ----------------------- User-defined locks ------------------------ */ +/* Define your own lock implementation here */ +/* #define INITIAL_LOCK(lk) ... */ +/* #define DESTROY_LOCK(lk) ... */ +/* #define ACQUIRE_LOCK(lk) ... */ +/* #define RELEASE_LOCK(lk) ... */ +/* #define TRY_LOCK(lk) ... */ +/* static MLOCK_T malloc_global_mutex = ... */ + +#elif USE_SPIN_LOCKS + +/* First, define CAS_LOCK and CLEAR_LOCK on ints */ +/* Note CAS_LOCK defined to return 0 on success */ + +#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) +#define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) +#define CLEAR_LOCK(sl) __sync_lock_release(sl) + +#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) +/* Custom spin locks for older gcc on x86 */ +static FORCEINLINE int x86_cas_lock(int *sl) { + int ret; + int val = 1; + int cmp = 0; + __asm__ __volatile__ ("lock; cmpxchgl %1, %2" + : "=a" (ret) + : "r" (val), "m" (*(sl)), "0"(cmp) + : "memory", "cc"); + return ret; +} + +static FORCEINLINE void x86_clear_lock(int* sl) { + assert(*sl != 0); + int prev = 0; + int ret; + __asm__ __volatile__ ("lock; xchgl %0, %1" + : "=r" (ret) + : "m" (*(sl)), "0"(prev) + : "memory"); +} + +#define CAS_LOCK(sl) x86_cas_lock(sl) +#define CLEAR_LOCK(sl) x86_clear_lock(sl) + +#else /* Win32 MSC */ +#define CAS_LOCK(sl) interlockedexchange(sl, (LONG)1) +#define CLEAR_LOCK(sl) interlockedexchange (sl, (LONG)0) + +#endif /* ... gcc spins locks ... */ + +/* How to yield for a spin lock */ +#define SPINS_PER_YIELD 63 +#if defined(_MSC_VER) && !defined(_TLIBC_) +#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ +#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) +#elif defined (__SVR4) && defined (__sun) /* solaris */ +#define SPIN_LOCK_YIELD thr_yield(); +#elif !defined(LACKS_SCHED_H) +#define SPIN_LOCK_YIELD sched_yield(); +#else +#define SPIN_LOCK_YIELD +#endif /* ... yield ... */ + +#if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 +/* Plain spin locks use single word (embedded in malloc_states) */ +static int spin_acquire_lock(int *sl) { + int spins = 0; + while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) { + if ((++spins & SPINS_PER_YIELD) == 0) { + SPIN_LOCK_YIELD; + } + } + return 0; +} + +#define MLOCK_T int +#define TRY_LOCK(sl) !CAS_LOCK(sl) +#define RELEASE_LOCK(sl) CLEAR_LOCK(sl) +#define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0) +#define INITIAL_LOCK(sl) (*sl = 0) +#define DESTROY_LOCK(sl) (0) +static MLOCK_T malloc_global_mutex = 0; + +#else /* USE_RECURSIVE_LOCKS */ +/* types for lock owners */ +#ifdef WIN32 +#define THREAD_ID_T DWORD +#define CURRENT_THREAD GetCurrentThreadId() +#define EQ_OWNER(X,Y) ((X) == (Y)) +#else +/* + Note: the following assume that pthread_t is a type that can be + initialized to (casted) zero. If this is not the case, you will need to + somehow redefine these or not use spin locks. +*/ +#define THREAD_ID_T pthread_t +#define CURRENT_THREAD pthread_self() +#define EQ_OWNER(X,Y) pthread_equal(X, Y) +#endif + +struct malloc_recursive_lock { + int sl; + unsigned int c; + THREAD_ID_T threadid; +}; + +#define MLOCK_T struct malloc_recursive_lock +static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0}; + +static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) { + assert(lk->sl != 0); + if (--lk->c == 0) { + CLEAR_LOCK(&lk->sl); + } +} + +static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; + int spins = 0; + for (;;) { + if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; + lk->c = 1; + return 0; + } + } + else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; + return 0; + } + if ((++spins & SPINS_PER_YIELD) == 0) { + SPIN_LOCK_YIELD; + } + } +} + +static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; + if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; + lk->c = 1; + return 1; + } + } + else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; + return 1; + } + return 0; +} + +#define RELEASE_LOCK(lk) recursive_release_lock(lk) +#define TRY_LOCK(lk) recursive_try_lock(lk) +#define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) +#define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) +#define DESTROY_LOCK(lk) (0) +#endif /* USE_RECURSIVE_LOCKS */ + +#elif defined(WIN32) /* Win32 critical sections */ +#define MLOCK_T CRITICAL_SECTION +#define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) +#define RELEASE_LOCK(lk) LeaveCriticalSection(lk) +#define TRY_LOCK(lk) TryEnterCriticalSection(lk) +#define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000)) +#define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) +#define NEED_GLOBAL_LOCK_INIT + +static MLOCK_T malloc_global_mutex; +static volatile LONG malloc_global_mutex_status; + +/* Use spin loop to initialize global lock */ +static void init_malloc_global_mutex() { + for (;;) { + long stat = malloc_global_mutex_status; + if (stat > 0) + return; + /* transition to < 0 while initializing, then to > 0) */ + if (stat == 0 && + interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) { + InitializeCriticalSection(&malloc_global_mutex); + interlockedexchange(&malloc_global_mutex_status, (LONG)1); + return; + } + SleepEx(0, FALSE); + } +} + +#else /* pthreads-based locks */ +#define MLOCK_T pthread_mutex_t +#define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) +#define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) +#define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) +#define INITIAL_LOCK(lk) pthread_init_lock(lk) +#define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) + +#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) +/* Cope with old-style linux recursive lock initialization by adding */ +/* skipped internal declaration from pthread.h */ +extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, + int __kind)); +#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP +#define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) +#endif /* USE_RECURSIVE_LOCKS ... */ + +static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; + +static int pthread_init_lock (MLOCK_T *lk) { + pthread_mutexattr_t attr; + if (pthread_mutexattr_init(&attr)) return 1; +#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; +#endif + if (pthread_mutex_init(lk, &attr)) return 1; + if (pthread_mutexattr_destroy(&attr)) return 1; + return 0; +} + +#endif /* ... lock types ... */ + +/* Common code for all lock types */ +#define USE_LOCK_BIT (2U) + +#ifndef ACQUIRE_MALLOC_GLOBAL_LOCK +#define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); +#endif + +#ifndef RELEASE_MALLOC_GLOBAL_LOCK +#define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); +#endif + +#endif /* USE_LOCKS */ + +/* ----------------------- Chunk representations ------------------------ */ + +/* + (The following includes lightly edited explanations by Colin Plumb.) + + The malloc_chunk declaration below is misleading (but accurate and + necessary). It declares a "view" into memory allowing access to + necessary fields at known offsets from a given base. + + Chunks of memory are maintained using a `boundary tag' method as + originally described by Knuth. (See the paper by Paul Wilson + ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such + techniques.) Sizes of free chunks are stored both in the front of + each chunk and at the end. This makes consolidating fragmented + chunks into bigger chunks fast. The head fields also hold bits + representing whether chunks are free or in use. + + Here are some pictures to make it clearer. They are "exploded" to + show that the state of a chunk can be thought of as extending from + the high 31 bits of the head field of its header through the + prev_foot and PINUSE_BIT bit of the following chunk header. + + A chunk that's in use looks like: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk (if P = 0) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| + | Size of this chunk 1| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + +- -+ + | | + +- -+ + | : + +- size - sizeof(size_t) available payload bytes -+ + : | + chunk-> +- -+ + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| + | Size of next chunk (may or may not be in use) | +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + And if it's free, it looks like this: + + chunk-> +- -+ + | User payload (must be in use, or we would have merged!) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| + | Size of this chunk 0| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Next pointer | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Prev pointer | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | : + +- size - sizeof(struct chunk) unused bytes -+ + : | + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of this chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| + | Size of next chunk (must be in use, or we would have merged)| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | : + +- User payload -+ + : | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |0| + +-+ + Note that since we always merge adjacent free chunks, the chunks + adjacent to a free chunk must be in use. + + Given a pointer to a chunk (which can be derived trivially from the + payload pointer) we can, in O(1) time, find out whether the adjacent + chunks are free, and if so, unlink them from the lists that they + are on and merge them with the current chunk. + + Chunks always begin on even word boundaries, so the mem portion + (which is returned to the user) is also on an even word boundary, and + thus at least double-word aligned. + + The P (PINUSE_BIT) bit, stored in the unused low-order bit of the + chunk size (which is always a multiple of two words), is an in-use + bit for the *previous* chunk. If that bit is *clear*, then the + word before the current chunk size contains the previous chunk + size, and can be used to find the front of the previous chunk. + The very first chunk allocated always has this bit set, preventing + access to non-existent (or non-owned) memory. If pinuse is set for + any given chunk, then you CANNOT determine the size of the + previous chunk, and might even get a memory addressing fault when + trying to do so. + + The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of + the chunk size redundantly records whether the current chunk is + inuse (unless the chunk is mmapped). This redundancy enables usage + checks within free and realloc, and reduces indirection when freeing + and consolidating chunks. + + Each freshly allocated chunk must have both cinuse and pinuse set. + That is, each allocated chunk borders either a previously allocated + and still in-use chunk, or the base of its memory arena. This is + ensured by making all allocations from the `lowest' part of any + found chunk. Further, no free chunk physically borders another one, + so each free chunk is known to be preceded and followed by either + inuse chunks or the ends of memory. + + Note that the `foot' of the current chunk is actually represented + as the prev_foot of the NEXT chunk. This makes it easier to + deal with alignments etc but can be very confusing when trying + to extend or adapt this code. + + The exceptions to all this are + + 1. The special chunk `top' is the top-most available chunk (i.e., + the one bordering the end of available memory). It is treated + specially. Top is never included in any bin, is used only if + no other chunk is available, and is released back to the + system if it is very large (see M_TRIM_THRESHOLD). In effect, + the top chunk is treated as larger (and thus less well + fitting) than any other available chunk. The top chunk + doesn't update its trailing size field since there is no next + contiguous chunk that would have to index off it. However, + space is still allocated for it (TOP_FOOT_SIZE) to enable + separation or merging when space is extended. + + 3. Chunks allocated via mmap, have both cinuse and pinuse bits + cleared in their head fields. Because they are allocated + one-by-one, each must carry its own prev_foot field, which is + also used to hold the offset this chunk has within its mmapped + region, which is needed to preserve alignment. Each mmapped + chunk is trailed by the first two fields of a fake next-chunk + for sake of usage checks. + +*/ + +struct malloc_chunk { + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk* fd; /* double links -- used only if free. */ + struct malloc_chunk* bk; +}; + +typedef struct malloc_chunk mchunk; +typedef struct malloc_chunk* mchunkptr; +typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ +typedef unsigned int bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ + +/* ------------------- Chunks sizes and alignments ----------------------- */ + +#define MCHUNK_SIZE (sizeof(mchunk)) + +#if FOOTERS +#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +#else /* FOOTERS */ +#define CHUNK_OVERHEAD (SIZE_T_SIZE) +#endif /* FOOTERS */ + +/* MMapped chunks need a second word of overhead ... */ +#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +/* ... and additional padding for fake next-chunk at foot */ +#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) + +/* The smallest size we can malloc is an aligned minimal chunk */ +#define MIN_CHUNK_SIZE\ + ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* conversion from malloc headers to user pointers, and back */ +#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) +/* chunk associated with aligned address A */ +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) + +/* Bounds on request (not chunk) sizes. */ +#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) + +/* pad request bytes into a usable size */ +#define pad_request(req) \ + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* pad request, checking for minimum (but not maximum) */ +#define request2size(req) \ + (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) + + +/* ------------------ Operations on head and foot fields ----------------- */ + +/* + The head field of a chunk is or'ed with PINUSE_BIT when previous + adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in + use, unless mmapped, in which case both bits are cleared. + + FLAG4_BIT is not used by this malloc, but might be useful in extensions. +*/ + +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define FLAG4_BIT (SIZE_T_FOUR) +#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) +#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) + +/* Head value for fenceposts */ +#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) + +/* extraction of fields from head words */ +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define flag4inuse(p) ((p)->head & FLAG4_BIT) +#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) +#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) + +#define chunksize(p) ((p)->head & ~(FLAG_BITS)) + +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define set_flag4(p) ((p)->head |= FLAG4_BIT) +#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) + +/* Treat space at ptr +/- offset as a chunk */ +#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) +#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) + +/* Ptr to next or previous physical malloc_chunk. */ +#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) +#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) + +/* extract next chunk's pinuse bit */ +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) + +/* Get/set size at footer */ +#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) + +/* Set size, pinuse bit, and foot */ +#define set_size_and_pinuse_of_free_chunk(p, s)\ + ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) + +/* Set size, pinuse bit, foot, and clear next pinuse */ +#define set_free_with_pinuse(p, s, n)\ + (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) + +/* Get the internal overhead associated with chunk p */ +#define overhead_for(p)\ + (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) + +/* Return true if malloced space is not necessarily cleared */ +#if MMAP_CLEARS +#define calloc_must_clear(p) (!is_mmapped(p)) +#else /* MMAP_CLEARS */ +#define calloc_must_clear(p) (1) +#endif /* MMAP_CLEARS */ + +/* ---------------------- Overlaid data structures ----------------------- */ + +/* + When chunks are not in use, they are treated as nodes of either + lists or trees. + + "Small" chunks are stored in circular doubly-linked lists, and look + like this: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `head:' | Size of chunk, in bytes |P| + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Forward pointer to next chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Back pointer to previous chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Unused space (may be 0 bytes long) . + . . + . | +nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `foot:' | Size of chunk, in bytes | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Larger chunks are kept in a form of bitwise digital trees (aka + tries) keyed on chunksizes. Because malloc_tree_chunks are only for + free chunks greater than 256 bytes, their size doesn't impose any + constraints on user chunk sizes. Each node looks like: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `head:' | Size of chunk, in bytes |P| + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Forward pointer to next chunk of same size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Back pointer to previous chunk of same size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to left child (child[0]) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to right child (child[1]) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to parent | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | bin index of this chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Unused space . + . | +nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `foot:' | Size of chunk, in bytes | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Each tree holding treenodes is a tree of unique chunk sizes. Chunks + of the same size are arranged in a circularly-linked list, with only + the oldest chunk (the next to be used, in our FIFO ordering) + actually in the tree. (Tree members are distinguished by a non-null + parent pointer.) If a chunk with the same size an an existing node + is inserted, it is linked off the existing node using pointers that + work in the same way as fd/bk pointers of small chunks. + + Each tree contains a power of 2 sized range of chunk sizes (the + smallest is 0x100 <= x < 0x180), which is is divided in half at each + tree level, with the chunks in the smaller half of the range (0x100 + <= x < 0x140 for the top nose) in the left subtree and the larger + half (0x140 <= x < 0x180) in the right subtree. This is, of course, + done by inspecting individual bits. + + Using these rules, each node's left subtree contains all smaller + sizes than its right subtree. However, the node at the root of each + subtree has no particular ordering relationship to either. (The + dividing line between the subtree sizes is based on trie relation.) + If we remove the last chunk of a given size from the interior of the + tree, we need to replace it with a leaf node. The tree ordering + rules permit a node to be replaced by any leaf below it. + + The smallest chunk in a tree (a common operation in a best-fit + allocator) can be found by walking a path to the leftmost leaf in + the tree. Unlike a usual binary tree, where we follow left child + pointers until we reach a null, here we follow the right child + pointer any time the left one is null, until we reach a leaf with + both child pointers null. The smallest chunk in the tree will be + somewhere along that path. + + The worst case number of steps to add, find, or remove a node is + bounded by the number of bits differentiating chunks within + bins. Under current bin calculations, this ranges from 6 up to 21 + (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case + is of course much better. +*/ + +struct malloc_tree_chunk { + /* The first four fields must be compatible with malloc_chunk */ + size_t prev_foot; + size_t head; + struct malloc_tree_chunk* fd; + struct malloc_tree_chunk* bk; + + struct malloc_tree_chunk* child[2]; + struct malloc_tree_chunk* parent; + bindex_t index; +}; + +typedef struct malloc_tree_chunk tchunk; +typedef struct malloc_tree_chunk* tchunkptr; +typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ + +/* A little helper macro for trees */ +#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) + +/* ----------------------------- Segments -------------------------------- */ + +/* + Each malloc space may include non-contiguous segments, held in a + list headed by an embedded malloc_segment record representing the + top-most space. Segments also include flags holding properties of + the space. Large chunks that are directly allocated by mmap are not + included in this list. They are instead independently created and + destroyed without otherwise keeping track of them. + + Segment management mainly comes into play for spaces allocated by + MMAP. Any call to MMAP might or might not return memory that is + adjacent to an existing segment. MORECORE normally contiguously + extends the current space, so this space is almost always adjacent, + which is simpler and faster to deal with. (This is why MORECORE is + used preferentially to MMAP when both are available -- see + sys_alloc.) When allocating using MMAP, we don't use any of the + hinting mechanisms (inconsistently) supported in various + implementations of unix mmap, or distinguish reserving from + committing memory. Instead, we just ask for space, and exploit + contiguity when we get it. It is probably possible to do + better than this on some systems, but no general scheme seems + to be significantly better. + + Management entails a simpler variant of the consolidation scheme + used for chunks to reduce fragmentation -- new adjacent memory is + normally prepended or appended to an existing segment. However, + there are limitations compared to chunk consolidation that mostly + reflect the fact that segment processing is relatively infrequent + (occurring only when getting memory from system) and that we + don't expect to have huge numbers of segments: + + * Segments are not indexed, so traversal requires linear scans. (It + would be possible to index these, but is not worth the extra + overhead and complexity for most programs on most platforms.) + * New segments are only appended to old ones when holding top-most + memory; if they cannot be prepended to others, they are held in + different segments. + + Except for the top-most segment of an mstate, each segment record + is kept at the tail of its segment. Segments are added by pushing + segment records onto the list headed by &mstate.seg for the + containing mstate. + + Segment flags control allocation/merge/deallocation policies: + * If EXTERN_BIT set, then we did not allocate this segment, + and so should not try to deallocate or merge with others. + (This currently holds only for the initial segment passed + into create_mspace_with_base.) + * If USE_MMAP_BIT set, the segment may be merged with + other surrounding mmapped segments and trimmed/de-allocated + using munmap. + * If neither bit is set, then the segment was obtained using + MORECORE so can be merged with surrounding MORECORE'd segments + and deallocated/trimmed using MORECORE with negative arguments. +*/ + +struct malloc_segment { + char* base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment* next; /* ptr to next segment */ + flag_t sflags; /* mmap and extern flag */ +}; + +#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) +#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) + +typedef struct malloc_segment msegment; +typedef struct malloc_segment* msegmentptr; + +/* ---------------------------- malloc_state ----------------------------- */ + +/* + A malloc_state holds all of the bookkeeping for a space. + The main fields are: + + Top + The topmost chunk of the currently active segment. Its size is + cached in topsize. The actual size of topmost space is + topsize+TOP_FOOT_SIZE, which includes space reserved for adding + fenceposts and segment records if necessary when getting more + space from the system. The size at which to autotrim top is + cached from mparams in trim_check, except that it is disabled if + an autotrim fails. + + Designated victim (dv) + This is the preferred chunk for servicing small requests that + don't have exact fits. It is normally the chunk split off most + recently to service another small request. Its size is cached in + dvsize. The link fields of this chunk are not maintained since it + is not kept in a bin. + + SmallBins + An array of bin headers for free chunks. These bins hold chunks + with sizes less than MIN_LARGE_SIZE bytes. Each bin contains + chunks of all the same size, spaced 8 bytes apart. To simplify + use in double-linked lists, each bin header acts as a malloc_chunk + pointing to the real first node, if it exists (else pointing to + itself). This avoids special-casing for headers. But to avoid + waste, we allocate only the fd/bk pointers of bins, and then use + repositioning tricks to treat these as the fields of a chunk. + + TreeBins + Treebins are pointers to the roots of trees holding a range of + sizes. There are 2 equally spaced treebins for each power of two + from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything + larger. + + Bin maps + There is one bit map for small bins ("smallmap") and one for + treebins ("treemap). Each bin sets its bit when non-empty, and + clears the bit when empty. Bit operations are then used to avoid + bin-by-bin searching -- nearly all "search" is done without ever + looking at bins that won't be selected. The bit maps + conservatively use 32 bits per map word, even if on 64bit system. + For a good description of some of the bit-based techniques used + here, see Henry S. Warren Jr's book "Hacker's Delight" (and + supplement at http://hackersdelight.org/). Many of these are + intended to reduce the branchiness of paths through malloc etc, as + well as to reduce the number of memory locations read or written. + + Segments + A list of segments headed by an embedded malloc_segment record + representing the initial space. + + Address check support + The least_addr field is the least address ever obtained from + MORECORE or MMAP. Attempted frees and reallocs of any address less + than this are trapped (unless INSECURE is defined). + + Magic tag + A cross-check field that should always hold same value as mparams.magic. + + Max allowed footprint + The maximum allowed bytes to allocate from system (zero means no limit) + + Flags + Bits recording whether to use MMAP, locks, or contiguous MORECORE + + Statistics + Each space keeps track of current and maximum system memory + obtained via MORECORE or MMAP. + + Trim support + Fields holding the amount of unused topmost memory that should trigger + trimming, and a counter to force periodic scanning to release unused + non-topmost segments. + + Locking + If USE_LOCKS is defined, the "mutex" lock is acquired and released + around every public call using this mspace. + + Extension support + A void* pointer and a size_t field that can be used to help implement + extensions to this malloc. +*/ + +/* Bin types, widths and sizes */ +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) + +struct malloc_state { + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char* least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + size_t magic; + mchunkptr smallbins[(NSMALLBINS+1)*2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + size_t footprint_limit; /* zero means no limit */ + flag_t mflags; +#if USE_LOCKS + MLOCK_T mutex; /* locate lock among fields that rarely change */ +#endif /* USE_LOCKS */ + msegment seg; + void* extp; /* Unused but available for extensions */ + size_t exts; +}; + +typedef struct malloc_state* mstate; + +/* ------------- Global malloc_state and malloc_params ------------------- */ + +/* + malloc_params holds global properties, including those that can be + dynamically set using mallopt. There is a single instance, mparams, + initialized in init_mparams. Note that the non-zeroness of "magic" + also serves as an initialization flag. +*/ + +struct malloc_params { + size_t magic; + size_t page_size; + size_t granularity; + size_t mmap_threshold; + size_t trim_threshold; + flag_t default_mflags; +}; + +static struct malloc_params mparams; + +/* Ensure mparams initialized */ +#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) + +#if !ONLY_MSPACES + +/* The global malloc_state used for all non-"mspace" calls */ +static struct malloc_state _gm_; +#define gm (&_gm_) +#define is_global(M) ((M) == &_gm_) + +#endif /* !ONLY_MSPACES */ + +#define is_initialized(M) ((M)->top != 0) + +/* -------------------------- system alloc setup ------------------------- */ + +/* Operations on mflags */ + +#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) +#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) +#if USE_LOCKS +#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) +#else +#define disable_lock(M) +#endif + +#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) +#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) +#if HAVE_MMAP +#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) +#else +#define disable_mmap(M) +#endif + +#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) +#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) + +#define set_lock(M,L)\ + ((M)->mflags = (L)?\ + ((M)->mflags | USE_LOCK_BIT) :\ + ((M)->mflags & ~USE_LOCK_BIT)) + +/* page-align a size */ +#define page_align(S)\ + (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) + +/* granularity-align a size */ +#define granularity_align(S)\ + (((S) + (mparams.granularity - SIZE_T_ONE))\ + & ~(mparams.granularity - SIZE_T_ONE)) + + +/* For mmap, use granularity alignment on windows, else page-align */ +#ifdef WIN32 +#define mmap_align(S) granularity_align(S) +#else +#define mmap_align(S) page_align(S) +#endif + +/* For sys_alloc, enough padding to ensure can malloc request on success */ +#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) + +#define is_page_aligned(S)\ + (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) +#define is_granularity_aligned(S)\ + (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) + +/* True if segment S holds address A */ +#define segment_holds(S, A)\ + ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) + +/* Return segment holding given address */ +static msegmentptr segment_holding(mstate m, char* addr) { + msegmentptr sp = &m->seg; + for (;;) { + if (addr >= sp->base && addr < sp->base + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; + } +} + +/* Return true if segment contains a segment link */ +static int has_segment_link(mstate m, msegmentptr ss) { + msegmentptr sp = &m->seg; + for (;;) { + if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) + return 1; + if ((sp = sp->next) == 0) + return 0; + } +} + +#ifndef MORECORE_CANNOT_TRIM +#define should_trim(M,s) ((s) > (M)->trim_check) +#else /* MORECORE_CANNOT_TRIM */ +#define should_trim(M,s) (0) +#endif /* MORECORE_CANNOT_TRIM */ + +/* + TOP_FOOT_SIZE is padding at the end of a segment, including space + that may be needed to place segment records and fenceposts when new + noncontiguous segments are added. +*/ +#define TOP_FOOT_SIZE\ + (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) + + +/* ------------------------------- Hooks -------------------------------- */ + +/* + PREACTION should be defined to return 0 on success, and nonzero on + failure. If you are not using locking, you can redefine these to do + anything you like. +*/ + +#if USE_LOCKS +#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) +#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } +#else /* USE_LOCKS */ + +#ifndef PREACTION +#define PREACTION(M) (0) +#endif /* PREACTION */ + +#ifndef POSTACTION +#define POSTACTION(M) +#endif /* POSTACTION */ + +#endif /* USE_LOCKS */ + +/* + CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. + USAGE_ERROR_ACTION is triggered on detected bad frees and + reallocs. The argument p is an address that might have triggered the + fault. It is ignored by the two predefined actions, but might be + useful in custom actions that try to help diagnose errors. +*/ + +#if PROCEED_ON_ERROR + +/* A count of the number of corruption errors causing resets */ +int malloc_corruption_error_count; + +/* default corruption action */ +static void reset_on_error(mstate m); + +#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) +#define USAGE_ERROR_ACTION(m, p) + +#else /* PROCEED_ON_ERROR */ + +#ifndef CORRUPTION_ERROR_ACTION +#define CORRUPTION_ERROR_ACTION(m) ABORT +#endif /* CORRUPTION_ERROR_ACTION */ + +#ifndef USAGE_ERROR_ACTION +#define USAGE_ERROR_ACTION(m,p) ABORT +#endif /* USAGE_ERROR_ACTION */ + +#endif /* PROCEED_ON_ERROR */ + + +/* -------------------------- Debugging setup ---------------------------- */ + +#if ! DEBUG + +#define check_free_chunk(M,P) +#define check_inuse_chunk(M,P) +#define check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) +#define check_malloc_state(M) +#define check_top_chunk(M,P) + +#else /* DEBUG */ +#define check_free_chunk(M,P) do_check_free_chunk(M,P) +#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) +#define check_top_chunk(M,P) do_check_top_chunk(M,P) +#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) +#define check_malloc_state(M) do_check_malloc_state(M) + +static void do_check_any_chunk(mstate m, mchunkptr p); +static void do_check_top_chunk(mstate m, mchunkptr p); +static void do_check_mmapped_chunk(mstate m, mchunkptr p); +static void do_check_inuse_chunk(mstate m, mchunkptr p); +static void do_check_free_chunk(mstate m, mchunkptr p); +static void do_check_malloced_chunk(mstate m, void* mem, size_t s); +static void do_check_tree(mstate m, tchunkptr t); +static void do_check_treebin(mstate m, bindex_t i); +static void do_check_smallbin(mstate m, bindex_t i); +static void do_check_malloc_state(mstate m); +static int bin_find(mstate m, mchunkptr x); +static size_t traverse_and_check(mstate m); +#endif /* DEBUG */ + +/* ---------------------------- Indexing Bins ---------------------------- */ + +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) + +/* addressing by index. See above about smallbin repositioning */ +#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) +#define treebin_at(M,i) (&((M)->treebins[i])) + +/* assign tree index for size S to variable I. Use x86 asm if possible */ +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +#define compute_tree_index(S, I)\ +{\ + unsigned int X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +#elif defined (__INTEL_COMPILER) +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K = _bit_scan_reverse (X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +#elif defined(_MSC_VER) && _MSC_VER>=1300 +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K;\ + _BitScanReverse((DWORD *) &K, (DWORD) X);\ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +#else /* GNUC */ +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int Y = (unsigned int)X;\ + unsigned int N = ((Y - 0x100) >> 16) & 8;\ + unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ + N += K;\ + N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ + K = 14 - N + ((Y <<= K) >> 15);\ + I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ + }\ +} +#endif /* GNUC */ + +/* Bit representing maximum resolved size in a treebin at i */ +#define bit_for_tree_index(i) \ + (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + +/* Shift placing maximum resolved bit in a treebin at i as sign bit */ +#define leftshift_for_tree_index(i) \ + ((i == NTREEBINS-1)? 0 : \ + ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + +/* The size of the smallest chunk held in bin with index i */ +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) + + +/* ------------------------ Operations on bin maps ----------------------- */ + +/* bit corresponding to given index */ +#define idx2bit(i) ((binmap_t)(1) << (i)) + +/* Mark/Clear bits with given index */ +#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) + +#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) + +/* isolate the least set bit of a bitmap */ +#define least_bit(x) ((x) & -(x)) + +/* mask with all bits to left of least bit of x on */ +#define left_bits(x) ((x<<1) | -(x<<1)) + +/* mask with all bits to left of or equal to least bit of x on */ +#define same_or_left_bits(x) ((x) | -(x)) + +/* index corresponding to given bit. Use x86 asm if possible */ + +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + J = __builtin_ctz(X); \ + I = (bindex_t)J;\ +} + +#elif defined (__INTEL_COMPILER) +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + J = _bit_scan_forward (X); \ + I = (bindex_t)J;\ +} + +#elif defined(_MSC_VER) && _MSC_VER>=1300 +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + _BitScanForward((DWORD *) &J, X);\ + I = (bindex_t)J;\ +} + +#elif USE_BUILTIN_FFS +#define compute_bit2idx(X, I) I = ffs(X)-1 + +#else +#define compute_bit2idx(X, I)\ +{\ + unsigned int Y = X - 1;\ + unsigned int K = Y >> (16-4) & 16;\ + unsigned int N = K; Y >>= K;\ + N += K = Y >> (8-3) & 8; Y >>= K;\ + N += K = Y >> (4-2) & 4; Y >>= K;\ + N += K = Y >> (2-1) & 2; Y >>= K;\ + N += K = Y >> (1-0) & 1; Y >>= K;\ + I = (bindex_t)(N + Y);\ +} +#endif /* GNUC */ + + +/* ----------------------- Runtime Check Support ------------------------- */ + +/* + For security, the main invariant is that malloc/free/etc never + writes to a static address other than malloc_state, unless static + malloc_state itself has been corrupted, which cannot occur via + malloc (because of these checks). In essence this means that we + believe all pointers, sizes, maps etc held in malloc_state, but + check all of those linked or offsetted from other embedded data + structures. These checks are interspersed with main code in a way + that tends to minimize their run-time cost. + + When FOOTERS is defined, in addition to range checking, we also + verify footer fields of inuse chunks, which can be used guarantee + that the mstate controlling malloc/free is intact. This is a + streamlined version of the approach described by William Robertson + et al in "Run-time Detection of Heap-based Overflows" LISA'03 + http://www.usenix.org/events/lisa03/tech/robertson.html The footer + of an inuse chunk holds the xor of its mstate and a random seed, + that is checked upon calls to free() and realloc(). This is + (probabalistically) unguessable from outside the program, but can be + computed by any code successfully malloc'ing any chunk, so does not + itself provide protection against code that has already broken + security through some other means. Unlike Robertson et al, we + always dynamically check addresses of all offset chunks (previous, + next, etc). This turns out to be cheaper than relying on hashes. +*/ + +#if !INSECURE +/* Check if address a is at least as high as any from MORECORE or MMAP */ +#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) +/* Check if address of next chunk n is higher than base chunk p */ +#define ok_next(p, n) ((char*)(p) < (char*)(n)) +/* Check if p has inuse status */ +#define ok_inuse(p) is_inuse(p) +/* Check if p has its pinuse bit on */ +#define ok_pinuse(p) pinuse(p) + +#else /* !INSECURE */ +#define ok_address(M, a) (1) +#define ok_next(b, n) (1) +#define ok_inuse(p) (1) +#define ok_pinuse(p) (1) +#endif /* !INSECURE */ + +#if (FOOTERS && !INSECURE) +/* Check if (alleged) mstate m has expected magic field */ +#define ok_magic(M) ((M)->magic == mparams.magic) +#else /* (FOOTERS && !INSECURE) */ +#define ok_magic(M) (1) +#endif /* (FOOTERS && !INSECURE) */ + +/* In gcc, use __builtin_expect to minimize impact of checks */ +#if !INSECURE +#if defined(__GNUC__) && __GNUC__ >= 3 +#define RTCHECK(e) __builtin_expect(e, 1) +#else /* GNUC */ +#define RTCHECK(e) (e) +#endif /* GNUC */ +#else /* !INSECURE */ +#define RTCHECK(e) (1) +#endif /* !INSECURE */ + +/* macros to set up inuse chunks with or without footers */ + +#if !FOOTERS + +#define mark_inuse_foot(M,p,s) + +/* Macros for setting head/foot of non-mmapped chunks */ + +/* Set cinuse bit and pinuse bit of next chunk */ +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set size, cinuse and pinuse bit of this chunk */ +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) + +#else /* FOOTERS */ + +/* Set foot of inuse chunk to be xor of mstate and seed */ +#define mark_inuse_foot(M,p,s)\ + (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) + +#define get_mstate_for(p)\ + ((mstate)(((mchunkptr)((char*)(p) +\ + (chunksize(p))))->prev_foot ^ mparams.magic)) + +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M,p,s)) + +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ + mark_inuse_foot(M,p,s)) + +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + mark_inuse_foot(M, p, s)) + +#endif /* !FOOTERS */ + +/* check if allocated memory falls into trusted heap range */ +#ifdef _TLIBC_ +#include "trts_util.h" +#define ok_heap_range(p, b) \ + (((p) >= get_heap_base()) && \ + ((b) <= (SIZE_MAX - (size_t)(p))) && \ + ((void *)((size_t)(p) + (b)) <= sbrk(0))) +#else +#define ok_heap_range(p, b) (1) +#endif + +/* ---------------------------- setting mparams -------------------------- */ + +#if LOCK_AT_FORK +static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); } +static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); } +static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); } +#endif /* LOCK_AT_FORK */ + +/* Initialize mparams */ +static int init_mparams(void) { +#ifdef NEED_GLOBAL_LOCK_INIT + if (malloc_global_mutex_status <= 0) + init_malloc_global_mutex(); +#endif + + ACQUIRE_MALLOC_GLOBAL_LOCK(); + if (mparams.magic == 0) { + size_t magic; + size_t psize; + size_t gsize; + +#if !defined(WIN32) || defined(_TLIBC_) + psize = malloc_getpagesize; + gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); +#else /* WIN32 */ + { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + psize = system_info.dwPageSize; + gsize = ((DEFAULT_GRANULARITY != 0)? + DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); + } +#endif /* WIN32 */ + + /* Sanity-check configuration: + size_t must be unsigned and as wide as pointer type. + ints must be at least 4 bytes. + alignment must be at least 8. + Alignment, min chunk size, and page size must all be powers of 2. + */ + if ((sizeof(size_t) != sizeof(char*)) || + (MAX_SIZE_T < MIN_CHUNK_SIZE) || + (sizeof(int) < 4) || + (MALLOC_ALIGNMENT < (size_t)8U) || + ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || + ((gsize & (gsize-SIZE_T_ONE)) != 0) || + ((psize & (psize-SIZE_T_ONE)) != 0)) + ABORT; + mparams.granularity = gsize; + mparams.page_size = psize; + mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; + mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; +#if MORECORE_CONTIGUOUS + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; +#else /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; +#endif /* MORECORE_CONTIGUOUS */ + +#if !ONLY_MSPACES + /* Set up lock for main malloc area */ + gm->mflags = mparams.default_mflags; + (void)INITIAL_LOCK(&gm->mutex); +#endif +#if LOCK_AT_FORK + pthread_atfork(&pre_fork, &post_fork_parent, &post_fork_child); +#endif + + { +#if USE_DEV_RANDOM + int fd; + unsigned char buf[sizeof(size_t)]; + /* Try to use /dev/urandom, else fall back on using time */ + if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && + read(fd, buf, sizeof(buf)) == sizeof(buf)) { + magic = *((size_t *) buf); + close(fd); + } + else +#endif /* USE_DEV_RANDOM */ +#if defined(WIN32) && !defined(_TLIBC_) + magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); +#elif defined(LACKS_TIME_H) + if (SGX_SUCCESS != sgx_read_rand((unsigned char *)&magic, sizeof(size_t))) + ABORT; + magic = (size_t)(magic ^ (size_t)0x55555555U); +#else + magic = (size_t)(time(0) ^ (size_t)0x55555555U); +#endif + magic |= (size_t)8U; /* ensure nonzero */ + magic &= ~(size_t)7U; /* improve chances of fault for bad values */ + /* Until memory modes commonly available, use volatile-write */ + (*(volatile size_t *)(&(mparams.magic))) = magic; + } + } + + RELEASE_MALLOC_GLOBAL_LOCK(); + return 1; +} + +/* support for mallopt */ +static int change_mparam(int param_number, int value) { + size_t val; + ensure_initialization(); + val = (value == -1)? MAX_SIZE_T : (size_t)value; + switch(param_number) { + case M_TRIM_THRESHOLD: + mparams.trim_threshold = val; + return 1; + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val-1)) == 0)) { + mparams.granularity = val; + return 1; + } + else + return 0; + case M_MMAP_THRESHOLD: + mparams.mmap_threshold = val; + return 1; + default: + return 0; + } +} + +#if DEBUG +/* ------------------------- Debugging Support --------------------------- */ + +/* Check properties of any chunk, whether free, inuse, mmapped etc */ +static void do_check_any_chunk(mstate m, mchunkptr p) { + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); +} + +/* Check properties of top chunk */ +static void do_check_top_chunk(mstate m, mchunkptr p) { + msegmentptr sp = segment_holding(m, (char*)p); + size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ + assert(sp != 0); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(sz == m->topsize); + assert(sz > 0); + assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); + assert(pinuse(p)); + assert(!pinuse(chunk_plus_offset(p, sz))); +} + +/* Check properties of (inuse) mmapped chunks */ +static void do_check_mmapped_chunk(mstate m, mchunkptr p) { + size_t sz = chunksize(p); + size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); + assert(is_mmapped(p)); + assert(use_mmap(m)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(!is_small(sz)); + assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); + assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); + assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); +} + +/* Check properties of inuse chunks */ +static void do_check_inuse_chunk(mstate m, mchunkptr p) { + do_check_any_chunk(m, p); + assert(is_inuse(p)); + assert(next_pinuse(p)); + /* If not pinuse and not mmapped, previous chunk has OK offset */ + assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); + if (is_mmapped(p)) + do_check_mmapped_chunk(m, p); +} + +/* Check properties of free chunks */ +static void do_check_free_chunk(mstate m, mchunkptr p) { + size_t sz = chunksize(p); + mchunkptr next = chunk_plus_offset(p, sz); + do_check_any_chunk(m, p); + assert(!is_inuse(p)); + assert(!next_pinuse(p)); + assert (!is_mmapped(p)); + if (p != m->dv && p != m->top) { + if (sz >= MIN_CHUNK_SIZE) { + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(is_aligned(chunk2mem(p))); + assert(next->prev_foot == sz); + assert(pinuse(p)); + assert (next == m->top || is_inuse(next)); + assert(p->fd->bk == p); + assert(p->bk->fd == p); + } + else /* markers are always of size SIZE_T_SIZE */ + assert(sz == SIZE_T_SIZE); + } +} + +/* Check properties of malloced chunks at the point they are malloced */ +static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + size_t sz = p->head & ~INUSE_BITS; + do_check_inuse_chunk(m, p); + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(sz >= MIN_CHUNK_SIZE); + assert(sz >= s); + /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ + assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); + } +} + +/* Check a tree and its subtrees. */ +static void do_check_tree(mstate m, tchunkptr t) { + tchunkptr head = 0; + tchunkptr u = t; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; + compute_tree_index(tsize, idx); + assert(tindex == idx); + assert(tsize >= MIN_LARGE_SIZE); + assert(tsize >= minsize_for_tree_index(idx)); + assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); + + do { /* traverse through chain of same-sized nodes */ + do_check_any_chunk(m, ((mchunkptr)u)); + assert(u->index == tindex); + assert(chunksize(u) == tsize); + assert(!is_inuse(u)); + assert(!next_pinuse(u)); + assert(u->fd->bk == u); + assert(u->bk->fd == u); + if (u->parent == 0) { + assert(u->child[0] == 0); + assert(u->child[1] == 0); + } + else { + assert(head == 0); /* only one node on chain has parent */ + head = u; + assert(u->parent != u); + assert (u->parent->child[0] == u || + u->parent->child[1] == u || + *((tbinptr*)(u->parent)) == u); + if (u->child[0] != 0) { + assert(u->child[0]->parent == u); + assert(u->child[0] != u); + do_check_tree(m, u->child[0]); + } + if (u->child[1] != 0) { + assert(u->child[1]->parent == u); + assert(u->child[1] != u); + do_check_tree(m, u->child[1]); + } + if (u->child[0] != 0 && u->child[1] != 0) { + assert(chunksize(u->child[0]) < chunksize(u->child[1])); + } + } + u = u->fd; + } while (u != t); + assert(head != 0); +} + +/* Check all the chunks in a treebin. */ +static void do_check_treebin(mstate m, bindex_t i) { + tbinptr* tb = treebin_at(m, i); + tchunkptr t = *tb; + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) + assert(empty); + if (!empty) + do_check_tree(m, t); +} + +/* Check all the chunks in a smallbin. */ +static void do_check_smallbin(mstate m, bindex_t i) { + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; + unsigned int empty = (m->smallmap & (1U << i)) == 0; + if (p == b) + assert(empty); + if (!empty) { + for (; p != b; p = p->bk) { + size_t size = chunksize(p); + mchunkptr q; + /* each chunk claims to be free */ + do_check_free_chunk(m, p); + /* chunk belongs in bin */ + assert(small_index(size) == i); + assert(p->bk == b || chunksize(p->bk) == chunksize(p)); + /* chunk is followed by an inuse chunk */ + q = next_chunk(p); + if (q->head != FENCEPOST_HEAD) + do_check_inuse_chunk(m, q); + } + } +} + +/* Find x in a bin. Used in other check functions. */ +static int bin_find(mstate m, mchunkptr x) { + size_t size = chunksize(x); + if (is_small(size)) { + bindex_t sidx = small_index(size); + sbinptr b = smallbin_at(m, sidx); + if (smallmap_is_marked(m, sidx)) { + mchunkptr p = b; + do { + if (p == x) + return 1; + } while ((p = p->fd) != b); + } + } + else { + bindex_t tidx; + compute_tree_index(size, tidx); + if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); + while (t != 0 && chunksize(t) != size) { + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + sizebits <<= 1; + } + if (t != 0) { + tchunkptr u = t; + do { + if (u == (tchunkptr)x) + return 1; + } while ((u = u->fd) != t); + } + } + } + return 0; +} + +/* Traverse each chunk and check it; return total */ +static size_t traverse_and_check(mstate m) { + size_t sum = 0; + if (is_initialized(m)) { + msegmentptr s = &m->seg; + sum += m->topsize + TOP_FOOT_SIZE; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + mchunkptr lastq = 0; + assert(pinuse(q)); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + sum += chunksize(q); + if (is_inuse(q)) { + assert(!bin_find(m, q)); + do_check_inuse_chunk(m, q); + } + else { + assert(q == m->dv || bin_find(m, q)); + assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ + do_check_free_chunk(m, q); + } + lastq = q; + q = next_chunk(q); + } + s = s->next; + } + } + return sum; +} + + +/* Check all properties of malloc_state. */ +static void do_check_malloc_state(mstate m) { + bindex_t i; + size_t total; + /* check bins */ + for (i = 0; i < NSMALLBINS; ++i) + do_check_smallbin(m, i); + for (i = 0; i < NTREEBINS; ++i) + do_check_treebin(m, i); + + if (m->dvsize != 0) { /* check dv chunk */ + do_check_any_chunk(m, m->dv); + assert(m->dvsize == chunksize(m->dv)); + assert(m->dvsize >= MIN_CHUNK_SIZE); + assert(bin_find(m, m->dv) == 0); + } + + if (m->top != 0) { /* check top chunk */ + do_check_top_chunk(m, m->top); + /*assert(m->topsize == chunksize(m->top)); redundant */ + assert(m->topsize > 0); + assert(bin_find(m, m->top) == 0); + } + + total = traverse_and_check(m); + assert(total <= m->footprint); + assert(m->footprint <= m->max_footprint); +} +#endif /* DEBUG */ + +/* ----------------------------- statistics ------------------------------ */ + +#if !NO_MALLINFO +static struct mallinfo internal_mallinfo(mstate m) { + struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ensure_initialization(); + if (!PREACTION(m)) { + check_malloc_state(m); + if (is_initialized(m)) { + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; + msegmentptr s = &m->seg; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + size_t sz = chunksize(q); + sum += sz; + if (!is_inuse(q)) { + mfree += sz; + ++nfree; + } + q = next_chunk(q); + } + s = s->next; + } + + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; + nm.uordblks = m->footprint - mfree; + nm.fordblks = mfree; + nm.keepcost = m->topsize; + } + + POSTACTION(m); + } + return nm; +} +#endif /* !NO_MALLINFO */ + +#if !NO_MALLOC_STATS +static void internal_malloc_stats(mstate m) { + ensure_initialization(); + if (!PREACTION(m)) { + size_t maxfp = 0; + size_t fp = 0; + size_t used = 0; + check_malloc_state(m); + if (is_initialized(m)) { + msegmentptr s = &m->seg; + maxfp = m->max_footprint; + fp = m->footprint; + used = fp - (m->topsize + TOP_FOOT_SIZE); + + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + if (!is_inuse(q)) + used -= chunksize(q); + q = next_chunk(q); + } + s = s->next; + } + } + POSTACTION(m); /* drop lock */ +#ifndef _TLIBC_ + fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); + fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); + fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); +#endif + } +} +#endif /* NO_MALLOC_STATS */ + +/* ----------------------- Operations on smallbins ----------------------- */ + +/* + Various forms of linking and unlinking are defined as macros. Even + the ones for trees, which are very long but have very short typical + paths. This is ugly but reduces reliance on inlining support of + compilers. +*/ + +/* Link a free chunk into a smallbin */ +#define insert_small_chunk(M, P, S) {\ + bindex_t I = small_index(S);\ + mchunkptr B = smallbin_at(M, I);\ + mchunkptr F = B;\ + assert(S >= MIN_CHUNK_SIZE);\ + if (!smallmap_is_marked(M, I))\ + mark_smallmap(M, I);\ + else if (RTCHECK(ok_address(M, B->fd)))\ + F = B->fd;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + B->fd = P;\ + F->bk = P;\ + P->fd = F;\ + P->bk = B;\ +} + +/* Unlink a chunk from a smallbin */ +#define unlink_small_chunk(M, P, S) {\ + mchunkptr F = P->fd;\ + mchunkptr B = P->bk;\ + bindex_t I = small_index(S);\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \ + if (B == F) {\ + clear_smallmap(M, I);\ + }\ + else if (RTCHECK(B == smallbin_at(M,I) ||\ + (ok_address(M, B) && B->fd == P))) {\ + F->bk = B;\ + B->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} + +/* Unlink the first chunk from a smallbin */ +#define unlink_first_small_chunk(M, B, P, I) {\ + mchunkptr F = P->fd;\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (B == F) {\ + clear_smallmap(M, I);\ + }\ + else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\ + F->bk = B;\ + B->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} + +/* Replace dv node, binning the old one */ +/* Used only when dvsize known to be small */ +#define replace_dv(M, P, S) {\ + size_t DVS = M->dvsize;\ + assert(is_small(DVS));\ + if (DVS != 0) {\ + mchunkptr DV = M->dv;\ + insert_small_chunk(M, DV, DVS);\ + }\ + M->dvsize = S;\ + M->dv = P;\ +} + +/* ------------------------- Operations on trees ------------------------- */ + +/* Insert chunk into tree */ +#define insert_large_chunk(M, X, S) {\ + tbinptr* H;\ + bindex_t I;\ + compute_tree_index(S, I);\ + H = treebin_at(M, I);\ + X->index = I;\ + X->child[0] = X->child[1] = 0;\ + if (!treemap_is_marked(M, I)) {\ + mark_treemap(M, I);\ + *H = X;\ + X->parent = (tchunkptr)H;\ + X->fd = X->bk = X;\ + }\ + else {\ + tchunkptr T = *H;\ + size_t K = S << leftshift_for_tree_index(I);\ + for (;;) {\ + if (chunksize(T) != S) {\ + tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ + K <<= 1;\ + if (*C != 0)\ + T = *C;\ + else if (RTCHECK(ok_address(M, C))) {\ + *C = X;\ + X->parent = T;\ + X->fd = X->bk = X;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + else {\ + tchunkptr F = T->fd;\ + if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ + T->fd = F->bk = X;\ + X->fd = F;\ + X->bk = T;\ + X->parent = 0;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + }\ + }\ +} + +/* + Unlink steps: + + 1. If x is a chained node, unlink it from its same-sized fd/bk links + and choose its bk node as its replacement. + 2. If x was the last node of its size, but not a leaf node, it must + be replaced with a leaf node (not merely one with an open left or + right), to make sure that lefts and rights of descendents + correspond properly to bit masks. We use the rightmost descendent + of x. We could use any other leaf, but this is easy to locate and + tends to counteract removal of leftmosts elsewhere, and so keeps + paths shorter than minimally guaranteed. This doesn't loop much + because on average a node in a tree is near the bottom. + 3. If x is the base of a chain (i.e., has parent links) relink + x's parent and children to x's replacement (or null if none). +*/ + +#define unlink_large_chunk(M, X) {\ + tchunkptr XP = X->parent;\ + tchunkptr R;\ + if (X->bk != X) {\ + tchunkptr F = X->fd;\ + R = X->bk;\ + if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\ + F->bk = R;\ + R->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else {\ + tchunkptr* RP;\ + if (((R = *(RP = &(X->child[1]))) != 0) ||\ + ((R = *(RP = &(X->child[0]))) != 0)) {\ + tchunkptr* CP;\ + while ((*(CP = &(R->child[1])) != 0) ||\ + (*(CP = &(R->child[0])) != 0)) {\ + R = *(RP = CP);\ + }\ + if (RTCHECK(ok_address(M, RP)))\ + *RP = 0;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + }\ + if (XP != 0) {\ + tbinptr* H = treebin_at(M, X->index);\ + if (X == *H) {\ + if ((*H = R) == 0) \ + clear_treemap(M, X->index);\ + }\ + else if (RTCHECK(ok_address(M, XP))) {\ + if (XP->child[0] == X) \ + XP->child[0] = R;\ + else \ + XP->child[1] = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + if (R != 0) {\ + if (RTCHECK(ok_address(M, R))) {\ + tchunkptr C0, C1;\ + R->parent = XP;\ + if ((C0 = X->child[0]) != 0) {\ + if (RTCHECK(ok_address(M, C0))) {\ + R->child[0] = C0;\ + C0->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + if ((C1 = X->child[1]) != 0) {\ + if (RTCHECK(ok_address(M, C1))) {\ + R->child[1] = C1;\ + C1->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ +} + +/* Relays to large vs small bin operations */ + +#define insert_chunk(M, P, S)\ + if (is_small(S)) insert_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } + +#define unlink_chunk(M, P, S)\ + if (is_small(S)) unlink_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } + + +/* Relays to internal calls to malloc/free from realloc, memalign etc */ + +#if ONLY_MSPACES +#define internal_malloc(m, b) mspace_malloc(m, b) +#define internal_free(m, mem) mspace_free(m,mem); +#else /* ONLY_MSPACES */ +#if MSPACES +#define internal_malloc(m, b)\ + ((m == gm)? dlmalloc(b) : mspace_malloc(m, b)) +#define internal_free(m, mem)\ + if (m == gm) dlfree(mem); else mspace_free(m,mem); +#else /* MSPACES */ +#define internal_malloc(m, b) dlmalloc(b) +#define internal_free(m, mem) dlfree(mem) +#endif /* MSPACES */ +#endif /* ONLY_MSPACES */ + +/* ----------------------- Direct-mmapping chunks ----------------------- */ + +/* + Directly mmapped chunks are set up with an offset to the start of + the mmapped region stored in the prev_foot field of the chunk. This + allows reconstruction of the required argument to MUNMAP when freed, + and also allows adjustment of the returned chunk to meet alignment + requirements (especially in memalign). +*/ + +/* Malloc using mmap */ +static void* mmap_alloc(mstate m, size_t nb) { + size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + if (m->footprint_limit != 0) { + size_t fp = m->footprint + mmsize; + if (fp <= m->footprint || fp > m->footprint_limit) + return 0; + } + if (mmsize > nb) { /* Check for wrap around 0 */ + char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); + if (mm != CMFAIL) { + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; + mchunkptr p = (mchunkptr)(mm + offset); + p->prev_foot = offset; + p->head = psize; + mark_inuse_foot(m, p, psize); + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + + if (m->least_addr == 0 || mm < m->least_addr) + m->least_addr = mm; + if ((m->footprint += mmsize) > m->max_footprint) + m->max_footprint = m->footprint; + assert(is_aligned(chunk2mem(p))); + check_mmapped_chunk(m, p); + return chunk2mem(p); + } + } + return 0; +} + +/* Realloc using mmap */ +static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) { + size_t oldsize = chunksize(oldp); + (void)flags; /* placate people compiling -Wunused */ + if (is_small(nb)) /* Can't shrink mmap regions below small size */ + return 0; + /* Keep old chunk if big enough but not too big */ + if (oldsize >= nb + SIZE_T_SIZE && + (oldsize - nb) <= (mparams.granularity << 1)) + return oldp; + else { + size_t offset = oldp->prev_foot; + size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; + size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + char* cp = (char*)CALL_MREMAP((char*)oldp - offset, + oldmmsize, newmmsize, flags); + if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + newp->head = psize; + mark_inuse_foot(m, newp, psize); + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + + if (cp < m->least_addr) + m->least_addr = cp; + if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) + m->max_footprint = m->footprint; + check_mmapped_chunk(m, newp); + return newp; + } + } + return 0; +} + + +/* -------------------------- mspace management -------------------------- */ + +/* Initialize top chunk and its size */ +static void init_top(mstate m, mchunkptr p, size_t psize) { + /* Ensure alignment */ + size_t offset = align_offset(chunk2mem(p)); + p = (mchunkptr)((char*)p + offset); + psize -= offset; + + m->top = p; + m->topsize = psize; + p->head = psize | PINUSE_BIT; + /* set size of fake trailing chunk holding overhead space only once */ + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; + m->trim_check = mparams.trim_threshold; /* reset on each update */ +} + +/* Initialize bins for a new mstate that is otherwise zeroed out */ +static void init_bins(mstate m) { + /* Establish circular links for smallbins */ + bindex_t i; + for (i = 0; i < NSMALLBINS; ++i) { + sbinptr bin = smallbin_at(m,i); + bin->fd = bin->bk = bin; + } +} + +#if PROCEED_ON_ERROR + +/* default corruption action */ +static void reset_on_error(mstate m) { + int i; + ++malloc_corruption_error_count; + /* Reinitialize fields to forget about all memory */ + m->smallmap = m->treemap = 0; + m->dvsize = m->topsize = 0; + m->seg.base = 0; + m->seg.size = 0; + m->seg.next = 0; + m->top = m->dv = 0; + for (i = 0; i < NTREEBINS; ++i) + *treebin_at(m, i) = 0; + init_bins(m); +} +#endif /* PROCEED_ON_ERROR */ + +/* Allocate chunk and prepend remainder with chunk in successor base. */ +static void* prepend_alloc(mstate m, char* newbase, char* oldbase, + size_t nb) { + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); + size_t psize = (char*)oldfirst - (char*)p; + mchunkptr q = chunk_plus_offset(p, nb); + size_t qsize = psize - nb; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + assert((char*)oldfirst > (char*)q); + assert(pinuse(oldfirst)); + assert(qsize >= MIN_CHUNK_SIZE); + + /* consolidate remainder with first chunk of old base */ + if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; + m->top = q; + q->head = tsize | PINUSE_BIT; + check_top_chunk(m, q); + } + else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; + m->dv = q; + set_size_and_pinuse_of_free_chunk(q, dsize); + } + else { + if (!is_inuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); + qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + check_free_chunk(m, q); + } + + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); +} + +/* Add a segment to hold a new noncontiguous region */ +static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { + /* Determine locations and sizes of segment, fenceposts, old top */ + char* old_top = (char*)m->top; + msegmentptr oldsp = segment_holding(m, old_top); + char* old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char* asp = rawsp + offset; + char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; + mchunkptr sp = (mchunkptr)csp; + msegmentptr ss = (msegmentptr)(chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; + + /* reset top to new space */ + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + + /* Set up segment record */ + assert(is_aligned(ss)); + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); + *ss = m->seg; /* Push current record */ + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.sflags = mmapped; + m->seg.next = ss; + + /* Insert trailing fenceposts */ + for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); + p->head = FENCEPOST_HEAD; + ++nfences; + if ((char*)(&(nextp->head)) < old_end) + p = nextp; + else + break; + } + assert(nfences >= 2); + + /* Insert the rest of old top into a bin as an ordinary free chunk */ + if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; + size_t psize = csp - old_top; + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); + } + + check_top_chunk(m, m->top); +} + +/* -------------------------- System allocation -------------------------- */ + +/* Get memory from system using MORECORE or MMAP */ +static void* sys_alloc(mstate m, size_t nb) { + char* tbase = CMFAIL; + size_t tsize = 0; + flag_t mmap_flag = 0; + size_t asize; /* allocation size */ + + ensure_initialization(); + + /* Directly map large chunks, but only if already initialized */ + if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { + void* mem = mmap_alloc(m, nb); + if (mem != 0) + return mem; + } + + asize = granularity_align(nb + SYS_ALLOC_PADDING); + if (asize <= nb) + return 0; /* wraparound */ + if (m->footprint_limit != 0) { + size_t fp = m->footprint + asize; + if (fp <= m->footprint || fp > m->footprint_limit) + return 0; + } + + /* + Try getting memory in any of three ways (in most-preferred to + least-preferred order): + 1. A call to MORECORE that can normally contiguously extend memory. + (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or + or main space is mmapped or a previous contiguous call failed) + 2. A call to MMAP new space (disabled if not HAVE_MMAP). + Note that under the default settings, if MORECORE is unable to + fulfill a request, and HAVE_MMAP is true, then mmap is + used as a noncontiguous system allocator. This is a useful backup + strategy for systems with holes in address spaces -- in this case + sbrk cannot contiguously expand the heap, but mmap may be able to + find space. + 3. A call to MORECORE that cannot usually contiguously extend memory. + (disabled if not HAVE_MORECORE) + + In all cases, we need to request enough bytes from system to ensure + we can malloc nb bytes upon success, so pad with enough space for + top_foot, plus alignment-pad to make sure we don't lose bytes if + not on boundary, and round this up to a granularity unit. + */ + + if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { + char* br = CMFAIL; + size_t ssize = asize; /* sbrk call size */ + msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); + ACQUIRE_MALLOC_GLOBAL_LOCK(); + + if (ss == 0) { /* First time through or recovery */ + char* base = (char*)CALL_MORECORE(0); + if (base != CMFAIL) { + size_t fp; + /* Adjust to end on a page boundary */ + if (!is_page_aligned(base)) + ssize += (page_align((size_t)base) - (size_t)base); + fp = m->footprint + ssize; /* recheck limits */ + if (ssize > nb && ssize < HALF_MAX_SIZE_T && + (m->footprint_limit == 0 || + (fp > m->footprint && fp <= m->footprint_limit)) && + (br = (char*)(CALL_MORECORE(ssize))) == base) { + tbase = base; + tsize = ssize; + } + } + } + else { + /* Subtract out existing available top space from MORECORE request. */ + ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); + /* Use mem here only if it did continuously extend old space */ + if (ssize < HALF_MAX_SIZE_T && + (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) { + tbase = br; + tsize = ssize; + } + } + + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (ssize < HALF_MAX_SIZE_T && + ssize < nb + SYS_ALLOC_PADDING) { + size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize); + if (esize < HALF_MAX_SIZE_T) { + char* end = (char*)CALL_MORECORE(esize); + if (end != CMFAIL) + ssize += esize; + else { /* Can't use; try to release */ + (void) CALL_MORECORE(-ssize); + br = CMFAIL; + } + } + } + } + if (br != CMFAIL) { /* Use the space we did get */ + tbase = br; + tsize = ssize; + } +#ifndef _TLIBC_ /* Always try contiguous path in tlibc */ + else + disable_contiguous(m); /* Don't try contiguous path in the future */ +#endif + } + + RELEASE_MALLOC_GLOBAL_LOCK(); + } + + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + char* mp = (char*)(CALL_MMAP(asize)); + if (mp != CMFAIL) { + tbase = mp; + tsize = asize; + mmap_flag = USE_MMAP_BIT; + } + } + + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + if (asize < HALF_MAX_SIZE_T) { + char* br = CMFAIL; + char* end = CMFAIL; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + br = (char*)(CALL_MORECORE(asize)); + end = (char*)(CALL_MORECORE(0)); + RELEASE_MALLOC_GLOBAL_LOCK(); + if (br != CMFAIL && end != CMFAIL && br < end) { + size_t ssize = end - br; + if (ssize > nb + TOP_FOOT_SIZE) { + tbase = br; + tsize = ssize; + } + } + } + } + + if (tbase != CMFAIL) { + + if ((m->footprint += tsize) > m->max_footprint) + m->max_footprint = m->footprint; + + if (!is_initialized(m)) { /* first-time initialization */ + if (m->least_addr == 0 || tbase < m->least_addr) + m->least_addr = tbase; + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.sflags = mmap_flag; + m->magic = mparams.magic; + m->release_checks = MAX_RELEASE_CHECK_RATE; + init_bins(m); +#if !ONLY_MSPACES + if (is_global(m)) + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + else +#endif + { + /* Offset top by embedded malloc_state */ + mchunkptr mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); + } + } + + else { + /* Try to merge with an existing segment */ + msegmentptr sp = &m->seg; + /* Only consider most recent segment if traversal suppressed */ + while (sp != 0 && tbase != sp->base + sp->size) + sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + (sp->sflags & USE_MMAP_BIT) == mmap_flag && + segment_holds(sp, m->top)) { /* append */ + sp->size += tsize; + init_top(m, m->top, m->topsize + tsize); + } + else { + if (tbase < m->least_addr) + m->least_addr = tbase; + sp = &m->seg; + while (sp != 0 && sp->base != tbase + tsize) + sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + (sp->sflags & USE_MMAP_BIT) == mmap_flag) { + char* oldbase = sp->base; + sp->base = tbase; + sp->size += tsize; + return prepend_alloc(m, tbase, oldbase, nb); + } + else + add_segment(m, tbase, tsize, mmap_flag); + } + } + + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; + mchunkptr p = m->top; + mchunkptr r = m->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + check_top_chunk(m, m->top); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); + } + } + + MALLOC_FAILURE_ACTION; + return 0; +} + +/* ----------------------- system deallocation -------------------------- */ + +/* Unmap and unlink any mmapped segments that don't contain used chunks */ +static size_t release_unused_segments(mstate m) { + size_t released = 0; + int nsegs = 0; + msegmentptr pred = &m->seg; + msegmentptr sp = pred->next; + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + msegmentptr next = sp->next; + ++nsegs; + if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ + if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; + assert(segment_holds(sp, (char*)sp)); + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } + else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; + m->footprint -= size; + /* unlink obsoleted record */ + sp = pred; + sp->next = next; + } + else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } + if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ + break; + pred = sp; + sp = next; + } + /* Reset check counter */ + m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)? + (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE); + return released; +} + +static int sys_trim(mstate m, size_t pad) { + size_t released = 0; + ensure_initialization(); + if (pad < MAX_REQUEST && is_initialized(m)) { + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ + size_t unit = mparams.granularity; + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - + SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char*)m->top); + + if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { + if (HAVE_MMAP && + sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ + size_t newsize = sp->size - extra; + (void)newsize; /* placate people compiling -Wunused-variable */ + /* Prefer mremap, fall back to munmap */ + if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || + (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } + } + else if (HAVE_MORECORE) { + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + { + /* Make sure end of memory is where we last set it. */ + char* old_br = (char*)(CALL_MORECORE(0)); + if (old_br == sp->base + sp->size) { + char* rel_br = (char*)(CALL_MORECORE(-extra)); + char* new_br = (char*)(CALL_MORECORE(0)); + if (rel_br != CMFAIL && new_br < old_br) + released = old_br - new_br; + } + } + RELEASE_MALLOC_GLOBAL_LOCK(); + } + } + + if (released != 0) { + sp->size -= released; + m->footprint -= released; + init_top(m, m->top, m->topsize - released); + check_top_chunk(m, m->top); + } + } + + /* Unmap any unused mmapped segments */ + if (HAVE_MMAP) + released += release_unused_segments(m); + + /* On failure, disable autotrim to avoid repeated failed future calls */ + if (released == 0 && m->topsize > m->trim_check) + m->trim_check = MAX_SIZE_T; + } + + return (released != 0)? 1 : 0; +} + +/* Consolidate and bin a chunk. Differs from exported versions + of free mainly in that the chunk need not be marked as inuse. +*/ +static void dispose_chunk(mstate m, mchunkptr p, size_t psize) { + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + mchunkptr prev; + size_t prevsize = p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + m->footprint -= psize; + return; + } + prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ + if (p != m->dv) { + unlink_chunk(m, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + m->dvsize = psize; + set_free_with_pinuse(p, psize, next); + return; + } + } + else { + CORRUPTION_ERROR_ACTION(m); + return; + } + } + if (RTCHECK(ok_address(m, next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == m->top) { + size_t tsize = m->topsize += psize; + m->top = p; + p->head = tsize | PINUSE_BIT; + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } + return; + } + else if (next == m->dv) { + size_t dsize = m->dvsize += psize; + m->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + return; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(m, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == m->dv) { + m->dvsize = psize; + return; + } + } + } + else { + set_free_with_pinuse(p, psize, next); + } + insert_chunk(m, p, psize); + } + else { + CORRUPTION_ERROR_ACTION(m); + } +} + +/* ---------------------------- malloc --------------------------- */ + +/* allocate a large request from the best fitting chunk in a treebin */ +static void* tmalloc_large(mstate m, size_t nb) { + tchunkptr v = 0; + size_t rsize = -nb; /* Unsigned negation */ + tchunkptr t; + bindex_t idx; + compute_tree_index(nb, idx); + if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ + for (;;) { + tchunkptr rt; + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + v = t; + if ((rsize = trem) == 0) + break; + } + rt = t->child[1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) + rst = rt; + if (t == 0) { + t = rst; /* set t to least subtree holding sizes > nb */ + break; + } + sizebits <<= 1; + } + } + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; + if (leftbits != 0) { + bindex_t i; + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + t = *treebin_at(m, i); + } + } + + while (t != 0) { /* find smallest of tree or subtree */ + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + t = leftmost_child(t); + } + + /* If dv is a better fit, return 0 so malloc will use it */ + if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { + if (RTCHECK(ok_address(m, v))) { /* split */ + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + } + CORRUPTION_ERROR_ACTION(m); + } + return 0; +} + +/* allocate a small request from the best fitting chunk in a treebin */ +static void* tmalloc_small(mstate m, size_t nb) { + tchunkptr t, v; + size_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); + compute_bit2idx(leastbit, i); + v = t = *treebin_at(m, i); + rsize = chunksize(t) - nb; + + while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + } + + if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); + } + return chunk2mem(v); + } + } + + CORRUPTION_ERROR_ACTION(m); + return 0; +} + +#if !ONLY_MSPACES + +void* dlmalloc(size_t bytes) { + /* + Basic algorithm: + If a small request (< 256 bytes minus per-chunk overhead): + 1. If one exists, use a remainderless chunk in associated smallbin. + (Remainderless means that there are too few excess bytes to + represent as a chunk.) + 2. If it is big enough, use the dv chunk, which is normally the + chunk adjacent to the one used for the most recent small request. + 3. If one exists, split the smallest available chunk in a bin, + saving remainder in dv. + 4. If it is big enough, use the top chunk. + 5. If available, get memory from system and use it + Otherwise, for a large request: + 1. Find the smallest available binned chunk that fits, and use it + if it is better fitting than dv chunk, splitting if necessary. + 2. If better fitting than any binned chunk, use the dv chunk. + 3. If it is big enough, use the top chunk. + 4. If request size >= mmap threshold, try to directly mmap this chunk. + 5. If available, get memory from system and use it + + The ugly goto's here ensure that postaction occurs along all paths. + */ + +#if USE_LOCKS + ensure_initialization(); /* initialize in sys_alloc if not using locks */ +#endif + + if (!PREACTION(gm)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = gm->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(gm, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(gm, b, p, idx); + set_inuse_and_pinuse(gm, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb > gm->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(gm, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(gm, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(gm, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(gm, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + + if (nb <= gm->dvsize) { + size_t rsize = gm->dvsize - nb; + mchunkptr p = gm->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = gm->dv = chunk_plus_offset(p, nb); + gm->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + } + else { /* exhaust dv */ + size_t dvs = gm->dvsize; + gm->dvsize = 0; + gm->dv = 0; + set_inuse_and_pinuse(gm, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb < gm->topsize) { /* Split top */ + size_t rsize = gm->topsize -= nb; + mchunkptr p = gm->top; + mchunkptr r = gm->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + mem = chunk2mem(p); + check_top_chunk(gm, gm->top); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + mem = sys_alloc(gm, nb); + + postaction: + if (mem != 0 && !ok_heap_range(mem, bytes)) ABORT; + POSTACTION(gm); + return mem; + } + + return 0; +} + +/* ---------------------------- free --------------------------- */ + +void dlfree(void* mem) { + /* + Consolidate freed chunks with preceeding or succeeding bordering + free chunks, if they exist, and then place in a bin. Intermixed + with special cases for top, dv, mmapped chunks, and usage errors. + */ + + if (mem != 0) { + mchunkptr p = mem2chunk(mem); +#if FOOTERS + mstate fm = get_mstate_for(p); + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } +#else /* FOOTERS */ +#define fm gm +#endif /* FOOTERS */ + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + check_free_chunk(fm, p); + } + else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + check_free_chunk(fm, p); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); + } + } +#if !FOOTERS +#undef fm +#endif /* FOOTERS */ +} + +void* dlcalloc(size_t n_elements, size_t elem_size) { + void* mem; + size_t req = 0; + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = dlmalloc(req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); + return mem; +} + +#endif /* !ONLY_MSPACES */ + +/* ------------ Internal support for realloc, memalign, etc -------------- */ + +/* Try to realloc; only in-place unless can_move true */ +static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, + int can_move) { + mchunkptr newp = 0; + size_t oldsize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, oldsize); + if (RTCHECK(ok_address(m, p) && ok_inuse(p) && + ok_next(p, next) && ok_pinuse(next))) { + if (is_mmapped(p)) { + newp = mmap_resize(m, p, nb, can_move); + } + else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; + if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ + mchunkptr r = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, r, rsize); +#ifdef _TLIBC_ + /* Zero recycled chunk */ + memset(chunk2mem(r), 0, rsize - overhead_for(r)); +#endif + dispose_chunk(m, r, rsize); + } + newp = p; + } + else if (next == m->top) { /* extend into top */ + if (oldsize + m->topsize > nb) { + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; + mchunkptr newtop = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + newtop->head = newtopsize |PINUSE_BIT; + m->top = newtop; + m->topsize = newtopsize; + newp = p; + } + } + else if (next == m->dv) { /* extend into dv */ + size_t dvs = m->dvsize; + if (oldsize + dvs >= nb) { + size_t dsize = oldsize + dvs - nb; + if (dsize >= MIN_CHUNK_SIZE) { + mchunkptr r = chunk_plus_offset(p, nb); + mchunkptr n = chunk_plus_offset(r, dsize); + set_inuse(m, p, nb); + set_size_and_pinuse_of_free_chunk(r, dsize); + clear_pinuse(n); + m->dvsize = dsize; + m->dv = r; + } + else { /* exhaust dv */ + size_t newsize = oldsize + dvs; + set_inuse(m, p, newsize); + m->dvsize = 0; + m->dv = 0; + } + newp = p; + } + } + else if (!cinuse(next)) { /* extend into next free chunk */ + size_t nextsize = chunksize(next); + if (oldsize + nextsize >= nb) { + size_t rsize = oldsize + nextsize - nb; + unlink_chunk(m, next, nextsize); + if (rsize < MIN_CHUNK_SIZE) { + size_t newsize = oldsize + nextsize; + set_inuse(m, p, newsize); + } + else { + mchunkptr r = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, r, rsize); + dispose_chunk(m, r, rsize); + } + newp = p; + } + } + } + else { + USAGE_ERROR_ACTION(m, chunk2mem(p)); + } + return newp; +} + +static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { + void* mem = 0; + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ + alignment = MIN_CHUNK_SIZE; + if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ + size_t a = MALLOC_ALIGNMENT << 1; + while (a < alignment) a <<= 1; + alignment = a; + } + if (bytes >= MAX_REQUEST - alignment) { + if (m != 0) { /* Test isn't needed but avoids compiler warning */ + MALLOC_FAILURE_ACTION; + } + } + else { + size_t nb = request2size(bytes); + size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; + mem = internal_malloc(m, req); + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (PREACTION(m)) + return 0; + if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ + /* + Find an aligned spot inside chunk. Since we need to give + back leading space in a chunk of at least MIN_CHUNK_SIZE, if + the first calculation places us at a spot with less than + MIN_CHUNK_SIZE leader, we can move to the next aligned spot. + We've allocated enough total room so that this is always + possible. + */ + char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment - + SIZE_T_ONE)) & + -alignment)); + char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? + br : br+alignment; + mchunkptr newp = (mchunkptr)pos; + size_t leadsize = pos - (char*)(p); + size_t newsize = chunksize(p) - leadsize; + + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + newp->prev_foot = p->prev_foot + leadsize; + newp->head = newsize; + } + else { /* Otherwise, give back leader, use the rest */ + set_inuse(m, newp, newsize); + set_inuse(m, p, leadsize); + dispose_chunk(m, p, leadsize); + } + p = newp; + } + + /* Give back spare room at the end */ + if (!is_mmapped(p)) { + size_t size = chunksize(p); + if (size > nb + MIN_CHUNK_SIZE) { + size_t remainder_size = size - nb; + mchunkptr remainder = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, remainder, remainder_size); + dispose_chunk(m, remainder, remainder_size); + } + } + + mem = chunk2mem(p); + assert (chunksize(p) >= nb); + assert(((size_t)mem & (alignment - 1)) == 0); + check_inuse_chunk(m, p); + POSTACTION(m); + } + } + return mem; +} + +#ifdef USE_MALLOC_DEPRECATED +/* + Common support for independent_X routines, handling + all of the combinations that can result. + The opts arg has: + bit 0 set if all elements are same size (using sizes[0]) + bit 1 set if elements should be zeroed +*/ +static void** ialloc(mstate m, + size_t n_elements, + size_t* sizes, + int opts, + void* chunks[]) { + + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void* mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ + size_t size; + size_t i; + + ensure_initialization(); + /* compute array length, if needed */ + if (chunks != 0) { + if (n_elements == 0) + return chunks; /* nothing to do */ + marray = chunks; + array_size = 0; + } + else { + /* if empty req, must still return chunk representing empty array */ + if (n_elements == 0) + return (void**)internal_malloc(m, 0); + marray = 0; + array_size = request2size(n_elements * (sizeof(void*))); + } + + /* compute total element size */ + if (opts & 0x1) { /* all-same-size */ + element_size = request2size(*sizes); + contents_size = n_elements * element_size; + } + else { /* add up all the sizes */ + element_size = 0; + contents_size = 0; + for (i = 0; i != n_elements; ++i) + contents_size += request2size(sizes[i]); + } + + size = contents_size + array_size; + + /* + Allocate the aggregate chunk. First disable direct-mmapping so + malloc won't use it, since we would not be able to later + free/realloc space internal to a segregated mmap region. + */ + was_enabled = use_mmap(m); + disable_mmap(m); + mem = internal_malloc(m, size - CHUNK_OVERHEAD); + if (was_enabled) + enable_mmap(m); + if (mem == 0) + return 0; + + if (PREACTION(m)) return 0; + p = mem2chunk(mem); + remainder_size = chunksize(p); + + assert(!is_mmapped(p)); + + if (opts & 0x2) { /* optionally clear the elements */ + memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); + } + + /* If not provided, allocate the pointer array as final part of chunk */ + if (marray == 0) { + size_t array_chunk_size; + array_chunk = chunk_plus_offset(p, contents_size); + array_chunk_size = remainder_size - contents_size; + marray = (void**) (chunk2mem(array_chunk)); + set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); + remainder_size = contents_size; + } + + /* split out elements */ + for (i = 0; ; ++i) { + marray[i] = chunk2mem(p); + if (i != n_elements-1) { + if (element_size != 0) + size = element_size; + else + size = request2size(sizes[i]); + remainder_size -= size; + set_size_and_pinuse_of_inuse_chunk(m, p, size); + p = chunk_plus_offset(p, size); + } + else { /* the final element absorbs any overallocation slop */ + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); + break; + } + } + +#if DEBUG + if (marray != chunks) { + /* final element must have exactly exhausted chunk */ + if (element_size != 0) { + assert(remainder_size == element_size); + } + else { + assert(remainder_size == request2size(sizes[i])); + } + check_inuse_chunk(m, mem2chunk(marray)); + } + for (i = 0; i != n_elements; ++i) + check_inuse_chunk(m, mem2chunk(marray[i])); + +#endif /* DEBUG */ + + POSTACTION(m); + return marray; +} + +/* Try to free all pointers in the given array. + Note: this could be made faster, by delaying consolidation, + at the price of disabling some user integrity checks, We + still optimize some consolidations by combining adjacent + chunks before freeing, which will occur often if allocated + with ialloc or the array is sorted. +*/ +static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) { + size_t unfreed = 0; + if (!PREACTION(m)) { + void** a; + void** fence = &(array[nelem]); + for (a = array; a != fence; ++a) { + void* mem = *a; + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + size_t psize = chunksize(p); +#if FOOTERS + if (get_mstate_for(p) != m) { + ++unfreed; + continue; + } +#endif + check_inuse_chunk(m, p); + *a = 0; + if (RTCHECK(ok_address(m, p) && ok_inuse(p))) { + void ** b = a + 1; /* try to merge with next chunk */ + mchunkptr next = next_chunk(p); + if (b != fence && *b == chunk2mem(next)) { + size_t newsize = chunksize(next) + psize; + set_inuse(m, p, newsize); + *b = chunk2mem(p); + } + else + dispose_chunk(m, p, psize); + } + else { + CORRUPTION_ERROR_ACTION(m); + break; + } + } + } + if (should_trim(m, m->topsize)) + sys_trim(m, 0); + POSTACTION(m); + } + return unfreed; +} +#endif /* USE_MALLOC_DEPRECATED */ + +/* Traversal */ +#if MALLOC_INSPECT_ALL +static void internal_inspect_all(mstate m, + void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { + if (is_initialized(m)) { + mchunkptr top = m->top; + msegmentptr s; + for (s = &m->seg; s != 0; s = s->next) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) { + mchunkptr next = next_chunk(q); + size_t sz = chunksize(q); + size_t used; + void* start; + if (is_inuse(q)) { + used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ + start = chunk2mem(q); + } + else { + used = 0; + if (is_small(sz)) { /* offset by possible bookkeeping */ + start = (void*)((char*)q + sizeof(struct malloc_chunk)); + } + else { + start = (void*)((char*)q + sizeof(struct malloc_tree_chunk)); + } + } + if (start < (void*)next) /* skip if all space is bookkeeping */ + handler(start, next, used, arg); + if (q == top) + break; + q = next; + } + } + } +} +#endif /* MALLOC_INSPECT_ALL */ + +/* ------------------ Exported realloc, memalign, etc -------------------- */ + +#if !ONLY_MSPACES + +void* dlrealloc(void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem == 0) { + mem = dlmalloc(bytes); + } + else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } +#ifdef REALLOC_ZERO_BYTES_FREES + else if (bytes == 0) { + dlfree(oldmem); + } +#endif /* REALLOC_ZERO_BYTES_FREES */ + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = gm; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); + POSTACTION(m); + if (newp != 0) { + check_inuse_chunk(m, newp); + mem = chunk2mem(newp); + } + else { + mem = internal_malloc(m, bytes); + if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); + memcpy(mem, oldmem, (oc < bytes)? oc : bytes); +#ifdef _TLIBC_ + /* Zero recycled chunk */ + memset(oldmem, 0, oc); +#endif + internal_free(m, oldmem); + } + } + } + } + return mem; +} + +#ifdef USE_MALLOC_DEPRECATED +void* dlrealloc_in_place(void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = gm; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); + POSTACTION(m); + if (newp == oldp) { + check_inuse_chunk(m, newp); + mem = oldmem; + } + } + } + } + return mem; +} +#endif + +void* dlmemalign(size_t alignment, size_t bytes) { + if (alignment <= MALLOC_ALIGNMENT) { + return dlmalloc(bytes); + } + return internal_memalign(gm, alignment, bytes); +} + +#ifdef USE_MALLOC_DEPRECATED +int dlposix_memalign(void** pp, size_t alignment, size_t bytes) { + void* mem = 0; + if (alignment == MALLOC_ALIGNMENT) + mem = dlmalloc(bytes); + else { + size_t d = alignment / sizeof(void*); + size_t r = alignment % sizeof(void*); + if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0) + return EINVAL; + else if (bytes <= MAX_REQUEST - alignment) { + if (alignment < MIN_CHUNK_SIZE) + alignment = MIN_CHUNK_SIZE; + mem = internal_memalign(gm, alignment, bytes); + } + } + if (mem == 0) + return ENOMEM; + else { + *pp = mem; + return 0; + } +} + +void* dlvalloc(size_t bytes) { + size_t pagesz; + ensure_initialization(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, bytes); +} + +void* dlpvalloc(size_t bytes) { + size_t pagesz; + ensure_initialization(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); +} + +void** dlindependent_calloc(size_t n_elements, size_t elem_size, + void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ + return ialloc(gm, n_elements, &sz, 3, chunks); +} + +void** dlindependent_comalloc(size_t n_elements, size_t sizes[], + void* chunks[]) { + return ialloc(gm, n_elements, sizes, 0, chunks); +} + +size_t dlbulk_free(void* array[], size_t nelem) { + return internal_bulk_free(gm, array, nelem); +} + +#if MALLOC_INSPECT_ALL +void dlmalloc_inspect_all(void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { + ensure_initialization(); + if (!PREACTION(gm)) { + internal_inspect_all(gm, handler, arg); + POSTACTION(gm); + } +} +#endif /* MALLOC_INSPECT_ALL */ + +int dlmalloc_trim(size_t pad) { + int result = 0; + ensure_initialization(); + if (!PREACTION(gm)) { + result = sys_trim(gm, pad); + POSTACTION(gm); + } + return result; +} + +size_t dlmalloc_footprint(void) { + return gm->footprint; +} + +size_t dlmalloc_max_footprint(void) { + return gm->max_footprint; +} + +size_t dlmalloc_footprint_limit(void) { + size_t maf = gm->footprint_limit; + return maf == 0 ? MAX_SIZE_T : maf; +} + +size_t dlmalloc_set_footprint_limit(size_t bytes) { + size_t result; /* invert sense of 0 */ + if (bytes == 0) + result = granularity_align(1); /* Use minimal size */ + if (bytes == MAX_SIZE_T) + result = 0; /* disable */ + else + result = granularity_align(bytes); + return gm->footprint_limit = result; +} + +#endif /* USE_MALLOC_DEPRECATED */ + +#if !NO_MALLINFO +struct mallinfo dlmallinfo(void) { + return internal_mallinfo(gm); +} +#endif /* NO_MALLINFO */ + +#ifdef USE_MALLOC_DEPRECATED + +#if !NO_MALLOC_STATS +void dlmalloc_stats() { + internal_malloc_stats(gm); +} +#endif /* NO_MALLOC_STATS */ + +int dlmallopt(int param_number, int value) { + return change_mparam(param_number, value); +} + +size_t dlmalloc_usable_size(void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); + } + return 0; +} + +#endif /* USE_MALLOC_DEPRECATED */ + +#endif /* !ONLY_MSPACES */ + +/* ----------------------------- user mspaces ---------------------------- */ + +#if MSPACES + +static mstate init_user_mstate(char* tbase, size_t tsize) { + size_t msize = pad_request(sizeof(struct malloc_state)); + mchunkptr mn; + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate)(chunk2mem(msp)); + memset(m, 0, msize); + (void)INITIAL_LOCK(&m->mutex); + msp->head = (msize|INUSE_BITS); + m->seg.base = m->least_addr = tbase; + m->seg.size = m->footprint = m->max_footprint = tsize; + m->magic = mparams.magic; + m->release_checks = MAX_RELEASE_CHECK_RATE; + m->mflags = mparams.default_mflags; + m->extp = 0; + m->exts = 0; + disable_contiguous(m); + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + check_top_chunk(m, m->top); + return m; +} + +mspace create_mspace(size_t capacity, int locked) { + mstate m = 0; + size_t msize; + ensure_initialization(); + msize = pad_request(sizeof(struct malloc_state)); + if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + size_t rs = ((capacity == 0)? mparams.granularity : + (capacity + TOP_FOOT_SIZE + msize)); + size_t tsize = granularity_align(rs); + char* tbase = (char*)(CALL_MMAP(tsize)); + if (tbase != CMFAIL) { + m = init_user_mstate(tbase, tsize); + m->seg.sflags = USE_MMAP_BIT; + set_lock(m, locked); + } + } + return (mspace)m; +} + +mspace create_mspace_with_base(void* base, size_t capacity, int locked) { + mstate m = 0; + size_t msize; + ensure_initialization(); + msize = pad_request(sizeof(struct malloc_state)); + if (capacity > msize + TOP_FOOT_SIZE && + capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + m = init_user_mstate((char*)base, capacity); + m->seg.sflags = EXTERN_BIT; + set_lock(m, locked); + } + return (mspace)m; +} + +int mspace_track_large_chunks(mspace msp, int enable) { + int ret = 0; + mstate ms = (mstate)msp; + if (!PREACTION(ms)) { + if (!use_mmap(ms)) { + ret = 1; + } + if (!enable) { + enable_mmap(ms); + } else { + disable_mmap(ms); + } + POSTACTION(ms); + } + return ret; +} + +size_t destroy_mspace(mspace msp) { + size_t freed = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + msegmentptr sp = &ms->seg; + (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + flag_t flag = sp->sflags; + (void)base; /* placate people compiling -Wunused-variable */ + sp = sp->next; + if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && + CALL_MUNMAP(base, size) == 0) + freed += size; + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return freed; +} + +/* + mspace versions of routines are near-clones of the global + versions. This is not so nice but better than the alternatives. +*/ + +void* mspace_malloc(mspace msp, size_t bytes) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (!PREACTION(ms)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = ms->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(ms, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb > ms->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(ms, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(ms, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + + if (nb <= ms->dvsize) { + size_t rsize = ms->dvsize - nb; + mchunkptr p = ms->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); + ms->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + } + else { /* exhaust dv */ + size_t dvs = ms->dvsize; + ms->dvsize = 0; + ms->dv = 0; + set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; + mchunkptr p = ms->top; + mchunkptr r = ms->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + check_top_chunk(ms, ms->top); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + mem = sys_alloc(ms, nb); + + postaction: + POSTACTION(ms); + return mem; + } + + return 0; +} + +void mspace_free(mspace msp, void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); +#if FOOTERS + mstate fm = get_mstate_for(p); + (void)msp; /* placate people compiling -Wunused */ +#else /* FOOTERS */ + mstate fm = (mstate)msp; +#endif /* FOOTERS */ + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + check_free_chunk(fm, p); + } + else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + check_free_chunk(fm, p); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); + } + } +} + +void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { + void* mem; + size_t req = 0; + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = internal_malloc(ms, req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); + return mem; +} + +void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem == 0) { + mem = mspace_malloc(msp, bytes); + } + else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } +#ifdef REALLOC_ZERO_BYTES_FREES + else if (bytes == 0) { + mspace_free(msp, oldmem); + } +#endif /* REALLOC_ZERO_BYTES_FREES */ + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = (mstate)msp; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); + POSTACTION(m); + if (newp != 0) { + check_inuse_chunk(m, newp); + mem = chunk2mem(newp); + } + else { + mem = mspace_malloc(m, bytes); + if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); + memcpy(mem, oldmem, (oc < bytes)? oc : bytes); + mspace_free(m, oldmem); + } + } + } + } + return mem; +} + +void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = (mstate)msp; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + (void)msp; /* placate people compiling -Wunused */ + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); + POSTACTION(m); + if (newp == oldp) { + check_inuse_chunk(m, newp); + mem = oldmem; + } + } + } + } + return mem; +} + +void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (alignment <= MALLOC_ALIGNMENT) + return mspace_malloc(msp, bytes); + return internal_memalign(ms, alignment, bytes); +} + +void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, &sz, 3, chunks); +} + +void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, sizes, 0, chunks); +} + +size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) { + return internal_bulk_free((mstate)msp, array, nelem); +} + +#if MALLOC_INSPECT_ALL +void mspace_inspect_all(mspace msp, + void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + internal_inspect_all(ms, handler, arg); + POSTACTION(ms); + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } +} +#endif /* MALLOC_INSPECT_ALL */ + +int mspace_trim(mspace msp, size_t pad) { + int result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); + POSTACTION(ms); + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +#if !NO_MALLOC_STATS +void mspace_malloc_stats(mspace msp) { + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + internal_malloc_stats(ms); + } + else { + USAGE_ERROR_ACTION(ms,ms); + } +} +#endif /* NO_MALLOC_STATS */ + +size_t mspace_footprint(mspace msp) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->footprint; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +size_t mspace_max_footprint(mspace msp) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->max_footprint; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +size_t mspace_footprint_limit(mspace msp) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + size_t maf = ms->footprint_limit; + result = (maf == 0) ? MAX_SIZE_T : maf; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (bytes == 0) + result = granularity_align(1); /* Use minimal size */ + if (bytes == MAX_SIZE_T) + result = 0; /* disable */ + else + result = granularity_align(bytes); + ms->footprint_limit = result; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +#if !NO_MALLINFO +struct mallinfo mspace_mallinfo(mspace msp) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + } + return internal_mallinfo(ms); +} +#endif /* NO_MALLINFO */ + +size_t mspace_usable_size(const void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); + } + return 0; +} + +int mspace_mallopt(int param_number, int value) { + return change_mparam(param_number, value); +} + +#endif /* MSPACES */ + + +/* -------------------- Alternative MORECORE functions ------------------- */ + +/* + Guidelines for creating a custom version of MORECORE: + + * For best performance, MORECORE should allocate in multiples of pagesize. + * MORECORE may allocate more memory than requested. (Or even less, + but this will usually result in a malloc failure.) + * MORECORE must not allocate memory when given argument zero, but + instead return one past the end address of memory from previous + nonzero call. + * For best performance, consecutive calls to MORECORE with positive + arguments should return increasing addresses, indicating that + space has been contiguously extended. + * Even though consecutive calls to MORECORE need not return contiguous + addresses, it must be OK for malloc'ed chunks to span multiple + regions in those cases where they do happen to be contiguous. + * MORECORE need not handle negative arguments -- it may instead + just return MFAIL when given negative arguments. + Negative arguments are always multiples of pagesize. MORECORE + must not misinterpret negative args as large positive unsigned + args. You can suppress all such calls from even occurring by defining + MORECORE_CANNOT_TRIM, + + As an example alternative MORECORE, here is a custom allocator + kindly contributed for pre-OSX macOS. It uses virtually but not + necessarily physically contiguous non-paged memory (locked in, + present and won't get swapped out). You can use it by uncommenting + this section, adding some #includes, and setting up the appropriate + defines above: + + #define MORECORE osMoreCore + + There is also a shutdown routine that should somehow be called for + cleanup upon program exit. + + #define MAX_POOL_ENTRIES 100 + #define MINIMUM_MORECORE_SIZE (64 * 1024U) + static int next_os_pool; + void *our_os_pools[MAX_POOL_ENTRIES]; + + void *osMoreCore(int size) + { + void *ptr = 0; + static void *sbrk_top = 0; + + if (size > 0) + { + if (size < MINIMUM_MORECORE_SIZE) + size = MINIMUM_MORECORE_SIZE; + if (CurrentExecutionLevel() == kTaskLevel) + ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); + if (ptr == 0) + { + return (void *) MFAIL; + } + // save ptrs so they can be freed during cleanup + our_os_pools[next_os_pool] = ptr; + next_os_pool++; + ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); + sbrk_top = (char *) ptr + size; + return ptr; + } + else if (size < 0) + { + // we don't currently support shrink behavior + return (void *) MFAIL; + } + else + { + return sbrk_top; + } + } + + // cleanup any allocated memory pools + // called as last thing before shutting down driver + + void osCleanupMem(void) + { + void **ptr; + + for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) + if (*ptr) + { + PoolDeallocate(*ptr); + *ptr = 0; + } + } + +*/ + + +/* ----------------------------------------------------------------------- +History: + v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea + * fix bad comparison in dlposix_memalign + * don't reuse adjusted asize in sys_alloc + * add LOCK_AT_FORK -- thanks to Kirill Artamonov for the suggestion + * reduce compiler warnings -- thanks to all who reported/suggested these + + v2.8.5 Sun May 22 10:26:02 2011 Doug Lea (dl at gee) + * Always perform unlink checks unless INSECURE + * Add posix_memalign. + * Improve realloc to expand in more cases; expose realloc_in_place. + Thanks to Peter Buhr for the suggestion. + * Add footprint_limit, inspect_all, bulk_free. Thanks + to Barry Hayes and others for the suggestions. + * Internal refactorings to avoid calls while holding locks + * Use non-reentrant locks by default. Thanks to Roland McGrath + for the suggestion. + * Small fixes to mspace_destroy, reset_on_error. + * Various configuration extensions/changes. Thanks + to all who contributed these. + + V2.8.4a Thu Apr 28 14:39:43 2011 (dl at gee.cs.oswego.edu) + * Update Creative Commons URL + + V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) + * Use zeros instead of prev foot for is_mmapped + * Add mspace_track_large_chunks; thanks to Jean Brouwers + * Fix set_inuse in internal_realloc; thanks to Jean Brouwers + * Fix insufficient sys_alloc padding when using 16byte alignment + * Fix bad error check in mspace_footprint + * Adaptations for ptmalloc; thanks to Wolfram Gloger. + * Reentrant spin locks; thanks to Earl Chew and others + * Win32 improvements; thanks to Niall Douglas and Earl Chew + * Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options + * Extension hook in malloc_state + * Various small adjustments to reduce warnings on some compilers + * Various configuration extensions/changes for more platforms. Thanks + to all who contributed these. + + V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) + * Add max_footprint functions + * Ensure all appropriate literals are size_t + * Fix conditional compilation problem for some #define settings + * Avoid concatenating segments with the one provided + in create_mspace_with_base + * Rename some variables to avoid compiler shadowing warnings + * Use explicit lock initialization. + * Better handling of sbrk interference. + * Simplify and fix segment insertion, trimming and mspace_destroy + * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x + * Thanks especially to Dennis Flanagan for help on these. + + V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) + * Fix memalign brace error. + + V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) + * Fix improper #endif nesting in C++ + * Add explicit casts needed for C++ + + V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) + * Use trees for large bins + * Support mspaces + * Use segments to unify sbrk-based and mmap-based system allocation, + removing need for emulation on most platforms without sbrk. + * Default safety checks + * Optional footer checks. Thanks to William Robertson for the idea. + * Internal code refactoring + * Incorporate suggestions and platform-specific changes. + Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, + Aaron Bachmann, Emery Berger, and others. + * Speed up non-fastbin processing enough to remove fastbins. + * Remove useless cfree() to avoid conflicts with other apps. + * Remove internal memcpy, memset. Compilers handle builtins better. + * Remove some options that no one ever used and rename others. + + V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + * Fix malloc_state bitmap array misdeclaration + + V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) + * Allow tuning of FIRST_SORTED_BIN_SIZE + * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. + * Better detection and support for non-contiguousness of MORECORE. + Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger + * Bypass most of malloc if no frees. Thanks To Emery Berger. + * Fix freeing of old top non-contiguous chunk im sysmalloc. + * Raised default trim and map thresholds to 256K. + * Fix mmap-related #defines. Thanks to Lubos Lunak. + * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. + * Branch-free bin calculation + * Default trim and mmap thresholds now 256K. + + V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) + * Introduce independent_comalloc and independent_calloc. + Thanks to Michael Pachos for motivation and help. + * Make optional .h file available + * Allow > 2GB requests on 32bit systems. + * new WIN32 sbrk, mmap, munmap, lock code from . + Thanks also to Andreas Mueller , + and Anonymous. + * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for + helping test this.) + * memalign: check alignment arg + * realloc: don't try to shift chunks backwards, since this + leads to more fragmentation in some programs and doesn't + seem to help in any others. + * Collect all cases in malloc requiring system memory into sysmalloc + * Use mmap as backup to sbrk + * Place all internal state in malloc_state + * Introduce fastbins (although similar to 2.5.1) + * Many minor tunings and cosmetic improvements + * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK + * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS + Thanks to Tony E. Bennett and others. + * Include errno.h to support default failure action. + + V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) + * return null for negative arguments + * Added Several WIN32 cleanups from Martin C. Fong + * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' + (e.g. WIN32 platforms) + * Cleanup header file inclusion for WIN32 platforms + * Cleanup code to avoid Microsoft Visual C++ compiler complaints + * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing + memory allocation routines + * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) + * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to + usage of 'assert' in non-WIN32 code + * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to + avoid infinite loop + * Always call 'fREe()' rather than 'free()' + + V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) + * Fixed ordering problem with boundary-stamping + + V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) + * Added pvalloc, as recommended by H.J. Liu + * Added 64bit pointer support mainly from Wolfram Gloger + * Added anonymously donated WIN32 sbrk emulation + * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen + * malloc_extend_top: fix mask error that caused wastage after + foreign sbrks + * Add linux mremap support code from HJ Liu + + V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) + * Integrated most documentation with the code. + * Add support for mmap, with help from + Wolfram Gloger (Gloger@lrz.uni-muenchen.de). + * Use last_remainder in more cases. + * Pack bins using idea from colin@nyx10.cs.du.edu + * Use ordered bins instead of best-fit threshhold + * Eliminate block-local decls to simplify tracing and debugging. + * Support another case of realloc via move into top + * Fix error occuring when initial sbrk_base not word-aligned. + * Rely on page size for units instead of SBRK_UNIT to + avoid surprises about sbrk alignment conventions. + * Add mallinfo, mallopt. Thanks to Raymond Nijssen + (raymond@es.ele.tue.nl) for the suggestion. + * Add `pad' argument to malloc_trim and top_pad mallopt parameter. + * More precautions for cases where other routines call sbrk, + courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). + * Added macros etc., allowing use in linux libc from + H.J. Lu (hjl@gnu.ai.mit.edu) + * Inverted this history list + + V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) + * Re-tuned and fixed to behave more nicely with V2.6.0 changes. + * Removed all preallocation code since under current scheme + the work required to undo bad preallocations exceeds + the work saved in good cases for most test programs. + * No longer use return list or unconsolidated bins since + no scheme using them consistently outperforms those that don't + given above changes. + * Use best fit for very large chunks to prevent some worst-cases. + * Added some support for debugging + + V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) + * Removed footers when chunks are in use. Thanks to + Paul Wilson (wilson@cs.texas.edu) for the suggestion. + + V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) + * Added malloc_trim, with help from Wolfram Gloger + (wmglo@Dent.MED.Uni-Muenchen.DE). + + V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) + + V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) + * realloc: try to expand in both directions + * malloc: swap order of clean-bin strategy; + * realloc: only conditionally expand backwards + * Try not to scavenge used bins + * Use bin counts as a guide to preallocation + * Occasionally bin return list chunks in first scan + * Add a few optimizations from colin@nyx10.cs.du.edu + + V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) + * faster bin computation & slightly different binning + * merged all consolidations to one part of malloc proper + (eliminating old malloc_find_space & malloc_clean_bin) + * Scan 2 returns chunks (not just 1) + * Propagate failure in realloc if malloc returns 0 + * Add stuff to allow compilation on non-ANSI compilers + from kpv@research.att.com + + V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) + * removed potential for odd address access in prev_chunk + * removed dependency on getpagesize.h + * misc cosmetics and a bit more internal documentation + * anticosmetics: mangled names in macros to evade debugger strangeness + * tested on sparc, hp-700, dec-mips, rs6000 + with gcc & native cc (hp, dec only) allowing + Detlefs & Zorn comparison study (in SIGPLAN Notices.) + + Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) + * Based loosely on libg++-1.2X malloc. (It retains some of the overall + structure of old version, but most details differ.) + +*/ diff --git a/sdk/tlibc/stdlib/qsort.c b/sdk/tlibc/stdlib/qsort.c new file mode 100644 index 0000000000..8a8b978534 --- /dev/null +++ b/sdk/tlibc/stdlib/qsort.c @@ -0,0 +1,164 @@ +/* $OpenBSD: qsort.c,v 1.11 2010/02/08 11:04:07 otto Exp $ */ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +static __inline char *med3(char *, char *, char *, int (*)(const void *, const void *)); +static __inline void swapfunc(char *, char *, size_t, int); + +#define min(a, b) (a) < (b) ? a : b + +/* + * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". + */ +#define swapcode(TYPE, parmi, parmj, n) { \ + size_t i = (n) / sizeof (TYPE); \ + TYPE *pi = (TYPE *) (parmi); \ + TYPE *pj = (TYPE *) (parmj); \ + do { \ + TYPE t = *pi; \ + *pi++ = *pj; \ + *pj++ = t; \ + } while (--i > 0); \ +} + +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ + es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; + +static __inline void +swapfunc(char *a, char *b, size_t n, int swaptype) +{ + if (swaptype <= 1) + swapcode(long, a, b, n) + else + swapcode(char, a, b, n) +} + +#define swap(a, b) \ + if (swaptype == 0) { \ + long t = *(long *)(a); \ + *(long *)(a) = *(long *)(b); \ + *(long *)(b) = t; \ + } else \ + swapfunc(a, b, es, swaptype) + +#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) + +static __inline char * +med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *)) +{ + return cmp(a, b) < 0 ? + (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a )) + :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c )); +} + +/* Disable warnings */ + +void +qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *)) +{ + char *pa, *pb, *pc, *pd, *pl, *pm, *pn; + int cmp_result, swaptype, swap_cnt; + size_t d, r; + char *a = (char *)aa; + +loop: SWAPINIT(a, es); + swap_cnt = 0; + if (n < 7) { + for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es) + for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + pm = (char *)a + (n / 2) * es; + if (n > 7) { + pl = (char *)a; + pn = (char *)a + (n - 1) * es; + if (n > 40) { + d = (n / 8) * es; + pl = med3(pl, pl + d, pl + 2 * d, cmp); + pm = med3(pm - d, pm, pm + d, cmp); + pn = med3(pn - 2 * d, pn - d, pn, cmp); + } + pm = med3(pl, pm, pn, cmp); + } + swap(a, pm); + pa = pb = (char *)a + es; + + pc = pd = (char *)a + (n - 1) * es; + for (;;) { + while (pb <= pc && (cmp_result = cmp(pb, a)) <= 0) { + if (cmp_result == 0) { + swap_cnt = 1; + swap(pa, pb); + pa += es; + } + pb += es; + } + while (pb <= pc && (cmp_result = cmp(pc, a)) >= 0) { + if (cmp_result == 0) { + swap_cnt = 1; + swap(pc, pd); + pd -= es; + } + pc -= es; + } + if (pb > pc) + break; + swap(pb, pc); + swap_cnt = 1; + pb += es; + pc -= es; + } + if (swap_cnt == 0) { /* Switch to insertion sort */ + for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) + for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + + pn = (char *)a + n * es; + r = min(pa - (char *)a, pb - pa); + vecswap(a, pb - r, r); + r = min(pd - pc, pn - pd - es); + vecswap(pb, pn - r, r); + if ((r = pb - pa) > es) + qsort(a, r / es, es, cmp); + if ((r = pd - pc) > es) { + /* Iterate rather than recurse to save stack space */ + a = pn - r; + n = r / es; + goto loop; + } +/* qsort(pn - r, r / es, es, cmp);*/ +} diff --git a/sdk/tlibc/stdlib/strtoimax.c b/sdk/tlibc/stdlib/strtoimax.c new file mode 100644 index 0000000000..2c77f41650 --- /dev/null +++ b/sdk/tlibc/stdlib/strtoimax.c @@ -0,0 +1,140 @@ +/* $OpenBSD: strtoimax.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ + +/*- + * Copyright (c) 1992 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +/* + * Convert a string to an intmax_t + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +intmax_t +strtoimax(const char *nptr, char **endptr, int base) +{ + const char *s; + intmax_t acc, cutoff; + int c; + int neg, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = (unsigned char) *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for intmax_t is + * [-9223372036854775808..9223372036854775807] and the input base + * is 10, cutoff will be set to 922337203685477580 and cutlim to + * either 7 (neg==0) or 8 (neg==1), meaning that if we have + * accumulated a value > 922337203685477580, or equal but the + * next digit is > 7 (or 8), the number is too big, and we will + * return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? INTMAX_MIN : INTMAX_MAX; + cutlim = cutoff % base; + cutoff /= base; + if (neg) { + if (cutlim > 0) { + cutlim -= base; + cutoff += 1; + } + cutlim = -cutlim; + } + for (acc = 0, any = 0;; c = (unsigned char) *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0) + continue; + if (neg) { + if (acc < cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = INTMAX_MIN; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc -= c; + } + } else { + if (acc > cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = INTMAX_MAX; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc += c; + } + } + } + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/sdk/tlibc/stdlib/strtol.c b/sdk/tlibc/stdlib/strtol.c new file mode 100644 index 0000000000..dc2cf8871c --- /dev/null +++ b/sdk/tlibc/stdlib/strtol.c @@ -0,0 +1,151 @@ +/* $OpenBSD: strtol.c,v 1.9 2013/04/17 17:40:35 tedu Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + + +/* + * Convert a string to a long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long +strtol(const char *nptr, char **endptr, int base) +{ + const char *s; + long acc, cutoff; + int c; + int neg, any, cutlim; + + /* + * Ensure that base is between 2 and 36 inclusive, or the special + * value of 0. + */ + if (base != 0 && (base < 2 || base > 36)) { + if (endptr != 0) + *endptr = (char *)nptr; + errno = EINVAL; + return 0; + } + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = (unsigned char) *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? LONG_MIN : LONG_MAX; + cutlim = cutoff % base; + cutoff /= base; + if (neg) { + if (cutlim > 0) { + cutlim -= base; + cutoff += 1; + } + cutlim = -cutlim; + } + for (acc = 0, any = 0;; c = (unsigned char) *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0) + continue; + if (neg) { + if (acc < cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = LONG_MIN; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc -= c; + } + } else { + if (acc > cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = LONG_MAX; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc += c; + } + } + } + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/sdk/tlibc/stdlib/strtoll.c b/sdk/tlibc/stdlib/strtoll.c new file mode 100644 index 0000000000..ffb4eb526a --- /dev/null +++ b/sdk/tlibc/stdlib/strtoll.c @@ -0,0 +1,143 @@ +/* $OpenBSD: strtoll.c,v 1.7 2013/03/28 18:09:38 martynas Exp $ */ +/*- + * Copyright (c) 1992 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include + +/* + * Convert a string to a long long. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long long +strtoll(const char *nptr, char **endptr, int base) +{ + const char *s; + long long acc, cutoff; + int c; + int neg, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = (unsigned char) *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for long longs is + * [-9223372036854775808..9223372036854775807] and the input base + * is 10, cutoff will be set to 922337203685477580 and cutlim to + * either 7 (neg==0) or 8 (neg==1), meaning that if we have + * accumulated a value > 922337203685477580, or equal but the + * next digit is > 7 (or 8), the number is too big, and we will + * return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? LLONG_MIN : LLONG_MAX; + cutlim = cutoff % base; + cutoff /= base; + if (neg) { + if (cutlim > 0) { + cutlim -= base; + cutoff += 1; + } + cutlim = -cutlim; + } + for (acc = 0, any = 0;; c = (unsigned char) *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0) + continue; + if (neg) { + if (acc < cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = LLONG_MIN; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc -= c; + } + } else { + if (acc > cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = LLONG_MAX; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc += c; + } + } + } + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} + diff --git a/sdk/tlibc/stdlib/strtoul.c b/sdk/tlibc/stdlib/strtoul.c new file mode 100644 index 0000000000..f33c818510 --- /dev/null +++ b/sdk/tlibc/stdlib/strtoul.c @@ -0,0 +1,104 @@ +/* $OpenBSD: strtoul.c,v 1.7 2005/08/08 08:05:37 espie Exp $ */ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +/* Disable warnings */ + +/* + * Convert a string to an unsigned long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long +strtoul(const char *nptr, char **endptr, int base) +{ + const char *s; + unsigned long acc, cutoff; + int c; + int neg, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + s = nptr; + do { + c = (unsigned char) *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + cutoff = ULONG_MAX / (unsigned long)base; + cutlim = ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = (unsigned char) *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0) + continue; + if (acc > cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = ULONG_MAX; + errno = ERANGE; + } else { + any = 1; + acc *= (unsigned long)base; + acc += c; + } + } + if (neg && any > 0) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/sdk/tlibc/stdlib/strtoull.c b/sdk/tlibc/stdlib/strtoull.c new file mode 100644 index 0000000000..9bb4477486 --- /dev/null +++ b/sdk/tlibc/stdlib/strtoull.c @@ -0,0 +1,107 @@ +/* $OpenBSD: strtoull.c,v 1.6 2013/03/28 18:09:38 martynas Exp $ */ +/*- + * Copyright (c) 1992 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include + +/* Disable warnings */ + +/* + * Convert a string to an unsigned long long. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long long +strtoull(const char *nptr, char **endptr, int base) +{ + const char *s; + unsigned long long acc, cutoff; + int c; + int neg, any, cutlim; + + /* + * See strtoq for comments as to the logic used. + */ + s = nptr; + do { + c = (unsigned char) *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + cutoff = ULLONG_MAX / (unsigned long long)base; + cutlim = ULLONG_MAX % (unsigned long long)base; + for (acc = 0, any = 0;; c = (unsigned char) *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0) + continue; + if (acc > cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = ULLONG_MAX; + errno = ERANGE; + } else { + any = 1; + acc *= (unsigned long long)base; + acc += c; + } + } + if (neg && any > 0) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} + diff --git a/sdk/tlibc/stdlib/strtoumax.c b/sdk/tlibc/stdlib/strtoumax.c new file mode 100644 index 0000000000..f4dab52391 --- /dev/null +++ b/sdk/tlibc/stdlib/strtoumax.c @@ -0,0 +1,104 @@ +/* $OpenBSD: strtoumax.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ + +/*- + * Copyright (c) 1992 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +/* Disable warnings */ + +/* + * Convert a string to a uintmax_t. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +uintmax_t +strtoumax(const char *nptr, char **endptr, int base) +{ + const char *s; + uintmax_t acc, cutoff; + int c; + int neg, any, cutlim; + + /* + * See strtoq for comments as to the logic used. + */ + s = nptr; + do { + c = (unsigned char) *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + cutoff = UINTMAX_MAX / (uintmax_t)base; + cutlim = UINTMAX_MAX % (uintmax_t)base; + for (acc = 0, any = 0;; c = (unsigned char) *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0) + continue; + if (acc > cutoff || (acc == cutoff && c > cutlim)) { + any = -1; + acc = UINTMAX_MAX; + errno = ERANGE; + } else { + any = 1; + acc *= (uintmax_t)base; + acc += c; + } + } + if (neg && any > 0) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/sdk/tlibc/string/bcmp.c b/sdk/tlibc/string/bcmp.c new file mode 100644 index 0000000000..79a2382aee --- /dev/null +++ b/sdk/tlibc/string/bcmp.c @@ -0,0 +1,51 @@ +/* $OpenBSD: bcmp.c,v 1.11 2015/08/31 02:53:57 guenther Exp $ */ + +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * bcmp -- vax cmpc3 instruction + */ +int +bcmp(const void *b1, const void *b2, size_t length) +{ + char *p1, *p2; + + if (length == 0) + return (0); + p1 = (char *)b1; + p2 = (char *)b2; + do + if (*p1++ != *p2++) + return (1); + while (--length); + return (0); +} diff --git a/sdk/tlibc/string/bcopy.c b/sdk/tlibc/string/bcopy.c new file mode 100644 index 0000000000..d9195c1fdf --- /dev/null +++ b/sdk/tlibc/string/bcopy.c @@ -0,0 +1,112 @@ +/* $OpenBSD: bcopy.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * sizeof(word) MUST BE A POWER OF TWO + * SO THAT wmask BELOW IS ALL ONES + */ +typedef long word; /* "word" used for optimal copy speed */ + +#define wsize sizeof(word) +#define wmask (wsize - 1) + +/* + * Copy a block of memory, handling overlap. + */ +void +bcopy(const void *src0, void *dst0, size_t length) +{ + char *dst = dst0; + const char *src = src0; + size_t t; + + if (length == 0 || dst == src) /* nothing to do */ + goto done; + + /* + * Macros: loop-t-times; and loop-t-times, t>0 + */ +#define TLOOP(s) if (t) TLOOP1(s) +#define TLOOP1(s) do { s; } while (--t) + + if ((unsigned long)dst < (unsigned long)src) { + /* + * Copy forward. + */ + t = (long)src; /* only need low bits */ + if ((t | (long)dst) & wmask) { + /* + * Try to align operands. This cannot be done + * unless the low bits match. + */ + if ((t ^ (long)dst) & wmask || length < wsize) + t = length; + else + t = wsize - (t & wmask); + length -= t; + TLOOP1(*dst++ = *src++); + } + /* + * Copy whole words, then mop up any trailing bytes. + */ + t = length / wsize; + TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); + t = length & wmask; + TLOOP(*dst++ = *src++); + } else { + /* + * Copy backwards. Otherwise essentially the same. + * Alignment works as before, except that it takes + * (t&wmask) bytes to align, not wsize-(t&wmask). + */ + src += length; + dst += length; + t = (long)src; + if ((t | (long)dst) & wmask) { + if ((t ^ (long)dst) & wmask || length <= wsize) + t = length; + else + t &= wmask; + length -= t; + TLOOP1(*--dst = *--src); + } + t = length / wsize; + TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); + t = length & wmask; + TLOOP(*--dst = *--src); + } +done: + return; +} diff --git a/sdk/tlibc/string/bzero.c b/sdk/tlibc/string/bzero.c new file mode 100644 index 0000000000..79bfcf3443 --- /dev/null +++ b/sdk/tlibc/string/bzero.c @@ -0,0 +1,44 @@ +/* $OpenBSD: bzero.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ + +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * bzero -- vax movc5 instruction + */ +void +bzero(void *b, size_t length) +{ + char *p; + + for (p =(char *) b; length--;) + *p++ = '\0'; +} diff --git a/sdk/tlibc/string/consttime_memequal.c b/sdk/tlibc/string/consttime_memequal.c new file mode 100644 index 0000000000..d10a5092dc --- /dev/null +++ b/sdk/tlibc/string/consttime_memequal.c @@ -0,0 +1,29 @@ +/* $NetBSD: consttime_memequal.c,v 1.6 2015/03/18 20:11:35 riastradh Exp $ */ + +/* + * Written by Matthias Drochner . + * Public domain. + */ + +#include + +int +consttime_memequal(const void *b1, const void *b2, size_t len) +{ + const unsigned char *c1 = b1, *c2 = b2; + unsigned int res = 0; + + while (len--) + res |= *c1++ ^ *c2++; + + /* + * Map 0 to 1 and [1, 256) to 0 using only constant-time + * arithmetic. + * + * This is not simply `!res' because although many CPUs support + * branchless conditional moves and many compilers will take + * advantage of them, certain compilers generate branches on + * certain CPUs for `!res'. + */ + return (1 & ((res - 1) >> 8)); +} diff --git a/sdk/tlibc/string/ffs.c b/sdk/tlibc/string/ffs.c new file mode 100644 index 0000000000..794d4028a3 --- /dev/null +++ b/sdk/tlibc/string/ffs.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +/* + * Find first set bit in an integer + */ +int ffs(int mask) +{ + return __builtin_ffs(mask); +} diff --git a/sdk/tlibc/string/ffsl.c b/sdk/tlibc/string/ffsl.c new file mode 100644 index 0000000000..0ae742fbff --- /dev/null +++ b/sdk/tlibc/string/ffsl.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +/* + * Find first set bit in Long + */ +int ffsl(long int mask) +{ + return __builtin_ffsl(mask); +} diff --git a/sdk/tlibc/string/ffsll.c b/sdk/tlibc/string/ffsll.c new file mode 100644 index 0000000000..443ff895a4 --- /dev/null +++ b/sdk/tlibc/string/ffsll.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +/* + * Find first set bit in LongLong + */ +int ffsll(long long int mask) +{ + return __builtin_ffsll(mask); +} diff --git a/sdk/tlibc/string/index.c b/sdk/tlibc/string/index.c new file mode 100644 index 0000000000..ff57250b17 --- /dev/null +++ b/sdk/tlibc/string/index.c @@ -0,0 +1,38 @@ +/* $OpenBSD: index.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +char * +index(const char *p, int ch) +{ + return strchr(p, ch); +} + diff --git a/sdk/tlibc/string/memchr.c b/sdk/tlibc/string/memchr.c new file mode 100644 index 0000000000..e97652b12d --- /dev/null +++ b/sdk/tlibc/string/memchr.c @@ -0,0 +1,48 @@ +/* $OpenBSD: memchr.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +void * +memchr(const void *s, int c, size_t n) +{ + if (n != 0) { + const unsigned char *p = (const unsigned char *)s; + + do { + if (*p++ == (unsigned char)c) + return ((void *)(p - 1)); + } while (--n != 0); + } + return (NULL); +} diff --git a/sdk/tlibc/string/memcmp.c b/sdk/tlibc/string/memcmp.c new file mode 100644 index 0000000000..3e9fc2536c --- /dev/null +++ b/sdk/tlibc/string/memcmp.c @@ -0,0 +1,59 @@ +/* $OpenBSD: memcmp.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +/* + * Compare memory regions. + */ +int +__memcmp(const void *s1, const void *s2, size_t n) +{ + if (n != 0) { + const unsigned char *p1 = (const unsigned char *)s1; + const unsigned char *p2 = (const unsigned char *)s2; + + do { + if (*p1++ != *p2++) + return (*--p1 - *--p2); + } while (--n != 0); + } + return (0); +} + +int +memcmp(const void *s1, const void *s2, size_t n) +{ + return __memcmp(s1, s2, n); +} diff --git a/sdk/tlibc/string/memcpy.c b/sdk/tlibc/string/memcpy.c new file mode 100644 index 0000000000..758ddd25f9 --- /dev/null +++ b/sdk/tlibc/string/memcpy.c @@ -0,0 +1,105 @@ +/* $OpenBSD: memcpy.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +/* + * sizeof(word) MUST BE A POWER OF TWO + * SO THAT wmask BELOW IS ALL ONES + */ +typedef long word; /* "word" used for optimal copy speed */ + +#define wsize sizeof(word) +#define wmask (wsize - 1) + + +/* + * Copy a block of memory, not handling overlap. + */ +void * +__memcpy(void *dst0, const void *src0, size_t length) +{ + char *dst = (char *)dst0; + const char *src = (const char *)src0; + size_t t; + + if (length == 0 || dst == src) /* nothing to do */ + goto done; + + if ((dst < src && dst + length > src) || + (src < dst && src + length > dst)) { + /* backwards memcpy */ + abort(); + } + + /* + * Macros: loop-t-times; and loop-t-times, t>0 + */ +#define TLOOP(s) if (t) TLOOP1(s) +#define TLOOP1(s) do { s; } while (--t) + + /* + * Copy forward. + */ + t = (long)src; /* only need low bits */ + if ((t | (long)dst) & wmask) { + /* + * Try to align operands. This cannot be done + * unless the low bits match. + */ + if ((t ^ (long)dst) & wmask || length < wsize) + t = length; + else + t = wsize - (t & wmask); + length -= t; + TLOOP1(*dst++ = *src++); + } + /* + * Copy whole words, then mop up any trailing bytes. + */ + t = length / wsize; + TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); + t = length & wmask; + TLOOP(*dst++ = *src++); +done: + return (dst0); +} + + +void * +memcpy(void *dst0, const void *src0, size_t length) +{ + return __memcpy(dst0, src0, length); +} diff --git a/sdk/tlibc/string/memmove.c b/sdk/tlibc/string/memmove.c new file mode 100644 index 0000000000..c08e13c93f --- /dev/null +++ b/sdk/tlibc/string/memmove.c @@ -0,0 +1,112 @@ +/* $OpenBSD: memmove.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * sizeof(word) MUST BE A POWER OF TWO + * SO THAT wmask BELOW IS ALL ONES + */ +typedef long word; /* "word" used for optimal copy speed */ + +#define wsize sizeof(word) +#define wmask (wsize - 1) + +/* + * Copy a block of memory, handling overlap. + */ +void * +memmove(void *dst0, const void *src0, size_t length) +{ + char *dst = dst0; + const char *src = src0; + size_t t; + + if (length == 0 || dst == src) /* nothing to do */ + goto done; + + /* + * Macros: loop-t-times; and loop-t-times, t>0 + */ +#define TLOOP(s) if (t) TLOOP1(s) +#define TLOOP1(s) do { s; } while (--t) + + if ((unsigned long)dst < (unsigned long)src) { + /* + * Copy forward. + */ + t = (long)src; /* only need low bits */ + if ((t | (long)dst) & wmask) { + /* + * Try to align operands. This cannot be done + * unless the low bits match. + */ + if ((t ^ (long)dst) & wmask || length < wsize) + t = length; + else + t = wsize - (t & wmask); + length -= t; + TLOOP1(*dst++ = *src++); + } + /* + * Copy whole words, then mop up any trailing bytes. + */ + t = length / wsize; + TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); + t = length & wmask; + TLOOP(*dst++ = *src++); + } else { + /* + * Copy backwards. Otherwise essentially the same. + * Alignment works as before, except that it takes + * (t&wmask) bytes to align, not wsize-(t&wmask). + */ + src += length; + dst += length; + t = (long)src; + if ((t | (long)dst) & wmask) { + if ((t ^ (long)dst) & wmask || length <= wsize) + t = length; + else + t &= wmask; + length -= t; + TLOOP1(*--dst = *--src); + } + t = length / wsize; + TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); + t = length & wmask; + TLOOP(*--dst = *--src); + } +done: + return (dst0); +} diff --git a/sdk/tlibc/string/mempcpy.c b/sdk/tlibc/string/mempcpy.c new file mode 100644 index 0000000000..6d2568630f --- /dev/null +++ b/sdk/tlibc/string/mempcpy.c @@ -0,0 +1,2 @@ +#define MEMPCPY +#include "./memcpy.c" diff --git a/sdk/tlibc/string/memset.c b/sdk/tlibc/string/memset.c new file mode 100644 index 0000000000..e5f3f421c5 --- /dev/null +++ b/sdk/tlibc/string/memset.c @@ -0,0 +1,56 @@ +/* $OpenBSD: memset.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +void * +__memset(void *dst, int c, size_t n) +{ + if (n != 0) { + unsigned char *d = dst; + + do + *d++ = (unsigned char)c; + while (--n != 0); + } + return (dst); + + +} + +void * +memset(void *dst, int c, size_t n) +{ + return __memset(dst, c, n); +} diff --git a/sdk/tlibc/string/memset_s.c b/sdk/tlibc/string/memset_s.c new file mode 100644 index 0000000000..4fc1333e1a --- /dev/null +++ b/sdk/tlibc/string/memset_s.c @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Alan Barrett + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ISO/IEC 9899:2011 section K.3.7.4.1 The memset_s function + */ + +#include + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include + +/* + * __memset_vp is a volatile pointer to a function. + * It is initialised to point to memset, and should never be changed. + */ +static void * (* const volatile __memset_vp)(void *, int, size_t) + = (memset); + +#undef memset_s /* in case it was defined as a macro */ + +errno_t +memset_s(void *s, size_t smax, int c, size_t n) +{ + errno_t err = 0; + + if (s == NULL) { + err = EINVAL; + goto out; + } + if (smax > SIZE_MAX) { + err = E2BIG; + goto out; + } + if (n > SIZE_MAX) { + err = E2BIG; + n = smax; + } + if (n > smax) { + err = EOVERFLOW; + n = smax; + } + + /* Calling through a volatile pointer should never be optimised away. */ + (*__memset_vp)(s, c, n); + + out: + if (err == 0) + return 0; + else { + errno = err; + /* XXX call runtime-constraint handler */ + return err; + } +} \ No newline at end of file diff --git a/sdk/tlibc/string/rindex.c b/sdk/tlibc/string/rindex.c new file mode 100644 index 0000000000..bb8cb061d4 --- /dev/null +++ b/sdk/tlibc/string/rindex.c @@ -0,0 +1,37 @@ +/* $OpenBSD: rindex.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +char * +rindex(const char *p, int ch) +{ + return strrchr(p, ch); +} diff --git a/sdk/tlibc/string/se_string_init.c b/sdk/tlibc/string/se_string_init.c new file mode 100644 index 0000000000..f5d62380fc --- /dev/null +++ b/sdk/tlibc/string/se_string_init.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "stdint.h" +#include "se_cpu_feature.h" +#include "se_cdefs.h" + +// add a version to tlibc. +SGX_ACCESS_VERSION(tstdc, 1) + +int sgx_init_string_lib(uint64_t cpu_feature_indicator) +{ + (void)cpu_feature_indicator; + return 0; +} diff --git a/sdk/tlibc/string/stpncpy.c b/sdk/tlibc/string/stpncpy.c new file mode 100644 index 0000000000..d56a27b881 --- /dev/null +++ b/sdk/tlibc/string/stpncpy.c @@ -0,0 +1,56 @@ +/* $OpenBSD: stpncpy.c,v 1.2 2012/07/11 10:44:59 naddy Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +char * +stpncpy(char *dst, const char *src, size_t n) +{ + if (n != 0) { + char *d = dst; + const char *s = src; + + dst = &dst[n]; + do { + if ((*d++ = *s++) == 0) { + dst = d - 1; + /* NUL pad the remaining n-1 bytes */ + while (--n != 0) + *d++ = 0; + break; + } + } while (--n != 0); + } + return (dst); +} diff --git a/sdk/tlibc/string/strcasecmp.c b/sdk/tlibc/string/strcasecmp.c new file mode 100644 index 0000000000..08eb3739d0 --- /dev/null +++ b/sdk/tlibc/string/strcasecmp.c @@ -0,0 +1,105 @@ +/* $OpenBSD: strcasecmp.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */ + +/* + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +typedef unsigned char u_char; + +/* + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ +static const u_char charmap[] = { + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', + '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', + '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', + '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', +}; + +int +strcasecmp(const char *s1, const char *s2) +{ + const u_char *cm = charmap; + const u_char *us1 = (const u_char *)s1; + const u_char *us2 = (const u_char *)s2; + + while (cm[*us1] == cm[*us2++]) + if (*us1++ == '\0') + return (0); + return (cm[*us1] - cm[*--us2]); +} + +int +strncasecmp(const char *s1, const char *s2, size_t n) +{ + if (n != 0) { + const u_char *cm = charmap; + const u_char *us1 = (const u_char *)s1; + const u_char *us2 = (const u_char *)s2; + + do { + if (cm[*us1] != cm[*us2++]) + return (cm[*us1] - cm[*--us2]); + if (*us1++ == '\0') + break; + } while (--n != 0); + } + return (0); +} diff --git a/sdk/tlibc/string/strchr.c b/sdk/tlibc/string/strchr.c new file mode 100644 index 0000000000..531e0ffd87 --- /dev/null +++ b/sdk/tlibc/string/strchr.c @@ -0,0 +1,48 @@ +/* $OpenBSD: strchr.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +__weak_alias(index, strchr); + + + +char * +strchr(const char *p, int ch) +{ + char c = ch; + for (;; ++p) { + if (*p == c) + return((char *)p); + if (!*p) + return ((char *)NULL); + } + /* NOTREACHED */ +} diff --git a/sdk/tlibc/string/strcmp.c b/sdk/tlibc/string/strcmp.c new file mode 100644 index 0000000000..5fba8a9d97 --- /dev/null +++ b/sdk/tlibc/string/strcmp.c @@ -0,0 +1,48 @@ +/* $OpenBSD: strcmp.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +/* + * Compare strings. + */ +int +strcmp(const char *s1, const char *s2) +{ + while (*s1 == *s2++) + if (*s1++ == 0) + return (0); + return (*(const unsigned char *)s1 - *(const unsigned char *)--s2); +} diff --git a/sdk/tlibc/string/strcoll.c b/sdk/tlibc/string/strcoll.c new file mode 100644 index 0000000000..2569f5074b --- /dev/null +++ b/sdk/tlibc/string/strcoll.c @@ -0,0 +1,44 @@ +/* $OpenBSD: strcoll.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * Compare strings according to LC_COLLATE category of current locale. + */ +int +strcoll(const char *s1, const char *s2) +{ + /* LC_COLLATE is unimplemented, hence always "C" */ + return (strcmp(s1, s2)); +} diff --git a/sdk/tlibc/string/strcspn.c b/sdk/tlibc/string/strcspn.c new file mode 100644 index 0000000000..08a1065f77 --- /dev/null +++ b/sdk/tlibc/string/strcspn.c @@ -0,0 +1,65 @@ +/* $OpenBSD: strcspn.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +/* + * Span the complement of string s2. + */ +size_t +__strcspn(const char *s1, const char *s2) +{ + const char *p, *spanp; + char c, sc; + + /* + * Stop as soon as we find any character from s2. Note that there + * must be a NUL in s2; it suffices to stop when we find that, too. + */ + for (p = s1;;) { + c = *p++; + spanp = s2; + do { + if ((sc = *spanp++) == c) + return (p - 1 - s1); + } while (sc != 0); + } + /* NOTREACHED */ +} + +size_t +strcspn(const char *s1, const char *s2) +{ + return __strcspn(s1, s2); +} diff --git a/sdk/tlibc/string/strerror.c b/sdk/tlibc/string/strerror.c new file mode 100644 index 0000000000..a9339f5da7 --- /dev/null +++ b/sdk/tlibc/string/strerror.c @@ -0,0 +1,44 @@ +/* $OpenBSD: strerror.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + + +#define NL_TEXTMAX 2048 + +char * +strerror(int num) +{ + static char _TLIBC_THREAD_ buf[NL_TEXTMAX]; + + (void)strerror_r(num, buf, sizeof(buf)); + return (buf); +} diff --git a/sdk/tlibc/string/strerror_r.c b/sdk/tlibc/string/strerror_r.c new file mode 100644 index 0000000000..0c5f3cbe05 --- /dev/null +++ b/sdk/tlibc/string/strerror_r.c @@ -0,0 +1,100 @@ +/* $OpenBSD: strerror_r.c,v 1.8 2013/06/01 21:26:18 stsp Exp $ */ +/* Public Domain */ + +#include +#include +#include +extern int sys_nerr; +extern const char *const sys_errlist[]; + +static size_t +__digits10(unsigned int num) +{ + size_t i = 0; + + do { + num /= 10; + i++; + } while (num != 0); + + return i; +} + +static int +__itoa(int num, int sign, char *buffer, size_t start, size_t end) +{ + size_t pos; + unsigned int a; + int neg; + + if (sign && num < 0) { + a = -num; + neg = 1; + } + else { + a = num; + neg = 0; + } + + pos = start + __digits10(a); + if (neg) + pos++; + + if (pos < end) + buffer[pos] = '\0'; + else + return ERANGE; + pos--; + do { + buffer[pos] = (a % 10) + '0'; + pos--; + a /= 10; + } while (a != 0); + if (neg) + buffer[pos] = '-'; + return 0; +} + + +static int +__num2string(int num, int sign, int setid, char *buf, size_t buflen, + const char *const list[], size_t max, const char *def) +{ + int ret = 0; + size_t len; + + (void *)&setid; + if (0 <= num && num < max) { + len = strlcpy(buf, list[num], buflen); + if (len >= buflen) + ret = ERANGE; + } else { + len = strlcpy(buf, def, buflen); + if (len >= buflen) + ret = ERANGE; + else { + ret = __itoa(num, sign, buf, len, buflen); + if (ret == 0) + ret = EINVAL; + } + } + + return ret; +} + +#define UPREFIX "Unknown error: " + +int +strerror_r(int errnum, char *strerrbuf, size_t buflen) +{ + int save_errno; + int ret_errno; + + save_errno = errno; + + ret_errno = __num2string(errnum, 1, 1, strerrbuf, buflen, + sys_errlist, sys_nerr, UPREFIX); + + errno = ret_errno ? ret_errno : save_errno; + return (ret_errno); +} diff --git a/sdk/tlibc/string/strlcpy.c b/sdk/tlibc/string/strlcpy.c new file mode 100644 index 0000000000..630167489b --- /dev/null +++ b/sdk/tlibc/string/strlcpy.c @@ -0,0 +1,50 @@ +/* $OpenBSD: strlcpy.c,v 1.13 2015/08/31 02:53:57 guenther Exp $ */ + +/* + * Copyright (c) 1998, 2015 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +/* + * Copy string src to buffer dst of size dsize. At most dsize-1 + * chars will be copied. Always NUL terminates (unless dsize == 0). + * Returns strlen(src); if retval >= dsize, truncation occurred. + */ +size_t +strlcpy(char *dst, const char *src, size_t dsize) +{ + const char *osrc = src; + size_t nleft = dsize; + + /* Copy as many bytes as will fit. */ + if (nleft != 0) { + while (--nleft != 0) { + if ((*dst++ = *src++) == '\0') + break; + } + } + + /* Not enough room in dst, add NUL and traverse rest of src. */ + if (nleft == 0) { + if (dsize != 0) + *dst = '\0'; /* NUL-terminate dst */ + while (*src++) + ; + } + + return(src - osrc - 1); /* count does not include NUL */ +} diff --git a/sdk/tlibc/string/strlen.c b/sdk/tlibc/string/strlen.c new file mode 100644 index 0000000000..a100ff3b4c --- /dev/null +++ b/sdk/tlibc/string/strlen.c @@ -0,0 +1,44 @@ +/* $OpenBSD: strlen.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +size_t +strlen(const char *str) +{ + const char *s; + + for (s = str; *s; ++s) + ; + return (s - str); +} + diff --git a/sdk/tlibc/string/strncat.c b/sdk/tlibc/string/strncat.c new file mode 100644 index 0000000000..a74ae68929 --- /dev/null +++ b/sdk/tlibc/string/strncat.c @@ -0,0 +1,59 @@ +/* $OpenBSD: strncat.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes + * are written at dst (at most n+1 bytes being appended). Return dst. + */ + + +char * +strncat(char *dst, const char *src, size_t n) +{ + if (n != 0) { + char *d = dst; + const char *s = src; + + while (*d != 0) + d++; + do { + if ((*d = *s++) == 0) + break; + d++; + } while (--n != 0); + *d = 0; + } + return (dst); +} diff --git a/sdk/tlibc/string/strncmp.c b/sdk/tlibc/string/strncmp.c new file mode 100644 index 0000000000..b3c88858af --- /dev/null +++ b/sdk/tlibc/string/strncmp.c @@ -0,0 +1,47 @@ +/* $OpenBSD: strncmp.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +int +strncmp(const char *s1, const char *s2, size_t n) +{ + if (n == 0) + return (0); + do { + if (*s1 != *s2++) + return (*(unsigned char *)s1 - *(unsigned char *)--s2); + if (*s1++ == 0) + break; + } while (--n != 0); + return (0); +} diff --git a/sdk/tlibc/string/strncpy.c b/sdk/tlibc/string/strncpy.c new file mode 100644 index 0000000000..e47462b5fa --- /dev/null +++ b/sdk/tlibc/string/strncpy.c @@ -0,0 +1,60 @@ +/* $OpenBSD: strncpy.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * Copy src to dst, truncating or null-padding to always copy n bytes. + * Return dst. + */ + + +char * +strncpy(char *dst, const char *src, size_t n) +{ + if (n != 0) { + char *d = dst; + const char *s = src; + + do { + if ((*d++ = *s++) == 0) { + /* NUL pad the remaining n-1 bytes */ + while (--n != 0) + *d++ = 0; + break; + } + } while (--n != 0); + } + return (dst); +} diff --git a/sdk/tlibc/string/strndup.c b/sdk/tlibc/string/strndup.c new file mode 100644 index 0000000000..f43ba6592f --- /dev/null +++ b/sdk/tlibc/string/strndup.c @@ -0,0 +1,39 @@ +/* $OpenBSD: strndup.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */ + +/* + * Copyright (c) 2010 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#include + +char * +strndup(const char *str, size_t maxlen) +{ + char *copy; + size_t len; + + len = strnlen(str, maxlen); + copy = malloc(len + 1); + if (copy != NULL) { + (void)memcpy(copy, str, len); + copy[len] = '\0'; + } + + return copy; +} diff --git a/sdk/tlibc/string/strnlen.c b/sdk/tlibc/string/strnlen.c new file mode 100644 index 0000000000..6aca3c6b79 --- /dev/null +++ b/sdk/tlibc/string/strnlen.c @@ -0,0 +1,32 @@ +/* $OpenBSD: strnlen.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ + +/* + * Copyright (c) 2010 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include + +size_t +strnlen(const char *str, size_t maxlen) +{ + const char *cp; + + for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) + ; + + return (size_t)(cp - str); +} diff --git a/sdk/tlibc/string/strpbrk.c b/sdk/tlibc/string/strpbrk.c new file mode 100644 index 0000000000..f6d3a22b4d --- /dev/null +++ b/sdk/tlibc/string/strpbrk.c @@ -0,0 +1,56 @@ +/* $OpenBSD: strpbrk.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * Find the first occurrence in s1 of a character in s2 (excluding NUL). + */ +char * +__strpbrk(const char *s1, const char *s2) +{ + const char *scanp; + int c, sc; + + while ((c = *s1++) != 0) { + for (scanp = s2; (sc = *scanp++) != 0;) + if (sc == c) + return ((char *)(s1 - 1)); + } + return (NULL); +} + + +char * +strpbrk(const char *s1, const char *s2) +{ + return __strpbrk(s1, s2); +} + diff --git a/sdk/tlibc/string/strrchr.c b/sdk/tlibc/string/strrchr.c new file mode 100644 index 0000000000..71b5eec708 --- /dev/null +++ b/sdk/tlibc/string/strrchr.c @@ -0,0 +1,50 @@ +/* $OpenBSD: strrchr.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include + + + +__weak_alias(rindex, strrchr); + +char * +strrchr(const char *p, int ch) +{ + char *save; + + for (save = NULL;; ++p) { + if (*p == ch) + save = (char *)p; + if (!*p) + return(save); + } + /* NOTREACHED */ +} diff --git a/sdk/tlibc/string/strspn.c b/sdk/tlibc/string/strspn.c new file mode 100644 index 0000000000..45b95ba2f5 --- /dev/null +++ b/sdk/tlibc/string/strspn.c @@ -0,0 +1,59 @@ +/* $OpenBSD: strspn.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + + +/* + * Span the string s2 (skip characters that are in s2). + */ +size_t +__strspn(const char *s1, const char *s2) +{ + const char *p = s1, *spanp; + char c, sc; + + /* + * Skip any characters in s2, excluding the terminating \0. + */ +cont: + c = *p++; + for (spanp = s2; (sc = *spanp++) != 0;) + if (sc == c) + goto cont; + return (p - 1 - s1); +} + + +size_t +strspn(const char *s1, const char *s2) +{ + return __strspn(s1, s2); +} diff --git a/sdk/tlibc/string/strstr.c b/sdk/tlibc/string/strstr.c new file mode 100644 index 0000000000..ff6939ace8 --- /dev/null +++ b/sdk/tlibc/string/strstr.c @@ -0,0 +1,56 @@ +/* $OpenBSD: strstr.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * Find the first occurrence of find in s. + */ +char * +strstr(const char *s, const char *find) +{ + char c, sc; + size_t len; + + if ((c = *find++) != 0) { + len = strlen(find); + do { + do { + if ((sc = *s++) == 0) + return (NULL); + } while (sc != c); + } while (strncmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} diff --git a/sdk/tlibc/string/strtok.c b/sdk/tlibc/string/strtok.c new file mode 100644 index 0000000000..abc364ac39 --- /dev/null +++ b/sdk/tlibc/string/strtok.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +char * +strtok_r(char *s, const char *delim, char **last) +{ + const char *spanp; + int c, sc; + char *tok; + + + if (s == NULL && (s = *last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ +cont: + c = *s++; + for (spanp = delim; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } + + if (c == 0) { /* no non-delimiter characters */ + *last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = '\0'; + *last = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} + + +char * +strtok(char *s, const char *delim) +{ + static _TLIBC_THREAD_ char *last = NULL; + return strtok_r(s, delim, &last); +} diff --git a/sdk/tlibc/string/strxfrm.c b/sdk/tlibc/string/strxfrm.c new file mode 100644 index 0000000000..c747a36d4e --- /dev/null +++ b/sdk/tlibc/string/strxfrm.c @@ -0,0 +1,51 @@ +/* $OpenBSD: strxfrm.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +/* + * Transform src, storing the result in dst, such that + * strcmp() on transformed strings returns what strcoll() + * on the original untransformed strings would return. + */ +size_t +strxfrm(char *dst, const char *src, size_t n) +{ + + /* + * Since locales are unimplemented, this is just a copy. + */ + if (n == 0) + return (strlen(src)); + return (strlcpy(dst, src, n)); +} diff --git a/sdk/tlibc/string/wcschr.c b/sdk/tlibc/string/wcschr.c new file mode 100644 index 0000000000..48d864b059 --- /dev/null +++ b/sdk/tlibc/string/wcschr.c @@ -0,0 +1,49 @@ +/* $OpenBSD: wcschr.c,v 1.6 2015/10/01 02:32:07 guenther Exp $ */ +/* $NetBSD: wcschr.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcschr.c,v 1.2 2000/12/21 05:07:25 itojun Exp + */ + +#include + +wchar_t * +wcschr(const wchar_t *s, wchar_t c) +{ + const wchar_t *p; + + p = s; + for (;;) { + if (*p == c) { + return (wchar_t *)p; + } + if (!*p) + return NULL; + p++; + } + /* NOTREACHED */ +} diff --git a/sdk/tlibc/string/wcscmp.c b/sdk/tlibc/string/wcscmp.c new file mode 100644 index 0000000000..bf76aac25c --- /dev/null +++ b/sdk/tlibc/string/wcscmp.c @@ -0,0 +1,51 @@ +/* $OpenBSD: wcscmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wcscmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include "locale/runetype.h" + +/* + * Compare strings. + */ +int +wcscmp(const wchar_t *s1, const wchar_t *s2) +{ + + while (*s1 == *s2++) + if (*s1++ == 0) + return (0); + /* XXX assumes wchar_t = int */ + return (*(const rune_t *)s1 - *(const rune_t *)--s2); +} diff --git a/sdk/tlibc/string/wcscspn.c b/sdk/tlibc/string/wcscspn.c new file mode 100644 index 0000000000..613360a00b --- /dev/null +++ b/sdk/tlibc/string/wcscspn.c @@ -0,0 +1,53 @@ +/* $OpenBSD: wcscspn.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wcscspn.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcscspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp + */ + +#include + +size_t +wcscspn(const wchar_t *s, const wchar_t *set) +{ + const wchar_t *p; + const wchar_t *q; + + p = s; + while (*p) { + q = set; + while (*q) { + if (*p == *q) + goto done; + q++; + } + p++; + } + +done: + return (p - s); +} diff --git a/sdk/tlibc/string/wcslcpy.c b/sdk/tlibc/string/wcslcpy.c new file mode 100644 index 0000000000..169971a94a --- /dev/null +++ b/sdk/tlibc/string/wcslcpy.c @@ -0,0 +1,50 @@ +/* $OpenBSD: wcslcpy.c,v 1.7 2015/09/12 16:23:14 guenther Exp $ */ + +/* + * Copyright (c) 1998, 2015 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +/* + * Copy string src to buffer dst of size dsize. At most dsize-1 + * chars will be copied. Always NUL terminates (unless dsize == 0). + * Returns wcslen(src); if retval >= dsize, truncation occurred. + */ +size_t +wcslcpy(wchar_t *dst, const wchar_t *src, size_t dsize) +{ + const wchar_t *osrc = src; + size_t nleft = dsize; + + /* Copy as many bytes as will fit. */ + if (nleft != 0) { + while (--nleft != 0) { + if ((*dst++ = *src++) == L'\0') + break; + } + } + + /* Not enough room in dst, add NUL and traverse rest of src. */ + if (nleft == 0) { + if (dsize != 0) + *dst = L'\0'; /* NUL-terminate dst */ + while (*src++) + ; + } + + return(src - osrc - 1); /* count does not include NUL */ +} diff --git a/sdk/tlibc/string/wcslen.c b/sdk/tlibc/string/wcslen.c new file mode 100644 index 0000000000..9484501e6e --- /dev/null +++ b/sdk/tlibc/string/wcslen.c @@ -0,0 +1,44 @@ +/* $OpenBSD: wcslen.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp + */ + +#include + +size_t +wcslen(const wchar_t *s) +{ + const wchar_t *p; + + p = s; + while (*p) + p++; + + return p - s; +} diff --git a/sdk/tlibc/string/wcsncat.c b/sdk/tlibc/string/wcsncat.c new file mode 100644 index 0000000000..869ba08576 --- /dev/null +++ b/sdk/tlibc/string/wcsncat.c @@ -0,0 +1,52 @@ +/* $OpenBSD: wcsncat.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wcsncat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp + */ + +#include + +wchar_t * +wcsncat(wchar_t *s1, const wchar_t *s2, size_t n) +{ + wchar_t *p; + wchar_t *q; + const wchar_t *r; + + p = s1; + while (*p) + p++; + q = p; + r = s2; + while (*r && n) { + *q++ = *r++; + n--; + } + *q = '\0'; + return s1; +} diff --git a/sdk/tlibc/string/wcsncmp.c b/sdk/tlibc/string/wcsncmp.c new file mode 100644 index 0000000000..1dbf737998 --- /dev/null +++ b/sdk/tlibc/string/wcsncmp.c @@ -0,0 +1,52 @@ +/* $OpenBSD: wcsncmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wcsncmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include "locale/runetype.h" + +int +wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n) +{ + + if (n == 0) + return (0); + do { + if (*s1 != *s2++) { + /* XXX assumes wchar_t = int */ + return (*(const rune_t *)s1 - + *(const rune_t *)--s2); + } + if (*s1++ == 0) + break; + } while (--n != 0); + return (0); +} diff --git a/sdk/tlibc/string/wcsncpy.c b/sdk/tlibc/string/wcsncpy.c new file mode 100644 index 0000000000..07a536d352 --- /dev/null +++ b/sdk/tlibc/string/wcsncpy.c @@ -0,0 +1,50 @@ +/* $OpenBSD: wcsncpy.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wcsncpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcsncpy.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp + */ + +#include + +wchar_t * +wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n) +{ + wchar_t *p; + + p = s1; + while (n && *s2) { + *p++ = *s2++; + n--; + } + while (n) { + *p++ = L'\0'; + n--; + } + + return s1; +} diff --git a/sdk/tlibc/string/wcspbrk.c b/sdk/tlibc/string/wcspbrk.c new file mode 100644 index 0000000000..f41b481084 --- /dev/null +++ b/sdk/tlibc/string/wcspbrk.c @@ -0,0 +1,52 @@ +/* $OpenBSD: wcspbrk.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ +/* $NetBSD: wcspbrk.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcspbrk.c,v 1.2 2000/12/21 05:07:25 itojun Exp + */ + +#include + +wchar_t * +wcspbrk(const wchar_t *s, const wchar_t *set) +{ + const wchar_t *p; + const wchar_t *q; + + p = s; + while (*p) { + q = set; + while (*q) { + if (*p == *q) { + return (wchar_t *)p; + } + q++; + } + p++; + } + return NULL; +} diff --git a/sdk/tlibc/string/wcsrchr.c b/sdk/tlibc/string/wcsrchr.c new file mode 100644 index 0000000000..6e484d1bec --- /dev/null +++ b/sdk/tlibc/string/wcsrchr.c @@ -0,0 +1,49 @@ +/* $OpenBSD: wcsrchr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ +/* $NetBSD: wcsrchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcsrchr.c,v 1.2 2000/12/21 05:07:25 itojun Exp + */ + +#include + +wchar_t * +wcsrchr(const wchar_t *s, wchar_t c) +{ + const wchar_t *p; + + p = s; + while (*p) + p++; + while (s <= p) { + if (*p == c) { + return (wchar_t *)p; + } + p--; + } + return NULL; +} diff --git a/sdk/tlibc/string/wcsspn.c b/sdk/tlibc/string/wcsspn.c new file mode 100644 index 0000000000..8b26960204 --- /dev/null +++ b/sdk/tlibc/string/wcsspn.c @@ -0,0 +1,55 @@ +/* $OpenBSD: wcsspn.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wcsspn.c,v 1.3 2001/09/21 16:09:15 yamt Exp $ */ + +/*- + * Copyright (c)1999,2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus: xpg4dl/FreeBSD/lib/libc/string/wcsspn.c,v 1.3 2001/09/21 16:06:43 yamt Exp $ + */ + +#include + +size_t +wcsspn(const wchar_t *s, const wchar_t *set) +{ + const wchar_t *p; + const wchar_t *q; + + p = s; + while (*p) { + q = set; + while (*q) { + if (*p == *q) + break; + q++; + } + if (!*q) + goto done; + p++; + } + +done: + return (p - s); +} diff --git a/sdk/tlibc/string/wcsstr.c b/sdk/tlibc/string/wcsstr.c new file mode 100644 index 0000000000..daabc8c213 --- /dev/null +++ b/sdk/tlibc/string/wcsstr.c @@ -0,0 +1,68 @@ +/* $OpenBSD: wcsstr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ +/* $NetBSD: wcsstr.c,v 1.3 2003/03/05 20:18:17 tshiozak Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wcsstr.c,v 1.2 2000/12/21 05:07:25 itojun Exp + */ + +#include + +wchar_t * +#ifdef WCSWCS +wcswcs(const wchar_t *big, const wchar_t *little) +#else +wcsstr(const wchar_t *big, const wchar_t *little) +#endif +{ + const wchar_t *p; + const wchar_t *q; + const wchar_t *r; + + if (!*little) { + return (wchar_t *)big; + } + if (wcslen(big) < wcslen(little)) + return NULL; + + p = big; + q = little; + while (*p) { + q = little; + r = p; + while (*q) { + if (*r != *q) + break; + q++; + r++; + } + if (!*q) { + return (wchar_t *)p; + } + p++; + } + return NULL; +} diff --git a/sdk/tlibc/string/wcstok.c b/sdk/tlibc/string/wcstok.c new file mode 100644 index 0000000000..bc1ac3e8cb --- /dev/null +++ b/sdk/tlibc/string/wcstok.c @@ -0,0 +1,93 @@ +/* $OpenBSD: wcstok.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ +/* $NetBSD: wcstok.c,v 1.3 2003/07/10 08:50:48 tshiozak Exp $ */ + +/*- + * Copyright (c) 1998 Softweyr LLC. All rights reserved. + * + * strtok_r, from Berkeley strtok + * Oct 13, 1998 by Wes Peters + * + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notices, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notices, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Softweyr LLC, the + * University of California, Berkeley, and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE + * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Original version ID: + * FreeBSD: src/lib/libc/string/wcstok.c,v 1.1 2002/09/07 08:16:57 tjr Exp + */ + +#include + +wchar_t * +wcstok(wchar_t * __restrict s, const wchar_t * __restrict delim, + wchar_t ** __restrict last) +{ + const wchar_t *spanp; + wchar_t c, sc; + wchar_t *tok; + + if (s == NULL && (s = *last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += wcsspn(s, delim), sort of). + */ +cont: + c = *s++; + for (spanp = delim; (sc = *spanp++) != L'\0';) { + if (c == sc) + goto cont; + } + + if (c == L'\0') { /* no non-delimiter characters */ + *last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += wcscspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == L'\0') + s = NULL; + else + s[-1] = L'\0'; + *last = s; + return (tok); + } + } while (sc != L'\0'); + } + /* NOTREACHED */ +} diff --git a/sdk/tlibc/string/wcswcs.c b/sdk/tlibc/string/wcswcs.c new file mode 100644 index 0000000000..bd35605547 --- /dev/null +++ b/sdk/tlibc/string/wcswcs.c @@ -0,0 +1,5 @@ +/* $OpenBSD: wcswcs.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ +/* $NetBSD: wcswcs.c,v 1.1 2003/03/05 20:18:17 tshiozak Exp $ */ + +#define WCSWCS +#include "wcsstr.c" diff --git a/sdk/tlibc/string/wmemchr.c b/sdk/tlibc/string/wmemchr.c new file mode 100644 index 0000000000..c4a910a1fa --- /dev/null +++ b/sdk/tlibc/string/wmemchr.c @@ -0,0 +1,46 @@ +/* $OpenBSD: wmemchr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ +/* $NetBSD: wmemchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wmemchr.c,v 1.2 2000/12/20 14:08:31 itojun Exp + */ + +#include + +wchar_t * +wmemchr(const wchar_t *s, wchar_t c, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + if (*s == c) { + return (wchar_t *)s; + } + s++; + } + return NULL; +} diff --git a/sdk/tlibc/string/wmemcmp.c b/sdk/tlibc/string/wmemcmp.c new file mode 100644 index 0000000000..d123d221d5 --- /dev/null +++ b/sdk/tlibc/string/wmemcmp.c @@ -0,0 +1,50 @@ +/* $OpenBSD: wmemcmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wmemcmp.c,v 1.3 2003/04/06 18:33:23 tshiozak Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wmemcmp.c,v 1.2 2000/12/20 14:08:31 itojun Exp + */ + +#include +#include "locale/runetype.h" + +int +wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + if (*s1 != *s2) { + /* wchar might be unsigned */ + return *(const rune_t *)s1 > + *(const rune_t *)s2 ? 1 : -1; + } + s1++; + s2++; + } + return 0; +} diff --git a/sdk/tlibc/string/wmemcpy.c b/sdk/tlibc/string/wmemcpy.c new file mode 100644 index 0000000000..9780f01a8a --- /dev/null +++ b/sdk/tlibc/string/wmemcpy.c @@ -0,0 +1,40 @@ +/* $OpenBSD: wmemcpy.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp + */ + +#include +#include + +wchar_t * +wmemcpy(wchar_t *d, const wchar_t *s, size_t n) +{ + + return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t)); +} diff --git a/sdk/tlibc/string/wmemmove.c b/sdk/tlibc/string/wmemmove.c new file mode 100644 index 0000000000..9056081764 --- /dev/null +++ b/sdk/tlibc/string/wmemmove.c @@ -0,0 +1,40 @@ +/* $OpenBSD: wmemmove.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wmemmove.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wmemmove.c,v 1.2 2000/12/20 14:08:31 itojun Exp + */ + +#include +#include + +wchar_t * +wmemmove(wchar_t *d, const wchar_t *s, size_t n) +{ + + return (wchar_t *)memmove(d, s, n * sizeof(wchar_t)); +} diff --git a/sdk/tlibc/string/wmemset.c b/sdk/tlibc/string/wmemset.c new file mode 100644 index 0000000000..0dda958670 --- /dev/null +++ b/sdk/tlibc/string/wmemset.c @@ -0,0 +1,46 @@ +/* $OpenBSD: wmemset.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ +/* $NetBSD: wmemset.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp + */ + +#include + +wchar_t * +wmemset(wchar_t *s, wchar_t c, size_t n) +{ + size_t i; + wchar_t *p; + + p = s; + for (i = 0; i < n; i++) { + *p = c; + p++; + } + return s; +} diff --git a/sdk/tlibc/time/asctime.c b/sdk/tlibc/time/asctime.c new file mode 100644 index 0000000000..fd3186ef98 --- /dev/null +++ b/sdk/tlibc/time/asctime.c @@ -0,0 +1,154 @@ +/* $OpenBSD: asctime.c,v 1.16 2010/08/23 22:35:34 millert Exp $ */ +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson. +*/ + +/* +** Avoid the temptation to punt entirely to strftime; +** the output of strftime is supposed to be locale specific +** whereas the output of asctime is supposed to be constant. +*/ + +/*LINTLIBRARY*/ + +#include "private.h" +#include "tzfile.h" +//#include "thread_private.h" +#include "internal/se_cdefs.h" + +/* +** Some systems only handle "%.2d"; others only handle "%02d"; +** "%02.2d" makes (most) everybody happy. +** At least some versions of gcc warn about the %02.2d; +** we conditionalize below to avoid the warning. +*/ +/* +** All years associated with 32-bit time_t values are exactly four digits long; +** some years associated with 64-bit time_t values are not. +** Vintage programs are coded for years that are always four digits long +** and may assume that the newline always lands in the same place. +** For years that are less than four digits, we pad the output with +** leading zeroes to get the newline in the traditional place. +** The -4 ensures that we get four characters of output even if +** we call a strftime variant that produces fewer characters for some years. +** The ISO C 1999 and POSIX 1003.1-2004 standards prohibit padding the year, +** but many implementations pad anyway; most likely the standards are buggy. +*/ +#ifdef __GNUC__ +#define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" +#else /* !defined __GNUC__ */ +#define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n" +#endif /* !defined __GNUC__ */ +/* +** For years that are more than four digits we put extra spaces before the year +** so that code trying to overwrite the newline won't end up overwriting +** a digit within a year and truncating the year (operating on the assumption +** that no output is better than wrong output). +*/ +#ifdef __GNUC__ +#define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n" +#else /* !defined __GNUC__ */ +#define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n" +#endif /* !defined __GNUC__ */ + +#define STD_ASCTIME_BUF_SIZE 26 +/* +** Big enough for something such as +** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n +** (two three-character abbreviations, five strings denoting integers, +** seven explicit spaces, two explicit colons, a newline, +** and a trailing ASCII nul). +** The values above are for systems where an int is 32 bits and are provided +** as an example; the define below calculates the maximum for the system at +** hand. +*/ +#define MAX_ASCTIME_BUF_SIZE (2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1) + +static char * +asctime3(timeptr, buf, bufsize) +register const struct tm * timeptr; +char * buf; +int bufsize; +{ + static const char wday_name[][4] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static const char mon_name[][4] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + register const char * wn; + register const char * mn; + char year[INT_STRLEN_MAXIMUM(int) + 2]; + int len; + + if (timeptr == NULL) { + errno = EINVAL; + strlcpy(buf, "??? ??? ?? ??:??:?? ????\n", bufsize); + return buf; + } + if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK) + wn = "???"; + else wn = wday_name[timeptr->tm_wday]; + if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR) + mn = "???"; + else mn = mon_name[timeptr->tm_mon]; + /* + ** Use strftime's %Y to generate the year, to avoid overflow problems + ** when computing timeptr->tm_year + TM_YEAR_BASE. + ** Assume that strftime is unaffected by other out-of-range members + ** (e.g., timeptr->tm_mday) when processing "%Y". + */ + (void) strftime(year, sizeof year, "%Y", timeptr); + len = snprintf(buf, bufsize, + ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B), + wn, mn, + timeptr->tm_mday, timeptr->tm_hour, + timeptr->tm_min, timeptr->tm_sec, + year); + if (len != -1 && len < bufsize) { + return buf; + } else { +#ifdef EOVERFLOW + errno = EOVERFLOW; +#else /* !defined EOVERFLOW */ + errno = EINVAL; +#endif /* !defined EOVERFLOW */ + return NULL; + } +} + +/* +** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition. +*/ + +/* + ** Enable asctime_r implementation at Windows platform for + ** sample code needs this implementation at Windows platform + */ +//#ifdef __GNUC__ /* Not for Windows */ +char * +asctime_r(timeptr, buf) +register const struct tm * timeptr; +char * buf; +{ + /* + ** P1003 8.3.5.2 says that asctime_r() can only assume at most + ** a 26 byte buffer. + */ + return asctime3(timeptr, buf, STD_ASCTIME_BUF_SIZE); +} +//#endif + +/* +** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition. +*/ + +char * +asctime(timeptr) +const struct tm * timeptr; +{ + static _TLIBC_THREAD_ char result[MAX_ASCTIME_BUF_SIZE]; + return asctime3(timeptr, result, (int)sizeof(result)); +} diff --git a/sdk/tlibc/time/difftime.c b/sdk/tlibc/time/difftime.c new file mode 100644 index 0000000000..8521a60110 --- /dev/null +++ b/sdk/tlibc/time/difftime.c @@ -0,0 +1,60 @@ +/* $OpenBSD: difftime.c,v 1.9 2005/08/08 08:05:38 espie Exp $ */ +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson. +*/ + +/*LINTLIBRARY*/ + +#include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */ + +double +difftime(time1, time0) +const time_t time1; +const time_t time0; +{ + /* + ** If (sizeof (double) > sizeof (time_t)) simply convert and subtract + ** (assuming that the larger type has more precision). + ** This is the common real-world case circa 2004. + */ + if (sizeof (double) > sizeof (time_t)) + return (double) time1 - (double) time0; + if (!TYPE_INTEGRAL(time_t)) { + /* + ** time_t is floating. + */ + return time1 - time0; + } + if (!TYPE_SIGNED(time_t)) { + /* + ** time_t is integral and unsigned. + ** The difference of two unsigned values can't overflow + ** if the minuend is greater than or equal to the subtrahend. + */ + if (time1 >= time0) + return time1 - time0; + else return -((double) (time0 - time1)); + } + /* + ** time_t is integral and signed. + ** Handle cases where both time1 and time0 have the same sign + ** (meaning that their difference cannot overflow). + */ + if ((time1 < 0) == (time0 < 0)) + return time1 - time0; + /* + ** time1 and time0 have opposite signs. + ** Punt if unsigned long is too narrow. + */ + if (sizeof (unsigned long) < sizeof (time_t)) + return (double) time1 - (double) time0; + /* + ** Stay calm...decent optimizers will eliminate the complexity below. + */ + if (time1 >= 0 /* && time0 < 0 */) + return (unsigned long) time1 + + (unsigned long) (-(time0 + 1)) + 1; + return -(double) ((unsigned long) time0 + + (unsigned long) (-(time1 + 1)) + 1); +} diff --git a/sdk/tlibc/time/private.h b/sdk/tlibc/time/private.h new file mode 100644 index 0000000000..846063e5bd --- /dev/null +++ b/sdk/tlibc/time/private.h @@ -0,0 +1,65 @@ +/* $OpenBSD: private.h,v 1.25 2012/09/13 11:14:20 millert Exp $ */ +#ifndef PRIVATE_H + +#define PRIVATE_H + +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson. +*/ + +/* +** Nested includes +*/ + +#include "sys/types.h" /* for time_t */ +#include "stdio.h" +#include "errno.h" +#include "string.h" +#include "limits.h" /* for CHAR_BIT et al. */ +#include "time.h" + +/* +** Finally, some convenience items. +*/ + +#ifndef TRUE +#define TRUE 1 +#endif /* !defined TRUE */ + +#ifndef FALSE +#define FALSE 0 +#endif /* !defined FALSE */ + +#ifndef TYPE_BIT +#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) +#endif /* !defined TYPE_BIT */ + +#ifndef TYPE_SIGNED +#define TYPE_SIGNED(type) (((type) -1) < 0) +#endif /* !defined TYPE_SIGNED */ + +/* +** Since the definition of TYPE_INTEGRAL contains floating point numbers, +** it cannot be used in preprocessor directives. +*/ + +#ifndef TYPE_INTEGRAL +#define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5) +#endif /* !defined TYPE_INTEGRAL */ + +#ifndef INT_STRLEN_MAXIMUM +/* +** 302 / 1000 is log10(2.0) rounded up. +** Subtract one for the sign bit if the type is signed; +** add one for integer division truncation; +** add one more for a minus sign if the type is signed. +*/ +#define INT_STRLEN_MAXIMUM(type) \ + ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \ + 1 + TYPE_SIGNED(type)) +#endif /* !defined INT_STRLEN_MAXIMUM */ + +/* Disable warnings */ + +#endif /* !defined PRIVATE_H */ diff --git a/sdk/tlibc/time/strftime.c b/sdk/tlibc/time/strftime.c new file mode 100644 index 0000000000..411d575e01 --- /dev/null +++ b/sdk/tlibc/time/strftime.c @@ -0,0 +1,763 @@ +/* $OpenBSD: strftime.c,v 1.21 2012/09/13 11:14:20 millert Exp $ */ +#include "private.h" + +/* +** Copyright (c) 1989, 1993 +** The Regents of the University of California. All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. Neither the name of the University nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +** SUCH DAMAGE. +*/ + +#include "tzfile.h" +//#include "fcntl.h" +//#include "locale.h" + +struct lc_time_T { + const char * mon[MONSPERYEAR]; + const char * month[MONSPERYEAR]; + const char * wday[DAYSPERWEEK]; + const char * weekday[DAYSPERWEEK]; + const char * X_fmt; + const char * x_fmt; + const char * c_fmt; + const char * am; + const char * pm; + const char * date_fmt; +}; + +#ifdef LOCALE_HOME +#include "sys/stat.h" +static struct lc_time_T localebuf; +static struct lc_time_T * _loc(void); +#define Locale _loc() +#endif /* defined LOCALE_HOME */ +#ifndef LOCALE_HOME +#define Locale (&C_time_locale) +#endif /* !defined LOCALE_HOME */ + +static const struct lc_time_T C_time_locale = { + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }, { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }, { + "Sun", "Mon", "Tue", "Wed", + "Thu", "Fri", "Sat" + }, { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" + }, + + /* X_fmt */ + "%H:%M:%S", + + /* + ** x_fmt + ** C99 requires this format. + ** Using just numbers (as here) makes Quakers happier; + ** it's also compatible with SVR4. + */ + "%m/%d/%y", + + /* + ** c_fmt + ** C99 requires this format. + ** Previously this code used "%D %X", but we now conform to C99. + ** Note that + ** "%a %b %d %H:%M:%S %Y" + ** is used by Solaris 2.3. + */ + "%a %b %e %T %Y", + + /* am */ + "AM", + + /* pm */ + "PM", + + /* date_fmt */ + "%a %b %e %H:%M:%S %Z %Y" +}; + +static char * _add(const char *, char *, const char *); +static char * _conv(int, const char *, char *, const char *); +static char * _fmt(const char *, const struct tm *, char *, const char *, + int *); +static char * _yconv(int, int, int, int, char *, const char *); + +//extern char * tzname[]; + +#ifndef YEAR_2000_NAME +#define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS" +#endif /* !defined YEAR_2000_NAME */ + +#define IN_NONE 0 +#define IN_SOME 1 +#define IN_THIS 2 +#define IN_ALL 3 + +size_t +strftime(s, maxsize, format, t) +char * const s; +const size_t maxsize; +const char * const format; +const struct tm * const t; +{ + char * p; + int warn; + + //tzset(); +#ifdef LOCALE_HOME + localebuf.mon[0] = 0; +#endif /* defined LOCALE_HOME */ + warn = IN_NONE; + p = _fmt(((format == NULL) ? "%c" : format), t, s, s + maxsize, &warn); + if (p == s + maxsize) { + if (maxsize > 0) + s[maxsize - 1] = '\0'; + return 0; + } + *p = '\0'; + return p - s; +} + +static char * +_fmt(format, t, pt, ptlim, warnp) +const char * format; +const struct tm * const t; +char * pt; +const char * const ptlim; +int * warnp; +{ + for ( ; *format; ++format) { + if (*format == '%') { +label: + switch (*++format) { + case '\0': + --format; + break; + case 'A': + pt = _add((t->tm_wday < 0 || + t->tm_wday >= DAYSPERWEEK) ? + "?" : Locale->weekday[t->tm_wday], + pt, ptlim); + continue; + case 'a': + pt = _add((t->tm_wday < 0 || + t->tm_wday >= DAYSPERWEEK) ? + "?" : Locale->wday[t->tm_wday], + pt, ptlim); + continue; + case 'B': + pt = _add((t->tm_mon < 0 || + t->tm_mon >= MONSPERYEAR) ? + "?" : Locale->month[t->tm_mon], + pt, ptlim); + continue; + case 'b': + case 'h': + pt = _add((t->tm_mon < 0 || + t->tm_mon >= MONSPERYEAR) ? + "?" : Locale->mon[t->tm_mon], + pt, ptlim); + continue; + case 'C': + /* + ** %C used to do a... + ** _fmt("%a %b %e %X %Y", t); + ** ...whereas now POSIX 1003.2 calls for + ** something completely different. + ** (ado, 1993-05-24) + */ + pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 0, + pt, ptlim); + continue; + case 'c': + { + int warn2 = IN_SOME; + + pt = _fmt(Locale->c_fmt, t, pt, ptlim, &warn2); + if (warn2 == IN_ALL) + warn2 = IN_THIS; + if (warn2 > *warnp) + *warnp = warn2; + } + continue; + case 'D': + pt = _fmt("%m/%d/%y", t, pt, ptlim, warnp); + continue; + case 'd': + pt = _conv(t->tm_mday, "%02d", pt, ptlim); + continue; + case 'E': + case 'O': + /* + ** C99 locale modifiers. + ** The sequences + ** %Ec %EC %Ex %EX %Ey %EY + ** %Od %oe %OH %OI %Om %OM + ** %OS %Ou %OU %OV %Ow %OW %Oy + ** are supposed to provide alternate + ** representations. + */ + goto label; + case 'e': + pt = _conv(t->tm_mday, "%2d", pt, ptlim); + continue; + case 'F': + pt = _fmt("%Y-%m-%d", t, pt, ptlim, warnp); + continue; + case 'H': + pt = _conv(t->tm_hour, "%02d", pt, ptlim); + continue; + case 'I': + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%02d", pt, ptlim); + continue; + case 'j': + pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim); + continue; + case 'k': + /* + ** This used to be... + ** _conv(t->tm_hour % 12 ? + ** t->tm_hour % 12 : 12, 2, ' '); + ** ...and has been changed to the below to + ** match SunOS 4.1.1 and Arnold Robbins' + ** strftime version 3.0. That is, "%k" and + ** "%l" have been swapped. + ** (ado, 1993-05-24) + */ + pt = _conv(t->tm_hour, "%2d", pt, ptlim); + continue; +#ifdef KITCHEN_SINK + case 'K': + /* + ** After all this time, still unclaimed! + */ + pt = _add("kitchen sink", pt, ptlim); + continue; +#endif /* defined KITCHEN_SINK */ + case 'l': + /* + ** This used to be... + ** _conv(t->tm_hour, 2, ' '); + ** ...and has been changed to the below to + ** match SunOS 4.1.1 and Arnold Robbin's + ** strftime version 3.0. That is, "%k" and + ** "%l" have been swapped. + ** (ado, 1993-05-24) + */ + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%2d", pt, ptlim); + continue; + case 'M': + pt = _conv(t->tm_min, "%02d", pt, ptlim); + continue; + case 'm': + pt = _conv(t->tm_mon + 1, "%02d", pt, ptlim); + continue; + case 'n': + pt = _add("\n", pt, ptlim); + continue; + case 'p': + pt = _add((t->tm_hour >= (HOURSPERDAY / 2)) ? + Locale->pm : + Locale->am, + pt, ptlim); + continue; + case 'R': + pt = _fmt("%H:%M", t, pt, ptlim, warnp); + continue; + case 'r': + pt = _fmt("%I:%M:%S %p", t, pt, ptlim, warnp); + continue; + case 'S': + pt = _conv(t->tm_sec, "%02d", pt, ptlim); + continue; + case 's': + #if 0 + { + struct tm tm; + char buf[INT_STRLEN_MAXIMUM( + time_t) + 1]; + time_t mkt; + + tm = *t; + mkt = mktime(&tm); + if (TYPE_SIGNED(time_t)) + (void) snprintf(buf, sizeof buf, + "%ld", (long) mkt); + else (void) snprintf(buf, sizeof buf, + "%lu", (unsigned long) mkt); + pt = _add(buf, pt, ptlim); + } + #endif + continue; + case 'T': + pt = _fmt("%H:%M:%S", t, pt, ptlim, warnp); + continue; + case 't': + pt = _add("\t", pt, ptlim); + continue; + case 'U': + pt = _conv((t->tm_yday + DAYSPERWEEK - + t->tm_wday) / DAYSPERWEEK, + "%02d", pt, ptlim); + continue; + case 'u': + /* + ** From Arnold Robbins' strftime version 3.0: + ** "ISO 8601: Weekday as a decimal number + ** [1 (Monday) - 7]" + ** (ado, 1993-05-24) + */ + pt = _conv((t->tm_wday == 0) ? + DAYSPERWEEK : t->tm_wday, + "%d", pt, ptlim); + continue; + case 'V': /* ISO 8601 week number */ + case 'G': /* ISO 8601 year (four digits) */ + case 'g': /* ISO 8601 year (two digits) */ +/* +** From Arnold Robbins' strftime version 3.0: "the week number of the +** year (the first Monday as the first day of week 1) as a decimal number +** (01-53)." +** (ado, 1993-05-24) +** +** From "http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html" by Markus Kuhn: +** "Week 01 of a year is per definition the first week which has the +** Thursday in this year, which is equivalent to the week which contains +** the fourth day of January. In other words, the first week of a new year +** is the week which has the majority of its days in the new year. Week 01 +** might also contain days from the previous year and the week before week +** 01 of a year is the last week (52 or 53) of the previous year even if +** it contains days from the new year. A week starts with Monday (day 1) +** and ends with Sunday (day 7). For example, the first week of the year +** 1997 lasts from 1996-12-30 to 1997-01-05..." +** (ado, 1996-01-02) +*/ + { + int year; + int base; + int yday; + int wday; + int w; + + year = t->tm_year; + base = TM_YEAR_BASE; + yday = t->tm_yday; + wday = t->tm_wday; + for ( ; ; ) { + int len; + int bot; + int top; + + len = isleap_sum(year, base) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + /* + ** What yday (-3 ... 3) does + ** the ISO year begin on? + */ + bot = ((yday + 11 - wday) % + DAYSPERWEEK) - 3; + /* + ** What yday does the NEXT + ** ISO year begin on? + */ + top = bot - + (len % DAYSPERWEEK); + if (top < -3) + top += DAYSPERWEEK; + top += len; + if (yday >= top) { + ++base; + w = 1; + break; + } + if (yday >= bot) { + w = 1 + ((yday - bot) / + DAYSPERWEEK); + break; + } + --base; + yday += isleap_sum(year, base) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + } +#ifdef XPG4_1994_04_09 + if ((w == 52 && + t->tm_mon == TM_JANUARY) || + (w == 1 && + t->tm_mon == TM_DECEMBER)) + w = 53; +#endif /* defined XPG4_1994_04_09 */ + if (*format == 'V') + pt = _conv(w, "%02d", + pt, ptlim); + else if (*format == 'g') { + *warnp = IN_ALL; + pt = _yconv(year, base, 0, 1, + pt, ptlim); + } else pt = _yconv(year, base, 1, 1, + pt, ptlim); + } + continue; + case 'v': + /* + ** From Arnold Robbins' strftime version 3.0: + ** "date as dd-bbb-YYYY" + ** (ado, 1993-05-24) + */ + pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp); + continue; + case 'W': + pt = _conv((t->tm_yday + DAYSPERWEEK - + (t->tm_wday ? + (t->tm_wday - 1) : + (DAYSPERWEEK - 1))) / DAYSPERWEEK, + "%02d", pt, ptlim); + continue; + case 'w': + pt = _conv(t->tm_wday, "%d", pt, ptlim); + continue; + case 'X': + pt = _fmt(Locale->X_fmt, t, pt, ptlim, warnp); + continue; + case 'x': + { + int warn2 = IN_SOME; + + pt = _fmt(Locale->x_fmt, t, pt, ptlim, &warn2); + if (warn2 == IN_ALL) + warn2 = IN_THIS; + if (warn2 > *warnp) + *warnp = warn2; + } + continue; + case 'y': + *warnp = IN_ALL; + pt = _yconv(t->tm_year, TM_YEAR_BASE, 0, 1, + pt, ptlim); + continue; + case 'Y': + pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 1, + pt, ptlim); + continue; + case 'Z': + #if 0 +#ifdef TM_ZONE + if (t->TM_ZONE != NULL) + pt = _add(t->TM_ZONE, pt, ptlim); + else +#endif /* defined TM_ZONE */ + if (t->tm_isdst >= 0) + pt = _add(tzname[t->tm_isdst != 0], + pt, ptlim); + #endif + /* + ** C99 says that %Z must be replaced by the + ** empty string if the time zone is not + ** determinable. + */ + continue; + case 'z': + #if 0 + { + int diff; + char const * sign; + + if (t->tm_isdst < 0) + continue; +#ifdef TM_GMTOFF + diff = t->TM_GMTOFF; +#else /* !defined TM_GMTOFF */ + /* + ** C99 says that the UTC offset must + ** be computed by looking only at + ** tm_isdst. This requirement is + ** incorrect, since it means the code + ** must rely on magic (in this case + ** altzone and timezone), and the + ** magic might not have the correct + ** offset. Doing things correctly is + ** tricky and requires disobeying C99; + ** see GNU C strftime for details. + ** For now, punt and conform to the + ** standard, even though it's incorrect. + ** + ** C99 says that %z must be replaced by the + ** empty string if the time zone is not + ** determinable, so output nothing if the + ** appropriate variables are not available. + */ + if (t->tm_isdst == 0) +#ifdef USG_COMPAT + diff = -timezone; +#else /* !defined USG_COMPAT */ + continue; +#endif /* !defined USG_COMPAT */ + else +#ifdef ALTZONE + diff = -altzone; +#else /* !defined ALTZONE */ + continue; +#endif /* !defined ALTZONE */ +#endif /* !defined TM_GMTOFF */ + if (diff < 0) { + sign = "-"; + diff = -diff; + } else sign = "+"; + pt = _add(sign, pt, ptlim); + diff /= SECSPERMIN; + diff = (diff / MINSPERHOUR) * 100 + + (diff % MINSPERHOUR); + pt = _conv(diff, "%04d", pt, ptlim); + } + #endif + continue; + case '+': + pt = _fmt(Locale->date_fmt, t, pt, ptlim, + warnp); + continue; + case '%': + /* + ** X311J/88-090 (4.12.3.5): if conversion char is + ** undefined, behavior is undefined. Print out the + ** character itself as printf(3) also does. + */ + default: + break; + } + } + if (pt == ptlim) + break; + *pt++ = *format; + } + return pt; +} + +static char * +_conv(n, format, pt, ptlim) +const int n; +const char * const format; +char * const pt; +const char * const ptlim; +{ + char buf[INT_STRLEN_MAXIMUM(int) + 1]; + + (void) snprintf(buf, sizeof buf, format, n); + return _add(buf, pt, ptlim); +} + +static char * +_add(str, pt, ptlim) +const char * str; +char * pt; +const char * const ptlim; +{ + while (pt < ptlim && (*pt = *str++) != '\0') + ++pt; + return pt; +} + +/* +** POSIX and the C Standard are unclear or inconsistent about +** what %C and %y do if the year is negative or exceeds 9999. +** Use the convention that %C concatenated with %y yields the +** same output as %Y, and that %Y contains at least 4 bytes, +** with more only if necessary. +*/ + +static char * +_yconv(a, b, convert_top, convert_yy, pt, ptlim) +const int a; +const int b; +const int convert_top; +const int convert_yy; +char * pt; +const char * const ptlim; +{ + register int lead; + register int trail; + +#define DIVISOR 100 + trail = a % DIVISOR + b % DIVISOR; + lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR; + trail %= DIVISOR; + if (trail < 0 && lead > 0) { + trail += DIVISOR; + --lead; + } else if (lead < 0 && trail > 0) { + trail -= DIVISOR; + ++lead; + } + if (convert_top) { + if (lead == 0 && trail < 0) + pt = _add("-0", pt, ptlim); + else pt = _conv(lead, "%02d", pt, ptlim); + } + if (convert_yy) + pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim); + return pt; +} + +#ifdef LOCALE_HOME +static struct lc_time_T * +_loc(void) +{ + static const char locale_home[] = LOCALE_HOME; + static const char lc_time[] = "LC_TIME"; + static char * locale_buf; + + int fd; + int oldsun; /* "...ain't got nothin' to do..." */ + int len; + char * lbuf; + char * nlbuf; + char * name; + char * p; + const char ** ap; + const char * plim; + char filename[FILENAME_MAX]; + struct stat st; + size_t namesize; + size_t bufsize; + + /* + ** Use localebuf.mon[0] to signal whether locale is already set up. + */ + if (localebuf.mon[0]) + return &localebuf; + name = setlocale(LC_TIME, (char *) NULL); + if (name == NULL || *name == '\0') + goto no_locale; + /* + ** If the locale name is the same as our cache, use the cache. + */ + lbuf = locale_buf; + if (lbuf != NULL && strcmp(name, lbuf) == 0) { + p = lbuf; + for (ap = (const char **) &localebuf; + ap < (const char **) (&localebuf + 1); + ++ap) + *ap = p += strlen(p) + 1; + return &localebuf; + } + /* + ** Slurp the locale file into the cache. + */ + namesize = strlen(name) + 1; + if (sizeof filename < + ((sizeof locale_home) + namesize + (sizeof lc_time))) + goto no_locale; + oldsun = 0; + len = snprintf(filename, sizeof filename, "%s/%s/%s", locale_home, + name, lc_time); + if (len < 0 || len >= sizeof filename) + goto no_locale; + fd = open(filename, O_RDONLY); + if (fd < 0) { + /* + ** Old Sun systems have a different naming and data convention. + */ + oldsun = 1; + len = snprintf(filename, sizeof filename, "%s/%s/%s", + locale_home, lc_time, name); + if (len < 0 || len >= sizeof filename) + goto no_locale; + fd = open(filename, O_RDONLY); + if (fd < 0) + goto no_locale; + } + if (fstat(fd, &st) != 0) + goto bad_locale; + if (st.st_size <= 0) + goto bad_locale; + bufsize = namesize + st.st_size; + locale_buf = NULL; + nlbuf = (lbuf == NULL) ? malloc(bufsize) : realloc(lbuf, bufsize); + if (nlbuf == NULL) { + if (lbuf) + free(lbuf); + lbuf = NULL; + goto bad_locale; + } + lbuf = nlbuf; + (void) strlcpy(lbuf, name, bufsize); + p = lbuf + namesize; + plim = p + st.st_size; + if (read(fd, p, (size_t) st.st_size) != st.st_size) + goto bad_lbuf; + if (close(fd) != 0) + goto bad_lbuf; + /* + ** Parse the locale file into localebuf. + */ + if (plim[-1] != '\n') + goto bad_lbuf; + for (ap = (const char **) &localebuf; + ap < (const char **) (&localebuf + 1); + ++ap) { + if (p == plim) + goto bad_lbuf; + *ap = p; + while (*p != '\n') + ++p; + *p++ = '\0'; + } + if (oldsun) { + /* + ** SunOS 4 used an obsolescent format; see localdtconv(3). + ** c_fmt had the ``short format for dates and times together'' + ** (SunOS 4 date, "%a %b %e %T %Z %Y" in the C locale); + ** date_fmt had the ``long format for dates'' + ** (SunOS 4 strftime %C, "%A, %B %e, %Y" in the C locale). + ** Discard the latter in favor of the former. + */ + localebuf.date_fmt = localebuf.c_fmt; + } + /* + ** Record the successful parse in the cache. + */ + locale_buf = lbuf; + + return &localebuf; + +bad_lbuf: + free(lbuf); +bad_locale: + (void) close(fd); +no_locale: + localebuf = C_time_locale; + locale_buf = NULL; + return &localebuf; +} +#endif /* defined LOCALE_HOME */ diff --git a/sdk/tlibc/time/tzfile.h b/sdk/tlibc/time/tzfile.h new file mode 100644 index 0000000000..f2316855ca --- /dev/null +++ b/sdk/tlibc/time/tzfile.h @@ -0,0 +1,72 @@ +/* $OpenBSD: tzfile.h,v 1.8 2007/02/06 19:35:16 millert Exp $ */ + +#ifndef TZFILE_H + +#define TZFILE_H + +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson. +*/ + +/* +** This header is for use ONLY with the time conversion code. +** There is no guarantee that it will remain unchanged, +** or that it will remain at all. +** Do NOT copy it to any system include directory. +** Thank you! +*/ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) + +/* +** Since everything in isleap is modulo 400 (or a factor of 400), we know that +** isleap(y) == isleap(y % 400) +** and so +** isleap(a + b) == isleap((a + b) % 400) +** or +** isleap(a + b) == isleap(a % 400 + b % 400) +** This is true even if % means modulo rather than Fortran remainder +** (which is allowed by C89 but not C99). +** We use this to avoid addition overflow problems. +*/ + +#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400) + +#endif /* !defined TZFILE_H */ diff --git a/sdk/tlibc/tstdc_version.cpp b/sdk/tlibc/tstdc_version.cpp new file mode 100644 index 0000000000..4fba487614 --- /dev/null +++ b/sdk/tlibc/tstdc_version.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_TSTDC_VERSION_STR __CONCAT("SGX_TSTDC_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_tstdc_version = SGX_TSTDC_VERSION_STR; + +#ifdef __cplusplus +} +#endif diff --git a/sdk/tlibcrypto/Makefile b/sdk/tlibcrypto/Makefile new file mode 100644 index 0000000000..32a29627e1 --- /dev/null +++ b/sdk/tlibcrypto/Makefile @@ -0,0 +1,70 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +CRYPTO_PATH = $(LINUX_EXTERNAL_DIR)/crypto_px + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-exceptions -fno-rtti + +CPPFLAGS := -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(CRYPTO_PATH)/include + +OBJ = init_crypto_lib.o sgx_aes_ctr.o sgx_aes_gcm.o sgx_cmac128.o sgx_ecc256.o sgx_ecc256_common.o sgx_ecc256_ecdsa.o sgx_sha256.o sgx_sha256_msg.o tcrypto_version.o + +TARGET := libsgx_tcrypto.a + +libcrypto_px: + $(MAKE) -C $(CRYPTO_PATH) + +$(TARGET): $(OBJ) libcrypto_px + @$(CP) $(CRYPTO_PATH)/libcrypto_px.a $@ + $(AR) rsD $@ $(OBJ) + +$(OBJ): %.o: %.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: all +all: $(TARGET) | $(BUILD_DIR) + @$(CP) $< $| + +.PHONY: clean +clean: + $(MAKE) -C $(CRYPTO_PATH) clean + @$(RM) *.o $(TARGET) $(BUILD_DIR)/$(TARGET) + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/tlibcrypto/init_crypto_lib.cpp b/sdk/tlibcrypto/init_crypto_lib.cpp new file mode 100644 index 0000000000..fe983f1d9d --- /dev/null +++ b/sdk/tlibcrypto/init_crypto_lib.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tcrypto.h" +#include "ippcore.h" +#include "ippcp.h" +#include "se_cpu_feature.h" +#include "se_cdefs.h" + +// add a version to tcrypto. +SGX_ACCESS_VERSION(tcrypto, 1) + + +extern "C" sgx_status_t sgx_init_crypto_lib(uint64_t cpu_feature_indicator) +{ + (void) cpu_feature_indicator; + return SGX_SUCCESS; +} + diff --git a/sdk/tlibcrypto/sgx_aes_ctr.cpp b/sdk/tlibcrypto/sgx_aes_ctr.cpp new file mode 100644 index 0000000000..296fbc3764 --- /dev/null +++ b/sdk/tlibcrypto/sgx_aes_ctr.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tcrypto.h" +#include "ippcp.h" +#include "stdlib.h" +#include "string.h" + +/* AES-CTR 128-bit + * Parameters: + * Return: + * sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: + * sgx_aes_128bit_key_t *p_key - Pointer to the key used in encryption/decryption operation + * uint8_t *p_src - Pointer to the input stream to be encrypted/decrypted + * uint32_t src_len - Length of the input stream to be encrypted/decrypted + * uint8_t *p_ctr - Pointer to the counter block + * uint32_t ctr_inc_bits - Number of bits in counter to be incremented + * Output: + * uint8_t *p_dst - Pointer to the cipher text. Size of buffer should be >= src_len. + */ +sgx_status_t sgx_aes_ctr_encrypt(const sgx_aes_ctr_128bit_key_t *p_key, const uint8_t *p_src, + const uint32_t src_len, uint8_t *p_ctr, const uint32_t ctr_inc_bits, + uint8_t *p_dst) +{ + IppStatus error_code = ippStsNoErr; + IppsAESSpec* ptr_ctx = NULL; + int ctx_size = 0; + + if ((p_key == NULL) || (p_src == NULL) || (p_ctr == NULL) || (p_dst == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // AES-CTR-128 encryption + error_code = ippsAESGetSize(&ctx_size); + if (error_code != ippStsNoErr) + { + return SGX_ERROR_UNEXPECTED; + } + ptr_ctx = (IppsAESSpec*)malloc(ctx_size); + if (ptr_ctx == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + + // Init + error_code = ippsAESInit((const Ipp8u*)p_key, SGX_AESCTR_KEY_SIZE, ptr_ctx, ctx_size); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(ptr_ctx, ctx_size, 0, ctx_size); + free(ptr_ctx); + switch (error_code) + { + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + error_code = ippsAESEncryptCTR(p_src, p_dst, src_len, ptr_ctx, p_ctr, ctr_inc_bits); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(ptr_ctx, ctx_size, 0, ctx_size); + free(ptr_ctx); + switch (error_code) + { + case ippStsCTRSizeErr: + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + // Clear temp State before free. + memset_s(ptr_ctx, ctx_size, 0, ctx_size); + free(ptr_ctx); + return SGX_SUCCESS; +} + +sgx_status_t sgx_aes_ctr_decrypt(const sgx_aes_ctr_128bit_key_t *p_key, const uint8_t *p_src, + const uint32_t src_len, uint8_t *p_ctr, const uint32_t ctr_inc_bits, + uint8_t *p_dst) +{ + IppStatus error_code = ippStsNoErr; + IppsAESSpec* ptr_ctx = NULL; + int ctx_size = 0; + + if ((p_key == NULL) || (p_src == NULL) || (p_ctr == NULL) || (p_dst == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // AES-CTR-128 encryption + error_code = ippsAESGetSize(&ctx_size); + if (error_code != ippStsNoErr) + { + return SGX_ERROR_UNEXPECTED; + } + ptr_ctx = (IppsAESSpec*)malloc(ctx_size); + if (ptr_ctx == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + + // Init + error_code = ippsAESInit((const Ipp8u*)p_key, SGX_AESCTR_KEY_SIZE, ptr_ctx, ctx_size); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(ptr_ctx, ctx_size, 0, ctx_size); + free(ptr_ctx); + switch (error_code) + { + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + error_code = ippsAESDecryptCTR(p_src, p_dst, src_len, ptr_ctx, p_ctr, ctr_inc_bits); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(ptr_ctx, ctx_size, 0, ctx_size); + free(ptr_ctx); + switch (error_code) + { + case ippStsCTRSizeErr: + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + // Clear temp State before free. + memset_s(ptr_ctx, ctx_size, 0, ctx_size); + free(ptr_ctx); + return SGX_SUCCESS; +} diff --git a/sdk/tlibcrypto/sgx_aes_gcm.cpp b/sdk/tlibcrypto/sgx_aes_gcm.cpp new file mode 100644 index 0000000000..3590542d85 --- /dev/null +++ b/sdk/tlibcrypto/sgx_aes_gcm.cpp @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tcrypto.h" +#include "ippcp.h" +#include "stdlib.h" +#include "string.h" + +/* Rijndael AES-GCM +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_aes_gcm_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be encrypted/decrypted +* uint32_t src_len - Length of input stream to be encrypted/decrypted +* uint8_t *p_iv - Pointer to initialization vector to use +* uint32_t iv_len - Length of initialization vector +* uint8_t *p_aad - Pointer to input stream of additional authentication data +* uint32_t aad_len - Length of additional authentication data stream +* sgx_aes_gcm_128bit_tag_t *p_in_mac - Pointer to expected MAC in decryption process +* Output: uint8_t *p_dst - Pointer to cipher text. Size of buffer should be >= src_len. +* sgx_aes_gcm_128bit_tag_t *p_out_mac - Pointer to MAC generated from encryption process +* NOTE: Wrapper is responsible for confirming decryption tag matches encryption tag */ +sgx_status_t sgx_rijndael128GCM_encrypt(const sgx_aes_gcm_128bit_key_t *p_key, const uint8_t *p_src, uint32_t src_len, + uint8_t *p_dst, const uint8_t *p_iv, uint32_t iv_len, const uint8_t *p_aad, uint32_t aad_len, + sgx_aes_gcm_128bit_tag_t *p_out_mac) +{ + IppStatus error_code = ippStsNoErr; + IppsAES_GCMState* pState = NULL; + int ippStateSize = 0; + + if ((p_key == NULL) || ((src_len > 0) && (p_dst == NULL)) || ((src_len > 0) && (p_src == NULL)) + || (p_out_mac == NULL) || (iv_len != SGX_AESGCM_IV_SIZE) || ((aad_len > 0) && (p_aad == NULL)) + || (p_iv == NULL) || ((p_src == NULL) && (p_aad == NULL))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + error_code = ippsAES_GCMGetSize(&ippStateSize); + if (error_code != ippStsNoErr) + { + return SGX_ERROR_UNEXPECTED; + } + pState = (IppsAES_GCMState*)malloc(ippStateSize); + if (pState == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + error_code = ippsAES_GCMInit((const Ipp8u *)p_key, SGX_AESGCM_KEY_SIZE, pState, ippStateSize); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + error_code = ippsAES_GCMStart(p_iv, SGX_AESGCM_IV_SIZE, p_aad, aad_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + if (src_len > 0) { + error_code = ippsAES_GCMEncrypt(p_src, p_dst, src_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + } + error_code = ippsAES_GCMGetTag((Ipp8u *)p_out_mac, SGX_AESGCM_MAC_SIZE, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(p_dst, src_len, 0, src_len); + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + return SGX_SUCCESS; +} + +sgx_status_t sgx_rijndael128GCM_decrypt(const sgx_aes_gcm_128bit_key_t *p_key, const uint8_t *p_src, + uint32_t src_len, uint8_t *p_dst, const uint8_t *p_iv, uint32_t iv_len, + const uint8_t *p_aad, uint32_t aad_len, const sgx_aes_gcm_128bit_tag_t *p_in_mac) +{ + IppStatus error_code = ippStsNoErr; + uint8_t l_tag[SGX_AESGCM_MAC_SIZE]; + IppsAES_GCMState* pState = NULL; + int ippStateSize = 0; + + if ((p_key == NULL) || ((src_len > 0) && (p_dst == NULL)) || ((src_len > 0) && (p_src == NULL)) + || (p_in_mac == NULL) || (iv_len != SGX_AESGCM_IV_SIZE) || ((aad_len > 0) && (p_aad == NULL)) + || (p_iv == NULL) || ((p_src == NULL) && (p_aad == NULL))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // Autenthication Tag returned by Decrypt to be compared with Tag created during seal + memset(&l_tag, 0, SGX_AESGCM_MAC_SIZE); + error_code = ippsAES_GCMGetSize(&ippStateSize); + if (error_code != ippStsNoErr) + { + return SGX_ERROR_UNEXPECTED; + } + pState = (IppsAES_GCMState*)malloc(ippStateSize); + if (pState == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + error_code = ippsAES_GCMInit((const Ipp8u *)p_key, SGX_AESGCM_KEY_SIZE, pState, ippStateSize); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + error_code = ippsAES_GCMStart(p_iv, SGX_AESGCM_IV_SIZE, p_aad, aad_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + if (src_len > 0) { + error_code = ippsAES_GCMDecrypt(p_src, p_dst, src_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + } + error_code = ippsAES_GCMGetTag((Ipp8u *)l_tag, SGX_AESGCM_MAC_SIZE, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(p_dst, src_len, 0, src_len); + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + + // Verify current data tag = data tag generated when sealing the data blob + if (consttime_memequal(p_in_mac, &l_tag, SGX_AESGCM_MAC_SIZE) == 0) + { + memset_s(p_dst, src_len, 0, src_len); + memset_s(&l_tag, SGX_AESGCM_MAC_SIZE, 0, SGX_AESGCM_MAC_SIZE); + return SGX_ERROR_MAC_MISMATCH; + } + + memset_s(&l_tag, SGX_AESGCM_MAC_SIZE, 0, SGX_AESGCM_MAC_SIZE); + return SGX_SUCCESS; +} + diff --git a/sdk/tlibcrypto/sgx_cmac128.cpp b/sdk/tlibcrypto/sgx_cmac128.cpp new file mode 100644 index 0000000000..c532a648c4 --- /dev/null +++ b/sdk/tlibcrypto/sgx_cmac128.cpp @@ -0,0 +1,230 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tcrypto.h" +#include "ippcp.h" +#include "stdlib.h" +#include "string.h" + + +/* Message Authentication - Rijndael 128 CMAC +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_cmac_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be MACed +* uint32_t src_len - Length of input stream to be MACed +* Output: sgx_cmac_gcm_128bit_tag_t *p_mac - Pointer to resultant MAC */ +sgx_status_t sgx_rijndael128_cmac_msg(const sgx_cmac_128bit_key_t *p_key, const uint8_t *p_src, + uint32_t src_len, sgx_cmac_128bit_tag_t *p_mac) +{ + IppsAES_CMACState* pState = NULL; + int ippStateSize = 0; + IppStatus error_code = ippStsNoErr; + + if ((p_key == NULL) || (p_src == NULL) || (p_mac == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + error_code = ippsAES_CMACGetSize(&ippStateSize); + if (error_code != ippStsNoErr) + { + return SGX_ERROR_UNEXPECTED; + } + pState = (IppsAES_CMACState*)malloc(ippStateSize); + if (pState == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + error_code = ippsAES_CMACInit((const Ipp8u *)p_key, SGX_CMAC_KEY_SIZE, pState, ippStateSize); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + error_code = ippsAES_CMACUpdate((const Ipp8u *)p_src, src_len, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + error_code = ippsAES_CMACFinal((Ipp8u *)p_mac, SGX_CMAC_MAC_SIZE, pState); + if (error_code != ippStsNoErr) + { + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + switch (error_code) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + // Clear temp State before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + return SGX_SUCCESS; +} + +static void sgx_secure_free_cmac128_state(IppsAES_CMACState *pState) +{ + if (pState == NULL) + return; + int ippStateSize = 0; + IppStatus error_code = ippStsNoErr; + error_code = ippsAES_CMACGetSize(&ippStateSize); + if (error_code != ippStsNoErr) + { + free(pState); + return; + } + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + return; +} + +/* Allocates and initializes CMAC state +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Inputs: sgx_cmac_128bit_key_t *p_key - Pointer to the key used in encryption/decryption operation +* Output: sgx_cmac_state_handle_t *p_cmac_handle - Pointer to the handle of the CMAC state */ +sgx_status_t sgx_cmac128_init(const sgx_cmac_128bit_key_t *p_key, sgx_cmac_state_handle_t* p_cmac_handle) +{ + if ((p_key == NULL) || (p_cmac_handle == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppsAES_CMACState* pState = NULL; + int ippStateSize = 0; + IppStatus error_code = ippStsNoErr; + error_code = ippsAES_CMACGetSize(&ippStateSize); + if (error_code != ippStsNoErr) + { + return SGX_ERROR_UNEXPECTED; + } + pState = (IppsAES_CMACState*)malloc(ippStateSize); + if (pState == NULL) + { + return SGX_ERROR_OUT_OF_MEMORY; + } + error_code = ippsAES_CMACInit((const Ipp8u *)p_key, SGX_CMAC_KEY_SIZE, pState, ippStateSize); + if (error_code != ippStsNoErr) + { + // Clear state before free. + memset_s(pState, ippStateSize, 0, ippStateSize); + free(pState); + *p_cmac_handle = NULL; + switch (error_code) + { + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + *p_cmac_handle = pState; + return SGX_SUCCESS; +} + +/* Updates CMAC hash calculation based on the input message +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error. +* Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state +* uint8_t *p_src - Pointer to the input stream to be hashed +* uint32_t src_len - Length of the input stream to be hashed */ +sgx_status_t sgx_cmac128_update(const uint8_t *p_src, uint32_t src_len, sgx_cmac_state_handle_t cmac_handle) +{ + if ((p_src == NULL) || (cmac_handle == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + IppStatus error_code = ippStsNoErr; + error_code = ippsAES_CMACUpdate(p_src, src_len, (IppsAES_CMACState*)cmac_handle); + switch (error_code) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + +/* Returns Hash calculation +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state +* Output: sgx_cmac_128bit_tag_t *p_hash - Resultant hash from operation */ +sgx_status_t sgx_cmac128_final(sgx_cmac_state_handle_t cmac_handle, sgx_cmac_128bit_tag_t *p_hash) +{ + if ((cmac_handle == NULL) || (p_hash == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + IppStatus error_code = ippStsNoErr; + error_code = ippsAES_CMACFinal((Ipp8u *)p_hash, SGX_CMAC_MAC_SIZE, (IppsAES_CMACState*)cmac_handle); + switch (error_code) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + + +/* Clean up the CMAC state +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state */ +sgx_status_t sgx_cmac128_close(sgx_cmac_state_handle_t cmac_handle) +{ + if (cmac_handle == NULL) + return SGX_ERROR_INVALID_PARAMETER; + sgx_secure_free_cmac128_state((IppsAES_CMACState*)cmac_handle); + return SGX_SUCCESS; +} diff --git a/sdk/tlibcrypto/sgx_ecc256.cpp b/sdk/tlibcrypto/sgx_ecc256.cpp new file mode 100644 index 0000000000..c459f761c0 --- /dev/null +++ b/sdk/tlibcrypto/sgx_ecc256.cpp @@ -0,0 +1,484 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_ecc256_common.h" + + +/* +* Elliptic Curve Crytpography - Based on GF(p), 256 bit +*/ +/* Allocates and initializes ecc context +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Output: sgx_ecc_state_handle_t *p_ecc_handle - Pointer to the handle of ECC crypto system */ +sgx_status_t sgx_ecc256_open_context(sgx_ecc_state_handle_t* p_ecc_handle) +{ + IppStatus ipp_ret = ippStsNoErr; + IppsECCPState* p_ecc_state = NULL; + // default use 256r1 parameter + int ctx_size = 0; + + if (p_ecc_handle == NULL) + return SGX_ERROR_INVALID_PARAMETER; + ipp_ret = ippsECCPGetSize(256, &ctx_size); + if (ipp_ret != ippStsNoErr) + return SGX_ERROR_UNEXPECTED; + p_ecc_state = (IppsECCPState*)(malloc(ctx_size)); + if (p_ecc_state == NULL) + return SGX_ERROR_OUT_OF_MEMORY; + ipp_ret = ippsECCPInit(256, p_ecc_state); + if (ipp_ret != ippStsNoErr) + { + SAFE_FREE(p_ecc_state); + *p_ecc_handle = NULL; + return SGX_ERROR_UNEXPECTED; + } + ipp_ret = ippsECCPSetStd(IppECCPStd256r1, p_ecc_state); + if (ipp_ret != ippStsNoErr) + { + SAFE_FREE(p_ecc_state); + *p_ecc_handle = NULL; + return SGX_ERROR_UNEXPECTED; + } + *p_ecc_handle = p_ecc_state; + return SGX_SUCCESS; +} + +/* Cleans up ecc context +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Output: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system */ +sgx_status_t sgx_ecc256_close_context(sgx_ecc_state_handle_t ecc_handle) +{ + if (ecc_handle == NULL) + { + return SGX_ERROR_INVALID_PARAMETER; + } + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + int ctx_size = 0; + IppStatus ipp_ret = ippsECCPGetSize(256, &ctx_size); + if (ipp_ret != ippStsNoErr) + { + free(p_ecc_state); + return SGX_SUCCESS; + } + memset_s(p_ecc_state, ctx_size, 0, ctx_size); + free(p_ecc_state); + return SGX_SUCCESS; +} + +/* Populates private/public key pair - caller code allocates memory +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* Outputs: sgx_ec256_private_t *p_private - Pointer to the private key +* sgx_ec256_public_t *p_public - Pointer to the public key */ +sgx_status_t sgx_ecc256_create_key_pair(sgx_ec256_private_t *p_private, + sgx_ec256_public_t *p_public, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private == NULL) || (p_public == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppsBigNumState* dh_priv_BN = NULL; + IppsECCPPointState* point_pub = NULL; + IppsBigNumState* pub_gx = NULL; + IppsBigNumState* pub_gy = NULL; + IppStatus ipp_ret = ippStsNoErr; + int ecPointSize = 0; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + + do + { + //init eccp point + ipp_ret = ippsECCPPointGetSize(256, &ecPointSize); + ERROR_BREAK(ipp_ret); + point_pub = (IppsECCPPointState*)(malloc(ecPointSize)); + if (!point_pub) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, point_pub); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, SGX_ECP256_KEY_SIZE, &dh_priv_BN); + ERROR_BREAK(ipp_ret); + // Use the true random number (DRNG) + // Notice that IPP ensures the private key generated is non-zero + ipp_ret = ippsECCPGenKeyPair(dh_priv_BN, point_pub, p_ecc_state, (IppBitSupplier)sgx_ipp_DRNGen, NULL); + ERROR_BREAK(ipp_ret); + + //convert point_result to oct string + ipp_ret = sgx_ipp_newBN(NULL, SGX_ECP256_KEY_SIZE, &pub_gx); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(NULL, SGX_ECP256_KEY_SIZE, &pub_gy); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPGetPoint(pub_gx, pub_gy, point_pub, p_ecc_state); + ERROR_BREAK(ipp_ret); + + IppsBigNumSGN sgn = IppsBigNumPOS; + Ipp32u *pdata = NULL; + // ippsRef_BN is in bits not bytes (versus old ippsGet_BN) + int length = 0; + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, pub_gx); + ERROR_BREAK(ipp_ret); + memset(p_public->gx, 0, sizeof(p_public->gx)); + ipp_ret = check_copy_size(sizeof(p_public->gx), ROUND_TO(length, 8) / 8); + ERROR_BREAK(ipp_ret); + memcpy(p_public->gx, pdata, ROUND_TO(length, 8) / 8); + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, pub_gy); + ERROR_BREAK(ipp_ret); + memset(p_public->gy, 0, sizeof(p_public->gy)); + ipp_ret = check_copy_size(sizeof(p_public->gy), ROUND_TO(length, 8) / 8); + ERROR_BREAK(ipp_ret); + memcpy(p_public->gy, pdata, ROUND_TO(length, 8) / 8); + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, dh_priv_BN); + ERROR_BREAK(ipp_ret); + memset(p_private->r, 0, sizeof(p_private->r)); + ipp_ret = check_copy_size(sizeof(p_private->r), ROUND_TO(length, 8) / 8); + ERROR_BREAK(ipp_ret); + memcpy(p_private->r, pdata, ROUND_TO(length, 8) / 8); + } while (0); + + //Clear temp buffer before free. + if (point_pub) memset_s(point_pub, ecPointSize, 0, ecPointSize); + SAFE_FREE(point_pub); + sgx_ipp_secure_free_BN(pub_gx, SGX_ECP256_KEY_SIZE); + sgx_ipp_secure_free_BN(pub_gy, SGX_ECP256_KEY_SIZE); + sgx_ipp_secure_free_BN(dh_priv_BN, SGX_ECP256_KEY_SIZE); + + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + +/* Checks whether the input point is a valid point on the given elliptic curve +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_public_t *p_point - Pointer to perform validity check on - LITTLE ENDIAN +* Output: int *p_valid - Return 0 if the point is an invalid point on ECC curve */ +sgx_status_t sgx_ecc256_check_point(const sgx_ec256_public_t *p_point, + const sgx_ecc_state_handle_t ecc_handle, + int *p_valid) +{ + if ((ecc_handle == NULL) || (p_point == NULL) || (p_valid == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppsECCPPointState* point2check = NULL; + IppStatus ipp_ret = ippStsNoErr; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + IppECResult ipp_result = ippECValid; + int ecPointSize = 0; + IppsBigNumState* BN_gx = NULL; + IppsBigNumState* BN_gy = NULL; + + // Intialize return to false + *p_valid = 0; + + do + { + ipp_ret = ippsECCPPointGetSize(256, &ecPointSize); + ERROR_BREAK(ipp_ret); + point2check = (IppsECCPPointState*)malloc(ecPointSize); + if (!point2check) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, point2check); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN((const Ipp32u *)p_point->gx, sizeof(p_point->gx), &BN_gx); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((const Ipp32u *)p_point->gy, sizeof(p_point->gy), &BN_gy); + ERROR_BREAK(ipp_ret); + + ipp_ret = ippsECCPSetPoint(BN_gx, BN_gy, point2check, p_ecc_state); + ERROR_BREAK(ipp_ret); + + // Check to see if the point is a valid point on the Elliptic curve and is not infinity + ipp_ret = ippsECCPCheckPoint(point2check, &ipp_result, p_ecc_state); + ERROR_BREAK(ipp_ret); + if (ipp_result == ippECValid) + { + *p_valid = 1; + } + } while (0); + + // Clear temp buffer before free. + if (point2check) + memset_s(point2check, ecPointSize, 0, ecPointSize); + SAFE_FREE(point2check); + + sgx_ipp_secure_free_BN(BN_gx, sizeof(p_point->gx)); + sgx_ipp_secure_free_BN(BN_gy, sizeof(p_point->gy)); + + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + +/* Computes DH shared key based on private B key (local) and remote public Ga Key +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN +* sgx_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN +* Output: sgx_ec256_dh_shared_t *p_shared_key - Pointer to the shared DH key - LITTLE ENDIAN +x-coordinate of (privKeyB - pubKeyA) */ +sgx_status_t sgx_ecc256_compute_shared_dhkey(sgx_ec256_private_t *p_private_b, + sgx_ec256_public_t *p_public_ga, + sgx_ec256_dh_shared_t *p_shared_key, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private_b == NULL) || (p_public_ga == NULL) || (p_shared_key == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppsBigNumState* BN_dh_privB = NULL; + IppsBigNumState* BN_dh_share = NULL; + IppsBigNumState* pubA_gx = NULL; + IppsBigNumState* pubA_gy = NULL; + IppsECCPPointState* point_pubA = NULL; + IppStatus ipp_ret = ippStsNoErr; + int ecPointSize = 0; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + IppECResult ipp_result = ippECValid; + + do + { + ipp_ret = sgx_ipp_newBN((Ipp32u*)p_private_b->r, sizeof(sgx_ec256_private_t), &BN_dh_privB); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((uint32_t*)p_public_ga->gx, sizeof(p_public_ga->gx), &pubA_gx); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((uint32_t*)p_public_ga->gy, sizeof(p_public_ga->gy), &pubA_gy); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPPointGetSize(256, &ecPointSize); + ERROR_BREAK(ipp_ret); + point_pubA = (IppsECCPPointState*)(malloc(ecPointSize)); + if (!point_pubA) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, point_pubA); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPSetPoint(pubA_gx, pubA_gy, point_pubA, p_ecc_state); + ERROR_BREAK(ipp_ret); + + // Check to see if the point is a valid point on the Elliptic curve and is not infinity + ipp_ret = ippsECCPCheckPoint(point_pubA, &ipp_result, p_ecc_state); + if (ipp_result != ippECValid) + { + break; + } + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, sizeof(sgx_ec256_dh_shared_t), &BN_dh_share); + ERROR_BREAK(ipp_ret); + /* This API generates shareA = x-coordinate of (privKeyB*pubKeyA) */ + ipp_ret = ippsECCPSharedSecretDH(BN_dh_privB, point_pubA, BN_dh_share, p_ecc_state); + ERROR_BREAK(ipp_ret); + IppsBigNumSGN sgn = IppsBigNumPOS; + int length = 0; + Ipp32u * pdata = NULL; + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_share); + ERROR_BREAK(ipp_ret); + memset(p_shared_key->s, 0, sizeof(p_shared_key->s)); + ipp_ret = check_copy_size(sizeof(p_shared_key->s), ROUND_TO(length, 8) / 8); + ERROR_BREAK(ipp_ret); + memcpy(p_shared_key->s, pdata, ROUND_TO(length, 8) / 8); + } while (0); + + // Clear temp buffer before free. + if (point_pubA) memset_s(point_pubA, ecPointSize, 0, ecPointSize); + SAFE_FREE(point_pubA); + sgx_ipp_secure_free_BN(pubA_gx, sizeof(p_public_ga->gx)); + sgx_ipp_secure_free_BN(pubA_gy, sizeof(p_public_ga->gy)); + sgx_ipp_secure_free_BN(BN_dh_privB, sizeof(sgx_ec256_private_t)); + sgx_ipp_secure_free_BN(BN_dh_share, sizeof(sgx_ec256_dh_shared_t)); + + + if (ipp_result != ippECValid) + { + return SGX_ERROR_INVALID_PARAMETER; + } + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + +/* Computes 512-bit DH shared key based on private B key (local) and remote public Ga Key +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN +* sgx_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN +* Output: sgx_ec256_dh_shared_t *p_shared_key - Pointer to the shared DH key - LITTLE ENDIAN +x-coordinate of (privKeyB - pubKeyA) */ +sgx_status_t sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b, + sgx_ec256_public_t *p_public_ga, + sgx_ec256_dh_shared512_t *p_shared_key, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private_b == NULL) || (p_public_ga == NULL) || (p_shared_key == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppsBigNumState* BN_dh_privB = NULL; + IppsBigNumState* BN_dh_share512_x = NULL; + IppsBigNumState* BN_dh_share512_y = NULL; + IppsBigNumState* pubA_gx = NULL; + IppsBigNumState* pubA_gy = NULL; + IppsECCPPointState* point_pubA = NULL; + IppsECCPPointState* point_R = NULL; + IppStatus ipp_ret = ippStsNoErr; + int ecPointSize = 0; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + + do + { + ipp_ret = sgx_ipp_newBN((Ipp32u*)p_private_b->r, sizeof(sgx_ec256_private_t), &BN_dh_privB); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((uint32_t*)p_public_ga->gx, sizeof(p_public_ga->gx), &pubA_gx); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((uint32_t*)p_public_ga->gy, sizeof(p_public_ga->gy), &pubA_gy); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPPointGetSize(256, &ecPointSize); + ERROR_BREAK(ipp_ret); + point_pubA = (IppsECCPPointState*)( malloc(ecPointSize) ); + if(!point_pubA) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, point_pubA); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPSetPoint(pubA_gx, pubA_gy, point_pubA, p_ecc_state); + ERROR_BREAK(ipp_ret); + + point_R = (IppsECCPPointState*)( malloc(ecPointSize) ); + if(!point_R) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, point_R); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, sizeof(sgx_ec256_dh_shared_t), &BN_dh_share512_x); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(NULL, sizeof(sgx_ec256_dh_shared_t), &BN_dh_share512_y); + ERROR_BREAK(ipp_ret); + + ipp_ret = ippsECCPMulPointScalar(point_pubA, BN_dh_privB, point_R, p_ecc_state); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPGetPoint(BN_dh_share512_x, BN_dh_share512_y, point_R, p_ecc_state); + ERROR_BREAK(ipp_ret); + + IppsBigNumSGN sgn = IppsBigNumPOS; + int length = 0; + Ipp32u *pdata = NULL; + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_share512_x); + ERROR_BREAK(ipp_ret); + memset(p_shared_key->x, 0, sizeof(p_shared_key->x)); + memcpy(p_shared_key->x, pdata, ROUND_TO(length, 8)/8); + // Clear memory securely + memset_s(pdata, sizeof(p_shared_key->x), 0, ROUND_TO(length, 8)/8); + + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_share512_y); + ERROR_BREAK(ipp_ret); + memset(p_shared_key->y, 0, sizeof(p_shared_key->y)); + memcpy(p_shared_key->y, pdata, ROUND_TO(length, 8)/8); + // Clear memory securely + memset_s(pdata, sizeof(p_shared_key->x), 0, ROUND_TO(length, 8)/8); + }while(0); + + // Clear temp buffer before free. + if (point_pubA) memset_s(point_pubA, ecPointSize, 0, ecPointSize); + SAFE_FREE(point_pubA); + if (point_R) memset_s(point_R, ecPointSize, 0, ecPointSize); + SAFE_FREE(point_R); + sgx_ipp_secure_free_BN(pubA_gx, sizeof(p_public_ga->gx)); + sgx_ipp_secure_free_BN(pubA_gy, sizeof(p_public_ga->gy)); + sgx_ipp_secure_free_BN(BN_dh_privB, sizeof(sgx_ec256_private_t)); + sgx_ipp_secure_free_BN(BN_dh_share512_x, sizeof(sgx_ec256_dh_shared_t)); + sgx_ipp_secure_free_BN(BN_dh_share512_y, sizeof(sgx_ec256_dh_shared_t)); + + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} diff --git a/sdk/tlibcrypto/sgx_ecc256_common.cpp b/sdk/tlibcrypto/sgx_ecc256_common.cpp new file mode 100644 index 0000000000..6c5bdb994d --- /dev/null +++ b/sdk/tlibcrypto/sgx_ecc256_common.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_ecc256_common.h" + + +IppStatus sgx_ipp_newBN(const Ipp32u *p_data, int size_in_bytes, IppsBigNumState **p_new_BN) +{ + IppsBigNumState *pBN = 0; + int bn_size = 0; + + if (p_new_BN == NULL || (size_in_bytes <= 0) || ((size_in_bytes % sizeof(Ipp32u)) != 0)) + return ippStsBadArgErr; + + // Get the size of the IppsBigNumState context in bytes + IppStatus error_code = ippsBigNumGetSize(size_in_bytes/(int)sizeof(Ipp32u), &bn_size); + if (error_code != ippStsNoErr) + { + *p_new_BN = 0; + return error_code; + } + pBN = (IppsBigNumState *)malloc(bn_size); + if (!pBN) + { + error_code = ippStsMemAllocErr; + *p_new_BN = 0; + return error_code; + } + // Initialize context and partition allocated buffer + error_code = ippsBigNumInit(size_in_bytes/(int)sizeof(Ipp32u), pBN); + if (error_code != ippStsNoErr) + { + free(pBN); + *p_new_BN = 0; + return error_code; + } + if (p_data) + { + error_code = ippsSet_BN(IppsBigNumPOS, size_in_bytes/(int)sizeof(Ipp32u), p_data, pBN); + if (error_code != ippStsNoErr) + { + *p_new_BN = 0; + free(pBN); + return error_code; + } + } + + + *p_new_BN = pBN; + return error_code; +} + +void sgx_ipp_secure_free_BN(IppsBigNumState *pBN, int size_in_bytes) +{ + if (pBN == NULL || size_in_bytes <= 0 || ((size_in_bytes % sizeof(Ipp32u)) != 0)) + { + if (pBN) + { + free(pBN); + } + return; + } + int bn_size = 0; + + // Get the size of the IppsBigNumState context in bytes + // Since we have checked the size_in_bytes before and the &bn_size is not NULL, ippsBigNumGetSize never returns failure + IppStatus error_code = ippsBigNumGetSize(size_in_bytes/(int)sizeof(Ipp32u), &bn_size); + if (error_code != ippStsNoErr) + { + free(pBN); + return; + } + // Clear the buffer before free. + memset_s(pBN, bn_size, 0, bn_size); + free(pBN); + return; +} + +IppStatus __STDCALL sgx_ipp_DRNGen(Ipp32u* pRandBNU, int nBits, void* pCtx) +{ + sgx_status_t sgx_ret; + UNUSED(pCtx); + + if (0 != nBits % 8) + { + // Must be byte aligned + return ippStsSizeErr; + } + + if (!pRandBNU) + { + return ippStsNullPtrErr; + } + sgx_ret = sgx_read_rand((uint8_t*)pRandBNU, (uint32_t)nBits / 8); + if (SGX_SUCCESS != sgx_ret) + { + return ippStsErr; + } + return ippStsNoErr; +} diff --git a/sdk/tlibcrypto/sgx_ecc256_common.h b/sdk/tlibcrypto/sgx_ecc256_common.h new file mode 100644 index 0000000000..cf6512c81f --- /dev/null +++ b/sdk/tlibcrypto/sgx_ecc256_common.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _SGX_ECC256_COMMON_H_ +#define _SGX_ECC256_COMMON_H_ + +#include "sgx_trts.h" +#include "sgx_tcrypto.h" +#include "sgx_tcrypto_internal.h" +#include "ippcp.h" +#include "util.h" +#include "stdlib.h" +#include "string.h" + +#ifndef ERROR_BREAK +#define ERROR_BREAK(x) if(x != ippStsNoErr){break;} +#endif +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} +#endif + +IppStatus sgx_ipp_newBN(const Ipp32u *p_data, int size_in_bytes, IppsBigNumState **p_new_BN); +void sgx_ipp_secure_free_BN(IppsBigNumState *pBN, int size_in_bytes); +IppStatus __STDCALL sgx_ipp_DRNGen(Ipp32u* pRandBNU, int nBits, void* pCtx); + + + +static inline IppStatus check_copy_size(size_t target_size, size_t source_size) +{ + if(target_size < source_size) + return ippStsSizeErr; + return ippStsNoErr; +} + +#endif diff --git a/sdk/tlibcrypto/sgx_ecc256_ecdsa.cpp b/sdk/tlibcrypto/sgx_ecc256_ecdsa.cpp new file mode 100644 index 0000000000..dd5a6790a7 --- /dev/null +++ b/sdk/tlibcrypto/sgx_ecc256_ecdsa.cpp @@ -0,0 +1,299 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_ecc256_common.h" + + +const uint32_t sgx_nistp256_r[] = { + 0xFC632551, 0xF3B9CAC2, 0xA7179E84, 0xBCE6FAAD, 0xFFFFFFFF, 0xFFFFFFFF, + 0x00000000, 0xFFFFFFFF }; + + +/* Computes signature for data based on private key +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_private_t *p_private - Pointer to the private key - LITTLE ENDIAN +* sgx_uint8_t *p_data - Pointer to the data to be signed +* uint32_t data_size - Size of the data to be signed +* Output: sgx_ec256_signature_t *p_signature - Pointer to the signature - LITTLE ENDIAN */ +sgx_status_t sgx_ecdsa_sign(const uint8_t *p_data, + uint32_t data_size, + sgx_ec256_private_t *p_private, + sgx_ec256_signature_t *p_signature, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private == NULL) || (p_signature == NULL) || (p_data == NULL) || (data_size < 1)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppStatus ipp_ret = ippStsNoErr; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + IppsBigNumState* p_ecp_order = NULL; + IppsBigNumState* p_hash_bn = NULL; + IppsBigNumState* p_msg_bn = NULL; + IppsBigNumState* p_eph_priv_bn = NULL; + IppsECCPPointState* p_eph_pub = NULL; + IppsBigNumState* p_reg_priv_bn = NULL; + IppsBigNumState* p_signx_bn = NULL; + IppsBigNumState* p_signy_bn = NULL; + Ipp32u *p_sigx = NULL; + Ipp32u *p_sigy = NULL; + int ecp_size = 0; + const int order_size = sizeof(sgx_nistp256_r); + uint32_t hash[8] = { 0 }; + + do + { + + ipp_ret = sgx_ipp_newBN(sgx_nistp256_r, order_size, &p_ecp_order); + ERROR_BREAK(ipp_ret); + + // Prepare the message used to sign. + ipp_ret = ippsHashMessage(p_data, data_size, (Ipp8u*)hash, IPP_ALG_HASH_SHA256); + ERROR_BREAK(ipp_ret); + /* Byte swap in creation of Big Number from SHA256 hash output */ + ipp_ret = sgx_ipp_newBN(NULL, sizeof(hash), &p_hash_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsSetOctString_BN((Ipp8u*)hash, sizeof(hash), p_hash_bn); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_msg_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsMod_BN(p_hash_bn, p_ecp_order, p_msg_bn); + ERROR_BREAK(ipp_ret); + + // Get ephemeral key pair. + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_eph_priv_bn); + ERROR_BREAK(ipp_ret); + //init eccp point + ipp_ret = ippsECCPPointGetSize(256, &ecp_size); + ERROR_BREAK(ipp_ret); + p_eph_pub = (IppsECCPPointState*)(malloc(ecp_size)); + if (!p_eph_pub) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, p_eph_pub); + ERROR_BREAK(ipp_ret); + // Generate ephemeral key pair for signing operation + // Notice that IPP ensures the private key generated is non-zero + ipp_ret = ippsECCPGenKeyPair(p_eph_priv_bn, p_eph_pub, p_ecc_state, + (IppBitSupplier)sgx_ipp_DRNGen, NULL); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPSetKeyPair(p_eph_priv_bn, p_eph_pub, ippFalse, p_ecc_state); + ERROR_BREAK(ipp_ret); + + // Set the regular private key. + ipp_ret = sgx_ipp_newBN((uint32_t *)p_private->r, sizeof(p_private->r), + &p_reg_priv_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_signx_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_signy_bn); + ERROR_BREAK(ipp_ret); + + // Sign the message. + ipp_ret = ippsECCPSignDSA(p_msg_bn, p_reg_priv_bn, p_signx_bn, p_signy_bn, + p_ecc_state); + ERROR_BREAK(ipp_ret); + + IppsBigNumSGN sign; + int length; + ipp_ret = ippsRef_BN(&sign, &length,(Ipp32u**) &p_sigx, p_signx_bn); + ERROR_BREAK(ipp_ret); + memset(p_signature->x, 0, sizeof(p_signature->x)); + ipp_ret = check_copy_size(sizeof(p_signature->x), ROUND_TO(length, 8) / 8); + ERROR_BREAK(ipp_ret); + memcpy(p_signature->x, p_sigx, ROUND_TO(length, 8) / 8); + memset_s(p_sigx, sizeof(p_signature->x), 0, ROUND_TO(length, 8) / 8); + ipp_ret = ippsRef_BN(&sign, &length,(Ipp32u**) &p_sigy, p_signy_bn); + ERROR_BREAK(ipp_ret); + memset(p_signature->y, 0, sizeof(p_signature->y)); + ipp_ret = check_copy_size(sizeof(p_signature->y), ROUND_TO(length, 8) / 8); + ERROR_BREAK(ipp_ret); + memcpy(p_signature->y, p_sigy, ROUND_TO(length, 8) / 8); + memset_s(p_sigy, sizeof(p_signature->y), 0, ROUND_TO(length, 8) / 8); + } while (0); + + // Clear buffer before free. + if (p_eph_pub) + memset_s(p_eph_pub, ecp_size, 0, ecp_size); + SAFE_FREE(p_eph_pub); + sgx_ipp_secure_free_BN(p_ecp_order, order_size); + sgx_ipp_secure_free_BN(p_hash_bn, sizeof(hash)); + sgx_ipp_secure_free_BN(p_msg_bn, order_size); + sgx_ipp_secure_free_BN(p_eph_priv_bn, order_size); + sgx_ipp_secure_free_BN(p_reg_priv_bn, sizeof(p_private->r)); + sgx_ipp_secure_free_BN(p_signx_bn, order_size); + sgx_ipp_secure_free_BN(p_signy_bn, order_size); + + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + +/* Verifies the signature for the given data based on the public key +* +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_public_t *p_public - Pointer to the public key - LITTLE ENDIAN +* uint8_t *p_data - Pointer to the data to be signed +* uint32_t data_size - Size of the data to be signed +* sgx_ec256_signature_t *p_signature - Pointer to the signature - LITTLE ENDIAN +* Output: uint8_t *p_result - Pointer to the result of verification check */ +sgx_status_t sgx_ecdsa_verify(const uint8_t *p_data, + uint32_t data_size, + const sgx_ec256_public_t *p_public, + sgx_ec256_signature_t *p_signature, + uint8_t *p_result, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_public == NULL) || (p_signature == NULL) || + (p_data == NULL) || (data_size < 1) || (p_result == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppStatus ipp_ret = ippStsNoErr; + IppsECCPState* p_ecc_state = (IppsECCPState*)ecc_handle; + IppECResult result = ippECInvalidSignature; + *p_result = SGX_EC_INVALID_SIGNATURE; + + IppsBigNumState* p_ecp_order = NULL; + IppsBigNumState* p_hash_bn = NULL; + IppsBigNumState* p_msg_bn = NULL; + IppsECCPPointState* p_reg_pub = NULL; + IppsBigNumState* p_reg_pubx_bn = NULL; + IppsBigNumState* p_reg_puby_bn = NULL; + IppsBigNumState* p_signx_bn = NULL; + IppsBigNumState* p_signy_bn = NULL; + const int order_size = sizeof(sgx_nistp256_r); + uint32_t hash[8] = { 0 }; + int ecp_size = 0; + + do + { + ipp_ret = sgx_ipp_newBN(sgx_nistp256_r, order_size, &p_ecp_order); + ERROR_BREAK(ipp_ret); + + // Prepare the message used to sign. + ipp_ret = ippsHashMessage(p_data, data_size, (Ipp8u*)hash, IPP_ALG_HASH_SHA256); + ERROR_BREAK(ipp_ret); + /* Byte swap in creation of Big Number from SHA256 hash output */ + ipp_ret = sgx_ipp_newBN(NULL, sizeof(hash), &p_hash_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsSetOctString_BN((Ipp8u*)hash, sizeof(hash), p_hash_bn); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(NULL, order_size, &p_msg_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsMod_BN(p_hash_bn, p_ecp_order, p_msg_bn); + ERROR_BREAK(ipp_ret); + + //Init eccp point + ipp_ret = ippsECCPPointGetSize(256, &ecp_size); + ERROR_BREAK(ipp_ret); + p_reg_pub = (IppsECCPPointState*)(malloc(ecp_size)); + if (!p_reg_pub) + { + ipp_ret = ippStsNoMemErr; + break; + } + ipp_ret = ippsECCPPointInit(256, p_reg_pub); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((const uint32_t *)p_public->gx, sizeof(p_public->gx), + &p_reg_pubx_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN((const uint32_t *)p_public->gy, sizeof(p_public->gy), + &p_reg_puby_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPSetPoint(p_reg_pubx_bn, p_reg_puby_bn, p_reg_pub, + p_ecc_state); + ERROR_BREAK(ipp_ret); + ipp_ret = ippsECCPSetKeyPair(NULL, p_reg_pub, ippTrue, p_ecc_state); + ERROR_BREAK(ipp_ret); + + ipp_ret = sgx_ipp_newBN(p_signature->x, order_size, &p_signx_bn); + ERROR_BREAK(ipp_ret); + ipp_ret = sgx_ipp_newBN(p_signature->y, order_size, &p_signy_bn); + ERROR_BREAK(ipp_ret); + + // Verify the message. + ipp_ret = ippsECCPVerifyDSA(p_msg_bn, p_signx_bn, p_signy_bn, &result, + p_ecc_state); + ERROR_BREAK(ipp_ret); + } while (0); + + // Clear buffer before free. + if (p_reg_pub) + memset_s(p_reg_pub, ecp_size, 0, ecp_size); + SAFE_FREE(p_reg_pub); + sgx_ipp_secure_free_BN(p_ecp_order, order_size); + sgx_ipp_secure_free_BN(p_hash_bn, sizeof(hash)); + sgx_ipp_secure_free_BN(p_msg_bn, order_size); + sgx_ipp_secure_free_BN(p_reg_pubx_bn, sizeof(p_public->gx)); + sgx_ipp_secure_free_BN(p_reg_puby_bn, sizeof(p_public->gy)); + sgx_ipp_secure_free_BN(p_signx_bn, order_size); + sgx_ipp_secure_free_BN(p_signy_bn, order_size); + + switch (result) { + case ippECValid: *p_result = SGX_EC_VALID; break; /* validation pass successfully */ + case ippECInvalidSignature: *p_result = SGX_EC_INVALID_SIGNATURE; break; /* invalid signature */ + default: *p_result = SGX_EC_INVALID_SIGNATURE; break; + } + + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNoMemErr: + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: + case ippStsOutOfRangeErr: + case ippStsSizeErr: + case ippStsBadArgErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} diff --git a/sdk/tlibcrypto/sgx_sha256.cpp b/sdk/tlibcrypto/sgx_sha256.cpp new file mode 100644 index 0000000000..8edc2ab1ea --- /dev/null +++ b/sdk/tlibcrypto/sgx_sha256.cpp @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tcrypto.h" +#include "ippcp.h" +#include "stdlib.h" + +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} +#endif + + +/* Allocates and initializes sha256 state +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Output: sgx_sha_state_handle_t *p_sha_handle - Pointer to the handle of the SHA256 state */ +sgx_status_t sgx_sha256_init(sgx_sha_state_handle_t* p_sha_handle) +{ + IppStatus ipp_ret = ippStsNoErr; + IppsHashState* p_temp_state = NULL; + + if (p_sha_handle == NULL) + return SGX_ERROR_INVALID_PARAMETER; + + int ctx_size = 0; + ipp_ret = ippsHashGetSize(&ctx_size); + if (ipp_ret != ippStsNoErr) + return SGX_ERROR_UNEXPECTED; + p_temp_state = (IppsHashState*)(malloc(ctx_size)); + if (p_temp_state == NULL) + return SGX_ERROR_OUT_OF_MEMORY; + ipp_ret = ippsHashInit(p_temp_state, IPP_ALG_HASH_SHA256); + if (ipp_ret != ippStsNoErr) + { + SAFE_FREE(p_temp_state); + *p_sha_handle = NULL; + switch (ipp_ret) + { + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } + } + + *p_sha_handle = p_temp_state; + return SGX_SUCCESS; +} + +/* Updates sha256 has calculation based on the input message +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error. +* Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state +* uint8_t *p_src - Pointer to the input stream to be hashed +* uint32_t src_len - Length of the input stream to be hashed */ +sgx_status_t sgx_sha256_update(const uint8_t *p_src, uint32_t src_len, sgx_sha_state_handle_t sha_handle) +{ + if ((p_src == NULL) || (sha_handle == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + IppStatus ipp_ret = ippStsNoErr; + ipp_ret = ippsHashUpdate(p_src, src_len, (IppsHashState*)sha_handle); + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + +/* Returns Hash calculation +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state +* Output: sgx_sha256_hash_t *p_hash - Resultant hash from operation */ +sgx_status_t sgx_sha256_get_hash(sgx_sha_state_handle_t sha_handle, sgx_sha256_hash_t *p_hash) +{ + if ((sha_handle == NULL) || (p_hash == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + IppStatus ipp_ret = ippStsNoErr; + ipp_ret = ippsHashGetTag((Ipp8u*)p_hash, SGX_SHA256_HASH_SIZE, (IppsHashState*)sha_handle); + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} + +/* Cleans up sha state +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state */ +sgx_status_t sgx_sha256_close(sgx_sha_state_handle_t sha_handle) +{ + if (sha_handle == NULL) + { + return SGX_ERROR_INVALID_PARAMETER; + } + SAFE_FREE(sha_handle); + return SGX_SUCCESS; +} diff --git a/sdk/tlibcrypto/sgx_sha256_msg.cpp b/sdk/tlibcrypto/sgx_sha256_msg.cpp new file mode 100644 index 0000000000..a8d9a04d9e --- /dev/null +++ b/sdk/tlibcrypto/sgx_sha256_msg.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tcrypto.h" +#include "ippcp.h" +#include "stdlib.h" + +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} +#endif + + +/* SHA Hashing functions +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: uint8_t *p_src - Pointer to input stream to be hashed +* uint32_t src_len - Length of input stream to be hashed +* Output: sgx_sha256_hash_t *p_hash - Resultant hash from operation */ +sgx_status_t sgx_sha256_msg(const uint8_t *p_src, uint32_t src_len, sgx_sha256_hash_t *p_hash) +{ + if ((p_src == NULL) || (p_hash == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + IppStatus ipp_ret = ippStsNoErr; + ipp_ret = ippsHashMessage((const Ipp8u *) p_src, src_len, (Ipp8u *)p_hash, IPP_ALG_HASH_SHA256); + switch (ipp_ret) + { + case ippStsNoErr: return SGX_SUCCESS; + case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY; + case ippStsNullPtrErr: + case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER; + default: return SGX_ERROR_UNEXPECTED; + } +} diff --git a/sdk/tlibcrypto/tcrypto_version.cpp b/sdk/tlibcrypto/tcrypto_version.cpp new file mode 100644 index 0000000000..609f08b610 --- /dev/null +++ b/sdk/tlibcrypto/tcrypto_version.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_TCRYPTO_VERSION_STR __CONCAT("SGX_TCRYPTO_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_tcrypto_version = SGX_TCRYPTO_VERSION_STR; + +#ifdef __cplusplus +} +#endif diff --git a/sdk/tlibstdcxx/Makefile b/sdk/tlibstdcxx/Makefile new file mode 100644 index 0000000000..e35a394d08 --- /dev/null +++ b/sdk/tlibstdcxx/Makefile @@ -0,0 +1,60 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + + +include ../../buildenv.mk + +CPPFLAGS += -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/tlibc \ + -I./stlport + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) + +SRCS := src/string.cpp \ + src/complex.cpp \ + src/complex_trig.cpp + +OBJS := $(SRCS:.cpp=.o) + +LIBNAME_AR = libtlibstdcxx.a + +.PHONY:all +all: $(LIBNAME_AR) + +$(LIBNAME_AR): $(OBJS) + $(AR) rcs $(LIBNAME_AR) $^ + +$(OBJS): %.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + @$(RM) $(LIBNAME_AR) $(OBJS) diff --git a/sdk/tlibstdcxx/README.sgx b/sdk/tlibstdcxx/README.sgx new file mode 100644 index 0000000000..a74551a45c --- /dev/null +++ b/sdk/tlibstdcxx/README.sgx @@ -0,0 +1,22 @@ +Version: 5.2.1 + +Changes: + + * Move unsupported STL headers to stlport/deprecated folder + * Do not include ctime in stlport_prefix.h + * Inlude __Named_exception imple. in stlport static library + * Fix warnings under MSVC and GCC, and most of them are issues of unused parameters + * Use sgx_read_rand for generating rand numbers + * Replace unique(...) in _algo.h with LLVM imple. + * Add no storage (zero-length) bitset in _bitset.h + * Disable features rely on I/O operations + * Disable wchar support + * Define _NOTHREADS, _STLP_NO_THREADS, _STLP_USE_NEWALLOC, _STLP_NO_EXTENSIONS by default + * Use SGX C++ runtime library instead + * Disable unsupported data types and interfaces in _cstdio.h, _cstdlib.h, _ctime.h, _cwchar.h, etc. + * Add using _STLP_VENDOR_EXCEPT_STD::bad_alloc + * Let _STLP_THROW_BAD_ALLOC call _STLP_ABORT() directly, do not use puts() and exit(1) + * Do not use puts() in _STLP_THROW_MSG() + * Use SGX spinlock instead + * Add _sgx.h for SGX configurations + * Do not include Windows/Linux system headers directly diff --git a/sdk/tlibstdcxx/etc/stlport.natvis b/sdk/tlibstdcxx/etc/stlport.natvis new file mode 100755 index 0000000000..57d1a44b21 --- /dev/null +++ b/sdk/tlibstdcxx/etc/stlport.natvis @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + {_M_start_of_storage._M_data, s} + _M_start_of_storage._M_data, s + + _M_start_of_storage._M_data, s + _M_finish - _M_start_of_storage._M_data + _DEFAULT_SIZE + _M_buffers._M_end_of_storage - _M_start_of_storage._M_data + + _M_finish - _M_start_of_storage._M_data + _M_start_of_storage._M_data + + + + + + + + + + + + + + + + + + + + + {_M_start_of_storage._M_data, su} + _M_start_of_storage._M_data, su + + _M_start_of_storage._M_data, su + _M_finish - _M_start_of_storage._M_data + _DEFAULT_SIZE + _M_buffers._M_end_of_storage - _M_start_of_storage._M_data + + _M_finish - _M_start_of_storage._M_data + _M_start_of_storage._M_data + + + + + + + + + {_M_non_dbg_impl} + _M_non_dbg_impl + + _M_non_dbg_impl + + + + + + + + + + + + + {{ size = {(_M_finish._M_p - _M_start._M_p) * sizeof(unsigned int) * 8 + _M_finish._M_offset} }} + + _M_start._M_p, x + (_M_finish._M_p - _M_start._M_p) * sizeof(unsigned int) * 8 + _M_finish._M_offset + + + (_M_finish._M_p - _M_start._M_p) * sizeof(unsigned int) * 8 + _M_finish._M_offset + (bool)((_M_start._M_p[$i / (sizeof(unsigned int) * 8)] >> ($i % (sizeof(unsigned int) * 8))) & 1) + + + + + + + + + + + + + {(bool)(((*_M_p) >> _M_offset) & 1)} + + (bool)(((*_M_p) >> _M_offset) & 1) + + + + + + + + + + + + {{ size = {_M_finish - _M_start} }} + + _M_finish - _M_start + _M_end_of_storage._M_data - _M_start + + _M_finish - _M_start + _M_start + + + + + + + + + {_M_non_dbg_impl} + + _M_non_dbg_impl + + + + + + + + + + + + + + {{ size = {((_M_finish._M_node - _M_start._M_node + 1) * (_MAX_BYTES / sizeof($T1))) - (_M_start._M_cur - _M_start._M_first) - (_M_finish._M_last - _M_finish._M_cur)} }} + {{ size = {_M_finish._M_node - _M_start._M_node} }} + + ((_M_finish._M_node - _M_start._M_node + 1) * (_MAX_BYTES / sizeof($T1))) - (_M_start._M_cur - _M_start._M_first) - (_M_finish._M_last - _M_finish._M_cur) + _M_finish._M_node - _M_start._M_node + (_M_finish._M_node - _M_start._M_node + 1) * (_MAX_BYTES / sizeof($T1)) - 1 + _M_finish._M_node - _M_start._M_node + + ((_M_finish._M_node - _M_start._M_node + 1) * (_MAX_BYTES / sizeof($T1))) - (_M_start._M_cur - _M_start._M_first) - (_M_finish._M_last - _M_finish._M_cur) + _M_finish._M_node - _M_start._M_node + *(*(_M_start._M_node + (($i + (_M_start._M_cur - _M_start._M_first)) / (_MAX_BYTES / sizeof($T1)))) + (($i + (_M_start._M_cur - _M_start._M_first)) % (_MAX_BYTES / sizeof($T1)))) + **(_M_start._M_node + $i) + + + + + + + + + + + + + {*_M_cur} + + _M_cur, x + *(_M_cur) + + + + + + + + {_M_non_dbg_impl} + + _M_non_dbg_impl + + + + + + + + + + + + + {{ size= ':(' }} + + + + _M_node._M_data._M_next + _M_next + *($T1 *)(this + 1) + + + + + + + + + + + + + {*($T1 *)(_M_node + 1)} + + ($T1 *)(_M_node + 1), x + *($T1 *)(_M_node + 1) + + + + + + + + {_M_non_dbg_impl} + + _M_non_dbg_impl + + + + + + + + + + + + + + + ({first}, {second}) + + first + second + + + + + + + + + + + + + + + + + + + + + {{ size = {_M_t._M_node_count} }} + + _M_t._M_node_count + _M_t + + + + + + + + + + + + + + + + + + + + {{ size = {_M_t._M_non_dbg_impl._M_node_count} }} + + _M_t._M_non_dbg_impl._M_node_count + _M_t._M_non_dbg_impl + + + + + + + + + + + + + + {*($T3 *)(&(_M_header._M_data) + 1)} + + + _M_node_count + _M_header._M_data._M_parent + _M_left + _M_right + *($T3 *)(this + 1) + + + + + + + + + + + + + {*($T1 *)(_M_node + 1)} + + ($T1 *)(_M_node + 1), x + *($T1 *)(_M_node + 1) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {c} + + c + + + + + + + + + + + + + {_M_iterator} + {"undefined"} + + _M_iterator + true + false + + + + + + + + + + + + + {{ size = {$T1} }} + + + $T1 + (((_WordT)_M_w) >> ($i % (sizeof(_WordT) * 8))) & 1, d + + + $T1 + (((_WordT *)_M_w)[$i / (sizeof(_WordT) * 8)] >> ($i % (sizeof(_WordT) * 8))) & 1, d + + + + + + + + + + + + + {{ size = 0 }} + + + + + + + + + + + + + + {(*(_M_wp) >> _M_bpos) & 1, d} + + _M_wp + _M_bpos + + + + + + + + + + + + + + {*($T1 *)_M_p} + {"null"} + + ($T1 *)_M_p, x + *($T1 *)_M_p + + + + + + + + + + + + + {_M_re} + {_M_re}+i*{_M_im} + {_M_re}-i*{-_M_im} + i*{_M_im} + -i*{-_M_im} + + _M_re + _M_im + + + + + + + + + + + + + {{ size = {_M_size} }} + + + _M_size + _M_first + + + + + + + + + + + + + {{ start = {_M_start}, size = {_M_length}, stride = {_M_stride} }} + + _M_start + _M_length + _M_stride + + + + + + + + + + + + {{ start = {_M_start}, sizes = {_M_lengths}, strides = {_M_strides} }} + + _M_start + _M_lengths + _M_strides + + + + diff --git a/sdk/tlibstdcxx/src/_stdio_file.h b/sdk/tlibstdcxx/src/_stdio_file.h new file mode 100644 index 0000000000..d913fc4484 --- /dev/null +++ b/sdk/tlibstdcxx/src/_stdio_file.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STDIO_FILE_H +#define _STLP_STDIO_FILE_H + +/* This file provides a low-level interface between the internal + * representation of struct FILE, from the C stdio library, and + * the C++ I/O library. */ + +#ifndef _STLP_CSTDIO +# include +#endif +#ifndef _STLP_CSTDDEF +# include +#endif + +#if defined (__MSL__) +# include /* get the definition of fileno */ +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_WCE) + +inline int _FILE_fd(const FILE *__f) { + /* Check if FILE is one of the three standard streams + We do this check first, because invoking _fileno() on one of them + causes a terminal window to be created. This also happens if you do + any IO on them, but merely retrieving the filedescriptor shouldn't + already do that. + + Obviously this is pretty implementation-specific because it requires + that indeed the first three FDs are always the same, but that is not + only common but almost guaranteed. */ + for (int __fd = 0; __fd != 3; ++__fd) { + if (__f == _getstdfilex(__fd)) + return __fd; + } + + /* Normal files. */ + return (int)::_fileno((FILE*)__f); +} + +# elif defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR) + +inline int _FILE_fd(const FILE *__f) { return __f->__file; } + +# elif defined (__sun) && defined (_LP64) + +inline int _FILE_fd(const FILE *__f) { return (int) __f->__pad[2]; } + +#elif defined (__hpux) /* && defined(__hppa) && defined(__HP_aCC)) */ || \ + defined (__MVS__) || \ + defined (_STLP_USE_UCLIBC) /* should be before _STLP_USE_GLIBC */ + +inline int _FILE_fd(const FILE *__f) { return fileno(__CONST_CAST(FILE*, __f)); } + +#elif defined (_STLP_USE_GLIBC) + +inline int _FILE_fd(const FILE *__f) { return __f->_fileno; } + +#elif defined (__BORLANDC__) + +inline int _FILE_fd(const FILE *__f) { return __f->fd; } + +#elif defined (__MWERKS__) + +/* using MWERKS-specific defines here to detect other OS targets + * dwa: I'm not sure they provide fileno for all OS's, but this should + * work for Win32 and WinCE + + * Hmm, at least for Novell NetWare __dest_os == __mac_os true too.. + * May be both __dest_os and __mac_os defined and empty? - ptr */ +# if __dest_os == __mac_os +inline int _FILE_fd(const FILE *__f) { return ::fileno(__CONST_CAST(FILE*, __f)); } +# else +inline int _FILE_fd(const FILE *__f) { return ::_fileno(__CONST_CAST(FILE*, __f)); } +# endif + +#elif defined (__QNXNTO__) || defined (__WATCOMC__) || defined (__EMX__) + +inline int _FILE_fd(const FILE *__f) { return __f->_handle; } + +#elif defined (__Lynx__) + +/* the prototypes are taken from LynxOS patch for STLport 4.0 */ +inline int _FILE_fd(const FILE *__f) { return __f->_fd; } + +#else /* The most common access to file descriptor. */ + +inline int _FILE_fd(const FILE *__f) { return __f->_file; } + +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_STDIO_FILE_H */ + +/* Local Variables: + * mode:C++ + * End: */ diff --git a/sdk/tlibstdcxx/src/acquire_release.h b/sdk/tlibstdcxx/src/acquire_release.h new file mode 100644 index 0000000000..5ea73da1a1 --- /dev/null +++ b/sdk/tlibstdcxx/src/acquire_release.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef ACQUIRE_RELEASE_H +#define ACQUIRE_RELEASE_H + +#include "c_locale.h" + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +_Locale_ctype* _STLP_CALL __acquire_ctype(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code); +_Locale_codecvt* _STLP_CALL __acquire_codecvt(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code); +_Locale_numeric* _STLP_CALL __acquire_numeric(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code); +_Locale_collate* _STLP_CALL __acquire_collate(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code); +_Locale_monetary* _STLP_CALL __acquire_monetary(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code); +_Locale_time* _STLP_CALL __acquire_time(const char* &name, char *buf, _Locale_name_hint*, int *__err_code); +_Locale_messages* _STLP_CALL __acquire_messages(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code); + +void _STLP_CALL __release_ctype(_Locale_ctype* cat); +void _STLP_CALL __release_codecvt(_Locale_codecvt* cat); +void _STLP_CALL __release_numeric(_Locale_numeric* cat); +void _STLP_CALL __release_collate(_Locale_collate* cat); +void _STLP_CALL __release_monetary(_Locale_monetary* cat); +void _STLP_CALL __release_time(_Locale_time* __time); +void _STLP_CALL __release_messages(_Locale_messages* cat); + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#endif /* ACQUIRE_RELEASE_H */ diff --git a/sdk/tlibstdcxx/src/aligned_buffer.h b/sdk/tlibstdcxx/src/aligned_buffer.h new file mode 100644 index 0000000000..6ff6ca6b90 --- /dev/null +++ b/sdk/tlibstdcxx/src/aligned_buffer.h @@ -0,0 +1,21 @@ +#ifndef ALIGNED_BUFFER_H +#define ALIGNED_BUFFER_H + +_STLP_BEGIN_NAMESPACE +// this is for fake initialization +template +union _Stl_aligned_buffer { + char buf[sizeof(T)]; + struct { double a; double b; } padding; + + T* operator&() { + return __REINTERPRET_CAST(T*, this); + } + + T const* operator&() const { + return __REINTERPRET_CAST(T const*, this); + } +}; +_STLP_END_NAMESPACE + +#endif diff --git a/sdk/tlibstdcxx/src/allocators.cpp b/sdk/tlibstdcxx/src/allocators.cpp new file mode 100644 index 0000000000..8bbcca86ba --- /dev/null +++ b/sdk/tlibstdcxx/src/allocators.cpp @@ -0,0 +1,1121 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include + +#if defined (__GNUC__) && (defined (__CYGWIN__) || defined (__MINGW32__)) +# include +#endif + +#if defined (_STLP_PTHREADS) && !defined (_STLP_NO_THREADS) +# include +# include +#endif + +#include + +#include "lock_free_slist.h" + +#if defined (__WATCOMC__) +# pragma warning 13 9 +# pragma warning 367 9 +# pragma warning 368 9 +#endif + +#if defined (_STLP_SGI_THREADS) + // We test whether threads are in use before locking. + // Perhaps this should be moved into stl_threads.h, but that + // probably makes it harder to avoid the procedure call when + // it isn't needed. +extern "C" { + extern int __us_rsthread_malloc; +} +#endif + +// Specialised debug form of new operator which does not provide "false" +// memory leaks when run with debug CRT libraries. +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1020 && defined (_STLP_DEBUG_ALLOC)) && !defined (_STLP_WCE) +# include +inline char* __stlp_new_chunk(size_t __bytes) { + void *__chunk = _STLP_CHECK_NULL_ALLOC(::operator new(__bytes, __FILE__, __LINE__)); + return __STATIC_CAST(char*, __chunk); +} +inline void __stlp_delete_chunck(void* __p) { ::operator delete(__p, __FILE__, __LINE__); } +#else +# ifdef _STLP_NODE_ALLOC_USE_MALLOC +# include +inline char* __stlp_new_chunk(size_t __bytes) { + // do not use _STLP_CHECK_NULL_ALLOC, this macro is dedicated to new operator. + void *__chunk = _STLP_VENDOR_CSTD::malloc(__bytes); + if (__chunk == 0) { + _STLP_THROW_BAD_ALLOC; + } + return __STATIC_CAST(char*, __chunk); +} +inline void __stlp_delete_chunck(void* __p) { _STLP_VENDOR_CSTD::free(__p); } +# else +inline char* __stlp_new_chunk(size_t __bytes) +{ return __STATIC_CAST(char*, _STLP_STD::__stl_new(__bytes)); } +inline void __stlp_delete_chunck(void* __p) { _STLP_STD::__stl_delete(__p); } +# endif +#endif + +/* This is an additional atomic operations to the ones already defined in + * stl/_threads.h, platform should try to support it to improve performance. + * __add_atomic_t _STLP_ATOMIC_ADD(volatile __add_atomic_t* __target, __add_atomic_t __val) : + * does *__target = *__target + __val and returns the old *__target value */ +typedef long __add_atomic_t; +typedef unsigned long __uadd_atomic_t; + +#if defined (__GNUC__) && defined (__i386__) +inline long _STLP_atomic_add_gcc_x86(long volatile* p, long addend) { + long result; + __asm__ __volatile__ + ("lock; xaddl %1, %0;" + :"=m" (*p), "=r" (result) + :"m" (*p), "1" (addend) + :"cc"); + return result + addend; +} +# define _STLP_ATOMIC_ADD(__dst, __val) _STLP_atomic_add_gcc_x86(__dst, __val) +#elif defined (_STLP_WIN32THREADS) +// The Win32 API function InterlockedExchangeAdd is not available on Windows 95. +# if !defined (_STLP_WIN95_LIKE) +# if defined (_STLP_NEW_PLATFORM_SDK) +# define _STLP_ATOMIC_ADD(__dst, __val) InterlockedExchangeAdd(__dst, __val) +# else +# define _STLP_ATOMIC_ADD(__dst, __val) InterlockedExchangeAdd(__CONST_CAST(__add_atomic_t*, __dst), __val) +# endif +# endif +#endif + +#if defined (__OS400__) +// dums 02/05/2007: is it really necessary ? +enum { _ALIGN = 16, _ALIGN_SHIFT = 4 }; +#else +enum { _ALIGN = 2 * sizeof(void*), _ALIGN_SHIFT = 2 + sizeof(void*) / 4 }; +#endif + +#define _S_FREELIST_INDEX(__bytes) ((__bytes - size_t(1)) >> (int)_ALIGN_SHIFT) + +_STLP_BEGIN_NAMESPACE + +// malloc_alloc out-of-memory handling +static __oom_handler_type __oom_handler = __STATIC_CAST(__oom_handler_type, 0); + +#ifdef _STLP_THREADS +_STLP_mutex __oom_handler_lock; +#endif + +void* _STLP_CALL __malloc_alloc::allocate(size_t __n) +{ + void *__result = malloc(__n); + if ( 0 == __result ) { + __oom_handler_type __my_malloc_handler; + + for (;;) { + { +#ifdef _STLP_THREADS + _STLP_auto_lock _l( __oom_handler_lock ); +#endif + __my_malloc_handler = __oom_handler; + } + if ( 0 == __my_malloc_handler) { + _STLP_THROW_BAD_ALLOC; + } + (*__my_malloc_handler)(); + __result = malloc(__n); + if ( __result ) + return __result; + } + } + return __result; +} + +__oom_handler_type _STLP_CALL __malloc_alloc::set_malloc_handler(__oom_handler_type __f) +{ +#ifdef _STLP_THREADS + _STLP_auto_lock _l( __oom_handler_lock ); +#endif + __oom_handler_type __old = __oom_handler; + __oom_handler = __f; + return __old; +} + +// ******************************************************* +// Default node allocator. +// With a reasonable compiler, this should be roughly as fast as the +// original STL class-specific allocators, but with less fragmentation. +// +// Important implementation properties: +// 1. If the client request an object of size > _MAX_BYTES, the resulting +// object will be obtained directly from malloc. +// 2. In all other cases, we allocate an object of size exactly +// _S_round_up(requested_size). Thus the client has enough size +// information that we can return the object to the proper free list +// without permanently losing part of the object. +// + +#define _STLP_NFREELISTS 16 + +#if defined (_STLP_LEAKS_PEDANTIC) && defined (_STLP_USE_DYNAMIC_LIB) +/* + * We can only do cleanup of the node allocator memory pool if we are + * sure that the STLport library is used as a shared one as it guaranties + * the unicity of the node allocator instance. Without that guaranty node + * allocator instances might exchange memory blocks making the implementation + * of a cleaning process much more complicated. + */ +# define _STLP_DO_CLEAN_NODE_ALLOC +#endif + +/* When STLport is used without multi threaded safety we use the node allocator + * implementation with locks as locks becomes no-op. The lock free implementation + * always use system specific atomic operations which are slower than 'normal' + * ones. + */ +#if defined (_STLP_THREADS) && \ + defined (_STLP_HAS_ATOMIC_FREELIST) && defined (_STLP_ATOMIC_ADD) +/* + * We have an implementation of the atomic freelist (_STLP_atomic_freelist) + * for this architecture and compiler. That means we can use the non-blocking + * implementation of the node-allocation engine.*/ +# define _STLP_USE_LOCK_FREE_IMPLEMENTATION +#endif + +#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) +# if defined (_STLP_THREADS) + +class _Node_Alloc_Lock { + static _STLP_STATIC_MUTEX& _S_Mutex() { + static _STLP_STATIC_MUTEX mutex _STLP_MUTEX_INITIALIZER; + return mutex; + } +public: + _Node_Alloc_Lock() { +# if defined (_STLP_SGI_THREADS) + if (__us_rsthread_malloc) +# endif + _S_Mutex()._M_acquire_lock(); + } + + ~_Node_Alloc_Lock() { +# if defined (_STLP_SGI_THREADS) + if (__us_rsthread_malloc) +# endif + _S_Mutex()._M_release_lock(); + } +}; + +# else + +class _Node_Alloc_Lock { +public: + _Node_Alloc_Lock() { } + ~_Node_Alloc_Lock() { } +}; + +# endif + +struct _Node_alloc_obj { + _Node_alloc_obj * _M_next; +}; +#endif + +class __node_alloc_impl { + static inline size_t _STLP_CALL _S_round_up(size_t __bytes) + { return (((__bytes) + (size_t)_ALIGN-1) & ~((size_t)_ALIGN - 1)); } + +#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) + typedef _STLP_atomic_freelist::item _Obj; + typedef _STLP_atomic_freelist _Freelist; + typedef _STLP_atomic_freelist _ChunkList; + + // Header of blocks of memory that have been allocated as part of + // a larger chunk but have not yet been chopped up into nodes. + struct _FreeBlockHeader : public _STLP_atomic_freelist::item { + char* _M_end; // pointer to end of free memory + }; +#else + typedef _Node_alloc_obj _Obj; + typedef _Obj* _STLP_VOLATILE _Freelist; + typedef _Obj* _ChunkList; +#endif + +private: + // Returns an object of size __n, and optionally adds to size __n free list. + static _Obj* _S_refill(size_t __n); + // Allocates a chunk for nobjs of size __p_size. nobjs may be reduced + // if it is inconvenient to allocate the requested number. + static char* _S_chunk_alloc(size_t __p_size, int& __nobjs); + // Chunk allocation state. + static _Freelist _S_free_list[_STLP_NFREELISTS]; + // Amount of total allocated memory +#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) + static _STLP_VOLATILE __add_atomic_t _S_heap_size; +#else + static size_t _S_heap_size; +#endif + +#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) + // List of blocks of free memory + static _STLP_atomic_freelist _S_free_mem_blocks; +#else + // Start of the current free memory buffer + static char* _S_start_free; + // End of the current free memory buffer + static char* _S_end_free; +#endif + +#if defined (_STLP_DO_CLEAN_NODE_ALLOC) +public: + // Methods to report alloc/dealloc calls to the counter system. +# if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) + typedef _STLP_VOLATILE __stl_atomic_t _AllocCounter; +# else + typedef __stl_atomic_t _AllocCounter; +# endif + static _AllocCounter& _STLP_CALL _S_alloc_counter(); + static void _S_alloc_call(); + static void _S_dealloc_call(); + +private: + // Free all the allocated chuncks of memory + static void _S_chunk_dealloc(); + // Beginning of the linked list of allocated chunks of memory + static _ChunkList _S_chunks; +#endif /* _STLP_DO_CLEAN_NODE_ALLOC */ + +public: + /* __n must be > 0 */ + static void* _M_allocate(size_t& __n); + /* __p may not be 0 */ + static void _M_deallocate(void *__p, size_t __n); +}; + +#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) +void* __node_alloc_impl::_M_allocate(size_t& __n) { + __n = _S_round_up(__n); + _Obj * _STLP_VOLATILE * __my_free_list = _S_free_list + _S_FREELIST_INDEX(__n); + _Obj *__r; + + // Acquire the lock here with a constructor call. + // This ensures that it is released in exit or during stack + // unwinding. + _Node_Alloc_Lock __lock_instance; + + if ( (__r = *__my_free_list) != 0 ) { + *__my_free_list = __r->_M_next; + } else { + __r = _S_refill(__n); + } +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) + _S_alloc_call(); +# endif + // lock is released here + return __r; +} + +void __node_alloc_impl::_M_deallocate(void *__p, size_t __n) { + _Obj * _STLP_VOLATILE * __my_free_list = _S_free_list + _S_FREELIST_INDEX(__n); + _Obj * __pobj = __STATIC_CAST(_Obj*, __p); + + // acquire lock + _Node_Alloc_Lock __lock_instance; + __pobj->_M_next = *__my_free_list; + *__my_free_list = __pobj; + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) + _S_dealloc_call(); +# endif + // lock is released here +} + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) +# define _STLP_OFFSET sizeof(_Obj) +# else +# define _STLP_OFFSET 0 +# endif + +/* We allocate memory in large chunks in order to avoid fragmenting */ +/* the malloc heap too much. */ +/* We assume that size is properly aligned. */ +/* We hold the allocation lock. */ +char* __node_alloc_impl::_S_chunk_alloc(size_t _p_size, int& __nobjs) { + char* __result; + size_t __total_bytes = _p_size * __nobjs; + size_t __bytes_left = _S_end_free - _S_start_free; + + if (__bytes_left > 0) { + if (__bytes_left >= __total_bytes) { + __result = _S_start_free; + _S_start_free += __total_bytes; + return __result; + } + + if (__bytes_left >= _p_size) { + __nobjs = (int)(__bytes_left / _p_size); + __total_bytes = _p_size * __nobjs; + __result = _S_start_free; + _S_start_free += __total_bytes; + return __result; + } + + // Try to make use of the left-over piece. + _Obj* _STLP_VOLATILE* __my_free_list = _S_free_list + _S_FREELIST_INDEX(__bytes_left); + __REINTERPRET_CAST(_Obj*, _S_start_free)->_M_next = *__my_free_list; + *__my_free_list = __REINTERPRET_CAST(_Obj*, _S_start_free); + _S_start_free = _S_end_free = 0; + } + + size_t __bytes_to_get = 2 * __total_bytes + _S_round_up(_S_heap_size) + _STLP_OFFSET; + + _STLP_TRY { + _S_start_free = __stlp_new_chunk(__bytes_to_get); + } +#if defined (_STLP_USE_EXCEPTIONS) + catch (const _STLP_STD::bad_alloc&) { + _Obj* _STLP_VOLATILE* __my_free_list; + _Obj* __p; + // Try to do with what we have. That can't hurt. + // We do not try smaller requests, since that tends + // to result in disaster on multi-process machines. + for (size_t __i = _p_size; __i <= (size_t)_MAX_BYTES; __i += (size_t)_ALIGN) { + __my_free_list = _S_free_list + _S_FREELIST_INDEX(__i); + __p = *__my_free_list; + if (0 != __p) { + *__my_free_list = __p -> _M_next; + _S_start_free = __REINTERPRET_CAST(char*, __p); + _S_end_free = _S_start_free + __i; + return _S_chunk_alloc(_p_size, __nobjs); + // Any leftover piece will eventually make it to the + // right free list. + } + } + __bytes_to_get = __total_bytes + _STLP_OFFSET; + _S_start_free = __stlp_new_chunk(__bytes_to_get); + } +#endif + + _S_heap_size += __bytes_to_get >> 4; +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) + __REINTERPRET_CAST(_Obj*, _S_start_free)->_M_next = _S_chunks; + _S_chunks = __REINTERPRET_CAST(_Obj*, _S_start_free); +# endif + _S_end_free = _S_start_free + __bytes_to_get; + _S_start_free += _STLP_OFFSET; + return _S_chunk_alloc(_p_size, __nobjs); +} + +/* Returns an object of size __n, and optionally adds to size __n free list.*/ +/* We assume that __n is properly aligned. */ +/* We hold the allocation lock. */ +_Node_alloc_obj* __node_alloc_impl::_S_refill(size_t __n) { + int __nobjs = 20; + char* __chunk = _S_chunk_alloc(__n, __nobjs); + + if (1 == __nobjs) return __REINTERPRET_CAST(_Obj*, __chunk); + + _Obj* _STLP_VOLATILE* __my_free_list = _S_free_list + _S_FREELIST_INDEX(__n); + _Obj* __result; + _Obj* __current_obj; + _Obj* __next_obj; + + /* Build free list in chunk */ + __result = __REINTERPRET_CAST(_Obj*, __chunk); + *__my_free_list = __next_obj = __REINTERPRET_CAST(_Obj*, __chunk + __n); + for (--__nobjs; --__nobjs; ) { + __current_obj = __next_obj; + __next_obj = __REINTERPRET_CAST(_Obj*, __REINTERPRET_CAST(char*, __next_obj) + __n); + __current_obj->_M_next = __next_obj; + } + __next_obj->_M_next = 0; + return __result; +} + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) +void __node_alloc_impl::_S_alloc_call() +{ ++_S_alloc_counter(); } + +void __node_alloc_impl::_S_dealloc_call() { + __stl_atomic_t &counter = _S_alloc_counter(); + if (--counter == 0) + { _S_chunk_dealloc(); } +} + +/* We deallocate all the memory chunks */ +void __node_alloc_impl::_S_chunk_dealloc() { + _Obj *__pcur = _S_chunks, *__pnext; + while (__pcur != 0) { + __pnext = __pcur->_M_next; + __stlp_delete_chunck(__pcur); + __pcur = __pnext; + } + _S_chunks = 0; + _S_start_free = _S_end_free = 0; + _S_heap_size = 0; + memset(__REINTERPRET_CAST(char*, __CONST_CAST(_Obj**, &_S_free_list[0])), 0, _STLP_NFREELISTS * sizeof(_Obj*)); +} +# endif + +#else + +void* __node_alloc_impl::_M_allocate(size_t& __n) { + __n = _S_round_up(__n); + _Obj* __r = _S_free_list[_S_FREELIST_INDEX(__n)].pop(); + if (__r == 0) + { __r = _S_refill(__n); } + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) + _S_alloc_call(); +# endif + return __r; +} + +void __node_alloc_impl::_M_deallocate(void *__p, size_t __n) { + _S_free_list[_S_FREELIST_INDEX(__n)].push(__STATIC_CAST(_Obj*, __p)); + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) + _S_dealloc_call(); +# endif +} + +/* Returns an object of size __n, and optionally adds additional ones to */ +/* freelist of objects of size __n. */ +/* We assume that __n is properly aligned. */ +__node_alloc_impl::_Obj* __node_alloc_impl::_S_refill(size_t __n) { + int __nobjs = 20; + char* __chunk = _S_chunk_alloc(__n, __nobjs); + + if (__nobjs <= 1) + return __REINTERPRET_CAST(_Obj*, __chunk); + + // Push all new nodes (minus first one) onto freelist + _Obj* __result = __REINTERPRET_CAST(_Obj*, __chunk); + _Obj* __cur_item = __result; + _Freelist* __my_freelist = _S_free_list + _S_FREELIST_INDEX(__n); + for (--__nobjs; __nobjs != 0; --__nobjs) { + __cur_item = __REINTERPRET_CAST(_Obj*, __REINTERPRET_CAST(char*, __cur_item) + __n); + __my_freelist->push(__cur_item); + } + return __result; +} + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) +# define _STLP_OFFSET _ALIGN +# else +# define _STLP_OFFSET 0 +# endif + +/* We allocate memory in large chunks in order to avoid fragmenting */ +/* the malloc heap too much. */ +/* We assume that size is properly aligned. */ +char* __node_alloc_impl::_S_chunk_alloc(size_t _p_size, int& __nobjs) { +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) + //We are going to add a small memory block to keep all the allocated blocks + //address, we need to do so respecting the memory alignment. The following + //static assert checks that the reserved block is big enough to store a pointer. + _STLP_STATIC_ASSERT(sizeof(_Obj) <= _ALIGN) +# endif + char* __result = 0; + __add_atomic_t __total_bytes = __STATIC_CAST(__add_atomic_t, _p_size) * __nobjs; + + _FreeBlockHeader* __block = __STATIC_CAST(_FreeBlockHeader*, _S_free_mem_blocks.pop()); + if (__block != 0) { + // We checked a block out and can now mess with it with impugnity. + // We'll put the remainder back into the list if we're done with it below. + char* __buf_start = __REINTERPRET_CAST(char*, __block); + __add_atomic_t __bytes_left = __block->_M_end - __buf_start; + + if ((__bytes_left < __total_bytes) && (__bytes_left >= __STATIC_CAST(__add_atomic_t, _p_size))) { + // There's enough left for at least one object, but not as much as we wanted + __result = __buf_start; + __nobjs = (int)(__bytes_left/_p_size); + __total_bytes = __STATIC_CAST(__add_atomic_t, _p_size) * __nobjs; + __bytes_left -= __total_bytes; + __buf_start += __total_bytes; + } + else if (__bytes_left >= __total_bytes) { + // The block has enough left to satisfy all that was asked for + __result = __buf_start; + __bytes_left -= __total_bytes; + __buf_start += __total_bytes; + } + + if (__bytes_left != 0) { + // There is still some memory left over in block after we satisfied our request. + if ((__result != 0) && (__bytes_left >= (__add_atomic_t)sizeof(_FreeBlockHeader))) { + // We were able to allocate at least one object and there is still enough + // left to put remainder back into list. + _FreeBlockHeader* __newblock = __REINTERPRET_CAST(_FreeBlockHeader*, __buf_start); + __newblock->_M_end = __block->_M_end; + _S_free_mem_blocks.push(__newblock); + } + else { + // We were not able to allocate enough for at least one object. + // Shove into freelist of nearest (rounded-down!) size. + size_t __rounded_down = _S_round_up(__bytes_left + 1) - (size_t)_ALIGN; + if (__rounded_down > 0) + _S_free_list[_S_FREELIST_INDEX(__rounded_down)].push((_Obj*)__buf_start); + } + } + if (__result != 0) + return __result; + } + + // We couldn't satisfy it from the list of free blocks, get new memory. + __add_atomic_t __bytes_to_get = 2 * __total_bytes + + __STATIC_CAST(__add_atomic_t, + _S_round_up(__STATIC_CAST(__uadd_atomic_t, _STLP_ATOMIC_ADD(&_S_heap_size, 0)))) + + _STLP_OFFSET; + _STLP_TRY { + __result = __stlp_new_chunk(__bytes_to_get); + } +#if defined (_STLP_USE_EXCEPTIONS) + catch (const bad_alloc&) { + // Allocation failed; try to canibalize from freelist of a larger object size. + for (size_t __i = _p_size; __i <= (size_t)_MAX_BYTES; __i += (size_t)_ALIGN) { + _Obj* __p = _S_free_list[_S_FREELIST_INDEX(__i)].pop(); + if (0 != __p) { + if (__i < sizeof(_FreeBlockHeader)) { + // Not enough to put into list of free blocks, divvy it up here. + // Use as much as possible for this request and shove remainder into freelist. + __nobjs = (int)(__i/_p_size); + __total_bytes = __nobjs * __STATIC_CAST(__add_atomic_t, _p_size); + size_t __bytes_left = __i - __total_bytes; + size_t __rounded_down = _S_round_up(__bytes_left+1) - (size_t)_ALIGN; + if (__rounded_down > 0) { + _S_free_list[_S_FREELIST_INDEX(__rounded_down)].push(__REINTERPRET_CAST(_Obj*, __REINTERPRET_CAST(char*, __p) + __total_bytes)); + } + return __REINTERPRET_CAST(char*, __p); + } + else { + // Add node to list of available blocks and recursively allocate from it. + _FreeBlockHeader* __newblock = (_FreeBlockHeader*)__p; + __newblock->_M_end = __REINTERPRET_CAST(char*, __p) + __i; + _S_free_mem_blocks.push(__newblock); + return _S_chunk_alloc(_p_size, __nobjs); + } + } + } + + // We were not able to find something in a freelist, try to allocate a smaller amount. + __bytes_to_get = __total_bytes + _STLP_OFFSET; + __result = __stlp_new_chunk(__bytes_to_get); + + // This should either throw an exception or remedy the situation. + // Thus we assume it succeeded. + } +#endif + // Alignment check + _STLP_VERBOSE_ASSERT(((__REINTERPRET_CAST(size_t, __result) & __STATIC_CAST(size_t, _ALIGN - 1)) == 0), + _StlMsg_DBA_DELETED_TWICE) + _STLP_ATOMIC_ADD(&_S_heap_size, __bytes_to_get >> 4); + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) + // We have to track the allocated memory chunks for release on exit. + _S_chunks.push(__REINTERPRET_CAST(_Obj*, __result)); + __result += _ALIGN; + __bytes_to_get -= _ALIGN; +# endif + + if (__bytes_to_get > __total_bytes) { + // Push excess memory allocated in this chunk into list of free memory blocks + _FreeBlockHeader* __freeblock = __REINTERPRET_CAST(_FreeBlockHeader*, __result + __total_bytes); + __freeblock->_M_end = __result + __bytes_to_get; + _S_free_mem_blocks.push(__freeblock); + } + return __result; +} + +# if defined (_STLP_DO_CLEAN_NODE_ALLOC) +void __node_alloc_impl::_S_alloc_call() +{ _STLP_ATOMIC_INCREMENT(&_S_alloc_counter()); } + +void __node_alloc_impl::_S_dealloc_call() { + _STLP_VOLATILE __stl_atomic_t *pcounter = &_S_alloc_counter(); + if (_STLP_ATOMIC_DECREMENT(pcounter) == 0) + _S_chunk_dealloc(); +} + +/* We deallocate all the memory chunks */ +void __node_alloc_impl::_S_chunk_dealloc() { + // Note: The _Node_alloc_helper class ensures that this function + // will only be called when the (shared) library is unloaded or the + // process is shutdown. It's thus not possible that another thread + // is currently trying to allocate a node (we're not thread-safe here). + // + + // Clear the free blocks and all freelistst. This makes sure that if + // for some reason more memory is allocated again during shutdown + // (it'd also be really nasty to leave references to deallocated memory). + _S_free_mem_blocks.clear(); + _S_heap_size = 0; + + for (size_t __i = 0; __i < _STLP_NFREELISTS; ++__i) { + _S_free_list[__i].clear(); + } + + // Detach list of chunks and free them all + _Obj* __chunk = _S_chunks.clear(); + while (__chunk != 0) { + _Obj* __next = __chunk->_M_next; + __stlp_delete_chunck(__chunk); + __chunk = __next; + } +} +# endif + +#endif + +#if defined (_STLP_DO_CLEAN_NODE_ALLOC) +struct __node_alloc_cleaner { + ~__node_alloc_cleaner() + { __node_alloc_impl::_S_dealloc_call(); } +}; + +# if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) +_STLP_VOLATILE __stl_atomic_t& _STLP_CALL +# else +__stl_atomic_t& _STLP_CALL +# endif +__node_alloc_impl::_S_alloc_counter() { + static _AllocCounter _S_counter = 1; + static __node_alloc_cleaner _S_node_alloc_cleaner; + return _S_counter; +} +#endif + +#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) +_Node_alloc_obj * _STLP_VOLATILE +__node_alloc_impl::_S_free_list[_STLP_NFREELISTS] += {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// The 16 zeros are necessary to make version 4.1 of the SunPro +// compiler happy. Otherwise it appears to allocate too little +// space for the array. +#else +_STLP_atomic_freelist __node_alloc_impl::_S_free_list[_STLP_NFREELISTS]; +_STLP_atomic_freelist __node_alloc_impl::_S_free_mem_blocks; +#endif + +#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) +char *__node_alloc_impl::_S_start_free = 0; +char *__node_alloc_impl::_S_end_free = 0; +#endif + +#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) +_STLP_VOLATILE __add_atomic_t +#else +size_t +#endif +__node_alloc_impl::_S_heap_size = 0; + +#if defined (_STLP_DO_CLEAN_NODE_ALLOC) +# if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) +_STLP_atomic_freelist __node_alloc_impl::_S_chunks; +# else +_Node_alloc_obj* __node_alloc_impl::_S_chunks = 0; +# endif +#endif + +void * _STLP_CALL __node_alloc::_M_allocate(size_t& __n) +{ return __node_alloc_impl::_M_allocate(__n); } + +void _STLP_CALL __node_alloc::_M_deallocate(void *__p, size_t __n) +{ __node_alloc_impl::_M_deallocate(__p, __n); } + +#if defined (_STLP_PTHREADS) && !defined (_STLP_NO_THREADS) + +# define _STLP_DATA_ALIGNMENT 8 + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// ******************************************************* +// __perthread_alloc implementation +union _Pthread_alloc_obj { + union _Pthread_alloc_obj * __free_list_link; + char __client_data[_STLP_DATA_ALIGNMENT]; /* The client sees this. */ +}; + +// Pthread allocators don't appear to the client to have meaningful +// instances. We do in fact need to associate some state with each +// thread. That state is represented by _Pthread_alloc_per_thread_state. + +struct _Pthread_alloc_per_thread_state { + typedef _Pthread_alloc_obj __obj; + enum { _S_NFREELISTS = _MAX_BYTES / _STLP_DATA_ALIGNMENT }; + + // Free list link for list of available per thread structures. + // When one of these becomes available for reuse due to thread + // termination, any objects in its free list remain associated + // with it. The whole structure may then be used by a newly + // created thread. + _Pthread_alloc_per_thread_state() : __next(0) + { memset((void *)__CONST_CAST(_Pthread_alloc_obj**, __free_list), 0, (size_t)_S_NFREELISTS * sizeof(__obj *)); } + // Returns an object of size __n, and possibly adds to size n free list. + void *_M_refill(size_t __n); + + _Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS]; + _Pthread_alloc_per_thread_state *__next; + // this data member is only to be used by per_thread_allocator, which returns memory to the originating thread. + _STLP_mutex _M_lock; +}; + +// Pthread-specific allocator. +class _Pthread_alloc_impl { +public: // but only for internal use: + typedef _Pthread_alloc_per_thread_state __state_type; + typedef char value_type; + + // Allocates a chunk for nobjs of size size. nobjs may be reduced + // if it is inconvenient to allocate the requested number. + static char *_S_chunk_alloc(size_t __size, size_t &__nobjs, __state_type*); + + enum {_S_ALIGN = _STLP_DATA_ALIGNMENT}; + + static size_t _S_round_up(size_t __bytes) + { return (((__bytes) + (int)_S_ALIGN - 1) & ~((int)_S_ALIGN - 1)); } + static size_t _S_freelist_index(size_t __bytes) + { return (((__bytes) + (int)_S_ALIGN - 1) / (int)_S_ALIGN - 1); } + +private: + // Chunk allocation state. And other shared state. + // Protected by _S_chunk_allocator_lock. + static _STLP_STATIC_MUTEX _S_chunk_allocator_lock; + static char *_S_start_free; + static char *_S_end_free; + static size_t _S_heap_size; + static __state_type *_S_free_per_thread_states; + static pthread_key_t _S_key; + static bool _S_key_initialized; + // Pthread key under which per thread state is stored. + // Allocator instances that are currently unclaimed by any thread. + static void _S_destructor(void *instance); + // Function to be called on thread exit to reclaim per thread + // state. + static __state_type *_S_new_per_thread_state(); +public: + // Return a recycled or new per thread state. + static __state_type *_S_get_per_thread_state(); +private: + // ensure that the current thread has an associated + // per thread state. + class _M_lock; + friend class _M_lock; + class _M_lock { + public: + _M_lock () { _S_chunk_allocator_lock._M_acquire_lock(); } + ~_M_lock () { _S_chunk_allocator_lock._M_release_lock(); } + }; + +public: + + /* n must be > 0 */ + static void * allocate(size_t& __n); + + /* p may not be 0 */ + static void deallocate(void *__p, size_t __n); + + // boris : versions for per_thread_allocator + /* n must be > 0 */ + static void * allocate(size_t& __n, __state_type* __a); + + /* p may not be 0 */ + static void deallocate(void *__p, size_t __n, __state_type* __a); + + static void * reallocate(void *__p, size_t __old_sz, size_t& __new_sz); +}; + +/* Returns an object of size n, and optionally adds to size n free list.*/ +/* We assume that n is properly aligned. */ +/* We hold the allocation lock. */ +void *_Pthread_alloc_per_thread_state::_M_refill(size_t __n) { + typedef _Pthread_alloc_obj __obj; + size_t __nobjs = 128; + char * __chunk = _Pthread_alloc_impl::_S_chunk_alloc(__n, __nobjs, this); + __obj * volatile * __my_free_list; + __obj * __result; + __obj * __current_obj, * __next_obj; + size_t __i; + + if (1 == __nobjs) { + return __chunk; + } + + __my_free_list = __free_list + _Pthread_alloc_impl::_S_freelist_index(__n); + + /* Build free list in chunk */ + __result = (__obj *)__chunk; + *__my_free_list = __next_obj = (__obj *)(__chunk + __n); + for (__i = 1; ; ++__i) { + __current_obj = __next_obj; + __next_obj = (__obj *)((char *)__next_obj + __n); + if (__nobjs - 1 == __i) { + __current_obj -> __free_list_link = 0; + break; + } else { + __current_obj -> __free_list_link = __next_obj; + } + } + return __result; +} + +void _Pthread_alloc_impl::_S_destructor(void *__instance) { + _M_lock __lock_instance; // Need to acquire lock here. + _Pthread_alloc_per_thread_state* __s = (_Pthread_alloc_per_thread_state*)__instance; + __s -> __next = _S_free_per_thread_states; + _S_free_per_thread_states = __s; +} + +_Pthread_alloc_per_thread_state* _Pthread_alloc_impl::_S_new_per_thread_state() { + /* lock already held here. */ + if (0 != _S_free_per_thread_states) { + _Pthread_alloc_per_thread_state *__result = _S_free_per_thread_states; + _S_free_per_thread_states = _S_free_per_thread_states -> __next; + return __result; + } + else { + return new _Pthread_alloc_per_thread_state; + } +} + +_Pthread_alloc_per_thread_state* _Pthread_alloc_impl::_S_get_per_thread_state() { + int __ret_code; + __state_type* __result; + + if (_S_key_initialized && (__result = (__state_type*) pthread_getspecific(_S_key))) + return __result; + + /*REFERENCED*/ + _M_lock __lock_instance; // Need to acquire lock here. + if (!_S_key_initialized) { + if (pthread_key_create(&_S_key, _S_destructor)) { + _STLP_THROW_BAD_ALLOC; // failed + } + _S_key_initialized = true; + } + + __result = _S_new_per_thread_state(); + __ret_code = pthread_setspecific(_S_key, __result); + if (__ret_code) { + if (__ret_code == ENOMEM) { + _STLP_THROW_BAD_ALLOC; + } else { + // EINVAL + _STLP_ABORT(); + } + } + return __result; +} + +/* We allocate memory in large chunks in order to avoid fragmenting */ +/* the malloc heap too much. */ +/* We assume that size is properly aligned. */ +char *_Pthread_alloc_impl::_S_chunk_alloc(size_t __p_size, size_t &__nobjs, _Pthread_alloc_per_thread_state *__a) { + typedef _Pthread_alloc_obj __obj; + { + char * __result; + size_t __total_bytes; + size_t __bytes_left; + /*REFERENCED*/ + _M_lock __lock_instance; // Acquire lock for this routine + + __total_bytes = __p_size * __nobjs; + __bytes_left = _S_end_free - _S_start_free; + if (__bytes_left >= __total_bytes) { + __result = _S_start_free; + _S_start_free += __total_bytes; + return __result; + } else if (__bytes_left >= __p_size) { + __nobjs = __bytes_left/__p_size; + __total_bytes = __p_size * __nobjs; + __result = _S_start_free; + _S_start_free += __total_bytes; + return __result; + } else { + size_t __bytes_to_get = 2 * __total_bytes + _S_round_up(_S_heap_size); + // Try to make use of the left-over piece. + if (__bytes_left > 0) { + __obj * volatile * __my_free_list = __a->__free_list + _S_freelist_index(__bytes_left); + ((__obj *)_S_start_free) -> __free_list_link = *__my_free_list; + *__my_free_list = (__obj *)_S_start_free; + } +# ifdef _SGI_SOURCE + // Try to get memory that's aligned on something like a + // cache line boundary, so as to avoid parceling out + // parts of the same line to different threads and thus + // possibly different processors. + { + const int __cache_line_size = 128; // probable upper bound + __bytes_to_get &= ~(__cache_line_size-1); + _S_start_free = (char *)memalign(__cache_line_size, __bytes_to_get); + if (0 == _S_start_free) { + _S_start_free = (char *)__malloc_alloc::allocate(__bytes_to_get); + } + } +# else /* !SGI_SOURCE */ + _S_start_free = (char *)__malloc_alloc::allocate(__bytes_to_get); +# endif + _S_heap_size += __bytes_to_get >> 4; + _S_end_free = _S_start_free + __bytes_to_get; + } + } + // lock is released here + return _S_chunk_alloc(__p_size, __nobjs, __a); +} + + +/* n must be > 0 */ +void *_Pthread_alloc_impl::allocate(size_t& __n) { + typedef _Pthread_alloc_obj __obj; + __obj * volatile * __my_free_list; + __obj * __result; + __state_type* __a; + + if (__n > _MAX_BYTES) { + return __malloc_alloc::allocate(__n); + } + + __n = _S_round_up(__n); + __a = _S_get_per_thread_state(); + + __my_free_list = __a->__free_list + _S_freelist_index(__n); + __result = *__my_free_list; + if (__result == 0) { + void *__r = __a->_M_refill(__n); + return __r; + } + *__my_free_list = __result->__free_list_link; + return __result; +}; + +/* p may not be 0 */ +void _Pthread_alloc_impl::deallocate(void *__p, size_t __n) { + typedef _Pthread_alloc_obj __obj; + __obj *__q = (__obj *)__p; + __obj * volatile * __my_free_list; + __state_type* __a; + + if (__n > _MAX_BYTES) { + __malloc_alloc::deallocate(__p, __n); + return; + } + + __a = _S_get_per_thread_state(); + + __my_free_list = __a->__free_list + _S_freelist_index(__n); + __q -> __free_list_link = *__my_free_list; + *__my_free_list = __q; +} + +// boris : versions for per_thread_allocator +/* n must be > 0 */ +void *_Pthread_alloc_impl::allocate(size_t& __n, __state_type* __a) { + typedef _Pthread_alloc_obj __obj; + __obj * volatile * __my_free_list; + __obj * __result; + + if (__n > _MAX_BYTES) { + return __malloc_alloc::allocate(__n); + } + __n = _S_round_up(__n); + + // boris : here, we have to lock per thread state, as we may be getting memory from + // different thread pool. + _STLP_auto_lock __lock(__a->_M_lock); + + __my_free_list = __a->__free_list + _S_freelist_index(__n); + __result = *__my_free_list; + if (__result == 0) { + void *__r = __a->_M_refill(__n); + return __r; + } + *__my_free_list = __result->__free_list_link; + return __result; +}; + +/* p may not be 0 */ +void _Pthread_alloc_impl::deallocate(void *__p, size_t __n, __state_type* __a) { + typedef _Pthread_alloc_obj __obj; + __obj *__q = (__obj *)__p; + __obj * volatile * __my_free_list; + + if (__n > _MAX_BYTES) { + __malloc_alloc::deallocate(__p, __n); + return; + } + + // boris : here, we have to lock per thread state, as we may be returning memory from + // different thread. + _STLP_auto_lock __lock(__a->_M_lock); + + __my_free_list = __a->__free_list + _S_freelist_index(__n); + __q -> __free_list_link = *__my_free_list; + *__my_free_list = __q; +} + +void *_Pthread_alloc_impl::reallocate(void *__p, size_t __old_sz, size_t& __new_sz) { + void * __result; + size_t __copy_sz; + + if (__old_sz > _MAX_BYTES && __new_sz > _MAX_BYTES) { + return realloc(__p, __new_sz); + } + + if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return __p; + __result = allocate(__new_sz); + __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz; + memcpy(__result, __p, __copy_sz); + deallocate(__p, __old_sz); + return __result; +} + +_Pthread_alloc_per_thread_state* _Pthread_alloc_impl::_S_free_per_thread_states = 0; +pthread_key_t _Pthread_alloc_impl::_S_key = 0; +_STLP_STATIC_MUTEX _Pthread_alloc_impl::_S_chunk_allocator_lock _STLP_MUTEX_INITIALIZER; +bool _Pthread_alloc_impl::_S_key_initialized = false; +char *_Pthread_alloc_impl::_S_start_free = 0; +char *_Pthread_alloc_impl::_S_end_free = 0; +size_t _Pthread_alloc_impl::_S_heap_size = 0; + +void * _STLP_CALL _Pthread_alloc::allocate(size_t& __n) +{ return _Pthread_alloc_impl::allocate(__n); } +void _STLP_CALL _Pthread_alloc::deallocate(void *__p, size_t __n) +{ _Pthread_alloc_impl::deallocate(__p, __n); } +void * _STLP_CALL _Pthread_alloc::allocate(size_t& __n, __state_type* __a) +{ return _Pthread_alloc_impl::allocate(__n, __a); } +void _STLP_CALL _Pthread_alloc::deallocate(void *__p, size_t __n, __state_type* __a) +{ _Pthread_alloc_impl::deallocate(__p, __n, __a); } +void * _STLP_CALL _Pthread_alloc::reallocate(void *__p, size_t __old_sz, size_t& __new_sz) +{ return _Pthread_alloc_impl::reallocate(__p, __old_sz, __new_sz); } +_Pthread_alloc_per_thread_state* _STLP_CALL _Pthread_alloc::_S_get_per_thread_state() +{ return _Pthread_alloc_impl::_S_get_per_thread_state(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +#endif + +_STLP_END_NAMESPACE + +#undef _S_FREELIST_INDEX diff --git a/sdk/tlibstdcxx/src/bitset.cpp b/sdk/tlibstdcxx/src/bitset.cpp new file mode 100644 index 0000000000..90f1799157 --- /dev/null +++ b/sdk/tlibstdcxx/src/bitset.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// ------------------------------------------------------------ +// Lookup tables for find and count operations. + +size_t _Bs_G::_S_count(const unsigned char *__first, + const unsigned char *__last) +{ + static const unsigned char _bit_count[256] = { + 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */ + 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */ + 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */ + 4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */ + 2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */ + 3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */ + 4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */ + 3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */ + 2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */ + 4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */ + 3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */ + 5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */ + 4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */ + 2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */ + 3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */ + 4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */ + 2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */ + 4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */ + 4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */ + 6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */ + 3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */ + 4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */ + 5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */ + 5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */ + 4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */ + 6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */ + 2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */ + 4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */ + 3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */ + 3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */ + 4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */ + 5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */ + 2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */ + 4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */ + 4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */ + 6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */ + 4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */ + 5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */ + 6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */ + 4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */ + 3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */ + 5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */ + 4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */ + 6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */ + 5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */ + 4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */ + 5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */ + 6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */ + 4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */ + 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */ + 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */ + 8 /* 255 */ + }; + + size_t __result(0); + while ( __first < __last ) { + __result += _bit_count[*(__first++)]; + } + return __result; +} + +unsigned char _Bs_G::_S_first_one(unsigned char __byte) +{ + static const unsigned char _first_one[256] = { + 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */ + 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */ + 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */ + 0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */ + 2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */ + 0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */ + 1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */ + 0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */ + 3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */ + 0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */ + 1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */ + 0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */ + 2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */ + 0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */ + 1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */ + 0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */ + 4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */ + 0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */ + 1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */ + 0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */ + 2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */ + 0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */ + 1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */ + 0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */ + 3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */ + 0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */ + 1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */ + 0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */ + 2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */ + 0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */ + 1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */ + 0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */ + 5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */ + 0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */ + 1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */ + 0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */ + 2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */ + 0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */ + 1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */ + 0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */ + 3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */ + 0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */ + 1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */ + 0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */ + 2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */ + 0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */ + 1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */ + 0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */ + 4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */ + 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */ + 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */ + 0, /* 255 */ + }; + return _first_one[__byte]; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/c_locale.c b/sdk/tlibstdcxx/src/c_locale.c new file mode 100644 index 0000000000..376e22e493 --- /dev/null +++ b/sdk/tlibstdcxx/src/c_locale.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include "c_locale.h" + +#if defined (_STLP_WIN32) && !defined (_STLP_WCE) +# include "c_locale_win32/c_locale_win32.c" +#elif defined (_STLP_USE_GLIBC2_LOCALIZATION) +# include "c_locale_glibc/c_locale_glibc2.c" /* glibc 2.2 and newer */ +#else +# include "c_locale_dummy/c_locale_dummy.c" +#endif diff --git a/sdk/tlibstdcxx/src/c_locale.h b/sdk/tlibstdcxx/src/c_locale.h new file mode 100644 index 0000000000..36d9961128 --- /dev/null +++ b/sdk/tlibstdcxx/src/c_locale.h @@ -0,0 +1,450 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * It is impossible to write the C++ locale library in terms of locales + * as defined in the C standard. Instead, we write the C++ locale and I/O + * library in terms of a low level C-like interface. This file defines + * that interface. + * + * The low-level locale interface can't be written portably; there + * must be a version of it for each platform that the C++ library + * is ported to. On many systems this interface may be a thin wrapper + * for existing functionality. + */ + +#ifndef _STLP_C_LOCALE_IMPL_H +#define _STLP_C_LOCALE_IMPL_H + +#include "stlport_prefix.h" + +#include /* for mbstate_t */ +#include + +struct _Locale_name_hint; + +#if defined (_GNU_SOURCE) && defined (__GLIBC__) && \ + ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) +# define _STLP_USE_GLIBC2_LOCALIZATION +# include +typedef nl_catd nl_catd_type; +#else +typedef int nl_catd_type; +#endif + +/* + * A number: the maximum length of a simple locale name. + * (i.e. a name like like en_US, as opposed to a name like + * en_US/de_AT/de_AT/es_MX/en_US/en_US) */ +#define _Locale_MAX_SIMPLE_NAME 256 + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Typedefs: + */ +typedef unsigned short int _Locale_mask_t; + +/* Function called during STLport library load phase. Might contain any + * code necessary to the platform localization layer. + */ +void _Locale_init(void); + +/* Function called during STLport library unload. Might contain any + * code necessary to the platform localization layer. + */ +void _Locale_final(void); + +/* Create a category of the locale with the given name. + * + * The char* argument is a simple (not a composite) locale name, which may + * neither be an empty string nor a null pointer. + * + * These functions return NULL to indicate failure. Failure reason should be reported + * using the __err_code pointer. + */ +struct _Locale_ctype* _Locale_ctype_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); +struct _Locale_codecvt* _Locale_codecvt_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); +struct _Locale_numeric* _Locale_numeric_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); +struct _Locale_time* _Locale_time_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); +struct _Locale_collate* _Locale_collate_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); +struct _Locale_monetary* _Locale_monetary_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); +struct _Locale_messages* _Locale_messages_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); + +/* Give error reason on failure of one of the _Locale_*_create functions. Available + * reasons are: + * 0: No specific error reason has been reported. + * 1: No platform support for the given facet. + * 2: Unknown locale name + * 3: No platform API for localization support. + * 4: No more memory + */ +#define _STLP_LOC_UNDEFINED 0 +#define _STLP_LOC_UNSUPPORTED_FACET_CATEGORY 1 +#define _STLP_LOC_UNKNOWN_NAME 2 +#define _STLP_LOC_NO_PLATFORM_SUPPORT 3 +#define _STLP_LOC_NO_MEMORY 4 + +/* Release a category of a locale + * + * These functions are used to release a category acquired with the + * according _Locale_*_create() functions. + */ +void _Locale_ctype_destroy(struct _Locale_ctype *); +void _Locale_codecvt_destroy(struct _Locale_codecvt *); +void _Locale_numeric_destroy(struct _Locale_numeric *); +void _Locale_time_destroy(struct _Locale_time *); +void _Locale_collate_destroy(struct _Locale_collate *); +void _Locale_monetary_destroy(struct _Locale_monetary *); +void _Locale_messages_destroy(struct _Locale_messages *); + +/* + * Returns the name of the user's default locale in each + * category, as a null-terminated string. A NULL value + * means the default "C" locale. + */ +const char * _Locale_ctype_default(char * __buf); +const char * _Locale_numeric_default(char * __buf); +const char * _Locale_time_default(char * __buf); +const char * _Locale_collate_default(char * __buf); +const char * _Locale_monetary_default(char * __buf); +const char * _Locale_messages_default(char * __buf); + +/* Retrieve the name of the given category + * + * __buf points to a buffer that can hold at least _Locale_MAX_SIMPLE_NAME + * characters. These functions store the name, as a null-terminated + * string, in __buf. This function can't fail, at worst name is truncated. + */ +char const* _Locale_ctype_name(const struct _Locale_ctype *, char* __buf); +char const* _Locale_codecvt_name(const struct _Locale_codecvt *, char* __buf); +char const* _Locale_numeric_name(const struct _Locale_numeric *, char* __buf); +char const* _Locale_time_name(const struct _Locale_time *, char* __buf); +char const* _Locale_collate_name(const struct _Locale_collate *, char* __buf); +char const* _Locale_monetary_name(const struct _Locale_monetary *, char* __buf); +char const* _Locale_messages_name(const struct _Locale_messages *, char* __buf); + +/* + * cname is a (possibly composite) locale name---i.e. a name that can + * be passed to setlocale. __buf points to an array large enough to + * store at least _Locale_MAX_SIMPLE_NAME characters, and each of these + * functions extracts the name of a single category, stores it in buf + * as a null-terminated string, and returns buf. + */ +char const* _Locale_extract_ctype_name(const char *cname, char *__buf, + struct _Locale_name_hint* __hint, int *__err_code); +char const* _Locale_extract_numeric_name(const char *cname, char *__buf, + struct _Locale_name_hint* __hint, int *__err_code); +char const* _Locale_extract_time_name(const char *cname, char *__buf, + struct _Locale_name_hint* __hint, int *__err_code); +char const* _Locale_extract_collate_name(const char *cname, char *__buf, + struct _Locale_name_hint* __hint, int *__err_code); +char const* _Locale_extract_monetary_name(const char *cname, char *__buf, + struct _Locale_name_hint* __hint, int *__err_code); +char const* _Locale_extract_messages_name(const char *cname, char *__buf, + struct _Locale_name_hint* __hint, int *__err_code); + +/* Functions to improve locale creation process. For some locale API (Win32) + * you need to find a locale identification from the name which can be a + * rather expensive operation especially if you do so for all facets of a + * locale. Those functions can be used to extract from a API dependent facet + * struct the information necessary to skip this lookup process for other + * facets creation. If not supported those function should return NULL. + */ +struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype*); +struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric*); +struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time*); +struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate*); +struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary*); +struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages*); + +/* + * FUNCTIONS THAT USE CTYPE + */ + +/* + * Narrow character functions: + */ + +/* + * Returns a pointer to the beginning of the ctype table. The table is + * at least 257 bytes long; if p is the pointer returned by this + * function, then p[c] is valid if c is EOF or if p is any value of + * type unsigned char. + */ +const _Locale_mask_t * _Locale_ctype_table(struct _Locale_ctype *); + +/* + * c is either EOF, or an unsigned char value. + */ +int _Locale_toupper(struct _Locale_ctype *, int /* c */); +int _Locale_tolower(struct _Locale_ctype *, int /* c */); + + +#ifndef _STLP_NO_WCHAR_T +/* + * Wide character functions: + */ +_Locale_mask_t _WLocale_ctype(struct _Locale_ctype *, wint_t, _Locale_mask_t); +wint_t _WLocale_tolower(struct _Locale_ctype *, wint_t); +wint_t _WLocale_toupper(struct _Locale_ctype *, wint_t); + +/* + * Multibyte functions: + */ + +/* + * Returns the number of bytes of the longest allowed multibyte + * character in the current encoding. + */ +int _WLocale_mb_cur_max(struct _Locale_codecvt *); + +/* + * Returns the number of bytes of the shortest allowed multibyte + * character in the current encoding. + */ +int _WLocale_mb_cur_min(struct _Locale_codecvt *); + +/* + * Returns 1 if the current multibyte encoding is stateless + * and does not require the use of an mbstate_t value. + */ +int _WLocale_is_stateless(struct _Locale_codecvt *); + +/* + * Almost identical to mbrtowc, from 4.6.5.3.2 of NA1. The only + * important difference is that mbrtowc treats null wide characters + * as special, and we don't. Specifically: examines the characters + * in [from, from + n), extracts a single wide character, and stores + * it in *to. Modifies shift_state if appropriate. The return value, + * which is always positive, is the number of characters extracted from + * the input sequence. Return value is (size_t) -1 if there was an + * encoding error in the input sequence, and (size_t) -2 if + * [from, from + n) is correct but not complete. None of the pointer + * arguments may be null pointers. + */ +size_t _WLocale_mbtowc(struct _Locale_codecvt *, + wchar_t * /* to */, + const char * /* from */, size_t /* n */, + mbstate_t *); + +/* + * Again, very similar to wcrtomb. The differences are that (1) it + * doesn't treat null characters as special; and (2) it stores at most + * n characters. Converts c to a multibyte sequence, stores that + * sequence in the array 'to', and returns the length of the sequence. + * Modifies shift_state if appropriate. The return value is (size_t) -1 + * if c is not a valid wide character, and (size_t) -2 if the length of + * the multibyte character sequence is greater than n. + */ +size_t _WLocale_wctomb(struct _Locale_codecvt *, + char *, size_t, + const wchar_t, + mbstate_t *); + +/* + * Inserts whatever characters are necessary to restore st to an + * initial shift state. Sets *next to buf + m, where m is the number + * of characters inserted. (0 <= m <= n.) Returns m to indicate + * success, (size_t) -1 to indicate error, (size_t) -2 to indicate + * partial success (more than n characters needed). For success or partial + * success, sets *next to buf + m. + */ +size_t _WLocale_unshift(struct _Locale_codecvt *, + mbstate_t *, + char *, size_t, char **); +#endif + +/* + * FUNCTIONS THAT USE COLLATE + */ + +/* + * Compares the two sequences [s1, s1 + n1) and [s2, s2 + n2). Neither + * sequence is assumed to be null-terminated, and null characters + * aren't special. If the two sequences are the same up through + * min(n1, n2), then the sequence that compares less is whichever one + * is shorter. + */ +int _Locale_strcmp(struct _Locale_collate *, + const char * /* s1 */, size_t /* n1 */, + const char * /* s2 */, size_t /* n2 */); +#ifndef _STLP_NO_WCHAR_T +int _WLocale_strcmp(struct _Locale_collate *, + const wchar_t * /* s1 */, size_t /* n1 */, + const wchar_t * /* s2 */, size_t /* n2 */); +#endif + +/* + * Creates a transformed version of the string [s2, s2 + n2). The + * string may contain embedded null characters; nulls aren't special. + * The transformed string begins at s1, and contains at most n1 + * characters. The return value is the length of the transformed + * string. If the return value is greater than n1 then this is an + * error condition: it indicates that there wasn't enough space. In + * that case, the contents of [s1, s1 + n1) is unspecified. +*/ +size_t _Locale_strxfrm(struct _Locale_collate *, + char * /* s1 */, size_t /* n1 */, + const char * /* s2 */, size_t /* n2 */); + +#ifndef _STLP_NO_WCHAR_T +size_t _WLocale_strxfrm(struct _Locale_collate *, + wchar_t * /* s1 */, size_t /* n1 */, + const wchar_t * /* s2 */, size_t /* n2 */); +#endif + + +/* + * FUNCTIONS THAT USE NUMERIC + */ + +/* + * Equivalent to the first three fields in struct lconv. (C standard, + * section 7.4.) + */ +char _Locale_decimal_point(struct _Locale_numeric *); +char _Locale_thousands_sep(struct _Locale_numeric *); +const char * _Locale_grouping(struct _Locale_numeric *); + +#ifndef _STLP_NO_WCHAR_T +wchar_t _WLocale_decimal_point(struct _Locale_numeric *); +wchar_t _WLocale_thousands_sep(struct _Locale_numeric *); +#endif + +/* + * Return "true" and "false" in English locales, and something + * appropriate in non-English locales. + */ +const char * _Locale_true(struct _Locale_numeric *); +const char * _Locale_false(struct _Locale_numeric *); + +#ifndef _STLP_NO_WCHAR_T +const wchar_t * _WLocale_true(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */); +const wchar_t * _WLocale_false(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */); +#endif + +/* + * FUNCTIONS THAT USE MONETARY + */ + +/* + * Return the obvious fields of struct lconv. + */ +const char * _Locale_int_curr_symbol(struct _Locale_monetary *); +const char * _Locale_currency_symbol(struct _Locale_monetary *); +char _Locale_mon_decimal_point(struct _Locale_monetary *); +char _Locale_mon_thousands_sep(struct _Locale_monetary *); +const char * _Locale_mon_grouping(struct _Locale_monetary *); +const char * _Locale_positive_sign(struct _Locale_monetary *); +const char * _Locale_negative_sign(struct _Locale_monetary *); +char _Locale_int_frac_digits(struct _Locale_monetary *); +char _Locale_frac_digits(struct _Locale_monetary *); +int _Locale_p_cs_precedes(struct _Locale_monetary *); +int _Locale_p_sep_by_space(struct _Locale_monetary *); +int _Locale_p_sign_posn(struct _Locale_monetary *); +int _Locale_n_cs_precedes(struct _Locale_monetary *); +int _Locale_n_sep_by_space(struct _Locale_monetary *); +int _Locale_n_sign_posn(struct _Locale_monetary *); + +#ifndef _STLP_NO_WCHAR_T +const wchar_t * _WLocale_int_curr_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); +const wchar_t * _WLocale_currency_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); +wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary *); +wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary *); +const wchar_t * _WLocale_positive_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); +const wchar_t * _WLocale_negative_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); +#endif + +/* + * FUNCTIONS THAT USE TIME + */ + +/* + * month is in the range [0, 12). + */ +const char * _Locale_full_monthname(struct _Locale_time *, int /* month */); +const char * _Locale_abbrev_monthname(struct _Locale_time *, int /* month */); + +#ifndef _STLP_NO_WCHAR_T +const wchar_t * _WLocale_full_monthname(struct _Locale_time *, int /* month */, + wchar_t* /* buf */, size_t /* bufSize */); +const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time *, int /* month */, + wchar_t* /* buf */, size_t /* bufSize */); +#endif + +/* + * day is in the range [0, 7). Sunday is 0. + */ +const char * _Locale_full_dayofweek(struct _Locale_time *, int /* day */); +const char * _Locale_abbrev_dayofweek(struct _Locale_time *, int /* day */); + +#ifndef _STLP_NO_WCHAR_T +const wchar_t * _WLocale_full_dayofweek(struct _Locale_time *, int /* day */, + wchar_t* /* buf */, size_t /* bufSize */); +const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time *, int /* day */, + wchar_t* /* buf */, size_t /* bufSize */); +#endif + +const char * _Locale_d_t_fmt(struct _Locale_time *); +const char * _Locale_d_fmt(struct _Locale_time *); +const char * _Locale_t_fmt(struct _Locale_time *); +const char * _Locale_long_d_t_fmt(struct _Locale_time*); +const char * _Locale_long_d_fmt(struct _Locale_time*); + +const char * _Locale_am_str(struct _Locale_time *); +const char * _Locale_pm_str(struct _Locale_time *); + +#ifndef _STLP_NO_WCHAR_T +const wchar_t * _WLocale_am_str(struct _Locale_time *, + wchar_t* /* buf */, size_t /* bufSize */); +const wchar_t * _WLocale_pm_str(struct _Locale_time *, + wchar_t* /* buf */, size_t /* bufSize */); +#endif + +/* + * FUNCTIONS THAT USE MESSAGES + */ + +/* + * Very similar to catopen, except that it uses the given message + * category to determine which catalog to open. + */ +nl_catd_type _Locale_catopen(struct _Locale_messages*, const char*); + +/* Complementary to _Locale_catopen. + * The catalog must be a value that was returned by a previous call + * to _Locale_catopen. + */ +void _Locale_catclose(struct _Locale_messages*, nl_catd_type); + +/* + * Returns a string, identified by a set index and a message index, + * from an opened message catalog. Returns the supplied default if + * no such string exists. + */ +const char * _Locale_catgets(struct _Locale_messages *, nl_catd_type, + int, int,const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _STLP_C_LOCALE_IMPL_H */ diff --git a/sdk/tlibstdcxx/src/c_locale_dummy/c_locale_dummy.c b/sdk/tlibstdcxx/src/c_locale_dummy/c_locale_dummy.c new file mode 100644 index 0000000000..be48f23063 --- /dev/null +++ b/sdk/tlibstdcxx/src/c_locale_dummy/c_locale_dummy.c @@ -0,0 +1,485 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* This is a "stub" implementation of the "c_locale.h" interface, + intended for operating systems where we have not yet written + a real implementation. A C++ library using this stub implementation + is still standard-conforming, since the C++ standard does not require + that any locales other than "C" be supported. +*/ + +#include +#include +#include +#include +#include + +#if defined (_STLP_USE_SAFE_STRING_FUNCTIONS) +# define _STLP_STRNCPY(D, DS, S, C) strncpy_s(D, DS, S, C) +# if !defined (_STLP_NO_WCHAR_T) +# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy_s(D, DS, S, C) +# endif +#else +# define _STLP_STRNCPY(D, DS, S, C) strncpy(D, S, C) +# if !defined (_STLP_NO_WCHAR_T) +# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy(D, S, C) +# endif +#endif + +static const char *_C_name = "C"; +static const char *_empty_str = ""; +#ifndef _STLP_NO_WCHAR_T +static const wchar_t *_empty_wstr = L""; +#endif + +static _Locale_mask_t ctable[256]; + +/* Framework functions */ + +void _Locale_init(void) { + /* Ctype table for the ASCII character set. */ + char c; + /* We might never reach 128 when char is signed. */ + for (c = 0; /* c != 128 */; ++c) { + if (isalpha(c)) ctable[(unsigned char)c] |= _Locale_ALPHA; + if (iscntrl(c)) ctable[(unsigned char)c] |= _Locale_CNTRL; + if (isdigit(c)) ctable[(unsigned char)c] |= _Locale_DIGIT; + if (isprint(c)) ctable[(unsigned char)c] |= _Locale_PRINT; + if (ispunct(c)) ctable[(unsigned char)c] |= _Locale_PUNCT; + if (isspace(c)) ctable[(unsigned char)c] |= _Locale_SPACE; + if (isxdigit(c)) ctable[(unsigned char)c] |= _Locale_XDIGIT; + if (isupper(c)) ctable[(unsigned char)c] |= _Locale_UPPER; + if (islower(c)) ctable[(unsigned char)c] |= _Locale_LOWER; + if (c == 127) break; + } + + /* ASCII is a 7-bit code, so everything else is non-ASCII. */ + memset(&(ctable[128]), 0, 128 * sizeof(_Locale_mask_t)); +} + +void _Locale_final(void) +{} + +void* _Locale_create(const char* name, int *__err_code) { + if (name[0] == 'C' && name[1] == 0) + { return (void*)0x1; } + *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0; +} + +struct _Locale_ctype* _Locale_ctype_create(const char *name, + struct _Locale_name_hint* hint, int *__err_code) +{ return (struct _Locale_ctype*)_Locale_create(name, __err_code); } + +struct _Locale_codecvt* _Locale_codecvt_create(const char *name, + struct _Locale_name_hint* hint, int *__err_code) +{ return (struct _Locale_codecvt*)_Locale_create(name, __err_code); } + +struct _Locale_numeric* _Locale_numeric_create(const char *name, + struct _Locale_name_hint* hint, int *__err_code) +{ return (struct _Locale_numeric*)_Locale_create(name, __err_code); } + +struct _Locale_time* _Locale_time_create(const char *name, + struct _Locale_name_hint* hint, int *__err_code) +{ return (struct _Locale_time*)_Locale_create(name, __err_code); } + +struct _Locale_collate* _Locale_collate_create(const char *name, + struct _Locale_name_hint* hint, int *__err_code) +{ return (struct _Locale_collate*)_Locale_create(name, __err_code); } + +struct _Locale_monetary* _Locale_monetary_create(const char *name, + struct _Locale_name_hint* hint, int *__err_code) +{ return (struct _Locale_monetary*)_Locale_create(name, __err_code); } + +struct _Locale_messages* _Locale_messages_create(const char *name, + struct _Locale_name_hint* hint, int *__err_code) +{ return (struct _Locale_messages*)_Locale_create(name, __err_code); } + +const char *_Locale_ctype_default(char* buf) { return _C_name; } +const char *_Locale_numeric_default(char * buf) { return _C_name; } +const char *_Locale_time_default(char* buf) { return _C_name; } +const char *_Locale_collate_default(char* buf) { return _C_name; } +const char *_Locale_monetary_default(char* buf) { return _C_name; } +const char *_Locale_messages_default(char* buf) { return _C_name; } + +char const* _Locale_ctype_name(const struct _Locale_ctype *lctype, char* buf) +{ return _C_name; } + +char const* _Locale_codecvt_name(const struct _Locale_codecvt *lcodecvt, char* buf) +{ return _C_name; } + +char const* _Locale_numeric_name(const struct _Locale_numeric *lnum, char* buf) +{ return _C_name; } + +char const* _Locale_time_name(const struct _Locale_time *ltime, char* buf) +{ return _C_name; } + +char const* _Locale_collate_name(const struct _Locale_collate *lcol, char* buf) +{ return _C_name; } + +char const* _Locale_monetary_name(const struct _Locale_monetary *lmon, char* buf) +{ return _C_name; } + +char const* _Locale_messages_name(const struct _Locale_messages *lmes, char* buf) +{ return _C_name; } + +void _Locale_ctype_destroy(struct _Locale_ctype *lctype) {} +void _Locale_codecvt_destroy(struct _Locale_codecvt *lcodecvt) {} +void _Locale_numeric_destroy(struct _Locale_numeric *lnum) {} +void _Locale_time_destroy(struct _Locale_time *ltime) {} +void _Locale_collate_destroy(struct _Locale_collate *lcol) {} +void _Locale_monetary_destroy(struct _Locale_monetary *lmon) {} +void _Locale_messages_destroy(struct _Locale_messages *lmes) {} + +static char const* _Locale_extract_name(const char* name, int *__err_code) { + // When the request is the default locale or the "C" locale we answer "C". + if (name[0] == 0 || + (name[0] == 'C' && name[1] == 0)) + { return _C_name; } + *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0; +} + +char const* _Locale_extract_ctype_name(const char *name, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return _Locale_extract_name(name, __err_code); } + +char const* _Locale_extract_numeric_name(const char *name, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return _Locale_extract_name(name, __err_code); } + +char const* _Locale_extract_time_name(const char*name, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return _Locale_extract_name(name, __err_code); } + +char const* _Locale_extract_collate_name(const char *name, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return _Locale_extract_name(name, __err_code); } + +char const* _Locale_extract_monetary_name(const char *name, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return _Locale_extract_name(name, __err_code); } + +char const* _Locale_extract_messages_name(const char *name, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return _Locale_extract_name(name, __err_code); } + +struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype) +{ return 0; } +struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric) +{ return 0; } +struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time) +{ return 0; } +struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate) +{ return 0; } +struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary) +{ return 0; } +struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages) +{ return 0; } + +/* ctype */ +const _Locale_mask_t* _Locale_ctype_table(struct _Locale_ctype* lctype) { + _STLP_MARK_PARAMETER_AS_UNUSED(lctype) + return ctable; +} + +int _Locale_toupper(struct _Locale_ctype*lctype, int c) +{ return toupper(c); } + +int _Locale_tolower(struct _Locale_ctype*lctype, int c) +{ return tolower(c); } + +#ifndef _STLP_NO_WCHAR_T +_Locale_mask_t _WLocale_ctype(struct _Locale_ctype *lctype, wint_t wc, _Locale_mask_t mask) { + _Locale_mask_t ret = 0; + if ((mask & _Locale_ALPHA) != 0 && iswalpha(wc)) + ret |= _Locale_ALPHA; + + if ((mask & _Locale_CNTRL) != 0 && iswcntrl(wc)) + ret |= _Locale_CNTRL; + + if ((mask & _Locale_DIGIT) != 0 && iswdigit(wc)) + ret |= _Locale_DIGIT; + + if ((mask & _Locale_PRINT) != 0 && iswprint(wc)) + ret |= _Locale_PRINT; + + if ((mask & _Locale_PUNCT) != 0 && iswpunct(wc)) + ret |= _Locale_PUNCT; + + if ((mask & _Locale_SPACE) != 0 && iswspace(wc)) + ret |= _Locale_SPACE; + + if ((mask & _Locale_XDIGIT) != 0 && iswxdigit(wc)) + ret |= _Locale_XDIGIT; + + if ((mask & _Locale_UPPER) != 0 && iswupper(wc)) + ret |= _Locale_UPPER; + + if ((mask & _Locale_LOWER) != 0 && iswlower(wc)) + ret |= _Locale_LOWER; + + return ret; +} + +wint_t _WLocale_tolower(struct _Locale_ctype *lctype, wint_t wc) +{ return towlower(wc); } + +wint_t _WLocale_toupper(struct _Locale_ctype *lctype, wint_t wc) +{ return towupper(wc); } + +int _WLocale_mb_cur_max (struct _Locale_codecvt *lcodecvt) { return 1; } +int _WLocale_mb_cur_min (struct _Locale_codecvt *lcodecvt) { return 1; } +int _WLocale_is_stateless (struct _Locale_codecvt *lcodecvt) { return 1; } + +size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt, + wchar_t *to, + const char *from, size_t n, + mbstate_t *st) +{ *to = *from; return 1; } + +size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt, + char *to, size_t n, + const wchar_t c, + mbstate_t *st) +{ *to = (char)c; return 1; } + +size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt, + mbstate_t *st, + char *buf, size_t n, char ** next) +{ *next = buf; return 0; } +#endif + +/* Collate */ + int _Locale_strcmp(struct _Locale_collate* lcol, + const char* s1, size_t n1, const char* s2, size_t n2) { + int ret = 0; + char buf1[64], buf2[64]; + while (n1 > 0 || n2 > 0) { + size_t bufsize1 = n1 < 63 ? n1 : 63; + size_t bufsize2 = n2 < 63 ? n2 : 63; + _STLP_STRNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0; + _STLP_STRNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0; + + ret = strcmp(buf1, buf2); + if (ret != 0) return ret < 0 ? -1 : 1; + s1 += bufsize1; n1 -= bufsize1; + s2 += bufsize2; n2 -= bufsize2; + } + return ret == 0 ? 0 : (ret < 0 ? -1 : 1); +} + +#ifndef _STLP_NO_WCHAR_T + +int _WLocale_strcmp(struct _Locale_collate* lcol, + const wchar_t* s1, size_t n1, const wchar_t* s2, size_t n2) { + int ret = 0; + wchar_t buf1[64], buf2[64]; + while (n1 > 0 || n2 > 0) { + size_t bufsize1 = n1 < 63 ? n1 : 63; + size_t bufsize2 = n2 < 63 ? n2 : 63; + _STLP_WCSNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0; + _STLP_WCSNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0; + + ret = wcscmp(buf1, buf2); + if (ret != 0) return ret < 0 ? -1 : 1; + s1 += bufsize1; n1 -= bufsize1; + s2 += bufsize2; n2 -= bufsize2; + } + return ret == 0 ? 0 : (ret < 0 ? -1 : 1); +} + +#endif + +size_t _Locale_strxfrm(struct _Locale_collate* lcol, + char* dest, size_t dest_n, + const char* src, size_t src_n) { + if (dest != 0) { + _STLP_STRNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0; + } + return src_n; +} + +#ifndef _STLP_NO_WCHAR_T + +size_t _WLocale_strxfrm(struct _Locale_collate* lcol, + wchar_t* dest, size_t dest_n, + const wchar_t* src, size_t src_n) { + if (dest != 0) { + _STLP_WCSNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0; + } + return src_n; +} + +#endif + +/* Numeric */ + +char _Locale_decimal_point(struct _Locale_numeric* lnum) +{ return '.'; } +char _Locale_thousands_sep(struct _Locale_numeric* lnum) +{ return ','; } +const char* _Locale_grouping(struct _Locale_numeric * lnum) +{ return _empty_str; } +const char * _Locale_true(struct _Locale_numeric * lnum) +{ return "true"; } +const char * _Locale_false(struct _Locale_numeric * lnum) +{ return "false"; } + +#ifndef _STLP_NO_WCHAR_T +wchar_t _WLocale_decimal_point(struct _Locale_numeric* lnum) +{ return L'.'; } +wchar_t _WLocale_thousands_sep(struct _Locale_numeric* lnum) +{ return L','; } +const wchar_t * _WLocale_true(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize) +{ return L"true"; } +const wchar_t * _WLocale_false(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize) +{ return L"false"; } +#endif + +/* Monetary */ + +const char* _Locale_int_curr_symbol(struct _Locale_monetary * lmon) +{ return _empty_str; } +const char* _Locale_currency_symbol(struct _Locale_monetary * lmon) +{ return _empty_str; } +char _Locale_mon_decimal_point(struct _Locale_monetary * lmon) +{ return '.'; } +char _Locale_mon_thousands_sep(struct _Locale_monetary * lmon) +{ return ','; } +const char* _Locale_mon_grouping(struct _Locale_monetary * lmon) +{ return _empty_str; } +const char* _Locale_positive_sign(struct _Locale_monetary * lmon) +{ return _empty_str; } +const char* _Locale_negative_sign(struct _Locale_monetary * lmon) +{ return _empty_str; } +char _Locale_int_frac_digits(struct _Locale_monetary * lmon) +{ return 0; } +char _Locale_frac_digits(struct _Locale_monetary * lmon) +{ return 0; } +int _Locale_p_cs_precedes(struct _Locale_monetary * lmon) +{ return CHAR_MAX; } +int _Locale_p_sep_by_space(struct _Locale_monetary * lmon) +{ return CHAR_MAX; } +int _Locale_p_sign_posn(struct _Locale_monetary * lmon) +{ return CHAR_MAX; } +int _Locale_n_cs_precedes(struct _Locale_monetary * lmon) +{ return CHAR_MAX; } +int _Locale_n_sep_by_space(struct _Locale_monetary * lmon) +{ return CHAR_MAX; } +int _Locale_n_sign_posn(struct _Locale_monetary * lmon) +{ return CHAR_MAX; } + +#ifndef _STLP_NO_WCHAR_T +const wchar_t* _WLocale_int_curr_symbol(struct _Locale_monetary * lmon, + wchar_t* buf, size_t bufSize) +{ return _empty_wstr; } +const wchar_t* _WLocale_currency_symbol(struct _Locale_monetary * lmon, + wchar_t* buf, size_t bufSize) +{ return _empty_wstr; } +wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * lmon) +{ return L'.'; } +wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * lmon) +{ return L','; } +const wchar_t* _WLocale_positive_sign(struct _Locale_monetary * lmon, + wchar_t* buf, size_t bufSize) +{ return _empty_wstr; } +const wchar_t* _WLocale_negative_sign(struct _Locale_monetary * lmon, + wchar_t* buf, size_t bufSize) +{ return _empty_wstr; } +#endif + +/* Time */ +static const char* full_monthname[] = +{ "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" }; +const char * _Locale_full_monthname(struct _Locale_time * ltime, int n) +{ return full_monthname[n]; } + +static const char* abbrev_monthname[] = +{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; +const char * _Locale_abbrev_monthname(struct _Locale_time * ltime, int n) +{ return abbrev_monthname[n]; } + +static const char* full_dayname[] = +{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; +const char * _Locale_full_dayofweek(struct _Locale_time * ltime, int n) +{ return full_dayname[n]; } + +static const char* abbrev_dayname[] = +{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; +const char * _Locale_abbrev_dayofweek(struct _Locale_time * ltime, int n) +{ return abbrev_dayname[n]; } + +const char* _Locale_d_t_fmt(struct _Locale_time* ltime) +{ return "%m/%d/%y"; } +const char* _Locale_d_fmt(struct _Locale_time* ltime) +{ return "%m/%d/%y"; } +const char* _Locale_t_fmt(struct _Locale_time* ltime) +{ return "%H:%M:%S"; } +const char* _Locale_long_d_t_fmt(struct _Locale_time* ltime) +{ return _empty_str; } +const char* _Locale_long_d_fmt(struct _Locale_time* ltime) +{ return _empty_str; } +const char* _Locale_am_str(struct _Locale_time* ltime) +{ return "AM"; } +const char* _Locale_pm_str(struct _Locale_time* ltime) +{ return "PM"; } + +#ifndef _STLP_NO_WCHAR_T +static const wchar_t* full_wmonthname[] = +{ L"January", L"February", L"March", L"April", L"May", L"June", + L"July", L"August", L"September", L"October", L"November", L"December" }; +const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime, int n, + wchar_t* buf, size_t bufSize) +{ return full_wmonthname[n]; } + +static const wchar_t* abbrev_wmonthname[] = +{ L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", + L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" }; +const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime, int n, + wchar_t* buf, size_t bufSize) +{ return abbrev_wmonthname[n]; } + +static const wchar_t* full_wdayname[] = +{ L"Sunday", L"Monday", L"Tuesday", L"Wednesday", L"Thursday", L"Friday", L"Saturday" }; +const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime, int n, + wchar_t* buf, size_t bufSize) +{ return full_wdayname[n]; } + +static const wchar_t* abbrev_wdayname[] = +{ L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat" }; +const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime, int n, + wchar_t* buf, size_t bufSize) +{ return abbrev_wdayname[n]; } + +const wchar_t* _WLocale_am_str(struct _Locale_time* ltime, + wchar_t* buf, size_t bufSize) +{ return L"AM"; } +const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime, + wchar_t* buf, size_t bufSize) +{ return L"PM"; } +#endif + +/* Messages */ + +nl_catd_type _Locale_catopen(struct _Locale_messages* lmes, const char* name) +{ return -1; } +void _Locale_catclose(struct _Locale_messages* lmes, nl_catd_type cat) {} +const char* _Locale_catgets(struct _Locale_messages* lmes, nl_catd_type cat, + int setid, int msgid, const char *dfault) +{ return dfault; } diff --git a/sdk/tlibstdcxx/src/c_locale_glibc/c_locale_glibc2.c b/sdk/tlibstdcxx/src/c_locale_glibc/c_locale_glibc2.c new file mode 100644 index 0000000000..0cf8279d5b --- /dev/null +++ b/sdk/tlibstdcxx/src/c_locale_glibc/c_locale_glibc2.c @@ -0,0 +1,705 @@ +#include +#include +#include +#include +#include +#include +#include + +static const char *_empty_str = ""; +static const char *_C_name = "C"; + +static wchar_t* _ToWChar(const char* buf, wchar_t *wbuf, size_t wbufSize) { + wchar_t *wcur = wbuf; + wchar_t *wend = wbuf + wbufSize - 1; + for (; wcur != wend && *buf != 0; ++buf, ++wcur) + *wcur = *buf; + *wcur = 0; + return wbuf; +} + +#if 0 +struct _Locale_ctype +{ + locale_t __cloc; +}; + +struct _Locale_numeric +{ + locale_t __cloc; +}; + +struct _Locale_time +{ + locale_t __cloc; +}; + +struct _Locale_collate +{ + locale_t __cloc; +}; + +struct _Locale_monetary +{ + locale_t __cloc; +}; + +struct _Locale_messages +{ + locale_t __cloc; +}; +#endif + +void _Locale_init() +{} + +void _Locale_final() +{} + +struct _Locale_ctype *_Locale_ctype_create(const char *nm, struct _Locale_name_hint* hint, + int *__err_code) { + *__err_code = _STLP_LOC_UNKNOWN_NAME; + return (struct _Locale_ctype*)newlocale(LC_CTYPE_MASK, nm, NULL); +} + +struct _Locale_codecvt *_Locale_codecvt_create(const char *nm, struct _Locale_name_hint* hint, + int *__err_code) { + // Glibc do not support multibyte manipulation for the moment, it simply implements "C". + if (nm[0] == 'C' && nm[1] == 0) + { return (struct _Locale_codecvt*)0x01; } + *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0; +} + +struct _Locale_numeric *_Locale_numeric_create(const char *nm, struct _Locale_name_hint* hint, + int *__err_code) { + *__err_code = _STLP_LOC_UNKNOWN_NAME; + return (struct _Locale_numeric*)newlocale(LC_NUMERIC_MASK, nm, NULL); +} + +struct _Locale_time *_Locale_time_create(const char *nm, struct _Locale_name_hint* hint, + int *__err_code) { + *__err_code = _STLP_LOC_UNKNOWN_NAME; + return (struct _Locale_time*)newlocale(LC_TIME_MASK, nm, NULL); +} + +struct _Locale_collate *_Locale_collate_create(const char *nm, struct _Locale_name_hint* hint, + int *__err_code) { + *__err_code = _STLP_LOC_UNKNOWN_NAME; + return (struct _Locale_collate*)newlocale(LC_COLLATE_MASK, nm, NULL); +} + +struct _Locale_monetary *_Locale_monetary_create(const char *nm, struct _Locale_name_hint* hint, + int *__err_code) { + *__err_code = _STLP_LOC_UNKNOWN_NAME; + return (struct _Locale_monetary*)newlocale(LC_MONETARY_MASK, nm, NULL); +} + +struct _Locale_messages *_Locale_messages_create(const char *nm, struct _Locale_name_hint* hint, + int *__err_code) { + *__err_code = _STLP_LOC_UNKNOWN_NAME; + return (struct _Locale_messages*)newlocale(LC_MESSAGES_MASK, nm, NULL); +} + +/* + try to see locale category LC should be used from environment; + according POSIX, the order is + 1. LC_ALL + 2. category (LC_CTYPE, LC_NUMERIC, ... ) + 3. LANG + If set nothing, return "C" (this really implementation-specific). +*/ +static const char *_Locale_aux_default( const char *LC, char *nm ) +{ + char *name = getenv( "LC_ALL" ); + + if ( name != NULL && *name != 0 ) { + return name; + } + name = getenv( LC ); + if ( name != NULL && *name != 0 ) { + return name; + } + name = getenv( "LANG" ); + if ( name != NULL && *name != 0 ) { + return name; + } + + return _C_name; +} + +const char *_Locale_ctype_default( char *nm ) +{ + return _Locale_aux_default( "LC_CTYPE", nm ); +} + +const char *_Locale_numeric_default( char *nm ) +{ + return _Locale_aux_default( "LC_NUMERIC", nm ); +} + +const char *_Locale_time_default( char *nm ) +{ + return _Locale_aux_default( "LC_TIME", nm ); +} + +const char *_Locale_collate_default( char *nm ) +{ + return _Locale_aux_default( "LC_COLLATE", nm ); +} + +const char *_Locale_monetary_default( char *nm ) +{ + return _Locale_aux_default( "LC_MONETARY", nm ); +} + +const char *_Locale_messages_default( char *nm ) +{ + return _Locale_aux_default( "LC_MESSAGES", nm ); +} + +char const*_Locale_ctype_name( const struct _Locale_ctype *__loc, char *buf ) +{ + return ((locale_t)__loc)->__names[LC_CTYPE]; +} + +char const*_Locale_codecvt_name( const struct _Locale_codecvt *__loc, char *buf ) +{ + return _C_name; +} + +char const*_Locale_numeric_name( const struct _Locale_numeric *__loc, char *buf ) +{ + return ((locale_t)__loc)->__names[LC_NUMERIC]; +} + +char const*_Locale_time_name( const struct _Locale_time *__loc, char *buf ) +{ + return ((locale_t)__loc)->__names[LC_TIME]; +} + +char const*_Locale_collate_name( const struct _Locale_collate *__loc, char *buf ) +{ + return ((locale_t)__loc)->__names[LC_COLLATE]; +} + +char const*_Locale_monetary_name( const struct _Locale_monetary *__loc, char *buf ) +{ + return ((locale_t)__loc)->__names[LC_MONETARY]; +} + +char const*_Locale_messages_name( const struct _Locale_messages *__loc, char *buf ) +{ + return ((locale_t)__loc)->__names[LC_MESSAGES]; +} + +void _Locale_ctype_destroy( struct _Locale_ctype *__loc ) +{ freelocale((locale_t)__loc); } + +void _Locale_codecvt_destroy( struct _Locale_codecvt *__loc ) +{} + +void _Locale_numeric_destroy( struct _Locale_numeric *__loc ) +{ freelocale((locale_t)__loc); } + +void _Locale_time_destroy( struct _Locale_time *__loc ) +{ freelocale((locale_t)__loc); } + +void _Locale_collate_destroy( struct _Locale_collate *__loc ) +{ freelocale((locale_t)__loc); } + +void _Locale_monetary_destroy( struct _Locale_monetary *__loc ) +{ freelocale((locale_t)__loc); } + +void _Locale_messages_destroy( struct _Locale_messages* __loc ) +{ freelocale((locale_t)__loc); } + +/* + * locale loc expected either locale name indeed (platform-specific) + * or string like "LC_CTYPE=LocaleNameForCType;LC_NUMERIC=LocaleNameForNum;" + * + */ + +static char const*__Extract_locale_name( const char *loc, const char *category, char *buf ) +{ + char *expr; + size_t len_name; + + if( loc[0]=='L' && loc[1]=='C' && loc[2]=='_') { + expr = strstr( (char*)loc, category ); + if ( expr == NULL ) + return NULL; /* Category not found. */ + ++expr; + len_name = strcspn( expr, ";" ); + len_name = len_name >= _Locale_MAX_SIMPLE_NAME ? _Locale_MAX_SIMPLE_NAME - 1 : len_name; + strncpy( buf, expr, len_name ); + buf[len_name] = 0; + return buf; + } + return loc; +} + +char const*_Locale_extract_ctype_name(const char *loc, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return __Extract_locale_name( loc, "LC_CTYPE=", buf ); } + +char const*_Locale_extract_numeric_name(const char *loc, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return __Extract_locale_name( loc, "LC_NUMERIC=", buf ); } + +char const*_Locale_extract_time_name(const char *loc, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return __Extract_locale_name( loc, "LC_TIME=", buf ); } + +char const*_Locale_extract_collate_name(const char *loc, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return __Extract_locale_name( loc, "LC_COLLATE=", buf ); } + +char const*_Locale_extract_monetary_name(const char *loc, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return __Extract_locale_name( loc, "LC_MONETARY=", buf ); } + +char const*_Locale_extract_messages_name(const char *loc, char *buf, + struct _Locale_name_hint* hint, int *__err_code) +{ return __Extract_locale_name( loc, "LC_MESSAGES=", buf ); } + +struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype) +{ return 0; } +struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric) +{ return 0; } +struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time) +{ return 0; } +struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate) +{ return 0; } +struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary) +{ return 0; } +struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages) +{ return 0; } + +/* ctype */ + +const _Locale_mask_t *_Locale_ctype_table( struct _Locale_ctype *__loc ) +{ + /* return table with masks (upper, lower, alpha, etc.) */ + _STLP_STATIC_ASSERT( sizeof(_Locale_mask_t) == sizeof(((locale_t)__loc)->__ctype_b[0]) ) + return ((locale_t)__loc)->__ctype_b; +} + +int _Locale_toupper( struct _Locale_ctype *__loc, int c ) +{ return ((locale_t)__loc)->__ctype_toupper[c]; } + +int _Locale_tolower( struct _Locale_ctype *__loc, int c ) +{ return ((locale_t)__loc)->__ctype_tolower[c]; } + +#if !defined (_STLP_NO_WCHAR_T) +_Locale_mask_t _WLocale_ctype( struct _Locale_ctype *__loc, wint_t wc, _Locale_mask_t __mask ) +{ + _Locale_mask_t ret = 0; + if ((__mask & _Locale_ALPHA) != 0 && iswalpha_l(wc, (locale_t)__loc)) + ret |= _Locale_ALPHA; + + if ((__mask & _Locale_CNTRL) != 0 && iswcntrl_l(wc, (locale_t)__loc)) + ret |= _Locale_CNTRL; + + if ((__mask & _Locale_DIGIT) != 0 && iswdigit_l(wc, (locale_t)__loc)) + ret |= _Locale_DIGIT; + + if ((__mask & _Locale_PRINT) != 0 && iswprint_l(wc, (locale_t)__loc)) + ret |= _Locale_PRINT; + + if ((__mask & _Locale_PUNCT) != 0 && iswpunct_l(wc, (locale_t)__loc)) + ret |= _Locale_PUNCT; + + if ((__mask & _Locale_SPACE) != 0 && iswspace_l(wc, (locale_t)__loc)) + ret |= _Locale_SPACE; + + if ((__mask & _Locale_XDIGIT) != 0 && iswxdigit_l(wc, (locale_t)__loc)) + ret |= _Locale_XDIGIT; + + if ((__mask & _Locale_UPPER) != 0 && iswupper_l(wc, (locale_t)__loc)) + ret |= _Locale_UPPER; + + if ((__mask & _Locale_LOWER) != 0 && iswlower_l(wc, (locale_t)__loc)) + ret |= _Locale_LOWER; + + return ret; +} + +wint_t _WLocale_tolower( struct _Locale_ctype *__loc, wint_t c ) +{ + return towlower_l( c, ((locale_t)__loc) ); +} + +wint_t _WLocale_toupper( struct _Locale_ctype *__loc, wint_t c ) +{ + return towupper_l( c, ((locale_t)__loc) ); +} +#endif + +int _WLocale_mb_cur_max( struct _Locale_codecvt * lcodecvt) { return 1; } +int _WLocale_mb_cur_min( struct _Locale_codecvt * lcodecvt) { return 1; } +int _WLocale_is_stateless( struct _Locale_codecvt * lcodecvt) { return 1; } + +#if !defined (_STLP_NO_WCHAR_T) +size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt, + wchar_t *to, + const char *from, size_t n, + mbstate_t *st) +{ *to = *from; return 1; } + +size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt, + char *to, size_t n, + const wchar_t c, + mbstate_t *st) +{ *to = (char)c; return 1; } +#endif + +size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt, + mbstate_t *st, + char *buf, size_t n, char ** next) +{ *next = buf; return 0; } + +/* Collate */ +int _Locale_strcmp(struct _Locale_collate * __loc, + const char *s1, size_t n1, + const char *s2, size_t n2) { + int ret = 0; + char buf1[64], buf2[64]; + while (n1 > 0 || n2 > 0) { + size_t bufsize1 = n1 < 63 ? n1 : 63; + size_t bufsize2 = n2 < 63 ? n2 : 63; + strncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0; + strncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0; + + ret = strcoll_l(buf1, buf2, (locale_t)__loc); + if (ret != 0) return ret; + s1 += bufsize1; n1 -= bufsize1; + s2 += bufsize2; n2 -= bufsize2; + } + return ret; +} + +#if !defined (_STLP_NO_WCHAR_T) +int _WLocale_strcmp(struct _Locale_collate *__loc, + const wchar_t *s1, size_t n1, + const wchar_t *s2, size_t n2) { + int ret = 0; + wchar_t buf1[64], buf2[64]; + while (n1 > 0 || n2 > 0) { + size_t bufsize1 = n1 < 63 ? n1 : 63; + size_t bufsize2 = n2 < 63 ? n2 : 63; + wcsncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0; + wcsncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0; + + ret = wcscoll_l(buf1, buf2, (locale_t)__loc); + if (ret != 0) return ret; + s1 += bufsize1; n1 -= bufsize1; + s2 += bufsize2; n2 -= bufsize2; + } + return ret; +} + +#endif + +size_t _Locale_strxfrm(struct _Locale_collate *__loc, + char *dest, size_t dest_n, + const char *src, size_t src_n ) +{ + const char *real_src; + char *buf = NULL; + size_t result; + + if (src_n == 0) + { + if (dest != NULL) dest[0] = 0; + return 0; + } + if (src[src_n] != 0) { + buf = malloc(src_n + 1); + strncpy(buf, src, src_n); + buf[src_n] = 0; + real_src = buf; + } + else + real_src = src; + result = strxfrm_l(dest, real_src, dest_n, (locale_t)__loc); + if (buf != NULL) free(buf); + return result; +} + +# ifndef _STLP_NO_WCHAR_T + +size_t _WLocale_strxfrm( struct _Locale_collate *__loc, + wchar_t *dest, size_t dest_n, + const wchar_t *src, size_t src_n ) +{ + const wchar_t *real_src; + wchar_t *buf = NULL; + size_t result; + + if (src_n == 0) + { + if (dest != NULL) dest[0] = 0; + return 0; + } + if (src[src_n] != 0) { + buf = malloc((src_n + 1) * sizeof(wchar_t)); + wcsncpy(buf, src, src_n); + buf[src_n] = 0; + real_src = buf; + } + else + real_src = src; + result = wcsxfrm_l(dest, real_src, dest_n, (locale_t)__loc); + if (buf != NULL) free(buf); + return result; +} + +# endif + +/* Numeric */ + +char _Locale_decimal_point(struct _Locale_numeric *__loc) +{ + return *(nl_langinfo_l(RADIXCHAR, (locale_t)__loc)); +} + +char _Locale_thousands_sep(struct _Locale_numeric *__loc) +{ + return *(nl_langinfo_l(THOUSEP, (locale_t)__loc)); +} + +const char* _Locale_grouping(struct _Locale_numeric *__loc) +{ + return (_Locale_thousands_sep(__loc) != 0 ) ? (nl_langinfo_l(GROUPING, (locale_t)__loc)) : _empty_str; +} + +const char *_Locale_true(struct _Locale_numeric *__loc) +{ + return nl_langinfo_l(YESSTR, (locale_t)__loc); +} + +const char *_Locale_false(struct _Locale_numeric *__loc) +{ + return nl_langinfo_l(NOSTR, (locale_t)__loc); +} + +#ifndef _STLP_NO_WCHAR_T +wchar_t _WLocale_decimal_point(struct _Locale_numeric *__loc) +{ return (wchar_t)_Locale_decimal_point(__loc); } +wchar_t _WLocale_thousands_sep(struct _Locale_numeric *__loc) +{ return (wchar_t)_Locale_thousands_sep(__loc); } +const wchar_t *_WLocale_true(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_true(__loc), buf, bufSize); } +const wchar_t *_WLocale_false(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_false(__loc), buf, bufSize); } +#endif + +/* Monetary */ + +const char *_Locale_int_curr_symbol(struct _Locale_monetary *__loc) +{ + return nl_langinfo_l(INT_CURR_SYMBOL, (locale_t)__loc); +} + +const char *_Locale_currency_symbol(struct _Locale_monetary *__loc) +{ + return nl_langinfo_l(CURRENCY_SYMBOL, (locale_t)__loc); +} + +char _Locale_mon_decimal_point(struct _Locale_monetary * __loc) +{ + return *(nl_langinfo_l(MON_DECIMAL_POINT,(locale_t)__loc)); +} + +char _Locale_mon_thousands_sep(struct _Locale_monetary *__loc) +{ + return *(nl_langinfo_l(MON_THOUSANDS_SEP, (locale_t)__loc)); +} + +#ifndef _STLP_NO_WCHAR_T +const wchar_t *_WLocale_int_curr_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_int_curr_symbol(__loc), buf, bufSize); } +const wchar_t *_WLocale_currency_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_currency_symbol(__loc), buf, bufSize); } +wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * __loc) +{ return (wchar_t)_Locale_mon_decimal_point(__loc); } +wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * __loc) +{ return (wchar_t)_Locale_mon_thousands_sep(__loc); } +const wchar_t *_WLocale_positive_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_positive_sign(__loc), buf, bufSize); } +const wchar_t *_WLocale_negative_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_negative_sign(__loc), buf, bufSize); } +#endif + +const char *_Locale_mon_grouping(struct _Locale_monetary *__loc) +{ + return (_Locale_mon_thousands_sep( __loc ) != 0 ) ? nl_langinfo_l(MON_GROUPING, (locale_t)__loc) : _empty_str; +} + +const char *_Locale_positive_sign(struct _Locale_monetary *__loc) +{ + return nl_langinfo_l(POSITIVE_SIGN, (locale_t)__loc); +} + +const char *_Locale_negative_sign(struct _Locale_monetary *__loc) +{ + return nl_langinfo_l(NEGATIVE_SIGN, (locale_t)__loc); +} + +char _Locale_int_frac_digits(struct _Locale_monetary *__loc) +{ + /* We are forced to manually handled the "C" locale for consistency with + * the default implementation in STLport. */ + const char* lname = ((locale_t)__loc)->__names[LC_MONETARY]; + if (lname[0] == 'C' && lname[1] == 0) + return 0; + return *(nl_langinfo_l(INT_FRAC_DIGITS, (locale_t)__loc)); +} + +char _Locale_frac_digits(struct _Locale_monetary *__loc) +{ + /* We are forced to manually handled the "C" locale for consistency with + * the default implementation in STLport. */ + const char* lname = ((locale_t)__loc)->__names[LC_MONETARY]; + if (lname[0] == 'C' && lname[1] == 0) + return 0; + return *(nl_langinfo_l(FRAC_DIGITS, (locale_t)__loc)); +} + +/* 1 if currency_symbol precedes a positive value, 0 if succeeds */ +int _Locale_p_cs_precedes(struct _Locale_monetary *__loc) +{ + return *(nl_langinfo_l(P_CS_PRECEDES, (locale_t)__loc)); +} + +/* 1 if a space separates currency_symbol from a positive value. */ +int _Locale_p_sep_by_space(struct _Locale_monetary *__loc) +{ + return *(nl_langinfo_l(P_SEP_BY_SPACE, (locale_t)__loc)); +} + +/* + * 0 Parentheses surround the quantity and currency_symbol + * 1 The sign string precedes the quantity and currency_symbol + * 2 The sign string succeeds the quantity and currency_symbol. + * 3 The sign string immediately precedes the currency_symbol. + * 4 The sign string immediately succeeds the currency_symbol. + */ +int _Locale_p_sign_posn(struct _Locale_monetary *__loc) +{ + return *(nl_langinfo_l(P_SIGN_POSN, (locale_t)__loc)); +} + +/* 1 if currency_symbol precedes a negative value, 0 if succeeds */ +int _Locale_n_cs_precedes(struct _Locale_monetary *__loc) +{ + return *(nl_langinfo_l(N_CS_PRECEDES, (locale_t)__loc)); +} + +/* 1 if a space separates currency_symbol from a negative value. */ +int _Locale_n_sep_by_space(struct _Locale_monetary *__loc) +{ + return *(nl_langinfo_l(N_SEP_BY_SPACE, (locale_t)__loc)); +} + +/* + * 0 Parentheses surround the quantity and currency_symbol + * 1 The sign string precedes the quantity and currency_symbol + * 2 The sign string succeeds the quantity and currency_symbol. + * 3 The sign string immediately precedes the currency_symbol. + * 4 The sign string immediately succeeds the currency_symbol. + */ +int _Locale_n_sign_posn(struct _Locale_monetary *__loc) +{ + return *(nl_langinfo_l(N_SIGN_POSN, (locale_t)__loc)); +} + + +/* Time */ +const char *_Locale_full_monthname(struct _Locale_time *__loc, int _m ) +{ + return nl_langinfo_l(MON_1 + _m, (locale_t)__loc); +} + +const char *_Locale_abbrev_monthname(struct _Locale_time *__loc, int _m ) +{ + return nl_langinfo_l(ABMON_1 + _m, (locale_t)__loc); +} + +const char *_Locale_full_dayofweek(struct _Locale_time *__loc, int _d ) +{ + return nl_langinfo_l(DAY_1 + _d, (locale_t)__loc); +} + +const char *_Locale_abbrev_dayofweek(struct _Locale_time *__loc, int _d ) +{ + return nl_langinfo_l(ABDAY_1 + _d, (locale_t)__loc); +} + +const char *_Locale_d_t_fmt(struct _Locale_time *__loc) +{ + return nl_langinfo_l(D_T_FMT, (locale_t)__loc); +} + +const char *_Locale_d_fmt(struct _Locale_time *__loc ) +{ + return nl_langinfo_l(D_FMT, (locale_t)__loc); +} + +const char *_Locale_t_fmt(struct _Locale_time *__loc ) +{ + return nl_langinfo_l(T_FMT, (locale_t)__loc); +} + +const char *_Locale_long_d_t_fmt(struct _Locale_time *__loc ) +{ + return nl_langinfo_l(ERA_D_T_FMT, (locale_t)__loc); +} + +const char *_Locale_long_d_fmt(struct _Locale_time *__loc ) +{ + return nl_langinfo_l(ERA_D_FMT, (locale_t)__loc); +} + +const char *_Locale_am_str(struct _Locale_time *__loc ) +{ + return nl_langinfo_l(AM_STR, (locale_t)__loc); +} + +const char *_Locale_pm_str(struct _Locale_time* __loc ) +{ + return nl_langinfo_l(PM_STR, (locale_t)__loc); +} + +#ifndef _STLP_NO_WCHAR_T +const wchar_t *_WLocale_full_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_full_monthname(__loc, _m), buf, bufSize); } +const wchar_t *_WLocale_abbrev_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_abbrev_monthname(__loc, _m), buf, bufSize); } +const wchar_t *_WLocale_full_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_full_dayofweek(__loc, _d), buf, bufSize); } +const wchar_t *_WLocale_abbrev_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_abbrev_dayofweek(__loc, _d), buf, bufSize); } +const wchar_t *_WLocale_am_str(struct _Locale_time *__loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_am_str(__loc), buf, bufSize); } +const wchar_t *_WLocale_pm_str(struct _Locale_time* __loc, wchar_t *buf, size_t bufSize) +{ return _ToWChar(_Locale_pm_str(__loc), buf, bufSize); } +#endif + +/* Messages */ + +nl_catd_type _Locale_catopen(struct _Locale_messages *__loc, const char *__cat_name ) +{ + return catopen( __cat_name, NL_CAT_LOCALE ); +} + +void _Locale_catclose(struct _Locale_messages *__loc, nl_catd_type __cat ) +{ + catclose( __cat ); +} + +const char *_Locale_catgets(struct _Locale_messages *__loc, nl_catd_type __cat, + int __setid, int __msgid, const char *dfault) +{ + return catgets( __cat, __setid, __msgid, dfault ); +} diff --git a/sdk/tlibstdcxx/src/codecvt.cpp b/sdk/tlibstdcxx/src/codecvt.cpp new file mode 100644 index 0000000000..113a262340 --- /dev/null +++ b/sdk/tlibstdcxx/src/codecvt.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include +#include + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// codecvt + +codecvt::~codecvt() {} + +int codecvt::do_length(state_type&, + const char* from, + const char* end, + size_t mx) const +{ return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); } + +int codecvt::do_max_length() const _STLP_NOTHROW +{ return 1; } + +bool +codecvt::do_always_noconv() const _STLP_NOTHROW +{ return true; } + +int +codecvt::do_encoding() const _STLP_NOTHROW +{ return 1; } + +codecvt_base::result +codecvt::do_unshift(state_type& /* __state */, + char* __to, + char* /* __to_limit */, + char*& __to_next) const +{ __to_next = __to; return noconv; } + +codecvt_base::result +codecvt::do_in (state_type& /* __state */ , + const char* __from, + const char* /* __from_end */, + const char*& __from_next, + char* __to, + char* /* __to_end */, + char*& __to_next) const +{ __from_next = __from; __to_next = __to; return noconv; } + +codecvt_base::result +codecvt::do_out(state_type& /* __state */, + const char* __from, + const char* /* __from_end */, + const char*& __from_next, + char* __to, + char* /* __to_limit */, + char*& __to_next) const +{ __from_next = __from; __to_next = __to; return noconv; } + + +#if !defined (_STLP_NO_WCHAR_T) +//---------------------------------------------------------------------- +// codecvt + +codecvt::~codecvt() {} + + +codecvt::result +codecvt::do_out(state_type& /* state */, + const intern_type* from, + const intern_type* from_end, + const intern_type*& from_next, + extern_type* to, + extern_type* to_limit, + extern_type*& to_next) const { + ptrdiff_t len = (min) (from_end - from, to_limit - to); + copy(from, from + len, to); + from_next = from + len; + to_next = to + len; + return ok; +} + +codecvt::result +codecvt::do_in (state_type& /* state */, + const extern_type* from, + const extern_type* from_end, + const extern_type*& from_next, + intern_type* to, + intern_type* to_limit, + intern_type*& to_next) const { + ptrdiff_t len = (min) (from_end - from, to_limit - to); + copy(__REINTERPRET_CAST(const unsigned char*, from), + __REINTERPRET_CAST(const unsigned char*, from) + len, to); + from_next = from + len; + to_next = to + len; + return ok; +} + +codecvt::result +codecvt::do_unshift(state_type& /* state */, + extern_type* to, + extern_type* , + extern_type*& to_next) const { + to_next = to; + return noconv; +} + +int codecvt::do_encoding() const _STLP_NOTHROW +{ return 1; } + +bool codecvt::do_always_noconv() const _STLP_NOTHROW +{ return true; } + +int codecvt::do_length(state_type&, + const extern_type* from, + const extern_type* end, + size_t mx) const +{ return (int)(min) ((size_t) (end - from), mx); } + +int codecvt::do_max_length() const _STLP_NOTHROW +{ return 1; } +#endif /* wchar_t */ + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/src/collate.cpp b/sdk/tlibstdcxx/src/collate.cpp new file mode 100644 index 0000000000..ee5540dfed --- /dev/null +++ b/sdk/tlibstdcxx/src/collate.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include + +_STLP_BEGIN_NAMESPACE + +// collate + +collate::~collate() {} + +int collate::do_compare(const char* low1, const char* high1, + const char* low2, const char* high2) const +{ return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); } + +string collate::do_transform(const char* low, const char* high) const +{ return string(low, high); } + +long collate::do_hash(const char* low, const char* high) const { + unsigned long result = 0; + for ( ; low < high; ++low) + result = 5 * result + *low; + return result; +} + +#if !defined (_STLP_NO_WCHAR_T) +// collate + +collate::~collate() {} + +int +collate::do_compare(const wchar_t* low1, const wchar_t* high1, + const wchar_t* low2, const wchar_t* high2) const +{ return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); } + +wstring collate::do_transform(const wchar_t* low, const wchar_t* high) const +{ return wstring(low, high); } + +long collate::do_hash(const wchar_t* low, const wchar_t* high) const { + unsigned long result = 0; + for ( ; low < high; ++low) + result = 5 * result + *low; + return result; +} +#endif + +_STLP_END_NAMESPACE + + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/src/complex.cpp b/sdk/tlibstdcxx/src/complex.cpp new file mode 100644 index 0000000000..50f310ca5a --- /dev/null +++ b/sdk/tlibstdcxx/src/complex.cpp @@ -0,0 +1,347 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include +#include + +#if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB >= 1400) +// hypot is deprecated. +# if defined (_STLP_MSVC) +# pragma warning (disable : 4996) +# elif defined (__ICL) +# pragma warning (disable : 1478) +# endif +#endif + +_STLP_BEGIN_NAMESPACE + +// Complex division and square roots. + +// Absolute value +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC float _STLP_CALL abs(const complex& __z) +{ return ::hypot(__z._M_re, __z._M_im); } +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC double _STLP_CALL abs(const complex& __z) +{ return ::hypot(__z._M_re, __z._M_im); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC long double _STLP_CALL abs(const complex& __z) +{ return ::hypot(__z._M_re, __z._M_im); } +#endif + +// Phase + +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC float _STLP_CALL arg(const complex& __z) +{ return ::atan2(__z._M_im, __z._M_re); } + +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC double _STLP_CALL arg(const complex& __z) +{ return ::atan2(__z._M_im, __z._M_re); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC long double _STLP_CALL arg(const complex& __z) +{ return ::atan2(__z._M_im, __z._M_re); } +#endif + +// Construct a complex number from polar representation +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC complex _STLP_CALL polar(const float& __rho, const float& __phi) +{ return complex(__rho * ::cos(__phi), __rho * ::sin(__phi)); } +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC complex _STLP_CALL polar(const double& __rho, const double& __phi) +{ return complex(__rho * ::cos(__phi), __rho * ::sin(__phi)); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC complex _STLP_CALL polar(const long double& __rho, const long double& __phi) +{ return complex(__rho * ::cos(__phi), __rho * ::sin(__phi)); } +#endif + +// Division +template +static void _divT(const _Tp& __z1_r, const _Tp& __z1_i, + const _Tp& __z2_r, const _Tp& __z2_i, + _Tp& __res_r, _Tp& __res_i) { + _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r; + _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i; + + if (__ar <= __ai) { + _Tp __ratio = __z2_r / __z2_i; + _Tp __denom = __z2_i * (1 + __ratio * __ratio); + __res_r = (__z1_r * __ratio + __z1_i) / __denom; + __res_i = (__z1_i * __ratio - __z1_r) / __denom; + } + else { + _Tp __ratio = __z2_i / __z2_r; + _Tp __denom = __z2_r * (1 + __ratio * __ratio); + __res_r = (__z1_r + __z1_i * __ratio) / __denom; + __res_i = (__z1_i - __z1_r * __ratio) / __denom; + } +} + +template +static void _divT(const _Tp& __z1_r, + const _Tp& __z2_r, const _Tp& __z2_i, + _Tp& __res_r, _Tp& __res_i) { + _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r; + _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i; + + if (__ar <= __ai) { + _Tp __ratio = __z2_r / __z2_i; + _Tp __denom = __z2_i * (1 + __ratio * __ratio); + __res_r = (__z1_r * __ratio) / __denom; + __res_i = - __z1_r / __denom; + } + else { + _Tp __ratio = __z2_i / __z2_r; + _Tp __denom = __z2_r * (1 + __ratio * __ratio); + __res_r = __z1_r / __denom; + __res_i = - (__z1_r * __ratio) / __denom; + } +} + +void _STLP_CALL +complex::_div(const float& __z1_r, const float& __z1_i, + const float& __z2_r, const float& __z2_i, + float& __res_r, float& __res_i) +{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); } + +void _STLP_CALL +complex::_div(const float& __z1_r, + const float& __z2_r, const float& __z2_i, + float& __res_r, float& __res_i) +{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); } + + +void _STLP_CALL +complex::_div(const double& __z1_r, const double& __z1_i, + const double& __z2_r, const double& __z2_i, + double& __res_r, double& __res_i) +{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); } + +void _STLP_CALL +complex::_div(const double& __z1_r, + const double& __z2_r, const double& __z2_i, + double& __res_r, double& __res_i) +{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +void _STLP_CALL +complex::_div(const long double& __z1_r, const long double& __z1_i, + const long double& __z2_r, const long double& __z2_i, + long double& __res_r, long double& __res_i) +{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); } + +void _STLP_CALL +complex::_div(const long double& __z1_r, + const long double& __z2_r, const long double& __z2_i, + long double& __res_r, long double& __res_i) +{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); } +#endif + +//---------------------------------------------------------------------- +// Square root +template +static complex<_Tp> sqrtT(const complex<_Tp>& z) { + _Tp re = z._M_re; + _Tp im = z._M_im; + _Tp mag = ::hypot(re, im); + complex<_Tp> result; + + if (mag == 0.f) { + result._M_re = result._M_im = 0.f; + } else if (re > 0.f) { + result._M_re = ::sqrt(0.5f * (mag + re)); + result._M_im = im/result._M_re/2.f; + } else { + result._M_im = ::sqrt(0.5f * (mag - re)); + if (im < 0.f) + result._M_im = - result._M_im; + result._M_re = im/result._M_im/2.f; + } + return result; +} + +complex _STLP_CALL +sqrt(const complex& z) { return sqrtT(z); } + +complex _STLP_CALL +sqrt(const complex& z) { return sqrtT(z); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +complex _STLP_CALL +sqrt(const complex& z) { return sqrtT(z); } +#endif + +// exp, log, pow for complex, complex, and complex +//---------------------------------------------------------------------- +// exp +template +static complex<_Tp> expT(const complex<_Tp>& z) { + _Tp expx = ::exp(z._M_re); + return complex<_Tp>(expx * ::cos(z._M_im), + expx * ::sin(z._M_im)); +} +_STLP_DECLSPEC complex _STLP_CALL exp(const complex& z) +{ return expT(z); } + +_STLP_DECLSPEC complex _STLP_CALL exp(const complex& z) +{ return expT(z); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL exp(const complex& z) +{ return expT(z); } +#endif + +//---------------------------------------------------------------------- +// log10 +template +static complex<_Tp> log10T(const complex<_Tp>& z, const _Tp& ln10_inv) { + complex<_Tp> r; + + r._M_im = ::atan2(z._M_im, z._M_re) * ln10_inv; + r._M_re = ::log10(::hypot(z._M_re, z._M_im)); + return r; +} + +static const float LN10_INVF = 1.f / ::log(10.f); +_STLP_DECLSPEC complex _STLP_CALL log10(const complex& z) +{ return log10T(z, LN10_INVF); } + +static const double LN10_INV = 1. / ::log10(10.); +_STLP_DECLSPEC complex _STLP_CALL log10(const complex& z) +{ return log10T(z, LN10_INV); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +static const long double LN10_INVL = 1.l / ::log(10.l); +_STLP_DECLSPEC complex _STLP_CALL log10(const complex& z) +{ return log10T(z, LN10_INVL); } +#endif + +//---------------------------------------------------------------------- +// log +template +static complex<_Tp> logT(const complex<_Tp>& z) { + complex<_Tp> r; + + r._M_im = ::atan2(z._M_im, z._M_re); + r._M_re = ::log(::hypot(z._M_re, z._M_im)); + return r; +} +_STLP_DECLSPEC complex _STLP_CALL log(const complex& z) +{ return logT(z); } + +_STLP_DECLSPEC complex _STLP_CALL log(const complex& z) +{ return logT(z); } + +#ifndef _STLP_NO_LONG_DOUBLE +_STLP_DECLSPEC complex _STLP_CALL log(const complex& z) +{ return logT(z); } +# endif + +//---------------------------------------------------------------------- +// pow +template +static complex<_Tp> powT(const _Tp& a, const complex<_Tp>& b) { + _Tp logr = ::log(a); + _Tp x = ::exp(logr * b._M_re); + _Tp y = logr * b._M_im; + + return complex<_Tp>(x * ::cos(y), x * ::sin(y)); +} + +template +static complex<_Tp> powT(const complex<_Tp>& z_in, int n) { + complex<_Tp> z = z_in; + z = _STLP_PRIV __power(z, (n < 0 ? -n : n), multiplies< complex<_Tp> >()); + if (n < 0) + return _Tp(1.0) / z; + else + return z; +} + +template +static complex<_Tp> powT(const complex<_Tp>& a, const _Tp& b) { + _Tp logr = ::log(::hypot(a._M_re,a._M_im)); + _Tp logi = ::atan2(a._M_im, a._M_re); + _Tp x = ::exp(logr * b); + _Tp y = logi * b; + + return complex<_Tp>(x * ::cos(y), x * ::sin(y)); +} + +template +static complex<_Tp> powT(const complex<_Tp>& a, const complex<_Tp>& b) { + _Tp logr = ::log(::hypot(a._M_re,a._M_im)); + _Tp logi = ::atan2(a._M_im, a._M_re); + _Tp x = ::exp(logr * b._M_re - logi * b._M_im); + _Tp y = logr * b._M_im + logi * b._M_re; + + return complex<_Tp>(x * ::cos(y), x * ::sin(y)); +} + +_STLP_DECLSPEC complex _STLP_CALL pow(const float& a, const complex& b) +{ return powT(a, b); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& z_in, int n) +{ return powT(z_in, n); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& a, const float& b) +{ return powT(a, b); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& a, const complex& b) +{ return powT(a, b); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const double& a, const complex& b) +{ return powT(a, b); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& z_in, int n) +{ return powT(z_in, n); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& a, const double& b) +{ return powT(a, b); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& a, const complex& b) +{ return powT(a, b); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL pow(const long double& a, + const complex& b) +{ return powT(a, b); } + + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& z_in, int n) +{ return powT(z_in, n); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& a, + const long double& b) +{ return powT(a, b); } + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex& a, + const complex& b) +{ return powT(a, b); } +#endif + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/complex_io.cpp b/sdk/tlibstdcxx/src/complex_io.cpp new file mode 100644 index 0000000000..4cb6636f63 --- /dev/null +++ b/sdk/tlibstdcxx/src/complex_io.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include + +_STLP_BEGIN_NAMESPACE + +// Specializations for narrow characters; lets us avoid the nuisance of +// widening. +_STLP_OPERATOR_SPEC +basic_ostream >& _STLP_CALL +operator<< (basic_ostream >& __os, const complex& __z) +{ return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; } + +_STLP_OPERATOR_SPEC +basic_ostream >& _STLP_CALL +operator<< (basic_ostream >& __os, const complex& __z) +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } + +#ifndef _STLP_NO_LONG_DOUBLE +_STLP_OPERATOR_SPEC +basic_ostream >& _STLP_CALL +operator<< (basic_ostream >& __os, const complex& __z) +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } +#endif + +// Specialization for narrow characters; lets us avoid widen. +_STLP_OPERATOR_SPEC +basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z) { + float __re = 0; + float __im = 0; + + char __c; + + __is >> __c; + if (__c == '(') { + __is >> __re >> __c; + if (__c == ',') + __is >> __im >> __c; + if (__c != ')') + __is.setstate(ios_base::failbit); + } + else { + __is.putback(__c); + __is >> __re; + } + + if (__is) + __z = complex(__re, __im); + return __is; +} + +_STLP_OPERATOR_SPEC +basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z) { + double __re = 0; + double __im = 0; + + char __c; + + __is >> __c; + if (__c == '(') { + __is >> __re >> __c; + if (__c == ',') + __is >> __im >> __c; + if (__c != ')') + __is.setstate(ios_base::failbit); + } + else { + __is.putback(__c); + __is >> __re; + } + + if (__is) + __z = complex(__re, __im); + return __is; +} + +#ifndef _STLP_NO_LONG_DOUBLE +_STLP_OPERATOR_SPEC +basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z) { + long double __re = 0; + long double __im = 0; + + char __c; + + __is >> __c; + if (__c == '(') { + __is >> __re >> __c; + if (__c == ',') + __is >> __im >> __c; + if (__c != ')') + __is.setstate(ios_base::failbit); + } + else { + __is.putback(__c); + __is >> __re; + } + + if (__is) + __z = complex(__re, __im); + return __is; +} +#endif + +// Force instantiation of complex I/O functions +#if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T)) + +_STLP_OPERATOR_SPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); + +_STLP_OPERATOR_SPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); + +#ifndef _STLP_NO_LONG_DOUBLE +_STLP_OPERATOR_SPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); + +_STLP_OPERATOR_SPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); +#endif + +_STLP_OPERATOR_SPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); + +_STLP_OPERATOR_SPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); + +#endif /* _STLP_NO_WCHAR_T */ + +_STLP_END_NAMESPACE + + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/src/complex_trig.cpp b/sdk/tlibstdcxx/src/complex_trig.cpp new file mode 100644 index 0000000000..f566fe9913 --- /dev/null +++ b/sdk/tlibstdcxx/src/complex_trig.cpp @@ -0,0 +1,192 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + + +// Trigonometric and hyperbolic functions for complex, +// complex, and complex +#include +#include +#include + +_STLP_BEGIN_NAMESPACE + + +//---------------------------------------------------------------------- +// helpers +#if defined (__sgi) + static const union { unsigned int i; float f; } float_ulimit = { 0x42b2d4fc }; + static const float float_limit = float_ulimit.f; + static union { + struct { unsigned int h; unsigned int l; } w; + double d; + } double_ulimit = { 0x408633ce, 0x8fb9f87d }; + static const double double_limit = double_ulimit.d; + static union { + struct { unsigned int h[2]; unsigned int l[2]; } w; + long double ld; + } ldouble_ulimit = {0x408633ce, 0x8fb9f87e, 0xbd23b659, 0x4e9bd8b1}; +# if !defined (_STLP_NO_LONG_DOUBLE) + static const long double ldouble_limit = ldouble_ulimit.ld; +# endif +#else +# if defined (M_LN2) && defined (FLT_MAX_EXP) + static const float float_limit = float(M_LN2 * FLT_MAX_EXP); + static const double double_limit = M_LN2 * DBL_MAX_EXP; +# else + static const float float_limit = ::log(FLT_MAX); + static const double double_limit = ::log(DBL_MAX); +# endif +# if !defined (_STLP_NO_LONG_DOUBLE) +# if defined (M_LN2l) + static const long double ldouble_limit = M_LN2l * LDBL_MAX_EXP; +# else + static const long double ldouble_limit = ::log(LDBL_MAX); +# endif +# endif +#endif + + +//---------------------------------------------------------------------- +// sin +template +static complex<_Tp> sinT(const complex<_Tp>& z) { + return complex<_Tp>(::sin(z._M_re) * ::cosh(z._M_im), + ::cos(z._M_re) * ::sinh(z._M_im)); +} + +_STLP_DECLSPEC complex _STLP_CALL sin(const complex& z) +{ return sinT(z); } + +_STLP_DECLSPEC complex _STLP_CALL sin(const complex& z) +{ return sinT(z); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL sin(const complex& z) +{ return sinT(z); } +#endif + +//---------------------------------------------------------------------- +// cos +template +static complex<_Tp> cosT(const complex<_Tp>& z) { + return complex<_Tp>(::cos(z._M_re) * ::cosh(z._M_im), + -::sin(z._M_re) * ::sinh(z._M_im)); +} + +_STLP_DECLSPEC complex _STLP_CALL cos(const complex& z) +{ return cosT(z); } + +_STLP_DECLSPEC complex _STLP_CALL cos(const complex& z) +{ return cosT(z); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL cos(const complex& z) +{ return cosT(z); } +#endif + +//---------------------------------------------------------------------- +// tan +template +static complex<_Tp> tanT(const complex<_Tp>& z, const _Tp& Tp_limit) { + _Tp re2 = 2.f * z._M_re; + _Tp im2 = 2.f * z._M_im; + + if (::abs(im2) > Tp_limit) + return complex<_Tp>(0.f, (im2 > 0 ? 1.f : -1.f)); + else { + _Tp den = ::cos(re2) + ::cosh(im2); + return complex<_Tp>(::sin(re2) / den, ::sinh(im2) / den); + } +} + +_STLP_DECLSPEC complex _STLP_CALL tan(const complex& z) +{ return tanT(z, float_limit); } + +_STLP_DECLSPEC complex _STLP_CALL tan(const complex& z) +{ return tanT(z, double_limit); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL tan(const complex& z) +{ return tanT(z, ldouble_limit); } +#endif + +//---------------------------------------------------------------------- +// sinh +template +static complex<_Tp> sinhT(const complex<_Tp>& z) { + return complex<_Tp>(::sinh(z._M_re) * ::cos(z._M_im), + ::cosh(z._M_re) * ::sin(z._M_im)); +} + +_STLP_DECLSPEC complex _STLP_CALL sinh(const complex& z) +{ return sinhT(z); } + +_STLP_DECLSPEC complex _STLP_CALL sinh(const complex& z) +{ return sinhT(z); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL sinh(const complex& z) +{ return sinhT(z); } +#endif + +//---------------------------------------------------------------------- +// cosh +template +static complex<_Tp> coshT(const complex<_Tp>& z) { + return complex<_Tp>(::cosh(z._M_re) * ::cos(z._M_im), + ::sinh(z._M_re) * ::sin(z._M_im)); +} + +_STLP_DECLSPEC complex _STLP_CALL cosh(const complex& z) +{ return coshT(z); } + +_STLP_DECLSPEC complex _STLP_CALL cosh(const complex& z) +{ return coshT(z); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL cosh(const complex& z) +{ return coshT(z); } +#endif + +//---------------------------------------------------------------------- +// tanh +template +static complex<_Tp> tanhT(const complex<_Tp>& z, const _Tp& Tp_limit) { + _Tp re2 = 2.f * z._M_re; + _Tp im2 = 2.f * z._M_im; + if (::abs(re2) > Tp_limit) + return complex<_Tp>((re2 > 0 ? 1.f : -1.f), 0.f); + else { + _Tp den = ::cosh(re2) + ::cos(im2); + return complex<_Tp>(::sinh(re2) / den, ::sin(im2) / den); + } +} + +_STLP_DECLSPEC complex _STLP_CALL tanh(const complex& z) +{ return tanhT(z, float_limit); } + +_STLP_DECLSPEC complex _STLP_CALL tanh(const complex& z) +{ return tanhT(z, double_limit); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL tanh(const complex& z) +{ return tanhT(z, ldouble_limit); } +#endif + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/ctype.cpp b/sdk/tlibstdcxx/src/ctype.cpp new file mode 100644 index 0000000000..b1e84b1568 --- /dev/null +++ b/sdk/tlibstdcxx/src/ctype.cpp @@ -0,0 +1,486 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include +#include + +#include "c_locale.h" + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// ctype + +// The classic table: static data members. + +#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) +//*TY 02/25/2000 - added workaround for MPW compilers; they confuse on in-class static const +const size_t ctype::table_size; +#endif + +// This macro is specifically for platforms where isprint() relies +// on separate flag + +const ctype_base::mask* +ctype::classic_table() _STLP_NOTHROW { + /* Ctype table for the ASCII character set. */ + static const ctype_base::mask _S_classic_table[table_size] = { + cntrl /* null */, + cntrl /* ^A */, + cntrl /* ^B */, + cntrl /* ^C */, + cntrl /* ^D */, + cntrl /* ^E */, + cntrl /* ^F */, + cntrl /* ^G */, + cntrl /* ^H */, + ctype_base::mask(space | cntrl) /* tab */, + ctype_base::mask(space | cntrl) /* LF */, + ctype_base::mask(space | cntrl) /* ^K */, + ctype_base::mask(space | cntrl) /* FF */, + ctype_base::mask(space | cntrl) /* ^M */, + cntrl /* ^N */, + cntrl /* ^O */, + cntrl /* ^P */, + cntrl /* ^Q */, + cntrl /* ^R */, + cntrl /* ^S */, + cntrl /* ^T */, + cntrl /* ^U */, + cntrl /* ^V */, + cntrl /* ^W */, + cntrl /* ^X */, + cntrl /* ^Y */, + cntrl /* ^Z */, + cntrl /* esc */, + cntrl /* ^\ */, + cntrl /* ^] */, + cntrl /* ^^ */, + cntrl /* ^_ */, + ctype_base::mask(space | print) /* */, + ctype_base::mask(punct | print) /* ! */, + ctype_base::mask(punct | print) /* " */, + ctype_base::mask(punct | print) /* # */, + ctype_base::mask(punct | print) /* $ */, + ctype_base::mask(punct | print) /* % */, + ctype_base::mask(punct | print) /* & */, + ctype_base::mask(punct | print) /* ' */, + ctype_base::mask(punct | print) /* ( */, + ctype_base::mask(punct | print) /* ) */, + ctype_base::mask(punct | print) /* * */, + ctype_base::mask(punct | print) /* + */, + ctype_base::mask(punct | print) /* , */, + ctype_base::mask(punct | print) /* - */, + ctype_base::mask(punct | print) /* . */, + ctype_base::mask(punct | print) /* / */, + ctype_base::mask(digit | print | xdigit) /* 0 */, + ctype_base::mask(digit | print | xdigit) /* 1 */, + ctype_base::mask(digit | print | xdigit) /* 2 */, + ctype_base::mask(digit | print | xdigit) /* 3 */, + ctype_base::mask(digit | print | xdigit) /* 4 */, + ctype_base::mask(digit | print | xdigit) /* 5 */, + ctype_base::mask(digit | print | xdigit) /* 6 */, + ctype_base::mask(digit | print | xdigit) /* 7 */, + ctype_base::mask(digit | print | xdigit) /* 8 */, + ctype_base::mask(digit | print | xdigit) /* 9 */, + ctype_base::mask(punct | print) /* : */, + ctype_base::mask(punct | print) /* ; */, + ctype_base::mask(punct | print) /* < */, + ctype_base::mask(punct | print) /* = */, + ctype_base::mask(punct | print) /* > */, + ctype_base::mask(punct | print) /* ? */, + ctype_base::mask(punct | print) /* ! */, + ctype_base::mask(alpha | print | upper | xdigit) /* A */, + ctype_base::mask(alpha | print | upper | xdigit) /* B */, + ctype_base::mask(alpha | print | upper | xdigit) /* C */, + ctype_base::mask(alpha | print | upper | xdigit) /* D */, + ctype_base::mask(alpha | print | upper | xdigit) /* E */, + ctype_base::mask(alpha | print | upper | xdigit) /* F */, + ctype_base::mask(alpha | print | upper) /* G */, + ctype_base::mask(alpha | print | upper) /* H */, + ctype_base::mask(alpha | print | upper) /* I */, + ctype_base::mask(alpha | print | upper) /* J */, + ctype_base::mask(alpha | print | upper) /* K */, + ctype_base::mask(alpha | print | upper) /* L */, + ctype_base::mask(alpha | print | upper) /* M */, + ctype_base::mask(alpha | print | upper) /* N */, + ctype_base::mask(alpha | print | upper) /* O */, + ctype_base::mask(alpha | print | upper) /* P */, + ctype_base::mask(alpha | print | upper) /* Q */, + ctype_base::mask(alpha | print | upper) /* R */, + ctype_base::mask(alpha | print | upper) /* S */, + ctype_base::mask(alpha | print | upper) /* T */, + ctype_base::mask(alpha | print | upper) /* U */, + ctype_base::mask(alpha | print | upper) /* V */, + ctype_base::mask(alpha | print | upper) /* W */, + ctype_base::mask(alpha | print | upper) /* X */, + ctype_base::mask(alpha | print | upper) /* Y */, + ctype_base::mask(alpha | print | upper) /* Z */, + ctype_base::mask(punct | print) /* [ */, + ctype_base::mask(punct | print) /* \ */, + ctype_base::mask(punct | print) /* ] */, + ctype_base::mask(punct | print) /* ^ */, + ctype_base::mask(punct | print) /* _ */, + ctype_base::mask(punct | print) /* ` */, + ctype_base::mask(alpha | print | lower | xdigit) /* a */, + ctype_base::mask(alpha | print | lower | xdigit) /* b */, + ctype_base::mask(alpha | print | lower | xdigit) /* c */, + ctype_base::mask(alpha | print | lower | xdigit) /* d */, + ctype_base::mask(alpha | print | lower | xdigit) /* e */, + ctype_base::mask(alpha | print | lower | xdigit) /* f */, + ctype_base::mask(alpha | print | lower) /* g */, + ctype_base::mask(alpha | print | lower) /* h */, + ctype_base::mask(alpha | print | lower) /* i */, + ctype_base::mask(alpha | print | lower) /* j */, + ctype_base::mask(alpha | print | lower) /* k */, + ctype_base::mask(alpha | print | lower) /* l */, + ctype_base::mask(alpha | print | lower) /* m */, + ctype_base::mask(alpha | print | lower) /* n */, + ctype_base::mask(alpha | print | lower) /* o */, + ctype_base::mask(alpha | print | lower) /* p */, + ctype_base::mask(alpha | print | lower) /* q */, + ctype_base::mask(alpha | print | lower) /* r */, + ctype_base::mask(alpha | print | lower) /* s */, + ctype_base::mask(alpha | print | lower) /* t */, + ctype_base::mask(alpha | print | lower) /* u */, + ctype_base::mask(alpha | print | lower) /* v */, + ctype_base::mask(alpha | print | lower) /* w */, + ctype_base::mask(alpha | print | lower) /* x */, + ctype_base::mask(alpha | print | lower) /* y */, + ctype_base::mask(alpha | print | lower) /* z */, + ctype_base::mask(punct | print) /* { */, + ctype_base::mask(punct | print) /* | */, + ctype_base::mask(punct | print) /* } */, + ctype_base::mask(punct | print) /* ~ */, + cntrl /* del (0x7f)*/, + /* ASCII is a 7-bit code, so everything else is non-ASCII */ + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), + ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0) + }; + return _S_classic_table; +} + +// For every c in the range 0 <= c < 256, _S_upper[c] is the +// uppercased version of c and _S_lower[c] is the lowercased +// version. As before, these two tables assume the ASCII character +// set. + +const unsigned char _S_upper[ctype::table_size] = +{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; + +const unsigned char _S_lower[ctype::table_size] = +{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; + +//An helper struct to check wchar_t index without generating warnings +//under some compilers (gcc) because of a limited range of value +//(when wchar_t is unsigned) +template +struct _WCharIndexT; + +#if !(defined (__BORLANDC__) && !defined(__linux__)) && \ + !(defined (__GNUC__) && (defined (__MINGW32__) || defined (__CYGWIN__))) && \ + !defined (__ICL) +_STLP_TEMPLATE_NULL +struct _WCharIndexT { + static bool in_range(wchar_t c, size_t upperBound) { + return c >= 0 && size_t(c) < upperBound; + } +}; +#endif + +_STLP_TEMPLATE_NULL +struct _WCharIndexT { + static bool in_range(wchar_t c, size_t upperBound) { + return size_t(c) < upperBound; + } +}; + +typedef _WCharIndexT _WCharIndex; + +// Some helper functions used in ctype<>::scan_is and scan_is_not. + +struct _Ctype_is_mask : public unary_function { + ctype_base::mask _Mask; + const ctype_base::mask* _M_table; + + _Ctype_is_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {} + bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) != 0; } +}; + +struct _Ctype_not_mask : public unary_function { + ctype_base::mask _Mask; + const ctype_base::mask* _M_table; + + _Ctype_not_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {} + bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) == 0; } +}; + +ctype::ctype(const ctype_base::mask * __tab, bool __del, size_t __refs) : + locale::facet(__refs), + _M_ctype_table(__tab ? __tab : classic_table()), + _M_delete(__tab && __del) +{} + +ctype::~ctype() { + if (_M_delete) + delete[] __CONST_CAST(ctype_base::mask *, _M_ctype_table); +} + +const char* +#if defined (__DMC__) +_STLP_DECLSPEC +#endif +ctype::scan_is(ctype_base::mask __m, const char* __low, const char* __high) const +{ return _STLP_STD::find_if(__low, __high, _Ctype_is_mask(__m, _M_ctype_table)); } + +const char* +#if defined (__DMC__) +_STLP_DECLSPEC +#endif +ctype::scan_not(ctype_base::mask __m, const char* __low, const char* __high) const +{ return _STLP_STD::find_if(__low, __high, _Ctype_not_mask(__m, _M_ctype_table)); } + +char ctype::do_toupper(char __c) const +{ return (char) _S_upper[(unsigned char) __c]; } +char ctype::do_tolower(char __c) const +{ return (char) _S_lower[(unsigned char) __c]; } + +const char* ctype::do_toupper(char* __low, const char* __high) const { + for ( ; __low < __high; ++__low) + *__low = (char) _S_upper[(unsigned char) *__low]; + return __high; +} +const char* ctype::do_tolower(char* __low, const char* __high) const { + for ( ; __low < __high; ++__low) + *__low = (char) _S_lower[(unsigned char) *__low]; + return __high; +} + +char +ctype::do_widen(char __c) const { return __c; } + +const char* +ctype::do_widen(const char* __low, const char* __high, + char* __to) const { + _STLP_PRIV __copy_trivial(__low, __high, __to); + return __high; +} +char +ctype::do_narrow(char __c, char /* dfault */ ) const { return __c; } +const char* +ctype::do_narrow(const char* __low, const char* __high, + char /* dfault */, char* __to) const { + _STLP_PRIV __copy_trivial(__low, __high, __to); + return __high; +} + + +#if !defined (_STLP_NO_WCHAR_T) + +struct _Ctype_w_is_mask : public unary_function { + ctype_base::mask M; + const ctype_base::mask* table; + + _Ctype_w_is_mask(ctype_base::mask m, const ctype_base::mask* t) + : M(m), table(t) {} + bool operator()(wchar_t c) const + { return _WCharIndex::in_range(c, ctype::table_size) && (table[c] & M); } +}; + +//---------------------------------------------------------------------- +// ctype + +ctype::~ctype() {} + + +bool ctype::do_is(ctype_base::mask m, wchar_t c) const { + const ctype_base::mask * table = ctype::classic_table(); + return _WCharIndex::in_range(c, ctype::table_size) && (m & table[c]); +} + +const wchar_t* ctype::do_is(const wchar_t* low, const wchar_t* high, + ctype_base::mask * vec) const { + // boris : not clear if this is the right thing to do... + const ctype_base::mask * table = ctype::classic_table(); + wchar_t c; + for ( ; low < high; ++low, ++vec) { + c = *low; + *vec = _WCharIndex::in_range(c, ctype::table_size) ? table[c] : ctype_base::mask(0); + } + return high; +} + +const wchar_t* +ctype::do_scan_is(ctype_base::mask m, + const wchar_t* low, const wchar_t* high) const { + return find_if(low, high, _Ctype_w_is_mask(m, ctype::classic_table())); +} + + +const wchar_t* +ctype::do_scan_not(ctype_base::mask m, + const wchar_t* low, const wchar_t* high) const { + return find_if(low, high, not1(_Ctype_w_is_mask(m, ctype::classic_table()))); +} + +wchar_t ctype::do_toupper(wchar_t c) const { + return _WCharIndex::in_range(c, ctype::table_size) ? (wchar_t)_S_upper[c] + : c; +} + +const wchar_t* +ctype::do_toupper(wchar_t* low, const wchar_t* high) const { + for ( ; low < high; ++low) { + wchar_t c = *low; + *low = _WCharIndex::in_range(c, ctype::table_size) ? (wchar_t)_S_upper[c] + : c; + } + return high; +} + +wchar_t ctype::do_tolower(wchar_t c) const { + return _WCharIndex::in_range(c, ctype::table_size) ? (wchar_t)_S_lower[c] + : c; +} + +const wchar_t* +ctype::do_tolower(wchar_t* low, const wchar_t* high) const { + for ( ; low < high; ++low) { + wchar_t c = *low; + *low = _WCharIndex::in_range(c, ctype::table_size) ? (wchar_t)_S_lower[c] + : c; + } + return high; +} + +wchar_t ctype::do_widen(char c) const { + return (wchar_t)(unsigned char)c; +} + +const char* +ctype::do_widen(const char* low, const char* high, + wchar_t* dest) const { + while (low != high) + *dest++ = (wchar_t)(unsigned char)*low++; + return high; +} + +char ctype::do_narrow(wchar_t c, char dfault) const +{ return (unsigned char)c == c ? (char)c : dfault; } + +const wchar_t* ctype::do_narrow(const wchar_t* low, + const wchar_t* high, + char dfault, char* dest) const { + while (low != high) { + wchar_t c = *low++; + *dest++ = (unsigned char)c == c ? (char)c : dfault; + } + + return high; +} + +# endif +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/src/cxa.c b/sdk/tlibstdcxx/src/cxa.c new file mode 100644 index 0000000000..998170e0f1 --- /dev/null +++ b/sdk/tlibstdcxx/src/cxa.c @@ -0,0 +1,198 @@ +#include "stlport_prefix.h" + +#if defined(__unix) && defined(__GNUC__) + +#ifdef __FreeBSD__ +# include +#endif + +#if (defined(__FreeBSD__) && (__FreeBSD_version < 503001)) || defined(__sun) || defined (__hpux) +/* Note: __cxa_finalize and __cxa_atexit present in libc in FreeBSD 5.3 */ + +#include +#include +#include + +/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@" "STLPORT_5_0_0"); */ +/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */ + +/* Not atomic! */ +/* But we can use static mutexes here: I hope that performance issue isn't very + significant on unloading (for only few calls, ~10) - ptr */ + +/* +#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ + ({ __typeof (mem) __gmemp = (mem); \ + __typeof (*mem) __gnewval = (newval); \ + \ + *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; }) +*/ + +enum { + ef_free, /* `ef_free' MUST be zero! */ + ef_us, + ef_on, + ef_at, + ef_cxa +}; + +struct exit_function +{ + /* `flavour' should be of type of the `enum' above but since we need + this element in an atomic operation we have to use `long int'. */ + long int flavor; + union { + void (*at)(void); + struct { + void (*fn)(int status, void *arg); + void *arg; + } on; + struct { + void (*fn)(void *arg, int status); + void *arg; + void *dso_handle; + } cxa; + } func; +}; + +struct exit_function_list +{ + struct exit_function_list *next; + size_t idx; + struct exit_function fns[32]; +}; + +struct exit_function *__new_exitfn (void); + +/* Register a function to be called by exit or when a shared library + is unloaded. This function is only called from code generated by + the C++ compiler. */ +int __cxa_atexit(void (*func)(void *), void *arg, void *d) +{ + struct exit_function *new = __new_exitfn (); + + if ( new == NULL ) + return -1; + + new->flavor = ef_cxa; + new->func.cxa.fn = (void (*) (void *, int)) func; + new->func.cxa.arg = arg; + new->func.cxa.dso_handle = d; + return 0; +} + + +/* We change global data, so we need locking. */ +#ifdef __linux__ +static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +#endif +/* #ifdef __FreeBSD__ */ +#if 0 +static pthread_mutex_t lock = + { PTHREAD_MUTEX_RECURSIVE /* PTHREAD_MUTEX_DEFAULT */, PTHREAD_PRIO_NONE, {NULL,NULL}, + NULL, { NULL }, /* MUTEX_FLAGS_PRIVATE */ 0x1, 0, 0, 0, {NULL, NULL}, + { 0, 0, 0, 0 } }; +#endif +#ifdef __sun +static pthread_mutex_t lock = + {{0, 0, 0, PTHREAD_MUTEX_RECURSIVE, _MUTEX_MAGIC}, {{{0}}}, 0}; +#endif +#ifdef __hpux +static pthread_mutex_t lock = PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP; +# ifdef __ia64 +void *__dso_handle = (void *) &__dso_handle; +# endif +#endif + + +static struct exit_function_list initial; +struct exit_function_list *__exit_funcs = &initial; + +struct exit_function *__new_exitfn(void) +{ + struct exit_function_list *l; + size_t i = 0; + +#ifndef __FreeBSD__ + pthread_mutex_lock( &lock ); +#endif + + for (l = __exit_funcs; l != NULL; l = l->next) { + for (i = 0; i < l->idx; ++i) + if (l->fns[i].flavor == ef_free) + break; + if ( i < l->idx ) + break; + + if (l->idx < sizeof (l->fns) / sizeof (l->fns[0])) { + i = l->idx++; + break; + } + } + + if (l == NULL) { + l = (struct exit_function_list *)malloc( sizeof(struct exit_function_list) ); + if (l != NULL) { + l->next = __exit_funcs; + __exit_funcs = l; + + l->idx = 1; + i = 0; + } + } + + /* Mark entry as used, but we don't know the flavor now. */ + if ( l != NULL ) + l->fns[i].flavor = ef_us; + +#ifndef __FreeBSD__ + pthread_mutex_unlock( &lock ); +#endif + + return l == NULL ? NULL : &l->fns[i]; +} + +/* If D is non-NULL, call all functions registered with `__cxa_atexit' + with the same dso handle. Otherwise, if D is NULL, call all of the + registered handlers. */ + +/* + * Note, that original __cxa_finalize don't use lock, but use __exit_funcs + * i.e. global data. + */ +void __cxa_finalize(void *d) +{ + struct exit_function_list *funcs; + +#ifndef __FreeBSD__ + pthread_mutex_lock( &lock ); +#endif + + for (funcs = __exit_funcs; funcs; funcs = funcs->next) { + struct exit_function *f; + + for (f = &funcs->fns[funcs->idx - 1]; f >= &funcs->fns[0]; --f) { + if ( (d == NULL || d == f->func.cxa.dso_handle) && (f->flavor == ef_cxa) ) { + f->flavor = ef_free; + (*f->func.cxa.fn) (f->func.cxa.arg, 0); + } + } + } + + /* Remove the registered fork handlers. We do not have to + unregister anything if the program is going to terminate anyway. */ +#ifdef UNREGISTER_ATFORK + if (d != NULL) + UNREGISTER_ATFORK (d); +#endif +#ifndef __FreeBSD__ + pthread_mutex_unlock( &lock ); +#endif +} + +/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */ +/* void __cxa_finalize(void *d) __attribute__ ((weak)); */ + +#endif /* OS name */ +#endif /* __unix */ + diff --git a/sdk/tlibstdcxx/src/details/fstream_stdio.cpp b/sdk/tlibstdcxx/src/details/fstream_stdio.cpp new file mode 100644 index 0000000000..8392ffdebc --- /dev/null +++ b/sdk/tlibstdcxx/src/details/fstream_stdio.cpp @@ -0,0 +1,387 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if defined (__SUNPPRO_CC) && !defined (_STLP_NO_NEW_C_HEADERS) +# include +// For sunpro, it chokes if time.h is included through stat.h +#endif + +#include + +#ifdef __CYGWIN__ +# define __int64 long long +#endif + +#include +#if !defined(__ISCPP__) +extern "C" { +# include +} +#endif + +#if defined( __MSL__ ) +# include +#endif + +#if defined(__ISCPP__) +# include +#endif + +#if defined(__BEOS__) && defined(__INTEL__) +# include +# include // For _fstat +#endif + +#if defined (_STLP_MSVC) || defined (__MINGW32__) +# include +# define S_IREAD _S_IREAD +# define S_IWRITE _S_IWRITE +# define S_IFREG _S_IFREG + // map permission masks +# ifndef S_IRUSR +# define S_IRUSR _S_IREAD +# define S_IWUSR _S_IWRITE +# endif +# ifndef S_IRGRP +# define S_IRGRP _S_IREAD +# define S_IWGRP _S_IWRITE +# endif +# ifndef S_IROTH +# define S_IROTH _S_IREAD +# define S_IWOTH _S_IWRITE +# endif + +# ifndef O_RDONLY +# define O_RDONLY _O_RDONLY +# define O_WRONLY _O_WRONLY +# define O_RDWR _O_RDWR +# define O_APPEND _O_APPEND +# define O_CREAT _O_CREAT +# define O_TRUNC _O_TRUNC +# define O_TEXT _O_TEXT +# define O_BINARY _O_BINARY +# endif + +# ifndef O_ACCMODE +# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +# endif +#endif + +const _STLP_fd INVALID_STLP_FD = -1; + + +# ifdef __MSL__ +# define _O_TEXT 0x0 +# if !defined( O_TEXT ) +# define O_TEXT _O_TEXT +# endif +# define _S_IFREG S_IFREG +# define S_IREAD S_IRUSR +# define S_IWRITE S_IWUSR +# define S_IEXEC S_IXUSR +# define _S_IWRITE S_IWRITE +# define _S_IREAD S_IREAD +# define _open open +# define _close close +# define _read read +# define _write write +# endif + +_STLP_BEGIN_NAMESPACE + +// Compare with streamoff definition in stl/char_traits.h! + +#if defined (_STLP_USE_DEFAULT_FILE_OFFSET) || \ + (!defined(_LARGEFILE_SOURCE) && !defined(_LARGEFILE64_SOURCE)) +# define FOPEN fopen +# define FSEEK fseek +# define FSTAT fstat +# define STAT stat +# define FTELL ftell +#else +# define FOPEN fopen64 +# define FSEEK fseeko64 +# define FSTAT fstat64 +# define STAT stat64 +# define FTELL ftello64 +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Helper functions for _Filebuf_base. + +static bool __is_regular_file(_STLP_fd fd) { + struct STAT buf; + return FSTAT(fd, &buf) == 0 && (buf.st_mode & S_IFREG) != 0 ; +} + +// Number of characters in the file. +static streamoff __file_size(_STLP_fd fd) { + streamoff ret = 0; + + struct STAT buf; + if (FSTAT(fd, &buf) == 0 && (buf.st_mode & S_IFREG) != 0) + ret = buf.st_size > 0 ? buf.st_size : 0; + + return ret; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +// All version of Unix have mmap and lseek system calls. Some also have +// longer versions of those system calls to accommodate 64-bit offsets. +// If we're on a Unix system, define some macros to encapsulate those +// differences. + +size_t _Filebuf_base::_M_page_size = 4096; + +_Filebuf_base::_Filebuf_base() + : _M_file_id(INVALID_STLP_FD), + _M_openmode(0), + _M_is_open(false), + _M_should_close(false) +{} + +void _Filebuf_base::_S_initialize() +{ + +} + +// Return the size of the file. This is a wrapper for stat. +// Returns zero if the size cannot be determined or is ill-defined. +streamoff _Filebuf_base::_M_file_size() +{ + return _STLP_PRIV __file_size(_M_file_id); +} + +bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode, + long permission) +{ + _STLP_fd file_no; + + if (_M_is_open) + return false; + + // use FILE-based i/o + const char* flags; + + switch (openmode & (~ios_base::ate)) { + case ios_base::out: + case ios_base::out | ios_base::trunc: + flags = "w"; + break; + + case ios_base::out | ios_base::binary: + case ios_base::out | ios_base::trunc | ios_base::binary: + flags = "wb"; + break; + + case ios_base::out | ios_base::app: + flags = "a"; + break; + + case ios_base::out | ios_base::app | ios_base::binary: + flags = "ab"; + break; + + case ios_base::in: + flags = "r"; + break; + + case ios_base::in | ios_base::binary: + flags = "rb"; + break; + + case ios_base::in | ios_base::out: + flags = "r+"; + break; + + case ios_base::in | ios_base::out | ios_base::binary: + flags = "r+b"; + break; + + case ios_base::in | ios_base::out | ios_base::trunc: + flags = "w+"; + break; + + case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary: + flags = "w+b"; + break; + + default: // The above are the only combinations of + return false; // flags allowed by the C++ standard. + } + + // fbp : TODO : set permissions ! + (void)permission; // currently unused //*TY 02/26/2000 - added to suppress warning message + _M_file = FOPEN(name, flags); + + if (_M_file) { + file_no = fileno(_M_file); + } else { + return false; + } + + // unset buffering immediately + setbuf(_M_file, 0); + + _M_is_open = true; + + if (openmode & ios_base::ate) { + if (FSEEK(_M_file, 0, SEEK_END) != 0) + _M_is_open = false; + } + + _M_file_id = file_no; + _M_should_close = _M_is_open; + _M_openmode = openmode; + + if (_M_is_open) + _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id); + + return (_M_is_open != 0); +} + + +bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode) +{ + // This doesn't really grant everyone in the world read/write + // access. On Unix, file-creation system calls always clear + // bits that are set in the umask from the permissions flag. + return this->_M_open(name, openmode, S_IRUSR | S_IWUSR | S_IRGRP | + S_IWGRP | S_IROTH | S_IWOTH); +} + +// Associated the filebuf with a file descriptor pointing to an already- +// open file. Mode is set to be consistent with the way that the file +// was opened. +bool _Filebuf_base::_M_open( int file_no, ios_base::openmode ) +{ + if (_M_is_open || file_no < 0) + return false; + + struct STAT buf; + if (FSTAT(file_no, &buf) != 0) + return false; + int mode = buf.st_mode; + + switch ( mode & (S_IWRITE | S_IREAD) ) { + case S_IREAD: + _M_openmode = ios_base::in; + break; + case S_IWRITE: + _M_openmode = ios_base::out; + break; + case (S_IWRITE | S_IREAD): + _M_openmode = ios_base::in | ios_base::out; + break; + default: + return false; + } + _M_file_id = file_no; + _M_is_open = true; + _M_should_close = false; + _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id); + return true; +} + +bool _Filebuf_base::_M_close() +{ + if (!_M_is_open) + return false; + + bool ok = _M_should_close ? (fclose(_M_file) == 0) : true; + + _M_is_open = _M_should_close = false; + _M_openmode = 0; + return ok; +} + +// Read up to n characters into a buffer. Return value is number of +// characters read. +ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n) { + return fread(buf, 1, n, _M_file); +} + +// Write n characters from a buffer. Return value: true if we managed +// to write the entire buffer, false if we didn't. +bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n) +{ + for (;;) { + ptrdiff_t written = fwrite(buf, 1, n, _M_file); + + if (n == written) { + return true; + } + + if (written > 0 && written < n) { + n -= written; + buf += written; + } else { + return false; + } + } +} + +// Wrapper for lseek or the like. +streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir) +{ + int whence; + + switch ( dir ) { + case ios_base::beg: + if (offset < 0 /* || offset > _M_file_size() */ ) + return streamoff(-1); + whence = SEEK_SET; + break; + case ios_base::cur: + whence = SEEK_CUR; + break; + case ios_base::end: + if (/* offset > 0 || */ -offset > _M_file_size() ) + return streamoff(-1); + whence = SEEK_END; + break; + default: + return streamoff(-1); + } + + if ( FSEEK(_M_file, offset, whence) == 0 ) { + return FTELL(_M_file); + } + + return streamoff(-1); +} + + +// Attempts to memory-map len bytes of the current file, starting +// at position offset. Precondition: offset is a multiple of the +// page size. Postcondition: return value is a null pointer if the +// memory mapping failed. Otherwise the return value is a pointer to +// the memory-mapped file and the file position is set to offset. +void *_Filebuf_base::_M_mmap(streamoff, streamoff ) +{ + return 0; +} + +void _Filebuf_base::_M_unmap(void*, streamoff) +{ + // precondition : there is a valid mapping at the moment +} + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/details/fstream_unistd.cpp b/sdk/tlibstdcxx/src/details/fstream_unistd.cpp new file mode 100644 index 0000000000..744088302f --- /dev/null +++ b/sdk/tlibstdcxx/src/details/fstream_unistd.cpp @@ -0,0 +1,347 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if defined (__SUNPPRO_CC) && !defined (_STLP_NO_NEW_C_HEADERS) +# include +// For sunpro, it chokes if time.h is included through stat.h +#endif + +#include + +#ifdef __CYGWIN__ +# define __int64 long long +#endif + +extern "C" { +// open/close/read/write +#include // For stat +#if !defined (_CRAY) && ! defined (__EMX__) +# include // For mmap +#endif + +// on HP-UX 11, this one contradicts with pthread.h on pthread_atfork, unless we unset this +#if defined (__hpux) && defined (__GNUC__) +# undef _INCLUDE_POSIX1C_SOURCE +#endif + +#include +#include +} + +#ifdef __APPLE__ +# include +#endif + +const _STLP_fd INVALID_STLP_FD = -1; + +#ifndef O_ACCMODE +# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +// Compare with streamoff definition in stl/char_traits.h! +#if defined (_STLP_USE_DEFAULT_FILE_OFFSET) || \ + (!defined(_LARGEFILE_SOURCE) && !defined (_LARGEFILE64_SOURCE)) +# define FSTAT fstat +# define STAT stat +# define LSEEK lseek +# define MMAP mmap +# define OPEN open +#else +# define FSTAT fstat64 +# define STAT stat64 +# define LSEEK lseek64 +# define MMAP mmap64 +# define OPEN open64 +#endif + +#ifndef MAP_FAILED /* MMAP failure return code */ +# define MAP_FAILED -1 +#endif + +_STLP_BEGIN_NAMESPACE + +static ios_base::openmode flag_to_openmode(int mode) +{ + ios_base::openmode ret = ios_base::__default_mode; + + switch ( mode & O_ACCMODE ) { + case O_RDONLY: + ret = ios_base::in; + break; + case O_WRONLY: + ret = ios_base::out; + break; + case O_RDWR: + ret = ios_base::in | ios_base::out; + break; + } + + if ( mode & O_APPEND ) + ret |= ios_base::app; + + return ret; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Helper functions for _Filebuf_base. + +static bool __is_regular_file(_STLP_fd fd) { + struct STAT buf; + return FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode); +} + +// Number of characters in the file. +static streamoff __file_size(_STLP_fd fd) { + streamoff ret = 0; + + struct STAT buf; + if (FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode)) + ret = buf.st_size > 0 ? buf.st_size : 0; + + return ret; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +size_t _Filebuf_base::_M_page_size = 4096; + +_Filebuf_base::_Filebuf_base() + : _M_file_id(INVALID_STLP_FD), + _M_openmode(0), + _M_is_open(false), + _M_should_close(false) +{} + +void _Filebuf_base::_S_initialize() +{ +#if defined (__APPLE__) + int mib[2]; + size_t pagesize, len; + mib[0] = CTL_HW; + mib[1] = HW_PAGESIZE; + len = sizeof(pagesize); + sysctl(mib, 2, &pagesize, &len, NULL, 0); + _M_page_size = pagesize; +#elif defined (__DJGPP) && defined (_CRAY) + _M_page_size = BUFSIZ; +#else + _M_page_size = sysconf(_SC_PAGESIZE); +#endif +} + +// Return the size of the file. This is a wrapper for stat. +// Returns zero if the size cannot be determined or is ill-defined. +streamoff _Filebuf_base::_M_file_size() +{ + return _STLP_PRIV __file_size(_M_file_id); +} + +bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode, + long permission) +{ + _STLP_fd file_no; + + if (_M_is_open) + return false; + + int flags = 0; + + // Unix makes no distinction between text and binary files. + switch ( openmode & (~ios_base::ate & ~ios_base::binary) ) { + case ios_base::out: + case ios_base::out | ios_base::trunc: + flags = O_WRONLY | O_CREAT | O_TRUNC; + break; + case ios_base::app: + case ios_base::out | ios_base::app: + flags = O_WRONLY | O_CREAT | O_APPEND; + break; + case ios_base::in: + flags = O_RDONLY; + permission = 0; // Irrelevant unless we're writing. + break; + case ios_base::in | ios_base::out: + flags = O_RDWR; + break; + case ios_base::in | ios_base::out | ios_base::trunc: + flags = O_RDWR | O_CREAT | O_TRUNC; + break; + case ios_base::in | ios_base::app: + case ios_base::in | ios_base::out | ios_base::app: + flags = O_RDWR | O_CREAT | O_APPEND; + break; + default: // The above are the only combinations of + return false; // flags allowed by the C++ standard. + } + + file_no = OPEN(name, flags, permission); + + if (file_no < 0) + return false; + + _M_is_open = true; + + if ((openmode & (ios_base::ate | ios_base::app)) && (LSEEK(file_no, 0, SEEK_END) == -1)) { + _M_is_open = false; + } + + _M_file_id = file_no; + _M_should_close = _M_is_open; + _M_openmode = openmode; + + if (_M_is_open) + _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id); + + return (_M_is_open != 0); +} + + +bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode) +{ + // This doesn't really grant everyone in the world read/write + // access. On Unix, file-creation system calls always clear + // bits that are set in the umask from the permissions flag. + return this->_M_open(name, openmode, S_IRUSR | S_IWUSR | S_IRGRP | + S_IWGRP | S_IROTH | S_IWOTH); +} + +// Associated the filebuf with a file descriptor pointing to an already- +// open file. Mode is set to be consistent with the way that the file +// was opened. +bool _Filebuf_base::_M_open(int file_no, ios_base::openmode) +{ + if (_M_is_open || file_no < 0) + return false; + + int mode = fcntl(file_no, F_GETFL); + + if (mode == -1) + return false; + + _M_openmode = flag_to_openmode(mode); + _M_file_id = file_no; + + _M_is_open = true; + _M_should_close = false; + _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id); + return true; +} + +bool _Filebuf_base::_M_close() +{ + if (!_M_is_open) + return false; + + bool ok = _M_should_close ? (close(_M_file_id) == 0) : true; + + _M_is_open = _M_should_close = false; + _M_openmode = 0; + return ok; +} + +// Read up to n characters into a buffer. Return value is number of +// characters read. +ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n) +{ + return read(_M_file_id, buf, n); +} + +// Write n characters from a buffer. Return value: true if we managed +// to write the entire buffer, false if we didn't. +bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n) +{ + for (;;) { + ptrdiff_t written = write(_M_file_id, buf, n); + + if (n == written) { + return true; + } + + if (written > 0 && written < n) { + n -= written; + buf += written; + } else { + return false; + } + } +} + +// Wrapper for lseek or the like. +streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir) +{ + int whence; + + switch ( dir ) { + case ios_base::beg: + if (offset < 0 /* || offset > _M_file_size() */ ) + return streamoff(-1); + whence = SEEK_SET; + break; + case ios_base::cur: + whence = SEEK_CUR; + break; + case ios_base::end: + if (/* offset > 0 || */ -offset > _M_file_size() ) + return streamoff(-1); + whence = SEEK_END; + break; + default: + return streamoff(-1); + } + + return LSEEK(_M_file_id, offset, whence); +} + +// Attempts to memory-map len bytes of the current file, starting +// at position offset. Precondition: offset is a multiple of the +// page size. Postcondition: return value is a null pointer if the +// memory mapping failed. Otherwise the return value is a pointer to +// the memory-mapped file and the file position is set to offset. +void* _Filebuf_base::_M_mmap(streamoff offset, streamoff len) +{ + void* base; +#if !defined (__DJGPP) && !defined (_CRAY) + base = MMAP(0, len, PROT_READ, MAP_PRIVATE, _M_file_id, offset); + if (base != (void*)MAP_FAILED) { + if (LSEEK(_M_file_id, offset + len, SEEK_SET) < 0) { + this->_M_unmap(base, len); + base = 0; + } + } else + base =0; +#else + _STLP_MARK_PARAMETER_AS_UNUSED(&offset) + _STLP_MARK_PARAMETER_AS_UNUSED(&len) + base = 0; +#endif + return base; +} + +void _Filebuf_base::_M_unmap(void* base, streamoff len) +{ + // precondition : there is a valid mapping at the moment +#if !defined (__DJGPP) && !defined (_CRAY) + munmap((char*)base, len); +#else + _STLP_MARK_PARAMETER_AS_UNUSED(&len) + _STLP_MARK_PARAMETER_AS_UNUSED(base) +#endif +} + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/dll_main.cpp b/sdk/tlibstdcxx/src/dll_main.cpp new file mode 100644 index 0000000000..faaa721a70 --- /dev/null +++ b/sdk/tlibstdcxx/src/dll_main.cpp @@ -0,0 +1,262 @@ + /* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION + +#include "stlport_prefix.h" + +#if !defined (_STLP_DEBUG) && ! defined (_STLP_ASSERTIONS) +# if !defined (__APPLE__) || !defined (__GNUC__) || (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3)) +/* dums: Please if the following code was being uncommented please explain why + * as for the moment it only looks like a source of inconsistency in the way + * STLport different translation units are compiled. + */ +//# define _STLP_ASSERTIONS 1 +# endif +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined (__DMC__) +// for rope static members +# include +#endif + +#include + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS) +exception::exception() _STLP_NOTHROW {} +exception::~exception() _STLP_NOTHROW {} +bad_exception::bad_exception() _STLP_NOTHROW {} +bad_exception::~bad_exception() _STLP_NOTHROW {} +const char* exception::what() const _STLP_NOTHROW { return "class exception"; } +const char* bad_exception::what() const _STLP_NOTHROW { return "class bad_exception"; } +#endif + +#if defined (_STLP_OWN_STDEXCEPT) +# include + +// boris : those are needed to force typeinfo nodes to be created in here only +logic_error::~logic_error() _STLP_NOTHROW_INHERENTLY {} +runtime_error::~runtime_error() _STLP_NOTHROW_INHERENTLY {} +domain_error::~domain_error() _STLP_NOTHROW_INHERENTLY {} +invalid_argument::~invalid_argument() _STLP_NOTHROW_INHERENTLY {} +length_error::~length_error() _STLP_NOTHROW_INHERENTLY {} +out_of_range::~out_of_range() _STLP_NOTHROW_INHERENTLY {} +range_error::~range_error() _STLP_NOTHROW_INHERENTLY {} +overflow_error::~overflow_error() _STLP_NOTHROW_INHERENTLY {} +underflow_error::~underflow_error() _STLP_NOTHROW_INHERENTLY {} + +#endif + +#if !defined(_STLP_WCE_EVC3) +# if defined (_STLP_NO_BAD_ALLOC) +const nothrow_t nothrow /* = {} */; +# endif +#endif + +#if !defined (_STLP_NO_FORCE_INSTANTIATE) + +# if defined (_STLP_DEBUG) || defined (_STLP_ASSERTIONS) +_STLP_MOVE_TO_PRIV_NAMESPACE +template class _STLP_CLASS_DECLSPEC __stl_debug_engine; +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +template class _STLP_CLASS_DECLSPEC __debug_alloc<__node_alloc>; +template class _STLP_CLASS_DECLSPEC __debug_alloc<__new_alloc>; + +//Export of the types used to represent buckets in the hashtable implementation. +/* + * For the vector class we do not use any MSVC6 workaround even if we export it from + * the STLport dynamic libraries because we know what methods are called and none is + * a template method. Moreover the exported class is an instanciation of vector with + * _Slist_node_base struct that is an internal STLport class that no user should ever + * use. + */ +# if !defined (_STLP_USE_PTR_SPECIALIZATIONS) +template class _STLP_CLASS_DECLSPEC allocator<_STLP_PRIV _Slist_node_base*>; + +_STLP_MOVE_TO_PRIV_NAMESPACE +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base**, _Slist_node_base*, + allocator<_Slist_node_base*> >; +template class _STLP_CLASS_DECLSPEC _Vector_base<_Slist_node_base*, + allocator<_Slist_node_base*> >; +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +# if defined (_STLP_DEBUG) +_STLP_MOVE_TO_PRIV_NAMESPACE +template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_NAME(vector)<_Slist_node_base*, + allocator<_Slist_node_base*> >; +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +template class _STLP_CLASS_DECLSPEC vector<_STLP_PRIV _Slist_node_base*, + allocator<_STLP_PRIV _Slist_node_base*> >; +//End of hashtable bucket types export. + +//Export of _Locale_impl facets container: +# if !defined (_STLP_USE_PTR_SPECIALIZATIONS) +template class _STLP_CLASS_DECLSPEC allocator; + +_STLP_MOVE_TO_PRIV_NAMESPACE +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy >; +template class _STLP_CLASS_DECLSPEC _Vector_base >; +_STLP_MOVE_TO_STD_NAMESPACE + +# endif +# if defined (_STLP_DEBUG) +_STLP_MOVE_TO_PRIV_NAMESPACE +# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector) +template class _STLP_CLASS_DECLSPEC __construct_checker<_STLP_PRIV _STLP_NON_DBG_VECTOR > >; +template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_VECTOR >; +# undef _STLP_NON_DBG_VECTOR +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +template class _STLP_CLASS_DECLSPEC vector >; +//End of export of _Locale_impl facets container. + +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +template class _STLP_CLASS_DECLSPEC allocator; + +typedef _STLP_PRIV _List_node _VoidPtr_Node; +template class _STLP_CLASS_DECLSPEC allocator<_VoidPtr_Node>; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy >; +template class _STLP_CLASS_DECLSPEC _Vector_base >; +template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(vector) >; + +template class _STLP_CLASS_DECLSPEC _List_node; +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_List_node_base, _VoidPtr_Node, allocator<_VoidPtr_Node> >; +template class _STLP_CLASS_DECLSPEC _List_base >; +template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(list) >; + +template class _STLP_CLASS_DECLSPEC _Slist_node; +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base, _Slist_node, allocator<_Slist_node > >; +template class _STLP_CLASS_DECLSPEC _Slist_base >; +template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(slist) >; + +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy >; +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy >; +template struct _STLP_CLASS_DECLSPEC _Deque_iterator >; +template class _STLP_CLASS_DECLSPEC _Deque_base >; +template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(deque) >; + +_STLP_MOVE_TO_STD_NAMESPACE + +# endif /* _STLP_USE_PTR_SPECIALIZATIONS */ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template class _STLP_CLASS_DECLSPEC _Rb_global; +template class _STLP_CLASS_DECLSPEC _List_global; + +template class _STLP_CLASS_DECLSPEC _Sl_global; +template class _STLP_CLASS_DECLSPEC _Stl_prime; + +template class _STLP_CLASS_DECLSPEC _LimG; + +_STLP_MOVE_TO_STD_NAMESPACE + +#endif /* _STLP_NO_FORCE_INSTANTIATE */ + +_STLP_END_NAMESPACE + +#if defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) +extern "C" void _STLP_DECLSPEC _STLP_CALL _STLP_SIGNAL_RUNTIME_COMPATIBILITY() {} +#endif + +#define FORCE_SYMBOL extern + +#if defined (_WIN32) && defined (_STLP_USE_DECLSPEC) && !defined (_STLP_USE_STATIC_LIB) +// stlportmt.cpp : Defines the entry point for the DLL application. +// +# undef FORCE_SYMBOL +# define FORCE_SYMBOL APIENTRY + +extern "C" { + +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID) { + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls((HINSTANCE)hModule); + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +} /* extern "C" */ + +#if !defined (_STLP_MSVC) && !defined (__MINGW32__) +_STLP_BEGIN_NAMESPACE + +static void FORCE_SYMBOL +force_link() { + set::iterator iter; + // _M_increment; _M_decrement instantiation + ++iter; + --iter; +} + +_STLP_END_NAMESPACE +#endif + +#endif /* _WIN32 */ + +#if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300) +# undef std + +namespace std +{ + void _STLP_CALL unexpected() { + unexpected_handler hdl; + set_unexpected(hdl = set_unexpected((unexpected_handler)0)); + hdl(); + } +} +#endif diff --git a/sdk/tlibstdcxx/src/facets_byname.cpp b/sdk/tlibstdcxx/src/facets_byname.cpp new file mode 100644 index 0000000000..07d1a3d67c --- /dev/null +++ b/sdk/tlibstdcxx/src/facets_byname.cpp @@ -0,0 +1,1057 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include +#include + +#include +#include + +#include +#include + +#include "c_locale.h" +#include "locale_impl.h" +#include "acquire_release.h" + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// ctype_byname + +#if defined (__DMC__) +_STLP_DECLSPEC +#endif +ctype_byname::ctype_byname(const char* name, size_t refs) + : ctype( 0, false, refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_ctype = _STLP_PRIV __acquire_ctype(name, buf, 0, &__err_code); + if (!_M_ctype) + locale::_M_throw_on_creation_failure(__err_code, name, "ctype"); + + _M_init(); +} + +void ctype_byname::_M_init() { + _M_ctype_table = _M_byname_table; + + // We have to do this, instead of just pointer twiddling, because + // ctype_base::mask isn't the same type as _Locale_mask_t. + const _Locale_mask_t* p = _Locale_ctype_table(_M_ctype); + for (size_t i = 0; i != table_size; ++i) { + _M_byname_table[i] = ctype_base::mask(p[i]); + } +} + +ctype_byname::~ctype_byname() +{ _STLP_PRIV __release_ctype(_M_ctype); } + +char ctype_byname::do_toupper(char c) const +{ return (char)_Locale_toupper(_M_ctype, c); } + +char ctype_byname::do_tolower(char c) const +{ return (char)_Locale_tolower(_M_ctype, c); } + +const char* +ctype_byname::do_toupper(char* first, const char* last) const { + for ( ; first != last ; ++first) + *first = (char)_Locale_toupper(_M_ctype, *first); + return last; +} + +const char* +ctype_byname::do_tolower(char* first, const char* last) const { + for ( ; first != last ; ++first) + *first = (char)_Locale_tolower(_M_ctype, *first); + return last; +} + + +// Some helper functions used in ctype<>::scan_is and scan_is_not. +#if !defined (_STLP_NO_WCHAR_T) + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// ctype_byname + +struct _Ctype_byname_w_is_mask : public unary_function { + _Locale_mask_t M; + _Locale_ctype* M_ctp; + + _Ctype_byname_w_is_mask(_Locale_mask_t m, _Locale_ctype* c) + : M(m), M_ctp(c) {} + bool operator()(wchar_t c) const + { return _WLocale_ctype(M_ctp, c, M) != 0; } +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (__DMC__) +_STLP_DECLSPEC +#endif +ctype_byname::ctype_byname(const char* name, size_t refs) + : ctype(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_ctype = _STLP_PRIV __acquire_ctype(name, buf, 0, &__err_code); + if (!_M_ctype) + locale::_M_throw_on_creation_failure(__err_code, name, "ctype"); +} + +ctype_byname::~ctype_byname() +{ _STLP_PRIV __release_ctype(_M_ctype); } + +bool ctype_byname::do_is(ctype_base::mask m, wchar_t c) const +{ return _WLocale_ctype(_M_ctype, c, (_Locale_mask_t)m) != 0; } + +const wchar_t* +ctype_byname::do_is(const wchar_t* low, const wchar_t* high, + ctype_base::mask * m) const { + _Locale_mask_t all_bits = _Locale_mask_t(ctype_base::space | + ctype_base::print | + ctype_base::cntrl | + ctype_base::upper | + ctype_base::lower | + ctype_base::alpha | + ctype_base::digit | + ctype_base::punct | + ctype_base::xdigit); + + for ( ; low < high; ++low, ++m) + *m = ctype_base::mask (_WLocale_ctype(_M_ctype, *low, all_bits)); + return high; +} + +const wchar_t* +ctype_byname + ::do_scan_is(ctype_base::mask m, const wchar_t* low, const wchar_t* high) const +{ return find_if(low, high, _STLP_PRIV _Ctype_byname_w_is_mask(m, _M_ctype)); } + +const wchar_t* +ctype_byname + ::do_scan_not(ctype_base::mask m, const wchar_t* low, const wchar_t* high) const +{ return find_if(low, high, not1(_STLP_PRIV _Ctype_byname_w_is_mask(m, _M_ctype))); } + +wchar_t ctype_byname::do_toupper(wchar_t c) const +{ return _WLocale_toupper(_M_ctype, c); } + +const wchar_t* +ctype_byname::do_toupper(wchar_t* low, const wchar_t* high) const { + for ( ; low < high; ++low) + *low = _WLocale_toupper(_M_ctype, *low); + return high; +} + +wchar_t ctype_byname::do_tolower(wchar_t c) const +{ return _WLocale_tolower(_M_ctype, c); } + +const wchar_t* +ctype_byname::do_tolower(wchar_t* low, const wchar_t* high) const { + for ( ; low < high; ++low) + *low = _WLocale_tolower(_M_ctype, *low); + return high; +} + +#endif /* WCHAR_T */ + +// collate_byname +#if defined (__DMC__) +_STLP_DECLSPEC +#endif +collate_byname::collate_byname(const char* name, size_t refs) + : collate(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_collate = _STLP_PRIV __acquire_collate(name, buf, 0, &__err_code); + if (!_M_collate) + locale::_M_throw_on_creation_failure(__err_code, name, "collate"); +} + +collate_byname::~collate_byname() +{ _STLP_PRIV __release_collate(_M_collate); } + +int collate_byname::do_compare(const char* __low1, + const char* __high1, + const char* __low2, + const char* __high2) const { + return _Locale_strcmp(_M_collate, + __low1, __high1 - __low1, + __low2, __high2 - __low2); +} + +collate_byname::string_type +collate_byname::do_transform(const char* low, const char* high) const { + if (low == high) + return string_type(); + + size_t n = _Locale_strxfrm(_M_collate, NULL, 0, low, high - low); + + // NOT PORTABLE. What we're doing relies on internal details of the + // string implementation. (Contiguity of string elements and presence + // of trailing zero.) + string_type buf(n, 0); + _Locale_strxfrm(_M_collate, &(*buf.begin()), n + 1, low, high - low); + return buf; +} + + +#if !defined (_STLP_NO_WCHAR_T) + +// collate_byname + +#if defined (__DMC__) +_STLP_DECLSPEC +#endif +collate_byname::collate_byname(const char* name, size_t refs) + : collate(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_collate = _STLP_PRIV __acquire_collate(name, buf, 0, &__err_code); + if (!_M_collate) + locale::_M_throw_on_creation_failure(__err_code, name, "collate"); +} + +collate_byname::~collate_byname() +{ _STLP_PRIV __release_collate(_M_collate); } + +int collate_byname::do_compare(const wchar_t* low1, + const wchar_t* high1, + const wchar_t* low2, + const wchar_t* high2) const { + return _WLocale_strcmp(_M_collate, + low1, high1 - low1, + low2, high2 - low2); +} + +collate_byname::string_type +collate_byname::do_transform(const wchar_t* low, + const wchar_t* high) const { + if (low == high) + return string_type(); + + size_t n = _WLocale_strxfrm(_M_collate, NULL, 0, low, high - low); + + // NOT PORTABLE. What we're doing relies on internal details of the + // string implementation. (Contiguity of string elements and presence + // of trailing zero.) + string_type buf(n, 0); + _WLocale_strxfrm(_M_collate, &(*buf.begin()), n + 1, low, high - low); + return buf; +} + +#endif /* _STLP_NO_WCHAR_T */ + +//---------------------------------------------------------------------- +// codecvt_byname + +codecvt_byname + ::codecvt_byname(const char* name, size_t refs) + : codecvt(refs) { + if (!name) + locale::_M_throw_on_null_name(); +} + +codecvt_byname::~codecvt_byname() {} + + +#if !defined (_STLP_NO_WCHAR_T) + +//---------------------------------------------------------------------- +// codecvt_byname +codecvt_byname::codecvt_byname(const char* name, size_t refs) + : codecvt(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_codecvt = _STLP_PRIV __acquire_codecvt(name, buf, 0, &__err_code); + if (!_M_codecvt) + locale::_M_throw_on_creation_failure(__err_code, name, "ctype"); +} + +codecvt_byname::~codecvt_byname() +{ _STLP_PRIV __release_codecvt(_M_codecvt); } + +codecvt::result +codecvt_byname::do_out(state_type& state, + const intern_type* from, + const intern_type* from_end, + const intern_type*& from_next, + extern_type* to, + extern_type* to_limit, + extern_type*& to_next) const { + while (from != from_end && to != to_limit) { + size_t chars_stored = _WLocale_wctomb(_M_codecvt, + to, to_limit - to, *from, + &state); + if (chars_stored == (size_t) -1) { + from_next = from; + to_next = to; + return error; + } + else if (chars_stored == (size_t) -2) { + from_next = from; + to_next = to; + return partial; + } + + ++from; + to += chars_stored; + } + + from_next = from; + to_next = to; + return ok; +} + +codecvt::result +codecvt_byname::do_in(state_type& state, + const extern_type* from, + const extern_type* from_end, + const extern_type*& from_next, + intern_type* to, + intern_type* to_end, + intern_type*& to_next) const { + while (from != from_end && to != to_end) { + size_t chars_read = _WLocale_mbtowc(_M_codecvt, + to, from, from_end - from, + &state); + if (chars_read == (size_t) -1) { + from_next = from; + to_next = to; + return error; + } + + if (chars_read == (size_t) -2) { + from_next = from; + to_next = to; + return partial; + } + + from += chars_read; + to++; + } + + from_next = from; + to_next = to; + return ok; +} + +codecvt::result +codecvt_byname::do_unshift(state_type& state, + extern_type* to, + extern_type* to_limit, + extern_type*& to_next) const { + to_next = to; + size_t result = _WLocale_unshift(_M_codecvt, &state, + to, to_limit - to, &to_next); + if (result == (size_t) -1) + return error; + else if (result == (size_t) -2) + return partial; + else +# if defined (__ISCPP__) + return /*to_next == to ? noconv :*/ ok; +# else + return to_next == to ? noconv : ok; +# endif +} + +int +codecvt_byname::do_encoding() const _STLP_NOTHROW { + if (_WLocale_is_stateless(_M_codecvt)) { + int max_width = _WLocale_mb_cur_max(_M_codecvt); + int min_width = _WLocale_mb_cur_min(_M_codecvt); + return min_width == max_width ? min_width : 0; + } + else + return -1; +} + +bool +codecvt_byname::do_always_noconv() const _STLP_NOTHROW +{ return false; } + +int +codecvt_byname::do_length(state_type& state, + const extern_type* from, + const extern_type* end, + size_t mx) const { + size_t __count = 0; + while (from != end && mx--) { + intern_type __dummy; + size_t chars_read = _WLocale_mbtowc(_M_codecvt, + &__dummy, from, end - from, + &state); + if ((chars_read == (size_t) -1) || (chars_read == (size_t) -2)) // error or partial + break; + __count += chars_read; + from += chars_read; + } + return int(__count); +} + +int +codecvt_byname::do_max_length() const _STLP_NOTHROW +{ return _WLocale_mb_cur_max(_M_codecvt); } +#endif + +// numpunct_byname +numpunct_byname::numpunct_byname(const char* name, size_t refs) +: numpunct(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_numeric = _STLP_PRIV __acquire_numeric(name, buf, 0, &__err_code); + if (!_M_numeric) + locale::_M_throw_on_creation_failure(__err_code, name, "numpunct"); +} + +numpunct_byname::~numpunct_byname() +{ _STLP_PRIV __release_numeric(_M_numeric); } + +char numpunct_byname::do_decimal_point() const +{ return _Locale_decimal_point(_M_numeric); } + +char numpunct_byname::do_thousands_sep() const +{ return _Locale_thousands_sep(_M_numeric); } + +string numpunct_byname::do_grouping() const { + const char * __grouping = _Locale_grouping(_M_numeric); + if (__grouping != NULL && __grouping[0] == CHAR_MAX) + __grouping = ""; + return __grouping; +} + +string numpunct_byname::do_truename() const +{ return _Locale_true(_M_numeric); } + +string numpunct_byname::do_falsename() const +{ return _Locale_false(_M_numeric); } + +//---------------------------------------------------------------------- +// numpunct + +#if !defined (_STLP_NO_WCHAR_T) + +// numpunct_byname + +numpunct_byname::numpunct_byname(const char* name, size_t refs) +: numpunct(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_numeric = _STLP_PRIV __acquire_numeric(name, buf, 0, &__err_code); + if (!_M_numeric) + locale::_M_throw_on_creation_failure(__err_code, name, "numpunct"); +} + +numpunct_byname::~numpunct_byname() +{ _STLP_PRIV __release_numeric(_M_numeric); } + +wchar_t numpunct_byname::do_decimal_point() const +{ return _WLocale_decimal_point(_M_numeric); } + +wchar_t numpunct_byname::do_thousands_sep() const +{ return _WLocale_thousands_sep(_M_numeric); } + +string numpunct_byname::do_grouping() const { + const char * __grouping = _Locale_grouping(_M_numeric); + if (__grouping != NULL && __grouping[0] == CHAR_MAX) + __grouping = ""; + return __grouping; +} + +wstring numpunct_byname::do_truename() const { + wchar_t buf[16]; + return _WLocale_true(_M_numeric, _STLP_ARRAY_AND_SIZE(buf)); +} + +wstring numpunct_byname::do_falsename() const { + wchar_t buf[16]; + return _WLocale_false(_M_numeric, _STLP_ARRAY_AND_SIZE(buf)); +} + +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +static void _Init_monetary_formats(money_base::pattern& pos_format, + money_base::pattern& neg_format, + _Locale_monetary * monetary) { + switch (_Locale_p_sign_posn(monetary)) { + case 0: // Parentheses surround the quantity and currency symbol + case 1: // The sign string precedes the quantity and currency symbol + pos_format.field[0] = (char) money_base::sign; + if (_Locale_p_cs_precedes(monetary)) { + // 1 if currency symbol precedes a positive value + pos_format.field[1] = (char) money_base::symbol; + if (_Locale_p_sep_by_space(monetary)) { + // a space separates currency symbol from a positive value. + pos_format.field[2] = (char) money_base::space; + pos_format.field[3] = (char) money_base::value; + } else { + // a space not separates currency symbol from a positive value. + pos_format.field[2] = (char) money_base::value; + pos_format.field[3] = (char) money_base::none; + } + } else { + // 0 if currency symbol succeeds a positive value + pos_format.field[1] = (char) money_base::value; + if (_Locale_p_sep_by_space(monetary)) { + // a space separates currency symbol from a positive value. + pos_format.field[2] = (char) money_base::space; + pos_format.field[3] = (char) money_base::symbol; + } else { + // a space not separates currency symbol from a positive value. + pos_format.field[2] = (char) money_base::symbol; + pos_format.field[3] = (char) money_base::none; + } + } + break; + case 2: // The sign string succeeds the quantity and currency symbol. + if (_Locale_p_cs_precedes(monetary)) { + // 1 if currency symbol precedes a positive value + pos_format.field[0] = (char) money_base::symbol; + if (_Locale_p_sep_by_space(monetary)) { + // a space separates currency symbol from a positive value. + pos_format.field[1] = (char) money_base::space; + pos_format.field[2] = (char) money_base::value; + pos_format.field[3] = (char) money_base::sign; + } else { + // a space not separates currency symbol from a positive value. + pos_format.field[1] = (char) money_base::value; + pos_format.field[2] = (char) money_base::sign; + pos_format.field[3] = (char) money_base::none; + } + } else { + // 0 if currency symbol succeeds a positive value + pos_format.field[0] = (char) money_base::value; + if (_Locale_p_sep_by_space(monetary)) { + // a space separates currency symbol from a positive value. + pos_format.field[1] = (char) money_base::space; + pos_format.field[2] = (char) money_base::symbol; + pos_format.field[3] = (char) money_base::sign; + } else { + // a space not separates currency symbol from a positive value. + pos_format.field[1] = (char) money_base::symbol; + pos_format.field[2] = (char) money_base::sign; + pos_format.field[3] = (char) money_base::none; + } + } + break; + case 3: // The sign string immediately precedes the currency symbol. + if (_Locale_p_cs_precedes(monetary)) { + // 1 if currency symbol precedes a positive value + pos_format.field[0] = (char) money_base::sign; + pos_format.field[1] = (char) money_base::symbol; + if (_Locale_p_sep_by_space(monetary)) { + // a space separates currency symbol from a positive value. + pos_format.field[2] = (char) money_base::space; + pos_format.field[3] = (char) money_base::value; + } else { + // a space not separates currency symbol from a positive value. + pos_format.field[2] = (char) money_base::value; + pos_format.field[3] = (char) money_base::none; + } + } else { + // 0 if currency symbol succeeds a positive value + pos_format.field[0] = (char) money_base::value; + pos_format.field[1] = (char) money_base::sign; + pos_format.field[2] = (char) money_base::symbol; + pos_format.field[3] = (char) money_base::none; + } + break; + case 4: // The sign string immediately succeeds the currency symbol. + if (_Locale_p_cs_precedes(monetary)) { + // 1 if currency symbol precedes a positive value + pos_format.field[0] = (char) money_base::symbol; + pos_format.field[1] = (char) money_base::sign; + pos_format.field[2] = (char) money_base::value; + pos_format.field[3] = (char) money_base::none; + } else { + // 0 if currency symbol succeeds a positive value + pos_format.field[0] = (char) money_base::value; + if (_Locale_p_sep_by_space(monetary)) { + // a space separates currency symbol from a positive value. + pos_format.field[1] = (char) money_base::space; + pos_format.field[2] = (char) money_base::symbol; + pos_format.field[3] = (char) money_base::sign; + } else { + // a space not separates currency symbol from a positive value. + pos_format.field[1] = (char) money_base::symbol; + pos_format.field[2] = (char) money_base::sign; + pos_format.field[3] = (char) money_base::none; + } + } + break; + default: // Default C++ Standard format + pos_format.field[0] = (char) money_base::symbol; + pos_format.field[1] = (char) money_base::sign; + pos_format.field[2] = (char) money_base::none; + pos_format.field[3] = (char) money_base::value; + break; + } + + switch (_Locale_n_sign_posn(monetary)) { + case 0: // Parentheses surround the quantity and currency symbol + case 1: // The sign string precedes the quantity and currency symbol + neg_format.field[0] = (char) money_base::sign; + if (_Locale_n_cs_precedes(monetary)) { + // 1 if currency symbol precedes a negative value + neg_format.field[1] = (char) money_base::symbol; + if (_Locale_n_sep_by_space(monetary)) { + // a space separates currency symbol from a negative value. + neg_format.field[2] = (char) money_base::space; + neg_format.field[3] = (char) money_base::value; + } else { + // a space not separates currency symbol from a negative value. + neg_format.field[2] = (char) money_base::value; + neg_format.field[3] = (char) money_base::none; + } + } else { + // 0 if currency symbol succeeds a negative value + neg_format.field[1] = (char) money_base::value; + if (_Locale_n_sep_by_space(monetary)) { + // a space separates currency symbol from a negative value. + neg_format.field[2] = (char) money_base::space; + neg_format.field[3] = (char) money_base::symbol; + } else { + // a space not separates currency symbol from a negative value. + neg_format.field[2] = (char) money_base::symbol; + neg_format.field[3] = (char) money_base::none; + } + } + break; + case 2: // The sign string succeeds the quantity and currency symbol. + if (_Locale_n_cs_precedes(monetary)) { + // 1 if currency symbol precedes a negative value + neg_format.field[0] = (char) money_base::symbol; + if (_Locale_n_sep_by_space(monetary)) { + // a space separates currency symbol from a negative value. + neg_format.field[1] = (char) money_base::space; + neg_format.field[2] = (char) money_base::value; + neg_format.field[3] = (char) money_base::sign; + } else { + // a space not separates currency symbol from a negative value. + neg_format.field[1] = (char) money_base::value; + neg_format.field[2] = (char) money_base::sign; + neg_format.field[3] = (char) money_base::none; + } + } else { + // 0 if currency symbol succeeds a negative value + neg_format.field[0] = (char) money_base::value; + if (_Locale_n_sep_by_space(monetary)) { + // a space separates currency symbol from a negative value. + neg_format.field[1] = (char) money_base::space; + neg_format.field[2] = (char) money_base::symbol; + neg_format.field[3] = (char) money_base::sign; + } else { + // a space not separates currency symbol from a negative value. + neg_format.field[1] = (char) money_base::symbol; + neg_format.field[2] = (char) money_base::sign; + neg_format.field[3] = (char) money_base::none; + } + } + break; + case 3: // The sign string immediately precedes the currency symbol. + if (_Locale_n_cs_precedes(monetary)) { + // 1 if currency symbol precedes a negative value + neg_format.field[0] = (char) money_base::sign; + neg_format.field[1] = (char) money_base::symbol; + if (_Locale_n_sep_by_space(monetary)) { + // a space separates currency symbol from a negative value. + neg_format.field[2] = (char) money_base::space; + neg_format.field[3] = (char) money_base::value; + } else { + // a space not separates currency symbol from a negative value. + neg_format.field[2] = (char) money_base::value; + neg_format.field[3] = (char) money_base::none; + } + } else { + // 0 if currency symbol succeeds a negative value + neg_format.field[0] = (char) money_base::value; + neg_format.field[1] = (char) money_base::sign; + neg_format.field[2] = (char) money_base::symbol; + neg_format.field[3] = (char) money_base::none; + } + break; + case 4: // The sign string immediately succeeds the currency symbol. + if (_Locale_n_cs_precedes(monetary)) { + // 1 if currency symbol precedes a negative value + neg_format.field[0] = (char) money_base::symbol; + neg_format.field[1] = (char) money_base::sign; + neg_format.field[2] = (char) money_base::none; + neg_format.field[3] = (char) money_base::value; + } else { + // 0 if currency symbol succeeds a negative value + neg_format.field[0] = (char) money_base::value; + if (_Locale_n_sep_by_space(monetary)) { + // a space separates currency symbol from a negative value. + neg_format.field[1] = (char) money_base::space; + neg_format.field[2] = (char) money_base::symbol; + neg_format.field[3] = (char) money_base::sign; + } else { + // a space not separates currency symbol from a negative value. + neg_format.field[1] = (char) money_base::symbol; + neg_format.field[2] = (char) money_base::sign; + neg_format.field[3] = (char) money_base::none; + } + } + break; + default: // Default C++ Standard format + neg_format.field[0] = (char) money_base::symbol; + neg_format.field[1] = (char) money_base::sign; + neg_format.field[2] = (char) money_base::none; + neg_format.field[3] = (char) money_base::value; + break; + } +} + +// international variant of monetary + +/* + * int_curr_symbol + * + * The international currency symbol. The operand is a four-character + * string, with the first three characters containing the alphabetic + * international currency symbol in accordance with those specified + * in the ISO 4217 specification. The fourth character is the character used + * to separate the international currency symbol from the monetary quantity. + * + * (http://www.opengroup.org/onlinepubs/7990989775/xbd/locale.html) + */ + +/* + * Standards are unclear in the usage of international currency + * and monetary formats. + * But I am expect that international currency symbol should be the first + * (not depends upon where currency symbol situated in the national + * format). + * + * If this isn't so, let's see: + * 1 234.56 RUR + * GBP 1,234.56 + * USD 1,234.56 + * The situation really is worse than you see above: + * RUR typed wrong here---it prints '1 234.56 RUR ' (see space after RUR). + * This is due to intl_fmp.curr_symbol() == "RUR ". (see reference in comments + * above). + * + */ + +static void _Init_monetary_formats_int(money_base::pattern& pos_format, + money_base::pattern& neg_format, + _Locale_monetary * monetary) +{ + + switch (_Locale_p_sign_posn(monetary)) { + case 0: // Parentheses surround the quantity and currency symbol + case 1: // The sign string precedes the quantity and currency symbol + pos_format.field[0] = (char) money_base::symbol; + pos_format.field[1] = (char) money_base::sign; + pos_format.field[2] = (char) money_base::value; + pos_format.field[3] = (char) money_base::none; + break; + case 2: // The sign string succeeds the quantity and currency symbol. + pos_format.field[0] = (char) money_base::symbol; + pos_format.field[1] = (char) money_base::value; + pos_format.field[2] = (char) money_base::sign; + pos_format.field[3] = (char) money_base::none; + break; + case 3: // The sign string immediately precedes the currency symbol. + case 4: // The sign string immediately succeeds the currency symbol. + pos_format.field[0] = (char) money_base::symbol; + if (_Locale_p_cs_precedes(monetary)) { + // 1 if currency symbol precedes a positive value + pos_format.field[1] = (char) money_base::sign; + pos_format.field[2] = (char) money_base::value; + } else { + // 0 if currency symbol succeeds a positive value + pos_format.field[1] = (char) money_base::value; + pos_format.field[2] = (char) money_base::sign; + } + pos_format.field[3] = (char) money_base::none; + break; + default: // Default C++ Standard format + pos_format.field[0] = (char) money_base::symbol; + pos_format.field[1] = (char) money_base::sign; + pos_format.field[2] = (char) money_base::none; + pos_format.field[3] = (char) money_base::value; + break; + } + + + switch (_Locale_n_sign_posn(monetary)) { + case 0: // Parentheses surround the quantity and currency symbol + case 1: // The sign string precedes the quantity and currency symbol + neg_format.field[0] = (char) money_base::symbol; + neg_format.field[1] = (char) money_base::sign; + neg_format.field[2] = (char) money_base::value; + neg_format.field[3] = (char) money_base::none; + break; + case 2: // The sign string succeeds the quantity and currency symbol. + neg_format.field[0] = (char) money_base::symbol; + neg_format.field[1] = (char) money_base::value; + neg_format.field[2] = (char) money_base::sign; + neg_format.field[3] = (char) money_base::none; + break; + case 3: // The sign string immediately precedes the currency symbol. + case 4: // The sign string immediately succeeds the currency symbol. + neg_format.field[0] = (char) money_base::symbol; + if (_Locale_n_cs_precedes(monetary)) { + // 1 if currency symbol precedes a negative value + neg_format.field[1] = (char) money_base::sign; + neg_format.field[2] = (char) money_base::value; + } else { + // 0 if currency symbol succeeds a negative value + neg_format.field[1] = (char) money_base::value; + neg_format.field[2] = (char) money_base::sign; + } + neg_format.field[3] = (char) money_base::none; + break; + default: // Default C++ Standard format + neg_format.field[0] = (char) money_base::symbol; + neg_format.field[1] = (char) money_base::sign; + neg_format.field[2] = (char) money_base::none; + neg_format.field[3] = (char) money_base::value; + break; + } +} + +_STLP_MOVE_TO_STD_NAMESPACE + +// +// moneypunct_byname<> +// +moneypunct_byname::moneypunct_byname(const char * name, + size_t refs) + : moneypunct(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code); + if (!_M_monetary) + locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct"); + + _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::moneypunct_byname(_Locale_monetary *__mon) + : _M_monetary(__mon) { + _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::~moneypunct_byname() +{ _STLP_PRIV __release_monetary(_M_monetary); } + +char moneypunct_byname::do_decimal_point() const +{ return _Locale_mon_decimal_point(_M_monetary); } + +char moneypunct_byname::do_thousands_sep() const +{ return _Locale_mon_thousands_sep(_M_monetary); } + +string moneypunct_byname::do_grouping() const +{ return _Locale_mon_grouping(_M_monetary); } + +string moneypunct_byname::do_curr_symbol() const +{ return _Locale_int_curr_symbol(_M_monetary); } + +string moneypunct_byname::do_positive_sign() const +{ return _Locale_positive_sign(_M_monetary); } + +string moneypunct_byname::do_negative_sign() const +{ return _Locale_negative_sign(_M_monetary); } + +int moneypunct_byname::do_frac_digits() const +{ return _Locale_int_frac_digits(_M_monetary); } + +moneypunct_byname::moneypunct_byname(const char * name, + size_t refs) + : moneypunct(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code); + if (!_M_monetary) + locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct"); + + _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::moneypunct_byname(_Locale_monetary *__mon) + : _M_monetary(__mon) { + _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::~moneypunct_byname() +{ _STLP_PRIV __release_monetary(_M_monetary); } + +char moneypunct_byname::do_decimal_point() const +{ return _Locale_mon_decimal_point(_M_monetary); } + +char moneypunct_byname::do_thousands_sep() const +{ return _Locale_mon_thousands_sep(_M_monetary); } + +string moneypunct_byname::do_grouping() const +{ return _Locale_mon_grouping(_M_monetary); } + +string moneypunct_byname::do_curr_symbol() const +{ return _Locale_currency_symbol(_M_monetary); } + +string moneypunct_byname::do_positive_sign() const +{ return _Locale_positive_sign(_M_monetary); } + +string moneypunct_byname::do_negative_sign() const +{ return _Locale_negative_sign(_M_monetary); } + +int moneypunct_byname::do_frac_digits() const +{ return _Locale_frac_digits(_M_monetary); } + +// +// moneypunct_byname +// +#if !defined (_STLP_NO_WCHAR_T) + +moneypunct_byname::moneypunct_byname(const char * name, + size_t refs) + : moneypunct(refs) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code); + if (!_M_monetary) + locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct"); + + _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::moneypunct_byname(_Locale_monetary *__mon) + : _M_monetary(__mon) { + _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::~moneypunct_byname() +{ _STLP_PRIV __release_monetary(_M_monetary); } + +wchar_t moneypunct_byname::do_decimal_point() const +{ return _Locale_mon_decimal_point(_M_monetary); } + +wchar_t moneypunct_byname::do_thousands_sep() const +{ return _Locale_mon_thousands_sep(_M_monetary); } + +string moneypunct_byname::do_grouping() const +{ return _Locale_mon_grouping(_M_monetary); } + +inline wstring __do_widen (string const& str) { +#if defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_MSVC) + wstring::_Reserve_t __Reserve; + size_t __size = str.size(); + wstring result(__Reserve, __size); + copy(str.begin(), str.end(), result.begin()); +#else + wstring result(str.begin(), str.end()); +#endif + return result; +} + +wstring moneypunct_byname::do_curr_symbol() const +{ wchar_t buf[16]; return _WLocale_int_curr_symbol(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); } + +wstring moneypunct_byname::do_positive_sign() const +{ wchar_t buf[16]; return _WLocale_positive_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); } + +wstring moneypunct_byname::do_negative_sign() const +{ wchar_t buf[16]; return _WLocale_negative_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); } + +int moneypunct_byname::do_frac_digits() const +{ return _Locale_int_frac_digits(_M_monetary); } + +moneypunct_byname::moneypunct_byname(const char * name, + size_t refs) + : moneypunct(refs) { + if (!name) + locale::_M_throw_on_null_name() ; + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code); + if (!_M_monetary) + locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct"); + + _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::moneypunct_byname(_Locale_monetary *__mon) + : _M_monetary(__mon) { + _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary); +} + +moneypunct_byname::~moneypunct_byname() +{ _STLP_PRIV __release_monetary(_M_monetary); } + +wchar_t moneypunct_byname::do_decimal_point() const +{ return _Locale_mon_decimal_point(_M_monetary); } + +wchar_t moneypunct_byname::do_thousands_sep() const +{ return _Locale_mon_thousands_sep(_M_monetary); } + +string moneypunct_byname::do_grouping() const +{ return _Locale_mon_grouping(_M_monetary); } + +wstring moneypunct_byname::do_curr_symbol() const +{ wchar_t buf[16]; return _WLocale_currency_symbol(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); } + +wstring moneypunct_byname::do_positive_sign() const +{ wchar_t buf[16]; return _WLocale_positive_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); } + +wstring moneypunct_byname::do_negative_sign() const +{ wchar_t buf[16]; return _WLocale_negative_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); } + +int moneypunct_byname::do_frac_digits() const +{ return _Locale_frac_digits(_M_monetary); } + +#endif + +_STLP_END_NAMESPACE + diff --git a/sdk/tlibstdcxx/src/fstream.cpp b/sdk/tlibstdcxx/src/fstream.cpp new file mode 100644 index 0000000000..81543bb828 --- /dev/null +++ b/sdk/tlibstdcxx/src/fstream.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#ifdef _STLP_USE_UNIX_IO +# include "details/fstream_unistd.cpp" +#elif defined(_STLP_USE_STDIO_IO) +# include "details/fstream_stdio.cpp" +#elif defined(_STLP_USE_WIN32_IO) +# include "details/fstream_win32io.cpp" +#else +# error "Can't recognize IO scheme to use" +#endif + +_STLP_BEGIN_NAMESPACE + +// fbp : let us map 1 MB maximum, just be sure not to trash VM +#define MMAP_CHUNK 0x100000L + +_Underflow< char, char_traits >::int_type _STLP_CALL +_Underflow< char, char_traits >::_M_doit(basic_filebuf >* __this) +{ + typedef char_traits traits_type; + typedef traits_type::int_type int_type; + + if (!__this->_M_in_input_mode) { + if (!__this->_M_switch_to_input_mode()) + return traits_type::eof(); + } + else if (__this->_M_in_putback_mode) { + __this->_M_exit_putback_mode(); + if (__this->gptr() != __this->egptr()) { + int_type __c = traits_type::to_int_type(*__this->gptr()); + return __c; + } + } + + // If it's a disk file, and if the internal and external character + // sequences are guaranteed to be identical, then try to use memory + // mapped I/O. Otherwise, revert to ordinary read. + if (__this->_M_base.__regular_file() + && __this->_M_always_noconv + && __this->_M_base._M_in_binary_mode()) { + // If we've mmapped part of the file already, then unmap it. + if (__this->_M_mmap_base) + __this->_M_base._M_unmap(__this->_M_mmap_base, __this->_M_mmap_len); + + // Determine the position where we start mapping. It has to be + // a multiple of the page size. + streamoff __cur = __this->_M_base._M_seek(0, ios_base::cur); + streamoff __size = __this->_M_base._M_file_size(); + if (__size > 0 && __cur >= 0 && __cur < __size) { + streamoff __offset = (__cur / __this->_M_base.__page_size()) * __this->_M_base.__page_size(); + streamoff __remainder = __cur - __offset; + + __this->_M_mmap_len = __size - __offset; + + if (__this->_M_mmap_len > MMAP_CHUNK) + __this->_M_mmap_len = MMAP_CHUNK; + + if ((__this->_M_mmap_base = __this->_M_base._M_mmap(__offset, __this->_M_mmap_len)) != 0) { + __this->setg(__STATIC_CAST(char*, __this->_M_mmap_base), + __STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __remainder), + __STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __this->_M_mmap_len)); + return traits_type::to_int_type(*__this->gptr()); + } + else + __this->_M_mmap_len = 0; + } + else { + __this->_M_mmap_base = 0; + __this->_M_mmap_len = 0; + } + } + + return __this->_M_underflow_aux(); +} + +//---------------------------------------------------------------------- +// Force instantiation of filebuf and fstream classes. +#if !defined(_STLP_NO_FORCE_INSTANTIATE) + +template class basic_filebuf >; +template class basic_ifstream >; +template class basic_ofstream >; +template class basic_fstream >; + +# if !defined (_STLP_NO_WCHAR_T) +template class _Underflow >; +template class basic_filebuf >; +template class basic_ifstream >; +template class basic_ofstream >; +template class basic_fstream >; +# endif /* _STLP_NO_WCHAR_T */ + +#endif + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/ios.cpp b/sdk/tlibstdcxx/src/ios.cpp new file mode 100644 index 0000000000..cb35e0b1b7 --- /dev/null +++ b/sdk/tlibstdcxx/src/ios.cpp @@ -0,0 +1,318 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include +#include +#include // for __get_ostreambuf definition + +#include "aligned_buffer.h" + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// ios_base members + +// class ios_base::failure, a subclass of exception. It's used solely +// for reporting errors. + +ios_base::failure::failure(const string& s) + : __Named_exception(s) +{} + +ios_base::failure::~failure() _STLP_NOTHROW_INHERENTLY {} + +#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) +// Definitions of ios_base's formatting flags. +const ios_base::fmtflags ios_base::left; +const ios_base::fmtflags ios_base::right; +const ios_base::fmtflags ios_base::internal; +const ios_base::fmtflags ios_base::dec; +const ios_base::fmtflags ios_base::hex; +const ios_base::fmtflags ios_base::oct; +const ios_base::fmtflags ios_base::fixed; +const ios_base::fmtflags ios_base::scientific; +const ios_base::fmtflags ios_base::boolalpha; +const ios_base::fmtflags ios_base::showbase; +const ios_base::fmtflags ios_base::showpoint; +const ios_base::fmtflags ios_base::showpos; +const ios_base::fmtflags ios_base::skipws; +const ios_base::fmtflags ios_base::unitbuf; +const ios_base::fmtflags ios_base::uppercase; +const ios_base::fmtflags ios_base::adjustfield; +const ios_base::fmtflags ios_base::basefield; +const ios_base::fmtflags ios_base::floatfield; + +// Definitions of ios_base's state flags. +const ios_base::iostate ios_base::goodbit; +const ios_base::iostate ios_base::badbit; +const ios_base::iostate ios_base::eofbit; +const ios_base::iostate ios_base::failbit; + +// Definitions of ios_base's openmode flags. +const ios_base::openmode ios_base::app; +const ios_base::openmode ios_base::ate; +const ios_base::openmode ios_base::binary; +const ios_base::openmode ios_base::in; +const ios_base::openmode ios_base::out; +const ios_base::openmode ios_base::trunc; + +// Definitions of ios_base's seekdir flags. +const ios_base::seekdir ios_base::beg; +const ios_base::seekdir ios_base::cur; +const ios_base::seekdir ios_base::end; + +#endif + +// Internal functions used for managing exponentially-growing arrays of +// POD types. + +// array is a pointer to N elements of type PODType. Expands the array, +// if necessary, so that array[index] is meaningful. All new elements are +// initialized to zero. Returns a pointer to the new array, and the new +// size. + +template +static pair +_Stl_expand_array(PODType* __array, size_t N, int index) { + if ((int)N < index + 1) { + size_t new_N = (max)(2 * N, size_t(index + 1)); + PODType* new_array + = __STATIC_CAST(PODType*,realloc(__array, new_N * sizeof(PODType))); + if (new_array) { + fill(new_array + N, new_array + new_N, PODType()); + return pair(new_array, new_N); + } + else + return pair(__STATIC_CAST(PODType*,0), 0); + } + else + return pair(__array, N); +} + +// array is a pointer to N elements of type PODType. Allocate a new +// array of N elements, copying the values from the old array to the new. +// Return a pointer to the new array. It is assumed that array is non-null +// and N is nonzero. +template +static PODType* _Stl_copy_array(const PODType* __array, size_t N) { + PODType* result = __STATIC_CAST(PODType*,malloc(N * sizeof(PODType))); + if (result) + copy(__array, __array + N, result); + return result; +} + +locale ios_base::imbue(const locale& loc) { + if (loc != _M_locale) { + locale previous = _M_locale; + _M_locale = loc; + _M_invoke_callbacks(imbue_event); + return previous; + } + else { + _M_invoke_callbacks(imbue_event); + return _M_locale; + } +} + +int _STLP_CALL ios_base::xalloc() { +#if defined (_STLP_THREADS) && \ + defined (_STLP_WIN32THREADS) && defined (_STLP_NEW_PLATFORM_SDK) + static volatile __stl_atomic_t _S_index = 0; + return _STLP_ATOMIC_INCREMENT(&_S_index); +#else + static int _S_index = 0; + static _STLP_STATIC_MUTEX __lock _STLP_MUTEX_INITIALIZER; + _STLP_auto_lock sentry(__lock); + return _S_index++; +#endif +} + +long& ios_base::iword(int index) { + static long dummy = 0; + + pair tmp = _Stl_expand_array(_M_iwords, _M_num_iwords, index); + if (tmp.first) { // The allocation, if any, succeeded. + _M_iwords = tmp.first; + _M_num_iwords = tmp.second; + return _M_iwords[index]; + } + else { + _M_setstate_nothrow(badbit); + _M_check_exception_mask(); + return dummy; + } +} + + +void*& ios_base::pword(int index) { + static void* dummy = 0; + + pair tmp = _Stl_expand_array(_M_pwords, _M_num_pwords, index); + if (tmp.first) { // The allocation, if any, succeeded. + _M_pwords = tmp.first; + _M_num_pwords = tmp.second; + return _M_pwords[index]; + } + else { + _M_setstate_nothrow(badbit); + _M_check_exception_mask(); + return dummy; + } +} + +void ios_base::register_callback(event_callback __fn, int index) { + pair*, size_t> tmp + = _Stl_expand_array(_M_callbacks, _M_num_callbacks, (int)_M_callback_index /* fbp: index ??? */ ); + if (tmp.first) { + _M_callbacks = tmp.first; + _M_num_callbacks = tmp.second; + _M_callbacks[_M_callback_index++] = make_pair(__fn, index); + } + else { + _M_setstate_nothrow(badbit); + _M_check_exception_mask(); + } +} + +// Invokes all currently registered callbacks for a particular event. +// Behaves correctly even if one of the callbacks adds a new callback. +void ios_base::_M_invoke_callbacks(event E) { + for (size_t i = _M_callback_index; i > 0; --i) { + event_callback f = _M_callbacks[i-1].first; + int n = _M_callbacks[i-1].second; + f(E, *this, n); + } +} + +// This function is called if the state, rdstate(), has a bit set +// that is also set in the exception mask exceptions(). +void ios_base::_M_throw_failure() { + const char* arg ; +# if 0 + char buffer[256]; + char* ptr; + strcpy(buffer, "ios failure: rdstate = 0x"); + ptr = __write_integer(buffer+strlen(buffer), ios_base::hex, __STATIC_CAST(unsigned long,_M_iostate)); + strcpy(ptr, " mask = 0x"); + ptr = __write_integer(buffer+strlen(buffer), ios_base::hex, __STATIC_CAST(unsigned long,_M_exception_mask)); + *ptr = 0; + arg = buffer; +# else + arg = "ios failure"; +# endif + +# ifndef _STLP_USE_EXCEPTIONS + fputs(arg, stderr); +# else + throw failure(arg); +# endif +} + +// Copy x's state to *this. This member function is used in the +// implementation of basic_ios::copyfmt. Does not copy _M_exception_mask +// or _M_iostate. +void ios_base::_M_copy_state(const ios_base& x) { + _M_fmtflags = x._M_fmtflags; // Copy the flags, except for _M_iostate + _M_openmode = x._M_openmode; // and _M_exception_mask. + _M_seekdir = x._M_seekdir; + _M_precision = x._M_precision; + _M_width = x._M_width; + _M_locale = x._M_locale; + + if (x._M_callbacks) { + pair* tmp = _Stl_copy_array(x._M_callbacks, x._M_callback_index); + if (tmp) { + free(_M_callbacks); + _M_callbacks = tmp; + _M_num_callbacks = _M_callback_index = x._M_callback_index; + } + else { + _M_setstate_nothrow(badbit); + _M_check_exception_mask(); + } + } + + if (x._M_iwords) { + long* tmp = _Stl_copy_array(x._M_iwords, x._M_num_iwords); + if (tmp) { + free(_M_iwords); + _M_iwords = tmp; + _M_num_iwords = x._M_num_iwords; + } + else { + _M_setstate_nothrow(badbit); + _M_check_exception_mask(); + } + } + + if (x._M_pwords) { + void** tmp = _Stl_copy_array(x._M_pwords, x._M_num_pwords); + if (tmp) { + free(_M_pwords); + _M_pwords = tmp; + _M_num_pwords = x._M_num_pwords; + } + else { + _M_setstate_nothrow(badbit); + _M_check_exception_mask(); + } + } +} + +// ios's (protected) default constructor. The standard says that all +// fields have indeterminate values; we initialize them to zero for +// simplicity. The only thing that really matters is that the arrays +// are all initially null pointers, and the array element counts are all +// initially zero. +ios_base::ios_base() + : _M_fmtflags(0), _M_iostate(0), _M_openmode(0), _M_seekdir(0), + _M_exception_mask(0), + _M_precision(0), _M_width(0), + _M_locale(), + _M_callbacks(0), _M_num_callbacks(0), _M_callback_index(0), + _M_iwords(0), _M_num_iwords(0), + _M_pwords(0), + _M_num_pwords(0) +{} + +// ios's destructor. +ios_base::~ios_base() { + _M_invoke_callbacks(erase_event); + free(_M_callbacks); + free(_M_iwords); + free(_M_pwords); +} + +//---------------------------------------------------------------------- +// Force instantiation of basic_ios +// For DLL exports, they are already instantiated. +#if !defined(_STLP_NO_FORCE_INSTANTIATE) +template class _STLP_CLASS_DECLSPEC basic_ios >; +# if !defined (_STLP_NO_WCHAR_T) +template class _STLP_CLASS_DECLSPEC basic_ios >; +# endif /* _STLP_NO_WCHAR_T */ +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/iostream.cpp b/sdk/tlibstdcxx/src/iostream.cpp new file mode 100644 index 0000000000..0d3329b53e --- /dev/null +++ b/sdk/tlibstdcxx/src/iostream.cpp @@ -0,0 +1,354 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include +#include +#include +#if defined (_STLP_MSVC) || defined (__MWERKS__) || defined (__ICL) || defined (__ISCPP__) +# define _STLP_USE_NOT_INIT_SEGMENT +# include +#endif + +#include "stdio_streambuf.h" +#include "aligned_buffer.h" +#include "_stdio_file.h" +#include "c_locale.h" + +// boris : note this is repeated in +#ifndef _STLP_USE_NAMESPACES +// in case of SGI iostreams, we have to rename our streams not to clash with those +// provided in native lib +# define cin _STLP_cin +# define cout _STLP_cout +# define cerr _STLP_cerr +# define clog _STLP_clog +#endif + +_STLP_BEGIN_NAMESPACE + +// This file handles iostream initialization. It is inherently +// nonportable, since the C++ language definition provides no mechanism +// for controlling order of initialization of nonlocal objects. +// Initialization has three parts, which must be performed in the following +// order: +// (1) Initialize the locale system +// (2) Call the constructors for the eight global stream objects. +// (3) Create streambufs for the global stream objects, and initialize +// the stream objects by calling the init() member function. + + +#if defined (_STLP_USE_NOT_INIT_SEGMENT) + +// Definitions of the eight global I/O objects that are declared in +// . For some compilers we use pragmas to put the global I/O +// objects into an initialization segment that will not +// be executed. We then explicitly invoke the constructors +// with placement new in ios_base::_S_initialize() + +# if defined (__MWERKS__) +# pragma suppress_init_code on +# else +# pragma init_seg("STLPORT_NO_INIT") +# endif + +_STLP_DECLSPEC istream cin(0); +_STLP_DECLSPEC ostream cout(0); +_STLP_DECLSPEC ostream cerr(0); +_STLP_DECLSPEC ostream clog(0); + +# ifndef _STLP_NO_WCHAR_T +_STLP_DECLSPEC wistream wcin(0); +_STLP_DECLSPEC wostream wcout(0); +_STLP_DECLSPEC wostream wcerr(0); +_STLP_DECLSPEC wostream wclog(0); +# endif + +# if defined (__MWERKS__) +# pragma suppress_init_code off +# endif + +#else + +// Definitions of the eight global I/O objects that are declared in +// . Disgusting hack: we deliberately define them with the +// wrong types so that the constructors don't get run automatically. +// We need special tricks to make sure that these objects are struct- +// aligned rather than byte-aligned. + +// This is not portable. Declaring a variable with different types in +// two translations units is "undefined", according to the C++ standard. +// Most compilers, however, silently accept this instead of diagnosing +// it as an error. + +# ifndef __DMC__ +_STLP_DECLSPEC _Stl_aligned_buffer cin; +_STLP_DECLSPEC _Stl_aligned_buffer cout; +_STLP_DECLSPEC _Stl_aligned_buffer cerr; +_STLP_DECLSPEC _Stl_aligned_buffer clog; +# else +_Stl_aligned_buffer cin; +_Stl_aligned_buffer cout; +_Stl_aligned_buffer cerr; +_Stl_aligned_buffer clog; + +# pragma alias("?cin@std@@3V?$basic_istream@std@DV?$char_traits@std@D@1@@1@A", "?cin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@DV?$char_traits@std@D@1@@1@@1@A") +# pragma alias("?cout@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A") +# pragma alias("?cerr@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A") +# pragma alias("?clog@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?clog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A") +# endif + +# ifndef _STLP_NO_WCHAR_T + +# ifndef __DMC__ +_STLP_DECLSPEC _Stl_aligned_buffer wcin; +_STLP_DECLSPEC _Stl_aligned_buffer wcout; +_STLP_DECLSPEC _Stl_aligned_buffer wcerr; +_STLP_DECLSPEC _Stl_aligned_buffer wclog; +# else +_Stl_aligned_buffer wcin; +_Stl_aligned_buffer wcout; +_Stl_aligned_buffer wcerr; +_Stl_aligned_buffer wclog; + +# pragma alias("?wcin@std@@3V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") +# pragma alias("?wcout@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") +# pragma alias("?wcerr@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") +# pragma alias("?wclog@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wclog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") +# endif +# endif +#endif /* STL_MSVC || __MWERKS__ */ + +// Member functions from class ios_base and ios_base::Init + +long ios_base::Init::_S_count = 0; +// by default, those are synced +bool ios_base::_S_is_synced = true; + +ios_base::Init::Init() { + if (_S_count++ == 0) { + _Locale_init(); + ios_base::_S_initialize(); + _Filebuf_base::_S_initialize(); + } +} + +ios_base::Init::~Init() { + if (--_S_count == 0) { + ios_base::_S_uninitialize(); + _Locale_final(); + } +} + +static int _Stl_extract_open_param(FILE* f) +{ return _FILE_fd(f); } + +#ifdef _STLP_REDIRECT_STDSTREAMS +static const char* _Stl_extract_open_param(const char* name) +{ return name; } +#endif + +template +static filebuf* +_Stl_create_filebuf(_Tp x, ios_base::openmode mode ) { + auto_ptr result(new basic_filebuf >()); + result->open(_Stl_extract_open_param(x), mode); + + if (result->is_open()) + return result.release(); + + return 0; +} + +#if !defined (_STLP_NO_WCHAR_T) +static wfilebuf* +_Stl_create_wfilebuf(FILE* f, ios_base::openmode mode) { + auto_ptr result(new basic_filebuf >()); + result->_M_open(_FILE_fd(f), mode); + + if (result->is_open()) + return result.release(); + + return 0; +} +#endif + +void _STLP_CALL ios_base::_S_initialize() { +#if !defined (_STLP_HAS_NO_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE) + using _STLP_PRIV stdio_istreambuf; + using _STLP_PRIV stdio_ostreambuf; +#endif + + auto_ptr cin_buf; + auto_ptr cout_buf; + auto_ptr cerr_buf; + auto_ptr clog_buf; + + if (_S_is_synced) + cin_buf.reset(new stdio_istreambuf(stdin)); + else + cin_buf.reset(_Stl_create_filebuf(stdin, ios_base::in)); + + if (_S_is_synced) { +#ifdef _STLP_REDIRECT_STDSTREAMS + cout_buf.reset(_Stl_create_filebuf("/stdout.txt", ios::out)); + cerr_buf.reset(_Stl_create_filebuf("/stderr.txt", ios::out)); + clog_buf.reset(_Stl_create_filebuf("/stdlog.txt", ios::out)); +#else + cout_buf.reset(new stdio_ostreambuf(stdout)); + cerr_buf.reset(new stdio_ostreambuf(stderr)); + clog_buf.reset(new stdio_ostreambuf(stderr)); +#endif + } + else { + cout_buf.reset(_Stl_create_filebuf(stdout, ios_base::out)); + cerr_buf.reset(_Stl_create_filebuf(stderr, ios_base::out)); + clog_buf.reset(_Stl_create_filebuf(stderr, ios_base::out)); + } + + istream* ptr_cin = new(&cin) istream(cin_buf.get()); cin_buf.release(); + ostream* ptr_cout = new(&cout) ostream(cout_buf.get()); cout_buf.release(); + ostream* ptr_cerr = new(&cerr) ostream(cerr_buf.get()); cerr_buf.release(); + /*ostream* ptr_clog = */ new(&clog) ostream(clog_buf.get()); clog_buf.release(); + ptr_cin->tie(ptr_cout); + ptr_cerr->setf(ios_base::unitbuf); + +#ifndef _STLP_NO_WCHAR_T + auto_ptr win(_Stl_create_wfilebuf(stdin, ios_base::in)); + auto_ptr wout(_Stl_create_wfilebuf(stdout, ios_base::out)); + auto_ptr werr(_Stl_create_wfilebuf(stderr, ios_base::out)); + auto_ptr wlog(_Stl_create_wfilebuf(stderr, ios_base::out)); + + // Run constructors for the four wide stream objects. + wistream* ptr_wcin = new(&wcin) wistream(win.get()); win.release(); + wostream* ptr_wcout = new(&wcout) wostream(wout.get()); wout.release(); + wostream* ptr_wcerr = new(&wcerr) wostream(werr.get()); werr.release(); + /*wostream* ptr_wclog = */ new(&wclog) wostream(wlog.get()); wlog.release(); + + ptr_wcin->tie(ptr_wcout); + ptr_wcerr->setf(ios_base::unitbuf); +#endif +} + +void _STLP_CALL ios_base::_S_uninitialize() { + // Note that destroying output streambufs flushes the buffers. + istream* ptr_cin = &cin; + ostream* ptr_cout = &cout; + ostream* ptr_cerr = &cerr; + ostream* ptr_clog = &clog; + + // We don't want any exceptions being thrown here + ptr_cin->exceptions(0); + ptr_cout->exceptions(0); + ptr_cerr->exceptions(0); + ptr_clog->exceptions(0); + + delete ptr_cin->rdbuf(0); + delete ptr_cout->rdbuf(0); + delete ptr_cerr->rdbuf(0); + delete ptr_clog->rdbuf(0); + + _Destroy(ptr_cin); + _Destroy(ptr_cout); + _Destroy(ptr_cerr); + _Destroy(ptr_clog); + +#ifndef _STLP_NO_WCHAR_T + wistream* ptr_wcin = &wcin; + wostream* ptr_wcout = &wcout; + wostream* ptr_wcerr = &wcerr; + wostream* ptr_wclog = &wclog; + + // We don't want any exceptions being thrown here + ptr_wcin->exceptions(0); + ptr_wcout->exceptions(0); + ptr_wcerr->exceptions(0); + ptr_wclog->exceptions(0); + + delete ptr_wcin->rdbuf(0); + delete ptr_wcout->rdbuf(0); + delete ptr_wcerr->rdbuf(0); + delete ptr_wclog->rdbuf(0); + + _Destroy(ptr_wcin); + _Destroy(ptr_wcout); + _Destroy(ptr_wcerr); + _Destroy(ptr_wclog); +#endif +} + + +bool _STLP_CALL ios_base::sync_with_stdio(bool sync) { +# if !defined (_STLP_HAS_NO_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE) + using _STLP_PRIV stdio_istreambuf; + using _STLP_PRIV stdio_ostreambuf; +# endif + + if (sync == _S_is_synced) return sync; + + // if by any chance we got there before std streams initialization, + // just set the sync flag and exit + if (Init::_S_count == 0) { + _S_is_synced = sync; + return sync; + } + + auto_ptr cin_buf; + auto_ptr cout_buf; + auto_ptr cerr_buf; + auto_ptr clog_buf; + + if (sync) + cin_buf.reset(new stdio_istreambuf(stdin)); + else + cin_buf.reset(_Stl_create_filebuf(stdin, ios_base::in)); + + if (sync) { +#ifdef _STLP_REDIRECT_STDSTREAMS + cout_buf.reset(_Stl_create_filebuf("/stdout.txt", ios::out)); + cerr_buf.reset(_Stl_create_filebuf("/stderr.txt", ios::out)); + clog_buf.reset(_Stl_create_filebuf("/stdlog.txt", ios::out)); +#else + cout_buf.reset(new stdio_ostreambuf(stdout)); + cerr_buf.reset(new stdio_ostreambuf(stderr)); + clog_buf.reset(new stdio_ostreambuf(stderr)); +#endif + } + else { + cout_buf.reset(_Stl_create_filebuf(stdout, ios_base::out)); + cerr_buf.reset(_Stl_create_filebuf(stderr, ios_base::out)); + clog_buf.reset(_Stl_create_filebuf(stderr, ios_base::out)); + } + + if (cin_buf.get() != 0 && cout_buf.get() != 0 && cerr_buf.get() != 0 && clog_buf.get() != 0) { + // When streambuf passed to rdbuf is not null, rdbuf is exception safe: + delete (&cin)->rdbuf(cin_buf.release()); + delete (&cout)->rdbuf(cout_buf.release()); + delete (&cerr)->rdbuf(cerr_buf.release()); + delete (&clog)->rdbuf(clog_buf.release()); + _S_is_synced = sync; + } + + return _S_is_synced; +} + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/istream.cpp b/sdk/tlibstdcxx/src/istream.cpp new file mode 100644 index 0000000000..715364cd6c --- /dev/null +++ b/sdk/tlibstdcxx/src/istream.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +# include "stlport_prefix.h" + +#include + +_STLP_BEGIN_NAMESPACE + +#if !defined(_STLP_NO_FORCE_INSTANTIATE) + +// instantiations +# if defined (_STLP_USE_TEMPLATE_EXPORT) +template class _STLP_CLASS_DECLSPEC _Isentry >; +# endif + +template class _STLP_CLASS_DECLSPEC basic_iostream >; +template class _STLP_CLASS_DECLSPEC basic_istream >; + +# if !defined (_STLP_NO_WCHAR_T) +# if defined (_STLP_USE_TEMPLATE_EXPORT) +template class _STLP_CLASS_DECLSPEC _Isentry >; +# endif +template class _STLP_CLASS_DECLSPEC basic_istream >; +template class _STLP_CLASS_DECLSPEC basic_iostream >; +# endif /* !_STLP_NO_WCHAR_T */ + +#endif /* _STLP_NO_FORCE_INSTANTIATE */ + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/locale.cpp b/sdk/tlibstdcxx/src/locale.cpp new file mode 100644 index 0000000000..8df976b602 --- /dev/null +++ b/sdk/tlibstdcxx/src/locale.cpp @@ -0,0 +1,445 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include + +#include "c_locale.h" +#include "locale_impl.h" + +_STLP_BEGIN_NAMESPACE + +static const string _Nameless("*"); + +static inline bool is_C_locale_name (const char* name) +{ return ((name[0] == 'C') && (name[1] == 0)); } + +locale* _Stl_get_classic_locale(); +locale* _Stl_get_global_locale(); + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ + defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +# define locale _STLP_NO_MEM_T_NAME(loc) +#endif + +locale::facet::~facet() {} + +#if !defined (_STLP_MEMBER_TEMPLATES) || defined (_STLP_INLINE_MEMBER_TEMPLATES) +// members that fail to be templates +bool locale::operator()(const string& __x, + const string& __y) const +{ return __locale_do_operator_call(*this, __x, __y); } + +# if !defined (_STLP_NO_WCHAR_T) +bool locale::operator()(const wstring& __x, + const wstring& __y) const +{ return __locale_do_operator_call(*this, __x, __y); } +# endif +#endif + +void _STLP_CALL locale::_M_throw_on_null_name() +{ _STLP_THROW(runtime_error("Invalid null locale name")); } + +void _STLP_CALL locale::_M_throw_on_combine_error(const string& name) { + string what = "Unable to find facet"; + what += " in "; + what += name.empty() ? "system" : name.c_str(); + what += " locale"; + _STLP_THROW(runtime_error(what.c_str())); +} + +void _STLP_CALL locale::_M_throw_on_creation_failure(int __err_code, + const char* name, const char* facet) { + string what; + switch (__err_code) { + case _STLP_LOC_UNSUPPORTED_FACET_CATEGORY: + what = "No platform localization support for "; + what += facet; + what += " facet category, unable to create facet for "; + what += name[0] == 0 ? "system" : name; + what += " locale"; + break; + case _STLP_LOC_NO_PLATFORM_SUPPORT: + what = "No platform localization support, unable to create "; + what += name[0] == 0 ? "system" : name; + what += " locale"; + break; + default: + case _STLP_LOC_UNKNOWN_NAME: + what = "Unable to create facet "; + what += facet; + what += " from name '"; + what += name; + what += "'"; + break; + case _STLP_LOC_NO_MEMORY: + _STLP_THROW_BAD_ALLOC; + break; + } + + _STLP_THROW(runtime_error(what.c_str())); +} + +// Takes a reference to a locale::id, assign a numeric index if not already +// affected and returns it. The returned index is always positive. +static const locale::id& _Stl_loc_get_index(locale::id& id) { + if (id._M_index == 0) { +#if defined (_STLP_ATOMIC_INCREMENT) && !defined (_STLP_WIN95_LIKE) + static _STLP_VOLATILE __stl_atomic_t _S_index = __STATIC_CAST(__stl_atomic_t, locale::id::_S_max); + id._M_index = _STLP_ATOMIC_INCREMENT(&_S_index); +#else + static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER; + _STLP_auto_lock sentry(_Index_lock); + size_t new_index = locale::id::_S_max++; + id._M_index = new_index; +#endif + } + return id; +} + +// Default constructor: create a copy of the global locale. +locale::locale() _STLP_NOTHROW + : _M_impl(_get_Locale_impl(_Stl_get_global_locale()->_M_impl)) +{} + +// Copy constructor +locale::locale(const locale& L) _STLP_NOTHROW + : _M_impl( _get_Locale_impl( L._M_impl ) ) +{} + +void locale::_M_insert(facet* f, locale::id& n) { + if (f) + _M_impl->insert(f, _Stl_loc_get_index(n)); +} + +locale::locale( _Locale_impl* impl ) : + _M_impl( _get_Locale_impl( impl ) ) +{} + +// Create a locale from a name. +locale::locale(const char* name) + : _M_impl(0) { + if (!name) + _M_throw_on_null_name(); + + if (is_C_locale_name(name)) { + _M_impl = _get_Locale_impl( locale::classic()._M_impl ); + return; + } + + _Locale_impl* impl = 0; + _STLP_TRY { + impl = new _Locale_impl(locale::id::_S_max, name); + + // Insert categories one at a time. + _Locale_name_hint *hint = 0; + const char* ctype_name = name; + char ctype_buf[_Locale_MAX_SIMPLE_NAME]; + const char* numeric_name = name; + char numeric_buf[_Locale_MAX_SIMPLE_NAME]; + const char* time_name = name; + char time_buf[_Locale_MAX_SIMPLE_NAME]; + const char* collate_name = name; + char collate_buf[_Locale_MAX_SIMPLE_NAME]; + const char* monetary_name = name; + char monetary_buf[_Locale_MAX_SIMPLE_NAME]; + const char* messages_name = name; + char messages_buf[_Locale_MAX_SIMPLE_NAME]; + hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint); + hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint); + hint = impl->insert_time_facets(time_name, time_buf, hint); + hint = impl->insert_collate_facets(collate_name, collate_buf, hint); + hint = impl->insert_monetary_facets(monetary_name, monetary_buf, hint); + impl->insert_messages_facets(messages_name, messages_buf, hint); + + // Try to use a normalize locale name in order to have the == operator + // to behave correctly: + if (strcmp(ctype_name, numeric_name) == 0 && + strcmp(ctype_name, time_name) == 0 && + strcmp(ctype_name, collate_name) == 0 && + strcmp(ctype_name, monetary_name) == 0 && + strcmp(ctype_name, messages_name) == 0) { + impl->name = ctype_name; + } + // else we keep current name. + + // reassign impl + _M_impl = _get_Locale_impl( impl ); + } + _STLP_UNWIND(delete impl); +} + +static void _Stl_loc_combine_names_aux(_Locale_impl* L, + const char* name, + const char* ctype_name, const char* time_name, const char* numeric_name, + const char* collate_name, const char* monetary_name, const char* messages_name, + locale::category c) { + // This function is only called when names has been validated so using _Locale_extract_*_name + // can't fail. + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + L->name = string("LC_CTYPE=") + _Locale_extract_ctype_name((c & locale::ctype) ? ctype_name : name, buf, 0, &__err_code) + ";"; + L->name += string("LC_TIME=") + _Locale_extract_time_name((c & locale::time) ? time_name : name, buf, 0, &__err_code) + ";"; + L->name += string("LC_NUMERIC=") + _Locale_extract_numeric_name((c & locale::numeric) ? numeric_name : name, buf, 0, &__err_code) + ";"; + L->name += string("LC_COLLATE=") + _Locale_extract_collate_name((c & locale::collate) ? collate_name : name, buf, 0, &__err_code) + ";"; + L->name += string("LC_MONETARY=") + _Locale_extract_monetary_name((c & locale::monetary) ? monetary_name : name, buf, 0, &__err_code) + ";"; + L->name += string("LC_MESSAGES=") + _Locale_extract_messages_name((c & locale::messages) ? messages_name : name, buf, 0, &__err_code); +} + +// Give L a name where all facets except those in category c +// are taken from name1, and those in category c are taken from name2. +static void _Stl_loc_combine_names(_Locale_impl* L, + const char* name1, const char* name2, + locale::category c) { + if ((c & locale::all) == 0 || strcmp(name1, name1) == 0) + L->name = name1; + else if ((c & locale::all) == locale::all) + L->name = name2; + else { + _Stl_loc_combine_names_aux(L, name1, name2, name2, name2, name2, name2, name2, c); + } +} + +static void _Stl_loc_combine_names(_Locale_impl* L, + const char* name, + const char* ctype_name, const char* time_name, const char* numeric_name, + const char* collate_name, const char* monetary_name, const char* messages_name, + locale::category c) { + if ((c & locale::all) == 0 || (strcmp(name, ctype_name) == 0 && + strcmp(name, time_name) == 0 && + strcmp(name, numeric_name) == 0 && + strcmp(name, collate_name) == 0 && + strcmp(name, monetary_name) == 0 && + strcmp(name, messages_name) == 0)) + L->name = name; + else if ((c & locale::all) == locale::all && strcmp(ctype_name, time_name) == 0 && + strcmp(ctype_name, numeric_name) == 0 && + strcmp(ctype_name, collate_name) == 0 && + strcmp(ctype_name, monetary_name) == 0 && + strcmp(ctype_name, messages_name) == 0) + L->name = ctype_name; + else { + _Stl_loc_combine_names_aux(L, name, ctype_name, time_name, numeric_name, collate_name, monetary_name, messages_name, c); + } +} + + +// Create a locale that's a copy of L, except that all of the facets +// in category c are instead constructed by name. +locale::locale(const locale& L, const char* name, locale::category c) + : _M_impl(0) { + if (!name) + _M_throw_on_null_name(); + + if (_Nameless == name) + _STLP_THROW(runtime_error((string("Invalid locale name '") + _Nameless + "'").c_str())); + + _Locale_impl* impl = 0; + + _STLP_TRY { + impl = new _Locale_impl(*L._M_impl); + + _Locale_name_hint *hint = 0; + const char* ctype_name = name; + char ctype_buf[_Locale_MAX_SIMPLE_NAME]; + const char* numeric_name = name; + char numeric_buf[_Locale_MAX_SIMPLE_NAME]; + const char* time_name = name; + char time_buf[_Locale_MAX_SIMPLE_NAME]; + const char* collate_name = name; + char collate_buf[_Locale_MAX_SIMPLE_NAME]; + const char* monetary_name = name; + char monetary_buf[_Locale_MAX_SIMPLE_NAME]; + const char* messages_name = name; + char messages_buf[_Locale_MAX_SIMPLE_NAME]; + if (c & locale::ctype) + hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint); + if (c & locale::numeric) + hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint); + if (c & locale::time) + hint = impl->insert_time_facets(time_name, time_buf, hint); + if (c & locale::collate) + hint = impl->insert_collate_facets(collate_name, collate_buf, hint); + if (c & locale::monetary) + hint = impl->insert_monetary_facets(monetary_name, monetary_buf,hint); + if (c & locale::messages) + impl->insert_messages_facets(messages_name, messages_buf, hint); + + _Stl_loc_combine_names(impl, L._M_impl->name.c_str(), + ctype_name, time_name, numeric_name, + collate_name, monetary_name, messages_name, c); + _M_impl = _get_Locale_impl( impl ); + } + _STLP_UNWIND(delete impl) +} + +// Contruct a new locale where all facets that aren't in category c +// come from L1, and all those that are in category c come from L2. +locale::locale(const locale& L1, const locale& L2, category c) + : _M_impl(0) { + _Locale_impl* impl = new _Locale_impl(*L1._M_impl); + + _Locale_impl* i2 = L2._M_impl; + + if (L1.name() != _Nameless && L2.name() != _Nameless) + _Stl_loc_combine_names(impl, L1._M_impl->name.c_str(), L2._M_impl->name.c_str(), c); + else { + impl->name = _Nameless; + } + + if (c & collate) { + impl->insert( i2, _STLP_STD::collate::id); +# ifndef _STLP_NO_WCHAR_T + impl->insert( i2, _STLP_STD::collate::id); +# endif + } + if (c & ctype) { + impl->insert( i2, _STLP_STD::ctype::id); + impl->insert( i2, _STLP_STD::codecvt::id); +# ifndef _STLP_NO_WCHAR_T + impl->insert( i2, _STLP_STD::ctype::id); + impl->insert( i2, _STLP_STD::codecvt::id); +# endif + } + if (c & monetary) { + impl->insert( i2, _STLP_STD::moneypunct::id); + impl->insert( i2, _STLP_STD::moneypunct::id); + impl->insert( i2, _STLP_STD::money_get > >::id); + impl->insert( i2, _STLP_STD::money_put > >::id); +# ifndef _STLP_NO_WCHAR_T + impl->insert( i2, _STLP_STD::moneypunct::id); + impl->insert( i2, _STLP_STD::moneypunct::id); + impl->insert( i2, _STLP_STD::money_get > >::id); + impl->insert( i2, _STLP_STD::money_put > >::id); +# endif + } + if (c & numeric) { + impl->insert( i2, _STLP_STD::numpunct::id); + impl->insert( i2, _STLP_STD::num_get > >::id); + impl->insert( i2, _STLP_STD::num_put > >::id); +# ifndef _STLP_NO_WCHAR_T + impl->insert( i2, _STLP_STD::numpunct::id); + impl->insert( i2, _STLP_STD::num_get > >::id); + impl->insert( i2, _STLP_STD::num_put > >::id); +# endif + } + if (c & time) { + impl->insert( i2, _STLP_STD::time_get > >::id); + impl->insert( i2, _STLP_STD::time_put > >::id); +# ifndef _STLP_NO_WCHAR_T + impl->insert( i2, _STLP_STD::time_get > >::id); + impl->insert( i2, _STLP_STD::time_put > >::id); +# endif + } + if (c & messages) { + impl->insert( i2, _STLP_STD::messages::id); +# ifndef _STLP_NO_WCHAR_T + impl->insert( i2, _STLP_STD::messages::id); +# endif + } + _M_impl = _get_Locale_impl( impl ); +} + +// Destructor. +locale::~locale() _STLP_NOTHROW { + if (_M_impl) + _release_Locale_impl(_M_impl); +} + +// Assignment operator. Much like the copy constructor: just a bit of +// pointer twiddling. +const locale& locale::operator=(const locale& L) _STLP_NOTHROW { + if (this->_M_impl != L._M_impl) { + if (this->_M_impl) + _release_Locale_impl(this->_M_impl); + this->_M_impl = _get_Locale_impl(L._M_impl); + } + return *this; +} + +locale::facet* locale::_M_get_facet(const locale::id& n) const { + return n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0; +} + +locale::facet* locale::_M_use_facet(const locale::id& n) const { + locale::facet* f = (n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0); + if (!f) + _M_impl->_M_throw_bad_cast(); + return f; +} + +string locale::name() const { + return _M_impl->name; +} + +// Compare two locales for equality. +bool locale::operator==(const locale& L) const { + return this->_M_impl == L._M_impl || + (this->name() == L.name() && this->name() != _Nameless); +} + +bool locale::operator!=(const locale& L) const { + return !(*this == L); +} + +// static data members. + +const locale& _STLP_CALL locale::classic() { + return *_Stl_get_classic_locale(); +} + +#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +locale _STLP_CALL locale::global(const locale& L) { +#else +_Locale_impl* _STLP_CALL locale::global(const locale& L) { +#endif + locale old(_Stl_get_global_locale()->_M_impl); + if (_Stl_get_global_locale()->_M_impl != L._M_impl) { + _release_Locale_impl(_Stl_get_global_locale()->_M_impl); + // this assign should be atomic, should be fixed here: + _Stl_get_global_locale()->_M_impl = _get_Locale_impl(L._M_impl); + + // Set the global C locale, if appropriate. +#if !defined(_STLP_NO_LOCALE_SUPPORT) + if (L.name() != _Nameless) + setlocale(LC_ALL, L.name().c_str()); +#endif + } + +#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + return old; +#else + return old._M_impl; +#endif +} + +#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) +const locale::category locale::none; +const locale::category locale::collate; +const locale::category locale::ctype; +const locale::category locale::monetary; +const locale::category locale::numeric; +const locale::category locale::time; +const locale::category locale::messages; +const locale::category locale::all; +#endif + +_STLP_END_NAMESPACE + diff --git a/sdk/tlibstdcxx/src/locale_catalog.cpp b/sdk/tlibstdcxx/src/locale_catalog.cpp new file mode 100644 index 0000000000..31e672e838 --- /dev/null +++ b/sdk/tlibstdcxx/src/locale_catalog.cpp @@ -0,0 +1,288 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include +#include + +#include +#include + +#include "c_locale.h" +#include "locale_impl.h" +#include "acquire_release.h" + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Those wrappers are needed to use locale functions in __acquire_category, +// all functions have to present the same prototype. + +static void* _Loc_ctype_create(const char * s, _Locale_name_hint* hint, int *__err_code) +{ return _Locale_ctype_create(s, hint, __err_code); } +static void* _Loc_codecvt_create(const char * s, _Locale_name_hint* hint, int *__err_code) +{ return _Locale_codecvt_create(s, hint, __err_code); } +static void* _Loc_numeric_create(const char * s, _Locale_name_hint* hint, int *__err_code) +{ return _Locale_numeric_create(s, hint, __err_code); } +static void* _Loc_time_create(const char * s, _Locale_name_hint* hint, int *__err_code) +{ return _Locale_time_create(s, hint, __err_code); } +static void* _Loc_collate_create(const char * s, _Locale_name_hint* hint, int *__err_code) +{ return _Locale_collate_create(s, hint, __err_code); } +static void* _Loc_monetary_create(const char * s, _Locale_name_hint* hint, int *__err_code) +{ return _Locale_monetary_create(s, hint, __err_code); } +static void* _Loc_messages_create(const char * s, _Locale_name_hint* hint, int *__err_code) +{ return _Locale_messages_create(s, hint, __err_code); } + +static char const* _Loc_ctype_name(void* l, char* s) +{ return _Locale_ctype_name((_Locale_ctype*)l, s); } +static char const* _Loc_codecvt_name(void* l, char* s) +{ return _Locale_codecvt_name((_Locale_codecvt*)l, s); } +static char const* _Loc_numeric_name(void* l, char* s) +{ return _Locale_numeric_name((_Locale_numeric*)l, s); } +static char const* _Loc_time_name(void* l, char* s) +{ return _Locale_time_name((_Locale_time*)l, s); } +static char const* _Loc_collate_name(void* l, char* s) +{ return _Locale_collate_name((_Locale_collate*)l, s); } +static char const* _Loc_monetary_name(void* l, char* s) +{ return _Locale_monetary_name((_Locale_monetary*)l, s); } +static char const* _Loc_messages_name(void* l, char* s) +{ return _Locale_messages_name((_Locale_messages*)l, s); } + +static const char* _Loc_ctype_default(char* p) +{ return _Locale_ctype_default(p); } +static const char* _Loc_numeric_default(char * p) +{ return _Locale_numeric_default(p); } +static const char* _Loc_time_default(char* p) +{ return _Locale_time_default(p); } +static const char* _Loc_collate_default(char* p) +{ return _Locale_collate_default(p); } +static const char* _Loc_monetary_default(char* p) +{ return _Locale_monetary_default(p); } +static const char* _Loc_messages_default(char* p) +{ return _Locale_messages_default(p); } + +static void _Loc_ctype_destroy(void* p) {_Locale_ctype_destroy((_Locale_ctype*)p); } +static void _Loc_codecvt_destroy(void* p) {_Locale_codecvt_destroy((_Locale_codecvt*)p); } +static void _Loc_numeric_destroy(void* p) {_Locale_numeric_destroy((_Locale_numeric*)p); } +static void _Loc_time_destroy(void* p) {_Locale_time_destroy((_Locale_time*)p);} +static void _Loc_collate_destroy(void* p) {_Locale_collate_destroy((_Locale_collate*)p);} +static void _Loc_monetary_destroy(void* p) {_Locale_monetary_destroy((_Locale_monetary*)p);} +static void _Loc_messages_destroy(void* p) {_Locale_messages_destroy((_Locale_messages*)p);} + +typedef void* (*loc_create_func_t)(const char *, _Locale_name_hint*, int *__err_code); +typedef char const* (*loc_name_func_t)(void* l, char* s); +typedef void (*loc_destroy_func_t)(void* l); +typedef const char* (*loc_default_name_func_t)(char* s); +typedef char const* (*loc_extract_name_func_t)(const char*, char*, _Locale_name_hint*, int *__err_code); + +//---------------------------------------------------------------------- +// Acquire and release low-level category objects. The whole point of +// this is so that we don't allocate (say) four different _Locale_ctype +// objects for a single locale. + +// Global hash tables for category objects. +typedef hash_map, hash, equal_to > Category_Map; + +// Look up a category by name +static Category_Map** ctype_hash() { + static Category_Map *_S_ctype_hash = 0; + return &_S_ctype_hash; +} +static Category_Map** codecvt_hash() { + static Category_Map *_S_codecvt_hash = 0; + return &_S_codecvt_hash; +} +static Category_Map** numeric_hash() { + static Category_Map *_S_numeric_hash = 0; + return &_S_numeric_hash; +} +static Category_Map** time_hash() { + static Category_Map *_S_time_hash = 0; + return &_S_time_hash; +} +static Category_Map** collate_hash() { + static Category_Map *_S_collate_hash = 0; + return &_S_collate_hash; +} +static Category_Map** monetary_hash() { + static Category_Map *_S_monetary_hash = 0; + return &_S_monetary_hash; +} +static Category_Map** messages_hash() { + static Category_Map *_S_messages_hash; + return &_S_messages_hash; +} + +// We have a single lock for all of the hash tables. We may wish to +// replace it with six different locks. +/* REFERENCED */ +static _STLP_STATIC_MUTEX& category_hash_mutex() { + static _STLP_STATIC_MUTEX lock _STLP_MUTEX_INITIALIZER; + return lock; +} + +static void* +__acquire_category(const char* &name, char *buf, _Locale_name_hint* hint, + loc_extract_name_func_t extract_name, + loc_create_func_t create_obj, loc_default_name_func_t default_name, + Category_Map ** M, int *__err_code) { +#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564) + typedef Category_Map::iterator Category_iterator; + pair result; +#else +# if !defined(_STLP_DEBUG) + pair<_Ht_iterator<_Slist_iterator >,_Nonconst_traits > > >,_NonLocalHashMapTraitsT > > >, bool> result; +# else + pair<_DBG_iter<_NonDbg_hashtable >,string,hash,_HashMapTraitsT > >,_Select1st > >,_DbgEqual >,allocator > > >,_DbgTraits<_NonLocalHashMapTraitsT > > > >, bool> result; +# endif +#endif + + *__err_code = _STLP_LOC_UNDEFINED; + + // Find what name to look for. Be careful if user requests the default. + if (name[0] == 0) { + name = default_name(buf); + if (name == 0 || name[0] == 0) + name = "C"; + } + else { + const char* cname = extract_name(name, buf, hint, __err_code); + if (cname == 0) { + return 0; + } + name = cname; + } + + Category_Map::value_type __e(name, pair((void*)0,size_t(0))); + + _STLP_auto_lock sentry(category_hash_mutex()); + + if (!*M) + *M = new Category_Map(); + + // Look for an existing entry with that name. + result = (*M)->insert_noresize(__e); + + if (result.second) { + // There was no entry in the map already. Create the category. + (*result.first).second.first = create_obj(name, hint, __err_code); + if (!(*result.first).second.first) { + (*M)->erase(result.first); +#if defined (_STLP_LEAKS_PEDANTIC) + if ((*M)->empty()) { + delete *M; + *M = 0; + } +#endif + return 0; + } + } + + // Increment the reference count. + ++((*result.first).second.second); + + return (*result.first).second.first; +} + +static void +__release_category(void* cat, + loc_destroy_func_t destroy_fun, + loc_name_func_t get_name, + Category_Map** M) { + Category_Map *pM = *M; + + if (cat && pM) { + // Find the name of the category object. + char buf[_Locale_MAX_SIMPLE_NAME + 1]; + char const* name = get_name(cat, buf); + + if (name != 0) { + _STLP_auto_lock sentry(category_hash_mutex()); + Category_Map::iterator it = pM->find(name); + if (it != pM->end()) { + // Decrement the ref count. If it goes to zero, delete this category + // from the map. + if (--((*it).second.second) == 0) { + void* cat1 = (*it).second.first; + destroy_fun(cat1); + pM->erase(it); +#if defined (_STLP_LEAKS_PEDANTIC) + if (pM->empty()) { + delete pM; + *M = 0; + } +#endif + } + } + } + } +} + +_Locale_ctype* _STLP_CALL __acquire_ctype(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) { + return __REINTERPRET_CAST(_Locale_ctype*, __acquire_category(name, buf, hint, + _Locale_extract_ctype_name, _Loc_ctype_create, _Loc_ctype_default, + ctype_hash(), __err_code)); +} +_Locale_codecvt* _STLP_CALL __acquire_codecvt(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) { + return __REINTERPRET_CAST(_Locale_codecvt*, __acquire_category(name, buf, hint, + _Locale_extract_ctype_name, _Loc_codecvt_create, _Loc_ctype_default, + codecvt_hash(), __err_code)); +} +_Locale_numeric* _STLP_CALL __acquire_numeric(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) { + return __REINTERPRET_CAST(_Locale_numeric*, __acquire_category(name, buf, hint, + _Locale_extract_numeric_name, _Loc_numeric_create, _Loc_numeric_default, + numeric_hash(), __err_code)); +} +_Locale_time* _STLP_CALL __acquire_time(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) { + return __REINTERPRET_CAST(_Locale_time*, __acquire_category(name, buf, hint, + _Locale_extract_time_name, _Loc_time_create, _Loc_time_default, + time_hash(), __err_code)); +} +_Locale_collate* _STLP_CALL __acquire_collate(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) { + return __REINTERPRET_CAST(_Locale_collate*, __acquire_category(name, buf, hint, + _Locale_extract_collate_name, _Loc_collate_create, _Loc_collate_default, + collate_hash(), __err_code)); +} +_Locale_monetary* _STLP_CALL __acquire_monetary(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) { + return __REINTERPRET_CAST(_Locale_monetary*, __acquire_category(name, buf, hint, + _Locale_extract_monetary_name, _Loc_monetary_create, _Loc_monetary_default, + monetary_hash(), __err_code)); +} +_Locale_messages* _STLP_CALL __acquire_messages(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) { + return __REINTERPRET_CAST(_Locale_messages*, __acquire_category(name, buf, hint, + _Locale_extract_messages_name, _Loc_messages_create, _Loc_messages_default, + messages_hash(), __err_code)); +} + +void _STLP_CALL __release_ctype(_Locale_ctype* cat) +{ __release_category(cat, _Loc_ctype_destroy, _Loc_ctype_name, ctype_hash()); } +void _STLP_CALL __release_codecvt(_Locale_codecvt* cat) +{ __release_category(cat, _Loc_codecvt_destroy, _Loc_codecvt_name, codecvt_hash()); } +void _STLP_CALL __release_numeric(_Locale_numeric* cat) +{ __release_category(cat, _Loc_numeric_destroy, _Loc_numeric_name, numeric_hash()); } +void _STLP_CALL __release_time(_Locale_time* cat) +{ __release_category(cat, _Loc_time_destroy, _Loc_time_name, time_hash()); } +void _STLP_CALL __release_collate(_Locale_collate* cat) +{ __release_category(cat, _Loc_collate_destroy, _Loc_collate_name, collate_hash()); } +void _STLP_CALL __release_monetary(_Locale_monetary* cat) +{ __release_category(cat, _Loc_monetary_destroy, _Loc_monetary_name, monetary_hash()); } +void _STLP_CALL __release_messages(_Locale_messages* cat) +{ __release_category(cat, _Loc_messages_destroy, _Loc_messages_name, messages_hash()); } + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/locale_impl.cpp b/sdk/tlibstdcxx/src/locale_impl.cpp new file mode 100644 index 0000000000..103b60336f --- /dev/null +++ b/sdk/tlibstdcxx/src/locale_impl.cpp @@ -0,0 +1,765 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include +#include +#include + +#include "c_locale.h" +#include "aligned_buffer.h" +#include "acquire_release.h" +#include "locale_impl.h" + +_STLP_BEGIN_NAMESPACE + +static const string _Nameless("*"); + +static inline bool is_C_locale_name (const char* name) +{ return ((name[0] == 'C') && (name[1] == 0)); } + +locale::facet * _STLP_CALL _get_facet(locale::facet *f) +{ + if (f != 0) + f->_M_incr(); + return f; +} + +void _STLP_CALL _release_facet(locale::facet *&f) +{ + if ((f != 0) && (f->_M_decr() == 0)) { + delete f; + f = 0; + } +} + +size_t locale::id::_S_max = 27; + +static void _Stl_loc_assign_ids(); + +static _Stl_aligned_buffer<_Locale_impl::Init> __Loc_init_buf; + +_Locale_impl::Init::Init() { + if (_M_count()._M_incr() == 1) { + _Locale_impl::_S_initialize(); + } +} + +_Locale_impl::Init::~Init() { + if (_M_count()._M_decr() == 0) { + _Locale_impl::_S_uninitialize(); + } +} + +_Refcount_Base& _Locale_impl::Init::_M_count() const { + static _Refcount_Base _S_count(0); + return _S_count; +} + +_Locale_impl::_Locale_impl(const char* s) + : _Refcount_Base(0), name(s), facets_vec() { + facets_vec.reserve( locale::id::_S_max ); + new (&__Loc_init_buf) Init(); +} + +_Locale_impl::_Locale_impl( _Locale_impl const& locimpl ) + : _Refcount_Base(0), name(locimpl.name), facets_vec() { + for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet); + facets_vec = locimpl.facets_vec; + new (&__Loc_init_buf) Init(); +} + +_Locale_impl::_Locale_impl( size_t n, const char* s) + : _Refcount_Base(0), name(s), facets_vec(n, 0) { + new (&__Loc_init_buf) Init(); +} + +_Locale_impl::~_Locale_impl() { + (&__Loc_init_buf)->~Init(); + for_each( facets_vec.begin(), facets_vec.end(), _release_facet); +} + +// Initialization of the locale system. This must be called before +// any locales are constructed. (Meaning that it must be called when +// the I/O library itself is initialized.) +void _STLP_CALL _Locale_impl::_S_initialize() { + _Stl_loc_assign_ids(); + make_classic_locale(); +} + +// Release of the classic locale ressources. Has to be called after the last +// locale destruction and not only after the classic locale destruction as +// the facets can be shared between different facets. +void _STLP_CALL _Locale_impl::_S_uninitialize() { + //Not necessary anymore as classic facets are now 'normal' dynamically allocated + //facets with a reference counter telling to _release_facet when the facet can be + //deleted. + //free_classic_locale(); +} + +// _Locale_impl non-inline member functions. +void _STLP_CALL _Locale_impl::_M_throw_bad_cast() { + _STLP_THROW(bad_cast()); +} + +void _Locale_impl::insert(_Locale_impl *from, const locale::id& n) { + if (n._M_index > 0 && n._M_index < from->size()) { + this->insert(from->facets_vec[n._M_index], n); + } +} + +locale::facet* _Locale_impl::insert(locale::facet *f, const locale::id& n) { + if (f == 0 || n._M_index == 0) + return 0; + + if (n._M_index >= facets_vec.size()) { + facets_vec.resize(n._M_index + 1); + } + + if (f != facets_vec[n._M_index]) + { + _release_facet(facets_vec[n._M_index]); + facets_vec[n._M_index] = _get_facet(f); + } + + return f; +} + +// +// content which is dependent on the name +// + +/* Six functions, one for each category. Each of them takes a + * a name, constructs that appropriate category facets by name, + * and inserts them into the locale. */ +_Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint) { + if (name[0] == 0) + name = _Locale_ctype_default(buf); + + if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { + _Locale_impl* i2 = locale::classic()._M_impl; + this->insert(i2, ctype::id); + this->insert(i2, codecvt::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, ctype::id); + this->insert(i2, codecvt::id); +#endif + } else { + locale::facet* ct = 0; + locale::facet* cvt = 0; +#ifndef _STLP_NO_WCHAR_T + locale::facet* wct = 0; + locale::facet* wcvt = 0; +#endif + int __err_code; + _Locale_ctype *__lct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code); + if (!__lct) { + locale::_M_throw_on_creation_failure(__err_code, name, "ctype"); + return hint; + } + + if (hint == 0) hint = _Locale_get_ctype_hint(__lct); + + _STLP_TRY { + ct = new ctype_byname(__lct); + } + _STLP_UNWIND(_STLP_PRIV __release_ctype(__lct)); + + _STLP_TRY { + cvt = new codecvt_byname(name); + } + _STLP_UNWIND(delete ct); + +#ifndef _STLP_NO_WCHAR_T + _STLP_TRY { + _Locale_ctype *__lwct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code); + if (!__lwct) { + locale::_M_throw_on_creation_failure(__err_code, name, "ctype"); + return hint; + } + + _STLP_TRY { + wct = new ctype_byname(__lwct); + } + _STLP_UNWIND(_STLP_PRIV __release_ctype(__lwct)); + + _Locale_codecvt *__lwcvt = _STLP_PRIV __acquire_codecvt(name, buf, hint, &__err_code); + if (__lwcvt) { + _STLP_TRY { + wcvt = new codecvt_byname(__lwcvt); + } + _STLP_UNWIND(_STLP_PRIV __release_codecvt(__lwcvt); delete wct); + } + } + _STLP_UNWIND(delete cvt; delete ct); +#endif + + this->insert(ct, ctype::id); + this->insert(cvt, codecvt::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(wct, ctype::id); + if (wcvt) this->insert(wcvt, codecvt::id); +#endif + } + return hint; +} + +_Locale_name_hint* _Locale_impl::insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint) { + if (name[0] == 0) + name = _Locale_numeric_default(buf); + + _Locale_impl* i2 = locale::classic()._M_impl; + + // We first insert name independant facets taken from the classic locale instance: + this->insert(i2, + num_put > >::id); + this->insert(i2, + num_get > >::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, + num_get > >::id); + this->insert(i2, + num_put > >::id); +#endif + + if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { + this->insert(i2, numpunct::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, numpunct::id); +#endif + } + else { + locale::facet* punct = 0; +#ifndef _STLP_NO_WCHAR_T + locale::facet* wpunct = 0; +#endif + + int __err_code; + _Locale_numeric *__lpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code); + if (!__lpunct) { + locale::_M_throw_on_creation_failure(__err_code, name, "numpunct"); + return hint; + } + + if (hint == 0) hint = _Locale_get_numeric_hint(__lpunct); + _STLP_TRY { + punct = new numpunct_byname(__lpunct); + } + _STLP_UNWIND(_STLP_PRIV __release_numeric(__lpunct)); + +#ifndef _STLP_NO_WCHAR_T + _Locale_numeric *__lwpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code); + if (!__lwpunct) { + delete punct; + locale::_M_throw_on_creation_failure(__err_code, name, "numpunct"); + return hint; + } + if (__lwpunct) { + _STLP_TRY { + wpunct = new numpunct_byname(__lwpunct); + } + _STLP_UNWIND(_STLP_PRIV __release_numeric(__lwpunct); delete punct); + } +#endif + + this->insert(punct, numpunct::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(wpunct, numpunct::id); +#endif + } + return hint; +} + +_Locale_name_hint* _Locale_impl::insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint) { + if (name[0] == 0) + name = _Locale_time_default(buf); + + if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { + _Locale_impl* i2 = locale::classic()._M_impl; + this->insert(i2, + time_get > >::id); + this->insert(i2, + time_put > >::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, + time_get > >::id); + this->insert(i2, + time_put > >::id); +#endif + } else { + locale::facet *get = 0; + locale::facet *put = 0; +#ifndef _STLP_NO_WCHAR_T + locale::facet *wget = 0; + locale::facet *wput = 0; +#endif + + int __err_code; + _Locale_time *__time = _STLP_PRIV __acquire_time(name, buf, hint, &__err_code); + if (!__time) { + // time facets category is not mandatory for correct stream behavior so if platform + // do not support it we do not generate a runtime_error exception. + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + return hint; + } + + if (!hint) hint = _Locale_get_time_hint(__time); + _STLP_TRY { + get = new time_get_byname > >(__time); + put = new time_put_byname > >(__time); +#ifndef _STLP_NO_WCHAR_T + wget = new time_get_byname > >(__time); + wput = new time_put_byname > >(__time); +#endif + } +#ifndef _STLP_NO_WCHAR_T + _STLP_UNWIND(delete wget; delete put; delete get; _STLP_PRIV __release_time(__time)); +#else + _STLP_UNWIND(delete get; _STLP_PRIV __release_time(__time)); +#endif + + _STLP_PRIV __release_time(__time); + + this->insert(get, time_get > >::id); + this->insert(put, time_put > >::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(wget, time_get > >::id); + this->insert(wput, time_put > >::id); +#endif + } + return hint; +} + +_Locale_name_hint* _Locale_impl::insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint) { + if (name[0] == 0) + name = _Locale_collate_default(buf); + + if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { + _Locale_impl* i2 = locale::classic()._M_impl; + this->insert(i2, collate::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, collate::id); +#endif + } + else { + locale::facet *col = 0; +#ifndef _STLP_NO_WCHAR_T + locale::facet *wcol = 0; +#endif + + int __err_code; + _Locale_collate *__coll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code); + if (!__coll) { + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + return hint; + } + + if (hint == 0) hint = _Locale_get_collate_hint(__coll); + _STLP_TRY { + col = new collate_byname(__coll); + } + _STLP_UNWIND(_STLP_PRIV __release_collate(__coll)); + +#ifndef _STLP_NO_WCHAR_T + _Locale_collate *__wcoll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code); + if (!__wcoll) { + if (__err_code == _STLP_LOC_NO_MEMORY) { + delete col; + _STLP_THROW_BAD_ALLOC; + } + } + if (__wcoll) { + _STLP_TRY { + wcol = new collate_byname(__wcoll); + } + _STLP_UNWIND(_STLP_PRIV __release_collate(__wcoll); delete col); + } +#endif + + this->insert(col, collate::id); +#ifndef _STLP_NO_WCHAR_T + if (wcol) this->insert(wcol, collate::id); +#endif + } + return hint; +} + +_Locale_name_hint* _Locale_impl::insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint) { + if (name[0] == 0) + name = _Locale_monetary_default(buf); + + _Locale_impl* i2 = locale::classic()._M_impl; + + // We first insert name independant facets taken from the classic locale instance: + this->insert(i2, money_get > >::id); + this->insert(i2, money_put > >::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, money_get > >::id); + this->insert(i2, money_put > >::id); +#endif + + if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { + this->insert(i2, moneypunct::id); + this->insert(i2, moneypunct::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, moneypunct::id); + this->insert(i2, moneypunct::id); +#endif + } + else { + locale::facet *punct = 0; + locale::facet *ipunct = 0; + +#ifndef _STLP_NO_WCHAR_T + locale::facet* wpunct = 0; + locale::facet* wipunct = 0; +#endif + + int __err_code; + _Locale_monetary *__mon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); + if (!__mon) { + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + return hint; + } + + if (hint == 0) hint = _Locale_get_monetary_hint(__mon); + + _STLP_TRY { + punct = new moneypunct_byname(__mon); + } + _STLP_UNWIND(_STLP_PRIV __release_monetary(__mon)); + + _Locale_monetary *__imon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); + if (!__imon) { + delete punct; + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + return hint; + } + + _STLP_TRY { + ipunct = new moneypunct_byname(__imon); + } + _STLP_UNWIND(_STLP_PRIV __release_monetary(__imon); delete punct); + +#ifndef _STLP_NO_WCHAR_T + _STLP_TRY { + _Locale_monetary *__wmon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); + if (!__wmon) { + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + } + + if (__wmon) { + _STLP_TRY { + wpunct = new moneypunct_byname(__wmon); + } + _STLP_UNWIND(_STLP_PRIV __release_monetary(__wmon)); + + _Locale_monetary *__wimon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); + if (!__wimon) { + delete wpunct; + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + wpunct = 0; + } + else { + _STLP_TRY { + wipunct = new moneypunct_byname(__wimon); + } + _STLP_UNWIND(_STLP_PRIV __release_monetary(__wimon); delete wpunct); + } + } + } + _STLP_UNWIND(delete ipunct; delete punct); +#endif + + this->insert(punct, moneypunct::id); + this->insert(ipunct, moneypunct::id); +#ifndef _STLP_NO_WCHAR_T + if (wpunct) this->insert(wpunct, moneypunct::id); + if (wipunct) this->insert(wipunct, moneypunct::id); +#endif + } + return hint; +} + +_Locale_name_hint* _Locale_impl::insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint) { + if (name[0] == 0) + name = _Locale_messages_default(buf); + + if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { + _Locale_impl* i2 = locale::classic()._M_impl; + this->insert(i2, messages::id); +#ifndef _STLP_NO_WCHAR_T + this->insert(i2, messages::id); +#endif + } + else { + locale::facet *msg = 0; +#ifndef _STLP_NO_WCHAR_T + locale::facet *wmsg = 0; +#endif + + int __err_code; + _Locale_messages *__msg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code); + if (!__msg) { + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + return hint; + } + + _STLP_TRY { + msg = new messages_byname(__msg); + } + _STLP_UNWIND(_STLP_PRIV __release_messages(__msg)); + +#ifndef _STLP_NO_WCHAR_T + _STLP_TRY { + _Locale_messages *__wmsg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code); + if (!__wmsg) { + if (__err_code == _STLP_LOC_NO_MEMORY) { + _STLP_THROW_BAD_ALLOC; + } + } + + if (__wmsg) { + _STLP_TRY { + wmsg = new messages_byname(__wmsg); + } + _STLP_UNWIND(_STLP_PRIV __release_messages(__wmsg)); + } + } + _STLP_UNWIND(delete msg); +#endif + + this->insert(msg, messages::id); +#ifndef _STLP_NO_WCHAR_T + if (wmsg) this->insert(wmsg, messages::id); +#endif + } + return hint; +} + +static void _Stl_loc_assign_ids() { + // This assigns ids to every facet that is a member of a category, + // and also to money_get/put, num_get/put, and time_get/put + // instantiated using ordinary pointers as the input/output + // iterators. (The default is [io]streambuf_iterator.) + + money_get > >::id._M_index = 8; + money_put > >::id._M_index = 9; + num_get > >::id._M_index = 10; + num_put > >::id._M_index = 11; + time_get > >::id._M_index = 12; + time_put > >::id._M_index = 13; + +#ifndef _STLP_NO_WCHAR_T + money_get > >::id._M_index = 21; + money_put > >::id._M_index = 22; + num_get > >::id._M_index = 23; + num_put > > ::id._M_index = 24; + time_get > >::id._M_index = 25; + time_put > >::id._M_index = 26; +#endif + // locale::id::_S_max = 27; +} + +// To access those static instance use the getter below, they guaranty +// a correct initialization. +static locale *_Stl_classic_locale = 0; +static locale *_Stl_global_locale = 0; + +locale* _Stl_get_classic_locale() { + static _Locale_impl::Init init; + return _Stl_classic_locale; +} + +locale* _Stl_get_global_locale() { + static _Locale_impl::Init init; + return _Stl_global_locale; +} + +#if defined (_STLP_MSVC) || defined (__ICL) || defined (__ISCPP__) || defined (__DMC__) +/* + * The following static variable needs to be initialized before STLport + * users static variable in order for him to be able to use Standard + * streams in its variable initialization. + * This variable is here because MSVC do not allow to change the initialization + * segment in a given translation unit, iostream.cpp already contains an + * initialization segment specification. + */ +# pragma warning (disable : 4073) +# pragma init_seg(lib) +#endif + +static ios_base::Init _IosInit; + +void _Locale_impl::make_classic_locale() { + // This funcion will be called once: during build classic _Locale_impl + + // The classic locale contains every facet that belongs to a category. + static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf; + _Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C"); + + locale::facet* classic_facets[] = { + 0, + new collate(1), + new ctype(0, false, 1), + new codecvt(1), + new moneypunct(1), + new moneypunct(1), + new numpunct(1), + new messages(1), + new money_get > >(1), + new money_put > >(1), + new num_get > >(1), + new num_put > >(1), + new time_get > >(1), + new time_put > >(1), +#ifndef _STLP_NO_WCHAR_T + new collate(1), + new ctype(1), + new codecvt(1), + new moneypunct(1), + new moneypunct(1), + new numpunct(1), + new messages(1), + new money_get > >(1), + new money_put > >(1), + new num_get > >(1), + new num_put > >(1), + new time_get > >(1), + new time_put > >(1), +#endif + 0 + }; + + const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *); + classic->facets_vec.reserve(nb_classic_facets); + classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets); + + static locale _Locale_classic(classic); + _Stl_classic_locale = &_Locale_classic; + + static locale _Locale_global(classic); + _Stl_global_locale = &_Locale_global; +} + +// Declarations of (non-template) facets' static data members +// size_t locale::id::_S_max = 27; // made before + +locale::id collate::id = { 1 }; +locale::id ctype::id = { 2 }; +locale::id codecvt::id = { 3 }; +locale::id moneypunct::id = { 4 }; +locale::id moneypunct::id = { 5 }; +locale::id numpunct::id = { 6 } ; +locale::id messages::id = { 7 }; + +#ifndef _STLP_NO_WCHAR_T +locale::id collate::id = { 14 }; +locale::id ctype::id = { 15 }; +locale::id codecvt::id = { 16 }; +locale::id moneypunct::id = { 17 } ; +locale::id moneypunct::id = { 18 } ; +locale::id numpunct::id = { 19 }; +locale::id messages::id = { 20 }; +#endif + +_STLP_DECLSPEC _Locale_impl* _STLP_CALL _get_Locale_impl(_Locale_impl *loc) +{ + _STLP_ASSERT( loc != 0 ); + loc->_M_incr(); + return loc; +} + +void _STLP_CALL _release_Locale_impl(_Locale_impl *& loc) +{ + _STLP_ASSERT( loc != 0 ); + if (loc->_M_decr() == 0) { + if (*loc != *_Stl_classic_locale) + delete loc; + else + loc->~_Locale_impl(); + loc = 0; + } +} + +_STLP_DECLSPEC _Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl(_Locale_impl *loc) +{ + _STLP_ASSERT( loc != 0 ); + _Locale_impl *loc_new = new _Locale_impl(*loc); + loc_new->name = _Nameless; + return loc_new; +} + +/* _GetFacetId implementation have to be here in order to be in the same translation unit + * as where id are initialize (in _Stl_loc_assign_ids) */ +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get > >*) +{ return money_get > >::id; } +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put > >*) +{ return money_put > >::id; } +#ifndef _STLP_NO_WCHAR_T +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get > >*) +{ return money_get > >::id; } +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put > >*) +{ return money_put > >::id; } +#endif + +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get > >*) +{ return num_get > >::id; } +#ifndef _STLP_NO_WCHAR_T +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get > >*) +{ return num_get > >::id; } +#endif + +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put > >*) +{ return num_put > >::id; } +#ifndef _STLP_NO_WCHAR_T +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put > >*) +{ return num_put > >::id; } +#endif + +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get > >*) +{ return time_get > >::id; } +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put > >*) +{ return time_put > >::id; } +#ifndef _STLP_NO_WCHAR_T +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get > >*) +{ return time_get > >::id; } +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put > >*) +{ return time_put > >::id; } +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + diff --git a/sdk/tlibstdcxx/src/locale_impl.h b/sdk/tlibstdcxx/src/locale_impl.h new file mode 100644 index 0000000000..2aa694c99b --- /dev/null +++ b/sdk/tlibstdcxx/src/locale_impl.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef LOCALE_IMPL_H +#define LOCALE_IMPL_H + +#include // C locale header file. +#include +#include +#include +#include "c_locale.h" + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +//Export of _Locale_impl facets container: +# if !defined (_STLP_USE_PTR_SPECIALIZATIONS) +//If we are using pointer specialization, vector will use +//the already exported vector implementation. +_STLP_EXPORT_TEMPLATE_CLASS allocator; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy >; +_STLP_EXPORT_TEMPLATE_CLASS _Vector_base >; + +_STLP_MOVE_TO_STD_NAMESPACE +# endif +# if defined (_STLP_DEBUG) +_STLP_MOVE_TO_PRIV_NAMESPACE +# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector) +_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_VECTOR > >; +_STLP_EXPORT_TEMPLATE_CLASS _STLP_NON_DBG_VECTOR >; +# undef _STLP_NON_DBG_VECTOR +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +_STLP_EXPORT_TEMPLATE_CLASS vector >; +#endif + +//---------------------------------------------------------------------- +// Class _Locale_impl +// This is the base class which implements access only and is supposed to +// be used for classic locale only +class _STLP_CLASS_DECLSPEC _Locale_impl : public _Refcount_Base { + public: + _Locale_impl(const char* s); + _Locale_impl(const _Locale_impl&); + _Locale_impl(size_t n, const char* s); + + private: + ~_Locale_impl(); + + public: + size_t size() const { return facets_vec.size(); } + + basic_string, allocator > name; + + static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_bad_cast(); + + private: + void operator=(const _Locale_impl&); + + public: + class _STLP_CLASS_DECLSPEC Init { + public: + Init(); + ~Init(); + private: + _Refcount_Base& _M_count() const; + }; + + static void _STLP_CALL _S_initialize(); + static void _STLP_CALL _S_uninitialize(); + + static void make_classic_locale(); + static void free_classic_locale(); + + friend class Init; + + public: + // void remove(size_t index); + locale::facet* insert(locale::facet*, const locale::id& n); + void insert(_Locale_impl* from, const locale::id& n); + + // Helper functions for byname construction of locales. + _Locale_name_hint* insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint); + _Locale_name_hint* insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint); + _Locale_name_hint* insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint); + _Locale_name_hint* insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint); + _Locale_name_hint* insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint); + _Locale_name_hint* insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint); + + bool operator != (const locale& __loc) const { return __loc._M_impl != this; } + + private: + vector facets_vec; + + private: + friend _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl * ); + friend void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc ); +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ + defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) + friend class _STLP_NO_MEM_T_NAME(loc); +#else + friend class locale; +#endif +}; + +void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc ); + +_STLP_END_NAMESPACE + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/lock_free_slist.h b/sdk/tlibstdcxx/src/lock_free_slist.h new file mode 100644 index 0000000000..7c753d17c5 --- /dev/null +++ b/sdk/tlibstdcxx/src/lock_free_slist.h @@ -0,0 +1,307 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_LOCK_FREE_SLIST_H +#define _STLP_LOCK_FREE_SLIST_H + +#if defined(_STLP_PTHREADS) +# include + +# if defined (__GNUC__) && defined (__i386__) + +# define _STLP_HAS_ATOMIC_FREELIST +/** + * Class that implements a non-blocking and thread-safe freelist. + * It is used for the lock-free node allocation engine. + * + * @author felixw@inin.com + */ +class _STLP_atomic_freelist { +public: + /** + * Type representing items of the freelist + */ + struct item { + item* _M_next; + }; + + _STLP_atomic_freelist() { + // Statically assert layout of member is as expected by assembly code + _STLP_STATIC_ASSERT(sizeof(_M) == 8) + _M._M_data._M_top = 0; + _M._M_data._M_sequence = 0; + } + + /** + * Atomically pushes the specified item onto the freelist. + * + * @param __item [in] Item to add to the front of the list + */ + void push(item* __item) { + // NOTE: GCC uses ebx as the PIC register for globals in shared libraries. + // The GCC version I'm using (3.4.1) won't temporarily spill it if it's + // used as input, output, or clobber. Instead, it complains with a + // "can't find a register in class `BREG' while reloading `asm'" error. + // This is probably a compiler bug, but as the cmpxchg8b instruction + // requires ebx, I work around this here by using ecx for the '__item' + // input and spilling ebx into edi. This also precludes us from using + // a "m" operand for the cmpxchg8b argument (GCC might think it can make + // it relative to ebx). Instead, we're using esi for the address of _M_data. + // + int __tmp1; // These dummy variables are used to tell GCC that the eax, ecx, + int __tmp2; // and edx registers will not have the same value as their input. + int __tmp3; // The optimizer will remove them as their values are not used. + __asm__ __volatile__ + (" movl %%ebx, %%edi\n\t" + " movl %%ecx, %%ebx\n\t" + "L1_%=: movl %%eax, (%%ebx)\n\t" // __item._M_next = _M._M_data._M_top + " leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1 + "lock; cmpxchg8b (%%esi)\n\t" + " jne L1_%=\n\t" // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top) + " movl %%edi, %%ebx" + :"=a" (__tmp1), "=d" (__tmp2), "=c" (__tmp3) + :"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "c" (__item), "S" (&_M._M_data) + :"edi", "memory", "cc"); + } + + /** + * Atomically removes the topmost item from the freelist and returns a + * pointer to it. Returns NULL if the list is empty. + * + * @return Item that was removed from front of list; NULL if list empty + */ + item* pop() { + item* __result; + int __tmp; + __asm__ __volatile__ + (" movl %%ebx, %%edi\n\t" + "L1_%=: testl %%eax, %%eax\n\t" // _M_top == NULL? + " je L2_%=\n\t" // If yes, we're done + " movl (%%eax), %%ebx\n\t" // new top = _M._M_data._M_top->_M_next + " leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1 + "lock; cmpxchg8b (%%esi)\n\t" + " jne L1_%=\n\t" // We failed, retry! (edx:eax now contain most recent _M_sequence:_M_top) + "L2_%=: movl %%edi, %%ebx" + :"=a" (__result), "=d" (__tmp) + :"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "S" (&_M._M_data) + :"edi", "ecx", "memory", "cc"); + return __result; + } + + /** + * Atomically detaches all items from the list and returns a pointer to the + * topmost item. The items are still chained and may be traversed safely as + * they're now "owned" by the calling thread. + * + * @return Pointer to topmost item in the list; NULL if list empty + */ + item* clear() { + item* __result; + int __tmp; + __asm__ __volatile__ + (" movl %%ebx, %%edi\n\t" + "L1_%=: testl %%eax, %%eax\n\t" // _M_top == NULL? + " je L2_%=\n\t" // If yes, we're done + " xorl %%ebx, %%ebx\n\t" // We're attempting to set _M_top to NULL + " leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1 + "lock; cmpxchg8b (%%esi)\n\t" + " jne L1_%=\n\t" // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top) + "L2_%=: movl %%edi, %%ebx" + :"=a" (__result), "=d" (__tmp) + :"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "S" (&_M._M_data) + :"edi", "ecx", "memory", "cc"); + return __result; + } + +private: + union { + long long _M_align; + struct { + item* _M_top; // Topmost element in the freelist + unsigned int _M_sequence; // Sequence counter to prevent "ABA problem" + } _M_data; + } _M; + + _STLP_atomic_freelist(const _STLP_atomic_freelist&); + _STLP_atomic_freelist& operator=(const _STLP_atomic_freelist&); +}; + +# endif /* if defined(__GNUC__) && defined(__i386__) */ + +#elif defined (_STLP_WIN32THREADS) + +# if !defined (_WIN64) +# define _STLP_USE_ASM_IMPLEMENTATION +# endif + +// Here are the compiler/platform requirements for the thread safe and +// lock free singly linked list implementation: +# if defined (_STLP_USE_ASM_IMPLEMENTATION) +// For the asm version: +# if defined (_STLP_MSVC) && defined (_M_IX86) && (_M_IX86 >= 500) +# define _STLP_HAS_ATOMIC_FREELIST +# endif +# else +// For the API based version: +# if defined (_STLP_NEW_PLATFORM_SDK) && (!defined (WINVER) || (WINVER >= 0x0501)) && \ + (!defined (_WIN32_WINNT) || (_WIN32_WINNT >= 0x0501)) +# define _STLP_HAS_ATOMIC_FREELIST +# endif +# endif + +# if defined (_STLP_HAS_ATOMIC_FREELIST) +# if defined (_STLP_USE_ASM_IMPLEMENTATION) +# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) || defined (__ICL) +# pragma warning (push) +# pragma warning (disable : 4035) //function has no return value +# endif +# endif +/** + * Class that implements a non-blocking and thread-safe freelist. + * It is used for the lock-free node allocation engine. + * + * @author felixw@inin.com + */ +class _STLP_atomic_freelist { +public: + /** + * Type representing items of the freelist + */ +# if defined (_STLP_USE_ASM_IMPLEMENTATION) + struct item { + item* _M_next; + }; +# else + typedef SLIST_ENTRY item; +# endif + + _STLP_atomic_freelist() { + // Statically assert layout of member is as expected by assembly code +# if defined (_STLP_USE_ASM_IMPLEMENTATION) + _STLP_STATIC_ASSERT((sizeof(item) == sizeof(item*)) && (sizeof(_M) == 8)) + _M._M_data._M_top = 0; + _M._M_data._M_sequence = 0; +# else + InitializeSListHead(&_M_head); +# endif + } + + /** + * Atomically pushes the specified item onto the freelist. + * + * @param __item [in] Item to add to the front of the list + */ + void push(item* __item) { +# if defined (_STLP_USE_ASM_IMPLEMENTATION) + __asm + { + mov esi, this + mov ebx, __item + mov eax, [esi] // _M._M_data._M_top + mov edx, [esi+4] // _M._M_data._M_sequence + L1: mov [ebx], eax // __item._M_next = _M._M_data._M_top + lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1 + lock cmpxchg8b qword ptr [esi] + jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top) + } +# else + InterlockedPushEntrySList(&_M_head, __item); +# endif + } + + /** + * Atomically removes the topmost item from the freelist and returns a + * pointer to it. Returns NULL if the list is empty. + * + * @return Item that was removed from front of list; NULL if list empty + */ + item* pop() { +# if defined (_STLP_USE_ASM_IMPLEMENTATION) + __asm + { + mov esi, this + mov eax, [esi] // _M._M_data._M_top + mov edx, [esi+4] // _M._M_data._M_sequence + L1: test eax, eax // _M_top == NULL? + je L2 // Yes, we're done + mov ebx, [eax] // new top = _M._M_data._M_top->_M_next + lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1 + lock cmpxchg8b qword ptr [esi] + jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top) + L2: + } +# else + return InterlockedPopEntrySList(&_M_head); +# endif + } + + /** + * Atomically detaches all items from the list and returns pointer to the + * topmost. The items are still chained and may be traversed safely as + * they're now "owned" by the calling thread. + * + * @return Pointer to topmost item in the list; NULL if list empty + */ + item* clear() { +# if defined (_STLP_USE_ASM_IMPLEMENTATION) + __asm + { + mov esi, this + mov eax, [esi] // _M._M_data._M_top + mov edx, [esi+4] // _M._M_data._M_sequence + L1: test eax, eax // _M_top == NULL? + je L2 // Yes, we're done + xor ebx,ebx // We're attempting to set _M._M_data._M_top to NULL + lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1 + lock cmpxchg8b qword ptr [esi] + jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top) + L2: + } +# else + return InterlockedFlushSList(&_M_head); +# endif + } + +private: +# if defined (_STLP_USE_ASM_IMPLEMENTATION) + union { + __int64 _M_align; + struct { + item* _M_top; // Topmost element in the freelist + unsigned int _M_sequence; // Sequence counter to prevent "ABA problem" + } _M_data; + } _M; +# else + SLIST_HEADER _M_head; +# endif + + _STLP_atomic_freelist(const _STLP_atomic_freelist&); + _STLP_atomic_freelist& operator = (const _STLP_atomic_freelist&); +}; + +# if defined (_STLP_USE_ASM_IMPLEMENTATION) +# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) || defined (__ICL) +# pragma warning (pop) +# endif +# endif + +# endif /* _STLP_HAS_ATOMIC_FREELIST */ + +#endif + +#endif /* _STLP_LOCK_FREE_SLIST_H */ diff --git a/sdk/tlibstdcxx/src/message_facets.h b/sdk/tlibstdcxx/src/message_facets.h new file mode 100644 index 0000000000..946b5291b0 --- /dev/null +++ b/sdk/tlibstdcxx/src/message_facets.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef MESSAGE_FACETS_H +#define MESSAGE_FACETS_H + +#include +#include +#include + +#include "c_locale.h" + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Class _Catalog_locale_map. The reason for this is that, internally, +// a message string is always a char*. We need a ctype facet to convert +// a string to and from wchar_t, and the user is permitted to provide such +// a facet when calling open(). + +struct _Catalog_locale_map { + _Catalog_locale_map() : M(0) {} + ~_Catalog_locale_map() { if (M) delete M; } + + void insert(nl_catd_type key, const locale& L); + locale lookup(nl_catd_type key) const; + void erase(nl_catd_type key); + + typedef hash_map, equal_to, + allocator > > map_type; + map_type *M; + +private: // Invalidate copy constructor and assignment + _Catalog_locale_map(const _Catalog_locale_map&); + void operator=(const _Catalog_locale_map&); +}; + +/* + * In glibc nl_catd type is void *, but messages_base::catalog is defined as int + * by ISO/IEC 14882; The int may be too short to store pointer on 64-bit platforms; + * Another problem, is that do_open() may return negative value to indicate that no + * catalog open---this case can't be represented with pointers. + * The class _Catalog_nl_catd_map intended to make relation between + * messages_base::catalog and nl_catd handler. + * + */ + +#if defined (_STLP_USE_GLIBC2_LOCALIZATION) +# define _STLP_USE_NL_CATD_MAPPING +#else +/* If no mapping a message_base::catalog entry, int typedef according C++ Standard 22.2.7.1, + * has to be large enough to contain a nl_catd_type value. + */ +_STLP_STATIC_ASSERT(sizeof(nl_catd_type) <= sizeof(int)) +#endif + +class _STLP_CLASS_DECLSPEC _Catalog_nl_catd_map { +public: + _Catalog_nl_catd_map() + {} + ~_Catalog_nl_catd_map() + {} + + typedef hash_map, equal_to, + allocator > > map_type; + typedef hash_map, equal_to, + allocator > > rmap_type; + // typedef map map_type; + // typedef map rmap_type; + + messages_base::catalog insert(nl_catd_type cat) +#if !defined (_STLP_USE_NL_CATD_MAPPING) + { return (messages_base::catalog)cat; } +#else + ; +#endif + + void erase(messages_base::catalog) +#if !defined (_STLP_USE_NL_CATD_MAPPING) + {} +#else + ; +#endif + + nl_catd_type operator [] ( messages_base::catalog cat ) +#if !defined (_STLP_USE_NL_CATD_MAPPING) + { return cat; } +#else + { return cat < 0 ? 0 : M[cat]; } +#endif + +private: + _Catalog_nl_catd_map(const _Catalog_nl_catd_map&); + _Catalog_nl_catd_map& operator =(const _Catalog_nl_catd_map&); + +#if defined (_STLP_USE_NL_CATD_MAPPING) + map_type M; + rmap_type Mr; + static _STLP_VOLATILE __stl_atomic_t _count; +#endif +}; + +class _Messages { +public: + typedef messages_base::catalog catalog; + + _Messages(bool, const char *name); + _Messages(bool, _Locale_messages*); + + catalog do_open(const string& __fn, const locale& __loc) const; + string do_get(catalog __c, int __set, int __msgid, + const string& __dfault) const; +#if !defined (_STLP_NO_WCHAR_T) + wstring do_get(catalog __c, int __set, int __msgid, + const wstring& __dfault) const; +#endif + void do_close(catalog __c) const; + ~_Messages(); + +private: + _Locale_messages* _M_message_obj; + _Catalog_locale_map* _M_map; + mutable _Catalog_nl_catd_map _M_cat; + + //private definition to avoid warning (with ICL) + _Messages(const _Messages&); + _Messages& operator=(const _Messages&); +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/messages.cpp b/sdk/tlibstdcxx/src/messages.cpp new file mode 100644 index 0000000000..ae4669e5c8 --- /dev/null +++ b/sdk/tlibstdcxx/src/messages.cpp @@ -0,0 +1,247 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include + +#include "message_facets.h" +#include "acquire_release.h" + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +void _Catalog_locale_map::insert(nl_catd_type key, const locale& L) { + _STLP_TRY { +#if !defined (_STLP_NO_TYPEINFO) && !defined (_STLP_NO_RTTI) + // Don't bother to do anything unless we're using a non-default ctype facet +# ifdef _STLP_NO_WCHAR_T + typedef char _Char; +# else + typedef wchar_t _Char; +# endif + + typedef ctype<_Char> wctype; + wctype const& wct = use_facet(L); + if (typeid(wct) != typeid(wctype)) { +#endif + if (!M) + M = new map_type; + + M->insert(map_type::value_type(key, L)); +#if !defined (_STLP_NO_TYPEINFO) && !defined (_STLP_NO_RTTI) + } +#endif + } + _STLP_CATCH_ALL {} +} + +void _Catalog_locale_map::erase(nl_catd_type key) { + if (M) + M->erase(key); +} + +locale _Catalog_locale_map::lookup(nl_catd_type key) const { + if (M) { + map_type::const_iterator i = M->find(key); + return i != M->end() ? (*i).second : locale::classic(); + } + else + return locale::classic(); +} + + +#if defined (_STLP_USE_NL_CATD_MAPPING) +_STLP_VOLATILE __stl_atomic_t _Catalog_nl_catd_map::_count = 0; + +messages_base::catalog _Catalog_nl_catd_map::insert(nl_catd_type cat) { + messages_base::catalog &res = Mr[cat]; + if ( res == 0 ) { +#if defined (_STLP_ATOMIC_INCREMENT) + res = __STATIC_CAST(int, _STLP_ATOMIC_INCREMENT(&_count)); +#else + static _STLP_STATIC_MUTEX _Count_lock _STLP_MUTEX_INITIALIZER; + { + _STLP_auto_lock sentry(_Count_lock); + res = __STATIC_CAST(int, ++_count); + } +#endif + M[res] = cat; + } + return res; +} + +void _Catalog_nl_catd_map::erase(messages_base::catalog cat) { + map_type::iterator mit(M.find(cat)); + if (mit != M.end()) { + Mr.erase((*mit).second); + M.erase(mit); + } +} +#endif + +//---------------------------------------------------------------------- +// +_Messages::_Messages(bool is_wide, const char *name) : + _M_message_obj(0), _M_map(0) { + if (!name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _M_message_obj = _STLP_PRIV __acquire_messages(name, buf, 0, &__err_code); + if (!_M_message_obj) + locale::_M_throw_on_creation_failure(__err_code, name, "messages"); + + if (is_wide) + _M_map = new _Catalog_locale_map; +} + +_Messages::_Messages(bool is_wide, _Locale_messages* msg) : + _M_message_obj(msg), _M_map(is_wide ? new _Catalog_locale_map() : 0) +{} + +_Messages::~_Messages() { + __release_messages(_M_message_obj); + delete _M_map; +} + +_Messages::catalog _Messages::do_open(const string& filename, const locale& L) const { + nl_catd_type result = _M_message_obj ? _Locale_catopen(_M_message_obj, filename.c_str()) + : (nl_catd_type)(-1); + + if ( result != (nl_catd_type)(-1) ) { + if ( _M_map != 0 ) { + _M_map->insert(result, L); + } + return _STLP_MUTABLE(_Messages_impl, _M_cat).insert( result ); + } + + return -1; +} + +string _Messages::do_get(catalog cat, + int set, int p_id, const string& dfault) const { + return _M_message_obj != 0 && cat >= 0 + ? string(_Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[cat], + set, p_id, dfault.c_str())) + : dfault; +} + +#if !defined (_STLP_NO_WCHAR_T) + +wstring +_Messages::do_get(catalog thecat, + int set, int p_id, const wstring& dfault) const { + typedef ctype wctype; + const wctype& ct = use_facet(_M_map->lookup(_STLP_MUTABLE(_Messages_impl, _M_cat)[thecat])); + + const char* str = _Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat], set, p_id, ""); + + // Verify that the lookup failed; an empty string might represent success. + if (!str) + return dfault; + else if (str[0] == '\0') { + const char* str2 = _Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat], set, p_id, "*"); + if (!str2 || ((str2[0] == '*') && (str2[1] == '\0'))) + return dfault; + } + + // str is correct. Now we must widen it to get a wstring. + size_t n = strlen(str); + + // NOT PORTABLE. What we're doing relies on internal details of the + // string implementation. (Contiguity of string elements.) + wstring result(n, wchar_t(0)); + ct.widen(str, str + n, &*result.begin()); + return result; +} + +#endif + +void _Messages::do_close(catalog thecat) const { + if (_M_message_obj) + _Locale_catclose(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]); + if (_M_map) _M_map->erase(_STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]); + _STLP_MUTABLE(_Messages_impl, _M_cat).erase( thecat ); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +//---------------------------------------------------------------------- +// messages +messages::messages(size_t refs) + : locale::facet(refs) {} + +messages_byname::messages_byname(const char *name, size_t refs) + : messages(refs), _M_impl(new _STLP_PRIV _Messages(false, name)) {} + +messages_byname::messages_byname(_Locale_messages* msg) + : messages(0), _M_impl(new _STLP_PRIV _Messages(false, msg)) {} + +messages_byname::~messages_byname() +{ delete _M_impl; } + +messages_byname::catalog +messages_byname::do_open(const string& filename, const locale& l) const +{ return _M_impl->do_open(filename, l); } + +string +messages_byname::do_get(catalog cat, int set, int p_id, + const string& dfault) const +{ return _M_impl->do_get(cat, set, p_id, dfault); } + +void messages_byname::do_close(catalog cat) const +{ _M_impl->do_close(cat); } + +#if !defined (_STLP_NO_WCHAR_T) + +//---------------------------------------------------------------------- +// messages + +messages::messages(size_t refs) + : locale::facet(refs) {} + +messages_byname::messages_byname(const char *name, size_t refs) + : messages(refs), _M_impl(new _STLP_PRIV _Messages(true, name)) {} + +messages_byname::messages_byname(_Locale_messages* msg) + : messages(0), _M_impl(new _STLP_PRIV _Messages(true, msg)) {} + +messages_byname::~messages_byname() +{ delete _M_impl; } + +messages_byname::catalog +messages_byname::do_open(const string& filename, const locale& L) const +{ return _M_impl->do_open(filename, L); } + +wstring +messages_byname::do_get(catalog thecat, + int set, int p_id, const wstring& dfault) const +{ return _M_impl->do_get(thecat, set, p_id, dfault); } + +void messages_byname::do_close(catalog cat) const +{ _M_impl->do_close(cat); } + +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/monetary.cpp b/sdk/tlibstdcxx/src/monetary.cpp new file mode 100644 index 0000000000..d9b213ac0b --- /dev/null +++ b/sdk/tlibstdcxx/src/monetary.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include +#include + +_STLP_BEGIN_NAMESPACE + +static void _Init_monetary_formats(money_base::pattern& pos_format, + money_base::pattern& neg_format) { + pos_format.field[0] = (char) money_base::symbol; + pos_format.field[1] = (char) money_base::sign; + pos_format.field[2] = (char) money_base::none; + pos_format.field[3] = (char) money_base::value; + + neg_format.field[0] = (char) money_base::symbol; + neg_format.field[1] = (char) money_base::sign; + neg_format.field[2] = (char) money_base::none; + neg_format.field[3] = (char) money_base::value; +} + +// This is being used throughout the library +static const string _S_empty_string; +#ifndef _STLP_NO_WCHAR_T +static const wstring _S_empty_wstring; +#endif + +// +// moneypunct<> +// + +moneypunct::moneypunct(size_t __refs) : locale::facet(__refs) +{ _Init_monetary_formats(_M_pos_format, _M_neg_format); } +moneypunct::~moneypunct() {} + +char moneypunct::do_decimal_point() const {return ' ';} +char moneypunct::do_thousands_sep() const {return ' ';} +string moneypunct::do_grouping() const { return _S_empty_string; } +string moneypunct::do_curr_symbol() const { return _S_empty_string; } +string moneypunct::do_positive_sign() const { return _S_empty_string; } +string moneypunct::do_negative_sign() const { return _S_empty_string; } +money_base::pattern moneypunct::do_pos_format() const {return _M_pos_format;} +money_base::pattern moneypunct::do_neg_format() const {return _M_neg_format;} +int moneypunct::do_frac_digits() const {return 0;} + +moneypunct::moneypunct(size_t __refs) : locale::facet(__refs) +{ _Init_monetary_formats(_M_pos_format, _M_neg_format); } +moneypunct::~moneypunct() {} + +char moneypunct::do_decimal_point() const {return ' ';} +char moneypunct::do_thousands_sep() const {return ' ';} + +string moneypunct::do_grouping() const { return _S_empty_string; } +string moneypunct::do_curr_symbol() const { return _S_empty_string; } +string moneypunct::do_positive_sign() const { return _S_empty_string; } +string moneypunct::do_negative_sign() const { return _S_empty_string; } +money_base::pattern moneypunct::do_pos_format() const {return _M_pos_format;} +money_base::pattern moneypunct::do_neg_format() const {return _M_neg_format;} +int moneypunct::do_frac_digits() const {return 0;} + +#ifndef _STLP_NO_WCHAR_T +moneypunct::moneypunct(size_t __refs) : locale::facet(__refs) +{ _Init_monetary_formats(_M_pos_format, _M_neg_format); } +moneypunct::~moneypunct() {} + +wchar_t moneypunct::do_decimal_point() const {return L' ';} +wchar_t moneypunct::do_thousands_sep() const {return L' ';} +string moneypunct::do_grouping() const {return _S_empty_string;} + +wstring moneypunct::do_curr_symbol() const +{return _S_empty_wstring;} +wstring moneypunct::do_positive_sign() const +{return _S_empty_wstring;} +wstring moneypunct::do_negative_sign() const +{return _S_empty_wstring;} +int moneypunct::do_frac_digits() const {return 0;} +money_base::pattern moneypunct::do_pos_format() const +{return _M_pos_format;} +money_base::pattern moneypunct::do_neg_format() const +{return _M_neg_format;} + +moneypunct::moneypunct(size_t __refs) : locale::facet(__refs) +{ _Init_monetary_formats(_M_pos_format, _M_neg_format); } +moneypunct::~moneypunct() {} + +wchar_t moneypunct::do_decimal_point() const {return L' ';} +wchar_t moneypunct::do_thousands_sep() const {return L' ';} +string moneypunct::do_grouping() const { return _S_empty_string;} +wstring moneypunct::do_curr_symbol() const +{return _S_empty_wstring;} +wstring moneypunct::do_positive_sign() const +{return _S_empty_wstring;} +wstring moneypunct::do_negative_sign() const +{return _S_empty_wstring;} +int moneypunct::do_frac_digits() const {return 0;} + +money_base::pattern moneypunct::do_pos_format() const +{return _M_pos_format;} +money_base::pattern moneypunct::do_neg_format() const +{return _M_neg_format;} + +#endif /* WCHAR_T */ + +// +// Instantiations +// + +#if !defined (_STLP_NO_FORCE_INSTANTIATE) + +template class _STLP_CLASS_DECLSPEC money_get > >; +template class _STLP_CLASS_DECLSPEC money_put > >; +// template class money_put; + +# ifndef _STLP_NO_WCHAR_T +template class _STLP_CLASS_DECLSPEC money_get > >; +template class _STLP_CLASS_DECLSPEC money_put > >; +// template class money_put; +// template class money_get; +# endif + +#endif + +#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) +const bool moneypunct::intl; +const bool moneypunct::intl; +# ifndef _STLP_NO_WCHAR_T +const bool moneypunct::intl; +const bool moneypunct::intl; +# endif +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/num_get.cpp b/sdk/tlibstdcxx/src/num_get.cpp new file mode 100644 index 0000000000..45901acff0 --- /dev/null +++ b/sdk/tlibstdcxx/src/num_get.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include +#include +#include + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +// __valid_grouping compares two strings, one representing the +// group sizes encountered when reading an integer, and the other +// representing the valid group sizes as returned by the numpunct +// grouping() member function. Both are interpreted right-to-left. +// The grouping string is treated as if it were extended indefinitely +// with its last value. For a grouping to be valid, each term in +// the first string must be equal to the corresponding term in the +// second, except for the last, which must be less than or equal. + +// boris : this takes reversed first string ! +bool _STLP_CALL +__valid_grouping(const char * first1, const char * last1, + const char * first2, const char * last2) { + if (first1 == last1 || first2 == last2) return true; + + --last1; --last2; + + while (first1 != last1) { + if (*last1 != *first2) + return false; + --last1; + if (first2 != last2) ++first2; + } + + return *last1 <= *first2; +} + +_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index) { + static const unsigned char __val_table[128] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + }; + + return __val_table[__index]; +} + +_STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms() +{ return "+-0xX"; } + +// index is actually a char + +#if !defined (_STLP_NO_WCHAR_T) + +// Similar, except return the character itself instead of the numeric +// value. Used for floating-point input. +bool _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits) { + const wchar_t* p = find(digits, digits + 10, c); + if (p != digits + 10) { + c = (char)('0' + (p - digits)); + return true; + } + else + return false; +} + +bool _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep, + const wchar_t * digits) { + if (c == sep) { + c = (char)','; + return true; + } + else + return __get_fdigit(c, digits); +} + +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +#if !defined(_STLP_NO_FORCE_INSTANTIATE) +//---------------------------------------------------------------------- +// Force instantiation of num_get<> +template class _STLP_CLASS_DECLSPEC istreambuf_iterator >; +// template class num_get; +template class num_get > >; + +# if !defined (_STLP_NO_WCHAR_T) +template class _STLP_CLASS_DECLSPEC istreambuf_iterator >; +template class num_get > >; +// template class num_get; +# endif +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/num_get_float.cpp b/sdk/tlibstdcxx/src/num_get_float.cpp new file mode 100644 index 0000000000..d26f58d45c --- /dev/null +++ b/sdk/tlibstdcxx/src/num_get_float.cpp @@ -0,0 +1,883 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include +#include + +#if (defined (__GNUC__) && !defined (__sun) && !defined (__hpux)) || \ + defined (__DMC__) +# include +#endif + +#if defined (__linux__) || defined (__MINGW32__) || defined (__CYGWIN__) || \ + defined (__BORLANDC__) || defined (__DMC__) || defined (__HP_aCC) + +# if defined (__BORLANDC__) +typedef unsigned int uint32_t; +typedef unsigned __int64 uint64_t; +# endif + +union _ll { + uint64_t i64; + struct { +# if defined (_STLP_BIG_ENDIAN) + uint32_t hi; + uint32_t lo; +# elif defined (_STLP_LITTLE_ENDIAN) + uint32_t lo; + uint32_t hi; +# else +# error Unknown endianess +# endif + } i32; +}; + +# if defined (__linux__) +# include +# else +union ieee854_long_double { + long double d; + + /* This is the IEEE 854 double-extended-precision format. */ + struct { + unsigned int mantissa1:32; + unsigned int mantissa0:32; + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; + } ieee; +}; + +# define IEEE854_LONG_DOUBLE_BIAS 0x3fff +# endif +#endif + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +//---------------------------------------------------------------------- +// num_get + +// Helper functions for _M_do_get_float. + +#if !defined (_STLP_NO_WCHAR_T) +void _STLP_CALL +_Initialize_get_float( const ctype& ct, + wchar_t& Plus, wchar_t& Minus, + wchar_t& pow_e, wchar_t& pow_E, + wchar_t* digits) { + char ndigits[11] = "0123456789"; + Plus = ct.widen('+'); + Minus = ct.widen('-'); + pow_e = ct.widen('e'); + pow_E = ct.widen('E'); + ct.widen(ndigits + 0, ndigits + 10, digits); +} +#endif /* WCHAR_T */ + +/* + * __string_to_double is just lifted from atof, the difference being + * that we just use '.' for the decimal point, rather than let it + * be taken from the current C locale, which of course is not accessible + * to us. + */ +#if defined (_STLP_MSVC) || defined (__BORLANDC__) || defined (__ICL) +typedef unsigned long uint32; +typedef unsigned __int64 uint64; +# define ULL(x) x##Ui64 +#elif defined (__unix) || defined (__MINGW32__) || \ + (defined (__DMC__) && (__LONGLONG)) || defined (__WATCOMC__) +typedef uint32_t uint32; +typedef uint64_t uint64; +# define ULL(x) x##ULL +#else +# error There should be some unsigned 64-bit integer on the system! +#endif + +// Multiplication of two 64-bit integers, giving a 128-bit result. +// Taken from Algorithm M in Knuth section 4.3.1, with the loop +// hand-unrolled. +static void _Stl_mult64(const uint64 u, const uint64 v, + uint64& high, uint64& low) { + const uint64 low_mask = ULL(0xffffffff); + const uint64 u0 = u & low_mask; + const uint64 u1 = u >> 32; + const uint64 v0 = v & low_mask; + const uint64 v1 = v >> 32; + + uint64 t = u0 * v0; + low = t & low_mask; + + t = u1 * v0 + (t >> 32); + uint64 w1 = t & low_mask; + uint64 w2 = t >> 32; + + uint64 x = u0 * v1 + w1; + low += (x & low_mask) << 32; + high = u1 * v1 + w2 + (x >> 32); +} + +#ifndef __linux__ + +# define bit11 ULL(0x7ff) +# define exponent_mask (bit11 << 52) + +# if !defined (__GNUC__) || (__GNUC__ != 3) || (__GNUC_MINOR__ != 4) || \ + (!defined (__CYGWIN__) && !defined (__MINGW32__)) +//Generate bad code when compiled with -O2 option. +inline +# endif +void _Stl_set_exponent(uint64 &val, uint64 exp) +{ val = (val & ~exponent_mask) | ((exp & bit11) << 52); } + +#endif // __linux__ + +/* Power of ten fractions for tenscale*/ +/* The constants are factored so that at most two constants + * and two multiplies are needed. Furthermore, one of the constants + * is represented exactly - 10**n where 1<= n <= 27. + */ + +static const uint64 _Stl_tenpow[80] = { +ULL(0xa000000000000000), /* _Stl_tenpow[0]=(10**1)/(2**4) */ +ULL(0xc800000000000000), /* _Stl_tenpow[1]=(10**2)/(2**7) */ +ULL(0xfa00000000000000), /* _Stl_tenpow[2]=(10**3)/(2**10) */ +ULL(0x9c40000000000000), /* _Stl_tenpow[3]=(10**4)/(2**14) */ +ULL(0xc350000000000000), /* _Stl_tenpow[4]=(10**5)/(2**17) */ +ULL(0xf424000000000000), /* _Stl_tenpow[5]=(10**6)/(2**20) */ +ULL(0x9896800000000000), /* _Stl_tenpow[6]=(10**7)/(2**24) */ +ULL(0xbebc200000000000), /* _Stl_tenpow[7]=(10**8)/(2**27) */ +ULL(0xee6b280000000000), /* _Stl_tenpow[8]=(10**9)/(2**30) */ +ULL(0x9502f90000000000), /* _Stl_tenpow[9]=(10**10)/(2**34) */ +ULL(0xba43b74000000000), /* _Stl_tenpow[10]=(10**11)/(2**37) */ +ULL(0xe8d4a51000000000), /* _Stl_tenpow[11]=(10**12)/(2**40) */ +ULL(0x9184e72a00000000), /* _Stl_tenpow[12]=(10**13)/(2**44) */ +ULL(0xb5e620f480000000), /* _Stl_tenpow[13]=(10**14)/(2**47) */ +ULL(0xe35fa931a0000000), /* _Stl_tenpow[14]=(10**15)/(2**50) */ +ULL(0x8e1bc9bf04000000), /* _Stl_tenpow[15]=(10**16)/(2**54) */ +ULL(0xb1a2bc2ec5000000), /* _Stl_tenpow[16]=(10**17)/(2**57) */ +ULL(0xde0b6b3a76400000), /* _Stl_tenpow[17]=(10**18)/(2**60) */ +ULL(0x8ac7230489e80000), /* _Stl_tenpow[18]=(10**19)/(2**64) */ +ULL(0xad78ebc5ac620000), /* _Stl_tenpow[19]=(10**20)/(2**67) */ +ULL(0xd8d726b7177a8000), /* _Stl_tenpow[20]=(10**21)/(2**70) */ +ULL(0x878678326eac9000), /* _Stl_tenpow[21]=(10**22)/(2**74) */ +ULL(0xa968163f0a57b400), /* _Stl_tenpow[22]=(10**23)/(2**77) */ +ULL(0xd3c21bcecceda100), /* _Stl_tenpow[23]=(10**24)/(2**80) */ +ULL(0x84595161401484a0), /* _Stl_tenpow[24]=(10**25)/(2**84) */ +ULL(0xa56fa5b99019a5c8), /* _Stl_tenpow[25]=(10**26)/(2**87) */ +ULL(0xcecb8f27f4200f3a), /* _Stl_tenpow[26]=(10**27)/(2**90) */ + +ULL(0xd0cf4b50cfe20766), /* _Stl_tenpow[27]=(10**55)/(2**183) */ +ULL(0xd2d80db02aabd62c), /* _Stl_tenpow[28]=(10**83)/(2**276) */ +ULL(0xd4e5e2cdc1d1ea96), /* _Stl_tenpow[29]=(10**111)/(2**369) */ +ULL(0xd6f8d7509292d603), /* _Stl_tenpow[30]=(10**139)/(2**462) */ +ULL(0xd910f7ff28069da4), /* _Stl_tenpow[31]=(10**167)/(2**555) */ +ULL(0xdb2e51bfe9d0696a), /* _Stl_tenpow[32]=(10**195)/(2**648) */ +ULL(0xdd50f1996b947519), /* _Stl_tenpow[33]=(10**223)/(2**741) */ +ULL(0xdf78e4b2bd342cf7), /* _Stl_tenpow[34]=(10**251)/(2**834) */ +ULL(0xe1a63853bbd26451), /* _Stl_tenpow[35]=(10**279)/(2**927) */ +ULL(0xe3d8f9e563a198e5), /* _Stl_tenpow[36]=(10**307)/(2**1020) */ + +// /* _Stl_tenpow[36]=(10**335)/(2**) */ +// /* _Stl_tenpow[36]=(10**335)/(2**) */ + +ULL(0xfd87b5f28300ca0e), /* _Stl_tenpow[37]=(10**-28)/(2**-93) */ +ULL(0xfb158592be068d2f), /* _Stl_tenpow[38]=(10**-56)/(2**-186) */ +ULL(0xf8a95fcf88747d94), /* _Stl_tenpow[39]=(10**-84)/(2**-279) */ +ULL(0xf64335bcf065d37d), /* _Stl_tenpow[40]=(10**-112)/(2**-372) */ +ULL(0xf3e2f893dec3f126), /* _Stl_tenpow[41]=(10**-140)/(2**-465) */ +ULL(0xf18899b1bc3f8ca2), /* _Stl_tenpow[42]=(10**-168)/(2**-558) */ +ULL(0xef340a98172aace5), /* _Stl_tenpow[43]=(10**-196)/(2**-651) */ +ULL(0xece53cec4a314ebe), /* _Stl_tenpow[44]=(10**-224)/(2**-744) */ +ULL(0xea9c227723ee8bcb), /* _Stl_tenpow[45]=(10**-252)/(2**-837) */ +ULL(0xe858ad248f5c22ca), /* _Stl_tenpow[46]=(10**-280)/(2**-930) */ +ULL(0xe61acf033d1a45df), /* _Stl_tenpow[47]=(10**-308)/(2**-1023) */ +ULL(0xe3e27a444d8d98b8), /* _Stl_tenpow[48]=(10**-336)/(2**-1116) */ +ULL(0xe1afa13afbd14d6e) /* _Stl_tenpow[49]=(10**-364)/(2**-1209) */ +}; + +static const short _Stl_twoexp[80] = { +4,7,10,14,17,20,24,27,30,34,37,40,44,47,50,54,57,60,64,67,70,74,77,80,84,87,90, +183,276,369,462,555,648,741,834,927,1020, +-93,-186,-279,-372,-465,-558,-651,-744,-837,-930,-1023,-1116,-1209 +}; + +#define TEN_1 0 /* offset to 10 ** 1 */ +#define TEN_27 26 /* offset to 10 ** 27 */ +#define TEN_M28 37 /* offset to 10 ** -28 */ +#define NUM_HI_P 11 +#define NUM_HI_N 13 + +#define _Stl_HIBITULL (ULL(1) << 63) + +static void _Stl_norm_and_round(uint64& p, int& norm, uint64 prodhi, uint64 prodlo) { + norm = 0; + if ((prodhi & _Stl_HIBITULL) == 0) { + /* leading bit is a zero + * may have to normalize + */ + if ((prodhi == ~_Stl_HIBITULL) && + ((prodlo >> 62) == 0x3)) { /* normalization followed by round + * would cause carry to create + * extra bit, so don't normalize + */ + p = _Stl_HIBITULL; + return; + } + p = (prodhi << 1) | (prodlo >> 63); /* normalize */ + norm = 1; + prodlo <<= 1; + } + else { + p = prodhi; + } + + if ((prodlo & _Stl_HIBITULL) != 0) { /* first guard bit a one */ + if (((p & 0x1) != 0) || + prodlo != _Stl_HIBITULL ) { /* not borderline for round to even */ + /* round */ + ++p; + if (p == 0) + ++p; + } + } +} + +// Convert a 64-bitb fraction * 10^exp to a 64-bit fraction * 2^bexp. +// p: 64-bit fraction +// exp: base-10 exponent +// bexp: base-2 exponent (output parameter) +static void _Stl_tenscale(uint64& p, int exp, int& bexp) { + bexp = 0; + + if ( exp == 0 ) { /* no scaling needed */ + return; + } + + int exp_hi = 0, exp_lo = exp; /* exp = exp_hi*32 + exp_lo */ + int tlo = TEN_1, thi; /* offsets in power of ten table */ + int num_hi; /* number of high exponent powers */ + + if (exp > 0) { /* split exponent */ + if (exp_lo > 27) { + exp_lo++; + while (exp_lo > 27) { + exp_hi++; + exp_lo -= 28; + } + } + thi = TEN_27; + num_hi = NUM_HI_P; + } else { // exp < 0 + while (exp_lo < 0) { + exp_hi++; + exp_lo += 28; + } + thi = TEN_M28; + num_hi = NUM_HI_N; + } + + uint64 prodhi, prodlo; /* 128b product */ + int norm; /* number of bits of normalization */ + + int hi, lo; /* offsets in power of ten table */ + while (exp_hi) { /* scale */ + hi = (min) (exp_hi, num_hi); /* only a few large powers of 10 */ + exp_hi -= hi; /* could iterate in extreme case */ + hi += thi-1; + _Stl_mult64(p, _Stl_tenpow[hi], prodhi, prodlo); + _Stl_norm_and_round(p, norm, prodhi, prodlo); + bexp += _Stl_twoexp[hi] - norm; + } + + if (exp_lo) { + lo = tlo + exp_lo -1; + _Stl_mult64(p, _Stl_tenpow[lo], prodhi, prodlo); + _Stl_norm_and_round(p, norm, prodhi, prodlo); + bexp += _Stl_twoexp[lo] - norm; + } + + return; +} + +// First argument is a buffer of values from 0 to 9, NOT ascii. +// Second argument is number of digits in buffer, 1 <= digits <= 17. +// Third argument is base-10 exponent. + +/* IEEE representation */ +#if !defined (__linux__) + +union _Double_rep { + uint64 ival; + double val; +}; + +static double _Stl_atod(char *buffer, ptrdiff_t ndigit, int dexp) { + typedef numeric_limits limits; + _Double_rep drep; + uint64 &value = drep.ival; /* Value develops as follows: + * 1) decimal digits as an integer + * 2) left adjusted fraction + * 3) right adjusted fraction + * 4) exponent and fraction + */ + + uint32 guard; /* First guard bit */ + uint64 rest; /* Remaining guard bits */ + + int bexp; /* binary exponent */ + int nzero; /* number of non-zero bits */ + int sexp; /* scaling exponent */ + + char *bufferend; /* pointer to char after last digit */ + + /* Convert the decimal digits to a binary integer. */ + bufferend = buffer + ndigit; + value = 0; + + while (buffer < bufferend) { + value *= 10; + value += *buffer++; + } + + /* Check for zero and treat it as a special case */ + if (value == 0) { + return 0.0; + } + + /* Normalize value */ + bexp = 64; /* convert from 64b int to fraction */ + + /* Count number of non-zeroes in value */ + nzero = 0; + if ((value >> 32) != 0) { nzero = 32; } //*TY 03/25/2000 - added explicit comparison to zero to avoid uint64 to bool conversion operator + if ((value >> (16 + nzero)) != 0) { nzero += 16; } + if ((value >> ( 8 + nzero)) != 0) { nzero += 8; } + if ((value >> ( 4 + nzero)) != 0) { nzero += 4; } + if ((value >> ( 2 + nzero)) != 0) { nzero += 2; } + if ((value >> ( 1 + nzero)) != 0) { nzero += 1; } + if ((value >> ( nzero)) != 0) { nzero += 1; } + + /* Normalize */ + value <<= /*(uint64)*/ (64 - nzero); //*TY 03/25/2000 - removed extraneous cast to uint64 + bexp -= 64 - nzero; + + /* At this point we have a 64b fraction and a binary exponent + * but have yet to incorporate the decimal exponent. + */ + + /* multiply by 10^dexp */ + _Stl_tenscale(value, dexp, sexp); + bexp += sexp; + + if (bexp <= -1022) { /* HI denorm or underflow */ + bexp += 1022; + if (bexp < -53) { /* guaranteed underflow */ + value = 0; + } + else { /* denorm or possible underflow */ + int lead0 = 12 - bexp; /* 12 sign and exponent bits */ + + /* we must special case right shifts of more than 63 */ + if (lead0 > 64) { + rest = value; + guard = 0; + value = 0; + } + else if (lead0 == 64) { + rest = value & ((ULL(1)<< 63)-1); + guard = (uint32) ((value>> 63) & 1 ); + value = 0; + } + else { + rest = value & (((ULL(1) << lead0)-1)-1); + guard = (uint32) (((value>> lead0)-1) & 1); + value >>= /*(uint64)*/ lead0; /* exponent is zero */ + } + + /* Round */ + if (guard && ((value & 1) || rest) ) { + ++value; + if (value == (ULL(1) << (limits::digits - 1))) { /* carry created normal number */ + value = 0; + _Stl_set_exponent(value, 1); + } + } + } + } + else { /* not zero or denorm */ + /* Round to 53 bits */ + rest = value & ((1 << 10) - 1); + value >>= 10; + guard = (uint32) value & 1; + value >>= 1; + + /* value&1 guard rest Action + * + * dc 0 dc none + * 1 1 dc round + * 0 1 0 none + * 0 1 !=0 round + */ + if (guard) { + if (((value&1)!=0) || (rest!=0)) { + ++value; /* round */ + if ((value >> 53) != 0) { /* carry all the way across */ + value >>= 1; /* renormalize */ + ++bexp; + } + } + } + /* + * Check for overflow + * IEEE Double Precision Format + * (From Table 7-8 of Kane and Heinrich) + * + * Fraction bits 52 + * Emax +1023 + * Emin -1022 + * Exponent bias +1023 + * Exponent bits 11 + * Integer bit hidden + * Total width in bits 64 + */ + + if (bexp > limits::max_exponent) { /* overflow */ + return limits::infinity(); + } + else { /* value is normal */ + value &= ~(ULL(1) << (limits::digits - 1)); /* hide hidden bit */ + _Stl_set_exponent(value, bexp + 1022); /* add bias */ + } + } + + _STLP_STATIC_ASSERT(sizeof(uint64) >= sizeof(double)) + return drep.val; +} + +#endif + +#if defined (__linux__) || defined (__MINGW32__) || defined (__CYGWIN__) || \ + defined (__BORLANDC__) || defined (__DMC__) || defined (__HP_aCC) + +template +D _Stl_atodT(char *buffer, ptrdiff_t ndigit, int dexp) +{ + typedef numeric_limits limits; + + /* Convert the decimal digits to a binary integer. */ + char *bufferend = buffer + ndigit; /* pointer to char after last digit */ + _ll vv; + vv.i64 = 0L; + + while ( buffer < bufferend ) { + vv.i64 *= 10; + vv.i64 += *buffer++; + } + + if ( vv.i64 == ULL(0) ) { /* Check for zero and treat it as a special case */ + return D(0.0); + } + + /* Normalize value */ + + int bexp = 64; /* convert from 64b int to fraction */ + + /* Count number of non-zeroes in value */ + int nzero = 0; + if ((vv.i64 >> 32) != 0) { nzero = 32; } + if ((vv.i64 >> (16 + nzero)) != 0) { nzero += 16; } + if ((vv.i64 >> ( 8 + nzero)) != 0) { nzero += 8; } + if ((vv.i64 >> ( 4 + nzero)) != 0) { nzero += 4; } + if ((vv.i64 >> ( 2 + nzero)) != 0) { nzero += 2; } + if ((vv.i64 >> ( 1 + nzero)) != 0) { nzero += 1; } + if ((vv.i64 >> ( nzero)) != 0) { nzero += 1; } + + /* Normalize */ + nzero = 64 - nzero; + vv.i64 <<= nzero; // * TY 03/25/2000 - removed extraneous cast to uint64 + bexp -= nzero; + + /* At this point we have a 64b fraction and a binary exponent + * but have yet to incorporate the decimal exponent. + */ + + /* multiply by 10^dexp */ + int sexp; + _Stl_tenscale(vv.i64, dexp, sexp); + bexp += sexp; + + if ( bexp >= limits::min_exponent ) { /* not zero or denorm */ + if ( limits::digits < 64 ) { + /* Round to (64 - M + 1) bits */ + uint64_t rest = vv.i64 & ((~ULL(0) / ULL(2)) >> (limits::digits - 1)); + vv.i64 >>= M - 2; + uint32_t guard = (uint32) vv.i64 & 1; + vv.i64 >>= 1; + + /* value&1 guard rest Action + * + * dc 0 dc none + * 1 1 dc round + * 0 1 0 none + * 0 1 !=0 round + */ + + if (guard) { + if ( ((vv.i64 & 1) != 0) || (rest != 0) ) { + vv.i64++; /* round */ + if ( (vv.i64 >> (limits::digits < 64 ? limits::digits : 0)) != 0 ) { /* carry all the way across */ + vv.i64 >>= 1; /* renormalize */ + ++bexp; + } + } + } + + vv.i64 &= ~(ULL(1) << (limits::digits - 1)); /* hide hidden bit */ + } + /* + * Check for overflow + * IEEE Double Precision Format + * (From Table 7-8 of Kane and Heinrich) + * + * Fraction bits 52 + * Emax +1023 + * Emin -1022 + * Exponent bias +1023 + * Exponent bits 11 + * Integer bit hidden + * Total width in bits 64 + */ + + if (bexp > limits::max_exponent) { /* overflow */ + return limits::infinity(); + } + + /* value is normal */ + + IEEE v; + + v.ieee.mantissa0 = vv.i32.hi; + v.ieee.mantissa1 = vv.i32.lo; + v.ieee.negative = 0; + v.ieee.exponent = bexp + BIAS - 1; + + return v.d; + } + + /* HI denorm or underflow */ + bexp += BIAS - 1; + if (bexp < -limits::digits) { /* guaranteed underflow */ + vv.i64 = 0; + } else { /* denorm or possible underflow */ + + /* + * Problem point for long double: looks like this code reflect shareing of mantissa + * and exponent in 64b int; not so for long double + */ + + int lead0 = M - bexp; /* M = 12 sign and exponent bits */ + uint64_t rest; + uint32_t guard; + + /* we must special case right shifts of more than 63 */ + + if (lead0 > 64) { + rest = vv.i64; + guard = 0; + vv.i64 = 0; + } else if (lead0 == 64) { + rest = vv.i64 & ((ULL(1) << 63)-1); + guard = (uint32) ((vv.i64 >> 63) & 1 ); + vv.i64 = 0; + } else { + rest = vv.i64 & (((ULL(1) << lead0)-1)-1); + guard = (uint32) (((vv.i64 >> lead0)-1) & 1); + vv.i64 >>= /*(uint64)*/ lead0; /* exponent is zero */ + } + + /* Round */ + if (guard && ( (vv.i64 & 1) || rest)) { + vv.i64++; + if (vv.i64 == (ULL(1) << (limits::digits - 1))) { /* carry created normal number */ + IEEE v; + + v.ieee.mantissa0 = 0; + v.ieee.mantissa1 = 0; + v.ieee.negative = 0; + v.ieee.exponent = 1; + return v.d; + } + } + } + + IEEE v; + + v.ieee.mantissa0 = vv.i32.hi; + v.ieee.mantissa1 = vv.i32.lo; + v.ieee.negative = 0; + v.ieee.exponent = 0; + + return v.d; +} +#endif // __linux__ + +#ifndef __linux__ +static double _Stl_string_to_double(const char *s) { + typedef numeric_limits limits; + const int max_digits = limits::digits10 + 2; + unsigned c; + unsigned Negate, decimal_point; + char *d; + int exp; + int dpchar; + char digits[max_digits]; + + c = *s++; + + /* process sign */ + Negate = 0; + if (c == '+') { + c = *s++; + } else if (c == '-') { + Negate = 1; + c = *s++; + } + + d = digits; + dpchar = '.' - '0'; + decimal_point = 0; + exp = 0; + + for (;;) { + c -= '0'; + if (c < 10) { + if (d == digits + max_digits) { + /* ignore more than max_digits digits, but adjust exponent */ + exp += (decimal_point ^ 1); + } else { + if (c == 0 && d == digits) { + /* ignore leading zeros */ + } else { + *d++ = (char) c; + } + exp -= decimal_point; + } + } else if (c == (unsigned int) dpchar && !decimal_point) { /* INTERNATIONAL */ + decimal_point = 1; + } else { + break; + } + c = *s++; + } + + /* strtod cant return until it finds the end of the exponent */ + if (d == digits) { + return 0.0; + } + + if (c == 'e' - '0' || c == 'E' - '0') { + register unsigned negate_exp = 0; + register int e = 0; + c = *s++; + if (c == '+' || c == ' ') { + c = *s++; + } else if (c == '-') { + negate_exp = 1; + c = *s++; + } + if (c -= '0', c < 10) { + do { + e = e * 10 + (int)c; + c = *s++; + } while (c -= '0', c < 10); + + if (negate_exp) { + e = -e; + } + exp += e; + } + } + + double x; + ptrdiff_t n = d - digits; + if ((exp + n - 1) < limits::min_exponent10) { + x = 0; + } + else if ((exp + n - 1) > limits::max_exponent10) { + x = limits::infinity(); + } + else { + /* Let _Stl_atod diagnose under- and over-flows. + * If the input was == 0.0, we have already returned, + * so retval of +-Inf signals OVERFLOW, 0.0 UNDERFLOW */ + x = _Stl_atod(digits, n, exp); + } + + if (Negate) { + x = -x; + } + + return x; +} + +#endif + +#if defined (__linux__) || defined (__MINGW32__) || defined (__CYGWIN__) || \ + defined (__BORLANDC__) || defined (__DMC__) || defined (__HP_aCC) + +template +D _Stl_string_to_doubleT(const char *s) +{ + typedef numeric_limits limits; + const int max_digits = limits::digits10; /* + 2 17 */; + unsigned c; + unsigned decimal_point; + char *d; + int exp; + D x; + int dpchar; + char digits[max_digits]; + + c = *s++; + + /* process sign */ + bool Negate = false; + if (c == '+') { + c = *s++; + } else if (c == '-') { + Negate = true; + c = *s++; + } + + d = digits; + dpchar = '.' - '0'; + decimal_point = 0; + exp = 0; + + for (;;) { + c -= '0'; + if (c < 10) { + if (d == digits + max_digits) { + /* ignore more than max_digits digits, but adjust exponent */ + exp += (decimal_point ^ 1); + } else { + if (c == 0 && d == digits) { + /* ignore leading zeros */ + } else { + *d++ = (char) c; + } + exp -= decimal_point; + } + } else if (c == (unsigned int) dpchar && !decimal_point) { /* INTERNATIONAL */ + decimal_point = 1; + } else { + break; + } + c = *s++; + } + /* strtod cant return until it finds the end of the exponent */ + if (d == digits) { + return D(0.0); + } + + if (c == 'e'-'0' || c == 'E'-'0') { + bool negate_exp = false; + register int e = 0; + c = *s++; + if (c == '+' || c == ' ') { + c = *s++; + } else if (c == '-') { + negate_exp = true; + c = *s++; + } + if (c -= '0', c < 10) { + do { + e = e * 10 + (int)c; + c = *s++; + } while (c -= '0', c < 10); + + if (negate_exp) { + e = -e; + } + exp += e; + } + } + + ptrdiff_t n = d - digits; + if ((exp + n - 1) < limits::min_exponent10) { + return D(0.0); // +0.0 is the same as -0.0 + } else if ((exp + n - 1) > limits::max_exponent10 ) { + // not good, because of x = -x below; this may lead to portability problems + x = limits::infinity(); + } else { + /* let _Stl_atod diagnose under- and over-flows */ + /* if the input was == 0.0, we have already returned, + so retval of +-Inf signals OVERFLOW, 0.0 UNDERFLOW + */ + x = _Stl_atodT(digits, n, exp); + } + + return Negate ? -x : x; +} + +#endif // __linux__ + +void _STLP_CALL +__string_to_float(const __iostring& v, float& val) +{ +#if !defined (__linux__) + val = (float)_Stl_string_to_double(v.c_str()); +#else + val = (float)_Stl_string_to_doubleT(v.c_str()); +#endif +} + +void _STLP_CALL +__string_to_float(const __iostring& v, double& val) +{ +#if !defined (__linux__) + val = _Stl_string_to_double(v.c_str()); +#else + val = _Stl_string_to_doubleT(v.c_str()); +#endif +} + +#if !defined (_STLP_NO_LONG_DOUBLE) +void _STLP_CALL +__string_to_float(const __iostring& v, long double& val) { +#if !defined (__linux__) && !defined (__MINGW32__) && !defined (__CYGWIN__) && \ + !defined (__BORLANDC__) && !defined (__DMC__) && !defined (__HP_aCC) + //The following function is valid only if long double is an alias for double. + _STLP_STATIC_ASSERT( sizeof(long double) <= sizeof(double) ) + val = _Stl_string_to_double(v.c_str()); +#else + val = _Stl_string_to_doubleT(v.c_str()); +#endif +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/num_put.cpp b/sdk/tlibstdcxx/src/num_put.cpp new file mode 100644 index 0000000000..e1235617db --- /dev/null +++ b/sdk/tlibstdcxx/src/num_put.cpp @@ -0,0 +1,183 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include + +_STLP_BEGIN_NAMESPACE + +// Note that grouping[0] is the number of digits in the *rightmost* group. +// We assume, without checking, that *last is null and that there is enough +// space in the buffer to extend the number past [first, last). +template +static ptrdiff_t +__insert_grouping_aux(Char* first, Char* last, const string& grouping, + Char separator, Char Plus, Char Minus, + int basechars) { + typedef string::size_type str_size; + + if (first == last) + return 0; + + int sign = 0; + + if (*first == Plus || *first == Minus) { + sign = 1; + ++first; + } + + first += basechars; + Char* cur_group = last; // Points immediately beyond the rightmost + // digit of the current group. + int groupsize = 0; // Size of the current group (if grouping.size() == 0, size + // of group unlimited: we force condition (groupsize <= 0)) + + for ( str_size n = 0; ; ) { // Index of the current group + if ( n < grouping.size() ) { + groupsize = __STATIC_CAST(int, grouping[n++] ); + } + + if ((groupsize <= 0) || (groupsize >= cur_group - first) || (groupsize == CHAR_MAX)) { + break; + } + + // Insert a separator character just before position cur_group - groupsize + cur_group -= groupsize; + ++last; + copy_backward(cur_group, last, last + 1); + *cur_group = separator; + } + + return (last - first) + sign + basechars; +} + +//Dynamic output buffer version. +template +static void +__insert_grouping_aux( /* __basic_iostring */ Str& iostr, size_t __group_pos, + const string& grouping, + Char separator, Char Plus, Char Minus, + int basechars) { + typedef string::size_type str_size; + + if (iostr.size() < __group_pos) + return; + + int __first_pos = 0; + Char __first = *iostr.begin(); + + if (__first == Plus || __first == Minus) { + ++__first_pos; + } + + __first_pos += basechars; + + typename Str::iterator cur_group(iostr.begin() + __group_pos); // Points immediately beyond the rightmost + // digit of the current group. + int groupsize = 0; // Size of the current group (if grouping.size() == 0, size + // of group unlimited: we force condition (groupsize <= 0)) + + for ( str_size n = 0; ; ) { // Index of the current group + if ( n < grouping.size() ) { + groupsize = __STATIC_CAST( int, grouping[n++] ); + } + + if ( (groupsize <= 0) || (groupsize >= ((cur_group - iostr.begin()) - __first_pos)) || + (groupsize == CHAR_MAX)) { + break; + } + + // Insert a separator character just before position cur_group - groupsize + cur_group -= groupsize; + cur_group = iostr.insert(cur_group, separator); + } +} + +//---------------------------------------------------------------------- +// num_put + +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_lo() +{ return "0123456789abcdefx"; } + +_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_hi() +{ return "0123456789ABCDEFX"; } + +char* _STLP_CALL +__write_integer(char* buf, ios_base::fmtflags flags, long x) { + char tmp[64]; + char* bufend = tmp+64; + char* beg = __write_integer_backward(bufend, flags, x); + return copy(beg, bufend, buf); +} + +///------------------------------------- + +ptrdiff_t _STLP_CALL +__insert_grouping(char * first, char * last, const string& grouping, + char separator, char Plus, char Minus, int basechars) { + return __insert_grouping_aux(first, last, grouping, + separator, Plus, Minus, basechars); +} + +void _STLP_CALL +__insert_grouping(__iostring &str, size_t group_pos, const string& grouping, + char separator, char Plus, char Minus, int basechars) { + __insert_grouping_aux(str, group_pos, grouping, separator, Plus, Minus, basechars); +} + +#if !defined (_STLP_NO_WCHAR_T) +ptrdiff_t _STLP_CALL +__insert_grouping(wchar_t* first, wchar_t* last, const string& grouping, + wchar_t separator, wchar_t Plus, wchar_t Minus, + int basechars) { + return __insert_grouping_aux(first, last, grouping, separator, + Plus, Minus, basechars); +} + +void _STLP_CALL +__insert_grouping(__iowstring &str, size_t group_pos, const string& grouping, + wchar_t separator, wchar_t Plus, wchar_t Minus, + int basechars) { + __insert_grouping_aux(str, group_pos, grouping, separator, Plus, Minus, basechars); +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +//---------------------------------------------------------------------- +// Force instantiation of num_put<> +#if !defined(_STLP_NO_FORCE_INSTANTIATE) +template class _STLP_CLASS_DECLSPEC ostreambuf_iterator >; +// template class num_put; +template class num_put > >; +# ifndef _STLP_NO_WCHAR_T +template class ostreambuf_iterator >; +template class num_put > >; +// template class num_put; +# endif /* INSTANTIATE_WIDE_STREAMS */ +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/num_put_float.cpp b/sdk/tlibstdcxx/src/num_put_float.cpp new file mode 100644 index 0000000000..cb5c446860 --- /dev/null +++ b/sdk/tlibstdcxx/src/num_put_float.cpp @@ -0,0 +1,918 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include +#include + +#if defined (__DECCXX) +# define NDIG 400 +#else +# define NDIG 82 +#endif + +#define todigit(x) ((x)+'0') + +#if defined (_STLP_UNIX) + +# if defined (__sun) +# include +# endif + +# if defined (__sun) || defined (__digital__) || defined (__sgi) || defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR) +// DEC, SGI & Solaris need this +# include +# include +# endif + +# if defined (__QNXNTO__) || ( defined(__GNUC__) && defined(__APPLE__) ) || defined(_STLP_USE_UCLIBC) /* 0.9.26 */ || \ + defined(__FreeBSD__) +# define USE_SPRINTF_INSTEAD +# endif + +# if defined (_AIX) // JFA 3-Aug-2000 +# include +# include +# endif + +# include +#endif + +#include +#include + +#if defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__) || defined (__DJGPP) || \ + defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR) +# include +#endif + +#if defined (__MRC__) || defined (__SC__) || defined (_CRAY) //*TY 02/24/2000 - added support for MPW +# include +#endif + +#if defined (__CYGWIN__) +# include +#endif + +#if defined (__MSL__) +# include // for atoi +# include // for snprintf +# include +# include +#endif + +#if defined (__ISCPP__) +# include +#endif + +#include + +#if defined (__DMC__) +# define snprintf _snprintf +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#if defined (__MWERKS__) || defined(__BEOS__) +# define USE_SPRINTF_INSTEAD +#endif + +template +struct _Dig +{ + enum { dig = _Dig::dig + 1 }; +}; + +_STLP_TEMPLATE_NULL +struct _Dig<0> +{ + enum { dig = 0 }; +}; + +#ifdef _STLP_NO_LONG_DOUBLE +# define MAXEDIGITS int(_Dig::dig) +# define MAXFSIG DBL_DIG +# define MAXFCVT (DBL_DIG + 1) +#else +# define MAXEDIGITS int(_Dig::dig) +# define MAXFSIG LDBL_DIG +# define MAXFCVT (LDBL_DIG + 1) +#endif + +// Tests for infinity and NaN differ on different OSs. We encapsulate +// these differences here. +#if !defined (USE_SPRINTF_INSTEAD) +# if defined (__hpux) && defined (__GNUC__) +# define _STLP_USE_SIGN_HELPER +# elif defined (__DJGPP) || (defined (_STLP_USE_GLIBC) && ! defined (__MSL__)) || \ + defined (__CYGWIN__) || \ + defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || \ + defined (__HP_aCC) +static inline bool _Stl_is_nan_or_inf(double x) +# if defined (isfinite) +{ return !isfinite(x); } +# else +{ return !finite(x); } +# endif +static inline bool _Stl_is_neg_nan(double x) { return isnan(x) && ( copysign(1., x) < 0 ); } +static inline bool _Stl_is_inf(double x) { return isinf(x); } +// inline bool _Stl_is_neg_inf(double x) { return isinf(x) < 0; } +static inline bool _Stl_is_neg_inf(double x) { return isinf(x) && x < 0; } +# elif (defined (__unix) || defined (__unix__)) && \ + !defined (__APPLE__) && !defined (__DJGPP) && !defined(__osf__) && \ + !defined (_CRAY) +static inline bool _Stl_is_nan_or_inf(double x) { return IsNANorINF(x); } +static inline bool _Stl_is_inf(double x) { return IsNANorINF(x) && IsINF(x); } +static inline bool _Stl_is_neg_inf(double x) { return (IsINF(x)) && (x < 0.0); } +static inline bool _Stl_is_neg_nan(double x) { return IsNegNAN(x); } +# elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__) +static inline bool _Stl_is_nan_or_inf(double x) { return !_finite(x); } +# if !defined (__BORLANDC__) +static inline bool _Stl_is_inf(double x) { + int fclass = _fpclass(x); + return fclass == _FPCLASS_NINF || fclass == _FPCLASS_PINF; +} +static inline bool _Stl_is_neg_inf(double x) { return _fpclass(x) == _FPCLASS_NINF; } +# else +static inline bool _Stl_is_inf(double x) { return _Stl_is_nan_or_inf(x) && !_isnan(x);} +static inline bool _Stl_is_neg_inf(double x) { return _Stl_is_inf(x) && x < 0 ; } +# endif +static inline bool _Stl_is_neg_nan(double x) { return _isnan(x) && _copysign(1., x) < 0 ; } +# if defined (__BORLANDC__) +static inline bool _Stl_is_nan_or_inf(long double x) { return !_finitel(x); } +static inline bool _Stl_is_inf(long double x) { return _Stl_is_nan_or_inf(x) && !_isnanl(x);} +static inline bool _Stl_is_neg_inf(long double x) { return _Stl_is_inf(x) && x < 0 ; } +static inline bool _Stl_is_neg_nan(long double x) { return _isnanl(x) && _copysignl(1.l, x) < 0 ; } +# elif !defined (_STLP_NO_LONG_DOUBLE) +// Simply there to avoid warning long double -> double implicit conversion: +static inline bool _Stl_is_nan_or_inf(long double x) { return _Stl_is_nan_or_inf(__STATIC_CAST(double, x)); } +static inline bool _Stl_is_inf(long double x) { return _Stl_is_inf(__STATIC_CAST(double, x));} +static inline bool _Stl_is_neg_inf(long double x) { return _Stl_is_neg_inf(__STATIC_CAST(double, x)); } +static inline bool _Stl_is_neg_nan(long double x) { return _Stl_is_neg_nan(__STATIC_CAST(double, x)); } +# endif +# elif defined (__MRC__) || defined (__SC__) || defined (__DMC__) +static bool _Stl_is_nan_or_inf(double x) { return isnan(x) || !isfinite(x); } +static bool _Stl_is_inf(double x) { return !isfinite(x); } +static bool _Stl_is_neg_inf(double x) { return !isfinite(x) && signbit(x); } +static bool _Stl_is_neg_nan(double x) { return isnan(x) && signbit(x); } +# elif /* defined(__FreeBSD__) || defined(__OpenBSD__) || */ (defined(__GNUC__) && defined(__APPLE__)) +static inline bool _Stl_is_nan_or_inf(double x) { return !finite(x); } +static inline bool _Stl_is_inf(double x) { return _Stl_is_nan_or_inf(x) && ! isnan(x); } +static inline bool _Stl_is_neg_inf(double x) { return _Stl_is_inf(x) && x < 0 ; } +static inline bool _Stl_is_neg_nan(double x) { return isnan(x) && copysign(1., x) < 0 ; } +# elif defined( _AIX ) // JFA 11-Aug-2000 +static bool _Stl_is_nan_or_inf(double x) { return isnan(x) || !finite(x); } +static bool _Stl_is_inf(double x) { return !finite(x); } +// bool _Stl_is_neg_inf(double x) { return _class(x) == FP_MINUS_INF; } +static bool _Stl_is_neg_inf(double x) { return _Stl_is_inf(x) && ( copysign(1., x) < 0 ); } +static bool _Stl_is_neg_nan(double x) { return isnan(x) && ( copysign(1., x) < 0 ); } +# elif defined (__ISCPP__) +static inline bool _Stl_is_nan_or_inf (double x) { return _fp_isINF(x) || _fp_isNAN(x); } +static inline bool _Stl_is_inf (double x) { return _fp_isINF(x); } +static inline bool _Stl_is_neg_inf (double x) { return _fp_isINF(x) && x < 0; } +static inline bool _Stl_is_neg_nan (double x) { return _fp_isNAN(x) && x < 0; } +# elif defined (_CRAY) +# if defined (_CRAYIEEE) +static inline bool _Stl_is_nan_or_inf(double x) { return isnan(x) || isinf(x); } +static inline bool _Stl_is_inf(double x) { return isinf(x); } +static inline bool _Stl_is_neg_inf(double x) { return isinf(x) && signbit(x); } +static inline bool _Stl_is_neg_nan(double x) { return isnan(x) && signbit(x); } +# else +static inline bool _Stl_is_nan_or_inf(double x) { return false; } +static inline bool _Stl_is_inf(double x) { return false; } +static inline bool _Stl_is_neg_inf(double x) { return false; } +static inline bool _Stl_is_neg_nan(double x) { return false; } +# endif +# else // nothing from above +# define USE_SPRINTF_INSTEAD +# endif +#endif // !USE_SPRINTF_INSTEAD + +#if !defined (USE_SPRINTF_INSTEAD) +// Reentrant versions of floating-point conversion functions. The argument +// lists look slightly different on different operating systems, so we're +// encapsulating the differences here. + +# if defined (__CYGWIN__) || defined(__DJGPP) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf) +{ return ecvtbuf(x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf) +{ return fcvtbuf(x, n, pt, sign, buf); } +# if !defined (_STLP_NO_LONG_DOUBLE) +# if defined (__CYGWIN__) +# define _STLP_EMULATE_LONG_DOUBLE_CVT +# else +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return ecvtbuf(x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return fcvtbuf(x, n, pt, sign, buf); } +# endif +# endif +# elif defined (_STLP_USE_GLIBC) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return ecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return fcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; } +# ifndef _STLP_NO_LONG_DOUBLE +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return qecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return qfcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; } +# endif +# define _STLP_NEED_CVT_BUFFER_SIZE +# elif defined (__sun) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf) +{ return econvert(x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf) +{ return fconvert(x, n, pt, sign, buf); } +# ifndef _STLP_NO_LONG_DOUBLE +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return qeconvert(&x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return qfconvert(&x, n, pt, sign, buf); } +# endif +# elif defined (__DECCXX) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return (ecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return (fcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0); } +# ifndef _STLP_NO_LONG_DOUBLE +// fbp : no "long double" conversions ! +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return (ecvt_r((double)x, n, pt, sign, buf, bsize) == 0 ? buf : 0) ; } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize) +{ return (fcvt_r((double)x, n, pt, sign, buf, bsize) == 0 ? buf : 0); } +# endif +# define _STLP_NEED_CVT_BUFFER_SIZE +# elif defined (__hpux) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign) +{ return ecvt(x, n, pt, sign); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign) +{ return fcvt(x, n, pt, sign); } +# if !defined (_STLP_NO_LONG_DOUBLE) +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign) +{ return _ldecvt(*(long_double*)&x, n, pt, sign); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign) +{ return _ldfcvt(*(long_double*)&x, n, pt, sign); } +# endif +# define _STLP_CVT_NEED_SYNCHRONIZATION +# elif defined (__unix) && !defined (__APPLE__) && !defined (_CRAY) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf) +{ return ecvt_r(x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf) +{ return fcvt_r(x, n, pt, sign, buf); } +# if !defined (_STLP_NO_LONG_DOUBLE) +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return qecvt_r(x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return qfcvt_r(x, n, pt, sign, buf); } +# endif +# elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__) +# if defined (_STLP_USE_SAFE_STRING_FUNCTIONS) +# define _STLP_APPEND(a, b) a##b +# define _STLP_BUF_PARAMS , char* buf, size_t bsize +# define _STLP_SECURE_FUN(F, X, N, PT, SIGN) _STLP_APPEND(F, _s)(buf, bsize, X, N, PT, SIGN); return buf +# else +# define _STLP_BUF_PARAMS +# define _STLP_SECURE_FUN(F, X, N, PT, SIGN) return F(X, N, PT, SIGN) +# define _STLP_CVT_NEED_SYNCHRONIZATION +# endif +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign _STLP_BUF_PARAMS) +{ _STLP_SECURE_FUN(_ecvt, x, n, pt, sign); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign _STLP_BUF_PARAMS) +{ _STLP_SECURE_FUN(_fcvt, x, n, pt, sign); } +# if !defined (_STLP_NO_LONG_DOUBLE) +# if defined (_STLP_USE_SAFE_STRING_FUNCTIONS) +# define _STLP_PARAMS , buf, bsize +# else +# define _STLP_PARAMS +# endif +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign _STLP_BUF_PARAMS) +{ return _Stl_ecvtR(__STATIC_CAST(double, x), n, pt, sign _STLP_PARAMS); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign _STLP_BUF_PARAMS) +{ return _Stl_fcvtR(__STATIC_CAST(double, x), n, pt, sign _STLP_PARAMS); } +# undef _STLP_PARAMS +# endif +# undef _STLP_SECURE_FUN +# undef _STLP_BUF_PARAMS +# undef _STLP_APPEND +# if defined (__BORLANDC__) /* || defined (__GNUC__) MinGW do not support 'L' modifier so emulation do not work */ +# define _STLP_EMULATE_LONG_DOUBLE_CVT +# endif +# elif defined (__ISCPP__) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf) +{ return _fp_ecvt( x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf) +{ return _fp_fcvt(x, n, pt, sign, buf); } +# if !defined (_STLP_NO_LONG_DOUBLE) +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return _fp_ecvt( x, n, pt, sign, buf); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) +{ return _fp_fcvt(x, n, pt, sign, buf); } +# endif +# elif defined (_AIX) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || \ + defined (__MRC__) || defined (__SC__) || defined (_CRAY) || \ + defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR) || \ + defined (__DMC__) +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign) +{ return ecvt(x, n, pt, sign ); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign) +{ return fcvt(x, n, pt, sign); } +# if !defined (_STLP_NO_LONG_DOUBLE) +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign) +{ return ecvt(x, n, pt, sign ); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign) +{ return fcvt(x, n, pt, sign); } +# endif +# define _STLP_CVT_NEED_SYNCHRONIZATION +# else +# error Missing _Stl_ecvtR and _Stl_fcvtR implementations. +# endif + +#if defined (_STLP_CVT_NEED_SYNCHRONIZATION) +/* STLport synchronize access to *cvt functions but those methods might + * be called from outside, in this case we will still have a race condition. */ +# if defined (_STLP_THREADS) +static _STLP_STATIC_MUTEX& put_float_mutex() { + static _STLP_STATIC_MUTEX __put_float_mutex _STLP_MUTEX_INITIALIZER; + return __put_float_mutex; +} +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf) { + _STLP_auto_lock lock(put_float_mutex()); + strcpy(buf, _Stl_ecvtR(x, n, pt, sign)); return buf; +} +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf) { + _STLP_auto_lock lock(put_float_mutex()); + strcpy(buf, _Stl_fcvtR(x, n, pt, sign)); return buf; +} +# if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_EMULATE_LONG_DOUBLE_CVT) +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) { + _STLP_auto_lock lock(put_float_mutex()); + strcpy(buf, _Stl_ecvtR(x, n, pt, sign)); return buf; +} +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) { + _STLP_auto_lock lock(put_float_mutex()); + strcpy(buf, _Stl_fcvtR(x, n, pt, sign)); return buf; +} +# endif +# else +static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char*) +{ return _Stl_ecvtR(x, n, pt, sign); } +static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char*) +{ return _Stl_fcvtR(x, n, pt, sign); } +# if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_EMULATE_LONG_DOUBLE_CVT) +static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char*) +{ return _Stl_ecvtR(x, n, pt, sign); } +static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char*) +{ return _Stl_fcvtR(x, n, pt, sign); } +# endif +# endif +#endif + +# if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) && !defined (_STLP_NEED_CVT_BUFFER_SIZE) +# define _STLP_CVT_BUFFER(B) B +# else +# define _STLP_CVT_BUFFER(B) _STLP_ARRAY_AND_SIZE(B) +# endif + +# if defined (_STLP_EMULATE_LONG_DOUBLE_CVT) +static void __fill_fmtbuf(char* fmtbuf, ios_base::fmtflags flags, char long_modifier); + +// Emulation of ecvt/fcvt functions using sprintf: +static char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) { + // If long double value can be safely converted to double without losing precision + // we use the ecvt function for double: + double y = __STATIC_CAST(double, x); + if (x == y) + return _Stl_ecvtR(y, n, pt, sign, buf); + + char fmtbuf[32]; + __fill_fmtbuf(fmtbuf, 0, 'L'); + sprintf(buf, fmtbuf, n, x < 0.0l ? -x : x); + /* We are waiting for something having the form x.xxxe+yyyy */ + *pt = 0; + *sign = 0; + int i = -1; + int offset = 0; + while (buf[++i] != 0 && n != 0) { + if (buf[i] >= '0' && buf[i] <= '9') { + --n; + if (offset != 0) + buf[i - offset] = buf[i]; + } + else { + if (offset != 0) break; + ++offset; + *pt = i; + } + } + if (offset != 0) + buf[i - offset] = 0; + // Extract exponent part in point position: + int e = 0; + while (buf[++i] != 0) { + if (buf[i] >= '0' && buf[i] <= '9') { + e = e * 10 + (buf[i] - '0'); + } + } + *pt += e; + return buf; +} + +static char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) { + // If long double value can be safely converted to double without losing precision + // we use the fcvt function for double: + double y = __STATIC_CAST(double, x); + if (x == y) + return _Stl_fcvtR(y, n, pt, sign, buf); + + char fmtbuf[32]; + __fill_fmtbuf(fmtbuf, ios_base::fixed, 'L'); + sprintf(buf, fmtbuf, n, x < 0.0l ? -x : x); + *pt = 0; + *sign = 0; + int i = -1; + int offset = 0; + while (buf[++i] != 0 && (offset == 0 || n != 0)) { + if (buf[i] >= '0' && buf[i] <= '9') { + if (offset != 0) { + --n; + buf[i - offset] = buf[i]; + } + } + else { + ++offset; + *pt = i; + } + } + if (offset != 0) + buf[i - offset] = 0; + else + *pt = i; + return buf; +} +#endif + +//---------------------------------------------------------------------- +// num_put + +// __format_float formats a mantissa and exponent as returned by +// one of the conversion functions (ecvt_r, fcvt_r, qecvt_r, qfcvt_r) +// according to the specified precision and format flags. This is +// based on doprnt but is much simpler since it is concerned only +// with floating point input and does not consider all formats. It +// also does not deal with blank padding, which is handled by +// __copy_float_and_fill. + +static size_t __format_float_scientific( __iostring& buf, const char *bp, + int decpt, int sign, bool is_zero, + ios_base::fmtflags flags, + int precision) { + // sign if required + if (sign) + buf += '-'; + else if (flags & ios_base::showpos) + buf += '+'; + + // first digit of mantissa + buf += *bp++; + + // start of grouping position, grouping won't occur in scientific notation + // as it is impossible to have something like 1234.0e04 but we return a correct + // group position for coherency with __format_float_fixed. + size_t __group_pos = buf.size(); + + // decimal point if required + if (precision != 0 || flags & ios_base::showpoint) { + buf += '.'; + } + + // rest of mantissa + while (*bp != 0 && precision--) + buf += *bp++; + + // trailing 0 if needed + if (precision > 0) + buf.append(precision, '0'); + + // exponent size = number of digits + exponent sign + exponent symbol + trailing zero + char expbuf[MAXEDIGITS + 3]; + //We start filling at the buffer end + char *suffix = expbuf + MAXEDIGITS + 2; + *suffix = 0; + if (!is_zero) { + int nn = decpt - 1; + if (nn < 0) + nn = -nn; + for (; nn > 9; nn /= 10) + *--suffix = (char) todigit(nn % 10); + *--suffix = (char) todigit(nn); + } + + // prepend leading zeros to exponent + // C89 Standard says that it should be at least 2 digits, C99 Standard says that + // we stop prepend zeros if more than 3 digits. To repect both STLport prepend zeros + // until it is 2 digits. + while (suffix > &expbuf[MAXEDIGITS]) + *--suffix = '0'; + + // put in the exponent sign + *--suffix = (char) ((decpt > 0 || is_zero ) ? '+' : '-'); + + // put in the e + *--suffix = flags & ios_base::uppercase ? 'E' : 'e'; + + // copy the suffix + buf += suffix; + return __group_pos; +} + +static size_t __format_float_fixed( __iostring &buf, const char *bp, + int decpt, int sign, + ios_base::fmtflags flags, + int precision) { + if ( sign && (decpt > -precision) && (*bp != 0) ) + buf += '-'; + else if ( flags & ios_base::showpos ) + buf += '+'; + + // digits before decimal point + int nnn = decpt; + do { + buf += (nnn <= 0 || *bp == 0) ? '0' : *bp++; + } while ( --nnn > 0 ); + + // start of grouping position + size_t __group_pos = buf.size(); + + // decimal point if needed + if ( flags & ios_base::showpoint || precision > 0 ) { + buf += '.'; + } + + // digits after decimal point if any + while ( *bp != 0 && --precision >= 0 ) { + buf += (++decpt <= 0) ? '0' : *bp++; + } + + // trailing zeros if needed + if (precision > 0) + buf.append(precision, '0'); + + return __group_pos; +} + +#if defined (_STLP_USE_SIGN_HELPER) +template +struct float_sign_helper { + float_sign_helper(_FloatT __x) + { _M_number._num = __x; } + + bool is_negative() const { + const unsigned short sign_mask(1 << (sizeof(unsigned short) * CHAR_BIT - 1)); + return (get_sign_word() & sign_mask) != 0; + } +private: + union { + unsigned short _Words[8]; + _FloatT _num; + } _M_number; + + unsigned short get_word_higher() const _STLP_NOTHROW + { return _M_number._Words[0]; } + unsigned short get_word_lower() const _STLP_NOTHROW + { return _M_number._Words[(sizeof(_FloatT) >= 12 ? 10 : sizeof(_FloatT)) / sizeof(unsigned short) - 1]; } + unsigned short get_sign_word() const _STLP_NOTHROW +# if defined (_STLP_BIG_ENDIAN) + { return get_word_higher(); } +# else /* _STLP_LITTLE_ENDIAN */ + { return get_word_lower(); } +# endif +}; +#endif + +template +static size_t __format_nan_or_inf(__iostring& buf, _FloatT x, ios_base::fmtflags flags) { + static const char* inf[2] = { "inf", "Inf" }; + static const char* nan[2] = { "nan", "NaN" }; + const char** inf_or_nan; +#if !defined (_STLP_USE_SIGN_HELPER) + if (_Stl_is_inf(x)) { // Infinity + inf_or_nan = inf; + if (_Stl_is_neg_inf(x)) + buf += '-'; + else if (flags & ios_base::showpos) + buf += '+'; + } else { // NaN + inf_or_nan = nan; + if (_Stl_is_neg_nan(x)) + buf += '-'; + else if (flags & ios_base::showpos) + buf += '+'; + } +#else + typedef numeric_limits<_FloatT> limits; + if (x == limits::infinity() || x == -limits::infinity()) { + inf_or_nan = inf; + } else { // NaN + inf_or_nan = nan; + } + float_sign_helper<_FloatT> helper(x); + if (helper.is_negative()) + buf += '-'; + else if (flags & ios_base::showpos) + buf += '+'; +#endif + size_t ret = buf.size(); + buf += inf_or_nan[flags & ios_base::uppercase ? 1 : 0]; + return ret; +} + +static inline size_t __format_float(__iostring &buf, const char * bp, + int decpt, int sign, bool is_zero, + ios_base::fmtflags flags, + int precision) { + size_t __group_pos = 0; + switch (flags & ios_base::floatfield) { + case ios_base::scientific: + __group_pos = __format_float_scientific( buf, bp, decpt, sign, is_zero, + flags, precision); + break; + case ios_base::fixed: + __group_pos = __format_float_fixed( buf, bp, decpt, sign, + flags, precision); + break; + default: // g format + // establish default precision + if (flags & ios_base::showpoint || precision > 0) { + if (precision == 0) precision = 1; + } else + precision = 6; + + // reset exponent if value is zero + if (is_zero) + decpt = 1; + + int kk = precision; + if (!(flags & ios_base::showpoint)) { + size_t n = strlen(bp); + if (n < (size_t)kk) + kk = (int)n; + while (kk >= 1 && bp[kk-1] == '0') + --kk; + } + + if (decpt < -3 || decpt > precision) { + precision = kk - 1; + __group_pos = __format_float_scientific( buf, bp, decpt, sign, is_zero, + flags, precision); + } else { + precision = kk - decpt; + __group_pos = __format_float_fixed( buf, bp, decpt, sign, + flags, precision); + } + break; + } /* switch */ + return __group_pos; +} + +#endif + +#if defined (USE_SPRINTF_INSTEAD) || defined (_STLP_EMULATE_LONG_DOUBLE_CVT) +struct GroupPos { + bool operator () (char __c) const { + return __c == '.' || + __c == 'e' || __c == 'E'; + } +}; + +// Creates a format string for sprintf() +static void __fill_fmtbuf(char* fmtbuf, ios_base::fmtflags flags, char long_modifier) { + fmtbuf[0] = '%'; + int i = 1; + + if (flags & ios_base::showpos) + fmtbuf[i++] = '+'; + + if (flags & ios_base::showpoint) + fmtbuf[i++] = '#'; + + fmtbuf[i++] = '.'; + fmtbuf[i++] = '*'; + + if (long_modifier) + fmtbuf[i++] = long_modifier; + + switch (flags & ios_base::floatfield) + { + case ios_base::scientific: + fmtbuf[i++] = (flags & ios_base::uppercase) ? 'E' : 'e'; + break; + case ios_base::fixed: +# if defined (__FreeBSD__) + fmtbuf[i++] = 'f'; +# else + fmtbuf[i++] = (flags & ios_base::uppercase) ? 'F' : 'f'; +# endif + break; + default: + fmtbuf[i++] = (flags & ios_base::uppercase) ? 'G' : 'g'; + break; + } + + fmtbuf[i] = 0; +} + +#endif /* USE_SPRINTF_INSTEAD */ + +template +static size_t __write_floatT(__iostring &buf, ios_base::fmtflags flags, int precision, + _FloatT x +#if defined (USE_SPRINTF_INSTEAD) + , char modifier) { + /* In theory, if we want 'arbitrary' precision, we should use 'arbitrary' + * buffer size below, but really we limited by exponent part in double. + * - ptr + */ + typedef numeric_limits<_FloatT> limits; + char static_buf[limits::max_exponent10 + 6]; // 6: -xxx.yyyE-zzz (sign, dot, E, exp sign, \0) + char fmtbuf[32]; + __fill_fmtbuf(fmtbuf, flags, modifier); + snprintf(_STLP_ARRAY_AND_SIZE(static_buf), fmtbuf, precision, x); + buf = static_buf; + return find_if(buf.begin(), buf.end(), GroupPos()) - buf.begin(); +#else + ) { + typedef numeric_limits<_FloatT> limits; + //If numeric_limits support is correct we use the exposed values to detect NaN and infinity: + if (limits::has_infinity && limits::has_quiet_NaN) { + if (!(x == x) || // NaN check + (x == limits::infinity() || x == -limits::infinity())) { + return __format_nan_or_inf(buf, x, flags); + } + } + // numeric_limits support is not good enough, we rely on platform dependent function + // _Stl_is_nan_or_inf that do not support long double. + else if (_Stl_is_nan_or_inf(x)) { + return __format_nan_or_inf(buf, x, flags); + } +# if defined (__MINGW32__) + //For the moment MinGW is limited to display at most numeric_limits::max() + if (x > numeric_limits::max() || + x < -numeric_limits::max()) { + return __format_nan_or_inf(buf, x, flags); + } +# endif + + /* Buffer size is max number of digits which is the addition of: + * - max_exponent10: max number of digits in fixed mode + * - digits10 + 2: max number of significant digits + * - trailing '\0' + */ + char cvtbuf[limits::max_exponent10 + limits::digits10 + 2 + 1]; + char *bp; + int decpt, sign; + + switch (flags & ios_base::floatfield) { + case ios_base::fixed: + { + /* Here, number of digits represents digits _after_ decimal point. + * In order to limit static buffer size we have to give 2 different values depending on x value. + * For small values (abs(x) < 1) we need as many digits as requested by precision limited by the maximum number of digits + * which is min_exponent10 + digits10 + 2 + * For bigger values we won't have more than limits::digits10 + 2 digits after decimal point. */ + int digits10 = (x > -1.0 && x < 1.0 ? -limits::min_exponent10 + limits::digits10 + 2 + : limits::digits10 + 2); + bp = _Stl_fcvtR(x, (min) (precision, digits10), &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf) ); + } + break; + case ios_base::scientific: + default: + /* Here, number of digits is total number of digits which is limited to digits10 + 2. */ + { + int digits10 = limits::digits10 + 2; + bp = _Stl_ecvtR(x, (min) (precision, digits10), &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf) ); + } + break; + } + return __format_float(buf, bp, decpt, sign, x == 0.0, flags, precision); +#endif +} + +size_t _STLP_CALL +__write_float(__iostring &buf, ios_base::fmtflags flags, int precision, + double x) { + return __write_floatT(buf, flags, precision, x +#if defined (USE_SPRINTF_INSTEAD) + , 0 +#endif + ); +} + +#if !defined (_STLP_NO_LONG_DOUBLE) +size_t _STLP_CALL +__write_float(__iostring &buf, ios_base::fmtflags flags, int precision, + long double x) { + return __write_floatT(buf, flags, precision, x +#if defined (USE_SPRINTF_INSTEAD) + , 'L' +#endif + ); +} +#endif + +void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONGEST_FLOAT_TYPE __x) { + typedef numeric_limits<_STLP_LONGEST_FLOAT_TYPE> limits; +#if defined (USE_SPRINTF_INSTEAD) + char cvtbuf[limits::max_exponent10 + 6]; +# if !defined (_STLP_NO_LONG_DOUBLE) + snprintf(_STLP_ARRAY_AND_SIZE(cvtbuf), "%Lf", __x); // check for 1234.56! +# else + snprintf(_STLP_ARRAY_AND_SIZE(cvtbuf), "%f", __x); // check for 1234.56! +# endif + char *p = strchr( cvtbuf, '.' ); + if ( p == 0 ) { + out.append( cvtbuf ); + } else { + out.append( cvtbuf, p ); + } +#else + char cvtbuf[limits::max_exponent10 + 1]; + char * bp; + int decpt, sign; + bp = _Stl_fcvtR(__x, 0, &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf)); + + if (sign) { + out += '-'; + } + out.append(bp, bp + decpt); +#endif +} + + +#if !defined (_STLP_NO_WCHAR_T) +void _STLP_CALL __convert_float_buffer( __iostring const& str, __iowstring &out, + const ctype& ct, wchar_t dot, bool __check_dot) { + string::const_iterator str_ite(str.begin()), str_end(str.end()); + + //First loop, check the dot char + if (__check_dot) { + while (str_ite != str_end) { + if (*str_ite != '.') { + out += ct.widen(*str_ite++); + } else { + out += dot; + break; + } + } + } else { + if (str_ite != str_end) { + out += ct.widen(*str_ite); + } + } + + if (str_ite != str_end) { + //Second loop, dot has been found, no check anymore + while (++str_ite != str_end) { + out += ct.widen(*str_ite); + } + } +} + +#endif + +void _STLP_CALL +__adjust_float_buffer(__iostring &str, char dot) { + if ('.' != dot) { + size_t __dot_pos = str.find('.'); + if (__dot_pos != string::npos) { + str[__dot_pos] = dot; + } + } +} + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/numpunct.cpp b/sdk/tlibstdcxx/src/numpunct.cpp new file mode 100644 index 0000000000..cbadc7ab08 --- /dev/null +++ b/sdk/tlibstdcxx/src/numpunct.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// numpunct +char numpunct::do_decimal_point() const {return '.';} +char numpunct::do_thousands_sep() const { return ','; } +string numpunct::do_grouping() const { return string();} +string numpunct::do_truename() const { return "true";} +string numpunct::do_falsename() const { return "false"; } +numpunct::~numpunct() {} + +#if !defined (_STLP_NO_WCHAR_T) +wchar_t numpunct::do_decimal_point() const { return L'.'; } +wchar_t numpunct::do_thousands_sep() const { return L','; } +string numpunct::do_grouping() const { return string(); } +wstring numpunct::do_truename() const { return L"true"; } +wstring numpunct::do_falsename() const { return L"false"; } +numpunct::~numpunct() {} +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/ostream.cpp b/sdk/tlibstdcxx/src/ostream.cpp new file mode 100644 index 0000000000..96d4737409 --- /dev/null +++ b/sdk/tlibstdcxx/src/ostream.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include + +_STLP_BEGIN_NAMESPACE + +#if !defined(_STLP_NO_FORCE_INSTANTIATE) + +// instantiations +template class _STLP_CLASS_DECLSPEC basic_ostream >; + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +template class _STLP_CLASS_DECLSPEC _Osentry >; +# endif + +#ifndef _STLP_NO_WCHAR_T + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +template class _STLP_CLASS_DECLSPEC _Osentry >; +# endif +template class _STLP_CLASS_DECLSPEC basic_ostream >; +#endif + +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/sparc_atomic.s b/sdk/tlibstdcxx/src/sparc_atomic.s new file mode 100644 index 0000000000..67e41d6283 --- /dev/null +++ b/sdk/tlibstdcxx/src/sparc_atomic.s @@ -0,0 +1,68 @@ + .section ".text",#alloc,#execinstr + .align 8 + .skip 16 + + + /* + ** int _STLP_atomic_exchange (void *pvalue, int value) + */ + + .type _STLP_atomic_exchange,#function + .global _STLP_atomic_exchange + .align 8 + +_STLP_atomic_exchange: +0: + ld [%o0], %o2 ! Set the current value + mov %o1, %o3 ! Set the new value +! swap [%o0], %o3 ! Do the compare and swap + cas [%o0], %o2, %o3 + cmp %o2, %o3 ! Check whether successful + bne 0b ! Retry upon failure + stbar + mov %o2, %o0 ! Set the new value + retl ! return + nop + .size _STLP_atomic_exchange,(.-_STLP_atomic_exchange) + + /* int _STLP_atomic_increment (void *pvalue) */ + + .type _STLP_atomic_increment,#function + .global _STLP_atomic_increment + .align 8 +_STLP_atomic_increment: +1: + ld [%o0], %o2 ! set the current + add %o2, 0x1, %o3 ! Increment and store current +! swap [%o0], %o3 ! Do the compare and swap + cas [%o0], %o2, %o3 + cmp %o3, %o2 ! Check whether successful + bne 1b ! Retry if we failed. + membar #LoadLoad | #LoadStore ! Ensure the cas finishes before + ! returning + nop + retl ! return + nop + + .size _STLP_atomic_increment,(.-_STLP_atomic_increment) + + + /* int _STLP_atomic_decrement (void *pvalue) */ + .type _STLP_atomic_decrement,#function + .global _STLP_atomic_decrement + .align 8 + +_STLP_atomic_decrement: +2: + ld [%o0], %o2 ! set the current + sub %o2, 0x1, %o3 ! decrement and store current +! swap [%o0], %o3 ! Do the compare and swap + cas [%o0], %o2, %o3 + cmp %o3, %o2 ! Check whether successful + bne 2b ! Retry if we failed. + membar #LoadLoad | #LoadStore ! Ensure the cas finishes before + nop + ! returning + retl ! return + nop + .size _STLP_atomic_decrement,(.-_STLP_atomic_decrement) diff --git a/sdk/tlibstdcxx/src/sparc_atomic64.s b/sdk/tlibstdcxx/src/sparc_atomic64.s new file mode 100644 index 0000000000..ff2c42a82c --- /dev/null +++ b/sdk/tlibstdcxx/src/sparc_atomic64.s @@ -0,0 +1,65 @@ + .section ".text",#alloc,#execinstr + .align 8 + .skip 16 + +! int _STLP_atomic_exchange (void *pvalue, int value) +! + + .type _STLP_atomic_exchange,#function + .global _STLP_atomic_exchange + .align 8 + +_STLP_atomic_exchange: +1: + ldx [%o0], %o2 ! Set the current value + mov %o1, %o3 ! Set the new value + casx [%o0], %o2, %o3 ! Do the compare and swap + cmp %o2, %o3 ! Check whether successful + bne 1b ! Retry upon failure + membar #LoadLoad | #LoadStore ! Ensure the cas finishes before + ! returning + retl ! return + mov %o2, %o0 ! Set the new value + .size _STLP_atomic_exchange,(.-_STLP_atomic_exchange) + + +! int _STLP_atomic_increment (void *pvalue) + + .type _STLP_atomic_increment,#function + .global _STLP_atomic_increment + .align 8 +_STLP_atomic_increment: +0: + ldx [%o0], %o2 ! set the current + addx %o2, 0x1, %o3 ! Increment and store current + casx [%o0], %o2, %o3 ! Do the compare and swap + cmp %o3, %o2 ! Check whether successful + bne 0b + membar #LoadLoad | #LoadStore ! Ensure the cas finishes before + ! returning + retl ! return + mov %o1, %o0 ! Set the return value + + .size _STLP_atomic_increment,(.-_STLP_atomic_increment) + + +! /* int _STLP_atomic_decrement (void *pvalue) */ + .type _STLP_atomic_decrement,#function + .global _STLP_atomic_decrement + .align 8 + +_STLP_atomic_decrement: +0: + ldx [%o0], %o2 ! set the current + subx %o2, 0x1, %o3 ! decrement and store current + casx [%o0], %o2, %o3 ! Do the compare and swap + cmp %o3, %o2 ! Check whether successful + bne 0b + membar #LoadLoad | #LoadStore ! Ensure the cas finishes before + ! returning + retl ! return + nop + .size _STLP_atomic_decrement,(.-_STLP_atomic_decrement) + + + diff --git a/sdk/tlibstdcxx/src/sstream.cpp b/sdk/tlibstdcxx/src/sstream.cpp new file mode 100644 index 0000000000..2d1d652754 --- /dev/null +++ b/sdk/tlibstdcxx/src/sstream.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#include "stlport_prefix.h" + +#include + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_NO_FORCE_INSTANTIATE) + +// Force instantiation of stringstream classes. +template class _STLP_CLASS_DECLSPEC basic_stringbuf, allocator >; +template class _STLP_CLASS_DECLSPEC basic_ostringstream, allocator >; +template class _STLP_CLASS_DECLSPEC basic_istringstream, allocator >; +template class _STLP_CLASS_DECLSPEC basic_stringstream, allocator >; + +# if !defined (_STLP_NO_WCHAR_T) +template class _STLP_CLASS_DECLSPEC basic_stringbuf, allocator >; +template class _STLP_CLASS_DECLSPEC basic_ostringstream, allocator >; +template class _STLP_CLASS_DECLSPEC basic_istringstream, allocator >; +template class _STLP_CLASS_DECLSPEC basic_stringstream, allocator >; +# endif + +#endif + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/stdio_streambuf.cpp b/sdk/tlibstdcxx/src/stdio_streambuf.cpp new file mode 100644 index 0000000000..45aad790a6 --- /dev/null +++ b/sdk/tlibstdcxx/src/stdio_streambuf.cpp @@ -0,0 +1,239 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" +#include "stdio_streambuf.h" + +#ifdef _STLP_UNIX +# include +# include +#endif + +#include +#include + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Compare with streamoff definition in stl/char_traits.h! + +#if defined (_STLP_USE_DEFAULT_FILE_OFFSET) || \ + (!defined(_LARGEFILE_SOURCE) && !defined(_LARGEFILE64_SOURCE)) +# if !defined (_STLP_MSVC) || (_STLP_MSVC < 1400) || defined(_STLP_WCE) +# define FSEEK fseek +# else +# define FSEEK _fseeki64 +# endif +# define FSETPOS fsetpos +# define FGETPOS fgetpos +# define FPOS_T fpos_t +#else +# define FSEEK fseeko64 +# define FSETPOS fsetpos64 +# define FGETPOS fgetpos64 +# define FPOS_T fpos64_t +#endif + +//---------------------------------------------------------------------- +// Class stdio_streambuf_base + +stdio_streambuf_base::stdio_streambuf_base(FILE* file) + : /* _STLP_STD::FILE_basic_streambuf(file, 0), */ + _M_file(file) +{} + +stdio_streambuf_base::~stdio_streambuf_base() { + _STLP_VENDOR_CSTD::fflush(_M_file); +} + +_STLP_STD::streambuf* stdio_streambuf_base::setbuf(char* s, streamsize n) { +#ifdef _STLP_WCE + // no buffering in windows ce .NET +#else + size_t __n_size_t = (sizeof(streamsize) > sizeof(size_t)) ? __STATIC_CAST(size_t, (min)(__STATIC_CAST(streamsize, (numeric_limits::max)()), n)) + : __STATIC_CAST(size_t, n); + _STLP_VENDOR_CSTD::setvbuf(_M_file, s, (s == 0 && n == 0) ? _IONBF : _IOFBF, __n_size_t); +#endif + return this; +} + +stdio_streambuf_base::pos_type +stdio_streambuf_base::seekoff(off_type off, ios_base::seekdir dir, + ios_base::openmode /* mode */) { + int whence; + switch (dir) { + case ios_base::beg: + whence = SEEK_SET; + break; + case ios_base::cur: + whence = SEEK_CUR; + break; + case ios_base::end: + whence = SEEK_END; + break; + default: + return pos_type(-1); + } + + if (off <= numeric_limits::max() && FSEEK(_M_file, off, whence) == 0) { + FPOS_T pos; + FGETPOS(_M_file, &pos); + // added 21 june 00 mdb,rjf,wjs: glibc 2.2 changed fpos_t to be a struct instead + // of a primitive type +#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)))) + return pos_type((streamoff)pos.__pos); +#elif defined (__ISCPP__) || defined (__MVS__) || defined (__OS400__) + return pos_type(pos.__fpos_elem[ 0 ]); +#elif defined (__EMX__) + return pos_type((streamoff)pos._pos); +#else + return pos_type(pos); +#endif + } + else + return pos_type(-1); +} + + +stdio_streambuf_base::pos_type +stdio_streambuf_base::seekpos(pos_type pos, ios_base::openmode /* mode */) { + // added 21 june 00 mdb,rjf,wjs: glibc 2.2 changed fpos_t to be a struct instead + // of a primitive type +#if (defined(__GLIBC__) && ( (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2) ) ) ) + FPOS_T p; + p.__pos = pos; +# ifdef _STLP_USE_UCLIBC +# ifdef __STDIO_MBSTATE + memset( &(p.__mbstate), 0, sizeof(p.__mbstate) ); +# endif +# ifdef __STDIO_WIDE + p.mblen_pending = 0; +# endif +# else + memset( &(p.__state), 0, sizeof(p.__state) ); +# endif +#elif defined (__MVS__) || defined (__OS400__) + FPOS_T p; + p.__fpos_elem[0] = pos; +#elif defined (__EMX__) + FPOS_T p; + p._pos = pos; + memset( &(p._mbstate), 0, sizeof(p._mbstate) ); +#else + FPOS_T p(pos); +#endif + + return FSETPOS(_M_file, &p) == 0 ? pos : pos_type(-1); +} + +int stdio_streambuf_base::sync() { + return _STLP_VENDOR_CSTD::fflush(_M_file) == 0 ? 0 : -1; +} + +//---------------------------------------------------------------------- +// Class stdio_istreambuf + +stdio_istreambuf::~stdio_istreambuf() {} + +streamsize stdio_istreambuf::showmanyc() +{ return 0; } + +stdio_istreambuf::int_type stdio_istreambuf::underflow() +{ +#ifdef _STLP_WCE + int c = fgetc(_M_file); +#else + int c = getc(_M_file); +#endif + if (c != EOF) { + _STLP_VENDOR_CSTD::ungetc(c, _M_file); + return c; + } + else + return traits_type::eof(); +} + +stdio_istreambuf::int_type stdio_istreambuf::uflow() { +#ifdef _STLP_WCE + int c = fgetc(_M_file); +#else + int c = getc(_M_file); +#endif + return c != EOF ? c : traits_type::eof(); +} + +stdio_istreambuf::int_type stdio_istreambuf::pbackfail(int_type c) { + if (c != traits_type::eof()) { + int result = _STLP_VENDOR_CSTD::ungetc(c, _M_file); + return result != EOF ? result : traits_type::eof(); + } + else{ + if (this->eback() < this->gptr()) { + this->gbump(-1); + return traits_type::not_eof(c); + } + else + return traits_type::eof(); + } +} + +//---------------------------------------------------------------------- +// Class stdio_ostreambuf + +stdio_ostreambuf::~stdio_ostreambuf() {} + +streamsize stdio_ostreambuf::showmanyc() +{ return -1; } + +stdio_ostreambuf::int_type stdio_ostreambuf::overflow(int_type c) { + // Write the existing buffer, without writing any additional character. + if (c == traits_type::eof()) { + // Do we have a buffer to write? + ptrdiff_t unwritten = this->pptr() - this->pbase(); + if (unwritten != 0) { + _STLP_VENDOR_CSTD::fflush(_M_file); + // Test if the write succeeded. + if (this->pptr() - this->pbase() < unwritten) + return traits_type::not_eof(c); + else + return traits_type::eof(); + } + + // We always succeed if we don't have to do anything. + else + return traits_type::not_eof(c); + } + + // Write the character c, and whatever else might be in the buffer. + else { +#ifdef _STLP_WCE + int result = fputc(c, _M_file); +#else + int result = putc(c, _M_file); +#endif + return result != EOF ? result : traits_type::eof(); + } +} + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/src/stdio_streambuf.h b/sdk/tlibstdcxx/src/stdio_streambuf.h new file mode 100644 index 0000000000..33747b5136 --- /dev/null +++ b/sdk/tlibstdcxx/src/stdio_streambuf.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +// This header defines two streambufs: +// stdio_istreambuf, a read-only streambuf synchronized with a C stdio +// FILE object +// stdio_ostreambuf, a write-only streambuf synchronized with a C stdio +// FILE object. +// Note that neither stdio_istreambuf nor stdio_ostreambuf is a template; +// both classes are derived from basic_streambuf >. + +// Note: the imbue() member function is a no-op. In particular, these +// classes assume that codecvt is always an identity +// transformation. This is true of the default locale, and of all locales +// defined for the C I/O library. If you need to use a locale where +// the codecvt facet performs a nontrivial +// conversion, then you should use basic_filebuf<> instead of stdio_istreambuf +// or stdio_ostreambuf. (If you don't understand what any of this means, +// then it's not a feature you need to worry about. Locales where +// codecvt does something nontrivial are a rare +// corner case.) + + +#ifndef _STLP_STDIO_STREAMBUF +#define _STLP_STDIO_STREAMBUF + +#include +#include // For FILE. + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Base class for features common to stdio_istreambuf and stdio_ostreambuf +class stdio_streambuf_base : + public basic_streambuf > /* FILE_basic_streambuf */ { +public: // Constructor, destructor. + // The argument may not be null. It must be an open file pointer. + stdio_streambuf_base(FILE*); + + // The destructor flushes the stream, but does not close it. + ~stdio_streambuf_base(); + +protected: // Virtual functions from basic_streambuf. + streambuf* setbuf(char*, streamsize); + + pos_type seekoff(off_type, ios_base::seekdir, + ios_base::openmode + = ios_base::in | ios_base::out); + pos_type seekpos(pos_type, + ios_base::openmode + = ios_base::in | ios_base::out); + int sync(); + +protected: + FILE* _M_file; +}; + +class stdio_istreambuf : public stdio_streambuf_base { +public: // Constructor, destructor. + stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {} + ~stdio_istreambuf(); + +protected: // Virtual functions from basic_streambuf. + streamsize showmanyc(); + int_type underflow(); + int_type uflow(); + virtual int_type pbackfail(int_type c = traits_type::eof()); +}; + +class stdio_ostreambuf : public stdio_streambuf_base { +public: // Constructor, destructor. + stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {} + ~stdio_ostreambuf(); + +protected: // Virtual functions from basic_streambuf. + streamsize showmanyc(); + int_type overflow(int_type c = traits_type::eof()); +}; + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#endif /* _STLP_STDIO_STREAMBUF */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/stlport_prefix.h b/sdk/tlibstdcxx/src/stlport_prefix.h new file mode 100644 index 0000000000..e621603bde --- /dev/null +++ b/sdk/tlibstdcxx/src/stlport_prefix.h @@ -0,0 +1,48 @@ +#ifndef STLPORT_PREFIX_H +#define STLPORT_PREFIX_H + +#define __BUILDING_STLPORT 1 + +#if defined (_WIN32) || defined (WIN32) +# ifdef __cplusplus +# define WIN32_LEAN_AND_MEAN +# define NOSERVICE +# endif +#endif + +#undef _STLP_NO_FORCE_INSTANTIATE + +/* Please add extra compilation switches for particular compilers here */ + +#if defined (_MSC_VER) && !defined (__COMO__) && !defined (__MWERKS__) +# include "warning_disable.h" +#endif + +#include + +#if defined (_STLP_USE_TEMPLATE_EXPORT) && defined (_STLP_USE_DECLSPEC) && !defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) +# define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION +#endif + +#ifdef __cplusplus + +#if !defined (_STLP_SGX_CONFIG) + +# include +# if defined (_STLP_USE_NAMESPACES) && !defined (_STLP_VENDOR_GLOBAL_CSTD) +using _STLP_VENDOR_CSTD::time_t; +# endif + +#endif /* !_STLP_SGX_CONFIG */ + +# if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +# define _STLP_OPERATOR_SPEC _STLP_DECLSPEC +# else +# define _STLP_OPERATOR_SPEC _STLP_TEMPLATE_NULL _STLP_DECLSPEC +# endif + +#endif /* __cplusplus */ + + +#endif /* PREFIX */ + diff --git a/sdk/tlibstdcxx/src/string.cpp b/sdk/tlibstdcxx/src/string.cpp new file mode 100644 index 0000000000..052c2a3c14 --- /dev/null +++ b/sdk/tlibstdcxx/src/string.cpp @@ -0,0 +1,94 @@ +#include "stlport_prefix.h" + +#include +#include /* include __Named_exception imple. in static lib */ + +_STLP_BEGIN_NAMESPACE + +#if defined(_STLP_USE_WIDE_INTERFACE) +_STLP_MOVE_TO_PRIV_NAMESPACE + +wstring __ASCIIToWide(const char *ascii) { + size_t size = strlen(ascii); + wchar_t* buff = new wchar_t[size+1]; + mbstowcs(buff, ascii, size); + buff[size] = 0x00; + wstring ret(buff); + delete[] buff; + return ret; +} +string __WideToASCII(const wchar_t *wide) { + size_t size = wcslen(wide); + char* buff = new char[size+1]; + wcstombs(buff, wide, size); + buff[size] = 0; + string ret(buff); + delete[] buff; + return ret; +} +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#if !defined (_STLP_NO_FORCE_INSTANTIATE) + +template class _STLP_CLASS_DECLSPEC allocator; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy >; +template class _STLP_CLASS_DECLSPEC _String_base >; + +# if defined (_STLP_DEBUG) && !defined (__SUNPRO_CC) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define basic_string _STLP_NON_DBG_NAME(str) + +template class _STLP_CLASS_DECLSPEC basic_string, allocator >; +template class _STLP_CLASS_DECLSPEC __construct_checker, allocator > >; + +# undef basic_string +# endif + +# if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define basic_string _STLP_NO_MEM_T_NAME(str) +# else +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +template class _STLP_CLASS_DECLSPEC basic_string, allocator >; + +# if defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +# undef basic_string +# endif + +# if !defined (_STLP_NO_WCHAR_T) +template class _STLP_CLASS_DECLSPEC allocator; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template class _STLP_CLASS_DECLSPEC _String_base >; + +# if defined (_STLP_DEBUG) && !defined (__SUNPRO_CC) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define basic_string _STLP_NON_DBG_NAME(str) + +template class _STLP_CLASS_DECLSPEC basic_string, allocator >; +template class _STLP_CLASS_DECLSPEC __construct_checker, allocator > >; + +# undef basic_string +# endif + +# if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define basic_string _STLP_NO_MEM_T_NAME(str) +# else +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +template class _STLP_CLASS_DECLSPEC basic_string, allocator >; + +# if defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +# undef basic_string +# endif +# endif +#endif + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/strstream.cpp b/sdk/tlibstdcxx/src/strstream.cpp new file mode 100644 index 0000000000..740e01ea7b --- /dev/null +++ b/sdk/tlibstdcxx/src/strstream.cpp @@ -0,0 +1,391 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +// Implementation of the classes in header . +// WARNING: The classes defined in are DEPRECATED. This +// header is defined in section D.7.1 of the C++ standard, and it +// MAY BE REMOVED in a future standard revision. You should use the +// header instead. + +#include "stlport_prefix.h" + +#include +#include +#include + +_STLP_BEGIN_NAMESPACE + +// strstreambuf constructor, destructor. +strstreambuf::strstreambuf(streamsize initial_capacity) + : _M_alloc_fun(0), _M_free_fun(0), + _M_dynamic(true), _M_frozen(false), _M_constant(false) { + size_t n = (sizeof(streamsize) > sizeof(size_t)) ? __STATIC_CAST(size_t, (min)(__STATIC_CAST(streamsize, (numeric_limits::max)()), + (max)(initial_capacity, streamsize(16)))) + : __STATIC_CAST(size_t, (max)(initial_capacity, streamsize(16))); + + char* buf = _M_alloc(n); + if (buf) { + setp(buf, buf + n); + setg(buf, buf, buf); + } +} + +strstreambuf::strstreambuf(__alloc_fn alloc_f, __free_fn free_f) + : _M_alloc_fun(alloc_f), _M_free_fun(free_f), + _M_dynamic(true), _M_frozen(false), _M_constant(false) { + size_t n = 16; + + char* buf = _M_alloc(n); + if (buf) { + setp(buf, buf + n); + setg(buf, buf, buf); + } +} + +strstreambuf::strstreambuf(char* get, streamsize n, char* put) + : _M_alloc_fun(0), _M_free_fun(0), + _M_dynamic(false), _M_frozen(false), _M_constant(false) { + _M_setup(get, put, n); +} + +strstreambuf::strstreambuf(signed char* get, streamsize n, signed char* put) + : _M_alloc_fun(0), _M_free_fun(0), + _M_dynamic(false), _M_frozen(false), _M_constant(false) { + _M_setup(__REINTERPRET_CAST(char*,get), __REINTERPRET_CAST(char*,put), n); +} + +strstreambuf::strstreambuf(unsigned char* get, streamsize n, + unsigned char* put) + : _M_alloc_fun(0), _M_free_fun(0), + _M_dynamic(false), _M_frozen(false), _M_constant(false) { + _M_setup(__REINTERPRET_CAST(char*,get), __REINTERPRET_CAST(char*,put), n); +} + +strstreambuf::strstreambuf(const char* get, streamsize n) + : _M_alloc_fun(0), _M_free_fun(0), + _M_dynamic(false), _M_frozen(false), _M_constant(true) { + _M_setup(__CONST_CAST(char*,get), 0, n); +} + +strstreambuf::strstreambuf(const signed char* get, streamsize n) + : _M_alloc_fun(0), _M_free_fun(0), + _M_dynamic(false), _M_frozen(false), _M_constant(true) { + _M_setup(__REINTERPRET_CAST(char*, __CONST_CAST(signed char*,get)), 0, n); +} + +strstreambuf::strstreambuf(const unsigned char* get, streamsize n) + : _M_alloc_fun(0), _M_free_fun(0), + _M_dynamic(false), _M_frozen(false), _M_constant(true) { + _M_setup(__REINTERPRET_CAST(char*, __CONST_CAST(unsigned char*,get)), 0, n); +} + +strstreambuf::~strstreambuf() { + if (_M_dynamic && !_M_frozen) + _M_free(eback()); +} + +void strstreambuf::freeze(bool frozenflag) { + if (_M_dynamic) + _M_frozen = frozenflag; +} + +char* strstreambuf::str() { + freeze(true); + return eback(); +} + +int strstreambuf::pcount() const { + return int(pptr() ? pptr() - pbase() : 0); +} + +strstreambuf::int_type strstreambuf::overflow(int_type c) { + if (c == traits_type::eof()) + return traits_type::not_eof(c); + + // Try to expand the buffer. + if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) { + ptrdiff_t old_size = epptr() - pbase(); + ptrdiff_t new_size = (max)(2 * old_size, ptrdiff_t(1)); + + char* buf = _M_alloc(new_size); + if (buf) { + memcpy(buf, pbase(), old_size); + + char* old_buffer = pbase(); + bool reposition_get = false; + ptrdiff_t old_get_offset; + if (gptr() != 0) { + reposition_get = true; + old_get_offset = gptr() - eback(); + } + + setp(buf, buf + new_size); + pbump((int)old_size); + + if (reposition_get) + setg(buf, buf + old_get_offset, buf + (max)(old_get_offset, old_size)); + + _M_free(old_buffer); + } + } + + if (pptr() != epptr()) { + *pptr() = traits_type::to_char_type(c); + pbump(1); + return c; + } + else + return traits_type::eof(); +} + +strstreambuf::int_type strstreambuf::pbackfail(int_type c) { + if (gptr() != eback()) { + if (c == traits_type::eof()) { + gbump(-1); + return traits_type::not_eof(c); + } + else if (c == gptr()[-1]) { + gbump(-1); + return c; + } + else if (!_M_constant) { + gbump(-1); + *gptr() = traits_type::to_char_type(c); + return c; + } + } + + return traits_type::eof(); +} + +strstreambuf::int_type strstreambuf::underflow() { + if (gptr() == egptr() && pptr() && pptr() > egptr()) + setg(eback(), gptr(), pptr()); + + if (gptr() != egptr()) + return (unsigned char) *gptr(); + else + return _Traits::eof(); +} + +basic_streambuf >* +strstreambuf::setbuf(char*, streamsize) { + return this; +} + +strstreambuf::pos_type +strstreambuf::seekoff(off_type off, + ios_base::seekdir dir, ios_base::openmode mode) { + bool do_get = false; + bool do_put = false; + + if ((mode & (ios_base::in | ios_base::out)) == + (ios_base::in | ios_base::out) && + (dir == ios_base::beg || dir == ios_base::end)) + do_get = do_put = true; + else if (mode & ios_base::in) + do_get = true; + else if (mode & ios_base::out) + do_put = true; + + // !gptr() is here because, according to D.7.1 paragraph 4, the seekable + // area is undefined if there is no get area. + if ((!do_get && !do_put) || (do_put && !pptr()) || !gptr()) + return pos_type(off_type(-1)); + + char* seeklow = eback(); + char* seekhigh = epptr() ? epptr() : egptr(); + + off_type newoff; + switch(dir) { + case ios_base::beg: + newoff = 0; + break; + case ios_base::end: + newoff = seekhigh - seeklow; + break; + case ios_base::cur: + newoff = do_put ? pptr() - seeklow : gptr() - seeklow; + break; + default: + return pos_type(off_type(-1)); + } + + off += newoff; + if (off < 0 || off > seekhigh - seeklow) + return pos_type(off_type(-1)); + + if (do_put) { + if (seeklow + __STATIC_CAST(ptrdiff_t, off) < pbase()) { + setp(seeklow, epptr()); + pbump((int)off); + } + else { + setp(pbase(), epptr()); + pbump((int)(off - (pbase() - seeklow))); + } + } + if (do_get) { + if (off <= egptr() - seeklow) + setg(seeklow, seeklow + __STATIC_CAST(ptrdiff_t, off), egptr()); + else if (off <= pptr() - seeklow) + setg(seeklow, seeklow + __STATIC_CAST(ptrdiff_t, off), pptr()); + else + setg(seeklow, seeklow + __STATIC_CAST(ptrdiff_t, off), epptr()); + } + + return pos_type(newoff); +} + +strstreambuf::pos_type +strstreambuf::seekpos(pos_type pos, ios_base::openmode mode) { + return seekoff(pos - pos_type(off_type(0)), ios_base::beg, mode); +} + + +char* strstreambuf::_M_alloc(size_t n) { + if (_M_alloc_fun) + return __STATIC_CAST(char*,_M_alloc_fun(n)); + else + return new char[n]; +} + +void strstreambuf::_M_free(char* p) { + if (p) { + if (_M_free_fun) + _M_free_fun(p); + else + delete[] p; + } +} + +void strstreambuf::_M_setup(char* get, char* put, streamsize n) { + if (get) { + size_t N = n > 0 ? size_t(n) : n == 0 ? strlen(get) : size_t(INT_MAX); + + if (put) { + setg(get, get, get + N); + setp(put, put + N); + } + else { + setg(get, get, get + N); + } + } +} + +//---------------------------------------------------------------------- +// Class istrstream + +istrstream::istrstream(char* s) + : basic_istream >(0), _M_buf(s, 0) { + this->init(&_M_buf); +} + +istrstream::istrstream(const char* s) + : basic_istream >(0), _M_buf(s, 0) { + this->init(&_M_buf); +} + +istrstream::istrstream(char* s, streamsize n) + : basic_istream >(0), _M_buf(s, n) { + this->init(&_M_buf); +} + +istrstream::istrstream(const char* s, streamsize n) + : basic_istream >(0), _M_buf(s, n) { + this->init(&_M_buf); +} + +istrstream::~istrstream() {} + +strstreambuf* istrstream::rdbuf() const { + return __CONST_CAST(strstreambuf*,&_M_buf); +} + +char* istrstream::str() { return _M_buf.str(); } + +//---------------------------------------------------------------------- +// Class ostrstream + +ostrstream::ostrstream() + : basic_ostream >(0), _M_buf() { + basic_ios >::init(&_M_buf); +} + +ostrstream::ostrstream(char* s, int n, ios_base::openmode mode) + : basic_ostream >(0), + _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s) { + basic_ios >::init(&_M_buf); +} + +ostrstream::~ostrstream() {} + +strstreambuf* ostrstream::rdbuf() const { + return __CONST_CAST(strstreambuf*,&_M_buf); +} + +void ostrstream::freeze(bool freezeflag) { + _M_buf.freeze(freezeflag); +} + +char* ostrstream::str() { + return _M_buf.str(); +} + +int ostrstream::pcount() const { + return _M_buf.pcount(); +} + + +//---------------------------------------------------------------------- +// Class strstream + +strstream::strstream() + : basic_iostream >(0), _M_buf() { + basic_ios >::init(&_M_buf); +} + +strstream::strstream(char* s, int n, ios_base::openmode mode) + : basic_iostream >(0), + _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s) { + basic_ios >::init(&_M_buf); +} + +strstream::~strstream() {} + +strstreambuf* strstream::rdbuf() const { + return __CONST_CAST(strstreambuf*,&_M_buf); +} + +void strstream::freeze(bool freezeflag) { + _M_buf.freeze(freezeflag); +} + +int strstream::pcount() const { + return _M_buf.pcount(); +} + +char* strstream::str() { + return _M_buf.str(); +} + +_STLP_END_NAMESPACE + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/src/time_facets.cpp b/sdk/tlibstdcxx/src/time_facets.cpp new file mode 100644 index 0000000000..3e98c70d1f --- /dev/null +++ b/sdk/tlibstdcxx/src/time_facets.cpp @@ -0,0 +1,565 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include +#include + +#include "c_locale.h" +#include "acquire_release.h" + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// default "C" values for month and day names + +const char default_dayname[][14] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday"}; + +const char default_monthname[][24] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December"}; + +#ifndef _STLP_NO_WCHAR_T +const wchar_t default_wdayname[][14] = { + L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat", + L"Sunday", L"Monday", L"Tuesday", L"Wednesday", L"Thursday", + L"Friday", L"Saturday"}; + +const wchar_t default_wmonthname[][24] = { + L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", + L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec", + L"January", L"February", L"March", L"April", L"May", L"June", + L"July", L"August", L"September", L"October", L"November", L"December"}; +#endif + +#if defined (__BORLANDC__) +_Time_Info time_init::_M_timeinfo; +# ifndef _STLP_NO_WCHAR_T +_WTime_Info time_init::_M_timeinfo; +# endif +#endif + +// _Init_time_info: initialize table with +// "C" values (note these are not defined in the C standard, so this +// is somewhat arbitrary). + +static void _Init_timeinfo_base(_Time_Info_Base& table) { + table._M_time_format = "%H:%M:%S"; + table._M_date_format = "%m/%d/%y"; + table._M_date_time_format = "%m/%d/%y"; +} + +static void _Init_timeinfo(_Time_Info& table) { + int i; + for (i = 0; i < 14; ++i) + table._M_dayname[i] = default_dayname[i]; + for (i = 0; i < 24; ++i) + table._M_monthname[i] = default_monthname[i]; + table._M_am_pm[0] = "AM"; + table._M_am_pm[1] = "PM"; + _Init_timeinfo_base(table); +} + +#ifndef _STLP_NO_WCHAR_T +static void _Init_timeinfo(_WTime_Info& table) { + int i; + for (i = 0; i < 14; ++i) + table._M_dayname[i] = default_wdayname[i]; + for (i = 0; i < 24; ++i) + table._M_monthname[i] = default_wmonthname[i]; + table._M_am_pm[0] = L"AM"; + table._M_am_pm[1] = L"PM"; + _Init_timeinfo_base(table); +} +#endif + +static void _Init_timeinfo_base(_Time_Info_Base& table, _Locale_time * time) { + table._M_time_format = _Locale_t_fmt(time); + if ( table._M_time_format == "%T" ) { + table._M_time_format = "%H:%M:%S"; + } else if ( table._M_time_format == "%r" ) { + table._M_time_format = "%I:%M:%S %p"; + } else if ( table._M_time_format == "%R" ) { + table._M_time_format = "%H:%M"; + } + table._M_date_format = _Locale_d_fmt(time); + table._M_date_time_format = _Locale_d_t_fmt(time); + table._M_long_date_format = _Locale_long_d_fmt(time); + table._M_long_date_time_format = _Locale_long_d_t_fmt(time); +} + +static void _Init_timeinfo(_Time_Info& table, _Locale_time * time) { + int i; + for (i = 0; i < 7; ++i) + table._M_dayname[i] = _Locale_abbrev_dayofweek(time, i); + for (i = 0; i < 7; ++i) + table._M_dayname[i+7] = _Locale_full_dayofweek(time, i); + for (i = 0; i < 12; ++i) + table._M_monthname[i] = _Locale_abbrev_monthname(time, i); + for (i = 0; i < 12; ++i) + table._M_monthname[i+12] = _Locale_full_monthname(time, i); + table._M_am_pm[0] = _Locale_am_str(time); + table._M_am_pm[1] = _Locale_pm_str(time); + _Init_timeinfo_base(table, time); +} + +#ifndef _STLP_NO_WCHAR_T +static void _Init_timeinfo(_WTime_Info& table, _Locale_time * time) { + wchar_t buf[128]; + int i; + for (i = 0; i < 7; ++i) + table._M_dayname[i] = _WLocale_abbrev_dayofweek(time, i, _STLP_ARRAY_AND_SIZE(buf)); + for (i = 0; i < 7; ++i) + table._M_dayname[i+7] = _WLocale_full_dayofweek(time, i, _STLP_ARRAY_AND_SIZE(buf)); + for (i = 0; i < 12; ++i) + table._M_monthname[i] = _WLocale_abbrev_monthname(time, i, _STLP_ARRAY_AND_SIZE(buf)); + for (i = 0; i < 12; ++i) + table._M_monthname[i+12] = _WLocale_full_monthname(time, i, _STLP_ARRAY_AND_SIZE(buf)); + table._M_am_pm[0] = _WLocale_am_str(time, _STLP_ARRAY_AND_SIZE(buf)); + table._M_am_pm[1] = _WLocale_pm_str(time, _STLP_ARRAY_AND_SIZE(buf)); + _Init_timeinfo_base(table, time); +} +#endif + +template +void __subformat(_STLP_BASIC_IOSTRING(_Ch) &buf, const ctype<_Ch>& ct, + const string& format, const _TimeInfo& table, const tm* t) { + const char * cp = format.data(); + const char * cp_end = cp + format.size(); + while (cp != cp_end) { + if (*cp == '%') { + char mod = 0; + ++cp; + if (*cp == '#') { + mod = *cp; ++cp; + } + __write_formatted_timeT(buf, ct, *cp++, mod, table, t); + } else + buf.append(1, *cp++); + } +} + +static void __append(__iostring &buf, const string& name) +{ buf.append(name.data(), name.data() + name.size()); } + +static void __append(__iowstring &buf, const wstring& name) +{ buf.append(name.data(), name.data() + name.size()); } + +static void __append(__iostring &buf, char *first, char *last, const ctype& /* ct */) +{ buf.append(first, last); } + +static void __append(__iowstring &buf, char *first, char *last, const ctype& ct) { + wchar_t _wbuf[64]; + ct.widen(first, last, _wbuf); + buf.append(_wbuf, _wbuf + (last - first)); +} + +#if defined (__GNUC__) +/* The number of days from the first day of the first ISO week of this + year to the year day YDAY with week day WDAY. ISO weeks start on + Monday; the first ISO week has the year's first Thursday. YDAY may + be as small as YDAY_MINIMUM. */ +# define __ISO_WEEK_START_WDAY 1 /* Monday */ +# define __ISO_WEEK1_WDAY 4 /* Thursday */ +# define __YDAY_MINIMUM (-366) +# define __TM_YEAR_BASE 1900 +static int +__iso_week_days(int yday, int wday) { + /* Add enough to the first operand of % to make it nonnegative. */ + int big_enough_multiple_of_7 = (-__YDAY_MINIMUM / 7 + 2) * 7; + return (yday + - (yday - wday + __ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 + + __ISO_WEEK1_WDAY - __ISO_WEEK_START_WDAY); +} + +# define __is_leap(year)\ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) + +#endif + +#define __hour12(hour) \ + (((hour) % 12 == 0) ? (12) : (hour) % 12) + +#if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) +# define _STLP_SPRINTF sprintf +#else +# define _STLP_SPRINTF sprintf_s +#endif + +template +void _STLP_CALL __write_formatted_timeT(_STLP_BASIC_IOSTRING(_Ch) &buf, + const ctype<_Ch>& ct, + char format, char modifier, + const _TimeInfo& table, const tm* t) { + char _buf[64]; + char *_bend; + + switch (format) { + case 'a': + __append(buf, table._M_dayname[t->tm_wday]); + break; + + case 'A': + __append(buf, table._M_dayname[t->tm_wday + 7]); + break; + + case 'b': + __append(buf, table._M_monthname[t->tm_mon]); + break; + + case 'B': + __append(buf, table._M_monthname[t->tm_mon + 12]); + break; + + case 'c': + __subformat(buf, ct, (modifier != '#') ? table._M_date_time_format + : table._M_long_date_time_format, table, t); + break; + + case 'd': + _STLP_SPRINTF(_buf, (modifier != '#') ? "%.2ld" : "%ld", (long)t->tm_mday); + __append(buf, _buf, ((long)t->tm_mday < 10L && modifier == '#') ? _buf + 1 : _buf + 2, ct); + break; + + case 'e': + _STLP_SPRINTF(_buf, "%2ld", (long)t->tm_mday); + __append(buf, _buf, _buf + 2, ct); + break; + + case 'H': + _STLP_SPRINTF(_buf, (modifier != '#') ? "%.2ld" : "%ld", (long)t->tm_hour); + __append(buf, _buf, ((long)t->tm_hour < 10L && modifier == '#') ? _buf + 1 : _buf + 2, ct); + break; + + case 'I': + _STLP_SPRINTF(_buf, (modifier != '#') ? "%.2ld" : "%ld", (long)__hour12(t->tm_hour)); + __append(buf, _buf, ((long)__hour12(t->tm_hour) < 10L && modifier == '#') ? _buf + 1 : _buf + 2, ct); + break; + + case 'j': + _bend = __write_integer(_buf, 0, (long)((long)t->tm_yday + 1)); + __append(buf, _buf, _bend, ct); + break; + + case 'm': + _STLP_SPRINTF(_buf, (modifier != '#') ? "%.2ld" : "%ld", (long)t->tm_mon + 1); + __append(buf, _buf, ((long)(t->tm_mon + 1) < 10L && modifier == '#') ? _buf + 1 : _buf + 2, ct); + break; + + case 'M': + _STLP_SPRINTF(_buf, (modifier != '#') ? "%.2ld" : "%ld", (long)t->tm_min); + __append(buf, _buf, ((long)t->tm_min < 10L && modifier == '#') ? _buf + 1 : _buf + 2, ct); + break; + + case 'p': + __append(buf, table._M_am_pm[t->tm_hour / 12]); + break; + + case 'S': // pad with zeros + _STLP_SPRINTF(_buf, (modifier != '#') ? "%.2ld" : "%ld", (long)t->tm_sec); + __append(buf, _buf, ((long)t->tm_sec < 10L && modifier == '#') ? _buf + 1 : _buf + 2, ct); + break; + + case 'U': + _bend = __write_integer(_buf, 0, long((t->tm_yday - t->tm_wday + 7) / 7)); + __append(buf, _buf, _bend, ct); + break; + + case 'w': + _bend = __write_integer(_buf, 0, (long)t->tm_wday); + __append(buf, _buf, _bend, ct); + break; + + case 'W': + _bend = __write_integer(_buf, 0, + (long)(t->tm_wday == 0 ? (t->tm_yday + 1) / 7 : + (t->tm_yday + 8 - t->tm_wday) / 7)); + __append(buf, _buf, _bend, ct); + break; + + case'x': + __subformat(buf, ct, (modifier != '#') ? table._M_date_format + : table._M_long_date_format, table, t); + break; + + case 'X': + __subformat(buf, ct, table._M_time_format, table, t); + break; + + case 'y': + _bend = __write_integer(_buf, 0, (long)((long)(t->tm_year + 1900) % 100)); + __append(buf, _buf, _bend, ct); + break; + + case 'Y': + _bend = __write_integer(_buf, 0, (long)((long)t->tm_year + 1900)); + __append(buf, _buf, _bend, ct); + break; + + case '%': + buf.append(1, ct.widen('%')); + break; + +#if defined (__GNUC__) + // fbp : at least on SUN +# if defined (_STLP_UNIX) && !defined (__linux__) +# define __USE_BSD 1 +# endif + + /********************************************* + * JGS, handle various extensions * + *********************************************/ + + case 'h': /* POSIX.2 extension */ + // same as 'b', abbrev month name + __append(buf, table._M_monthname[t->tm_mon]); + break; + case 'C': /* POSIX.2 extension */ + // same as 'd', the day + _STLP_SPRINTF(_buf, "%2ld", (long)t->tm_mday); + __append(buf, _buf, _buf + 2, ct); + break; + + case 'D': /* POSIX.2 extension */ + // same as 'x' + __subformat(buf, ct, table._M_date_format, table, t); + break; + + case 'k': /* GNU extension */ + _STLP_SPRINTF(_buf, "%2ld", (long)t->tm_hour); + __append(buf, _buf, _buf + 2, ct); + break; + + case 'l': /* GNU extension */ + _STLP_SPRINTF(_buf, "%2ld", (long)t->tm_hour % 12); + __append(buf, _buf, _buf + 2, ct); + break; + + case 'n': /* POSIX.2 extension */ + buf.append(1, ct.widen('\n')); + break; + + case 'R': /* GNU extension */ + __subformat(buf, ct, "%H:%M", table, t); + break; + + case 'r': /* POSIX.2 extension */ + __subformat(buf, ct, "%I:%M:%S %p", table, t); + break; + + case 'T': /* POSIX.2 extension. */ + __subformat(buf, ct, "%H:%M:%S", table, t); + break; + + case 't': /* POSIX.2 extension. */ + buf.append(1, ct.widen('\t')); + + case 'u': /* POSIX.2 extension. */ + _bend = __write_integer(_buf, 0, long((t->tm_wday - 1 + 7)) % 7 + 1); + __append(buf, _buf, _bend, ct); + break; + + case 's': { + time_t __t = mktime(__CONST_CAST(tm*, t)); + _bend = __write_integer(_buf, 0, (long)__t ); + __append(buf, _buf, _bend, ct); + break; + } + case 'g': /* GNU extension */ + case 'G': { + int year = t->tm_year + __TM_YEAR_BASE; + int days = __iso_week_days (t->tm_yday, t->tm_wday); + if (days < 0) { + /* This ISO week belongs to the previous year. */ + year--; + days = __iso_week_days (t->tm_yday + (365 + __is_leap (year)), t->tm_wday); + } + else { + int d = __iso_week_days (t->tm_yday - (365 + __is_leap (year)), t->tm_wday); + if (0 <= d) { + /* This ISO week belongs to the next year. */ + ++year; + days = d; + } + } + long val; + switch (format) { + case 'g': + val = (long)(year % 100 + 100) % 100; + break; + case 'G': + val = (long)year; + break; + default: + val = (long)days / 7 + 1; + break; + } + _bend = __write_integer(_buf, 0, val); + __append(buf, _buf, _bend, ct); + break; + } + +# if defined (_STLP_USE_GLIBC) + case 'z': /* GNU extension. */ + if (t->tm_isdst < 0) + break; + { + int diff; +# if defined (__USE_BSD) || defined (__BEOS__) + diff = t->tm_gmtoff; +# else + diff = t->__tm_gmtoff; +# endif + if (diff < 0) { + buf.append(1, ct.widen('-')); + diff = -diff; + } else + buf.append(1, ct.widen('+')); + diff /= 60; + _STLP_SPRINTF(_buf, "%.4d", (diff / 60) * 100 + diff % 60); + __append(buf, _buf, _buf + 4, ct); + break; + } +# endif /* __GLIBC__ */ +#endif /* __GNUC__ */ + + default: + break; + } +} + +void _STLP_CALL __write_formatted_time(__iostring &buf, const ctype& ct, + char format, char modifier, + const _Time_Info& table, const tm* t) +{ __write_formatted_timeT(buf, ct, format, modifier, table, t); } + +void _STLP_CALL __write_formatted_time(__iowstring &buf, const ctype& ct, + char format, char modifier, + const _WTime_Info& table, const tm* t) +{ __write_formatted_timeT(buf, ct, format, modifier, table, t); } + +static time_base::dateorder __get_date_order(_Locale_time* time) { + const char * fmt = _Locale_d_fmt(time); + char first, second, third; + + while (*fmt != 0 && *fmt != '%') ++fmt; + if (*fmt == 0) + return time_base::no_order; + first = *++fmt; + while (*fmt != 0 && *fmt != '%') ++fmt; + if (*fmt == 0) + return time_base::no_order; + second = *++fmt; + while (*fmt != 0 && *fmt != '%') ++fmt; + if (*fmt == 0) + return time_base::no_order; + third = *++fmt; + + switch (first) { + case 'd': + return (second == 'm' && third == 'y') ? time_base::dmy + : time_base::no_order; + case 'm': + return (second == 'd' && third == 'y') ? time_base::mdy + : time_base::no_order; + case 'y': + switch (second) { + case 'd': + return third == 'm' ? time_base::ydm : time_base::no_order; + case 'm': + return third == 'd' ? time_base::ymd : time_base::no_order; + default: + return time_base::no_order; + } + default: + return time_base::no_order; + } +} + +time_init::time_init() + : _M_dateorder(time_base::no_order) +{ _Init_timeinfo(_M_timeinfo); } + +time_init::time_init(const char* __name) { + if (!__name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _Locale_time *__time = __acquire_time(__name, buf, 0, &__err_code); + if (!__time) + locale::_M_throw_on_creation_failure(__err_code, __name, "time"); + + _Init_timeinfo(this->_M_timeinfo, __time); + _M_dateorder = __get_date_order(__time); + __release_time(__time); +} + +time_init::time_init(_Locale_time *__time) { + _Init_timeinfo(this->_M_timeinfo, __time); + _M_dateorder = __get_date_order(__time); +} + +#ifndef _STLP_NO_WCHAR_T +time_init::time_init() + : _M_dateorder(time_base::no_order) +{ _Init_timeinfo(_M_timeinfo); } + +time_init::time_init(const char* __name) { + if (!__name) + locale::_M_throw_on_null_name(); + + int __err_code; + char buf[_Locale_MAX_SIMPLE_NAME]; + _Locale_time *__time = __acquire_time(__name, buf, 0, &__err_code); + if (!__time) + locale::_M_throw_on_creation_failure(__err_code, __name, "time"); + + _Init_timeinfo(this->_M_timeinfo, __time); + _M_dateorder = __get_date_order(__time); + __release_time(__time); +} + +time_init::time_init(_Locale_time *__time) { + _Init_timeinfo(this->_M_timeinfo, __time); + _M_dateorder = __get_date_order(__time); +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +#if !defined (_STLP_NO_FORCE_INSTANTIATE) +template class time_get > >; +template class time_put > >; + +# ifndef _STLP_NO_WCHAR_T +template class time_get > >; +template class time_put > >; +# endif + +#endif + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/src/warning_disable.h b/sdk/tlibstdcxx/src/warning_disable.h new file mode 100644 index 0000000000..7f0c1c8470 --- /dev/null +++ b/sdk/tlibstdcxx/src/warning_disable.h @@ -0,0 +1,61 @@ +#if !defined (__ICL) +/* This header is used to turn off warnings of Microsoft compilers generated. + * while building STLport. + * For compiling user code, see stlport/config/_msvc_warnings_off.h. + */ + +# if (_MSC_VER < 1300) /* VC6/eVC4 */ +# pragma warning( disable : 4097 ) /* typedef-name used as based class of (...) */ +# pragma warning( disable : 4251 ) /* DLL interface needed */ +# pragma warning( disable : 4284 ) /* for -> operator */ +# pragma warning( disable : 4503 ) /* decorated name length exceeded, name was truncated */ +# pragma warning( disable : 4514 ) /* unreferenced inline function has been removed */ +# pragma warning( disable : 4660 ) /* template-class specialization '...' is already instantiated */ +# pragma warning( disable : 4701 ) /* local variable 'base' may be used without having been initialized */ +# pragma warning( disable : 4710 ) /* function (...) not inlined */ +# pragma warning( disable : 4786 ) /* identifier truncated to 255 characters */ +# endif + +# if (_MSC_VER <= 1310) +# pragma warning( disable : 4511 ) /* copy constructor cannot be generated */ +# endif + +# if (_MSC_VER < 1300) && defined (UNDER_CE) +# pragma warning( disable : 4201 ) /* nonstandard extension used : nameless struct/union */ +# pragma warning( disable : 4214 ) /* nonstandard extension used : bit field types other than int */ +# endif + +/* Suppress warnings emitted from Windows CE SDK headers. */ +# if (_MSC_VER >= 1400) && defined (UNDER_CE) +# pragma warning( disable : 4115 ) /* Named type definition in parentheses. */ +# pragma warning( disable : 4201 ) /* Nameless struct/union. */ +# pragma warning( disable : 4214 ) /* Bit field types other than int. */ +# pragma warning( disable : 4290 ) /* C++ exception specification ignored. */ +# pragma warning( disable : 4430 ) /* Missing type specifier, int assumed. */ +# pragma warning( disable : 4431 ) /* Missing type specifier, int assumed. */ +# endif + +# pragma warning( disable : 4075 ) /* initializers put in unrecognized initialization area */ +/* This warning is disable only for the c_locale_win32.c file compilation: */ +# pragma warning( disable : 4100 ) /* unreferenced formal parameter */ +# pragma warning( disable : 4127 ) /* conditional expression is constant */ +# pragma warning( disable : 4146 ) /* unary minus applied to unsigned type */ +# pragma warning( disable : 4245 ) /* conversion from 'enum ' to 'unsigned int', signed/unsigned mismatch */ +# pragma warning( disable : 4244 ) /* implicit conversion: possible loss of data */ +# pragma warning( disable : 4512 ) /* assignment operator could not be generated */ +# pragma warning( disable : 4571 ) /* catch(...) blocks compiled with /EHs do not catch or re-throw Structured Exceptions */ +# pragma warning( disable : 4702 ) /* unreachable code (appears in release with warning level4) */ +#else +# pragma warning( disable : 69 ) /* integer conversion resulted in truncation */ +# pragma warning( disable : 174 ) /* expression has no effect */ +# pragma warning( disable : 279 ) /* controling expression is constant */ +# pragma warning( disable : 383 ) /* reference to temporary used */ +# pragma warning( disable : 444 ) /* destructor for base class "..." is not virtual*/ +# pragma warning( disable : 810 ) /* conversion from "int" to "char" may lose significant bits */ +# pragma warning( disable : 981 ) /* operands are evaluated in unspecified order */ +# pragma warning( disable : 1418 ) /* external definition with no prior declaration */ +# pragma warning( disable : 1419 ) /* external declaration in primary source file */ +# pragma warning( disable : 1572 ) /* floating-point equality and inequality comparisons are unreliable */ +# pragma warning( disable : 1682 ) /* implicit conversion of a 64-bit integral type to a smaller integral type */ +# pragma warning( disable : 1683 ) /* explicit conversion of a 64-bit integral type to a smaller integral type */ +#endif diff --git a/sdk/tlibstdcxx/stlport/algorithm b/sdk/tlibstdcxx/stlport/algorithm new file mode 100644 index 0000000000..c653d8c773 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/algorithm @@ -0,0 +1,62 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_ALGORITHM + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x1 +# include +# define _STLP_ALGORITHM +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x1) +# ifndef _STLP_INTERNAL_CSTDIO +// remove() conflicts, should always go first +# include +# endif + +# ifndef _STLP_INTERNAL_ALGO_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x1) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(algorithm) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x1 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_ALGORITHM */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/assert.h b/sdk/tlibstdcxx/stlport/assert.h new file mode 100644 index 0000000000..ac73de5fad --- /dev/null +++ b/sdk/tlibstdcxx/stlport/assert.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x202 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x202) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +/* evc3 doesn't have assert.h; macro assert() is defined in stl_evc.h */ +#ifndef _STLP_WCE_EVC3 +# if !defined (assert) +# define _STLP_NATIVE_ASSERT_H_INCLUDED +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(assert.h) +# endif +# endif +# if !defined (_STLP_SGX_CONFIG) && !defined (_STLP_NATIVE_ASSERT_H_INCLUDED) +/* See errno.h for additional information about this #error */ +# error assert has been defined before inclusion of assert.h header. +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x202) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif + +/* Local Variables: + * mode:C++ + * End: + */ diff --git a/sdk/tlibstdcxx/stlport/bitset b/sdk/tlibstdcxx/stlport/bitset new file mode 100644 index 0000000000..1d7fcf3ebb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/bitset @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_BITSET + +// This implementation of bitset<> has a second template parameter, +// _WordT, which defaults to unsigned long. *YOU SHOULD NOT USE +// THIS FEATURE*. It is experimental, and it may be removed in +// future releases. + +// A bitset of size N, using words of type _WordT, will have +// N % (sizeof(_WordT) * CHAR_BIT) unused bits. (They are the high- +// order bits in the highest word.) It is a class invariant +// of class bitset<> that those unused bits are always zero. + +// Most of the actual code isn't contained in bitset<> itself, but in the +// base class _Base_bitset. The base class works with whole words, not with +// individual bits. This allows us to specialize _Base_bitset for the +// important special case where the bitset is only a single word. + +// The C++ standard does not define the precise semantics of operator[]. +// In this implementation the const version of operator[] is equivalent +// to test(), except that it does no range checking. The non-const version +// returns a reference to a bit, again without doing any range checking. + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x2 +# include +# define _STLP_BITSET +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x2) +# ifndef _STLP_INTERNAL_BITSET +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x2) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(bitset) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x2 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_BITSET */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cassert b/sdk/tlibstdcxx/stlport/cassert new file mode 100644 index 0000000000..aabd0b4ee5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cassert @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x103 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x103) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if !defined (_STLP_WCE_EVC3) +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cassert) +# endif +# else +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x103 ) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cctype b/sdk/tlibstdcxx/stlport/cctype new file mode 100644 index 0000000000..513512e928 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cctype @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CCTYPE + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x104 +# define _STLP_CCTYPE +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x104 ) +# ifndef _STLP_INTERNAL_CCTYPE +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x104) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cctype) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x104 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CCTYPE */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cerrno b/sdk/tlibstdcxx/stlport/cerrno new file mode 100644 index 0000000000..0d17faf5e1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cerrno @@ -0,0 +1,55 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CERRNO +#define _STLP_CERRNO + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x105 +# include +#endif + +#ifndef _STLP_WCE +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cerrno) +# endif +# else +# include +# endif +#endif + +#ifndef errno /* errno is not a macro */ +# if defined (_STLP_IMPORT_VENDOR_CSTD) +# if !defined (__IBMCPP__) && !defined (__hpux) && !defined (__MWERKS__) && !defined (_STLP_WCE) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::errno; +_STLP_END_NAMESPACE +# endif +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x105 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CERRNO */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cfloat b/sdk/tlibstdcxx/stlport/cfloat new file mode 100644 index 0000000000..cb2e0cd002 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cfloat @@ -0,0 +1,45 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CFLOAT +#define _STLP_CFLOAT + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x106 +# include +#endif + +// Borland defines some implementation constants in std:: namespace, +// we do not want to import them. +#if defined (_STLP_USE_NEW_C_HEADERS) && !defined (__BORLANDC__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cfloat) +# endif +#else +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x106 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CFLOAT */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/ciso646 b/sdk/tlibstdcxx/stlport/ciso646 new file mode 100644 index 0000000000..443449d6f5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/ciso646 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CISO646 +#define _STLP_CISO646 + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x107 +# include +#endif + +#if !defined(_STLP_WCE_EVC3) && !defined (__BORLANDC__) +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(ciso646) +# endif +# else +# include +# endif /* _STLP_USE_NEW_C_HEADERS */ +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x107 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CISO646 */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/climits b/sdk/tlibstdcxx/stlport/climits new file mode 100644 index 0000000000..86bc413c87 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/climits @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CLIMITS +# define _STLP_CLIMITS + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x108 +# include +#endif + +#if defined (__SUNPRO_CC) && ((__SUNPRO_CC == 0x500) && (__SUNPRO_CC_COMPAT > 4)) +# include +#elif defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(climits) +# endif +#else +# if defined (__BORLANDC__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(limits.h) +# endif +# else +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x108 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CLIMITS */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cmath b/sdk/tlibstdcxx/stlport/cmath new file mode 100644 index 0000000000..46a8f52ec7 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cmath @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CMATH + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x110 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x110) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_CMATH +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x110) && !defined (_STLP_DONT_POP_HEADER_ID) +# ifndef _STLP_INTERNAL_CMATH +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x110) || defined (_STLP_DONT_POP_HEADER_ID) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cmath) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x110) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +#endif /* _STLP_CMATH */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/complex b/sdk/tlibstdcxx/stlport/complex new file mode 100644 index 0000000000..6cfe6052f9 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/complex @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_COMPLEX + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x10 +# define _STLP_COMPLEX +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x10) +// This header declares the template class complex, as described in +// in the C++ Standard. Single-precision complex numbers +// are complex, double-precision are complex, and +// quad precision are complex. + +// Note that the template class complex is declared within namespace +// std, as called for by the draft C++ standard +# ifndef _STLP_INTERNAL_COMPLEX +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x10) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(complex) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x10 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_COMPLEX */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cstdarg b/sdk/tlibstdcxx/stlport/cstdarg new file mode 100644 index 0000000000..6882bbdc07 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cstdarg @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CSTDARG + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x113 +# define _STLP_CSTDARG +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x113) +# ifndef _STLP_INTERNAL_CSTDARG +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x113) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdarg) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x113 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CSTDARG */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cstddef b/sdk/tlibstdcxx/stlport/cstddef new file mode 100644 index 0000000000..0a66f0e4d5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cstddef @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CSTDDEF + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x114 +# define _STLP_CSTDDEF +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x114) +# ifndef _STLP_INTERNAL_CSTDDEF +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x114) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstddef) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x114 ) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CSTDDEF */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cstdio b/sdk/tlibstdcxx/stlport/cstdio new file mode 100644 index 0000000000..e20c8fff79 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cstdio @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CSTDIO + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x15 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x15) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_CSTDIO +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x15) && !defined (_STLP_DONT_POP_HEADER_ID) +# ifndef _STLP_INTERNAL_CSTDIO +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x15) || defined (_STLP_DONT_POP_HEADER_ID) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdio) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x15) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cstdlib b/sdk/tlibstdcxx/stlport/cstdlib new file mode 100644 index 0000000000..20afa3563a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cstdlib @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CSTDLIB + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x116 +# define _STLP_CSTDLIB +# include +#endif + +# if defined (__GNUC__) && defined (__MINGW32__) +/* Native cstdlib includes stdlib.h using an include_next so STLport stdlib.h + * is not used and the workaround in this file must be duplicated here + * (see stdlib.h). */ +# include "errno.h" +# endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x116) +# ifndef _STLP_INTERNAL_CSTDLIB +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x116) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x116) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CSTDLIB */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cstring b/sdk/tlibstdcxx/stlport/cstring new file mode 100644 index 0000000000..d5cf58d017 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cstring @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CSTRING + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x117 +# define _STLP_CSTRING +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x117) +# ifndef _STLP_INTERNAL_CSTRING +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x117) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstring) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x117) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CSTRING */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/ctime b/sdk/tlibstdcxx/stlport/ctime new file mode 100644 index 0000000000..bafb7dd2e3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/ctime @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CTIME + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x118 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x118) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_CTIME +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x118) && !defined (_STLP_DONT_POP_HEADER_ID) +# ifndef _STLP_INTERNAL_CTIME +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x118) || defined (_STLP_DONT_POP_HEADER_ID) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(ctime) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x118) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +#endif /* _STLP_CTIME */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/ctype.h b/sdk/tlibstdcxx/stlport/ctype.h new file mode 100644 index 0000000000..f9d10003e1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/ctype.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CTYPE_H + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include ctype.h, which results in warnings and errors + */ +#if !defined(RC_INVOKED) + +# if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x219 +# include +# elif (_STLP_OUTERMOST_HEADER_ID == 0x219) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_CTYPE_H +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(ctype.h) +# endif + +/* on evc4 including ctype.h also defines setjmp macro */ +# if defined (_STLP_WCE) +# define _STLP_NATIVE_SETJMP_H_INCLUDED +# endif + +# ifndef _STLP_CTYPE_H_SEEN +# define _STLP_CTYPE_H_SEEN + +/* Undef convenience interfaces */ +# undef isspace +# undef isprint +# undef iscntrl +# undef isupper +# undef islower +# undef isalpha +# undef isdigit +# undef ispunct +# undef isxdigit +# undef isalnum +# undef isgraph +# undef toupper +# undef tolower + +# if defined (UNDER_CE) + +# if (_WIN32_WCE < 300) /* Only wide chars for older versions */ +# define _isctype iswctype +# endif + +__inline int (isalpha)(int c) { return _isctype(c, _ALPHA); } +__inline int (isupper)(int c) { return _isctype(c, _UPPER); } +__inline int (islower)(int c) { return _isctype(c, _LOWER); } +__inline int (isdigit)(int c) { return _isctype(c, _DIGIT); } +__inline int (isxdigit)(int c) { return _isctype(c, _HEX); } +__inline int (isspace)(int c) { return _isctype(c, _SPACE); } +__inline int (ispunct)(int c) { return _isctype(c, _PUNCT); } +__inline int (isalnum)(int c) { return _isctype(c, _ALPHA|_DIGIT); } +__inline int (isprint)(int c) { return _isctype(c, _BLANK|_PUNCT|_ALPHA|_DIGIT); } +__inline int (isgraph)(int c) { return _isctype(c, _PUNCT|_ALPHA|_DIGIT); } +__inline int (iscntrl)(int c) { return _isctype(c, _CONTROL); } +__inline int (isascii)(int c) { return ((unsigned)(c) < 0x80); } + +# undef _isctype + +__inline int (iswalpha)(int c) { return iswctype((unsigned short)(c), _ALPHA); } +__inline int (iswupper)(int c) { return iswctype((unsigned short)(c), _UPPER); } +__inline int (iswlower)(int c) { return iswctype((unsigned short)(c), _LOWER); } +__inline int (iswdigit)(int c) { return iswctype((unsigned short)(c), _DIGIT); } +__inline int (iswxdigit)(int c) { return iswctype((unsigned short)(c), _HEX); } +__inline int (iswspace)(int c) { return iswctype((unsigned short)(c), _SPACE); } +__inline int (iswpunct)(int c) { return iswctype((unsigned short)(c), _PUNCT); } +__inline int (iswalnum)(int c) { return iswctype((unsigned short)(c), _ALPHA|_DIGIT); } +__inline int (iswprint)(int c) { return iswctype((unsigned short)(c), _BLANK|_PUNCT|_ALPHA|_DIGIT); } +__inline int (iswgraph)(int c) { return iswctype((unsigned short)(c), _PUNCT|_ALPHA|_DIGIT); } +__inline int (iswcntrl)(int c) { return iswctype((unsigned short)(c), _CONTROL); } +__inline int (iswascii)(int c) { return ((unsigned)(c) < 0x80); } + +# endif /* UNDER_CE */ + +# endif /* _STLP_CTYPE_H_SEEN */ + +# if (_STLP_OUTERMOST_HEADER_ID == 0x219) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif + +#endif /* RC_INVOKED */ + +#endif /* _STLP_CTYPE_H */ diff --git a/sdk/tlibstdcxx/stlport/cwchar b/sdk/tlibstdcxx/stlport/cwchar new file mode 100644 index 0000000000..0b3205474a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cwchar @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CWCHAR + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x120 +# define _STLP_CWCHAR +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x120) +# ifndef _STLP_INTERNAL_CWCHAR +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x120) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cwchar) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x120) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CWCHAR */ + + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/cwctype b/sdk/tlibstdcxx/stlport/cwctype new file mode 100644 index 0000000000..0e86218e01 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/cwctype @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CWCTYPE + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x121 +# define _STLP_CWCTYPE +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x121) +# ifndef _STLP_INTERNAL_CWCTYPE +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x121) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cwctype) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x121) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CWCTYPE */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/deque b/sdk/tlibstdcxx/stlport/deque new file mode 100644 index 0000000000..448f159b7f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/deque @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_DEQUE + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x22 +# include +# define _STLP_DEQUE +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x22) +# ifndef _STLP_INTERNAL_DEQUE_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x22) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(deque) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x22) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_DEQUE */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/errno.h b/sdk/tlibstdcxx/stlport/errno.h new file mode 100644 index 0000000000..0f8a15bff6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/errno.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x205 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x205) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#ifdef _STLP_WCE +/* only show message when directly including this file in a non-library build */ +# if !defined(__BUILDING_STLPORT) && (_STLP_OUTERMOST_HEADER_ID == 0x205) +# pragma message("eMbedded Visual C++ 3 and .NET don't have a errno.h header; STLport won't include native errno.h here") +# endif +#else +# ifndef errno +/* We define the following macro first to guaranty the header reentrancy: */ +# define _STLP_NATIVE_ERRNO_H_INCLUDED +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(errno.h) +# endif +# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x590) && defined (__cplusplus) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::__errno; +_STLP_END_NAMESPACE +# endif +# endif /* errno */ + +# if !defined (_STLP_SGX_CONFIG) && !defined (_STLP_NATIVE_ERRNO_H_INCLUDED) +/* If errno has been defined before inclusion of native errno.h including it from STLport errno.h + * becomes impossible because if: + * #define errno foo + * then + * #include _STLP_NATIVE_C_HEADER(errno.h) + * becomes: + * #include _STLP_NATIVE_C_HEADER(foo.h) + * + * To fix this problem you have to find where this definition comes from and include errno.h before it. + */ +# error errno has been defined before inclusion of errno.h header. +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x205) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif + +/* Local Variables: + * mode: C + * End: + */ diff --git a/sdk/tlibstdcxx/stlport/exception b/sdk/tlibstdcxx/stlport/exception new file mode 100644 index 0000000000..47822e9154 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/exception @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +// This header exists solely for portability. Normally it just includes +// the native header . + +#ifndef _STLP_EXCEPTION + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x423 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x423) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_EXCEPTION +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x423) && !defined (_STLP_DONT_POP_HEADER_ID) +# ifndef _STLP_INTERNAL_EXCEPTION +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x423) || defined (_STLP_DONT_POP_HEADER_ID) || defined (_STLP_IMPORT_VENDOR_STD) +/* If we are here it means that we are in an include called + * from the native lib which means that we can simply forward this + * call to the native exception header: + */ +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# if defined (__DMC__) && (_STLP_OUTERMOST_HEADER_ID == 0x874) +// Workaround to DMC harcoded typeinfo.h inclusion. +# include <../include/exception> +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception) +# endif +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x423) +# if !defined(_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +#endif /* _STLP_EXCEPTION */ + + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/float.h b/sdk/tlibstdcxx/stlport/float.h new file mode 100644 index 0000000000..70fe3ade9d --- /dev/null +++ b/sdk/tlibstdcxx/stlport/float.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x203 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x203) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#elif (_STLP_OUTERMOST_HEADER_ID == 0x203) +# error This header is only reentrant once, it should be modified if it has to be included more. +#endif + +#if defined (_STLP_WCE_EVC3) +struct _exception; +#endif + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +#else +# include _STLP_NATIVE_C_HEADER(float.h) +#endif + +#if !defined (__linux__) +# if defined(__BORLANDC__) && defined (__cplusplus) && (__BORLANDC__ >= 0x560) +_STLP_BEGIN_NAMESPACE +using ::_max_dble; +using ::_max_flt; +using ::_max_ldble; +using ::_tiny_ldble; +_STLP_END_NAMESPACE +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x203) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif diff --git a/sdk/tlibstdcxx/stlport/functional b/sdk/tlibstdcxx/stlport/functional new file mode 100644 index 0000000000..27e37ab983 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/functional @@ -0,0 +1,148 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_FUNCTIONAL + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x27 +# include +# define _STLP_FUNCTIONAL +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x27) +# ifndef _STLP_INTERNAL_FUNCTION_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x27) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(functional) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x27) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#if !defined(_STLP_NO_EXTENSIONS) && defined(_STLP_USE_BOOST_SUPPORT) + +#include +#include +#include +#include +#include + +namespace boost { + +template class reference_wrapper; +template reference_wrapper const ref(T &); +template inline reference_wrapper const cref(T const &); + +template struct result_of; + +namespace _mfi { +template class dm; +} + +template _mfi::dm mem_fn(R T::*f); + +} // namespace boost + +_STLP_BEGIN_NAMESPACE + +namespace tr1 { + +using ::boost::reference_wrapper; +using ::boost::ref; +using ::boost::cref; + +using ::boost::result_of; + +using ::boost::mem_fn; + +using ::boost::bind; + +namespace placeholders { + using ::_1; + using ::_2; + using ::_3; + using ::_4; + using ::_5; + using ::_6; + using ::_7; + using ::_8; + using ::_9; +} // placeholders + +} // namespace tr1 + +_STLP_END_NAMESPACE + +#endif // !_STLP_NO_EXTENSIONS && _STLP_USE_BOOST_SUPPORT + +#endif /* _STLP_FUNCTIONAL */ + +#if !defined(_STLP_FUNCTIONAL_FUN) && !defined(_STLP_NO_EXTENSIONS) && defined(_STLP_USE_BOOST_SUPPORT) + +#ifndef BOOST_FUNCTION_NUM_ARGS // avoid recursive includes + +// #ifdef BOOST_FUNCTION_BASE_HEADER +// #undef BOOST_FUNCTION_BASE_HEADER +// #endif + +// #ifdef BOOST_FUNCTION_PROLOGUE_HPP +// #undef BOOST_FUNCTION_PROLOGUE_HPP +// #endif + +#define _STLP_FUNCTIONAL_FUN + +#ifndef BOOST_FUNCTION_BASE_HEADER // avoid recursive includes +# include +#else +namespace boost { +class bad_function_call; +template +class function; +template +void swap(function& f1, function& f2); +} +#endif + +_STLP_BEGIN_NAMESPACE + +namespace tr1 { + +using ::boost::bad_function_call; +using ::boost::function; +using ::boost::swap; + +} // namespace tr1 + +_STLP_END_NAMESPACE + +#endif // !BOOST_FUNCTION_NUM_ARGS + +#endif // !_STLP_FUNCTIONAL_REF && !_STLP_NO_EXTENSIONS && _STLP_USE_BOOST_SUPPORT + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/iso646.h b/sdk/tlibstdcxx/stlport/iso646.h new file mode 100644 index 0000000000..858863aef6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/iso646.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x204 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x204) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +/* evc3 doesn't have iso646.h */ +#if !defined (_STLP_WCE_EVC3) && !defined (__BORLANDC__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(iso646.h) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x204) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif + diff --git a/sdk/tlibstdcxx/stlport/iterator b/sdk/tlibstdcxx/stlport/iterator new file mode 100644 index 0000000000..f8d3deee7c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/iterator @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_ITERATOR + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x38 +# include +# define _STLP_ITERATOR +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x38) +# ifndef _STLP_INTERNAL_ITERATOR_H +# include +# endif + +# ifndef _STLP_INTERNAL_STREAM_ITERATOR_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x38) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(iterator) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x38) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_ITERATOR */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/limits b/sdk/tlibstdcxx/stlport/limits new file mode 100644 index 0000000000..5333b14fdd --- /dev/null +++ b/sdk/tlibstdcxx/stlport/limits @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_LIMITS + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x39 +# include +# define _STLP_LIMITS +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x39) +# ifndef _STLP_INTERNAL_LIMITS +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x39) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(limits) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x39) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_LIMITS */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/limits.h b/sdk/tlibstdcxx/stlport/limits.h new file mode 100644 index 0000000000..aab553b654 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/limits.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x201 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x201) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if defined(_STLP_WCE_EVC3) +struct _exception; +#endif + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +#else +# include _STLP_NATIVE_C_HEADER(limits.h) +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x201) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif diff --git a/sdk/tlibstdcxx/stlport/list b/sdk/tlibstdcxx/stlport/list new file mode 100644 index 0000000000..647a8be5d0 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/list @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_LIST + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x40 +# include +# define _STLP_LIST +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x40) +# ifndef _STLP_INTERNAL_LIST_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x40) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(list) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x40) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_LIST */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/map b/sdk/tlibstdcxx/stlport/map new file mode 100644 index 0000000000..f30c400c55 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/map @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_MAP + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x43 +# include +# define _STLP_MAP +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x43) +# ifndef _STLP_INTERNAL_MAP_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x43) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(map) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x43) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_MAP */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/math.h b/sdk/tlibstdcxx/stlport/math.h new file mode 100644 index 0000000000..32b666f05d --- /dev/null +++ b/sdk/tlibstdcxx/stlport/math.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x244 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x244) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if !defined (exception) && (!defined (__KCC) || (__KCC_VERSION < 4000)) && \ + !(defined(__IBMCPP__) && (500 <= __IBMCPP__)) && !defined(_STLP_WCE_EVC3) +# define _STLP_EXCEPTION_WAS_REDEFINED 1 +# define exception __math_exception +#endif + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +#else +# include _STLP_NATIVE_C_HEADER(math.h) +#endif + +#if defined (_STLP_EXCEPTION_WAS_REDEFINED) +# undef exception +# undef _STLP_EXCEPTION_WAS_REDEFINED +#endif + +#ifdef _STLP_WCE_EVC3 +# undef _exception +# define _exception exception +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x244) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + diff --git a/sdk/tlibstdcxx/stlport/memory b/sdk/tlibstdcxx/stlport/memory new file mode 100644 index 0000000000..3c0ceb38bc --- /dev/null +++ b/sdk/tlibstdcxx/stlport/memory @@ -0,0 +1,130 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_MEMORY + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x46 +# include +# define _STLP_MEMORY +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x46) +# ifndef _STLP_INTERNAL_ALLOC_H +# include +# endif + +# ifndef _STLP_INTERNAL_TEMPBUF_H +# include +# endif + +# ifndef _STLP_INTERNAL_RAW_STORAGE_ITER_H +# include +# endif + +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x46) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (__MSL__) +# include _STLP_NATIVE_HEADER(limits) +# endif + +# if !defined(_STLP_NO_EXTENSIONS) && defined(_STLP_USE_BOOST_SUPPORT) +# define BOOST_TR1_MEMORY_INCLUDED +# define BOOST_TR1_FULL_MEMORY_INCLUDED +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(memory) +# endif + +# if defined (__MSL__) && (__MSL__ >= 0x2405 && __MSL__ < 0x5201) +/* 980401 vss MSL 2.4 Pro 3 Release */ +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x46) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#if !defined(_STLP_NO_EXTENSIONS) && defined(_STLP_USE_BOOST_SUPPORT) + +namespace boost { + +class bad_weak_ptr; +template class shared_ptr; +template class weak_ptr; +template class enable_shared_from_this; +template D * get_deleter(shared_ptr const & p); +template shared_ptr static_pointer_cast(shared_ptr const & r); +template shared_ptr const_pointer_cast(shared_ptr const & r); +template shared_ptr dynamic_pointer_cast(shared_ptr const & r); +template void swap(weak_ptr & a, weak_ptr & b); +template void swap(shared_ptr & a, shared_ptr & b); + +namespace detail{ +class shared_count; +class weak_count; +} + +} // namespace boost + +# ifndef BOOST_SHARED_PTR_HPP_INCLUDED +# include +# endif +# ifndef BOOST_WEAK_PTR_HPP_INCLUDED +# include +# endif +# ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED +# include +# endif + +_STLP_BEGIN_NAMESPACE + +namespace tr1 { + +using ::boost::bad_weak_ptr; +using ::boost::shared_ptr; +using ::boost::swap; +using ::boost::static_pointer_cast; +using ::boost::dynamic_pointer_cast; +using ::boost::const_pointer_cast; +using ::boost::get_deleter; +using ::boost::weak_ptr; +using ::boost::enable_shared_from_this; + +// shared_ptr IO +// weak_ptr IO + +} // namespace tr1 + +_STLP_END_NAMESPACE + +#endif /* !_STLP_NO_EXTENSIONS && _STLP_USE_BOOST_SUPPORT */ + +#endif /* _STLP_MEMORY */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/new b/sdk/tlibstdcxx/stlport/new new file mode 100644 index 0000000000..974ca4480f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/new @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_NEW_HEADER + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x447 +# define _STLP_NEW_HEADER +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x447) +# ifndef _STLP_NEW_H_HEADER +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x447) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(new) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x447) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_NEW */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/new.h b/sdk/tlibstdcxx/stlport/new.h new file mode 100644 index 0000000000..0a9bf33e88 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/new.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x848 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x848) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if !defined(_STLP_NO_NEW_HEADER) +# if defined (__BORLANDC__) +# include +# elif defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800 && !defined(_MSC_VER)) +# include _STLP_NATIVE_OLD_STREAMS_HEADER(new.h) +# else +# if defined (__GNUC__) && (__GNUC__ >= 3) +# include _STLP_NATIVE_OLD_STREAMS_HEADER(new.h) +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(new.h) +# endif +# endif +#endif /* !defined(_STLP_NO_NEW_HEADER) */ + +#if (_STLP_OUTERMOST_HEADER_ID == 0x848) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/numeric b/sdk/tlibstdcxx/stlport/numeric new file mode 100644 index 0000000000..79e46471bd --- /dev/null +++ b/sdk/tlibstdcxx/stlport/numeric @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_NUMERIC + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x49 +# include +# define _STLP_NUMERIC +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x49) +# ifndef _STLP_INTERNAL_NUMERIC_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x49) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(numeric) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x49) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_NUMERIC */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/queue b/sdk/tlibstdcxx/stlport/queue new file mode 100644 index 0000000000..6acd63fdd0 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/queue @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_QUEUE + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x53 +# include +# define _STLP_QUEUE +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x53) +# ifndef _STLP_INTERNAL_QUEUE_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x53) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(queue) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x53) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_QUEUE */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/set b/sdk/tlibstdcxx/stlport/set new file mode 100644 index 0000000000..ed79d89fb1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/set @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_SET + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x55 +# include +# define _STLP_SET +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x55) +# ifndef _STLP_INTERNAL_SET_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x55) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(set) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x55) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_SET */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stack b/sdk/tlibstdcxx/stlport/stack new file mode 100644 index 0000000000..253b31d2f7 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stack @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STACK + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x60 +# include +# define _STLP_STACK +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x60) +# ifndef _STLP_INTERNAL_STACK_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x60) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(stack) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x60) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_STACK */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stdarg.h b/sdk/tlibstdcxx/stlport/stdarg.h new file mode 100644 index 0000000000..368e6724b3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stdarg.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include stdarg.h, which results in warnings and errors + */ +#if !defined (RC_INVOKED) + +# if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x261 +# include +# elif (_STLP_OUTERMOST_HEADER_ID == 0x261) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(stdarg.h) +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x261) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif +#endif /* RC_INVOKED */ diff --git a/sdk/tlibstdcxx/stlport/stddef.h b/sdk/tlibstdcxx/stlport/stddef.h new file mode 100644 index 0000000000..f959c23af4 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stddef.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x262 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x262) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if defined (_MSC_VER) || defined (__DMC__) +/* Native stddef.h contains errno macro definition making inclusion of native + * errno.h in STLport errno.h impossible. We are then forced to include errno.h + * first. + */ +# include "errno.h" +#endif + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +#else +# include _STLP_NATIVE_C_HEADER(stddef.h) +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x262) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif diff --git a/sdk/tlibstdcxx/stlport/stdexcept b/sdk/tlibstdcxx/stlport/stdexcept new file mode 100644 index 0000000000..dbb96b9a91 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stdexcept @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STDEXCEPT + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x63 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x63) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_STDEXCEPT +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x63) +# ifndef _STLP_INTERNAL_STDEXCEPT +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x63) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(stdexcept) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x63) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +#endif /* _STLP_STDEXCEPT */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stdio.h b/sdk/tlibstdcxx/stlport/stdio.h new file mode 100644 index 0000000000..e2dbdeae3a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stdio.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include stdarg.h, which results in warnings and errors + */ +#if !defined(RC_INVOKED) + +# ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x264 +# include +# elif (_STLP_OUTERMOST_HEADER_ID == 0x264) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(stdio.h) +# endif + +# if defined (__SUNPRO_CC) && !defined (_STRUCT_FILE) +# define _STRUCT_FILE +# endif + +# if defined (__BORLANDC__) && defined (__cplusplus) && !defined (__linux__) +_STLP_BEGIN_NAMESPACE +using __std_alias::_streams; +_STLP_END_NAMESPACE +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x264) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif + +#endif /* RC_INVOKED */ diff --git a/sdk/tlibstdcxx/stlport/stdlib.h b/sdk/tlibstdcxx/stlport/stdlib.h new file mode 100644 index 0000000000..fd55f8a8fb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stdlib.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include stdlib.h, which results in warnings and errors + */ +#if !defined (RC_INVOKED) + +# if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x265 +# include +# elif (_STLP_OUTERMOST_HEADER_ID == 0x265) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# endif + +# if defined (_STLP_MSVC_LIB) || (defined (__GNUC__) && defined (__MINGW32__)) || \ + defined (__BORLANDC__) || defined (__DMC__) || \ + (defined (__HP_aCC) && defined (_REENTRANT)) +/* Native stdlib.h contains errno macro definition making inclusion of native + * errno.h in STLport errno.h impossible. We are then forced to include errno.h + * first. + */ +# include "errno.h" +# endif + +/* + forward-declaration for _exception struct; prevents warning message + ../include/stdlib.h(817) : warning C4115: '_exception' : named type definition in parentheses +*/ +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(stdlib.h) +# endif + +/* on evc3/evc4 including stdlib.h also defines setjmp macro */ +# if defined (_STLP_WCE) +# define _STLP_NATIVE_SETJMP_H_INCLUDED +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x265) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif + +#endif /* RC_INVOKED */ diff --git a/sdk/tlibstdcxx/stlport/stl/_abbrevs.h b/sdk/tlibstdcxx/stlport/stl/_abbrevs.h new file mode 100644 index 0000000000..c4acac8b1f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_abbrevs.h @@ -0,0 +1,77 @@ +/* + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ABBREVS_H +# define _STLP_INTERNAL_ABBREVS_H + +// ugliness is intentional - to reduce conflicts +# define input_iterator_tag _In__ItT +# define output_iterator_tag _Ou__ItT +# define bidirectional_iterator_tag _Bd__ItT +# define random_access_iterator_tag _Ra__ItT +# define input_iterator _In__It +# define output_iterator _Ou__It +# define bidirectional_iterator _Bd__It +# define random_access_iterator _Ra__It +# define reverse_bidirectional_iterator _rBd__It +# define reverse_iterator _r__It +# define back_insert_iterator _bI__It +# define front_insert_iterator _fI__It +# define raw_storage_iterator _rS__It +# define _Const_traits _C_Tr +# define _Const_Const_traits _CC_Tr +# define _Nonconst_traits _N_Tr +# define _Nonconst_Const_traits _NC_Tr + +// ugliness is intentional - to reduce conflicts probability +# define __malloc_alloc M__A +# define __node_alloc D__A +# define __new_alloc N__A +# define __debug_alloc G__A +# define _STLP_alloc_proxy P__A + +# define _Deque_iterator_base _Dq__ItB +# define _Deque_iterator _Dq__It + +# define _Select1st _S1st +# define _Select2nd _S2nd +# define __move_source __m_s +# define _Vector_nonconst_traits _V_nct + +# define _Ht_iterator _Ht_It + +# define _List_node_base _L__NB +# define _List_iterator_base _L__ItB +# define _List_iterator _L__It + +# define _Slist_iterator_base _SL__ItB +# define _Slist_iterator _SL__It + +# define _Rb_tree_node_base _rbT__NB +# define _Rb_tree_node _rbT__N +# define _Rb_tree_base_iterator _rbT__It +# define _Rb_tree_base _rbT__B + +# if defined (__DMC__) && defined (_STLP_DEBUG) +# define _NonDbg_hashtable _Nd_Ht +# define _DBG_iter _d__It +# endif +#endif + diff --git a/sdk/tlibstdcxx/stlport/stl/_algo.c b/sdk/tlibstdcxx/stlport/stl/_algo.c new file mode 100644 index 0000000000..c92a7eeef9 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_algo.c @@ -0,0 +1,2040 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_ALGO_C +#define _STLP_ALGO_C + +#if !defined (_STLP_INTERNAL_ALGO_H) +# include +#endif + +#ifndef _STLP_INTERNAL_TEMPBUF_H +# include +#endif + +#ifdef _STLP_SGX_CONFIG +# include "sgx_trts.h" +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void __merge_without_buffer(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last, + _Distance __len1, _Distance __len2, + _Compare __comp); + + +template +_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1, + _BidirectionalIter1 __last1, + _BidirectionalIter2 __first2, + _BidirectionalIter2 __last2, + _BidirectionalIter3 __result, + _Compare __comp); + +template +#if !(defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x420 )) +inline +#endif +const _Tp& __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) { + if (__a < __b) + if (__b < __c) + return __b; + else if (__a < __c) + return __c; + else + return __a; + else if (__a < __c) + return __a; + else if (__b < __c) + return __c; + else + return __b; +} + +template +#if !(defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x420 )) +inline +#endif +const _Tp& +__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) { + if (__comp(__a, __b)) { + _STLP_VERBOSE_ASSERT(!__comp(__b, __a), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + if (__comp(__b, __c)) { + _STLP_VERBOSE_ASSERT(!__comp(__c, __b), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return __b; + } + else if (__comp(__a, __c)) { + _STLP_VERBOSE_ASSERT(!__comp(__c, __a), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return __c; + } + else + return __a; + } + else if (__comp(__a, __c)) { + _STLP_VERBOSE_ASSERT(!__comp(__c, __a), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return __a; + } + else if (__comp(__b, __c)) { + _STLP_VERBOSE_ASSERT(!__comp(__c, __b), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return __c; + } + else + return __b; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + // Test for empty ranges + if (__first1 == __last1 || __first2 == __last2) + return __first1; + + // Test for a pattern of length 1. + _ForwardIter2 __p1(__first2); + + if ( ++__p1 == __last2 ) + return find(__first1, __last1, *__first2); + + // General case. + + for ( ; ; ) { // __first1 != __last1 will be checked in find below + __first1 = find(__first1, __last1, *__first2); + if (__first1 == __last1) + return __last1; + + _ForwardIter2 __p = __p1; + _ForwardIter1 __current = __first1; + if (++__current == __last1) + return __last1; + + while (*__current == *__p) { + if (++__p == __last2) + return __first1; + if (++__current == __last1) + return __last1; + } + + ++__first1; + } + return __first1; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_RandomAccessIter __search_n(_RandomAccessIter __first, _RandomAccessIter __last, + _Integer __count, const _Tp& __val, _BinaryPred __pred, + _Distance*, const random_access_iterator_tag &) +{ + _Distance __tailSize = __last - __first; + const _Distance __pattSize = __count; + const _Distance __skipOffset = __pattSize - 1; + _RandomAccessIter __backTrack; + _Distance __remainder, __prevRemainder; + + for ( _RandomAccessIter __lookAhead = __first + __skipOffset; __tailSize >= __pattSize; __lookAhead += __pattSize ) { // the main loop... + //__lookAhead here is always pointing to the last element of next possible match. + __tailSize -= __pattSize; + + while ( !__pred(*__lookAhead, __val) ) { // the skip loop... + if (__tailSize < __pattSize) + return __last; + + __lookAhead += __pattSize; + __tailSize -= __pattSize; + } + + if ( __skipOffset == 0 ) { + return (__lookAhead - __skipOffset); //Success + } + + __remainder = __skipOffset; + + for (__backTrack = __lookAhead; __pred(*--__backTrack, __val); ) { + if (--__remainder == 0) + return (__lookAhead - __skipOffset); //Success + } + + if (__remainder > __tailSize) + return __last; //failure + + __lookAhead += __remainder; + __tailSize -= __remainder; + + while ( __pred(*__lookAhead, __val) ) { + __prevRemainder = __remainder; + __backTrack = __lookAhead; + + do { + if (--__remainder == 0) + return (__lookAhead - __skipOffset); //Success + } while (__pred(*--__backTrack, __val)); + + //adjust remainder for next comparison + __remainder += __pattSize - __prevRemainder; + + if (__remainder > __tailSize) + return __last; //failure + + __lookAhead += __remainder; + __tailSize -= __remainder; + } + + //__lookAhead here is always pointing to the element of the last mismatch. + } + + return __last; //failure +} + +template +_ForwardIter __search_n(_ForwardIter __first, _ForwardIter __last, + _Integer __count, const _Tp& __val, _BinaryPred __pred, + _Distance*, const forward_iterator_tag &) { + for (; (__first != __last) && !__pred(*__first, __val); ++__first) {} + while (__first != __last) { + _Integer __n = __count - 1; + _ForwardIter __i = __first; + ++__i; + while (__i != __last && __n != 0 && __pred(*__i, __val)) { + ++__i; + --__n; + } + if (__n == 0) + return __first; + else if (__i != __last) + for (__first = ++__i; (__first != __last) && !__pred(*__first, __val); ++__first) {} + else + break; + } + return __last; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +// search_n. Search for __count consecutive copies of __val. +template +_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, + _Integer __count, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__count <= 0) + return __first; + if (__count == 1) + //We use find when __count == 1 to use potential find overload. + return find(__first, __last, __val); + return _STLP_PRIV __search_n(__first, __last, __count, __val, equal_to<_Tp>(), + _STLP_DISTANCE_TYPE(__first, _ForwardIter), + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); +} + +template +_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, + _Integer __count, const _Tp& __val, + _BinaryPred __binary_pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__count <= 0) + return __first; + return _STLP_PRIV __search_n(__first, __last, __count, __val, __binary_pred, + _STLP_DISTANCE_TYPE(__first, _ForwardIter), + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); +} + +template +_ForwardIter1 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + return _STLP_PRIV __find_end(__first1, __last1, __first2, __last2, +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + _STLP_ITERATOR_CATEGORY(__first1, _ForwardIter1), + _STLP_ITERATOR_CATEGORY(__first2, _ForwardIter2), +#else + forward_iterator_tag(), + forward_iterator_tag(), +#endif + _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first1, _ForwardIter1)) + ); +} + +// unique and unique_copy +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP _OutputIterator +__unique_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _BinaryPredicate __binary_pred, _Tp*) { + _Tp __val = *__first; + *__result = __val; + while (++__first != __last) + if (!__binary_pred(__val, *__first)) { + __val = *__first; + *++__result = __val; + } + return ++__result; +} + +template +inline _OutputIter +__unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result, + _BinaryPredicate __binary_pred, const output_iterator_tag &) { + return _STLP_PRIV __unique_copy(__first, __last, __result, __binary_pred, + _STLP_VALUE_TYPE(__first, _InputIter)); +} + +template +_STLP_INLINE_LOOP _ForwardIter +__unique_copy(_InputIter __first, _InputIter __last, _ForwardIter __result, + _BinaryPredicate __binary_pred, const forward_iterator_tag &) { + *__result = *__first; + while (++__first != __last) + if (!__binary_pred(*__result, *__first)) *++__result = *__first; + return ++__result; +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline _BidirectionalIterator +__unique_copy(_InputIterator __first, _InputIterator __last, + _BidirectionalIterator __result, _BinaryPredicate __binary_pred, + const bidirectional_iterator_tag &) { + return _STLP_PRIV __unique_copy(__first, __last, __result, __binary_pred, forward_iterator_tag()); +} + +template +inline _RandomAccessIterator +__unique_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result, _BinaryPredicate __binary_pred, + const random_access_iterator_tag &) { + return _STLP_PRIV __unique_copy(__first, __last, __result, __binary_pred, forward_iterator_tag()); +} +#endif /* _STLP_NONTEMPL_BASE_MATCH_BUG */ + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_OutputIter +unique_copy(_InputIter __first, _InputIter __last, _OutputIter __result) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return __result; + return _STLP_PRIV __unique_copy(__first, __last, __result, + _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first, _InputIter)), + _STLP_ITERATOR_CATEGORY(__result, _OutputIter)); +} + +template +_OutputIter +unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result, + _BinaryPredicate __binary_pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return __result; + return _STLP_PRIV __unique_copy(__first, __last, __result, __binary_pred, + _STLP_ITERATOR_CATEGORY(__result, _OutputIter)); +} + +// rotate and rotate_copy, and their auxiliary functions +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_ForwardIter __rotate_aux(_ForwardIter __first, + _ForwardIter __middle, + _ForwardIter __last, + _Distance*, + const forward_iterator_tag &) { + if (__first == __middle) + return __last; + if (__last == __middle) + return __first; + + _ForwardIter __first2 = __middle; + do { + _STLP_STD::swap(*__first++, *__first2++); + if (__first == __middle) + __middle = __first2; + } while (__first2 != __last); + + _ForwardIter __new_middle = __first; + + __first2 = __middle; + + while (__first2 != __last) { + _STLP_STD::swap (*__first++, *__first2++); + if (__first == __middle) + __middle = __first2; + else if (__first2 == __last) + __first2 = __middle; + } + + return __new_middle; +} + +template +_BidirectionalIter __rotate_aux(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last, + _Distance*, + const bidirectional_iterator_tag &) { + if (__first == __middle) + return __last; + if (__last == __middle) + return __first; + + _STLP_PRIV __reverse(__first, __middle, bidirectional_iterator_tag()); + _STLP_PRIV __reverse(__middle, __last, bidirectional_iterator_tag()); + + while (__first != __middle && __middle != __last) + _STLP_STD::swap(*__first++, *--__last); + + if (__first == __middle) { + _STLP_PRIV __reverse(__middle, __last, bidirectional_iterator_tag()); + return __last; + } + else { + _STLP_PRIV __reverse(__first, __middle, bidirectional_iterator_tag()); + return __first; + } +} + +// rotate and rotate_copy, and their auxiliary functions +template +_STLP_INLINE_LOOP +_EuclideanRingElement __gcd(_EuclideanRingElement __m, + _EuclideanRingElement __n) { + while (__n != 0) { + _EuclideanRingElement __t = __m % __n; + __m = __n; + __n = __t; + } + return __m; +} + +template +_RandomAccessIter __rotate_aux(_RandomAccessIter __first, + _RandomAccessIter __middle, + _RandomAccessIter __last, + _Distance *, _Tp *) { + + _Distance __n = __last - __first; + _Distance __k = __middle - __first; + _Distance __l = __n - __k; + _RandomAccessIter __result = __first + (__last - __middle); + + if (__k == 0) /* __first == middle */ + return __last; + + if (__k == __l) { + _STLP_STD::swap_ranges(__first, __middle, __middle); + return __result; + } + + _Distance __d = _STLP_PRIV __gcd(__n, __k); + + for (_Distance __i = 0; __i < __d; __i++) { + _Tp __tmp = *__first; + _RandomAccessIter __p = __first; + + if (__k < __l) { + for (_Distance __j = 0; __j < __l/__d; __j++) { + if (__p > __first + __l) { + *__p = *(__p - __l); + __p -= __l; + } + + *__p = *(__p + __k); + __p += __k; + } + } + + else { + for (_Distance __j = 0; __j < __k/__d - 1; __j ++) { + if (__p < __last - __k) { + *__p = *(__p + __k); + __p += __k; + } + + *__p = * (__p - __l); + __p -= __l; + } + } + + *__p = __tmp; + ++__first; + } + + return __result; +} + +template +inline _RandomAccessIter +__rotate_aux(_RandomAccessIter __first, _RandomAccessIter __middle, _RandomAccessIter __last, + _Distance * __dis, const random_access_iterator_tag &) { + return _STLP_PRIV __rotate_aux(__first, __middle, __last, + __dis, _STLP_VALUE_TYPE(__first, _RandomAccessIter)); +} + +template +_ForwardIter +__rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last) { + _STLP_DEBUG_CHECK(__check_range(__first, __middle)) + _STLP_DEBUG_CHECK(__check_range(__middle, __last)) + return __rotate_aux(__first, __middle, __last, + _STLP_DISTANCE_TYPE(__first, _ForwardIter), + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last) { + _STLP_PRIV __rotate(__first, __middle, __last); +} + +// Return a random number in the range [0, __n). This function encapsulates +// whether we're using rand (part of the standard C library) or lrand48 +// (not standard, but a much better choice whenever it's available). +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _Distance __random_number(_Distance __n) { +#ifdef _STLP_NO_DRAND48 +# ifdef _STLP_SGX_CONFIG + _Distance __rand; + if (SGX_SUCCESS != sgx_read_rand(__REINTERPRET_CAST(unsigned char*, &__rand), sizeof(__rand))) { + _STLP_ABORT(); + } + return abs(__rand) % __n; +# else + return rand() % __n; +# endif +#else + return lrand48() % __n; +#endif +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void random_shuffle(_RandomAccessIter __first, + _RandomAccessIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return; + for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) + iter_swap(__i, __first + _STLP_PRIV __random_number((__i - __first) + 1)); +} + +template +void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last, + _RandomNumberGenerator &__rand) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return; + for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) + iter_swap(__i, __first + __rand((__i - __first) + 1)); +} + +#if !defined (_STLP_NO_EXTENSIONS) +// random_sample and random_sample_n (extensions, not part of the standard). +template +_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, + _OutputIter __out_ite, const _Distance __n) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _Distance __remaining = _STLP_STD::distance(__first, __last); + _Distance __m = (min) (__n, __remaining); + + while (__m > 0) { + if (_STLP_PRIV __random_number(__remaining) < __m) { + *__out_ite = *__first; + ++__out_ite; + --__m; + } + + --__remaining; + ++__first; + } + return __out_ite; +} + + +template +_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, + _OutputIter __out_ite, const _Distance __n, + _RandomNumberGenerator& __rand) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _Distance __remaining = _STLP_STD::distance(__first, __last); + _Distance __m = (min) (__n, __remaining); + + while (__m > 0) { + if (__rand(__remaining) < __m) { + *__out_ite = *__first; + ++__out_ite; + --__m; + } + + --__remaining; + ++__first; + } + return __out_ite; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last, + _RandomAccessIter __out_ite, + const _Distance __n) { + _Distance __m = 0; + _Distance __t = __n; + for ( ; __first != __last && __m < __n; ++__m, ++__first) + __out_ite[__m] = *__first; + + while (__first != __last) { + ++__t; + _Distance __M = __random_number(__t); + if (__M < __n) + __out_ite[__M] = *__first; + ++__first; + } + + return __out_ite + __m; +} + +template +_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last, + _RandomAccessIter __out_ite, + _RandomNumberGenerator& __rand, + const _Distance __n) { + _Distance __m = 0; + _Distance __t = __n; + for ( ; __first != __last && __m < __n; ++__m, ++__first) + __out_ite[__m] = *__first; + + while (__first != __last) { + ++__t; + _Distance __M = __rand(__t); + if (__M < __n) + __out_ite[__M] = *__first; + ++__first; + } + + return __out_ite + __m; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_RandomAccessIter +random_sample(_InputIter __first, _InputIter __last, + _RandomAccessIter __out_first, _RandomAccessIter __out_last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__out_first, __out_last)) + return _STLP_PRIV __random_sample(__first, __last, + __out_first, __out_last - __out_first); +} + +template +_RandomAccessIter +random_sample(_InputIter __first, _InputIter __last, + _RandomAccessIter __out_first, _RandomAccessIter __out_last, + _RandomNumberGenerator& __rand) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__out_first, __out_last)) + return _STLP_PRIV __random_sample(__first, __last, + __out_first, __rand, + __out_last - __out_first); +} + +#endif /* _STLP_NO_EXTENSIONS */ + +// partition, stable_partition, and their auxiliary functions +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP _ForwardIter __partition(_ForwardIter __first, + _ForwardIter __last, + _Predicate __pred, + const forward_iterator_tag &) { + if (__first == __last) return __first; + + while (__pred(*__first)) + if (++__first == __last) return __first; + + _ForwardIter __next = __first; + + while (++__next != __last) { + if (__pred(*__next)) { + _STLP_STD::swap(*__first, *__next); + ++__first; + } + } + return __first; +} + +template +_STLP_INLINE_LOOP _BidirectionalIter __partition(_BidirectionalIter __first, + _BidirectionalIter __last, + _Predicate __pred, + const bidirectional_iterator_tag &) { + for (;;) { + for (;;) { + if (__first == __last) + return __first; + else if (__pred(*__first)) + ++__first; + else + break; + } + --__last; + for (;;) { + if (__first == __last) + return __first; + else if (!__pred(*__last)) + --__last; + else + break; + } + iter_swap(__first, __last); + ++__first; + } +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline +_BidirectionalIter __partition(_BidirectionalIter __first, + _BidirectionalIter __last, + _Predicate __pred, + const random_access_iterator_tag &) { + return __partition(__first, __last, __pred, bidirectional_iterator_tag()); +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_ForwardIter partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __partition(__first, __last, __pred, _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); +} + + +/* __pred_of_first: false if we know that __pred(*__first) is false, + * true when we don't know the result of __pred(*__first). + * __not_pred_of_before_last: true if we know that __pred(*--__last) is true, + * false when we don't know the result of __pred(*--__last). + */ +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_ForwardIter __inplace_stable_partition(_ForwardIter __first, + _ForwardIter __last, + _Predicate __pred, _Distance __len, + bool __pred_of_first, bool __pred_of_before_last) { + if (__len == 1) + return (__pred_of_first && (__pred_of_before_last || __pred(*__first))) ? __last : __first; + _ForwardIter __middle = __first; + _Distance __half_len = __len / 2; + _STLP_STD::advance(__middle, __half_len); + return _STLP_PRIV __rotate(_STLP_PRIV __inplace_stable_partition(__first, __middle, __pred, __half_len, __pred_of_first, false), + __middle, + _STLP_PRIV __inplace_stable_partition(__middle, __last, __pred, __len - __half_len, true, __pred_of_before_last)); +} + +template +_ForwardIter __stable_partition_adaptive(_ForwardIter __first, + _ForwardIter __last, + _Predicate __pred, _Distance __len, + _Pointer __buffer, _Distance __buffer_size, + bool __pred_of_first, bool __pred_of_before_last) { + if (__len <= __buffer_size) { + _ForwardIter __result1 = __first; + _Pointer __result2 = __buffer; + if ((__first != __last) && (!__pred_of_first || __pred(*__first))) { + *__result2 = *__first; + ++__result2; ++__first; --__len; + } + for (; __first != __last ; ++__first, --__len) { + if (((__len == 1) && (__pred_of_before_last || __pred(*__first))) || + ((__len != 1) && __pred(*__first))){ + *__result1 = *__first; + ++__result1; + } + else { + *__result2 = *__first; + ++__result2; + } + } + _STLP_STD::copy(__buffer, __result2, __result1); + return __result1; + } + else { + _ForwardIter __middle = __first; + _Distance __half_len = __len / 2; + _STLP_STD::advance(__middle, __half_len); + return _STLP_PRIV __rotate(_STLP_PRIV __stable_partition_adaptive(__first, __middle, __pred, + __half_len, __buffer, __buffer_size, + __pred_of_first, false), + __middle, + _STLP_PRIV __stable_partition_adaptive(__middle, __last, __pred, + __len - __half_len, __buffer, __buffer_size, + true, __pred_of_before_last)); + } +} + +template +inline _ForwardIter +__stable_partition_aux_aux(_ForwardIter __first, _ForwardIter __last, + _Predicate __pred, _Tp*, _Distance*, bool __pred_of_before_last) { + _Temporary_buffer<_ForwardIter, _Tp> __buf(__first, __last); + _STLP_MPWFIX_TRY //*TY 06/01/2000 - they forget to call dtor for _Temporary_buffer if no try/catch block is present + return (__buf.size() > 0) ? + __stable_partition_adaptive(__first, __last, __pred, + _Distance(__buf.requested_size()), + __buf.begin(), __buf.size(), + false, __pred_of_before_last) : + __inplace_stable_partition(__first, __last, __pred, + _Distance(__buf.requested_size()), + false, __pred_of_before_last); + _STLP_MPWFIX_CATCH //*TY 06/01/2000 - they forget to call dtor for _Temporary_buffer if no try/catch block is present +} + +template +_ForwardIter +__stable_partition_aux(_ForwardIter __first, _ForwardIter __last, _Predicate __pred, + const forward_iterator_tag &) { + return __stable_partition_aux_aux(__first, __last, __pred, + _STLP_VALUE_TYPE(__first, _ForwardIter), + _STLP_DISTANCE_TYPE(__first, _ForwardIter), false); +} + +template +_BidirectIter +__stable_partition_aux(_BidirectIter __first, _BidirectIter __last, _Predicate __pred, + const bidirectional_iterator_tag &) { + for (--__last;;) { + if (__first == __last) + return __first; + else if (!__pred(*__last)) + --__last; + else + break; + } + ++__last; + //Here we know that __pred(*--__last) is true + return __stable_partition_aux_aux(__first, __last, __pred, + _STLP_VALUE_TYPE(__first, _BidirectIter), + _STLP_DISTANCE_TYPE(__first, _BidirectIter), true); +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +_BidirectIter +__stable_partition_aux(_BidirectIter __first, _BidirectIter __last, _Predicate __pred, + const random_access_iterator_tag &) { + return __stable_partition_aux(__first, __last, __pred, bidirectional_iterator_tag()); +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_ForwardIter +stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for (;;) { + if (__first == __last) + return __first; + else if (__pred(*__first)) + ++__first; + else + break; + } + return _STLP_PRIV __stable_partition_aux(__first, __last, __pred, + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, + _RandomAccessIter __last, + _Tp __pivot, _Compare __comp) { + for (;;) { + while (__comp(*__first, __pivot)) { + _STLP_VERBOSE_ASSERT(!__comp(__pivot, *__first), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + ++__first; + } + --__last; + while (__comp(__pivot, *__last)) { + _STLP_VERBOSE_ASSERT(!__comp(*__last, __pivot), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + --__last; + } + if (!(__first < __last)) + return __first; + iter_swap(__first, __last); + ++__first; + } +} + +// sort() and its auxiliary functions. +#define __stl_threshold 16 + +template +void __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val, + _Compare __comp) { + _RandomAccessIter __next = __last; + --__next; + while (__comp(__val, *__next)) { + _STLP_VERBOSE_ASSERT(!__comp(*__next, __val), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *__last = *__next; + __last = __next; + --__next; + } + *__last = __val; +} + +template +inline void __linear_insert(_RandomAccessIter __first, + _RandomAccessIter __last, _Tp __val, _Compare __comp) { + //*TY 12/26/1998 - added __val as a paramter + // _Tp __val = *__last; //*TY 12/26/1998 - __val supplied by caller + if (__comp(__val, *__first)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first, __val), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + copy_backward(__first, __last, __last + 1); + *__first = __val; + } + else + __unguarded_linear_insert(__last, __val, __comp); +} + +template +void __insertion_sort(_RandomAccessIter __first, + _RandomAccessIter __last, + _Tp *, _Compare __comp) { + if (__first == __last) return; + for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) + __linear_insert<_RandomAccessIter, _Tp, _Compare>(__first, __i, *__i, __comp); //*TY 12/26/1998 - supply *__i as __val +} + +template +void __unguarded_insertion_sort_aux(_RandomAccessIter __first, + _RandomAccessIter __last, + _Tp*, _Compare __comp) { + for (_RandomAccessIter __i = __first; __i != __last; ++__i) + __unguarded_linear_insert<_RandomAccessIter, _Tp, _Compare>(__i, *__i, __comp); +} + +template +inline void __unguarded_insertion_sort(_RandomAccessIter __first, + _RandomAccessIter __last, + _Compare __comp) { + __unguarded_insertion_sort_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), __comp); +} + +template +void __final_insertion_sort(_RandomAccessIter __first, + _RandomAccessIter __last, _Compare __comp) { + if (__last - __first > __stl_threshold) { + __insertion_sort(__first, __first + __stl_threshold, _STLP_VALUE_TYPE(__first,_RandomAccessIter), __comp); + __unguarded_insertion_sort(__first + __stl_threshold, __last, __comp); + } + else + __insertion_sort(__first, __last, _STLP_VALUE_TYPE(__first,_RandomAccessIter), __comp); +} + +template +void __introsort_loop(_RandomAccessIter __first, + _RandomAccessIter __last, _Tp*, + _Size __depth_limit, _Compare __comp) { + while (__last - __first > __stl_threshold) { + if (__depth_limit == 0) { + partial_sort(__first, __last, __last, __comp); + return; + } + --__depth_limit; + _RandomAccessIter __cut = + __unguarded_partition(__first, __last, + _Tp(__median(*__first, + *(__first + (__last - __first)/2), + *(__last - 1), __comp)), + __comp); + __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit, __comp); + __last = __cut; + } +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void sort(_RandomAccessIter __first, _RandomAccessIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first != __last) { + _STLP_PRIV __introsort_loop(__first, __last, + _STLP_VALUE_TYPE(__first, _RandomAccessIter), + _STLP_PRIV __lg(__last - __first) * 2, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter))); + _STLP_PRIV __final_insertion_sort(__first, __last, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter))); + } +} + +template +void sort(_RandomAccessIter __first, _RandomAccessIter __last, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first != __last) { + _STLP_PRIV __introsort_loop(__first, __last, + _STLP_VALUE_TYPE(__first, _RandomAccessIter), + _STLP_PRIV __lg(__last - __first) * 2, __comp); + _STLP_PRIV __final_insertion_sort(__first, __last, __comp); + } +} + +// stable_sort() and its auxiliary functions. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void __inplace_stable_sort(_RandomAccessIter __first, + _RandomAccessIter __last, _Compare __comp) { + if (__last - __first < 15) { + __insertion_sort(__first, __last, _STLP_VALUE_TYPE(__first,_RandomAccessIter), __comp); + return; + } + _RandomAccessIter __middle = __first + (__last - __first) / 2; + __inplace_stable_sort(__first, __middle, __comp); + __inplace_stable_sort(__middle, __last, __comp); + __merge_without_buffer(__first, __middle, __last, + __middle - __first, + __last - __middle, + __comp); +} + +template +void __merge_sort_loop(_RandomAccessIter1 __first, + _RandomAccessIter1 __last, + _RandomAccessIter2 __result, _Distance __step_size, + _Compare __comp) { + _Distance __two_step = 2 * __step_size; + + while (__last - __first >= __two_step) { + __result = merge(__first, __first + __step_size, + __first + __step_size, __first + __two_step, + __result, + __comp); + __first += __two_step; + } + __step_size = (min) (_Distance(__last - __first), __step_size); + + merge(__first, __first + __step_size, + __first + __step_size, __last, + __result, + __comp); +} + +const int __stl_chunk_size = 7; + +template +void __chunk_insertion_sort(_RandomAccessIter __first, + _RandomAccessIter __last, + _Distance __chunk_size, _Compare __comp) { + while (__last - __first >= __chunk_size) { + __insertion_sort(__first, __first + __chunk_size, + _STLP_VALUE_TYPE(__first,_RandomAccessIter), __comp); + __first += __chunk_size; + } + __insertion_sort(__first, __last, _STLP_VALUE_TYPE(__first,_RandomAccessIter), __comp); +} + +template +void __merge_sort_with_buffer(_RandomAccessIter __first, + _RandomAccessIter __last, _Pointer __buffer, + _Distance*, _Compare __comp) { + _Distance __len = __last - __first; + _Pointer __buffer_last = __buffer + __len; + + _Distance __step_size = __stl_chunk_size; + __chunk_insertion_sort(__first, __last, __step_size, __comp); + + while (__step_size < __len) { + __merge_sort_loop(__first, __last, __buffer, __step_size, __comp); + __step_size *= 2; + __merge_sort_loop(__buffer, __buffer_last, __first, __step_size, __comp); + __step_size *= 2; + } +} + +template +_BidirectionalIter1 __rotate_adaptive(_BidirectionalIter1 __first, + _BidirectionalIter1 __middle, + _BidirectionalIter1 __last, + _Distance __len1, _Distance __len2, + _BidirectionalIter2 __buffer, + _Distance __buffer_size) { + if (__len1 > __len2 && __len2 <= __buffer_size) { + _BidirectionalIter2 __buffer_end = _STLP_STD::copy(__middle, __last, __buffer); + _STLP_STD::copy_backward(__first, __middle, __last); + return _STLP_STD::copy(__buffer, __buffer_end, __first); + } + else if (__len1 <= __buffer_size) { + _BidirectionalIter2 __buffer_end = _STLP_STD::copy(__first, __middle, __buffer); + _STLP_STD::copy(__middle, __last, __first); + return _STLP_STD::copy_backward(__buffer, __buffer_end, __last); + } + else + return _STLP_PRIV __rotate(__first, __middle, __last); +} + +template +void __merge_adaptive(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last, + _Distance __len1, _Distance __len2, + _Pointer __buffer, _Distance __buffer_size, + _Compare __comp) { + if (__len1 <= __len2 && __len1 <= __buffer_size) { + _Pointer __buffer_end = _STLP_STD::copy(__first, __middle, __buffer); + _STLP_STD::merge(__buffer, __buffer_end, __middle, __last, __first, __comp); + } + else if (__len2 <= __buffer_size) { + _Pointer __buffer_end = _STLP_STD::copy(__middle, __last, __buffer); + _STLP_PRIV __merge_backward(__first, __middle, __buffer, __buffer_end, __last, + __comp); + } + else { + _BidirectionalIter __first_cut = __first; + _BidirectionalIter __second_cut = __middle; + _Distance __len11 = 0; + _Distance __len22 = 0; + if (__len1 > __len2) { + __len11 = __len1 / 2; + _STLP_STD::advance(__first_cut, __len11); + __second_cut = _STLP_STD::lower_bound(__middle, __last, *__first_cut, __comp); + __len22 += _STLP_STD::distance(__middle, __second_cut); + } + else { + __len22 = __len2 / 2; + _STLP_STD::advance(__second_cut, __len22); + __first_cut = _STLP_STD::upper_bound(__first, __middle, *__second_cut, __comp); + __len11 += _STLP_STD::distance(__first, __first_cut); + } + _BidirectionalIter __new_middle = + __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11, + __len22, __buffer, __buffer_size); + __merge_adaptive(__first, __first_cut, __new_middle, __len11, + __len22, __buffer, __buffer_size, __comp); + __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11, + __len2 - __len22, __buffer, __buffer_size, __comp); + } +} + +template +void __stable_sort_adaptive(_RandomAccessIter __first, + _RandomAccessIter __last, _Pointer __buffer, + _Distance __buffer_size, _Compare __comp) { + _Distance __len = (__last - __first + 1) / 2; + _RandomAccessIter __middle = __first + __len; + if (__len > __buffer_size) { + __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size, + __comp); + __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size, + __comp); + } + else { + __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0, + __comp); + __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0, + __comp); + } + __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), + _Distance(__last - __middle), __buffer, __buffer_size, + __comp); +} + +template +void __stable_sort_aux(_RandomAccessIter __first, + _RandomAccessIter __last, _Tp*, _Distance*, + _Compare __comp) { + _Temporary_buffer<_RandomAccessIter, _Tp> buf(__first, __last); + if (buf.begin() == 0) + __inplace_stable_sort(__first, __last, __comp); + else + __stable_sort_adaptive(__first, __last, buf.begin(), + _Distance(buf.size()), + __comp); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void stable_sort(_RandomAccessIter __first, + _RandomAccessIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_PRIV __stable_sort_aux(__first, __last, + _STLP_VALUE_TYPE(__first, _RandomAccessIter), + _STLP_DISTANCE_TYPE(__first, _RandomAccessIter), + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter))); +} + +template +void stable_sort(_RandomAccessIter __first, + _RandomAccessIter __last, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_PRIV __stable_sort_aux(__first, __last, + _STLP_VALUE_TYPE(__first, _RandomAccessIter), + _STLP_DISTANCE_TYPE(__first, _RandomAccessIter), + __comp); +} + +// partial_sort, partial_sort_copy, and auxiliary functions. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, + _RandomAccessIter __last, _Tp*, _Compare __comp) { + make_heap(__first, __middle, __comp); + for (_RandomAccessIter __i = __middle; __i < __last; ++__i) { + if (__comp(*__i, *__first)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first, *__i), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __pop_heap(__first, __middle, __i, _Tp(*__i), __comp, + _STLP_DISTANCE_TYPE(__first, _RandomAccessIter)); + } + } + sort_heap(__first, __middle, __comp); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, + _RandomAccessIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __middle)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__middle, __last)) + _STLP_PRIV __partial_sort(__first, __middle, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter))); +} + +template +void partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, + _RandomAccessIter __last, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __middle)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__middle, __last)) + _STLP_PRIV __partial_sort(__first, __middle, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_RandomAccessIter __partial_sort_copy(_InputIter __first, + _InputIter __last, + _RandomAccessIter __result_first, + _RandomAccessIter __result_last, + _Compare __comp, _Distance*, _Tp*) { + if (__result_first == __result_last) return __result_last; + _RandomAccessIter __result_real_last = __result_first; + while(__first != __last && __result_real_last != __result_last) { + *__result_real_last = *__first; + ++__result_real_last; + ++__first; + } + make_heap(__result_first, __result_real_last, __comp); + while (__first != __last) { + if (__comp(*__first, *__result_first)) { + _STLP_VERBOSE_ASSERT(!__comp(*__result_first, *__first), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __adjust_heap(__result_first, _Distance(0), + _Distance(__result_real_last - __result_first), + _Tp(*__first), + __comp); + } + ++__first; + } + sort_heap(__result_first, __result_real_last, __comp); + return __result_real_last; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_RandomAccessIter +partial_sort_copy(_InputIter __first, _InputIter __last, + _RandomAccessIter __result_first, _RandomAccessIter __result_last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__result_first, __result_last)) + return _STLP_PRIV __partial_sort_copy(__first, __last, __result_first, __result_last, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _InputIter)), + _STLP_DISTANCE_TYPE(__result_first, _RandomAccessIter), + _STLP_VALUE_TYPE(__first, _InputIter)); +} + +template +_RandomAccessIter +partial_sort_copy(_InputIter __first, _InputIter __last, + _RandomAccessIter __result_first, + _RandomAccessIter __result_last, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__result_first, __result_last)) + return _STLP_PRIV __partial_sort_copy(__first, __last, __result_first, __result_last, + __comp, + _STLP_DISTANCE_TYPE(__result_first, _RandomAccessIter), + _STLP_VALUE_TYPE(__first, _InputIter)); +} + +// nth_element() and its auxiliary functions. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, + _RandomAccessIter __last, _Tp*, _Compare __comp) { + while (__last - __first > 3) { + _RandomAccessIter __cut = + __unguarded_partition(__first, __last, + _Tp(__median(*__first, + *(__first + (__last - __first)/2), + *(__last - 1), + __comp)), + __comp); + if (__cut <= __nth) + __first = __cut; + else + __last = __cut; + } + __insertion_sort(__first, __last, _STLP_VALUE_TYPE(__first,_RandomAccessIter), __comp); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, + _RandomAccessIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __nth)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__nth, __last)) + _STLP_PRIV __nth_element(__first, __nth, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter))); +} + +template +void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, + _RandomAccessIter __last, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __nth)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__nth, __last)) + _STLP_PRIV __nth_element(__first, __nth, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), __comp); +} + +// Binary search (lower_bound, upper_bound, equal_range, binary_search). +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + _Compare1 __comp1, _Compare2 __comp2, _Distance*) { + _Distance __len = _STLP_STD::distance(__first, __last); + _Distance __half; + + while (__len > 0) { + __half = __len >> 1; + _ForwardIter __middle = __first; + _STLP_STD::advance(__middle, __half); + if (__comp2(__val, *__middle)) { + _STLP_VERBOSE_ASSERT(!__comp1(*__middle, __val), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __len = __half; + } + else { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + } + return __first; +} + +template +pair<_ForwardIter, _ForwardIter> +__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + _Compare1 __comp1, _Compare2 __comp2, _Distance* __dist) { + _Distance __len = _STLP_STD::distance(__first, __last); + _Distance __half; + + while (__len > 0) { + __half = __len >> 1; + _ForwardIter __middle = __first; + _STLP_STD::advance(__middle, __half); + if (__comp1(*__middle, __val)) { + _STLP_VERBOSE_ASSERT(!__comp2(__val, *__middle), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else if (__comp2(__val, *__middle)) { + _STLP_VERBOSE_ASSERT(!__comp1(*__middle, __val), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __len = __half; + } + else { + _ForwardIter __left = _STLP_PRIV __lower_bound(__first, __middle, __val, __comp1, __comp2, __dist); + //Small optim: If lower_bound haven't found an equivalent value + //there is no need to call upper_bound. + if (__comp1(*__left, __val)) { + _STLP_VERBOSE_ASSERT(!__comp2(__val, *__left), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return pair<_ForwardIter, _ForwardIter>(__left, __left); + } + _STLP_STD::advance(__first, __len); + _ForwardIter __right = _STLP_PRIV __upper_bound(++__middle, __first, __val, __comp1, __comp2, __dist); + return pair<_ForwardIter, _ForwardIter>(__left, __right); + } + } + return pair<_ForwardIter, _ForwardIter>(__first, __first); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + while (__first1 != __last1 && __first2 != __last2) { + if (*__first2 < *__first1) { + *__result = *__first2; + ++__first2; + } + else { + *__result = *__first1; + ++__first1; + } + ++__result; + } + return _STLP_STD::copy(__first2, __last2, _STLP_STD::copy(__first1, __last1, __result)); +} + +template +_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + while (__first1 != __last1 && __first2 != __last2) { + if (__comp(*__first2, *__first1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *__result = *__first2; + ++__first2; + } + else { + *__result = *__first1; + ++__first1; + } + ++__result; + } + return _STLP_STD::copy(__first2, __last2, _STLP_STD::copy(__first1, __last1, __result)); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void __merge_without_buffer(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last, + _Distance __len1, _Distance __len2, + _Compare __comp) { + if (__len1 == 0 || __len2 == 0) + return; + if (__len1 + __len2 == 2) { + if (__comp(*__middle, *__first)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first, *__middle), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + iter_swap(__first, __middle); + } + return; + } + _BidirectionalIter __first_cut = __first; + _BidirectionalIter __second_cut = __middle; + _Distance __len11 = 0; + _Distance __len22 = 0; + if (__len1 > __len2) { + __len11 = __len1 / 2; + _STLP_STD::advance(__first_cut, __len11); + __second_cut = _STLP_STD::lower_bound(__middle, __last, *__first_cut, __comp); + __len22 += _STLP_STD::distance(__middle, __second_cut); + } + else { + __len22 = __len2 / 2; + _STLP_STD::advance(__second_cut, __len22); + __first_cut = _STLP_STD::upper_bound(__first, __middle, *__second_cut, __comp); + __len11 += _STLP_STD::distance(__first, __first_cut); + } + _BidirectionalIter __new_middle + = _STLP_PRIV __rotate(__first_cut, __middle, __second_cut); + __merge_without_buffer(__first, __first_cut, __new_middle, __len11, __len22, + __comp); + __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11, + __len2 - __len22, __comp); +} + +template +_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1, + _BidirectionalIter1 __last1, + _BidirectionalIter2 __first2, + _BidirectionalIter2 __last2, + _BidirectionalIter3 __result, + _Compare __comp) { + if (__first1 == __last1) + return copy_backward(__first2, __last2, __result); + if (__first2 == __last2) + return copy_backward(__first1, __last1, __result); + --__last1; + --__last2; + for (;;) { + if (__comp(*__last2, *__last1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__last1, *__last2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *--__result = *__last1; + if (__first1 == __last1) + return copy_backward(__first2, ++__last2, __result); + --__last1; + } + else { + *--__result = *__last2; + if (__first2 == __last2) + return copy_backward(__first1, ++__last1, __result); + --__last2; + } + } +} + +template +inline void __inplace_merge_aux(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last, _Tp*, _Distance*, + _Compare __comp) { + _Distance __len1 = _STLP_STD::distance(__first, __middle); + _Distance __len2 = _STLP_STD::distance(__middle, __last); + + _Temporary_buffer<_BidirectionalIter, _Tp> __buf(__first, __last); + if (__buf.begin() == 0) + __merge_without_buffer(__first, __middle, __last, __len1, __len2, __comp); + else + __merge_adaptive(__first, __middle, __last, __len1, __len2, + __buf.begin(), _Distance(__buf.size()), + __comp); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void inplace_merge(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __middle)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__middle, __last)) + if (__first == __middle || __middle == __last) + return; + _STLP_PRIV __inplace_merge_aux(__first, __middle, __last, + _STLP_VALUE_TYPE(__first, _BidirectionalIter), _STLP_DISTANCE_TYPE(__first, _BidirectionalIter), + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _BidirectionalIter))); +} + +template +void inplace_merge(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __middle)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__middle, __last)) + if (__first == __middle || __middle == __last) + return; + _STLP_PRIV __inplace_merge_aux(__first, __middle, __last, + _STLP_VALUE_TYPE(__first, _BidirectionalIter), _STLP_DISTANCE_TYPE(__first, _BidirectionalIter), + __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool __includes(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + while (__first1 != __last1 && __first2 != __last2) + if (__comp(*__first2, *__first1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return false; + } + else if (__comp(*__first1, *__first2)) + ++__first1; + else + ++__first1, ++__first2; + + return __first2 == __last2; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +bool includes(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, _Compare __comp) { + return _STLP_PRIV __includes(__first1, __last1, __first2, __last2, __comp); +} + +template +bool includes(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2) { + return _STLP_PRIV __includes(__first1, __last1, __first2, __last2, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first1, _InputIter1))); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIter __set_union(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + while (__first1 != __last1 && __first2 != __last2) { + if (__comp(*__first1, *__first2)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first2, *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *__result = *__first1; + ++__first1; + } + else if (__comp(*__first2, *__first1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *__result = *__first2; + ++__first2; + } + else { + *__result = *__first1; + ++__first1; + ++__first2; + } + ++__result; + } + return _STLP_STD::copy(__first2, __last2, _STLP_STD::copy(__first1, __last1, __result)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result) { + return _STLP_PRIV __set_union(__first1, __last1, __first2, __last2, __result, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first1, _InputIter1))); +} + +template +_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + return _STLP_PRIV __set_union(__first1, __last1, __first2, __last2, __result, __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIter __set_intersection(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + while (__first1 != __last1 && __first2 != __last2) + if (__comp(*__first1, *__first2)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first2, *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + ++__first1; + } + else if (__comp(*__first2, *__first1)) + ++__first2; + else { + *__result = *__first1; + ++__first1; + ++__first2; + ++__result; + } + return __result; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result) { + return _STLP_PRIV __set_intersection(__first1, __last1, __first2, __last2, __result, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first1, _InputIter1))); +} + +template +_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + return _STLP_PRIV __set_intersection(__first1, __last1, __first2, __last2, __result, __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIter __set_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + while (__first1 != __last1 && __first2 != __last2) + if (__comp(*__first1, *__first2)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first2, *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *__result = *__first1; + ++__first1; + ++__result; + } + else if (__comp(*__first2, *__first1)) + ++__first2; + else { + ++__first1; + ++__first2; + } + return _STLP_STD::copy(__first1, __last1, __result); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result) { + return _STLP_PRIV __set_difference(__first1, __last1, __first2, __last2, __result, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first1, _InputIter1))); +} + +template +_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + return _STLP_PRIV __set_difference(__first1, __last1, __first2, __last2, __result, __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIter +__set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + while (__first1 != __last1 && __first2 != __last2) { + if (__comp(*__first1, *__first2)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first2, *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *__result = *__first1; + ++__first1; + ++__result; + } + else if (__comp(*__first2, *__first1)) { + *__result = *__first2; + ++__first2; + ++__result; + } + else { + ++__first1; + ++__first2; + } + } + return _STLP_STD::copy(__first2, __last2, _STLP_STD::copy(__first1, __last1, __result)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_OutputIter +set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result) { + return _STLP_PRIV __set_symmetric_difference(__first1, __last1, __first2, __last2, __result, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first1, _InputIter1))); +} + +template +_OutputIter +set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, + _Compare __comp) { + return _STLP_PRIV __set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __comp); +} + +// min_element and max_element, with and without an explicitly supplied +// comparison function. + +template +_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return __first; + _ForwardIter __result = __first; + while (++__first != __last) + if (*__result < *__first) { + _STLP_VERBOSE_ASSERT(!(*__first < *__result), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __result = __first; + } + return __result; +} + +template +_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return __first; + _ForwardIter __result = __first; + while (++__first != __last) { + if (__comp(*__result, *__first)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first, *__result), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __result = __first; + } + } + return __result; +} + +template +_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return __first; + _ForwardIter __result = __first; + while (++__first != __last) + if (*__first < *__result) { + _STLP_VERBOSE_ASSERT(!(*__result < *__first), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __result = __first; + } + return __result; +} + +template +_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) return __first; + _ForwardIter __result = __first; + while (++__first != __last) { + if (__comp(*__first, *__result)) { + _STLP_VERBOSE_ASSERT(!__comp(*__result, *__first), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __result = __first; + } + } + return __result; +} + +// next_permutation and prev_permutation, with and without an explicitly +// supplied comparison function. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool __next_permutation(_BidirectionalIter __first, _BidirectionalIter __last, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) + return false; + _BidirectionalIter __i = __first; + ++__i; + if (__i == __last) + return false; + __i = __last; + --__i; + + for(;;) { + _BidirectionalIter __ii = __i; + --__i; + if (__comp(*__i, *__ii)) { + _STLP_VERBOSE_ASSERT(!__comp(*__ii, *__i), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + _BidirectionalIter __j = __last; + while (!__comp(*__i, *--__j)) {} + iter_swap(__i, __j); + reverse(__ii, __last); + return true; + } + if (__i == __first) { + reverse(__first, __last); + return false; + } + } +#if defined (_STLP_NEED_UNREACHABLE_RETURN) + return false; +#endif +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __next_permutation(__first, __last, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _BidirectionalIter))); +} + +template +bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __next_permutation(__first, __last, __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool __prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last, + _Compare __comp) { + if (__first == __last) + return false; + _BidirectionalIter __i = __first; + ++__i; + if (__i == __last) + return false; + __i = __last; + --__i; + + for(;;) { + _BidirectionalIter __ii = __i; + --__i; + if (__comp(*__ii, *__i)) { + _STLP_VERBOSE_ASSERT(!__comp(*__i, *__ii), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + _BidirectionalIter __j = __last; + while (!__comp(*--__j, *__i)) {} + iter_swap(__i, __j); + reverse(__ii, __last); + return true; + } + if (__i == __first) { + reverse(__first, __last); + return false; + } + } +#if defined (_STLP_NEED_UNREACHABLE_RETURN) + return false; +#endif +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __prev_permutation(__first, __last, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _BidirectionalIter))); +} + +template +bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __prev_permutation(__first, __last, __comp); +} + +#if !defined (_STLP_NO_EXTENSIONS) + +// is_heap, a predicate testing whether or not a range is +// a heap. This function is an extension, not part of the C++ +// standard. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool __is_heap(_RandomAccessIter __first, _StrictWeakOrdering __comp, + _Distance __n) { + _Distance __parent = 0; + for (_Distance __child = 1; __child < __n; ++__child) { + if (__comp(__first[__parent], __first[__child])) { + _STLP_VERBOSE_ASSERT(!__comp(__first[__child], __first[__parent]), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return false; + } + if ((__child & 1) == 0) + ++__parent; + } + return true; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __is_heap(__first, _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter)), __last - __first); +} + +template +bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last, + _StrictWeakOrdering __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __is_heap(__first, __comp, __last - __first); +} + + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool __is_sorted(_ForwardIter __first, _ForwardIter __last, + _StrictWeakOrdering __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) + return true; + + _ForwardIter __next = __first; + for (++__next; __next != __last; __first = __next, ++__next) { + if (__comp(*__next, *__first)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first, *__next), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return false; + } + } + + return true; +} + +_STLP_MOVE_TO_STD_NAMESPACE +#endif /* _STLP_NO_EXTENSIONS */ + +_STLP_END_NAMESPACE + +#undef __stl_threshold + +#endif /* _STLP_ALGO_C */ +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_algo.h b/sdk/tlibstdcxx/stlport/stl/_algo.h new file mode 100644 index 0000000000..7f67661e14 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_algo.h @@ -0,0 +1,777 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +// This file is partly from libc++/include/algorithm from LLVM project. +//===-------------------------- algorithm ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _STLP_INTERNAL_ALGO_H +#define _STLP_INTERNAL_ALGO_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_HEAP_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +#if defined (__SUNPRO_CC) && !defined (_STLP_INTERNAL_CSTDIO) +// remove() conflict +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// for_each. Apply a function to every element of a range. +template +_STLP_INLINE_LOOP _Function +for_each(_InputIter __first, _InputIter __last, _Function __f) { + for ( ; __first != __last; ++__first) + __f(*__first); + return __f; +} + +// count_if +template +_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter) +count_if(_InputIter __first, _InputIter __last, _Predicate __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0; + for ( ; __first != __last; ++__first) { + if (__pred(*__first)) + ++__n; + } + return __n; +} + +// adjacent_find. + +template +_STLP_INLINE_LOOP _ForwardIter +adjacent_find(_ForwardIter __first, _ForwardIter __last, + _BinaryPredicate __binary_pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + if (__first == __last) + return __last; + _ForwardIter __next = __first; + while(++__next != __last) { + if (__binary_pred(*__first, *__next)) + return __first; + __first = __next; + } + return __last; +} + +template +_STLP_INLINE_LOOP _ForwardIter +adjacent_find(_ForwardIter __first, _ForwardIter __last) { + return adjacent_find(__first, __last, + _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first, _ForwardIter))); +} + +#if !defined (_STLP_NO_ANACHRONISMS) +template +_STLP_INLINE_LOOP void +count(_InputIter __first, _InputIter __last, const _Tp& __val, _Size& __n) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + if (*__first == __val) + ++__n; +} + +template +_STLP_INLINE_LOOP void +count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size& __n) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + if (__pred(*__first)) + ++__n; +} +#endif + +template +_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2); + +// search_n. Search for __count consecutive copies of __val. +template +_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, + _Integer __count, const _Tp& __val); +template +_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, + _Integer __count, const _Tp& __val, _BinaryPred __binary_pred); + +template +inline _InputIter find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2); +} + +template +inline _InputIter +find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, _BinaryPredicate __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2, __comp); +} + +template +_ForwardIter1 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2); + +// swap_ranges +template +_STLP_INLINE_LOOP _ForwardIter2 +swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2) + iter_swap(__first1, __first2); + return __first2; +} + +// transform +template +_STLP_INLINE_LOOP _OutputIter +transform(_InputIter __first, _InputIter __last, _OutputIter __result, _UnaryOperation __opr) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first, ++__result) + *__result = __opr(*__first); + return __result; +} +template +_STLP_INLINE_LOOP _OutputIter +transform(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _OutputIter __result,_BinaryOperation __binary_op) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result) + *__result = __binary_op(*__first1, *__first2); + return __result; +} + +// replace_if, replace_copy, replace_copy_if + +template +_STLP_INLINE_LOOP void +replace_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred, const _Tp& __new_value) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + if (__pred(*__first)) + *__first = __new_value; +} + +template +_STLP_INLINE_LOOP _OutputIter +replace_copy(_InputIter __first, _InputIter __last,_OutputIter __result, + const _Tp& __old_value, const _Tp& __new_value) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first, ++__result) + *__result = *__first == __old_value ? __new_value : *__first; + return __result; +} + +template +_STLP_INLINE_LOOP _OutputIter +replace_copy_if(_Iterator __first, _Iterator __last, + _OutputIter __result, + _Predicate __pred, const _Tp& __new_value) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first, ++__result) + *__result = __pred(*__first) ? __new_value : *__first; + return __result; +} + +// generate and generate_n + +template +_STLP_INLINE_LOOP void +generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + *__first = __gen(); +} + +template +_STLP_INLINE_LOOP void +generate_n(_OutputIter __first, _Size __n, _Generator __gen) { + for ( ; __n > 0; --__n, ++__first) + *__first = __gen(); +} + +// remove, remove_if, remove_copy, remove_copy_if + +template +_STLP_INLINE_LOOP _OutputIter +remove_copy(_InputIter __first, _InputIter __last,_OutputIter __result, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) { + if (!(*__first == __val)) { + *__result = *__first; + ++__result; + } + } + return __result; +} + +template +_STLP_INLINE_LOOP _OutputIter +remove_copy_if(_InputIter __first, _InputIter __last, _OutputIter __result, _Predicate __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) { + if (!__pred(*__first)) { + *__result = *__first; + ++__result; + } + } + return __result; +} + +template +_STLP_INLINE_LOOP _ForwardIter +remove(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + __first = find(__first, __last, __val); + if (__first == __last) + return __first; + else { + _ForwardIter __next = __first; + return remove_copy(++__next, __last, __first, __val); + } +} + +template +_STLP_INLINE_LOOP _ForwardIter +remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + __first = find_if(__first, __last, __pred); + if ( __first == __last ) + return __first; + else { + _ForwardIter __next = __first; + return remove_copy_if(++__next, __last, __first, __pred); + } +} + +// unique and unique_copy +template +_OutputIter unique_copy(_InputIter __first, _InputIter __last, _OutputIter __result); + +template +_OutputIter unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result, + _BinaryPredicate __binary_pred); + +template +inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last) { + __first = adjacent_find(__first, __last); + + if (__first != __last) + { + // ... a a ? ... + // f i + _ForwardIter __i = __first; + for (++__i; ++__i != __last;) + if (!(*__first == *__i)) + *++__first = *__i; + ++__first; + } + return __first; +} + +template +inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last, + _BinaryPredicate __binary_pred) { + __first = adjacent_find(__first, __last, __binary_pred); + + if (__first != __last) + { + // ... a a ? ... + // f i + _ForwardIter __i = __first; + for (++__i; ++__i != __last;) + if (!__binary_pred(*__first, *__i)) + *++__first = *__i; + ++__first; + } + return __first; +} + +// reverse and reverse_copy, and their auxiliary functions + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP void +__reverse(_BidirectionalIter __first, _BidirectionalIter __last, const bidirectional_iterator_tag &) { + for (; __first != __last && __first != --__last; ++__first) + _STLP_STD::iter_swap(__first,__last); +} + +template +_STLP_INLINE_LOOP void +__reverse(_RandomAccessIter __first, _RandomAccessIter __last, const random_access_iterator_tag &) { + for (; __first < __last; ++__first) + _STLP_STD::iter_swap(__first, --__last); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline void +reverse(_BidirectionalIter __first, _BidirectionalIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_PRIV __reverse(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _BidirectionalIter)); +} + +template +_STLP_INLINE_LOOP +_OutputIter reverse_copy(_BidirectionalIter __first, + _BidirectionalIter __last, + _OutputIter __result) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + while (__first != __last) { + --__last; + *__result = *__last; + ++__result; + } + return __result; +} + +template +void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last); + +template +inline _OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle, + _ForwardIter __last, _OutputIter __result) { + return _STLP_STD::copy(__first, __middle, copy(__middle, __last, __result)); +} + +// random_shuffle + +template +void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last); + +template +void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last, + _RandomNumberGenerator& __rand); + +#if !defined (_STLP_NO_EXTENSIONS) +// random_sample and random_sample_n (extensions, not part of the standard). + +template +_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, + _OutputIter __out_ite, const _Distance __n); + +template +_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, + _OutputIter __out_ite, const _Distance __n, + _RandomNumberGenerator& __rand); + +template +_RandomAccessIter +random_sample(_InputIter __first, _InputIter __last, + _RandomAccessIter __out_first, _RandomAccessIter __out_last); + +template +_RandomAccessIter +random_sample(_InputIter __first, _InputIter __last, + _RandomAccessIter __out_first, _RandomAccessIter __out_last, + _RandomNumberGenerator& __rand); + +#endif /* _STLP_NO_EXTENSIONS */ + +// partition, stable_partition, and their auxiliary functions + +template +_ForwardIter partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred); + +template +_ForwardIter +stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred); + +// sort() and its auxiliary functions. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _Size __lg(_Size __n) { + _Size __k; + for (__k = 0; __n != 1; __n >>= 1) ++__k; + return __k; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +void sort(_RandomAccessIter __first, _RandomAccessIter __last); +template +void sort(_RandomAccessIter __first, _RandomAccessIter __last, _Compare __comp); + +// stable_sort() and its auxiliary functions. +template +void stable_sort(_RandomAccessIter __first, + _RandomAccessIter __last); + +template +void stable_sort(_RandomAccessIter __first, + _RandomAccessIter __last, _Compare __comp); + +// partial_sort, partial_sort_copy, and auxiliary functions. + +template +void partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, + _RandomAccessIter __last); + +template +void partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, + _RandomAccessIter __last, _Compare __comp); + +template +_RandomAccessIter +partial_sort_copy(_InputIter __first, _InputIter __last, + _RandomAccessIter __result_first, _RandomAccessIter __result_last); + +template +_RandomAccessIter +partial_sort_copy(_InputIter __first, _InputIter __last, + _RandomAccessIter __result_first, + _RandomAccessIter __result_last, _Compare __comp); + +// nth_element() and its auxiliary functions. +template +void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, + _RandomAccessIter __last); + +template +void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, + _RandomAccessIter __last, _Compare __comp); + +// auxiliary class for lower_bound, etc. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct __less_2 { + bool operator() (const _T1& __x, const _T2& __y) const { return __x < __y ; } +}; + +template +__less_2<_T1,_T2> __less2(_T1*, _T2* ) { return __less_2<_T1, _T2>(); } + +#if defined (_STLP_FUNCTION_PARTIAL_ORDER) +template +less<_Tp> __less2(_Tp*, _Tp* ) { return less<_Tp>(); } +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +// Binary search (lower_bound, upper_bound, equal_range, binary_search). +template +inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __lower_bound(__first, __last, __val, + _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), + _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +template +inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp, + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + _Compare1 __comp1, _Compare2 __comp2, _Distance*); + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __upper_bound(__first, __last, __val, + _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), + _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +template +inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val, _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __upper_bound(__first, __last, __val, __comp, __comp, + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +pair<_ForwardIter, _ForwardIter> +__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + _Compare1 __comp1, _Compare2 __comp2, _Distance*); + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline pair<_ForwardIter, _ForwardIter> +equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __equal_range(__first, __last, __val, + _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), + _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +template +inline pair<_ForwardIter, _ForwardIter> +equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __equal_range(__first, __last, __val, __comp, __comp, + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +template +inline bool binary_search(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val, + _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), + _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); + return __i != __last && !(__val < *__i); +} + +template +inline bool binary_search(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp, + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); + return __i != __last && !__comp(__val, *__i); +} + +// merge, with and without an explicitly supplied comparison function. + +template +_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result); + +template +_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp); + + +// inplace_merge and its auxiliary functions. + + +template +void inplace_merge(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last) ; + +template +void inplace_merge(_BidirectionalIter __first, + _BidirectionalIter __middle, + _BidirectionalIter __last, _Compare __comp); + +// Set algorithms: includes, set_union, set_intersection, set_difference, +// set_symmetric_difference. All of these algorithms have the precondition +// that their input ranges are sorted and the postcondition that their output +// ranges are sorted. + +template +bool includes(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2); + +template +bool includes(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, _Compare __comp); + +template +_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result); + +template +_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp); + +template +_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result); + +template +_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp); + + + +template +_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result); + +template +_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, _Compare __comp); + +template +_OutputIter +set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result); + + +template +_OutputIter +set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _OutputIter __result, + _Compare __comp); + + +// min_element and max_element, with and without an explicitly supplied +// comparison function. + +template +_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last); +template +_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last, + _Compare __comp); + +template +_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last); + +template +_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last, + _Compare __comp); + +// next_permutation and prev_permutation, with and without an explicitly +// supplied comparison function. + +template +bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last); + +template +bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last, + _Compare __comp); + + +template +bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last); + + +template +bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last, + _Compare __comp); + +#if !defined (_STLP_NO_EXTENSIONS) +// is_heap, a predicate testing whether or not a range is +// a heap. This function is an extension, not part of the C++ +// standard. + +template +bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last); + +template +bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last, + _StrictWeakOrdering __comp); + +// is_sorted, a predicated testing whether a range is sorted in +// nondescending order. This is an extension, not part of the C++ +// standard. +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool __is_sorted(_ForwardIter __first, _ForwardIter __last, + _StrictWeakOrdering __comp); + +_STLP_MOVE_TO_STD_NAMESPACE +template +inline bool is_sorted(_ForwardIter __first, _ForwardIter __last) { + return _STLP_PRIV __is_sorted(__first, __last, + _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _ForwardIter))); +} + +template +inline bool is_sorted(_ForwardIter __first, _ForwardIter __last, + _StrictWeakOrdering __comp) { + return _STLP_PRIV __is_sorted(__first, __last, __comp); +} +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_ALGO_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_algobase.c b/sdk/tlibstdcxx/stlport/stl/_algobase.c new file mode 100644 index 0000000000..b3367d80a6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_algobase.c @@ -0,0 +1,484 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_ALGOBASE_C +#define _STLP_ALGOBASE_C + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + for ( ; __first1 != __last1 && __first2 != __last2 + ; ++__first1, ++__first2) { + if (*__first1 < *__first2) { + _STLP_VERBOSE_ASSERT(!(*__first2 < *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return true; + } + if (*__first2 < *__first1) + return false; + } + return __first1 == __last1 && __first2 != __last2; +} + +template +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + for ( ; __first1 != __last1 && __first2 != __last2 + ; ++__first1, ++__first2) { + if (__comp(*__first1, *__first2)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first2, *__first1), + _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return true; + } + if (__comp(*__first2, *__first1)) + return false; + } + return __first1 == __last1 && __first2 != __last2; +} + +#if !defined (_STLP_NO_EXTENSIONS) +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2) { + while (__first1 != __last1 && __first2 != __last2) { + if (*__first1 < *__first2) { + _STLP_VERBOSE_ASSERT(!(*__first2 < *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return -1; + } + if (*__first2 < *__first1) + return 1; + ++__first1; + ++__first2; + } + if (__first2 == __last2) { + return !(__first1 == __last1); + } + else { + return -1; + } +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + return _STLP_PRIV __lexicographical_compare_3way(__first1, __last1, __first2, __last2); +} +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP _RandomAccessIter __find(_RandomAccessIter __first, _RandomAccessIter __last, + const _Tp& __val, + const random_access_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_RandomAccessIter) __trip_count = (__last - __first) >> 2; + + for ( ; __trip_count > 0 ; --__trip_count) { + if (*__first == __val) return __first; + ++__first; + + if (*__first == __val) return __first; + ++__first; + + if (*__first == __val) return __first; + ++__first; + + if (*__first == __val) return __first; + ++__first; + } + + switch (__last - __first) { + case 3: + if (*__first == __val) return __first; + ++__first; + case 2: + if (*__first == __val) return __first; + ++__first; + case 1: + if (*__first == __val) return __first; + //++__first; + case 0: + default: + return __last; + } +} + +inline char* +__find(char* __first, char* __last, char __val, const random_access_iterator_tag &) { + void *res = memchr(__first, __val, __last - __first); + return res != 0 ? __STATIC_CAST(char*, res) : __last; +} +inline const char* +__find(const char* __first, const char* __last, char __val, const random_access_iterator_tag &) { + const void *res = memchr(__first, __val, __last - __first); + return res != 0 ? __STATIC_CAST(const char*, res) : __last; +} + +template +_STLP_INLINE_LOOP _RandomAccessIter __find_if(_RandomAccessIter __first, _RandomAccessIter __last, + _Predicate __pred, + const random_access_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_RandomAccessIter) __trip_count = (__last - __first) >> 2; + + for ( ; __trip_count > 0 ; --__trip_count) { + if (__pred(*__first)) return __first; + ++__first; + + if (__pred(*__first)) return __first; + ++__first; + + if (__pred(*__first)) return __first; + ++__first; + + if (__pred(*__first)) return __first; + ++__first; + } + + switch(__last - __first) { + case 3: + if (__pred(*__first)) return __first; + ++__first; + case 2: + if (__pred(*__first)) return __first; + ++__first; + case 1: + if (__pred(*__first)) return __first; + //++__first; + case 0: + default: + return __last; + } +} + +template +_STLP_INLINE_LOOP _InputIter __find(_InputIter __first, _InputIter __last, + const _Tp& __val, + const input_iterator_tag &) { + while (__first != __last && !(*__first == __val)) ++__first; + return __first; +} + +template +_STLP_INLINE_LOOP _InputIter __find_if(_InputIter __first, _InputIter __last, + _Predicate __pred, + const input_iterator_tag &) { + while (__first != __last && !__pred(*__first)) + ++__first; + return __first; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_InputIter find_if(_InputIter __first, _InputIter __last, + _Predicate __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __find_if(__first, __last, __pred, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); +} + +template +_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __find(__first, __last, __val, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); +} + +template +_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + _BinaryPred __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + // Test for empty ranges + if (__first1 == __last1 || __first2 == __last2) + return __first1; + + // Test for a pattern of length 1. + _ForwardIter2 __p1(__first2); + + if ( ++__p1 == __last2 ) { + while (__first1 != __last1 && !__pred(*__first1, *__first2)) { + ++__first1; + } + return __first1; + } + + // General case. + + for ( ; ; ) { // __first1 != __last1 will be checked below + while (__first1 != __last1 && !__pred(*__first1, *__first2)) { + ++__first1; + } + if (__first1 == __last1) { + return __last1; + } + _ForwardIter2 __p = __p1; + _ForwardIter1 __current = __first1; + if (++__current == __last1) return __last1; + + while (__pred(*__current, *__p)) { + if (++__p == __last2) + return __first1; + if (++__current == __last1) + return __last1; + } + ++__first1; + } + //return __first1; /* NOTREACHED */ +} + +_STLP_MOVE_TO_PRIV_NAMESPACE +template +struct _IsCharLikeType +{ typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsCharLikeType +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsCharLikeType +{ typedef __true_type _Ret; }; + +# ifndef _STLP_NO_SIGNED_BUILTINS +_STLP_TEMPLATE_NULL struct _IsCharLikeType +{ typedef __true_type _Ret; }; +# endif + +template +inline bool __stlp_eq(_Tp1 __val1, _Tp2 __val2) +{ return __val1 == __val2; } + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template +inline bool __stlp_eq(_Tp, _Tp) +{ return true; } +#endif + +template +inline _InputIter __find_first_of_aux2(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _Tp2*, _Predicate __pred, + const __true_type& /* _UseStrcspnLikeAlgo */) { + unsigned char __hints[(UCHAR_MAX + 1) / CHAR_BIT]; + memset(__hints, 0, sizeof(__hints) / sizeof(unsigned char)); + for (; __first2 != __last2; ++__first2) { + unsigned char __tmp = (unsigned char)*__first2; + __hints[__tmp / CHAR_BIT] |= (1 << (__tmp % CHAR_BIT)); + } + + for (; __first1 != __last1; ++__first1) { + _Tp2 __tmp = (_Tp2)*__first1; + if (__stlp_eq(*__first1, __tmp) && + __pred((__hints[(unsigned char)__tmp / CHAR_BIT] & (1 << ((unsigned char)__tmp % CHAR_BIT))) != 0)) + break; + } + return __first1; +} + +template +inline _InputIter __find_first_of_aux2(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _Tp2* /* __dummy */, _Predicate /* __pred */, + const __false_type& /* _UseStrcspnLikeAlgo */) { + return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2, + _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first1, _InputIter))); +} + +template +inline _InputIter __find_first_of_aux1(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _Tp1* __pt1, _Tp2* __pt2) { + typedef _STLP_TYPENAME _STLP_STD::_IsIntegral<_Tp1>::_Ret _IsIntegral; + typedef _STLP_TYPENAME _STLP_PRIV _IsCharLikeType<_Tp2>::_Ret _IsCharLike; + typedef _STLP_TYPENAME _STLP_STD::_Land2<_IsIntegral, _IsCharLike>::_Ret _UseStrcspnLikeAlgo; + _STLP_MARK_PARAMETER_AS_UNUSED(__pt1); + return _STLP_PRIV __find_first_of_aux2(__first1, __last1, + __first2, __last2, + __pt2, _Identity(), _UseStrcspnLikeAlgo()); +} + +template +inline _InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2) { + return _STLP_PRIV __find_first_of_aux1(__first1, __last1, __first2, __last2, + _STLP_VALUE_TYPE(__first1, _InputIter), + _STLP_VALUE_TYPE(__first2, _ForwardIter)); +} + +// find_first_of, with and without an explicitly supplied comparison function. +template +_InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _BinaryPredicate __comp) { + for ( ; __first1 != __last1; ++__first1) { + for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter) { + if (__comp(*__first1, *__iter)) { + return __first1; + } + } + } + return __last1; +} + +// find_end, with and without an explicitly supplied comparison function. +// Search [first2, last2) as a subsequence in [first1, last1), and return +// the *last* possible match. Note that find_end for bidirectional iterators +// is much faster than for forward iterators. + +// find_end for forward iterators. +template +_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + const forward_iterator_tag &, const forward_iterator_tag &, + _BinaryPredicate __comp) { + if (__first2 == __last2) + return __last1; + else { + _ForwardIter1 __result = __last1; + for (;;) { + _ForwardIter1 __new_result = _STLP_STD::search(__first1, __last1, __first2, __last2, __comp); + if (__new_result == __last1) + return __result; + else { + __result = __new_result; + __first1 = __new_result; + ++__first1; + } + } + } +} + +_STLP_MOVE_TO_STD_NAMESPACE + +// find_end for bidirectional iterators. Requires partial specialization. +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + +# ifndef _STLP_INTERNAL_ITERATOR_H +_STLP_END_NAMESPACE +# include +_STLP_BEGIN_NAMESPACE +# endif /*_STLP_INTERNAL_ITERATOR_H*/ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_BidirectionalIter1 +__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1, + _BidirectionalIter2 __first2, _BidirectionalIter2 __last2, + const bidirectional_iterator_tag &, const bidirectional_iterator_tag &, + _BinaryPredicate __comp) { + typedef _STLP_STD::reverse_iterator<_BidirectionalIter1> _RevIter1; + typedef _STLP_STD::reverse_iterator<_BidirectionalIter2> _RevIter2; + + _RevIter1 __rlast1(__first1); + _RevIter2 __rlast2(__first2); + _RevIter1 __rresult = _STLP_STD::search(_RevIter1(__last1), __rlast1, + _RevIter2(__last2), __rlast2, + __comp); + + if (__rresult == __rlast1) + return __last1; + else { + _BidirectionalIter1 __result = __rresult.base(); + _STLP_STD::advance(__result, -_STLP_STD::distance(__first2, __last2)); + return __result; + } +} + +_STLP_MOVE_TO_STD_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +template +_ForwardIter1 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + _BinaryPredicate __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + return _STLP_PRIV __find_end(__first1, __last1, __first2, __last2, +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + _STLP_ITERATOR_CATEGORY(__first1, _ForwardIter1), + _STLP_ITERATOR_CATEGORY(__first2, _ForwardIter2), +#else + forward_iterator_tag(), + forward_iterator_tag(), +#endif + __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + _Compare1 __comp1, _Compare2 __comp2, _Distance*) { + _Distance __len = _STLP_STD::distance(__first, __last); + _Distance __half; + _ForwardIter __middle; + + while (__len > 0) { + __half = __len >> 1; + __middle = __first; + _STLP_STD::advance(__middle, __half); + if (__comp1(*__middle, __val)) { + _STLP_VERBOSE_ASSERT(!__comp2(__val, *__middle), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_ALGOBASE_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_algobase.h b/sdk/tlibstdcxx/stlport/stl/_algobase.h new file mode 100644 index 0000000000..597dcbea3c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_algobase.h @@ -0,0 +1,728 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ALGOBASE_H +#define _STLP_INTERNAL_ALGOBASE_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include +#endif + +#ifndef _STLP_INTERNAL_CSTRING +# include +#endif + +#ifndef _STLP_CLIMITS +# include +#endif + +#ifndef _STLP_INTERNAL_CSTDLIB +# include +#endif + +#ifndef _STLP_INTERNAL_PAIR_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +#ifndef _STLP_TYPE_TRAITS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +_STLP_MOVE_TO_PRIV_NAMESPACE +template +inline void __swap_aux(_Tp& __a, _Tp& __b, const __true_type& /*SwapImplemented*/) { + __a._M_swap_workaround(__b); +} + +template +inline void __swap_aux(_Tp& __a, _Tp& __b, const __false_type& /*SwapImplemented*/) { + _Tp __tmp = __a; + __a = __b; + __b = __tmp; +} +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +// swap and iter_swap +template +inline void swap(_Tp& __a, _Tp& __b) { +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +# if !defined(__BORLANDC__) + typedef typename _SwapImplemented<_Tp>::_Ret _Implemented; +# else + enum { _Is = _SwapImplemented<_Tp>::_Is }; + typedef typename __bool2type<_Is>::_Ret _Implemented; +# endif + _STLP_PRIV __swap_aux(__a, __b, _Implemented()); +#else + _Tp __tmp = __a; + __a = __b; + __b = __tmp; +#endif +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline void __iter_swap_aux_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, _Value *) { + _Value tmp = *__i1; + *__i1 = *__i2; + *__i2 = tmp; +} + +template +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __true_type& /*OKToSwap*/) { + /* namespace specification breaks access to the right swap template overload (at least for gcc) */ + /*_STLP_STD::*/ swap(*__i1, *__i2); +} + +template +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __false_type& /*OKToSwap*/) { + _STLP_PRIV __iter_swap_aux_aux( __i1, __i2, _STLP_VALUE_TYPE(__i1,_ForwardIter1) ); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) { + _STLP_PRIV __iter_swap_aux( __i1, __i2, _IsOKToSwap(_STLP_VALUE_TYPE(__i1, _ForwardIter1), _STLP_VALUE_TYPE(__i2, _ForwardIter2), + _STLP_IS_REF_TYPE_REAL_REF(__i1, _ForwardIter1), + _STLP_IS_REF_TYPE_REAL_REF(__i2, _ForwardIter2))._Answer()); +} + +//-------------------------------------------------- +// min and max + +#if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE) +# if (defined (__BORLANDC__) && (__BORLANDC__ < 0x580)) && !defined (__STDC__) +//In not ANSI mode Borland import min/max in global namespace which conflict +//with STLport min/max when user does a 'using namespace std' in its code +//(see test/unit/alg_test.cpp). To avoid this clash we simply import Borland min/max +//in STLport namespace. +using _STLP_VENDOR_STD::min; +using _STLP_VENDOR_STD::max; +# else +template +inline const _Tp& (min)(const _Tp& __a, const _Tp& __b) { return __b < __a ? __b : __a; } +template +inline const _Tp& (max)(const _Tp& __a, const _Tp& __b) { return __a < __b ? __b : __a; } +# endif +#endif + +# if defined (__BORLANDC__) && defined (_STLP_USE_OWN_NAMESPACE) +inline unsigned long (min) (unsigned long __a, unsigned long __b) { return __b < __a ? __b : __a; } +inline unsigned long (max) (unsigned long __a, unsigned long __b) { return __a < __b ? __b : __a; } +# endif + +# if !defined (__BORLANDC__) || (__BORLANDC__ < 0x590) +template +inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) { + return __comp(__b, __a) ? __b : __a; +} + +template +inline const _Tp& (max)(const _Tp& __a, const _Tp& __b, _Compare __comp) { + return __comp(__a, __b) ? __b : __a; +} +# else +template +inline const _Tp (min)(const _Tp __a, const _Tp __b, _Compare __comp) { + return __comp(__b, __a) ? __b : __a; +} + +template +inline const _Tp (max)(const _Tp __a, const _Tp __b, _Compare __comp) { + return __comp(__a, __b) ? __b : __a; +} +# endif + +//-------------------------------------------------- +// copy + +// All of these auxiliary functions serve two purposes. (1) Replace +// calls to copy with memmove whenever possible. (Memmove, not memcpy, +// because the input and output ranges are permitted to overlap.) +// (2) If we're using random access iterators, then write the loop as +// a for loop with an explicit count. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _OutputIter __copy(_InputIter __first, _InputIter __last, + _OutputIter __result, const input_iterator_tag &, _Distance*) { + for ( ; __first != __last; ++__result, ++__first) + *__result = *__first; + return __result; +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline _OutputIter __copy(_InputIter __first, _InputIter __last, + _OutputIter __result, const forward_iterator_tag &, _Distance* ) { + for ( ; __first != __last; ++__result, ++__first) + *__result = *__first; + return __result; +} + +template +inline _OutputIter __copy(_InputIter __first, _InputIter __last, + _OutputIter __result, const bidirectional_iterator_tag &, _Distance* ) { + for ( ; __first != __last; ++__result, ++__first) + *__result = *__first; + return __result; +} +#endif + +template +inline _OutputIter +__copy(_RandomAccessIter __first, _RandomAccessIter __last, + _OutputIter __result, const random_access_iterator_tag &, _Distance*) { + for (_Distance __n = __last - __first; __n > 0; --__n) { + *__result = *__first; + ++__first; + ++__result; + } + return __result; +} + +inline void* +__copy_trivial(const void* __first, const void* __last, void* __result) { + size_t __n = (const char*)__last - (const char*)__first; + return __n ? (void *)((char*)memmove(__result, __first, __n) + __n) : __result; +} + +//-------------------------------------------------- +// copy_backward auxiliary functions + +template +inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first, + _BidirectionalIter1 __last, + _BidirectionalIter2 __result, + const bidirectional_iterator_tag &, + _Distance*) { + while (__first != __last) + *--__result = *--__last; + return __result; +} + +template +inline _BidirectionalIter __copy_backward(_RandomAccessIter __first, + _RandomAccessIter __last, + _BidirectionalIter __result, + const random_access_iterator_tag &, + _Distance*) { + for (_Distance __n = __last - __first; __n > 0; --__n) + *--__result = *--__last; + return __result; +} + +inline void* +__copy_trivial_backward(const void* __first, const void* __last, void* __result) { + const ptrdiff_t _Num = (const char*)__last - (const char*)__first; + return (_Num > 0) ? memmove((char*)__result - _Num, __first, _Num) : __result ; +} + +template +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*IsOKToMemCpy*/) { + return _STLP_PRIV __copy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); +} +template +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*IsOKToMemCpy*/) { + // we know they all pointers, so this cast is OK + // return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result)); + return (_OutputIter)_STLP_PRIV __copy_trivial(__first, __last, __result); +} + +template +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*BothPtrType*/) { + return _STLP_PRIV __copy_ptrs(__first, __last, __result, + _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter), + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer()); +} + +template +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*BothPtrType*/) { + return _STLP_PRIV __copy(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first, _InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer()); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, + _OutputIter __result, const __false_type& /*TrivialAssignment*/) { + return _STLP_PRIV __copy_backward(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first, _InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} +template +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, + _OutputIter __result, const __true_type& /*TrivialAssignment*/) { + return (_OutputIter)_STLP_PRIV __copy_trivial_backward(__first, __last, __result); +} + +template +inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) { + return _STLP_PRIV __copy_backward(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first,_InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} + +template +inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) { + return _STLP_PRIV __copy_backward_ptrs(__first, __last, __result, + _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter), + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer()); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer() ); +} + +#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +# define _STLP_DECLARE_COPY_TRIVIAL(_Tp) \ +inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) \ +{ return (_Tp*)_STLP_PRIV __copy_trivial(__first, __last, __result); } \ +inline _Tp* copy_backward(const _Tp* __first, const _Tp* __last, _Tp* __result) \ +{ return (_Tp*)_STLP_PRIV __copy_trivial_backward(__first, __last, __result); } + +# if !defined (_STLP_NO_BOOL) +_STLP_DECLARE_COPY_TRIVIAL(bool) +# endif +_STLP_DECLARE_COPY_TRIVIAL(char) +# if !defined (_STLP_NO_SIGNED_BUILTINS) +_STLP_DECLARE_COPY_TRIVIAL(signed char) +# endif +_STLP_DECLARE_COPY_TRIVIAL(unsigned char) +_STLP_DECLARE_COPY_TRIVIAL(short) +_STLP_DECLARE_COPY_TRIVIAL(unsigned short) +_STLP_DECLARE_COPY_TRIVIAL(int) +_STLP_DECLARE_COPY_TRIVIAL(unsigned int) +_STLP_DECLARE_COPY_TRIVIAL(long) +_STLP_DECLARE_COPY_TRIVIAL(unsigned long) +# if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT) +_STLP_DECLARE_COPY_TRIVIAL(wchar_t) +# endif +# if defined (_STLP_LONG_LONG) +_STLP_DECLARE_COPY_TRIVIAL(_STLP_LONG_LONG) +_STLP_DECLARE_COPY_TRIVIAL(unsigned _STLP_LONG_LONG) +# endif +_STLP_DECLARE_COPY_TRIVIAL(float) +_STLP_DECLARE_COPY_TRIVIAL(double) +# if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLARE_COPY_TRIVIAL(long double) +# endif +# undef _STLP_DECLARE_COPY_TRIVIAL +#endif + +//-------------------------------------------------- +// copy_n (not part of the C++ standard) + +#if !defined (_STLP_NO_EXTENSIONS) +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP _STLP_STD::pair<_InputIter, _OutputIter> +__copy_n(_InputIter __first, _Size __count, _OutputIter __result, + const input_iterator_tag &) { + for ( ; __count > 0; --__count) { + *__result = *__first; + ++__first; + ++__result; + } + return _STLP_STD::pair<_InputIter, _OutputIter>(__first, __result); +} + +template +inline _STLP_STD::pair<_RAIter, _OutputIter> +__copy_n(_RAIter __first, _Size __count, _OutputIter __result, + const random_access_iterator_tag &) { + _RAIter __last = __first + __count; + return _STLP_STD::pair<_RAIter, _OutputIter>(__last, _STLP_STD::copy(__first, __last, __result)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline pair<_InputIter, _OutputIter> +copy_n(_InputIter __first, _Size __count, _OutputIter __result) { + _STLP_FIX_LITERAL_BUG(__first) + return _STLP_PRIV __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); +} +#endif + +//-------------------------------------------------- +// fill and fill_n +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP +void __fill_fwd(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { + for ( ; __first != __last; ++__first) + *__first = __val; +} + +template +inline void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + const input_iterator_tag &, _Distance*) { + _STLP_PRIV __fill_fwd(__first, __last, __val); +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +_STLP_INLINE_LOOP +void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + const forward_iterator_tag &, _Distance*) { + _STLP_PRIV __fill_fwd(__first, __last, __val); +} + +template +_STLP_INLINE_LOOP +void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + const bidirectional_iterator_tag &, _Distance*) { + _STLP_PRIV __fill_fwd(__first, __last, __val); +} +#endif + +template +_STLP_INLINE_LOOP +void __fill(_RandomAccessIter __first, _RandomAccessIter __last, const _Tp& __val, + const random_access_iterator_tag &, _Distance*) { + for (_Distance __n = __last - __first ; __n > 0; ++__first, --__n) + *__first = __val; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_PRIV __fill(__first, __last, __val, + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +// Specialization: for one-byte types we can use memset. +inline void fill(unsigned char* __first, unsigned char* __last, + const unsigned char& __val) { + unsigned char __tmp = __val; + memset(__first, __tmp, __last - __first); +} +#if !defined (_STLP_NO_SIGNED_BUILTINS) +inline void fill(signed char* __first, signed char* __last, + const signed char& __val) { + signed char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} +#endif +inline void fill(char* __first, char* __last, const char& __val) { + char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP +_OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp& __val) { + _STLP_FIX_LITERAL_BUG(__first) + for ( ; __n > 0; --__n, ++__first) + *__first = __val; + return __first; +} + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template +inline unsigned char* __fill_n(unsigned char* __first, _Size __n, + const unsigned char& __val) { + _STLP_STD::fill(__first, __first + __n, __val); + return __first + __n; +} +#if !defined (_STLP_NO_SIGNED_BUILTINS) +template +inline signed char* __fill_n(signed char* __first, _Size __n, + const signed char& __val) { + _STLP_STD::fill(__first, __first + __n, __val); + return __first + __n; +} +#endif +template +inline char* __fill_n(char* __first, _Size __n, + const char& __val) { + _STLP_STD::fill(__first, __first + __n, __val); + return __first + __n; +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline void fill_n(_OutputIter __first, _Size __n, const _Tp& __val) { + _STLP_FIX_LITERAL_BUG(__first) + _STLP_PRIV __fill_n(__first, __n, __val); +} + + +//-------------------------------------------------- +// equal and mismatch + +template +_STLP_INLINE_LOOP +_STLP_STD::pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2) { + _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + while (__first1 != __last1 && *__first1 == *__first2) { + ++__first1; + ++__first2; + } + return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2); +} + +template +_STLP_INLINE_LOOP +_STLP_STD::pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2, + _BinaryPredicate __binary_pred) { + _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) { + ++__first1; + ++__first2; + } + return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2); +} + +template +_STLP_INLINE_LOOP +bool equal(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2) { + _STLP_FIX_LITERAL_BUG(__first1) _STLP_FIX_LITERAL_BUG(__last1) _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2) + if (!(*__first1 == *__first2)) + return false; + return true; +} + +template +_STLP_INLINE_LOOP +bool equal(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _BinaryPredicate __binary_pred) { + _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2) + if (!__binary_pred(*__first1, *__first2)) + return false; + return true; +} + +//-------------------------------------------------- +// lexicographical_compare and lexicographical_compare_3way. +// (the latter is not part of the C++ standard.) + +template +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2); + +template +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _Compare __comp); + +inline bool +lexicographical_compare(const unsigned char* __first1, + const unsigned char* __last1, + const unsigned char* __first2, + const unsigned char* __last2) { + const size_t __len1 = __last1 - __first1; + const size_t __len2 = __last2 - __first2; + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + + const int __result = memcmp(__first1, __first2, (min) (__len1, __len2)); + return __result != 0 ? (__result < 0) : (__len1 < __len2); +} + + +#if !(CHAR_MAX == SCHAR_MAX) +inline bool lexicographical_compare(const char* __first1, const char* __last1, + const char* __first2, const char* __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + + return lexicographical_compare((const unsigned char*) __first1, + (const unsigned char*) __last1, + (const unsigned char*) __first2, + (const unsigned char*) __last2); +} +#endif /* CHAR_MAX == SCHAR_MAX */ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2); + +inline int +__lexicographical_compare_3way(const unsigned char* __first1, + const unsigned char* __last1, + const unsigned char* __first2, + const unsigned char* __last2) { + const ptrdiff_t __len1 = __last1 - __first1; + const ptrdiff_t __len2 = __last2 - __first2; + const int __result = memcmp(__first1, __first2, (min) (__len1, __len2)); + return __result != 0 ? __result + : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1)); +} + + +#if !(CHAR_MAX == SCHAR_MAX) +inline int +__lexicographical_compare_3way(const char* __first1, const char* __last1, + const char* __first2, const char* __last2) { + return __lexicographical_compare_3way((const unsigned char*) __first1, + (const unsigned char*) __last1, + (const unsigned char*) __first2, + (const unsigned char*) __last2); +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +#if !defined (_STLP_NO_EXTENSIONS) +template +int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2); + +#endif + +// count +template +_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter) +count(_InputIter __first, _InputIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0; + for ( ; __first != __last; ++__first) + if (*__first == __val) + ++__n; + return __n; +} + +// find and find_if. Note find may be expressed in terms of find_if if appropriate binder was available. +template +_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val); + +template +_InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred); + +// search. +template +_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate); + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// find_first_of +template +_InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2); + +template +_InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _BinaryPredicate __comp); + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_ForwardIter1 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + _BinaryPredicate __comp); + +// replace +template +_STLP_INLINE_LOOP void +replace(_ForwardIter __first, _ForwardIter __last, + const _Tp& __old_value, const _Tp& __new_value) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + if (*__first == __old_value) + *__first = __new_value; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val, _Compare1 __comp1, _Compare2 __comp2, _Distance*); + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_ALGOBASE_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_alloc.c b/sdk/tlibstdcxx/stlport/stl/_alloc.c new file mode 100644 index 0000000000..467405b4b8 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_alloc.c @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_ALLOC_C +#define _STLP_ALLOC_C + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#if defined (__WATCOMC__) +# pragma warning 13 9 +# pragma warning 367 9 +# pragma warning 368 9 +#endif + +_STLP_BEGIN_NAMESPACE + +template +void * _STLP_CALL __debug_alloc<_Alloc>::allocate(size_t __n) { + size_t __total_extra = __extra_before_chunk() + __extra_after_chunk(); + size_t __real_n = __n + __total_extra; + if (__real_n < __n) { + //It means that we rolled on size_t, __n must be very large: + _STLP_THROW_BAD_ALLOC; + } + __alloc_header *__result = (__alloc_header *)__allocator_type::allocate(__real_n); + memset((char*)__result, __shred_byte, __real_n * sizeof(value_type)); + __result->__magic = __magic; + __result->__type_size = sizeof(value_type); + __result->_M_size = (_STLP_UINT32_T)__n; + return ((char*)__result) + (long)__extra_before; +} + +template +void _STLP_CALL +__debug_alloc<_Alloc>::deallocate(void *__p, size_t __n) { + __alloc_header * __real_p = (__alloc_header*)((char *)__p -(long)__extra_before); + // check integrity + _STLP_VERBOSE_ASSERT(__real_p->__magic != __deleted_magic, _StlMsg_DBA_DELETED_TWICE) + _STLP_VERBOSE_ASSERT(__real_p->__magic == __magic, _StlMsg_DBA_NEVER_ALLOCATED) + _STLP_VERBOSE_ASSERT(__real_p->__type_size == 1,_StlMsg_DBA_TYPE_MISMATCH) + _STLP_VERBOSE_ASSERT(__real_p->_M_size == __n, _StlMsg_DBA_SIZE_MISMATCH) + // check pads on both sides + unsigned char* __tmp; + for (__tmp = (unsigned char*)(__real_p + 1); __tmp < (unsigned char*)__p; ++__tmp) { + _STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_UNDERRUN) + } + + size_t __real_n = __n + __extra_before_chunk() + __extra_after_chunk(); + + for (__tmp= ((unsigned char*)__p) + __n * sizeof(value_type); + __tmp < ((unsigned char*)__real_p) + __real_n ; ++__tmp) { + _STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_OVERRUN) + } + + // that may be unfortunate, just in case + __real_p->__magic = __deleted_magic; + memset((char*)__p, __shred_byte, __n * sizeof(value_type)); + __allocator_type::deallocate(__real_p, __real_n); +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_ALLOC_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_alloc.h b/sdk/tlibstdcxx/stlport/stl/_alloc.h new file mode 100644 index 0000000000..a0529cd339 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_alloc.h @@ -0,0 +1,580 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ALLOC_H +#define _STLP_INTERNAL_ALLOC_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include +#endif + +#ifndef _STLP_INTERNAL_CSTDLIB +# include +#endif + +#ifndef _STLP_INTERNAL_CSTRING +# include +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_NEW_HEADER +# include +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// Malloc-based allocator. Typically slower than default alloc below. +// Typically thread-safe and more storage efficient. + +#if !defined (_STLP_USE_NO_IOSTREAMS) +typedef void (* __oom_handler_type)(); +#endif + +class _STLP_CLASS_DECLSPEC __malloc_alloc { +public: + // this one is needed for proper simple_alloc wrapping + typedef char value_type; + static void* _STLP_CALL allocate(size_t __n) +#if !defined (_STLP_USE_NO_IOSTREAMS) + ; +#else + { + void *__result = malloc(__n); + if (__result == 0) { + _STLP_THROW_BAD_ALLOC; + } + return __result; + } +#endif + + static void _STLP_CALL deallocate(void* __p, size_t /* __n */) { free((char*)__p); } +#if !defined (_STLP_USE_NO_IOSTREAMS) + static __oom_handler_type _STLP_CALL set_malloc_handler(__oom_handler_type __f); +#endif +}; + +// New-based allocator. Typically slower than default alloc below. +// Typically thread-safe and more storage efficient. +class _STLP_CLASS_DECLSPEC __new_alloc { +public: + // this one is needed for proper simple_alloc wrapping + typedef char value_type; + static void* _STLP_CALL allocate(size_t __n) { return __stl_new(__n); } + static void _STLP_CALL deallocate(void* __p, size_t) { __stl_delete(__p); } +}; + +// Allocator adaptor to check size arguments for debugging. +// Reports errors using assert. Checking can be disabled with +// NDEBUG, but it's far better to just use the underlying allocator +// instead when no checking is desired. +// There is some evidence that this can confuse Purify. +// This adaptor can only be applied to raw allocators + +template +class __debug_alloc : public _Alloc { +public: + typedef _Alloc __allocator_type; + typedef typename _Alloc::value_type value_type; +private: + struct __alloc_header { + size_t __magic: 16; + size_t __type_size:16; + _STLP_UINT32_T _M_size; + }; // that is 8 bytes for sure + // Sunpro CC has bug on enums, so extra_before/after set explicitly + enum { __pad = 8, __magic = 0xdeba, __deleted_magic = 0xdebd, + __shred_byte = _STLP_SHRED_BYTE }; + + enum { __extra_before = 16, __extra_after = 8 }; + // Size of space used to store size. Note + // that this must be large enough to preserve + // alignment. + static size_t _STLP_CALL __extra_before_chunk() { + return (long)__extra_before / sizeof(value_type) + + (size_t)((long)__extra_before % sizeof(value_type) > 0); + } + static size_t _STLP_CALL __extra_after_chunk() { + return (long)__extra_after / sizeof(value_type) + + (size_t)((long)__extra_after % sizeof(value_type) > 0); + } +public: + __debug_alloc() {} + ~__debug_alloc() {} + static void* _STLP_CALL allocate(size_t); + static void _STLP_CALL deallocate(void *, size_t); +}; + +# if defined (__OS400__) +// dums 02/05/2007: is it really necessary ? +enum { _MAX_BYTES = 256 }; +# else +enum { _MAX_BYTES = 32 * sizeof(void*) }; +# endif + +#if !defined (_STLP_USE_NO_IOSTREAMS) +// Default node allocator. +// With a reasonable compiler, this should be roughly as fast as the +// original STL class-specific allocators, but with less fragmentation. +class _STLP_CLASS_DECLSPEC __node_alloc { + static void * _STLP_CALL _M_allocate(size_t& __n); + /* __p may not be 0 */ + static void _STLP_CALL _M_deallocate(void *__p, size_t __n); + +public: + // this one is needed for proper simple_alloc wrapping + typedef char value_type; + /* __n must be > 0 */ + static void* _STLP_CALL allocate(size_t& __n) + { return (__n > (size_t)_MAX_BYTES) ? __stl_new(__n) : _M_allocate(__n); } + /* __p may not be 0 */ + static void _STLP_CALL deallocate(void *__p, size_t __n) + { if (__n > (size_t)_MAX_BYTES) __stl_delete(__p); else _M_deallocate(__p, __n); } +}; + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__node_alloc>; +# endif + +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__new_alloc>; +_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__malloc_alloc>; +#endif + +/* macro to convert the allocator for initialization + * not using MEMBER_TEMPLATE_CLASSES as it should work given template constructor */ +#if defined (_STLP_MEMBER_TEMPLATES) || ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +/* if _STLP_NO_TEMPLATE_CONVERSIONS is set, the member template constructor is + * not used implicitly to convert allocator parameter, so let us do it explicitly */ +# if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_NO_TEMPLATE_CONVERSIONS) +# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0) +# else +# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __a +# endif +/* else convert, but only if partial specialization works, since else + * Container::allocator_type won't be different */ +#else +# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0) +#endif + +// Another allocator adaptor: _Alloc_traits. This serves two +// purposes. First, make it possible to write containers that can use +// either SGI-style allocators or standard-conforming allocator. + +// The fully general version. +template +struct _Alloc_traits { + typedef _Allocator _Orig; +#if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) + typedef typename _Allocator::_STLP_TEMPLATE rebind<_Tp> _Rebind_type; + typedef typename _Rebind_type::other allocator_type; + static allocator_type create_allocator(const _Orig& __a) + { return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); } +#else + // this is not actually true, used only to pass this type through + // to dynamic overload selection in _STLP_alloc_proxy methods + typedef _Allocator allocator_type; +#endif +}; + +#if defined (_STLP_USE_PERTHREAD_ALLOC) + +_STLP_END_NAMESPACE +// include additional header here +# include +_STLP_BEGIN_NAMESPACE + +typedef __pthread_alloc __alloc_type; +#elif defined (_STLP_USE_NEWALLOC) +typedef __new_alloc __alloc_type; +#elif defined (_STLP_USE_MALLOC) +typedef __malloc_alloc __alloc_type; +#else +typedef __node_alloc __alloc_type; +#endif + +#if defined (_STLP_DEBUG_ALLOC) +typedef __debug_alloc<__alloc_type> __sgi_alloc; +#else +typedef __alloc_type __sgi_alloc; +#endif + +#if !defined (_STLP_NO_ANACHRONISMS) +typedef __sgi_alloc __single_client_alloc; +typedef __sgi_alloc __multithreaded_alloc; +#endif + +// This implements allocators as specified in the C++ standard. +// +// Note that standard-conforming allocators use many language features +// that are not yet widely implemented. In particular, they rely on +// member templates, partial specialization, partial ordering of function +// templates, the typename keyword, and the use of the template keyword +// to refer to a template member of a dependent type. + +/* +template +struct _AllocatorAux { + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + pointer address(reference __x) const {return &__x;} + const_pointer address(const_reference __x) const { return &__x; } +}; + +template +struct _AllocatorAux { + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + const_pointer address(const_reference __x) const { return &__x; } +}; +*/ + +template +class allocator //: public _AllocatorAux<_Tp> +/* A small helper struct to recognize STLport allocator implementation + * from any user specialization one. + */ + : public __stlport_class > +{ +public: + typedef _Tp value_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; +#if defined (_STLP_MEMBER_TEMPLATE_CLASSES) + template struct rebind { + typedef allocator<_Tp1> other; + }; +#endif + allocator() _STLP_NOTHROW {} +#if defined (_STLP_MEMBER_TEMPLATES) + template allocator(const allocator<_Tp1>&) _STLP_NOTHROW {} +#endif + allocator(const allocator<_Tp>&) _STLP_NOTHROW {} +#if !defined (_STLP_NO_MOVE_SEMANTIC) + allocator(__move_source > src) _STLP_NOTHROW { _STLP_MARK_PARAMETER_AS_UNUSED(&src); } +#endif + ~allocator() _STLP_NOTHROW {} + pointer address(reference __x) const {return &__x;} + const_pointer address(const_reference __x) const { return &__x; } + // __n is permitted to be 0. The C++ standard says nothing about what the return value is when __n == 0. + _Tp* allocate(size_type __n, const void* = 0) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + return __ret; + } + + return 0; + } + // __p is permitted to be a null pointer, only if n==0. + void deallocate(pointer __p, size_type __n) { + _STLP_ASSERT( (__p == 0) == (__n == 0) ) + if (__p != 0) { +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type)); +#endif + __sgi_alloc::deallocate((void*)__p, __n * sizeof(value_type)); + } + } +#if !defined (_STLP_NO_ANACHRONISMS) + // backwards compatibility + void deallocate(pointer __p) const { if (__p != 0) __sgi_alloc::deallocate((void*)__p, sizeof(value_type)); } +#endif + size_type max_size() const _STLP_NOTHROW { return size_t(-1) / sizeof(value_type); } + void construct(pointer __p, const_reference __val) { _STLP_STD::_Copy_Construct(__p, __val); } + void destroy(pointer __p) { _STLP_STD::_Destroy(__p); } + +#if defined (_STLP_NO_EXTENSIONS) + /* STLport extension giving rounded size of an allocated memory buffer + * This method do not have to be part of a user defined allocator implementation + * and won't even be called if such a function was granted. + */ +protected: +#endif + _Tp* _M_allocate(size_type __n, size_type& __allocated_n) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + __allocated_n = __buf_size / sizeof(value_type); + return __ret; + } + + return 0; + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(allocator<_Tp>& __other) {} +#endif +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC allocator { +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef void* pointer; + typedef const void* const_pointer; +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + typedef void value_type; +#endif +#if defined (_STLP_MEMBER_TEMPLATE_CLASSES) + template struct rebind { + typedef allocator<_Tp1> other; + }; +#endif +}; + +template +inline bool _STLP_CALL operator==(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW +{ return true; } +template +inline bool _STLP_CALL operator!=(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW +{ return false; } + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS allocator; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS allocator; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_EXPORT_TEMPLATE_CLASS allocator; +# endif +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct __alloc_type_traits { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass >::_Ret _STLportAlloc; +#else + enum { _Is = _IsSTLportClass >::_Is }; + typedef typename __bool2type<_Is>::_Ret _STLportAlloc; +#endif + //The default allocator implementation which is recognize thanks to the + //__stlport_class inheritance is a stateless object so: + typedef _STLportAlloc has_trivial_default_constructor; + typedef _STLportAlloc has_trivial_copy_constructor; + typedef _STLportAlloc has_trivial_assignment_operator; + typedef _STLportAlloc has_trivial_destructor; + typedef _STLportAlloc is_POD_type; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct __type_traits > : _STLP_PRIV __alloc_type_traits<_Tp> {}; +#else +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __alloc_type_traits {}; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __alloc_type_traits {}; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __alloc_type_traits {}; +# endif +#endif + + +#if !defined (_STLP_FORCE_ALLOCATORS) +# define _STLP_FORCE_ALLOCATORS(a,y) +#endif + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_MEMBER_TEMPLATE_CLASSES) +// The version for the default allocator, for rare occasion when we have partial spec w/o member template classes +template +struct _Alloc_traits<_Tp, allocator<_Tp1> > { + typedef allocator<_Tp1> _Orig; + typedef allocator<_Tp> allocator_type; + static allocator_type create_allocator(const allocator<_Tp1 >& __a) + { return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); } +}; +#endif + +#if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) && defined (_STLP_MEMBER_TEMPLATES) +template +inline _STLP_TYPENAME_ON_RETURN_TYPE _Alloc_traits<_Tp, _Alloc>::allocator_type _STLP_CALL +__stl_alloc_create(const _Alloc& __a, const _Tp*) { + typedef typename _Alloc::_STLP_TEMPLATE rebind<_Tp>::other _Rebound_type; + return _Rebound_type(__a); +} +#else +// If custom allocators are being used without member template classes support : +// user (on purpose) is forced to define rebind/get operations !!! +template +inline allocator<_Tp2>& _STLP_CALL +__stl_alloc_rebind(allocator<_Tp1>& __a, const _Tp2*) { return (allocator<_Tp2>&)(__a); } +template +inline allocator<_Tp2> _STLP_CALL +__stl_alloc_create(const allocator<_Tp1>&, const _Tp2*) { return allocator<_Tp2>(); } +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// inheritance is being used for EBO optimization +template +class _STLP_alloc_proxy : public _MaybeReboundAlloc { +private: + typedef _MaybeReboundAlloc _Base; + typedef typename _Base::size_type size_type; + typedef _STLP_alloc_proxy<_Value, _Tp, _MaybeReboundAlloc> _Self; +public: + _Value _M_data; + + _STLP_alloc_proxy (const _MaybeReboundAlloc& __a, _Value __p) : + _MaybeReboundAlloc(__a), _M_data(__p) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _STLP_alloc_proxy (__move_source<_Self> src) : + _Base(_STLP_PRIV _AsMoveSource(src.get()._M_base())), + _M_data(_STLP_PRIV _AsMoveSource(src.get()._M_data)) {} + + _Base& _M_base() + { return *this; } +#endif + +private: + /* Following are helper methods to detect stateless allocators and avoid + * swap in this case. For some compilers (VC6) it is a workaround for a + * compiler bug in the Empty Base class Optimization feature, for others + * it is a small optimization or nothing if no EBO. */ + void _M_swap_alloc(_Self&, const __true_type& /*_IsStateless*/) + {} + + void _M_swap_alloc(_Self& __x, const __false_type& /*_IsStateless*/) { + _MaybeReboundAlloc &__base_this = *this; + _MaybeReboundAlloc &__base_x = __x; + _STLP_STD::swap(__base_this, __base_x); + } + +public: + void _M_swap_alloc(_Self& __x) { +#if !defined (__BORLANDC__) + typedef typename _IsStateless<_MaybeReboundAlloc>::_Ret _StatelessAlloc; +#else + typedef typename __bool2type<_IsStateless<_MaybeReboundAlloc>::_Is>::_Ret _StatelessAlloc; +#endif + _M_swap_alloc(__x, _StatelessAlloc()); + } + + /* We need to define the following swap implementation for allocator with state + * as those allocators might have implement a special swap function to correctly + * move datas from an instance to the oher, _STLP_alloc_proxy should not break + * this mecanism. */ + void swap(_Self& __x) { + _M_swap_alloc(__x); + _STLP_STD::swap(_M_data, __x._M_data); + } + + _Tp* allocate(size_type __n, size_type& __allocated_n) { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass<_MaybeReboundAlloc>::_Ret _STLportAlloc; +#else + typedef typename __bool2type<_IsSTLportClass<_MaybeReboundAlloc>::_Is>::_Ret _STLportAlloc; +#endif + return allocate(__n, __allocated_n, _STLportAlloc()); + } + + // Unified interface to perform allocate()/deallocate() with limited + // language support +#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) + // else it is rebound already, and allocate() member is accessible + _Tp* allocate(size_type __n) + { return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).allocate(__n, 0); } + void deallocate(_Tp* __p, size_type __n) + { __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).deallocate(__p, __n); } +private: + _Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/) + { return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0))._M_allocate(__n, __allocated_n); } +#else + //Expose Standard allocate overload (using expression do not work for some compilers (Borland)) + _Tp* allocate(size_type __n) + { return _Base::allocate(__n); } +private: + _Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/) + { return _Base::_M_allocate(__n, __allocated_n); } +#endif + + _Tp* allocate(size_type __n, size_type& __allocated_n, const __false_type& /*STLport allocator*/) + { __allocated_n = __n; return allocate(__n); } +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy >; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy >; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy >; +# endif +#endif + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_ALLOC_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_auto_ptr.h b/sdk/tlibstdcxx/stlport/stl/_auto_ptr.h new file mode 100644 index 0000000000..c750534a01 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_auto_ptr.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_AUTO_PTR_H +#define _STLP_AUTO_PTR_H + +_STLP_BEGIN_NAMESPACE +// implementation primitive +class __ptr_base { +public: + void* _M_p; + void __set(const volatile void* p) { _M_p = __CONST_CAST(void*,p); } + void __set(void* p) { _M_p = p; } +}; + +template +class auto_ptr_ref { +public: + __ptr_base& _M_r; + _Tp* const _M_p; + + auto_ptr_ref(__ptr_base& __r, _Tp* __p) : _M_r(__r), _M_p(__p) { } + + _Tp* release() const { _M_r.__set(__STATIC_CAST(void*, 0)); return _M_p; } + +private: + //explicitely defined as private to avoid warnings: + typedef auto_ptr_ref<_Tp> _Self; + _Self& operator = (_Self const&); +}; + +template +class auto_ptr : public __ptr_base { +public: + typedef _Tp element_type; + typedef auto_ptr<_Tp> _Self; + + _Tp* release() _STLP_NOTHROW { + _Tp* __px = this->get(); + this->_M_p = 0; + return __px; + } + + void reset(_Tp* __px = 0) _STLP_NOTHROW { + _Tp* __pt = this->get(); + if (__px != __pt) + delete __pt; + this->__set(__px); + } + + _Tp* get() const _STLP_NOTHROW +#if !defined (__GNUC__) || (__GNUC__ > 2) + { return __STATIC_CAST(_Tp*, _M_p); } +#else + { return __REINTERPRET_CAST(_Tp*, _M_p); } +#endif + +#if !defined (_STLP_NO_ARROW_OPERATOR) + _Tp* operator->() const _STLP_NOTHROW { + _STLP_VERBOSE_ASSERT(get() != 0, _StlMsg_AUTO_PTR_NULL) + return get(); + } +#endif + _Tp& operator*() const _STLP_NOTHROW { + _STLP_VERBOSE_ASSERT(get() != 0, _StlMsg_AUTO_PTR_NULL) + return *get(); + } + + explicit auto_ptr(_Tp* __px = 0) _STLP_NOTHROW { this->__set(__px); } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if !defined (_STLP_NO_TEMPLATE_CONVERSIONS) + template auto_ptr(auto_ptr<_Tp1>& __r) _STLP_NOTHROW { + _Tp* __conversionCheck = __r.release(); + this->__set(__conversionCheck); + } +# endif + template auto_ptr<_Tp>& operator=(auto_ptr<_Tp1>& __r) _STLP_NOTHROW { + _Tp* __conversionCheck = __r.release(); + reset(__conversionCheck); + return *this; + } +#endif + + auto_ptr(_Self& __r) _STLP_NOTHROW { this->__set(__r.release()); } + + _Self& operator=(_Self& __r) _STLP_NOTHROW { + reset(__r.release()); + return *this; + } + + ~auto_ptr() _STLP_NOTHROW { /* boris : reset(0) might be better */ delete this->get(); } + + auto_ptr(auto_ptr_ref<_Tp> __r) _STLP_NOTHROW + { this->__set(__r.release()); } + + _Self& operator=(auto_ptr_ref<_Tp> __r) _STLP_NOTHROW { + reset(__r.release()); + return *this; + } + +#if defined(_STLP_MEMBER_TEMPLATES) && !defined(_STLP_NO_TEMPLATE_CONVERSIONS) + template operator auto_ptr_ref<_Tp1>() _STLP_NOTHROW + { return auto_ptr_ref<_Tp1>(*this, this->get()); } + template operator auto_ptr<_Tp1>() _STLP_NOTHROW + { return auto_ptr<_Tp1>(release()); } +#else + operator auto_ptr_ref<_Tp>() _STLP_NOTHROW + { return auto_ptr_ref<_Tp>(*this, this->get()); } +#endif +}; +_STLP_END_NAMESPACE + +#endif /* _STLP_AUTO_PTR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_bitset.c b/sdk/tlibstdcxx/stlport/stl/_bitset.c new file mode 100644 index 0000000000..82b9312d9a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_bitset.c @@ -0,0 +1,235 @@ +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_BITSET_C +#define _STLP_BITSET_C + +#ifndef _STLP_BITSET_H +# include +#endif + +#define __BITS_PER_WORD (CHAR_BIT * sizeof(unsigned long)) + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE +// +// Definitions of non-inline functions from _Base_bitset. +// +template +void _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) { + if (__shift != 0) { + const size_t __wshift = __shift / __BITS_PER_WORD; + const size_t __offset = __shift % __BITS_PER_WORD; + + if (__offset == 0) + for (size_t __n = _Nw - 1; __n >= __wshift; --__n) + _M_w[__n] = _M_w[__n - __wshift]; + + else { + const size_t __sub_offset = __BITS_PER_WORD - __offset; + for (size_t __n = _Nw - 1; __n > __wshift; --__n) + _M_w[__n] = (_M_w[__n - __wshift] << __offset) | + (_M_w[__n - __wshift - 1] >> __sub_offset); + _M_w[__wshift] = _M_w[0] << __offset; + } + + fill(_M_w + 0, _M_w + __wshift, __STATIC_CAST(_WordT,0)); + } +} + +template +void _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) { + if (__shift != 0) { + const size_t __wshift = __shift / __BITS_PER_WORD; + const size_t __offset = __shift % __BITS_PER_WORD; + const size_t __limit = _Nw - __wshift - 1; + + if (__offset == 0) + for (size_t __n = 0; __n <= __limit; ++__n) + _M_w[__n] = _M_w[__n + __wshift]; + + else { + const size_t __sub_offset = __BITS_PER_WORD - __offset; + for (size_t __n = 0; __n < __limit; ++__n) + _M_w[__n] = (_M_w[__n + __wshift] >> __offset) | + (_M_w[__n + __wshift + 1] << __sub_offset); + _M_w[__limit] = _M_w[_Nw-1] >> __offset; + } + + fill(_M_w + __limit + 1, _M_w + _Nw, __STATIC_CAST(_WordT,0)); + } +} + +template +unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const { + for (size_t __i = 1; __i < _Nw; ++__i) + if (_M_w[__i]) + __stl_throw_overflow_error("bitset"); + return _M_w[0]; +} // End _M_do_to_ulong + +template +size_t _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const { + for ( size_t __i = 0; __i < _Nw; __i++ ) { + _WordT __thisword = _M_w[__i]; + if ( __thisword != __STATIC_CAST(_WordT,0) ) { + // find byte within word + for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { + unsigned char __this_byte + = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0))); + if ( __this_byte ) + return __i*__BITS_PER_WORD + __j*CHAR_BIT + + _Bs_G::_S_first_one(__this_byte); + + __thisword >>= CHAR_BIT; + } + } + } + // not found, so return an indication of failure. + return __not_found; +} + +template +size_t +_Base_bitset<_Nw>::_M_do_find_next(size_t __prev, + size_t __not_found) const { + // make bound inclusive + ++__prev; + + // check out of bounds + if ( __prev >= _Nw * __BITS_PER_WORD ) + return __not_found; + + // search first word + size_t __i = _S_whichword(__prev); + _WordT __thisword = _M_w[__i]; + + // mask off bits below bound + __thisword &= (~__STATIC_CAST(_WordT,0)) << _S_whichbit(__prev); + + if ( __thisword != __STATIC_CAST(_WordT,0) ) { + // find byte within word + // get first byte into place + __thisword >>= _S_whichbyte(__prev) * CHAR_BIT; + for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); ++__j ) { + unsigned char __this_byte + = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0))); + if ( __this_byte ) + return __i*__BITS_PER_WORD + __j*CHAR_BIT + + _Bs_G::_S_first_one(__this_byte); + + __thisword >>= CHAR_BIT; + } + } + + // check subsequent words + ++__i; + for ( ; __i < _Nw; ++__i ) { + /* _WordT */ __thisword = _M_w[__i]; + if ( __thisword != __STATIC_CAST(_WordT,0) ) { + // find byte within word + for ( size_t __j = 0; __j < sizeof(_WordT); ++__j ) { + unsigned char __this_byte + = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0))); + if ( __this_byte ) + return __i*__BITS_PER_WORD + __j*CHAR_BIT + + _Bs_G::_S_first_one(__this_byte); + + __thisword >>= CHAR_BIT; + } + } + } + + // not found, so return an indication of failure. + return __not_found; +} // end _M_do_find_next + +_STLP_MOVE_TO_STD_NAMESPACE + +#if !defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) + +# if !defined (_STLP_USE_NO_IOSTREAMS) + +_STLP_END_NAMESPACE + +#ifndef _STLP_STRING_IO_H +# include //includes _istream.h and _ostream.h +#endif + +_STLP_BEGIN_NAMESPACE + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) { + basic_string<_CharT, _Traits> __tmp; + __tmp.reserve(_Nb); + + // Skip whitespace + typename basic_istream<_CharT, _Traits>::sentry __sentry(__is); + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); + for (size_t __i = 0; __i < _Nb; ++__i) { + static typename _Traits::int_type __eof = _Traits::eof(); + + typename _Traits::int_type __c1 = __buf->sbumpc(); + if (_Traits::eq_int_type(__c1, __eof)) { + __is.setstate(ios_base::eofbit); + break; + } + else { + typename _Traits::char_type __c2 = _Traits::to_char_type(__c1); + char __c = __is.narrow(__c2, '*'); + + if (__c == '0' || __c == '1') + __tmp.push_back(__c); + else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) { + __is.setstate(ios_base::failbit); + break; + } + } + } + + if (__tmp.empty()) + __is.setstate(ios_base::failbit); + else + __x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb); + } + + return __is; +} + +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, + const bitset<_Nb>& __x) { + basic_string<_CharT, _Traits> __tmp; + __x._M_copy_to_string(__tmp); + return __os << __tmp; +} + +# endif /* !_STLP_USE_NO_IOSTREAMS */ + +#endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */ + +_STLP_END_NAMESPACE + +#undef __BITS_PER_WORD +#undef bitset + +#endif /* _STLP_BITSET_C */ diff --git a/sdk/tlibstdcxx/stlport/stl/_bitset.h b/sdk/tlibstdcxx/stlport/stl/_bitset.h new file mode 100644 index 0000000000..ee8e0472b0 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_bitset.h @@ -0,0 +1,928 @@ +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_BITSET_H +#define _STLP_BITSET_H + +// A bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused +// bits. (They are the high- order bits in the highest word.) It is +// a class invariant of class bitset<> that those unused bits are +// always zero. + +// Most of the actual code isn't contained in bitset<> itself, but in the +// base class _Base_bitset. The base class works with whole words, not with +// individual bits. This allows us to specialize _Base_bitset for the +// important special case where the bitset is only a single word. + +// The C++ standard does not define the precise semantics of operator[]. +// In this implementation the const version of operator[] is equivalent +// to test(), except that it does no range checking. The non-const version +// returns a reference to a bit, again without doing any range checking. + + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +# include +#endif + +#ifndef _STLP_RANGE_ERRORS_H +# include +#endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +#define __BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long)) +#define __BITSET_WORDS(__n) ((__n + __BITS_PER_WORD - 1)/__BITS_PER_WORD) + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// structure to aid in counting bits +class _STLP_CLASS_DECLSPEC _Bs_G +{ + public: + //returns the number of bit set within the buffer between __beg and __end. + static size_t _S_count(const unsigned char *__beg, const unsigned char *__end) +#if defined (_STLP_USE_NO_IOSTREAMS) + { + size_t __result = 0; + for (; __beg != __end; ++__beg) { + for (size_t i = 0; i < (sizeof(unsigned char) * 8); ++i) { + if ((*__beg & (1 << i)) != 0) { ++__result; } + } + } + return __result; + } +#else + ; +#endif + // Mapping from 8 bit unsigned integers to the index of the first one bit set: + static unsigned char _S_first_one(unsigned char __x) +#if defined (_STLP_USE_NO_IOSTREAMS) + { + for (unsigned char i = 0; i < (sizeof(unsigned char) * 8); ++i) { + if ((__x & (1 << i)) != 0) { return i; } + } + return 0; + } +#else + ; +#endif +}; + +// +// Base class: general case. +// + +template +struct _Base_bitset { + typedef unsigned long _WordT; + + _WordT _M_w[_Nw]; // 0 is the least significant word. + + _Base_bitset() { _M_do_reset(); } + + _Base_bitset(unsigned long __val) { + _M_do_reset(); + _M_w[0] = __val; + } + + static size_t _STLP_CALL _S_whichword( size_t __pos ) { + return __pos / __BITS_PER_WORD; + } + static size_t _STLP_CALL _S_whichbyte( size_t __pos ) { + return (__pos % __BITS_PER_WORD) / CHAR_BIT; + } + static size_t _STLP_CALL _S_whichbit( size_t __pos ) { + return __pos % __BITS_PER_WORD; + } + static _WordT _STLP_CALL _S_maskbit( size_t __pos ) { + return __STATIC_CAST(_WordT,1) << _S_whichbit(__pos); + } + + _WordT& _M_getword(size_t __pos) { return _M_w[_S_whichword(__pos)]; } + _WordT _M_getword(size_t __pos) const { return _M_w[_S_whichword(__pos)]; } + + _WordT& _M_hiword() { return _M_w[_Nw - 1]; } + _WordT _M_hiword() const { return _M_w[_Nw - 1]; } + + void _M_do_and(const _Base_bitset<_Nw>& __x) { + for ( size_t __i = 0; __i < _Nw; __i++ ) { + _M_w[__i] &= __x._M_w[__i]; + } + } + + void _M_do_or(const _Base_bitset<_Nw>& __x) { + for ( size_t __i = 0; __i < _Nw; __i++ ) { + _M_w[__i] |= __x._M_w[__i]; + } + } + + void _M_do_xor(const _Base_bitset<_Nw>& __x) { + for ( size_t __i = 0; __i < _Nw; __i++ ) { + _M_w[__i] ^= __x._M_w[__i]; + } + } + + void _M_do_left_shift(size_t __shift); + + void _M_do_right_shift(size_t __shift); + + void _M_do_flip() { + for ( size_t __i = 0; __i < _Nw; __i++ ) { + _M_w[__i] = ~_M_w[__i]; + } + } + + void _M_do_set() { + for ( size_t __i = 0; __i < _Nw; __i++ ) { + _M_w[__i] = ~__STATIC_CAST(_WordT,0); + } + } + + void _M_do_reset() { memset(_M_w, 0, _Nw * sizeof(_WordT)); } + + bool _M_is_equal(const _Base_bitset<_Nw>& __x) const { + for (size_t __i = 0; __i < _Nw; ++__i) { + if (_M_w[__i] != __x._M_w[__i]) + return false; + } + return true; + } + + bool _M_is_any() const { + for ( size_t __i = 0; __i < _Nw ; __i++ ) { + if ( _M_w[__i] != __STATIC_CAST(_WordT,0) ) + return true; + } + return false; + } + + size_t _M_do_count() const { + const unsigned char* __byte_ptr = (const unsigned char*)_M_w; + const unsigned char* __end_ptr = (const unsigned char*)(_M_w+_Nw); + + return _Bs_G::_S_count(__byte_ptr, __end_ptr); + } + + unsigned long _M_do_to_ulong() const; + + // find first "on" bit + size_t _M_do_find_first(size_t __not_found) const; + + // find the next "on" bit that follows "prev" + size_t _M_do_find_next(size_t __prev, size_t __not_found) const; +}; + +// +// Base class: specialization for a single word. +// +_STLP_TEMPLATE_NULL +struct _Base_bitset<1UL> { + typedef unsigned long _WordT; + typedef _Base_bitset<1UL> _Self; + + _WordT _M_w; + + _Base_bitset( void ) : _M_w(0) {} + _Base_bitset(unsigned long __val) : _M_w(__val) {} + + static size_t _STLP_CALL _S_whichword( size_t __pos ) { + return __pos / __BITS_PER_WORD ; + } + static size_t _STLP_CALL _S_whichbyte( size_t __pos ) { + return (__pos % __BITS_PER_WORD) / CHAR_BIT; + } + static size_t _STLP_CALL _S_whichbit( size_t __pos ) { + return __pos % __BITS_PER_WORD; + } + static _WordT _STLP_CALL _S_maskbit( size_t __pos ) { + return (__STATIC_CAST(_WordT,1)) << _S_whichbit(__pos); + } + + _WordT& _M_getword(size_t) { return _M_w; } + _WordT _M_getword(size_t) const { return _M_w; } + + _WordT& _M_hiword() { return _M_w; } + _WordT _M_hiword() const { return _M_w; } + + void _M_do_and(const _Self& __x) { _M_w &= __x._M_w; } + void _M_do_or(const _Self& __x) { _M_w |= __x._M_w; } + void _M_do_xor(const _Self& __x) { _M_w ^= __x._M_w; } + void _M_do_left_shift(size_t __shift) { _M_w <<= __shift; } + void _M_do_right_shift(size_t __shift) { _M_w >>= __shift; } + void _M_do_flip() { _M_w = ~_M_w; } + void _M_do_set() { _M_w = ~__STATIC_CAST(_WordT,0); } + void _M_do_reset() { _M_w = 0; } + + bool _M_is_equal(const _Self& __x) const { + return _M_w == __x._M_w; + } + bool _M_is_any() const { + return _M_w != 0; + } + + size_t _M_do_count() const { + const unsigned char* __byte_ptr = (const unsigned char*)&_M_w; + const unsigned char* __end_ptr = ((const unsigned char*)&_M_w)+sizeof(_M_w); + return _Bs_G::_S_count(__byte_ptr, __end_ptr); + } + + unsigned long _M_do_to_ulong() const { return _M_w; } + + inline size_t _M_do_find_first(size_t __not_found) const; + + // find the next "on" bit that follows "prev" + inline size_t _M_do_find_next(size_t __prev, size_t __not_found) const; +}; + + +// ------------------------------------------------------------ +// +// Definitions of should-be-non-inline functions from the single-word version of +// _Base_bitset. +// +inline size_t +_Base_bitset<1UL>::_M_do_find_first(size_t __not_found) const { + // typedef unsigned long _WordT; + _WordT __thisword = _M_w; + + if ( __thisword != __STATIC_CAST(_WordT,0) ) { + // find byte within word + for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) { + unsigned char __this_byte + = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0))); + if ( __this_byte ) + return __j*CHAR_BIT + _Bs_G::_S_first_one(__this_byte); + + __thisword >>= CHAR_BIT; + } + } + // not found, so return a value that indicates failure. + return __not_found; +} + +inline size_t +_Base_bitset<1UL>::_M_do_find_next(size_t __prev, + size_t __not_found ) const { + // make bound inclusive + ++__prev; + + // check out of bounds + if ( __prev >= __BITS_PER_WORD ) + return __not_found; + + // search first (and only) word + _WordT __thisword = _M_w; + + // mask off bits below bound + __thisword &= (~__STATIC_CAST(_WordT,0)) << _S_whichbit(__prev); + + if ( __thisword != __STATIC_CAST(_WordT,0) ) { + // find byte within word + // get first byte into place + __thisword >>= _S_whichbyte(__prev) * CHAR_BIT; + for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) { + unsigned char __this_byte + = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0))); + if ( __this_byte ) + return __j*CHAR_BIT + _Bs_G::_S_first_one(__this_byte); + + __thisword >>= CHAR_BIT; + } + } + + // not found, so return a value that indicates failure. + return __not_found; +} // end _M_do_find_next + +// +// Base class, specialization for no storage (zero-length %bitset). +// +_STLP_TEMPLATE_NULL +struct _Base_bitset<0UL> { + typedef unsigned long _WordT; + typedef _Base_bitset<0UL> _Self; + + _Base_bitset(void) {} + _Base_bitset(unsigned long) {} + + static size_t _STLP_CALL _S_whichword(size_t __pos) { + return __pos / __BITS_PER_WORD; + } + static size_t _STLP_CALL _S_whichbyte(size_t __pos) { + return (__pos % __BITS_PER_WORD) / CHAR_BIT; + } + static size_t _STLP_CALL _S_whichbit(size_t __pos) { + return __pos % __BITS_PER_WORD; + } + static _WordT _STLP_CALL _S_maskbit(size_t __pos) { + return (__STATIC_CAST(_WordT,1)) << _S_whichbit(__pos); + } + + _WordT& _M_getword(size_t) { + __stl_throw_out_of_range("_Base_bitset::_M_getword"); + return *new _WordT; + } + _WordT _M_getword(size_t) const { return 0; } + _WordT _M_hiword() const { return 0; } + + void _M_do_and(const _Self&) {} + void _M_do_or(const _Self&) {} + void _M_do_xor(const _Self&) {} + void _M_do_left_shift(size_t) {} + void _M_do_right_shift(size_t) {} + void _M_do_flip() {} + void _M_do_set() {} + void _M_do_reset() {} + + bool _M_is_equal(const _Self&) const { return true; } + bool _M_is_any() const { return false; } + + size_t _M_do_count() const { return 0; } + unsigned long _M_do_to_ulong() const { return 0; } + size_t _M_do_find_first(size_t) const { return 0; } + size_t _M_do_find_next(size_t, size_t) const { return 0; } +}; + +// ------------------------------------------------------------ +// Helper class to zero out the unused high-order bits in the highest word. + +template struct _Sanitize { + static void _STLP_CALL _M_do_sanitize(unsigned long& __val) + { __val &= ~((~__STATIC_CAST(unsigned long,0)) << _Extrabits); } +}; + +_STLP_TEMPLATE_NULL struct _Sanitize<0UL> { + static void _STLP_CALL _M_do_sanitize(unsigned long) {} +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +// ------------------------------------------------------------ +// Class bitset. +// _Nb may be any nonzero number of type size_t. +template +class bitset : public _STLP_PRIV _Base_bitset<__BITSET_WORDS(_Nb) > { +public: + enum { _Words = __BITSET_WORDS(_Nb) } ; + +private: + typedef _STLP_PRIV _Base_bitset< _Words > _Base; + + void _M_do_sanitize() { + _STLP_PRIV _Sanitize<_Nb%__BITS_PER_WORD >::_M_do_sanitize(this->_M_hiword()); + } +public: + typedef unsigned long _WordT; + struct reference; + friend struct reference; + + // bit reference: + struct reference { + typedef _STLP_PRIV _Base_bitset<_Words > _Bitset_base; + typedef bitset<_Nb> _Bitset; + // friend _Bitset; + _WordT *_M_wp; + size_t _M_bpos; + + // should be left undefined + reference() {} + + reference( _Bitset& __b, size_t __pos ) { + _M_wp = &__b._M_getword(__pos); + _M_bpos = _Bitset_base::_S_whichbit(__pos); + } + + public: + ~reference() {} + + // for b[i] = __x; + reference& operator=(bool __x) { + if ( __x ) + *_M_wp |= _Bitset_base::_S_maskbit(_M_bpos); + else + *_M_wp &= ~_Bitset_base::_S_maskbit(_M_bpos); + + return *this; + } + + // for b[i] = b[__j]; + reference& operator=(const reference& __j) { + if ( (*(__j._M_wp) & _Bitset_base::_S_maskbit(__j._M_bpos)) ) + *_M_wp |= _Bitset_base::_S_maskbit(_M_bpos); + else + *_M_wp &= ~_Bitset_base::_S_maskbit(_M_bpos); + + return *this; + } + + // flips the bit + bool operator~() const { return (*(_M_wp) & _Bitset_base::_S_maskbit(_M_bpos)) == 0; } + + // for __x = b[i]; + operator bool() const { return (*(_M_wp) & _Bitset_base::_S_maskbit(_M_bpos)) != 0; } + + // for b[i].flip(); + reference& flip() { + *_M_wp ^= _Bitset_base::_S_maskbit(_M_bpos); + return *this; + } + }; + + // 23.3.5.1 constructors: + bitset() {} + + bitset(unsigned long __val) : _STLP_PRIV _Base_bitset<_Words>(__val) { _M_do_sanitize(); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + explicit bitset(const basic_string<_CharT,_Traits,_Alloc>& __s, + size_t __pos = 0) + : _STLP_PRIV _Base_bitset<_Words >() { + if (__pos > __s.size()) + __stl_throw_out_of_range("bitset"); + _M_copy_from_string(__s, __pos, + basic_string<_CharT, _Traits, _Alloc>::npos); + } + template + bitset(const basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __pos, + size_t __n) + : _STLP_PRIV _Base_bitset<_Words >() { + if (__pos > __s.size()) + __stl_throw_out_of_range("bitset"); + _M_copy_from_string(__s, __pos, __n); + } +#else /* _STLP_MEMBER_TEMPLATES */ + explicit bitset(const string& __s, + size_t __pos = 0, + size_t __n = (size_t)-1) + : _STLP_PRIV _Base_bitset<_Words >() { + if (__pos > __s.size()) + __stl_throw_out_of_range("bitset"); + _M_copy_from_string(__s, __pos, __n); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + // 23.3.5.2 bitset operations: + bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) { + this->_M_do_and(__rhs); + return *this; + } + + bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) { + this->_M_do_or(__rhs); + return *this; + } + + bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) { + this->_M_do_xor(__rhs); + return *this; + } + + bitset<_Nb>& operator<<=(size_t __pos) { + this->_M_do_left_shift(__pos); + this->_M_do_sanitize(); + return *this; + } + + bitset<_Nb>& operator>>=(size_t __pos) { + this->_M_do_right_shift(__pos); + this->_M_do_sanitize(); + return *this; + } + + // + // Extension: + // Versions of single-bit set, reset, flip, test with no range checking. + // + + bitset<_Nb>& _Unchecked_set(size_t __pos) { + this->_M_getword(__pos) |= _STLP_PRIV _Base_bitset<_Words > ::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& _Unchecked_set(size_t __pos, int __val) { + if (__val) + this->_M_getword(__pos) |= this->_S_maskbit(__pos); + else + this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos); + + return *this; + } + + bitset<_Nb>& _Unchecked_reset(size_t __pos) { + this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& _Unchecked_flip(size_t __pos) { + this->_M_getword(__pos) ^= this->_S_maskbit(__pos); + return *this; + } + + bool _Unchecked_test(size_t __pos) const { + return (this->_M_getword(__pos) & this->_S_maskbit(__pos)) != __STATIC_CAST(_WordT,0); + } + + // Set, reset, and flip. + + bitset<_Nb>& set() { + this->_M_do_set(); + this->_M_do_sanitize(); + return *this; + } + + bitset<_Nb>& set(size_t __pos) { + if (__pos >= _Nb) + __stl_throw_out_of_range("bitset"); + return _Unchecked_set(__pos); + } + + bitset<_Nb>& set(size_t __pos, int __val) { + if (__pos >= _Nb) + __stl_throw_out_of_range("bitset"); + return _Unchecked_set(__pos, __val); + } + + bitset<_Nb>& reset() { + this->_M_do_reset(); + return *this; + } + + bitset<_Nb>& reset(size_t __pos) { + if (__pos >= _Nb) + __stl_throw_out_of_range("bitset"); + + return _Unchecked_reset(__pos); + } + + bitset<_Nb>& flip() { + this->_M_do_flip(); + this->_M_do_sanitize(); + return *this; + } + + bitset<_Nb>& flip(size_t __pos) { + if (__pos >= _Nb) + __stl_throw_out_of_range("bitset"); + + return _Unchecked_flip(__pos); + } + + bitset<_Nb> operator~() const { + return bitset<_Nb>(*this).flip(); + } + + // element access: + //for b[i]; + reference operator[](size_t __pos) { return reference(*this,__pos); } + bool operator[](size_t __pos) const { return _Unchecked_test(__pos); } + + unsigned long to_ulong() const { return this->_M_do_to_ulong(); } + +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) + template + basic_string<_CharT, _Traits, _Alloc> to_string() const { + basic_string<_CharT, _Traits, _Alloc> __result; + _M_copy_to_string(__result); + return __result; + } +#else + string to_string() const { + string __result; + _M_copy_to_string(__result); + return __result; + } +#endif /* _STLP_EXPLICIT_FUNCTION_TMPL_ARGS */ + + size_t count() const { return this->_M_do_count(); } + + size_t size() const { return _Nb; } + + bool operator==(const bitset<_Nb>& __rhs) const { + return this->_M_is_equal(__rhs); + } + bool operator!=(const bitset<_Nb>& __rhs) const { + return !this->_M_is_equal(__rhs); + } + + bool test(size_t __pos) const { + if (__pos >= _Nb) + __stl_throw_out_of_range("bitset"); + + return _Unchecked_test(__pos); + } + + bool any() const { return this->_M_is_any(); } + bool none() const { return !this->_M_is_any(); } + + bitset<_Nb> operator<<(size_t __pos) const { + bitset<_Nb> __result(*this); + __result <<= __pos ; return __result; + } + bitset<_Nb> operator>>(size_t __pos) const { + bitset<_Nb> __result(*this); + __result >>= __pos ; return __result; + } + +#if !defined (_STLP_NO_EXTENSIONS) + // + // EXTENSIONS: bit-find operations. These operations are + // experimental, and are subject to change or removal in future + // versions. + // + + // find the index of the first "on" bit + size_t _Find_first() const + { return this->_M_do_find_first(_Nb); } + + // find the index of the next "on" bit after prev + size_t _Find_next( size_t __prev ) const + { return this->_M_do_find_next(__prev, _Nb); } +#endif + +// +// Definitions of should-be non-inline member functions. +// +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s, + size_t __pos, size_t __n) { +#else + void _M_copy_from_string(const string& __s, + size_t __pos, size_t __n) { + typedef typename string::traits_type _Traits; +#endif + reset(); + size_t __tmp = _Nb; + const size_t __Nbits = (min) (__tmp, (min) (__n, __s.size() - __pos)); + for ( size_t __i= 0; __i < __Nbits; ++__i) { + typename _Traits::int_type __k = _Traits::to_int_type(__s[__pos + __Nbits - __i - 1]); + // boris : widen() ? + if (__k == '1') + set(__i); + else if (__k != '0') + __stl_throw_invalid_argument("bitset"); + } + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_copy_to_string(basic_string<_CharT, _Traits, _Alloc>& __s) const +#else + void _M_copy_to_string(string& __s) const +#endif + { + __s.assign(_Nb, '0'); + + for (size_t __i = 0; __i < _Nb; ++__i) { + if (_Unchecked_test(__i)) + __s[_Nb - 1 - __i] = '1'; + } + } + +#if !defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_WCHAR_T) + void _M_copy_to_string(wstring& __s) const { + __s.assign(_Nb, '0'); + + for (size_t __i = 0; __i < _Nb; ++__i) { + if (_Unchecked_test(__i)) + __s[_Nb - 1 - __i] = '1'; + } + } +#endif + +#if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) + bitset<_Nb> operator&(const bitset<_Nb>& __y) const { + bitset<_Nb> __result(*this); + __result &= __y; + return __result; + } + bitset<_Nb> operator|(const bitset<_Nb>& __y) const { + bitset<_Nb> __result(*this); + __result |= __y; + return __result; + } + bitset<_Nb> operator^(const bitset<_Nb>& __y) const { + bitset<_Nb> __result(*this); + __result ^= __y; + return __result; + } +#endif +}; + +// ------------------------------------------------------------ +// +// 23.3.5.3 bitset operations: +// +#if ! defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) +template +inline bitset<_Nb> _STLP_CALL +operator&(const bitset<_Nb>& __x, + const bitset<_Nb>& __y) { + bitset<_Nb> __result(__x); + __result &= __y; + return __result; +} + + +template +inline bitset<_Nb> _STLP_CALL +operator|(const bitset<_Nb>& __x, + const bitset<_Nb>& __y) { + bitset<_Nb> __result(__x); + __result |= __y; + return __result; +} + +template +inline bitset<_Nb> _STLP_CALL +operator^(const bitset<_Nb>& __x, + const bitset<_Nb>& __y) { + bitset<_Nb> __result(__x); + __result ^= __y; + return __result; +} + +#if !defined (_STLP_USE_NO_IOSTREAMS) + +_STLP_END_NAMESPACE + +# if !(defined (_STLP_MSVC) && (_STLP_MSVC < 1300)) && \ + !(defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x500)) + +#ifndef _STLP_INTERNAL_IOSFWD +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x); + +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x); + +# else + +#ifndef _STLP_STRING_IO_H +# include //includes _istream.h and _ostream.h +#endif + +_STLP_BEGIN_NAMESPACE + +template +istream& _STLP_CALL +operator>>(istream& __is, bitset<_Nb>& __x) { + typedef typename string::traits_type _Traits; + string __tmp; + __tmp.reserve(_Nb); + + // Skip whitespace + typename istream::sentry __sentry(__is); + if (__sentry) { + streambuf* __buf = __is.rdbuf(); + for (size_t __i = 0; __i < _Nb; ++__i) { + static typename _Traits::int_type __eof = _Traits::eof(); + + typename _Traits::int_type __c1 = __buf->sbumpc(); + if (_Traits::eq_int_type(__c1, __eof)) { + __is.setstate(ios_base::eofbit); + break; + } + else { + typename _Traits::char_type __c2 = _Traits::to_char_type(__c1); + char __c = __is.narrow(__c2, '*'); + + if (__c == '0' || __c == '1') + __tmp.push_back(__c); + else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) { + __is.setstate(ios_base::failbit); + break; + } + } + } + + if (__tmp.empty()) + __is.setstate(ios_base::failbit); + else + __x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb); + } + + return __is; +} + +template +ostream& _STLP_CALL +operator<<(ostream& __os, const bitset<_Nb>& __x) { + string __tmp; + __x._M_copy_to_string(__tmp); + return __os << __tmp; +} + +# if !defined (_STLP_NO_WCHAR_T) + +template +wistream& _STLP_CALL +operator>>(wistream& __is, bitset<_Nb>& __x) { + typedef typename wstring::traits_type _Traits; + wstring __tmp; + __tmp.reserve(_Nb); + + // Skip whitespace + typename wistream::sentry __sentry(__is); + if (__sentry) { + wstreambuf* __buf = __is.rdbuf(); + for (size_t __i = 0; __i < _Nb; ++__i) { + static typename _Traits::int_type __eof = _Traits::eof(); + + typename _Traits::int_type __c1 = __buf->sbumpc(); + if (_Traits::eq_int_type(__c1, __eof)) { + __is.setstate(ios_base::eofbit); + break; + } + else { + typename _Traits::char_type __c2 = _Traits::to_char_type(__c1); + char __c = __is.narrow(__c2, '*'); + + if (__c == '0' || __c == '1') + __tmp.push_back(__c); + else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) { + __is.setstate(ios_base::failbit); + break; + } + } + } + + if (__tmp.empty()) + __is.setstate(ios_base::failbit); + else + __x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb); + } + + return __is; +} + +template +wostream& _STLP_CALL +operator<<(wostream& __os, const bitset<_Nb>& __x) { + wstring __tmp; + __x._M_copy_to_string(__tmp); + return __os << __tmp; +} + +# endif /* _STLP_NO_WCHAR_T */ +# endif +#endif + +#endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */ + +#undef bitset + +_STLP_END_NAMESPACE + +#undef __BITS_PER_WORD +#undef __BITSET_WORDS + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_BITSET_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_bvector.h b/sdk/tlibstdcxx/stlport/stl/_bvector.h new file mode 100644 index 0000000000..bf417f179c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_bvector.h @@ -0,0 +1,841 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_BVECTOR_H +#define _STLP_INTERNAL_BVECTOR_H + +#ifndef _STLP_INTERNAL_VECTOR_H +# include +#endif + +#define _STLP_WORD_BIT (int(CHAR_BIT * sizeof(unsigned int))) + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _Bit_reference { + unsigned int* _M_p; + unsigned int _M_mask; + _Bit_reference(unsigned int* __x, unsigned int __y) + : _M_p(__x), _M_mask(__y) {} + +public: + _Bit_reference() : _M_p(0), _M_mask(0) {} + + operator bool() const { + return !(!(*_M_p & _M_mask)); + } + _Bit_reference& operator = (bool __x) { + if (__x) *_M_p |= _M_mask; + else *_M_p &= ~_M_mask; + return *this; + } + _Bit_reference& operator = (const _Bit_reference& __x) { + return *this = bool(__x); + } + bool operator == (const _Bit_reference& __x) const { + return bool(*this) == bool(__x); + } + bool operator < (const _Bit_reference& __x) const { + return !bool(*this) && bool(__x); + } + + _Bit_reference& operator |= (bool __x) { + if (__x) + *_M_p |= _M_mask; + return *this; + } + _Bit_reference& operator &= (bool __x) { + if (!__x) + *_M_p &= ~_M_mask; + return *this; + } + void flip() { *_M_p ^= _M_mask; } +}; + + +_STLP_MOVE_TO_STD_NAMESPACE + +inline void swap(_STLP_PRIV _Bit_reference& __x, _STLP_PRIV _Bit_reference& __y) { + bool __tmp = (bool)__x; + __x = __y; + __y = __tmp; +} + +// Might not be very useful but costs nothing! +_STLP_TEMPLATE_NULL +struct __type_traits<_STLP_PRIV _Bit_reference> { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _Bit_iterator_base { + typedef ptrdiff_t difference_type; + + unsigned int* _M_p; + unsigned int _M_offset; + + void _M_bump_up() { + if (_M_offset++ == _STLP_WORD_BIT - 1) { + _M_offset = 0; + ++_M_p; + } + } + + void _M_bump_down() { + if (_M_offset-- == 0) { + _M_offset = _STLP_WORD_BIT - 1; + --_M_p; + } + } + + _Bit_iterator_base() : _M_p(0), _M_offset(0) {} + _Bit_iterator_base(unsigned int* __x, unsigned int __y) : _M_p(__x), _M_offset(__y) {} +// see comment in doc/README.evc4 and doc/README.evc8 +#if defined(_MSC_VER) && _MSC_VER<=1401 && defined(MIPS) && defined(NDEBUG) + _Bit_iterator_base( const _Bit_iterator_base& __x) : _M_p(__x._M_p), _M_offset(__x._M_offset) {} +#endif + // _Bit_iterator_base& operator = ( const _Bit_iterator_base& __x) { _M_p = __x._M_p ; _M_offset = __x._M_offset ; return *this; } + + void _M_advance (difference_type __i) { + difference_type __n = __i + _M_offset; + _M_p += __n / _STLP_WORD_BIT; + __n = __n % _STLP_WORD_BIT; + if (__n < 0) { + _M_offset = (unsigned int) __n + _STLP_WORD_BIT; + --_M_p; + } else + _M_offset = (unsigned int) __n; + } + + difference_type _M_subtract(const _Bit_iterator_base& __x) const { + return _STLP_WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset; + } +}; + +inline bool _STLP_CALL operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return __y._M_p == __x._M_p && __y._M_offset == __x._M_offset; +} +inline bool _STLP_CALL operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return __y._M_p != __x._M_p || __y._M_offset != __x._M_offset; +} + +inline bool _STLP_CALL operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return __x._M_p < __y._M_p || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset); +} + +inline bool _STLP_CALL operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return operator <(__y , __x); +} +inline bool _STLP_CALL operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return !(__y < __x); +} +inline bool _STLP_CALL operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return !(__x < __y); +} + +template +struct _Bit_iter : public _Bit_iterator_base { + typedef _Ref reference; + typedef _Ptr pointer; + typedef _Bit_iter<_Ref, _Ptr> _Self; + typedef random_access_iterator_tag iterator_category; + typedef bool value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + + _Bit_iter(unsigned int* __x, unsigned int __y) : _Bit_iterator_base(__x, __y) {} + _Bit_iter() {} + + _Bit_iter(const _Bit_iter<_Bit_reference, _Bit_reference*>& __x): + _Bit_iterator_base((const _Bit_iterator_base&)__x) {} + + // _Self& operator = (const _Bit_iter<_Bit_reference, _Bit_reference*>& __x) + // { (_Bit_iterator_base&)*this = (const _Bit_iterator_base&)__x; return *this; } + + reference operator*() const { + return _Bit_reference(_M_p, 1UL << _M_offset); + } + _Self& operator++() { + _M_bump_up(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + _M_bump_up(); + return __tmp; + } + _Self& operator--() { + _M_bump_down(); + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + _M_bump_down(); + return __tmp; + } + _Self& operator+=(difference_type __i) { + _M_advance(__i); + return *this; + } + _Self& operator-=(difference_type __i) { + *this += -__i; + return *this; + } + _Self operator+(difference_type __i) const { + _Self __tmp = *this; + return __tmp += __i; + } + _Self operator-(difference_type __i) const { + _Self __tmp = *this; + return __tmp -= __i; + } + difference_type operator-(const _Self& __x) const { + return _M_subtract(__x); + } + reference operator[](difference_type __i) { return *(*this + __i); } +}; + +template +inline _Bit_iter<_Ref,_Ptr> _STLP_CALL +operator+(ptrdiff_t __n, const _Bit_iter<_Ref, _Ptr>& __x) { + return __x + __n; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct __type_traits< _STLP_PRIV _Bit_iter<_Ref, _Ptr> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +inline random_access_iterator_tag iterator_category(const _STLP_PRIV _Bit_iterator_base&) +{ return random_access_iterator_tag(); } +inline ptrdiff_t* distance_type(const _STLP_PRIV _Bit_iterator_base&) +{ return (ptrdiff_t*)0; } +inline bool* value_type(const _STLP_PRIV _Bit_iter<_STLP_PRIV _Bit_reference, _STLP_PRIV _Bit_reference*>&) +{ return (bool*)0; } +inline bool* value_type(const _STLP_PRIV _Bit_iter&) +{ return (bool*)0; } +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +typedef _Bit_iter _Bit_const_iterator; +typedef _Bit_iter<_Bit_reference, _Bit_reference*> _Bit_iterator; + +// Bit-vector base class, which encapsulates the difference between +// old SGI-style allocators and standard-conforming allocators. +template +class _Bvector_base { + typedef _Bvector_base<_Alloc> _Self; +public: + _STLP_FORCE_ALLOCATORS(bool, _Alloc) + typedef _Alloc allocator_type; + typedef unsigned int __chunk_type; + typedef typename _Alloc_traits<__chunk_type, _Alloc>::allocator_type __chunk_allocator_type; + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR(__STATIC_CAST(const __chunk_allocator_type&, _M_end_of_storage), bool); } + + _Bvector_base(const allocator_type& __a) + : _M_start(), _M_finish(), _M_end_of_storage(_STLP_CONVERT_ALLOCATOR(__a, __chunk_type), + (__chunk_type*)0) + {} +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Bvector_base(__move_source<_Self> src) + : _M_start(src.get()._M_start), _M_finish(src.get()._M_finish), + _M_end_of_storage(src.get()._M_end_of_storage) { + //Make the source destroyable + src.get()._M_start._M_p = 0; + } +#endif + + ~_Bvector_base() { + _M_deallocate(); + } + +protected: + + static size_t _M_bits_to_chunks(size_t __n_bits) + { return (__n_bits + _STLP_WORD_BIT - 1) / _STLP_WORD_BIT; } + + __chunk_type* _M_bit_alloc(size_t __n) + { return _M_end_of_storage.allocate(_M_bits_to_chunks(__n)); } + + void _M_deallocate() { + if (_M_start._M_p) + _M_end_of_storage.deallocate(_M_start._M_p, + _M_end_of_storage._M_data - _M_start._M_p); + } + + _Bit_iterator _M_start; + _Bit_iterator _M_finish; + _STLP_alloc_proxy<__chunk_type*, __chunk_type, __chunk_allocator_type> _M_end_of_storage; +}; + + +// The next few lines are confusing. What we're doing is declaring a +// partial specialization of vector if we have the necessary +// compiler support. Otherwise, we define a class bit_vector which uses +// the default allocator. + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_BOOL) && !defined (__SUNPRO_CC) +# define _STLP_VECBOOL_TEMPLATE +# define __BVEC_TMPL_HEADER template +#else +# undef _STLP_VECBOOL_TEMPLATE +# ifdef _STLP_NO_BOOL +# define __BVEC_TMPL_HEADER +# else +# define __BVEC_TMPL_HEADER _STLP_TEMPLATE_NULL +# endif +# define _Alloc allocator +#endif + +#if defined (_STLP_DEBUG) +# define vector _STLP_NON_DBG_NAME(vector) +#endif + +#ifdef _STLP_NO_BOOL +# define __BVECTOR_QUALIFIED bit_vector +# define __BVECTOR bit_vector +#else +# ifdef _STLP_VECBOOL_TEMPLATE +# define __BVECTOR_QUALIFIED vector +# else +# define __BVECTOR_QUALIFIED vector > +# endif +# if defined (_STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS) +# define __BVECTOR __BVECTOR_QUALIFIED +# else +# define __BVECTOR vector +# endif +#endif + +#if !defined (_STLP_DEBUG) || defined (_STLP_NO_BOOL) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +__BVEC_TMPL_HEADER +class __BVECTOR_QUALIFIED : public _STLP_PRIV _Bvector_base<_Alloc > +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_DEBUG) + , public __stlport_class< __BVECTOR_QUALIFIED > +#endif +{ + typedef _STLP_PRIV _Bvector_base<_Alloc > _Base; + typedef __BVECTOR_QUALIFIED _Self; +public: + typedef bool value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _STLP_PRIV _Bit_reference reference; + typedef bool const_reference; + typedef _STLP_PRIV _Bit_reference* pointer; + typedef const bool* const_pointer; + typedef random_access_iterator_tag _Iterator_category; + + typedef _STLP_PRIV _Bit_iterator iterator; + typedef _STLP_PRIV _Bit_const_iterator const_iterator; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +#ifdef _STLP_VECBOOL_TEMPLATE + typedef _STLP_TYPENAME _STLP_PRIV _Bvector_base<_Alloc >::allocator_type allocator_type; + typedef _STLP_TYPENAME _STLP_PRIV _Bvector_base<_Alloc >::__chunk_type __chunk_type; +#else + typedef _STLP_PRIV _Bvector_base<_Alloc >::allocator_type allocator_type; + typedef _STLP_PRIV _Bvector_base<_Alloc >::__chunk_type __chunk_type; +#endif + +protected: + + void _M_initialize(size_type __n) { + __chunk_type* __q = this->_M_bit_alloc(__n); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__n); + this->_M_start = iterator(__q, 0); + this->_M_finish = this->_M_start + difference_type(__n); + } + void _M_insert_aux(iterator __position, bool __x) { + if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) { + _STLP_PRIV __copy_backward(__position, this->_M_finish, this->_M_finish + 1, + random_access_iterator_tag(), (difference_type*)0 ); + *__position = __x; + ++this->_M_finish; + } + else { + size_type __len = size() ? 2 * size() : _STLP_WORD_BIT; + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + *__i++ = __x; + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_initialize_range(_InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + this->_M_start = iterator(); + this->_M_finish = iterator(); + this->_M_end_of_storage._M_data = 0; + for ( ; __first != __last; ++__first) + push_back(*__first); + } + + template + void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + size_type __n = _STLP_STD::distance(__first, __last); + _M_initialize(__n); + _STLP_STD::copy(__first, __last, this->_M_start); + } + + template + void _M_insert_range(iterator __pos, + _InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) { + __pos = insert(__pos, *__first); + ++__pos; + } + } + + template + void _M_insert_range(iterator __position, + _ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + if (__first != __last) { + size_type __n = _STLP_STD::distance(__first, __last); + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + difference_type(__n), + random_access_iterator_tag(), (difference_type*)0 ); + _STLP_STD::copy(__first, __last, __position); + this->_M_finish += difference_type(__n); + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + __i = _STLP_STD::copy(__first, __last, __i); + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + } + +#endif /* _STLP_MEMBER_TEMPLATES */ + +public: + iterator begin() { return this->_M_start; } + const_iterator begin() const { return this->_M_start; } + iterator end() { return this->_M_finish; } + const_iterator end() const { return this->_M_finish; } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + size_type size() const { return size_type(end() - begin()); } + size_type max_size() const { return size_type(-1); } + size_type capacity() const { + return size_type(const_iterator(this->_M_end_of_storage._M_data, 0) - begin()); + } + bool empty() const { return begin() == end(); } + reference operator[](size_type __n) + { return *(begin() + difference_type(__n)); } + const_reference operator[](size_type __n) const + { return *(begin() + difference_type(__n)); } + + void _M_range_check(size_type __n) const { + if (__n >= this->size()) + __stl_throw_range_error("vector"); + } + + reference at(size_type __n) + { _M_range_check(__n); return (*this)[__n]; } + const_reference at(size_type __n) const + { _M_range_check(__n); return (*this)[__n]; } + + explicit __BVECTOR(const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) {} + + __BVECTOR(size_type __n, bool __val, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + _M_initialize(__n); + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __val ? ~0 : 0); + } + + explicit __BVECTOR(size_type __n) + : _STLP_PRIV _Bvector_base<_Alloc >(allocator_type()) { + _M_initialize(__n); + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), 0); + } + + __BVECTOR(const _Self& __x) + : _STLP_PRIV _Bvector_base<_Alloc >(__x.get_allocator()) { + _M_initialize(__x.size()); + _STLP_STD::copy(__x.begin(), __x.end(), this->_M_start); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) { + _M_initialize(__n); + fill(this->_M_start._M_p, this->_M_end_of_storage._M_data, __x ? ~0 : 0); + } + + template + void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_initialize_range(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); + } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + // Check whether it's an integral type. If so, it's not an iterator. + template + __BVECTOR(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _Bvector_base<_Alloc >(allocator_type()) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +# endif + template + __BVECTOR(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#else /* _STLP_MEMBER_TEMPLATES */ + __BVECTOR(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + size_type __n = _STLP_STD::distance(__first, __last); + _M_initialize(__n); + _STLP_STD::copy(__first, __last, this->_M_start); + } + __BVECTOR(const bool* __first, const bool* __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + size_type __n = _STLP_STD::distance(__first, __last); + _M_initialize(__n); + _STLP_STD::copy(__first, __last, this->_M_start); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + __BVECTOR(__move_source<_Self> src) + : _STLP_PRIV _Bvector_base<_Alloc >(__move_source<_Base>(src.get())) {} +#endif + + ~__BVECTOR() {} + + __BVECTOR_QUALIFIED& operator=(const __BVECTOR_QUALIFIED& __x) { + if (&__x == this) return *this; + if (__x.size() > capacity()) { + this->_M_deallocate(); + _M_initialize(__x.size()); + } + _STLP_STD::copy(__x.begin(), __x.end(), begin()); + this->_M_finish = begin() + difference_type(__x.size()); + return *this; + } + + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void _M_fill_assign(size_t __n, bool __x) { + if (__n > size()) { + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0); + insert(end(), __n - size(), __x); + } + else { + erase(begin() + __n, end()); + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0); + } + } + void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } + + template + void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&) + { _M_fill_assign((size_t) __n, (bool) __val); } + + template + void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&) + { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); } + + template + void _M_assign_aux(_InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + iterator __cur = begin(); + for ( ; __first != __last && __cur != end(); ++__cur, ++__first) + *__cur = *__first; + if (__first == __last) + erase(__cur, end()); + else + insert(end(), __first, __last); + } + + template + void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + size_type __len = _STLP_STD::distance(__first, __last); + if (__len < size()) + erase(_STLP_STD::copy(__first, __last, begin()), end()); + else { + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, size()); + _STLP_STD::copy(__first, __mid, begin()); + insert(end(), __mid, __last); + } + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void reserve(size_type __n) { + if (capacity() < __n) { + if (max_size() < __n) + __stl_throw_length_error("vector"); + __chunk_type* __q = this->_M_bit_alloc(__n); + _STLP_PRIV _Bit_iterator __z(__q, 0); + this->_M_finish = _STLP_STD::copy(begin(), end(), __z); + this->_M_deallocate(); + this->_M_start = iterator(__q, 0); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__n); + } + } + + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(end() - 1); } + const_reference back() const { return *(end() - 1); } + void push_back(bool __x) { + if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) { + *(this->_M_finish) = __x; + ++this->_M_finish; + } + else + _M_insert_aux(end(), __x); + } + void swap(__BVECTOR_QUALIFIED& __x) { + _STLP_STD::swap(this->_M_start, __x._M_start); + _STLP_STD::swap(this->_M_finish, __x._M_finish); + this->_M_end_of_storage.swap(__x._M_end_of_storage); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(__BVECTOR_QUALIFIED& __x) { swap(__x); } +#endif + + iterator insert(iterator __position, bool __x = bool()) { + difference_type __n = __position - begin(); + if (this->_M_finish._M_p != this->_M_end_of_storage._M_data && __position == end()) { + *(this->_M_finish) = __x; + ++this->_M_finish; + } + else + _M_insert_aux(__position, __x); + return begin() + __n; + } + +#if defined (_STLP_MEMBER_TEMPLATES) + + template + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + const __true_type&) { + _M_fill_insert(__pos, (size_type) __n, (bool) __x); + } + + template + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_insert_range(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); + } + + // Check whether it's an integral type. If so, it's not an iterator. + template + void insert(iterator __position, + _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __position, + const_iterator __first, const_iterator __last) { + if (__first == __last) return; + size_type __n = _STLP_STD::distance(__first, __last); + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + __n, + random_access_iterator_tag(), (difference_type*)0 ); + _STLP_STD::copy(__first, __last, __position); + this->_M_finish += __n; + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + __i = _STLP_STD::copy(__first, __last, __i); + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + + void insert(iterator __position, const bool* __first, const bool* __last) { + if (__first == __last) return; + size_type __n = _STLP_STD::distance(__first, __last); + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + __n, + random_access_iterator_tag(), (difference_type*)0 ); + _STLP_STD::copy(__first, __last, __position); + this->_M_finish += __n; + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + __i = _STLP_STD::copy(__first, __last, __i); + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void _M_fill_insert(iterator __position, size_type __n, bool __x) { + if (__n == 0) return; + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + difference_type(__n), + random_access_iterator_tag(), (difference_type*)0 ); + fill(__position, __position + difference_type(__n), __x); + this->_M_finish += difference_type(__n); + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + fill_n(__i, __n, __x); + this->_M_finish = _STLP_STD::copy(__position, end(), __i + difference_type(__n)); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + + void insert(iterator __position, size_type __n, bool __x) { + _M_fill_insert(__position, __n, __x); + } + + void pop_back() { + --this->_M_finish; + } + iterator erase(iterator __position) { + if (__position + 1 != end()) + _STLP_STD::copy(__position + 1, end(), __position); + --this->_M_finish; + return __position; + } + iterator erase(iterator __first, iterator __last) { + this->_M_finish = _STLP_STD::copy(__last, end(), __first); + return __first; + } + void resize(size_type __new_size, bool __x = bool()) { + if (__new_size < size()) + erase(begin() + difference_type(__new_size), end()); + else + insert(end(), __new_size - size(), __x); + } + void flip() { + for (__chunk_type* __p = this->_M_start._M_p; __p != this->_M_end_of_storage._M_data; ++__p) + *__p = ~*__p; + } + + void clear() { erase(begin(), end()); } +}; + +#if defined (_STLP_NO_BOOL) || defined (__HP_aCC) // fixed soon (03/17/2000) +# define _STLP_TEMPLATE_HEADER __BVEC_TMPL_HEADER +# define _STLP_TEMPLATE_CONTAINER __BVECTOR_QUALIFIED +# include +# undef _STLP_TEMPLATE_CONTAINER +# undef _STLP_TEMPLATE_HEADER +#endif /* NO_BOOL */ + +#if defined (_STLP_DEBUG) && !defined (_STLP_NO_BOOL) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#undef vector +#undef _Alloc +#undef _STLP_VECBOOL_TEMPLATE +#undef __BVECTOR +#undef __BVECTOR_QUALIFIED +#undef __BVEC_TMPL_HEADER + +#undef _STLP_WORD_BIT + +#endif /* _STLP_INTERNAL_BVECTOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_carray.h b/sdk/tlibstdcxx/stlport/stl/_carray.h new file mode 100644 index 0000000000..560bab2957 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_carray.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_CARRAY_H +#define _STLP_CARRAY_H + +/* Purpose: Mimic a pur C array with the additionnal feature of + * being able to be used with type not default constructible. + */ + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _CArray { + _CArray (const _Tp& __val) { + for (size_t __i = 0; __i < _Nb; ++__i) { + _Copy_Construct(__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)), __val); + } + } + + ~_CArray() { + _Destroy_Range(__REINTERPRET_CAST(_Tp*, _M_data + 0), + __REINTERPRET_CAST(_Tp*, _M_data + _Nb * sizeof(_Tp))); + } + + _Tp& operator [] (size_t __i) { + _STLP_ASSERT(__i < _Nb) + return *__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)); + } + +private: + char _M_data[sizeof(_Tp) * _Nb]; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif //_STLP_CARRAY_H diff --git a/sdk/tlibstdcxx/stlport/stl/_cctype.h b/sdk/tlibstdcxx/stlport/stl/_cctype.h new file mode 100644 index 0000000000..cf82524ae2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cctype.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CCTYPE +#define _STLP_INTERNAL_CCTYPE + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cctype) +# endif +#else +# include +#endif /* _STLP_USE_NEW_C_HEADERS */ + +#if ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +# if defined ( _STLP_IMPORT_VENDOR_CSTD ) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::isalnum; +using _STLP_VENDOR_CSTD::isalpha; +using _STLP_VENDOR_CSTD::iscntrl; +using _STLP_VENDOR_CSTD::isdigit; +using _STLP_VENDOR_CSTD::isgraph; +using _STLP_VENDOR_CSTD::islower; +using _STLP_VENDOR_CSTD::isprint; +using _STLP_VENDOR_CSTD::ispunct; +using _STLP_VENDOR_CSTD::isspace; +using _STLP_VENDOR_CSTD::isupper; +using _STLP_VENDOR_CSTD::isxdigit; +using _STLP_VENDOR_CSTD::tolower; +using _STLP_VENDOR_CSTD::toupper; +_STLP_END_NAMESPACE +# endif /* _STLP_IMPORT_VENDOR_CSTD*/ +#endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_clocale.h b/sdk/tlibstdcxx/stlport/stl/_clocale.h new file mode 100644 index 0000000000..091a9b6649 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_clocale.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CLOCALE +#define _STLP_INTERNAL_CLOCALE + +#if !defined (_STLP_WCE_EVC3) + +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(clocale) +# endif +# else +# include +# endif + +# if defined (_STLP_IMPORT_VENDOR_CSTD) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::lconv; +# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +using _STLP_VENDOR_CSTD::localeconv; +using _STLP_VENDOR_CSTD::setlocale; +# endif +_STLP_END_NAMESPACE +# endif + +#endif /* !_STLP_WCE_EVC3 */ + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_cmath.h b/sdk/tlibstdcxx/stlport/stl/_cmath.h new file mode 100644 index 0000000000..0ceb8005bc --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cmath.h @@ -0,0 +1,579 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CMATH +#define _STLP_INTERNAL_CMATH + +/* gcc do not like when a using directive appear after a function + * declaration. cmath have abs overloads and cstdlib a using directive + * so cstdlib has to be included first. + */ +#if defined (__GNUC__) && defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib) +# endif +#endif + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_NO_NAMESPACES) && !defined (exception) +# define exception __math_exception +# endif +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cmath) +# endif +# if defined (_STLP_HAS_NO_NAMESPACES) +# undef exception +# endif +#else +# include +#endif + +#if (defined (__SUNPRO_CC) && (__SUNPRO_CC > 0x500)) || \ + !(defined (__IBMCPP__) && (__IBMCPP__ >= 500) || !(defined(__HP_aCC) && (__HP_aCC >= 30000) )) +# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC) +// All the other hypot stuff is going to be at file scope, so follow along here. +namespace std { +# endif +extern "C" double hypot(double x, double y); +# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC) +} +# endif + +#endif + +#if defined (__sun) && defined (__GNUC__) +extern "C" { + float __cosf(float v); + float __sinf(float v); + float __atan2f(float, float); + float __coshf(float v); + float __sinhf(float v); + float __sqrtf(float v); + float __expf(float v); + float __logf(float v); + float __log10f(float v); + + long double __cosl(long double v); + long double __sinl(long double v); + long double __atan2l(long double, long double); + long double __coshl(long double v); + long double __sinhl(long double v); + long double __sqrtl(long double v); + long double __expl(long double v); + long double __logl(long double v); + long double __log10l(long double v); +} + +extern "C" { + inline float cosf(float v) { return __cosf(v); } + inline float sinf(float v) { return __sinf(v); } + inline float atan2f(float v1, float v2) { return __atan2f(v1,v2); } + inline float coshf(float v) { return __coshf(v); } + inline float sinhf(float v) { return __sinhf(v); } + inline float sqrtf(float v) { return __sqrtf(v); } + inline float expf(float v) { return __expf(v); } + inline float logf(float v) { return __logf(v); } + inline float log10f(float v) { return __log10f(v); } + + inline long double cosl(long double v) { return __cosl(v); } + inline long double sinl(long double v) { return __sinl(v); } + inline long double atan2l(long double v1, long double v2) { return __atan2l(v1,v2); } + inline long double coshl(long double v) { return __coshl(v); } + inline long double sinhl(long double v) { return __sinhl(v); } + inline long double sqrtl(long double v) { return __sqrtl(v); } + inline long double expl(long double v) { return __expl(v); } + inline long double logl(long double v) { return __logl(v); } + inline long double log10l(long double v) { return __log10l(v); } +} +#endif // __sun && __GNUC__ + +#if defined (__sun) +extern "C" { +extern float __acosf(float); +extern float __asinf(float); +extern float __atanf(float); +extern float __atan2f(float, float); +extern float __ceilf(float); +extern float __cosf(float); +extern float __coshf(float); +extern float __expf(float); +extern float __fabsf(float); +extern float __floorf(float); +extern float __fmodf(float, float); +extern float __frexpf(float, int *); +extern float __ldexpf(float, int); +extern float __logf(float); +extern float __log10f(float); +extern float __modff(float, float *); +extern float __powf(float, float); +extern float __sinf(float); +extern float __sinhf(float); +extern float __sqrtf(float); +extern float __tanf(float); +extern float __tanhf(float); + +extern long double __acosl(long double); +extern long double __asinl(long double); +extern long double __atanl(long double); +extern long double __atan2l(long double, long double); +extern long double __ceill(long double); +extern long double __cosl(long double); +extern long double __coshl(long double); +extern long double __expl(long double); +extern long double __fabsl(long double); +extern long double __floorl(long double); +extern long double __fmodl(long double, long double); +extern long double __frexpl(long double, int *); +extern long double __ldexpl(long double, int); +extern long double __logl(long double); +extern long double __log10l(long double); +extern long double __modfl(long double, long double *); +extern long double __powl(long double, long double); +extern long double __sinl(long double); +extern long double __sinhl(long double); +extern long double __sqrtl(long double); +extern long double __tanl(long double); +extern long double __tanhl(long double); +} +#endif + +#if defined (__BORLANDC__) +# define _STLP_CMATH_FUNC_NAMESPACE _STLP_VENDOR_CSTD +#else +# define _STLP_CMATH_FUNC_NAMESPACE +#endif + +#if !defined (__sun) || defined (__GNUC__) +# define _STLP_MATH_INLINE(float_type, func, cfunc) \ + inline float_type func (float_type x) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x); } +# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \ + inline float_type func (float_type x, type y) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x, y); } +# define _STLP_MATH_INLINE_D(float_type, func, cfunc) +# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc) +#else +# ifdef __SUNPRO_CC +# define _STLP_MATH_INLINE(float_type, func, cfunc) \ + inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::__##cfunc(x); } +# define _STLP_MATH_INLINE_D(float_type, func, cfunc) \ + inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::cfunc(x); } +# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \ + inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::__##cfunc(x,y); } +# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc) \ + inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::cfunc(x,y); } +# else +# error Unknown compiler for the Sun platform +# endif +#endif + +/** macros to define math functions +These macros (having an X somewhere in the name) forward to the C library's +double functions but cast the arguments and return values to the given type. */ + +#define _STLP_MATH_INLINEX(__type,func,cfunc) \ + inline __type func (__type x) \ + { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x)); } +#define _STLP_MATH_INLINE2X(__type1,__type2,func,cfunc) \ + inline __type1 func (__type1 x, __type2 y) \ + { return __STATIC_CAST(__type1, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, y)); } +#define _STLP_MATH_INLINE2PX(__type,func,cfunc) \ + inline __type func (__type x, __type *y) { \ + double tmp1, tmp2; \ + tmp1 = _STLP_CMATH_FUNC_NAMESPACE::cfunc(__STATIC_CAST(double, x), &tmp2); \ + *y = __STATIC_CAST(__type, tmp2); \ + return __STATIC_CAST(__type, tmp1); \ + } +#define _STLP_MATH_INLINE2XX(__type,func,cfunc) \ + inline __type func (__type x, __type y) \ + { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, (double)y)); } + + +/** rough characterization of compiler and native C library +For the compiler, it can either support long double or not. If it doesn't, the +macro _STLP_NO_LONG_DOUBLE is not defined and we don't define any long double +overloads. +For the native C library the question is whether it has variants with an 'f' +suffix (for float as opposed to double) or an 'l' suffix (for long double). If +the float variants are missing, _STLP_NO_VENDOR_MATH_F is defined, when the +long double variants are missing, _STLP_NO_VENDOR_MATH_L is defined. Of course +the latter doesn't make sense anyway when the compiler already has no long +double support. + +Those two traits determine a) which overloads get defined and b) how they are +defined. + +Meaning of suffixes: +"" : function returning and taking a float_type +"2" : function returning a float_type and taking to float_types +"2P" : function returning a float_type and taking a float_type and a float_type* +"2PI": function returning a float_type and taking a float_type and an int* +"2I" : function returning a float_type and taking a float_Type and an int +*/ + +#if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_NO_VENDOR_MATH_L) && !defined (_STLP_NO_VENDOR_MATH_F) + // long double support and both e.g. sinl(long double) and sinf(float) + // This is the default for a correct and complete native library. +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINE(float,func,cf##f) \ + _STLP_MATH_INLINE_D(double,func,cf) \ + _STLP_MATH_INLINE(long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2(float,float,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,double,func,cf) \ + _STLP_MATH_INLINE2(long double,long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2(float,float *,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,double *,func,cf) \ + _STLP_MATH_INLINE2(long double,long double *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2(float,int *,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,int *,func,cf) \ + _STLP_MATH_INLINE2(long double,int *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2(float,int,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,int,func,cf) \ + _STLP_MATH_INLINE2(long double,int,func,cf##l) +#else +# if !defined (_STLP_NO_LONG_DOUBLE) +# if !defined (_STLP_NO_VENDOR_MATH_F) + // long double support and e.g. sinf(float) but not e.g. sinl(long double) +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINE(float,func,cf##f) \ + _STLP_MATH_INLINEX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2(float,float,func,cf##f) \ + _STLP_MATH_INLINE2XX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2(float,float *,func,cf##f) \ + _STLP_MATH_INLINE2PX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2(float,int *,func,cf##f) \ + _STLP_MATH_INLINE2X(long double,int *,func,cf) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2(float,int,func,cf##f) \ + _STLP_MATH_INLINE2X(long double,int,func,cf) +# elif !defined (_STLP_NO_VENDOR_MATH_L) + // long double support and e.g. sinl(long double) but not e.g. sinf(float) +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINEX(float,func,cf) \ + _STLP_MATH_INLINE(long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2XX(float,func,cf) \ + _STLP_MATH_INLINE2(long double,long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2PX(float,func,cf) \ + _STLP_MATH_INLINE2(long double,long double *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2X(float,int *,func,cf) \ + _STLP_MATH_INLINE2(long double,int *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2X(float,int,func,cf) \ + _STLP_MATH_INLINE2(long double,int,func,cf##l) +# else +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINEX(float,func,cf) \ + _STLP_MATH_INLINEX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2XX(float,func,cf) \ + _STLP_MATH_INLINE2XX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2PX(float,func,cf) \ + _STLP_MATH_INLINE2PX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2X(float,int *,func,cf) \ + _STLP_MATH_INLINE2X(long double,int *,func,cf) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2X(float,int,func,cf) \ + _STLP_MATH_INLINE2X(long double,int,func,cf) +# endif +# else +# if !defined (_STLP_NO_VENDOR_MATH_F) +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINE(float,func,cf##f) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2(float,float,func,cf##f) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2(float,float *,func,cf##f) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2(float,int *,func,cf##f) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2(float,int,func,cf##f) +# else // _STLP_NO_VENDOR_MATH_F + // neither long double support nor e.g. sinf(float) functions +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINEX(float,func,cf) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2XX(float,func,cf) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2PX(float,func,cf) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2X(float,int *,func,cf) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2X(float,int,func,cf) +# endif // _STLP_NO_VENDOR_MATH_F +# endif +#endif + +#if defined (_STLP_WCE) || \ + (defined(_STLP_MSVC) && (_STLP_MSVC <= 1300) && defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */) +/* + * dums: VC6 has all the required C++ functions but only define them if + * _MSC_EXTENSIONS is not defined (a bug?). STLport just do the same + * thing also when _MSC_EXTENSIONS is defined. + * TODO: above check (_STLP_MSVC <= 1300) also catches VC7.0, is that intended? + */ +//We have to tell the compilers that abs, acos ... math functions are not intrinsic +//otherwise we have Internal Compiler Error in release mode... +# pragma warning(push) +# pragma warning(disable: 4162) // no function with C linkage found +# pragma warning(disable: 4163) // not available as an intrinsic function +# pragma function (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh) +# if defined (_STLP_WCE) +# pragma function (ceil, floor) +# endif +# define _STLP_RESTORE_FUNCTION_INTRINSIC +#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS + +#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS) +/* In this config Borland native lib only define functions in std namespace. + * In order to have all overloads in STLport namespace we need to add the + * double overload in global namespace. We do not use a using statement to avoid + * import of invalid overload. + */ +# define _STLP_DMATH_INLINE(func) _STLP_MATH_INLINE(double, func, func) +# define _STLP_DMATH_INLINE2(func) _STLP_MATH_INLINE2(double, double, func, func) + +_STLP_DMATH_INLINE(acos) +_STLP_DMATH_INLINE(asin) +_STLP_DMATH_INLINE(atan) +_STLP_DMATH_INLINE2(atan2) +_STLP_DMATH_INLINE(ceil) +_STLP_DMATH_INLINE(cos) +_STLP_DMATH_INLINE(cosh) +_STLP_DMATH_INLINE(exp) +_STLP_DMATH_INLINE(fabs) +_STLP_DMATH_INLINE(floor) +_STLP_DMATH_INLINE2(fmod) +_STLP_MATH_INLINE2X(double, int*, frexp, frexp) +_STLP_MATH_INLINE2X(double, int, ldexp, ldexp) +_STLP_DMATH_INLINE(log) +_STLP_DMATH_INLINE(log10) +_STLP_MATH_INLINE2PX(double, modf, modf) +_STLP_DMATH_INLINE(sin) +_STLP_DMATH_INLINE(sinh) +_STLP_DMATH_INLINE(sqrt) +_STLP_DMATH_INLINE(tan) +_STLP_DMATH_INLINE(tanh) +_STLP_DMATH_INLINE2(pow) +_STLP_DMATH_INLINE2(hypot) + +# undef _STLP_DMATH_INLINE +# undef _STLP_DMATH_INLINE2 +#endif + +#if defined (__DMC__) +# if defined (fabs) +inline double __stlp_fabs(double __x) { return fabs(__x); } +# undef fabs +inline double fabs(double __x) { return __stlp_fabs(__x); } +# endif +# if defined (cos) +inline double __stlp_cos(double __x) { return cos(__x); } +# undef cos +inline double cos(double __x) { return __stlp_cos(__x); } +# endif +# if defined (sin) +inline double __stlp_sin(double __x) { return sin(__x); } +# undef sin +inline double sin(double __x) { return __stlp_sin(__x); } +# endif +# if defined (sqrt) +inline double __stlp_sqrt(double __x) { return sqrt(__x); } +# undef sqrt +inline double sqrt(double __x) { return __stlp_sqrt(__x); } +# endif +# if defined (ldexp) +inline double __stlp_ldexp(double __x, int __y) { return ldexp(__x, __y); } +# undef ldexp +inline double ldexp(double __x, int __y) { return __stlp_ldexp(__x, __y); } +# endif +#endif + +/* MSVC native lib starting with .Net 2003 has already all math functions + * in global namespace. + * HP-UX native lib has math functions in the global namespace. + */ +#if defined (_STLP_SGX_CONFIG) || (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)) && \ + (!defined (__HP_aCC) || (__HP_aCC < 30000)) && \ + !defined (__WATCOMC__) +inline double abs(double __x) +{ return ::fabs(__x); } +# if !defined (__MVS__) +_STLP_DEF_MATH_INLINE(abs, fabs) +# else // __MVS__ has native long double abs? +inline float abs(float __x) { return ::fabsf(__x); } +# endif + +_STLP_DEF_MATH_INLINE(acos, acos) +_STLP_DEF_MATH_INLINE(asin, asin) +_STLP_DEF_MATH_INLINE(atan, atan) +_STLP_DEF_MATH_INLINE2(atan2, atan2) +_STLP_DEF_MATH_INLINE(ceil, ceil) +_STLP_DEF_MATH_INLINE(cos, cos) +_STLP_DEF_MATH_INLINE(cosh, cosh) +_STLP_DEF_MATH_INLINE(exp, exp) +_STLP_DEF_MATH_INLINE(fabs, fabs) +_STLP_DEF_MATH_INLINE(floor, floor) +_STLP_DEF_MATH_INLINE2(fmod, fmod) +_STLP_DEF_MATH_INLINE2PI(frexp, frexp) +_STLP_DEF_MATH_INLINE2I(ldexp, ldexp) +_STLP_DEF_MATH_INLINE(log, log) +_STLP_DEF_MATH_INLINE(log10, log10) +_STLP_DEF_MATH_INLINE2P(modf, modf) +_STLP_DEF_MATH_INLINE(sin, sin) +_STLP_DEF_MATH_INLINE(sinh, sinh) +_STLP_DEF_MATH_INLINE(sqrt, sqrt) +_STLP_DEF_MATH_INLINE(tan, tan) +_STLP_DEF_MATH_INLINE(tanh, tanh) +_STLP_DEF_MATH_INLINE2(pow, pow) + +# if defined (_STLP_SGX_CONFIG) || !defined(_STLP_MSVC) /* || (_STLP_MSVC > 1300) */ || defined(_STLP_WCE) || !defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */ +# ifndef _STLP_NO_VENDOR_MATH_F +# ifndef __sun +inline float pow(float __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powf(__x, __STATIC_CAST(float,__y)); } +# else +inline float pow(float __x, int __y) { return ::__powf(__x, __STATIC_CAST(float,__y)); } +# endif +# else +inline float pow(float __x, int __y) { return __STATIC_CAST(float, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(float,__y))); } +# endif +inline double pow(double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(double,__y)); } +# if !defined (_STLP_NO_LONG_DOUBLE) +# if !defined(_STLP_NO_VENDOR_MATH_L) +# ifndef __sun +inline long double pow(long double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powl(__x, __STATIC_CAST(long double,__y)); } +# else +# ifndef __SUNPRO_CC +inline long double pow(long double __x, int __y) { return ::__powl(__x, __STATIC_CAST(long double,__y)); } +# else +inline long double pow(long double __x, int __y) { return _STLP_VENDOR_CSTD::__powl(__x, __STATIC_CAST(long double,__y)); } +# endif +# endif +# else +inline long double pow(long double __x, int __y) { return __STATIC_CAST(long double, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(long double,__y))); } +# endif +# endif +# else +//The MS native pow version has a bugged overload so it is not imported +//in the STLport namespace. +//Here is the bugged version: +//inline double pow(int __x, int __y) { return (_Pow_int(__x, __y)); } +inline double pow(double __x, int __y) { return (_Pow_int(__x, __y)); } +inline float pow(float __x, int __y) { return (_Pow_int(__x, __y)); } +inline long double pow(long double __x, int __y) { return (_Pow_int(__x, __y)); } +# endif +#endif + +#if (defined (_STLP_MSVC) && !defined (_STLP_WCE)) || defined (__ICL) || defined (__sun) +# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400) +# pragma warning (push) +# pragma warning (disable : 4996) // hypot is deprecated. +# endif +_STLP_MATH_INLINE2XX(float, hypot, hypot) +inline long double hypot(long double x, long double y) { return sqrt(x * x + y * y); } +# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400) +# pragma warning (pop) +# endif +#else +# if defined (_STLP_USE_UCLIBC) +inline double hypot(double x, double y) { return sqrt(x * x + y * y); } +_STLP_DEF_MATH_INLINE2(hypot, hypot) +# elif defined (_STLP_WCE) + /* CE has a double _hypot(double,double) which we use */ +inline double hypot(double __x, double __y) { return _hypot(__x,__y); } +_STLP_DEF_MATH_INLINE2(hypot, _hypot) +# endif +#endif + +#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC) +//restoration of the default intrinsic status of those functions: +# pragma intrinsic (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh) +# if defined (_STLP_WCE) +# pragma intrinsic (ceil, floor) +# endif +# pragma warning(pop) +# undef _STLP_RESTORE_FUNCTION_INTRINSIC +#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS + +/* C++ Standard is unclear about several call to 'using ::func' if new overloads + * of ::func appears between 2 successive 'using' calls. To avoid this potential + * problem we provide all abs overload before the 'using' call. + * Beware: This header inclusion has to be after all abs overload of this file. + * The first 'using ::abs' call is going to be in the other header. + */ +#ifndef _STLP_INTERNAL_CSTDLIB +# include +#endif + +#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +_STLP_BEGIN_NAMESPACE +using ::abs; +using ::acos; +using ::asin; +using ::atan; +using ::atan2; +using ::ceil; +using ::cos; +using ::cosh; +using ::exp; +using ::fabs; +using ::floor; +using ::fmod; +using ::frexp; +/* + Because of some weird interaction between STLport headers + and native HP-UX headers, when compiled with _STLP_DEBUG + macro defined with aC++, hypot() is not declared. + At some point we'll need to get to the bottom line of + this problem. +*/ +#if !(defined(__HP_aCC) && defined(_STLP_DEBUG)) +using ::hypot; +#endif +using ::ldexp; +using ::log; +using ::log10; +using ::modf; +using ::pow; +using ::sin; +using ::sinh; +using ::sqrt; +using ::tan; +using ::tanh; +_STLP_END_NAMESPACE +# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x560) && !defined (__linux__) +using _STLP_VENDOR_CSTD::_ecvt; +using _STLP_VENDOR_CSTD::_fcvt; +# endif +#endif + +#endif /* _STLP_INTERNAL_CMATH */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_codecvt.h b/sdk/tlibstdcxx/stlport/stl/_codecvt.h new file mode 100644 index 0000000000..29b408b2e4 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_codecvt.h @@ -0,0 +1,442 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_CODECVT_H +#define _STLP_INTERNAL_CODECVT_H + +#ifndef _STLP_C_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +class _STLP_CLASS_DECLSPEC codecvt_base { +public: + enum result {ok, partial, error, noconv}; +}; + +template +class codecvt : public locale::facet, public codecvt_base { +public: + typedef _InternT intern_type; + typedef _ExternT extern_type; + typedef _StateT state_type; + +#if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) + /* For the moment VC6 do not support this facet default implementation + * because of the static locale::id instance. When VC6 see this definition + * it goes crasy with locale::id static instances and all the has_facet tests + * unit tests are failing. + */ +}; +#else + explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} + + result out(state_type& __state, + const intern_type* __from, + const intern_type* __from_end, + const intern_type*& __from_next, + extern_type* __to, + extern_type* __to_limit, + extern_type*& __to_next) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_out(__state, + __from, __from_end, __from_next, + __to, __to_limit, __to_next); + } + + result unshift(state_type& __state, + extern_type* __to, + extern_type* __to_limit, + extern_type*& __to_next) const { + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_unshift(__state, __to, __to_limit, __to_next); + } + + result in(state_type& __state, + const extern_type* __from, + const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, + intern_type* __to_limit, + intern_type*& __to_next) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_in(__state, + __from, __from_end, __from_next, + __to, __to_limit, __to_next); + } + + int encoding() const _STLP_NOTHROW { return do_encoding(); } + + bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); } + + int length(state_type& __state, + const extern_type* __from, + const extern_type* __from_end, + size_t __max) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + return do_length(__state, __from, __from_end, __max); + } + + int max_length() const _STLP_NOTHROW { return do_max_length(); } + + static locale::id id; + +protected: + ~codecvt() {} + + virtual result do_out(state_type&, + const intern_type* __from, + const intern_type*, + const intern_type*& __from_next, + extern_type* __to, + extern_type*, + extern_type*& __to_next) const + { __from_next = __from; __to_next = __to; return noconv; } + + virtual result do_in (state_type&, + const extern_type* __from, + const extern_type*, + const extern_type*& __from_next, + intern_type* __to, + intern_type*, + intern_type*& __to_next) const + { __from_next = __from; __to_next = __to; return noconv; } + + virtual result do_unshift(state_type&, + extern_type* __to, + extern_type*, + extern_type*& __to_next) const + { __to_next = __to; return noconv; } + + virtual int do_encoding() const _STLP_NOTHROW + { return 1; } + + virtual bool do_always_noconv() const _STLP_NOTHROW + { return true; } + + virtual int do_length(state_type&, + const extern_type* __from, + const extern_type* __end, + size_t __max) const + { return (int)(min) ( __STATIC_CAST(size_t, (__end - __from)), __max); } + + virtual int do_max_length() const _STLP_NOTHROW + { return 1; } + +private: + codecvt(const codecvt&); + codecvt& operator = (const codecvt&); +}; + +# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x590) +template +locale::id codecvt<_InternT, _ExternT, _StateT>::id; +# endif +# endif +#endif + +template +class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC codecvt + : public locale::facet, public codecvt_base { +public: + typedef char intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} + + result out(state_type& __state, + const char* __from, + const char* __from_end, + const char*& __from_next, + char* __to, + char* __to_limit, + char*& __to_next) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_out(__state, + __from, __from_end, __from_next, + __to, __to_limit, __to_next); + } + + result unshift(state_type& __state, + char* __to, char* __to_limit, char*& __to_next) const { + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_unshift(__state, __to, __to_limit, __to_next); + } + + result in(state_type& __state, + const char* __from, + const char* __from_end, + const char*& __from_next, + char* __to, + char* __to_limit, + char*& __to_next) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_in(__state, + __from, __from_end, __from_next, + __to, __to_limit, __to_next); + } + + int encoding() const _STLP_NOTHROW { return do_encoding(); } + + bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); } + + int length(state_type& __state, + const char* __from, const char* __from_end, + size_t __max) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + return do_length(__state, __from, __from_end, __max); + } + + int max_length() const _STLP_NOTHROW { return do_max_length(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~codecvt(); + + virtual result do_out(state_type& /* __state */, + const char* __from, + const char* /* __from_end */, + const char*& __from_next, + char* __to, + char* /* __to_limit */, + char*& __to_next) const; + + virtual result do_in (state_type& /* __state */ , + const char* __from, + const char* /* __from_end */, + const char*& __from_next, + char* __to, + char* /* __to_end */, + char*& __to_next) const; + + virtual result do_unshift(state_type& /* __state */, + char* __to, + char* /* __to_limit */, + char*& __to_next) const; + + virtual int do_encoding() const _STLP_NOTHROW; + virtual bool do_always_noconv() const _STLP_NOTHROW; + virtual int do_length(state_type& __state, + const char* __from, + const char* __end, + size_t __max) const; + virtual int do_max_length() const _STLP_NOTHROW; +private: + codecvt(const codecvt&); + codecvt& operator =(const codecvt&); +}; + +# ifndef _STLP_NO_WCHAR_T + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC codecvt + : public locale::facet, public codecvt_base { +public: + typedef wchar_t intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} + + result out(state_type& __state, + const wchar_t* __from, + const wchar_t* __from_end, + const wchar_t*& __from_next, + char* __to, + char* __to_limit, + char*& __to_next) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_out(__state, + __from, __from_end, __from_next, + __to, __to_limit, __to_next); + } + + result unshift(state_type& __state, + char* __to, char* __to_limit, char*& __to_next) const { + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_unshift(__state, __to, __to_limit, __to_next); + } + + result in(state_type& __state, + const char* __from, + const char* __from_end, + const char*& __from_next, + wchar_t* __to, + wchar_t* __to_limit, + wchar_t*& __to_next) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) + return do_in(__state, + __from, __from_end, __from_next, + __to, __to_limit, __to_next); + } + + int encoding() const _STLP_NOTHROW { return do_encoding(); } + + bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); } + + int length(state_type& __state, + const char* __from, const char* __from_end, + size_t __max) const { + _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) + return do_length(__state, __from, __from_end, __max); + } + + int max_length() const _STLP_NOTHROW { return do_max_length(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~codecvt(); + + virtual result do_out(state_type& __state, + const wchar_t* __from, + const wchar_t* __from_end, + const wchar_t*& __from_next, + char* __to, + char* __to_limit, + char*& __to_next) const; + + virtual result do_in (state_type& __state, + const char* __from, + const char* __from_end, + const char*& __from_next, + wchar_t* __to, + wchar_t* __to_limit, + wchar_t*& __to_next) const; + + virtual result do_unshift(state_type& __state, + char* __to, + char* __to_limit, + char*& __to_next) const; + + virtual int do_encoding() const _STLP_NOTHROW; + + virtual bool do_always_noconv() const _STLP_NOTHROW; + + virtual int do_length(state_type& __state, + const char* __from, + const char* __end, + size_t __max) const; + + virtual int do_max_length() const _STLP_NOTHROW; + +private: + codecvt(const codecvt&); + codecvt& operator = (const codecvt&); +}; + +# endif + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC codecvt_byname + : public codecvt { +public: + explicit codecvt_byname(const char* __name, size_t __refs = 0); + ~codecvt_byname(); +private: + codecvt_byname(const codecvt_byname&); + codecvt_byname& operator =(const codecvt_byname&); +}; + +# ifndef _STLP_NO_WCHAR_T +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC codecvt_byname + : public codecvt { + friend class _Locale_impl; +public: + explicit codecvt_byname(const char * __name, size_t __refs = 0); + +protected: + ~codecvt_byname(); + + virtual result do_out(state_type& __state, + const wchar_t* __from, + const wchar_t* __from_end, + const wchar_t*& __from_next, + char* __to, + char* __to_limit, + char*& __to_next) const; + + virtual result do_in (state_type& __state, + const char* __from, + const char* __from_end, + const char*& __from_next, + wchar_t* __to, + wchar_t* __to_limit, + wchar_t*& __to_next) const; + + virtual result do_unshift(state_type& __state, + char* __to, + char* __to_limit, + char*& __to_next) const; + + virtual int do_encoding() const _STLP_NOTHROW; + + virtual bool do_always_noconv() const _STLP_NOTHROW; + + virtual int do_length(state_type& __state, + const char* __from, + const char* __end, + size_t __max) const; + + virtual int do_max_length() const _STLP_NOTHROW; + +private: + codecvt_byname(_Locale_codecvt* __cvt) + : _M_codecvt(__cvt) {} + + codecvt_byname(const codecvt_byname&); + codecvt_byname& operator =(const codecvt_byname&); + _Locale_codecvt* _M_codecvt; +}; + +# endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_CODECVT_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_collate.h b/sdk/tlibstdcxx/stlport/stl/_collate.h new file mode 100644 index 0000000000..4384f2e920 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_collate.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + +#ifndef _STLP_INTERNAL_COLLATE_H +#define _STLP_INTERNAL_COLLATE_H + +#ifndef _STLP_C_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template class collate {}; +template class collate_byname {}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC collate : public locale::facet { +public: + typedef char char_type; + typedef string string_type; + + explicit collate(size_t __refs = 0) : locale::facet(__refs) {} + + int compare(const char* __low1, const char* __high1, + const char* __low2, const char* __high2) const { + return do_compare( __low1, __high1, __low2, __high2); + } + + string_type transform(const char* __low, const char* __high) const { + return do_transform(__low, __high); + } + + long hash(const char* __low, const char* __high) const + { return do_hash(__low, __high); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~collate(); + + virtual int do_compare(const char*, const char*, + const char*, const char*) const; + virtual string_type do_transform(const char*, const char*) const; + virtual long do_hash(const char*, const char*) const; +private: + collate(const collate&); + collate& operator =(const collate&); +}; + +# ifndef _STLP_NO_WCHAR_T + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC collate : public locale::facet { +public: + typedef wchar_t char_type; + typedef wstring string_type; + + explicit collate(size_t __refs = 0) : locale::facet(__refs) {} + + int compare(const wchar_t* __low1, const wchar_t* __high1, + const wchar_t* __low2, const wchar_t* __high2) const { + return do_compare( __low1, __high1, __low2, __high2); + } + + string_type transform(const wchar_t* __low, const wchar_t* __high) const { + return do_transform(__low, __high); + } + + long hash(const wchar_t* __low, const wchar_t* __high) const + { return do_hash(__low, __high); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~collate(); + + virtual int do_compare(const wchar_t*, const wchar_t*, + const wchar_t*, const wchar_t*) const; + virtual string_type do_transform(const wchar_t*, const wchar_t*) const; + virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const; +private: + collate(const collate&); + collate& operator = (const collate&); +}; + +# endif /* NO_WCHAR_T */ + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC collate_byname: public collate { + friend class _Locale_impl; +public: + explicit collate_byname(const char* __name, size_t __refs = 0); + +protected: + ~collate_byname(); + + virtual int do_compare(const char*, const char*, + const char*, const char*) const; + virtual string_type do_transform(const char*, const char*) const; + +private: + collate_byname(_Locale_collate *__coll) + : _M_collate(__coll) {} + _Locale_collate* _M_collate; + collate_byname(const collate_byname&); + collate_byname& operator =(const collate_byname&); +}; + +# ifndef _STLP_NO_WCHAR_T + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC collate_byname: public collate { + friend class _Locale_impl; +public: + explicit collate_byname(const char * __name, size_t __refs = 0); + +protected: + ~collate_byname(); + + virtual int do_compare(const wchar_t*, const wchar_t*, + const wchar_t*, const wchar_t*) const; + virtual string_type do_transform(const wchar_t*, const wchar_t*) const; + +private: + collate_byname(_Locale_collate *__coll) + : _M_collate(__coll) {} + _Locale_collate* _M_collate; + collate_byname(const collate_byname&); + collate_byname& operator =(const collate_byname&); +}; + +# endif /* NO_WCHAR_T */ + +template +bool +__locale_do_operator_call (const locale& __loc, + const basic_string<_CharT, _Traits, _Alloc>& __x, + const basic_string<_CharT, _Traits, _Alloc>& __y) { + collate<_CharT> const& __coll = use_facet >(__loc); + return __coll.compare(__x.data(), __x.data() + __x.size(), + __y.data(), __y.data() + __y.size()) < 0; +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_COLLATE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_complex.c b/sdk/tlibstdcxx/stlport/stl/_complex.c new file mode 100644 index 0000000000..204fa1ecf2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_complex.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_COMPLEX_C +#define _STLP_COMPLEX_C + +#ifndef _STLP_INTERNAL_COMPLEX +# include +#endif + +#if !defined (_STLP_USE_NO_IOSTREAMS) +# ifndef _STLP_INTERNAL_ISTREAM +# include +# endif + +# ifndef _STLP_INTERNAL_SSTREAM +# include +# endif + +# ifndef _STLP_STRING_IO_H +# include +# endif +#endif + +_STLP_BEGIN_NAMESPACE + +// Non-inline member functions. + +template +void complex<_Tp>::_div(const _Tp& __z1_r, const _Tp& __z1_i, + const _Tp& __z2_r, const _Tp& __z2_i, + _Tp& __res_r, _Tp& __res_i) { + _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r; + _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i; + + if (__ar <= __ai) { + _Tp __ratio = __z2_r / __z2_i; + _Tp __denom = __z2_i * (1 + __ratio * __ratio); + __res_r = (__z1_r * __ratio + __z1_i) / __denom; + __res_i = (__z1_i * __ratio - __z1_r) / __denom; + } + else { + _Tp __ratio = __z2_i / __z2_r; + _Tp __denom = __z2_r * (1 + __ratio * __ratio); + __res_r = (__z1_r + __z1_i * __ratio) / __denom; + __res_i = (__z1_i - __z1_r * __ratio) / __denom; + } +} + +template +void complex<_Tp>::_div(const _Tp& __z1_r, + const _Tp& __z2_r, const _Tp& __z2_i, + _Tp& __res_r, _Tp& __res_i) { + _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r; + _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i; + + if (__ar <= __ai) { + _Tp __ratio = __z2_r / __z2_i; + _Tp __denom = __z2_i * (1 + __ratio * __ratio); + __res_r = (__z1_r * __ratio) / __denom; + __res_i = - __z1_r / __denom; + } + else { + _Tp __ratio = __z2_i / __z2_r; + _Tp __denom = __z2_r * (1 + __ratio * __ratio); + __res_r = __z1_r / __denom; + __res_i = - (__z1_r * __ratio) / __denom; + } +} + +// I/O. +#if !defined (_STLP_USE_NO_IOSTREAMS) + +// Complex output, in the form (re,im). We use a two-step process +// involving stringstream so that we get the padding right. +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __z) { + basic_ostringstream<_CharT, _Traits, allocator<_CharT> > __tmp; + __tmp.flags(__os.flags()); + __tmp.imbue(__os.getloc()); + __tmp.precision(__os.precision()); + __tmp << '(' << __z.real() << ',' << __z.imag() << ')'; + return __os << __tmp.str(); +} + +// Complex input from arbitrary streams. Note that results in some +// locales may be confusing, since the decimal character varies with +// locale and the separator between real and imaginary parts does not. + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __z) { + _Tp __re = 0; + _Tp __im = 0; + + const ctype<_CharT>& __c_type = *__is._M_ctype_facet(); + + const char __punct[4] = "(,)"; + _CharT __wpunct[3]; + __c_type.widen(__punct, __punct + 3, __wpunct); + + _CharT __c; + + __is >> __c; + if (_Traits::eq(__c, __wpunct[0])) { // Left paren + __is >> __re >> __c; + if (_Traits::eq(__c, __wpunct[1])) // Comma + __is >> __im >> __c; + if (!_Traits::eq(__c, __wpunct[2])) // Right paren + __is.setstate(ios_base::failbit); + } + else { + __is.putback(__c); + __is >> __re; + } + + if (__is) + __z = complex<_Tp>(__re, __im); + return __is; +} + +#endif /* _STLP_USE_NO_IOSTREAMS */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_COMPLEX_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_complex.h b/sdk/tlibstdcxx/stlport/stl/_complex.h new file mode 100644 index 0000000000..5dba0ad401 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_complex.h @@ -0,0 +1,935 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_INTERNAL_COMPLEX +#define _STLP_INTERNAL_COMPLEX + +// This header declares the template class complex, as described in +// in the draft C++ standard. Single-precision complex numbers +// are complex, double-precision are complex, and +// quad precision are complex. + +// Note that the template class complex is declared within namespace +// std, as called for by the draft C++ standard. + +#ifndef _STLP_INTERNAL_CMATH +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +struct complex { + typedef _Tp value_type; + typedef complex<_Tp> _Self; + + // Constructors, destructor, assignment operator. + complex() : _M_re(0), _M_im(0) {} + complex(const value_type& __x) + : _M_re(__x), _M_im(0) {} + complex(const value_type& __x, const value_type& __y) + : _M_re(__x), _M_im(__y) {} + complex(const _Self& __z) + : _M_re(__z._M_re), _M_im(__z._M_im) {} + + _Self& operator=(const _Self& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } + +#if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + template + explicit complex(const complex<_Tp2>& __z) + : _M_re(__z._M_re), _M_im(__z._M_im) {} + + template + _Self& operator=(const complex<_Tp2>& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + // Element access. + value_type real() const { return _M_re; } + value_type imag() const { return _M_im; } + + // Arithmetic op= operations involving one real argument. + + _Self& operator= (const value_type& __x) { + _M_re = __x; + _M_im = 0; + return *this; + } + _Self& operator+= (const value_type& __x) { + _M_re += __x; + return *this; + } + _Self& operator-= (const value_type& __x) { + _M_re -= __x; + return *this; + } + _Self& operator*= (const value_type& __x) { + _M_re *= __x; + _M_im *= __x; + return *this; + } + _Self& operator/= (const value_type& __x) { + _M_re /= __x; + _M_im /= __x; + return *this; + } + + // Arithmetic op= operations involving two complex arguments. + + static void _STLP_CALL _div(const value_type& __z1_r, const value_type& __z1_i, + const value_type& __z2_r, const value_type& __z2_i, + value_type& __res_r, value_type& __res_i); + + static void _STLP_CALL _div(const value_type& __z1_r, + const value_type& __z2_r, const value_type& __z2_i, + value_type& __res_r, value_type& __res_i); + +#if defined (_STLP_MEMBER_TEMPLATES) // && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + + template _Self& operator+= (const complex<_Tp2>& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + template _Self& operator-= (const complex<_Tp2>& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + template _Self& operator*= (const complex<_Tp2>& __z) { + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im; + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + template _Self& operator/= (const complex<_Tp2>& __z) { + value_type __r; + value_type __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + _Self& operator+= (const _Self& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + _Self& operator-= (const _Self& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + _Self& operator*= (const _Self& __z) { + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im; + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + _Self& operator/= (const _Self& __z) { + value_type __r; + value_type __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } + + // Data members. + value_type _M_re; + value_type _M_im; +}; + +// Explicit specializations for float, double, long double. The only +// reason for these specializations is to enable automatic conversions +// from complex to complex, and complex to +// complex. + +_STLP_TEMPLATE_NULL +struct _STLP_CLASS_DECLSPEC complex { + typedef float value_type; + typedef complex _Self; + // Constructors, destructor, assignment operator. + + complex(value_type __x = 0.0f, value_type __y = 0.0f) + : _M_re(__x), _M_im(__y) {} + + complex(const complex& __z) : _M_re(__z._M_re), _M_im(__z._M_im) {} + + inline explicit complex(const complex& __z); +#ifndef _STLP_NO_LONG_DOUBLE + inline explicit complex(const complex& __z); +#endif + // Element access. + value_type real() const { return _M_re; } + value_type imag() const { return _M_im; } + + // Arithmetic op= operations involving one real argument. + + _Self& operator= (value_type __x) { + _M_re = __x; + _M_im = 0.0f; + return *this; + } + _Self& operator+= (value_type __x) { + _M_re += __x; + return *this; + } + _Self& operator-= (value_type __x) { + _M_re -= __x; + return *this; + } + _Self& operator*= (value_type __x) { + _M_re *= __x; + _M_im *= __x; + return *this; + } + _Self& operator/= (value_type __x) { + _M_re /= __x; + _M_im /= __x; + return *this; + } + + // Arithmetic op= operations involving two complex arguments. + + static void _STLP_CALL _div(const float& __z1_r, const float& __z1_i, + const float& __z2_r, const float& __z2_i, + float& __res_r, float& __res_i); + + static void _STLP_CALL _div(const float& __z1_r, + const float& __z2_r, const float& __z2_i, + float& __res_r, float& __res_i); + +#if defined (_STLP_MEMBER_TEMPLATES) + template + complex& operator=(const complex<_Tp2>& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } + + template + complex& operator+= (const complex<_Tp2>& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + template + complex& operator-= (const complex<_Tp2>& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + template + complex& operator*= (const complex<_Tp2>& __z) { + float __r = _M_re * __z._M_re - _M_im * __z._M_im; + float __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + template + complex& operator/= (const complex<_Tp2>& __z) { + float __r; + float __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } + +#endif /* _STLP_MEMBER_TEMPLATES */ + + _Self& operator=(const _Self& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } + + _Self& operator+= (const _Self& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + _Self& operator-= (const _Self& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + _Self& operator*= (const _Self& __z) { + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im; + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + _Self& operator/= (const _Self& __z) { + value_type __r; + value_type __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } + + // Data members. + value_type _M_re; + value_type _M_im; +}; + +_STLP_TEMPLATE_NULL +struct _STLP_CLASS_DECLSPEC complex { + typedef double value_type; + typedef complex _Self; + + // Constructors, destructor, assignment operator. + + complex(value_type __x = 0.0, value_type __y = 0.0) + : _M_re(__x), _M_im(__y) {} + + complex(const complex& __z) + : _M_re(__z._M_re), _M_im(__z._M_im) {} + inline complex(const complex& __z); +#if !defined (_STLP_NO_LONG_DOUBLE) + explicit inline complex(const complex& __z); +#endif + // Element access. + value_type real() const { return _M_re; } + value_type imag() const { return _M_im; } + + // Arithmetic op= operations involving one real argument. + + _Self& operator= (value_type __x) { + _M_re = __x; + _M_im = 0.0; + return *this; + } + _Self& operator+= (value_type __x) { + _M_re += __x; + return *this; + } + _Self& operator-= (value_type __x) { + _M_re -= __x; + return *this; + } + _Self& operator*= (value_type __x) { + _M_re *= __x; + _M_im *= __x; + return *this; + } + _Self& operator/= (value_type __x) { + _M_re /= __x; + _M_im /= __x; + return *this; + } + + // Arithmetic op= operations involving two complex arguments. + + static void _STLP_CALL _div(const double& __z1_r, const double& __z1_i, + const double& __z2_r, const double& __z2_i, + double& __res_r, double& __res_i); + static void _STLP_CALL _div(const double& __z1_r, + const double& __z2_r, const double& __z2_i, + double& __res_r, double& __res_i); + +#if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + template + complex& operator=(const complex<_Tp2>& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } + + template + complex& operator+= (const complex<_Tp2>& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + template + complex& operator-= (const complex<_Tp2>& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + template + complex& operator*= (const complex<_Tp2>& __z) { + double __r = _M_re * __z._M_re - _M_im * __z._M_im; + double __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + template + complex& operator/= (const complex<_Tp2>& __z) { + double __r; + double __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } + +#endif /* _STLP_MEMBER_TEMPLATES */ + + _Self& operator=(const _Self& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } + + _Self& operator+= (const _Self& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + _Self& operator-= (const _Self& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + _Self& operator*= (const _Self& __z) { + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im; + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + _Self& operator/= (const _Self& __z) { + value_type __r; + value_type __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } + + // Data members. + value_type _M_re; + value_type _M_im; +}; + +#if !defined (_STLP_NO_LONG_DOUBLE) + +_STLP_TEMPLATE_NULL +struct _STLP_CLASS_DECLSPEC complex { + typedef long double value_type; + typedef complex _Self; + + // Constructors, destructor, assignment operator. + complex(value_type __x = 0.0l, value_type __y = 0.0l) + : _M_re(__x), _M_im(__y) {} + + complex(const complex& __z) + : _M_re(__z._M_re), _M_im(__z._M_im) {} + inline complex(const complex& __z); + inline complex(const complex& __z); + + // Element access. + value_type real() const { return _M_re; } + value_type imag() const { return _M_im; } + + // Arithmetic op= operations involving one real argument. + + _Self& operator= (value_type __x) { + _M_re = __x; + _M_im = 0.0l; + return *this; + } + _Self& operator+= (value_type __x) { + _M_re += __x; + return *this; + } + _Self& operator-= (value_type __x) { + _M_re -= __x; + return *this; + } + _Self& operator*= (value_type __x) { + _M_re *= __x; + _M_im *= __x; + return *this; + } + _Self& operator/= (value_type __x) { + _M_re /= __x; + _M_im /= __x; + return *this; + } + + // Arithmetic op= operations involving two complex arguments. + + static void _STLP_CALL _div(const long double& __z1_r, const long double& __z1_i, + const long double& __z2_r, const long double& __z2_i, + long double& __res_r, long double& __res_i); + + static void _STLP_CALL _div(const long double& __z1_r, + const long double& __z2_r, const long double& __z2_i, + long double& __res_r, long double& __res_i); + +# if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + + template + complex& operator=(const complex<_Tp2>& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } + + template + complex& operator+= (const complex<_Tp2>& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + template + complex& operator-= (const complex<_Tp2>& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + template + complex& operator*= (const complex<_Tp2>& __z) { + long double __r = _M_re * __z._M_re - _M_im * __z._M_im; + long double __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + template + complex& operator/= (const complex<_Tp2>& __z) { + long double __r; + long double __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } + +# endif /* _STLP_MEMBER_TEMPLATES */ + + _Self& operator=(const _Self& __z) { + _M_re = __z._M_re; + _M_im = __z._M_im; + return *this; + } + + _Self& operator+= (const _Self& __z) { + _M_re += __z._M_re; + _M_im += __z._M_im; + return *this; + } + + _Self& operator-= (const _Self& __z) { + _M_re -= __z._M_re; + _M_im -= __z._M_im; + return *this; + } + + _Self& operator*= (const _Self& __z) { + value_type __r = _M_re * __z._M_re - _M_im * __z._M_im; + value_type __i = _M_re * __z._M_im + _M_im * __z._M_re; + _M_re = __r; + _M_im = __i; + return *this; + } + + _Self& operator/= (const _Self& __z) { + value_type __r; + value_type __i; + _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i); + _M_re = __r; + _M_im = __i; + return *this; + } + + // Data members. + value_type _M_re; + value_type _M_im; +}; + +#endif /* _STLP_NO_LONG_DOUBLE */ + +// Converting constructors from one of these three specialized types +// to another. + +inline complex::complex(const complex& __z) + : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {} +inline complex::complex(const complex& __z) + : _M_re(__z._M_re), _M_im(__z._M_im) {} +#ifndef _STLP_NO_LONG_DOUBLE +inline complex::complex(const complex& __z) + : _M_re((float)__z._M_re), _M_im((float)__z._M_im) {} +inline complex::complex(const complex& __z) + : _M_re((double)__z._M_re), _M_im((double)__z._M_im) {} +inline complex::complex(const complex& __z) + : _M_re(__z._M_re), _M_im(__z._M_im) {} +inline complex::complex(const complex& __z) + : _M_re(__z._M_re), _M_im(__z._M_im) {} +#endif + +// Unary non-member arithmetic operators. + +template +inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z) +{ return __z; } + +template +inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z) +{ return complex<_Tp>(-__z._M_re, -__z._M_im); } + +// Non-member arithmetic operations involving one real argument. + +template +inline complex<_Tp> _STLP_CALL operator+(const _Tp& __x, const complex<_Tp>& __z) +{ return complex<_Tp>(__x + __z._M_re, __z._M_im); } + +template +inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z, const _Tp& __x) +{ return complex<_Tp>(__z._M_re + __x, __z._M_im); } + +template +inline complex<_Tp> _STLP_CALL operator-(const _Tp& __x, const complex<_Tp>& __z) +{ return complex<_Tp>(__x - __z._M_re, -__z._M_im); } + +template +inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z, const _Tp& __x) +{ return complex<_Tp>(__z._M_re - __x, __z._M_im); } + +template +inline complex<_Tp> _STLP_CALL operator*(const _Tp& __x, const complex<_Tp>& __z) +{ return complex<_Tp>(__x * __z._M_re, __x * __z._M_im); } + +template +inline complex<_Tp> _STLP_CALL operator*(const complex<_Tp>& __z, const _Tp& __x) +{ return complex<_Tp>(__z._M_re * __x, __z._M_im * __x); } + +template +inline complex<_Tp> _STLP_CALL operator/(const _Tp& __x, const complex<_Tp>& __z) { + complex<_Tp> __result; + complex<_Tp>::_div(__x, + __z._M_re, __z._M_im, + __result._M_re, __result._M_im); + return __result; +} + +template +inline complex<_Tp> _STLP_CALL operator/(const complex<_Tp>& __z, const _Tp& __x) +{ return complex<_Tp>(__z._M_re / __x, __z._M_im / __x); } + +// Non-member arithmetic operations involving two complex arguments + +template +inline complex<_Tp> _STLP_CALL +operator+(const complex<_Tp>& __z1, const complex<_Tp>& __z2) +{ return complex<_Tp>(__z1._M_re + __z2._M_re, __z1._M_im + __z2._M_im); } + +template +inline complex<_Tp> _STLP_CALL +operator-(const complex<_Tp>& __z1, const complex<_Tp>& __z2) +{ return complex<_Tp>(__z1._M_re - __z2._M_re, __z1._M_im - __z2._M_im); } + +template +inline complex<_Tp> _STLP_CALL +operator*(const complex<_Tp>& __z1, const complex<_Tp>& __z2) { + return complex<_Tp>(__z1._M_re * __z2._M_re - __z1._M_im * __z2._M_im, + __z1._M_re * __z2._M_im + __z1._M_im * __z2._M_re); +} + +template +inline complex<_Tp> _STLP_CALL +operator/(const complex<_Tp>& __z1, const complex<_Tp>& __z2) { + complex<_Tp> __result; + complex<_Tp>::_div(__z1._M_re, __z1._M_im, + __z2._M_re, __z2._M_im, + __result._M_re, __result._M_im); + return __result; +} + +// Comparison operators. + +template +inline bool _STLP_CALL operator==(const complex<_Tp>& __z1, const complex<_Tp>& __z2) +{ return __z1._M_re == __z2._M_re && __z1._M_im == __z2._M_im; } + +template +inline bool _STLP_CALL operator==(const complex<_Tp>& __z, const _Tp& __x) +{ return __z._M_re == __x && __z._M_im == 0; } + +template +inline bool _STLP_CALL operator==(const _Tp& __x, const complex<_Tp>& __z) +{ return __x == __z._M_re && 0 == __z._M_im; } + +//04/27/04 dums: removal of this check, if it is restablish +//please explain why the other operators are not macro guarded +//#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER + +template +inline bool _STLP_CALL operator!=(const complex<_Tp>& __z1, const complex<_Tp>& __z2) +{ return __z1._M_re != __z2._M_re || __z1._M_im != __z2._M_im; } + +//#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ + +template +inline bool _STLP_CALL operator!=(const complex<_Tp>& __z, const _Tp& __x) +{ return __z._M_re != __x || __z._M_im != 0; } + +template +inline bool _STLP_CALL operator!=(const _Tp& __x, const complex<_Tp>& __z) +{ return __x != __z._M_re || 0 != __z._M_im; } + +// Other basic arithmetic operations +template +inline _Tp _STLP_CALL real(const complex<_Tp>& __z) +{ return __z._M_re; } + +template +inline _Tp _STLP_CALL imag(const complex<_Tp>& __z) +{ return __z._M_im; } + +template +_Tp _STLP_CALL abs(const complex<_Tp>& __z); + +template +_Tp _STLP_CALL arg(const complex<_Tp>& __z); + +template +inline _Tp _STLP_CALL norm(const complex<_Tp>& __z) +{ return __z._M_re * __z._M_re + __z._M_im * __z._M_im; } + +template +inline complex<_Tp> _STLP_CALL conj(const complex<_Tp>& __z) +{ return complex<_Tp>(__z._M_re, -__z._M_im); } + +template +complex<_Tp> _STLP_CALL polar(const _Tp& __rho) +{ return complex<_Tp>(__rho, 0); } + +template +complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi); + +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC float _STLP_CALL abs(const complex&); +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC double _STLP_CALL abs(const complex&); +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC float _STLP_CALL arg(const complex&); +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC double _STLP_CALL arg(const complex&); +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC complex _STLP_CALL polar(const float& __rho, const float& __phi); +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC complex _STLP_CALL polar(const double& __rho, const double& __phi); + +template +_Tp _STLP_CALL abs(const complex<_Tp>& __z) +{ return _Tp(abs(complex(double(__z.real()), double(__z.imag())))); } + +template +_Tp _STLP_CALL arg(const complex<_Tp>& __z) +{ return _Tp(arg(complex(double(__z.real()), double(__z.imag())))); } + +template +complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi) { + complex __tmp = polar(double(__rho), double(__phi)); + return complex<_Tp>(_Tp(__tmp.real()), _Tp(__tmp.imag())); +} + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC long double _STLP_CALL arg(const complex&); +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC long double _STLP_CALL abs(const complex&); +_STLP_TEMPLATE_NULL +_STLP_DECLSPEC complex _STLP_CALL polar(const long double&, const long double&); +#endif + + +#if !defined (_STLP_USE_NO_IOSTREAMS) + +_STLP_END_NAMESPACE + +# ifndef _STLP_INTERNAL_IOSFWD +# include +# endif + +_STLP_BEGIN_NAMESPACE + +// Complex output, in the form (re,im). We use a two-step process +// involving stringstream so that we get the padding right. +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __z); + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __z); + +// Specializations for narrow characters; lets us avoid widen. + +_STLP_OPERATOR_TEMPLATE +_STLP_DECLSPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z); + +_STLP_OPERATOR_TEMPLATE +_STLP_DECLSPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z); + +_STLP_OPERATOR_TEMPLATE +_STLP_DECLSPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __is, const complex& __z); + +_STLP_OPERATOR_TEMPLATE +_STLP_DECLSPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __is, const complex& __z); + +# if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_OPERATOR_TEMPLATE +_STLP_DECLSPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z); + +_STLP_OPERATOR_TEMPLATE +_STLP_DECLSPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __is, const complex& __z); + +# endif + +# if defined (_STLP_USE_TEMPLATE_EXPORT) && ! defined (_STLP_NO_WCHAR_T) + +_STLP_EXPORT_TEMPLATE basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); +_STLP_EXPORT_TEMPLATE basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); +_STLP_EXPORT_TEMPLATE basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); +_STLP_EXPORT_TEMPLATE basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); + +# if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_EXPORT_TEMPLATE basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); +_STLP_EXPORT_TEMPLATE basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); +# endif +# endif +#endif + + +// Transcendental functions. These are defined only for float, +// double, and long double. (Sqrt isn't transcendental, of course, +// but it's included in this section anyway.) + +_STLP_DECLSPEC complex _STLP_CALL sqrt(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL exp(const complex&); +_STLP_DECLSPEC complex _STLP_CALL log(const complex&); +_STLP_DECLSPEC complex _STLP_CALL log10(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, int); +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, const float&); +_STLP_DECLSPEC complex _STLP_CALL pow(const float&, const complex&); +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, const complex&); + +_STLP_DECLSPEC complex _STLP_CALL sin(const complex&); +_STLP_DECLSPEC complex _STLP_CALL cos(const complex&); +_STLP_DECLSPEC complex _STLP_CALL tan(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL sinh(const complex&); +_STLP_DECLSPEC complex _STLP_CALL cosh(const complex&); +_STLP_DECLSPEC complex _STLP_CALL tanh(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL sqrt(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL exp(const complex&); +_STLP_DECLSPEC complex _STLP_CALL log(const complex&); +_STLP_DECLSPEC complex _STLP_CALL log10(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, int); +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, const double&); +_STLP_DECLSPEC complex _STLP_CALL pow(const double&, const complex&); +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, const complex&); + +_STLP_DECLSPEC complex _STLP_CALL sin(const complex&); +_STLP_DECLSPEC complex _STLP_CALL cos(const complex&); +_STLP_DECLSPEC complex _STLP_CALL tan(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL sinh(const complex&); +_STLP_DECLSPEC complex _STLP_CALL cosh(const complex&); +_STLP_DECLSPEC complex _STLP_CALL tanh(const complex&); + +#if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLSPEC complex _STLP_CALL sqrt(const complex&); +_STLP_DECLSPEC complex _STLP_CALL exp(const complex&); +_STLP_DECLSPEC complex _STLP_CALL log(const complex&); +_STLP_DECLSPEC complex _STLP_CALL log10(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, int); +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, const long double&); +_STLP_DECLSPEC complex _STLP_CALL pow(const long double&, const complex&); +_STLP_DECLSPEC complex _STLP_CALL pow(const complex&, + const complex&); + +_STLP_DECLSPEC complex _STLP_CALL sin(const complex&); +_STLP_DECLSPEC complex _STLP_CALL cos(const complex&); +_STLP_DECLSPEC complex _STLP_CALL tan(const complex&); + +_STLP_DECLSPEC complex _STLP_CALL sinh(const complex&); +_STLP_DECLSPEC complex _STLP_CALL cosh(const complex&); +_STLP_DECLSPEC complex _STLP_CALL tanh(const complex&); +#endif + +_STLP_END_NAMESPACE + +#ifndef _STLP_LINK_TIME_INSTANTIATION +# include +#endif + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_config_compat_post.h b/sdk/tlibstdcxx/stlport/stl/_config_compat_post.h new file mode 100644 index 0000000000..e3b411172c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_config_compat_post.h @@ -0,0 +1,51 @@ +/*========================================== */ +#if 1 /* def _STLP_3_COMPATIBILITY */ + +# define __SGI_STL_PORT _STLPORT_VERSION + +# if defined (_STLP_DEBUG) && ! defined ( __STL_DEBUG ) +# define __STL_DEBUG _STLP_DEBUG +# endif + +# if defined (_STLP_USE_NAMESPACES) +# undef __STL_USE_NAMESPACES +# define __STL_USE_NAMESPACES _STLP_USE_NAMESPACES +# endif + +# if defined (_STLP_USE_EXCEPTIONS) +# undef __STL_USE_EXCEPTIONS +# define __STL_USE_EXCEPTIONS _STLP_USE_EXCEPTIONS +# endif + +# if defined (_STLP_BEGIN_NAMESPACE) && ! defined ( __STL_BEGIN_NAMESPACE ) +# define __STL_BEGIN_NAMESPACE _STLP_BEGIN_NAMESPACE +# define __STL_END_NAMESPACE _STLP_END_NAMESPACE +# define __STL_VENDOR_STD _STLP_VENDOR_STD +# define __STL_VENDOR_CSTD _STLP_VENDOR_CSTD +# endif +# endif + +/* +# if defined (_STLP_XXX) && ! defined ( __STL_XXX ) +# define __STL_XXX _STLP_XXX +# endif +*/ + +/* 5.0 -> 4.6 compatibility section */ +#if 1 /* def _STLP_46_COMPATIBILITY */ + +/* provide a uniform way to access full functionality */ +# define __slist__ slist +# define __map__ map +# define __multimap__ multimap +# define __set__ set +# define __multiset__ multiset +# define __list__ list +# define __hash_map__ hash_map +# define __hash_multimap__ hash_multimap +# define __hash_set__ hash_set +# define __hash_multiset__ hash_multiset +# define __vector__ vector + +#endif + diff --git a/sdk/tlibstdcxx/stlport/stl/_construct.h b/sdk/tlibstdcxx/stlport/stl/_construct.h new file mode 100644 index 0000000000..5356b91d7b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_construct.h @@ -0,0 +1,289 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +#define _STLP_INTERNAL_CONSTRUCT_H + +#if !defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_INTERNAL_CSTRING) +# include +#endif + +#ifndef _STLP_INTERNAL_NEW +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +#ifndef _STLP_TYPE_TRAITS_H +# include +#endif + +#if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +inline void __destroy_aux(_Tp* __pointer, const __false_type& /*_Trivial_destructor*/) +{ __pointer->~_Tp(); } + +template +inline void __destroy_aux(_Tp*, const __true_type& /*_Trivial_destructor*/) {} + +template +inline void _Destroy(_Tp* __pointer) { + typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor; + __destroy_aux(__pointer, _Trivial_destructor()); +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset(__REINTERPRET_CAST(char*, __pointer), _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif +} + +template +inline void _Destroy_Moved(_Tp* __pointer) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::complete _Trivial_destructor; + __destroy_aux(__pointer, _Trivial_destructor()); +# if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp)); +# endif +#else + _Destroy(__pointer); +#endif +} + +#if defined (new) +# define _STLP_NEW_REDEFINE new +# undef new +#endif + +template +inline void _Construct_aux (_T1* __p, const __false_type&) { + new(__p) _T1(); +} + +template +inline void _Construct_aux (_T1* __p, const __true_type&) { +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG) + *__p = _T1(0); +#else + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = _T1(); +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */ +} + +template +inline void _Construct(_T1* __p) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG) + _Construct_aux (__p, _HasDefaultZeroValue(__p)._Answer()); +#else + _Construct_aux (__p, _Is_POD(__p)._Answer()); +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */ +} + +template +inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __false_type&) { + ::new(__p) _Tp(__val); +} + +template +inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __true_type&) { + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = __val; +} + +template +inline void _Copy_Construct(_Tp* __p, const _Tp& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif + _Copy_Construct_aux(__p, __val, _Is_POD(__p)._Answer()); +} + +template +inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __false_type&) { + new(__p) _T1(__val); +} + +template +inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __true_type&) { + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = _T1(__val); +} + +template +inline void _Param_Construct(_T1* __p, const _T2& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif + _Param_Construct_aux(__p, __val, _Is_POD(__p)._Answer()); +} + +template +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __false_type& /*_IsPOD*/) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + new(__p) _T1(_STLP_PRIV _AsMoveSource(__val)); +#else + _Param_Construct(__p, __val); +#endif +} + +template +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __true_type& /*_IsPOD*/) { + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = _T1(__val); +} + +template +inline void _Move_Construct(_T1* __p, _T2& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif + _Move_Construct_Aux(__p, __val, _Is_POD(__p)._Answer()); +} + +#if defined(_STLP_NEW_REDEFINE) +# if defined (DEBUG_NEW) +# define new DEBUG_NEW +# endif +# undef _STLP_NEW_REDEFINE +#endif + +template +_STLP_INLINE_LOOP void +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __false_type& /*_Trivial_destructor*/) { + for ( ; __first != __last; ++__first) { + __destroy_aux(&(*__first), __false_type()); +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif + } +} + +template +#if defined (_STLP_DEBUG_UNINITIALIZED) +_STLP_INLINE_LOOP void +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __true_type& /*_Trivial_destructor*/) { + for ( ; __first != __last; ++__first) + memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp)); +} +#else +inline void +__destroy_range_aux(_ForwardIterator, _ForwardIterator, _Tp*, const __true_type& /*_Trivial_destructor*/) {} +#endif + +template +inline void +__destroy_range(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) { + typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor; + __destroy_range_aux(__first, __last, __ptr, _Trivial_destructor()); +} + +template +inline void _Destroy_Range(_ForwardIterator __first, _ForwardIterator __last) { + __destroy_range(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); +} + +inline void _Destroy_Range(char*, char*) {} +#if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97 +inline void _Destroy_Range(wchar_t*, wchar_t*) {} +inline void _Destroy_Range(const wchar_t*, const wchar_t*) {} +#endif + +#if !defined (_STLP_NO_MOVE_SEMANTIC) +template +inline void +__destroy_mv_srcs(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) { + typedef typename __move_traits<_Tp>::complete _CompleteMove; + __destroy_range_aux(__first, __last, __ptr, _CompleteMove()); +} +#endif + +template +inline void _Destroy_Moved_Range(_ForwardIterator __first, _ForwardIterator __last) +#if !defined (_STLP_NO_MOVE_SEMANTIC) +{ __destroy_mv_srcs(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); } +#else +{ _Destroy_Range(__first, __last); } +#endif + +#if defined (_STLP_DEF_CONST_DEF_PARAM_BUG) +// Those adaptors are here to fix common compiler bug regarding builtins: +// expressions like int k = int() should initialize k to 0 +template +inline _Tp __default_constructed_aux(_Tp*, const __false_type&) { + return _Tp(); +} +template +inline _Tp __default_constructed_aux(_Tp*, const __true_type&) { + return _Tp(0); +} + +template +inline _Tp __default_constructed(_Tp* __p) { + return __default_constructed_aux(__p, _HasDefaultZeroValue(__p)._Answer()); +} + +# define _STLP_DEFAULT_CONSTRUCTED(_TTp) __default_constructed((_TTp*)0) +#else +# define _STLP_DEFAULT_CONSTRUCTED(_TTp) _TTp() +#endif /* _STLP_DEF_CONST_DEF_PARAM_BUG */ + + +#if !defined (_STLP_NO_ANACHRONISMS) +// -------------------------------------------------- +// Old names from the HP STL. + +template +inline void construct(_T1* __p, const _T2& __val) {_Param_Construct(__p, __val); } +template +inline void construct(_T1* __p) { _STLP_STD::_Construct(__p); } +template +inline void destroy(_Tp* __pointer) { _STLP_STD::_Destroy(__pointer); } +template +inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy_Range(__first, __last); } +#endif /* _STLP_NO_ANACHRONISMS */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_CONSTRUCT_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_cprolog.h b/sdk/tlibstdcxx/stlport/stl/_cprolog.h new file mode 100644 index 0000000000..1d276562cc --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cprolog.h @@ -0,0 +1,25 @@ +/* NOTE : this header has no guards and is MEANT for multiple inclusion! + * If you are using "header protection" option with your compiler, + * please also find #pragma which disables it and put it here, to + * allow reentrancy of this header. + */ + +#ifdef std +# undef std /* We undef "std" on entry , as STLport headers may include native ones. */ +#endif + +#ifdef _STLP_PROLOG_HEADER_INCLUDED +# error STlport prolog header can not be reincluded as long as epilog has not be included. +#endif + +#define _STLP_PROLOG_HEADER_INCLUDED + +#ifndef _STLP_FEATURES_H +# include +#endif + +/* If the platform provides any specific prolog actions, + * like #pragmas, do include platform-specific prolog file */ +#if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) +# include +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_csetjmp.h b/sdk/tlibstdcxx/stlport/stl/_csetjmp.h new file mode 100644 index 0000000000..ca132c1101 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_csetjmp.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSETJMP +#define _STLP_INTERNAL_CSETJMP + +// if the macro is on, the header is already there +#if !defined (setjmp) +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(csetjmp) +# endif +# else +# include +# endif +#endif + +#if defined (_STLP_IMPORT_VENDOR_CSTD) + +# if defined (__BORLANDC__) && defined (_STLP_USE_NEW_C_HEADERS) +/* For Borland, even if stdjmp.h is included symbols won't be in global namespace + * so we need to reach them in vendor namespace: + */ +# undef _STLP_NATIVE_SETJMP_H_INCLUDED +# endif + +_STLP_BEGIN_NAMESPACE +# if !defined (_STLP_NATIVE_SETJMP_H_INCLUDED) +using _STLP_VENDOR_CSTD::jmp_buf; +# else +// if setjmp.h was included first, this is in global namespace, not in +// vendor's std. - 2005-08-04, ptr +using ::jmp_buf; +# endif +# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +# if !defined (setjmp) +# if !defined (__MSL__) || ((__MSL__ > 0x7001) && (__MSL__ < 0x8000)) +# ifndef _STLP_NATIVE_SETJMP_H_INCLUDED +using _STLP_VENDOR_CSTD::setjmp; +# else +using ::setjmp; +# endif +# endif +# endif +# if !defined (_STLP_NATIVE_SETJMP_H_INCLUDED) +using _STLP_VENDOR_CSTD::longjmp; +# else +using ::longjmp; +# endif +# endif +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_csignal.h b/sdk/tlibstdcxx/stlport/stl/_csignal.h new file mode 100644 index 0000000000..551846b385 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_csignal.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSIGNAL +#define _STLP_INTERNAL_CSIGNAL + +#if !defined (_STLP_WCE) +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(csignal) +# endif +# else +# include +# endif + +# if defined (_STLP_IMPORT_VENDOR_CSTD) +_STLP_BEGIN_NAMESPACE +# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +using _STLP_VENDOR_CSTD::signal; +using _STLP_VENDOR_CSTD::raise; +# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ +using _STLP_VENDOR_CSTD::sig_atomic_t; +_STLP_END_NAMESPACE +# endif /* _STLP_IMPORT_VENDOR_CSTD */ +#endif + +#endif /* _STLP_INTERNAL_CSIGNAL */ diff --git a/sdk/tlibstdcxx/stlport/stl/_cstdarg.h b/sdk/tlibstdcxx/stlport/stl/_cstdarg.h new file mode 100644 index 0000000000..e98f31cd5a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cstdarg.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#ifndef _STLP_INTERNAL_CSTDARG +#define _STLP_INTERNAL_CSTDARG + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdarg) +# endif +#else +# include +#endif + +#ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::va_list; +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_cstddef.h b/sdk/tlibstdcxx/stlport/stl/_cstddef.h new file mode 100644 index 0000000000..35a585c4ee --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cstddef.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSTDDEF +#define _STLP_INTERNAL_CSTDDEF + +# if (__GNUC__ >= 3) && defined (__CYGWIN__) // this total HACK is the only expedient way I could cygwin to work with GCC 3.0 +# define __need_wint_t // mostly because wint_t didn't seem to get defined otherwise :( +# define __need_wchar_t +# define __need_size_t +# define __need_ptrdiff_t +# define __need_NULL +# endif + +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstddef) +# endif +# else +# include +# endif + +# ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::ptrdiff_t; +using _STLP_VENDOR_CSTD::size_t; +_STLP_END_NAMESPACE +# endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif /* _STLP_INTERNAL_CSTDDEF */ diff --git a/sdk/tlibstdcxx/stlport/stl/_cstdio.h b/sdk/tlibstdcxx/stlport/stl/_cstdio.h new file mode 100644 index 0000000000..e802b5844f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cstdio.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSTDIO +#define _STLP_INTERNAL_CSTDIO + +#if defined (__Lynx__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(stdarg.h) +# endif +#endif + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdio) +# endif +#else +# include +#endif + +#if defined (__MWERKS__) +# undef stdin +# undef stdout +# undef stderr +# define stdin (&_STLP_VENDOR_CSTD::__files[0]) +# define stdout (&_STLP_VENDOR_CSTD::__files[1]) +# define stderr (&_STLP_VENDOR_CSTD::__files[2]) +#endif + +#if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) +inline int vsnprintf(char *s1, size_t n, const char *s2, va_list v) +{ return _STLP_VENDOR_CSTD::_vsnprintf(s1, n, s2, v); } +#endif + +#if !defined (_STLP_SGX_CONFIG) +#if defined (_STLP_IMPORT_VENDOR_CSTD ) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::FILE; +using _STLP_VENDOR_CSTD::fpos_t; +using _STLP_VENDOR_CSTD::size_t; + +// undef obsolete macros +# undef putc +# undef getc +# undef getchar +# undef putchar +# undef feof +# undef ferror + +# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +using _STLP_VENDOR_CSTD::clearerr; +using _STLP_VENDOR_CSTD::fclose; +using _STLP_VENDOR_CSTD::feof; +using _STLP_VENDOR_CSTD::ferror; +using _STLP_VENDOR_CSTD::fflush; +using _STLP_VENDOR_CSTD::fgetc; +using _STLP_VENDOR_CSTD::fgetpos; +using _STLP_VENDOR_CSTD::fgets; +using _STLP_VENDOR_CSTD::fopen; +using _STLP_VENDOR_CSTD::fprintf; +using _STLP_VENDOR_CSTD::fputc; +using _STLP_VENDOR_CSTD::fputs; +using _STLP_VENDOR_CSTD::fread; +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) +using _STLP_VENDOR_CSTD::freopen; +# endif +using _STLP_VENDOR_CSTD::fscanf; +using _STLP_VENDOR_CSTD::fseek; +using _STLP_VENDOR_CSTD::fsetpos; +using _STLP_VENDOR_CSTD::ftell; +using _STLP_VENDOR_CSTD::fwrite; + +# if !(defined (__IBMCPP__) && (__IBMCPP__ >= 500)) +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) // Supplied as macros, TODO: use inline function to redirect to the macros? + using _STLP_VENDOR_CSTD::getc; + using _STLP_VENDOR_CSTD::putc; +# endif + using _STLP_VENDOR_CSTD::getchar; + using _STLP_VENDOR_CSTD::putchar; +# endif + +using _STLP_VENDOR_CSTD::gets; +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) +using _STLP_VENDOR_CSTD::perror; +# endif +using _STLP_VENDOR_CSTD::printf; +using _STLP_VENDOR_CSTD::puts; +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) +using _STLP_VENDOR_CSTD::remove; +using _STLP_VENDOR_CSTD::rename; +using _STLP_VENDOR_CSTD::rewind; +using _STLP_VENDOR_CSTD::setbuf; +using _STLP_VENDOR_CSTD::tmpfile; +using _STLP_VENDOR_CSTD::tmpnam; +# endif +using _STLP_VENDOR_CSTD::scanf; +using _STLP_VENDOR_CSTD::setvbuf; +using _STLP_VENDOR_CSTD::sprintf; +using _STLP_VENDOR_CSTD::sscanf; +using _STLP_VENDOR_CSTD::ungetc; +using _STLP_VENDOR_CSTD::vfprintf; +using _STLP_VENDOR_CSTD::vprintf; +using _STLP_VENDOR_CSTD::vsprintf; +# if (defined (__MWERKS__) || (defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400)) || \ + (defined (__BORLANDC__))) +using _STLP_VENDOR_CSTD::vsnprintf; +# endif +# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ +#endif /* !STLP_SE1_CONFIG */ + +#endif /* _STLP_INTERNAL_CSTDIO */ diff --git a/sdk/tlibstdcxx/stlport/stl/_cstdlib.h b/sdk/tlibstdcxx/stlport/stl/_cstdlib.h new file mode 100644 index 0000000000..b5f0ee9df8 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cstdlib.h @@ -0,0 +1,188 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSTDLIB +#define _STLP_INTERNAL_CSTDLIB + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib) +# endif +#else +# include +#endif + +#if defined (__BORLANDC__) && !defined (__linux__) +/* Borland process.h header do not bring anything here and is just included + * in order to avoid inclusion later. This header cannot be included later + * because Borland compiler consider that for instance the abort function + * defined as extern "C" cannot be overloaded and it finds 2 "overloads", + * once in native std namespace and the other in STLport namespace... + */ +# include +#endif + +/* on evc3/evc4 including stdlib.h also defines setjmp macro */ +#if defined (_STLP_WCE) +# define _STLP_NATIVE_SETJMP_H_INCLUDED +#endif + +#if defined (__MSL__) && (__MSL__ <= 0x5003) +namespace std { + typedef ::div_t div_t; + typedef ::ldiv_t ldiv_t; +# ifdef __MSL_LONGLONG_SUPPORT__ + typedef ::lldiv_t lldiv_t; +# endif +} +#endif + +#ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::div_t; +using _STLP_VENDOR_CSTD::ldiv_t; +using _STLP_VENDOR_CSTD::size_t; + +# ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS +# ifndef _STLP_WCE +// these functions just don't exist on Windows CE +using _STLP_VENDOR_CSTD::abort; +#if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::getenv; +using _STLP_VENDOR_CSTD::mblen; +using _STLP_VENDOR_CSTD::mbtowc; +using _STLP_VENDOR_CSTD::system; +# endif /* !_STLP_SGX_CONFIG */ +using _STLP_VENDOR_CSTD::bsearch; +# endif +#if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::atexit; +using _STLP_VENDOR_CSTD::exit; +# endif /* !_STLP_SGX_CONFIG */ +using _STLP_VENDOR_CSTD::calloc; +using _STLP_VENDOR_CSTD::free; +using _STLP_VENDOR_CSTD::malloc; +using _STLP_VENDOR_CSTD::realloc; +using _STLP_VENDOR_CSTD::atof; +using _STLP_VENDOR_CSTD::atoi; +using _STLP_VENDOR_CSTD::atol; +#if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::mbstowcs; +# endif /* !_STLP_SGX_CONFIG */ +using _STLP_VENDOR_CSTD::strtod; +using _STLP_VENDOR_CSTD::strtol; +using _STLP_VENDOR_CSTD::strtoul; + +# if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_NATIVE_MBSTATE_T)) +using _STLP_VENDOR_CSTD::wcstombs; +# ifndef _STLP_WCE +using _STLP_VENDOR_CSTD::wctomb; +# endif +# endif +using _STLP_VENDOR_CSTD::qsort; +using _STLP_VENDOR_CSTD::labs; +using _STLP_VENDOR_CSTD::ldiv; +# if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L) +# if !defined(__sun) +using _STLP_VENDOR_CSTD::llabs; +using _STLP_VENDOR_CSTD::lldiv_t; +using _STLP_VENDOR_CSTD::lldiv; +# else +using ::llabs; +using ::lldiv_t; +using ::lldiv; +# endif +# endif +#if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::rand; +using _STLP_VENDOR_CSTD::srand; +# endif /* !_STLP_SGX_CONFIG */ +# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS) +//In this config bcc define everything in std namespace and not in +//the global one. +inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); } +inline _STLP_VENDOR_CSTD::div_t div(int __x, int __y) { return _STLP_VENDOR_CSTD::div(__x, __y); } +#endif + +#if defined(_MSC_EXTENSIONS) && defined(_STLP_MSVC) && (_STLP_MSVC <= 1300) +# define _STLP_RESTORE_FUNCTION_INTRINSIC +# pragma warning (push) +# pragma warning (disable: 4162) +# pragma function (abs) +#endif + +//HP-UX native lib has abs() and div() functions in global namespace +#if !defined (__SUNPRO_CC) && \ + (!defined (__HP_aCC) || (__HP_aCC < 30000)) + +//MSVC starting with .Net 2003 already define all math functions in global namespace: +# if defined (_STLP_SGX_CONFIG) || !defined (__WATCOMC__) && \ + (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined (UNDER_CE)) +inline long abs(long __x) { return _STLP_VENDOR_CSTD::labs(__x); } +# endif + +/** VC since version 8 has this, the platform SDK and CE SDKs hanging behind. */ +# if defined (_STLP_SGX_CONFIG) || !defined (__WATCOMC__) && \ + (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) || defined (UNDER_CE)) +inline _STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y) { return _STLP_VENDOR_CSTD::ldiv(__x, __y); } +# endif + +#endif + +#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC) +# pragma intrinsic (abs) +# pragma warning (pop) +# undef _STLP_RESTORE_FUNCTION_INTRINSIC +#endif + +#if defined (_STLP_LONG_LONG) +# if !defined (_STLP_NO_VENDOR_STDLIB_L) +# if !defined (__sun) +inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); } +inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); } +# else +inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return ::llabs(__x); } +inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); } +# endif +# else +inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; } +# endif +#endif + +/* C++ Standard is unclear about several call to 'using ::func' if new overloads + * of ::func appears between 2 successive 'using' calls. To avoid this potential + * problem we provide all abs overload before the 'using' call. + * Beware: This header inclusion has to be after all abs overload of this file. + * The first 'using ::abs' call is going to be in the other header. + */ +#ifndef _STLP_INTERNAL_CMATH +# include +#endif + +#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +// ad hoc, don't replace with _STLP_VENDOR_CSTD::abs here! - ptr 2005-03-05 +_STLP_BEGIN_NAMESPACE +using ::abs; +using ::div; +_STLP_END_NAMESPACE +#endif + +#endif /* _STLP_INTERNAL_CSTDLIB */ diff --git a/sdk/tlibstdcxx/stlport/stl/_cstring.h b/sdk/tlibstdcxx/stlport/stl/_cstring.h new file mode 100644 index 0000000000..fe0fd5fe43 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cstring.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSTRING +#define _STLP_INTERNAL_CSTRING + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstring) +# endif +#else +# include +#endif + +#ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +# include +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif /* _STLP_INTERNAL_CSTRING */ diff --git a/sdk/tlibstdcxx/stlport/stl/_ctime.h b/sdk/tlibstdcxx/stlport/stl/_ctime.h new file mode 100644 index 0000000000..27bb2664eb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ctime.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CTIME +#define _STLP_INTERNAL_CTIME + +#if !defined (_STLP_WCE_EVC3) + +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(ctime) +# endif +# else +# include +# endif + +# if defined (_STLP_IMPORT_VENDOR_CSTD) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::size_t; +using _STLP_VENDOR_CSTD::clock_t; +using _STLP_VENDOR_CSTD::time_t; +using _STLP_VENDOR_CSTD::tm; +# if !defined (_STLP_SGX_CONFIG) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +using _STLP_VENDOR_CSTD::clock; +using _STLP_VENDOR_CSTD::asctime; +using _STLP_VENDOR_CSTD::ctime; +using _STLP_VENDOR_CSTD::gmtime; + +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 0x500) // CE5 stopped supplying this +using _STLP_VENDOR_CSTD::difftime; +# endif +using _STLP_VENDOR_CSTD::mktime; +using _STLP_VENDOR_CSTD::localtime; +using _STLP_VENDOR_CSTD::strftime; +using _STLP_VENDOR_CSTD::time; +# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ + +_STLP_END_NAMESPACE +# endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif + +#endif /* _STLP_INTERNAL_CTIME */ diff --git a/sdk/tlibstdcxx/stlport/stl/_ctraits_fns.h b/sdk/tlibstdcxx/stlport/stl/_ctraits_fns.h new file mode 100644 index 0000000000..e4a4af109b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ctraits_fns.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + +#ifndef _STLP_INTERNAL_CTRAITS_FUNCTIONS_H +#define _STLP_INTERNAL_CTRAITS_FUNCTIONS_H + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +// This file contains a few small adapters that allow a character +// traits class to be used as a function object. + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _Eq_traits + : public binary_function { + bool operator()(const typename _Traits::char_type& __x, + const typename _Traits::char_type& __y) const + { return _Traits::eq(__x, __y); } +}; + +template +struct _Eq_char_bound + : public unary_function { + typename _Traits::char_type __val; + _Eq_char_bound(typename _Traits::char_type __c) : __val(__c) {} + bool operator()(const typename _Traits::char_type& __x) const + { return _Traits::eq(__x, __val); } +}; + +template +struct _Neq_char_bound + : public unary_function +{ + typename _Traits::char_type __val; + _Neq_char_bound(typename _Traits::char_type __c) : __val(__c) {} + bool operator()(const typename _Traits::char_type& __x) const + { return !_Traits::eq(__x, __val); } +}; + +template +struct _Eq_int_bound + : public unary_function { + typename _Traits::int_type __val; + + _Eq_int_bound(typename _Traits::int_type __c) : __val(__c) {} + bool operator()(const typename _Traits::char_type& __x) const + { return _Traits::eq_int_type(_Traits::to_int_type(__x), __val); } +}; + +#if 0 +template +struct _Lt_traits + : public binary_function { + bool operator()(const typename _Traits::char_type& __x, + const typename _Traits::char_type& __y) const + { return _Traits::lt(__x, __y); } +}; +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_CTRAITS_FUNCTIONS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_ctype.h b/sdk/tlibstdcxx/stlport/stl/_ctype.h new file mode 100644 index 0000000000..33a5d3cbed --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ctype.h @@ -0,0 +1,280 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + +#ifndef _STLP_INTERNAL_CTYPE_H +#define _STLP_INTERNAL_CTYPE_H + +#ifndef _STLP_C_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +class _STLP_CLASS_DECLSPEC ctype_base { +public: + enum mask { + space = _Locale_SPACE, + print = _Locale_PRINT, + cntrl = _Locale_CNTRL, + upper = _Locale_UPPER, + lower = _Locale_LOWER, + alpha = _Locale_ALPHA, + digit = _Locale_DIGIT, + punct = _Locale_PUNCT, + xdigit = _Locale_XDIGIT, + alnum = alpha | digit, + graph = alnum | punct + }; +}; + +// ctype<> template + +template class ctype {}; +template class ctype_byname {}; + +//ctype specializations + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC ctype : public locale::facet, public ctype_base { +#ifndef _STLP_NO_WCHAR_T +# ifdef _STLP_MSVC + typedef ctype _Wctype; + friend _Wctype; +# else + friend class ctype; +# endif +#endif +public: + + typedef char char_type; + + explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0); + bool is(mask __m, char __c) const + { return ((*(_M_ctype_table+(unsigned char)__c)) & __m) != 0; } + + const char* is(const char* __low, const char* __high, mask* __vec) const { + for (const char* __p = __low;__p != __high; ++__p, ++__vec) { + *__vec = _M_ctype_table[(unsigned char)*__p]; + } + return __high; + } + + const char* scan_is(mask __m, const char* __low, const char* __high) const; + const char* scan_not(mask __m, const char* __low, const char* __high) const; + + char (toupper)(char __c) const { return do_toupper(__c); } + const char* (toupper)(char* __low, const char* __high) const { + return do_toupper(__low, __high); + } + + char (tolower)(char __c) const { return do_tolower(__c); } + const char* (tolower)(char* __low, const char* __high) const { + return do_tolower(__low, __high); + } + + char widen(char __c) const { return do_widen(__c); } + const char* widen(const char* __low, const char* __high, char* __to) const { + return do_widen(__low, __high, __to); + } + + char narrow(char __c, char __dfault) const { + return do_narrow(__c, __dfault); + } + const char* narrow(const char* __low, const char* __high, + char __dfault, char* __to) const { + return do_narrow(__low, __high, __dfault, __to); + } + + static _STLP_STATIC_DECLSPEC locale::id id; + _STLP_STATIC_CONSTANT(size_t, table_size = 256); + +protected: + const mask* table() const _STLP_NOTHROW { return _M_ctype_table; } + static const mask* _STLP_CALL classic_table() _STLP_NOTHROW; + + ~ctype(); + + virtual char do_toupper(char __c) const; + virtual char do_tolower(char __c) const; + virtual const char* do_toupper(char* __low, const char* __high) const; + virtual const char* do_tolower(char* __low, const char* __high) const; + virtual char do_widen(char __c) const; + virtual const char* do_widen(const char* __low, const char* __high, + char* __to) const; + virtual char do_narrow(char __c, char /* dfault */ ) const; + virtual const char* do_narrow(const char* __low, const char* __high, + char /* dfault */, char* __to) const; +private: + struct _Is_mask { + mask __m; + _Is_mask(mask __x): __m(__x) {} + bool operator()(char __c) {return (__m & (unsigned char) __c) != 0;} + }; + +protected: + const mask* _M_ctype_table; +private: + bool _M_delete; +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC ctype_byname: public ctype { + friend class _Locale_impl; +public: + explicit ctype_byname(const char*, size_t = 0); + ~ctype_byname(); + + virtual char do_toupper(char __c) const; + virtual char do_tolower(char __c) const; + + virtual const char* do_toupper(char*, const char*) const; + virtual const char* do_tolower(char*, const char*) const; + +private: + ctype_byname(_Locale_ctype* __ctype) + : _M_ctype(__ctype) + { _M_init(); } + + void _M_init(); + + //explicitely defined as private to avoid warnings: + typedef ctype_byname _Self; + ctype_byname(_Self const&); + _Self& operator = (_Self const&); + + mask _M_byname_table[table_size]; + _Locale_ctype* _M_ctype; +}; + +# ifndef _STLP_NO_WCHAR_T +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC ctype : public locale::facet, public ctype_base { +public: + typedef wchar_t char_type; + + explicit ctype(size_t __refs = 0) : locale::facet(__refs) {} + + bool is(mask __m, wchar_t __c) const + { return do_is(__m, __c); } + + const wchar_t* is(const wchar_t* __low, const wchar_t* __high, + mask* __vec) const + { return do_is(__low, __high, __vec); } + + const wchar_t* scan_is(mask __m, + const wchar_t* __low, const wchar_t* __high) const + { return do_scan_is(__m, __low, __high); } + + const wchar_t* scan_not (mask __m, + const wchar_t* __low, const wchar_t* __high) const + { return do_scan_not(__m, __low, __high); } + + wchar_t (toupper)(wchar_t __c) const { return do_toupper(__c); } + const wchar_t* (toupper)(wchar_t* __low, const wchar_t* __high) const + { return do_toupper(__low, __high); } + + wchar_t (tolower)(wchar_t __c) const { return do_tolower(__c); } + const wchar_t* (tolower)(wchar_t* __low, const wchar_t* __high) const + { return do_tolower(__low, __high); } + + wchar_t widen(char __c) const { return do_widen(__c); } + const char* widen(const char* __low, const char* __high, + wchar_t* __to) const + { return do_widen(__low, __high, __to); } + + char narrow(wchar_t __c, char __dfault) const + { return do_narrow(__c, __dfault); } + const wchar_t* narrow(const wchar_t* __low, const wchar_t* __high, + char __dfault, char* __to) const + { return do_narrow(__low, __high, __dfault, __to); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~ctype(); + + virtual bool do_is(mask __m, wchar_t __c) const; + virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const; + virtual const wchar_t* do_scan_is(mask, + const wchar_t*, const wchar_t*) const; + virtual const wchar_t* do_scan_not(mask, + const wchar_t*, const wchar_t*) const; + virtual wchar_t do_toupper(wchar_t __c) const; + virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const; + virtual wchar_t do_tolower(wchar_t c) const; + virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const; + virtual wchar_t do_widen(char c) const; + virtual const char* do_widen(const char*, const char*, wchar_t*) const; + virtual char do_narrow(wchar_t __c, char __dfault) const; + virtual const wchar_t* do_narrow(const wchar_t*, const wchar_t*, + char, char*) const; +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC ctype_byname: public ctype { + friend class _Locale_impl; +public: + explicit ctype_byname(const char* __name, size_t __refs = 0); + +protected: + ~ctype_byname(); + + virtual bool do_is(mask __m, wchar_t __c) const; + virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const; + virtual const wchar_t* do_scan_is(mask, + const wchar_t*, const wchar_t*) const; + virtual const wchar_t* do_scan_not(mask, + const wchar_t*, const wchar_t*) const; + virtual wchar_t do_toupper(wchar_t __c) const; + virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const; + virtual wchar_t do_tolower(wchar_t c) const; + virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const; + +private: + ctype_byname(_Locale_ctype* __ctype) + : _M_ctype(__ctype) {} + + //explicitely defined as private to avoid warnings: + typedef ctype_byname _Self; + ctype_byname(_Self const&); + _Self& operator = (_Self const&); + + _Locale_ctype* _M_ctype; +}; + +# endif /* WCHAR_T */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_CTYPE_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_cwchar.h b/sdk/tlibstdcxx/stlport/stl/_cwchar.h new file mode 100644 index 0000000000..d99f2240fc --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cwchar.h @@ -0,0 +1,355 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CWCHAR +#define _STLP_INTERNAL_CWCHAR + +#if defined (_STLP_WCE_EVC3) +# ifndef _STLP_INTERNAL_MBSTATE_T +# include +# endif +#else +# if defined (__GNUC__) && defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstddef) +# endif +# endif + +# if !defined (_STLP_NO_CWCHAR) && defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cwchar) +# endif +# if defined (__OpenBSD__) +typedef _BSD_WINT_T_ wint_t; +# endif /* __OpenBSD__ */ + +# if defined (__DMC__) +# define __STDC_LIMIT_MACROS +# include // WCHAR_MIN, WCHAR_MAX +# endif +# elif defined (_STLP_NO_WCHAR_T) || \ + (defined (__BORLANDC__) && (__BORLANDC__ < 0x570)) || \ + defined (__OpenBSD__) || defined (__FreeBSD__) || \ + (defined (__GNUC__) && (defined (__APPLE__) || defined ( __Lynx__ ))) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(stddef.h) +# endif +# if defined (__Lynx__) +# ifndef _WINT_T +typedef long int wint_t; +# define _WINT_T +# endif /* _WINT_T */ +# endif +# if defined(__OpenBSD__) +typedef _BSD_WINT_T_ wint_t; +# endif /* __OpenBSD__ */ +# else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(wchar.h) +# endif + +# if defined (__sun) && (defined (_XOPEN_SOURCE) || (_XOPEN_VERSION - 0 == 4)) +extern wint_t btowc(); +extern int fwprintf(); +extern int fwscanf(); +extern int fwide(); +extern int mbsinit(); +extern size_t mbrlen(); +extern size_t mbrtowc(); +extern size_t mbsrtowcs(); +extern int swprintf(); +extern int swscanf(); +extern int vfwprintf(); +extern int vwprintf(); +extern int vswprintf(); +extern size_t wcrtomb(); +extern size_t wcsrtombs(); +extern wchar_t *wcsstr(); +extern int wctob(); +extern wchar_t *wmemchr(); +extern int wmemcmp(); +extern wchar_t *wmemcpy(); +extern wchar_t *wmemmove(); +extern wchar_t *wmemset(); +extern int wprintf(); +extern int wscanf(); +# endif +# endif + +# if defined (__MSL__) && (__MSL__ <= 0x51FF) /* dwa 2/28/99 - not yet implemented by MSL */ +# define _STLP_WCHAR_MSL_EXCLUDE 1 +namespace std { + extern "C" size_t wcsftime(wchar_t * str, size_t max_size, const wchar_t * format_str, const struct tm * timeptr); +} +# define _STLP_NO_NATIVE_MBSTATE_T 1 +# elif defined (__BORLANDC__) +# if !defined (_STLP_USE_NO_IOSTREAMS) +# define _STLP_NO_NATIVE_MBSTATE_T +# endif +# define _STLP_WCHAR_BORLAND_EXCLUDE 1 +# endif + +# ifndef _STLP_INTERNAL_MBSTATE_T +# include +# endif + +# ifdef _STLP_SGX_CONFIG +# include /* WCHAR_MAX WCHAR_MIN */ +# endif + +# if !defined (_STLP_NO_WCHAR_T) +# ifndef WCHAR_MIN +# define WCHAR_MIN 0 +/* SUNpro has some bugs with casts. wchar_t is size of int there anyway. */ +# if defined (__SUNPRO_CC) || defined (__DJGPP) +# define WCHAR_MAX (~0) +# else +# define WCHAR_MAX ((wchar_t)~0) +# endif +# endif +# if defined (__DMC__) || (defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400)) || defined(_WIN32_WCE) +/* Compilers that do not define WCHAR_MIN and WCHAR_MAX to be testable at + * preprocessing time. */ +# undef WCHAR_MIN +# define WCHAR_MIN 0 +# undef WCHAR_MAX +# define WCHAR_MAX 0xffff +# endif +# if defined (__GNUC__) && defined (__alpha__) +/* Definition of WCHAR_MIN and MAX are wrong for alpha platform + * as gcc consider wchar_t as an unsigned type but WCHAR_MIN is defined as + * a negative value. Static assertion is here to check that a future alpha + * SDK or a future gcc won't change the situation making this workaround + * useless. + */ +/* Check that gcc still consider wchar_t as unsigned */ +_STLP_STATIC_ASSERT(((wchar_t)-1 > 0)) +/* Check that WCHAR_MIN value hasn't been fixed */ +_STLP_STATIC_ASSERT((WCHAR_MIN < 0)) +# undef WCHAR_MIN +# define WCHAR_MIN 0 +# undef WCHAR_MAX +# define WCHAR_MAX 0xffffffff +# endif +# if defined(__HP_aCC) && (__HP_aCC >= 60000) +/* Starting with B.11.31, HP-UX/ia64 provides C99-compliant definitions + * of WCHAR_MIN/MAX macros without having to define + * _INCLUDE_STDC__SOURCE_199901 macro (which aCC compiler does not + * predefine). Let STLport provide B.11.31 definitions on any version of + * HP-UX/ia64. + */ +# undef WCHAR_MIN +# define WCHAR_MIN 0 +# undef WCHAR_MAX +# define WCHAR_MAX UINT_MAX +# endif +# endif + +# if defined (_STLP_IMPORT_VENDOR_CSTD) + +# if defined (__SUNPRO_CC) && !defined (_STLP_HAS_NO_NEW_C_HEADERS) +using _STLP_VENDOR_CSTD::wint_t; +# endif + +_STLP_BEGIN_NAMESPACE +# if defined (_STLP_NO_WCHAR_T) +typedef int wint_t; +# else +// gcc 3.0 has a glitch : wint_t only sucked into the global namespace if _GLIBCPP_USE_WCHAR_T is defined +// __MWERKS__ has definition in wchar_t.h (MSL C++), but ones differ from definition +// in stdio.h; I prefer settings from last file. +# if (defined (__GNUC__) && ! defined (_GLIBCPP_USE_WCHAR_T)) +using ::wint_t; +# else +using _STLP_VENDOR_CSTD::wint_t; +# endif +# endif + +using _STLP_VENDOR_CSTD::size_t; + +# if !defined (_STLP_NO_NATIVE_MBSTATE_T) && !defined (_STLP_USE_OWN_MBSTATE_T) +using _STLP_VENDOR_MB_NAMESPACE::mbstate_t; + +# if !defined (_STLP_SGX_CONFIG) +# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) && !defined(_STLP_WCHAR_BORLAND_EXCLUDE) && \ + (!defined(__MSL__) || __MSL__ > 0x6001) +# if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \ + !(defined (__KCC) || defined (__GNUC__)) && !defined(_STLP_WCE_NET) +using _STLP_VENDOR_MB_NAMESPACE::btowc; +# if (!defined(__MSL__) || __MSL__ > 0x7001) +using _STLP_VENDOR_MB_NAMESPACE::mbsinit; +# endif +# endif +# if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \ + !defined (__GNUC__) && !defined(_STLP_WCE_NET) +using _STLP_VENDOR_MB_NAMESPACE::mbrlen; +using _STLP_VENDOR_MB_NAMESPACE::mbrtowc; +using _STLP_VENDOR_MB_NAMESPACE::mbsrtowcs; +using _STLP_VENDOR_MB_NAMESPACE::wcrtomb; +using _STLP_VENDOR_MB_NAMESPACE::wcsrtombs; +# endif +# endif /* BORLAND && !__MSL__ || __MSL__ > 0x6001 */ +# endif /* !_STLP_SGX_CONFIG */ +# endif /* _STLP_NO_NATIVE_MBSTATE_T */ + +# if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) + +# if !defined (_STLP_SGX_CONFIG) && !defined (_STLP_WCHAR_BORLAND_EXCLUDE) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +using _STLP_VENDOR_CSTD::fgetwc; +using _STLP_VENDOR_CSTD::fgetws; +using _STLP_VENDOR_CSTD::fputwc; +using _STLP_VENDOR_CSTD::fputws; +# endif + +# if !defined (_STLP_SGX_CONFIG) && !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \ + defined(_STLP_WCHAR_HPACC_EXCLUDE) ) +# if !defined (__DECCXX) +using _STLP_VENDOR_CSTD::fwide; +# endif +using _STLP_VENDOR_CSTD::fwprintf; +using _STLP_VENDOR_CSTD::fwscanf; +using _STLP_VENDOR_CSTD::getwchar; +# endif + +# if !defined (_STLP_SGX_CONFIG) && !defined(_STLP_WCHAR_BORLAND_EXCLUDE) +# ifndef _STLP_WCE_NET +using _STLP_VENDOR_CSTD::getwc; +# endif +using _STLP_VENDOR_CSTD::ungetwc; +# ifndef _STLP_WCE_NET +using _STLP_VENDOR_CSTD::putwc; +# endif +using _STLP_VENDOR_CSTD::putwchar; +# endif + +# if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \ + defined (_STLP_WCHAR_HPACC_EXCLUDE) ) +# if !defined (_STLP_SGX_CONFIG) +# if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB <= 1300) || \ + defined (__MINGW32__) +# undef swprintf +# define swprintf _snwprintf +# undef vswprintf +# define vswprintf _vsnwprintf +using ::swprintf; +using ::vswprintf; +# else +using _STLP_VENDOR_CSTD::swprintf; +using _STLP_VENDOR_CSTD::vswprintf; +# endif +using _STLP_VENDOR_CSTD::swscanf; +using _STLP_VENDOR_CSTD::vfwprintf; +using _STLP_VENDOR_CSTD::vwprintf; +# endif + +# if !defined (_STLP_SGX_CONFIG) && (!defined(__MSL__) || __MSL__ > 0x7001 ) && !defined(_STLP_WCE_NET) && \ + !defined(_STLP_USE_UCLIBC) /* at least in uClibc 0.9.26 */ + +using _STLP_VENDOR_CSTD::wcsftime; +# endif +using _STLP_VENDOR_CSTD::wcstok; + +# endif + +# if !defined (_STLP_WCE_NET) +using _STLP_VENDOR_CSTD::wcscoll; +using _STLP_VENDOR_CSTD::wcsxfrm; +# endif +# if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::wcscat; +# endif +using _STLP_VENDOR_CSTD::wcsrchr; +using _STLP_VENDOR_CSTD::wcscmp; + +# if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::wcscpy; +# endif +using _STLP_VENDOR_CSTD::wcscspn; + +using _STLP_VENDOR_CSTD::wcslen; +using _STLP_VENDOR_CSTD::wcsncat; +using _STLP_VENDOR_CSTD::wcsncmp; +using _STLP_VENDOR_CSTD::wcsncpy; +using _STLP_VENDOR_CSTD::wcspbrk; +using _STLP_VENDOR_CSTD::wcschr; + +using _STLP_VENDOR_CSTD::wcsspn; + +# if !defined (_STLP_SGX_CONFIG) && !defined (_STLP_WCHAR_BORLAND_EXCLUDE) +using _STLP_VENDOR_CSTD::wcstod; +using _STLP_VENDOR_CSTD::wcstol; +# endif + +# if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_HPACC_EXCLUDE) ) +using _STLP_VENDOR_CSTD::wcsstr; +using _STLP_VENDOR_CSTD::wmemchr; + +# if !defined (_STLP_WCHAR_BORLAND_EXCLUDE) +# if !defined (_STLP_SGX_CONFIG) && !defined (_STLP_WCE_NET) +using _STLP_VENDOR_CSTD::wctob; +# endif +# if !defined (__DMC__) +using _STLP_VENDOR_CSTD::wmemcmp; +using _STLP_VENDOR_CSTD::wmemmove; +# endif +# if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::wprintf; +using _STLP_VENDOR_CSTD::wscanf; +# endif +# endif + +# if defined (__BORLANDC__) && !defined (__linux__) +inline wchar_t* _STLP_wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n) +{ return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::wmemcpy(__wdst, __wsrc, __n)); } +inline wchar_t* _STLP_wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n) +{ return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::memset(__wdst, __wc, __n)); } +# undef wmemcpy +# undef wmemset +inline wchar_t* wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n) +{ return _STLP_wmemcpy(__wdst, __wsrc, __n); } +inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n) +{ return _STLP_wmemset(__wdst, __wc, __n); } +# elif defined (__DMC__) +inline wchar_t* wmemcpy(wchar_t* __RESTRICT __wdst, const wchar_t* __RESTRICT __wsrc, size_t __n) +{ return __STATIC_CAST(wchar_t*, memcpy(__wdst, __wsrc, __n * sizeof(wchar_t))); } +inline wchar_t* wmemmove(wchar_t* __RESTRICT __wdst, const wchar_t * __RESTRICT __wc, size_t __n) +{ return __STATIC_CAST(wchar_t*, memmove(__wdst, __wc, __n * sizeof(wchar_t))); } +inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n) +{ for (size_t i = 0; i < __n; i++) __wdst[i] = __wc; return __wdst; } +# else +using _STLP_VENDOR_CSTD::wmemcpy; +using _STLP_VENDOR_CSTD::wmemset; +# endif +# endif + +# endif /* _STLP_NO_NATIVE_WIDE_FUNCTIONS */ +_STLP_END_NAMESPACE + +# endif /* _STLP_IMPORT_VENDOR_CSTD */ + +# undef _STLP_WCHAR_SUNPRO_EXCLUDE +# undef _STLP_WCHAR_MSL_EXCLUDE + +# endif /* !defined(_STLP_WCE_EVC3) */ + +#endif /* _STLP_INTERNAL_CWCHAR */ diff --git a/sdk/tlibstdcxx/stlport/stl/_cwctype.h b/sdk/tlibstdcxx/stlport/stl/_cwctype.h new file mode 100644 index 0000000000..d9ade645e3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_cwctype.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CWCTYPE +#define _STLP_INTERNAL_CWCTYPE + +#if defined (__BORLANDC__) && !defined (_STLP_INTERNAL_CCTYPE) +# include +#endif + +#if !defined (_STLP_WCE_EVC3) +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_C_HEADER(cwctype) +# endif +# if defined (__MSL__) +namespace std { + typedef wchar_t wctrans_t; + wint_t towctrans(wint_t c, wctrans_t value); + wctrans_t wctrans(const char *name); +} +using std::wctrans_t; +using std::towctrans; +using std::wctrans; +# endif +# else +# include +# endif + +# if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (__hpux) + +# if defined (_STLP_USE_GLIBC) && !(defined (_GLIBCPP_USE_WCHAR_T) || defined (_GLIBCXX_USE_WCHAR_T)) || \ + defined (__sun) || defined (__FreeBSD__) || \ + defined (__CYGWIN__) || \ + defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION < 3) || (__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION <= 0)) +//We take wide functions from global namespace: +# define _STLP_VENDOR_CSTD_WFUNC +# else +# define _STLP_VENDOR_CSTD_WFUNC _STLP_VENDOR_CSTD +# endif + +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD_WFUNC::wctype_t; +using _STLP_VENDOR_CSTD_WFUNC::wint_t; +# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +# if !defined (__BORLANDC__) && !defined (__MSL__) +using _STLP_VENDOR_CSTD_WFUNC::wctrans_t; +# if !defined (_STLP_SGX_CONFIG) +# if !defined (__DMC__) && (!defined(_WIN32_WCE) || (_WIN32_WCE < 400)) +using _STLP_VENDOR_CSTD_WFUNC::towctrans; +using _STLP_VENDOR_CSTD_WFUNC::wctrans; +using _STLP_VENDOR_CSTD_WFUNC::wctype; +# endif +using _STLP_VENDOR_CSTD_WFUNC::iswctype; +# endif +# endif +# if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD_WFUNC::iswalnum; +using _STLP_VENDOR_CSTD_WFUNC::iswalpha; +using _STLP_VENDOR_CSTD_WFUNC::iswcntrl; + +using _STLP_VENDOR_CSTD_WFUNC::iswdigit; +using _STLP_VENDOR_CSTD_WFUNC::iswgraph; +using _STLP_VENDOR_CSTD_WFUNC::iswlower; +using _STLP_VENDOR_CSTD_WFUNC::iswprint; +using _STLP_VENDOR_CSTD_WFUNC::iswpunct; +using _STLP_VENDOR_CSTD_WFUNC::iswspace; +using _STLP_VENDOR_CSTD_WFUNC::iswupper; +using _STLP_VENDOR_CSTD_WFUNC::iswxdigit; + +using _STLP_VENDOR_CSTD_WFUNC::towlower; +using _STLP_VENDOR_CSTD_WFUNC::towupper; +# endif +# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ +_STLP_END_NAMESPACE +# endif /* _STLP_IMPORT_VENDOR_CSTD */ +#endif /* _STLP_WCE_EVC3 */ + +#endif /* _STLP_INTERNAL_CWCTYPE */ diff --git a/sdk/tlibstdcxx/stlport/stl/_deque.c b/sdk/tlibstdcxx/stlport/stl/_deque.c new file mode 100644 index 0000000000..74e9ef61da --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_deque.c @@ -0,0 +1,823 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_DEQUE_C +#define _STLP_DEQUE_C + +#ifndef _STLP_INTERNAL_DEQUE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Non-inline member functions from _Deque_base. + +template +_Deque_base<_Tp,_Alloc >::~_Deque_base() { + if (_M_map._M_data) { + _M_destroy_nodes(_M_start._M_node, this->_M_finish._M_node + 1); + _M_map.deallocate(_M_map._M_data, _M_map_size._M_data); + } +} + +template +void _Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements) { + size_t __num_nodes = __num_elements / this->buffer_size() + 1 ; + + _M_map_size._M_data = (max)((size_t) _S_initial_map_size, __num_nodes + 2); + _M_map._M_data = _M_map.allocate(_M_map_size._M_data); + + _Tp** __nstart = _M_map._M_data + (_M_map_size._M_data - __num_nodes) / 2; + _Tp** __nfinish = __nstart + __num_nodes; + + _STLP_TRY { + _M_create_nodes(__nstart, __nfinish); + } + _STLP_UNWIND((_M_map.deallocate(_M_map._M_data, _M_map_size._M_data), + _M_map._M_data = 0, _M_map_size._M_data = 0)) + _M_start._M_set_node(__nstart); + this->_M_finish._M_set_node(__nfinish - 1); + _M_start._M_cur = _M_start._M_first; + this->_M_finish._M_cur = this->_M_finish._M_first + __num_elements % this->buffer_size(); +} + +template +void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, + _Tp** __nfinish) { + _Tp** __cur = __nstart; + _STLP_TRY { + for (; __cur < __nfinish; ++__cur) + *__cur = _M_map_size.allocate(this->buffer_size()); + } + _STLP_UNWIND(_M_destroy_nodes(__nstart, __cur)) +} + +template +void _Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, + _Tp** __nfinish) { + for (_Tp** __n = __nstart; __n < __nfinish; ++__n) + _M_map_size.deallocate(*__n, this->buffer_size()); +} + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define deque _STLP_PTR_IMPL_NAME(deque) +#elif defined (_STLP_DEBUG) +# define deque _STLP_NON_DBG_NAME(deque) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +// qualified references +# define __iterator__ _Deque_iterator<_Tp, _Nonconst_traits<_Tp> > +# define const_iterator _Deque_iterator<_Tp, _Const_traits<_Tp> > +# define iterator __iterator__ +# define size_type size_t +# define value_type _Tp +#else +# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE deque<_Tp, _Alloc>::iterator +#endif + +template +deque<_Tp, _Alloc >& +deque<_Tp, _Alloc >::operator= (const deque<_Tp, _Alloc >& __x) { + const size_type __len = size(); + if (&__x != this) { + if (__len >= __x.size()) + erase(_STLP_STD::copy(__x.begin(), __x.end(), this->_M_start), this->_M_finish); + else { + const_iterator __mid = __x.begin() + difference_type(__len); + _STLP_STD::copy(__x.begin(), __mid, this->_M_start); + insert(this->_M_finish, __mid, __x.end()); + } + } + return *this; +} + +template +void deque<_Tp, _Alloc >::_M_fill_insert(iterator __pos, + size_type __n, const value_type& __x) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + if (__pos._M_cur == this->_M_start._M_cur) { + iterator __new_start = _M_reserve_elements_at_front(__n); + _STLP_TRY { + uninitialized_fill(__new_start, this->_M_start, __x); + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + this->_M_start = __new_start; + } + else if (__pos._M_cur == this->_M_finish._M_cur) { + iterator __new_finish = _M_reserve_elements_at_back(__n); + _STLP_TRY { + uninitialized_fill(this->_M_finish, __new_finish, __x); + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node+1, __new_finish._M_node+1)) + this->_M_finish = __new_finish; + } + else + _M_fill_insert_aux(__pos, __n, __x, _Movable()); +} + +#if !defined (_STLP_MEMBER_TEMPLATES) + +template +void deque<_Tp, _Alloc>::insert(iterator __pos, + const value_type* __first, const value_type* __last) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + size_type __n = __last - __first; + if (__pos._M_cur == this->_M_start._M_cur) { + iterator __new_start = _M_reserve_elements_at_front(__n); + _STLP_TRY { + _STLP_PRIV __ucopy(__first, __last, __new_start); + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + this->_M_start = __new_start; + } + else if (__pos._M_cur == this->_M_finish._M_cur) { + iterator __new_finish = _M_reserve_elements_at_back(__n); + _STLP_TRY { + _STLP_PRIV __ucopy(__first, __last, this->_M_finish); + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, + __new_finish._M_node + 1)) + this->_M_finish = __new_finish; + } + else + _M_insert_range_aux(__pos, __first, __last, __n, _Movable()); +} + +template +void deque<_Tp,_Alloc>::insert(iterator __pos, + const_iterator __first, const_iterator __last) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + size_type __n = __last - __first; + if (__pos._M_cur == this->_M_start._M_cur) { + iterator __new_start = _M_reserve_elements_at_front(__n); + _STLP_TRY { + _STLP_PRIV __ucopy(__first, __last, __new_start); + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + this->_M_start = __new_start; + } + else if (__pos._M_cur == this->_M_finish._M_cur) { + iterator __new_finish = _M_reserve_elements_at_back(__n); + _STLP_TRY { + _STLP_PRIV __ucopy(__first, __last, this->_M_finish); + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, + __new_finish._M_node + 1)) + this->_M_finish = __new_finish; + } + else + _M_insert_range_aux(__pos, __first, __last, __n, _Movable()); +} + +#endif /* _STLP_MEMBER_TEMPLATES */ + +template +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __pos, + const __true_type& /*_Movable*/) { + difference_type __index = __pos - this->_M_start; + if (size_type(__index) < this->size() >> 1) { + //We move the start of the deque one position to the right + //starting from the rightmost element to move. + iterator __src = __pos, __dst = __pos; + _STLP_STD::_Destroy(&(*__dst)); + if (__src != this->_M_start) { + for (--__src; __dst != this->_M_start; --__src, --__dst) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + } + _M_pop_front_aux(); + } + else { + iterator __src = __pos, __dst = __pos; + _STLP_STD::_Destroy(&(*__dst)); + for (++__src; __src != this->_M_finish; ++__src, ++__dst) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + //Duplication of the pop_back code without the destroy which has already been done: + if (this->_M_finish._M_cur != this->_M_finish._M_first) { + --this->_M_finish._M_cur; + } + else { + _M_pop_back_aux(); + } + } + return this->_M_start + __index; +} + +template +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __pos, + const __false_type& /*_Movable*/) { + iterator __next = __pos; + ++__next; + difference_type __index = __pos - this->_M_start; + if (size_type(__index) < this->size() >> 1) { + copy_backward(this->_M_start, __pos, __next); + pop_front(); + } + else { + _STLP_STD::copy(__next, this->_M_finish, __pos); + pop_back(); + } + return this->_M_start + __index; +} + +template +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __first, iterator __last, + const __true_type& /*_Movable*/) { + difference_type __n = __last - __first; + difference_type __elems_before = __first - this->_M_start; + if (__elems_before <= difference_type(this->size() - __n) / 2) { + iterator __src = __first, __dst = __last; + if (__src != this->_M_start) { + for (--__src, --__dst; (__src >= this->_M_start) && (__dst >= __first); --__src, --__dst) { + _STLP_STD::_Destroy(&(*__dst)); + _STLP_STD::_Move_Construct(&(*__dst), *__src); + } + if (__dst >= __first) { + //There are more elements to erase than elements to move + _STLP_STD::_Destroy_Range(__first, ++__dst); + _STLP_STD::_Destroy_Moved_Range(this->_M_start, __first); + } + else { + //There are more elements to move than elements to erase + for (; __src >= this->_M_start; --__src, --__dst) { + _STLP_STD::_Destroy_Moved(&(*__dst)); + _STLP_STD::_Move_Construct(&(*__dst), *__src); + } + _STLP_STD::_Destroy_Moved_Range(this->_M_start, ++__dst); + } + } + else { + _STLP_STD::_Destroy_Range(this->_M_start, __last); + } + iterator __new_start = this->_M_start + __n; + this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node); + this->_M_start = __new_start; + } + else { + if (__last != this->_M_finish) { + iterator __src = __last, __dst = __first; + for (; (__src != this->_M_finish) && (__dst != __last); ++__src, ++__dst) { + _STLP_STD::_Destroy(&(*__dst)); + _STLP_STD::_Move_Construct(&(*__dst), *__src); + } + if (__dst != __last) { + //There are more elements to erase than elements to move + _STLP_STD::_Destroy_Range(__dst, __last); + _STLP_STD::_Destroy_Moved_Range(__last, this->_M_finish); + } + else { + //There are more elements to move than elements to erase + for (; __src != this->_M_finish; ++__src, ++__dst) { + _STLP_STD::_Destroy_Moved(&(*__dst)); + _STLP_STD::_Move_Construct(&(*__dst), *__src); + } + _STLP_STD::_Destroy_Moved_Range(__dst, this->_M_finish); + } + } + else { + _STLP_STD::_Destroy_Range(__first, this->_M_finish); + } + iterator __new_finish = this->_M_finish - __n; + this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1); + this->_M_finish = __new_finish; + } + return this->_M_start + __elems_before; +} + +template +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __first, iterator __last, + const __false_type& /*_Movable*/) { + difference_type __n = __last - __first; + difference_type __elems_before = __first - this->_M_start; + if (__elems_before <= difference_type(this->size() - __n) / 2) { + copy_backward(this->_M_start, __first, __last); + iterator __new_start = this->_M_start + __n; + _STLP_STD::_Destroy_Range(this->_M_start, __new_start); + this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node); + this->_M_start = __new_start; + } + else { + _STLP_STD::copy(__last, this->_M_finish, __first); + iterator __new_finish = this->_M_finish - __n; + _STLP_STD::_Destroy_Range(__new_finish, this->_M_finish); + this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1); + this->_M_finish = __new_finish; + } + return this->_M_start + __elems_before; +} + +template +void deque<_Tp,_Alloc>::clear() { + for (_Map_pointer __node = this->_M_start._M_node + 1; + __node < this->_M_finish._M_node; + ++__node) { + _STLP_STD::_Destroy_Range(*__node, *__node + this->buffer_size()); + this->_M_map_size.deallocate(*__node, this->buffer_size()); + } + + if (this->_M_start._M_node != this->_M_finish._M_node) { + _STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_start._M_last); + _STLP_STD::_Destroy_Range(this->_M_finish._M_first, this->_M_finish._M_cur); + this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size()); + } + else + _STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_finish._M_cur); + + this->_M_finish = this->_M_start; +} + +// Precondition: this->_M_start and this->_M_finish have already been initialized, +// but none of the deque's elements have yet been constructed. +template +void deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __val, + const __false_type& /*_TrivialInit*/) { + _Map_pointer __cur = this->_M_start._M_node; + _STLP_TRY { + for (; __cur < this->_M_finish._M_node; ++__cur) + uninitialized_fill(*__cur, *__cur + this->buffer_size(), __val); + uninitialized_fill(this->_M_finish._M_first, this->_M_finish._M_cur, __val); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(this->_M_start, iterator(*__cur, __cur))) +} + + +// Called only if this->_M_finish._M_cur == this->_M_finish._M_last - 1. +template +void deque<_Tp,_Alloc>::_M_push_back_aux_v(const value_type& __t) { + _M_reserve_map_at_back(); + *(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size()); + _STLP_TRY { + _Copy_Construct(this->_M_finish._M_cur, __t); + this->_M_finish._M_set_node(this->_M_finish._M_node + 1); + this->_M_finish._M_cur = this->_M_finish._M_first; + } + _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1), + this->buffer_size())) +} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) +// Called only if this->_M_finish._M_cur == this->_M_finish._M_last - 1. +template +void deque<_Tp,_Alloc>::_M_push_back_aux() { + _M_reserve_map_at_back(); + *(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size()); + _STLP_TRY { + _STLP_STD::_Construct(this->_M_finish._M_cur); + this->_M_finish._M_set_node(this->_M_finish._M_node + 1); + this->_M_finish._M_cur = this->_M_finish._M_first; + } + _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1), + this->buffer_size())) +} +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + +// Called only if this->_M_start._M_cur == this->_M_start._M_first. +template +void deque<_Tp,_Alloc>::_M_push_front_aux_v(const value_type& __t) { + _M_reserve_map_at_front(); + *(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size()); + _STLP_TRY { + this->_M_start._M_set_node(this->_M_start._M_node - 1); + this->_M_start._M_cur = this->_M_start._M_last - 1; + _Copy_Construct(this->_M_start._M_cur, __t); + } + _STLP_UNWIND((++this->_M_start, + this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), this->buffer_size()))) +} + + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) +// Called only if this->_M_start._M_cur == this->_M_start._M_first. +template +void deque<_Tp,_Alloc>::_M_push_front_aux() { + _M_reserve_map_at_front(); + *(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size()); + _STLP_TRY { + this->_M_start._M_set_node(this->_M_start._M_node - 1); + this->_M_start._M_cur = this->_M_start._M_last - 1; + _STLP_STD::_Construct(this->_M_start._M_cur); + } + _STLP_UNWIND((++this->_M_start, this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), + this->buffer_size()))) +} +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + +// Called only if this->_M_finish._M_cur == this->_M_finish._M_first. +template +void deque<_Tp,_Alloc>::_M_pop_back_aux() { + this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size()); + this->_M_finish._M_set_node(this->_M_finish._M_node - 1); + this->_M_finish._M_cur = this->_M_finish._M_last - 1; +} + +// Note that if the deque has at least one element (a precondition for this member +// function), and if this->_M_start._M_cur == this->_M_start._M_last, then the deque +// must have at least two nodes. +template +void deque<_Tp,_Alloc>::_M_pop_front_aux() { + if (this->_M_start._M_cur != this->_M_start._M_last - 1) + ++this->_M_start._M_cur; + else { + this->_M_map_size.deallocate(this->_M_start._M_first, this->buffer_size()); + this->_M_start._M_set_node(this->_M_start._M_node + 1); + this->_M_start._M_cur = this->_M_start._M_first; + } +} + +template +__iterator__ deque<_Tp,_Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n, + const value_type& __x, + const __true_type& /*_Movable*/) { + const difference_type __elems_before = __pos - this->_M_start; + size_type __length = this->size(); + value_type __x_copy = __x; + if (__elems_before <= difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + __pos = this->_M_start + __elems_before; + _STLP_TRY { + iterator __dst = __new_start; + iterator __src = this->_M_start; + for (; __src != __pos; ++__dst, ++__src) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_start = __new_start; + uninitialized_fill(__dst, __src, __x_copy); + __pos = __dst; + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + const difference_type __elems_after = difference_type(__length) - __elems_before; + __pos = this->_M_finish - __elems_after; + _STLP_TRY { + iterator __dst = __new_finish; + iterator __src = this->_M_finish; + for (--__src, --__dst; __src >= __pos; --__src, --__dst) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_finish = __new_finish; + uninitialized_fill(__pos, __pos + __n, __x_copy); + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } + return __pos; +} + +template +__iterator__ deque<_Tp,_Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n, + const value_type& __x, + const __false_type& /*_Movable*/) { + const difference_type __elems_before = __pos - this->_M_start; + size_type __length = this->size(); + value_type __x_copy = __x; + if (__elems_before <= difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_start; + __pos = this->_M_start + __elems_before; + _STLP_TRY { + if (__elems_before >= difference_type(__n)) { + iterator __start_n = this->_M_start + difference_type(__n); + _STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start); + this->_M_start = __new_start; + _STLP_STD::copy(__start_n, __pos, __old_start); + _STLP_STD::fill(__pos - difference_type(__n), __pos, __x_copy); + __pos -= difference_type(__n); + } + else { + _STLP_PRIV __uninitialized_copy_fill(this->_M_start, __pos, __new_start, + this->_M_start, __x_copy); + this->_M_start = __new_start; + fill(__old_start, __pos, __x_copy); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_finish; + const difference_type __elems_after = + difference_type(__length) - __elems_before; + __pos = this->_M_finish - __elems_after; + _STLP_TRY { + if (__elems_after > difference_type(__n)) { + iterator __finish_n = this->_M_finish - difference_type(__n); + _STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; + copy_backward(__pos, __finish_n, __old_finish); + fill(__pos, __pos + difference_type(__n), __x_copy); + } + else { + _STLP_PRIV __uninitialized_fill_copy(this->_M_finish, __pos + difference_type(__n), + __x_copy, __pos, this->_M_finish); + this->_M_finish = __new_finish; + fill(__pos, __old_finish, __x_copy); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } + return __pos; +} + +#if !defined (_STLP_MEMBER_TEMPLATES) +template +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos, + const value_type* __first, const value_type* __last, + size_type __n, const __true_type& /*_Movable*/) { + const difference_type __elems_before = __pos - this->_M_start; + size_type __length = size(); + if (__elems_before <= difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + __pos = this->_M_start + __elems_before; + _STLP_TRY { + iterator __dst = __new_start; + iterator __src = this->_M_start; + for (; __src != __pos; ++__dst, ++__src) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_start = __new_start; + _STLP_PRIV __ucopy(__first, __last, __dst); + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + const difference_type __elems_after = difference_type(__length) - __elems_before; + __pos = this->_M_finish - __elems_after; + _STLP_TRY { + iterator __dst = __new_finish; + iterator __src = this->_M_finish; + for (--__src, --__dst; __src >= __pos; --__src, --__dst) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_finish = __new_finish; + _STLP_PRIV __ucopy(__first, __last, __pos); + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } +} + +template +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos, + const value_type* __first, const value_type* __last, + size_type __n, const __false_type& /*_Movable*/) { + const difference_type __elems_before = __pos - this->_M_start; + size_type __length = size(); + if (__elems_before <= difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_start; + __pos = this->_M_start + __elems_before; + _STLP_TRY { + if (__elems_before >= difference_type(__n)) { + iterator __start_n = this->_M_start + difference_type(__n); + _STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start); + this->_M_start = __new_start; + _STLP_STD::copy(__start_n, __pos, __old_start); + _STLP_STD::copy(__first, __last, __pos - difference_type(__n)); + } + else { + const value_type* __mid = __first + (difference_type(__n) - __elems_before); + _STLP_PRIV __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid, __new_start); + this->_M_start = __new_start; + _STLP_STD::copy(__mid, __last, __old_start); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_finish; + const difference_type __elems_after = + difference_type(__length) - __elems_before; + __pos = this->_M_finish - __elems_after; + _STLP_TRY { + + if (__elems_after > difference_type(__n)) { + iterator __finish_n = this->_M_finish - difference_type(__n); + _STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; + _STLP_STD::copy_backward(__pos, __finish_n, __old_finish); + _STLP_STD::copy(__first, __last, __pos); + } + else { + const value_type* __mid = __first + __elems_after; + _STLP_PRIV __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; + _STLP_STD::copy(__first, __mid, __pos); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } +} + +template +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos, + const_iterator __first, const_iterator __last, + size_type __n, const __true_type& /*_Movable*/) { + const difference_type __elems_before = __pos - this->_M_start; + size_type __length = size(); + if (__elems_before <= difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + __pos = this->_M_start + __elems_before; + _STLP_TRY { + iterator __dst = __new_start; + iterator __src = this->_M_start; + for (; __src != __pos; ++__dst, ++__src) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_start = __new_start; + _STLP_PRIV __ucopy(__first, __last, __dst); + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + const difference_type __elems_after = difference_type(__length) - __elems_before; + __pos = this->_M_finish - __elems_after; + _STLP_TRY { + iterator __dst = __new_finish; + iterator __src = this->_M_finish; + for (--__src, --__dst; __src >= __pos; --__src, --__dst) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_finish = __new_finish; + _STLP_PRIV __ucopy(__first, __last, __pos); + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } +} + +template +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos, + const_iterator __first, const_iterator __last, + size_type __n, const __false_type& /*_Movable*/) { + const difference_type __elems_before = __pos - this->_M_start; + size_type __length = size(); + if (__elems_before < difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_start; + __pos = this->_M_start + __elems_before; + _STLP_TRY { + if (__elems_before >= difference_type(__n)) { + iterator __start_n = this->_M_start + __n; + _STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start); + this->_M_start = __new_start; + _STLP_STD::copy(__start_n, __pos, __old_start); + _STLP_STD::copy(__first, __last, __pos - difference_type(__n)); + } + else { + const_iterator __mid = __first + (__n - __elems_before); + _STLP_PRIV __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid, __new_start); + this->_M_start = __new_start; + _STLP_STD::copy(__mid, __last, __old_start); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_finish; + const difference_type __elems_after = __length - __elems_before; + __pos = this->_M_finish - __elems_after; + _STLP_TRY { + if (__elems_after > difference_type(__n)) { + iterator __finish_n = this->_M_finish - difference_type(__n); + _STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; + _STLP_STD::copy_backward(__pos, __finish_n, __old_finish); + _STLP_STD::copy(__first, __last, __pos); + } + else { + const_iterator __mid = __first + __elems_after; + _STLP_PRIV __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; + _STLP_STD::copy(__first, __mid, __pos); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } +} +#endif /* _STLP_MEMBER_TEMPLATES */ + +template +void deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems) { + size_type __new_nodes + = (__new_elems + this->buffer_size() - 1) / this->buffer_size(); + _M_reserve_map_at_front(__new_nodes); + size_type __i = 1; + _STLP_TRY { + for (; __i <= __new_nodes; ++__i) + *(this->_M_start._M_node - __i) = this->_M_map_size.allocate(this->buffer_size()); + } + _STLP_UNWIND(for (size_type __j = 1; __j < __i; ++__j) + this->_M_map_size.deallocate(*(this->_M_start._M_node - __j), this->buffer_size())) +} + +template +void deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems) { + size_type __new_nodes + = (__new_elems + this->buffer_size() - 1) / this->buffer_size(); + _M_reserve_map_at_back(__new_nodes); + size_type __i = 1; + _STLP_TRY { + for (; __i <= __new_nodes; ++__i) + *(this->_M_finish._M_node + __i) = this->_M_map_size.allocate(this->buffer_size()); + } + _STLP_UNWIND(for (size_type __j = 1; __j < __i; ++__j) + this->_M_map_size.deallocate(*(this->_M_finish._M_node + __j), this->buffer_size())) +} + +template +void deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add, + bool __add_at_front) { + size_type __old_num_nodes = this->_M_finish._M_node - this->_M_start._M_node + 1; + size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; + + _Map_pointer __new_nstart; + if (this->_M_map_size._M_data > 2 * __new_num_nodes) { + __new_nstart = this->_M_map._M_data + (this->_M_map_size._M_data - __new_num_nodes) / 2 + + (__add_at_front ? __nodes_to_add : 0); + if (__new_nstart < this->_M_start._M_node) + _STLP_STD::copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart); + else + _STLP_STD::copy_backward(this->_M_start._M_node, this->_M_finish._M_node + 1, + __new_nstart + __old_num_nodes); + } + else { + size_type __new_map_size = + this->_M_map_size._M_data + (max)((size_t)this->_M_map_size._M_data, __nodes_to_add) + 2; + + _Map_pointer __new_map = this->_M_map.allocate(__new_map_size); + __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2 + + (__add_at_front ? __nodes_to_add : 0); + _STLP_STD::copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart); + this->_M_map.deallocate(this->_M_map._M_data, this->_M_map_size._M_data); + + this->_M_map._M_data = __new_map; + this->_M_map_size._M_data = __new_map_size; + } + + this->_M_start._M_set_node(__new_nstart); + this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); +} + +#if defined (deque) +# undef deque +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#undef __iterator__ +#undef iterator +#undef const_iterator +#undef size_type +#undef value_type + +#endif /* _STLP_DEQUE_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_deque.h b/sdk/tlibstdcxx/stlport/stl/_deque.h new file mode 100644 index 0000000000..a8faeef286 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_deque.h @@ -0,0 +1,1115 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_DEQUE_H +#define _STLP_INTERNAL_DEQUE_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +# include +#endif + +#ifndef _STLP_RANGE_ERRORS_H +# include +#endif + +/* Class invariants: + * For any nonsingular iterator i: + * i.node is the address of an element in the map array. The + * contents of i.node is a pointer to the beginning of a node. + * i.first == *(i.node) + * i.last == i.first + node_size + * i.cur is a pointer in the range [i.first, i.last). NOTE: + * the implication of this is that i.cur is always a dereferenceable + * pointer, even if i is a past-the-end iterator. + * Start and Finish are always nonsingular iterators. NOTE: this means + * that an empty deque must have one node, and that a deque + * with N elements, where N is the buffer size, must have two nodes. + * For every node other than start.node and finish.node, every element + * in the node is an initialized object. If start.node == finish.node, + * then [start.cur, finish.cur) are initialized objects, and + * the elements outside that range are uninitialized storage. Otherwise, + * [start.cur, start.last) and [finish.first, finish.cur) are initialized + * objects, and [start.first, start.cur) and [finish.cur, finish.last) + * are uninitialized storage. + * [map, map + map_size) is a valid, non-empty range. + * [start.node, finish.node] is a valid range contained within + * [map, map + map_size). + * A pointer in the range [map, map + map_size) points to an allocated node + * if and only if the pointer is in the range [start.node, finish.node]. + */ + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _Deque_iterator_base { + + static size_t _S_buffer_size() { + const size_t blocksize = _MAX_BYTES; + return (sizeof(_Tp) < blocksize ? (blocksize / sizeof(_Tp)) : 1); + } + + typedef random_access_iterator_tag iterator_category; + + typedef _Tp value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + typedef value_type** _Map_pointer; + + typedef _Deque_iterator_base< _Tp > _Self; + + value_type* _M_cur; + value_type* _M_first; + value_type* _M_last; + _Map_pointer _M_node; + + _Deque_iterator_base(value_type* __x, _Map_pointer __y) + : _M_cur(__x), _M_first(*__y), + _M_last(*__y + _S_buffer_size()), _M_node(__y) {} + + _Deque_iterator_base() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {} + +// see comment in doc/README.evc4 and doc/README.evc8 +#if defined (_STLP_MSVC) && (_STLP_MSVC <= 1401) && defined (MIPS) && defined (NDEBUG) + _Deque_iterator_base(_Deque_iterator_base const& __other) + : _M_cur(__other._M_cur), _M_first(__other._M_first), + _M_last(__other._M_last), _M_node(__other._M_node) {} +#endif + + difference_type _M_subtract(const _Self& __x) const { + return difference_type(_S_buffer_size()) * (_M_node - __x._M_node - 1) + + (_M_cur - _M_first) + (__x._M_last - __x._M_cur); + } + + void _M_increment() { + if (++_M_cur == _M_last) { + _M_set_node(_M_node + 1); + _M_cur = _M_first; + } + } + + void _M_decrement() { + if (_M_cur == _M_first) { + _M_set_node(_M_node - 1); + _M_cur = _M_last; + } + --_M_cur; + } + + void _M_advance(difference_type __n) { + const size_t buffersize = _S_buffer_size(); + difference_type __offset = __n + (_M_cur - _M_first); + if (__offset >= 0 && __offset < difference_type(buffersize)) + _M_cur += __n; + else { + difference_type __node_offset = + __offset > 0 ? __offset / buffersize + : -difference_type((-__offset - 1) / buffersize) - 1; + _M_set_node(_M_node + __node_offset); + _M_cur = _M_first + + + (__offset - __node_offset * difference_type(buffersize)); + } + } + + void _M_set_node(_Map_pointer __new_node) { + _M_last = (_M_first = *(_M_node = __new_node)) + difference_type(_S_buffer_size()); + } +}; + + +template +struct _Deque_iterator : public _Deque_iterator_base< _Tp> { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef typename _Traits::reference reference; + typedef typename _Traits::pointer pointer; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef value_type** _Map_pointer; + + typedef _Deque_iterator_base< _Tp > _Base; + typedef _Deque_iterator<_Tp, _Traits> _Self; + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef _Deque_iterator<_Tp, _NonConstTraits> iterator; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _Deque_iterator<_Tp, _ConstTraits> const_iterator; + + _Deque_iterator(value_type* __x, _Map_pointer __y) : + _Deque_iterator_base(__x,__y) {} + + _Deque_iterator() {} + //copy constructor for iterator and constructor from iterator for const_iterator + _Deque_iterator(const iterator& __x) : + _Deque_iterator_base(__x) {} + + reference operator*() const { + return *this->_M_cur; + } + + _STLP_DEFINE_ARROW_OPERATOR + + difference_type operator-(const const_iterator& __x) const { return this->_M_subtract(__x); } + + _Self& operator++() { this->_M_increment(); return *this; } + _Self operator++(int) { + _Self __tmp = *this; + ++*this; + return __tmp; + } + + _Self& operator--() { this->_M_decrement(); return *this; } + _Self operator--(int) { + _Self __tmp = *this; + --*this; + return __tmp; + } + + _Self& operator+=(difference_type __n) { this->_M_advance(__n); return *this; } + _Self operator+(difference_type __n) const { + _Self __tmp = *this; + return __tmp += __n; + } + + _Self& operator-=(difference_type __n) { return *this += -__n; } + _Self operator-(difference_type __n) const { + _Self __tmp = *this; + return __tmp -= __n; + } + + reference operator[](difference_type __n) const { return *(*this + __n); } +}; + + +template +inline _Deque_iterator<_Tp, _Traits> _STLP_CALL +operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Traits>& __x) +{ return __x + __n; } + + +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template +inline bool _STLP_CALL +operator==(const _Deque_iterator_base<_Tp >& __x, + const _Deque_iterator_base<_Tp >& __y) +{ return __x._M_cur == __y._M_cur; } + +template +inline bool _STLP_CALL +operator < (const _Deque_iterator_base<_Tp >& __x, + const _Deque_iterator_base<_Tp >& __y) { + return (__x._M_node == __y._M_node) ? + (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); +} + +template +inline bool _STLP_CALL +operator!=(const _Deque_iterator_base<_Tp >& __x, + const _Deque_iterator_base<_Tp >& __y) +{ return __x._M_cur != __y._M_cur; } + +template +inline bool _STLP_CALL +operator>(const _Deque_iterator_base<_Tp >& __x, + const _Deque_iterator_base<_Tp >& __y) +{ return __y < __x; } + +template +inline bool _STLP_CALL operator>=(const _Deque_iterator_base<_Tp >& __x, + const _Deque_iterator_base<_Tp >& __y) +{ return !(__x < __y); } + +template +inline bool _STLP_CALL operator<=(const _Deque_iterator_base<_Tp >& __x, + const _Deque_iterator_base<_Tp >& __y) +{ return !(__y < __x); } + +#else /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template +inline bool _STLP_CALL +operator==(const _Deque_iterator<_Tp, _Traits1 >& __x, + const _Deque_iterator<_Tp, _Traits2 >& __y) +{ return __x._M_cur == __y._M_cur; } + +template +inline bool _STLP_CALL +operator < (const _Deque_iterator<_Tp, _Traits1 >& __x, + const _Deque_iterator<_Tp, _Traits2 >& __y) { + return (__x._M_node == __y._M_node) ? + (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); +} + +template +inline bool _STLP_CALL +operator!=(const _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >& __x, + const _Deque_iterator<_Tp, _Const_traits<_Tp> >& __y) +{ return __x._M_cur != __y._M_cur; } + +template +inline bool _STLP_CALL +operator>(const _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >& __x, + const _Deque_iterator<_Tp, _Const_traits<_Tp> >& __y) +{ return __y < __x; } + +template +inline bool _STLP_CALL +operator>=(const _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >& __x, + const _Deque_iterator<_Tp, _Const_traits<_Tp> >& __y) +{ return !(__x < __y); } + +template +inline bool _STLP_CALL +operator<=(const _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >& __x, + const _Deque_iterator<_Tp, _Const_traits<_Tp> >& __y) +{ return !(__y < __x); } +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_MOVE_TO_STD_NAMESPACE +template +struct __type_traits<_STLP_PRIV _Deque_iterator<_Tp, _Traits> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +_STLP_MOVE_TO_STD_NAMESPACE +template inline _Tp* _STLP_CALL +value_type(const _STLP_PRIV _Deque_iterator<_Tp, _Traits >&) { return (_Tp*)0; } +template inline random_access_iterator_tag _STLP_CALL +iterator_category(const _STLP_PRIV _Deque_iterator<_Tp, _Traits >&) { return random_access_iterator_tag(); } +template inline ptrdiff_t* _STLP_CALL +distance_type(const _STLP_PRIV _Deque_iterator<_Tp, _Traits >&) { return 0; } +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +/* Deque base class. It has two purposes. First, its constructor + * and destructor allocate (but don't initialize) storage. This makes + * exception safety easier. Second, the base class encapsulates all of + * the differences between SGI-style allocators and standard-conforming + * allocators. + */ + +template +class _Deque_base { + typedef _Deque_base<_Tp, _Alloc> _Self; +public: + typedef _Tp value_type; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _Alloc allocator_type; + typedef _STLP_alloc_proxy _Alloc_proxy; + + typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type _Map_alloc_type; + typedef _STLP_alloc_proxy _Map_alloc_proxy; + + typedef _Deque_iterator<_Tp, _Nonconst_traits<_Tp> > iterator; + typedef _Deque_iterator<_Tp, _Const_traits<_Tp> > const_iterator; + + static size_t _STLP_CALL buffer_size() { return _Deque_iterator_base<_Tp>::_S_buffer_size(); } + + _Deque_base(const allocator_type& __a, size_t __num_elements) + : _M_start(), _M_finish(), _M_map(_STLP_CONVERT_ALLOCATOR(__a, _Tp*), 0), + _M_map_size(__a, (size_t)0) + { _M_initialize_map(__num_elements); } + + _Deque_base(const allocator_type& __a) + : _M_start(), _M_finish(), _M_map(_STLP_CONVERT_ALLOCATOR(__a, _Tp*), 0), + _M_map_size(__a, (size_t)0) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Deque_base(__move_source<_Self> src) + : _M_start(src.get()._M_start), _M_finish(src.get()._M_finish), + _M_map(__move_source<_Map_alloc_proxy>(src.get()._M_map)), + _M_map_size(__move_source<_Alloc_proxy>(src.get()._M_map_size)) { + src.get()._M_map._M_data = 0; + src.get()._M_map_size._M_data = 0; + src.get()._M_finish = src.get()._M_start; + } +#endif + + ~_Deque_base(); + +protected: + void _M_initialize_map(size_t); + void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish); + void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish); + enum { _S_initial_map_size = 8 }; + +protected: + iterator _M_start; + iterator _M_finish; + _Map_alloc_proxy _M_map; + _Alloc_proxy _M_map_size; +}; + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define deque _STLP_PTR_IMPL_NAME(deque) +#elif defined (_STLP_DEBUG) +# define deque _STLP_NON_DBG_NAME(deque) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template ) > +class deque : protected _STLP_PRIV _Deque_base<_Tp, _Alloc> +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (deque) + , public __stlport_class > +#endif +{ + typedef _STLP_PRIV _Deque_base<_Tp, _Alloc> _Base; + typedef deque<_Tp, _Alloc> _Self; +public: // Basic types + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag _Iterator_category; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef typename _Base::allocator_type allocator_type; + +public: // Iterators + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +protected: // Internal typedefs + typedef pointer* _Map_pointer; +#if defined (_STLP_NO_MOVE_SEMANTIC) + typedef __false_type _Movable; +#endif + +public: // Basic accessors + iterator begin() { return this->_M_start; } + iterator end() { return this->_M_finish; } + const_iterator begin() const { return const_iterator(this->_M_start); } + const_iterator end() const { return const_iterator(this->_M_finish); } + + reverse_iterator rbegin() { return reverse_iterator(this->_M_finish); } + reverse_iterator rend() { return reverse_iterator(this->_M_start); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator(this->_M_finish); } + const_reverse_iterator rend() const + { return const_reverse_iterator(this->_M_start); } + + reference operator[](size_type __n) + { return this->_M_start[difference_type(__n)]; } + const_reference operator[](size_type __n) const + { return this->_M_start[difference_type(__n)]; } + + void _M_range_check(size_type __n) const { + if (__n >= this->size()) + __stl_throw_out_of_range("deque"); + } + reference at(size_type __n) + { _M_range_check(__n); return (*this)[__n]; } + const_reference at(size_type __n) const + { _M_range_check(__n); return (*this)[__n]; } + + reference front() { return *this->_M_start; } + reference back() { + iterator __tmp = this->_M_finish; + --__tmp; + return *__tmp; + } + const_reference front() const { return *this->_M_start; } + const_reference back() const { + const_iterator __tmp = this->_M_finish; + --__tmp; + return *__tmp; + } + + size_type size() const { return this->_M_finish - this->_M_start; } + size_type max_size() const { return size_type(-1); } + bool empty() const { return this->_M_finish == this->_M_start; } + allocator_type get_allocator() const { return this->_M_map_size; } + +public: // Constructor, destructor. +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit deque(const allocator_type& __a = allocator_type()) +#else + deque() + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(allocator_type(), 0) {} + deque(const allocator_type& __a) +#endif + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(__a, 0) {} + + deque(const _Self& __x) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(__x.get_allocator(), __x.size()) + { _STLP_PRIV __ucopy(__x.begin(), __x.end(), this->_M_start); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) +private: + void _M_initialize(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { + typedef typename _TrivialInit<_Tp>::_Ret _TrivialInit; + _M_fill_initialize(__val, _TrivialInit()); + } +public: + explicit deque(size_type __n) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(allocator_type(), __n) + { _M_initialize(__n); } + deque(size_type __n, const value_type& __val, const allocator_type& __a = allocator_type()) +#else + explicit deque(size_type __n) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(allocator_type(), __n) { + typedef typename _TrivialInit<_Tp>::_Ret _TrivialInit; + _M_fill_initialize(_STLP_DEFAULT_CONSTRUCTED(_Tp), _TrivialInit()); + } + deque(size_type __n, const value_type& __val) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(allocator_type(), __n) + { _M_fill_initialize(__val, __false_type()); } + deque(size_type __n, const value_type& __val, const allocator_type& __a) +#endif + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(__a, __n) + { _M_fill_initialize(__val, __false_type()); } + +#if defined (_STLP_MEMBER_TEMPLATES) +protected: + template + void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) { + this->_M_initialize_map(__n); + _M_fill_initialize(__x, __false_type()); + } + + template + void _M_initialize_dispatch(_InputIter __first, _InputIter __last, + const __false_type&) { + _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); + } + +public: + // Check whether it's an integral type. If so, it's not an iterator. + template + deque(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(__a) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + deque(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(allocator_type()) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +# endif + +#else + deque(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type() ) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(__a, __last - __first) + { _STLP_PRIV __ucopy(__first, __last, this->_M_start); } + + deque(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type() ) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(__a, __last - __first) + { _STLP_PRIV __ucopy(__first, __last, this->_M_start); } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + deque(__move_source<_Self> src) + : _STLP_PRIV _Deque_base<_Tp, _Alloc>(__move_source<_Base>(src.get())) + {} +#endif + + ~deque() + { _STLP_STD::_Destroy_Range(this->_M_start, this->_M_finish); } + + _Self& operator= (const _Self& __x); + + void swap(_Self& __x) { + _STLP_STD::swap(this->_M_start, __x._M_start); + _STLP_STD::swap(this->_M_finish, __x._M_finish); + this->_M_map.swap(__x._M_map); + this->_M_map_size.swap(__x._M_map_size); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +public: + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void _M_fill_assign(size_type __n, const _Tp& __val) { + if (__n > size()) { + _STLP_STD::fill(begin(), end(), __val); + insert(end(), __n - size(), __val); + } + else { + erase(begin() + __n, end()); + _STLP_STD::fill(begin(), end(), __val); + } + } + + void assign(size_type __n, const _Tp& __val) { + _M_fill_assign(__n, __val); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } + +private: // helper functions for assign() + + template + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) + { _M_fill_assign((size_type) __n, (_Tp) __val); } + + template + void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + const __false_type& /*_IsIntegral*/) { + _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); + } + + template + void _M_assign_aux(_InputIter __first, _InputIter __last, const input_iterator_tag &) { + iterator __cur = begin(); + for ( ; __first != __last && __cur != end(); ++__cur, ++__first) + *__cur = *__first; + if (__first == __last) + erase(__cur, end()); + else + insert(end(), __first, __last); + } + + template + void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { +#else + void assign(const value_type *__first, const value_type *__last) { + size_type __size = size(); + size_type __len = __last - __first; + if (__len > __size) { + const value_type *__mid = __first + __size; + _STLP_STD::copy(__first, __mid, begin()); + insert(end(), __mid, __last); + } + else { + erase(_STLP_STD::copy(__first, __last, begin()), end()); + } + } + void assign(const_iterator __first, const_iterator __last) { + typedef const_iterator _ForwardIterator; +#endif /* _STLP_MEMBER_TEMPLATES */ + size_type __len = _STLP_STD::distance(__first, __last); + if (__len > size()) { + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, size()); + _STLP_STD::copy(__first, __mid, begin()); + insert(end(), __mid, __last); + } + else { + erase(_STLP_STD::copy(__first, __last, begin()), end()); + } + } + + +public: // push_* and pop_* + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void push_back(const value_type& __t) { +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + if (this->_M_finish._M_cur != this->_M_finish._M_last - 1) { + _Copy_Construct(this->_M_finish._M_cur, __t); + ++this->_M_finish._M_cur; + } + else + _M_push_back_aux_v(__t); + } +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_front(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void push_front(const value_type& __t) { +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + if (this->_M_start._M_cur != this->_M_start._M_first) { + _Copy_Construct(this->_M_start._M_cur - 1, __t); + --this->_M_start._M_cur; + } + else + _M_push_front_aux_v(__t); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back() { + if (this->_M_finish._M_cur != this->_M_finish._M_last - 1) { + _STLP_STD::_Construct(this->_M_finish._M_cur); + ++this->_M_finish._M_cur; + } + else + _M_push_back_aux(); + } + void push_front() { + if (this->_M_start._M_cur != this->_M_start._M_first) { + _STLP_STD::_Construct(this->_M_start._M_cur - 1); + --this->_M_start._M_cur; + } + else + _M_push_front_aux(); + } +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + void pop_back() { + if (this->_M_finish._M_cur != this->_M_finish._M_first) { + --this->_M_finish._M_cur; + _STLP_STD::_Destroy(this->_M_finish._M_cur); + } + else { + _M_pop_back_aux(); + _STLP_STD::_Destroy(this->_M_finish._M_cur); + } + } + + void pop_front() { + _STLP_STD::_Destroy(this->_M_start._M_cur); + _M_pop_front_aux(); + } + +public: // Insert + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + iterator insert(iterator __pos, const value_type& __x) { +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + if (__pos._M_cur == this->_M_start._M_cur) { + push_front(__x); + return this->_M_start; + } + else if (__pos._M_cur == this->_M_finish._M_cur) { + push_back(__x); + iterator __tmp = this->_M_finish; + --__tmp; + return __tmp; + } + else { + return _M_fill_insert_aux(__pos, 1, __x, _Movable()); + } + } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos) + { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + void insert(iterator __pos, size_type __n, const value_type& __x) + { _M_fill_insert(__pos, __n, __x); } + +protected: + iterator _M_fill_insert_aux(iterator __pos, size_type __n, const value_type& __x, const __true_type& /*_Movable*/); + iterator _M_fill_insert_aux(iterator __pos, size_type __n, const value_type& __x, const __false_type& /*_Movable*/); + + void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + const __true_type& /*_IsIntegral*/) { + _M_fill_insert(__pos, (size_type) __n, (value_type) __x); + } + + template + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type& /*_IsIntegral*/) { + _M_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); + } + +public: + // Check whether it's an integral type. If so, it's not an iterator. + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); + } + +#else /* _STLP_MEMBER_TEMPLATES */ + void _M_insert_range_aux(iterator __pos, + const value_type* __first, const value_type* __last, + size_type __n, const __true_type& /*_Movable*/); + void _M_insert_range_aux(iterator __pos, + const value_type* __first, const value_type* __last, + size_type __n, const __false_type& /*_Movable*/); + void _M_insert_range_aux(iterator __pos, + const_iterator __first, const_iterator __last, + size_type __n, const __true_type& /*_Movable*/); + void _M_insert_range_aux(iterator __pos, + const_iterator __first, const_iterator __last, + size_type __n, const __false_type& /*_Movable*/); +public: + void insert(iterator __pos, + const value_type* __first, const value_type* __last); + void insert(iterator __pos, + const_iterator __first, const_iterator __last); + +#endif /* _STLP_MEMBER_TEMPLATES */ + +public: +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, + const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void resize(size_type __new_size, const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + const size_type __len = size(); + if (__new_size < __len) + erase(this->_M_start + __new_size, this->_M_finish); + else + insert(this->_M_finish, __new_size - __len, __x); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) + { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +protected: + iterator _M_erase(iterator __pos, const __true_type& /*_Movable*/); + iterator _M_erase(iterator __pos, const __false_type& /*_Movable*/); + + iterator _M_erase(iterator __first, iterator __last, const __true_type& /*_Movable*/); + iterator _M_erase(iterator __first, iterator __last, const __false_type& /*_Movable*/); +public: // Erase + iterator erase(iterator __pos) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + return _M_erase(__pos, _Movable()); + } + iterator erase(iterator __first, iterator __last) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + if (__first == this->_M_start && __last == this->_M_finish) { + clear(); + return this->_M_finish; + } + else { + if (__first == __last) + return __first; + return _M_erase(__first, __last, _Movable()); + } + } + void clear(); + +protected: // Internal construction/destruction + + void _M_fill_initialize(const value_type& __val, const __true_type& /*_TrivialInit*/) + {} + void _M_fill_initialize(const value_type& __val, const __false_type& /*_TrivialInit*/); + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_range_initialize(_InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + this->_M_initialize_map(0); + _STLP_TRY { + for ( ; __first != __last; ++__first) + push_back(*__first); + } + _STLP_UNWIND(clear()) + } + template + void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + size_type __n = _STLP_STD::distance(__first, __last); + this->_M_initialize_map(__n); + _Map_pointer __cur_node = this->_M_start._M_node; + _STLP_TRY { + for (; __cur_node < this->_M_finish._M_node; ++__cur_node) { + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, this->buffer_size()); + _STLP_STD::uninitialized_copy(__first, __mid, *__cur_node); + __first = __mid; + } + _STLP_STD::uninitialized_copy(__first, __last, this->_M_finish._M_first); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(this->_M_start, iterator(*__cur_node, __cur_node))) + } +#endif /* _STLP_MEMBER_TEMPLATES */ + +protected: // Internal push_* and pop_* + + void _M_push_back_aux_v(const value_type&); + void _M_push_front_aux_v(const value_type&); +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void _M_push_back_aux(); + void _M_push_front_aux(); +#endif /*_STLP_DONT_SUP_DFLT_PARAM !_STLP_NO_ANACHRONISMS*/ + void _M_pop_back_aux(); + void _M_pop_front_aux(); + +protected: // Internal insert functions + +#if defined (_STLP_MEMBER_TEMPLATES) + + template + void _M_insert(iterator __pos, + _InputIterator __first, + _InputIterator __last, + const input_iterator_tag &) { + _STLP_STD::copy(__first, __last, inserter(*this, __pos)); + } + + template + void _M_insert(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + size_type __n = _STLP_STD::distance(__first, __last); + if (__pos._M_cur == this->_M_start._M_cur) { + iterator __new_start = _M_reserve_elements_at_front(__n); + _STLP_TRY { + uninitialized_copy(__first, __last, __new_start); + this->_M_start = __new_start; + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else if (__pos._M_cur == this->_M_finish._M_cur) { + iterator __new_finish = _M_reserve_elements_at_back(__n); + _STLP_TRY { + uninitialized_copy(__first, __last, this->_M_finish); + this->_M_finish = __new_finish; + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } + else + _M_insert_range_aux(__pos, __first, __last, __n, _Movable()); + } + + template + void _M_insert_range_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + size_type __n, const __true_type& /*_Movable*/) { + const difference_type __elemsbefore = __pos - this->_M_start; + size_type __length = size(); + if (__elemsbefore <= difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + __pos = this->_M_start + __elemsbefore; + _STLP_TRY { + iterator __dst = __new_start; + iterator __src = this->_M_start; + for (; __src != __pos; ++__dst, ++__src) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_start = __new_start; + uninitialized_copy(__first, __last, __dst); + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + const difference_type __elemsafter = difference_type(__length) - __elemsbefore; + __pos = this->_M_finish - __elemsafter; + _STLP_TRY { + iterator __dst = __new_finish; + iterator __src = this->_M_finish; + for (--__src, --__dst; __src >= __pos; --__src, --__dst) { + _STLP_STD::_Move_Construct(&(*__dst), *__src); + _STLP_STD::_Destroy_Moved(&(*__src)); + } + this->_M_finish = __new_finish; + uninitialized_copy(__first, __last, __pos); + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } + } + + template + void _M_insert_range_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + size_type __n, const __false_type& /*_Movable*/) { + const difference_type __elemsbefore = __pos - this->_M_start; + size_type __length = size(); + if (__elemsbefore <= difference_type(__length / 2)) { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_start; + __pos = this->_M_start + __elemsbefore; + _STLP_TRY { + if (__elemsbefore >= difference_type(__n)) { + iterator __start_n = this->_M_start + difference_type(__n); + _STLP_STD::uninitialized_copy(this->_M_start, __start_n, __new_start); + this->_M_start = __new_start; + _STLP_STD::copy(__start_n, __pos, __old_start); + _STLP_STD::copy(__first, __last, __pos - difference_type(__n)); + } + else { + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, difference_type(__n) - __elemsbefore); + _STLP_PRIV __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid, __new_start); + this->_M_start = __new_start; + _STLP_STD::copy(__mid, __last, __old_start); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node)) + } + else { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_finish; + const difference_type __elemsafter = difference_type(__length) - __elemsbefore; + __pos = this->_M_finish - __elemsafter; + _STLP_TRY { + if (__elemsafter > difference_type(__n)) { + iterator __finish_n = this->_M_finish - difference_type(__n); + _STLP_STD::uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; + _STLP_STD::copy_backward(__pos, __finish_n, __old_finish); + _STLP_STD::copy(__first, __last, __pos); + } + else { + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, __elemsafter); + _STLP_PRIV __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; + _STLP_STD::copy(__first, __mid, __pos); + } + } + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1)) + } + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + iterator _M_reserve_elements_at_front(size_type __n) { + size_type __vacancies = this->_M_start._M_cur - this->_M_start._M_first; + if (__n > __vacancies) + _M_new_elements_at_front(__n - __vacancies); + return this->_M_start - difference_type(__n); + } + + iterator _M_reserve_elements_at_back(size_type __n) { + size_type __vacancies = (this->_M_finish._M_last - this->_M_finish._M_cur) - 1; + if (__n > __vacancies) + _M_new_elements_at_back(__n - __vacancies); + return this->_M_finish + difference_type(__n); + } + + void _M_new_elements_at_front(size_type __new_elements); + void _M_new_elements_at_back(size_type __new_elements); + +protected: // Allocation of _M_map and nodes + + // Makes sure the _M_map has space for new nodes. Does not actually + // add the nodes. Can invalidate _M_map pointers. (And consequently, + // deque iterators.) + + void _M_reserve_map_at_back (size_type __nodes_to_add = 1) { + if (__nodes_to_add + 1 > this->_M_map_size._M_data - (this->_M_finish._M_node - this->_M_map._M_data)) + _M_reallocate_map(__nodes_to_add, false); + } + + void _M_reserve_map_at_front (size_type __nodes_to_add = 1) { + if (__nodes_to_add > size_type(this->_M_start._M_node - this->_M_map._M_data)) + _M_reallocate_map(__nodes_to_add, true); + } + + void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front); +}; + +#if defined (deque) +# undef deque +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# include +#endif + +#if defined (_STLP_DEBUG) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#define _STLP_TEMPLATE_CONTAINER deque<_Tp, _Alloc> +#define _STLP_TEMPLATE_HEADER template +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > { + typedef __true_type implemented; + typedef typename __move_traits<_Alloc>::complete complete; +}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_DEQUE_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_epilog.h b/sdk/tlibstdcxx/stlport/stl/_epilog.h new file mode 100644 index 0000000000..0747ae3204 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_epilog.h @@ -0,0 +1,42 @@ +/* NOTE : this header has no guards and is MEANT for multiple inclusion! + * If you are using "header protection" option with your compiler, + * please also find #pragma which disables it and put it here, to + * allow reentrancy of this header. + */ + +#ifndef _STLP_PROLOG_HEADER_INCLUDED +# error STLport epilog header can not be included as long as prolog has not be included. +#endif + +/* If the platform provides any specific epilog actions, + * like #pragmas, do include platform-specific prolog file + */ +#if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) +# include +#endif + +#if !defined (_STLP_NO_POST_COMPATIBLE_SECTION) +# include +#endif + +#if defined (_STLP_USE_OWN_NAMESPACE) + +# if !defined (_STLP_DONT_REDEFINE_STD) +/* We redefine "std" to STLPORT, so that user code may use std:: transparently + * The STLPORT macro contains the STLport namespace name containing all the std + * stuff. + */ +# if defined (std) +/* + * Looks like the compiler native library on which STLport rely defined the std macro. + * This might introduce major incompatibility so report the problem to the STLport + * forum or comment the following #error at your own risk. + */ +# error Incompatible native Std library. +# endif /* std */ +# define std STLPORT +# endif /* _STLP_DONT_REDEFINE_STD */ + +#endif + +#undef _STLP_PROLOG_HEADER_INCLUDED /* defined in _prolog.h */ diff --git a/sdk/tlibstdcxx/stlport/stl/_exception.h b/sdk/tlibstdcxx/stlport/stl/_exception.h new file mode 100644 index 0000000000..5432ba943b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_exception.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +// The header contains low-level functions that interact +// with a compiler's exception-handling mechanism. It is assumed to +// be supplied with the compiler, rather than with the library, because +// it is inherently tied very closely to the compiler itself. + +// On platforms where does not exist, this header defines +// an exception base class. This is *not* a substitute for everything +// in , but it suffices to support a bare minimum of STL +// functionality. + +#ifndef _STLP_INTERNAL_EXCEPTION +#define _STLP_INTERNAL_EXCEPTION + +#if !defined (_STLP_NO_EXCEPTION_HEADER) + +# if defined ( _UNCAUGHT_EXCEPTION ) +# undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT +# endif + +# if defined (_STLP_BROKEN_EXCEPTION_CLASS) +# define exception _STLP_NULLIFIED_BROKEN_EXCEPTION_CLASS +# define bad_exception _STLP_NULLIFIED_BROKEN_BAD_EXCEPTION_CLASS +# if defined (_STLP_NO_NEW_NEW_HEADER) +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception.h) +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception) +# endif +# undef exception +# undef bad_exception +# else +# if defined (_STLP_NO_NEW_NEW_HEADER) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h) +# endif +# else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception) +# endif +# endif +# endif + +# if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) && defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1300) +// dwa 02/04/00 +// The header which ships with vc6 and is included by its native +// actually turns on warnings, so we have to turn them back off. +# include +# endif + +# if defined (_STLP_USE_OWN_NAMESPACE) + +_STLP_BEGIN_NAMESPACE +# if !defined (_STLP_BROKEN_EXCEPTION_CLASS) +# if !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_WIN64) +using _STLP_VENDOR_EXCEPT_STD::exception; +# else +using ::exception; +# endif +using _STLP_VENDOR_EXCEPT_STD::bad_alloc; +using _STLP_VENDOR_EXCEPT_STD::bad_exception; +# endif + +# if !defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS) +// fbp : many platforms present strange mix of +// those in various namespaces +# if !defined (_STLP_VENDOR_UNEXPECTED_STD) +# define _STLP_VENDOR_UNEXPECTED_STD _STLP_VENDOR_EXCEPT_STD +# else +/* The following definitions are for backward compatibility as _STLP_VENDOR_TERMINATE_STD + * and _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD has been introduce after _STLP_VENDOR_UNEXPECTED_STD + * and _STLP_VENDOR_UNEXPECTED_STD was the macro used in their place before that introduction. + */ +# if !defined (_STLP_VENDOR_TERMINATE_STD) +# define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_UNEXPECTED_STD +# endif +# if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD) +# define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_UNEXPECTED_STD +# endif +# endif +# if !defined (_STLP_VENDOR_TERMINATE_STD) +# define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD +# endif +# if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD) +# define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD +# endif +# if !defined (_STLP_VENDOR_TERMINATE_STD) +# define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD +# endif +# if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD) +# define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD +# endif +// weird errors +# if !defined (_STLP_NO_UNEXPECTED_EXCEPT_SUPPORT) +# if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300) +//See config/_intel.h for reason about this workaround +using std::unexpected; +# else +using _STLP_VENDOR_UNEXPECTED_STD::unexpected; +# endif +using _STLP_VENDOR_UNEXPECTED_STD::unexpected_handler; +using _STLP_VENDOR_UNEXPECTED_STD::set_unexpected; +# endif +using _STLP_VENDOR_TERMINATE_STD::terminate; +using _STLP_VENDOR_TERMINATE_STD::terminate_handler; +using _STLP_VENDOR_TERMINATE_STD::set_terminate; + +# if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) +using _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD::uncaught_exception; +# endif +# endif /* !_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS */ +_STLP_END_NAMESPACE +# endif /* _STLP_OWN_NAMESPACE */ +#else /* _STLP_NO_EXCEPTION_HEADER */ + +/* fbp : absence of usually means that those + * functions are not going to be called by compiler. + * Still, define them for the user. + * dums: Policy modification, if the function do not behave like the Standard + * defined it we do not grant it in the STLport namespace. We will have + * compile time error rather than runtime error. + */ +#if 0 +/* +typedef void (*unexpected_handler)(); +unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY; +void unexpected(); + +typedef void (*terminate_handler)(); +terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY; +void terminate(); + +bool uncaught_exception(); // not implemented under mpw as of Jan/1999 +*/ +#endif + +#endif /* _STLP_NO_EXCEPTION_HEADER */ + +#if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS) +_STLP_BEGIN_NAMESPACE + +// section 18.6.1 +class _STLP_CLASS_DECLSPEC exception { +public: +# ifndef _STLP_USE_NO_IOSTREAMS + exception() _STLP_NOTHROW; + virtual ~exception() _STLP_NOTHROW; + virtual const char* what() const _STLP_NOTHROW; +# else + exception() _STLP_NOTHROW {} + virtual ~exception() _STLP_NOTHROW {} + virtual const char* what() const _STLP_NOTHROW {return "class exception";} +# endif +}; + +// section 18.6.2.1 +class _STLP_CLASS_DECLSPEC bad_exception : public exception { +public: +# ifndef _STLP_USE_NO_IOSTREAMS + bad_exception() _STLP_NOTHROW; + ~bad_exception() _STLP_NOTHROW; + const char* what() const _STLP_NOTHROW; +# else + bad_exception() _STLP_NOTHROW {} + ~bad_exception() _STLP_NOTHROW {} + const char* what() const _STLP_NOTHROW {return "class bad_exception";} +# endif +}; + +// forward declaration +class __Named_exception; +_STLP_END_NAMESPACE +#endif + +#endif /* _STLP_INTERNAL_EXCEPTION */ diff --git a/sdk/tlibstdcxx/stlport/stl/_facets_fwd.h b/sdk/tlibstdcxx/stlport/stl/_facets_fwd.h new file mode 100644 index 0000000000..d4c8451f53 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_facets_fwd.h @@ -0,0 +1,53 @@ +#ifndef _STLP_FACETS_FWD_H +#define _STLP_FACETS_FWD_H + + +#include + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class money_get; + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class money_put; + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class num_get; + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class num_put; + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class time_get; + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class time_put; + +_STLP_END_NAMESPACE + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_fstream.c b/sdk/tlibstdcxx/stlport/stl/_fstream.c new file mode 100644 index 0000000000..f1548ae6a3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_fstream.c @@ -0,0 +1,766 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_FSTREAM_C +#define _STLP_FSTREAM_C + +#ifndef _STLP_INTERNAL_FSTREAM_H +# include +#endif + +#ifndef _STLP_INTERNAL_LIMITS +# include +#endif + +_STLP_BEGIN_NAMESPACE + +# if defined ( _STLP_NESTED_TYPE_PARAM_BUG ) +// no wchar_t is supported for this mode +# define __BF_int_type__ int +# define __BF_pos_type__ streampos +# define __BF_off_type__ streamoff +# else +# define __BF_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::int_type +# define __BF_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::pos_type +# define __BF_off_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::off_type +# endif + + +//---------------------------------------------------------------------- +// Public basic_filebuf<> member functions + +template +basic_filebuf<_CharT, _Traits>::basic_filebuf() + : basic_streambuf<_CharT, _Traits>(), _M_base(), + _M_constant_width(false), _M_always_noconv(false), + _M_int_buf_dynamic(false), + _M_in_input_mode(false), _M_in_output_mode(false), + _M_in_error_mode(false), _M_in_putback_mode(false), + _M_int_buf(0), _M_int_buf_EOS(0), + _M_ext_buf(0), _M_ext_buf_EOS(0), + _M_ext_buf_converted(0), _M_ext_buf_end(0), + _M_state(_STLP_DEFAULT_CONSTRUCTED(_State_type)), + _M_end_state(_STLP_DEFAULT_CONSTRUCTED(_State_type)), + _M_mmap_base(0), _M_mmap_len(0), + _M_saved_eback(0), _M_saved_gptr(0), _M_saved_egptr(0), + _M_codecvt(0), + _M_width(1), _M_max_width(1) +{ + this->_M_setup_codecvt(locale(), false); +} + +template +basic_filebuf<_CharT, _Traits>::~basic_filebuf() { + this->close(); + _M_deallocate_buffers(); +} + + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::int_type +basic_filebuf<_CharT, _Traits>::underflow() { + return _Underflow<_CharT, _Traits>::_M_doit(this); +} + +template +basic_filebuf<_CharT, _Traits>* +basic_filebuf<_CharT, _Traits>::close() { + bool __ok = this->is_open(); + + if (_M_in_output_mode) { + __ok = __ok && !_Traits::eq_int_type(this->overflow(traits_type::eof()), + traits_type::eof()); + __ok == __ok && this->_M_unshift(); + } + else if (_M_in_input_mode) + this->_M_exit_input_mode(); + + // Note order of arguments. We close the file even if __ok is false. + __ok = _M_base._M_close() && __ok; + + // Restore the initial state, except that we don't deallocate the buffer + // or mess with the cached codecvt information. + _M_state = _M_end_state = _State_type(); + _M_ext_buf_converted = _M_ext_buf_end = 0; + + _M_mmap_base = 0; + _M_mmap_len = 0; + + this->setg(0, 0, 0); + this->setp(0, 0); + + _M_saved_eback = _M_saved_gptr = _M_saved_egptr = 0; + + _M_in_input_mode = _M_in_output_mode = _M_in_error_mode = _M_in_putback_mode + = false; + + return __ok ? this : 0; +} + +// This member function is called whenever we exit input mode. +// It unmaps the memory-mapped file, if any, and sets +// _M_in_input_mode to false. +template +void basic_filebuf<_CharT, _Traits>::_M_exit_input_mode() { + if (_M_mmap_base != 0) { + _M_base._M_unmap(_M_mmap_base, _M_mmap_len); + _M_mmap_base = 0; + _M_mmap_len = 0; + } + _M_in_input_mode = false; +} + + +//---------------------------------------------------------------------- +// basic_filebuf<> overridden protected virtual member functions + +template +streamsize basic_filebuf<_CharT, _Traits>::showmanyc() { + // Is there any possibility that reads can succeed? + if (!this->is_open() || _M_in_output_mode || _M_in_error_mode) + return -1; + else if (_M_in_putback_mode) + return this->egptr() - this->gptr(); + else if (_M_constant_width) { + streamoff __pos = _M_base._M_seek(0, ios_base::cur); + streamoff __size = _M_base._M_file_size(); + return __pos >= 0 && __size > __pos ? __size - __pos : 0; + } + else + return 0; +} + + +// Make a putback position available, if necessary, by switching to a +// special internal buffer used only for putback. The buffer is +// [_M_pback_buf, _M_pback_buf + _S_pback_buf_size), but the base +// class only sees a piece of it at a time. (We want to make sure +// that we don't try to read a character that hasn't been initialized.) +// The end of the putback buffer is always _M_pback_buf + _S_pback_buf_size, +// but the beginning is usually not _M_pback_buf. +template +__BF_int_type__ +basic_filebuf<_CharT, _Traits>::pbackfail(int_type __c) { + const int_type __eof = traits_type::eof(); + + // If we aren't already in input mode, pushback is impossible. + if (!_M_in_input_mode) + return __eof; + + // We can use the ordinary get buffer if there's enough space, and + // if it's a buffer that we're allowed to write to. + if (this->gptr() != this->eback() && + (traits_type::eq_int_type(__c, __eof) || + traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]) || + !_M_mmap_base)) { + this->gbump(-1); + if (traits_type::eq_int_type(__c, __eof) || + traits_type::eq(traits_type::to_char_type(__c), *this->gptr())) + return traits_type::to_int_type(*this->gptr()); + } + else if (!traits_type::eq_int_type(__c, __eof)) { + // Are we in the putback buffer already? + _CharT* __pback_end = _M_pback_buf + __STATIC_CAST(int,_S_pback_buf_size); + if (_M_in_putback_mode) { + // Do we have more room in the putback buffer? + if (this->eback() != _M_pback_buf) + this->setg(this->egptr() - 1, this->egptr() - 1, __pback_end); + else + return __eof; // No more room in the buffer, so fail. + } + else { // We're not yet in the putback buffer. + _M_saved_eback = this->eback(); + _M_saved_gptr = this->gptr(); + _M_saved_egptr = this->egptr(); + this->setg(__pback_end - 1, __pback_end - 1, __pback_end); + _M_in_putback_mode = true; + } + } + else + return __eof; + + // We have made a putback position available. Assign to it, and return. + *this->gptr() = traits_type::to_char_type(__c); + return __c; +} + +// This member function flushes the put area, and also outputs the +// character __c (unless __c is eof). Invariant: we always leave room +// in the internal buffer for one character more than the base class knows +// about. We see the internal buffer as [_M_int_buf, _M_int_buf_EOS), but +// the base class only sees [_M_int_buf, _M_int_buf_EOS - 1). +template +__BF_int_type__ +basic_filebuf<_CharT, _Traits>::overflow(int_type __c) { + // Switch to output mode, if necessary. + if (!_M_in_output_mode) + if (!_M_switch_to_output_mode()) + return traits_type::eof(); + + _CharT* __ibegin = this->_M_int_buf; + _CharT* __iend = this->pptr(); + this->setp(_M_int_buf, _M_int_buf_EOS - 1); + + // Put __c at the end of the internal buffer. + if (!traits_type::eq_int_type(__c, traits_type::eof())) + *__iend++ = _Traits::to_char_type(__c); + + // For variable-width encodings, output may take more than one pass. + while (__ibegin != __iend) { + const _CharT* __inext = __ibegin; + char* __enext = _M_ext_buf; + typename _Codecvt::result __status + = _M_codecvt->out(_M_state, __ibegin, __iend, __inext, + _M_ext_buf, _M_ext_buf_EOS, __enext); + if (__status == _Codecvt::noconv) { + return _Noconv_output<_Traits>::_M_doit(this, __ibegin, __iend) + ? traits_type::not_eof(__c) + : _M_output_error(); + } + + // For a constant-width encoding we know that the external buffer + // is large enough, so failure to consume the entire internal buffer + // or to produce the correct number of external characters, is an error. + // For a variable-width encoding, however, we require only that we + // consume at least one internal character + else if (__status != _Codecvt::error && + (((__inext == __iend) && + (__enext - _M_ext_buf == _M_width * (__iend - __ibegin))) || + (!_M_constant_width && __inext != __ibegin))) { + // We successfully converted part or all of the internal buffer. + ptrdiff_t __n = __enext - _M_ext_buf; + if (_M_write(_M_ext_buf, __n)) + __ibegin += __inext - __ibegin; + else + return _M_output_error(); + } + else + return _M_output_error(); + } + + return traits_type::not_eof(__c); +} + +// This member function must be called before any I/O has been +// performed on the stream, otherwise it has no effect. +// +// __buf == 0 && __n == 0 means to make this stream unbuffered. +// __buf != 0 && __n > 0 means to use __buf as the stream's internal +// buffer, rather than the buffer that would otherwise be allocated +// automatically. __buf must be a pointer to an array of _CharT whose +// size is at least __n. +template +basic_streambuf<_CharT, _Traits>* +basic_filebuf<_CharT, _Traits>::setbuf(_CharT* __buf, streamsize __n) { + if (!_M_in_input_mode &&! _M_in_output_mode && !_M_in_error_mode && + _M_int_buf == 0) { + if (__buf == 0 && __n == 0) + _M_allocate_buffers(0, 1); + else if (__buf != 0 && __n > 0) + _M_allocate_buffers(__buf, __n); + } + return this; +} + +#if defined (_STLP_ASSERTIONS) +// helper class. +template +struct _Filebuf_Tmp_Buf { + _CharT* _M_ptr; + _Filebuf_Tmp_Buf(ptrdiff_t __n) : _M_ptr(0) { _M_ptr = new _CharT[__n]; } + ~_Filebuf_Tmp_Buf() { delete[] _M_ptr; } +}; +#endif + +template +__BF_pos_type__ +basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, + ios_base::seekdir __whence, + ios_base::openmode /* dummy */) { + if (!this->is_open()) + return pos_type(-1); + + if (!_M_constant_width && __off != 0) + return pos_type(-1); + + if (!_M_seek_init(__off != 0 || __whence != ios_base::cur)) + return pos_type(-1); + + // Seek to beginning or end, regardless of whether we're in input mode. + if (__whence == ios_base::beg || __whence == ios_base::end) + return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence), + _State_type()); + + // Seek relative to current position. Complicated if we're in input mode. + _STLP_ASSERT(__whence == ios_base::cur) + if (!_M_in_input_mode) + return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence), + _State_type()); + + if (_M_mmap_base != 0) { + // __off is relative to gptr(). We need to do a bit of arithmetic + // to get an offset relative to the external file pointer. + streamoff __adjust = _M_mmap_len - (this->gptr() - (_CharT*) _M_mmap_base); + + // if __off == 0, we do not need to exit input mode and to shift file pointer + return __off == 0 ? pos_type(_M_base._M_seek(0, ios_base::cur) - __adjust) + : _M_seek_return(_M_base._M_seek(__off - __adjust, ios_base::cur), _State_type()); + } + + if (_M_constant_width) { // Get or set the position. + streamoff __iadj = _M_width * (this->gptr() - this->eback()); + + // Compensate for offset relative to gptr versus offset relative + // to external pointer. For a text-oriented stream, where the + // compensation is more than just pointer arithmetic, we may get + // but not set the current position. + + if (__iadj <= _M_ext_buf_end - _M_ext_buf) { + streamoff __eadj = _M_base._M_get_offset(_M_ext_buf + __STATIC_CAST(ptrdiff_t, __iadj), _M_ext_buf_end); + + return __off == 0 ? pos_type(_M_base._M_seek(0, ios_base::cur) - __eadj) + : _M_seek_return(_M_base._M_seek(__off - __eadj, ios_base::cur), _State_type()); + } + } + else { // Get the position. Encoding is var width. + // Get position in internal buffer. + ptrdiff_t __ipos = this->gptr() - this->eback(); + + // Get corresponding position in external buffer. + _State_type __state = _M_state; + int __epos = _M_codecvt->length(__state, _M_ext_buf, _M_ext_buf_converted, + __ipos); +#if defined (_STLP_ASSERTIONS) + // Sanity check (expensive): make sure __epos is the right answer. + _STLP_ASSERT(__epos >= 0) + _State_type __tmp_state = _M_state; + _Filebuf_Tmp_Buf<_CharT> __buf(__ipos); + _CharT* __ibegin = __buf._M_ptr; + _CharT* __inext = __ibegin; + const char* __dummy; + typename _Codecvt::result __status + = _M_codecvt->in(__tmp_state, + _M_ext_buf, _M_ext_buf + __epos, __dummy, + __ibegin, __ibegin + __ipos, __inext); + // The result code is necessarily ok because: + // - noconv: impossible for a variable encoding + // - error: length method is supposed to count until it reach max value or find an error so we cannot have + // an error again when decoding an external buffer up to length return value. + // - partial: idem error, it is also a reason for length to stop counting. + _STLP_ASSERT(__status == _Codecvt::ok) + _STLP_ASSERT(__inext == __ibegin + __ipos) + _STLP_ASSERT(equal(this->eback(), this->gptr(), __ibegin, _STLP_PRIV _Eq_traits())) +#endif + // Get the current position (at the end of the external buffer), + // then adjust it. Again, it might be a text-oriented stream. + streamoff __cur = _M_base._M_seek(0, ios_base::cur); + streamoff __adj = _M_base._M_get_offset(_M_ext_buf, _M_ext_buf + __epos) - + _M_base._M_get_offset(_M_ext_buf, _M_ext_buf_end); + if (__cur != -1 && __cur + __adj >= 0) + return __off == 0 ? pos_type(__cur + __adj) + : _M_seek_return(__cur + __adj, __state); + } + + return pos_type(-1); +} + + +template +__BF_pos_type__ +basic_filebuf<_CharT, _Traits>::seekpos(pos_type __pos, + ios_base::openmode /* dummy */) { + if (this->is_open()) { + if (!_M_seek_init(true)) + return pos_type(-1); + + streamoff __off = off_type(__pos); + if (__off != -1 && _M_base._M_seek(__off, ios_base::beg) != -1) { + _M_state = __pos.state(); + return _M_seek_return(__off, __pos.state()); + } + } + + return pos_type(-1); +} + + +template +int basic_filebuf<_CharT, _Traits>::sync() { + if (_M_in_output_mode) + return traits_type::eq_int_type(this->overflow(traits_type::eof()), + traits_type::eof()) ? -1 : 0; + return 0; +} + + +// Change the filebuf's locale. This member function has no effect +// unless it is called before any I/O is performed on the stream. +template +void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) { + if (!_M_in_input_mode && !_M_in_output_mode && !_M_in_error_mode) { + this->_M_setup_codecvt(__loc); + } +} + +//---------------------------------------------------------------------- +// basic_filebuf<> helper functions. + +//---------------------------------------- +// Helper functions for switching between modes. + +// This member function is called if we're performing the first I/O +// operation on a filebuf, or if we're performing an input operation +// immediately after a seek. +template +bool basic_filebuf<_CharT, _Traits>::_M_switch_to_input_mode() { + if (this->is_open() && (((int)_M_base.__o_mode() & (int)ios_base::in) !=0) + && (_M_in_output_mode == 0) && (_M_in_error_mode == 0)) { + if (!_M_int_buf && !_M_allocate_buffers()) + return false; + + _M_ext_buf_converted = _M_ext_buf; + _M_ext_buf_end = _M_ext_buf; + + _M_end_state = _M_state; + + _M_in_input_mode = true; + return true; + } + + return false; +} + + +// This member function is called if we're performing the first I/O +// operation on a filebuf, or if we're performing an output operation +// immediately after a seek. +template +bool basic_filebuf<_CharT, _Traits>::_M_switch_to_output_mode() { + if (this->is_open() && (_M_base.__o_mode() & (int)ios_base::out) && + _M_in_input_mode == 0 && _M_in_error_mode == 0) { + + if (!_M_int_buf && !_M_allocate_buffers()) + return false; + + // In append mode, every write does an implicit seek to the end + // of the file. Whenever leaving output mode, the end of file + // get put in the initial shift state. + if (_M_base.__o_mode() & ios_base::app) + _M_state = _State_type(); + + this->setp(_M_int_buf, _M_int_buf_EOS - 1); + _M_in_output_mode = true; + return true; + } + + return false; +} + + +//---------------------------------------- +// Helper functions for input + +// This member function is called if there is an error during input. +// It puts the filebuf in error mode, clear the get area buffer, and +// returns eof. +// returns eof. Error mode is sticky; it is cleared only by close or +// seek. + +template +__BF_int_type__ +basic_filebuf<_CharT, _Traits>::_M_input_error() { + this->_M_exit_input_mode(); + _M_in_output_mode = false; + _M_in_error_mode = true; + this->setg(0, 0, 0); + return traits_type::eof(); +} + +template +__BF_int_type__ +basic_filebuf<_CharT, _Traits>::_M_underflow_aux() { + // We have the state and file position from the end of the internal + // buffer. This round, they become the beginning of the internal buffer. + _M_state = _M_end_state; + + // Fill the external buffer. Start with any leftover characters that + // didn't get converted last time. + if (_M_ext_buf_end > _M_ext_buf_converted) + + _M_ext_buf_end = _STLP_STD::copy(_M_ext_buf_converted, _M_ext_buf_end, _M_ext_buf); + // boris : copy_backward did not work + //_M_ext_buf_end = copy_backward(_M_ext_buf_converted, _M_ext_buf_end, + //_M_ext_buf+ (_M_ext_buf_end - _M_ext_buf_converted)); + else + _M_ext_buf_end = _M_ext_buf; + + // Now fill the external buffer with characters from the file. This is + // a loop because occasionally we don't get enough external characters + // to make progress. + for (;;) { + ptrdiff_t __n = _M_base._M_read(_M_ext_buf_end, _M_ext_buf_EOS - _M_ext_buf_end); + if (__n < 0) { + // Read failed, maybe we should set err bit on associated stream... + this->setg(0, 0, 0); + return traits_type::eof(); + } + + _M_ext_buf_end += __n; + + // If external buffer is empty there is nothing to do. + if (_M_ext_buf == _M_ext_buf_end) { + this->setg(0, 0, 0); + return traits_type::eof(); + } + + // Convert the external buffer to internal characters. + const char* __enext; + _CharT* __inext; + + typename _Codecvt::result __status + = _M_codecvt->in(_M_end_state, + _M_ext_buf, _M_ext_buf_end, __enext, + _M_int_buf, _M_int_buf_EOS, __inext); + + /* Error conditions: + * (1) Return value of error. + * (2) Producing internal characters without consuming external characters. + * (3) In fixed-width encodings, producing an internal sequence whose length + * is inconsistent with that of the internal sequence. + * (4) Failure to produce any characters if we have enough characters in + * the external buffer, where "enough" means the largest possible width + * of a single character. */ + if (__status == _Codecvt::noconv) + return _Noconv_input<_Traits>::_M_doit(this); + else if (__status == _Codecvt::error || + (__inext != _M_int_buf && __enext == _M_ext_buf) || + (_M_constant_width && (__inext - _M_int_buf) * _M_width != (__enext - _M_ext_buf)) || + (__inext == _M_int_buf && __enext - _M_ext_buf >= _M_max_width)) + return _M_input_error(); + else if (__inext != _M_int_buf) { + _M_ext_buf_converted = _M_ext_buf + (__enext - _M_ext_buf); + this->setg(_M_int_buf, _M_int_buf, __inext); + return traits_type::to_int_type(*_M_int_buf); + } + /* We need to go around the loop again to get more external characters. + * But if the previous read failed then don't try again for now. + * Don't enter error mode for a failed read. Error mode is sticky, + * and we might succeed if we try again. */ + if (__n <= 0) { + this->setg(0, 0, 0); + return traits_type::eof(); + } + } +} + +//---------------------------------------- +// Helper functions for output + +// This member function is called if there is an error during output. +// It puts the filebuf in error mode, clear the put area buffer, and +// returns eof. Error mode is sticky; it is cleared only by close or +// seek. +template +__BF_int_type__ +basic_filebuf<_CharT, _Traits>::_M_output_error() { + _M_in_output_mode = false; + _M_in_input_mode = false; + _M_in_error_mode = true; + this->setp(0, 0); + return traits_type::eof(); +} + + +// Write whatever sequence of characters is necessary to get back to +// the initial shift state. This function overwrites the external +// buffer, changes the external file position, and changes the state. +// Precondition: the internal buffer is empty. +template +bool basic_filebuf<_CharT, _Traits>::_M_unshift() { + if (_M_in_output_mode && !_M_constant_width) { + typename _Codecvt::result __status; + do { + char* __enext = _M_ext_buf; + __status = _M_codecvt->unshift(_M_state, + _M_ext_buf, _M_ext_buf_EOS, __enext); + if (__status == _Codecvt::noconv || + (__enext == _M_ext_buf && __status == _Codecvt::ok)) + return true; + else if (__status == _Codecvt::error) + return false; + else if (!_M_write(_M_ext_buf, __enext - _M_ext_buf)) + return false; + } while (__status == _Codecvt::partial); + } + + return true; +} + + +//---------------------------------------- +// Helper functions for buffer allocation and deallocation + +// This member function is called when we're initializing a filebuf's +// internal and external buffers. The argument is the size of the +// internal buffer; the external buffer is sized using the character +// width in the current encoding. Preconditions: the buffers are currently +// null. __n >= 1. __buf is either a null pointer or a pointer to an +// array show size is at least __n. + +// We need __n >= 1 for two different reasons. For input, the base +// class always needs a buffer because of the semantics of underflow(). +// For output, we want to have an internal buffer that's larger by one +// element than the buffer that the base class knows about. (See +// basic_filebuf<>::overflow() for the reason.) +template +bool basic_filebuf<_CharT, _Traits>::_M_allocate_buffers(_CharT* __buf, streamsize __n) { + //The major hypothesis in the following implementation is that size_t is unsigned. + //We also need streamsize byte representation to be larger or equal to the int + //representation to correctly store the encoding information. + _STLP_STATIC_ASSERT(!numeric_limits::is_signed && + sizeof(streamsize) >= sizeof(int)) + + if (__buf == 0) { + streamsize __bufsize = __n * sizeof(_CharT); + //We first check that the streamsize representation can't overflow a size_t one. + //If it can, we check that __bufsize is not higher than the size_t max value. + if ((sizeof(streamsize) > sizeof(size_t)) && + (__bufsize > __STATIC_CAST(streamsize, (numeric_limits::max)()))) + return false; + _M_int_buf = __STATIC_CAST(_CharT*, malloc(__STATIC_CAST(size_t, __bufsize))); + if (!_M_int_buf) + return false; + _M_int_buf_dynamic = true; + } + else { + _M_int_buf = __buf; + _M_int_buf_dynamic = false; + } + + streamsize __ebufsiz = (max)(__n * __STATIC_CAST(streamsize, _M_width), + __STATIC_CAST(streamsize, _M_codecvt->max_length())); + + _M_ext_buf = 0; + if ((sizeof(streamsize) < sizeof(size_t)) || + ((sizeof(streamsize) == sizeof(size_t)) && numeric_limits::is_signed) || + (__ebufsiz <= __STATIC_CAST(streamsize, (numeric_limits::max)()))) { + _M_ext_buf = __STATIC_CAST(char*, malloc(__STATIC_CAST(size_t, __ebufsiz))); + } + + if (!_M_ext_buf) { + _M_deallocate_buffers(); + return false; + } + + _M_int_buf_EOS = _M_int_buf + __STATIC_CAST(ptrdiff_t, __n); + _M_ext_buf_EOS = _M_ext_buf + __STATIC_CAST(ptrdiff_t, __ebufsiz); + return true; +} + +// Abbreviation for the most common case. +template +bool basic_filebuf<_CharT, _Traits>::_M_allocate_buffers() { + // Choose a buffer that's at least 4096 characters long and that's a + // multiple of the page size. + streamsize __default_bufsiz = + ((_M_base.__page_size() + 4095UL) / _M_base.__page_size()) * _M_base.__page_size(); + return _M_allocate_buffers(0, __default_bufsiz); +} + +template +void basic_filebuf<_CharT, _Traits>::_M_deallocate_buffers() { + if (_M_int_buf_dynamic) + free(_M_int_buf); + free(_M_ext_buf); + _M_int_buf = 0; + _M_int_buf_EOS = 0; + _M_ext_buf = 0; + _M_ext_buf_EOS = 0; +} + + +//---------------------------------------- +// Helper functiosn for seek and imbue + +template +bool basic_filebuf<_CharT, _Traits>::_M_seek_init(bool __do_unshift) { + // If we're in error mode, leave it. + _M_in_error_mode = false; + + // Flush the output buffer if we're in output mode, and (conditionally) + // emit an unshift sequence. + if (_M_in_output_mode) { + bool __ok = !traits_type::eq_int_type(this->overflow(traits_type::eof()), + traits_type::eof()); + if (__do_unshift) + __ok = __ok && this->_M_unshift(); + if (!__ok) { + _M_in_output_mode = false; + _M_in_error_mode = true; + this->setp(0, 0); + return false; + } + } + + // Discard putback characters, if any. + if (_M_in_input_mode && _M_in_putback_mode) + _M_exit_putback_mode(); + + return true; +} + + +/* Change the filebuf's locale. This member function has no effect + * unless it is called before any I/O is performed on the stream. + * This function is called on construction and on an imbue call. In the + * case of the construction the codecvt facet might be a custom one if + * the basic_filebuf user has instanciate it with a custom char_traits. + * The user will have to call imbue before any I/O operation. + */ +template +void basic_filebuf<_CharT, _Traits>::_M_setup_codecvt(const locale& __loc, bool __on_imbue) { + if (has_facet<_Codecvt>(__loc)) { + _M_codecvt = &use_facet<_Codecvt>(__loc) ; + int __encoding = _M_codecvt->encoding(); + + _M_width = (max)(__encoding, 1); + _M_max_width = _M_codecvt->max_length(); + _M_constant_width = __encoding > 0; + _M_always_noconv = _M_codecvt->always_noconv(); + } + else { + _M_codecvt = 0; + _M_width = _M_max_width = 1; + _M_constant_width = _M_always_noconv = false; + if (__on_imbue) { + //This call will generate an exception reporting the problem. + use_facet<_Codecvt>(__loc); + } + } +} + +_STLP_END_NAMESPACE + +# undef __BF_int_type__ +# undef __BF_pos_type__ +# undef __BF_off_type__ + +#endif /* _STLP_FSTREAM_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_fstream.h b/sdk/tlibstdcxx/stlport/stl/_fstream.h new file mode 100644 index 0000000000..1945e41188 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_fstream.h @@ -0,0 +1,714 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// This header defines classes basic_filebuf, basic_ifstream, +// basic_ofstream, and basic_fstream. These classes represent +// streambufs and streams whose sources or destinations are files. + +#ifndef _STLP_INTERNAL_FSTREAM_H +#define _STLP_INTERNAL_FSTREAM_H + +#if defined(__sgi) && !defined(__GNUC__) && !defined(_STANDARD_C_PLUS_PLUS) +# error This header file requires the -LANG:std option +#endif + +#ifndef _STLP_INTERNAL_STREAMBUF +# include +#endif + +#ifndef _STLP_INTERNAL_ISTREAM +# include +#endif + +#ifndef _STLP_INTERNAL_CODECVT_H +# include +#endif + +#if defined (_STLP_USE_WIN32_IO) +typedef void* _STLP_fd; +#elif defined (_STLP_USE_UNIX_EMULATION_IO) || defined (_STLP_USE_STDIO_IO) || defined (_STLP_USE_UNIX_IO) +typedef int _STLP_fd; +#else +# error "Configure i/o !" +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// Class _Filebuf_base, a private base class to factor out the system- +// dependent code from basic_filebuf<>. + +class _STLP_CLASS_DECLSPEC _Filebuf_base { +public: // Opening and closing files. + _Filebuf_base(); + + bool _M_open(const char*, ios_base::openmode, long __protection); + bool _M_open(const char*, ios_base::openmode); + bool _M_open(int __id, ios_base::openmode = ios_base::__default_mode); +#if defined (_STLP_USE_WIN32_IO) + bool _M_open(_STLP_fd __id, ios_base::openmode = ios_base::__default_mode); +#endif /* _STLP_USE_WIN32_IO */ + bool _M_close(); + +public: // Low-level I/O, like Unix read/write + ptrdiff_t _M_read(char* __buf, ptrdiff_t __n); + streamoff _M_seek(streamoff __offset, ios_base::seekdir __dir); + streamoff _M_file_size(); + bool _M_write(char* __buf, ptrdiff_t __n); + +public: // Memory-mapped I/O. + void* _M_mmap(streamoff __offset, streamoff __len); + void _M_unmap(void* __mmap_base, streamoff __len); + +public: + // Returns a value n such that, if pos is the file pointer at the + // beginning of the range [first, last), pos + n is the file pointer at + // the end. On many operating systems n == __last - __first. + // In Unix, writing n characters always bumps the file position by n. + // In Windows text mode, however, it bumps the file position by n + m, + // where m is the number of newlines in the range. That's because an + // internal \n corresponds to an external two-character sequence. + streamoff _M_get_offset(char* __first, char* __last) { +#if defined (_STLP_UNIX) || defined (_STLP_MAC) + return __last - __first; +#else // defined (_STLP_WIN32) + return ( (_M_openmode & ios_base::binary) != 0 ) + ? (__last - __first) + : count(__first, __last, '\n') + (__last - __first); +#endif + } + + // Returns true if we're in binary mode or if we're using an OS or file + // system where there is no distinction between text and binary mode. + bool _M_in_binary_mode() const { +#if defined (_STLP_UNIX) || defined (_STLP_MAC) || defined(__BEOS__) || defined (__amigaos__) + return true; +#elif defined (_STLP_WIN32) || defined (_STLP_VM) + return (_M_openmode & ios_base::binary) != 0; +#else +# error "Port!" +#endif + } + + static void _S_initialize(); + +protected: // Static data members. + static size_t _M_page_size; + +protected: // Data members. + _STLP_fd _M_file_id; +#if defined (_STLP_USE_STDIO_IO) + // for stdio, the whole FILE* is being kept here + FILE* _M_file; +#endif + ios_base::openmode _M_openmode ; + unsigned char _M_is_open ; + unsigned char _M_should_close ; + unsigned char _M_regular_file ; + +#if defined (_STLP_USE_WIN32_IO) + _STLP_fd _M_view_id; +#endif + +public : + static size_t _STLP_CALL __page_size() { return _M_page_size; } + int __o_mode() const { return (int)_M_openmode; } + bool __is_open() const { return (_M_is_open !=0 ); } + bool __should_close() const { return (_M_should_close != 0); } + bool __regular_file() const { return (_M_regular_file != 0); } + _STLP_fd __get_fd() const { return _M_file_id; } +}; + +//---------------------------------------------------------------------- +// Class basic_filebuf<>. + +// Forward declaration of two helper classes. +template class _Noconv_input; +template class _Noconv_output; + +// There is a specialized version of underflow, for basic_filebuf, +// in fstream.cpp. +template +class _Underflow; + +template +class basic_filebuf : public basic_streambuf<_CharT, _Traits> { +public: // Types. + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef typename _Traits::state_type _State_type; + typedef basic_streambuf<_CharT, _Traits> _Base; + typedef basic_filebuf<_CharT, _Traits> _Self; + +public: // Constructors, destructor. + basic_filebuf(); + ~basic_filebuf(); + +public: // Opening and closing files. + bool is_open() const { return _M_base.__is_open(); } + + _Self* open(const char* __s, ios_base::openmode __m) { + return _M_base._M_open(__s, __m) ? this : 0; + } + +#if !defined (_STLP_NO_EXTENSIONS) + // These two version of open() and file descriptor getter are extensions. + _Self* open(const char* __s, ios_base::openmode __m, + long __protection) { + return _M_base._M_open(__s, __m, __protection) ? this : 0; + } + + _STLP_fd fd() const { return _M_base.__get_fd(); } + + _Self* open(int __id, ios_base::openmode _Init_mode = ios_base::__default_mode) { + return this->_M_open(__id, _Init_mode); + } + +# if defined (_STLP_USE_WIN32_IO) + _Self* open(_STLP_fd __id, ios_base::openmode _Init_mode = ios_base::__default_mode) { + return _M_base._M_open(__id, _Init_mode) ? this : 0; + } +# endif /* _STLP_USE_WIN32_IO */ + +#endif + + _Self* _M_open(int __id, ios_base::openmode _Init_mode = ios_base::__default_mode) { + return _M_base._M_open(__id, _Init_mode) ? this : 0; + } + + _Self* close(); + +protected: // Virtual functions from basic_streambuf. + virtual streamsize showmanyc(); + virtual int_type underflow(); + + virtual int_type pbackfail(int_type = traits_type::eof()); + virtual int_type overflow(int_type = traits_type::eof()); + + virtual basic_streambuf<_CharT, _Traits>* setbuf(char_type*, streamsize); + virtual pos_type seekoff(off_type, ios_base::seekdir, + ios_base::openmode = ios_base::in | ios_base::out); + virtual pos_type seekpos(pos_type, + ios_base::openmode = ios_base::in | ios_base::out); + + virtual int sync(); + virtual void imbue(const locale&); + +private: // Helper functions. + + // Precondition: we are currently in putback input mode. Effect: + // switches back to ordinary input mode. + void _M_exit_putback_mode() { + this->setg(_M_saved_eback, _M_saved_gptr, _M_saved_egptr); + _M_in_putback_mode = false; + } + bool _M_switch_to_input_mode(); + void _M_exit_input_mode(); + bool _M_switch_to_output_mode(); + + int_type _M_input_error(); + int_type _M_underflow_aux(); + friend class _Underflow<_CharT, _Traits>; + + int_type _M_output_error(); + bool _M_unshift(); + + bool _M_allocate_buffers(_CharT* __buf, streamsize __n); + bool _M_allocate_buffers(); + void _M_deallocate_buffers(); + + pos_type _M_seek_return(off_type __off, _State_type __state) { + if (__off != -1) { + if (_M_in_input_mode) + _M_exit_input_mode(); + _M_in_input_mode = false; + _M_in_output_mode = false; + _M_in_putback_mode = false; + _M_in_error_mode = false; + this->setg(0, 0, 0); + this->setp(0, 0); + } + + pos_type __result(__off); + __result.state(__state); + return __result; + } + + bool _M_seek_init(bool __do_unshift); + + void _M_setup_codecvt(const locale&, bool __on_imbue = true); + +private: // Data members used in all modes. + + _Filebuf_base _M_base; + +private: // Locale-related information. + + unsigned char _M_constant_width; + unsigned char _M_always_noconv; + + // private: // Mode flags. + unsigned char _M_int_buf_dynamic; // True if internal buffer is heap allocated, + // false if it was supplied by the user. + unsigned char _M_in_input_mode; + unsigned char _M_in_output_mode; + unsigned char _M_in_error_mode; + unsigned char _M_in_putback_mode; + + // Internal buffer: characters seen by the filebuf's clients. + _CharT* _M_int_buf; + _CharT* _M_int_buf_EOS; + + // External buffer: characters corresponding to the external file. + char* _M_ext_buf; + char* _M_ext_buf_EOS; + + // The range [_M_ext_buf, _M_ext_buf_converted) contains the external + // characters corresponding to the sequence in the internal buffer. The + // range [_M_ext_buf_converted, _M_ext_buf_end) contains characters that + // have been read into the external buffer but have not been converted + // to an internal sequence. + char* _M_ext_buf_converted; + char* _M_ext_buf_end; + + // State corresponding to beginning of internal buffer. + _State_type _M_state; + +private: // Data members used only in input mode. + + // Similar to _M_state except that it corresponds to + // the end of the internal buffer instead of the beginning. + _State_type _M_end_state; + + // This is a null pointer unless we are in mmap input mode. + void* _M_mmap_base; + streamoff _M_mmap_len; + +private: // Data members used only in putback mode. + _CharT* _M_saved_eback; + _CharT* _M_saved_gptr; + _CharT* _M_saved_egptr; + + typedef codecvt<_CharT, char, _State_type> _Codecvt; + const _Codecvt* _M_codecvt; + + int _M_width; // Width of the encoding (if constant), else 1 + int _M_max_width; // Largest possible width of single character. + + + enum { _S_pback_buf_size = 8 }; + _CharT _M_pback_buf[_S_pback_buf_size]; + + // for _Noconv_output +public: + bool _M_write(char* __buf, ptrdiff_t __n) {return _M_base._M_write(__buf, __n); } + +public: + int_type + _M_do_noconv_input() { + _M_ext_buf_converted = _M_ext_buf_end; + /* this-> */ _Base::setg((char_type*)_M_ext_buf, (char_type*)_M_ext_buf, (char_type*)_M_ext_buf_end); + return traits_type::to_int_type(*_M_ext_buf); + } +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_filebuf >; +# if ! defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_filebuf >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +// +// This class had to be designed very carefully to work +// with Visual C++. +// +template +class _Noconv_output { +public: + typedef typename _Traits::char_type char_type; + static bool _STLP_CALL _M_doit(basic_filebuf*, + char_type*, char_type*) + { return false; } +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC _Noconv_output< char_traits > { +public: + static bool _STLP_CALL + _M_doit(basic_filebuf >* __buf, + char* __first, char* __last) { + ptrdiff_t __n = __last - __first; + return (__buf->_M_write(__first, __n)); + } +}; + +//---------------------------------------------------------------------- +// basic_filebuf<> helper functions. + + +//---------------------------------------- +// Helper functions for switching between modes. + +// +// This class had to be designed very carefully to work +// with Visual C++. +// +template +class _Noconv_input { +public: + typedef typename _Traits::int_type int_type; + typedef typename _Traits::char_type char_type; + + static inline int_type _STLP_CALL + _M_doit(basic_filebuf*) + { return _Traits::eof(); } +}; + +_STLP_TEMPLATE_NULL +class _Noconv_input > { +public: + static inline int _STLP_CALL + _M_doit(basic_filebuf >* __buf) { + return __buf->_M_do_noconv_input(); + } +}; + +// underflow() may be called for one of two reasons. (1) We've +// been going through the special putback buffer, and we need to move back +// to the regular internal buffer. (2) We've exhausted the internal buffer, +// and we need to replentish it. +template +class _Underflow { +public: + typedef typename _Traits::int_type int_type; + typedef _Traits traits_type; + + // There is a specialized version of underflow, for basic_filebuf, + // in fstream.cpp. + static int_type _STLP_CALL _M_doit(basic_filebuf<_CharT, _Traits>* __this) { + if (!__this->_M_in_input_mode) { + if (!__this->_M_switch_to_input_mode()) + return traits_type::eof(); + } + else if (__this->_M_in_putback_mode) { + __this->_M_exit_putback_mode(); + if (__this->gptr() != __this->egptr()) { + int_type __c = traits_type::to_int_type(*__this->gptr()); + return __c; + } + } + + return __this->_M_underflow_aux(); + } +}; + +// Specialization of underflow: if the character type is char, maybe +// we can use mmap instead of read. +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC _Underflow< char, char_traits > +{ + public: + typedef char_traits::int_type int_type; + typedef char_traits traits_type; + static int_type _STLP_CALL _M_doit(basic_filebuf* __this); +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS _Underflow >; +#endif + +//---------------------------------------------------------------------- +// Class basic_ifstream<> + +template +class basic_ifstream : public basic_istream<_CharT, _Traits> { +public: // Types + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef basic_ios<_CharT, _Traits> _Basic_ios; + typedef basic_istream<_CharT, _Traits> _Base; + typedef basic_filebuf<_CharT, _Traits> _Buf; + +public: // Constructors, destructor. + + basic_ifstream() : + basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + } + + explicit basic_ifstream(const char* __s, ios_base::openmode __mod = ios_base::in) : + basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), + _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__s, __mod | ios_base::in)) + this->setstate(ios_base::failbit); + } + +#if !defined (_STLP_NO_EXTENSIONS) + explicit basic_ifstream(int __id, ios_base::openmode __mod = ios_base::in) : + basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__id, __mod | ios_base::in)) + this->setstate(ios_base::failbit); + } + basic_ifstream(const char* __s, ios_base::openmode __m, + long __protection) : + basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__s, __m | ios_base::in, __protection)) + this->setstate(ios_base::failbit); + } + +# if defined (_STLP_USE_WIN32_IO) + explicit basic_ifstream(_STLP_fd __id, ios_base::openmode __mod = ios_base::in) : + basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__id, __mod | ios_base::in)) + this->setstate(ios_base::failbit); + } +# endif /* _STLP_USE_WIN32_IO */ +#endif + + ~basic_ifstream() {} + +public: // File and buffer operations. + basic_filebuf<_CharT, _Traits>* rdbuf() const + { return __CONST_CAST(_Buf*,&_M_buf); } + + bool is_open() { + return this->rdbuf()->is_open(); + } + + void open(const char* __s, ios_base::openmode __mod = ios_base::in) { + if (!this->rdbuf()->open(__s, __mod | ios_base::in)) + this->setstate(ios_base::failbit); + } + + void close() { + if (!this->rdbuf()->close()) + this->setstate(ios_base::failbit); + } + +private: + basic_filebuf<_CharT, _Traits> _M_buf; +}; + + +//---------------------------------------------------------------------- +// Class basic_ofstream<> + +template +class basic_ofstream : public basic_ostream<_CharT, _Traits> { +public: // Types + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef basic_ios<_CharT, _Traits> _Basic_ios; + typedef basic_ostream<_CharT, _Traits> _Base; + typedef basic_filebuf<_CharT, _Traits> _Buf; + +public: // Constructors, destructor. + basic_ofstream() : + basic_ios<_CharT, _Traits>(), + basic_ostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + } + explicit basic_ofstream(const char* __s, ios_base::openmode __mod = ios_base::out) + : basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__s, __mod | ios_base::out)) + this->setstate(ios_base::failbit); + } + +#if !defined (_STLP_NO_EXTENSIONS) + explicit basic_ofstream(int __id, ios_base::openmode __mod = ios_base::out) + : basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), + _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__id, __mod | ios_base::out)) + this->setstate(ios_base::failbit); + } + basic_ofstream(const char* __s, ios_base::openmode __m, long __protection) : + basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__s, __m | ios_base::out, __protection)) + this->setstate(ios_base::failbit); + } +# if defined (_STLP_USE_WIN32_IO) + explicit basic_ofstream(_STLP_fd __id, ios_base::openmode __mod = ios_base::out) + : basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), + _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__id, __mod | ios_base::out)) + this->setstate(ios_base::failbit); + } +# endif /* _STLP_USE_WIN32_IO */ +#endif + + ~basic_ofstream() {} + +public: // File and buffer operations. + basic_filebuf<_CharT, _Traits>* rdbuf() const + { return __CONST_CAST(_Buf*,&_M_buf); } + + bool is_open() { + return this->rdbuf()->is_open(); + } + + void open(const char* __s, ios_base::openmode __mod= ios_base::out) { + if (!this->rdbuf()->open(__s, __mod | ios_base::out)) + this->setstate(ios_base::failbit); + } + + void close() { + if (!this->rdbuf()->close()) + this->setstate(ios_base::failbit); + } + +private: + basic_filebuf<_CharT, _Traits> _M_buf; +}; + + +//---------------------------------------------------------------------- +// Class basic_fstream<> + +template +class basic_fstream : public basic_iostream<_CharT, _Traits> { +public: // Types + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef basic_ios<_CharT, _Traits> _Basic_ios; + typedef basic_iostream<_CharT, _Traits> _Base; + typedef basic_filebuf<_CharT, _Traits> _Buf; + +public: // Constructors, destructor. + + basic_fstream() + : basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + } + + explicit basic_fstream(const char* __s, + ios_base::openmode __mod = ios_base::in | ios_base::out) : + basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__s, __mod)) + this->setstate(ios_base::failbit); + } + +#if !defined (_STLP_NO_EXTENSIONS) + explicit basic_fstream(int __id, + ios_base::openmode __mod = ios_base::in | ios_base::out) : + basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__id, __mod)) + this->setstate(ios_base::failbit); + } + basic_fstream(const char* __s, ios_base::openmode __m, long __protection) : + basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__s, __m, __protection)) + this->setstate(ios_base::failbit); + } +# if defined (_STLP_USE_WIN32_IO) + explicit basic_fstream(_STLP_fd __id, + ios_base::openmode __mod = ios_base::in | ios_base::out) : + basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() { + this->init(&_M_buf); + if (!_M_buf.open(__id, __mod)) + this->setstate(ios_base::failbit); + } +# endif /* _STLP_USE_WIN32_IO */ +#endif + ~basic_fstream() {} + +public: // File and buffer operations. + + basic_filebuf<_CharT, _Traits>* rdbuf() const + { return __CONST_CAST(_Buf*,&_M_buf); } + + bool is_open() { + return this->rdbuf()->is_open(); + } + + void open(const char* __s, + ios_base::openmode __mod = + ios_base::in | ios_base::out) { + if (!this->rdbuf()->open(__s, __mod)) + this->setstate(ios_base::failbit); + } + + void close() { + if (!this->rdbuf()->close()) + this->setstate(ios_base::failbit); + } + +private: + basic_filebuf<_CharT, _Traits> _M_buf; + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + typedef basic_fstream<_CharT, _Traits> _Self; + //explicitely defined as private to avoid warnings: + basic_fstream(_Self const&); + _Self& operator = (_Self const&); +#endif +}; + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_ifstream >; +_STLP_EXPORT_TEMPLATE_CLASS basic_ofstream >; +_STLP_EXPORT_TEMPLATE_CLASS basic_fstream >; +# if ! defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_ifstream >; +_STLP_EXPORT_TEMPLATE_CLASS basic_ofstream >; +_STLP_EXPORT_TEMPLATE_CLASS basic_fstream >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_FSTREAM */ + + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_function.h b/sdk/tlibstdcxx/stlport/stl/_function.h new file mode 100644 index 0000000000..bf4ad3ee4b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_function.h @@ -0,0 +1,433 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_FUNCTION_H +#define _STLP_INTERNAL_FUNCTION_H + +#ifndef _STLP_TYPE_TRAITS_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +struct not_equal_to : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; } +}; + +template +struct greater : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; } +}; + +template +struct greater_equal : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; } +}; + +template +struct less_equal : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; } +}; + +template +struct divides : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; } +}; + +template +struct modulus : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; } +}; + +template +struct negate : public unary_function<_Tp, _Tp> { + _Tp operator()(const _Tp& __x) const { return -__x; } +}; + +template +struct logical_and : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; } +}; + +template +struct logical_or : public binary_function<_Tp, _Tp,bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; } +}; + +template +struct logical_not : public unary_function<_Tp, bool> { + bool operator()(const _Tp& __x) const { return !__x; } +}; + +#if !defined (_STLP_NO_EXTENSIONS) +// identity_element (not part of the C++ standard). +template inline _Tp identity_element(plus<_Tp>) { return _Tp(0); } +template inline _Tp identity_element(multiplies<_Tp>) { return _Tp(1); } +#endif + +#if defined (_STLP_BASE_TYPEDEF_BUG) +// this workaround is needed for SunPro 4.0.1 +// suggested by "Martin Abernethy" : + +// We have to introduce the XXary_predicate_aux structures in order to +// access the argument and return types of predicate functions supplied +// as type parameters. SUN C++ 4.0.1 compiler gives errors for template type parameters +// of the form 'name1::name2', where name1 is itself a type parameter. +template +struct __pair_aux : private _Pair { + typedef typename _Pair::first_type first_type; + typedef typename _Pair::second_type second_type; +}; + +template +struct __unary_fun_aux : private _Operation { + typedef typename _Operation::argument_type argument_type; + typedef typename _Operation::result_type result_type; +}; + +template +struct __binary_fun_aux : private _Operation { + typedef typename _Operation::first_argument_type first_argument_type; + typedef typename _Operation::second_argument_type second_argument_type; + typedef typename _Operation::result_type result_type; +}; + +# define __UNARY_ARG(__Operation,__type) __unary_fun_aux<__Operation>::__type +# define __BINARY_ARG(__Operation,__type) __binary_fun_aux<__Operation>::__type +# define __PAIR_ARG(__Pair,__type) __pair_aux<__Pair>::__type +#else +# define __UNARY_ARG(__Operation,__type) __Operation::__type +# define __BINARY_ARG(__Operation,__type) __Operation::__type +# define __PAIR_ARG(__Pair,__type) __Pair::__type +#endif + +template +class unary_negate + : public unary_function { + typedef unary_function _Base; +public: + typedef typename _Base::argument_type argument_type; +private: + typedef typename __call_traits::const_param_type _ArgParamType; +protected: + _Predicate _M_pred; +public: + explicit unary_negate(const _Predicate& __x) : _M_pred(__x) {} + bool operator()(_ArgParamType __x) const { + return !_M_pred(__x); + } +}; + +template +inline unary_negate<_Predicate> +not1(const _Predicate& __pred) { + return unary_negate<_Predicate>(__pred); +} + +template +class binary_negate + : public binary_function { + typedef binary_function _Base; +public: + typedef typename _Base::first_argument_type first_argument_type; + typedef typename _Base::second_argument_type second_argument_type; +private: + typedef typename __call_traits::const_param_type _FstArgParamType; + typedef typename __call_traits::const_param_type _SndArgParamType; +protected: + _Predicate _M_pred; +public: + explicit binary_negate(const _Predicate& __x) : _M_pred(__x) {} + bool operator()(_FstArgParamType __x, _SndArgParamType __y) const { + return !_M_pred(__x, __y); + } +}; + +template +inline binary_negate<_Predicate> +not2(const _Predicate& __pred) { + return binary_negate<_Predicate>(__pred); +} + +template +class binder1st : + public unary_function { + typedef unary_function _Base; +public: + typedef typename _Base::argument_type argument_type; + typedef typename _Base::result_type result_type; +private: + typedef typename __call_traits::param_type _ArgParamType; + typedef typename __call_traits::const_param_type _ConstArgParamType; + typedef typename __call_traits::const_param_type _ValueParamType; +protected: + //op is a Standard name (20.3.6.1), do no make it STLport naming convention compliant. + _Operation op; + typename _Operation::first_argument_type _M_value; +public: + binder1st(const _Operation& __x, _ValueParamType __y) + : op(__x), _M_value(__y) {} + + result_type operator()(_ConstArgParamType __x) const + { return op(_M_value, __x); } + // DR 109 Missing binders for non-const sequence elements + result_type operator()(_ArgParamType __x) const + { return op(_M_value, __x); } +}; + +template +inline binder1st<_Operation> +bind1st(const _Operation& __fn, const _Tp& __x) { + typedef typename _Operation::first_argument_type _Arg1_type; + return binder1st<_Operation>(__fn, _Arg1_type(__x)); +} + +template +class binder2nd + : public unary_function { + typedef unary_function _Base; +public: + typedef typename _Base::argument_type argument_type; + typedef typename _Base::result_type result_type; +private: + typedef typename __call_traits::param_type _ArgParamType; + typedef typename __call_traits::const_param_type _ConstArgParamType; + typedef typename __call_traits::const_param_type _ValueParamType; +protected: + //op is a Standard name (20.3.6.3), do no make it STLport naming convention compliant. + _Operation op; + typename _Operation::second_argument_type value; +public: + binder2nd(const _Operation& __x, _ValueParamType __y) + : op(__x), value(__y) {} + + result_type operator()(_ConstArgParamType __x) const + { return op(__x, value); } + // DR 109 Missing binders for non-const sequence elements + result_type operator()(_ArgParamType __x) const + { return op(__x, value); } +}; + +template +inline binder2nd<_Operation> +bind2nd(const _Operation& __fn, const _Tp& __x) { + typedef typename _Operation::second_argument_type _Arg2_type; + return binder2nd<_Operation>(__fn, _Arg2_type(__x)); +} + +#if !defined (_STLP_NO_EXTENSIONS) +// unary_compose and binary_compose (extensions, not part of the standard). + +template +class unary_compose : + public unary_function { + typedef unary_function _Base; +public: + typedef typename _Base::argument_type argument_type; + typedef typename _Base::result_type result_type; +private: + typedef typename __call_traits::const_param_type _ArgParamType; +protected: + _Operation1 _M_fn1; + _Operation2 _M_fn2; +public: + unary_compose(const _Operation1& __x, const _Operation2& __y) + : _M_fn1(__x), _M_fn2(__y) {} + + result_type operator()(_ArgParamType __x) const { + return _M_fn1(_M_fn2(__x)); + } +}; + +template +inline unary_compose<_Operation1,_Operation2> +compose1(const _Operation1& __fn1, const _Operation2& __fn2) { + return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); +} + +template +class binary_compose : + public unary_function { + typedef unary_function _Base; +public: + typedef typename _Base::argument_type argument_type; + typedef typename _Base::result_type result_type; +private: + typedef typename __call_traits::const_param_type _ArgParamType; +protected: + _Operation1 _M_fn1; + _Operation2 _M_fn2; + _Operation3 _M_fn3; +public: + binary_compose(const _Operation1& __x, const _Operation2& __y, + const _Operation3& __z) + : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { } + + result_type operator()(_ArgParamType __x) const { + return _M_fn1(_M_fn2(__x), _M_fn3(__x)); + } +}; + +template +inline binary_compose<_Operation1, _Operation2, _Operation3> +compose2(const _Operation1& __fn1, const _Operation2& __fn2, + const _Operation3& __fn3) { + return binary_compose<_Operation1,_Operation2,_Operation3>(__fn1, __fn2, __fn3); +} + +// identity is an extension: it is not part of the standard. +template struct identity : public _STLP_PRIV _Identity<_Tp> {}; +// select1st and select2nd are extensions: they are not part of the standard. +template struct select1st : public _STLP_PRIV _Select1st<_Pair> {}; +template struct select2nd : public _STLP_PRIV _Select2nd<_Pair> {}; + +template +struct project1st : public _STLP_PRIV _Project1st<_Arg1, _Arg2> {}; + +template +struct project2nd : public _STLP_PRIV _Project2nd<_Arg1, _Arg2> {}; + + +// constant_void_fun, constant_unary_fun, and constant_binary_fun are +// extensions: they are not part of the standard. (The same, of course, +// is true of the helper functions constant0, constant1, and constant2.) + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _Constant_void_fun { + typedef _Result result_type; + result_type _M_val; + + _Constant_void_fun(const result_type& __v) : _M_val(__v) {} + const result_type& operator()() const { return _M_val; } +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +template +struct constant_void_fun : public _STLP_PRIV _Constant_void_fun<_Result> { + constant_void_fun(const _Result& __v) + : _STLP_PRIV _Constant_void_fun<_Result>(__v) {} +}; + +template +struct constant_unary_fun : public _STLP_PRIV _Constant_unary_fun<_Result, _Argument> { + constant_unary_fun(const _Result& __v) + : _STLP_PRIV _Constant_unary_fun<_Result, _Argument>(__v) {} +}; + +template +struct constant_binary_fun + : public _STLP_PRIV _Constant_binary_fun<_Result, _Arg1, _Arg2> { + constant_binary_fun(const _Result& __v) + : _STLP_PRIV _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {} +}; + +template +inline constant_void_fun<_Result> constant0(const _Result& __val) { + return constant_void_fun<_Result>(__val); +} + +template +inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val) { + return constant_unary_fun<_Result,_Result>(__val); +} + +template +inline constant_binary_fun<_Result,_Result,_Result> +constant2(const _Result& __val) { + return constant_binary_fun<_Result,_Result,_Result>(__val); +} + +// subtractive_rng is an extension: it is not part of the standard. +// Note: this code assumes that int is 32 bits. +class subtractive_rng : public unary_function<_STLP_UINT32_T, _STLP_UINT32_T> { +private: + _STLP_UINT32_T _M_table[55]; + _STLP_UINT32_T _M_index1; + _STLP_UINT32_T _M_index2; +public: + _STLP_UINT32_T operator()(_STLP_UINT32_T __limit) { + _M_index1 = (_M_index1 + 1) % 55; + _M_index2 = (_M_index2 + 1) % 55; + _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2]; + return _M_table[_M_index1] % __limit; + } + + void _M_initialize(_STLP_UINT32_T __seed) { + _STLP_UINT32_T __k = 1; + _M_table[54] = __seed; + _STLP_UINT32_T __i; + for (__i = 0; __i < 54; __i++) { + _STLP_UINT32_T __ii = (21 * (__i + 1) % 55) - 1; + _M_table[__ii] = __k; + __k = __seed - __k; + __seed = _M_table[__ii]; + } + for (int __loop = 0; __loop < 4; __loop++) { + for (__i = 0; __i < 55; __i++) + _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55]; + } + _M_index1 = 0; + _M_index2 = 31; + } + + subtractive_rng(unsigned int __seed) { _M_initialize(__seed); } + subtractive_rng() { _M_initialize(161803398ul); } +}; + +#endif /* _STLP_NO_EXTENSIONS */ + +_STLP_END_NAMESPACE + +#include + +#endif /* _STLP_INTERNAL_FUNCTION_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_function_adaptors.h b/sdk/tlibstdcxx/stlport/stl/_function_adaptors.h new file mode 100644 index 0000000000..0da419b9ad --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_function_adaptors.h @@ -0,0 +1,783 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * Copyright (c) 2000 + * Pavel Kuznetsov + * + * Copyright (c) 2001 + * Meridian'93 + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +// This file has noo macro protection as it is meant to be included several times +// from other header. +// Adaptor function objects: pointers to member functions. + +// There are a total of 16 = 2^4 function objects in this family. +// (1) Member functions taking no arguments vs member functions taking +// one argument. +// (2) Call through pointer vs call through reference. +// (3) Member function with void return type vs member function with +// non-void return type. +// (4) Const vs non-const member function. + +// Note that choice (3) is nothing more than a workaround: according +// to the draft, compilers should handle void and non-void the same way. +// This feature is not yet widely implemented, though. You can only use +// member functions returning void if your compiler supports partial +// specialization. + +// All of this complexity is in the function objects themselves. You can +// ignore it by using the helper function mem_fun and mem_fun_ref, +// which create whichever type of adaptor is appropriate. + +_STLP_BEGIN_NAMESPACE + +//This implementation will only be used if needed, that is to say when there is the return void bug +//and when there is no partial template specialization +#if defined (_STLP_DONT_RETURN_VOID) && defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_MEMBER_TEMPLATE_CLASSES) + +template +class _Mem_fun0_ptr : public unary_function<_Tp*, _Result> { +protected: + typedef _Result (_Tp::*__fun_type) (); + explicit _Mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(_Tp* __p) const { return (__p->*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Mem_fun1_ptr : public binary_function<_Tp*,_Arg,_Result> { +protected: + typedef _Result (_Tp::*__fun_type) (_Arg); + explicit _Mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Const_mem_fun0_ptr : public unary_function { +protected: + typedef _Result (_Tp::*__fun_type) () const; + explicit _Const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(const _Tp* __p) const { return (__p->*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Const_mem_fun1_ptr : public binary_function { +protected: + typedef _Result (_Tp::*__fun_type) (_Arg) const; + explicit _Const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(const _Tp* __p, _Arg __x) const { + return (__p->*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Mem_fun0_ref : public unary_function<_Tp,_Result> { +protected: + typedef _Result (_Tp::*__fun_type) (); + explicit _Mem_fun0_ref(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(_Tp& __p) const { return (__p.*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> { +protected: + typedef _Result (_Tp::*__fun_type) (_Arg); + explicit _Mem_fun1_ref(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(_Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Const_mem_fun0_ref : public unary_function<_Tp,_Result> { +protected: + typedef _Result (_Tp::*__fun_type) () const; + explicit _Const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(const _Tp& __p) const { return (__p.*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Const_mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> { +protected: + typedef _Result (_Tp::*__fun_type) (_Arg) const; + explicit _Const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator ()(const _Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +template +struct _Mem_fun_traits { + template + struct _Args0 { + typedef _Mem_fun0_ptr<_Result,_Tp> _Ptr; + typedef _Const_mem_fun0_ptr<_Result,_Tp> _Ptr_const; + typedef _Mem_fun0_ref<_Result,_Tp> _Ref; + typedef _Const_mem_fun0_ref<_Result,_Tp> _Ref_const; + }; + + template + struct _Args1 { + typedef _Mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr; + typedef _Const_mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr_const; + typedef _Mem_fun1_ref<_Result,_Tp,_Arg> _Ref; + typedef _Const_mem_fun1_ref<_Result,_Tp,_Arg> _Ref_const; + }; +}; + +template +class _Ptr_fun1_base : public unary_function<_Arg, _Result> { +protected: + typedef _Result (*__fun_type) (_Arg); + explicit _Ptr_fun1_base(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator()(_Arg __x) const { return _M_f(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Ptr_fun2_base : public binary_function<_Arg1,_Arg2,_Result> { +protected: + typedef _Result (*__fun_type) (_Arg1, _Arg2); + explicit _Ptr_fun2_base(__fun_type __f) : _M_f(__f) {} + +public: + _Result operator()(_Arg1 __x, _Arg2 __y) const { return _M_f(__x, __y); } + +private: + __fun_type _M_f; +}; + +template +struct _Ptr_fun_traits { + template struct _Args1 { + typedef _Ptr_fun1_base<_Arg,_Result> _Fun; + }; + + template struct _Args2 { + typedef _Ptr_fun2_base<_Arg1,_Arg2,_Result> _Fun; + }; +}; + +/* Specializations for void return type */ +template +class _Void_mem_fun0_ptr : public unary_function<_Tp*,void> { +protected: + typedef void (_Tp::*__fun_type) (); + explicit _Void_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(_Tp* __p) const { (__p->*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Void_mem_fun1_ptr : public binary_function<_Tp*,_Arg,void> { +protected: + typedef void (_Tp::*__fun_type) (_Arg); + explicit _Void_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Void_const_mem_fun0_ptr : public unary_function { +protected: + typedef void (_Tp::*__fun_type) () const; + explicit _Void_const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(const _Tp* __p) const { (__p->*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Void_const_mem_fun1_ptr : public binary_function { +protected: + typedef void (_Tp::*__fun_type) (_Arg) const; + explicit _Void_const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Void_mem_fun0_ref : public unary_function<_Tp,void> { +protected: + typedef void (_Tp::*__fun_type) (); + explicit _Void_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(_Tp& __p) const { (__p.*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Void_mem_fun1_ref : public binary_function<_Tp,_Arg,void> { +protected: + typedef void (_Tp::*__fun_type) (_Arg); + explicit _Void_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(_Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Void_const_mem_fun0_ref : public unary_function<_Tp,void> { +protected: + typedef void (_Tp::*__fun_type) () const; + explicit _Void_const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(const _Tp& __p) const { (__p.*_M_f)(); } + +private: + __fun_type _M_f; +}; + +template +class _Void_const_mem_fun1_ref : public binary_function<_Tp,_Arg,void> { +protected: + typedef void (_Tp::*__fun_type) (_Arg) const; + explicit _Void_const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {} + +public: + void operator ()(const _Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); } + +private: + __fun_type _M_f; +}; + +_STLP_TEMPLATE_NULL +struct _Mem_fun_traits { + template struct _Args0 { + typedef _Void_mem_fun0_ptr<_Tp> _Ptr; + typedef _Void_const_mem_fun0_ptr<_Tp> _Ptr_const; + typedef _Void_mem_fun0_ref<_Tp> _Ref; + typedef _Void_const_mem_fun0_ref<_Tp> _Ref_const; + }; + + template struct _Args1 { + typedef _Void_mem_fun1_ptr<_Tp,_Arg> _Ptr; + typedef _Void_const_mem_fun1_ptr<_Tp,_Arg> _Ptr_const; + typedef _Void_mem_fun1_ref<_Tp,_Arg> _Ref; + typedef _Void_const_mem_fun1_ref<_Tp,_Arg> _Ref_const; + }; +}; + +template +class _Ptr_void_fun1_base : public unary_function<_Arg, void> { +protected: + typedef void (*__fun_type) (_Arg); + explicit _Ptr_void_fun1_base(__fun_type __f) : _M_f(__f) {} + +public: + void operator()(_Arg __x) const { _M_f(__x); } + +private: + __fun_type _M_f; +}; + +template +class _Ptr_void_fun2_base : public binary_function<_Arg1,_Arg2,void> { +protected: + typedef void (*__fun_type) (_Arg1, _Arg2); + explicit _Ptr_void_fun2_base(__fun_type __f) : _M_f(__f) {} + +public: + void operator()(_Arg1 __x, _Arg2 __y) const { _M_f(__x, __y); } + +private: + __fun_type _M_f; +}; + +_STLP_TEMPLATE_NULL +struct _Ptr_fun_traits { + template struct _Args1 { + typedef _Ptr_void_fun1_base<_Arg> _Fun; + }; + + template struct _Args2 { + typedef _Ptr_void_fun2_base<_Arg1,_Arg2> _Fun; + }; +}; + +// pavel: need extra level of inheritance here since MSVC++ does not +// accept traits-based fake partial specialization for template +// arguments other than first + +template +class _Ptr_fun1 : + public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun { +protected: + typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun _Base; + explicit _Ptr_fun1(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class _Ptr_fun2 : + public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun { +protected: + typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun _Base; + explicit _Ptr_fun2(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class mem_fun_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr _Base; +public: + explicit mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class const_mem_fun_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const _Base; +public: + explicit const_mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class mem_fun_ref_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref _Base; +public: + explicit mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class const_mem_fun_ref_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const _Base; +public: + explicit const_mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class mem_fun1_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr _Base; +public: + explicit mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class const_mem_fun1_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const _Base; +public: + explicit const_mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class mem_fun1_ref_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref _Base; +public: + explicit mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class const_mem_fun1_ref_t : + public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const { + typedef typename + _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const _Base; +public: + explicit const_mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {} +}; + +template +class pointer_to_unary_function : + public _Ptr_fun1<_Result,_Arg> { + typedef typename + _Ptr_fun1<_Result,_Arg>::__fun_type __fun_type; +public: + explicit pointer_to_unary_function(__fun_type __f) + : _Ptr_fun1<_Result,_Arg>(__f) {} +}; + +template +class pointer_to_binary_function : + public _Ptr_fun2<_Result,_Arg1,_Arg2> { + typedef typename + _Ptr_fun2<_Result,_Arg1,_Arg2>::__fun_type __fun_type; +public: + explicit pointer_to_binary_function(__fun_type __f) + : _Ptr_fun2<_Result,_Arg1,_Arg2>(__f) {} +}; + +#else + +template +class mem_fun_t : public unary_function<_Tp*,_Ret> { + typedef _Ret (_Tp::*__fun_type)(void); +public: + explicit mem_fun_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun_t : public unary_function { + typedef _Ret (_Tp::*__fun_type)(void) const; +public: + explicit const_mem_fun_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class mem_fun_ref_t : public unary_function<_Tp,_Ret> { + typedef _Ret (_Tp::*__fun_type)(void); +public: + explicit mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> { + typedef _Ret (_Tp::*__fun_type)(void) const; +public: + explicit const_mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> { + typedef _Ret (_Tp::*__fun_type)(_Arg); +public: + explicit mem_fun1_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun1_t : public binary_function { + typedef _Ret (_Tp::*__fun_type)(_Arg) const; +public: + explicit const_mem_fun1_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(const _Tp* __p, _Arg __x) const + { return (__p->*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { + typedef _Ret (_Tp::*__fun_type)(_Arg); +public: + explicit mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> { + typedef _Ret (_Tp::*__fun_type)(_Arg) const; +public: + explicit const_mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {} + _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class pointer_to_unary_function : public unary_function<_Arg, _Result> { +protected: + _Result (*_M_ptr)(_Arg); +public: + pointer_to_unary_function() {} + explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {} + _Result operator()(_Arg __x) const { return _M_ptr(__x); } +}; + +template +class pointer_to_binary_function : + public binary_function<_Arg1,_Arg2,_Result> { +protected: + _Result (*_M_ptr)(_Arg1, _Arg2); +public: + pointer_to_binary_function() {} + explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) + : _M_ptr(__x) {} + _Result operator()(_Arg1 __x, _Arg2 __y) const { + return _M_ptr(__x, __y); + } +}; + +# if defined (_STLP_DONT_RETURN_VOID) && !defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) +//Partial specializations for the void type +template +class mem_fun_t : public unary_function<_Tp*,void> { + typedef void (_Tp::*__fun_type)(void); +public: + explicit mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} + void operator()(_Tp* __p) const { (__p->*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun_t : public unary_function { + typedef void (_Tp::*__fun_type)(void) const; +public: + explicit const_mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} + void operator()(const _Tp* __p) const { (__p->*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class mem_fun_ref_t : public unary_function<_Tp,void> { + typedef void (_Tp::*__fun_type)(void); +public: + explicit mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} + void operator()(_Tp& __r) const { (__r.*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun_ref_t : public unary_function<_Tp,void> { + typedef void (_Tp::*__fun_type)(void) const; +public: + explicit const_mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {} + void operator()(const _Tp& __r) const { (__r.*_M_f)(); } +private: + __fun_type _M_f; +}; + +template +class mem_fun1_t : public binary_function<_Tp*,_Arg,void> { + typedef void (_Tp::*__fun_type)(_Arg); +public: + explicit mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} + void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun1_t + : public binary_function { + typedef void (_Tp::*__fun_type)(_Arg) const; +public: + explicit const_mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} + void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class mem_fun1_ref_t + : public binary_function<_Tp,_Arg,void> { + typedef void (_Tp::*__fun_type)(_Arg); +public: + explicit mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} + void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class const_mem_fun1_ref_t + : public binary_function<_Tp,_Arg,void> { + typedef void (_Tp::*__fun_type)(_Arg) const; +public: + explicit const_mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {} + void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } +private: + __fun_type _M_f; +}; + +template +class pointer_to_unary_function<_Arg, void> : public unary_function<_Arg, void> { + typedef void (*__fun_type)(_Arg); + __fun_type _M_ptr; +public: + pointer_to_unary_function() {} + explicit pointer_to_unary_function(__fun_type __x) : _M_ptr(__x) {} + void operator()(_Arg __x) const { _M_ptr(__x); } +}; + +template +class pointer_to_binary_function<_Arg1, _Arg2, void> : public binary_function<_Arg1,_Arg2,void> { + typedef void (*__fun_type)(_Arg1, _Arg2); + __fun_type _M_ptr; +public: + pointer_to_binary_function() {} + explicit pointer_to_binary_function(__fun_type __x) : _M_ptr(__x) {} + void operator()(_Arg1 __x, _Arg2 __y) const { _M_ptr(__x, __y); } +}; + +# endif + +#endif + +#if !defined (_STLP_MEMBER_POINTER_PARAM_BUG) +// Mem_fun adaptor helper functions. There are only two: +// mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref +// are provided for backward compatibility, but they are no longer +// part of the C++ standard.) + +template +inline mem_fun_t<_Result,_Tp> +mem_fun(_Result (_Tp::*__f)()) { return mem_fun_t<_Result,_Tp>(__f); } + +template +inline const_mem_fun_t<_Result,_Tp> +mem_fun(_Result (_Tp::*__f)() const) { return const_mem_fun_t<_Result,_Tp>(__f); } + +template +inline mem_fun_ref_t<_Result,_Tp> +mem_fun_ref(_Result (_Tp::*__f)()) { return mem_fun_ref_t<_Result,_Tp>(__f); } + +template +inline const_mem_fun_ref_t<_Result,_Tp> +mem_fun_ref(_Result (_Tp::*__f)() const) { return const_mem_fun_ref_t<_Result,_Tp>(__f); } + +template +inline mem_fun1_t<_Result,_Tp,_Arg> +mem_fun(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); } + +template +inline const_mem_fun1_t<_Result,_Tp,_Arg> +mem_fun(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); } + +template +inline mem_fun1_ref_t<_Result,_Tp,_Arg> +mem_fun_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } + +template +inline const_mem_fun1_ref_t<_Result,_Tp,_Arg> +mem_fun_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } + +# if !(defined (_STLP_NO_EXTENSIONS) || defined (_STLP_NO_ANACHRONISMS)) +// mem_fun1 and mem_fun1_ref are no longer part of the C++ standard, +// but they are provided for backward compatibility. +template +inline mem_fun1_t<_Result,_Tp,_Arg> +mem_fun1(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); } + +template +inline const_mem_fun1_t<_Result,_Tp,_Arg> +mem_fun1(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); } + +template +inline mem_fun1_ref_t<_Result,_Tp,_Arg> +mem_fun1_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } + +template +inline const_mem_fun1_ref_t<_Result,_Tp,_Arg> +mem_fun1_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); } + +# endif + +#endif + +template +inline pointer_to_unary_function<_Arg, _Result> +ptr_fun(_Result (*__f)(_Arg)) +{ return pointer_to_unary_function<_Arg, _Result>(__f); } + +template +inline pointer_to_binary_function<_Arg1,_Arg2,_Result> +ptr_fun(_Result (*__f)(_Arg1, _Arg2)) +{ return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f); } + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/stlport/stl/_function_base.h b/sdk/tlibstdcxx/stlport/stl/_function_base.h new file mode 100644 index 0000000000..1e7f4f5484 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_function_base.h @@ -0,0 +1,217 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +#define _STLP_INTERNAL_FUNCTION_BASE_H + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_TYPE_TRAITS_H) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +struct unary_function { + typedef _Arg argument_type; + typedef _Result result_type; +#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580) +protected: + /* This class purpose is to be derived but it is not polymorphic so users should never try + * to destroy an instance of it directly. The protected non-virtual destructor make this + * fact obvious at compilation time. */ + ~unary_function() {} +#endif +}; + +template +struct binary_function { + typedef _Arg1 first_argument_type; + typedef _Arg2 second_argument_type; + typedef _Result result_type; +#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580) +protected: + /* See unary_function comment. */ + ~binary_function() {} +#endif +}; + +template +struct equal_to : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; } +}; + +template +struct less : public binary_function<_Tp,_Tp,bool> +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +/* less is the default template parameter for many STL containers, to fully use + * the move constructor feature we need to know that the default less is just a + * functor. + */ + , public __stlport_class > +#endif +{ + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } + +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(less<_Tp>& __x) {} +#endif +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct __type_traits > { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass >::_Ret _STLportLess; +#else + enum { _Is = _IsSTLportClass >::_Is }; + typedef typename __bool2type<_Is>::_Ret _STLportLess; +#endif + typedef _STLportLess has_trivial_default_constructor; + typedef _STLportLess has_trivial_copy_constructor; + typedef _STLportLess has_trivial_assignment_operator; + typedef _STLportLess has_trivial_destructor; + typedef _STLportLess is_POD_type; +}; +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +less<_Tp> __less(_Tp* ) { return less<_Tp>(); } + +template +equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +template +struct plus : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; } +}; + +template +struct minus : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; } +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); } + +template +minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +template +struct multiplies : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; } +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { + const typename _Pair::first_type& operator()(const _Pair& __x) const { + return __x.first; + } +}; + +template +struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> { + const typename _Pair::second_type& operator()(const _Pair& __x) const { + return __x.second; + } +}; + +// project1st and project2nd are extensions: they are not part of the standard +template +struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> { + _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; } +}; + +template +struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> { + _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; } +}; + +#if defined (_STLP_MULTI_CONST_TEMPLATE_ARG_BUG) +// fbp : sort of select1st just for maps +template +// JDJ (CW Pro1 doesn't like const when first_type is also const) +struct __Select1st_hint : public unary_function<_Pair, _Whatever> { + const _Whatever& operator () (const _Pair& __x) const { return __x.first; } +}; +# define _STLP_SELECT1ST(__x,__y) _STLP_PRIV __Select1st_hint< __x, __y > +#else +# define _STLP_SELECT1ST(__x, __y) _STLP_PRIV _Select1st< __x > +#endif + +template +struct _Identity : public unary_function<_Tp,_Tp> { + const _Tp& operator()(const _Tp& __x) const { return __x; } +}; + +template +struct _Constant_unary_fun { + typedef _Argument argument_type; + typedef _Result result_type; + result_type _M_val; + + _Constant_unary_fun(const result_type& __v) : _M_val(__v) {} + const result_type& operator()(const _Argument&) const { return _M_val; } +}; + +template +struct _Constant_binary_fun { + typedef _Arg1 first_argument_type; + typedef _Arg2 second_argument_type; + typedef _Result result_type; + _Result _M_val; + + _Constant_binary_fun(const _Result& __v) : _M_val(__v) {} + const result_type& operator()(const _Arg1&, const _Arg2&) const { + return _M_val; + } +}; + +// identity_element (not part of the C++ standard). +template inline _Tp __identity_element(plus<_Tp>) { return _Tp(0); } +template inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); } + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_FUNCTION_BASE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_hash_fun.h b/sdk/tlibstdcxx/stlport/stl/_hash_fun.h new file mode 100644 index 0000000000..6197d7b2e6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_hash_fun.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_HASH_FUN_H +#define _STLP_HASH_FUN_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template struct hash { }; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +inline size_t __stl_hash_string(const char* __s) { + _STLP_FIX_LITERAL_BUG(__s) + unsigned long __h = 0; + for ( ; *__s; ++__s) + __h = 5*__h + *__s; + + return size_t(__h); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_TEMPLATE_NULL +struct hash { + size_t operator()(const char* __s) const { + _STLP_FIX_LITERAL_BUG(__s) + return _STLP_PRIV __stl_hash_string(__s); + } +}; + +_STLP_TEMPLATE_NULL +struct hash { + size_t operator()(const char* __s) const { + _STLP_FIX_LITERAL_BUG(__s) + return _STLP_PRIV __stl_hash_string(__s); + } +}; + +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(char __x) const { return __x; } +}; +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(unsigned char __x) const { return __x; } +}; +#if !defined (_STLP_NO_SIGNED_BUILTINS) +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(unsigned char __x) const { return __x; } +}; +#endif +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(short __x) const { return __x; } +}; +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(unsigned short __x) const { return __x; } +}; +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(int __x) const { return __x; } +}; + +#if !defined (_STLP_MSVC) || (_STLP_MSVC < 1300) || defined (_WIN64) +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(unsigned int __x) const { return __x; } +}; +#else +/* MSVC .Net since 2002 has a 64 bits portability warning feature. typedef + * like size_t are tagged as potential 64 bits variables making them different from + * unsigned int. To avoid the warning when a hash container is instanciated with + * the size_t key we prefer to grant the size_t specialization rather than the + * unsigned int one. + */ +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(size_t __x) const { return __x; } +}; +#endif + +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(long __x) const { return __x; } +}; +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(unsigned long __x) const { return __x; } +}; + +#if defined (_STLP_LONG_LONG) +_STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> { + size_t operator()(_STLP_LONG_LONG x) const { return (size_t)x; } +}; +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(unsigned _STLP_LONG_LONG x) const { return (size_t)x; } +}; +#endif + +_STLP_TEMPLATE_NULL +struct hash +{ + union __vp { + size_t s; + void *p; + }; + + size_t operator()(void *__x) const + { + __vp vp; + vp.p = __x; + return vp.s; + } +}; + +_STLP_END_NAMESPACE + +#endif /* _STLP_HASH_FUN_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_hash_map.h b/sdk/tlibstdcxx/stlport/stl/_hash_map.h new file mode 100644 index 0000000000..cd4660315a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_hash_map.h @@ -0,0 +1,500 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_HASH_MAP_H +#define _STLP_INTERNAL_HASH_MAP_H + +#ifndef _STLP_INTERNAL_HASHTABLE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMapTraitsT, traits) + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class hash_map +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ +private: + typedef hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; +public: + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST key_type, data_type> value_type; +private: + //Specific iterator traits creation + typedef _STLP_PRIV _HashMapTraitsT _HashMapTraits; + +public: + typedef hashtable _Ht; + + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) +public: + hash_map() : _M_ht(0, hasher(), key_equal(), allocator_type()) {} + explicit hash_map(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_map(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + hash_map(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) { + } +#endif + +#ifdef _STLP_MEMBER_TEMPLATES + template + hash_map(_InputIterator __f, _InputIterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql) + : _M_ht(__n, __hf, __eql, allocator_type()) + { _M_ht.insert_unique(__f, __l); } +# endif + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + +#else + hash_map(const value_type* __f, const value_type* __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + hash_map(const_iterator __f, const_iterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_map(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + +public: + pair insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } +#ifdef _STLP_MEMBER_TEMPLATES + template + void insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_unique(__f,__l); } +#else + void insert(const value_type* __f, const value_type* __l) + { _M_ht.insert_unique(__f,__l); } + void insert(const_iterator __f, const_iterator __l) + { _M_ht.insert_unique(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + pair insert_noresize(const value_type& __obj) + { return _M_ht.insert_unique_noresize(__obj); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + _Tp& operator[](const _KT& __key) { + iterator __it = _M_ht.find(__key); + return (__it == _M_ht.end() ? + _M_ht._M_insert(value_type(__key, _STLP_DEFAULT_CONSTRUCTED(_Tp))).second : + (*__it).second ); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type erase(const _KT& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMultimapTraitsT, traits) + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class hash_multimap +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ +private: + typedef hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; +public: + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST key_type, data_type> value_type; +private: + //Specific iterator traits creation + typedef _STLP_PRIV _HashMultimapTraitsT _HashMultimapTraits; + +public: + typedef hashtable _Ht; + + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) +public: + hash_multimap() : _M_ht(0, hasher(), key_equal(), allocator_type()) {} + explicit hash_multimap(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_multimap(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + hash_multimap(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) { + } +#endif + +#ifdef _STLP_MEMBER_TEMPLATES + template + hash_multimap(_InputIterator __f, _InputIterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql) + : _M_ht(__n, __hf, __eql, allocator_type()) + { _M_ht.insert_equal(__f, __l); } +# endif + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + +#else + hash_multimap(const value_type* __f, const value_type* __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + hash_multimap(const_iterator __f, const_iterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multimap(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + +public: + iterator insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } +#ifdef _STLP_MEMBER_TEMPLATES + template + void insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } +#else + void insert(const value_type* __f, const value_type* __l) { + _M_ht.insert_equal(__f,__l); + } + void insert(const_iterator __f, const_iterator __l) + { _M_ht.insert_equal(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + iterator insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair + equal_range(const _KT& __key) { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair + equal_range(const _KT& __key) const { return _M_ht.equal_range(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type erase(const _KT& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + +public: + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > : + _STLP_PRIV __move_traits_help::_Ht> +{}; + +template +struct __move_traits > : + _STLP_PRIV __move_traits_help::_Ht> +{}; +# endif + +// Specialization of insert_iterator so that it will work for hash_map +// and hash_multimap. +template +class insert_iterator > { +protected: + typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; + _Container* container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; + +template +class insert_iterator > { +protected: + typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; + _Container* container; + typename _Container::iterator iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_HASH_MAP_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_hash_set.h b/sdk/tlibstdcxx/stlport/stl/_hash_set.h new file mode 100644 index 0000000000..29b168b8dd --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_hash_set.h @@ -0,0 +1,495 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_HASH_SET_H +#define _STLP_INTERNAL_HASH_SET_H + +#ifndef _STLP_INTERNAL_HASHTABLE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(HashSetTraitsT, Const_traits) + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Value>), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) > +class hash_set +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Self; + //Specific iterator traits creation + typedef _STLP_PRIV _HashSetTraitsT<_Value> _HashSetTraits; +public: + typedef hashtable<_Value, _Value, _HashFcn, + _HashSetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht; +public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + hash_set() + : _M_ht(0, hasher(), key_equal(), allocator_type()) {} + explicit hash_set(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_set(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) +#else + hash_set(size_type __n, const hasher& __hf, const key_equal& __eql) + : _M_ht(__n, __hf, __eql, allocator_type()) {} + hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a) +#endif + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + hash_set(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + hash_set(_InputIterator __f, _InputIterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql) + : _M_ht(__n, __hf, __eql, allocator_type()) + { _M_ht.insert_unique(__f, __l); } +# endif +#else + hash_set(const value_type* __f, const value_type* __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + hash_set(const_iterator __f, const_iterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + hash_set(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + +public: + pair insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __f, _InputIterator __l) +#else + void insert(const_iterator __f, const_iterator __l) + {_M_ht.insert_unique(__f, __l); } + void insert(const value_type* __f, const value_type* __l) +#endif + { _M_ht.insert_unique(__f,__l); } + + pair insert_noresize(const value_type& __obj) + { return _M_ht.insert_unique_noresize(__obj); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type erase(const _KT& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + +public: + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMultisetTraitsT, Const_traits) + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Value>), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) > +class hash_multiset +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Self; + //Specific iterator traits creation + typedef _STLP_PRIV _HashMultisetTraitsT<_Value> _HashMultisetTraits; +public: + typedef hashtable<_Value, _Value, _HashFcn, + _HashMultisetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht; + + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_funct() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + hash_multiset() + : _M_ht(0, hasher(), key_equal(), allocator_type()) {} + explicit hash_multiset(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + hash_multiset(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql) + : _M_ht(__n, __hf, __eql, allocator_type()) {} + hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + hash_multiset(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + hash_multiset(_InputIterator __f, _InputIterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql) + : _M_ht(__n, __hf, __eql, allocator_type()) + { _M_ht.insert_equal(__f, __l); } +# endif +#else + hash_multiset(const value_type* __f, const value_type* __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const value_type* __f, const value_type* __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const value_type* __f, const value_type* __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + hash_multiset(const_iterator __f, const_iterator __l) + : _M_ht(0, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const_iterator __f, const_iterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + hash_multiset(const_iterator __f, const_iterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + +public: + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& hs) { _M_ht.swap(hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + +public: + iterator insert(const value_type& __obj) { return _M_ht.insert_equal(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } +#else + void insert(const value_type* __f, const value_type* __l) + { _M_ht.insert_equal(__f,__l); } + void insert(const_iterator __f, const_iterator __l) + { _M_ht.insert_equal(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + iterator insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type erase(const _KT& __key) {return _M_ht.erase(__key); } + void erase(iterator __it) { _M_ht.erase(__it); } + void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + +public: + void resize(size_type __hint) { _M_ht.resize(__hint); } + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } +}; + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER hash_set<_Value,_HashFcn,_EqualKey,_Alloc> + +#include + +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER hash_multiset<_Value,_HashFcn,_EqualKey,_Alloc> +#include + +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +// Specialization of insert_iterator so that it will work for hash_set +// and hash_multiset. + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux::_Ht> +{}; + +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux::_Ht> +{}; +# endif + +template +class insert_iterator > { +protected: + typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container; + _Container* container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; + +template +class insert_iterator > { +protected: + typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container; + _Container* container; + typename _Container::iterator iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_HASH_SET_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_hashtable.c b/sdk/tlibstdcxx/stlport/stl/_hashtable.c new file mode 100644 index 0000000000..b743156e46 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_hashtable.c @@ -0,0 +1,553 @@ +/* + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_HASHTABLE_C +#define _STLP_HASHTABLE_C + +#ifndef _STLP_INTERNAL_HASHTABLE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) + +_STLP_MOVE_TO_PRIV_NAMESPACE + +# define __PRIME_LIST_BODY { \ + 7ul, 23ul, \ + 53ul, 97ul, 193ul, 389ul, 769ul, \ + 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, \ + 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, \ + 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, \ + 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,\ + 1610612741ul, 3221225473ul, 4294967291ul \ +} + +template +const size_t* _STLP_CALL +_Stl_prime<_Dummy>::_S_primes(size_t &__size) { + static const size_t _list[] = __PRIME_LIST_BODY; +# ifndef __MWERKS__ + __size = sizeof(_list) / sizeof(_list[0]); +# else + __size = 30; +# endif + return _list; +} + +template +size_t _STLP_CALL +_Stl_prime<_Dummy>::_S_max_nb_buckets() { + size_t __size; + const size_t* __first = _S_primes(__size); + return *(__first + __size - 1); +} + +template +size_t _STLP_CALL +_Stl_prime<_Dummy>::_S_next_size(size_t __n) { + size_t __size; + const size_t* __first = _S_primes(__size); + const size_t* __last = __first + __size; + const size_t* pos = __lower_bound(__first, __last, __n, + __less((size_t*)0), __less((size_t*)0), (ptrdiff_t*)0); + return (pos == __last ? *(__last - 1) : *pos); +} + +template +void _STLP_CALL +_Stl_prime<_Dummy>::_S_prev_sizes(size_t __n, size_t const*&__begin, size_t const*&__pos) { + size_t __size; + __begin = _S_primes(__size); + const size_t* __last = __begin + __size; + __pos = __lower_bound(__begin, __last, __n, + __less((size_t*)0), __less((size_t*)0), (ptrdiff_t*)0); + + if (__pos== __last) + --__pos; + else if (*__pos == __n) { + if (__pos != __begin) + --__pos; + } +} + +# undef __PRIME_LIST_BODY + +_STLP_MOVE_TO_STD_NAMESPACE + +#endif + +#if defined (_STLP_DEBUG) +# define hashtable _STLP_NON_DBG_NAME(hashtable) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +// fbp: these defines are for outline methods definitions. +// needed to definitions to be portable. Should not be used in method bodies. + +#if defined ( _STLP_NESTED_TYPE_PARAM_BUG ) +# define __size_type__ size_t +# define size_type size_t +# define value_type _Val +# define key_type _Key +# define __reference__ _Val& + +# define __iterator__ _Ht_iterator<_Val, _STLP_HEADER_TYPENAME _Traits::_NonConstTraits, \ + _Key, _HF, _ExK, _EqK, _All> +# define __const_iterator__ _Ht_iterator<_Val, _STLP_HEADER_TYPENAME _Traits::_ConstTraits, \ + _Key, _HF, _ExK, _EqK, _All> +#else +# define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::size_type +# define __reference__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::reference +# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::iterator +# define __const_iterator__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::const_iterator +#endif + +/* + * This method is too difficult to implement for hashtable that do not + * require a sorted operation on the stored type. +template +bool hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::_M_equal( + const hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>& __ht1, + const hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>& __ht2) { + return __ht1._M_buckets == __ht2._M_buckets && + __ht1._M_elems == __ht2._M_elems; +} +*/ + +/* Returns the iterator before the first iterator of the bucket __n and set + * __n to the first previous bucket having the same first iterator as bucket + * __n. + */ +template +__iterator__ +hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_before_begin(size_type &__n) const { + return _S_before_begin(_M_elems, _M_buckets, __n); +} + +template +__iterator__ +hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_S_before_begin(const _ElemsCont& __elems, const _BucketVector& __buckets, + size_type &__n) { + _ElemsCont &__mutable_elems = __CONST_CAST(_ElemsCont&, __elems); + typename _BucketVector::const_iterator __bpos(__buckets.begin() + __n); + + _ElemsIte __pos(*__bpos); + if (__pos == __mutable_elems.begin()) { + __n = 0; + return __mutable_elems.before_begin(); + } + + typename _BucketVector::const_iterator __bcur(__bpos); + _BucketType *__pos_node = __pos._M_node; + for (--__bcur; __pos_node == *__bcur; --__bcur); + + __n = __bcur - __buckets.begin() + 1; + _ElemsIte __cur(*__bcur); + _ElemsIte __prev = __cur++; + for (; __cur != __pos; ++__prev, ++__cur); + return __prev; +} + + +template +__iterator__ +hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_insert_noresize(size_type __n, const value_type& __obj) { + //We always insert this element as 1st in the bucket to not break + //the elements order as equal elements must be kept next to each other. + size_type __prev = __n; + _ElemsIte __pos = _M_before_begin(__prev)._M_ite; + + fill(_M_buckets.begin() + __prev, _M_buckets.begin() + __n + 1, + _M_elems.insert_after(__pos, __obj)._M_node); + ++_M_num_elements; + return iterator(_ElemsIte(_M_buckets[__n])); +} + +template +pair<__iterator__, bool> +hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::insert_unique_noresize(const value_type& __obj) { + const size_type __n = _M_bkt_num(__obj); + _ElemsIte __cur(_M_buckets[__n]); + _ElemsIte __last(_M_buckets[__n + 1]); + + if (__cur != __last) { + for (; __cur != __last; ++__cur) { + if (_M_equals(_M_get_key(*__cur), _M_get_key(__obj))) { + //We check that equivalent keys have equals hash code as otherwise, on resize, + //equivalent value might not be in the same bucket + _STLP_ASSERT(_M_hash(_M_get_key(*__cur)) == _M_hash(_M_get_key(__obj))) + return pair(iterator(__cur), false); + } + } + /* Here we do not rely on the _M_insert_noresize method as we know + * that we cannot break element orders, elements are unique, and + * insertion after the first bucket element is faster than what is + * done in _M_insert_noresize. + */ + __cur = _M_elems.insert_after(_ElemsIte(_M_buckets[__n]), __obj); + ++_M_num_elements; + return pair(iterator(__cur), true); + } + + return pair(_M_insert_noresize(__n, __obj), true); +} + +template +__iterator__ +hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::insert_equal_noresize(const value_type& __obj) { + const size_type __n = _M_bkt_num(__obj); + { + _ElemsIte __cur(_M_buckets[__n]); + _ElemsIte __last(_M_buckets[__n + 1]); + + for (; __cur != __last; ++__cur) { + if (_M_equals(_M_get_key(*__cur), _M_get_key(__obj))) { + //We check that equivalent keys have equals hash code as otherwise, on resize, + //equivalent value might not be in the same bucket + _STLP_ASSERT(_M_hash(_M_get_key(*__cur)) == _M_hash(_M_get_key(__obj))) + ++_M_num_elements; + return _M_elems.insert_after(__cur, __obj); + } + } + } + + return _M_insert_noresize(__n, __obj); +} + +template +__reference__ +hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_insert(const value_type& __obj) { + _M_enlarge(_M_num_elements + 1); + return *insert_unique_noresize(__obj).first; +} + +template +__size_type__ +hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::erase(const key_type& __key) { + const size_type __n = _M_bkt_num_key(__key); + + _ElemsIte __cur(_M_buckets[__n]); + _ElemsIte __last(_M_buckets[__n + 1]); + if (__cur == __last) + return 0; + + size_type __erased = 0; + if (_M_equals(_M_get_key(*__cur), __key)) { + //We look for the pos before __cur: + size_type __prev_b = __n; + _ElemsIte __prev = _M_before_begin(__prev_b)._M_ite; + do { + __cur = _M_elems.erase_after(__prev); + ++__erased; + } while ((__cur != __last) && _M_equals(_M_get_key(*__cur), __key)); + fill(_M_buckets.begin() + __prev_b, _M_buckets.begin() + __n + 1, __cur._M_node); + } + else { + _ElemsIte __prev = __cur++; + for (; __cur != __last; ++__prev, ++__cur) { + if (_M_equals(_M_get_key(*__cur), __key)) { + do { + __cur = _M_elems.erase_after(__prev); + ++__erased; + } while ((__cur != __last) && _M_equals(_M_get_key(*__cur), __key)); + break; + } + } + } + + _M_num_elements -= __erased; + _M_reduce(); + return __erased; +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::erase(const_iterator __it) { + const size_type __n = _M_bkt_num(*__it); + _ElemsIte __cur(_M_buckets[__n]); + + size_type __erased = 0; + if (__cur == __it._M_ite) { + size_type __prev_b = __n; + _ElemsIte __prev = _M_before_begin(__prev_b)._M_ite; + fill(_M_buckets.begin() + __prev_b, _M_buckets.begin() + __n + 1, + _M_elems.erase_after(__prev)._M_node); + ++__erased; + } + else { + _ElemsIte __prev = __cur++; + _ElemsIte __last(_M_buckets[__n + 1]); + for (; __cur != __last; ++__prev, ++__cur) { + if (__cur == __it._M_ite) { + _M_elems.erase_after(__prev); + ++__erased; + break; + } + } + } + + _M_num_elements -= __erased; + _M_reduce(); +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::erase(const_iterator __first, const_iterator __last) { + if (__first == __last) + return; + size_type __f_bucket = _M_bkt_num(*__first); + size_type __l_bucket = __last != end() ? _M_bkt_num(*__last) : (_M_buckets.size() - 1); + + _ElemsIte __cur(_M_buckets[__f_bucket]); + _ElemsIte __prev; + if (__cur == __first._M_ite) { + __prev = _M_before_begin(__f_bucket)._M_ite; + } + else { + _ElemsIte __last(_M_buckets[++__f_bucket]); + __prev = __cur++; + for (; (__cur != __last) && (__cur != __first._M_ite); ++__prev, ++__cur); + } + size_type __erased = 0; + //We do not use the slist::erase_after method taking a range to count the + //number of erased elements: + while (__cur != __last._M_ite) { + __cur = _M_elems.erase_after(__prev); + ++__erased; + } + fill(_M_buckets.begin() + __f_bucket, _M_buckets.begin() + __l_bucket + 1, __cur._M_node); + _M_num_elements -= __erased; + _M_reduce(); +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::rehash(size_type __num_buckets_hint) { + if (bucket_count() >= __num_buckets_hint) { + // We are trying to reduce number of buckets, we have to validate it: + size_type __limit_num_buckets = (size_type)((float)size() / max_load_factor()); + if (__num_buckets_hint < __limit_num_buckets) { + // Targetted number of buckets __num_buckets_hint would break + // load_factor() <= max_load_factor() rule. + return; + } + } + + _M_rehash(__num_buckets_hint); +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_enlarge(size_type __to_size) { + size_type __num_buckets = bucket_count(); + size_type __num_buckets_hint = (size_type)((float)__to_size / max_load_factor()); + if (__num_buckets_hint <= __num_buckets) { + return; + } + __num_buckets = _STLP_PRIV _Stl_prime_type::_S_next_size(__num_buckets_hint); + + _M_rehash(__num_buckets); +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_reduce() { + size_type __num_buckets = bucket_count(); + // We only try to reduce the hashtable if the theorical load factor + // is lower than a fraction of the max load factor: + // 4 factor is coming from the fact that prime number list is almost a + // geometrical suite with reason 2, as we try to jump 2 levels is means + // a 4 factor. + if ((float)size() / (float)__num_buckets > max_load_factor() / 4.0f) + return; + + const size_type *__first; + const size_type *__prev; + _STLP_PRIV _Stl_prime_type::_S_prev_sizes(__num_buckets, __first, __prev); + + /* We are only going to reduce number of buckets if moving to yet the previous number + * of buckets in the prime numbers would respect the load rule. Otherwise algorithm + * successively removing and adding an element would each time perform an expensive + * rehash operation. */ + const size_type *__prev_prev = __prev; + if (__prev_prev != __first) { + --__prev_prev; + if ((float)size() / (float)*__prev_prev > max_load_factor()) + return; + } + else { + if (*__prev >= __num_buckets) + return; + } + + // Can we reduce further: + while (__prev_prev != __first) { + --__prev_prev; + if ((float)size() / (float)*__prev_prev > max_load_factor()) + // We cannot reduce further. + break; + --__prev; + } + + _M_rehash(*__prev); +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_resize() { + if (load_factor() > max_load_factor()) { + // We have to enlarge + _M_enlarge(size()); + } + else { + // We can try to reduce size: + _M_reduce(); + } +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_rehash(size_type __num_buckets) { +#if defined (_STLP_DEBUG) + _M_check(); +#endif + _ElemsCont __tmp_elems(_M_elems.get_allocator()); + _BucketVector __tmp(__num_buckets + 1, __STATIC_CAST(_BucketType*, 0), _M_buckets.get_allocator()); + _ElemsIte __cur, __last(_M_elems.end()); + while (!_M_elems.empty()) { + __cur = _M_elems.begin(); + size_type __new_bucket = _M_bkt_num(*__cur, __num_buckets); + _ElemsIte __ite(__cur), __before_ite(__cur); + for (++__ite; + __ite != __last && _M_equals(_M_get_key(*__cur), _M_get_key(*__ite)); + ++__ite, ++__before_ite); + size_type __prev_bucket = __new_bucket; + _ElemsIte __prev = _S_before_begin(__tmp_elems, __tmp, __prev_bucket)._M_ite; + __tmp_elems.splice_after(__prev, _M_elems, _M_elems.before_begin(), __before_ite); + fill(__tmp.begin() + __prev_bucket, __tmp.begin() + __new_bucket + 1, __cur._M_node); + } + _M_elems.swap(__tmp_elems); + _M_buckets.swap(__tmp); +} + +#if defined (_STLP_DEBUG) +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::_M_check() const { + //We check that hash code of stored keys haven't change and also that equivalent + //relation hasn't been modified + size_t __num_buckets = bucket_count(); + for (size_t __b = 0; __b < __num_buckets; ++__b) { + _ElemsIte __cur(_M_buckets[__b]), __last(_M_buckets[__b + 1]); + _ElemsIte __fst(__cur), __snd(__cur); + for (; __cur != __last; ++__cur) { + _STLP_ASSERT( _M_bkt_num(*__cur, __num_buckets) == __b ) + _STLP_ASSERT( !_M_equals(_M_get_key(*__fst), _M_get_key(*__cur)) || _M_equals(_M_get_key(*__snd), _M_get_key(*__cur)) ) + if (__fst != __snd) + ++__fst; + if (__snd != __cur) + ++__snd; + } + } +} +#endif + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::clear() { + _M_elems.clear(); + _M_buckets.assign(_M_buckets.size(), __STATIC_CAST(_BucketType*, 0)); + _M_num_elements = 0; +} + +template +void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> + ::_M_copy_from(const hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>& __ht) { + _M_elems.clear(); + _M_elems.insert(_M_elems.end(), __ht._M_elems.begin(), __ht._M_elems.end()); + _M_buckets.resize(__ht._M_buckets.size()); + _ElemsConstIte __src(__ht._M_elems.begin()), __src_end(__ht._M_elems.end()); + _ElemsIte __dst(_M_elems.begin()); + typename _BucketVector::const_iterator __src_b(__ht._M_buckets.begin()), + __src_end_b(__ht._M_buckets.end()); + typename _BucketVector::iterator __dst_b(_M_buckets.begin()), __dst_end_b(_M_buckets.end()); + for (; __src != __src_end; ++__src, ++__dst) { + for (; __src_b != __src_end_b; ++__src_b, ++__dst_b) { + if (*__src_b == __src._M_node) { + *__dst_b = __dst._M_node; + } + else + break; + } + } + fill(__dst_b, __dst_end_b, __STATIC_CAST(_BucketType*, 0)); + _M_num_elements = __ht._M_num_elements; + _M_max_load_factor = __ht._M_max_load_factor; +} + +#undef __iterator__ +#undef const_iterator +#undef __size_type__ +#undef __reference__ +#undef size_type +#undef value_type +#undef key_type +#undef __stl_num_primes + +#if defined (_STLP_DEBUG) +# undef hashtable +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_HASHTABLE_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_hashtable.h b/sdk/tlibstdcxx/stlport/stl/_hashtable.h new file mode 100644 index 0000000000..1c8e2f5434 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_hashtable.h @@ -0,0 +1,658 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_HASHTABLE_H +#define _STLP_INTERNAL_HASHTABLE_H + +#ifndef _STLP_INTERNAL_VECTOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_SLIST_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_HASH_FUN_H +# include +#endif + +/* + * Hashtable class, used to implement the hashed associative containers + * hash_set, hash_map, hash_multiset, hash_multimap, + * unordered_set, unordered_map, unordered_multiset, unordered_multimap. + */ + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +//Export of the classes used to represent buckets in the hashtable implementation. +# if !defined (_STLP_USE_PTR_SPECIALIZATIONS) +//If pointer specialization is enabled vector<_Slist_node_base*> will use the void* +//storage type for which internal classes have already been exported. +_STLP_EXPORT_TEMPLATE_CLASS allocator<_STLP_PRIV _Slist_node_base*>; + +_STLP_MOVE_TO_PRIV_NAMESPACE +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Slist_node_base**, _Slist_node_base*, + allocator<_Slist_node_base*> >; +_STLP_EXPORT_TEMPLATE_CLASS _Vector_base<_Slist_node_base*, + allocator<_Slist_node_base*> >; +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +# if defined (_STLP_DEBUG) +_STLP_MOVE_TO_PRIV_NAMESPACE +# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector) +_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_VECTOR<_Slist_node_base*, allocator<_Slist_node_base*> > >; +_STLP_EXPORT_TEMPLATE_CLASS _STLP_NON_DBG_VECTOR<_Slist_node_base*, allocator<_Slist_node_base*> >; +# undef _STLP_NON_DBG_VECTOR +_STLP_MOVE_TO_STD_NAMESPACE +# endif + +_STLP_EXPORT_TEMPLATE_CLASS vector<_STLP_PRIV _Slist_node_base*, + allocator<_STLP_PRIV _Slist_node_base*> >; +#endif + +#if defined (_STLP_DEBUG) +# define hashtable _STLP_NON_DBG_NAME(hashtable) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +// some compilers require the names of template parameters to be the same +template +class hashtable; + +#if !defined (_STLP_DEBUG) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template +struct _Ht_iterator { + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef typename _Traits::_NonConstTraits _NonConstTraits; + + typedef _Ht_iterator<_BaseIte,_Traits> _Self; + + typedef typename _Traits::value_type value_type; + typedef typename _Traits::pointer pointer; + typedef typename _Traits::reference reference; + typedef forward_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + + typedef _Ht_iterator<_BaseIte, _NonConstTraits> iterator; + typedef _Ht_iterator<_BaseIte, _ConstTraits> const_iterator; + + _Ht_iterator() {} + //copy constructor for iterator and constructor from iterator for const_iterator + _Ht_iterator(const iterator& __it) : _M_ite(__it._M_ite) {} + _Ht_iterator(_BaseIte __it) : _M_ite(__it) {} + + reference operator*() const { + return *_M_ite; + } + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + ++_M_ite; + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + ++*this; + return __tmp; + } + + bool operator == (const_iterator __rhs) const { + return _M_ite == __rhs._M_ite; + } + bool operator != (const_iterator __rhs) const { + return _M_ite != __rhs._M_ite; + } + + _BaseIte _M_ite; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct __type_traits<_STLP_PRIV _Ht_iterator<_BaseIte, _Traits> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +template +inline +# if defined (_STLP_NESTED_TYPE_PARAM_BUG) +_STLP_TYPENAME_ON_RETURN_TYPE _Traits::value_type * +# else +_STLP_TYPENAME_ON_RETURN_TYPE _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>::value_type * +# endif +value_type(const _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>&) { + typedef _STLP_TYPENAME _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>::value_type _Val; + return (_Val*) 0; +} +template +inline forward_iterator_tag iterator_category(const _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>&) +{ return forward_iterator_tag(); } +template +inline ptrdiff_t* distance_type(const _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>&) +{ return (ptrdiff_t*) 0; } +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class _Stl_prime { + // Returns begining of primes list and size by reference. + static const size_t* _S_primes(size_t&); +public: + //Returns the maximum number of buckets handled by the hashtable implementation + static size_t _STLP_CALL _S_max_nb_buckets(); + + //Returns the bucket size next to a required size + static size_t _STLP_CALL _S_next_size(size_t); + + // Returns the bucket range containing sorted list of prime numbers <= __hint. + static void _STLP_CALL _S_prev_sizes(size_t __hint, const size_t *&__begin, const size_t *&__end); +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _Stl_prime; +#endif + +typedef _Stl_prime _Stl_prime_type; + +#if !defined (_STLP_DEBUG) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +/* + * Hashtables handle allocators a bit differently than other containers + * do. If we're using standard-conforming allocators, then a hashtable + * unconditionally has a member variable to hold its allocator, even if + * it so happens that all instances of the allocator type are identical. + * This is because, for hashtables, this extra storage is negligible. + * Additionally, a base class wouldn't serve any other purposes; it + * wouldn't, for example, simplify the exception-handling code. + */ +template +class hashtable { + typedef hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All> _Self; + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef typename _Traits::_NonConstLocalTraits _NonConstLocalTraits; + typedef typename _Traits::_ConstLocalTraits _ConstLocalTraits; + +public: + typedef _Key key_type; + typedef _Val value_type; + typedef _HF hasher; + typedef _EqK key_equal; + + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef typename _NonConstTraits::pointer pointer; + typedef const value_type* const_pointer; + typedef typename _NonConstTraits::reference reference; + typedef const value_type& const_reference; + typedef forward_iterator_tag _Iterator_category; + + hasher hash_funct() const { return _M_hash; } + key_equal key_eq() const { return _M_equals; } + +private: + _STLP_FORCE_ALLOCATORS(_Val, _All) +#if defined (_STLP_DEBUG) + typedef _STLP_PRIV _STLP_NON_DBG_NAME(slist) _ElemsCont; +#else + typedef slist _ElemsCont; +#endif + typedef typename _ElemsCont::iterator _ElemsIte; + typedef typename _ElemsCont::const_iterator _ElemsConstIte; + typedef _STLP_PRIV _Slist_node_base _BucketType; + typedef typename _Alloc_traits<_BucketType*, _All>::allocator_type _BucketAllocType; + /* + * We are going to use vector of _Slist_node_base pointers for 2 reasons: + * - limit code bloat, all hashtable instanciation use the same buckets representation. + * - avoid _STLP_DEBUG performance trouble: with a vector of iterator on slist the resize + * method would be too slow because the slist::splice_after method become linear on + * the number of iterators in the buckets rather than constant in time as the iterator + * has to be move from a slist to the other. + */ +#if defined (_STLP_DEBUG) + typedef _STLP_PRIV _STLP_NON_DBG_NAME(vector)<_BucketType*, _BucketAllocType> _BucketVector; +#else + typedef vector<_BucketType*, _BucketAllocType> _BucketVector; +#endif + + hasher _M_hash; + key_equal _M_equals; + _ElemsCont _M_elems; + _BucketVector _M_buckets; + size_type _M_num_elements; + float _M_max_load_factor; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + + static const key_type& _M_get_key(const value_type& __val) { + _ExK k; + return k(__val); + } +public: + typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _NonConstTraits> iterator; + typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _ConstTraits> const_iterator; + //TODO: Avoids this debug check and make the local_iterator different from + //iterator in debug mode too. +#if !defined (_STLP_DEBUG) + typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _NonConstLocalTraits> local_iterator; + typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _ConstLocalTraits> const_local_iterator; +#else + typedef iterator local_iterator; + typedef const_iterator const_local_iterator; +#endif + + typedef _All allocator_type; + allocator_type get_allocator() const { return _M_elems.get_allocator(); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + hashtable(size_type __n, + const _HF& __hf, + const _EqK& __eql, + const allocator_type& __a = allocator_type()) +#else + hashtable(size_type __n, + const _HF& __hf, + const _EqK& __eql) + : _M_hash(__hf), + _M_equals(__eql), + _M_elems(allocator_type()), + _M_buckets(_STLP_CONVERT_ALLOCATOR(__a, _BucketType*)), + _M_num_elements(0), + _M_max_load_factor(1.0f) + { _M_initialize_buckets(__n); } + + hashtable(size_type __n, + const _HF& __hf, + const _EqK& __eql, + const allocator_type& __a) +#endif + : _M_hash(__hf), + _M_equals(__eql), + _M_elems(__a), + _M_buckets(_STLP_CONVERT_ALLOCATOR(__a, _BucketType*)), + _M_num_elements(0), + _M_max_load_factor(1.0f) + { _M_initialize_buckets(__n); } + + hashtable(const _Self& __ht) + : _M_hash(__ht._M_hash), + _M_equals(__ht._M_equals), + _M_elems(__ht.get_allocator()), + _M_buckets(_STLP_CONVERT_ALLOCATOR(__ht.get_allocator(), _BucketType*)), + _M_num_elements(0), + _M_max_load_factor(1.0f) + { _M_copy_from(__ht); } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + hashtable(__move_source<_Self> src) + : _M_hash(_STLP_PRIV _AsMoveSource(src.get()._M_hash)), + _M_equals(_STLP_PRIV _AsMoveSource(src.get()._M_equals)), + _M_elems(__move_source<_ElemsCont>(src.get()._M_elems)), + _M_buckets(__move_source<_BucketVector>(src.get()._M_buckets)), + _M_num_elements(src.get()._M_num_elements), + _M_max_load_factor(src.get()._M_max_load_factor) {} +#endif + + _Self& operator= (const _Self& __ht) { + if (&__ht != this) { + clear(); + _M_hash = __ht._M_hash; + _M_equals = __ht._M_equals; + _M_copy_from(__ht); + } + return *this; + } + + ~hashtable() { clear(); } + + size_type size() const { return _M_num_elements; } + size_type max_size() const { return size_type(-1); } + bool empty() const { return size() == 0; } + + void swap(_Self& __ht) { + _STLP_STD::swap(_M_hash, __ht._M_hash); + _STLP_STD::swap(_M_equals, __ht._M_equals); + _M_elems.swap(__ht._M_elems); + _M_buckets.swap(__ht._M_buckets); + _STLP_STD::swap(_M_num_elements, __ht._M_num_elements); + _STLP_STD::swap(_M_max_load_factor, __ht._M_max_load_factor); + } + + iterator begin() { return _M_elems.begin(); } + iterator end() { return _M_elems.end(); } + local_iterator begin(size_type __n) { return _ElemsIte(_M_buckets[__n]); } + local_iterator end(size_type __n) { return _ElemsIte(_M_buckets[__n + 1]); } + + const_iterator begin() const { return __CONST_CAST(_ElemsCont&, _M_elems).begin(); } + const_iterator end() const { return __CONST_CAST(_ElemsCont&, _M_elems).end(); } + const_local_iterator begin(size_type __n) const { return _ElemsIte(_M_buckets[__n]); } + const_local_iterator end(size_type __n) const { return _ElemsIte(_M_buckets[__n + 1]); } + + //static bool _STLP_CALL _M_equal (const _Self&, const _Self&); + +public: + //The number of buckets is size() - 1 because the last bucket always contains + //_M_elems.end() to make algo easier to implement. + size_type bucket_count() const { return _M_buckets.size() - 1; } + size_type max_bucket_count() const { return _STLP_PRIV _Stl_prime_type::_S_max_nb_buckets(); } + size_type elems_in_bucket(size_type __bucket) const + { return _STLP_STD::distance(_ElemsIte(_M_buckets[__bucket]), _ElemsIte(_M_buckets[__bucket + 1])); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_bkt_num_key(__k); } + + // hash policy + float load_factor() const { return (float)size() / (float)bucket_count(); } + float max_load_factor() const { return _M_max_load_factor; } + void max_load_factor(float __z) { + _M_max_load_factor = __z; + _M_resize(); + } + + pair insert_unique(const value_type& __obj) { + _M_enlarge(_M_num_elements + 1); + return insert_unique_noresize(__obj); + } + + iterator insert_equal(const value_type& __obj) { + _M_enlarge(_M_num_elements + 1); + return insert_equal_noresize(__obj); + } + +protected: + iterator _M_insert_noresize(size_type __n, const value_type& __obj); +public: + pair insert_unique_noresize(const value_type& __obj); + iterator insert_equal_noresize(const value_type& __obj); + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert_unique(_InputIterator __f, _InputIterator __l) + { insert_unique(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIterator)); } + + template + void insert_equal(_InputIterator __f, _InputIterator __l) + { insert_equal(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIterator)); } + + template + void insert_unique(_InputIterator __f, _InputIterator __l, + const input_iterator_tag &) { + for ( ; __f != __l; ++__f) + insert_unique(*__f); + } + + template + void insert_equal(_InputIterator __f, _InputIterator __l, + const input_iterator_tag &) { + for ( ; __f != __l; ++__f) + insert_equal(*__f); + } + + template + void insert_unique(_ForwardIterator __f, _ForwardIterator __l, + const forward_iterator_tag &) { + size_type __n = _STLP_STD::distance(__f, __l); + _M_enlarge(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + template + void insert_equal(_ForwardIterator __f, _ForwardIterator __l, + const forward_iterator_tag &) { + size_type __n = _STLP_STD::distance(__f, __l); + _M_enlarge(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } + +#else /* _STLP_MEMBER_TEMPLATES */ + void insert_unique(const value_type* __f, const value_type* __l) { + size_type __n = __l - __f; + _M_enlarge(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + void insert_equal(const value_type* __f, const value_type* __l) { + size_type __n = __l - __f; + _M_enlarge(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } + + void insert_unique(const_iterator __f, const_iterator __l) { + size_type __n = _STLP_STD::distance(__f, __l); + _M_enlarge(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + void insert_equal(const_iterator __f, const_iterator __l) { + size_type __n = _STLP_STD::distance(__f, __l); + _M_enlarge(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } +#endif /*_STLP_MEMBER_TEMPLATES */ + + //reference find_or_insert(const value_type& __obj); + +private: + _STLP_TEMPLATE_FOR_CONT_EXT + _ElemsIte _M_find(const _KT& __key) const { + size_type __n = _M_bkt_num_key(__key); + _ElemsIte __first(_M_buckets[__n]); + _ElemsIte __last(_M_buckets[__n + 1]); + for ( ; (__first != __last) && !_M_equals(_M_get_key(*__first), __key); ++__first); + if (__first != __last) + return __first; + else + return __CONST_CAST(_ElemsCont&, _M_elems).end(); + } + +public: + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { + const size_type __n = _M_bkt_num_key(__key); + + _ElemsIte __cur(_M_buckets[__n]); + _ElemsIte __last(_M_buckets[__n + 1]); + for (; __cur != __last; ++__cur) { + if (_M_equals(_M_get_key(*__cur), __key)) { + size_type __result = 1; + for (++__cur; + __cur != __last && _M_equals(_M_get_key(*__cur), __key); + ++__result, ++__cur); + return __result; + } + } + return 0; + } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) { + typedef pair _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (_ElemsIte __first(_M_buckets[__n]), __last(_M_buckets[__n + 1]); + __first != __last; ++__first) { + if (_M_equals(_M_get_key(*__first), __key)) { + _ElemsIte __cur(__first); + for (++__cur; (__cur != __last) && _M_equals(_M_get_key(*__cur), __key); ++__cur); + return _Pii(__first, __cur); + } + } + return _Pii(end(), end()); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const { + typedef pair _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (_ElemsIte __first(_M_buckets[__n]), __last(_M_buckets[__n + 1]); + __first != __last; ++__first) { + if (_M_equals(_M_get_key(*__first), __key)) { + _ElemsIte __cur(__first); + for (++__cur; (__cur != __last) && _M_equals(_M_get_key(*__cur), __key); ++__cur); + return _Pii(__first, __cur); + } + } + return _Pii(end(), end()); + } + + size_type erase(const key_type& __key); + void erase(const_iterator __it); + void erase(const_iterator __first, const_iterator __last); + +private: + void _M_enlarge(size_type __n); + void _M_reduce(); + void _M_resize(); + void _M_rehash(size_type __num_buckets); +#if defined (_STLP_DEBUG) + void _M_check() const; +#endif + +public: + void rehash(size_type __num_buckets_hint); + void resize(size_type __num_buckets_hint) + { rehash(__num_buckets_hint); } + void clear(); + + // this is for hash_map::operator[] + reference _M_insert(const value_type& __obj); + +private: + //__n is set to the first bucket that has to be modified if any + //erase/insert operation is done after the returned iterator. + iterator _M_before_begin(size_type &__n) const; + + static iterator _S_before_begin(const _ElemsCont& __elems, const _BucketVector& __buckets, + size_type &__n); + + void _M_initialize_buckets(size_type __n) { + const size_type __n_buckets = _STLP_PRIV _Stl_prime_type::_S_next_size(__n) + 1; + _M_buckets.reserve(__n_buckets); + _M_buckets.assign(__n_buckets, __STATIC_CAST(_BucketType*, 0)); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type _M_bkt_num_key(const _KT& __key) const + { return _M_bkt_num_key(__key, bucket_count()); } + + size_type _M_bkt_num(const value_type& __obj) const + { return _M_bkt_num_key(_M_get_key(__obj)); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type _M_bkt_num_key(const _KT& __key, size_type __n) const + { return _M_hash(__key) % __n; } + + size_type _M_bkt_num(const value_type& __obj, size_t __n) const + { return _M_bkt_num_key(_M_get_key(__obj), __n); } + + void _M_copy_from(const _Self& __ht); +}; + +#if defined (_STLP_DEBUG) +# undef hashtable +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#if defined (_STLP_DEBUG) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > { + //Hashtables are movable: + typedef __true_type implemented; + + //Completeness depends on many template parameters, for the moment we consider it not complete: + typedef __false_type complete; +}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_HASHTABLE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_heap.c b/sdk/tlibstdcxx/stlport/stl/_heap.c new file mode 100644 index 0000000000..a4ab049fee --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_heap.c @@ -0,0 +1,246 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_HEAP_C +#define _STLP_HEAP_C + +#ifndef _STLP_INTERNAL_HEAP_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +_STLP_INLINE_LOOP +void +__push_heap(_RandomAccessIterator __first, + _Distance __holeIndex, _Distance __topIndex, _Tp __val) +{ + _Distance __parent = (__holeIndex - 1) / 2; + while (__holeIndex > __topIndex && *(__first + __parent) < __val) { + *(__first + __holeIndex) = *(__first + __parent); + __holeIndex = __parent; + __parent = (__holeIndex - 1) / 2; + } + *(__first + __holeIndex) = __val; +} + +template +inline void +__push_heap_aux(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Distance*, _Tp*) +{ + __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), + _Tp(*(__last - 1))); +} + +template +void +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + __push_heap_aux(__first, __last, + _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator), _STLP_VALUE_TYPE(__first, _RandomAccessIterator)); +} + + +template +_STLP_INLINE_LOOP +void +__push_heap(_RandomAccessIterator __first, _Distance __holeIndex, + _Distance __topIndex, _Tp __val, _Compare __comp) +{ + _Distance __parent = (__holeIndex - 1) / 2; + while (__holeIndex > __topIndex && __comp(*(__first + __parent), __val)) { + _STLP_VERBOSE_ASSERT(!__comp(__val, *(__first + __parent)), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + *(__first + __holeIndex) = *(__first + __parent); + __holeIndex = __parent; + __parent = (__holeIndex - 1) / 2; + } + *(__first + __holeIndex) = __val; +} + +template +inline void +__push_heap_aux(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp, + _Distance*, _Tp*) +{ + __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), + _Tp(*(__last - 1)), __comp); +} + +template +void +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) +{ + __push_heap_aux(__first, __last, __comp, + _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator), _STLP_VALUE_TYPE(__first, _RandomAccessIterator)); +} + +template +void +__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, + _Distance __len, _Tp __val) { + _Distance __topIndex = __holeIndex; + _Distance __secondChild = 2 * __holeIndex + 2; + while (__secondChild < __len) { + if (*(__first + __secondChild) < *(__first + (__secondChild - 1))) + __secondChild--; + *(__first + __holeIndex) = *(__first + __secondChild); + __holeIndex = __secondChild; + __secondChild = 2 * (__secondChild + 1); + } + if (__secondChild == __len) { + *(__first + __holeIndex) = *(__first + (__secondChild - 1)); + __holeIndex = __secondChild - 1; + } + __push_heap(__first, __holeIndex, __topIndex, __val); +} + + +template +inline void +__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp*) { + __pop_heap(__first, __last - 1, __last - 1, + _Tp(*(__last - 1)), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator)); +} + +template +void pop_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last) { + __pop_heap_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIterator)); +} + +template +void +__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, + _Distance __len, _Tp __val, _Compare __comp) +{ + _Distance __topIndex = __holeIndex; + _Distance __secondChild = 2 * __holeIndex + 2; + while (__secondChild < __len) { + if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) { + _STLP_VERBOSE_ASSERT(!__comp(*(__first + (__secondChild - 1)), *(__first + __secondChild)), + _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __secondChild--; + } + *(__first + __holeIndex) = *(__first + __secondChild); + __holeIndex = __secondChild; + __secondChild = 2 * (__secondChild + 1); + } + if (__secondChild == __len) { + *(__first + __holeIndex) = *(__first + (__secondChild - 1)); + __holeIndex = __secondChild - 1; + } + __push_heap(__first, __holeIndex, __topIndex, __val, __comp); +} + + +template +inline void +__pop_heap_aux(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Tp*, _Compare __comp) +{ + __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp, + _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator)); +} + + +template +void +pop_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) +{ + __pop_heap_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIterator), __comp); +} + +template +_STLP_INLINE_LOOP +void +__make_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Tp*, _Distance*) +{ + if (__last - __first < 2) return; + _Distance __len = __last - __first; + _Distance __parent = (__len - 2)/2; + + for (;;) { + __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent))); + if (__parent == 0) return; + __parent--; + } +} + +template +void +make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + __make_heap(__first, __last, + _STLP_VALUE_TYPE(__first, _RandomAccessIterator), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator)); +} + +template +_STLP_INLINE_LOOP +void +__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp, _Tp*, _Distance*) +{ + if (__last - __first < 2) return; + _Distance __len = __last - __first; + _Distance __parent = (__len - 2)/2; + + for (;;) { + __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)), + __comp); + if (__parent == 0) return; + __parent--; + } +} + +template +void +make_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) +{ + __make_heap(__first, __last, __comp, + _STLP_VALUE_TYPE(__first, _RandomAccessIterator), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator)); +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_HEAP_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_heap.h b/sdk/tlibstdcxx/stlport/stl/_heap.h new file mode 100644 index 0000000000..016dc490ee --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_heap.h @@ -0,0 +1,125 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_HEAP_H +#define _STLP_INTERNAL_HEAP_H + +_STLP_BEGIN_NAMESPACE + +// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap. + +template +void +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last); + + +template +void +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp); + +template +void +__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, + _Distance __len, _Tp __val); + +template +inline void +__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _RandomAccessIterator __result, _Tp __val, _Distance*) +{ + *__result = *__first; + __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __val); +} + +template +void pop_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last); + +template +void +__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, + _Distance __len, _Tp __val, _Compare __comp); + +template +inline void +__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _RandomAccessIterator __result, _Tp __val, _Compare __comp, + _Distance*) +{ + *__result = *__first; + __adjust_heap(__first, _Distance(0), _Distance(__last - __first), + __val, __comp); +} + +template +void +pop_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp); + +template +void +make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last); + +template +void +make_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp); + +template +_STLP_INLINE_LOOP +void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + while (__last - __first > 1) + pop_heap(__first, __last--); +} + +template +_STLP_INLINE_LOOP +void +sort_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) +{ + while (__last - __first > 1) + pop_heap(__first, __last--, __comp); +} + +_STLP_END_NAMESPACE + +# if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +# endif + +#endif /* _STLP_INTERNAL_HEAP_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_iomanip.h b/sdk/tlibstdcxx/stlport/stl/_iomanip.h new file mode 100644 index 0000000000..a27d95164c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_iomanip.h @@ -0,0 +1,165 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_IOMANIP +#define _STLP_INTERNAL_IOMANIP + +#ifndef _STLP_INTERNAL_ISTREAM +# include // Includes and +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +//---------------------------------------------------------------------- +// Machinery for defining manipulators. + +// Class that calls one of ios_base's single-argument member functions. +template +struct _Ios_Manip_1 { + typedef _Arg (ios_base::*__f_ptr_type)(_Arg); + + _Ios_Manip_1(__f_ptr_type __f, const _Arg& __arg) + : _M_f(__f), _M_arg(__arg) {} + + void operator()(ios_base& __ios) const + { (__ios.*_M_f)(_M_arg); } + + __f_ptr_type _M_f; + _Arg _M_arg; +}; + +// Class that calls one of ios_base's two-argument member functions. +struct _Ios_Setf_Manip { + ios_base::fmtflags _M_flag; + ios_base::fmtflags _M_mask; + bool _M_two_args; + + _Ios_Setf_Manip(ios_base::fmtflags __f) + : _M_flag(__f), _M_mask(0), _M_two_args(false) {} + + _Ios_Setf_Manip(ios_base::fmtflags __f, ios_base::fmtflags __m) + : _M_flag(__f), _M_mask(__m), _M_two_args(true) {} + + void operator()(ios_base& __ios) const { + if (_M_two_args) + __ios.setf(_M_flag, _M_mask); + else + __ios.setf(_M_flag); + } +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __istr, + const _STLP_PRIV _Ios_Manip_1<_Arg>& __f) { + __f(__istr); + return __istr; +} + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, + const _STLP_PRIV _Ios_Manip_1<_Arg>& __f) { + __f(__os); + return __os; +} + +template +inline basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __istr, + const _STLP_PRIV _Ios_Setf_Manip& __f) { + __f(__istr); + return __istr; +} + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, + const _STLP_PRIV _Ios_Setf_Manip& __f) { + __f(__os); + return __os; +} + +//---------------------------------------------------------------------- +// The ios_base manipulators. +inline _STLP_PRIV _Ios_Setf_Manip _STLP_CALL resetiosflags(ios_base::fmtflags __mask) +{ return _STLP_PRIV _Ios_Setf_Manip(0, __mask); } + +inline _STLP_PRIV _Ios_Setf_Manip _STLP_CALL setiosflags(ios_base::fmtflags __flag) +{ return _STLP_PRIV _Ios_Setf_Manip(__flag); } + +inline _STLP_PRIV _Ios_Setf_Manip _STLP_CALL setbase(int __n) { + ios_base::fmtflags __base = __n == 8 ? ios_base::oct : + __n == 10 ? ios_base::dec : + __n == 16 ? ios_base::hex : + ios_base::fmtflags(0); + return _STLP_PRIV _Ios_Setf_Manip(__base, ios_base::basefield); +} + +inline _STLP_PRIV _Ios_Manip_1 _STLP_CALL +setprecision(int __n) { + _STLP_PRIV _Ios_Manip_1::__f_ptr_type __f = &ios_base::precision; + return _STLP_PRIV _Ios_Manip_1(__f, __n); +} + +inline _STLP_PRIV _Ios_Manip_1 _STLP_CALL +setw(int __n) { + _STLP_PRIV _Ios_Manip_1::__f_ptr_type __f = &ios_base::width; + return _STLP_PRIV _Ios_Manip_1(__f, __n); +} + +//---------------------------------------------------------------------- +// setfill, a manipulator that operates on basic_ios<> instead of ios_base. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _Setfill_Manip { + _Setfill_Manip(_CharT __c) : _M_c(__c) {} + _CharT _M_c; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, + const _STLP_PRIV _Setfill_Manip<_CharT2>& __m) { + __os.fill(__m._M_c); + return __os; +} + +template +inline basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __is, + const _STLP_PRIV _Setfill_Manip<_CharT2>& __m) { + __is.fill(__m._M_c); + return __is; +} + +template +inline _STLP_PRIV _Setfill_Manip<_CharT> _STLP_CALL setfill(_CharT __c) +{ return _STLP_PRIV _Setfill_Manip<_CharT>(__c); } + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_IOMANIP */ diff --git a/sdk/tlibstdcxx/stlport/stl/_ios.c b/sdk/tlibstdcxx/stlport/stl/_ios.c new file mode 100644 index 0000000000..7dec77f08d --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ios.c @@ -0,0 +1,127 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_IOS_C +#define _STLP_IOS_C + +#ifndef _STLP_INTERNAL_IOS_H +# include +#endif + +#ifndef _STLP_INTERNAL_STREAMBUF +# include +#endif + +#ifndef _STLP_INTERNAL_NUMPUNCT_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// basic_ios<>'s non-inline member functions + +// Public constructor, taking a streambuf. +template +basic_ios<_CharT, _Traits> + ::basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf) + : ios_base(), _M_cached_ctype(0), + _M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0) { + basic_ios<_CharT, _Traits>::init(__streambuf); +} + +template +basic_streambuf<_CharT, _Traits>* +basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __buf) { + basic_streambuf<_CharT, _Traits>* __tmp = _M_streambuf; + _M_streambuf = __buf; + this->clear(); + return __tmp; +} + +template +basic_ios<_CharT, _Traits>& +basic_ios<_CharT, _Traits>::copyfmt(const basic_ios<_CharT, _Traits>& __x) { + _M_invoke_callbacks(erase_event); + _M_copy_state(__x); // Inherited from ios_base. + _M_cached_ctype = __x._M_cached_ctype; + _M_fill = __x._M_fill; + _M_tied_ostream = __x._M_tied_ostream; + _M_invoke_callbacks(copyfmt_event); + this->_M_set_exception_mask(__x.exceptions()); + return *this; +} + +template +locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) { + locale __tmp = ios_base::imbue(__loc); + _STLP_TRY { + if (_M_streambuf) + _M_streambuf->pubimbue(__loc); + + // no throwing here + _M_cached_ctype = &use_facet >(__loc); + } + _STLP_CATCH_ALL { + __tmp = ios_base::imbue(__tmp); + _M_handle_exception(ios_base::failbit); + } + return __tmp; +} + +// Protected constructor and initialization functions. The default +// constructor creates an uninitialized basic_ios, and init() initializes +// all of the members to the values in Table 89 of the C++ standard. + +template +basic_ios<_CharT, _Traits>::basic_ios() + : ios_base(), + _M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0) +{} + +template +void +basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb) +{ + this->rdbuf(__sb); + this->imbue(locale()); + this->tie(0); + this->_M_set_exception_mask(ios_base::goodbit); + this->_M_clear_nothrow(__sb != 0 ? ios_base::goodbit : ios_base::badbit); + ios_base::flags(ios_base::skipws | ios_base::dec); + ios_base::width(0); + ios_base::precision(6); + this->fill(widen(' ')); + // We don't need to worry about any of the three arrays: they are + // initialized correctly in ios_base's constructor. +} + +// This is never called except from within a catch clause. +template +void basic_ios<_CharT, _Traits>::_M_handle_exception(ios_base::iostate __flag) +{ + this->_M_setstate_nothrow(__flag); + if (this->_M_get_exception_mask() & __flag) + _STLP_RETHROW; +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_IOS_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_ios.h b/sdk/tlibstdcxx/stlport/stl/_ios.h new file mode 100644 index 0000000000..20422f0eab --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ios.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_INTERNAL_IOS_H +#define _STLP_INTERNAL_IOS_H + + +#ifndef _STLP_IOS_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_CTYPE_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUMPUNCT_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// ---------------------------------------------------------------------- + +// Class basic_ios, a subclass of ios_base. The only important difference +// between the two is that basic_ios is a class template, parameterized +// by the character type. ios_base exists to factor out all of the +// common properties that don't depend on the character type. + +// The second template parameter, _Traits, defaults to char_traits<_CharT>. +// The default is declared in header , and it isn't declared here +// because C++ language rules do not allow it to be declared twice. + +template +class basic_ios : public ios_base { + friend class ios_base; +public: // Synonyms for types. + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + +public: // Constructor, destructor. + explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf); + virtual ~basic_ios() {} + +public: // Members from clause 27.4.4.2 + basic_ostream<_CharT, _Traits>* tie() const { + return _M_tied_ostream; + } + basic_ostream<_CharT, _Traits>* + tie(basic_ostream* __new_tied_ostream) { + basic_ostream* __tmp = _M_tied_ostream; + _M_tied_ostream = __new_tied_ostream; + return __tmp; + } + + basic_streambuf<_CharT, _Traits>* rdbuf() const + { return _M_streambuf; } + + basic_streambuf<_CharT, _Traits>* + rdbuf(basic_streambuf*); + + // Copies __x's state to *this. + basic_ios<_CharT, _Traits>& copyfmt(const basic_ios<_CharT, _Traits>& __x); + + char_type fill() const { return _M_fill; } + char_type fill(char_type __fill) { + char_type __tmp(_M_fill); + _M_fill = __fill; + return __tmp; + } + +public: // Members from 27.4.4.3. These four functions + // can almost be defined in ios_base. + + void clear(iostate __state = goodbit) { + _M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit)); + _M_check_exception_mask(); + } + void setstate(iostate __state) { this->clear(rdstate() | __state); } + + iostate exceptions() const { return this->_M_get_exception_mask(); } + void exceptions(iostate __mask) { + this->_M_set_exception_mask(__mask); + this->clear(this->rdstate()); + } + +public: // Locale-related member functions. + locale imbue(const locale&); + + inline char narrow(_CharT, char) const ; + inline _CharT widen(char) const; + + // Helper function that makes testing for EOF more convenient. + static bool _STLP_CALL _S_eof(int_type __c) { + const int_type __eof = _Traits::eof(); + return _Traits::eq_int_type(__c, __eof); + } + +protected: + // Cached copy of the curent locale's ctype facet. Set by init() and imbue(). + const ctype* _M_cached_ctype; + +public: + // Equivalent to &use_facet< Facet >(getloc()), but faster. + const ctype* _M_ctype_facet() const { return _M_cached_ctype; } + +protected: + basic_ios(); + + void init(basic_streambuf<_CharT, _Traits>* __streambuf); + +public: + + // Helper function used in istream and ostream. It is called only from + // a catch clause. + void _M_handle_exception(ios_base::iostate __flag); + +private: // Data members + char_type _M_fill; // The fill character, used for padding. + + basic_streambuf<_CharT, _Traits>* _M_streambuf; + basic_ostream<_CharT, _Traits>* _M_tied_ostream; + +}; + + +template +inline char +basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const +{ return _M_ctype_facet()->narrow(__c, __default); } + +template +inline _CharT +basic_ios<_CharT, _Traits>::widen(char __c) const +{ return _M_ctype_facet()->widen(__c); } + +# if !defined (_STLP_NO_METHOD_SPECIALIZATION) +_STLP_TEMPLATE_NULL +inline char +basic_ios >::narrow(char __c, char) const +{ + return __c; +} + +_STLP_TEMPLATE_NULL +inline char +basic_ios >::widen(char __c) const +{ + return __c; +} +# endif /* _STLP_NO_METHOD_SPECIALIZATION */ + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_ios >; +# if ! defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_ios >; +# endif +# endif /* _STLP_USE_TEMPLATE_EXPORT */ + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_IOS */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_ios_base.h b/sdk/tlibstdcxx/stlport/stl/_ios_base.h new file mode 100644 index 0000000000..c9e10ad48e --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ios_base.h @@ -0,0 +1,345 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_IOS_BASE_H +#define _STLP_IOS_BASE_H + +#ifndef _STLP_INTERNAL_STDEXCEPT_BASE +# include +#endif + +#ifndef _STLP_INTERNAL_PAIR_H +# include +#endif + +#ifndef _STLP_INTERNAL_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// ---------------------------------------------------------------------- + +// Class ios_base. This is the base class of the ios hierarchy, which +// includes basic_istream and basic_ostream. Classes in the ios +// hierarchy are actually quite simple: they are just glorified +// wrapper classes. They delegate buffering and physical character +// manipulation to the streambuf classes, and they delegate most +// formatting tasks to a locale. + +class _STLP_CLASS_DECLSPEC ios_base { +public: + + class _STLP_CLASS_DECLSPEC failure : public __Named_exception { + public: + explicit failure(const string&); + virtual ~failure() _STLP_NOTHROW_INHERENTLY; + }; + + typedef int fmtflags; + typedef int iostate; + typedef int openmode; + typedef int seekdir; + +# ifndef _STLP_NO_ANACHRONISMS + typedef fmtflags fmt_flags; +# endif + + // Formatting flags. + _STLP_STATIC_CONSTANT(int, left = 0x0001); + _STLP_STATIC_CONSTANT(int, right = 0x0002); + _STLP_STATIC_CONSTANT(int, internal = 0x0004); + _STLP_STATIC_CONSTANT(int, dec = 0x0008); + _STLP_STATIC_CONSTANT(int, hex = 0x0010); + _STLP_STATIC_CONSTANT(int, oct = 0x0020); + _STLP_STATIC_CONSTANT(int, fixed = 0x0040); + _STLP_STATIC_CONSTANT(int, scientific = 0x0080); + _STLP_STATIC_CONSTANT(int, boolalpha = 0x0100); + _STLP_STATIC_CONSTANT(int, showbase = 0x0200); + _STLP_STATIC_CONSTANT(int, showpoint = 0x0400); + _STLP_STATIC_CONSTANT(int, showpos = 0x0800); + _STLP_STATIC_CONSTANT(int, skipws = 0x1000); + _STLP_STATIC_CONSTANT(int, unitbuf = 0x2000); + _STLP_STATIC_CONSTANT(int, uppercase = 0x4000); + _STLP_STATIC_CONSTANT(int, adjustfield = left | right | internal); + _STLP_STATIC_CONSTANT(int, basefield = dec | hex | oct); + _STLP_STATIC_CONSTANT(int, floatfield = scientific | fixed); + + // State flags. + _STLP_STATIC_CONSTANT(int, goodbit = 0x00); + _STLP_STATIC_CONSTANT(int, badbit = 0x01); + _STLP_STATIC_CONSTANT(int, eofbit = 0x02); + _STLP_STATIC_CONSTANT(int, failbit = 0x04); + + // Openmode flags. + _STLP_STATIC_CONSTANT(int, __default_mode = 0x0); /* implementation detail */ + _STLP_STATIC_CONSTANT(int, app = 0x01); + _STLP_STATIC_CONSTANT(int, ate = 0x02); + _STLP_STATIC_CONSTANT(int, binary = 0x04); + _STLP_STATIC_CONSTANT(int, in = 0x08); + _STLP_STATIC_CONSTANT(int, out = 0x10); + _STLP_STATIC_CONSTANT(int, trunc = 0x20); + + // Seekdir flags + _STLP_STATIC_CONSTANT(int, beg = 0x01); + _STLP_STATIC_CONSTANT(int, cur = 0x02); + _STLP_STATIC_CONSTANT(int, end = 0x04); + +public: // Flag-manipulation functions. + fmtflags flags() const { return _M_fmtflags; } + fmtflags flags(fmtflags __flags) { + fmtflags __tmp = _M_fmtflags; + _M_fmtflags = __flags; + return __tmp; + } + + fmtflags setf(fmtflags __flag) { + fmtflags __tmp = _M_fmtflags; + _M_fmtflags |= __flag; + return __tmp; + } + fmtflags setf(fmtflags __flag, fmtflags __mask) { + fmtflags __tmp = _M_fmtflags; + _M_fmtflags &= ~__mask; + _M_fmtflags |= __flag & __mask; + return __tmp; + } + void unsetf(fmtflags __mask) { _M_fmtflags &= ~__mask; } + + streamsize precision() const { return _M_precision; } + streamsize precision(streamsize __newprecision) { + streamsize __tmp = _M_precision; + _M_precision = __newprecision; + return __tmp; + } + + streamsize width() const { return _M_width; } + streamsize width(streamsize __newwidth) { + streamsize __tmp = _M_width; + _M_width = __newwidth; + return __tmp; + } + +public: // Locales + locale imbue(const locale&); + locale getloc() const { return _M_locale; } + +public: // Auxiliary storage. + static int _STLP_CALL xalloc(); + long& iword(int __index); + void*& pword(int __index); + +public: // Destructor. + virtual ~ios_base(); + +public: // Callbacks. + enum event { erase_event, imbue_event, copyfmt_event }; + typedef void (*event_callback)(event, ios_base&, int __index); + void register_callback(event_callback __fn, int __index); + +public: // This member function affects only + // the eight predefined ios objects: + // cin, cout, etc. + static bool _STLP_CALL sync_with_stdio(bool __sync = true); + +public: // The C++ standard requires only that these + // member functions be defined in basic_ios. + // We define them in the non-template + // base class to avoid code duplication. + operator void*() const { return !fail() ? (void*) __CONST_CAST(ios_base*,this) : (void*) 0; } + bool operator!() const { return fail(); } + + iostate rdstate() const { return _M_iostate; } + + bool good() const { return _M_iostate == 0; } + bool eof() const { return (_M_iostate & eofbit) != 0; } + bool fail() const { return (_M_iostate & (failbit | badbit)) != 0; } + bool bad() const { return (_M_iostate & badbit) != 0; } + +protected: // The functional protected interface. + + // Copies the state of __x to *this. This member function makes it + // possible to implement basic_ios::copyfmt without having to expose + // ios_base's private data members. Does not copy _M_exception_mask + // or _M_iostate. + void _M_copy_state(const ios_base& __x); + + void _M_setstate_nothrow(iostate __state) { _M_iostate |= __state; } + void _M_clear_nothrow(iostate __state) { _M_iostate = __state; } + iostate _M_get_exception_mask() const { return _M_exception_mask; } + void _M_set_exception_mask(iostate __mask) { _M_exception_mask = __mask; } + void _M_check_exception_mask() { + if (_M_iostate & _M_exception_mask) + _M_throw_failure(); + } + + void _M_invoke_callbacks(event); + void _STLP_FUNCTION_THROWS _M_throw_failure(); + + ios_base(); // Default constructor. + +protected: // Initialization of the I/O system + static void _STLP_CALL _S_initialize(); + static void _STLP_CALL _S_uninitialize(); + static bool _S_is_synced; + +private: // Invalidate the copy constructor and + // assignment operator. + ios_base(const ios_base&); + void operator=(const ios_base&); + +private: // Data members. + + fmtflags _M_fmtflags; // Flags + iostate _M_iostate; + openmode _M_openmode; + seekdir _M_seekdir; + iostate _M_exception_mask; + + streamsize _M_precision; + streamsize _M_width; + + locale _M_locale; + + pair* _M_callbacks; + size_t _M_num_callbacks; // Size of the callback array. + size_t _M_callback_index; // Index of the next available callback; + // initially zero. + + long* _M_iwords; // Auxiliary storage. The count is zero + size_t _M_num_iwords; // if and only if the pointer is null. + + void** _M_pwords; + size_t _M_num_pwords; + +public: + // ---------------------------------------------------------------------- + // Nested initializer class. This is an implementation detail, but it's + // prescribed by the standard. The static initializer object (on + // implementations where such a thing is required) is declared in + // + class _STLP_CLASS_DECLSPEC Init + { + public: + Init(); + ~Init(); + private: + static long _S_count; + friend class ios_base; + }; + + friend class Init; + +public: +# ifndef _STLP_NO_ANACHRONISMS + // 31.6 Old iostreams members [depr.ios.members] + typedef iostate io_state; + typedef openmode open_mode; + typedef seekdir seek_dir; + typedef _STLP_STD::streamoff streamoff; + typedef _STLP_STD::streampos streampos; +# endif +}; + +// ---------------------------------------------------------------------- +// ios_base manipulator functions, from section 27.4.5 of the C++ standard. +// All of them are trivial one-line wrapper functions. + +// fmtflag manipulators, section 27.4.5.1 +inline ios_base& _STLP_CALL boolalpha(ios_base& __s) + { __s.setf(ios_base::boolalpha); return __s;} + +inline ios_base& _STLP_CALL noboolalpha(ios_base& __s) + { __s.unsetf(ios_base::boolalpha); return __s;} + +inline ios_base& _STLP_CALL showbase(ios_base& __s) + { __s.setf(ios_base::showbase); return __s;} + +inline ios_base& _STLP_CALL noshowbase(ios_base& __s) + { __s.unsetf(ios_base::showbase); return __s;} + +inline ios_base& _STLP_CALL showpoint(ios_base& __s) + { __s.setf(ios_base::showpoint); return __s;} + +inline ios_base& _STLP_CALL noshowpoint(ios_base& __s) + { __s.unsetf(ios_base::showpoint); return __s;} + +inline ios_base& _STLP_CALL showpos(ios_base& __s) + { __s.setf(ios_base::showpos); return __s;} + +inline ios_base& _STLP_CALL noshowpos(ios_base& __s) + { __s.unsetf(ios_base::showpos); return __s;} + +inline ios_base& _STLP_CALL skipws(ios_base& __s) + { __s.setf(ios_base::skipws); return __s;} + +inline ios_base& _STLP_CALL noskipws(ios_base& __s) + { __s.unsetf(ios_base::skipws); return __s;} + +inline ios_base& _STLP_CALL uppercase(ios_base& __s) + { __s.setf(ios_base::uppercase); return __s;} + +inline ios_base& _STLP_CALL nouppercase(ios_base& __s) + { __s.unsetf(ios_base::uppercase); return __s;} + +inline ios_base& _STLP_CALL unitbuf(ios_base& __s) + { __s.setf(ios_base::unitbuf); return __s;} + +inline ios_base& _STLP_CALL nounitbuf(ios_base& __s) + { __s.unsetf(ios_base::unitbuf); return __s;} + + +// adjustfield manipulators, section 27.4.5.2 +inline ios_base& _STLP_CALL internal(ios_base& __s) + { __s.setf(ios_base::internal, ios_base::adjustfield); return __s; } + +inline ios_base& _STLP_CALL left(ios_base& __s) + { __s.setf(ios_base::left, ios_base::adjustfield); return __s; } + +inline ios_base& _STLP_CALL right(ios_base& __s) + { __s.setf(ios_base::right, ios_base::adjustfield); return __s; } + +// basefield manipulators, section 27.4.5.3 +inline ios_base& _STLP_CALL dec(ios_base& __s) + { __s.setf(ios_base::dec, ios_base::basefield); return __s; } + +inline ios_base& _STLP_CALL hex(ios_base& __s) + { __s.setf(ios_base::hex, ios_base::basefield); return __s; } + +inline ios_base& _STLP_CALL oct(ios_base& __s) + { __s.setf(ios_base::oct, ios_base::basefield); return __s; } + + +// floatfield manipulators, section 27.4.5.3 +inline ios_base& _STLP_CALL fixed(ios_base& __s) + { __s.setf(ios_base::fixed, ios_base::floatfield); return __s; } + +inline ios_base& _STLP_CALL scientific(ios_base& __s) + { __s.setf(ios_base::scientific, ios_base::floatfield); return __s; } + +_STLP_END_NAMESPACE + +#endif /* _STLP_IOS_BASE */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_ioserr.h b/sdk/tlibstdcxx/stlport/stl/_ioserr.h new file mode 100644 index 0000000000..83ba8775b6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ioserr.h @@ -0,0 +1,12 @@ +/* + * This file is included in every header that needs the STLport library to be + * built; the header files mostly are the iostreams-headers. The file checks for + * _STLP_USE_NO_IOSTREAMS or _STLP_NO_IOSTREAMS being not defined, so that the + * iostreams part of STLport cannot be used when the symbols were defined + * accidentally. + */ +#if defined (_STLP_NO_IOSTREAMS) +# error STLport iostreams header cannot be used; you chose not to use iostreams in the STLport configuration file (stlport/stl/config/user_config.h). +#elif defined (_STLP_USE_NO_IOSTREAMS ) +# error STLport iostreams header cannot be used; your compiler do not support it. +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_iosfwd.h b/sdk/tlibstdcxx/stlport/stl/_iosfwd.h new file mode 100644 index 0000000000..e31db319c8 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_iosfwd.h @@ -0,0 +1,159 @@ +#ifndef _STLP_INTERNAL_IOSFWD +#define _STLP_INTERNAL_IOSFWD + +#if defined (__sgi) && !defined (__GNUC__) && !defined (_STANDARD_C_PLUS_PLUS) +# error This header file requires the -LANG:std option +#endif + +// This file provides forward declarations of the most important I/O +// classes. Note that almost all of those classes are class templates, +// with default template arguments. According to the C++ standard, +// if a class template is declared more than once in the same scope +// then only one of those declarations may have default arguments. + +// contains the same declarations as other headers, and including +// both and (say) is permitted. This means that only +// one header may contain those default template arguments. + +// In this implementation, the declarations in contain default +// template arguments. All of the other I/O headers include . + +#ifndef _STLP_CHAR_TRAITS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +class ios_base; + +template ) > +class basic_ios; + +template ) > +class basic_streambuf; + +template ) > +class basic_istream; + +template ) > +class basic_ostream; + +template ) > +class basic_iostream; + +template ), + _STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) > +class basic_stringbuf; + +template ), + _STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) > +class basic_istringstream; + +template ), + _STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) > +class basic_ostringstream; + +template ), + _STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) > +class basic_stringstream; + +template ) > +class basic_filebuf; + +template ) > +class basic_ifstream; + +template ) > +class basic_ofstream; + +template ) > +class basic_fstream; + +template ) > +class istreambuf_iterator; + +template ) > +class ostreambuf_iterator; + +typedef basic_ios > ios; + +#if !defined (_STLP_NO_WCHAR_T) +typedef basic_ios > wios; +#endif + +// Forward declaration of class locale, and of the most important facets. +class locale; +template +#if defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) +struct _Use_facet { + const locale& __loc; + _Use_facet(const locale& __p_loc) : __loc(__p_loc) {} + inline const _Facet& operator *() const; +}; +# define use_facet *_Use_facet +#else +inline const _Facet& use_facet(const locale&); +#endif + +template class ctype; +template class ctype_byname; +template class collate; +template class collate_byname; + +_STLP_TEMPLATE_NULL class ctype; +_STLP_TEMPLATE_NULL class ctype_byname; +_STLP_TEMPLATE_NULL class collate; +_STLP_TEMPLATE_NULL class collate_byname; + +#if !defined (_STLP_NO_WCHAR_T) +_STLP_TEMPLATE_NULL class ctype; +_STLP_TEMPLATE_NULL class ctype_byname; +_STLP_TEMPLATE_NULL class collate; +_STLP_TEMPLATE_NULL class collate_byname; +#endif + +#if !(defined (__SUNPRO_CC) && __SUNPRO_CC < 0x500 ) +// Typedefs for ordinary (narrow-character) streams. +//_STLP_TEMPLATE_NULL class basic_streambuf >; +#endif + +typedef basic_istream > istream; +typedef basic_ostream > ostream; +typedef basic_iostream > iostream; +typedef basic_streambuf > streambuf; + +typedef basic_stringbuf, allocator > stringbuf; +typedef basic_istringstream, allocator > istringstream; +typedef basic_ostringstream, allocator > ostringstream; +typedef basic_stringstream, allocator > stringstream; + +typedef basic_filebuf > filebuf; +typedef basic_ifstream > ifstream; +typedef basic_ofstream > ofstream; +typedef basic_fstream > fstream; + +#if !defined (_STLP_NO_WCHAR_T) +// Typedefs for wide-character streams. +typedef basic_streambuf > wstreambuf; +typedef basic_istream > wistream; +typedef basic_ostream > wostream; +typedef basic_iostream > wiostream; + +typedef basic_stringbuf, allocator > wstringbuf; +typedef basic_istringstream, allocator > wistringstream; +typedef basic_ostringstream, allocator > wostringstream; +typedef basic_stringstream, allocator > wstringstream; + +typedef basic_filebuf > wfilebuf; +typedef basic_ifstream > wifstream; +typedef basic_ofstream > wofstream; +typedef basic_fstream > wfstream; +#endif + +_STLP_END_NAMESPACE + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_iostream_string.h b/sdk/tlibstdcxx/stlport/stl/_iostream_string.h new file mode 100644 index 0000000000..87656a4ce5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_iostream_string.h @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + /* + * This is an internal string for the STLport own iostream implementation. + * The only diference rely on the allocator used to instanciate the basic_string. + * Its goals is to improve performance limitating the number of dynamic allocation + * that could occur when requesting a big float ouput for instance. This allocator + * is not standard conformant as it has an internal state (the static buffer) + */ + + +#ifndef _STLP_INTERNAL_IOSTREAM_STRING_H +#define _STLP_INTERNAL_IOSTREAM_STRING_H + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif /* _STLP_INTERNAL_ALLOC_H */ + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif /* _STLP_INTERNAL_STRING_H */ + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class __iostring_allocator : public allocator<_CharT> { +public: + enum { _STR_SIZE = 256 }; + +private: + enum { _BUF_SIZE = _STR_SIZE + 1 }; + typedef allocator<_CharT> _Base; + _CharT _M_static_buf[_BUF_SIZE]; + +public: + typedef typename _Base::size_type size_type; + typedef typename _Base::pointer pointer; +#if defined (_STLP_MEMBER_TEMPLATE_CLASSES) + template struct rebind { +# if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1300) + typedef __iostring_allocator<_Tp1> other; +# else + typedef _STLP_PRIV __iostring_allocator<_Tp1> other; +# endif + }; +#endif + + _CharT* allocate(size_type __n, const void* __ptr = 0) { + if (__n > _BUF_SIZE) { + return _Base::allocate(__n, __ptr); + } + return _M_static_buf; + } + void deallocate(pointer __p, size_type __n) { + if (__p != _M_static_buf) _Base::deallocate(__p, __n); + } +}; + +#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) || !defined (_STLP_MEMBER_TEMPLATES) +/* + * As the __iostring_allocator allocator will only be used in the basic_string implementation + * we known that it is never going to be bound to another type that the one used to instantiate + * the basic_string. This is why the associated __stl_alloc_rebind has only one template + * parameter. + */ +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _STLP_PRIV __iostring_allocator<_Tp>& _STLP_CALL +__stl_alloc_rebind(_STLP_PRIV __iostring_allocator<_Tp>& __a, const _Tp*) +{ return __a; } +template +inline _STLP_PRIV __iostring_allocator<_Tp> _STLP_CALL +__stl_alloc_create(const _STLP_PRIV __iostring_allocator<_Tp>&, const _Tp*) +{ return _STLP_PRIV __iostring_allocator<_Tp>(); } + +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE */ + +#if !defined (_STLP_DEBUG) +template +struct __basic_iostring : public basic_string<_CharT, char_traits<_CharT>, __iostring_allocator<_CharT> > { + /* + * A consequence of the non standard conformant allocator is that a string using it + * must always be presized to the allocator static buffer size because the basic_string implementation + * do not manage an allocator returning always the same memory adress as long as the + * requested memory block size is under a certain value. + */ + typedef __basic_iostring<_CharT> _Self; + typedef basic_string<_CharT, char_traits<_CharT>, __iostring_allocator<_CharT> > _Base; + typedef typename _Base::_Reserve_t _Reserve_t; + + __basic_iostring() : _Base(_Reserve_t(), __iostring_allocator<_CharT>::_STR_SIZE) + {} + + _Self& operator=(const _CharT* __s) { + _Base::operator=(__s); + return *this; + } +}; + +typedef __basic_iostring __iostring; + +# if !defined (_STLP_NO_WCHAR_T) +typedef __basic_iostring __iowstring; +# endif + +# define _STLP_BASIC_IOSTRING(_CharT) _STLP_PRIV __basic_iostring<_CharT> + +#else + +typedef string __iostring; +# if !defined (_STLP_NO_WCHAR_T) +typedef wstring __iowstring; +# endif + +# define _STLP_BASIC_IOSTRING(_CharT) basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > + +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_IOSTREAM_STRING_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/_istream.c b/sdk/tlibstdcxx/stlport/stl/_istream.c new file mode 100644 index 0000000000..ab327b2969 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_istream.c @@ -0,0 +1,1429 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_ISTREAM_C +#define _STLP_ISTREAM_C + +#ifndef _STLP_INTERNAL_ISTREAM +# include +#endif + +#ifndef _STLP_INTERNAL_LIMITS +# include +#endif + +#ifndef _STLP_INTERNAL_NUM_GET_H +# include +#endif + +#if defined ( _STLP_NESTED_TYPE_PARAM_BUG ) +// no wchar_t is supported for this mode +# define __BIS_int_type__ int +# define __BIS_pos_type__ streampos +# define __BIS_off_type__ streamoff +#else +# define __BIS_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::int_type +# define __BIS_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::pos_type +# define __BIS_off_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::off_type +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// Function object structs used by some member functions. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _Is_not_wspace { + typedef typename _Traits::char_type argument_type; + typedef bool result_type; + + const ctype* _M_ctype; + + _Is_not_wspace(const ctype* __c_type) : _M_ctype(__c_type) {} + bool operator()(argument_type __c) const + { return !_M_ctype->is(ctype_base::space, __c); } +}; + +template +struct _Is_wspace_null { + typedef typename _Traits::char_type argument_type; + typedef bool result_type; + + const ctype* _M_ctype; + + _Is_wspace_null(const ctype* __c_type) : _M_ctype(__c_type) {} + bool operator()(argument_type __c) const { + return _Traits::eq(__c, argument_type()) || + _M_ctype->is(ctype_base::space, __c); + } +}; + +template +struct _Scan_for_wspace { + typedef typename _Traits::char_type char_type; + typedef char_type* first_argument_type; + typedef char_type* second_argument_type; + typedef char_type* result_type; + + const ctype* _M_ctype; + + _Scan_for_wspace(const ctype* __ctype) : _M_ctype(__ctype) {} + const char_type* + operator()(const char_type* __first, const char_type* __last) const { + return _M_ctype->scan_is(ctype_base::space, __first, __last); + } +}; + +template +struct _Scan_wspace_null { + typedef typename _Traits::char_type char_type; + typedef char_type* first_argument_type; + typedef char_type* second_argument_type; + typedef char_type* result_type; + + const ctype* _M_ctype; + + _Scan_wspace_null(const ctype* __c_type) : _M_ctype(__c_type) {} + const char_type* + operator()(const char_type* __first, const char_type* __last) const { + __last = find_if(__first, __last, + _Eq_char_bound<_Traits>(char_type())); + return _M_ctype->scan_is(ctype_base::space, __first, __last); + } +}; + +template +struct _Scan_for_not_wspace { + typedef typename _Traits::char_type char_type; + typedef char_type* first_argument_type; + typedef char_type* second_argument_type; + typedef char_type* result_type; + + const ctype* _M_ctype; + + _Scan_for_not_wspace(const ctype* __c_type) : _M_ctype(__c_type) {} + const char_type* + operator()(const char_type* __first, const char_type* __last) const { + return _M_ctype->scan_not(ctype_base::space, __first, __last); + } +}; + +template +struct _Scan_for_char_val { + typedef typename _Traits::char_type char_type; + typedef char_type* first_argument_type; + typedef char_type* second_argument_type; + typedef char_type* result_type; + + char_type _M_val; + + _Scan_for_char_val(char_type __val) : _M_val(__val) {} + + const char_type* + operator()(const char_type* __first, const char_type* __last) const { + return find_if(__first, __last, _Eq_char_bound<_Traits>(_M_val)); + } +}; + +template +struct _Scan_for_int_val { + typedef typename _Traits::char_type char_type; + typedef typename _Traits::int_type int_type; + typedef char_type* first_argument_type; + typedef char_type* second_argument_type; + typedef char_type* result_type; + + int_type _M_val; + + _Scan_for_int_val(int_type __val) : _M_val(__val) {} + + const char_type* + operator()(const char_type* __first, const char_type* __last) const { + return find_if(__first, __last, + _Eq_int_bound<_Traits>(_M_val)); + } +}; + +// Helper function: try to push back a character to a streambuf, +// return true if the pushback succeeded. Does not throw. + +template +bool _STLP_CALL +__pushback(basic_streambuf<_CharT, _Traits>* __buf, _CharT __c) { + bool ret; + _STLP_TRY { + const typename _Traits::int_type __eof = _Traits::eof(); + ret = !_Traits::eq_int_type(__buf->sputbackc(__c), __eof); + } + _STLP_CATCH_ALL { + ret = false; + } + return ret; +} + +//---------------------------------------------------------------------- +// Definitions of basic_istream<>'s noninline member functions. + +// Helper function for formatted input of numbers. +template +ios_base::iostate _STLP_CALL +__get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val) { + typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry; + ios_base::iostate __err = 0; + _Sentry __sentry( __that ); // Skip whitespace. + if (__sentry) { + typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > _Num_get; + _STLP_TRY { + // Do not remove additional parenthesis around use_facet instanciation, some compilers (VC6) + // require it when building the library. + (use_facet<_Num_get>(__that.getloc())).get(istreambuf_iterator<_CharT, _Traits>(__that.rdbuf()), + 0, __that, __err, __val); + } + _STLP_CATCH_ALL { + __that._M_handle_exception(ios_base::badbit); + } + if (__err) __that.setstate(__err); + } + return __err; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (short& __val) { + long __lval; + _STLP_PRIV __get_num(*this, __lval); + if ( this->fail() ) { + return *this; + } + short __tmp = __STATIC_CAST(short, __lval); + unsigned short __uval = __STATIC_CAST(unsigned short, __lval); + // check if we lose digits + // if ((__val != __lval) && ((unsigned short)__val != __lval)) + if ((__tmp != __lval) && ((long)__uval != __lval)) + this->setstate(ios_base::failbit); + else + __val = __tmp; + return *this; +} + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (int& __val) { + long __lval; + _STLP_PRIV __get_num(*this, __lval); + if ( this->fail() ) { + return *this; + } + int __tmp = __lval; + unsigned int __uval = __lval; + // check if we lose digits + // if ((__val != __lval) && ((unsigned int)__val != __lval)) + if ((__tmp != __lval) && ((long)__uval != __lval)) + this->setstate(ios_base::failbit); + else + __val = __tmp; + return *this; +} + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned short& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned int& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (long& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned long& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} + +#if defined (_STLP_LONG_LONG) +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (_STLP_LONG_LONG& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned _STLP_LONG_LONG& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} +#endif +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (float& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (double& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} +#if !defined (_STLP_NO_LONG_DOUBLE) +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (long double& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} +#endif +#if !defined (_STLP_NO_BOOL) +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (bool& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} +#endif + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (void*& __val) { + _STLP_PRIV __get_num(*this, __val); + return *this; +} + +// Unformatted input + +template +__BIS_int_type__ +basic_istream<_CharT, _Traits>::peek() { + typename _Traits::int_type __tmp = _Traits::eof(); + + this->_M_gcount = 0; + sentry __sentry(*this, _No_Skip_WS()); + + if (__sentry) { + _STLP_TRY { + __tmp = this->rdbuf()->sgetc(); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + if (this->_S_eof(__tmp)) + this->setstate(ios_base::eofbit); + } + + return __tmp; +} + + +template +__BIS_int_type__ +basic_istream<_CharT, _Traits>::get() { + typename _Traits::int_type __tmp = _Traits::eof(); + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + _STLP_TRY { + __tmp = this->rdbuf()->sbumpc(); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + + if (!this->_S_eof(__tmp)) + this->_M_gcount = 1; + } + + if (_M_gcount == 0) + this->setstate(ios_base::eofbit | ios_base::failbit); + + return __tmp; +} + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::get(_CharT& __c) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + typename _Traits::int_type __tmp = _Traits::eof(); + _STLP_TRY { + __tmp = this->rdbuf()->sbumpc(); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + + if (!this->_S_eof(__tmp)) { + this->_M_gcount = 1; + __c = _Traits::to_char_type(__tmp); + } + } + + if (this->_M_gcount == 0) + this->setstate(ios_base::eofbit | ios_base::failbit); + + return *this; +} + + +// Read characters and discard them. The standard specifies a single +// function with two arguments, each with a default. We instead use +// three overloded functions, because it's possible to implement the +// first two more efficiently than the fully general third version. +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore() { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + int_type __c; + _STLP_TRY { + __c = this->rdbuf()->sbumpc(); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + return *this; + } + + if (!this->_S_eof(__c)) + this->_M_gcount = 1; + else + this->setstate(ios_base::eofbit); + } + + return *this; +} + +// Putback + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::putback(_CharT __c) { + this->_M_gcount = 0; + sentry __sentry(*this, _No_Skip_WS()); + + if (__sentry) { + typename _Traits::int_type __tmp = _Traits::eof(); + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); +// if (!__buf || this->_S_eof(__buf->sputbackc(__c))) + if (__buf) { + _STLP_TRY { + __tmp = __buf->sputbackc(__c); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + } + if (this->_S_eof(__tmp)) + this->setstate(ios_base::badbit); + } + else + this->setstate(ios_base::failbit); + + return *this; +} + +template +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { + this->_M_gcount = 0; + + sentry __sentry(*this, _No_Skip_WS()); + + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + // if (!__buf || _Traits::eq_int_type(__buf->sungetc(), _Traits::eof())) + if (__buf) { + _STLP_TRY { + if (this->_S_eof(__buf->sungetc())) + this->setstate(ios_base::badbit); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + } else + this->setstate(ios_base::badbit); + } + else + this->setstate(ios_base::failbit); + + return *this; +} + +// Positioning and buffer control. + +template +int basic_istream<_CharT, _Traits>::sync() { + sentry __sentry(*this, _No_Skip_WS()); + + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + if (__buf) { + if (__buf->pubsync() == -1) { + this->setstate(ios_base::badbit); + return -1; + } + else + return 0; + } + else + return -1; +} + +template +__BIS_pos_type__ +basic_istream<_CharT, _Traits>::tellg() { + sentry __sentry(*this, _No_Skip_WS()); + + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + return (__buf && !this->fail()) ? __buf->pubseekoff(0, ios_base::cur, ios_base::in) + : pos_type(-1); +} + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::seekg(pos_type __pos) { + sentry __sentry(*this, _No_Skip_WS()); + + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + if (!this->fail() && __buf) { + if (__buf->pubseekpos(__pos, ios_base::in) == pos_type(-1)) { + this->setstate(ios_base::failbit); + } + } + return *this; +} + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) { + sentry __sentry(*this, _No_Skip_WS()); + + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + if (!this->fail() && __buf) + __buf->pubseekoff(__off, __dir, ios_base::in); + return *this; +} + +// Formatted input of characters and character arrays. + +template +void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT& __c) { +// typename _Traits::int_type __tmp = _Traits::eof(); + + sentry __sentry(*this); // Skip whitespace. + + if (__sentry) { + typename _Traits::int_type __tmp;// = _Traits::eof(); + + _STLP_TRY { + __tmp = this->rdbuf()->sbumpc(); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + return; + } + + if (!this->_S_eof(__tmp)) + __c = _Traits::to_char_type(__tmp); + else + this->setstate(ios_base::eofbit | ios_base::failbit); + } +} + + +//--------------------------------------------------------------------------- +// istream's helper functions. + +// A generic function for unbuffered input. We stop when we reach EOF, +// or when we have extracted _Num characters, or when the function object +// __is_delim return true. In the last case, it extracts the character +// for which __is_delim is true, if and only if __extract_delim is true. +// It appends a null character to the end of the string; this means that +// it may store up to _Num + 1 characters. +// +// __is_getline governs two corner cases: reading _Num characters without +// encountering delim or eof (in which case failbit is set if __is_getline +// is true); and reading _Num characters where the _Num+1'st character is +// eof (in which case eofbit is set if __is_getline is true). +// +// It is assumed that __is_delim never throws. +// +// Return value is the number of characters extracted, including the +// delimiter if it is extracted. Note that the number of characaters +// extracted isn't necessarily the same as the number stored. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template < class _CharT, class _Traits, class _Is_Delim> +streamsize _STLP_CALL +__read_unbuffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf, + streamsize _Num, _CharT* __s, + _Is_Delim __is_delim, + bool __extract_delim, bool __append_null, + bool __is_getline) +{ + streamsize __n = 0; + ios_base::iostate __status = 0; + + typedef typename basic_istream<_CharT, _Traits>::int_type int_type; + // The operations that can potentially throw are sbumpc, snextc, and sgetc. + _STLP_TRY { + for (;;) { + if (__n == _Num) { + if (__is_getline) // didn't find delimiter as one of the _Num chars + __status |= ios_base::failbit; + break; + } + int_type __c = __buf->sbumpc(); // sschwarz + + if (__that->_S_eof(__c)) { + if (__n < _Num || __is_getline) + __status |= ios_base::eofbit; + break; + } else if (__is_delim(_Traits::to_char_type(__c))) { + if (__extract_delim) { // Extract and discard current character. + ++__n; + } else if ( !__pushback(__buf, _Traits::to_char_type(__c)) ) { // leave delimiter + __status |= ios_base::failbit; + } + break; + } + // regular character + *__s++ = _Traits::to_char_type(__c); + ++__n; + } + } + _STLP_CATCH_ALL { + __that->_M_handle_exception(ios_base::badbit); + *__s = _STLP_DEFAULT_CONSTRUCTED(_CharT); + return __n; + } + + if (__append_null) + *__s = _STLP_DEFAULT_CONSTRUCTED(_CharT); + if (__status) + __that->setstate(__status); // This might throw. + return __n; +} + +// Much like __read_unbuffered, but with one additional function object: +// __scan_delim(first, last) returns the first pointer p in [first, last) +// such that __is_delim(p) is true. + +template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim> +streamsize _STLP_CALL +__read_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf, + streamsize _Num, _CharT* __s, + _Is_Delim __is_delim, _Scan_Delim __scan_delim, + bool __extract_delim, bool __append_null, + bool __is_getline) { + streamsize __n = 0; + ios_base::iostate __status = 0; + bool __done = false; + + _STLP_TRY { + while (__buf->_M_egptr() != __buf->_M_gptr() && !__done) { + const _CharT* __first = __buf->_M_gptr(); + const _CharT* __last = __buf->_M_egptr(); + //casting numeric_limits::max to streamsize only works is ptrdiff_t is signed or streamsize representation + //is larger than ptrdiff_t one. + _STLP_STATIC_ASSERT((sizeof(streamsize) > sizeof(ptrdiff_t)) || + ((sizeof(streamsize) == sizeof(ptrdiff_t)) && numeric_limits::is_signed)) + ptrdiff_t __request = __STATIC_CAST(ptrdiff_t, (min) (__STATIC_CAST(streamsize, (numeric_limits::max)()), _Num - __n)); + + const _CharT* __p = __scan_delim(__first, __last); + ptrdiff_t __chunk = (min) (ptrdiff_t(__p - __first), __request); + _Traits::copy(__s, __first, __chunk); + __s += __chunk; + __n += __chunk; + __buf->_M_gbump((int)__chunk); + + // We terminated by finding delim. + if (__p != __last && __p - __first <= __request) { + if (__extract_delim) { + __n += 1; + __buf->_M_gbump(1); + } + __done = true; + } + + // We terminated by reading all the characters we were asked for. + else if (__n == _Num) { + + // Find out if we have reached eof. This matters for getline. + if (__is_getline) { + if (__chunk == __last - __first) { + if (__that->_S_eof(__buf->sgetc())) + __status |= ios_base::eofbit; + } + else + __status |= ios_base::failbit; + } + __done = true; + } + + // The buffer contained fewer than _Num - __n characters. Either we're + // at eof, or we should refill the buffer and try again. + else { + if (__that->_S_eof(__buf->sgetc())) { + __status |= ios_base::eofbit; + __done = true; + } + } + } // Close the while loop. + } + _STLP_CATCH_ALL { + __that->_M_handle_exception(ios_base::badbit); + __done = true; + } + + if (__done) { + if (__append_null) + *__s = _STLP_DEFAULT_CONSTRUCTED(_CharT); + if (__status != 0) + __that->setstate(__status); // This might throw. + return __n; + } + + // If execution has reached this point, then we have an empty buffer but + // we have not reached eof. What that means is that the streambuf has + // decided to switch from buffered to unbuffered input. We switch to + // to __read_unbuffered. + + return __n + __read_unbuffered(__that, __buf, _Num - __n, __s, __is_delim, + __extract_delim,__append_null,__is_getline); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::get(_CharT* __s, streamsize __n, + _CharT __delim) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + if (__n > 0) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + + if (__buf->egptr() != __buf->gptr()) + this->_M_gcount = + _STLP_PRIV __read_buffered(this, __buf, __n - 1, __s, + _STLP_PRIV _Eq_char_bound<_Traits>(__delim), + _STLP_PRIV _Scan_for_char_val<_Traits>(__delim), + false, true, false); + else + this->_M_gcount = + _STLP_PRIV __read_unbuffered(this, __buf, __n - 1, __s, + _STLP_PRIV _Eq_char_bound<_Traits>(__delim), + false, true, false); + } + } + + if (this->_M_gcount == 0) + this->setstate(ios_base::failbit); + + return *this; +} + +// Getline is essentially identical to get, except that it extracts +// the delimiter. +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::getline(_CharT* __s, streamsize __n, + _CharT __delim) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + if (__n > 0) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + this->_M_gcount = __buf->egptr() != __buf->gptr() + ? _STLP_PRIV __read_buffered(this, __buf, __n - 1, __s, + _STLP_PRIV _Eq_char_bound<_Traits>(__delim), + _STLP_PRIV _Scan_for_char_val<_Traits>(__delim), + true, true, true) + : _STLP_PRIV __read_unbuffered(this, __buf, __n - 1, __s, + _STLP_PRIV _Eq_char_bound<_Traits>(__delim), + true, true, true); + } + } + + if (this->_M_gcount == 0) + this->setstate(ios_base::failbit); + + return *this; +} + +// Read n characters. We don't look for any delimiter, and we don't +// put in a terminating null character. +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry && !this->eof()) { + basic_streambuf<_CharT, _Traits>*__buf = this->rdbuf(); + if (__buf->gptr() != __buf->egptr()) + _M_gcount + = _STLP_PRIV __read_buffered(this, __buf, __n, __s, + _STLP_PRIV _Constant_unary_fun(false), + _STLP_PRIV _Project2nd(), + false, false, false); + else + _M_gcount + = _STLP_PRIV __read_unbuffered(this, __buf, __n, __s, + _STLP_PRIV _Constant_unary_fun(false), + false, false, false); + } + else + this->setstate(ios_base::failbit); + + if (this->eof()) + this->setstate(ios_base::eofbit | ios_base::failbit); + + return *this; +} + + +// Read n or fewer characters. We don't look for any delimiter, and +// we don't put in a terminating null character. +template +streamsize +basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __nmax) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry && !this->eof() && __nmax >= 0) { + + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + streamsize __avail = __buf->in_avail(); + + // fbp : isn't full-blown setstate required here ? + if (__avail == -1) + this->_M_setstate_nothrow(ios_base::eofbit); + + else if (__avail != 0) { + + if (__buf->gptr() != __buf->egptr()) + _M_gcount + = _STLP_PRIV __read_buffered(this, __buf, (min) (__avail, __nmax), __s, + _STLP_PRIV _Constant_unary_fun(false), + _STLP_PRIV _Project2nd(), + false, false, false); + else + _M_gcount + = _STLP_PRIV __read_unbuffered(this, __buf, (min) (__avail, __nmax), __s, + _STLP_PRIV _Constant_unary_fun(false), + false, false, false); + } + } + else { + // fbp : changed so that failbit is set only there, to pass Dietmar's test + if (this->eof()) + this->setstate(ios_base::eofbit | ios_base::failbit); + else + this->setstate(ios_base::failbit); + } + + // if (this->eof()) + // this->setstate(ios_base::eofbit | ios_base::failbit); + + return _M_gcount; +} + +template +void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT* __s) { + sentry __sentry(*this); // Skip whitespace. + + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + streamsize __nmax = this->width() > 0 + ? this->width() - 1 + : ((numeric_limits::max)() / sizeof(_CharT)) - 1; + + streamsize __n = __buf->gptr() != __buf->egptr() + ? _STLP_PRIV __read_buffered(this, __buf, __nmax, __s, + _STLP_PRIV _Is_wspace_null<_Traits>(this->_M_ctype_facet()), + _STLP_PRIV _Scan_wspace_null<_Traits>(this->_M_ctype_facet()), + false, true, false) + : _STLP_PRIV __read_unbuffered(this, __buf, __nmax, __s, + _STLP_PRIV _Is_wspace_null<_Traits>(this->_M_ctype_facet()), + false, true, false); + if (__n == 0) + this->setstate(ios_base::failbit); + } + this->width(0); +} + +// A generic unbuffered function for ignoring characters. We stop +// when we reach EOF, or when the function object __is_delim returns +// true. In the last case, it extracts the character for which +// __is_delim is true, if and only if __extract_delim is true. + +template < class _CharT, class _Traits, class _Is_Delim> +void _STLP_CALL +_M_ignore_unbuffered(basic_istream<_CharT, _Traits>* __that, + basic_streambuf<_CharT, _Traits>* __buf, + _Is_Delim __is_delim, + bool __extract_delim, bool __set_failbit) { + bool __done = false; + ios_base::iostate __status = 0; + typedef typename basic_istream<_CharT, _Traits>::int_type int_type; + + _STLP_TRY { + while (!__done) { + int_type __c = __buf->sbumpc(); + + if (__that->_S_eof(__c)) { + __done = true; + __status |= __set_failbit ? ios_base::eofbit | ios_base::failbit + : ios_base::eofbit; + } + + else if (__is_delim(_Traits::to_char_type(__c))) { + __done = true; + if (!__extract_delim) + if (__that->_S_eof(__buf->sputbackc(_Traits::to_char_type(__c)))) + __status |= ios_base::failbit; + } + } + } + _STLP_CATCH_ALL { + __that->_M_handle_exception(ios_base::badbit); + } + + __that->setstate(__status); +} + +// A generic buffered function for ignoring characters. Much like +// _M_ignore_unbuffered, but with one additional function object: +// __scan_delim(first, last) returns the first pointer p in [first, +// last) such that __is_delim(p) is true. + +template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim> +void _STLP_CALL +_M_ignore_buffered(basic_istream<_CharT, _Traits>* __that, + basic_streambuf<_CharT, _Traits>* __buf, + _Is_Delim __is_delim, _Scan_Delim __scan_delim, + bool __extract_delim, bool __set_failbit) { + bool __at_eof = false; + bool __found_delim = false; + + _STLP_TRY { + while (__buf->_M_egptr() != __buf->_M_gptr() && !__at_eof && !__found_delim) { + const _CharT* __p = __scan_delim(__buf->_M_gptr(), __buf->_M_egptr()); + __buf->_M_gbump((int)(__p - __buf->_M_gptr())); + + if (__p != __buf->_M_egptr()) { // We found delim, so we're done. + if (__extract_delim) + __buf->_M_gbump(1); + __found_delim = true; + } + + else // No delim. Try to refil the buffer. + __at_eof = __that->_S_eof(__buf->sgetc()); + } // Close the while loop. + } + _STLP_CATCH_ALL { + __that->_M_handle_exception(ios_base::badbit); + return; + } + + if (__at_eof) { + __that->setstate(__set_failbit ? ios_base::eofbit | ios_base::failbit + : ios_base::eofbit); + return; + } + if (__found_delim) + return; + + // If execution has reached this point, then we have an empty buffer but + // we have not reached eof. What that means is that the streambuf has + // decided to switch from a buffered to an unbuffered mode. We switch + // to _M_ignore_unbuffered. + _M_ignore_unbuffered(__that, __buf, __is_delim, __extract_delim, __set_failbit); +} + +// Overloaded versions of _M_ignore_unbuffered and _M_ignore_unbuffered +// with an explicit count _Num. Return value is the number of +// characters extracted. +// +// The function object __max_chars takes two arguments, _Num and __n +// (the latter being the number of characters we have already read), +// and returns the maximum number of characters to read from the buffer. +// We parameterize _M_ignore_buffered so that we can use it for both +// bounded and unbounded input; for the former the function object should +// be minus<>, and for the latter it should return a constant maximum value. + +template < class _CharT, class _Traits, class _Max_Chars, class _Is_Delim> +streamsize _STLP_CALL +_M_ignore_unbuffered(basic_istream<_CharT, _Traits>* __that, + basic_streambuf<_CharT, _Traits>* __buf, + streamsize _Num, _Max_Chars __max_chars, + _Is_Delim __is_delim, + bool __extract_delim, bool __set_failbit) { + streamsize __n = 0; + ios_base::iostate __status = 0; + typedef typename basic_istream<_CharT, _Traits>::int_type int_type; + + _STLP_TRY { + while (__max_chars(_Num, __n) > 0) { + int_type __c = __buf->sbumpc(); + + if (__that->_S_eof(__c)) { + __status |= __set_failbit ? ios_base::eofbit | ios_base::failbit + : ios_base::eofbit; + break; + } + + else if (__is_delim(_Traits::to_char_type(__c))) { + if (__extract_delim) + ++__n; + else if (__that->_S_eof(__buf->sputbackc(_Traits::to_char_type(__c)))) + __status |= ios_base::failbit; + + break; + } + // fbp : added counter increment to pass Dietmar's test + ++__n; + } + } + _STLP_CATCH_ALL { + __that->_M_handle_exception(ios_base::badbit); + } + + if (__status) + __that->setstate(__status); // This might throw. + return __n; +} + +template < class _CharT, class _Traits, class _Max_Chars, class _Is_Delim, class _Scan_Delim> +streamsize _STLP_CALL +_M_ignore_buffered(basic_istream<_CharT, _Traits>* __that, + basic_streambuf<_CharT, _Traits>* __buf, + streamsize _Num, + _Max_Chars __max_chars, + _Is_Delim __is_delim, _Scan_Delim __scan_delim, + bool __extract_delim, bool __set_failbit) { + streamsize __n = 0; + bool __at_eof = false; + bool __done = false; + + _STLP_TRY { + while (__buf->_M_egptr() != __buf->_M_gptr() && !__done) { + ptrdiff_t __avail = __buf->_M_egptr() - __buf->_M_gptr(); + streamsize __m = __max_chars(_Num, __n); + + if (__avail >= __m) { // We have more characters than we need. + const _CharT* __last = __buf->_M_gptr() + __STATIC_CAST(ptrdiff_t, __m); + const _CharT* __p = __scan_delim(__buf->_M_gptr(), __last); + ptrdiff_t __chunk = __p - __buf->_M_gptr(); + __n += __chunk; + __buf->_M_gbump((int)__chunk); + + if (__extract_delim && __p != __last) { + __n += 1; + __buf->_M_gbump(1); + } + + __done = true; + } + + else { + const _CharT* __p = __scan_delim(__buf->_M_gptr(), __buf->_M_egptr()); + ptrdiff_t __chunk = __p - __buf->_M_gptr(); + __n += __chunk; + __buf->_M_gbump((int)__chunk); + + if (__p != __buf->_M_egptr()) { // We found delim. + if (__extract_delim) { + __n += 1; + __buf->_M_gbump(1); + } + + __done = true; + } + + // We didn't find delim. Try to refill the buffer. + else if (__that->_S_eof(__buf->sgetc())) { + __done = true; + __at_eof = true; + } + } + } // Close the while loop. + } + _STLP_CATCH_ALL { + __that->_M_handle_exception(ios_base::badbit); + return __n; + } + + if (__at_eof) + __that->setstate(__set_failbit ? ios_base::eofbit | ios_base::failbit + : ios_base::eofbit); + + if (__done) + return __n; + + // If execution has reached this point, then we have an empty buffer but + // we have not reached eof. What that means is that the streambuf has + // decided to switch from buffered to unbuffered input. We switch to + // to _M_ignore_unbuffered. + + return __n + _M_ignore_unbuffered(__that, __buf, _Num, __max_chars, + __is_delim, __extract_delim, __set_failbit); +} + + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::ignore(streamsize __n) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + typedef _STLP_PRIV _Constant_unary_fun _Const_bool; + typedef _STLP_PRIV _Constant_binary_fun _Const_streamsize; + const streamsize __maxss = (numeric_limits::max)(); + + if (__n == (numeric_limits::max)()) { + if (__buf->gptr() != __buf->egptr()) + _M_gcount = _M_ignore_buffered(this, __buf, + __maxss, _Const_streamsize(__maxss), + _Const_bool(false), + _STLP_PRIV _Project2nd(), + false, false); + else + _M_gcount = _M_ignore_unbuffered(this, __buf, + __maxss, _Const_streamsize(__maxss), + _Const_bool(false), false, false); + } + else { + if (__buf->gptr() != __buf->egptr()) + _M_gcount = _M_ignore_buffered(this, __buf, + __n, minus(), + _Const_bool(false), + _STLP_PRIV _Project2nd(), + false, false); + else + _M_gcount = _M_ignore_unbuffered(this, __buf, __n, minus(), + _Const_bool(false), false, false); + } + } + + return *this; +} + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __delim) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + typedef _STLP_PRIV _Constant_unary_fun _Const_bool; + typedef _STLP_PRIV _Constant_binary_fun + _Const_streamsize; + const streamsize __maxss = (numeric_limits::max)(); + + if (__n == (numeric_limits::max)()) { + if (__buf->gptr() != __buf->egptr()) + _M_gcount = _M_ignore_buffered(this, __buf, + __maxss, _Const_streamsize(__maxss), + _STLP_PRIV _Eq_int_bound<_Traits>(__delim), + _STLP_PRIV _Scan_for_int_val<_Traits>(__delim), + true, false); + else + _M_gcount = _M_ignore_unbuffered(this, __buf, + __maxss, _Const_streamsize(__maxss), + _STLP_PRIV _Eq_int_bound<_Traits>(__delim), + true, false); + } + else { + if (__buf->gptr() != __buf->egptr()) + _M_gcount = _M_ignore_buffered(this, __buf, + __n, minus(), + _STLP_PRIV _Eq_int_bound<_Traits>(__delim), + _STLP_PRIV _Scan_for_int_val<_Traits>(__delim), + true, false); + else + _M_gcount = _M_ignore_unbuffered(this, __buf, __n, minus(), + _STLP_PRIV _Eq_int_bound<_Traits>(__delim), + true, false); + } + } + + return *this; +} + +// This member function does not construct a sentry object, because +// it is called from sentry's constructor. +template +void basic_istream<_CharT, _Traits>::_M_skip_whitespace(bool __set_failbit) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + if (!__buf) + this->setstate(ios_base::badbit); + else if (__buf->gptr() != __buf->egptr()) + _M_ignore_buffered(this, __buf, + _STLP_PRIV _Is_not_wspace<_Traits>(this->_M_ctype_facet()), + _STLP_PRIV _Scan_for_not_wspace<_Traits>(this->_M_ctype_facet()), + false, __set_failbit); + else + _M_ignore_unbuffered(this, __buf, + _STLP_PRIV _Is_not_wspace<_Traits>(this->_M_ctype_facet()), + false, __set_failbit); +} + + +// This is a very simple loop that reads characters from __src and puts +// them into __dest. It looks complicated because of the (standard- +// mandated) exception handling policy. +// +// We stop when we get an exception, when we fail to insert into the +// output streambuf, or when __is_delim is true. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template < class _CharT, class _Traits, class _Is_Delim> +streamsize _STLP_CALL +__copy_unbuffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src, + basic_streambuf<_CharT, _Traits>* __dest, + _Is_Delim __is_delim, + bool __extract_delim, bool __rethrow) { + streamsize __extracted = 0; + ios_base::iostate __status = 0; + typedef typename basic_istream<_CharT, _Traits>::int_type int_type; + int_type __c; + + _STLP_TRY { + for (;;) { + // Get a character. If there's an exception, catch and (maybe) rethrow it. + __c = __src->sbumpc(); + + // If we failed to get a character, then quit. + if (__that->_S_eof(__c)) { + __status |= ios_base::eofbit; + break; + } + // If it's the delimiter, then quit. + else if (__is_delim(_Traits::to_char_type(__c))) { + if (!__extract_delim && !__pushback(__src, _Traits::to_char_type(__c))) + __status |= ios_base::failbit; + break; + } + else { + // Try to put the character in the output streambuf. + bool __failed = false; + _STLP_TRY { + if (!__that->_S_eof(__dest->sputc(_Traits::to_char_type(__c)))) + ++__extracted; + else + __failed = true; + } + _STLP_CATCH_ALL { + __failed = true; + } + + // If we failed to put the character in the output streambuf, then + // try to push it back to the input streambuf. + if (__failed && !__pushback(__src, _Traits::to_char_type(__c))) + __status |= ios_base::failbit; + + // fbp : avoiding infinite loop in io-27-6-1-2-3.exp + if (__failed) + break; + } + + } /* for (;;) */ + + } + // fbp : this try/catch moved here in reasonable assumption + // __is_delim never throw (__pushback is guaranteed not to) + _STLP_CATCH_ALL { + // See 27.6.1.2.3, paragraph 13. + if (__rethrow && __extracted == 0) + __that->_M_handle_exception(ios_base::failbit); + } + __that->setstate(__status); + return __extracted; +} + +// Buffered copying from one streambuf to another. We copy the characters +// in chunks, rather than one at a time. We still have to worry about all +// of the error conditions we checked in __copy_unbuffered, plus one more: +// the streambuf might decide to switch from a buffered to an unbuffered mode. + +template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim> +streamsize _STLP_CALL +__copy_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src, + basic_streambuf<_CharT, _Traits>* __dest, + _Scan_Delim __scan_delim, _Is_Delim __is_delim, + bool __extract_delim, bool __rethrow) { + streamsize __extracted = 0; + ios_base::iostate __status = 0; + typedef typename basic_istream<_CharT, _Traits>::int_type int_type; + //Borland compiler generates a warning if assignment because value is never used: + int_type __c /*= _Traits::eof()*/; + _CharT* __first = __src->_M_gptr(); + ptrdiff_t __avail = __src->_M_egptr() - __first; + // fbp : introduced to move catch/try blocks out of the loop + bool __do_handle_exceptions = false; + + _STLP_TRY { + for (;;) { + const _CharT* __last = __scan_delim(__first, __src->_M_egptr()); + + // Try to copy the entire input buffer to the output buffer. + streamsize __n = __dest->sputn(__first, __extract_delim && __last != __src->_M_egptr() + ? (__last - __first) + 1 + : (__last - __first)); + __src->_M_gbump((int)__n); + __extracted += __n; + + // from this on, catch() will call _M_handle_exceptions() + __do_handle_exceptions = true; + + if (__n < __avail) // We found the delimiter, or else failed to + break; // copy some characters. + + __c = __src->sgetc(); + + // Three possibilities: we succeeded in refilling the buffer, or + // we got EOF, or the streambuf has switched to unbuffered mode. + __first = __src->_M_gptr(); + __avail = __src->_M_egptr() - __first; + + if (__avail > 0) + {} // dwa 1/16/00 -- suppress a Metrowerks warning + else if (__that->_S_eof(__c)) { + __status |= ios_base::eofbit; + break; + } + else { + return __extracted + __copy_unbuffered(__that, __src, __dest, __is_delim, + __extract_delim, __rethrow); + } + + __do_handle_exceptions = false; + } + } + + _STLP_CATCH_ALL { + // See 27.6.1.2.3, paragraph 13. + if (__rethrow && __do_handle_exceptions && __extracted == 0) + __that->_M_handle_exception(ios_base::failbit); + } + + if (__status) + __that->setstate(__status); // This might throw. + return __extracted; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits> + ::get(basic_streambuf<_CharT, _Traits>& __dest, _CharT __delim) { + sentry __sentry(*this, _No_Skip_WS()); + this->_M_gcount = 0; + + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __src = this->rdbuf(); + + if (__src) + this->_M_gcount = __src->egptr() != __src->gptr() + ? _STLP_PRIV __copy_buffered(this, __src, &__dest, + _STLP_PRIV _Scan_for_char_val<_Traits>(__delim), + _STLP_PRIV _Eq_char_bound<_Traits>(__delim), + false, false) + : _STLP_PRIV __copy_unbuffered(this, __src, &__dest, + _STLP_PRIV _Eq_char_bound<_Traits>(__delim), + false, false); + } + + if (this->_M_gcount == 0) + this->setstate(ios_base::failbit); + + return *this; +} + +// Copying characters into a streambuf. +template +basic_istream<_CharT, _Traits>& +basic_istream<_CharT, _Traits> + ::operator>>(basic_streambuf<_CharT, _Traits>* __dest) { + streamsize __n = 0; + typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry; + _Sentry __sentry(*this); + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __src = this->rdbuf(); + if (__src && __dest) + __n = __src->egptr() != __src->gptr() + ? _STLP_PRIV __copy_buffered(this, __src, __dest, + _STLP_PRIV _Project2nd(), + _STLP_PRIV _Constant_unary_fun(false), + false, true) + : _STLP_PRIV __copy_unbuffered(this, __src, __dest, + _STLP_PRIV _Constant_unary_fun(false), + false, true); + } + + if (__n == 0) + this->setstate(ios_base::failbit); + + return *this; +} + +// ---------------------------------------------------------------- +// basic_iostream<> class +// ---------------------------------------------------------------- + +template +basic_iostream<_CharT, _Traits> + ::basic_iostream(basic_streambuf<_CharT, _Traits>* __buf) + : basic_ios<_CharT, _Traits>(), + basic_istream<_CharT, _Traits>(__buf), + basic_ostream<_CharT, _Traits>(__buf) { + this->init(__buf); +} + +template +basic_iostream<_CharT, _Traits>::~basic_iostream() +{} + +_STLP_END_NAMESPACE + +#undef __BIS_int_type__ +#undef __BIS_pos_type__ +#undef __BIS_off_type__ + +#endif /* _STLP_ISTREAM_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_istream.h b/sdk/tlibstdcxx/stlport/stl/_istream.h new file mode 100644 index 0000000000..6b38d03c77 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_istream.h @@ -0,0 +1,359 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_INTERNAL_ISTREAM +#define _STLP_INTERNAL_ISTREAM + +// this block is included by _ostream.h, we include it here to lower #include level +#if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_INTERNAL_CWCHAR) +# include +#endif + +#ifndef _STLP_INTERNAL_IOS_H +# include // For basic_ios<>. Includes . +#endif + +#ifndef _STLP_INTERNAL_OSTREAM_H +# include // Needed as a base class of basic_iostream. +#endif + +#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H +# include +#endif + +#include // Helper functions that allow char traits + // to be used as function objects. +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +template +class _Isentry; +#endif + +struct _No_Skip_WS {}; // Dummy class used by sentry. + +template +bool _M_init_skip(basic_istream<_CharT, _Traits>& __istr); +template +bool _M_init_noskip(basic_istream<_CharT, _Traits>& __istr); + +//---------------------------------------------------------------------- +// Class basic_istream, a class that performs formatted input through +// a stream buffer. + +// The second template parameter, _Traits, defaults to char_traits<_CharT>. +// The default is declared in header , and it isn't declared here +// because C++ language rules do not allow it to be declared twice. + +template +class basic_istream : virtual public basic_ios<_CharT, _Traits> { + typedef basic_istream<_CharT, _Traits> _Self; + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + //explicitely defined as private to avoid warnings: + basic_istream(_Self const&); + _Self& operator = (_Self const&); +#endif + +public: + // Types + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + typedef basic_ios<_CharT, _Traits> _Basic_ios; + + typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&); + typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&); + typedef _Self& (_STLP_CALL *__istream_fn)(_Self&); + +public: // Constructor and destructor. + explicit basic_istream(basic_streambuf<_CharT, _Traits>* __buf) : + basic_ios<_CharT, _Traits>(), _M_gcount(0) { + this->init(__buf); + } + ~basic_istream() {}; + +public: // Nested sentry class. + +public: // Hooks for manipulators. The arguments are + // function pointers. + _Self& operator>> (__istream_fn __f) { return __f(*this); } + _Self& operator>> (__ios_fn __f) { __f(*this); return *this; } + _Self& operator>> (__ios_base_fn __f) { __f(*this); return *this; } + +public: // Formatted input of numbers. + _Self& operator>> (short& __val); + _Self& operator>> (int& __val); + _Self& operator>> (unsigned short& __val); + _Self& operator>> (unsigned int& __val); + _Self& operator>> (long& __val); + _Self& operator>> (unsigned long& __val); +#ifdef _STLP_LONG_LONG + _Self& operator>> (_STLP_LONG_LONG& __val); + _Self& operator>> (unsigned _STLP_LONG_LONG& __val); +#endif + _Self& operator>> (float& __val); + _Self& operator>> (double& __val); +# ifndef _STLP_NO_LONG_DOUBLE + _Self& operator>> (long double& __val); +# endif +# ifndef _STLP_NO_BOOL + _Self& operator>> (bool& __val); +# endif + _Self& operator>> (void*& __val); + +public: // Copying characters into a streambuf. + _Self& operator>>(basic_streambuf<_CharT, _Traits>*); + +public: // Unformatted input. + streamsize gcount() const { return _M_gcount; } + int_type peek(); + +public: // get() for single characters + int_type get(); + _Self& get(char_type& __c); + +public: // get() for character arrays. + _Self& get(char_type* __s, streamsize __n, char_type __delim); + _Self& get(char_type* __s, streamsize __n) + { return get(__s, __n, this->widen('\n')); } + +public: // get() for streambufs + _Self& get(basic_streambuf<_CharT, _Traits>& __buf, + char_type __delim); + _Self& get(basic_streambuf<_CharT, _Traits>& __buf) + { return get(__buf, this->widen('\n')); } + +public: // getline() + _Self& getline(char_type* __s, streamsize __n, char_type delim); + _Self& getline(char_type* __s, streamsize __n) + { return getline(__s, __n, this->widen('\n')); } + +public: // read(), readsome(), ignore() + _Self& ignore(); + _Self& ignore(streamsize __n); + _Self& ignore(streamsize __n, int_type __delim); + + _Self& read(char_type* __s, streamsize __n); + streamsize readsome(char_type* __s, streamsize __n); + +public: // putback + _Self& putback(char_type __c); + _Self& unget(); + +public: // Positioning and buffer control. + int sync(); + + pos_type tellg(); + _Self& seekg(pos_type __pos); + _Self& seekg(off_type, ios_base::seekdir); + +public: // Helper functions for non-member extractors. + void _M_formatted_get(_CharT& __c); + void _M_formatted_get(_CharT* __s); + void _M_skip_whitespace(bool __set_failbit); + +private: // Number of characters extracted by the + streamsize _M_gcount; // most recent unformatted input function. + +public: + +#if defined (_STLP_USE_TEMPLATE_EXPORT) + // If we are using DLL specs, we have not to use inner classes + // end class declaration here + typedef _Isentry<_CharT, _Traits> sentry; +}; +# define sentry _Isentry +template +class _Isentry { + typedef _Isentry<_CharT, _Traits> _Self; +# else + class sentry { + typedef sentry _Self; +#endif + + private: + const bool _M_ok; + // basic_streambuf<_CharT, _Traits>* _M_buf; + + public: + typedef _Traits traits_type; + + explicit sentry(basic_istream<_CharT, _Traits>& __istr, + bool __noskipws = false) : + _M_ok((__noskipws || !(__istr.flags() & ios_base::skipws)) ? _M_init_noskip(__istr) : _M_init_skip(__istr) ) + /* , _M_buf(__istr.rdbuf()) */ + {} + + // Calling this constructor is the same as calling the previous one with + // __noskipws = true, except that it doesn't require a runtime test. + sentry(basic_istream<_CharT, _Traits>& __istr, _No_Skip_WS) : /* _M_buf(__istr.rdbuf()), */ + _M_ok(_M_init_noskip(__istr)) {} + + ~sentry() {} + + operator bool() const { return _M_ok; } + + private: // Disable assignment and copy constructor. + //Implementation is here only to avoid warning with some compilers. + sentry(const _Self&) : _M_ok(false) {} + _Self& operator=(const _Self&) { return *this; } + }; + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +# undef sentry +# else + // close basic_istream class definition here +}; +# endif + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _Isentry >; +_STLP_EXPORT_TEMPLATE_CLASS basic_istream >; +# if ! defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS _Isentry >; +_STLP_EXPORT_TEMPLATE_CLASS basic_istream >; +# endif +# endif /* _STLP_USE_TEMPLATE_EXPORT */ + +// Non-member character and string extractor functions. +template +inline basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __in_str, _CharT& __c) { + __in_str._M_formatted_get(__c); + return __in_str; +} + +template +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, unsigned char& __c) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char&,__c)); + return __in_str; +} + +template +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, signed char& __c) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char&,__c)); + return __in_str; +} + +template +inline basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __in_str, _CharT* __s) { + __in_str._M_formatted_get(__s); + return __in_str; +} + +template +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, unsigned char* __s) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char*,__s)); + return __in_str; +} + +template +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, signed char* __s) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char*,__s)); + return __in_str; +} + +//---------------------------------------------------------------------- +// istream manipulator. +template +basic_istream<_CharT, _Traits>& _STLP_CALL +ws(basic_istream<_CharT, _Traits>& __istr) { + if (!__istr.eof()) { + typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry; + _Sentry __sentry(__istr, _No_Skip_WS()); // Don't skip whitespace. + if (__sentry) + __istr._M_skip_whitespace(false); + } + return __istr; +} + +// Helper functions for istream<>::sentry constructor. +template +inline bool _M_init_skip(basic_istream<_CharT, _Traits>& __istr) { + if (__istr.good()) { + if (__istr.tie()) + __istr.tie()->flush(); + + __istr._M_skip_whitespace(true); + } + + if (!__istr.good()) { + __istr.setstate(ios_base::failbit); + return false; + } else + return true; +} + +template +inline bool _M_init_noskip(basic_istream<_CharT, _Traits>& __istr) { + if (__istr.good()) { + if (__istr.tie()) + __istr.tie()->flush(); + + if (!__istr.rdbuf()) + __istr.setstate(ios_base::badbit); + } + else + __istr.setstate(ios_base::failbit); + return __istr.good(); +} + +//---------------------------------------------------------------------- +// Class iostream. +template +class basic_iostream + : public basic_istream<_CharT, _Traits>, + public basic_ostream<_CharT, _Traits> +{ +public: + typedef basic_ios<_CharT, _Traits> _Basic_ios; + + explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __buf); + virtual ~basic_iostream(); +}; + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_iostream >; + +# if ! defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_iostream >; +# endif +# endif /* _STLP_USE_TEMPLATE_EXPORT */ + +template +basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& __istr) +{ return __istr.rdbuf(); } + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_ISTREAM */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_istreambuf_iterator.h b/sdk/tlibstdcxx/stlport/stl/_istreambuf_iterator.h new file mode 100644 index 0000000000..9f340cb517 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_istreambuf_iterator.h @@ -0,0 +1,161 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H +#define _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_STREAMBUF +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// defined in _istream.h +template +extern basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& ) ; + +// We do not read any characters until operator* is called. operator* calls sgetc +// unless the iterator is unchanged from the last call in which case a cached value is +// used. Calls to operator++ use sbumpc. + +template +class istreambuf_iterator : + public iterator +{ +public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename _Traits::int_type int_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_istream<_CharT, _Traits> istream_type; + + typedef input_iterator_tag iterator_category; + typedef _CharT value_type; + typedef typename _Traits::off_type difference_type; + typedef const _CharT* pointer; + typedef const _CharT& reference; + +public: + istreambuf_iterator(streambuf_type* __p = 0) { this->_M_init(__p); } + // istreambuf_iterator(basic_istream<_CharT, _Traits>& __is) { this->_M_init(_M_get_istreambuf(__is)); } + inline istreambuf_iterator(basic_istream<_CharT, _Traits>& __is); + + char_type operator*() const { this->_M_getc(); return _M_c; } + istreambuf_iterator<_CharT, _Traits>& operator++() { + _M_buf->sbumpc(); + _M_have_c = false; + return *this; + } + istreambuf_iterator<_CharT, _Traits> operator++(int); + + bool equal(const istreambuf_iterator<_CharT, _Traits>& __i) const { + if (this->_M_buf) + this->_M_getc(); + if (__i._M_buf) + __i._M_getc(); + return this->_M_eof == __i._M_eof; + } + +private: + void _M_init(streambuf_type* __p) { + _M_buf = __p; + _M_eof = (__p == 0); + _M_have_c = false; + } + + void _M_getc() const { + if (_M_have_c) + return; + int_type __c = _M_buf->sgetc(); + _STLP_MUTABLE(_Self, _M_c) = traits_type::to_char_type(__c); + _STLP_MUTABLE(_Self, _M_eof) = traits_type::eq_int_type(__c, traits_type::eof()); + _STLP_MUTABLE(_Self, _M_have_c) = true; + } + +private: + streambuf_type* _M_buf; + mutable _CharT _M_c; + mutable bool _M_eof; + mutable bool _M_have_c; +}; + +template +inline istreambuf_iterator<_CharT, _Traits>::istreambuf_iterator(basic_istream<_CharT, _Traits>& __is) +{ this->_M_init(_M_get_istreambuf(__is)); } + +template +inline bool _STLP_CALL operator==(const istreambuf_iterator<_CharT, _Traits>& __x, + const istreambuf_iterator<_CharT, _Traits>& __y) { + return __x.equal(__y); +} + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE + +template +inline bool _STLP_CALL operator!=(const istreambuf_iterator<_CharT, _Traits>& __x, + const istreambuf_iterator<_CharT, _Traits>& __y) { + return !__x.equal(__y); +} + +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS istreambuf_iterator >; +# if defined (INSTANTIATE_WIDE_STREAMS) +_STLP_EXPORT_TEMPLATE_CLASS istreambuf_iterator >; +# endif +# endif /* _STLP_USE_TEMPLATE_EXPORT */ + +# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES +template +inline input_iterator_tag _STLP_CALL iterator_category(const istreambuf_iterator<_CharT, _Traits>&) { return input_iterator_tag(); } +template +inline streamoff* _STLP_CALL +distance_type(const istreambuf_iterator<_CharT, _Traits>&) { return (streamoff*)0; } +template +inline _CharT* _STLP_CALL value_type(const istreambuf_iterator<_CharT, _Traits>&) { return (_CharT*)0; } +# endif + +template +istreambuf_iterator<_CharT, _Traits> +istreambuf_iterator<_CharT, _Traits>::operator++(int) { + _M_getc(); // __tmp should avoid any future actions under + // underlined buffer---during call of operator *() + // (due to buffer for *this and __tmp are the same). + istreambuf_iterator<_CharT, _Traits> __tmp = *this; + _M_buf->sbumpc(); + _M_have_c = false; + return __tmp; +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_iterator.h b/sdk/tlibstdcxx/stlport/stl/_iterator.h new file mode 100644 index 0000000000..8e3b7b032a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_iterator.h @@ -0,0 +1,265 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ITERATOR_H +#define _STLP_INTERNAL_ITERATOR_H + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +// This is the new version of reverse_iterator, as defined in the +// draft C++ standard. It relies on the iterator_traits template, +// which in turn relies on partial specialization. The class +// reverse_bidirectional_iterator is no longer part of the draft +// standard, but it is retained for backward compatibility. + +template +class reverse_iterator : + public iterator::iterator_category, + typename iterator_traits<_Iterator>::value_type, + typename iterator_traits<_Iterator>::difference_type, + typename iterator_traits<_Iterator>::pointer, + typename iterator_traits<_Iterator>::reference> { +protected: + _Iterator current; + typedef reverse_iterator<_Iterator> _Self; +public: + typedef typename iterator_traits<_Iterator>::difference_type difference_type; + // pointer type required for arrow operator hidden behind _STLP_DEFINE_ARROW_OPERATOR: + typedef typename iterator_traits<_Iterator>::pointer pointer; + typedef typename iterator_traits<_Iterator>::reference reference; + typedef _Iterator iterator_type; +public: + reverse_iterator() {} + explicit reverse_iterator(iterator_type __x) : current(__x) {} + reverse_iterator(const _Self& __x) : current(__x.current) {} + _Self& operator = (const _Self& __x) { current = __x.base(); return *this; } +# if defined (_STLP_MEMBER_TEMPLATES) + template + reverse_iterator(const reverse_iterator<_Iter>& __x) : current(__x.base()) {} + template + _Self& operator = (const reverse_iterator<_Iter>& __x) { current = __x.base(); return *this; } +# endif /* _STLP_MEMBER_TEMPLATES */ + + iterator_type base() const { return current; } + reference operator*() const { + _Iterator __tmp = current; + return *--__tmp; + } + _STLP_DEFINE_ARROW_OPERATOR + _Self& operator++() { + --current; + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + --current; + return __tmp; + } + _Self& operator--() { + ++current; + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + ++current; + return __tmp; + } + + _Self operator+(difference_type __n) const { return _Self(current - __n); } + _Self& operator+=(difference_type __n) { + current -= __n; + return *this; + } + _Self operator-(difference_type __n) const { return _Self(current + __n); } + _Self& operator-=(difference_type __n) { + current += __n; + return *this; + } + reference operator[](difference_type __n) const { return *(*this + __n); } +}; + +template +inline bool _STLP_CALL operator==(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __x.base() == __y.base(); } + +template +inline bool _STLP_CALL operator<(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __y.base() < __x.base(); } + +# if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template +inline bool _STLP_CALL operator!=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return !(__x == __y); } + +template +inline bool _STLP_CALL operator>(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __y < __x; } + +template +inline bool _STLP_CALL operator<=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return !(__y < __x); } + +template +inline bool _STLP_CALL operator>=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return !(__x < __y); } +# endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template +# if defined (__SUNPRO_CC) +inline ptrdiff_t _STLP_CALL +# else +inline typename reverse_iterator<_Iterator>::difference_type _STLP_CALL +# endif +operator-(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __y.base() - __x.base(); } + +template +inline reverse_iterator<_Iterator> _STLP_CALL +operator+(_DifferenceType n,const reverse_iterator<_Iterator>& x) +{ return x.operator+(n); } +#endif + +template +class back_insert_iterator + : public iterator { + typedef back_insert_iterator<_Container> _Self; +protected: + //c is a Standard name (24.4.2.1), do no make it STLport naming convention compliant. + _Container *container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + + explicit back_insert_iterator(_Container& __x) : container(&__x) {} + + _Self& operator=(const _Self& __other) { + container = __other.container; + return *this; + } + _Self& operator=(const typename _Container::value_type& __val) { + container->push_back(__val); + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self operator++(int) { return *this; } +}; + +template +inline back_insert_iterator<_Container> _STLP_CALL back_inserter(_Container& __x) +{ return back_insert_iterator<_Container>(__x); } + +template +class front_insert_iterator + : public iterator { + typedef front_insert_iterator<_Container> _Self; +protected: + //c is a Standard name (24.4.2.3), do no make it STLport naming convention compliant. + _Container *container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + explicit front_insert_iterator(_Container& __x) : container(&__x) {} + + _Self& operator=(const _Self& __other) { + container = __other.container; + return *this; + } + _Self& operator=(const typename _Container::value_type& __val) { + container->push_front(__val); + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self operator++(int) { return *this; } +}; + +template +inline front_insert_iterator<_Container> _STLP_CALL front_inserter(_Container& __x) +{ return front_insert_iterator<_Container>(__x); } + +template +class insert_iterator + : public iterator { + typedef insert_iterator<_Container> _Self; +protected: + //container is a Standard name (24.4.2.5), do no make it STLport naming convention compliant. + _Container *container; + typename _Container::iterator _M_iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + insert_iterator(_Container& __x, typename _Container::iterator __i) + : container(&__x), _M_iter(__i) {} + + _Self& operator=(_Self const& __other) { + container = __other.container; + _M_iter = __other._M_iter; + return *this; + } + _Self& operator=(const typename _Container::value_type& __val) { + _M_iter = container->insert(_M_iter, __val); + ++_M_iter; + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self& operator++(int) { return *this; } +}; + +template +inline insert_iterator<_Container> _STLP_CALL +inserter(_Container& __x, _Iterator __i) { + typedef typename _Container::iterator __iter; + return insert_iterator<_Container>(__x, __iter(__i)); +} + +_STLP_END_NAMESPACE + +#if ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +# include +#endif + +#endif /* _STLP_INTERNAL_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_iterator_base.h b/sdk/tlibstdcxx/stlport/stl/_iterator_base.h new file mode 100644 index 0000000000..2362ca1665 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_iterator_base.h @@ -0,0 +1,528 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +#define _STLP_INTERNAL_ITERATOR_BASE_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include +#endif + +//# if defined (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD) +//_STLP_BEGIN_NAMESPACE +//using namespace _STLP_VENDOR_CSTD; +//_STLP_END_NAMESPACE +//#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#if !defined(_STLP_USE_OLD_HP_ITERATOR_QUERIES) && !defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) +# ifndef _STLP_TYPE_TRAITS_H +# include +# endif +#endif + +_STLP_BEGIN_NAMESPACE + +struct input_iterator_tag {}; +struct output_iterator_tag {}; +struct forward_iterator_tag : public input_iterator_tag {}; +struct bidirectional_iterator_tag : public forward_iterator_tag {}; +struct random_access_iterator_tag : public bidirectional_iterator_tag {}; + +template +struct iterator { + typedef _Category iterator_category; + typedef _Tp value_type; + typedef _Distance difference_type; + typedef _Pointer pointer; + typedef _Reference reference; +}; +_STLP_TEMPLATE_NULL +struct iterator { + typedef output_iterator_tag iterator_category; +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; +#endif +}; + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_category(_It) +# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::distance_type(_It) +# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::value_type(_It) +//Old HP iterator queries do not give information about the iterator +//associated reference type so we consider that it is not a real reference. +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type() +#else +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# define _STLP_VALUE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::value_type*)0 +# define _STLP_DISTANCE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::difference_type*)0 +# if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \ + (defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__) +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_traits< _Tp >::iterator_category() +# else +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::iterator_category() +# endif +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) _STLP_STD::_IsRefType< _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::reference >::_Ret() +# else +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::__iterator_category(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret()) +# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::__distance_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret()) +# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::__value_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret()) +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type() +# endif +#endif + +#if defined (_STLP_DONT_REDEFINE_STD) && defined (_STLP_WHOLE_NATIVE_STD) +/* In this mode we will see both STLport implementation and native + * one. To allow some interaction between both implementations through + * iterators we have to map std iterator categories to stlport ones. This + * way we will be able to initialize STLport containers with native + * iterators, the other side won't work except when STLport iterators are + * simple pointers. */ + +_STLP_END_NAMESPACE + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(iterator) +# endif + +_STLP_BEGIN_NAMESPACE + +template +struct _CategoryMapping +{ typedef _IteCat _Tag; }; + +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::input_iterator_tag> +{ typedef input_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::output_iterator_tag> +{ typedef output_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::forward_iterator_tag> +{ typedef forward_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::bidirectional_iterator_tag> +{ typedef bidirectional_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::random_access_iterator_tag> +{ typedef random_access_iterator_tag _Tag; }; + +template +struct iterator_traits { + typedef typename _Iterator::iterator_category _OriginalTag; + typedef typename _CategoryMapping<_OriginalTag>::_Tag iterator_category; +#else +template +struct iterator_traits { + typedef typename _Iterator::iterator_category iterator_category; +#endif + typedef typename _Iterator::value_type value_type; + typedef typename _Iterator::difference_type difference_type; + typedef typename _Iterator::pointer pointer; + typedef typename _Iterator::reference reference; +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (__SUNPRO_CC) +# define _STLP_DIFFERENCE_TYPE(_Iterator) typename iterator_traits<_Iterator>::difference_type +#else +# define _STLP_DIFFERENCE_TYPE(_Iterator) ptrdiff_t +#endif + +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION + +// fbp : this order keeps gcc happy +template +struct iterator_traits { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; +}; + +template +struct iterator_traits<_Tp*> { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef _Tp& reference; +}; + +# if defined (__BORLANDC__) +template +struct iterator_traits<_Tp* const> { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; +}; +# endif + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE +#include +_STLP_BEGIN_NAMESPACE + +#ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES +// The overloaded functions iterator_category, distance_type, and +// value_type are not part of the C++ standard. (They have been +// replaced by struct iterator_traits.) They are included for +// backward compatibility with the HP STL. +// We introduce internal names for these functions. + +# ifndef _STLP_CLASS_PARTIAL_SPECIALIZATION + +template +inline _STLP_STD::random_access_iterator_tag +__iterator_category(const _Tp*, const __true_type&) +{ return _STLP_STD::random_access_iterator_tag(); } + +template +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::iterator_category +__iterator_category(const _Iter&, const __false_type&) { + typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::iterator_category _Category; + return _Category(); +} + +template +inline ptrdiff_t* +__distance_type(const _Tp*, const __true_type&) +{ return __STATIC_CAST(ptrdiff_t*, 0); } + +template +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::difference_type* +__distance_type(const _Iter&, const __false_type&) { + typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::difference_type _diff_type; + return __STATIC_CAST(_diff_type*,0); +} + +template +inline _Tp* +__value_type(const _Tp*, const __true_type&) +{ return __STATIC_CAST(_Tp*, 0); } + +template +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::value_type* +__value_type(const _Iter&, const __false_type&) { + typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::value_type _value_type; + return __STATIC_CAST(_value_type*,0); +} + +# endif + +#else /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */ +template +inline _Category _STLP_CALL iterator_category(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return _Category(); } +template +inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Tp*, 0); } +template +inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Distance*, 0); } +template +inline random_access_iterator_tag _STLP_CALL iterator_category(const _Tp*) { return random_access_iterator_tag(); } +template +inline _Tp* _STLP_CALL value_type(const _Tp*) { return __STATIC_CAST(_Tp*, 0); } +template +inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return __STATIC_CAST(ptrdiff_t*, 0); } +#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */ + +#if !defined (_STLP_NO_ANACHRONISMS) +// The base classes input_iterator, output_iterator, forward_iterator, +// bidirectional_iterator, and random_access_iterator are not part of +// the C++ standard. (They have been replaced by struct iterator.) +// They are included for backward compatibility with the HP STL. +template struct input_iterator : + public iterator {}; +struct output_iterator : public iterator {}; +template struct forward_iterator : + public iterator {}; +template struct bidirectional_iterator : + public iterator {}; +template struct random_access_iterator : + public iterator {}; + +# if defined (_STLP_BASE_MATCH_BUG) && defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +template +inline input_iterator_tag _STLP_CALL +iterator_category(const input_iterator<_Tp, _Distance>&) { return input_iterator_tag(); } +inline output_iterator_tag _STLP_CALL +iterator_category(const output_iterator&) { return output_iterator_tag(); } +template +inline forward_iterator_tag _STLP_CALL +iterator_category(const forward_iterator<_Tp, _Distance>&) { return forward_iterator_tag(); } +template +inline bidirectional_iterator_tag _STLP_CALL +iterator_category(const bidirectional_iterator<_Tp, _Distance>&) { return bidirectional_iterator_tag(); } +template +inline random_access_iterator_tag _STLP_CALL +iterator_category(const random_access_iterator<_Tp, _Distance>&) { return random_access_iterator_tag(); } +template +inline _Tp* _STLP_CALL value_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template +inline _Tp* _STLP_CALL value_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template +inline _Tp* _STLP_CALL value_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template +inline _Tp* _STLP_CALL value_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template +inline _Distance* _STLP_CALL distance_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); } +template +inline _Distance* _STLP_CALL distance_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); } +template +inline _Distance* _STLP_CALL distance_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0);} +template +inline _Distance* _STLP_CALL distance_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); } +# endif +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL +__distance(const _InputIterator& __first, const _InputIterator& __last, + const input_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_InputIterator) __n = 0; + _InputIterator __it(__first); + while (__it != __last) { + ++__it; ++__n; + } + return __n; +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline _STLP_DIFFERENCE_TYPE(_ForwardIterator) _STLP_CALL +__distance(const _ForwardIterator& __first, const _ForwardIterator& __last, + const forward_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_ForwardIterator) __n = 0; + _ForwardIterator __it(__first); + while (__it != __last) { + ++__it; ++__n; + } + return __n; +} + +template +_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) _STLP_CALL +__distance(const _BidirectionalIterator& __first, const _BidirectionalIterator& __last, + const bidirectional_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) __n = 0; + _BidirectionalIterator __it(__first); + while (__it != __last) { + ++__it; ++__n; + } + return __n; +} +#endif + +template +inline _STLP_DIFFERENCE_TYPE(_RandomAccessIterator) _STLP_CALL +__distance(const _RandomAccessIterator& __first, const _RandomAccessIterator& __last, + const random_access_iterator_tag &) +{ return __last - __first; } + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL +distance(_InputIterator __first, _InputIterator __last) +{ return _STLP_PRIV __distance(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); } + +#if !defined (_STLP_NO_ANACHRONISMS) +template +inline void _STLP_CALL distance(const _InputIterator& __first, + const _InputIterator& __last, _Distance& __n) +{ __n += _STLP_STD::distance(__first, __last); } + +# if defined (_STLP_MSVC) +// MSVC specific +template +inline void _STLP_CALL _Distance(_InputIterator __first, + _InputIterator __last, _Dist& __n) +{ __n += _STLP_STD::distance(__first, __last); } +# endif +#endif + +// fbp: those are being used for iterator/const_iterator definitions everywhere +template +struct _Nonconst_traits; + +template +struct _Const_traits { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_traits<_Tp> _NonConstTraits; +}; + +template +struct _Nonconst_traits { + typedef _Tp value_type; + typedef _Tp& reference; + typedef _Tp* pointer; + typedef _Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_traits<_Tp> _NonConstTraits; +}; + +/* + * dums: A special iterator/const_iterator traits for set and multiset for which even + * the iterator is not mutable + */ +template +struct _Nonconst_Const_traits; + +template +struct _Const_Const_traits { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Const_Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_Const_traits<_Tp> _NonConstTraits; +}; + +template +struct _Nonconst_Const_traits { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Const_Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_Const_traits<_Tp> _NonConstTraits; +}; + +/* + * A macro to generate a new iterator traits from one of the + * previous one. Changing the iterator traits type make iterators + * from different containers not comparable. + */ +#define _STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \ +template \ +struct _##Motif; \ +template \ +struct _Const##Motif : public _STLP_STD::_Const_##Traits<_Tp> { \ + typedef _Const##Motif<_Tp> _ConstTraits; \ + typedef _##Motif<_Tp> _NonConstTraits; \ +}; \ +template \ +struct _##Motif : public _STLP_STD::_Nonconst_##Traits<_Tp> { \ + typedef _Const##Motif<_Tp> _ConstTraits; \ + typedef _##Motif<_Tp> _NonConstTraits; \ +}; + +#define _STLP_CREATE_ITERATOR_TRAITS(Motif, Traits) \ +_STLP_MOVE_TO_PRIV_NAMESPACE \ +_STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \ +_STLP_MOVE_TO_STD_NAMESPACE + +#define _STLP_CREATE_HASH_ITERATOR_TRAITS(Motif, Traits) \ +_STLP_MOVE_TO_PRIV_NAMESPACE \ +_STLP_CREATE_ITERATOR_TRAITS_BASE(NonLocal##Motif, Traits) \ +_STLP_CREATE_ITERATOR_TRAITS_BASE(Local##Motif, Traits) \ +template \ +struct _##Motif { \ + typedef _ConstNonLocal##Motif<_Tp> _ConstTraits; \ + typedef _NonLocal##Motif<_Tp> _NonConstTraits; \ + typedef _ConstLocal##Motif<_Tp> _ConstLocalTraits; \ + typedef _Local##Motif<_Tp> _NonConstLocalTraits; \ +}; \ +_STLP_MOVE_TO_STD_NAMESPACE + +/* +# if defined (_STLP_BASE_TYPEDEF_BUG) +// this workaround is needed for SunPro 4.0.1 +template +struct __cnst_traits_aux : private _Traits { + typedef typename _Traits::value_type value_type; +}; +# define __TRAITS_VALUE_TYPE(_Traits) __cnst_traits_aux<_Traits>::value_type +# else +# define __TRAITS_VALUE_TYPE(_Traits) _Traits::value_type +# endif +*/ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_InputIter& __i, _Distance __n, const input_iterator_tag &) +{ while (__n--) ++__i; } + +// fbp : added output iterator tag variant +template +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_InputIter& __i, _Distance __n, const output_iterator_tag &) +{ while (__n--) ++__i; } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_ForwardIterator& i, _Distance n, const forward_iterator_tag &) +{ while (n--) ++i; } +#endif + +template +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_BidirectionalIterator& __i, _Distance __n, + const bidirectional_iterator_tag &) { + if (__n > 0) + while (__n--) ++__i; + else + while (__n++) --__i; +} + +template +inline void _STLP_CALL +__advance(_RandomAccessIterator& __i, _Distance __n, + const random_access_iterator_tag &) +{ __i += __n; } + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline void _STLP_CALL advance(_InputIterator& __i, _Distance __n) +{ + _STLP_DIFFERENCE_TYPE(_InputIterator) __d = __n; + _STLP_PRIV __advance(__i, __d, _STLP_ITERATOR_CATEGORY(__i, _InputIterator)); +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_ITERATOR_BASE_H */ + + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_iterator_old.h b/sdk/tlibstdcxx/stlport/stl/_iterator_old.h new file mode 100644 index 0000000000..144b9ab388 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_iterator_old.h @@ -0,0 +1,334 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ITERATOR_OLD_H +#define _STLP_INTERNAL_ITERATOR_OLD_H + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES + +template +inline output_iterator_tag _STLP_CALL +iterator_category(const back_insert_iterator<_Container>&) { return output_iterator_tag(); } +template +inline output_iterator_tag _STLP_CALL +iterator_category(const front_insert_iterator<_Container>&) { return output_iterator_tag(); } +template +inline output_iterator_tag _STLP_CALL +iterator_category(const insert_iterator<_Container>&) { return output_iterator_tag(); } + +#endif + +template +class reverse_bidirectional_iterator { + typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, + Reference__, _Distance> _Self; + // friend inline bool operator== _STLP_NULL_TMPL_ARGS (const _Self& x, const _Self& y); +protected: + _BidirectionalIterator current; +public: + typedef bidirectional_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Distance difference_type; +# if defined (_STLP_MSVC50_COMPATIBILITY) + typedef _Pointer pointer; +# else + typedef _Tp* pointer; +# endif + typedef _Reference reference; + + reverse_bidirectional_iterator() {} + explicit reverse_bidirectional_iterator(_BidirectionalIterator __x) + : current(__x) {} + _BidirectionalIterator base() const { return current; } + _Reference operator*() const { + _BidirectionalIterator __tmp = current; + return *(--__tmp); + } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + --current; + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + --current; + return __tmp; + } + _Self& operator--() { + ++current; + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + ++current; + return __tmp; + } +}; + +#ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES +template +inline bidirectional_iterator_tag _STLP_CALL +iterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&) +{ return bidirectional_iterator_tag(); } +template +inline _Tp* _STLP_CALL +value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&) +{ return (_Tp*) 0; } +template +inline _Distance* _STLP_CALL +distance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&) +{ return (_Distance*) 0; } +#endif + +template +inline bool _STLP_CALL operator==( + const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, + Reference__, _Distance>& __y) +{ return __x.base() == __y.base(); } + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE + +template +inline bool _STLP_CALL operator!=( + const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __x, + const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __y) +{ return !(__x == __y); } + +#endif + +#if !defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) + +// This is the old version of reverse_iterator, as found in the original +// HP STL. It does not use partial specialization. + +template +class reverse_iterator { + typedef reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance> _Self; +protected: + _RandomAccessIterator __current; +public: + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Distance difference_type; +# if defined (_STLP_MSVC50_COMPATIBILITY) + typedef _Pointer pointer; +# else + typedef _Tp* pointer; +# endif + typedef _Reference reference; + + reverse_iterator() {} + reverse_iterator(const _Self& __x) : __current(__x.base()) {} + explicit reverse_iterator(_RandomAccessIterator __x) : __current(__x) {} + _Self& operator=(const _Self& __x) {__current = __x.base(); return *this; } + + _RandomAccessIterator base() const { return __current; } + _Reference operator*() const { return *(__current - (difference_type)1); } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + --__current; + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + --__current; + return __tmp; + } + _Self& operator--() { + ++__current; + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + ++__current; + return __tmp; + } + _Self operator+(_Distance __n) const { + return _Self(__current - __n); + } + _Self& operator+=(_Distance __n) { + __current -= __n; + return *this; + } + _Self operator-(_Distance __n) const { + return _Self(__current + __n); + } + _Self& operator-=(_Distance __n) { + __current += __n; + return *this; + } + _Reference operator[](_Distance __n) const { return *(*this + __n); } +}; + +# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES +template +inline random_access_iterator_tag _STLP_CALL +iterator_category(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&) +{ return random_access_iterator_tag(); } +template +inline _Tp* _STLP_CALL value_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&) +{ return (_Tp*) 0; } +template +inline _Distance* _STLP_CALL +distance_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&) +{ return (_Distance*) 0; } +# endif + +template +inline bool _STLP_CALL +operator==(const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __y) +{ + return __x.base() == __y.base(); +} + +template +inline bool _STLP_CALL +operator<(const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __y) +{ + return __y.base() < __x.base(); +} + +# ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE + +template +inline bool _STLP_CALL +operator!=(const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __y) { + return !(__x == __y); +} + +template +inline bool _STLP_CALL +operator>(const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __y) { + return __y < __x; +} + +template +inline bool _STLP_CALL +operator<=(const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __y) { + return !(__y < __x); +} + +template +inline bool _STLP_CALL +operator>=(const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __y) { + return !(__x < __y); +} + +# endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template +inline _Distance _STLP_CALL +operator-(const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __y) +{ + return __y.base() - __x.base(); +} + +template +inline reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance> _STLP_CALL +operator+(_Distance __n, + const reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>& __x) +{ + return reverse_iterator<_RandomAccessIterator, _Tp, + Reference__, _Distance>(__x.base() - __n); +} + +#endif /* ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_limits.c b/sdk/tlibstdcxx/stlport/stl/_limits.c new file mode 100644 index 0000000000..39380249eb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_limits.c @@ -0,0 +1,405 @@ +/* + * Copyright (c) 1998,1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_LIMITS_C +#define _STLP_LIMITS_C + +#ifndef _STLP_INTERNAL_LIMITS +# include +#endif + +//========================================================== +// numeric_limits static members +//========================================================== + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) + +# define __declare_numeric_base_member(__type, __mem) \ +template \ + const __type _Numeric_limits_base<__number>:: __mem + +__declare_numeric_base_member(bool, is_specialized); +__declare_numeric_base_member(int, digits); +__declare_numeric_base_member(int, digits10); +__declare_numeric_base_member(bool, is_signed); +__declare_numeric_base_member(bool, is_integer); +__declare_numeric_base_member(bool, is_exact); +__declare_numeric_base_member(int, radix); +__declare_numeric_base_member(int, min_exponent); +__declare_numeric_base_member(int, max_exponent); +__declare_numeric_base_member(int, min_exponent10); +__declare_numeric_base_member(int, max_exponent10); +__declare_numeric_base_member(bool, has_infinity); +__declare_numeric_base_member(bool, has_quiet_NaN); +__declare_numeric_base_member(bool, has_signaling_NaN); +__declare_numeric_base_member(float_denorm_style, has_denorm); +__declare_numeric_base_member(bool, has_denorm_loss); +__declare_numeric_base_member(bool, is_iec559); +__declare_numeric_base_member(bool, is_bounded); +__declare_numeric_base_member(bool, is_modulo); +__declare_numeric_base_member(bool, traps); +__declare_numeric_base_member(bool, tinyness_before); +__declare_numeric_base_member(float_round_style, round_style); + +# undef __declare_numeric_base_member + +# define __declare_integer_limits_member(__type, __mem) \ +template \ + const __type _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: __mem + +__declare_integer_limits_member(bool, is_specialized); +__declare_integer_limits_member(int, digits); +__declare_integer_limits_member(int, digits10); +__declare_integer_limits_member(bool, is_signed); +__declare_integer_limits_member(bool, is_integer); +__declare_integer_limits_member(bool, is_exact); +__declare_integer_limits_member(int, radix); +__declare_integer_limits_member(bool, is_bounded); +__declare_integer_limits_member(bool, is_modulo); +# undef __declare_integer_limits_member + +# if defined (__GNUC__) && (__GNUC__ != 2 || __GNUC_MINOR__ > 96) && (__GNUC__ != 3 || __GNUC_MINOR__ == 0) && (__GNUC__ <= 3) +_STLP_MOVE_TO_STD_NAMESPACE + +# define __declare_numeric_limits_member(__integer) \ + _STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits; \ + _STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits10; \ + _STLP_TEMPLATE_NULL const int numeric_limits<__integer>::radix; \ + _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_specialized; \ + _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_signed; \ + _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_integer; \ + _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_exact; \ + _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_bounded; \ + _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_modulo + +__declare_numeric_limits_member(_STLP_LONG_LONG); +__declare_numeric_limits_member(unsigned _STLP_LONG_LONG); + +# undef __declare_numeric_limits_member + +_STLP_MOVE_TO_PRIV_NAMESPACE +# endif + +# define __declare_float_limits_member(__type, __mem) \ +template \ +const __type _Floating_limits< __number, __Digits, __Digits10, \ + __MinExp, __MaxExp, __MinExp10, __MaxExp10, \ + __IsIEC559, __DenormStyle, __RoundStyle>::\ + __mem + +__declare_float_limits_member(bool, is_specialized); +__declare_float_limits_member(int, digits); +__declare_float_limits_member(int, digits10); +__declare_float_limits_member(bool, is_signed); +__declare_float_limits_member(int, radix); +__declare_float_limits_member(int, min_exponent); +__declare_float_limits_member(int, max_exponent); +__declare_float_limits_member(int, min_exponent10); +__declare_float_limits_member(int, max_exponent10); +__declare_float_limits_member(bool, has_infinity); +__declare_float_limits_member(bool, has_quiet_NaN); +__declare_float_limits_member(bool, has_signaling_NaN); +__declare_float_limits_member(float_denorm_style, has_denorm); +__declare_float_limits_member(bool, has_denorm_loss); +__declare_float_limits_member(bool, is_iec559); +__declare_float_limits_member(bool, is_bounded); +__declare_float_limits_member(bool, traps); +__declare_float_limits_member(bool, tinyness_before); +__declare_float_limits_member(float_round_style, round_style); +# undef __declare_float_limits_member + +#endif + + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) + +# if defined (__GNUC__) || defined (__BORLANDC__) +# define _STLP_ADDITIONAL_OPEN_BRACKET { +# define _STLP_ADDITIONAL_CLOSE_BRACKET } +# else +# define _STLP_ADDITIONAL_OPEN_BRACKET +# define _STLP_ADDITIONAL_CLOSE_BRACKET +# endif + +/* The following code has been extracted from the boost libraries (www.boost.org) and + * adapted with the STLport portability macros. Advantage on previous technique is that + * computation of infinity and NaN values is only based on big/little endianess, compiler + * float, double or long double representation is taken into account thanks to the sizeof + * operator. */ +template +struct float_helper { + union _WordsNumber { + unsigned short _Words[8]; + _Number _num; + }; + static _Number get_word_higher() _STLP_NOTHROW { + _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET _Word, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; + return __tmp._num; + } + static _Number get_word_lower() _STLP_NOTHROW { + _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; + __tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 1] = _Word; + return __tmp._num; + } + static _Number get_from_last_word() _STLP_NOTHROW { +# if defined (_STLP_BIG_ENDIAN) + return get_word_higher(); +# else /* _STLP_LITTLE_ENDIAN */ + return get_word_lower(); +# endif + } + static _Number get_from_first_word() _STLP_NOTHROW { +# if defined (_STLP_BIG_ENDIAN) + return get_word_lower(); +# else /* _STLP_LITTLE_ENDIAN */ + return get_word_higher(); +# endif + } +}; + +# if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_BIG_ENDIAN) +template +struct float_helper2 { + union _WordsNumber { + unsigned short _Words[8]; + _Number _num; + }; + //static _Number get_word_higher() _STLP_NOTHROW { + // _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET _Word1, _Word2, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; + // return __tmp._num; + //} + static _Number get_word_lower() _STLP_NOTHROW { + _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; + __tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 2] = _Word1; + __tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 1] = _Word2; + return __tmp._num; + } + static _Number get_from_last_word() _STLP_NOTHROW { +//# if defined (_STLP_BIG_ENDIAN) +// return get_word_higher(); +//# else /* _STLP_LITTLE_ENDIAN */ + return get_word_lower(); +//# endif + } +}; +# endif + +/* Former values kept in case moving to boost code has introduce a regression on + * some platform. */ +#if 0 +# if defined (_STLP_BIG_ENDIAN) +# if defined (__OS400__) +# define _STLP_FLOAT_INF_REP { 0x7f80, 0 } +# define _STLP_FLOAT_QNAN_REP { 0xffc0, 0 } +# define _STLP_FLOAT_SNAN_REP { 0xff80, 0 } +# define _STLP_DOUBLE_INF_REP { 0x7ff0, 0, 0, 0 } +# define _STLP_DOUBLE_QNAN_REP { 0xfff8, 0, 0, 0 } +# define _STLP_DOUBLE_SNAN_REP { 0xfff0, 0, 0, 0 } +# define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 } +# define _STLP_LDOUBLE_QNAN_REP { 0xfff8, 0, 0, 0, 0, 0, 0, 0 } +# define _STLP_LDOUBLE_SNAN_REP { 0xfff0, 0, 0, 0, 0, 0, 0, 0 } +# else /* __OS400__ */ +# define _STLP_FLOAT_INF_REP { 0x7f80, 0 } +# define _STLP_FLOAT_QNAN_REP { 0x7fc1, 0 } +# define _STLP_FLOAT_SNAN_REP { 0x7f81, 0 } +# define _STLP_DOUBLE_INF_REP { 0x7ff0, 0, 0, 0 } +# define _STLP_DOUBLE_QNAN_REP { 0x7ff9, 0, 0, 0 } +# define _STLP_DOUBLE_SNAN_REP { 0x7ff1, 0, 0, 0 } +# define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 } +# define _STLP_LDOUBLE_QNAN_REP { 0x7ff1, 0, 0, 0, 0, 0, 0, 0 } +# define _STLP_LDOUBLE_SNAN_REP { 0x7ff9, 0, 0, 0, 0, 0, 0, 0 } +# endif /* __OS400__ */ +# else /* _STLP_LITTLE_ENDIAN */ +# if defined(__DECCXX) +# define _STLP_FLOAT_INF_REP { 0, 0x7f80 } +# define _STLP_FLOAT_QNAN_REP { 0, 0xffc0 } +# define _STLP_FLOAT_SNAN_REP { 0x5555, 0x7f85 } +# define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 } +# define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 } +# define _STLP_DOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x7ff5 } +# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0, 0, 0, 0, 0x7fff } +# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0, 0, 0, 0x8000, 0xffff } +# define _STLP_LDOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x7fff} +# else +# define _STLP_FLOAT_INF_REP { 0, 0x7f80 } +# define _STLP_FLOAT_QNAN_REP { 0, 0x7fc0 } +# define _STLP_FLOAT_SNAN_REP { 0, 0x7fa0 } +# define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 } +# define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0x7ff8 } +# define _STLP_DOUBLE_SNAN_REP { 0, 0, 0, 0x7ff4 } +# if defined (_STLP_MSVC) || defined (__ICL) +# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x7FF0, 0 } +# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xFFF8, 0 } +# define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xFFF8, 0 } +# elif defined (__BORLANDC__) +# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff } +# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xc000, 0x7fff } +# define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xa000, 0x7fff } +# else +# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff, 0 } +# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xa000, 0x7fff, 0 } +# define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xc000, 0x7fff, 0 } +# endif +# endif +# endif + +union _F_rep { + unsigned short rep[2]; + float val; +}; +union _D_rep { + unsigned short rep[4]; + double val; +}; + +# ifndef _STLP_NO_LONG_DOUBLE +union _LD_rep { + unsigned short rep[8]; + long double val; +}; +# endif +#endif + +template +float _STLP_CALL _LimG<__dummy>::get_F_inf() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_last_word(); +} +template +float _STLP_CALL _LimG<__dummy>::get_F_qNaN() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_last_word(); +} +template +float _STLP_CALL _LimG<__dummy>::get_F_sNaN() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_last_word(); +} +template +float _STLP_CALL _LimG<__dummy>::get_F_denormMin() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_first_word(); +} + +template +class _NumericLimitsAccess; + +_STLP_TEMPLATE_NULL +class _NumericLimitsAccess<1> { +public: + static double get_inf() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_last_word(); + } + static double get_qNaN() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_last_word(); + } + static double get_sNaN() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_last_word(); + } +}; + +template +double _STLP_CALL _LimG<__dummy>::get_D_inf() +{ return _NumericLimitsAccess<1>::get_inf(); } +template +double _STLP_CALL _LimG<__dummy>::get_D_qNaN() +{ return _NumericLimitsAccess<1>::get_qNaN(); } +template +double _STLP_CALL _LimG<__dummy>::get_D_sNaN() +{ return _NumericLimitsAccess<1>::get_sNaN(); } +template +double _STLP_CALL _LimG<__dummy>::get_D_denormMin() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_first_word(); +} + +# if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_TEMPLATE_NULL +class _NumericLimitsAccess<0> { +public: + static long double get_inf() { +# if defined (_STLP_BIG_ENDIAN) + typedef float_helper _FloatHelper; +# else + typedef float_helper2 _FloatHelper; +# endif + return _FloatHelper::get_from_last_word(); + } + static long double get_qNaN() { +# if defined (_STLP_BIG_ENDIAN) + typedef float_helper _FloatHelper; +# else + typedef float_helper2 _FloatHelper; +# endif + return _FloatHelper::get_from_last_word(); + } + static long double get_sNaN() { +# if defined (_STLP_BIG_ENDIAN) + typedef float_helper _FloatHelper; +# else + typedef float_helper2 _FloatHelper; +# endif + return _FloatHelper::get_from_last_word(); + } +}; + +template +long double _STLP_CALL _LimG<__dummy>::get_LD_inf() { + const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0; + return _NumericLimitsAccess<__use_double_limits>::get_inf(); +} +template +long double _STLP_CALL _LimG<__dummy>::get_LD_qNaN() { + const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0; + return _NumericLimitsAccess<__use_double_limits>::get_qNaN(); +} +template +long double _STLP_CALL _LimG<__dummy>::get_LD_sNaN() { + const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0; + return _NumericLimitsAccess<__use_double_limits>::get_sNaN(); +} +template +long double _STLP_CALL _LimG<__dummy>::get_LD_denormMin() { + typedef float_helper _FloatHelper; + return _FloatHelper::get_from_first_word(); +} +# endif + +#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */ + +#undef _STLP_LIMITS_MIN_TYPE +#undef _STLP_LIMITS_MAX_TYPE + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_LIMITS_C_INCLUDED */ diff --git a/sdk/tlibstdcxx/stlport/stl/_limits.h b/sdk/tlibstdcxx/stlport/stl/_limits.h new file mode 100644 index 0000000000..f5f840c984 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_limits.h @@ -0,0 +1,519 @@ +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This may be not portable code. Parts of numeric_limits<> are + * inherently machine-dependent. At present this file is suitable + * for the MIPS, SPARC, Alpha and ia32 architectures. + */ + +#ifndef _STLP_INTERNAL_LIMITS +#define _STLP_INTERNAL_LIMITS + +#ifndef _STLP_CLIMITS +# include +#endif + +#ifndef _STLP_CFLOAT +# include +#endif + +#if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_INTERNAL_CWCHAR) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +enum float_round_style { + round_indeterminate = -1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, + round_toward_neg_infinity = 3 +}; + +enum float_denorm_style { + denorm_indeterminate = -1, + denorm_absent = 0, + denorm_present = 1 +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Base class for all specializations of numeric_limits. +template +class _Numeric_limits_base { +public: + + static __number (_STLP_CALL min)() _STLP_NOTHROW { return __number(); } + static __number (_STLP_CALL max)() _STLP_NOTHROW { return __number(); } + + _STLP_STATIC_CONSTANT(int, digits = 0); + _STLP_STATIC_CONSTANT(int, digits10 = 0); + _STLP_STATIC_CONSTANT(int, radix = 0); + _STLP_STATIC_CONSTANT(int, min_exponent = 0); + _STLP_STATIC_CONSTANT(int, min_exponent10 = 0); + _STLP_STATIC_CONSTANT(int, max_exponent = 0); + _STLP_STATIC_CONSTANT(int, max_exponent10 = 0); + + _STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = denorm_absent); + _STLP_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero); + + _STLP_STATIC_CONSTANT(bool, is_specialized = false); + _STLP_STATIC_CONSTANT(bool, is_signed = false); + _STLP_STATIC_CONSTANT(bool, is_integer = false); + _STLP_STATIC_CONSTANT(bool, is_exact = false); + _STLP_STATIC_CONSTANT(bool, has_infinity = false); + _STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false); + _STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false); + _STLP_STATIC_CONSTANT(bool, has_denorm_loss = false); + _STLP_STATIC_CONSTANT(bool, is_iec559 = false); + _STLP_STATIC_CONSTANT(bool, is_bounded = false); + _STLP_STATIC_CONSTANT(bool, is_modulo = false); + _STLP_STATIC_CONSTANT(bool, traps = false); + _STLP_STATIC_CONSTANT(bool, tinyness_before = false); + + static __number _STLP_CALL epsilon() _STLP_NOTHROW { return __number(); } + static __number _STLP_CALL round_error() _STLP_NOTHROW { return __number(); } + + static __number _STLP_CALL infinity() _STLP_NOTHROW { return __number(); } + static __number _STLP_CALL quiet_NaN() _STLP_NOTHROW { return __number(); } + static __number _STLP_CALL signaling_NaN() _STLP_NOTHROW { return __number(); } + static __number _STLP_CALL denorm_min() _STLP_NOTHROW { return __number(); } +}; + +// Base class for integers. + +#ifdef _STLP_LIMITED_DEFAULT_TEMPLATES +# ifdef _STLP_LONG_LONG +# define _STLP_LIMITS_MIN_TYPE _STLP_LONG_LONG +# define _STLP_LIMITS_MAX_TYPE unsigned _STLP_LONG_LONG +# else +# define _STLP_LIMITS_MIN_TYPE long +# define _STLP_LIMITS_MAX_TYPE unsigned long +# endif +#else +# define _STLP_LIMITS_MIN_TYPE _Int +# define _STLP_LIMITS_MAX_TYPE _Int +#endif /* _STLP_LIMITED_DEFAULT_TEMPLATES */ + +template +class _Integer_limits : public _Numeric_limits_base<_Int> { +public: + + static _Int (_STLP_CALL min) () _STLP_NOTHROW { return (_Int)__imin; } + static _Int (_STLP_CALL max) () _STLP_NOTHROW { return (_Int)__imax; } + + _STLP_STATIC_CONSTANT(int, digits = (__idigits < 0) ? ((int)((sizeof(_Int) * (CHAR_BIT))) - ((__imin == 0) ? 0 : 1)) : (__idigits)); + _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000); + _STLP_STATIC_CONSTANT(int, radix = 2); + _STLP_STATIC_CONSTANT(bool, is_specialized = true); + _STLP_STATIC_CONSTANT(bool, is_signed = (__imin != 0)); + _STLP_STATIC_CONSTANT(bool, is_integer = true); + _STLP_STATIC_CONSTANT(bool, is_exact = true); + _STLP_STATIC_CONSTANT(bool, is_bounded = true); + _STLP_STATIC_CONSTANT(bool, is_modulo = __ismod); +}; + +// Base class for floating-point numbers. +template +class _Floating_limits : public _Numeric_limits_base<__number> { +public: + + _STLP_STATIC_CONSTANT(int, digits = __Digits); + _STLP_STATIC_CONSTANT(int, digits10 = __Digits10); + _STLP_STATIC_CONSTANT(int, radix = FLT_RADIX); + _STLP_STATIC_CONSTANT(int, min_exponent = __MinExp); + _STLP_STATIC_CONSTANT(int, max_exponent = __MaxExp); + _STLP_STATIC_CONSTANT(int, min_exponent10 = __MinExp10); + _STLP_STATIC_CONSTANT(int, max_exponent10 = __MaxExp10); + + _STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = __DenormStyle); + _STLP_STATIC_CONSTANT(float_round_style, round_style = __RoundStyle); + + _STLP_STATIC_CONSTANT(bool, is_specialized = true); + _STLP_STATIC_CONSTANT(bool, is_signed = true); + + _STLP_STATIC_CONSTANT(bool, has_infinity = true); +#if (!defined (_STLP_MSVC) || (_STLP_MSVC > 1300)) && \ + (!defined (__BORLANDC__) || (__BORLANDC__ >= 0x590)) && \ + (!defined (_CRAY) || defined (_CRAYIEEE)) + _STLP_STATIC_CONSTANT(bool, has_quiet_NaN = true); + _STLP_STATIC_CONSTANT(bool, has_signaling_NaN = true); +#else + _STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false); + _STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false); +#endif + + _STLP_STATIC_CONSTANT(bool, is_iec559 = __IsIEC559 && has_infinity && has_quiet_NaN && has_signaling_NaN && (has_denorm == denorm_present)); + _STLP_STATIC_CONSTANT(bool, has_denorm_loss = false); + _STLP_STATIC_CONSTANT(bool, is_bounded = true); + _STLP_STATIC_CONSTANT(bool, traps = true); + _STLP_STATIC_CONSTANT(bool, tinyness_before = false); +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +// Class numeric_limits + +// The unspecialized class. + +template +class numeric_limits : public _STLP_PRIV _Numeric_limits_base<_Tp> {}; + +// Specializations for all built-in integral types. + +#if !defined (_STLP_NO_BOOL) +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; +#endif /* _STLP_NO_BOOL */ + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +#if !defined (_STLP_NO_SIGNED_BUILTINS) +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; +#endif + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +#if !(defined (_STLP_NO_WCHAR_T) || (!defined (_STLP_SGX_CONFIG) && defined (_STLP_WCHAR_T_IS_USHORT))) + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +#endif + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +#if defined (__xlC__) && (__xlC__ == 0x500) +# undef INT_MIN +# define INT_MIN -2147483648 +#endif + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; + +#if defined (_STLP_LONG_LONG) + +# if defined (_STLP_MSVC) || defined (__BORLANDC__) +# define LONGLONG_MAX 0x7fffffffffffffffi64 +# define LONGLONG_MIN (-LONGLONG_MAX-1i64) +# define ULONGLONG_MAX 0xffffffffffffffffUi64 +# else +# ifndef LONGLONG_MAX +# define LONGLONG_MAX 0x7fffffffffffffffLL +# endif +# ifndef LONGLONG_MIN +# define LONGLONG_MIN (-LONGLONG_MAX-1LL) +# endif +# ifndef ULONGLONG_MAX +# define ULONGLONG_MAX 0xffffffffffffffffULL +# endif +# endif + +# if !defined (__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ <= 96) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 3) + +_STLP_TEMPLATE_NULL +class numeric_limits<_STLP_LONG_LONG> + : public _STLP_PRIV _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true> +{}; + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Integer_limits +{}; +# else /* gcc 2.97 (after 2000-11-01), 2.98, 3.0 */ +/* + newest gcc has new mangling scheme, that has problem + with generating name [instantiated] of template specialization like + _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true> + ~~~~~~~~~~~~ ~~~~~~~~~~~~ + Below is code that solve this problem. + - ptr + */ +_STLP_TEMPLATE_NULL +class numeric_limits<_STLP_LONG_LONG> + : public _STLP_PRIV _Numeric_limits_base<_STLP_LONG_LONG> { +public: + + static _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return LONGLONG_MIN; } + static _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return LONGLONG_MAX; } + + _STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(_STLP_LONG_LONG) * (CHAR_BIT))) - 1)); + _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000); + _STLP_STATIC_CONSTANT(int, radix = 2); + _STLP_STATIC_CONSTANT(bool, is_specialized = true); + _STLP_STATIC_CONSTANT(bool, is_signed = true); + _STLP_STATIC_CONSTANT(bool, is_integer = true); + _STLP_STATIC_CONSTANT(bool, is_exact = true); + _STLP_STATIC_CONSTANT(bool, is_bounded = true); + _STLP_STATIC_CONSTANT(bool, is_modulo = true); +}; + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Numeric_limits_base { +public: + + static unsigned _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return 0ULL; } + static unsigned _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return ULONGLONG_MAX; } + + _STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(unsigned _STLP_LONG_LONG) * (CHAR_BIT))))); + _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000); + _STLP_STATIC_CONSTANT(int, radix = 2); + _STLP_STATIC_CONSTANT(bool, is_specialized = true); + _STLP_STATIC_CONSTANT(bool, is_signed = false); + _STLP_STATIC_CONSTANT(bool, is_integer = true); + _STLP_STATIC_CONSTANT(bool, is_exact = true); + _STLP_STATIC_CONSTANT(bool, is_bounded = true); + _STLP_STATIC_CONSTANT(bool, is_modulo = true); +}; + +# endif /* __GNUC__ > 2000-11-01 */ + +#endif /* _STLP_LONG_LONG */ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Specializations for all built-in floating-point types. +template +class _LimG { +public: + static float _STLP_CALL get_F_inf(); + static float _STLP_CALL get_F_qNaN(); + static float _STLP_CALL get_F_sNaN(); + static float _STLP_CALL get_F_denormMin(); + static double _STLP_CALL get_D_inf(); + static double _STLP_CALL get_D_qNaN(); + static double _STLP_CALL get_D_sNaN(); + static double _STLP_CALL get_D_denormMin(); + +#if !defined (_STLP_NO_LONG_DOUBLE) + static long double _STLP_CALL get_LD_inf(); + static long double _STLP_CALL get_LD_qNaN(); + static long double _STLP_CALL get_LD_sNaN(); + static long double _STLP_CALL get_LD_denormMin(); +#endif +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _LimG; +#endif + +#if defined (__GNUC__) +# if defined (__FLT_DENORM_MIN__) +# define _STLP_FLT_DENORM_MIN __FLT_DENORM_MIN__ +# else +# define _STLP_FLT_DENORM_STYLE denorm_absent +# endif +# if defined (__DBL_DENORM_MIN__) +# define _STLP_DBL_DENORM_MIN __DBL_DENORM_MIN__ +# else +# define _STLP_DBL_DENORM_STYLE denorm_absent +# endif +# if defined (__LDBL_DENORM_MIN__) +# define _STLP_LDBL_DENORM_MIN __LDBL_DENORM_MIN__ +# else +# define _STLP_LDBL_DENORM_STYLE denorm_absent +# endif +#endif + +/* If compiler do not expose thanks to some macro its status regarding + * denormalized floating point numbers, we consider that denormalization + * is present. Unit tests will tell us if compiler do not support them. */ +#if !defined (_STLP_FLT_DENORM_STYLE) +# define _STLP_FLT_DENORM_STYLE denorm_present +#endif + +#if !defined (_STLP_DBL_DENORM_STYLE) +# define _STLP_DBL_DENORM_STYLE denorm_present +#endif + +#if !defined (_STLP_LDBL_DENORM_STYLE) +# define _STLP_LDBL_DENORM_STYLE denorm_present +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Floating_limits { +public: + static float (_STLP_CALL min) () _STLP_NOTHROW { return FLT_MIN; } + static float _STLP_CALL denorm_min() _STLP_NOTHROW +#if defined (_STLP_FLT_DENORM_MIN) + { return _STLP_FLT_DENORM_MIN; } +#else + { return _STLP_FLT_DENORM_STYLE ? _STLP_PRIV _LimG::get_F_denormMin() : FLT_MIN; } +#endif + static float (_STLP_CALL max) () _STLP_NOTHROW { return FLT_MAX; } + static float _STLP_CALL epsilon() _STLP_NOTHROW { return FLT_EPSILON; } + static float _STLP_CALL round_error() _STLP_NOTHROW { return 0.5f; } // Units: ulps. + static float _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG::get_F_inf(); } + static float _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG::get_F_qNaN(); } + static float _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG::get_F_sNaN(); } +}; + +#undef _STLP_FLT_DENORM_MIN +#undef _STLP_FLT_DNORM_STYLE + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Floating_limits { +public: + static double (_STLP_CALL min)() _STLP_NOTHROW { return DBL_MIN; } + static double _STLP_CALL denorm_min() _STLP_NOTHROW +#if defined (_STLP_DBL_DENORM_MIN) + { return _STLP_DBL_DENORM_MIN; } +#else + { return _STLP_DBL_DENORM_STYLE ? _STLP_PRIV _LimG::get_D_denormMin() : DBL_MIN; } +#endif + static double (_STLP_CALL max)() _STLP_NOTHROW { return DBL_MAX; } + static double _STLP_CALL epsilon() _STLP_NOTHROW { return DBL_EPSILON; } + static double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5; } // Units: ulps. + static double _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG::get_D_inf(); } + static double _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG::get_D_qNaN(); } + static double _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG::get_D_sNaN(); } +}; + +#if !defined (_STLP_NO_LONG_DOUBLE) + +_STLP_TEMPLATE_NULL +class numeric_limits + : public _STLP_PRIV _Floating_limits { +public: + static long double (_STLP_CALL min) () _STLP_NOTHROW { return LDBL_MIN; } + static long double _STLP_CALL denorm_min() _STLP_NOTHROW +#if defined (_STLP_LDBL_DENORM_MIN) + { return _STLP_LDBL_DENORM_MIN; } +#else + { return _STLP_LDBL_DENORM_STYLE ? _STLP_PRIV _LimG::get_LD_denormMin() : LDBL_MIN; } +#endif + _STLP_STATIC_CONSTANT(bool, is_iec559 = false); + static long double (_STLP_CALL max) () _STLP_NOTHROW { return LDBL_MAX; } + static long double _STLP_CALL epsilon() _STLP_NOTHROW { return LDBL_EPSILON; } + static long double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5l; } + static long double _STLP_CALL infinity() _STLP_NOTHROW + //For MSVC, long double is nothing more than an alias for double. +#if !defined (_STLP_MSVC) + { return _STLP_PRIV _LimG::get_LD_inf(); } +#else + { return _STLP_PRIV _LimG::get_D_inf(); } +#endif + static long double _STLP_CALL quiet_NaN() _STLP_NOTHROW +#if !defined (_STLP_MSVC) + { return _STLP_PRIV _LimG::get_LD_qNaN(); } +#else + { return _STLP_PRIV _LimG::get_D_qNaN(); } +#endif + static long double _STLP_CALL signaling_NaN() _STLP_NOTHROW +#if !defined (_STLP_MSVC) + { return _STLP_PRIV _LimG::get_LD_sNaN(); } +#else + { return _STLP_PRIV _LimG::get_D_sNaN(); } +#endif +}; + +#endif + +// We write special values (Inf and NaN) as bit patterns and +// cast the the appropriate floating-point types. +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_list.c b/sdk/tlibstdcxx/stlport/stl/_list.c new file mode 100644 index 0000000000..86e420b72d --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_list.c @@ -0,0 +1,250 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_LIST_C +#define _STLP_LIST_C + +#ifndef _STLP_INTERNAL_LIST_H +# include +#endif + +#ifndef _STLP_CARRAY_H +# include +#endif + +#ifndef _STLP_RANGE_ERRORS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) +template +void _STLP_CALL +_List_global<_Dummy>::_Transfer(_List_node_base* __position, + _List_node_base* __first, _List_node_base* __last) { + if (__position != __last) { + // Remove [first, last) from its old position. + __last->_M_prev->_M_next = __position; + __first->_M_prev->_M_next = __last; + __position->_M_prev->_M_next = __first; + + // Splice [first, last) into its new position. + _Node_base* __tmp = __position->_M_prev; + __position->_M_prev = __last->_M_prev; + __last->_M_prev = __first->_M_prev; + __first->_M_prev = __tmp; + } +} +#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */ + +template +void _List_base<_Tp,_Alloc>::clear() { + _Node* __cur = __STATIC_CAST(_Node*, _M_node._M_data._M_next); + while ( +#if defined (__BORLANDC__) // runtime error + __cur && +#endif + __cur != &(_M_node._M_data)) { + _Node* __tmp = __cur; + __cur = __STATIC_CAST(_Node*, __cur->_M_next); + _STLP_STD::_Destroy(&__tmp->_M_data); + this->_M_node.deallocate(__tmp, 1); + } + _M_node._M_data._M_next = &_M_node._M_data; + _M_node._M_data._M_prev = &_M_node._M_data; +} + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define size_type size_t +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define list _STLP_PTR_IMPL_NAME(list) +#elif defined (_STLP_DEBUG) +# define list _STLP_NON_DBG_NAME(list) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template +void list<_Tp, _Alloc>::resize(size_type __new_size, const _Tp& __x) { + iterator __i = begin(); + size_type __len = 0; + for ( ; __i != end() && __len < __new_size; ++__i, ++__len); + + if (__len == __new_size) + erase(__i, end()); + else // __i == end() + insert(end(), __new_size - __len, __x); +} + +template +list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list<_Tp, _Alloc>& __x) { + if (this != &__x) { + iterator __first1 = begin(); + iterator __last1 = end(); + const_iterator __first2 = __x.begin(); + const_iterator __last2 = __x.end(); + while (__first1 != __last1 && __first2 != __last2) + *__first1++ = *__first2++; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + return *this; +} + +template +void list<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) { + iterator __i = begin(); + for ( ; __i != end() && __n > 0; ++__i, --__n) + *__i = __val; + if (__n > 0) + insert(end(), __n, __val); + else + erase(__i, end()); +} + +#if !defined (list) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template +void _S_remove_if(list<_Tp, _Alloc>& __that, _Predicate __pred) { + typedef typename list<_Tp, _Alloc>::iterator _Literator; + _Literator __first = __that.begin(); + _Literator __last = __that.end(); + while (__first != __last) { + _Literator __next = __first; + ++__next; + if (__pred(*__first)) __that.erase(__first); + __first = __next; + } +} + +template +void _S_unique(list<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred) { + typedef typename list<_Tp, _Alloc>::iterator _Literator; + _Literator __first = __that.begin(); + _Literator __last = __that.end(); + if (__first == __last) return; + _Literator __next = __first; + while (++__next != __last) { + if (__binary_pred(*__first, *__next)) + __that.erase(__next); + else + __first = __next; + __next = __first; + } +} + +template +void _S_merge(list<_Tp, _Alloc>& __that, list<_Tp, _Alloc>& __x, + _StrictWeakOrdering __comp) { + typedef typename list<_Tp, _Alloc>::iterator _Literator; + _Literator __first1 = __that.begin(); + _Literator __last1 = __that.end(); + _Literator __first2 = __x.begin(); + _Literator __last2 = __x.end(); + if (__that.get_allocator() == __x.get_allocator()) { + while (__first1 != __last1 && __first2 != __last2) { + if (__comp(*__first2, *__first1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + _Literator __next = __first2; + _List_global_inst::_Transfer(__first1._M_node, __first2._M_node, (++__next)._M_node); + __first2 = __next; + } + else + ++__first1; + } + if (__first2 != __last2) + _List_global_inst::_Transfer(__last1._M_node, __first2._M_node, __last2._M_node); + } + else { + while (__first1 != __last1 && __first2 != __last2) { + if (__comp(*__first2, *__first1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __first1 = __that.insert(__first1, *__first2); + } + else + ++__first1; + } + if (__first2 != __last2) { + __that.insert(__first1, __first2, __last2); + } + __x.clear(); + } +} + +template +void _S_sort(list<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp) { + // Do nothing if the list has length 0 or 1. + if (__that._M_node._M_data._M_next == &__that._M_node._M_data || + __that._M_node._M_data._M_next->_M_next == &__that._M_node._M_data) + return; + + list<_Tp, _Alloc> __carry(__that.get_allocator()); + const int NB = 64; + _STLP_PRIV _CArray, NB> __counter(__carry); + int __fill = 0; + while (!__that.empty()) { + __carry.splice(__carry.begin(), __that, __that.begin()); + int __i = 0; + while (__i < __fill && !__counter[__i].empty()) { + _S_merge(__counter[__i], __carry, __comp); + __carry.swap(__counter[__i++]); + } + __carry.swap(__counter[__i]); + if (__i == __fill) { + ++__fill; + if (__fill >= NB) { + //Looks like the list has too many elements to be sorted with this algorithm: + __stl_throw_overflow_error("list::sort"); + } + } + } + + for (int __i = 1; __i < __fill; ++__i) + _S_merge(__counter[__i], __counter[__i - 1], __comp); + __that.swap(__counter[__fill - 1]); +} + +#if defined (list) +# undef list +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_LIST_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_list.h b/sdk/tlibstdcxx/stlport/stl/_list.h new file mode 100644 index 0000000000..6cd3f2b1a1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_list.h @@ -0,0 +1,742 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_LIST_IMPL_H +#define _STLP_INTERNAL_LIST_IMPL_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _List_node_base { + _List_node_base* _M_next; + _List_node_base* _M_prev; +}; + +template +class _List_global { +public: + typedef _List_node_base _Node_base; + static void _STLP_CALL _Transfer(_Node_base* __pos, + _Node_base* __first, _Node_base* __last); +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _List_global; +#endif +typedef _List_global _List_global_inst; + +template +class _List_node : public _List_node_base { +public: + _Tp _M_data; + __TRIVIAL_STUFF(_List_node) +}; + +struct _List_iterator_base { + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef bidirectional_iterator_tag iterator_category; + + _List_node_base* _M_node; + + _List_iterator_base(_List_node_base* __x) : _M_node(__x) {} + + void _M_incr() { _M_node = _M_node->_M_next; } + void _M_decr() { _M_node = _M_node->_M_prev; } +}; + + +template +struct _List_iterator : public _List_iterator_base { + typedef _Tp value_type; + typedef typename _Traits::pointer pointer; + typedef typename _Traits::reference reference; + + typedef _List_iterator<_Tp, _Traits> _Self; + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef _List_iterator<_Tp, _NonConstTraits> iterator; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _List_iterator<_Tp, _ConstTraits> const_iterator; + + typedef bidirectional_iterator_tag iterator_category; + typedef _List_node<_Tp> _Node; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + explicit _List_iterator(_List_node_base* __x) : _List_iterator_base(__x) {} + _List_iterator() : _List_iterator_base(0) {} + //copy constructor for iterator and constructor from iterator for const_iterator + _List_iterator(const iterator& __x) : _List_iterator_base(__x._M_node) {} + + reference operator*() const { return __STATIC_CAST(_Node*, this->_M_node)->_M_data; } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + this->_M_incr(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + this->_M_incr(); + return __tmp; + } + _Self& operator--() { + this->_M_decr(); + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + this->_M_decr(); + return __tmp; + } + bool operator==(const_iterator __y ) const { + return this->_M_node == __y._M_node; + } + bool operator!=(const_iterator __y ) const { + return this->_M_node != __y._M_node; + } +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_MOVE_TO_STD_NAMESPACE +template +struct __type_traits<_STLP_PRIV _List_iterator<_Tp, _Traits> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +_STLP_MOVE_TO_STD_NAMESPACE +template +inline _Tp* value_type(const _STLP_PRIV _List_iterator<_Tp, _Traits>&) { return 0; } +inline bidirectional_iterator_tag iterator_category(const _STLP_PRIV _List_iterator_base&) { return bidirectional_iterator_tag();} +inline ptrdiff_t* distance_type(const _STLP_PRIV _List_iterator_base&) { return 0; } +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +// Base class that encapsulates details of allocators and helps +// to simplify EH + +template +class _List_base { +protected: + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _List_node_base _Node_base; + typedef _List_node<_Tp> _Node; + typedef _List_base<_Tp, _Alloc> _Self; + typedef typename _Alloc_traits<_Node, _Alloc>::allocator_type _Node_allocator_type; +public: + typedef _STLP_alloc_proxy<_Node_base, _Node, _Node_allocator_type> _AllocProxy; + typedef _Alloc allocator_type; + + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR((const _Node_allocator_type&)_M_node, _Tp); } + + _List_base(const allocator_type& __a) : _M_node(_STLP_CONVERT_ALLOCATOR(__a, _Node), _Node_base()) + { _M_empty_initialize(); } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _List_base(__move_source<_Self> src) : + _M_node(__move_source<_AllocProxy>(src.get()._M_node)) { + if (src.get().empty()) + //We force this to empty. + _M_empty_initialize(); + else { + src.get()._M_empty_initialize(); + _M_node._M_data._M_prev->_M_next = _M_node._M_data._M_next->_M_prev = &_M_node._M_data; + } + } +#endif + + ~_List_base() + { clear(); } + + void clear(); + bool empty() const { return _M_node._M_data._M_next == &_M_node._M_data; } + + void _M_empty_initialize() { + _M_node._M_data._M_next = &_M_node._M_data; + _M_node._M_data._M_prev = _M_node._M_data._M_next; + } + +public: + _AllocProxy _M_node; +}; + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define list _STLP_PTR_IMPL_NAME(list) +#elif defined (_STLP_DEBUG) +# define list _STLP_NON_DBG_NAME(list) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template ) > +class list; + +#if !defined (list) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +// helper functions to reduce code duplication +template +void _S_remove_if(list<_Tp, _Alloc>& __that, _Predicate __pred); + +template +void _S_unique(list<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred); + +template +void _S_merge(list<_Tp, _Alloc>& __that, list<_Tp, _Alloc>& __x, + _StrictWeakOrdering __comp); + +template +void _S_sort(list<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp); + +#if !defined (list) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template +class list : public _STLP_PRIV _List_base<_Tp, _Alloc> +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list) + , public __stlport_class > +#endif +{ + typedef _STLP_PRIV _List_base<_Tp, _Alloc> _Base; + typedef list<_Tp, _Alloc> _Self; + typedef _STLP_PRIV _List_node<_Tp> _Node; + typedef _STLP_PRIV _List_node_base _Node_base; +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef typename _Base::allocator_type allocator_type; + typedef bidirectional_iterator_tag _Iterator_category; + +public: + typedef _STLP_PRIV _List_iterator<_Tp, _Nonconst_traits<_Tp> > iterator; + typedef _STLP_PRIV _List_iterator<_Tp, _Const_traits<_Tp> > const_iterator; + _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; + +protected: +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + _Node_base* _M_create_node(const_reference __x = value_type()) { +#else + _Node_base* _M_create_node(const_reference __x) { +#endif + _Node* __p = this->_M_node.allocate(1); + _STLP_TRY { + _Copy_Construct(&__p->_M_data, __x); + } + _STLP_UNWIND(this->_M_node.deallocate(__p, 1)) + return __p; + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + _Node_base* _M_create_node() { + _Node* __p = this->_M_node.allocate(1); + _STLP_TRY { + _STLP_STD::_Construct(&__p->_M_data); + } + _STLP_UNWIND(this->_M_node.deallocate(__p, 1)) + return __p; + } +#endif + +public: +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit list(size_type __n, const_reference __val = _STLP_DEFAULT_CONSTRUCTED(value_type), + const allocator_type& __a = allocator_type()) +#else + explicit list(size_type __n) + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) + { this->insert(begin(), __n, _STLP_DEFAULT_CONSTRUCTED(value_type)); } + list(size_type __n, const_reference __val) + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) + { this->insert(begin(), __n, __val); } + list(size_type __n, const_reference __val, const allocator_type& __a) +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { this->insert(begin(), __n, __val); } + +#if defined (_STLP_MEMBER_TEMPLATES) + // We don't need any dispatching tricks here, because insert does all of + // that anyway. + template + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { _M_insert(begin(), __first, __last); } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + list(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) + { _M_insert(begin(), __first, __last); } +# endif +#else /* _STLP_MEMBER_TEMPLATES */ + list(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { _M_insert(begin(), __first, __last); } + list(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { _M_insert(begin(), __first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit list(const allocator_type& __a = allocator_type()) +#else + list() + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) {} + list(const allocator_type& __a) +#endif + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) {} + + list(const _Self& __x) : _STLP_PRIV _List_base<_Tp, _Alloc>(__x.get_allocator()) + { _M_insert(begin(), __x.begin(), __x.end()); } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + list(__move_source<_Self> src) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__move_source<_Base>(src.get())) {} +#endif + + ~list() {} + + _Self& operator = (const _Self& __x); + + iterator begin() { return iterator(this->_M_node._M_data._M_next); } + const_iterator begin() const { return const_iterator(this->_M_node._M_data._M_next); } + + iterator end() { return iterator(&this->_M_node._M_data); } + const_iterator end() const { return const_iterator(__CONST_CAST(_Node_base*, &this->_M_node._M_data)); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + size_type size() const { + size_type __result = _STLP_STD::distance(begin(), end()); + return __result; + } + size_type max_size() const { return size_type(-1); } + + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(--end()); } + const_reference back() const { return *(--end()); } + +private: + void _M_swap_aux(_Self& __x) { + __x._M_node._M_swap_alloc(this->_M_node); + __x._M_node._M_data._M_next = this->_M_node._M_data._M_next; + __x._M_node._M_data._M_next->_M_prev = &__x._M_node._M_data; + __x._M_node._M_data._M_prev = this->_M_node._M_data._M_prev; + __x._M_node._M_data._M_prev->_M_next = &__x._M_node._M_data; + this->_M_empty_initialize(); + } + +public: + void swap(_Self& __x) { + if (__x.empty()) { + if (this->empty()) { + return; + } + this->_M_swap_aux(__x); + } else if (this->empty()) { + __x._M_swap_aux(*this); + } else { + this->_M_node.swap(__x._M_node); + _STLP_STD::swap(this->_M_node._M_data._M_prev->_M_next, __x._M_node._M_data._M_prev->_M_next); + _STLP_STD::swap(this->_M_node._M_data._M_next->_M_prev, __x._M_node._M_data._M_next->_M_prev); + } + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const_reference __x = value_type()) +#else + iterator insert(iterator __pos, const_reference __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { + _Node_base* __tmp = _M_create_node(__x); + _Node_base* __n = __pos._M_node; + _Node_base* __p = __n->_M_prev; + __tmp->_M_next = __n; + __tmp->_M_prev = __p; + __p->_M_next = __tmp; + __n->_M_prev = __tmp; + return iterator(__tmp); + } + +private: +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); + } + + // Check whether it's an integral type. If so, it's not an iterator. + template + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + const __true_type& /*_IsIntegral*/) { + _M_fill_insert(__pos, __n, __x); + } + template + void _M_insert_dispatch(iterator __pos, + _InputIter __first, _InputIter __last, + const __false_type& /*_IsIntegral*/) { +#else /* _STLP_MEMBER_TEMPLATES */ + void _M_insert(iterator __pos, const value_type* __first, const value_type* __last) { + for (; __first != __last; ++__first) + insert(__pos, *__first); + } + void _M_insert(iterator __pos, const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + //We use a temporary list to avoid the auto reference troubles (infinite loop) + for (; __first != __last; ++__first) + insert(__pos, *__first); + } + +public: +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_splice_insert_dispatch(__pos, __first, __last, _Integral()); + } + +private: + // Check whether it's an integral type. If so, it's not an iterator. + template + void _M_splice_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + const __true_type& /*_IsIntegral*/) { + _M_fill_insert(__pos, __n, __x); + } + template + void _M_splice_insert_dispatch(iterator __pos, + _InputIter __first, _InputIter __last, + const __false_type& /*_IsIntegral*/) { +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __pos, const value_type* __first, const value_type* __last) { + _Self __tmp(__first, __last, this->get_allocator()); + _STLP_ASSERT(__tmp.get_allocator() == this->get_allocator()) + splice(__pos, __tmp); + } + void insert(iterator __pos, const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + //We use a temporary list to avoid the auto reference troubles (infinite loop) + _Self __tmp(__first, __last, this->get_allocator()); + splice(__pos, __tmp); + } + +public: + void insert(iterator __pos, size_type __n, const_reference __x) + { _M_fill_insert(__pos, __n, __x); } + +private: + void _M_fill_insert(iterator __pos, size_type __n, const_reference __x) { + for ( ; __n > 0; --__n) + insert(__pos, __x); + } + +public: + void push_front(const_reference __x) { insert(begin(), __x); } + void push_back (const_reference __x) { insert(end(), __x); } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos) + { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); } + void push_front() {insert(begin());} + void push_back() {insert(end());} +# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + iterator erase(iterator __pos) { + _Node_base* __next_node = __pos._M_node->_M_next; + _Node_base* __prev_node = __pos._M_node->_M_prev; + _Node* __n = __STATIC_CAST(_Node*, __pos._M_node); + __prev_node->_M_next = __next_node; + __next_node->_M_prev = __prev_node; + _STLP_STD::_Destroy(&__n->_M_data); + this->_M_node.deallocate(__n, 1); + return iterator(__next_node); + } + + iterator erase(iterator __first, iterator __last) { + while (__first != __last) + erase(__first++); + return __last; + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const_reference __x = value_type()); +#else + void resize(size_type __new_size, const_reference __x); + void resize(size_type __new_size) + { this->resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(value_type)); } +#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/ + + void pop_front() { erase(begin()); } + void pop_back() { + iterator __tmp = end(); + erase(--__tmp); + } + +public: + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void assign(size_type __n, const_reference __val) { _M_fill_assign(__n, __val); } + + void _M_fill_assign(size_type __n, const_reference __val); + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } + + template + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) { + _M_fill_assign(__n, __val); + } + + template + void _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2, + const __false_type& /*_IsIntegral*/) { +#else + void assign(const value_type *__first2, const value_type *__last2) { + iterator __first1 = begin(); + iterator __last1 = end(); + for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + *__first1 = *__first2; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + void assign(const_iterator __first2, const_iterator __last2) { +#endif /* _STLP_MEMBER_TEMPLATES */ + iterator __first1 = begin(); + iterator __last1 = end(); + for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + *__first1 = *__first2; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + +public: + void splice(iterator __pos, _Self& __x) { + if (!__x.empty()) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __x.begin()._M_node, __x.end()._M_node); + } + else { + insert(__pos, __x.begin(), __x.end()); + __x.clear(); + } + } + } + void splice(iterator __pos, _Self& __x, iterator __i) { + iterator __j = __i; + ++__j; + if (__pos == __i || __pos == __j) return; + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __i._M_node, __j._M_node); + } + else { + insert(__pos, *__i); + __x.erase(__i); + } + } + void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) { + if (__first != __last) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __first._M_node, __last._M_node); + } + else { + insert(__pos, __first, __last); + __x.erase(__first, __last); + } + } + } + + void remove(const_reference __val) { + iterator __first = begin(); + iterator __last = end(); + while (__first != __last) { + iterator __next = __first; + ++__next; + if (__val == *__first) erase(__first); + __first = __next; + } + } + + void unique() + { _STLP_PRIV _S_unique(*this, equal_to()); } + + void merge(_Self& __x) + { _STLP_PRIV _S_merge(*this, __x, less()); } + + void reverse() { + _Node_base* __p = &this->_M_node._M_data; + _Node_base* __tmp = __p; + do { + _STLP_STD::swap(__tmp->_M_next, __tmp->_M_prev); + __tmp = __tmp->_M_prev; // Old next node is now prev. + } while (__tmp != __p); + } + + void sort() + { _STLP_PRIV _S_sort(*this, less()); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void remove_if(_Predicate __pred) + { _STLP_PRIV _S_remove_if(*this, __pred); } + template + void unique(_BinaryPredicate __binary_pred) + { _STLP_PRIV _S_unique(*this, __binary_pred); } + + template + void merge(_Self& __x, + _StrictWeakOrdering __comp) { + _STLP_PRIV _S_merge(*this, __x, __comp); + } + + template + void sort(_StrictWeakOrdering __comp) + { _STLP_PRIV _S_sort(*this, __comp); } +#endif /* _STLP_MEMBER_TEMPLATES */ +}; + +#if defined (list) +# undef list +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# include +#endif + +#if defined (_STLP_DEBUG) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +_STLP_INLINE_LOOP bool _STLP_CALL +operator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) { + typedef typename list<_Tp,_Alloc>::const_iterator const_iterator; + const_iterator __end1 = __x.end(); + const_iterator __end2 = __y.end(); + + const_iterator __i1 = __x.begin(); + const_iterator __i2 = __y.begin(); + while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) { + ++__i1; + ++__i2; + } + return __i1 == __end1 && __i2 == __end2; +} + +#define _STLP_EQUAL_OPERATOR_SPECIALIZED +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER list<_Tp, _Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER +#undef _STLP_EQUAL_OPERATOR_SPECIALIZED + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > { + typedef __true_type implemented; + typedef typename __move_traits<_Alloc>::complete complete; +}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_LIST_IMPL_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_locale.h b/sdk/tlibstdcxx/stlport/stl/_locale.h new file mode 100644 index 0000000000..fd6d537dda --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_locale.h @@ -0,0 +1,364 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_LOCALE_H +#define _STLP_INTERNAL_LOCALE_H + +#ifndef _STLP_INTERNAL_CSTDLIB +# include +#endif + +#ifndef _STLP_INTERNAL_CWCHAR +# include +#endif + +#ifndef _STLP_INTERNAL_THREADS_H +# include +#endif + +#ifndef _STLP_STRING_FWD_H +# include +#endif + +#include + +_STLP_BEGIN_NAMESPACE + +class _Locale_impl; // Forward declaration of opaque type. +class locale; + +template +bool __locale_do_operator_call(const locale& __loc, + const basic_string<_CharT, _Traits, _Alloc>& __x, + const basic_string<_CharT, _Traits, _Alloc>& __y); + +_STLP_DECLSPEC _Locale_impl * _STLP_CALL _get_Locale_impl( _Locale_impl *locimpl ); +_STLP_DECLSPEC _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl *locimpl ); + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool _HasFacet(const locale& __loc, const _Facet* __facet) _STLP_NOTHROW; + +template +_Facet* _UseFacet(const locale& __loc, const _Facet* __facet); + +template +void _InsertFacet(locale& __loc, _Facet* __facet); + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ + defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +# define locale _STLP_NO_MEM_T_NAME(loc) +#endif + +class _STLP_CLASS_DECLSPEC locale { +public: + // types: + class _STLP_CLASS_DECLSPEC facet : protected _Refcount_Base { + protected: + /* Here we filter __init_count user value to 0 or 1 because __init_count is a + * size_t instance and _Refcount_Base use __stl_atomic_t instances that might + * have lower sizeof and generate roll issues. 1 is enough to keep the facet + * alive when required. */ + explicit facet(size_t __init_count = 0) : _Refcount_Base( __init_count == 0 ? 0 : 1 ) {} + virtual ~facet(); + friend class locale; + friend class _Locale_impl; + friend facet * _STLP_CALL _get_facet( facet * ); + friend void _STLP_CALL _release_facet( facet *& ); + + private: // Invalidate assignment and copying. + facet(const facet& ) /* : _Refcount_Base(1) {} */; + void operator=(const facet&); + }; + +#if defined (__MVS__) || defined (__OS400__) + struct +#else + class +#endif + _STLP_CLASS_DECLSPEC id { + public: + size_t _M_index; + static size_t _S_max; + }; + + typedef int category; + _STLP_STATIC_CONSTANT(category, none = 0x000); + _STLP_STATIC_CONSTANT(category, collate = 0x010); + _STLP_STATIC_CONSTANT(category, ctype = 0x020); + _STLP_STATIC_CONSTANT(category, monetary = 0x040); + _STLP_STATIC_CONSTANT(category, numeric = 0x100); + _STLP_STATIC_CONSTANT(category, time = 0x200); + _STLP_STATIC_CONSTANT(category, messages = 0x400); + _STLP_STATIC_CONSTANT(category, all = collate | ctype | monetary | numeric | time | messages); + + // construct/copy/destroy: + locale() _STLP_NOTHROW; + locale(const locale&) _STLP_NOTHROW; + explicit locale(const char *); + locale(const locale&, const char*, category); + +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + template + locale(const locale& __loc, _Facet* __f) { + if ( __f != 0 ) { + this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) ); + _STLP_PRIV _InsertFacet(*this, __f); + } else { + this->_M_impl = _get_Locale_impl( __loc._M_impl ); + } + } +#endif + +protected: + // those are for internal use + locale(_Locale_impl*); + +public: + locale(const locale&, const locale&, category); + const locale& operator=(const locale&) _STLP_NOTHROW; + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +protected: +#endif + ~locale() _STLP_NOTHROW; + +public: +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && \ + !defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + template + locale combine(const locale& __loc) const { + _Facet *__facet = 0; + if (!_STLP_PRIV _HasFacet(__loc, __facet)) + _M_throw_on_combine_error(__loc.name()); + + return locale(*this, _STLP_PRIV _UseFacet(__loc, __facet)); + } +#endif + + // locale operations: + string name() const; + + bool operator==(const locale&) const; + bool operator!=(const locale&) const; + +#if !defined (_STLP_MEMBER_TEMPLATES) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301) + bool operator()(const string& __x, const string& __y) const; +# ifndef _STLP_NO_WCHAR_T + bool operator()(const wstring& __x, const wstring& __y) const; +# endif +#elif !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + template + bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x, + const basic_string<_CharT, _Traits, _Alloc>& __y) const + { return __locale_do_operator_call(*this, __x, __y); } +#endif + + // global locale objects: +#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + static locale _STLP_CALL global(const locale&); +#else + static _Locale_impl* _STLP_CALL global(const locale&); +#endif + static const locale& _STLP_CALL classic(); + +//protected: // Helper functions for locale globals. + facet* _M_get_facet(const id&) const; + // same, but throws + facet* _M_use_facet(const id&) const; + static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_combine_error(const string& name); + static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_null_name(); + static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_creation_failure(int __err_code, + const char* name, const char* facet); + +//protected: // More helper functions. + void _M_insert(facet* __f, id& __id); + + // friends: + friend class _Locale_impl; + +protected: // Data members + _Locale_impl* _M_impl; + _Locale_impl* _M_get_impl() const { return _M_impl; } +}; + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ + defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +# undef locale +# define _Locale _STLP_NO_MEM_T_NAME(loc) + +class locale : public _Locale { +public: + + // construct/copy/destroy: + locale() _STLP_NOTHROW { +#if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) + _STLP_CHECK_RUNTIME_COMPATIBILITY(); +#endif + } + locale(const locale& __loc) _STLP_NOTHROW : _Locale(__loc) {} + explicit locale(const char *__str) : _Locale(__str) {} + locale(const locale& __loc, const char* __str, category __cat) + : _Locale(__loc, __str, __cat) {} + + template + locale(const locale& __loc, _Facet* __f) + : _Locale(__f != 0 ? _copy_Nameless_Locale_impl(__loc._M_impl) : __loc._M_impl) { + if ( __f != 0 ) { + _STLP_PRIV _InsertFacet(*this, __f); + } + } + +private: + // those are for internal use + locale(_Locale_impl* __impl) : _Locale(__impl) {} + locale(const _Locale& __loc) : _Locale(__loc) {} + +public: + + locale(const locale& __loc1, const locale& __loc2, category __cat) + : _Locale(__loc1, __loc2, __cat) {} + + const locale& operator=(const locale& __loc) _STLP_NOTHROW { + _Locale::operator=(__loc); + return *this; + } + + template + locale combine(const locale& __loc) const { + _Facet *__facet = 0; + if (!_STLP_PRIV _HasFacet(__loc, __facet)) + _M_throw_on_combine_error(__loc.name()); + + return locale(*this, _STLP_PRIV _UseFacet(__loc, __facet)); + } + + // locale operations: + bool operator==(const locale& __loc) const { return _Locale::operator==(__loc); } + bool operator!=(const locale& __loc) const { return _Locale::operator!=(__loc); } + + template + bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x, + const basic_string<_CharT, _Traits, _Alloc>& __y) const + { return __locale_do_operator_call(*this, __x, __y); } + + // global locale objects: + static locale _STLP_CALL global(const locale& __loc) { + return _Locale::global(__loc); + } + static const locale& _STLP_CALL classic() { + return __STATIC_CAST(const locale&, _Locale::classic()); + } + + // friends: + friend class _Locale_impl; +}; + +# undef _Locale +#endif + +//---------------------------------------------------------------------- +// locale globals + +template +inline const _Facet& +#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS +_Use_facet<_Facet>::operator *() const +#else +use_facet(const locale& __loc) +#endif +{ + _Facet *__facet = 0; + return *(_STLP_PRIV _UseFacet(__loc, __facet)); +} + +template +#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS +struct has_facet { + const locale& __loc; + has_facet(const locale& __p_loc) : __loc(__p_loc) {} + operator bool() const _STLP_NOTHROW +#else +inline bool has_facet(const locale& __loc) _STLP_NOTHROW +#endif +{ + _Facet *__facet = 0; + return _STLP_PRIV _HasFacet(__loc, __facet); +} + +#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS +}; // close class definition +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* _GetFacetId is a helper function that allow delaying access to + * facet id static instance in the library source code to avoid + * the other static instances that many compilers are generating + * in all dynamic library or executable when instanciating facet + * template class. + */ +template +inline locale::id& _GetFacetId(const _Facet*) +{ return _Facet::id; } + +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put > >*); + +#ifndef _STLP_NO_WCHAR_T +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get > >*); +_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put > >*); +#endif + +template +inline bool _HasFacet(const locale& __loc, const _Facet* __facet) _STLP_NOTHROW +{ return (__loc._M_get_facet(_GetFacetId(__facet)) != 0); } + +template +inline _Facet* _UseFacet(const locale& __loc, const _Facet* __facet) +{ return __STATIC_CAST(_Facet*, __loc._M_use_facet(_GetFacetId(__facet))); } + +template +inline void _InsertFacet(locale& __loc, _Facet* __facet) +{ __loc._M_insert(__facet, _GetFacetId(__facet)); } + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_LOCALE_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_map.h b/sdk/tlibstdcxx/stlport/stl/_map.h new file mode 100644 index 0000000000..bf46a5ddd7 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_map.h @@ -0,0 +1,435 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_MAP_H +#define _STLP_INTERNAL_MAP_H + +#ifndef _STLP_INTERNAL_TREE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(MapTraitsT, traits) + +template ), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class map +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef map<_Key, _Tp, _Compare, _Alloc> _Self; +public: + +// typedefs: + + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST _Key, _Tp> value_type; + typedef _Compare key_compare; + + class value_compare + : public binary_function { + friend class map<_Key,_Tp,_Compare,_Alloc>; + protected : + //c is a Standard name (23.3.1), do no make it STLport naming convention compliant. + _Compare comp; + value_compare(_Compare __c) : comp(__c) {} + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; + +protected: + typedef _STLP_PRIV _MapTraitsT _MapTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing map + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + // allocation/deallocation + map() : _M_t(_Compare(), allocator_type()) {} +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit map(const _Compare& __comp, + const allocator_type& __a = allocator_type()) +#else + explicit map(const _Compare& __comp) + : _M_t(__comp, allocator_type()) {} + explicit map(const _Compare& __comp, const allocator_type& __a) +#endif + : _M_t(__comp, __a) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template + map(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + template + map(_InputIterator __first, _InputIterator __last, const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + map(_InputIterator __first, _InputIterator __last, const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); } +# endif + +#else + map(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + map(const value_type* __first, + const value_type* __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } + + map(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + map(const_iterator __first, const_iterator __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + map(const _Self& __x) : _M_t(__x._M_t) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + map(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return value_compare(_M_t.key_comp()); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + const_iterator begin() const { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + _STLP_TEMPLATE_FOR_CONT_EXT + _Tp& operator[](const _KT& __k) { + iterator __i = lower_bound(__k); + // __i->first is greater than or equivalent to __k. + if (__i == end() || key_comp()(__k, (*__i).first)) + __i = insert(__i, value_type(__k, _STLP_DEFAULT_CONSTRUCTED(_Tp))); + return (*__i).second; + } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + pair insert(const value_type& __x) + { return _M_t.insert_unique(__x); } + iterator insert(iterator __pos, const value_type& __x) + { return _M_t.insert_unique(__pos, __x); } +#ifdef _STLP_MEMBER_TEMPLATES + template + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_unique(__first, __last); } +#else + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_unique(__first, __last); } + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void erase(iterator __pos) { _M_t.erase(__pos); } + size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); } + void clear() { _M_t.clear(); } + + // map operations: + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) + { return _M_t.equal_range_unique(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const + { return _M_t.equal_range_unique(__x); } +}; + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(MultimapTraitsT, traits) + +template ), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class multimap +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef multimap<_Key, _Tp, _Compare, _Alloc> _Self; +public: + +// typedefs: + + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST _Key, _Tp> value_type; + typedef _Compare key_compare; + + class value_compare : public binary_function { + friend class multimap<_Key,_Tp,_Compare,_Alloc>; + protected: + //comp is a Standard name (23.3.2), do no make it STLport naming convention compliant. + _Compare comp; + value_compare(_Compare __c) : comp(__c) {} + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; + +protected: + //Specific iterator traits creation + typedef _STLP_PRIV _MultimapTraitsT _MultimapTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing multimap + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + // allocation/deallocation + multimap() : _M_t(_Compare(), allocator_type()) { } + explicit multimap(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { } + +#ifdef _STLP_MEMBER_TEMPLATES + template + multimap(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS + template + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); } +# endif + template + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +#else + multimap(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + multimap(const value_type* __first, const value_type* __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } + + multimap(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + multimap(const_iterator __first, const_iterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + multimap(const _Self& __x) : _M_t(__x._M_t) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + multimap(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + + // accessors: + + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return value_compare(_M_t.key_comp()); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + const_iterator begin() const { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); } + iterator insert(iterator __pos, const value_type& __x) { return _M_t.insert_equal(__pos, __x); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_equal(__first, __last); } +#else + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_equal(__first, __last); } + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + void erase(iterator __pos) { _M_t.erase(__pos); } + size_type erase(const key_type& __x) { return _M_t.erase(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); } + void clear() { _M_t.clear(); } + + // multimap operations: + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { return _M_t.count(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) + { return _M_t.equal_range(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const + { return _M_t.equal_range(__x); } +}; + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER map<_Key,_Tp,_Compare,_Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER multimap<_Key,_Tp,_Compare,_Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux::_Rep_type> +{}; + +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux::_Rep_type> +{}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_MAP_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_mbstate_t.h b/sdk/tlibstdcxx/stlport/stl/_mbstate_t.h new file mode 100644 index 0000000000..e6a3e75bc3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_mbstate_t.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_MBSTATE_T +#define _STLP_INTERNAL_MBSTATE_T + +#if (defined (__OpenBSD__) || defined (__FreeBSD__) || defined (__hpux)) && defined (__GNUC__) && !defined (_GLIBCPP_HAVE_MBSTATE_T) +# define _STLP_CPP_MBSTATE_T /* mbstate_t defined in native , so not defined in C! */ +#endif + +#if defined (_STLP_NO_NATIVE_MBSTATE_T) || defined (_STLP_CPP_MBSTATE_T) && !defined (_MBSTATE_T) +# define _STLP_USE_OWN_MBSTATE_T +# define _MBSTATE_T +#endif + +#if defined (_STLP_USE_OWN_MBSTATE_T) +# if !defined (_STLP_CPP_MBSTATE_T) || !defined (__cplusplus) || !defined (_STLP_USE_NEW_C_HEADERS) +typedef int mbstate_t; +# endif + +# if !defined (_STLP_CPP_MBSTATE_T) && defined (__cplusplus) && defined (_STLP_USE_NAMESPACES) +_STLP_BEGIN_NAMESPACE +using ::mbstate_t; +_STLP_END_NAMESPACE +# endif + +#endif /* _STLP_USE_OWN_MBSTATE_T */ + +#endif /* _STLP_INTERNAL_MBSTATE_T */ diff --git a/sdk/tlibstdcxx/stlport/stl/_messages_facets.h b/sdk/tlibstdcxx/stlport/stl/_messages_facets.h new file mode 100644 index 0000000000..aca5596574 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_messages_facets.h @@ -0,0 +1,185 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_MESSAGES_H +#define _STLP_INTERNAL_MESSAGES_H + +#ifndef _STLP_IOS_BASE_H +# include +#endif + +#ifndef _STLP_C_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// messages facets + +class messages_base { + public: + typedef int catalog; +}; + +template class messages {}; + +_STLP_MOVE_TO_PRIV_NAMESPACE +class _Messages; +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC messages : public locale::facet, public messages_base { +public: + typedef messages_base::catalog catalog; + typedef char char_type; + typedef string string_type; + + explicit messages(size_t __refs = 0); + + catalog open(const string& __fn, const locale& __loc) const + { return do_open(__fn, __loc); } + string_type get(catalog __c, int __set, int __msgid, + const string_type& __dfault) const + { return do_get(__c, __set, __msgid, __dfault); } + inline void close(catalog __c) const + { do_close(__c); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~messages() {} + + virtual catalog do_open(const string& __fn, const locale& __loc) const + { return -1; } + virtual string_type do_get(catalog __c, int __set, int __msgid, + const string_type& __dfault) const + { return __dfault; } + virtual void do_close(catalog __c) const + {} +}; + +#if !defined (_STLP_NO_WCHAR_T) + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC messages : public locale::facet, public messages_base { +public: + typedef messages_base::catalog catalog; + typedef wchar_t char_type; + typedef wstring string_type; + + explicit messages(size_t __refs = 0); + + inline catalog open(const string& __fn, const locale& __loc) const + { return do_open(__fn, __loc); } + inline string_type get(catalog __c, int __set, int __msgid, + const string_type& __dfault) const + { return do_get(__c, __set, __msgid, __dfault); } + inline void close(catalog __c) const + { do_close(__c); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~messages() {} + + virtual catalog do_open(const string& __fn, const locale& __loc) const + { return -1; } + virtual string_type do_get(catalog __c, int __set, int __msgid, + const string_type& __dfault) const + { return __dfault; } + virtual void do_close(catalog __c) const + {} +}; + +#endif + +template class messages_byname {}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC messages_byname : public messages { + friend class _Locale_impl; +public: + typedef messages_base::catalog catalog; + typedef string string_type; + + explicit messages_byname(const char* __name, size_t __refs = 0); + +protected: + ~messages_byname(); + + virtual catalog do_open(const string& __fn, const locale& __loc) const; + virtual string_type do_get(catalog __c, int __set, int __msgid, + const string_type& __dfault) const; + virtual void do_close(catalog __c) const; + +private: + messages_byname(_Locale_messages*); + typedef messages_byname _Self; + //explicitely defined as private to avoid warnings: + messages_byname(_Self const&); + _Self& operator = (_Self const&); + + _STLP_PRIV _Messages* _M_impl; +}; + +#if !defined (_STLP_NO_WCHAR_T) +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC messages_byname : public messages { + friend class _Locale_impl; +public: + typedef messages_base::catalog catalog; + typedef wstring string_type; + + explicit messages_byname(const char* __name, size_t __refs = 0); + +protected: + ~messages_byname(); + + virtual catalog do_open(const string& __fn, const locale& __loc) const; + virtual string_type do_get(catalog __c, int __set, int __msgid, + const string_type& __dfault) const; + virtual void do_close(catalog __c) const; + +private: + messages_byname(_Locale_messages*); + typedef messages_byname _Self; + //explicitely defined as private to avoid warnings: + messages_byname(_Self const&); + _Self& operator = (_Self const&); + + _STLP_PRIV _Messages* _M_impl; +}; +#endif /* WCHAR_T */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_MESSAGES_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_monetary.c b/sdk/tlibstdcxx/stlport/stl/_monetary.c new file mode 100644 index 0000000000..3de937cbc1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_monetary.c @@ -0,0 +1,527 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_MONETARY_C +#define _STLP_MONETARY_C + +# ifndef _STLP_INTERNAL_MONETARY_H +# include +# endif + +#ifndef _STLP_INTERNAL_IOS_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUM_PUT_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUM_GET_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +locale::id money_get<_CharT, _InputIterator>::id; + +template +locale::id money_put<_CharT, _OutputIterator>::id; + +// money_get facets + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// helper functions for do_get +template +pair<_InIt1, bool> __get_string( _InIt1 __first, _InIt1 __last, + _InIt2 __str_first, _InIt2 __str_last) { + while ( __first != __last && __str_first != __str_last && *__first == *__str_first ) { + ++__first; + ++__str_first; + } + return make_pair(__first, __str_first == __str_last); +} + +template +bool +__get_monetary_value(_InIt& __first, _InIt __last, _OuIt __out_ite, + const ctype<_CharT>& _c_type, + _CharT __point, int __frac_digits, _CharT __sep, + const string& __grouping, bool &__syntax_ok) { + if (__first == __last || !_c_type.is(ctype_base::digit, *__first)) + return false; + + char __group_sizes[128]; + char* __group_sizes_end = __grouping.empty()? 0 : __group_sizes; + char __current_group_size = 0; + + while (__first != __last) { + if (_c_type.is(ctype_base::digit, *__first)) { + ++__current_group_size; + *__out_ite++ = *__first++; + } + else if (__group_sizes_end) { + if (*__first == __sep) { + *__group_sizes_end++ = __current_group_size; + __current_group_size = 0; + ++__first; + } + else break; + } + else + break; + } + + if (__grouping.empty()) + __syntax_ok = true; + else { + if (__group_sizes_end != __group_sizes) + *__group_sizes_end++ = __current_group_size; + + __syntax_ok = __valid_grouping(__group_sizes, __group_sizes_end, + __grouping.data(), __grouping.data()+ __grouping.size()); + + if (__first == __last || *__first != __point) { + for (int __digits = 0; __digits != __frac_digits; ++__digits) + *__out_ite++ = _CharT('0'); + return true; // OK not to have decimal point + } + } + + ++__first; + + int __digits = 0; + + while (__first != __last && _c_type.is(ctype_base::digit, *__first)) { + *__out_ite++ = *__first++; + ++__digits; + } + + __syntax_ok = __syntax_ok && (__digits == __frac_digits); + + return true; +} + + +template +_InputIter __money_do_get(_InputIter __s, _InputIter __end, bool __intl, + ios_base& __str, ios_base::iostate& __err, + _StrType& __digits, bool &__is_positive, _CharT* /*__dummy*/) { + if (__s == __end) { + __err |= ios_base::eofbit; + return __s; + } + + typedef _CharT char_type; + typedef _StrType string_type; + typedef _InputIter iter_type; + typedef moneypunct _Punct; + typedef moneypunct _Punct_intl; + typedef ctype _Ctype; + + locale __loc = __str.getloc(); + const _Punct& __punct = use_facet<_Punct>(__loc) ; + const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ; + const _Ctype& __c_type = use_facet<_Ctype>(__loc) ; + + money_base::pattern __format = __intl ? __punct_intl.neg_format() + : __punct.neg_format(); + string_type __ns = __intl ? __punct_intl.negative_sign() + : __punct.negative_sign(); + string_type __ps = __intl ? __punct_intl.positive_sign() + : __punct.positive_sign(); + int __i; + bool __symbol_required = (__str.flags() & ios_base::showbase) != 0; + string_type __buf; + back_insert_iterator __out_ite(__buf); + + for (__i = 0; __i < 4; ++__i) { + switch (__format.field[__i]) { + case money_base::space: + if (!__c_type.is(ctype_base::space, *__s)) { + __err = ios_base::failbit; + return __s; + } + ++__s; + case money_base::none: + while (__s != __end && __c_type.is(ctype_base::space, *__s)) + ++__s; + break; + case money_base::symbol: { + string_type __curs = __intl ? __punct_intl.curr_symbol() + : __punct.curr_symbol(); + pair + __result = __get_string(__s, __end, __curs.begin(), __curs.end()); + if (!__result.second && __symbol_required) + __err = ios_base::failbit; + __s = __result.first; + break; + } + case money_base::sign: { + if (__s == __end) { + if (__ps.empty()) + break; + if (__ns.empty()) { + __is_positive = false; + break; + } + __err = ios_base::failbit; + return __s; + } + else { + if (__ps.empty()) { + if (__ns.empty()) + break; + if (*__s == __ns[0]) { + ++__s; + __is_positive = false; + } + break; + } + else { + if (*__s == __ps[0]) { + ++__s; + break; + } + if (__ns.empty()) + break; + if (*__s == __ns[0]) { + ++__s; + __is_positive = false; + break; + } + __err = ios_base::failbit; + } + } + return __s; + } + case money_base::value: { + char_type __point = __intl ? __punct_intl.decimal_point() + : __punct.decimal_point(); + int __frac_digits = __intl ? __punct_intl.frac_digits() + : __punct.frac_digits(); + string __grouping = __intl ? __punct_intl.grouping() + : __punct.grouping(); + bool __syntax_ok = true; + + bool __result; + + char_type __sep = __grouping.empty() ? char_type() : + __intl ? __punct_intl.thousands_sep() : __punct.thousands_sep(); + + __result = __get_monetary_value(__s, __end, __out_ite, __c_type, + __point, __frac_digits, + __sep, + __grouping, __syntax_ok); + + if (!__syntax_ok) + __err |= ios_base::failbit; + if (!__result) { + __err = ios_base::failbit; + return __s; + } + break; + + } // Close money_base::value case + } // Close switch statement + } // Close for loop + + if (__is_positive) { + if (__ps.size() > 1) { + pair<_InputIter, bool> + __result = __get_string(__s, __end, __ps.begin() + 1, __ps.end()); + __s = __result.first; + if (!__result.second) + __err |= ios::failbit; + } + if (!(__err & ios_base::failbit)) + __digits = __buf; + } + else { + if (__ns.size() > 1) { + pair<_InputIter, bool> + __result = __get_string(__s, __end, __ns.begin() + 1, __ns.end()); + __s = __result.first; + if (!__result.second) + __err |= ios::failbit; + } + if (!(__err & ios::failbit)) { + __digits = __c_type.widen('-'); + __digits += __buf; + } + } + if (__s == __end) + __err |= ios::eofbit; + + return __s; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +//===== methods ====== +template +_InputIter +money_get<_CharT, _InputIter>::do_get(_InputIter __s, _InputIter __end, bool __intl, + ios_base& __str, ios_base::iostate& __err, + _STLP_LONGEST_FLOAT_TYPE& __units) const { + string_type __buf; + bool __is_positive = true; + __s = _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __buf, __is_positive, (_CharT*)0); + + if (__err == ios_base::goodbit || __err == ios_base::eofbit) { + typename string_type::iterator __b = __buf.begin(), __e = __buf.end(); + + if (!__is_positive) ++__b; + // Can't use atold, since it might be wchar_t. Don't get confused by name below : + // it's perfectly capable of reading long double. + _STLP_PRIV __get_decimal_integer(__b, __e, __units, (_CharT*)0); + + if (!__is_positive) { + __units = -__units; + } + } + + return __s; +} + +template +_InputIter +money_get<_CharT, _InputIter>::do_get(iter_type __s, iter_type __end, bool __intl, + ios_base& __str, ios_base::iostate& __err, + string_type& __digits) const { + bool __is_positive = true; + return _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __digits, __is_positive, (_CharT*)0); +} + +// money_put facets + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIter __money_do_put(_OutputIter __s, bool __intl, ios_base& __str, + _CharT __fill, const _Str& __digits, bool __check_digits, + _Str_Type * /*__dummy*/) { + typedef _CharT char_type; + typedef _Str_Type string_type; + typedef ctype _Ctype; + typedef moneypunct _Punct; + typedef moneypunct _Punct_intl; + + locale __loc = __str.getloc(); + const _Ctype& __c_type = use_facet<_Ctype>(__loc) ; + const _Punct& __punct = use_facet<_Punct>(__loc) ; + const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ; + + // some special characters + char_type __minus = __c_type.widen('-'); + char_type __plus = __c_type.widen('+'); + char_type __space = __c_type.widen(' '); + char_type __zero = __c_type.widen('0'); + char_type __point = __intl ? __punct_intl.decimal_point() + : __punct.decimal_point(); + + char_type __sep = __intl ? __punct_intl.thousands_sep() + : __punct.thousands_sep(); + + string __grouping = __intl ? __punct_intl.grouping() + : __punct.grouping(); + + int __frac_digits = __intl ? __punct_intl.frac_digits() + : __punct.frac_digits(); + + string_type __curr_sym = __intl ? __punct_intl.curr_symbol() + : __punct.curr_symbol(); + + // if there are no digits we are going to return __s. If there + // are digits, but not enough to fill the frac_digits, we are + // going to add zeros. I don't know whether this is right or + // not. + if (__digits.empty()) + return __s; + + typename string_type::const_iterator __digits_first = __digits.begin(); + typename string_type::const_iterator __digits_last = __digits.end(); + + bool __is_negative = *__digits_first == __minus; + if (__is_negative) + ++__digits_first; + +#if !defined (__BORLANDC__) + string_type __sign = __intl ? __is_negative ? __punct_intl.negative_sign() + : __punct_intl.positive_sign() + : __is_negative ? __punct.negative_sign() + : __punct.positive_sign(); +#else + string_type __sign; + if (__intl) { + if (__is_negative) + __sign = __punct_intl.negative_sign(); + else + __sign = __punct_intl.positive_sign(); + } + else { + if (__is_negative) + __sign = __punct.negative_sign(); + else + __sign = __punct.positive_sign(); + } +#endif + + if (__check_digits) { + typename string_type::const_iterator __cp = __digits_first; + while (__cp != __digits_last && __c_type.is(ctype_base::digit, *__cp)) + ++__cp; + if (__cp == __digits_first) + return __s; + __digits_last = __cp; + } + + // If grouping is required, we make a copy of __digits and + // insert the grouping. + _STLP_BASIC_IOSTRING(char_type) __new_digits; + if (!__grouping.empty()) { + __new_digits.assign(__digits_first, __digits_last); + __insert_grouping(__new_digits, + __new_digits.size() - __frac_digits, + __grouping, + __sep, __plus, __minus, 0); + __digits_first = __new_digits.begin(); // <<-- + __digits_last = __new_digits.end(); // <<-- + } + + // Determine the amount of padding required, if any. + streamsize __width = __str.width(); + +#if defined (_STLP_DEBUG) && (defined(__HP_aCC) && (__HP_aCC <= 1)) + size_t __value_length = operator -(__digits_last, __digits_first); +#else + size_t __value_length = __digits_last - __digits_first; +#endif + + size_t __length = __value_length + __sign.size(); + + if (__frac_digits != 0) + ++__length; + + bool __generate_curr = (__str.flags() & ios_base::showbase) !=0; + if (__generate_curr) + __length += __curr_sym.size(); + money_base::pattern __format = __intl ? (__is_negative ? __punct_intl.neg_format() + : __punct_intl.pos_format()) + : (__is_negative ? __punct.neg_format() + : __punct.pos_format()); + { + //For the moment the following is commented for decoding reason. + //No reason to add a space last if the money symbol do not have to be display + //if (__format.field[3] == (char) money_base::symbol && !__generate_curr) { + // if (__format.field[2] == (char) money_base::space) { + // __format.field[2] = (char) money_base::none; + // } + //} + //space can only be second or third and only once (22.2.6.3-1): + if ((__format.field[1] == (char) money_base::space) || + (__format.field[2] == (char) money_base::space)) + ++__length; + } + + const bool __need_fill = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __length) < __width)) || + ((sizeof(streamsize) <= sizeof(size_t)) && (__length < __STATIC_CAST(size_t, __width)))); + streamsize __fill_amt = __need_fill ? __width - __length : 0; + + ios_base::fmtflags __fill_pos = __str.flags() & ios_base::adjustfield; + + if (__fill_amt != 0 && + !(__fill_pos & (ios_base::left | ios_base::internal))) + __s = _STLP_PRIV __fill_n(__s, __fill_amt, __fill); + + for (int __i = 0; __i < 4; ++__i) { + char __ffield = __format.field[__i]; + switch (__ffield) { + case money_base::space: + *__s++ = __space; + case money_base::none: + if (__fill_amt != 0 && __fill_pos == ios_base::internal) + __s = _STLP_PRIV __fill_n(__s, __fill_amt, __fill); + break; + case money_base::symbol: + if (__generate_curr) + __s = _STLP_STD::copy(__curr_sym.begin(), __curr_sym.end(), __s); + break; + case money_base::sign: + if (!__sign.empty()) + *__s++ = __sign[0]; + break; + case money_base::value: + if (__frac_digits == 0) { + __s = _STLP_STD::copy(__digits_first, __digits_last, __s); + } else { + if ((int)__value_length <= __frac_digits) { + // if we see '9' here, we should out 0.09 + *__s++ = __zero; // integer part is zero + *__s++ = __point; // decimal point + __s = _STLP_PRIV __fill_n(__s, __frac_digits - __value_length, __zero); // zeros + __s = _STLP_STD::copy(__digits_first, __digits_last, __s); // digits + } else { + __s = _STLP_STD::copy(__digits_first, __digits_last - __frac_digits, __s); + if (__frac_digits != 0) { + *__s++ = __point; + __s = _STLP_STD::copy(__digits_last - __frac_digits, __digits_last, __s); + } + } + } + break; + } //Close for switch + } // Close for loop + + // Ouput rest of sign if necessary. + if (__sign.size() > 1) + __s = _STLP_STD::copy(__sign.begin() + 1, __sign.end(), __s); + if (__fill_amt != 0 && + !(__fill_pos & (ios_base::right | ios_base::internal))) + __s = _STLP_PRIV __fill_n(__s, __fill_amt, __fill); + + return __s; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_OutputIter +money_put<_CharT, _OutputIter> + ::do_put(_OutputIter __s, bool __intl, ios_base& __str, + char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const { + _STLP_BASIC_IOSTRING(char_type) __digits; + _STLP_PRIV __get_money_digits(__digits, __str, __units); + return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, false, __STATIC_CAST(string_type*, 0)); +} + +template +_OutputIter +money_put<_CharT, _OutputIter> + ::do_put(_OutputIter __s, bool __intl, ios_base& __str, + char_type __fill, const string_type& __digits) const { + return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, true, __STATIC_CAST(string_type*, 0)); +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_MONETARY_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_monetary.h b/sdk/tlibstdcxx/stlport/stl/_monetary.h new file mode 100644 index 0000000000..7b9301076d --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_monetary.h @@ -0,0 +1,435 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_MONETARY_H +#define _STLP_INTERNAL_MONETARY_H + +#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H +# include +#endif + +#ifndef _STLP_FACETS_FWD_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +class money_base { +public: + enum part {none, space, symbol, sign, value}; + struct pattern { + char field[4]; + }; +}; + +// moneypunct facets: forward declaration +template class moneypunct {}; + +// money_get facets + +template +class money_get : public locale::facet { +public: + typedef _CharT char_type; + typedef _InputIter iter_type; + typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type; + + explicit money_get(size_t __refs = 0) : locale::facet(__refs) {} + iter_type get(iter_type __s, iter_type __end, bool __intl, + ios_base& __str, ios_base::iostate& __err, + _STLP_LONGEST_FLOAT_TYPE& __units) const + { return do_get(__s, __end, __intl, __str, __err, __units); } + iter_type get(iter_type __s, iter_type __end, bool __intl, + ios_base& __str, ios_base::iostate& __err, + string_type& __digits) const + { return do_get(__s, __end, __intl, __str, __err, __digits); } + + static locale::id id; + +protected: + ~money_get() {} + virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl, + ios_base& __str, ios_base::iostate& __err, + _STLP_LONGEST_FLOAT_TYPE& __units) const; + virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl, + ios_base& __str, ios_base::iostate& __err, + string_type& __digits) const; +}; + + +// moneypunct facets: definition of specializations + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct : public locale::facet, public money_base { +public: + typedef char char_type; + typedef string string_type; + explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0); + + char decimal_point() const { return do_decimal_point(); } + char thousands_sep() const { return do_thousands_sep(); } + string grouping() const { return do_grouping(); } + string_type curr_symbol() const { return do_curr_symbol(); } + string_type positive_sign() const { return do_positive_sign(); } + string_type negative_sign() const { return do_negative_sign(); } + int frac_digits() const { return do_frac_digits(); } + pattern pos_format() const { return do_pos_format(); } + pattern neg_format() const { return do_neg_format(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + _STLP_STATIC_CONSTANT(bool, intl = true); + +protected: + pattern _M_pos_format; + pattern _M_neg_format; + + ~moneypunct _STLP_PSPEC2(char, true) (); + + virtual char do_decimal_point() const; + virtual char do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string do_curr_symbol() const; + + virtual string do_positive_sign() const; + virtual string do_negative_sign() const; + virtual int do_frac_digits() const; + virtual pattern do_pos_format() const; + virtual pattern do_neg_format() const; +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct : public locale::facet, public money_base { +public: + typedef char char_type; + typedef string string_type; + + explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0); + + char decimal_point() const { return do_decimal_point(); } + char thousands_sep() const { return do_thousands_sep(); } + string grouping() const { return do_grouping(); } + string_type curr_symbol() const { return do_curr_symbol(); } + string_type positive_sign() const { return do_positive_sign(); } + string_type negative_sign() const { return do_negative_sign(); } + int frac_digits() const { return do_frac_digits(); } + pattern pos_format() const { return do_pos_format(); } + pattern neg_format() const { return do_neg_format(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + _STLP_STATIC_CONSTANT(bool, intl = false); + +protected: + pattern _M_pos_format; + pattern _M_neg_format; + + ~moneypunct _STLP_PSPEC2(char, false) (); + + virtual char do_decimal_point() const; + virtual char do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string do_curr_symbol() const; + + virtual string do_positive_sign() const; + virtual string do_negative_sign() const; + virtual int do_frac_digits() const; + virtual pattern do_pos_format() const; + virtual pattern do_neg_format() const; +}; + + +#ifndef _STLP_NO_WCHAR_T + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct : public locale::facet, public money_base { +public: + typedef wchar_t char_type; + typedef wstring string_type; + explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0); + wchar_t decimal_point() const { return do_decimal_point(); } + wchar_t thousands_sep() const { return do_thousands_sep(); } + string grouping() const { return do_grouping(); } + string_type curr_symbol() const { return do_curr_symbol(); } + string_type positive_sign() const { return do_positive_sign(); } + string_type negative_sign() const { return do_negative_sign(); } + int frac_digits() const { return do_frac_digits(); } + pattern pos_format() const { return do_pos_format(); } + pattern neg_format() const { return do_neg_format(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + _STLP_STATIC_CONSTANT(bool, intl = true); + +protected: + pattern _M_pos_format; + pattern _M_neg_format; + + ~moneypunct _STLP_PSPEC2(wchar_t, true) (); + + virtual wchar_t do_decimal_point() const; + virtual wchar_t do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string_type do_curr_symbol() const; + + virtual string_type do_positive_sign() const; + virtual string_type do_negative_sign() const; + virtual int do_frac_digits() const; + virtual pattern do_pos_format() const; + virtual pattern do_neg_format() const; +}; + + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct : public locale::facet, public money_base { +public: + typedef wchar_t char_type; + typedef wstring string_type; + explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0); + wchar_t decimal_point() const { return do_decimal_point(); } + wchar_t thousands_sep() const { return do_thousands_sep(); } + string grouping() const { return do_grouping(); } + string_type curr_symbol() const { return do_curr_symbol(); } + string_type positive_sign() const { return do_positive_sign(); } + string_type negative_sign() const { return do_negative_sign(); } + int frac_digits() const { return do_frac_digits(); } + pattern pos_format() const { return do_pos_format(); } + pattern neg_format() const { return do_neg_format(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + _STLP_STATIC_CONSTANT(bool, intl = false); + +protected: + pattern _M_pos_format; + pattern _M_neg_format; + + ~moneypunct _STLP_PSPEC2(wchar_t, false) (); + + virtual wchar_t do_decimal_point() const; + virtual wchar_t do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string_type do_curr_symbol() const; + + virtual string_type do_positive_sign() const; + virtual string_type do_negative_sign() const; + virtual int do_frac_digits() const; + virtual pattern do_pos_format() const; + virtual pattern do_neg_format() const; +}; + +# endif + +template class moneypunct_byname {}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct_byname : public moneypunct { + friend class _Locale_impl; +public: + typedef money_base::pattern pattern; + typedef char char_type; + typedef string string_type; + + explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0); + +protected: + ~moneypunct_byname _STLP_PSPEC2(char, true) (); + virtual char do_decimal_point() const; + virtual char do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string_type do_curr_symbol() const; + + virtual string_type do_positive_sign() const; + virtual string_type do_negative_sign() const; + virtual int do_frac_digits() const; + +private: + moneypunct_byname _STLP_PSPEC2(char, true) (_Locale_monetary *__monetary); + + typedef moneypunct_byname _Self; + //explicitely defined as private to avoid warnings: + moneypunct_byname(_Self const&); + _Self& operator = (_Self const&); + + _Locale_monetary* _M_monetary; +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct_byname : public moneypunct { + friend class _Locale_impl; +public: + typedef money_base::pattern pattern; + typedef char char_type; + typedef string string_type; + + explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0); + +protected: + ~moneypunct_byname _STLP_PSPEC2(char, false) (); + virtual char do_decimal_point() const; + virtual char do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string_type do_curr_symbol() const; + + virtual string_type do_positive_sign() const; + virtual string_type do_negative_sign() const; + virtual int do_frac_digits() const; + +private: + moneypunct_byname _STLP_PSPEC2(char, false) (_Locale_monetary *__monetary); + + typedef moneypunct_byname _Self; + //explicitely defined as private to avoid warnings: + moneypunct_byname(_Self const&); + _Self& operator = (_Self const&); + + _Locale_monetary* _M_monetary; +}; + +#if !defined (_STLP_NO_WCHAR_T) +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct_byname : public moneypunct { + friend class _Locale_impl; +public: + typedef money_base::pattern pattern; + typedef wchar_t char_type; + typedef wstring string_type; + + explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0); + +protected: + ~moneypunct_byname _STLP_PSPEC2(wchar_t, true) (); + virtual wchar_t do_decimal_point() const; + virtual wchar_t do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string_type do_curr_symbol() const; + + virtual string_type do_positive_sign() const; + virtual string_type do_negative_sign() const; + virtual int do_frac_digits() const; + +private: + moneypunct_byname _STLP_PSPEC2(wchar_t, true) (_Locale_monetary *__monetary); + + typedef moneypunct_byname _Self; + //explicitely defined as private to avoid warnings: + moneypunct_byname(_Self const&); + _Self& operator = (_Self const&); + + _Locale_monetary* _M_monetary; +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC moneypunct_byname : public moneypunct { + friend class _Locale_impl; +public: + typedef money_base::pattern pattern; + typedef wchar_t char_type; + typedef wstring string_type; + + explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0); + +protected: + ~moneypunct_byname _STLP_PSPEC2(wchar_t, false) (); + virtual wchar_t do_decimal_point() const; + virtual wchar_t do_thousands_sep() const; + virtual string do_grouping() const; + + virtual string_type do_curr_symbol() const; + + virtual string_type do_positive_sign() const; + virtual string_type do_negative_sign() const; + virtual int do_frac_digits() const; + +private: + moneypunct_byname _STLP_PSPEC2(wchar_t, false) (_Locale_monetary *__monetary); + + typedef moneypunct_byname _Self; + //explicitely defined as private to avoid warnings: + moneypunct_byname(_Self const&); + _Self& operator = (_Self const&); + + _Locale_monetary* _M_monetary; +}; +#endif + +//===== methods ====== + + +// money_put facets + +template +class money_put : public locale::facet { +public: + typedef _CharT char_type; + typedef _OutputIter iter_type; + typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type; + + explicit money_put(size_t __refs = 0) : locale::facet(__refs) {} + iter_type put(iter_type __s, bool __intl, ios_base& __str, + char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const + { return do_put(__s, __intl, __str, __fill, __units); } + iter_type put(iter_type __s, bool __intl, ios_base& __str, + char_type __fill, + const string_type& __digits) const + { return do_put(__s, __intl, __str, __fill, __digits); } + + static locale::id id; + +protected: + ~money_put() {} + virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str, + char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const; + virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str, + char_type __fill, + const string_type& __digits) const; +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS money_get > >; +_STLP_EXPORT_TEMPLATE_CLASS money_put > >; +# if ! defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS money_get > >; +_STLP_EXPORT_TEMPLATE_CLASS money_put > >; +# endif +#endif + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_MONETARY_H */ + +// Local Variables: +// mode:C++ +// End: + + diff --git a/sdk/tlibstdcxx/stlport/stl/_move_construct_fwk.h b/sdk/tlibstdcxx/stlport/stl/_move_construct_fwk.h new file mode 100644 index 0000000000..4a85fe32de --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_move_construct_fwk.h @@ -0,0 +1,159 @@ +/* + * + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_MOVE_CONSTRUCT_FWK_H +#define _STLP_MOVE_CONSTRUCT_FWK_H + +#ifndef _STLP_TYPE_TRAITS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +/************************************************************* + * Move constructor framework + *************************************************************/ + +/************************************************************* + *Partial move: + *The source HAS to be a valid instance after the move! + *************************************************************/ +template +class __move_source { +public: + explicit __move_source (_Tp &_src) : _M_data(_src) + {} + + _Tp& get() const + { return _M_data; } +private: + _Tp &_M_data; + + //We explicitely forbid assignment to avoid warning: + typedef __move_source<_Tp> _Self; + _Self& operator = (_Self const&); +}; + +//Class used to signal move constructor support, implementation and type. +template +struct __move_traits { + /* + * implemented tells if a the special move constructor has to be called or the classic + * copy constructor is just fine. Most of the time the copy constructor is fine only + * if the following info is true. + */ +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && \ + !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && \ + !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename _IsSTLportClass<_Tp>::_Ret implemented; +#else + typedef __false_type implemented; +#endif + /* + * complete tells if the move is complete or partial, that is to say, does the source + * needs to be destroyed once it has been moved. + */ +# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564) + typedef __type_traits<_Tp>::has_trivial_destructor _TpMoveComplete; + typedef typename __bool2type<__type2bool<_TpMoveComplete>::_Ret>::_Ret complete; +# else + typedef typename __type_traits<_Tp>::has_trivial_destructor complete; +# endif +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* + * This struct should never be used if the user has not explicitely stipulated + * that its class support the full move concept. To check that the return type + * in such a case will be __invalid_source<_Tp> to generate a compile error + * revealing the configuration problem. + */ +template +struct _MoveSourceTraits { + typedef typename __move_traits<_Tp>::implemented _MvImpRet; +#if defined (__BORLANDC__) + typedef typename __selectT<_MvImpRet, +#else + enum {_MvImp = __type2bool<_MvImpRet>::_Ret}; + typedef typename __select<_MvImp, +#endif + __move_source<_Tp>, + _Tp const&>::_Ret _Type; +}; + +//The helper function +template +inline _STLP_TYPENAME_ON_RETURN_TYPE _MoveSourceTraits<_Tp>::_Type +_AsMoveSource (_Tp &src) { + typedef typename _MoveSourceTraits<_Tp>::_Type _SrcType; + return _SrcType(src); +} + +//Helper structs used for many class. +template +struct __move_traits_aux { + typedef typename __move_traits<_Tp>::implemented implemented; + typedef typename __move_traits<_Tp>::complete complete; +}; + +template +struct __move_traits_aux2 { + typedef __move_traits<_Tp1> _MoveTraits1; + typedef __move_traits<_Tp2> _MoveTraits2; + + typedef typename _Lor2::_Ret implemented; + typedef typename _Land2::_Ret complete; +}; + +/* + * Most of the time a class implement a move constructor but its use depends + * on a third party, this is what the following struct are for. + */ +template +struct __move_traits_help { + typedef __true_type implemented; + typedef typename __move_traits<_Tp>::complete complete; +}; + +template +struct __move_traits_help1 { + typedef __move_traits<_Tp1> _MoveTraits1; + typedef __move_traits<_Tp2> _MoveTraits2; + + typedef typename _Lor2::_Ret implemented; + typedef typename _Land2::_Ret complete; +}; + +template +struct __move_traits_help2 { + typedef __move_traits<_Tp1> _MoveTraits1; + typedef __move_traits<_Tp2> _MoveTraits2; + + typedef __true_type implemented; + typedef typename _Land2::_Ret complete; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_MOVE_CONSTRUCT_FWK_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/_new.h b/sdk/tlibstdcxx/stlport/stl/_new.h new file mode 100644 index 0000000000..25086375a3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_new.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_NEW +#define _STLP_INTERNAL_NEW + +#ifndef _STLP_INTERNAL_CSTDDEF +// size_t +# include +#endif + +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x570) +// new.h uses ::malloc ;( +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib) +using _STLP_VENDOR_CSTD::malloc; +#endif + +#if !defined (_STLP_NO_NEW_NEW_HEADER) +// eMbedded Visual C++ .NET unfortunately uses _INC_NEW for both and +// we undefine the symbol to get the stuff in the SDK's +# if defined (_STLP_WCE_NET) && defined (_INC_NEW) +# undef _INC_NEW +# endif + +# if defined (new) +/* STLport cannot replace native Std library new header if new is a macro, + * please define new macro after header inclusion. + */ +# error Cannot include native new header as new is a macro. +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(new) +# endif +#else +# include +#endif + +#if defined (_STLP_NO_BAD_ALLOC) && !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) +# define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 +#endif + +#if defined (_STLP_USE_EXCEPTIONS) && defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) + +# ifndef _STLP_INTERNAL_EXCEPTION +# include +# endif + +_STLP_BEGIN_NAMESPACE + +# if defined (_STLP_NO_BAD_ALLOC) +struct nothrow_t {}; +# define nothrow nothrow_t() +# endif + +/* + * STLport own bad_alloc exception to be used if the native C++ library + * do not define it or when the new operator do not throw it to avoid + * a useless library dependency. + */ +class bad_alloc : public exception { +public: + bad_alloc () _STLP_NOTHROW_INHERENTLY { } + bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { } + bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;} + ~bad_alloc () _STLP_NOTHROW_INHERENTLY { } + const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; } +}; + +_STLP_END_NAMESPACE + +#endif /* _STLP_USE_EXCEPTIONS && (_STLP_NO_BAD_ALLOC || _STLP_NEW_DONT_THROW_BAD_ALLOC) */ + +#if defined (_STLP_USE_OWN_NAMESPACE) + +_STLP_BEGIN_NAMESPACE + +# if !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) +using _STLP_VENDOR_EXCEPT_STD::bad_alloc; +# endif + +# if !defined (_STLP_NO_BAD_ALLOC) +using _STLP_VENDOR_EXCEPT_STD::nothrow_t; +using _STLP_VENDOR_EXCEPT_STD::nothrow; +# if defined (_STLP_GLOBAL_NEW_HANDLER) +using ::new_handler; +using ::set_new_handler; +# else +using _STLP_VENDOR_EXCEPT_STD::new_handler; +using _STLP_VENDOR_EXCEPT_STD::set_new_handler; +# endif +# endif /* !_STLP_NO_BAD_ALLOC */ + +_STLP_END_NAMESPACE +#endif /* _STLP_USE_OWN_NAMESPACE */ + +#ifndef _STLP_THROW_BAD_ALLOC +# if !defined (_STLP_USE_EXCEPTIONS) +# ifndef _STLP_INTERNAL_CSTDIO +# include +# endif +# define _STLP_THROW_BAD_ALLOC _STLP_ABORT(); //puts("out of memory\n"); exit(1) +# else +# define _STLP_THROW_BAD_ALLOC _STLP_THROW(_STLP_STD::bad_alloc()) +# endif +#endif + +#if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) +# define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x; if (__y == 0) { _STLP_THROW_BAD_ALLOC; } return __y +#else +# define _STLP_CHECK_NULL_ALLOC(__x) return __x +#endif + +_STLP_BEGIN_NAMESPACE + +#if ((defined (__IBMCPP__) || defined (__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined (_STLP_DEBUG_ALLOC)) +inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator new(__n, __FILE__, __LINE__)); } +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); } +#else +inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator new(__n)); } +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); } +#endif +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_NEW */ + +/* + * Local Variables: + * mode:C++ + * End: + */ diff --git a/sdk/tlibstdcxx/stlport/stl/_num_get.c b/sdk/tlibstdcxx/stlport/stl/_num_get.c new file mode 100644 index 0000000000..1e7d23487e --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_num_get.c @@ -0,0 +1,623 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_NUM_GET_C +#define _STLP_NUM_GET_C + +#ifndef _STLP_INTERNAL_NUM_GET_H +# include +#endif + +#ifndef _STLP_INTERNAL_LIMITS +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned); +_STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms(); + +// __do_get_integer, __do_get_float and its helper functions. + +inline bool _STLP_CALL __get_fdigit(char __c, const char*) +{ return __c >= '0' && __c <= '9'; } + +inline bool _STLP_CALL __get_fdigit_or_sep(char& __c, char __sep, const char *__digits) { + if (__c == __sep) { + __c = ',' ; + return true ; + } + else + return __get_fdigit(__c, __digits); +} + +inline int _STLP_CALL +__get_digit_from_table(unsigned __index) +{ return (__index > 127 ? 0xFF : __digit_val_table(__index)); } + +template +int +__get_base_or_zero(_InputIter& __in_ite, _InputIter& __end, + ios_base::fmtflags __flags, const ctype<_CharT>& __c_type) { + _CharT __atoms[5]; + __c_type.widen(__narrow_atoms(), __narrow_atoms() + 5, __atoms); + + bool __negative = false; + _CharT __c = *__in_ite; + + if (__c == __atoms[1] /* __xminus_char */ ) { + __negative = true; + ++__in_ite; + } + else if (__c == __atoms[0] /* __xplus_char */ ) + ++__in_ite; + + int __base; + int __valid_zero = 0; + + ios_base::fmtflags __basefield = __flags & ios_base::basefield; + + switch (__basefield) { + case ios_base::oct: + __base = 8; + break; + case ios_base::dec: + __base = 10; + break; + case ios_base::hex: + __base = 16; + if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) { + ++__in_ite; + if (__in_ite != __end && + (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ )) + ++__in_ite; + else + __valid_zero = 1; // That zero is valid by itself. + } + break; + default: + if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) { + ++__in_ite; + if (__in_ite != __end && + (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ )) { + ++__in_ite; + __base = 16; + } + else + { + __base = 8; + __valid_zero = 1; // That zero is still valid by itself. + } + } + else + __base = 10; + break; + } + return (__base << 2) | ((int)__negative << 1) | __valid_zero; +} + + +template +bool _STLP_CALL +__get_integer(_InputIter& __first, _InputIter& __last, + int __base, _Integer& __val, + int __got, bool __is_negative, _CharT __separator, const string& __grouping, const __true_type& /*_IsSigned*/) { + bool __ovflow = false; + _Integer __result = 0; + bool __is_group = !__grouping.empty(); + char __group_sizes[64]; + char __current_group_size = 0; + char* __group_sizes_end = __group_sizes; + + _Integer __over_base = (numeric_limits<_Integer>::min)() / __STATIC_CAST(_Integer, __base); + + for ( ; __first != __last ; ++__first) { + + const _CharT __c = *__first; + + if (__is_group && __c == __separator) { + *__group_sizes_end++ = __current_group_size; + __current_group_size = 0; + continue; + } + + int __n = __get_digit_from_table(__c); + + if (__n >= __base) + break; + + ++__got; + ++__current_group_size; + + if (__result < __over_base) + __ovflow = true; // don't need to keep accumulating + else { + _Integer __next = __STATIC_CAST(_Integer, __base * __result - __n); + if (__result != 0) + __ovflow = __ovflow || __next >= __result; + __result = __next; + } + } + + if (__is_group && __group_sizes_end != __group_sizes) { + *__group_sizes_end++ = __current_group_size; + } + + // fbp : added to not modify value if nothing was read + if (__got > 0) { + __val = __ovflow ? __is_negative ? (numeric_limits<_Integer>::min)() + : (numeric_limits<_Integer>::max)() + : __is_negative ? __result + : __STATIC_CAST(_Integer, -__result); + } + // overflow is being treated as failure + return ((__got > 0) && !__ovflow) && + (__is_group == 0 || + __valid_grouping(__group_sizes, __group_sizes_end, + __grouping.data(), __grouping.data()+ __grouping.size())); +} + +template +bool _STLP_CALL +__get_integer(_InputIter& __first, _InputIter& __last, + int __base, _Integer& __val, + int __got, bool __is_negative, _CharT __separator, const string& __grouping, const __false_type& /*_IsSigned*/) { + bool __ovflow = false; + _Integer __result = 0; + bool __is_group = !__grouping.empty(); + char __group_sizes[64]; + char __current_group_size = 0; + char* __group_sizes_end = __group_sizes; + + _Integer __over_base = (numeric_limits<_Integer>::max)() / __STATIC_CAST(_Integer, __base); + + for ( ; __first != __last ; ++__first) { + + const _CharT __c = *__first; + + if (__is_group && __c == __separator) { + *__group_sizes_end++ = __current_group_size; + __current_group_size = 0; + continue; + } + + int __n = __get_digit_from_table(__c); + + if (__n >= __base) + break; + + ++__got; + ++__current_group_size; + + if (__result > __over_base) + __ovflow = true; //don't need to keep accumulating + else { + _Integer __next = __STATIC_CAST(_Integer, __base * __result + __n); + if (__result != 0) + __ovflow = __ovflow || __next <= __result; + __result = __next; + } + } + + if (__is_group && __group_sizes_end != __group_sizes) { + *__group_sizes_end++ = __current_group_size; + } + + // fbp : added to not modify value if nothing was read + if (__got > 0) { + __val = __ovflow ? (numeric_limits<_Integer>::max)() + : (__is_negative ? __STATIC_CAST(_Integer, -__result) + : __result); + } + + // overflow is being treated as failure + return ((__got > 0) && !__ovflow) && + (__is_group == 0 || + __valid_grouping(__group_sizes, __group_sizes_end, + __grouping.data(), __grouping.data()+ __grouping.size())); +} + + +template +bool _STLP_CALL +__get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val, _CharT* /*dummy*/) { + string __grp; + //Here there is no grouping so separator is not important, we just pass the default character. + return __get_integer(__first, __last, 10, __val, 0, false, _CharT() /*separator*/, __grp, __false_type()); +} + +template +_InputIter _STLP_CALL +__do_get_integer(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, + ios_base::iostate& __err, _Integer& __val, _CharT* /*__pc*/) { + locale __loc = __str.getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + +#if defined (__HP_aCC) && (__HP_aCC == 1) + bool _IsSigned = !((_Integer)(-1) > 0); +#else + typedef typename __bool2type::is_signed>::_Ret _IsSigned; +#endif + + const int __base_or_zero = __get_base_or_zero(__in_ite, __end, __str.flags(), __ctype); + int __got = __base_or_zero & 1; + + bool __result; + + if (__in_ite == __end) { // We may have already read a 0. If so, + + if (__got > 0) { // the result is 0 even if we're at eof. + __val = 0; + __result = true; + } + else + __result = false; + } + else { + const numpunct<_CharT>& __np = use_facet >(__loc); + const bool __negative = (__base_or_zero & 2) != 0; + const int __base = __base_or_zero >> 2; + +#if defined (__HP_aCC) && (__HP_aCC == 1) + if (_IsSigned) + __result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __true_type() ); + else + __result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __false_type() ); +#else + __result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), _IsSigned()); +# endif + } + + __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit); + + if (__in_ite == __end) + __err |= ios_base::eofbit; + return __in_ite; +} + +// __read_float and its helper functions. +template +_InputIter _STLP_CALL +__copy_sign(_InputIter __first, _InputIter __last, __iostring& __v, + _CharT __xplus, _CharT __xminus) { + if (__first != __last) { + _CharT __c = *__first; + if (__c == __xplus) + ++__first; + else if (__c == __xminus) { + __v.push_back('-'); + ++__first; + } + } + return __first; +} + + +template +bool _STLP_CALL +__copy_digits(_InputIter& __first, _InputIter __last, + __iostring& __v, const _CharT* __digits) { + bool __ok = false; + + for ( ; __first != __last; ++__first) { + _CharT __c = *__first; + if (__get_fdigit(__c, __digits)) { + __v.push_back((char)__c); + __ok = true; + } + else + break; + } + return __ok; +} + +template +bool _STLP_CALL +__copy_grouped_digits(_InputIter& __first, _InputIter __last, + __iostring& __v, const _CharT * __digits, + _CharT __sep, const string& __grouping, + bool& __grouping_ok) { + bool __ok = false; + char __group_sizes[64]; + char*__group_sizes_end = __group_sizes; + char __current_group_size = 0; + + for ( ; __first != __last; ++__first) { + _CharT __c = *__first; + bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits); + if (__tmp) { + if (__c == ',') { + *__group_sizes_end++ = __current_group_size; + __current_group_size = 0; + } + else { + __ok = true; + __v.push_back((char)__c); + ++__current_group_size; + } + } + else + break; + } + + if (__group_sizes_end != __group_sizes) + *__group_sizes_end++ = __current_group_size; + __grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size()); + return __ok; +} + + +template +bool _STLP_CALL +__read_float(__iostring& __buf, _InputIter& __in_ite, _InputIter& __end, + const ctype<_CharT> &__ct, const numpunct<_CharT> &__numpunct) { + // Create a string, copying characters of the form + // [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)? + + string __grouping = __numpunct.grouping(); + bool __digits_before_dot /* = false */; + bool __digits_after_dot = false; + bool __ok; + + bool __grouping_ok = true; + + _CharT __dot = __numpunct.decimal_point(); + _CharT __sep = __numpunct.thousands_sep(); + + _CharT __digits[10]; + _CharT __xplus; + _CharT __xminus; + + _CharT __pow_e; + _CharT __pow_E; + + _Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits); + + // Get an optional sign + __in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus); + + // Get an optional string of digits. + if (!__grouping.empty()) + __digits_before_dot = __copy_grouped_digits(__in_ite, __end, __buf, __digits, + __sep, __grouping, __grouping_ok); + else + __digits_before_dot = __copy_digits(__in_ite, __end, __buf, __digits); + + // Get an optional decimal point, and an optional string of digits. + if (__in_ite != __end && *__in_ite == __dot) { + __buf.push_back('.'); + ++__in_ite; + __digits_after_dot = __copy_digits(__in_ite, __end, __buf, __digits); + } + + // There have to be some digits, somewhere. + __ok = __digits_before_dot || __digits_after_dot; + + // Get an optional exponent. + if (__ok && __in_ite != __end && (*__in_ite == __pow_e || *__in_ite == __pow_E)) { + __buf.push_back('e'); + ++__in_ite; + __in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus); + __ok = __copy_digits(__in_ite, __end, __buf, __digits); + // If we have an exponent then the sign + // is optional but the digits aren't. + } + + return __ok; +} + +template +_InputIter _STLP_CALL +__do_get_float(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, + ios_base::iostate& __err, _Float& __val, _CharT* /*__pc*/) { + locale __loc = __str.getloc(); + const ctype<_CharT> &__ctype = use_facet >(__loc); + const numpunct<_CharT> &__numpunct = use_facet >(__loc); + + __iostring __buf ; + bool __ok = __read_float(__buf, __in_ite, __end, __ctype, __numpunct); + if (__ok) { + __string_to_float(__buf, __val); + __err = ios_base::goodbit; + } + else { + __err = ios_base::failbit; + } + if (__in_ite == __end) + __err |= ios_base::eofbit; + return __in_ite; +} + +template +_InputIter _STLP_CALL +__do_get_alphabool(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, + ios_base::iostate& __err, bool& __x, _CharT* /*__pc*/) { + const numpunct<_CharT>& __np = use_facet >(__str.getloc()); + const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __truename = __np.truename(); + const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __falsename = __np.falsename(); + bool __true_ok = true; + bool __false_ok = true; + + size_t __n = 0; + for ( ; __in_ite != __end; ++__in_ite) { + _CharT __c = *__in_ite; + __true_ok = __true_ok && (__c == __truename[__n]); + __false_ok = __false_ok && (__c == __falsename[__n]); + ++__n; + + if ((!__true_ok && !__false_ok) || + (__true_ok && __n >= __truename.size()) || + (__false_ok && __n >= __falsename.size())) { + ++__in_ite; + break; + } + } + if (__true_ok && __n < __truename.size()) __true_ok = false; + if (__false_ok && __n < __falsename.size()) __false_ok = false; + + if (__true_ok || __false_ok) { + __err = ios_base::goodbit; + __x = __true_ok; + } + else + __err = ios_base::failbit; + + if (__in_ite == __end) + __err |= ios_base::eofbit; + + return __in_ite; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +// +// num_get<>, num_put<> +// + +template +locale::id num_get<_CharT, _InputIterator>::id; + +#if !defined (_STLP_NO_BOOL) +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, + ios_base& __s, ios_base::iostate& __err, bool& __x) const { + if (__s.flags() & ios_base::boolalpha) { + return _STLP_PRIV __do_get_alphabool(__in_ite, __end, __s, __err, __x, (_CharT*)0); + } + else { + long __lx; + _InputIter __tmp = _STLP_PRIV __do_get_integer(__in_ite, __end, __s, __err, __lx, (_CharT*)0 ); + if (!(__err & ios_base::failbit)) { + if (__lx == 0) + __x = false; + else if (__lx == 1) + __x = true; + else + __err |= ios_base::failbit; + } + return __tmp; + } +} +#endif + +#if defined (_STLP_FIX_LIBRARY_ISSUES) +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, short& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, int& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +#endif + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, long& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + unsigned short& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + unsigned int& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + unsigned long& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + float& __val) const +{ return _STLP_PRIV __do_get_float(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + double& __val) const +{ return _STLP_PRIV __do_get_float(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + long double& __val) const +{ return _STLP_PRIV __do_get_float(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } +#endif + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + void*& __p) const { +#if defined (_STLP_LONG_LONG) && !defined (__MRC__) //*ty 12/07/2001 - MrCpp can not cast from long long to void* + unsigned _STLP_LONG_LONG __val; +#else + unsigned long __val; +#endif + iter_type __tmp = _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); + if (!(__err & ios_base::failbit)) + __p = __REINTERPRET_CAST(void*, __val); + return __tmp; +} + +#if defined (_STLP_LONG_LONG) +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + _STLP_LONG_LONG& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } + +template +_InputIter +num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, + unsigned _STLP_LONG_LONG& __val) const +{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); } +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_NUMERIC_FACETS_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_num_get.h b/sdk/tlibstdcxx/stlport/stl/_num_get.h new file mode 100644 index 0000000000..95f7935f93 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_num_get.h @@ -0,0 +1,237 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_NUM_GET_H +#define _STLP_INTERNAL_NUM_GET_H + +#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H +# include +#endif + +#ifndef _STLP_C_LOCALE_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUMPUNCT_H +# include +#endif + +#ifndef _STLP_INTERNAL_CTYPE_H +# include +#endif + +#ifndef _STLP_INTERNAL_IOSTREAM_STRING_H +# include +#endif + +#ifndef _STLP_FACETS_FWD_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// num_get facets + +template +class num_get: public locale::facet { +public: + typedef _CharT char_type; + typedef _InputIter iter_type; + + explicit num_get(size_t __refs = 0): locale::facet(__refs) {} + +#if !defined (_STLP_NO_BOOL) + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, bool& __val) const + { return do_get(__ii, __end, __str, __err, __val); } +#endif + +#if defined (_STLP_FIX_LIBRARY_ISSUES) + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, short& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, int& __val) const + { return do_get(__ii, __end, __str, __err, __val); } +#endif + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, long& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned short& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned int& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned long& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + +#if defined (_STLP_LONG_LONG) + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, _STLP_LONG_LONG& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const + { return do_get(__ii, __end, __str, __err, __val); } +#endif /* _STLP_LONG_LONG */ + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, float& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, double& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + +#if !defined (_STLP_NO_LONG_DOUBLE) + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, long double& __val) const + { return do_get(__ii, __end, __str, __err, __val); } +# endif + + _InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, void*& __val) const + { return do_get(__ii, __end, __str, __err, __val); } + + static locale::id id; + +protected: + ~num_get() {} + + typedef string string_type; + typedef ctype<_CharT> _Ctype; + typedef numpunct<_CharT> _Numpunct; + +#if !defined (_STLP_NO_BOOL) + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, bool& __val) const; +#endif + + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, long& __val) const; + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned short& __val) const; + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned int& __val) const; + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned long& __val) const; + +#if defined (_STLP_FIX_LIBRARY_ISSUES) + // issue 118 : those are actually not supposed to be here + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, short& __val) const; + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, int& __val) const; +#endif + + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, float& __val) const; + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, double& __val) const; + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, void*& __p) const; + +#if !defined (_STLP_NO_LONG_DOUBLE) + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, long double& __val) const; +#endif + +#if defined (_STLP_LONG_LONG) + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, _STLP_LONG_LONG& __val) const; + virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str, + ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const; +#endif + +}; + + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS num_get > >; +// _STLP_EXPORT_TEMPLATE_CLASS num_get; +# if !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS num_get > >; +// _STLP_EXPORT_TEMPLATE_CLASS num_get; +# endif +#endif + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) + +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_DECLSPEC bool _STLP_CALL __valid_grouping(const char*, const char*, const char*, const char*); + +template +bool _STLP_CALL +__get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val, _CharT*); + +# if !defined (_STLP_NO_WCHAR_T) +bool _STLP_DECLSPEC _STLP_CALL __get_fdigit(wchar_t&, const wchar_t*); +bool _STLP_DECLSPEC _STLP_CALL __get_fdigit_or_sep(wchar_t&, wchar_t, const wchar_t*); +# endif + +inline void _STLP_CALL +_Initialize_get_float(const ctype&, + char& Plus, char& Minus, + char& pow_e, char& pow_E, + char*) { + Plus = '+'; + Minus = '-'; + pow_e = 'e'; + pow_E = 'E'; +} + +# if !defined (_STLP_NO_WCHAR_T) +void _STLP_DECLSPEC _STLP_CALL _Initialize_get_float(const ctype&, + wchar_t&, wchar_t&, wchar_t&, wchar_t&, wchar_t*); +# endif +void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, float&); +void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, double&); +# if !defined (_STLP_NO_LONG_DOUBLE) +void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, long double&); +# endif + +_STLP_MOVE_TO_STD_NAMESPACE + +#endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */ + + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_NUM_GET_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_num_put.c b/sdk/tlibstdcxx/stlport/stl/_num_put.c new file mode 100644 index 0000000000..0c07838212 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_num_put.c @@ -0,0 +1,522 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_NUM_PUT_C +#define _STLP_NUM_PUT_C + +#ifndef _STLP_INTERNAL_NUM_PUT_H +# include +#endif + +#ifndef _STLP_INTERNAL_LIMITS +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// __do_put_float and its helper functions. Strategy: write the output +// to a buffer of char, transform the buffer to _CharT, and then copy +// it to the output. + +//---------------------------------------------------------------------- +// num_put facet + +template +_OutputIter _STLP_CALL +__copy_float_and_fill(const _CharT* __first, const _CharT* __last, + _OutputIter __oi, + ios_base::fmtflags __flags, + streamsize __width, _CharT __fill, + _CharT __xplus, _CharT __xminus) { + if (__width <= __last - __first) + return _STLP_STD::copy(__first, __last, __oi); + else { + streamsize __pad = __width - (__last - __first); + ios_base::fmtflags __dir = __flags & ios_base::adjustfield; + + if (__dir == ios_base::left) { + __oi = _STLP_STD::copy(__first, __last, __oi); + return _STLP_PRIV __fill_n(__oi, __pad, __fill); + } + else if (__dir == ios_base::internal && __first != __last && + (*__first == __xplus || *__first == __xminus)) { + *__oi++ = *__first++; + __oi = _STLP_PRIV __fill_n(__oi, __pad, __fill); + return _STLP_STD::copy(__first, __last, __oi); + } + else { + __oi = _STLP_PRIV __fill_n(__oi, __pad, __fill); + return _STLP_STD::copy(__first, __last, __oi); + } + } +} + +#if !defined (_STLP_NO_WCHAR_T) +// Helper routine for wchar_t +template +_OutputIter _STLP_CALL +__put_float(__iostring &__str, _OutputIter __oi, + ios_base& __f, wchar_t __fill, + wchar_t __decimal_point, wchar_t __sep, + size_t __group_pos, const string& __grouping) { + const ctype& __ct = use_facet >(__f.getloc()); + + __iowstring __wbuf; + __convert_float_buffer(__str, __wbuf, __ct, __decimal_point); + + if (!__grouping.empty()) { + __insert_grouping(__wbuf, __group_pos, __grouping, + __sep, __ct.widen('+'), __ct.widen('-'), 0); + } + + return __copy_float_and_fill(__wbuf.data(), __wbuf.data() + __wbuf.size(), __oi, + __f.flags(), __f.width(0), __fill, __ct.widen('+'), __ct.widen('-')); +} +#endif /* WCHAR_T */ + +// Helper routine for char +template +_OutputIter _STLP_CALL +__put_float(__iostring &__str, _OutputIter __oi, + ios_base& __f, char __fill, + char __decimal_point, char __sep, + size_t __group_pos, const string& __grouping) { + if ((__group_pos < __str.size()) && (__str[__group_pos] == '.')) { + __str[__group_pos] = __decimal_point; + } + + if (!__grouping.empty()) { + __insert_grouping(__str, __group_pos, + __grouping, __sep, '+', '-', 0); + } + + return __copy_float_and_fill(__str.data(), __str.data() + __str.size(), __oi, + __f.flags(), __f.width(0), __fill, '+', '-'); +} + +template +_OutputIter _STLP_CALL +__do_put_float(_OutputIter __s, ios_base& __f, + _CharT __fill, _Float __x) { + __iostring __buf; + + size_t __group_pos = __write_float(__buf, __f.flags(), (int)__f.precision(), __x); + + const numpunct<_CharT>& __np = use_facet >(__f.getloc()); + return __put_float(__buf, __s, __f, __fill, + __np.decimal_point(), __np.thousands_sep(), + __group_pos, __np.grouping()); +} + +inline void __get_money_digits_aux (__iostring &__buf, ios_base &, _STLP_LONGEST_FLOAT_TYPE __x) +{ __get_floor_digits(__buf, __x); } + +#if !defined (_STLP_NO_WCHAR_T) +inline void __get_money_digits_aux (__iowstring &__wbuf, ios_base &__f, _STLP_LONGEST_FLOAT_TYPE __x) { + __iostring __buf; + __get_floor_digits(__buf, __x); + + const ctype& __ct = use_facet >(__f.getloc()); + __convert_float_buffer(__buf, __wbuf, __ct, wchar_t(0), false); +} +#endif + +template +void _STLP_CALL __get_money_digits(_STLP_BASIC_IOSTRING(_CharT) &__buf, ios_base& __f, _STLP_LONGEST_FLOAT_TYPE __x) +{ __get_money_digits_aux(__buf, __f, __x); } + +// _M_do_put_integer and its helper functions. + +template +_OutputIter _STLP_CALL +__copy_integer_and_fill(const _CharT* __buf, ptrdiff_t __len, + _OutputIter __oi, + ios_base::fmtflags __flg, streamsize __wid, _CharT __fill, + _CharT __xplus, _CharT __xminus) { + if (__len >= __wid) + return _STLP_STD::copy(__buf, __buf + __len, __oi); + else { + //casting numeric_limits::max to streamsize only works is ptrdiff_t is signed or streamsize representation + //is larger than ptrdiff_t one. + _STLP_STATIC_ASSERT((sizeof(streamsize) > sizeof(ptrdiff_t)) || + ((sizeof(streamsize) == sizeof(ptrdiff_t)) && numeric_limits::is_signed)) + ptrdiff_t __pad = __STATIC_CAST(ptrdiff_t, (min) (__STATIC_CAST(streamsize, (numeric_limits::max)()), + __STATIC_CAST(streamsize, __wid - __len))); + ios_base::fmtflags __dir = __flg & ios_base::adjustfield; + + if (__dir == ios_base::left) { + __oi = _STLP_STD::copy(__buf, __buf + __len, __oi); + return _STLP_PRIV __fill_n(__oi, __pad, __fill); + } + else if (__dir == ios_base::internal && __len != 0 && + (__buf[0] == __xplus || __buf[0] == __xminus)) { + *__oi++ = __buf[0]; + __oi = __fill_n(__oi, __pad, __fill); + return _STLP_STD::copy(__buf + 1, __buf + __len, __oi); + } + else if (__dir == ios_base::internal && __len >= 2 && + (__flg & ios_base::showbase) && + (__flg & ios_base::basefield) == ios_base::hex) { + *__oi++ = __buf[0]; + *__oi++ = __buf[1]; + __oi = __fill_n(__oi, __pad, __fill); + return _STLP_STD::copy(__buf + 2, __buf + __len, __oi); + } + else { + __oi = __fill_n(__oi, __pad, __fill); + return _STLP_STD::copy(__buf, __buf + __len, __oi); + } + } +} + +#if !defined (_STLP_NO_WCHAR_T) +// Helper function for wchar_t +template +_OutputIter _STLP_CALL +__put_integer(char* __buf, char* __iend, _OutputIter __s, + ios_base& __f, + ios_base::fmtflags __flags, wchar_t __fill) { + locale __loc = __f.getloc(); + const ctype& __ct = use_facet >(__loc); + + wchar_t __xplus = __ct.widen('+'); + wchar_t __xminus = __ct.widen('-'); + + wchar_t __wbuf[64]; + __ct.widen(__buf, __iend, __wbuf); + ptrdiff_t __len = __iend - __buf; + wchar_t* __eend = __wbuf + __len; + + const numpunct& __np = use_facet >(__loc); + const string& __grouping = __np.grouping(); + + if (!__grouping.empty()) { + int __basechars; + if (__flags & ios_base::showbase) + switch (__flags & ios_base::basefield) { + case ios_base::hex: __basechars = 2; break; + case ios_base::oct: __basechars = 1; break; + default: __basechars = 0; + } + else + __basechars = 0; + + __len = __insert_grouping(__wbuf, __eend, __grouping, __np.thousands_sep(), + __xplus, __xminus, __basechars); + } + + return __copy_integer_and_fill((wchar_t*)__wbuf, __len, __s, + __flags, __f.width(0), __fill, __xplus, __xminus); +} +#endif + +// Helper function for char +template +_OutputIter _STLP_CALL +__put_integer(char* __buf, char* __iend, _OutputIter __s, + ios_base& __f, ios_base::fmtflags __flags, char __fill) { + char __grpbuf[64]; + ptrdiff_t __len = __iend - __buf; + + const numpunct& __np = use_facet >(__f.getloc()); + const string& __grouping = __np.grouping(); + + if (!__grouping.empty()) { + int __basechars; + if (__flags & ios_base::showbase) + switch (__flags & ios_base::basefield) { + case ios_base::hex: __basechars = 2; break; + case ios_base::oct: __basechars = 1; break; + default: __basechars = 0; + } + else + __basechars = 0; + + // make sure there is room at the end of the buffer + // we pass to __insert_grouping + _STLP_STD::copy(__buf, __iend, (char *) __grpbuf); + __buf = __grpbuf; + __iend = __grpbuf + __len; + __len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(), + '+', '-', __basechars); + } + + return __copy_integer_and_fill(__buf, __len, __s, __flags, __f.width(0), __fill, '+', '-'); +} + +#if defined (_STLP_LONG_LONG) +typedef _STLP_LONG_LONG __max_int_t; +typedef unsigned _STLP_LONG_LONG __umax_int_t; +#else +typedef long __max_int_t; +typedef unsigned long __umax_int_t; +#endif + +_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_lo(); +_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_hi(); + +template +inline char* _STLP_CALL +__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type& /* is_signed */) { + const bool __negative = __x < 0 ; + __max_int_t __temp = __x; + __umax_int_t __utemp = __negative?-__temp:__temp; + + for (; __utemp != 0; __utemp /= 10) + *--__ptr = (char)((int)(__utemp % 10) + '0'); + // put sign if needed or requested + if (__negative) + *--__ptr = '-'; + else if (__flags & ios_base::showpos) + *--__ptr = '+'; + return __ptr; +} + +template +inline char* _STLP_CALL +__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __false_type& /* is_signed */) { + for (; __x != 0; __x /= 10) + *--__ptr = (char)((int)(__x % 10) + '0'); + // put sign if requested + if (__flags & ios_base::showpos) + *--__ptr = '+'; + return __ptr; +} + +template +char* _STLP_CALL +__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x) { + char* __ptr = __buf; + + if (__x == 0) { + *--__ptr = '0'; + if ((__flags & ios_base::showpos) && ((__flags & (ios_base::oct | ios_base::hex)) == 0)) + *--__ptr = '+'; + // oct or hex base shall not be added to the 0 value (see '#' flag in C formating strings) + } + else { + switch (__flags & ios_base::basefield) { + case ios_base::oct: + { + __umax_int_t __temp = __x; + // if the size of integer is less than 8, clear upper part + if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 ) + __temp &= 0xFFFFFFFF; + + for (; __temp != 0; __temp >>=3) + *--__ptr = (char)((((unsigned)__temp)& 0x7) + '0'); + + // put leading '0' if showbase is set + if (__flags & ios_base::showbase) + *--__ptr = '0'; + } + break; + case ios_base::hex: + { + const char* __table_ptr = (__flags & ios_base::uppercase) ? + __hex_char_table_hi() : __hex_char_table_lo(); + __umax_int_t __temp = __x; + // if the size of integer is less than 8, clear upper part + if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 ) + __temp &= 0xFFFFFFFF; + + for (; __temp != 0; __temp >>=4) + *--__ptr = __table_ptr[((unsigned)__temp & 0xF)]; + + if (__flags & ios_base::showbase) { + *--__ptr = __table_ptr[16]; + *--__ptr = '0'; + } + } + break; + //case ios_base::dec: + default: + { +#if defined(__HP_aCC) && (__HP_aCC == 1) + bool _IsSigned = !((_Integer)-1 > 0); + if (_IsSigned) + __ptr = __write_decimal_backward(__ptr, __x, __flags, __true_type() ); + else + __ptr = __write_decimal_backward(__ptr, __x, __flags, __false_type() ); +#else + typedef typename __bool2type::is_signed>::_Ret _IsSigned; + __ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned()); +#endif + } + break; + } + } + + // return pointer to beginning of the string + return __ptr; +} + +template +_OutputIter _STLP_CALL +__do_put_integer(_OutputIter __s, ios_base& __f, _CharT __fill, _Integer __x) { + // buffer size = number of bytes * number of digit necessary in the smallest Standard base (base 8, 3 digits/byte) + // plus the longest base representation '0x' + // Do not use __buf_size to define __buf static buffer, some compilers (HP aCC) do not accept const variable as + // the specification of a static buffer size. + char __buf[sizeof(_Integer) * 3 + 2]; + const ptrdiff_t __buf_size = sizeof(__buf) / sizeof(char); + ios_base::fmtflags __flags = __f.flags(); + char* __ibeg = __write_integer_backward((char*)__buf + __buf_size, __flags, __x); + return __put_integer(__ibeg, (char*)__buf + __buf_size, __s, __f, __flags, __fill); +} + +template +_OutputIter _STLP_CALL +__do_put_bool(_OutputIter __s, ios_base& __f, _CharT __fill, bool __x) { + const numpunct<_CharT>& __np = use_facet >(__f.getloc()); + + basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __str = __x ? __np.truename() : __np.falsename(); + + streamsize __wid = __f.width(0); + if (__str.size() >= __STATIC_CAST(size_t, __wid)) + return _STLP_STD::copy(__str.begin(), __str.end(), __s); + else { + streamsize __pad = __wid - __str.size(); + ios_base::fmtflags __dir = __f.flags() & ios_base::adjustfield; + + if (__dir == ios_base::left) { + __s = _STLP_STD::copy(__str.begin(), __str.end(), __s); + return __fill_n(__s, __pad, __fill); + } + else /* covers right and internal padding */ { + __s = __fill_n(__s, __pad, __fill); + return _STLP_STD::copy(__str.begin(), __str.end(), __s); + } + } +} +_STLP_MOVE_TO_STD_NAMESPACE + +// +// num_put<> +// + +template +locale::id num_put<_CharT, _OutputIterator>::id; + +#if !defined (_STLP_NO_BOOL) +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + bool __val) const { + if (!(__f.flags() & ios_base::boolalpha)) + // 22.2.2.2.2.23: shall return do_put for int and not directly __do_put_integer. + return do_put(__s, __f, __fill, __STATIC_CAST(long, __val)); + + return _STLP_PRIV __do_put_bool(__s, __f, __fill, __val); +} +#endif + +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + long __val) const +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); } + +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + unsigned long __val) const +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); } + +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + double __val) const +{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); } + +#if !defined (_STLP_NO_LONG_DOUBLE) +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + long double __val) const +{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); } +#endif + +#if defined (_STLP_LONG_LONG) +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + _STLP_LONG_LONG __val) const +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); } + +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + unsigned _STLP_LONG_LONG __val) const +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); } +#endif /* _STLP_LONG_LONG */ + + +// 22.2.2.2.2 Stage 1: "For conversion from void* the specifier is %p." +// This is not clear and I'm really don't follow this (below). +template +_OutputIter +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT /*__fill*/, + const void* __val) const { + const ctype<_CharT>& __c_type = use_facet >(__f.getloc()); + ios_base::fmtflags __save_flags = __f.flags(); + + __f.setf(ios_base::hex, ios_base::basefield); + __f.setf(ios_base::showbase); + __f.setf(ios_base::internal, ios_base::adjustfield); + __f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix + if ( __val == 0 ) { + // base ('0x') not shown for null, but I really want to type it + // for pointer. Print it first in this case. + const char* __table_ptr = (__save_flags & ios_base::uppercase) ? + _STLP_PRIV __hex_char_table_hi() : _STLP_PRIV __hex_char_table_lo(); + __s++ = __c_type.widen( '0' ); + __s++ = __c_type.widen( __table_ptr[16] ); + __f.width((sizeof(void*) * 2)); // digits in pointer type + } else { + __f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix + } +#if defined (_STLP_MSVC) +# pragma warning (push) +# pragma warning (disable : 4311) //pointer truncation from 'const void*' to 'unsigned long' +#endif + _OutputIter result = +#ifdef _STLP_LONG_LONG + ( sizeof(void*) == sizeof(unsigned long) ) ? +#endif + _STLP_PRIV __do_put_integer(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned long,__val)) +#ifdef _STLP_LONG_LONG + : /* ( sizeof(void*) == sizeof(unsigned _STLP_LONG_LONG) ) ? */ + _STLP_PRIV __do_put_integer(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned _STLP_LONG_LONG,__val)) +#endif + ; +#if defined (_STLP_MSVC) +# pragma warning (pop) +#endif + __f.flags(__save_flags); + return result; +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_NUM_PUT_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_num_put.h b/sdk/tlibstdcxx/stlport/stl/_num_put.h new file mode 100644 index 0000000000..29bfc01cb5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_num_put.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_NUM_PUT_H +#define _STLP_INTERNAL_NUM_PUT_H + +#ifndef _STLP_INTERNAL_NUMPUNCT_H +# include +#endif + +#ifndef _STLP_INTERNAL_CTYPE_H +# include +#endif + +#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_IOSTREAM_STRING_H +# include +#endif + +#ifndef _STLP_FACETS_FWD_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// num_put facet + +template +class num_put: public locale::facet { +public: + typedef _CharT char_type; + typedef _OutputIter iter_type; + + explicit num_put(size_t __refs = 0) : locale::facet(__refs) {} + +#if !defined (_STLP_NO_BOOL) + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + bool __val) const { + return do_put(__s, __f, __fill, __val); + } +#endif + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + long __val) const { + return do_put(__s, __f, __fill, __val); + } + + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + unsigned long __val) const { + return do_put(__s, __f, __fill, __val); + } + +#if defined (_STLP_LONG_LONG) + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + _STLP_LONG_LONG __val) const { + return do_put(__s, __f, __fill, __val); + } + + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + unsigned _STLP_LONG_LONG __val) const { + return do_put(__s, __f, __fill, __val); + } +#endif + + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + double __val) const { + return do_put(__s, __f, __fill, (double)__val); + } + +#if !defined (_STLP_NO_LONG_DOUBLE) + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + long double __val) const { + return do_put(__s, __f, __fill, __val); + } +#endif + + iter_type put(iter_type __s, ios_base& __f, char_type __fill, + const void * __val) const { + return do_put(__s, __f, __fill, __val); + } + + static locale::id id; + +protected: + ~num_put() {} +#if !defined (_STLP_NO_BOOL) + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, bool __val) const; +#endif + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long __val) const; + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, unsigned long __val) const; + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, double __val) const; +#if !defined (_STLP_NO_LONG_DOUBLE) + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long double __val) const; +#endif + +#if defined (_STLP_LONG_LONG) + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, _STLP_LONG_LONG __val) const; + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, + unsigned _STLP_LONG_LONG __val) const ; +#endif + virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, const void* __val) const; +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS num_put > >; +# if !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS num_put > >; +# endif +#endif + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +char* _STLP_CALL +__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x); + +/* + * Returns the position on the right of the digits that has to be considered + * for the application of the grouping policy. + */ +extern size_t _STLP_CALL __write_float(__iostring&, ios_base::fmtflags, int, double); +# if !defined (_STLP_NO_LONG_DOUBLE) +extern size_t _STLP_CALL __write_float(__iostring&, ios_base::fmtflags, int, long double); +# endif + +/* + * Gets the digits of the integer part. + */ +void _STLP_CALL __get_floor_digits(__iostring&, _STLP_LONGEST_FLOAT_TYPE); + +template +void _STLP_CALL __get_money_digits(_STLP_BASIC_IOSTRING(_CharT)&, ios_base&, _STLP_LONGEST_FLOAT_TYPE); + +# if !defined (_STLP_NO_WCHAR_T) +extern void _STLP_CALL __convert_float_buffer(__iostring const&, __iowstring&, const ctype&, wchar_t, bool = true); +# endif +extern void _STLP_CALL __adjust_float_buffer(__iostring&, char); + +extern char* _STLP_CALL +__write_integer(char* buf, ios_base::fmtflags flags, long x); + +extern ptrdiff_t _STLP_CALL __insert_grouping(char* first, char* last, const string&, char, char, char, int); +extern void _STLP_CALL __insert_grouping(__iostring&, size_t, const string&, char, char, char, int); +# if !defined (_STLP_NO_WCHAR_T) +extern ptrdiff_t _STLP_CALL __insert_grouping(wchar_t*, wchar_t*, const string&, wchar_t, wchar_t, wchar_t, int); +extern void _STLP_CALL __insert_grouping(__iowstring&, size_t, const string&, wchar_t, wchar_t, wchar_t, int); +# endif + +_STLP_MOVE_TO_STD_NAMESPACE + +#endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */ + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_NUMERIC_FACETS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_numeric.c b/sdk/tlibstdcxx/stlport/stl/_numeric.c new file mode 100644 index 0000000000..6bd07ff121 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_numeric.c @@ -0,0 +1,106 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_NUMERIC_C +#define _STLP_NUMERIC_C + +#ifndef _STLP_INTERNAL_NUMERIC_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIterator +__partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp*, _BinaryOperation __binary_op) { + _STLP_DEBUG_CHECK(__check_range(__first, __last)) + if (__first == __last) return __result; + *__result = *__first; + + _Tp __val = *__first; + while (++__first != __last) { + __val = __binary_op(__val, *__first); + *++__result = __val; + } + return ++__result; +} + +template +_OutputIterator +__adjacent_difference(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp*, + _BinaryOperation __binary_op) { + _STLP_DEBUG_CHECK(__check_range(__first, __last)) + if (__first == __last) return __result; + *__result = *__first; + _Tp __val = *__first; + while (++__first != __last) { + _Tp __tmp = *__first; + *++__result = __binary_op(__tmp, __val); + __val = __tmp; + } + return ++__result; +} + + +template +_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr) { + _STLP_MPWFIX_TRY + if (__n == 0) + return __identity_element(__opr); + else { + while ((__n & 1) == 0) { + __n >>= 1; + __x = __opr(__x, __x); + } + _Tp __result = __x; + _STLP_MPWFIX_TRY + __n >>= 1; + while (__n != 0) { + __x = __opr(__x, __x); + if ((__n & 1) != 0) + __result = __opr(__result, __x); + __n >>= 1; + } + return __result; + _STLP_MPWFIX_CATCH + } + _STLP_MPWFIX_CATCH_ACTION(__x = _Tp()) +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_NUMERIC_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_numeric.h b/sdk/tlibstdcxx/stlport/stl/_numeric.h new file mode 100644 index 0000000000..4844da165a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_numeric.h @@ -0,0 +1,191 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_NUMERIC_H +#define _STLP_INTERNAL_NUMERIC_H + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +_STLP_INLINE_LOOP +_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + _Init = _Init + *__first; + return _Init; +} + +template +_STLP_INLINE_LOOP +_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init, + _BinaryOperation __binary_op) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + _Init = __binary_op(_Init, *__first); + return _Init; +} + +template +_STLP_INLINE_LOOP +_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp _Init) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2) + _Init = _Init + (*__first1 * *__first2); + return _Init; +} + +template +_STLP_INLINE_LOOP +_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp _Init, + _BinaryOperation1 __binary_op1, + _BinaryOperation2 __binary_op2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2) + _Init = __binary_op1(_Init, __binary_op2(*__first1, *__first2)); + return _Init; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIterator +__partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp*, _BinaryOperation __binary_op); + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _OutputIterator +partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result) { + return _STLP_PRIV __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator), + _STLP_PRIV __plus(_STLP_VALUE_TYPE(__first, _InputIterator))); +} + +template +inline _OutputIterator +partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op) { + return _STLP_PRIV __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator), + __binary_op); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_OutputIterator +__adjacent_difference(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp*, + _BinaryOperation __binary_op); + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _OutputIterator +adjacent_difference(_InputIterator __first, + _InputIterator __last, _OutputIterator __result) { + return _STLP_PRIV __adjacent_difference(__first, __last, __result, + _STLP_VALUE_TYPE(__first, _InputIterator), + _STLP_PRIV __minus(_STLP_VALUE_TYPE(__first, _InputIterator))); +} + +template +_OutputIterator +adjacent_difference(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op) { + return _STLP_PRIV __adjacent_difference(__first, __last, __result, + _STLP_VALUE_TYPE(__first, _InputIterator), + __binary_op); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr); + +_STLP_MOVE_TO_STD_NAMESPACE + +#if !defined (_STLP_NO_EXTENSIONS) + +// Returns __x ** __n, where __n >= 0. _Note that "multiplication" +// is required to be associative, but not necessarily commutative. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _Tp __power(_Tp __x, _Integer __n) { + return __power(__x, __n, multiplies<_Tp>()); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +// Alias for the internal name __power. Note that power is an extension, +// not part of the C++ standard. +template +inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr) { + return _STLP_PRIV __power(__x, __n, __opr); +} + +template +inline _Tp power(_Tp __x, _Integer __n) { + return _STLP_PRIV __power(__x, __n, multiplies<_Tp>()); +} + +// iota is not part of the C++ standard. It is an extension. + +template +_STLP_INLINE_LOOP +void iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + while (__first != __last) + *__first++ = __val++; +} +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_NUMERIC_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_numpunct.h b/sdk/tlibstdcxx/stlport/stl/_numpunct.h new file mode 100644 index 0000000000..c0d0ff4d58 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_numpunct.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_NUMPUNCT_H +#define _STLP_INTERNAL_NUMPUNCT_H + +#ifndef _STLP_IOS_BASE_H +# include +#endif + +# ifndef _STLP_C_LOCALE_H +# include +# endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// numpunct facets + +template class numpunct {}; +template class numpunct_byname {}; +template class num_get; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC numpunct : public locale::facet { +public: + typedef char char_type; + typedef string string_type; + + explicit numpunct(size_t __refs = 0) + : locale::facet(__refs) {} + + char decimal_point() const { return do_decimal_point(); } + char thousands_sep() const { return do_thousands_sep(); } + string grouping() const { return do_grouping(); } + string truename() const { return do_truename(); } + string falsename() const { return do_falsename(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~numpunct(); + + virtual char do_decimal_point() const; + virtual char do_thousands_sep() const; + virtual string do_grouping() const; + virtual string do_truename() const; + virtual string do_falsename() const; +}; + +# if ! defined (_STLP_NO_WCHAR_T) + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC numpunct : public locale::facet { +public: + typedef wchar_t char_type; + typedef wstring string_type; + + explicit numpunct(size_t __refs = 0) + : locale::facet(__refs) {} + + wchar_t decimal_point() const { return do_decimal_point(); } + wchar_t thousands_sep() const { return do_thousands_sep(); } + string grouping() const { return do_grouping(); } + wstring truename() const { return do_truename(); } + wstring falsename() const { return do_falsename(); } + + static _STLP_STATIC_DECLSPEC locale::id id; + +protected: + ~numpunct(); + + virtual wchar_t do_decimal_point() const; + virtual wchar_t do_thousands_sep() const; + virtual string do_grouping() const; + virtual wstring do_truename() const; + virtual wstring do_falsename() const; +}; + +# endif /* WCHAR_T */ + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC numpunct_byname : public numpunct { + friend class _Locale_impl; +public: + typedef char char_type; + typedef string string_type; + + explicit numpunct_byname(const char* __name, size_t __refs = 0); + +protected: + + ~numpunct_byname(); + + virtual char do_decimal_point() const; + virtual char do_thousands_sep() const; + virtual string do_grouping() const; + virtual string do_truename() const; + virtual string do_falsename() const; + +private: + numpunct_byname(_Locale_numeric *__numeric) + : _M_numeric(__numeric) {} + + //explicitely defined as private to avoid warnings: + typedef numpunct_byname _Self; + numpunct_byname(_Self const&); + _Self& operator = (_Self const&); + + _Locale_numeric* _M_numeric; +}; + +# ifndef _STLP_NO_WCHAR_T +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC numpunct_byname: public numpunct { + friend class _Locale_impl; +public: + typedef wchar_t char_type; + typedef wstring string_type; + + explicit numpunct_byname(const char* __name, size_t __refs = 0); + +protected: + ~numpunct_byname(); + + virtual wchar_t do_decimal_point() const; + virtual wchar_t do_thousands_sep() const; + virtual string do_grouping() const; + virtual wstring do_truename() const; + virtual wstring do_falsename() const; + +private: + numpunct_byname(_Locale_numeric *__numeric) + : _M_numeric(__numeric) {} + + //explicitely defined as private to avoid warnings: + typedef numpunct_byname _Self; + numpunct_byname(_Self const&); + _Self& operator = (_Self const&); + + _Locale_numeric* _M_numeric; +}; + +# endif /* WCHAR_T */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_NUMPUNCT_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_ostream.c b/sdk/tlibstdcxx/stlport/stl/_ostream.c new file mode 100644 index 0000000000..faba6c272a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ostream.c @@ -0,0 +1,455 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_OSTREAM_C +#define _STLP_OSTREAM_C + +#ifndef _STLP_INTERNAL_OSTREAM_H +# include +#endif + +#if !defined (_STLP_INTERNAL_NUM_PUT_H) +# include // For basic_streambuf and iterators +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// Definitions of non-inline member functions. + +// Constructor, destructor + +template +basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf<_CharT, _Traits>* __buf) + : basic_ios<_CharT, _Traits>() { + this->init(__buf); +} + +template +basic_ostream<_CharT, _Traits>::~basic_ostream() +{} + +// Output directly from a streambuf. +template +basic_ostream<_CharT, _Traits>& +basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<_CharT, _Traits>* __from) { + sentry __sentry(*this); + if (__sentry) { + if (__from) { + bool __any_inserted = __from->gptr() != __from->egptr() + ? this->_M_copy_buffered(__from, this->rdbuf()) + : this->_M_copy_unbuffered(__from, this->rdbuf()); + if (!__any_inserted) + this->setstate(ios_base::failbit); + } + else + this->setstate(ios_base::badbit); + } + + return *this; +} + +// Helper functions for the streambuf version of operator<<. The +// exception-handling code is complicated because exceptions thrown +// while extracting characters are treated differently than exceptions +// thrown while inserting characters. + +template +bool basic_ostream<_CharT, _Traits> + ::_M_copy_buffered(basic_streambuf<_CharT, _Traits>* __from, + basic_streambuf<_CharT, _Traits>* __to) { + bool __any_inserted = false; + + while (__from->egptr() != __from->gptr()) { + const ptrdiff_t __avail = __from->egptr() - __from->gptr(); + + streamsize __nwritten; + _STLP_TRY { + __nwritten = __to->sputn(__from->gptr(), __avail); + __from->gbump((int)__nwritten); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + return __any_inserted; + } + + if (__nwritten == __avail) { + _STLP_TRY { + if (this->_S_eof(__from->sgetc())) + return true; + else + __any_inserted = true; + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::failbit); + return false; + } + } + else if (__nwritten != 0) + return true; + else + return __any_inserted; + } + + // No characters are in the buffer, but we aren't at EOF. Switch to + // unbuffered mode. + return __any_inserted || this->_M_copy_unbuffered(__from, __to); +} + +/* + * Helper struct (guard) to put back a character in a streambuf + * whenever an exception or an eof occur. + */ +template +struct _SPutBackC { + typedef basic_streambuf<_CharT, _Traits> _StreamBuf; + typedef typename _StreamBuf::int_type int_type; + _SPutBackC(_StreamBuf *pfrom) + : __pfrom(pfrom), __c(0), __do_guard(false) {} + ~_SPutBackC() { + if (__do_guard) { + __pfrom->sputbackc(_Traits::to_char_type(__c)); + } + } + + void guard(int_type c) { + __c = c; + __do_guard = true; + } + void release() { + __do_guard = false; + } + +private: + _StreamBuf *__pfrom; + int_type __c; + bool __do_guard; +}; + +template +bool basic_ostream<_CharT, _Traits> + ::_M_copy_unbuffered(basic_streambuf<_CharT, _Traits>* __from, + basic_streambuf<_CharT, _Traits>* __to) { + typedef _SPutBackC<_CharT, _Traits> _SPutBackCGuard; + bool __any_inserted = false; + int_type __c; + + _STLP_TRY { + _SPutBackCGuard __cguard(__from); + for (;;) { + _STLP_TRY { + __c = __from->sbumpc(); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::failbit); + break; + } + + if (this->_S_eof(__c)) + break; + + __cguard.guard(__c); +#if defined (__DMC__) + _STLP_TRY { +#endif + if (this->_S_eof(__to->sputc(_Traits::to_char_type(__c)))) + break; + +#if defined (__DMC__) + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + break; + } +#endif + __cguard.release(); + __any_inserted = true; + } + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + return __any_inserted; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Helper function for numeric output. +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +__put_num(basic_ostream<_CharT, _Traits>& __os, _Number __x) { + typedef typename basic_ostream<_CharT, _Traits>::sentry _Sentry; + _Sentry __sentry(__os); + bool __failed = true; + + if (__sentry) { + _STLP_TRY { + typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > _NumPut; + __failed = (use_facet<_NumPut>(__os.getloc())).put(ostreambuf_iterator<_CharT, _Traits>(__os.rdbuf()), + __os, __os.fill(), + __x).failed(); + } + _STLP_CATCH_ALL { + __os._M_handle_exception(ios_base::badbit); + } + } + if (__failed) + __os.setstate(ios_base::badbit); + return __os; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +/* + * In the following operators we try to limit code bloat by limiting the + * number of __put_num instanciations. + */ +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __x) { + _STLP_STATIC_ASSERT( sizeof(short) <= sizeof(long) ) + long __tmp = ((this->flags() & _Basic_ios::basefield) != ios_base::dec) ? + __STATIC_CAST(long, __STATIC_CAST(unsigned short, __x)): __x; + return _STLP_PRIV __put_num(*this, __tmp); +} + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __x) { + _STLP_STATIC_ASSERT( sizeof(unsigned short) <= sizeof(unsigned long) ) + return _STLP_PRIV __put_num(*this, __STATIC_CAST(unsigned long,__x)); +} + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __x) { + _STLP_STATIC_ASSERT( sizeof(int) <= sizeof(long) ) + long __tmp = ((this->flags() & _Basic_ios::basefield) != ios_base::dec) ? + __STATIC_CAST(long, __STATIC_CAST(unsigned int, __x)): __x; + return _STLP_PRIV __put_num(*this, __tmp); +} + +template +#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300) +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __x) { + _STLP_STATIC_ASSERT( sizeof(unsigned int) <= sizeof(unsigned long) ) +#else +/* We define this operator with size_t rather than unsigned int to avoid + * 64 bits warning. + */ +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(size_t __x) { + _STLP_STATIC_ASSERT( sizeof(size_t) <= sizeof(unsigned long) ) +#endif + return _STLP_PRIV __put_num(*this, __STATIC_CAST(unsigned long,__x)); +} + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __x) +{ return _STLP_PRIV __put_num(*this, __x); } + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __x) +{ return _STLP_PRIV __put_num(*this, __x); } + +#ifdef _STLP_LONG_LONG +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<< (_STLP_LONG_LONG __x) +{ return _STLP_PRIV __put_num(*this, __x); } + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<< (unsigned _STLP_LONG_LONG __x) +{ return _STLP_PRIV __put_num(*this, __x); } +#endif + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __x) +{ return _STLP_PRIV __put_num(*this, __STATIC_CAST(double,__x)); } + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __x) +{ return _STLP_PRIV __put_num(*this, __x); } + +#ifndef _STLP_NO_LONG_DOUBLE +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __x) +{ return _STLP_PRIV __put_num(*this, __x); } +#endif + +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __x) +{ return _STLP_PRIV __put_num(*this, __x); } + +#ifndef _STLP_NO_BOOL +template +basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __x) +{ return _STLP_PRIV __put_num(*this, __x); } +#endif + +template +void basic_ostream<_CharT, _Traits>::_M_put_char(_CharT __c) { + sentry __sentry(*this); + if (__sentry) { + bool __failed = true; + _STLP_TRY { + streamsize __npad = this->width() > 0 ? this->width() - 1 : 0; + // if (__npad <= 1) + if (__npad == 0) + __failed = this->_S_eof(this->rdbuf()->sputc(__c)); + else if ((this->flags() & ios_base::adjustfield) == ios_base::left) { + __failed = this->_S_eof(this->rdbuf()->sputc(__c)); + __failed = __failed || + this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad; + } + else { + __failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad; + __failed = __failed || this->_S_eof(this->rdbuf()->sputc(__c)); + } + + this->width(0); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + + if (__failed) + this->setstate(ios_base::badbit); + } +} + +template +void basic_ostream<_CharT, _Traits>::_M_put_nowiden(const _CharT* __s) { + sentry __sentry(*this); + if (__sentry) { + bool __failed = true; + streamsize __n = _Traits::length(__s); + streamsize __npad = this->width() > __n ? this->width() - __n : 0; + + _STLP_TRY { + if (__npad == 0) + __failed = this->rdbuf()->sputn(__s, __n) != __n; + else if ((this->flags() & ios_base::adjustfield) == ios_base::left) { + __failed = this->rdbuf()->sputn(__s, __n) != __n; + __failed = __failed || + this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad; + } + else { + __failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad; + __failed = __failed || this->rdbuf()->sputn(__s, __n) != __n; + } + + this->width(0); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + + if (__failed) + this->setstate(ios_base::failbit); + } +} + +template +void basic_ostream<_CharT, _Traits>::_M_put_widen(const char* __s) { + sentry __sentry(*this); + if (__sentry) { + bool __failed = true; + streamsize __n = char_traits::length(__s); + streamsize __npad = this->width() > __n ? this->width() - __n : 0; + + _STLP_TRY { + if (__npad == 0) + __failed = !this->_M_put_widen_aux(__s, __n); + else if ((this->flags() & ios_base::adjustfield) == ios_base::left) { + __failed = !this->_M_put_widen_aux(__s, __n); + __failed = __failed || + this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad; + } + else { + __failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad; + __failed = __failed || !this->_M_put_widen_aux(__s, __n); + } + + this->width(0); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + + if (__failed) + this->setstate(ios_base::failbit); + } +} + +template +bool basic_ostream<_CharT, _Traits>::_M_put_widen_aux(const char* __s, + streamsize __n) { + basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf(); + + for ( ; __n > 0 ; --__n) + if (this->_S_eof(__buf->sputc(this->widen(*__s++)))) + return false; + return true; +} + +// Unformatted output of a single character. +template +basic_ostream<_CharT, _Traits>& +basic_ostream<_CharT, _Traits>::put(char_type __c) { + sentry __sentry(*this); + bool __failed = true; + + if (__sentry) { + _STLP_TRY { + __failed = this->_S_eof(this->rdbuf()->sputc(__c)); + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + } + + if (__failed) + this->setstate(ios_base::badbit); + + return *this; +} + +// Unformatted output of a single character. +template +basic_ostream<_CharT, _Traits>& +basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) { + sentry __sentry(*this); + bool __failed = true; + + if (__sentry) { + _STLP_TRY { + __failed = this->rdbuf()->sputn(__s, __n) != __n; + } + _STLP_CATCH_ALL { + this->_M_handle_exception(ios_base::badbit); + } + } + + if (__failed) + this->setstate(ios_base::badbit); + + return *this; +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_OSTREAM_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_ostream.h b/sdk/tlibstdcxx/stlport/stl/_ostream.h new file mode 100644 index 0000000000..3335b66f5e --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ostream.h @@ -0,0 +1,387 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +#ifndef _STLP_INTERNAL_OSTREAM_H +#define _STLP_INTERNAL_OSTREAM_H + +#ifndef _STLP_INTERNAL_IOS_H +# include // For basic_ios<>. Includes . +#endif + +#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H +# include +#endif + +#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) && !defined (_STLP_INTERNAL_EXCEPTION) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +template +class _Osentry; +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +bool __init_bostr(basic_ostream<_CharT, _Traits>& __str); + +_STLP_MOVE_TO_STD_NAMESPACE + +//---------------------------------------------------------------------- +// class basic_ostream<> + +template +class basic_ostream : virtual public basic_ios<_CharT, _Traits> { + typedef basic_ostream<_CharT, _Traits> _Self; + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + //explicitely defined as private to avoid warnings: + basic_ostream(_Self const&); + _Self& operator = (_Self const&); +#endif + +public: // Types + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + typedef basic_ios<_CharT, _Traits> _Basic_ios; + +public: // Constructor and destructor. + explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf); + ~basic_ostream(); + +public: // Hooks for manipulators. + typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&); + typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&); + typedef _Self& (_STLP_CALL *__ostream_fn)(_Self&); + _Self& operator<< (__ostream_fn __f) { return __f(*this); } + _Self & operator<< (__ios_base_fn __f) { __f(*this); return *this; } + _Self& operator<< (__ios_fn __ff) { __ff(*this); return *this; } + +private: + bool _M_copy_buffered(basic_streambuf<_CharT, _Traits>* __from, + basic_streambuf<_CharT, _Traits>* __to); + bool _M_copy_unbuffered(basic_streambuf<_CharT, _Traits>* __from, + basic_streambuf<_CharT, _Traits>* __to); + +public: + void _M_put_char(_CharT __c); + + void _M_put_nowiden(const _CharT* __s); + void _M_put_widen(const char* __s); + bool _M_put_widen_aux(const char* __s, streamsize __n); + +public: // Unformatted output. + _Self& put(char_type __c); + _Self& write(const char_type* __s, streamsize __n); + +public: // Formatted output. + // Formatted output from a streambuf. + _Self& operator<<(basic_streambuf<_CharT, _Traits>* __buf); +# ifndef _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER + // this is needed for compiling with option char = unsigned + _Self& operator<<(unsigned char __x) { _M_put_char(__x); return *this; } +# endif + _Self& operator<<(short __x); + _Self& operator<<(unsigned short __x); + _Self& operator<<(int __x); +#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300) + _Self& operator<<(unsigned int __x); +#else +/* We define this operator with size_t rather than unsigned int to avoid + * 64 bits warning. + */ + _Self& operator<<(size_t __x); +#endif + _Self& operator<<(long __x); + _Self& operator<<(unsigned long __x); +#ifdef _STLP_LONG_LONG + _Self& operator<< (_STLP_LONG_LONG __x); + _Self& operator<< (unsigned _STLP_LONG_LONG __x); +#endif + _Self& operator<<(float __x); + _Self& operator<<(double __x); +# ifndef _STLP_NO_LONG_DOUBLE + _Self& operator<<(long double __x); +# endif + _Self& operator<<(const void* __x); +# ifndef _STLP_NO_BOOL + _Self& operator<<(bool __x); +# endif + +public: // Buffer positioning and manipulation. + _Self& flush() { + if (this->rdbuf()) + if (this->rdbuf()->pubsync() == -1) + this->setstate(ios_base::badbit); + return *this; + } + + pos_type tellp() { + return this->rdbuf() && !this->fail() + ? this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out) + : pos_type(-1); + } + + _Self& seekp(pos_type __pos) { + if (this->rdbuf() && !this->fail()) { + if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) { + this->setstate(ios_base::failbit); + } + } + return *this; + } + + _Self& seekp(off_type __off, ios_base::seekdir __dir) { + if (this->rdbuf() && !this->fail()) + this->rdbuf()->pubseekoff(__off, __dir, ios_base::out); + return *this; + } + +#if defined (_STLP_USE_TEMPLATE_EXPORT) + // If we are using DLL specs, we have not to use inner classes + // end class declaration here + typedef _Osentry<_CharT, _Traits> sentry; +}; +# define sentry _Osentry + template + class _Osentry { + typedef _Osentry<_CharT, _Traits> _Self; +#else + class sentry { + typedef sentry _Self; +#endif + private: + basic_ostream<_CharT, _Traits>& _M_str; + // basic_streambuf<_CharT, _Traits>* _M_buf; + bool _M_ok; + public: + explicit sentry(basic_ostream<_CharT, _Traits>& __str) + : _M_str(__str), /* _M_buf(__str.rdbuf()), */ _M_ok(_STLP_PRIV __init_bostr(__str)) + {} + + ~sentry() { + if (_M_str.flags() & ios_base::unitbuf) +#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) + if (!uncaught_exception()) +#endif + _M_str.flush(); + } + + operator bool() const { return _M_ok; } + private: // Disable assignment and copy constructor. + //Implementation is here only to avoid warning with some compilers. + sentry(const _Self& __s) : _M_str(__s._M_str) {} + _Self& operator=(const _Self&) { return *this; } + }; +#if defined (_STLP_USE_TEMPLATE_EXPORT) +# undef sentry +#else + // close basic_ostream class definition here +}; +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_ostream >; +_STLP_EXPORT_TEMPLATE_CLASS _Osentry >; +# if !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_ostream >; +_STLP_EXPORT_TEMPLATE_CLASS _Osentry >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Helper functions for istream<>::sentry constructor. +template +bool __init_bostr(basic_ostream<_CharT, _Traits>& __str) { + if (__str.good()) { + // boris : check if this is needed ! + if (!__str.rdbuf()) + __str.setstate(ios_base::badbit); + if (__str.tie()) + __str.tie()->flush(); + return __str.good(); + } + else + return false; +} + +template +inline basic_streambuf<_CharT, _Traits>* _STLP_CALL +__get_ostreambuf(basic_ostream<_CharT, _Traits>& __St) +{ return __St.rdbuf(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +// Non-member functions. +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c){ + __os._M_put_char(__c); + return __os; +} + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s) { + __os._M_put_nowiden(__s); + return __os; +} + +#if defined (_STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER) +// some specializations + +inline basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __os, char __c) { + __os._M_put_char(__c); + return __os; +} + +inline basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __os, signed char __c) { + __os._M_put_char(__c); + return __os; +} + +inline basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __os, unsigned char __c) { + __os._M_put_char(__c); + return __os; +} + +inline basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __os, const char* __s) { + __os._M_put_nowiden(__s); + return __os; +} + +inline basic_ostream >& _STLP_CALL +operator<<(basic_ostream >& __os, const signed char* __s) { + __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); + return __os; +} + +inline basic_ostream >& +operator<<(basic_ostream >& __os, const unsigned char* __s) { + __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); + return __os; +} + +#else + +// also for compilers who might use that +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, char __c) { + __os._M_put_char(__os.widen(__c)); + return __os; +} + +template +inline basic_ostream& _STLP_CALL +operator<<(basic_ostream& __os, char __c) { + __os._M_put_char(__c); + return __os; +} + +template +inline basic_ostream& _STLP_CALL +operator<<(basic_ostream& __os, signed char __c) { + __os._M_put_char(__c); + return __os; +} + +template +inline basic_ostream& _STLP_CALL +operator<<(basic_ostream& __os, unsigned char __c) { + __os._M_put_char(__c); + return __os; +} + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __s) { + __os._M_put_widen(__s); + return __os; +} + +template +inline basic_ostream& _STLP_CALL +operator<<(basic_ostream& __os, const char* __s) { + __os._M_put_nowiden(__s); + return __os; +} + +template +inline basic_ostream& _STLP_CALL +operator<<(basic_ostream& __os, const signed char* __s) { + __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); + return __os; +} + +template +inline basic_ostream& +operator<<(basic_ostream& __os, const unsigned char* __s) { + __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); + return __os; +} +#endif /* _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER */ + +//---------------------------------------------------------------------- +// basic_ostream manipulators. + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +endl(basic_ostream<_CharT, _Traits>& __os) { + __os.put(__os.widen('\n')); + __os.flush(); + return __os; +} + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +ends(basic_ostream<_CharT, _Traits>& __os) { + __os.put(_STLP_DEFAULT_CONSTRUCTED(_CharT)); + return __os; +} + +template +inline basic_ostream<_CharT, _Traits>& _STLP_CALL +flush(basic_ostream<_CharT, _Traits>& __os) { + __os.flush(); + return __os; +} + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_OSTREAM_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_ostreambuf_iterator.h b/sdk/tlibstdcxx/stlport/stl/_ostreambuf_iterator.h new file mode 100644 index 0000000000..d8865493c3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ostreambuf_iterator.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H +#define _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H + +#ifndef _STLP_INTERNAL_STREAMBUF +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +extern basic_streambuf<_CharT, _Traits>* _STLP_CALL __get_ostreambuf(basic_ostream<_CharT, _Traits>&); + +_STLP_MOVE_TO_STD_NAMESPACE + +// The default template argument is declared in iosfwd +template +class ostreambuf_iterator : + public iterator { +public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename _Traits::int_type int_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + +public: + ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {} + // ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(__get_ostreambuf(__o)), _M_ok(_M_buf != 0) {} + inline ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW; + + ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) { + _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c), + traits_type::eof()); + return *this; + } + + ostreambuf_iterator<_CharT, _Traits>& operator*() { return *this; } + ostreambuf_iterator<_CharT, _Traits>& operator++() { return *this; } + ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; } + + bool failed() const { return !_M_ok; } + +private: + streambuf_type* _M_buf; + bool _M_ok; +}; + +template +inline ostreambuf_iterator<_CharT, _Traits>::ostreambuf_iterator(basic_ostream<_CharT, _Traits>& __o) _STLP_NOTHROW + : _M_buf(_STLP_PRIV __get_ostreambuf(__o)), _M_ok(_M_buf != 0) {} + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator >; +# if defined (INSTANTIATE_WIDE_STREAMS) +_STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +template +inline output_iterator_tag _STLP_CALL +iterator_category(const ostreambuf_iterator<_CharT, _Traits>&) { return output_iterator_tag(); } +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_pair.h b/sdk/tlibstdcxx/stlport/stl/_pair.h new file mode 100644 index 0000000000..7038bb1a15 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_pair.h @@ -0,0 +1,182 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_PAIR_H +#define _STLP_INTERNAL_PAIR_H + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# ifndef _STLP_TYPE_TRAITS_H +# include +# endif + +# if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC) +# include +# endif +#endif + +_STLP_BEGIN_NAMESPACE + +template +struct pair { + typedef _T1 first_type; + typedef _T2 second_type; + + _T1 first; + _T2 second; +#if defined (_STLP_CONST_CONSTRUCTOR_BUG) + pair() {} +#else + pair() : first(_T1()), second(_T2()) {} +#endif + pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template + pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} + + pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {} +#endif + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) + pair(__move_source > src) : first(_STLP_PRIV _AsMoveSource(src.get().first)), + second(_STLP_PRIV _AsMoveSource(src.get().second)) + {} +#endif + + __TRIVIAL_DESTRUCTOR(pair) +}; + +template +inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return __x.first == __y.first && __x.second == __y.second; } + +template +inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { + return __x.first < __y.first || + (!(__y.first < __x.first) && __x.second < __y.second); +} + +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template +inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return !(__x == __y); } + +template +inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return __y < __x; } + +template +inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return !(__y < __x); } + +template +inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return !(__x < __y); } +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS) +template +inline pair<_T1, _T2 const*> make_pair(_T1 const& __x, + _T2 const (&__y)[_Sz]) +{ return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); } + +template +inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz], + _T2 const& __y) +{ return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); } + +template +inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1], + _T2 const (&__y)[_Sz2]) { + return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x), + static_cast<_T2 const*>(__y)); +} +#endif + +template +inline pair<_T1, _T2> _STLP_CALL make_pair(_T1 __x, _T2 __y) +{ return pair<_T1, _T2>(__x, __y); } + +_STLP_END_NAMESPACE + +#if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +_STLP_BEGIN_RELOPS_NAMESPACE + +template +inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y) +{ return !(__x == __y); } + +template +inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y) +{ return __y < __x; } + +template +inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y) +{ return !(__y < __x); } + +template +inline bool _STLP_CALL operator>=(const _Tp& __x, const _Tp& __y) +{ return !(__x < __y); } + +_STLP_END_RELOPS_NAMESPACE +#endif + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_BEGIN_NAMESPACE + +template +struct __type_traits > { + typedef __type_traits<_T1> _T1Traits; + typedef __type_traits<_T2> _T2Traits; + typedef typename _Land2::_Ret has_trivial_default_constructor; + typedef typename _Land2::_Ret has_trivial_copy_constructor; + typedef typename _Land2::_Ret has_trivial_assignment_operator; + typedef typename _Land2::_Ret has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > + : _STLP_PRIV __move_traits_help1<_T1, _T2> {}; +# endif + +_STLP_END_NAMESPACE +#endif + +#endif /* _STLP_INTERNAL_PAIR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_prolog.h b/sdk/tlibstdcxx/stlport/stl/_prolog.h new file mode 100644 index 0000000000..9705c2c674 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_prolog.h @@ -0,0 +1,18 @@ +/* NOTE : this header has no guards and is MEANT for multiple inclusion! + * If you are using "header protection" option with your compiler, + * please also find #pragma which disables it and put it here, to + * allow reentrancy of this header. + */ + +#include + +/* Get all debug things, potentially only empty macros if none of + * the debug features available in user config file is activated. */ + /* Thanks to _STLP_OUTERMOST_HEADER_ID we hide _debug.h when C standard + * headers are included as some platforms (Win32) include C standard headers + * in an 'extern "C"' scope which do not accept the templates exposed + * in _debug.h. */ +#if defined (__cplusplus) && !defined (_STLP_DEBUG_H) && \ + !((_STLP_OUTERMOST_HEADER_ID >= 0x200) && (_STLP_OUTERMOST_HEADER_ID <= 0x300)) +# include +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_pthread_alloc.h b/sdk/tlibstdcxx/stlport/stl/_pthread_alloc.h new file mode 100644 index 0000000000..f45d9497ba --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_pthread_alloc.h @@ -0,0 +1,461 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_PTHREAD_ALLOC_H +#define _STLP_PTHREAD_ALLOC_H + +/* + * Pthread-specific node allocator. + * This is similar to the default allocator, except that free-list + * information is kept separately for each thread, avoiding locking. + * This should be reasonably fast even in the presence of threads. + * The down side is that storage may not be well-utilized. + * It is not an error to allocate memory in thread A and deallocate + * it in thread B. But this effectively transfers ownership of the memory, + * so that it can only be reallocated by thread B. Thus this can effectively + * result in a storage leak if it's done on a regular basis. + * It can also result in frequent sharing of + * cache lines among processors, with potentially serious performance + * consequences. + */ + +#if !defined (_STLP_PTHREADS) +# error POSIX specific allocator implementation. Your system do not seems to \ +have this interface so please comment the _STLP_USE_PERTHREAD_ALLOC macro \ +or report to the STLport forum. +#endif + +#if defined (_STLP_USE_NO_IOSTREAMS) +# error You cannot use per thread allocator implementation without building \ +STLport libraries. +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _Pthread_alloc_per_thread_state; + +// Pthread-specific allocator. +class _STLP_CLASS_DECLSPEC _Pthread_alloc { +public: // but only for internal use: + typedef _Pthread_alloc_per_thread_state __state_type; + typedef char value_type; + +public: + // Return a recycled or new per thread state. + static __state_type * _STLP_CALL _S_get_per_thread_state(); + + /* n must be > 0 */ + static void * _STLP_CALL allocate(size_t& __n); + + /* p may not be 0 */ + static void _STLP_CALL deallocate(void *__p, size_t __n); + + // boris : versions for per_thread_allocator + /* n must be > 0 */ + static void * _STLP_CALL allocate(size_t& __n, __state_type* __a); + + /* p may not be 0 */ + static void _STLP_CALL deallocate(void *__p, size_t __n, __state_type* __a); + + static void * _STLP_CALL reallocate(void *__p, size_t __old_sz, size_t& __new_sz); +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +typedef _STLP_PRIV _Pthread_alloc __pthread_alloc; +typedef __pthread_alloc pthread_alloc; + +template +class pthread_allocator : public __stlport_class > { + typedef pthread_alloc _S_Alloc; // The underlying allocator. +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + +#ifdef _STLP_MEMBER_TEMPLATE_CLASSES + template struct rebind { + typedef pthread_allocator<_NewType> other; + }; +#endif + + pthread_allocator() _STLP_NOTHROW {} + pthread_allocator(const pthread_allocator<_Tp>& a) _STLP_NOTHROW {} + +#if defined (_STLP_MEMBER_TEMPLATES) /* && defined (_STLP_FUNCTION_PARTIAL_ORDER) */ + template pthread_allocator(const pthread_allocator<_OtherType>&) + _STLP_NOTHROW {} +#endif + + ~pthread_allocator() _STLP_NOTHROW {} + + pointer address(reference __x) const { return &__x; } + const_pointer address(const_reference __x) const { return &__x; } + + // __n is permitted to be 0. The C++ standard says nothing about what + // the return value is when __n == 0. + _Tp* allocate(size_type __n, const void* = 0) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(value_type*, _S_Alloc::allocate(__buf_size)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + return __ret; + } + else + return 0; + } + + void deallocate(pointer __p, size_type __n) { + _STLP_ASSERT( (__p == 0) == (__n == 0) ) + if (__p != 0) { +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type)); +#endif + _S_Alloc::deallocate(__p, __n * sizeof(value_type)); + } + } + + size_type max_size() const _STLP_NOTHROW + { return size_t(-1) / sizeof(_Tp); } + + void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); } + void destroy(pointer _p) { _p->~_Tp(); } + +#if defined (_STLP_NO_EXTENSIONS) + /* STLport extension giving rounded size of an allocated memory buffer + * This method do not have to be part of a user defined allocator implementation + * and won't even be called if such a function was granted. + */ +protected: +#endif + _Tp* allocate(size_type __n, size_type& __allocated_n) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(value_type*, _S_Alloc::allocate(__buf_size)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + __allocated_n = __buf_size / sizeof(value_type); + return __ret; + } + else + return 0; + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(pthread_allocator<_Tp>& __x) {} +#endif +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC pthread_allocator { +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef void* pointer; + typedef const void* const_pointer; + typedef void value_type; +#ifdef _STLP_MEMBER_TEMPLATE_CLASSES + template struct rebind { + typedef pthread_allocator<_NewType> other; + }; +#endif +}; + +template +inline bool operator==(const pthread_allocator<_T1>&, + const pthread_allocator<_T2>& a2) +{ return true; } + +#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER +template +inline bool operator!=(const pthread_allocator<_T1>&, + const pthread_allocator<_T2>&) +{ return false; } +#endif + + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + +template +struct _Alloc_traits<_Tp, pthread_allocator<_Atype> > +{ typedef pthread_allocator<_Tp> allocator_type; }; + +#endif + +#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) + +template +inline pthread_allocator<_Tp2>& +__stl_alloc_rebind(pthread_allocator<_Tp1>& __x, const _Tp2*) +{ return (pthread_allocator<_Tp2>&)__x; } + +template +inline pthread_allocator<_Tp2> +__stl_alloc_create(pthread_allocator<_Tp1>&, const _Tp2*) +{ return pthread_allocator<_Tp2>(); } + +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct __pthread_alloc_type_traits { + typedef typename _IsSTLportClass >::_Ret _STLportAlloc; + //The default allocator implementation which is recognize thanks to the + //__stlport_class inheritance is a stateless object so: + typedef _STLportAlloc has_trivial_default_constructor; + typedef _STLportAlloc has_trivial_copy_constructor; + typedef _STLportAlloc has_trivial_assignment_operator; + typedef _STLportAlloc has_trivial_destructor; + typedef _STLportAlloc is_POD_type; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct __type_traits > : _STLP_PRIV __pthread_alloc_type_traits<_Tp> {}; +#else +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __pthread_alloc_type_traits {}; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __pthread_alloc_type_traits {}; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __pthread_alloc_type_traits {}; +# endif +#endif + +// +// per_thread_allocator<> : this allocator always return memory to the same thread +// it was allocated from. +// + +template +class per_thread_allocator { + typedef pthread_alloc _S_Alloc; // The underlying allocator. + typedef pthread_alloc::__state_type __state_type; +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + +#ifdef _STLP_MEMBER_TEMPLATE_CLASSES + template struct rebind { + typedef per_thread_allocator<_NewType> other; + }; +#endif + + per_thread_allocator() _STLP_NOTHROW { + _M_state = _S_Alloc::_S_get_per_thread_state(); + } + per_thread_allocator(const per_thread_allocator<_Tp>& __a) _STLP_NOTHROW : _M_state(__a._M_state){} + +#if defined (_STLP_MEMBER_TEMPLATES) /* && defined (_STLP_FUNCTION_PARTIAL_ORDER) */ + template per_thread_allocator(const per_thread_allocator<_OtherType>& __a) + _STLP_NOTHROW : _M_state(__a._M_state) {} +#endif + + ~per_thread_allocator() _STLP_NOTHROW {} + + pointer address(reference __x) const { return &__x; } + const_pointer address(const_reference __x) const { return &__x; } + + // __n is permitted to be 0. The C++ standard says nothing about what + // the return value is when __n == 0. + _Tp* allocate(size_type __n, const void* = 0) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(_Tp*, _S_Alloc::allocate(__buf_size, _M_state)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + return __ret; + } + else + return 0; + } + + void deallocate(pointer __p, size_type __n) { + _STLP_ASSERT( (__p == 0) == (__n == 0) ) + if (__p != 0) { +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type)); +#endif + _S_Alloc::deallocate(__p, __n * sizeof(value_type), _M_state); + } + } + + size_type max_size() const _STLP_NOTHROW + { return size_t(-1) / sizeof(_Tp); } + + void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); } + void destroy(pointer _p) { _p->~_Tp(); } + + // state is being kept here + __state_type* _M_state; + +#if defined (_STLP_NO_EXTENSIONS) + /* STLport extension giving rounded size of an allocated memory buffer + * This method do not have to be part of a user defined allocator implementation + * and won't even be called if such a function was granted. + */ +protected: +#endif + _Tp* allocate(size_type __n, size_type& __allocated_n) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(value_type*, _S_Alloc::allocate(__buf_size, _M_state)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + __allocated_n = __buf_size / sizeof(value_type); + return __ret; + } + else + return 0; + } +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC per_thread_allocator { +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef void* pointer; + typedef const void* const_pointer; + typedef void value_type; +#ifdef _STLP_MEMBER_TEMPLATE_CLASSES + template struct rebind { + typedef per_thread_allocator<_NewType> other; + }; +#endif +}; + +template +inline bool operator==(const per_thread_allocator<_T1>& __a1, + const per_thread_allocator<_T2>& __a2) +{ return __a1._M_state == __a2._M_state; } + +#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER +template +inline bool operator!=(const per_thread_allocator<_T1>& __a1, + const per_thread_allocator<_T2>& __a2) +{ return __a1._M_state != __a2._M_state; } +#endif + + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + +template +struct _Alloc_traits<_Tp, per_thread_allocator<_Atype> > +{ typedef per_thread_allocator<_Tp> allocator_type; }; + +#endif + +#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) + +template +inline per_thread_allocator<_Tp2>& +__stl_alloc_rebind(per_thread_allocator<_Tp1>& __x, const _Tp2*) +{ return (per_thread_allocator<_Tp2>&)__x; } + +template +inline per_thread_allocator<_Tp2> +__stl_alloc_create(per_thread_allocator<_Tp1>&, const _Tp2*) +{ return per_thread_allocator<_Tp2>(); } + +#endif /* _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE */ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct __perthread_alloc_type_traits { + typedef typename _IsSTLportClass >::_Ret _STLportAlloc; + //The default allocator implementation which is recognize thanks to the + //__stlport_class inheritance is a stateless object so: + typedef __false_type has_trivial_default_constructor; + typedef _STLportAlloc has_trivial_copy_constructor; + typedef _STLportAlloc has_trivial_assignment_operator; + typedef _STLportAlloc has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct __type_traits > : _STLP_PRIV __perthread_alloc_type_traits<_Tp> {}; +#else +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __perthread_alloc_type_traits {}; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __perthread_alloc_type_traits {}; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_TEMPLATE_NULL +struct __type_traits > : _STLP_PRIV __perthread_alloc_type_traits {}; +# endif +#endif + + +_STLP_END_NAMESPACE + +#endif /* _STLP_PTHREAD_ALLOC */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_ptrs_specialize.h b/sdk/tlibstdcxx/stlport/stl/_ptrs_specialize.h new file mode 100644 index 0000000000..b9cb5d8867 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_ptrs_specialize.h @@ -0,0 +1,83 @@ +#ifndef _STLP_PTRS_SPECIALIZE_H +#define _STLP_PTRS_SPECIALIZE_H + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || \ + (defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && !defined (_STLP_NO_ARROW_OPERATOR)) +# define _STLP_POINTERS_SPECIALIZE( _TpP ) +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(operator*()); } +#else +# ifndef _STLP_TYPE_TRAITS_H +# include +# endif + +// the following is a workaround for arrow operator problems +# if defined ( _STLP_NO_ARROW_OPERATOR ) +// User wants to disable proxy -> operators +# define _STLP_DEFINE_ARROW_OPERATOR +# else +// Compiler can handle generic -> operator. +# if defined (__BORLANDC__) +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(*(*this)); } +# elif defined(__WATCOMC__) +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { reference x = operator*(); return &x; } +# else +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(operator*()); } +# endif +# endif /* _STLP_NO_ARROW_OPERATOR */ + +// Important pointers specializations + +# ifdef _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type) +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type) +# else +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type) _STLP_TEMPLATE_NULL struct __type_traits<_Type> : __type_traits_aux<__true_type> {}; +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type*) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type*) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type**) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type* const *) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type**) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type***) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type***) +# endif + +# define _STLP_POINTERS_SPECIALIZE(_Type) _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type) + +_STLP_BEGIN_NAMESPACE + +# if !defined ( _STLP_NO_BOOL ) +_STLP_POINTERS_SPECIALIZE( bool ) +# endif +_STLP_TYPE_TRAITS_POD_SPECIALIZE_V(void) +# ifndef _STLP_NO_SIGNED_BUILTINS + _STLP_POINTERS_SPECIALIZE( signed char ) +# endif + _STLP_POINTERS_SPECIALIZE( char ) + _STLP_POINTERS_SPECIALIZE( unsigned char ) + _STLP_POINTERS_SPECIALIZE( short ) + _STLP_POINTERS_SPECIALIZE( unsigned short ) + _STLP_POINTERS_SPECIALIZE( int ) + _STLP_POINTERS_SPECIALIZE( unsigned int ) + _STLP_POINTERS_SPECIALIZE( long ) + _STLP_POINTERS_SPECIALIZE( unsigned long ) + _STLP_POINTERS_SPECIALIZE( float ) + _STLP_POINTERS_SPECIALIZE( double ) +# if !defined ( _STLP_NO_LONG_DOUBLE ) + _STLP_POINTERS_SPECIALIZE( long double ) +# endif +# if defined ( _STLP_LONG_LONG) + _STLP_POINTERS_SPECIALIZE( _STLP_LONG_LONG ) + _STLP_POINTERS_SPECIALIZE( unsigned _STLP_LONG_LONG ) +# endif +# if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) + _STLP_POINTERS_SPECIALIZE( wchar_t ) +# endif + +_STLP_END_NAMESPACE + +# undef _STLP_ARROW_SPECIALIZE +# undef _STLP_TYPE_TRAITS_POD_SPECIALIZE_V + +#endif +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_queue.h b/sdk/tlibstdcxx/stlport/stl/_queue.h new file mode 100644 index 0000000000..5f3763c020 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_queue.h @@ -0,0 +1,268 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_QUEUE_H +#define _STLP_INTERNAL_QUEUE_H + +#ifndef _STLP_INTERNAL_DEQUE_H +# include +#endif + +#ifndef _STLP_INTERNAL_VECTOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_HEAP_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +# if ! defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) +template > +# elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS ) +# define _STLP_QUEUE_ARGS _Tp +template +# else +template +# endif +class queue +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) +# if defined (_STLP_QUEUE_ARGS) + : public __stlport_class > +# else + : public __stlport_class > +# endif +#endif +{ +# if defined ( _STLP_QUEUE_ARGS ) + typedef deque<_Tp> _Sequence; + typedef queue<_Tp> _Self; +# else + typedef queue<_Tp, _Sequence> _Self; +# endif +public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; + +protected: + //c is a Standard name (23.2.3.1), do no make it STLport naming convention compliant. + _Sequence c; +public: + queue() : c() {} + explicit queue(const _Sequence& __c) : c(__c) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + queue(__move_source<_Self> src) + : c(_STLP_PRIV _AsMoveSource(src.get().c)) {} +#endif + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + reference front() { return c.front(); } + const_reference front() const { return c.front(); } + reference back() { return c.back(); } + const_reference back() const { return c.back(); } + void push(const value_type& __x) { c.push_back(__x); } + void pop() { c.pop_front(); } + const _Sequence& _Get_s() const { return c; } + +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { + _Sequence __tmp = c; + c = __x.c; + __x.c = __tmp; + } +#endif +}; + +#ifndef _STLP_QUEUE_ARGS +# define _STLP_QUEUE_ARGS _Tp, _Sequence +# define _STLP_QUEUE_HEADER_ARGS class _Tp, class _Sequence +#else +# define _STLP_QUEUE_HEADER_ARGS class _Tp +#endif + +template < _STLP_QUEUE_HEADER_ARGS > +inline bool _STLP_CALL +operator==(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) { + return __x._Get_s() == __y._Get_s(); +} + +template < _STLP_QUEUE_HEADER_ARGS > +inline bool _STLP_CALL +operator<(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) { + return __x._Get_s() < __y._Get_s(); +} + +_STLP_RELOPS_OPERATORS( template < _STLP_QUEUE_HEADER_ARGS >, queue<_STLP_QUEUE_ARGS > ) + +# if !(defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) || defined ( _STLP_TEMPLATE_PARAM_SUBTYPE_BUG )) +template , + class _Compare = less<_STLP_HEADER_TYPENAME _Sequence::value_type> > +# elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS ) +template +# else +template +# endif +class priority_queue +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) +# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) + : public __stlport_class > +# else + : public __stlport_class > +# endif +#endif +{ +# ifdef _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS + typedef vector<_Tp> _Sequence; + typedef less< typename vector<_Tp>::value_type> _Compare; + typedef priority_queue<_Tp> _Self; +# else + typedef priority_queue<_Tp, _Sequence, _Compare> _Self; +# endif +public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; +protected: + //c is a Standard name (23.2.3.2), do no make it STLport naming convention compliant. + _Sequence c; + _Compare comp; +public: + priority_queue() : c() {} + explicit priority_queue(const _Compare& __x) : c(), comp(__x) {} + priority_queue(const _Compare& __x, const _Sequence& __s) + : c(__s), comp(__x) + { make_heap(c.begin(), c.end(), comp); } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + priority_queue(__move_source<_Self> src) + : c(_STLP_PRIV _AsMoveSource(src.get().c)), + comp(_STLP_PRIV _AsMoveSource(src.get().comp)) {} +#endif + +#ifdef _STLP_MEMBER_TEMPLATES + template + priority_queue(_InputIterator __first, _InputIterator __last) + : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } + + template + priority_queue(_InputIterator __first, + _InputIterator __last, const _Compare& __x) + : c(__first, __last), comp(__x) + { make_heap(c.begin(), c.end(), comp); } + + template + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, const _Sequence& __s) + : c(__s), comp(__x) + { + c.insert(c.end(), __first, __last); + make_heap(c.begin(), c.end(), comp); + } + +#else /* _STLP_MEMBER_TEMPLATES */ + priority_queue(const value_type* __first, const value_type* __last) + : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } + + priority_queue(const value_type* __first, const value_type* __last, + const _Compare& __x) + : c(__first, __last), comp(__x) + { make_heap(c.begin(), c.end(), comp); } + + priority_queue(const value_type* __first, const value_type* __last, + const _Compare& __x, const _Sequence& __c) + : c(__c), comp(__x) + { + c.insert(c.end(), __first, __last); + make_heap(c.begin(), c.end(), comp); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + const_reference top() const { return c.front(); } + void push(const value_type& __x) { + _STLP_TRY { + c.push_back(__x); + push_heap(c.begin(), c.end(), comp); + } + _STLP_UNWIND(c.clear()) + } + void pop() { + _STLP_TRY { + pop_heap(c.begin(), c.end(), comp); + c.pop_back(); + } + _STLP_UNWIND(c.clear()) + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { + _Sequence __tmp = c; + c = __x.c; + __x.c = __tmp; + } +#endif +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux<_Sequence> +{}; + +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux2<_Sequence, _Compare> +{}; +#endif + +_STLP_END_NAMESPACE + +#undef _STLP_QUEUE_ARGS +#undef _STLP_QUEUE_HEADER_ARGS +#undef comp + +#endif /* _STLP_INTERNAL_QUEUE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_range_errors.c b/sdk/tlibstdcxx/stlport/stl/_range_errors.c new file mode 100644 index 0000000000..537e91a911 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_range_errors.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#if defined(_STLP_THROW_RANGE_ERRORS) +# if defined (_STLP_WHOLE_NATIVE_STD) && defined (_STLP_DONT_REDEFINE_STD) +// In this mode we are going to throw native exception so that catch of +// exception like std::runtime_error for instance will also catch exception +// thrown by STLport containers like stlport::vector or stlport::string. +# include +# include +# define _STLP_THROW_MSG(ex,msg) throw std::ex(msg) +# else +# if !defined (_STLP_SGX_CONFIG) && defined (__BUILDING_STLPORT) +# include +# include +# else +# ifndef _STLP_INTERNAL_STDEXCEPT +# include +# endif +# ifndef _STLP_INTERNAL_STRING_H +# include +# endif +# endif +# define _STLP_THROW_MSG(ex,msg) throw ex(msg) +# endif +#else +# if !defined (_STLP_SGX_CONFIG) && defined (__BUILDING_STLPORT) +# include +# include +# else +# ifndef _STLP_INTERNAL_CSTDLIB +# include +# endif +# ifndef _STLP_INTERNAL_CSTDIO +# include +# endif +# endif +# define _STLP_THROW_MSG(ex,msg) /*puts(msg),*/(void)(msg), _STLP_ABORT() +#endif + +// For mode without library and throwing range errors, include the +// stdexcept header and throw the appropriate exceptions directly. + +#if defined (_STLP_EXTERN_RANGE_ERRORS) +# define _STLP_THROW_FUNCT_SPEC void _STLP_DECLSPEC +#else +# define _STLP_THROW_FUNCT_SPEC inline void +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg) +{ _STLP_THROW_MSG(runtime_error, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_range_error(const char* __msg) +{ _STLP_THROW_MSG(range_error, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg) +{ _STLP_THROW_MSG(out_of_range, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_length_error(const char* __msg) +{ _STLP_THROW_MSG(length_error, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg) +{ _STLP_THROW_MSG(invalid_argument, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg) +{ _STLP_THROW_MSG(overflow_error, __msg); } + +_STLP_END_NAMESPACE + +#undef _STLP_THROW_FUNCT_SPEC +#undef _STLP_THROW_MSG diff --git a/sdk/tlibstdcxx/stlport/stl/_range_errors.h b/sdk/tlibstdcxx/stlport/stl/_range_errors.h new file mode 100644 index 0000000000..80df26a465 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_range_errors.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef _STLP_RANGE_ERRORS_H +#define _STLP_RANGE_ERRORS_H + +// A few places in the STL throw range errors, using standard exception +// classes defined in . This header file provides functions +// to throw those exception objects. + +// _STLP_DONT_THROW_RANGE_ERRORS is a hook so that users can disable +// this exception throwing. +#if defined (_STLP_CAN_THROW_RANGE_ERRORS) && defined (_STLP_USE_EXCEPTIONS) && \ + !defined (_STLP_DONT_THROW_RANGE_ERRORS) +# define _STLP_THROW_RANGE_ERRORS +#endif + +// For the STLport iostreams, only declaration here, definition is in the lib +#if !defined (_STLP_USE_NO_IOSTREAMS) && !defined (_STLP_EXTERN_RANGE_ERRORS) +# define _STLP_EXTERN_RANGE_ERRORS +#endif + +_STLP_BEGIN_NAMESPACE +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg); + +#if defined (__DMC__) && !defined (_STLP_NO_EXCEPTIONS) +# pragma noreturn(__stl_throw_runtime_error) +# pragma noreturn(__stl_throw_range_error) +# pragma noreturn(__stl_throw_out_of_range) +# pragma noreturn(__stl_throw_length_error) +# pragma noreturn(__stl_throw_invalid_argument) +# pragma noreturn(__stl_throw_overflow_error) +#endif +_STLP_END_NAMESPACE + +#if !defined (_STLP_EXTERN_RANGE_ERRORS) +# include +#endif + +#endif /* _STLP_RANGE_ERRORS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_raw_storage_iter.h b/sdk/tlibstdcxx/stlport/stl/_raw_storage_iter.h new file mode 100644 index 0000000000..6e4bc2e9de --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_raw_storage_iter.h @@ -0,0 +1,80 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_RAW_STORAGE_ITERATOR_H +#define _STLP_INTERNAL_RAW_STORAGE_ITERATOR_H + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +class raw_storage_iterator + : public iterator +{ +protected: + _ForwardIterator _M_iter; +public: + typedef output_iterator_tag iterator_category; +# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; +# endif + explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {} + raw_storage_iterator<_ForwardIterator, _Tp>& operator*() { return *this; } + raw_storage_iterator<_ForwardIterator, _Tp>& operator=(const _Tp& __element) { + _Param_Construct(&*_M_iter, __element); + return *this; + } + raw_storage_iterator<_ForwardIterator, _Tp>& operator++() { + ++_M_iter; + return *this; + } + raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) { + raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this; + ++_M_iter; + return __tmp; + } +}; + +# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES +template +inline output_iterator_tag iterator_category(const raw_storage_iterator<_ForwardIterator, _Tp>&) { return output_iterator_tag(); } +#endif +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_RAW_STORAGE_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_relops_cont.h b/sdk/tlibstdcxx/stlport/stl/_relops_cont.h new file mode 100644 index 0000000000..cd8ec05043 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_relops_cont.h @@ -0,0 +1,29 @@ +// This is an implementation file which +// is intended to be included multiple times with different _STLP_ASSOCIATIVE_CONTAINER +// setting + +#if !defined (_STLP_EQUAL_OPERATOR_SPECIALIZED) +_STLP_TEMPLATE_HEADER +inline bool _STLP_CALL operator==(const _STLP_TEMPLATE_CONTAINER& __x, + const _STLP_TEMPLATE_CONTAINER& __y) { + return __x.size() == __y.size() && + equal(__x.begin(), __x.end(), __y.begin()); +} +#endif /* _STLP_EQUAL_OPERATOR_SPECIALIZED */ + +_STLP_TEMPLATE_HEADER +inline bool _STLP_CALL operator<(const _STLP_TEMPLATE_CONTAINER& __x, + const _STLP_TEMPLATE_CONTAINER& __y) { + return lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); +} + +_STLP_RELOPS_OPERATORS( _STLP_TEMPLATE_HEADER , _STLP_TEMPLATE_CONTAINER ) + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +_STLP_TEMPLATE_HEADER +inline void _STLP_CALL swap(_STLP_TEMPLATE_CONTAINER& __x, + _STLP_TEMPLATE_CONTAINER& __y) { + __x.swap(__y); +} +#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ diff --git a/sdk/tlibstdcxx/stlport/stl/_relops_hash_cont.h b/sdk/tlibstdcxx/stlport/stl/_relops_hash_cont.h new file mode 100644 index 0000000000..421c8050bf --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_relops_hash_cont.h @@ -0,0 +1,13 @@ +/* This is an implementation file which is intended to be included + * multiple times with different _STLP_TEMPLATE_CONTAINER settings. + */ + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + +_STLP_TEMPLATE_HEADER +inline void _STLP_CALL +swap(_STLP_TEMPLATE_CONTAINER& __hm1, _STLP_TEMPLATE_CONTAINER& __hm2) { + __hm1.swap(__hm2); +} + +#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ diff --git a/sdk/tlibstdcxx/stlport/stl/_rope.c b/sdk/tlibstdcxx/stlport/stl/_rope.c new file mode 100644 index 0000000000..196ee220b5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_rope.c @@ -0,0 +1,1407 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf +// if necessary. Assumes path_end[leaf_index] and leaf_pos are correct. +// Results in a valid buf_ptr if the iterator can be legitimately +// dereferenced. +#ifndef _STLP_ROPEIMPL_H +#define _STLP_ROPEIMPL_H + +#ifndef _STLP_INTERNAL_ROPE_H +# include +#endif + +#ifndef _STLP_INTERNAL_CSTDIO +# include +#endif + +#if !defined (_STLP_USE_NO_IOSTREAMS) +# ifndef _STLP_INTERNAL_OSTREAM_H +# include +# endif + +# ifndef _STLP_INTERNAL_ISTREAM +# include +# endif +#endif + +#include + +_STLP_BEGIN_NAMESPACE + +#if defined ( _STLP_NESTED_TYPE_PARAM_BUG ) +# define __allocator__ _Alloc +#else +# define __allocator__ allocator_type +#endif + +template +_Rope_iterator<_CharT, _Alloc>::_Rope_iterator(rope<_CharT,_Alloc>* __r, size_t __pos) + : _Rope_iterator_base<_CharT,_Alloc>(__r->_M_tree_ptr._M_data, __pos), + _M_root_rope(__r) { _RopeRep::_S_ref(this->_M_root); } + +template +_Rope_iterator<_CharT, _Alloc>::_Rope_iterator(rope<_CharT,_Alloc>& __r, size_t __pos): + _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr._M_data, __pos), + _M_root_rope(&__r) { +#if !defined (__DMC__) + _RopeRep::_S_ref(this->_M_root); if (!(__r.empty()))_S_setcache(*this); +#else + _Rope_iterator_base<_CharT, _Alloc>* __x = this; + _RopeRep::_S_ref(this->_M_root); if (!(__r.empty()))_S_setcache(*__x); +#endif +} + +template +void _Rope_RopeRep<_CharT, _Alloc>::_M_free_c_string() { + _CharT* __cstr = _M_c_string; + if (0 != __cstr) { + size_t _p_size = _M_size._M_data + 1; + _STLP_STD::_Destroy_Range(__cstr, __cstr + _p_size); + _M_size.deallocate(__cstr, _p_size); + } +} + +// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf +// if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct. +// Results in a valid buf_ptr if the iterator can be legitimately +// dereferenced. +template +void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf( + _Rope_iterator_base<_CharT,_Alloc>& __x) { + const _RopeRep* __leaf = __x._M_path_end._M_data[__x._M_leaf_index]; + size_t __leaf_pos = __x._M_leaf_pos; + size_t __pos = __x._M_current_pos; + + switch(__leaf->_M_tag) { + case _RopeRep::_S_leaf: + typedef _Rope_RopeLeaf<_CharT, _Alloc> _RopeLeaf; + __x._M_buf_start = __STATIC_CAST(const _RopeLeaf*, __leaf)->_M_data; + __x._M_buf_ptr = __x._M_buf_start + (__pos - __leaf_pos); + __x._M_buf_end = __x._M_buf_start + __leaf->_M_size._M_data; + break; + case _RopeRep::_S_function: + case _RopeRep::_S_substringfn: + { + size_t __len = _S_iterator_buf_len; + size_t __buf_start_pos = __leaf_pos; + size_t __leaf_end = __leaf_pos + __leaf->_M_size._M_data; + typedef _Rope_RopeFunction<_CharT, _Alloc> _RopeFunction; + char_producer<_CharT>* __fn = __STATIC_CAST(const _RopeFunction*, __leaf)->_M_fn; + + if (__buf_start_pos + __len <= __pos) { + __buf_start_pos = __pos - __len/4; + if (__buf_start_pos + __len > __leaf_end) { + __buf_start_pos = __leaf_end - __len; + } + } + if (__buf_start_pos + __len > __leaf_end) { + __len = __leaf_end - __buf_start_pos; + } + (*__fn)(__buf_start_pos - __leaf_pos, __len, __x._M_tmp_buf._M_data); + __x._M_buf_ptr = __x._M_tmp_buf._M_data + (__pos - __buf_start_pos); + __x._M_buf_start = __x._M_tmp_buf._M_data; + __x._M_buf_end = __x._M_tmp_buf._M_data + __len; + } + break; + default: + _STLP_ASSERT(0) + ; + } +} + +// Set path and buffer inside a rope iterator. We assume that +// pos and root are already set. +template +void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache( + _Rope_iterator_base<_CharT,_Alloc>& __x) { + const _RopeRep* __path[_RopeRep::_S_max_rope_depth+1]; + const _RopeRep* __curr_rope; + int __curr_depth = -1; /* index into path */ + size_t __curr_start_pos = 0; + size_t __pos = __x._M_current_pos; + unsigned char __dirns = 0; // Bit vector marking right turns in the path + + _STLP_ASSERT(__pos <= __x._M_root->_M_size._M_data) + if (__pos >= __x._M_root->_M_size._M_data) { + __x._M_buf_ptr = 0; + return; + } + __curr_rope = __x._M_root; + if (0 != __curr_rope->_M_c_string) { + /* Treat the root as a leaf. */ + __x._M_buf_start = __curr_rope->_M_c_string; + __x._M_buf_end = __curr_rope->_M_c_string + __curr_rope->_M_size._M_data; + __x._M_buf_ptr = __curr_rope->_M_c_string + __pos; + __x._M_path_end._M_data[0] = __curr_rope; + __x._M_leaf_index = 0; + __x._M_leaf_pos = 0; + return; + } + for(;;) { + ++__curr_depth; + _STLP_ASSERT(__curr_depth <= _RopeRep::_S_max_rope_depth) + __path[__curr_depth] = __curr_rope; + switch(__curr_rope->_M_tag) { + case _RopeRep::_S_leaf: + case _RopeRep::_S_function: + case _RopeRep::_S_substringfn: + __x._M_leaf_pos = __curr_start_pos; + goto done; + case _RopeRep::_S_concat: + { + const _RopeConcat* __c = __STATIC_CAST(const _RopeConcat*, __curr_rope); + _RopeRep* __left = __c->_M_left; + size_t __left_len = __left->_M_size._M_data; + + __dirns <<= 1; + if (__pos >= __curr_start_pos + __left_len) { + __dirns |= 1; + __curr_rope = __c->_M_right; + __curr_start_pos += __left_len; + } else { + __curr_rope = __left; + } + } + break; + } + } +done: + // Copy last section of path into _M_path_end. + { + int __i = -1; + int __j = __curr_depth + 1 - _S_path_cache_len; + + if (__j < 0) __j = 0; + while (__j <= __curr_depth) { + __x._M_path_end._M_data[++__i] = __path[__j++]; + } + __x._M_leaf_index = __i; + } + __x._M_path_directions = __dirns; + _S_setbuf(__x); +} + +// Specialized version of the above. Assumes that +// the path cache is valid for the previous position. +template +void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr( +_Rope_iterator_base<_CharT,_Alloc>& __x) { + int __current_index = __x._M_leaf_index; + const _RopeRep* __current_node = __x._M_path_end._M_data[__current_index]; + size_t __len = __current_node->_M_size._M_data; + size_t __node_start_pos = __x._M_leaf_pos; + unsigned char __dirns = __x._M_path_directions; + const _RopeConcat* __c; + + _STLP_ASSERT(__x._M_current_pos <= __x._M_root->_M_size._M_data) + if (__x._M_current_pos - __node_start_pos < __len) { + /* More stuff in this leaf, we just didn't cache it. */ + _S_setbuf(__x); + return; + } + _STLP_ASSERT(__node_start_pos + __len == __x._M_current_pos) + // node_start_pos is starting position of last_node. + while (--__current_index >= 0) { + if (!(__dirns & 1) /* Path turned left */) + break; + __current_node = __x._M_path_end._M_data[__current_index]; + __c = __STATIC_CAST(const _RopeConcat*, __current_node); + // Otherwise we were in the right child. Thus we should pop + // the concatenation node. + __node_start_pos -= __c->_M_left->_M_size._M_data; + __dirns >>= 1; + } + if (__current_index < 0) { + // We underflowed the cache. Punt. + _S_setcache(__x); + return; + } + __current_node = __x._M_path_end._M_data[__current_index]; + __c = __STATIC_CAST(const _RopeConcat*, __current_node); + // current_node is a concatenation node. We are positioned on the first + // character in its right child. + // node_start_pos is starting position of current_node. + __node_start_pos += __c->_M_left->_M_size._M_data; + __current_node = __c->_M_right; + __x._M_path_end._M_data[++__current_index] = __current_node; + __dirns |= 1; + while (_RopeRep::_S_concat == __current_node->_M_tag) { + ++__current_index; + if (_S_path_cache_len == __current_index) { + int __i; + for (__i = 0; __i < _S_path_cache_len-1; ++__i) { + __x._M_path_end._M_data[__i] = __x._M_path_end._M_data[__i+1]; + } + --__current_index; + } + __current_node = __STATIC_CAST(const _RopeConcat*, __current_node)->_M_left; + __x._M_path_end._M_data[__current_index] = __current_node; + __dirns <<= 1; + // node_start_pos is unchanged. + } + __x._M_leaf_index = __current_index; + __x._M_leaf_pos = __node_start_pos; + __x._M_path_directions = __dirns; + _S_setbuf(__x); +} + +template +void _Rope_iterator_base<_CharT,_Alloc>::_M_incr(size_t __n) { + _M_current_pos += __n; + if (0 != _M_buf_ptr) { + size_t __chars_left = _M_buf_end - _M_buf_ptr; + if (__chars_left > __n) { + _M_buf_ptr += __n; + } else if (__chars_left == __n) { + _M_buf_ptr += __n; + _S_setcache_for_incr(*this); + } else { + _M_buf_ptr = 0; + } + } +} + +template +void _Rope_iterator_base<_CharT,_Alloc>::_M_decr(size_t __n) { + if (0 != _M_buf_ptr) { + size_t __chars_left = _M_buf_ptr - _M_buf_start; + if (__chars_left >= __n) { + _M_buf_ptr -= __n; + } else { + _M_buf_ptr = 0; + } + } + _M_current_pos -= __n; +} + +template +void _Rope_iterator<_CharT,_Alloc>::_M_check() { + if (_M_root_rope->_M_tree_ptr._M_data != this->_M_root) { + // _Rope was modified. Get things fixed up. + _RopeRep::_S_unref(this->_M_root); + this->_M_root = _M_root_rope->_M_tree_ptr._M_data; + _RopeRep::_S_ref(this->_M_root); + this->_M_buf_ptr = 0; + } +} + +// There are several reasons for not doing this with virtual destructors +// and a class specific delete operator: +// - A class specific delete operator can't easily get access to +// allocator instances if we need them. +// - Any virtual function would need a 4 or byte vtable pointer; +// this only requires a one byte tag per object. +template +void _Rope_RopeRep<_CharT,_Alloc>::_M_free_tree() { + switch (_M_tag) { + case _S_leaf: + { + typedef _Rope_RopeLeaf<_CharT, _Alloc> _RopeLeaf; + _RopeLeaf* __l = __STATIC_CAST(_RopeLeaf*, this); + _STLP_STD::_Destroy(__l); // ->_Rope_RopeLeaf<_CharT,_Alloc>::~_Rope_RopeLeaf(); + _STLP_CREATE_ALLOCATOR(allocator_type,(const allocator_type&)_M_size, + _RopeLeaf).deallocate(__l, 1); + break; + } + case _S_concat: + { + typedef _Rope_RopeConcatenation<_CharT, _Alloc> _RopeConcatenation; + _RopeConcatenation* __c = __STATIC_CAST(_RopeConcatenation*, this); + _STLP_STD::_Destroy(__c); + _STLP_CREATE_ALLOCATOR(allocator_type,(const allocator_type&)_M_size, + _RopeConcatenation).deallocate(__c, 1); + break; + } + case _S_function: + { + typedef _Rope_RopeFunction<_CharT, _Alloc> _RopeFunction; + _RopeFunction* __f = __STATIC_CAST(_RopeFunction*, this); + _STLP_STD::_Destroy(__f); + _STLP_CREATE_ALLOCATOR(allocator_type, (const allocator_type&)_M_size, + _RopeFunction).deallocate(__f, 1); + break; + } + case _S_substringfn: + { + typedef _Rope_RopeSubstring<_CharT, _Alloc> _RopeSubstring; + _RopeSubstring* __rss = __STATIC_CAST(_RopeSubstring*, this); + _STLP_STD::_Destroy(__rss); + _STLP_CREATE_ALLOCATOR(allocator_type, (const allocator_type&)_M_size, + _RopeSubstring).deallocate(__rss, 1); + break; + } + } +} + +# if defined ( _STLP_NESTED_TYPE_PARAM_BUG ) +# define __RopeLeaf__ _Rope_RopeLeaf<_CharT,_Alloc> +# define __RopeRep__ _Rope_RopeRep<_CharT,_Alloc> +# define _RopeLeaf _Rope_RopeLeaf<_CharT,_Alloc> +# define _RopeRep _Rope_RopeRep<_CharT,_Alloc> +# define size_type size_t +# else +# define __RopeLeaf__ _STLP_TYPENAME_ON_RETURN_TYPE rope<_CharT,_Alloc>::_RopeLeaf +# define __RopeRep__ _STLP_TYPENAME_ON_RETURN_TYPE rope<_CharT,_Alloc>::_RopeRep +# endif + +template +void rope<_CharT, _Alloc>::_M_throw_out_of_range() const { + __stl_throw_out_of_range("rope"); +} + +// Concatenate a C string onto a leaf rope by copying the rope data. +// Used for short ropes. +template +__RopeLeaf__* +rope<_CharT,_Alloc>::_S_leaf_concat_char_iter ( + _RopeLeaf* __r, const _CharT* __iter, size_t __len) { + size_t __old_len = __r->_M_size._M_data; + _CharT* __new_data = __r->_M_size.allocate(_S_rounded_up_size(__old_len + __len)); + _RopeLeaf* __result; + + _STLP_PRIV __ucopy_n(__r->_M_data, __old_len, __new_data); + _STLP_PRIV __ucopy_n(__iter, __len, __new_data + __old_len); + _S_construct_null(__new_data + __old_len + __len); + _STLP_TRY { + __result = _S_new_RopeLeaf(__new_data, __old_len + __len, __r->get_allocator()); + } + _STLP_UNWIND(_RopeRep::_S_free_string(__new_data, __old_len + __len, + __r->get_allocator())) + return __result; +} + +template +void _Terminate_RopeLeaf(_Rope_RopeLeaf<_CharT,_Alloc> *__r, + size_t __size, const __true_type& /*basic char type*/) { + _S_construct_null(__r->_M_data + __size); + _STLP_ASSERT(__r->_M_c_string == __r->_M_data) +} + +template +void _Terminate_RopeLeaf(_Rope_RopeLeaf<_CharT,_Alloc> *__r, + size_t, const __false_type& /*basic char type*/) { + if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string) { + __r->_M_free_c_string(); + __r->_M_c_string = 0; + } +} + +// As above, but it's OK to clobber original if refcount is 1 +template +__RopeLeaf__* +rope<_CharT,_Alloc>::_S_destr_leaf_concat_char_iter (_RopeLeaf* __r, const _CharT* __iter, size_t __len) { + //_STLP_ASSERT(__r->_M_ref_count >= 1) + if ( /* __r->_M_ref_count > 1 */ __r->_M_incr() > 2 ) { // - ptr + __r->_M_decr(); // - ptr + return _S_leaf_concat_char_iter(__r, __iter, __len); + } + __r->_M_decr(); // - ptr, __r->_M_ref_count == 1 or 0 + size_t __old_len = __r->_M_size._M_data; + if (_S_rounded_up_size(__old_len) == _S_rounded_up_size(__old_len + __len)) { + // The space has been partially initialized for the standard + // character types. But that doesn't matter for those types. + _STLP_PRIV __ucopy_n(__iter, __len, __r->_M_data + __old_len); + _Terminate_RopeLeaf(__r, __old_len + __len, _IsBasicCharType()); + __r->_M_size._M_data = __old_len + __len; + // _STLP_ASSERT(__r->_M_ref_count == 1) + // __r->_M_ref_count = 2; + __r->_M_incr(); // i.e. __r->_M_ref_count = 2 + return __r; + } else { + _RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len); + //_STLP_ASSERT(__result->_M_ref_count == 1) + return __result; + } +} + +// Assumes left and right are not 0. +// Does not increment (nor decrement on exception) child reference counts. +// Result has ref count 1. +template +__RopeRep__* +rope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right) { + _RopeConcatenation* __result = + _S_new_RopeConcatenation(__left, __right, __left->get_allocator()); + size_t __depth = __result->_M_depth; + + _STLP_ASSERT(__left->get_allocator() == __right->get_allocator()) + if (__depth > 20 && (__result->_M_size._M_data < 1000 || + __depth > _RopeRep::_S_max_rope_depth)) { + _RopeRep* __balanced; + + _STLP_TRY { + __balanced = _S_balance(__result); + // _STLP_ASSERT(__result == __balanced || + // 1 == __result->_M_ref_count && + // 1 == __balanced->_M_ref_count) + __result->_M_unref_nonnil(); + } + _STLP_UNWIND((_STLP_CREATE_ALLOCATOR(allocator_type,(allocator_type&)__left->_M_size, + _RopeConcatenation).deallocate(__result,1))) + // In case of exception, we need to deallocate + // otherwise dangling result node. But caller + // still owns its children. Thus unref is + // inappropriate. + return __balanced; + } else { + return __result; + } +} + +template +__RopeRep__* +rope<_CharT,_Alloc>::_S_concat_char_iter (_RopeRep* __r, + const _CharT*__s, size_t __slen) { + _RopeRep* __result; + if (0 == __slen) { + _S_ref(__r); + return __r; + } + if (0 == __r) + return _S_RopeLeaf_from_unowned_char_ptr(__s, __slen, __r->get_allocator()); + if (_RopeRep::_S_leaf == __r->_M_tag && + __r->_M_size._M_data + __slen <= _S_copy_max) { + __result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen); + // _STLP_ASSERT(1 == __result->_M_ref_count) + return __result; + } + if (_RopeRep::_S_concat == __r->_M_tag && + _RopeRep::_S_leaf == ((_RopeConcatenation*)__r)->_M_right->_M_tag) { + _RopeLeaf* __right = (_RopeLeaf* )(((_RopeConcatenation* )__r)->_M_right); + if (__right->_M_size._M_data + __slen <= _S_copy_max) { + _RopeRep* __left = ((_RopeConcatenation*)__r)->_M_left; + _RopeRep* __nright = _S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen); + __left->_M_ref_nonnil(); + _STLP_TRY { + __result = _S_tree_concat(__left, __nright); + } + _STLP_UNWIND(_S_unref(__left); _S_unref(__nright)) + // _STLP_ASSERT(1 == __result->_M_ref_count) + return __result; + } + } + _RopeRep* __nright = + _S_RopeLeaf_from_unowned_char_ptr(__s, __slen, __r->get_allocator()); + _STLP_TRY { + __r->_M_ref_nonnil(); + __result = _S_tree_concat(__r, __nright); + } + _STLP_UNWIND(_S_unref(__r); _S_unref(__nright)) + // _STLP_ASSERT(1 == __result->_M_ref_count) + return __result; +} + +template +__RopeRep__* +rope<_CharT,_Alloc>::_S_destr_concat_char_iter( + _RopeRep* __r, const _CharT* __s, size_t __slen) { + _RopeRep* __result; + if (0 == __r) + return _S_RopeLeaf_from_unowned_char_ptr(__s, __slen, + __r->get_allocator()); + // size_t __count = __r->_M_ref_count; + size_t __orig_size = __r->_M_size._M_data; + // _STLP_ASSERT(__count >= 1) + if ( /* __count > 1 */ __r->_M_incr() > 2 ) { + __r->_M_decr(); + return _S_concat_char_iter(__r, __s, __slen); + } + if (0 == __slen) { + return __r; + } + __r->_M_decr(); + if (__orig_size + __slen <= _S_copy_max && _RopeRep::_S_leaf == __r->_M_tag) { + return _S_destr_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen); + } + if (_RopeRep::_S_concat == __r->_M_tag) { + _RopeLeaf* __right = __STATIC_CAST(_RopeLeaf*, __STATIC_CAST(_RopeConcatenation*, __r)->_M_right); + if (_RopeRep::_S_leaf == __right->_M_tag && + __right->_M_size._M_data + __slen <= _S_copy_max) { + _RopeRep* __new_right = _S_destr_leaf_concat_char_iter(__right, __s, __slen); + if (__right == __new_right) { + // _STLP_ASSERT(__new_right->_M_ref_count == 2) + // __new_right->_M_ref_count = 1; + __new_right->_M_decr(); + } else { + // _STLP_ASSERT(__new_right->_M_ref_count >= 1) + __right->_M_unref_nonnil(); + } + // _STLP_ASSERT(__r->_M_ref_count == 1) + // __r->_M_ref_count = 2; // One more than before. + __r->_M_incr(); + __STATIC_CAST(_RopeConcatenation*, __r)->_M_right = __new_right; + // E.Musser : moved below + // __r->_M_size._M_data = __orig_size + __slen; + if (0 != __r->_M_c_string) { + __r->_M_free_c_string(); + __r->_M_c_string = 0; + } + __r->_M_size._M_data = __orig_size + __slen; + return __r; + } + } + _RopeRep* __right = + _S_RopeLeaf_from_unowned_char_ptr(__s, __slen, __r->get_allocator()); + __r->_M_ref_nonnil(); + _STLP_TRY { + __result = _S_tree_concat(__r, __right); + } + _STLP_UNWIND(_S_unref(__r); _S_unref(__right)) + // _STLP_ASSERT(1 == __result->_M_ref_count) + return __result; +} + +template +__RopeRep__* +rope<_CharT,_Alloc>::_S_concat_rep(_RopeRep* __left, _RopeRep* __right) { + if (0 == __left) { + _S_ref(__right); + return __right; + } + if (0 == __right) { + __left->_M_ref_nonnil(); + return __left; + } + if (_RopeRep::_S_leaf == __right->_M_tag) { + if (_RopeRep::_S_leaf == __left->_M_tag) { + if (__right->_M_size._M_data + __left->_M_size._M_data <= _S_copy_max) { + return _S_leaf_concat_char_iter(__STATIC_CAST(_RopeLeaf*, __left), + __STATIC_CAST(_RopeLeaf*, __right)->_M_data, + __right->_M_size._M_data); + } + } else if (_RopeRep::_S_concat == __left->_M_tag && + _RopeRep::_S_leaf == __STATIC_CAST(_RopeConcatenation*, __left)->_M_right->_M_tag) { + _RopeLeaf* __leftright = + __STATIC_CAST(_RopeLeaf*, __STATIC_CAST(_RopeConcatenation*, __left)->_M_right); + if (__leftright->_M_size._M_data + __right->_M_size._M_data <= _S_copy_max) { + _RopeRep* __leftleft = __STATIC_CAST(_RopeConcatenation*, __left)->_M_left; + _RopeRep* __rest = _S_leaf_concat_char_iter(__leftright, + __STATIC_CAST(_RopeLeaf*, __right)->_M_data, + __right->_M_size._M_data); + __leftleft->_M_ref_nonnil(); + _STLP_TRY { + return _S_tree_concat(__leftleft, __rest); + } + _STLP_UNWIND(_S_unref(__leftleft); _S_unref(__rest)) + } + } + } + __left->_M_ref_nonnil(); + __right->_M_ref_nonnil(); + _STLP_TRY { + return _S_tree_concat(__left, __right); + } + _STLP_UNWIND(_S_unref(__left); _S_unref(__right)) + _STLP_RET_AFTER_THROW(0) +} + +template +__RopeRep__* +rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, + size_t __start, size_t __endp1) { + if (0 == __base) return 0; + size_t __len = __base->_M_size._M_data; + size_t __adj_endp1; + const size_t __lazy_threshold = 128; + + if (__endp1 >= __len) { + if (0 == __start) { + __base->_M_ref_nonnil(); + return __base; + } else { + __adj_endp1 = __len; + } + } else { + __adj_endp1 = __endp1; + } + switch(__base->_M_tag) { + case _RopeRep::_S_concat: + { + _RopeConcatenation* __c = __STATIC_CAST(_RopeConcatenation*, __base); + _RopeRep* __left = __c->_M_left; + _RopeRep* __right = __c->_M_right; + size_t __left_len = __left->_M_size._M_data; + _RopeRep* __result; + + if (__adj_endp1 <= __left_len) { + return _S_substring(__left, __start, __endp1); + } else if (__start >= __left_len) { + return _S_substring(__right, __start - __left_len, + __adj_endp1 - __left_len); + } + _Self_destruct_ptr __left_result(_S_substring(__left, __start, __left_len)); + _Self_destruct_ptr __right_result(_S_substring(__right, 0, __endp1 - __left_len)); + _STLP_MPWFIX_TRY //*TY 06/01/2000 - mpw forgets to call dtor on __left_result and __right_result without this try block + __result = _S_concat_rep(__left_result, __right_result); + // _STLP_ASSERT(1 == __result->_M_ref_count) + return __result; + _STLP_MPWFIX_CATCH //*TY 06/01/2000 - + } + case _RopeRep::_S_leaf: + { + _RopeLeaf* __l = __STATIC_CAST(_RopeLeaf*, __base); + _RopeLeaf* __result; + size_t __result_len; + if (__start >= __adj_endp1) return 0; + __result_len = __adj_endp1 - __start; + if (__result_len > __lazy_threshold) goto lazy; + const _CharT* __section = __l->_M_data + __start; + // We should sometimes create substring node instead. + __result = _S_RopeLeaf_from_unowned_char_ptr(__section, __result_len, + __base->get_allocator()); + return __result; + } + case _RopeRep::_S_substringfn: + // Avoid introducing multiple layers of substring nodes. + { + _RopeSubstring* __old = __STATIC_CAST(_RopeSubstring*, __base); + size_t __result_len; + if (__start >= __adj_endp1) return 0; + __result_len = __adj_endp1 - __start; + if (__result_len > __lazy_threshold) { + _RopeSubstring* __result = _S_new_RopeSubstring(__old->_M_base, + __start + __old->_M_start, + __adj_endp1 - __start, + __base->get_allocator()); + return __result; + } // *** else fall through: *** + } + case _RopeRep::_S_function: + { + _RopeFunction* __f = __STATIC_CAST(_RopeFunction*, __base); + if (__start >= __adj_endp1) return 0; + size_t __result_len = __adj_endp1 - __start; + + if (__result_len > __lazy_threshold) goto lazy; + _CharT* __section = __base->_M_size.allocate(_S_rounded_up_size(__result_len)); + _STLP_TRY { + (*(__f->_M_fn))(__start, __result_len, __section); + } + _STLP_UNWIND(_RopeRep::_S_free_string(__section, + __result_len, __base->get_allocator())) + _S_construct_null(__section + __result_len); + return _S_new_RopeLeaf(__section, __result_len, + __base->get_allocator()); + } + } + /*NOTREACHED*/ + _STLP_ASSERT(false) + lazy: + { + // Create substring node. + return _S_new_RopeSubstring(__base, __start, __adj_endp1 - __start, + __base->get_allocator()); + } +} + +template +class _Rope_flatten_char_consumer : public _Rope_char_consumer<_CharT> { +private: + _CharT* _M_buf_ptr; +public: + _Rope_flatten_char_consumer(_CharT* __buffer) { + _M_buf_ptr = __buffer; + } + ~_Rope_flatten_char_consumer() {} + bool operator() (const _CharT* __leaf, size_t __n) { + _STLP_PRIV __ucopy_n(__leaf, __n, _M_buf_ptr); + _M_buf_ptr += __n; + return true; + } +}; + +template +class _Rope_find_char_char_consumer : public _Rope_char_consumer<_CharT> { +private: + _CharT _M_pattern; +public: + size_t _M_count; // Number of nonmatching characters + _Rope_find_char_char_consumer(_CharT __p) + : _M_pattern(__p), _M_count(0) {} + ~_Rope_find_char_char_consumer() {} + bool operator() (const _CharT* __leaf, size_t __n) { + size_t __i; + for (__i = 0; __i < __n; ++__i) { + if (__leaf[__i] == _M_pattern) { + _M_count += __i; return false; + } + } + _M_count += __n; return true; + } +}; + +#if !defined (_STLP_USE_NO_IOSTREAMS) +template +// Here _CharT is both the stream and rope character type. +class _Rope_insert_char_consumer : public _Rope_char_consumer<_CharT> { +private: + typedef basic_ostream<_CharT,_Traits> _Insert_ostream; + typedef _Rope_insert_char_consumer<_CharT,_Traits> _Self; + _Insert_ostream& _M_o; + + //explicitely defined as private to avoid warnings: + _Self& operator = (_Self const&); +public: + _Rope_insert_char_consumer(_Insert_ostream& __writer) + : _M_o(__writer) {} + ~_Rope_insert_char_consumer() {} + // Caller is presumed to own the ostream + bool operator() (const _CharT* __leaf, size_t __n); + // Returns true to continue traversal. +}; + +template +bool _Rope_insert_char_consumer<_CharT, _Traits>::operator() + (const _CharT* __leaf, size_t __n) { + size_t __i; + // We assume that formatting is set up correctly for each element. + for (__i = 0; __i < __n; ++__i) _M_o.put(__leaf[__i]); + return true; +} +#endif /* !_STLP_USE_NO_IOSTREAMS */ + +template +bool _S_apply_to_pieces(_CharConsumer& __c, + _Rope_RopeRep<_CharT, _Alloc> * __r, + size_t __begin, size_t __end) { + typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; + typedef _Rope_RopeConcatenation<_CharT,_Alloc> _RopeConcatenation; + typedef _Rope_RopeLeaf<_CharT,_Alloc> _RopeLeaf; + typedef _Rope_RopeFunction<_CharT,_Alloc> _RopeFunction; + + if (0 == __r) return true; + switch(__r->_M_tag) { + case _RopeRep::_S_concat: + { + _RopeConcatenation* __conc = __STATIC_CAST(_RopeConcatenation*, __r); + _RopeRep* __left = __conc->_M_left; + size_t __left_len = __left->_M_size._M_data; + if (__begin < __left_len) { + size_t __left_end = (min) (__left_len, __end); + if (!_S_apply_to_pieces(__c, __left, __begin, __left_end)) + return false; + } + if (__end > __left_len) { + _RopeRep* __right = __conc->_M_right; + size_t __right_start = (max)(__left_len, __begin); + if (!_S_apply_to_pieces(__c, __right, + __right_start - __left_len, + __end - __left_len)) { + return false; + } + } + } + return true; + case _RopeRep::_S_leaf: + { + _RopeLeaf* __l = __STATIC_CAST(_RopeLeaf*, __r); + return __c(__l->_M_data + __begin, __end - __begin); + } + case _RopeRep::_S_function: + case _RopeRep::_S_substringfn: + { + _RopeFunction* __f = __STATIC_CAST(_RopeFunction*, __r); + size_t __len = __end - __begin; + bool __result; + _CharT* __buffer = __r->get_allocator().allocate(__len); + _STLP_TRY { + (*(__f->_M_fn))(__begin, __len, __buffer); + __result = __c(__buffer, __len); + __r->get_allocator().deallocate(__buffer, __len); + } + _STLP_UNWIND((__r->get_allocator().deallocate(__buffer, __len))) + return __result; + } + default: + _STLP_ASSERT(false) + /*NOTREACHED*/ + return false; + } +} + +#if !defined (_STLP_USE_NO_IOSTREAMS) +template +inline void _Rope_fill(basic_ostream<_CharT, _Traits>& __o, streamsize __n) { + char __f = __o.fill(); + for (streamsize __i = 0; __i < __n; ++__i) __o.put(__f); +} + +template +basic_ostream<_CharT, _Traits>& _S_io_get(basic_ostream<_CharT, _Traits>& __o, + const rope<_CharT, _Alloc>& __r, const __true_type& /*_IsBasicCharType*/) { + streamsize __w = __o.width(); + const bool __left = (__o.flags() & ios::left) != 0; + size_t __rope_len = __r.size(); + _Rope_insert_char_consumer<_CharT, _Traits> __c(__o); + + const bool __need_pad = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __rope_len) < __w)) || + ((sizeof(streamsize) <= sizeof(size_t)) && (__rope_len < __STATIC_CAST(size_t, __w)))); + streamsize __pad_len = __need_pad ? __w - __rope_len : 0; + + if (!__left && __pad_len > 0) { + _Rope_fill(__o, __pad_len); + } + __r.apply_to_pieces(0, __rope_len, __c); + if (__left && __pad_len > 0) { + _Rope_fill(__o, __pad_len); + } + return __o; +} + +template +basic_ostream<_CharT, _Traits>& _S_io_get(basic_ostream<_CharT, _Traits>& __o, + const rope<_CharT, _Alloc>& __r, const __false_type& /*_IsBasicCharType*/) { + streamsize __w = __o.width(); + size_t __rope_len = __r.size(); + _Rope_insert_char_consumer<_CharT, _Traits> __c(__o); + + __o.width(__w /__rope_len); + _STLP_TRY { + __r.apply_to_pieces(0, __rope_len, __c); + __o.width(__w); + } + _STLP_UNWIND(__o.width(__w)) + return __o; +} + +template +basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __o, + const rope<_CharT, _Alloc>& __r) { + typedef typename _IsIntegral<_CharT>::_Ret _Char_Is_Integral; + return _S_io_get(__o, __r, _Char_Is_Integral()); +} +#endif /* NO_IOSTREAMS */ + +template +_CharT* rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, + size_t __start, size_t __len, + _CharT* __buffer) { + _Rope_flatten_char_consumer<_CharT> __c(__buffer); + _S_apply_to_pieces(__c, __r, __start, __start + __len); + return(__buffer + __len); +} + +template +size_t rope<_CharT,_Alloc>::find(_CharT __pattern, size_t __start) const { + _Rope_find_char_char_consumer<_CharT> __c(__pattern); + _S_apply_to_pieces(__c, _M_tree_ptr._M_data, __start, size()); + size_type __result_pos = __start + __c._M_count; +#ifndef _STLP_OLD_ROPE_SEMANTICS + if (__result_pos == size()) __result_pos = npos; +#endif + return __result_pos; +} + +template +_CharT* +rope<_CharT,_Alloc>::_S_flatten(_Rope_RopeRep<_CharT, _Alloc>* __r, _CharT* __buffer) { + if (0 == __r) return __buffer; + switch(__r->_M_tag) { + case _RopeRep::_S_concat: + { + _RopeConcatenation* __c = __STATIC_CAST(_RopeConcatenation*, __r); + _RopeRep* __left = __c->_M_left; + _RopeRep* __right = __c->_M_right; + _CharT* __rest = _S_flatten(__left, __buffer); + return _S_flatten(__right, __rest); + } + case _RopeRep::_S_leaf: + { + _RopeLeaf* __l = __STATIC_CAST(_RopeLeaf*, __r); + return _STLP_PRIV __ucopy_n(__l->_M_data, __l->_M_size._M_data, __buffer).second; + } + case _RopeRep::_S_function: + case _RopeRep::_S_substringfn: + // We dont yet do anything with substring nodes. + // This needs to be fixed before ropefiles will work well. + { + _RopeFunction* __f = __STATIC_CAST(_RopeFunction*, __r); + (*(__f->_M_fn))(0, __f->_M_size._M_data, __buffer); + return __buffer + __f->_M_size._M_data; + } + default: + _STLP_ASSERT(false) + /*NOTREACHED*/ + return 0; + } +} + +#ifdef _STLP_DEBUG +// This needs work for _CharT != char +template +void rope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent) { + for (int __i = 0; __i < __indent; ++__i) putchar(' '); + if (0 == __r) { + printf("NULL\n"); return; + } + if (_RopeRep::_S_concat == __r->_M_tag) { + _RopeConcatenation* __c = __STATIC_CAST(_RopeConcatenation*, __r); + _RopeRep* __left = __c->_M_left; + _RopeRep* __right = __c->_M_right; + printf("Concatenation %p (rc = %ld, depth = %d, len = %ld, %s balanced)\n", + __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size._M_data, + __r->_M_is_balanced? "" : "not"); + _S_dump(__left, __indent + 2); + _S_dump(__right, __indent + 2); + return; + } + else { + const char* __kind; + + switch (__r->_M_tag) { + case _RopeRep::_S_leaf: + __kind = "Leaf"; + break; + case _RopeRep::_S_function: + __kind = "Function"; + break; + case _RopeRep::_S_substringfn: + __kind = "Function representing substring"; + break; + default: + __kind = "(corrupted kind field!)"; + } + printf("%s %p (rc = %ld, depth = %d, len = %ld) ", + __kind, __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size._M_data); + if (sizeof(_CharT) == 1) { + const int __max_len = 40; + _Self_destruct_ptr __prefix(_S_substring(__r, 0, __max_len)); + _CharT __buffer[__max_len + 1]; + bool __too_big = __r->_M_size._M_data > __prefix->_M_size._M_data; + + _S_flatten(__prefix, __buffer); + __buffer[__prefix->_M_size._M_data] = _STLP_DEFAULT_CONSTRUCTED(_CharT); + printf("%s%s\n", (char*)__buffer, __too_big? "...\n" : "\n"); + } else { + printf("\n"); + } + } +} +#endif /* _STLP_DEBUG */ + +# define __ROPE_TABLE_BODY = { \ +/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21, \ +/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377, \ +/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181, \ +/* 18 */6765ul, /* 19 */10946ul, /* 20 */17711ul, /* 21 */28657ul, /* 22 */46368ul, \ +/* 23 */75025ul, /* 24 */121393ul, /* 25 */196418ul, /* 26 */317811ul, \ +/* 27 */514229ul, /* 28 */832040ul, /* 29 */1346269ul, /* 30 */2178309ul, \ +/* 31 */3524578ul, /* 32 */5702887ul, /* 33 */9227465ul, /* 34 */14930352ul, \ +/* 35 */24157817ul, /* 36 */39088169ul, /* 37 */63245986ul, /* 38 */102334155ul, \ +/* 39 */165580141ul, /* 40 */267914296ul, /* 41 */433494437ul, \ +/* 42 */701408733ul, /* 43 */1134903170ul, /* 44 */1836311903ul, \ +/* 45 */2971215073ul } + +template +const unsigned long +rope<_CharT,_Alloc>::_S_min_len[__ROPE_DEPTH_SIZE] __ROPE_TABLE_BODY; +# undef __ROPE_DEPTH_SIZE +# undef __ROPE_MAX_DEPTH +# undef __ROPE_TABLE_BODY + +// These are Fibonacci numbers < 2**32. + +template +__RopeRep__* rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r) { + _RopeRep* __forest[_RopeRep::_S_max_rope_depth + 1] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0}; + _RopeRep* __result = 0; + int __i; + // Invariant: + // The concatenation of forest in descending order is equal to __r. + // __forest[__i]._M_size._M_data >= _S_min_len[__i] + // __forest[__i]._M_depth = __i + // References from forest are included in refcount. + + _STLP_TRY { + _S_add_to_forest(__r, __forest); + for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) + if (0 != __forest[__i]) { + _Self_destruct_ptr __old(__result); + __result = _S_concat_rep(__forest[__i], __result); + __forest[__i]->_M_unref_nonnil(); +# ifdef _STLP_USE_EXCEPTIONS + __forest[__i] = 0; +# endif + } + } + _STLP_UNWIND(for(__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) + _S_unref(__forest[__i])) + if (__result->_M_depth > _RopeRep::_S_max_rope_depth) { + __stl_throw_range_error("rope too long"); + } + return(__result); +} + + +template +void +rope<_CharT,_Alloc>::_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest) +{ + if (__r -> _M_is_balanced) { + _S_add_leaf_to_forest(__r, __forest); + return; + } + _STLP_ASSERT(__r->_M_tag == _RopeRep::_S_concat) + { + _RopeConcatenation* __c = (_RopeConcatenation*)__r; + + _S_add_to_forest(__c->_M_left, __forest); + _S_add_to_forest(__c->_M_right, __forest); + } +} + + +template +void +rope<_CharT,_Alloc>::_S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest) +{ + _RopeRep* __insertee; // included in refcount + _RopeRep* __too_tiny = 0; // included in refcount + int __i; // forest[0..__i-1] is empty + size_t __s = __r->_M_size._M_data; + + for (__i = 0; __s >= _S_min_len[__i+1]/* not this bucket */; ++__i) { + if (0 != __forest[__i]) { + _Self_destruct_ptr __old(__too_tiny); + __too_tiny = _S_concat_and_set_balanced(__forest[__i], __too_tiny); + __forest[__i]->_M_unref_nonnil(); + __forest[__i] = 0; + } + } + { + _Self_destruct_ptr __old(__too_tiny); + __insertee = _S_concat_and_set_balanced(__too_tiny, __r); + } + // Too_tiny dead, and no longer included in refcount. + // Insertee is live and included. + _STLP_ASSERT(_S_is_almost_balanced(__insertee)) + _STLP_ASSERT(__insertee->_M_depth <= __r->_M_depth + 1) + for (;; ++__i) { + if (0 != __forest[__i]) { + _Self_destruct_ptr __old(__insertee); + __insertee = _S_concat_and_set_balanced(__forest[__i], __insertee); + __forest[__i]->_M_unref_nonnil(); + __forest[__i] = 0; + _STLP_ASSERT(_S_is_almost_balanced(__insertee)) + } + _STLP_ASSERT(_S_min_len[__i] <= __insertee->_M_size._M_data) + _STLP_ASSERT(__forest[__i] == 0) + if (__i == _RopeRep::_S_max_rope_depth || + __insertee->_M_size._M_data < _S_min_len[__i+1]) { + __forest[__i] = __insertee; + // refcount is OK since __insertee is now dead. + return; + } + } +} + +template +_CharT +rope<_CharT,_Alloc>::_S_fetch(_RopeRep* __r, size_type __i) +{ + _CharT* __cstr = __r->_M_c_string; + + _STLP_ASSERT(__i < __r->_M_size._M_data) + if (0 != __cstr) return __cstr[__i]; + for(;;) { + switch(__r->_M_tag) { + case _RopeRep::_S_concat: + { + _RopeConcatenation* __c = (_RopeConcatenation*)__r; + _RopeRep* __left = __c->_M_left; + size_t __left_len = __left->_M_size._M_data; + + if (__i >= __left_len) { + __i -= __left_len; + __r = __c->_M_right; + } else { + __r = __left; + } + } + break; + case _RopeRep::_S_leaf: + { + _RopeLeaf* __l = (_RopeLeaf*)__r; + return __l->_M_data[__i]; + } + case _RopeRep::_S_function: + case _RopeRep::_S_substringfn: + { + _RopeFunction* __f = (_RopeFunction*)__r; + _CharT __result; + + (*(__f->_M_fn))(__i, 1, &__result); + return __result; + } + } + } +#if defined(_STLP_NEED_UNREACHABLE_RETURN) + return 0; +#endif +} + +// Return a uniquely referenced character slot for the given +// position, or 0 if that's not possible. +template +_CharT* +rope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i) +{ + _RopeRep* __clrstack[_RopeRep::_S_max_rope_depth]; + size_t __csptr = 0; + + for(;;) { + // if (__r->_M_ref_count > 1) return 0; + if ( __r->_M_incr() > 2 ) { + __r->_M_decr(); + return 0; + } + switch(__r->_M_tag) { + case _RopeRep::_S_concat: + { + _RopeConcatenation* __c = (_RopeConcatenation*)__r; + _RopeRep* __left = __c->_M_left; + size_t __left_len = __left->_M_size._M_data; + + if (__c->_M_c_string != 0) __clrstack[__csptr++] = __c; + if (__i >= __left_len) { + __i -= __left_len; + __r = __c->_M_right; + } else { + __r = __left; + } + } + break; + case _RopeRep::_S_leaf: + { + _RopeLeaf* __l = (_RopeLeaf*)__r; + if (__l->_M_c_string != __l->_M_data && __l->_M_c_string != 0) + __clrstack[__csptr++] = __l; + while (__csptr > 0) { + -- __csptr; + _RopeRep* __d = __clrstack[__csptr]; + __d->_M_free_c_string(); + __d->_M_c_string = 0; + } + return __l->_M_data + __i; + } + case _RopeRep::_S_function: + case _RopeRep::_S_substringfn: + return 0; + } + } +#if defined(_STLP_NEED_UNREACHABLE_RETURN) + return 0; +#endif + +} + +// The following could be implemented trivially using +// lexicographical_compare_3way. +// We do a little more work to avoid dealing with rope iterators for +// flat strings. +template +int +rope<_CharT,_Alloc>::_S_compare (const _RopeRep* __left, + const _RopeRep* __right) { + size_t __left_len; + size_t __right_len; + + if (0 == __right) return 0 != __left; + if (0 == __left) return -1; + __left_len = __left->_M_size._M_data; + __right_len = __right->_M_size._M_data; + if (_RopeRep::_S_leaf == __left->_M_tag) { + const _RopeLeaf* __l = __STATIC_CAST(const _RopeLeaf*, __left); + if (_RopeRep::_S_leaf == __right->_M_tag) { + const _RopeLeaf* __r = __STATIC_CAST(const _RopeLeaf*, __right); + return _STLP_PRIV __lexicographical_compare_3way(__l->_M_data, __l->_M_data + __left_len, + __r->_M_data, __r->_M_data + __right_len); + } + else { + const_iterator __rstart(__right, 0); + const_iterator __rend(__right, __right_len); + return _STLP_PRIV __lexicographical_compare_3way(__l->_M_data, __l->_M_data + __left_len, + __rstart, __rend); + } + } + else { + const_iterator __lstart(__left, 0); + const_iterator __lend(__left, __left_len); + if (_RopeRep::_S_leaf == __right->_M_tag) { + const _RopeLeaf* __r = __STATIC_CAST(const _RopeLeaf*, __right); + return _STLP_PRIV __lexicographical_compare_3way(__lstart, __lend, + __r->_M_data, __r->_M_data + __right_len); + } + else { + const_iterator __rstart(__right, 0); + const_iterator __rend(__right, __right_len); + return _STLP_PRIV __lexicographical_compare_3way(__lstart, __lend, __rstart, __rend); + } + } +} + +// Assignment to reference proxies. +template +_Rope_char_ref_proxy<_CharT, _Alloc>& +_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c) { + _RopeRep* __old = _M_root->_M_tree_ptr._M_data; + // First check for the case in which everything is uniquely + // referenced. In that case we can do this destructively. + _CharT* __ptr = _My_rope::_S_fetch_ptr(__old, _M_pos); + if (0 != __ptr) { + *__ptr = __c; + return *this; + } + _Self_destruct_ptr __left( + _My_rope::_S_substring(__old, 0, _M_pos)); + _Self_destruct_ptr __right( + _My_rope::_S_substring(__old, _M_pos+1, __old->_M_size._M_data)); + _Self_destruct_ptr __result_left( + _My_rope::_S_destr_concat_char_iter(__left, &__c, 1)); + + // _STLP_ASSERT(__left == __result_left || 1 == __result_left->_M_ref_count) + _RopeRep* __result = + _My_rope::_S_concat_rep(__result_left, __right); + // _STLP_ASSERT(1 <= __result->_M_ref_count) + _RopeRep::_S_unref(__old); + _M_root->_M_tree_ptr._M_data = __result; + return *this; +} + +template +_Rope_char_ptr_proxy<_CharT, _Alloc> +_Rope_char_ref_proxy<_CharT, _Alloc>::operator& () const { + return _Rope_char_ptr_proxy<_CharT, _Alloc>(*this); +} + +template +_CharT rope<_CharT,_Alloc>::_S_empty_c_str[1] = { _CharT() }; +// # endif + +#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) +template +const size_t rope<_CharT, _Alloc>::npos; +#endif + +template +const _CharT* rope<_CharT,_Alloc>::c_str() const { + if (0 == _M_tree_ptr._M_data) { + // Possibly redundant, but probably fast. + _S_empty_c_str[0] = _STLP_DEFAULT_CONSTRUCTED(_CharT); + return _S_empty_c_str; + } + _CharT* __old_c_string = _M_tree_ptr._M_data->_M_c_string; + if (0 != __old_c_string) return __old_c_string; + size_t __s = size(); + _CharT* __result = _STLP_CREATE_ALLOCATOR(allocator_type,(const allocator_type&)_M_tree_ptr, _CharT).allocate(__s + 1); + _S_flatten(_M_tree_ptr._M_data, __result); + _S_construct_null(__result + __s); + __old_c_string = __STATIC_CAST(_CharT*, _Atomic_swap_ptr(__REINTERPRET_CAST(void* _STLP_VOLATILE*, &(_M_tree_ptr._M_data->_M_c_string)), + __result)); + if (0 != __old_c_string) { + // It must have been added in the interim. Hence it had to have been + // separately allocated. Deallocate the old copy, since we just + // replaced it. + _STLP_STD::_Destroy_Range(__old_c_string, __old_c_string + __s + 1); + _STLP_CREATE_ALLOCATOR(allocator_type,(const allocator_type&)_M_tree_ptr, _CharT).deallocate(__old_c_string, __s + 1); + } + return __result; +} + +template +const _CharT* rope<_CharT,_Alloc>::replace_with_c_str() { + if (0 == _M_tree_ptr._M_data) { + _S_empty_c_str[0] = _STLP_DEFAULT_CONSTRUCTED(_CharT); + return _S_empty_c_str; + } + _CharT* __old_c_string = _M_tree_ptr._M_data->_M_c_string; + if (_RopeRep::_S_leaf == _M_tree_ptr._M_data->_M_tag && 0 != __old_c_string) { + return __old_c_string; + } + size_t __s = size(); + _CharT* __result = _M_tree_ptr.allocate(_S_rounded_up_size(__s)); + _S_flatten(_M_tree_ptr._M_data, __result); + _S_construct_null(__result + __s); + _M_tree_ptr._M_data->_M_unref_nonnil(); + _M_tree_ptr._M_data = _S_new_RopeLeaf(__result, __s, _M_tree_ptr); + return __result; +} + +// Algorithm specializations. More should be added. + +#if (!defined (_STLP_MSVC) || (_STLP_MSVC >= 1310)) && !defined (__DMC__) +// I couldn't get this to work with VC++ +template +void _Rope_rotate(_Rope_iterator<_CharT,_Alloc> __first, + _Rope_iterator<_CharT,_Alloc> __middle, + _Rope_iterator<_CharT,_Alloc> __last) { + _STLP_ASSERT(__first.container() == __middle.container() && + __middle.container() == __last.container()) + rope<_CharT,_Alloc>& __r(__first.container()); + rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index()); + rope<_CharT,_Alloc> __suffix = + __r.substr(__last.index(), __r.size() - __last.index()); + rope<_CharT,_Alloc> __part1 = + __r.substr(__middle.index(), __last.index() - __middle.index()); + rope<_CharT,_Alloc> __part2 = + __r.substr(__first.index(), __middle.index() - __first.index()); + __r = __prefix; + __r += __part1; + __r += __part2; + __r += __suffix; +} + + +# if 0 +// Probably not useful for several reasons: +// - for SGIs 7.1 compiler and probably some others, +// this forces lots of rope instantiations, creating a +// code bloat and compile time problem. (Fixed in 7.2.) +// - wchar_t is 4 bytes wide on most UNIX platforms, making it unattractive +// for unicode strings. Unsigned short may be a better character +// type. +inline void rotate( + _Rope_iterator > __first, + _Rope_iterator > __middle, + _Rope_iterator > __last) { + _Rope_rotate(__first, __middle, __last); +} +# endif +#endif /* _STLP_MSVC */ + +# undef __RopeLeaf__ +# undef __RopeRep__ +# undef __RopeLeaf +# undef __RopeRep +# undef size_type + +_STLP_END_NAMESPACE + +# endif /* ROPEIMPL_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_rope.h b/sdk/tlibstdcxx/stlport/stl/_rope.h new file mode 100644 index 0000000000..f100f673c8 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_rope.h @@ -0,0 +1,2389 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +// rope<_CharT,_Alloc> is a sequence of _CharT. +// Ropes appear to be mutable, but update operations +// really copy enough of the data structure to leave the original +// valid. Thus ropes can be logically copied by just copying +// a pointer value. + +#ifndef _STLP_INTERNAL_ROPE_H +#define _STLP_INTERNAL_ROPE_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#if !defined (_STLP_USE_NO_IOSTREAMS) && !defined (_STLP_INTERNAL_IOSFWD) +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALGO_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUMERIC_H +# include +#endif + +#ifndef _STLP_INTERNAL_HASH_FUN_H +# include +#endif + +#ifndef _STLP_CHAR_TRAITS_H +# include +#endif + +#ifndef _STLP_INTERNAL_THREADS_H +# include +#endif + +#ifdef _STLP_SGI_THREADS +# include +#endif + +#ifndef _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE +# define _STLP_CREATE_ALLOCATOR(__atype,__a, _Tp) (_Alloc_traits<_Tp,__atype>::create_allocator(__a)) +#else +# define _STLP_CREATE_ALLOCATOR(__atype,__a, _Tp) __stl_alloc_create(__a,(_Tp*)0) +#endif + +_STLP_BEGIN_NAMESPACE + +// First a lot of forward declarations. The standard seems to require +// much stricter "declaration before use" than many of the implementations +// that preceded it. +template) > class rope; +template struct _Rope_RopeConcatenation; +template struct _Rope_RopeRep; +template struct _Rope_RopeLeaf; +template struct _Rope_RopeFunction; +template struct _Rope_RopeSubstring; +template class _Rope_iterator; +template class _Rope_const_iterator; +template class _Rope_char_ref_proxy; +template class _Rope_char_ptr_proxy; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _BasicCharType { typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _BasicCharType { typedef __true_type _Ret; }; + +#ifdef _STLP_HAS_WCHAR_T +_STLP_TEMPLATE_NULL +struct _BasicCharType { typedef __true_type _Ret; }; +#endif + +// Some helpers, so we can use the power algorithm on ropes. +// See below for why this isn't local to the implementation. + +// This uses a nonstandard refcount convention. +// The result has refcount 0. +template +struct _Rope_Concat_fn + : public binary_function, rope<_CharT,_Alloc>, + rope<_CharT,_Alloc> > { + rope<_CharT,_Alloc> operator() (const rope<_CharT,_Alloc>& __x, + const rope<_CharT,_Alloc>& __y) { + return __x + __y; + } +}; + +template +inline +rope<_CharT,_Alloc> +__identity_element(_Rope_Concat_fn<_CharT, _Alloc>) +{ return rope<_CharT,_Alloc>(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +// Store an eos +template +inline void _S_construct_null_aux(_CharT *__p, const __true_type&) +{ *__p = 0; } + +template +inline void _S_construct_null_aux(_CharT *__p, const __false_type&) +{ _STLP_STD::_Construct(__p); } + +template +inline void _S_construct_null(_CharT *__p) { + typedef typename _IsIntegral<_CharT>::_Ret _Char_Is_Integral; + _S_construct_null_aux(__p, _Char_Is_Integral()); +} + +// char_producers are logically functions that generate a section of +// a string. These can be converted to ropes. The resulting rope +// invokes the char_producer on demand. This allows, for example, +// files to be viewed as ropes without reading the entire file. +template +class char_producer { +public: + virtual ~char_producer() {} + virtual void operator()(size_t __start_pos, size_t __len, + _CharT* __buffer) = 0; + // Buffer should really be an arbitrary output iterator. + // That way we could flatten directly into an ostream, etc. + // This is thoroughly impossible, since iterator types don't + // have runtime descriptions. +}; + +// Sequence buffers: +// +// Sequence must provide an append operation that appends an +// array to the sequence. Sequence buffers are useful only if +// appending an entire array is cheaper than appending element by element. +// This is true for many string representations. +// This should perhaps inherit from ostream +// and be implemented correspondingly, so that they can be used +// for formatted. For the sake of portability, we don't do this yet. +// +// For now, sequence buffers behave as output iterators. But they also +// behave a little like basic_ostringstream and a +// little like containers. + +template +// The 3rd parameter works around a common compiler bug. +class sequence_buffer : public iterator { +public: +# ifndef __TYPEDEF_WORKAROUND + typedef typename _Sequence::value_type value_type; + typedef sequence_buffer<_Sequence +# if !(defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) || \ + defined ( _STLP_NO_DEFAULT_NON_TYPE_PARAM )) + , _Buf_sz + > _Self; +# else /* _STLP_NON_TYPE_TMPL_PARAM_BUG */ + > _Self; + enum { _Buf_sz = 100}; +# endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */ + // # endif +# else /* __TYPEDEF_WORKAROUND */ + typedef _V value_type; + typedef sequence_buffer<_Sequence, _Buf_sz, _V> _Self; +# endif /* __TYPEDEF_WORKAROUND */ +protected: + _Sequence* _M_prefix; + value_type _M_buffer[_Buf_sz]; + size_t _M_buf_count; +public: + void flush() { + _M_prefix->append(_M_buffer, _M_buffer + _M_buf_count); + _M_buf_count = 0; + } + ~sequence_buffer() { flush(); } + sequence_buffer() : _M_prefix(0), _M_buf_count(0) {} + sequence_buffer(const _Self& __x) { + _M_prefix = __x._M_prefix; + _M_buf_count = __x._M_buf_count; + _STLP_STD::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); + } + sequence_buffer(_Self& __x) { + __x.flush(); + _M_prefix = __x._M_prefix; + _M_buf_count = 0; + } + sequence_buffer(_Sequence& __s) : _M_prefix(&__s), _M_buf_count(0) {} + _Self& operator= (_Self& __x) { + __x.flush(); + _M_prefix = __x._M_prefix; + _M_buf_count = 0; + return *this; + } + _Self& operator= (const _Self& __x) { + _M_prefix = __x._M_prefix; + _M_buf_count = __x._M_buf_count; + _STLP_STD::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); + return *this; + } + void push_back(value_type __x) { + if (_M_buf_count < _Buf_sz) { + _M_buffer[_M_buf_count] = __x; + ++_M_buf_count; + } else { + flush(); + _M_buffer[0] = __x; + _M_buf_count = 1; + } + } + void append(const value_type *__s, size_t __len) { + if (__len + _M_buf_count <= _Buf_sz) { + size_t __i = _M_buf_count; + size_t __j = 0; + for (; __j < __len; __i++, __j++) { + _M_buffer[__i] = __s[__j]; + } + _M_buf_count += __len; + } else if (0 == _M_buf_count) { + _M_prefix->append(__s, __s + __len); + } else { + flush(); + append(__s, __len); + } + } + _Self& write(const value_type *__s, size_t __len) { + append(__s, __len); + return *this; + } + _Self& put(value_type __x) { + push_back(__x); + return *this; + } + _Self& operator=(const value_type& __rhs) { + push_back(__rhs); + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self& operator++(int) { return *this; } +}; + +// The following should be treated as private, at least for now. +template +class _Rope_char_consumer { +#if !defined (_STLP_MEMBER_TEMPLATES) +public: + //Without member templates we have to use run-time parameterization. + // The symmetry with char_producer is accidental and temporary. + virtual ~_Rope_char_consumer() {} + virtual bool operator()(const _CharT* __buffer, size_t __len) = 0; +#endif +}; + +// +// What follows should really be local to rope. Unfortunately, +// that doesn't work, since it makes it impossible to define generic +// equality on rope iterators. According to the draft standard, the +// template parameters for such an equality operator cannot be inferred +// from the occurence of a member class as a parameter. +// (SGI compilers in fact allow this, but the __result wouldn't be +// portable.) +// Similarly, some of the static member functions are member functions +// only to avoid polluting the global namespace, and to circumvent +// restrictions on type inference for template functions. +// + +// +// The internal data structure for representing a rope. This is +// private to the implementation. A rope is really just a pointer +// to one of these. +// +// A few basic functions for manipulating this data structure +// are members of _RopeRep. Most of the more complex algorithms +// are implemented as rope members. +// +// Some of the static member functions of _RopeRep have identically +// named functions in rope that simply invoke the _RopeRep versions. +// + +template +struct _Rope_RopeRep + : public _Refcount_Base +{ + typedef _Rope_RopeRep<_CharT, _Alloc> _Self; +public: + // + // GAB: 11/09/05 + // + // "__ROPE_DEPTH_SIZE" is set to one more then the "__ROPE_MAX_DEPTH". + // This was originally just an addition of "__ROPE_MAX_DEPTH + 1" + // but this addition causes the sunpro compiler to complain about + // multiple declarations during the initialization of "_S_min_len". + // Changed to be a fixed value and the sunpro compiler appears to + // be happy??? + // +# define __ROPE_MAX_DEPTH 45 +# define __ROPE_DEPTH_SIZE 46 // __ROPE_MAX_DEPTH + 1 + enum { _S_max_rope_depth = __ROPE_MAX_DEPTH }; + enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function}; + // Apparently needed by VC++ + // The data fields of leaves are allocated with some + // extra space, to accomodate future growth and for basic + // character types, to hold a trailing eos character. + enum { _S_alloc_granularity = 8 }; + + _Tag _M_tag:8; + bool _M_is_balanced:8; + + _STLP_FORCE_ALLOCATORS(_CharT, _Alloc) + typedef _Alloc allocator_type; + + allocator_type get_allocator() const { return allocator_type(_M_size); } + + unsigned char _M_depth; + _CharT* _STLP_VOLATILE _M_c_string; + _STLP_PRIV _STLP_alloc_proxy _M_size; + +#ifdef _STLP_NO_ARROW_OPERATOR + _Rope_RopeRep() : _Refcount_Base(1), _M_size(allocator_type(), 0) { +# if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) + _STLP_CHECK_RUNTIME_COMPATIBILITY(); +# endif + } +#endif + + /* Flattened version of string, if needed. */ + /* typically 0. */ + /* If it's not 0, then the memory is owned */ + /* by this node. */ + /* In the case of a leaf, this may point to */ + /* the same memory as the data field. */ + _Rope_RopeRep(_Tag __t, unsigned char __d, bool __b, size_t _p_size, + allocator_type __a) : + _Refcount_Base(1), + _M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0), _M_size(__a, _p_size) { +#if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) + _STLP_CHECK_RUNTIME_COMPATIBILITY(); +#endif + } + + typedef _STLP_TYPENAME _STLP_PRIV _BasicCharType<_CharT>::_Ret _IsBasicCharType; + +#if 0 + /* Please tell why this code is necessary if you uncomment it. + * Problem with it is that rope implementation expect that _S_rounded_up_size(n) + * returns a size > n in order to store the terminating null charater. When + * instanciation type is not a char or wchar_t this is not guaranty resulting in + * memory overrun. + */ + static size_t _S_rounded_up_size_aux(size_t __n, __true_type const& /*_IsBasicCharType*/) { + // Allow slop for in-place expansion. + return (__n + _S_alloc_granularity) & ~(_S_alloc_granularity - 1); + } + + static size_t _S_rounded_up_size_aux(size_t __n, __false_type const& /*_IsBasicCharType*/) { + // Allow slop for in-place expansion. + return (__n + _S_alloc_granularity - 1) & ~(_S_alloc_granularity - 1); + } +#endif + // fbp : moved from RopeLeaf + static size_t _S_rounded_up_size(size_t __n) + //{ return _S_rounded_up_size_aux(__n, _IsBasicCharType()); } + { return (__n + _S_alloc_granularity) & ~(_S_alloc_granularity - 1); } + + static void _S_free_string( _CharT* __s, size_t __len, + allocator_type __a) { + _STLP_STD::_Destroy_Range(__s, __s + __len); + // This has to be a static member, so this gets a bit messy +# ifndef _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE + __a.deallocate(__s, _S_rounded_up_size(__len)); //*ty 03/24/2001 - restored not to use __stl_alloc_rebind() since it is not defined under _STLP_MEMBER_TEMPLATE_CLASSES +# else + __stl_alloc_rebind (__a, (_CharT*)0).deallocate(__s, _S_rounded_up_size(__len)); +# endif + } + + // Deallocate data section of a leaf. + // This shouldn't be a member function. + // But its hard to do anything else at the + // moment, because it's templatized w.r.t. + // an allocator. + // Does nothing if __GC is defined. + void _M_free_c_string(); + void _M_free_tree(); + // Deallocate t. Assumes t is not 0. + void _M_unref_nonnil() { + if (_M_decr() == 0) _M_free_tree(); + } + void _M_ref_nonnil() { + _M_incr(); + } + static void _S_unref(_Self* __t) { + if (0 != __t) { + __t->_M_unref_nonnil(); + } + } + static void _S_ref(_Self* __t) { + if (0 != __t) __t->_M_incr(); + } + //static void _S_free_if_unref(_Self* __t) { + // if (0 != __t && 0 == __t->_M_ref_count) __t->_M_free_tree(); + //} +}; + +template +struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> { +public: + _CharT* _M_data; /* Not necessarily 0 terminated. */ + /* The allocated size is */ + /* _S_rounded_up_size(size), except */ + /* in the GC case, in which it */ + /* doesn't matter. */ +private: + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; + typedef typename _RopeRep::_IsBasicCharType _IsBasicCharType; + void _M_init(__true_type const& /*_IsBasicCharType*/) { + this->_M_c_string = _M_data; + } + void _M_init(__false_type const& /*_IsBasicCharType*/) {} + +public: + _STLP_FORCE_ALLOCATORS(_CharT, _Alloc) + typedef typename _RopeRep::allocator_type allocator_type; + + _Rope_RopeLeaf( _CharT* __d, size_t _p_size, allocator_type __a) + : _Rope_RopeRep<_CharT,_Alloc>(_RopeRep::_S_leaf, 0, true, _p_size, __a), + _M_data(__d) { + _STLP_ASSERT(_p_size > 0) + _M_init(_IsBasicCharType()); + } + +# ifdef _STLP_NO_ARROW_OPERATOR + _Rope_RopeLeaf() {} + _Rope_RopeLeaf(const _Rope_RopeLeaf<_CharT, _Alloc>& ) {} +# endif + +// The constructor assumes that d has been allocated with + // the proper allocator and the properly padded size. + // In contrast, the destructor deallocates the data: + ~_Rope_RopeLeaf() { + if (_M_data != this->_M_c_string) { + this->_M_free_c_string(); + } + _RopeRep::_S_free_string(_M_data, this->_M_size._M_data, this->get_allocator()); + } +}; + +template +struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT, _Alloc> { +private: + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; + +public: + _RopeRep* _M_left; + _RopeRep* _M_right; + _STLP_FORCE_ALLOCATORS(_CharT, _Alloc) + typedef typename _RopeRep::allocator_type allocator_type; + _Rope_RopeConcatenation(_RopeRep* __l, _RopeRep* __r, allocator_type __a) + : _Rope_RopeRep<_CharT,_Alloc>(_RopeRep::_S_concat, + (max)(__l->_M_depth, __r->_M_depth) + 1, false, + __l->_M_size._M_data + __r->_M_size._M_data, __a), _M_left(__l), _M_right(__r) + {} +# ifdef _STLP_NO_ARROW_OPERATOR + _Rope_RopeConcatenation() {} + _Rope_RopeConcatenation(const _Rope_RopeConcatenation<_CharT, _Alloc>&) {} +# endif + + ~_Rope_RopeConcatenation() { + this->_M_free_c_string(); + _M_left->_M_unref_nonnil(); + _M_right->_M_unref_nonnil(); + } +}; + +template +struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT, _Alloc> { +private: + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; +public: + char_producer<_CharT>* _M_fn; + /* + * Char_producer is owned by the + * rope and should be explicitly + * deleted when the rope becomes + * inaccessible. + */ + bool _M_delete_when_done; + _STLP_FORCE_ALLOCATORS(_CharT, _Alloc) + typedef typename _Rope_RopeRep<_CharT,_Alloc>::allocator_type allocator_type; +# ifdef _STLP_NO_ARROW_OPERATOR + _Rope_RopeFunction() {} + _Rope_RopeFunction(const _Rope_RopeFunction<_CharT, _Alloc>& ) {} +# endif + + _Rope_RopeFunction(char_producer<_CharT>* __f, size_t _p_size, + bool __d, allocator_type __a) + : _Rope_RopeRep<_CharT,_Alloc>(_RopeRep::_S_function, 0, true, _p_size, __a), _M_fn(__f) + , _M_delete_when_done(__d) + { _STLP_ASSERT(_p_size > 0) } + + ~_Rope_RopeFunction() { + this->_M_free_c_string(); + if (_M_delete_when_done) { + delete _M_fn; + } + } +}; + +/* + * Substring results are usually represented using just + * concatenation nodes. But in the case of very long flat ropes + * or ropes with a functional representation that isn't practical. + * In that case, we represent the __result as a special case of + * RopeFunction, whose char_producer points back to the rope itself. + * In all cases except repeated substring operations and + * deallocation, we treat the __result as a RopeFunction. + */ +template +struct _Rope_RopeSubstring : public char_producer<_CharT>, public _Rope_RopeFunction<_CharT,_Alloc> { +public: + // XXX this whole class should be rewritten. + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; + _RopeRep *_M_base; // not 0 + size_t _M_start; + /* virtual */ void operator()(size_t __start_pos, size_t __req_len, + _CharT* __buffer) { + typedef _Rope_RopeFunction<_CharT,_Alloc> _RopeFunction; + typedef _Rope_RopeLeaf<_CharT,_Alloc> _RopeLeaf; + switch (_M_base->_M_tag) { + case _RopeRep::_S_function: + case _RopeRep::_S_substringfn: + { + char_producer<_CharT>* __fn = + __STATIC_CAST(_RopeFunction*, _M_base)->_M_fn; + _STLP_ASSERT(__start_pos + __req_len <= this->_M_size._M_data) + _STLP_ASSERT(_M_start + this->_M_size._M_data <= _M_base->_M_size._M_data) + (*__fn)(__start_pos + _M_start, __req_len, __buffer); + } + break; + case _RopeRep::_S_leaf: + { + _CharT* __s = + __STATIC_CAST(_RopeLeaf*, _M_base)->_M_data; + _STLP_PRIV __ucopy_n(__s + __start_pos + _M_start, __req_len, __buffer); + } + break; + default: + _STLP_ASSERT(false) + ; + } + } + + _STLP_FORCE_ALLOCATORS(_CharT, _Alloc) + typedef typename _RopeRep::allocator_type allocator_type; + + _Rope_RopeSubstring(_RopeRep* __b, size_t __s, size_t __l, allocator_type __a) + : _Rope_RopeFunction<_CharT,_Alloc>(this, __l, false, __a), + _M_base(__b), _M_start(__s) { + _STLP_ASSERT(__l > 0) + _STLP_ASSERT(__s + __l <= __b->_M_size._M_data) + _M_base->_M_ref_nonnil(); + this->_M_tag = _RopeRep::_S_substringfn; + } + virtual ~_Rope_RopeSubstring() + { _M_base->_M_unref_nonnil(); } +}; + +/* + * Self-destructing pointers to Rope_rep. + * These are not conventional smart pointers. Their + * only purpose in life is to ensure that unref is called + * on the pointer either at normal exit or if an exception + * is raised. It is the caller's responsibility to + * adjust reference counts when these pointers are initialized + * or assigned to. (This convention significantly reduces + * the number of potentially expensive reference count + * updates.) + */ +template +struct _Rope_self_destruct_ptr { + _Rope_RopeRep<_CharT,_Alloc>* _M_ptr; + ~_Rope_self_destruct_ptr() + { _Rope_RopeRep<_CharT,_Alloc>::_S_unref(_M_ptr); } +# ifdef _STLP_USE_EXCEPTIONS + _Rope_self_destruct_ptr() : _M_ptr(0) {} +# else + _Rope_self_destruct_ptr() {} +# endif + _Rope_self_destruct_ptr(_Rope_RopeRep<_CharT,_Alloc>* __p) : _M_ptr(__p) {} + _Rope_RopeRep<_CharT,_Alloc>& operator*() { return *_M_ptr; } + _Rope_RopeRep<_CharT,_Alloc>* operator->() { return _M_ptr; } + operator _Rope_RopeRep<_CharT,_Alloc>*() { return _M_ptr; } + _Rope_self_destruct_ptr<_CharT, _Alloc>& + operator= (_Rope_RopeRep<_CharT,_Alloc>* __x) + { _M_ptr = __x; return *this; } +}; + +/* + * Dereferencing a nonconst iterator has to return something + * that behaves almost like a reference. It's not possible to + * return an actual reference since assignment requires extra + * work. And we would get into the same problems as with the + * CD2 version of basic_string. + */ +template +class _Rope_char_ref_proxy { + typedef _Rope_char_ref_proxy<_CharT, _Alloc> _Self; + friend class rope<_CharT,_Alloc>; + friend class _Rope_iterator<_CharT,_Alloc>; + friend class _Rope_char_ptr_proxy<_CharT,_Alloc>; + typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr; + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; + typedef rope<_CharT,_Alloc> _My_rope; + size_t _M_pos; + _CharT _M_current; + bool _M_current_valid; + _My_rope* _M_root; // The whole rope. +public: + _Rope_char_ref_proxy(_My_rope* __r, size_t __p) : + _M_pos(__p), _M_current_valid(false), _M_root(__r) {} + _Rope_char_ref_proxy(const _Self& __x) : + _M_pos(__x._M_pos), _M_current_valid(false), _M_root(__x._M_root) {} + // Don't preserve cache if the reference can outlive the + // expression. We claim that's not possible without calling + // a copy constructor or generating reference to a proxy + // reference. We declare the latter to have undefined semantics. + _Rope_char_ref_proxy(_My_rope* __r, size_t __p, _CharT __c) + : _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) {} + inline operator _CharT () const; + _Self& operator= (_CharT __c); + _Rope_char_ptr_proxy<_CharT, _Alloc> operator& () const; + _Self& operator= (const _Self& __c) { + return operator=((_CharT)__c); + } +}; + +#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER +template +inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a, + _Rope_char_ref_proxy <_CharT, __Alloc > __b) { + _CharT __tmp = __a; + __a = __b; + __b = __tmp; +} +#else +// There is no really acceptable way to handle this. The default +// definition of swap doesn't work for proxy references. +// It can't really be made to work, even with ugly hacks, since +// the only unusual operation it uses is the copy constructor, which +// is needed for other purposes. We provide a macro for +// full specializations, and instantiate the most common case. +# define _ROPE_SWAP_SPECIALIZATION(_CharT, __Alloc) \ + inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a, \ + _Rope_char_ref_proxy <_CharT, __Alloc > __b) { \ + _CharT __tmp = __a; \ + __a = __b; \ + __b = __tmp; \ + } + +_ROPE_SWAP_SPECIALIZATION(char, allocator) + +# ifndef _STLP_NO_WCHAR_T +_ROPE_SWAP_SPECIALIZATION(wchar_t, allocator) +# endif + +#endif /* !_STLP_FUNCTION_TMPL_PARTIAL_ORDER */ + +template +class _Rope_char_ptr_proxy { + // XXX this class should be rewritten. +public: + typedef _Rope_char_ptr_proxy<_CharT, _Alloc> _Self; + friend class _Rope_char_ref_proxy<_CharT,_Alloc>; + size_t _M_pos; + rope<_CharT,_Alloc>* _M_root; // The whole rope. + + _Rope_char_ptr_proxy(const _Rope_char_ref_proxy<_CharT,_Alloc>& __x) + : _M_pos(__x._M_pos), _M_root(__x._M_root) {} + _Rope_char_ptr_proxy(const _Self& __x) + : _M_pos(__x._M_pos), _M_root(__x._M_root) {} + _Rope_char_ptr_proxy() {} + _Rope_char_ptr_proxy(_CharT* __x) : _M_pos(0), _M_root(0) { + _STLP_ASSERT(0 == __x) + } + _Self& operator= (const _Self& __x) { + _M_pos = __x._M_pos; + _M_root = __x._M_root; + return *this; + } + + _Rope_char_ref_proxy<_CharT,_Alloc> operator*() const { + return _Rope_char_ref_proxy<_CharT,_Alloc>(_M_root, _M_pos); + } +}; + + +/* + * Rope iterators: + * Unlike in the C version, we cache only part of the stack + * for rope iterators, since they must be efficiently copyable. + * When we run out of cache, we have to reconstruct the iterator + * value. + * Pointers from iterators are not included in reference counts. + * Iterators are assumed to be thread private. Ropes can + * be shared. + */ +template +class _Rope_iterator_base +/* : public random_access_iterator<_CharT, ptrdiff_t> */ +{ + friend class rope<_CharT,_Alloc>; + typedef _Rope_iterator_base<_CharT, _Alloc> _Self; + typedef _Rope_RopeConcatenation<_CharT,_Alloc> _RopeConcat; +public: + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; + + enum { _S_path_cache_len = 4 }; // Must be <= 9 because of _M_path_direction. + enum { _S_iterator_buf_len = 15 }; + size_t _M_current_pos; + // The whole rope. + _RopeRep* _M_root; + // Starting position for current leaf + size_t _M_leaf_pos; + // Buffer possibly containing current char. + _CharT* _M_buf_start; + // Pointer to current char in buffer, != 0 ==> buffer valid. + _CharT* _M_buf_ptr; + // One past __last valid char in buffer. + _CharT* _M_buf_end; + + // What follows is the path cache. We go out of our + // way to make this compact. + // Path_end contains the bottom section of the path from + // the root to the current leaf. + struct { +# if defined (__BORLANDC__) && (__BORLANDC__ < 0x560) + _RopeRep const*_M_data[4]; +# else + _RopeRep const*_M_data[_S_path_cache_len]; +# endif + } _M_path_end; + // Last valid __pos in path_end; + // _M_path_end[0] ... _M_path_end[_M_leaf_index-1] + // point to concatenation nodes. + int _M_leaf_index; + // (_M_path_directions >> __i) & 1 is 1 + // if we got from _M_path_end[leaf_index - __i - 1] + // to _M_path_end[leaf_index - __i] by going to the + // __right. Assumes path_cache_len <= 9. + unsigned char _M_path_directions; + // Short buffer for surrounding chars. + // This is useful primarily for + // RopeFunctions. We put the buffer + // here to avoid locking in the + // multithreaded case. + // The cached path is generally assumed to be valid + // only if the buffer is valid. + struct { +# if defined (__BORLANDC__) && (__BORLANDC__ < 0x560) + _CharT _M_data[15]; +# else + _CharT _M_data[_S_iterator_buf_len]; +# endif + } _M_tmp_buf; + + // Set buffer contents given path cache. + static void _S_setbuf(_Rope_iterator_base<_CharT, _Alloc>& __x); + // Set buffer contents and path cache. + static void _S_setcache(_Rope_iterator_base<_CharT, _Alloc>& __x); + // As above, but assumes path cache is valid for previous posn. + static void _S_setcache_for_incr(_Rope_iterator_base<_CharT, _Alloc>& __x); + _Rope_iterator_base() {} + _Rope_iterator_base(_RopeRep* __root, size_t __pos) + : _M_current_pos(__pos),_M_root(__root), _M_buf_ptr(0) {} + void _M_incr(size_t __n); + void _M_decr(size_t __n); +public: + size_t index() const { return _M_current_pos; } +private: + void _M_copy_buf(const _Self& __x) { + _M_tmp_buf = __x._M_tmp_buf; + if (__x._M_buf_start == __x._M_tmp_buf._M_data) { + _M_buf_start = _M_tmp_buf._M_data; + _M_buf_end = _M_buf_start + (__x._M_buf_end - __x._M_buf_start); + _M_buf_ptr = _M_buf_start + (__x._M_buf_ptr - __x._M_buf_start); + } else { + _M_buf_end = __x._M_buf_end; + } + } + +public: + _Rope_iterator_base(const _Self& __x) : + _M_current_pos(__x._M_current_pos), + _M_root(__x._M_root), + _M_leaf_pos( __x._M_leaf_pos ), + _M_buf_start(__x._M_buf_start), + _M_buf_ptr(__x._M_buf_ptr), + _M_path_end(__x._M_path_end), + _M_leaf_index(__x._M_leaf_index), + _M_path_directions(__x._M_path_directions) + { + if (0 != __x._M_buf_ptr) { + _M_copy_buf(__x); + } + } + _Self& operator = (const _Self& __x) + { + _M_current_pos = __x._M_current_pos; + _M_root = __x._M_root; + _M_buf_start = __x._M_buf_start; + _M_buf_ptr = __x._M_buf_ptr; + _M_path_end = __x._M_path_end; + _M_leaf_index = __x._M_leaf_index; + _M_path_directions = __x._M_path_directions; + _M_leaf_pos = __x._M_leaf_pos; + if (0 != __x._M_buf_ptr) { + _M_copy_buf(__x); + } + return *this; + } +}; + +template class _Rope_iterator; + +template +class _Rope_const_iterator : public _Rope_iterator_base<_CharT,_Alloc> { + friend class rope<_CharT,_Alloc>; + typedef _Rope_const_iterator<_CharT, _Alloc> _Self; + typedef _Rope_iterator_base<_CharT,_Alloc> _Base; + // protected: +public: +# ifndef _STLP_HAS_NO_NAMESPACES + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; + // The one from the base class may not be directly visible. +# endif + _Rope_const_iterator(const _RopeRep* __root, size_t __pos): + _Rope_iterator_base<_CharT,_Alloc>(__CONST_CAST(_RopeRep*,__root), __pos) + // Only nonconst iterators modify root ref count + {} +public: + typedef _CharT reference; // Really a value. Returning a reference + // Would be a mess, since it would have + // to be included in refcount. + typedef const _CharT* pointer; + typedef _CharT value_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag iterator_category; + +public: + _Rope_const_iterator() {} + _Rope_const_iterator(const _Self& __x) : + _Rope_iterator_base<_CharT,_Alloc>(__x) { } + _Rope_const_iterator(const _Rope_iterator<_CharT,_Alloc>& __x): + _Rope_iterator_base<_CharT,_Alloc>(__x) {} + _Rope_const_iterator(const rope<_CharT,_Alloc>& __r, size_t __pos) : + _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr._M_data, __pos) {} + _Self& operator= (const _Self& __x) { + _Base::operator=(__x); + return *this; + } + reference operator*() { + if (0 == this->_M_buf_ptr) +#if !defined (__DMC__) + _S_setcache(*this); +#else + { _Rope_iterator_base<_CharT, _Alloc>* __x = this; _S_setcache(*__x); } +#endif + return *(this->_M_buf_ptr); + } + _Self& operator++() + { + if ( this->_M_buf_ptr != 0 ) { + _CharT *__next = this->_M_buf_ptr + 1; + if ( __next < this->_M_buf_end ) { + this->_M_buf_ptr = __next; + ++this->_M_current_pos; + return *this; + } + } + this->_M_incr(1); + return *this; + } + _Self& operator+=(ptrdiff_t __n) { + if (__n >= 0) { + this->_M_incr(__n); + } else { + this->_M_decr(-__n); + } + return *this; + } + _Self& operator--() { + this->_M_decr(1); + return *this; + } + _Self& operator-=(ptrdiff_t __n) { + if (__n >= 0) { + this->_M_decr(__n); + } else { + this->_M_incr(-__n); + } + return *this; + } + _Self operator++(int) { + size_t __old_pos = this->_M_current_pos; + this->_M_incr(1); + return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos); + // This makes a subsequent dereference expensive. + // Perhaps we should instead copy the iterator + // if it has a valid cache? + } + _Self operator--(int) { + size_t __old_pos = this->_M_current_pos; + this->_M_decr(1); + return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos); + } + inline reference operator[](size_t __n); +}; + +template +class _Rope_iterator : public _Rope_iterator_base<_CharT,_Alloc> { + friend class rope<_CharT,_Alloc>; + typedef _Rope_iterator<_CharT, _Alloc> _Self; + typedef _Rope_iterator_base<_CharT,_Alloc> _Base; + typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep; + +public: + rope<_CharT,_Alloc>* _M_root_rope; + // root is treated as a cached version of this, + // and is used to detect changes to the underlying + // rope. + // Root is included in the reference count. + // This is necessary so that we can detect changes reliably. + // Unfortunately, it requires careful bookkeeping for the + // nonGC case. + _Rope_iterator(rope<_CharT,_Alloc>* __r, size_t __pos); + + void _M_check(); +public: + typedef _Rope_char_ref_proxy<_CharT,_Alloc> reference; + typedef _Rope_char_ref_proxy<_CharT,_Alloc>* pointer; + typedef _CharT value_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag iterator_category; +public: + ~_Rope_iterator() { //*TY 5/6/00 - added dtor to balance reference count + _RopeRep::_S_unref(this->_M_root); + } + + rope<_CharT,_Alloc>& container() { return *_M_root_rope; } + _Rope_iterator() { + this->_M_root = 0; // Needed for reference counting. + } + _Rope_iterator(const _Self& __x) : + _Rope_iterator_base<_CharT,_Alloc>(__x) { + _M_root_rope = __x._M_root_rope; + _RopeRep::_S_ref(this->_M_root); + } + _Rope_iterator(rope<_CharT,_Alloc>& __r, size_t __pos); + _Self& operator= (const _Self& __x) { + _RopeRep* __old = this->_M_root; + _RopeRep::_S_ref(__x._M_root); + _Base::operator=(__x); + _M_root_rope = __x._M_root_rope; + _RopeRep::_S_unref(__old); + return *this; + } + reference operator*() { + _M_check(); + if (0 == this->_M_buf_ptr) { + return reference(_M_root_rope, this->_M_current_pos); + } else { + return reference(_M_root_rope, this->_M_current_pos, *(this->_M_buf_ptr)); + } + } + _Self& operator++() { + this->_M_incr(1); + return *this; + } + _Self& operator+=(ptrdiff_t __n) { + if (__n >= 0) { + this->_M_incr(__n); + } else { + this->_M_decr(-__n); + } + return *this; + } + _Self& operator--() { + this->_M_decr(1); + return *this; + } + _Self& operator-=(ptrdiff_t __n) { + if (__n >= 0) { + this->_M_decr(__n); + } else { + this->_M_incr(-__n); + } + return *this; + } + _Self operator++(int) { + size_t __old_pos = this->_M_current_pos; + this->_M_incr(1); + return _Self(_M_root_rope, __old_pos); + } + _Self operator--(int) { + size_t __old_pos = this->_M_current_pos; + this->_M_decr(1); + return _Self(_M_root_rope, __old_pos); + } + reference operator[](ptrdiff_t __n) { + return reference(_M_root_rope, this->_M_current_pos + __n); + } +}; + +# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES +template +inline random_access_iterator_tag +iterator_category(const _Rope_iterator<_CharT,_Alloc>&) { return random_access_iterator_tag();} +template +inline _CharT* value_type(const _Rope_iterator<_CharT,_Alloc>&) { return 0; } +template +inline ptrdiff_t* distance_type(const _Rope_iterator<_CharT,_Alloc>&) { return 0; } +template +inline random_access_iterator_tag +iterator_category(const _Rope_const_iterator<_CharT,_Alloc>&) { return random_access_iterator_tag(); } +template +inline _CharT* value_type(const _Rope_const_iterator<_CharT,_Alloc>&) { return 0; } +template +inline ptrdiff_t* distance_type(const _Rope_const_iterator<_CharT,_Alloc>&) { return 0; } +#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */ + +template +bool _S_apply_to_pieces(_CharConsumer& __c, + _Rope_RopeRep<_CharT, _Alloc> *__r, + size_t __begin, size_t __end); + // begin and end are assumed to be in range. + +template +class rope +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef rope<_CharT,_Alloc> _Self; +public: + typedef _CharT value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef _CharT const_reference; + typedef const _CharT* const_pointer; + typedef _Rope_iterator<_CharT,_Alloc> iterator; + typedef _Rope_const_iterator<_CharT,_Alloc> const_iterator; + typedef _Rope_char_ref_proxy<_CharT,_Alloc> reference; + typedef _Rope_char_ptr_proxy<_CharT,_Alloc> pointer; + + friend class _Rope_iterator<_CharT,_Alloc>; + friend class _Rope_const_iterator<_CharT,_Alloc>; + friend struct _Rope_RopeRep<_CharT,_Alloc>; + friend class _Rope_iterator_base<_CharT,_Alloc>; + friend class _Rope_char_ptr_proxy<_CharT,_Alloc>; + friend class _Rope_char_ref_proxy<_CharT,_Alloc>; + friend struct _Rope_RopeSubstring<_CharT,_Alloc>; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +protected: + typedef _CharT* _Cstrptr; + + static _CharT _S_empty_c_str[1]; + + enum { _S_copy_max = 23 }; + // For strings shorter than _S_copy_max, we copy to + // concatenate. + + typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep; + typedef typename _RopeRep::_IsBasicCharType _IsBasicCharType; + +public: + _STLP_FORCE_ALLOCATORS(_CharT, _Alloc) + typedef _Alloc allocator_type; + +public: + // The only data member of a rope: + _STLP_PRIV _STLP_alloc_proxy<_RopeRep*, _CharT, allocator_type> _M_tree_ptr; + +public: + allocator_type get_allocator() const { return allocator_type(_M_tree_ptr); } + +public: + typedef _Rope_RopeConcatenation<_CharT,_Alloc> _RopeConcatenation; + typedef _Rope_RopeLeaf<_CharT,_Alloc> _RopeLeaf; + typedef _Rope_RopeFunction<_CharT,_Alloc> _RopeFunction; + typedef _Rope_RopeSubstring<_CharT,_Alloc> _RopeSubstring; + + // Retrieve a character at the indicated position. + static _CharT _S_fetch(_RopeRep* __r, size_type __pos); + + // Obtain a pointer to the character at the indicated position. + // The pointer can be used to change the character. + // If such a pointer cannot be produced, as is frequently the + // case, 0 is returned instead. + // (Returns nonzero only if all nodes in the path have a refcount + // of 1.) + static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos); + + static void _S_unref(_RopeRep* __t) { + _RopeRep::_S_unref(__t); + } + static void _S_ref(_RopeRep* __t) { + _RopeRep::_S_ref(__t); + } + + typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr; + + // _Result is counted in refcount. + static _RopeRep* _S_substring(_RopeRep* __base, + size_t __start, size_t __endp1); + + static _RopeRep* _S_concat_char_iter(_RopeRep* __r, + const _CharT* __iter, size_t __slen); + // Concatenate rope and char ptr, copying __s. + // Should really take an arbitrary iterator. + // Result is counted in refcount. + static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r, + const _CharT* __iter, size_t __slen); + // As above, but one reference to __r is about to be + // destroyed. Thus the pieces may be recycled if all + // relevent reference counts are 1. + + // General concatenation on _RopeRep. _Result + // has refcount of 1. Adjusts argument refcounts. + static _RopeRep* _S_concat_rep(_RopeRep* __left, _RopeRep* __right); + +public: +#if defined (_STLP_MEMBER_TEMPLATES) + template +#else + typedef _Rope_char_consumer<_CharT> _CharConsumer; +#endif + void apply_to_pieces(size_t __begin, size_t __end, + _CharConsumer& __c) const + { _S_apply_to_pieces(__c, _M_tree_ptr._M_data, __begin, __end); } + +protected: + + static size_t _S_rounded_up_size(size_t __n) + { return _RopeRep::_S_rounded_up_size(__n); } + + // Allocate and construct a RopeLeaf using the supplied allocator + // Takes ownership of s instead of copying. + static _RopeLeaf* _S_new_RopeLeaf(_CharT *__s, + size_t _p_size, allocator_type __a) { + _RopeLeaf* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a, + _RopeLeaf).allocate(1); + _STLP_TRY { + new(__space) _RopeLeaf(__s, _p_size, __a); + } + _STLP_UNWIND(_STLP_CREATE_ALLOCATOR(allocator_type,__a, + _RopeLeaf).deallocate(__space, 1)) + return __space; + } + + static _RopeConcatenation* _S_new_RopeConcatenation(_RopeRep* __left, _RopeRep* __right, + allocator_type __a) { + _RopeConcatenation* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a, + _RopeConcatenation).allocate(1); + return new(__space) _RopeConcatenation(__left, __right, __a); + } + + static _RopeFunction* _S_new_RopeFunction(char_producer<_CharT>* __f, + size_t _p_size, bool __d, allocator_type __a) { + _RopeFunction* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a, + _RopeFunction).allocate(1); + return new(__space) _RopeFunction(__f, _p_size, __d, __a); + } + + static _RopeSubstring* _S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s, + size_t __l, allocator_type __a) { + _RopeSubstring* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a, + _RopeSubstring).allocate(1); + return new(__space) _RopeSubstring(__b, __s, __l, __a); + } + + static + _RopeLeaf* _S_RopeLeaf_from_unowned_char_ptr(const _CharT *__s, + size_t _p_size, allocator_type __a) { + if (0 == _p_size) return 0; + + _CharT* __buf = _STLP_CREATE_ALLOCATOR(allocator_type,__a, _CharT).allocate(_S_rounded_up_size(_p_size)); + + _STLP_PRIV __ucopy_n(__s, _p_size, __buf); + _S_construct_null(__buf + _p_size); + + _STLP_TRY { + return _S_new_RopeLeaf(__buf, _p_size, __a); + } + _STLP_UNWIND(_RopeRep::_S_free_string(__buf, _p_size, __a)) + _STLP_RET_AFTER_THROW(0) + } + + + // Concatenation of nonempty strings. + // Always builds a concatenation node. + // Rebalances if the result is too deep. + // Result has refcount 1. + // Does not increment left and right ref counts even though + // they are referenced. + static _RopeRep* + _S_tree_concat(_RopeRep* __left, _RopeRep* __right); + + // Concatenation helper functions + static _RopeLeaf* + _S_leaf_concat_char_iter(_RopeLeaf* __r, + const _CharT* __iter, size_t __slen); + // Concatenate by copying leaf. + // should take an arbitrary iterator + // result has refcount 1. + static _RopeLeaf* _S_destr_leaf_concat_char_iter + (_RopeLeaf* __r, const _CharT* __iter, size_t __slen); + // A version that potentially clobbers __r if __r->_M_ref_count == 1. + + + // A helper function for exponentiating strings. + // This uses a nonstandard refcount convention. + // The result has refcount 0. + typedef _STLP_PRIV _Rope_Concat_fn<_CharT,_Alloc> _Concat_fn; +#if !defined (__GNUC__) || (__GNUC__ < 3) + friend _Concat_fn; +#else + friend struct _STLP_PRIV _Rope_Concat_fn<_CharT,_Alloc>; +#endif + +public: + static size_t _S_char_ptr_len(const _CharT* __s) { + return char_traits<_CharT>::length(__s); + } + +public: /* for operators */ + rope(_RopeRep* __t, const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, __t) { } +private: + // Copy __r to the _CharT buffer. + // Returns __buffer + __r->_M_size._M_data. + // Assumes that buffer is uninitialized. + static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer); + + // Again, with explicit starting position and length. + // Assumes that buffer is uninitialized. + static _CharT* _S_flatten(_RopeRep* __r, + size_t __start, size_t __len, + _CharT* __buffer); + + // fbp : HP aCC prohibits access to protected min_len from within static methods ( ?? ) +public: + static const unsigned long _S_min_len[__ROPE_DEPTH_SIZE]; +protected: + static bool _S_is_balanced(_RopeRep* __r) + { return (__r->_M_size._M_data >= _S_min_len[__r->_M_depth]); } + + static bool _S_is_almost_balanced(_RopeRep* __r) { + return (__r->_M_depth == 0 || + __r->_M_size._M_data >= _S_min_len[__r->_M_depth - 1]); + } + + static bool _S_is_roughly_balanced(_RopeRep* __r) { + return (__r->_M_depth <= 1 || + __r->_M_size._M_data >= _S_min_len[__r->_M_depth - 2]); + } + + // Assumes the result is not empty. + static _RopeRep* _S_concat_and_set_balanced(_RopeRep* __left, + _RopeRep* __right) { + _RopeRep* __result = _S_concat_rep(__left, __right); + if (_S_is_balanced(__result)) __result->_M_is_balanced = true; + return __result; + } + + // The basic rebalancing operation. Logically copies the + // rope. The result has refcount of 1. The client will + // usually decrement the reference count of __r. + // The result is within height 2 of balanced by the above + // definition. + static _RopeRep* _S_balance(_RopeRep* __r); + + // Add all unbalanced subtrees to the forest of balanceed trees. + // Used only by balance. + static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest); + + // Add __r to forest, assuming __r is already balanced. + static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest); + +#ifdef _STLP_DEBUG + // Print to stdout, exposing structure + static void _S_dump(_RopeRep* __r, int __indent = 0); +#endif + + // Return -1, 0, or 1 if __x < __y, __x == __y, or __x > __y resp. + static int _S_compare(const _RopeRep* __x, const _RopeRep* __y); + + void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const; + + void _M_reset(_RopeRep* __r) { + //if (__r != _M_tree_ptr._M_data) { + _S_unref(_M_tree_ptr._M_data); + _M_tree_ptr._M_data = __r; + //} + } + +public: + bool empty() const { return 0 == _M_tree_ptr._M_data; } + + // Comparison member function. This is public only for those + // clients that need a ternary comparison. Others + // should use the comparison operators below. + int compare(const _Self& __y) const { + return _S_compare(_M_tree_ptr._M_data, __y._M_tree_ptr._M_data); + } + + rope(const _CharT* __s, const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, _S_RopeLeaf_from_unowned_char_ptr(__s, _S_char_ptr_len(__s),__a)) + {} + + rope(const _CharT* __s, size_t __len, + const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, (_S_RopeLeaf_from_unowned_char_ptr(__s, __len, __a))) + {} + + // Should perhaps be templatized with respect to the iterator type + // and use Sequence_buffer. (It should perhaps use sequence_buffer + // even now.) + rope(const _CharT *__s, const _CharT *__e, + const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, _S_RopeLeaf_from_unowned_char_ptr(__s, __e - __s, __a)) + {} + + rope(const const_iterator& __s, const const_iterator& __e, + const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, _S_substring(__s._M_root, __s._M_current_pos, + __e._M_current_pos)) + {} + + rope(const iterator& __s, const iterator& __e, + const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, _S_substring(__s._M_root, __s._M_current_pos, + __e._M_current_pos)) + {} + + rope(_CharT __c, const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, (_RopeRep*)0) { + _CharT* __buf = _M_tree_ptr.allocate(_S_rounded_up_size(1)); + + _Copy_Construct(__buf, __c); + _S_construct_null(__buf + 1); + + _STLP_TRY { + _M_tree_ptr._M_data = _S_new_RopeLeaf(__buf, 1, __a); + } + _STLP_UNWIND(_RopeRep::_S_free_string(__buf, 1, __a)) + } + + rope(size_t __n, _CharT __c, + const allocator_type& __a = allocator_type()): + _M_tree_ptr(__a, (_RopeRep*)0) { + if (0 == __n) + return; + + rope<_CharT,_Alloc> __result; +# define __exponentiate_threshold size_t(32) + _RopeRep* __remainder; + rope<_CharT,_Alloc> __remainder_rope; + + // gcc-2.7.2 bugs + typedef _STLP_PRIV _Rope_Concat_fn<_CharT,_Alloc> _Concat_fn; + + size_t __exponent = __n / __exponentiate_threshold; + size_t __rest = __n % __exponentiate_threshold; + if (0 == __rest) { + __remainder = 0; + } else { + _CharT* __rest_buffer = _M_tree_ptr.allocate(_S_rounded_up_size(__rest)); + uninitialized_fill_n(__rest_buffer, __rest, __c); + _S_construct_null(__rest_buffer + __rest); + _STLP_TRY { + __remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a); + } + _STLP_UNWIND(_RopeRep::_S_free_string(__rest_buffer, __rest, __a)) + } + __remainder_rope._M_tree_ptr._M_data = __remainder; + if (__exponent != 0) { + _CharT* __base_buffer = _M_tree_ptr.allocate(_S_rounded_up_size(__exponentiate_threshold)); + _RopeLeaf* __base_leaf; + rope<_CharT,_Alloc> __base_rope; + uninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c); + _S_construct_null(__base_buffer + __exponentiate_threshold); + _STLP_TRY { + __base_leaf = _S_new_RopeLeaf(__base_buffer, + __exponentiate_threshold, __a); + } + _STLP_UNWIND(_RopeRep::_S_free_string(__base_buffer, + __exponentiate_threshold, __a)) + __base_rope._M_tree_ptr._M_data = __base_leaf; + if (1 == __exponent) { + __result = __base_rope; + // One each for base_rope and __result + //_STLP_ASSERT(2 == __result._M_tree_ptr._M_data->_M_ref_count) + } else { + __result = _STLP_PRIV __power(__base_rope, __exponent, _Concat_fn()); + } + if (0 != __remainder) { + __result += __remainder_rope; + } + } else { + __result = __remainder_rope; + } + _M_tree_ptr._M_data = __result._M_tree_ptr._M_data; + _M_tree_ptr._M_data->_M_ref_nonnil(); +# undef __exponentiate_threshold + } + + rope(const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, (_RopeRep*)0) {} + + // Construct a rope from a function that can compute its members + rope(char_producer<_CharT> *__fn, size_t __len, bool __delete_fn, + const allocator_type& __a = allocator_type()) + : _M_tree_ptr(__a, (_RopeRep*)0) { + _M_tree_ptr._M_data = (0 == __len) ? + 0 : _S_new_RopeFunction(__fn, __len, __delete_fn, __a); + } + + rope(const _Self& __x) + : _M_tree_ptr(__x._M_tree_ptr, __x._M_tree_ptr._M_data) { + _S_ref(_M_tree_ptr._M_data); + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + rope(__move_source<_Self> __src) + : _M_tree_ptr(__src.get()._M_tree_ptr, __src.get()._M_tree_ptr._M_data) { + __src.get()._M_tree_ptr._M_data = 0; + } +#endif + + ~rope() { + _S_unref(_M_tree_ptr._M_data); + } + + _Self& operator=(const _Self& __x) { + _STLP_ASSERT(get_allocator() == __x.get_allocator()) + _S_ref(__x._M_tree_ptr._M_data); + _M_reset(__x._M_tree_ptr._M_data); + return *this; + } + + void clear() { + _S_unref(_M_tree_ptr._M_data); + _M_tree_ptr._M_data = 0; + } + void push_back(_CharT __x) { + _M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, &__x, 1)); + } + + void pop_back() { + _RopeRep* __old = _M_tree_ptr._M_data; + _M_tree_ptr._M_data = + _S_substring(_M_tree_ptr._M_data, 0, _M_tree_ptr._M_data->_M_size._M_data - 1); + _S_unref(__old); + } + + _CharT back() const { + return _S_fetch(_M_tree_ptr._M_data, _M_tree_ptr._M_data->_M_size._M_data - 1); + } + + void push_front(_CharT __x) { + _RopeRep* __old = _M_tree_ptr._M_data; + _RopeRep* __left = + _S_RopeLeaf_from_unowned_char_ptr(&__x, 1, _M_tree_ptr); + _STLP_TRY { + _M_tree_ptr._M_data = _S_concat_rep(__left, _M_tree_ptr._M_data); + _S_unref(__old); + _S_unref(__left); + } + _STLP_UNWIND(_S_unref(__left)) + } + + void pop_front() { + _RopeRep* __old = _M_tree_ptr._M_data; + _M_tree_ptr._M_data = _S_substring(_M_tree_ptr._M_data, 1, _M_tree_ptr._M_data->_M_size._M_data); + _S_unref(__old); + } + + _CharT front() const { + return _S_fetch(_M_tree_ptr._M_data, 0); + } + + void balance() { + _RopeRep* __old = _M_tree_ptr._M_data; + _M_tree_ptr._M_data = _S_balance(_M_tree_ptr._M_data); + _S_unref(__old); + } + + void copy(_CharT* __buffer) const { + _STLP_STD::_Destroy_Range(__buffer, __buffer + size()); + _S_flatten(_M_tree_ptr._M_data, __buffer); + } + + /* + * This is the copy function from the standard, but + * with the arguments reordered to make it consistent with the + * rest of the interface. + * Note that this guaranteed not to compile if the draft standard + * order is assumed. + */ + size_type copy(size_type __pos, size_type __n, _CharT* __buffer) const { + size_t _p_size = size(); + size_t __len = (__pos + __n > _p_size? _p_size - __pos : __n); + + _STLP_STD::_Destroy_Range(__buffer, __buffer + __len); + _S_flatten(_M_tree_ptr._M_data, __pos, __len, __buffer); + return __len; + } + +# ifdef _STLP_DEBUG + // Print to stdout, exposing structure. May be useful for + // performance debugging. + void dump() { + _S_dump(_M_tree_ptr._M_data); + } +# endif + + // Convert to 0 terminated string in new allocated memory. + // Embedded 0s in the input do not terminate the copy. + const _CharT* c_str() const; + + // As above, but also use the flattened representation as the + // the new rope representation. + const _CharT* replace_with_c_str(); + + // Reclaim memory for the c_str generated flattened string. + // Intentionally undocumented, since it's hard to say when this + // is safe for multiple threads. + void delete_c_str () { + if (0 == _M_tree_ptr._M_data) return; + if (_RopeRep::_S_leaf == _M_tree_ptr._M_data->_M_tag && + ((_RopeLeaf*)_M_tree_ptr._M_data)->_M_data == + _M_tree_ptr._M_data->_M_c_string) { + // Representation shared + return; + } + _M_tree_ptr._M_data->_M_free_c_string(); + _M_tree_ptr._M_data->_M_c_string = 0; + } + + _CharT operator[] (size_type __pos) const { + return _S_fetch(_M_tree_ptr._M_data, __pos); + } + + _CharT at(size_type __pos) const { + if (__pos >= size()) _M_throw_out_of_range(); + return (*this)[__pos]; + } + + const_iterator begin() const { + return(const_iterator(_M_tree_ptr._M_data, 0)); + } + + // An easy way to get a const iterator from a non-const container. + const_iterator const_begin() const { + return(const_iterator(_M_tree_ptr._M_data, 0)); + } + + const_iterator end() const { + return(const_iterator(_M_tree_ptr._M_data, size())); + } + + const_iterator const_end() const { + return(const_iterator(_M_tree_ptr._M_data, size())); + } + + size_type size() const { + return(0 == _M_tree_ptr._M_data? 0 : _M_tree_ptr._M_data->_M_size._M_data); + } + + size_type length() const { + return size(); + } + + size_type max_size() const { + return _S_min_len[__ROPE_MAX_DEPTH-1] - 1; + // Guarantees that the result can be sufficiently + // balanced. Longer ropes will probably still work, + // but it's harder to make guarantees. + } + + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + + const_reverse_iterator const_rbegin() const { + return const_reverse_iterator(end()); + } + + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + const_reverse_iterator const_rend() const { + return const_reverse_iterator(begin()); + } + // The symmetric cases are intentionally omitted, since they're presumed + // to be less common, and we don't handle them as well. + + // The following should really be templatized. + // The first argument should be an input iterator or + // forward iterator with value_type _CharT. + _Self& append(const _CharT* __iter, size_t __n) { + _M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, __iter, __n)); + return *this; + } + + _Self& append(const _CharT* __c_string) { + size_t __len = _S_char_ptr_len(__c_string); + append(__c_string, __len); + return *this; + } + + _Self& append(const _CharT* __s, const _CharT* __e) { + _M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, __s, __e - __s)); + return *this; + } + + _Self& append(const_iterator __s, const_iterator __e) { + _STLP_ASSERT(__s._M_root == __e._M_root) + _STLP_ASSERT(get_allocator() == __s._M_root->get_allocator()) + _Self_destruct_ptr __appendee(_S_substring(__s._M_root, __s._M_current_pos, __e._M_current_pos)); + _M_reset(_S_concat_rep(_M_tree_ptr._M_data, (_RopeRep*)__appendee)); + return *this; + } + + _Self& append(_CharT __c) { + _M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, &__c, 1)); + return *this; + } + + _Self& append() { return append(_CharT()); } // XXX why? + + _Self& append(const _Self& __y) { + _STLP_ASSERT(__y.get_allocator() == get_allocator()) + _M_reset(_S_concat_rep(_M_tree_ptr._M_data, __y._M_tree_ptr._M_data)); + return *this; + } + + _Self& append(size_t __n, _CharT __c) { + rope<_CharT,_Alloc> __last(__n, __c); + return append(__last); + } + + void swap(_Self& __b) { + _M_tree_ptr.swap(__b._M_tree_ptr); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +protected: + // Result is included in refcount. + static _RopeRep* replace(_RopeRep* __old, size_t __pos1, + size_t __pos2, _RopeRep* __r) { + if (0 == __old) { _S_ref(__r); return __r; } + _Self_destruct_ptr __left(_S_substring(__old, 0, __pos1)); + _Self_destruct_ptr __right(_S_substring(__old, __pos2, __old->_M_size._M_data)); + _STLP_MPWFIX_TRY //*TY 06/01/2000 - + _RopeRep* __result; + + if (0 == __r) { + __result = _S_concat_rep(__left, __right); + } else { + _STLP_ASSERT(__old->get_allocator() == __r->get_allocator()) + _Self_destruct_ptr __left_result(_S_concat_rep(__left, __r)); + __result = _S_concat_rep(__left_result, __right); + } + return __result; + _STLP_MPWFIX_CATCH //*TY 06/01/2000 - + } + +public: + void insert(size_t __p, const _Self& __r) { + if (__p > size()) _M_throw_out_of_range(); + _STLP_ASSERT(get_allocator() == __r.get_allocator()) + _M_reset(replace(_M_tree_ptr._M_data, __p, __p, __r._M_tree_ptr._M_data)); + } + + void insert(size_t __p, size_t __n, _CharT __c) { + rope<_CharT,_Alloc> __r(__n,__c); + insert(__p, __r); + } + + void insert(size_t __p, const _CharT* __i, size_t __n) { + if (__p > size()) _M_throw_out_of_range(); + _Self_destruct_ptr __left(_S_substring(_M_tree_ptr._M_data, 0, __p)); + _Self_destruct_ptr __right(_S_substring(_M_tree_ptr._M_data, __p, size())); + _Self_destruct_ptr __left_result( + _S_concat_char_iter(__left, __i, __n)); + // _S_ destr_concat_char_iter should be safe here. + // But as it stands it's probably not a win, since __left + // is likely to have additional references. + _M_reset(_S_concat_rep(__left_result, __right)); + } + + void insert(size_t __p, const _CharT* __c_string) { + insert(__p, __c_string, _S_char_ptr_len(__c_string)); + } + + void insert(size_t __p, _CharT __c) { + insert(__p, &__c, 1); + } + + void insert(size_t __p) { + _CharT __c = _CharT(); + insert(__p, &__c, 1); + } + + void insert(size_t __p, const _CharT* __i, const _CharT* __j) { + _Self __r(__i, __j); + insert(__p, __r); + } + + void insert(size_t __p, const const_iterator& __i, + const const_iterator& __j) { + _Self __r(__i, __j); + insert(__p, __r); + } + + void insert(size_t __p, const iterator& __i, + const iterator& __j) { + _Self __r(__i, __j); + insert(__p, __r); + } + + // (position, length) versions of replace operations: + void replace(size_t __p, size_t __n, const _Self& __r) { + if (__p > size()) _M_throw_out_of_range(); + _M_reset(replace(_M_tree_ptr._M_data, __p, __p + __n, __r._M_tree_ptr._M_data)); + } + + void replace(size_t __p, size_t __n, + const _CharT* __i, size_t __i_len) { + _Self __r(__i, __i_len); + replace(__p, __n, __r); + } + + void replace(size_t __p, size_t __n, _CharT __c) { + _Self __r(__c); + replace(__p, __n, __r); + } + + void replace(size_t __p, size_t __n, const _CharT* __c_string) { + _Self __r(__c_string); + replace(__p, __n, __r); + } + + void replace(size_t __p, size_t __n, + const _CharT* __i, const _CharT* __j) { + _Self __r(__i, __j); + replace(__p, __n, __r); + } + + void replace(size_t __p, size_t __n, + const const_iterator& __i, const const_iterator& __j) { + _Self __r(__i, __j); + replace(__p, __n, __r); + } + + void replace(size_t __p, size_t __n, + const iterator& __i, const iterator& __j) { + _Self __r(__i, __j); + replace(__p, __n, __r); + } + + // Single character variants: + void replace(size_t __p, _CharT __c) { + if (__p > size()) _M_throw_out_of_range(); + iterator __i(this, __p); + *__i = __c; + } + + void replace(size_t __p, const _Self& __r) { + replace(__p, 1, __r); + } + + void replace(size_t __p, const _CharT* __i, size_t __i_len) { + replace(__p, 1, __i, __i_len); + } + + void replace(size_t __p, const _CharT* __c_string) { + replace(__p, 1, __c_string); + } + + void replace(size_t __p, const _CharT* __i, const _CharT* __j) { + replace(__p, 1, __i, __j); + } + + void replace(size_t __p, const const_iterator& __i, + const const_iterator& __j) { + replace(__p, 1, __i, __j); + } + + void replace(size_t __p, const iterator& __i, + const iterator& __j) { + replace(__p, 1, __i, __j); + } + + // Erase, (position, size) variant. + void erase(size_t __p, size_t __n) { + if (__p > size()) _M_throw_out_of_range(); + _M_reset(replace(_M_tree_ptr._M_data, __p, __p + __n, 0)); + } + + // Erase, single character + void erase(size_t __p) { + erase(__p, __p + 1); + } + + // Insert, iterator variants. + iterator insert(const iterator& __p, const _Self& __r) + { insert(__p.index(), __r); return __p; } + iterator insert(const iterator& __p, size_t __n, _CharT __c) + { insert(__p.index(), __n, __c); return __p; } + iterator insert(const iterator& __p, _CharT __c) + { insert(__p.index(), __c); return __p; } + iterator insert(const iterator& __p ) + { insert(__p.index()); return __p; } + iterator insert(const iterator& __p, const _CharT* c_string) + { insert(__p.index(), c_string); return __p; } + iterator insert(const iterator& __p, const _CharT* __i, size_t __n) + { insert(__p.index(), __i, __n); return __p; } + iterator insert(const iterator& __p, const _CharT* __i, + const _CharT* __j) + { insert(__p.index(), __i, __j); return __p; } + iterator insert(const iterator& __p, + const const_iterator& __i, const const_iterator& __j) + { insert(__p.index(), __i, __j); return __p; } + iterator insert(const iterator& __p, + const iterator& __i, const iterator& __j) + { insert(__p.index(), __i, __j); return __p; } + + // Replace, range variants. + void replace(const iterator& __p, const iterator& __q, + const _Self& __r) + { replace(__p.index(), __q.index() - __p.index(), __r); } + void replace(const iterator& __p, const iterator& __q, _CharT __c) + { replace(__p.index(), __q.index() - __p.index(), __c); } + void replace(const iterator& __p, const iterator& __q, + const _CharT* __c_string) + { replace(__p.index(), __q.index() - __p.index(), __c_string); } + void replace(const iterator& __p, const iterator& __q, + const _CharT* __i, size_t __n) + { replace(__p.index(), __q.index() - __p.index(), __i, __n); } + void replace(const iterator& __p, const iterator& __q, + const _CharT* __i, const _CharT* __j) + { replace(__p.index(), __q.index() - __p.index(), __i, __j); } + void replace(const iterator& __p, const iterator& __q, + const const_iterator& __i, const const_iterator& __j) + { replace(__p.index(), __q.index() - __p.index(), __i, __j); } + void replace(const iterator& __p, const iterator& __q, + const iterator& __i, const iterator& __j) + { replace(__p.index(), __q.index() - __p.index(), __i, __j); } + + // Replace, iterator variants. + void replace(const iterator& __p, const _Self& __r) + { replace(__p.index(), __r); } + void replace(const iterator& __p, _CharT __c) + { replace(__p.index(), __c); } + void replace(const iterator& __p, const _CharT* __c_string) + { replace(__p.index(), __c_string); } + void replace(const iterator& __p, const _CharT* __i, size_t __n) + { replace(__p.index(), __i, __n); } + void replace(const iterator& __p, const _CharT* __i, const _CharT* __j) + { replace(__p.index(), __i, __j); } + void replace(const iterator& __p, const_iterator __i, + const_iterator __j) + { replace(__p.index(), __i, __j); } + void replace(const iterator& __p, iterator __i, iterator __j) + { replace(__p.index(), __i, __j); } + + // Iterator and range variants of erase + iterator erase(const iterator& __p, const iterator& __q) { + size_t __p_index = __p.index(); + erase(__p_index, __q.index() - __p_index); + return iterator(this, __p_index); + } + iterator erase(const iterator& __p) { + size_t __p_index = __p.index(); + erase(__p_index, 1); + return iterator(this, __p_index); + } + + _Self substr(size_t __start, size_t __len = 1) const { + if (__start > size()) _M_throw_out_of_range(); + return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __start, __start + __len)); + } + + _Self substr(iterator __start, iterator __end) const { + return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __start.index(), __end.index())); + } + + _Self substr(iterator __start) const { + size_t __pos = __start.index(); + return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __pos, __pos + 1)); + } + + _Self substr(const_iterator __start, const_iterator __end) const { + // This might eventually take advantage of the cache in the + // iterator. + return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __start.index(), __end.index())); + } + + rope<_CharT,_Alloc> substr(const_iterator __start) { + size_t __pos = __start.index(); + return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __pos, __pos + 1)); + } + +#include + + size_type find(const _Self& __s, size_type __pos = 0) const { + if (__pos >= size()) +# ifndef _STLP_OLD_ROPE_SEMANTICS + return npos; +# else + return size(); +# endif + + size_type __result_pos; + const_iterator __result = _STLP_STD::search(const_begin() + (ptrdiff_t)__pos, const_end(), __s.begin(), __s.end() ); + __result_pos = __result.index(); +# ifndef _STLP_OLD_ROPE_SEMANTICS + if (__result_pos == size()) __result_pos = npos; +# endif + return __result_pos; + } + size_type find(_CharT __c, size_type __pos = 0) const; + size_type find(const _CharT* __s, size_type __pos = 0) const { + size_type __result_pos; + const_iterator __result = _STLP_STD::search(const_begin() + (ptrdiff_t)__pos, const_end(), + __s, __s + _S_char_ptr_len(__s)); + __result_pos = __result.index(); +# ifndef _STLP_OLD_ROPE_SEMANTICS + if (__result_pos == size()) __result_pos = npos; +# endif + return __result_pos; + } + + iterator mutable_begin() { + return(iterator(this, 0)); + } + + iterator mutable_end() { + return(iterator(this, size())); + } + + reverse_iterator mutable_rbegin() { + return reverse_iterator(mutable_end()); + } + + reverse_iterator mutable_rend() { + return reverse_iterator(mutable_begin()); + } + + reference mutable_reference_at(size_type __pos) { + return reference(this, __pos); + } + +# ifdef __STD_STUFF + reference operator[] (size_type __pos) { + return reference(this, __pos); + } + + reference at(size_type __pos) { + if (__pos >= size()) _M_throw_out_of_range(); + return (*this)[__pos]; + } + + void resize(size_type, _CharT) {} + void resize(size_type) {} + void reserve(size_type = 0) {} + size_type capacity() const { + return max_size(); + } + + // Stuff below this line is dangerous because it's error prone. + // I would really like to get rid of it. + // copy function with funny arg ordering. + size_type copy(_CharT* __buffer, size_type __n, + size_type __pos = 0) const { + return copy(__pos, __n, __buffer); + } + + iterator end() { return mutable_end(); } + + iterator begin() { return mutable_begin(); } + + reverse_iterator rend() { return mutable_rend(); } + + reverse_iterator rbegin() { return mutable_rbegin(); } + +# else + + const_iterator end() { return const_end(); } + + const_iterator begin() { return const_begin(); } + + const_reverse_iterator rend() { return const_rend(); } + + const_reverse_iterator rbegin() { return const_rbegin(); } + +# endif +}; //class rope + +#if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96) +template +const size_t rope<_CharT, _Alloc>::npos = ~(size_t) 0; +#endif + +template +inline _CharT +_Rope_const_iterator< _CharT, _Alloc>::operator[](size_t __n) +{ return rope<_CharT,_Alloc>::_S_fetch(this->_M_root, this->_M_current_pos + __n); } + +template +inline bool operator== (const _Rope_const_iterator<_CharT,_Alloc>& __x, + const _Rope_const_iterator<_CharT,_Alloc>& __y) { + return (__x._M_current_pos == __y._M_current_pos && + __x._M_root == __y._M_root); +} + +template +inline bool operator< (const _Rope_const_iterator<_CharT,_Alloc>& __x, + const _Rope_const_iterator<_CharT,_Alloc>& __y) +{ return (__x._M_current_pos < __y._M_current_pos); } + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE + +template +inline bool operator!= (const _Rope_const_iterator<_CharT,_Alloc>& __x, + const _Rope_const_iterator<_CharT,_Alloc>& __y) +{ return !(__x == __y); } + +template +inline bool operator> (const _Rope_const_iterator<_CharT,_Alloc>& __x, + const _Rope_const_iterator<_CharT,_Alloc>& __y) +{ return __y < __x; } + +template +inline bool operator<= (const _Rope_const_iterator<_CharT,_Alloc>& __x, + const _Rope_const_iterator<_CharT,_Alloc>& __y) +{ return !(__y < __x); } + +template +inline bool operator>= (const _Rope_const_iterator<_CharT,_Alloc>& __x, + const _Rope_const_iterator<_CharT,_Alloc>& __y) +{ return !(__x < __y); } + +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template +inline ptrdiff_t operator-(const _Rope_const_iterator<_CharT,_Alloc>& __x, + const _Rope_const_iterator<_CharT,_Alloc>& __y) +{ return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; } + +#if !defined( __MWERKS__ ) || __MWERKS__ >= 0x2000 // dwa 8/21/97 - "ambiguous access to overloaded function" bug. +template +inline _Rope_const_iterator<_CharT,_Alloc> +operator-(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n) +{ return _Rope_const_iterator<_CharT,_Alloc>(__x._M_root, __x._M_current_pos - __n); } +# endif + +template +inline _Rope_const_iterator<_CharT,_Alloc> +operator+(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n) +{ return _Rope_const_iterator<_CharT,_Alloc>(__x._M_root, __x._M_current_pos + __n); } + +template +inline _Rope_const_iterator<_CharT,_Alloc> +operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT,_Alloc>& __x) +{ return _Rope_const_iterator<_CharT,_Alloc>(__x._M_root, __x._M_current_pos + __n); } + +template +inline bool operator== (const _Rope_iterator<_CharT,_Alloc>& __x, + const _Rope_iterator<_CharT,_Alloc>& __y) { + return (__x._M_current_pos == __y._M_current_pos && + __x._M_root_rope == __y._M_root_rope); +} + +template +inline bool operator< (const _Rope_iterator<_CharT,_Alloc>& __x, + const _Rope_iterator<_CharT,_Alloc>& __y) +{ return (__x._M_current_pos < __y._M_current_pos); } + +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template +inline bool operator!= (const _Rope_iterator<_CharT,_Alloc>& __x, + const _Rope_iterator<_CharT,_Alloc>& __y) +{ return !(__x == __y); } + +template +inline bool operator> (const _Rope_iterator<_CharT,_Alloc>& __x, + const _Rope_iterator<_CharT,_Alloc>& __y) +{ return __y < __x; } + +template +inline bool operator<= (const _Rope_iterator<_CharT,_Alloc>& __x, + const _Rope_iterator<_CharT,_Alloc>& __y) +{ return !(__y < __x); } + +template +inline bool operator>= (const _Rope_iterator<_CharT,_Alloc>& __x, + const _Rope_iterator<_CharT,_Alloc>& __y) +{ return !(__x < __y); } +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template +inline ptrdiff_t operator-(const _Rope_iterator<_CharT,_Alloc>& __x, + const _Rope_iterator<_CharT,_Alloc>& __y) +{ return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; } + +#if !defined( __MWERKS__ ) || __MWERKS__ >= 0x2000 // dwa 8/21/97 - "ambiguous access to overloaded function" bug. +template +inline _Rope_iterator<_CharT,_Alloc> +operator-(const _Rope_iterator<_CharT,_Alloc>& __x, + ptrdiff_t __n) { + return _Rope_iterator<_CharT,_Alloc>(__x._M_root_rope, __x._M_current_pos - __n); +} +# endif + +template +inline _Rope_iterator<_CharT,_Alloc> +operator+(const _Rope_iterator<_CharT,_Alloc>& __x, + ptrdiff_t __n) { + return _Rope_iterator<_CharT,_Alloc>(__x._M_root_rope, __x._M_current_pos + __n); +} + +template +inline _Rope_iterator<_CharT,_Alloc> +operator+(ptrdiff_t __n, const _Rope_iterator<_CharT,_Alloc>& __x) { + return _Rope_iterator<_CharT,_Alloc>(__x._M_root_rope, __x._M_current_pos + __n); +} + +template +inline rope<_CharT,_Alloc> +operator+ (const rope<_CharT,_Alloc>& __left, + const rope<_CharT,_Alloc>& __right) { + _STLP_ASSERT(__left.get_allocator() == __right.get_allocator()) + return rope<_CharT,_Alloc>(rope<_CharT,_Alloc>::_S_concat_rep(__left._M_tree_ptr._M_data, __right._M_tree_ptr._M_data)); + // Inlining this should make it possible to keep __left and __right in registers. +} + +template +inline rope<_CharT,_Alloc>& +operator+= (rope<_CharT,_Alloc>& __left, + const rope<_CharT,_Alloc>& __right) { + __left.append(__right); + return __left; +} + +template +inline rope<_CharT,_Alloc> +operator+ (const rope<_CharT,_Alloc>& __left, + const _CharT* __right) { + size_t __rlen = rope<_CharT,_Alloc>::_S_char_ptr_len(__right); + return rope<_CharT,_Alloc>(rope<_CharT,_Alloc>::_S_concat_char_iter(__left._M_tree_ptr._M_data, __right, __rlen)); +} + +template +inline rope<_CharT,_Alloc>& +operator+= (rope<_CharT,_Alloc>& __left, + const _CharT* __right) { + __left.append(__right); + return __left; +} + +template +inline rope<_CharT,_Alloc> +operator+ (const rope<_CharT,_Alloc>& __left, _CharT __right) { + return rope<_CharT,_Alloc>(rope<_CharT,_Alloc>::_S_concat_char_iter(__left._M_tree_ptr._M_data, &__right, 1)); +} + +template +inline rope<_CharT,_Alloc>& +operator+= (rope<_CharT,_Alloc>& __left, _CharT __right) { + __left.append(__right); + return __left; +} + +template +inline bool +operator< (const rope<_CharT,_Alloc>& __left, + const rope<_CharT,_Alloc>& __right) { + return __left.compare(__right) < 0; +} + +template +inline bool +operator== (const rope<_CharT,_Alloc>& __left, + const rope<_CharT,_Alloc>& __right) { + return __left.compare(__right) == 0; +} + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE + +template +inline bool +operator!= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) { + return !(__x == __y); +} + +template +inline bool +operator> (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) { + return __y < __x; +} + +template +inline bool +operator<= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) { + return !(__y < __x); +} + +template +inline bool +operator>= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) { + return !(__x < __y); +} + +template +inline bool operator!= (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x, + const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y) { + return !(__x == __y); +} + +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template +inline bool operator== (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x, + const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y) { + return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root); +} + +#if !defined (_STLP_USE_NO_IOSTREAMS) +template +basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o, + const rope<_CharT, _Alloc>& __r); +#endif + +typedef rope > crope; +#if defined (_STLP_HAS_WCHAR_T) +typedef rope > wrope; +#endif + +inline crope::reference __mutable_reference_at(crope& __c, size_t __i) +{ return __c.mutable_reference_at(__i); } + +#if defined (_STLP_HAS_WCHAR_T) +inline wrope::reference __mutable_reference_at(wrope& __c, size_t __i) +{ return __c.mutable_reference_at(__i); } +#endif + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template +inline void swap(rope<_CharT,_Alloc>& __x, rope<_CharT,_Alloc>& __y) +{ __x.swap(__y); } +#else + +inline void swap(crope& __x, crope& __y) { __x.swap(__y); } +# ifdef _STLP_HAS_WCHAR_T // dwa 8/21/97 +inline void swap(wrope& __x, wrope& __y) { __x.swap(__y); } +# endif + +#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ + + +// Hash functions should probably be revisited later: +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(const crope& __str) const { + size_t _p_size = __str.size(); + + if (0 == _p_size) return 0; + return 13*__str[0] + 5*__str[_p_size - 1] + _p_size; + } +}; + +#if defined (_STLP_HAS_WCHAR_T) // dwa 8/21/97 +_STLP_TEMPLATE_NULL struct hash { + size_t operator()(const wrope& __str) const { + size_t _p_size = __str.size(); + + if (0 == _p_size) return 0; + return 13*__str[0] + 5*__str[_p_size - 1] + _p_size; + } +}; +#endif + +#if (!defined (_STLP_MSVC) || (_STLP_MSVC >= 1310)) +// I couldn't get this to work with VC++ +template +# if defined (__DMC__) +extern +# endif +void _Rope_rotate(_Rope_iterator<_CharT, _Alloc> __first, + _Rope_iterator<_CharT, _Alloc> __middle, + _Rope_iterator<_CharT, _Alloc> __last); + +inline void rotate(_Rope_iterator > __first, + _Rope_iterator > __middle, + _Rope_iterator > __last) +{ _Rope_rotate(__first, __middle, __last); } +#endif + +template +inline _Rope_char_ref_proxy<_CharT, _Alloc>::operator _CharT () const { + if (_M_current_valid) { + return _M_current; + } else { + return _My_rope::_S_fetch(_M_root->_M_tree_ptr._M_data, _M_pos); + } +} + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > { + typedef __true_type implemented; + //Completness depends on the allocator: + typedef typename __move_traits<_Alloc>::complete complete; +}; +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_ROPE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_set.h b/sdk/tlibstdcxx/stlport/stl/_set.h new file mode 100644 index 0000000000..a8f68620ea --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_set.h @@ -0,0 +1,412 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_SET_H +#define _STLP_INTERNAL_SET_H + +#ifndef _STLP_INTERNAL_TREE_H +# include +#endif + +#if !defined (_STLP_USE_PTR_SPECIALIZATIONS) + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits) + +template ), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > +class set +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef set<_Key, _Compare, _Alloc> _Self; +public: +// typedefs: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + +private: + //Specific iterator traits creation + typedef _STLP_PRIV _SetTraitsT _SetTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree, + _SetTraits, _Alloc> _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing set + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + + // allocation/deallocation +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit set(const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) +#else + set() + : _M_t(_Compare(), allocator_type()) {} + explicit set(const _Compare& __comp) + : _M_t(__comp, allocator_type()) {} + set(const _Compare& __comp, const allocator_type& __a) +#endif + : _M_t(__comp, __a) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template + set(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); } +# endif + template + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } +#else + set(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + set(const value_type* __first, + const value_type* __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } + + set(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + set(const_iterator __first, const_iterator __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + set(const _Self& __x) : _M_t(__x._M_t) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + set(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return _M_t.key_comp(); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator begin() const { return _M_t.begin(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + pair insert(const value_type& __x) + { return _M_t.insert_unique(__x); } + iterator insert(iterator __pos, const value_type& __x) + { return _M_t.insert_unique( __pos , __x); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_unique(__first, __last); } +#else + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_unique(__first, __last); } + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + void erase(iterator __pos) { _M_t.erase( __pos ); } + size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last ); } + void clear() { _M_t.clear(); } + + // set operations: + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const + { return _M_t.find(__x) == _M_t.end() ? 0 : 1 ; } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) + { return _M_t.equal_range_unique(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const + { return _M_t.equal_range_unique(__x); } +}; + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits) + +template ), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > +class multiset +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef multiset<_Key, _Compare, _Alloc> _Self; +public: + // typedefs: + + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + +private: + //Specific iterator traits creation + typedef _STLP_PRIV _MultisetTraitsT _MultisetTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree, + _MultisetTraits, _Alloc> _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing multiset + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit multiset(const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) +#else + multiset() + : _M_t(_Compare(), allocator_type()) {} + explicit multiset(const _Compare& __comp) + : _M_t(__comp, allocator_type()) {} + multiset(const _Compare& __comp, const allocator_type& __a) +#endif + : _M_t(__comp, __a) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template + multiset(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + + template + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); } +# endif +#else + multiset(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + + multiset(const value_type* __first, const value_type* __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } + + multiset(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + + multiset(const_iterator __first, const_iterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + multiset(const _Self& __x) : _M_t(__x._M_t) {} + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + multiset(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return _M_t.key_comp(); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator begin() const { return _M_t.begin(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + iterator insert(const value_type& __x) + { return _M_t.insert_equal(__x); } + iterator insert(iterator __pos, const value_type& __x) + { return _M_t.insert_equal(__pos, __x); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_equal(__first, __last); } +#else + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_equal(__first, __last); } + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + void erase(iterator __pos) { _M_t.erase( __pos ); } + size_type erase(const key_type& __x) { return _M_t.erase(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase( __first, __last ); } + void clear() { _M_t.clear(); } + + // multiset operations: + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { return _M_t.count(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) { return _M_t.equal_range(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const { return _M_t.equal_range(__x); } +}; + +#else +# include +_STLP_BEGIN_NAMESPACE +#endif /* _STLP_USE_PTR_SPECIALIZATIONS */ + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER set<_Key,_Compare,_Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER multiset<_Key,_Compare,_Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux::_Rep_type> +{}; + +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux::_Rep_type> +{}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_SET_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_slist.c b/sdk/tlibstdcxx/stlport/stl/_slist.c new file mode 100644 index 0000000000..ba158d00c5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_slist.c @@ -0,0 +1,231 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_SLIST_C +#define _STLP_SLIST_C + +#ifndef _STLP_INTERNAL_SLIST_H +# include +#endif + +#ifndef _STLP_CARRAY_H +# include +#endif + +#ifndef _STLP_RANGE_ERRORS_H +# include +#endif + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define size_type size_t +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_Slist_node_base* +_Slist_base<_Tp,_Alloc>::_M_erase_after(_Slist_node_base* __before_first, + _Slist_node_base* __last_node) { + _Slist_node_base* __cur = __before_first->_M_next; + while (__cur != __last_node) { + _Node* __tmp = __STATIC_CAST(_Node*, __cur); + __cur = __cur->_M_next; + _STLP_STD::_Destroy(&__tmp->_M_data); + _M_head.deallocate(__tmp,1); + } + __before_first->_M_next = __last_node; + return __last_node; +} + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define slist _STLP_PTR_IMPL_NAME(slist) +#elif defined (_STLP_DEBUG) +# define slist _STLP_NON_DBG_NAME(slist) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +/* When building STLport lib Digital Mars Compiler complains on the _M_data assignment + * problem which would be perfertly right if we were using it. Hiding it during build + * fix this issue. + */ +template +slist<_Tp,_Alloc>& slist<_Tp,_Alloc>::operator=(const slist<_Tp,_Alloc>& __x) { + if (&__x != this) { + _Node_base* __p1 = &this->_M_head._M_data; + _Node_base* __n1 = this->_M_head._M_data._M_next; + const _Node_base* __n2 = __x._M_head._M_data._M_next; + while (__n1 && __n2) { + __STATIC_CAST(_Node*, __n1)->_M_data = __STATIC_CAST(const _Node*, __n2)->_M_data; + __p1 = __n1; + __n1 = __n1->_M_next; + __n2 = __n2->_M_next; + } + if (__n2 == 0) + this->_M_erase_after(__p1, 0); + else + _M_insert_after_range(__p1, const_iterator(__CONST_CAST(_Node_base*, __n2)), + const_iterator(0)); + } + return *this; +} + +template +void slist<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) { + _Node_base* __prev = &this->_M_head._M_data; + _Node_base* __node = this->_M_head._M_data._M_next; + for ( ; __node != 0 && __n > 0 ; --__n) { + __STATIC_CAST(_Node*, __node)->_M_data = __val; + __prev = __node; + __node = __node->_M_next; + } + if (__n > 0) + _M_insert_after_fill(__prev, __n, __val); + else + this->_M_erase_after(__prev, 0); +} + +template +void slist<_Tp,_Alloc>::resize(size_type __len, const _Tp& __x) { + _Node_base* __cur = &this->_M_head._M_data; + while (__cur->_M_next != 0 && __len > 0) { + --__len; + __cur = __cur->_M_next; + } + if (__cur->_M_next) + this->_M_erase_after(__cur, 0); + else + _M_insert_after_fill(__cur, __len, __x); +} + +template +void slist<_Tp,_Alloc>::remove(const _Tp& __val) { + _Node_base* __cur = &this->_M_head._M_data; + while (__cur && __cur->_M_next) { + if (__STATIC_CAST(_Node*, __cur->_M_next)->_M_data == __val) + this->_M_erase_after(__cur); + else + __cur = __cur->_M_next; + } +} + +#if !defined (slist) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template +void _Slist_unique(slist<_Tp, _Alloc>& __that, _BinaryPredicate __pred) { + typedef _Slist_node<_Tp> _Node; + typename slist<_Tp, _Alloc>::iterator __ite(__that.begin()); + if (__ite != __that.end()) { + while (__ite._M_node->_M_next) { + if (__pred(*__ite, __STATIC_CAST(_Node*, __ite._M_node->_M_next)->_M_data)) + __that.erase_after(__ite); + else + ++__ite; + } + } +} + +template +void _Slist_merge(slist<_Tp, _Alloc>& __that, slist<_Tp, _Alloc>& __x, + _StrictWeakOrdering __comp) { + typedef _Slist_node<_Tp> _Node; + typedef _STLP_PRIV _Slist_node_base _Node_base; + if (__that.get_allocator() == __x.get_allocator()) { + typename slist<_Tp, _Alloc>::iterator __ite(__that.before_begin()); + while (__ite._M_node->_M_next && !__x.empty()) { + if (__comp(__x.front(), __STATIC_CAST(_Node*, __ite._M_node->_M_next)->_M_data)) { + _STLP_VERBOSE_ASSERT(!__comp(__STATIC_CAST(_Node*, __ite._M_node->_M_next)->_M_data, __x.front()), + _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __that.splice_after(__ite, __x, __x.before_begin()); + } + ++__ite; + } + if (!__x.empty()) { + __that.splice_after(__ite, __x); + } + } + else { + typename slist<_Tp, _Alloc>::iterator __i1(__that.before_begin()), __i2(__x.begin()); + while (__i1._M_node->_M_next && __i2._M_node) { + if (__comp(__STATIC_CAST(_Node*, __i1._M_node->_M_next)->_M_data, *__i2)) { + _STLP_VERBOSE_ASSERT(!__comp(*__i2, __STATIC_CAST(_Node*, __i1._M_node->_M_next)->_M_data), + _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + ++__i1; + } + else { + __i1 = __that.insert_after(__i1, *(__i2++)); + } + } + __that.insert_after(__i1, __i2, __x.end()); + __x.clear(); + } +} + +template +void _Slist_sort(slist<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp) { + if (!__that.begin()._M_node || !__that.begin()._M_node->_M_next) + return; + + slist<_Tp, _Alloc> __carry(__that.get_allocator()); + const int NB = 64; + _STLP_PRIV _CArray, NB> __counter(__carry); + int __fill = 0; + while (!__that.empty()) { + __carry.splice_after(__carry.before_begin(), __that, __that.before_begin()); + int __i = 0; + while (__i < __fill && !__counter[__i].empty()) { + _STLP_PRIV _Slist_merge(__counter[__i], __carry, __comp); + __carry.swap(__counter[__i]); + ++__i; + } + __carry.swap(__counter[__i]); + if (__i == __fill) { + ++__fill; + if (__fill >= NB) { + //Looks like the slist has too many elements to be sorted with this algorithm: + __stl_throw_overflow_error("slist::sort"); + } + } + } + + for (int __i = 1; __i < __fill; ++__i) + _STLP_PRIV _Slist_merge(__counter[__i], __counter[__i - 1], __comp); + __that.swap(__counter[__fill-1]); +} + +#if defined (slist) +# undef slist +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# undef size_type +#endif + +#endif /* _STLP_SLIST_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_slist.h b/sdk/tlibstdcxx/stlport/stl/_slist.h new file mode 100644 index 0000000000..924daa4962 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_slist.h @@ -0,0 +1,914 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_SLIST_H +#define _STLP_INTERNAL_SLIST_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_SLIST_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class _Slist_node : public _Slist_node_base { +public: + _Tp _M_data; + __TRIVIAL_STUFF(_Slist_node) +}; + +struct _Slist_iterator_base { + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef forward_iterator_tag iterator_category; + + _Slist_node_base *_M_node; + + _Slist_iterator_base(_Slist_node_base *__x) : _M_node(__x) {} + + void _M_incr() { + _M_node = _M_node->_M_next; + } +}; + +template +class _Slist_iterator : public _Slist_iterator_base { +public: + typedef typename _Traits::value_type value_type; + typedef typename _Traits::pointer pointer; + typedef typename _Traits::reference reference; + typedef forward_iterator_tag iterator_category; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + typedef _Slist_iterator<_Tp, _Traits> _Self; + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef _Slist_iterator<_Tp, _NonConstTraits> iterator; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _Slist_iterator<_Tp, _ConstTraits> const_iterator; + + typedef _Slist_node _Node; + + explicit _Slist_iterator(_Slist_node_base *__x) : _Slist_iterator_base(__x) {} + _Slist_iterator() : _Slist_iterator_base(0) {} + //copy constructor for iterator and constructor from iterator for const_iterator + _Slist_iterator(const iterator& __x) : _Slist_iterator_base(__x._M_node) {} + + reference operator*() const { return __STATIC_CAST(_Node*, this->_M_node)->_M_data; } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + _M_incr(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + _M_incr(); + return __tmp; + } + + bool operator==(const_iterator __y ) const { + return this->_M_node == __y._M_node; + } + bool operator!=(const_iterator __y ) const { + return this->_M_node != __y._M_node; + } +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_MOVE_TO_STD_NAMESPACE +template +struct __type_traits<_STLP_PRIV _Slist_iterator<_Tp, _Traits> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +_STLP_MOVE_TO_STD_NAMESPACE +template +inline _Tp* _STLP_CALL value_type(const _STLP_PRIV _Slist_iterator<_Tp, _Traits>&) { return __STATIC_CAST(_Tp*, 0); } +inline ptrdiff_t* _STLP_CALL distance_type(const _STLP_PRIV _Slist_iterator_base&) { return 0; } +inline forward_iterator_tag _STLP_CALL iterator_category(const _STLP_PRIV _Slist_iterator_base&) { return forward_iterator_tag(); } +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* OLD_QUERIES */ + +// Base class that encapsulates details of allocators and simplifies EH +template +class _Slist_base { +protected: + typedef _Slist_node<_Tp> _Node; + typedef typename _Alloc_traits<_Node,_Alloc>::allocator_type _M_node_allocator_type; + typedef _Slist_base<_Tp, _Alloc> _Self; + +public: + typedef _STLP_alloc_proxy<_Slist_node_base, _Node, _M_node_allocator_type> _AllocProxy; + + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _Alloc allocator_type; + + _Slist_base(const allocator_type& __a) : + _M_head(_STLP_CONVERT_ALLOCATOR(__a, _Node), _Slist_node_base() ) + { _M_head._M_data._M_next = 0; } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Slist_base(__move_source<_Self> src) : + _M_head(__move_source<_AllocProxy>(src.get()._M_head)) + { src.get()._M_head._M_data._M_next = 0; } +#endif + + ~_Slist_base() { _M_erase_after(&_M_head._M_data, 0); } + +protected: + _Slist_node_base* _M_erase_after(_Slist_node_base* __pos) { + _Node* __next = __STATIC_CAST(_Node*, __pos->_M_next); + _Slist_node_base* __next_next = __next->_M_next; + __pos->_M_next = __next_next; + _STLP_STD::_Destroy(&__next->_M_data); + _M_head.deallocate(__next,1); + return __next_next; + } + _Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*); + +public: + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR((const _M_node_allocator_type&)_M_head, _Tp); } + _AllocProxy _M_head; +}; + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define slist _STLP_PTR_IMPL_NAME(slist) +#elif defined (_STLP_DEBUG) +# define slist _STLP_NON_DBG_NAME(slist) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template ) > +class slist; + +#if !defined (slist) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +// helper functions to reduce code duplication +template +void _Slist_unique(slist<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred); + +template +void _Slist_merge(slist<_Tp, _Alloc>& __that, slist<_Tp, _Alloc>& __x, + _StrictWeakOrdering __comp); + +template +void _Slist_sort(slist<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp); + +#if !defined (slist) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template +class slist : protected _STLP_PRIV _Slist_base<_Tp,_Alloc> +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (slist) + , public __stlport_class > +#endif +{ +private: + typedef _STLP_PRIV _Slist_base<_Tp,_Alloc> _Base; + typedef slist<_Tp,_Alloc> _Self; +public: + typedef _Tp value_type; + + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef forward_iterator_tag _Iterator_category; + + typedef _STLP_PRIV _Slist_iterator<_Tp, _Nonconst_traits<_Tp> > iterator; + typedef _STLP_PRIV _Slist_iterator<_Tp, _Const_traits<_Tp> > const_iterator; + + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef typename _Base::allocator_type allocator_type; + +private: + typedef _STLP_PRIV _Slist_node<_Tp> _Node; + typedef _STLP_PRIV _Slist_node_base _Node_base; + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + _Node* _M_create_node(const value_type& __x = _Tp()) { +#else + _Node* _M_create_node(const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + _Node* __node = this->_M_head.allocate(1); + _STLP_TRY { + _Copy_Construct(&__node->_M_data, __x); + __node->_M_next = 0; + } + _STLP_UNWIND(this->_M_head.deallocate(__node, 1)) + return __node; + } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + _Node* _M_create_node() { + _Node* __node = this->_M_head.allocate(1); + _STLP_TRY { + _STLP_STD::_Construct(&__node->_M_data); + __node->_M_next = 0; + } + _STLP_UNWIND(this->_M_head.deallocate(__node, 1)) + return __node; + } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +public: + + allocator_type get_allocator() const { return _Base::get_allocator(); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit slist(const allocator_type& __a = allocator_type()) +#else + slist() + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(allocator_type()) {} + slist(const allocator_type& __a) +#endif + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a) {} + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit slist(size_type __n, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp), + const allocator_type& __a = allocator_type()) +#else + explicit slist(size_type __n) + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(allocator_type()) + { _M_insert_after_fill(&this->_M_head._M_data, __n, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } + slist(size_type __n, const value_type& __x) + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(allocator_type()) + { _M_insert_after_fill(&this->_M_head._M_data, __n, __x); } + slist(size_type __n, const value_type& __x, const allocator_type& __a) +#endif + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a) + { _M_insert_after_fill(&this->_M_head._M_data, __n, __x); } + +#if defined (_STLP_MEMBER_TEMPLATES) + // We don't need any dispatching tricks here, because _M_insert_after_range + // already does them. + template + slist(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a) + { _M_insert_after_range(&this->_M_head._M_data, __first, __last); } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + // VC++ needs this crazyness + template + slist(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(allocator_type()) + { _M_insert_after_range(&this->_M_head._M_data, __first, __last); } +# endif +#else /* _STLP_MEMBER_TEMPLATES */ + slist(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type() ) + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a) + { _M_insert_after_range(&this->_M_head._M_data, __first, __last); } + slist(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a) + { _M_insert_after_range(&this->_M_head._M_data, __first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + slist(const _Self& __x) + : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__x.get_allocator()) + { _M_insert_after_range(&this->_M_head._M_data, __x.begin(), __x.end()); } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + slist(__move_source<_Self> src) + : _STLP_PRIV _Slist_base<_Tp, _Alloc>(__move_source<_Base>(src.get())) {} +#endif + + _Self& operator= (const _Self& __x); + + ~slist() {} + +public: + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); } + +private: + void _M_fill_assign(size_type __n, const _Tp& __val); + +#if defined (_STLP_MEMBER_TEMPLATES) +public: + template + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } + +private: + template + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) { + _M_fill_assign((size_type) __n, (_Tp) __val); + } + + template + void _M_assign_dispatch(_InputIter __first, _InputIter __last, + const __false_type& /*_IsIntegral*/) { +#else +public: + void assign(const_pointer __first, const_pointer __last) { + _Node_base* __prev = &this->_M_head._M_data; + _Node_base* __node = this->_M_head._M_data._M_next; + while (__node != 0 && __first != __last) { + __STATIC_CAST(_Node*, __node)->_M_data = *__first; + __prev = __node; + __node = __node->_M_next; + ++__first; + } + if (__first != __last) + _M_insert_after_range(__prev, __first, __last); + else + this->_M_erase_after(__prev, 0); + } + void assign(const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + _Node_base* __prev = &this->_M_head._M_data; + _Node_base* __node = this->_M_head._M_data._M_next; + while (__node != 0 && __first != __last) { + __STATIC_CAST(_Node*, __node)->_M_data = *__first; + __prev = __node; + __node = __node->_M_next; + ++__first; + } + if (__first != __last) + _M_insert_after_range(__prev, __first, __last); + else + this->_M_erase_after(__prev, 0); + } + +public: + + // Experimental new feature: before_begin() returns a + // non-dereferenceable iterator that, when incremented, yields + // begin(). This iterator may be used as the argument to + // insert_after, erase_after, etc. Note that even for an empty + // slist, before_begin() is not the same iterator as end(). It + // is always necessary to increment before_begin() at least once to + // obtain end(). + iterator before_begin() { return iterator(&this->_M_head._M_data); } + const_iterator before_begin() const + { return const_iterator(__CONST_CAST(_Node_base*, &this->_M_head._M_data)); } + + iterator begin() { return iterator(this->_M_head._M_data._M_next); } + const_iterator begin() const + { return const_iterator(this->_M_head._M_data._M_next);} + + iterator end() { return iterator(); } + const_iterator end() const { return const_iterator(); } + + size_type size() const + { return _STLP_PRIV _Sl_global_inst::size(this->_M_head._M_data._M_next); } + + size_type max_size() const { return size_type(-1); } + + bool empty() const { return this->_M_head._M_data._M_next == 0; } + + void swap(_Self& __x) + { this->_M_head.swap(__x._M_head); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +public: + reference front() { return *begin(); } + const_reference front() const { return *begin(); } +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_front(const value_type& __x = _Tp()) { +#else + void push_front(const value_type& __x) { +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + _STLP_PRIV __slist_make_link(&this->_M_head._M_data, _M_create_node(__x)); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_front() { _STLP_PRIV __slist_make_link(&this->_M_head._M_data, _M_create_node());} +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + void pop_front() { + _Node* __node = __STATIC_CAST(_Node*, this->_M_head._M_data._M_next); + this->_M_head._M_data._M_next = __node->_M_next; + _STLP_STD::_Destroy(&__node->_M_data); + this->_M_head.deallocate(__node, 1); + } + + iterator previous(const_iterator __pos) { + return iterator(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node)); + } + const_iterator previous(const_iterator __pos) const { + return const_iterator(__CONST_CAST(_Node_base*, + _STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, + __pos._M_node))); + } + +private: +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + _Node* _M_insert_after(_Node_base* __pos, const value_type& __x = _Tp()) { +#else + _Node* _M_insert_after(_Node_base* __pos, const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + return __STATIC_CAST(_Node*, _STLP_PRIV __slist_make_link(__pos, _M_create_node(__x))); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + _Node* _M_insert_after(_Node_base* __pos) { + return __STATIC_CAST(_Node*, _STLP_PRIV __slist_make_link(__pos, _M_create_node())); + } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void _M_insert_after_fill(_Node_base* __pos, + size_type __n, const value_type& __x) { + for (size_type __i = 0; __i < __n; ++__i) + __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(__x)); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + // Check whether it's an integral type. If so, it's not an iterator. + template + void _M_insert_after_range(_Node_base* __pos, + _InIter __first, _InIter __last) { + typedef typename _IsIntegral<_InIter>::_Ret _Integral; + _M_insert_after_range(__pos, __first, __last, _Integral()); + } + + template + void _M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x, + const __true_type&) { + _M_insert_after_fill(__pos, __n, __x); + } + + template + void _M_insert_after_range(_Node_base* __pos, + _InIter __first, _InIter __last, + const __false_type&) { +#else /* _STLP_MEMBER_TEMPLATES */ + void _M_insert_after_range(_Node_base* __pos, + const value_type* __first, + const value_type* __last) { + while (__first != __last) { + __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first)); + ++__first; + } + } + void _M_insert_after_range(_Node_base* __pos, + const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + while (__first != __last) { + __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first)); + ++__first; + } + } + +#if defined (_STLP_MEMBER_TEMPLATES) + // Check whether it's an integral type. If so, it's not an iterator. + template + void _M_splice_after_range(_Node_base* __pos, + _InIter __first, _InIter __last) { + typedef typename _IsIntegral<_InIter>::_Ret _Integral; + _M_splice_after_range(__pos, __first, __last, _Integral()); + } + + template + void _M_splice_after_range(_Node_base* __pos, _Integer __n, _Integer __x, + const __true_type&) { + _M_insert_after_fill(__pos, __n, __x); + } + + template + void _M_splice_after_range(_Node_base* __pos, + _InIter __first, _InIter __last, + const __false_type&) { +#else /* _STLP_MEMBER_TEMPLATES */ + void _M_splice_after_range(_Node_base* __pos, + const value_type* __first, + const value_type* __last) { + while (__first != __last) { + __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first)); + ++__first; + } + } + void _M_splice_after_range(_Node_base* __pos, + const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + //We use a temporary slist to avoid the auto reference troubles (infinite loop) + _Self __tmp(__first, __last, this->get_allocator()); + splice_after(iterator(__pos), __tmp); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + // Check whether it's an integral type. If so, it's not an iterator. + template + void _M_splice_range(_Node_base* __pos, + _InIter __first, _InIter __last) { + typedef typename _IsIntegral<_InIter>::_Ret _Integral; + _M_splice_range(__pos, __first, __last, _Integral()); + } + + template + void _M_splice_range(_Node_base* __pos, _Integer __n, _Integer __x, + const __true_type&) { + _M_insert_after_fill(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos), + __n, __x); + } + + template + void _M_splice_range(_Node_base* __pos, + _InIter __first, _InIter __last, + const __false_type&) { +#else /* _STLP_MEMBER_TEMPLATES */ + void _M_splice_range(_Node_base* __pos, + const value_type* __first, + const value_type* __last) { + while (__first != __last) { + __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first)); + ++__first; + } + } + void _M_splice_range(_Node_base* __pos, + const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + //We use a temporary slist to avoid the auto reference troubles (infinite loop) + _Self __tmp(__first, __last, this->get_allocator()); + splice(iterator(__pos), __tmp); + } + +public: + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert_after(iterator __pos, const value_type& __x = _Tp()) { +#else + iterator insert_after(iterator __pos, const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + return iterator(_M_insert_after(__pos._M_node, __x)); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert_after(iterator __pos) { + return insert_after(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); + } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void insert_after(iterator __pos, size_type __n, const value_type& __x) { + _M_insert_after_fill(__pos._M_node, __n, __x); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + // We don't need any dispatching tricks here, because _M_insert_after_range + // already does them. + template + void insert_after(iterator __pos, _InIter __first, _InIter __last) { +#else /* _STLP_MEMBER_TEMPLATES */ + void insert_after(iterator __pos, + const value_type* __first, const value_type* __last) { + _M_insert_after_range(__pos._M_node, __first, __last); + } + void insert_after(iterator __pos, + const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + _M_splice_after_range(__pos._M_node, __first, __last); + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos, const value_type& __x = _Tp()) { +#else + iterator insert(iterator __pos, const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + return iterator(_M_insert_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), + __x)); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos) { + return iterator(_M_insert_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), + _STLP_DEFAULT_CONSTRUCTED(_Tp))); + } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void insert(iterator __pos, size_type __n, const value_type& __x) { + _M_insert_after_fill(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), __n, __x); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + // We don't need any dispatching tricks here, because _M_insert_after_range + // already does them. + template + void insert(iterator __pos, _InIter __first, _InIter __last) { +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __pos, const value_type* __first, + const value_type* __last) { + _M_insert_after_range(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), + __first, __last); + } + void insert(iterator __pos, const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + _M_splice_range(__pos._M_node, __first, __last); + } + +public: + iterator erase_after(iterator __pos) + { return iterator(this->_M_erase_after(__pos._M_node)); } + iterator erase_after(iterator __before_first, iterator __last) + { return iterator(this->_M_erase_after(__before_first._M_node, __last._M_node)); } + + iterator erase(iterator __pos) + { return iterator(this->_M_erase_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node))); } + iterator erase(iterator __first, iterator __last) + { return iterator(this->_M_erase_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __first._M_node), __last._M_node)); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type new_size, const value_type& __x = _Tp()); +#else + void resize(size_type new_size, const value_type& __x); +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type new_size) { resize(new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void clear() + { this->_M_erase_after(&this->_M_head._M_data, 0); } + +public: + // Moves the range [__before_first + 1, __before_last + 1) to *this, + // inserting it immediately after __pos. This is constant time. + void splice_after(iterator __pos, _Self& __x, + iterator __before_first, iterator __before_last) { + if (__before_first != __before_last) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _Sl_global_inst::__splice_after(__pos._M_node, + __before_first._M_node, __before_last._M_node); + } + else { + this->insert_after(__pos, iterator(__before_first._M_node->_M_next), iterator(__before_last._M_node->_M_next)); + __x.erase_after(__before_first, ++__before_last); + } + } + } + + // Moves the element that follows __prev to *this, inserting it immediately + // after __pos. This is constant time. + void splice_after(iterator __pos, _Self& __x, iterator __prev) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _Sl_global_inst::__splice_after(__pos._M_node, + __prev._M_node, __prev._M_node->_M_next); + } + else { + this->insert_after(__pos, __STATIC_CAST(_Node*, __prev._M_node->_M_next)->_M_data); + __x.erase_after(__prev); + } + } + + // Removes all of the elements from the list __x to *this, inserting + // them immediately after __pos. __x must not be *this. Complexity: + // linear in __x.size(). + void splice_after(iterator __pos, _Self& __x) { + if (this->get_allocator() == __x.get_allocator()) + _STLP_PRIV _Sl_global_inst::__splice_after(__pos._M_node, &__x._M_head._M_data); + else { + this->insert_after(__pos, __x.begin(), __x.end()); + __x.clear(); + } + } + + // Linear in distance(begin(), __pos), and linear in __x.size(). + void splice(iterator __pos, _Self& __x) { + if (__x._M_head._M_data._M_next) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _Sl_global_inst::__splice_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), + &__x._M_head._M_data, + _STLP_PRIV _Sl_global_inst::__previous(&__x._M_head._M_data, 0)); + } + else { + insert(__pos, __x.begin(), __x.end()); + __x.clear(); + } + } + } + + // Linear in distance(begin(), __pos), and in distance(__x.begin(), __i). + void splice(iterator __pos, _Self& __x, iterator __i) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _Sl_global_inst::__splice_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), + _STLP_PRIV _Sl_global_inst::__previous(&__x._M_head._M_data, __i._M_node), + __i._M_node); + } + else { + insert(__pos, *__i); + __x.erase(__i); + } + } + + // Linear in distance(begin(), __pos), in distance(__x.begin(), __first), + // and in distance(__first, __last). + void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) { + if (__first != __last) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _Sl_global_inst::__splice_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), + _STLP_PRIV _Sl_global_inst::__previous(&__x._M_head._M_data, __first._M_node), + _STLP_PRIV _Sl_global_inst::__previous(__first._M_node, __last._M_node)); + } + else { + insert(__pos, __first, __last); + __x.erase(__first, __last); + } + } + } + +public: + void reverse() { + if (this->_M_head._M_data._M_next) + this->_M_head._M_data._M_next = _STLP_PRIV _Sl_global_inst::__reverse(this->_M_head._M_data._M_next); + } + + void remove(const _Tp& __val); + + void unique() { _STLP_PRIV _Slist_unique(*this, equal_to()); } + void merge(_Self& __x) { _STLP_PRIV _Slist_merge(*this, __x, less()); } + void sort() { _STLP_PRIV _Slist_sort(*this, less()); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void remove_if(_Predicate __pred) { + _Node_base* __cur = &this->_M_head._M_data; + while (__cur->_M_next) { + if (__pred(__STATIC_CAST(_Node*, __cur->_M_next)->_M_data)) + this->_M_erase_after(__cur); + else + __cur = __cur->_M_next; + } + } + + template + void unique(_BinaryPredicate __pred) + { _STLP_PRIV _Slist_unique(*this, __pred); } + + template + void merge(_Self& __x, _StrictWeakOrdering __comp) + { _STLP_PRIV _Slist_merge(*this, __x, __comp); } + + template + void sort(_StrictWeakOrdering __comp) + { _STLP_PRIV _Slist_sort(*this, __comp); } +#endif /* _STLP_MEMBER_TEMPLATES */ +}; + +#if defined (slist) +# undef slist +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# include +#endif + +#if defined (_STLP_DEBUG) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +inline bool _STLP_CALL +operator == (const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) { + typedef typename slist<_Tp,_Alloc>::const_iterator const_iterator; + const_iterator __end1 = _SL1.end(); + const_iterator __end2 = _SL2.end(); + + const_iterator __i1 = _SL1.begin(); + const_iterator __i2 = _SL2.begin(); + while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) { + ++__i1; + ++__i2; + } + return __i1 == __end1 && __i2 == __end2; +} + +#define _STLP_EQUAL_OPERATOR_SPECIALIZED +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER slist<_Tp, _Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER +#undef _STLP_EQUAL_OPERATOR_SPECIALIZED + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > { + typedef __true_type implemented; + typedef typename __move_traits<_Alloc>::complete complete; +}; +# endif + +// Specialization of insert_iterator so that insertions will be constant +// time rather than linear time. +template +class insert_iterator > { +protected: + typedef slist<_Tp, _Alloc> _Container; + _Container* _M_container; + typename _Container::iterator _M_iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x, typename _Container::iterator __i) + : _M_container(&__x) { + if (__i == __x.begin()) + _M_iter = __x.before_begin(); + else + _M_iter = __x.previous(__i); + } + + insert_iterator<_Container>& + operator = (const typename _Container::value_type& __val) { + _M_iter = _M_container->insert_after(_M_iter, __val); + return *this; + } + + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_SLIST_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_slist_base.c b/sdk/tlibstdcxx/stlport/stl/_slist_base.c new file mode 100644 index 0000000000..e0e68c9b26 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_slist_base.c @@ -0,0 +1,104 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_SLIST_BASE_C +#define _STLP_SLIST_BASE_C + +#ifndef _STLP_INTERNAL_SLIST_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_Slist_node_base* _STLP_CALL +_Sl_global<_Dummy>::__previous(_Slist_node_base* __head, + const _Slist_node_base* __node) { + while (__head && __head->_M_next != __node) + __head = __head->_M_next; + return __head; +} + +template +void _STLP_CALL +_Sl_global<_Dummy>::__splice_after(_Slist_node_base* __pos, _Slist_node_base* __head) { + _Slist_node_base* __before_last = __previous(__head, 0); + if (__before_last != __head) { + _Slist_node_base* __after = __pos->_M_next; + __pos->_M_next = __head->_M_next; + __head->_M_next = 0; + __before_last->_M_next = __after; + } +} + +template +void _STLP_CALL +_Sl_global<_Dummy>::__splice_after(_Slist_node_base* __pos, + _Slist_node_base* __before_first, + _Slist_node_base* __before_last) { + if (__pos != __before_first && __pos != __before_last) { + _Slist_node_base* __first = __before_first->_M_next; + _Slist_node_base* __after = __pos->_M_next; + __before_first->_M_next = __before_last->_M_next; + __pos->_M_next = __first; + __before_last->_M_next = __after; + } +} + +template +_Slist_node_base* _STLP_CALL +_Sl_global<_Dummy>::__reverse(_Slist_node_base* __node) { + _Slist_node_base* __result = __node; + __node = __node->_M_next; + __result->_M_next = 0; + while(__node) { + _Slist_node_base* __next = __node->_M_next; + __node->_M_next = __result; + __result = __node; + __node = __next; + } + return __result; +} + +template +size_t _STLP_CALL +_Sl_global<_Dummy>::size(_Slist_node_base* __node) { + size_t __result = 0; + for ( ; __node != 0; __node = __node->_M_next) + ++__result; + return __result; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_SLIST_BASE_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_slist_base.h b/sdk/tlibstdcxx/stlport/stl/_slist_base.h new file mode 100644 index 0000000000..3afa18a15b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_slist_base.h @@ -0,0 +1,90 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_SLIST_BASE_H +#define _STLP_INTERNAL_SLIST_BASE_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _Slist_node_base { + _Slist_node_base* _M_next; +}; + +inline _Slist_node_base* +__slist_make_link(_Slist_node_base* __prev_node, + _Slist_node_base* __new_node) { + __new_node->_M_next = __prev_node->_M_next; + __prev_node->_M_next = __new_node; + return __new_node; +} + + +template +class _Sl_global { +public: + // those used to be global functions + // moved here to reduce code bloat without templatizing _Slist_iterator_base + static size_t _STLP_CALL size(_Slist_node_base* __node); + static _Slist_node_base* _STLP_CALL __reverse(_Slist_node_base* __node); + static void _STLP_CALL __splice_after(_Slist_node_base* __pos, + _Slist_node_base* __before_first, + _Slist_node_base* __before_last); + + static void _STLP_CALL __splice_after(_Slist_node_base* __pos, _Slist_node_base* __head); + + static _Slist_node_base* _STLP_CALL __previous(_Slist_node_base* __head, + const _Slist_node_base* __node); + static const _Slist_node_base* _STLP_CALL __previous(const _Slist_node_base* __head, + const _Slist_node_base* __node) { + return _Sl_global<_Dummy>::__previous(__CONST_CAST(_Slist_node_base*, __head), __node); + } +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _Sl_global; +#endif + +typedef _Sl_global _Sl_global_inst; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) && defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) +# include +#endif + +#endif /* _STLP_INTERNAL_SLIST_BASE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_sparc_atomic.h b/sdk/tlibstdcxx/stlport/stl/_sparc_atomic.h new file mode 100644 index 0000000000..21cc0ad030 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_sparc_atomic.h @@ -0,0 +1,61 @@ + +// Currently, SUN CC requires object file + +#if defined (__GNUC__) + +/* +** int _STLP_atomic_exchange (__stl_atomic_t *pvalue, __stl_atomic_t value) +*/ + +# if defined(__sparc_v9__) || defined (__sparcv9) + +# ifdef __arch64__ + +# define _STLP_EXCH_ASM asm volatile ("casx [%3], %4, %0 ; membar #LoadLoad | #LoadStore " : \ + "=r" (_L_value2), "=m" (*_L_pvalue1) : \ + "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) ) + +# else /* __arch64__ */ + +# define _STLP_EXCH_ASM asm volatile ("cas [%3], %4, %0" : \ + "=r" (_L_value2), "=m" (*_L_pvalue1) : \ + "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) ) +# endif + +# else /* __sparc_v9__ */ + +# define _STLP_EXCH_ASM asm volatile ("swap [%3], %0 " : \ + "=r" (_L_value2), "=m" (*_L_pvalue1) : \ + "m" (*_L_pvalue1), "r" (_L_pvalue1), "0" (_L_value2) ) +# endif + + +# define _STLP_ATOMIC_EXCHANGE(__pvalue1, __value2) \ + ({ register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \ + register __stl_atomic_t _L_value1, _L_value2 = __value2 ; \ + do { _L_value1 = *_L_pvalue1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \ + _L_value1; }) + +# define _STLP_ATOMIC_INCREMENT(__pvalue1) \ + ({ register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \ + register __stl_atomic_t _L_value1, _L_value2; \ + do { _L_value1 = *_L_pvalue1; _L_value2 = _L_value1+1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \ + (_L_value2 + 1); }) + +# define _STLP_ATOMIC_DECREMENT(__pvalue1) \ + ({ register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \ + register __stl_atomic_t _L_value1, _L_value2; \ + do { _L_value1 = *_L_pvalue1; _L_value2 = _L_value1-1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \ + (_L_value2 - 1); }) + +# elif ! defined (_STLP_NO_EXTERN_INLINE) + +extern "C" __stl_atomic_t _STLP_atomic_exchange(__stl_atomic_t * __x, __stl_atomic_t __v); +extern "C" void _STLP_atomic_decrement(__stl_atomic_t* i); +extern "C" void _STLP_atomic_increment(__stl_atomic_t* i); + +# define _STLP_ATOMIC_INCREMENT(__x) _STLP_atomic_increment((__stl_atomic_t*)__x) +# define _STLP_ATOMIC_DECREMENT(__x) _STLP_atomic_decrement((__stl_atomic_t*)__x) +# define _STLP_ATOMIC_EXCHANGE(__x, __y) _STLP_atomic_exchange((__stl_atomic_t*)__x, (__stl_atomic_t)__y) + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_sstream.c b/sdk/tlibstdcxx/stlport/stl/_sstream.c new file mode 100644 index 0000000000..9f585351e1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_sstream.c @@ -0,0 +1,465 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_SSTREAM_C +#define _STLP_SSTREAM_C + +#ifndef _STLP_INTERNAL_SSTREAM +# include +#endif + +#if defined ( _STLP_NESTED_TYPE_PARAM_BUG ) +// no wint_t is supported for this mode +# define __BSB_int_type__ int +# define __BSB_pos_type__ streampos +#else +# define __BSB_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::int_type +# define __BSB_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// Non-inline stringbuf member functions. + +// Constructors. Note that the base class constructor sets all of the +// get and area pointers to null. + +template +basic_stringbuf<_CharT, _Traits, _Alloc> + ::basic_stringbuf(ios_base::openmode __mode) + : basic_streambuf<_CharT, _Traits>(), _M_mode(__mode), _M_str() +{} + +template +basic_stringbuf<_CharT, _Traits, _Alloc> + ::basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __s, ios_base::openmode __mode) + : basic_streambuf<_CharT, _Traits>(), _M_mode(__mode), _M_str(__s) +{ + _M_set_ptrs(); +} + +template +basic_stringbuf<_CharT, _Traits, _Alloc>::~basic_stringbuf() +{} + +// Set the underlying string to a new value. +template +void +basic_stringbuf<_CharT, _Traits, _Alloc>::str(const basic_string<_CharT, _Traits, _Alloc>& __s) +{ + _M_str = __s; + _M_set_ptrs(); +} + +template +void +basic_stringbuf<_CharT, _Traits, _Alloc>::_M_set_ptrs() +{ + _CharT* __data_ptr = _S_start(_M_str); + _CharT* __data_end = _S_finish(_M_str); + // The initial read position is the beginning of the string. + if (_M_mode & ios_base::in) { + this->setg(__data_ptr, (_M_mode & ios_base::ate) ? __data_end : __data_ptr, __data_end); + } + + // The initial write position is the beginning of the string. + if (_M_mode & ios_base::out) { + if ( _M_mode & (ios_base::app | ios_base::ate) ) { + this->setp( __data_end, __data_end ); + } else { + this->setp( __data_ptr, __data_end ); + this->pbump((int)_M_str.size()); // initial write position, if we initialized with string + } + // this->setp((_M_mode & (ios_base::app | ios_base::ate))? __data_end : __data_ptr, __data_end); + } +} + +// Precondition: gptr() >= egptr(). Returns a character, if one is available. +template +__BSB_int_type__ +basic_stringbuf<_CharT, _Traits, _Alloc>::underflow() { + return this->gptr() != this->egptr() + ? _Traits::to_int_type(*this->gptr()) + : _Traits::eof(); +} + +// Precondition: gptr() >= egptr(). +template +__BSB_int_type__ +basic_stringbuf<_CharT, _Traits, _Alloc>::uflow() { + if (this->gptr() != this->egptr()) { + int_type __c = _Traits::to_int_type(*this->gptr()); + this->gbump(1); + return __c; + } + else + return _Traits::eof(); +} + +template +__BSB_int_type__ +basic_stringbuf<_CharT, _Traits, _Alloc>::pbackfail(int_type __c) { + if (this->gptr() != this->eback()) { + if (!_Traits::eq_int_type(__c, _Traits::eof())) { + if (_Traits::eq(_Traits::to_char_type(__c), this->gptr()[-1])) { + this->gbump(-1); + return __c; + } + else if (_M_mode & ios_base::out) { + this->gbump(-1); + *this->gptr() = _Traits::to_char_type(__c); + return __c; + } + else + return _Traits::eof(); + } + else { + this->gbump(-1); + return _Traits::not_eof(__c); + } + } + else + return _Traits::eof(); +} + +template +__BSB_int_type__ basic_stringbuf<_CharT, _Traits, _Alloc>::overflow(int_type __c) +{ + if (!_Traits::eq_int_type(__c, _Traits::eof())) { + if (_M_mode & ios_base::out) { + if ( this->pptr() < this->epptr() ) { // just put back in any case + _M_str.push_back( _Traits::to_char_type(__c) ); + this->pbump(1); + } else if ( _M_mode & ios_base::in ) { + ptrdiff_t __offset = this->gptr() - this->eback(); + _M_str.push_back(_Traits::to_char_type(__c)); + _CharT* __data_ptr = _S_start(_M_str); + this->setg(__data_ptr, __data_ptr + __offset, _S_finish(_M_str)); + this->setp(__data_ptr, _S_finish(_M_str)); + this->pbump((int)_M_str.size()); + } else { + _M_str.push_back( _Traits::to_char_type(__c) ); + this->setp(_S_start(_M_str), _S_finish(_M_str)); + this->pbump((int)_M_str.size()); + } + return __c; + } + return _Traits::eof(); // Overflow always fails if it's read-only + } + return _Traits::not_eof(__c); // __c is EOF, so we don't have to do anything +} + +template +streamsize +basic_stringbuf<_CharT, _Traits, _Alloc>::xsputn(const char_type* __s, + streamsize __n) { + streamsize __nwritten = 0; + + if ((_M_mode & ios_base::out) && __n > 0) { + // If the put pointer is somewhere in the middle of the string, + // then overwrite instead of append. + if ( !_M_str.empty() && this->pbase() == _S_start(_M_str)) { + ptrdiff_t __avail = _S_finish(_M_str) - this->pptr(); + if (__avail > __n) { + _Traits::copy(this->pptr(), __s, __STATIC_CAST(size_t, __n)); + this->pbump((int)__n); + return __n; + } else { + _Traits::copy(this->pptr(), __s, __avail); + __nwritten += __avail; + __n -= __avail; + __s += __avail; + } + } + + // At this point we know we're appending. + _CharT* __data_ptr; + if (_M_mode & ios_base::in) { + ptrdiff_t __get_offset = this->gptr() - this->eback(); + _M_str.append(__s, __s + __STATIC_CAST(ptrdiff_t, __n)); + __data_ptr = _S_start(_M_str); + this->setg(__data_ptr, __data_ptr + __get_offset, _S_finish(_M_str)); + } else { + _M_str.append(__s, __s + __STATIC_CAST(ptrdiff_t, __n)); + __data_ptr = _S_start(_M_str); + } + + this->setp(__data_ptr, _S_finish(_M_str)); + this->pbump((int)_M_str.size()); + __nwritten += __n; + } + + return __nwritten; +} + +template +streamsize +basic_stringbuf<_CharT, _Traits, _Alloc>::_M_xsputnc(char_type __c, + streamsize __n) { + streamsize __nwritten = 0; + + if ((_M_mode & ios_base::out) && __n > 0) { + // If the put pointer is somewhere in the middle of the string, + // then overwrite instead of append. + if (this->pbase() == _S_start(_M_str)) { + ptrdiff_t __avail = _S_finish(_M_str) - this->pptr(); + if (__avail > __n) { + _Traits::assign(this->pptr(), __STATIC_CAST(size_t, __n), __c); + this->pbump(__STATIC_CAST(int, __n)); + return __n; + } + else { + _Traits::assign(this->pptr(), __avail, __c); + __nwritten += __avail; + __n -= __avail; + } + } + + // At this point we know we're appending. + size_t __app_size = sizeof(streamsize) > sizeof(size_t) ? __STATIC_CAST(size_t, (min)(__n, __STATIC_CAST(streamsize, _M_str.max_size()))) + : __STATIC_CAST(size_t, __n); + _CharT* __data_ptr; + if (this->_M_mode & ios_base::in) { + ptrdiff_t __get_offset = this->gptr() - this->eback(); + _M_str.append(__app_size, __c); + __data_ptr = _S_start(_M_str); + this->setg(__data_ptr, __data_ptr + __get_offset, _S_finish(_M_str)); + } else { + _M_str.append(__app_size, __c); + __data_ptr = _S_start(_M_str); + } + + this->setp(__data_ptr, _S_finish(_M_str)); + this->pbump((int)_M_str.size()); + __nwritten += __app_size; + } + + return __nwritten; +} + +// According to the C++ standard the effects of setbuf are implementation +// defined, except that setbuf(0, 0) has no effect. In this implementation, +// setbuf(, n), for n > 0, calls reserve(n) on the underlying +// string. +template +basic_streambuf<_CharT, _Traits>* +basic_stringbuf<_CharT, _Traits, _Alloc>::setbuf(_CharT*, streamsize __n) { + if (__n > 0) { + bool __do_get_area = false; + bool __do_put_area = false; + ptrdiff_t __offg = 0; + ptrdiff_t __offp = 0; + + if (this->pbase() == _S_start(_M_str)) { + __do_put_area = true; + __offp = this->pptr() - this->pbase(); + } + + if (this->eback() == _S_start(_M_str)) { + __do_get_area = true; + __offg = this->gptr() - this->eback(); + } + + _M_str.reserve(sizeof(streamsize) > sizeof(size_t) ? __STATIC_CAST(size_t, (min)(__n, __STATIC_CAST(streamsize, _M_str.max_size()))) + : __STATIC_CAST(size_t, __n)); + + _CharT* __data_ptr = _S_start(_M_str); + + if (__do_get_area) { + this->setg(__data_ptr, __data_ptr + __offg, _S_finish(_M_str)); + } + + if (__do_put_area) { + this->setp(__data_ptr, _S_finish(_M_str)); + this->pbump((int)__offp); + } + } + + return this; +} + +template +__BSB_pos_type__ +basic_stringbuf<_CharT, _Traits, _Alloc> + ::seekoff(off_type __off, + ios_base::seekdir __dir, + ios_base::openmode __mode) { + __mode &= _M_mode; + + bool __imode = (__mode & ios_base::in) != 0; + bool __omode = (__mode & ios_base::out) != 0; + + if ( !(__imode || __omode) ) + return pos_type(off_type(-1)); + + if ( (__imode && (this->gptr() == 0)) || (__omode && (this->pptr() == 0)) ) + return pos_type(off_type(-1)); + + streamoff __newoff; + switch(__dir) { + case ios_base::beg: + __newoff = 0; + break; + case ios_base::end: + __newoff = _M_str.size(); + break; + case ios_base::cur: + __newoff = __imode ? this->gptr() - this->eback() : this->pptr() - this->pbase(); + if ( __off == 0 ) { + return pos_type(__newoff); + } + break; + default: + return pos_type(off_type(-1)); + } + + __off += __newoff; + + if (__imode) { + ptrdiff_t __n = this->egptr() - this->eback(); + + if (__off < 0 || __off > __n) + return pos_type(off_type(-1)); + this->setg(this->eback(), this->eback() + __STATIC_CAST(ptrdiff_t, __off), + this->eback() + __STATIC_CAST(ptrdiff_t, __n)); + } + + if (__omode) { + ptrdiff_t __n = this->epptr() - this->pbase(); + + if (__off < 0 || __off > __n) + return pos_type(off_type(-1)); + this->setp(this->pbase(), this->pbase() + __n); + this->pbump((int)__off); + } + + return pos_type(__off); +} + +template +__BSB_pos_type__ +basic_stringbuf<_CharT, _Traits, _Alloc> + ::seekpos(pos_type __pos, ios_base::openmode __mode) { + __mode &= _M_mode; + + bool __imode = (__mode & ios_base::in) != 0; + bool __omode = (__mode & ios_base::out) != 0; + + if ( !(__imode || __omode) ) + return pos_type(off_type(-1)); + + if ( (__imode && (this->gptr() == 0)) || (__omode && (this->pptr() == 0)) ) + return pos_type(off_type(-1)); + + const off_type __n = __pos - pos_type(off_type(0)); + + if (__imode) { + if (__n < 0 || __n > this->egptr() - this->eback()) + return pos_type(off_type(-1)); + this->setg(this->eback(), this->eback() + __STATIC_CAST(ptrdiff_t, __n), this->egptr()); + } + + if (__omode) { + if (__n < 0 || size_t(__n) > _M_str.size()) + return pos_type(off_type(-1)); + + this->setp(_S_start(_M_str), _S_finish(_M_str)); + this->pbump((int)__n); + } + + return __pos; +} + +//---------------------------------------------------------------------- +// Non-inline istringstream member functions. + +template +basic_istringstream<_CharT, _Traits, _Alloc> + ::basic_istringstream(ios_base::openmode __mode) + : basic_istream<_CharT, _Traits>(0), + _M_buf(__mode | ios_base::in) { + this->init(&_M_buf); +} + +template +basic_istringstream<_CharT, _Traits, _Alloc> + ::basic_istringstream(const _String& __str,ios_base::openmode __mode) + : basic_istream<_CharT, _Traits>(0), + _M_buf(__str, __mode | ios_base::in) { + this->init(&_M_buf); +} + +template +basic_istringstream<_CharT, _Traits, _Alloc>::~basic_istringstream() +{} + +//---------------------------------------------------------------------- +// Non-inline ostringstream member functions. + +template +basic_ostringstream<_CharT, _Traits, _Alloc> + ::basic_ostringstream(ios_base::openmode __mode) + : basic_ostream<_CharT, _Traits>(0), + _M_buf(__mode | ios_base::out) { + this->init(&_M_buf); +} + +template +basic_ostringstream<_CharT, _Traits, _Alloc> + ::basic_ostringstream(const _String& __str, ios_base::openmode __mode) + : basic_ostream<_CharT, _Traits>(0), + _M_buf(__str, __mode | ios_base::out) { + this->init(&_M_buf); +} + +template +basic_ostringstream<_CharT, _Traits, _Alloc>::~basic_ostringstream() +{} + +//---------------------------------------------------------------------- +// Non-inline stringstream member functions. + +template +basic_stringstream<_CharT, _Traits, _Alloc> + ::basic_stringstream(ios_base::openmode __mode) + : basic_iostream<_CharT, _Traits>(0), _M_buf(__mode) { + this->init(&_M_buf); +} + +template +basic_stringstream<_CharT, _Traits, _Alloc> + ::basic_stringstream(const _String& __str, ios_base::openmode __mode) + : basic_iostream<_CharT, _Traits>(0), _M_buf(__str, __mode) { + this->init(&_M_buf); +} + +template +basic_stringstream<_CharT, _Traits, _Alloc>::~basic_stringstream() +{} + +_STLP_END_NAMESPACE + +# undef __BSB_int_type__ +# undef __BSB_pos_type__ + +#endif /* _STLP_SSTREAM_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_sstream.h b/sdk/tlibstdcxx/stlport/stl/_sstream.h new file mode 100644 index 0000000000..9e8d02a64a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_sstream.h @@ -0,0 +1,266 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +// This header defines classes basic_stringbuf, basic_istringstream, +// basic_ostringstream, and basic_stringstream. These classes +// represent streamsbufs and streams whose sources or destinations are +// C++ strings. + +#ifndef _STLP_INTERNAL_SSTREAM +#define _STLP_INTERNAL_SSTREAM + +#ifndef _STLP_INTERNAL_STREAMBUF +# include +#endif + +#ifndef _STLP_INTERNAL_ISTREAM +# include // Includes , , +#endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// This version of basic_stringbuf relies on the internal details of +// basic_string. It relies on the fact that, in this implementation, +// basic_string's iterators are pointers. It also assumes (as allowed +// by the standard) that _CharT is a POD type. + +// We have a very small buffer for the put area, just so that we don't +// have to use append() for every sputc. Conceptually, the buffer +// immediately follows the end of the underlying string. We use this +// buffer when appending to write-only streambufs, but we don't use it +// for read-write streambufs. + +template +class basic_stringbuf : public basic_streambuf<_CharT, _Traits> { +public: // Typedefs. + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef basic_streambuf<_CharT, _Traits> _Base; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Self; + typedef basic_string<_CharT, _Traits, _Alloc> _String; + +public: // Constructors, destructor. + explicit basic_stringbuf(ios_base::openmode __mode + = ios_base::in | ios_base::out); + explicit basic_stringbuf(const _String& __s, ios_base::openmode __mode + = ios_base::in | ios_base::out); + virtual ~basic_stringbuf(); + +public: // Get or set the string. + _String str() const { return _M_str; } + void str(const _String& __s); + +protected: // Overridden virtual member functions. + virtual int_type underflow(); + virtual int_type uflow(); + virtual int_type pbackfail(int_type __c); + virtual int_type overflow(int_type __c); + int_type pbackfail() {return pbackfail(_Traits::eof());} + int_type overflow() {return overflow(_Traits::eof());} + + virtual streamsize xsputn(const char_type* __s, streamsize __n); + virtual streamsize _M_xsputnc(char_type __c, streamsize __n); + + virtual _Base* setbuf(_CharT* __buf, streamsize __n); + virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, + ios_base::openmode __mode + = ios_base::in | ios_base::out); + virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode + = ios_base::in | ios_base::out); + +private: // Helper functions. + void _M_set_ptrs(); + static _CharT* _S_start(const _String& __str) { return __CONST_CAST(_CharT*, __str.data()); } + static _CharT* _S_finish(const _String& __str) { return __CONST_CAST(_CharT*, __str.data()) + __str.size(); } + +private: + ios_base::openmode _M_mode; + _String _M_str; +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_stringbuf, allocator >; +# if !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_stringbuf, allocator >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +//---------------------------------------------------------------------- +// Class basic_istringstream, an input stream that uses a stringbuf. + +template +class basic_istringstream : public basic_istream<_CharT, _Traits> { +public: // Typedefs + typedef typename _Traits::char_type char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef basic_ios<_CharT, _Traits> _Basic_ios; + typedef basic_istream<_CharT, _Traits> _Base; + typedef basic_string<_CharT, _Traits, _Alloc> _String; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Buf; + +public: // Constructors, destructor. + basic_istringstream(ios_base::openmode __mode = ios_base::in); + basic_istringstream(const _String& __str, + ios_base::openmode __mode = ios_base::in); + ~basic_istringstream(); + +public: // Member functions + + basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const + { return __CONST_CAST(_Buf*,&_M_buf); } + + _String str() const { return _M_buf.str(); } + void str(const _String& __s) { _M_buf.str(__s); } + +private: + basic_stringbuf<_CharT, _Traits, _Alloc> _M_buf; + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + typedef basic_istringstream<_CharT, _Traits> _Self; + //explicitely defined as private to avoid warnings: + basic_istringstream(_Self const&); + _Self& operator = (_Self const&); +#endif +}; + + +//---------------------------------------------------------------------- +// Class basic_ostringstream, an output stream that uses a stringbuf. + +template +class basic_ostringstream : public basic_ostream<_CharT, _Traits> { +public: // Typedefs + typedef typename _Traits::char_type char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef basic_ios<_CharT, _Traits> _Basic_ios; + typedef basic_ostream<_CharT, _Traits> _Base; + typedef basic_string<_CharT, _Traits, _Alloc> _String; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Buf; + +public: // Constructors, destructor. + basic_ostringstream(ios_base::openmode __mode = ios_base::out); + basic_ostringstream(const _String& __str, + ios_base::openmode __mode = ios_base::out); + ~basic_ostringstream(); + +public: // Member functions. + + basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const + { return __CONST_CAST(_Buf*,&_M_buf); } + + _String str() const { return _M_buf.str(); } + void str(const _String& __s) { _M_buf.str(__s); } // dwa 02/07/00 - BUG STOMPER DAVE + + +private: + basic_stringbuf<_CharT, _Traits, _Alloc> _M_buf; + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + typedef basic_ostringstream<_CharT, _Traits> _Self; + //explicitely defined as private to avoid warnings: + basic_ostringstream(_Self const&); + _Self& operator = (_Self const&); +#endif +}; + + +//---------------------------------------------------------------------- +// Class basic_stringstream, a bidirectional stream that uses a stringbuf. + +template +class basic_stringstream : public basic_iostream<_CharT, _Traits> { +public: // Typedefs + typedef typename _Traits::char_type char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + typedef basic_ios<_CharT, _Traits> _Basic_ios; + typedef basic_iostream<_CharT, _Traits> _Base; + typedef basic_string<_CharT, _Traits, _Alloc> _String; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Buf; + + typedef ios_base::openmode openmode; + +public: // Constructors, destructor. + basic_stringstream(openmode __mod = ios_base::in | ios_base::out); + basic_stringstream(const _String& __str, + openmode __mod = ios_base::in | ios_base::out); + ~basic_stringstream(); + +public: // Member functions. + + basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const + { return __CONST_CAST(_Buf*,&_M_buf); } + + _String str() const { return _M_buf.str(); } + void str(const _String& __s) { _M_buf.str(__s); } + +private: + basic_stringbuf<_CharT, _Traits, _Alloc> _M_buf; + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + typedef basic_stringstream<_CharT, _Traits> _Self; + //explicitely defined as private to avoid warnings: + basic_stringstream(_Self const&); + _Self& operator = (_Self const&); +#endif +}; + + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_istringstream, allocator >; +_STLP_EXPORT_TEMPLATE_CLASS basic_ostringstream, allocator >; +_STLP_EXPORT_TEMPLATE_CLASS basic_stringstream, allocator >; +# if !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_istringstream, allocator >; +_STLP_EXPORT_TEMPLATE_CLASS basic_ostringstream, allocator >; +_STLP_EXPORT_TEMPLATE_CLASS basic_stringstream, allocator >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_SSTREAM */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_stack.h b/sdk/tlibstdcxx/stlport/stl/_stack.h new file mode 100644 index 0000000000..7ea9d59afb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_stack.h @@ -0,0 +1,133 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_STACK_H +#define _STLP_INTERNAL_STACK_H + +#ifndef _STLP_INTERNAL_DEQUE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if !defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) +template > +#elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS ) +# define _STLP_STACK_ARGS _Tp +template +#else +template +#endif +class stack +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) +# if defined (_STLP_STACK_ARGS) + : public __stlport_class > +# else + : public __stlport_class > +# endif +#endif +{ +#ifdef _STLP_STACK_ARGS + typedef deque<_Tp> _Sequence; + typedef stack<_Tp> _Self; +#else + typedef stack<_Tp, _Sequence> _Self; +#endif + +public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; +protected: + //c is a Standard name (23.2.3.3), do no make it STLport naming convention compliant. + _Sequence c; +public: + stack() : c() {} + explicit stack(const _Sequence& __s) : c(__s) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + stack(__move_source<_Self> src) + : c(_STLP_PRIV _AsMoveSource(src.get().c)) {} +#endif + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + reference top() { return c.back(); } + const_reference top() const { return c.back(); } + void push(const value_type& __x) { c.push_back(__x); } + void pop() { c.pop_back(); } + const _Sequence& _Get_s() const { return c; } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { + _Sequence __tmp = c; + c = __x.c; + __x.c = __tmp; + } +#endif +}; + +#ifndef _STLP_STACK_ARGS +# define _STLP_STACK_ARGS _Tp, _Sequence +# define _STLP_STACK_HEADER_ARGS class _Tp, class _Sequence +#else +# define _STLP_STACK_HEADER_ARGS class _Tp +#endif + +template < _STLP_STACK_HEADER_ARGS > +inline bool _STLP_CALL operator==(const stack< _STLP_STACK_ARGS >& __x, + const stack< _STLP_STACK_ARGS >& __y) +{ return __x._Get_s() == __y._Get_s(); } + +template < _STLP_STACK_HEADER_ARGS > +inline bool _STLP_CALL operator<(const stack< _STLP_STACK_ARGS >& __x, + const stack< _STLP_STACK_ARGS >& __y) +{ return __x._Get_s() < __y._Get_s(); } + +_STLP_RELOPS_OPERATORS(template < _STLP_STACK_HEADER_ARGS >, stack< _STLP_STACK_ARGS >) + +#undef _STLP_STACK_ARGS +#undef _STLP_STACK_HEADER_ARGS + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > : + _STLP_PRIV __move_traits_aux<_Sequence> +{}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_STACK_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_stdexcept.h b/sdk/tlibstdcxx/stlport/stl/_stdexcept.h new file mode 100644 index 0000000000..8c784bb990 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_stdexcept.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_STDEXCEPT +#define _STLP_INTERNAL_STDEXCEPT + +#ifndef _STLP_INTERNAL_STDEXCEPT_BASE +# include +#endif + +#if !defined (_STLP_USE_NATIVE_STDEXCEPT) || defined (_STLP_USE_OWN_NAMESPACE) + +# if defined(_STLP_USE_EXCEPTIONS) || \ + !(defined(_MIPS_SIM) && defined(_ABIO32) && (_MIPS_SIM == _ABIO32)) + +_STLP_BEGIN_NAMESPACE + +class _STLP_CLASS_DECLSPEC logic_error : public __Named_exception { +public: + logic_error(const string& __s) : __Named_exception(__s) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~logic_error() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC runtime_error : public __Named_exception { +public: + runtime_error(const string& __s) : __Named_exception(__s) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~runtime_error() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC domain_error : public logic_error { +public: + domain_error(const string& __arg) : logic_error(__arg) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~domain_error() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC invalid_argument : public logic_error { +public: + invalid_argument(const string& __arg) : logic_error(__arg) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~invalid_argument() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC length_error : public logic_error { +public: + length_error(const string& __arg) : logic_error(__arg) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~length_error() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC out_of_range : public logic_error { +public: + out_of_range(const string& __arg) : logic_error(__arg) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~out_of_range() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC range_error : public runtime_error { +public: + range_error(const string& __arg) : runtime_error(__arg) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~range_error() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC overflow_error : public runtime_error { +public: + overflow_error(const string& __arg) : runtime_error(__arg) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~overflow_error() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +class _STLP_CLASS_DECLSPEC underflow_error : public runtime_error { +public: + underflow_error(const string& __arg) : runtime_error(__arg) {} +# ifndef _STLP_USE_NO_IOSTREAMS + ~underflow_error() _STLP_NOTHROW_INHERENTLY; +# endif +}; + +_STLP_END_NAMESPACE + +# endif +#endif + +#endif /* _STLP_INTERNAL_STDEXCEPT */ diff --git a/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.c b/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.c new file mode 100644 index 0000000000..deb705637f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.c @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +__Named_exception::__Named_exception(const string& __str) { + size_t __size = strlen(_STLP_PRIV __get_c_string(__str)) + 1; + if (__size > _S_bufsize) { + _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char))); + if (!_M_name) { + __size = _S_bufsize; + _M_name = _M_static_name; + } + else { + *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char); + } + } + else { + _M_name = _M_static_name; + } +#if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) + strncpy(_M_name, _STLP_PRIV __get_c_string(__str), __size - 1); + _M_name[__size - 1] = '\0'; +#else + strncpy_s(_M_name, __size, _STLP_PRIV __get_c_string(__str), __size - 1); +#endif +} + +__Named_exception::__Named_exception(const __Named_exception& __x) { + size_t __size = strlen(__x._M_name) + 1; + if (__size > _S_bufsize) { + _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char))); + if (!_M_name) { + __size = _S_bufsize; + _M_name = _M_static_name; + } + else { + *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char); + } + } + else { + _M_name = _M_static_name; + } +#if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) + strncpy(_M_name, __x._M_name, __size - 1); + _M_name[__size - 1] = '\0'; +#else + strncpy_s(_M_name, __size, __x._M_name, __size - 1); +#endif +} + +__Named_exception& __Named_exception::operator = (const __Named_exception& __x) { + size_t __size = strlen(__x._M_name) + 1; + size_t __buf_size = _M_name != _M_static_name ? *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) : _S_bufsize; + if (__size > __buf_size) { + // Being here necessarily mean that we need to allocate a buffer: + if (_M_name != _M_static_name) free(_M_name); + _M_name = __STATIC_CAST(char*, malloc(__size * sizeof(char))); + if (!_M_name) { + __size = _S_bufsize; + _M_name = _M_static_name; + } + else { + *(__REINTERPRET_CAST(size_t*, &_M_static_name[0])) = __size * sizeof(char); + } + } +#if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) + strncpy(_M_name, __x._M_name, __size - 1); + _M_name[__size - 1] = '\0'; +#else + strncpy_s(_M_name, __size, __x._M_name, __size - 1); +#endif + return *this; +} + +__Named_exception::~__Named_exception() _STLP_NOTHROW_INHERENTLY { + if (_M_name != _M_static_name) + free(_M_name); +} + +const char* __Named_exception::what() const _STLP_NOTHROW_INHERENTLY +{ return _M_name; } diff --git a/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.h b/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.h new file mode 100644 index 0000000000..cf8d198694 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_stdexcept_base.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_STDEXCEPT_BASE +#define _STLP_INTERNAL_STDEXCEPT_BASE + +#if !defined (_STLP_USE_NATIVE_STDEXCEPT) || defined (_STLP_USE_OWN_NAMESPACE) + +# ifndef _STLP_INTERNAL_EXCEPTION +# include +# endif + +# if defined(_STLP_USE_EXCEPTIONS) || \ + !(defined(_MIPS_SIM) && defined(_ABIO32) && (_MIPS_SIM == _ABIO32)) + +# ifndef _STLP_INTERNAL_CSTRING +# include +# endif + +# ifndef _STLP_STRING_FWD_H +# include +# endif + +# ifndef _STLP_USE_NO_IOSTREAMS +# define _STLP_OWN_STDEXCEPT 1 +# endif + +_STLP_BEGIN_NAMESPACE + +/* We disable the 4275 warning for + * - WinCE where there are only static version of the native C++ runtime. + * - The MSVC compilers when the STLport user wants to make an STLport dll linked to + * the static C++ native runtime. In this case the std::exception base class is no more + * exported from native dll but is used as a base class for the exported __Named_exception + * class. + */ +# if defined (_STLP_WCE_NET) || \ + defined (_STLP_USE_DYNAMIC_LIB) && defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# define _STLP_DO_WARNING_POP +# pragma warning (push) +# pragma warning (disable: 4275) // Non dll interface class 'exception' used as base + // for dll-interface class '__Named_exception' +# endif + +# if !defined (_STLP_NO_EXCEPTION_HEADER) +# if !defined (_STLP_EXCEPTION_BASE) && !defined (_STLP_BROKEN_EXCEPTION_CLASS) && \ + defined (_STLP_USE_NAMESPACES) && defined (_STLP_USE_OWN_NAMESPACE) +using _STLP_VENDOR_EXCEPT_STD::exception; +# endif +# endif +# define _STLP_EXCEPTION_BASE exception + +class _STLP_CLASS_DECLSPEC __Named_exception : public _STLP_EXCEPTION_BASE { +public: + __Named_exception(const string& __str); + __Named_exception(const __Named_exception&); + __Named_exception& operator = (const __Named_exception&); + + const char* what() const _STLP_NOTHROW_INHERENTLY; + ~__Named_exception() _STLP_NOTHROW_INHERENTLY; + +private: + enum { _S_bufsize = 256 }; + char _M_static_name[_S_bufsize]; + char *_M_name; +}; + +# if defined (_STLP_USE_NO_IOSTREAMS) && defined (__BUILDING_STLPORT) + // if not linking to the lib, expose implementation of members here +# include +# endif + +# if defined (_STLP_DO_WARNING_POP) +# pragma warning (pop) +# undef _STLP_DO_WARNING_POP +# endif + +_STLP_END_NAMESPACE + +# endif /* Not o32, and no exceptions */ +#endif /* _STLP_STDEXCEPT_SEEN */ + +#endif /* _STLP_INTERNAL_STDEXCEPT_BASE */ diff --git a/sdk/tlibstdcxx/stlport/stl/_stlport_version.h b/sdk/tlibstdcxx/stlport/stl/_stlport_version.h new file mode 100644 index 0000000000..587651de41 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_stlport_version.h @@ -0,0 +1,30 @@ + /* + * + * Copyright (c) 2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STLPORT_VERSION_H +#define _STLP_STLPORT_VERSION_H + +/* The last SGI STL release we merged with */ +#define __SGI_STL 0x330 + +/* STLport version */ +#define _STLPORT_MAJOR 5 +#define _STLPORT_MINOR 2 +#define _STLPORT_PATCHLEVEL 1 + +#define _STLPORT_VERSION 0x521 + +#endif /* _STLP_STLPORT_VERSION_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/_stream_iterator.h b/sdk/tlibstdcxx/stlport/stl/_stream_iterator.h new file mode 100644 index 0000000000..aa26ae3517 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_stream_iterator.h @@ -0,0 +1,253 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#if !defined (_STLP_INTERNAL_STREAM_ITERATOR_H) && !defined (_STLP_USE_NO_IOSTREAMS) +#define _STLP_INTERNAL_STREAM_ITERATOR_H + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +#endif + +// streambuf_iterators predeclarations must appear first +#ifndef _STLP_INTERNAL_IOSFWD +# include +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_ISTREAM +# include +#endif + +// istream_iterator and ostream_iterator look very different if we're +// using new, templatized iostreams than if we're using the old cfront +// version. + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +# define __ISI_TMPL_HEADER_ARGUMENTS class _Tp, class _CharT, class _Traits, class _Dist +# define __ISI_TMPL_ARGUMENTS _Tp, _CharT, _Traits, _Dist +template , + class _Dist = ptrdiff_t> +class istream_iterator : public iterator { +#else +# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_DEFAULT_TYPE_PARAM) +# define __ISI_TMPL_HEADER_ARGUMENTS class _Tp +# define __ISI_TMPL_ARGUMENTS _Tp +template +class istream_iterator : public iterator { +# else +# define __ISI_TMPL_HEADER_ARGUMENTS class _Tp, class _Dist +# define __ISI_TMPL_ARGUMENTS _Tp, _Dist +template +class istream_iterator : public iterator { +# endif /* _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS */ +#endif /* _STLP_LIMITED_DEFAULT_TEMPLATES */ + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) + typedef char _CharT; + typedef char_traits _Traits; +# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_DEFAULT_TYPE_PARAM) + typedef ptrdiff_t _Dist; +# endif +#endif + + typedef istream_iterator< __ISI_TMPL_ARGUMENTS > _Self; +public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_istream<_CharT, _Traits> istream_type; + + typedef input_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Dist difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + + istream_iterator() : _M_stream(0), _M_ok(false), _M_read_done(true) {} + istream_iterator(istream_type& __s) : _M_stream(&__s), _M_ok(false), _M_read_done(false) {} + + reference operator*() const { + if (!_M_read_done) { + _M_read(); + } + return _M_value; + } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + _M_read(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + _M_read(); + return __tmp; + } + + bool _M_equal(const _Self& __x) const { + if (!_M_read_done) { + _M_read(); + } + if (!__x._M_read_done) { + __x._M_read(); + } + return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); + } + +private: + istream_type* _M_stream; + mutable _Tp _M_value; + mutable bool _M_ok; + mutable bool _M_read_done; + + void _M_read() const { + _STLP_MUTABLE(_Self, _M_ok) = ((_M_stream != 0) && !_M_stream->fail()); + if (_M_ok) { + *_M_stream >> _STLP_MUTABLE(_Self, _M_value); + _STLP_MUTABLE(_Self, _M_ok) = !_M_stream->fail(); + } + _STLP_MUTABLE(_Self, _M_read_done) = true; + } +}; + +#if !defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template > +#else +template +#endif +class ostream_iterator: public iterator { +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) + typedef char _CharT; + typedef char_traits _Traits; + typedef ostream_iterator<_TpP> _Self; +#else + typedef ostream_iterator<_TpP, _CharT, _Traits> _Self; +#endif +public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + + typedef output_iterator_tag iterator_category; + + ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {} + ostream_iterator(ostream_type& __s, const _CharT* __c) + : _M_stream(&__s), _M_string(__c) {} + _Self& operator=(const _TpP& __val) { + *_M_stream << __val; + if (_M_string) *_M_stream << _M_string; + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self& operator++(int) { return *this; } +private: + ostream_type* _M_stream; + const _CharT* _M_string; +}; + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +# if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +inline output_iterator_tag _STLP_CALL +iterator_category(const ostream_iterator<_TpP>&) { return output_iterator_tag(); } +# else +template +inline output_iterator_tag _STLP_CALL +iterator_category(const ostream_iterator<_TpP, _CharT, _Traits>&) { return output_iterator_tag(); } +# endif +#endif + +_STLP_END_NAMESPACE + +// form-independent definiotion of stream iterators +_STLP_BEGIN_NAMESPACE + +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline bool _STLP_CALL +operator==(const istream_iterator< __ISI_TMPL_ARGUMENTS >& __x, + const istream_iterator< __ISI_TMPL_ARGUMENTS >& __y) +{ return __x._M_equal(__y); } + +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline bool _STLP_CALL +operator!=(const istream_iterator< __ISI_TMPL_ARGUMENTS >& __x, + const istream_iterator< __ISI_TMPL_ARGUMENTS >& __y) +{ return !__x._M_equal(__y); } +#endif + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline input_iterator_tag _STLP_CALL +iterator_category(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) +{ return input_iterator_tag(); } +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline _Tp* _STLP_CALL +value_type(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) { return (_Tp*) 0; } + +# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_DEFAULT_TYPE_PARAM) +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline ptrdiff_t* _STLP_CALL +distance_type(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) { return (ptrdiff_t*)0; } +# else +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline _Dist* _STLP_CALL +distance_type(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) { return (_Dist*)0; } +# endif /* _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS */ +#endif + +_STLP_END_NAMESPACE + +#undef __ISI_TMPL_HEADER_ARGUMENTS +#undef __ISI_TMPL_ARGUMENTS + +#endif /* _STLP_INTERNAL_STREAM_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_streambuf.c b/sdk/tlibstdcxx/stlport/stl/_streambuf.c new file mode 100644 index 0000000000..bd61a204fa --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_streambuf.c @@ -0,0 +1,208 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_STREAMBUF_C +#define _STLP_STREAMBUF_C + +#ifndef _STLP_INTERNAL_STREAMBUF +# include +#endif + +_STLP_BEGIN_NAMESPACE +//---------------------------------------------------------------------- +// Non-inline basic_streambuf<> member functions. + +#if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1300) || !defined (_STLP_USE_STATIC_LIB) +template +basic_streambuf<_CharT, _Traits>::basic_streambuf() + : _M_gbegin(0), _M_gnext(0), _M_gend(0), + _M_pbegin(0), _M_pnext(0), _M_pend(0), + _M_locale() { + // _M_lock._M_initialize(); +} +#endif + +template +basic_streambuf<_CharT, _Traits>::~basic_streambuf() +{} + +template +locale +basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) { + this->imbue(__loc); + locale __tmp = _M_locale; + _M_locale = __loc; + return __tmp; +} + +template +streamsize +basic_streambuf<_CharT, _Traits>::xsgetn(_CharT* __s, streamsize __n) { + streamsize __result = 0; + const int_type __eof = _Traits::eof(); + + while (__result < __n) { + if (_M_gnext < _M_gend) { + size_t __chunk = (min) (__STATIC_CAST(size_t,_M_gend - _M_gnext), + __STATIC_CAST(size_t,__n - __result)); + _Traits::copy(__s, _M_gnext, __chunk); + __result += __chunk; + __s += __chunk; + _M_gnext += __chunk; + } + else { + int_type __c = this->sbumpc(); + if (!_Traits::eq_int_type(__c, __eof)) { + *__s = _Traits::to_char_type(__c); + ++__result; + ++__s; + } + else + break; + } + } + + return __result; +} + +template +streamsize +basic_streambuf<_CharT, _Traits>::xsputn(const _CharT* __s, streamsize __n) +{ + streamsize __result = 0; + const int_type __eof = _Traits::eof(); + + while (__result < __n) { + if (_M_pnext < _M_pend) { + size_t __chunk = (min) (__STATIC_CAST(size_t,_M_pend - _M_pnext), + __STATIC_CAST(size_t,__n - __result)); + _Traits::copy(_M_pnext, __s, __chunk); + __result += __chunk; + __s += __chunk; + _M_pnext += __chunk; + } + + else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(*__s)), + __eof)) { + ++__result; + ++__s; + } + else + break; + } + return __result; +} + +template +streamsize +basic_streambuf<_CharT, _Traits>::_M_xsputnc(_CharT __c, streamsize __n) +{ + streamsize __result = 0; + const int_type __eof = _Traits::eof(); + + while (__result < __n) { + if (_M_pnext < _M_pend) { + size_t __chunk = (min) (__STATIC_CAST(size_t,_M_pend - _M_pnext), + __STATIC_CAST(size_t,__n - __result)); + _Traits::assign(_M_pnext, __chunk, __c); + __result += __chunk; + _M_pnext += __chunk; + } + + else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(__c)), + __eof)) + ++__result; + else + break; + } + return __result; +} + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type +basic_streambuf<_CharT, _Traits>::_M_snextc_aux() +{ + int_type __eof = _Traits::eof(); + if (_M_gend == _M_gnext) + return _Traits::eq_int_type(this->uflow(), __eof) ? __eof : this->sgetc(); + else { + _M_gnext = _M_gend; + return this->underflow(); + } +} + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type +basic_streambuf<_CharT, _Traits>::pbackfail(int_type) { + return _Traits::eof(); +} + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type +basic_streambuf<_CharT, _Traits>::overflow(int_type) { + return _Traits::eof(); +} + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type +basic_streambuf<_CharT, _Traits>::uflow() { + return ( _Traits::eq_int_type(this->underflow(),_Traits::eof()) ? + _Traits::eof() : + _Traits::to_int_type(*_M_gnext++)); +} + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type +basic_streambuf<_CharT, _Traits>::underflow() +{ return _Traits::eof(); } + +template +streamsize +basic_streambuf<_CharT, _Traits>::showmanyc() +{ return 0; } + +template +void +basic_streambuf<_CharT, _Traits>::imbue(const locale&) {} + +template +int +basic_streambuf<_CharT, _Traits>::sync() { return 0; } + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::pos_type +basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode) +{ return pos_type(-1); } + +template +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::pos_type +basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir, + ios_base::openmode) +{ return pos_type(-1); } + +template +basic_streambuf<_CharT, _Traits>* +basic_streambuf<_CharT, _Traits>:: setbuf(char_type*, streamsize) +{ return this; } + +_STLP_END_NAMESPACE + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_streambuf.h b/sdk/tlibstdcxx/stlport/stl/_streambuf.h new file mode 100644 index 0000000000..e336b0f53f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_streambuf.h @@ -0,0 +1,287 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_INTERNAL_STREAMBUF +#define _STLP_INTERNAL_STREAMBUF + +#ifndef _STLP_IOS_BASE_H +# include // Needed for ios_base bitfield members. +#endif // includes . + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// Class basic_streambuf<>, the base class of the streambuf hierarchy. + +// A basic_streambuf<> manages an input (get) area and an output (put) +// area. Each is described by three pointers: a beginning, an end, and a +// current position. basic_streambuf<> contains some very simple member +// functions that manipulate those six pointers, but almost all of the real +// functionality gets delegated to protected virtual member functions. +// All of the public member functions are inline, and most of the protected +// member functions are virtual. + +// Although basic_streambuf<> is not abstract, it is useful only as a base +// class. Its virtual member functions have default definitions such that +// reading from a basic_streambuf<> will always yield EOF, and writing to a +// basic_streambuf<> will always fail. + +// The second template parameter, _Traits, defaults to char_traits<_CharT>. +// The default is declared in header , and it isn't declared here +// because C++ language rules do not allow it to be declared twice. + +template +class basic_streambuf { + friend class basic_istream<_CharT, _Traits>; + friend class basic_ostream<_CharT, _Traits>; + +public: // Typedefs. + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + +private: // Data members. + + char_type* _M_gbegin; // Beginning of get area + char_type* _M_gnext; // Current position within the get area + char_type* _M_gend; // End of get area + + char_type* _M_pbegin; // Beginning of put area + char_type* _M_pnext; // Current position within the put area + char_type* _M_pend; // End of put area + + locale _M_locale; // The streambuf's locale object + +public: // Destructor. + virtual ~basic_streambuf(); + +protected: // The default constructor. + basic_streambuf() +#if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) && defined (_STLP_USE_STATIC_LIB) + //We make it inline to avoid unresolved symbol. + : _M_gbegin(0), _M_gnext(0), _M_gend(0), + _M_pbegin(0), _M_pnext(0), _M_pend(0), + _M_locale() + {} +#else + ; +#endif + +protected: // Protected interface to the get area. + char_type* eback() const { return _M_gbegin; } // Beginning + char_type* gptr() const { return _M_gnext; } // Current position + char_type* egptr() const { return _M_gend; } // End + + void gbump(int __n) { _M_gnext += __n; } + void setg(char_type* __gbegin, char_type* __gnext, char_type* __gend) { + _M_gbegin = __gbegin; + _M_gnext = __gnext; + _M_gend = __gend; + } + +public: + // An alternate public interface to the above functions + // which allows us to avoid using templated friends which + // are not supported on some compilers. + char_type* _M_eback() const { return eback(); } + char_type* _M_gptr() const { return gptr(); } + char_type* _M_egptr() const { return egptr(); } + void _M_gbump(int __n) { gbump(__n); } + void _M_setg(char_type* __gbegin, char_type* __gnext, char_type* __gend) + { this->setg(__gbegin, __gnext, __gend); } + +protected: // Protected interface to the put area + + char_type* pbase() const { return _M_pbegin; } // Beginning + char_type* pptr() const { return _M_pnext; } // Current position + char_type* epptr() const { return _M_pend; } // End + + void pbump(int __n) { _M_pnext += __n; } + void setp(char_type* __pbegin, char_type* __pend) { + _M_pbegin = __pbegin; + _M_pnext = __pbegin; + _M_pend = __pend; + } + +protected: // Virtual buffer management functions. + + virtual basic_streambuf<_CharT, _Traits>* setbuf(char_type*, streamsize); + + // Alters the stream position, using an integer offset. In this + // class seekoff does nothing; subclasses are expected to override it. + virtual pos_type seekoff(off_type, ios_base::seekdir, + ios_base::openmode = ios_base::in | ios_base::out); + + // Alters the stream position, using a previously obtained streampos. In + // this class seekpos does nothing; subclasses are expected to override it. + virtual pos_type + seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out); + + // Synchronizes (i.e. flushes) the buffer. All subclasses are expected to + // override this virtual member function. + virtual int sync(); + + +public: // Buffer management. + basic_streambuf<_CharT, _Traits>* pubsetbuf(char_type* __s, streamsize __n) + { return this->setbuf(__s, __n); } + + pos_type pubseekoff(off_type __offset, ios_base::seekdir __way, + ios_base::openmode __mod = ios_base::in | ios_base::out) + { return this->seekoff(__offset, __way, __mod); } + + pos_type pubseekpos(pos_type __sp, + ios_base::openmode __mod = ios_base::in | ios_base::out) + { return this->seekpos(__sp, __mod); } + + int pubsync() { return this->sync(); } + +protected: // Virtual get area functions, as defined in + // 17.5.2.4.3 and 17.5.2.4.4 of the standard. + // Returns a lower bound on the number of characters that we can read, + // with underflow, before reaching end of file. (-1 is a special value: + // it means that underflow will fail.) Most subclasses should probably + // override this virtual member function. + virtual streamsize showmanyc(); + + // Reads up to __n characters. Return value is the number of + // characters read. + virtual streamsize xsgetn(char_type* __s, streamsize __n); + + // Called when there is no read position, i.e. when gptr() is null + // or when gptr() >= egptr(). Subclasses are expected to override + // this virtual member function. + virtual int_type underflow(); + + // Similar to underflow(), but used for unbuffered input. Most + // subclasses should probably override this virtual member function. + virtual int_type uflow(); + + // Called when there is no putback position, i.e. when gptr() is null + // or when gptr() == eback(). All subclasses are expected to override + // this virtual member function. + virtual int_type pbackfail(int_type = traits_type::eof()); + +protected: // Virtual put area functions, as defined in + // 27.5.2.4.5 of the standard. + + // Writes up to __n characters. Return value is the number of characters + // written. + virtual streamsize xsputn(const char_type* __s, streamsize __n); + + // Extension: writes up to __n copies of __c. Return value is the number + // of characters written. + virtual streamsize _M_xsputnc(char_type __c, streamsize __n); + + // Called when there is no write position. All subclasses are expected to + // override this virtual member function. + virtual int_type overflow(int_type = traits_type::eof()); + +public: // Public members for writing characters. + // Write a single character. + int_type sputc(char_type __c) { + return ((_M_pnext < _M_pend) ? _Traits::to_int_type(*_M_pnext++ = __c) + : this->overflow(_Traits::to_int_type(__c))); + } + + // Write __n characters. + streamsize sputn(const char_type* __s, streamsize __n) + { return this->xsputn(__s, __n); } + + // Extension: write __n copies of __c. + streamsize _M_sputnc(char_type __c, streamsize __n) + { return this->_M_xsputnc(__c, __n); } + +private: // Helper functions. + int_type _M_snextc_aux(); + +public: // Public members for reading characters. + streamsize in_avail() { + return (_M_gnext < _M_gend) ? (_M_gend - _M_gnext) : this->showmanyc(); + } + + // Advance to the next character and return it. + int_type snextc() { + return ( _M_gend - _M_gnext > 1 ? + _Traits::to_int_type(*++_M_gnext) : + this->_M_snextc_aux()); + } + + // Return the current character and advance to the next. + int_type sbumpc() { + return _M_gnext < _M_gend ? _Traits::to_int_type(*_M_gnext++) + : this->uflow(); + } + + // Return the current character without advancing to the next. + int_type sgetc() { + return _M_gnext < _M_gend ? _Traits::to_int_type(*_M_gnext) + : this->underflow(); + } + + streamsize sgetn(char_type* __s, streamsize __n) + { return this->xsgetn(__s, __n); } + + int_type sputbackc(char_type __c) { + return ((_M_gbegin < _M_gnext) && _Traits::eq(__c, *(_M_gnext - 1))) + ? _Traits::to_int_type(*--_M_gnext) + : this->pbackfail(_Traits::to_int_type(__c)); + } + + int_type sungetc() { + return (_M_gbegin < _M_gnext) + ? _Traits::to_int_type(*--_M_gnext) + : this->pbackfail(); + } + +protected: // Virtual locale functions. + + // This is a hook, called by pubimbue() just before pubimbue() + // sets the streambuf's locale to __loc. Note that imbue should + // not (and cannot, since it has no access to streambuf's private + // members) set the streambuf's locale itself. + virtual void imbue(const locale&); + +public: // Locale-related functions. + locale pubimbue(const locale&); + locale getloc() const { return _M_locale; } + +#if !defined (_STLP_NO_ANACHRONISMS) + void stossc() { this->sbumpc(); } +#endif +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_streambuf >; +# if !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_streambuf >; +# endif // _STLP_NO_WCHAR_T +#endif // _STLP_USE_TEMPLATE_EXPORT + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_string.c b/sdk/tlibstdcxx/stlport/stl/_string.c new file mode 100644 index 0000000000..3c247f464b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string.c @@ -0,0 +1,674 @@ +/* + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#ifndef _STLP_STRING_C +#define _STLP_STRING_C + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +#ifndef _STLP_INTERNAL_CTRAITS_FUNCTIONS_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_H +# include +#endif + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define basic_string _STLP_NO_MEM_T_NAME(str) +#elif defined (_STLP_DEBUG) +# define basic_string _STLP_NON_DBG_NAME(str) +#endif + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define __size_type__ size_t +# define size_type size_t +# define iterator _CharT* +#else +# define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_string<_CharT,_Traits,_Alloc>::size_type +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// A helper class to use a char_traits as a function object. +template +struct _Not_within_traits : public unary_function { + typedef typename _Traits::char_type _CharT; + const _CharT* _M_first; + const _CharT* _M_last; + + _Not_within_traits(const _CharT* __f, const _CharT* __l) + : _M_first(__f), _M_last(__l) {} + + bool operator()(const _CharT& __x) const { + return find_if(_M_first, _M_last, + _STLP_PRIV _Eq_char_bound<_Traits>(__x)) == _M_last; + } +}; + +template +inline _InputIter __str_find_first_of_aux(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits*, const __true_type& /* _STLportTraits */) +{ return __find_first_of(__first1, __last1, __first2, __last2); } + +template +inline _InputIter __str_find_first_of_aux(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits*, const __false_type& /* _STLportTraits */) +{ return __find_first_of(__first1, __last1, __first2, __last2, _STLP_PRIV _Eq_traits<_Traits>()); } + +template +inline _InputIter __str_find_first_of(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits* __traits) { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass<_Traits>::_Ret _STLportTraits; +#else + enum { _Is = _IsSTLportClass<_Traits>::_Is }; + typedef typename __bool2type<_Is>::_Ret _STLportTraits; +#endif + return __str_find_first_of_aux(__first1, __last1, __first2, __last2, __traits, _STLportTraits()); +} + +template +inline _InputIter __str_find_first_not_of_aux3(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits* /* __traits */, const __true_type& __useStrcspnLikeAlgo) +{ return __find_first_of_aux2(__first1, __last1, __first2, __last2, __first2, not1(_Identity()), __useStrcspnLikeAlgo); } + +template +inline _InputIter __str_find_first_not_of_aux3(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits* /* __traits */, const __false_type& /* _UseStrcspnLikeAlgo */) +{ return _STLP_STD::find_if(__first1, __last1, _STLP_PRIV _Not_within_traits<_Traits>(__first2, __last2)); } + +template +inline _InputIter __str_find_first_not_of_aux2(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Tp* __pt, _Traits* __traits) { + typedef typename _IsIntegral<_Tp>::_Ret _IsIntegral; + typedef typename _IsCharLikeType<_CharT>::_Ret _IsCharLike; + typedef typename _Land2<_IsIntegral, _IsCharLike>::_Ret _UseStrcspnLikeAlgo; + _STLP_MARK_PARAMETER_AS_UNUSED(__pt); + return __str_find_first_not_of_aux3(__first1, __last1, __first2, __last2, __traits, _UseStrcspnLikeAlgo()); +} + +template +inline _InputIter __str_find_first_not_of_aux1(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits* __traits, const __true_type& /* _STLportTraits */) +{ return __str_find_first_not_of_aux2(__first1, __last1, __first2, __last2, + _STLP_VALUE_TYPE(__first1, _InputIter), __traits); } + +template +inline _InputIter __str_find_first_not_of_aux1(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits*, const __false_type& /* _STLportTraits */) +{ return _STLP_STD::find_if(__first1, __last1, _STLP_PRIV _Not_within_traits<_Traits>(__first2, __last2)); } + +template +inline _InputIter __str_find_first_not_of(_InputIter __first1, _InputIter __last1, + const _CharT* __first2, const _CharT* __last2, + _Traits* __traits) { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass<_Traits>::_Ret _STLportTraits; +#else + enum { _Is = _IsSTLportClass<_Traits>::_Is }; + typedef typename __bool2type<_Is>::_Ret _STLportTraits; +#endif + return __str_find_first_not_of_aux1(__first1, __last1, __first2, __last2, __traits, _STLportTraits()); +} + +// ------------------------------------------------------------ +// Non-inline declarations. + +#if !defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +// Change the string's capacity so that it is large enough to hold +// at least __res_arg elements, plus the terminating _CharT(). Note that, +// if __res_arg < capacity(), this member function may actually decrease +// the string's capacity. +template +void basic_string<_CharT,_Traits,_Alloc>::reserve(size_type __res_arg) { + if (__res_arg > max_size()) + this->_M_throw_length_error(); + + size_type __n = (max)(__res_arg, size()) + 1; + if (__n < this->_M_capacity()) + return; + + _M_reserve(__n); +} + +template +void basic_string<_CharT,_Traits,_Alloc>::_M_reserve(size_type __n) { + pointer __new_start = this->_M_start_of_storage.allocate(__n, __n); + pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), this->_M_Finish(), __new_start); + _M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __n); +} + +template +basic_string<_CharT,_Traits,_Alloc>& +basic_string<_CharT,_Traits,_Alloc>::append(size_type __n, _CharT __c) { + if (__n > 0) { + if (__n > max_size() - size()) + this->_M_throw_length_error(); + if (__n >= this->_M_rest()) + _M_reserve(_M_compute_next_size(__n)); + _STLP_PRIV __uninitialized_fill_n(this->_M_finish + 1, __n - 1, __c); + _M_construct_null(this->_M_finish + __n); + _Traits::assign(*end(), __c); + this->_M_finish += __n; + } + return *this; +} + +template +basic_string<_CharT, _Traits, _Alloc>& +basic_string<_CharT, _Traits, _Alloc>::_M_append(const _CharT* __first, const _CharT* __last) { + if (__first != __last) { + size_type __n = __STATIC_CAST(size_type, __last - __first); + if (__n >= this->_M_rest()) { + size_type __len = _M_compute_next_size(__n); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), this->_M_Finish(), __new_start); + __new_finish = _STLP_PRIV __ucopy(__first, __last, __new_finish); + _M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + else { + const _CharT* __f1 = __first; + ++__f1; + _STLP_PRIV __ucopy(__f1, __last, this->_M_finish + 1); + _M_construct_null(this->_M_finish + __n); + _Traits::assign(*end(), *__first); + this->_M_finish += __n; + } + } + return *this; +} + +template +basic_string<_CharT,_Traits,_Alloc>& +basic_string<_CharT,_Traits,_Alloc>::assign(size_type __n, _CharT __c) { + if (__n <= size()) { + _Traits::assign(this->_M_Start(), __n, __c); + erase(begin() + __n, end()); + } + else { + if (__n < capacity()) { + _Traits::assign(this->_M_Start(), size(), __c); + append(__n - size(), __c); + } + else { + _Self __str(__n, __c); + this->swap(__str); + } + } + return *this; +} + +template +basic_string<_CharT,_Traits,_Alloc>& +basic_string<_CharT,_Traits,_Alloc>::_M_assign(const _CharT* __f, const _CharT* __l) { + ptrdiff_t __n = __l - __f; + if (__STATIC_CAST(size_type, __n) <= size()) { + _Traits::move(this->_M_Start(), __f, __n); + erase(begin() + __n, end()); + } + else { + _Traits::move(this->_M_Start(), __f, size()); + _M_append(__f + size(), __l); + } + return *this; +} + +template +_CharT* basic_string<_CharT,_Traits,_Alloc> ::_M_insert_aux(_CharT* __p, + _CharT __c) { + pointer __new_pos = __p; + if (this->_M_rest() > 1 ) { + _M_construct_null(this->_M_finish + 1); + _Traits::move(__p + 1, __p, this->_M_finish - __p); + _Traits::assign(*__p, __c); + ++this->_M_finish; + } + else { + size_type __len = _M_compute_next_size(1); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + __new_pos = _STLP_PRIV __ucopy(this->_M_Start(), __p, __new_start); + _Traits::assign(*__new_pos, __c); + pointer __new_finish = __new_pos + 1; + __new_finish = _STLP_PRIV __ucopy(__p, this->_M_finish, __new_finish); + _M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + return __new_pos; +} + +template +void basic_string<_CharT,_Traits,_Alloc>::insert(iterator __pos, + size_t __n, _CharT __c) { + if (__n != 0) { + if (this->_M_rest() > __n) { + const size_type __elems_after = this->_M_finish - __pos; + pointer __old_finish = this->_M_finish; + if (__elems_after >= __n) { + _STLP_PRIV __ucopy((this->_M_finish - __n) + 1, this->_M_finish + 1, this->_M_finish + 1); + this->_M_finish += __n; + _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1); + _Traits::assign(__pos, __n, __c); + } + else { + _STLP_PRIV __uninitialized_fill_n(this->_M_finish + 1, __n - __elems_after - 1, __c); + this->_M_finish += __n - __elems_after; + _STLP_PRIV __ucopy(__pos, __old_finish + 1, this->_M_finish); + this->_M_finish += __elems_after; + _Traits::assign(__pos, __elems_after + 1, __c); + } + } + else { + size_type __len = _M_compute_next_size(__n); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), __pos, __new_start); + __new_finish = _STLP_PRIV __uninitialized_fill_n(__new_finish, __n, __c); + __new_finish = _STLP_PRIV __ucopy(__pos, this->_M_finish, __new_finish); + _M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + } +} + +template +void basic_string<_CharT,_Traits,_Alloc>::_M_insert(iterator __pos, + const _CharT* __first, const _CharT* __last, + bool __self_ref) { + //this version has to take care about the auto referencing + if (__first != __last) { + const size_t __n = __last - __first; + if (this->_M_rest() > __n) { + const size_t __elems_after = this->_M_finish - __pos; + pointer __old_finish = this->_M_finish; + if (__elems_after >= __n) { + _STLP_PRIV __ucopy((this->_M_finish - __n) + 1, this->_M_finish + 1, this->_M_finish + 1); + this->_M_finish += __n; + _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1); + if (!__self_ref || __last < __pos) { + _M_copy(__first, __last, __pos); + } + else { + //We have to check that the source buffer hasn't move + if (__first >= __pos) { + //The source buffer has move + __first += __n; + __last += __n; + _M_copy(__first, __last, __pos); + } + else { + //The source buffer hasn't move, it has been duplicated + _M_move(__first, __last, __pos); + } + } + } + else { + const_iterator __mid = __first; + __mid += __elems_after + 1; + _STLP_PRIV __ucopy(__mid, __last, this->_M_finish + 1); + this->_M_finish += __n - __elems_after; + _STLP_PRIV __ucopy(__pos, __old_finish + 1, this->_M_finish); + this->_M_finish += __elems_after; + if (!__self_ref) + _M_copy(__first, __mid, __pos); + else + _M_move(__first, __mid, __pos); + } + } + else { + size_type __len = _M_compute_next_size(__n); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), __pos, __new_start); + __new_finish = _STLP_PRIV __ucopy(__first, __last, __new_finish); + __new_finish = _STLP_PRIV __ucopy(__pos, this->_M_finish, __new_finish); + _M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + } +} + +template +basic_string<_CharT,_Traits,_Alloc>& +basic_string<_CharT,_Traits,_Alloc> ::replace(iterator __first, iterator __last, + size_type __n, _CharT __c) { + size_type __len = (size_type)(__last - __first); + + if (__len >= __n) { + _Traits::assign(__first, __n, __c); + erase(__first + __n, __last); + } + else { + _Traits::assign(__first, __len, __c); + insert(__last, __n - __len, __c); + } + return *this; +} + +template +basic_string<_CharT,_Traits,_Alloc>& +basic_string<_CharT,_Traits,_Alloc> ::_M_replace(iterator __first, iterator __last, + const _CharT* __f, const _CharT* __l, + bool __self_ref) { + const ptrdiff_t __n = __l - __f; + const difference_type __len = __last - __first; + if (__len >= __n) { + if (!__self_ref || __l < __first || __f >= __last) + _M_copy(__f, __l, __first); + else + _M_move(__f, __l, __first); + erase(__first + __n, __last); + } else if (!__self_ref || (__f >= __last) || (__l <= __first)) { // no overlap + const_iterator __m = __f + __len; + _M_copy(__f, __m, __first); + _M_insert(__last, __m, __l, __self_ref ); + } else if (__f < __first) { // we have to take care of overlaping + const_iterator __m = __f + __len; + // We have to deal with possible reallocation because we do insert first. + const difference_type __off_dest = __first - this->begin(); + const difference_type __off_src = __f - this->begin(); + _M_insert(__last, __m, __l, true); + _Traits::move(begin() + __off_dest, begin() + __off_src, __len); + } else { + const_iterator __m = __f + __len; + _Traits::move(__first, __f, __len); + _M_insert(__last, __m, __l, true); + } + return *this; +} + +template +__size_type__ basic_string<_CharT,_Traits,_Alloc>::find( const _CharT* __s, size_type __pos, + size_type __n) const +{ + const size_t __len = size(); + if (__pos >= __len || __pos + __n > __len) { + if ( __n == 0 && __pos <= __len ) { // marginal case + return __pos; + } + return npos; + } + + const_pointer __result = + _STLP_STD::search(this->_M_Start() + __pos, this->_M_Finish(), + __s, __s + __n, _STLP_PRIV _Eq_traits<_Traits>()); + return __result != this->_M_Finish() ? __result - this->_M_Start() : npos; +} + +template +__size_type__ basic_string<_CharT,_Traits,_Alloc>::find(_CharT __c, size_type __pos) const +{ + if (__pos >= size()) { /*__pos + 1 > size()*/ + return npos; + } + + const_pointer __result = + _STLP_STD::find_if(this->_M_Start() + __pos, this->_M_Finish(), + _STLP_PRIV _Eq_char_bound<_Traits>(__c)); + return __result != this->_M_Finish() ? __result - this->_M_Start() : npos; +} + +template +__size_type__ basic_string<_CharT,_Traits,_Alloc>::rfind(const _CharT* __s, size_type __pos, + size_type __n) const +{ + const size_type __len = size(); + if ( __len < __n ) { + return npos; + } + const_pointer __last = this->_M_Start() + (min)( __len - __n, __pos) + __n; + if ( __n == 0 ) { // marginal case + return __last - this->_M_Start(); + } + const_pointer __result = _STLP_STD::find_end(this->_M_Start(), __last, + __s, __s + __n, _STLP_PRIV _Eq_traits<_Traits>()); + return __result != __last ? __result - this->_M_Start() : npos; +} + +template +__size_type__ basic_string<_CharT,_Traits,_Alloc>::rfind(_CharT __c, size_type __pos) const +{ + const size_type __len = size(); + if ( __len < 1 ) { + return npos; + } + const_iterator __last = begin() + (min)(__len - 1, __pos) + 1; + const_reverse_iterator __rresult = + _STLP_STD::find_if(const_reverse_iterator(__last), rend(), + _STLP_PRIV _Eq_char_bound<_Traits>(__c)); + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos; +} + +template __size_type__ +basic_string<_CharT,_Traits,_Alloc> ::find_first_of(const _CharT* __s, size_type __pos, + size_type __n) const { + if (__pos >= size()) /*__pos + 1 > size()*/ + return npos; + else { + const_iterator __result = _STLP_PRIV __str_find_first_of(begin() + __pos, end(), + __s, __s + __n, + __STATIC_CAST(_Traits*, 0)); + return __result != end() ? __result - begin() : npos; + } +} + +template + __size_type__ +basic_string<_CharT,_Traits,_Alloc> ::find_last_of(const _CharT* __s, size_type __pos, + size_type __n) const +{ + const size_type __len = size(); + if ( __len < 1 ) { + return npos; + } + const const_iterator __last = begin() + (min)(__len - 1, __pos) + 1; + const const_reverse_iterator __rresult = + _STLP_PRIV __str_find_first_of(const_reverse_iterator(__last), rend(), + __s, __s + __n, + __STATIC_CAST(_Traits*, 0)); + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos; +} + + +template __size_type__ +basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(const _CharT* __s, size_type __pos, + size_type __n) const { + typedef typename _Traits::char_type _CharType; + if (__pos >= size()) /*__pos + 1 >= size()*/ + return npos; + else { + const_pointer __result = _STLP_PRIV __str_find_first_not_of(this->_M_Start() + __pos, this->_M_Finish(), + __STATIC_CAST(const _CharType*, __s), + __STATIC_CAST(const _CharType*, __s) + __n, + __STATIC_CAST(_Traits*, 0)); + return __result != this->_M_finish ? __result - this->_M_Start() : npos; + } +} + +template __size_type__ +basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(_CharT __c, size_type __pos) const { + if (1 > size()) + return npos; + else { + const_pointer __result = _STLP_STD::find_if(this->_M_Start() + __pos, this->_M_Finish(), + _STLP_PRIV _Neq_char_bound<_Traits>(__c)); + return __result != this->_M_finish ? __result - this->_M_Start() : npos; + } +} + +template +__size_type__ +basic_string<_CharT,_Traits,_Alloc>::find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const +{ + typedef typename _Traits::char_type _CharType; + const size_type __len = size(); + if ( __len < 1 ) { + return npos; + } + const_iterator __last = begin() + (min)(__len - 1, __pos) + 1; + const_reverse_iterator __rlast = const_reverse_iterator(__last); + const_reverse_iterator __rresult = + _STLP_PRIV __str_find_first_not_of(__rlast, rend(), + __STATIC_CAST(const _CharType*, __s), + __STATIC_CAST(const _CharType*, __s) + __n, + __STATIC_CAST(_Traits*, 0)); + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos; +} + +template +__size_type__ +basic_string<_CharT, _Traits, _Alloc>::find_last_not_of(_CharT __c, size_type __pos) const +{ + const size_type __len = size(); + if ( __len < 1 ) { + return npos; + } + const_iterator __last = begin() + (min)(__len - 1, __pos) + 1; + const_reverse_iterator __rlast = const_reverse_iterator(__last); + const_reverse_iterator __rresult = + _STLP_STD::find_if(__rlast, rend(), + _STLP_PRIV _Neq_char_bound<_Traits>(__c)); + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos; +} + +#if !defined (basic_string) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template +void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s, + _CharT* __buf, size_t __n) { + if (__n > 0) { + __n = (min) (__n - 1, __s.size()); + _STLP_STD::copy(__s.begin(), __s.begin() + __n, __buf); + __buf[__n] = _CharT(); + } +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#include + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// _String_base methods +template +void _String_base<_Tp,_Alloc>::_M_throw_length_error() const +{ __stl_throw_length_error("basic_string"); } + +template +void _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const +{ __stl_throw_out_of_range("basic_string"); } + +template +void _String_base<_Tp, _Alloc>::_M_allocate_block(size_t __n) { + if ((__n <= (max_size() + 1)) && (__n > 0)) { +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + if (__n > _DEFAULT_SIZE) { + this->_M_start_of_storage._M_data = _M_start_of_storage.allocate(__n, __n); + this->_M_finish = this->_M_start_of_storage._M_data; + this->_M_buffers._M_end_of_storage = this->_M_start_of_storage._M_data + __n; + } +#else + this->_M_start_of_storage._M_data = _M_start_of_storage.allocate(__n, __n); + this->_M_finish = this->_M_start_of_storage._M_data; + this->_M_end_of_storage = this->_M_start_of_storage._M_data + __n; +#endif + } else { + this->_M_throw_length_error(); + } +} + +#if !defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) +template +basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) { + _STLP_FIX_LITERAL_BUG(__s) + _M_range_initialize(__s, __s + traits_type::length(__s)); +} +#endif + +template +basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s, + const allocator_type& __a) + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) { + _STLP_FIX_LITERAL_BUG(__s) + _M_range_initialize(__s, __s + traits_type::length(__s)); +} + +template +basic_string<_CharT, _Traits, _Alloc>::basic_string(const basic_string<_CharT, _Traits, _Alloc> & __s) + : _STLP_PRIV _String_base<_CharT,_Alloc>(__s.get_allocator()) +{ _M_range_initialize(__s._M_Start(), __s._M_Finish()); } + +#if defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +# undef basic_string +#endif + +#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) +template +const size_t basic_string<_CharT, _Traits, _Alloc>::npos; +#endif + +_STLP_END_NAMESPACE + +#undef __size_type__ +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# undef size_type +# undef iterator +#endif + +#endif /* _STLP_STRING_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_string.h b/sdk/tlibstdcxx/stlport/stl/_string.h new file mode 100644 index 0000000000..540822b3c1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string.h @@ -0,0 +1,1182 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_STRING_H +#define _STLP_INTERNAL_STRING_H + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_STRING_FWD_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +# include +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +# include +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +#if defined (__MWERKS__) && ! defined (_STLP_USE_OWN_NAMESPACE) + +// MSL implementation classes expect to see the definition of streampos +// when this header is included. We expect this to be fixed in later MSL +// implementations +# if !defined( __MSL_CPP__ ) || __MSL_CPP__ < 0x4105 +# include +# endif +#endif // __MWERKS__ + +/* + * Standard C++ string class. This class has performance + * characteristics very much like vector<>, meaning, for example, that + * it does not perform reference-count or copy-on-write, and that + * concatenation of two strings is an O(N) operation. + + * There are three reasons why basic_string is not identical to + * vector. + * First, basic_string always stores a null character at the end; + * this makes it possible for c_str to be a fast operation. + * Second, the C++ standard requires basic_string to copy elements + * using char_traits<>::assign, char_traits<>::copy, and + * char_traits<>::move. This means that all of vector<>'s low-level + * operations must be rewritten. Third, basic_string<> has a lot of + * extra functions in its interface that are convenient but, strictly + * speaking, redundant. + */ + +#include + +_STLP_BEGIN_NAMESPACE + +// ------------------------------------------------------------ +// Class basic_string. + +// Class invariants: +// (1) [start, finish) is a valid range. +// (2) Each iterator in [start, finish) points to a valid object +// of type value_type. +// (3) *finish is a valid object of type value_type; when +// value_type is not a POD it is value_type(). +// (4) [finish + 1, end_of_storage) is a valid range. +// (5) Each iterator in [finish + 1, end_of_storage) points to +// unininitialized memory. + +// Note one important consequence: a string of length n must manage +// a block of memory whose size is at least n + 1. + +_STLP_MOVE_TO_PRIV_NAMESPACE +struct _String_reserve_t {}; +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define basic_string _STLP_NO_MEM_T_NAME(str) +#elif defined (_STLP_DEBUG) +# define basic_string _STLP_NON_DBG_NAME(str) +#endif + +#if defined (basic_string) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +#if defined (__DMC__) +# define _STLP_PRIVATE public +#elif defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define _STLP_PRIVATE protected +#else +# define _STLP_PRIVATE private +#endif + +template +class basic_string : _STLP_PRIVATE _STLP_PRIV _String_base<_CharT,_Alloc> +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string) + , public __stlport_class > +#endif +{ +_STLP_PRIVATE: // Private members inherited from base. + typedef _STLP_PRIV _String_base<_CharT,_Alloc> _Base; + typedef basic_string<_CharT, _Traits, _Alloc> _Self; + +public: + typedef _CharT value_type; + typedef _Traits traits_type; + + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef typename _Base::size_type size_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag _Iterator_category; + + typedef const value_type* const_iterator; + typedef value_type* iterator; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +#include + + typedef _STLP_PRIV _String_reserve_t _Reserve_t; + +public: // Constructor, destructor, assignment. + typedef typename _Base::allocator_type allocator_type; + + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_start_of_storage, _CharT); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit basic_string(const allocator_type& __a = allocator_type()) +#else + basic_string() + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), _Base::_DEFAULT_SIZE) + { _M_terminate_string(); } + explicit basic_string(const allocator_type& __a) +#endif + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, _Base::_DEFAULT_SIZE) + { _M_terminate_string(); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + basic_string(_Reserve_t, size_t __n, + const allocator_type& __a = allocator_type()) +#else + basic_string(_Reserve_t, size_t __n) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), __n + 1) + { _M_terminate_string(); } + basic_string(_Reserve_t, size_t __n, const allocator_type& __a) +#endif + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, __n + 1) + { _M_terminate_string(); } + + basic_string(const _Self&); + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + basic_string(const _Self& __s, size_type __pos, size_type __n = npos, + const allocator_type& __a = allocator_type()) +#else + basic_string(const _Self& __s, size_type __pos) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) { + if (__pos > __s.size()) + this->_M_throw_out_of_range(); + else + _M_range_initialize(__s._M_Start() + __pos, __s._M_Finish()); + } + basic_string(const _Self& __s, size_type __pos, size_type __n) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) { + if (__pos > __s.size()) + this->_M_throw_out_of_range(); + else + _M_range_initialize(__s._M_Start() + __pos, + __s._M_Start() + __pos + (min) (__n, __s.size() - __pos)); + } + basic_string(const _Self& __s, size_type __pos, size_type __n, + const allocator_type& __a) +#endif + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) { + if (__pos > __s.size()) + this->_M_throw_out_of_range(); + else + _M_range_initialize(__s._M_Start() + __pos, + __s._M_Start() + __pos + (min) (__n, __s.size() - __pos)); + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + basic_string(const _CharT* __s, size_type __n, + const allocator_type& __a = allocator_type()) +#else + basic_string(const _CharT* __s, size_type __n) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) { + _STLP_FIX_LITERAL_BUG(__s) + _M_range_initialize(__s, __s + __n); + } + basic_string(const _CharT* __s, size_type __n, const allocator_type& __a) +#endif + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) { + _STLP_FIX_LITERAL_BUG(__s) + _M_range_initialize(__s, __s + __n); + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + basic_string(const _CharT* __s, + const allocator_type& __a = allocator_type()); +#else + basic_string(const _CharT* __s); + basic_string(const _CharT* __s, const allocator_type& __a); +#endif + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + basic_string(size_type __n, _CharT __c, + const allocator_type& __a = allocator_type()) +#else + basic_string(size_type __n, _CharT __c) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), __n + 1) { + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __c); + _M_terminate_string(); + } + basic_string(size_type __n, _CharT __c, const allocator_type& __a) +#endif + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, __n + 1) { + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __c); + _M_terminate_string(); + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + basic_string(__move_source<_Self> src) + : _STLP_PRIV _String_base<_CharT,_Alloc>(__move_source<_Base>(src.get())) {} +#endif + + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + template + basic_string(_InputIterator __f, _InputIterator __l, + const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__f, __l, _Integral()); + } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + basic_string(_InputIterator __f, _InputIterator __l) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__f, __l, _Integral()); + } +# endif +#else +# if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + basic_string(const _CharT* __f, const _CharT* __l, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _M_range_initialize(__f, __l); + } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + basic_string(const _CharT* __f, const _CharT* __l) + : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _M_range_initialize(__f, __l); + } +# endif +# endif +# if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + /* We need an additionnal constructor to build an empty string without + * any allocation or termination char*/ +protected: + struct _CalledFromWorkaround_t {}; + basic_string(_CalledFromWorkaround_t, const allocator_type &__a) + : _String_base<_CharT,_Alloc>(__a) {} +# endif +#endif + +_STLP_PRIVATE: + size_type _M_compute_next_size(size_type __n) { + const size_type __size = size(); + if (__n > max_size() - __size) + this->_M_throw_length_error(); + size_type __len = __size + (max)(__n, __size) + 1; + if (__len > max_size() || __len < __size) + __len = max_size(); // overflow + return __len; + } + + template + void _M_range_initialize(_InputIter __f, _InputIter __l, + const input_iterator_tag &__tag) { + this->_M_allocate_block(); + _M_construct_null(this->_M_Finish()); + _M_appendT(__f, __l, __tag); + } + + template + void _M_range_initialize(_ForwardIter __f, _ForwardIter __l, + const forward_iterator_tag &) { + difference_type __n = _STLP_STD::distance(__f, __l); + this->_M_allocate_block(__n + 1); + this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start()); + this->_M_terminate_string(); + } + + template + void _M_range_initializeT(_InputIter __f, _InputIter __l) { + _M_range_initialize(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); + } + + template + void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) { + this->_M_allocate_block(__n + 1); + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __x); + this->_M_terminate_string(); + } + + template + void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) { + _M_range_initializeT(__f, __l); + } + +public: + _Self& operator=(const _Self& __s) { + if (&__s != this) + _M_assign(__s._M_Start(), __s._M_Finish()); + return *this; + } + + _Self& operator=(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return _M_assign(__s, __s + traits_type::length(__s)); + } + + _Self& operator=(_CharT __c) + { return assign(__STATIC_CAST(size_type,1), __c); } + +private: + static _CharT _STLP_CALL _M_null() + { return _STLP_DEFAULT_CONSTRUCTED(_CharT); } + +_STLP_PRIVATE: // Helper functions used by constructors + // and elsewhere. + void _M_construct_null(_CharT* __p) const + { _STLP_STD::_Construct(__p); } + void _M_terminate_string() + { _M_construct_null(this->_M_Finish()); } + bool _M_inside(const _CharT* __s) const { + _STLP_FIX_LITERAL_BUG(__s) + return (__s >= this->_M_Start()) && (__s < this->_M_Finish()); + } + + void _M_range_initialize(const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + ptrdiff_t __n = __l - __f; + this->_M_allocate_block(__n + 1); + this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start()); + _M_terminate_string(); + } + +public: // Iterators. + iterator begin() { return this->_M_Start(); } + iterator end() { return this->_M_Finish(); } + const_iterator begin() const { return this->_M_Start(); } + const_iterator end() const { return this->_M_Finish(); } + + reverse_iterator rbegin() + { return reverse_iterator(this->_M_Finish()); } + reverse_iterator rend() + { return reverse_iterator(this->_M_Start()); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator(this->_M_Finish()); } + const_reverse_iterator rend() const + { return const_reverse_iterator(this->_M_Start()); } + +public: // Size, capacity, etc. + size_type size() const { return this->_M_Finish() - this->_M_Start(); } + size_type length() const { return size(); } + size_type max_size() const { return _Base::max_size(); } + + void resize(size_type __n, _CharT __c) { + if (__n <= size()) + erase(begin() + __n, end()); + else + append(__n - size(), __c); + } + + void resize(size_type __n) { resize(__n, _M_null()); } + +private: + void _M_reserve(size_type); +public: + void reserve(size_type = 0); + + size_type capacity() const + { return this->_M_capacity() - 1; } + + void clear() { + if (!empty()) { + _Traits::assign(*(this->_M_Start()), _M_null()); + this->_M_finish = this->_M_Start(); + } + } + + bool empty() const { return this->_M_Start() == this->_M_Finish(); } + +public: // Element access. + + const_reference operator[](size_type __n) const + { return *(this->_M_Start() + __n); } + reference operator[](size_type __n) + { return *(this->_M_Start() + __n); } + + const_reference at(size_type __n) const { + if (__n >= size()) + this->_M_throw_out_of_range(); + return *(this->_M_Start() + __n); + } + + reference at(size_type __n) { + if (__n >= size()) + this->_M_throw_out_of_range(); + return *(this->_M_Start() + __n); + } + +public: // Append, operator+=, push_back. + + _Self& operator+=(const _Self& __s) { return append(__s); } + _Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); } + _Self& operator+=(_CharT __c) { push_back(__c); return *this; } + +private: + _Self& _M_append(const _CharT* __first, const _CharT* __last); + +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + template + _Self& _M_appendT(_InputIter __first, _InputIter __last, + const input_iterator_tag &) { + for ( ; __first != __last ; ++__first) + push_back(*__first); + return *this; + } + + template + _Self& _M_appendT(_ForwardIter __first, _ForwardIter __last, + const forward_iterator_tag &) { + if (__first != __last) { + size_type __n = __STATIC_CAST(size_type, _STLP_STD::distance(__first, __last)); + if (__n >= this->_M_rest()) { + size_type __len = _M_compute_next_size(__n); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + pointer __new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start); + __new_finish = uninitialized_copy(__first, __last, __new_finish); + _M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + else { + _Traits::assign(*this->_M_finish, *__first++); + uninitialized_copy(__first, __last, this->_M_Finish() + 1); + _M_construct_null(this->_M_Finish() + __n); + this->_M_finish += __n; + } + } + return *this; + } + + template + _Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type& /*Integral*/) + { return append((size_type) __n, (_CharT) __x); } + + template + _Self& _M_append_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*Integral*/) + { return _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); } + +public: + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. + template + _Self& append(_InputIter __first, _InputIter __last) { + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + return _M_append_dispatch(__first, __last, _Integral()); + } +#else +public: + _Self& append(const _CharT* __first, const _CharT* __last) { + _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) + return _M_append(__first, __last); + } +#endif + +public: + _Self& append(const _Self& __s) + { return _M_append(__s._M_Start(), __s._M_Finish()); } + + _Self& append(const _Self& __s, + size_type __pos, size_type __n) { + if (__pos > __s.size()) + this->_M_throw_out_of_range(); + return _M_append(__s._M_Start() + __pos, + __s._M_Start() + __pos + (min) (__n, __s.size() - __pos)); + } + + _Self& append(const _CharT* __s, size_type __n) + { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s+__n); } + _Self& append(const _CharT* __s) + { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s + traits_type::length(__s)); } + _Self& append(size_type __n, _CharT __c); + +public: + void push_back(_CharT __c) { + if (this->_M_rest() == 1 ) + _M_reserve(_M_compute_next_size(1)); + _M_construct_null(this->_M_Finish() + 1); + _Traits::assign(*(this->_M_Finish()), __c); + ++this->_M_finish; + } + + void pop_back() { + _Traits::assign(*(this->_M_Finish() - 1), _M_null()); + --this->_M_finish; + } + +public: // Assign + _Self& assign(const _Self& __s) + { return _M_assign(__s._M_Start(), __s._M_Finish()); } + + _Self& assign(const _Self& __s, + size_type __pos, size_type __n) { + if (__pos > __s.size()) + this->_M_throw_out_of_range(); + return _M_assign(__s._M_Start() + __pos, + __s._M_Start() + __pos + (min) (__n, __s.size() - __pos)); + } + + _Self& assign(const _CharT* __s, size_type __n) + { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + __n); } + + _Self& assign(const _CharT* __s) + { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + _Traits::length(__s)); } + + _Self& assign(size_type __n, _CharT __c); + +private: + _Self& _M_assign(const _CharT* __f, const _CharT* __l); + +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + // Helper functions for assign. + template + _Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) + { return assign((size_type) __n, (_CharT) __x); } + + template + _Self& _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) { + pointer __cur = this->_M_Start(); + while (__f != __l && __cur != this->_M_Finish()) { + _Traits::assign(*__cur, *__f); + ++__f; + ++__cur; + } + if (__f == __l) + erase(__cur, this->end()); + else + _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); + return *this; + } + +public: + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. + template + _Self& assign(_InputIter __first, _InputIter __last) { + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + return _M_assign_dispatch(__first, __last, _Integral()); + } +#else +public: + _Self& assign(const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + return _M_assign(__f, __l); + } +#endif + +public: // Insert + _Self& insert(size_type __pos, const _Self& __s) { + if (__pos > size()) + this->_M_throw_out_of_range(); + if (__s.size() > max_size() - size()) + this->_M_throw_length_error(); + _M_insert(begin() + __pos, __s._M_Start(), __s._M_Finish(), &__s == this); + return *this; + } + + _Self& insert(size_type __pos, const _Self& __s, + size_type __beg, size_type __n) { + if (__pos > size() || __beg > __s.size()) + this->_M_throw_out_of_range(); + size_type __len = (min) (__n, __s.size() - __beg); + if (__len > max_size() - size()) + this->_M_throw_length_error(); + _M_insert(begin() + __pos, + __s._M_Start() + __beg, __s._M_Start() + __beg + __len, &__s == this); + return *this; + } + _Self& insert(size_type __pos, const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + if (__pos > size()) + this->_M_throw_out_of_range(); + if (__n > max_size() - size()) + this->_M_throw_length_error(); + _M_insert(begin() + __pos, __s, __s + __n, _M_inside(__s)); + return *this; + } + + _Self& insert(size_type __pos, const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + if (__pos > size()) + this->_M_throw_out_of_range(); + size_type __len = _Traits::length(__s); + if (__len > max_size() - size()) + this->_M_throw_length_error(); + _M_insert(this->_M_Start() + __pos, __s, __s + __len, _M_inside(__s)); + return *this; + } + + _Self& insert(size_type __pos, size_type __n, _CharT __c) { + if (__pos > size()) + this->_M_throw_out_of_range(); + if (__n > max_size() - size()) + this->_M_throw_length_error(); + insert(begin() + __pos, __n, __c); + return *this; + } + + iterator insert(iterator __p, _CharT __c) { + _STLP_FIX_LITERAL_BUG(__p) + if (__p == end()) { + push_back(__c); + return this->_M_Finish() - 1; + } + else + return _M_insert_aux(__p, __c); + } + + void insert(iterator __p, size_t __n, _CharT __c); + +_STLP_PRIVATE: // Helper functions for insert. + void _M_insert(iterator __p, const _CharT* __first, const _CharT* __last, bool __self_ref); + + pointer _M_insert_aux(pointer, _CharT); + + void _M_copy(const _CharT* __f, const _CharT* __l, _CharT* __res) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _STLP_FIX_LITERAL_BUG(__res) + _Traits::copy(__res, __f, __l - __f); + } + + void _M_move(const _CharT* __f, const _CharT* __l, _CharT* __res) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _Traits::move(__res, __f, __l - __f); + } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + template + void _M_insert_overflow(iterator __pos, _ForwardIter __first, _ForwardIter __last, + size_type __n) { + size_type __len = _M_compute_next_size(__n); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + pointer __new_finish = uninitialized_copy(this->_M_Start(), __pos, __new_start); + __new_finish = uninitialized_copy(__first, __last, __new_finish); + __new_finish = uninitialized_copy(__pos, this->_M_Finish(), __new_finish); + _M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + + template + void _M_insertT(iterator __p, _InputIter __first, _InputIter __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) { + __p = insert(__p, *__first); + ++__p; + } + } + + template + void _M_insertT(iterator __pos, _ForwardIter __first, _ForwardIter __last, + const forward_iterator_tag &) { + if (__first != __last) { + size_type __n = _STLP_STD::distance(__first, __last); + if (__n < this->_M_rest()) { + const size_type __elems_after = this->_M_finish - __pos; + if (__elems_after >= __n) { + uninitialized_copy((this->_M_Finish() - __n) + 1, this->_M_Finish() + 1, this->_M_Finish() + 1); + this->_M_finish += __n; + _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1); + _M_copyT(__first, __last, __pos); + } + else { + pointer __old_finish = this->_M_Finish(); + _ForwardIter __mid = __first; + _STLP_STD::advance(__mid, __elems_after + 1); + _STLP_STD::uninitialized_copy(__mid, __last, this->_M_Finish() + 1); + this->_M_finish += __n - __elems_after; + uninitialized_copy(__pos, __old_finish + 1, this->_M_Finish()); + this->_M_finish += __elems_after; + _M_copyT(__first, __mid, __pos); + } + } + else { + _M_insert_overflow(__pos, __first, __last, __n); + } + } + } + + template + void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x, + const __true_type& /*Integral*/) + { insert(__p, (size_type) __n, (_CharT) __x); } + + template + void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last, + const __false_type& /*Integral*/) { + _STLP_FIX_LITERAL_BUG(__p) + /* We are forced to do a temporary string to avoid the self referencing issue. */ + const _Self __self(__first, __last, get_allocator()); + _M_insertT(__p, __self.begin(), __self.end(), forward_iterator_tag()); + } + + template + void _M_copyT(_InputIterator __first, _InputIterator __last, pointer __result) { + _STLP_FIX_LITERAL_BUG(__result) + for ( ; __first != __last; ++__first, ++__result) + _Traits::assign(*__result, *__first); + } + +# if !defined (_STLP_NO_METHOD_SPECIALIZATION) + void _M_copyT(const _CharT* __f, const _CharT* __l, _CharT* __res) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _STLP_FIX_LITERAL_BUG(__res) + _Traits::copy(__res, __f, __l - __f); + } +# endif +public: + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. + template + void insert(iterator __p, _InputIter __first, _InputIter __last) { + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + _M_insert_dispatch(__p, __first, __last, _Integral()); + } +# endif +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) +public: + void insert(iterator __p, const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _M_insert(__p, __f, __l, _M_inside(__f)); + } +#endif + +public: // Erase. + _Self& erase(size_type __pos = 0, size_type __n = npos) { + if (__pos > size()) + this->_M_throw_out_of_range(); + erase(begin() + __pos, begin() + __pos + (min) (__n, size() - __pos)); + return *this; + } + + iterator erase(iterator __pos) { + // The move includes the terminating _CharT(). + _Traits::move(__pos, __pos + 1, this->_M_Finish() - __pos); + --this->_M_finish; + return __pos; + } + + iterator erase(iterator __first, iterator __last) { + if (__first != __last) { + // The move includes the terminating _CharT(). + traits_type::move(__first, __last, (this->_M_Finish() - __last) + 1); + this->_M_finish = this->_M_Finish() - (__last - __first); + } + return __first; + } + +public: // Replace. (Conceptually equivalent + // to erase followed by insert.) + _Self& replace(size_type __pos, size_type __n, const _Self& __s) { + const size_type __size = size(); + if (__pos > __size) + this->_M_throw_out_of_range(); + const size_type __len = (min) (__n, __size - __pos); + if (__s.size() > max_size() - (__size - __len)) + this->_M_throw_length_error(); + return _M_replace(begin() + __pos, begin() + __pos + __len, + __s._M_Start(), __s._M_Finish(), &__s == this); + } + + _Self& replace(size_type __pos1, size_type __n1, const _Self& __s, + size_type __pos2, size_type __n2) { + const size_type __size1 = size(); + const size_type __size2 = __s.size(); + if (__pos1 > __size1 || __pos2 > __size2) + this->_M_throw_out_of_range(); + const size_type __len1 = (min) (__n1, __size1 - __pos1); + const size_type __len2 = (min) (__n2, __size2 - __pos2); + if (__len2 > max_size() - (__size1 - __len1)) + this->_M_throw_length_error(); + return _M_replace(begin() + __pos1, begin() + __pos1 + __len1, + __s._M_Start() + __pos2, __s._M_Start() + __pos2 + __len2, &__s == this); + } + + _Self& replace(size_type __pos, size_type __n1, + const _CharT* __s, size_type __n2) { + _STLP_FIX_LITERAL_BUG(__s) + const size_type __size = size(); + if (__pos > __size) + this->_M_throw_out_of_range(); + const size_type __len = (min) (__n1, __size - __pos); + if (__n2 > max_size() - (__size - __len)) + this->_M_throw_length_error(); + return _M_replace(begin() + __pos, begin() + __pos + __len, + __s, __s + __n2, _M_inside(__s)); + } + + _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return replace(__pos, __n1, __s, _Traits::length(__s)); + } + + _Self& replace(size_type __pos, size_type __n1, + size_type __n2, _CharT __c) { + const size_type __size = size(); + if (__pos > __size) + this->_M_throw_out_of_range(); + const size_type __len = (min) (__n1, __size - __pos); + if (__n2 > max_size() - (__size - __len)) + this->_M_throw_length_error(); + return replace(begin() + __pos, begin() + __pos + __len, __n2, __c); + } + + _Self& replace(iterator __first, iterator __last, const _Self& __s) { + _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) + return _M_replace(__first, __last, __s._M_Start(), __s._M_Finish(), &__s == this); + } + + _Self& replace(iterator __first, iterator __last, + const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) + _STLP_FIX_LITERAL_BUG(__s) + return _M_replace(__first, __last, __s, __s + __n, _M_inside(__s)); + } + + _Self& replace(iterator __first, iterator __last, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) + _STLP_FIX_LITERAL_BUG(__s) + return _M_replace(__first, __last, __s, __s + _Traits::length(__s), _M_inside(__s)); + } + + _Self& replace(iterator __first, iterator __last, size_type __n, _CharT __c); + +_STLP_PRIVATE: // Helper functions for replace. + _Self& _M_replace(iterator __first, iterator __last, + const _CharT* __f, const _CharT* __l, bool __self_ref); + +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + template + _Self& _M_replace_dispatch(iterator __first, iterator __last, + _Integer __n, _Integer __x, const __true_type& /*IsIntegral*/) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + return replace(__first, __last, (size_type) __n, (_CharT) __x); + } + + template + _Self& _M_replace_dispatch(iterator __first, iterator __last, + _InputIter __f, _InputIter __l, const __false_type& /*IsIntegral*/) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + /* We are forced to do a temporary string to avoid the self referencing issue. */ + const _Self __self(__f, __l, get_allocator()); + return _M_replace(__first, __last, __self._M_Start(), __self._M_Finish(), false); + } + +public: + // Check to see if _InputIter is an integer type. If so, then + // it can't be an iterator. + template + _Self& replace(iterator __first, iterator __last, + _InputIter __f, _InputIter __l) { + _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + return _M_replace_dispatch(__first, __last, __f, __l, _Integral()); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) +public: + _Self& replace(iterator __first, iterator __last, + const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + return _M_replace(__first, __last, __f, __l, _M_inside(__f)); + } +#endif + +public: // Other modifier member functions. + + size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { + _STLP_FIX_LITERAL_BUG(__s) + if (__pos > size()) + this->_M_throw_out_of_range(); + const size_type __len = (min) (__n, size() - __pos); + _Traits::copy(__s, this->_M_Start() + __pos, __len); + return __len; + } + + void swap(_Self& __s) { this->_M_swap(__s); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +public: // Conversion to C string. + + const _CharT* c_str() const { return this->_M_Start(); } + const _CharT* data() const { return this->_M_Start(); } + +public: // find. + size_type find(const _Self& __s, size_type __pos = 0) const + { return find(__s._M_Start(), __pos, __s.size()); } + + size_type find(const _CharT* __s, size_type __pos = 0) const + { _STLP_FIX_LITERAL_BUG(__s) return find(__s, __pos, _Traits::length(__s)); } + + size_type find(const _CharT* __s, size_type __pos, size_type __n) const; + + // WIE: Versant schema compiler 5.2.2 ICE workaround + size_type find(_CharT __c) const { return find(__c, 0); } + size_type find(_CharT __c, size_type __pos /* = 0 */) const; + +public: // rfind. + size_type rfind(const _Self& __s, size_type __pos = npos) const + { return rfind(__s._M_Start(), __pos, __s.size()); } + + size_type rfind(const _CharT* __s, size_type __pos = npos) const + { _STLP_FIX_LITERAL_BUG(__s) return rfind(__s, __pos, _Traits::length(__s)); } + + size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const; + size_type rfind(_CharT __c, size_type __pos = npos) const; + +public: // find_first_of + size_type find_first_of(const _Self& __s, size_type __pos = 0) const + { return find_first_of(__s._M_Start(), __pos, __s.size()); } + + size_type find_first_of(const _CharT* __s, size_type __pos = 0) const + { _STLP_FIX_LITERAL_BUG(__s) return find_first_of(__s, __pos, _Traits::length(__s)); } + + size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type find_first_of(_CharT __c, size_type __pos = 0) const + { return find(__c, __pos); } + +public: // find_last_of + size_type find_last_of(const _Self& __s, size_type __pos = npos) const + { return find_last_of(__s._M_Start(), __pos, __s.size()); } + + size_type find_last_of(const _CharT* __s, size_type __pos = npos) const + { _STLP_FIX_LITERAL_BUG(__s) return find_last_of(__s, __pos, _Traits::length(__s)); } + + size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type find_last_of(_CharT __c, size_type __pos = npos) const + { return rfind(__c, __pos); } + +public: // find_first_not_of + size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const + { return find_first_not_of(__s._M_Start(), __pos, __s.size()); } + + size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const + { _STLP_FIX_LITERAL_BUG(__s) return find_first_not_of(__s, __pos, _Traits::length(__s)); } + + size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type find_first_not_of(_CharT __c, size_type __pos = 0) const; + +public: // find_last_not_of + size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const + { return find_last_not_of(__s._M_Start(), __pos, __s.size()); } + + size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const + { _STLP_FIX_LITERAL_BUG(__s) return find_last_not_of(__s, __pos, _Traits::length(__s)); } + + size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type find_last_not_of(_CharT __c, size_type __pos = npos) const; + +public: // Substring. + _Self substr(size_type __pos = 0, size_type __n = npos) const + { return _Self(*this, __pos, __n, get_allocator()); } + +public: // Compare + int compare(const _Self& __s) const + { return _M_compare(this->_M_Start(), this->_M_Finish(), __s._M_Start(), __s._M_Finish()); } + + int compare(size_type __pos1, size_type __n1, const _Self& __s) const { + if (__pos1 > size()) + this->_M_throw_out_of_range(); + return _M_compare(this->_M_Start() + __pos1, + this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), + __s._M_Start(), __s._M_Finish()); + } + + int compare(size_type __pos1, size_type __n1, const _Self& __s, + size_type __pos2, size_type __n2) const { + if (__pos1 > size() || __pos2 > __s.size()) + this->_M_throw_out_of_range(); + return _M_compare(this->_M_Start() + __pos1, + this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), + __s._M_Start() + __pos2, + __s._M_Start() + __pos2 + (min) (__n2, __s.size() - __pos2)); + } + + int compare(const _CharT* __s) const { + _STLP_FIX_LITERAL_BUG(__s) + return _M_compare(this->_M_Start(), this->_M_Finish(), __s, __s + _Traits::length(__s)); + } + + int compare(size_type __pos1, size_type __n1, const _CharT* __s) const { + _STLP_FIX_LITERAL_BUG(__s) + if (__pos1 > size()) + this->_M_throw_out_of_range(); + return _M_compare(this->_M_Start() + __pos1, + this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), + __s, __s + _Traits::length(__s)); + } + + int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const { + _STLP_FIX_LITERAL_BUG(__s) + if (__pos1 > size()) + this->_M_throw_out_of_range(); + return _M_compare(this->_M_Start() + __pos1, + this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1), + __s, __s + __n2); + } + +public: // Helper functions for compare. + static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1, + const _CharT* __f2, const _CharT* __l2) { + const ptrdiff_t __n1 = __l1 - __f1; + const ptrdiff_t __n2 = __l2 - __f2; + const int cmp = _Traits::compare(__f1, __f2, (min) (__n1, __n2)); + return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0)); + } +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) && !defined (_STLP_DEBUG) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# define _STLP_STRING_SUM_BASE(__reserve, __size, __alloc) _STLP_PRIV _String_base<_CharT,_Alloc>(__alloc, __size + 1) +# include +# undef _STLP_STRING_SUM_BASE +#endif +}; + +#undef _STLP_PRIVATE + +#if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96) +template +const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0; +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS basic_string, allocator >; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS basic_string, allocator >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +#if defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +# undef basic_string +#endif + +_STLP_END_NAMESPACE + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +# include +#endif + +#if defined (_STLP_DEBUG) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// ------------------------------------------------------------ +// Non-member functions. +// Swap. +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template +inline void _STLP_CALL +swap(basic_string<_CharT,_Traits,_Alloc>& __x, + basic_string<_CharT,_Traits,_Alloc>& __y) +{ __x.swap(__y); } +#else +inline void _STLP_CALL swap(string& __x, string& __y) +{ __x.swap(__y); } +# if defined (_STLP_HAS_WCHAR_T) +inline void _STLP_CALL swap(wstring& __x, wstring& __y) +{ __x.swap(__y); } +# endif +#endif + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > { + typedef __true_type implemented; + //Completness depends on the allocator: + typedef typename __move_traits<_Alloc>::complete complete; +}; +/*#else + * There is no need to specialize for string and wstring in this case + * as the default __move_traits will already tell that string is movable + * but not complete. We cannot define it as complete as nothing guaranty + * that the STLport user hasn't specialized std::allocator for char or + * wchar_t. + */ +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s, + _CharT* __buf, size_t __n); + +#if defined(_STLP_USE_WIDE_INTERFACE) +// A couple of functions to transfer between ASCII/Unicode +wstring __ASCIIToWide(const char *ascii); +string __WideToASCII(const wchar_t *wide); +#endif + +inline const char* _STLP_CALL +__get_c_string(const string& __str) { return __str.c_str(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#include + +#if defined(_STLP_USE_NO_IOSTREAMS) || \ + (defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)) +# include +#endif + +#endif /* _STLP_INTERNAL_STRING_H */ + +/* + * Local Variables: + * mode:C++ + * End: + */ diff --git a/sdk/tlibstdcxx/stlport/stl/_string_base.h b/sdk/tlibstdcxx/stlport/stl/_string_base.h new file mode 100644 index 0000000000..7c6d7fe694 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_base.h @@ -0,0 +1,231 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STRING_BASE_H +#define _STLP_STRING_BASE_H + +// ------------------------------------------------------------ +// Class _String_base. + +// _String_base is a helper class that makes it it easier to write an +// exception-safe version of basic_string. The constructor allocates, +// but does not initialize, a block of memory. The destructor +// deallocates, but does not destroy elements within, a block of +// memory. The destructor assumes that _M_start either is null, or else +// points to a block of memory that was allocated using _String_base's +// allocator and whose size is _M_end_of_storage - _M_start_of_storage._M_data. + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class _String_base { + typedef _String_base<_Tp, _Alloc> _Self; +protected: + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) +public: + //dums: Some compiler(MSVC6) require it to be public not simply protected! + enum {_DEFAULT_SIZE = 4 * sizeof( void * )}; + //This is needed by the full move framework + typedef _Alloc allocator_type; + typedef _STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _AllocProxy; + typedef size_t size_type; +private: +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + union _Buffers { + _Tp* _M_end_of_storage; + _Tp _M_static_buf[_DEFAULT_SIZE]; + } _M_buffers; +#else + _Tp* _M_end_of_storage; +#endif /* _STLP_USE_SHORT_STRING_OPTIM */ +protected: +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + bool _M_using_static_buf() const + { return (_M_start_of_storage._M_data == _M_buffers._M_static_buf); } + _Tp const* _M_Start() const { return _M_start_of_storage._M_data; } + _Tp* _M_Start() { return _M_start_of_storage._M_data; } + _Tp const* _M_End() const + { return _M_using_static_buf() ? _M_buffers._M_static_buf + _DEFAULT_SIZE : _M_buffers._M_end_of_storage; } + _Tp* _M_End() + { return _M_using_static_buf() ? _M_buffers._M_static_buf + _DEFAULT_SIZE : _M_buffers._M_end_of_storage; } + size_type _M_capacity() const + { return _M_using_static_buf() ? _DEFAULT_SIZE : _M_buffers._M_end_of_storage - _M_start_of_storage._M_data; } + size_type _M_rest() const + { return _M_using_static_buf() ? _DEFAULT_SIZE - (_M_finish - _M_buffers._M_static_buf) : _M_buffers._M_end_of_storage - _M_finish; } +#else + _Tp const* _M_Start() const { return _M_start_of_storage._M_data; } + _Tp* _M_Start() { return _M_start_of_storage._M_data; } + _Tp const* _M_End() const { return _M_end_of_storage; } + _Tp* _M_End() { return _M_end_of_storage; } + size_type _M_capacity() const + { return _M_end_of_storage - _M_start_of_storage._M_data; } + size_type _M_rest() const + { return _M_end_of_storage - _M_finish; } +#endif /* _STLP_USE_SHORT_STRING_OPTIM */ + + _Tp* _M_finish; + _AllocProxy _M_start_of_storage; + + _Tp const* _M_Finish() const {return _M_finish;} + _Tp* _M_Finish() {return _M_finish;} + + // Precondition: 0 < __n <= max_size(). + void _M_allocate_block(size_t __n = _DEFAULT_SIZE); + void _M_deallocate_block() { +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + if (!_M_using_static_buf() && (_M_start_of_storage._M_data != 0)) + _M_start_of_storage.deallocate(_M_start_of_storage._M_data, _M_buffers._M_end_of_storage - _M_start_of_storage._M_data); +#else + if (_M_start_of_storage._M_data != 0) + _M_start_of_storage.deallocate(_M_start_of_storage._M_data, _M_end_of_storage - _M_start_of_storage._M_data); +#endif /* _STLP_USE_SHORT_STRING_OPTIM */ + } + + size_t max_size() const { + const size_type __string_max_size = size_type(-1) / sizeof(_Tp); + typename allocator_type::size_type __alloc_max_size = _M_start_of_storage.max_size(); + return (min)(__alloc_max_size, __string_max_size) - 1; + } + + _String_base(const allocator_type& __a) +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + : _M_finish(_M_buffers._M_static_buf), _M_start_of_storage(__a, _M_buffers._M_static_buf) +#else + : _M_end_of_storage(0), _M_finish(0), _M_start_of_storage(__a, (_Tp*)0) +#endif + {} + + _String_base(const allocator_type& __a, size_t __n) +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + : _M_finish(_M_buffers._M_static_buf), _M_start_of_storage(__a, _M_buffers._M_static_buf) { +#else + : _M_end_of_storage(0), _M_finish(0), _M_start_of_storage(__a, (_Tp*)0) { +#endif + _M_allocate_block(__n); + } + +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + void _M_move_src (_Self &src) { + if (src._M_using_static_buf()) { + _M_buffers = src._M_buffers; + _M_finish = _M_buffers._M_static_buf + (src._M_finish - src._M_start_of_storage._M_data); + _M_start_of_storage._M_data = _M_buffers._M_static_buf; + } + else { + _M_start_of_storage._M_data = src._M_start_of_storage._M_data; + _M_finish = src._M_finish; + _M_buffers._M_end_of_storage = src._M_buffers._M_end_of_storage; + src._M_start_of_storage._M_data = 0; + } + } +#endif + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _String_base(__move_source<_Self> src) +# if defined (_STLP_USE_SHORT_STRING_OPTIM) + : _M_start_of_storage(__move_source<_AllocProxy>(src.get()._M_start_of_storage)) { + _M_move_src(src.get()); +# else + : _M_end_of_storage(src.get()._M_end_of_storage), _M_finish(src.get()._M_finish), + _M_start_of_storage(__move_source<_AllocProxy>(src.get()._M_start_of_storage)) { + src.get()._M_start_of_storage._M_data = 0; +# endif + } +#endif + + ~_String_base() { _M_deallocate_block(); } + + void _M_reset(_Tp *__start, _Tp *__finish, _Tp *__end_of_storage) { +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + _M_buffers._M_end_of_storage = __end_of_storage; +#else + _M_end_of_storage = __end_of_storage; +#endif + _M_finish = __finish; + _M_start_of_storage._M_data = __start; + } + + void _M_swap(_Self &__s) { +#if defined (_STLP_USE_SHORT_STRING_OPTIM) + if (_M_using_static_buf()) { + if (__s._M_using_static_buf()) { + _STLP_STD::swap(_M_buffers, __s._M_buffers); + _Tp *__tmp = _M_finish; + _M_finish = _M_start_of_storage._M_data + (__s._M_finish - __s._M_start_of_storage._M_data); + __s._M_finish = __s._M_buffers._M_static_buf + (__tmp - _M_start_of_storage._M_data); + //We need to swap _M_start_of_storage for allocators with state: + _M_start_of_storage.swap(__s._M_start_of_storage); + _M_start_of_storage._M_data = _M_buffers._M_static_buf; + __s._M_start_of_storage._M_data = __s._M_buffers._M_static_buf; + } else { + __s._M_swap(*this); + return; + } + } + else if (__s._M_using_static_buf()) { + _Tp *__tmp = _M_start_of_storage._M_data; + _Tp *__tmp_finish = _M_finish; + _Tp *__tmp_end_data = _M_buffers._M_end_of_storage; + _M_buffers = __s._M_buffers; + //We need to swap _M_start_of_storage for allocators with state: + _M_start_of_storage.swap(__s._M_start_of_storage); + _M_start_of_storage._M_data = _M_buffers._M_static_buf; + _M_finish = _M_buffers._M_static_buf + (__s._M_finish - __s._M_buffers._M_static_buf); + __s._M_buffers._M_end_of_storage = __tmp_end_data; + __s._M_start_of_storage._M_data = __tmp; + __s._M_finish = __tmp_finish; + } + else { + _STLP_STD::swap(_M_buffers._M_end_of_storage, __s._M_buffers._M_end_of_storage); + _M_start_of_storage.swap(__s._M_start_of_storage); + _STLP_STD::swap(_M_finish, __s._M_finish); + } +#else + _STLP_STD::swap(_M_end_of_storage, __s._M_end_of_storage); + _M_start_of_storage.swap(__s._M_start_of_storage); + _STLP_STD::swap(_M_finish, __s._M_finish); +#endif + } + + void _STLP_FUNCTION_THROWS _M_throw_length_error() const; + void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const; +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _String_base >; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS _String_base >; +# endif +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_STRING_BASE_H */ + +/* + * Local Variables: + * mode:C++ + * End: + */ diff --git a/sdk/tlibstdcxx/stlport/stl/_string_fwd.h b/sdk/tlibstdcxx/stlport/stl/_string_fwd.h new file mode 100644 index 0000000000..93fb29458c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_fwd.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STRING_FWD_H +#define _STLP_STRING_FWD_H + +#ifndef _STLP_CHAR_TRAITS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template , + class _Alloc = allocator<_CharT> > +class basic_string; +#else +template +class basic_string; +#endif /* _STLP_LIMITED_DEFAULT_TEMPLATES */ + +typedef basic_string, allocator > string; + +#if defined (_STLP_HAS_WCHAR_T) +typedef basic_string, allocator > wstring; +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +//This function limits header dependency between exception and string +//implementation. It is implemented in _string.h +const char* _STLP_CALL __get_c_string(const string& __str); + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_STRING_FWD_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_string_hash.h b/sdk/tlibstdcxx/stlport/stl/_string_hash.h new file mode 100644 index 0000000000..87f2d9fbea --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_hash.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STRING_HASH_H +#define _STLP_STRING_HASH_H + +#ifndef _STLP_HASH_FUN_H +# include +#endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +_STLP_INLINE_LOOP size_t +__stl_string_hash(const basic_string<_CharT,_Traits,_Alloc>& __s) { + unsigned long __h = 0; + size_t __len = __s.size(); + const _CharT* __data = __s.data(); + for ( size_t __i = 0; __i < __len; ++__i) + __h = /* 5 *__h */(__h << 2) + __h + __data[__i]; + return size_t(__h); +} + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && \ + (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x560)) +template +struct hash > { + size_t operator()(const basic_string<_CharT,_Traits,_Alloc>& __s) const + { return __stl_string_hash(__s); } +}; + +#else + +_STLP_TEMPLATE_NULL +struct _STLP_CLASS_DECLSPEC hash { + size_t operator()(const string& __s) const + { return __stl_string_hash(__s); } +}; + +# if defined (_STLP_HAS_WCHAR_T) +_STLP_TEMPLATE_NULL +struct _STLP_CLASS_DECLSPEC hash { + size_t operator()(const wstring& __s) const + { return __stl_string_hash(__s); } +}; +# endif + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_string_io.c b/sdk/tlibstdcxx/stlport/stl/_string_io.c new file mode 100644 index 0000000000..84b18736b5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_io.c @@ -0,0 +1,172 @@ +#ifndef _STLP_STRING_IO_C +#define _STLP_STRING_IO_C + +#ifndef _STLP_STRING_IO_H +# include +#endif + +#ifndef _STLP_INTERNAL_CTYPE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +bool _STLP_CALL +__stlp_string_fill(basic_ostream<_CharT, _Traits>& __os, + basic_streambuf<_CharT, _Traits>* __buf, + streamsize __n) { + _CharT __f = __os.fill(); + for (streamsize __i = 0; __i < __n; ++__i) { + if (_Traits::eq_int_type(__buf->sputc(__f), _Traits::eof())) + return false; + } + return true; +} + + +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +operator << (basic_ostream<_CharT, _Traits>& __os, + const basic_string<_CharT,_Traits,_Alloc>& __s) { + typedef basic_ostream<_CharT, _Traits> __ostream; + typedef typename basic_string<_CharT, _Traits, _Alloc>::size_type size_type; + + // The hypothesis of this implementation is that size_type is unsigned: + _STLP_STATIC_ASSERT(__STATIC_CAST(size_type, -1) > 0) + + typename __ostream::sentry __sentry(__os); + bool __ok = false; + + if (__sentry) { + __ok = true; + size_type __n = __s.size(); + const bool __left = (__os.flags() & __ostream::left) != 0; + const streamsize __w = __os.width(0); + basic_streambuf<_CharT, _Traits>* __buf = __os.rdbuf(); + + const bool __need_pad = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __n) < __w)) || + ((sizeof(streamsize) <= sizeof(size_t)) && (__n < __STATIC_CAST(size_t, __w)))); + streamsize __pad_len = __need_pad ? __w - __n : 0; + + if (!__left) + __ok = __stlp_string_fill(__os, __buf, __pad_len); + + __ok = __ok && (__buf->sputn(__s.data(), streamsize(__n)) == streamsize(__n)); + + if (__left) + __ok = __ok && __stlp_string_fill(__os, __buf, __pad_len); + } + + if (!__ok) + __os.setstate(__ostream::failbit); + + return __os; +} + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +operator >> (basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT,_Traits, _Alloc>& __s) { + typedef basic_istream<_CharT, _Traits> __istream; + typedef typename basic_string<_CharT, _Traits, _Alloc>::size_type size_type; + + // The hypothesis of this implementation is that size_type is unsigned: + _STLP_STATIC_ASSERT(__STATIC_CAST(size_type, -1) > 0) + + typename __istream::sentry __sentry(__is); + + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); + typedef ctype<_CharT> _C_type; + + const locale& __loc = __is.getloc(); + const _C_type& _Ctype = use_facet<_C_type>(__loc); + __s.clear(); + streamsize __width = __is.width(0); + size_type __n; + if (__width <= 0) + __n = __s.max_size(); + /* __width can only overflow size_type if sizeof(streamsize) > sizeof(size_type) + * because here we know that __width is positive and the stattic assertion check + * that size_type is unsigned. + */ + else if (sizeof(streamsize) > sizeof(size_type) && + (__width > __STATIC_CAST(streamsize, __s.max_size()))) + __n = 0; + else { + __n = __STATIC_CAST(size_type, __width); + __s.reserve(__n); + } + + while (__n-- > 0) { + typename _Traits::int_type __c1 = __buf->sbumpc(); + if (_Traits::eq_int_type(__c1, _Traits::eof())) { + __is.setstate(__istream::eofbit); + break; + } + else { + _CharT __c = _Traits::to_char_type(__c1); + + if (_Ctype.is(_C_type::space, __c)) { + if (_Traits::eq_int_type(__buf->sputbackc(__c), _Traits::eof())) + __is.setstate(__istream::failbit); + break; + } + else + __s.push_back(__c); + } + } + + // If we have read no characters, then set failbit. + if (__s.empty()) + __is.setstate(__istream::failbit); + } + else + __is.setstate(__istream::failbit); + + return __is; +} + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +getline(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT,_Traits,_Alloc>& __s, + _CharT __delim) { + typedef basic_istream<_CharT, _Traits> __istream; + typedef typename basic_string<_CharT, _Traits, _Alloc>::size_type size_type; + size_type __nread = 0; + typename basic_istream<_CharT, _Traits>::sentry __sentry(__is, true); + if (__sentry) { + basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); + __s.clear(); + + while (__nread < __s.max_size()) { + int __c1 = __buf->sbumpc(); + if (_Traits::eq_int_type(__c1, _Traits::eof())) { + __is.setstate(__istream::eofbit); + break; + } + else { + ++__nread; + _CharT __c = _Traits::to_char_type(__c1); + if (!_Traits::eq(__c, __delim)) + __s.push_back(__c); + else + break; // Character is extracted but not appended. + } + } + } + if (__nread == 0 || __nread >= __s.max_size()) + __is.setstate(__istream::failbit); + + return __is; +} + +_STLP_END_NAMESPACE + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_string_io.h b/sdk/tlibstdcxx/stlport/stl/_string_io.h new file mode 100644 index 0000000000..fe549fef64 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_io.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STRING_IO_H +#define _STLP_STRING_IO_H + +#ifndef _STLP_INTERNAL_OSTREAM_H +# include +#endif + +#ifndef _STLP_INTERNAL_ISTREAM +# include +#endif + +// I/O. +_STLP_BEGIN_NAMESPACE + +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, + const basic_string<_CharT,_Traits,_Alloc>& __s); + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) + +template +basic_ostream<_CharT, _Traits>& _STLP_CALL +operator<<(basic_ostream<_CharT, _Traits>& __os, + const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __sum) { + basic_string<_CharT, _Traits, _Alloc> __tmp(__sum); + return __os << __tmp; +} + +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT,_Traits,_Alloc>& __s); + +template +basic_istream<_CharT, _Traits>& _STLP_CALL +getline(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT,_Traits,_Alloc>& __s, + _CharT __delim); + +#if !(defined (__BORLANDC__) && !defined (_STLP_USE_OWN_NAMESPACE)) + +template +inline basic_istream<_CharT, _Traits>& _STLP_CALL +getline(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT,_Traits,_Alloc>& __s) { + return getline(__is, __s, __is.widen('\n')); +} +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_STRING_IO_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/_string_npos.h b/sdk/tlibstdcxx/stlport/stl/_string_npos.h new file mode 100644 index 0000000000..faa9c62728 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_npos.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* This header contains npos definition used in basic_string and rope + * implementation. It do not have to be guarded as files including it + * are already guarded and it has sometimes to be included several times. + */ + +#if defined (_STLP_STATIC_CONST_INIT_BUG) + enum { npos = -1 }; +#elif defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96) + // inline initializer conflicts with 'extern template' + static const size_t npos; +#else + static const size_t npos = ~(size_t)0; +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_string_operators.h b/sdk/tlibstdcxx/stlport/stl/_string_operators.h new file mode 100644 index 0000000000..cff13af01c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_operators.h @@ -0,0 +1,602 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STRING_OPERATORS_H +#define _STLP_STRING_OPERATORS_H + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_USE_TEMPLATE_EXPRESSION) + +# if defined (__GNUC__) || defined (__MLCCPP__) +# define _STLP_INIT_AMBIGUITY 1 +# endif + +template +inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL +operator+(const basic_string<_CharT,_Traits,_Alloc>& __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + typedef basic_string<_CharT,_Traits,_Alloc> _Str; + typedef typename _Str::_Reserve_t _Reserve_t; +# if defined (_STLP_INIT_AMBIGUITY) + // gcc counts this as a function + _Str __result = _Str(_Reserve_t(), __s.size() + __y.size(), __s.get_allocator()); +# else + _Str __result(_Reserve_t(), __s.size() + __y.size(), __s.get_allocator()); +# endif + __result.append(__s); + __result.append(__y); + return __result; +} + +template +inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL +operator+(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + typedef basic_string<_CharT,_Traits,_Alloc> _Str; + typedef typename _Str::_Reserve_t _Reserve_t; + const size_t __n = _Traits::length(__s); +# if defined (_STLP_INIT_AMBIGUITY) + _Str __result = _Str(_Reserve_t(), __n + __y.size(), __y.get_allocator()); +# else + _Str __result(_Reserve_t(), __n + __y.size(), __y.get_allocator()); +# endif + __result.append(__s, __s + __n); + __result.append(__y); + return __result; +} + +template +inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL +operator+(_CharT __c, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + typedef basic_string<_CharT,_Traits,_Alloc> _Str; + typedef typename _Str::_Reserve_t _Reserve_t; +# if defined (_STLP_INIT_AMBIGUITY) + _Str __result = _Str(_Reserve_t(), 1 + __y.size(), __y.get_allocator()); +# else + _Str __result(_Reserve_t(), 1 + __y.size(), __y.get_allocator()); +# endif + __result.push_back(__c); + __result.append(__y); + return __result; +} + +template +inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL +operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + typedef basic_string<_CharT,_Traits,_Alloc> _Str; + typedef typename _Str::_Reserve_t _Reserve_t; + const size_t __n = _Traits::length(__s); +# if defined (_STLP_INIT_AMBIGUITY) + _Str __result = _Str(_Reserve_t(), __x.size() + __n, __x.get_allocator()); +# else + _Str __result(_Reserve_t(), __x.size() + __n, __x.get_allocator()); +# endif + __result.append(__x); + __result.append(__s, __s + __n); + return __result; +} + +template +inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL +operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT __c) { + typedef basic_string<_CharT,_Traits,_Alloc> _Str; + typedef typename _Str::_Reserve_t _Reserve_t; +# if defined (_STLP_INIT_AMBIGUITY) + _Str __result = _Str(_Reserve_t(), __x.size() + 1, __x.get_allocator()); +# else + _Str __result(_Reserve_t(), __x.size() + 1, __x.get_allocator()); +# endif + __result.append(__x); + __result.push_back(__c); + return __result; +} + +# undef _STLP_INIT_AMBIGUITY + +#else /* _STLP_USE_TEMPLATE_EXPRESSION */ + +// addition with basic_string +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const basic_string<_CharT,_Traits,_Alloc>& __lhs, + const basic_string<_CharT,_Traits,_Alloc>& __rhs) { + typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right> __root_type; + __root_type __root(__rhs, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__lhs.get_allocator())); + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + __root_type, + _STLP_PRIV __on_right>(__lhs, __root); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const basic_string<_CharT,_Traits,_Alloc>& __lhs, + const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __rhs) { + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __on_right>(__lhs, __rhs); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __on_left> _STLP_CALL +operator+(const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __lhs, + const basic_string<_CharT,_Traits,_Alloc>& __rhs) { + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __on_left>(__lhs, __rhs); +} + +// addition with C string +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __cstr_wrapper<_CharT>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + const size_t __n = _Traits::length(__s); + typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __cstr_wrapper<_CharT>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right> __root_type; + __root_type __root(_STLP_PRIV __cstr_wrapper<_CharT>(__s, __n), _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__x.get_allocator())); + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + __root_type, _STLP_PRIV __on_right>(__x, __root); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __cstr_wrapper<_CharT>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + const size_t __n = _Traits::length(__s); + typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right> __root_type; + __root_type __root(__y, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__y.get_allocator())); + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __cstr_wrapper<_CharT>, + __root_type, + _STLP_PRIV __on_right>(_STLP_PRIV __cstr_wrapper<_CharT>(__s, __n), __root); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __cstr_wrapper<_CharT>, + _STLP_PRIV __on_left> _STLP_CALL +operator+(const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __x, + const _CharT* __s) { + const size_t __n = _Traits::length(__s); + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __cstr_wrapper<_CharT>, + _STLP_PRIV __on_left>(__x, _STLP_PRIV __cstr_wrapper<_CharT>(__s, __n)); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __cstr_wrapper<_CharT>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const _CharT* __s, + const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __y) { + const size_t __n = _Traits::length(__s); + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __cstr_wrapper<_CharT>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __on_right>(_STLP_PRIV __cstr_wrapper<_CharT>(__s, __n), __y); +} + +// addition with char +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __char_wrapper<_CharT>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, const _CharT __c) { + typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right> __root_type; + __root_type __root(__c, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__x.get_allocator())); + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + __root_type, _STLP_PRIV __on_right>(__x, __root); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __char_wrapper<_CharT>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const _CharT __c, const basic_string<_CharT,_Traits,_Alloc>& __x) { + typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, + _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, + _STLP_PRIV __on_right> __root_type; + __root_type __root(__x, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__x.get_allocator())); + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, + __root_type, _STLP_PRIV __on_right>(__c, __root); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __char_wrapper<_CharT>, + _STLP_PRIV __on_left> _STLP_CALL +operator+(const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __x, const _CharT __c) { + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __char_wrapper<_CharT>, _STLP_PRIV __on_left>(__x, __c); +} + +template +inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __on_right> _STLP_CALL +operator+(const _CharT __c, const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __x) { + return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, + _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, + _STLP_PRIV __on_right>(__c, __x); +} + +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +// Operator== and operator!= + +template +inline bool _STLP_CALL +operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0; +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator==(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0; +} + +template +inline bool _STLP_CALL +operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0; +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + + +template +inline bool _STLP_CALL +operator==(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0; +} + +template +inline bool _STLP_CALL +operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0; +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator==(const _CharT* __s, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0; +} + +template +inline bool _STLP_CALL +operator==(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0; +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +// Operator< (and also >, <=, and >=). + +template +inline bool _STLP_CALL +operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()) < 0; +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator<(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()) < 0; +} + +template +inline bool _STLP_CALL +operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()) < 0; +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +template +inline bool _STLP_CALL +operator<(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__s, __s + __n, + __y.begin(), __y.end()) < 0; +} + +template +inline bool _STLP_CALL +operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), + __s, __s + __n) < 0; +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator<(const _CharT* __s, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__s, __s + __n, + __y.begin(), __y.end()) < 0; +} + +template +inline bool _STLP_CALL +operator<(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + size_t __n = _Traits::length(__s); + return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), + __s, __s + __n) < 0; +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) + +/* Only defined if _STLP_USE_SEPARATE_RELOPS_NAMESPACE is defined otherwise + * it might introduce ambiguity with pure template relational operators + * from rel_ops namespace. + */ +template +inline bool _STLP_CALL +operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) +{ return !(__x == __y); } + +template +inline bool _STLP_CALL +operator>(const basic_string<_CharT,_Traits,_Alloc>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) +{ return __y < __x; } + +template +inline bool _STLP_CALL +operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) +{ return !(__y < __x); } + +template +inline bool _STLP_CALL +operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) +{ return !(__x < __y); } + +# if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator!=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const basic_string<_CharT,_Traits,_Alloc>& __y) +{ return !(__x==__y); } + +template +inline bool _STLP_CALL +operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) +{ return !(__x==__y); } +# endif + +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template +inline bool _STLP_CALL +operator!=(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__s == __y); +} + +template +inline bool _STLP_CALL +operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__x == __s); +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator!=(const _CharT* __s, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__s == __y); +} + +template +inline bool _STLP_CALL +operator!=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__x == __s); +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +template +inline bool _STLP_CALL +operator>(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return __y < __s; +} + +template +inline bool _STLP_CALL +operator>(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return __s < __x; +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator>(const _CharT* __s, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return __y < __s; +} + +template +inline bool _STLP_CALL +operator>(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return __s < __x; +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +template +inline bool _STLP_CALL +operator<=(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__y < __s); +} + +template +inline bool _STLP_CALL +operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__s < __x); +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator<=(const _CharT* __s, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__y < __s); +} + +template +inline bool _STLP_CALL +operator<=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__s < __x); +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +template +inline bool _STLP_CALL +operator>=(const _CharT* __s, + const basic_string<_CharT,_Traits,_Alloc>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__s < __y); +} + +template +inline bool _STLP_CALL +operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__x < __s); +} + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +template +inline bool _STLP_CALL +operator>=(const _CharT* __s, + const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__s < __y); +} + +template +inline bool _STLP_CALL +operator>=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + return !(__x < __s); +} +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_STRING_OPERATORS_H */ + diff --git a/sdk/tlibstdcxx/stlport/stl/_string_sum.h b/sdk/tlibstdcxx/stlport/stl/_string_sum.h new file mode 100644 index 0000000000..739d2884f0 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_sum.h @@ -0,0 +1,414 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STRING_SUM_H +#define _STLP_STRING_SUM_H + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/*char wrapper to simulate basic_string*/ +template +struct __char_wrapper { + typedef const _CharT& const_reference; + + __char_wrapper(_CharT __val) : _Val(__val) {} + + _CharT getValue() const { return _Val; } + size_t size() const { return 1; } + + const_reference operator[] (size_t __n) const { + //To avoid a check on __n we use this strange implementation + return (&_Val)[__n]; + } + +private: + _CharT _Val; +}; + +/*C string wrapper to simulate basic_string*/ +template +struct __cstr_wrapper { + typedef const _CharT& const_reference; + + __cstr_wrapper(const _CharT *__cstr, size_t __size) : + _CStr(__cstr), _Size(__size) {} + + const _CharT* c_str() const { return _CStr; } + + size_t size() const { return _Size; } + + const_reference operator[] (size_t __n) const { return _CStr[__n]; } + +private: + const _CharT *_CStr; + size_t _Size; +}; + +/*basic_string wrapper to ensure that we only store a reference to the original string and not copy it*/ +template +struct __bstr_wrapper { + typedef const _CharT& const_reference; + typedef basic_string<_CharT, _Traits, _Alloc> _BString; + + __bstr_wrapper (_BString const& __s) : + _BStr(__s) {} + + size_t size() const { return _BStr.size(); } + + const_reference operator[] (size_t __n) const { return _BStr[__n]; } + + _BString const& b_str() const { return _BStr; } + +private: + _BString const& _BStr; +}; + +struct __on_left {}; +struct __on_right {}; + +template +class __bstr_sum { +public: + typedef basic_string<_CharT, _Traits, _Alloc> _BString; + typedef typename _BString::const_reference const_reference; + typedef typename _BString::const_iterator const_iterator; + typedef typename _BString::const_reverse_iterator const_reverse_iterator; + typedef typename _BString::size_type size_type; + typedef typename _BString::allocator_type allocator_type; + typedef __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDirection> _Self; + + __bstr_sum (_Left const& lhs, _Right const& rhs) : + _lhs(lhs), _rhs(rhs) {} + + _Left const& getLhs() const { return _lhs; } + _Right const& getRhs() const { return _rhs; } + + allocator_type get_allocator() const { return _M_get_storage(false).get_allocator(); } + + const_iterator begin() const { return _M_get_storage().begin(); } + const_iterator end() const { return _M_get_storage().end(); } + const_reverse_iterator rbegin() const { return _M_get_storage().rbegin(); } + const_reverse_iterator rend() const { return _M_get_storage().rend(); } + + size_type size() const { return _lhs.size() + _rhs.size(); } + size_type length() const { return size(); } + + size_t max_size() const { return _M_get_storage().max_size(); } + size_type capacity() const { return size(); } + bool empty() const { return size() == 0; } + + const_reference operator[](size_t __n) const + { return (__n < _lhs.size())?_lhs[__n]:_rhs[__n - _lhs.size()]; } + + const_reference at(size_type __n) const + { return _M_get_storage().at(__n); } + + //operator += + typedef __bstr_sum<_CharT, _Traits, _Alloc, _Self, __bstr_wrapper<_CharT, _Traits, _Alloc>, __on_left> _BStrOnLeft; + _BStrOnLeft operator += (const _BString& __s) { return append(__s); } + + typedef __bstr_sum<_CharT, _Traits, _Alloc, _Self, __cstr_wrapper<_CharT>, __on_left> _CStrOnLeft; + _CStrOnLeft operator += (const _CharT* __s) { return append(__s); } + + typedef __bstr_sum<_CharT, _Traits, _Alloc, _Self, __char_wrapper<_CharT>, __on_left> _CharOnLeft; + _CharOnLeft operator += (_CharT __c) { return _CharOnLeft(*this, __c); } + + //append + _BStrOnLeft append (const _BString& __s) + { return _BStrOnLeft(*this, __s); } + _BString& append(const _BString& __s, size_type __pos, size_type __n) + { return _M_get_storage().append(__s, __pos, __n); } + _CStrOnLeft append(const _CharT* __s) { + const size_type __n = _Traits::length(__s); + return _CStrOnLeft(*this, __cstr_wrapper<_CharT>(__s, __n)); + } + _CStrOnLeft append(const _CharT* __s, size_type __n) + { return _CStrOnLeft(*this, __cstr_wrapper<_CharT>(__s, __n)); } + _BString& append(size_type __n, _CharT __c) + {return _M_get_storage().append(__n, __c);} + template + _BString& append(_InputIter __first, _InputIter __last) + {return _M_get_storage().append(__first, __last);} + + //assign + _BString& assign(const _BString& __s) {return _M_get_storage().assign(__s);} + _BString& assign(const _BString& __s, size_type __pos, size_type __n) {return _M_get_storage().assign(__s, __pos, __n);} + _BString& assign(const _CharT* __s, size_type __n) {return _M_get_storage().assign(__s, __n);} + _BString& assign(const _CharT* __s) {return _M_get_storage().assign(__s); } + _BString& assign(size_type __n, _CharT __c) {return _M_get_storage().assign(__n, __c);} + + //insert + _BString& insert(size_type __pos, const _BString& __s) {return _M_get_storage().insert(__pos, __s);} + _BString& insert(size_type __pos, const _BString& __s, size_type __beg, size_type __n) + {return _M_get_storage().insert(__pos, __s, __beg, __n);} + _BString& insert(size_type __pos, const _CharT* __s, size_type __n) {return _M_get_storage().insert(__pos, __s, __n);} + _BString& insert(size_type __pos, const _CharT* __s) {return _M_get_storage().insert(__pos, __s);} + _BString& insert(size_type __pos, size_type __n, _CharT __c) {return _M_get_storage().insert(__pos, __n, __c);} + + //erase + _BString& erase(size_type __pos = 0, size_type __n =_BString::npos) {return _M_get_storage().erase(__pos, __n);} + + //replace + _BString& replace(size_type __pos, size_type __n, const _BString& __s) + {return _M_get_storage().replace(__pos, __n, __s);} + _BString& replace(size_type __pos1, size_type __n1, const _BString& __s, size_type __pos2, size_type __n2) + {return _M_get_storage().replace(__pos1, __n1, __s, __pos2, __n2);} + _BString& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) + {return _M_get_storage().replace(__pos, __n1, __s, __n2);} + _BString& replace(size_type __pos, size_type __n1, const _CharT* __s) + {return _M_get_storage().replace(__pos, __n1, __s);} + _BString& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) + {return _M_get_storage().replace(__pos, __n1, __n2, __c);} + + size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const + {return _M_get_storage().copy(__s, __n, __pos);} + + void swap(_BString& __s) + {_M_get_storage().swap(__s);} + + const _CharT* c_str() const { return _M_get_storage().c_str(); } + const _CharT* data() const { return _M_get_storage().data(); } + + //find family + size_type find(const _BString& __s, size_type __pos = 0) const { return _M_get_storage().find(__s, __pos); } + size_type find(const _CharT* __s, size_type __pos = 0) const { return _M_get_storage().find(__s, __pos); } + size_type find(const _CharT* __s, size_type __pos, size_type __n) const { return _M_get_storage().find(__s, __pos, __n); } + size_type find(_CharT __c, size_type __pos = 0) const { return _M_get_storage().find(__c, __pos); } + + size_type rfind(const _BString& __s, size_type __pos = _BString::npos) const { return _M_get_storage().rfind(__s, __pos); } + size_type rfind(const _CharT* __s, size_type __pos = _BString::npos) const { return _M_get_storage().rfind(__s, __pos); } + size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const { return _M_get_storage().rfind(__s, __pos, __n); } + size_type rfind(_CharT __c, size_type __pos = _BString::npos) const { return _M_get_storage().rfind(__c, __pos); } + + size_type find_first_of(const _BString& __s, size_type __pos = 0) const + { return _M_get_storage().find_first_of(__s, __pos); } + size_type find_first_of(const _CharT* __s, size_type __pos = 0) const + { return _M_get_storage().find_first_of(__s, __pos); } + size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + { return _M_get_storage().find_first_of(__s, __pos, __n); } + size_type find_first_of(_CharT __c, size_type __pos = 0) const + { return _M_get_storage().find(__c, __pos); } + + size_type find_last_of(const _BString& __s, size_type __pos = _BString::npos) const + { return _M_get_storage().find_last_of(__s, __pos); } + size_type find_last_of(const _CharT* __s, size_type __pos = _BString::npos) const + { return _M_get_storage().find_last_of(__s, __pos); } + size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + { return _M_get_storage().find_last_of(__s, __pos, __n); } + size_type find_last_of(_CharT __c, size_type __pos = _BString::npos) const + { return _M_get_storage().rfind(__c, __pos); } + + size_type find_first_not_of(const _BString& __s, size_type __pos = 0) const + { return _M_get_storage().find_first_not_of(__s, __pos); } + size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const + { return _M_get_storage().find_first_not_of(__s, __pos); } + size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { return _M_get_storage().find_first_not_of(__s, __pos, __n); } + size_type find_first_not_of(_CharT __c, size_type __pos = 0) const + { return _M_get_storage().find_first_not_of(__c, __pos); } + + size_type find_last_not_of(const _BString& __s, size_type __pos = _BString::npos) const + { return _M_get_storage().find_last_not_of(__s, __pos); } + size_type find_last_not_of(const _CharT* __s, size_type __pos =_BString:: npos) const + { return _M_get_storage().find_last_not_of(__s, __pos); } + size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { return _M_get_storage().find_last_not_of(__s, __pos, __n); } + size_type find_last_not_of(_CharT __c, size_type __pos = _BString::npos) const + { return _M_get_storage().find_last_not_of(__c, __pos); } + + _BString substr(size_type __pos = 0, size_type __n = _BString::npos) const + { return _M_get_storage().substr(__pos, __n); } + + //compare + int compare(const _BString& __s) const + { return _M_get_storage().compare(__s); } + int compare(size_type __pos1, size_type __n1, const _Self& __s) const + { return _M_get_storage().compare(__pos1, __n1, __s); } + int compare(size_type __pos1, size_type __n1, const _Self& __s, size_type __pos2, size_type __n2) const + { return _M_get_storage().compare(__pos1, __n1, __s, __pos2, __n2); } + int compare(const _CharT* __s) const + { return _M_get_storage().compare(__s); } + int compare(size_type __pos1, size_type __n1, const _CharT* __s) const + { return _M_get_storage().compare(__pos1, __n1, __s); } + int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const + { return _M_get_storage().compare(__pos1, __n1, __s, __n2); } + + //Returns the underlying basic_string representation of the template expression + //The non const method will always initialise it. + _BString& _M_get_storage() + { return _rhs._M_get_storage(*this, _StorageDirection()); } + + template + _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir> const& __ref, + __on_left const& /*StorageDir*/) + { return _lhs._M_get_storage(__ref); } + + template + _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir> const& __ref, + __on_right const& /*StorageDir*/) + { return _rhs._M_get_storage(__ref); } + + template + _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir> const& __ref) + { return _M_get_storage(__ref, _StorageDirection()); } + + //The const method can be invoked without initialising the basic_string so avoiding dynamic allocation. + _BString const& _M_get_storage(bool __do_init = true) const + { return _M_get_storage(*this, __do_init, _StorageDirection()); } + + template + _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir> const& __ref, + bool __do_init, __on_left const& /*StorageDir*/) const + { return _lhs._M_get_storage(__ref, __do_init); } + + template + _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir> const& __ref, + bool __do_init, __on_right const& /*StorageDir*/) const + { return _rhs._M_get_storage(__ref, __do_init); } + + template + _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir> const& __ref, + bool __do_init) const + { return _M_get_storage(__ref, __do_init, _StorageDirection()); } + +private: + _Left _lhs; + _Right _rhs; +}; + +/* + * For this operator we choose to use the right part as the storage part + */ +template +inline __bstr_sum<_CharT, _Traits, _Alloc, + __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1>, + __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2>, + __on_right> _STLP_CALL +operator + (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs, + const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) { + return __bstr_sum<_CharT, _Traits, _Alloc, + __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1>, + __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2>, + __on_right>(__lhs, __rhs); +} + +template +inline bool _STLP_CALL +operator == (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs, + const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) +{ return (__lhs.size() == __rhs.size()) && (__lhs._M_get_storage() == __rhs._M_get_storage()); } + +template +inline bool _STLP_CALL +operator < (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs, + const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) +{ return __lhs._M_get_storage() < __rhs._M_get_storage(); } + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE + +template +inline bool _STLP_CALL +operator != (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs, + const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) +{ return !(__lhs == __rhs); } + +template +inline bool _STLP_CALL +operator > (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs, + const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) +{ return __rhs < __lhs; } + +template +inline bool _STLP_CALL +operator <= (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs, + const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) +{ return !(__rhs < __lhs); } + +template +inline bool _STLP_CALL +operator >= (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs, + const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) +{ return !(__lhs < __rhs); } + +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + + +/* + * This class will be used to simulate a temporary string that is required for + * a call to the c_str method on the __bstr_sum class. + */ + +template +struct __sum_storage_elem { + typedef __sum_storage_elem<_CharT, _Traits, _Alloc> _Self; + typedef basic_string<_CharT, _Traits, _Alloc> _BString; + + __sum_storage_elem(_Alloc __alloc) : _M_init(false), _M_storage(__alloc) + {} + + template + void _M_Init(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __ref) const { + if (!_M_init) { + _STLP_MUTABLE(_Self, _M_storage) = __ref; + _STLP_MUTABLE(_Self, _M_init) = true; + } + } + + template + _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __ref, + bool __do_init) const { + if (__do_init) { + _M_Init(__ref); + } + return _M_storage; + } + template + _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __ref) { + _M_Init(__ref); + return _M_storage; + } + + size_t size() const { return 0; } + _CharT const& operator[](size_t __n) const + { return __STATIC_CAST(_CharT*, 0)[__n]; } + +private: + mutable bool _M_init; + mutable basic_string<_CharT, _Traits, _Alloc> _M_storage; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /*_STLP_STRING_SUM_H*/ diff --git a/sdk/tlibstdcxx/stlport/stl/_string_sum_methods.h b/sdk/tlibstdcxx/stlport/stl/_string_sum_methods.h new file mode 100644 index 0000000000..305608e50e --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_sum_methods.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * All the necessary methods used for template expressions with basic_string + * This file do not have to be macro guarded as it is only used in the _string.h + * file and it is a part of the basic_string definition. + */ + +public: + template + basic_string(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s) + : _STLP_STRING_SUM_BASE(_Reserve_t(), __s.size(), __s.get_allocator()) + { _M_append_sum(__s); } + + template + basic_string(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + size_type __pos, size_type __n = npos, + const allocator_type& __a = allocator_type()) + : _STLP_STRING_SUM_BASE(_Reserve_t(), (__pos <= __s.size()) ? ((min) (__n, __s.size() - __pos)) : 0, __a) { + size_type __size = __s.size(); + if (__pos > __size) + this->_M_throw_out_of_range(); + else + _M_append_sum_pos(__s, __pos, (min) (__n, __size - __pos)); + } + +private: + _CharT* _M_append_fast(_STLP_PRIV __char_wrapper<_CharT> __c, _CharT *__buf) { + _STLP_STD::_Copy_Construct(__buf, __c.getValue()); + return __buf + 1; + } + _CharT* _M_append_fast(_CharT const* __s, size_type __s_size, _CharT *__buf) + { return uninitialized_copy(__s, __s + __s_size, __buf); } + _CharT* _M_append_fast(_STLP_PRIV __cstr_wrapper<_CharT> const& __s, _CharT *__buf) + { return _M_append_fast(__s.c_str(), __s.size(), __buf); } + _CharT* _M_append_fast(_STLP_PRIV __bstr_wrapper<_CharT, _Traits, _Alloc> __s, _CharT *__buf) + { return _M_append_fast(__s.b_str(), __buf); } + _CharT* _M_append_fast(_Self const& __s, _CharT *__buf) + { return _M_append_fast(__s.data(), __s.size(), __buf); } + _CharT* _M_append_fast(_STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc> const&, _CharT *__buf) + { return __buf; } + template + _CharT* _M_append_fast(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, _CharT *__buf) + { return _M_append_fast(__s.getRhs(), _M_append_fast(__s.getLhs(), __buf)); } + + _CharT* _M_append_fast_pos(_STLP_PRIV __char_wrapper<_CharT> __c, _CharT *__buf, size_type /*__pos*/, size_type __n) { + if (__n == 0) + return __buf; + _STLP_STD::_Copy_Construct(__buf, __c.getValue()); + return __buf + 1; + } + _CharT* _M_append_fast_pos(_CharT const* __s, size_type __s_size, _CharT *__buf, + size_type __pos, size_type __n) + { return uninitialized_copy(__s + __pos, __s + __pos + (min)(__n, __s_size - __pos), __buf); } + _CharT* _M_append_fast_pos(_STLP_PRIV __cstr_wrapper<_CharT> const& __s, _CharT *__buf, + size_type __pos, size_type __n) + { return _M_append_fast_pos(__s.c_str(), __s.size(), __buf, __pos, __n); } + _CharT* _M_append_fast_pos(_STLP_PRIV __bstr_wrapper<_CharT, _Traits, _Alloc> __s, _CharT *__buf, + size_type __pos, size_type __n) + { return _M_append_fast_pos(__s.b_str(), __buf, __pos, __n); } + _CharT* _M_append_fast_pos(_Self const& __s, _CharT *__buf, + size_type __pos, size_type __n) + { return _M_append_fast_pos(__s.data(), __s.size(), __buf, __pos, __n); } + _CharT* _M_append_fast_pos(_STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc> const&, _CharT *__buf, + size_type, size_type) + { return __buf; } + + template + _CharT* _M_append_fast_pos(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + _CharT *__buf, size_type __pos, size_type __n) { + if (__n == 0) { + return __buf; + } + size_type __lhs_size = __s.getLhs().size(); + if (__pos < __lhs_size) { + if (__n < (__lhs_size - __pos)) { + return _M_append_fast_pos(__s.getLhs(), __buf, __pos, __n); + } else { + return _M_append_fast_pos(__s.getRhs(), _M_append_fast_pos(__s.getLhs(), __buf, __pos, __n), + 0, __n - (__lhs_size - __pos)); + } + } else { + return _M_append_fast_pos(__s.getRhs(), __buf, __pos - __lhs_size, __n); + } + } + + template + _Self& _M_append_sum (_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s) { + size_type __s_size = __s.size(); + if (__s_size == 0) + return *this; + const size_type __old_size = this->size(); + if (__s_size > this->max_size() || __old_size > (this->max_size() - __s_size)) + this->_M_throw_length_error(); + if (__old_size + __s_size > this->capacity()) { + const size_type __len = __old_size + (max)(__old_size, __s_size) + 1; + pointer __new_start = this->_M_start_of_storage.allocate(__len); + pointer __new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start); + __new_finish = this->_M_append_fast(__s, __new_finish); + this->_M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + else { + _M_append_sum_no_overflow(__s, 0, __s_size); + } + return *this; + } + + template + _Self& _M_append_sum_pos(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + size_type __pos, size_type __n) { + size_type __s_size = (min)(__s.size() - __pos, __n); + if (__s_size == 0) + return *this; + const size_type __old_size = this->size(); + if (__s_size > this->max_size() || __old_size > (this->max_size() - __s_size)) + this->_M_throw_length_error(); + if (__old_size + __s_size > this->capacity()) { + const size_type __len = __old_size + (max)(__old_size, __s_size) + 1; + pointer __new_start = this->_M_start_of_storage.allocate(__len); + pointer __new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start); + __new_finish = _M_append_fast_pos(__s, __new_finish, __pos, __s_size); + this->_M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + else { + _M_append_sum_no_overflow(__s, __pos, __s_size); + } + return *this; + } + + template + void _M_append_sum_no_overflow(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + size_type __pos, size_type __n) { + pointer __finish = this->_M_Finish(); + _M_append_fast_pos(__s, __finish + 1, __pos + 1, __n - 1); + this->_M_construct_null(__finish + __n); + _Traits::assign(*this->_M_finish, __s[__pos]); + this->_M_finish += __n; + } diff --git a/sdk/tlibstdcxx/stlport/stl/_string_workaround.h b/sdk/tlibstdcxx/stlport/stl/_string_workaround.h new file mode 100644 index 0000000000..d77e320155 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_string_workaround.h @@ -0,0 +1,599 @@ +/* + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +//Included from _string.h, no need for macro guarding. + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_DEBUG) +# define basic_string _STLP_NON_DBG_NAME(str) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +#define _STLP_NO_MEM_T_STRING_BASE _STLP_PRIV _STLP_NO_MEM_T_NAME(str)<_CharT, _Traits, _Alloc> + +template +class basic_string : public _STLP_NO_MEM_T_STRING_BASE +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string) + , public __stlport_class > +#endif +{ +private: // Protected members inherited from base. + typedef basic_string<_CharT, _Traits, _Alloc> _Self; + typedef _STLP_NO_MEM_T_STRING_BASE _Base; + typedef typename _Base::_CalledFromWorkaround_t _CalledFromWorkaround_t; +public: + + __IMPORT_WITH_REVERSE_ITERATORS(_Base) + + typedef typename _Base::_Iterator_category _Iterator_category; + typedef typename _Base::traits_type traits_type; + typedef typename _Base::_Reserve_t _Reserve_t; + +#include + +public: // Constructor, destructor, assignment. + explicit basic_string(const allocator_type& __a = allocator_type()) + : _STLP_NO_MEM_T_STRING_BASE(__a) {} + + basic_string(_Reserve_t __r, size_t __n, + const allocator_type& __a = allocator_type()) + : _STLP_NO_MEM_T_STRING_BASE(__r, __n, __a) {} + + basic_string(const _Self& __s) + : _STLP_NO_MEM_T_STRING_BASE(__s) {} + + basic_string(const _Self& __s, size_type __pos, size_type __n = npos, + const allocator_type& __a = allocator_type()) + : _STLP_NO_MEM_T_STRING_BASE(__s, __pos, __n, __a) {} + + basic_string(const _CharT* __s, size_type __n, + const allocator_type& __a = allocator_type()) + : _STLP_NO_MEM_T_STRING_BASE(__s, __n, __a) {} + + basic_string(const _CharT* __s, + const allocator_type& __a = allocator_type()) + : _STLP_NO_MEM_T_STRING_BASE(__s, __a) {} + + basic_string(size_type __n, _CharT __c, + const allocator_type& __a = allocator_type()) + : _STLP_NO_MEM_T_STRING_BASE(__n, __c, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + basic_string(__move_source<_Self> src) + : _STLP_NO_MEM_T_STRING_BASE(__move_source<_Base>(src.get())) {} +#endif + + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. + template + basic_string(_InputIterator __f, _InputIterator __l, + const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_NO_MEM_T_STRING_BASE(_CalledFromWorkaround_t(), __a) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__f, __l, _Integral()); + } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + basic_string(_InputIterator __f, _InputIterator __l) + : _STLP_NO_MEM_T_STRING_BASE(_CalledFromWorkaround_t(), allocator_type()) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__f, __l, _Integral()); + } +# endif + + _Self& operator=(const _Self& __s) { + _Base::operator=(__s); + return *this; + } + + _Self& operator=(const _CharT* __s) { + _Base::operator=(__s); + return *this; + } + + _Self& operator=(_CharT __c) { + _Base::operator=(__c); + return *this; + } + +private: + template + void _M_range_initialize(_InputIter __f, _InputIter __l, + const input_iterator_tag &__tag) { + this->_M_allocate_block(); + this->_M_construct_null(this->_M_Finish()); + _M_appendT(__f, __l, __tag); + } + + template + void _M_range_initialize(_ForwardIter __f, _ForwardIter __l, + const forward_iterator_tag &) { + difference_type __n = _STLP_STD::distance(__f, __l); + this->_M_allocate_block(__n + 1); + this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start()); + this->_M_terminate_string(); + } + + template + void _M_range_initializeT(_InputIter __f, _InputIter __l) { + _M_range_initialize(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); + } + + template + void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) { + this->_M_allocate_block(__n + 1); + this->_M_finish = uninitialized_fill_n(this->_M_Start(), __n, __x); + this->_M_terminate_string(); + } + + template + void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) { + _M_range_initializeT(__f, __l); + } + +public: // Append, operator+=, push_back. + _Self& operator+=(const _Self& __s) { + _Base::operator+=(__s); + return *this; + } + _Self& operator+=(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::operator+=(__s); + return *this; + } + _Self& operator+=(_CharT __c) { + _Base::operator+=(__c); + return *this; + } + + _Self& append(const _Self& __s) { + _Base::append(__s); + return *this; + } + + _Self& append(const _Self& __s, + size_type __pos, size_type __n) { + _Base::append(__s, __pos, __n); + return *this; + } + + _Self& append(const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::append(__s, __n); + return *this; + } + _Self& append(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::append(__s); + return *this; + } + _Self& append(size_type __n, _CharT __c) { + _Base::append(__n, __c); + return *this; + } + + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. + template + _Self& append(_InputIter __first, _InputIter __last) { + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + return _M_append_dispatch(__first, __last, _Integral()); + } + +#if !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS) + //See equivalent assign method remark. + _Self& append(const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l) + _Base::append(__f, __l); + return *this; + } +#endif + +private: // Helper functions for append. + + template + _Self& _M_appendT(_InputIter __first, _InputIter __last, + const input_iterator_tag &) { + for ( ; __first != __last ; ++__first) + _Base::push_back(*__first); + return *this; + } + + template + _Self& _M_appendT(_ForwardIter __first, _ForwardIter __last, + const forward_iterator_tag &) { + if (__first != __last) { + const size_type __n = __STATIC_CAST(size_type, _STLP_STD::distance(__first, __last)); + if (__n >= this->_M_rest()) { + size_type __len = this->_M_compute_next_size(__n); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + pointer __new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start); + __new_finish = uninitialized_copy(__first, __last, __new_finish); + this->_M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + else { + _Traits::assign(*this->_M_finish, *__first++); + uninitialized_copy(__first, __last, this->_M_Finish() + 1); + this->_M_construct_null(this->_M_Finish() + __n); + this->_M_finish += __n; + } + } + return *this; + } + + template + _Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type& /*Integral*/) + { return append((size_type) __n, (_CharT) __x); } + + template + _Self& _M_append_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*Integral*/) + { return _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); } + +public: // Assign + _Self& assign(const _Self& __s) { + _Base::assign(__s); + return *this; + } + + _Self& assign(const _Self& __s, + size_type __pos, size_type __n) { + _Base::assign(__s, __pos, __n); + return *this; + } + + _Self& assign(const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::assign(__s, __n); + return *this; + } + + _Self& assign(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::assign(__s); + return *this; + } + + _Self& assign(size_type __n, _CharT __c) { + _Base::assign(__n, __c); + return *this; + } + +private: // Helper functions for assign. + + template + _Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) + { return assign((size_type) __n, (_CharT) __x); } + + template + _Self& _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) { + pointer __cur = this->_M_Start(); + while (__f != __l && __cur != this->_M_Finish()) { + _Traits::assign(*__cur, *__f); + ++__f; + ++__cur; + } + if (__f == __l) + _Base::erase(__cur, this->_M_Finish()); + else + _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); + return *this; + } + +public: + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. + template + _Self& assign(_InputIter __first, _InputIter __last) { + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + return _M_assign_dispatch(__first, __last, _Integral()); + } + +#if !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS) + /* This method is not part of the standard and is a specialization of the + * template method assign. It is only granted for convenience to call assign + * with mixed parameters iterator and const_iterator. + */ + _Self& assign(const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l) + _Base::assign(__f, __l); + return *this; + } +#endif + +public: // Insert + _Self& insert(size_type __pos, const _Self& __s) { + _Base::insert(__pos, __s); + return *this; + } + + _Self& insert(size_type __pos, const _Self& __s, + size_type __beg, size_type __n) { + _Base::insert(__pos, __s, __beg, __n); + return *this; + } + _Self& insert(size_type __pos, const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::insert(__pos, __s, __n); + return *this; + } + + _Self& insert(size_type __pos, const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::insert(__pos, __s); + return *this; + } + + _Self& insert(size_type __pos, size_type __n, _CharT __c) { + _Base::insert(__pos, __n, __c); + return *this; + } + + iterator insert(iterator __p, _CharT __c) + { return _Base::insert(__p, __c); } + + void insert(iterator __p, size_t __n, _CharT __c) + { _Base::insert(__p, __n, __c); } + + // Check to see if _InputIterator is an integer type. If so, then + // it can't be an iterator. + template + void insert(iterator __p, _InputIter __first, _InputIter __last) { + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + _M_insert_dispatch(__p, __first, __last, _Integral()); + } + +#if !defined (_STLP_NO_METHOD_SPECIALIZATION) +public: + void insert(iterator __p, const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _M_insert(__p, __f, __l, this->_M_inside(__f)); + } +#endif + +private: // Helper functions for insert. + void _M_insert(iterator __p, const _CharT* __f, const _CharT* __l, bool __self_ref) { + _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l) + _Base::_M_insert(__p, __f, __l, __self_ref); + } + + template + void _M_insert_overflow(iterator __pos, _ForwardIter __first, _ForwardIter __last, + size_type __n) { + size_type __len = this->_M_compute_next_size(__n); + pointer __new_start = this->_M_start_of_storage.allocate(__len, __len); + pointer __new_finish = uninitialized_copy(this->_M_Start(), __pos, __new_start); + __new_finish = uninitialized_copy(__first, __last, __new_finish); + __new_finish = uninitialized_copy(__pos, this->_M_Finish(), __new_finish); + this->_M_construct_null(__new_finish); + this->_M_deallocate_block(); + this->_M_reset(__new_start, __new_finish, __new_start + __len); + } + + template + void _M_insertT(iterator __p, _InputIter __first, _InputIter __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) { + __p = insert(__p, *__first); + ++__p; + } + } + + template + void _M_insertT(iterator __pos, _ForwardIter __first, _ForwardIter __last, + const forward_iterator_tag &) { + if (__first != __last) { + size_type __n = __STATIC_CAST(size_type, _STLP_STD::distance(__first, __last)); + if (__n < this->_M_rest()) { + const size_type __elems_after = this->_M_finish - __pos; + if (__elems_after >= __n) { + uninitialized_copy((this->_M_Finish() - __n) + 1, this->_M_Finish() + 1, this->_M_Finish() + 1); + this->_M_finish += __n; + _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1); + _M_copyT(__first, __last, __pos); + } + else { + pointer __old_finish = this->_M_Finish(); + _ForwardIter __mid = __first; + _STLP_STD::advance(__mid, __elems_after + 1); + _STLP_STD::uninitialized_copy(__mid, __last, this->_M_Finish() + 1); + this->_M_finish += __n - __elems_after; + uninitialized_copy(__pos, __old_finish + 1, this->_M_Finish()); + this->_M_finish += __elems_after; + _M_copyT(__first, __mid, __pos); + } + } + else { + _M_insert_overflow(__pos, __first, __last, __n); + } + } + } + + template + void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x, + const __true_type& /*Integral*/) + { insert(__p, (size_type) __n, (_CharT) __x); } + + template + void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last, + const __false_type& /*Integral*/) { + _STLP_FIX_LITERAL_BUG(__p) + /* We are forced to do a temporary string to avoid the self referencing issue. */ + const _Self __self(__first, __last, this->get_allocator()); + _M_insertT(__p, __self.begin(), __self.end(), _STLP_ITERATOR_CATEGORY(__first, _InputIter)); + } + + template + void _M_copyT(_InputIterator __first, _InputIterator __last, pointer __result) { + _STLP_FIX_LITERAL_BUG(__p) + for ( ; __first != __last; ++__first, ++__result) + _Traits::assign(*__result, *__first); + } + +#if !defined (_STLP_NO_METHOD_SPECIALIZATION) + void _M_copyT(const _CharT* __f, const _CharT* __l, _CharT* __res) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) _STLP_FIX_LITERAL_BUG(__res) + _Base::_M_copy(__f, __l, __res); + } +#endif + +public: // Erase. + _Self& erase(size_type __pos = 0, size_type __n = npos) { + _Base::erase(__pos, __n); + return *this; + } + + iterator erase(iterator __pos) { + _STLP_FIX_LITERAL_BUG(__pos) + return _Base::erase(__pos); + } + + iterator erase(iterator __first, iterator __last) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + return _Base::erase(__first, __last); + } + +public: // Replace. (Conceptually equivalent + // to erase followed by insert.) + _Self& replace(size_type __pos, size_type __n, const _Self& __s) { + _Base::replace(__pos, __n, __s); + return *this; + } + + _Self& replace(size_type __pos1, size_type __n1, const _Self& __s, + size_type __pos2, size_type __n2) { + _Base::replace(__pos1, __n1, __s, __pos2, __n2); + return *this; + } + + _Self& replace(size_type __pos, size_type __n1, + const _CharT* __s, size_type __n2) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::replace(__pos, __n1, __s, __n2); + return *this; + } + + _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _Base::replace(__pos, __n1, __s); + return *this; + } + + _Self& replace(size_type __pos, size_type __n1, + size_type __n2, _CharT __c) { + _Base::replace(__pos, __n1, __n2, __c); + return *this; + } + + _Self& replace(iterator __first, iterator __last, const _Self& __s) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + _Base::replace(__first, __last, __s); + return *this; + } + + _Self& replace(iterator __first, iterator __last, + const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + _STLP_FIX_LITERAL_BUG(__s) + _Base::replace(__first, __last, __s, __n); + return *this; + } + + _Self& replace(iterator __first, iterator __last, + const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + _STLP_FIX_LITERAL_BUG(__s) + _Base::replace(__first, __last, __s); + return *this; + } + + _Self& replace(iterator __first, iterator __last, + size_type __n, _CharT __c) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + _Base::replace(__first, __last, __n, __c); + return *this; + } + + // Check to see if _InputIter is an integer type. If so, then + // it can't be an iterator. + template + _Self& replace(iterator __first, iterator __last, + _InputIter __f, _InputIter __l) { + _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last) + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + return _M_replace_dispatch(__first, __last, __f, __l, _Integral()); + } + +#if !defined (_STLP_NO_METHOD_SPECIALIZATION) + _Self& replace(iterator __first, iterator __last, + const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + return _M_replace(__first, __last, __f, __l, this->_M_inside(__f)); + } +#endif + +private: // Helper functions for replace. + _Self& _M_replace(iterator __first, iterator __last, + const _CharT* __f, const _CharT* __l, bool __self_ref) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _Base::_M_replace(__first, __last, __f, __l, __self_ref); + return *this; + } + + template + _Self& _M_replace_dispatch(iterator __first, iterator __last, + _Integer __n, _Integer __x, const __true_type& /*IsIntegral*/) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + return replace(__first, __last, (size_type) __n, (_CharT) __x); + } + + template + _Self& _M_replace_dispatch(iterator __first, iterator __last, + _InputIter __f, _InputIter __l, const __false_type& /*IsIntegral*/) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + /* We are forced to do a temporary string to avoid the self referencing issue. */ + const _Self __self(__f, __l, this->get_allocator()); + return _M_replace(__first, __last, __self._M_Start(), __self._M_Finish(), false); + } + +public: // Other modifier member functions. + void swap(_Self& __s) { _Base::swap(__s); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +public: // Substring. + _Self substr(size_type __pos = 0, size_type __n = npos) const + { return _Self(*this, __pos, __n, this->get_allocator()); } + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) && !defined (_STLP_DEBUG) +# define _STLP_STRING_SUM_BASE _STLP_NO_MEM_T_STRING_BASE +# include +# undef _STLP_STRING_SUM_BASE +#endif +}; + +#undef _STLP_NO_MEM_T_STRING_BASE + +#if defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +# undef basic_string +#endif + +_STLP_END_NAMESPACE diff --git a/sdk/tlibstdcxx/stlport/stl/_strstream.h b/sdk/tlibstdcxx/stlport/stl/_strstream.h new file mode 100644 index 0000000000..5e3d4c37dc --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_strstream.h @@ -0,0 +1,165 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_INTERNAL_STRSTREAM +#define _STLP_INTERNAL_STRSTREAM + +#ifndef _STLP_INTERNAL_STREAMBUF +# include +#endif + +#ifndef _STLP_INTERNAL_ISTREAM +# include // Includes , , +#endif + +#ifndef _STLP_INTERNAL_STRING_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#ifndef _STLP_USE_NAMESPACES +# define strstream _STLP_strstream +# define ostrstream _STLP_ostrstream +# define istrstream _STLP_istrstream +# define strstreambuf _STLP_strstreambuf +#endif + +//---------------------------------------------------------------------- +// Class strstreambuf, a streambuf class that manages an array of char. +// Note that this class is not a template. + +class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf > { +public: // Types. + typedef char_traits _Traits; + typedef basic_streambuf > _Base; + typedef void* (*__alloc_fn)(size_t); + typedef void (*__free_fn)(void*); +public: // Constructor, destructor + + explicit strstreambuf(streamsize _Initial_capacity = 0); + + strstreambuf(__alloc_fn, __free_fn); + + strstreambuf(char* __get, streamsize __n, char* __put = 0); + strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0); + strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0); + + strstreambuf(const char* __get, streamsize __n); + strstreambuf(const signed char* __get, streamsize __n); + strstreambuf(const unsigned char* __get, streamsize __n); + + virtual ~strstreambuf(); + +public: // strstreambuf operations. + void freeze(bool = true); + char* str(); + int pcount() const; + +protected: // Overridden virtual member functions. + virtual int_type overflow(int_type __c = _Traits::eof()); + virtual int_type pbackfail(int_type __c = _Traits::eof()); + virtual int_type underflow(); + virtual _Base* setbuf(char* __buf, streamsize __n); + virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, + ios_base::openmode __mode + = ios_base::in | ios_base::out); + virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode + = ios_base::in | ios_base::out); + +private: // Helper functions. + // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. + char* _M_alloc(size_t); + void _M_free(char*); + + // Helper function used in constructors. + void _M_setup(char* __get, char* __put, streamsize __n); +private: // Data members. + __alloc_fn _M_alloc_fun; + __free_fn _M_free_fun; + bool _M_dynamic : 1; + bool _M_frozen : 1; + bool _M_constant : 1; +}; + +//---------------------------------------------------------------------- +// Class istrstream, an istream that manages a strstreambuf. + +class _STLP_CLASS_DECLSPEC istrstream : public basic_istream > { +public: + explicit istrstream(char*); + explicit istrstream(const char*); + istrstream(char* , streamsize); + istrstream(const char*, streamsize); + virtual ~istrstream(); + + strstreambuf* rdbuf() const; + char* str(); + +private: + strstreambuf _M_buf; +}; + +//---------------------------------------------------------------------- +// Class ostrstream + +class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream > +{ +public: + ostrstream(); + ostrstream(char*, int, ios_base::openmode = ios_base::out); + virtual ~ostrstream(); + + strstreambuf* rdbuf() const; + void freeze(bool = true); + char* str(); + int pcount() const; + +private: + strstreambuf _M_buf; +}; + +//---------------------------------------------------------------------- +// Class strstream + +class _STLP_CLASS_DECLSPEC strstream : public basic_iostream > { +public: + typedef char char_type; + typedef char_traits::int_type int_type; + typedef char_traits::pos_type pos_type; + typedef char_traits::off_type off_type; + + strstream(); + strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); + virtual ~strstream(); + + strstreambuf* rdbuf() const; + void freeze(bool = true); + int pcount() const; + char* str(); + +private: + strstreambuf _M_buf; + + //explicitely defined as private to avoid warnings: + strstream(strstream const&); + strstream& operator = (strstream const&); +}; + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_STRSTREAM */ diff --git a/sdk/tlibstdcxx/stlport/stl/_tempbuf.c b/sdk/tlibstdcxx/stlport/stl/_tempbuf.c new file mode 100644 index 0000000000..179b4725cb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_tempbuf.c @@ -0,0 +1,57 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_TEMPBUF_C +#define _STLP_TEMPBUF_C + +#ifndef _STLP_INTERNAL_TEMPBUF_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +pair<_Tp*, ptrdiff_t> _STLP_CALL +__get_temporary_buffer(ptrdiff_t __len, _Tp*) +{ + if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) + __len = INT_MAX / sizeof(_Tp); + + while (__len > 0) { + _Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp)); + if (__tmp != 0) + return pair<_Tp*, ptrdiff_t>(__tmp, __len); + __len /= 2; + } + + return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); +} +_STLP_END_NAMESPACE + +#endif /* _STLP_TEMPBUF_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_tempbuf.h b/sdk/tlibstdcxx/stlport/stl/_tempbuf.h new file mode 100644 index 0000000000..0e0a747858 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_tempbuf.h @@ -0,0 +1,167 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_TEMPBUF_H +#define _STLP_INTERNAL_TEMPBUF_H + +#ifndef _STLP_CLIMITS +# include +#endif + +#ifndef _STLP_INTERNAL_CSTDLIB +# include +#endif + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +pair<_Tp*, ptrdiff_t> _STLP_CALL +__get_temporary_buffer(ptrdiff_t __len, _Tp*); + +#ifndef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS + +template +inline pair<_Tp*, ptrdiff_t> _STLP_CALL get_temporary_buffer(ptrdiff_t __len) { + return __get_temporary_buffer(__len, (_Tp*) 0); +} + +# if ! defined(_STLP_NO_EXTENSIONS) +// This overload is not required by the standard; it is an extension. +// It is supported for backward compatibility with the HP STL, and +// because not all compilers support the language feature (explicit +// function template arguments) that is required for the standard +// version of get_temporary_buffer. +template +inline pair<_Tp*, ptrdiff_t> _STLP_CALL +get_temporary_buffer(ptrdiff_t __len, _Tp*) { + return __get_temporary_buffer(__len, (_Tp*) 0); +} +# endif +#endif + +template +inline void _STLP_CALL return_temporary_buffer(_Tp* __p) { +// SunPro brain damage + free((char*)__p); +} + +template +class _Temporary_buffer { +private: + ptrdiff_t _M_original_len; + ptrdiff_t _M_len; + _Tp* _M_buffer; + + void _M_allocate_buffer() { + _M_original_len = _M_len; + _M_buffer = 0; + + if (_M_len > (ptrdiff_t)(INT_MAX / sizeof(_Tp))) + _M_len = INT_MAX / sizeof(_Tp); + + while (_M_len > 0) { + _M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp)); + if (_M_buffer) + break; + _M_len /= 2; + } + } + + void _M_initialize_buffer(const _Tp&, const __true_type&) {} + void _M_initialize_buffer(const _Tp& val, const __false_type&) { + uninitialized_fill_n(_M_buffer, _M_len, val); + } + +public: + ptrdiff_t size() const { return _M_len; } + ptrdiff_t requested_size() const { return _M_original_len; } + _Tp* begin() { return _M_buffer; } + _Tp* end() { return _M_buffer + _M_len; } + + _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) { + // Workaround for a __type_traits bug in the pre-7.3 compiler. +# if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION < 730 + typedef typename __type_traits<_Tp>::is_POD_type _Trivial; +# else + typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Trivial; +# endif + _STLP_TRY { + _M_len = _STLP_STD::distance(__first, __last); + _M_allocate_buffer(); + if (_M_len > 0) + _M_initialize_buffer(*__first, _Trivial()); + } + _STLP_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0) + } + + ~_Temporary_buffer() { + _STLP_STD::_Destroy_Range(_M_buffer, _M_buffer + _M_len); + free(_M_buffer); + } + +private: + // Disable copy constructor and assignment operator. + _Temporary_buffer(const _Temporary_buffer<_ForwardIterator, _Tp>&) {} + void operator=(const _Temporary_buffer<_ForwardIterator, _Tp>&) {} +}; + +# ifndef _STLP_NO_EXTENSIONS + +// Class temporary_buffer is not part of the standard. It is an extension. + +template ::value_type +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + > +struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> +{ + temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) + : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) {} + ~temporary_buffer() {} +}; + +# endif /* _STLP_NO_EXTENSIONS */ + +_STLP_END_NAMESPACE + +# ifndef _STLP_LINK_TIME_INSTANTIATION +# include +# endif + +#endif /* _STLP_INTERNAL_TEMPBUF_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_threads.c b/sdk/tlibstdcxx/stlport/stl/_threads.c new file mode 100644 index 0000000000..ea3c0b9c61 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_threads.c @@ -0,0 +1,167 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_THREADS_C +#define _STLP_THREADS_C + +#ifndef _STLP_INTERNAL_THREADS_H +# include +#endif + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) + +#if defined (_STLP_SGI_THREADS) +# include +#elif defined (_STLP_UNIX) +# ifndef _STLP_INTERNAL_CTIME +# include +# endif +# if defined (_STLP_USE_NAMESPACES) && !defined (_STLP_VENDOR_GLOBAL_CSTD) +using _STLP_VENDOR_CSTD::time_t; +# endif +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_ATOMIC_SWAP_MUTEX) +template +_STLP_STATIC_MUTEX +_Atomic_swap_struct<__32bits>::_S_swap_lock _STLP_MUTEX_INITIALIZER; +# undef _STLP_USE_ATOMIC_SWAP_MUTEX +#endif + +#if defined (_STLP_THREADS) && !defined (_STLP_USE_PTHREAD_SPINLOCK) +template +unsigned _STLP_mutex_spin<__inst>::__max = _STLP_mutex_spin<__inst>::__low_max; + +template +unsigned _STLP_mutex_spin<__inst>::__last = 0; +#endif // _STLP_USE_PTHREAD_SPINLOCK + +#if defined (_STLP_THREADS) && !defined (_STLP_USE_PTHREAD_SPINLOCK) + +# if defined (_STLP_SPARC_SOLARIS_THREADS) +// underground function in libc.so; we do not want dependance on librt +extern "C" int __nanosleep(const struct timespec*, struct timespec*); +# define _STLP_NANOSLEEP __nanosleep +# else +# define _STLP_NANOSLEEP nanosleep +# endif + +template +void _STLP_CALL +_STLP_mutex_spin<__inst>::_S_nsec_sleep(int __log_nsec, unsigned int& __iteration) { +# if defined (_STLP_WIN32THREADS) +# if defined (_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) + if (__iteration <= 4000) { + // Use SwitchToThread because + // 1) Sleep(1) often takes ~15 ms + // 2) SwitchToThread yields to lower-priority threads + // 4000 is enough to avoid Sleep and is used just to prevent infinite looping + // This number is advised spin count for Heap management by Microsoft + SwitchToThread(); + } else { +# endif + if (__log_nsec <= 21) { + /* Note from boost (www.boost.org): + * Changed from Sleep(0) to Sleep(1). + * According to MSDN, Sleep(0) will never yield to a lower-priority thread, + * whereas Sleep(1) will. Performance seems not to be affected. */ + Sleep(1); + } else { + Sleep(1 << (__log_nsec - 20)); + } +# if defined (_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) + __iteration = 0; //reset to avoid sleeps sequence + } +# endif +# elif defined(_STLP_OS2THREADS) + if (__log_nsec <= 20) { + DosSleep(0); + } else { + DosSleep(1 << (__log_nsec - 20)); + } +# elif defined (_STLP_UNIX) + timespec __ts; + /* Max sleep is 2**27nsec ~ 60msec */ + __ts.tv_sec = 0; + __ts.tv_nsec = 1 << __log_nsec; + _STLP_NANOSLEEP(&__ts, 0); +# endif +} + +template +void _STLP_CALL +_STLP_mutex_spin<__inst>::_M_do_lock(volatile __stl_atomic_t* __lock) { +# if defined(_STLP_ATOMIC_EXCHANGE) + if (_Atomic_swap(__lock, 1)) { + unsigned __my_spin_max = _STLP_mutex_spin<0>::__max; + unsigned __my_last_spins = _STLP_mutex_spin<0>::__last; + volatile unsigned __junk = 17; // Value doesn't matter. + unsigned __i; + + for (__i = 0; __i < __my_spin_max; ++__i) { + if (__i < __my_last_spins/2 || *__lock) { + __junk *= __junk; __junk *= __junk; + __junk *= __junk; __junk *= __junk; + } else { + if (!_Atomic_swap(__lock, 1)) { + // got it! + // Spinning worked. Thus we're probably not being scheduled + // against the other process with which we were contending. + // Thus it makes sense to spin longer the next time. + _STLP_mutex_spin<0>::__last = __i; + _STLP_mutex_spin<0>::__max = _STLP_mutex_spin<0>::__high_max; + return; + } + } + } + + // We are probably being scheduled against the other process. Sleep. + _STLP_mutex_spin<0>::__max = _STLP_mutex_spin<0>::__low_max; + + for (__i = 0 ;; ++__i) { + int __log_nsec = __i + 6; + + if (__log_nsec > 27) __log_nsec = 27; + if (!_Atomic_swap(__lock, 1)) { + break; + } + _S_nsec_sleep(__log_nsec, __i); + } + } /* first _Atomic_swap */ +# endif +} +#endif // _STLP_USE_PTHREAD_SPINLOCK + +_STLP_END_NAMESPACE + +#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */ +#endif /* _STLP_THREADS_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_threads.h b/sdk/tlibstdcxx/stlport/stl/_threads.h new file mode 100644 index 0000000000..8bf3c6ccae --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_threads.h @@ -0,0 +1,687 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_THREADS_H +#define _STLP_INTERNAL_THREADS_H + +// Supported threading models are native SGI, pthreads, uithreads +// (similar to pthreads, but based on an earlier draft of the Posix +// threads standard), and Win32 threads. Uithread support by Jochen +// Schlick, 1999, and Solaris threads generalized to them. + +#ifndef _STLP_INTERNAL_CSTDDEF +# include +#endif + +#ifndef _STLP_INTERNAL_CSTDLIB +# include +#endif + +// On SUN and Mac OS X gcc, zero-initialization works just fine... +#if defined (__sun) || (defined (__GNUC__) && defined(__APPLE__)) +# define _STLP_MUTEX_INITIALIZER +#endif + +/* This header defines the following atomic operation that platform should + * try to support as much as possible. Atomic operation are exposed as macro + * in order to easily test for their existance. They are: + * __stl_atomic_t _STLP_ATOMIC_INCREMENT(volatile __stl_atomic_t* __ptr) : + * increment *__ptr by 1 and returns the new value + * __stl_atomic_t _STLP_ATOMIC_DECREMENT(volatile __stl_atomic_t* __ptr) : + * decrement *__ptr by 1 and returns the new value + * __stl_atomic_t _STLP_ATOMIC_EXCHANGE(volatile __stl_atomic_t* __target, __stl_atomic_t __val) : + * assign __val to *__target and returns former *__target value + * void* _STLP_ATOMIC_EXCHANGE_PTR(void* volatile* __target, void* __ptr) : + * assign __ptr to *__target and returns former *__target value + */ + +#if defined (_STLP_THREADS) + +# if defined (_STLP_SGI_THREADS) + +# include +// Hack for SGI o32 compilers. +# if !defined(__add_and_fetch) && \ + (__mips < 3 || !(defined (_ABIN32) || defined(_ABI64))) +# define __add_and_fetch(__l,__v) add_then_test((unsigned long*)__l,__v) +# define __test_and_set(__l,__v) test_and_set(__l,__v) +# endif /* o32 */ + +# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) +# define _STLP_ATOMIC_EXCHANGE(__p, __q) test_and_set(__p, __q) +# else +# define _STLP_ATOMIC_EXCHANGE(__p, __q) __test_and_set((unsigned long*)__p, (unsigned long)__q) +# endif + +# define _STLP_ATOMIC_INCREMENT(__x) __add_and_fetch(__x, 1) +# define _STLP_ATOMIC_DECREMENT(__x) __add_and_fetch(__x, (size_t) -1) +typedef long __stl_atomic_t; + +# elif defined (_STLP_PTHREADS) + +# include +# if !defined (_STLP_USE_PTHREAD_SPINLOCK) +# if defined (PTHREAD_MUTEX_INITIALIZER) && !defined (_STLP_MUTEX_INITIALIZER) && defined (_REENTRANT) +# define _STLP_MUTEX_INITIALIZER = { PTHREAD_MUTEX_INITIALIZER } +# endif +//HPUX variants have (on some platforms optional) non-standard "DCE" pthreads impl +# if defined (_DECTHREADS_) && (defined (_PTHREAD_USE_D4) || defined (__hpux)) && !defined (_CMA_SUPPRESS_EXTERNALS_) +# define _STLP_PTHREAD_ATTR_DEFAULT pthread_mutexattr_default +# else +# define _STLP_PTHREAD_ATTR_DEFAULT 0 +# endif +# else +# if defined (__OpenBSD__) +# include +# endif +# endif + +# if defined (__GNUC__) && defined (__i386__) +# if !defined (_STLP_ATOMIC_INCREMENT) +inline long _STLP_atomic_increment_gcc_x86(long volatile* p) { + long result; + __asm__ __volatile__ + ("lock; xaddl %1, %0;" + :"=m" (*p), "=r" (result) + :"m" (*p), "1" (1) + :"cc"); + return result + 1; +} +# define _STLP_ATOMIC_INCREMENT(__x) (_STLP_atomic_increment_gcc_x86((long volatile*)__x)) +# endif + +# if !defined (_STLP_ATOMIC_DECREMENT) +inline long _STLP_atomic_decrement_gcc_x86(long volatile* p) { + long result; + __asm__ __volatile__ + ("lock; xaddl %1, %0;" + :"=m" (*p), "=r" (result) + :"m" (*p), "1" (-1) + :"cc"); + return result - 1; +} +# define _STLP_ATOMIC_DECREMENT(__x) (_STLP_atomic_decrement_gcc_x86((long volatile*)__x)) +# endif +typedef long __stl_atomic_t; +# else +typedef size_t __stl_atomic_t; +# endif /* if defined(__GNUC__) && defined(__i386__) */ + +# elif defined (_STLP_WIN32THREADS) + +# if !defined (_STLP_ATOMIC_INCREMENT) +# if !defined (_STLP_NEW_PLATFORM_SDK) +# define _STLP_ATOMIC_INCREMENT(__x) InterlockedIncrement(__CONST_CAST(long*, __x)) +# define _STLP_ATOMIC_DECREMENT(__x) InterlockedDecrement(__CONST_CAST(long*, __x)) +# define _STLP_ATOMIC_EXCHANGE(__x, __y) InterlockedExchange(__CONST_CAST(long*, __x), __y) +# else +# define _STLP_ATOMIC_INCREMENT(__x) InterlockedIncrement(__x) +# define _STLP_ATOMIC_DECREMENT(__x) InterlockedDecrement(__x) +# define _STLP_ATOMIC_EXCHANGE(__x, __y) InterlockedExchange(__x, __y) +# endif +# define _STLP_ATOMIC_EXCHANGE_PTR(__x, __y) STLPInterlockedExchangePointer(__x, __y) +# endif +typedef long __stl_atomic_t; + +# elif defined (__DECC) || defined (__DECCXX) + +# include +# define _STLP_ATOMIC_EXCHANGE __ATOMIC_EXCH_LONG +# define _STLP_ATOMIC_INCREMENT(__x) __ATOMIC_ADD_LONG(__x, 1) +# define _STLP_ATOMIC_DECREMENT(__x) __ATOMIC_ADD_LONG(__x, -1) +typedef long __stl_atomic_t; + +# elif defined (_STLP_SPARC_SOLARIS_THREADS) + +typedef long __stl_atomic_t; +# include + +# elif defined (_STLP_UITHREADS) + +// this inclusion is potential hazard to bring up all sorts +// of old-style headers. Let's assume vendor already know how +// to deal with that. +# ifndef _STLP_INTERNAL_CTIME +# include +# endif +# if defined (_STLP_USE_NAMESPACES) && ! defined (_STLP_VENDOR_GLOBAL_CSTD) +using _STLP_VENDOR_CSTD::time_t; +# endif +# include +# ifndef _STLP_INTERNAL_CSTDIO +# include +# endif +# ifndef _STLP_INTERNAL_CWCHAR +# include +# endif +typedef size_t __stl_atomic_t; + +# elif defined (_STLP_BETHREADS) + +# include +# include +# include +# define _STLP_MUTEX_INITIALIZER = { 0 } +typedef size_t __stl_atomic_t; + +# elif defined (_STLP_NWTHREADS) + +# include +# include +typedef size_t __stl_atomic_t; + +# elif defined(_STLP_OS2THREADS) + +# if defined (__GNUC__) +# define INCL_DOSSEMAPHORES +# include +# else +// This section serves to replace os2.h for VisualAge C++ + typedef unsigned long ULONG; +# if !defined (__HEV__) /* INCL_SEMAPHORE may also define HEV */ +# define __HEV__ + typedef ULONG HEV; + typedef HEV* PHEV; +# endif + typedef ULONG APIRET; + typedef ULONG HMTX; + typedef HMTX* PHMTX; + typedef const char* PCSZ; + typedef ULONG BOOL32; + APIRET _System DosCreateMutexSem(PCSZ pszName, PHEV phev, ULONG flAttr, BOOL32 fState); + APIRET _System DosRequestMutexSem(HMTX hmtx, ULONG ulTimeout); + APIRET _System DosReleaseMutexSem(HMTX hmtx); + APIRET _System DosCloseMutexSem(HMTX hmtx); +# define _STLP_MUTEX_INITIALIZER = { 0 } +# endif /* GNUC */ +typedef size_t __stl_atomic_t; + +# else + +typedef size_t __stl_atomic_t; + +# endif + +#else +/* no threads */ +# define _STLP_ATOMIC_INCREMENT(__x) ++(*__x) +# define _STLP_ATOMIC_DECREMENT(__x) --(*__x) +/* We do not grant other atomic operations as they are useless if STLport do not have + * to be thread safe + */ +typedef size_t __stl_atomic_t; +#endif + +#if !defined (_STLP_MUTEX_INITIALIZER) +# if defined(_STLP_ATOMIC_EXCHANGE) +# define _STLP_MUTEX_INITIALIZER = { 0 } +# elif defined(_STLP_UITHREADS) +# define _STLP_MUTEX_INITIALIZER = { DEFAULTMUTEX } +# else +# define _STLP_MUTEX_INITIALIZER +# endif +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_THREADS) && !defined (_STLP_USE_PTHREAD_SPINLOCK) +// Helper struct. This is a workaround for various compilers that don't +// handle static variables in inline functions properly. +template +struct _STLP_mutex_spin { + enum { __low_max = 30, __high_max = 1000 }; + // Low if we suspect uniprocessor, high for multiprocessor. + static unsigned __max; + static unsigned __last; + static void _STLP_CALL _M_do_lock(volatile __stl_atomic_t* __lock); + static void _STLP_CALL _S_nsec_sleep(int __log_nsec, unsigned int& __iteration); +}; +#endif // !_STLP_USE_PTHREAD_SPINLOCK + +// Locking class. Note that this class *does not have a constructor*. +// It must be initialized either statically, with _STLP_MUTEX_INITIALIZER, +// or dynamically, by explicitly calling the _M_initialize member function. +// (This is similar to the ways that a pthreads mutex can be initialized.) +// There are explicit member functions for acquiring and releasing the lock. + +// There is no constructor because static initialization is essential for +// some uses, and only a class aggregate (see section 8.5.1 of the C++ +// standard) can be initialized that way. That means we must have no +// constructors, no base classes, no virtual functions, and no private or +// protected members. + +// For non-static cases, clients should use _STLP_mutex. + +struct _STLP_CLASS_DECLSPEC _STLP_mutex_base { +#if defined (_STLP_ATOMIC_EXCHANGE) || defined (_STLP_SGI_THREADS) + // It should be relatively easy to get this to work on any modern Unix. + volatile __stl_atomic_t _M_lock; +#endif + +#if defined (_STLP_THREADS) +# if defined (_STLP_ATOMIC_EXCHANGE) + inline void _M_initialize() { _M_lock = 0; } + inline void _M_destroy() {} + + void _M_acquire_lock() { + _STLP_mutex_spin<0>::_M_do_lock(&_M_lock); + } + + inline void _M_release_lock() { + volatile __stl_atomic_t* __lock = &_M_lock; +# if defined(_STLP_SGI_THREADS) && defined(__GNUC__) && __mips >= 3 + asm("sync"); + *__lock = 0; +# elif defined(_STLP_SGI_THREADS) && __mips >= 3 && \ + (defined (_ABIN32) || defined(_ABI64)) + __lock_release(__lock); +# elif defined (_STLP_SPARC_SOLARIS_THREADS) +# if defined (__WORD64) || defined (__arch64__) || defined (__sparcv9) || defined (__sparcv8plus) + asm("membar #StoreStore ; membar #LoadStore"); +# else + asm(" stbar "); +# endif + *__lock = 0; +# else + *__lock = 0; + // This is not sufficient on many multiprocessors, since + // writes to protected variables and the lock may be reordered. +# endif + } +# elif defined (_STLP_PTHREADS) +# if defined (_STLP_USE_PTHREAD_SPINLOCK) +# if !defined (__OpenBSD__) + pthread_spinlock_t _M_lock; + inline void _M_initialize() { pthread_spin_init( &_M_lock, 0 ); } + inline void _M_destroy() { pthread_spin_destroy( &_M_lock ); } + + // sorry, but no static initializer for pthread_spinlock_t; + // this will not work for compilers that has problems with call + // constructor of static object... + + // _STLP_mutex_base() + // { pthread_spin_init( &_M_lock, 0 ); } + + // ~_STLP_mutex_base() + // { pthread_spin_destroy( &_M_lock ); } + + inline void _M_acquire_lock() { pthread_spin_lock( &_M_lock ); } + inline void _M_release_lock() { pthread_spin_unlock( &_M_lock ); } +# else // __OpenBSD__ + sgx_spinlock_t _M_lock; + inline void _M_initialize() { _SPINLOCK_INIT( &_M_lock ); } + inline void _M_destroy() { } + inline void _M_acquire_lock() { _SPINLOCK( &_M_lock ); } + inline void _M_release_lock() { _SPINUNLOCK( &_M_lock ); } +# endif // __OpenBSD__ +# else // !_STLP_USE_PTHREAD_SPINLOCK + pthread_mutex_t _M_lock; + inline void _M_initialize() + { pthread_mutex_init(&_M_lock,_STLP_PTHREAD_ATTR_DEFAULT); } + inline void _M_destroy() + { pthread_mutex_destroy(&_M_lock); } + inline void _M_acquire_lock() { +# if defined ( __hpux ) && ! defined (PTHREAD_MUTEX_INITIALIZER) + if (!_M_lock.field1) _M_initialize(); +# endif + pthread_mutex_lock(&_M_lock); + } + inline void _M_release_lock() { pthread_mutex_unlock(&_M_lock); } +# endif // !_STLP_USE_PTHREAD_SPINLOCK + +# elif defined (_STLP_UITHREADS) + mutex_t _M_lock; + inline void _M_initialize() + { mutex_init(&_M_lock, 0, NULL); } + inline void _M_destroy() + { mutex_destroy(&_M_lock); } + inline void _M_acquire_lock() { mutex_lock(&_M_lock); } + inline void _M_release_lock() { mutex_unlock(&_M_lock); } + +# elif defined (_STLP_OS2THREADS) + HMTX _M_lock; + inline void _M_initialize() { DosCreateMutexSem(NULL, &_M_lock, 0, false); } + inline void _M_destroy() { DosCloseMutexSem(_M_lock); } + inline void _M_acquire_lock() { + if (!_M_lock) _M_initialize(); + DosRequestMutexSem(_M_lock, SEM_INDEFINITE_WAIT); + } + inline void _M_release_lock() { DosReleaseMutexSem(_M_lock); } +# elif defined (_STLP_BETHREADS) + sem_id sem; + inline void _M_initialize() { + sem = create_sem(1, "STLPort"); + assert(sem > 0); + } + inline void _M_destroy() { + int t = delete_sem(sem); + assert(t == B_NO_ERROR); + } + inline void _M_acquire_lock(); + inline void _M_release_lock() { + status_t t = release_sem(sem); + assert(t == B_NO_ERROR); + } +# elif defined (_STLP_NWTHREADS) + LONG _M_lock; + inline void _M_initialize() + { _M_lock = OpenLocalSemaphore(1); } + inline void _M_destroy() + { CloseLocalSemaphore(_M_lock); } + inline void _M_acquire_lock() + { WaitOnLocalSemaphore(_M_lock); } + inline void _M_release_lock() { SignalLocalSemaphore(_M_lock); } +# else //*ty 11/24/2001 - added configuration check +# error "Unknown thread facility configuration" +# endif +#else /* No threads */ + inline void _M_initialize() {} + inline void _M_destroy() {} + inline void _M_acquire_lock() {} + inline void _M_release_lock() {} +#endif // _STLP_PTHREADS +}; + +// Locking class. The constructor initializes the lock, the destructor destroys it. +// Well - behaving class, does not need static initializer + +class _STLP_CLASS_DECLSPEC _STLP_mutex : public _STLP_mutex_base { + public: + inline _STLP_mutex () { _M_initialize(); } + inline ~_STLP_mutex () { _M_destroy(); } + private: + _STLP_mutex(const _STLP_mutex&); + void operator=(const _STLP_mutex&); +}; + +// A locking class that uses _STLP_STATIC_MUTEX. The constructor takes +// a reference to an _STLP_STATIC_MUTEX, and acquires a lock. The destructor +// releases the lock. +// It's not clear that this is exactly the right functionality. +// It will probably change in the future. + +struct _STLP_CLASS_DECLSPEC _STLP_auto_lock { + _STLP_auto_lock(_STLP_STATIC_MUTEX& __lock) : _M_lock(__lock) + { _M_lock._M_acquire_lock(); } + ~_STLP_auto_lock() + { _M_lock._M_release_lock(); } + +private: + _STLP_STATIC_MUTEX& _M_lock; + void operator=(const _STLP_auto_lock&); + _STLP_auto_lock(const _STLP_auto_lock&); +}; + +/* + * Class _Refcount_Base provides a type, __stl_atomic_t, a data member, + * _M_ref_count, and member functions _M_incr and _M_decr, which perform + * atomic preincrement/predecrement. The constructor initializes + * _M_ref_count. + */ +class _STLP_CLASS_DECLSPEC _Refcount_Base { + // The data member _M_ref_count +#if defined (__DMC__) +public: +#endif + _STLP_VOLATILE __stl_atomic_t _M_ref_count; + +#if defined (_STLP_THREADS) && \ + (!defined (_STLP_ATOMIC_INCREMENT) || !defined (_STLP_ATOMIC_DECREMENT) || \ + defined (_STLP_WIN95_LIKE)) +# define _STLP_USE_MUTEX + _STLP_mutex _M_mutex; +#endif + + public: + // Constructor + _Refcount_Base(__stl_atomic_t __n) : _M_ref_count(__n) {} +#if defined (__BORLANDC__) + ~_Refcount_Base(){}; +#endif + + // _M_incr and _M_decr +#if defined (_STLP_THREADS) +# if !defined (_STLP_USE_MUTEX) + __stl_atomic_t _M_incr() { return _STLP_ATOMIC_INCREMENT(&_M_ref_count); } + __stl_atomic_t _M_decr() { return _STLP_ATOMIC_DECREMENT(&_M_ref_count); } +# else +# undef _STLP_USE_MUTEX + __stl_atomic_t _M_incr() { + _STLP_auto_lock l(_M_mutex); + return ++_M_ref_count; + } + __stl_atomic_t _M_decr() { + _STLP_auto_lock l(_M_mutex); + return --_M_ref_count; + } +# endif +#else /* No threads */ + __stl_atomic_t _M_incr() { return ++_M_ref_count; } + __stl_atomic_t _M_decr() { return --_M_ref_count; } +#endif +}; + +/* Atomic swap on __stl_atomic_t + * This is guaranteed to behave as though it were atomic only if all + * possibly concurrent updates use _Atomic_swap. + * In some cases the operation is emulated with a lock. + * Idem for _Atomic_swap_ptr + */ +/* Helper struct to handle following cases: + * - on platforms where sizeof(__stl_atomic_t) == sizeof(void*) atomic + * exchange can be done on pointers + * - on platform without atomic operation swap is done in a critical section, + * portable but inefficient. + */ +template +class _Atomic_swap_struct { +public: +#if defined (_STLP_THREADS) && \ + !defined (_STLP_ATOMIC_EXCHANGE) && \ + (defined (_STLP_PTHREADS) || defined (_STLP_UITHREADS) || defined (_STLP_OS2THREADS) || \ + defined (_STLP_USE_PTHREAD_SPINLOCK) || defined (_STLP_NWTHREADS)) +# define _STLP_USE_ATOMIC_SWAP_MUTEX + static _STLP_STATIC_MUTEX _S_swap_lock; +#endif + + static __stl_atomic_t _S_swap(_STLP_VOLATILE __stl_atomic_t* __p, __stl_atomic_t __q) { +#if defined (_STLP_THREADS) +# if defined (_STLP_ATOMIC_EXCHANGE) + return _STLP_ATOMIC_EXCHANGE(__p, __q); +# elif defined (_STLP_USE_ATOMIC_SWAP_MUTEX) + _S_swap_lock._M_acquire_lock(); + __stl_atomic_t __result = *__p; + *__p = __q; + _S_swap_lock._M_release_lock(); + return __result; +# else +# error Missing atomic swap implementation +# endif +#else + /* no threads */ + __stl_atomic_t __result = *__p; + *__p = __q; + return __result; +#endif // _STLP_THREADS + } + + static void* _S_swap_ptr(void* _STLP_VOLATILE* __p, void* __q) { +#if defined (_STLP_THREADS) +# if defined (_STLP_ATOMIC_EXCHANGE_PTR) + return _STLP_ATOMIC_EXCHANGE_PTR(__p, __q); +# elif defined (_STLP_ATOMIC_EXCHANGE) + _STLP_STATIC_ASSERT(sizeof(__stl_atomic_t) == sizeof(void*)) + return __REINTERPRET_CAST(void*, _STLP_ATOMIC_EXCHANGE(__REINTERPRET_CAST(volatile __stl_atomic_t*, __p), + __REINTERPRET_CAST(__stl_atomic_t, __q)) + ); +# elif defined (_STLP_USE_ATOMIC_SWAP_MUTEX) + _S_swap_lock._M_acquire_lock(); + void *__result = *__p; + *__p = __q; + _S_swap_lock._M_release_lock(); + return __result; +# else +# error Missing pointer atomic swap implementation +# endif +#else + /* no thread */ + void *__result = *__p; + *__p = __q; + return __result; +#endif + } +}; + +_STLP_TEMPLATE_NULL +class _Atomic_swap_struct<0> { +public: +#if defined (_STLP_THREADS) && \ + (!defined (_STLP_ATOMIC_EXCHANGE) || !defined (_STLP_ATOMIC_EXCHANGE_PTR)) && \ + (defined (_STLP_PTHREADS) || defined (_STLP_UITHREADS) || defined (_STLP_OS2THREADS) || \ + defined (_STLP_USE_PTHREAD_SPINLOCK) || defined (_STLP_NWTHREADS)) +# define _STLP_USE_ATOMIC_SWAP_MUTEX + static _STLP_STATIC_MUTEX _S_swap_lock; +#endif + + static __stl_atomic_t _S_swap(_STLP_VOLATILE __stl_atomic_t* __p, __stl_atomic_t __q) { +#if defined (_STLP_THREADS) +# if defined (_STLP_ATOMIC_EXCHANGE) + return _STLP_ATOMIC_EXCHANGE(__p, __q); +# elif defined (_STLP_USE_ATOMIC_SWAP_MUTEX) + /* This should be portable, but performance is expected + * to be quite awful. This really needs platform specific + * code. + */ + _S_swap_lock._M_acquire_lock(); + __stl_atomic_t __result = *__p; + *__p = __q; + _S_swap_lock._M_release_lock(); + return __result; +# else +# error Missing atomic swap implementation +# endif +#else + /* no threads */ + __stl_atomic_t __result = *__p; + *__p = __q; + return __result; +#endif // _STLP_THREADS + } + + static void* _S_swap_ptr(void* _STLP_VOLATILE* __p, void* __q) { +#if defined (_STLP_THREADS) +# if defined (_STLP_ATOMIC_EXCHANGE_PTR) + return _STLP_ATOMIC_EXCHANGE_PTR(__p, __q); +# elif defined (_STLP_ATOMIC_EXCHANGE) + _STLP_STATIC_ASSERT(sizeof(__stl_atomic_t) == sizeof(void*)) + return __REINTERPRET_CAST(void*, _STLP_ATOMIC_EXCHANGE(__REINTERPRET_CAST(volatile __stl_atomic_t*, __p), + __REINTERPRET_CAST(__stl_atomic_t, __q)) + ); +# elif defined (_STLP_USE_ATOMIC_SWAP_MUTEX) + _S_swap_lock._M_acquire_lock(); + void *__result = *__p; + *__p = __q; + _S_swap_lock._M_release_lock(); + return __result; +# else +# error Missing pointer atomic swap implementation +# endif +#else + /* no thread */ + void *__result = *__p; + *__p = __q; + return __result; +#endif + } +}; + +#if defined (_STLP_MSVC) && (_STLP_MSVC == 1300) +# pragma warning (push) +# pragma warning (disable : 4189) //__use_ptr_atomic_swap initialized but not used +#endif + +inline __stl_atomic_t _STLP_CALL _Atomic_swap(_STLP_VOLATILE __stl_atomic_t * __p, __stl_atomic_t __q) { + const int __use_ptr_atomic_swap = sizeof(__stl_atomic_t) == sizeof(void*); + return _Atomic_swap_struct<__use_ptr_atomic_swap>::_S_swap(__p, __q); +} + +inline void* _STLP_CALL _Atomic_swap_ptr(void* _STLP_VOLATILE* __p, void* __q) { + const int __use_ptr_atomic_swap = sizeof(__stl_atomic_t) == sizeof(void*); + return _Atomic_swap_struct<__use_ptr_atomic_swap>::_S_swap_ptr(__p, __q); +} + +#if defined (_STLP_MSVC) && (_STLP_MSVC == 1300) +# pragma warning (pop) +#endif + +#if defined (_STLP_BETHREADS) +template +struct _STLP_beos_static_lock_data { + static bool is_init; + struct mutex_t : public _STLP_mutex { + mutex_t() + { _STLP_beos_static_lock_data<0>::is_init = true; } + ~mutex_t() + { _STLP_beos_static_lock_data<0>::is_init = false; } + }; + static mutex_t mut; +}; + +template +bool _STLP_beos_static_lock_data<__inst>::is_init = false; +template +typename _STLP_beos_static_lock_data<__inst>::mutex_t _STLP_beos_static_lock_data<__inst>::mut; + +inline void _STLP_mutex_base::_M_acquire_lock() { + if (sem == 0) { + // we need to initialise on demand here + // to prevent race conditions use our global + // mutex if it's available: + if (_STLP_beos_static_lock_data<0>::is_init) { + _STLP_auto_lock al(_STLP_beos_static_lock_data<0>::mut); + if (sem == 0) _M_initialize(); + } + else { + // no lock available, we must still be + // in startup code, THERE MUST BE ONE THREAD + // ONLY active at this point. + _M_initialize(); + } + } + status_t t; + t = acquire_sem(sem); + assert(t == B_NO_ERROR); +} +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_THREADS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_time_facets.c b/sdk/tlibstdcxx/stlport/stl/_time_facets.c new file mode 100644 index 0000000000..f403817a12 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_time_facets.c @@ -0,0 +1,441 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_TIME_FACETS_C +#define _STLP_TIME_FACETS_C + +#ifndef _STLP_INTERNAL_TIME_FACETS_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUM_PUT_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUM_GET_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//---------------------------------------------------------------------- +// Declarations of static template members. + +template +locale::id time_get<_CharT, _InputIterator>::id; + +template +locale::id time_put<_CharT, _OutputIterator>::id; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* Matching input against a list of names + + * Alphabetic input of the names of months and the names + * of weekdays requires matching input against a list of names. + * We use a simple generic algorithm to accomplish this. This + * algorithm is not very efficient, especially for longer lists + * of names, but it probably does not matter for the initial + * implementation and it may never matter, since we do not expect + * this kind of input to be used very often. The algorithm + * could be improved fairly simply by creating a new list of + * names still in the running at each iteration. A more sophisticated + * approach would be to build a tree to do the matching. + * + * We compare each character of the input to the corresponding + * character of each name on the list that has not been eliminated, + * either because every character in the name has already been + * matched, or because some character has not been matched. We + * continue only as long as there are some names that have not been + * eliminated. + + * We do not really need a random access iterator (a forward iterator + * would do), but the extra generality makes the notation clumsier, + * and we don't really need it. + + * We can recognize a failed match by the fact that the return value + * will be __name_end. + */ + +#define _MAXNAMES 24 + +template +size_t _STLP_CALL +__match(_InIt& __first, _InIt& __last, _NameIt __name, _NameIt __name_end) { + typedef ptrdiff_t difference_type; + difference_type __n = __name_end - __name; + difference_type __i, __start = 0; + size_t __pos = 0; + difference_type __check_count = __n; + bool __do_not_check[_MAXNAMES]; + size_t __matching_name_index = __n; + + memset(__do_not_check, 0, sizeof(__do_not_check)); + + while (__first != __last) { + difference_type __new_n = __n; + for (__i = __start; __i < __n; ++__i) { + if (!__do_not_check[__i]) { + if (*__first == __name[__i][__pos]) { + if (__pos == (__name[__i].size() - 1)) { + __matching_name_index = __i; + __do_not_check[__i] = true; + if (__i == __start) ++__start; + --__check_count; + if (__check_count == 0) { + ++__first; + return __matching_name_index; + } + } + __new_n = __i + 1; + } + else { + __do_not_check[__i] = true; + if (__i == __start) ++__start; + --__check_count; + if (__check_count == 0) + return __matching_name_index; + } + } + else { + if (__i == __start) ++ __start; + } + } + + __n = __new_n; + ++__first; ++__pos; + } + + return __matching_name_index; +} + +// __get_formatted_time reads input that is assumed to be formatted +// according to the rules for the C strftime function (C standard, +// 7.12.3.5). This function is used to implement the do_get_time +// and do_get_date virtual functions, which depend on the locale +// specifications for the time and day formats respectively. +// Note the catchall default case, intended mainly for the '%Z' +// format designator, which does not make sense here since the +// representation of timezones is not part of the locale. +// +// The case branches are implemented either by doing a match using +// the appopriate name table or by doing a __get_integer_nogroup. +// +// 'y' format is assumed to mean that the input represents years +// since 1900. That is, 2002 should be represented as 102. There +// is no century-guessing. +// +// The match is successful if and only if the second component of the +// return value is format_end. + +// Note that the antepenultimate parameter is being used only to determine +// the correct overloading for the calls to __get_integer_nogroup. +template +string::const_iterator _STLP_CALL +__get_formatted_time _STLP_WEAK (_InIt1 __first, _InIt1 __last, + string::const_iterator __format, string::const_iterator __format_end, + _Ch*, const _TimeInfo& __table, + const ios_base& __s, ios_base::iostate& __err, tm* __t) { + const ctype<_Ch>& __ct = use_facet >(__s.getloc()); + typedef basic_string<_Ch, char_traits<_Ch>, allocator<_Ch> > string_type; + size_t offset; + + while (__first != __last && __format != __format_end) { + offset = 0; + if (*__format == '%') { + ++__format; + char __c = *__format; + if (__c == '#') { //MS extension + ++__format; + __c = *__format; + } + + switch (__c) { + case 'A': + offset = 7; + case 'a': { + size_t __index = __match(__first, __last, + __table._M_dayname + offset, __table._M_dayname + offset + 7); + if (__index == 7) + return __format; + __t->tm_wday = __STATIC_CAST(int, __index); + break; + } + + case 'B': + offset = 12; + case 'b': { + size_t __index = __match(__first, __last, + __table._M_monthname + offset, __table._M_monthname + offset + 12); + if (__index == 12) + return __format; + __t->tm_mon = __STATIC_CAST(int, __index); + break; + } + + case 'd': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_mday, __STATIC_CAST(_Ch*, 0)); + if (!__pr || __t->tm_mday < 1 || __t->tm_mday > 31) { + __err |= ios_base::failbit; + return __format; + } + break; + } + + case 'H': case 'I': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_hour, __STATIC_CAST(_Ch*, 0)); + if (!__pr) + return __format; + break; + } + + case 'j': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_yday, __STATIC_CAST(_Ch*, 0)); + if (!__pr) + return __format; + break; + } + + case 'm': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_mon, __STATIC_CAST(_Ch*, 0)); + --__t->tm_mon; + if (!__pr || __t->tm_mon < 0 || __t->tm_mon > 11) { + __err |= ios_base::failbit; + return __format; + } + break; + } + + case 'M': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_min, __STATIC_CAST(_Ch*, 0)); + if (!__pr) + return __format; + break; + } + + case 'p': { + size_t __index = __match(__first, __last, + __table._M_am_pm + 0, __table._M_am_pm + 2); + if (__index == 2) + return __format; + // 12:00 PM <=> 12:00, 12:00 AM <=> 00:00 + if (__index == 1 && __t->tm_hour != 12 ) + __t->tm_hour += 12; + if (__index == 0 && __t->tm_hour == 12 ) + __t->tm_hour = 0; + break; + } + + case 'S': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_sec, __STATIC_CAST(_Ch*, 0)); + if (!__pr) + return __format; + break; + } + + case 'y': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0)); + if (!__pr) + return __format; + break; + } + + case 'Y': { + bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0)); + __t->tm_year -= 1900; + if (!__pr) + return __format; + break; + } + + default: + break; + } + } + else { + if (*__first++ != __ct.widen(*__format)) break; + } + + ++__format; + } + + return __format; +} + +template +bool _STLP_CALL +__get_short_or_long_dayname(_InIt& __first, _InIt& __last, const _TimeInfo& __table, tm* __t) { + size_t __index = __match(__first, __last, __table._M_dayname + 0, __table._M_dayname + 14); + if (__index != 14) { + __t->tm_wday = __STATIC_CAST(int, __index % 7); + return true; + } + return false; +} + +template +bool _STLP_CALL +__get_short_or_long_monthname(_InIt& __first, _InIt& __last, const _TimeInfo& __table, tm* __t) { + size_t __index = __match(__first, __last, __table._M_monthname + 0, __table._M_monthname + 24); + if (__index != 24) { + __t->tm_mon = __STATIC_CAST(int, __index % 12); + return true; + } + return false; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +_InIt +time_get<_Ch, _InIt>::do_get_date(_InIt __s, _InIt __end, + ios_base& __str, ios_base::iostate& __err, + tm* __t) const { + typedef string::const_iterator string_iterator; + + string_iterator __format = this->_M_timeinfo._M_date_format.begin(); + string_iterator __format_end = this->_M_timeinfo._M_date_format.end(); + + string_iterator __result + = _STLP_PRIV __get_formatted_time(__s, __end, __format, __format_end, + __STATIC_CAST(_Ch*, 0), this->_M_timeinfo, + __str, __err, __t); + if (__result == __format_end) + __err = ios_base::goodbit; + else { + __err = ios_base::failbit; + if (__s == __end) + __err |= ios_base::eofbit; + } + return __s; +} + +template +_InIt +time_get<_Ch, _InIt>::do_get_time(_InIt __s, _InIt __end, + ios_base& __str, ios_base::iostate& __err, + tm* __t) const { + typedef string::const_iterator string_iterator; + string_iterator __format = this->_M_timeinfo._M_time_format.begin(); + string_iterator __format_end = this->_M_timeinfo._M_time_format.end(); + + string_iterator __result + = _STLP_PRIV __get_formatted_time(__s, __end, __format, __format_end, + __STATIC_CAST(_Ch*, 0), this->_M_timeinfo, + __str, __err, __t); + __err = __result == __format_end ? ios_base::goodbit + : ios_base::failbit; + if (__s == __end) + __err |= ios_base::eofbit; + return __s; +} + +template +_InIt +time_get<_Ch, _InIt>::do_get_year(_InIt __s, _InIt __end, + ios_base&, ios_base::iostate& __err, + tm* __t) const { + if (__s == __end) { + __err = ios_base::failbit | ios_base::eofbit; + return __s; + } + + bool __pr = _STLP_PRIV __get_decimal_integer(__s, __end, __t->tm_year, __STATIC_CAST(_Ch*, 0)); + __t->tm_year -= 1900; + __err = __pr ? ios_base::goodbit : ios_base::failbit; + if (__s == __end) + __err |= ios_base::eofbit; + + return __s; +} + +template +_InIt +time_get<_Ch, _InIt>::do_get_weekday(_InIt __s, _InIt __end, + ios_base &__str, ios_base::iostate &__err, + tm *__t) const { + bool __result = + _STLP_PRIV __get_short_or_long_dayname(__s, __end, this->_M_timeinfo, __t); + if (__result) + __err = ios_base::goodbit; + else { + __err = ios_base::failbit; + if (__s == __end) + __err |= ios_base::eofbit; + } + return __s; +} + +template +_InIt +time_get<_Ch, _InIt>::do_get_monthname(_InIt __s, _InIt __end, + ios_base &__str, ios_base::iostate &__err, + tm *__t) const { + bool __result = + _STLP_PRIV __get_short_or_long_monthname(__s, __end, this->_M_timeinfo, __t); + if (__result) + __err = ios_base::goodbit; + else { + __err = ios_base::failbit; + if (__s == __end) + __err |= ios_base::eofbit; + } + return __s; +} + +template +_OutputIter +time_put<_Ch,_OutputIter>::put(_OutputIter __s, ios_base& __f, _Ch __fill, + const tm* __tmb, const _Ch* __pat, + const _Ch* __pat_end) const { + const ctype<_Ch>& _Ct = use_facet >(__f.getloc()); + while (__pat != __pat_end) { + char __c = _Ct.narrow(*__pat, 0); + if (__c == '%') { + char __mod = 0; + ++__pat; + __c = _Ct.narrow(*__pat++, 0); + if (__c == '#') { // MS extension + __mod = __c; + __c = _Ct.narrow(*__pat++, 0); + } + __s = do_put(__s, __f, __fill, __tmb, __c, __mod); + } + else + *__s++ = *__pat++; + } + return __s; +} + +template +_OutputIter +time_put<_Ch,_OutputIter>::do_put(_OutputIter __s, ios_base& __f, _Ch /* __fill */, + const tm* __tmb, char __format, + char __modifier ) const { + const ctype<_Ch>& __ct = use_facet >(__f.getloc()); + _STLP_BASIC_IOSTRING(_Ch) __buf; + _STLP_PRIV __write_formatted_time(__buf, __ct, __format, __modifier, this->_M_timeinfo, __tmb); + return copy(__buf.begin(), __buf.end(), __s); +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_TIME_FACETS_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_time_facets.h b/sdk/tlibstdcxx/stlport/stl/_time_facets.h new file mode 100644 index 0000000000..e67c2f47a4 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_time_facets.h @@ -0,0 +1,329 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +// WARNING: This is an internal header file, included by other C++ +// standard library headers. You should not attempt to use this header +// file directly. + + +#ifndef _STLP_INTERNAL_TIME_FACETS_H +#define _STLP_INTERNAL_TIME_FACETS_H + +#ifndef _STLP_INTERNAL_CTIME +# include // Needed (for struct tm) by time facets +#endif + +#ifndef _STLP_C_LOCALE_H +# include +#endif + +#ifndef _STLP_IOS_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_IOSTREAM_STRING_H +# include +#endif + +#ifndef _STLP_FACETS_FWD_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Template functions used by time_get + +/* Both time_get and time_put need a structure of type _Time_Info + * to provide names and abbreviated names for months and days, + * as well as the am/pm designator. The month and weekday tables + * have the all the abbreviated names before all the full names. + * The _Time_Info tables are initialized using the non-template + * time_base class, which has a default constructor and two protected. + * The default one initialize _Time_Info with "C" time info. The + * protected initialize _time_Info using a _Locale_time instance + * or using a name( in fact the name is used to build a _Locale_time + * instance that is then used for initialization). */ + +class _STLP_CLASS_DECLSPEC _Time_Info_Base { +public: + string _M_time_format; + string _M_date_format; + string _M_date_time_format; + string _M_long_date_format; + string _M_long_date_time_format; +}; + +class _STLP_CLASS_DECLSPEC _Time_Info : public _Time_Info_Base { +public: + string _M_dayname[14]; + string _M_monthname[24]; + string _M_am_pm[2]; +}; + +#ifndef _STLP_NO_WCHAR_T +class _STLP_CLASS_DECLSPEC _WTime_Info : public _Time_Info_Base { +public: + wstring _M_dayname[14]; + wstring _M_monthname[24]; + wstring _M_am_pm[2]; +}; +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +class _STLP_CLASS_DECLSPEC time_base { +public: + enum dateorder {no_order, dmy, mdy, ymd, ydm}; +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class time_init; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC time_init { +protected: + time_init(); + time_init(const char *name); + time_init(_Locale_time*); +#if defined (__BORLANDC__) + static +#endif + _Time_Info _M_timeinfo; + time_base::dateorder _M_dateorder; +}; + +#ifndef _STLP_NO_WCHAR_T +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC time_init { +protected: + time_init(); + time_init(const char *name); + time_init(_Locale_time*); +#if defined (__BORLANDC__) + static +#endif + _WTime_Info _M_timeinfo; + time_base::dateorder _M_dateorder; +}; +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +template +class time_get : public locale::facet, public time_base, public _STLP_PRIV time_init<_Ch> { +public: + typedef _Ch char_type; + typedef _InIt iter_type; + + explicit time_get(size_t __refs = 0) : locale::facet(__refs) + {} + + dateorder date_order() const { return do_date_order(); } + iter_type get_time(iter_type __s, iter_type __end, ios_base& __str, + ios_base::iostate& __err, tm* __t) const + { return do_get_time(__s, __end, __str, __err, __t); } + iter_type get_date(iter_type __s, iter_type __end, ios_base& __str, + ios_base::iostate& __err, tm* __t) const + { return do_get_date(__s, __end, __str, __err, __t); } + iter_type get_weekday(iter_type __s, iter_type __end, ios_base& __str, + ios_base::iostate& __err, tm* __t) const + { return do_get_weekday(__s, __end, __str, __err, __t); } + iter_type get_monthname(iter_type __s, iter_type __end, ios_base& __str, + ios_base::iostate& __err, tm* __t) const + { return do_get_monthname(__s, __end, __str, __err, __t); } + iter_type get_year(iter_type __s, iter_type __end, ios_base& __str, + ios_base::iostate& __err, tm* __t) const + { return do_get_year(__s, __end, __str, __err, __t); } + + static locale::id id; + +protected: + time_get(const char* __name, size_t __refs) + : locale::facet(__refs), _STLP_PRIV time_init<_Ch>(__name) + {} + time_get(_Locale_time *__time) + : _STLP_PRIV time_init<_Ch>(__time) + {} + + ~time_get() {} + + virtual dateorder do_date_order() const { return this->_M_dateorder; } + + virtual iter_type do_get_time(iter_type __s, iter_type __end, + ios_base&, ios_base::iostate& __err, + tm* __t) const; + + virtual iter_type do_get_date(iter_type __s, iter_type __end, + ios_base&, ios_base::iostate& __err, + tm* __t) const; + + virtual iter_type do_get_weekday(iter_type __s, iter_type __end, + ios_base&, + ios_base::iostate& __err, + tm* __t) const; + virtual iter_type do_get_monthname(iter_type __s, iter_type __end, + ios_base&, + ios_base::iostate& __err, + tm* __t) const; + + virtual iter_type do_get_year(iter_type __s, iter_type __end, + ios_base&, ios_base::iostate& __err, + tm* __t) const; +}; + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class time_get_byname : public time_get<_Ch, _InIt> { + friend class _Locale_impl; +public: + typedef time_base::dateorder dateorder; + typedef _InIt iter_type; + + explicit time_get_byname(const char* __name, size_t __refs = 0) + : time_get<_Ch, _InIt>(__name, __refs) {} + +protected: + ~time_get_byname() {} + dateorder do_date_order() const { return this->_M_dateorder; } + +private: + time_get_byname(_Locale_time *__time) + : time_get<_Ch, _InIt>(__time) + {} + + typedef time_get_byname<_Ch, _InIt> _Self; + //explicitely defined as private to avoid warnings: + time_get_byname(_Self const&); + _Self& operator = (_Self const&); +}; + +// time_put facet + +// For the formats 'x, 'X', and 'c', do_put calls the first form of +// put with the pattern obtained from _M_timeinfo._M_date_format or +// _M_timeinfo._M_time_format. + +// Helper function: __ takes a single-character +// format. As indicated by the foregoing remark, this will never be +// 'x', 'X', or 'c'. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_DECLSPEC void _STLP_CALL +__write_formatted_time(__iostring&, const ctype& __ct, + char __format, char __modifier, + const _Time_Info& __table, const tm* __t); + +#ifndef _STLP_NO_WCHAR_T +_STLP_DECLSPEC void _STLP_CALL +__write_formatted_time(__iowstring&, const ctype& __ct, + char __format, char __modifier, + const _WTime_Info& __table, const tm* __t); +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +template +class time_put : public locale::facet, public time_base, public _STLP_PRIV time_init<_Ch> { +public: + typedef _Ch char_type; + typedef _OutIt iter_type; + + explicit time_put(size_t __refs = 0) : locale::facet(__refs) + {} + + _OutIt put(iter_type __s, ios_base& __f, _Ch __fill, + const tm* __tmb, + const _Ch* __pat, const _Ch* __pat_end) const; + + _OutIt put(iter_type __s, ios_base& __f, _Ch __fill, + const tm* __tmb, char __format, char __modifier = 0) const + { return do_put(__s, __f, __fill, __tmb, __format, __modifier); } + + static locale::id id; + +protected: + time_put(const char* __name, size_t __refs) + : locale::facet(__refs), _STLP_PRIV time_init<_Ch>(__name) + {} + time_put(_Locale_time *__time) + : _STLP_PRIV time_init<_Ch>(__time) + {} + ~time_put() {} + virtual iter_type do_put(iter_type __s, ios_base& __f, + char_type /* __fill */, const tm* __tmb, + char __format, char /* __modifier */) const; +}; + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template +#else +template > > +#endif +class time_put_byname : public time_put<_Ch, _OutIt> { + friend class _Locale_impl; +public: + typedef time_base::dateorder dateorder; + typedef _OutIt iter_type; + typedef _Ch char_type; + + explicit time_put_byname(const char * __name, size_t __refs = 0) + : time_put<_Ch, _OutIt>(__name, __refs) + {} + +protected: + ~time_put_byname() {} + +private: + time_put_byname(_Locale_time *__time) + : time_put<_Ch, _OutIt>(__time) + {} + + typedef time_put_byname<_Ch, _OutIt> _Self; + //explicitely defined as private to avoid warnings: + time_put_byname(_Self const&); + _Self& operator = (_Self const&); +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS time_get > >; +_STLP_EXPORT_TEMPLATE_CLASS time_put > >; +# if !defined (_STLP_NO_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS time_get > >; +_STLP_EXPORT_TEMPLATE_CLASS time_put > >; +# endif + +#endif + +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* _STLP_INTERNAL_TIME_FACETS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_tree.c b/sdk/tlibstdcxx/stlport/stl/_tree.c new file mode 100644 index 0000000000..818fcc4acd --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_tree.c @@ -0,0 +1,730 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Modified CRP 7/10/00 for improved conformance / efficiency on insert_unique / + * insert_equal with valid hint -- efficiency is improved all around, and it is + * should now be standard conforming for complexity on insert point immediately + * after hint (amortized constant time). + * + */ +#ifndef _STLP_TREE_C +#define _STLP_TREE_C + +#ifndef _STLP_INTERNAL_TREE_H +# include +#endif + +#if defined (_STLP_DEBUG) +# define _Rb_tree _STLP_NON_DBG_NAME(Rb_tree) +#endif + +// fbp: these defines are for outline methods definitions. +// needed for definitions to be portable. Should not be used in method bodies. +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define __iterator__ _Rb_tree_iterator<_Value, _STLP_HEADER_TYPENAME _Traits::_NonConstTraits> +# define __size_type__ size_t +# define iterator __iterator__ +#else +# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc>::iterator +# define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc>::size_type +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) + +template void _STLP_CALL +_Rb_global<_Dummy>::_Rotate_left(_Rb_tree_node_base* __x, + _Rb_tree_node_base*& __root) { + _Rb_tree_node_base* __y = __x->_M_right; + __x->_M_right = __y->_M_left; + if (__y->_M_left != 0) + __y->_M_left->_M_parent = __x; + __y->_M_parent = __x->_M_parent; + + if (__x == __root) + __root = __y; + else if (__x == __x->_M_parent->_M_left) + __x->_M_parent->_M_left = __y; + else + __x->_M_parent->_M_right = __y; + __y->_M_left = __x; + __x->_M_parent = __y; +} + +template void _STLP_CALL +_Rb_global<_Dummy>::_Rotate_right(_Rb_tree_node_base* __x, + _Rb_tree_node_base*& __root) { + _Rb_tree_node_base* __y = __x->_M_left; + __x->_M_left = __y->_M_right; + if (__y->_M_right != 0) + __y->_M_right->_M_parent = __x; + __y->_M_parent = __x->_M_parent; + + if (__x == __root) + __root = __y; + else if (__x == __x->_M_parent->_M_right) + __x->_M_parent->_M_right = __y; + else + __x->_M_parent->_M_left = __y; + __y->_M_right = __x; + __x->_M_parent = __y; +} + +template void _STLP_CALL +_Rb_global<_Dummy>::_Rebalance(_Rb_tree_node_base* __x, + _Rb_tree_node_base*& __root) { + __x->_M_color = _S_rb_tree_red; + while (__x != __root && __x->_M_parent->_M_color == _S_rb_tree_red) { + if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left) { + _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right; + if (__y && __y->_M_color == _S_rb_tree_red) { + __x->_M_parent->_M_color = _S_rb_tree_black; + __y->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + __x = __x->_M_parent->_M_parent; + } + else { + if (__x == __x->_M_parent->_M_right) { + __x = __x->_M_parent; + _Rotate_left(__x, __root); + } + __x->_M_parent->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + _Rotate_right(__x->_M_parent->_M_parent, __root); + } + } + else { + _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left; + if (__y && __y->_M_color == _S_rb_tree_red) { + __x->_M_parent->_M_color = _S_rb_tree_black; + __y->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + __x = __x->_M_parent->_M_parent; + } + else { + if (__x == __x->_M_parent->_M_left) { + __x = __x->_M_parent; + _Rotate_right(__x, __root); + } + __x->_M_parent->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + _Rotate_left(__x->_M_parent->_M_parent, __root); + } + } + } + __root->_M_color = _S_rb_tree_black; +} + +template _Rb_tree_node_base* _STLP_CALL +_Rb_global<_Dummy>::_Rebalance_for_erase(_Rb_tree_node_base* __z, + _Rb_tree_node_base*& __root, + _Rb_tree_node_base*& __leftmost, + _Rb_tree_node_base*& __rightmost) { + _Rb_tree_node_base* __y = __z; + _Rb_tree_node_base* __x; + _Rb_tree_node_base* __x_parent; + + if (__y->_M_left == 0) // __z has at most one non-null child. y == z. + __x = __y->_M_right; // __x might be null. + else { + if (__y->_M_right == 0) // __z has exactly one non-null child. y == z. + __x = __y->_M_left; // __x is not null. + else { // __z has two non-null children. Set __y to + __y = _Rb_tree_node_base::_S_minimum(__y->_M_right); // __z's successor. __x might be null. + __x = __y->_M_right; + } + } + + if (__y != __z) { // relink y in place of z. y is z's successor + __z->_M_left->_M_parent = __y; + __y->_M_left = __z->_M_left; + if (__y != __z->_M_right) { + __x_parent = __y->_M_parent; + if (__x) __x->_M_parent = __y->_M_parent; + __y->_M_parent->_M_left = __x; // __y must be a child of _M_left + __y->_M_right = __z->_M_right; + __z->_M_right->_M_parent = __y; + } + else + __x_parent = __y; + if (__root == __z) + __root = __y; + else if (__z->_M_parent->_M_left == __z) + __z->_M_parent->_M_left = __y; + else + __z->_M_parent->_M_right = __y; + __y->_M_parent = __z->_M_parent; + _STLP_STD::swap(__y->_M_color, __z->_M_color); + __y = __z; + // __y now points to node to be actually deleted + } + else { // __y == __z + __x_parent = __y->_M_parent; + if (__x) __x->_M_parent = __y->_M_parent; + if (__root == __z) + __root = __x; + else { + if (__z->_M_parent->_M_left == __z) + __z->_M_parent->_M_left = __x; + else + __z->_M_parent->_M_right = __x; + } + + if (__leftmost == __z) { + if (__z->_M_right == 0) // __z->_M_left must be null also + __leftmost = __z->_M_parent; + // makes __leftmost == _M_header if __z == __root + else + __leftmost = _Rb_tree_node_base::_S_minimum(__x); + } + if (__rightmost == __z) { + if (__z->_M_left == 0) // __z->_M_right must be null also + __rightmost = __z->_M_parent; + // makes __rightmost == _M_header if __z == __root + else // __x == __z->_M_left + __rightmost = _Rb_tree_node_base::_S_maximum(__x); + } + } + + if (__y->_M_color != _S_rb_tree_red) { + while (__x != __root && (__x == 0 || __x->_M_color == _S_rb_tree_black)) + if (__x == __x_parent->_M_left) { + _Rb_tree_node_base* __w = __x_parent->_M_right; + if (__w->_M_color == _S_rb_tree_red) { + __w->_M_color = _S_rb_tree_black; + __x_parent->_M_color = _S_rb_tree_red; + _Rotate_left(__x_parent, __root); + __w = __x_parent->_M_right; + } + if ((__w->_M_left == 0 || + __w->_M_left->_M_color == _S_rb_tree_black) && (__w->_M_right == 0 || + __w->_M_right->_M_color == _S_rb_tree_black)) { + __w->_M_color = _S_rb_tree_red; + __x = __x_parent; + __x_parent = __x_parent->_M_parent; + } else { + if (__w->_M_right == 0 || + __w->_M_right->_M_color == _S_rb_tree_black) { + if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; + __w->_M_color = _S_rb_tree_red; + _Rotate_right(__w, __root); + __w = __x_parent->_M_right; + } + __w->_M_color = __x_parent->_M_color; + __x_parent->_M_color = _S_rb_tree_black; + if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; + _Rotate_left(__x_parent, __root); + break; + } + } else { // same as above, with _M_right <-> _M_left. + _Rb_tree_node_base* __w = __x_parent->_M_left; + if (__w->_M_color == _S_rb_tree_red) { + __w->_M_color = _S_rb_tree_black; + __x_parent->_M_color = _S_rb_tree_red; + _Rotate_right(__x_parent, __root); + __w = __x_parent->_M_left; + } + if ((__w->_M_right == 0 || + __w->_M_right->_M_color == _S_rb_tree_black) && (__w->_M_left == 0 || + __w->_M_left->_M_color == _S_rb_tree_black)) { + __w->_M_color = _S_rb_tree_red; + __x = __x_parent; + __x_parent = __x_parent->_M_parent; + } else { + if (__w->_M_left == 0 || + __w->_M_left->_M_color == _S_rb_tree_black) { + if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; + __w->_M_color = _S_rb_tree_red; + _Rotate_left(__w, __root); + __w = __x_parent->_M_left; + } + __w->_M_color = __x_parent->_M_color; + __x_parent->_M_color = _S_rb_tree_black; + if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; + _Rotate_right(__x_parent, __root); + break; + } + } + if (__x) __x->_M_color = _S_rb_tree_black; + } + return __y; +} + +template _Rb_tree_node_base* _STLP_CALL +_Rb_global<_Dummy>::_M_decrement(_Rb_tree_node_base* _M_node) { + if (_M_node->_M_color == _S_rb_tree_red && _M_node->_M_parent->_M_parent == _M_node) + _M_node = _M_node->_M_right; + else if (_M_node->_M_left != 0) { + _M_node = _Rb_tree_node_base::_S_maximum(_M_node->_M_left); + } + else { + _Base_ptr __y = _M_node->_M_parent; + while (_M_node == __y->_M_left) { + _M_node = __y; + __y = __y->_M_parent; + } + _M_node = __y; + } + return _M_node; +} + +template _Rb_tree_node_base* _STLP_CALL +_Rb_global<_Dummy>::_M_increment(_Rb_tree_node_base* _M_node) { + if (_M_node->_M_right != 0) { + _M_node = _Rb_tree_node_base::_S_minimum(_M_node->_M_right); + } + else { + _Base_ptr __y = _M_node->_M_parent; + while (_M_node == __y->_M_right) { + _M_node = __y; + __y = __y->_M_parent; + } + // check special case: This is necessary if _M_node is the + // _M_head and the tree contains only a single node __y. In + // that case parent, left and right all point to __y! + if (_M_node->_M_right != __y) + _M_node = __y; + } + return _M_node; +} + +#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */ + + +template +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>& +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::operator=( + const _Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>& __x) { + if (this != &__x) { + // Note that _Key may be a constant type. + clear(); + _M_node_count = 0; + _M_key_compare = __x._M_key_compare; + if (__x._M_root() == 0) { + _M_root() = 0; + _M_leftmost() = &this->_M_header._M_data; + _M_rightmost() = &this->_M_header._M_data; + } + else { + _M_root() = _M_copy(__x._M_root(), &this->_M_header._M_data); + _M_leftmost() = _S_minimum(_M_root()); + _M_rightmost() = _S_maximum(_M_root()); + _M_node_count = __x._M_node_count; + } + } + return *this; +} + +// CRP 7/10/00 inserted argument __on_right, which is another hint (meant to +// act like __on_left and ignore a portion of the if conditions -- specify +// __on_right != 0 to bypass comparison as false or __on_left != 0 to bypass +// comparison as true) +template +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::_M_insert(_Rb_tree_node_base * __parent, + const _Value& __val, + _Rb_tree_node_base * __on_left, + _Rb_tree_node_base * __on_right) { + // We do not create the node here as, depending on tests, we might call + // _M_key_compare that can throw an exception. + _Base_ptr __new_node; + + if ( __parent == &this->_M_header._M_data ) { + __new_node = _M_create_node(__val); + _S_left(__parent) = __new_node; // also makes _M_leftmost() = __new_node + _M_root() = __new_node; + _M_rightmost() = __new_node; + } + else if ( __on_right == 0 && // If __on_right != 0, the remainder fails to false + ( __on_left != 0 || // If __on_left != 0, the remainder succeeds to true + _M_key_compare( _KeyOfValue()(__val), _S_key(__parent) ) ) ) { + __new_node = _M_create_node(__val); + _S_left(__parent) = __new_node; + if (__parent == _M_leftmost()) + _M_leftmost() = __new_node; // maintain _M_leftmost() pointing to min node + } + else { + __new_node = _M_create_node(__val); + _S_right(__parent) = __new_node; + if (__parent == _M_rightmost()) + _M_rightmost() = __new_node; // maintain _M_rightmost() pointing to max node + } + _S_parent(__new_node) = __parent; + _Rb_global_inst::_Rebalance(__new_node, this->_M_header._M_data._M_parent); + ++_M_node_count; + return iterator(__new_node); +} + +template +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_equal(const _Value& __val) { + _Base_ptr __y = &this->_M_header._M_data; + _Base_ptr __x = _M_root(); + while (__x != 0) { + __y = __x; + if (_M_key_compare(_KeyOfValue()(__val), _S_key(__x))) { + __x = _S_left(__x); + } + else + __x = _S_right(__x); + } + return _M_insert(__y, __val, __x); +} + + +template +pair<__iterator__, bool> +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_unique(const _Value& __val) { + _Base_ptr __y = &this->_M_header._M_data; + _Base_ptr __x = _M_root(); + bool __comp = true; + while (__x != 0) { + __y = __x; + __comp = _M_key_compare(_KeyOfValue()(__val), _S_key(__x)); + __x = __comp ? _S_left(__x) : _S_right(__x); + } + iterator __j = iterator(__y); + if (__comp) { + if (__j == begin()) + return pair(_M_insert(__y, __val, /* __x*/ __y), true); + else + --__j; + } + if (_M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__val))) { + return pair(_M_insert(__y, __val, __x), true); + } + return pair(__j, false); +} + +// Modifications CRP 7/10/00 as noted to improve conformance and +// efficiency. +template +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_unique(iterator __position, + const _Value& __val) { + if (__position._M_node == this->_M_header._M_data._M_left) { // begin() + + // if the container is empty, fall back on insert_unique. + if (empty()) + return insert_unique(__val).first; + + if (_M_key_compare(_KeyOfValue()(__val), _S_key(__position._M_node))) { + return _M_insert(__position._M_node, __val, __position._M_node); + } + // first argument just needs to be non-null + else { + bool __comp_pos_v = _M_key_compare( _S_key(__position._M_node), _KeyOfValue()(__val) ); + + if (__comp_pos_v == false) // compare > and compare < both false so compare equal + return __position; + //Below __comp_pos_v == true + + // Standard-conformance - does the insertion point fall immediately AFTER + // the hint? + iterator __after = __position; + ++__after; + + // Check for only one member -- in that case, __position points to itself, + // and attempting to increment will cause an infinite loop. + if (__after._M_node == &this->_M_header._M_data) + // Check guarantees exactly one member, so comparison was already + // performed and we know the result; skip repeating it in _M_insert + // by specifying a non-zero fourth argument. + return _M_insert(__position._M_node, __val, 0, __position._M_node); + + // All other cases: + + // Optimization to catch insert-equivalent -- save comparison results, + // and we get this for free. + if (_M_key_compare( _KeyOfValue()(__val), _S_key(__after._M_node) )) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } + else { + return insert_unique(__val).first; + } + } + } + else if (__position._M_node == &this->_M_header._M_data) { // end() + if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__val))) { + // pass along to _M_insert that it can skip comparing + // v, Key ; since compare Key, v was true, compare v, Key must be false. + return _M_insert(_M_rightmost(), __val, 0, __position._M_node); // Last argument only needs to be non-null + } + else + return insert_unique(__val).first; + } + else { + iterator __before = __position; + --__before; + + bool __comp_v_pos = _M_key_compare(_KeyOfValue()(__val), _S_key(__position._M_node)); + + if (__comp_v_pos + && _M_key_compare( _S_key(__before._M_node), _KeyOfValue()(__val) )) { + + if (_S_right(__before._M_node) == 0) + return _M_insert(__before._M_node, __val, 0, __before._M_node); // Last argument only needs to be non-null + else + return _M_insert(__position._M_node, __val, __position._M_node); + // first argument just needs to be non-null + } + else { + // Does the insertion point fall immediately AFTER the hint? + iterator __after = __position; + ++__after; + // Optimization to catch equivalent cases and avoid unnecessary comparisons + bool __comp_pos_v = !__comp_v_pos; // Stored this result earlier + // If the earlier comparison was true, this comparison doesn't need to be + // performed because it must be false. However, if the earlier comparison + // was false, we need to perform this one because in the equal case, both will + // be false. + if (!__comp_v_pos) { + __comp_pos_v = _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__val)); + } + + if ( (!__comp_v_pos) // comp_v_pos true implies comp_v_pos false + && __comp_pos_v + && (__after._M_node == &this->_M_header._M_data || + _M_key_compare( _KeyOfValue()(__val), _S_key(__after._M_node) ))) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } else { + // Test for equivalent case + if (__comp_v_pos == __comp_pos_v) + return __position; + else + return insert_unique(__val).first; + } + } + } +} + +template +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_equal(iterator __position, + const _Value& __val) { + if (__position._M_node == this->_M_header._M_data._M_left) { // begin() + + // Check for zero members + if (size() <= 0) + return insert_equal(__val); + + if (!_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__val))) + return _M_insert(__position._M_node, __val, __position._M_node); + else { + // Check for only one member + if (__position._M_node->_M_left == __position._M_node) + // Unlike insert_unique, can't avoid doing a comparison here. + return _M_insert(__position._M_node, __val); + + // All other cases: + // Standard-conformance - does the insertion point fall immediately AFTER + // the hint? + iterator __after = __position; + ++__after; + + // Already know that compare(pos, v) must be true! + // Therefore, we want to know if compare(after, v) is false. + // (i.e., we now pos < v, now we want to know if v <= after) + // If not, invalid hint. + if ( __after._M_node == &this->_M_header._M_data || + !_M_key_compare( _S_key(__after._M_node), _KeyOfValue()(__val) ) ) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } + else { // Invalid hint + return insert_equal(__val); + } + } + } + else if (__position._M_node == &this->_M_header._M_data) { // end() + if (!_M_key_compare(_KeyOfValue()(__val), _S_key(_M_rightmost()))) + return _M_insert(_M_rightmost(), __val, 0, __position._M_node); // Last argument only needs to be non-null + else { + return insert_equal(__val); + } + } + else { + iterator __before = __position; + --__before; + // store the result of the comparison between pos and v so + // that we don't have to do it again later. Note that this reverses the shortcut + // on the if, possibly harming efficiency in comparisons; I think the harm will + // be negligible, and to do what I want to do (save the result of a comparison so + // that it can be re-used) there is no alternative. Test here is for before <= v <= pos. + bool __comp_pos_v = _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__val)); + if (!__comp_pos_v && + !_M_key_compare(_KeyOfValue()(__val), _S_key(__before._M_node))) { + if (_S_right(__before._M_node) == 0) + return _M_insert(__before._M_node, __val, 0, __before._M_node); // Last argument only needs to be non-null + else + return _M_insert(__position._M_node, __val, __position._M_node); + } + else { + // Does the insertion point fall immediately AFTER the hint? + // Test for pos < v <= after + iterator __after = __position; + ++__after; + + if (__comp_pos_v && + ( __after._M_node == &this->_M_header._M_data || + !_M_key_compare( _S_key(__after._M_node), _KeyOfValue()(__val) ) ) ) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } + else { // Invalid hint + return insert_equal(__val); + } + } + } +} + +template +_Rb_tree_node_base* +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::_M_copy(_Rb_tree_node_base* __x, + _Rb_tree_node_base* __p) { + // structural copy. __x and __p must be non-null. + _Base_ptr __top = _M_clone_node(__x); + _S_parent(__top) = __p; + + _STLP_TRY { + if (_S_right(__x)) + _S_right(__top) = _M_copy(_S_right(__x), __top); + __p = __top; + __x = _S_left(__x); + + while (__x != 0) { + _Base_ptr __y = _M_clone_node(__x); + _S_left(__p) = __y; + _S_parent(__y) = __p; + if (_S_right(__x)) + _S_right(__y) = _M_copy(_S_right(__x), __y); + __p = __y; + __x = _S_left(__x); + } + } + _STLP_UNWIND(_M_erase(__top)) + + return __top; +} + +// this has to stay out-of-line : it's recursive +template +void +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>::_M_erase(_Rb_tree_node_base *__x) { + // erase without rebalancing + while (__x != 0) { + _M_erase(_S_right(__x)); + _Base_ptr __y = _S_left(__x); + _STLP_STD::_Destroy(&_S_value(__x)); + this->_M_header.deallocate(__STATIC_CAST(_Link_type, __x),1); + __x = __y; + } +} + +#if defined (_STLP_DEBUG) +inline int +__black_count(_Rb_tree_node_base* __node, _Rb_tree_node_base* __root) { + if (__node == 0) + return 0; + else { + int __bc = __node->_M_color == _S_rb_tree_black ? 1 : 0; + if (__node == __root) + return __bc; + else + return __bc + __black_count(__node->_M_parent, __root); + } +} + +template +bool _Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>::__rb_verify() const { + if (_M_node_count == 0 || begin() == end()) + return ((_M_node_count == 0) && + (begin() == end()) && + (this->_M_header._M_data._M_left == &this->_M_header._M_data) && + (this->_M_header._M_data._M_right == &this->_M_header._M_data)); + + int __len = __black_count(_M_leftmost(), _M_root()); + for (const_iterator __it = begin(); __it != end(); ++__it) { + _Base_ptr __x = __it._M_node; + _Base_ptr __L = _S_left(__x); + _Base_ptr __R = _S_right(__x); + + if (__x->_M_color == _S_rb_tree_red) + if ((__L && __L->_M_color == _S_rb_tree_red) || + (__R && __R->_M_color == _S_rb_tree_red)) + return false; + + if (__L && _M_key_compare(_S_key(__x), _S_key(__L))) + return false; + if (__R && _M_key_compare(_S_key(__R), _S_key(__x))) + return false; + + if (!__L && !__R && __black_count(__x, _M_root()) != __len) + return false; + } + + if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root())) + return false; + if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root())) + return false; + + return true; +} +#endif /* _STLP_DEBUG */ + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#undef _Rb_tree +#undef __iterator__ +#undef iterator +#undef __size_type__ + +#endif /* _STLP_TREE_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_tree.h b/sdk/tlibstdcxx/stlport/stl/_tree.h new file mode 100644 index 0000000000..bf059015e9 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_tree.h @@ -0,0 +1,684 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_TREE_H +#define _STLP_INTERNAL_TREE_H + +/* + +Red-black tree class, designed for use in implementing STL +associative containers (set, multiset, map, and multimap). The +insertion and deletion algorithms are based on those in Cormen, +Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990), +except that + +(1) the header cell is maintained with links not only to the root +but also to the leftmost node of the tree, to enable constant time +begin(), and to the rightmost node of the tree, to enable linear time +performance when used with the generic set algorithms (set_union, +etc.); + +(2) when a node being deleted has two children its successor node is +relinked into its place, rather than copied, so that the only +iterators invalidated are those referring to the deleted node. + +*/ + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +typedef bool _Rb_tree_Color_type; +//const _Rb_tree_Color_type _S_rb_tree_red = false; +//const _Rb_tree_Color_type _S_rb_tree_black = true; + +#define _S_rb_tree_red false +#define _S_rb_tree_black true + +struct _Rb_tree_node_base { + typedef _Rb_tree_Color_type _Color_type; + typedef _Rb_tree_node_base* _Base_ptr; + + _Color_type _M_color; + _Base_ptr _M_parent; + _Base_ptr _M_left; + _Base_ptr _M_right; + + static _Base_ptr _STLP_CALL _S_minimum(_Base_ptr __x) { + while (__x->_M_left != 0) __x = __x->_M_left; + return __x; + } + + static _Base_ptr _STLP_CALL _S_maximum(_Base_ptr __x) { + while (__x->_M_right != 0) __x = __x->_M_right; + return __x; + } +}; + +template +struct _Rb_tree_node : public _Rb_tree_node_base { + _Value _M_value_field; + __TRIVIAL_STUFF(_Rb_tree_node) +}; + +struct _Rb_tree_base_iterator; + +template +class _Rb_global { +public: + typedef _Rb_tree_node_base* _Base_ptr; + // those used to be global functions + static void _STLP_CALL _Rebalance(_Base_ptr __x, _Base_ptr& __root); + static _Base_ptr _STLP_CALL _Rebalance_for_erase(_Base_ptr __z, + _Base_ptr& __root, + _Base_ptr& __leftmost, + _Base_ptr& __rightmost); + // those are from _Rb_tree_base_iterator - moved here to reduce code bloat + // moved here to reduce code bloat without templatizing _Rb_tree_base_iterator + static _Base_ptr _STLP_CALL _M_increment (_Base_ptr); + static _Base_ptr _STLP_CALL _M_decrement (_Base_ptr); + static void _STLP_CALL _Rotate_left (_Base_ptr __x, _Base_ptr& __root); + static void _STLP_CALL _Rotate_right(_Base_ptr __x, _Base_ptr& __root); +}; + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _Rb_global; +# endif + +typedef _Rb_global _Rb_global_inst; + +struct _Rb_tree_base_iterator { + typedef _Rb_tree_node_base* _Base_ptr; + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + _Base_ptr _M_node; + _Rb_tree_base_iterator() : _M_node(0) {} + _Rb_tree_base_iterator(_Base_ptr __x) : _M_node(__x) {} +}; + +template +struct _Rb_tree_iterator : public _Rb_tree_base_iterator { + typedef _Value value_type; + typedef typename _Traits::reference reference; + typedef typename _Traits::pointer pointer; + typedef _Rb_tree_iterator<_Value, _Traits> _Self; + typedef _Rb_tree_node_base* _Base_ptr; + typedef _Rb_tree_node<_Value>* _Link_type; + + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef _Rb_tree_iterator<_Value, _NonConstTraits> iterator; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _Rb_tree_iterator<_Value, _ConstTraits> const_iterator; + + _Rb_tree_iterator() {} +#if !defined (_STLP_DEBUG) + /* In STL debug mode we need this constructor implicit for the pointer + * specialization implementation. + */ + explicit +#endif + _Rb_tree_iterator(_Base_ptr __x) : _Rb_tree_base_iterator(__x) {} + //copy constructor for iterator and constructor from iterator for const_iterator + _Rb_tree_iterator(const iterator& __it) : _Rb_tree_base_iterator(__it._M_node) {} + + reference operator*() const { + return __STATIC_CAST(_Link_type, _M_node)->_M_value_field; + } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + _M_node = _Rb_global_inst::_M_increment(_M_node); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + ++(*this); + return __tmp; + } + + _Self& operator--() { + _M_node = _Rb_global_inst::_M_decrement(_M_node); + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + --(*this); + return __tmp; + } + + bool operator == (const_iterator __rhs) const { + return _M_node == __rhs._M_node; + } + bool operator != (const_iterator __rhs) const { + return _M_node != __rhs._M_node; + } +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_MOVE_TO_STD_NAMESPACE +template +struct __type_traits<_STLP_PRIV _Rb_tree_iterator<_Value, _Traits> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +_STLP_MOVE_TO_STD_NAMESPACE +template +inline _Value* value_type(const _STLP_PRIV _Rb_tree_iterator<_Value, _Traits>&) +{ return (_Value*)0; } +inline bidirectional_iterator_tag iterator_category(const _STLP_PRIV _Rb_tree_base_iterator&) +{ return bidirectional_iterator_tag(); } +inline ptrdiff_t* distance_type(const _STLP_PRIV _Rb_tree_base_iterator&) +{ return (ptrdiff_t*) 0; } +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +// Base class to help EH + +template +class _Rb_tree_base { +public: + typedef _Rb_tree_node_base _Node_base; + typedef _Rb_tree_node<_Tp> _Node; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _Alloc allocator_type; +private: + typedef _Rb_tree_base<_Tp, _Alloc> _Self; + typedef typename _Alloc_traits<_Node, _Alloc>::allocator_type _M_node_allocator_type; + typedef _STLP_alloc_proxy<_Node_base, _Node, _M_node_allocator_type> _AllocProxy; + +public: + allocator_type get_allocator() const { + return _STLP_CONVERT_ALLOCATOR(_M_header, _Tp); + } + +protected: + _Rb_tree_base(const allocator_type& __a) : + _M_header(_STLP_CONVERT_ALLOCATOR(__a, _Node), _Node_base() ) { + _M_empty_initialize(); + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Rb_tree_base(__move_source<_Self> src) : + _M_header(__move_source<_AllocProxy>(src.get()._M_header)) { + _M_rebind(&src.get()._M_header._M_data); + src.get()._M_empty_initialize(); + } +#endif + + void _M_empty_initialize() { + _M_header._M_data._M_color = _S_rb_tree_red; // used to distinguish header from + // __root, in iterator.operator++ + _M_header._M_data._M_parent = 0; + _M_header._M_data._M_left = &_M_header._M_data; + _M_header._M_data._M_right = &_M_header._M_data; + } + + void _M_rebind(_Node_base *__static_node) { + if (_M_header._M_data._M_parent != 0) { + _M_header._M_data._M_parent->_M_parent = &_M_header._M_data; + } + if (_M_header._M_data._M_right == __static_node) { + _M_header._M_data._M_right = &_M_header._M_data; + } + if (_M_header._M_data._M_left == __static_node) { + _M_header._M_data._M_left = &_M_header._M_data; + } + } + + _AllocProxy _M_header; +}; + +#if defined (_STLP_DEBUG) +# define _Rb_tree _STLP_NON_DBG_NAME(Rb_tree) +#endif + +template ) > +class _Rb_tree : public _Rb_tree_base<_Value, _Alloc> { + typedef _Rb_tree_base<_Value, _Alloc> _Base; + typedef _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc> _Self; +protected: + typedef _Rb_tree_node_base * _Base_ptr; + typedef _Rb_tree_node<_Value> _Node; + typedef _Node* _Link_type; + typedef _Rb_tree_Color_type _Color_type; +public: + typedef _Key key_type; + typedef _Value value_type; + typedef typename _Traits::pointer pointer; + typedef const value_type* const_pointer; + typedef typename _Traits::reference reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef bidirectional_iterator_tag _Iterator_category; + typedef typename _Base::allocator_type allocator_type; + +protected: + + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + _Base_ptr _M_create_node(const value_type& __x) { + _Link_type __tmp = this->_M_header.allocate(1); + _STLP_TRY { + _Copy_Construct(&__tmp->_M_value_field, __x); + } + _STLP_UNWIND(this->_M_header.deallocate(__tmp,1)) + _S_left(__tmp) = 0; + _S_right(__tmp) = 0; + return __tmp; + } + + _Base_ptr _M_clone_node(_Base_ptr __x) { + _Base_ptr __tmp = _M_create_node(_S_value(__x)); + _S_color(__tmp) = _S_color(__x); + return __tmp; + } + + size_type _M_node_count; // keeps track of size of tree + _Compare _M_key_compare; + + _Base_ptr _M_root() const + { return this->_M_header._M_data._M_parent; } + _Base_ptr _M_leftmost() const + { return this->_M_header._M_data._M_left; } + _Base_ptr _M_rightmost() const + { return this->_M_header._M_data._M_right; } + + _Base_ptr& _M_root() + { return this->_M_header._M_data._M_parent; } + _Base_ptr& _M_leftmost() + { return this->_M_header._M_data._M_left; } + _Base_ptr& _M_rightmost() + { return this->_M_header._M_data._M_right; } + + static _Base_ptr& _STLP_CALL _S_left(_Base_ptr __x) + { return __x->_M_left; } + static _Base_ptr& _STLP_CALL _S_right(_Base_ptr __x) + { return __x->_M_right; } + static _Base_ptr& _STLP_CALL _S_parent(_Base_ptr __x) + { return __x->_M_parent; } + static value_type& _STLP_CALL _S_value(_Base_ptr __x) + { return __STATIC_CAST(_Link_type, __x)->_M_value_field; } + static const _Key& _STLP_CALL _S_key(_Base_ptr __x) + { return _KeyOfValue()(_S_value(__x));} + static _Color_type& _STLP_CALL _S_color(_Base_ptr __x) + { return (_Color_type&)(__x->_M_color); } + + static _Base_ptr _STLP_CALL _S_minimum(_Base_ptr __x) + { return _Rb_tree_node_base::_S_minimum(__x); } + + static _Base_ptr _STLP_CALL _S_maximum(_Base_ptr __x) + { return _Rb_tree_node_base::_S_maximum(__x); } + +public: + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _Rb_tree_iterator iterator; + typedef _Rb_tree_iterator const_iterator; + _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; + +private: + iterator _M_insert(_Base_ptr __parent, const value_type& __val, _Base_ptr __on_left = 0, _Base_ptr __on_right = 0); + _Base_ptr _M_copy(_Base_ptr __x, _Base_ptr __p); + void _M_erase(_Base_ptr __x); + +public: + // allocation/deallocation + _Rb_tree() + : _Rb_tree_base<_Value, _Alloc>(allocator_type()), _M_node_count(0), _M_key_compare(_Compare()) + {} + + _Rb_tree(const _Compare& __comp) + : _Rb_tree_base<_Value, _Alloc>(allocator_type()), _M_node_count(0), _M_key_compare(__comp) + {} + + _Rb_tree(const _Compare& __comp, const allocator_type& __a) + : _Rb_tree_base<_Value, _Alloc>(__a), _M_node_count(0), _M_key_compare(__comp) + {} + + _Rb_tree(const _Self& __x) + : _Rb_tree_base<_Value, _Alloc>(__x.get_allocator()), + _M_node_count(0), _M_key_compare(__x._M_key_compare) { + if (__x._M_root() != 0) { + _S_color(&this->_M_header._M_data) = _S_rb_tree_red; + _M_root() = _M_copy(__x._M_root(), &this->_M_header._M_data); + _M_leftmost() = _S_minimum(_M_root()); + _M_rightmost() = _S_maximum(_M_root()); + } + _M_node_count = __x._M_node_count; + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Rb_tree(__move_source<_Self> src) + : _Rb_tree_base<_Value, _Alloc>(__move_source<_Base>(src.get())), + _M_node_count(src.get()._M_node_count), + _M_key_compare(_AsMoveSource(src.get()._M_key_compare)) + { src.get()._M_node_count = 0; } +#endif + + ~_Rb_tree() { clear(); } + _Self& operator=(const _Self& __x); + +public: + // accessors: + _Compare key_comp() const { return _M_key_compare; } + + iterator begin() { return iterator(_M_leftmost()); } + const_iterator begin() const { return const_iterator(_M_leftmost()); } + iterator end() { return iterator(&this->_M_header._M_data); } + const_iterator end() const { return const_iterator(__CONST_CAST(_Base_ptr, &this->_M_header._M_data)); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } + bool empty() const { return _M_node_count == 0; } + size_type size() const { return _M_node_count; } + size_type max_size() const { return size_type(-1); } + + void swap(_Self& __t) { + if (__t.empty()) { + if (this->empty()) return; + __t._M_header.swap(this->_M_header); + __t._M_rebind(&this->_M_header._M_data); + this->_M_empty_initialize(); + } + else if (this->empty()) { + __t.swap(*this); + return; + } + else { + this->_M_header.swap(__t._M_header); + this->_M_rebind(&__t._M_header._M_data); + __t._M_rebind(&this->_M_header._M_data); + } + _STLP_STD::swap(_M_node_count, __t._M_node_count); + _STLP_STD::swap(_M_key_compare, __t._M_key_compare); + } + +public: + // insert/erase + pair insert_unique(const value_type& __x); + iterator insert_equal(const value_type& __x); + + iterator insert_unique(iterator __pos, const value_type& __x); + iterator insert_equal(iterator __pos, const value_type& __x); + +#if defined (_STLP_MEMBER_TEMPLATES) + template void insert_equal(_II __first, _II __last) { + for ( ; __first != __last; ++__first) + insert_equal(*__first); + } + template void insert_unique(_II __first, _II __last) { + for ( ; __first != __last; ++__first) + insert_unique(*__first); + } +#else + void insert_unique(const_iterator __first, const_iterator __last) { + for ( ; __first != __last; ++__first) + insert_unique(*__first); + } + void insert_unique(const value_type* __first, const value_type* __last) { + for ( ; __first != __last; ++__first) + insert_unique(*__first); + } + void insert_equal(const_iterator __first, const_iterator __last) { + for ( ; __first != __last; ++__first) + insert_equal(*__first); + } + void insert_equal(const value_type* __first, const value_type* __last) { + for ( ; __first != __last; ++__first) + insert_equal(*__first); + } +#endif + + void erase(iterator __pos) { + _Base_ptr __x = _Rb_global_inst::_Rebalance_for_erase(__pos._M_node, + this->_M_header._M_data._M_parent, + this->_M_header._M_data._M_left, + this->_M_header._M_data._M_right); + _STLP_STD::_Destroy(&_S_value(__x)); + this->_M_header.deallocate(__STATIC_CAST(_Link_type, __x), 1); + --_M_node_count; + } + + size_type erase(const key_type& __x) { + pair __p = equal_range(__x); + size_type __n = _STLP_STD::distance(__p.first, __p.second); + erase(__p.first, __p.second); + return __n; + } + + size_type erase_unique(const key_type& __x) { + iterator __i = find(__x); + if (__i._M_node != &this->_M_header._M_data) { + erase(__i); + return 1; + } + return 0; + } + + void erase(iterator __first, iterator __last) { + if (__first._M_node == this->_M_header._M_data._M_left && // begin() + __last._M_node == &this->_M_header._M_data) // end() + clear(); + else + while (__first != __last) erase(__first++); + } + + void erase(const key_type* __first, const key_type* __last) { + while (__first != __last) erase(*__first++); + } + + void clear() { + if (_M_node_count != 0) { + _M_erase(_M_root()); + _M_leftmost() = &this->_M_header._M_data; + _M_root() = 0; + _M_rightmost() = &this->_M_header._M_data; + _M_node_count = 0; + } + } + +public: + // set operations: + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __k) { return iterator(_M_find(__k)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __k) const { return const_iterator(_M_find(__k)); } +private: + _STLP_TEMPLATE_FOR_CONT_EXT + _Base_ptr _M_find(const _KT& __k) const { + _Base_ptr __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); // Last node which is not less than __k. + _Base_ptr __x = _M_root(); // Current node. + + while (__x != 0) + if (!_M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + + if (__y != &this->_M_header._M_data) { + if (_M_key_compare(__k, _S_key(__y))) { + __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); + } + } + return __y; + } + + _STLP_TEMPLATE_FOR_CONT_EXT + _Base_ptr _M_lower_bound(const _KT& __k) const { + _Base_ptr __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); /* Last node which is not less than __k. */ + _Base_ptr __x = _M_root(); /* Current node. */ + + while (__x != 0) + if (!_M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + + return __y; + } + + _STLP_TEMPLATE_FOR_CONT_EXT + _Base_ptr _M_upper_bound(const _KT& __k) const { + _Base_ptr __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); /* Last node which is greater than __k. */ + _Base_ptr __x = _M_root(); /* Current node. */ + + while (__x != 0) + if (_M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + + return __y; + } + +public: + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { + pair __p = equal_range(__x); + return _STLP_STD::distance(__p.first, __p.second); + } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return iterator(_M_lower_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return const_iterator(_M_lower_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return iterator(_M_upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return const_iterator(_M_upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) + { return pair(lower_bound(__x), upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const + { return pair(lower_bound(__x), upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range_unique(const _KT& __x) { + pair __p; + __p.second = lower_bound(__x); + if (__p.second._M_node != &this->_M_header._M_data && + !_M_key_compare(__x, _S_key(__p.second._M_node))) { + __p.first = __p.second++; + } + else { + __p.first = __p.second; + } + return __p; + } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range_unique(const _KT& __x) const { + pair __p; + __p.second = lower_bound(__x); + if (__p.second._M_node != &this->_M_header._M_data && + !_M_key_compare(__x, _S_key(__p.second._M_node))) { + __p.first = __p.second++; + } + else { + __p.first = __p.second; + } + return __p; + } + +#if defined (_STLP_DEBUG) +public: + // Debugging. + bool __rb_verify() const; +#endif //_STLP_DEBUG +}; + +#if defined (_STLP_DEBUG) +# undef _Rb_tree +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#if defined (_STLP_DEBUG) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER _STLP_PRIV _Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits<_STLP_PRIV _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc> > + : _STLP_PRIV __move_traits_help2<_Compare, _Alloc> {}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_TREE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_typeinfo.h b/sdk/tlibstdcxx/stlport/stl/_typeinfo.h new file mode 100644 index 0000000000..ad9e4d0b63 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_typeinfo.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_TYPEINFO +#define _STLP_INTERNAL_TYPEINFO + +#if !defined (_STLP_NO_TYPEINFO) + +# if defined (_STLP_NO_NEW_NEW_HEADER) +# include +# else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(typeinfo) +# endif +# endif + +// We need to import std::exception into _STLP_STD_NAME +# if defined(_STLP_SGX_CONFIG) && !defined(_STLP_INTERNAL_EXCEPTION) +# include +# endif + +# if (defined(_STLP_MSVC) && (_STLP_MSVC >= 1300)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) +// In .NET, actually includes +# undef _STLP_OLDSTD_typeinfo +# endif + +// if already included, do not import anything +# if defined(_STLP_USE_NAMESPACES) && !defined(_STLP_OLDSTD_typeinfo) && \ + (defined(_STLP_VENDOR_GLOBAL_EXCEPT_STD) || \ + defined(_STLP_USE_OWN_NAMESPACE) || defined (_STLP_DEBUG)) +# if defined(_STLP_MSVC) && (_STLP_MSVC < 1300) && !defined(_STLP_WCE_NET) +class bad_cast : public exception {}; +# endif + +_STLP_BEGIN_NAMESPACE +// VC 6 and eVC 4 have type_info in the global namespace +# if (defined(_STLP_MSVC) && (_STLP_MSVC < 1300)) || defined(_STLP_WCE_NET) +using ::type_info; +# else +using _STLP_VENDOR_EXCEPT_STD::type_info; +# endif + +# if !defined (__DMC__) +using _STLP_VENDOR_EXCEPT_STD::bad_typeid; +# endif + +# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) && !defined (_STLP_WCE_NET) +using ::bad_cast; +# else +using _STLP_VENDOR_EXCEPT_STD::bad_cast; +# endif + +_STLP_END_NAMESPACE + +# endif + +#else + +# ifndef _STLP_INTERNAL_EXCEPTION +# include +# endif + +_STLP_BEGIN_NAMESPACE +# if !defined (__DMC__) +struct bad_cast : exception {}; +# endif +_STLP_END_NAMESPACE +#endif + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/_uninitialized.h b/sdk/tlibstdcxx/stlport/stl/_uninitialized.h new file mode 100644 index 0000000000..5489a94a13 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_uninitialized.h @@ -0,0 +1,443 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +#define _STLP_INTERNAL_UNINITIALIZED_H + +#ifndef _STLP_INTERNAL_CSTRING +# include +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// uninitialized_copy + +template +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, _Distance*) { + _OutputIter __cur = __result; + _STLP_TRY { + for ( ; __first != __last; ++__first, ++__cur) + _Param_Construct(&*__cur, *__first); + return __cur; + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur)) + _STLP_RET_AFTER_THROW(__cur) +} + +template +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, const input_iterator_tag &, _Distance* __d) +{ return __ucopy(__first, __last, __result, __d); } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, const forward_iterator_tag &, _Distance* __d) +{ return __ucopy(__first, __last, __result, __d); } + +template +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, const bidirectional_iterator_tag &, _Distance* __d) +{ return __ucopy(__first, __last, __result, __d); } +#endif + +template +inline _OutputIter __ucopy(_RandomAccessIter __first, _RandomAccessIter __last, + _OutputIter __result, const random_access_iterator_tag &, _Distance*) { + _OutputIter __cur = __result; + _STLP_TRY { + for (_Distance __n = __last - __first; __n > 0; --__n) { + _Param_Construct(&*__cur, *__first); + ++__first; + ++__cur; + } + return __cur; + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur)) + _STLP_RET_AFTER_THROW(__cur) +} + +//Used internaly +template +inline _OutputIter __ucopy(_RandomAccessIter __first, _RandomAccessIter __last, _OutputIter __result) +{ return __ucopy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); } + +inline void* +__ucopy_trivial(const void* __first, const void* __last, void* __result) { + //dums: this version can use memcpy (__copy_trivial can't) + return (__last == __first) ? __result : + ((char*)memcpy(__result, __first, ((const char*)__last - (const char*)__first))) + + ((const char*)__last - (const char*)__first); +} + +template +inline _OutputIter __ucopy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*TrivialUCopy*/) +{ return __ucopy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); } + +template +inline _OutputIter __ucopy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*TrivialUCopy*/) { + // we know they all pointers, so this cast is OK + // return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result)); + return (_OutputIter)__ucopy_trivial(__first, __last, __result); +} + +template +inline _OutputIter __ucopy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*BothPtrType*/) { + return __ucopy_ptrs(__first, __last, __result, + _UseTrivialUCopy(_STLP_VALUE_TYPE(__first, _InputIter), + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer()); +} + +template +inline _OutputIter __ucopy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*BothPtrType*/) { + return __ucopy(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first, _InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline _ForwardIter +uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result) +{ return _STLP_PRIV __ucopy_aux(__first, __last, __result, _BothPtrType< _InputIter, _ForwardIter>::_Answer()); } + +inline char* +uninitialized_copy(const char* __first, const char* __last, char* __result) +{ return (char*)_STLP_PRIV __ucopy_trivial(__first, __last, __result); } + +# if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97 +inline wchar_t* +uninitialized_copy(const wchar_t* __first, const wchar_t* __last, wchar_t* __result) +{ return (wchar_t*)_STLP_PRIV __ucopy_trivial (__first, __last, __result); } +# endif + +// uninitialized_copy_n (not part of the C++ standard) +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_STLP_INLINE_LOOP +pair<_InputIter, _ForwardIter> +__ucopy_n(_InputIter __first, _Size __count, _ForwardIter __result, + const input_iterator_tag &) { + _ForwardIter __cur = __result; + _STLP_TRY { + for ( ; __count > 0 ; --__count, ++__first, ++__cur) + _Param_Construct(&*__cur, *__first); + return pair<_InputIter, _ForwardIter>(__first, __cur); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur)) + _STLP_RET_AFTER_THROW((pair<_InputIter, _ForwardIter>(__first, __cur))) +} + +# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline pair<_InputIter, _ForwardIterator> +__ucopy_n(_InputIter __first, _Size __count, + _ForwardIterator __result, + const forward_iterator_tag &) +{ return __ucopy_n(__first, __count, __result, input_iterator_tag()); } + +template +inline pair<_InputIter, _ForwardIterator> +__ucopy_n(_InputIter __first, _Size __count, + _ForwardIterator __result, + const bidirectional_iterator_tag &) +{ return __ucopy_n(__first, __count, __result, input_iterator_tag()); } +# endif + +template +inline pair<_RandomAccessIter, _ForwardIter> +__ucopy_n(_RandomAccessIter __first, _Size __count, _ForwardIter __result, + const random_access_iterator_tag &) { + _RandomAccessIter __last = __first + __count; + return pair<_RandomAccessIter, _ForwardIter>(__last, uninitialized_copy(__first, __last, __result)); +} + +// This is used internally in , which is extension itself. +template +inline pair<_InputIter, _ForwardIter> +__ucopy_n(_InputIter __first, _Size __count, _ForwardIter __result) +{ return _STLP_PRIV __ucopy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); } + +#if !defined (_STLP_NO_EXTENSIONS) + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline pair<_InputIter, _ForwardIter> +uninitialized_copy_n(_InputIter __first, _Size __count, _ForwardIter __result) +{ return _STLP_PRIV __ucopy_n(__first, __count, __result); } + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#endif + +template +inline void __ufill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x, _Distance*) { + _ForwardIter __cur = __first; + _STLP_TRY { + for ( ; __cur != __last; ++__cur) + _Param_Construct(&*__cur, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur)) +} + +template +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const input_iterator_tag &, _Distance* __d) +{ __ufill(__first, __last, __x, __d); } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const forward_iterator_tag &, _Distance* __d) +{ __ufill(__first, __last, __x, __d); } + +template +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const bidirectional_iterator_tag &, _Distance* __d) +{ __ufill(__first, __last, __x, __d); } +#endif + +template +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const random_access_iterator_tag &, _Distance*) { + _ForwardIter __cur = __first; + _STLP_TRY { + for (_Distance __n = __last - __first; __n > 0; --__n, ++__cur) + _Param_Construct(&*__cur, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur)) +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline void uninitialized_fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x) { + _STLP_PRIV __ufill(__first, __last, __x, + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +// Specialization: for one-byte types we can use memset. +inline void uninitialized_fill(unsigned char* __first, unsigned char* __last, + const unsigned char& __val) { + unsigned char __tmp = __val; + memset(__first, __tmp, __last - __first); +} +#if !defined (_STLP_NO_SIGNED_BUILTINS) +inline void uninitialized_fill(signed char* __first, signed char* __last, + const signed char& __val) { + signed char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} +#endif +inline void uninitialized_fill(char* __first, char* __last, const char& __val) { + char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x) { + _ForwardIter __cur = __first; + _STLP_TRY { + for ( ; __n > 0; --__n, ++__cur) + _Param_Construct(&*__cur, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur)) + return __cur; +} + +template +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const input_iterator_tag &) +{ return __ufill_n(__first, __n, __x); } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const forward_iterator_tag &) +{ return __ufill_n(__first, __n, __x); } + +template +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const bidirectional_iterator_tag &) +{ return __ufill_n(__first, __n, __x); } +#endif + +template +inline _ForwardIter __uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) { + _ForwardIter __last = __first + __n; + __ufill(__first, __last, __x, random_access_iterator_tag(), (ptrdiff_t*)0); + return __last; +} + +template +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const random_access_iterator_tag &) +{ return __uninitialized_fill_n(__first, __n, __x); } + +/* __uninitialized_init is an internal algo to init a range with a value + * built using default constructor. It is only called with pointer as + * iterator. + */ +template +inline _ForwardIter __uinit_aux_aux(_ForwardIter __first, _Size __n, const _Tp& __val, + const __false_type& /*_HasDefaultZero*/) +{ return __uninitialized_fill_n(__first, __n, __val); } + +template +inline _ForwardIter __uinit_aux_aux(_ForwardIter __first, _Size __n, const _Tp& /* __val */, + const __true_type& /*_HasDefaultZero*/) { + memset((unsigned char*)__first, 0, __n * sizeof(_Tp)); + return __first + __n; +} + +template +inline _ForwardIter __uinit_aux(_ForwardIter __first, _Size __n, const _Tp&, + const __true_type& /*_TrivialInit*/) +{ return __first + __n; } + +template +inline _ForwardIter __uinit_aux(_ForwardIter __first, _Size __n, const _Tp& __val, + const __false_type& /*_TrivialInit*/) +{ return __uinit_aux_aux(__first, __n, __val, _HasDefaultZeroValue(__first)._Answer()); } + +template +inline _ForwardIter __uninitialized_init(_ForwardIter __first, _Size __n, const _Tp& __val) +{ return __uinit_aux(__first, __n, __val, _UseTrivialInit(__first)._Answer()); } + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline void +uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) +{ _STLP_PRIV __ufill_n(__first, __n, __x, _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); } + +// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, +// __uninitialized_fill_copy. + +// __uninitialized_copy_copy +// Copies [first1, last1) into [result, result + (last1 - first1)), and +// copies [first2, last2) into +// [result + (last1 - first1), result + (last1 - first1) + (last2 - first2)). + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +inline _ForwardIter +__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _ForwardIter __result) { + _ForwardIter __new_result = uninitialized_copy(__first1, __last1, __result); + _STLP_TRY { + return uninitialized_copy(__first2, __last2, __new_result); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __new_result)) + _STLP_RET_AFTER_THROW(__result) +} + +// __uninitialized_fill_copy +// Fills [result, mid) with x, and copies [first, last) into +// [mid, mid + (last - first)). +template +inline _ForwardIter +__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, const _Tp& __x, + _InputIter __first, _InputIter __last) { + uninitialized_fill(__result, __mid, __x); + _STLP_TRY { + return uninitialized_copy(__first, __last, __mid); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __mid)) + _STLP_RET_AFTER_THROW(__result) +} + +// __uninitialized_copy_fill +// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and +// fills [first2 + (last1 - first1), last2) with x. +template +inline void +__uninitialized_copy_fill(_Iter __first1, _Iter __last1, _Iter __first2, _Iter __last2, + const _Tp& __x) { + _Iter __mid2 = uninitialized_copy(__first1, __last1, __first2); + _STLP_TRY { + uninitialized_fill(__mid2, __last2, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first2, __mid2)) +} + +/* __uninitialized_move: + * This function is used internaly and only with pointers as iterators. + */ +template +inline _ForwardIter +__uninitialized_move(_InputIter __first, _InputIter __last, _ForwardIter __result, + _TrivialUCpy __trivial_ucpy, const __false_type& /*_Movable*/) +{ return __ucopy_ptrs(__first, __last, __result, __trivial_ucpy); } + +template +_STLP_INLINE_LOOP +_ForwardIter +__uninitialized_move(_InputIter __first, _InputIter __last, _ForwardIter __result, + _TrivialUCpy , const __true_type& /*_Movable*/) { + //Move constructor should not throw so we do not need to take care of exceptions here. + for (ptrdiff_t __n = __last - __first ; __n > 0; --__n) { + _Move_Construct(&*__result, *__first); + ++__first; ++__result; + } + return __result; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_UNINITIALIZED_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_unordered_map.h b/sdk/tlibstdcxx/stlport/stl/_unordered_map.h new file mode 100644 index 0000000000..f2b017ddf9 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_unordered_map.h @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_UNORDERED_MAP_H +#define _STLP_INTERNAL_UNORDERED_MAP_H + +#ifndef _STLP_INTERNAL_HASHTABLE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMapTraitsT, traits) + +_STLP_BEGIN_TR1_NAMESPACE + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Key>), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class unordered_map +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ +private: + typedef unordered_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; +public: + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST key_type, data_type> value_type; +private: + //Specific iterator traits creation + typedef _STLP_PRIV _UnorderedMapTraitsT _UnorderedMapTraits; + +public: + typedef hashtable _Ht; + + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + typedef typename _Ht::local_iterator local_iterator; + typedef typename _Ht::const_local_iterator const_local_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_function() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + explicit unordered_map(size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + unordered_map(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + unordered_map(_InputIterator __f, _InputIterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#else + unordered_map(const value_type* __f, const value_type* __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + unordered_map(const_iterator __f, const_iterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + + _Self& operator = (const _Self& __other) + { _M_ht = __other._M_ht; return *this; } + + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + + pair insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } + iterator insert(const_iterator /*__hint*/, const value_type& __obj) + { return _M_ht.insert_unique(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __f, _InputIterator __l) +#else + void insert(const value_type* __f, const value_type* __l) + { _M_ht.insert_unique(__f,__l); } + void insert(const_iterator __f, const_iterator __l) +#endif /*_STLP_MEMBER_TEMPLATES */ + { _M_ht.insert_unique(__f, __l); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + _Tp& operator[](const _KT& __key) { + iterator __it = _M_ht.find(__key); + return (__it == _M_ht.end() ? + _M_ht._M_insert(value_type(__key, _STLP_DEFAULT_CONSTRUCTED(_Tp))).second : + (*__it).second ); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(const_iterator __it) { _M_ht.erase(__it); } + void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } + local_iterator begin(size_type __n) { return _M_ht.begin(__n); } + local_iterator end(size_type __n) { return _M_ht.end(__n); } + const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } + const_local_iterator end(size_type __n) const { return _M_ht.end(__n); } + + float load_factor() const { return _M_ht.load_factor(); } + float max_load_factor() const { return _M_ht.max_load_factor(); } + void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } + void rehash(size_type __hint) { _M_ht.rehash(__hint); } + +#if defined (__DMC__) // disable operator==(pair, pair) + bool operator==(const _Self&) const; +#endif +}; + +_STLP_END_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMultimapTraitsT, traits) + +_STLP_BEGIN_TR1_NAMESPACE + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Key>), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class unordered_multimap +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ +private: + typedef unordered_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; +public: + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST key_type, data_type> value_type; +private: + //Specific iterator traits creation + typedef _STLP_PRIV _UnorderedMultimapTraitsT _UnorderedMultimapTraits; + +public: + typedef hashtable _Ht; + + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + typedef typename _Ht::local_iterator local_iterator; + typedef typename _Ht::const_local_iterator const_local_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_function() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + explicit unordered_multimap(size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + unordered_multimap(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + unordered_multimap(_InputIterator __f, _InputIterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#else + unordered_multimap(const value_type* __f, const value_type* __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + unordered_multimap(const_iterator __f, const_iterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + + _Self& operator = (const _Self& __other) + { _M_ht = __other._M_ht; return *this; } + + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + + iterator insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } + iterator insert(const_iterator /*__hint*/, const value_type& __obj) + { return _M_ht.insert_equal(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __f, _InputIterator __l) +#else + void insert(const value_type* __f, const value_type* __l) + { _M_ht.insert_equal(__f,__l); } + void insert(const_iterator __f, const_iterator __l) +#endif /*_STLP_MEMBER_TEMPLATES */ + { _M_ht.insert_equal(__f, __l); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(const_iterator __it) { _M_ht.erase(__it); } + void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } + local_iterator begin(size_type __n) { return _M_ht.begin(__n); } + local_iterator end(size_type __n) { return _M_ht.end(__n); } + const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } + const_local_iterator end(size_type __n) const { return _M_ht.end(__n); } + + float load_factor() const { return _M_ht.load_factor(); } + float max_load_factor() const { return _M_ht.max_load_factor(); } + void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } + void rehash(size_type __hint) { _M_ht.rehash(__hint); } +}; + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER unordered_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> + +#include + +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER unordered_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> + +#include + +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +_STLP_END_NAMESPACE + +// Specialization of insert_iterator so that it will work for unordered_map +// and unordered_multimap. + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits<_STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > : + _STLP_PRIV __move_traits_help::_Ht> +{}; + +template +struct __move_traits<_STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > : + _STLP_PRIV __move_traits_help::_Ht> +{}; +# endif + +template +class insert_iterator<_STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { +protected: + typedef _STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; + _Container* container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; + +template +class insert_iterator<_STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { +protected: + typedef _STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; + _Container* container; + typename _Container::iterator iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_UNORDERED_MAP_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_unordered_set.h b/sdk/tlibstdcxx/stlport/stl/_unordered_set.h new file mode 100644 index 0000000000..ef5f5fe78b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_unordered_set.h @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_UNORDERED_SET_H +#define _STLP_INTERNAL_UNORDERED_SET_H + +#ifndef _STLP_INTERNAL_HASHTABLE_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedSetTraitsT, Const_traits) + +_STLP_BEGIN_TR1_NAMESPACE + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Value>), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) > +class unordered_set +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> _Self; + //Specific iterator traits creation + typedef _STLP_PRIV _UnorderedSetTraitsT<_Value> _UnorderedSetTraits; +public: + typedef hashtable<_Value, _Value, _HashFcn, + _UnorderedSetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht; +public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + typedef typename _Ht::local_iterator local_iterator; + typedef typename _Ht::const_local_iterator const_local_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_function() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + explicit unordered_set(size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + unordered_set(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + unordered_set(_InputIterator __f, _InputIterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#else + unordered_set(const value_type* __f, const value_type* __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + unordered_set(const_iterator __f, const_iterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + + _Self& operator = (const _Self& __other) + { _M_ht = __other._M_ht; return *this; } + + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + + pair insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } + iterator insert(const_iterator /*__hint*/, const value_type& __obj) + { return _M_ht.insert_unique(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __f, _InputIterator __l) +#else + void insert(const_iterator __f, const_iterator __l) + {_M_ht.insert_unique(__f, __l); } + void insert(const value_type* __f, const value_type* __l) +#endif + { _M_ht.insert_unique(__f,__l); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(const_iterator __it) { _M_ht.erase(__it); } + void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } + local_iterator begin(size_type __n) { return _M_ht.begin(__n); } + local_iterator end(size_type __n) { return _M_ht.end(__n); } + const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } + const_local_iterator end(size_type __n) const { return _M_ht.end(__n); } + + float load_factor() const { return _M_ht.load_factor(); } + float max_load_factor() const { return _M_ht.max_load_factor(); } + void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } + void rehash(size_type __hint) { _M_ht.rehash(__hint); } +}; + +_STLP_END_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMultisetTraitsT, Const_traits) + +_STLP_BEGIN_TR1_NAMESPACE + +template ), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Value>), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) > +class unordered_multiset +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ + typedef unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Self; + //Specific iterator traits creation + typedef _STLP_PRIV _UnorderedMultisetTraitsT<_Value> _UnorderedMultisetTraits; +public: + typedef hashtable<_Value, _Value, _HashFcn, + _UnorderedMultisetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht; + + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + typedef typename _Ht::local_iterator local_iterator; + typedef typename _Ht::const_local_iterator const_local_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_function() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + explicit unordered_multiset(size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + unordered_multiset(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + unordered_multiset(_InputIterator __f, _InputIterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#else + unordered_multiset(const value_type* __f, const value_type* __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + unordered_multiset(const_iterator __f, const_iterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + + _Self& operator = (const _Self& __other) + { _M_ht = __other._M_ht; return *this; } + + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& hs) { _M_ht.swap(hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + + iterator insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } + iterator insert(const_iterator /*__hint*/, const value_type& __obj) + { return _M_ht.insert_equal(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __f, _InputIterator __l) +#else + void insert(const value_type* __f, const value_type* __l) + { _M_ht.insert_equal(__f,__l); } + void insert(const_iterator __f, const_iterator __l) +#endif /*_STLP_MEMBER_TEMPLATES */ + { _M_ht.insert_equal(__f, __l); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(const_iterator __it) { _M_ht.erase(__it); } + void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } + local_iterator begin(size_type __n) { return _M_ht.begin(__n); } + local_iterator end(size_type __n) { return _M_ht.end(__n); } + const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } + const_local_iterator end(size_type __n) const { return _M_ht.end(__n); } + + float load_factor() const { return _M_ht.load_factor(); } + float max_load_factor() const { return _M_ht.max_load_factor(); } + void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } + void rehash(size_type __hint) { _M_ht.rehash(__hint); } +}; + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER unordered_set<_Value,_HashFcn,_EqualKey,_Alloc> + +#include + +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER unordered_multiset<_Value,_HashFcn,_EqualKey,_Alloc> +#include + +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +_STLP_END_NAMESPACE + +// Specialization of insert_iterator so that it will work for unordered_set +// and unordered_multiset. + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits<_STLP_TR1 unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> > : + _STLP_PRIV __move_traits_aux::_Ht> +{}; + +template +struct __move_traits<_STLP_TR1 unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > : + _STLP_PRIV __move_traits_aux::_Ht> +{}; +# endif + +template +class insert_iterator<_STLP_TR1 unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> > { +protected: + typedef _STLP_TR1 unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container; + _Container* container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; + +template +class insert_iterator<_STLP_TR1 unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > { +protected: + typedef _STLP_TR1 unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container; + _Container* container; + typename _Container::iterator iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_UNORDERED_SET_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/stl/_valarray.c b/sdk/tlibstdcxx/stlport/stl/_valarray.c new file mode 100644 index 0000000000..85ee2f8cbb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_valarray.c @@ -0,0 +1,194 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_VALARRAY_C +#define _STLP_VALARRAY_C + +#ifndef _STLP_VALARRAY_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template +_Valarray_bool valarray<_Tp>:: operator!() const { + _Valarray_bool __tmp(this->size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < this->size(); ++__i) + __tmp[__i] = !(*this)[__i]; + return __tmp; +} + +// Behavior is undefined if __x and *this have different sizes +template +valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<_Tp>& __x) { + _STLP_ASSERT(__x._M_slice.size() == this->size()) + size_t __index = __x._M_slice.start(); + for (size_t __i = 0; + __i < __x._M_slice.size(); + ++__i, __index += __x._M_slice.stride()) + (*this)[__i] = __x._M_array[__index]; + return *this; +} + +template +valarray<_Tp> valarray<_Tp>::operator[](slice __slice) const { + valarray<_Tp> __tmp(__slice.size(), _NoInit()); + size_t __index = __slice.start(); + for (size_t __i = 0; + __i < __slice.size(); + ++__i, __index += __slice.stride()) + __tmp[__i] = (*this)[__index]; + return __tmp; +} + +template +bool _Gslice_Iter_tmpl<_Size>::_M_incr() { + size_t __dim = _M_indices.size() - 1; + ++_M_step; + for (;;) { + _M_1d_idx += _M_gslice._M_strides[__dim]; + if (++_M_indices[__dim] != _M_gslice._M_lengths[__dim]) + return true; + else if (__dim != 0) { + _M_1d_idx -= _M_gslice._M_strides[__dim] * _M_gslice._M_lengths[__dim]; + _M_indices[__dim] = 0; + --__dim; + } + else + return false; + } +} + +// Behavior is undefined if __x and *this have different sizes, or if +// __x was constructed from a degenerate gslice. +template +valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<_Tp>& __x) { + if (this->size() != 0) { + _Gslice_Iter __i(__x._M_gslice); + do + (*this)[__i._M_step] = __x._M_array[__i._M_1d_idx]; + while(__i._M_incr()); + } + return *this; +} + +template +valarray<_Tp> valarray<_Tp>::operator[](const gslice& __slice) const { + valarray<_Tp> __tmp(__slice._M_size(), _NoInit()); + if (__tmp.size() != 0) { + _Gslice_Iter __i(__slice); + do __tmp[__i._M_step] = (*this)[__i._M_1d_idx]; while(__i._M_incr()); + } + return __tmp; +} + +template +valarray<_Tp> valarray<_Tp>::operator[](const _Valarray_bool& __mask) const { + size_t _p_size = 0; + { + for (size_t __i = 0; __i < __mask.size(); ++__i) + if (__mask[__i]) ++_p_size; + } + + valarray<_Tp> __tmp(_p_size, _NoInit()); + size_t __idx = 0; + { + for (size_t __i = 0; __i < __mask.size(); ++__i) + if (__mask[__i]) __tmp[__idx++] = (*this)[__i]; + } + + return __tmp; +} + +template +valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<_Tp>& __x) { + _STLP_ASSERT(__x._M_addr.size() == this->size()) + for (size_t __i = 0; __i < __x._M_addr.size(); ++__i) + (*this)[__i] = __x._M_array[__x._M_addr[__i]]; + return *this; +} + +template +valarray<_Tp> +valarray<_Tp>::operator[](const _Valarray_size_t& __addr) const { + valarray<_Tp> __tmp(__addr.size(), _NoInit()); + for (size_t __i = 0; __i < __addr.size(); ++__i) + __tmp[__i] = (*this)[__addr[__i]]; + return __tmp; +} + +//---------------------------------------------------------------------- +// Other valarray noninline member functions + +// Shift and cshift + +template +valarray<_Tp> valarray<_Tp>::shift(int __n) const { + valarray<_Tp> __tmp(this->size()); + + if (__n >= 0) { + if (__n < this->size()) + copy(this->_M_first + __n, this->_M_first + this->size(), + __tmp._M_first); + } + else { + if (-__n < this->size()) + copy(this->_M_first, this->_M_first + this->size() + __n, + __tmp._M_first - __n); + } + return __tmp; +} + +template +valarray<_Tp> valarray<_Tp>::cshift(int __m) const { + valarray<_Tp> __tmp(this->size()); + + if (this->size() == 0) + return __tmp; + + // Reduce __m to an equivalent number in the range [0, size()). We + // have to be careful with negative numbers, since the sign of a % b + // is unspecified when a < 0. + long __n = __m; + if (this->size() < (numeric_limits::max)()) + __n %= long(this->size()); + if (__n < 0) + __n += this->size(); + + copy(this->_M_first, this->_M_first + __n, + __tmp._M_first + (this->size() - __n)); + copy(this->_M_first + __n, this->_M_first + this->size(), + __tmp._M_first); + + return __tmp; +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_VALARRAY_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_valarray.h b/sdk/tlibstdcxx/stlport/stl/_valarray.h new file mode 100644 index 0000000000..cd9641ab4a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_valarray.h @@ -0,0 +1,1684 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_VALARRAY_H +#define _STLP_VALARRAY_H + +#ifndef _STLP_INTERNAL_CMATH +# include +#endif + +#ifndef _STLP_INTERNAL_NEW +# include +#endif + +#ifndef _STLP_INTERNAL_ALGO_H +# include +#endif + +#ifndef _STLP_INTERNAL_NUMERIC_H +# include +#endif + +#ifndef _STLP_INTERNAL_LIMITS +# include +#endif + +_STLP_BEGIN_NAMESPACE + +class slice; +class gslice; + +template class valarray; +typedef valarray _Valarray_bool; +typedef valarray _Valarray_size_t; + +template class slice_array; +template class gslice_array; +template class mask_array; +template class indirect_array; + +//---------------------------------------------------------------------- +// class valarray + +// Base class to handle memory allocation and deallocation. We can't just +// use vector<>, because vector would be unsuitable as an internal +// representation for valarray. + +template +struct _Valarray_base { + _Tp* _M_first; + size_t _M_size; + + _Valarray_base() : _M_first(0), _M_size(0) {} + _Valarray_base(size_t __n) : _M_first(0), _M_size(0) { _M_allocate(__n); } + ~_Valarray_base() { _M_deallocate(); } + + void _M_allocate(size_t __n) { + if (__n != 0) { + _M_first = __STATIC_CAST(_Tp*, __stl_new(__n * sizeof(_Tp))); + _M_size = __n; + } + else { + _M_first = 0; + _M_size = 0; + } + } + + void _M_deallocate() { + __stl_delete(_M_first); + _M_first = 0; + _M_size = 0; + } +}; + +template +class valarray : private _Valarray_base<_Tp> +{ + friend class gslice; + +public: + typedef _Tp value_type; + + // Basic constructors + valarray() : _Valarray_base<_Tp>() {} + explicit valarray(size_t __n) : _Valarray_base<_Tp>(__n) + { uninitialized_fill_n(this->_M_first, this->_M_size, _STLP_DEFAULT_CONSTRUCTED(value_type)); } + valarray(const value_type& __x, size_t __n) : _Valarray_base<_Tp>(__n) + { uninitialized_fill_n(this->_M_first, this->_M_size, __x); } + valarray(const value_type* __p, size_t __n) : _Valarray_base<_Tp>(__n) + { uninitialized_copy(__p, __p + __n, this->_M_first); } + valarray(const valarray<_Tp>& __x) : _Valarray_base<_Tp>(__x._M_size) { + uninitialized_copy(__x._M_first, __x._M_first + __x._M_size, + this->_M_first); + } + + // Constructors from auxiliary array types + valarray(const slice_array<_Tp>&); + valarray(const gslice_array<_Tp>&); + valarray(const mask_array<_Tp>&); + valarray(const indirect_array<_Tp>&); + + // Destructor + ~valarray() { _STLP_STD::_Destroy_Range(this->_M_first, this->_M_first + this->_M_size); } + + // Extension: constructor that doesn't initialize valarray elements to a + // specific value. This is faster for types such as int and double. +private: + void _M_initialize(const __true_type&) {} + void _M_initialize(const __false_type&) + { uninitialized_fill_n(this->_M_first, this->_M_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } + +public: + struct _NoInit {}; + valarray(size_t __n, _NoInit) : _Valarray_base<_Tp>(__n) { + typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Is_Trivial; + _M_initialize(_Is_Trivial()); + } + +public: // Assignment + // Basic assignment. Note that 'x = y' is undefined if x.size() != y.size() + valarray<_Tp>& operator=(const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + if (this != &__x) + copy(__x._M_first, __x._M_first + __x._M_size, this->_M_first); + return *this; + } + + // Scalar assignment + valarray<_Tp>& operator=(const value_type& __x) { + fill_n(this->_M_first, this->_M_size, __x); + return *this; + } + + // Assignment of auxiliary array types + valarray<_Tp>& operator=(const slice_array<_Tp>&); + valarray<_Tp>& operator=(const gslice_array<_Tp>&); + valarray<_Tp>& operator=(const mask_array<_Tp>&); + valarray<_Tp>& operator=(const indirect_array<_Tp>&); + +public: // Element access + value_type operator[](size_t __n) const { + _STLP_ASSERT(__n < this->size()) + return this->_M_first[__n]; + } + value_type& operator[](size_t __n) { + _STLP_ASSERT(__n < this->size()) + return this->_M_first[__n]; + } + size_t size() const { return this->_M_size; } + +public: // Subsetting operations with auxiliary type + valarray<_Tp> operator[](slice) const; + slice_array<_Tp> operator[](slice); + valarray<_Tp> operator[](const gslice&) const; + gslice_array<_Tp> operator[](const gslice&); + valarray<_Tp> operator[](const _Valarray_bool&) const; + mask_array<_Tp> operator[](const _Valarray_bool&); + valarray<_Tp> operator[](const _Valarray_size_t&) const; + indirect_array<_Tp> operator[](const _Valarray_size_t&); + +public: // Unary operators. + valarray<_Tp> operator+() const { return *this; } + + valarray<_Tp> operator-() const { + valarray<_Tp> __tmp(this->size(), _NoInit()); + for (size_t __i = 0; __i < this->size(); ++__i) + __tmp[__i] = -(*this)[__i]; + return __tmp; + } + + valarray<_Tp> operator~() const { + valarray<_Tp> __tmp(this->size(), _NoInit()); + for (size_t __i = 0; __i < this->size(); ++__i) + __tmp[__i] = ~(*this)[__i]; + return __tmp; + } + + _Valarray_bool operator!() const; + +public: // Scalar computed assignment. + valarray<_Tp>& operator*= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] *= __x; + return *this; + } + + valarray<_Tp>& operator/= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] /= __x; + return *this; + } + + valarray<_Tp>& operator%= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] %= __x; + return *this; + } + + valarray<_Tp>& operator+= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] += __x; + return *this; + } + + valarray<_Tp>& operator-= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] -= __x; + return *this; + } + + valarray<_Tp>& operator^= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] ^= __x; + return *this; + } + + valarray<_Tp>& operator&= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] &= __x; + return *this; + } + + valarray<_Tp>& operator|= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] |= __x; + return *this; + } + + valarray<_Tp>& operator<<= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] <<= __x; + return *this; + } + + valarray<_Tp>& operator>>= (const value_type& __x) { + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] >>= __x; + return *this; + } + +public: // Array computed assignment. + valarray<_Tp>& operator*= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] *= __x[__i]; + return *this; + } + + valarray<_Tp>& operator/= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] /= __x[__i]; + return *this; + } + + valarray<_Tp>& operator%= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] %= __x[__i]; + return *this; + } + + valarray<_Tp>& operator+= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] += __x[__i]; + return *this; + } + + valarray<_Tp>& operator-= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] -= __x[__i]; + return *this; + } + + valarray<_Tp>& operator^= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] ^= __x[__i]; + return *this; + } + + valarray<_Tp>& operator&= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] &= __x[__i]; + return *this; + } + + valarray<_Tp>& operator|= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] |= __x[__i]; + return *this; + } + + valarray<_Tp>& operator<<= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] <<= __x[__i]; + return *this; + } + + valarray<_Tp>& operator>>= (const valarray<_Tp>& __x) { + _STLP_ASSERT(__x.size() == this->size()) + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i] >>= __x[__i]; + return *this; + } + +public: // Other member functions. + + // The result is undefined for zero-length arrays + value_type sum() const { + _STLP_ASSERT(this->size() != 0) + return accumulate(this->_M_first + 1, this->_M_first + this->_M_size, + (*this)[0]); + } + + // The result is undefined for zero-length arrays + value_type (min) () const { + _STLP_ASSERT(this->size() != 0) + return *min_element(this->_M_first + 0, this->_M_first + this->_M_size); + } + + value_type (max) () const { + _STLP_ASSERT(this->size() != 0) + return *max_element(this->_M_first + 0, this->_M_first + this->_M_size); + } + + valarray<_Tp> shift(int __n) const; + valarray<_Tp> cshift(int __n) const; + + valarray<_Tp> apply(value_type __f(value_type)) const { + valarray<_Tp> __tmp(this->size()); + transform(this->_M_first + 0, this->_M_first + this->_M_size, __tmp._M_first, + __f); + return __tmp; + } + valarray<_Tp> apply(value_type __f(const value_type&)) const { + valarray<_Tp> __tmp(this->size()); + transform(this->_M_first + 0, this->_M_first + this->_M_size, __tmp._M_first, + __f); + return __tmp; + } + + void resize(size_t __n, value_type __x = value_type()) { + _STLP_STD::_Destroy_Range(this->_M_first, this->_M_first + this->_M_size); + _Valarray_base<_Tp>::_M_deallocate(); + _Valarray_base<_Tp>::_M_allocate(__n); + uninitialized_fill_n(this->_M_first, this->_M_size, __x); + } +}; + +//---------------------------------------------------------------------- +// valarray non-member functions. + +// Binary arithmetic operations between two arrays. Behavior is +// undefined if the two arrays do not have the same length. + +template +inline valarray<_Tp> _STLP_CALL operator*(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] * __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator/(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] / __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator%(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] % __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator+(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] + __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator-(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] - __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator^(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] ^ __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator&(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] & __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator|(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] | __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator<<(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] << __y[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator>>(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] >> __y[__i]; + return __tmp; +} + +// Binary arithmetic operations between an array and a scalar. + +template +inline valarray<_Tp> _STLP_CALL operator*(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] * __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator*(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c * __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator/(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] / __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator/(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c / __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator%(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] % __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator%(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c % __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator+(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] + __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator+(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c + __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator-(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] - __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator-(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c - __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator^(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] ^ __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator^(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c ^ __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator&(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] & __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator&(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c & __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator|(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] | __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator|(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c | __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator<<(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] << __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator<<(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c << __x[__i]; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator>>(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] >> __c; + return __tmp; +} + +template +inline valarray<_Tp> _STLP_CALL operator>>(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c >> __x[__i]; + return __tmp; +} + +// Binary logical operations between two arrays. Behavior is undefined +// if the two arrays have different lengths. Note that operator== does +// not do what you might at first expect. + +template +inline _Valarray_bool _STLP_CALL operator==(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] == __y[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator<(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] < __y[__i]; + return __tmp; +} + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE + +template +inline _Valarray_bool _STLP_CALL operator!=(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] != __y[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator>(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] > __y[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator<=(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] <= __y[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator>=(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] >= __y[__i]; + return __tmp; +} + +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ +// fbp : swap ? + +template +inline _Valarray_bool _STLP_CALL operator&&(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] && __y[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator||(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + _STLP_ASSERT(__x.size() == __y.size()) + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] || __y[__i]; + return __tmp; +} + +// Logical operations between an array and a scalar. + +template +inline _Valarray_bool _STLP_CALL operator==(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] == __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator==(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c == __x[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator!=(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] != __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator!=(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c != __x[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator<(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] < __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator<(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c < __x[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator>(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] > __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator>(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c > __x[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator<=(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] <= __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator<=(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c <= __x[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator>=(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] >= __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator>=(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c >= __x[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator&&(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] && __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator&&(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c && __x[__i]; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator||(const valarray<_Tp>& __x, const _Tp& __c) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __x[__i] || __c; + return __tmp; +} + +template +inline _Valarray_bool _STLP_CALL operator||(const _Tp& __c, const valarray<_Tp>& __x) { + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = __c || __x[__i]; + return __tmp; +} + +// valarray "transcendentals" (the list includes abs and sqrt, which, +// of course, are not transcendental). + +template +inline valarray<_Tp> abs(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::abs(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> acos(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::acos(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> asin(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::asin(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> atan(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::atan(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> atan2(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::atan2(__x[__i], __y[__i]); + return __tmp; +} + +template +inline valarray<_Tp> atan2(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::atan2(__x[__i], __c); + return __tmp; +} + +template +inline valarray<_Tp> atan2(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::atan2(__c, __x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> cos(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::cos(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> cosh(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::cosh(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> exp(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::exp(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> log(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::log(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> log10(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::log10(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> pow(const valarray<_Tp>& __x, + const valarray<_Tp>& __y) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::pow(__x[__i], __y[__i]); + return __tmp; +} + +template +inline valarray<_Tp> pow(const valarray<_Tp>& __x, const _Tp& __c) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::pow(__x[__i], __c); + return __tmp; +} + +template +inline valarray<_Tp> pow(const _Tp& __c, const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::pow(__c, __x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> sin(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::sin(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> sinh(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::sinh(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> sqrt(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::sqrt(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> tan(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::tan(__x[__i]); + return __tmp; +} + +template +inline valarray<_Tp> tanh(const valarray<_Tp>& __x) { + typedef typename valarray<_Tp>::_NoInit _NoInit; + valarray<_Tp> __tmp(__x.size(), _NoInit()); + for (size_t __i = 0; __i < __x.size(); ++__i) + __tmp[__i] = ::tanh(__x[__i]); + return __tmp; +} + +//---------------------------------------------------------------------- +// slice and slice_array + +class slice { +public: + slice() : _M_start(0), _M_length(0), _M_stride(0) {} + slice(size_t __start, size_t __length, size_t __stride) + : _M_start(__start), _M_length(__length), _M_stride(__stride) + {} + __TRIVIAL_DESTRUCTOR(slice) + + size_t start() const { return _M_start; } + size_t size() const { return _M_length; } + size_t stride() const { return _M_stride; } + +private: + size_t _M_start; + size_t _M_length; + size_t _M_stride; +}; + +template +class slice_array { + friend class valarray<_Tp>; +public: + typedef _Tp value_type; + + void operator=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] = __x[__i]; + } + + void operator*=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] *= __x[__i]; + } + + void operator/=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] /= __x[__i]; + } + + void operator%=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] %= __x[__i]; + } + + void operator+=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] += __x[__i]; + } + + void operator-=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] -= __x[__i]; + } + + void operator^=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] ^= __x[__i]; + } + + void operator&=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] &= __x[__i]; + } + + void operator|=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] |= __x[__i]; + } + + void operator<<=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] <<= __x[__i]; + } + + void operator>>=(const valarray& __x) const { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] >>= __x[__i]; + } + + void operator=(const value_type& __c) /*const could be const but standard says NO (26.3.5.4-1)*/ { + size_t __index = _M_slice.start(); + for (size_t __i = 0; + __i < _M_slice.size(); + ++__i, __index += _M_slice.stride()) + _M_array[__index] = __c; + } + + // C++ Standard defect 253, copy constructor must be public. + slice_array(const slice_array &__x) + : _M_slice(__x._M_slice), _M_array(__x._M_array) + {} + + ~slice_array() {} + +private: + slice_array(const slice& __slice, valarray<_Tp> &__array) + : _M_slice(__slice), _M_array(__array) + {} + + slice _M_slice; + valarray<_Tp>& _M_array; + +private: + // Disable default constructor and assignment + slice_array(); + slice_array& operator=(const slice_array&); +}; + +// valarray member functions dealing with slice and slice_array + +template +inline valarray<_Tp>::valarray(const slice_array<_Tp>& __x) + : _Valarray_base<_Tp>(__x._M_slice.size()) { + typedef typename __type_traits<_Tp>::has_trivial_default_constructor + _Is_Trivial; + _M_initialize(_Is_Trivial()); + *this = __x; +} + + +template +inline slice_array<_Tp> valarray<_Tp>::operator[](slice __slice) +{ return slice_array<_Tp>(__slice, *this); } + +//---------------------------------------------------------------------- +// gslice and gslice_array + +template +struct _Gslice_Iter_tmpl; + +class gslice { + friend struct _Gslice_Iter_tmpl; +public: + gslice() : _M_start(0), _M_lengths(), _M_strides() {} + gslice(size_t __start, + const _Valarray_size_t& __lengths, const _Valarray_size_t& __strides) + : _M_start(__start), _M_lengths(__lengths), _M_strides(__strides) + {} + __TRIVIAL_DESTRUCTOR(gslice) + + size_t start() const { return _M_start; } + _Valarray_size_t size() const { return _M_lengths; } + _Valarray_size_t stride() const { return _M_strides; } + + // Extension: check for an empty gslice. + bool _M_empty() const { return _M_lengths.size() == 0; } + + // Extension: number of indices this gslice represents. (For a degenerate + // gslice, they're not necessarily all distinct.) + size_t _M_size() const { + return !this->_M_empty() + ? accumulate(_M_lengths._M_first + 1, + _M_lengths._M_first + _M_lengths._M_size, + _M_lengths[0], + multiplies()) + : 0; + } + +# ifndef __HP_aCC +private: +# endif + + size_t _M_start; + _Valarray_size_t _M_lengths; + _Valarray_size_t _M_strides; +}; + +// This is not an STL iterator. It is constructed from a gslice, and it +// steps through the gslice indices in sequence. See 23.3.6 of the C++ +// standard, paragraphs 2-3, for an explanation of the sequence. At +// each step we get two things: the ordinal (i.e. number of steps taken), +// and the one-dimensional index. + +template +struct _Gslice_Iter_tmpl { + _Gslice_Iter_tmpl(const gslice& __gslice) + : _M_step(0), _M_1d_idx(__gslice.start()), + _M_indices(size_t(0), __gslice._M_lengths.size()), + _M_gslice(__gslice) + {} + + bool _M_done() const { return _M_indices[0] == _M_gslice._M_lengths[0]; } + + bool _M_incr(); + + _Size _M_step; + _Size _M_1d_idx; + + valarray<_Size> _M_indices; + const gslice& _M_gslice; +}; + +typedef _Gslice_Iter_tmpl _Gslice_Iter; + +template +class gslice_array { + friend class valarray<_Tp>; +public: + typedef _Tp value_type; + + void operator= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] = __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator*= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] *= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator/= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] /= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator%= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] %= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator+= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] += __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator-= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] -= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator^= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] ^= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator&= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] &= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator|= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] |= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator<<= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] <<= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator>>= (const valarray& __x) const { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] >>= __x[__i._M_step]; while(__i._M_incr()); + } + } + + void operator= (const value_type& __c) /*const could be const but standard says NO (26.3.7.4-1)*/ { + if (!_M_gslice._M_empty()) { + _Gslice_Iter __i(_M_gslice); + do _M_array[__i._M_1d_idx] = __c; while(__i._M_incr()); + } + } + + // C++ Standard defect 253, copy constructor must be public. + gslice_array(const gslice_array& __x) + : _M_gslice(__x._M_gslice), _M_array(__x._M_array) + {} + + ~gslice_array() {} + +private: + gslice_array(const gslice &__gslice, valarray<_Tp> &__array) + : _M_gslice(__gslice), _M_array(__array) + {} + + gslice _M_gslice; + valarray& _M_array; + +private: + // Disable default constructor and assignment + gslice_array(); + void operator=(const gslice_array<_Tp>&); +}; + +// valarray member functions dealing with gslice and gslice_array. Note +// that it is illegal (behavior is undefined) to construct a gslice_array +// from a degenerate gslice. + +template +inline valarray<_Tp>::valarray(const gslice_array<_Tp>& __x) + : _Valarray_base<_Tp>(__x._M_gslice._M_size()) { + typedef typename __type_traits<_Tp>::has_trivial_default_constructor + _Is_Trivial; + _M_initialize(_Is_Trivial()); + *this = __x; +} + +template +inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __slice) +{ return gslice_array<_Tp>(__slice, *this); } + + +//---------------------------------------------------------------------- +// mask_array + +template +class mask_array { + friend class valarray<_Tp>; +public: + typedef _Tp value_type; + + void operator=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] = __x[__idx++]; + } + + void operator*=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] *= __x[__idx++]; + } + + void operator/=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] /= __x[__idx++]; + } + + void operator%=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] %= __x[__idx++]; + } + + void operator+=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] += __x[__idx++]; + } + + void operator-=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] -= __x[__idx++]; + } + + void operator^=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] ^= __x[__idx++]; + } + + void operator&=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] &= __x[__idx++]; + } + + void operator|=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] |= __x[__idx++]; + } + + void operator<<=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] <<= __x[__idx++]; + } + + void operator>>=(const valarray& __x) const { + size_t __idx = 0; + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] >>= __x[__idx++]; + } + + void operator=(const value_type& __c) const { + for (size_t __i = 0; __i < _M_array.size(); ++__i) + if (_M_mask[__i]) _M_array[__i] = __c; + } + + // Extension: number of true values in the mask + size_t _M_num_true() const { + size_t __result = 0; + for (size_t __i = 0; __i < _M_mask.size(); ++__i) + if (_M_mask[__i]) ++__result; + return __result; + } + + // C++ Standard defect 253, copy constructor must be public. + mask_array(const mask_array& __x) + : _M_mask(__x._M_mask), _M_array(__x._M_array) + {} + + ~mask_array() {} + +private: + mask_array(const _Valarray_bool& __mask, valarray<_Tp>& __array) + : _M_mask(__mask), _M_array(__array) + {} + _Valarray_bool _M_mask; + valarray<_Tp>& _M_array; + +private: + // Disable default constructor and assignment + mask_array(); + void operator=(const mask_array<_Tp>&); +}; + +// valarray member functions dealing with mask_array + +template +inline valarray<_Tp>::valarray(const mask_array<_Tp>& __x) + : _Valarray_base<_Tp>(__x._M_num_true()) { + typedef typename __type_traits<_Tp>::has_trivial_default_constructor + _Is_Trivial; + _M_initialize(_Is_Trivial()); + *this = __x; +} + +// Behavior is undefined if __x._M_num_true() != this->size() +template +inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<_Tp>& __x) { + size_t __idx = 0; + for (size_t __i = 0; __i < __x._M_array.size(); ++__i) + if (__x._M_mask[__i]) (*this)[__idx++] = __x._M_array[__i]; + return *this; +} + +template +inline mask_array<_Tp> valarray<_Tp>::operator[](const _Valarray_bool& __mask) { + _STLP_ASSERT(__mask.size() == this->size()) + return mask_array<_Tp>(__mask, *this); +} + +//---------------------------------------------------------------------- +// indirect_array + +template +class indirect_array { + friend class valarray<_Tp>; +public: + typedef _Tp value_type; + + void operator=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] = __x[__i]; + } + + void operator*=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] *= __x[__i]; + } + + void operator/=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] /= __x[__i]; + } + + void operator%=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] %= __x[__i]; + } + + void operator+=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] += __x[__i]; + } + + void operator-=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] -= __x[__i]; + } + + void operator^=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] ^= __x[__i]; + } + + void operator&=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] &= __x[__i]; + } + + void operator|=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] |= __x[__i]; + } + + void operator<<=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] <<= __x[__i]; + } + + void operator>>=(const valarray& __x) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] >>= __x[__i]; + } + + void operator=(const value_type& __c) const { + for (size_t __i = 0; __i < _M_addr.size(); ++__i) + _M_array[_M_addr[__i]] = __c; + } + + // C++ Standard defect 253, copy constructor must be public. + indirect_array(const indirect_array& __x) + : _M_addr(__x._M_addr), _M_array(__x._M_array) + {} + + ~indirect_array() {} + +private: + indirect_array(const _Valarray_size_t& __addr, valarray<_Tp>& __array) + : _M_addr(__addr), _M_array(__array) + {} + + _Valarray_size_t _M_addr; + valarray<_Tp>& _M_array; + +private: + // Disable default constructor and assignment + indirect_array(); + void operator=(const indirect_array<_Tp>&); +}; + +// valarray member functions dealing with indirect_array + +template +inline valarray<_Tp>::valarray(const indirect_array<_Tp>& __x) + : _Valarray_base<_Tp>(__x._M_addr.size()) { + typedef typename __type_traits<_Tp>::has_trivial_default_constructor + _Is_Trivial; + _M_initialize(_Is_Trivial()); + *this = __x; +} + + +template +inline indirect_array<_Tp> +valarray<_Tp>::operator[](const _Valarray_size_t& __addr) +{ return indirect_array<_Tp>(__addr, *this); } + +_STLP_END_NAMESPACE + +# if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +# endif + +#endif /* _STLP_VALARRAY */ + + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_vector.c b/sdk/tlibstdcxx/stlport/stl/_vector.c new file mode 100644 index 0000000000..705f786006 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_vector.c @@ -0,0 +1,242 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_VECTOR_C +#define _STLP_VECTOR_C + +#if !defined (_STLP_INTERNAL_VECTOR_H) +# include +#endif + +#include + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void _Vector_base<_Tp,_Alloc>::_M_throw_length_error() const +{ __stl_throw_length_error("vector"); } + +template +void _Vector_base<_Tp, _Alloc>::_M_throw_out_of_range() const +{ __stl_throw_out_of_range("vector"); } + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define vector _STLP_PTR_IMPL_NAME(vector) +#elif defined (_STLP_DEBUG) +# define vector _STLP_NON_DBG_NAME(vector) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define __iterator__ _Tp* +#else +# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE vector<_Tp, _Alloc>::iterator +#endif + +template +void vector<_Tp, _Alloc>::reserve(size_type __n) { + if (capacity() < __n) { + if (max_size() < __n) { + this->_M_throw_length_error(); + } + + const size_type __old_size = size(); + pointer __tmp; + if (this->_M_start) { + __tmp = _M_allocate_and_copy(__n, this->_M_start, this->_M_finish); + _M_clear(); + } else { + __tmp = this->_M_end_of_storage.allocate(__n, __n); + } + _M_set(__tmp, __tmp + __old_size, __tmp + __n); + } +} + +template +void vector<_Tp, _Alloc>::_M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __false_type& /*DO NOT USE!!*/, + size_type __fill_len, bool __atend ) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + size_type __len = _M_compute_next_size(__fill_len); + pointer __new_start = this->_M_end_of_storage.allocate(__len, __len); + pointer __new_finish = __new_start; + _STLP_TRY { + __new_finish = _STLP_PRIV __uninitialized_move(this->_M_start, __pos, __new_start, _TrivialUCopy(), _Movable()); + // handle insertion + if (__fill_len == 1) { + _Copy_Construct(__new_finish, __x); + ++__new_finish; + } else + __new_finish = _STLP_PRIV __uninitialized_fill_n(__new_finish, __fill_len, __x); + if (!__atend) + __new_finish = _STLP_PRIV __uninitialized_move(__pos, this->_M_finish, __new_finish, _TrivialUCopy(), _Movable()); // copy remainder + } + _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish), + this->_M_end_of_storage.deallocate(__new_start,__len))) + _M_clear_after_move(); + _M_set(__new_start, __new_finish, __new_start + __len); +} + +template +void vector<_Tp, _Alloc>::_M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCopy*/, + size_type __fill_len, bool __atend ) { + size_type __len = _M_compute_next_size(__fill_len); + pointer __new_start = this->_M_end_of_storage.allocate(__len, __len); + pointer __new_finish = __STATIC_CAST(pointer, _STLP_PRIV __copy_trivial(this->_M_start, __pos, __new_start)); + // handle insertion + __new_finish = _STLP_PRIV __fill_n(__new_finish, __fill_len, __x); + if (!__atend) + __new_finish = __STATIC_CAST(pointer, _STLP_PRIV __copy_trivial(__pos, this->_M_finish, __new_finish)); // copy remainder + _M_clear(); + _M_set(__new_start, __new_finish, __new_start + __len); +} + +template +void vector<_Tp, _Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n, + const _Tp& __x, const __true_type& /*_Movable*/) { + if (_M_is_inside(__x)) { + _Tp __x_copy = __x; + _M_fill_insert_aux(__pos, __n, __x_copy, __true_type()); + return; + } + iterator __src = this->_M_finish - 1; + iterator __dst = __src + __n; + for (; __src >= __pos; --__dst, --__src) { + _STLP_STD::_Move_Construct(__dst, *__src); + _STLP_STD::_Destroy_Moved(__src); + } + _STLP_PRIV __uninitialized_fill_n(__pos, __n, __x); + this->_M_finish += __n; +} + +template +void vector<_Tp, _Alloc>::_M_fill_insert_aux (iterator __pos, size_type __n, + const _Tp& __x, const __false_type& /*_Movable*/) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + //Here self referencing needs to be checked even for non movable types. + if (_M_is_inside(__x)) { + _Tp __x_copy = __x; + _M_fill_insert_aux(__pos, __n, __x_copy, __false_type()); + return; + } + const size_type __elems_after = this->_M_finish - __pos; + pointer __old_finish = this->_M_finish; + if (__elems_after > __n) { + _STLP_PRIV __ucopy_ptrs(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __n; + _STLP_PRIV __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialCopy()); + _STLP_STD::fill(__pos, __pos + __n, __x); + } else { + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_finish, __n - __elems_after, __x); + _STLP_PRIV __ucopy_ptrs(__pos, __old_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __elems_after; + _STLP_STD::fill(__pos, __old_finish, __x); + } +} + +template +void vector<_Tp, _Alloc>::_M_fill_insert(iterator __pos, + size_type __n, const _Tp& __x) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + if (__n != 0) { + if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) { + _M_fill_insert_aux(__pos, __n, __x, _Movable()); + } else { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + _M_insert_overflow(__pos, __x, _TrivialCopy(), __n); + } + } +} + +template +vector<_Tp, _Alloc>& vector<_Tp, _Alloc>::operator = (const vector<_Tp, _Alloc>& __x) { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + if (&__x != this) { + const size_type __xlen = __x.size(); + if (__xlen > capacity()) { + size_type __len = __xlen; + pointer __tmp = _M_allocate_and_copy(__len, __CONST_CAST(const_pointer, __x._M_start) + 0, + __CONST_CAST(const_pointer, __x._M_finish) + 0); + _M_clear(); + this->_M_start = __tmp; + this->_M_end_of_storage._M_data = this->_M_start + __len; + } else if (size() >= __xlen) { + pointer __i = _STLP_PRIV __copy_ptrs(__CONST_CAST(const_pointer, __x._M_start) + 0, + __CONST_CAST(const_pointer, __x._M_finish) + 0, this->_M_start, _TrivialCopy()); + _STLP_STD::_Destroy_Range(__i, this->_M_finish); + } else { + _STLP_PRIV __copy_ptrs(__CONST_CAST(const_pointer, __x._M_start), + __CONST_CAST(const_pointer, __x._M_start) + size(), this->_M_start, _TrivialCopy()); + _STLP_PRIV __ucopy_ptrs(__CONST_CAST(const_pointer, __x._M_start) + size(), + __CONST_CAST(const_pointer, __x._M_finish) + 0, this->_M_finish, _TrivialUCopy()); + } + this->_M_finish = this->_M_start + __xlen; + } + return *this; +} + +template +void vector<_Tp, _Alloc>::_M_fill_assign(size_t __n, const _Tp& __val) { + if (__n > capacity()) { + vector<_Tp, _Alloc> __tmp(__n, __val, get_allocator()); + __tmp.swap(*this); + } else if (__n > size()) { + fill(begin(), end(), __val); + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_finish, __n - size(), __val); + } else + erase(_STLP_PRIV __fill_n(begin(), __n, __val), end()); +} + +template +__iterator__ +vector<_Tp, _Alloc>::insert(iterator __pos, const _Tp& __x) { + size_type __n = __pos - begin(); + _M_fill_insert(__pos, 1, __x); + return begin() + __n; +} + +#undef __iterator__ + +#if defined (vector) +# undef vector +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_VECTOR_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/_vector.h b/sdk/tlibstdcxx/stlport/stl/_vector.h new file mode 100644 index 0000000000..ed243ef374 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/_vector.h @@ -0,0 +1,773 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_VECTOR_H +#define _STLP_INTERNAL_VECTOR_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +// The vector base class serves one purpose, its constructor and +// destructor allocate (but don't initialize) storage. This makes +// exception safety easier. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class _Vector_base { +public: + typedef _Vector_base<_Tp, _Alloc> _Self; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _Alloc allocator_type; + typedef _Tp* pointer; + typedef _STLP_alloc_proxy _AllocProxy; + + _Vector_base(const _Alloc& __a) + : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {} + + _Vector_base(size_t __n, const _Alloc& __a) + : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) { + _M_start = _M_end_of_storage.allocate(__n, __n); + _M_finish = _M_start; + _M_end_of_storage._M_data = _M_start + __n; + _STLP_MPWFIX_TRY _STLP_MPWFIX_CATCH + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Vector_base(__move_source<_Self> src) + : _M_start(src.get()._M_start), _M_finish(src.get()._M_finish), + _M_end_of_storage(__move_source<_AllocProxy>(src.get()._M_end_of_storage)) { + //Set the source as empty: + src.get()._M_finish = src.get()._M_end_of_storage._M_data = src.get()._M_start = 0; + } +#endif + + ~_Vector_base() { + if (_M_start != _STLP_DEFAULT_CONSTRUCTED(pointer)) + _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); + } + +protected: + void _STLP_FUNCTION_THROWS _M_throw_length_error() const; + void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const; + + pointer _M_start; + pointer _M_finish; + _AllocProxy _M_end_of_storage; +}; + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define vector _STLP_PTR_IMPL_NAME(vector) +#elif defined (_STLP_DEBUG) +# define vector _STLP_NON_DBG_NAME(vector) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template ) > +class vector : protected _STLP_PRIV _Vector_base<_Tp, _Alloc> +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector) + , public __stlport_class > +#endif +{ +private: + typedef _STLP_PRIV _Vector_base<_Tp, _Alloc> _Base; + typedef vector<_Tp, _Alloc> _Self; +public: + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef typename _Base::allocator_type allocator_type; + + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type* iterator; + typedef const value_type* const_iterator; + + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag _Iterator_category; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _Tp); } + +private: +#if defined (_STLP_NO_MOVE_SEMANTIC) + typedef __false_type _Movable; +#endif + + // handles insertions on overflow + void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __false_type& /*_Movable*/, + size_type __fill_len, bool __atend); + void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __true_type& /*_Movable*/, + size_type __fill_len, bool __atend) { + //We need to take care of self referencing here: + if (_M_is_inside(__x)) { + value_type __x_copy = __x; + _M_insert_overflow_aux(__pos, __x_copy, __false_type(), __fill_len, __atend); + return; + } + _M_insert_overflow_aux(__pos, __x, __false_type(), __fill_len, __atend); + } + + void _M_insert_overflow(pointer __pos, const _Tp& __x, const __false_type& /*_TrivialCopy*/, + size_type __fill_len, bool __atend = false) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + _M_insert_overflow_aux(__pos, __x, _Movable(), __fill_len, __atend); + } + void _M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCopy*/, + size_type __fill_len, bool __atend = false); + void _M_range_check(size_type __n) const { + if (__n >= size_type(this->_M_finish - this->_M_start)) + this->_M_throw_out_of_range(); + } + + size_type _M_compute_next_size(size_type __n) { + const size_type __size = size(); + if (__n > max_size() - __size) + this->_M_throw_length_error(); + size_type __len = __size + (max)(__n, __size); + if (__len > max_size() || __len < __size) + __len = max_size(); // overflow + return __len; + } + +public: + iterator begin() { return this->_M_start; } + const_iterator begin() const { return this->_M_start; } + iterator end() { return this->_M_finish; } + const_iterator end() const { return this->_M_finish; } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + size_type size() const { return size_type(this->_M_finish - this->_M_start); } + size_type max_size() const { + size_type __vector_max_size = size_type(-1) / sizeof(_Tp); + typename allocator_type::size_type __alloc_max_size = this->_M_end_of_storage.max_size(); + return (__alloc_max_size < __vector_max_size)?__alloc_max_size:__vector_max_size; + } + + size_type capacity() const { return size_type(this->_M_end_of_storage._M_data - this->_M_start); } + bool empty() const { return this->_M_start == this->_M_finish; } + + reference operator[](size_type __n) { return *(begin() + __n); } + const_reference operator[](size_type __n) const { return *(begin() + __n); } + + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(end() - 1); } + const_reference back() const { return *(end() - 1); } + + reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; } + const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit vector(const allocator_type& __a = allocator_type()) +#else + vector() + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(allocator_type()) {} + vector(const allocator_type& __a) +#endif + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__a) {} + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) +private: + //We always call _M_initialize with only 1 parameter. Default parameter + //is used to allow explicit instanciation of vector with types with no + //default constructor. + void _M_initialize(size_type __n, const _Tp& __val = _STLP_DEFAULT_CONSTRUCTED(_Tp)) + { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, __val); } +public: + explicit vector(size_type __n) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type()) + { _M_initialize(__n); } + vector(size_type __n, const _Tp& __val, const allocator_type& __a = allocator_type()) +#else + explicit vector(size_type __n) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type()) + { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } + vector(size_type __n, const _Tp& __val) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type()) + { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); } + vector(size_type __n, const _Tp& __val, const allocator_type& __a) +#endif + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, __a) + { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); } + + vector(const _Self& __x) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__x.size(), __x.get_allocator()) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + this->_M_finish = _STLP_PRIV __ucopy_ptrs(__x.begin(), __x.end(), this->_M_start, _TrivialUCopy()); + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + vector(__move_source<_Self> src) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__move_source<_Base>(src.get())) + {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) +private: + template + void _M_initialize_aux(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) { + size_type __real_n = __n; + this->_M_start = this->_M_end_of_storage.allocate(__n, __real_n); + this->_M_end_of_storage._M_data = this->_M_start + __real_n; + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); + } + + template + void _M_initialize_aux(_InputIterator __first, _InputIterator __last, + const __false_type& /*_IsIntegral*/) + { _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); } + +public: + // Check whether it's an integral type. If so, it's not an iterator. + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL ) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__a) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_aux(__first, __last, _Integral()); + } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + vector(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(allocator_type()) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_aux(__first, __last, _Integral()); + } +# endif /* _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS */ + +#else /* _STLP_MEMBER_TEMPLATES */ + vector(const _Tp* __first, const _Tp* __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__last - __first, __a) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + this->_M_finish = _STLP_PRIV __ucopy_ptrs(__first, __last, this->_M_start, _TrivialUCopy()); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + //As the vector container is a back insert oriented container it + //seems rather logical to destroy elements in reverse order. + ~vector() { _STLP_STD::_Destroy_Range(rbegin(), rend()); } + + _Self& operator=(const _Self& __x); + + void reserve(size_type __n); + + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); } + void _M_fill_assign(size_type __n, const _Tp& __val); + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_assign_aux(_ForwardIter __first, _ForwardIter __last, const forward_iterator_tag &) { +#else + void assign(const_iterator __first, const_iterator __last) { + typedef const_iterator _ForwardIter; +#endif + const size_type __len = _STLP_STD::distance(__first, __last); + if (__len > capacity()) { + size_type __n = __len; + iterator __tmp = _M_allocate_and_copy(__n, __first, __last); + _M_clear(); + _M_set(__tmp, __tmp + __len, __tmp + __n); + } + else if (size() >= __len) { + iterator __new_finish = copy(__first, __last, this->_M_start); + _STLP_STD::_Destroy_Range(__new_finish, this->_M_finish); + this->_M_finish = __new_finish; + } + else { + _ForwardIter __mid = __first; + _STLP_STD::advance(__mid, size()); + _STLP_STD::copy(__first, __mid, this->_M_start); + this->_M_finish = _STLP_STD::uninitialized_copy(__mid, __last, this->_M_finish); + } + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_assign_aux(_InputIter __first, _InputIter __last, + const input_iterator_tag &) { + iterator __cur = begin(); + for ( ; __first != __last && __cur != end(); ++__cur, ++__first) + *__cur = *__first; + if (__first == __last) + erase(__cur, end()); + else + insert(end(), __first, __last); + } + + template + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) + { _M_fill_assign(__n, __val); } + + template + void _M_assign_dispatch(_InputIter __first, _InputIter __last, + const __false_type& /*_IsIntegral*/) + { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); } + + template + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back(const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void push_back(const _Tp& __x) { +#endif + if (this->_M_finish != this->_M_end_of_storage._M_data) { + _Copy_Construct(this->_M_finish, __x); + ++this->_M_finish; + } + else { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + _M_insert_overflow(this->_M_finish, __x, _TrivialCopy(), 1, true); + } + } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)); +#else + iterator insert(iterator __pos, const _Tp& __x); +#endif + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + void push_back() { push_back(_STLP_DEFAULT_CONSTRUCTED(_Tp)); } + iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif + + void swap(_Self& __x) { + _STLP_STD::swap(this->_M_start, __x._M_start); + _STLP_STD::swap(this->_M_finish, __x._M_finish); + this->_M_end_of_storage.swap(__x._M_end_of_storage); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +private: + void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __true_type& /*_Movable*/); + void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __false_type& /*_Movable*/); + void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x); + + bool _M_is_inside(const value_type& __x) const { + return (&__x >= this->_M_start && &__x < this->_M_finish); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_range_insert_realloc(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, +#else + void _M_range_insert_realloc(iterator __pos, + const_iterator __first, const_iterator __last, +#endif + size_type __n) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + size_type __len = _M_compute_next_size(__n); + pointer __new_start = this->_M_end_of_storage.allocate(__len, __len); + pointer __new_finish = __new_start; + _STLP_TRY { + __new_finish = _STLP_PRIV __uninitialized_move(this->_M_start, __pos, __new_start, _TrivialUCopy(), _Movable()); + __new_finish = uninitialized_copy(__first, __last, __new_finish); + __new_finish = _STLP_PRIV __uninitialized_move(__pos, this->_M_finish, __new_finish, _TrivialUCopy(), _Movable()); + } + _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish), + this->_M_end_of_storage.deallocate(__new_start,__len))) + _M_clear_after_move(); + _M_set(__new_start, __new_finish, __new_start + __len); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_range_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, +#else + void _M_range_insert_aux(iterator __pos, + const_iterator __first, const_iterator __last, +#endif + size_type __n, const __true_type& /*_Movable*/) { + iterator __src = this->_M_finish - 1; + iterator __dst = __src + __n; + for (; __src >= __pos; --__dst, --__src) { + _STLP_STD::_Move_Construct(__dst, *__src); + _STLP_STD::_Destroy_Moved(__src); + } + uninitialized_copy(__first, __last, __pos); + this->_M_finish += __n; + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_range_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, +#else + void _M_range_insert_aux(iterator __pos, + const_iterator __first, const_iterator __last, +#endif + size_type __n, const __false_type& /*_Movable*/) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + const size_type __elems_after = this->_M_finish - __pos; + pointer __old_finish = this->_M_finish; + if (__elems_after > __n) { + _STLP_PRIV __ucopy_ptrs(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __n; + _STLP_PRIV __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialCopy()); + copy(__first, __last, __pos); + } + else { +#if defined ( _STLP_MEMBER_TEMPLATES ) + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, __elems_after); +#else + const_pointer __mid = __first + __elems_after; +#endif + uninitialized_copy(__mid, __last, this->_M_finish); + this->_M_finish += __n - __elems_after; + _STLP_PRIV __ucopy_ptrs(__pos, __old_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __elems_after; + copy(__first, __mid, __pos); + } /* elems_after */ + } + + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + const __true_type&) + { _M_fill_insert(__pos, (size_type) __n, (_Tp) __val); } + + template + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) + { _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); } + +public: + // Check whether it's an integral type. If so, it's not an iterator. + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); + } + +private: + template + void _M_range_insert(iterator __pos, + _InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) { + __pos = insert(__pos, *__first); + ++__pos; + } + } + + template + void _M_range_insert(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { +#else +public: + void insert(iterator __pos, + const_iterator __first, const_iterator __last) { +#endif +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + /* This method do not check self referencing. + * Standard forbids it, checked by the debug mode. + */ + if (__first != __last) { + size_type __n = _STLP_STD::distance(__first, __last); + + if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) { + _M_range_insert_aux(__pos, __first, __last, __n, _Movable()); + } + else { + _M_range_insert_realloc(__pos, __first, __last, __n); + } + } + } + +public: + void insert (iterator __pos, size_type __n, const _Tp& __x) + { _M_fill_insert(__pos, __n, __x); } + + void pop_back() { + --this->_M_finish; + _STLP_STD::_Destroy(this->_M_finish); + } + +private: + iterator _M_erase(iterator __pos, const __true_type& /*_Movable*/) { + _STLP_STD::_Destroy(__pos); + iterator __dst = __pos, __src = __dst + 1; + iterator __end = end(); + for (; __src != __end; ++__dst, ++__src) { + _STLP_STD::_Move_Construct(__dst, *__src); + _STLP_STD::_Destroy_Moved(__src); + } + this->_M_finish = __dst; + return __pos; + } + iterator _M_erase(iterator __pos, const __false_type& /*_Movable*/) { + if (__pos + 1 != end()) { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + _STLP_PRIV __copy_ptrs(__pos + 1, this->_M_finish, __pos, _TrivialCopy()); + } + --this->_M_finish; + _STLP_STD::_Destroy(this->_M_finish); + return __pos; + } + iterator _M_erase(iterator __first, iterator __last, const __true_type& /*_Movable*/) { + iterator __dst = __first, __src = __last; + iterator __end = end(); + for (; __dst != __last && __src != __end; ++__dst, ++__src) { + _STLP_STD::_Destroy(__dst); + _STLP_STD::_Move_Construct(__dst, *__src); + } + if (__dst != __last) { + //There is more elements to erase than element to move: + _STLP_STD::_Destroy_Range(__dst, __last); + _STLP_STD::_Destroy_Moved_Range(__last, __end); + } + else { + //There is more element to move than element to erase: + for (; __src != __end; ++__dst, ++__src) { + _STLP_STD::_Destroy_Moved(__dst); + _STLP_STD::_Move_Construct(__dst, *__src); + } + _STLP_STD::_Destroy_Moved_Range(__dst, __end); + } + this->_M_finish = __dst; + return __first; + } + iterator _M_erase(iterator __first, iterator __last, const __false_type& /*_Movable*/) { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + pointer __i = _STLP_PRIV __copy_ptrs(__last, this->_M_finish, __first, _TrivialCopy()); + _STLP_STD::_Destroy_Range(__i, this->_M_finish); + this->_M_finish = __i; + return __first; + } + +public: + iterator erase(iterator __pos) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + return _M_erase(__pos, _Movable()); + } + iterator erase(iterator __first, iterator __last) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + if (__first == __last) + return __first; + return _M_erase(__first, __last, _Movable()); + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void resize(size_type __new_size, const _Tp& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + if (__new_size < size()) + erase(begin() + __new_size, end()); + else + insert(end(), __new_size - size(), __x); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void clear() { + erase(begin(), end()); + } + +private: + void _M_clear() { + _STLP_STD::_Destroy_Range(rbegin(), rend()); + this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start); + } + + void _M_clear_after_move() { + _STLP_STD::_Destroy_Moved_Range(rbegin(), rend()); + this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start); + } + + void _M_set(pointer __s, pointer __f, pointer __e) { + this->_M_start = __s; + this->_M_finish = __f; + this->_M_end_of_storage._M_data = __e; + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + pointer _M_allocate_and_copy(size_type& __n, + _ForwardIterator __first, _ForwardIterator __last) +#else /* _STLP_MEMBER_TEMPLATES */ + pointer _M_allocate_and_copy(size_type& __n, + const_pointer __first, const_pointer __last) +#endif /* _STLP_MEMBER_TEMPLATES */ + { + pointer __result = this->_M_end_of_storage.allocate(__n, __n); + _STLP_TRY { + uninitialized_copy(__first, __last, __result); + return __result; + } + _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n)) + _STLP_RET_AFTER_THROW(__result) + } + + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void _M_range_initialize(_InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) + push_back(*__first); + } + // This function is only called by the constructor. + template + void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + size_type __n = _STLP_STD::distance(__first, __last); + this->_M_start = this->_M_end_of_storage.allocate(__n, __n); + this->_M_end_of_storage._M_data = this->_M_start + __n; + this->_M_finish = uninitialized_copy(__first, __last, this->_M_start); + } +#endif /* _STLP_MEMBER_TEMPLATES */ +}; + +#if defined (vector) +# undef vector +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# include +#endif + +//We define the bool specialization before the debug interfave +//to benefit of the debug version of vector even for the bool +//specialization. +#if !defined (_STLP_NO_BOOL) || !defined (_STLP_NO_EXTENSIONS) +# if !defined (_STLP_INTERNAL_BVECTOR_H) +# include +# endif +#endif + +#if defined (_STLP_DEBUG) +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_NO_BOOL) && !defined (_STLP_NO_EXTENSIONS) +// This typedef is non-standard. It is provided for backward compatibility. +typedef vector > bit_vector; +#endif + +#define _STLP_TEMPLATE_HEADER template +#define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc> +#include +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template +struct __move_traits > { + typedef __true_type implemented; + typedef typename __move_traits<_Alloc>::complete complete; +}; +# endif + +# if !defined (_STLP_DEBUG) +template +struct _DefaultZeroValue > +{ typedef typename __type_traits<_Alloc>::has_trivial_default_constructor _Ret; }; +# endif + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_VECTOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/boost_type_traits.h b/sdk/tlibstdcxx/stlport/stl/boost_type_traits.h new file mode 100644 index 0000000000..ae3a3f61d9 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/boost_type_traits.h @@ -0,0 +1,150 @@ +/* + * + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_BOOST_TYPE_TRAITS_H +#define _STLP_BOOST_TYPE_TRAITS_H + +#ifndef BOOST_CONFIG_SUFFIX_HPP +# ifdef BOOST_CONFIG_HPP +# undef BOOST_CONFIG_HPP +# endif +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * This file mostly wraps boost type_traits in the STLport type_traits. + * When checking a type traits like trivial assign operator for instance + * both the boost value and STLport values has to be taken into account + * as we don't know what the user might have prefer, specializing the boost + * type traits or the STLport one. + */ +_STLP_BEGIN_NAMESPACE + +template struct _IsRef { + enum { _Is = ::boost::is_reference<_Tp>::value }; + typedef typename __bool2type<_Is>::_Ret _Ret; +}; + +template struct _IsPtr { + enum { is_pointer = ::boost::is_pointer<_Tp>::value }; + typedef typename __bool2type::_Ret _Ret; +}; + +template struct _IsIntegral { + enum { is_integral = ::boost::is_integral<_Tp>::value }; + typedef typename __bool2type::_Ret _Ret; +}; + +template struct _IsRational { + enum { is_float = ::boost::is_float<_Tp>::value }; + typedef typename __bool2type::_Ret _Ret; +}; + +template +struct __type_traits { + enum { trivial_constructor = ::boost::has_trivial_constructor<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_default_constructor; + + enum { trivial_copy = ::boost::has_trivial_copy<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_copy_constructor; + + enum { trivial_assign = ::boost::has_trivial_assign<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_assignment_operator; + + enum { trivial_destructor = ::boost::has_trivial_destructor<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_destructor; + + enum { pod = ::boost::is_pod<_Tp>::value }; + typedef typename __bool2type::_Ret is_POD_type; +}; + +template +struct _TrivialCopy { + typedef typename ::boost::remove_cv<_Tp1>::type uncv1; + typedef typename ::boost::remove_cv<_Tp2>::type uncv2; + + enum { same = ::boost::is_same::value }; + typedef typename __bool2type::_Ret _Same; + + enum { boost_trivial_assign = ::boost::has_trivial_assign::value }; + typedef typename __bool2type::_Ret _BoostTrivialAssign; + typedef typename __type_traits::has_trivial_assignment_operator _STLPTrivialAssign; + typedef typename _Lor2<_BoostTrivialAssign, _STLPTrivialAssign>::_Ret _TrivialAssign; + + typedef typename _Land2<_Same, _TrivialAssign>::_Ret _Type; + static _Type _Answer() { return _Type(); } +}; + +template +struct _TrivialUCopy { + typedef typename ::boost::remove_cv<_Tp1>::type uncv1; + typedef typename ::boost::remove_cv<_Tp2>::type uncv2; + + enum { same = ::boost::is_same::value }; + typedef typename __bool2type::_Ret _Same; + + enum { boost_trivial_copy = ::boost::has_trivial_copy::value }; + typedef typename __bool2type::_Ret _BoostTrivialCopy; + typedef typename __type_traits::has_trivial_copy_constructor _STLPTrivialCopy; + typedef typename _Lor2<_BoostTrivialCopy, _STLPTrivialCopy>::_Ret _TrivialCopy; + + typedef typename _Land2<_Same, _TrivialCopy>::_Ret _Type; + static _Type _Answer() { return _Type(); } +}; + +template +struct _DefaultZeroValue { + enum { is_integral = ::boost::is_integral<_Tp>::value }; + typedef typename __bool2type::_Ret _IsIntegral; + enum { is_float = ::boost::is_float<_Tp>::value }; + typedef typename __bool2type::_Ret _IsFloat; + enum { is_pointer = ::boost::is_pointer<_Tp>::value }; + typedef typename __bool2type::_Ret _IsPointer; + + typedef typename _Lor3<_IsIntegral, _IsFloat, _IsPointer>::_Ret _Ret; +}; + +template +struct _TrivialInit { + typedef typename ::boost::remove_cv<_Tp>::type uncv; + + enum { boost_trivial_constructor = ::boost::has_trivial_constructor::value }; + typedef typename __bool2type::_Ret _BoostTrivialInit; + typedef typename __type_traits::has_trivial_default_constructor _STLPTrivialInit; + typedef typename _Lor2<_BoostTrivialInit, _STLPTrivialInit>::_Ret _Tr1; + + typedef typename _DefaultZeroValue<_Tp>::_Ret _Tr2; + typedef typename _Not<_Tr2>::_Ret _Tr3; + + typedef typename _Land2<_Tr1, _Tr3>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +_STLP_END_NAMESPACE + +#endif /* _STLP_BOOST_TYPE_TRAITS_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/c_locale.h b/sdk/tlibstdcxx/stlport/stl/c_locale.h new file mode 100644 index 0000000000..cadd2bc102 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/c_locale.h @@ -0,0 +1,131 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_C_LOCALE_H +#define _STLP_C_LOCALE_H + +/* + * Implementation dependent definitions. + * Beware: This header is not a purely internal header, it is also included + * from the outside world when building the STLport library. So this header + * should not reference internal headers (stlport/stl/_*.h) directly. + */ +#if defined (__sgi) +# if defined (ROOT_65) /* IRIX 6.5.x */ +# include +# include +# include +# include +# else /* IRIX pre-6.5 */ +# include +# include +# if !defined(_SIZE_T) && !defined(_SIZE_T_) +# define _SIZE_T +# if (_MIPS_SZLONG == 32) +typedef unsigned int size_t; +# endif +# if (_MIPS_SZLONG == 64) +typedef unsigned long size_t; +# endif +# endif +# if !defined (_WCHAR_T) +# define _WCHAR_T +# if (_MIPS_SZLONG == 32) +typedef long wchar_t; +# endif +# if (_MIPS_SZLONG == 64) +typedef __int32_t wchar_t; +# endif +# endif /* _WCHAR_T */ +# if !defined (_WINT_T) +# define _WINT_T +# if (_MIPS_SZLONG == 32) +typedef long wint_t; +# endif +# if (_MIPS_SZLONG == 64) +typedef __int32_t wint_t; +# endif +# endif /* _WINT_T */ +# if !defined (_MBSTATE_T) +# define _MBSTATE_T +/* _MSC_VER check is here for historical reason and seems wrong as it is the macro defined + * by Microsoft compilers to give their version. But we are in a SGI platform section so it + * is weird. However _MSC_VER might also be a SGI compiler macro so we keep it this way.*/ +# if defined (_MSC_VER) +typedef int mbstate_t; +# else +typedef char mbstate_t; +# endif +# endif /* _MBSTATE_T */ +# endif /* ROOT65 */ +#elif defined (_STLP_USE_GLIBC) +# include +#endif + +/* + * GENERAL FRAMEWORK + */ + +/* + * Opaque types, implementation (if there is one) depends + * on platform localisation API. + */ +struct _Locale_ctype; +struct _Locale_codecvt; +struct _Locale_numeric; +struct _Locale_time; +struct _Locale_collate; +struct _Locale_monetary; +struct _Locale_messages; + +/* + Bitmask macros. +*/ + +/* + * For narrow characters, we expose the lookup table interface. + */ + +#if defined (_STLP_USE_GLIBC) +/* This section uses macros defined in the gnu libc ctype.h header */ +# define _Locale_CNTRL _IScntrl +# define _Locale_UPPER _ISupper +# define _Locale_LOWER _ISlower +# define _Locale_DIGIT _ISdigit +# define _Locale_XDIGIT _ISxdigit +# define _Locale_PUNCT _ISpunct +# define _Locale_SPACE _ISspace +# define _Locale_PRINT _ISprint +# define _Locale_ALPHA _ISalpha +#else +/* Default values based on C++ Standard 22.2.1. + * Under Windows the localisation implementation take care of mapping its + * mask values to those internal values. For other platforms without real + * localization support we are free to use the most suitable values.*/ +# define _Locale_SPACE 0x0001 +# define _Locale_PRINT 0x0002 +# define _Locale_CNTRL 0x0004 +# define _Locale_UPPER 0x0008 +# define _Locale_LOWER 0x0010 +# define _Locale_ALPHA 0x0020 +# define _Locale_DIGIT 0x0040 +# define _Locale_PUNCT 0x0080 +# define _Locale_XDIGIT 0x0100 +#endif + +#endif /* _STLP_C_LOCALE_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/char_traits.h b/sdk/tlibstdcxx/stlport/stl/char_traits.h new file mode 100644 index 0000000000..f004a70492 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/char_traits.h @@ -0,0 +1,278 @@ +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CHAR_TRAITS_H +#define _STLP_CHAR_TRAITS_H + +// Define char_traits + +#ifndef _STLP_INTERNAL_CSTDDEF +# include +#endif + +#ifndef _STLP_INTERNAL_CSTRING +# include +#endif + +#if defined (__unix) +# include // For off_t +#endif /* __unix */ + +#if defined (__BORLANDC__) +# include +# include +# include <_stddef.h> +# include +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include +#endif + +#ifndef _STLP_INTERNAL_CWCHAR +# include +#endif + +_STLP_BEGIN_NAMESPACE + +template class allocator; + +#define _STLP_NULL_CHAR_INIT(_ChT) _STLP_DEFAULT_CONSTRUCTED(_ChT) + +#if defined(_STLP_WCE) +typedef long streamoff; +#elif defined (_STLP_WIN32) +# if defined (_STLP_LONG_LONG) && !defined (__CYGWIN__) +//The Win32 file io API support 64 bits access so streamoff and streamsize +//has to reflect that. Do not change the stringbuf behavior. +typedef _STLP_LONG_LONG streamoff; +# else +typedef ptrdiff_t streamoff; +# endif +#else // __unix +# ifdef _STLP_USE_DEFAULT_FILE_OFFSET +typedef off_t streamoff; +# elif defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE) /* || defined(__USE_FILE_OFFSET64) */ \ + /* || (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */ /* || defined (__sgi) && defined (_STLP_HAS_NO_NEW_C_HEADERS) */ +typedef off64_t streamoff; +# else +typedef off_t streamoff; +# endif +#endif /* __unix */ + +#if defined (_STLP_WIN32) +typedef streamoff streamsize; +#else +typedef ptrdiff_t streamsize; +#endif + +// Class fpos, which represents a position within a file. (The C++ +// standard calls for it to be defined in . This implementation +// moves it to , which is included by .) +template class fpos { +public: // From table 88 of the C++ standard. + fpos(streamoff __pos) : _M_pos(__pos), _M_st(_STLP_NULL_CHAR_INIT(_StateT)) {} + fpos() : _M_pos(0), _M_st(_STLP_NULL_CHAR_INIT(_StateT)) {} + + operator streamoff() const { return _M_pos; } + + bool operator==(const fpos& __y) const + { return _M_pos == __y._M_pos; } + bool operator!=(const fpos& __y) const + { return _M_pos != __y._M_pos; } + + fpos& operator+=(streamoff __off) { + _M_pos += __off; + return *this; + } + fpos& operator-=(streamoff __off) { + _M_pos -= __off; + return *this; + } + + fpos operator+(streamoff __off) { + fpos __tmp(*this); + __tmp += __off; + return __tmp; + } + fpos operator-(streamoff __off) { + fpos __tmp(*this); + __tmp -= __off; + return __tmp; + } + +public: // Manipulation of the state member. + _StateT state() const { return _M_st; } + void state(_StateT __st) { _M_st = __st; } +private: + streamoff _M_pos; + _StateT _M_st; +}; + +typedef fpos streampos; +typedef fpos wstreampos; + +// Class __char_traits_base. +template +class __char_traits_base { +public: + typedef _CharT char_type; + typedef _IntT int_type; + typedef streamoff off_type; + typedef streampos pos_type; + typedef mbstate_t state_type; + + static void _STLP_CALL assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; } + static bool _STLP_CALL eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + static bool _STLP_CALL lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int _STLP_CALL compare(const char_type* __s1, const char_type* __s2, size_t __n) { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return __s1[__i] < __s2[__i] ? -1 : 1; + return 0; + } + + static size_t _STLP_CALL length(const char_type* __s) { + const char_type _NullChar = _STLP_DEFAULT_CONSTRUCTED(char_type); + size_t __i(0); + for (; !eq(__s[__i], _NullChar); ++__i) {} + return __i; + } + + static const char_type* _STLP_CALL find(const char_type* __s, size_t __n, const char_type& __c) { + for ( ; __n > 0 ; ++__s, --__n) + if (eq(*__s, __c)) + return __s; + return 0; + } + + static char_type* _STLP_CALL move(char_type* __s1, const char_type* __s2, size_t _Sz) + { return (_Sz == 0 ? __s1 : (char_type*)memmove(__s1, __s2, _Sz * sizeof(char_type))); } + + static char_type* _STLP_CALL copy(char_type* __s1, const char_type* __s2, size_t __n) { + return (__n == 0 ? __s1 : + (char_type*)memcpy(__s1, __s2, __n * sizeof(char_type))); + } + + static char_type* _STLP_CALL assign(char_type* __s, size_t __n, char_type __c) { + for (size_t __i = 0; __i < __n; ++__i) + __s[__i] = __c; + return __s; + } + + static int_type _STLP_CALL not_eof(const int_type& __c) + { return !eq_int_type(__c, eof()) ? __c : __STATIC_CAST(int_type, 0); } + + static char_type _STLP_CALL to_char_type(const int_type& __c) + { return (char_type)__c; } + + static int_type _STLP_CALL to_int_type(const char_type& __c) + { return (int_type)__c; } + + static bool _STLP_CALL eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type _STLP_CALL eof() + { return (int_type)-1; } +}; + +// Generic char_traits class. Note that this class is provided only +// as a base for explicit specialization; it is unlikely to be useful +// as is for any particular user-defined type. In particular, it +// *will not work* for a non-POD type. + +template +class char_traits + : public __char_traits_base<_CharT, _CharT> {}; + +// Specialization for char. + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC char_traits + : public __char_traits_base, + public __stlport_class > { +public: + typedef char char_type; + typedef int int_type; + typedef streamoff off_type; + typedef streampos pos_type; + typedef mbstate_t state_type; + + static char _STLP_CALL to_char_type(const int& __c) + { return (char)(unsigned char)__c; } + + static int _STLP_CALL to_int_type(const char& __c) + { return (unsigned char)__c; } + + static int _STLP_CALL compare(const char* __s1, const char* __s2, size_t __n) + { return memcmp(__s1, __s2, __n); } + + static size_t _STLP_CALL length(const char* __s) + { return strlen(__s); } + + static void _STLP_CALL assign(char& __c1, const char& __c2) + { __c1 = __c2; } + + static char* _STLP_CALL assign(char* __s, size_t __n, char __c) { + memset(__s, __c, __n); + return __s; + } +}; + +#if defined (_STLP_HAS_WCHAR_T) +// Specialization for wchar_t. +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC char_traits + : public __char_traits_base { +# if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && !defined (_STLP_WCHAR_HPACC_EXCLUDE) +public: +# if !defined (__BORLANDC__) + static wchar_t* _STLP_CALL move(wchar_t* __dest, const wchar_t* __src, size_t __n) + { return wmemmove(__dest, __src, __n); } +# endif + + static wchar_t* _STLP_CALL copy(wchar_t* __dest, const wchar_t* __src, size_t __n) + { return wmemcpy(__dest, __src, __n); } + +# if !defined (__DMC__) && !defined (__BORLANDC__) + static int _STLP_CALL compare(const wchar_t* __s1, const wchar_t* __s2, size_t __n) + { return wmemcmp(__s1, __s2, __n); } +# endif + + static wchar_t* _STLP_CALL assign(wchar_t* __s, size_t __n, wchar_t __c) + { return wmemset(__s, __c, __n); } + + static size_t _STLP_CALL length(const wchar_t* __s) + { return wcslen(__s); } + + static void _STLP_CALL assign(wchar_t& __c1, const wchar_t& __c2) + { __c1 = __c2; } +# endif +}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_CHAR_TRAITS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/concept_checks.h b/sdk/tlibstdcxx/stlport/stl/concept_checks.h new file mode 100644 index 0000000000..5fe02c298a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/concept_checks.h @@ -0,0 +1,810 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __CONCEPT_CHECKS_H +#define __CONCEPT_CHECKS_H + +/* + Use these macro like assertions, but they assert properties + on types (usually template arguments). In technical terms they + verify whether a type "models" a "concept". + + This set of requirements and the terminology used here is derived + from the book "Generic Programming and the STL" by Matt Austern + (Addison Wesley). For further information please consult that + book. The requirements also are intended to match the ANSI/ISO C++ + standard. + + This file covers the basic concepts and the iterator concepts. + There are several other files that provide the requirements + for the STL containers: + container_concepts.h + sequence_concepts.h + assoc_container_concepts.h + + Jeremy Siek, 1999 + + TO DO: + - some issues with regards to concept classification and mutability + including AssociativeContianer -> ForwardContainer + and SortedAssociativeContainer -> ReversibleContainer + - HashedAssociativeContainer + - Allocator + - Function Object Concepts + + */ + +#ifndef _STLP_USE_CONCEPT_CHECKS + +// Some compilers lack the features that are necessary for concept checks. +// On those compilers we define the concept check macros to do nothing. +#define _STLP_REQUIRES(__type_var, __concept) do {} while(0) +#define _STLP_CLASS_REQUIRES(__type_var, __concept) \ + static int __##__type_var##_##__concept +#define _STLP_CONVERTIBLE(__type_x, __type_y) do {} while(0) +#define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0) +#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ + static int __##__type_x##__type_y##_require_same_type +#define _STLP_GENERATOR_CHECK(__func, __ret) do {} while(0) +#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \ + static int __##__func##__ret##_generator_check +#define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0) +#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ + static int __##__func##__ret##__arg##_unary_function_check +#define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ + do {} while(0) +#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ + static int __##__func##__ret##__first##__second##_binary_function_check +#define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ + do {} while(0) +#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ + static int __##__opname##__ret##__first##__second##_require_binary_op + +#else /* _STLP_USE_CONCEPT_CHECKS */ + +// This macro tests whether the template argument "__type_var" +// satisfies the requirements of "__concept". Here is a list of concepts +// that we know how to check: +// _Allocator +// _Assignable +// _DefaultConstructible +// _EqualityComparable +// _LessThanComparable +// _TrivialIterator +// _InputIterator +// _OutputIterator +// _ForwardIterator +// _BidirectionalIterator +// _RandomAccessIterator +// _Mutable_TrivialIterator +// _Mutable_ForwardIterator +// _Mutable_BidirectionalIterator +// _Mutable_RandomAccessIterator + +#define _STLP_REQUIRES(__type_var, __concept) \ +do { \ + void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\ + ::##__concept##_requirement_violation; __x = __x; } while (0) + +// Use this to check whether type X is convertible to type Y +#define _STLP_CONVERTIBLE(__type_x, __type_y) \ +do { \ + void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \ + __type_y >::__type_X_is_not_convertible_to_type_Y; \ + __x = __x; } while (0) + +// Use this to test whether two template arguments are the same type +#define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) \ +do { \ + void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \ + __type_y >::__type_X_not_same_as_type_Y; \ + __x = __x; } while (0) + + +// function object checks +#define _STLP_GENERATOR_CHECK(__func, __ret) \ +do { \ + __ret (*__x)( __func&) = \ + _STL_GENERATOR_ERROR< \ + __func, __ret>::__generator_requirement_violation; \ + __x = __x; } while (0) + + +#define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ +do { \ + __ret (*__x)( __func&, const __arg& ) = \ + _STL_UNARY_FUNCTION_ERROR< \ + __func, __ret, __arg>::__unary_function_requirement_violation; \ + __x = __x; } while (0) + + +#define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ +do { \ + __ret (*__x)( __func&, const __first&, const __second& ) = \ + _STL_BINARY_FUNCTION_ERROR< \ + __func, __ret, __first, __second>::__binary_function_requirement_violation; \ + __x = __x; } while (0) + + +#define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ + do { \ + __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \ + __ret, __first, __second>::__binary_operator_requirement_violation; \ + __ret (*__y)( const __first&, const __second& ) = \ + _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \ + __const_binary_operator_requirement_violation; \ + __y = __y; __x = __x; } while (0) + + +#ifdef _STLP_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE + +#define _STLP_CLASS_REQUIRES(__type_var, __concept) +#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) +#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) +#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) +#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) +#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) + +#else + +// Use this macro inside of template classes, where you would +// like to place requirements on the template arguments to the class +// Warning: do not pass pointers and such (e.g. T*) in as the __type_var, +// since the type_var is used to construct identifiers. Instead typedef +// the pointer type, then use the typedef name for the __type_var. +#define _STLP_CLASS_REQUIRES(__type_var, __concept) \ + typedef void (* __func##__type_var##__concept)( __type_var ); \ + template <__func##__type_var##__concept _Tp1> \ + struct __dummy_struct_##__type_var##__concept { }; \ + static __dummy_struct_##__type_var##__concept< \ + __concept##_concept_specification< \ + __type_var>::__concept##_requirement_violation> \ + __dummy_ptr_##__type_var##__concept + + +#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ + typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \ + __type_y ); \ + template < __func_##__type_x##__type_y##same_type _Tp1> \ + struct __dummy_struct_##__type_x##__type_y##_same_type { }; \ + static __dummy_struct_##__type_x##__type_y##_same_type< \ + _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y> \ + __dummy_ptr_##__type_x##__type_y##_same_type + + +#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \ + typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \ + template <__f_##__func##__ret##_generator _Tp1> \ + struct __dummy_struct_##__func##__ret##_generator { }; \ + static __dummy_struct_##__func##__ret##_generator< \ + _STL_GENERATOR_ERROR< \ + __func, __ret>::__generator_requirement_violation> \ + __dummy_ptr_##__func##__ret##_generator + + +#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ + typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \ + const __arg& ); \ + template <__f_##__func##__ret##__arg##_unary_check _Tp1> \ + struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \ + static __dummy_struct_##__func##__ret##__arg##_unary_check< \ + _STL_UNARY_FUNCTION_ERROR< \ + __func, __ret, __arg>::__unary_function_requirement_violation> \ + __dummy_ptr_##__func##__ret##__arg##_unary_check + + +#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ + typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\ + const __second& ); \ + template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \ + struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \ + static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \ + _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \ + __binary_function_requirement_violation> \ + __dummy_ptr_##__func##__ret##__first##__second##_binary_check + + +#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ + typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \ + const __second& ); \ + template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \ + struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \ + static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \ + _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \ + __binary_operator_requirement_violation> \ + __dummy_ptr_##__func##__ret##__first##__second##_binary_op + +#endif + +/* helper class for finding non-const version of a type. Need to have + something to assign to etc. when testing constant iterators. */ + +template +struct _Mutable_trait { + typedef _Tp _Type; +}; +template +struct _Mutable_trait { + typedef _Tp _Type; +}; + + +/* helper function for avoiding compiler warnings about unused variables */ +template +void __sink_unused_warning(_Type) { } + +template +struct _STL_CONVERT_ERROR { + static void + __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) { + _TypeY __y = __x; + __sink_unused_warning(__y); + } +}; + + +template struct __check_equal { }; + +template +struct _STL_SAME_TYPE_ERROR { + static void + __type_X_not_same_as_type_Y(_TypeX , _TypeY ) { + __check_equal<_TypeX> t1 = __check_equal<_TypeY>(); + } +}; + + +// Some Functon Object Checks + +template +struct _STL_GENERATOR_ERROR { + static _Ret __generator_requirement_violation(_Func& __f) { + return __f(); + } +}; + +template +struct _STL_GENERATOR_ERROR<_Func, void> { + static void __generator_requirement_violation(_Func& __f) { + __f(); + } +}; + + +template +struct _STL_UNARY_FUNCTION_ERROR { + static _Ret + __unary_function_requirement_violation(_Func& __f, + const _Arg& __arg) { + return __f(__arg); + } +}; + +template +struct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> { + static void + __unary_function_requirement_violation(_Func& __f, + const _Arg& __arg) { + __f(__arg); + } +}; + +template +struct _STL_BINARY_FUNCTION_ERROR { + static _Ret + __binary_function_requirement_violation(_Func& __f, + const _First& __first, + const _Second& __second) { + return __f(__first, __second); + } +}; + +template +struct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> { + static void + __binary_function_requirement_violation(_Func& __f, + const _First& __first, + const _Second& __second) { + __f(__first, __second); + } +}; + + +#define _STLP_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \ +template \ +struct _STL_BINARY##_NAME##_ERROR { \ + static _Ret \ + __const_binary_operator_requirement_violation(const _First& __first, \ + const _Second& __second) { \ + return __first _OP __second; \ + } \ + static _Ret \ + __binary_operator_requirement_violation(_First& __first, \ + _Second& __second) { \ + return __first _OP __second; \ + } \ +} + +_STLP_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL); +_STLP_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL); +_STLP_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN); +_STLP_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL); +_STLP_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN); +_STLP_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL); +_STLP_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS); +_STLP_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES); +_STLP_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE); +_STLP_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT); +_STLP_DEFINE_BINARY_OP_CHECK(%, _OP_MOD); +// ... + +// TODO, add unary operators (prefix and postfix) + +/* + The presence of this class is just to trick EDG into displaying + these error messages before any other errors. Without the + classes, the errors in the functions get reported after + other class errors deep inside the library. The name + choice just makes for an eye catching error message :) + */ +struct _STL_ERROR { + + template + static _Type + __default_constructor_requirement_violation(_Type) { + return _Type(); + } + template + static _Type + __assignment_operator_requirement_violation(_Type __a) { + __a = __a; + return __a; + } + template + static _Type + __copy_constructor_requirement_violation(_Type __a) { + _Type __c(__a); + return __c; + } + template + static _Type + __const_parameter_required_for_copy_constructor(_Type /* __a */, + const _Type& __b) { + _Type __c(__b); + return __c; + } + template + static _Type + __const_parameter_required_for_assignment_operator(_Type __a, + const _Type& __b) { + __a = __b; + return __a; + } + template + static _Type + __less_than_comparable_requirement_violation(_Type __a, _Type __b) { + if (__a < __b || __a > __b || __a <= __b || __a >= __b) return __a; + return __b; + } + template + static _Type + __equality_comparable_requirement_violation(_Type __a, _Type __b) { + if (__a == __b || __a != __b) return __a; + return __b; + } + template + static void + __dereference_operator_requirement_violation(_Iterator __i) { + __sink_unused_warning(*__i); + } + template + static void + __dereference_operator_and_assignment_requirement_violation(_Iterator __i) { + *__i = *__i; + } + template + static void + __preincrement_operator_requirement_violation(_Iterator __i) { + ++__i; + } + template + static void + __postincrement_operator_requirement_violation(_Iterator __i) { + __i++; + } + template + static void + __predecrement_operator_requirement_violation(_Iterator __i) { + --__i; + } + template + static void + __postdecrement_operator_requirement_violation(_Iterator __i) { + __i--; + } + template + static void + __postincrement_operator_and_assignment_requirement_violation(_Iterator __i, + _Type __t) { + *__i++ = __t; + } + template + static _Iterator + __iterator_addition_assignment_requirement_violation(_Iterator __i, + _Distance __n) { + __i += __n; + return __i; + } + template + static _Iterator + __iterator_addition_requirement_violation(_Iterator __i, _Distance __n) { + __i = __i + __n; + __i = __n + __i; + return __i; + } + template + static _Iterator + __iterator_subtraction_assignment_requirement_violation(_Iterator __i, + _Distance __n) { + __i -= __n; + return __i; + } + template + static _Iterator + __iterator_subtraction_requirement_violation(_Iterator __i, _Distance __n) { + __i = __i - __n; + return __i; + } + template + static _Distance + __difference_operator_requirement_violation(_Iterator __i, _Iterator __j, + _Distance __n) { + __n = __i - __j; + return __n; + } + template + static _Type + __element_access_operator_requirement_violation(_Exp __x, _Type*, + _Distance __n) { + return __x[__n]; + } + template + static void + __element_assignment_operator_requirement_violation(_Exp __x, + _Type* __t, + _Distance __n) { + __x[__n] = *__t; + } + +}; /* _STL_ERROR */ + +/* Associated Type Requirements */ + +_STLP_BEGIN_NAMESPACE +template struct iterator_traits; +_STLP_END_NAMESPACE + +template +struct __value_type_type_definition_requirement_violation { + typedef typename __STD::iterator_traits<_Iter>::value_type value_type; +}; + +template +struct __difference_type_type_definition_requirement_violation { + typedef typename __STD::iterator_traits<_Iter>::difference_type + difference_type; +}; + +template +struct __reference_type_definition_requirement_violation { + typedef typename __STD::iterator_traits<_Iter>::reference reference; +}; + +template +struct __pointer_type_definition_requirement_violation { + typedef typename __STD::iterator_traits<_Iter>::pointer pointer; +}; + +template +struct __iterator_category_type_definition_requirement_violation { + typedef typename __STD::iterator_traits<_Iter>::iterator_category + iterator_category; +}; + +/* Assignable Requirements */ + + +template +struct _Assignable_concept_specification { + static void _Assignable_requirement_violation(_Type __a) { + _STL_ERROR::__assignment_operator_requirement_violation(__a); + _STL_ERROR::__copy_constructor_requirement_violation(__a); + _STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a); + _STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a); + } +}; + +/* DefaultConstructible Requirements */ + + +template +struct _DefaultConstructible_concept_specification { + static void _DefaultConstructible_requirement_violation(_Type __a) { + _STL_ERROR::__default_constructor_requirement_violation(__a); + } +}; + +/* EqualityComparable Requirements */ + +template +struct _EqualityComparable_concept_specification { + static void _EqualityComparable_requirement_violation(_Type __a) { + _STL_ERROR::__equality_comparable_requirement_violation(__a, __a); + } +}; + +/* LessThanComparable Requirements */ +template +struct _LessThanComparable_concept_specification { + static void _LessThanComparable_requirement_violation(_Type __a) { + _STL_ERROR::__less_than_comparable_requirement_violation(__a, __a); + } +}; + +/* TrivialIterator Requirements */ + +template +struct _TrivialIterator_concept_specification { +static void +_TrivialIterator_requirement_violation(_TrivialIterator __i) { + typedef typename + __value_type_type_definition_requirement_violation<_TrivialIterator>:: + value_type __T; + // Refinement of Assignable + _Assignable_concept_specification<_TrivialIterator>:: + _Assignable_requirement_violation(__i); + // Refinement of DefaultConstructible + _DefaultConstructible_concept_specification<_TrivialIterator>:: + _DefaultConstructible_requirement_violation(__i); + // Refinement of EqualityComparable + _EqualityComparable_concept_specification<_TrivialIterator>:: + _EqualityComparable_requirement_violation(__i); + // Valid Expressions + _STL_ERROR::__dereference_operator_requirement_violation(__i); +} +}; + +template +struct _Mutable_TrivialIterator_concept_specification { +static void +_Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) { + _TrivialIterator_concept_specification<_TrivialIterator>:: + _TrivialIterator_requirement_violation(__i); + // Valid Expressions + _STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i); +} +}; + +/* InputIterator Requirements */ + +template +struct _InputIterator_concept_specification { +static void +_InputIterator_requirement_violation(_InputIterator __i) { + // Refinement of TrivialIterator + _TrivialIterator_concept_specification<_InputIterator>:: + _TrivialIterator_requirement_violation(__i); + // Associated Types + __difference_type_type_definition_requirement_violation<_InputIterator>(); + __reference_type_definition_requirement_violation<_InputIterator>(); + __pointer_type_definition_requirement_violation<_InputIterator>(); + __iterator_category_type_definition_requirement_violation<_InputIterator>(); + // Valid Expressions + _STL_ERROR::__preincrement_operator_requirement_violation(__i); + _STL_ERROR::__postincrement_operator_requirement_violation(__i); +} +}; + +/* OutputIterator Requirements */ + +template +struct _OutputIterator_concept_specification { +static void +_OutputIterator_requirement_violation(_OutputIterator __i) { + // Refinement of Assignable + _Assignable_concept_specification<_OutputIterator>:: + _Assignable_requirement_violation(__i); + // Associated Types + __iterator_category_type_definition_requirement_violation<_OutputIterator>(); + // Valid Expressions + _STL_ERROR::__dereference_operator_requirement_violation(__i); + _STL_ERROR::__preincrement_operator_requirement_violation(__i); + _STL_ERROR::__postincrement_operator_requirement_violation(__i); + _STL_ERROR:: + __postincrement_operator_and_assignment_requirement_violation(__i, *__i); +} +}; + +/* ForwardIterator Requirements */ + +template +struct _ForwardIterator_concept_specification { +static void +_ForwardIterator_requirement_violation(_ForwardIterator __i) { + // Refinement of InputIterator + _InputIterator_concept_specification<_ForwardIterator>:: + _InputIterator_requirement_violation(__i); +} +}; + +template +struct _Mutable_ForwardIterator_concept_specification { +static void +_Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) { + _ForwardIterator_concept_specification<_ForwardIterator>:: + _ForwardIterator_requirement_violation(__i); + // Refinement of OutputIterator + _OutputIterator_concept_specification<_ForwardIterator>:: + _OutputIterator_requirement_violation(__i); +} +}; + +/* BidirectionalIterator Requirements */ + +template +struct _BidirectionalIterator_concept_specification { +static void +_BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) { + // Refinement of ForwardIterator + _ForwardIterator_concept_specification<_BidirectionalIterator>:: + _ForwardIterator_requirement_violation(__i); + // Valid Expressions + _STL_ERROR::__predecrement_operator_requirement_violation(__i); + _STL_ERROR::__postdecrement_operator_requirement_violation(__i); +} +}; + +template +struct _Mutable_BidirectionalIterator_concept_specification { +static void +_Mutable_BidirectionalIterator_requirement_violation( + _BidirectionalIterator __i) +{ + _BidirectionalIterator_concept_specification<_BidirectionalIterator>:: + _BidirectionalIterator_requirement_violation(__i); + // Refinement of mutable_ForwardIterator + _Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>:: + _Mutable_ForwardIterator_requirement_violation(__i); + typedef typename + __value_type_type_definition_requirement_violation< + _BidirectionalIterator>::value_type __T; + typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0; + // Valid Expressions + _STL_ERROR:: + __postincrement_operator_and_assignment_requirement_violation(__i, + *__tmp_ptr); +} +}; + +/* RandomAccessIterator Requirements */ + +template +struct _RandomAccessIterator_concept_specification { +static void +_RandomAccessIterator_requirement_violation(_RandAccIter __i) { + // Refinement of BidirectionalIterator + _BidirectionalIterator_concept_specification<_RandAccIter>:: + _BidirectionalIterator_requirement_violation(__i); + // Refinement of LessThanComparable + _LessThanComparable_concept_specification<_RandAccIter>:: + _LessThanComparable_requirement_violation(__i); + typedef typename + __value_type_type_definition_requirement_violation<_RandAccIter> + ::value_type + value_type; + typedef typename + __difference_type_type_definition_requirement_violation<_RandAccIter> + ::difference_type + _Dist; + typedef typename _Mutable_trait<_Dist>::_Type _MutDist; + + // Valid Expressions + _STL_ERROR::__iterator_addition_assignment_requirement_violation(__i, + _MutDist()); + _STL_ERROR::__iterator_addition_requirement_violation(__i, + _MutDist()); + _STL_ERROR:: + __iterator_subtraction_assignment_requirement_violation(__i, + _MutDist()); + _STL_ERROR::__iterator_subtraction_requirement_violation(__i, + _MutDist()); + _STL_ERROR::__difference_operator_requirement_violation(__i, __i, + _MutDist()); + typename _Mutable_trait::_Type* __dummy_ptr = 0; + _STL_ERROR::__element_access_operator_requirement_violation(__i, + __dummy_ptr, + _MutDist()); +} +}; + +template +struct _Mutable_RandomAccessIterator_concept_specification { +static void +_Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i) +{ + _RandomAccessIterator_concept_specification<_RandAccIter>:: + _RandomAccessIterator_requirement_violation(__i); + // Refinement of mutable_BidirectionalIterator + _Mutable_BidirectionalIterator_concept_specification<_RandAccIter>:: + _Mutable_BidirectionalIterator_requirement_violation(__i); + typedef typename + __value_type_type_definition_requirement_violation<_RandAccIter> + ::value_type + value_type; + typedef typename + __difference_type_type_definition_requirement_violation<_RandAccIter> + ::difference_type + _Dist; + + typename _Mutable_trait::_Type* __tmp_ptr = 0; + // Valid Expressions + _STL_ERROR::__element_assignment_operator_requirement_violation(__i, + __tmp_ptr, _Dist()); +} +}; + +#define _STLP_TYPEDEF_REQUIREMENT(__REQUIREMENT) \ +template \ +struct __##__REQUIREMENT##__typedef_requirement_violation { \ + typedef typename Type::__REQUIREMENT __REQUIREMENT; \ +}; + +_STLP_TYPEDEF_REQUIREMENT(value_type); +_STLP_TYPEDEF_REQUIREMENT(difference_type); +_STLP_TYPEDEF_REQUIREMENT(size_type); +_STLP_TYPEDEF_REQUIREMENT(reference); +_STLP_TYPEDEF_REQUIREMENT(const_reference); +_STLP_TYPEDEF_REQUIREMENT(pointer); +_STLP_TYPEDEF_REQUIREMENT(const_pointer); + + +template +struct _Allocator_concept_specification { +static void +_Allocator_requirement_violation(_Alloc __a) { + // Refinement of DefaultConstructible + _DefaultConstructible_concept_specification<_Alloc>:: + _DefaultConstructible_requirement_violation(__a); + // Refinement of EqualityComparable + _EqualityComparable_concept_specification<_Alloc>:: + _EqualityComparable_requirement_violation(__a); + // Associated Types + __value_type__typedef_requirement_violation<_Alloc>(); + __difference_type__typedef_requirement_violation<_Alloc>(); + __size_type__typedef_requirement_violation<_Alloc>(); + __reference__typedef_requirement_violation<_Alloc>(); + __const_reference__typedef_requirement_violation<_Alloc>(); + __pointer__typedef_requirement_violation<_Alloc>(); + __const_pointer__typedef_requirement_violation<_Alloc>(); + typedef typename _Alloc::value_type _Type; + _STLP_REQUIRES_SAME_TYPE(typename _Alloc::rebind<_Type>::other, _Alloc); +} +}; + +#endif /* _STLP_USE_CONCEPT_CHECKS */ + +#endif /* __CONCEPT_CHECKS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/config/_aix.h b/sdk/tlibstdcxx/stlport/stl/config/_aix.h new file mode 100644 index 0000000000..45ea8b6fd7 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_aix.h @@ -0,0 +1,3 @@ +#define _STLP_PLATFORM "AIX" + +#define _STLP_USE_UNIX_IO diff --git a/sdk/tlibstdcxx/stlport/stl/config/_apcc.h b/sdk/tlibstdcxx/stlport/stl/config/_apcc.h new file mode 100644 index 0000000000..7b4e1397c2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_apcc.h @@ -0,0 +1,30 @@ +// STLport config file for Apogee 4.x + +#define _STLP_COMPILER "Apogee" + +#define _STLP_NO_NEW_NEW_HEADER 1 +#define _STLP_HAS_NO_NEW_C_HEADERS 1 + +#if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) +# define _STLP_RAND48 1 +#endif +// # define _STLP_RAND48 1 +#define _STLP_LONG_LONG long long +#define _STLP_NO_BAD_ALLOC 1 +#define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +#define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 +// # define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 1 +#define _STLP_NO_EXCEPTION_HEADER 1 + +#undef _STLP_LINK_TIME_INSTANTIATION +#define _STLP_LINK_TIME_INSTANTIATION 1 + +#ifdef __STDLIB +# undef _STLP_NO_NEW_C_HEADERS +# undef _STLP_NO_NEW_NEW_HEADER +# undef _STLP_NO_BAD_ALLOC +# undef _STLP_LONG_LONG +#else +# undef _STLP_NO_EXCEPTION_SPEC +# define _STLP_NO_EXCEPTION_SPEC 1 +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_apple.h b/sdk/tlibstdcxx/stlport/stl/config/_apple.h new file mode 100644 index 0000000000..899ed143ac --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_apple.h @@ -0,0 +1,118 @@ +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly + */ + +/* common configuration settings for Apple MPW MrCpp / SCpp */ + +#define _STLP_COMPILER "spec me!" + +#if defined(__MRC__) && __MRC__ < 0x500 +# error Apple's MPW MrCpp v.5.0.0 or better compiler required +#endif +#if defined(__SC__) && __SC__ < 0x890 +# error Apple's MPW SCpp v.8.9.0 or better compiler required +#endif + +/* TODO: Check that this config is necessary for all compiler versions. + * It is here for historical reasons for the moment. + */ +#define _STLP_NO_CONTAINERS_EXTENSION + +#ifdef qMacApp +# ifndef __CONDITIONALMACROS__ /* skip including ConditionalMacros_AC.h if ConditionalMacros.h is already included */ +# include +# include +# include +# define _STLP_FILE__ _FILE_AC +# define _STLP_DEBUG_MESSAGE +# define __stl_debug_message ProgramBreak_AC +# include +# endif +# include +#else +# include +# include +#endif + +#define _STLP_UINT32_T UInt32 +typedef int wint_t; + +#ifndef TYPE_BOOL +# error must be included. (TYPE_BOOL) +#endif +#if !TYPE_BOOL +# define _STLP_NO_BOOL +# define _STLP_DONT_USE_BOOL_TYPEDEF +#endif + +#ifndef TYPE_LONGLONG +# error must be included. (TYPE_LONGLONG) +#endif +#if TYPE_LONGLONG +# define _STLP_LONG_LONG long long +#endif + +#if !__option(exceptions) +# define _STLP_HAS_NO_EXCEPTIONS +#endif + +#define _STLP_DEBUG_MESSAGE_POST DebugStr("\pSTL diagnosis issued. See 'stderr' for detail."); +#define _STLP_ASSERT_MSG_TRAILER " " + +#ifdef _STLP_DEBUG +# define _STLP_THROW(x) (DebugStr("\pSTL is about to throw exception: "#x),throw x) +#endif + +#if defined(__MRC__) +# ifndef __spillargs +# define __spillargs 1 // MrCpp requires this symbol to be defined as 1 to properly handle va_start; ref.[ file stdarg.h; line 26 ] +# endif +#endif + +#if defined(__SC__) +#define _STLP_VENDOR_LONG_DOUBLE_MATH //*TY 12/03/2000 - SCpp's native math type is long double +#endif + +#ifndef _STLP_NATIVE_INCLUDE_PATH +# if __option(unix_includes) +# define _STLP_NATIVE_INCLUDE_PATH ../CIncludes // expects the alias to {CIncludes} under the same folder as {STL} +# else +# define _STLP_NATIVE_INCLUDE_PATH ::CIncludes // expects the alias to {CIncludes} under the same folder as {STL} +# endif +#endif +#if !defined(_STLP_MAKE_HEADER) +# if !__option(unix_includes) +# define _STLP_MAKE_HEADER(path, header) // Mac uses ":" for directory delimiter +# endif +#endif + +# define _STLD _DBG // to keep the length of generated symbols within the compiler limitation + +#define _STLP_USE_STDIO_IO 1 //*TY 02/24/2000 - see also ; ref.[ file _fstream.h; line 36 ] +#define _STLP_NO_THREADS //*TY 12/17/2000 - multi-thread capability not explored, yet. +#undef _REENTRANT //*ty 11/24/2001 - to make sure no thread facility is activated +#define _NOTHREADS //*ty 12/07/2001 - + +// native library limitations +#define _STLP_VENDOR_GLOBAL_STD // mpw's c++ libs do not utilize namespace std yet +#define _STLP_NO_BAD_ALLOC // known limitation +#define _STLP_HAS_NO_NEW_C_HEADERS // known limitation +#define _STLP_NO_NEW_NEW_HEADER // known limitation +#define _STLP_NO_NATIVE_MBSTATE_T // known limitation +#define _STLP_NO_NATIVE_WIDE_FUNCTIONS // known limitation +#define _STLP_NO_NATIVE_WIDE_STREAMS // known limitation +#define _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT // known limitation +#define _STLP_BROKEN_EXCEPTION_CLASS // known limitation + +// compiler limitations +# define _STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS + +# define _STLP_MPWFIX_TRY try{ //*TY 06/01/2000 - exception handling bug workaround +# define _STLP_MPWFIX_CATCH }catch(...){throw;} //*TY 06/01/2000 - exception handling bug workaround +# define _STLP_MPWFIX_CATCH_ACTION(action) }catch(...){action;throw;} //*TY 06/01/2000 - exception handling bug workaround +# define _STLP_THROW_RETURN_BUG // known limitation +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION // known limitation +# define _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX // known limitation +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER // known limitation +# define _STLP_NO_RELOPS_NAMESPACE // known limitation +// end of stl_apple.h diff --git a/sdk/tlibstdcxx/stlport/stl/config/_as400.h b/sdk/tlibstdcxx/stlport/stl/config/_as400.h new file mode 100644 index 0000000000..28d960b77f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_as400.h @@ -0,0 +1,55 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +// AS/400 C++ config + +# ifdef _REENTRANT +# define _PTHREADS +# endif + +# define _STLP_NO_NEW_NEW_HEADER 1 + +# define _STLP_NO_BOOL +# define _STLP_LIMITED_DEFAULT_TEMPLATES + +# define _STLP_HAS_NO_NAMESPACES +# define _STLP_NEED_TYPENAME +# define _STLP_NEED_EXPLICIT +# define _STLP_HAS_NO_EXCEPTIONS +# define _STLP_NO_EXCEPTION_SPEC +# define _STLP_NO_ARROW_OPERATOR +# define _STLP_NO_NEW_STYLE_CASTS + +# define _STLP_NEED_MUTABLE +# define _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX +# define _STLP_NO_BAD_ALLOC +# define _STLP_NO_MEMBER_TEMPLATES +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD +# define _STLP_NO_QUALIFIED_FRIENDS +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER + +# define _STLP_NO_METHOD_SPECIALIZATION +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS + +// # define _STLP_NO_EXCEPTION_HEADER + +# define _STLP_HAS_NO_NEW_C_HEADERS + +# define _STLP_STATIC_CONST_INIT_BUG +# define _STLP_THROW_RETURN_BUG +# define _STLP_LINK_TIME_INSTANTIATION +# define _STLP_NO_TEMPLATE_CONVERSIONS + +# define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 +# define _STLP_TRIVIAL_DESTRUCTOR_BUG 1 + +# if defined(_LONG_LONG) +# define _STLP_LONG_LONG long long +# endif +# if defined(_PTHREADS) +# define _MULTI_THREADED +# endif +// fbp : to fix __partition() problem +# define _STLP_NONTEMPL_BASE_MATCH_BUG 1 diff --git a/sdk/tlibstdcxx/stlport/stl/config/_auto_link.h b/sdk/tlibstdcxx/stlport/stl/config/_auto_link.h new file mode 100644 index 0000000000..8898c55588 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_auto_link.h @@ -0,0 +1,61 @@ +/* We do not use auto link feature when: + * - user asked not to use it (_STLP_DONT_USE_AUTO_LINK) + * - STLport is used only as a STL library (_STLP_NO_IOSTREAMS || _STLP_USE_NO_IOSTREAMS) + * - we are building a C translation unit, STLport is a C++ Standard library implementation + */ +#if !defined (__BUILDING_STLPORT) && !defined (_STLP_DONT_USE_AUTO_LINK) && \ + !defined (_STLP_NO_IOSTREAMS) && !defined (_STLP_USE_NO_IOSTREAMS) && \ + defined (__cplusplus) + +# define _STLP_STRINGIZE(X) _STLP_STRINGIZE_AUX(X) +# define _STLP_STRINGIZE_AUX(X) #X + +# if defined (_STLP_DEBUG) +# define _STLP_LIB_OPTIM_MODE "stld" +# elif defined (_DEBUG) +# define _STLP_LIB_OPTIM_MODE "d" +# else +# define _STLP_LIB_OPTIM_MODE "" +# endif + +# if defined (_STLP_LIB_NAME_MOTIF) +# define _STLP_LIB_MOTIF "_"_STLP_LIB_NAME_MOTIF +# else +# define _STLP_LIB_MOTIF "" +# endif + +# if defined (_STLP_USE_DYNAMIC_LIB) +# if defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# define _STLP_LIB_TYPE "_x" +# else +# define _STLP_LIB_TYPE "" +# endif +# else +# if defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# define _STLP_LIB_TYPE "_statix" +# else +# define _STLP_LIB_TYPE "_static" +# endif +# endif + +# if defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_VERSION_STR "."_STLP_STRINGIZE(_STLPORT_MAJOR)"."_STLP_STRINGIZE(_STLPORT_MINOR) +# else +# define _STLP_VERSION_STR "" +# endif + +# define _STLP_STLPORT_LIB "stlport"_STLP_LIB_OPTIM_MODE""_STLP_LIB_TYPE""_STLP_LIB_MOTIF""_STLP_VERSION_STR".lib" + +# if defined (_STLP_VERBOSE) +# pragma message ("STLport: Auto linking to "_STLP_STLPORT_LIB) +# endif +# pragma comment (lib, _STLP_STLPORT_LIB) + +# undef _STLP_STLPORT_LIB +# undef _STLP_LIB_OPTIM_MODE +# undef _STLP_LIB_TYPE +# undef _STLP_STRINGIZE_AUX +# undef _STLP_STRINGIZE + +#endif /* _STLP_DONT_USE_AUTO_LINK */ + diff --git a/sdk/tlibstdcxx/stlport/stl/config/_bc.h b/sdk/tlibstdcxx/stlport/stl/config/_bc.h new file mode 100644 index 0000000000..e3802dc090 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_bc.h @@ -0,0 +1,138 @@ +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly */ + +#define _STLP_COMPILER "Borland" + +#if (__BORLANDC__ < 0x551) +# error - Borland compilers below version 5.5.1 not supported. +#endif + +#pragma defineonoption _STLP_NO_RTTI -RT- + +#define _STLP_DONT_SUP_DFLT_PARAM + +#if (__BORLANDC__ >= 0x580) +# define _STLP_HAS_INCLUDE_NEXT +# define _STLP_NATIVE_HEADER(header) <../include/##header> +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../include/dinkumware/##header> +# define _STLP_NO_NEW_C_HEADERS +# define _STLP_NO_FORCE_INSTANTIATE +#endif + +#if (__BORLANDC__ >= 0x570) && (__BORLANDC__ < 0x580) +# define _STLP_NO_NEW_C_HEADERS +# define _STLP_NO_FORCE_INSTANTIATE +# define _STLP_DEF_CONST_DEF_PARAM_BUG +# define _STLP_USE_DEFAULT_FILE_OFFSET + +# if defined (__cplusplus) +# define _STLP_NATIVE_CPP_C_INCLUDE_PATH ../include/c++/ ## GCC_VERSION +# define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH ../include/c++/ ## GCC_VERSION +# endif + +# undef _SYS_CDEFS_H +# include + +# ifdef __MT__ +# define _PTHREADS +# if !defined (_RTLDLL) +# define _STLP_DONT_USE_PTHREAD_SPINLOCK +# endif +# else +# define _NOTHREADS +# endif + +# pragma defineonoption _CPPUNWIND -xd +# define _STLP_NO_EXCEPTION_HEADER +# define _STLP_DONT_USE_EXCEPTIONS +#endif + +#if (__BORLANDC__ >= 0x560) && (__BORLANDC__ < 0x570) +# define _USE_OLD_RW_STL +#endif + +#if (__BORLANDC__ >= 0x560) +# if !defined (__BUILDING_STLPORT) +# define NOWINBASEINTERLOCK +# endif +# define _STLP_LANG_INVARIANT_DEFINED +#endif + +#if (__BORLANDC__ < 0x590) +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER +# define _STLP_DLLEXPORT_NEEDS_PREDECLARATION + // problems +# define _STLP_MEMBER_SPECIALIZATION_BUG 1 +# ifdef __cplusplus +# define _STLP_TR1 _STLP_STD_NAME::tr1:: +# endif +#endif + +#if (__BORLANDC__ < 0x564) +# define _STLP_QUALIFIED_SPECIALIZATION_BUG +# define _STLP_NO_MOVE_SEMANTIC +#endif + +#define _STLP_DONT_USE_PRIV_NAMESPACE +#define _STLP_NO_TYPENAME_BEFORE_NAMESPACE +#define _STLP_NO_VENDOR_STDLIB_L +#define _STLP_NO_VENDOR_MATH_F +#define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 + +#if (__BORLANDC__ < 0x570) || (__BORLANDC__ >= 0x580) +#define _STLP_NO_NATIVE_MBSTATE_T +#undef _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT +#endif + +#if (__BORLANDC__ < 0x580) && !defined (_RTLDLL) +# define _UNCAUGHT_EXCEPTION 1 +#endif + +// problem +#define _STLP_STATIC_CONST_INIT_BUG + +#define _STLP_HAS_SPECIFIC_PROLOG_EPILOG 1 + +#define _STLP_LONG_LONG __int64 + +// auto enable thread safety and exceptions: +#ifndef _CPPUNWIND +# define _STLP_HAS_NO_EXCEPTIONS +#endif + +#if defined (__MT__) && !defined (_NOTHREADS) +# define _STLP_THREADS +#endif + +#define _STLP_EXPORT_DECLSPEC __declspec(dllexport) +#define _STLP_IMPORT_DECLSPEC __declspec(dllimport) + +#define _STLP_CLASS_EXPORT_DECLSPEC __declspec(dllexport) +#define _STLP_CLASS_IMPORT_DECLSPEC __declspec(dllimport) + +#if defined (_DLL) +# define _STLP_DLL +#endif +#if defined (_RTLDLL) +# define _STLP_RUNTIME_DLL +#endif +#include +#undef _STLP_RUNTIME_DLL +#undef _STLP_DLL + +#if defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_USE_DECLSPEC 1 +# if defined (__BUILDING_STLPORT) +# define _STLP_CALL __cdecl __export +# else +# define _STLP_CALL __cdecl +# endif +#else +# define _STLP_CALL __cdecl +#endif + +#if !defined (__linux__) +# include +#endif + +#include diff --git a/sdk/tlibstdcxx/stlport/stl/config/_como.h b/sdk/tlibstdcxx/stlport/stl/config/_como.h new file mode 100644 index 0000000000..6076f88084 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_como.h @@ -0,0 +1,207 @@ + +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +#define _STLP_COMPILER "Comeau" + +#include + +#define _STLP_UINT32_T unsigned int + +#define _STLP_HAS_NO_NEW_C_HEADERS +// #define _STLP_VENDOR_GLOBAL_EXCEPT_STD +#define _STLP_LONG_LONG long long + + +// +// ADDITIONS FOR COMEAU C++, made by Comeau Computing. +// We can be reached through comeau@comeaucomputing.com +// You shouldn't need to change anything below here for Comeau C++. +// If you do, please tell us at comeau@comeaucomputing.com +// +// Changes made here, AND THROUGH ALL FILES, based upon the __COMO__ macro +// (and SIMILAR NAMES INVOLVING COMO).... no doubt some of this will +// change as SGI integrates the changes into their code base since +// some changes are not really Comeau C++ specific, but required to +// make the SGI code compliant with Standard C++). +// +// Testing was done with Comeau C++ 4.2.44 and 4.2.45.2. Changes were made for +// both Comeau relaxed mode and Comeau strict mode, especially for end user code +// (that is, some of the .cxx files cannot compile in strict mode, because they +// contain extensions to Standard C++, however their object code forms can +// be used once compiled in relaxed mode, even if the end user code uses +// strict mode). +// +// These changes may also work for some earlier versions of Comeau C++, +// though we have not tested them. +// +// Actual mods made under RedHat 6.1 LINUX, should be ok with SuSE too and +// other LINUX's, and older Caldera LINUX, Solaris/SPARC, SunOS, SCO UNIX, +// and NetBSD. Other platforms may be added. Comeau will also perform +// custom ports for you. +// +// Check libcomo details at http://www.comeaucomputing.com/libcomo and +// http://www.comeaucomputing.com +// +// History of Comeau changes (this is rough, as work was often going on in parallel): +// BETA1 July 14, 2000, Initial port for RedHat 6.1 INTEL/ELF +// BETA2 Aug 4, 2000, Stronger RedHat support +// Support for Comeau strict mode for end user code +// BETA3 Aug 22, 2000, Support for other LINUX/INTEL/ELF's, including older ones +// BETA4 Sept 2, 2000, Initial support for SCO UNIX + other UNIX x86 SVR3's +// Stronger support for end user Comeau strict mode +// BETA5 Oct 5, 2000, Initial support for Solaris/SPARC +// More SCO support (though still incomplete) +// BETA6 Feb 5, 2001, Minor mods to accomodate Comeau C++ 4.2.45.1 +// BETA7 Mar 13, 2001, Verified with Comeau C++ 4.2.45.2 +// Minor NetBSD support +// BETA8 Apr 1. 2001, Initial support for SunOS/SPARC +// BETA9 Apr 7, 2001, Stronger SCO support + other UNIX x86 SVR3's +// Mods for an fpos_t problem for some LINUXes +// Mods since Destroy did not work in strict mode +// BETA10 Apr 12. 2001, Stronger NetBSD support +// +// PLANNED: +// BETAx TBA TBA, 2001, NetBSD, UNIXWARE, and Windows support expected +// + + +#ifdef __linux__ + +# define _STLP_NO_NATIVE_MBSTATE_T 1 +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 +# define _STLP_NO_NATIVE_WIDE_STREAMS 1 +# define _STLP_NO_LONG_DOUBLE 1 + +// Comeau C++ under LINUX/INTEL/ELF +// Preprocess away "long long" routines for now, even in relaxed mode +# define __wcstoull_internal_defined 1 +# define __wcstoll_internal_defined 1 + +#endif /* __COMO__ under __linux__ */ + +#ifdef __USING_x86SVR3x_WITH_COMO /* SCO et al */ +/* UNIX 386+ SVR3 mods made with __USING_x86SVR3x_WITH_COMO + in other sources, not here */ +# define atan2l atan2 +# define cosl cos +# define sinl sin +# define sqrtl sqrt +# include + inline long double expl(long double arg) { return exp(arg); } + inline long double logl(long double arg) { return log(arg); } +# define log10l log10 + +# define sinhl sinh +# define coshl cosh +# define fabsl fabs +namespace std { + inline int min(int a, int b) { return a>b ? b : a; } +} +#endif + +#ifdef sun +// Comeau C++ under Solaris/SPARC or SunOS + +#ifdef solarissparc +#define __USING_SOLARIS_SPARC_WITH_COMO /* show this in the source when grep'ing for COMO */ +// Note comowchar.h for Solaris/SPARC wchar stuff + +#include +# define sinf sin +# define sinl sin +# define sinhf sinh +# define sinhl sinh +# define cosf cos +# define cosl cos +# define coshf cosh +# define coshl cosh +# define atan2l atan2 +# define atan2f atan2 + inline float logf(float arg) { return log(arg); } + inline long double logl(long double arg) { return log(arg); } +# define log10f log10 +# define log10l log10 +# define expf exp + inline long double expl(long double arg) { return exp(arg); } +# define sqrtf sqrt +# define sqrtl sqrt +# define fabsf fabs +# define fabsl fabs +#else +#define __USING_SUNOS_WITH_COMO + +#define __unix 1 +#define __EXTENSIONS__ /* This might create undue noise somewhere */ +#endif +#endif /* sun */ + +#if defined(__NetBSD__) +// From non-como #ifdef __GNUC__ above +#undef _STLP_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE +#define __unix 1 + +#include +// Some joker #define'd __END_DECLS as }; +#undef __END_DECLS +#define __END_DECLS } + +// prob +#include +#undef __RENAME +#define __RENAME(x) + +#define wchar_t __COMO_WCHAR_T +#include +#undef wchar_t + +#include +# ifdef BORIS_DISABLED +# define atan2l atan2 +# define cosl cos +# define sinl sin +# define sqrtl sqrt + inline long double expl(long double arg) { return exp(arg); } + inline long double logl(long double arg) { return log(arg); } +# define log10l log10 +# define sinhl sinh +# define coshl cosh +# define fabsl fabs +# endif +#endif /* __NetBSD__ under __COMO__ */ + +// Shouldn't need to change anything below here for Comeau C++ +// If so, tell us at comeau@comeaucomputing.com + +#define _STLP_NO_DRAND48 + +#define _STLP_PARTIAL_SPECIALIZATION_SYNTAX +#define _STLP_NO_USING_CLAUSE_IN_CLASS + +#if __COMO_VERSION__ < 4300 +#if __COMO_VERSION__ >= 4245 +#define _STLP_NO_EXCEPTION_HEADER /**/ + // Is this needed? +# include +#endif +#define _STLP_NO_BAD_ALLOC /**/ +#define _STLP_USE_AUTO_PTR_CONVERSIONS /**/ +#endif + +// this one is true only with MS +# if defined (_MSC_VER) +# define _STLP_WCHAR_T_IS_USHORT 1 +# if _MSC_VER <= 1200 +# define _STLP_VENDOR_GLOBAL_CSTD +# endif +# if _MSC_VER < 1100 +# define _STLP_NO_BAD_ALLOC 1 +# define _STLP_NO_EXCEPTION_HEADER 1 +# define _STLP_NO_NEW_NEW_HEADER 1 +# define _STLP_USE_NO_IOSTREAMS 1 +# endif +# endif + +// # define __EDG_SWITCHES + + diff --git a/sdk/tlibstdcxx/stlport/stl/config/_cray.h b/sdk/tlibstdcxx/stlport/stl/config/_cray.h new file mode 100644 index 0000000000..55327c11da --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_cray.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#define _STLP_COMPILER "CC" + +// Mostly correct guess, change it for Alpha (and other environments +// that has 64-bit "long") +# define _STLP_UINT32_T unsigned long + +// Uncomment if long long is available +# define _STLP_LONG_LONG long long + +// Uncomment this if your compiler can't inline while(), for() +# define _STLP_LOOP_INLINE_PROBLEMS 1 + +// Uncomment this if your compiler does not support exceptions +// Cray C++ supports exceptions when '-h exceptions' option is user; +// therefore '-D_STLP_HAS_NO_EXCEPTIONS' must be used when '-h exceptions' +// is NOT used. +//# define _STLP_HAS_NO_EXCEPTIONS 1 + +// Delete? +// Define this if compiler lacks header +//# define _STLP_NO_EXCEPTION_HEADER 1 + +// Uncomment this if your C library has lrand48() function +# define _STLP_RAND48 1 + +// Uncomment if native new-style C library headers lile , etc are not available. +# define _STLP_HAS_NO_NEW_C_HEADERS 1 + +// uncomment if new-style headers is available +# define _STLP_NO_NEW_NEW_HEADER 1 + +// uncomment this if and other STD headers put their stuff in ::namespace, +// not std:: +# define _STLP_VENDOR_GLOBAL_STD + +// uncomment this if and the like put stuff in ::namespace, +// not std:: +# define _STLP_VENDOR_GLOBAL_CSTD + +# define _STLP_NATIVE_C_HEADER(__x) +// WARNING: Following is hardcoded to the system default C++ include files +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(__x) + + +# define _STLP_NO_NATIVE_MBSTATE_T +# define _STLP_NO_USING_FOR_GLOBAL_FUNCTIONS +//# define _STLP_VENDOR_GLOBAL_EXCEPT_STD diff --git a/sdk/tlibstdcxx/stlport/stl/config/_cygwin.h b/sdk/tlibstdcxx/stlport/stl/config/_cygwin.h new file mode 100644 index 0000000000..8610743b99 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_cygwin.h @@ -0,0 +1,9 @@ +#define _STLP_PLATFORM "Cygwin" + +#define _STLP_UNIX + +#ifndef _STLP_USE_STDIO_IO +# define _STLP_USE_UNIX_IO +#endif + +#define _STLP_LDOUBLE_96 diff --git a/sdk/tlibstdcxx/stlport/stl/config/_dec.h b/sdk/tlibstdcxx/stlport/stl/config/_dec.h new file mode 100644 index 0000000000..fc8ace7d62 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_dec.h @@ -0,0 +1,113 @@ +#define _STLP_COMPILER "Dec" + +# define _STLP_HAS_SPECIFIC_PROLOG_EPILOG + +# define _STLP_NATIVE_HEADER(header) <../cxx/##header> +# define _STLP_NATIVE_C_HEADER(x) <../include/##x> + +#if (__DECCXX_VER < 60300000) +# define _STLP_NATIVE_CPP_C_HEADER(header) <../cxx/##header> +#else +# define _STLP_NATIVE_CPP_C_HEADER(header) +#endif + +# define _STLP_NATIVE_OLD_STREAMS_HEADER(header) <../cxx/##header> +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../cxx/##header> + +/* Alpha is little-endian */ +# define _STLP_LITTLE_ENDIAN + +// collisions +# define _STLP_DONT_PUT_STLPORT_IN_STD + +#if (__DECCXX_VER < 60000000) + +/* + automatic template instantiation does not + work with namespaces ;( +*/ +# define _STLP_HAS_NO_NAMESPACES 1 + +# define _STLP_NO_NEW_NEW_HEADER 1 + +# define _STLP_NO_WCHAR_T 1 +# define _STLP_NEED_EXPLICIT 1 + +# define _STLP_NO_BOOL 1 +# define _STLP_NEED_TYPENAME 1 +# define _STLP_NO_NEW_STYLE_CASTS 1 +# define _STLP_NEED_MUTABLE 1 +# define _STLP_NO_BAD_ALLOC 1 + + +# define _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX 1 + +# define _STLP_NO_MEMBER_TEMPLATES 1 +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# define _STLP_NO_QUALIFIED_FRIENDS 1 +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 +# define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 +# define _STLP_BROKEN_USING_DIRECTIVE 1 +# define _STLP_NO_EXCEPTION_HEADER 1 +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +# define _STLP_DEF_CONST_DEF_PARAM_BUG 1 + +#endif + + +#ifndef __NO_USE_STD_IOSTREAM +/* default is to use new iostreams, anyway */ +# ifndef __USE_STD_IOSTREAM +# define __USE_STD_IOSTREAM +# endif +#endif + +/* +# ifndef __STD_STRICT_ANSI_ERRORS +# endif +*/ + +#ifndef __EXCEPTIONS +# define _STLP_HAS_NO_EXCEPTIONS 1 +#endif + +# ifdef __IMPLICIT_INCLUDE_ENABLED + +/* but, works with ours ;). */ +# define _STLP_LINK_TIME_INSTANTIATION 1 +# else +# undef _STLP_LINK_TIME_INSTANTIATION +# endif + +# if defined (__IMPLICIT_USING_STD) && !defined (__NO_USE_STD_IOSTREAM) +/* + we should ban that ! + # error "STLport won't work with new iostreams and std:: being implicitly included. Please use -std strict_ansi[_errors] or specify __NO_USE_STD_IOSTREAM" +*/ +# endif + +# if (defined (__STD_STRICT_ANSI) || defined (__STD_STRICT_ANSI_ERRORS)) +# define _STLP_STRICT_ANSI 1 +# else +/* we want to enforce it */ +# define _STLP_LONG_LONG long long +# endif + +/* unsigned 32-bit integer type */ +# define _STLP_UINT32_T unsigned int +#if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) +# define _STLP_RAND48 1 +#endif +/* # define _STLP_RAND48 1 */ + +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 1 + +# if (__DECCXX_VER <= 60600000) +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +# endif + +#if !defined (_NOTHREADS) && !defined (_STLP_THREADS_DEFINED) +# define _STLP_DEC_THREADS +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_dec_vms.h b/sdk/tlibstdcxx/stlport/stl/config/_dec_vms.h new file mode 100644 index 0000000000..44a0fb8b22 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_dec_vms.h @@ -0,0 +1,89 @@ +// OpenVMS version + +#define _STLP_COMPILER "Dec Vms" + +# define _STLP_NATIVE_HEADER(header) +# define _STLP_NATIVE_C_HEADER(x) +# define _STLP_NATIVE_CPP_C_HEADER(header) +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) + +#if (__DECCXX_VER < 60000000) + +// automatic template instantiation does not +// work with namespaces ;( +# define _STLP_HAS_NO_NAMESPACES 1 + +# define _STLP_NO_WCHAR_T 1 +# define _STLP_NEED_EXPLICIT 1 + +# define _STLP_NO_BOOL 1 +# define _STLP_NEED_TYPENAME 1 +# define _STLP_NO_NEW_STYLE_CASTS 1 +# define _STLP_NEED_MUTABLE 1 +# define _STLP_NO_BAD_ALLOC 1 + +# define _STLP_NO_NEW_NEW_HEADER 1 +# define _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX 1 + +# define _STLP_NO_MEMBER_TEMPLATES 1 +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# define _STLP_NO_QUALIFIED_FRIENDS 1 +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 +# define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 +# define _STLP_BROKEN_USING_DIRECTIVE 1 +# define _STLP_NO_EXCEPTION_HEADER 1 +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +# define _STLP_DEF_CONST_DEF_PARAM_BUG 1 + +#endif + + +#ifdef __NO_USE_STD_IOSTREAM +# define _STLP_USE_NO_IOSTREAMS 1 +# else +// default is to use new iostreams, anyway +# ifndef __USE_STD_IOSTREAM +# define __USE_STD_IOSTREAM +# endif +#endif + +#ifndef __EXCEPTIONS +# define _STLP_HAS_NO_EXCEPTIONS 1 +#endif + +# ifdef __IMPLICIT_INCLUDE_ENABLED + +#ifdef _STLP_USE_NO_IOSTREAMS +// implicit include introduces conflicts +// between stlport and native lib. +# undef __IMPLICIT_INCLUDE_ENABLED +#endif + +// but, works with ours ;). +# define _STLP_LINK_TIME_INSTANTIATION 1 + +# endif + +# if defined (__IMPLICIT_USING_STD) && !defined (__NO_USE_STD_IOSTREAM) +// we should ban that ! +# error "STLport won't work with new iostreams and std:: being implicitly included. Please use -std strict_ansi[_errors] or specify __NO_USE_STD_IOSTREAM" +# endif + +# if !(defined (__STD_STRICT_ANSI) || defined (__STD_STRICT_ANSI_ERRORS)) +// we want to enforce it +# define _STLP_LONG_LONG long long +# endif + +// unsigned 32-bit integer type +# define _STLP_UINT32_T unsigned int +#if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) +# define _STLP_RAND48 1 +#endif +// # define _STLP_RAND48 1 + +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 1 + +#define _STLP_HAS_NO_NEW_C_HEADERS 1 + diff --git a/sdk/tlibstdcxx/stlport/stl/config/_detect_dll_or_lib.h b/sdk/tlibstdcxx/stlport/stl/config/_detect_dll_or_lib.h new file mode 100644 index 0000000000..a062e6929c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_detect_dll_or_lib.h @@ -0,0 +1,74 @@ +/* File used to define macros: + * _STLP_USE_DYNAMIC_LIB: To signal use STLport as a dll or build of the + * STLport dlls. + * _STLP_USE_STATIC_LIB: To signal use of STLport as a static lib or build of + * the STLport static libs. + * _STLP_USING_CROSS_NATIVE_RUNTIME_LIB: Signal that we are using a native runtime + * in a version different from the STLport one. + * If _STLP_USE_DYNAMIC_LIB or _STLP_USE_STATIC_LIB is alreday defined it means that + * user forces use of a specific version. In this case _STLP_USING_CROSS_NATIVE_RUNTIME_LIB + * will surely be defined otherwise there is no need to force macro defines. + * + * Before including this file the compiler must define: + * _STLP_DLL: If we are building a dll + * _STLP_RUNTIME_DLL: If we are using native runtime as a dll + */ +#if defined (__BUILDING_STLPORT) +# undef _STLP_USE_DYNAMIC_LIB +# undef _STLP_USE_STATIC_LIB +# if defined (_STLP_DLL) +/* We are building the STLport dll */ +# define _STLP_USE_DYNAMIC_LIB +# if !defined (_STLP_RUNTIME_DLL) +# define _STLP_USING_CROSS_NATIVE_RUNTIME_LIB +# endif +# else +# define _STLP_USE_STATIC_LIB +# if defined (_STLP_RUNTIME_DLL) +# define _STLP_USING_CROSS_NATIVE_RUNTIME_LIB +# endif +# endif +#else +# if !defined (_STLP_NO_IOSTREAMS) +/* STLport use only depend on _STLP_RUNTIME_DLL as we are replacing + * the native runtime. + */ +# if defined (_STLP_RUNTIME_DLL) +# if !defined (_STLP_USE_STATIC_LIB) +# if !defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_USE_DYNAMIC_LIB +# endif +# else +/* The user is forcing use of STLport as a dynamic library. We signal it so + * that the STLport namespace will be modify to report such a combination + * and force the user to link with the rebuilt STLport library. + */ +# define _STLP_USING_CROSS_NATIVE_RUNTIME_LIB +# endif +# else +# if !defined(_STLP_USE_DYNAMIC_LIB) +# if !defined (_STLP_USE_STATIC_LIB) +# define _STLP_USE_STATIC_LIB +# endif +# else +/* Idem previous remark but the user forces use of the static native runtime. + */ +# define _STLP_USING_CROSS_NATIVE_RUNTIME_LIB +# endif +# endif +# else +/* If we do not build and use STLport libs we consider that we are in a static lib + * mode as only dynamic lib needs additional export/import specifier. + */ +# define _STLP_USE_STATIC_LIB +# endif +#endif + +/* we don't have a static native runtime library on evc3/evc4 */ +#ifdef _STLP_WCE +# undef _STLP_USING_CROSS_NATIVE_RUNTIME_LIB +#endif + +#if !defined (_STLP_USE_DYNAMIC_LIB) && !defined (_STLP_USE_STATIC_LIB) +# error Unknown STLport usage config (dll/lib?) +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_dm.h b/sdk/tlibstdcxx/stlport/stl/config/_dm.h new file mode 100644 index 0000000000..4f707323aa --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_dm.h @@ -0,0 +1,121 @@ +// STLport configuration file for Digital Mars C++ + +#define _STLP_COMPILER __DMC_VERSION_STRING__ + +#if (__DMC__ < 0x849) +# error "Digital Mars C++ compilers before version 8.49 are not supported!" +#endif + +/* DMC goes too far in template instanciation and tries to fully instanciate + * slist > for instance. The generation of assignment + * operator fails of course so we are force to use mutable key for this compiler. + */ +#define _STLP_NO_CONST_IN_PAIR +#define _STLP_DONT_SUP_DFLT_PARAM + +#ifndef _CPPUNWIND +# define _STLP_NO_EXCEPTIONS +#endif + +#ifndef _CPPRTTI +# define _STLP_NO_RTTI +#endif + +#define _STLP_VENDOR_GLOBAL_CSTD + +//DMC prefer enum to real static const variable because it do not consider +//static const as const enough to be used in switch declaration... +#define _STLP_STATIC_CONST_INIT_BUG + +#if !defined (_WIN32) +// it's not fully supported on non-Win32 platforms +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS +#endif + +/* _STLP_NO_OWN_NAMESPACE is defined because Digital Mars' linker and libarian + appear to have problems with STLport namespaces. Summary of the issues: + + STATIC: Digital Mars' librarian (lib.exe) may fail with "len <= IDMAX" error + if _STLP_DEBUG is defined. This is because Digital Mars' librarian uses + Microsoft OMF format, which limits identifier length to about 512 bytes. + With STLport namespaces, some identifiers such as Category_Map in + src/locale_catalog.cpp may exceed the maximum OMF identifier length. + + DYNAMIC: Export issues with cin, cout, cerr, clog in src/iostream.cpp. + Exports in Digital Mars 'def' file must match mangled names in iostream.cpp. + With STLport namespaces, the mangled names in the intermediate files no + longer match these pre-defined exports. To use STLport dynamic libraries + and STLport namespaces with Digital Mars, the pre-defined exports in + src/iostream.cpp and the related Digital Mars 'def' files would need to be + revised. */ +#define _STLP_NO_OWN_NAMESPACE 1 + +// select threads strategy +#if defined (_MT) && !defined (_STLP_NO_THREADS) +# define _STLP_THREADS +#endif + +#ifndef _BOOL_DEFINED +# define _STLP_NO_BOOL +#else +# define _STLP_DONT_USE_BOOL_TYPEDEF +#endif + +#if _INTEGRAL_MAX_BITS >= 64 +# define _STLP_LONG_LONG long long +#endif + +#define _STLP_MARK_PARAMETER_AS_UNUSED(X) +#define _STLP_DONT_USE_PRIV_NAMESPACE +#define _STLP_PRIV +#define _STLP_THROW_RETURN_BUG + +#if !defined (_DLL) +# undef _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT +#endif + +#if (__DMC__ < 0x849) +# define _STLP_NO_BAD_ALLOC +#endif + +#define _STLP_USE_ABBREVS +#define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER + +#define _STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND +#define _STLP_EXPORT_DECLSPEC __declspec(dllexport) +#define _STLP_IMPORT_DECLSPEC __declspec(dllimport) + +#define _STLP_CLASS_EXPORT_DECLSPEC __declspec(dllexport) +#define _STLP_CLASS_IMPORT_DECLSPEC __declspec(dllimport) + +#define _STLP_NEED_ADDITIONAL_STATIC_DECLSPEC + +//#define _STLP_IMPORT_TEMPLATE_KEYWORD __declspec(dllimport) +//#define _STLP_EXPORT_TEMPLATE_KEYWORD __declspec(dllexport) + +#if defined (_WINDLL) +# define _STLP_DLL +#endif +#if defined (_DLL) +# define _STLP_RUNTIME_DLL +#endif +#include +#undef _STLP_RUNTIME_DLL +#undef _STLP_DLL + +#if defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_USE_DECLSPEC 1 +# if defined (__BUILDING_STLPORT) +# define _STLP_CALL __export +# else +# define _STLP_CALL +# endif +#else +# define _STLP_CALL +#endif + +#include + +#undef __SC__ + +#include diff --git a/sdk/tlibstdcxx/stlport/stl/config/_epilog.h b/sdk/tlibstdcxx/stlport/stl/config/_epilog.h new file mode 100644 index 0000000000..30d1e244e7 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_epilog.h @@ -0,0 +1,29 @@ +#if defined (_STLP_MSVC) || defined (__ICL) + +# pragma warning (pop) +# pragma pack (pop) + +#elif defined (__BORLANDC__) + +# pragma option pop +# pragma option -w-pow // -w-8062 Previous options and warnings not restored + +#elif defined (__sgi) && !defined (__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) + +# pragma reset woff 1174 +# pragma reset woff 1375 +# pragma reset woff 1209 +/* from iterator_base.h */ +# pragma reset woff 1183 + +#elif defined (__DECCXX) + +# ifdef __PRAGMA_ENVIRONMENT +# pragma __environment __restore +# endif + +#elif defined (__IBMCPP__) + +# pragma info(restore) + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_evc.h b/sdk/tlibstdcxx/stlport/stl/config/_evc.h new file mode 100644 index 0000000000..c460450689 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_evc.h @@ -0,0 +1,333 @@ +/* + * File to have Microsoft eMbedded Visual C++ 3.0 and .NET working with STLport + * May 2004 + * Origin : Zdenek Nemec - zero@mapfactor.com + * Michael Fink - vividos@users.sourceforge.net + */ + +#ifndef _STLP_EVC_H +#define _STLP_EVC_H + +#define _STLP_COMPILER "eMbedded Visual C++" + +// This flag is being used by STLport to support +// old-fashioned Windows CE SDK (see stl_wince.h) +// do not use with eMebedded Visual C++ 3 or 4! +#ifdef _STLP_WINCE +# undef _STLP_WINCE +#endif + +/* Compiler dependent define. The following defines may be available: + * _STLP_WCE_EVC3 when compiling under eMbedded Visual C++ 3 + * _STLP_WCE_NET when compiling under eMbedded Visual C++ .NET + * _STLP_WCE always defined when compiling with one of the above + */ +#undef _STLP_WCE_EVC3 +#undef _STLP_WCE_NET + +#if (_WIN32_WCE > 300) +# define _STLP_WCE_NET UNDER_CE +#elif (_WIN32_WCE == 300) +# define _STLP_WCE_EVC3 UNDER_CE +#else +# error No support for Windows CE below 3.0! +#endif + +// This is defined for all platforms using Windows CE +#define _STLP_WCE + +/* All Windows CE versions up to at least version 5 are little-endian, even + * if the hardware (like e.g. MIPS) can be configured for big-endian, too. */ +#define _STLP_LITTLE_ENDIAN + +// Ensure _DEBUG is defined. +#if defined (DEBUG) && !defined (_DEBUG) +# define _DEBUG +#endif + +// inherit all msvc6 options +#include + +// CE up to at least version 5 has no C locale support +#define _STLP_NO_LOCALE_SUPPORT + +#if _WIN32_WCE >= 420 + // SDKs built with PB5 have terminate&co in namespace std... +# define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_STD +# define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_STD + // ...and new_handler/set_new_handler in the global namespace. +# define _STLP_GLOBAL_NEW_HANDLER 1 +#endif + +// Always threaded in eMbedded Visual C++ 3.0 and .NET +#ifndef _MT +# define _MT +#endif + +// we don't have a static native runtime library +#undef _STLP_USING_CROSS_NATIVE_RUNTIME_LIB + +#if _WIN32_WCE < 400 +// no long double under CE3 and older +# define _STLP_NO_LONG_DOUBLE +#endif + +// no *f and *l math functions available +#define _STLP_NO_VENDOR_MATH_F +#define _STLP_NO_VENDOR_MATH_L + +/* + * Redirect cout, cerr and clog: + * If defined redirect cout, cerr and clog to + * files stdout.txt, stderr.txt and stdlog.txt + */ +//# define _STLP_REDIRECT_STDSTREAMS + +/* + * Static class members may generate LNK1179: + * Wrong COMDAT packing may cause LNK1179 error. + * For details see http://groups.google.com/groups?th=8a05c82c4ffee280 + * example P78. This define is not used/needed at this moment + * but may came handy in future... + */ +//# define _STLP_STATIC_MEMBERS_BUG + +// Use wide-string interface of windows native functions (CreateFile...). +// Note that this should be defined all the time while under CE. +#if defined (UNICODE) +# define _STLP_USE_WIDE_INTERFACE +#endif + +// Force exception std to std instead of __std_alias. +#if defined (__cplusplus) && !defined (_STLP_HAS_NO_NAMESPACES) +# ifdef _STLP_VENDOR_EXCEPT_STD +# undef _STLP_VENDOR_EXCEPT_STD +# endif +# define _STLP_VENDOR_EXCEPT_STD std +#endif + +// short string optimization bug under evc3, evc4 using ARM compiler +#if _MSC_VER < 1400 && (defined (ARM) || defined (_ARM_)) +# define _STLP_DONT_USE_SHORT_STRING_OPTIM +#endif + +// when using MFC, disable another placement new declaration, since there is one in wcealt.h +#if !defined (__BUILDING_STLPORT) && defined (_MFC_VER) +# define __PLACEMENT_NEW_INLINE +#endif + +// threads +#undef _REENTRANT +#define _REENTRANT +#undef _NOTHREADS + +// Use old fashioned headers (ctime vs. time.h). +#undef _STLP_NO_NEW_C_HEADERS +#define _STLP_NO_NEW_C_HEADERS + +// exception handling support: only on evc4 and user added /GX to project settings +#if defined (_STLP_WCE_EVC3) || !defined (_CPPUNWIND) +# define _STLP_NO_EXCEPTION_HEADER +# define _STLP_NO_EXCEPTIONS +# undef _STLP_USE_EXCEPTIONS +# ifndef _STLP_THROW_BAD_ALLOC +# define _STLP_THROW_BAD_ALLOC { _STLP_WINCE_TRACE(L"out of memory"); ExitThread(1); } +# endif +#endif + +#define _STLP_WINCE_TRACE(msg) OutputDebugString(msg) + +/* + * eMbedded Visual C++ .NET specific settings + */ +#if defined (_STLP_WCE_NET) + +// evc4 has no locale and time support +# define _STLP_NO_LOCALE_SUPPORT +# define _STLP_NO_TIME_SUPPORT + +// ptrdiff_t is not defined in evc4 headers +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif + +/* + * Helper macros for including the native headers in cases where a file with + * the same name also exists in the STLport include folder. The idea behind + * this is that we first go up one directory and then down into a dir that + * is only present in the native install but not in STLport. + * + */ +# if !defined (_STLP_NATIVE_INCLUDE_PATH) +# if defined (_X86_) +# if defined (_STLP_WCE_TARGET_PROC_SUBTYPE_EMULATOR) +# define _STLP_NATIVE_INCLUDE_PATH ../Emulator +# else +# define _STLP_NATIVE_INCLUDE_PATH ../X86 +# endif +# elif defined (_ARM_) +# if _MSC_VER < 1400 + // eVC3/4 +# if defined (ARMV4) +# define _STLP_NATIVE_INCLUDE_PATH ../Armv4 +# elif defined (ARMV4I) +# define _STLP_NATIVE_INCLUDE_PATH ../Armv4i +# elif defined (ARMV4T) +# define _STLP_NATIVE_INCLUDE_PATH ../Armv4t +# else +# error Unknown ARM SDK. +# endif +# else + // VC8 crosscompiling for CE +# if defined (ARMV4) + // VC8 bundled Pocket PC 2003 SDK don't have a target CPU subfolder. +# if defined(WIN32_PLATFORM_PSPC) +# define _STLP_NATIVE_INCLUDE_PATH ../Include +# else +# define _STLP_NATIVE_INCLUDE_PATH ../Armv4 +# endif +# elif defined(ARMV4I) || defined(ARMV4T) +# define _STLP_NATIVE_INCLUDE_PATH ../Armv4i +# else +# error Unknown ARM SDK. +# endif +# endif +# elif defined (_MIPS_) +# if defined (MIPS16) +# define _STLP_NATIVE_INCLUDE_PATH ../mips16 +# elif defined (MIPSII) +# define _STLP_NATIVE_INCLUDE_PATH ../mipsII +# elif defined (MIPSII_FP) +# define _STLP_NATIVE_INCLUDE_PATH ../mipsII_fp +# elif defined (MIPSIV) +# define _STLP_NATIVE_INCLUDE_PATH ../mipsIV +# elif defined (MIPSIV_FP) +# define _STLP_NATIVE_INCLUDE_PATH ../mipsIV_fp +# else +# error Unknown MIPS SDK. +# endif +# elif defined (SHx) +# if defined (SH3) +# define _STLP_NATIVE_INCLUDE_PATH ../sh3 +# elif defined (SH4) +# define _STLP_NATIVE_INCLUDE_PATH ../sh4 +# else +# error Unknown SHx SDK. +# endif +# else +# error Unknown SDK. +# endif +# endif /* !_STLP_NATIVE_INCLUDE_PATH */ + +/* Workaround when using MFCCE and using together: MFCCE's wcealt.h doesn't + * check for __PLACEMENT_NEW_INLINE before defining operator new, so when + * defines the operatore before, there will be an error C2084: + * "function 'void *__cdecl operator new(unsigned int,void *)' already has a body". + */ +# ifdef _STLP_USE_MFC +# define __PLACEMENT_NEW_INLINE +# endif + +#endif /* _STLP_WCE_NET */ + +/* + * eMbedded Visual C++ 3.0 specific settings + */ +#if defined (_STLP_WCE_EVC3) + +# define _STLP_NO_NATIVE_MBSTATE_T + +// evc3 has no locale and time support +# define _STLP_NO_LOCALE_SUPPORT +# define _STLP_NO_TIME_SUPPORT + +// evc3 has new, but no explicit header +# define _STLP_NO_NEW_HEADER +# define _STLP_NO_NEW_NEW_HEADER + +// evc3 has no bad_alloc and no typeinfo +# undef _STLP_NO_BAD_ALLOC +# define _STLP_NO_BAD_ALLOC + +# undef _STLP_NO_TYPEINFO +# define _STLP_NO_TYPEINFO + +// missing things in eMbedded Visual C++ 3.0 headers +# ifndef _SIZE_T_DEFINED + typedef unsigned int size_t; +# define _SIZE_T_DEFINED +# endif + +# ifndef _WCHAR_T_DEFINED + typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +# endif + +// ptrdiff_t is not defined in evc3 headers +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif + +// clock_t is not defined in evc3 headers +# ifndef _CLOCK_T_DEFINED + typedef long clock_t; +# define _CLOCK_T_DEFINED +# endif + +// Struct tm is not defined in evc3 headers +# ifndef _TM_DEFINED +struct tm { + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday - [0,6] */ + int tm_yday; /* days since January 1 - [0,365] */ + int tm_isdst; /* daylight savings time flag */ +}; +# define _TM_DEFINED +# endif + +// define placement new and delete operator +// note: when MFCCE headers are included first, don't define the new operator, +// since it was already defined in wcealt.h +# ifdef __cplusplus +# ifndef __PLACEMENT_NEW_INLINE +# ifndef _MFC_VER +inline void *__cdecl operator new(size_t, void *_P) { return (_P); } +# endif /* _MFC_VER */ +inline void __cdecl operator delete(void *, void *) { return; } +# define __PLACEMENT_NEW_INLINE +# endif +# endif /* __cplusplus */ + +// evc3 doesn't have native wide functions, e.g. fgetwc, wmemmove +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS + +// evc3 doesn't have assert.h +# ifndef _ASSERT_DEFINED +# define assert(expr) _STLP_ASSERT(expr) +# define _ASSERT_DEFINED +# endif + +#endif /* _STLP_WCE_EVC3 */ + +/* + * original call: TerminateProcess(GetCurrentProcess(), 0); + * we substitute the GetCurrentProcess() with the result of the inline function + * defined in kfuncs.h, since we then can avoid including at all. + * all needed Win32 API functions are defined in + */ +#ifndef _ABORT_DEFINED +# define _STLP_ABORT() TerminateProcess(reinterpret_cast(66), 0) +# define _ABORT_DEFINED +#endif + +// Notice: windows.h isn't included here anymore; all needed defines are in +// stl/_windows.h now + +#endif /* _STLP_EVC_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/_feedback.h b/sdk/tlibstdcxx/stlport/stl/config/_feedback.h new file mode 100644 index 0000000000..0171ca5119 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_feedback.h @@ -0,0 +1,43 @@ +/* Helper header to give feedback about build environment configuration + * thanks to #pragma message directives. + */ + +#if defined (_STLP_VERBOSE) +# define _STLP_VERBOSE_MODE_SUPPORTED + +# if defined (_STLP_COMPILER) +# pragma message (_STLP_COMPILER) +# endif + +# if defined (_STLP_NO_RTTI) +# pragma message ("STLport: RTTI support -> Disabled") +# else +# pragma message ("STLport: RTTI support -> Enabled") +# endif + +# if defined (_STLP_HAS_NO_EXCEPTIONS) +# pragma message ("STLport: Exception support -> Disabled") +# else +# pragma message ("STLport: Exception support -> Enabled") +# endif + +# if defined (_STLP_THREADS) +# pragma message ("STLport: Threading model -> Multi") +# else +# pragma message ("STLport: Threading model -> Mono") +# endif + +# if defined (_STLP_USE_DYNAMIC_LIB) +# pragma message ("STLport: Library model -> Dynamic") +# else +# pragma message ("STLport: Library model -> Static") +# endif + +# if defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# if defined (_STLP_USE_DYNAMIC_LIB) +# pragma message ("STLport: Native library model -> Static") +# else +# pragma message ("STLport: Native library model -> Dynamic") +# endif +# endif +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_freebsd.h b/sdk/tlibstdcxx/stlport/stl/config/_freebsd.h new file mode 100644 index 0000000000..ab9339bd21 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_freebsd.h @@ -0,0 +1,3 @@ +#define _STLP_PLATFORM "Free BSD" + +#define _STLP_USE_UNIX_IO diff --git a/sdk/tlibstdcxx/stlport/stl/config/_fujitsu.h b/sdk/tlibstdcxx/stlport/stl/config/_fujitsu.h new file mode 100644 index 0000000000..cf91e05f94 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_fujitsu.h @@ -0,0 +1,7 @@ +/* STLport configuration for Fujitsu compiler : looks like a perfect one ! */ +#define _STLP_COMPILER "Fujitsu" + +#define _STLP_NATIVE_INCLUDE_PATH ../std +#define _STLP_UINT32_T unsigned int +#define _STLP_LONG_LONG long long +#define _STLP_WCHAR_SUNPRO_EXCLUDE 1 diff --git a/sdk/tlibstdcxx/stlport/stl/config/_gcc.h b/sdk/tlibstdcxx/stlport/stl/config/_gcc.h new file mode 100644 index 0000000000..71dc09c0d2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_gcc.h @@ -0,0 +1,204 @@ +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly + */ + +#define _STLP_COMPILER "gcc" + +#if !defined (_STLP_SGX_CONFIG) +#define _STLP_HAS_INCLUDE_NEXT 1 +#endif + +#if (__GNUC__ < 2) || ((__GNUC__ < 3) && ((__GNUC_MINOR__ < 95) || (__GNUC_MINOR__ == 96))) +/* We do not support neither the unofficial 2.96 gcc version. */ +# error GNU compilers before 2.95 are not supported anymore. +#endif + +/* Systems having GLIBC installed have different traits */ +#if !defined (_STLP_SGX_CONFIG) +#if defined (__linux__) +# ifndef _STLP_USE_GLIBC +# define _STLP_USE_GLIBC 1 +# endif +# if defined (__UCLIBC__) && !defined (_STLP_USE_UCLIBC) +# define _STLP_USE_UCLIBC 1 +# endif +#endif +#endif + +#if defined (__CYGWIN__) && \ + (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 3) && !defined (_GLIBCPP_USE_C99) +# define _STLP_NO_VENDOR_MATH_L +# define _STLP_NO_VENDOR_STDLIB_L +#endif + +#if (__GNUC__ < 3) +# define _STLP_NO_VENDOR_STDLIB_L +#endif + +#if (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) +/* define for gcc versions before 3.4.0. */ +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD +#endif + +#if !defined (_REENTRANT) && (defined (_THREAD_SAFE) || \ + (defined (__OpenBSD__) && defined (_POSIX_THREADS)) || \ + (defined (__MINGW32__) && defined (_MT))) +# define _REENTRANT +#endif + +#if defined (__DJGPP) +# define _STLP_RAND48 1 +# define _NOTHREADS 1 +# undef _PTHREADS +# define _STLP_LITTLE_ENDIAN +#endif + +#if defined (__MINGW32__) +/* Mingw32, egcs compiler using the Microsoft C runtime */ +# if (__GNUC__ >= 3) +/* For gcc before version 3 this macro is defined below */ +# define _STLP_VENDOR_GLOBAL_CSTD +# endif +# undef _STLP_NO_DRAND48 +# define _STLP_NO_DRAND48 +# define _STLP_CALL +#endif /* __MINGW32__ */ + +#if defined (__CYGWIN__) || defined (__MINGW32__) +# if !defined (_STLP_USE_STATIC_LIB) +# define _STLP_USE_DECLSPEC 1 +# if !defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_USE_DYNAMIC_LIB +# endif +# define _STLP_EXPORT_DECLSPEC __declspec(dllexport) +# define _STLP_CLASS_EXPORT_DECLSPEC __declspec(dllexport) +# define _STLP_CLASS_IMPORT_DECLSPEC __declspec(dllimport) +# endif +/* The following is defined independently of _STLP_USE_STATIC_LIB because it is also + * used to import symbols from PSDK under MinGW + */ +# define _STLP_IMPORT_DECLSPEC __declspec(dllimport) +#else +# if (__GNUC__ >= 4) +# if !defined (_STLP_USE_STATIC_LIB) +# if !defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_USE_DYNAMIC_LIB +# endif +# define _STLP_USE_DECLSPEC 1 +# define _STLP_EXPORT_DECLSPEC __attribute__((visibility("default"))) +# define _STLP_IMPORT_DECLSPEC __attribute__((visibility("default"))) +# define _STLP_CLASS_EXPORT_DECLSPEC __attribute__((visibility("default"))) +# define _STLP_CLASS_IMPORT_DECLSPEC __attribute__((visibility("default"))) +# endif +# endif +#endif + +#if !defined (_STLP_SGX_CONFIG) +#if defined (__CYGWIN__) || defined (__MINGW32__) || !(defined (_STLP_USE_GLIBC) || defined (__sun) || defined(__APPLE__)) +# if !defined (__MINGW32__) && !defined (__CYGWIN__) +# define _STLP_NO_NATIVE_MBSTATE_T 1 +# endif +# if !defined (__MINGW32__) || (__GNUC__ < 3) || (__GNUC__ == 3) && (__GNUC_MINOR__ < 4) +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 +# endif +# define _STLP_NO_NATIVE_WIDE_STREAMS 1 +#endif +#endif /* _STLP_SGX_CONFIG */ + +#define _STLP_NORETURN_FUNCTION __attribute__((noreturn)) + +/* Mac OS X is a little different with namespaces and cannot instantiate + * static data members in template classes */ +#if defined (__APPLE__) +# if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3))) +/* Mac OS X is missing a required typedef and standard macro */ +typedef unsigned int wint_t; +# endif + +# define __unix + +# define _STLP_NO_LONG_DOUBLE + +/* Mac OS X needs all "::" scope references to be "std::" */ +# define _STLP_USE_NEW_C_HEADERS + +# define _STLP_NO_VENDOR_STDLIB_L + +#endif /* __APPLE__ */ + +/* g++ 2.7.x and above */ +#define _STLP_LONG_LONG long long + +#ifdef _STLP_USE_UCLIBC + /* No *f math fuctions variants (i.e. sqrtf, fabsf, etc.) */ +# define _STLP_NO_VENDOR_MATH_F + /* No *l math fuctions variants (i.e. sqrtl, fabsl, etc.) */ +# define _STLP_NO_VENDOR_MATH_L +# define _STLP_NO_LONG_DOUBLE +#endif + +#if defined (__OpenBSD__) || defined (__FreeBSD__) +# define _STLP_NO_VENDOR_MATH_L +# define _STLP_NO_VENDOR_STDLIB_L /* no llabs */ +# ifndef __unix +# define __unix +# endif +#endif + +#if defined (__alpha__) +# define _STLP_NO_VENDOR_MATH_L +#endif + +#if defined (__hpux) +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_NO_VENDOR_STDLIB_L /* no llabs */ + /* No *f math fuctions variants (i.e. sqrtf, fabsf, etc.) */ +# define _STLP_NO_VENDOR_MATH_F +#endif + +#if (__GNUC__ >= 3) +# ifndef _STLP_HAS_NO_NEW_C_HEADERS +/* +# ifndef _STLP_USE_UCLIBC +*/ +# define _STLP_HAS_NATIVE_FLOAT_ABS +/* +# endif +*/ +# else +# ifdef _STLP_USE_GLIBC +# define _STLP_VENDOR_LONG_DOUBLE_MATH 1 +# endif +# endif +#endif + +#if (__GNUC__ < 3) +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_DONT_USE_PTHREAD_SPINLOCK 1 +# ifndef __HONOR_STD +# define _STLP_VENDOR_GLOBAL_EXCEPT_STD 1 +# endif +/* egcs fails to initialize builtin types in expr. like this : new(p) char(); */ +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +#endif + +#undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT +#undef _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT + +/* strict ANSI prohibits "long long" ( gcc) */ +#if defined ( __STRICT_ANSI__ ) +# undef _STLP_LONG_LONG +#endif + +#ifndef __EXCEPTIONS +# undef _STLP_DONT_USE_EXCEPTIONS +# define _STLP_DONT_USE_EXCEPTIONS 1 +#endif + +#if (__GNUC__ >= 3) +/* Instantiation scheme that used (default) in gcc 3 made void of sense explicit + instantiation within library: nothing except increased library size. - ptr + */ +# define _STLP_NO_FORCE_INSTANTIATE +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_hpacc.h b/sdk/tlibstdcxx/stlport/stl/config/_hpacc.h new file mode 100644 index 0000000000..920b8b4171 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_hpacc.h @@ -0,0 +1,129 @@ +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly + */ + +#define _STLP_COMPILER "aCC" + +/* system C-library dependent */ +#if defined (_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) +# define _STLP_RAND48 1 +#endif +/* # define _STLP_RAND48 1 */ +/* #define _STLP_NO_NATIVE_MBSTATE_T 1 */ +#define _STLP_HPACC_BROKEN_BUFEND 1 +#define _STLP_WCHAR_HPACC_EXCLUDE 1 + +/* this was reported to help, just as with SUN CC 4.2 */ +#define _STLP_INLINE_STRING_LITERAL_BUG + +/* specific prolog is needed to select correct threads impl */ +#define _STLP_HAS_SPECIFIC_PROLOG_EPILOG + +/* HP aCC with +noeh */ +#ifdef __HPACC_NOEH +# define _STLP_HAS_NO_EXCEPTIONS 1 +#endif + +#define _STLP_NO_FORCE_INSTANTIATE +#define _STLP_LONG_LONG long long +#define _STLP_NO_VENDOR_STDLIB_L + +/* The aCC6 compiler is using the EDG Front End. Unfortunately, prior to + * version A.06.12, defining the __EDG__ and __EDG_VERSION__ macros was + * disabled. It was corrected in A.06.12. + */ +#if ((__HP_aCC > 60000) && (__HP_aCC < 61200)) +# define __EDG__ +# define __EDG_VERSION__ 306 +#endif + +#if (__HP_aCC >= 32500 ) +# define _STLP_USE_NEW_C_HEADERS + +# define _STLP_FORCE_ALLOCATORS(t,a) \ + typedef typename _Alloc_traits::_Orig _STLP_dummy_type1;\ + typedef typename _STLP_dummy_type1:: _STLP_TEMPLATE rebind::other _STLP_dummy_type2; + +# if defined (_HP_NAMESPACE_STD) // option -AA +/* from now, we have a full standard lib in namespace std + * + * -AA indicates that we are compiling against Rogue Wave 2.2.1 + * STL shipped with the HP aCC compiler. -AA tells the compiler + * to use the STL defined in the include_std directory. + */ +# define _STLP_NATIVE_INCLUDE_PATH ../include_std +# else // option -Aa +# define _STLP_VENDOR_GLOBAL_STD 1 +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_DONT_THROW_RANGE_ERRORS 1 +# endif +#endif + +#if (__HP_aCC >= 31400 && __HP_aCC < 32500) +# define _STLP_FORCE_ALLOCATORS(t,a) \ +typedef typename _Alloc_traits::_Orig _STLP_dummy_type1;\ +typedef typename _STLP_dummy_type1:: _STLP_TEMPLATE rebind::other _STLP_dummy_type2; +# define _STLP_NO_CWCHAR +# if defined (_NAMESPACE_STD) // option -AA +/* from now, we have a full standard lib in namespace std */ +# define _STLP_NATIVE_INCLUDE_PATH ../include_std +# else /* kind of compatibility mode */ +# define _STLP_VENDOR_GLOBAL_STD 1 +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_DONT_THROW_RANGE_ERRORS 1 +# define _STLP_NO_ROPE 1 +# endif +#endif /* 314 */ + +#if ((__HP_aCC >= 30000 && __HP_aCC < 31400) || (__HP_aCC == 1)) // A.03.13: __HP_aCC == 1 + +# if (__HP_aCC != 1) +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +# endif + +# define _STLP_NO_QUALIFIED_FRIENDS 1 +/* aCC bug ? need explicit args on constructors of partial specialized + * classes + */ +# define _STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS 1 +/* ?? fbp : maybe present in some versions ? */ +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +/* and stuff is in global namespace */ +# define _STLP_VENDOR_GLOBAL_EXCEPT_STD +/* fbp : moved here */ +# define _STLP_VENDOR_GLOBAL_CSTD 1 +/* # define _INCLUDE_HPUX_SOURCE */ +# define _XPG4 +# define _INCLUDE_XOPEN_SOURCE +# define _INCLUDE_AES_SOURCE +#endif + +#if (__HP_aCC <= 30000 && __HP_aCC >= 12100) +/* Special kludge to workaround bug in aCC A.01.23, CR JAGac40634 */ +# ifdef _STLP_DEBUG +static void _STLP_dummy_literal() { const char *p = "x";} +static void _STLP_dummy_literal_2() { const char *p = "123456789"; } +static void _STLP_dummy_literal_3() { const char *p = "123456700000000000000089";} +# endif + +# define _STLP_VENDOR_GLOBAL_STD 1 +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_DONT_THROW_RANGE_ERRORS 1 +# define _STLP_STATIC_CONST_INIT_BUG 1 +# if (__HP_aCC < 12700) +/* new flag: on most HP compilers cwchar is missing */ +# define _STLP_NO_CWCHAR +# endif + +# define _STLP_FORCE_ALLOCATORS(t,a) \ + typedef typename _Alloc_traits::_Orig _STLP_dummy_type1;\ + typedef typename _STLP_dummy_type1:: _STLP_TEMPLATE rebind::other _STLP_dummy_type2; +#endif + +#if __HP_aCC == 1 +# define _STLP_BROKEN_USING_IN_CLASS +# define _STLP_USING_BASE_MEMBER +# define _STLP_NO_CWCHAR +/* # define _STLP_NO_WCHAR_T 1 */ +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_hpux.h b/sdk/tlibstdcxx/stlport/stl/config/_hpux.h new file mode 100644 index 0000000000..385c514cc0 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_hpux.h @@ -0,0 +1,17 @@ +#ifndef __stl_config__hpux_h +#define __stl_config__hpux_h + +#define _STLP_PLATFORM "HP Unix" + +#define _STLP_USE_UNIX_IO + +#ifdef __GNUC__ +# define _STLP_NO_WCHAR_T +# define _STLP_NO_CWCHAR +# define _STLP_NO_LONG_DOUBLE +# ifndef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 199506 +# endif +#endif + +#endif /* __stl_config__hpux_h */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/_ibm.h b/sdk/tlibstdcxx/stlport/stl/config/_ibm.h new file mode 100644 index 0000000000..f74f6d9be9 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_ibm.h @@ -0,0 +1,144 @@ +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly + */ + +#if defined (__IBMCPP__) || defined (__IBMC__) +# define _STLP_COMPILER "Visual Age C++" +#elif defined (__xlC__) +# define _STLP_COMPILER "xlc" +#else +# error "Unknown compiler" +#endif + +#if !defined(__IBMCPP__) || (__IBMCPP__ < 500) +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +#endif + +/* string literal problem, same as with SUN and aCC */ +# define _STLP_INLINE_STRING_LITERAL_BUG 1 +# define _STLP_HAS_NATIVE_FLOAT_ABS + +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +# define _STLP_DEF_CONST_DEF_PARAM_BUG 1 + + +# ifdef __IBMCPP__ +# define _STLP_HAS_SPECIFIC_PROLOG_EPILOG +# endif + +/* # if ( defined (__MULTI__) && defined (__WINDOWS__)) + * # define _STLP_WIN32THREADS 1 Only Visual Age 3.5 for Windows + * # endif + */ + +# if ( defined (__MULTI__) && defined (__OS2__)) +# define _STLP_OS2THREADS 1 +# endif + +/* __TEMPINC__ is set when /Ft+ option is used */ +# ifdef __TEMPINC__ +# define _STLP_LINK_TIME_INSTANTIATION 1 +# endif + +# if defined (__MVS__) +/* long long support is buggy - reported by Tinny Ng + * # if __EXTENDED__ && __COMPILER_VER__ >= 0x22060000 + * # define _STLP_LONG_LONG long long + * # endif + */ +/* boris : hstash reported it can be treated like UNIX */ +# define _STLP_NO_TYPEINFO 1 +# undef _STLP_NATIVE_INCLUDE_PATH +# define _STLP_NATIVE_INCLUDE_PATH /usr/lpp/ioclib/include +/* same for C headers like */ +# undef _STLP_NATIVE_C_INCLUDE_PATH +# define _STLP_NATIVE_C_INCLUDE_PATH /usr/include +# define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH /usr/include + +# elif (defined (__WINDOWS__) || defined (_AIX) || defined (__OS2__) ) && (__IBMCPP__ >= 350) + +# define _STLP_LONG_LONG long long + +#endif + +#if !( defined( __xlC__ ) && __xlC__ >= 0x500 ) + +/* AIX xlC 3.1 , 3.0.1 ==0x301 + * Visual Age C++ 3.x + * OS-390 C++ + * fbp : should be more version-specific! + */ + +# define _STLP_NO_BOOL 1 +# define _STLP_DONT_USE_BOOL_TYPEDEF 1 +# define _STLP_LIMITED_DEFAULT_TEMPLATES 1 +# define _STLP_HAS_NO_NAMESPACES 1 +# define _STLP_NEED_TYPENAME 1 +# define _STLP_NEED_EXPLICIT 1 +# define _STLP_NO_ARROW_OPERATOR 1 +# define _STLP_NO_NEW_STYLE_CASTS 1 +# define _STLP_NO_WCHAR_T 1 +# define _STLP_NEED_MUTABLE 1 +# define _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX 1 +# define _STLP_NO_BAD_ALLOC 1 + +# define _STLP_NO_MEMBER_TEMPLATES 1 +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# define _STLP_NO_QUALIFIED_FRIENDS 1 +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 + +# define _STLP_NO_DEFAULT_NON_TYPE_PARAM 1 +# define _STLP_NO_METHOD_SPECIALIZATION 1 +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 1 +# define _STLP_NO_EXCEPTION_HEADER 1 + +# define _STLP_NO_NEW_NEW_HEADER 1 + +# if defined (__OS2__) && (__IBMCPP__ <= 350) +# define _STLP_NO_TYPEINFO 1 +# endif +# define _STLP_NO_NEW_NEW_HEADER 1 + +# define _STLP_STATIC_CONST_INIT_BUG 1 +/* # define _STLP_THROW_RETURN_BUG 1 */ + + +# define _STLP_NO_TEMPLATE_CONVERSIONS 1 +# define _STLP_BASE_TYPEDEF_OUTSIDE_BUG 1 + +/* AIX xlC, Visual Age 3.0 for OS/2 and MS */ +# define _STLP_TRIVIAL_DESTRUCTOR_BUG + +# define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 +# define _STLP_NONTEMPL_BASE_MATCH_BUG 1 + +#if __IBMCPP__ <= 350 +# define _STLP_NEED_UNREACHABLE_RETURN 1 +#endif + +#if __IBMCPP__ < 350 +# define _STLP_NO_LONG_DOUBLE 1 +#endif + +#if __IBMCPP__ >= 365 +/* does not have new C headers, but has div() */ +# define _STLP_LDIV +#endif + +#endif /* xlC 5 */ + +/* detect xlC5 by: */ +#if defined(__IBMCPP__) && (500 <= __IBMCPP__) && (__IBMCPP__ < 700) +# define _STLP_USE_EXCEPTIONS 1 +# define _STLP_STATIC_CONST_INIT_BUG 1 +/* #pragma report(disable,CPPC1500029) + * unsigned 32-bit integer type + */ +# define _STLP_UINT32_T unsigned int +# if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) +# define _STLP_RAND48 1 +# endif +/* # define _STLP_RAND48 1 */ +#endif /* __IBMCPP__ == 500 */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/_icc.h b/sdk/tlibstdcxx/stlport/stl/config/_icc.h new file mode 100644 index 0000000000..e9d7a6c3e4 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_icc.h @@ -0,0 +1,45 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly +// A list of Intel compiler for Linux portion of STLport settings. + +#define _STLP_COMPILER "Intel ICC" + +#define _STLP_LONG_LONG long long + +// Edit relative path below (or put full path) to get native +// compiler headers included. Default is "../include". +// C headers may reside in different directory, so separate macro is provided. +#if !defined (_STLP_SGX_CONFIG) +#if (__INTEL_COMPILER < 800) +# define _STLP_NATIVE_INCLUDE_PATH ../include +# define _STLP_NATIVE_C_INCLUDE_PATH ../include +# define _STLP_NATIVE_CPP_C_INCLUDE_PATH ../include +#endif + +#if (__INTEL_COMPILER >= 800) +# define _STLP_NATIVE_INCLUDE_PATH ../include/c++ +# define _STLP_NATIVE_C_INCLUDE_PATH ../include +# define _STLP_NATIVE_CPP_C_INCLUDE_PATH ../include + +#endif /* __INTEL_COMPILER >= 800 */ +#endif /* !_STLP_SGX_CONFIG */ +#define _STLP_HAS_NO_NEW_C_HEADERS 1 +#define _STLP_VENDOR_GLOBAL_CSTD 1 + +/* Systems having GLIBC installed have different traits */ +#if !defined (_STLP_USE_GLIBC) && defined (__linux__) +# define _STLP_USE_GLIBC +# define _XOPEN_SOURCE 600 +#endif + +#undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT + + +#ifndef __GNUC__ +# define __GNUC__ 3 +#endif + +//#define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 + +#define _STLP_NO_FORCE_INSTANTIATE +//#define _REENTRANT diff --git a/sdk/tlibstdcxx/stlport/stl/config/_intel.h b/sdk/tlibstdcxx/stlport/stl/config/_intel.h new file mode 100644 index 0000000000..01e09d60f2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_intel.h @@ -0,0 +1,72 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +#define _STLP_COMPILER "Intel ICL" + +#define _STLP_IMPORT_TEMPLATE_KEYWORD extern + +/* You need to undef following macro if your icl install is binded to MSVC 6 + * native lib and you are building with /Qvc7 or /Qvc7.1 or /Qvc8 option. + */ +/* #define _STLP_MSVC_LIB 1200 */ +/* You need to undef following macro if your icl install is binded to MSVC .Net 2002 + * native lib and you are building without any /Qvc* option or with /Qvc6 or /Qvc7.1 + * or /Qvc8 option. + */ +/* #define _STLP_MSVC_LIB 1300 */ +/* You need to undef following macro if your icl install is binded to MSVC .Net 2003 + * native lib and you are building without any /Qvc* option or with /Qvc6 or /Qvc7 + * or /Qvc8 option. + */ +/* #define _STLP_MSVC_LIB 1310 */ +/* You need to undef following macro if your icl install is binded to MSVC 2005 + * native lib and you are building without any /Qvc* option or with /Qvc6 or /Qvc7 + * or /Qvc7.1 option. + */ +/* #define _STLP_MSVC_LIB 1400 */ + +#include + +#if defined (_STLP_DONT_RETURN_VOID) +# undef _STLP_DONT_RETURN_VOID +#endif + +#if (__ICL < 900) +# define _STLP_NOTHROW +#endif + +#if (__ICL <= 810) +/* If method specialization is activated, compiler do not export some + * symbols anymore. + */ +# define _STLP_NO_METHOD_SPECIALIZATION 1 +#endif + +#if (__ICL >= 800 && __ICL < 900) +# define _STLP_STATIC_CONST_INIT_BUG 1 +#endif + +#if (__ICL >= 450) +# define _STLP_DLLEXPORT_NEEDS_PREDECLARATION 1 +#endif + +#if (__ICL < 450) +/* only static STLport lib works for ICL */ +# undef _STLP_USE_STATIC_LIB +# undef _STLP_USE_DYNAMIC_LIB +# define _STLP_USE_STATIC_LIB +/* disable hook which makes template symbols to be searched for in the library */ +# undef _STLP_NO_CUSTOM_IO +#endif + +#undef _STLP_LONG_LONG +#define _STLP_LONG_LONG long long + +#if defined (__cplusplus) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300) +namespace std +{ + void _STLP_CALL unexpected(); +} +#endif + +#include diff --git a/sdk/tlibstdcxx/stlport/stl/config/_kai.h b/sdk/tlibstdcxx/stlport/stl/config/_kai.h new file mode 100644 index 0000000000..267158f834 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_kai.h @@ -0,0 +1,43 @@ +// STLport config file for KAI C++ compiler + +#if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) +# define _STLP_RAND48 1 +#endif + +# ifndef __KAI_STRICT /* _NO_LONGLONG */ +# define _STLP_LONG_LONG long long +# endif + +# if !defined (__EXCEPTIONS) && ! defined (_EXCEPTIONS) +# define _STLP_HAS_NO_EXCEPTIONS +# endif + +# ifndef __BUILDING_STLPORT +# define _STLP_LINK_TIME_INSTANTIATION 1 +# endif + +// two levels of macros do not work good with kcc. +# define _STLP_NATIVE_HEADER(header) <../include/##header> +# define _STLP_NATIVE_C_HEADER(header) <../include/##header> +# define _STLP_NATIVE_CPP_C_HEADER(header) <../include/##header> +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../include/##header> + +// KAI C++ uses EDG front-end, but apparently different switches +// # define __EDG_SWITCHES 1 + +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_VENDOR_MB_NAMESPACE std + +// boris : some of those may also apply to KCC 3.4 +# if __KCC_VERSION < 4000 +# define _STLP_VENDOR_GLOBAL_EXCEPT_STD 1 + +# endif + +# if defined (__sgi) +// this requires some discrimination on whether we are actually on +// a system officially supported by KAI. +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +# include +# endif + diff --git a/sdk/tlibstdcxx/stlport/stl/config/_linux.h b/sdk/tlibstdcxx/stlport/stl/config/_linux.h new file mode 100644 index 0000000000..f6d845ceeb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_linux.h @@ -0,0 +1,126 @@ +#ifndef __stl_config__linux_h +#define __stl_config__linux_h + +#define _STLP_PLATFORM "Linux" + +#include "features.h" + +/* This is defined wether library in use is glibc or not. + This may be treated as presence of GNU libc compatible + header files (these define is not really intended to check + for the presence of a particular library, but rather is used + to define an INTERFACE.) */ +#ifndef _STLP_SGX_CONFIG +#ifndef _STLP_USE_GLIBC +# define _STLP_USE_GLIBC 1 +#endif + +#ifndef _STLP_USE_STDIO_IO +# define _STLP_USE_UNIX_IO +#endif +#endif + +/* #define _STLP_USE_STDIO_IO */ + +/* If not explicitly specified otherwise, work with threads + */ +#if !defined(_STLP_NO_THREADS) && !defined(_REENTRANT) +# define _REENTRANT +#endif + +#if defined(_REENTRANT) && !defined(_PTHREADS) +# define _PTHREADS +#endif + +#ifdef __UCLIBC__ /* uClibc 0.9.27 */ +# define _STLP_USE_UCLIBC 1 +# if !defined(__UCLIBC_HAS_WCHAR__) +# ifndef _STLP_NO_WCHAR_T +# define _STLP_NO_WCHAR_T +# endif +# ifndef _STLP_NO_NATIVE_MBSTATE_T +# define _STLP_NO_NATIVE_MBSTATE_T +# endif +# ifndef _STLP_NO_NATIVE_WIDE_STREAMS +# define _STLP_NO_NATIVE_WIDE_STREAMS +# endif +# endif /* __UCLIBC_HAS_WCHAR__ */ + /* Hmm, bogus _GLIBCPP_USE_NAMESPACES seems undefined... */ +# define _STLP_VENDOR_GLOBAL_CSTD 1 +#endif + + +#if defined(_PTHREADS) +# define _STLP_THREADS +# define _STLP_PTHREADS +/* +# ifndef __USE_UNIX98 +# define __USE_UNIX98 +# endif +*/ +/* This feature exist at least since glibc 2.2.4 */ +/* # define __FIT_XSI_THR */ /* Unix 98 or X/Open System Interfaces Extention */ +# ifdef __USE_XOPEN2K +/* The IEEE Std. 1003.1j-2000 introduces functions to implement spinlocks. */ +# ifndef __UCLIBC__ /* There are no spinlocks in uClibc 0.9.27 */ +# define _STLP_USE_PTHREAD_SPINLOCK +# else +# ifndef _STLP_DONT_USE_PTHREAD_SPINLOCK + /* in uClibc (0.9.26) pthread_spinlock* declared in headers + * but absent in library */ +# define _STLP_DONT_USE_PTHREAD_SPINLOCK +# endif +# endif +# ifndef _STLP_DONT_USE_PTHREAD_SPINLOCK +# define _STLP_USE_PTHREAD_SPINLOCK +# define _STLP_STATIC_MUTEX _STLP_mutex +# endif +/* # define __FIT_PSHARED_MUTEX */ +# endif +#endif + +/* Endiannes */ +#include +#if !defined(_BYTE_ORDER) || !defined(_LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) +# error "One of _BYTE_ORDER, _LITTLE_ENDIAN and _BIG_ENDIAN undefined; Fix me!" +#endif + +#if ( _BYTE_ORDER == _LITTLE_ENDIAN ) +# define _STLP_LITTLE_ENDIAN 1 +#elif ( _BYTE_ORDER == _BIG_ENDIAN ) +# define _STLP_BIG_ENDIAN 1 +#else +# error "_BYTE_ORDER neither _BIG_ENDIAN nor _LITTLE_ENDIAN; Fix me!" +#endif + +#if defined(__GNUC__) && (__GNUC__ < 3) +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 +#endif + +#ifdef __GLIBC__ +# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__GLIBC__ > 2) +/* From glibc 2.3.x default allocator is malloc_alloc, if was not defined other */ +# if !defined(_STLP_USE_MALLOC) && !defined(_STLP_USE_NEWALLOC) && !defined(_STLP_USE_PERTHREAD_ALLOC) && !defined(_STLP_USE_NODE_ALLOC) +# define _STLP_USE_MALLOC 1 +# endif +# endif +/* Following platforms has no long double: + * - Alpha + * - PowerPC + * - SPARC, 32-bits (64-bits platform has long double) + * - MIPS, 32-bits + * - ARM + * - SH4 + */ +# if defined(__alpha__) || \ + defined(__ppc__) || defined(PPC) || defined(__powerpc__) || \ + ((defined(__sparc) || defined(__sparcv9) || defined(__sparcv8plus)) && !defined ( __WORD64 ) && !defined(__arch64__)) /* ? */ || \ + (defined(_MIPS_SIM) && (_MIPS_SIM == _ABIO32)) || \ + defined(__arm__) || \ + defined(__sh__) + /* # if defined(__NO_LONG_DOUBLE_MATH) */ +# define _STLP_NO_LONG_DOUBLE +# endif +#endif + +#endif /* __stl_config__linux_h */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/_mac.h b/sdk/tlibstdcxx/stlport/stl/config/_mac.h new file mode 100644 index 0000000000..575c183816 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_mac.h @@ -0,0 +1,6 @@ +#define _STLP_PLATFORM "Mac" + +#define _STLP_MAC 1 + +#error Looks like unsupported platform +#define _STLP_USE_UNIX_EMULATION_IO diff --git a/sdk/tlibstdcxx/stlport/stl/config/_macosx.h b/sdk/tlibstdcxx/stlport/stl/config/_macosx.h new file mode 100644 index 0000000000..54a922267e --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_macosx.h @@ -0,0 +1,9 @@ +#define _STLP_PLATFORM "Mac OS X" + +#if defined (__BIG_ENDIAN__) +# define _STLP_BIG_ENDIAN 1 +#elif defined (__LITTLE_ENDIAN__) +# define _STLP_LITTLE_ENDIAN 1 +#endif + +#define _STLP_USE_UNIX_IO diff --git a/sdk/tlibstdcxx/stlport/stl/config/_mlc.h b/sdk/tlibstdcxx/stlport/stl/config/_mlc.h new file mode 100644 index 0000000000..8687d0bf8b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_mlc.h @@ -0,0 +1,7 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +#define _STLP_NO_MEMBER_TEMPLATES // Compiler does not support member templates +#define _STLP_NO_MEMBER_TEMPLATE_CLASSES // Compiler does not support member template classes + +#define _STLP_HAS_NEW_NEW_HEADER diff --git a/sdk/tlibstdcxx/stlport/stl/config/_msvc.h b/sdk/tlibstdcxx/stlport/stl/config/_msvc.h new file mode 100644 index 0000000000..cf56e4ee57 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_msvc.h @@ -0,0 +1,265 @@ +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly + * Microsoft Visual C++ 6.0, 7.0, 7.1, 8.0, ICL + */ + +#if !defined (_STLP_COMPILER) +# define _STLP_COMPILER "Microsoft Visual Studio C++" +#endif + +#if !defined (__ICL) && !defined (_STLP_MSVC) +# define _STLP_MSVC _MSC_VER +#endif + +#if !defined (_STLP_MSVC_LIB) +# define _STLP_MSVC_LIB _MSC_VER +#endif + +#if defined (__BUILDING_STLPORT) && defined (_MANAGED) +/* Building a managed version of STLport is not supported because we haven't + * found a good reason to support it. However, building a managed translation + * unit using STLport _is_ supported. + */ +# error Sorry but building a managed version of STLport is not supported. +#endif + +#if defined (_STLP_USING_PLATFORM_SDK_COMPILER) +/* This is a specific section for compilers coming with platform SDKs. Native + * library coming with it is different from the one coming with commercial + * MSVC compilers so there is some specific settings. + */ +# define _STLP_NATIVE_INCLUDE_PATH ../crt +# define _STLP_VENDOR_GLOBAL_CSTD +# define _STLP_VENDOR_TERMINATE_STD +# define _STLP_GLOBAL_NEW_HANDLER +# if (_STLP_MSVC_LIB <= 1400) +/* We hope this bug will be fixed in future versions. */ +# define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 +# endif +#endif + +#define _STLP_CALL __cdecl + +#ifndef _STLP_LONG_LONG +# define _STLP_LONG_LONG __int64 +#endif + +#define _STLP_PRAGMA_ONCE + +/* These switches depend on compiler flags. We are hoping here that compilers + * simulating MSVC behavior use identical macros to report compilation context. + * Otherwise those macros will have to be undef in specific compiler configuration + * files. + */ +#ifndef _CPPUNWIND +# define _STLP_DONT_USE_EXCEPTIONS 1 +#endif + +#ifndef _CPPRTTI +# define _STLP_NO_RTTI 1 +#endif + +#if defined (_MT) && !defined (_STLP_NO_THREADS) +# define _STLP_THREADS 1 +#endif + +#if defined (_STLP_SGX_CONFIG) || !defined (_NATIVE_WCHAR_T_DEFINED) +# define _STLP_WCHAR_T_IS_USHORT 1 +#endif + +#define _STLP_NO_VENDOR_STDLIB_L 1 + +#if defined (_STLP_MSVC) + +# if (_STLP_MSVC < 1200) +# error Microsoft Visual C++ compilers before version 6 (SP5) are not supported. +# endif + +# define _STLP_NORETURN_FUNCTION __declspec(noreturn) + +/* Full compiler version comes from boost library intrinsics.hpp header. */ +# if defined (_MSC_FULL_VER) && (_MSC_FULL_VER >= 140050215) +# define _STLP_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T) +# define _STLP_HAS_TRIVIAL_COPY(T) __has_trivial_copy(T) +# define _STLP_HAS_TRIVIAL_ASSIGN(T) __has_trivial_assign(T) +# define _STLP_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) +# define _STLP_IS_POD(T) __is_pod(T) +# define _STLP_HAS_TYPE_TRAITS_INTRINSICS +# endif + +# ifndef _STLP_MSVC50_COMPATIBILITY +# define _STLP_MSVC50_COMPATIBILITY 1 +# endif + +# define _STLP_DLLEXPORT_NEEDS_PREDECLARATION 1 +# define _STLP_HAS_SPECIFIC_PROLOG_EPILOG 1 +# define _STLP_NO_STATIC_CONST_DEFINITION 1 + +/* # ifndef __BUILDING_STLPORT + * # define _STLP_USE_TEMPLATE_EXPORT 1 + * # endif + */ + +/** Note: the macro _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT is defined +unconditionally and undef'ed here when applicable. */ +# if defined (UNDER_CE) +/* eVCx: +uncaught_exception is declared in the SDKs delivered with eVC4 (eVC3 is +unknown) and they all reside in namespace 'std' there. However, they are not +part of any lib so linking fails. When using VC8 to crosscompile for CE 5 on +an ARMV4I, the uncaught_exception test fails, the function returns the wrong +value. */ +/* All eVCs up to at least VC8/CE5 have a broken new operator that + returns null instead of throwing bad_alloc. */ +# define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 +# else +/* VCx: +These are present at least since VC6, but the uncaught_exception() of VC6 is +broken, it returns the wrong value in the unittests. 7.1 and later seem to +work, 7.0 is still unknown (we assume it works until negative report). */ +# if (_STLP_MSVC >= 1300)// VC7 and later +# undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT +# endif +# if (_STLP_MSVC < 1300) +# define _STLP_NOTHROW +# endif +# endif + +# if (_STLP_MSVC <= 1300) +# define _STLP_STATIC_CONST_INIT_BUG 1 +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 +/* There is no partial spec, and MSVC breaks on simulating it for iterator_traits queries */ +# define _STLP_USE_OLD_HP_ITERATOR_QUERIES +# define _STLP_NO_TYPENAME_IN_TEMPLATE_HEADER +# define _STLP_NO_METHOD_SPECIALIZATION 1 +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +# define _STLP_NO_TYPENAME_ON_RETURN_TYPE 1 +/* VC++ cannot handle default allocator argument in template constructors */ +# define _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS +# define _STLP_NO_QUALIFIED_FRIENDS 1 +# endif + +# if (_STLP_MSVC < 1300) /* including MSVC 6.0 */ +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# define _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE 1 +# endif + +# define _STLP_HAS_NATIVE_FLOAT_ABS 1 + +// TODO: some eVC4 compilers report _MSC_VER 1201 or 1202, which category do they belong to? +# if (_STLP_MSVC > 1200) && (_STLP_MSVC < 1310) +# define _STLP_NO_MOVE_SEMANTIC +# endif + +# if (_STLP_MSVC < 1300) +/* TODO: remove this if it is handled and documented elsewhere + * dums: VC6 do not handle correctly member templates of class that are explicitely + * instanciated to be exported. There is a workaround, seperate the non template methods + * from the template ones within 2 different classes and only export the non template one. + * It is implemented for basic_string and locale at the writing of this note. + * However this problem hos not been considered as important enough to remove template member + * methods for other classes. Moreover Boost (www.boost.org) required it to be granted. + * The workaround is activated thanks to the _STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND macro defined + * later in this config file. + */ +/* +# if defined (_DLL) +# define _STLP_NO_MEMBER_TEMPLATES 1 +# endif +*/ + +/* Boris : not defining this macro for SP5 causes other problems */ +/*# if !defined (_MSC_FULL_VER) || (_MSC_FULL_VER < 12008804 ) */ +# define _STLP_NO_USING_FOR_GLOBAL_FUNCTIONS 1 +/*# endif */ +# define _STLP_DONT_USE_BOOL_TYPEDEF 1 +# define _STLP_DONT_RETURN_VOID 1 +# endif + +# if (_STLP_MSVC < 1300) /* MSVC 6.0 and earlier */ +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 1 +/* defined for DEBUG and NDEBUG too, to allow user mix own debug build with STLP release library */ +# define _STLP_USE_ABBREVS +# endif + +#endif /* _STLP_MSVC */ + +/* The desktop variants starting with VC8 have a set of more secure replacements + * for the error-prone string handling functions of the C standard lib. */ +/* When user do not consider 'unsafe' string functions as deprecated using _CRT_SECURE_NO_DEPRECATE + * macro we use 'unsafe' functions for performance reasons. */ +#if (_STLP_MSVC_LIB >= 1400) && !defined (_STLP_USING_PLATFORM_SDK_COMPILER) && !defined (UNDER_CE) && \ + !defined (_CRT_SECURE_NO_DEPRECATE) +# define _STLP_USE_SAFE_STRING_FUNCTIONS 1 +#endif + +#if (_STLP_MSVC_LIB <= 1310) +# define _STLP_VENDOR_GLOBAL_CSTD +#endif + +#if (_STLP_MSVC_LIB >= 1300) && !defined(UNDER_CE) +/* Starting with MSVC 7.0 and compilers simulating it, + * we assume that the new SDK is granted: + */ +# define _STLP_NEW_PLATFORM_SDK 1 +#endif + +#if (_STLP_MSVC_LIB < 1300) /* including MSVC 6.0 */ +# define _STLP_GLOBAL_NEW_HANDLER 1 +# define _STLP_VENDOR_UNEXPECTED_STD +# define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 +#endif + +#define _STLP_EXPORT_DECLSPEC __declspec(dllexport) +#define _STLP_IMPORT_DECLSPEC __declspec(dllimport) +#define _STLP_CLASS_EXPORT_DECLSPEC __declspec(dllexport) +#define _STLP_CLASS_IMPORT_DECLSPEC __declspec(dllimport) + +#if defined (__DLL) || defined (_DLL) || defined (_RTLDLL) || defined (_AFXDLL) +# define _STLP_RUNTIME_DLL +#endif +#if defined (__BUILDING_STLPORT) && \ + (defined (_STLP_USE_DYNAMIC_LIB) || \ + defined (_STLP_RUNTIME_DLL) && !defined (_STLP_USE_STATIC_LIB)) +# define _STLP_DLL +#endif +#include +#undef _STLP_RUNTIME_DLL +#undef _STLP_DLL + +#if defined (_STLP_USE_DYNAMIC_LIB) +# undef _STLP_USE_DECLSPEC +# define _STLP_USE_DECLSPEC 1 +# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) +# define _STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND 1 +# endif +#endif + +#if !defined (_STLP_IMPORT_TEMPLATE_KEYWORD) +# if !defined (_MSC_EXTENSIONS) || defined (_STLP_MSVC) && (_STLP_MSVC >= 1300) +# define _STLP_IMPORT_TEMPLATE_KEYWORD +# else +# define _STLP_IMPORT_TEMPLATE_KEYWORD extern +# endif +#endif +#define _STLP_EXPORT_TEMPLATE_KEYWORD + +#include + +#if defined (_STLP_USING_PLATFORM_SDK_COMPILER) +/* The Windows 64 bits SDK required for the moment link to bufferoverflowU.lib for + * additional buffer overrun checks. Rather than require the STLport build system and + * users to explicitely link with it we use the MSVC auto link feature. + */ +# if !defined (_STLP_DONT_USE_AUTO_LINK) || defined (__BUILDING_STLPORT) +# pragma comment (lib, "bufferoverflowU.lib") +# if defined (_STLP_VERBOSE) +# pragma message ("STLport: Auto linking to bufferoverflowU.lib") +# endif +# endif +#endif + +#if defined (_STLP_MSVC) +# include +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_mwerks.h b/sdk/tlibstdcxx/stlport/stl/config/_mwerks.h new file mode 100644 index 0000000000..f91f3b181b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_mwerks.h @@ -0,0 +1,159 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +#define _STLP_COMPILER "Metrowerk Codewarrior" + +// Bring in definition of __MSL__ and related items +#include +#include + +// +// Compiler features +// + + +// *** CodeWarrior Compiler Common Features *** +# if __option(longlong) +# define _STLP_LONG_LONG long long +# endif + +# define _STLP_USE_UNIX_EMULATION_IO 1 + +# define _STLP_USE_AUTO_PTR_CONVERSIONS 1 + +# ifdef __INTEL__ +# define _STLP_LITTLE_ENDIAN +# else +# define _STLP_BIG_ENDIAN +# endif + +#if defined(_MSL_NO_LOCALE) +#define _STLP_NO_IMPORT_LOCALE +#endif +#if !__option( wchar_type ) +# define _STLP_WCHAR_T_IS_USHORT +#endif + +# if __MWERKS__ < 0x3000 +// *** CodeWarrior Compiler Common Bugs *** +# define __MSL_FIX_ITERATORS__(myType) // Some MSL headers rely on this +# define _STLP_THROW_RETURN_BUG 1 +# endif + +// *** Version-specific settings *** + +# if __MWERKS__ >= 0x2405 +# define _STLP_HAS_NATIVE_FLOAT_ABS +# endif + +# if __MWERKS__ < 0x2405 +# define _STLP_STATIC_CONST_INIT_BUG +# endif + +# if __MWERKS__ <= 0x2303 +# define _STLP_NO_TEMPLATE_CONVERSIONS 1 +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# endif + +# if __MWERKS__ < 0x2301 +# define _STLP_MEMBER_SPECIALIZATION_BUG 1 +# endif + +# if __MWERKS__ < 0x2300 // CW Pro5 features +# define _STLP_INLINE_MEMBER_TEMPLATES 1 +# define _STLP_RELOPS_IN_STD_BUG 1 +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +# define _STLP_DEF_CONST_DEF_PARAM_BUG 1 +# define _STLP_NO_TYPENAME_ON_RETURN_TYPE +# endif + +# if __MWERKS__ < 0x2200 // CW Pro4 features +# define _STLP_BROKEN_USING_DIRECTIVE 1 +# define _STLP_NO_MEMBER_TEMPLATES 1 +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# define _STLP_NO_QUALIFIED_FRIENDS 1 +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 +# endif + +# if __MWERKS__ < 0x2100 // CW Pro3 features +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# define _STLP_HAS_NO_NAMESPACES 1 +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 1 + +# define _STLP_NEED_TYPENAME 1 +# define _STLP_NO_ARROW_OPERATOR 1 +# define _STLP_TEMPLATE_PARAM_SUBTYPE_BUG 1 +# define _STLP_FORCED_INLINE_INSTANTIATION_BUG 1 +# define _STLP_MULTI_CONST_TEMPLATE_ARG_BUG 1 +# define _STLP_INLINE_NAME_RESOLUTION_BUG 1 +// *** Metrowerks Standard Library Bug *** +# define _STLP_MSVC50_COMPATIBILITY 1 +# endif + +# if __MWERKS__ < 0x2000 // v. 2.0 features +# define _STLP_NO_WCHAR_T 1 +# define _STLP_NO_DEFAULT_NON_TYPE_PARAM 1 +# define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 // dwa 8/21/97 - this bug fixed for CWPro2 +# endif + +# if __MWERKS__ < 0x1900 // dwa 8/19/97 - 1.9 Compiler feature defines +# define _STLP_LIMITED_DEFAULT_TEMPLATES 1 +# define _STLP_BASE_TYPEDEF_BUG 1 +# define _STLP_BASE_MATCH_BUG 1 +# define _STLP_NONTEMPL_BASE_MATCH_BUG 1 +# define _STLP_DEFAULT_TYPE_PARAM 1 // More limited template parameters + +# if __MWERKS__ < 0x1800 + __GIVE_UP_WITH_STL(CW_18) +# endif + +# endif + + +// fixes to native inclusion wrappers. +# if __MWERKS__ >= 0x2300 // CWPro5 changes paths - dwa 2/28/99 +# define _STLP_NATIVE_INCLUDE_PATH ../include +# define _STLP_NATIVE_C_INCLUDE_PATH ../include +# define _STLP_NATIVE_HEADER(header) <../include/##header> +# define _STLP_NATIVE_CPP_C_HEADER(header) <../include/##header> +# define _STLP_NATIVE_C_HEADER(header) <../include/##header> +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../include/##header> +# else + +# define _STLP_NATIVE_INCLUDE_PATH Macintosh HD:Codewarrior Pro 4:Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C++:Include +# define _STLP_NATIVE_C_INCLUDE_PATH Macintosh HD:Codewarrior Pro 4:Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:MSL Common:Public Includes +# define _STLP_NATIVE_HEADER(header) +# define _STLP_NATIVE_CPP_C_HEADER(header) +# define _STLP_NATIVE_C_HEADER(header) +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) + +# endif + +//Following block come from boost intrinsics.hpp file: +#if defined (__MSL_CPP__) && (__MSL_CPP__ >= 0x8000) + // Metrowerks compiler is acquiring intrinsic type traits support + // post version 8. We hook into the published interface to pick up + // user defined specializations as well as compiler intrinsics as + // and when they become available: +# include +# define _STLP_HAS_TRIVIAL_CONSTRUCTOR(T) Metrowerks::has_trivial_default_ctor::value +# define _STLP_HAS_TRIVIAL_COPY(T) Metrowerks::has_trivial_copy_ctor::value +# define _STLP_HAS_TRIVIAL_ASSIGN(T) Metrowerks::has_trivial_assignment::value +# define _STLP_HAS_TRIVIAL_DESTRUCTOR(T) Metrowerks::has_trivial_dtor::value +# define _STLP_IS_POD(T) Metrowerks::is_POD::value +# define _STLP_HAS_TYPE_TRAITS_INTRINSICS +#endif + +// fbp +# if !defined( __MSL_CPP__ ) || __MSL_CPP__ <= 0x4105 +# define _STLP_NO_NATIVE_WIDE_STREAMS 1 +# endif + +# if defined(__MACH__) +# define _STLP_MAC +# define O_BINARY 0 +# elif defined(macintosh) +# define _NOTHREADS +# endif +# define _STLP_DLLEXPORT_NEEDS_PREDECLARATION 1 diff --git a/sdk/tlibstdcxx/stlport/stl/config/_native_headers.h b/sdk/tlibstdcxx/stlport/stl/config/_native_headers.h new file mode 100644 index 0000000000..f1f4bc9324 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_native_headers.h @@ -0,0 +1,50 @@ + /* + * + * Copyright (c) 2006 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_MAKE_HEADER) +# define _STLP_MAKE_HEADER(path, header) +#endif + +#if !defined (_STLP_NATIVE_HEADER) +# if !defined (_STLP_NATIVE_INCLUDE_PATH) +# define _STLP_NATIVE_INCLUDE_PATH ../include +# endif +# define _STLP_NATIVE_HEADER(header) _STLP_MAKE_HEADER(_STLP_NATIVE_INCLUDE_PATH,header) +#endif + +/* For some compilers, C headers like are located in separate directory */ +#if !defined (_STLP_NATIVE_C_HEADER) +# if !defined (_STLP_NATIVE_C_INCLUDE_PATH) +# define _STLP_NATIVE_C_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +# endif +# define _STLP_NATIVE_C_HEADER(header) _STLP_MAKE_HEADER(_STLP_NATIVE_C_INCLUDE_PATH,header) +#endif + +/* For some compilers, C-library headers like are located in separate directory */ +#if !defined (_STLP_NATIVE_CPP_C_HEADER) +# if !defined (_STLP_NATIVE_CPP_C_INCLUDE_PATH) +# define _STLP_NATIVE_CPP_C_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +# endif +# define _STLP_NATIVE_CPP_C_HEADER(header) _STLP_MAKE_HEADER(_STLP_NATIVE_CPP_C_INCLUDE_PATH,header) +#endif + +/* Some compilers locate basic C++ runtime support headers (, , ) in separate directory */ +#if !defined ( _STLP_NATIVE_CPP_RUNTIME_HEADER ) +# if !defined (_STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH) +# define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +# endif +# define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) _STLP_MAKE_HEADER(_STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH,header) +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_openbsd.h b/sdk/tlibstdcxx/stlport/stl/config/_openbsd.h new file mode 100644 index 0000000000..86a19d1f3b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_openbsd.h @@ -0,0 +1,12 @@ +#define _STLP_PLATFORM "Open BSD" + +#define _STLP_USE_UNIX_IO + +#if defined (_POSIX_THREADS) && !defined (_STLP_THREADS) +# define _STLP_THREADS +#endif + +#if defined (_POSIX_THREADS) && !defined (_STLP_DONT_USE_PTHREAD_SPINLOCK) +# define _STLP_USE_PTHREAD_SPINLOCK +# define _STLP_STATIC_MUTEX _STLP_mutex +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_prolog.h b/sdk/tlibstdcxx/stlport/stl/config/_prolog.h new file mode 100644 index 0000000000..a16a794695 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_prolog.h @@ -0,0 +1,43 @@ + +#if defined (_STLP_MSVC) || defined (__ICL) + +# pragma warning (push) +# include +/* We are forcing the alignment to guaranty that libraries are use + * with the same alignment as the one use to build them. + */ +# if !defined (_WIN64) +# pragma pack(push, 8) +# else +# pragma pack(push, 16) +# endif + +#elif defined (__BORLANDC__) + +# pragma option push +# pragma option -Vx- -Ve- -a8 -b -pc +# include + +#elif defined (__sgi) && !defined (__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) + +# pragma set woff 1209 +# pragma set woff 1174 +# pragma set woff 1375 +/* from iterator_base.h */ +# pragma set woff 1183 + +#elif defined (__DECCXX) + +# ifdef __PRAGMA_ENVIRONMENT +# pragma __environment __save +# pragma __environment __header_defaults +# endif + +#elif defined (__IBMCPP__) +/* supress EDC3130: A constant is being used as a conditional expression */ +# pragma info(nocnd) +#elif defined (__WATCOMCPLUSPLUS__) +# pragma warning 604 10 /* must lookahead to determine... */ +# pragma warning 594 10 /* resolved as declaration/type */ +# pragma warning 595 10 /* resolved as an expression */ +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_sgi.h b/sdk/tlibstdcxx/stlport/stl/config/_sgi.h new file mode 100644 index 0000000000..7500f3d87b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_sgi.h @@ -0,0 +1,94 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +#define _STLP_COMPILER "CC" + +#define _STLP_HAS_SPECIFIC_PROLOG_EPILOG + +// define native include path before trying to include anything + +#define _STLP_NATIVE_HEADER(__x) +#define _STLP_NATIVE_C_HEADER(__x) +#define _STLP_NATIVE_OLD_STREAMS_HEADER(__x) +#define _STLP_NATIVE_CPP_C_HEADER(__x) +#define _STLP_NATIVE_CPP_RUNTIME_HEADER(__x) + +#define _STLP_NO_NATIVE_MBSTATE_T + +#define _STLP_NO_USING_FOR_GLOBAL_FUNCTIONS +#define _STLP_NO_NATIVE_WIDE_FUNCTIONS +#define _STLP_NO_MEMBER_TEMPLATE_CLASSES + +// #define _STLP_NO_BAD_ALLOC + +#define _STL_HAS_NAMESPACES + +#if ! defined (__EXCEPTIONS) && ! defined (_STLP_NO_EXCEPTIONS) +# define _STLP_NO_EXCEPTIONS +#endif + +#define __EDG_SWITCHES + +#define _STLP_USE_SGI_STRING 1 + +#define _STLP_HAS_NO_NEW_C_HEADERS 1 +// # define _STLP_VENDOR_GLOBAL_EXCEPT_STD + +#define _STLP_NO_POST_COMPATIBLE_SECTION + +#include + +#if !(_COMPILER_VERSION >= 730) +# define _STLP_NO_NEW_NEW_HEADER 1 +#endif + +#if (_COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)) +# define _STLP_EXTERN_RANGE_ERRORS +#endif + +#if !defined(_BOOL) +# define _STLP_NO_BOOL +#endif +#if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32 +# define _STLP_STATIC_CONST_INIT_BUG +#endif + +#if (_COMPILER_VERSION < 720) || (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) +# define _STLP_DEF_CONST_PLCT_NEW_BUG +# define _STLP_DEF_CONST_DEF_PARAM_BUG +#endif +#if !((_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32) +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD +#endif +#if !defined(_STANDARD_C_PLUS_PLUS) +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS +#endif +#if !((_COMPILER_VERSION >= 721) && defined(_NAMESPACES)) +# define _STLP_HAS_NO_NAMESPACES +#endif +#if (_COMPILER_VERSION < 721) || !defined(_STL_HAS_NAMESPACES) || defined(_STLP_NO_NAMESPACES) +# define _STLP_NO_EXCEPTION_HEADER +#endif +#if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || !defined(_NAMESPACES) +# define _STLP_NO_BAD_ALLOC +#endif +#if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI +# define _STLP_LONG_LONG long long +#endif +#if !(_COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)) +# define _STLP_USE_NO_IOSTREAMS +#endif +#if !(_COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)) +# define _STLP_NO_AT_MEMBER_FUNCTION +#endif +// # if !(_COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)) +#if !(_COMPILER_VERSION >= 721 && defined(_STANDARD_C_PLUS_PLUS)) +# define _STLP_NO_TEMPLATE_CONVERSIONS +#endif +#if !((_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32) +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER +#endif + +#if !defined (_NOTHREADS) && !defined (_STLP_THREADS_DEFINED) && !defined (__GNUC__) +# define _STLP_SGI_THREADS +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_sgx.h b/sdk/tlibstdcxx/stlport/stl/config/_sgx.h new file mode 100644 index 0000000000..7d58a804b2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_sgx.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly */ + +#define _STLP_SGX_CONFIG 1 + +/* Use new C headers in STLport instead */ +#define _STLP_HAS_NO_NEW_C_HEADERS 1 + +//#define _STLP_USE_NATIVE_STDEXCEPT 1 +//#define _STLP_NO_EXCEPTION_HEADER 1 + +/* Disable wcstombs, wctomb */ +#define _STLP_NO_NATIVE_WIDE_STREAMS 1 + +/* Use separated C/C++ Runtime directories */ +#define _STLP_NATIVE_C_INCLUDE_PATH tlibc +#define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH stdc++ + +/* No I/O operations that involve OCalls allowed */ +#define _STLP_NO_IOSTREAMS 1 + +/* Do not use secure routines in CRT */ +#define _CRT_SECURE_NO_DEPRECATE 1 + +/* Do not support move semantic (C++11) */ +#define _STLP_NO_MOVE_SEMANTIC 1 diff --git a/sdk/tlibstdcxx/stlport/stl/config/_solaris.h b/sdk/tlibstdcxx/stlport/stl/config/_solaris.h new file mode 100644 index 0000000000..8756a060f7 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_solaris.h @@ -0,0 +1,77 @@ +#ifndef __stl_config__solaris_h +#define __stl_config__solaris_h + +#define _STLP_PLATFORM "Sun Solaris" + +/* include system features file */ +#include + +/* system-dependent defines */ +#define _STLP_USE_UNIX_IO + +#ifdef __GNUC__ +/* + * See comments (and configuration defines) in the host.h + */ +# if !(defined(__SunOS_5_5_1) || defined(__SunOS_5_6) || defined(__SunOS_5_7) || \ + defined(__SunOS_5_8) || defined(__SunOS_5_9) || defined(__SunOS_5_10)) +# error Uncomment one of the defines (__SunOS_5_x) in the file stlport/stl/config/host.h +# endif +#endif + +#if defined (__SunOS_5_8) && ! defined (_STLP_HAS_NO_NEW_C_HEADERS) && ( __cplusplus >= 199711L) +# define _STLP_HAS_NATIVE_FLOAT_ABS +#endif + +#if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) +# define _STLP_RAND48 1 +#endif + +#if (defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4)) || defined (__SunOS_5_6) +# define _STLP_WCHAR_SUNPRO_EXCLUDE 1 +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 +#endif + +/* boris : this should always be defined for Solaris 5 & 6. Any ideas how to do it? */ +#if !(defined ( __KCC ) && __KCC_VERSION > 3400 ) && \ + ((defined(__SunOS_5_5_1) || defined(__SunOS_5_6) )) +# ifndef _STLP_NO_NATIVE_MBSTATE_T +# define _STLP_NO_NATIVE_MBSTATE_T 1 +# endif +#endif /* KCC */ + +/* For SPARC we use lightweight synchronization */ +#if defined (__sparc) /* && (defined (_REENTRANT) || defined (_PTHREADS)) */ +# if ( (defined (__GNUC__) && defined (__sparc_v9__)) || \ + defined (__sparcv9) ) \ + && !defined(_NOTHREADS) && !defined (_STLP_NO_SPARC_SOLARIS_THREADS) +# define _STLP_SPARC_SOLARIS_THREADS +# define _STLP_THREADS_DEFINED +# endif +#endif + +/* gcc does not support ELF64 yet ; however; it supports ultrasparc + v8plus. + * limits.h contains invalid values for this combination + */ +#ifdef __GNUC__ +# if (defined (__sparc_v9__) || defined (__sparcv9)) && !defined ( __WORD64 ) && !defined(__arch64__) +# define __LONG_MAX__ 2147483647L +# endif +#endif + +/* + * Attention! See comments (and configuration defines) in the host.h + * (you host may has MATH_F and MATH_L functions) + * + */ +#if !defined(__SunOS_5_10) && !defined(_STLP_SOLARIS_MATH_PATCH) +# define _STLP_NO_VENDOR_MATH_F +# define _STLP_NO_VENDOR_MATH_L +#endif + +#ifdef __GNUC__ +# define _STLP_WCHAR_BORLAND_EXCLUDE +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 +#endif + +#endif /* __stl_config__solaris_h */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/_sunprocc.h b/sdk/tlibstdcxx/stlport/stl/config/_sunprocc.h new file mode 100644 index 0000000000..15fe5cd11b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_sunprocc.h @@ -0,0 +1,166 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +#define _STLP_COMPILER "Sunpro CC" + +#define _STLP_LONG_LONG long long + +// GAB: 11/09/05 +// Starting with 5.0 the STLport code expects to be +// instantiated during compile time. This is due to undefing +// a number of defines that are also used in the c versions +// of the file. When they are undefed the c version fails to +// compile. +// # define _STLP_LINK_TIME_INSTANTIATION 1 + +#if ! defined(_BOOL) +# define _STLP_NO_BOOL 1 +#endif + +// compatibility mode stuff +#if (__SUNPRO_CC >= 0x510) && (!defined (__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT == 5 )) +# define _STLP_NATIVE_INCLUDE_PATH ../CC/Cstd +# define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH ../CC +#elif (__SUNPRO_CC >= 0x500) && (!defined (__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT == 5 )) +# define _STLP_NATIVE_INCLUDE_PATH ../CC +#elif (defined (__SUNPRO_CC_COMPAT) && __SUNPRO_CC_COMPAT == 4) +# define _STLP_NATIVE_INCLUDE_PATH ../CC4 +#else +# define _STLP_NATIVE_INCLUDE_PATH ../CC +#endif + +#define _STLP_STATIC_CONST_INIT_BUG 1 + +#if (__SUNPRO_CC < 0x530) +// those are tested and proved not to work... +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# define _STLP_USE_OLD_HP_ITERATOR_QUERIES +#endif + +#ifdef _STLP_USE_NO_IOSTREAMS +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +#endif + +// those do not depend on compatibility +#if (__SUNPRO_CC < 0x510) +# define _STLP_NO_TYPENAME_ON_RETURN_TYPE 1 +# define _STLP_NONTEMPL_BASE_MATCH_BUG 1 +#endif + +#if (__SUNPRO_CC < 0x510) || (defined (__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT < 5)) + +# define _STLP_NO_QUALIFIED_FRIENDS 1 + +// no partial , just for explicit one +# define _STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS +# define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 + +# define _STLP_NO_MEMBER_TEMPLATES 1 + +# define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 +# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +#endif + +// Features that depend on compatibility switch +#if ( __SUNPRO_CC < 0x500 ) || (defined (__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT < 5)) + +# ifndef _STLP_USE_NO_IOSTREAMS +# define _STLP_USE_NO_IOSTREAMS 1 +# endif +# define _STLP_NO_NEW_NEW_HEADER 1 +// # define _STLP_NO_RELOPS_NAMESPACE +# define _STLP_HAS_NO_NAMESPACES 1 +# define _STLP_NEED_MUTABLE 1 +# define _STLP_NO_BAD_ALLOC 1 +# define _STLP_NO_EXCEPTION_HEADER 1 +# define _STLP_NATIVE_C_INCLUDE_PATH ../include +#elif (__SUNPRO_CC < 0x510) +// # define _STLP_NATIVE_C_HEADER(header) <../CC/##header##.SUNWCCh> +# define _STLP_NATIVE_CPP_C_HEADER(header) <../CC/##header##.SUNWCCh> +# define _STLP_NATIVE_C_INCLUDE_PATH /usr/include +#elif defined( __SunOS_5_5_1 ) || defined( __SunOS_5_6 ) || defined( __SunOS_5_7 ) +# define _STLP_NATIVE_C_INCLUDE_PATH ../CC/std +# define _STLP_NATIVE_CPP_C_INCLUDE_PATH ../CC/std +#else +# define _STLP_NATIVE_C_INCLUDE_PATH /usr/include +# define _STLP_NATIVE_CPP_C_INCLUDE_PATH ../CC/std +#endif + +#if ( __SUNPRO_CC < 0x500 ) + +# undef _STLP_NATIVE_C_HEADER +# undef _STLP_NATIVE_CPP_C_HEADER + +# define wint_t __wint_t +// famous CC 4.2 bug +# define _STLP_INLINE_STRING_LITERAL_BUG 1 +// /usr/include +# define _STLP_NATIVE_C_INCLUDE_PATH ../include + +// 4.2 cannot handle iterator_traits<_Tp>::iterator_category as a return type ;( +# define _STLP_USE_OLD_HP_ITERATOR_QUERIES + +// 4.2 does not like it +# undef _STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS + +# define _STLP_LIMITED_DEFAULT_TEMPLATES 1 + +# define _STLP_NEED_TYPENAME 1 +# define _STLP_NEED_EXPLICIT 1 +# define _STLP_NO_BAD_ALLOC 1 +# define _STLP_NO_ARROW_OPERATOR 1 + +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +# define _STLP_DEF_CONST_DEF_PARAM_BUG 1 +# define _STLP_GLOBAL_NESTED_RETURN_TYPE_PARAM_BUG 1 +# undef _STLP_HAS_NO_NEW_C_HEADERS +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +// # define _STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS + +# if ( __SUNPRO_CC < 0x420 ) +# define _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX 1 +# define _STLP_NO_NEW_STYLE_CASTS 1 +# define _STLP_NO_METHOD_SPECIALIZATION 1 +# if ( __SUNPRO_CC > 0x401 ) +# if (__SUNPRO_CC==0x410) +# define _STLP_BASE_TYPEDEF_OUTSIDE_BUG 1 +# endif +# else + // SUNPro C++ 4.0.1 +# define _STLP_BASE_MATCH_BUG 1 +# define _STLP_BASE_TYPEDEF_BUG 1 +# if (( __SUNPRO_CC < 0x401 ) && !defined(__SUNPRO_C)) + __GIVE_UP_WITH_STL(SUNPRO_401) +# endif +# endif /* 4.0.1 */ +# endif /* 4.2 */ +#endif /* < 5.0 */ + +#ifndef _MBSTATET_H +# define _MBSTATET_H +# undef _MBSTATE_T +# define _MBSTATE_T +typedef struct __mbstate_t { +# if defined(_LP64) + long __filler[4]; +# else + int __filler[6]; +# endif +} __mbstate_t; +# ifndef _STLP_HAS_NO_NAMESPACES +namespace std { + typedef __mbstate_t mbstate_t; +} +using std::mbstate_t; +# else +typedef __mbstate_t mbstate_t; +# endif +#endif /* __MBSTATET_H */ + +#if !defined(_STLP_HAS_NO_NEW_C_HEADERS) && !defined(_STLP_NO_NEW_C_HEADERS) +/* Since Sun Studio uses , we are at its + * mercy. GCC is built on top of . */ +#define _STLP_NO_VENDOR_STDLIB_L +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_system.h b/sdk/tlibstdcxx/stlport/stl/config/_system.h new file mode 100644 index 0000000000..a2dbb938dd --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_system.h @@ -0,0 +1,171 @@ +/* + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * Purpose of this file : + * + * To hold COMPILER-SPECIFIC portion of STLport settings. + * In general, user should not edit this file unless + * using the compiler not recognized below. + * + * If your compiler is not being recognized yet, + * please look for definitions of macros in stl_mycomp.h, + * copy stl_mycomp.h to stl_YOUR_COMPILER_NAME, + * adjust flags for your compiler, and add + * to the secton controlled by unique macro defined internaly by your compiler. + * + * To change user-definable settings, please edit + * + */ + +#ifndef __stl_config__system_h +#define __stl_config__system_h + +#if defined (__sun) +# include +# if defined (__GNUC__) +# include +# elif defined (__SUNPRO_CC) || defined (__SUNPRO_C) +# include +/* +# ifdef __KCC +# include +# endif +*/ +# elif defined (__APOGEE__) /* Apogee 4.x */ +# include +# elif defined (__FCC_VERSION) /* Fujitsu Compiler, v4.0 assumed */ +# include +# endif +#elif defined (__hpux) +# include +# if defined (__GNUC__) +# include +# elif defined (__HP_aCC) +# include +# endif +#elif defined (linux) || defined (__linux__) +# include +# if defined (__BORLANDC__) +# include /* Borland C++ 0x570 */ +/* Intel's icc define __GNUC__! */ +# elif defined (__INTEL_COMPILER) +# include +# elif defined (__GNUC__) +# include +# endif +/* +# ifdef __KCC +# include +# endif +*/ +#elif defined (__FreeBSD__) +# include +# if defined (__GNUC__) +# include +# endif +#elif defined (__OpenBSD__) +# include +# if defined (__GNUC__) +# include +# endif +#elif defined (__sgi) /* IRIX? */ +# define _STLP_PLATFORM "SGI Irix" +# if defined (__GNUC__) +# include +# else +# include +# endif +#elif defined (__OS400__) /* AS/400 C++ */ +# define _STLP_PLATFORM "OS 400" +# if defined (__GNUC__) +# include +# else +# include +# endif +#elif defined (_AIX) +# include +# if defined (__xlC__) || defined (__IBMC__) || defined ( __IBMCPP__ ) + /* AIX xlC, Visual Age C++ , OS-390 C++ */ +# include +# endif +#elif defined (_CRAY) /* Cray C++ 3.4 or 3.5 */ +# define _STLP_PLATFORM "Cray" +# include +#elif defined (__DECCXX) || defined (__DECC) +# define _STLP_PLATFORM "DECC" +# ifdef __vms +# include +# else +# include +# endif +#elif defined (macintosh) || defined (_MAC) +# include +# if defined (__MWERKS__) +# include +# endif +#elif defined (__APPLE__) +# include +# ifdef __GNUC__ +# include +# endif +#elif defined (__CYGWIN__) +# include +# if defined (__GNUC__) +# include +# endif +#elif defined (__MINGW32__) +# define _STLP_PLATFORM "MinGW" +# if defined (__GNUC__) +# include +# endif +# include +#elif defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__) || \ + defined (__WIN16) || defined (WIN16) || defined (_WIN16) +# if defined ( __BORLANDC__ ) /* Borland C++ / CodeGear C++ */ +# include +# elif defined (__WATCOM_CPLUSPLUS__) || defined (__WATCOMC__) /* Watcom C++ */ +# include +# elif defined (__COMO__) || defined (__COMO_VERSION_) +# include +# elif defined (__DMC__) /* Digital Mars C++ */ +# include +# elif defined (__ICL) /* Intel reference compiler for Win */ +# include +# elif defined (__MWERKS__) +# include +# elif defined (_MSC_VER) && (_MSC_VER >= 1200) && defined (UNDER_CE) + /* Microsoft eMbedded Visual C++ 3.0, 4.0 (.NET) */ +# include +# elif defined (_MSC_VER) + /* Microsoft Visual C++ 6.0, 7.0, 7.1, 8.0 */ +# include +# endif + +# include +#else +# error Unknown platform !! +#endif + +#if !defined (_STLP_COMPILER) +/* Unable to identify the compiler, issue error diagnostic. + * Edit to set STLport up for your compiler. */ +# include +#endif + +#endif /* __stl_config__system_h */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/_warnings_off.h b/sdk/tlibstdcxx/stlport/stl/config/_warnings_off.h new file mode 100644 index 0000000000..77e9815ebc --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_warnings_off.h @@ -0,0 +1,51 @@ +/* This header turns off warnings that STLport headers generate for compiled + * user code. + */ + +#if defined (_STLP_MSVC) +# if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ + defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +/* + * 31/07/2004: dums - now that we do not export the basic_string class anymore but only a base class + * we have to disable this warning as the string are used as data members type of many iostream classes. + */ +# pragma warning ( disable : 4251 ) // ignore template classes being exported in .dll's +# endif + +# if (_STLP_MSVC < 1300) // VC6, eVC3, eVC4 +# pragma warning( disable : 4097 ) // typedef-name used as based class of (...) +# pragma warning( disable : 4231 ) // non standard extension : 'extern' before template instanciation +# pragma warning( disable : 4244 ) // implicit conversion: possible loss of data +# pragma warning( disable : 4284 ) // for -> operator +//This warning is necessary because of the native platform headers: +# pragma warning( disable : 4290 ) // c++ exception specification ignored +# pragma warning( disable : 4514 ) // unreferenced inline function has been removed +# pragma warning( disable : 4660 ) // template-class specialization '...' is already instantiated +# pragma warning( disable : 4701 ) // local variable '...' may be used without having been initialized +# pragma warning( disable : 4710 ) // function (...) not inlined +# pragma warning( disable : 4786 ) // identifier truncated to 255 characters +# endif + +# if (_STLP_MSVC < 1400) +# pragma warning( disable : 4511 ) // copy constructor cannot be generated +# endif + +//Pool of common warnings for all MSVC supported versions: +//Many are only useful if warning level is set to 4. +# pragma warning( disable : 4100 ) // unreferenced formal parameter +# pragma warning( disable : 4127 ) // conditional expression is constant +# pragma warning( disable : 4146 ) // unary minus operator applied to unsigned type, result still unsigned +# pragma warning( disable : 4245 ) // conversion from 'enum ' to 'unsigned int', signed/unsigned mismatch +# pragma warning( disable : 4355 ) // this used in base member initializer list (used in rope implementation) +# pragma warning( disable : 4510 ) // default constructor cannot be generated +# pragma warning( disable : 4512 ) // assignment operator could not be generated +# pragma warning( disable : 4571 ) // catch(...) blocks compiled with /EHs do not catch or re-throw Structured Exceptions +# pragma warning( disable : 4610 ) // struct '...' can never be instantiated - user defined construtor required +#elif defined (__BORLANDC__) +# pragma option -w-ccc // -w-8008 Condition is always true OR Condition is always false +# pragma option -w-inl // -w-8027 Functions containing reserved words are not expanded inline +# pragma option -w-ngu // -w-8041 Negating unsigned value +# pragma option -w-pow // -w-8062 Previous options and warnings not restored +# pragma option -w-rch // -w-8066 Unreachable code +# pragma option -w-par // -w-8057 Parameter 'parameter' is never used +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/_watcom.h b/sdk/tlibstdcxx/stlport/stl/config/_watcom.h new file mode 100644 index 0000000000..b0d2defee4 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_watcom.h @@ -0,0 +1,151 @@ +// STLport configuration file +// It is internal STLport header - DO NOT include it directly + +#define _STLP_COMPILER "Watcom" + +#if (__WATCOMC__ < 1250) +# error Not supported! +#endif + +#ifndef _CPPRTTI +# define _STLP_NO_RTTI 1 +#endif + +// for switches (-xs, -xss, -xst) +#if !(defined (__SW_XS) || defined (__SW_XSS) || defined(__SW_XST)) +# define _STLP_HAS_NO_EXCEPTIONS 1 +#endif + +#if defined (_MT) && !defined (_NOTHREADS) +# define _STLP_THREADS 1 +#endif + +#define _STLP_NO_VENDOR_STDLIB_L +#define _STLP_NO_VENDOR_MATH_F +#define _STLP_NO_VENDOR_MATH_L + +#define _STLP_LONG_LONG long long + +#define _STLP_CALL __cdecl +#define _STLP_IMPORT_DECLSPEC __declspec(dllimport) + +#define _STLP_NO_CONST_IN_PAIR + +//#define _STLP_DONT_USE_PRIV_NAMESPACE +//#define _STLP_NO_MOVE_SEMANTIC +//#define _STLP_NO_TYPENAME_IN_TEMPLATE_HEADER +#define _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE + +#define _STLP_NO_RELOPS_NAMESPACE + +#define _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS +#define _STLP_NO_STATIC_CONST_DEFINITION + +//#define _STLP_HAS_SPECIFIC_PROLOG_EPILOG +#define _STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS +//#define _STLP_USE_OLD_HP_ITERATOR_QUERIES + +#define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 +#define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +//#define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +//#define _STLP_NO_MEMBER_TEMPLATES 1 +//#define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 + +//#define _STLP_LIMITED_DEFAULT_TEMPLATES 1 +//#define _STLP_HAS_NO_NAMESPACES 1 +//#define _STLP_NEED_TYPENAME 1 + +#define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 1 + +//#define _STLP_STATIC_CONST_INIT_BUG 1 +// #define _STLP_THROW_RETURN_BUG 1 +//#define _STLP_NO_TEMPLATE_CONVERSIONS 1 + +#define _STLP_BASE_TYPEDEF_OUTSIDE_BUG 1 + +#define _STLP_NO_DEFAULT_NON_TYPE_PARAM 1 +#define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 + +//#define _STLP_NONTEMPL_BASE_MATCH_BUG +//#define _STLP_NO_EXCEPTION_HEADER 1 +#define _STLP_NO_BAD_ALLOC 1 + +//#define _STLP_NO_TYPENAME_ON_RETURN_TYPE +//#define _STLP_NESTED_TYPE_PARAM_BUG 1 + +//#define _STLP_NO_USING_FOR_GLOBAL_FUNCTIONS 1 + +#define _STLP_NO_ARROW_OPERATOR 1 +// This one is present in 11, but apparently has bugs (with auto_ptr). +//#define _STLP_NO_NEW_STYLE_CASTS 1 + +// Get rid of Watcom's min and max macros +#undef min +#undef max + +// On QNX, headers are supposed to be found in /usr/include, +// so default "../include" should work. +#ifndef __QNX__ +# define _STLP_NATIVE_INCLUDE_PATH ../h +#else +// boris : is this true or just the header is not in /usr/include ? +# define _STLP_NO_TYPEINFO 1 +#endif + +// Inline replacements for locking calls under Watcom +// Define _STLP_NO_WATCOM_INLINE_INTERLOCK to keep using +// standard WIN32 calls +// Define _STL_MULTIPROCESSOR to enable lock +#define _STLP_NO_WATCOM_INLINE_INTERLOCK +#if !defined(_STLP_NO_WATCOM_INLINE_INTERLOCK) + +long __stl_InterlockedIncrement( long *var ); +long __stl_InterlockedDecrement( long *var ); + +#ifdef _STL_MULTIPROCESSOR +// Multiple Processors, add lock prefix +#pragma aux __stl_InterlockedIncrement parm [ ecx ] = \ + ".586" \ + "mov eax, 1" \ + "lock xadd [ecx], eax" \ + "inc eax" \ + value [eax]; + + +#pragma aux __stl_InterlockedDecrement parm [ ecx ] = \ + ".586" \ + "mov eax, 0FFFFFFFFh" \ + "lock xadd [ecx], eax" \ + "dec eax" \ + value [eax]; +#else +// Single Processor, lock prefix not needed +#pragma aux __stl_InterlockedIncrement parm [ ecx ] = \ + ".586" \ + "mov eax, 1" \ + "xadd [ecx], eax" \ + "inc eax" \ + value [eax]; + +#pragma aux __stl_InterlockedDecrement parm [ ecx ] = \ + ".586" \ + "mov eax, 0FFFFFFFFh" \ + "xadd [ecx], eax" \ + "dec eax" \ + value [eax]; +#endif // _STL_MULTIPROCESSOR + +long __stl_InterlockedExchange( long *Destination, long Value ); + +// xchg has auto-lock +#pragma aux __stl_InterlockedExchange parm [ecx] [eax] = \ + ".586" \ + "xchg eax, [ecx]" \ + value [eax]; + +# define _STLP_ATOMIC_INCREMENT(__x) __stl_InterlockedIncrement((long*)__x) +# define _STLP_ATOMIC_DECREMENT(__x) __stl_InterlockedDecrement((long*)__x) +# define _STLP_ATOMIC_EXCHANGE(__x, __y) __stl_InterlockedExchange((long*)__x, (long)__y) +# define _STLP_ATOMIC_EXCHANGE_PTR(__x, __y) __stl_InterlockedExchange((long*)__x, (long)__y) +#endif /* INLINE INTERLOCK */ + diff --git a/sdk/tlibstdcxx/stlport/stl/config/_windows.h b/sdk/tlibstdcxx/stlport/stl/config/_windows.h new file mode 100644 index 0000000000..c8c41adfc5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/_windows.h @@ -0,0 +1,293 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_INTERNAL_WINDOWS_H +#define _STLP_INTERNAL_WINDOWS_H + +#if !defined (_STLP_PLATFORM) +# define _STLP_PLATFORM "Windows" +#endif + +#if !defined (_STLP_BIG_ENDIAN) && !defined (_STLP_LITTLE_ENDIAN) +# if defined (_MIPSEB) +# define _STLP_BIG_ENDIAN 1 +# endif +# if defined (__i386) || defined (_M_IX86) || defined (_M_ARM) || \ + defined (__amd64__) || defined (_M_AMD64) || defined (__x86_64__) || \ + defined (__alpha__) +# define _STLP_LITTLE_ENDIAN 1 +# endif +# if defined (__ia64__) + /* itanium allows both settings (for instance via gcc -mbig-endian) - hence a seperate check is required */ +# if defined (__BIG_ENDIAN__) +# define _STLP_BIG_ENDIAN 1 +# else +# define _STLP_LITTLE_ENDIAN 1 +# endif +# endif +#endif /* _STLP_BIG_ENDIAN */ + +#if !defined (_STLP_SGX_CONFIG) +#if !defined (_STLP_WINDOWS_H_INCLUDED) +# define _STLP_WINDOWS_H_INCLUDED +# if defined (__BUILDING_STLPORT) +# include +/* Here we define _STLP_OUTERMOST_HEADER_ID to avoid indirect inclusion + * of STLport stuffs from C/C++ Standard headers exposed by STLport + * as configuration is not yet completed. */ +# if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x100 +# endif +# if !defined (WIN32_LEAN_AND_MEAN) +# define WIN32_LEAN_AND_MEAN +# endif +# if !defined (VC_EXTRALEAN) +# define VC_EXTRALEAN +# endif +/* Don't let windows.h define its min and max macros. */ +# if !defined (NOMINMAX) +# define NOMINMAX +# endif +# if !defined (STRICT) +# define STRICT +# endif +# if defined (_STLP_USE_MFC) +# include +# else +# include +# endif +# if (_STLP_OUTERMOST_HEADER_ID == 0x100) +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# else +/* This section serves as a replacement for windows.h header. */ +# if defined (__cplusplus) +extern "C" { +# endif +# if (defined (_M_AMD64) || defined (_M_IA64) || (!defined (_STLP_WCE) && defined (_M_MRX000)) || defined (_M_ALPHA) || \ + (defined (_M_PPC) && (_STLP_MSVC_LIB >= 1000))) && !defined (RC_INVOKED) +# define InterlockedIncrement _InterlockedIncrement +# define InterlockedDecrement _InterlockedDecrement +# define InterlockedExchange _InterlockedExchange +# define _STLP_STDCALL +# else +# if defined (_MAC) +# define _STLP_STDCALL _cdecl +# else +# define _STLP_STDCALL __stdcall +# endif +# endif + +# if defined (_STLP_NEW_PLATFORM_SDK) +_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedIncrement(long volatile *); +_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedDecrement(long volatile *); +_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchange(long volatile *, long); +# if defined (_WIN64) +_STLP_IMPORT_DECLSPEC void* _STLP_STDCALL _InterlockedExchangePointer(void* volatile *, void*); +# endif +# elif !defined (_STLP_WCE) +/* boris : for the latest SDK, you may actually need the other version of the declaration (above) + * even for earlier VC++ versions. There is no way to tell SDK versions apart, sorry ... + */ +_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedIncrement(long*); +_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedDecrement(long*); +_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchange(long*, long); +# else +/* start of eMbedded Visual C++ specific section */ +# include + +/* Don't let windef.h define its min and max macros. */ +# if !defined (NOMINMAX) +# define NOMINMAX +# endif +# include /* needed for basic windows types */ + + /** in SDKs generated with PB5, windef.h somehow includes headers which then + define setjmp. */ +# if (_WIN32_WCE >= 0x500) +# define _STLP_NATIVE_SETJMP_H_INCLUDED +# endif + +# ifndef _WINBASE_ /* winbase.h already included? */ +long WINAPI InterlockedIncrement(long*); +long WINAPI InterlockedDecrement(long*); +long WINAPI InterlockedExchange(long*, long); +# endif + +# ifndef __WINDOWS__ /* windows.h already included? */ + +# if defined (x86) +# include /* needed for inline versions of Interlocked* functions */ +# endif + +# ifndef _MFC_VER + +# define MessageBox MessageBoxW +int WINAPI MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); + +# define wvsprintf wvsprintfW +int WINAPI wvsprintfW(LPWSTR, LPCWSTR, va_list ArgList); + +void WINAPI ExitThread(DWORD dwExitCode); + +# if !defined (COREDLL) +# define _STLP_WCE_WINBASEAPI DECLSPEC_IMPORT +# else +# define _STLP_WCE_WINBASEAPI +# endif + +_STLP_WCE_WINBASEAPI int WINAPI +MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, + int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar); + +_STLP_WCE_WINBASEAPI UINT WINAPI GetACP(); + +_STLP_WCE_WINBASEAPI BOOL WINAPI TerminateProcess(HANDLE hProcess, DWORD uExitCode); + +# define OutputDebugString OutputDebugStringW +void WINAPI OutputDebugStringW(LPCWSTR); + +_STLP_WCE_WINBASEAPI void WINAPI Sleep(DWORD); + +# undef _STLP_WCE_WINBASEAPI + +# endif /* !_MFC_VER */ + +# endif /* !__WINDOWS__ */ + +/* end of eMbedded Visual C++ specific section */ +# endif + +# if !defined (_STLP_WCE) +_STLP_IMPORT_DECLSPEC void _STLP_STDCALL Sleep(unsigned long); +_STLP_IMPORT_DECLSPEC void _STLP_STDCALL OutputDebugStringA(const char* lpOutputString); +# endif + +# if defined (InterlockedIncrement) +# pragma intrinsic(_InterlockedIncrement) +# pragma intrinsic(_InterlockedDecrement) +# pragma intrinsic(_InterlockedExchange) +# if defined (_WIN64) +# pragma intrinsic(_InterlockedExchangePointer) +# endif +# endif +# if defined (__cplusplus) +} /* extern "C" */ +# endif + +# endif + +/* Here we use a macro different than the InterlockedExchangePointer SDK one + * to avoid macro definition conflict. */ +# if !defined (_WIN64) +/* Under 32 bits platform we rely on a simple InterlockedExchange call. */ +# if defined (__cplusplus) +/* We do not define this function if we are not in a C++ translation unit just + * because of the 'inline' keyword portability issue it would introduce. We will + * have to fix it the day we need this function for a C translation unit. + */ +inline +void* _STLP_CALL STLPInterlockedExchangePointer(void* volatile* __a, void* __b) { +# if defined (_STLP_MSVC) +/* Here MSVC produces warning if 64 bits portability issue is activated. + * MSVC do not see that _STLP_ATOMIC_EXCHANGE_PTR is a macro which content + * is based on the platform, Win32 or Win64 + */ +# pragma warning (push) +# pragma warning (disable : 4311) // pointer truncation from void* to long +# pragma warning (disable : 4312) // conversion from long to void* of greater size +# endif +# if !defined (_STLP_NO_NEW_STYLE_CASTS) + return reinterpret_cast(InterlockedExchange(reinterpret_cast(const_cast(__a)), + reinterpret_cast(__b))); +# else + return (void*)InterlockedExchange((long*)__a, (long)__b); +# endif +# if defined (_STLP_MSVC) +# pragma warning (pop) +# endif +} +# endif +# else +# define STLPInterlockedExchangePointer _InterlockedExchangePointer +# endif + +#endif /* _STLP_WINDOWS_H_INCLUDED */ +#endif /* _STLP_SGX_CONFIG */ + +/* _STLP_WIN95_LIKE signal the Windows 95 OS or assimilated Windows OS version that + * has Interlockeded[Increment, Decrement] Win32 API functions not returning modified + * value. + */ +#if (defined (WINVER) && (WINVER < 0x0410) && (!defined (_WIN32_WINNT) || (_WIN32_WINNT < 0x400))) || \ + (!defined (WINVER) && (defined (_WIN32_WINDOWS) && (_WIN32_WINDOWS < 0x0410) || \ + (defined (_WIN32_WINNT) && (_WIN32_WINNT < 0x400)))) +# define _STLP_WIN95_LIKE +#endif + +/* Between Windows 95 (0x400) and later Windows OSes an API enhancement forces us + * to change _Refcount_Base internal struct. As _Refcount_base member methods might + * be partially inlined we need to check that STLport build/use are coherent. To do + * so we try to generate a link time error thanks to the following macro. + * This additional check is limited to old compilers that might still be used with + * Windows 95. */ +#if (defined (_DEBUG) || defined (_STLP_DEBUG)) && \ + (defined (_STLP_MSVC) && (_STLP_MSVC < 1310) || \ + defined (__GNUC__) && (__GNUC__ < 3)) +/* We invert symbol names based on macro detection, when building for Windows + * 95 we expose a + * building_for_windows95_or_previous_but_library_built_for_windows98_or_later + * function in order to have a more obvious link error message signaling how + * the lib has been built and how it is used. */ +# if defined (__BUILDING_STLPORT) +# if defined (_STLP_WIN95_LIKE) +# define _STLP_SIGNAL_RUNTIME_COMPATIBILITY building_for_windows95_but_library_built_for_at_least_windows98 +# else +# define _STLP_SIGNAL_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95 +# endif +# else +# if defined (_STLP_WIN95_LIKE) +# define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_windows95_but_library_built_for_at_least_windows98 +# else +# define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95 +# endif +# endif +#endif + +#if defined (__WIN16) || defined (WIN16) || defined (_WIN16) +# define _STLP_WIN16 +#else +# define _STLP_WIN32 +#endif + +#if defined(_STLP_WIN32) +# define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */ +#endif + +#if defined(__MINGW32__) && !defined(_STLP_USE_STDIO_IO) +# define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */ +#endif /* __MINGW32__ */ + +#ifdef _STLP_WIN16 +# define _STLP_USE_UNIX_EMULATION_IO /* _open/_read/_write */ +# define _STLP_LDOUBLE_80 +#endif + +#endif /* _STLP_INTERNAL_WINDOWS_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/compat.h b/sdk/tlibstdcxx/stlport/stl/config/compat.h new file mode 100644 index 0000000000..434f314e7a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/compat.h @@ -0,0 +1,80 @@ + +/* + * Compatibility section + * This section sets new-style macros based on old-style ones, for compatibility + */ + +#if defined (__STL_DEBUG) && !defined (_STLP_DEBUG) +# define _STLP_DEBUG __STL_DEBUG +#endif +#if defined (__STL_NO_ANACHRONISMS) && !defined (_STLP_NO_ANACHRONISMS) +# define _STLP_NO_ANACHRONISMS __STL_NO_ANACHRONISMS +#endif +#if defined (__STL_NO_EXTENSIONS) && !defined (_STLP_NO_EXTENSIONS) +# define _STLP_NO_EXTENSIONS __STL_NO_EXTENSIONS +#endif +#if defined (__STL_NO_EXCEPTIONS) && !defined (_STLP_NO_EXCEPTIONS) +# define _STLP_NO_EXCEPTIONS __STL_NO_EXCEPTIONS +#endif +#if defined (__STL_NO_NAMESPACES) && !defined (_STLP_NO_NAMESPACES) +# define _STLP_NO_NAMESPACES __STL_NO_NAMESPACES +#endif +#if defined (__STL_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) +# define _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS __STL_MINIMUM_DEFAULT_TEMPLATE_PARAMS +#endif +#if defined (__STL_NO_OWN_NAMESPACE) && !defined (_STLP_NO_OWN_NAMESPACE) +# define _STLP_NO_OWN_NAMESPACE __STL_NO_OWN_NAMESPACE +#endif + +#if defined (__STL_NO_RELOPS_NAMESPACE) && !defined (_STLP_NO_RELOPS_NAMESPACE) +# define _STLP_NO_RELOPS_NAMESPACE __STL_NO_RELOPS_NAMESPACE +#endif + +#if defined (__STL_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_UNINITIALIZED) +# define _STLP_DEBUG_UNINITIALIZED __STL_DEBUG_UNINITIALIZED +#endif +#if defined (__STL_SHRED_BYTE) && !defined (_STLP_SHRED_BYTE) +# define _STLP_SHRED_BYTE __STL_SHRED_BYTE +#endif +#if defined (__STL_USE_MFC) && !defined (_STLP_USE_MFC) +# define _STLP_USE_MFC __STL_USE_MFC +#endif + +#if defined (__STL_USE_NEWALLOC) && !defined (_STLP_USE_NEWALLOC) +# define _STLP_USE_NEWALLOC __STL_USE_NEWALLOC +#endif +#if defined (__STL_USE_MALLOC) && !defined (_STLP_USE_MALLOC) +# define _STLP_USE_MALLOC __STL_USE_MALLOC +#endif + +#if defined (__STL_DEBUG_ALLOC) && !defined (_STLP_DEBUG_ALLOC) +# define _STLP_DEBUG_ALLOC __STL_DEBUG_ALLOC +#endif + +#if defined (__STL_DEBUG_MESSAGE) && !defined (_STLP_DEBUG_MESSAGE) +# define _STLP_DEBUG_MESSAGE __STL_DEBUG_MESSAGE +#endif + +#if defined (__STL_DEBUG_TERMINATE) && !defined (_STLP_DEBUG_TERMINATE) +# define _STLP_DEBUG_TERMINATE __STL_DEBUG_TERMINATE +#endif + +#if defined (__STL_USE_ABBREVS) && !defined (_STLP_USE_ABBREVS) +# define _STLP_USE_ABBREVS __STL_USE_ABBREVS +#endif + +#if defined (__STL_NO_MSVC50_COMPATIBILITY) && !defined (_STLP_NO_MSVC50_COMPATIBILITY) +# define _STLP_NO_MSVC50_COMPATIBILITY __STL_NO_MSVC50_COMPATIBILITY +#endif + +/* STLport do not support anymore the iostream wrapper mode so this macro should + * always been define for other libraries that was using it: + */ +#if !defined (_STLP_OWN_IOSTREAMS) +# define _STLP_OWN_IOSTREAMS +#endif + +#if defined (_STLP_NO_OWN_IOSTREAMS) +# error STLport do not support anymore the wrapper mode. If you want to use STLport \ +use its iostreams implementation or no iostreams at all. +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/features.h b/sdk/tlibstdcxx/stlport/stl/config/features.h new file mode 100644 index 0000000000..d86e2e6ef4 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/features.h @@ -0,0 +1,1084 @@ + /* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_FEATURES_H +#define _STLP_FEATURES_H + +/* + * Purpose of this file: + * + * Defines all STLport settings. + * This file is actually a wrapper : it includes compiler-specific + * settings from + * and user-defined settings from . + * See and for the description + * of those macros + * + */ + +/* Definition of the STLport version informations */ +#include + +/* Other macros defined by this file: + + * bool, true, and false, if _STLP_NO_BOOL is defined. + * typename, as a null macro if it's not already a keyword. + * explicit, as a null macro if it's not already a keyword. + * namespace-related macros (_STLP_STD, _STLP_BEGIN_NAMESPACE, etc.) + * exception-related macros (_STLP_TRY, _STLP_UNWIND, etc.) + * _STLP_ASSERT, either as a test or as a null macro, depending on + whether or not _STLP_ASSERTIONS is defined. +*/ + +/* Definition of the 2 STLport debug levels */ +#define _STLP_STLPORT_DBG_LEVEL 1 +#define _STLP_STANDARD_DBG_LEVEL 2 + +/* Common settings for SGX */ +#include + +/* Placeholder for user to override settings. + * It could be also used to mask settings from + * different directories. + */ +#include + +#if defined (_STLP_DEBUG) && !defined (_STLP_DEBUG_LEVEL) +# define _STLP_DEBUG_LEVEL _STLP_STLPORT_DBG_LEVEL +#endif + +#if defined (__BUILDING_STLPORT) +/* For the STLport implementation we can use everything: + */ +# if defined (_STLP_NO_ANACHRONISMS) +# undef _STLP_NO_ANACHRONISMS +# endif +# if defined (_STLP_NO_EXTENSIONS) +# undef _STLP_NO_EXTENSIONS +# endif +/* Moreover there are things that have no sens: + */ +# if !defined (_STLP_SGX_CONFIG) +# if defined (_STLP_NO_IOSTREAMS) +# error If you do not use iostreams you do not need to build the STLport library. +# endif +# endif +#endif + +/* ========================================================= */ +/* This file is used for compatibility; it accepts old-style config + switches */ +#include + +/* Common configuration file for this particular installation. */ +#include + +/* Operational Environment specific */ +#include + +/* ========================================================= */ + +/* some fixes to configuration. This also includes modifications + * of STLport switches depending on compiler flags, + * or settings applicable to a group of compilers, such as + * to all who use EDG front-end. + */ +#include + +#if !defined (_STLP_NO_MEMBER_TEMPLATES) && !defined (_STLP_MEMBER_TEMPLATES) +# define _STLP_MEMBER_TEMPLATES 1 +#endif + +#if !defined (_STLP_NO_MEMBER_TEMPLATE_CLASSES) && !defined (_STLP_MEMBER_TEMPLATE_CLASSES) +# define _STLP_MEMBER_TEMPLATE_CLASSES 1 +#endif + +#if defined (_STLP_NO_MEMBER_TEMPLATE_CLASSES) && !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) +# define _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE 1 +#endif + +#if !defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# define _STLP_CLASS_PARTIAL_SPECIALIZATION 1 +#endif + +#if !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER) +# define _STLP_FUNCTION_TMPL_PARTIAL_ORDER 1 +#endif + +#if !defined (_STLP_DONT_USE_SHORT_STRING_OPTIM) && !defined (_STLP_USE_SHORT_STRING_OPTIM) +# define _STLP_USE_SHORT_STRING_OPTIM 1 +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXTENSIONS) && \ + !defined (_STLP_NO_CONTAINERS_EXTENSION) && !defined (_STLP_USE_CONTAINERS_EXTENSION) +# define _STLP_USE_CONTAINERS_EXTENSION +#endif + +#if defined (_STLP_USE_CONTAINERS_EXTENSION) +# define _STLP_TEMPLATE_FOR_CONT_EXT template +#else +# define _STLP_TEMPLATE_FOR_CONT_EXT +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) && \ + (defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)) +# error Sorry but according the STLport settings your compiler can not support the pointer specialization feature. +#endif + +#if defined (_STLP_WHOLE_NATIVE_STD) && defined (_STLP_NO_OWN_NAMESPACE) +# error Sorry but asking for both STLport to be in the real std namespace and also having STLport import all native std stuff \ + is invalid, chose one or none. +#endif + +#if defined (_STLP_VERBOSE) && !defined (_STLP_VERBOSE_MODE_SUPPORTED) +# error Sorry but the verbose mode is not implemented for your compiler. +#endif + +#if defined (_STLP_NO_IOSTREAMS) && \ + !defined (_STLP_USE_NEWALLOC) && !defined (_STLP_USE_MALLOC) +# define _STLP_USE_NEWALLOC +#endif + +#if !defined (_STLP_BIG_ENDIAN) && !defined (_STLP_LITTLE_ENDIAN) +# if defined (_MIPSEB) || defined (__sparc) || defined (_AIX) || \ + defined (__hpux) || defined (macintosh) || defined (_MAC) +# define _STLP_BIG_ENDIAN 1 +# elif defined (__i386) || defined (_M_IX86) || defined (_M_ARM) || \ + defined (__amd64__) || defined (_M_AMD64) || defined (__x86_64__) || \ + defined (__alpha__) +# define _STLP_LITTLE_ENDIAN 1 +# elif defined (__ia64__) + /* itanium allows both settings (for instance via gcc -mbig-endian) - hence a seperate check is required */ +# if defined (__BIG_ENDIAN__) +# define _STLP_BIG_ENDIAN 1 +# else +# define _STLP_LITTLE_ENDIAN 1 +# endif +# else +# error "can't determine endianess" +# endif +#endif /* _STLP_BIG_ENDIAN */ + +/* ========================================================== + * final workaround tuning based on given flags + * ========================================================== */ + +#ifndef _STLP_UINT32_T +# define _STLP_UINT32_T unsigned long +#endif +#ifndef _STLP_ABORT +# define _STLP_ABORT() abort() +#endif + +#if !defined (_STLP_HAS_NO_NAMESPACES) +# if defined _STLP_NO_NAMESPACES +# undef _STLP_USE_NAMESPACES +# else +/* assume it as the default, turn it off later if NO_NAMESPACES selected */ +# undef _STLP_USE_NAMESPACES +# define _STLP_USE_NAMESPACES 1 +# endif +#endif + +#if defined (_STLP_NO_IOSTREAMS) +# define _STLP_USE_NO_IOSTREAMS +#endif + +/* Operating system recognition (basic) */ +#if (defined(__unix) || defined(__linux__) || defined(__QNX__) || defined(_AIX) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__Lynx__) || defined(__hpux) || defined(__sgi)) && \ + !defined (_STLP_UNIX) +# define _STLP_UNIX 1 +#endif /* __unix */ + +#if !defined (_STLP_NO_LONG_DOUBLE) +# define _STLP_LONGEST_FLOAT_TYPE long double +#else +# define _STLP_LONGEST_FLOAT_TYPE double +#endif + +/* Native headers access macros */ +#if !defined (_STLP_HAS_INCLUDE_NEXT) +# include +#endif + +/* shared library tune-up */ + +#if defined (__BUILDING_STLPORT) +/* if we are rebuilding right now, place everything here */ +# undef _STLP_DESIGNATED_DLL +# define _STLP_DESIGNATED_DLL 1 +#endif + +/* Use own namespace always if possible and not explicitly instructed otherwise */ +#if defined (_STLP_USE_NAMESPACES) && !defined (_STLP_BROKEN_USING_DIRECTIVE) && \ + !defined (_STLP_NO_OWN_NAMESPACE) +# undef _STLP_USE_OWN_NAMESPACE +# define _STLP_USE_OWN_NAMESPACE 1 +#else +# undef _STLP_WHOLE_NATIVE_STD +#endif + +#if !defined (_NOTHREADS) && !defined (_STLP_THREADS_DEFINED) + +# if defined (_PTHREADS) +# define _STLP_PTHREADS +# define _STLP_THREADS +# endif +# if defined (_UITHREADS) +# define _STLP_UITHREADS +# define _STLP_THREADS +# endif + +# if defined (_STLP_WIN32) && !defined (_STLP_PTHREADS) +# define _STLP_WIN32THREADS 1 +# elif ((defined (__sun) && !defined (__linux__)) || defined (_UITHREADS) ) && \ + !defined(_STLP_PTHREADS) +# define _STLP_UITHREADS +# else +# define _STLP_PTHREADS +# endif /* __sgi */ +# define _STLP_THREADS_DEFINED +#endif + +#if (defined (_REENTRANT) || defined (_THREAD_SAFE)) && !defined (_STLP_THREADS) +# define _STLP_THREADS +#endif + +#ifndef _STLP_STATIC_MUTEX +# define _STLP_STATIC_MUTEX _STLP_mutex_base +#endif + +#if (defined (_MFC_VER) || defined (_AFXDLL)) && !defined (_STLP_USE_MFC) +# define _STLP_USE_MFC 1 +#endif + +#if defined (_STLP_THREADS) +# define _STLP_VOLATILE volatile +#else +# define _STLP_VOLATILE +#endif + +#if !defined (_STLP_USE_NEW_C_HEADERS) && !defined (_STLP_HAS_NO_NEW_C_HEADERS) +# define _STLP_USE_NEW_C_HEADERS +#endif +/* disable new-style headers if requested */ +#if defined (_STLP_NO_NEW_C_HEADERS) +# undef _STLP_USE_NEW_C_HEADERS +#endif + +#if defined (_STLP_BASE_TYPEDEF_BUG) +# undef _STLP_BASE_TYPEDEF_OUTSIDE_BUG +# define _STLP_BASE_TYPEDEF_OUTSIDE_BUG 1 +#endif + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define _STLP_GLOBAL_NESTED_RETURN_TYPE_PARAM_BUG +#endif + +/* SUNpro 4.2 inline string literal bug */ +#ifdef _STLP_INLINE_STRING_LITERAL_BUG +# define _STLP_FIX_LITERAL_BUG(__x) __x = __x; +#else +# define _STLP_FIX_LITERAL_BUG(__x) +#endif + +#if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) +# undef _STLP_NO_DEFAULT_NON_TYPE_PARAM +# define _STLP_NO_DEFAULT_NON_TYPE_PARAM 1 +#endif + +#if !defined (_STLP_STATIC_ASSERT) +/* Some compiler support 0 size array so we use negative size array to generate + * a compilation time error. + */ +# define _STLP_STATIC_ASSERT(expr) typedef char __static_assert[expr ? 1 : -1]; +#endif + +/* apple mpw exception handling bug */ +#ifndef _STLP_MPWFIX_TRY +# define _STLP_MPWFIX_TRY +#endif +#ifndef _STLP_MPWFIX_CATCH +# define _STLP_MPWFIX_CATCH +#endif +#ifndef _STLP_MPWFIX_CATCH_ACTION +# define _STLP_MPWFIX_CATCH_ACTION(action) +#endif + +#if !defined (_STLP_WEAK) +# define _STLP_WEAK +#endif + +/* default parameters as template types derived from arguments ( not always supported ) */ +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +# define _STLP_DFL_TMPL_PARAM( classname, defval ) class classname +#else +# if !defined (_STLP_DEFAULT_TYPE_PARAM) +# define _STLP_DEFAULT_TYPE_PARAM 1 +# endif +# define _STLP_DFL_TMPL_PARAM( classname, defval ) class classname = defval +#endif + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +# define _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_Key, _Tp ) class _Alloc +#else +# define _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_Key, _Tp ) \ + class _Alloc = allocator< pair < _Key, _Tp > > +#endif + +/* default parameters as complete types */ +#if defined (_STLP_DEFAULT_TYPE_PARAM) +# define _STLP_DFL_TYPE_PARAM( classname, defval ) class classname = defval +# define _STLP_DFL_NON_TYPE_PARAM(type,name,val) type name = val +#else +# define _STLP_DFL_TYPE_PARAM( classname, defval ) class classname +# define _STLP_DFL_NON_TYPE_PARAM(type,name,val) type name +#endif + +/* SGI compatibility */ + +#ifdef _STLP_NO_WCHAR_T +# ifndef _STLP_NO_NATIVE_WIDE_STREAMS +# define _STLP_NO_NATIVE_WIDE_STREAMS 1 +# endif +#else +# define _STLP_HAS_WCHAR_T 1 +#endif + +#if !defined (_STLP_NO_AT_MEMBER_FUNCTION) +# define _STLP_CAN_THROW_RANGE_ERRORS 1 +#endif + +/* debug mode tool */ +#if defined (_STLP_DEBUG) +# define _STLP_NON_DBG_NAME(X) _NonDbg_##X +#endif + +/* pointer specialization tool */ +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define _STLP_PTR_IMPL_NAME(X) _Impl_##X +#endif + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ + defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +# define _STLP_NO_MEM_T_NAME(X) _NoMemT_##X +#endif + +/* this always mean the C library is in global namespace */ +#if defined (_STLP_HAS_NO_NEW_C_HEADERS) && !defined (_STLP_VENDOR_GLOBAL_CSTD) +# define _STLP_VENDOR_GLOBAL_CSTD 1 +#endif + +/* Depending of whether compiler supports namespaces, + * tune the parameters for vendor-supplied libraries. + * This section is guarded by _STLP_HAS_NO_NAMESPACES, not by _STLP_USE_NAMESPACES, + * since it depends only on the native features, not on user's preference whether + * to use namespace for STLport or not. + */ +#if !defined (_STLP_HAS_NO_NAMESPACES) +/* Import some vendor's headers into corresponding STLport ones if they might be needed + * (if we wrap native iostreams and use namepace other than std::) */ +# if defined (_STLP_WHOLE_NATIVE_STD) +# define _STLP_IMPORT_VENDOR_STD 1 +# endif + +/* if using stlport:: namespace or if C library stuff is not in vendor's std::, + * try importing 'em. + * MSVC has ambiguity problem when we try to import C-style std:: stuff back into global namespace */ +# if defined (_STLP_USE_NAMESPACES) && (defined(_STLP_USE_OWN_NAMESPACE) || defined (_STLP_VENDOR_GLOBAL_CSTD)) +# define _STLP_IMPORT_VENDOR_CSTD 1 +# endif + +# if defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS) && !defined (_STLP_DO_IMPORT_CSTD_FUNCTIONS) +# define _STLP_NO_CSTD_FUNCTION_IMPORTS +# endif + +# define _STLP_USING_NAMESPACE(x) using namespace x ; + +namespace std { } +namespace __std_alias = std; + +/* assume std:: namespace for C++ std library if not being told otherwise */ +# if defined (_STLP_VENDOR_GLOBAL_STD) +# define _STLP_VENDOR_STD +# else +# define _STLP_VENDOR_STD std +# endif + +/* tune things that come from C library */ +# if defined (_STLP_VENDOR_GLOBAL_CSTD) || !defined(_STLP_USE_NEW_C_HEADERS) +/* in old-style headers, C functions go to global scope. */ +# define _STLP_VENDOR_CSTD +# define _STLP_USING_VENDOR_CSTD +# else +# define _STLP_VENDOR_CSTD _STLP_VENDOR_STD +# define _STLP_USING_VENDOR_CSTD _STLP_USING_NAMESPACE(_STLP_VENDOR_CSTD) +# endif /* _STLP_VENDOR_CSTD */ +/* exception, typeinfo, new - always come from the vendor */ +# if !defined (_STLP_VENDOR_EXCEPT_STD) +# if defined (_STLP_VENDOR_GLOBAL_EXCEPT_STD) +# define _STLP_VENDOR_EXCEPT_STD +# else +# define _STLP_VENDOR_EXCEPT_STD _STLP_VENDOR_STD +# endif +# endif +# define _STLP_OLD_IO_NAMESPACE +# if !defined (_STLP_VENDOR_MB_NAMESPACE) +# define _STLP_VENDOR_MB_NAMESPACE _STLP_VENDOR_CSTD +# endif +#else +/* compiler has no namespace support */ +# define _STLP_VENDOR_STD +# define _STLP_VENDOR_CSTD +# define _STLP_USING_NAMESPACE(x) +# define _STLP_USING_VENDOR_CSTD +# define _STLP_VENDOR_EXCEPT_STD +#endif + +#if defined (_STLP_USE_NAMESPACES) + +# if defined (_STLP_USE_OWN_NAMESPACE) +# if !defined (_STLP_STD_NAME) +# if !defined (_STLP_DEBUG) +# if !defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpmtx_std +# else +# define _STLP_STD_NAME stlp_std +# endif +# else +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpxmtx_std +# else +# define _STLP_STD_NAME stlpx_std +# endif +# endif +# else +/* + * The STLport debug mode is binary incompatible with the other modes, + * lets make it clear on the STLport namespace to generate link errors rather + * than runtime ones. + */ +# if !defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpdmtx_std +# else +# define _STLP_STD_NAME stlpd_std +# endif +# else +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpdxmtx_std +# else +# define _STLP_STD_NAME stlpdx_std +# endif +# endif +# endif +# endif +namespace _STLP_STD_NAME { } +# else +# define _STLP_STD_NAME std +# endif /* _STLP_USE_OWN_NAMESPACE */ + +# define _STLP_BEGIN_NAMESPACE namespace _STLP_STD_NAME { +# define _STLP_BEGIN_TR1_NAMESPACE namespace tr1 { +# define _STLP_END_NAMESPACE } + +/* decide whether or not we use separate namespace for rel ops */ +# if defined (_STLP_NO_RELOPS_NAMESPACE) +# define _STLP_BEGIN_RELOPS_NAMESPACE _STLP_BEGIN_NAMESPACE namespace rel_ops {} +# define _STLP_END_RELOPS_NAMESPACE } +# else +/* Use std::rel_ops namespace */ +# define _STLP_BEGIN_RELOPS_NAMESPACE _STLP_BEGIN_NAMESPACE namespace rel_ops { +# define _STLP_END_RELOPS_NAMESPACE } } +# define _STLP_USE_SEPARATE_RELOPS_NAMESPACE +# endif /* Use std::rel_ops namespace */ + +# define _STLP_STD ::_STLP_STD_NAME +# if !defined (_STLP_TR1) +# define _STLP_TR1 _STLP_STD::tr1:: +# endif + +# if !defined (_STLP_DONT_USE_PRIV_NAMESPACE) +# define _STLP_PRIV_NAME priv +# define _STLP_PRIV _STLP_STD::_STLP_PRIV_NAME:: +# define _STLP_MOVE_TO_PRIV_NAMESPACE namespace _STLP_PRIV_NAME { +# define _STLP_MOVE_TO_STD_NAMESPACE } +# else +# if !defined (_STLP_PRIV) +# define _STLP_PRIV _STLP_STD:: +# endif +# define _STLP_MOVE_TO_PRIV_NAMESPACE +# define _STLP_MOVE_TO_STD_NAMESPACE +# endif + +/* Official STLport namespace when std is not redefined. + * Here we don't use a macro because we do not need it and because + * stlport is used as file name by boost and folder name under beos: + */ +namespace stlport = _STLP_STD_NAME; + +/* Backward compatibility: + */ +namespace _STL = _STLP_STD_NAME; +#undef __STLPORT_NAMESPACE +#define __STLPORT_NAMESPACE _STLP_STD_NAME + +#else /* _STLP_USE_NAMESPACES */ +/* STLport is being put into global namespace */ +# define _STLP_STD +# define _STLP_PRIV +# define _STLP_TR1 +# define _STLP_BEGIN_NAMESPACE +# define _STLP_BEGIN_TR1_NAMESPACE +# define _STLP_END_NAMESPACE +# define _STLP_MOVE_TO_PRIV_NAMESPACE +# define _STLP_MOVE_TO_STD_NAMESPACE + +/* boris : it was found out that _STLP_USE_SEPARATE_RELOPS_NAMESPACE + causes less problems than having relational operator templates in global namespace + Please define _STLP_NO_RELOPS_NAMESPACE in config/user_config.h if your code rely on them. */ +# if !defined (_STLP_NO_RELOPS_NAMESPACE) +# define _STLP_USE_SEPARATE_RELOPS_NAMESPACE +# endif +# define _STLP_BEGIN_RELOPS_NAMESPACE +# define _STLP_END_RELOPS_NAMESPACE +# undef _STLP_USE_OWN_NAMESPACE +#endif /* _STLP_USE_NAMESPACES */ + +#define STLPORT_CSTD _STLP_VENDOR_CSTD +#define STLPORT _STLP_STD_NAME + +#if defined(_STLP_BOGUS_TEMPLATE_TYPE_MATCHING_BUG) +# define _STLP_SIMPLE_TYPE(T) _stl_trivial_proxy +#else +# define _STLP_SIMPLE_TYPE(T) T +#endif + +#ifndef _STLP_RAND48 +# define _STLP_NO_DRAND48 +#endif + +/* advanced keywords usage */ +#define __C_CAST(__x, __y) ((__x)(__y)) +#ifndef _STLP_NO_NEW_STYLE_CASTS +# define __CONST_CAST(__x,__y) const_cast<__x>(__y) +# define __STATIC_CAST(__x,__y) static_cast<__x>(__y) +# define __REINTERPRET_CAST(__x,__y) reinterpret_cast<__x>(__y) +#else +# define __STATIC_CAST(__x,__y) __C_CAST(__x, __y) +# define __CONST_CAST(__x,__y) __C_CAST(__x, __y) +# define __REINTERPRET_CAST(__x,__y) __C_CAST(__x, __y) +#endif + +#if defined (_STLP_NEED_TYPENAME) && ! defined (typename) +# define typename +#endif + +#if defined (_STLP_NEED_TYPENAME) || defined (_STLP_NO_TYPENAME_ON_RETURN_TYPE ) +# define _STLP_TYPENAME_ON_RETURN_TYPE +#else +# define _STLP_TYPENAME_ON_RETURN_TYPE typename +#endif + +#ifdef _STLP_NO_TYPENAME_IN_TEMPLATE_HEADER +# define _STLP_HEADER_TYPENAME +#else +# define _STLP_HEADER_TYPENAME typename +#endif + +#ifdef _STLP_NO_TYPENAME_BEFORE_NAMESPACE +# define _STLP_TYPENAME +#else +# define _STLP_TYPENAME typename +#endif + +#ifndef _STLP_NO_MEMBER_TEMPLATE_KEYWORD +# define _STLP_TEMPLATE template +#else +# define _STLP_TEMPLATE +#endif + +#if defined (_STLP_USE_CONTAINERS_EXTENSION) +# define _STLP_KEY_TYPE_FOR_CONT_EXT(type) +# define _STLP_TEMPLATE_FOR_CONT_EXT template +#else +# define _STLP_KEY_TYPE_FOR_CONT_EXT(type) typedef type _KT; +# define _STLP_TEMPLATE_FOR_CONT_EXT +#endif + +#if defined (_STLP_NEED_EXPLICIT) && !defined (explicit) +# define explicit +#endif + +#if !defined (_STLP_NEED_MUTABLE) +# define _STLP_MUTABLE(type, x) x +#else +# define _STLP_MUTABLE(type, x) __CONST_CAST(type*, this)->x +# define mutable +#endif + +#if defined (_STLP_NO_SIGNED_BUILTINS) +/* old HP-UX doesn't understand "signed" keyword */ +# define signed +#endif + +#if defined (_STLP_LOOP_INLINE_PROBLEMS) +# define _STLP_INLINE_LOOP +#else +# define _STLP_INLINE_LOOP inline +#endif + +#ifndef _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX +# define _STLP_TEMPLATE_NULL template<> +#else +# define _STLP_TEMPLATE_NULL +#endif + +#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER +# define _STLP_OPERATOR_TEMPLATE +#else +# define _STLP_OPERATOR_TEMPLATE _STLP_TEMPLATE_NULL +#endif + +#ifndef _STLP_CLASS_PARTIAL_SPECIALIZATION +/* unless we have other compiler problem, try simulating partial spec here */ +# if !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +# define _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS +# endif +/* For your own iterators, please use inheritance from iterator<> instead of these obsolete queries. */ +# if (defined (_STLP_NESTED_TYPE_PARAM_BUG) || !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)) +# if ! defined ( _STLP_USE_OLD_HP_ITERATOR_QUERIES ) +# define _STLP_USE_OLD_HP_ITERATOR_QUERIES +# endif +# elif defined ( _STLP_NO_ANACHRONISMS ) +# undef _STLP_USE_OLD_HP_ITERATOR_QUERIES +# endif +#endif + +#ifndef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS +# define _STLP_NULL_TMPL_ARGS <> +# else +# define _STLP_NULL_TMPL_ARGS +#endif + +#if !defined (_STLP_ALLOCATOR_TYPE_DFL) +# if defined (_STLP_DONT_SUP_DFLT_PARAM) +# define _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS +# endif +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) +# define _STLP_ALLOCATOR_TYPE_DFL +# else +# define _STLP_ALLOCATOR_TYPE_DFL = allocator_type() +# endif +#endif + +/* When the compiler do not correctly initialized the basic types value in default parameters we prefer + * to avoid them to be able to correct this bug. + */ +#if defined (_STLP_DEF_CONST_DEF_PARAM_BUG) +# define _STLP_DONT_SUP_DFLT_PARAM 1 +#endif + +#if defined (__SGI_STL_NO_ARROW_OPERATOR) && ! defined (_STLP_NO_ARROW_OPERATOR) +# define _STLP_NO_ARROW_OPERATOR +#endif + +#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !(defined (_STLP_NO_ARROW_OPERATOR)) && \ + !defined (_STLP_NO_MSVC50_COMPATIBILITY) && !defined (_STLP_MSVC50_COMPATIBILITY) +/* this one is needed for proper reverse_iterator<> operator ->() handling */ +# define _STLP_MSVC50_COMPATIBILITY 1 +# endif +#endif + +#if defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) +# if (defined(__IBMCPP__) && (500 <= __IBMCPP__) && (__IBMCPP__ < 600) ) +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef typename _STLP_STD :: reverse_iterator const_reverse_iterator; \ + typedef typename _STLP_STD :: reverse_iterator reverse_iterator +# elif (defined (__sgi) && ! defined (__GNUC__)) || defined (__SUNPRO_CC) || defined (__xlC__) +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD:: _STLP_TEMPLATE reverse_iterator const_reverse_iterator; \ + typedef _STLP_STD:: _STLP_TEMPLATE reverse_iterator reverse_iterator +# else +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD::reverse_iterator const_reverse_iterator; \ + typedef _STLP_STD::reverse_iterator reverse_iterator +# endif +#else /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ +# if defined (_STLP_MSVC50_COMPATIBILITY) +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD::__reverse_iterator const_reverse_iterator; \ + typedef _STLP_STD::__reverse_iterator \ + reverse_iterator +# else +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD::__reverse_iterator const_reverse_iterator; \ + typedef _STLP_STD::__reverse_iterator \ + reverse_iterator +# endif +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#define _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS \ + _STLP_DECLARE_REVERSE_ITERATORS(reverse_bidirectional_iterator) +#define _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS \ + _STLP_DECLARE_REVERSE_ITERATORS(reverse_iterator) + +#define __IMPORT_CONTAINER_TYPEDEFS(_Super) \ + typedef typename _Super::value_type value_type; \ + typedef typename _Super::size_type size_type; \ + typedef typename _Super::difference_type difference_type; \ + typedef typename _Super::reference reference; \ + typedef typename _Super::const_reference const_reference; \ + typedef typename _Super::pointer pointer; \ + typedef typename _Super::const_pointer const_pointer; \ + typedef typename _Super::allocator_type allocator_type; + + +#define __IMPORT_ITERATORS(_Super) \ + typedef typename _Super::iterator iterator; \ + typedef typename _Super::const_iterator const_iterator; + +#define __IMPORT_REVERSE_ITERATORS(_Super) \ + typedef typename _Super::const_reverse_iterator const_reverse_iterator; \ + typedef typename _Super::reverse_iterator reverse_iterator; + +#define __IMPORT_SUPER_COPY_ASSIGNMENT(__derived_name, _Self, _SUPER) \ + __derived_name(const _Super& __x) : _SUPER(__x) {} \ + _Self& operator=(const _Super& __x) { \ + *(_Super*)this = __x; \ + return *this; \ + } \ + __derived_name(const _Self& __x) : _SUPER(__x) {} \ + _Self& operator=(const _Self& __x) { \ + *(_Super*)this = __x; \ + return *this; \ + } + +#define __IMPORT_WITH_ITERATORS(_Super) \ + __IMPORT_CONTAINER_TYPEDEFS(_Super) __IMPORT_ITERATORS(_Super) + +#define __IMPORT_WITH_REVERSE_ITERATORS(_Super) \ + __IMPORT_WITH_ITERATORS(_Super) __IMPORT_REVERSE_ITERATORS(_Super) + +#if defined (_STLP_TRIVIAL_CONSTRUCTOR_BUG) +# define __TRIVIAL_CONSTRUCTOR(__type) __type() {} +#else +# define __TRIVIAL_CONSTRUCTOR(__type) +#endif + +#if defined (_STLP_TRIVIAL_DESTRUCTOR_BUG) +# define __TRIVIAL_DESTRUCTOR(__type) ~__type() {} +#else +# define __TRIVIAL_DESTRUCTOR(__type) +#endif + +#define __TRIVIAL_STUFF(__type) \ + __TRIVIAL_CONSTRUCTOR(__type) __TRIVIAL_DESTRUCTOR(__type) + +#if defined (_STLP_STATIC_CONST_INIT_BUG) +# define _STLP_STATIC_CONSTANT(__type, __assignment) enum { __assignment } +#else +# define _STLP_STATIC_CONSTANT(__type, __assignment) static const __type __assignment +#endif + +#if defined (_STLP_HAS_NO_EXCEPTIONS) +# define _STLP_NO_EXCEPTIONS +#endif + +#if !defined (_STLP_DONT_USE_EXCEPTIONS) && !defined (_STLP_NO_EXCEPTIONS) && !defined (_STLP_USE_EXCEPTIONS) +# define _STLP_USE_EXCEPTIONS +#endif + +#if defined (_STLP_USE_EXCEPTIONS) +# define _STLP_TRY try +# define _STLP_CATCH_ALL catch(...) +# ifndef _STLP_THROW +# define _STLP_THROW(x) throw x +# endif +# define _STLP_RETHROW throw + +# define _STLP_UNWIND(action) catch(...) { action; throw; } + +# ifdef _STLP_THROW_RETURN_BUG +# define _STLP_RET_AFTER_THROW(data) return data; +# else +# define _STLP_RET_AFTER_THROW(data) +# endif + +# if !defined (_STLP_THROWS) +# define _STLP_THROWS(x) throw(x) +# endif +# if !defined (_STLP_NOTHROW) +# define _STLP_NOTHROW throw() +# endif +#else +# define _STLP_TRY +# define _STLP_CATCH_ALL if (false) +# ifndef _STLP_THROW +# define _STLP_THROW(x) +# endif +# define _STLP_RETHROW {} +# define _STLP_UNWIND(action) +# define _STLP_THROWS(x) +# define _STLP_NOTHROW +# define _STLP_RET_AFTER_THROW(data) +#endif + +/* + * Here we check _STLP_NO_EXCEPTIONS which means that the compiler has no + * exception support but not the _STLP_USE_EXCEPTIONS which simply means + * that the user do not want to use them. + */ +#if !defined (_STLP_NO_EXCEPTIONS) && !defined (_STLP_NO_EXCEPTION_SPEC) +# define _STLP_THROWS_INHERENTLY(x) throw x +# define _STLP_NOTHROW_INHERENTLY throw() +#else +# define _STLP_THROWS_INHERENTLY(x) +# define _STLP_NOTHROW_INHERENTLY +#endif + +/* STLport function not returning are functions that throw so we translate + * the noreturn functions in throwing functions taking also into account + * exception support activation. + */ +#if defined (_STLP_NORETURN_FUNCTION) && !defined (_STLP_NO_EXCEPTIONS) && \ + !defined (_STLP_FUNCTION_THROWS) +# define _STLP_FUNCTION_THROWS _STLP_NORETURN_FUNCTION +#else +# define _STLP_FUNCTION_THROWS +#endif + +#if defined(_STLP_NO_BOOL) +# if (defined (__IBMCPP__) && (__IBMCPP__ < 400)) && ! defined (_AIX) +# include +# if defined (__OS400__) +typedef int bool; +# elif !( defined (__xlC__) || defined (_AIX)) +typedef Boolean bool; +# endif +# else +# if defined(_STLP_YVALS_H) +# include +# else +# if defined (_STLP_DONT_USE_BOOL_TYPEDEF) +# define bool int +# else +typedef int bool; +# endif +# define true 1 +# define false 0 +# endif +# endif /* __IBMCPP__ */ +#else +# define _STLP_BOOL_KEYWORD 1 +#endif /* _STLP_NO_BOOL */ + +/* uninitialized value filler */ +#ifndef _STLP_SHRED_BYTE +/* This value is designed to cause problems if an error occurs */ +# define _STLP_SHRED_BYTE 0xA3 +#endif /* _STLP_SHRED_BYTE */ + +/* shared library tune-up */ +#ifndef _STLP_IMPORT_DECLSPEC +# define _STLP_IMPORT_DECLSPEC +#endif + +/* a keyword used to instantiate export template */ +#ifndef _STLP_EXPORT_TEMPLATE_KEYWORD +# define _STLP_EXPORT_TEMPLATE_KEYWORD +#endif +#ifndef _STLP_IMPORT_TEMPLATE_KEYWORD +# define _STLP_IMPORT_TEMPLATE_KEYWORD +#endif + +#if !defined (_STLP_NO_CONST_IN_PAIR) +# define _STLP_CONST const +#else +# define _STLP_CONST +#endif + +#ifdef _STLP_USE_NO_IOSTREAMS +/* + * If we do not use iostreams we do not use the export/import + * techniques to avoid build of the STLport library. + */ +# undef _STLP_USE_DECLSPEC +/* We also undef USE_DYNAMIC_LIB macro as this macro add some code + * to use the dynamic (shared) STLport library for some platform/compiler + * configuration leading to problem when not linking to the STLport lib. + */ +# undef _STLP_USE_DYNAMIC_LIB +#endif + +#if defined (_STLP_DLLEXPORT_NEEDS_PREDECLARATION) && defined (_STLP_USE_DECLSPEC) +# if ! defined (_STLP_USE_TEMPLATE_EXPORT) +/* this setting turns on "extern template" extension use */ +# define _STLP_USE_TEMPLATE_EXPORT +# endif +# if defined (_STLP_DESIGNATED_DLL) && ! defined (_STLP_NO_FORCE_INSTANTIATE) +# define _STLP_NO_FORCE_INSTANTIATE +# endif +#endif + +#if defined (_STLP_DESIGNATED_DLL) /* This is a lib which will contain STLport exports */ +# define _STLP_EXPORT _STLP_EXPORT_TEMPLATE_KEYWORD +#else +# define _STLP_EXPORT _STLP_IMPORT_TEMPLATE_KEYWORD +#endif + +#ifndef _STLP_EXPORT_TEMPLATE +# define _STLP_EXPORT_TEMPLATE _STLP_EXPORT template +#endif + +#if defined (_STLP_USE_DECLSPEC) /* using export/import technique */ + +# ifndef _STLP_EXPORT_DECLSPEC +# define _STLP_EXPORT_DECLSPEC +# endif +# ifndef _STLP_IMPORT_DECLSPEC +# define _STLP_IMPORT_DECLSPEC +# endif +# ifndef _STLP_CLASS_EXPORT_DECLSPEC +# define _STLP_CLASS_EXPORT_DECLSPEC +# endif +# ifndef _STLP_CLASS_IMPORT_DECLSPEC +# define _STLP_CLASS_IMPORT_DECLSPEC +# endif +# if defined (_STLP_DESIGNATED_DLL) /* This is a lib which will contain STLport exports */ +# define _STLP_DECLSPEC _STLP_EXPORT_DECLSPEC +# define _STLP_CLASS_DECLSPEC _STLP_CLASS_EXPORT_DECLSPEC +# else +# define _STLP_DECLSPEC _STLP_IMPORT_DECLSPEC /* Other modules, importing STLport exports */ +# define _STLP_CLASS_DECLSPEC _STLP_CLASS_IMPORT_DECLSPEC +# endif + +#else /* Not using DLL export/import specifications */ + +# define _STLP_DECLSPEC +# define _STLP_CLASS_DECLSPEC + +#endif + +#define _STLP_EXPORT_TEMPLATE_CLASS _STLP_EXPORT template class _STLP_CLASS_DECLSPEC + +#if defined (_STLP_NEED_ADDITIONAL_STATIC_DECLSPEC) +# define _STLP_STATIC_DECLSPEC _STLP_DECLSPEC +#else +# define _STLP_STATIC_DECLSPEC +#endif + +#if !defined (_STLP_CALL) +# define _STLP_CALL +#endif + +#ifndef _STLP_USE_NO_IOSTREAMS + +# if defined (__DECCXX) && ! defined (__USE_STD_IOSTREAM) +# define __USE_STD_IOSTREAM +# endif + +/* We only need to expose details of streams implementation + if we use non-standard i/o or are building STLport*/ +# if defined (__BUILDING_STLPORT) || defined (_STLP_NO_FORCE_INSTANTIATE) || !defined(_STLP_NO_CUSTOM_IO) +# define _STLP_EXPOSE_STREAM_IMPLEMENTATION 1 +# endif + +/* We only need to expose details of global implementation if we are building STLport + or have not instantiated everything in the lib */ +# if defined (__BUILDING_STLPORT) || defined (_STLP_NO_FORCE_INSTANTIATE) +# undef _STLP_EXPOSE_GLOBALS_IMPLEMENTATION +# define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION 1 +# endif + +#else /* _STLP_USE_NO_IOSTREAMS */ +/* when we are not using SGI iostreams, we must expose globals, but not streams implementation */ +# define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION +#endif /* _STLP_USE_NO_IOSTREAMS */ + +#ifdef _STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS +# define _STLP_PSPEC2(t1,t2) < t1,t2 > +# define _STLP_PSPEC3(t1,t2,t3) < t1,t2,t3 > +#else +# define _STLP_PSPEC2(t1,t2) /* nothing */ +# define _STLP_PSPEC3(t1,t2,t3) /* nothing */ +#endif + +/* Activation of the partial template workaround: + */ +#if !defined(_STLP_DONT_USE_PARTIAL_SPEC_WRKD) &&\ + (!defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) || !defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER)) +# define _STLP_USE_PARTIAL_SPEC_WORKAROUND +#endif + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE +# define _STLP_RELOPS_OPERATORS(_TMPL, _TP) \ +_TMPL inline bool _STLP_CALL operator!=(const _TP& __x, const _TP& __y) {return !(__x == __y);}\ +_TMPL inline bool _STLP_CALL operator>(const _TP& __x, const _TP& __y) {return __y < __x;}\ +_TMPL inline bool _STLP_CALL operator<=(const _TP& __x, const _TP& __y) { return !(__y < __x);}\ +_TMPL inline bool _STLP_CALL operator>=(const _TP& __x, const _TP& __y) { return !(__x < __y);} +#else +# define _STLP_RELOPS_OPERATORS(_TMPL, _TP) +#endif + +#if defined ( _STLP_USE_ABBREVS ) +# include +#endif + +/* Some really useful macro */ +#define _STLP_ARRAY_SIZE(A) sizeof(A) / sizeof(A[0]) +#define _STLP_ARRAY_AND_SIZE(A) A, sizeof(A) / sizeof(A[0]) + +#if !defined (_STLP_MARK_PARAMETER_AS_UNUSED) +# define _STLP_MARK_PARAMETER_AS_UNUSED(X) (void*)X; +#endif + +#if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +# if defined (_STLP_USE_NO_IOSTREAMS) +# undef _STLP_CHECK_RUNTIME_COMPATIBILITY +# else +/* The extern "C" simply makes the symbol simpler. */ +#if defined (__cplusplus) +extern "C" +#endif +void _STLP_DECLSPEC _STLP_CALL _STLP_CHECK_RUNTIME_COMPATIBILITY(); +# endif +#endif + +/* some cleanup */ +#undef _STLP_DONT_USE_BOOL_TYPEDEF +#undef _STLP_YVALS_H +#undef _STLP_LOOP_INLINE_PROBLEMS +#undef _STLP_NEED_EXPLICIT +#undef _STLP_NEED_TYPENAME +#undef _STLP_NO_NEW_STYLE_CASTS +#undef __AUTO_CONFIGURED + +#endif /* _STLP_FEATURES_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/config/host.h b/sdk/tlibstdcxx/stlport/stl/config/host.h new file mode 100644 index 0000000000..b0be0f6f14 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/host.h @@ -0,0 +1,342 @@ +/* + * This file defines site configuration. + */ + +/* + * _STLP_NO_THREADS: if defined, STLport don't use any + * multithreading support. Synonym is _NOTHREADS + */ + +#define _NOTHREADS +#define _STLP_NO_THREADS + + +/* _PTHREADS: if defined, use POSIX threads for multithreading support. */ +/* +#define _PTHREADS +*/ + +/* compatibility section + */ + +#if (defined (_STLP_NOTHREADS) || defined (_STLP_NO_THREADS) || defined (NOTHREADS)) +# if !defined (_NOTHREADS) +# define _NOTHREADS +# endif +# if !defined (_STLP_NO_THREADS) +# define _STLP_NO_THREADS +# endif +#endif + +#if !defined(_STLP_USE_DYNAMIC_LIB) && !defined(_STLP_USE_STATIC_LIB) +/* + * Turn _STLP_USE_DYNAMIC_LIB to enforce use of .dll version of STLport library. + * NOTE: please do that only if you know what you are doing! + * Changing default will require you to change makefiles in "build" accordingly + * and to rebuild STLPort library! + * On UNIX, this has no effect, see build/lib/README for make tags. + * See STLport configuration file (build/lib/configure.bat) for help in building + * the require library versions. + */ +/* +#define _STLP_USE_DYNAMIC_LIB +*/ + +/* + * Turn _STLP_USE_STATIC_LIB to enforce use of static version of STLport library. + * NOTE: please do that only if you know what you are doing! + * Changing default will require you to change makefile in "build" accordingly + * and to rebuild STLPort library! + * On UNIX, this has no effect, see build/lib/README for make tags. + * See STLport configuration file (build/lib/configure.bat) for help in building + * the require library versions. + */ +/* +#define _STLP_USE_STATIC_LIB +*/ +#endif + +/* + * Edit relative path below (or put full path) to get native + * compiler vendor's headers included. Default is "../include" + * for _STLP_NATIVE_INCLUDE_PATH, default for other macros is + * _STLP_NATIVE_INCLUDE_PATH. + * Hint: never install STLport in the directory that ends with "include" + */ +/* +#undef _STLP_NATIVE_INCLUDE_PATH +#define _STLP_NATIVE_INCLUDE_PATH ../include +*/ +/* same for C library headers like */ +/* +#undef _STLP_NATIVE_CPP_C_INCLUDE_PATH +#define _STLP_NATIVE_CPP_C_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +*/ +/* same for C headers like */ +/* +#undef _STLP_NATIVE_C_INCLUDE_PATH +#define _STLP_NATIVE_C_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +*/ +/* Some compilers locate basic C++ runtime support headers (, , ) in separate directory */ +/* +#undef _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH +#define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +*/ + +/* + * If namespases available, STLport use own namespace (and masquerade + * it as std). Disable own namespace may cause undefined behaviour. + */ +/* +#define _STLP_NO_OWN_NAMESPACE 1 +*/ + +/* + * Uncomment _STLP_LEAKS_PEDANTIC to force deallocation of ALL allocated + * memory chunks. Normally not required. But if you worry about quazi-leaks + * (may be reported by some leaks detection tools), use + * _STLP_LEAKS_PEDANTIC. It should be used with _STLP_USE_NEWALLOC or + * _STLP_USE_MALLOC (see below), the default node_alloc allocator also clean + * its internal memory pool but only if STLport is used as a dynamic library + * under Win32 (using MSVC like compilers). + */ +/* +#define _STLP_LEAKS_PEDANTIC 1 +*/ + +/* + * Uncomment _STLP_USE_NEWALLOC to force allocator to use plain "new" + * instead of STLport optimized node allocator engine. + */ + +#define _STLP_USE_NEWALLOC 1 + + +/* + * Uncomment _STLP_USE_MALLOC to force allocator to use plain "malloc" + * instead of STLport optimized node allocator engine. + * + * This is default allocator for glibc 2.3.x and later, if not mentioned other + */ +/* +#define _STLP_USE_MALLOC 1 +*/ + +/* + * Uncomment _STLP_USE_PERTHREAD_ALLOC to force allocator to use + * a specific implementation targetting the massively multi-threaded + * environment. The implementation is based on the POSIX pthread + * interface. + */ +/* +#define _STLP_USE_PERTHREAD_ALLOC 1 +*/ + +/* + * Uncomment _STLP_USE_NODE_ALLOC if you want to force allocator to use + * "node_alloc" allocator (this is default allocator for STLport, if not + * used other above, except glibc 2.3.x and later, where default is + * "malloc", due to better results) + */ +/* +#define _STLP_USE_NODE_ALLOC 1 +*/ + +/* + * Set _STLP_DEBUG_ALLOC to use allocators that perform memory debugging, + * such as padding/checking for memory consistency + */ +/* +#define _STLP_DEBUG_ALLOC 1 +*/ + +/* + * For compiler not supporting partial template specialization or ordering of + * template functions STLport implement a workaround based on inheritance + * detection. This inheritance can introduce trouble in client code when + * a user class derived a STL container (which is not advised as STL containers + * do not have virtual destructors). To disable this workaround turn this macro on: + */ +/* +#define _STLP_DONT_USE_PARTIAL_SPEC_WRKD 1 +*/ + +/* + * Uncomment this to force all debug diagnostic to be directed through a + * user-defined global function: + * void __stl_debug_message(const char * format_str, ...) + * instead of predefined STLport routine. + * This allows you to take control of debug message output. + * Default routine calls fprintf(stderr,...) + * Note : If you set this macro, you must supply __stl_debug_message + * function definition somewhere. + */ +/* +#define _STLP_DEBUG_MESSAGE 1 +*/ + +/* + * Uncomment this to force all failed assertions to be executed through + * user-defined global function: + * void __stl_debug_terminate(void). This allows + * you to take control of assertion behaviour for debugging purposes. + * Default routine calls _STLP_ABORT(). + * Note : If you set this macro, you must supply __stl_debug_terminate + * function definition somewhere. + */ +/* +#define _STLP_DEBUG_TERMINATE 1 +*/ + +/* + * Uncomment that to disable exception handling code + */ + +//#define _STLP_DONT_USE_EXCEPTIONS 1 + + +/* + * _STLP_NO_NAMESPACES: if defined, don't put the library in namespace + * stlport:: or std::, even if the compiler supports namespaces + */ +/* +#define _STLP_NO_NAMESPACES 1 +*/ + +/*========================================================== + * Compatibility section + *==========================================================*/ + +/* + * Use abbreviated class names for linker benefit (don't affect interface). + * This option is obsolete, but should work in this release. + * + */ +/* +#define _STLP_USE_ABBREVS +*/ + +/* + * This definition precludes STLport reverse_iterator to be compatible with + * other parts of MSVC library. (With partial specialization, it just + * has no effect). + * Use it _ONLY_ if you use SGI-style reverse_iterator<> template explicitly + */ +/* +#define _STLP_NO_MSVC50_COMPATIBILITY 1 +*/ + +/* + * Use obsolete overloaded template functions iterator_category(), value_type(), distance_type() + * for querying iterator properties. Please note those names are non-standard and are not guaranteed + * to be used by every implementation. However, this setting is on by default when partial specialization + * is not implemented in the compiler and cannot be simulated (only if _STLP_NO_ANACHRONISMS is not set). + * Use of those interfaces for user-defined iterators is strongly discouraged: + * please use public inheritance from iterator<> template to achieve desired effect. + * Second form is to disable old-style queries in any case. + */ +/* +#define _STLP_USE_OLD_HP_ITERATOR_QUERIES +#define _STLP_NO_OLD_HP_ITERATOR_QUERIES +*/ + + +/* + * On systems with support of large files (_LARGEFILE_SOURCE, + * _LARGEFILE64_SOURCE defined) we will use 64-bit file offset, even if + * __USE_FILE_OFFSET64 or _FILE_OFFSET_BITS not defined or _FILE_OFFSET_BITS + * less than 64. In the last case sizeof(std::streamoff) may not be equal to + * sizeof(off_t); if you want to force equal size of off_t and streamoff, + * uncomment macro below. But pay attention, this has influence on libstlport + * and in future usage it may cause conflict with defined _FILE_OFFSET_BITS macro. + */ + +/* +#define _STLP_USE_DEFAULT_FILE_OFFSET +*/ + +/* + * _STLP_USE_STDIO_IO, _STLP_USE_UNIX_IO: force selection of stdio calls + * (fopen/flose/fread/fwrite) under fstream buffers or unistd calls + * (open/close/read/write + mmap). On systems that have both (i.e. most Unixes) + * _STLP_USE_UNIX_IO is used. + * + * There is a third variant for Windows: _STLP_USE_WIN32_IO, that based + * on Windows calls (CreateFile/CloseHandle/ReadFile/WriteFile + CreateFileMapping, + * MapViewOfFile) + * + * Uncomment only one define here! + */ +/* +#define _STLP_USE_UNIX_IO +*/ +/* +#define _STLP_USE_STDIO_IO +*/ +/* +#define _STLP_USE_WIN32_IO + */ + +/*==========================================================================*/ + +/* This section contains swithes which should be off by default, + * but so few compilers would have it undefined, so that we set them here, + * with the option to be turned off later in compiler-specific file + */ + +//#define _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT +#define _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT + +/*==========================================================================*/ + +#if defined(__sun) && defined(__GNUC__) +/* __SunOS_5_x is not defined in headers, and there is no way to derive it from headers only; + * nevertheless this macro defined automagically by SunPro compilers family; + * + * gcc know nothing about it, but defining it with -D on compiler command line + * is a bad idea from one side, and this info still useful when we want to use + * (or don't use) some Solaris version-specific features from other side. + * Of course, the best way is to define it in spec file, but this is beyond our scope. + * + * Uncomment ONE of the following, depends on what Solaris version you use. + */ + +/* +#define __SunOS_5_5_1 + */ +/* +#define __SunOS_5_6 + */ +/* +#define __SunOS_5_7 + */ +/* +#define __SunOS_5_8 + */ +/* +#define __SunOS_5_9 + */ +/* +#define __SunOS_5_10 + */ +#endif + +#if defined(__sun) +/* With following patches Solaris 8 and 9 will have *l and *f (long double and float) + * variants of math functions: + * SunOS 5.8 patch 111721-04 (May/08/2003) + * + * SunOS 5.9 patch 111722-04 (May/08/2003) + * + * Solaris 10 has this functions from box. + */ +/* +#define _STLP_SOLARIS_MATH_PATCH + */ +#endif + +/* + Local Variables: + mode:C++ + End: +*/ diff --git a/sdk/tlibstdcxx/stlport/stl/config/stl_confix.h b/sdk/tlibstdcxx/stlport/stl/config/stl_confix.h new file mode 100644 index 0000000000..22e5df8e91 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/stl_confix.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * STLport configuration file + * It is internal STLport header - DO NOT include it directly + * Purpose of this file : to define STLport settings that depend on + * compiler flags or can be otherwise missed + * + */ + +#ifndef _STLP_CONFIX_H +#define _STLP_CONFIX_H + +/* If, by any chance, C compiler gets there, try to help it to pass smoothly */ +#if ! defined (__cplusplus) && ! defined (_STLP_HAS_NO_NAMESPACES) +# define _STLP_HAS_NO_NAMESPACES +#endif + +#if defined (__MINGW32__) +# define _STLP_NO_DRAND48 +#endif + +/* Modena C++ library */ +#if defined (__MWERKS__) && __MWERKS__ <= 0x2303 || (defined (__KCC) && __KCC_VERSION < 3400) +# include +# define _STLP_USE_MSIPL 1 +# if defined (__KCC) || (defined(__MSL_CPP__) && \ + ( (__MSL_CPP__ >= 0x5000 && defined( _MSL_NO_MESSAGE_FACET )) || \ + (__MSL_CPP__ < 0x5000 && defined( MSIPL_NL_TYPES )))) +# define _STLP_NO_NATIVE_MESSAGE_FACET 1 +# endif +#endif + +/* common switches for EDG front-end */ +/* __EDG_SWITCHES do not seem to be an official EDG macro. + * We keep it for historical reason. */ +#if defined (__EDG_SWITCHES) +# if !(defined(_TYPENAME) || defined (_TYPENAME_IS_KEYWORD)) +# undef _STLP_NEED_TYPENAME +# define _STLP_NEED_TYPENAME 1 +# endif +# ifndef _WCHAR_T_IS_KEYWORD +# undef _STLP_NO_WCHAR_T +# define _STLP_NO_WCHAR_T 1 +# endif +# ifndef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES +# undef _STLP_NO_CLASS_PARTIAL_SPECIALIZATION +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# endif +# ifndef _MEMBER_TEMPLATES +# undef _STLP_NO_MEMBER_TEMPLATES +# define _STLP_NO_MEMBER_TEMPLATES 1 +# undef _STLP_NO_MEMBER_TEMPLATE_CLASSES +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# endif +# ifndef _MEMBER_TEMPLATE_KEYWORD +# undef _STLP_NO_MEMBER_TEMPLATE_KEYWORD +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# endif +# if !defined (__EXCEPTIONS) && ! defined (_EXCEPTIONS) +# undef _STLP_HAS_NO_EXCEPTIONS +# define _STLP_HAS_NO_EXCEPTIONS +# endif +# undef __EDG_SWITCHES +#endif /* EDG */ + +/* __EDG_VERSION__ is an official EDG macro, compilers based + * on EDG have to define it. */ +#if defined (__EDG_VERSION__) +# if !defined (_STLP_SGX_CONFIG) && (__EDG_VERSION__ >= 244) && !defined (_STLP_HAS_INCLUDE_NEXT) +# define _STLP_HAS_INCLUDE_NEXT +# endif +# if (__EDG_VERSION__ <= 240) && !defined (_STLP_DONT_RETURN_VOID) +# define _STLP_DONT_RETURN_VOID +# endif +# if !defined (__EXCEPTIONS) && !defined (_STLP_HAS_NO_EXCEPTIONS) +# define _STLP_HAS_NO_EXCEPTIONS +# endif +# if !defined (__NO_LONG_LONG) && !defined (_STLP_LONG_LONG) +# define _STLP_LONG_LONG long long +# endif +#endif + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/stl_mycomp.h b/sdk/tlibstdcxx/stlport/stl/config/stl_mycomp.h new file mode 100644 index 0000000000..f92902fd2c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/stl_mycomp.h @@ -0,0 +1,282 @@ +/* + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * Purpose of this file : + * + * A list of COMPILER-SPECIFIC portion of STLport settings. + * This file is provided to help in manual configuration + * of STLport. This file is being included by stlcomp.h + * when STLport is unable to identify your compiler. + * Please remove the error diagnostic below before adjusting + * macros. + * + */ +#ifndef _STLP_MYCOMP_H +#define _STLP_MYCOMP_H + +#error "Your compiler version is not recognized by STLport. Please edit " + +//========================================================== + +// the values choosen here as defaults try to give +// maximum functionality on the most conservative settings + +// Mostly correct guess, change it for Alpha (and other environments +// that has 64-bit "long") +// # define _STLP_UINT32_T unsigned long + +// Disables wchar_t functionality +// # define _STLP_NO_WCHAR_T 1 + +// Define if wchar_t is not an intrinsic type, and is actually a typedef to unsigned short. +// # define _STLP_WCHAR_T_IS_USHORT 1 + +// Uncomment if long long is available +// # define _STLP_LONG_LONG long long + +// Uncomment if long double is not available +// # define _STLP_NO_LONG_DOUBLE 1 + +// Uncomment this if your compiler does not support "typename" keyword +// # define _STLP_NEED_TYPENAME 1 + +// Uncomment this if your compiler does not support "mutable" keyword +// # define _STLP_NEED_MUTABLE 1 + +// Uncomment this if your compiler does not support "explicit" keyword +// # define _STLP_NEED_EXPLICIT 1 + +// Uncomment if new-style-casts like const_cast<> are not available +// # define _STLP_NO_NEW_STYLE_CASTS 1 + +// Uncomment this if your compiler does not have "bool" type +// # define _STLP_NO_BOOL 1 + +// Uncomment this if your compiler does not have "bool" type, but has "bool" keyword reserved +// # define _STLP_DONT_USE_BOOL_TYPEDEF 1 + +// Uncomment this if your compiler does not have "bool" type, but defines "bool" in +// # define _STLP_YVALS_H 1 + +// Uncomment this if your compiler has limited or no default template arguments for classes +// # define _STLP_LIMITED_DEFAULT_TEMPLATES 1 + +// Uncomment this if your compiler support only complete (not dependent on other parameters) +// types as default parameters for class templates +// # define _STLP_DEFAULT_TYPE_PARAM 1 + +// Uncomment this if your compiler do not support default parameters in template class methods +// # define _STLP_DONT_SUP_DFLT_PARAM 1 + +// Uncomment this if your compiler has problem with not-type +// default template parameters +// # define _STLP_NO_DEFAULT_NON_TYPE_PARAM 1 + +// Define if compiler has +// trouble with functions getting non-type-parameterized classes as parameters +// # define _STLP_NON_TYPE_TMPL_PARAM_BUG 1 + +// Uncomment this if your compiler does not support namespaces +// # define _STLP_HAS_NO_NAMESPACES 1 + +// Uncomment if "using" keyword does not work with template types +// # define _STLP_BROKEN_USING_DIRECTIVE 1 + +// Uncomment this if your compiler does not support exceptions +// # define _STLP_HAS_NO_EXCEPTIONS 1 + +// Uncomment this when you are able to detect that the user do not +// want to use the exceptions feature. +// # define _STLP_DONT_USE_EXCEPTIONS 1 + +// Uncomment this if your compiler does not support exception specifications +// # define _STLP_NO_EXCEPTION_SPEC + +// Define this if your compiler requires return statement after throw() +// # define _STLP_THROW_RETURN_BUG 1 + +// Define this if your compiler do not support return of void +// # define _STLP_DONT_RETURN_VOID 1 + +// Header that comes with the compiler +// does not define bad_alloc exception +// # define _STLP_NO_BAD_ALLOC 1 + +// Define this if your compiler do not throw bad_alloc from the new operator +// # define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 + +// Define this if your compiler has no rtti support or if it has been disabled +// # define _STLP_NO_RTTI 1 + +// Define this if there is no native type_info definition +// # define _STLP_NO_TYPEINFO 1 + +// Uncomment if member template methods are not available +// # define _STLP_NO_MEMBER_TEMPLATES 1 + +// Uncomment if member template classes are not available +// # define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 + +// Uncomment if your compiler do not support the std::allocator rebind technique +// This is a special case of bad member template classes support, it is automatically +// defined if _STLP_NO_MEMBER_TEMPLATE_CLASSES is defined. +// # define _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE 1 + +// Uncomment if no "template" keyword should be used with member template classes +// # define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 + +// Compiler does not accept friend declaration qualified with namespace name. +// # define _STLP_NO_QUALIFIED_FRIENDS 1 + +// Uncomment if partial specialization is not available +// # define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 + +// Define if class being partially specialized require full name (template parameters) +// of itself for method declarations +// # define _STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS + +// Compiler has problem with qualified specializations (cont int, volatile int...) +// # define _STLP_QUALIFIED_SPECIALIZATION_BUG + +// Compiler has problems specializing members of partially +// specialized class +// # define _STLP_MEMBER_SPECIALIZATION_BUG + +// Uncomment if partial order of template functions is not available +// # define _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER 1 + +// Uncomment if specialization of methods is not allowed +// # define _STLP_NO_METHOD_SPECIALIZATION 1 + +// Uncomment if full specialization does not use partial spec. syntax : template <> struct .... +// # define _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX 1 + +// Uncomment if compiler does not support explicit template arguments for functions +// # define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS + +// Uncomment this if your compiler can't inline while(), for() +// # define _STLP_LOOP_INLINE_PROBLEMS 1 + +// Define if the compiler fails to match a template function argument of base +// # define _STLP_BASE_MATCH_BUG 1 + +// Define if the compiler fails to match a template function argument of base +// (non-template) +//# define _STLP_NONTEMPL_BASE_MATCH_BUG 1 + +// Define if the compiler rejects outline method definition +// explicitly taking nested types/typedefs +// # define _STLP_NESTED_TYPE_PARAM_BUG 1 + +// Compiler requires typename keyword on outline method definition +// explicitly taking nested types/typedefs +// #define _STLP_TYPENAME_ON_RETURN_TYPE + +// Define if the baseclass typedefs not visible from outside +// # define _STLP_BASE_TYPEDEF_OUTSIDE_BUG 1 + +// if your compiler have serious problems with typedefs, try this one +// # define _STLP_BASE_TYPEDEF_BUG 1 + +// Uncomment if getting errors compiling mem_fun* adaptors +// # define _STLP_MEMBER_POINTER_PARAM_BUG 1 + +// Uncomment if the compiler can't handle a constant-initializer in the +// declaration of a static const data member of integer type. +// (See section 9.4.2, paragraph 4, of the C++ standard.) +// # define _STLP_STATIC_CONST_INIT_BUG + +// Uncomment to indicate that the compiler do not like static constant +// definition. +// Meaningfull only if _STLP_STATIC_CONST_INIT_BUG is not defined. +// # define _STLP_NO_STATIC_CONST_DEFINITION + +// Define if default constructor for builtin integer type fails to initialize it to 0 +// In expression like new(&char) char(): +//# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +// In default function parameter like _M_method(_Tp __x = _Tp()) +//# define _STLP_DEF_CONST_DEF_PARAM_BUG 1 + +// Defined if constructor +// required to explicitly call member's default constructors for const objects +// # define _STLP_CONST_CONSTRUCTOR_BUG 1 + +// Defined if the compiler has trouble calling POD-types constructors/destructors +// # define _STLP_TRIVIAL_CONSTRUCTOR_BUG 1 +// # define _STLP_TRIVIAL_DESTRUCTOR_BUG 1 + +// Define if having problems specializing maps/sets with +// key type being const +// # define _STLP_MULTI_CONST_TEMPLATE_ARG_BUG + +// Uncomment this to disable -> operators on all iterators +// # define _STLP_NO_ARROW_OPERATOR 1 + +// Uncomment this to disble at() member functions for containers +// # define _STLP_NO_AT_MEMBER_FUNCTION 1 + +// Define this if compiler lacks header +// # define _STLP_NO_EXCEPTION_HEADER 1 + +// Uncomment this if your C library has lrand48() function +// # define _STLP_RAND48 1 + +// Uncomment if native new-style C library headers lile , etc are not available. +// # define _STLP_HAS_NO_NEW_C_HEADERS 1 + +// uncomment if new-style headers is available +// # define _STLP_HAS_NEW_NEW_HEADER 1 + +// uncomment this if and other STD headers put their stuff in ::namespace, +// not std:: +// # define _STLP_VENDOR_GLOBAL_STD + +// uncomment this if and the like put stuff in ::namespace, +// not std:: +// # define _STLP_VENDOR_GLOBAL_CSTD + +// uncomment this if your compiler consider as ambiguous a function imported within +// the stlport namespace and called without scope (:: or std::) +// # define _STLP_NO_USING_FOR_GLOBAL_FUNCTIONS 1 + +// uncomment this if your compiler define all the C math functions C++ additional +// overloads in ::namespace and not only in std::. +// # define _STLP_HAS_GLOBAL_C_MATH_FUNCTIONS 1 + +// Edit relative path below (or put full path) to get native +// compiler headers included. Default is "../include". +// C headers may reside in different directory, so separate macro is provided. +// Hint : never install STLport in the directory that ends with "include" +// # define _STLP_NATIVE_INCLUDE_PATH ../include +// # define _STLP_NATIVE_C_INCLUDE_PATH ../include +// # define _STLP_NATIVE_CPP_C_INCLUDE_PATH ../include + +// This macro constructs header path from directory and name. +// You may change it if your compiler does not understand "/". +// # define _STLP_MAKE_HEADER(path, header) + +// This macro constructs native include header path from include path and name. +// You may have do define it if experimenting problems with preprocessor +// # define _STLP_NATIVE_HEADER(header) _STLP_MAKE_HEADER(_STLP_NATIVE_INCLUDE_PATH,header) + +// Same for C headers +// #define _STLP_NATIVE_C_HEADER(header) + +//========================================================== +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/config/user_config.h b/sdk/tlibstdcxx/stlport/stl/config/user_config.h new file mode 100644 index 0000000000..01863b8565 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/config/user_config.h @@ -0,0 +1,326 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* + * Purpose of this file : + * + * To hold user-definable portion of STLport settings which may be overridden + * on per-project basis. + * Please note that if you use STLport iostreams (compiled library) then you have + * to use consistent settings when you compile STLport library and your project. + * Those settings are defined in host.h and have to be the same for a given + * STLport installation. + */ + + +/*========================================================== + * User-settable macros that control compilation: + * Features selection + *==========================================================*/ + +/* + * Use this switch for embedded systems where no iostreams are available + * at all. STLport own iostreams will also get disabled automatically then. + * You can either use STLport iostreams, or no iostreams. + * If you want iostreams, you have to compile library in ../build/lib + * and supply resulting library at link time. + */ +/* +#define _STLP_NO_IOSTREAMS 1 +*/ + +/* + * Set _STLP_DEBUG to turn the "Debug Mode" on. + * That gets you checked iterators/ranges in the manner + * of "Safe STL". Very useful for debugging. Thread-safe. + * Please do not forget to link proper STLport library flavor + * (e.g libstlportstlg.so or libstlportstlg.a) when you set this flag + * in STLport iostreams mode, namespace customization guaranty that you + * link to the right library. + */ +/* +#define _STLP_DEBUG 1 +*/ +/* + * You can also choose the debug level: + * STLport debug level: Default value + * Check only what the STLport implementation consider as invalid. + * It also change the iterator invalidation schema. + * Standard debug level: Check for all operations the standard consider as "undefined behavior" + * even if STlport implement it correctly. It also invalidates iterators + * more often. + */ +/* +#define _STLP_DEBUG_LEVEL _STLP_STLPORT_DBG_LEVEL +#define _STLP_DEBUG_LEVEL _STLP_STANDARD_DBG_LEVEL +*/ +/* When an inconsistency is detected by the 'safe STL' the program will abort. + * If you prefer an exception define the following macro. The thrown exception + * will be the Standard runtime_error exception. + */ +/* +#define _STLP_DEBUG_MODE_THROWS + */ + +/* + * _STLP_NO_CUSTOM_IO : define this if you do not instantiate basic_xxx iostream + * classes with custom types (which is most likely the case). Custom means types + * other than char, wchar_t, char_traits<> and allocator<> like + * basic_ostream > or + * basic_string, my_allocator > + * When this option is on, most non-inline template functions definitions for iostreams + * are not seen by the client which saves a lot of compile time for most compilers, + * also object and executable size for some. + * Default is off, just not to break compilation for those who do use those types. + * That also guarantees that you still use optimized standard i/o when you compile + * your program without optimization. Option does not affect STLport library build; you + * may use the same binary library with and without this option, on per-project basis. + */ +/* +#define _STLP_NO_CUSTOM_IO +*/ + +/* + * _STLP_NO_RELOPS_NAMESPACE: if defined, don't put the relational + * operator templates (>, <=, >=, !=) in namespace std::rel_ops, even + * if the compiler supports namespaces. + * Note : if the compiler do not support namespaces, those operators are not be provided by default, + * to simulate hiding them into rel_ops. This was proved to resolve many compiler bugs with ambiguity. + */ +/* +#define _STLP_NO_RELOPS_NAMESPACE 1 +*/ + +/* + * If STLport use its own namespace, see _STLP_NO_OWN_NAMESPACE in host.h, it will try + * by default to rename std:: for the user to stlport::. If you do not want this feature, + * please define the following switch and then use stlport:: + */ +/* +#define _STLP_DONT_REDEFINE_STD 1 +*/ + +/* + * _STLP_WHOLE_NATIVE_STD : only meaningful if STLport uses its own namespace. + * Normally, STLport only imports necessary components from native std:: namespace. + * You might want everything from std:: being available in std:: namespace when you + * include corresponding STLport header (like STLport provides std::map as well, etc.), + * if you are going to use both stlport:: and std:: components in your code. + * Otherwise this option is not recommended as it increases the size of your object files + * and slows down compilation. + * Beware, if you do not use STLport iostream (_STLP_NO_IOSTREAMS above), ask STLport to + * not rename std:: in stlport:: and try to have access to whole native Standard stuff then + * STLport will only throw exceptions from the std namespace and not from stlport. + * For instance a problem in stlport::vector::at will throw a std::out_of_range exception + * and not a stlport::out_of_range. + * Notice that STLport exceptions inherits from std::exception. + */ +/* +#define _STLP_WHOLE_NATIVE_STD +*/ + +/* + * Use this option to catch uninitialized members in your classes. + * When it is set, construct() and destroy() fill the class storage + * with _STLP_SHRED_BYTE (see below). + * Note : _STLP_DEBUG and _STLP_DEBUG_ALLOC don't set this option automatically. + */ +/* +#define _STLP_DEBUG_UNINITIALIZED 1 +#define _STLP_DEBUG_ALLOC 1 +*/ + +/* + * Uncomment and provide a definition for the byte with which raw memory + * will be filled if _STLP_DEBUG_ALLOC or _STLP_DEBUG_UNINITIALIZED is defined. + * Choose a value which is likely to cause a noticeable problem if dereferenced + * or otherwise abused. A good value may already be defined for your platform. + */ +/* +#define _STLP_SHRED_BYTE 0xA3 +*/ + +/* + * This option is for gcc users only and only affects systems where native linker + * does not let gcc to implement automatic instantiation of static template data members/ + * It is being put in this file as there is no way to check if we are using GNU ld automatically, + * so it becomes user's responsibility. + */ +/* +#define _STLP_GCC_USES_GNU_LD +*/ + +/*========================================================== + * Compatibility section + *==========================================================*/ + +/* + * Define this macro to disable anachronistic constructs (like the ones used in HP STL and + * not included in final standard, etc. + */ +/* +#define _STLP_NO_ANACHRONISMS 1 +*/ + +/* + * Define this macro to disable STLport extensions (for example, to make sure your code will + * compile with some other implementation ) + */ + +#define _STLP_NO_EXTENSIONS 1 + + +/* + * You should define this macro if compiling with MFC - STLport + * then include instead of to get synchronisation primitives + */ +/* +#define _STLP_USE_MFC 1 +*/ + +/* + * boris : this setting is here as we cannot detect precense of new Platform SDK automatically + * If you are using new PSDK with VC++ 6.0 or lower, + * please define this to get correct prototypes for InterlockedXXX functions + */ +/* +#define _STLP_NEW_PLATFORM_SDK 1 +*/ + +/* + * For the same reason as the one above we are not able to detect easily use + * of the compiler coming with the Platform SDK instead of the one coming with + * a Microsoft Visual Studio release. This change native C/C++ library location + * and implementation, please define this to get correct STLport configuration. + */ +/* +#define _STLP_USING_PLATFORM_SDK_COMPILER 1 +*/ + +/* + * Some compilers support the automatic linking feature. + * Uncomment the following if you prefer to specify the STLport library + * to link with yourself. + * For the moment, this feature is only supported and implemented within STLport + * by the Microsoft compilers. + */ +/* +#define _STLP_DONT_USE_AUTO_LINK 1 +*/ + +/* + * If you customize the STLport generated library names don't forget to give + * the motif you used during configuration here if you still want the auto link + * to work. (Do not remove double quotes in the macro value) + */ +/* +#define _STLP_LIB_NAME_MOTIF "???" + */ + +/* + * Uncomment to get feedback at compilation time about result of build environment + * introspection. + */ +/* +#define _STLP_VERBOSE 1 +*/ + +/* + * Use minimum set of default arguments on template classes that have more + * than one - for example map<>, set<>. + * This has effect only if _STLP_LIMITED_DEFAULT_TEMPLATES is on. + * If _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS is set, you'll be able to compile + * set with those compilers, but you'll have to use __set__> + * + * Affects : map<>, multimap<>, set<>, multiset<>, hash_*<>, + * queue<>, priority_queue<>, stack<>, istream_iterator<> + */ +/* +#define _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS 1 +*/ + +/* + * The agregation of strings using the + operator is an expensive operation + * as it requires construction of temporary objects that need memory allocation + * and deallocation. The problem can be even more important if you are adding + * several strings together in a single expression. To avoid this problem STLport + * implement expression template. With this technique addition of 2 strings is not + * a string anymore but a temporary object having a reference to each of the + * original strings involved in the expression. This object carry information + * directly to the destination string to set its size correctly and only make + * a single call to the allocator. This technique also works for the addition of + * N elements where elements are basic_string, C string or a single character. + * The drawback can be longer compilation time and bigger executable size. + * Another problem is that some compilers (gcc) fail to use string proxy object + * if do with class derived from string (see unit tests for details). + * STLport rebuild: Yes + */ +/* +#define _STLP_USE_TEMPLATE_EXPRESSION 1 +*/ + + +/* + * By default the STLport basic_string implementation use a little static buffer + * (of 16 chars when writing this doc) to avoid systematically memory allocation + * in case of little basic_string. The drawback of such a method is bigger + * basic_string size and some performance penalty for method like swap. If you + * prefer systematical dynamic allocation turn on this macro. + * STLport rebuild: Yes + */ +/* +#define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 +*/ + +/* + * To reduce the famous code bloat trouble due to the use of templates STLport grant + * a specialization of some containers for pointer types. So all instanciations + * of those containers with a pointer type will use the same implementation based on + * a container of void*. This feature has shown very good result on object files size + * but after link phase and optimization you will only experiment benefit if you use + * many container with pointer types. + * There are however a number of limitation to use this option: + * - with compilers not supporting partial template specialization feature, you won't + * be able to access some nested container types like iterator as long as the + * definition of the type used to instanciate the container will be incomplete + * (see IncompleteClass definition in test/unit/vector_test.cpp). + * - you won't be able to use complex Standard allocator implementations which are + * allocators having pointer nested type not being a real C pointer. + */ +/* +#define _STLP_USE_PTR_SPECIALIZATIONS 1 +*/ + +/* + * To achieve many different optimizations within the template implementations STLport + * uses some type traits technique. With this macro you can ask STLport to use the famous + * boost type traits rather than the internal one. The advantages are more compiler + * integration and a better support. If you only define this macro once the STLport has been + * built you just have to add the boost install path within your include path. If you want + * to use this feature at STLport built time you will have to define the + * STLP_BUILD_BOOST_PATH enrironment variable with the value of the boost library path. + */ + +/* +#define _STLP_USE_BOOST_SUPPORT 1 +*/ + + +/*==========================================================*/ + +/* + Local Variables: + mode: C++ + End: +*/ diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_debug.c b/sdk/tlibstdcxx/stlport/stl/debug/_debug.c new file mode 100644 index 0000000000..99d5c6b242 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_debug.c @@ -0,0 +1,628 @@ +/* + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_DEBUG_C +#define _STLP_DEBUG_C + +#if defined (_STLP_DEBUG) +#if defined (_STLP_THREADS) +# if !defined (_STLP_NEED_MUTABLE) +# define _STLP_ACQUIRE_LOCK(_Lock) _Lock._M_acquire_lock(); +# define _STLP_RELEASE_LOCK(_Lock) _Lock._M_release_lock(); +# else +# define _STLP_ACQUIRE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_acquire_lock(); +# define _STLP_RELEASE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_release_lock(); +# endif /* _STLP_NEED_MUTABLE */ +#else +# define _STLP_ACQUIRE_LOCK(_Lock) +# define _STLP_RELEASE_LOCK(_Lock) +#endif /* _STLP_THREADS */ + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +//========================================================== +// global non-inline functions +//========================================================== +// [ i1, i2) +#if !defined (__DMC__) +template +inline bool _STLP_CALL +stlp_in_range_aux(const _Iterator& __it, const _Iterator& __first, + const _Iterator& __last, const random_access_iterator_tag &) { + return ( __it >= __first && + __it < __last); +} +#endif + +template +#if defined (_STLP_MSVC) +inline bool _STLP_CALL stlp_in_range_aux(_Iterator1 __it, const _Iterator& __first, +#else +inline bool _STLP_CALL stlp_in_range_aux(const _Iterator1& __it, const _Iterator& __first, +#endif + const _Iterator& __last, const forward_iterator_tag &) { + _Iterator1 __i(__first); + for (; __i != __last && __i != __it; ++__i); + return (__i != __last); +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template +inline bool _STLP_CALL +stlp_in_range_aux(const _Iterator1& __it, const _Iterator& __first, + const _Iterator& __last, const bidirectional_iterator_tag &) { + _Iterator1 __i(__first); + for (; __i != __last && __i != __it; ++__i); + return (__i != __last); +} +#endif + +template +bool _STLP_CALL __check_range_aux(const _Iterator& __first, const _Iterator& __last, + const __false_type& /*_IsIntegral*/) { + _STLP_VERBOSE_RETURN(__valid_range(__first,__last), _StlMsg_INVALID_RANGE ) + return true; +} + +template +bool _STLP_CALL __check_range_aux(_Integral /*__first*/, _Integral /*__last*/, + const __true_type& /*_IsIntegral*/) +{ return true; } + +template +bool _STLP_CALL __check_range(const _Iterator& __first, const _Iterator& __last) { + typedef typename _IsIntegral<_Iterator>::_Ret _Integral; + return __check_range_aux(__first, __last, _Integral()); +} + +template +bool _STLP_CALL __check_range(const _Iterator& __it, + const _Iterator& __start, const _Iterator& __finish) { + _STLP_VERBOSE_RETURN(stlp_in_range(__it, __start, __finish), + _StlMsg_NOT_IN_RANGE_1) + return true; +} + +template +bool _STLP_CALL __check_range(const _Iterator& __first, const _Iterator& __last, + const _Iterator& __start, const _Iterator& __finish) { + _STLP_VERBOSE_RETURN(stlp_in_range(__first, __last, __start, __finish), + _StlMsg_NOT_IN_RANGE_2) + return true; +} + +template +bool _STLP_CALL __check_ptr_range(const _Tp* __first, const _Tp* __last) { + _STLP_VERBOSE_RETURN((__first != 0 || __last == 0), _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_RETURN(__valid_range(__first, __last, random_access_iterator_tag()), + _StlMsg_INVALID_RANGE) + return true; +} + +//=============================================================== +template +void _STLP_CALL __invalidate_range(const __owned_list* __base, + const _Iterator& __first, + const _Iterator& __last) { + typedef __owned_link _L_type; + _STLP_ACQUIRE_LOCK(__base->_M_lock) + _L_type* __prev = __CONST_CAST(_L_type*, &__base->_M_node); + _L_type* __pos = __prev->_M_next; + + while (__pos != 0) { + if (!(&__first == __STATIC_CAST(_Iterator*, __pos) || &__last == __STATIC_CAST(_Iterator*, __pos)) && + stlp_in_range_aux(__STATIC_CAST(_Iterator*, __pos)->_M_iterator, + __first._M_iterator, __last._M_iterator, + _STLP_ITERATOR_CATEGORY(__first, _Iterator))) { + __pos->_M_owner = 0; + __prev->_M_next = __pos->_M_next; + } + else { + __prev = __pos; + } + __pos = __prev->_M_next; + } + _STLP_RELEASE_LOCK(__base->_M_lock) +} + +template +void _STLP_CALL __invalidate_iterator(const __owned_list* __base, + const _Iterator& __it) { + typedef __owned_link _L_type; + _STLP_ACQUIRE_LOCK(__base->_M_lock) + _L_type* __prev = __CONST_CAST(_L_type*, &__base->_M_node); + _L_type* __pos = __prev->_M_next; + while (__pos != 0) { + // this requires safe iterators to be derived from __owned_link + if ((__pos != __STATIC_CAST(const _L_type*, &__it)) && + (__STATIC_CAST(_Iterator*, __pos)->_M_iterator == __it._M_iterator)) { + __pos->_M_owner = 0; + __prev->_M_next = __pos->_M_next; + } + else { + __prev = __pos; + } + __pos = __prev->_M_next; + } + _STLP_RELEASE_LOCK(__base->_M_lock) +} + +template +void _STLP_CALL __change_range_owner(const _Iterator& __first, + const _Iterator& __last, + const __owned_list* __dst) { + if (__first._Owner() == __dst) + return; + + typedef __owned_link _L_type; + // Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here + //_STLP_ACQUIRE_LOCK(__base->_M_lock) + __owned_list *__base = __CONST_CAST(__owned_list*, __first._Owner()); + _L_type* __src_prev = &__base->_M_node; + _L_type* __pos = __src_prev->_M_next; + _L_type* __dst_prev = __CONST_CAST(_L_type*, &__dst->_M_node); + + while (__pos != 0) { + if (!(&__first == __STATIC_CAST(_Iterator*, __pos) || &__last == __STATIC_CAST(_Iterator*, __pos)) && + stlp_in_range_aux(__STATIC_CAST(_Iterator*, __pos)->_M_iterator, + __first._M_iterator, __last._M_iterator, + _STLP_ITERATOR_CATEGORY(__first, _Iterator))) { + __pos->_M_owner = __CONST_CAST(__owned_list*, __dst); + //remove __pos from __base: + __src_prev->_M_next = __pos->_M_next; + //add __pos to __dst: + __pos->_M_next = __dst_prev->_M_next; + __dst_prev->_M_next = __pos; + } + else { + __src_prev = __pos; + } + __pos = __src_prev->_M_next; + } + +#if defined(_STLP_WCE) && defined(_ARM_) + // Note: This part is needed for compiling under Windows CE under ARM and correctly using + // _STLP_DEBUG mode. This comes from a bug in the ARM compiler where checked iterators that + // are passed by value are not copied over correctly. When __change_range_owner is called, + // e.g. in std::list::splice() the wrong _M_owner field gets modified and the __first + // iterator has the old _M_owner field, but was moved to the new __owned_list. Setting + // the first iterator's _M_owner field fixes this. Ugly but works. + __pos = __CONST_CAST(_Iterator*, &__first); + __pos->_M_owner = __CONST_CAST(__owned_list*, __dst); +#endif + //_STLP_RELEASE_LOCK(__base->_M_lock) +} + +template +void _STLP_CALL __change_ite_owner(const _Iterator& __it, + const __owned_list* __dst) { + if (__it._Owner() == __dst) + return; + + typedef __owned_link _L_type; + // Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here + //_STLP_ACQUIRE_LOCK(__base->_M_lock) + __owned_list *__base = __CONST_CAST(__owned_list*, __it._Owner()); + _L_type* __prev = &__base->_M_node; + _L_type* __pos = __prev->_M_next; + _L_type* __dst_prev = __CONST_CAST(_L_type*, &__dst->_M_node); + + while (__pos != 0) { + // this requires safe iterators to be derived from __owned_link + if ((__pos != __STATIC_CAST(const _L_type*, &__it)) && + (__STATIC_CAST(_Iterator*, __pos)->_M_iterator == __it._M_iterator)) { + __pos->_M_owner = __CONST_CAST(__owned_list*, __dst); + //remove __pos from __base: + __prev->_M_next = __pos->_M_next; + //add __pos to __dst: + __pos->_M_next = __dst_prev->_M_next; + __dst_prev->_M_next = __pos; + } + else { + __prev = __pos; + } + __pos = __prev->_M_next; + } + //_STLP_RELEASE_LOCK(__base->_M_lock) +} + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#endif /* _STLP_DEBUG */ + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) + +# ifndef _STLP_INTERNAL_CSTDLIB +# include +# endif + +//========================================================== +// .c section +// owned_list non-inline methods and global functions +//========================================================== + +# if defined (_STLP_ASSERTIONS) + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +# if !defined (_STLP_STRING_LITERAL) +# define _STLP_STRING_LITERAL(__x) __x +# endif + +# if defined (_STLP_USE_WIDE_INTERFACE) +// note: WinCE needs this to format single-byte strings in __stl_debug_engine::_Message +# define _STLP_PERCENT_S "%hs" +# else +# define _STLP_PERCENT_S "%s" +# endif /* _STLP_USE_WIDE_INTERFACE */ + +# define _STLP_MESSAGE_TABLE_BODY = { \ +_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error: " _STLP_PERCENT_S "\n"), \ +_STLP_STRING_LITERAL(_STLP_PERCENT_S "(%d): STL assertion failure : " _STLP_PERCENT_S "\n" _STLP_ASSERT_MSG_TRAILER), \ +_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error : " _STLP_PERCENT_S "\n" _STLP_PERCENT_S "(%d): STL assertion failure: " _STLP_PERCENT_S " \n" _STLP_ASSERT_MSG_TRAILER), \ +_STLP_STRING_LITERAL("Invalid argument to operation (see operation documentation)"), \ +_STLP_STRING_LITERAL("Taking an iterator out of destroyed (or otherwise corrupted) container"), \ +_STLP_STRING_LITERAL("Trying to extract an object out from empty container"),\ +_STLP_STRING_LITERAL("Past-the-end iterator could not be erased"), \ +_STLP_STRING_LITERAL("Index out of bounds"), \ +_STLP_STRING_LITERAL("Container doesn't own the iterator"), \ +_STLP_STRING_LITERAL("Container is owner of the iterator, but should not"), \ +_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) iterator used"), \ +_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) lefthand iterator in expression"), \ +_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) righthand iterator in expression"), \ +_STLP_STRING_LITERAL("Iterators used in expression are from different owners"), \ +_STLP_STRING_LITERAL("Iterator could not be dereferenced (past-the-end ?)"), \ +_STLP_STRING_LITERAL("Range [first,last) is invalid"), \ +_STLP_STRING_LITERAL("Iterator is not in range [first,last)"), \ +_STLP_STRING_LITERAL("Range [first,last) is not in range [start,finish)"), \ +_STLP_STRING_LITERAL("The advance would produce invalid iterator"), \ +_STLP_STRING_LITERAL("Iterator is singular (advanced beyond the bounds ?)"), \ +_STLP_STRING_LITERAL("Invalid strict weak ordering predicate, if pred(a, b) then we should have !pred(b, a)"), \ +_STLP_STRING_LITERAL("Invalid equivalent predicate, if pred(a, b) then we should have pred(b, a)"), \ +_STLP_STRING_LITERAL("Memory block deallocated twice"), \ +_STLP_STRING_LITERAL("Deallocating a block that was never allocated"), \ +_STLP_STRING_LITERAL("Deallocating a memory block allocated for another type"), \ +_STLP_STRING_LITERAL("Size of block passed to deallocate() doesn't match block size"), \ +_STLP_STRING_LITERAL("Pointer underrun - safety margin at front of memory block overwritten"), \ +_STLP_STRING_LITERAL("Pointer overrrun - safety margin at back of memory block overwritten"), \ +_STLP_STRING_LITERAL("Attempt to dereference null pointer returned by auto_ptr::get()"), \ +_STLP_STRING_LITERAL("Memory allocation function returned a wrongly align memory block"), \ +_STLP_STRING_LITERAL("Unknown problem") \ + } + +template +const char* __stl_debug_engine<_Dummy>::_Message_table[_StlMsg_MAX] _STLP_MESSAGE_TABLE_BODY; + +# undef _STLP_STRING_LITERAL +# undef _STLP_PERCENT_S + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +# if !defined (_STLP_DEBUG_MESSAGE) +# ifndef _STLP_INTERNAL_CSTDARG +# include +# endif +# ifndef _STLP_INTERNAL_CSTDIO +# include +# endif +# if defined (_STLP_DEBUG_MODE_THROWS) && !defined (_STLP_RANGE_ERRORS_H) +# include +# endif + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...) { + STLPORT_CSTD::va_list __args; + va_start( __args, __format_str ); + +# if !defined (_STLP_DEBUG_MODE_THROWS) +# if defined (_STLP_USE_WIDE_INTERFACE) + TCHAR __buffer[512]; + int _convert = strlen(__format_str) + 1; + LPWSTR _lpw = (LPWSTR)alloca(_convert * sizeof(wchar_t)); + _lpw[0] = '\0'; + MultiByteToWideChar(GetACP(), 0, __format_str, -1, _lpw, _convert); + wvsprintf(__buffer, _lpw, __args); + _STLP_WINCE_TRACE(__buffer); +# elif defined (_STLP_WIN32) && (defined(_STLP_MSVC) || defined (__ICL)) + char __buffer [4096]; + +# if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) + vsnprintf(__buffer, _STLP_ARRAY_SIZE(__buffer), __format_str, __args); +# else + vsnprintf_s(__buffer, _STLP_ARRAY_SIZE(__buffer), _TRUNCATE, __format_str, __args); +# endif + + OutputDebugStringA(__buffer); + +# elif defined (__amigaos__) + STLPORT_CSTD::vfprintf(stderr, __format_str, (char *)__args); +# else + STLPORT_CSTD::vfprintf(stderr, __format_str, __args); +# endif +# else + char __buffer[4096]; + +# if defined (_STLP_USE_SAFE_STRING_FUNCTIONS) + vsnprintf_s(__buffer, _STLP_ARRAY_SIZE(__buffer), _TRUNCATE, __format_str, __args); +# elif defined (_STLP_WIN32) && (defined(_STLP_MSVC) || defined (__ICL)) + vsnprintf(__buffer, _STLP_ARRAY_SIZE(__buffer), __format_str, __args); +# else + vsprintf(__buffer, __format_str, __args); +# endif +# endif + +# ifdef _STLP_DEBUG_MESSAGE_POST + _STLP_DEBUG_MESSAGE_POST +# endif + + va_end(__args); + +# if defined (_STLP_DEBUG_MODE_THROWS) + __stl_throw_runtime_error(__buffer); +# endif +} + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +# else +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...) +{} +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE +# endif /* _STLP_DEBUG_MESSAGE */ + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_IndexedError(int __error_ind, const char* __f, int __l) { + __stl_debug_message(_Message_table[_StlFormat_ERROR_RETURN], + __f, __l, _Message_table[__error_ind]); +} + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l) { + __stl_debug_message(_Message_table[_StlFormat_VERBOSE_ASSERTION_FAILURE], + __f, __l, _Message_table[__error_ind], __f, __l, __expr); + __stl_debug_terminate(); +} + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Assert(const char* __expr, const char* __f, int __l) { + __stl_debug_message(_Message_table[_StlFormat_ASSERTION_FAILURE],__f, __l, __expr); + __stl_debug_terminate(); +} + +// if exceptions are present, sends unique exception +// if not, calls abort() to terminate +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Terminate() +{ _STLP_ABORT(); } + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +# endif /* _STLP_ASSERTIONS */ + +# if defined (_STLP_DEBUG) + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +//========================================================== +// owned_list non-inline methods +//========================================================== + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Invalidate_all(__owned_list* __l) { + _STLP_ACQUIRE_LOCK(__l->_M_lock); + _Stamp_all(__l, 0); + __l->_M_node._M_next =0; + _STLP_RELEASE_LOCK(__l->_M_lock); +} + +// boris : this is unasafe routine; should be used from within critical section only ! +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Stamp_all(__owned_list* __l, __owned_list* __o) { + // crucial + if (__l->_M_node._M_owner) { + for (__owned_link* __pos = (__owned_link*)__l->_M_node._M_next; + __pos != 0; __pos = (__owned_link*)__pos->_M_next) { + _STLP_ASSERT(__pos->_Owner()== __l) + __pos->_M_owner=__o; + } + } +} + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Verify(const __owned_list* __l) { + _STLP_ACQUIRE_LOCK(__l->_M_lock); + if (__l) { + _STLP_ASSERT(__l->_M_node._Owner() != 0) + for (__owned_link* __pos = (__owned_link*)__l->_M_node._M_next; + __pos != 0; __pos = (__owned_link*)__pos->_M_next) { + _STLP_ASSERT(__pos->_Owner()== __l) + } + } + _STLP_RELEASE_LOCK(__l->_M_lock); +} + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Swap_owners(__owned_list& __x, __owned_list& __y) { + /* + * according to the standard : --no swap() function invalidates any references, + * pointers, or iterators referring to the elements of the containers being swapped. + */ + + __owned_link* __tmp; + + /* + * boris : there is a deadlock potential situation here if we lock two containers sequentially. + * As user is supposed to provide its own synchronization around swap() ( it is unsafe to do any container/iterator access + * in parallel with swap()), we just do not use any locking at all -- that behaviour is closer to non-debug version + */ + + __tmp = __x._M_node._M_next; + + _Stamp_all(&__x, &__y); + _Stamp_all(&__y, &__x); + + __x._M_node._M_next = __y._M_node._M_next; + __y._M_node._M_next = __tmp; +} + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_Set_owner(__owned_list& __src, __owned_list& __dst) { + if (&__src == &__dst) + return; + + // Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here + typedef __owned_link _L_type; + _L_type* __prev = &__src._M_node; + _L_type* __pos = __prev->_M_next; + + while (__pos != 0) { + __pos->_M_owner = &__dst; + __prev = __pos; + __pos = __prev->_M_next; + } + __prev->_M_next = __dst._M_node._M_next; + __dst._M_node._M_next = __src._M_node._M_next; + __src._M_node._M_next = 0; +} + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_M_detach(__owned_list* __l, __owned_link* __c_node) { + if (__l != 0) { + + _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER) + + _STLP_ACQUIRE_LOCK(__l->_M_lock) + // boris : re-test the condition in case someone else already deleted us + if(__c_node->_M_owner != 0) { + __owned_link* __prev, *__next; + + for (__prev = &__l->_M_node; (__next = __prev->_M_next) != __c_node; + __prev = __next) { + _STLP_ASSERT(__next && __next->_Owner() == __l) + } + + __prev->_M_next = __c_node->_M_next; + __c_node->_M_owner=0; + } + _STLP_RELEASE_LOCK(__l->_M_lock) + } +} + +template +void _STLP_CALL +__stl_debug_engine<_Dummy>::_M_attach(__owned_list* __l, __owned_link* __c_node) { + if (__l ==0) { + (__c_node)->_M_owner = 0; + } else { + _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER) + _STLP_ACQUIRE_LOCK(__l->_M_lock) + __c_node->_M_owner = __l; + __c_node->_M_next = __l->_M_node._M_next; + __l->_M_node._M_next = __c_node; + _STLP_RELEASE_LOCK(__l->_M_lock) + } +} + +template +void* _STLP_CALL +__stl_debug_engine<_Dummy>::_Get_container_ptr(const __owned_link* __l) { + const __owned_list* __owner = __l->_Owner(); + _STLP_VERBOSE_RETURN_0(__owner != 0, _StlMsg_INVALID_ITERATOR) + void* __ret = __CONST_CAST(void*,__owner->_Owner()); + _STLP_VERBOSE_RETURN_0(__ret !=0, _StlMsg_INVALID_CONTAINER) + return __ret; +} + +template +bool _STLP_CALL +__stl_debug_engine<_Dummy>::_Check_same_owner(const __owned_link& __i1, + const __owned_link& __i2) { + _STLP_VERBOSE_RETURN(__i1._Valid(), _StlMsg_INVALID_LEFTHAND_ITERATOR) + _STLP_VERBOSE_RETURN(__i2._Valid(), _StlMsg_INVALID_RIGHTHAND_ITERATOR) + _STLP_VERBOSE_RETURN((__i1._Owner() == __i2._Owner()), _StlMsg_DIFFERENT_OWNERS) + return true; +} + +template +bool _STLP_CALL +__stl_debug_engine<_Dummy>::_Check_same_or_null_owner(const __owned_link& __i1, + const __owned_link& __i2) { + _STLP_VERBOSE_RETURN(__i1._Owner() == __i2._Owner(), _StlMsg_DIFFERENT_OWNERS) + return true; +} + +template +bool _STLP_CALL +__stl_debug_engine<_Dummy>::_Check_if_owner( const __owned_list * __l, const __owned_link& __it) { + const __owned_list* __owner_ptr = __it._Owner(); + _STLP_VERBOSE_RETURN(__owner_ptr != 0, _StlMsg_INVALID_ITERATOR) + _STLP_VERBOSE_RETURN(__l == __owner_ptr, _StlMsg_NOT_OWNER) + return true; +} + +template +bool _STLP_CALL +__stl_debug_engine<_Dummy>::_Check_if_not_owner( const __owned_list * __l, const __owned_link& __it) { + const __owned_list* __owner_ptr = __it._Owner(); + _STLP_VERBOSE_RETURN(__owner_ptr != 0, _StlMsg_INVALID_ITERATOR) + _STLP_VERBOSE_RETURN(__l != __owner_ptr, _StlMsg_SHOULD_NOT_OWNER) + return true; +} + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +# endif /* _STLP_DEBUG */ + +#endif /* if defined (EXPOSE_GLOBALS_IMPLEMENTATION) */ + +#endif /* header guard */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_debug.h b/sdk/tlibstdcxx/stlport/stl/debug/_debug.h new file mode 100644 index 0000000000..6a2a8ce9e0 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_debug.h @@ -0,0 +1,473 @@ +/* + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_DEBUG_H +#define _STLP_DEBUG_H + +#if (defined (_STLP_DEBUG) || defined (_STLP_DEBUG_ALLOC)) && \ + !defined (_STLP_ASSERTIONS) +# define _STLP_ASSERTIONS 1 +#endif + +#if defined (_STLP_ASSERTIONS) + +# if !defined (_STLP_FILE__) +# define _STLP_FILE__ __FILE__ +# endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +enum { + //General errors + _StlFormat_ERROR_RETURN, + _StlFormat_ASSERTION_FAILURE, + _StlFormat_VERBOSE_ASSERTION_FAILURE, + _StlMsg_INVALID_ARGUMENT, + //Container/Iterator related errors + _StlMsg_INVALID_CONTAINER, + _StlMsg_EMPTY_CONTAINER, + _StlMsg_ERASE_PAST_THE_END, + _StlMsg_OUT_OF_BOUNDS, + _StlMsg_NOT_OWNER, + _StlMsg_SHOULD_NOT_OWNER, + _StlMsg_INVALID_ITERATOR, + _StlMsg_INVALID_LEFTHAND_ITERATOR, + _StlMsg_INVALID_RIGHTHAND_ITERATOR, + _StlMsg_DIFFERENT_OWNERS , + _StlMsg_NOT_DEREFERENCEABLE , + _StlMsg_INVALID_RANGE , + _StlMsg_NOT_IN_RANGE_1 , + _StlMsg_NOT_IN_RANGE_2 , + _StlMsg_INVALID_ADVANCE , + _StlMsg_SINGULAR_ITERATOR , + //Bad predicate for sorting + _StlMsg_INVALID_STRICT_WEAK_PREDICATE, + _StlMsg_INVALID_EQUIVALENT_PREDICATE, + // debug alloc messages + _StlMsg_DBA_DELETED_TWICE , + _StlMsg_DBA_NEVER_ALLOCATED , + _StlMsg_DBA_TYPE_MISMATCH , + _StlMsg_DBA_SIZE_MISMATCH , + _StlMsg_DBA_UNDERRUN , + _StlMsg_DBA_OVERRUN , + // auto_ptr messages + _StlMsg_AUTO_PTR_NULL , + //Memory alignent message + _StlMsg_WRONG_MEMORY_ALIGNMENT, + _StlMsg_UNKNOWN + /* _StlMsg_MAX */ +}; + +/* have to hardcode that ;() */ +# define _StlMsg_MAX 31 + +class __owned_link; +class __owned_list; + +# if defined (_STLP_DEBUG_MODE_THROWS) +# define _STLP_MESSAGE_NORETURN _STLP_FUNCTION_THROWS +# else +# define _STLP_MESSAGE_NORETURN +# endif + +template +class __stl_debug_engine { +public: + // Basic routine to report any debug message + // Use _STLP_DEBUG_MESSAGE to override + static void _STLP_MESSAGE_NORETURN _STLP_CALL _Message(const char * format_str, ...); + + // Micsellanous function to report indexed error message + static void _STLP_CALL _IndexedError(int __ind, const char* __f, int __l); + + // Basic assertion report mechanism. + // Reports failed assertion via __stl_debug_message and calls _Terminate + // if _STLP_DEBUG_TERMINATE is specified, calls __stl_debug_terminate instead + static void _STLP_CALL _Assert(const char* __expr, const char* __f, int __l); + + // The same, with additional diagnostics + static void _STLP_CALL _VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l); + + // If exceptions are present, sends unique exception + // If not, calls _STLP_ABORT() to terminate + // Use _STLP_DEBUG_TERMINATE to override + static void _STLP_CALL _Terminate(); + +# if defined (_STLP_DEBUG) + // owned_list/link delegate non-inline functions here + + static bool _STLP_CALL _Check_same_owner( const __owned_link& __i1, + const __owned_link& __i2); + static bool _STLP_CALL _Check_same_or_null_owner( const __owned_link& __i1, + const __owned_link& __i2); + static bool _STLP_CALL _Check_if_owner( const __owned_list*, const __owned_link&); + + static bool _STLP_CALL _Check_if_not_owner( const __owned_list*, const __owned_link&); + + static void _STLP_CALL _Verify(const __owned_list*); + + static void _STLP_CALL _Swap_owners(__owned_list&, __owned_list&); + + static void _STLP_CALL _Invalidate_all(__owned_list*); + + static void _STLP_CALL _Set_owner(__owned_list& /*src*/, __owned_list& /*dst*/); + + static void _STLP_CALL _Stamp_all(__owned_list*, __owned_list*); + + static void _STLP_CALL _M_detach(__owned_list*, __owned_link*); + + static void _STLP_CALL _M_attach(__owned_list*, __owned_link*); + + // accessor : check and get pointer to the container + static void* _STLP_CALL _Get_container_ptr(const __owned_link*); +# endif + + // debug messages and formats + static const char* _Message_table[_StlMsg_MAX]; +}; + +# undef _STLP_MESSAGE_NORETURN + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS __stl_debug_engine; +# endif + +typedef __stl_debug_engine __stl_debugger; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +# if !defined (_STLP_ASSERT) +# define _STLP_ASSERT(expr) \ + if (!(expr)) { _STLP_PRIV __stl_debugger::_Assert( # expr, _STLP_FILE__, __LINE__); } +# endif + +#else +# define _STLP_ASSERT(expr) +#endif + +// this section is for _STLP_DEBUG only +#if defined (_STLP_DEBUG) + +# if !defined (_STLP_VERBOSE_ASSERT) +// fbp : new form not requiring ";" +# define _STLP_VERBOSE_ASSERT(expr, __diag_num) \ + if (!(expr)) { _STLP_PRIV __stl_debugger::_VerboseAssert\ + ( # expr, _STLP_PRIV __diag_num, _STLP_FILE__, __LINE__ ); \ + } +# endif + +# define _STLP_DEBUG_CHECK(expr) _STLP_ASSERT(expr) + +# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) +# define _STLP_STD_DEBUG_CHECK(expr) _STLP_DEBUG_CHECK(expr) +# else +# define _STLP_STD_DEBUG_CHECK(expr) +# endif + +# if !defined (_STLP_VERBOSE_RETURN) +# define _STLP_VERBOSE_RETURN(__expr,__diag_num) if (!(__expr)) { \ + _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__ , __LINE__); \ + return false; } +# endif + +# if !defined (_STLP_VERBOSE_RETURN_0) +# define _STLP_VERBOSE_RETURN_0(__expr,__diag_num) if (!(__expr)) { \ + _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__, __LINE__); \ + return 0; } +# endif + +# ifndef _STLP_INTERNAL_THREADS_H +# include +# endif + +# ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include +# endif + +# ifndef _STLP_TYPE_TRAITS_H +# include +# endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* + * Special debug iterator traits having an additionnal static member + * method _Check. It is used by the slist debug implementation to check + * the special before_begin iterator. + */ +template +struct _DbgTraits : _Traits { + typedef _DbgTraits _ConstTraits; + typedef _DbgTraits _NonConstTraits; + + template + static bool _Check(const _Iterator&) {return true;} +}; + +//============================================================= +template +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, + const random_access_iterator_tag&) +{ return (__i1 < __i2) || (__i1 == __i2); } + +template +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, + const bidirectional_iterator_tag&) { + // check if comparable + bool __dummy(__i1==__i2); + return (__dummy==__dummy); +} + +template +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, + const forward_iterator_tag&) { + // check if comparable + bool __dummy(__i1==__i2); + return (__dummy==__dummy); +} + +template +inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, + const input_iterator_tag&) +{ return true; } + +template +inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, + const output_iterator_tag&) +{ return true; } + +template +inline bool _STLP_CALL __valid_range(const _Iterator& __i1, const _Iterator& __i2) +{ return __valid_range(__i1,__i2,_STLP_ITERATOR_CATEGORY(__i1, _Iterator)); } + +// Note : that means in range [i1, i2]. +template +inline bool _STLP_CALL stlp_in_range(const _Iterator& _It, + const _Iterator& __i1, const _Iterator& __i2) +{ return __valid_range(__i1,_It) && __valid_range(_It,__i2); } + +template +inline bool _STLP_CALL stlp_in_range(const _Iterator& __first, const _Iterator& __last, + const _Iterator& __start, const _Iterator& __finish) +{ return __valid_range(__first,__last) && __valid_range(__start,__first) && __valid_range(__last,__finish); } + +//========================================================== +class _STLP_CLASS_DECLSPEC __owned_link { +public: + // Note: This and the following special defines for compiling under Windows CE under ARM + // is needed for correctly using _STLP_DEBUG mode. This comes from a bug in the ARM + // compiler where checked iterators that are passed by value call _M_attach with the wrong + // this pointer and calling _M_detach can't find the correct pointer to the __owned_link. + // This is circumvented by managing a _M_self pointer that points to the correct value. + // Ugly but works. +#if defined(_STLP_WCE) && defined(_ARM_) + __owned_link() : _M_self(this), _M_owner(0) {} + __owned_link(const __owned_list* __c) : _M_self(this), _M_owner(0), _M_next(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this); } + __owned_link(const __owned_link& __rhs): _M_self(this), _M_owner(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this); } +#else + __owned_link() : _M_owner(0) {} + __owned_link(const __owned_list* __c) : _M_owner(0), _M_next(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this); } + __owned_link(const __owned_link& __rhs): _M_owner(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this); } +#endif + __owned_link& operator=(const __owned_link& __rhs) { + __owned_list* __new_owner = __CONST_CAST(__owned_list*,__rhs._M_owner); + __owned_list* __old_owner = _M_owner; + if ( __old_owner != __new_owner ) { + __stl_debugger::_M_detach(__old_owner, this); + __stl_debugger::_M_attach(__new_owner, this); + } + return *this; + } +#if defined(_STLP_WCE) && defined(_ARM_) + ~__owned_link() { + __stl_debugger::_M_detach(_M_owner, _M_self); + _Invalidate(); + } +#else + ~__owned_link() { + __stl_debugger::_M_detach(_M_owner, this); + _Invalidate(); + } +#endif + + const __owned_list* _Owner() const { return _M_owner; } + __owned_list* _Owner() { return _M_owner; } + void _Set_owner(const __owned_list* __o) { _M_owner= __CONST_CAST(__owned_list*,__o); } + bool _Valid() const { return _M_owner != 0; } + void _Invalidate() { _M_owner = 0; _M_next = 0; } + void _Link_to_self() { _M_next = 0; } + + __owned_link* _Next() { return _M_next; } + const __owned_link* _Next() const { return _M_next; } + +public: +#if defined(_STLP_WCE) && defined(_ARM_) + __owned_link* _M_self; +#endif + + __owned_list* _M_owner; + __owned_link* _M_next; +}; + + +class _STLP_CLASS_DECLSPEC __owned_list { +public: + __owned_list(void* __o) { + // fprintf(stderr, "__owned_list(): %p\n",(void*)this); + _M_node._M_owner = __REINTERPRET_CAST(__owned_list*,__o); + _M_node._M_next = 0; + } + ~__owned_list() { + // fprintf(stderr, "~__owned_list(): %p\n",(void*)this); + _Invalidate_all(); + // that prevents detach + _M_node._Invalidate(); + } + const void* _Owner() const { return (const void*)_M_node._M_owner; } + void* _Owner() { return (void*)_M_node._M_owner; } + bool _Valid() const { return _M_node._M_owner != 0; } + void _Invalidate() { _M_node._M_owner = 0; } + + __owned_link* _First() { return _M_node._Next(); } + __owned_link* _Last() { return 0 ; } + + const __owned_link* _First() const { return (__owned_link*)_M_node._M_next; } + const __owned_link* _Last() const { return 0 ;} + + void _Verify() const { __stl_debugger::_Verify(this); } + void _Swap_owners(__owned_list& __y) { __stl_debugger::_Swap_owners(*this, __y); } + void _Invalidate_all() { __stl_debugger::_Invalidate_all(this); } + void _Set_owner(__owned_list& __y) { __stl_debugger::_Set_owner(*this, __y); } + + mutable __owned_link _M_node; + mutable _STLP_mutex _M_lock; + +private: + // should never be called, should be left not implemented, + // but some compilers complain about it ;( + __owned_list(const __owned_list&){} + __owned_list& operator = (const __owned_list&) { return *this; } + + friend class __owned_link; + friend class __stl_debug_engine; +}; + + +//========================================================== + +// forward declaratioins + +template +bool _STLP_CALL __check_range(const _Iterator&, const _Iterator&); +template +bool _STLP_CALL __check_range(const _Iterator&, + const _Iterator&, const _Iterator&); +template +bool _STLP_CALL __check_range(const _Iterator&, const _Iterator& , + const _Iterator&, const _Iterator& ); +template +bool _STLP_CALL __check_ptr_range(const _Tp*, const _Tp*); + +template +void _STLP_CALL __invalidate_range(const __owned_list* __base, + const _Iterator& __first, + const _Iterator& __last); + +template +void _STLP_CALL __invalidate_iterator(const __owned_list* __base, + const _Iterator& __it); + +template +void _STLP_CALL __change_range_owner(const _Iterator& __first, + const _Iterator& __last, + const __owned_list* __dst); + +template +void _STLP_CALL __change_ite_owner(const _Iterator& __it, + const __owned_list* __dst); + +//============================================================ +inline bool _STLP_CALL +__check_same_owner(const __owned_link& __i1, const __owned_link& __i2) +{ return __stl_debugger::_Check_same_owner(__i1,__i2); } + +inline bool _STLP_CALL +__check_same_or_null_owner(const __owned_link& __i1, const __owned_link& __i2) +{ return __stl_debugger::_Check_same_or_null_owner(__i1,__i2); } + +template +inline bool _STLP_CALL __check_if_owner( const __owned_list* __owner, + const _Iterator& __it) +{ return __stl_debugger::_Check_if_owner(__owner, (const __owned_link&)__it); } + +template +inline bool _STLP_CALL __check_if_not_owner( const __owned_list* __owner, + const _Iterator& __it) +{ return __stl_debugger::_Check_if_not_owner(__owner, (const __owned_link&)__it); } + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#else +# define _STLP_VERBOSE_ASSERT(expr, diagnostic) +# define _STLP_DEBUG_CHECK(expr) +#endif /* _STLP_DEBUG */ + +#if defined (_STLP_ASSERTIONS) + +# if !defined (_STLP_ASSERT_MSG_TRAILER) +# define _STLP_ASSERT_MSG_TRAILER +# endif + +// dwa 12/30/98 - if _STLP_DEBUG_MESSAGE is defined, the user can supply own definition. +# if !defined (_STLP_DEBUG_MESSAGE) +# define __stl_debug_message __stl_debugger::_Message +# else +extern void __stl_debug_message(const char * format_str, ...); +# endif + +// fbp: if _STLP_DEBUG_TERMINATE is defined, the user can supply own definition. +# if !defined (_STLP_DEBUG_TERMINATE) +# define __stl_debug_terminate __stl_debugger::_Terminate +# else +extern void __stl_debug_terminate(); +# endif + +#endif + +#if defined (_STLP_ASSERTIONS) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include +#endif + +#endif /* DEBUG_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_deque.h b/sdk/tlibstdcxx/stlport/stl/debug/_deque.h new file mode 100644 index 0000000000..f5c5ff5d7a --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_deque.h @@ -0,0 +1,414 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_DBG_DEQUE_H +#define _STLP_INTERNAL_DBG_DEQUE_H + +#ifndef _STLP_DBG_ITERATOR_H +# include +#endif + +#define _STLP_NON_DBG_DEQUE _STLP_PRIV _STLP_NON_DBG_NAME(deque) <_Tp,_Alloc> + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +template +inline _Tp* value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&) +{ return (_Tp*)0; } +template +inline random_access_iterator_tag iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&) +{ return random_access_iterator_tag(); } +#endif + +template ) > +class deque : +#if !defined (__DMC__) + private +#endif + _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE > +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + , public __stlport_class > +#endif +{ + typedef deque<_Tp,_Alloc> _Self; + typedef _STLP_NON_DBG_DEQUE _Base; + typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE > _ConstructCheck; + +public: + // Basic types + __IMPORT_CONTAINER_TYPEDEFS(_Base) + + // Iterators + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits > > iterator; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits > > const_iterator; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +protected: + _Base _M_non_dbg_impl; + _STLP_PRIV __owned_list _M_iter_list; + + void _Invalidate_all() + { _M_iter_list._Invalidate_all(); } + void _Invalidate_iterator(const iterator& __it) + { _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); } + void _Invalidate_iterators(const iterator& __first, const iterator& __last) + { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); } + +public: + // Basic accessors + allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } + + iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + reference operator[](size_type __n) { + _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS) + return _M_non_dbg_impl[__n]; + } + const_reference operator[](size_type __n) const { + _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS) + return _M_non_dbg_impl[__n]; + } + + reference at(size_type __n) { return _M_non_dbg_impl.at(__n); } + const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); } + + reference front() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *begin(); + } + const_reference front() const { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *begin(); + } + reference back() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *(--end()); + } + const_reference back() const { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *(--end()); + } + + // Constructor, destructor. + explicit deque(const allocator_type& __a = allocator_type()) : + _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {} + deque(const _Self& __x) : + _ConstructCheck(__x), _M_non_dbg_impl(__x._M_non_dbg_impl), + _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit deque(size_type __n, const value_type& __x = _Tp(), +#else + deque(size_type __n, const value_type& __x, +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + const allocator_type& __a = allocator_type()) : + _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {} +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit deque(size_type __n) : + _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {} +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + deque(__move_source<_Self> src) + : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)), + _M_iter_list(&_M_non_dbg_impl) { +# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + src.get()._M_iter_list._Invalidate_all(); +# else + src.get()._M_iter_list._Set_owner(_M_iter_list); +# endif + } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + deque(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a), + _M_iter_list(&_M_non_dbg_impl) { + } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + deque(_InputIterator __first, _InputIterator __last) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)), + _M_iter_list(&_M_non_dbg_impl) { + } +# endif +#else + deque(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(__first, __last, __a), + _M_iter_list(&_M_non_dbg_impl) { + } + + deque(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a), + _M_iter_list(&_M_non_dbg_impl) { + } +#endif + + _Self& operator=(const _Self& __x) { + if (this != &__x) { + _Invalidate_all(); + _M_non_dbg_impl = __x._M_non_dbg_impl; + } + return *this; + } + + bool empty() const { return _M_non_dbg_impl.empty(); } + size_type size() const { return _M_non_dbg_impl.size(); } + size_type max_size() const { return _M_non_dbg_impl.max_size(); } + + void swap(_Self& __x) { + _M_iter_list._Swap_owners(__x._M_iter_list); + _M_non_dbg_impl.swap(__x._M_non_dbg_impl); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +public: + void assign(size_type __n, const _Tp& __val) { + _Invalidate_all(); + _M_non_dbg_impl.assign(__n, __val); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _Invalidate_all(); + _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } +#else + void assign(const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _Invalidate_all(); + _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator); + } + void assign(const value_type *__first, const value_type *__last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) + _Invalidate_all(); + _M_non_dbg_impl.assign(__first, __last); + } +#endif + +public: // push_* and pop_* + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back(const value_type& __t = _Tp()) { +#else + void push_back(const value_type& __t) { +#endif + _Invalidate_all(); + _M_non_dbg_impl.push_back(__t); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back() { + _Invalidate_all(); + _M_non_dbg_impl.push_back(); + } +#endif + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_front(const value_type& __t = _Tp()) { +#else + void push_front(const value_type& __t) { +#endif + _Invalidate_all(); + _M_non_dbg_impl.push_front(__t); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_front() { + _Invalidate_all(); + _M_non_dbg_impl.push_front(); + } +#endif + + void pop_back() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + _Invalidate_iterator(end()); + _M_non_dbg_impl.pop_back(); + } + + void pop_front() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + _Invalidate_iterator(begin()); + _M_non_dbg_impl.pop_front(); + } + +public: // Insert + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const value_type& __x = _Tp()) { +#else + iterator insert(iterator __pos, const value_type& __x) { +#endif + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _Invalidate_all(); + return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x)); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _Invalidate_all(); + return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator)); + } +#endif + + void insert(iterator __pos, size_type __n, const value_type& __x) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + if (__n != 0) _Invalidate_all(); + _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + // We perform invalidate first to detect self referencing in __check_range as __first and __last + // will have been invalidated. + if (__first != __last) _Invalidate_all(); + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.insert(__pos._M_iterator, + _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) + void insert(iterator __pos, + const value_type* __first, const value_type* __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) + if (__first != __last) _Invalidate_all(); + _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) + void insert(iterator __pos, + const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + //Sequence requirements 23.1.1 Table 67: + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first)); + if (__first != __last) _Invalidate_all(); + _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + } + + void insert(iterator __pos, + iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + //Sequence requirements 23.1.1 Table 67: + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first)); + if (__first != __last) _Invalidate_all(); + _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + } +#endif + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const value_type& __x = _Tp()) { +#else + void resize(size_type __new_size, const value_type& __x) { +#endif + if (__new_size != size()) { + if ((__new_size > size()) || (__new_size < size() - 1)) + _Invalidate_all(); + else + _Invalidate_iterator(end()); + } + _M_non_dbg_impl.resize(__new_size, __x); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type new_size) { resize(new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif + + // Erase + iterator erase(iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + if (__pos._M_iterator == _M_non_dbg_impl.begin()) { + _Invalidate_iterator(__pos); + } else { + typename _Base::iterator tmp = --(_M_non_dbg_impl.end()); + if (__pos._M_iterator == tmp) + _Invalidate_iterator(__pos); + else + _Invalidate_all(); + } + return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator)); + } + + iterator erase(iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + if (!empty()) { + if (__first._M_iterator == _M_non_dbg_impl.begin() || + __last._M_iterator == _M_non_dbg_impl.end()) + _Invalidate_iterators(__first, __last); + else + _Invalidate_all(); + } + return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator)); + } + + void clear() { + _Invalidate_all(); + _M_non_dbg_impl.clear(); + } +}; + +_STLP_END_NAMESPACE + +#undef _STLP_NON_DBG_DEQUE + +#endif /* _STLP_INTERNAL_DEQUE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_hashtable.h b/sdk/tlibstdcxx/stlport/stl/debug/_hashtable.h new file mode 100644 index 0000000000..523f7e325f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_hashtable.h @@ -0,0 +1,340 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_DBG_HASHTABLE_H +#define _STLP_INTERNAL_DBG_HASHTABLE_H + +// Hashtable class, used to implement the hashed associative containers +// hash_set, hash_map, hash_multiset, and hash_multimap, +// unordered_set, unordered_map, unordered_multiset, unordered_multimap + +#ifndef _STLP_DBG_ITERATOR_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class _DbgEqual { +public: + _DbgEqual() {} + _DbgEqual(const _Equal& __eq) : _M_non_dbg_eq(__eq) {} + _DbgEqual(const _DbgEqual& __eq) : _M_non_dbg_eq(__eq._M_non_dbg_eq) {} + +#if !defined (_STLP_USE_CONTAINERS_EXTENSION) + bool operator () (const _Key& __lhs, const _Key& __rhs) const +#else + template + bool operator () (const _Kp1& __lhs, const _Kp2& __rhs) const +#endif + { +#if !defined (_STLP_USE_CONTAINERS_EXTENSION) + _STLP_VERBOSE_ASSERT(_M_non_dbg_eq(__rhs, __lhs) == _M_non_dbg_eq(__lhs, __rhs), _StlMsg_INVALID_EQUIVALENT_PREDICATE) +#endif + return _M_non_dbg_eq(__lhs, __rhs) ? true : false; + } + + _Equal non_dbg_key_eq() const { return _M_non_dbg_eq; } +private: + _Equal _M_non_dbg_eq; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +#define _STLP_NON_DBG_HT \ +_STLP_PRIV _STLP_NON_DBG_NAME(hashtable) <_Val, _Key, _HF, _Traits, _ExK, _STLP_PRIV _DbgEqual<_Key, _EqK>, _All> + +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +template +inline _Val* +value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_HT >&) +{ return (_Val*)0; } + +template +inline forward_iterator_tag +iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_HT >&) +{ return forward_iterator_tag(); } +#endif + +template +class hashtable { + typedef hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All> _Self; + typedef _STLP_NON_DBG_HT _Base; + + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef typename _Traits::_NonConstLocalTraits _NonConstLocalTraits; + typedef typename _Traits::_ConstLocalTraits _ConstLocalTraits; + + _Base _M_non_dbg_impl; + _STLP_PRIV __owned_list _M_iter_list; + +public: + typedef _Key key_type; + typedef _HF hasher; + typedef _EqK key_equal; + + __IMPORT_CONTAINER_TYPEDEFS(_Base) + + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_NonConstTraits> > iterator; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_ConstTraits> > const_iterator; + //typedef _STLP_PRIV _DBG_iter<_Base, _DbgTraits<_NonConstLocalTraits> > local_iterator; + typedef iterator local_iterator; + //typedef _STLP_PRIV _DBG_iter<_Base, _DbgTraits<_ConstLocalTraits> > const_local_iterator; + typedef const_iterator const_local_iterator; + + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_iterator _Base_const_iterator; + + hasher hash_funct() const { return _M_non_dbg_impl.hash_funct(); } + key_equal key_eq() const { return _M_non_dbg_impl.key_eq().non_dbg_key_eq(); } + +private: + void _Invalidate_iterator(const const_iterator& __it) + { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); } + void _Invalidate_iterators(const const_iterator& __first, const const_iterator& __last) + { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); } + + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } + + hashtable(size_type __n, + const _HF& __hf, + const _EqK& __eql, + const _ExK& __ext, + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__n, __hf, __eql, __ext, __a), + _M_iter_list(&_M_non_dbg_impl) {} + + hashtable(size_type __n, + const _HF& __hf, + const _EqK& __eql, + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__n, __hf, __eql, __a), + _M_iter_list(&_M_non_dbg_impl) {} + + hashtable(const _Self& __ht) + : _M_non_dbg_impl(__ht._M_non_dbg_impl), + _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + hashtable(__move_source<_Self> src) + : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)), + _M_iter_list(&_M_non_dbg_impl) { +# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + src.get()._M_iter_list._Invalidate_all(); +# else + src.get()._M_iter_list._Set_owner(_M_iter_list); +# endif + } +#endif + + size_type size() const { return _M_non_dbg_impl.size(); } + size_type max_size() const { return _M_non_dbg_impl.max_size(); } + bool empty() const { return _M_non_dbg_impl.empty(); } + + _Self& operator=(const _Self& __ht) { + if (this != &__ht) { + //Should not invalidate end iterator + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl = __ht._M_non_dbg_impl; + } + return *this; + } + + void swap(_Self& __ht) { + _M_iter_list._Swap_owners(__ht._M_iter_list); + _M_non_dbg_impl.swap(__ht._M_non_dbg_impl); + } + + iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + local_iterator begin(size_type __n) { + //TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators + _STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT) + return local_iterator(&_M_iter_list, _M_non_dbg_impl.begin(__n)); + } + local_iterator end(size_type __n) { + //TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators + _STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT) + return local_iterator(&_M_iter_list, _M_non_dbg_impl.end(__n)); + } + + const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + const_local_iterator begin(size_type __n) const { + //TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators + _STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT) + return const_local_iterator(&_M_iter_list, _M_non_dbg_impl.begin(__n)); + } + const_local_iterator end(size_type __n) const { + //TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators + _STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT) + return const_local_iterator(&_M_iter_list, _M_non_dbg_impl.end(__n)); + } + + pair insert_unique(const value_type& __obj) { + pair<_Base_iterator, bool> __res = _M_non_dbg_impl.insert_unique(__obj); + return pair(iterator(&_M_iter_list, __res.first), __res.second); + } + + iterator insert_equal(const value_type& __obj) + { return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__obj)); } + + pair insert_unique_noresize(const value_type& __obj) { + pair<_Base_iterator, bool> __res = _M_non_dbg_impl.insert_unique_noresize(__obj); + return pair(iterator(&_M_iter_list, __res.first), __res.second); + } + + iterator insert_equal_noresize(const value_type& __obj) + { return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal_noresize(__obj)); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert_unique(_InputIterator __f, _InputIterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + _M_non_dbg_impl.insert_unique(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)); + } + + template + void insert_equal(_InputIterator __f, _InputIterator __l){ + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + _M_non_dbg_impl.insert_equal(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)); + } + +#else + void insert_unique(const value_type* __f, const value_type* __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l)) + _M_non_dbg_impl.insert_unique(__f, __l); + } + + void insert_equal(const value_type* __f, const value_type* __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l)) + _M_non_dbg_impl.insert_equal(__f, __l); + } + + void insert_unique(const_iterator __f, const_iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + _M_non_dbg_impl.insert_unique(__f._M_iterator, __l._M_iterator); + } + + void insert_equal(const_iterator __f, const_iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + _M_non_dbg_impl.insert_equal(__f._M_iterator, __l._M_iterator); + } +#endif + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) + { return iterator(&_M_iter_list, _M_non_dbg_impl.find(__key)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const + { return const_iterator(&_M_iter_list, _M_non_dbg_impl.find(__key)); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_non_dbg_impl.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) { + pair<_Base_iterator, _Base_iterator> __res = _M_non_dbg_impl.equal_range(__key); + return pair (iterator(&_M_iter_list,__res.first), + iterator(&_M_iter_list,__res.second)); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __key) const { + pair <_Base_const_iterator, _Base_const_iterator> __res = _M_non_dbg_impl.equal_range(__key); + return pair (const_iterator(&_M_iter_list,__res.first), + const_iterator(&_M_iter_list,__res.second)); + } + + size_type erase(const key_type& __key) { + pair __p = equal_range(__key); + size_type __n = _STLP_STD::distance(__p.first, __p.second); + _Invalidate_iterators(__p.first, __p.second); + _M_non_dbg_impl.erase(__p.first._M_iterator, __p.second._M_iterator); + return __n; + } + + void erase(const const_iterator& __it) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__it)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __it)) + _Invalidate_iterator(__it); + _M_non_dbg_impl.erase(__it._M_iterator); + } + void erase(const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, + const_iterator(begin()), const_iterator(end()))) + _Invalidate_iterators(__first, __last); + _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator); + } + + void rehash(size_type __num_buckets_hint) { _M_non_dbg_impl.rehash(__num_buckets_hint); } + void resize(size_type __num_elements_hint) { _M_non_dbg_impl.resize(__num_elements_hint); } + + void clear() { + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.clear(); + } + + reference _M_insert(const value_type& __obj) { return _M_non_dbg_impl._M_insert(__obj); } + + size_type bucket_count() const { return _M_non_dbg_impl.bucket_count(); } + size_type max_bucket_count() const { return _M_non_dbg_impl.max_bucket_count(); } + size_type elems_in_bucket(size_type __n) const { + _STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.elems_in_bucket(__n); + } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_non_dbg_impl.bucket(__k); } + + float load_factor() const { return _M_non_dbg_impl.load_factor(); } + float max_load_factor() const { return _M_non_dbg_impl.max_load_factor(); } + void max_load_factor(float __z) { + _STLP_VERBOSE_ASSERT((__z > 0.0f), _StlMsg_INVALID_ARGUMENT) + _M_non_dbg_impl.max_load_factor(__z); + } +}; + +_STLP_END_NAMESPACE + +#undef _STLP_NON_DBG_HT + +#endif /* _STLP_INTERNAL_HASHTABLE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_iterator.h b/sdk/tlibstdcxx/stlport/stl/debug/_iterator.h new file mode 100644 index 0000000000..b2c8956ec3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_iterator.h @@ -0,0 +1,457 @@ +/* + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_DBG_ITERATOR_H +#define _STLP_DBG_ITERATOR_H + +#ifndef _STLP_INTERNAL_PAIR_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +//============================================================ + +template +void _Decrement(_Iterator& __it, const bidirectional_iterator_tag &) +{ --__it; } + +template +void _Decrement(_Iterator& __it, const random_access_iterator_tag &) +{ --__it; } + +template +void _Decrement(_Iterator& __it, const forward_iterator_tag &) +{ _STLP_ASSERT(0) } + +template +void _Advance(_Iterator&, ptrdiff_t, const forward_iterator_tag &) +{ _STLP_ASSERT(0) } + +template +void _Advance(_Iterator& __it, ptrdiff_t, const bidirectional_iterator_tag &) +{ _STLP_ASSERT(0) } + +template +void _Advance(_Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) +{ __it += __n; } + +template +ptrdiff_t _DBG_distance(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) +{ return __x - __y; } + +template +ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const forward_iterator_tag &) { + _STLP_ASSERT(0) + return 0; +} + +template +ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) { + _STLP_ASSERT(0) + return 0; +} + +template +bool _CompareIt(const _Iterator&, const _Iterator&, const forward_iterator_tag &) { + _STLP_ASSERT(0) + return false; +} + +template +bool _CompareIt(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) { + _STLP_ASSERT(0) + return false; +} + +template +bool _CompareIt(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) +{ return __x < __y; } + +template +bool _Dereferenceable(const _Iterator& __it) +{ return (__it._Get_container_ptr() != 0) && !(__it._M_iterator == (__it._Get_container_ptr())->end()); } + +template +bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const forward_iterator_tag &) +{ return (__n == 1) && _Dereferenceable(__it); } + +template +bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const bidirectional_iterator_tag &) { + typedef typename _Iterator::_Container_type __container_type; + __container_type* __c = __it._Get_container_ptr(); + return (__c != 0) && ((__n == 1 && __it._M_iterator != __c->end() ) || + (__n == -1 && __it._M_iterator != __c->begin())); +} + +template +bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) { + typedef typename _Iterator::_Container_type __container_type; + __container_type* __c = __it._Get_container_ptr(); + if (__c == 0) return false; + ptrdiff_t __new_pos = (__it._M_iterator - __c->begin()) + __n; + return (__new_pos >= 0) && (__STATIC_CAST(typename __container_type::size_type, __new_pos) <= __c->size()); +} + + +template +struct _DBG_iter_base : public __owned_link { +public: + typedef typename _Container::value_type value_type; + typedef typename _Container::reference reference; + typedef typename _Container::pointer pointer; + typedef ptrdiff_t difference_type; + //private: + typedef typename _Container::iterator _Nonconst_iterator; + typedef typename _Container::const_iterator _Const_iterator; + typedef _Container _Container_type; + +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION + typedef typename iterator_traits<_Const_iterator>::iterator_category _Iterator_category; +#else + typedef typename _Container::_Iterator_category _Iterator_category; +#endif + typedef _Iterator_category iterator_category; + + _DBG_iter_base() : __owned_link(0) {} + _DBG_iter_base(const __owned_list* __c, const _Const_iterator& __it) : +#if defined(__HP_aCC) && (__HP_aCC < 60000) + __owned_link(__c), _M_iterator(*__REINTERPRET_CAST(const _Nonconst_iterator *, &__it)) {} +#else + __owned_link(__c), _M_iterator(*(const _Nonconst_iterator*)&__it) {} +#endif + _Container* _Get_container_ptr() const { + return (_Container*)__stl_debugger::_Get_container_ptr(this); + } + + void __increment(); + void __decrement(); + void __advance(ptrdiff_t __n); + +// protected: + _Nonconst_iterator _M_iterator; +}; + +template +inline void _DBG_iter_base<_Container>::__increment() { + _STLP_DEBUG_CHECK(_Incrementable(*this, 1, _Iterator_category())) + ++_M_iterator; +} + +template +inline void _DBG_iter_base<_Container>::__decrement() { + _STLP_DEBUG_CHECK(_Incrementable(*this, -1, _Iterator_category())) + _Decrement(_M_iterator, _Iterator_category()); +} + +template +inline void _DBG_iter_base<_Container>::__advance(ptrdiff_t __n) { + _STLP_DEBUG_CHECK(_Incrementable(*this, __n, _Iterator_category())) + _Advance(_M_iterator, __n, _Iterator_category()); +} + +template +ptrdiff_t operator-(const _DBG_iter_base<_Container>& __x, + const _DBG_iter_base<_Container>& __y ) { + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Iterator_category; + _STLP_DEBUG_CHECK(__check_same_owner(__x, __y)) + return _DBG_distance(__x._M_iterator,__y._M_iterator, _Iterator_category()); +} + +template +struct _DBG_iter_mid : public _DBG_iter_base<_Container> { + typedef _DBG_iter_mid<_Container, typename _Traits::_NonConstTraits> _Nonconst_self; + typedef typename _Container::iterator _Nonconst_iterator; + typedef typename _Container::const_iterator _Const_iterator; + + _DBG_iter_mid() {} + + explicit _DBG_iter_mid(const _Nonconst_self& __it) : + _DBG_iter_base<_Container>(__it) {} + + _DBG_iter_mid(const __owned_list* __c, const _Const_iterator& __it) : + _DBG_iter_base<_Container>(__c, __it) {} +}; + +template +struct _DBG_iter : public _DBG_iter_mid<_Container, _Traits> { + typedef _DBG_iter_base<_Container> _Base; +public: + typedef typename _Base::value_type value_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Traits::reference reference; + typedef typename _Traits::pointer pointer; + + typedef typename _Base::_Nonconst_iterator _Nonconst_iterator; + typedef typename _Base::_Const_iterator _Const_iterator; + +private: + typedef _DBG_iter<_Container, _Traits> _Self; + typedef _DBG_iter_mid<_Container, typename _Traits::_NonConstTraits> _Nonconst_mid; + +public: + +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION + typedef typename _Base::iterator_category iterator_category; +#endif + typedef typename _Base::_Iterator_category _Iterator_category; + +public: + _DBG_iter() {} + // boris : real type of iter would be nice + _DBG_iter(const __owned_list* __c, const _Const_iterator& __it) : + _DBG_iter_mid<_Container, _Traits>(__c, __it) {} + + // This allows conversions from iterator to const_iterator without being + // redundant with the copy constructor below. + _DBG_iter(const _Nonconst_mid& __rhs) : + _DBG_iter_mid<_Container, _Traits>(__rhs) {} + + _DBG_iter(const _Self& __rhs) : + _DBG_iter_mid<_Container, _Traits>(__rhs) {} + + // This allows conversions from iterator to const_iterator without being + // redundant with the copy assignment operator below. + _Self& operator=(const _Nonconst_mid& __rhs) { + (_Base&)*this = __rhs; + return *this; + } + + _Self& operator=(const _Self& __rhs) { + (_Base&)*this = __rhs; + return *this; + } + + reference operator*() const; + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + this->__increment(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + this->__increment(); + return __tmp; + } + _Self& operator--() { + this->__decrement(); + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + this->__decrement(); + return __tmp; + } + + _Self& operator+=(difference_type __n) { + this->__advance(__n); + return *this; + } + + _Self& operator-=(difference_type __n) { + this->__advance(-__n); + return *this; + } + _Self operator+(difference_type __n) const { + _Self __tmp(*this); + __tmp.__advance(__n); + return __tmp; + } + _Self operator-(difference_type __n) const { + _Self __tmp(*this); + __tmp.__advance(-__n); + return __tmp; + } + reference operator[](difference_type __n) const { return *(*this + __n); } +}; + +template +inline +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +_STLP_TYPENAME_ON_RETURN_TYPE _Traits::reference +#else +_STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter<_Container, _Traits>::reference +#endif +_DBG_iter<_Container, _Traits>::operator*() const { + _STLP_DEBUG_CHECK(_Dereferenceable(*this)) + _STLP_DEBUG_CHECK(_Traits::_Check(*this)) + return *this->_M_iterator; +} + +template +inline bool +operator==(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) { + _STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y)) + return __x._M_iterator == __y._M_iterator; +} + +template +inline bool +operator<(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) { + _STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y)) + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category; + return _CompareIt(__x._M_iterator , __y._M_iterator, _Category()); +} + +template +inline bool +operator>(const _DBG_iter_base<_Container>& __x, + const _DBG_iter_base<_Container>& __y) { + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category; + return _CompareIt(__y._M_iterator , __x._M_iterator, _Category()); +} + +template +inline bool +operator>=(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) { + _STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y)) + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category; + return !_CompareIt(__x._M_iterator , __y._M_iterator, _Category()); +} + +template +inline bool +operator<=(const _DBG_iter_base<_Container>& __x, + const _DBG_iter_base<_Container>& __y) { + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category; + return !_CompareIt(__y._M_iterator , __x._M_iterator, _Category()); +} + +template +inline bool +operator!=(const _DBG_iter_base<_Container>& __x, + const _DBG_iter_base<_Container>& __y) { + _STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y)) + return __x._M_iterator != __y._M_iterator; +} + +//------------------------------------------ + +template +inline _DBG_iter<_Container, _Traits> +operator+(ptrdiff_t __n, const _DBG_iter<_Container, _Traits>& __it) { + _DBG_iter<_Container, _Traits> __tmp(__it); + return __tmp += __n; +} + + +template +inline _Iterator _Non_Dbg_iter(_Iterator __it) +{ return __it; } + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template +inline typename _DBG_iter<_Container, _Traits>::_Nonconst_iterator +_Non_Dbg_iter(const _DBG_iter<_Container, _Traits>& __it) +{ return __it._M_iterator; } +#endif + +/* + * Helper classes to check iterator range or pointer validity + * at construction time. + */ +template +class __construct_checker { + typedef typename _Container::value_type value_type; +protected: + __construct_checker() {} + + __construct_checker(const value_type* __p) { + _STLP_VERBOSE_ASSERT((__p != 0), _StlMsg_INVALID_ARGUMENT) + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + __construct_checker(const _InputIter& __f, const _InputIter& __l) { + typedef typename _IsIntegral<_InputIter>::_Ret _Integral; + _M_check_dispatch(__f, __l, _Integral()); + } + + template + void _M_check_dispatch(_Integer , _Integer, const __true_type& /*IsIntegral*/) {} + + template + void _M_check_dispatch(const _InputIter& __f, const _InputIter& __l, const __false_type& /*IsIntegral*/) { + _STLP_DEBUG_CHECK(__check_range(__f,__l)) + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) + __construct_checker(const value_type* __f, const value_type* __l) { + _STLP_DEBUG_CHECK(__check_ptr_range(__f,__l)) + } + + typedef _DBG_iter_base<_Container> _IteType; + __construct_checker(const _IteType& __f, const _IteType& __l) { + _STLP_DEBUG_CHECK(__check_range(__f,__l)) + } +#endif +#if defined (__BORLANDC__) + ~__construct_checker(){} +#endif +}; + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +# if defined (_STLP_NESTED_TYPE_PARAM_BUG) ||\ + (defined (__SUNPRO_CC) && __SUNPRO_CC < 0x600) +# define _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS 1 +# endif + +_STLP_MOVE_TO_STD_NAMESPACE + +template +inline ptrdiff_t* +distance_type(const _STLP_PRIV _DBG_iter_base<_Container>&) { return (ptrdiff_t*) 0; } + +# if !defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +template +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_PRIV _DBG_iter_base<_Container>::value_type* +value_type(const _STLP_PRIV _DBG_iter_base<_Container>&) { + typedef _STLP_TYPENAME _STLP_PRIV _DBG_iter_base<_Container>::value_type _Val; + return (_Val*)0; +} + +template +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_PRIV _DBG_iter_base<_Container>::_Iterator_category +iterator_category(const _STLP_PRIV _DBG_iter_base<_Container>&) { + typedef _STLP_TYPENAME _STLP_PRIV _DBG_iter_base<_Container>::_Iterator_category _Category; + return _Category(); +} +# endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */ + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* INTERNAL_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_list.h b/sdk/tlibstdcxx/stlport/stl/debug/_list.h new file mode 100644 index 0000000000..c45e1e7860 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_list.h @@ -0,0 +1,495 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_DBG_LIST_H +#define _STLP_INTERNAL_DBG_LIST_H + +#ifndef _STLP_INTERNAL_ALGO_H +# include +#endif + +#ifndef _STLP_DBG_ITERATOR_H +# include +#endif + +#define _STLP_NON_DBG_LIST _STLP_PRIV _STLP_NON_DBG_NAME(list) <_Tp, _Alloc> + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +template +inline _Tp* +value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_LIST >&) +{ return (_Tp*)0; } +template +inline bidirectional_iterator_tag +iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_LIST >&) +{ return bidirectional_iterator_tag(); } +#endif + +template ) > +class list : +#if !defined (__DMC__) + private +#endif + _STLP_PRIV __construct_checker<_STLP_NON_DBG_LIST > +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + , public __stlport_class > +#endif +{ + typedef _STLP_NON_DBG_LIST _Base; + typedef list<_Tp, _Alloc> _Self; + typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_LIST > _ConstructCheck; + +public: + __IMPORT_CONTAINER_TYPEDEFS(_Base) + +public: + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits > > iterator; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits > > const_iterator; + + _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; + +private: + _Base _M_non_dbg_impl; + _STLP_PRIV __owned_list _M_iter_list; + + void _Invalidate_iterator(const iterator& __it) + { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); } + void _Invalidate_iterators(const iterator& __first, const iterator& __last) + { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); } + + typedef typename _Base::iterator _Base_iterator; + +public: + explicit list(const allocator_type& __a = allocator_type()) : + _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit list(size_type __n, const _Tp& __x = _Tp(), +#else + list(size_type __n, const _Tp& __x, +#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/ + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit list(size_type __n) + : _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {} +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + list(__move_source<_Self> src) + : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)), + _M_iter_list(&_M_non_dbg_impl) { +# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + src.get()._M_iter_list._Invalidate_all(); +# else + src.get()._M_iter_list._Set_owner(_M_iter_list); +# endif + } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a), + _M_iter_list(&_M_non_dbg_impl) {} +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + list(_InputIterator __first, _InputIterator __last) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)), + _M_iter_list(&_M_non_dbg_impl) {} +# endif +#else + + list(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(__first, __last, __a), + _M_iter_list(&_M_non_dbg_impl) {} + list(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a), + _M_iter_list(&_M_non_dbg_impl) {} + +#endif + + list(const _Self& __x) : + _ConstructCheck(__x), + _M_non_dbg_impl(__x._M_non_dbg_impl) , _M_iter_list(&_M_non_dbg_impl) {} + + _Self& operator=(const _Self& __x) { + if (this != &__x) { + //Should not invalidate end iterator + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl = __x._M_non_dbg_impl; + } + return *this; + } + + allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } + + iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + + iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + size_type size() const { return _M_non_dbg_impl.size(); } + size_type max_size() const { return _M_non_dbg_impl.max_size(); } + bool empty() const { return _M_non_dbg_impl.empty(); } + + // those are here to enforce checking + reference front() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *begin(); + } + const_reference front() const { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *begin(); + } + reference back() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *(--end()); + } + const_reference back() const { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *(--end()); + } + + void swap(_Self& __x) { + _M_iter_list._Swap_owners(__x._M_iter_list); + _M_non_dbg_impl.swap(__x._M_non_dbg_impl); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const _Tp& __x = _Tp()) { +#else + iterator insert(iterator __pos, const _Tp& __x) { +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + return iterator(&_M_iter_list,_M_non_dbg_impl.insert(__pos._M_iterator, __x) ); + } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.insert(__pos._M_iterator, + _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) + void insert(iterator __pos, const _Tp* __first, const _Tp* __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) + _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) + void insert(iterator __pos, + const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) +# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first)) +# endif + _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + } + void insert(iterator __pos, + iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) +# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first)) +# endif + _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + } +#endif + + void insert(iterator __pos, size_type __n, const _Tp& __x) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x); + } + + void push_back(const_reference __x) { _M_non_dbg_impl.push_back(__x); } + void pop_back() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + _Invalidate_iterator(end()); + _M_non_dbg_impl.pop_back(); + } + + void push_front(const_reference __x) { _M_non_dbg_impl.push_front(__x); } + void pop_front() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + _Invalidate_iterator(begin()); + _M_non_dbg_impl.pop_front(); + } + + iterator erase(iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _Invalidate_iterator(__pos); + return iterator(&_M_iter_list,_M_non_dbg_impl.erase(__pos._M_iterator)); + } + iterator erase(iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + _Invalidate_iterators(__first, __last); + return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator)); + } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const _Tp& __x = _Tp()) { +#else + void resize(size_type __new_size, const _Tp& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + _Base_iterator __i = _M_non_dbg_impl.begin(); + size_type __len = 0; + for ( ; __i != _M_non_dbg_impl.end() && __len < __new_size; ++__i, ++__len); + + if (__len == __new_size) + erase(iterator(&_M_iter_list, __i), end()); + else // __i == end() + _M_non_dbg_impl.insert(_M_non_dbg_impl.end(), __new_size - __len, __x); + } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + _Invalidate_iterators(begin(), end()); + } +#else + void assign(const _Tp* __first, const _Tp* __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) + _M_non_dbg_impl.assign(__first, __last); + _Invalidate_iterators(begin(), end()); + } + + void assign(iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator); + _Invalidate_iterators(begin(), end()); + } + + void assign(const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator); + _Invalidate_iterators(begin(), end()); + } +#endif + + void assign(size_type __n, const _Tp& __val) { + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.assign(__n, __val); + } + + void remove(const _Tp& __x) { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + while (__first != __last) { + _Base_iterator __next = __first; + ++__next; + if (__x == *__first) { + _Invalidate_iterator(iterator(&_M_iter_list, __first)); + _M_non_dbg_impl.erase(__first); + } + __first = __next; + } + } + + void clear() { + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.clear(); + } + +public: + void splice(iterator __pos, _Self& __x) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl); +#if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL) + if (get_allocator() == __x.get_allocator()) + __x._M_iter_list._Set_owner(_M_iter_list); + else +#endif + // Std: 23.2.2.4:4 + // end iterator is not invalidated: + __x._Invalidate_iterators(__x.begin(), __x.end()); + } + + void splice(iterator __pos, _Self& __x, iterator __i) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__i)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&(__x._M_iter_list),__i)) + _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __i._M_iterator); +#if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL) + if (get_allocator() == __x.get_allocator()) + _STLP_PRIV __change_ite_owner(__i, &_M_iter_list); + else +#endif + // Std: 23.2.2.4:7 + __x._Invalidate_iterator(__i); + } + + void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, __x.begin(), __x.end())) + _STLP_DEBUG_CHECK(this == &__x ? !_STLP_PRIV __check_range(__pos, __first, __last) : true) +#if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL) + if (this->get_allocator() == __x.get_allocator()) + _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list); + else +#endif + // Std: 23.2.2.4:12 + __x._Invalidate_iterators(__first, __last); + _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __first._M_iterator, __last._M_iterator); + } + + void merge(_Self& __x) { +#if !defined (_STLP_NO_EXTENSIONS) + _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(begin()._M_iterator, end()._M_iterator)) + _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator)) +#endif + _M_non_dbg_impl.merge(__x._M_non_dbg_impl); + if (this->get_allocator() == __x.get_allocator()) { + __x._M_iter_list._Set_owner(_M_iter_list); + } + else { + __x._Invalidate_iterators(__x.begin(), __x.end()); + } + } + void reverse() { + _M_non_dbg_impl.reverse(); + } + void unique() { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + if (__first == __last) return; + _Base_iterator __next = __first; + while (++__next != __last) { + if (*__first == *__next) { + _Invalidate_iterator(iterator(&_M_iter_list, __next)); + _M_non_dbg_impl.erase(__next); + } + else + __first = __next; + __next = __first; + } + } + void sort() { + _M_non_dbg_impl.sort(); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void remove_if(_Predicate __pred) { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + while (__first != __last) { + _Base_iterator __next = __first; + ++__next; + if (__pred(*__first)) { + _Invalidate_iterator(iterator(&_M_iter_list, __first)); + _M_non_dbg_impl.erase(__first); + } + __first = __next; + } + } + + template + void unique(_BinaryPredicate __binary_pred) { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + if (__first == __last) return; + _Base_iterator __next = __first; + while (++__next != __last) { + if (__binary_pred(*__first, *__next)) { + _Invalidate_iterator(iterator(&_M_iter_list, __next)); + _M_non_dbg_impl.erase(__next); + } + else + __first = __next; + __next = __first; + } + } + + template + void merge(_Self& __x, _StrictWeakOrdering __comp) { +#if !defined (_STLP_NO_EXTENSIONS) + _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end(), __comp)) + _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __comp)) +#endif + _M_non_dbg_impl.merge(__x._M_non_dbg_impl, __comp); + if (this->get_allocator() == __x.get_allocator()) { + __x._M_iter_list._Set_owner(_M_iter_list); + } + else { + __x._Invalidate_iterators(__x.begin(), __x.end()); + } + } + + template + void sort(_StrictWeakOrdering __comp) { + _M_non_dbg_impl.sort(__comp); + } +#endif +}; + + +_STLP_END_NAMESPACE + +#undef _STLP_NON_DBG_LIST + +#endif /* _STLP_INTERNAL_LIST_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_slist.h b/sdk/tlibstdcxx/stlport/stl/debug/_slist.h new file mode 100644 index 0000000000..2eeaf36733 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_slist.h @@ -0,0 +1,613 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_DBG_SLIST_H +#define _STLP_INTERNAL_DBG_SLIST_H + +#ifndef _STLP_DBG_ITERATOR_H +# include +#endif + +#define _STLP_NON_DBG_SLIST _STLP_PRIV _STLP_NON_DBG_NAME(slist) <_Tp, _Alloc> + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +template +inline _Tp* +value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&) +{ return (_Tp*)0; } + +template +inline forward_iterator_tag +iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&) +{ return forward_iterator_tag(); } +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* + * slist special debug traits version. + */ +template +struct _SlistDbgTraits : _Traits { + typedef _SlistDbgTraits _ConstTraits; + typedef _SlistDbgTraits _NonConstTraits; + + /* + * We don't want the before_begin iterator to return false at _Dereferenceable + * call to do not break the current debug framework but calling * operator should + * fail. + */ + template + static bool _Check(const _Iterator& __it) + { return !(__it._M_iterator == (__it._Get_container_ptr())->before_begin()); } +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +template ) > +class slist : +#if !defined (__DMC__) + private +#endif + _STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST > +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + , public __stlport_class > +#endif +{ +private: + typedef _STLP_NON_DBG_SLIST _Base; + typedef slist<_Tp,_Alloc> _Self; + typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST > _ConstructCheck; + +public: + + __IMPORT_CONTAINER_TYPEDEFS(_Base) + + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Nonconst_traits > > iterator; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Const_traits > > const_iterator; + + allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } +private: + _Base _M_non_dbg_impl; + _STLP_PRIV __owned_list _M_iter_list; + + void _Invalidate_iterator(const iterator& __it) + { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); } + void _Invalidate_iterators(const iterator& __first, const iterator& __last) + { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); } + + typedef typename _Base::iterator _Base_iterator; + +public: + explicit slist(const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__a) , _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit slist(size_type __n, const value_type& __x = _Tp(), +#else + slist(size_type __n, const value_type& __x, +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit slist(size_type __n) : _M_non_dbg_impl(__n) , _M_iter_list(&_M_non_dbg_impl) {} +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + slist(__move_source<_Self> src) + : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)), + _M_iter_list(&_M_non_dbg_impl) { +# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + src.get()._M_iter_list._Invalidate_all(); +# else + src.get()._M_iter_list._Set_owner(_M_iter_list); +# endif + } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + // We don't need any dispatching tricks here, because _M_insert_after_range + // already does them. + template + slist(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a), + _M_iter_list(&_M_non_dbg_impl) {} +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + slist(_InputIterator __first, _InputIterator __last) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)), + _M_iter_list(&_M_non_dbg_impl) {} +# endif +#else + + slist(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(__first, __last, __a), + _M_iter_list(&_M_non_dbg_impl) {} + + slist(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type() ) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a), + _M_iter_list(&_M_non_dbg_impl) {} +#endif + + slist(const _Self& __x) : + _ConstructCheck(__x), + _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {} + + _Self& operator= (const _Self& __x) { + if (this != &__x) { + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl = __x._M_non_dbg_impl; + } + return *this; + } + + ~slist() {} + + void assign(size_type __n, const value_type& __val) { + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.assign(__n, __val); + } + + iterator before_begin() + { return iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); } + const_iterator before_begin() const + { return const_iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); } + + iterator begin() + { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + const_iterator begin() const + { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin());} + + iterator end() + { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + const_iterator end() const + { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + + bool empty() const { return _M_non_dbg_impl.empty(); } + size_type size() const { return _M_non_dbg_impl.size(); } + size_type max_size() const { return _M_non_dbg_impl.max_size(); } + + void swap(_Self& __x) { + _M_iter_list._Swap_owners(__x._M_iter_list); + _M_non_dbg_impl.swap(__x._M_non_dbg_impl); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + reference front() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return _M_non_dbg_impl.front(); + } + const_reference front() const { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return _M_non_dbg_impl.front(); + } + void push_front(const_reference __x) { _M_non_dbg_impl.push_front(__x); } + void pop_front() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + _M_non_dbg_impl.pop_front(); + } + iterator previous(const_iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + return iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator)); + } + const_iterator previous(const_iterator __pos) const { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + return const_iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator)); + } + +public: + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert_after(iterator __pos, const value_type& __x = _Tp()) { +#else + iterator insert_after(iterator __pos, const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + return iterator(&_M_iter_list,_M_non_dbg_impl.insert_after(__pos._M_iterator, __x)); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert_after(iterator __pos) { + return insert_after(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); + } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void insert_after(iterator __pos, size_type __n, const value_type& __x) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _M_non_dbg_impl.insert_after(__pos._M_iterator, __n, __x); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } +#else + void assign(const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator); + } + void assign(const value_type *__first, const value_type *__last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.assign(__first, __last); + } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert_after(iterator __pos, _InIter __first, _InIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.insert_after(__pos._M_iterator, + _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } + + template + void insert(iterator __pos, _InIter __first, _InIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.insert(__pos._M_iterator, + _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } +#else + void insert_after(iterator __pos, + const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.insert_after(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + } + void insert_after(iterator __pos, + const value_type* __first, const value_type* __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) + _M_non_dbg_impl.insert_after(__pos._M_iterator, __first, __last); + } + + void insert(iterator __pos, const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + } + void insert(iterator __pos, const value_type* __first, + const value_type* __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) + _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last); + } +#endif + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos, const value_type& __x = _Tp()) { +#else + iterator insert(iterator __pos, const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x)); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos) { + return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); + } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void insert(iterator __pos, size_type __n, const value_type& __x) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x); + } + +public: + iterator erase_after(iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + iterator __tmp = __pos; ++__tmp; + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp)) + _Invalidate_iterator(__tmp); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__pos._M_iterator)); + } + iterator erase_after(iterator __before_first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __last, begin(), end())) + iterator __tmp = __before_first; ++__tmp; + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp)) + _Invalidate_iterators(__tmp, __last); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__before_first._M_iterator, __last._M_iterator)); + } + + iterator erase(iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_VERBOSE_ASSERT(__pos._M_iterator != _M_non_dbg_impl.before_begin(), _StlMsg_INVALID_ARGUMENT) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _Invalidate_iterator(__pos); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator)); + } + iterator erase(iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + _Invalidate_iterators(__first, __last); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator)); + } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const value_type& __x = _Tp()) { +#else + void resize(size_type __new_size, const value_type& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + _M_non_dbg_impl.resize(__new_size, __x); + } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void clear() { + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.clear(); + } + +public: + // Removes all of the elements from the list __x to *this, inserting + // them immediately after __pos. __x must not be *this. Complexity: + // linear in __x.size(). + void splice_after(iterator __pos, _Self& __x) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT) + _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl); + if (get_allocator() == __x.get_allocator()) { + __x._M_iter_list._Set_owner(_M_iter_list); + } + else { + __x._Invalidate_iterators(__x.begin(), __x.end()); + } + } + + // Moves the element that follows __prev to *this, inserting it immediately + // after __pos. This is constant time. + void splice_after(iterator __pos, _Self& __x, iterator __prev) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__prev)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __prev)) + iterator __elem = __prev; ++__elem; + _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl, __prev._M_iterator); + if (get_allocator() == __x.get_allocator()) { + _STLP_PRIV __change_ite_owner(__elem, &_M_iter_list); + } + else { + __x._Invalidate_iterator(__elem); + } + } + + // Moves the range [__before_first + 1, __before_last + 1) to *this, + // inserting it immediately after __pos. This is constant time. + void splice_after(iterator __pos, _Self& __x, + iterator __before_first, iterator __before_last) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __before_last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __before_first)) + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first)) + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_last)) + iterator __first = __before_first; ++__first; + iterator __last = __before_last; ++__last; + if (get_allocator() == __x.get_allocator()) { + _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list); + } + else { + __x._Invalidate_iterators(__first, __last); + } + _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl, + __before_first._M_iterator, __before_last._M_iterator); + } + + void splice(iterator __pos, _Self& __x) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + _STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT) + _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl); + if (get_allocator() == __x.get_allocator()) { + __x._M_iter_list._Set_owner(_M_iter_list); + } + else { + __x._Invalidate_iterators(__x.begin(), __x.end()); + } + } + + void splice(iterator __pos, _Self& __x, iterator __i) { + //__pos should be owned by *this and not be the before_begin iterator + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + //__i should be dereferenceable, not before_begin and be owned by __x + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__i)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list ,__i)) + _STLP_VERBOSE_ASSERT(!(__i == __x.before_begin()), _StlMsg_INVALID_ARGUMENT) + if (get_allocator() == __x.get_allocator()) { + _STLP_PRIV __change_ite_owner(__i, &_M_iter_list); + } + else { + __x._Invalidate_iterator(__i); + } + _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __i._M_iterator); + } + + void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT) + //_STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, __x.begin(), __x.end())) + if (get_allocator() == __x.get_allocator()) { + _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list); + } + else { + __x._Invalidate_iterators(__first, __last); + } + _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, + __first._M_iterator, __last._M_iterator); + } + + void reverse() + { _M_non_dbg_impl.reverse(); } + + void remove(const value_type& __val) { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + while (__first != __last) { + _Base_iterator __next = __first; + ++__next; + if (__val == *__first) { + _Invalidate_iterator(iterator(&_M_iter_list, __first)); + _M_non_dbg_impl.erase(__first); + } + __first = __next; + } + } + void unique() { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + if (__first == __last) return; + _Base_iterator __next = __first; + while (++__next != __last) { + if (*__first == *__next) { + _Invalidate_iterator(iterator(&_M_iter_list, __next)); + _M_non_dbg_impl.erase(__next); + } + else + __first = __next; + __next = __first; + } + } + void merge(_Self& __x) { + _STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT) +#if !defined (_STLP_NO_EXTENSIONS) + /* comments below due to bug in GCC compilers: ones eat all memory and die if see + * something like namespace_name::func_name() - ptr + */ + _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end())) + _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator)) +#endif + _M_non_dbg_impl.merge(__x._M_non_dbg_impl); + if (get_allocator() == __x.get_allocator()) { + __x._M_iter_list._Set_owner(_M_iter_list); + } + else { + __x._Invalidate_iterators(__x.begin(), __x.end()); + } + } + void sort() { + _M_non_dbg_impl.sort(); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void remove_if(_Predicate __pred) { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + while (__first != __last) { + _Base_iterator __next = __first; + ++__next; + if (__pred(*__first)) { + _Invalidate_iterator(iterator(&_M_iter_list, __first)); + _M_non_dbg_impl.erase(__first); + } + __first = __next; + } + } + + template + void unique(_BinaryPredicate __pred) { + _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end(); + if (__first == __last) return; + _Base_iterator __next = __first; + while (++__next != __last) { + if (__binary_pred(*__first, *__next)) { + _Invalidate_iterator(iterator(&_M_iter_list, __next)); + _M_non_dbg_impl.erase(__next); + } + else + __first = __next; + __next = __first; + } + } + + template + void merge(_Self& __x, _StrictWeakOrdering __ord) { + _STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT) +#if !defined (_STLP_NO_EXTENSIONS) + /* comments below due to bug in GCC compilers: ones eat all memory and die if see + * something like namespace_name::func_name() - ptr + */ + _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end(), __ord)) + _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __ord)) +#endif + _M_non_dbg_impl.merge(__x._M_non_dbg_impl, __ord); + if (get_allocator() == __x.get_allocator()) { + __x._M_iter_list._Set_owner(_M_iter_list); + } + else { + __x._Invalidate_iterators(__x.begin(), __x.end()); + } + } + + template + void sort(_StrictWeakOrdering __comp) + { _M_non_dbg_impl.sort(__comp); } +#endif +}; + +_STLP_END_NAMESPACE + +#undef _STLP_NON_DBG_SLIST + +#endif /* _STLP_INTERNAL_DBG_SLIST_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_string.h b/sdk/tlibstdcxx/stlport/stl/debug/_string.h new file mode 100644 index 0000000000..49f7ab2258 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_string.h @@ -0,0 +1,828 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#ifndef _STLP_DBG_STRING_H +#define _STLP_DBG_STRING_H + +#ifndef _STLP_DBG_ITERATOR_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#define _STLP_NON_DBG_STRING_NAME _STLP_NON_DBG_NAME(str) +#define _STLP_NON_DBG_STRING _STLP_PRIV _STLP_NON_DBG_STRING_NAME <_CharT, _Traits, _Alloc> + +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +template +inline _CharT* +value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&) +{ return (_CharT*)0; } +template +inline random_access_iterator_tag +iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&) +{ return random_access_iterator_tag(); } +#endif + +template +class basic_string : +#if !defined (__DMC__) + private +#else + public +#endif + _STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING > +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string) + , public __stlport_class > +#endif +{ +protected: + typedef _STLP_NON_DBG_STRING _Base; + typedef basic_string<_CharT, _Traits, _Alloc> _Self; + typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING > _ConstructCheck; + typedef typename _IsPOD<_CharT>::_Type _Char_Is_POD; + +public: + __IMPORT_CONTAINER_TYPEDEFS(_Base) + typedef typename _Base::traits_type traits_type; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits > > iterator; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits > > const_iterator; + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +public: // Constructor, destructor, assignment. + typedef typename _Base::_Reserve_t _Reserve_t; + +private: + _Base _M_non_dbg_impl; + _STLP_PRIV __owned_list _M_iter_list; + + void _Invalidate_all() + { _M_iter_list._Invalidate_all(); } + void _Compare_Capacity (size_type __old_capacity) { + if (this->capacity() > __old_capacity) { + _Invalidate_all(); + } + } + void _Invalidate_iterator(const iterator& __it) + { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); } + void _Invalidate_iterators(const iterator& __f, const iterator& __l) + { _STLP_PRIV __invalidate_range(&_M_iter_list, __f, __l); } + +public: +#include + + allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } + + explicit basic_string(const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {} + + basic_string(_Reserve_t __r, size_t __n, + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__r, __n, __a), _M_iter_list(&_M_non_dbg_impl) {} + + basic_string(const _Self& __s) + : _ConstructCheck(__s), + _M_non_dbg_impl(__s._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {} + + basic_string(const _Self& __s, size_type __pos, size_type __n = npos, + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__s._M_non_dbg_impl, __pos, __n, __a), + _M_iter_list(&_M_non_dbg_impl) {} + + basic_string(const _CharT* __s, size_type __n, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__s), _M_non_dbg_impl(__s, __n, __a), + _M_iter_list(&_M_non_dbg_impl) {} + + basic_string(const _CharT* __s, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__s), + _M_non_dbg_impl(__s, __a), _M_iter_list(&_M_non_dbg_impl) {} + + basic_string(size_type __n, _CharT __c, + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__n, __c, __a), _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + basic_string(__move_source<_Self> src) + : _M_non_dbg_impl(__move_source<_Base >(src.get()._M_non_dbg_impl)), + _M_iter_list(&_M_non_dbg_impl) { +# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + src.get()._M_iter_list._Invalidate_all(); +# else + src.get()._M_iter_list._Set_owner(_M_iter_list); +# endif + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) + basic_string(const _CharT* __f, const _CharT* __l, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__f, __l), + _M_non_dbg_impl(__f, __l, __a), _M_iter_list(&_M_non_dbg_impl) { + } + basic_string(const_iterator __f, const_iterator __l, + const allocator_type & __a = allocator_type()) + : _ConstructCheck(__f, __l), + _M_non_dbg_impl(__f._M_iterator, __l._M_iterator, __a), _M_iter_list(&_M_non_dbg_impl) { + } +#else + template + basic_string(_InputIterator __f, _InputIterator __l, + const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL) + : _ConstructCheck(__f, __l), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l), __a), + _M_iter_list(&_M_non_dbg_impl) {} +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + basic_string(_InputIterator __f, _InputIterator __l) + : _ConstructCheck(__f, __l), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)), + _M_iter_list(&_M_non_dbg_impl) {} +# endif +#endif + +private: + // constructor from non-debug version for substr + basic_string (const _Base& __x) + : _M_non_dbg_impl(__x), _M_iter_list(&_M_non_dbg_impl) {} + +public: + _Self& operator=(const _Self& __s) { + if (this != &__s) { + assign(__s); + } + return *this; + } + + _Self& operator=(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return assign(__s); + } + + _Self& operator=(_CharT __c) { + return assign(1, __c); + } + + // Iterators. + iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + // Size, capacity, etc. + size_type size() const { return _M_non_dbg_impl.size(); } + size_type length() const { return _M_non_dbg_impl.length(); } + size_t max_size() const { return _M_non_dbg_impl.max_size(); } + + void resize(size_type __n, _CharT __c) { + if (__n > capacity()) + _Invalidate_all(); + else if (__n < size()) + _Invalidate_iterators(begin() + __n, end()); + _M_non_dbg_impl.resize(__n, __c); + } + void resize(size_type __n) { resize(__n, _STLP_DEFAULT_CONSTRUCTED(_CharT)); } + size_type capacity() const { return _M_non_dbg_impl.capacity(); } + + void reserve(size_type __s = 0) { + if (__s > capacity()) _Invalidate_all(); + _M_non_dbg_impl.reserve(__s); + } + + void clear() { + _Invalidate_all(); + _M_non_dbg_impl.clear(); + } + + bool empty() const { return _M_non_dbg_impl.empty(); } + + const_reference operator[](size_type __n) const { + _STLP_VERBOSE_ASSERT(__n <= this->size(), _StlMsg_OUT_OF_BOUNDS); + return _M_non_dbg_impl[__n]; + } + + reference operator[](size_type __n) { + _STLP_VERBOSE_ASSERT(__n < this->size(), _StlMsg_OUT_OF_BOUNDS) + return _M_non_dbg_impl[__n]; + } + + const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); } + reference at(size_type __n) { return _M_non_dbg_impl.at(__n); } + + // Append, operator+=, push_back. + _Self& operator+=(const _Self& __s) { return append(__s); } + _Self& operator+=(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return append(__s); + } + _Self& operator+=(_CharT __c) { return append(1, __c); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + _Self& append(_InputIter __first, _InputIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.append(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + _Compare_Capacity(__old_capacity); + return *this; + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || \ + !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS) + _Self& append(const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.append(__f, __l); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& append(const_iterator __f, const_iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.append(__f._M_iterator, __l._M_iterator); + _Compare_Capacity(__old_capacity); + return *this; + } +#endif + + _Self& append(const _Self& __s) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.append(__s._M_non_dbg_impl); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& append(const _Self& __s, size_type __pos, size_type __n) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.append(__s._M_non_dbg_impl, __pos, __n); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& append(const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.append(__s, __n); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& append(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.append(__s); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& append(size_type __n, _CharT __c) { + size_type __old_capacity = this->capacity(); + _M_non_dbg_impl.append(__n, __c); + _Compare_Capacity(__old_capacity); + return *this; + } + + void push_back(_CharT __c) { + size_type __old_capacity = this->capacity(); + _M_non_dbg_impl.push_back(__c); + _Compare_Capacity(__old_capacity); + } + + void pop_back() { + _Invalidate_iterator(this->end()); + _M_non_dbg_impl.pop_back(); + } + + // Assign + _Self& assign(const _Self& __s) { + _Invalidate_all(); + _M_non_dbg_impl.assign(__s._M_non_dbg_impl); + return *this; + } + + _Self& assign(const _Self& __s, size_type __pos, size_type __n) { + if (__pos < __s.size()) { + _Invalidate_all(); + } + _M_non_dbg_impl.assign(__s._M_non_dbg_impl, __pos, __n); + return *this; + } + + _Self& assign(const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + _Invalidate_all(); + _M_non_dbg_impl.assign(__s, __s + __n); + return *this; + } + + _Self& assign(const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + _Invalidate_all(); + _M_non_dbg_impl.assign(__s); + return *this; + } + + _Self& assign(size_type __n, _CharT __c) { + _Invalidate_all(); + _M_non_dbg_impl.assign(__n, __c); + return *this; + } + +#if defined(_STLP_MEMBER_TEMPLATES) + template + inline _Self& assign(_InputIter __first, _InputIter __last) { + _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _Invalidate_all(); + _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + return *this; + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || \ + !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS) + _Self& assign(const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l)) + _Invalidate_all(); + _M_non_dbg_impl.assign(__f, __l); + return *this; + } + _Self& assign(const_iterator __f, const_iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + _Invalidate_all(); + _M_non_dbg_impl.assign(__f._M_iterator, __l._M_iterator); + return *this; + } +#endif + + // Insert + _Self& insert(size_type __pos, const _Self& __s) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& insert(size_type __pos, const _Self& __s, + size_type __beg, size_type __n) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl, __beg, __n); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& insert(size_type __pos, const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos, __s, __n); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& insert(size_type __pos, const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return insert(__pos, __s, _Traits::length(__s)); + } + + _Self& insert(size_type __pos, size_type __n, _CharT __c) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos, __n, __c); + _Compare_Capacity(__old_capacity); + return *this; + } + + iterator insert(iterator __p, _CharT __c) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p)) + size_type __old_capacity = capacity(); + typename _Base::iterator __ret = _M_non_dbg_impl.insert(__p._M_iterator, __c); + _Compare_Capacity(__old_capacity); + return iterator(&_M_iter_list, __ret); + } + + void insert(iterator __p, size_t __n, _CharT __c) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__p._M_iterator, __n, __c); + _Compare_Capacity(__old_capacity); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(iterator __p, _InputIter __first, _InputIter __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last)) + + size_type __old_capacity = this->capacity(); + _M_non_dbg_impl.insert(__p._M_iterator, + _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + _Compare_Capacity(__old_capacity); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) + void insert(iterator __p, const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f,__l)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__p._M_iterator, __f, __l); + _Compare_Capacity(__old_capacity); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) + // Those overloads are necessary to check self referencing correctly in non debug + // basic_string implementation + void insert(iterator __p, const_iterator __f, const_iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l)) +# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __f)) +# endif + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator); + _Compare_Capacity(__old_capacity); + } + void insert(iterator __p, iterator __f, iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l)) +# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __f)) +# endif + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator); + _Compare_Capacity(__old_capacity); + } +#endif + + // Erase. + _Self& erase(size_type __pos = 0, size_type __n = npos) { + if (__pos < size()) { + _Invalidate_iterators(begin() + __pos, end()); + } + _M_non_dbg_impl.erase(__pos, __n); + return *this; + } + iterator erase(iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos)) + _Invalidate_iterators(__pos, end()); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator)); + } + iterator erase(iterator __f, iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end())) + _Invalidate_iterators(__f, end()); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__f._M_iterator, __l._M_iterator)); + } + + // Substring. + _Self substr(size_type __pos = 0, size_type __n = npos) const + { return _M_non_dbg_impl.substr(__pos, __n); } + + // Replace. (Conceptually equivalent to erase followed by insert.) + _Self& replace(size_type __pos, size_type __n, const _Self& __s) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__pos, __n, __s._M_non_dbg_impl); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(size_type __pos1, size_type __n1, const _Self& __s, + size_type __pos2, size_type __n2) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__pos, __n1, __s, __n2); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__pos, __n1, __s); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) { + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__pos, __n1, __n2, __c); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(iterator __f, iterator __l, const _Self& __s) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end())) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s._M_non_dbg_impl); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(iterator __f, iterator __l, const _CharT* __s, size_type __n) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end())) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s, __n); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(iterator __f, iterator __l, const _CharT* __s) { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end())) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s); + _Compare_Capacity(__old_capacity); + return *this; + } + + _Self& replace(iterator __f, iterator __l, size_type __n, _CharT __c) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end())) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __n, __c); + _Compare_Capacity(__old_capacity); + return *this; + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + _Self& replace(iterator __first, iterator __last, + _InputIter __f, _InputIter __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, + _STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)); + _Compare_Capacity(__old_capacity); + return *this; + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) + _Self& replace(iterator __first, iterator __last, + const _CharT* __f, const _CharT* __l) { + _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f, __l); + _Compare_Capacity(__old_capacity); + return *this; + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) + _Self& replace(iterator __first, iterator __last, + const_iterator __f, const_iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, + __f._M_iterator, __l._M_iterator); + _Compare_Capacity(__old_capacity); + return *this; + } + _Self& replace(iterator __first, iterator __last, + iterator __f, iterator __l) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, + __f._M_iterator, __l._M_iterator); + _Compare_Capacity(__old_capacity); + return *this; + } +#endif + + // Other modifier member functions. + void swap(_Self& __s) { + _M_iter_list._Swap_owners(__s._M_iter_list); + _M_non_dbg_impl.swap(__s._M_non_dbg_impl); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + int compare(const _Self& __s) const + { return _M_non_dbg_impl.compare(__s._M_non_dbg_impl); } + int compare(size_type __pos, size_type __n, const _Self& __s) const + { return _M_non_dbg_impl.compare(__pos, __n, __s._M_non_dbg_impl); } + int compare(size_type __pos1, size_type __n1, const _Self& __s, + size_type __pos2, size_type __n2) const + { return _M_non_dbg_impl.compare(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2); } + int compare(const _CharT* __s) const { + _STLP_FIX_LITERAL_BUG(__s) + return _M_non_dbg_impl.compare(__s); + } + int compare(size_type __pos, size_type __n, const _CharT* __s) const { + _STLP_FIX_LITERAL_BUG(__s) + return _M_non_dbg_impl.compare(__pos, __n, __s); + } + int compare(size_type __pos1, size_type __n1, const _CharT* __s, + size_type __n2) const { + _STLP_FIX_LITERAL_BUG(__s) + return _M_non_dbg_impl.compare(__pos1, __n1, __s, __n2); + } + + // Helper functions for compare. + static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1, + const _CharT* __f2, const _CharT* __l2) + { return _Base::_M_compare(__f1, __l1, __f2, __l2); } + static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1, + const _CharT* __f2, const _CharT* __l2) + { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2, __l2); } + static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1, + const_iterator __f2, const_iterator __l2) + { return _Base::_M_compare(__f1, __l1, __f2._M_iterator, __l2._M_iterator); } + static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1, + const_iterator __f2, const_iterator __l2) + { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2._M_iterator, __l2._M_iterator); } + + const _CharT* c_str() const { return _M_non_dbg_impl.c_str(); } + const _CharT* data() const { return _M_non_dbg_impl.data(); } + + size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const + { return _M_non_dbg_impl.copy(__s, __n, __pos); } + + // find. + size_type find(const _Self& __s, size_type __pos = 0) const + { return _M_non_dbg_impl.find(__s._M_non_dbg_impl, __pos); } + size_type find(const _CharT* __s, size_type __pos = 0) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find(__s, __pos); + } + size_type find(const _CharT* __s, size_type __pos, size_type __n) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find(__s, __pos, __n); + } + // WIE: Versant schema compiler 5.2.2 ICE workaround + size_type find(_CharT __c) const { return find(__c, 0); } + size_type find(_CharT __c, size_type __pos /* = 0 */) const + { return _M_non_dbg_impl.find(__c, __pos); } + + // rfind. + size_type rfind(const _Self& __s, size_type __pos = npos) const + { return _M_non_dbg_impl.rfind(__s._M_non_dbg_impl, __pos); } + size_type rfind(const _CharT* __s, size_type __pos = npos) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.rfind(__s, __pos); + } + size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.rfind(__s, __pos, __n); + } + size_type rfind(_CharT __c, size_type __pos = npos) const + { return _M_non_dbg_impl.rfind(__c, __pos); } + + // find_first_of + size_type find_first_of(const _Self& __s, size_type __pos = 0) const + { return _M_non_dbg_impl.find_first_of(__s._M_non_dbg_impl, __pos); } + size_type find_first_of(const _CharT* __s, size_type __pos = 0) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_first_of(__s, __pos); + } + size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_first_of(__s, __pos, __n); + } + size_type find_first_of(_CharT __c, size_type __pos = 0) const + { return _M_non_dbg_impl.find_first_of(__c, __pos); } + + // find_last_of + size_type find_last_of(const _Self& __s, size_type __pos = npos) const + { return _M_non_dbg_impl.find_last_of(__s._M_non_dbg_impl, __pos); } + size_type find_last_of(const _CharT* __s, size_type __pos = npos) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_last_of(__s, __pos); + } + size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_last_of(__s, __pos, __n); + } + size_type find_last_of(_CharT __c, size_type __pos = npos) const + { return _M_non_dbg_impl.rfind(__c, __pos); } + + // find_first_not_of + size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const + { return _M_non_dbg_impl.find_first_not_of(__s._M_non_dbg_impl, __pos); } + size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_first_not_of(__s, __pos); + } + size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_first_not_of(__s, __pos, __n); + } + size_type find_first_not_of(_CharT __c, size_type __pos = 0) const + { return _M_non_dbg_impl.find_first_not_of(__c, __pos); } + + // find_last_not_of + size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const + { return _M_non_dbg_impl.find_last_not_of(__s._M_non_dbg_impl, __pos); } + size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_last_not_of(__s, __pos); + } + size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const { + _STLP_FIX_LITERAL_BUG(__s) + _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT) + return _M_non_dbg_impl.find_last_not_of(__s, __pos, __n); + } + size_type find_last_not_of(_CharT __c, size_type __pos = npos) const + { return _M_non_dbg_impl.find_last_not_of(__c, __pos); } + +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) +# include +#endif +}; + +// This is a hook to instantiate STLport exports in a designated DLL +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +_STLP_MOVE_TO_PRIV_NAMESPACE +_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME , allocator > >; +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_EXPORT_TEMPLATE_CLASS basic_string, allocator >; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_MOVE_TO_PRIV_NAMESPACE +_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME , allocator > >; +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_EXPORT_TEMPLATE_CLASS basic_string, allocator >; +# endif +#endif + +#undef _STLP_NON_DBG_STRING +#undef _STLP_NON_DBG_STRING_NAME + +#if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96) +template +const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0; +#endif + +#if defined (basic_string) +_STLP_MOVE_TO_STD_NAMESPACE +#undef basic_string +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_DBG_STRING */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_string_sum_methods.h b/sdk/tlibstdcxx/stlport/stl/debug/_string_sum_methods.h new file mode 100644 index 0000000000..3fca19484c --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_string_sum_methods.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * All the necessary methods used for template expressions with basic_string + * This file do not have to be macro guarded as it is only used in the _string.h + * file and it is a part of the basic_string definition. + */ + + template + basic_string(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s) + : _M_non_dbg_impl(_Reserve_t(), __s.size(), __s.get_allocator()), + _M_iter_list(&_M_non_dbg_impl) + { _M_append_sum(__s, _M_non_dbg_impl); } + + template + basic_string(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + size_type __pos, size_type __n = npos, + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(_Reserve_t(), (__pos <= __s.size()) ? ((min) (__n, __s.size() - __pos)) : 0, __a), + _M_iter_list(&_M_non_dbg_impl) { + size_type __size = __s.size(); + if (__pos > __size) + //This call will generate the necessary out of range exception: + _M_non_dbg_impl.at(0); + else + _M_append_sum_pos(__s, __pos, (min) (__n, __size - __pos), _M_non_dbg_impl); + } + +private: + _Base& _M_append_fast(_STLP_PRIV __char_wrapper<_CharT> __c, _Base &__str) + { return __str += __c.getValue(); } + _Base& _M_append_fast(_CharT const* __s, size_type __s_size, _Base &__str) + { return __str.append(__s, __s_size); } + _Base& _M_append_fast(_STLP_PRIV __cstr_wrapper<_CharT> const& __s, _Base &__str) + { return _M_append_fast(__s.c_str(), __s.size(), __str); } + _Base& _M_append_fast(_STLP_PRIV __bstr_wrapper<_CharT, _Traits, _Alloc> __s, _Base &__str) + { return _M_append_fast(__s.b_str(), __str); } + _Base& _M_append_fast(_Self const& __s, _Base &__str) + { return _M_append_fast(__s.data(), __s.size(), __str); } + _Base& _M_append_fast(_STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc> const&, _Base &__str) + { return __str; } + template + _Base& _M_append_fast(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, _Base &__str) + { return _M_append_fast(__s.getRhs(), _M_append_fast(__s.getLhs(), __str)); } + + _Base& _M_append_fast_pos(_STLP_PRIV __char_wrapper<_CharT> __c, _Base &__str, size_type /*__pos*/, size_type __n) { + if (__n == 0) + return __str; + return __str += __c.getValue(); + } + _Base& _M_append_fast_pos(_CharT const* __s, size_type __s_size, _Base &__str, + size_type __pos, size_type __n) + { return __str.append(__s + __pos, __s + __pos + (min)(__n, __s_size - __pos)); } + _Base& _M_append_fast_pos(_STLP_PRIV __cstr_wrapper<_CharT> const& __s, _Base &__str, + size_type __pos, size_type __n) + { return _M_append_fast_pos(__s.c_str(), __s.size(), __str, __pos, __n); } + _Base& _M_append_fast_pos(_STLP_PRIV __bstr_wrapper<_CharT, _Traits, _Alloc> __s, _Base &__str, + size_type __pos, size_type __n) + { return _M_append_fast_pos(__s.b_str(), __str, __pos, __n); } + _Base& _M_append_fast_pos(_Self const& __s, _Base &__str, size_type __pos, size_type __n) + { return _M_append_fast_pos(__s.data(), __s.size(), __str, __pos, __n); } + _Base& _M_append_fast_pos(_STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc> const&, _Base &__str, + size_type /*__pos*/, size_type /*__n*/) + { return __str; } + + template + _Base& _M_append_fast_pos(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + _Base &__str, size_type __pos, size_type __n) { + if (__n == 0) { + return __str; + } + size_type __lhs_size = __s.getLhs().size(); + if (__pos < __lhs_size) { + if (__n < (__lhs_size - __pos)) { + return _M_append_fast_pos(__s.getLhs(), __str, __pos, __n); + } else { + return _M_append_fast_pos(__s.getRhs(), _M_append_fast_pos(__s.getLhs(), __str, __pos, __n), + 0, __n - (__lhs_size - __pos)); + } + } else { + return _M_append_fast_pos(__s.getRhs(), __str, __pos - __lhs_size, __n); + } + } + + template + _Self& _M_append_sum (_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + _Base &__impl) { + _M_append_fast(__s, __impl); + return *this; + } + + template + _Self& _M_append_sum_pos (_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, + size_type __pos, size_type __n, _Base &__impl) { + _M_non_dbg_impl.reserve(_M_non_dbg_impl.size() + (min) (__s.size() - __pos, __n)); + _M_append_fast_pos(__s, __impl, __pos, __n); + return *this; + } diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_tree.h b/sdk/tlibstdcxx/stlport/stl/debug/_tree.h new file mode 100644 index 0000000000..a32eda2c52 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_tree.h @@ -0,0 +1,317 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_DBG_TREE_H +#define _STLP_INTERNAL_DBG_TREE_H + +#ifndef _STLP_DBG_ITERATOR_H +# include +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +class _DbgCompare { +public: + _DbgCompare() {} + _DbgCompare(const _Compare& __cmp) : _M_non_dbg_cmp(__cmp) {} + _DbgCompare(const _DbgCompare& __cmp) : _M_non_dbg_cmp(__cmp._M_non_dbg_cmp) {} + +#if !defined (_STLP_USE_CONTAINERS_EXTENSION) + bool operator () (const _Key& __lhs, const _Key& __rhs) const { +#else + template + bool operator () (const _Kp1& __lhs, const _Kp2& __rhs) const { +#endif + if (_M_non_dbg_cmp(__lhs, __rhs)) { + return true; + } + return false; + } + + _Compare non_dbg_key_comp() const { return _M_non_dbg_cmp; } +private: + _Compare _M_non_dbg_cmp; +}; + +#define _STLP_NON_DBG_TREE _STLP_PRIV _STLP_NON_DBG_NAME(Rb_tree) <_Key, _STLP_PRIV _DbgCompare<_Key, _Compare>, _Value, _KeyOfValue, _Traits, _Alloc> + +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +_STLP_MOVE_TO_STD_NAMESPACE +template +inline _Value* +value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_TREE >&) +{ return (_Value*)0; } +template +inline bidirectional_iterator_tag +iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_TREE >&) +{ return bidirectional_iterator_tag(); } +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template ) > +class _Rb_tree { + typedef _STLP_NON_DBG_TREE _Base; + typedef _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc> _Self; + _Base _M_non_dbg_impl; + _STLP_PRIV __owned_list _M_iter_list; + +public: + __IMPORT_CONTAINER_TYPEDEFS(_Base) + typedef typename _Base::key_type key_type; + + typedef typename _Traits::_NonConstTraits _NonConstIteTraits; + typedef typename _Traits::_ConstTraits _ConstIteTraits; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_NonConstIteTraits> > iterator; + typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_ConstIteTraits> > const_iterator; + + _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; + +private: + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + void _Invalidate_iterator(const iterator& __it) + { _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); } + void _Invalidate_iterators(const iterator& __first, const iterator& __last) + { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); } + + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_iterator _Base_const_iterator; + +public: + _Rb_tree() + : _M_non_dbg_impl(), _M_iter_list(&_M_non_dbg_impl) {} + _Rb_tree(const _Compare& __comp) + : _M_non_dbg_impl(__comp), _M_iter_list(&_M_non_dbg_impl) {} + _Rb_tree(const _Compare& __comp, const allocator_type& __a) + : _M_non_dbg_impl(__comp, __a), _M_iter_list(&_M_non_dbg_impl) {} + _Rb_tree(const _Self& __x) + : _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Rb_tree(__move_source<_Self> src): + _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)), + _M_iter_list(&_M_non_dbg_impl) { +# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + src.get()._M_iter_list._Invalidate_all(); +# else + src.get()._M_iter_list._Set_owner(_M_iter_list); +# endif + } +#endif + + ~_Rb_tree() {} + + _Self& operator=(const _Self& __x) { + if (this != &__x) { + //Should not invalidate end iterator: + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl = __x._M_non_dbg_impl; + } + return *this; + } + + allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } + _Compare key_comp() const { return _M_non_dbg_impl.key_comp().non_dbg_key_comp(); } + + iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + bool empty() const { return _M_non_dbg_impl.empty(); } + size_type size() const { return _M_non_dbg_impl.size(); } + size_type max_size() const { return _M_non_dbg_impl.max_size(); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { return _M_non_dbg_impl.count(__x); } + + void swap(_Self& __t) { + _M_non_dbg_impl.swap(__t._M_non_dbg_impl); + _M_iter_list._Swap_owners(__t._M_iter_list); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __k) + { return iterator(&_M_iter_list, _M_non_dbg_impl.find(__k)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __k) const + { return const_iterator(&_M_iter_list, _M_non_dbg_impl.find(__k)); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) + { return iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const + { return const_iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) + { return iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const + { return const_iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) { + return pair(iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)), + iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x))); + } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const { + return pair(const_iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)), + const_iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x))); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range_unique(const _KT& __x) { + _STLP_STD::pair<_Base_iterator, _Base_iterator> __p; + __p = _M_non_dbg_impl.equal_range_unique(__x); + return pair(iterator(&_M_iter_list, __p.first), iterator(&_M_iter_list, __p.second)); + } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range_unique(const _KT& __x) const { + _STLP_STD::pair<_Base_const_iterator, _Base_const_iterator> __p; + __p = _M_non_dbg_impl.equal_range_unique(__x); + return pair(const_iterator(&_M_iter_list, __p.first), + const_iterator(&_M_iter_list, __p.second)); + } + + pair insert_unique(const value_type& __x) { + _STLP_STD::pair<_Base_iterator, bool> __res = _M_non_dbg_impl.insert_unique(__x); + return pair(iterator(&_M_iter_list, __res.first), __res.second); + } + iterator insert_equal(const value_type& __x) + { return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__x)); } + + iterator insert_unique(iterator __pos, const value_type& __x) { + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) + return iterator(&_M_iter_list, _M_non_dbg_impl.insert_unique(__pos._M_iterator, __x)); + } + iterator insert_equal(iterator __pos, const value_type& __x) { + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos)) + return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__pos._M_iterator, __x)); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert_equal(_InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(__check_range(__first,__last)) + _M_non_dbg_impl.insert_equal(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } + template + void insert_unique(_InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(__check_range(__first,__last)) + _M_non_dbg_impl.insert_unique(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } +#else + void insert_unique(const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(__check_range(__first,__last)) + _M_non_dbg_impl.insert_unique(__first._M_iterator, __last._M_iterator); + } + void insert_unique(const value_type* __first, const value_type* __last) { + _STLP_DEBUG_CHECK(__check_ptr_range(__first,__last)) + _M_non_dbg_impl.insert_unique(__first, __last); + } + void insert_equal(const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(__check_range(__first,__last)) + _M_non_dbg_impl.insert_equal(__first._M_iterator, __last._M_iterator); + } + void insert_equal(const value_type* __first, const value_type* __last) { + _STLP_DEBUG_CHECK(__check_ptr_range(__first,__last)) + _M_non_dbg_impl.insert_equal(__first, __last); + } +#endif + + void erase(iterator __pos) { + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) + _STLP_DEBUG_CHECK(_Dereferenceable(__pos)) + _Invalidate_iterator(__pos); + _M_non_dbg_impl.erase(__pos._M_iterator); + } + size_type erase(const key_type& __x) { + pair __p = equal_range(__x); + size_type __n = _STLP_STD::distance(__p.first._M_iterator, __p.second._M_iterator); + _Invalidate_iterators(__p.first, __p.second); + _M_non_dbg_impl.erase(__p.first._M_iterator, __p.second._M_iterator); + return __n; + } + size_type erase_unique(const key_type& __x) { + _Base_iterator __i = _M_non_dbg_impl.find(__x); + if (__i != _M_non_dbg_impl.end()) { + _Invalidate_iterator(iterator(&_M_iter_list, __i)); + _M_non_dbg_impl.erase(__i); + return 1; + } + return 0; + } + + void erase(iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(__check_range(__first, __last, begin(), end())) + _Invalidate_iterators(__first, __last); + _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator); + } + void erase(const key_type* __first, const key_type* __last) { + while (__first != __last) erase(*__first++); + } + + void clear() { + //should not invalidate end: + _Invalidate_iterators(begin(), end()); + _M_non_dbg_impl.clear(); + } +}; + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#undef _STLP_NON_DBG_TREE + +#endif /* _STLP_INTERNAL_DBG_TREE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/debug/_vector.h b/sdk/tlibstdcxx/stlport/stl/debug/_vector.h new file mode 100644 index 0000000000..c5800e9627 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/debug/_vector.h @@ -0,0 +1,425 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_DBG_VECTOR_H +#define _STLP_INTERNAL_DBG_VECTOR_H + +#ifndef _STLP_DBG_ITERATOR_H +# include +#endif + +#define _STLP_NON_DBG_VECTOR _STLP_PRIV _STLP_NON_DBG_NAME(vector) <_Tp, _Alloc> + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) +template +inline _Tp* +value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_VECTOR >&) +{ return (_Tp*)0; } +template +inline random_access_iterator_tag +iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_VECTOR >&) +{ return random_access_iterator_tag(); } +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _Vector_const_traits; + +template +struct _Vector_nonconst_traits { + typedef _Nonconst_traits<_Tp> _BaseT; + typedef _Tp value_type; + typedef _Tp& reference; + typedef _Tp* pointer; + typedef _Vector_const_traits<_Tp, _NcIt> _ConstTraits; + typedef _Vector_nonconst_traits<_Tp, _NcIt> _NonConstTraits; +}; + +template +struct _Vector_const_traits { + typedef _Const_traits<_Tp> _BaseT; + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Vector_const_traits<_Tp, _NcIt> _ConstTraits; + typedef _Vector_nonconst_traits<_Tp, _NcIt> _NonConstTraits; +}; + +_STLP_TEMPLATE_NULL +struct _Vector_nonconst_traits { + typedef _Bit_iterator::value_type value_type; + typedef _Bit_iterator::reference reference; + typedef _Bit_iterator::pointer pointer; + typedef _Vector_const_traits _ConstTraits; + typedef _Vector_nonconst_traits _NonConstTraits; +}; + +_STLP_TEMPLATE_NULL +struct _Vector_const_traits { + typedef _Bit_const_iterator::value_type value_type; + typedef _Bit_const_iterator::reference reference; + typedef _Bit_const_iterator::pointer pointer; + typedef _Vector_const_traits _ConstTraits; + typedef _Vector_nonconst_traits _NonConstTraits; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +template ) > +class vector : +#if !defined (__DMC__) + private +#endif + _STLP_PRIV __construct_checker< _STLP_NON_DBG_VECTOR > +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + , public __stlport_class > +#endif +{ +private: + typedef _STLP_NON_DBG_VECTOR _Base; + typedef vector<_Tp, _Alloc> _Self; + typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_VECTOR > _ConstructCheck; + _Base _M_non_dbg_impl; + _STLP_PRIV __owned_list _M_iter_list; + +public: + __IMPORT_CONTAINER_TYPEDEFS(_Base) + + typedef _STLP_PRIV _DBG_iter<_Base, + _STLP_PRIV _DbgTraits<_STLP_PRIV _Vector_nonconst_traits > > iterator; + + typedef _STLP_PRIV _DBG_iter<_Base, + _STLP_PRIV _DbgTraits<_STLP_PRIV _Vector_const_traits > > const_iterator; + +private: + void _Invalidate_all() + { _M_iter_list._Invalidate_all(); } + void _Invalidate_iterator(const iterator& __it) + { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); } + void _Invalidate_iterators(const iterator& __first, const iterator& __last) + { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); } + + void _Check_Overflow(size_type __nb) { + if (size() + __nb > capacity()) + _Invalidate_all(); + } + void _Compare_Capacity (size_type __old_capacity) { + if (capacity() > __old_capacity) { + _Invalidate_all(); + } + } + +public: + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + + allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } + + iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } + iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + size_type size() const { return _M_non_dbg_impl.size(); } + size_type max_size() const { return _M_non_dbg_impl.max_size(); } + size_type capacity() const { return _M_non_dbg_impl.capacity(); } + bool empty() const { return _M_non_dbg_impl.empty(); } + + reference operator[](size_type __n) { + _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS) + return _M_non_dbg_impl[__n]; + } + + const_reference operator[](size_type __n) const { + _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS) + return _M_non_dbg_impl[__n]; + } + + reference at(size_type __n) { return _M_non_dbg_impl.at(__n); } + const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); } + + explicit vector(const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit vector(size_type __n, const _Tp& __x = _Tp(), +#else + vector(size_type __n, const _Tp& __x, +#endif + const allocator_type& __a = allocator_type()) + : _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit vector(size_type __n) + : _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {} +#endif + + vector(const _Self& __x) + : _ConstructCheck(__x), _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + vector(__move_source<_Self> src) + : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)), + _M_iter_list(&_M_non_dbg_impl) { +# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) + src.get()._M_iter_list._Invalidate_all(); +# else + src.get()._M_iter_list._Set_owner(_M_iter_list); +# endif + } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a), + _M_iter_list(&_M_non_dbg_impl) {} + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + vector(_InputIterator __first, _InputIterator __last) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)), + _M_iter_list(&_M_non_dbg_impl) {} +# endif +#else + vector(const _Tp* __first, const _Tp* __last, + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__first, __last), _M_non_dbg_impl(__first, __last, __a), + _M_iter_list(&_M_non_dbg_impl) {} + + // mysterious VC++ bug ? + vector(const_iterator __first, const_iterator __last , + const allocator_type& __a = allocator_type()) + : _ConstructCheck(__first, __last), + _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a), + _M_iter_list(&_M_non_dbg_impl) {} +#endif /* _STLP_MEMBER_TEMPLATES */ + + _Self& operator=(const _Self& __x) { + if (this != &__x) { + _Invalidate_all(); + _M_non_dbg_impl = __x._M_non_dbg_impl; + } + return *this; + } + + void reserve(size_type __n) { + if (capacity() < __n) + _Invalidate_all(); + _M_non_dbg_impl.reserve(__n); + } + + reference front() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *begin(); + } + const_reference front() const { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *begin(); + } + reference back() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *(--end()); + } + const_reference back() const { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + return *(--end()); + } + + void swap(_Self& __x) { + _M_iter_list._Swap_owners(__x._M_iter_list); + _M_non_dbg_impl.swap(__x._M_non_dbg_impl); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos, const _Tp& __x = _Tp()) { +#else + iterator insert(iterator __pos, const _Tp& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _Check_Overflow(1); + return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x)); + } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos) + { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if defined (_STLP_MEMBER_TEMPLATES) + // Check whether it's an integral type. If so, it's not an iterator. + template + void insert(iterator __pos, + _InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos._M_iterator, + _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + _Compare_Capacity(__old_capacity); + } +#endif +#if !defined (_STLP_MEMBER_TEMPLATES) + void insert (iterator __pos, + const value_type *__first, const value_type *__last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first,__last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last); + _Compare_Capacity(__old_capacity); + } +#endif + +#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) + void insert(iterator __pos, + const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + //Sequence requirements 23.1.1 Table 67: + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first)); + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + _Compare_Capacity(__old_capacity); + } + void insert(iterator __pos, + iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + //Sequence requirements 23.1.1 Table 67: + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first)); + size_type __old_capacity = capacity(); + _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); + _Compare_Capacity(__old_capacity); + } +#endif + + void insert (iterator __pos, size_type __n, const _Tp& __x){ + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _Check_Overflow(__n); + _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x); + } + + void pop_back() { + _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) + _Invalidate_iterator(end()); + _M_non_dbg_impl.pop_back(); + } + iterator erase(iterator __pos) { + _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) + _Invalidate_iterators(__pos, end()); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator)); + } + iterator erase(iterator __first, iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) + _Invalidate_iterators(__first, end()); + return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator)); + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void resize(size_type __new_size, const _Tp& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + if (__new_size > capacity()) { + _Invalidate_all(); + } + else if (__new_size < size()) { + _Invalidate_iterators(begin() + __new_size, end()); + } + _M_non_dbg_impl.resize(__new_size, __x); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last)) + _Invalidate_all(); + _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); + } +#else +private: + void _M_assign(const value_type *__first, const value_type *__last) { + _Invalidate_all(); + _M_non_dbg_impl.assign(__first, __last); + } +public: + void assign(const value_type *__first, const value_type *__last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first,__last)) + _M_assign(__first, __last); + } + + void assign(const_iterator __first, const_iterator __last) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last)) + _M_assign(__first._M_iterator, __last._M_iterator); + } +#endif + +public: + void assign(size_type __n, const _Tp& __val) { + _Invalidate_all(); + _M_non_dbg_impl.assign(__n, __val); + } + + void clear() { + _Invalidate_all(); + _M_non_dbg_impl.clear(); + } + void push_back(const _Tp& __x) { + _Check_Overflow(1); + _M_non_dbg_impl.push_back(__x); + } +}; + +_STLP_END_NAMESPACE + +#undef _STLP_NON_DBG_VECTOR + +#endif /* _STLP_DBG_VECTOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/msl_string.h b/sdk/tlibstdcxx/stlport/stl/msl_string.h new file mode 100644 index 0000000000..1fa4931469 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/msl_string.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1998 + * Mark of the Unicorn, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Mark of the Unicorn, Inc. makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +#if defined( _STLP_USE_MSIPL ) && !defined( _STLP_MSL_STRING_H_ ) +#define _STLP_MSL_STRING_H_ + +//# define char_traits __msl_char_traits +# define basic_string __msl_basic_string +# define b_str_ref __msl_b_str_ref +# define basic_istream __msl_basic_istream +# define basic_ostream __msl_basic_ostream +# define string __msl_string +# define wstring __msl_wstring +# define iterator_traits __msl_iterator_traits + +namespace std +{ + template class basic_istream; + template class basic_ostream; +} + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +#else +# include _STLP_NATIVE_HEADER(string) +#endif + +// # undef char_traits +# undef basic_string +# undef b_str_ref +# undef basic_istream +# undef basic_ostream +# undef string +# undef wstring +# undef iterator_traits + +#endif diff --git a/sdk/tlibstdcxx/stlport/stl/pointers/_deque.h b/sdk/tlibstdcxx/stlport/stl/pointers/_deque.h new file mode 100644 index 0000000000..f82a559bcb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/pointers/_deque.h @@ -0,0 +1,390 @@ +/* + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_SPECIALIZED_DEQUE_H +#define _STLP_SPECIALIZED_DEQUE_H + +#ifndef _STLP_POINTERS_SPEC_TOOLS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* + * struct helper to cast deque iterators: + */ +template +struct _DequeIteCast { + typedef _Deque_iterator<_ValueT, _Nonconst_traits<_ValueT> > iterator; + typedef _Deque_iterator<_ValueT, _Const_traits<_ValueT> > const_iterator; + typedef _Deque_iterator<_StorageT, _Nonconst_traits<_StorageT> > storage_iterator; + typedef _Deque_iterator<_StorageT, _Const_traits<_StorageT> > const_storage_iterator; + typedef _CastTraits<_StorageT, _ValueT> cast_traits; + + static iterator to_value_type_ite (storage_iterator const& __ite) { + iterator tmp; + tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur); + tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first); + tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last); + tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node); + return tmp; + } + static storage_iterator to_storage_type_ite (iterator const& __ite) { + storage_iterator tmp; + tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur); + tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first); + tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last); + tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node); + return tmp; + } + + static const_iterator to_value_type_cite (const_storage_iterator const& __ite) { + const_iterator tmp; + tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur); + tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first); + tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last); + tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node); + return tmp; + } + + static const_storage_iterator to_storage_type_cite (const_iterator const& __ite) { + const_storage_iterator tmp; + tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur); + tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first); + tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last); + tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node); + return tmp; + } +}; + +#define DEQUE_IMPL _STLP_PTR_IMPL_NAME(deque) +#if defined (__BORLANDC__) || defined (__DMC__) +# define typename +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy >; +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy >; +_STLP_EXPORT template struct _STLP_CLASS_DECLSPEC _Deque_iterator >; +_STLP_EXPORT_TEMPLATE_CLASS _Deque_base >; +_STLP_EXPORT_TEMPLATE_CLASS DEQUE_IMPL >; +#endif + +#if defined (_STLP_DEBUG) +# define deque _STLP_NON_DBG_NAME(deque) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template ) > +class deque +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (deque) + : public __stlport_class > +#endif +{ + typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType; + typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc; + typedef _STLP_PRIV DEQUE_IMPL<_StorageType, _StorageTypeAlloc> _Base; + typedef deque<_Tp, _Alloc> _Self; + + typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits; + typedef _STLP_PRIV _DequeIteCast<_StorageType, _Tp> ite_cast_traits; + +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag _Iterator_category; + _STLP_FORCE_ALLOCATORS(value_type, _Alloc) + typedef typename _Alloc_traits::allocator_type allocator_type; + typedef _STLP_PRIV _Deque_iterator > iterator; + typedef _STLP_PRIV _Deque_iterator > const_iterator; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +public: // Basic accessors + iterator begin() { return ite_cast_traits::to_value_type_ite(_M_impl.begin()); } + iterator end() { return ite_cast_traits::to_value_type_ite(_M_impl.end()); } + const_iterator begin() const { return ite_cast_traits::to_value_type_cite(_M_impl.begin()); } + const_iterator end() const { return ite_cast_traits::to_value_type_cite(_M_impl.end()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } + + reference operator[](size_type __n) + { return cast_traits::to_value_type_ref(_M_impl[__n]); } + const_reference operator[](size_type __n) const + { return cast_traits::to_value_type_cref(_M_impl[__n]); } + + reference at(size_type __n) + { return cast_traits::to_value_type_ref(_M_impl.at(__n)); } + const_reference at(size_type __n) const + { return cast_traits::to_value_type_cref(_M_impl.at(__n)); } + + reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); } + reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); } + const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); } + const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); } + + size_type size() const { return _M_impl.size(); } + size_type max_size() const { return _M_impl.max_size(); } + bool empty() const { return _M_impl.empty(); } + allocator_type get_allocator() const { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); } + + explicit deque(const allocator_type& __a = allocator_type()) + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + + deque(const _Self& __x) : _M_impl(__x._M_impl) {} + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit deque(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type), +#else + deque(size_type __n, const value_type& __val, +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + const allocator_type& __a = allocator_type()) + : _M_impl(__n, cast_traits::to_storage_type_cref(__val), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + // int,long variants may be needed +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit deque(size_type __n) : _M_impl(__n) {} +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if defined (_STLP_MEMBER_TEMPLATES) + template + deque(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) +#if !defined (_STLP_USE_ITERATOR_WRAPPER) + : _M_impl(__first, __last, + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) { +#else + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) { +#endif +#if defined (_STLP_USE_ITERATOR_WRAPPER) + insert(end(), __first, __last); +#endif + } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + deque(_InputIterator __first, _InputIterator __last) +# if !defined (_STLP_USE_ITERATOR_WRAPPER) + : _M_impl(__first, __last) {} +# else + { insert(end(), __first, __last); } +# endif +# endif + +#else + deque(const_pointer __first, const_pointer __last, + const allocator_type& __a = allocator_type() ) + : _M_impl(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + + deque(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type() ) + : _M_impl(ite_cast_traits::to_storage_type_cite(__first), + ite_cast_traits::to_storage_type_cite(__last), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + deque(__move_source<_Self> src) + : _M_impl(__move_source<_Base>(src.get()._M_impl)) {} +#endif + + _Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; } + + void swap(_Self& __x) { _M_impl.swap(__x._M_impl); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + void assign(size_type __n, const value_type& __val) { + _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); + } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if defined (_STLP_USE_ITERATOR_WRAPPER) +private: + template + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type&) + { _M_impl.assign(__n, __val); } + + template + void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); + } + +public: +# endif + template + void assign(_InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); +# else + _M_impl.assign(__first, __last); +# endif + } +#else + void assign(const_pointer __first, const_pointer __last) + { _M_impl.assign(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); } + void assign(const_iterator __first, const_iterator __last) + { _M_impl.assign(ite_cast_traits::to_storage_type_cite(__first), + ite_cast_traits::to_storage_type_cite(__last)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void push_back(const value_type& __t) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { _M_impl.push_back(cast_traits::to_storage_type_cref(__t)); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_front(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void push_front(const value_type& __t) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { _M_impl.push_front(cast_traits::to_storage_type_cref(__t)); } + +# if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back() { _M_impl.push_back(); } + void push_front() { _M_impl.push_front(); } +# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + void pop_back() { _M_impl.pop_back(); } + void pop_front() { _M_impl.pop_front(); } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + iterator insert(iterator __pos, const value_type& __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { return ite_cast_traits::to_value_type_ite(_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), + cast_traits::to_storage_type_cref(__x))); } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + void insert(iterator __pos, size_type __n, const value_type& __x) + { _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, cast_traits::to_storage_type_cref(__x)); } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if defined (_STLP_USE_ITERATOR_WRAPPER) +private: + template + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + const __true_type&) { + _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, __val); + } + + template + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); + } + +public: +# endif + + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); +# else + _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __first, __last); +# endif + } + +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __pos, + const_pointer __first, const_pointer __last) { + _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), + cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + void insert(iterator __pos, + const_iterator __first, const_iterator __last) { + _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), + ite_cast_traits::to_storage_type_cite(__first), + ite_cast_traits::to_storage_type_cite(__last)); + } + +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void resize(size_type __new_size, const value_type& __x) +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { _M_impl.resize(__new_size); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + iterator erase(iterator __pos) + { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__pos))); } + + iterator erase(iterator __first, iterator __last) + { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__first), + ite_cast_traits::to_storage_type_ite(__last))); } + void clear() { _M_impl.clear(); } + +private: + _Base _M_impl; +}; + +#if defined (deque) +# undef deque +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#undef DEQUE_IMPL +#if defined (__BORLANDC__) || defined (__DMC__) +# undef typename +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_SPECIALIZED_DEQUE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/pointers/_list.h b/sdk/tlibstdcxx/stlport/stl/pointers/_list.h new file mode 100644 index 0000000000..52a9262a7b --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/pointers/_list.h @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_PTR_SPECIALIZED_LIST_H +#define _STLP_PTR_SPECIALIZED_LIST_H + +#ifndef _STLP_POINTERS_SPEC_TOOLS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#define LIST_IMPL _STLP_PTR_IMPL_NAME(list) +#if defined (__BORLANDC__) || defined (__DMC__) +# define typename +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) + +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_EXPORT_TEMPLATE_CLASS _List_node; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_EXPORT_TEMPLATE_CLASS allocator<_STLP_PRIV _List_node >; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_List_node_base, _List_node, allocator<_List_node > >; +_STLP_EXPORT_TEMPLATE_CLASS _List_base >; +_STLP_EXPORT_TEMPLATE_CLASS LIST_IMPL >; + +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#if defined (_STLP_DEBUG) +# define list _STLP_NON_DBG_NAME(list) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template ) > +class list +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list) + : public __stlport_class > +#endif +{ + typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType; + typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc; + typedef _STLP_PRIV LIST_IMPL<_StorageType, _StorageTypeAlloc> _Base; + typedef typename _Base::iterator _BaseIte; + typedef typename _Base::const_iterator _BaseConstIte; + typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits; + typedef list<_Tp, _Alloc> _Self; + +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + _STLP_FORCE_ALLOCATORS(value_type, _Alloc) + typedef typename _Alloc_traits::allocator_type allocator_type; + typedef bidirectional_iterator_tag _Iterator_category; + + typedef _STLP_PRIV _List_iterator > iterator; + typedef _STLP_PRIV _List_iterator > const_iterator; + + _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; + + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); } + + explicit list(const allocator_type& __a = allocator_type()) + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit list(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type), +#else + list(size_type __n, const value_type& __val, +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + const allocator_type& __a = allocator_type()) + : _M_impl(__n, cast_traits::to_storage_type_cref(__val), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit list(size_type __n) + : _M_impl(__n) {} +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if defined (_STLP_MEMBER_TEMPLATES) + template + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) +# if !defined (_STLP_USE_ITERATOR_WRAPPER) + : _M_impl(__first, __last, _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} +# else + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) { + insert(begin(), __first, __last); + } +# endif + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + list(_InputIterator __first, _InputIterator __last) +# if !defined (_STLP_USE_WRAPPER_ITERATOR) + : _M_impl(__first, __last) {} +# else + { insert(begin(), __first, __last); } +# endif +# endif + +#else /* _STLP_MEMBER_TEMPLATES */ + + list(const value_type *__first, const value_type *__last, + const allocator_type& __a = allocator_type()) + : _M_impl(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + list(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _M_impl(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +#endif /* _STLP_MEMBER_TEMPLATES */ + + list(const _Self& __x) : _M_impl(__x._M_impl) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + list(__move_source<_Self> src) + : _M_impl(__move_source<_Base>(src.get()._M_impl)) {} +#endif + + iterator begin() { return iterator(_M_impl.begin()._M_node); } + const_iterator begin() const { return const_iterator(_M_impl.begin()._M_node); } + + iterator end() { return iterator(_M_impl.end()._M_node); } + const_iterator end() const { return const_iterator(_M_impl.end()._M_node); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + bool empty() const { return _M_impl.empty(); } + size_type size() const { return _M_impl.size(); } + size_type max_size() const { return _M_impl.max_size(); } + + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(--end()); } + const_reference back() const { return *(--end()); } + + void swap(_Self &__x) { _M_impl.swap(__x._M_impl); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + void clear() { _M_impl.clear(); } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const_reference __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + iterator insert(iterator __pos, const_reference __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { return iterator(_M_impl.insert(_BaseIte(__pos._M_node), + cast_traits::to_storage_type_cref(__x))._M_node); } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if defined (_STLP_USE_ITERATOR_WRAPPER) +private: + template + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + const __true_type&) + { _M_impl.insert(_BaseIte(__pos._M_node), __n, __val); } + + template + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_impl.insert(_BaseIte(__pos._M_node), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); + } + +public: +# endif + + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); +# else + _M_impl.insert(_BaseIte(__pos._M_node), __first, __last); +# endif + } +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __pos, const value_type *__first, const value_type *__last) + { _M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); } + void insert(iterator __pos, const_iterator __first, const_iterator __last) + { _M_impl.insert(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void insert(iterator __pos, size_type __n, const value_type& __x) + { _M_impl.insert(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); } + + void push_front(const value_type& __x) { _M_impl.push_front(cast_traits::to_storage_type_cref(__x)); } + void push_back(const value_type& __x) { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos) { return iterator(_M_impl.insert(__pos._M_node)._M_node); } + void push_front() { _M_impl.push_front();} + void push_back() { _M_impl.push_back();} +# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + iterator erase(iterator __pos) + { return iterator(_M_impl.erase(_BaseIte(__pos._M_node))._M_node); } + iterator erase(iterator __first, iterator __last) + { return iterator(_M_impl.erase(_BaseIte(__first._M_node), _BaseIte(__last._M_node))._M_node); } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void resize(size_type __new_size) { _M_impl.resize(__new_size); } + void resize(size_type __new_size, const value_type& __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/ + {_M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x));} + + void pop_front() { _M_impl.pop_front(); } + void pop_back() { _M_impl.pop_back(); } + + _Self& operator=(const _Self& __x) + { _M_impl = __x._M_impl; return *this; } + void assign(size_type __n, const value_type& __val) + { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if defined (_STLP_USE_ITERATOR_WRAPPER) +private: + template + void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&) + { _M_impl.assign(__n, __val); } + + template + void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); + } + +public: +# endif + + template + void assign(_InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); +# else + _M_impl.assign(__first, __last); +# endif + } +#else + void assign(const value_type *__first, const value_type *__last) { + _M_impl.assign(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + void assign(const_iterator __first, const_iterator __last) + { _M_impl.assign(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } +#endif + + void splice(iterator __pos, _Self& __x) + { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl); } + void splice(iterator __pos, _Self& __x, iterator __i) + { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__i._M_node)); } + void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) + { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, + _BaseIte(__first._M_node), _BaseIte(__last._M_node)); } + + void remove(const_reference __val) + { _M_impl.remove(cast_traits::to_storage_type_cref(__val)); } + void unique() { _M_impl.unique(); } + void merge(_Self& __x) { _M_impl.merge(__x._M_impl); } + void reverse() { _M_impl.reverse(); } + void sort() { _M_impl.sort(); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void remove_if(_Predicate __pred) + { _M_impl.remove_if(_STLP_PRIV _UnaryPredWrapper<_StorageType, _Tp, _Predicate>(__pred)); } + template + void unique(_BinaryPredicate __bin_pred) + { _M_impl.unique(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _BinaryPredicate>(__bin_pred)); } + + template + void merge(_Self &__x, _StrictWeakOrdering __comp) + { _M_impl.merge(__x._M_impl, _STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } + + template + void sort(_StrictWeakOrdering __comp) + { _M_impl.sort(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + +private: + _Base _M_impl; +}; + +#if defined (list) +# undef list +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#undef LIST_IMPL +#if defined (__BORLANDC__) || defined (__DMC__) +# undef typename +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_PTR_SPECIALIZED_LIST_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/pointers/_set.h b/sdk/tlibstdcxx/stlport/stl/pointers/_set.h new file mode 100644 index 0000000000..f997a5ae13 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/pointers/_set.h @@ -0,0 +1,564 @@ +/* + * Copyright (c) 2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_PTR_SPECIALIZED_SET_H +#define _STLP_PTR_SPECIALIZED_SET_H + +#ifndef _STLP_POINTERS_SPEC_TOOLS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (__BORLANDC__) || defined (__DMC__) +# define typename +#endif + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits) + +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +_STLP_EXPORT template struct _STLP_CLASS_DECLSPEC less; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +typedef _Rb_tree_node _Node; +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Rb_tree_node_base, _Node, allocator<_Node> >; +_STLP_EXPORT_TEMPLATE_CLASS _Rb_tree_base >; +# if defined (_STLP_DEBUG) +_STLP_EXPORT_TEMPLATE_CLASS _DbgCompare >; +# define _Rb_tree _STLP_NON_DBG_NAME(Rb_tree) +_STLP_EXPORT_TEMPLATE_CLASS _Rb_tree >, void*, _Identity, + _SetTraitsT, allocator >; +# undef _Rb_tree +# endif +_STLP_EXPORT_TEMPLATE_CLASS _Rb_tree, void*, _Identity, + _SetTraitsT, allocator >; +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template ), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > +class set +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ +#if !defined (__BORLANDC__) + typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare> _AssocStorageTypes; + typedef typename _AssocStorageTypes::_KeyStorageType _KeyStorageType; + typedef typename _AssocStorageTypes::_CompareStorageType _CompareStorageType; +#else + typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_KeyStorageType _KeyStorageType; + typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_CompareStorageType _CompareStorageType; +#endif + typedef typename _Alloc_traits<_KeyStorageType, _Alloc>::allocator_type _StorageTypeAlloc; + typedef _STLP_PRIV _CastTraits<_KeyStorageType, _Key> cast_traits; + + typedef set<_Key, _Compare, _Alloc> _Self; +public: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + +protected: + //Specific iterator traits creation + typedef _STLP_PRIV _SetTraitsT _SetTraits; + typedef _STLP_PRIV _Rb_tree, + _SetTraits, _Alloc> _Priv_Rep_type; + + typedef _STLP_PRIV _SetTraitsT<_KeyStorageType> _SetStorageTraits; + +public: + //dums: need the following public for the __move_traits framework + typedef _STLP_PRIV _Rb_tree<_KeyStorageType, _CompareStorageType, + _KeyStorageType, _STLP_PRIV _Identity<_KeyStorageType>, + _SetStorageTraits, _StorageTypeAlloc> _Rep_type; + +private: + typedef typename _Rep_type::iterator base_iterator; + typedef typename _Rep_type::const_iterator const_base_iterator; + +public: + typedef typename _Priv_Rep_type::pointer pointer; + typedef typename _Priv_Rep_type::const_pointer const_pointer; + typedef typename _Priv_Rep_type::reference reference; + typedef typename _Priv_Rep_type::const_reference const_reference; + typedef typename _Priv_Rep_type::iterator iterator; + typedef typename _Priv_Rep_type::const_iterator const_iterator; + typedef typename _Priv_Rep_type::reverse_iterator reverse_iterator; + typedef typename _Priv_Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Priv_Rep_type::size_type size_type; + typedef typename _Priv_Rep_type::difference_type difference_type; + typedef typename _Priv_Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing set + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +#if defined (_STLP_DEBUG) + static iterator _S_to_value_ite(const_base_iterator __ite) + { return iterator(__ite._Owner(), __ite._M_iterator._M_node); } + static base_iterator _S_to_storage_ite(const_iterator __ite) + { return base_iterator(__ite._Owner(), __ite._M_iterator._M_node); } +#else + static iterator _S_to_value_ite(const_base_iterator __ite) + { return iterator(__ite._M_node); } + static base_iterator _S_to_storage_ite(const_iterator __ite) + { return base_iterator(__ite._M_node); } +#endif + +public: + set() : _M_t(_CompareStorageType(), _StorageTypeAlloc()) {} + explicit set(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template + set(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), _StorageTypeAlloc()) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_unique(__first, __last); +# endif + } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp) + : _M_t(__comp, _StorageTypeAlloc()) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_unique(__first, __last); +# endif + } +# endif + template + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_unique(__first, __last); +# endif + } +#else + set(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), _StorageTypeAlloc()) { + _M_t.insert_unique(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + + set(const value_type* __first, const value_type* __last, + const _Compare& __comp, const allocator_type& __a = allocator_type()) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { + _M_t.insert_unique(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + + set(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), _StorageTypeAlloc()) + { _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } + + set(const_iterator __first, const_iterator __last, + const _Compare& __comp, const allocator_type& __a = allocator_type()) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) + { _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + set(const _Self& __x) : _M_t(__x._M_t) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + set(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return _M_t.key_comp(); } + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR(_M_t.get_allocator(), value_type); } + + iterator begin() { return _S_to_value_ite(_M_t.begin()); } + iterator end() { return _S_to_value_ite(_M_t.end()); } + const_iterator begin() const { return _S_to_value_ite(_M_t.begin()); } + const_iterator end() const { return _S_to_value_ite(_M_t.end()); } + reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + pair insert(const value_type& __x) { + pair ret = _M_t.insert_unique(cast_traits::to_storage_type_cref(__x)); + return pair(_S_to_value_ite(ret.first), ret.second); + } + iterator insert(iterator __pos, const value_type& __x) + { return _S_to_value_ite(_M_t.insert_unique(_S_to_storage_ite(__pos), cast_traits::to_storage_type_cref(__x))); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_unique(__first, __last); +# endif + } +#else + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } + void insert(const value_type* __first, const value_type* __last) { + _M_t.insert_unique(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } +#endif + void erase(iterator __pos) + { _M_t.erase(_S_to_storage_ite(__pos)); } + size_type erase(const key_type& __x) + { return _M_t.erase_unique(cast_traits::to_storage_type_cref(__x)); } + void erase(iterator __first, iterator __last) + { _M_t.erase(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } + void clear() { _M_t.clear(); } + + // set operations: + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const + { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) + { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const + { return _M_t.find(cast_traits::to_storage_type_crefT(__x)) == _M_t.end() ? 0 : 1; } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) + { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const + { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) + { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const + { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) { + pair __ret; + __ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x)); + return pair(_S_to_value_ite(__ret.first), + _S_to_value_ite(__ret.second)); + } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const { + pair __ret; + __ret = _M_t.equal_range_unique(cast_traits::to_storage_type_crefT(__x)); + return pair(_S_to_value_ite(__ret.first), + _S_to_value_ite(__ret.second)); + } +}; + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits) + +template ), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > +class multiset +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class > +#endif +{ +#if !defined (__BORLANDC__) + typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare> _AssocStorageTypes; + typedef typename _AssocStorageTypes::_KeyStorageType _KeyStorageType; + typedef typename _AssocStorageTypes::_CompareStorageType _CompareStorageType; +#else + typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_KeyStorageType _KeyStorageType; + typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_CompareStorageType _CompareStorageType; +#endif + typedef typename _Alloc_traits<_KeyStorageType, _Alloc>::allocator_type _StorageTypeAlloc; + typedef _STLP_PRIV _CastTraits<_KeyStorageType, _Key> cast_traits; + + typedef multiset<_Key, _Compare, _Alloc> _Self; +public: + // typedefs: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + +protected: + //Specific iterator traits creation + typedef _STLP_PRIV _MultisetTraitsT _MultisetTraits; + typedef _STLP_PRIV _Rb_tree, + _MultisetTraits, _Alloc> _Priv_Rep_type; + + typedef _STLP_PRIV _MultisetTraitsT<_KeyStorageType> _MultisetStorageTraits; +public: + //dums: need the following public for the __move_traits framework + typedef _STLP_PRIV _Rb_tree<_KeyStorageType, _CompareStorageType, + _KeyStorageType, _STLP_PRIV _Identity<_KeyStorageType>, + _MultisetStorageTraits, _StorageTypeAlloc> _Rep_type; + +private: + typedef typename _Rep_type::iterator base_iterator; + typedef typename _Rep_type::const_iterator const_base_iterator; + +public: + typedef typename _Priv_Rep_type::pointer pointer; + typedef typename _Priv_Rep_type::const_pointer const_pointer; + typedef typename _Priv_Rep_type::reference reference; + typedef typename _Priv_Rep_type::const_reference const_reference; + typedef typename _Priv_Rep_type::iterator iterator; + typedef typename _Priv_Rep_type::const_iterator const_iterator; + typedef typename _Priv_Rep_type::reverse_iterator reverse_iterator; + typedef typename _Priv_Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Priv_Rep_type::size_type size_type; + typedef typename _Priv_Rep_type::difference_type difference_type; + typedef typename _Priv_Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing multiset + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +#if defined (_STLP_DEBUG) + static iterator _S_to_value_ite(const_base_iterator __ite) + { return iterator(__ite._Owner(), __ite._M_iterator._M_node); } + static base_iterator _S_to_storage_ite(const_iterator __ite) + { return base_iterator(__ite._Owner(), __ite._M_iterator._M_node); } +#else + static iterator _S_to_value_ite(const_base_iterator __ite) + { return iterator(__ite._M_node); } + static base_iterator _S_to_storage_ite(const_iterator __ite) + { return base_iterator(__ite._M_node); } +#endif + +public: + multiset() : _M_t(_Compare(), _StorageTypeAlloc()) {} + explicit multiset(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template + multiset(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), _StorageTypeAlloc()) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_equal(__first, __last); +# endif + } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp) + : _M_t(__comp, _StorageTypeAlloc()) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_equal(__first, __last); +# endif + } +# endif + template + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_equal(__first, __last); +# endif + } + +#else + multiset(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), _StorageTypeAlloc()) { + _M_t.insert_equal(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + + multiset(const value_type* __first, const value_type* __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { + _M_t.insert_equal(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + + multiset(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), _StorageTypeAlloc()) + { _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } + + multiset(const_iterator __first, const_iterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) + { _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + multiset(const _Self& __x) + : _M_t(__x._M_t) {} + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + multiset(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return _M_t.key_comp(); } + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR(_M_t.get_allocator(), value_type); } + + iterator begin() { return _S_to_value_ite(_M_t.begin()); } + iterator end() { return _S_to_value_ite(_M_t.end()); } + const_iterator begin() const { return _S_to_value_ite(_M_t.begin()); } + const_iterator end() const { return _S_to_value_ite(_M_t.end()); } + reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + iterator insert(const value_type& __x) + { return _S_to_value_ite(_M_t.insert_equal(cast_traits::to_storage_type_cref(__x))); } + iterator insert(iterator __pos, const value_type& __x) { + return _S_to_value_ite(_M_t.insert_equal(_S_to_storage_ite(__pos), + cast_traits::to_storage_type_cref(__x))); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(_InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + _M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); +# else + _M_t.insert_equal(__first, __last); +# endif + } +#else + void insert(const value_type* __first, const value_type* __last) { + _M_t.insert_equal(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void erase(iterator __pos) + { _M_t.erase(_S_to_storage_ite(__pos)); } + size_type erase(const key_type& __x) + { return _M_t.erase(cast_traits::to_storage_type_cref(__x)); } + void erase(iterator __first, iterator __last) + { _M_t.erase(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } + void clear() { _M_t.clear(); } + + // multiset operations: + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) + { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const + { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const + { return _M_t.count(cast_traits::to_storage_type_crefT(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) + { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const + { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) + { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const + { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) { + pair __ret; + __ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x)); + return pair(_S_to_value_ite(__ret.first), + _S_to_value_ite(__ret.second)); + } + _STLP_TEMPLATE_FOR_CONT_EXT + pair equal_range(const _KT& __x) const { + pair __ret; + __ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x)); + return pair(_S_to_value_ite(__ret.first), + _S_to_value_ite(__ret.second)); + } +}; + +#if defined (__BORLANDC__) || defined (__DMC__) +# undef typename +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_PTR_SPECIALIZED_SET_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/pointers/_slist.h b/sdk/tlibstdcxx/stlport/stl/pointers/_slist.h new file mode 100644 index 0000000000..76189fe0ed --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/pointers/_slist.h @@ -0,0 +1,427 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_SPECIALIZED_SLIST_H +#define _STLP_SPECIALIZED_SLIST_H + +#ifndef _STLP_POINTERS_SPEC_TOOLS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#define SLIST_IMPL _STLP_PTR_IMPL_NAME(slist) + +#if defined (__BORLANDC__) || defined (__DMC__) +# define typename +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +_STLP_MOVE_TO_PRIV_NAMESPACE + +_STLP_EXPORT_TEMPLATE_CLASS _Slist_node; +typedef _Slist_node _VoidPtrSNode; +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Slist_node_base, _VoidPtrSNode, allocator<_VoidPtrSNode> >; +_STLP_EXPORT_TEMPLATE_CLASS _Slist_base >; +_STLP_EXPORT_TEMPLATE_CLASS SLIST_IMPL >; + +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#if defined (_STLP_DEBUG) +# define slist _STLP_NON_DBG_NAME(slist) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template ) > +class slist +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (slist) + : public __stlport_class > +#endif +{ + typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType; + typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc; + typedef _STLP_PRIV SLIST_IMPL<_StorageType, _StorageTypeAlloc> _Base; + typedef typename _Base::iterator _BaseIte; + typedef typename _Base::const_iterator _BaseConstIte; + typedef slist<_Tp, _Alloc> _Self; + typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits; + typedef _STLP_PRIV _Slist_node_base _Node_base; + +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef forward_iterator_tag _Iterator_category; + + typedef _STLP_PRIV _Slist_iterator > iterator; + typedef _STLP_PRIV _Slist_iterator > const_iterator; + + _STLP_FORCE_ALLOCATORS(value_type, _Alloc) + typedef typename _Alloc_traits::allocator_type allocator_type; + +public: + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); } + + explicit slist(const allocator_type& __a = allocator_type()) + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit slist(size_type __n, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type), +#else + slist(size_type __n, const value_type& __x, +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + const allocator_type& __a = allocator_type()) + : _M_impl(__n, cast_traits::to_storage_type_cref(__x), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit slist(size_type __n) : _M_impl(__n) {} +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + +#if defined (_STLP_MEMBER_TEMPLATES) + // We don't need any dispatching tricks here, because _M_insert_after_range + // already does them. + template + slist(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) +# if !defined (_STLP_USE_ITERATOR_WRAPPER) + : _M_impl(__first, __last, _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} +# else + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) { + insert_after(before_begin(), __first, __last); + } +# endif +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + // VC++ needs this crazyness + template + slist(_InputIterator __first, _InputIterator __last) +# if !defined (_STLP_USE_WRAPPER_ITERATOR) + : _M_impl(__first, __last) {} +# else + { insert_after(before_begin(), __first, __last); } +# endif +# endif +#else /* _STLP_MEMBER_TEMPLATES */ + slist(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type() ) + : _M_impl(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + slist(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type()) + : _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} +#endif /* _STLP_MEMBER_TEMPLATES */ + + slist(const _Self& __x) : _M_impl(__x._M_impl) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + slist(__move_source<_Self> src) + : _M_impl(__move_source<_Base>(src.get()._M_impl)) {} +#endif + + _Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; } + + void assign(size_type __n, const value_type& __val) + { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if defined (_STLP_USE_ITERATOR_WRAPPER) +private: + template + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type&) + { _M_impl.assign(__n, __val); } + + template + void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); + } + +public: +# endif + + template + void assign(_InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); +# else + _M_impl.assign(__first, __last); +# endif + } +#else + void assign(const value_type *__first, const value_type *__last) { + _M_impl.assign(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } + void assign(const_iterator __first, const_iterator __last) { + _M_impl.assign(_BaseConstIte(__first._M_node), + _BaseConstIte(__last._M_node)); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + iterator before_begin() { return iterator(_M_impl.before_begin()._M_node); } + const_iterator before_begin() const { return const_iterator(const_cast<_Node_base*>(_M_impl.before_begin()._M_node)); } + + iterator begin() { return iterator(_M_impl.begin()._M_node); } + const_iterator begin() const { return const_iterator(const_cast<_Node_base*>(_M_impl.begin()._M_node));} + + iterator end() { return iterator(_M_impl.end()._M_node); } + const_iterator end() const { return iterator(_M_impl.end()._M_node); } + + size_type size() const { return _M_impl.size(); } + size_type max_size() const { return _M_impl.max_size(); } + bool empty() const { return _M_impl.empty(); } + + void swap(_Self& __x) { _M_impl.swap(__x._M_impl); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +public: + reference front() { return *begin(); } + const_reference front() const { return *begin(); } +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + void push_front(const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void push_front(const value_type& __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { _M_impl.push_front(cast_traits::to_storage_type_cref(__x)); } + +# if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + void push_front() { _M_impl.push_front();} +# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + void pop_front() { _M_impl.pop_front(); } + + iterator previous(const_iterator __pos) + { return iterator(_M_impl.previous(_BaseConstIte(__pos._M_node))._M_node); } + const_iterator previous(const_iterator __pos) const + { return const_iterator(const_cast<_Node_base*>(_M_impl.previous(_BaseConstIte(__pos._M_node))._M_node)); } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + iterator insert_after(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + iterator insert_after(iterator __pos, const value_type& __x) +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + { return iterator(_M_impl.insert_after(_BaseIte(__pos._M_node), + cast_traits::to_storage_type_cref(__x))._M_node); } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + iterator insert_after(iterator __pos) + { return iterator(_M_impl.insert_after(_BaseIte(__pos._M_node))._M_node);} +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void insert_after(iterator __pos, size_type __n, const value_type& __x) + { _M_impl.insert_after(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if defined (_STLP_USE_ITERATOR_WRAPPER) +private: + template + void _M_insert_after_dispatch(iterator __pos, _Integer __n, _Integer __val, + const __true_type&) { + _M_impl.insert_after(_BaseIte(__pos._M_node), __n, __val); + } + + template + void _M_insert_after_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_impl.insert_after(_BaseIte(__pos._M_node), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); + } + +public: +# endif + + template + void insert_after(iterator __pos, _InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_after_dispatch(__pos, __first, __last, _Integral()); +# else + _M_impl.insert_after(_BaseIte(__pos._M_node), __first, __last); +# endif + } + +#else /* _STLP_MEMBER_TEMPLATES */ + void insert_after(iterator __pos, + const_iterator __first, const_iterator __last) + { _M_impl.insert_after(_BaseIte(__pos._M_node), + _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } + void insert_after(iterator __pos, + const value_type* __first, const value_type* __last) { + _M_impl.insert_after(_BaseIte(__pos._M_node), + cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + iterator insert(iterator __pos, const value_type& __x) +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + { return iterator(_M_impl.insert(_BaseIte(__pos._M_node), + cast_traits::to_storage_type_cref(__x))._M_node); } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + iterator insert(iterator __pos) + { return iterator(_M_impl.insert(_BaseIte(__pos._M_node))._M_node); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void insert(iterator __pos, size_type __n, const value_type& __x) + { _M_impl.insert(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); } + +#if defined (_STLP_MEMBER_TEMPLATES) +# if defined (_STLP_USE_ITERATOR_WRAPPER) +private: + template + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + const __true_type&) { + _M_impl.insert(_BaseIte(__pos._M_node), __n, __val); + } + + template + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_impl.insert(_BaseIte(__pos._M_node), _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), + _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); + } + +public: +# endif + + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { +# if defined (_STLP_USE_ITERATOR_WRAPPER) + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); +# else + _M_impl.insert(_BaseIte(__pos._M_node), __first, __last); +# endif + } + +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __pos, const_iterator __first, const_iterator __last) + { _M_impl.insert(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } + void insert(iterator __pos, const value_type* __first, const value_type* __last) + { _M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + iterator erase_after(iterator __pos) + { return iterator(_M_impl.erase_after(_BaseIte(__pos._M_node))._M_node); } + iterator erase_after(iterator __before_first, iterator __last) + { return iterator(_M_impl.erase_after(_BaseIte(__before_first._M_node), + _BaseIte(__last._M_node))._M_node); } + + iterator erase(iterator __pos) + { return iterator(_M_impl.erase(_BaseIte(__pos._M_node))._M_node); } + iterator erase(iterator __first, iterator __last) + { return iterator(_M_impl.erase(_BaseIte(__first._M_node), _BaseIte(__last._M_node))._M_node); } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void resize(size_type __new_size, const value_type& __x) +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x));} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { _M_impl.resize(__new_size); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void clear() { _M_impl.clear(); } + + void splice_after(iterator __pos, _Self& __x, + iterator __before_first, iterator __before_last) + { _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl, + _BaseIte(__before_first._M_node), _BaseIte(__before_last._M_node)); } + void splice_after(iterator __pos, _Self& __x, iterator __prev) + { _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__prev._M_node)); } + void splice_after(iterator __pos, _Self& __x) + { _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl); } + void splice(iterator __pos, _Self& __x) + { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl); } + void splice(iterator __pos, _Self& __x, iterator __i) + { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__i._M_node)); } + void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) + { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, + _BaseIte(__first._M_node), _BaseIte(__last._M_node)); } + + void reverse() { _M_impl.reverse(); } + + void remove(const value_type& __val) { _M_impl.remove(cast_traits::to_storage_type_cref(__val)); } + void unique() { _M_impl.unique(); } + void merge(_Self& __x) { _M_impl.merge(__x._M_impl); } + void sort() {_M_impl.sort(); } + +#ifdef _STLP_MEMBER_TEMPLATES + template + void remove_if(_Predicate __pred) + { _M_impl.remove_if(_STLP_PRIV _UnaryPredWrapper<_StorageType, _Tp, _Predicate>(__pred)); } + + template + void unique(_BinaryPredicate __pred) + { _M_impl.unique(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _BinaryPredicate>(__pred)); } + + template + void merge(_Self& __x, _StrictWeakOrdering __comp) + { _M_impl.merge(__x._M_impl, _STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } + + template + void sort(_StrictWeakOrdering __comp) + { _M_impl.sort(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } +#endif /* _STLP_MEMBER_TEMPLATES */ + +private: + _Base _M_impl; +}; + +#if defined (slist) +# undef slist +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#undef SLIST_IMPL + +#if defined (__BORLANDC__) || defined (__DMC__) +# undef typename +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_SPECIALIZED_SLIST_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/stl/pointers/_tools.h b/sdk/tlibstdcxx/stlport/stl/pointers/_tools.h new file mode 100644 index 0000000000..ec94806199 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/pointers/_tools.h @@ -0,0 +1,471 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_POINTERS_SPEC_TOOLS_H +#define _STLP_POINTERS_SPEC_TOOLS_H + +#ifndef _STLP_TYPE_TRAITS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +//Some usefull declarations: +template struct less; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +struct _BinaryPredWrapper; + +/* + * Since the compiler only allows at most one non-trivial + * implicit conversion we can make use of a shim class to + * be sure that functions below doesn't accept classes with + * implicit pointer conversion operators + */ +struct _VoidPointerShim +{ _VoidPointerShim(void*); }; +struct _ConstVoidPointerShim +{ _ConstVoidPointerShim(const void*); }; +struct _VolatileVoidPointerShim +{ _VolatileVoidPointerShim(volatile void*); }; +struct _ConstVolatileVoidPointerShim +{ _ConstVolatileVoidPointerShim(const volatile void*); }; + +//The dispatch functions: +template +char _UseVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&); +char _UseVoidPtrStorageType(const __true_type& /*POD*/, ...); +char* _UseVoidPtrStorageType(const __true_type& /*POD*/, _VoidPointerShim); + +template +char _UseConstVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&); +char _UseConstVoidPtrStorageType(const __true_type& /*POD*/, ...); +char* _UseConstVoidPtrStorageType(const __true_type& /*POD*/, _ConstVoidPointerShim); + +template +char _UseVolatileVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&); +char _UseVolatileVoidPtrStorageType(const __true_type& /*POD*/, ...); +char* _UseVolatileVoidPtrStorageType(const __true_type& /*POD*/, _VolatileVoidPointerShim); + +template +char _UseConstVolatileVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&); +char _UseConstVolatileVoidPtrStorageType(const __true_type& /*POD*/, ...); +char* _UseConstVolatileVoidPtrStorageType(const __true_type& /*POD*/, _ConstVolatileVoidPointerShim); + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +/* Thanks to class partial specialization the pointer specialization feature can even be used in + * presence of incomplete type: + * struct MyStruct { + * typedef vector MyStructContainer; + * typedef MyStructContainer::iterator MyStructIterator; + * }; + */ + +template +struct _StorageType { + typedef _Tp _QualifiedType; + typedef _Tp _Type; + enum { use_const_volatile_void_ptr = 0 }; +}; + +template +struct _StorageType<_Tp*> { + // Even if we detect a pointer type we use dispatch function to consider if it can be stored as a void*. + // For instance function pointer might not necessarily be convertible to void*. + enum { use_void_ptr = (sizeof(_UseVoidPtrStorageType(__true_type(), + __STATIC_CAST(_Tp*, 0))) == sizeof(char*)) }; + enum { use_const_volatile_void_ptr = use_void_ptr }; + typedef typename __select::_Ret _QualifiedType; + typedef _QualifiedType _Type; +}; + +template +struct _StorageType<_Tp const*> { + enum { use_void_ptr = (sizeof(_UseConstVoidPtrStorageType(__true_type(), + __STATIC_CAST(const _Tp*, 0))) == sizeof(char*)) }; + enum { use_const_volatile_void_ptr = use_void_ptr }; + typedef typename __select::_Ret _QualifiedType; + typedef typename __select::_Ret _Type; +}; + +template +struct _StorageType<_Tp volatile*> { + enum { use_void_ptr = (sizeof(_UseVolatileVoidPtrStorageType(__true_type(), + __STATIC_CAST(_Tp volatile*, 0))) == sizeof(char*)) }; + enum { use_const_volatile_void_ptr = use_void_ptr }; + typedef typename __select::_Ret _QualifiedType; + typedef typename __select::_Ret _Type; +}; + +template +struct _StorageType<_Tp const volatile*> { + enum { use_void_ptr = (sizeof(_UseConstVolatileVoidPtrStorageType(__true_type(), + __STATIC_CAST(_Tp const volatile*, 0))) == sizeof(char*)) }; + enum { use_const_volatile_void_ptr = use_void_ptr }; + typedef typename __select::_Ret _QualifiedType; + typedef typename __select::_Ret _Type; +}; +#else +template +struct _StorageType { + typedef typename __type_traits<_Tp>::is_POD_type _PODType; + +#if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) + static _Tp __null_rep(); +#else + static _Tp __null_rep; +#endif + enum { use_void_ptr = (sizeof(_UseVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) }; + enum { use_const_void_ptr = (sizeof(_UseConstVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) }; + enum { use_volatile_void_ptr = (sizeof(_UseVolatileVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) }; + enum { use_const_volatile_void_ptr = (sizeof(_UseConstVolatileVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) }; + + typedef typename __select::_Ret >::_Ret >::_Ret >::_Ret _QualifiedType; + +#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + /* If the compiler do not support the iterator_traits structure we cannot wrap + * iterators pass to container template methods. The iterator dereferenced value + * has to be storable without any cast in the chosen storage type. To guaranty + * that the void pointer has to be correctly qualified. + */ + typedef _QualifiedType _Type; +#else + /* With iterator_traits we can wrap passed iterators and make the necessary casts. + * We can always use a simple void* storage type: + */ + typedef typename __select::_Ret _Type; +#endif +}; +#endif + +template +struct _AssocStorageTypes { + typedef _StorageType<_Tp> _StorageTypeInfo; + typedef typename _StorageTypeInfo::_Type _SType; + + //We need to also check that the comparison functor used to instanciate the assoc container + //is the default Standard less implementation: + enum { ptr_type = _StorageTypeInfo::use_const_volatile_void_ptr }; + typedef typename _IsSTLportClass<_Compare>::_Ret _STLportLess; + enum { is_default_less = __type2bool<_STLportLess>::_Ret }; + typedef typename __select::_Ret _KeyStorageType; + typedef typename __select, + _Compare>::_Ret _CompareStorageType; +}; + + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +/* + * Base struct to deal with qualifiers + */ +template +struct _VoidCastTraitsAux { + typedef _QualifiedStorageT void_cv_type; + typedef _StorageT void_type; + + static void_type * uncv_ptr(void_cv_type *__ptr) + { return __ptr; } + static void_type const* uncv_cptr(void_cv_type const*__ptr) + { return __ptr; } + static void_type ** uncv_pptr(void_cv_type **__ptr) + { return __ptr; } + static void_type & uncv_ref(void_cv_type & __ref) + { return __ref; } + static void_type const& uncv_cref(void_cv_type const& __ref) + { return __ref; } + static void_cv_type* cv_ptr(void_type *__ptr) + { return __ptr; } + static void_cv_type const* cv_cptr(void_type const*__ptr) + { return __ptr; } + static void_cv_type ** cv_pptr(void_type **__ptr) + { return __ptr; } + static void_cv_type & cv_ref(void_type & __ref) + { return __ref; } + static void_cv_type const& cv_cref(void_type const& __ref) + { return __ref; } +}; + +template +struct _VoidCastTraitsAuxBase { + typedef _VoidCVType* void_cv_type; + typedef void* void_type; + + static void_type* uncv_ptr(void_cv_type *__ptr) + { return __CONST_CAST(void_type*, __ptr); } + static void_type const* uncv_cptr(void_cv_type const*__ptr) + { return __CONST_CAST(void_type const*, __ptr); } + static void_type** uncv_pptr(void_cv_type **__ptr) + { return __CONST_CAST(void_type**, __ptr); } + static void_type& uncv_ref(void_cv_type &__ref) + { return __CONST_CAST(void_type&, __ref); } + static void_type const& uncv_cref(void_cv_type const& __ptr) + { return __CONST_CAST(void_type const&, __ptr); } + // The reverse versions + static void_cv_type * cv_ptr(void_type *__ptr) + { return __CONST_CAST(void_cv_type *, __ptr); } + static void_cv_type const* cv_cptr(void_type const*__ptr) + { return __CONST_CAST(void_cv_type const*, __ptr); } + static void_cv_type ** cv_pptr(void_type **__ptr) + { return __CONST_CAST(void_cv_type**, __ptr); } + static void_cv_type & cv_ref(void_type &__ref) + { return __CONST_CAST(void_cv_type &, __ref); } + static void_cv_type const& cv_cref(void_type const& __ref) + { return __CONST_CAST(void_cv_type const&, __ref); } +}; + +_STLP_TEMPLATE_NULL +struct _VoidCastTraitsAux : _VoidCastTraitsAuxBase +{}; +_STLP_TEMPLATE_NULL +struct _VoidCastTraitsAux : _VoidCastTraitsAuxBase +{}; +_STLP_TEMPLATE_NULL +struct _VoidCastTraitsAux : _VoidCastTraitsAuxBase +{}; + +template +struct _CastTraits { + typedef _ValueT value_type; + typedef typename _StorageType<_ValueT>::_QualifiedType _QualifiedStorageT; + typedef _VoidCastTraitsAux<_StorageT, _QualifiedStorageT> cv_traits; + typedef typename cv_traits::void_type void_type; + typedef typename cv_traits::void_cv_type void_cv_type; + + static value_type * to_value_type_ptr(void_type *__ptr) + { return __REINTERPRET_CAST(value_type *, cv_traits::cv_ptr(__ptr)); } + static value_type const* to_value_type_cptr(void_type const*__ptr) + { return __REINTERPRET_CAST(value_type const*, cv_traits::cv_cptr(__ptr)); } + static value_type ** to_value_type_pptr(void_type **__ptr) + { return __REINTERPRET_CAST(value_type **, cv_traits::cv_pptr(__ptr)); } + static value_type & to_value_type_ref(void_type &__ref) + { return __REINTERPRET_CAST(value_type &, cv_traits::cv_ref(__ref)); } + static value_type const& to_value_type_cref(void_type const& __ptr) + { return __REINTERPRET_CAST(value_type const&, cv_traits::cv_cref(__ptr)); } + // Reverse versions + static void_type * to_storage_type_ptr(value_type *__ptr) + { return cv_traits::uncv_ptr(__REINTERPRET_CAST(void_cv_type *, __ptr)); } + static void_type const* to_storage_type_cptr(value_type const*__ptr) + { return cv_traits::uncv_cptr(__REINTERPRET_CAST(void_cv_type const*, __ptr)); } + static void_type ** to_storage_type_pptr(value_type **__ptr) + { return cv_traits::uncv_pptr(__REINTERPRET_CAST(void_cv_type **, __ptr)); } + static void_type const& to_storage_type_cref(value_type const& __ref) + { return cv_traits::uncv_cref(__REINTERPRET_CAST(void_cv_type const&, __ref)); } + + //Method used to treat set container template method extension + static void_type const& to_storage_type_crefT(value_type const& __ref) + { return to_storage_type_cref(__ref); } +}; + +template +struct _CastTraits<_Tp, _Tp> { + typedef _Tp storage_type; + typedef _Tp value_type; + + static value_type * to_value_type_ptr(storage_type *__ptr) + { return __ptr; } + static value_type const* to_value_type_cptr(storage_type const*__ptr) + { return __ptr; } + static value_type ** to_value_type_pptr(storage_type **__ptr) + { return __ptr; } + static value_type & to_value_type_ref(storage_type &__ref) + { return __ref; } + static value_type const& to_value_type_cref(storage_type const&__ref) + { return __ref; } + // Reverse versions + static storage_type * to_storage_type_ptr(value_type *__ptr) + { return __ptr; } + static storage_type const* to_storage_type_cptr(value_type const*__ptr) + { return __ptr; } + static storage_type ** to_storage_type_pptr(value_type **__ptr) + { return __ptr; } + static storage_type const& to_storage_type_cref(value_type const& __ref) + { return __ref; } + + //Method used to treat set container template method extension + template + static _Tp1 const& to_storage_type_crefT(_Tp1 const& __ref) + { return __ref; } +}; + +#define _STLP_USE_ITERATOR_WRAPPER + +template +struct _IteWrapper { + typedef _CastTraits<_StorageT, _ValueT> cast_traits; + typedef iterator_traits<_Iterator> _IteTraits; + + typedef typename _IteTraits::iterator_category iterator_category; + typedef _StorageT value_type; + typedef typename _IteTraits::difference_type difference_type; + typedef value_type* pointer; + typedef value_type const& const_reference; + //This wrapper won't be used for input so to avoid surprise + //the reference type will be a const reference: + typedef const_reference reference; + + typedef _IteWrapper<_StorageT, _ValueT, _Iterator> _Self; + typedef _Self _Ite; + + _IteWrapper(_Iterator &__ite) : _M_ite(__ite) {} + + const_reference operator*() const { return cast_traits::to_storage_type_cref(*_M_ite); } + + _Self& operator= (_Self const& __rhs) { + _M_ite = __rhs._M_ite; + return *this; + } + + _Self& operator++() { + ++_M_ite; + return *this; + } + + _Self& operator--() { + --_M_ite; + return *this; + } + + _Self& operator += (difference_type __offset) { + _M_ite += __offset; + return *this; + } + difference_type operator -(_Self const& __other) const + { return _M_ite - __other._M_ite; } + + bool operator == (_Self const& __other) const + { return _M_ite == __other._M_ite; } + + bool operator != (_Self const& __other) const + { return _M_ite != __other._M_ite; } + + bool operator < (_Self const& __rhs) const + { return _M_ite < __rhs._M_ite; } + +private: + _Iterator _M_ite; +}; + +template +struct _IteWrapper<_Tp, _Tp, _Iterator> +{ typedef _Iterator _Ite; }; + +#else + +/* + * In this config the storage type is qualified in respect of the + * value_type qualification. Simple reinterpret_cast is enough. + */ +template +struct _CastTraits { + typedef _StorageT storage_type; + typedef _ValueT value_type; + + static value_type * to_value_type_ptr(storage_type *__ptr) + { return __REINTERPRET_CAST(value_type*, __ptr); } + static value_type const* to_value_type_cptr(storage_type const*__ptr) + { return __REINTERPRET_CAST(value_type const*, __ptr); } + static value_type ** to_value_type_pptr(storage_type **__ptr) + { return __REINTERPRET_CAST(value_type **, __ptr); } + static value_type & to_value_type_ref(storage_type &__ref) + { return __REINTERPRET_CAST(value_type&, __ref); } + static value_type const& to_value_type_cref(storage_type const&__ref) + { return __REINTERPRET_CAST(value_type const&, __ref); } + // Reverse versions + static storage_type * to_storage_type_ptr(value_type *__ptr) + { return __REINTERPRET_CAST(storage_type*, __ptr); } + static storage_type const* to_storage_type_cptr(value_type const*__ptr) + { return __REINTERPRET_CAST(storage_type const*, __ptr); } + static storage_type ** to_storage_type_pptr(value_type **__ptr) + { return __REINTERPRET_CAST(storage_type **, __ptr); } + static storage_type const& to_storage_type_cref(value_type const&__ref) + { return __REINTERPRET_CAST(storage_type const&, __ref); } + template + static _Tp1 const& to_storage_type_crefT(_Tp1 const& __ref) + { return __ref; } +}; + +#endif + +//Wrapper functors: +template +struct _UnaryPredWrapper { + typedef _CastTraits<_StorageT, _ValueT> cast_traits; + + _UnaryPredWrapper (_UnaryPredicate const& __pred) : _M_pred(__pred) {} + + bool operator () (_StorageT const& __ref) const + { return _M_pred(cast_traits::to_value_type_cref(__ref)); } + +private: + _UnaryPredicate _M_pred; +}; + +template +struct _BinaryPredWrapper { + typedef _CastTraits<_StorageT, _ValueT> cast_traits; + + _BinaryPredWrapper () {} + _BinaryPredWrapper (_BinaryPredicate const& __pred) : _M_pred(__pred) {} + + _BinaryPredicate get_pred() const { return _M_pred; } + + bool operator () (_StorageT const& __fst, _StorageT const& __snd) const + { return _M_pred(cast_traits::to_value_type_cref(__fst), cast_traits::to_value_type_cref(__snd)); } + + //Cast operator used to transparently access underlying predicate + //in set::key_comp() method + operator _BinaryPredicate() const + { return _M_pred; } + +private: + _BinaryPredicate _M_pred; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_POINTERS_SPEC_TOOLS_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/pointers/_vector.h b/sdk/tlibstdcxx/stlport/stl/pointers/_vector.h new file mode 100644 index 0000000000..64705bf248 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/pointers/_vector.h @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_SPECIALIZED_VECTOR_H +#define _STLP_SPECIALIZED_VECTOR_H + +#ifndef _STLP_POINTERS_SPEC_TOOLS_H +# include +#endif + +_STLP_BEGIN_NAMESPACE + +#define VECTOR_IMPL _STLP_PTR_IMPL_NAME(vector) + +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV _Vector_base >; +_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV VECTOR_IMPL >; +#endif + +#if defined (_STLP_DEBUG) +# define vector _STLP_NON_DBG_NAME(vector) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template ) > +class vector +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector) + : public __stlport_class > +#endif +{ + /* In the vector implementation iterators are pointer which give a number + * of opportunities for optimization. To not break those optimizations + * iterators passed to template should not be wrapped for casting purpose. + * So vector implementation will always use a qualified void pointer type and + * won't use iterator wrapping. + */ + typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_QualifiedType _StorageType; + typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc; + typedef _STLP_PRIV VECTOR_IMPL<_StorageType, _StorageTypeAlloc> _Base; + typedef vector<_Tp, _Alloc> _Self; + + typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits; + +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag _Iterator_category; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + _STLP_FORCE_ALLOCATORS(value_type, _Alloc) + typedef typename _Alloc_traits::allocator_type allocator_type; + + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); } + + iterator begin() { return cast_traits::to_value_type_ptr(_M_impl.begin()); } + const_iterator begin() const { return cast_traits::to_value_type_cptr(_M_impl.begin()); } + iterator end() { return cast_traits::to_value_type_ptr(_M_impl.end()); } + const_iterator end() const { return cast_traits::to_value_type_cptr(_M_impl.end()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + size_type size() const { return _M_impl.size(); } + size_type max_size() const { return _M_impl.max_size(); } + + size_type capacity() const { return _M_impl.capacity(); } + bool empty() const { return _M_impl.empty(); } + + reference operator[](size_type __n) { return cast_traits::to_value_type_ref(_M_impl[__n]); } + const_reference operator[](size_type __n) const { return cast_traits::to_value_type_cref(_M_impl[__n]); } + + reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); } + const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); } + reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); } + const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); } + + reference at(size_type __n) { return cast_traits::to_value_type_ref(_M_impl.at(__n)); } + const_reference at(size_type __n) const { return cast_traits::to_value_type_cref(_M_impl.at(__n)); } + + explicit vector(const allocator_type& __a = allocator_type()) + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit vector(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type), +#else + vector(size_type __n, const value_type& __val, +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + const allocator_type& __a = allocator_type()) + : _M_impl(__n, cast_traits::to_storage_type_cref(__val), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + explicit vector(size_type __n) + : _M_impl(__n, allocator_type() ) {} +#endif + + vector(const _Self& __x) + : _M_impl(__x._M_impl) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + explicit vector(__move_source<_Self> src) + : _M_impl(__move_source<_Base>(src.get()._M_impl)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL ) + : _M_impl(__first, __last, + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template + vector(_InputIterator __first, _InputIterator __last) + : _M_impl(__first, __last) {} +# endif + +#else + vector(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last), + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} +#endif /* _STLP_MEMBER_TEMPLATES */ + + _Self& operator=(const _Self& __x) { _M_impl = __x._M_impl; return *this; } + + void reserve(size_type __n) {_M_impl.reserve(__n);} + void assign(size_type __n, const value_type& __val) + { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void assign(_InputIterator __first, _InputIterator __last) + { _M_impl.assign(__first, __last); } +#else + void assign(const_iterator __first, const_iterator __last) { + _M_impl.assign(cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + void push_back(const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void push_back(const value_type& __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + iterator insert(iterator __pos, const value_type& __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { return cast_traits::to_value_type_ptr(_M_impl.insert(cast_traits::to_storage_type_ptr(__pos), + cast_traits::to_storage_type_cref(__x))); } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + void push_back() { _M_impl.push_back(); } + iterator insert(iterator __pos) + { return _M_impl.insert(cast_traits::to_storage_type_ptr(__pos)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + void swap(_Self& __x) { _M_impl.swap(__x._M_impl); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) + { _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __first, __last); } +#else + void insert(iterator __pos, const_iterator __first, const_iterator __last) { + _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), cast_traits::to_storage_type_cptr(__first), + cast_traits::to_storage_type_cptr(__last)); + } +#endif + + void insert (iterator __pos, size_type __n, const value_type& __x) { + _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __n, cast_traits::to_storage_type_cref(__x)); + } + + void pop_back() {_M_impl.pop_back();} + iterator erase(iterator __pos) + {return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__pos)));} + iterator erase(iterator __first, iterator __last) { + return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__first), + cast_traits::to_storage_type_ptr(__last))); + } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) +#else + void resize(size_type __new_size, const value_type& __x) +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); } + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { _M_impl.resize(__new_size); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void clear() { _M_impl.clear(); } + +private: + _Base _M_impl; +}; + +#if defined (vector) +# undef vector +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#undef VECTOR_IMPL + +_STLP_END_NAMESPACE + +#endif /* _STLP_SPECIALIZED_VECTOR_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/type_manips.h b/sdk/tlibstdcxx/stlport/stl/type_manips.h new file mode 100644 index 0000000000..410b59d256 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/type_manips.h @@ -0,0 +1,321 @@ +/* + * + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +#ifndef _STLP_TYPE_MANIPS_H +#define _STLP_TYPE_MANIPS_H + +_STLP_BEGIN_NAMESPACE + +struct __true_type {}; +struct __false_type {}; + +#if defined (_STLP_USE_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE) +_STLP_MOVE_TO_PRIV_NAMESPACE +using _STLP_STD::__true_type; +using _STLP_STD::__false_type; +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +//bool to type +template +struct __bool2type +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct __bool2type<1> { typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct __bool2type<0> { typedef __false_type _Ret; }; + +//type to bool +template +struct __type2bool { enum {_Ret = 1}; }; + +_STLP_TEMPLATE_NULL +struct __type2bool<__true_type> { enum {_Ret = 1}; }; + +_STLP_TEMPLATE_NULL +struct __type2bool<__false_type> { enum {_Ret = 0}; }; + +//Negation +template +struct _Not { typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Not<__false_type> { typedef __true_type _Ret; }; + +// logical and of 2 predicated +template +struct _Land2 { typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Land2<__true_type, __true_type> { typedef __true_type _Ret; }; + +// logical and of 3 predicated +template +struct _Land3 { typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Land3<__true_type, __true_type, __true_type> { typedef __true_type _Ret; }; + +//logical or of 2 predicated +template +struct _Lor2 { typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Lor2<__false_type, __false_type> { typedef __false_type _Ret; }; + +// logical or of 3 predicated +template +struct _Lor3 { typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Lor3<__false_type, __false_type, __false_type> { typedef __false_type _Ret; }; + +//////////////////////////////////////////////////////////////////////////////// +// class template __select +// Selects one of two types based upon a boolean constant +// Invocation: __select<_Cond, T, U>::Result +// where: +// flag is a compile-time boolean constant +// T and U are types +// Result evaluates to T if flag is true, and to U otherwise. +//////////////////////////////////////////////////////////////////////////////// +// BEWARE: If the compiler do not support partial template specialization or nested template +//classes the default behavior of the __select is to consider the condition as false and so return +//the second template type!! + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if defined (__BORLANDC__) +template +struct __selectT { typedef _Tp1 _Ret; }; + +template +struct __selectT<__false_type, _Tp1, _Tp2> { typedef _Tp2 _Ret; }; +# endif + +# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x590) +template +struct __select { typedef _Tp1 _Ret; }; + +template +struct __select { typedef _Tp2 _Ret; }; +# else +template +struct __select +{ typedef __selectT::_Ret, _Tp1, _Tp2>::_Ret _Ret; }; +# endif + +#else + +# if defined (_STLP_MEMBER_TEMPLATE_CLASSES) +template +struct __select_aux { + template + struct _In { + typedef _Tp1 _Ret; + }; +}; + +_STLP_TEMPLATE_NULL +struct __select_aux<0> { + template + struct _In { + typedef _Tp2 _Ret; + }; +}; + +template +struct __select { + typedef typename __select_aux<_Cond>::_STLP_TEMPLATE _In<_Tp1, _Tp2>::_Ret _Ret; +}; +# else /* _STLP_MEMBER_TEMPLATE_CLASSES */ +//default behavior +template +struct __select { + typedef _Tp2 _Ret; +}; +# endif /* _STLP_MEMBER_TEMPLATE_CLASSES */ + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +/* Rather than introducing a new macro for the following constrution we use + * an existing one (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) that + * is used for a similar feature. + */ +#if !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && \ + (!defined (__GNUC__) || (__GNUC__ > 2)) +// Helper struct that will forbid volatile qualified types: +# if !defined (__BORLANDC__) +struct _NoVolatilePointerShim { _NoVolatilePointerShim(const void*); }; +template +char _STLP_CALL _IsCopyableFun(bool, _NoVolatilePointerShim, _Tp const*, _Tp*); // no implementation is required +char* _STLP_CALL _IsCopyableFun(bool, ...); // no implementation is required + +template +struct _Copyable { + static _Src* __null_src(); + static _Dst* __null_dst(); + enum { _Ret = (sizeof(_IsCopyableFun(false, __null_src(), __null_src(), __null_dst())) == sizeof(char)) }; + typedef typename __bool2type<_Ret>::_Ret _RetT; +}; +# else +template struct _AreSameTypes; +template struct _IsUnQual; +template +struct _Copyable { + typedef typename _AreSameTypes<_Src, _Dst>::_Ret _Tr1; + typedef typename _IsUnQual<_Dst>::_Ret _Tr2; + typedef typename _Land2<_Tr1, _Tr2>::_Ret _RetT; + enum { _Ret = __type2bool<_RetT>::_Ret }; +}; +# endif +#else +template +struct _Copyable { + enum { _Ret = 0 }; + typedef __false_type _RetT; +}; +#endif + +/* + * The following struct will tell you if 2 types are the same and if copying memory + * from the _Src type to the _Dst type is right considering qualifiers. If _Src and + * _Dst types are the same unqualified types _Ret will be false if: + * - any of the type has the volatile qualifier + * - _Dst is const qualified + */ +template +struct _AreCopyable { + enum { _Same = _Copyable<_Src, _Dst>::_Ret }; + typedef typename _Copyable<_Src, _Dst>::_RetT _Ret; +}; + +template +struct _AreSameTypes { + enum { _Same = 0 }; + typedef __false_type _Ret; +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct _AreSameTypes<_Tp, _Tp> { + enum { _Same = 1 }; + typedef __true_type _Ret; +}; +#endif + +#if !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +template +struct _ConversionHelper { + static char _Test(bool, _Dst); + static char* _Test(bool, ...); + static _Src _MakeSource(); +}; + +template +struct _IsConvertible { + typedef _ConversionHelper<_Src*, const volatile _Dst*> _H; + enum { value = (sizeof(char) == sizeof(_H::_Test(false, _H::_MakeSource()))) }; + typedef typename __bool2type::_Ret _Ret; +}; + +# if defined (__BORLANDC__) +# if (__BORLANDC__ < 0x590) +template +struct _UnConstPtr { typedef _Tp _Type; }; + +template +struct _UnConstPtr<_Tp*> { typedef _Tp _Type; }; + +template +struct _UnConstPtr { typedef _Tp _Type; }; +# endif + +# if !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +template +struct _IsConst { typedef __false_type _Ret; }; +# else +template +struct _IsConst { typedef _AreSameTypes<_Tp, const _Tp>::_Ret _Ret; }; +# endif + +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +template +struct _IsConst { typedef __true_type _Ret; }; +# endif + +# if (__BORLANDC__ < 0x590) +template +struct _IsConst<_Tp*> { typedef _AreSameTypes<_Tp*, const _Tp*>::_Ret _Ret; }; +# endif +template +struct _IsVolatile { typedef _AreSameTypes<_Tp, volatile _Tp>::_Ret _Ret; }; + +template +struct _IsUnQual { + typedef _IsConst<_Tp>::_Ret _Tr1; + typedef _IsVolatile<_Tp>::_Ret _Tr2; + typedef _Not<_Tr1>::_Ret _NotCon; + typedef _Not<_Tr2>::_Ret _NotVol; + typedef _Land2<_NotCon, _NotVol>::_Ret _Ret; +}; + +# if !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +template struct _UnQual { typedef _Tp _Type; }; +template struct _UnQual { typedef _Tp _Type; }; +template struct _UnQual { typedef _Tp _Type; }; +template struct _UnQual { typedef _Tp _Type; }; +# endif +# endif + +/* This struct is intended to say if a pointer can be convertible to an other + * taking into account cv qualifications. It shouldn't be instanciated with + * something else than pointer type as it uses pass by value parameter that + * results in compilation error when parameter type has a special memory + * alignment + */ +template +struct _IsCVConvertible { +# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x590) + typedef _ConversionHelper<_Src, _Dst> _H; + enum { value = (sizeof(char) == sizeof(_H::_Test(false, _H::_MakeSource()))) }; +# else + enum { _Is1 = __type2bool<_IsConst<_Src>::_Ret>::_Ret }; + enum { _Is2 = _IsConvertible<_UnConstPtr<_Src>::_Type, _UnConstPtr<_Dst>::_Type>::value }; + enum { value = _Is1 ? 0 : _Is2 }; +# endif + typedef typename __bool2type::_Ret _Ret; +}; + +#else +template +struct _IsConvertible { + enum { value = 0 }; + typedef __false_type _Ret; +}; + +template +struct _IsCVConvertible { + enum { value = 0 }; + typedef __false_type _Ret; +}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_TYPE_MANIPS_H */ diff --git a/sdk/tlibstdcxx/stlport/stl/type_traits.h b/sdk/tlibstdcxx/stlport/stl/type_traits.h new file mode 100644 index 0000000000..af0923d03d --- /dev/null +++ b/sdk/tlibstdcxx/stlport/stl/type_traits.h @@ -0,0 +1,626 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_TYPE_TRAITS_H +#define _STLP_TYPE_TRAITS_H + +/* +This header file provides a framework for allowing compile time dispatch +based on type attributes. This is useful when writing template code. +For example, when making a copy of an array of an unknown type, it helps +to know if the type has a trivial copy constructor or not, to help decide +if a memcpy can be used. + +The class template __type_traits provides a series of typedefs each of +which is either __true_type or __false_type. The argument to +__type_traits can be any type. The typedefs within this template will +attain their correct values by one of these means: + 1. The general instantiation contain conservative values which work + for all types. + 2. Specializations may be declared to make distinctions between types. + 3. Some compilers (such as the Silicon Graphics N32 and N64 compilers) + will automatically provide the appropriate specializations for all + types. + +EXAMPLE: + +//Copy an array of elements which have non-trivial copy constructors +template void copy(T* source, T* destination, int n, __false_type); +//Copy an array of elements which have trivial copy constructors. Use memcpy. +template void copy(T* source, T* destination, int n, __true_type); + +//Copy an array of any type by using the most efficient copy mechanism +template inline void copy(T* source,T* destination,int n) { + copy(source, destination, n, + typename __type_traits::has_trivial_copy_constructor()); +} +*/ + +#ifdef __WATCOMC__ +# include +#endif + +#ifndef _STLP_TYPE_MANIPS_H +# include +#endif + +#ifdef _STLP_USE_BOOST_SUPPORT +# include +# include +# include +#endif /* _STLP_USE_BOOST_SUPPORT */ + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_USE_BOOST_SUPPORT) + +// The following could be written in terms of numeric_limits. +// We're doing it separately to reduce the number of dependencies. + +template struct _IsIntegral +{ typedef __false_type _Ret; }; + +# ifndef _STLP_NO_BOOL +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; +# endif /* _STLP_NO_BOOL */ + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +# ifndef _STLP_NO_SIGNED_BUILTINS +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; +# endif + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +# if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; +# endif /* _STLP_HAS_WCHAR_T */ + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; + +# ifdef _STLP_LONG_LONG +_STLP_TEMPLATE_NULL struct _IsIntegral<_STLP_LONG_LONG> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral +{ typedef __true_type _Ret; }; +# endif /* _STLP_LONG_LONG */ + +template struct _IsRational +{ typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsRational +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsRational +{ typedef __true_type _Ret; }; + +# if !defined ( _STLP_NO_LONG_DOUBLE ) +_STLP_TEMPLATE_NULL struct _IsRational +{ typedef __true_type _Ret; }; +# endif + +// Forward declarations. +template struct __type_traits; +template struct __type_traits_aux { + typedef __false_type has_trivial_default_constructor; + typedef __false_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __false_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +_STLP_TEMPLATE_NULL +struct __type_traits_aux<__false_type> { + typedef __false_type has_trivial_default_constructor; + typedef __false_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __false_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +_STLP_TEMPLATE_NULL +struct __type_traits_aux<__true_type> { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +template +struct _IsRef { + typedef __false_type _Ret; +}; + +# if defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +/* + * Boris : simulation technique is used here according to Adobe Open Source License Version 1.0. + * Copyright 2000 Adobe Systems Incorporated and others. All rights reserved. + * Authors: Mat Marcus and Jesse Jones + * The original version of this source code may be found at + * http://opensource.adobe.com. + */ + +struct _PointerShim { + /* + * Since the compiler only allows at most one non-trivial + * implicit conversion we can make use of a shim class to + * be sure that IsPtr below doesn't accept classes with + * implicit pointer conversion operators + */ + _PointerShim(const volatile void*); // no implementation +}; + +// These are the discriminating functions +char _STLP_CALL _IsP(bool, _PointerShim); // no implementation is required +char* _STLP_CALL _IsP(bool, ...); // no implementation is required + +template +struct _IsPtr { + /* + * This template meta function takes a type T + * and returns true exactly when T is a pointer. + * One can imagine meta-functions discriminating on + * other criteria. + */ + static _Tp& __null_rep(); + enum { _Ptr = (sizeof(_IsP(false,__null_rep())) == sizeof(char)) }; + typedef typename __bool2type<_Ptr>::_Ret _Ret; + +}; + +// we make general case dependant on the fact the type is actually a pointer. +template +struct __type_traits : __type_traits_aux::_Ret> {}; + +# else /* _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS */ + +template struct _IsPtr { + typedef __false_type _Ret; +}; + +template +struct __type_traits { + typedef __true_type this_dummy_member_must_be_first; + /* Do not remove this member. It informs a compiler which + automatically specializes __type_traits that this + __type_traits template is special. It just makes sure that + things work if an implementation is using a template + called __type_traits for something unrelated. */ + + /* The following restrictions should be observed for the sake of + compilers which automatically produce type specific specializations + of this class: + - You may reorder the members below if you wish + - You may remove any of the members below if you wish + - You must not rename members without making the corresponding + name change in the compiler + - Members you add will be treated like regular members unless + + you add the appropriate support in the compiler. */ +# if !defined (_STLP_HAS_TYPE_TRAITS_INTRINSICS) + typedef __false_type has_trivial_default_constructor; + typedef __false_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __false_type has_trivial_destructor; + typedef __false_type is_POD_type; +# else + typedef typename __bool2type<_STLP_HAS_TRIVIAL_CONSTRUCTOR(_Tp)>::_Ret has_trivial_default_constructor; + typedef typename __bool2type<_STLP_HAS_TRIVIAL_COPY(_Tp)>::_Ret has_trivial_copy_constructor; + typedef typename __bool2type<_STLP_HAS_TRIVIAL_ASSIGN(_Tp)>::_Ret has_trivial_assignment_operator; + typedef typename __bool2type<_STLP_HAS_TRIVIAL_DESTRUCTOR(_Tp)>::_Ret has_trivial_destructor; + typedef typename __bool2type<_STLP_IS_POD(_Tp)>::_Ret is_POD_type; +# endif +}; + +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template struct _IsPtr<_Tp*> +{ typedef __true_type _Ret; }; +template struct _IsRef<_Tp&> +{ typedef __true_type _Ret; }; + +template struct __type_traits<_Tp*> : __type_traits_aux<__true_type> +{}; +# endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +# endif /* _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS */ + +// Provide some specializations. This is harmless for compilers that +// have built-in __types_traits support, and essential for compilers +// that don't. +# if !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +# define _STLP_DEFINE_TYPE_TRAITS_FOR(Type) \ +_STLP_TEMPLATE_NULL struct __type_traits< Type > : __type_traits_aux<__true_type> {}; \ +_STLP_TEMPLATE_NULL struct __type_traits< const Type > : __type_traits_aux<__true_type> {}; \ +_STLP_TEMPLATE_NULL struct __type_traits< volatile Type > : __type_traits_aux<__true_type> {}; \ +_STLP_TEMPLATE_NULL struct __type_traits< const volatile Type > : __type_traits_aux<__true_type> {} +# else +# define _STLP_DEFINE_TYPE_TRAITS_FOR(Type) \ +_STLP_TEMPLATE_NULL struct __type_traits< Type > : __type_traits_aux<__true_type> {}; +# endif + +# ifndef _STLP_NO_BOOL +_STLP_DEFINE_TYPE_TRAITS_FOR(bool); +# endif /* _STLP_NO_BOOL */ +_STLP_DEFINE_TYPE_TRAITS_FOR(char); +# ifndef _STLP_NO_SIGNED_BUILTINS +_STLP_DEFINE_TYPE_TRAITS_FOR(signed char); +# endif +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned char); +# if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) +_STLP_DEFINE_TYPE_TRAITS_FOR(wchar_t); +# endif /* _STLP_HAS_WCHAR_T */ + +_STLP_DEFINE_TYPE_TRAITS_FOR(short); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned short); +_STLP_DEFINE_TYPE_TRAITS_FOR(int); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned int); +_STLP_DEFINE_TYPE_TRAITS_FOR(long); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned long); + +# ifdef _STLP_LONG_LONG +_STLP_DEFINE_TYPE_TRAITS_FOR(_STLP_LONG_LONG); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned _STLP_LONG_LONG); +# endif /* _STLP_LONG_LONG */ + +_STLP_DEFINE_TYPE_TRAITS_FOR(float); +_STLP_DEFINE_TYPE_TRAITS_FOR(double); + +# if !defined ( _STLP_NO_LONG_DOUBLE ) +_STLP_DEFINE_TYPE_TRAITS_FOR(long double); +# endif + +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct _IsCVConvertibleIf +{ typedef typename _IsCVConvertible<_Src, _Dst>::_Ret _Ret; }; + +template +struct _IsCVConvertibleIf<__false_type, _Src, _Dst> +{ typedef __false_type _Ret; }; +# else +# if defined (_STLP_MEMBER_TEMPLATE_CLASSES) +template +struct _IsCVConvertibleIfAux { + template + struct _In + { typedef typename _IsCVConvertible<_Src, _Dst>::_Ret _Ret; }; +}; + +_STLP_TEMPLATE_NULL +struct _IsCVConvertibleIfAux<__false_type> { + template + struct _In + { typedef __false_type _Ret; }; +}; + +template +struct _IsCVConvertibleIf { + typedef typename _IsCVConvertibleIfAux<_ArePtrs>::_STLP_TEMPLATE _In<_Src, _Dst>::_Ret _Ret; +}; +# else +/* default behavior: we prefer to miss an optimization rather than taking the risk of + * a compilation error if playing with types with exotic memory alignment. + */ +template +struct _IsCVConvertibleIf +{ typedef __false_type _Ret; }; +# endif +# endif + +template +struct _TrivialNativeTypeCopy { + typedef typename _IsPtr<_Src>::_Ret _Ptr1; + typedef typename _IsPtr<_Dst>::_Ret _Ptr2; + typedef typename _Land2<_Ptr1, _Ptr2>::_Ret _BothPtrs; + typedef typename _IsCVConvertibleIf<_BothPtrs, _Src, _Dst>::_Ret _Convertible; + typedef typename _Land2<_BothPtrs, _Convertible>::_Ret _Trivial1; + + typedef typename __bool2type<(sizeof(_Src) == sizeof(_Dst))>::_Ret _SameSize; + +#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x564) + typedef typename _IsIntegral<_Src>::_Ret _Int1; +#else + typedef typename _UnQual<_Src>::_Type _UnQuSrc; + typedef typename _IsIntegral<_UnQuSrc>::_Ret _Int1; +#endif + typedef typename _IsIntegral<_Dst>::_Ret _Int2; + typedef typename _Land2<_Int1, _Int2>::_Ret _BothInts; + + typedef typename _IsRational<_Src>::_Ret _Rat1; + typedef typename _IsRational<_Dst>::_Ret _Rat2; + typedef typename _Land2<_Rat1, _Rat2>::_Ret _BothRats; + + typedef typename _Lor2<_BothInts, _BothRats>::_Ret _BothNatives; +#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564) + typedef typename _Land2<_BothNatives, _SameSize>::_Ret _Trivial2; +#else + typedef typename _IsUnQual<_Dst>::_Ret _UnQualDst; + typedef typename _Land3<_BothNatives, _SameSize, _UnQualDst>::_Ret _Trivial2; +#endif + typedef typename _Lor2<_Trivial1, _Trivial2>::_Ret _Ret; +}; + +template +struct _TrivialCopy { + typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet; +# if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) + typedef typename __type_traits<_Src>::has_trivial_assignment_operator _Tr1; +# else + typedef typename _UnConstPtr<_Src*>::_Type _UnConstSrc; + typedef typename __type_traits<_UnConstSrc>::has_trivial_assignment_operator _Tr1; +# endif + typedef typename _AreCopyable<_Src, _Dst>::_Ret _Tr2; + typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet; + typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template +struct _TrivialUCopy { + typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet; +# if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) + typedef typename __type_traits<_Src>::has_trivial_copy_constructor _Tr1; +# else + typedef typename _UnConstPtr<_Src*>::_Type _UnConstSrc; + typedef typename __type_traits<_UnConstSrc>::has_trivial_copy_constructor _Tr1; +# endif + typedef typename _AreCopyable<_Src, _Dst>::_Ret _Tr2; + typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet; + typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template +struct _DefaultZeroValue { + typedef typename _IsIntegral<_Tp>::_Ret _Tr1; + typedef typename _IsRational<_Tp>::_Ret _Tr2; + typedef typename _IsPtr<_Tp>::_Ret _Tr3; + typedef typename _Lor3<_Tr1, _Tr2, _Tr3>::_Ret _Ret; +}; + +template +struct _TrivialInit { +# if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) + typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Tr1; +# else + typedef typename _UnConstPtr<_Tp*>::_Type _Tp1; + typedef typename __type_traits<_Tp1>::has_trivial_copy_constructor _Tr1; +# endif + typedef typename _DefaultZeroValue<_Tp>::_Ret _Tr2; + typedef typename _Not<_Tr2>::_Ret _Tr3; + typedef typename _Land2<_Tr1, _Tr3>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +#endif /* !_STLP_USE_BOOST_SUPPORT */ + +template +struct _IsPtrType { + typedef typename _IsPtr<_Tp>::_Ret _Type; + static _Type _Ret() { return _Type(); } +}; + +template +struct _IsRefType { + typedef typename _IsRef<_Tp>::_Ret _Type; + static _Type _Ret() { return _Type();} +}; + +template +struct __call_traits { +#if defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS) + typedef typename __select< ::boost::is_reference<_Tp>::value, + typename ::boost::add_const<_Tp>::type, + typename ::boost::add_reference< typename ::boost::add_const<_Tp>::type >::type>::_Ret const_param_type; + typedef typename __select< ::boost::is_reference<_Tp>::value, + typename ::boost::remove_const<_Tp>::type, + typename ::boost::add_reference<_Tp>::type>::_Ret param_type; +#else + typedef const _Tp& const_param_type; + typedef _Tp& param_type; +#endif +}; + +#if !defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS) && defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template +struct __call_traits<_Tp&> { + typedef _Tp& param_type; + typedef const _Tp& const_param_type; +}; +template +struct __call_traits { + typedef _Tp& param_type; + typedef const _Tp& const_param_type; +}; +#endif + +template +struct _BothPtrType { + typedef typename _IsPtr<_Tp1>::_Ret _IsPtr1; + typedef typename _IsPtr<_Tp2>::_Ret _IsPtr2; + + typedef typename _Land2<_IsPtr1, _IsPtr2>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template +struct _OKToSwap { + typedef typename _AreSameTypes<_Tp1, _Tp2>::_Ret _Same; + typedef typename _Land3<_Same, _IsRef1, _IsRef2>::_Ret _Type; + static _Type _Answer() { return _Type(); } +}; + +template +inline _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2> +_IsOKToSwap(_Tp1*, _Tp2*, const _IsRef1&, const _IsRef2&) +{ return _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2>(); } + +template +inline _TrivialCopy<_Src, _Dst> _UseTrivialCopy(_Src*, _Dst*) +{ return _TrivialCopy<_Src, _Dst>(); } + +template +inline _TrivialUCopy<_Src, _Dst> _UseTrivialUCopy(_Src*, _Dst*) +{ return _TrivialUCopy<_Src, _Dst>(); } + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) || defined (__BORLANDC__) || \ + defined (__DMC__) +struct _NegativeAnswer { + typedef __false_type _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template +inline _NegativeAnswer _UseTrivialCopy(_Src*, const _Dst*) +{ return _NegativeAnswer(); } + +template +inline _NegativeAnswer _UseTrivialCopy(_Src*, volatile _Dst*) +{ return _NegativeAnswer(); } + +template +inline _NegativeAnswer _UseTrivialCopy(_Src*, const volatile _Dst*) +{ return _NegativeAnswer(); } + +template +inline _NegativeAnswer _UseTrivialUCopy(_Src*, const _Dst*) +{ return _NegativeAnswer(); } + +template +inline _NegativeAnswer _UseTrivialUCopy(_Src*, volatile _Dst*) +{ return _NegativeAnswer(); } + +template +inline _NegativeAnswer _UseTrivialUCopy(_Src*, const volatile _Dst*) +{ return _NegativeAnswer(); } +#endif + +template +inline _TrivialInit<_Tp> _UseTrivialInit(_Tp*) +{ return _TrivialInit<_Tp>(); } + +template +struct _IsPOD { + typedef typename __type_traits<_Tp>::is_POD_type _Type; + static _Type _Answer() { return _Type(); } +}; + +template +inline _IsPOD<_Tp> _Is_POD(_Tp*) +{ return _IsPOD<_Tp>(); } + +template +struct _DefaultZeroValueQuestion { + typedef typename _DefaultZeroValue<_Tp>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template +inline _DefaultZeroValueQuestion<_Tp> _HasDefaultZeroValue(_Tp*) +{ return _DefaultZeroValueQuestion<_Tp>(); } + +/* + * Base class used: + * - to simulate partial template specialization + * - to simulate partial function ordering + * - to recognize STLport class from user specialized one + */ +template +struct __stlport_class +{ typedef _Tp _Type; }; + +template +struct _IsSTLportClass { + typedef typename _IsConvertible<_Tp, __stlport_class<_Tp> >::_Ret _Ret; +#if defined (__BORLANDC__) + enum { _Is = _IsConvertible<_Tp, __stlport_class<_Tp> >::value }; +#endif +}; + +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template +struct _SwapImplemented { + typedef typename _IsSTLportClass<_Tp>::_Ret _Ret; +# if defined (__BORLANDC__) + enum { _Is = _IsSTLportClass<_Tp>::_Is }; +# endif +}; +#endif + +template +class _TpWithState : private _Tp { + _TpWithState(); + int _state; +}; + +/* This is an internal helper struct used to guess if we are working + * on a stateless class. It can only be instanciated with a class type. */ +template +struct _IsStateless { + enum { _Is = sizeof(_TpWithState<_Tp>) == sizeof(int) }; + typedef typename __bool2type<_Is>::_Ret _Ret; +}; + +_STLP_END_NAMESPACE + +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION +# if defined (__BORLANDC__) || \ + defined (__SUNPRO_CC) || \ + (defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \ + (defined (__sgi) && defined (_COMPILER_VERSION)) || \ + defined (__DMC__) +# define _STLP_IS_POD_ITER(_It, _Tp) __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type() +# else +# define _STLP_IS_POD_ITER(_It, _Tp) typename __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type() +# endif +#else +# define _STLP_IS_POD_ITER(_It, _Tp) _Is_POD( _STLP_VALUE_TYPE( _It, _Tp ) )._Answer() +#endif + +#endif /* _STLP_TYPE_TRAITS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/string b/sdk/tlibstdcxx/stlport/string new file mode 100644 index 0000000000..74d458951e --- /dev/null +++ b/sdk/tlibstdcxx/stlport/string @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STRING + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x68 +# include +# define _STLP_STRING +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x68) +# ifndef _STLP_INTERNAL_STRING_H +# include +# endif + +# ifndef _STLP_STRING_HASH_H +# include +# endif + +# if !defined (_STLP_USE_NO_IOSTREAMS) && !defined (_STLP_STRING_IO_H) +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x68) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(string) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x68) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_STRING */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/string.h b/sdk/tlibstdcxx/stlport/string.h new file mode 100644 index 0000000000..52013cfb40 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/string.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include string.h, which results in warnings and errors + */ +#ifndef _STLP_STRING_H + +#if !defined (RC_INVOKED) + +# ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x269 +# include +# elif (_STLP_OUTERMOST_HEADER_ID == 0x269) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_STRING_H +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif +# if (_STLP_OUTERMOST_HEADER_ID != 0x269) || defined (_STLP_DONT_POP_HEADER_ID) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(string.h) +# endif +# else +# if defined (__BORLANDC__) && !defined (__linux__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <_str.h> +# else +# include _STLP_NATIVE_CPP_C_HEADER(_str.h) +# endif +# else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(string.h) +# endif +# endif +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x269) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif +#endif /* RC_INVOKED */ +#endif /* _STLP_STRING_H */ diff --git a/sdk/tlibstdcxx/stlport/time.h b/sdk/tlibstdcxx/stlport/time.h new file mode 100644 index 0000000000..e73aa85660 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/time.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x272 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x272) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#ifdef _STLP_WCE_EVC3 +/* only show message when directly including this file in a non-library build */ +# if !defined(__BUILDING_STLPORT) && (_STLP_OUTERMOST_HEADER_ID == 0x272) +# pragma message("eMbedded Visual C++ 3 doesn't have a time.h header; STLport won't include native time.h here") +# endif +#else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(time.h) +# endif +#endif + + +#if (_STLP_OUTERMOST_HEADER_ID == 0x272) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif diff --git a/sdk/tlibstdcxx/stlport/type_traits b/sdk/tlibstdcxx/stlport/type_traits new file mode 100644 index 0000000000..ae1ea8f186 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/type_traits @@ -0,0 +1,798 @@ +// -*- C++ -*- Time-stamp: <08/07/20 19:10:15 ptr> + +/* + * Copyright (c) 2007, 2008 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + * Derived from original of 'complement' project + * [http://complement.sourceforge.net] + * to make it close to JTC1/SC22/WG21 C++ 0x working draft + * [http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2008/n2521.pdf] + */ + +#ifndef __STLP_TYPE_TRAITS +#define __STLP_TYPE_TRAITS + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x3 +# include +#endif + +// libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, +// libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, +// while libstdc++ v3, 20050921 (4.0.2) not; use libstdc++ instead +// # if defined(STLPORT) || (defined(__GNUC__) && (__GNUC__ < 4)) /* !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) */ + +_STLP_BEGIN_NAMESPACE + +_STLP_BEGIN_TR1_NAMESPACE + +namespace detail { + +struct __select_types +{ + typedef char __t1; + struct __t2 + { + char __two[2]; + }; +}; + +template +struct __instance : + public __select_types +{ + private: + template + static __t1 __test(_Up(*)[1]); + + template + static __t2 __test(...); + + public: +#ifdef _STLP_STATIC_CONST_INIT_BUG + static const bool __value; +#else + static const bool __value = sizeof(__test<_Tp>(0)) == sizeof(__select_types::__t1); +#endif + +}; + +#ifdef _STLP_STATIC_CONST_INIT_BUG +template +const bool __instance<_Tp>::__value = sizeof(__instance<_Tp>::__test<_Tp>(0)) == sizeof(__select_types::__t1); +#endif + +template +struct __uoc_aux : // union or class + public __select_types +{ + private: + template + static __t1 __test( int _Up::* ); + + template + static __t2 __test(...); + + public: +#ifdef __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION + static const bool __value; +#else + static const bool __value = sizeof(__test(0)) == sizeof(__select_types::__t1); +#endif +}; + +#ifdef __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION +template +const bool __uoc_aux::__value = sizeof(__uoc_aux::__test(0)) == sizeof(__select_types::__t1); +#endif + +template +class __empty +{ }; + +template +class __inheritance_aux +{}; + +template +class __inheritance_aux : + public T +{ + public: + virtual ~__inheritance_aux() + { } +}; + +#if 0 +template +struct __virtual_aux +{ + public: +#ifdef _STLP_STATIC_CONST_INIT_BUG + static const bool __value; +#else + static const bool __value = B ? (sizeof(__inheritance_aux) == sizeof(T)) : false; +#endif +}; + +#ifdef _STLP_STATIC_CONST_INIT_BUG +template +const bool __virtual_aux::__value = B ? (sizeof(__inheritance_aux) == sizeof(T)) : false; +#endif +#endif + +} // namespace detail + +template +struct integral_constant +{ + static const _Tp value = __v; + // enum { value = __v }; ? + + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; +}; + +typedef integral_constant true_type; +typedef integral_constant false_type; + +namespace detail { + +template +struct __is_union_or_class : + public integral_constant::__value> +{ }; + +#if 0 +template +struct __is_vtbl : // has virtual table? + public integral_constant::value >::__value> +{ }; +#endif + +template +struct __is_vtbl : // has virtual table? + public integral_constant::value ? (sizeof(__inheritance_aux<_Tp,__is_union_or_class<_Tp>::value>) == sizeof(_Tp)) : false > +{ }; + +} // namespace detail + +#define __SPEC_(C,T,B) \ +template <> \ +struct C : \ + public integral_constant \ +{ } + +#define __CV_SPEC(C,T,B) \ +__SPEC_(C,T,B); \ +__SPEC_(C,const T,B); \ +__SPEC_(C,volatile T,B); \ +__SPEC_(C,const volatile T,B) + +#define __SPEC_1(C,T,B) \ +template \ +struct C : \ + public integral_constant \ +{ } + +#define __CV_SPEC_1(C,T,B) \ +__SPEC_1(C,T,B); \ +__SPEC_1(C,T const,B); \ +__SPEC_1(C,T volatile,B); \ +__SPEC_1(C,T const volatile,B) + +#define __SPEC_2(C,T,B) \ +template \ +struct C : \ + public integral_constant \ +{ } + +#define __CV_SPEC_2(C,T,B) \ +__SPEC_2(C,T,B); \ +__SPEC_2(C,T const,B); \ +__SPEC_2(C,T volatile,B); \ +__SPEC_2(C,T const volatile,B) + +// [4.5.1] primary type categories: + +template +struct is_void : + public false_type +{ }; + +template <> +struct is_void : + public true_type +{ }; + +template +struct is_integral : + public false_type +{ }; + +__CV_SPEC(is_integral,bool,true); +__CV_SPEC(is_integral,char,true); +__CV_SPEC(is_integral,signed char,true); +__CV_SPEC(is_integral,unsigned char,true); +__CV_SPEC(is_integral,wchar_t,true); +__CV_SPEC(is_integral,short,true); +__CV_SPEC(is_integral,unsigned short,true); +__CV_SPEC(is_integral,int,true); +__CV_SPEC(is_integral,unsigned int,true); +__CV_SPEC(is_integral,long,true); +__CV_SPEC(is_integral,unsigned long,true); +__CV_SPEC(is_integral,long long,true); +__CV_SPEC(is_integral,unsigned long long,true); + +template +struct is_floating_point : + public false_type +{ }; + +__CV_SPEC(is_floating_point,float,true); +__CV_SPEC(is_floating_point,double,true); +__CV_SPEC(is_floating_point,long double,true); + +template +struct is_array : + public false_type +{ }; + +template +struct is_array<_Tp[_Sz]> : + public true_type +{ }; + +template +struct is_array<_Tp[]> : + public true_type +{ }; + +template +struct is_pointer : + public false_type +{ }; + +__CV_SPEC_1(is_pointer,_Tp *,true); + +template +struct is_lvalue_reference : + public false_type +{ }; + +template +struct is_lvalue_reference<_Tp&> : + public true_type +{ }; + +template +struct is_rvalue_reference : + public false_type +{ }; + +// template +// struct is_rvalue_reference<_Tp&&> : +// public true_type +// { }; + +template +struct is_reference : + public false_type +{ }; + +template +struct is_reference<_Tp&> : + public true_type +{ }; + +template +struct is_function : + public integral_constant::__value + || detail::__is_union_or_class<_Tp>::value + || is_reference<_Tp>::value + || is_void<_Tp>::value)> +{ }; + +template +struct is_member_object_pointer : + public false_type +{ }; + +// _SPEC_FULL2(is_member_object_pointer, _Tp1 _Tp2::*,!is_function<_Tp1>::value); + +template +struct is_member_object_pointer<_Tp1 _Tp2::*> : + public integral_constant::value> +{ }; + +template +struct is_member_object_pointer<_Tp1 _Tp2::* const> : + public integral_constant::value> +{ }; + +template +struct is_member_object_pointer<_Tp1 _Tp2::* volatile> : + public integral_constant::value> +{ }; + +template +struct is_member_object_pointer<_Tp1 _Tp2::* const volatile> : + public integral_constant::value> +{ }; + +template +struct is_member_function_pointer : + public false_type +{ }; + +// _SPEC_FULL2(is_member_function_pointer,_Tp1 _Tp2::*,is_function<_Tp1>::value); + +template +struct is_member_function_pointer<_Tp1 _Tp2::*> : + public integral_constant::value> +{ }; + +template +struct is_member_function_pointer<_Tp1 _Tp2::* const> : + public integral_constant::value> +{ }; + +template +struct is_member_function_pointer<_Tp1 _Tp2::* volatile> : + public integral_constant::value> +{ }; + +template +struct is_member_function_pointer<_Tp1 _Tp2::* const volatile> : + public integral_constant::value> +{ }; + +template +struct is_member_pointer : + public integral_constant::value || is_member_function_pointer<_Tp>::value)> +{ }; + +// 4.5.2 composite type categories + +template +struct is_arithmetic : + public integral_constant::value || is_floating_point<_Tp>::value)> +{ }; + +template +struct is_fundamental : + public integral_constant::value || is_void<_Tp>::value)> +{ }; + +// [4.5.1] primary type categories (continued): + +template +struct is_enum : + public integral_constant::value + || is_array<_Tp>::value + || is_pointer<_Tp>::value + || is_reference<_Tp>::value + || is_member_pointer<_Tp>::value + || is_function<_Tp>::value + || detail::__is_union_or_class<_Tp>::value) > +{ }; + +template +struct is_union +{ }; + +template +struct is_class +{ }; + +// is_function (above) + +// 4.5.2 composite type categories (continued) + +// is_arithmetic (above) +// is_fundamental (above) + +template +struct is_object : + public integral_constant::value || + is_array<_Tp>::value || + is_pointer<_Tp>::value || + is_member_pointer<_Tp>::value || + detail::__is_union_or_class<_Tp>::value)> +{ }; + +template +struct is_scalar : + public integral_constant::value + || is_enum<_Tp>::value + || is_pointer<_Tp>::value + || is_member_pointer<_Tp>::value)> +{ }; + +template +struct is_compound : + public integral_constant::value> +{ }; + +// is_member_pointer + +// 4.5.3 type properties: + +template +struct is_const : + public false_type +{ }; + +template +struct is_const<_Tp const> : + public true_type +{ }; + +template +struct is_volatile : + public false_type +{ }; + +template +struct is_volatile<_Tp volatile> : + public true_type +{ }; + + +// 4.7.3 array modifications: + +template +struct remove_extent +{ + typedef _Tp type; +}; + +template +struct remove_extent<_Tp[_Sz]> +{ + typedef _Tp type; +}; + +template +struct remove_extent<_Tp[]> +{ + typedef _Tp type; +}; + +template +struct remove_all_extents +{ + typedef _Tp type; +}; + +template +struct remove_all_extents<_Tp[_Size]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +template +struct remove_all_extents<_Tp[]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +// 4.5.3 type properties (continued): + +template +struct is_trivial : + public integral_constant::value + || is_scalar::type>::value)> +{ }; + +template +struct is_standard_layout : + public integral_constant::value + || is_scalar::type>::value)> +{ }; + +template +struct is_pod : + public integral_constant::value + || is_scalar::type>::value)> +{ }; + +template +struct is_empty + : public integral_constant::value + && (sizeof(detail::__empty<_Tp>) == sizeof(_Tp)))> +{ }; + +// is_polimorphic +// is_abstract + +template +struct has_trivial_constructor : + public integral_constant::value> +{ }; + +template +struct has_trivial_copy : + public integral_constant::value> +{ }; + +template +struct has_trivial_assign : + public integral_constant::value> +{ }; + +template +struct has_trivial_destructor : + public integral_constant::value> +{ }; + +template +struct has_nothrow_constructor : + public integral_constant::value> +{ }; + +template +struct has_nothrow_copy : + public integral_constant::value> +{ }; + +template +struct has_nothrow_assign : + public integral_constant::value> +{ }; + +template +struct has_virtual_destructor : + public false_type +{ }; + +template +struct is_signed : + public false_type +{ }; + +__CV_SPEC(is_signed,signed char,true); +__CV_SPEC(is_signed,short,true); +__CV_SPEC(is_signed,int,true); +__CV_SPEC(is_signed,long,true); +__CV_SPEC(is_signed,long long,true); + +template +struct is_unsigned : + public false_type +{ }; + +__CV_SPEC(is_unsigned,unsigned char,true); +__CV_SPEC(is_unsigned,unsigned short,true); +__CV_SPEC(is_unsigned,unsigned int,true); +__CV_SPEC(is_unsigned,unsigned long,true); +__CV_SPEC(is_unsigned,unsigned long long,true); + +// alignment_of +// rank +// extent + +// 4.6 type relations: + +template +struct is_same : + public false_type +{ }; + +template +struct is_same<_Tp, _Tp> : + public true_type +{ }; + +// is_base_of +// is_convertible + +// 4.7.1 const-volatile modifications + +template +struct remove_const +{ + typedef _Tp type; +}; + +template +struct remove_const<_Tp const> +{ + typedef _Tp type; +}; + +template +struct remove_volatile +{ + typedef _Tp type; +}; + +template +struct remove_volatile<_Tp volatile> +{ + typedef _Tp type; +}; + +template +struct remove_cv +{ + typedef typename remove_const::type>::type type; +}; + +template +struct add_const +{ + typedef _Tp const type; +}; + +template +struct add_volatile +{ + typedef _Tp volatile type; +}; + +template +struct add_cv +{ + typedef typename add_const::type>::type type; +}; + +// 4.7.2 reference modifications: + +template +struct remove_reference +{ + typedef _Tp type; +}; + +template +struct remove_reference<_Tp&> +{ + typedef _Tp type; +}; + +template +struct add_reference +{ + typedef _Tp& type; +}; + +template +struct add_reference<_Tp&> +{ + typedef _Tp& type; +}; + +// 4.7.3 array modifications (see above) + +// 4.7.4 pointer modifications: + +template +struct remove_pointer +{ + typedef _Tp type; +}; + +template +struct remove_pointer<_Tp *> +{ + typedef _Tp type; +}; + +template +struct remove_pointer<_Tp * const> +{ + typedef _Tp type; +}; + +template +struct remove_pointer<_Tp * volatile> +{ + typedef _Tp type; +}; + +template +struct remove_pointer<_Tp * const volatile> +{ + typedef _Tp type; +}; + +template +struct add_pointer +{ + typedef typename remove_reference<_Tp>::type * type; +}; + +// 20.5.7 other transformations: + +// template <_STLP_STD::size_t Len, _STLP_STD::size_t Align> struct aligned_storage; +// template <_STLP_STD::size_t Len, class... Types> struct aligned_union; + +namespace detail { + +template +struct _decay_aux2 +{ + typedef typename remove_cv<_U>::type type; +}; + +template +struct _decay_aux2 +{ + typedef typename add_pointer<_U>::type type; +}; + +template +struct _decay_aux1 +{ + typedef typename _decay_aux2::value,_U>::type type; +}; + +template +struct _decay_aux1 +{ + typedef typename remove_extent<_U>::type* type; +}; + +} // namespace detail + +template +class decay +{ + private: + typedef typename remove_reference<_Tp>::type _U; + + public: + typedef typename detail::_decay_aux1::value,_U>::type type; +}; + +template +struct enable_if +{ +}; + +template +struct enable_if +{ + typedef _Tp type; +}; + +template +struct conditional +{ + typedef _Tp2 type; +}; + +template +struct conditional +{ + typedef _Tp1 type; +}; + +// template struct common_type; + +#undef __CV_SPEC +#undef __SPEC_ +#undef __CV_SPEC_1 +#undef __SPEC_1 +#undef __CV_SPEC_2 +#undef __SPEC_2 + +_STLP_END_NAMESPACE // tr1 + +_STLP_END_NAMESPACE + +// # else // __GLIBCXX__ && (__GNUC__ >= 4) && !STLPORT +// # include +// # endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x3) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif // __STLP_TYPE_TRAITS + diff --git a/sdk/tlibstdcxx/stlport/typeinfo b/sdk/tlibstdcxx/stlport/typeinfo new file mode 100644 index 0000000000..269123fce3 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/typeinfo @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_TYPEINFO + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x473 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x473) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_TYPEINFO +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x473) && !defined (_STLP_DONT_POP_HEADER_ID) +# ifndef _STLP_INTERNAL_TYPEINFO +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x473) || defined (_STLP_DONT_POP_HEADER_ID) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(typeinfo) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x473) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +#endif + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/typeinfo.h b/sdk/tlibstdcxx/stlport/typeinfo.h new file mode 100644 index 0000000000..3bc0f9be98 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/typeinfo.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +// DMC has hardcoded inclusion of typeinfo.h at the begining of any translation unit. +// So inclusion of this header will directly reference the native header. This is not +// a problem as typeinfo.h is neither a C nor C++ Standard header, this header should +// never be used in user code. +#if defined (__DMC__) +// We define _STLP_OUTERMOST_HEADER_ID to signal to other STLport headers that inclusion +// is done from native typeinfo.h (see exception header). +# define _STLP_OUTERMOST_HEADER_ID 0x874 +# include <../include/typeinfo.h> +# undef _STLP_OUTERMOST_HEADER_ID +#else +# ifndef _STLP_OLDSTD_typeinfo +# define _STLP_OLDSTD_typeinfo + +# ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x874 +# include +# endif + +# ifndef _STLP_NO_TYPEINFO + +# if defined (__GNUC__) +# undef _STLP_OLDSTD_typeinfo +# include +# define _STLP_OLDSTD_typeinfo +# else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# elif !defined (__BORLANDC__) || (__BORLANDC__ < 0x580) +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(typeinfo.h) +# else +# include _STLP_NATIVE_CPP_C_HEADER(typeinfo.h) +# endif +# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x580) || \ + defined (__DMC__) +using std::type_info; +using std::bad_typeid; +using std::bad_cast; +# endif +# endif + +// if already included, do not import anything + +# if defined (_STLP_USE_OWN_NAMESPACE) && !(defined (_STLP_TYPEINFO) && !defined (_STLP_NO_NEW_NEW_HEADER)) + +_STLP_BEGIN_NAMESPACE + +using _STLP_VENDOR_EXCEPT_STD :: type_info; +# if !(defined(__MRC__) || (defined(__SC__) && !defined(__DMC__))) +using _STLP_VENDOR_EXCEPT_STD :: bad_typeid; +# endif + +using _STLP_VENDOR_EXCEPT_STD :: bad_cast; + +_STLP_END_NAMESPACE + +# endif /* _STLP_OWN_NAMESPACE */ + +# endif /* _STLP_NO_TYPEINFO */ + +# if (_STLP_OUTERMOST_HEADER_ID == 0x874) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# endif + +# endif /* _STLP_OLDSTD_typeinfo */ + +#endif /* __DMC__ */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/unordered_map b/sdk/tlibstdcxx/stlport/unordered_map new file mode 100644 index 0000000000..09fa0d2493 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/unordered_map @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2004,2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_UNORDERED_MAP +#define _STLP_UNORDERED_MAP + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x4030 +# include +#endif + +#ifdef _STLP_PRAGMA_ONCE +# pragma once +#endif + +#include + +#if (_STLP_OUTERMOST_HEADER_ID == 0x4030) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_UNORDERED_MAP */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/unordered_set b/sdk/tlibstdcxx/stlport/unordered_set new file mode 100644 index 0000000000..14de437461 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/unordered_set @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2004,2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_UNORDERED_SET +#define _STLP_UNORDERED_SET + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x4031 +# include +#endif + +#ifdef _STLP_PRAGMA_ONCE +# pragma once +#endif + +#include + +#if (_STLP_OUTERMOST_HEADER_ID == 0x4031) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_UNORDERED_SET */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/using/cstring b/sdk/tlibstdcxx/stlport/using/cstring new file mode 100644 index 0000000000..bf6f024cfd --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/cstring @@ -0,0 +1,73 @@ +using _STLP_VENDOR_CSTD::size_t; + +#if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +# if defined (__MSL__) && __MC68K__ && !_No_BlockMove && __dest_os == __mac_os +# undef memcpy +# undef memmove +inline void* memcpy(void* dst, const void* src, size_t len) +{ return _STLP_VENDOR_CSTD::__memcpy(dst, src, len); } +inline void* memmove(void* dst, const void* src, size_t len) +{ return _STLP_VENDOR_CSTD::__memmove(dst, src, len); } +# else +using _STLP_VENDOR_CSTD::memmove; +using _STLP_VENDOR_CSTD::memcpy; +# endif + +# if !defined (_STLP_WCE) +// these functions just don't exist on Windows CE +using _STLP_VENDOR_CSTD::strcoll; +using _STLP_VENDOR_CSTD::strerror; +using _STLP_VENDOR_CSTD::strxfrm; +# endif + +# if defined (__BORLANDC__) +extern "C++" { +# endif +using _STLP_VENDOR_CSTD::memchr; +using _STLP_VENDOR_CSTD::strchr; +using _STLP_VENDOR_CSTD::strpbrk; +using _STLP_VENDOR_CSTD::strrchr; +using _STLP_VENDOR_CSTD::strstr; +# if defined (__BORLANDC__) +} +# endif + +inline char* strstr(char* __s1, const char* __s2) +{ + const char* s = __s1; + const char* p = _STLP_VENDOR_CSTD::strstr(s, __s2); + if (!p) return NULL; + return &__s1[p - s]; +} + +using _STLP_VENDOR_CSTD::memcmp; +using _STLP_VENDOR_CSTD::memset; + +#if !defined (_STLP_SGX_CONFIG) +using _STLP_VENDOR_CSTD::strcat; +#endif + +# if !defined (strcmp) || !defined (__BORLANDC__) +using _STLP_VENDOR_CSTD::strcmp; +# else +using ::strcmp; +# endif + +#if !defined (_STLP_SGX_CONFIG) +# if !defined (strcpy) || !defined (__BORLANDC__) +using _STLP_VENDOR_CSTD::strcpy; +# else +using ::strcpy; +# endif +#endif /* !_STLP_SGX_CONFIG */ + +using _STLP_VENDOR_CSTD::strcspn; +using _STLP_VENDOR_CSTD::strlen; +using _STLP_VENDOR_CSTD::strncat; +using _STLP_VENDOR_CSTD::strncmp; + +using _STLP_VENDOR_CSTD::strncpy; +using _STLP_VENDOR_CSTD::strspn; + +using _STLP_VENDOR_CSTD::strtok; +#endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ diff --git a/sdk/tlibstdcxx/stlport/using/export b/sdk/tlibstdcxx/stlport/using/export new file mode 100644 index 0000000000..2d3afcd9f5 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/export @@ -0,0 +1,12 @@ +cstring +fstream +iomanip +ios +iosfwd +iostream +istream +locale +ostream +sstream +streambuf +strstream diff --git a/sdk/tlibstdcxx/stlport/using/fstream b/sdk/tlibstdcxx/stlport/using/fstream new file mode 100644 index 0000000000..e79e0480f6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/fstream @@ -0,0 +1,19 @@ +#ifdef _STLP_BROKEN_USING_DIRECTIVE +using namespace _STLP_STD; +#else +using _STLP_NEW_IO_NAMESPACE::basic_filebuf; +using _STLP_NEW_IO_NAMESPACE::filebuf; +using _STLP_NEW_IO_NAMESPACE::basic_ifstream; +using _STLP_NEW_IO_NAMESPACE::basic_ofstream; +using _STLP_NEW_IO_NAMESPACE::ifstream; +using _STLP_NEW_IO_NAMESPACE::ofstream; +using _STLP_NEW_IO_NAMESPACE::basic_fstream; +using _STLP_NEW_IO_NAMESPACE::fstream; + +# ifndef _STLP_NO_WIDE_STREAMS +using _STLP_NEW_IO_NAMESPACE::wofstream; +using _STLP_NEW_IO_NAMESPACE::wfilebuf; +using _STLP_NEW_IO_NAMESPACE::wifstream; +using _STLP_NEW_IO_NAMESPACE::wfstream; +# endif +#endif diff --git a/sdk/tlibstdcxx/stlport/using/h/fstream.h b/sdk/tlibstdcxx/stlport/using/h/fstream.h new file mode 100644 index 0000000000..6600568955 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/h/fstream.h @@ -0,0 +1,4 @@ +using ::streambuf; +using ::ifstream; +using ::ofstream; +using ::fstream; diff --git a/sdk/tlibstdcxx/stlport/using/h/iomanip.h b/sdk/tlibstdcxx/stlport/using/h/iomanip.h new file mode 100644 index 0000000000..99e48d9980 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/h/iomanip.h @@ -0,0 +1,6 @@ +using ::setiosflags; +using ::resetiosflags; +// using ::setbase; +using ::setfill; +using ::setprecision; +using ::setw; diff --git a/sdk/tlibstdcxx/stlport/using/h/iostream.h b/sdk/tlibstdcxx/stlport/using/h/iostream.h new file mode 100644 index 0000000000..e85f4e2c74 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/h/iostream.h @@ -0,0 +1,24 @@ +using _STLP_OLD_IO_NAMESPACE::istream; +using _STLP_OLD_IO_NAMESPACE::ostream; + +/* HP aCC include files re-define these when THREAD_SAFE */ +#if !defined(cin) +using _STLP_OLD_IO_NAMESPACE::cin; +#endif +#if !defined(cout) +using _STLP_OLD_IO_NAMESPACE::cout; +#endif +#if !defined(cerr) +using _STLP_OLD_IO_NAMESPACE::cerr; +#endif +#if !defined(clog) +using _STLP_OLD_IO_NAMESPACE::clog; +#endif + +using _STLP_OLD_IO_NAMESPACE::endl; +using _STLP_OLD_IO_NAMESPACE::ends; + +using _STLP_OLD_IO_NAMESPACE::ios; +using _STLP_OLD_IO_NAMESPACE::flush; + +// using _STLP_OLD_IO_NAMESPACE::ws; diff --git a/sdk/tlibstdcxx/stlport/using/h/ostream.h b/sdk/tlibstdcxx/stlport/using/h/ostream.h new file mode 100644 index 0000000000..6ba3f88397 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/h/ostream.h @@ -0,0 +1,6 @@ +using _STLP_OLD_IO_NAMESPACE::ostream; +using _STLP_OLD_IO_NAMESPACE::endl; +using _STLP_OLD_IO_NAMESPACE::ends; +using _STLP_OLD_IO_NAMESPACE::flush; + +// using _STLP_OLD_IO_NAMESPACE::ws; diff --git a/sdk/tlibstdcxx/stlport/using/h/streambuf.h b/sdk/tlibstdcxx/stlport/using/h/streambuf.h new file mode 100644 index 0000000000..459de3dba2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/h/streambuf.h @@ -0,0 +1 @@ +using ::streambuf; diff --git a/sdk/tlibstdcxx/stlport/using/h/strstream.h b/sdk/tlibstdcxx/stlport/using/h/strstream.h new file mode 100644 index 0000000000..a7d9f119cb --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/h/strstream.h @@ -0,0 +1,4 @@ +using _STLP_OLD_IO_NAMESPACE::strstreambuf; +using _STLP_OLD_IO_NAMESPACE::istrstream; +using _STLP_OLD_IO_NAMESPACE::ostrstream; +using _STLP_OLD_IO_NAMESPACE::strstream; diff --git a/sdk/tlibstdcxx/stlport/using/iomanip b/sdk/tlibstdcxx/stlport/using/iomanip new file mode 100644 index 0000000000..8a7c792f85 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/iomanip @@ -0,0 +1,6 @@ +using _STLP_NEW_IO_NAMESPACE::setiosflags; +using _STLP_NEW_IO_NAMESPACE::resetiosflags; +using _STLP_NEW_IO_NAMESPACE::setbase; +using _STLP_NEW_IO_NAMESPACE::setfill; +using _STLP_NEW_IO_NAMESPACE::setprecision; +using _STLP_NEW_IO_NAMESPACE::setw; diff --git a/sdk/tlibstdcxx/stlport/using/ios b/sdk/tlibstdcxx/stlport/using/ios new file mode 100644 index 0000000000..d89b495ad2 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/ios @@ -0,0 +1,41 @@ +# ifdef _STLP_BROKEN_USING_DIRECTIVE +using namespace _STLP_NEW_IO_NAMESPACE; +# else + +using _STLP_NEW_IO_NAMESPACE::ios; +using _STLP_NEW_IO_NAMESPACE::streamoff; +using _STLP_NEW_IO_NAMESPACE::streamsize; + +using _STLP_NEW_IO_NAMESPACE::ios_base; +using _STLP_NEW_IO_NAMESPACE::basic_ios; + +// _lib.std.ios.manip_, manipulators: +using _STLP_NEW_IO_NAMESPACE::boolalpha; +using _STLP_NEW_IO_NAMESPACE::noboolalpha; +using _STLP_NEW_IO_NAMESPACE::showbase; +using _STLP_NEW_IO_NAMESPACE::noshowbase; +using _STLP_NEW_IO_NAMESPACE::showpoint; +using _STLP_NEW_IO_NAMESPACE::noshowpoint; +using _STLP_NEW_IO_NAMESPACE::showpos; +using _STLP_NEW_IO_NAMESPACE::noshowpos; +using _STLP_NEW_IO_NAMESPACE::skipws; +using _STLP_NEW_IO_NAMESPACE::noskipws; +using _STLP_NEW_IO_NAMESPACE::uppercase; +using _STLP_NEW_IO_NAMESPACE::nouppercase; + +// _lib.adjustfield.manip_ adjustfield: +using _STLP_NEW_IO_NAMESPACE::internal; +using _STLP_NEW_IO_NAMESPACE::left; +using _STLP_NEW_IO_NAMESPACE::right; + +// _lib.basefield.manip_ basefield: +using _STLP_NEW_IO_NAMESPACE::dec; +using _STLP_NEW_IO_NAMESPACE::hex; +using _STLP_NEW_IO_NAMESPACE::oct; + +// _lib.floatfield.manip_ floatfield: +using _STLP_NEW_IO_NAMESPACE::fixed; +using _STLP_NEW_IO_NAMESPACE::scientific; + +# endif /* _STLP_BROKEN_USING_DIRECTIVE */ + diff --git a/sdk/tlibstdcxx/stlport/using/iosfwd b/sdk/tlibstdcxx/stlport/using/iosfwd new file mode 100644 index 0000000000..b564e819f9 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/iosfwd @@ -0,0 +1,54 @@ +# if defined (_STLP_USE_NEW_IOSTREAMS) +using _STLP_NEW_IO_NAMESPACE::char_traits; +using _STLP_NEW_IO_NAMESPACE::basic_ios; +using _STLP_NEW_IO_NAMESPACE::basic_streambuf; +using _STLP_NEW_IO_NAMESPACE::basic_istream; +using _STLP_NEW_IO_NAMESPACE::basic_ostream; +using _STLP_NEW_IO_NAMESPACE::basic_iostream; +using _STLP_NEW_IO_NAMESPACE::basic_stringbuf; +using _STLP_NEW_IO_NAMESPACE::basic_istringstream; +using _STLP_NEW_IO_NAMESPACE::basic_ostringstream; +using _STLP_NEW_IO_NAMESPACE::basic_stringstream; +using _STLP_NEW_IO_NAMESPACE::basic_filebuf; +using _STLP_NEW_IO_NAMESPACE::basic_ifstream; +using _STLP_NEW_IO_NAMESPACE::basic_ofstream; +using _STLP_NEW_IO_NAMESPACE::basic_fstream; +using _STLP_NEW_IO_NAMESPACE::fpos; +using _STLP_NEW_IO_NAMESPACE::istreambuf_iterator; +using _STLP_NEW_IO_NAMESPACE::ostreambuf_iterator; +using _STLP_NEW_IO_NAMESPACE::stringbuf; +using _STLP_NEW_IO_NAMESPACE::istringstream; +using _STLP_NEW_IO_NAMESPACE::ostringstream; +using _STLP_NEW_IO_NAMESPACE::stringstream; +# endif + +using _STLP_NEW_IO_NAMESPACE::ios; +using _STLP_NEW_IO_NAMESPACE::streambuf; +using _STLP_NEW_IO_NAMESPACE::istream; +using _STLP_NEW_IO_NAMESPACE::ostream; +using _STLP_NEW_IO_NAMESPACE::iostream; + +using _STLP_NEW_IO_NAMESPACE::filebuf; +using _STLP_NEW_IO_NAMESPACE::ifstream; +using _STLP_NEW_IO_NAMESPACE::ofstream; +using _STLP_NEW_IO_NAMESPACE::fstream; + +using _STLP_NEW_IO_NAMESPACE::streampos; +using _STLP_NEW_IO_NAMESPACE::streamoff; + +# if !defined (_STLP_NO_WIDE_STREAMS) +using _STLP_NEW_IO_NAMESPACE::wios; +using _STLP_NEW_IO_NAMESPACE::wstreambuf; +using _STLP_NEW_IO_NAMESPACE::wistream; +using _STLP_NEW_IO_NAMESPACE::wostream; +using _STLP_NEW_IO_NAMESPACE::wiostream; +using _STLP_NEW_IO_NAMESPACE::wstringbuf; +using _STLP_NEW_IO_NAMESPACE::wistringstream; +using _STLP_NEW_IO_NAMESPACE::wostringstream; +using _STLP_NEW_IO_NAMESPACE::wstringstream; +using _STLP_NEW_IO_NAMESPACE::wfilebuf; +using _STLP_NEW_IO_NAMESPACE::wifstream; +using _STLP_NEW_IO_NAMESPACE::wofstream; +using _STLP_NEW_IO_NAMESPACE::wfstream; +using _STLP_NEW_IO_NAMESPACE::wstreampos; +# endif diff --git a/sdk/tlibstdcxx/stlport/using/iostream b/sdk/tlibstdcxx/stlport/using/iostream new file mode 100644 index 0000000000..6169afb2f6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/iostream @@ -0,0 +1,14 @@ + +# include + +using _STLP_VENDOR_STD::cin; +using _STLP_VENDOR_STD::cout; +using _STLP_VENDOR_STD::cerr; +using _STLP_VENDOR_STD::clog; + +# if ! defined (_STLP_NO_WIDE_STREAMS) +using _STLP_VENDOR_STD::wcin; +using _STLP_VENDOR_STD::wcout; +using _STLP_VENDOR_STD::wcerr; +using _STLP_VENDOR_STD::wclog; +# endif diff --git a/sdk/tlibstdcxx/stlport/using/istream b/sdk/tlibstdcxx/stlport/using/istream new file mode 100644 index 0000000000..baf10d2857 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/istream @@ -0,0 +1,16 @@ +# include + +using _STLP_NEW_IO_NAMESPACE::basic_istream; +using _STLP_NEW_IO_NAMESPACE::basic_iostream; + +using _STLP_NEW_IO_NAMESPACE::istream; +using _STLP_NEW_IO_NAMESPACE::iostream; + +# if !defined (_STLP_NO_NATIVE_WIDE_STREAMS) +using _STLP_NEW_IO_NAMESPACE::wistream; +using _STLP_NEW_IO_NAMESPACE::wiostream; +# endif + +#if !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200)) +using _STLP_NEW_IO_NAMESPACE::ws; +#endif diff --git a/sdk/tlibstdcxx/stlport/using/locale b/sdk/tlibstdcxx/stlport/using/locale new file mode 100644 index 0000000000..aa99b5bee4 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/locale @@ -0,0 +1,65 @@ +#if !defined(_STLP_NO_IMPORT_LOCALE) + +// from +#if !defined (_STLP_NO_MBSTATE_T) +using _STLP_VENDOR_MB_NAMESPACE::mbstate_t; +#endif + +// _lib.locale_, locale: +using _STLP_NEW_IO_NAMESPACE::locale; +using _STLP_NEW_IO_NAMESPACE::use_facet; +using _STLP_NEW_IO_NAMESPACE::has_facet; + +// _lib.locale.convenience_, convenience interfaces: +using _STLP_NEW_IO_NAMESPACE::isspace; +using _STLP_NEW_IO_NAMESPACE::isprint; +using _STLP_NEW_IO_NAMESPACE::iscntrl; +using _STLP_NEW_IO_NAMESPACE::isupper; +using _STLP_NEW_IO_NAMESPACE::islower; +using _STLP_NEW_IO_NAMESPACE::isalpha; +using _STLP_NEW_IO_NAMESPACE::isdigit; +using _STLP_NEW_IO_NAMESPACE::ispunct; +using _STLP_NEW_IO_NAMESPACE::isxdigit; +using _STLP_NEW_IO_NAMESPACE::isalnum; +using _STLP_NEW_IO_NAMESPACE::isgraph; +using _STLP_NEW_IO_NAMESPACE::toupper; +using _STLP_NEW_IO_NAMESPACE::tolower; + +// _lib.category.ctype_ and _lib.facet.ctype.special_, ctype: +using _STLP_NEW_IO_NAMESPACE::ctype_base; +using _STLP_NEW_IO_NAMESPACE::ctype; +using _STLP_NEW_IO_NAMESPACE::ctype_byname; +using _STLP_NEW_IO_NAMESPACE::codecvt_base; +using _STLP_NEW_IO_NAMESPACE::codecvt; +using _STLP_NEW_IO_NAMESPACE::codecvt_byname; + +// _lib.category.numeric_ and _lib.facet.numpunct_, numeric: +using _STLP_NEW_IO_NAMESPACE::num_get; +using _STLP_NEW_IO_NAMESPACE::num_put; +using _STLP_NEW_IO_NAMESPACE::numpunct; +using _STLP_NEW_IO_NAMESPACE::numpunct_byname; + +// _lib.category.collate_, collation: +using _STLP_NEW_IO_NAMESPACE::collate; +using _STLP_NEW_IO_NAMESPACE::collate_byname; + +// _lib.category.time_, date and time: +using _STLP_NEW_IO_NAMESPACE::time_base; +using _STLP_NEW_IO_NAMESPACE::time_get; +using _STLP_NEW_IO_NAMESPACE::time_get_byname; +using _STLP_NEW_IO_NAMESPACE::time_put; +using _STLP_NEW_IO_NAMESPACE::time_put_byname; + +// _lib.category.monetary_, money: +using _STLP_NEW_IO_NAMESPACE::money_base; +using _STLP_NEW_IO_NAMESPACE::money_get; +using _STLP_NEW_IO_NAMESPACE::money_put; +using _STLP_NEW_IO_NAMESPACE::moneypunct; +using _STLP_NEW_IO_NAMESPACE::moneypunct_byname; + +#if !defined (_STLP_OWN_IOSTREAMS) && !defined (_STLP_NO_NATIVE_MESSAGE_FACET) +using _STLP_NEW_IO_NAMESPACE::messages_base; +using _STLP_NEW_IO_NAMESPACE::messages; +using _STLP_NEW_IO_NAMESPACE::messages_byname; +#endif // _MSL_NO_MESSAGE_FACET +#endif /* !defined(_STLP_NO_IMPORT_LOCALE) */ diff --git a/sdk/tlibstdcxx/stlport/using/ostream b/sdk/tlibstdcxx/stlport/using/ostream new file mode 100644 index 0000000000..162b32d8b1 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/ostream @@ -0,0 +1,10 @@ +using _STLP_NEW_IO_NAMESPACE::basic_ostream; +using _STLP_NEW_IO_NAMESPACE::ostream; + +# ifndef _STLP_NO_WIDE_STREAMS +using _STLP_NEW_IO_NAMESPACE::wostream; +# endif + +using _STLP_NEW_IO_NAMESPACE::endl; +using _STLP_NEW_IO_NAMESPACE::ends; +using _STLP_NEW_IO_NAMESPACE::flush; diff --git a/sdk/tlibstdcxx/stlport/using/sstream b/sdk/tlibstdcxx/stlport/using/sstream new file mode 100644 index 0000000000..925c37e2da --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/sstream @@ -0,0 +1,16 @@ +using _STLP_NEW_IO_NAMESPACE::basic_stringbuf; +using _STLP_NEW_IO_NAMESPACE::stringbuf; + +using _STLP_NEW_IO_NAMESPACE::basic_istringstream; +using _STLP_NEW_IO_NAMESPACE::basic_ostringstream; +using _STLP_NEW_IO_NAMESPACE::basic_stringstream; +using _STLP_NEW_IO_NAMESPACE::istringstream; +using _STLP_NEW_IO_NAMESPACE::ostringstream; +using _STLP_NEW_IO_NAMESPACE::stringstream; + +#ifndef _STLP_NO_WIDE_STREAMS +using _STLP_NEW_IO_NAMESPACE::wstringbuf; +using _STLP_NEW_IO_NAMESPACE::wistringstream; +using _STLP_NEW_IO_NAMESPACE::wostringstream; +using _STLP_NEW_IO_NAMESPACE::wstringstream; +#endif diff --git a/sdk/tlibstdcxx/stlport/using/streambuf b/sdk/tlibstdcxx/stlport/using/streambuf new file mode 100644 index 0000000000..308241dee8 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/streambuf @@ -0,0 +1,5 @@ +using _STLP_NEW_IO_NAMESPACE::basic_streambuf; +using _STLP_NEW_IO_NAMESPACE::streambuf; +#ifndef _STLP_NO_WIDE_STREAMS +using _STLP_NEW_IO_NAMESPACE::wstreambuf; +# endif diff --git a/sdk/tlibstdcxx/stlport/using/strstream b/sdk/tlibstdcxx/stlport/using/strstream new file mode 100644 index 0000000000..eb26ac1f55 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/using/strstream @@ -0,0 +1,4 @@ +using _STLP_NEW_IO_NAMESPACE::strstreambuf; +using _STLP_NEW_IO_NAMESPACE::istrstream; +using _STLP_NEW_IO_NAMESPACE::ostrstream; +using _STLP_NEW_IO_NAMESPACE::strstream; diff --git a/sdk/tlibstdcxx/stlport/utility b/sdk/tlibstdcxx/stlport/utility new file mode 100644 index 0000000000..4aaaa5935d --- /dev/null +++ b/sdk/tlibstdcxx/stlport/utility @@ -0,0 +1,60 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_UTILITY + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x75 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x75) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_UTILITY +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x75) && !defined (_STLP_DONT_POP_HEADER_ID) +# ifndef _STLP_INTERNAL_PAIR_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x75) || defined (_STLP_DONT_POP_HEADER_ID) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(utility) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x75) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +#endif /* _STLP_UTILITY */ + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/valarray b/sdk/tlibstdcxx/stlport/valarray new file mode 100644 index 0000000000..0cb07767ca --- /dev/null +++ b/sdk/tlibstdcxx/stlport/valarray @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_VALARRAY + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x76 +# include +# define _STLP_VALARRAY +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x76) +# ifndef _STLP_VALARRAY_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x76) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(valarray) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x76) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_VALARRAY */ + + +// Local Variables: +// mode:C++ +// End: diff --git a/sdk/tlibstdcxx/stlport/vector b/sdk/tlibstdcxx/stlport/vector new file mode 100644 index 0000000000..92c41b744f --- /dev/null +++ b/sdk/tlibstdcxx/stlport/vector @@ -0,0 +1,59 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_VECTOR + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x77 +# include +# define _STLP_VECTOR +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x77) +# ifndef _STLP_INTERNAL_ALGOBASE_H +# include +# endif + +# ifndef _STLP_INTERNAL_VECTOR_H +# include +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x77) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_HEADER(vector) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x77) +# include +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_VECTOR */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/sdk/tlibstdcxx/stlport/wchar.h b/sdk/tlibstdcxx/stlport/wchar.h new file mode 100644 index 0000000000..6d66799698 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/wchar.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x278 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x278) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if !defined (_STLP_WCE_EVC3) && !defined (_STLP_NO_WCHAR_T) + +# if defined (__BORLANDC__) && !defined (__linux__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <_str.h> +# else +# include _STLP_NATIVE_CPP_C_HEADER(_str.h) +# endif +# ifdef __cplusplus +using _STLP_VENDOR_CSTD::strlen; +using _STLP_VENDOR_CSTD::strspn; +# endif +# endif + +# if (((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3))) && defined (__APPLE__)) || defined (__OpenBSD__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(stddef.h) +# endif +# else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next +# else +# include _STLP_NATIVE_C_HEADER(wchar.h) +# endif +# endif +#endif /* !defined (_STLP_WCE_EVC3) && !defined (_STLP_NO_WCHAR_T) */ + +#ifndef _STLP_INTERNAL_MBSTATE_T +# include +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x278) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + diff --git a/sdk/tlibstdcxx/stlport/wctype.h b/sdk/tlibstdcxx/stlport/wctype.h new file mode 100644 index 0000000000..c64ab9bea6 --- /dev/null +++ b/sdk/tlibstdcxx/stlport/wctype.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x279 +# include +#elif (_STLP_OUTERMOST_HEADER_ID == 0x279) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +/* evc3 doesn't have wctype.h */ +#if !defined(_STLP_WCE_EVC3) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# if defined (__hpux) +# include_next +# include_next +# endif +# include_next +# else +# if defined (__hpux) +# include _STLP_NATIVE_C_HEADER(stdarg.h) +# include _STLP_NATIVE_C_HEADER(wchar.h) +# endif +# include _STLP_NATIVE_C_HEADER(wctype.h) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x279) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif diff --git a/sdk/tlibthread/Makefile b/sdk/tlibthread/Makefile new file mode 100755 index 0000000000..94200d8c6d --- /dev/null +++ b/sdk/tlibthread/Makefile @@ -0,0 +1,62 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-exceptions -fno-rtti + +CPPFLAGS := -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/../sdk/trts \ + -I$(LINUX_PSW_DIR) + +OBJ := sethread_mutex.o \ + sethread_cond.o \ + sethread_utils.o + +LIBTLIBTHREAD := libtlibthread.a + +.PHONY:all +all: $(LIBTLIBTHREAD) + +$(LIBTLIBTHREAD): $(OBJ) + $(AR) rcs $@ $^ + +$(OBJ): %.o: %.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + +.PHONY: clean +clean: + @$(RM) *.o *.a + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/tlibthread/sethread_cond.cpp b/sdk/tlibthread/sethread_cond.cpp new file mode 100644 index 0000000000..7982d77c08 --- /dev/null +++ b/sdk/tlibthread/sethread_cond.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include + +#include "util.h" +#include "sethread_internal.h" + +int sgx_thread_cond_init(sgx_thread_cond_t *cond, const sgx_thread_condattr_t *unused) +{ + UNUSED(unused); + CHECK_PARAMETER(cond); + + cond->m_lock = SGX_SPINLOCK_INITIALIZER; + QUEUE_INIT(&cond->m_queue); + + return 0; +} + +int sgx_thread_cond_destroy(sgx_thread_cond_t *cond) +{ + CHECK_PARAMETER(cond); + + SPIN_LOCK(&cond->m_lock); + + if (QUEUE_FIRST(&cond->m_queue) != SGX_THREAD_T_NULL) { + SPIN_UNLOCK(&cond->m_lock); + return EBUSY; + } + + SPIN_UNLOCK(&cond->m_lock); + + return 0; +} + +int sgx_thread_cond_wait(sgx_thread_cond_t *cond, sgx_thread_mutex_t *mutex) +{ + CHECK_PARAMETER(cond); + CHECK_PARAMETER(mutex); + + sgx_thread_t self = (sgx_thread_t)get_thread_data(); + + SPIN_LOCK(&cond->m_lock); + QUEUE_INSERT_TAIL(&cond->m_queue, self); + + sgx_thread_t waiter = SGX_THREAD_T_NULL; + int ret = sgx_thread_mutex_unlock_lazy(mutex, &waiter); + if (ret != 0) { + SPIN_UNLOCK(&cond->m_lock); + return ret; + } + + while (1) { + sgx_thread_t tmp = SGX_THREAD_T_NULL; + + SPIN_UNLOCK(&cond->m_lock); + /* OPT: if there is a thread waiting on the mutex, wake it in a single OCALL. */ + if (waiter == SGX_THREAD_T_NULL) { + sgx_thread_wait_untrusted_event_ocall(&ret, TD2TCS(self)); + } else { + sgx_thread_setwait_untrusted_events_ocall(&ret, TD2TCS(waiter), TD2TCS(self)); + waiter = SGX_THREAD_T_NULL; + } + SPIN_LOCK(&cond->m_lock); + + QUEUE_FOREACH(tmp, &cond->m_queue) { + if (tmp == self) break; /* stop searching and re-wait outside */ + } + if (tmp == SGX_THREAD_T_NULL) break; /* current thread isn't in the queue */ + } + + SPIN_UNLOCK(&cond->m_lock); + sgx_thread_mutex_lock(mutex); + + return 0; +} + +int sgx_thread_cond_signal(sgx_thread_cond_t *cond) +{ + int err = 0; + sgx_thread_t waiter = SGX_THREAD_T_NULL; + + CHECK_PARAMETER(cond); + SPIN_LOCK(&cond->m_lock); + + if ((waiter = QUEUE_FIRST(&cond->m_queue)) == SGX_THREAD_T_NULL) { + SPIN_UNLOCK(&cond->m_lock); + return 0; + } + + QUEUE_REMOVE_HEAD(&cond->m_queue); + SPIN_UNLOCK(&cond->m_lock); + + sgx_thread_set_untrusted_event_ocall(&err, TD2TCS(waiter)); /* wake first pending thread */ + + return 0; +} + +int sgx_thread_cond_broadcast(sgx_thread_cond_t *cond) +{ + size_t n_waiter = 0; int err = 0; + sgx_thread_t waiter = SGX_THREAD_T_NULL; + const void **waiters = NULL; + + CHECK_PARAMETER(cond); + SPIN_LOCK(&cond->m_lock); + + QUEUE_COUNT_ALL(waiter, &cond->m_queue, n_waiter); + if (n_waiter == 0) { + SPIN_UNLOCK(&cond->m_lock); + return 0; + } + + waiters = (const void **)malloc(n_waiter * sizeof(const void *)); + if (waiters == NULL) { + SPIN_UNLOCK(&cond->m_lock); + return ENOMEM; + } + + const void **tmp = waiters; + while ((waiter = QUEUE_FIRST(&cond->m_queue)) != SGX_THREAD_T_NULL) { + QUEUE_REMOVE_HEAD(&cond->m_queue); /* remove the pending thread */ + *tmp++ = TD2TCS(waiter); + } + + SPIN_UNLOCK(&cond->m_lock); + + sgx_thread_set_multiple_untrusted_events_ocall(&err, waiters, n_waiter); /* wake all pending threads up */ + free(waiters); + return 0; +} diff --git a/sdk/tlibthread/sethread_internal.h b/sdk/tlibthread/sethread_internal.h new file mode 100644 index 0000000000..714269194b --- /dev/null +++ b/sdk/tlibthread/sethread_internal.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_trts.h" +#include "sgx_spinlock.h" +#include "sgx_thread.h" + +#include "internal/se_cdefs.h" +#include "internal/arch.h" +#include "internal/thread_data.h" +#include "trts_internal.h" + + +typedef struct _thread_data_t *pTD; + +/* Queue operations */ +#define QUEUE_FIRST(head) ((sgx_thread_t)((head)->m_first)) +#define QUEUE_NEXT(elm) ((sgx_thread_t)(((pTD)(elm))->m_next)) + +#define QUEUE_INIT(head) do { \ + (head)->m_first = \ + (head)->m_last = SGX_THREAD_T_NULL; \ +} while (0) + +#define QUEUE_FOREACH(var, head) \ + for((var) = QUEUE_FIRST(head); \ + (var) != SGX_THREAD_T_NULL; \ + (var) = QUEUE_NEXT(var)) + +#define QUEUE_INSERT_TAIL(head, elm) do { \ + ((pTD)(elm))->m_next = NULL; \ + if ((head)->m_first != SGX_THREAD_T_NULL) \ + ((pTD)((head)->m_last))->m_next = (pTD)(elm); \ + else \ + (head)->m_first = (elm); \ + (head)->m_last = (elm); \ +} while (0) + +#define QUEUE_REMOVE_HEAD(head) do { \ + if (((head)->m_first = \ + QUEUE_NEXT((head)->m_first)) == SGX_THREAD_T_NULL) \ + (head)->m_last = SGX_THREAD_T_NULL; \ +} while (0) + +#define QUEUE_COUNT_ALL(var, head, total) do { \ + QUEUE_FOREACH(var, head) \ + (total)++; \ +} while(0) \ + +/* Spinlock */ +#define SPIN_LOCK(_lck) sgx_spin_lock((sgx_spinlock_t *)_lck); +#define SPIN_UNLOCK(_lck) sgx_spin_unlock((sgx_spinlock_t *)_lck); + +/* check enclave address */ +#define CHECK_PARAMETER(addr) do { \ + if (addr == NULL || \ + !sgx_is_within_enclave((void *)addr, sizeof(*addr))) \ + return EINVAL; \ +} while (0) + +/* Generated OCALLs */ +extern "C" sgx_status_t sgx_thread_wait_untrusted_event_ocall(int* retval, const void *self); +extern "C" sgx_status_t sgx_thread_set_untrusted_event_ocall(int* retval, const void *waiter); +extern "C" sgx_status_t sgx_thread_set_multiple_untrusted_events_ocall(int* retval, const void** waiters, size_t total); +extern "C" sgx_status_t sgx_thread_setwait_untrusted_events_ocall(int* retval, const void *waiter, const void *self); + +extern "C" int sgx_thread_mutex_unlock_lazy(sgx_thread_mutex_t *mutex, sgx_thread_t *pwaiter); diff --git a/sdk/tlibthread/sethread_mutex.cpp b/sdk/tlibthread/sethread_mutex.cpp new file mode 100644 index 0000000000..322c9b91c6 --- /dev/null +++ b/sdk/tlibthread/sethread_mutex.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include + +#include "util.h" +#include "sethread_internal.h" + +int sgx_thread_mutex_init(sgx_thread_mutex_t *mutex, const sgx_thread_mutexattr_t *unused) +{ + UNUSED(unused); + CHECK_PARAMETER(mutex); + + mutex->m_control = SGX_THREAD_MUTEX_NONRECURSIVE; + mutex->m_refcount = 0; + mutex->m_owner = SGX_THREAD_T_NULL; + mutex->m_lock = SGX_SPINLOCK_INITIALIZER; + + QUEUE_INIT(&mutex->m_queue); + + return 0; +} + +int sgx_thread_mutex_destroy(sgx_thread_mutex_t *mutex) +{ + CHECK_PARAMETER(mutex); + + SPIN_LOCK(&mutex->m_lock); + if (mutex->m_owner != SGX_THREAD_T_NULL + || QUEUE_FIRST(&mutex->m_queue) != SGX_THREAD_T_NULL) { + SPIN_UNLOCK(&mutex->m_lock); + return EBUSY; + } + + mutex->m_control = 0; + mutex->m_refcount = 0; + + SPIN_UNLOCK(&mutex->m_lock); + + return 0; +} + +int sgx_thread_mutex_lock(sgx_thread_mutex_t *mutex) +{ + CHECK_PARAMETER(mutex); + + sgx_thread_t self = (sgx_thread_t)get_thread_data(); + + while (1) { + SPIN_LOCK(&mutex->m_lock); + + if(mutex->m_control != SGX_THREAD_MUTEX_RECURSIVE + && mutex->m_control != SGX_THREAD_MUTEX_NONRECURSIVE) { + SPIN_UNLOCK(&mutex->m_lock); + return EINVAL; + } + + if (mutex->m_control == SGX_THREAD_MUTEX_RECURSIVE + && mutex->m_owner == self) { + mutex->m_refcount++; + SPIN_UNLOCK(&mutex->m_lock); + return 0; + } + + if (mutex->m_owner == SGX_THREAD_T_NULL + && (QUEUE_FIRST(&mutex->m_queue) == self + || QUEUE_FIRST(&mutex->m_queue) == SGX_THREAD_T_NULL)) { + + if (QUEUE_FIRST(&mutex->m_queue) == self) + QUEUE_REMOVE_HEAD(&mutex->m_queue); + + mutex->m_owner = self; + mutex->m_refcount++; + SPIN_UNLOCK(&mutex->m_lock); + return 0; + } + + sgx_thread_t waiter = SGX_THREAD_T_NULL; + QUEUE_FOREACH(waiter, &mutex->m_queue) { + if (waiter == self) break; + } + + if (waiter == SGX_THREAD_T_NULL) + QUEUE_INSERT_TAIL(&mutex->m_queue, self); + + SPIN_UNLOCK(&mutex->m_lock); + + int err = 0; + sgx_thread_wait_untrusted_event_ocall(&err, TD2TCS(self)); + } + + /* NOTREACHED */ +} + +int sgx_thread_mutex_trylock(sgx_thread_mutex_t *mutex) +{ + CHECK_PARAMETER(mutex); + + sgx_thread_t self = (sgx_thread_t)get_thread_data(); + + SPIN_LOCK(&mutex->m_lock); + + if(mutex->m_control != SGX_THREAD_MUTEX_RECURSIVE + && mutex->m_control != SGX_THREAD_MUTEX_NONRECURSIVE) { + SPIN_UNLOCK(&mutex->m_lock); + return EINVAL; + } + + if (mutex->m_control == SGX_THREAD_MUTEX_RECURSIVE + && mutex->m_owner == self) { + mutex->m_refcount++; + SPIN_UNLOCK(&mutex->m_lock); + return 0; + } + + if (mutex->m_owner == SGX_THREAD_T_NULL + && (QUEUE_FIRST(&mutex->m_queue) == self + || QUEUE_FIRST(&mutex->m_queue) == SGX_THREAD_T_NULL)) { + + if (QUEUE_FIRST(&mutex->m_queue) == self) + QUEUE_REMOVE_HEAD(&mutex->m_queue); + + mutex->m_owner = self; + mutex->m_refcount++; + + SPIN_UNLOCK(&mutex->m_lock); + return 0; + } + + SPIN_UNLOCK(&mutex->m_lock); + return EBUSY; +} + +/* sgx_thread_mutex_unlock_lazy: + * check and modify mutex object, but not wake the pending thread up. + */ +int sgx_thread_mutex_unlock_lazy(sgx_thread_mutex_t *mutex, sgx_thread_t *pwaiter) +{ + CHECK_PARAMETER(mutex); + + sgx_thread_t self = (sgx_thread_t)get_thread_data(); + + SPIN_LOCK(&mutex->m_lock); + + if(mutex->m_control != SGX_THREAD_MUTEX_RECURSIVE + && mutex->m_control != SGX_THREAD_MUTEX_NONRECURSIVE) { + SPIN_UNLOCK(&mutex->m_lock); + return EINVAL; + } + + /* if the mutux is not locked by anyone */ + if(mutex->m_owner == SGX_THREAD_T_NULL) { + SPIN_UNLOCK(&mutex->m_lock); + return EINVAL; + } + + /* if the mutex is locked by another thread */ + if (mutex->m_owner != self) { + SPIN_UNLOCK(&mutex->m_lock); + return EPERM; + } + + /* the mutex is locked by current thread */ + if (--mutex->m_refcount == 0) + mutex->m_owner = SGX_THREAD_T_NULL; + else { + SPIN_UNLOCK(&mutex->m_lock); + return 0; + } + + /* Before releasing the mutex, get the first thread, + * the thread should be waked up by the caller. + */ + sgx_thread_t waiter = QUEUE_FIRST(&mutex->m_queue); + + SPIN_UNLOCK(&mutex->m_lock); + if (pwaiter != NULL) *pwaiter = waiter; + + return 0; +} + +/* sgx_thread_mutex_unlock: + * invoke sgx_thread_mutex_unlock_lazy, wake the pending thread up. + */ +int sgx_thread_mutex_unlock(sgx_thread_mutex_t *mutex) +{ + sgx_thread_t waiter = SGX_THREAD_T_NULL; + + int ret = sgx_thread_mutex_unlock_lazy(mutex, &waiter); + if (ret != 0) return ret; + + if (waiter != SGX_THREAD_T_NULL) /* wake the waiter up*/ + sgx_thread_set_untrusted_event_ocall(&ret, TD2TCS(waiter)); + + return 0; +} diff --git a/sdk/tlibthread/sethread_utils.cpp b/sdk/tlibthread/sethread_utils.cpp new file mode 100644 index 0000000000..7b2d3918c1 --- /dev/null +++ b/sdk/tlibthread/sethread_utils.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include +#include + +#include "util.h" +#include "sethread_internal.h" + +sgx_thread_t sgx_thread_self(void) +{ + return (sgx_thread_t)get_thread_data(); +} + diff --git a/sdk/trts/Makefile b/sdk/trts/Makefile new file mode 100644 index 0000000000..279e300011 --- /dev/null +++ b/sdk/trts/Makefile @@ -0,0 +1,66 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../buildenv.mk + +CPPFLAGS += -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc/tlibc + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) \ + -Werror \ + -fno-exceptions \ + -fno-rtti + +OBJS := init_enclave.o \ + trts.o \ + trts_ecall.o \ + trts_ocall.o \ + trts_util.o \ + trts_veh.o \ + trts_xsave.o \ + init_optimized_lib.o \ + trts_version.o + + +all: $(OBJS) elf_parser + +$(OBJS): %.o: %.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + +.PHONY: elf_parser +elf_parser: + $(MAKE) -C linux + +.PHONY: clean +clean: + @$(RM) $(OBJS) *.bak *~ + $(MAKE) -C linux clean diff --git a/sdk/trts/init_enclave.cpp b/sdk/trts/init_enclave.cpp new file mode 100644 index 0000000000..0f52f99336 --- /dev/null +++ b/sdk/trts/init_enclave.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: init_enclave.cpp + * Description: + * Initialize enclave by rebasing the image to the enclave base + */ + +#include +#include "thread_data.h" +#include "global_data.h" +#include "util.h" +#include "xsave.h" +#include "sgx_trts.h" +#include "init_optimized_lib.h" +#include "trts_internal.h" +# include "linux/elf_parser.h" +#include "rts.h" + +// The global cpu feature bits from uRTS +uint64_t g_cpu_feature_indicator = 0; + +const volatile global_data_t g_global_data = {1, 2, 3, 4, 0, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}}}; +uint32_t g_enclave_state = ENCLAVE_INIT_NOT_STARTED; + +extern "C" { +uintptr_t __stack_chk_guard = 0; +#define __weak_alias(alias,sym) \ + __asm__(".weak " __STRING(alias) " ; " \ + __STRING(alias) " = " __STRING(sym)) +__weak_alias(__intel_security_cookie, __stack_chk_guard); +} + +// init_enclave() +// Initialize enclave. +// Parameters: +// [IN] enclave_base - the enclave base address +// [IN] ms - the marshalling structure passed by uRTS +// Return Value: +// 0 - success +// -1 - fail +// +extern "C" int init_enclave(void *enclave_base, void *ms) +{ + if(enclave_base == NULL || ms == NULL) + { + return -1; + } + + // relocation + if(0 != relocate_enclave(enclave_base)) + { + return -1; + } + + // Check if the ms is outside the enclave. + // sgx_is_outside_enclave() should be placed after relocate_enclave() + cpu_sdk_info_t *info = (cpu_sdk_info_t *)ms; + if(!sgx_is_outside_enclave(info, sizeof(cpu_sdk_info_t))) + { + return -1; + } + const sdk_version_t sdk_version = info->version; + const uint64_t cpu_features = info->cpu_features; + + if (sdk_version != SDK_VERSION_1_5) + return -1; + + // xsave + uint64_t xfrm = get_xfeature_state(); + + // optimized libs + if(0 != init_optimized_libs(cpu_features, xfrm)) + { + CLEAN_XFEATURE_REGS + return -1; + } + + if(SGX_SUCCESS != sgx_read_rand((unsigned char*)&__stack_chk_guard, + sizeof(__stack_chk_guard))) + { + CLEAN_XFEATURE_REGS + return -1; + } + + // clean extended registers, no need to save + CLEAN_XFEATURE_REGS + return 0; +} + +sgx_status_t do_init_enclave(void *ms) +{ + void *enclave_base = get_enclave_base(); + if(ENCLAVE_INIT_NOT_STARTED != lock_enclave()) + { + return SGX_ERROR_UNEXPECTED; + } + if(0 != init_enclave(enclave_base, ms)) + { + return SGX_ERROR_UNEXPECTED; + } + memset(GET_PTR(void, enclave_base, g_global_data.heap_offset), 0, g_global_data.heap_size); + g_enclave_state = ENCLAVE_INIT_DONE; + return SGX_SUCCESS; +} + diff --git a/sdk/trts/init_optimized_lib.cpp b/sdk/trts/init_optimized_lib.cpp new file mode 100644 index 0000000000..4c3918965d --- /dev/null +++ b/sdk/trts/init_optimized_lib.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "init_optimized_lib.h" +#include +#include "se_cpu_feature.h" +#include "sgx_trts.h" +#include "sgx_attributes.h" +#include "global_data.h" + +extern "C" int sgx_init_string_lib(uint64_t cpu_feature_indicator); +extern "C" sgx_status_t sgx_init_crypto_lib(uint64_t cpu_feature_indicator); + +static int set_global_feature_indicator(uint64_t feature_bit_array, uint64_t xfrm) +{ + // Confirm the reserved bits and the unset bits by uRTS must be 0. + + + if(feature_bit_array & (RESERVED_CPU_FEATURE_BIT)) + { + // clear the reserved bits + feature_bit_array = feature_bit_array & (~(RESERVED_CPU_FEATURE_BIT)); + } + ; + + +#ifdef SE_SIM + // Simulation mode - requires SSE for x86 and SSE2 for x64. +#ifdef SE_32 + if(!(feature_bit_array & ~(CPU_FEATURE_SSE - 1))) + { + return -1; + } +#else + if(!(feature_bit_array & ~(CPU_FEATURE_SSE2 - 1))) + { + return -1; + } +#endif +#else + // HW mode - requires SSE4.2. Take SSE4.2 as the baseline. + if(!(feature_bit_array & ~(CPU_FEATURE_SSE4_2 - 1))) + { + return -1; + } +#endif + // Check for inconsistencies in the CPUID feature mask. + if ( (((feature_bit_array & CPU_FEATURE_SSE) == CPU_FEATURE_SSE) &&((feature_bit_array & (CPU_FEATURE_SSE - 1)) != (CPU_FEATURE_SSE - 1))) || + (((feature_bit_array & CPU_FEATURE_SSE2) == CPU_FEATURE_SSE2) &&((feature_bit_array & (CPU_FEATURE_SSE2 - 1)) != (CPU_FEATURE_SSE2 - 1))) || + (((feature_bit_array & CPU_FEATURE_SSE3) == CPU_FEATURE_SSE3) &&((feature_bit_array & (CPU_FEATURE_SSE3 - 1)) != (CPU_FEATURE_SSE3 - 1))) || + (((feature_bit_array & CPU_FEATURE_SSSE3) == CPU_FEATURE_SSSE3) && ((feature_bit_array & (CPU_FEATURE_SSSE3 - 1)) != (CPU_FEATURE_SSSE3 - 1))) || + (((feature_bit_array & CPU_FEATURE_SSE4_1) == CPU_FEATURE_SSE4_1) && ((feature_bit_array & (CPU_FEATURE_SSE4_1 - 1)) != (CPU_FEATURE_SSE4_1 - 1))) || + (((feature_bit_array & CPU_FEATURE_SSE4_2) == CPU_FEATURE_SSE4_2) && ((feature_bit_array & (CPU_FEATURE_SSE4_2 - 1)) != (CPU_FEATURE_SSE4_2 - 1))) ) + { + return -1; + } + + // Determine whether the OS & ENCLAVE support SAVE/RESTORE of the AVX register set + // IF NOT, clear the advanced feature set bits corresponding to AVX and beyond + if(!XFEATURE_ENABLED_AVX(xfrm)) + { + // AVX is disabled by OS, so clear the AVX related feature bits + feature_bit_array &= (~(CPU_FEATURE_AVX | CPU_FEATURE_F16C | CPU_FEATURE_AVX2 | + CPU_FEATURE_FMA | CPU_FEATURE_RTM | CPU_FEATURE_HLE | CPU_FEATURE_BMI | + CPU_FEATURE_PREFETCHW | CPU_FEATURE_RDSEED | CPU_FEATURE_ADCOX)); + } + + g_cpu_feature_indicator = feature_bit_array; + return 0; +} + +extern "C" int init_optimized_libs(const uint64_t feature_bit_array, uint64_t xfrm) +{ + if (g_enclave_state != ENCLAVE_INIT_IN_PROGRESS) + { + return -1; + } + // set the global feature indicator + if(set_global_feature_indicator(feature_bit_array, xfrm)) + { + return -1; + } + + // Init string library with the global feature indicator + if(sgx_init_string_lib(g_cpu_feature_indicator) != 0) + { + return -1; + } + + // Init IPP crypto library with the global feature indicator + if(sgx_init_crypto_lib(g_cpu_feature_indicator) != 0) + { + return -1; + } + + return 0; +} diff --git a/sdk/trts/init_optimized_lib.h b/sdk/trts/init_optimized_lib.h new file mode 100644 index 0000000000..373bfca04e --- /dev/null +++ b/sdk/trts/init_optimized_lib.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef INIT_OPTIMIZED_LIB_H +#define INIT_OPTIMIZED_LIB_H + +#include "se_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +int init_optimized_libs(const uint64_t feature_bits_array, uint64_t xfrm); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/trts/linux/Makefile b/sdk/trts/linux/Makefile new file mode 100644 index 0000000000..ff9394d4b4 --- /dev/null +++ b/sdk/trts/linux/Makefile @@ -0,0 +1,91 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +CFLAGS += -Werror $(ENCLAVE_CFLAGS) \ + -I$(LINUX_SDK_DIR)/trts \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc/internal/linux \ + -I$(LINUX_SDK_DIR)/simulation/assembly/ + +CXXFLAGS += -Werror $(ENCLAVE_CXXFLAGS) \ + -I$(LINUX_SDK_DIR)/trts \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/internal/ + +TCFLAGS += -nostdinc \ + -I$(COMMON_DIR)/inc/tlibc/ + +LDCFLAGS := -shared -nostdlib -nodefaultlibs -nostartfiles + +CPP_SRCS := $(wildcard ../*.cpp) +C_SRCS := $(wildcard *.c) +ASM_SRCS := $(wildcard *.S) +OBJS := $(CPP_SRCS:.cpp=.o) +OBJS += $(C_SRCS:.c=.o) +OBJS += $(ASM_SRCS:.S=.o) + +LIBTRTS = libsgx_trts.a + +.PHONY: all +all: $(LIBTRTS) | $(BUILD_DIR) + $(CP) $(LIBTRTS) $| + +$(LIBTRTS): $(OBJS) setcontext.o + $(AR) rsD $@ $(OBJS) + $(AR) rsD $@ $(ARCH)/setcontext.o + +%.o: %.S + $(CC) $(CFLAGS) $(TCFLAGS) -c $< -o $@ + +%.o: %.c + $(CC) $(CFLAGS) $(TCFLAGS) -c $< -o $@ + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(TCFLAGS) -c $< -o $@ + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: setcontext.o +setcontext.o: + $(MAKE) -C $(ARCH) + +.PHONY: clean +clean: + @$(RM) $(OBJS) $(LIBTRTS) $(BUILD_DIR)/$(LIBTRTS) + $(MAKE) -C $(ARCH) clean + +.PHONY: rebuild +rebuild: clean all + diff --git a/sdk/trts/linux/elf_parser.c b/sdk/trts/linux/elf_parser.c new file mode 100644 index 0000000000..964c10d0e0 --- /dev/null +++ b/sdk/trts/linux/elf_parser.c @@ -0,0 +1,419 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* + * This file is part of trusted loader for tRTS. + */ + +#include "elf_parser.h" +#include "rts.h" +#include "util.h" +#include "elf_util.h" +#include "global_data.h" + +static int elf_tls_aligned_virtual_size(const void *enclave_base, + size_t *aligned_virtual_size); + +static ElfW(Phdr)* get_phdr(const ElfW(Ehdr)* ehdr) +{ + if (ehdr == NULL) + return NULL; /* Invalid image. */ + + /* Check the ElfW Magic number. */ + if ((ehdr->e_ident[EI_MAG0] != ELFMAG0) || + (ehdr->e_ident[EI_MAG1] != ELFMAG1) || + (ehdr->e_ident[EI_MAG2] != ELFMAG2) || + (ehdr->e_ident[EI_MAG3] != ELFMAG3)) + return NULL; + + /* Enclave image should be a shared object file. */ + if (ehdr->e_type != ET_DYN) + return NULL; + + return GET_PTR(ElfW(Phdr), ehdr, ehdr->e_phoff); +} + +static ElfW(Sym)* get_sym(ElfW(Sym)* symtab, size_t idx) +{ + if(STB_WEAK == ELFW(ST_BIND)(symtab[idx].st_info) + && 0 == symtab[idx].st_value) + { + return NULL; + } + + return &symtab[idx]; +} + +#ifdef __x86_64__ +/* Relocation for x64 (with addend) */ +static int do_relocs(const ElfW(Addr) enclave_base, + ElfW(Addr) rela_offset, + ElfW(Addr) sym_offset, + size_t nr_relocs) +{ + ElfW(Rela)* rela = GET_PTR(ElfW(Rela), enclave_base, rela_offset); + ElfW(Sym)* symtab = GET_PTR(ElfW(Sym), enclave_base, sym_offset); + ElfW(Sym)* sym; + size_t i; + size_t aligned_virtual_size = 0; + + for (i = 0; i < nr_relocs; ++i, ++rela) + { + ElfW(Addr)* reloc_addr = GET_PTR(ElfW(Addr), enclave_base, rela->r_offset); + + switch (ELF64_R_TYPE(rela->r_info)) + { + case R_X86_64_RELATIVE: + *reloc_addr = enclave_base + (uintptr_t)rela->r_addend; + break; + + case R_X86_64_GLOB_DAT: + case R_X86_64_JUMP_SLOT: + case R_X86_64_64: + sym = get_sym(symtab, ELF64_R_SYM(rela->r_info)); + if(!sym) + break; + *reloc_addr = enclave_base + sym->st_value + (uintptr_t)rela->r_addend; + break; + + case R_X86_64_DTPMOD64: + *reloc_addr = 1; + break; + + case R_X86_64_DTPOFF64: + sym = get_sym(symtab, ELF64_R_SYM(rela->r_info)); + if(!sym) + break; + *reloc_addr = sym->st_value + (uintptr_t)rela->r_addend; + break; + + case R_X86_64_TPOFF64: + sym = get_sym(symtab, ELF64_R_SYM(rela->r_info)); + if(!sym) + break; + + if ((0 == elf_tls_aligned_virtual_size((void *)enclave_base, &aligned_virtual_size)) && (aligned_virtual_size)) + { + *reloc_addr = sym->st_value + (uintptr_t)rela->r_addend - aligned_virtual_size; + break; + } + else + return -1; + + case R_X86_64_NONE: + break; + + default: /* unsupported relocs */ + return -1; + } + } + + return 0; +} + +#elif defined(__i386__) +/* Relocation for x86 (without addend) */ +static int do_relocs(const ElfW(Addr) enclave_base, + ElfW(Addr) rel_offset, + ElfW(Addr) sym_offset, + size_t nr_relocs) +{ + ElfW(Rel)* rel = GET_PTR(ElfW(Rel), enclave_base, rel_offset); + ElfW(Sym)* symtab = GET_PTR(ElfW(Sym), enclave_base, sym_offset); + ElfW(Sym)* sym = NULL; + size_t i; + size_t aligned_virtual_size = 0; + + for (i = 0; i < nr_relocs; ++i, ++rel) + { + ElfW(Addr)* reloc_addr = GET_PTR(ElfW(Addr), enclave_base, rel->r_offset); + + if(R_386_RELATIVE == ELF32_R_TYPE(rel->r_info)) + { + *reloc_addr += enclave_base; /* B+A */ + continue; + } + sym = get_sym(symtab, ELF32_R_SYM(rel->r_info)); + if(!sym) /* when the weak symbol is not implemented, sym is NULL */ + continue; + switch (ELF32_R_TYPE(rel->r_info)) + { + case R_386_GLOB_DAT: + case R_386_JMP_SLOT: /* S */ + *reloc_addr = enclave_base + sym->st_value; + break; + + case R_386_32: /* S+A */ + *reloc_addr += enclave_base + sym->st_value; + break; + + case R_386_PC32: /* S+A-P */ + *reloc_addr += (enclave_base + sym->st_value - (ElfW(Addr))reloc_addr); + break; + + case R_386_NONE: + break; + + case R_386_TLS_DTPMOD32: + *reloc_addr = 1; + break; + + case R_386_TLS_DTPOFF32: + *reloc_addr = sym->st_value; + break; + + case R_386_TLS_TPOFF: + if ((0 == elf_tls_aligned_virtual_size((void *)enclave_base, &aligned_virtual_size)) && (aligned_virtual_size)) + { + *reloc_addr += sym->st_value - aligned_virtual_size; + break; + } + else + return -1; + + case R_386_TLS_TPOFF32: + if ((0 == elf_tls_aligned_virtual_size((void *)enclave_base, &aligned_virtual_size)) && (aligned_virtual_size)) + { + *reloc_addr += aligned_virtual_size - sym->st_value; + break; + } + else + return -1; + + default: /* unsupported relocs */ + return -1; + } + } + + return 0; +} +#endif + +#define DO_REL(base_addr, rel_offset, sym_offset, total_sz, rel_entry_sz) \ +do { \ + if (rel_offset) \ + { \ + size_t n; \ + if (rel_entry_sz == 0) \ + return -1; \ + n = total_sz/rel_entry_sz; \ + if (do_relocs((ElfW(Addr))enclave_base, rel_offset, sym_offset, n)) \ + return -1; \ + } \ +} while (0) + +/* By default all symbol is linked as global symbol by link editor. When call global symbol, + * we first call .plt entry. It should have problems if the call goloal symbol when relocation + * is not done. + * Declare relocate_enclave as .hidden is to make it local symbol. + * Since this function is called before relocation is done, we must make + * it local symbol, so the code is like "fce3: e8 98 12 00 00 call 10f80 " + * 0x9812=0x10f80-0xfce8 + */ +__attribute__ ((visibility ("hidden"))) +int relocate_enclave(void* enclave_base) +{ + ElfW(Half) phnum = 0; + ElfW(Ehdr) *ehdr = (ElfW(Ehdr)*)enclave_base; + ElfW(Phdr) *phdr = get_phdr(ehdr); + + if (phdr == NULL) + return -1; /* Invalid image. */ + + for (; phnum < ehdr->e_phnum; phnum++, phdr++) + { + /* Search for dynamic segment */ + if (phdr->p_type == PT_DYNAMIC) + { + size_t count; + size_t n_dyn = phdr->p_filesz/sizeof(ElfW(Dyn)); + ElfW(Dyn) *dyn = GET_PTR(ElfW(Dyn), ehdr, phdr->p_paddr); + + ElfW(Addr) sym_offset = 0; + ElfW(Addr) rel_offset = 0; + ElfW(Addr) plt_offset = 0; + + size_t rel_total_sz = 0; + size_t rel_entry_sz = 0; + size_t plt_total_sz = 0; + + for (count = 0; count < n_dyn; count++, dyn++) + { + if (dyn->d_tag == DT_NULL) /* End */ + break; + + switch (dyn->d_tag) + { + case DT_SYMTAB: /* symbol table */ + sym_offset = dyn->d_un.d_ptr; + break; + + case RTS_DT_REL:/* Rel (x86) or Rela (x64) relocs */ + rel_offset = dyn->d_un.d_ptr; + break; + + case RTS_DT_RELSZ: + rel_total_sz = dyn->d_un.d_val; + break; + + case RTS_DT_RELENT: + rel_entry_sz = dyn->d_un.d_val; + break; + + case DT_JMPREL: /* PLT relocs */ + plt_offset = dyn->d_un.d_ptr; + break; + + case DT_PLTRELSZ: + plt_total_sz = dyn->d_un.d_val; + break; + } + } + + DO_REL(enclave_base, rel_offset, sym_offset, rel_total_sz, rel_entry_sz); + DO_REL(enclave_base, plt_offset, sym_offset, plt_total_sz, rel_entry_sz); + } + } + + return 0; +} + +int elf_tls_info(const void* enclave_base, + uintptr_t *tls_addr, size_t *tdata_size) +{ + ElfW(Half) phnum = 0; + const ElfW(Ehdr) *ehdr = (const ElfW(Ehdr)*)enclave_base; + ElfW(Phdr) *phdr = get_phdr(ehdr); + + if (!tls_addr || !tdata_size) + return -1; + + if (phdr == NULL) + return -1; /* Invalid image. */ + + /* Search for TLS segment */ + *tls_addr = 0; + *tdata_size = 0; + for (; phnum < ehdr->e_phnum; phnum++, phdr++) + { + if (phdr->p_type == PT_TLS) + { + /* tls_addr here is got from the program header, the address + * need to be added by the enclave base. + */ + *tls_addr = (size_t)enclave_base + phdr->p_vaddr; + *tdata_size = phdr->p_filesz; + break; + } + } + + return 0; +} + +static int elf_tls_aligned_virtual_size(const void *enclave_base, + size_t *aligned_virtual_size) +{ + ElfW(Half) phnum = 0; + const ElfW(Ehdr) *ehdr = (const ElfW(Ehdr)*)enclave_base; + ElfW(Phdr) *phdr = get_phdr(ehdr); + size_t virtual_size =0, align = 0; + + if (phdr == NULL) + return -1; + + if (!aligned_virtual_size) + return -1; + + *aligned_virtual_size = 0; + for (; phnum < ehdr->e_phnum; phnum++, phdr++) + { + if (phdr->p_type == PT_TLS) + { + virtual_size = phdr->p_memsz; + align = phdr->p_align; + + /* p_align == 0 or p_align == 1 means no alignment is required */ + if (align == 0 || align == 1) + *aligned_virtual_size = virtual_size; + else + *aligned_virtual_size = (virtual_size + align - 1) & (~(align - 1)); + + break; + } + } + + return 0; +} + +int elf_get_init_array(const void* enclave_base, + uintptr_t *init_array_addr, size_t *init_array_size) +{ + ElfW(Half) phnum = 0; + const ElfW(Ehdr) *ehdr = (const ElfW(Ehdr)*)enclave_base; + ElfW(Phdr) *phdr = get_phdr(ehdr); + + if (!init_array_addr || !init_array_size) + return -1; + + if (phdr == NULL) + return -1; /* Invalid image. */ + + *init_array_addr = 0; + *init_array_size = 0; + + /* Search for Dynamic segment */ + for (; phnum < ehdr->e_phnum; phnum++, phdr++) + { + if (phdr->p_type == PT_DYNAMIC) + { + size_t count; + size_t n_dyn = phdr->p_filesz/sizeof(ElfW(Dyn)); + ElfW(Dyn) *dyn = GET_PTR(ElfW(Dyn), ehdr, phdr->p_paddr); + + for (count = 0; count < n_dyn; count++, dyn++) + { + switch (dyn->d_tag) + { + case DT_INIT_ARRAY: + *init_array_addr = dyn->d_un.d_ptr; + break; + case DT_INIT_ARRAYSZ: + *init_array_size = dyn->d_un.d_val; + break; + } + } + } + } + + return 0; +} +/* vim: set ts=4 sw=4 et cin: */ diff --git a/sdk/trts/linux/elf_parser.h b/sdk/trts/linux/elf_parser.h new file mode 100644 index 0000000000..0dc8f0cee1 --- /dev/null +++ b/sdk/trts/linux/elf_parser.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: elf_parser.h + * Description: + * Header file for tRTS ELF parser. + */ + +#ifndef _PE_PARSER_H_ +#define _PE_PARSER_H_ + +#include "se_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int relocate_enclave(void* enclave_base); + +int elf_tls_info(const void* enclave_base, + uintptr_t *tls_addr, size_t *tdata_size); + +int elf_get_init_array(const void* enclave_base, + uintptr_t *init_array_addr, size_t *init_array_size); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/trts/linux/global_init.c b/sdk/trts/linux/global_init.c new file mode 100644 index 0000000000..25a4ae5abe --- /dev/null +++ b/sdk/trts/linux/global_init.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "internal/global_init.h" +#include "linux/elf_parser.h" +#include "global_data.h" +#include "internal/util.h" +#include "thread_data.h" +#include "sgx_trts.h" +#include +#include + +typedef void (*fp_t)(void); + +/* required by global constructor when -fuse-cxa-atexit is enabled */ +void *__dso_handle __attribute__((weak)) = &(__dso_handle); + +int __cxa_atexit(void (*fun)(void *), void *para, void *dso) +{ + (void)(fun); + (void)(para); + (void)(dso); + + return 0; +} + +/* auxiliary routines */ +static void do_ctors_aux(void) +{ + /* SGX RTS does not support .ctors currently */ + + fp_t *p = NULL; + uintptr_t init_array_addr; + size_t init_array_size; + const void *enclave_start = (const void*)&__ImageBase; + + elf_get_init_array(enclave_start, &init_array_addr, &init_array_size); + + if (init_array_addr == 0 || init_array_size == 0) + return; + + fp_t *fp_start = (fp_t*)(init_array_addr + (uintptr_t)(enclave_start)); + fp_t *fp_end = fp_start + (init_array_size / sizeof(fp_t)); + + /* traverse .init_array in forward order */ + for (p = fp_start; p < fp_end; p++) + { + (*p)(); + } +} + +void init_global_object(void) +{ + do_ctors_aux(); +} + +void init_stack_guard(void) +{ + thread_data_t *thread_data = get_thread_data(); + assert(thread_data != NULL); + + if (SGX_SUCCESS != sgx_read_rand( + (unsigned char*)&thread_data->stack_guard, + sizeof(thread_data->stack_guard))) + abort(); +} diff --git a/sdk/trts/linux/metadata_sec.S b/sdk/trts/linux/metadata_sec.S new file mode 100644 index 0000000000..3ee2b52f04 --- /dev/null +++ b/sdk/trts/linux/metadata_sec.S @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + .file "metadata_sec.S" + +#define METADATA_SIZE 4096 +.section ".note.sgxmeta", "", @note + .p2align 0 /* section no alignment */ + .long 1f - 0f /* name size (not including padding) */ + .long 2f - 1f /* desc size (not including padding) */ + .long 0x01 /* type */ +0: .asciz "sgx_metadata" /* name */ +1: .fill METADATA_SIZE, 1, 0 /* desc - stand for metadata which is initialized with 0 */ +2: .p2align 0 diff --git a/sdk/trts/linux/tls_support.c b/sdk/trts/linux/tls_support.c new file mode 100644 index 0000000000..5726a22958 --- /dev/null +++ b/sdk/trts/linux/tls_support.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: tls_support.c + * Description: + * TLS support in the enclave. + */ + +#include "thread_data.h" + +typedef struct +{ + unsigned long int ti_module; + unsigned long int ti_offset; +} tls_index; + +#if defined SE_GNU32 +void * __attribute__((__regparm__(1))) ___tls_get_addr(tls_index *ti) +#elif defined SE_GNU64 +void *__tls_get_addr(tls_index *ti) +#endif +{ + thread_data_t *thread_data = get_thread_data(); + return (unsigned char *)thread_data->tls_addr + ti->ti_offset; +} diff --git a/sdk/trts/linux/trts_pic.S b/sdk/trts/linux/trts_pic.S new file mode 100644 index 0000000000..af47e443ab --- /dev/null +++ b/sdk/trts/linux/trts_pic.S @@ -0,0 +1,494 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* + * Description: + * The file provides `enclave_entry' function to switch code between + * trusted and untrusted envronment. + */ + + .file "trts_pic.S" + +#include "trts_pic.h" + + .text + +DECLARE_LOCAL_FUNC get_enclave_base + lea_pic __ImageBase, %xax + ret +DECLARE_LOCAL_FUNC get_enclave_state + lea_pic g_enclave_state, %xcx + xor %xax, %xax + movl (%xcx), %eax + ret +DECLARE_LOCAL_FUNC set_enclave_state + lea_pic g_enclave_state, %xax +#ifdef LINUX32 + mov SE_WORDSIZE(%esp), %edi +#endif + movl %edi, (%xax) + ret + +DECLARE_LOCAL_FUNC lock_enclave + lea_pic g_enclave_state, %xdx + xor %xax, %xax + mov $ENCLAVE_INIT_NOT_STARTED, %eax + xor %xcx, %xcx + mov $ENCLAVE_INIT_IN_PROGRESS, %ecx /* if (g_global_data.enclave_state == ENCLAVE_INIT_NOT_STARTED) */ + lock cmpxchgl %ecx, (%xdx) /* g_global_data.enclave_state == ENCLAVE_INIT_IN_PROGRESS */ + ret /* xax: the initial value of enclave state */ + +/* + * --------------------------------------------------------------------- + * Function: thread_data_t* get_thread_data(void); + * + * Get the address of thread_data + * --------------------------------------------------------------------- + */ +DECLARE_LOCAL_FUNC get_thread_data + READ_TD_DATA self_addr + ret + +/* + * --------------------------------------------------------------------- + * Function: enclave_entry + * The entry point of the enclave. + * + * Registers: + * XAX - TCS.CSSA + * XBX - the address of a TCS + * XCX - the address of the instruction following the EENTER + * XDI - the reason of entering the enclave + * XSI - the pointer to the marshalling structure + */ +DECLARE_GLOBAL_FUNC enclave_entry +/* + * ---------------------------------------------------------------------- + * Dispatch code according to CSSA and the reason of EENTER + * eax > 0 - exception handler + * edi >= 0 - ecall + * edi == -1 - do_init_enclave + * edi == -2 - oret + * Registers + * No need to use any register during the dipatch + * ---------------------------------------------------------------------- + */ + .cfi_startproc + cmp $0, %xax + jne .Ldo_handler /* handle exception state */ + xor %xdx, %xdx + READ_TD_DATA last_sp + cmp $0, %xax + jne .Lswitch_stack + GET_STACK_BASE %xbx /* if last_sp == 0, set sp to stack base */ + sub $STATIC_STACK_SIZE, %xax /* give space for static stack */ +.Lswitch_stack: + xchg %xsp, %xax + push %xcx + push %xbp + + .cfi_def_cfa_offset 2 * SE_WORDSIZE + .cfi_offset xbp, -2 * SE_WORDSIZE + mov %xsp, %xbp + .cfi_def_cfa_register xbp + + /* Save the registers */ + sub $(6*SE_WORDSIZE), %xsp + mov %xax, -1*SE_WORDSIZE(%xbp) /* xsp_u */ + mov %xdx, -3*SE_WORDSIZE(%xbp) /* cssa */ + mov %xbx, -4*SE_WORDSIZE(%xbp) /* TCS */ + mov %xsi, -5*SE_WORDSIZE(%xbp) /* XSI */ + mov %xdi, -6*SE_WORDSIZE(%xbp) /* XDI */ + +#ifdef LINUX64 + mov %rdx, %rcx + mov %rbx, %rdx +#endif + call enter_enclave + +.Lexit_enclave: + mov -1*SE_WORDSIZE(%xbp), %xdx /* xdx: xsp_u */ + mov %xbp, %xsp + pop %xbp /* xbp_u */ + pop %xbx /* ret_u */ + mov %xdx, %xsp /* xsp_u */ + mov $OCMD_ERET, %xdi + mov %xax, %xsi + +.Lclear_and_exit_enclave: + /* Clear all GPRs, except xax, xbx, xdi and xsi */ + xor %xcx, %xcx + xor %xdx, %xdx +#if defined(LINUX64) + xor %r8, %r8 + xor %r9, %r9 + xor %r10, %r10 + xor %r11, %r11 + xor %r12, %r12 + xor %r13, %r13 + xor %r14, %r14 + xor %r15, %r15 +#endif + + /* Set status flags to pre-defined values */ + add %xdx, %xdx /* OF = SF = AF = CF = 0; ZF = PF = 1 */ + + /* EEXIT */ + mov $SE_EEXIT, %xax /* EEXIT leaf */ + ENCLU + + /* Should not come here */ + ud2 + +.Ldo_handler: + mov %xax, %xdx /* XDX: cssa */ + GET_STACK_BASE %xbx /* XAX: static stack, set sp to stack base */ + jmp .Lswitch_stack + + /* Should not come here */ + ud2 + + .cfi_endproc + +/* + * ------------------------------------------------------------------------- + * sgx_status_t do_ocall(unsigned int index, void *ms); + * + * Function: do_ocall + * The entry point of the enclave + * Parameters: + * func_addr - target function address + * ms - marshalling structure + * + * Stack: (same as do_oret) + * bottom of stack -> + * ----------------- + * | ECALL/OCALL | + * previous TD.last_sp -> | frames | + * ----------------- + * | ECALL frame | + * | do_ocall param 2| 21 + * | do_ocall param 1| 20 + * |do_ocall ret_addr| 19 + * | ocall_depth | 18 + * | reserved | 17 + * | reserved | 16 + * | reserved | 15 + * | rbx | 14 + * | rsi | 13 + * | rdi | 12 + * | rbp | 11 + * | r12 | 10 + * | r13 | 9 + * | r14 | 8 + * | r15 | 7 + * | prev TD.last_sp | 6 + * | ocall_index | 5 + * | OCALL FLAG | 4 + * | shadow | 3 + * | shadow | 2 + * | shadow | 1 + * TD.last_sp -> | shadow | 0 + * ----------------- + * ------------------------------------------------------------------------- + */ +DECLARE_LOCAL_FUNC do_ocall + +/* + * 8 for GPR, 1 for TD.last_sp, 1 for ocall_index + * 1 for OCALL_FLAG, 4 for shadow space. + * Stack Pointer is 16-byte aligned under x86_64. + */ + sub $(19*SE_WORDSIZE), %xsp + + /* save non-volatile registers, except xsp */ + mov %xbx, SE_WORDSIZE*14(%xsp) + mov %xsi, SE_WORDSIZE*13(%xsp) + mov %xdi, SE_WORDSIZE*12(%xsp) + mov %xbp, SE_WORDSIZE*11(%xsp) + +#ifdef LINUX64 + mov %r12, SE_WORDSIZE*10(%rsp) + mov %r13, SE_WORDSIZE* 9(%rsp) + mov %r14, SE_WORDSIZE* 8(%rsp) + mov %r15, SE_WORDSIZE* 7(%rsp) +#endif + + /* set xdi and xsi using the input parameters */ +#ifdef LINUX64 + mov %edi, %edi /* it should clear the high 32bit word of RDI */ + /* + * rdi - param 1 (index), rsi - param 2 (ms) + * only use lower 32bit of rdi, rsi remains unchanged. + */ +#endif +#ifdef LINUX32 + mov SE_WORDSIZE*20(%esp), %edi + mov SE_WORDSIZE*21(%esp), %esi +#endif + + /* save ocall index to the stack */ + mov $OCALL_FLAG, %xax + mov %xax, SE_WORDSIZE*4(%xsp) /* save OCALL_FLAG */ + mov %xdi, SE_WORDSIZE*5(%xsp) /* save ocall_index */ + + /* + * save the inside stack context + * push TD.last_sp + * set TD.last_sp = xsp + */ + READ_TD_DATA self_addr + mov %xax, %xbx + + /* call update_ocall_lastsp */ +#ifdef LINUX32 + mov %xsp, (%xsp) +#else + mov %xsp, %xdi +#endif + + call update_ocall_lastsp /* xax: td.last_sp */ + +#ifdef LINUX64 + mov SE_WORDSIZE*12(%xsp), %xdi /* restore xdi */ + mov SE_WORDSIZE*13(%xsp), %xsi /* restore xdi */ +#endif + + /* restore outside stack context */ + mov first_ssa_gpr(%xbx), %xdx + mov ssa_bp_u(%xdx), %xbp + mov ssa_sp_u(%xdx), %xsp + /* + * set EEXIT registers + * return address can be read from the ECALL frame: + * TD.last_sp -> + * ------------- + * | ret_addr | + * | xbp_u | + * | xsp_u | + * | ... | + */ + mov -1*SE_WORDSIZE(%xax), %xbx /* return address */ + mov $SE_EEXIT, %xax /* EEXIT leaf */ + + /* Clear all GPRs, except xax, xbx, xdi, and xsi*/ + xor %xcx, %xcx + xor %xdx, %xdx +#ifdef LINUX64 + xor %r8, %r8 + xor %r9, %r9 + xor %r10, %r10 + xor %r11, %r11 + xor %r12, %r12 + xor %r13, %r13 + xor %r14, %r14 + xor %r15, %r15 +#endif + + /* Set status flags to pre-defined values */ + add %xdx, %xdx /* OF = SF = AF = CF = 0; ZF = PF = 1 */ + + ENCLU + +/* + * ------------------------------------------------------------------ + * this function is the wrapper of do_ocall, which is used to + * stick ocall bridge and proxy frame together + * ------------------------------------------------------------------ + */ +DECLARE_LOCAL_FUNC __morestack + .cfi_startproc + push %xbp + .cfi_def_cfa_offset 2*SE_WORDSIZE + .cfi_offset xbp,-2*SE_WORDSIZE + mov %xsp, %xbp + .cfi_def_cfa_register xbp + sub $(4*SE_WORDSIZE), %xsp +#ifdef LINUX32 + /* save the 2 parameters */ + mov (2*SE_WORDSIZE)(%xbp), %xax + mov %xax, (0*SE_WORDSIZE)(%xsp) + mov (3*SE_WORDSIZE)(%xbp), %xax + mov %xax, (1*SE_WORDSIZE)(%xsp) +#endif + call do_ocall + leave + ret + .cfi_endproc + +DECLARE_GLOBAL_FUNC asm_oret +#ifdef LINUX32 + mov SE_WORDSIZE(%xsp), %xdi + mov 2*SE_WORDSIZE(%xsp), %xsi +#endif + mov %xdi, %xsp /* restore thread_data.last_sp */ + mov %xsi, %xax /* ocall return value */ +#ifdef LINUX64 + mov 7*SE_WORDSIZE(%xsp), %r15 + mov 8*SE_WORDSIZE(%xsp), %r14 + mov 9*SE_WORDSIZE(%xsp), %r13 + mov 10*SE_WORDSIZE(%xsp), %r12 +#endif + + mov 11*SE_WORDSIZE(%xsp), %xbp + mov 12*SE_WORDSIZE(%xsp), %xdi + mov 13*SE_WORDSIZE(%xsp), %xsi + mov 14*SE_WORDSIZE(%xsp), %xbx + + add $(19*SE_WORDSIZE), %xsp + + ret + /* should not come here */ + ud2 + +/* + * ------------------------------------------------------------------------ + * extern "C" int do_egetkey(key_request_t *key_request, key_128bit_t *key) + * return value: + * 0 - success + * none-zeor - EGETKEY error code + * EGETKEY: rbx - the address of KEYREQUEST structure + * rcx - the address where the key is outputted + * ------------------------------------------------------------------------ + */ +DECLARE_LOCAL_FUNC do_egetkey + SE_PROLOG + mov $SE_EGETKEY, %xax /* EGETKEY leaf */ + ENCLU +#ifdef SE_SIM + cmp $SGX_SUCCESS, %xax /* In simulation mode, ZF flag will not be set */ + jnz .Legetkey_done /* because the stack clean operation will always clean ZF flag */ +#else + jz .Legetkey_done /* if EGETKEY error, ZF flag is set and error code is set to xax */ +#endif + xor %xax, %xax +.Legetkey_done: + SE_EPILOG + ret + + +/* + * ------------------------------------------------------------------------- + * extern "C" void do_ereport(sgx_target_info_t *target_info, sgx_report_data_t *report_data, sgx_report_t *report); + * EREPORT: rbx - the address of TARGETINFO; + * rcx - the address of REPORTDATA; + * rdx - the address where REPORT is outputted + * ------------------------------------------------------------------------- + */ +DECLARE_LOCAL_FUNC do_ereport + SE_PROLOG + mov $SE_EREPORT, %xax /* EREPORT leaf */ + ENCLU + SE_EPILOG + ret + +#define _RDRAND_RETRY_TIMES 10 +/* + * ------------------------------------- + * extern "C" uint32_t do_rdrand(uint32_t *rand); + * return value: + * non-zero: rdrand succeeded + * zero: rdrand failed + * ------------------------------------- + */ +DECLARE_LOCAL_FUNC do_rdrand + mov $_RDRAND_RETRY_TIMES, %ecx +.Lrdrand_retry: + .byte 0x0F, 0xC7, 0xF0 /* rdrand %eax */ + jc .Lrdrand_return + dec %ecx + jnz .Lrdrand_retry + xor %xax, %xax + ret +.Lrdrand_return: +#ifdef LINUX32 + mov SE_WORDSIZE(%esp), %ecx +#else + mov %rdi, %rcx +#endif + movl %eax, (%xcx) + mov $1, %xax + ret + +/* + * ------------------------------------------------------------------------- + * extern "C" void abort(void) __attribute__(__noreturn__); + * ------------------------------------------------------------------------- + */ +DECLARE_LOCAL_FUNC abort + lea_pic g_enclave_state, %xax + movl $ENCLAVE_CRASHED, (%xax) + ud2 + +/* + * ------------------------------------------------------------------------- + * extern "C" __attribute__((regparm(1))) void continue_execution(sgx_exception_info_t *info); + * ------------------------------------------------------------------------- + */ +DECLARE_LOCAL_FUNC continue_execution +#ifdef LINUX32 + mov %xax, %xcx +#else + mov %xdi, %xcx +#endif + mov SE_WORDSIZE*4(%xcx), %xdx + mov %xdx, %xsp + sub $(SE_WORDSIZE), %xsp +#ifdef LINUX64 + mov SE_WORDSIZE*17(%xcx), %xax +#else + mov SE_WORDSIZE*9(%xcx), %xax +#endif + mov %xax, (%xsp) + mov SE_WORDSIZE*0(%xcx), %xax + mov SE_WORDSIZE*2(%xcx), %xdx + mov SE_WORDSIZE*3(%xcx), %xbx + mov SE_WORDSIZE*5(%xcx), %xbp + mov SE_WORDSIZE*6(%xcx), %xsi + mov SE_WORDSIZE*7(%xcx), %xdi +#ifdef LINUX64 + mov SE_WORDSIZE*8(%xcx), %xsi + mov SE_WORDSIZE*9(%xcx), %xsi + mov SE_WORDSIZE*10(%xcx), %xsi + mov SE_WORDSIZE*11(%xcx), %xsi + mov SE_WORDSIZE*12(%xcx), %xsi + mov SE_WORDSIZE*13(%xcx), %xsi + mov SE_WORDSIZE*14(%xcx), %xsi + mov SE_WORDSIZE*15(%xcx), %xsi + push SE_WORDSIZE*16(%xcx) + popf +#else + push SE_WORDSIZE*8(%xcx) + popf +#endif + mov SE_WORDSIZE*1(%xcx), %xcx + ret diff --git a/sdk/trts/linux/trts_pic.h b/sdk/trts/linux/trts_pic.h new file mode 100644 index 0000000000..2f0484d530 --- /dev/null +++ b/sdk/trts/linux/trts_pic.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* + * This header contains constant definitions for tRTS. + */ + +#ifndef TRTS_PIC_H__ +#define TRTS_PIC_H__ + +#include "linux/linux-regs.h" +#include "rts_cmd.h" + +#define SE_GUARD_PAGE_SIZE 0x1000 + +#define ENCLAVE_INIT_NOT_STARTED 0 +#define ENCLAVE_INIT_IN_PROGRESS 1 +#define ENCLAVE_INIT_DONE 2 +#define ENCLAVE_CRASHED 3 + +/* Status */ +#define SGX_SUCCESS 0 +#define SGX_ERROR_UNEXPECTED 0x000000001 // Unexpected error +#define SGX_ERROR_INVALID_FUNCTION 0x000001001 // Invalid ecall/ocall function +#define SGX_ERROR_INVALID_ENCLAVE 0x000002001 // The enclave image is incorrect +#define SGX_ERROR_ENCLAVE_CRASHED 0x000001006 // enclave is crashed +#define SGX_ERROR_STACK_OVERRUN 0x000001009 // enclave is running out of stack + +#define STATIC_STACK_SIZE (SE_WORDSIZE * 100) + +/* Thread Data + * c.f. data structure defintion for thread_data_t in `rts.h'. + */ +#define last_sp (SE_WORDSIZE * 1) +#define stack_base_addr (SE_WORDSIZE * 2) +#define stack_limit_addr (SE_WORDSIZE * 3) +#define first_ssa_gpr (SE_WORDSIZE * 4) +#define self_addr 0 + +/* SSA GPR */ +#define ssa_sp_t 32 +#define ssa_sp_u 144 +#define ssa_bp_u 152 +#define ssa_exit_info 160 +#endif + +#define EXIT_INFO_VALID 0x80000000 +/* OCALL command */ +#define OCALL_FLAG 0x04F434944 + +#define dtv SE_WORDSIZE +#define tls 0 +.macro READ_TD_DATA offset +#ifdef SE_SIM +/* TLS support in simulation mode + * see "sdk/simulation/uinst/linux/set_tls.c" + * and "sdk/simulation/assembly/linux/gnu_tls.h" + * TD address (tcs->ofs_base) is set to tcb_head->dtv->value. + * The offset of tcb_head->dtv->value is SE_WORDSIZE. + */ + +#if defined(LINUX32) + mov %gs:dtv, %xax +#elif defined(LINUX64) + mov %fs:dtv, %xax +#endif + mov tls(%xax), %xax + mov \offset(%xax), %xax + +#else /* SE_SIM */ + +#if defined(LINUX32) + mov %fs:\offset, %xax +#elif defined(LINUX64) + mov %gs:\offset, %xax +#endif + +#endif /* !SE_SIM */ +.endm + +.macro GET_STACK_BASE tcs + mov \tcs, %xax + sub $SE_GUARD_PAGE_SIZE, %xax +.endm diff --git a/sdk/trts/linux/x86/Makefile b/sdk/trts/linux/x86/Makefile new file mode 100644 index 0000000000..414f0063db --- /dev/null +++ b/sdk/trts/linux/x86/Makefile @@ -0,0 +1,45 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../../buildenv.mk + +CPPFLAGS += -I$(LINUX_SDK_DIR)/cpprt/linux/libunwind/src/x86 +OBJS := setcontext.o + +.PHONY: all +all: $(OBJS) + +$(OBJS): %.o: %.S + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + @$(RM) *.o diff --git a/sdk/trts/linux/x86/setcontext.S b/sdk/trts/linux/x86/setcontext.S new file mode 100644 index 0000000000..1b90fc0732 --- /dev/null +++ b/sdk/trts/linux/x86/setcontext.S @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "offsets.h" + + .global setcontext + .type setcontext, @function +setcontext: + movl 4(%esp),%eax /* ucontext_t* */ + + /* restore FP state */ + movl LINUX_UC_FPREGS_PTR_OFF(%eax), %ecx + fldenv (%ecx) + +#ifdef SE_SIM + /* restore FS */ + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FS_OFF)(%eax), %ecx + + movl %ecx, %fs +#endif + + /* new stack */ + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ESP_OFF)(%eax), %esp + + /* push the return address on the stack */ + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EIP_OFF)(%eax), %ecx + pushl %ecx + + /* restore GPRs */ + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EDI_OFF)(%eax), %edi + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ESI_OFF)(%eax), %esi + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EBP_OFF)(%eax), %ebp + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EBX_OFF)(%eax), %ebx + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EDX_OFF)(%eax), %edx + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ECX_OFF)(%eax), %ecx + movl (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EAX_OFF)(%eax), %eax + + ret diff --git a/sdk/trts/linux/x86_64/Makefile b/sdk/trts/linux/x86_64/Makefile new file mode 100644 index 0000000000..74b347ad3b --- /dev/null +++ b/sdk/trts/linux/x86_64/Makefile @@ -0,0 +1,46 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../../buildenv.mk + +CPPFLAGS += -I$(LINUX_SDK_DIR)/cpprt/linux/libunwind/src/x86_64 +CFLAGS += -DISE=1 +OBJS := setcontext.o + +$(OBJS): %.o: %.S + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +.PHONY: all +all: $(OBJS) + +.PHONY: clean +clean: + @$(RM) *.o diff --git a/sdk/trts/linux/x86_64/setcontext.S b/sdk/trts/linux/x86_64/setcontext.S new file mode 100644 index 0000000000..a43fbf3648 --- /dev/null +++ b/sdk/trts/linux/x86_64/setcontext.S @@ -0,0 +1,117 @@ +/* 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" +#if (!ISE) +#if defined __linux__ +#include +#define SIG_SETMASK 2 +#define SIGSET_BYTE_SIZE (64/8) +#elif defined __FreeBSD__ +#include +#endif +#endif + +/* 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__ +#if (!ISE) + /* restore signal mask + sigprocmask(SIG_SETMASK, ucp->uc_sigmask, NULL, sizeof(sigset_t)) */ + push %rdi + mov $__NR_rt_sigprocmask, %rax + lea UC_SIGMASK(%rdi), %rsi + mov $SIG_SETMASK, %rdi + xor %rdx, %rdx + mov $SIGSET_BYTE_SIZE, %r10 + syscall + pop %rdi +#endif + + /* restore fp state */ + mov UC_MCONTEXT_FPREGS_PTR(%rdi),%r8 + fldenv (%r8) + ldmxcsr FPREGS_OFFSET_MXCSR(%r8) +#elif defined __FreeBSD__ +#if (!ISE) + /* restore signal mask */ + pushq %rdi + xorl %edx,%edx + leaq UC_SIGMASK(%rdi),%rsi + movl $3,%edi/* SIG_SETMASK */ + movl $SYS_sigprocmask,%eax + movq %rcx,%r10 + syscall + popq %rdi +#endif + + /* 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/sdk/trts/trts.cpp b/sdk/trts/trts.cpp new file mode 100644 index 0000000000..f48ec2f1ea --- /dev/null +++ b/sdk/trts/trts.cpp @@ -0,0 +1,323 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sgx_trts.h" +#include "sgx_edger8r.h" +#include "trts_inst.h" +#include +#include +#include "util.h" +#include "thread_data.h" +#include "global_data.h" + +#include "internal/rts.h" + +#ifdef SE_SIM +#include "t_instructions.h" /* for `g_global_data_sim' */ +#include "sgx_spinlock.h" +#endif + + + +#ifndef SE_SIM + +#include "se_cdefs.h" + +// add a version to trts +SGX_ACCESS_VERSION(trts, 1); + +#endif + +// sgx_is_within_enclave() +// Parameters: +// addr - the start address of the buffer +// size - the size of the buffer +// Return Value: +// 1 - the buffer is strictly within the enclave +// 0 - the whole buffer or part of the buffer is not within the enclave, +// or the buffer is wrap around +// +int sgx_is_within_enclave(const void *addr, size_t size) +{ + size_t start = reinterpret_cast(addr); + size_t end = 0; + size_t enclave_start = (size_t)&__ImageBase; + size_t enclave_end = enclave_start + g_global_data.enclave_size - 1; + // g_global_data.enclave_end = enclave_base + enclave_size - 1; + // so the enclave range is [enclave_start, enclave_end] inclusively + + if(size > 0) + { + end = start + size - 1; + } + else + { + end = start; + } + if( (start <= end) && (start >= enclave_start) && (end <= enclave_end) ) + { + return 1; + } + return 0; +} + +// sgx_is_outside_enclave() +// Parameters: +// addr - the start address of the buffer +// size - the size of the buffer +// Return Value: +// 1 - the buffer is strictly outside the enclave +// 0 - the whole buffer or part of the buffer is not outside the enclave, +// or the buffer is wrap around +// +int sgx_is_outside_enclave(const void *addr, size_t size) +{ + size_t start = reinterpret_cast(addr); + size_t end = 0; + size_t enclave_start = (size_t)&__ImageBase; + size_t enclave_end = enclave_start + g_global_data.enclave_size - 1; + // g_global_data.enclave_end = enclave_base + enclave_size - 1; + // so the enclave range is [enclave_start, enclave_end] inclusively + + if(size > 0) + { + end = start + size - 1; + } + else + { + end = start; + } + if( (start <= end) && ((end < enclave_start) || (start > enclave_end)) ) + { + return 1; + } + return 0; +} + +// sgx_ocalloc() +// Parameters: +// size - bytes to allocate on the outside stack +// Return Value: +// the pointer to the allocated space on the outside stack +// NULL - fail to allocate +// +// sgx_ocalloc allocates memory on the outside stack. It is only used for OCALL, and will be auto freed when ECALL returns. +// To achieve this, the outside stack pointer in SSA is updated when the stack memory is allocated, +// but the outside stack pointer saved in the ECALL stack frame is not changed accordingly. +// When doing an OCALL, the stack pointer is set as the value in SSA and EEXIT. +// When ECALL or exception handling returns, the stack pointer is set as the value in the ECALL stack frame and then EEXIT, +// so the outside stack is automatically unwind. +// In addition, sgx_ocalloc needs perform outside stack probe to make sure it is not allocating beyond the end of the stack. +#define OC_ROUND 16 +void * sgx_ocalloc(size_t size) +{ + // read the outside stack address from current SSA + thread_data_t *thread_data = get_thread_data(); + ssa_gpr_t *ssa_gpr = reinterpret_cast(thread_data->first_ssa_gpr); + size_t addr = ssa_gpr->REG(sp_u); + + // check u_rsp points to the untrusted address. + // if the check fails, it should be hacked. call abort directly + if(!sgx_is_outside_enclave(reinterpret_cast(addr), sizeof(size_t))) + { + abort(); + } + + // size is too large to allocate. call abort() directly. + if(addr < size) + { + abort(); + } + + // calculate the start address for the allocated memory + addr -= size; + addr &= ~(static_cast(OC_ROUND - 1)); // for stack alignment + + // the allocated memory has overlap with enclave, abort the enclave + if(!sgx_is_outside_enclave(reinterpret_cast(addr), size)) + { + abort(); + } + + // probe the outside stack to ensure that we do not skip over the stack3 guard page + // we need to probe all the pages including the first page and the last page + // the first page need to be probed in case uRTS didnot touch that page before EENTER enclave + // the last page need to be probed in case the enclave didnot touch that page before another OCALLOC + size_t first_page = TRIM_TO_PAGE(ssa_gpr->REG(sp_u) - 1); + size_t last_page = TRIM_TO_PAGE(addr); + + // To avoid the dead-loop in the following for(...) loop. + // Attacker might fake a stack address that is within address 0x4095. + if (last_page == 0) + { + abort(); + } + + // the compiler may optimize the following code to probe the pages in any order + // while we only expect the probe order should be from higher addr to lower addr + // so use volatile to avoid optimization by the compiler + for(volatile size_t page = first_page; page >= last_page; page -= SE_PAGE_SIZE) + { + *reinterpret_cast(page) = 0; + } + + // update the outside stack address in the SSA + ssa_gpr->REG(sp_u) = addr; + + return reinterpret_cast(addr); +} + +// sgx_ocfree() +// Parameters: +// N/A +// Return Value: +// N/A +// sgx_ocfree restores the original outside stack pointer in the SSA. +// Do not call this function if you still need the buffer allocated by sgx_ocalloc within the ECALL. +void sgx_ocfree() +{ + // ECALL stack frame + // last_sp -> | | + // ------------- + // | ret_addr | + // | xbp_u | + // | xsp_u | + + thread_data_t *thread_data = get_thread_data(); + ssa_gpr_t *ssa_gpr = reinterpret_cast(thread_data->first_ssa_gpr); + uintptr_t *addr = reinterpret_cast(thread_data->last_sp); + uintptr_t usp = *(addr - 3); + if(!sgx_is_outside_enclave(reinterpret_cast(usp), sizeof(uintptr_t))) + { + abort(); + } + ssa_gpr->REG(sp_u) = usp; +} + +#ifdef SE_SIM +static sgx_spinlock_t g_seed_lock = SGX_SPINLOCK_INITIALIZER; + +static uint32_t get_rand_lcg() +{ + sgx_spin_lock(&g_seed_lock); + + uint32_t& seed = g_global_data_sim.seed; + seed = seed * 1103515245 + 12345; + uint32_t n = (seed % ((uint32_t)RAND_MAX + 1)); + + sgx_spin_unlock(&g_seed_lock); + + return n; +} +#endif + +static sgx_status_t __do_get_rand32(uint32_t* rand_num) +{ +#ifndef SE_SIM + /* We expect the CPU has RDRAND support for HW mode. Otherwise, an exception will be thrown + * do_rdrand() will try to call RDRAND for 10 times + */ + if(0 == do_rdrand(rand_num)) + return SGX_ERROR_UNEXPECTED; +#else + /* use LCG in simulation mode */ + *rand_num = get_rand_lcg(); +#endif + return SGX_SUCCESS; +} + +sgx_status_t sgx_read_rand(unsigned char *rand, size_t length_in_bytes) +{ + // check parameters + // + // rand can be within or outside the enclave + if(!rand || !length_in_bytes) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if(!sgx_is_within_enclave(rand, length_in_bytes) && !sgx_is_outside_enclave(rand, length_in_bytes)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // loop to rdrand + uint32_t rand_num = 0; + while(length_in_bytes > 0) + { + sgx_status_t status = __do_get_rand32(&rand_num); + if(status != SGX_SUCCESS) + { + return status; + } + + size_t size = (length_in_bytes < sizeof(rand_num)) ? length_in_bytes : sizeof(rand_num); + memcpy(rand, &rand_num, size); + + rand += size; + length_in_bytes -= size; + } + memset_s(&rand_num, sizeof(rand_num), 0, sizeof(rand_num)); + return SGX_SUCCESS; +} + +#include "trts_internal.h" +extern "C" int enter_enclave(int index, void *ms, void *tcs, int cssa) +{ + if(get_enclave_state() == ENCLAVE_CRASHED) + { + return SGX_ERROR_ENCLAVE_CRASHED; + } + + sgx_status_t error = SGX_ERROR_UNEXPECTED; + if(cssa == 0) + { + if(index >= 0) + { + error = do_ecall(index, ms, tcs); + } + else if(index == ECMD_INIT_ENCLAVE) + { + error = do_init_enclave(ms); + } + else if(index == ECMD_ORET) + { + error = do_oret(ms); + } + } + else if((cssa == 1) && (index == ECMD_EXCEPT)) + { + error = trts_handle_exception(tcs); + } + if(error == SGX_ERROR_UNEXPECTED) + { + set_enclave_state(ENCLAVE_CRASHED); + } + return error; +} diff --git a/sdk/trts/trts_ecall.cpp b/sdk/trts/trts_ecall.cpp new file mode 100644 index 0000000000..4612ccc4ae --- /dev/null +++ b/sdk/trts/trts_ecall.cpp @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_memcpy.h" +#include "thread_data.h" +#include "global_data.h" +#include "rts.h" +#include "util.h" +#include "xsave.h" +#include "sgx_trts.h" +#include "sgx_spinlock.h" +#include "global_init.h" +#include "trts_internal.h" + +# include "linux/elf_parser.h" +# define GET_TLS_INFO elf_tls_info + +// is_ecall_allowed() +// check the index in the dynamic entry table +static sgx_status_t is_ecall_allowed(uint32_t ordinal) +{ + if(ordinal >= g_ecall_table.nr_ecall) + { + return SGX_ERROR_INVALID_FUNCTION; + } + thread_data_t *thread_data = get_thread_data(); + if(thread_data->last_sp == thread_data->stack_base_addr) + { + // root ECALL, check the priv bits. + if (g_ecall_table.ecall_table[ordinal].is_priv) + return SGX_ERROR_ECALL_NOT_ALLOWED; + return SGX_SUCCESS; + } + ocall_context_t *context = reinterpret_cast(thread_data->last_sp); + if(context->ocall_flag != OCALL_FLAG) + { + // abort the enclave if ocall frame is invalid + abort(); + } + uintptr_t ocall_index = context->ocall_index; + if(ocall_index >= g_dyn_entry_table.nr_ocall) + { + return SGX_ERROR_INVALID_FUNCTION; + } + return (g_dyn_entry_table.entry_table[ocall_index * g_ecall_table.nr_ecall + ordinal] ? SGX_SUCCESS : SGX_ERROR_ECALL_NOT_ALLOWED); +} +// get_func_addr() +// Get the address of ecall function from the ecall table +// Parameters: +// [IN] ordinal - the index of the ecall function in the ecall table +// Return Value: +// non-zero - success +// zero - fail +// +static sgx_status_t get_func_addr(uint32_t ordinal, void **addr) +{ + sgx_status_t status = is_ecall_allowed(ordinal); + if(SGX_SUCCESS != status) + { + return status; + } + + *addr = const_cast(g_ecall_table.ecall_table[ordinal].ecall_addr); + if(!sgx_is_within_enclave(*addr, 0)) + { + return SGX_ERROR_UNEXPECTED; + } + + return SGX_SUCCESS; +} + +static volatile bool g_is_first_ecall = true; +static volatile sgx_spinlock_t g_ife_lock = SGX_SPINLOCK_INITIALIZER; + +typedef sgx_status_t (*ecall_func_t)(void *ms); +static sgx_status_t trts_ecall(uint32_t ordinal, void *ms) +{ + if (unlikely(g_is_first_ecall)) + { + // The thread performing the global initialization cannot do a nested ECall + thread_data_t *thread_data = get_thread_data(); + if (thread_data->last_sp != thread_data->stack_base_addr) + { // nested ecall + return SGX_ERROR_ECALL_NOT_ALLOWED; + } + + sgx_spin_lock(&g_ife_lock); + if (g_is_first_ecall) + { + //invoke global object's construction + init_global_object(); + g_is_first_ecall = false; + } + sgx_spin_unlock(&g_ife_lock); + } + + void *addr = NULL; + sgx_status_t status = get_func_addr(ordinal, &addr); + if(status == SGX_SUCCESS) + { + ecall_func_t func = (ecall_func_t)addr; + status = func(ms); + } + + // clean extended registers, no need to save + CLEAN_XFEATURE_REGS + return status; +} + +extern "C" void init_stack_guard(); +static sgx_status_t do_init_thread(void *tcs) +{ + thread_data_t *thread_data = GET_PTR(thread_data_t, tcs, g_global_data.td_template.self_addr); + memcpy_s(thread_data, SE_PAGE_SIZE, const_cast(&g_global_data.td_template), sizeof(thread_data_t)); + thread_data->last_sp += (size_t)tcs; + thread_data->self_addr += (size_t)tcs; + thread_data->stack_base_addr += (size_t)tcs; + thread_data->stack_limit_addr += (size_t)tcs; + thread_data->first_ssa_gpr += (size_t)tcs; + thread_data->tls_array += (size_t)tcs; + thread_data->tls_addr += (size_t)tcs; + + thread_data->last_sp -= (size_t)STATIC_STACK_SIZE; + thread_data->stack_base_addr -= (size_t)STATIC_STACK_SIZE; + + uintptr_t tls_addr = 0; + size_t tdata_size = 0; + + if(0 != GET_TLS_INFO(&__ImageBase, &tls_addr, &tdata_size)) + { + return SGX_ERROR_UNEXPECTED; + } + if(tls_addr) + { + memset((void *)TRIM_TO_PAGE(thread_data->tls_addr), 0, ROUND_TO_PAGE(thread_data->self_addr - thread_data->tls_addr)); + memcpy_s((void *)(thread_data->tls_addr), thread_data->self_addr - thread_data->tls_addr, (void *)tls_addr, tdata_size); + } + init_stack_guard(); + return SGX_SUCCESS; +} +sgx_status_t do_ecall(int index, void *ms, void *tcs) +{ + sgx_status_t status = SGX_ERROR_UNEXPECTED; + if(ENCLAVE_INIT_DONE != get_enclave_state()) + { + return status; + } + thread_data_t *thread_data = get_thread_data(); + if( (NULL == thread_data) || ((thread_data->stack_base_addr == thread_data->last_sp) && (0 != g_global_data.thread_policy))) + { + status = do_init_thread(tcs); + if(0 != status) + { + return status; + } + } + status = trts_ecall(index, ms); + return status; +} + diff --git a/sdk/trts/trts_internal.h b/sdk/trts/trts_internal.h new file mode 100644 index 0000000000..6c781c5d54 --- /dev/null +++ b/sdk/trts/trts_internal.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef TRTS_INTERNAL_H +#define TRTS_INTERNAL_H + +#include "util.h" + +#ifdef SE_64 +#define STATIC_STACK_SIZE 8*100 +#else +#define STATIC_STACK_SIZE 4*100 +#endif + +#define TD2TCS(td) ((const void *)(((thread_data_t*)(td))->stack_base_addr + (size_t)STATIC_STACK_SIZE + (size_t)SE_GUARD_PAGE_SIZE)) + +typedef struct { + const void *ecall_addr; + uint8_t is_priv; +} ecall_addr_t; + +typedef struct { + size_t nr_ecall; + ecall_addr_t ecall_table[1]; +} ecall_table_t; + +typedef struct { + size_t nr_ocall; + uint8_t entry_table[1]; +} entry_table_t; + + +#ifdef __cplusplus +extern "C" { +#endif +extern ecall_table_t g_ecall_table; +extern entry_table_t g_dyn_entry_table; + +int lock_enclave(); +void *get_enclave_base(); +int get_enclave_state(); +void set_enclave_state(int state); + +sgx_status_t do_init_enclave(void *ms); +sgx_status_t do_ecall(int index, void *ms, void *tcs); +sgx_status_t do_oret(void *ms); +sgx_status_t trts_handle_exception(void *tcs); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/trts/trts_ocall.cpp b/sdk/trts/trts_ocall.cpp new file mode 100644 index 0000000000..7d08783e59 --- /dev/null +++ b/sdk/trts/trts_ocall.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include +#include "thread_data.h" +#include "global_data.h" +#include "sgx_edger8r.h" +#include "rts.h" +#include "util.h" +#include "xsave.h" +#include "trts_internal.h" + +extern "C" sgx_status_t asm_oret(uintptr_t sp, void *ms); +extern "C" sgx_status_t __morestack(const unsigned int index, void *ms); +#define do_ocall __morestack + +// +// sgx_ocall +// Parameters: +// index - the index in the ocall table +// ms - the mashalling structure +// Return Value: +// OCALL status +// +sgx_status_t sgx_ocall(const unsigned int index, void *ms) +{ + // sgx_ocall is not allowed during exception handling + thread_data_t *thread_data = get_thread_data(); + + // we have exceptions being handled + if(thread_data->exception_flag != 0) { + return SGX_ERROR_OCALL_NOT_ALLOWED; + } + // the OCALL index should be within the ocall table range + if(static_cast(index) >= g_dyn_entry_table.nr_ocall) + { + return SGX_ERROR_INVALID_FUNCTION; + } + // save and clean extended feature registers + uint8_t buffer[FXSAVE_SIZE] = {0}; + save_and_clean_xfeature_regs(buffer); + + // do sgx_ocall + sgx_status_t status = do_ocall(index, ms); + + // restore extended feature registers + restore_xfeature_regs(buffer); + + // clear buffer to avoid secret leaking + memset_s(buffer, FXSAVE_SIZE, 0, FXSAVE_SIZE); + + return status; +} + +extern "C" +uintptr_t update_ocall_lastsp(ocall_context_t* context) +{ + thread_data_t* thread_data = get_thread_data(); + + uintptr_t last_sp = 0; + + last_sp = thread_data->last_sp; + + context->pre_last_sp = last_sp; + + if (context->pre_last_sp == thread_data->stack_base_addr) + { + context->ocall_depth = 1; + } else { + // thread_data->last_sp is only set when ocall or exception handling occurs + // ocall is block during exception handling, so last_sp is always ocall frame here + ocall_context_t* context_pre = reinterpret_cast(context->pre_last_sp); + context->ocall_depth = context_pre->ocall_depth + 1; + } + + thread_data->last_sp = reinterpret_cast(context); + + return last_sp; +} + +sgx_status_t do_oret(void *ms) +{ + thread_data_t *thread_data = get_thread_data(); + uintptr_t last_sp = thread_data->last_sp; + ocall_context_t *context = reinterpret_cast(thread_data->last_sp); + if(0 == last_sp) + { + return SGX_ERROR_UNEXPECTED; + } + // At least 1 ecall frame and 1 ocall frame are expected on stack. + // 30 is an estimated value: 8 for enclave_entry and 22 for do_ocall. + if(last_sp > thread_data->stack_base_addr - 30 * sizeof(size_t)) + { + goto invalid_ocall_frame; + } + if(context->ocall_flag != OCALL_FLAG) + { + goto invalid_ocall_frame; + } + if(context->pre_last_sp > thread_data->stack_base_addr) + { + goto invalid_ocall_frame; + } + if(context->pre_last_sp <= (uintptr_t)&context) + { + goto invalid_ocall_frame; + } + thread_data->last_sp = context->pre_last_sp; + asm_oret(last_sp, ms); + +invalid_ocall_frame: + return SGX_ERROR_UNEXPECTED; +} + diff --git a/sdk/trts/trts_util.cpp b/sdk/trts/trts_util.cpp new file mode 100644 index 0000000000..9e86f5c75d --- /dev/null +++ b/sdk/trts/trts_util.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "trts_util.h" +#include "global_data.h" +#include "util.h" +#include "thread_data.h" + +// No need to check the state of enclave or thread. +// The functions should be called within an ECALL, so the enclave and thread must be initialized at that time. +void * get_heap_base(void) +{ + return GET_PTR(void, &__ImageBase, g_global_data.heap_offset); +} + +size_t get_heap_size(void) +{ + return g_global_data.heap_size; +} + +int * get_errno_addr(void) +{ + thread_data_t *thread_data = get_thread_data(); + return reinterpret_cast(&thread_data->last_error); +} + diff --git a/sdk/trts/trts_util.h b/sdk/trts/trts_util.h new file mode 100644 index 0000000000..a6e440aaad --- /dev/null +++ b/sdk/trts/trts_util.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _TRTS_UTIL_H_ +#define _TRTS_UTIL_H_ + +#include /* for size_t */ +#include "se_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void * get_heap_base(void); +size_t get_heap_size(void); +int * get_errno_addr(void); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/sdk/trts/trts_veh.cpp b/sdk/trts/trts_veh.cpp new file mode 100644 index 0000000000..c338d82c9d --- /dev/null +++ b/sdk/trts/trts_veh.cpp @@ -0,0 +1,395 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/** + * File: trts_veh.cpp + * Description: + * This file implements the support of custom exception handling. + */ + +#include "sgx_trts_exception.h" +#include +#include "sgx_trts.h" +#include "xsave.h" +#include "arch.h" +#include "sgx_spinlock.h" +#include "thread_data.h" +#include "global_data.h" +#include "trts_internal.h" + +typedef struct _handler_node_t +{ + uintptr_t callback; + struct _handler_node_t *next; +} handler_node_t; + +static handler_node_t *g_first_node = NULL; +static sgx_spinlock_t g_handler_lock = SGX_SPINLOCK_INITIALIZER; + +static uintptr_t g_veh_cookie = 0; +#define ENC_VEH_POINTER(x) (uintptr_t)(x) ^ g_veh_cookie +#define DEC_VEH_POINTER(x) (sgx_exception_handler_t)((x) ^ g_veh_cookie) + +static bool is_stack_addr(void *address, size_t size) +{ + thread_data_t *thread_data = get_thread_data(); + size_t stack_base = thread_data->stack_base_addr; + size_t stack_top = thread_data->stack_limit_addr; + size_t addr = (size_t) address; + return (addr <= (addr + size)) && (stack_base >= (addr + size)) && (stack_top <= addr); +} +static bool is_valid_sp(uintptr_t sp) +{ + return ( !(sp & (sizeof(uintptr_t) - 1)) // sp is expected to be 4/8 bytes aligned + && is_stack_addr((void*)sp, 0) ); // sp points to the top/bottom of stack are accepted +} + +// sgx_register_exception_handler() +// register a custom exception handler +// Parameter +// is_first_handler - the order in which the handler should be called. +// if the parameter is nonzero, the handler is the first handler to be called. +// if the parameter is zero, the handler is the last handler to be called. +// exception_handler - a pointer to the handler to be called. +// Return Value +// handler - success +// NULL - fail +void *sgx_register_exception_handler(int is_first_handler, sgx_exception_handler_t exception_handler) +{ + // initialize g_veh_cookie for the first time sgx_register_exception_handler is called. + if(unlikely(g_veh_cookie == 0)) + { + uintptr_t rand = 0; + do + { + if(SGX_SUCCESS != sgx_read_rand((unsigned char *)&rand, sizeof(rand))) + { + return NULL; + } + } while(rand == 0); + + sgx_spin_lock(&g_handler_lock); + if(g_veh_cookie == 0) + { + g_veh_cookie = rand; + } + sgx_spin_unlock(&g_handler_lock); + } + if(!sgx_is_within_enclave((const void*)exception_handler, 0)) + { + return NULL; + } + handler_node_t *node = (handler_node_t *)malloc(sizeof(handler_node_t)); + if(!node) + { + return NULL; + } + node->callback = ENC_VEH_POINTER(exception_handler); + + // write lock + sgx_spin_lock(&g_handler_lock); + + if((g_first_node == NULL) || is_first_handler) + { + node->next = g_first_node; + g_first_node = node; + } + else + { + handler_node_t *tmp = g_first_node; + while(tmp->next != NULL) + { + tmp = tmp->next; + } + node->next = NULL; + tmp->next = node; + } + // write unlock + sgx_spin_unlock(&g_handler_lock); + + return node; +} +// sgx_unregister_exception_handler() +// unregister a custom exception handler. +// Parameter +// handler - a handler to the custom exception handler previously +// registered using the sgx_register_exception_handler function. +// Return Value +// none zero - success +// 0 - fail +int sgx_unregister_exception_handler(void *handler) +{ + if(!handler) + { + return 0; + } + + int status = 0; + + // write lock + sgx_spin_lock(&g_handler_lock); + + if(g_first_node) + { + handler_node_t *node = g_first_node; + if(node == handler) + { + g_first_node = node->next; + status = 1; + } + else + { + while(node->next != NULL) + { + if(node->next == handler) + { + node->next = node->next->next; + status = 1; + break; + } + node = node->next; + } + } + } + // write unlock + sgx_spin_unlock(&g_handler_lock); + + if(status) free(handler); + return status; +} + +// continue_execution(sgx_exception_info_t *info): +// try to restore the thread context saved in info to current execution context. +extern "C" __attribute__((regparm(1))) void continue_execution(sgx_exception_info_t *info); + +// internal_handle_exception(sgx_exception_info_t *info): +// the 2nd phrase exception handing, which traverse registered exception handlers. +// if the exception can be handled, then continue execution +// otherwise, throw abortion, go back to 1st phrase, and call the default handler. +extern "C" __attribute__((regparm(1))) void internal_handle_exception(sgx_exception_info_t *info) +{ + int status = EXCEPTION_CONTINUE_SEARCH; + handler_node_t *node = NULL; + thread_data_t *thread_data = get_thread_data(); + size_t size = 0; + uintptr_t *nhead = NULL; + uintptr_t *ntmp = NULL; + uintptr_t xsp = 0; + + if (thread_data->exception_flag < 0) + goto failed_end; + thread_data->exception_flag++; + + // read lock + sgx_spin_lock(&g_handler_lock); + + node = g_first_node; + while(node != NULL) + { + size += sizeof(uintptr_t); + node = node->next; + } + + if (size == 0 || (nhead = (uintptr_t *)malloc(size)) == NULL) + { + sgx_spin_unlock(&g_handler_lock); + goto failed_end; + } + ntmp = nhead; + node = g_first_node; + while(node != NULL) + { + *ntmp = node->callback; + ntmp++; + node = node->next; + } + + // read unlock + sgx_spin_unlock(&g_handler_lock); + + // call exception handler until EXCEPTION_CONTINUE_EXECUTION is returned + ntmp = nhead; + while(size > 0) + { + sgx_exception_handler_t handler = DEC_VEH_POINTER(*ntmp); + status = handler(info); + if(EXCEPTION_CONTINUE_EXECUTION == status) + { + break; + } + ntmp++; + size -= sizeof(sgx_exception_handler_t); + } + free(nhead); + + // call default handler + // ignore invalid return value, treat to EXCEPTION_CONTINUE_SEARCH + // check SP to be written on SSA is pointing to the trusted stack + xsp = info->cpu_context.REG(sp); + if (!is_valid_sp(xsp)) + { + goto failed_end; + } + + if(EXCEPTION_CONTINUE_EXECUTION == status) + { + //exception is handled, decrease the nested exception count + thread_data->exception_flag--; + } + else + { + //exception cannot be handled + thread_data->exception_flag = -1; + } + + //instruction triggering the exception will be executed again. + continue_execution(info); + +failed_end: + thread_data->exception_flag = -1; // mark the current exception cannot be handled + abort(); // throw abortion +} + +// trts_handle_exception(void *tcs) +// the entry point for the exceptoin handling +// Parameter +// the pointer of TCS +// Return Value +// none zero - success +// 0 - fail +#include "trts_internal.h" +extern "C" sgx_status_t trts_handle_exception(void *tcs) +{ + thread_data_t *thread_data = get_thread_data(); + ssa_gpr_t *ssa_gpr = NULL; + sgx_exception_info_t *info = NULL; + uintptr_t sp, *new_sp = NULL; + size_t size = 0; + + if (tcs == NULL) goto default_handler; + + if(get_enclave_state() != ENCLAVE_INIT_DONE) + { + goto default_handler; + } + + // check if the exception is raised from 2nd phrase + if(thread_data->exception_flag == -1) { + goto default_handler; + } + + if ((TD2TCS(thread_data) != tcs) + || (((thread_data->first_ssa_gpr)&(~0xfff)) - SE_PAGE_SIZE) != (uintptr_t)tcs) { + goto default_handler; + } + + // no need to check the result of ssa_gpr because thread_data is always trusted + ssa_gpr = reinterpret_cast(thread_data->first_ssa_gpr); + + sp = ssa_gpr->REG(sp); + if(!is_stack_addr((void*)sp, 0)) // check stack overrun only, alignment will be checked after exception handled + { + g_enclave_state = ENCLAVE_CRASHED; + return SGX_ERROR_STACK_OVERRUN; + } + + size = 0; +#ifdef SE_GNU64 + size += 128; // preserve stack for red zone (128 bytes) +#endif + + // decrease the stack to give space for info + size += sizeof(sgx_exception_info_t); + sp -= size; + sp = sp & ~0xF; + + // check the decreased sp to make sure it is in the trusted stack range + if(!is_stack_addr((void *)sp, size)) + { + g_enclave_state = ENCLAVE_CRASHED; + return SGX_ERROR_STACK_OVERRUN; + } + + if(ssa_gpr->exit_info.valid != 1) + { // exception handlers are not allowed to call in a non-exception state + goto default_handler; + } + + info = (sgx_exception_info_t *)sp; + + // No need to check the stack as it have already been checked by assembly code + + // initialize the info with SSA[0] + info->exception_vector = (sgx_exception_vector_t)ssa_gpr->exit_info.vector; + info->exception_type = (sgx_exception_type_t)ssa_gpr->exit_info.exit_type; + + info->cpu_context.REG(ax) = ssa_gpr->REG(ax); + info->cpu_context.REG(cx) = ssa_gpr->REG(cx); + info->cpu_context.REG(dx) = ssa_gpr->REG(dx); + info->cpu_context.REG(bx) = ssa_gpr->REG(bx); + info->cpu_context.REG(sp) = ssa_gpr->REG(sp); + info->cpu_context.REG(bp) = ssa_gpr->REG(bp); + info->cpu_context.REG(si) = ssa_gpr->REG(si); + info->cpu_context.REG(di) = ssa_gpr->REG(di); + info->cpu_context.REG(flags) = ssa_gpr->REG(flags); + info->cpu_context.REG(ip) = ssa_gpr->REG(ip); +#ifdef SE_64 + info->cpu_context.r8 = ssa_gpr->r8; + info->cpu_context.r9 = ssa_gpr->r9; + info->cpu_context.r10 = ssa_gpr->r10; + info->cpu_context.r11 = ssa_gpr->r11; + info->cpu_context.r12 = ssa_gpr->r12; + info->cpu_context.r13 = ssa_gpr->r13; + info->cpu_context.r14 = ssa_gpr->r14; + info->cpu_context.r15 = ssa_gpr->r15; +#endif + + // decrease the stack to save the SSA[0]->ip + size = sizeof(uintptr_t); + new_sp = (uintptr_t *)(sp - size); + if(!is_stack_addr(new_sp, size)) + { + g_enclave_state = ENCLAVE_CRASHED; + return SGX_ERROR_STACK_OVERRUN; + } + ssa_gpr->REG(ip) = (size_t)internal_handle_exception; // prepare the ip for 2nd phrase handling + ssa_gpr->REG(sp) = (size_t)new_sp; // new stack for internal_handle_exception + ssa_gpr->REG(ax) = (size_t)info; // 1st parameter (info) for LINUX32 + ssa_gpr->REG(di) = (size_t)info; // 1st parameter (info) for LINUX64, LINUX32 also uses it while restoring the context + *new_sp = info->cpu_context.REG(ip); // for debugger to get call trace + + return SGX_SUCCESS; + +default_handler: + g_enclave_state = ENCLAVE_CRASHED; + return SGX_ERROR_ENCLAVE_CRASHED; +} diff --git a/sdk/trts/trts_version.cpp b/sdk/trts/trts_version.cpp new file mode 100644 index 0000000000..2012e1317e --- /dev/null +++ b/sdk/trts/trts_version.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_TRTS_VERSION_STR __CONCAT("SGX_TRTS_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_trts_version = SGX_TRTS_VERSION_STR; + +#ifdef __cplusplus +} +#endif diff --git a/sdk/trts/trts_xsave.cpp b/sdk/trts/trts_xsave.cpp new file mode 100644 index 0000000000..c7ac543682 --- /dev/null +++ b/sdk/trts/trts_xsave.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "arch.h" +#include "xsave.h" +#include "trts_inst.h" +#include "util.h" + +// 'SYNTHETIC_STATE' buffer size is (512 + 64 + 256) bytes +// 512 for fxsave buffer, +// 64 for xsave header, +// 256 for YMM State (16 * 16 bytes of each YMMH-register) +// and the buffer should be 64 byte aligned. +#define SYNTHETIC_STATE_SIZE (512 + 64 + 256) + +se_static_assert(SYNTHETIC_STATE_SIZE <= SE_PAGE_SIZE); + +static SE_DECLSPEC_ALIGN(4096) const uint16_t +SYNTHETIC_STATE[SYNTHETIC_STATE_SIZE/sizeof(uint16_t)] = { + 0x037F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1F80, 0, 0xFFFF, 0 +}; + +static int g_xsave_enabled; // flag to indicate whether xsave is enabled or not + +// EENTER will set xcr0 with secs.attr.xfrm, +// So use the xfeature mask from report instead of calling xgetbv +uint64_t get_xfeature_state() +{ + // target_info and report_data are useless + // we only need to make sure their alignment and within enclave + // so set the pointers to SYNTHETIC_STATE + sgx_target_info_t *target_info = (sgx_target_info_t *)SYNTHETIC_STATE; + sgx_report_data_t *report_data = (sgx_report_data_t *)SYNTHETIC_STATE; + uint8_t buffer[sizeof(sgx_report_t) + REPORT_ALIGN_SIZE -1] = {0}; + sgx_report_t *report = (sgx_report_t *)ROUND_TO((size_t)buffer, REPORT_ALIGN_SIZE); + + do_ereport(target_info, report_data, report); + + g_xsave_enabled = (report->body.attributes.xfrm == SGX_XFRM_LEGACY) ? 0 : 1; + uint64_t xfrm = report->body.attributes.xfrm; + + // no secrets in target_info, report_data, and report. no need to clear them before return + // tlibc functions cannot be used before calling init_optimized_libs(). + + return xfrm; +} + +// save_and_clean_xfeature_regs() +// do fwait, fxsave, and then clean the extended feature registers +// Parameters: +// buffer - If the pointer is not NULL, save the CPU state to the memory +// Return Value: +// none +void save_and_clean_xfeature_regs(uint8_t *buffer) +{ + do_fwait(); + + if(buffer != 0) + { + uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); + do_fxsave(buf); + } + + if(g_xsave_enabled) + { + do_xrstor(SYNTHETIC_STATE); + } + else + { + do_fxrstor(SYNTHETIC_STATE); + } +} +// restore_xfeature_regs() +// restore the extended feature registers +// +void restore_xfeature_regs(const uint8_t *buffer) +{ + if(buffer != 0) + { + uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); + do_fxrstor(buf); + } +} diff --git a/sdk/tseal/linux/Makefile b/sdk/tseal/linux/Makefile new file mode 100644 index 0000000000..596a0d59c3 --- /dev/null +++ b/sdk/tseal/linux/Makefile @@ -0,0 +1,60 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +include ../../../buildenv.mk + +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-rtti -fno-exceptions + +CPPFLAGS := -I$(COMMON_DIR)/inc/ \ + -I$(COMMON_DIR)/inc/internal/ \ + -I$(COMMON_DIR)/inc/tlibc \ + -I../ + +OBJ1 := tSeal.o tSeal_aad.o tSeal_internal.o tSeal_util.o +OBJS := $(OBJ1) + +LIBTSEAL := libtSeal.a + +.PHONY: all +all: $(LIBTSEAL) + +$(LIBTSEAL): $(OBJS) + $(AR) rcs $@ $^ + +$(OBJS): %.o: ../%.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + +.PHONY: clean +clean: + @$(RM) $(OBJS) $(LIBTSEAL) + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/tseal/tSeal.cpp b/sdk/tseal/tSeal.cpp new file mode 100644 index 0000000000..87fac83147 --- /dev/null +++ b/sdk/tseal/tSeal.cpp @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +// tSeal.cpp - Trusted Sealing Routines + +#include "sgx_tseal.h" +#include +#include +#include "sgx_trts.h" +#include "sgx_report.h" +#include "se_cdefs.h" +#include "sgx_utils.h" +#include "tSeal_internal.h" + +extern "C" sgx_status_t sgx_seal_data(const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, const uint32_t text2encrypt_length, + const uint8_t *p_text2encrypt, const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + sgx_attributes_t attribute_mask; + attribute_mask.flags = SGX_FLAGS_RESERVED | SGX_FLAGS_INITTED | SGX_FLAGS_DEBUG; + attribute_mask.xfrm = 0x0; + + err = sgx_seal_data_ex(SGX_KEYPOLICY_MRSIGNER, attribute_mask, TSEAL_DEFAULT_MISCMASK, additional_MACtext_length, + p_additional_MACtext, text2encrypt_length, p_text2encrypt, sealed_data_size, p_sealed_data); + return err; +} + +extern "C" sgx_status_t sgx_seal_data_ex(const uint16_t key_policy, + const sgx_attributes_t attribute_mask, + const sgx_misc_select_t misc_mask, + const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, const uint32_t text2encrypt_length, + const uint8_t *p_text2encrypt, const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + sgx_report_t report; + sgx_key_id_t keyID; + sgx_key_request_t tmp_key_request; + uint8_t payload_iv[SGX_SEAL_IV_SIZE]; + memset(&payload_iv, 0, sizeof(payload_iv)); + + + uint32_t sealedDataSize = sgx_calc_sealed_data_size(additional_MACtext_length,text2encrypt_length); + // Check for overflow + if (sealedDataSize == UINT32_MAX) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // + // Check parameters + // + // check key_request->key_policy reserved bits are not set and one of policy bits are set + if ((key_policy & ~(SGX_KEYPOLICY_MRENCLAVE | SGX_KEYPOLICY_MRSIGNER)) || + ((key_policy & (SGX_KEYPOLICY_MRENCLAVE | SGX_KEYPOLICY_MRSIGNER)) == 0)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ( !(attribute_mask.flags & SGX_FLAGS_INITTED) + || !(attribute_mask.flags & SGX_FLAGS_DEBUG) ) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ((additional_MACtext_length > 0) && (p_additional_MACtext == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ((text2encrypt_length == 0) || (p_text2encrypt == NULL) || (!sgx_is_within_enclave(p_text2encrypt,text2encrypt_length))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // Ensure sealed data blob is within an enclave during the sealing process + if ((p_sealed_data == NULL) || (!sgx_is_within_enclave(p_sealed_data,sealed_data_size))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // Ensure aad data does not cross enclave boundary + if ((additional_MACtext_length > 0) && + (!(sgx_is_within_enclave(p_additional_MACtext,additional_MACtext_length) || sgx_is_outside_enclave(p_additional_MACtext, additional_MACtext_length)))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if (sealedDataSize != sealed_data_size) + { + return SGX_ERROR_INVALID_PARAMETER; + } + memset(&report, 0, sizeof(sgx_report_t)); + memset(p_sealed_data, 0, sealedDataSize); + memset(&keyID, 0, sizeof(sgx_key_id_t)); + memset(&tmp_key_request, 0, sizeof(sgx_key_request_t)); + + // Get the report to obtain isv_svn and cpu_svn + err = sgx_create_report(NULL, NULL, &report); + if (err != SGX_SUCCESS) + { + goto clear_return; + } + + // Get a random number to populate the key_id of the key_request + err = sgx_read_rand(reinterpret_cast(&keyID), sizeof(sgx_key_id_t)); + if (err != SGX_SUCCESS) + { + goto clear_return; + } + + memcpy(&(tmp_key_request.cpu_svn), &(report.body.cpu_svn), sizeof(sgx_cpu_svn_t)); + memcpy(&(tmp_key_request.isv_svn), &(report.body.isv_svn), sizeof(sgx_isv_svn_t)); + tmp_key_request.key_name = SGX_KEYSELECT_SEAL; + tmp_key_request.key_policy = key_policy; + tmp_key_request.attribute_mask.flags = attribute_mask.flags; + tmp_key_request.attribute_mask.xfrm = attribute_mask.xfrm; + memcpy(&(tmp_key_request.key_id), &keyID, sizeof(sgx_key_id_t)); + tmp_key_request.misc_mask = misc_mask; + + err = sgx_seal_data_iv(additional_MACtext_length, p_additional_MACtext, + text2encrypt_length, p_text2encrypt, payload_iv, &tmp_key_request, p_sealed_data); + + if (err == SGX_SUCCESS) + { + // Copy data from the temporary key request buffer to the sealed data blob + memcpy(&(p_sealed_data->key_request), &tmp_key_request, sizeof(sgx_key_request_t)); + } +clear_return: + // Clear temp state + memset_s(&report, sizeof(sgx_report_t), 0, sizeof(sgx_report_t)); + memset_s(&keyID, sizeof(sgx_key_id_t), 0, sizeof(sgx_key_id_t)); + return err; +} + +extern "C" sgx_status_t sgx_unseal_data(const sgx_sealed_data_t *p_sealed_data, uint8_t *p_additional_MACtext, + uint32_t *p_additional_MACtext_length, uint8_t *p_decrypted_text, uint32_t *p_decrypted_text_length) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + // Ensure the the sgx_sealed_data_t members are all inside enclave before using them. + if ((p_sealed_data == NULL) || (!sgx_is_within_enclave(p_sealed_data,sizeof(sgx_sealed_data_t)))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + uint32_t encrypt_text_length = sgx_get_encrypt_txt_len(p_sealed_data); + if(encrypt_text_length == UINT32_MAX) + { + return SGX_ERROR_MAC_MISMATCH; // Return error indicating the blob is corrupted + } + uint32_t add_text_length = sgx_get_add_mac_txt_len(p_sealed_data); + if(add_text_length == UINT32_MAX) + { + return SGX_ERROR_MAC_MISMATCH; // Return error indicating the blob is corrupted + } + uint32_t sealedDataSize = sgx_calc_sealed_data_size(add_text_length,encrypt_text_length); + if (sealedDataSize == UINT32_MAX) + { + return SGX_ERROR_MAC_MISMATCH; // Return error indicating the blob is corrupted + } + + // + // Check parameters + // + // Ensure sealed data blob is within an enclave during the sealing process + if (!sgx_is_within_enclave(p_sealed_data,sealedDataSize)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ((add_text_length > 0) && ((p_additional_MACtext == NULL) || (p_additional_MACtext_length == NULL))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ((encrypt_text_length < 1) || (p_decrypted_text == NULL) || (p_decrypted_text_length == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if (!sgx_is_within_enclave(p_decrypted_text,encrypt_text_length)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if (!sgx_is_within_enclave(p_decrypted_text_length,sizeof(p_decrypted_text_length))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // Ensure aad data does not cross enclave boundary + if ((add_text_length > 0) && + (!(sgx_is_within_enclave(p_additional_MACtext,add_text_length) || sgx_is_outside_enclave(p_additional_MACtext, add_text_length)))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ((*p_decrypted_text_length) < encrypt_text_length) + { + return SGX_ERROR_INVALID_PARAMETER; + } + uint32_t additional_MACtext_length = (NULL != p_additional_MACtext_length) ? *p_additional_MACtext_length : 0; + if (additional_MACtext_length < add_text_length) { + return SGX_ERROR_INVALID_PARAMETER; + } + + err = sgx_unseal_data_helper(p_sealed_data, p_additional_MACtext, add_text_length, + p_decrypted_text, encrypt_text_length); + if (err == SGX_SUCCESS) + { + *p_decrypted_text_length = encrypt_text_length; + if(p_additional_MACtext_length != NULL) + *p_additional_MACtext_length = add_text_length; + } + return err; +} + diff --git a/sdk/tseal/tSeal_aad.cpp b/sdk/tseal/tSeal_aad.cpp new file mode 100644 index 0000000000..426ecd758f --- /dev/null +++ b/sdk/tseal/tSeal_aad.cpp @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tseal.h" +#include "sgx_utils.h" +#include "sgx_trts.h" +#include "tSeal_internal.h" +#include +#include + + +extern "C" sgx_status_t sgx_mac_aadata(const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, + const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + sgx_attributes_t attribute_mask; + attribute_mask.flags = SGX_FLAGS_RESERVED | SGX_FLAGS_INITTED | SGX_FLAGS_DEBUG; + attribute_mask.xfrm = 0x0; + + err = sgx_mac_aadata_ex(SGX_KEYPOLICY_MRSIGNER, attribute_mask, TSEAL_DEFAULT_MISCMASK, additional_MACtext_length, + p_additional_MACtext, sealed_data_size, p_sealed_data); + return err; +} + +extern "C" sgx_status_t sgx_mac_aadata_ex(const uint16_t key_policy, + const sgx_attributes_t attribute_mask, + const sgx_misc_select_t misc_mask, + const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, + const uint32_t sealed_data_size, + sgx_sealed_data_t *p_sealed_data) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + sgx_report_t report; + sgx_key_id_t keyID; + sgx_key_request_t tmp_key_request; + uint8_t payload_iv[SGX_SEAL_IV_SIZE]; + memset(&payload_iv, 0, sizeof(payload_iv)); + + uint32_t sealedDataSize = sgx_calc_sealed_data_size(additional_MACtext_length, 0); + // Check for overflow + if (sealedDataSize == UINT32_MAX) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // + // Check parameters + // + // check key_request->key_policy reserved bits are not set and one of policy bits are set + if ((key_policy & ~(SGX_KEYPOLICY_MRENCLAVE | SGX_KEYPOLICY_MRSIGNER)) || + ((key_policy & (SGX_KEYPOLICY_MRENCLAVE | SGX_KEYPOLICY_MRSIGNER)) == 0)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if ((attribute_mask.flags & 0x3) != 0x3) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // The AAD must be provided + if ((additional_MACtext_length == 0) || (p_additional_MACtext == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // Ensure AAD does not cross enclave boundary + if (!(sgx_is_within_enclave(p_additional_MACtext, additional_MACtext_length) || + sgx_is_outside_enclave(p_additional_MACtext, additional_MACtext_length))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + // Ensure sealed data blob is within an enclave during the sealing process + if ((p_sealed_data == NULL) || (!sgx_is_within_enclave(p_sealed_data, sealed_data_size))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if (sealedDataSize != sealed_data_size) + { + return SGX_ERROR_INVALID_PARAMETER; + } + memset(&report, 0, sizeof(sgx_report_t)); + memset(p_sealed_data, 0, sealedDataSize); + memset(&keyID, 0, sizeof(sgx_key_id_t)); + memset(&tmp_key_request, 0, sizeof(sgx_key_request_t)); + + // Get the report to obtain isv_svn and cpu_svn + err = sgx_create_report(NULL, NULL, &report); + if (err != SGX_SUCCESS) + { + goto clear_return; + } + + // Get a random number to populate the key_id of the key_request + err = sgx_read_rand(reinterpret_cast(&keyID), sizeof(sgx_key_id_t)); + if (err != SGX_SUCCESS) + { + goto clear_return; + } + + memcpy(&(tmp_key_request.cpu_svn), &(report.body.cpu_svn), sizeof(sgx_cpu_svn_t)); + memcpy(&(tmp_key_request.isv_svn), &(report.body.isv_svn), sizeof(sgx_isv_svn_t)); + tmp_key_request.key_name = SGX_KEYSELECT_SEAL; + tmp_key_request.key_policy = key_policy; + tmp_key_request.attribute_mask.flags = attribute_mask.flags; + tmp_key_request.attribute_mask.xfrm = attribute_mask.xfrm; + memcpy(&(tmp_key_request.key_id), &keyID, sizeof(sgx_key_id_t)); + tmp_key_request.misc_mask = misc_mask; + + err = sgx_seal_data_iv(additional_MACtext_length, p_additional_MACtext, + 0, NULL, payload_iv, &tmp_key_request, p_sealed_data); + + if (err == SGX_SUCCESS) + { + // Copy data from the temporary key request buffer to the sealed data blob + memcpy(&(p_sealed_data->key_request), &tmp_key_request, sizeof(sgx_key_request_t)); + } + +clear_return: + // Clear temp state + memset_s(&report, sizeof(sgx_report_t), 0, sizeof(sgx_report_t)); + memset_s(&keyID, sizeof(sgx_key_id_t), 0, sizeof(sgx_key_id_t)); + return err; +} + +extern "C" sgx_status_t sgx_unmac_aadata(const sgx_sealed_data_t *p_sealed_data, + uint8_t *p_additional_MACtext, + uint32_t *p_additional_MACtext_length) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + // Ensure the the sgx_sealed_data_t members are all inside enclave before using them. + if ((p_sealed_data == NULL) || (!sgx_is_within_enclave(p_sealed_data, sizeof(sgx_sealed_data_t)))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // If using this API, the sealed blob must have no encrypted data. + // So the encryt_text_length must be 0. + uint32_t encrypt_text_length = sgx_get_encrypt_txt_len(p_sealed_data); + if (encrypt_text_length != 0) + { + return SGX_ERROR_MAC_MISMATCH; // Return error indicating the blob is corrupted + } + + // The sealed blob must have AAD. So the add_text_length must not be 0. + uint32_t add_text_length = sgx_get_add_mac_txt_len(p_sealed_data); + if (add_text_length == UINT32_MAX || add_text_length == 0) + { + return SGX_ERROR_MAC_MISMATCH; // Return error indicating the blob is corrupted + } + uint32_t sealedDataSize = sgx_calc_sealed_data_size(add_text_length, encrypt_text_length); + if (sealedDataSize == UINT32_MAX) + { + return SGX_ERROR_MAC_MISMATCH; // Return error indicating the blob is corrupted + } + + // + // Check parameters + // + // Ensure sealed data blob is within an enclave during the sealing process + if (!sgx_is_within_enclave(p_sealed_data, sealedDataSize)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + if (p_additional_MACtext == NULL || p_additional_MACtext_length == NULL) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + // Ensure AAD does not cross enclave boundary + if (!(sgx_is_within_enclave(p_additional_MACtext, add_text_length) || + sgx_is_outside_enclave(p_additional_MACtext, add_text_length))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + uint32_t additional_MACtext_length = *p_additional_MACtext_length; + if (additional_MACtext_length < add_text_length) { + return SGX_ERROR_INVALID_PARAMETER; + } + + err = sgx_unseal_data_helper(p_sealed_data, p_additional_MACtext, add_text_length, + NULL, encrypt_text_length); + if (err == SGX_SUCCESS) + { + *p_additional_MACtext_length = add_text_length; + } + return err; +} diff --git a/sdk/tseal/tSeal_internal.cpp b/sdk/tseal/tSeal_internal.cpp new file mode 100644 index 0000000000..6e3bbe7793 --- /dev/null +++ b/sdk/tseal/tSeal_internal.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + + +#include "sgx_tseal.h" +#include "tSeal_internal.h" +#include "sgx_utils.h" +#include + + +// sgx_seal_data_iv +// +// Parameters: +// additional_MACtext_length - [IN] length of the plaintext data stream in bytes +// p_additional_MACtext - [IN] pointer to the plaintext data stream to be GCM protected +// text2encrypt_length - [IN] length of the data stream to encrypt in bytes +// p_text2encrypt - [IN] pointer to data stream to encrypt +// p_payload_iv - [IN] Pointer to Initialization Vector to be used during AES GCM encryption +// p_key_request - [IN] Pointer to the key request structure to be utilized to obtain the SEAL key +// p_sealed_data - [OUT] pointer to the sealed data structure containing protected data +// +// Return Value: +// sgx_status_t - SGX Error code +sgx_status_t sgx_seal_data_iv(const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, const uint32_t text2encrypt_length, + const uint8_t *p_text2encrypt, const uint8_t *p_payload_iv, + const sgx_key_request_t* p_key_request, sgx_sealed_data_t *p_sealed_data) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + + // Parameter checking performed in sgx_seal_data + + // Get the seal key + sgx_key_128bit_t seal_key; + memset(&seal_key, 0, sizeof(sgx_key_128bit_t)); + err = sgx_get_key(p_key_request, &seal_key); + if (err != SGX_SUCCESS) + { + // Clear temp state + memset_s(&seal_key, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + if (err != SGX_ERROR_OUT_OF_MEMORY) + err = SGX_ERROR_UNEXPECTED; + return err; + } + + err = sgx_rijndael128GCM_encrypt(&seal_key, p_text2encrypt, text2encrypt_length, + reinterpret_cast(&(p_sealed_data->aes_data.payload)), p_payload_iv, + SGX_SEAL_IV_SIZE, p_additional_MACtext, additional_MACtext_length, + &(p_sealed_data->aes_data.payload_tag)); + + if (err == SGX_SUCCESS) + { + // Copy additional MAC text + uint8_t* p_aad = NULL; + if (additional_MACtext_length > 0) + { + p_aad = &(p_sealed_data->aes_data.payload[text2encrypt_length]); + memcpy(p_aad, p_additional_MACtext, additional_MACtext_length); + } + + // populate the plain_text_offset, payload_size in the data_blob + p_sealed_data->plain_text_offset = text2encrypt_length; + p_sealed_data->aes_data.payload_size = additional_MACtext_length + text2encrypt_length; + } + // Clear temp state + memset_s(&seal_key, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + return err; +} + +// sgx_unseal_data_helper +// +// Parameters: +// p_sealed_data - [IN] pointer to the sealed data structure containing protected data +// p_additional_MACtext - [OUT] pointer to the plaintext data stream which was GCM protected +// additional_MACtext_length - [IN] length of the plaintext data stream in bytes +// p_decrypted_text - [OUT] pointer to decrypted data stream +// decrypted_text_length - [IN] length of the decrypted data stream to encrypt in bytes +// +// Return Value: +// sgx_status_t - SGX Error code +sgx_status_t sgx_unseal_data_helper(const sgx_sealed_data_t *p_sealed_data, uint8_t *p_additional_MACtext, + uint32_t additional_MACtext_length, uint8_t *p_decrypted_text, uint32_t decrypted_text_length) +{ + sgx_status_t err = SGX_ERROR_UNEXPECTED; + sgx_key_128bit_t seal_key; + memset(&seal_key, 0, sizeof(sgx_key_128bit_t)); + uint8_t payload_iv[SGX_SEAL_IV_SIZE]; + memset(&payload_iv, 0, SGX_SEAL_IV_SIZE); + + if (decrypted_text_length > 0) + memset(p_decrypted_text, 0, decrypted_text_length); + + if (additional_MACtext_length > 0) + memset(p_additional_MACtext, 0, additional_MACtext_length); + + // Get the seal key + err = sgx_get_key(&p_sealed_data->key_request, &seal_key); + if (err != SGX_SUCCESS) + { + // Clear temp state + memset_s(&seal_key, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + // Provide only error codes that the calling code could act on + if ((err == SGX_ERROR_INVALID_CPUSVN) || (err == SGX_ERROR_INVALID_ISVSVN) || (err == SGX_ERROR_OUT_OF_MEMORY)) + return err; + // Return error indicating the blob is corrupted + return SGX_ERROR_MAC_MISMATCH; + } + err = sgx_rijndael128GCM_decrypt(&seal_key, const_cast(p_sealed_data->aes_data.payload), + decrypted_text_length, p_decrypted_text, &payload_iv[0], SGX_SEAL_IV_SIZE, + const_cast(&(p_sealed_data->aes_data.payload[decrypted_text_length])), additional_MACtext_length, + const_cast(&p_sealed_data->aes_data.payload_tag)); + + if (err != SGX_SUCCESS) + { + // Clear temp state + memset_s(&seal_key, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + return err; + } + + if (additional_MACtext_length > 0) + { + memcpy(p_additional_MACtext, &(p_sealed_data->aes_data.payload[decrypted_text_length]), additional_MACtext_length); + } + // Clear temp state + memset_s(&seal_key, sizeof(sgx_key_128bit_t), 0, sizeof(sgx_key_128bit_t)); + return SGX_SUCCESS; +} \ No newline at end of file diff --git a/sdk/tseal/tSeal_internal.h b/sdk/tseal/tSeal_internal.h new file mode 100644 index 0000000000..5f9686da29 --- /dev/null +++ b/sdk/tseal/tSeal_internal.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _TSEAL_INTERNAL_H_ +#define _TSEAL_INTERNAL_H_ + +#include +#include "sgx_tseal.h" + +/* set MISCMASK.exinfo_bit = 0 for data migration to the enclave + built with the SDK that supports exinfo bit */ +#define SGX_MISCSEL_EXINFO 0x00000001 /* report #PF and #GP inside enclave */ +#define TSEAL_DEFAULT_MISCMASK (~SGX_MISCSEL_EXINFO) + +#ifdef __cplusplus +extern "C" { +#endif + + sgx_status_t sgx_seal_data_iv(const uint32_t additional_MACtext_length, + const uint8_t *p_additional_MACtext, const uint32_t text2encrypt_length, + const uint8_t *p_text2encrypt, const uint8_t *p_payload_iv, + const sgx_key_request_t* p_key_request, sgx_sealed_data_t *p_sealed_data); + + sgx_status_t sgx_unseal_data_helper(const sgx_sealed_data_t *p_sealed_data, uint8_t *p_additional_MACtext, + uint32_t additional_MACtext_length, uint8_t *p_decrypted_text, + uint32_t decrypted_text_length); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sdk/tseal/tSeal_util.cpp b/sdk/tseal/tSeal_util.cpp new file mode 100644 index 0000000000..4b17d7791b --- /dev/null +++ b/sdk/tseal/tSeal_util.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "sgx_tseal.h" +#ifndef UINT32_MAX +#define UINT32_MAX 0xffffffffU +#endif + +uint32_t sgx_calc_sealed_data_size(const uint32_t add_mac_txt_size, const uint32_t txt_encrypt_size) +{ + if(add_mac_txt_size > UINT32_MAX - txt_encrypt_size) + return UINT32_MAX; + uint32_t payload_size = add_mac_txt_size + txt_encrypt_size; //Calculate the payload size + + if(payload_size > UINT32_MAX - sizeof(sgx_sealed_data_t)) + return UINT32_MAX; + return (uint32_t)(sizeof(sgx_sealed_data_t) + payload_size); +} + +uint32_t sgx_get_add_mac_txt_len(const sgx_sealed_data_t* p_sealed_data) +{ + if(p_sealed_data == NULL) + return UINT32_MAX; + + uint32_t data_size = p_sealed_data->aes_data.payload_size - p_sealed_data->plain_text_offset; + if (data_size > p_sealed_data->aes_data.payload_size) + return UINT32_MAX; + return data_size; +} + +uint32_t sgx_get_encrypt_txt_len(const sgx_sealed_data_t* p_sealed_data) +{ + return ((p_sealed_data == NULL) ? UINT32_MAX : p_sealed_data->plain_text_offset); +} diff --git a/sdk/ukey_exchange/Makefile b/sdk/ukey_exchange/Makefile new file mode 100644 index 0000000000..a98b73cbb2 --- /dev/null +++ b/sdk/ukey_exchange/Makefile @@ -0,0 +1,70 @@ +# +# Copyright (C) 2011-2016 Intel Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +TOP_DIR = ../.. +include $(TOP_DIR)/buildenv.mk + +CFLAGS += -Werror +CXXFLAGS += -Werror + +INCLUDE += -I$(COMMON_DIR)/inc/internal \ + -I$(COMMON_DIR)/inc + +INCLUDE += -I$(LINUX_EXTERNAL_DIR)/crypto_px/include + +vpath %.cpp $(COMMON_DIR)/src + +vpath %.c $(TOP_DIR)/common/src + +CXXFLAGS += -fPIC -fno-rtti $(INCLUDE) +CFLAGS += -fPIC $(INCLUDE) + +OBJ := ukey_exchange.o se_thread.o ukey_exchange_version.o + +LIBNAME := libsgx_ukey_exchange.a + +.PHONY: all +all: $(LIBNAME) | $(BUILD_DIR) + $(CP) $< $| + +$(LIBNAME): $(OBJ) + $(AR) rcsD $@ $^ + +$(BUILD_DIR): + @$(MKDIR) $@ + +.PHONY: clean +clean: + @$(RM) $(OBJ) + @$(RM) $(LIBNAME) $(BUILD_DIR)/$(LIBNAME) + +.PHONY: rebuild +rebuild: clean all diff --git a/sdk/ukey_exchange/ukey_exchange.cpp b/sdk/ukey_exchange/ukey_exchange.cpp new file mode 100644 index 0000000000..82ccd5907f --- /dev/null +++ b/sdk/ukey_exchange/ukey_exchange.cpp @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef __STDINT_LIMITS +#define __STDINT_LIMITS +#endif +//for Linux +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif +#include +#include + +#include "se_memcpy.h" +#include "sgx_ukey_exchange.h" +#include "sgx_uae_service.h" +#include "sgx_ecp_types.h" +#include "se_lock.hpp" + +#include "se_cdefs.h" +SGX_ACCESS_VERSION(ukey_exchange, 1) + +static sgx_target_info_t g_qe_target_info; +static Mutex g_ukey_spin_lock; + + +#ifndef ERROR_BREAK +#define ERROR_BREAK(x) if(x){break;} +#endif +#ifndef SAFE_FREE +#define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}} +#endif + +sgx_status_t sgx_ra_get_msg1( + sgx_ra_context_t context, + sgx_enclave_id_t eid, + sgx_ecall_get_ga_trusted_t p_get_ga, + sgx_ra_msg1_t *p_msg1) +{ + if(!p_msg1 || !p_get_ga) + return SGX_ERROR_INVALID_PARAMETER; + sgx_epid_group_id_t gid = {0}; + sgx_target_info_t qe_target_info; + + memset(&qe_target_info, 0, sizeof(qe_target_info)); + sgx_status_t ret = sgx_init_quote(&qe_target_info, &gid); + if(SGX_SUCCESS != ret) + return ret; + g_ukey_spin_lock.lock(); + if(memcpy_s(&g_qe_target_info, sizeof(g_qe_target_info), + &qe_target_info, sizeof(qe_target_info)) != 0) + { + g_ukey_spin_lock.unlock(); + return SGX_ERROR_UNEXPECTED; + } + g_ukey_spin_lock.unlock(); + if(memcpy_s(&p_msg1->gid, sizeof(p_msg1->gid), &gid, sizeof(gid)) != 0) + return SGX_ERROR_UNEXPECTED; + sgx_ec256_public_t g_a; + sgx_status_t status = SGX_ERROR_UNEXPECTED; + memset(&g_a, 0, sizeof(g_a)); + ret = p_get_ga(eid, &status, context, &g_a); + if(SGX_SUCCESS !=ret) + return ret; + if (SGX_SUCCESS != status) + return status; + memcpy_s(&p_msg1->g_a, sizeof(p_msg1->g_a), &g_a, sizeof(g_a)); + return SGX_SUCCESS; +} + +sgx_status_t sgx_ra_proc_msg2( + sgx_ra_context_t context, + sgx_enclave_id_t eid, + sgx_ecall_proc_msg2_trusted_t p_proc_msg2, + sgx_ecall_get_msg3_trusted_t p_get_msg3, + const sgx_ra_msg2_t *p_msg2, + uint32_t msg2_size, + sgx_ra_msg3_t **pp_msg3, + uint32_t *p_msg3_size) +{ + if(!p_msg2 || !p_proc_msg2 || !p_get_msg3 || !p_msg3_size || !pp_msg3) + return SGX_ERROR_INVALID_PARAMETER; + if(msg2_size != sizeof(sgx_ra_msg2_t) + p_msg2->sig_rl_size) + return SGX_ERROR_INVALID_PARAMETER; + + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + sgx_report_t report; + sgx_ra_msg3_t *p_msg3 = NULL; + + memset(&report, 0, sizeof(report)); + + { + sgx_quote_nonce_t nonce; + sgx_report_t qe_report; + sgx_target_info_t qe_target_info; + + memset(&nonce, 0, sizeof(nonce)); + memset(&qe_report, 0, sizeof(qe_report)); + + sgx_status_t status; + g_ukey_spin_lock.lock(); + if(memcpy_s(&qe_target_info, sizeof(qe_target_info), + &g_qe_target_info, sizeof(g_qe_target_info)) != 0) + { + ret = SGX_ERROR_UNEXPECTED; + g_ukey_spin_lock.unlock(); + goto CLEANUP; + } + g_ukey_spin_lock.unlock(); + ret = p_proc_msg2(eid, &status, context, p_msg2, &qe_target_info, + &report, &nonce); + if(SGX_SUCCESS!=ret) + { + goto CLEANUP; + } + if(SGX_SUCCESS!=status) + { + ret = status; + goto CLEANUP; + } + + uint32_t quote_size = 0; + ret = sgx_get_quote_size(p_msg2->sig_rl_size ? + const_cast(p_msg2->sig_rl):NULL, + "e_size); + if(SGX_SUCCESS!=ret) + { + goto CLEANUP; + } + + //check integer overflow of quote_size + if (UINT32_MAX - quote_size < sizeof(sgx_ra_msg3_t)) + { + ret = SGX_ERROR_UNEXPECTED; + goto CLEANUP; + } + uint32_t msg3_size = static_cast(sizeof(sgx_ra_msg3_t)) + quote_size; + p_msg3 = (sgx_ra_msg3_t *)malloc(msg3_size); + if(!p_msg3) + { + ret = SGX_ERROR_OUT_OF_MEMORY; + goto CLEANUP; + } + memset(p_msg3, 0, msg3_size); + + ret = sgx_get_quote(&report, + p_msg2->quote_type == SGX_UNLINKABLE_SIGNATURE ? + SGX_UNLINKABLE_SIGNATURE : SGX_LINKABLE_SIGNATURE, + const_cast(&p_msg2->spid), + &nonce, + p_msg2->sig_rl_size ? + const_cast(p_msg2->sig_rl):NULL, + p_msg2->sig_rl_size, + &qe_report, + (sgx_quote_t *)p_msg3->quote, + quote_size); + if(SGX_SUCCESS!=ret) + { + goto CLEANUP; + } + + ret = p_get_msg3(eid, &status, context, quote_size, &qe_report, + p_msg3, msg3_size); + if(SGX_SUCCESS!=ret) + { + goto CLEANUP; + } + if(SGX_SUCCESS!=status) + { + ret = status; + goto CLEANUP; + } + *pp_msg3 = p_msg3; + *p_msg3_size = msg3_size; + } + +CLEANUP: + if(ret) + SAFE_FREE(p_msg3); + return ret; +} diff --git a/sdk/ukey_exchange/ukey_exchange_version.cpp b/sdk/ukey_exchange/ukey_exchange_version.cpp new file mode 100644 index 0000000000..05752e7e98 --- /dev/null +++ b/sdk/ukey_exchange/ukey_exchange_version.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011-2016 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_UKEY_EXCHANGE_VERSION_STR __CONCAT("SGX_UKEY_EXCHANGE_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_ukey_exchange_version = SGX_UKEY_EXCHANGE_VERSION_STR; + +#ifdef __cplusplus +} +#endif